Repository: chettrick/discobsd Branch: master Commit: fa3377cacc73 Files: 2067 Total size: 19.8 MB Directory structure: gitextract_mjluyb90/ ├── .gitignore ├── LICENSE ├── Makefile ├── README.md ├── bin/ │ ├── Makefile │ ├── csh/ │ │ ├── Makefile │ │ ├── alloc.c │ │ ├── printf.c │ │ ├── sh.c │ │ ├── sh.char.c │ │ ├── sh.char.h │ │ ├── sh.dir.c │ │ ├── sh.dir.h │ │ ├── sh.dol.c │ │ ├── sh.err.c │ │ ├── sh.exec.c │ │ ├── sh.exec.h │ │ ├── sh.exec2.c │ │ ├── sh.exp.c │ │ ├── sh.file.c │ │ ├── sh.func.c │ │ ├── sh.glob.c │ │ ├── sh.h │ │ ├── sh.hist.c │ │ ├── sh.init.c │ │ ├── sh.lex.c │ │ ├── sh.local.h │ │ ├── sh.misc.c │ │ ├── sh.parse.c │ │ ├── sh.print.c │ │ ├── sh.proc.c │ │ ├── sh.proc.h │ │ ├── sh.sem.c │ │ ├── sh.set.c │ │ └── sh.time.c │ ├── date/ │ │ └── date.c │ └── date2/ │ ├── .gitignore │ ├── Makefile │ └── date.c ├── distrib/ │ ├── .gitignore │ ├── base/ │ │ ├── mi │ │ └── mi.home │ ├── home/ │ │ ├── .gitignore │ │ └── README.txt │ ├── notes/ │ │ └── ANNOUNCEMENT.md │ ├── pic32/ │ │ ├── .gitignore │ │ ├── README.md │ │ └── md.pic32 │ └── stm32/ │ ├── .gitignore │ ├── README.md │ └── md.stm32 ├── etc/ │ ├── MAKEDEV │ ├── MAKEDEV.local │ ├── Makefile │ ├── fstab │ ├── gettytab │ ├── group │ ├── motd │ ├── passwd │ ├── rc │ ├── rc.local │ ├── root/ │ │ └── dot.profile │ ├── shadow │ ├── shells │ ├── syslog.conf │ └── ttys ├── games/ │ ├── Makefile │ ├── hunt/ │ │ ├── Makefile │ │ ├── README │ │ ├── answer.c │ │ ├── connect.c │ │ ├── draw.c │ │ ├── driver.c │ │ ├── execute.c │ │ ├── expl.c │ │ ├── extern.c │ │ ├── hunt.6 │ │ ├── hunt.c │ │ ├── hunt.h │ │ ├── makemaze.c │ │ ├── pathname.c │ │ ├── playit.c │ │ ├── shots.c │ │ └── terminal.c │ ├── phantasia/ │ │ ├── Makefile │ │ ├── Makefile-linux │ │ ├── fight.c │ │ ├── func0.c │ │ ├── func1.c │ │ ├── func2.c │ │ ├── main.c │ │ ├── monsters │ │ ├── phant.h │ │ ├── phant.nr │ │ ├── phant_run.c │ │ ├── setfiles.c │ │ └── test.c │ └── warp/ │ ├── .gitignore │ ├── EXTERN.h │ ├── INTERN.h │ ├── MANIFEST │ ├── Makefile │ ├── Makefile-linux │ ├── README │ ├── bang.c │ ├── bang.h │ ├── init.c │ ├── init.h │ ├── intrp.c │ ├── intrp.h │ ├── move.c │ ├── move.h │ ├── object.c │ ├── object.h │ ├── patchlevel.h │ ├── play.c │ ├── play.h │ ├── score.c │ ├── score.h │ ├── sig.c │ ├── sig.h │ ├── sm.c │ ├── smp.0 │ ├── smp.1 │ ├── smp.2 │ ├── smp.3 │ ├── smp.4 │ ├── smp.5 │ ├── smp.6 │ ├── smp.7 │ ├── term.c │ ├── term.h │ ├── them.c │ ├── them.h │ ├── us.c │ ├── us.h │ ├── util.c │ ├── util.h │ ├── version.c │ ├── version.h │ ├── warp.6 │ ├── warp.c │ ├── warp.doc │ ├── warp.h │ ├── warp.man │ ├── warp.news │ ├── weapon.c │ └── weapon.h ├── include/ │ ├── .gitignore │ ├── Makefile │ ├── Makefile.install │ ├── a.out.h │ ├── alloca.h │ ├── ar.h │ ├── arpa/ │ │ └── inet.h │ ├── assert.h │ ├── ctype.h │ ├── curses.h │ ├── fcntl.h │ ├── float.h │ ├── fstab.h │ ├── grp.h │ ├── kmem.h │ ├── lastlog.h │ ├── libgen.h │ ├── limits.h │ ├── math.h │ ├── mtab.h │ ├── ndbm.h │ ├── netinet/ │ │ └── in.h │ ├── nlist.h │ ├── paths.h │ ├── psout.h │ ├── pwd.h │ ├── ranlib.h │ ├── regexp.h │ ├── setjmp.h │ ├── sgtty.h │ ├── smallc/ │ │ ├── curses.h │ │ ├── fcntl.h │ │ ├── signal.h │ │ ├── stdio.h │ │ ├── sys/ │ │ │ ├── gpio.h │ │ │ └── spi.h │ │ └── wiznet.h │ ├── stdarg.h │ ├── stdbool.h │ ├── stddef.h │ ├── stdio.h │ ├── stdlib.h │ ├── string.h │ ├── strings.h │ ├── struct.h │ ├── syscall.h │ ├── sysexits.h │ ├── tcl/ │ │ └── tcl.h │ ├── term.h │ ├── termios-todo.h │ ├── time.h │ ├── ttyent.h │ ├── tzfile.h │ ├── unistd.h │ ├── utmp.h │ ├── vmf.h │ └── wiznet/ │ ├── client.h │ ├── ethernet.h │ ├── server.h │ ├── socket.h │ ├── udp.h │ └── w5100.h ├── lib/ │ ├── Makefile │ ├── elf32-arm.ld │ ├── elf32-mips.ld │ ├── libc/ │ │ ├── Makefile │ │ ├── arm/ │ │ │ ├── Makefile │ │ │ ├── gen/ │ │ │ │ ├── Makefile │ │ │ │ ├── _setjmp.S │ │ │ │ ├── htonl.S │ │ │ │ ├── htons.S │ │ │ │ ├── setjmp.S │ │ │ │ └── sigsetjmp.S │ │ │ ├── string/ │ │ │ │ ├── Makefile │ │ │ │ ├── memmove.S │ │ │ │ └── strcmp.S │ │ │ └── sys/ │ │ │ ├── Makefile │ │ │ ├── SYS.h │ │ │ ├── _brk.S │ │ │ ├── _exit.S │ │ │ ├── execl.c │ │ │ ├── execle.c │ │ │ ├── execv.c │ │ │ ├── pipe.S │ │ │ ├── ptrace.S │ │ │ ├── sbrk.c │ │ │ └── sigaction.S │ │ ├── compat/ │ │ │ ├── Makefile │ │ │ ├── creat.c │ │ │ ├── ftime.c │ │ │ ├── gethostid.c │ │ │ ├── memccpy.c │ │ │ ├── memchr.c │ │ │ ├── memcmp.c │ │ │ ├── memcpy.c │ │ │ ├── memset.c │ │ │ ├── nice.c │ │ │ ├── pause.c │ │ │ ├── rand.c │ │ │ ├── sethostid.c │ │ │ ├── setregid.c │ │ │ ├── setreuid.c │ │ │ ├── setrgid.c │ │ │ ├── setruid.c │ │ │ ├── sigcompat.c │ │ │ ├── strchr.c │ │ │ ├── strrchr.c │ │ │ ├── times.c │ │ │ ├── tmpnam.c │ │ │ └── utime.c │ │ ├── gen/ │ │ │ ├── Makefile │ │ │ ├── abort.c │ │ │ ├── abs.c │ │ │ ├── alarm.c │ │ │ ├── atof.c │ │ │ ├── atoi.c │ │ │ ├── atol.c │ │ │ ├── basename.c │ │ │ ├── bcmp.c │ │ │ ├── bcopy.c │ │ │ ├── bzero.c │ │ │ ├── calloc.c │ │ │ ├── closedir.c │ │ │ ├── crypt.c │ │ │ ├── ctime.c │ │ │ ├── ctype_.c │ │ │ ├── daemon.c │ │ │ ├── devname.c │ │ │ ├── dirname.c │ │ │ ├── ecvt.c │ │ │ ├── err.c │ │ │ ├── execvp.c │ │ │ ├── fabs.c │ │ │ ├── fakcu.c │ │ │ ├── ffs.c │ │ │ ├── frexp.c │ │ │ ├── fstab.c │ │ │ ├── gcvt.c │ │ │ ├── getenv.c │ │ │ ├── getgrent.c │ │ │ ├── getgrgid.c │ │ │ ├── getgrnam.c │ │ │ ├── getgrouplist.c │ │ │ ├── gethostname.c │ │ │ ├── getloadavg.c │ │ │ ├── getlogin.c │ │ │ ├── getmntinfo.c │ │ │ ├── getpagesize.c │ │ │ ├── getpass.c │ │ │ ├── getpwent.c │ │ │ ├── getttyent.c │ │ │ ├── getttynam.c │ │ │ ├── getusershell.c │ │ │ ├── getwd.c │ │ │ ├── index.c │ │ │ ├── initgroups.c │ │ │ ├── insque.c │ │ │ ├── isatty.c │ │ │ ├── isinf.c │ │ │ ├── isinff.c │ │ │ ├── isnan.c │ │ │ ├── isnanf.c │ │ │ ├── knlist.c │ │ │ ├── ldexp.c │ │ │ ├── malloc.c │ │ │ ├── mktemp.c │ │ │ ├── modf.c │ │ │ ├── modff.c │ │ │ ├── ndbm.c │ │ │ ├── nlist.c │ │ │ ├── opendir.c │ │ │ ├── perror.c │ │ │ ├── popen.c │ │ │ ├── psignal.c │ │ │ ├── qsort.c │ │ │ ├── random.c │ │ │ ├── readdir.c │ │ │ ├── regex.c │ │ │ ├── remque.c │ │ │ ├── rindex.c │ │ │ ├── scandir.c │ │ │ ├── seekdir.c │ │ │ ├── setenv.c │ │ │ ├── sethostname.c │ │ │ ├── setmode.c │ │ │ ├── siginterrupt.c │ │ │ ├── siglist.c │ │ │ ├── signal.c │ │ │ ├── sigsetops.c │ │ │ ├── sleep.c │ │ │ ├── strcasecmp.c │ │ │ ├── strcat.c │ │ │ ├── strcmp.c │ │ │ ├── strcpy.c │ │ │ ├── strdup.c │ │ │ ├── strftime.c │ │ │ ├── strlen.c │ │ │ ├── strncat.c │ │ │ ├── strncmp.c │ │ │ ├── strncpy.c │ │ │ ├── swab.c │ │ │ ├── sysctl.c │ │ │ ├── syslog.c │ │ │ ├── system.c │ │ │ ├── telldir.c │ │ │ ├── time.c │ │ │ ├── timezone.c │ │ │ ├── ttyname.c │ │ │ ├── ttyslot.c │ │ │ ├── ualarm.c │ │ │ ├── uname.c │ │ │ ├── usleep.c │ │ │ ├── valloc.c │ │ │ ├── wait.c │ │ │ ├── wait3.c │ │ │ └── waitpid.c │ │ ├── inet/ │ │ │ ├── Makefile │ │ │ ├── inet_addr.c │ │ │ ├── inet_lnaof.c │ │ │ ├── inet_maddr.c │ │ │ ├── inet_netof.c │ │ │ ├── inet_network.c │ │ │ └── inet_ntoa.c │ │ ├── mips/ │ │ │ ├── Makefile │ │ │ ├── gen/ │ │ │ │ ├── Makefile │ │ │ │ ├── _setjmp.S │ │ │ │ ├── htonl.S │ │ │ │ ├── htons.S │ │ │ │ ├── setjmp.S │ │ │ │ └── sigsetjmp.S │ │ │ ├── string/ │ │ │ │ ├── Makefile │ │ │ │ ├── bcmp.S │ │ │ │ ├── bcopy.S │ │ │ │ ├── bzero.S │ │ │ │ ├── ffs.S │ │ │ │ ├── index.S │ │ │ │ ├── memcpy.S │ │ │ │ ├── memmove.S │ │ │ │ ├── memset.S │ │ │ │ ├── rindex.S │ │ │ │ ├── strcmp.S │ │ │ │ └── strlen.S │ │ │ └── sys/ │ │ │ ├── Makefile │ │ │ ├── SYS.h │ │ │ ├── _brk.S │ │ │ ├── _exit.S │ │ │ ├── execl.c │ │ │ ├── execle.c │ │ │ ├── execv.c │ │ │ ├── pipe.S │ │ │ ├── ptrace.S │ │ │ ├── sbrk.c │ │ │ └── sigaction.S │ │ ├── net/ │ │ │ ├── Makefile │ │ │ ├── getnbyaddr.c │ │ │ ├── getnbyname.c │ │ │ ├── getnent.c │ │ │ ├── getpent.c │ │ │ ├── getpname.c │ │ │ ├── getproto.c │ │ │ ├── getsbyname.c │ │ │ ├── getsbyport.c │ │ │ ├── getsent.c │ │ │ ├── herror.c │ │ │ ├── hosttable/ │ │ │ │ ├── Makefile │ │ │ │ ├── gethnamadr.c │ │ │ │ └── gethostent.c │ │ │ ├── named/ │ │ │ │ ├── Makefile │ │ │ │ ├── gethnamadr.c │ │ │ │ └── sethostent.c │ │ │ ├── rcmd.c │ │ │ ├── res_comp.c │ │ │ ├── res_debug.c │ │ │ ├── res_init.c │ │ │ ├── res_mkquery.c │ │ │ ├── res_query.c │ │ │ ├── res_send.c │ │ │ ├── rexec.c │ │ │ └── ruserpass.c │ │ ├── ns/ │ │ │ ├── Makefile │ │ │ ├── ns_addr.c │ │ │ └── ns_ntoa.c │ │ ├── runtime/ │ │ │ ├── CREDITS.txt │ │ │ ├── LICENSE.txt │ │ │ ├── Makefile │ │ │ ├── README.txt │ │ │ ├── adddf3.c │ │ │ ├── addsf3.c │ │ │ ├── ashldi3.c │ │ │ ├── comparedf2.c │ │ │ ├── comparesf2.c │ │ │ ├── divdf3.c │ │ │ ├── divsf3.c │ │ │ ├── fixdfsi.c │ │ │ ├── fixsfsi.c │ │ │ ├── fixunsdfsi.c │ │ │ ├── fixunssfsi.c │ │ │ ├── floatsidf.c │ │ │ ├── floatsisf.c │ │ │ ├── floatunsidf.c │ │ │ ├── floatunsisf.c │ │ │ ├── fp_add_impl.inc │ │ │ ├── fp_fixint_impl.inc │ │ │ ├── fp_fixuint_impl.inc │ │ │ ├── fp_lib.h │ │ │ ├── fp_mul_impl.inc │ │ │ ├── int_endianness.h │ │ │ ├── int_lib.h │ │ │ ├── int_types.h │ │ │ ├── int_util.h │ │ │ ├── lshrdi3.c │ │ │ ├── muldf3.c │ │ │ ├── mulsf3.c │ │ │ ├── negdf2.c │ │ │ ├── negsf2.c │ │ │ ├── sc_case.S │ │ │ ├── subdf3.c │ │ │ └── subsf3.c │ │ ├── stdio/ │ │ │ ├── Makefile │ │ │ ├── clnup.c │ │ │ ├── clrerr.c │ │ │ ├── doprnt.c │ │ │ ├── doscan.c │ │ │ ├── exit.c │ │ │ ├── fdopen.c │ │ │ ├── feof.c │ │ │ ├── ferror.c │ │ │ ├── fgetc.c │ │ │ ├── fgets.c │ │ │ ├── filbuf.c │ │ │ ├── fileno.c │ │ │ ├── findiop.c │ │ │ ├── flsbuf.c │ │ │ ├── fopen.c │ │ │ ├── fprintf.c │ │ │ ├── fputc.c │ │ │ ├── fputs.c │ │ │ ├── fread.c │ │ │ ├── freopen.c │ │ │ ├── fseek.c │ │ │ ├── ftell.c │ │ │ ├── fwrite.c │ │ │ ├── getchar.c │ │ │ ├── gets.c │ │ │ ├── getw.c │ │ │ ├── printf.c │ │ │ ├── putchar.c │ │ │ ├── puts.c │ │ │ ├── putw.c │ │ │ ├── remove.c │ │ │ ├── rew.c │ │ │ ├── scanf.c │ │ │ ├── setbuf.c │ │ │ ├── setbuffer.c │ │ │ ├── setvbuf.c │ │ │ ├── snprintf.c │ │ │ ├── sprintf.c │ │ │ ├── strout.c │ │ │ ├── ungetc.c │ │ │ ├── vfprintf.c │ │ │ ├── vprintf.c │ │ │ └── vsprintf.c │ │ ├── stdlib/ │ │ │ ├── Makefile │ │ │ ├── getopt.c │ │ │ ├── getsubopt.c │ │ │ ├── strtod.c │ │ │ ├── strtol.c │ │ │ └── strtoul.c │ │ └── string/ │ │ ├── Makefile │ │ ├── strcspn.c │ │ ├── strerror.c │ │ ├── strlcat.c │ │ ├── strlcpy.c │ │ ├── strpbrk.c │ │ ├── strsep.c │ │ ├── strspn.c │ │ ├── strstr.c │ │ ├── strtok.c │ │ └── strtok_r.c │ ├── libc_aout/ │ │ ├── Makefile │ │ ├── libc/ │ │ │ └── Makefile │ │ ├── libcurses/ │ │ │ └── Makefile │ │ ├── libgpanel/ │ │ │ └── Makefile │ │ ├── libm/ │ │ │ └── Makefile │ │ ├── libreadline/ │ │ │ └── Makefile │ │ ├── libtermlib/ │ │ │ └── Makefile │ │ ├── libwiznet/ │ │ │ └── Makefile │ │ └── startup/ │ │ └── Makefile │ ├── libcurses/ │ │ ├── Makefile │ │ ├── addch.c │ │ ├── addstr.c │ │ ├── box.c │ │ ├── clear.c │ │ ├── clrtobot.c │ │ ├── clrtoeol.c │ │ ├── cr_put.c │ │ ├── cr_tty.c │ │ ├── curses.c │ │ ├── curses.ext │ │ ├── delch.c │ │ ├── deleteln.c │ │ ├── delwin.c │ │ ├── endwin.c │ │ ├── erase.c │ │ ├── fullname.c │ │ ├── getch.c │ │ ├── getstr.c │ │ ├── id_subwins.c │ │ ├── idlok.c │ │ ├── initscr.c │ │ ├── insch.c │ │ ├── insertln.c │ │ ├── longname.c │ │ ├── move.c │ │ ├── mvprintw.c │ │ ├── mvscanw.c │ │ ├── mvwin.c │ │ ├── newwin.c │ │ ├── overlay.c │ │ ├── overwrite.c │ │ ├── printw.c │ │ ├── putchar.c │ │ ├── refresh.c │ │ ├── scanw.c │ │ ├── scroll.c │ │ ├── standout.c │ │ ├── test.c │ │ ├── toucholap.c │ │ ├── touchwin.c │ │ ├── tstp.c │ │ └── unctrl.c │ ├── libgpanel/ │ │ ├── Makefile │ │ ├── char.c │ │ ├── circle.c │ │ ├── clear.c │ │ ├── fill.c │ │ ├── fill_triangle.c │ │ ├── gpanel.3 │ │ ├── image.c │ │ ├── line.c │ │ ├── open.c │ │ ├── pixel.c │ │ ├── rect.c │ │ ├── text.c │ │ └── text_width.c │ ├── libicache/ │ │ ├── icache.ld │ │ ├── icachec.c │ │ ├── icaches.s │ │ ├── license.txt │ │ └── readme.txt │ ├── libm/ │ │ ├── Makefile │ │ ├── asin.c │ │ ├── atan.c │ │ ├── erf.c │ │ ├── exp.c │ │ ├── fabs.c │ │ ├── floor.c │ │ ├── fmod.c │ │ ├── hypot.c │ │ ├── j0.c │ │ ├── j1.c │ │ ├── jn.c │ │ ├── log.c │ │ ├── pow.c │ │ ├── sin.c │ │ ├── sinh.c │ │ ├── sqrt.c │ │ ├── tan.c │ │ └── tanh.c │ ├── libreadline/ │ │ ├── LICENSE │ │ ├── Makefile │ │ ├── Makefile-unix │ │ ├── README │ │ ├── example.c │ │ ├── readline/ │ │ │ ├── history.h │ │ │ └── readline.h │ │ └── readline.c │ ├── libtcl/ │ │ ├── Makefile │ │ ├── doc/ │ │ │ ├── AddErrInfo.3 │ │ │ ├── AssembCmd.3 │ │ │ ├── Backslash.3 │ │ │ ├── Concat.3 │ │ │ ├── CrtCommand.3 │ │ │ ├── CrtInterp.3 │ │ │ ├── CrtPipelin.3 │ │ │ ├── CrtTrace.3 │ │ │ ├── Eval.3 │ │ │ ├── ExprLong.3 │ │ │ ├── Fork.3 │ │ │ ├── GetInt.3 │ │ │ ├── Hash.3 │ │ │ ├── History.3 │ │ │ ├── Interp.3 │ │ │ ├── SetResult.3 │ │ │ ├── SetVar.3 │ │ │ ├── SplitList.3 │ │ │ ├── StrMatch.3 │ │ │ ├── Tcl.n │ │ │ ├── TildeSubst.3 │ │ │ ├── TraceVar.3 │ │ │ ├── library.n │ │ │ └── man.macros │ │ ├── hash.h │ │ ├── internal.h │ │ ├── regexp.c │ │ ├── regexp.h │ │ ├── regpriv.h │ │ ├── regsub.c │ │ ├── tclassem.c │ │ ├── tclbasic.c │ │ ├── tclcmdah.c │ │ ├── tclcmdil.c │ │ ├── tclcmdmz.c │ │ ├── tclenv.c │ │ ├── tclexpr.c │ │ ├── tclget.c │ │ ├── tclglob.c │ │ ├── tclhash.c │ │ ├── tclparse.c │ │ ├── tclproc.c │ │ ├── tclunxaz.c │ │ ├── tclutil.c │ │ ├── tcluxstr.c │ │ ├── tcluxutl.c │ │ └── tclvar.c │ ├── libtermlib/ │ │ ├── Makefile │ │ ├── tc1.c │ │ ├── tc2.c │ │ ├── tc3.c │ │ ├── tcattr.c │ │ ├── termcap/ │ │ │ ├── .gitignore │ │ │ ├── Makefile │ │ │ ├── README │ │ │ ├── map3270 │ │ │ ├── reorder │ │ │ ├── tabset/ │ │ │ │ ├── 3101 │ │ │ │ ├── aa │ │ │ │ ├── aed512 │ │ │ │ ├── beehive │ │ │ │ ├── diablo │ │ │ │ ├── dtc382 │ │ │ │ ├── ibm3101 │ │ │ │ ├── std │ │ │ │ ├── stdcrt │ │ │ │ ├── tandem653 │ │ │ │ ├── teleray │ │ │ │ ├── vt100 │ │ │ │ ├── wyse-adds │ │ │ │ ├── xerox1720 │ │ │ │ ├── xerox1730 │ │ │ │ ├── xerox1730-lm │ │ │ │ └── zenith29 │ │ │ ├── termcap.local │ │ │ ├── termcap.small │ │ │ └── termcap.src │ │ ├── termcap.c │ │ ├── tgoto.c │ │ └── tputs.c │ ├── libutil/ │ │ ├── Makefile │ │ ├── login.c │ │ ├── logout.c │ │ └── logwtmp.c │ ├── libvmf/ │ │ ├── .gitignore │ │ ├── Makefile │ │ ├── vmf.3 │ │ ├── vmf.c │ │ └── vmlib.ms │ ├── libwiznet/ │ │ ├── Makefile │ │ ├── client.c │ │ ├── ethernet.c │ │ ├── server.c │ │ ├── socket.c │ │ ├── udp.c │ │ └── w5100.c │ ├── startup-arm/ │ │ ├── Makefile │ │ ├── crt0.c │ │ ├── mon.c │ │ └── mon.ex │ └── startup-mips/ │ ├── Makefile │ ├── crt0.c │ ├── mcount.S │ ├── mon.c │ └── mon.ex ├── libexec/ │ └── Makefile ├── sbin/ │ └── Makefile ├── share/ │ ├── Makefile │ ├── dict/ │ │ ├── Makefile │ │ └── words │ ├── examples/ │ │ ├── Makefile │ │ ├── asm/ │ │ │ ├── Makefile │ │ │ ├── Makefile-host │ │ │ ├── ashello.S │ │ │ └── echo.S │ │ ├── basic/ │ │ │ ├── blkjack.bas │ │ │ ├── hilow.bas │ │ │ └── stars.bas │ │ ├── c/ │ │ │ ├── Makefile │ │ │ ├── Makefile-host │ │ │ ├── adc.c │ │ │ ├── gpio.c │ │ │ ├── hello.c │ │ │ ├── lcd6.c │ │ │ ├── primelist.c │ │ │ ├── primesum.c │ │ │ ├── q8.c │ │ │ ├── rain.c │ │ │ ├── skeleton.c │ │ │ ├── stdarg.c │ │ │ ├── test1.c │ │ │ ├── test2.c │ │ │ ├── test3.c │ │ │ └── tetris.c │ │ ├── cube/ │ │ │ ├── Makefile │ │ │ ├── Makefile-host │ │ │ ├── README.txt │ │ │ ├── all.c │ │ │ ├── backlight.c │ │ │ ├── cube.c │ │ │ ├── cube.h │ │ │ ├── demo.c │ │ │ ├── duinomite.c │ │ │ └── fubarino.c │ │ ├── curses/ │ │ │ ├── Makefile │ │ │ ├── flip.c │ │ │ ├── jump.c │ │ │ ├── timer.c │ │ │ └── typetext.c │ │ ├── dhrystone/ │ │ │ ├── Makefile │ │ │ ├── RATIONALE │ │ │ ├── README │ │ │ ├── README_C │ │ │ ├── VARIATIONS │ │ │ ├── dhry.h │ │ │ ├── dhry_1.c │ │ │ └── dhry_2.c │ │ ├── forth/ │ │ │ └── fact.fth │ │ ├── gpanel/ │ │ │ ├── Makefile │ │ │ ├── circle.c │ │ │ ├── color.c │ │ │ ├── fill.c │ │ │ ├── flappy.c │ │ │ ├── font.c │ │ │ ├── fonts/ │ │ │ │ ├── 5x7.c │ │ │ │ ├── 6x9.c │ │ │ │ ├── Makefile │ │ │ │ ├── bdf/ │ │ │ │ │ ├── 5x7.bdf │ │ │ │ │ └── 6x9.bdf │ │ │ │ ├── convbdf.c │ │ │ │ ├── digits20.c │ │ │ │ ├── digits32.c │ │ │ │ ├── lucidasans11.c │ │ │ │ ├── lucidasans15.c │ │ │ │ ├── lucidasans28.c │ │ │ │ ├── lucidasans7.c │ │ │ │ ├── lucidasans9.c │ │ │ │ └── verdana7.c │ │ │ ├── line.c │ │ │ ├── pixel.c │ │ │ ├── rect.c │ │ │ ├── speed.c │ │ │ ├── tft.c │ │ │ └── tftetris.c │ │ ├── lex/ │ │ │ ├── Makefile │ │ │ ├── awk.lx.l │ │ │ ├── example.l │ │ │ ├── scan.l │ │ │ └── scanner.l │ │ ├── scheme/ │ │ │ └── prime.scm │ │ ├── sensors/ │ │ │ ├── Makefile │ │ │ ├── README.txt │ │ │ ├── buzzer.c │ │ │ ├── buzzer.sh │ │ │ ├── irled.c │ │ │ ├── joystick.c │ │ │ ├── laser.c │ │ │ ├── laser.sh │ │ │ ├── led2-portio.sh │ │ │ ├── led2.c │ │ │ ├── led2.sh │ │ │ ├── led3-portio.sh │ │ │ ├── led3.c │ │ │ ├── led3.sh │ │ │ ├── led7.c │ │ │ ├── pbuzz.c │ │ │ ├── relay.c │ │ │ └── relay.sh │ │ ├── smallc/ │ │ │ ├── Makefile │ │ │ ├── adc.c │ │ │ ├── gpio.c │ │ │ ├── hello.c │ │ │ ├── primelist.c │ │ │ ├── primesum.c │ │ │ ├── q8.c │ │ │ ├── rain.c │ │ │ ├── test1.c │ │ │ ├── test2.c │ │ │ ├── test3.c │ │ │ └── webserver.c │ │ └── yacc/ │ │ ├── Makefile │ │ ├── config.y │ │ ├── cpy.y │ │ ├── egrep.y │ │ ├── expr.y │ │ ├── gram.y │ │ ├── grammar.y │ │ └── parser.y │ ├── man/ │ │ ├── .gitignore │ │ ├── Makefile │ │ ├── makewhatis.sed │ │ ├── man.template │ │ ├── man0/ │ │ │ ├── Makefile │ │ │ ├── break │ │ │ ├── cshcmd │ │ │ ├── ignore │ │ │ ├── intro.ms │ │ │ ├── preface.ms │ │ │ ├── ptx.in │ │ │ ├── ptxx │ │ │ ├── title.prm │ │ │ ├── title.urm │ │ │ ├── toc.in │ │ │ ├── toc1 │ │ │ ├── toc2 │ │ │ ├── toc3 │ │ │ ├── toc3f │ │ │ ├── toc4 │ │ │ ├── toc5 │ │ │ ├── toc6 │ │ │ ├── toc7 │ │ │ ├── toc8 │ │ │ ├── tocrc │ │ │ ├── tocx1 │ │ │ ├── tocx2 │ │ │ ├── tocx3 │ │ │ ├── tocx3f │ │ │ ├── tocx4 │ │ │ ├── tocx5 │ │ │ ├── tocx6 │ │ │ ├── tocx7 │ │ │ └── tocx8 │ │ ├── man1/ │ │ │ ├── Makefile │ │ │ ├── adb.1 │ │ │ ├── addbib.1 │ │ │ ├── apply.1 │ │ │ ├── apropos.1 │ │ │ ├── as.1 │ │ │ ├── at.1 │ │ │ ├── atq.1 │ │ │ ├── atrm.1 │ │ │ ├── awk.1 │ │ │ ├── basename.1 │ │ │ ├── biff.1 │ │ │ ├── binmail.1 │ │ │ ├── cal.1 │ │ │ ├── calendar.1 │ │ │ ├── cat.1 │ │ │ ├── cb.1 │ │ │ ├── cc.1 │ │ │ ├── cd.1 │ │ │ ├── checknr.1 │ │ │ ├── chgrp.1 │ │ │ ├── chmod.1 │ │ │ ├── clear.1 │ │ │ ├── cmp.1 │ │ │ ├── col.1 │ │ │ ├── colcrt.1 │ │ │ ├── colrm.1 │ │ │ ├── comm.1 │ │ │ ├── compress.1 │ │ │ ├── cp.1 │ │ │ ├── csh.1 │ │ │ ├── ctags.1 │ │ │ ├── date.1 │ │ │ ├── dd.1 │ │ │ ├── deroff.1 │ │ │ ├── df.1 │ │ │ ├── diction.1 │ │ │ ├── diff.1 │ │ │ ├── diff3.1 │ │ │ ├── du.1 │ │ │ ├── echo.1 │ │ │ ├── ed.1 │ │ │ ├── efl.1 │ │ │ ├── eqn.1 │ │ │ ├── error.1 │ │ │ ├── ex.1 │ │ │ ├── expand.1 │ │ │ ├── expr.1 │ │ │ ├── f77.1 │ │ │ ├── false.1 │ │ │ ├── file.1 │ │ │ ├── find.1 │ │ │ ├── fmt.1 │ │ │ ├── fold.1 │ │ │ ├── fpr.1 │ │ │ ├── from.1 │ │ │ ├── fsplit.1 │ │ │ ├── gcore.1 │ │ │ ├── graph.1 │ │ │ ├── grep.1 │ │ │ ├── head.1 │ │ │ ├── hostid.1 │ │ │ ├── indent.1 │ │ │ ├── intro.1 │ │ │ ├── join.1 │ │ │ ├── kill.1 │ │ │ ├── last.1 │ │ │ ├── lastcomm.1 │ │ │ ├── learn.1 │ │ │ ├── leave.1 │ │ │ ├── lex.1 │ │ │ ├── lint.1 │ │ │ ├── lisp.1 │ │ │ ├── ln.1 │ │ │ ├── logger.1 │ │ │ ├── login.1 │ │ │ ├── look.1 │ │ │ ├── lookbib.1 │ │ │ ├── lorder.1 │ │ │ ├── lpq.1 │ │ │ ├── lpr.1 │ │ │ ├── lprm.1 │ │ │ ├── lptest.1 │ │ │ ├── ls.1 │ │ │ ├── lxref.1 │ │ │ ├── m4.1 │ │ │ ├── mail.1 │ │ │ ├── make.1 │ │ │ ├── man.1 │ │ │ ├── mesg.1 │ │ │ ├── mkdep.1 │ │ │ ├── mkdir.1 │ │ │ ├── mkstr.1 │ │ │ ├── more.1 │ │ │ ├── mset.1 │ │ │ ├── msgs.1 │ │ │ ├── mt.1 │ │ │ ├── mv.1 │ │ │ ├── netstat.1 │ │ │ ├── newaliases.1 │ │ │ ├── nice.1 │ │ │ ├── nm.1 │ │ │ ├── nroff.1 │ │ │ ├── nslookup.1 │ │ │ ├── od.1 │ │ │ ├── pagesize.1 │ │ │ ├── pdx.1 │ │ │ ├── pi.1 │ │ │ ├── pix.1 │ │ │ ├── plot.1 │ │ │ ├── pmerge.1 │ │ │ ├── pr.1 │ │ │ ├── printenv.1 │ │ │ ├── prof.1 │ │ │ ├── ps.1 │ │ │ ├── ptx.1 │ │ │ ├── pwd.1 │ │ │ ├── px.1 │ │ │ ├── pxp.1 │ │ │ ├── pxref.1 │ │ │ ├── quota.1 │ │ │ ├── ratfor.1 │ │ │ ├── rcp.1 │ │ │ ├── rdist.1 │ │ │ ├── refer.1 │ │ │ ├── rev.1 │ │ │ ├── rlogin.1 │ │ │ ├── rm.1 │ │ │ ├── rmail.1 │ │ │ ├── rmdir.1 │ │ │ ├── roffbib.1 │ │ │ ├── rsh.1 │ │ │ ├── ruptime.1 │ │ │ ├── rwho.1 │ │ │ ├── sccs.1 │ │ │ ├── script.1 │ │ │ ├── sed.1 │ │ │ ├── sendbug.1 │ │ │ ├── sh.1 │ │ │ ├── size.1 │ │ │ ├── sleep.1 │ │ │ ├── soelim.1 │ │ │ ├── sort.1 │ │ │ ├── sortbib.1 │ │ │ ├── spell.1 │ │ │ ├── spline.1 │ │ │ ├── split.1 │ │ │ ├── strcompact.1 │ │ │ ├── strings.1 │ │ │ ├── strip.1 │ │ │ ├── style.1 │ │ │ ├── su.1 │ │ │ ├── sum.1 │ │ │ ├── symcompact.1 │ │ │ ├── symorder.1 │ │ │ ├── tabs.1 │ │ │ ├── tail.1 │ │ │ ├── talk.1 │ │ │ ├── tar.1 │ │ │ ├── tbl.1 │ │ │ ├── tc.1 │ │ │ ├── tcopy.1 │ │ │ ├── tee.1 │ │ │ ├── telnet.1 │ │ │ ├── time.1 │ │ │ ├── tip.1 │ │ │ ├── tk.1 │ │ │ ├── tn3270.1 │ │ │ ├── touch.1 │ │ │ ├── tp.1 │ │ │ ├── tr.1 │ │ │ ├── troff.1 │ │ │ ├── true.1 │ │ │ ├── tsort.1 │ │ │ ├── tty.1 │ │ │ ├── ul.1 │ │ │ ├── unifdef.1 │ │ │ ├── uniq.1 │ │ │ ├── units.1 │ │ │ ├── uptime.1 │ │ │ ├── users.1 │ │ │ ├── uucp.1 │ │ │ ├── uuencode.1 │ │ │ ├── uulog.1 │ │ │ ├── uuname.1 │ │ │ ├── uuq.1 │ │ │ ├── uusend.1 │ │ │ ├── uux.1 │ │ │ ├── vacation.1 │ │ │ ├── vgrind.1 │ │ │ ├── vi.1 │ │ │ ├── vmstat.1 │ │ │ ├── vwidth.1 │ │ │ ├── w.1 │ │ │ ├── wait.1 │ │ │ ├── wall.1 │ │ │ ├── wc.1 │ │ │ ├── what.1 │ │ │ ├── whatis.1 │ │ │ ├── which.1 │ │ │ ├── who.1 │ │ │ ├── whois.1 │ │ │ ├── window.1 │ │ │ ├── write.1 │ │ │ ├── xstr.1 │ │ │ ├── yacc.1 │ │ │ └── yes.1 │ │ ├── man2/ │ │ │ ├── Makefile │ │ │ ├── accept.2 │ │ │ ├── access.2 │ │ │ ├── acct.2 │ │ │ ├── adjtime.2 │ │ │ ├── bind.2 │ │ │ ├── brk.2 │ │ │ ├── chdir.2 │ │ │ ├── chflags.2 │ │ │ ├── chmod.2 │ │ │ ├── chown.2 │ │ │ ├── chroot.2 │ │ │ ├── close.2 │ │ │ ├── connect.2 │ │ │ ├── creat.2 │ │ │ ├── dup.2 │ │ │ ├── execve.2 │ │ │ ├── exit.2 │ │ │ ├── fcntl.2 │ │ │ ├── fetchi.2 │ │ │ ├── flock.2 │ │ │ ├── fork.2 │ │ │ ├── fperr.2 │ │ │ ├── fsync.2 │ │ │ ├── getdtablesize.2 │ │ │ ├── getfsstat.2 │ │ │ ├── getgid.2 │ │ │ ├── getgroups.2 │ │ │ ├── gethostid.2 │ │ │ ├── gethostname.2 │ │ │ ├── getitimer.2 │ │ │ ├── getlogin.2 │ │ │ ├── getpagesize.2 │ │ │ ├── getpeername.2 │ │ │ ├── getpgrp.2 │ │ │ ├── getpid.2 │ │ │ ├── getpriority.2 │ │ │ ├── getrlimit.2 │ │ │ ├── getrusage.2 │ │ │ ├── getsockname.2 │ │ │ ├── getsockopt.2 │ │ │ ├── gettimeofday.2 │ │ │ ├── getuid.2 │ │ │ ├── intro.2 │ │ │ ├── ioctl.2 │ │ │ ├── kill.2 │ │ │ ├── killpg.2 │ │ │ ├── link.2 │ │ │ ├── listen.2 │ │ │ ├── lock.2 │ │ │ ├── lseek.2 │ │ │ ├── mkdir.2 │ │ │ ├── mknod.2 │ │ │ ├── mount.2 │ │ │ ├── nostk.2 │ │ │ ├── open.2 │ │ │ ├── phys.2 │ │ │ ├── pipe.2 │ │ │ ├── profil.2 │ │ │ ├── ptrace.2 │ │ │ ├── quota.2 │ │ │ ├── read.2 │ │ │ ├── readlink.2 │ │ │ ├── reboot.2 │ │ │ ├── recv.2 │ │ │ ├── rename.2 │ │ │ ├── rmdir.2 │ │ │ ├── select.2 │ │ │ ├── send.2 │ │ │ ├── setgroups.2 │ │ │ ├── setpgrp.2 │ │ │ ├── setquota.2 │ │ │ ├── setregid.2 │ │ │ ├── setreuid.2 │ │ │ ├── setuid.2 │ │ │ ├── shutdown.2 │ │ │ ├── sigaction.2 │ │ │ ├── sigaltstack.2 │ │ │ ├── sigblock.2 │ │ │ ├── sigpause.2 │ │ │ ├── sigpending.2 │ │ │ ├── sigprocmask.2 │ │ │ ├── sigreturn.2 │ │ │ ├── sigsetmask.2 │ │ │ ├── sigstack.2 │ │ │ ├── sigsuspend.2 │ │ │ ├── sigvec.2 │ │ │ ├── sigwait.2 │ │ │ ├── socket.2 │ │ │ ├── socketpair.2 │ │ │ ├── stat.2 │ │ │ ├── statfs.2 │ │ │ ├── swapon.2 │ │ │ ├── symlink.2 │ │ │ ├── sync.2 │ │ │ ├── syscall.2 │ │ │ ├── truncate.2 │ │ │ ├── ucall.2 │ │ │ ├── umask.2 │ │ │ ├── unlink.2 │ │ │ ├── utimes.2 │ │ │ ├── vfork.2 │ │ │ ├── vhangup.2 │ │ │ ├── wait.2 │ │ │ └── write.2 │ │ ├── man3/ │ │ │ ├── Makefile │ │ │ ├── abort.3 │ │ │ ├── abs.3 │ │ │ ├── alarm.3 │ │ │ ├── asinh.3 │ │ │ ├── assert.3 │ │ │ ├── atof.3 │ │ │ ├── basename.3 │ │ │ ├── bstring.3 │ │ │ ├── byteorder.3 │ │ │ ├── compat-sys5.3 │ │ │ ├── crypt.3 │ │ │ ├── ctime.3 │ │ │ ├── ctype.3 │ │ │ ├── curses.3 │ │ │ ├── daemon.3 │ │ │ ├── dbm.3 │ │ │ ├── devname.3 │ │ │ ├── directory.3 │ │ │ ├── dirname.3 │ │ │ ├── ecvt.3 │ │ │ ├── end.3 │ │ │ ├── erf.3 │ │ │ ├── err.3 │ │ │ ├── execl.3 │ │ │ ├── exit.3 │ │ │ ├── exp.3 │ │ │ ├── fclose.3 │ │ │ ├── ferror.3 │ │ │ ├── floor.3 │ │ │ ├── fopen.3 │ │ │ ├── fread.3 │ │ │ ├── frexp.3 │ │ │ ├── fseek.3 │ │ │ ├── getc.3 │ │ │ ├── getdisk.3 │ │ │ ├── getenv.3 │ │ │ ├── getfsent.3 │ │ │ ├── getgrent.3 │ │ │ ├── getgrouplist.3 │ │ │ ├── gethostbyname.3 │ │ │ ├── getloadavg.3 │ │ │ ├── getmntinfo.3 │ │ │ ├── getnetent.3 │ │ │ ├── getopt.3 │ │ │ ├── getpass.3 │ │ │ ├── getprotoent.3 │ │ │ ├── getpwent.3 │ │ │ ├── gets.3 │ │ │ ├── getservent.3 │ │ │ ├── getsubopt.3 │ │ │ ├── getttyent.3 │ │ │ ├── getusershell.3 │ │ │ ├── getwd.3 │ │ │ ├── hypot.3 │ │ │ ├── ieee.3 │ │ │ ├── inet.3 │ │ │ ├── infnan.3 │ │ │ ├── initgroups.3 │ │ │ ├── insque.3 │ │ │ ├── intro.3 │ │ │ ├── j0.3 │ │ │ ├── l3tol.3 │ │ │ ├── ldfps.3 │ │ │ ├── lgamma.3 │ │ │ ├── lib2648.3 │ │ │ ├── malloc.3 │ │ │ ├── math.3 │ │ │ ├── mktemp.3 │ │ │ ├── monitor.3 │ │ │ ├── mp.3 │ │ │ ├── ndbm.3 │ │ │ ├── nice.3 │ │ │ ├── nlist.3 │ │ │ ├── ns.3 │ │ │ ├── pause.3 │ │ │ ├── perror.3 │ │ │ ├── plot.3 │ │ │ ├── popen.3 │ │ │ ├── printf.3 │ │ │ ├── psignal.3 │ │ │ ├── putc.3 │ │ │ ├── puts.3 │ │ │ ├── qsort.3 │ │ │ ├── rand.3 │ │ │ ├── random.3 │ │ │ ├── rcmd.3 │ │ │ ├── regex.3 │ │ │ ├── resolver.3 │ │ │ ├── rexec.3 │ │ │ ├── scandir.3 │ │ │ ├── scanf.3 │ │ │ ├── setbuf.3 │ │ │ ├── setjmp.3 │ │ │ ├── setmode.3 │ │ │ ├── setruid.3 │ │ │ ├── siginterrupt.3 │ │ │ ├── signal.3 │ │ │ ├── sigsetops.3 │ │ │ ├── sin.3 │ │ │ ├── sinh.3 │ │ │ ├── sleep.3 │ │ │ ├── sqrt.3 │ │ │ ├── stdio.3 │ │ │ ├── strcspn.3 │ │ │ ├── strftime.3 │ │ │ ├── string.3 │ │ │ ├── strlcpy.3 │ │ │ ├── strpbrk.3 │ │ │ ├── strsep.3 │ │ │ ├── strspn.3 │ │ │ ├── strstr.3 │ │ │ ├── strtok.3 │ │ │ ├── strtol.3 │ │ │ ├── strtoul.3 │ │ │ ├── stty.3 │ │ │ ├── swab.3 │ │ │ ├── sysctl.3 │ │ │ ├── syserrlst.3 │ │ │ ├── syslog.3 │ │ │ ├── system.3 │ │ │ ├── termcap.3 │ │ │ ├── time.3 │ │ │ ├── times.3 │ │ │ ├── ttyname.3 │ │ │ ├── ualarm.3 │ │ │ ├── uname.3 │ │ │ ├── ungetc.3 │ │ │ ├── utime.3 │ │ │ ├── valloc.3 │ │ │ └── varargs.3 │ │ ├── man4/ │ │ │ ├── Makefile │ │ │ ├── acc.4 │ │ │ ├── arp.4 │ │ │ ├── bk.4 │ │ │ ├── br.4 │ │ │ ├── cons.4 │ │ │ ├── css.4 │ │ │ ├── de.4 │ │ │ ├── dh.4 │ │ │ ├── dhu.4 │ │ │ ├── dhv.4 │ │ │ ├── dmc.4 │ │ │ ├── dr.4 │ │ │ ├── dz.4 │ │ │ ├── ec.4 │ │ │ ├── en.4 │ │ │ ├── fd.4 │ │ │ ├── hk.4 │ │ │ ├── ht.4 │ │ │ ├── hy.4 │ │ │ ├── icmp.4 │ │ │ ├── idp.4 │ │ │ ├── il.4 │ │ │ ├── imp.4 │ │ │ ├── impconf.4 │ │ │ ├── inet.4 │ │ │ ├── intro.4 │ │ │ ├── ip.4 │ │ │ ├── lo.4 │ │ │ ├── lp.4 │ │ │ ├── mem.4 │ │ │ ├── mtio.4 │ │ │ ├── networking.4 │ │ │ ├── ns.4 │ │ │ ├── nsip.4 │ │ │ ├── null.4 │ │ │ ├── pty.4 │ │ │ ├── qe.4 │ │ │ ├── ra.4 │ │ │ ├── ram.4 │ │ │ ├── rk.4 │ │ │ ├── rl.4 │ │ │ ├── rx.4 │ │ │ ├── si.4 │ │ │ ├── spp.4 │ │ │ ├── sri.4 │ │ │ ├── swap.4 │ │ │ ├── tb.4 │ │ │ ├── tcp.4 │ │ │ ├── tm.4 │ │ │ ├── tmscp.4 │ │ │ ├── ts.4 │ │ │ ├── tty.4 │ │ │ ├── udp.4 │ │ │ ├── vv.4 │ │ │ └── xp.4 │ │ ├── man5/ │ │ │ ├── L-devices.5 │ │ │ ├── L-dialcodes.5 │ │ │ ├── L.aliases.5 │ │ │ ├── L.cmds.5 │ │ │ ├── L.sys.5 │ │ │ ├── Makefile │ │ │ ├── USERFILE.5 │ │ │ ├── a.out.5 │ │ │ ├── acct.5 │ │ │ ├── aliases.5 │ │ │ ├── core.5 │ │ │ ├── dbx.5 │ │ │ ├── dir.5 │ │ │ ├── disktab.5 │ │ │ ├── dtab.5 │ │ │ ├── dump.5 │ │ │ ├── fs.5 │ │ │ ├── fstab.5 │ │ │ ├── gettytab.5 │ │ │ ├── group.5 │ │ │ ├── hosts.5 │ │ │ ├── intro.5 │ │ │ ├── map3270.5 │ │ │ ├── networks.5 │ │ │ ├── passwd.5 │ │ │ ├── phones.5 │ │ │ ├── plot.5 │ │ │ ├── printcap.5 │ │ │ ├── protocols.5 │ │ │ ├── remote.5 │ │ │ ├── resolver.5 │ │ │ ├── services.5 │ │ │ ├── shells.5 │ │ │ ├── stack.5 │ │ │ ├── syserrlst.5 │ │ │ ├── tar.5 │ │ │ ├── termcap.5 │ │ │ ├── tp.5 │ │ │ ├── ttys.5 │ │ │ ├── types.5 │ │ │ ├── tzfile.5 │ │ │ ├── utmp.5 │ │ │ ├── uuencode.5 │ │ │ ├── vfont.5 │ │ │ └── vgrindefs.5 │ │ ├── man6/ │ │ │ ├── Makefile │ │ │ └── intro.6 │ │ ├── man7/ │ │ │ ├── Makefile │ │ │ ├── ascii.7 │ │ │ ├── environ.7 │ │ │ ├── eqnchar.7 │ │ │ ├── hier.7 │ │ │ ├── hostname.7 │ │ │ ├── intro.7 │ │ │ ├── mailaddr.7 │ │ │ ├── man.7 │ │ │ ├── me.7 │ │ │ ├── ms.7 │ │ │ └── term.7 │ │ ├── man8/ │ │ │ ├── Makefile │ │ │ ├── XNSrouted.8 │ │ │ ├── adduser.8 │ │ │ ├── autoconfig.8 │ │ │ ├── boot.8 │ │ │ ├── bugfiler.8 │ │ │ ├── crash.8 │ │ │ ├── drtest.8 │ │ │ ├── dump.8 │ │ │ ├── dumpdir.8 │ │ │ ├── format.8 │ │ │ ├── fsck.8 │ │ │ ├── getty.8 │ │ │ ├── htable.8 │ │ │ ├── intro.8 │ │ │ ├── lpc.8 │ │ │ ├── lpd.8 │ │ │ ├── makedev.8 │ │ │ ├── makekey.8 │ │ │ ├── named.8 │ │ │ ├── pac.8 │ │ │ ├── rc.8 │ │ │ ├── rdump.8 │ │ │ ├── routed.8 │ │ │ ├── rrestore.8 │ │ │ ├── sendmail.8 │ │ │ ├── sticky.8 │ │ │ ├── sync.8 │ │ │ ├── timed.8 │ │ │ ├── timedc.8 │ │ │ ├── uucico.8 │ │ │ ├── uuclean.8 │ │ │ ├── uupoll.8 │ │ │ ├── uusnap.8 │ │ │ └── uuxqt.8 │ │ ├── man9/ │ │ │ ├── Makefile │ │ │ ├── intro.9 │ │ │ └── style.9 │ │ └── manroff │ ├── misc/ │ │ └── Makefile │ ├── mk/ │ │ └── sys.mk │ └── zoneinfo/ │ ├── .gitignore │ ├── Makefile │ ├── README │ ├── Theory │ ├── asia │ ├── australasia │ ├── etcetera │ ├── europe │ ├── ialloc.c │ ├── northamerica │ ├── pacificnew │ ├── scheck.c │ ├── solar87 │ ├── systemv │ ├── zdump.8 │ ├── zdump.c │ ├── zic.8 │ └── zic.c ├── sys/ │ ├── arch/ │ │ ├── arm/ │ │ │ └── include/ │ │ │ ├── cmsis_gcc.h │ │ │ ├── core_cm4.h │ │ │ ├── core_cmFunc.h │ │ │ ├── core_cmInstr.h │ │ │ └── core_cmSimd.h │ │ ├── pic32/ │ │ │ ├── conf/ │ │ │ │ ├── BAREMETAL.ld │ │ │ │ ├── Config.generic │ │ │ │ ├── MAX32.ld │ │ │ │ ├── MAXIMITE.ld │ │ │ │ ├── MAXIMITE_COLOR.ld │ │ │ │ ├── MMB_MX7.ld │ │ │ │ ├── Makefile.inc │ │ │ │ ├── Makefile.pic32 │ │ │ │ ├── SDRAM32MX.ld │ │ │ │ ├── UBW32.ld │ │ │ │ ├── compiler.mk │ │ │ │ ├── devices.pic32 │ │ │ │ └── files.pic32 │ │ │ ├── dev/ │ │ │ │ ├── adc.c │ │ │ │ ├── adc.h │ │ │ │ ├── glcd.c │ │ │ │ ├── gpanel-ili9341.c │ │ │ │ ├── gpanel-nt35702.c │ │ │ │ ├── gpanel-s6d04h0.c │ │ │ │ ├── gpanel-spi-ili9341.c │ │ │ │ ├── gpanel-spi.c │ │ │ │ ├── gpanel-st7781.c │ │ │ │ ├── gpanel.c │ │ │ │ ├── gpio.c │ │ │ │ ├── hx8357.c │ │ │ │ ├── ili9341.h │ │ │ │ ├── kbd.c │ │ │ │ ├── kbd.h │ │ │ │ ├── mrams.c │ │ │ │ ├── mrams.h │ │ │ │ ├── picga.c │ │ │ │ ├── power_control.c │ │ │ │ ├── pwm.c │ │ │ │ ├── sd.c │ │ │ │ ├── sd.h │ │ │ │ ├── sdram.S │ │ │ │ ├── sdram.h │ │ │ │ ├── sdramp.c │ │ │ │ ├── sdramp.h │ │ │ │ ├── sdramp_config.h │ │ │ │ ├── skel.c │ │ │ │ ├── spi.c │ │ │ │ ├── spi_bus.c │ │ │ │ ├── spirams.c │ │ │ │ ├── spirams.h │ │ │ │ ├── sramc.c │ │ │ │ ├── sramc.h │ │ │ │ ├── uart.c │ │ │ │ ├── uart.h │ │ │ │ ├── usb_uart.c │ │ │ │ └── usb_uart.h │ │ │ ├── hal/ │ │ │ │ ├── usb_ch9.h │ │ │ │ ├── usb_device.c │ │ │ │ ├── usb_device.h │ │ │ │ ├── usb_function_cdc.c │ │ │ │ ├── usb_function_cdc.h │ │ │ │ ├── usb_function_hid.c │ │ │ │ ├── usb_function_hid.h │ │ │ │ └── usb_hal_pic32.h │ │ │ ├── include/ │ │ │ │ ├── _float.h │ │ │ │ ├── cpu.h │ │ │ │ ├── debug.h │ │ │ │ ├── elf_machdep.h │ │ │ │ ├── frame.h │ │ │ │ ├── io.h │ │ │ │ ├── limits.h │ │ │ │ ├── machparam.h │ │ │ │ ├── pic32mx.h │ │ │ │ ├── setjmp.h │ │ │ │ ├── signal.h │ │ │ │ └── types.h │ │ │ └── pic32/ │ │ │ ├── clock.c │ │ │ ├── conf.c │ │ │ ├── exception.c │ │ │ ├── locore.S │ │ │ ├── machdep.c │ │ │ ├── sig_machdep.c │ │ │ └── sysctl.c │ │ └── stm32/ │ │ ├── conf/ │ │ │ ├── Makefile.inc │ │ │ ├── Makefile.stm32 │ │ │ ├── STM32F407XE.ld │ │ │ ├── STM32F407XG.ld │ │ │ ├── STM32F411XE.ld │ │ │ ├── STM32F412XE.ld │ │ │ ├── STM32F412XG.ld │ │ │ ├── STM32F413XH.ld │ │ │ ├── STM32F446XE.ld │ │ │ ├── STM32F469XI.ld │ │ │ ├── compiler.mk │ │ │ ├── devices.stm32 │ │ │ ├── files.stm32 │ │ │ └── kern.ldscript │ │ ├── dev/ │ │ │ ├── sd.c │ │ │ ├── sd.h │ │ │ ├── sdio.c │ │ │ ├── sdio.h │ │ │ ├── sdio_card.c │ │ │ ├── sdio_card.h │ │ │ ├── spi.c │ │ │ ├── spi.h │ │ │ ├── stm32_adafruit_sd.c │ │ │ ├── stm32_bsp.c │ │ │ ├── stm32_bsp.h │ │ │ ├── stm32_bsp_sd.h │ │ │ ├── stm32_sdio_sd.c │ │ │ ├── stm32f4xx_nucleo_sd.c │ │ │ ├── stm32f4xx_nucleo_sd.h │ │ │ ├── uart.c │ │ │ └── uart.h │ │ ├── hal/ │ │ │ ├── stm32_assert.h │ │ │ ├── stm32f405xx.h │ │ │ ├── stm32f407xx.h │ │ │ ├── stm32f411xe.h │ │ │ ├── stm32f412rx.h │ │ │ ├── stm32f412zx.h │ │ │ ├── stm32f413xx.h │ │ │ ├── stm32f446xx.h │ │ │ ├── stm32f469xx.h │ │ │ ├── stm32f4xx.h │ │ │ ├── stm32f4xx_hal.c │ │ │ ├── stm32f4xx_hal.h │ │ │ ├── stm32f4xx_hal_conf.h │ │ │ ├── stm32f4xx_hal_def.h │ │ │ ├── stm32f4xx_hal_sd.c │ │ │ ├── stm32f4xx_hal_sd.h │ │ │ ├── stm32f4xx_hal_spi.c │ │ │ ├── stm32f4xx_hal_spi.h │ │ │ ├── stm32f4xx_ll_bus.h │ │ │ ├── stm32f4xx_ll_cortex.h │ │ │ ├── stm32f4xx_ll_gpio.h │ │ │ ├── stm32f4xx_ll_pwr.h │ │ │ ├── stm32f4xx_ll_rcc.c │ │ │ ├── stm32f4xx_ll_rcc.h │ │ │ ├── stm32f4xx_ll_sdmmc.c │ │ │ ├── stm32f4xx_ll_sdmmc.h │ │ │ ├── stm32f4xx_ll_system.h │ │ │ ├── stm32f4xx_ll_usart.c │ │ │ ├── stm32f4xx_ll_usart.h │ │ │ ├── stm32f4xx_ll_utils.c │ │ │ ├── stm32f4xx_ll_utils.h │ │ │ ├── system_stm32f4xx.c │ │ │ └── system_stm32f4xx.h │ │ ├── include/ │ │ │ ├── _float.h │ │ │ ├── cpu.h │ │ │ ├── debug.h │ │ │ ├── elf_machdep.h │ │ │ ├── fault.h │ │ │ ├── frame.h │ │ │ ├── intr.h │ │ │ ├── io.h │ │ │ ├── limits.h │ │ │ ├── machparam.h │ │ │ ├── mpuvar.h │ │ │ ├── setjmp.h │ │ │ ├── signal.h │ │ │ └── types.h │ │ └── stm32/ │ │ ├── clock.c │ │ ├── conf.c │ │ ├── fault.c │ │ ├── locore.S │ │ ├── locore0.S │ │ ├── machdep.c │ │ ├── mpu.c │ │ ├── sig_machdep.c │ │ ├── syscall.c │ │ ├── sysctl.c │ │ └── systick.c │ ├── conf/ │ │ └── newvers.sh │ ├── dev/ │ │ ├── cons.c │ │ ├── mem.c │ │ └── swap.c │ ├── kern/ │ │ ├── exec_aout.c │ │ ├── exec_conf.c │ │ ├── exec_elf.c │ │ ├── exec_script.c │ │ ├── exec_subr.c │ │ ├── init_main.c │ │ ├── init_sysent.c │ │ ├── kern_clock.c │ │ ├── kern_descrip.c │ │ ├── kern_exec.c │ │ ├── kern_exit.c │ │ ├── kern_fork.c │ │ ├── kern_glob.c │ │ ├── kern_mman.c │ │ ├── kern_proc.c │ │ ├── kern_prot.c │ │ ├── kern_prot2.c │ │ ├── kern_resource.c │ │ ├── kern_sig.c │ │ ├── kern_sig2.c │ │ ├── kern_subr.c │ │ ├── kern_synch.c │ │ ├── kern_sysctl.c │ │ ├── kern_time.c │ │ ├── subr_log.c │ │ ├── subr_prf.c │ │ ├── subr_rmap.c │ │ ├── sys_generic.c │ │ ├── sys_inode.c │ │ ├── sys_pipe.c │ │ ├── sys_process.c │ │ ├── syscalls.c │ │ ├── tty.c │ │ ├── tty_pty.c │ │ ├── tty_subr.c │ │ ├── tty_tty.c │ │ ├── ufs_alloc.c │ │ ├── ufs_bio.c │ │ ├── ufs_bmap.c │ │ ├── ufs_dsort.c │ │ ├── ufs_fio.c │ │ ├── ufs_inode.c │ │ ├── ufs_mount.c │ │ ├── ufs_namei.c │ │ ├── ufs_subr.c │ │ ├── ufs_syscalls.c │ │ ├── ufs_syscalls2.c │ │ ├── vfs_vnops.c │ │ ├── vm_sched.c │ │ ├── vm_swap.c │ │ └── vm_swp.c │ └── sys/ │ ├── buf.h │ ├── callout.h │ ├── clist.h │ ├── conf.h │ ├── config.h │ ├── dir.h │ ├── disk.h │ ├── dk.h │ ├── dkbad.h │ ├── errno.h │ ├── exec.h │ ├── exec_aout.h │ ├── exec_elf.h │ ├── fcntl.h │ ├── file.h │ ├── fs.h │ ├── glcd.h │ ├── glob.h │ ├── gpanel.h │ ├── gpio.h │ ├── inode.h │ ├── ioctl.h │ ├── kernel.h │ ├── map.h │ ├── mount.h │ ├── msgbuf.h │ ├── mtio.h │ ├── namei.h │ ├── param.h │ ├── picga.h │ ├── proc.h │ ├── ptrace.h │ ├── pty.h │ ├── pwm.h │ ├── reboot.h │ ├── resource.h │ ├── select.h │ ├── signal.h │ ├── signalvar.h │ ├── skel.h │ ├── spi.h │ ├── stat.h │ ├── stdint.h │ ├── swap.h │ ├── sysctl.h │ ├── syslimits.h │ ├── syslog.h │ ├── systm.h │ ├── time.h │ ├── times.h │ ├── tty.h │ ├── ttychars.h │ ├── ttydev.h │ ├── types.h │ ├── uio.h │ ├── user.h │ ├── utsname.h │ ├── vm.h │ ├── vmmac.h │ ├── vmmeter.h │ ├── vmparam.h │ ├── vmsystm.h │ └── wait.h ├── tools/ │ ├── Makefile │ ├── Makefile.inc │ ├── aoututils/ │ │ ├── Makefile │ │ ├── Makefile.inc │ │ └── include/ │ │ ├── a.out.h │ │ ├── ar.h │ │ ├── nlist.h │ │ └── ranlib.h │ ├── binstall/ │ │ ├── .gitignore │ │ ├── Makefile │ │ ├── install.1 │ │ ├── pathnames.h │ │ └── xinstall.c │ ├── icache/ │ │ ├── .gitignore │ │ ├── Makefile │ │ ├── ice2aout.c │ │ ├── license.txt │ │ └── readme.txt │ ├── libufs/ │ │ ├── Makefile │ │ ├── fops.c │ │ ├── fs.c │ │ ├── libufs.h │ │ ├── set.c │ │ ├── ucat.c │ │ ├── ucd.c │ │ ├── uchgrp.c │ │ ├── uchmod.c │ │ ├── uchown.c │ │ ├── ulogin.c │ │ ├── uls.c │ │ ├── umkdir.c │ │ ├── umkfs.c │ │ └── util.c │ ├── linux/ │ │ └── README.md │ ├── openbsd/ │ │ ├── README.md │ │ └── ports/ │ │ ├── devel/ │ │ │ └── openocd/ │ │ │ ├── Makefile │ │ │ ├── distinfo │ │ │ ├── patches/ │ │ │ │ ├── patch-src_jtag_drivers_cmsis_dap_usb_hid_c │ │ │ │ └── patch-src_jtag_drivers_nulink_usb_c │ │ │ └── pkg/ │ │ │ ├── DESCR │ │ │ └── PLIST │ │ └── mystuff/ │ │ ├── devel/ │ │ │ ├── arm-none-eabi/ │ │ │ │ ├── Makefile │ │ │ │ ├── Makefile.inc │ │ │ │ ├── binutils/ │ │ │ │ │ ├── Makefile │ │ │ │ │ ├── distinfo │ │ │ │ │ ├── patches/ │ │ │ │ │ │ ├── patch-bfd_Makefile_in │ │ │ │ │ │ ├── patch-binutils_Makefile_in │ │ │ │ │ │ ├── patch-gas_Makefile_in │ │ │ │ │ │ ├── patch-gprof_Makefile_in │ │ │ │ │ │ ├── patch-ld_Makefile_in │ │ │ │ │ │ ├── patch-libctf_Makefile_in │ │ │ │ │ │ ├── patch-libiberty_Makefile_in │ │ │ │ │ │ └── patch-libsframe_Makefile_in │ │ │ │ │ └── pkg/ │ │ │ │ │ ├── DESCR │ │ │ │ │ ├── PFRAG.aarch64 │ │ │ │ │ ├── PFRAG.arm │ │ │ │ │ └── PLIST │ │ │ │ ├── gcc/ │ │ │ │ │ ├── Makefile │ │ │ │ │ ├── distinfo │ │ │ │ │ ├── patches/ │ │ │ │ │ │ ├── patch-Makefile_in │ │ │ │ │ │ ├── patch-gcc_Makefile_in │ │ │ │ │ │ ├── patch-gcc_common_opt │ │ │ │ │ │ ├── patch-gcc_config_arm_elf_h │ │ │ │ │ │ ├── patch-gcc_config_host │ │ │ │ │ │ ├── patch-gcc_configure │ │ │ │ │ │ ├── patch-libcc1_connection_cc │ │ │ │ │ │ ├── patch-libgcc_Makefile_in │ │ │ │ │ │ ├── patch-libiberty_Makefile_in │ │ │ │ │ │ └── vecstep-gcc_tree-vect-loop_c │ │ │ │ │ └── pkg/ │ │ │ │ │ ├── DESCR │ │ │ │ │ ├── PFRAG.aarch64 │ │ │ │ │ ├── PFRAG.arm │ │ │ │ │ └── PLIST │ │ │ │ ├── gdb/ │ │ │ │ │ ├── Makefile │ │ │ │ │ ├── distinfo │ │ │ │ │ ├── patches/ │ │ │ │ │ │ ├── patch-gdb_data-directory_Makefile_in │ │ │ │ │ │ ├── patch-gdb_i386-obsd-nat_c │ │ │ │ │ │ ├── patch-gdbsupport_enum-flags_h │ │ │ │ │ │ ├── patch-include_diagnostics_h │ │ │ │ │ │ ├── patch-include_filenames_h │ │ │ │ │ │ ├── patch-libiberty_Makefile_in │ │ │ │ │ │ └── patch-libiberty_filename_cmp_c │ │ │ │ │ └── pkg/ │ │ │ │ │ ├── DESCR │ │ │ │ │ └── PLIST │ │ │ │ └── newlib/ │ │ │ │ ├── Makefile │ │ │ │ ├── distinfo │ │ │ │ ├── patches/ │ │ │ │ │ ├── patch-etc_Makefile_in │ │ │ │ │ ├── patch-libgloss_arm_Makefile_in │ │ │ │ │ ├── patch-libgloss_arm_arm_h │ │ │ │ │ ├── patch-libgloss_arm_crt0_S │ │ │ │ │ ├── patch-libgloss_arm_linux-crt0_c │ │ │ │ │ ├── patch-libgloss_arm_redboot-crt0_S │ │ │ │ │ ├── patch-libgloss_arm_swi_h │ │ │ │ │ ├── patch-libgloss_arm_trap_S │ │ │ │ │ ├── patch-newlib_doc_makedoc_c │ │ │ │ │ ├── patch-newlib_libc_machine_arm_setjmp_S │ │ │ │ │ ├── patch-newlib_libc_machine_arm_strcmp_S │ │ │ │ │ ├── patch-newlib_libc_sys_arm_Makefile_am │ │ │ │ │ ├── patch-newlib_libc_sys_arm_Makefile_in │ │ │ │ │ ├── patch-newlib_libc_sys_arm_arm_h │ │ │ │ │ ├── patch-newlib_libc_sys_arm_crt0_S │ │ │ │ │ ├── patch-newlib_libc_sys_arm_swi_h │ │ │ │ │ ├── patch-newlib_libc_sys_arm_trap_S │ │ │ │ │ ├── patch-newlib_libm_machine_arm_s_ceil_c │ │ │ │ │ ├── patch-newlib_libm_machine_arm_s_floor_c │ │ │ │ │ ├── patch-newlib_libm_machine_arm_s_nearbyint_c │ │ │ │ │ ├── patch-newlib_libm_machine_arm_s_rint_c │ │ │ │ │ ├── patch-newlib_libm_machine_arm_s_round_c │ │ │ │ │ └── patch-newlib_libm_machine_arm_s_trunc_c │ │ │ │ └── pkg/ │ │ │ │ ├── DESCR │ │ │ │ └── PLIST │ │ │ ├── mips-elf/ │ │ │ │ ├── Makefile │ │ │ │ ├── Makefile.inc │ │ │ │ ├── binutils/ │ │ │ │ │ ├── Makefile │ │ │ │ │ ├── distinfo │ │ │ │ │ ├── patches/ │ │ │ │ │ │ ├── patch-bfd_Makefile_in │ │ │ │ │ │ ├── patch-binutils_Makefile_in │ │ │ │ │ │ ├── patch-gas_Makefile_in │ │ │ │ │ │ ├── patch-gprof_Makefile_in │ │ │ │ │ │ ├── patch-ld_Makefile_in │ │ │ │ │ │ ├── patch-libctf_Makefile_in │ │ │ │ │ │ ├── patch-libiberty_Makefile_in │ │ │ │ │ │ └── patch-libsframe_Makefile_in │ │ │ │ │ └── pkg/ │ │ │ │ │ ├── DESCR │ │ │ │ │ └── PLIST │ │ │ │ └── gcc/ │ │ │ │ ├── Makefile │ │ │ │ ├── distinfo │ │ │ │ ├── patches/ │ │ │ │ │ ├── patch-Makefile_in │ │ │ │ │ ├── patch-gcc_Makefile_in │ │ │ │ │ ├── patch-gcc_common_opt │ │ │ │ │ ├── patch-gcc_config_host │ │ │ │ │ ├── patch-gcc_configure │ │ │ │ │ ├── patch-libcc1_connection_cc │ │ │ │ │ ├── patch-libgcc_Makefile_in │ │ │ │ │ ├── patch-libgcc_config_host │ │ │ │ │ └── patch-libiberty_Makefile_in │ │ │ │ └── pkg/ │ │ │ │ ├── DESCR │ │ │ │ └── PLIST │ │ │ └── stlink/ │ │ │ ├── Makefile │ │ │ ├── distinfo │ │ │ ├── patches/ │ │ │ │ ├── patch-CMakeLists_txt │ │ │ │ ├── patch-cmake_modules_c_flags_cmake │ │ │ │ └── patch-doc_man_CMakeLists_txt │ │ │ └── pkg/ │ │ │ ├── DESCR │ │ │ └── PLIST │ │ └── emulators/ │ │ └── qemu-arm/ │ │ ├── Makefile │ │ ├── distinfo │ │ ├── patches/ │ │ │ ├── patch-include_ui_egl-helpers_h │ │ │ ├── patch-ui_egl-helpers_c │ │ │ └── patch-ui_gtk-egl_c │ │ └── pkg/ │ │ ├── DESCR │ │ └── PLIST │ └── virtualmips/ │ ├── .gitignore │ ├── LICENSE │ ├── Makefile │ ├── README │ ├── SConstruct │ ├── adm5120/ │ │ ├── adm5120.c │ │ ├── adm5120.conf │ │ ├── adm5120.h │ │ ├── adm5120_dev_intctrl.c │ │ ├── adm5120_dev_mpmc.c │ │ ├── adm5120_dev_pci.c │ │ ├── adm5120_dev_sw.c │ │ ├── adm5120_dev_uart.c │ │ └── adm5120_host_alarm.c │ ├── bsd_syscalls.h │ ├── config.c │ ├── config.h │ ├── cpu.c │ ├── cpu.h │ ├── crc.c │ ├── crc.h │ ├── debug.c │ ├── debug.h │ ├── dev_cs8900.c │ ├── dev_cs8900.h │ ├── dev_nand_flash_1g.c │ ├── dev_nand_flash_1g.h │ ├── dev_nor_flash_4m.c │ ├── dev_ram.c │ ├── dev_sdcard.c │ ├── dev_sdcard.h │ ├── dev_swap.c │ ├── dev_swap.h │ ├── dev_vtty.c │ ├── dev_vtty.h │ ├── device.c │ ├── device.h │ ├── gdb_interface.c │ ├── gdb_interface.h │ ├── jz4740/ │ │ ├── jz4740.c │ │ ├── jz4740.h │ │ ├── jz4740_dev_cpm.c │ │ ├── jz4740_dev_dma.c │ │ ├── jz4740_dev_emc.c │ │ ├── jz4740_dev_gpio.c │ │ ├── jz4740_dev_int.c │ │ ├── jz4740_dev_lcd.c │ │ ├── jz4740_dev_rtc.c │ │ ├── jz4740_dev_ts.c │ │ ├── jz4740_dev_uart.c │ │ └── jz4740_dev_wdt_tcu.c │ ├── m4k.c │ ├── m4k.h │ ├── main.c │ ├── mempool.c │ ├── mempool.h │ ├── mips-dis.c │ ├── mips-opc.c │ ├── mips-opcode.h │ ├── mips.c │ ├── mips.h │ ├── mips16-opc.c │ ├── mips_codetable.c │ ├── mips_cp0.c │ ├── mips_cp0.h │ ├── mips_exec.c │ ├── mips_exec.h │ ├── mips_fdd.c │ ├── mips_fdd.h │ ├── mips_hostalarm.c │ ├── mips_hostalarm.h │ ├── mips_jit.c │ ├── mips_jit.h │ ├── mips_memory.c │ ├── mips_memory.h │ ├── net.h │ ├── net_io.c │ ├── net_io.h │ ├── pavo.c │ ├── pavo.conf │ ├── pavo.h │ ├── pic32.c │ ├── pic32.h │ ├── pic32_dev_adc.c │ ├── pic32_dev_bmxcon.c │ ├── pic32_dev_devcfg.c │ ├── pic32_dev_dmacon.c │ ├── pic32_dev_flash.c │ ├── pic32_dev_gpio.c │ ├── pic32_dev_intcon.c │ ├── pic32_dev_prefetch.c │ ├── pic32_dev_rtcc.c │ ├── pic32_dev_spi.c │ ├── pic32_dev_syscon.c │ ├── pic32_dev_timer.c │ ├── pic32_dev_uart.c │ ├── pic32_explorer16.conf │ ├── pic32_max32.conf │ ├── pic32_maximite.conf │ ├── pic32_ubw32.conf │ ├── pic32mx.h │ ├── sbox.c │ ├── sbox.h │ ├── system.h │ ├── types.h │ ├── utils.c │ ├── utils.h │ ├── vm.c │ ├── vm.h │ ├── vp_clock.c │ ├── vp_clock.h │ ├── vp_lock.h │ ├── vp_sdl.c │ ├── vp_sdl.h │ ├── vp_timer.c │ ├── vp_timer.h │ ├── x86-codegen.h │ ├── x86_trans.c │ └── x86_trans.h └── usr.sbin/ └── Makefile ================================================ FILE CONTENTS ================================================ ================================================ FILE: .gitignore ================================================ # Object files *.o *.ko *.obj *.elf # Libraries *.lib *.a # Shared objects (inc. Windows DLLs) *.dll *.so *.so.* *.dylib # Executables *.exe *.out *.app *.i*86 *.x86_64 *.hex *.dis *.0 *.img Makefile.user ================================================ FILE: LICENSE ================================================ Copyright (c) 2020-2026 DiscoBSD Copyright (c) 2014, RetroBSD All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the {organization} nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ================================================ FILE: Makefile ================================================ # Copyright (c) 1986 Regents of the University of California. # All rights reserved. The Berkeley software License Agreement # specifies the terms and conditions for redistribution. # # This makefile is designed to be run as: # make # # The `make' will compile everything, including a kernel, utilities # and a root filesystem image. TOPSRC!= pwd # Override the default port with: # $ make MACHINE=pic32 MACHINE_ARCH=mips # MACHINE= stm32 MACHINE_ARCH= arm DESTDIR?= ${TOPSRC}/distrib/obj/destdir.${MACHINE} RELEASEDIR?= ${TOPSRC}/distrib/obj/releasedir # Filesystem and swap sizes. FS_MBYTES = 200 U_MBYTES = 200 SWAP_MBYTES = 2 # SD card filesystem image for ${MACHINE}. FSIMG= ${TOPSRC}/distrib/${MACHINE}/sdcard.img # Set this to the device name for your SD card. With this # enabled you can use "make installfs" to copy the sdcard.img # to the SD card. #SDCARD = /dev/sdb # # C library options: passed to libc makefile. # See lib/libc/Makefile for explanation. # DEFS = FSUTIL= ${TOPSRC}/tools/bin/fsutil -include Makefile.user SUBDIR= share lib bin sbin libexec usr.bin usr.sbin games all: build build: symlinks tools $(MAKE) kernel $(MAKE) -C etc DESTDIR=${DESTDIR} distrib-dirs $(MAKE) -C include includes for dir in ${SUBDIR} ; do \ ${MAKE} -C $$dir ; done for dir in ${SUBDIR} ; do \ ${MAKE} -C $$dir DESTDIR=${DESTDIR} install ; done distribution: build ${MAKE} -C etc DESTDIR=${DESTDIR} distribution $(MAKE) fs tools: ${MAKE} -C tools MACHINE=${MACHINE} install kernel: tools ${MAKE} -C sys/arch/${MACHINE}/compile all fs: $(FSIMG) ${FSIMG}: distrib/${MACHINE}/md.${MACHINE} distrib/base/mi.home rm -f $@ distrib/$(MACHINE)/_manifest cat distrib/base/mi distrib/$(MACHINE)/md.$(MACHINE) > distrib/$(MACHINE)/_manifest $(FSUTIL) --repartition=fs=$(FS_MBYTES)M:swap=$(SWAP_MBYTES)M:fs=$(U_MBYTES)M $@ ${FSUTIL} --new --partition=1 --manifest=distrib/${MACHINE}/_manifest $@ ${DESTDIR} # In case you need a separate /home partition, # uncomment the following line. $(FSUTIL) --new --partition=3 --manifest=distrib/base/mi.home $@ distrib/home release: ${MAKE} -C etc MACHINE=${MACHINE} RELEASEDIR=${RELEASEDIR} release clean: rm -f *~ rm -f include/machine for dir in ${SUBDIR} ; do \ $(MAKE) -C $$dir -k clean; done cleantools: ${MAKE} -C tools clean cleankernel: ${MAKE} -C sys/arch/${MACHINE}/compile -k clean cleanfs: rm -f distrib/$(MACHINE)/_manifest rm -f $(FSIMG) cleanall: cleantools clean cleankernel symlinks: rm -f include/machine ln -s $(MACHINE) include/machine installfs: @[ -n "${SDCARD}" ] || (echo "SDCARD not defined." && exit 1) @[ -f $(FSIMG) ] || $(MAKE) $(FSIMG) sudo dd bs=1M if=${FSIMG} of=${SDCARD} .PHONY: all build distribution release tools kernel symlinks \ ${FSIMG} fs installfs \ clean cleantools cleanfs cleanall # Architecture-specific debugging and loading. -include sys/arch/${MACHINE}/conf/Makefile.inc ================================================ FILE: README.md ================================================ DiscoBSD ======== 2.11BSD-based UNIX-like Operating System for STM32 and PIC32 Microcontrollers ----------------------------------------------------------------------------- DiscoBSD is a 2.11BSD-based UNIX-like operating system for microcontrollers, with a focus on high portability to memory constrained devices without a memory management unit. The current and seventh official release of DiscoBSD is [DiscoBSD 2.6][1], released on February 11, 2026. This microcontroller-focused operating system is an independent continuation of RetroBSD, a 2.11BSD-based OS targeting the MIPS-based PIC32MX7. DiscoBSD is multi-platform, as it also supports Arm Cortex-M4 STM32F4 devices. Source code to the system is freely available under a BSD-like license. History ------- [DiscoBSD][2] began as an undergraduate [Directed Study][3] in the winter of 2020 at the University of Victoria, Canada, as a case study of [RetroBSD][4] to port the operating system to the Arm Cortex-M4 architecture, and to enable portability in the hosting environment and target architectures and platforms. The paper [*Porting the Unix Kernel*][5] details this initial porting effort. Work on DiscoBSD has progressed in earnest since the completion of the Directed Study, with the `DiscoBSD/stm32` port booting multi-user in August 2022. The system is quite usable on supported development boards. And work continues... [1]: https://github.com/chettrick/discobsd/releases/tag/DISCOBSD_2_6 [2]: http://DiscoBSD.org [3]: https://github.com/chettrick/CSC490 [4]: https://RetroBSD.org [5]: https://github.com/chettrick/CSC490/raw/master/project_outputs/Porting_the_Unix_Kernel-CSC490-Christopher_Hettrick.pdf DiscoBSD Resource Requirements ------------------------------ A basic, minimal system uses 128 Kbytes of flash and 128 Kbytes of RAM. The kernel is loaded into the flash and only uses 32 Kbytes of RAM. User programs each use the remaining 96 Kbytes of RAM, via swapping. Devices with more RAM can be used to run larger user programs. An SD card, at least 512 Mbytes in size, is required for the root file system. Installing and Running ---------------------- Installation consists of loading the kernel into the microcontroller's flash memory, and imaging the SD card with the file `sdcard.img`. On Windows host systems use a disk imaging utility such as [Rufus][6]. On Unix-like host systems with `dd` run: $ dd bs=1M if=sdcard.img of=/path/to/SD/card The board-specific kernel `unix` must be loaded into the MCU's flash memory. Formats are ELF `unix.elf`, binary `unix.bin`, and Intel HEX `unix.hex`. #### Loading a `DiscoBSD/stm32` kernel firmware into board's flash memory: On Windows host systems use [STM32CubeProgrammer][7] for flash programming. On Unix-like host systems use `st-flash` from the [stlink-org project][8] to load the binary-formatted kernel `unix.bin` into flash memory at 0x08000000. $ st-flash --reset write unix.bin 0x08000000 #### Loading a `DiscoBSD/pic32` kernel firmware into board's flash memory: On all supported host systems use [pic32prog][9] for flash programming. $ pic32prog unix.hex Communication with the DiscoBSD console requires a serial port. A USB to TTL device or the built-in VCP USB serial port on development boards can be used. $ cu -l /dev/cuaU0 -s 115200 Depending on the host system, other serial port utilities such as `screen`, `minicom`, `putty`, or `teraterm` may be used. Log in to DiscoBSD with user `root` and a blank password. Shutdown DiscoBSD with the `halt`, `shutdown`, or `reboot` commands. Manual pages on DiscoBSD are available through the `man` command. [6]: https://github.com/pbatard/rufus [7]: https://www.st.com/en/development-tools/stm32cubeprog.html [8]: https://github.com/stlink-org/stlink [9]: https://github.com/majenkotech/pic32prog-autotools Building -------- DiscoBSD is cross-built on UNIX-like host operating systems. Currently supported host operating systems: OpenBSD, Linux, FreeBSD. ### Instructions to configure a supported host development environment: * [OpenBSD][10] * [Debian-based Linux][27] The build system fully supports both BSD make and GNU make. From the source tree root, run: $ make build or just: $ make which builds `sys/arch/stm32/compile/${BOARD}/unix` ELF-formatted kernels and builds and populates a whole file system userland in `DESTDIR`. Running: $ make distribution will build everything from a `make build`, plus generate a file system image in the file `distrib/stm32/sdcard.img` for imaging to an SD card. `DiscoBSD/stm32` is the default port, but `DiscoBSD/pic32` may be built via: $ make clean $ make MACHINE=pic32 MACHINE_ARCH=mips distribution to generate a file system image in the file `distrib/pic32/sdcard.img` for imaging to an SD card, `sys/arch/pic32/compile/${BOARD}/unix` ELF-formatted kernels, and `sys/arch/pic32/compile/${BOARD}/unix.hex` Intel HEX-formatted kernels. Put the generated file system image `sdcard.img` onto an SD card. The `make` target `installfs` uses the `dd` utility to image `sdcard.img` to the SD card attached to the host operating system at `SDCARD`, such as `/dev/rsdXc`, `/dev/daX`, `/dev/mmcblkX`, `/dev/sdX`, or `/dev/rdiskX`, replacing `X` with the actual drive number or letter, as the case may be. For example, imaging an SD card attached at `sd2` on an OpenBSD host operating system through the raw i/o device: $ make SDCARD=/dev/rsd2c installfs Note that using BSD make on a FreeBSD host requires the system makefile include directory to be specified on the command line or via the `MAKESYSPATH` environment variable. For example: $ make -m /usr/share/mk or $ MAKESYSPATH=/usr/share/mk $ export MAKESYSPATH $ make [10]: tools/openbsd/README.md [27]: tools/linux/README.md Building a DiscoBSD Release --------------------------- A DiscoBSD release consists of, for each supported architecture: * a file system image that contains the full base system * kernels, in various file formats, for each supported development board * the ANNOUNCEMENT.md file * the README.md file for the architecture * this README.md file Before making a release, first create a distribution in `DESTDIR` with kernels in `sys/arch/${MACHINE}/compile/${BOARD}` by following the steps in [Building](#building): $ make distribution Once all the distribution source objects exist then a release can be created; one release for each architecture. A `DiscoBSD/stm32` release, as the default architecture, is created by: $ make release A `DiscoBSD/pic32` release is created by: $ make MACHINE=pic32 MACHINE_ARCH=mips release A DiscoBSD release is created from an already-populated `DESTDIR`, and it is placed in `RELEASEDIR`, `distrib/obj/releasedir` by default. [Releases are available][11], for each architecture, as a `.tar.gz` gzip-compressed tar archive and as a `.zip` zip-compressed archive. [11]: https://github.com/chettrick/discobsd/releases Debugging --------- `DiscoBSD/stm32` is debugged through OpenOCD and GDB. The `make` targets for debugging are `ocd` and `gdb-ocd`. Debug a particular development board via: $ make BOARD=F412GDISCO ocd in one terminal, and: $ make BOARD=F412GDISCO gdb-ocd in another terminal. Additional Information ---------------------- Port-specific information can be found in `distrib/${MACHINE}/README.md` for [DiscoBSD/stm32][12] and [DiscoBSD/pic32][13]. [12]: distrib/stm32/README.md [13]: distrib/pic32/README.md References and Resources ------------------------ * The [RetroBSD wiki][14] has a wealth of PIC32 architecture information. * [The Design and Implementation of the 4.3BSD UNIX Operating System][15]. * [Lions' Commentary on UNIX 6th Edition][16] and [recreations of it][17]. * [Advanced Programming in the UNIX Environment][18] 1st Edition. * [The Design of the UNIX Operating System][19]. * [OpenBSD's curated list of books][20] relevant to BSD Operating Systems. * The paper [*Porting the Unix Kernel*][5] details DiscoBSD's inception. * The Unix Heritage Society's [Unix Archive][21] and [Source Tree][22]. * STMicroelectronics [Reference Manual][23] and [Programming Manual][24]. * [The Definitive Guide to ARM Cortex-M3 and Cortex-M4 Processors][25]. * [ARMv7-M Architecture Reference Manual][26]. [14]: https://github.com/RetroBSD/retrobsd/wiki [15]: https://archive.org/details/designimplementa0000unse [16]: https://www.peerllc.com/peer-to-peer-books/lions-commentary-on-unix/ [17]: http://www.lemis.com/grog/Documentation/Lions/ [18]: http://www.kohala.com/start/apue.html [19]: https://archive.org/details/DesignUNIXOperatingSystem [20]: https://www.openbsd.org/books.html [21]: https://www.tuhs.org/Archive/Distributions/UCB/ [22]: https://www.tuhs.org/cgi-bin/utree.pl [23]: https://www.st.com/resource/en/reference_manual/dm00031020-stm32f405-415-stm32f407-417-stm32f427-437-and-stm32f429-439-advanced-arm-based-32-bit-mcus-stmicroelectronics.pdf [24]: https://www.st.com/resource/en/programming_manual/pm0214-stm32-cortexm4-mcus-and-mpus-programming-manual-stmicroelectronics.pdf [25]: https://booksite.elsevier.com/9780124080829/ [26]: https://developer.arm.com/documentation/ddi0403 Source Tree Roadmap ------------------- bin User utilities in both single and multi-user environments. distrib System distributions and releases. etc Templates for system configuration files and scripts in /etc. games Useful and semi-frivolous programs. The important stuff. include Standard C include files. lib System libraries. libexec System daemons and utilities (executed by other programs). sbin System administration utilities in both single and multi-user environments. share Architecture-independent shared resource data files. sys Kernel sources. tools Build tools and simulators. usr.bin User utilities in multi-user environments. usr.sbin System administration utilities in multi-user environments. `DiscoBSD/stm32` dmesg -------------------- ``` DiscoBSD 2.6 (F412GDISCO) #1 755: Wed Feb 11 11:11:11 MST 2026 chris@stm32.discobsd.org:/sys/arch/stm32/compile/F412GDISCO cpu: STM32F412xE/G rev 1/C, 100 MHz, bus 50 MHz oscillator: phase-locked loop, clock source: high speed external uart2: pins tx=PA2/rx=PA3, af=7, console sd0: port sdio0 sd0: type SDHC, size 31178752 kbytes sd0a: partition type b7, sector 2, size 204800 kbytes sd0b: partition type b8, sector 409602, size 2048 kbytes sd0c: partition type b7, sector 413698, size 204800 kbytes phys mem = 256 kbytes user mem = 96 kbytes root dev = (0,1) swap dev = (0,2) root size = 204800 kbytes swap size = 2048 kbytes Automatic boot in progress: starting file system checks. /dev/sd0a: 1475 files, 12210 used, 191789 free /dev/sd0c: 3 files, 3 used, 203996 free Updating motd... done Starting daemons: update cron Wed Feb 11 11:11:11 MST 2026 2.11 BSD UNIX (name.my.domain) (console) login: root Password: DiscoBSD 2.6 (F412GDISCO) #1 755: Wed Feb 11 11:11:11 MST 2026 Welcome to DiscoBSD. erase ^?, kill ^U, intr ^C # ``` `DiscoBSD/pic32` dmesg -------------------- ``` DiscoBSD 2.6 (MAX32) #1 755: Wed Feb 11 11:11:11 MST 2026 chris@pic32.discobsd.org:/sys/arch/pic32/compile/MAX32 cpu: 795F512L 80 MHz, bus 80 MHz oscillator: HS crystal, PLL div 1:2 mult x20 spi2: pins sdi=RG7/sdo=RG8/sck=RG6 uart1: pins rx=RF2/tx=RF8, interrupts 26/27/28, console uart2: pins rx=RF4/tx=RF5, interrupts 40/41/42 uart4: pins rx=RD14/tx=RD15, interrupts 67/68/69 sd0: port spi2, pin cs=RC14 gpio0: portA, pins ii---ii-iiiioiii gpio1: portB, pins iiiiiiiiiiiiiiii gpio2: portC, pins i-ii-------iiii- gpio3: portD, pins --iiiiiiiiiiiiii gpio4: portE, pins ------iiiiiiiiii gpio5: portF, pins --ii--------i-ii gpio6: portG, pins iiii--i-----iiii adc: 15 channels pwm: 5 channels sd0: type I, size 524288 kbytes, speed 10 Mbit/sec sd0a: partition type b7, sector 2, size 204800 kbytes sd0b: partition type b8, sector 409602, size 2048 kbytes sd0c: partition type b7, sector 413698, size 204800 kbytes phys mem = 128 kbytes user mem = 96 kbytes root dev = (0,1) swap dev = (0,2) root size = 204800 kbytes swap size = 2048 kbytes Automatic boot in progress: starting file system checks. /dev/sd0a: 1468 files, 13581 used, 190418 free /dev/sd0c: 3 files, 3 used, 203996 free Updating motd... done Starting daemons: update cron Wed Feb 11 11:11:11 MST 2026 2.11 BSD UNIX (name.my.domain) (console) login: root Password: DiscoBSD 2.6 (MAX32) #1 755: Wed Feb 11 11:11:11 MST 2026 Welcome to DiscoBSD. erase ^?, kill ^U, intr ^C # ``` ================================================ FILE: bin/Makefile ================================================ # # Copyright (c) 1980 Regents of the University of California. # All rights reserved. The Berkeley software License Agreement # specifies the terms and conditions for redistribution. # TOPSRC!=cd ..; pwd include ${TOPSRC}/share/mk/sys.mk SUBDIR= date2 hostname ls md5 sh stty test \ cat chgrp chmod cp dd df echo ed expr kill ln mkdir mv ps \ pwd rm rmail rmdir sleep sync tar # TODO: csh all: ${SUBDIR} ${SUBDIR}: FRC ${MAKE} -C $@ ${MFLAGS} FRC: install: -for i in ${SUBDIR}; do \ ${MAKE} -C $$i ${MFLAGS} DESTDIR=${DESTDIR} install; done clean: /bin/rm -f a.out core *.s *.o *.dis *.elf *~ y.tab.[ch] errs for i in ${SUBDIR}; do (cd $$i; ${MAKE} ${MFLAGS} clean); done ================================================ FILE: bin/csh/Makefile ================================================ # # Copyright (c) 1980 Regents of the University of California. # All rights reserved. The Berkeley Software License Agreement # specifies the terms and conditions for redistribution. # # C Shell with process control; VM/UNIX VAX Makefile # Bill Joy UC Berkeley; Jim Kulp IIASA, Austria # # To profile, put -DPROF in DEFS and -pg in CFLAGS, and recompile. # TOPSRC!=cd ../..; pwd include ${TOPSRC}/share/mk/sys.mk CFLAGS += -DTELL -DVFORK -DFILEC -DNOLIMITS -Os OBJS = alloc.o printf.o sh.char.o sh.dir.o sh.dol.o \ sh.err.o sh.exp.o sh.file.o sh.func.o sh.glob.o sh.hist.o \ sh.init.o sh.lex.o sh.misc.o sh.parse.o sh.print.o sh.proc.o sh.sem.o \ sh.set.o sh.o sh.exec.o sh.time.o sh.exec2.o all: csh csh: ${OBJS} ${CC} ${CFLAGS} ${LDFLAGS} -o csh.elf ${OBJS} ${LIBS} ${OBJDUMP} -S csh.elf > csh.dis ${SIZE} csh.elf ${ELF2AOUT} csh.elf $@ && rm csh.elf install: all ${INSTALL} csh ${DESTDIR}/bin/ clean: rm -f csh *.o *~ *.elf *.dis sh.o: sh.h sh.local.h sh.char.h sh.char.o: sh.char.h sh.dir.o: sh.h sh.local.h sh.dir.h sh.dol.o: sh.h sh.local.h sh.char.h sh.err.o: sh.h sh.local.h sh.char.h sh.exec.o: sh.h sh.local.h sh.char.h sh.exec2.o: sh.h sh.local.h sh.char.h sh.exp.o: sh.h sh.local.h sh.char.h sh.file.o: sh.h sh.local.h sh.char.h sh.func.o: sh.h sh.local.h sh.char.h sh.glob.o: sh.h sh.local.h sh.char.h sh.hist.o: sh.h sh.local.h sh.char.h sh.init.o: sh.local.h sh.lex.o: sh.h sh.local.h sh.char.h sh.misc.o: sh.h sh.local.h sh.char.h sh.parse.o: sh.h sh.local.h sh.char.h sh.print.o: sh.h sh.local.h sh.char.h sh.proc.o: sh.h sh.local.h sh.dir.h sh.proc.h sh.char.h sh.sem.o: sh.h sh.local.h sh.proc.h sh.char.h sh.set.o: sh.h sh.local.h sh.char.h sh.time.o: sh.h sh.local.h sh.char.h ================================================ FILE: bin/csh/alloc.c ================================================ /* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ /* * malloc.c (Caltech) 2/21/82 * Chris Kingsley, kingsley@cit-20. * * This is a very fast storage allocator. It allocates blocks of a small * number of different sizes, and keeps free lists of each size. Blocks that * don't exactly fit are passed up to the next larger size. In this * implementation, the available sizes are 2^n-4 (or 2^n-10) bytes long. * This is designed for use in a virtual memory environment. */ #include #include #include #include #ifndef NULL #define NULL 0 #endif /* * The overhead on a block is at least 4 bytes. When free, this space * contains a pointer to the next free block, and the bottom two bits must * be zero. When in use, the first byte is set to MAGIC, and the second * byte is the size index. The remaining bytes are for alignment. * If range checking is enabled then a second word holds the size of the * requested block, less 1, rounded up to a multiple of sizeof(RMAGIC). * The order of elements is critical: ov_magic must overlay the low order * bits of ov_next, and ov_magic can not be a valid ov_next bit pattern. */ union overhead { union overhead *ov_next; /* when free */ struct { u_char ovu_magic; /* magic number */ u_char ovu_index; /* bucket # */ #ifdef RCHECK u_short ovu_rmagic; /* range magic number */ u_int ovu_size; /* actual block size */ #endif } ovu; #define ov_magic ovu.ovu_magic #define ov_index ovu.ovu_index #define ov_rmagic ovu.ovu_rmagic #define ov_size ovu.ovu_size }; #define MAGIC 0xef /* magic # on accounting info */ #define RMAGIC 0x5555 /* magic # on range info */ #ifdef RCHECK #define RSLOP sizeof (u_short) #else #define RSLOP 0 #endif /* * nextf[i] is the pointer to the next free block of size 2^(i+3). The * smallest allocatable block is 8 bytes. The overhead information * precedes the data area returned to the user. */ #define NBUCKETS 30 static union overhead *nextf[NBUCKETS]; extern char *sbrk(); static int pagesz; /* page size */ static int pagebucket; /* page size bucket */ /* * nmalloc[i] is the difference between the number of mallocs and frees * for a given block size. */ static u_int nmalloc[NBUCKETS]; #if defined(DEBUG) || defined(RCHECK) #define ASSERT(p) if (!(p)) botch("p") static botch(s) char *s; { printf("\r\nassertion botched: %s\r\n", s); abort(); } #else #define ASSERT(p) #endif void * malloc(nbytes) size_t nbytes; { register union overhead *op; register int bucket; register unsigned amt, n; /* * First time malloc is called, setup page size and * align break pointer so all data will be page aligned. */ if (pagesz == 0) { pagesz = n = getpagesize(); op = (union overhead *)sbrk(0); n = n - sizeof (*op) - ((int)op & (n - 1)); if (n < 0) n += pagesz; if (n) { if (sbrk(n) == (char *)-1) return (NULL); } bucket = 0; amt = 8; while (pagesz > amt) { amt <<= 1; bucket++; } pagebucket = bucket; } /* * Convert amount of memory requested into closest block size * stored in hash buckets which satisfies request. * Account for space used per block for accounting. */ if (nbytes <= (n = pagesz - sizeof (*op) - RSLOP)) { #ifndef RCHECK amt = 8; /* size of first bucket */ bucket = 0; #else amt = 16; /* size of first bucket */ bucket = 1; #endif n = -(sizeof (*op) + RSLOP); } else { amt = pagesz; bucket = pagebucket; } while (nbytes > amt + n) { amt <<= 1; if (amt == 0) return (NULL); bucket++; } /* * If nothing in hash bucket right now, * request more memory from the system. */ if ((op = nextf[bucket]) == NULL) { morecore(bucket); if ((op = nextf[bucket]) == NULL) return (NULL); } /* remove from linked list */ nextf[bucket] = op->ov_next; op->ov_magic = MAGIC; op->ov_index = bucket; nmalloc[bucket]++; #ifdef RCHECK /* * Record allocated size of block and * bound space with magic numbers. */ op->ov_size = (nbytes + RSLOP - 1) & ~(RSLOP - 1); op->ov_rmagic = RMAGIC; *(u_short *)((caddr_t)(op + 1) + op->ov_size) = RMAGIC; #endif return ((char *)(op + 1)); } /* * Allocate more memory to the indicated bucket. */ morecore(bucket) int bucket; { register union overhead *op; register int sz; /* size of desired block */ int amt; /* amount to allocate */ int nblks; /* how many blocks we get */ /* * sbrk_size <= 0 only for big, FLUFFY, requests (about * 2^30 bytes on a VAX, I think) or for a negative arg. */ sz = 1 << (bucket + 3); #ifdef DEBUG ASSERT(sz > 0); #else if (sz <= 0) return; #endif if (sz < pagesz) { amt = pagesz; nblks = amt / sz; } else { amt = sz + pagesz; nblks = 1; } op = (union overhead *)sbrk(amt); /* no more room! */ if ((int)op == -1) return; /* * Add new memory allocated to that on * free list for this hash bucket. */ nextf[bucket] = op; while (--nblks > 0) { op->ov_next = (union overhead *)((caddr_t)op + sz); op = (union overhead *)((caddr_t)op + sz); } } void free(cp) void *cp; { register int size; register union overhead *op; if (cp == NULL) return; op = (union overhead *)((caddr_t)cp - sizeof (union overhead)); /* * The following botch is because csh tries to free a free block * when processing the =~ or !~ operators. -- layer@ucbmonet */ #ifdef CSHbotch /* was DEBUG */ ASSERT(op->ov_magic == MAGIC); /* make sure it was in use */ #else if (op->ov_magic != MAGIC) return; /* sanity */ #endif #ifdef RCHECK ASSERT(op->ov_rmagic == RMAGIC); ASSERT(*(u_short *)((caddr_t)(op + 1) + op->ov_size) == RMAGIC); #endif size = op->ov_index; ASSERT(size < NBUCKETS); op->ov_next = nextf[size]; /* also clobbers ov_magic */ nextf[size] = op; nmalloc[size]--; } /* * Search ``srchlen'' elements of each free list for a block whose * header starts at ``freep''. If srchlen is -1 search the whole list. * Return bucket number, or -1 if not found. */ static findbucket(freep, srchlen) union overhead *freep; int srchlen; { register union overhead *p; register int i, j; for (i = 0; i < NBUCKETS; i++) { j = 0; for (p = nextf[i]; p && j != srchlen; p = p->ov_next) { if (p == freep) return (i); j++; } } return (-1); } /* * When a program attempts "storage compaction" as mentioned in the * old malloc man page, it realloc's an already freed block. Usually * this is the last block it freed; occasionally it might be farther * back. We have to search all the free lists for the block in order * to determine its bucket: 1st we make one pass thru the lists * checking only the first block in each; if that fails we search * ``realloc_srchlen'' blocks in each list for a match (the variable * is extern so the caller can modify it). If that fails we just copy * however many bytes was given to realloc() and hope it's not huge. */ int realloc_srchlen = 4; /* 4 should be plenty, -1 =>'s whole list */ void * realloc(cp, nbytes) void *cp; size_t nbytes; { register u_int onb, i; union overhead *op; char *res; int was_alloced = 0; if (cp == NULL) return (malloc(nbytes)); op = (union overhead *)((caddr_t)cp - sizeof (union overhead)); if (op->ov_magic == MAGIC) { was_alloced++; i = op->ov_index; } else { /* * Already free, doing "compaction". * * Search for the old block of memory on the * free list. First, check the most common * case (last element free'd), then (this failing) * the last ``realloc_srchlen'' items free'd. * If all lookups fail, then assume the size of * the memory block being realloc'd is the * largest possible (so that all "nbytes" of new * memory are copied into). Note that this could cause * a memory fault if the old area was tiny, and the moon * is gibbous. However, that is very unlikely. */ if ((i = findbucket(op, 1)) < 0 && (i = findbucket(op, realloc_srchlen)) < 0) i = NBUCKETS; } onb = 1 << (i + 3); if (onb < pagesz) onb -= sizeof (*op) + RSLOP; else onb += pagesz - sizeof (*op) - RSLOP; /* avoid the copy if same size block */ if (was_alloced) { if (i) { i = 1 << (i + 2); if (i < pagesz) i -= sizeof (*op) + RSLOP; else i += pagesz - sizeof (*op) - RSLOP; } if (nbytes <= onb && nbytes > i) { #ifdef RCHECK op->ov_size = (nbytes + RSLOP - 1) & ~(RSLOP - 1); *(u_short *)((caddr_t)(op + 1) + op->ov_size) = RMAGIC; #endif return(cp); } else free(cp); } if ((res = malloc(nbytes)) == NULL) return (NULL); if (cp != res) /* common optimization if "compacting" */ bcopy(cp, res, (nbytes < onb) ? nbytes : onb); return (res); } /* * mstats - print out statistics about malloc * * Prints two lines of numbers, one showing the length of the free list * for each size category, the second showing the number of mallocs - * frees for each size category. */ showall(s) char **s; { register int i, j; register union overhead *p; int totfree = 0, totused = 0; if (s[1]) printf("Memory allocation statistics %s\nfree:", s[1]); for (i = 0; i < NBUCKETS; i++) { for (j = 0, p = nextf[i]; p; p = p->ov_next, j++) ; if (s[1]) printf(" %d", j); totfree += j * (1 << (i + 3)); } if (s[1]) printf("\nused:"); for (i = 0; i < NBUCKETS; i++) { if (s[1]) printf(" %d", nmalloc[i]); totused += nmalloc[i] * (1 << (i + 3)); } if (s[1]) printf("\n"); printf("Total in use: %d, total free: %d\n", totused, totfree); } ================================================ FILE: bin/csh/printf.c ================================================ /* * Scaled down version of printf(3). * Based on FreeBSD sources, heavily rewritten. * * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include #include #include #include #include /* Max number conversion buffer length: a long in base 2, plus NUL byte. */ #define MAXNBUF (sizeof(long) * 8 + 1) static unsigned char *ksprintn (unsigned char *buf, unsigned long v, unsigned char base, int width, unsigned char *lp); static unsigned char mkhex (unsigned char ch); int shprintf (char const *fmt, ...) { #define PUTC(c) { putchr (c); ++retval; } unsigned char nbuf [MAXNBUF], padding, *q; const unsigned char *s; unsigned char c, base, lflag, ladjust, sharpflag, neg, dot, size; int n, width, dwidth, retval, uppercase, extrazeros, sign; unsigned long ul; va_list ap; va_start (ap, fmt); if (! fmt) fmt = "(null)\n"; retval = 0; for (;;) { while ((c = *fmt++) != '%') { if (! c) { va_end (ap); return retval; } PUTC (c); } padding = ' '; width = 0; extrazeros = 0; lflag = 0; ladjust = 0; sharpflag = 0; neg = 0; sign = 0; dot = 0; uppercase = 0; dwidth = -1; reswitch: switch (c = *fmt++) { case '.': dot = 1; padding = ' '; dwidth = 0; goto reswitch; case '#': sharpflag = 1; goto reswitch; case '+': sign = -1; goto reswitch; case '-': ladjust = 1; goto reswitch; case '%': PUTC (c); break; case '*': if (! dot) { width = va_arg (ap, int); if (width < 0) { ladjust = !ladjust; width = -width; } } else { dwidth = va_arg (ap, int); } goto reswitch; case '0': if (! dot) { padding = '0'; goto reswitch; } case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': for (n=0; ; ++fmt) { n = n * 10 + c - '0'; c = *fmt; if (c < '0' || c > '9') break; } if (dot) dwidth = n; else width = n; goto reswitch; case 'c': if (! ladjust && width > 0) while (width--) PUTC (' '); PUTC (va_arg (ap, int)); if (ladjust && width > 0) while (width--) PUTC (' '); break; case 'd': ul = lflag ? va_arg (ap, long) : va_arg (ap, int); if (! sign) sign = 1; base = 10; goto number; case 'l': lflag = 1; goto reswitch; case 'o': ul = lflag ? va_arg (ap, unsigned long) : va_arg (ap, unsigned int); base = 8; goto nosign; case 'p': ul = (size_t) va_arg (ap, void*); if (! ul) { s = (const unsigned char*) "(nil)"; goto string; } base = 16; sharpflag = (width == 0); goto nosign; case 'n': ul = lflag ? va_arg (ap, unsigned long) : sign ? (unsigned long) va_arg (ap, int) : va_arg (ap, unsigned int); base = 10; goto number; case 's': s = va_arg (ap, unsigned char*); if (! s) s = (const unsigned char*) "(null)"; string: if (! dot) n = strlen (s); else for (n=0; n 0) while (width--) PUTC (' '); while (n--) PUTC (*s++); if (ladjust && width > 0) while (width--) PUTC (' '); break; case 'u': ul = lflag ? va_arg (ap, unsigned long) : va_arg (ap, unsigned int); base = 10; goto nosign; case 'x': case 'X': ul = lflag ? va_arg (ap, unsigned long) : va_arg (ap, unsigned int); base = 16; uppercase = (c == 'X'); goto nosign; case 'z': case 'Z': ul = lflag ? va_arg (ap, unsigned long) : sign ? (unsigned long) va_arg (ap, int) : va_arg (ap, unsigned int); base = 16; uppercase = (c == 'Z'); goto number; nosign: sign = 0; number: if (sign && ((long) ul != 0L)) { if ((long) ul < 0L) { neg = '-'; ul = -(long) ul; } else if (sign < 0) neg = '+'; } if (dwidth >= (int) sizeof(nbuf)) { extrazeros = dwidth - sizeof(nbuf) + 1; dwidth = sizeof(nbuf) - 1; } s = ksprintn (nbuf, ul, base, dwidth, &size); if (sharpflag && ul != 0) { if (base == 8) size++; else if (base == 16) size += 2; } if (neg) size++; if (! ladjust && width && padding == ' ' && (width -= size) > 0) do { PUTC (' '); } while (--width > 0); if (neg) PUTC (neg); if (sharpflag && ul != 0) { if (base == 8) { PUTC ('0'); } else if (base == 16) { PUTC ('0'); PUTC (uppercase ? 'X' : 'x'); } } if (extrazeros) do { PUTC ('0'); } while (--extrazeros > 0); if (! ladjust && width && (width -= size) > 0) do { PUTC (padding); } while (--width > 0); for (; *s; --s) { if (uppercase && *s>='a' && *s<='z') { PUTC (*s + 'A' - 'a'); } else { PUTC (*s); } } if (ladjust && width && (width -= size) > 0) do { PUTC (' '); } while (--width > 0); break; default: PUTC ('%'); if (lflag) PUTC ('l'); PUTC (c); break; } } } /* * Put a NUL-terminated ASCII number (base <= 16) in a buffer in reverse * order; return an optional length and a pointer to the last character * written in the buffer (i.e., the first character of the string). * The buffer pointed to by `nbuf' must have length >= MAXNBUF. */ static unsigned char * ksprintn (unsigned char *nbuf, unsigned long ul, unsigned char base, int width, unsigned char *lenp) { unsigned char *p; p = nbuf; *p = 0; for (;;) { *++p = mkhex (ul % base); ul /= base; if (--width > 0) continue; if (! ul) break; } if (lenp) *lenp = p - nbuf; return (p); } static unsigned char mkhex (unsigned char ch) { ch &= 15; if (ch > 9) return ch + 'a' - 10; return ch + '0'; } ================================================ FILE: bin/csh/sh.c ================================================ /* * C Shell * * Bill Joy, UC Berkeley, California, USA * October 1978, May 1980 * * Jim Kulp, IIASA, Laxenburg, Austria * April 1980 * * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley Software License Agreement * specifies the terms and conditions for redistribution. */ #include "sh.h" #include char *pathlist[] = { "/bin", 0 }; char *dumphist[] = { "history", "-h", 0, 0 }; char *loadhist[] = { "source", "-h", "~/.history", 0 }; char HIST = '!'; char HISTSUB = '^'; bool nofile; bool reenter; bool nverbose; bool nexececho; bool quitit; bool fast; bool batch; bool prompt = 1; bool enterhist = 0; extern gid_t getegid(), getgid(); extern uid_t geteuid(), getuid(); /* * in the event of a HUP we want to save the history */ void phup(int sig) { rechist(); exit(1); } /* * Catch an interrupt, e.g. during lexical input. * If we are an interactive shell, we reset the interrupt catch * immediately. In any case we drain the shell output, * and finally go through the normal error mechanism, which * gets a chance to make the shell go away. */ void pintr(int sig) { pintr1(1); } int main(c, av) int c; char **av; { register char **v, *cp; register int f; struct sigvec osv; settimes(); /* Immed. estab. timing base */ v = av; if (eq(v[0], "a.out")) /* A.out's are quittable */ quitit = 1; uid = getuid(); loginsh = **v == '-' && c == 1; if (loginsh) (void) time(&chktim); /* * Move the descriptors to safe places. * The variable didfds is 0 while we have only FSH* to work with. * When didfds is true, we have 0,1,2 and prefer to use these. */ initdesc(); /* * Initialize the shell variables. * ARGV and PROMPT are initialized later. * STATUS is also munged in several places. * CHILD is munged when forking/waiting */ set("status", "0"); dinit(cp = getenv("HOME")); /* dinit thinks that HOME == cwd in a * login shell */ if (cp == NOSTR) fast++; /* No home -> can't read scripts */ else set("home", savestr(cp)); /* * Grab other useful things from the environment. * Should we grab everything?? */ if ((cp = getenv("USER")) != NOSTR) set("user", savestr(cp)); if ((cp = getenv("TERM")) != NOSTR) set("term", savestr(cp)); /* * Re-initialize path if set in environment */ if ((cp = getenv("PATH")) == NOSTR) set1("path", saveblk(pathlist), &shvhed); else importpath(cp); set("shell", SHELLPATH); doldol = putn(getpid()); /* For $$ */ shtemp = strspl("/tmp/sh", doldol); /* For << */ /* * Record the interrupt states from the parent process. * If the parent is non-interruptible our hand must be forced * or we (and our children) won't be either. * Our children inherit termination from our parent. * We catch it only if we are the login shell. */ /* parents interruptibility */ (void) sigvec(SIGINT, (struct sigvec *)0, &osv); parintr = osv.sv_handler; /* parents terminability */ (void) sigvec(SIGTERM, (struct sigvec *)0, &osv); parterm = osv.sv_handler; if (loginsh) { (void) signal(SIGHUP, phup); /* exit processing on HUP */ (void) signal(SIGXCPU, phup); /* ...and on XCPU */ (void) signal(SIGXFSZ, phup); /* ...and on XFSZ */ } /* * Process the arguments. * * Note that processing of -v/-x is actually delayed till after * script processing. */ c--, v++; while (c > 0 && (cp = v[0])[0] == '-' && *++cp != '\0' && !batch) { do switch (*cp++) { case 'b': /* -b Next arg is input file */ batch++; break; case 'c': /* -c Command input from arg */ if (c == 1) exit(0); c--, v++; arginp = v[0]; prompt = 0; nofile++; break; case 'e': /* -e Exit on any error */ exiterr++; break; case 'f': /* -f Fast start */ fast++; break; case 'i': /* -i Interactive, even if !intty */ intact++; nofile++; break; case 'n': /* -n Don't execute */ noexec++; break; case 'q': /* -q (Undoc'd) ... die on quit */ quitit = 1; break; case 's': /* -s Read from std input */ nofile++; break; case 't': /* -t Read one line from input */ onelflg = 2; prompt = 0; nofile++; break; case 'v': /* -v Echo hist expanded input */ nverbose = 1; /* ... later */ break; case 'x': /* -x Echo just before execution */ nexececho = 1; /* ... later */ break; case 'V': /* -V Echo hist expanded input */ setNS("verbose"); /* NOW! */ break; case 'X': /* -X Echo just before execution */ setNS("echo"); /* NOW! */ break; } while (*cp); v++, c--; } if (quitit) /* With all due haste, for debugging */ (void) signal(SIGQUIT, SIG_DFL); /* * Unless prevented by -c, -i, -s, or -t, if there * are remaining arguments the first of them is the name * of a shell file from which to read commands. */ if (nofile == 0 && c > 0) { nofile = open(v[0], 0); if (nofile < 0) { child++; /* So this ... */ Perror(v[0]); /* ... doesn't return */ } file = v[0]; SHIN = dmove(nofile, FSHIN); /* Replace FSHIN */ (void) ioctl(SHIN, FIOCLEX, (char *)0); prompt = 0; c--, v++; } if (!batch && (uid != geteuid() || getgid() != getegid())) { errno = EACCES; child++; /* So this ... */ Perror("csh"); /* ... doesn't return */ } /* * Consider input a tty if it really is or we are interactive. */ intty = intact || isatty(SHIN); /* * Decide whether we should play with signals or not. * If we are explicitly told (via -i, or -) or we are a login * shell (arg0 starts with -) or the input and output are both * the ttys("csh", or "csh/dev/ttyx") * Note that in only the login shell is it likely that parent * may have set signals to be ignored */ if (loginsh || intact || intty && isatty(SHOUT)) setintr = 1; #ifdef TELL settell(); #endif /* * Save the remaining arguments in argv. */ setq("argv", v, &shvhed); /* * Set up the prompt. */ if (prompt) set("prompt", uid == 0 ? "# " : "% "); /* * If we are an interactive shell, then start fiddling * with the signals; this is a tricky game. */ shpgrp = getpgrp(0); opgrp = tpgrp = -1; oldisc = -1; if (setintr) { **av = '-'; if (!quitit) /* Wary! */ (void) signal(SIGQUIT, SIG_IGN); (void) signal(SIGINT, pintr); (void) sigblock(sigmask(SIGINT)); (void) signal(SIGTERM, SIG_IGN); if (quitit == 0 && arginp == 0) { (void) signal(SIGTSTP, SIG_IGN); (void) signal(SIGTTIN, SIG_IGN); (void) signal(SIGTTOU, SIG_IGN); /* * Wait till in foreground, in case someone * stupidly runs * csh & * dont want to try to grab away the tty. */ if (isatty(FSHDIAG)) f = FSHDIAG; else if (isatty(FSHOUT)) f = FSHOUT; else if (isatty(OLDSTD)) f = OLDSTD; else f = -1; retry: if (ioctl(f, TIOCGPGRP, (char *)&tpgrp) == 0 && tpgrp != -1) { int ldisc; if (tpgrp != shpgrp) { void (*old)(int) = signal(SIGTTIN, SIG_DFL); (void) kill(0, SIGTTIN); (void) signal(SIGTTIN, old); goto retry; } if (ioctl(f, TIOCGETD, (char *)&oldisc) != 0) goto notty; if (oldisc != NTTYDISC) { #ifdef DEBUG printf("Switching to new tty driver...\n"); #endif ldisc = NTTYDISC; (void) ioctl(f, TIOCSETD, (char *)&ldisc); } else oldisc = -1; opgrp = shpgrp; shpgrp = getpid(); tpgrp = shpgrp; (void) ioctl(f, TIOCSPGRP, (char *)&shpgrp); (void) setpgrp(0, shpgrp); (void) ioctl(dcopy(f, FSHTTY), FIOCLEX, (char *)0); } else { notty: printf("Warning: no access to tty; thus no job control in this shell...\n"); tpgrp = -1; } } } if (setintr == 0 && parintr == SIG_DFL) setintr++; (void) signal(SIGCHLD, pchild); /* while signals not ready */ /* * Set an exit here in case of an interrupt or error reading * the shell start-up scripts. */ setexit(); haderr = 0; /* In case second time through */ if (!fast && reenter == 0) { reenter++; /* Will have value("home") here because set fast if don't */ srccat(value("home"), "/.cshrc"); if (!fast && !arginp && !onelflg && !havhash) dohash(); if (loginsh) { srccat(value("home"), "/.login"); } dosource(loadhist); } /* * Now are ready for the -v and -x flags */ if (nverbose) setNS("verbose"); if (nexececho) setNS("echo"); /* * All the rest of the world is inside this call. * The argument to process indicates whether it should * catch "error unwinds". Thus if we are a interactive shell * our call here will never return by being blown past on an error. */ process(setintr); /* * Mop-up. */ if (loginsh) { printf("logout\n"); (void) close(SHIN); child++; goodbye(); } rechist(); exitstat(); } untty() { if (tpgrp > 0) { (void) setpgrp(0, opgrp); (void) ioctl(FSHTTY, TIOCSPGRP, (char *)&opgrp); if (oldisc != -1 && oldisc != NTTYDISC) { #ifdef DEBUG printf("\nReverting to old tty driver...\n"); #endif (void) ioctl(FSHTTY, TIOCSETD, (char *)&oldisc); } } } importpath(cp) char *cp; { register int i = 0; register char *dp; register char **pv; int c; static char dot[2] = {'.', 0}; for (dp = cp; *dp; dp++) if (*dp == ':') i++; /* * i+2 where i is the number of colons in the path. * There are i+1 directories in the path plus we need * room for a zero terminator. */ pv = (char **) calloc((unsigned) (i + 2), sizeof (char **)); dp = cp; i = 0; if (*dp) for (;;) { if ((c = *dp) == ':' || c == 0) { *dp = 0; pv[i++] = savestr(*cp ? cp : dot); if (c) { cp = dp + 1; *dp = ':'; } else break; } dp++; } pv[i] = 0; set1("path", pv, &shvhed); } /* * Source to the file which is the catenation of the argument names. */ srccat(cp, dp) char *cp, *dp; { register char *ep = strspl(cp, dp); register int unit = dmove(open(ep, 0), -1); (void) ioctl(unit, FIOCLEX, (char *)0); xfree(ep); #ifdef INGRES srcunit(unit, 0, 0); #else srcunit(unit, 1, 0); #endif } /* * Source to a unit. If onlyown it must be our file or our group or * we don't chance it. This occurs on ".cshrc"s and the like. */ srcunit(unit, onlyown, hflg) register int unit; bool onlyown; bool hflg; { /* We have to push down a lot of state here */ /* All this could go into a structure */ int oSHIN = -1, oldintty = intty; struct whyle *oldwhyl = whyles; char *ogointr = gointr, *oarginp = arginp; char *oevalp = evalp, **oevalvec = evalvec; int oonelflg = onelflg; bool oenterhist = enterhist; char OHIST = HIST; #ifdef TELL bool otell = cantell; #endif struct Bin saveB; /* The (few) real local variables */ jmp_buf oldexit; int reenter; long omask; if (unit < 0) return; if (didfds) donefds(); if (onlyown) { struct stat stb; if (fstat(unit, &stb) < 0 || (stb.st_uid != uid && stb.st_gid != getgid())) { (void) close(unit); return; } } /* * There is a critical section here while we are pushing down the * input stream since we have stuff in different structures. * If we weren't careful an interrupt could corrupt SHIN's Bin * structure and kill the shell. * * We could avoid the critical region by grouping all the stuff * in a single structure and pointing at it to move it all at * once. This is less efficient globally on many variable references * however. */ getexit(oldexit); reenter = 0; if (setintr) omask = sigblock(sigmask(SIGINT)); setexit(); reenter++; if (reenter == 1) { /* Setup the new values of the state stuff saved above */ memcpy((char *)&saveB, (char *)&B, sizeof saveB); fbuf = (char **) 0; fseekp = feobp = fblocks = 0; oSHIN = SHIN, SHIN = unit, arginp = 0, onelflg = 0; intty = isatty(SHIN), whyles = 0, gointr = 0; evalvec = 0; evalp = 0; enterhist = hflg; if (enterhist) HIST = '\0'; /* * Now if we are allowing commands to be interrupted, * we let ourselves be interrupted. */ if (setintr) (void) sigsetmask(omask); #ifdef TELL settell(); #endif process(0); /* 0 -> blow away on errors */ } if (setintr) (void) sigsetmask(omask); if (oSHIN >= 0) { register int i; /* We made it to the new state... free up its storage */ /* This code could get run twice but xfree doesn't care */ for (i = 0; i < fblocks; i++) xfree(fbuf[i]); xfree((char *)fbuf); /* Reset input arena */ memcpy((char *)&B, (char *)&saveB, sizeof B); (void) close(SHIN), SHIN = oSHIN; arginp = oarginp, onelflg = oonelflg; evalp = oevalp, evalvec = oevalvec; intty = oldintty, whyles = oldwhyl, gointr = ogointr; if (enterhist) HIST = OHIST; enterhist = oenterhist; #ifdef TELL cantell = otell; #endif } resexit(oldexit); /* * If process reset() (effectively an unwind) then * we must also unwind. */ if (reenter >= 2) error(NOSTR); } rechist() { char buf[BUFSIZ]; int fp, ftmp, oldidfds; if (!fast) { if (value("savehist")[0] == '\0') return; (void) strcpy(buf, value("home")); (void) strcat(buf, "/.history"); fp = creat(buf, 0666); if (fp == -1) return; oldidfds = didfds; didfds = 0; ftmp = SHOUT; SHOUT = fp; (void) strcpy(buf, value("savehist")); dumphist[2] = buf; dohist(dumphist); (void) close(fp); SHOUT = ftmp; didfds = oldidfds; } } goodbye() { if (loginsh) { (void) signal(SIGQUIT, SIG_IGN); (void) signal(SIGINT, SIG_IGN); (void) signal(SIGTERM, SIG_IGN); setintr = 0; /* No interrupts after "logout" */ if (adrof("home")) srccat(value("home"), "/.logout"); } rechist(); exitstat(); } exitstat() { #ifdef PROF monitor(0); #endif /* * Note that if STATUS is corrupted (i.e. getn bombs) * then error will exit directly because we poke child here. * Otherwise we might continue unwarrantedly (sic). */ child++; exit(getn(value("status"))); } char *jobargv[2] = { "jobs", 0 }; pintr1(wantnl) bool wantnl; { register char **v; long omask; omask = sigblock(0L); if (setintr) { (void) sigsetmask(omask & ~sigmask(SIGINT)); if (pjobs) { pjobs = 0; printf("\n"); dojobs(jobargv); bferr("Interrupted"); } } (void) sigsetmask(omask & ~sigmask(SIGCHLD)); draino(); /* * If we have an active "onintr" then we search for the label. * Note that if one does "onintr -" then we shan't be interruptible * so we needn't worry about that here. */ if (gointr) { search(ZGOTO, 0, gointr); timflg = 0; if (v = pargv) pargv = 0, blkfree(v); if (v = gargv) gargv = 0, blkfree(v); reset(); } else if (intty && wantnl) printf("\n"); /* Some like this, others don't */ error(NOSTR); } /* * Process is the main driving routine for the shell. * It runs all command processing, except for those within { ... } * in expressions (which is run by a routine evalav in sh.exp.c which * is a stripped down process), and `...` evaluation which is run * also by a subset of this code in sh.glob.c in the routine backeval. * * The code here is a little strange because part of it is interruptible * and hence freeing of structures appears to occur when none is necessary * if this is ignored. * * Note that if catch is not set then we will unwind on any error. * If an end-of-file occurs, we return. */ process(catch) bool catch; { jmp_buf osetexit; register struct command *t; getexit(osetexit); for (;;) { pendjob(); paraml.next = paraml.prev = ¶ml; paraml.word = ""; t = 0; setexit(); justpr = enterhist; /* execute if not entering history */ /* * Interruptible during interactive reads */ if (setintr) (void) sigsetmask(sigblock(0L) & ~sigmask(SIGINT)); /* * For the sake of reset() */ freelex(¶ml), freesyn(t), t = 0; if (haderr) { if (!catch) { /* unwind */ doneinp = 0; resexit(osetexit); reset(); } haderr = 0; /* * Every error is eventually caught here or * the shell dies. It is at this * point that we clean up any left-over open * files, by closing all but a fixed number * of pre-defined files. Thus routines don't * have to worry about leaving files open due * to deeper errors... they will get closed here. */ closem(); continue; } if (doneinp) { doneinp = 0; break; } if (chkstop) chkstop--; if (neednote) pnote(); if (intty && prompt && evalvec == 0) { mailchk(); /* * If we are at the end of the input buffer * then we are going to read fresh stuff. * Otherwise, we are rereading input and don't * need or want to prompt. */ if (fseekp == feobp) printprompt(); } parserr = 0; /* * Echo not only on VERBOSE, but also with history expansion. * If there is a lexical error then we forego history echo. */ if (lex(¶ml) && !parserr && intty || adrof("verbose")) { haderr = 1; prlex(¶ml); haderr = 0; } /* * The parser may lose space if interrupted. */ if (setintr) (void) sigblock(sigmask(SIGINT)); /* * Save input text on the history list if * reading in old history, or it * is from the terminal at the top level and not * in a loop. */ if (enterhist || catch && intty && !whyles) savehist(¶ml); /* * Print lexical error messages, except when sourcing * history lists. */ if (!enterhist && parserr) error(parserr); /* * If had a history command :p modifier then * this is as far as we should go */ if (justpr) reset(); alias(¶ml); /* * Parse the words of the input into a parse tree. */ t = syntax(paraml.next, ¶ml, 0); if (parserr) error(parserr); /* * Execute the parse tree */ execute(t, tpgrp); /* * Made it! */ freelex(¶ml), freesyn(t); } resexit(osetexit); } dosource(t) register char **t; { register char *f; register int u; bool hflg = 0; char buf[BUFSIZ]; t++; if (*t && eq(*t, "-h")) { t++; hflg++; } (void) strcpy(buf, *t); f = globone(buf); u = dmove(open(f, 0), -1); xfree(f); if (u < 0 && !hflg) Perror(f); (void) ioctl(u, FIOCLEX, (char *)0); srcunit(u, 0, hflg); } /* * Check for mail. * If we are a login shell, then we don't want to tell * about any mail file unless its been modified * after the time we started. * This prevents us from telling the user things he already * knows, since the login program insists on saying * "You have mail." */ mailchk() { register struct varent *v; register char **vp; time_t t; int intvl, cnt; struct stat stb; bool new; v = adrof("mail"); if (v == 0) return; (void) time(&t); vp = v->vec; cnt = blklen(vp); intvl = (cnt && number(*vp)) ? (--cnt, getn(*vp++)) : MAILINTVL; if (intvl < 1) intvl = 1; if (chktim + intvl > t) return; for (; *vp; vp++) { if (stat(*vp, &stb) < 0) continue; new = stb.st_mtime > time0.tv_sec; if (stb.st_size == 0 || stb.st_atime > stb.st_mtime || (stb.st_atime < chktim && stb.st_mtime < chktim) || loginsh && !new) continue; if (cnt == 1) printf("You have %smail.\n", new ? "new " : ""); else printf("%s in %s.\n", new ? "New mail" : "Mail", *vp); } chktim = t; } #include /* * Extract a home directory from the password file * The argument points to a buffer where the name of the * user whose home directory is sought is currently. * We write the home directory of the user back there. */ gethdir(home) char *home; { register struct passwd *pp = getpwnam(home); if (pp == 0) return (1); (void) strcpy(home, pp->pw_dir); return (0); } /* * Move the initial descriptors to their eventual * resting places, closin all other units. */ initdesc() { didfds = 0; /* 0, 1, 2 aren't set up */ (void) ioctl(SHIN = dcopy(0, FSHIN), FIOCLEX, (char *)0); (void) ioctl(SHOUT = dcopy(1, FSHOUT), FIOCLEX, (char *)0); (void) ioctl(SHDIAG = dcopy(2, FSHDIAG), FIOCLEX, (char *)0); (void) ioctl(OLDSTD = dcopy(SHIN, FOLDSTD), FIOCLEX, (char *)0); closem(); } #ifdef PROF void done(i) #else void exit(i) #endif int i; { untty(); _exit(i); } printprompt() { register char *cp; if (!whyles) { for (cp = value("prompt"); *cp; cp++) if (*cp == HIST) printf("%d", eventno + 1); else { if (*cp == '\\' && cp[1] == HIST) cp++; putchar(*cp | QUOTE); } } else /* * Prompt for forward reading loop * body content. */ printf("? "); flush(); } ================================================ FILE: bin/csh/sh.char.c ================================================ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley Software License Agreement * specifies the terms and conditions for redistribution. */ #if !defined(lint) && defined(DOSCCS) static char *sccsid = "@(#)sh.char.c 5.3 (Berkeley) 3/29/86"; #endif #include "sh.char.h" unsigned short _cmap[256] = { /* nul soh stx etx */ 0, 0, 0, 0, /* eot enq ack bel */ 0, 0, 0, 0, /* bs ht nl vt */ 0, _SP|_META, _NL|_META, 0, /* np cr so si */ 0, 0, 0, 0, /* dle dc1 dc2 dc3 */ 0, 0, 0, 0, /* dc4 nak syn etb */ 0, 0, 0, 0, /* can em sub esc */ 0, 0, 0, 0, /* fs gs rs us */ 0, 0, 0, 0, /* sp ! " # */ _SP|_META, 0, _Q, _META, /* $ % & ' */ _DOL, 0, _META, _Q, /* ( ) * + */ _META, _META, _GLOB, 0, /* , - . / */ 0, 0, 0, 0, /* 0 1 2 3 */ _DIG, _DIG, _DIG, _DIG, /* 4 5 6 7 */ _DIG, _DIG, _DIG, _DIG, /* 8 9 : ; */ _DIG, _DIG, 0, _META, /* < = > ? */ _META, 0, _META, _GLOB, /* @ A B C */ 0, _LET, _LET, _LET, /* D E F G */ _LET, _LET, _LET, _LET, /* H I J K */ _LET, _LET, _LET, _LET, /* L M N O */ _LET, _LET, _LET, _LET, /* P Q R S */ _LET, _LET, _LET, _LET, /* T U V W */ _LET, _LET, _LET, _LET, /* X Y Z [ */ _LET, _LET, _LET, _GLOB, /* \ ] ^ _ */ _ESC, 0, 0, _LET, /* ` a b c */ _Q1|_GLOB, _LET, _LET, _LET, /* d e f g */ _LET, _LET, _LET, _LET, /* h i j k */ _LET, _LET, _LET, _LET, /* l m n o */ _LET, _LET, _LET, _LET, /* p q r s */ _LET, _LET, _LET, _LET, /* t u v w */ _LET, _LET, _LET, _LET, /* x y z { */ _LET, _LET, _LET, _GLOB, /* | } ~ del */ _META, 0, 0, 0, }; ================================================ FILE: bin/csh/sh.char.h ================================================ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley Software License Agreement * specifies the terms and conditions for redistribution. * * @(#)sh.char.h 5.3 (Berkeley) 3/29/86 */ /* * Table for spotting special characters quickly * * Makes for very obscure but efficient coding. */ extern unsigned short _cmap[]; #define _Q 0x01 /* '" */ #define _Q1 0x02 /* ` */ #define _SP 0x04 /* space and tab */ #define _NL 0x08 /* \n */ #define _META 0x10 /* lex meta characters, sp #'`";&<>()|\t\n */ #define _GLOB 0x20 /* glob characters, *?{[` */ #define _ESC 0x40 /* \ */ #define _DOL 0x80 /* $ */ #define _DIG 0x100 /* 0-9 */ #define _LET 0x200 /* a-z, A-Z, _ */ #define cmap(c, bits) (_cmap[(unsigned char)(c)] & (bits)) #define isglob(c) cmap(c, _GLOB) #define isspace(c) cmap(c, _SP) #define isspnl(c) cmap(c, _SP|_NL) #define ismeta(c) cmap(c, _META) #define digit(c) cmap(c, _DIG) #define letter(c) cmap(c, _LET) #define alnum(c) (digit(c) || letter(c)) ================================================ FILE: bin/csh/sh.dir.c ================================================ /* * C Shell - directory management * * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley Software License Agreement * specifies the terms and conditions for redistribution. */ #include "sh.h" #include "sh.dir.h" struct directory *dfind(); char *dfollow(); char *dcanon(); struct directory dhead; /* "head" of loop */ int printd; /* force name to be printed */ static char *fakev[] = { "dirs", NOSTR }; /* * dinit - initialize current working directory */ dinit(hp) char *hp; { register char *cp; register struct directory *dp; char path[MAXPATHLEN]; if (loginsh && hp) cp = hp; else { cp = getwd(path); if (cp == NULL) { if (write(2, path, strlen(path)) < 0) ; exit(1); } } dp = (struct directory *)calloc(sizeof (struct directory), 1); dp->di_name = savestr(cp); dp->di_count = 0; dhead.di_next = dhead.di_prev = dp; dp->di_next = dp->di_prev = &dhead; printd = 0; dnewcwd(dp); } /* * dodirs - list all directories in directory loop */ dodirs(v) char **v; { register struct directory *dp; bool lflag; char *hp = value("home"); if (*hp == '\0') hp = NOSTR; if (*++v != NOSTR) if (eq(*v, "-l") && *++v == NOSTR) lflag = 1; else error("Usage: dirs [ -l ]"); else lflag = 0; dp = dcwd; do { if (dp == &dhead) continue; if (!lflag && hp != NOSTR) { dtildepr(hp, dp->di_name); } else printf("%s", dp->di_name); printf(" "); } while ((dp = dp->di_prev) != dcwd); printf("\n"); } dtildepr(home, dir) register char *home, *dir; { if (!eq(home, "/") && prefix(home, dir)) printf("~%s", dir + strlen(home)); else printf("%s", dir); } /* * dochngd - implement chdir command. */ dochngd(v) char **v; { register char *cp; register struct directory *dp; printd = 0; if (*++v == NOSTR) { if ((cp = value("home")) == NOSTR || *cp == 0) bferr("No home directory"); if (chdir(cp) < 0) bferr("Can't change to home directory"); cp = savestr(cp); } else if ((dp = dfind(*v)) != 0) { printd = 1; if (chdir(dp->di_name) < 0) Perror(dp->di_name); dcwd->di_prev->di_next = dcwd->di_next; dcwd->di_next->di_prev = dcwd->di_prev; goto flushcwd; } else cp = dfollow(*v); dp = (struct directory *)calloc(sizeof (struct directory), 1); dp->di_name = cp; dp->di_count = 0; dp->di_next = dcwd->di_next; dp->di_prev = dcwd->di_prev; dp->di_prev->di_next = dp; dp->di_next->di_prev = dp; flushcwd: dfree(dcwd); dnewcwd(dp); } /* * dfollow - change to arg directory; fall back on cdpath if not valid */ char * dfollow(cp) register char *cp; { register char *dp; struct varent *c; cp = globone(cp); if (chdir(cp) >= 0) goto gotcha; if (cp[0] != '/' && !prefix("./", cp) && !prefix("../", cp) && (c = adrof("cdpath"))) { char **cdp; register char *p; char buf[MAXPATHLEN]; for (cdp = c->vec; *cdp; cdp++) { for (dp = buf, p = *cdp; *dp++ = *p++;) ; dp[-1] = '/'; for (p = cp; *dp++ = *p++;) ; if (chdir(buf) >= 0) { printd = 1; xfree(cp); cp = savestr(buf); goto gotcha; } } } dp = value(cp); if ((dp[0] == '/' || dp[0] == '.') && chdir(dp) >= 0) { xfree(cp); cp = savestr(dp); printd = 1; goto gotcha; } xfree(cp); /* XXX, use after free */ Perror(cp); gotcha: if (*cp != '/') { register char *p, *q; int cwdlen; /* * All in the name of efficiency? */ for (p = dcwd->di_name; *p++;) ; if ((cwdlen = p - dcwd->di_name - 1) == 1) /* root */ cwdlen = 0; for (p = cp; *p++;) ; dp = xalloc((unsigned) (cwdlen + (p - cp) + 1)); for (p = dp, q = dcwd->di_name; *p++ = *q++;) ; if (cwdlen) p[-1] = '/'; else p--; /* don't add a / after root */ for (q = cp; *p++ = *q++;) ; xfree(cp); cp = dp; dp += cwdlen; } else dp = cp; return dcanon(cp, dp); } /* * dopushd - push new directory onto directory stack. * with no arguments exchange top and second. * with numeric argument (+n) bring it to top. */ dopushd(v) char **v; { register struct directory *dp; printd = 1; if (*++v == NOSTR) { if ((dp = dcwd->di_prev) == &dhead) dp = dhead.di_prev; if (dp == dcwd) bferr("No other directory"); if (chdir(dp->di_name) < 0) Perror(dp->di_name); dp->di_prev->di_next = dp->di_next; dp->di_next->di_prev = dp->di_prev; dp->di_next = dcwd->di_next; dp->di_prev = dcwd; dcwd->di_next->di_prev = dp; dcwd->di_next = dp; } else if (dp = dfind(*v)) { if (chdir(dp->di_name) < 0) Perror(dp->di_name); } else { register char *cp; cp = dfollow(*v); dp = (struct directory *)calloc(sizeof (struct directory), 1); dp->di_name = cp; dp->di_count = 0; dp->di_prev = dcwd; dp->di_next = dcwd->di_next; dcwd->di_next = dp; dp->di_next->di_prev = dp; } dnewcwd(dp); } /* * dfind - find a directory if specified by numeric (+n) argument */ struct directory * dfind(cp) register char *cp; { register struct directory *dp; register int i; register char *ep; if (*cp++ != '+') return (0); for (ep = cp; digit(*ep); ep++) continue; if (*ep) return (0); i = getn(cp); if (i <= 0) return (0); for (dp = dcwd; i != 0; i--) { if ((dp = dp->di_prev) == &dhead) dp = dp->di_prev; if (dp == dcwd) bferr("Directory stack not that deep"); } return (dp); } /* * dopopd - pop a directory out of the directory stack * with a numeric argument just discard it. */ dopopd(v) char **v; { register struct directory *dp, *p; printd = 1; if (*++v == NOSTR) dp = dcwd; else if ((dp = dfind(*v)) == 0) bferr("Bad directory"); if (dp->di_prev == &dhead && dp->di_next == &dhead) bferr("Directory stack empty"); if (dp == dcwd) { if ((p = dp->di_prev) == &dhead) p = dhead.di_prev; if (chdir(p->di_name) < 0) Perror(p->di_name); } dp->di_prev->di_next = dp->di_next; dp->di_next->di_prev = dp->di_prev; if (dp == dcwd) dnewcwd(p); else dodirs(fakev); dfree(dp); } /* * dfree - free the directory (or keep it if it still has ref count) */ dfree(dp) register struct directory *dp; { if (dp->di_count != 0) dp->di_next = dp->di_prev = 0; else xfree(dp->di_name), xfree((char *)dp); } /* * dcanon - canonicalize the pathname, removing excess ./ and ../ etc. * we are of course assuming that the file system is standardly * constructed (always have ..'s, directories have links) */ char * dcanon(cp, p) register char *cp, *p; { register char *sp; register char *p1, *p2; /* general purpose */ bool slash; if (*cp != '/') abort(); while (*p) { /* for each component */ sp = p; /* save slash address */ while (*++p == '/') /* flush extra slashes */ ; if (p != ++sp) for (p1 = sp, p2 = p; *p1++ = *p2++;) ; p = sp; /* save start of component */ slash = 0; while (*++p) /* find next slash or end of path */ if (*p == '/') { slash = 1; *p = 0; break; } if (*sp == '\0') /* if component is null */ if (--sp == cp) /* if path is one char (i.e. /) */ break; else *sp = '\0'; else if (sp[0] == '.' && sp[1] == 0) { if (slash) { for (p1 = sp, p2 = p + 1; *p1++ = *p2++;) ; p = --sp; } else if (--sp != cp) *sp = '\0'; } else if (sp[0] == '.' && sp[1] == '.' && sp[2] == 0) { char link[MAXPATHLEN]; int cc; char *newcp; /* * We have something like "yyy/xxx/..", where "yyy" * can be null or a path starting at /, and "xxx" * is a single component. * Before compressing "xxx/..", we want to expand * "yyy/xxx", if it is a symbolic link. */ *--sp = 0; /* form the pathname for readlink */ if (sp != cp && (cc = readlink(cp, link, sizeof link)) >= 0) { link[cc] = '\0'; if (slash) *p = '/'; /* * Point p to the '/' in "/..", and restore * the '/'. */ *(p = sp) = '/'; /* * find length of p */ for (p1 = p; *p1++;) ; if (*link != '/') { /* * Relative path, expand it between * the "yyy/" and the "/..". * First, back sp up to the character * past "yyy/". */ while (*--sp != '/') ; sp++; *sp = 0; /* * New length is * "yyy/" + link + "/.." and rest */ p1 = newcp = xalloc((unsigned) ((sp - cp) + cc + (p1 - p))); /* * Copy new path into newcp */ for (p2 = cp; *p1++ = *p2++;) ; for (p1--, p2 = link; *p1++ = *p2++;) ; for (p1--, p2 = p; *p1++ = *p2++;) ; /* * Restart canonicalization at * expanded "/xxx". */ p = sp - cp - 1 + newcp; } else { /* * New length is link + "/.." and rest */ p1 = newcp = xalloc((unsigned) (cc + (p1 - p))); /* * Copy new path into newcp */ for (p2 = link; *p1++ = *p2++;) ; for (p1--, p2 = p; *p1++ = *p2++;) ; /* * Restart canonicalization at beginning */ p = newcp; } xfree(cp); cp = newcp; continue; /* canonicalize the link */ } *sp = '/'; if (sp != cp) while (*--sp != '/') ; if (slash) { for (p1 = sp + 1, p2 = p + 1; *p1++ = *p2++;) ; p = sp; } else if (cp == sp) *++sp = '\0'; else *sp = '\0'; } else if (slash) *p = '/'; } return cp; } /* * dnewcwd - make a new directory in the loop the current one */ dnewcwd(dp) register struct directory *dp; { dcwd = dp; set("cwd", savestr(dcwd->di_name)); if (printd) dodirs(fakev); } ================================================ FILE: bin/csh/sh.dir.h ================================================ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley Software License Agreement * specifies the terms and conditions for redistribution. * * @(#)sh.dir.h 5.2 (Berkeley) 6/6/85 */ /* * Structure for entries in directory stack. */ struct directory { struct directory *di_next; /* next in loop */ struct directory *di_prev; /* prev in loop */ unsigned short *di_count; /* refcount of processes */ char *di_name; /* actual name */ }; struct directory *dcwd; /* the one we are in now */ ================================================ FILE: bin/csh/sh.dol.c ================================================ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley Software License Agreement * specifies the terms and conditions for redistribution. */ #if !defined(lint) && defined(DOSCCS) static char *sccsid = "@(#)sh.dol.c 5.3 (Berkeley) 3/29/86"; #endif #include "sh.h" /* * C shell */ /* * These routines perform variable substitution and quoting via ' and ". * To this point these constructs have been preserved in the divided * input words. Here we expand variables and turn quoting via ' and " into * QUOTE bits on characters (which prevent further interpretation). * If the `:q' modifier was applied during history expansion, then * some QUOTEing may have occurred already, so we dont "trim()" here. */ int Dpeekc, Dpeekrd; /* Peeks for DgetC and Dreadc */ char *Dcp, **Dvp; /* Input vector for Dreadc */ #define DEOF -1 #define unDgetC(c) Dpeekc = c #define QUOTES (_Q|_Q1|_ESC) /* \ ' " ` */ /* * The following variables give the information about the current * $ expansion, recording the current word position, the remaining * words within this expansion, the count of remaining words, and the * information about any : modifier which is being applied. */ char *dolp; /* Remaining chars from this word */ char **dolnxt; /* Further words */ int dolcnt; /* Count of further words */ char dolmod; /* : modifier character */ int dolmcnt; /* :gx -> 10000, else 1 */ /* * Fix up the $ expansions and quotations in the * argument list to command t. */ Dfix(t) register struct command *t; { register char **pp; register char *p; if (noexec) return; /* Note that t_dcom isn't trimmed thus !...:q's aren't lost */ for (pp = t->t_dcom; p = *pp++;) while (*p) if (cmap(*p++, _DOL|QUOTES)) { /* $, \, ', ", ` */ Dfix2(t->t_dcom); /* found one */ blkfree(t->t_dcom); t->t_dcom = gargv; gargv = 0; return; } } /* * $ substitute one word, for i/o redirection */ char * Dfix1(cp) register char *cp; { char *Dv[2]; if (noexec) return (0); Dv[0] = cp; Dv[1] = NOSTR; Dfix2(Dv); if (gargc != 1) { setname(cp); bferr("Ambiguous"); } cp = savestr(gargv[0]); blkfree(gargv), gargv = 0; return (cp); } /* * Subroutine to do actual fixing after state initialization. */ Dfix2(v) char **v; { char *agargv[GAVSIZ]; ginit(agargv); /* Initialize glob's area pointers */ Dvp = v; Dcp = ""; /* Setup input vector for Dreadc */ unDgetC(0); unDredc(0); /* Clear out any old peeks (at error) */ dolp = 0; dolcnt = 0; /* Clear out residual $ expands (...) */ while (Dword()) continue; gargv = copyblk(gargv); } /* * Get a word. This routine is analogous to the routine * word() in sh.lex.c for the main lexical input. One difference * here is that we don't get a newline to terminate our expansion. * Rather, DgetC will return a DEOF when we hit the end-of-input. */ Dword() { register int c, c1; char wbuf[BUFSIZ]; register char *wp = wbuf; register int i = BUFSIZ - 4; register bool dolflg; bool sofar = 0; loop: c = DgetC(DODOL); switch (c) { case DEOF: deof: if (sofar == 0) return (0); /* finish this word and catch the code above the next time */ unDredc(c); /* fall into ... */ case '\n': *wp = 0; goto ret; case ' ': case '\t': goto loop; case '`': /* We preserve ` quotations which are done yet later */ *wp++ = c, --i; case '\'': case '"': /* * Note that DgetC never returns a QUOTES character * from an expansion, so only true input quotes will * get us here or out. */ c1 = c; dolflg = c1 == '"' ? DODOL : 0; for (;;) { c = DgetC(dolflg); if (c == c1) break; if (c == '\n' || c == DEOF) error("Unmatched %c", c1); if ((c & (QUOTE|TRIM)) == ('\n' | QUOTE)) --wp, ++i; if (--i <= 0) goto toochars; switch (c1) { case '"': /* * Leave any `s alone for later. * Other chars are all quoted, thus `...` * can tell it was within "...". */ *wp++ = c == '`' ? '`' : c | QUOTE; break; case '\'': /* Prevent all further interpretation */ *wp++ = c | QUOTE; break; case '`': /* Leave all text alone for later */ *wp++ = c; break; } } if (c1 == '`') *wp++ = '`', --i; goto pack; /* continue the word */ case '\\': c = DgetC(0); /* No $ subst! */ if (c == '\n' || c == DEOF) goto loop; c |= QUOTE; break; } unDgetC(c); pack: sofar = 1; /* pack up more characters in this word */ for (;;) { c = DgetC(DODOL); if (c == '\\') { c = DgetC(0); if (c == DEOF) goto deof; if (c == '\n') c = ' '; else c |= QUOTE; } if (c == DEOF) goto deof; if (cmap(c, _SP|_NL|_Q|_Q1)) { /* sp \t\n'"` */ unDgetC(c); if (cmap(c, QUOTES)) goto loop; *wp++ = 0; goto ret; } if (--i <= 0) toochars: error("Word too long"); *wp++ = c; } ret: Gcat("", wbuf); return (1); } /* * Get a character, performing $ substitution unless flag is 0. * Any QUOTES character which is returned from a $ expansion is * QUOTEd so that it will not be recognized above. */ DgetC(flag) register int flag; { register int c; top: if (c = Dpeekc) { Dpeekc = 0; return (c); } if (lap) { c = *lap++ & (QUOTE|TRIM); if (c == 0) { lap = 0; goto top; } quotspec: if (cmap(c, QUOTES)) return (c | QUOTE); return (c); } if (dolp) { if (c = *dolp++ & (QUOTE|TRIM)) goto quotspec; if (dolcnt > 0) { setDolp(*dolnxt++); --dolcnt; return (' '); } dolp = 0; } if (dolcnt > 0) { setDolp(*dolnxt++); --dolcnt; goto top; } c = Dredc(); if (c == '$' && flag) { Dgetdol(); goto top; } return (c); } char *nulvec[] = { 0 }; struct varent nulargv = { nulvec, "argv", 0 }; /* * Handle the multitudinous $ expansion forms. * Ugh. */ Dgetdol() { register char *np; register struct varent *vp; char name[20]; int c, sc; int subscr = 0, lwb = 1, upb = 0; bool dimen = 0, bitset = 0; char wbuf[BUFSIZ]; dolmod = dolmcnt = 0; c = sc = DgetC(0); if (c == '{') c = DgetC(0); /* sc is { to take } later */ if ((c & TRIM) == '#') dimen++, c = DgetC(0); /* $# takes dimension */ else if (c == '?') bitset++, c = DgetC(0); /* $? tests existence */ switch (c) { case '$': if (dimen || bitset) goto syntax; /* No $?$, $#$ */ setDolp(doldol); goto eatbrac; case '<'|QUOTE: if (dimen || bitset) goto syntax; /* No $?<, $#< */ for (np = wbuf; read(OLDSTD, np, 1) == 1; np++) { if (np >= &wbuf[BUFSIZ-1]) error("$< line too long"); if (*np <= 0 || *np == '\n') break; } *np = 0; /* * KLUDGE: dolmod is set here because it will * cause setDolp to call domod and thus to copy wbuf. * Otherwise setDolp would use it directly. If we saved * it ourselves, no one would know when to free it. * The actual function of the 'q' causes filename * expansion not to be done on the interpolated value. */ dolmod = 'q'; dolmcnt = 10000; setDolp(wbuf); goto eatbrac; case DEOF: case '\n': goto syntax; case '*': (void) strcpy(name, "argv"); vp = adrof("argv"); subscr = -1; /* Prevent eating [...] */ break; default: np = name; if (digit(c)) { if (dimen) goto syntax; /* No $#1, e.g. */ subscr = 0; do { subscr = subscr * 10 + c - '0'; c = DgetC(0); } while (digit(c)); unDredc(c); if (subscr < 0) goto oob; if (subscr == 0) { if (bitset) { dolp = file ? "1" : "0"; goto eatbrac; } if (file == 0) error("No file for $0"); setDolp(file); goto eatbrac; } if (bitset) goto syntax; vp = adrof("argv"); if (vp == 0) { vp = &nulargv; goto eatmod; } break; } if (!alnum(c)) goto syntax; for (;;) { *np++ = c; c = DgetC(0); if (!alnum(c)) break; if (np >= &name[sizeof name - 2]) syntax: error("Variable syntax"); } *np++ = 0; unDredc(c); vp = adrof(name); } if (bitset) { dolp = (vp || getenv(name)) ? "1" : "0"; goto eatbrac; } if (vp == 0) { np = getenv(name); if (np) { addla(np); goto eatbrac; } udvar(name); /*NOTREACHED*/ } c = DgetC(0); upb = blklen(vp->vec); if (dimen == 0 && subscr == 0 && c == '[') { np = name; for (;;) { c = DgetC(DODOL); /* Allow $ expand within [ ] */ if (c == ']') break; if (c == '\n' || c == DEOF) goto syntax; if (np >= &name[sizeof name - 2]) goto syntax; *np++ = c; } *np = 0, np = name; if (dolp || dolcnt) /* $ exp must end before ] */ goto syntax; if (!*np) goto syntax; if (digit(*np)) { register int i = 0; while (digit(*np)) i = i * 10 + *np++ - '0'; if ((i < 0 || i > upb) && !any(*np, "-*")) { oob: setname(vp->v_name); error("Subscript out of range"); } lwb = i; if (!*np) upb = lwb, np = "*"; } if (*np == '*') np++; else if (*np != '-') goto syntax; else { register int i = upb; np++; if (digit(*np)) { i = 0; while (digit(*np)) i = i * 10 + *np++ - '0'; if (i < 0 || i > upb) goto oob; } if (i < lwb) upb = lwb - 1; else upb = i; } if (lwb == 0) { if (upb != 0) goto oob; upb = -1; } if (*np) goto syntax; } else { if (subscr > 0) if (subscr > upb) lwb = 1, upb = 0; else lwb = upb = subscr; unDredc(c); } if (dimen) { char *cp = putn(upb - lwb + 1); addla(cp); xfree(cp); } else { eatmod: c = DgetC(0); if (c == ':') { c = DgetC(0), dolmcnt = 1; if (c == 'g') c = DgetC(0), dolmcnt = 10000; if (!any(c, "htrqxe")) error("Bad : mod in $"); dolmod = c; if (c == 'q') dolmcnt = 10000; } else unDredc(c); dolnxt = &vp->vec[lwb - 1]; dolcnt = upb - lwb + 1; } eatbrac: if (sc == '{') { c = Dredc(); if (c != '}') goto syntax; } } setDolp(cp) register char *cp; { register char *dp; if (dolmod == 0 || dolmcnt == 0) { dolp = cp; return; } dp = domod(cp, dolmod); if (dp) { dolmcnt--; addla(dp); xfree(dp); } else addla(cp); dolp = ""; } unDredc(c) int c; { Dpeekrd = c; } Dredc() { register int c; if (c = Dpeekrd) { Dpeekrd = 0; return (c); } if (Dcp && (c = *Dcp++)) return (c&(QUOTE|TRIM)); if (*Dvp == 0) { Dcp = 0; return (DEOF); } Dcp = *Dvp++; return (' '); } Dtestq(c) register int c; { if (cmap(c, QUOTES)) gflag = 1; } /* * Form a shell temporary file (in unit 0) from the words * of the shell input up to a line the same as "term". * Unit 0 should have been closed before this call. */ heredoc(term) char *term; { register int c; char *Dv[2]; char obuf[BUFSIZ], lbuf[BUFSIZ], mbuf[BUFSIZ]; int ocnt, lcnt, mcnt; register char *lbp, *obp, *mbp; char **vp; bool quoted; if (creat(shtemp, 0600) < 0) Perror(shtemp); (void) close(0); if (open(shtemp, 2) < 0) { int oerrno = errno; (void) unlink(shtemp); errno = oerrno; Perror(shtemp); } (void) unlink(shtemp); /* 0 0 inode! */ Dv[0] = term; Dv[1] = NOSTR; gflag = 0; trim(Dv); rscan(Dv, Dtestq); quoted = gflag; ocnt = BUFSIZ; obp = obuf; for (;;) { /* * Read up a line */ lbp = lbuf; lcnt = BUFSIZ - 4; for (;;) { c = readc(1); /* 1 -> Want EOF returns */ if (c < 0) { setname(term); bferr("<< terminator not found"); } if (c == '\n') break; if (c &= TRIM) { *lbp++ = c; if (--lcnt < 0) { setname("<<"); error("Line overflow"); } } } *lbp = 0; /* * Compare to terminator -- before expansion */ if (eq(lbuf, term)) { if (write(0, obuf, BUFSIZ - ocnt) < 0) ; (void) lseek(0, (off_t)0, 0); return; } /* * If term was quoted or -n just pass it on */ if (quoted || noexec) { *lbp++ = '\n'; *lbp = 0; for (lbp = lbuf; c = *lbp++;) { *obp++ = c; if (--ocnt == 0) { if (write(0, obuf, BUFSIZ) < 0) ; obp = obuf; ocnt = BUFSIZ; } } continue; } /* * Term wasn't quoted so variable and then command * expand the input line */ Dcp = lbuf; Dvp = Dv + 1; mbp = mbuf; mcnt = BUFSIZ - 4; for (;;) { c = DgetC(DODOL); if (c == DEOF) break; if ((c &= TRIM) == 0) continue; /* \ quotes \ $ ` here */ if (c =='\\') { c = DgetC(0); if (!any(c, "$\\`")) unDgetC(c | QUOTE), c = '\\'; else c |= QUOTE; } *mbp++ = c; if (--mcnt == 0) { setname("<<"); bferr("Line overflow"); } } *mbp++ = 0; /* * If any ` in line do command substitution */ mbp = mbuf; if (any('`', mbp)) { /* * 1 arg to dobackp causes substitution to be literal. * Words are broken only at newlines so that all blanks * and tabs are preserved. Blank lines (null words) * are not discarded. */ vp = dobackp(mbuf, 1); } else /* Setup trivial vector similar to return of dobackp */ Dv[0] = mbp, Dv[1] = NOSTR, vp = Dv; /* * Resurrect the words from the command substitution * each separated by a newline. Note that the last * newline of a command substitution will have been * discarded, but we put a newline after the last word * because this represents the newline after the last * input line! */ for (; *vp; vp++) { for (mbp = *vp; *mbp; mbp++) { *obp++ = *mbp & TRIM; if (--ocnt == 0) { if (write(0, obuf, BUFSIZ) < 0) ; obp = obuf; ocnt = BUFSIZ; } } *obp++ = '\n'; if (--ocnt == 0) { if (write(0, obuf, BUFSIZ) < 0) ; obp = obuf; ocnt = BUFSIZ; } } if (pargv) blkfree(pargv), pargv = 0; } } ================================================ FILE: bin/csh/sh.err.c ================================================ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley Software License Agreement * specifies the terms and conditions for redistribution. */ #include "sh.h" #include /* * C Shell */ bool errspl; /* Argument to error was spliced by seterr2 */ char one[2] = { '1', 0 }; char *onev[2] = { one, NOSTR }; /* * Print error string s with optional argument arg. * This routine always resets or exits. The flag haderr * is set so the routine who catches the unwind can propogate * it if they want. * * Note that any open files at the point of error will eventually * be closed in the routine process in sh.c which is the only * place error unwinds are ever caught. */ /*VARARGS1*/ error(s, arg) char *s; { register char **v; register char *ep; /* * Must flush before we print as we wish output before the error * to go on (some form of) standard output, while output after * goes on (some form of) diagnostic output. * If didfds then output will go to 1/2 else to FSHOUT/FSHDIAG. * See flush in sh.print.c. */ flush(); haderr = 1; /* Now to diagnostic output */ timflg = 0; /* This isn't otherwise reset */ if (v = pargv) pargv = 0, blkfree(v); if (v = gargv) gargv = 0, blkfree(v); /* * A zero arguments causes no printing, else print * an error diagnostic here. */ if (s) printf(s, arg), printf(".\n"); didfds = 0; /* Forget about 0,1,2 */ if ((ep = parserr) && errspl) { errspl = 0; xfree(ep); } errspl = 0; /* * Go away if -e or we are a child shell */ if (exiterr || child) exit(1); /* * Reset the state of the input. * This buffered seek to end of file will also * clear the while/foreach stack. */ btoeof(); setq("status", onev, &shvhed); if (tpgrp > 0) (void) ioctl(FSHTTY, TIOCSPGRP, (char *)&tpgrp); reset(); /* Unwind */ } /* * Perror is the shells version of perror which should otherwise * never be called. */ Perror(s) char *s; { /* * Perror uses unit 2, thus if we didn't set up the fd's * we must set up unit 2 now else the diagnostic will disappear */ if (!didfds) { register int oerrno = errno; (void) dcopy(SHDIAG, 2); errno = oerrno; } perror(s); error(NOSTR); /* To exit or unwind */ } bferr(cp) char *cp; { flush(); haderr = 1; printf("%s: ", bname); error(cp); } /* * The parser and scanner set up errors for later by calling seterr, * which sets the variable parserr as a side effect; later to be tested, * e.g. in process. */ seterr(s) char *s; { if (parserr == 0) parserr = s, errspl = 0; } /* Set parserr to a splice of cp and dp, to be freed later in error() */ seterr2(cp, dp) char *cp, *dp; { if (parserr) return; parserr = strspl(cp, dp); errspl++; } /* Set parserr to a splice of cp with a string form of character d */ seterrc(cp, d) char *cp, d; { char chbuf[2]; chbuf[0] = d; chbuf[1] = 0; seterr2(cp, chbuf); } ================================================ FILE: bin/csh/sh.exec.c ================================================ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley Software License Agreement * specifies the terms and conditions for redistribution. */ #if !defined(lint) && defined(DOSCCS) static char *sccsid = "@(#)sh.exec.c 5.2.2 (2.11BSD) 1996/9/20"; #endif #include "sh.h" #include #include /* * C shell */ /* * System level search and execute of a command. * We look in each directory for the specified command name. * If the name contains a '/' then we execute only the full path name. * If there is no search path then we execute only full path names. */ /* * As we search for the command we note the first non-trivial error * message for presentation to the user. This allows us often * to show that a file has the wrong mode/no access when the file * is not in the last component of the search path, so we must * go on after first detecting the error. */ const char *exerr; /* Execution error message */ char *expath; /* Path for exerr */ #include "sh.exec.h" /* Dummy search path for just absolute search when no path */ char *justabs[] = { "", 0 }; doexec(t) register struct command *t; { char *sav; register char *dp, **pv, **av; register struct varent *v; bool slash = any('/', t->t_dcom[0]); int hashval, hashval1, i; char *blk[2]; /* * Glob the command name. If this does anything, then we * will execute the command only relative to ".". One special * case: if there is no PATH, then we execute only commands * which start with '/'. */ dp = globone(t->t_dcom[0]); sav = t->t_dcom[0]; exerr = 0; expath = t->t_dcom[0] = dp; xfree(sav); v = adrof("path"); if (v == 0 && expath[0] != '/') pexerr(); slash |= gflag; /* * Glob the argument list, if necessary. * Otherwise trim off the quote bits. */ gflag = 0; av = &t->t_dcom[1]; tglob(av); if (gflag) { av = glob(av); if (av == 0) error("No match"); } blk[0] = t->t_dcom[0]; blk[1] = 0; av = blkspl(blk, av); #ifdef VFORK Vav = av; #endif trim(av); xechoit(av); /* Echo command if -x */ /* * Since all internal file descriptors are set to close on exec, * we don't need to close them explicitly here. Just reorient * ourselves for error messages. */ SHIN = 0; SHOUT = 1; SHDIAG = 2; OLDSTD = 0; /* * We must do this AFTER any possible forking (like `foo` * in glob) so that this shell can still do subprocesses. */ (void) sigsetmask(0L); /* * If no path, no words in path, or a / in the filename * then restrict the command search. */ if (v == 0 || v->vec[0] == 0 || slash) pv = justabs; else pv = v->vec; sav = strspl("/", *av); /* / command name for postpending */ #ifdef VFORK Vsav = sav; #endif if (havhash) hashval = hashname(*av); i = 0; #ifdef VFORK hits++; #endif do { if (!slash && pv[0][0] == '/' && havhash) { hashval1 = hash(hashval, i); if (!bit(xhash, hashval1)) goto cont; } if (pv[0][0] == 0 || eq(pv[0], ".")) /* don't make ./xxx */ texec(*av, av); else { dp = strspl(*pv, sav); #ifdef VFORK Vdp = dp; #endif texec(dp, av); #ifdef VFORK Vdp = 0; #endif xfree(dp); } #ifdef VFORK misses++; #endif cont: pv++; i++; } while (*pv); #ifdef VFORK hits--; #endif #ifdef VFORK Vsav = 0; Vav = 0; #endif xfree(sav); xfree((char *)av); pexerr(); } pexerr() { /* Couldn't find the damn thing */ setname(expath); /* xfree(expath); */ if (exerr) bferr(exerr); bferr("Command not found"); } /* * Execute command f, arg list t. * Record error message if not found. * Also do shell scripts here. */ texec(f, t) char *f; register char **t; { register struct varent *v; register char **vp; char *lastsh[2]; execv(f, t); switch (errno) { case ENOEXEC: /* * If there is an alias for shell, then * put the words of the alias in front of the * argument list replacing the command name. * Note no interpretation of the words at this point. */ v = adrof1("shell", &aliases); if (v == 0) { #ifdef OTHERSH register int ff = open(f, 0); char ch; #endif vp = lastsh; vp[0] = adrof("shell") ? value("shell") : SHELLPATH; vp[1] = (char *) NULL; #ifdef OTHERSH if (ff != -1 && read(ff, &ch, 1) == 1 && ch != '#') vp[0] = OTHERSH; (void) close(ff); #endif } else vp = v->vec; t[0] = f; t = blkspl(vp, t); /* Splice up the new arglst */ f = *t; xfree((char *)t); execv(f, t); /* The sky is falling, the sky is falling! */ case ENOMEM: Perror(f); case ENOENT: break; default: if (exerr == 0) { exerr = strerror(errno); expath = savestr(f); } } } /*ARGSUSED*/ execash(t, kp) char **t; register struct command *kp; { rechist(); (void) signal(SIGINT, parintr); (void) signal(SIGQUIT, parintr); (void) signal(SIGTERM, parterm); /* if doexec loses, screw */ lshift(kp->t_dcom, 1); exiterr++; doexec(kp); /*NOTREACHED*/ } xechoit(t) char **t; { if (adrof("echo")) { flush(); haderr = 1; blkpr(t), putchar('\n'); haderr = 0; } } /*VARARGS0*//*ARGSUSED*/ int dohash() { struct stat stb; DIR *dirp; register struct direct *dp; register int cnt; int i = 0; struct varent *v = adrof("path"); char **pv; int hashval; havhash = 1; for (cnt = 0; cnt < sizeof xhash; cnt++) xhash[cnt] = 0; if (v == 0) return 0; for (pv = v->vec; *pv; pv++, i++) { if (pv[0][0] != '/') continue; printf ("dohash: %s\n", *pv); if (stat(*pv, &stb) < 0) { printf (" ---cannot stat dir %s: %s\n", *pv, strerror(errno)); continue; } if (! S_ISDIR(stb.st_mode)) { printf (" ---not a directory %s, mode = %#o\n", *pv, stb.st_mode); continue; } dirp = opendir(*pv); if (dirp == NULL) { printf (" ---cannot open dir %s\n", *pv); continue; } while ((dp = readdir(dirp)) != NULL) { if (dp->d_ino == 0) continue; if (dp->d_name[0] == '.' && (dp->d_name[1] == '\0' || dp->d_name[1] == '.' && dp->d_name[2] == '\0')) continue; hashval = hash(hashname(dp->d_name), i); bis(xhash, hashval); } closedir(dirp); printf (" ---done %s\n", *pv); } return 0; } dounhash() { havhash = 0; } #ifdef VFORK hashstat() { if (hits+misses) printf("%d hits, %d misses, %d%%\n", hits, misses, (int)(100L * hits / (hits + misses))); } #endif /* * Hash a command name. */ hashname(cp) register char *cp; { register long h = 0; while (*cp) h = hash(h, *cp++); return ((int) h); } ================================================ FILE: bin/csh/sh.exec.h ================================================ /* * Xhash is an array of HSHSIZ bits (HSHSIZ / 8 chars), which are used * to hash execs. If it is allocated (havhash true), then to tell * whether ``name'' is (possibly) present in the i'th component * of the variable path, you look at the bit in xhash indexed by * hash(hashname("name"), i). This is setup automatically * after .login is executed, and recomputed whenever ``path'' is * changed. * The two part hash function is designed to let texec() call the * more expensive hashname() only once and the simple hash() several * times (once for each path component checked). * Byte size is assumed to be 8. */ #define HSHSIZ 8192 /* 1k bytes */ #define HSHMASK (HSHSIZ - 1) #define HSHMUL 243 char xhash[HSHSIZ / 8]; #define hash(a, b) ((a) * HSHMUL + (b) & HSHMASK) #define bit(h, b) ((h)[(b) >> 3] & 1 << ((b) & 7)) /* bit test */ #define bis(h, b) ((h)[(b) >> 3] |= 1 << ((b) & 7)) /* bit set */ #ifdef VFORK int hits, misses; #endif ================================================ FILE: bin/csh/sh.exec2.c ================================================ /* * From the 4.4-Lite2 CD's csh sources and modified appropriately. */ #include "sh.h" #include #include #include #include #include "sh.exec.h" extern char *justabs[]; /* in sh.exec.c */ /* Also by: * Andreas Luik * I S A GmbH - Informationssysteme fuer computerintegrierte Automatisierung * Azenberstr. 35 * D-7000 Stuttgart 1 * West-Germany * is the executable() routine below and changes to iscommand(). * Thanks again!! */ /* * executable() examines the pathname obtained by concatenating dir and name * (dir may be NULL), and returns 1 either if it is executable by us, or * if dir_ok is set and the pathname refers to a directory. * This is a bit kludgy, but in the name of optimization... */ static int executable(dir, name, dir_ok) char *dir, *name; bool dir_ok; { struct stat stbuf; char path[MAXPATHLEN + 1]; register char *dp, *sp; char *strname; if (dir && *dir) { for (dp = path, sp = dir; *sp; *dp++ = *sp++) if (dp == &path[MAXPATHLEN + 1]) { *--dp = '\0'; break; } for (sp = name; *sp; *dp++ = *sp++) if (dp == &path[MAXPATHLEN + 1]) { *--dp = '\0'; break; } *dp = '\0'; strname = path; } else strname = name; return (stat(strname, &stbuf) != -1 && ((S_ISREG(stbuf.st_mode) && /* save time by not calling access() in the hopeless case */ (stbuf.st_mode & (S_IXOTH | S_IXGRP | S_IXUSR)) && access(strname, X_OK) == 0) || (dir_ok && S_ISDIR(stbuf.st_mode)))); } static int iscommand(name) char *name; { register char **pv; register char *sav; register struct varent *v; bool slash = any(name, '/'); int hashval = 0, hashval1, i; v = adrof("path"); if (v == 0 || v->vec[0] == 0 || slash) pv = justabs; else pv = v->vec; sav = strspl("/", name); /* / command name for postpending */ if (havhash) hashval = hashname(name); i = 0; do { if (!slash && pv[0][0] == '/' && havhash) { hashval1 = hash(hashval, i); if (!bit(xhash, hashval1)) goto cont; } if (pv[0][0] == 0 || eq(pv[0], ".")) { /* don't make ./xxx */ if (executable(NULL, name, 0)) { xfree(sav); return i + 1; } } else { if (executable(*pv, sav, 0)) { xfree(sav); return i + 1; } } cont: pv++; i++; } while (*pv); xfree(sav); return 0; } static void tellmewhat(lex) struct wordent *lex; { int i; struct biltins *bptr; register struct wordent *sp = lex->next; bool aliased = 0; register char *s2; char *s0, *s1, *cmd; char qc; if (adrof1(sp->word, &aliases)) { alias(lex); sp = lex->next; aliased = 1; } s0 = sp->word; /* to get the memory freeing right... */ /* handle quoted alias hack */ if ((*(sp->word) & (QUOTE | TRIM)) == QUOTE) (sp->word)++; /* do quoting, if it hasn't been done */ s1 = s2 = sp->word; while (*s2) switch (*s2) { case '\'': case '"': qc = *s2++; while (*s2 && *s2 != qc) *s1++ = *s2++ | QUOTE; if (*s2) s2++; break; case '\\': if (*++s2) *s1++ = *s2++ | QUOTE; break; default: *s1++ = *s2++; } *s1 = '\0'; for (bptr = bfunc; bptr < &bfunc[nbfunc]; bptr++) { if (eq(sp->word, bptr->bname)) { if (aliased) prlex(lex); (void) printf("%s: shell built-in command.\n", sp->word); sp->word = s0; /* we save and then restore this */ return; } } sp->word = cmd = globone(sp->word); if ((i = iscommand(strip(sp->word))) != 0) { register char **pv; register struct varent *v; bool slash = any(sp->word, '/'); v = adrof("path"); if (v == 0 || v->vec[0] == 0 || slash) pv = justabs; else pv = v->vec; while (--i) pv++; if (pv[0][0] == 0 || eq(pv[0], ".")) { if (!slash) { sp->word = strspl("./", sp->word); prlex(lex); xfree(sp->word); } else prlex(lex); sp->word = s0; /* we save and then restore this */ xfree(cmd); return; } s1 = strspl(*pv, "/"); sp->word = strspl(s1, sp->word); xfree(s1); prlex(lex); xfree(sp->word); } else { if (aliased) prlex(lex); (void) printf("%s: Command not found.\n", sp->word); } sp->word = s0; /* we save and then restore this */ xfree(cmd); } /* The dowhich() is by: * Andreas Luik * I S A GmbH - Informationssysteme fuer computerintegrierte Automatisierung * Azenberstr. 35 * D-7000 Stuttgart 1 * West-Germany * Thanks!! */ /*ARGSUSED*/ void dowhich(v, c) register char **v; struct command *c; { struct wordent lex[3]; struct varent *vp; lex[0].next = &lex[1]; lex[1].next = &lex[2]; lex[2].next = &lex[0]; lex[0].prev = &lex[2]; lex[1].prev = &lex[0]; lex[2].prev = &lex[1]; lex[0].word = ""; lex[2].word = "\n"; while (*++v) { if ((vp = adrof1(*v, &aliases)) != NULL) { (void) printf("%s: \t aliased to ", *v); blkpr(vp->vec); (void) putchar('\n'); } else { lex[1].word = *v; tellmewhat(lex); } } } ================================================ FILE: bin/csh/sh.exp.c ================================================ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley Software License Agreement * specifies the terms and conditions for redistribution. */ #include "sh.h" /* * C shell */ #define IGNORE 1 /* in ignore, it means to ignore value, just parse */ #define NOGLOB 2 /* in ignore, it means not to globone */ #define ADDOP 1 #define MULOP 2 #define EQOP 4 #define RELOP 8 #define RESTOP 16 #define ANYOP 31 #define EQEQ 1 #define GTR 2 #define LSS 4 #define NOTEQ 6 #define EQMATCH 7 #define NOTEQMATCH 8 expr(vp) register char ***vp; { return (exp0(vp, 0)); } exp0(vp, ignore) register char ***vp; bool ignore; { register int p1 = exp1(vp, ignore); #ifdef EDEBUG etraci("exp0 p1", p1, vp); #endif if (**vp && eq(**vp, "||")) { register int p2; (*vp)++; p2 = exp0(vp, (ignore&IGNORE) || p1); #ifdef EDEBUG etraci("exp0 p2", p2, vp); #endif return (p1 || p2); } return (p1); } exp1(vp, ignore) register char ***vp; { register int p1 = expr2(vp, ignore); #ifdef EDEBUG etraci("exp1 p1", p1, vp); #endif if (**vp && eq(**vp, "&&")) { register int p2; (*vp)++; p2 = exp1(vp, (ignore&IGNORE) || !p1); #ifdef EDEBUG etraci("exp1 p2", p2, vp); #endif return (p1 && p2); } return (p1); } expr2(vp, ignore) register char ***vp; bool ignore; { register int p1 = exp2a(vp, ignore); #ifdef EDEBUG etraci("exp3 p1", p1, vp); #endif if (**vp && eq(**vp, "|")) { register int p2; (*vp)++; p2 = expr2(vp, ignore); #ifdef EDEBUG etraci("exp3 p2", p2, vp); #endif return (p1 | p2); } return (p1); } exp2a(vp, ignore) register char ***vp; bool ignore; { register int p1 = exp2b(vp, ignore); #ifdef EDEBUG etraci("exp2a p1", p1, vp); #endif if (**vp && eq(**vp, "^")) { register int p2; (*vp)++; p2 = exp2a(vp, ignore); #ifdef EDEBUG etraci("exp2a p2", p2, vp); #endif return (p1 ^ p2); } return (p1); } exp2b(vp, ignore) register char ***vp; bool ignore; { register int p1 = exp2c(vp, ignore); #ifdef EDEBUG etraci("exp2b p1", p1, vp); #endif if (**vp && eq(**vp, "&")) { register int p2; (*vp)++; p2 = exp2b(vp, ignore); #ifdef EDEBUG etraci("exp2b p2", p2, vp); #endif return (p1 & p2); } return (p1); } exp2c(vp, ignore) register char ***vp; bool ignore; { register char *p1 = exp3(vp, ignore); register char *p2; register int i; #ifdef EDEBUG etracc("exp2c p1", p1, vp); #endif if (i = isa(**vp, EQOP)) { (*vp)++; if (i == EQMATCH || i == NOTEQMATCH) ignore |= NOGLOB; p2 = exp3(vp, ignore); #ifdef EDEBUG etracc("exp2c p2", p2, vp); #endif if (!(ignore&IGNORE)) switch (i) { case EQEQ: i = eq(p1, p2); break; case NOTEQ: i = !eq(p1, p2); break; case EQMATCH: i = Gmatch(p1, p2); break; case NOTEQMATCH: i = !Gmatch(p1, p2); break; } xfree(p1), xfree(p2); return (i); } i = egetn(p1); xfree(p1); return (i); } char * exp3(vp, ignore) register char ***vp; bool ignore; { register char *p1, *p2; register int i; p1 = exp3a(vp, ignore); #ifdef EDEBUG etracc("exp3 p1", p1, vp); #endif if (i = isa(**vp, RELOP)) { (*vp)++; if (**vp && eq(**vp, "=")) i |= 1, (*vp)++; p2 = exp3(vp, ignore); #ifdef EDEBUG etracc("exp3 p2", p2, vp); #endif if (!(ignore&IGNORE)) switch (i) { case GTR: i = egetn(p1) > egetn(p2); break; case GTR|1: i = egetn(p1) >= egetn(p2); break; case LSS: i = egetn(p1) < egetn(p2); break; case LSS|1: i = egetn(p1) <= egetn(p2); break; } xfree(p1), xfree(p2); return (putn(i)); } return (p1); } char * exp3a(vp, ignore) register char ***vp; bool ignore; { register char *p1, *p2, *op; register int i; p1 = exp4(vp, ignore); #ifdef EDEBUG etracc("exp3a p1", p1, vp); #endif op = **vp; if (op && any(op[0], "<>") && op[0] == op[1]) { (*vp)++; p2 = exp3a(vp, ignore); #ifdef EDEBUG etracc("exp3a p2", p2, vp); #endif if (op[0] == '<') i = egetn(p1) << egetn(p2); else i = egetn(p1) >> egetn(p2); xfree(p1), xfree(p2); return (putn(i)); } return (p1); } char * exp4(vp, ignore) register char ***vp; bool ignore; { register char *p1, *p2; register int i = 0; p1 = exp5(vp, ignore); #ifdef EDEBUG etracc("exp4 p1", p1, vp); #endif if (isa(**vp, ADDOP)) { register char *op = *(*vp)++; p2 = exp4(vp, ignore); #ifdef EDEBUG etracc("exp4 p2", p2, vp); #endif if (!(ignore&IGNORE)) switch (op[0]) { case '+': i = egetn(p1) + egetn(p2); break; case '-': i = egetn(p1) - egetn(p2); break; } xfree(p1), xfree(p2); return (putn(i)); } return (p1); } char * exp5(vp, ignore) register char ***vp; bool ignore; { register char *p1, *p2; register int i = 0; p1 = exp6(vp, ignore); #ifdef EDEBUG etracc("exp5 p1", p1, vp); #endif if (isa(**vp, MULOP)) { register char *op = *(*vp)++; p2 = exp5(vp, ignore); #ifdef EDEBUG etracc("exp5 p2", p2, vp); #endif if (!(ignore&IGNORE)) switch (op[0]) { case '*': i = egetn(p1) * egetn(p2); break; case '/': i = egetn(p2); if (i == 0) error("Divide by 0"); i = egetn(p1) / i; break; case '%': i = egetn(p2); if (i == 0) error("Mod by 0"); i = egetn(p1) % i; break; } xfree(p1), xfree(p2); return (putn(i)); } return (p1); } char * exp6(vp, ignore) register char ***vp; { int ccode, i; register char *cp, *dp, *ep; if (**vp == 0) bferr("Expression syntax"); if (eq(**vp, "!")) { (*vp)++; cp = exp6(vp, ignore); #ifdef EDEBUG etracc("exp6 ! cp", cp, vp); #endif i = egetn(cp); xfree(cp); return (putn(!i)); } if (eq(**vp, "~")) { (*vp)++; cp = exp6(vp, ignore); #ifdef EDEBUG etracc("exp6 ~ cp", cp, vp); #endif i = egetn(cp); xfree(cp); return (putn(~i)); } if (eq(**vp, "(")) { (*vp)++; ccode = exp0(vp, ignore); #ifdef EDEBUG etraci("exp6 () ccode", ccode, vp); #endif if (*vp == 0 || **vp == 0 || ***vp != ')') bferr("Expression syntax"); (*vp)++; return (putn(ccode)); } if (eq(**vp, "{")) { register char **v; struct command faket; char *fakecom[2]; faket.t_dtyp = TCOM; faket.t_dflg = 0; faket.t_dcar = faket.t_dcdr = faket.t_dspr = (struct command *)0; faket.t_dcom = fakecom; fakecom[0] = "{ ... }"; fakecom[1] = NOSTR; (*vp)++; v = *vp; for (;;) { if (!**vp) bferr("Missing }"); if (eq(*(*vp)++, "}")) break; } if (ignore&IGNORE) return (""); psavejob(); if (pfork(&faket, -1) == 0) { *--(*vp) = 0; evalav(v); exitstat(); } pwait(); prestjob(); #ifdef EDEBUG etraci("exp6 {} status", egetn(value("status")), vp); #endif return (putn(egetn(value("status")) == 0)); } if (isa(**vp, ANYOP)) return (""); cp = *(*vp)++; if (*cp == '-' && any(cp[1], "erwxfdzo")) { struct stat stb; if (isa(**vp, ANYOP)) bferr("Missing file name"); dp = *(*vp)++; if (ignore&IGNORE) return (""); ep = globone(dp); switch (cp[1]) { case 'r': i = !access(ep, 4); break; case 'w': i = !access(ep, 2); break; case 'x': i = !access(ep, 1); break; default: if (stat(ep, &stb)) { xfree(ep); return ("0"); } switch (cp[1]) { case 'f': i = (stb.st_mode & S_IFMT) == S_IFREG; break; case 'd': i = (stb.st_mode & S_IFMT) == S_IFDIR; break; case 'z': i = stb.st_size == 0; break; case 'e': i = 1; break; case 'o': i = stb.st_uid == uid; break; } } #ifdef EDEBUG etraci("exp6 -? i", i, vp); #endif xfree(ep); return (putn(i)); } #ifdef EDEBUG etracc("exp6 default", cp, vp); #endif return (ignore&NOGLOB ? savestr(cp) : globone(cp)); } evalav(v) register char **v; { struct wordent paraml; register struct wordent *hp = ¶ml; struct command *t; register struct wordent *wdp = hp; set("status", "0"); hp->prev = hp->next = hp; hp->word = ""; while (*v) { register struct wordent *new = (struct wordent *) calloc(1, sizeof *wdp); new->prev = wdp; new->next = hp; wdp->next = new; wdp = new; wdp->word = savestr(*v++); } hp->prev = wdp; alias(¶ml); t = syntax(paraml.next, ¶ml, 0); if (parserr) error(parserr); execute(t, -1); freelex(¶ml), freesyn(t); } isa(cp, what) register char *cp; register int what; { if (cp == 0) return ((what & RESTOP) != 0); if (cp[1] == 0) { if (what & ADDOP && (*cp == '+' || *cp == '-')) return (1); if (what & MULOP && (*cp == '*' || *cp == '/' || *cp == '%')) return (1); if (what & RESTOP && (*cp == '(' || *cp == ')' || *cp == '!' || *cp == '~' || *cp == '^' || *cp == '"')) return (1); } else if (cp[2] == 0) { if (what & RESTOP) { if (cp[0] == '|' && cp[1] == '&') return (1); if (cp[0] == '<' && cp[1] == '<') return (1); if (cp[0] == '>' && cp[1] == '>') return (1); } if (what & EQOP) { if (cp[0] == '=') { if (cp[1] == '=') return (EQEQ); if (cp[1] == '~') return (EQMATCH); } else if (cp[0] == '!') { if (cp[1] == '=') return (NOTEQ); if (cp[1] == '~') return (NOTEQMATCH); } } } if (what & RELOP) { if (*cp == '<') return (LSS); if (*cp == '>') return (GTR); } return (0); } egetn(cp) register char *cp; { if (*cp && *cp != '-' && !digit(*cp)) bferr("Expression syntax"); return (getn(cp)); } /* Phew! */ #ifdef EDEBUG etraci(str, i, vp) char *str; int i; char ***vp; { printf("%s=%d\t", str, i); blkpr(*vp); printf("\n"); } etracc(str, cp, vp) char *str, *cp; char ***vp; { printf("%s=%s\t", str, cp); blkpr(*vp); printf("\n"); } #endif ================================================ FILE: bin/csh/sh.file.c ================================================ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley Software License Agreement * specifies the terms and conditions for redistribution. */ #ifdef FILEC /* * Tenex style file name recognition, .. and more. * History: * Author: Ken Greer, Sept. 1975, CMU. * Finally got around to adding to the Cshell., Ken Greer, Dec. 1981. */ #include "sh.h" #include #include #include #define TRUE 1 #define FALSE 0 #define ON 1 #define OFF 0 #define ESC '\033' typedef enum {LIST, RECOGNIZE} COMMAND; int sortscmp(); /* defined in sh.glob.c */ /* * Put this here so the binary can be patched with adb to enable file * completion by default. Filec controls completion, nobeep controls * ringing the terminal bell on incomplete expansions. */ bool filec = 0; static setup_tty(on) int on; { struct sgttyb sgtty; static struct tchars tchars; /* INT, QUIT, XON, XOFF, EOF, BRK */ if (on) { (void) ioctl(SHIN, TIOCGETC, (char *)&tchars); tchars.t_brkc = ESC; (void) ioctl(SHIN, TIOCSETC, (char *)&tchars); /* * This must be done after every command: if * the tty gets into raw or cbreak mode the user * can't even type 'reset'. */ (void) ioctl(SHIN, TIOCGETP, (char *)&sgtty); if (sgtty.sg_flags & (RAW|CBREAK)) { sgtty.sg_flags &= ~(RAW|CBREAK); (void) ioctl(SHIN, TIOCSETP, (char *)&sgtty); } } else { tchars.t_brkc = -1; (void) ioctl(SHIN, TIOCSETC, (char *)&tchars); } } /* * Move back to beginning of current line */ static back_to_col_1() { struct sgttyb tty, tty_normal; long omask; omask = sigblock(sigmask(SIGINT)); (void) ioctl(SHIN, TIOCGETP, (char *)&tty); tty_normal = tty; tty.sg_flags &= ~CRMOD; (void) ioctl(SHIN, TIOCSETN, (char *)&tty); (void) write(SHOUT, "\r", 1); (void) ioctl(SHIN, TIOCSETN, (char *)&tty_normal); (void) sigsetmask(omask); } /* * Push string contents back into tty queue */ static pushback(string) char *string; { register char *p; struct sgttyb tty, tty_normal; long omask; omask = sigblock(sigmask(SIGINT)); (void) ioctl(SHOUT, TIOCGETP, (char *)&tty); tty_normal = tty; tty.sg_flags &= ~ECHO; (void) ioctl(SHOUT, TIOCSETN, (char *)&tty); for (p = string; *p; p++) (void) ioctl(SHOUT, TIOCSTI, p); (void) ioctl(SHOUT, TIOCSETN, (char *)&tty_normal); (void) sigsetmask(omask); } /* * Concatenate src onto tail of des. * Des is a string whose maximum length is count. * Always null terminate. */ static catn(des, src, count) register char *des, *src; register count; { while (--count >= 0 && *des) des++; while (--count >= 0) if ((*des++ = *src++) == 0) return; *des = '\0'; } /* * Like strncpy but always leave room for trailing \0 * and always null terminate. */ static copyn(des, src, count) register char *des, *src; register count; { while (--count >= 0) if ((*des++ = *src++) == 0) return; *des = '\0'; } static char filetype(dir, file) char *dir, *file; { char path[MAXPATHLEN]; struct stat statb; catn(strcpy(path, dir), file, sizeof path); if (lstat(path, &statb) == 0) { switch(statb.st_mode & S_IFMT) { case S_IFDIR: return ('/'); case S_IFLNK: if (stat(path, &statb) == 0 && /* follow it out */ (statb.st_mode & S_IFMT) == S_IFDIR) return ('>'); else return ('@'); case S_IFSOCK: return ('='); default: if (statb.st_mode & 0111) return ('*'); } } return (' '); } static struct winsize win; /* * Print sorted down columns */ static print_by_column(dir, items, count) char *dir, *items[]; { register int i, rows, r, c, maxwidth = 0, columns; if (ioctl(SHOUT, TIOCGWINSZ, (char *)&win) < 0 || win.ws_col == 0) win.ws_col = 80; for (i = 0; i < count; i++) maxwidth = maxwidth > (r = strlen(items[i])) ? maxwidth : r; maxwidth += 2; /* for the file tag and space */ columns = win.ws_col / maxwidth; if (columns == 0) columns = 1; rows = (count + (columns - 1)) / columns; for (r = 0; r < rows; r++) { for (c = 0; c < columns; c++) { i = c * rows + r; if (i < count) { register int w; printf("%s", items[i]); putchar(dir ? filetype(dir, items[i]) : ' '); if (c < columns - 1) { /* last column? */ w = strlen(items[i]) + 1; for (; w < maxwidth; w++) putchar(' '); } } } putchar('\n'); } } /* * Expand file name with possible tilde usage * ~person/mumble * expands to * home_directory_of_person/mumble */ static char * tilde(new, old) char *new, *old; { register char *o, *p; register struct passwd *pw; static char person[40]; if (old[0] != '~') return (strcpy(new, old)); for (p = person, o = &old[1]; *o && *o != '/'; *p++ = *o++) ; *p = '\0'; if (person[0] == '\0') (void) strcpy(new, value("home")); else { pw = getpwnam(person); if (pw == NULL) return (NULL); (void) strcpy(new, pw->pw_dir); } (void) strcat(new, o); return (new); } /* * Cause pending line to be printed */ static retype() { int pending_input = LPENDIN; (void) ioctl(SHOUT, TIOCLBIS, (char *)&pending_input); } static beep() { if (adrof("nobeep") == 0) (void) write(SHOUT, "\007", 1); } /* * Erase that silly ^[ and * print the recognized part of the string */ static print_recognized_stuff(recognized_part) char *recognized_part; { /* An optimized erasing of that silly ^[ */ switch (strlen(recognized_part)) { case 0: /* erase two characters: ^[ */ printf("\210\210 \210\210"); break; case 1: /* overstrike the ^, erase the [ */ printf("\210\210%s \210", recognized_part); break; default: /* overstrike both characters ^[ */ printf("\210\210%s", recognized_part); break; } flush(); } /* * Parse full path in file into 2 parts: directory and file names * Should leave final slash (/) at end of dir. */ static extract_dir_and_name(path, dir, name) char *path, *dir, *name; { register char *p; p = rindex(path, '/'); if (p == NULL) { copyn(name, path, MAXNAMLEN); dir[0] = '\0'; } else { copyn(name, ++p, MAXNAMLEN); copyn(dir, path, p - path); } } static char * getentry(dir_fd, looking_for_lognames) DIR *dir_fd; { register struct passwd *pw; register struct direct *dirp; if (looking_for_lognames) { if ((pw = getpwent()) == NULL) return (NULL); return (pw->pw_name); } if (dirp = readdir(dir_fd)) return (dirp->d_name); return (NULL); } static free_items(items) register char **items; { register int i; for (i = 0; items[i]; i++) free(items[i]); free((char *)items); } #define FREE_ITEMS(items) { \ long omask;\ \ omask = sigblock(sigmask(SIGINT));\ free_items(items);\ items = NULL;\ (void) sigsetmask(omask);\ } /* * Object: extend what user typed up to an ambiguity. * Algorithm: * On first match, copy full entry (assume it'll be the only match) * On subsequent matches, shorten extended_name to the first * character mismatch between extended_name and entry. * If we shorten it back to the prefix length, stop searching. */ static recognize(extended_name, entry, name_length, numitems) char *extended_name, *entry; { if (numitems == 1) /* 1st match */ copyn(extended_name, entry, MAXNAMLEN); else { /* 2nd & subsequent matches */ register char *x, *ent; register int len = 0; x = extended_name; for (ent = entry; *x && *x == *ent++; x++, len++) ; *x = '\0'; /* Shorten at 1st char diff */ if (len == name_length) /* Ambiguous to prefix? */ return (-1); /* So stop now and save time */ } return (0); } /* * Return true if check matches initial chars in template. * This differs from PWB imatch in that if check is null * it matches anything. */ static is_prefix(check, template) register char *check, *template; { do if (*check == 0) return (TRUE); while (*check++ == *template++); return (FALSE); } /* * Return true if the chars in template appear at the * end of check, I.e., are it's suffix. */ static is_suffix(check, template) char *check, *template; { register char *c, *t; for (c = check; *c++;) ; for (t = template; *t++;) ; for (;;) { if (t == template) return 1; if (c == check || *--t != *--c) return 0; } } static ignored(entry) register char *entry; { struct varent *vp; register char **cp; if ((vp = adrof("fignore")) == NULL || (cp = vp->vec) == NULL) return (FALSE); for (; *cp != NULL; cp++) if (is_suffix(entry, *cp)) return (TRUE); return (FALSE); } /* * Perform a RECOGNIZE or LIST command on string "word". */ static search(word, command, max_word_length) char *word; COMMAND command; { static char **items = NULL; register DIR *dir_fd; register numitems = 0, ignoring = TRUE, nignored = 0; register name_length, looking_for_lognames; char tilded_dir[MAXPATHLEN + 1], dir[MAXPATHLEN + 1]; char name[MAXNAMLEN + 1], extended_name[MAXNAMLEN+1]; char *entry; #define MAXITEMS 1024 if (items != NULL) FREE_ITEMS(items); looking_for_lognames = (*word == '~') && (index(word, '/') == NULL); if (looking_for_lognames) { (void) setpwent(); copyn(name, &word[1], MAXNAMLEN); /* name sans ~ */ } else { extract_dir_and_name(word, dir, name); if (tilde(tilded_dir, dir) == 0) return (0); dir_fd = opendir(*tilded_dir ? tilded_dir : "."); if (dir_fd == NULL) return (0); } again: /* search for matches */ name_length = strlen(name); for (numitems = 0; entry = getentry(dir_fd, looking_for_lognames); ) { if (!is_prefix(name, entry)) continue; /* Don't match . files on null prefix match */ if (name_length == 0 && entry[0] == '.' && !looking_for_lognames) continue; if (command == LIST) { if (numitems >= MAXITEMS) { printf ("\nYikes!! Too many %s!!\n", looking_for_lognames ? "names in password file":"files"); break; } if (items == NULL) items = (char **) calloc(sizeof (items[1]), MAXITEMS); items[numitems] = xalloc((unsigned)strlen(entry) + 1); copyn(items[numitems], entry, MAXNAMLEN); numitems++; } else { /* RECOGNIZE command */ if (ignoring && ignored(entry)) nignored++; else if (recognize(extended_name, entry, name_length, ++numitems)) break; } } if (ignoring && numitems == 0 && nignored > 0) { ignoring = FALSE; nignored = 0; if (looking_for_lognames) (void) setpwent(); else rewinddir(dir_fd); goto again; } if (looking_for_lognames) (void) endpwent(); else closedir(dir_fd); if (numitems == 0) return (0); if (command == RECOGNIZE) { if (looking_for_lognames) copyn(word, "~", 1); else /* put back dir part */ copyn(word, dir, max_word_length); /* add extended name */ catn(word, extended_name, max_word_length); return (numitems); } else { /* LIST */ qsort((char *)items, numitems, sizeof(items[1]), sortscmp); print_by_column(looking_for_lognames ? NULL : tilded_dir, items, numitems); if (items != NULL) FREE_ITEMS(items); } return (0); } tenex(inputline, inputline_size) char *inputline; int inputline_size; { register int numitems, num_read; setup_tty(ON); while ((num_read = read(SHIN, inputline, inputline_size)) > 0) { static char *delims = " '\"\t;&<>()|^%"; register char *str_end, *word_start, last_char, should_retype; register int space_left; COMMAND command; last_char = inputline[num_read - 1] & 0177; if (last_char == '\n' || num_read == inputline_size) break; command = (last_char == ESC) ? RECOGNIZE : LIST; if (command == LIST) putchar('\n'); str_end = &inputline[num_read]; if (last_char == ESC) --str_end; /* wipeout trailing cmd char */ *str_end = '\0'; /* * Find LAST occurence of a delimiter in the inputline. * The word start is one character past it. */ for (word_start = str_end; word_start > inputline; --word_start) if (index(delims, word_start[-1])) break; space_left = inputline_size - (word_start - inputline) - 1; numitems = search(word_start, command, space_left); if (command == RECOGNIZE) { /* print from str_end on */ print_recognized_stuff(str_end); if (numitems != 1) /* Beep = No match/ambiguous */ beep(); } /* * Tabs in the input line cause trouble after a pushback. * tty driver won't backspace over them because column * positions are now incorrect. This is solved by retyping * over current line. */ should_retype = FALSE; if (index(inputline, '\t')) { /* tab char in input line? */ back_to_col_1(); should_retype = TRUE; } if (command == LIST) /* Always retype after a LIST */ should_retype = TRUE; if (should_retype) printprompt(); pushback(inputline); if (should_retype) retype(); } setup_tty(OFF); return (num_read); } #endif /* FILEC */ ================================================ FILE: bin/csh/sh.func.c ================================================ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley Software License Agreement * specifies the terms and conditions for redistribution. */ #include "sh.h" #include /* * C shell */ struct biltins * isbfunc(t) struct command *t; { register char *cp = t->t_dcom[0]; register struct biltins *bp, *bp1, *bp2; int dolabel(), dofg1(), dobg1(); static struct biltins label = { "", dolabel, 0, 0 }; static struct biltins foregnd = { "%job", dofg1, 0, 0 }; static struct biltins backgnd = { "%job &", dobg1, 0, 0 }; if (lastchr(cp) == ':') { label.bname = cp; return (&label); } if (*cp == '%') { if (t->t_dflg & FAND) { t->t_dflg &= ~FAND; backgnd.bname = cp; return (&backgnd); } foregnd.bname = cp; return (&foregnd); } /* * Binary search * Bp1 is the beginning of the current search range. * Bp2 is one past the end. */ for (bp1 = bfunc, bp2 = bfunc + nbfunc; bp1 < bp2;) { register i; bp = bp1 + (bp2 - bp1 >> 1); if ((i = *cp - *bp->bname) == 0 && (i = strcmp(cp, bp->bname)) == 0) return bp; if (i < 0) bp2 = bp; else bp1 = bp + 1; } return (0); } func(t, bp) register struct command *t; register struct biltins *bp; { int i; xechoit(t->t_dcom); setname(bp->bname); i = blklen(t->t_dcom) - 1; if (i < bp->minargs) bferr("Too few arguments"); if (i > bp->maxargs) bferr("Too many arguments"); (*bp->bfunct)(t->t_dcom, t); } dolabel() { } doonintr(v) char **v; { register char *cp; register char *vv = v[1]; if (parintr == SIG_IGN) return; if (setintr && intty) bferr("Can't from terminal"); cp = gointr, gointr = 0, xfree(cp); if (vv == 0) { if (setintr) (void) sigblock(sigmask(SIGINT)); else (void) signal(SIGINT, SIG_DFL); gointr = 0; } else if (eq((vv = strip(vv)), "-")) { (void) signal(SIGINT, SIG_IGN); gointr = "-"; } else { gointr = savestr(vv); (void) signal(SIGINT, pintr); } } donohup() { if (intty) bferr("Can't from terminal"); if (setintr == 0) { (void) signal(SIGHUP, SIG_IGN); #ifdef CC submit(getpid()); #endif } } dozip() { ; } prvars() { plist(&shvhed); } doalias(v) register char **v; { register struct varent *vp; register char *p; v++; p = *v++; if (p == 0) plist(&aliases); else if (*v == 0) { vp = adrof1(strip(p), &aliases); if (vp) blkpr(vp->vec), printf("\n"); } else { if (eq(p, "alias") || eq(p, "unalias")) { setname(p); bferr("Too dangerous to alias that"); } set1(strip(p), saveblk(v), &aliases); } } unalias(v) char **v; { unset1(v, &aliases); } dologout() { islogin(); goodbye(); } dologin(v) char **v; { islogin(); rechist(); (void) signal(SIGTERM, parterm); execl("/usr/bin/login", "login", v[1], (char*)0); untty(); exit(1); } #ifdef NEWGRP donewgrp(v) char **v; { if (chkstop == 0 && setintr) panystop(0); (void) signal(SIGTERM, parterm); execl("/bin/newgrp", "newgrp", v[1], (char*)0); untty(); exit(1); } #endif islogin() { if (chkstop == 0 && setintr) panystop(0); if (loginsh) return; error("Not login shell"); } doif(v, kp) char **v; struct command *kp; { register int i; register char **vv; v++; i = expr(&v); vv = v; if (*vv == NOSTR) bferr("Empty if"); if (eq(*vv, "then")) { if (*++vv) bferr("Improper then"); setname("then"); /* * If expression was zero, then scan to else, * otherwise just fall into following code. */ if (!i) search(ZIF, 0); return; } /* * Simple command attached to this if. * Left shift the node in this tree, munging it * so we can reexecute it. */ if (i) { lshift(kp->t_dcom, vv - kp->t_dcom); reexecute(kp); donefds(); } } /* * Reexecute a command, being careful not * to redo i/o redirection, which is already set up. */ reexecute(kp) register struct command *kp; { kp->t_dflg &= FSAVE; kp->t_dflg |= FREDO; /* * If tty is still ours to arbitrate, arbitrate it; * otherwise dont even set pgrp's as the jobs would * then have no way to get the tty (we can't give it * to them, and our parent wouldn't know their pgrp, etc. */ execute(kp, tpgrp > 0 ? tpgrp : -1); } doelse() { search(ZELSE, 0); } dogoto(v) char **v; { register struct whyle *wp; char *lp; /* * While we still can, locate any unknown ends of existing loops. * This obscure code is the WORST result of the fact that we * don't really parse. */ for (wp = whyles; wp; wp = wp->w_next) if (wp->w_end == 0) { search(ZBREAK, 0); wp->w_end = btell(); } else bseek(wp->w_end); search(ZGOTO, 0, lp = globone(v[1])); xfree(lp); /* * Eliminate loops which were exited. */ wfree(); } doswitch(v) register char **v; { register char *cp, *lp; v++; if (!*v || *(*v++) != '(') goto syntax; cp = **v == ')' ? "" : *v++; if (*(*v++) != ')') v--; if (*v) syntax: error("Syntax error"); search(ZSWITCH, 0, lp = globone(cp)); xfree(lp); } dobreak() { if (whyles) toend(); else bferr("Not in while/foreach"); } doexit(v) char **v; { if (chkstop == 0) panystop(0); /* * Don't DEMAND parentheses here either. */ v++; if (*v) { set("status", putn(expr(&v))); if (*v) bferr("Expression syntax"); } btoeof(); if (intty) (void) close(SHIN); } doforeach(v) register char **v; { register char *cp; register struct whyle *nwp; v++; cp = strip(*v); while (*cp && letter(*cp)) cp++; if (*cp || strlen(*v) >= 20) bferr("Invalid variable"); cp = *v++; if (v[0][0] != '(' || v[blklen(v) - 1][0] != ')') bferr("Words not ()'ed"); v++; gflag = 0, tglob(v); v = glob(v); if (v == 0) bferr("No match"); nwp = (struct whyle *) calloc(1, sizeof *nwp); nwp->w_fe = nwp->w_fe0 = v; gargv = 0; nwp->w_start = btell(); nwp->w_fename = savestr(cp); nwp->w_next = whyles; whyles = nwp; /* * Pre-read the loop so as to be more * comprehensible to a terminal user. */ if (intty) preread(); doagain(); } dowhile(v) char **v; { register int status; register bool again = whyles != 0 && whyles->w_start == lineloc && whyles->w_fename == 0; v++; /* * Implement prereading here also, taking care not to * evaluate the expression before the loop has been read up * from a terminal. */ if (intty && !again) status = !exp0(&v, 1); else status = !expr(&v); if (*v) bferr("Expression syntax"); if (!again) { register struct whyle *nwp = (struct whyle *) calloc(1, sizeof (*nwp)); nwp->w_start = lineloc; nwp->w_end = 0; nwp->w_next = whyles; whyles = nwp; if (intty) { /* * The tty preread */ preread(); doagain(); return; } } if (status) /* We ain't gonna loop no more, no more! */ toend(); } preread() { whyles->w_end = -1; if (setintr) (void) sigsetmask(sigblock(0L) & ~sigmask(SIGINT)); search(ZBREAK, 0); if (setintr) (void) sigblock(sigmask(SIGINT)); whyles->w_end = btell(); } doend() { if (!whyles) bferr("Not in while/foreach"); whyles->w_end = btell(); doagain(); } docontin() { if (!whyles) bferr("Not in while/foreach"); doagain(); } doagain() { /* Repeating a while is simple */ if (whyles->w_fename == 0) { bseek(whyles->w_start); return; } /* * The foreach variable list actually has a spurious word * ")" at the end of the w_fe list. Thus we are at the * of the list if one word beyond this is 0. */ if (!whyles->w_fe[1]) { dobreak(); return; } set(whyles->w_fename, savestr(*whyles->w_fe++)); bseek(whyles->w_start); } dorepeat(v, kp) char **v; struct command *kp; { register int i; register long omask; i = getn(v[1]); if (setintr) omask = sigblock(sigmask(SIGINT)) & ~sigmask(SIGINT); lshift(v, 2); while (i > 0) { if (setintr) (void) sigsetmask(omask); reexecute(kp); --i; } donefds(); if (setintr) (void) sigsetmask(omask); } doswbrk() { search(ZBRKSW, 0); } srchx(cp) register char *cp; { register struct srch *sp, *sp1, *sp2; register i; /* * Binary search * Sp1 is the beginning of the current search range. * Sp2 is one past the end. */ for (sp1 = srchn, sp2 = srchn + nsrchn; sp1 < sp2;) { sp = sp1 + (sp2 - sp1 >> 1); if ((i = *cp - *sp->s_name) == 0 && (i = strcmp(cp, sp->s_name)) == 0) return sp->s_value; if (i < 0) sp2 = sp; else sp1 = sp + 1; } return (-1); } char Stype; char *Sgoal; /*VARARGS2*/ search(type, level, goal) int type; register int level; char *goal; { char wordbuf[BUFSIZ]; register char *aword = wordbuf; register char *cp; Stype = type; Sgoal = goal; if (type == ZGOTO) bseek((off_t)0); do { if (intty && fseekp == feobp) printf("? "), flush(); aword[0] = 0; (void) getword(aword); switch (srchx(aword)) { case ZELSE: if (level == 0 && type == ZIF) return; break; case ZIF: while (getword(aword)) continue; if ((type == ZIF || type == ZELSE) && eq(aword, "then")) level++; break; case ZENDIF: if (type == ZIF || type == ZELSE) level--; break; case ZFOREACH: case ZWHILE: if (type == ZBREAK) level++; break; case ZEND: if (type == ZBREAK) level--; break; case ZSWITCH: if (type == ZSWITCH || type == ZBRKSW) level++; break; case ZENDSW: if (type == ZSWITCH || type == ZBRKSW) level--; break; case ZLABEL: if (type == ZGOTO && getword(aword) && eq(aword, goal)) level = -1; break; default: if (type != ZGOTO && (type != ZSWITCH || level != 0)) break; if (lastchr(aword) != ':') break; aword[strlen(aword) - 1] = 0; if (type == ZGOTO && eq(aword, goal) || type == ZSWITCH && eq(aword, "default")) level = -1; break; case ZCASE: if (type != ZSWITCH || level != 0) break; (void) getword(aword); if (lastchr(aword) == ':') aword[strlen(aword) - 1] = 0; cp = strip(Dfix1(aword)); if (Gmatch(goal, cp)) level = -1; xfree(cp); break; case ZDEFAULT: if (type == ZSWITCH && level == 0) level = -1; break; } (void) getword(NOSTR); } while (level >= 0); } getword(wp) register char *wp; { register int found = 0; register int c, d; c = readc(1); d = 0; do { while (c == ' ' || c == '\t') c = readc(1); if (c == '#') do c = readc(1); while (c >= 0 && c != '\n'); if (c < 0) goto past; if (c == '\n') { if (wp) break; return (0); } unreadc(c); found = 1; do { c = readc(1); if (c == '\\' && (c = readc(1)) == '\n') c = ' '; if (c == '\'' || c == '"') if (d == 0) d = c; else if (d == c) d = 0; if (c < 0) goto past; if (wp) *wp++ = c; } while ((d || c != ' ' && c != '\t') && c != '\n'); } while (wp == 0); unreadc(c); if (found) *--wp = 0; return (found); past: switch (Stype) { case ZIF: bferr("then/endif not found"); case ZELSE: bferr("endif not found"); case ZBRKSW: case ZSWITCH: bferr("endsw not found"); case ZBREAK: bferr("end not found"); case ZGOTO: setname(Sgoal); bferr("label not found"); } /*NOTREACHED*/ } toend() { if (whyles->w_end == 0) { search(ZBREAK, 0); whyles->w_end = btell() - 1; } else bseek(whyles->w_end); wfree(); } wfree() { long o = btell(); while (whyles) { register struct whyle *wp = whyles; register struct whyle *nwp = wp->w_next; if (o >= wp->w_start && (wp->w_end == 0 || o < wp->w_end)) break; if (wp->w_fe0) blkfree(wp->w_fe0); if (wp->w_fename) xfree(wp->w_fename); xfree((char *)wp); whyles = nwp; } } doecho(v) char **v; { echo(' ', v); } doglob(v) char **v; { echo(0, v); flush(); } echo(sep, v) char sep; register char **v; { register char *cp; int nonl = 0; if (setintr) (void) sigsetmask(sigblock(0L) & ~sigmask(SIGINT)); v++; if (*v == 0) return; gflag = 0, tglob(v); if (gflag) { v = glob(v); if (v == 0) bferr("No match"); } else trim(v); if (sep == ' ' && *v && !strcmp(*v, "-n")) nonl++, v++; while (cp = *v++) { register int c; while (c = *cp++) putchar(c | QUOTE); if (*v) putchar(sep | QUOTE); } if (sep && nonl == 0) putchar('\n'); else flush(); if (setintr) (void) sigblock(sigmask(SIGINT)); if (gargv) blkfree(gargv), gargv = 0; } char **environ; dosetenv(v) register char **v; { char *vp, *lp; v++; if ((vp = *v++) == 0) { register char **ep; if (setintr) (void) sigsetmask(sigblock(0L) & ~ sigmask(SIGINT)); for (ep = environ; *ep; ep++) printf("%s\n", *ep); return; } if ((lp = *v++) == 0) lp = ""; setenvv(vp, lp = globone(lp)); if (eq(vp, "PATH")) { importpath(lp); dohash(); } xfree(lp); } dounsetenv(v) register char **v; { v++; do unsetenvv(*v++); while (*v); } setenvv(name, val) char *name, *val; { register char **ep = environ; register char *cp, *dp; char *blk[2], **oep = ep; for (; *ep; ep++) { for (cp = name, dp = *ep; *cp && *cp == *dp; cp++, dp++) continue; if (*cp != 0 || *dp != '=') continue; cp = strspl("=", val); xfree(*ep); *ep = strspl(name, cp); xfree(cp); trim(ep); return; } blk[0] = strspl(name, "="); blk[1] = 0; environ = blkspl(environ, blk); xfree((char *)oep); setenvv(name, val); } unsetenvv(name) char *name; { register char **ep = environ; register char *cp, *dp; char **oep = ep; for (; *ep; ep++) { for (cp = name, dp = *ep; *cp && *cp == *dp; cp++, dp++) continue; if (*cp != 0 || *dp != '=') continue; cp = *ep; *ep = 0; environ = blkspl(environ, ep+1); *ep = cp; xfree(cp); xfree((char *)oep); return; } } doumask(v) register char **v; { register char *cp = v[1]; register int i; if (cp == 0) { i = umask(0); (void) umask(i); printf("%o\n", i); return; } i = 0; while (digit(*cp) && *cp != '8' && *cp != '9') i = i * 8 + *cp++ - '0'; if (*cp || i < 0 || i > 0777) bferr("Improper mask"); (void) umask(i); } #ifndef NOLIMITS struct limits { int limconst; char *limname; int limdiv; char *limscale; } limits[] = { RLIMIT_CPU, "cputime", 1, "seconds", RLIMIT_FSIZE, "filesize", 1024, "kbytes", RLIMIT_DATA, "datasize", 1024, "kbytes", RLIMIT_STACK, "stacksize", 1024, "kbytes", RLIMIT_CORE, "coredumpsize", 1024, "kbytes", RLIMIT_RSS, "memoryuse", 1024, "kbytes", -1, 0, }; struct limits * findlim(cp) char *cp; { register struct limits *lp, *res; res = 0; for (lp = limits; lp->limconst >= 0; lp++) if (prefix(cp, lp->limname)) { if (res) bferr("Ambiguous"); res = lp; } if (res) return (res); bferr("No such limit"); /*NOTREACHED*/ } dolimit(v) register char **v; { register struct limits *lp; register long limit; long getval(); char hard = 0; v++; if (*v && eq(*v, "-h")) { hard = 1; v++; } if (*v == 0) { for (lp = limits; lp->limconst >= 0; lp++) plim(lp, hard); return; } lp = findlim(v[0]); if (v[1] == 0) { plim(lp, hard); return; } limit = getval(lp, v+1); if (setlim(lp, hard, limit) < 0) error(NOSTR); } long getval(lp, v) register struct limits *lp; char **v; { register float f; double atof(); char *cp = *v++; f = atof(cp); while (digit(*cp) || *cp == '.' || *cp == 'e' || *cp == 'E') cp++; if (*cp == 0) { if (*v == 0) return ((long)(f+0.5) * lp->limdiv); cp = *v; } switch (*cp) { case ':': if (lp->limconst != RLIMIT_CPU) goto badscal; return ((long)(f * 60.0 + atof(cp+1))); case 'h': if (lp->limconst != RLIMIT_CPU) goto badscal; limtail(cp, "hours"); f *= 3600.; break; case 'm': if (lp->limconst == RLIMIT_CPU) { limtail(cp, "minutes"); f *= 60.; break; } case 'M': if (lp->limconst == RLIMIT_CPU) goto badscal; *cp = 'm'; limtail(cp, "megabytes"); f *= 1024.*1024.; break; case 's': if (lp->limconst != RLIMIT_CPU) goto badscal; limtail(cp, "seconds"); break; case 'k': if (lp->limconst == RLIMIT_CPU) goto badscal; limtail(cp, "kbytes"); f *= 1024; break; case 'u': limtail(cp, "unlimited"); return (RLIM_INFINITY); default: badscal: bferr("Improper or unknown scale factor"); } return ((long)(f+0.5)); } limtail(cp, str0) char *cp, *str0; { register char *str = str0; while (*cp && *cp == *str) cp++, str++; if (*cp) error("Bad scaling; did you mean ``%s''?", str0); } plim(lp, hard) register struct limits *lp; char hard; { struct rlimit rlim; long limit; printf("%s \t", lp->limname); (void) getrlimit(lp->limconst, &rlim); limit = hard ? rlim.rlim_max : rlim.rlim_cur; if (limit == RLIM_INFINITY) printf("unlimited"); else if (lp->limconst == RLIMIT_CPU) psecs((long)limit); else printf("%ld %s", limit / lp->limdiv, lp->limscale); printf("\n"); } dounlimit(v) register char **v; { register struct limits *lp; int parserr = 0; char hard = 0; v++; if (*v && eq(*v, "-h")) { hard = 1; v++; } if (*v == 0) { for (lp = limits; lp->limconst >= 0; lp++) if (setlim(lp, hard, (long)RLIM_INFINITY) < 0) parserr++; if (parserr) error(NOSTR); return; } while (*v) { lp = findlim(*v++); if (setlim(lp, hard, (long)RLIM_INFINITY) < 0) error(NOSTR); } } setlim(lp, hard, limit) register struct limits *lp; char hard; long limit; { struct rlimit rlim; (void) getrlimit(lp->limconst, &rlim); if (hard) rlim.rlim_max = limit; else if (limit == RLIM_INFINITY && geteuid() != 0) rlim.rlim_cur = rlim.rlim_max; else rlim.rlim_cur = limit; if (setrlimit(lp->limconst, &rlim) < 0) { printf("%s: %s: Can't %s%s limit\n", bname, lp->limname, limit == RLIM_INFINITY ? "remove" : "set", hard ? " hard" : ""); return (-1); } return (0); } #endif /* !NOLIMITS */ dosuspend() { int ldisc, ctpgrp; void (*old)(int); if (loginsh) error("Can't suspend a login shell (yet)"); untty(); old = signal(SIGTSTP, SIG_DFL); (void) kill(0, SIGTSTP); /* the shell stops here */ (void) signal(SIGTSTP, old); if (tpgrp != -1) { retry: (void) ioctl(FSHTTY, TIOCGPGRP, (char *)&ctpgrp); if (ctpgrp != opgrp) { old = signal(SIGTTIN, SIG_DFL); (void) kill(0, SIGTTIN); (void) signal(SIGTTIN, old); goto retry; } (void) ioctl(FSHTTY, TIOCSPGRP, (char *)&shpgrp); (void) setpgrp(0, shpgrp); } (void) ioctl(FSHTTY, TIOCGETD, (char *)&oldisc); if (oldisc != NTTYDISC) { printf("Switching to new tty driver...\n"); ldisc = NTTYDISC; (void) ioctl(FSHTTY, TIOCSETD, (char *)&ldisc); } } doeval(v) char **v; { char **oevalvec = evalvec; char *oevalp = evalp; jmp_buf osetexit; int reenter; char **gv = 0; v++; if (*v == 0) return; gflag = 0, tglob(v); if (gflag) { gv = v = glob(v); gargv = 0; if (v == 0) error("No match"); v = copyblk(v); } else trim(v); getexit(osetexit); reenter = 0; setexit(); reenter++; if (reenter == 1) { evalvec = v; evalp = 0; process(0); } evalvec = oevalvec; evalp = oevalp; doneinp = 0; if (gv) blkfree(gv); resexit(osetexit); if (reenter >= 2) error(NOSTR); } ================================================ FILE: bin/csh/sh.glob.c ================================================ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley Software License Agreement * specifies the terms and conditions for redistribution. */ #include "sh.h" #include /* * C Shell */ int globcnt; char *gpath, *gpathp, *lastgpathp; int globbed; bool noglob; bool nonomatch; char *entp; char **sortbas; int sortscmp(); #define sort() qsort((char *)sortbas, &gargv[gargc] - sortbas, \ sizeof(*sortbas), sortscmp), sortbas = &gargv[gargc] char ** glob(v) register char **v; { char agpath[BUFSIZ]; char *agargv[GAVSIZ]; gpath = agpath; gpathp = gpath; *gpathp = 0; lastgpathp = &gpath[sizeof agpath - 2]; ginit(agargv); globcnt = 0; #ifdef GDEBUG printf("glob entered: "); blkpr(v); printf("\n"); #endif noglob = adrof("noglob") != 0; nonomatch = adrof("nonomatch") != 0; globcnt = noglob | nonomatch; while (*v) collect(*v++); #ifdef GDEBUG printf("glob done, globcnt=%d, gflag=%d: ", globcnt, gflag); blkpr(gargv); printf("\n"); #endif if (globcnt == 0 && (gflag&1)) { blkfree(gargv), gargv = 0; return (0); } else return (gargv = copyblk(gargv)); } ginit(agargv) char **agargv; { agargv[0] = 0; gargv = agargv; sortbas = agargv; gargc = 0; gnleft = NCARGS - 4; } collect(as) register char *as; { register int i; if (any('`', as)) { #ifdef GDEBUG printf("doing backp of %s\n", as); #endif (void) dobackp(as, 0); #ifdef GDEBUG printf("backp done, acollect'ing\n"); #endif for (i = 0; i < pargc; i++) if (noglob) { Gcat(pargv[i], ""); sortbas = &gargv[gargc]; } else acollect(pargv[i]); if (pargv) blkfree(pargv), pargv = 0; #ifdef GDEBUG printf("acollect done\n"); #endif } else if (noglob || eq(as, "{") || eq(as, "{}")) { Gcat(as, ""); sort(); } else acollect(as); } acollect(as) register char *as; { register int ogargc = gargc; gpathp = gpath; *gpathp = 0; globbed = 0; expand(as); if (gargc == ogargc) { if (nonomatch) { Gcat(as, ""); sort(); } } else sort(); } /* * String compare for qsort. Also used by filec code in sh.file.c. */ sortscmp(a1, a2) char **a1, **a2; { return (strcmp(*a1, *a2)); } expand(as) char *as; { register char *cs; register char *sgpathp, *oldcs; struct stat stb; sgpathp = gpathp; cs = as; if (*cs == '~' && gpathp == gpath) { addpath('~'); for (cs++; letter(*cs) || digit(*cs) || *cs == '-';) addpath(*cs++); if (!*cs || *cs == '/') { if (gpathp != gpath + 1) { *gpathp = 0; if (gethdir(gpath + 1)) error("Unknown user: %s", gpath + 1); (void) strcpy(gpath, gpath + 1); } else (void) strcpy(gpath, value("home")); gpathp = strend(gpath); } } while (!isglob(*cs)) { if (*cs == 0) { if (!globbed) Gcat(gpath, ""); else if (stat(gpath, &stb) >= 0) { Gcat(gpath, ""); globcnt++; } goto endit; } addpath(*cs++); } oldcs = cs; while (cs > as && *cs != '/') cs--, gpathp--; if (*cs == '/') cs++, gpathp++; *gpathp = 0; if (*oldcs == '{') { (void) execbrc(cs, NOSTR); return; } matchdir(cs); endit: gpathp = sgpathp; *gpathp = 0; } matchdir(pattern) char *pattern; { struct stat stb; register struct direct *dp; register DIR *dirp; dirp = opendir(gpath); if (dirp == NULL) { if (globbed) return; goto patherr2; } if (fstat(dirfd(dirp), &stb) < 0) goto patherr1; if (!S_ISDIR(stb.st_mode)) { errno = ENOTDIR; goto patherr1; } while ((dp = readdir(dirp)) != NULL) { if (dp->d_ino == 0) continue; if (match(dp->d_name, pattern)) { Gcat(gpath, dp->d_name); globcnt++; } } closedir(dirp); return; patherr1: closedir(dirp); patherr2: Perror(gpath); } execbrc(p, s) char *p, *s; { char restbuf[BUFSIZ + 2]; register char *pe, *pm, *pl; int brclev = 0; char *lm, savec, *sgpathp; for (lm = restbuf; *p != '{'; *lm++ = *p++) continue; for (pe = ++p; *pe; pe++) switch (*pe) { case '{': brclev++; continue; case '}': if (brclev == 0) goto pend; brclev--; continue; case '[': for (pe++; *pe && *pe != ']'; pe++) continue; if (!*pe) error("Missing ]"); continue; } pend: if (brclev || !*pe) error("Missing }"); for (pl = pm = p; pm <= pe; pm++) switch (*pm & (QUOTE|TRIM)) { case '{': brclev++; continue; case '}': if (brclev) { brclev--; continue; } goto doit; case ','|QUOTE: case ',': if (brclev) continue; doit: savec = *pm; *pm = 0; (void) strcpy(lm, pl); (void) strcat(restbuf, pe + 1); *pm = savec; if (s == 0) { sgpathp = gpathp; expand(restbuf); gpathp = sgpathp; *gpathp = 0; } else if (amatch(s, restbuf)) return (1); sort(); pl = pm + 1; continue; case '[': for (pm++; *pm && *pm != ']'; pm++) continue; if (!*pm) error("Missing ]"); continue; } return (0); } match(s, p) char *s, *p; { register int c; register char *sentp; char sglobbed = globbed; if (*s == '.' && *p != '.') return (0); sentp = entp; entp = s; c = amatch(s, p); entp = sentp; globbed = sglobbed; return (c); } amatch(s, p) register char *s, *p; { register int scc; int ok, lc; char *sgpathp; struct stat stb; int c, cc; globbed = 1; for (;;) { scc = *s++ & TRIM; switch (c = *p++) { case '{': return (execbrc(p - 1, s - 1)); case '[': ok = 0; lc = 077777; while (cc = *p++) { if (cc == ']') { if (ok) break; return (0); } if (cc == '-') { if (lc <= scc && scc <= *p++) ok++; } else if (scc == (lc = cc)) ok++; } if (cc == 0) error("Missing ]"); continue; case '*': if (!*p) return (1); if (*p == '/') { p++; goto slash; } for (s--; *s; s++) if (amatch(s, p)) return (1); return (0); case 0: return (scc == 0); default: if ((c & TRIM) != scc) return (0); continue; case '?': if (scc == 0) return (0); continue; case '/': if (scc) return (0); slash: s = entp; sgpathp = gpathp; while (*s) addpath(*s++); addpath('/'); if (stat(gpath, &stb) == 0 && S_ISDIR(stb.st_mode)) if (*p == 0) { Gcat(gpath, ""); globcnt++; } else expand(p); gpathp = sgpathp; *gpathp = 0; return (0); } } } Gmatch(s, p) register char *s, *p; { register int scc; int ok, lc; int c, cc; for (;;) { scc = *s++ & TRIM; switch (c = *p++) { case '[': ok = 0; lc = 077777; while (cc = *p++) { if (cc == ']') { if (ok) break; return (0); } if (cc == '-') { if (lc <= scc && scc <= *p++) ok++; } else if (scc == (lc = cc)) ok++; } if (cc == 0) bferr("Missing ]"); continue; case '*': if (!*p) return (1); for (s--; *s; s++) if (Gmatch(s, p)) return (1); return (0); case 0: return (scc == 0); default: if ((c & TRIM) != scc) return (0); continue; case '?': if (scc == 0) return (0); continue; } } } Gcat(s1, s2) char *s1, *s2; { register char *p, *q; int n; for (p = s1; *p++;) ; for (q = s2; *q++;) ; gnleft -= (n = (p - s1) + (q - s2) - 1); if (gnleft <= 0 || ++gargc >= GAVSIZ) error("Arguments too long"); gargv[gargc] = 0; p = gargv[gargc - 1] = xalloc((unsigned)n); for (q = s1; *p++ = *q++;) ; for (p--, q = s2; *p++ = *q++;) ; } addpath(c) char c; { if (gpathp >= lastgpathp) error("Pathname too long"); *gpathp++ = c & TRIM; *gpathp = 0; } rscan(t, f) register char **t; int (*f)(); { register char *p; while (p = *t++) while (*p) (*f)(*p++); } trim(t) register char **t; { register char *p; while (p = *t++) while (*p) *p++ &= TRIM; } tglob(t) register char **t; { register char *p, c; while (p = *t++) { if (*p == '~') gflag |= 2; else if (*p == '{' && (p[1] == '\0' || p[1] == '}' && p[2] == '\0')) continue; while (c = *p++) if (isglob(c)) gflag |= c == '{' ? 2 : 1; } } char * globone(str) register char *str; { char *gv[2]; register char **gvp; register char *cp; gv[0] = str; gv[1] = 0; gflag = 0; tglob(gv); if (gflag) { gvp = glob(gv); if (gvp == 0) { setname(str); bferr("No match"); } cp = *gvp++; if (cp == 0) cp = ""; else if (*gvp) { setname(str); bferr("Ambiguous"); } else cp = strip(cp); /* if (cp == 0 || *gvp) { setname(str); bferr(cp ? "Ambiguous" : "No output"); } */ xfree((char *)gargv); gargv = 0; } else { trim(gv); cp = savestr(gv[0]); } return (cp); } /* * Command substitute cp. If literal, then this is * a substitution from a << redirection, and so we should * not crunch blanks and tabs, separating words only at newlines. */ char ** dobackp(cp, literal) char *cp; bool literal; { register char *lp, *rp; char *ep; char word[BUFSIZ]; char *apargv[GAVSIZ + 2]; if (pargv) { abort(); blkfree(pargv); } pargv = apargv; pargv[0] = NOSTR; pargcp = pargs = word; pargc = 0; pnleft = BUFSIZ - 4; for (;;) { for (lp = cp; *lp != '`'; lp++) { if (*lp == 0) { if (pargcp != pargs) pword(); #ifdef GDEBUG printf("leaving dobackp\n"); #endif return (pargv = copyblk(pargv)); } psave(*lp); } lp++; for (rp = lp; *rp && *rp != '`'; rp++) if (*rp == '\\') { rp++; if (!*rp) goto oops; } if (!*rp) oops: error("Unmatched `"); ep = savestr(lp); ep[rp - lp] = 0; backeval(ep, literal); #ifdef GDEBUG printf("back from backeval\n"); #endif cp = rp + 1; } } backeval(cp, literal) char *cp; bool literal; { int pvec[2]; int quoted = (literal || (cp[0] & QUOTE)) ? QUOTE : 0; char ibuf[BUFSIZ]; register int icnt = 0, c; register char *ip; bool hadnl = 0; char *fakecom[2]; struct command faket; faket.t_dtyp = TCOM; faket.t_dflg = 0; faket.t_dlef = 0; faket.t_drit = 0; faket.t_dspr = 0; faket.t_dcom = fakecom; fakecom[0] = "` ... `"; fakecom[1] = 0; /* * We do the psave job to temporarily change the current job * so that the following fork is considered a separate job. * This is so that when backquotes are used in a * builtin function that calls glob the "current job" is not corrupted. * We only need one level of pushed jobs as long as we are sure to * fork here. */ psavejob(); /* * It would be nicer if we could integrate this redirection more * with the routines in sh.sem.c by doing a fake execute on a builtin * function that was piped out. */ mypipe(pvec); if (pfork(&faket, -1) == 0) { struct wordent paraml; struct command *t; (void) close(pvec[0]); (void) dmove(pvec[1], 1); (void) dmove(SHDIAG, 2); initdesc(); arginp = cp; while (*cp) *cp++ &= TRIM; (void) lex(¶ml); if (parserr) error(parserr); alias(¶ml); t = syntax(paraml.next, ¶ml, 0); if (parserr) error(parserr); if (t) t->t_dflg |= FPAR; (void) signal(SIGTSTP, SIG_IGN); (void) signal(SIGTTIN, SIG_IGN); (void) signal(SIGTTOU, SIG_IGN); execute(t, -1); exitstat(); } xfree(cp); (void) close(pvec[1]); do { int cnt = 0; for (;;) { if (icnt == 0) { ip = ibuf; icnt = read(pvec[0], ip, BUFSIZ); if (icnt <= 0) { c = -1; break; } } if (hadnl) break; --icnt; c = (*ip++ & TRIM); if (c == 0) break; if (c == '\n') { /* * Continue around the loop one * more time, so that we can eat * the last newline without terminating * this word. */ hadnl = 1; continue; } if (!quoted && (c == ' ' || c == '\t')) break; cnt++; psave(c | quoted); } /* * Unless at end-of-file, we will form a new word * here if there were characters in the word, or in * any case when we take text literally. If * we didn't make empty words here when literal was * set then we would lose blank lines. */ if (c != -1 && (cnt || literal)) pword(); hadnl = 0; } while (c >= 0); #ifdef GDEBUG printf("done in backeval, pvec: %d %d\n", pvec[0], pvec[1]); printf("also c = %c <%o>\n", c, c); #endif (void) close(pvec[0]); pwait(); prestjob(); } psave(c) char c; { if (--pnleft <= 0) error("Word too long"); *pargcp++ = c; } pword() { psave(0); if (pargc == GAVSIZ) error("Too many words from ``"); pargv[pargc++] = savestr(pargs); pargv[pargc] = NOSTR; #ifdef GDEBUG printf("got word %s\n", pargv[pargc-1]); #endif pargcp = pargs; pnleft = BUFSIZ - 4; } ================================================ FILE: bin/csh/sh.h ================================================ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley Software License Agreement * specifies the terms and conditions for redistribution. * * @(#)sh.h 5.3.2 (2.11BSD GTE) 1996/9/20 */ #include #include #include #include #include #include #include #include #include #include #include "sh.local.h" #include "sh.char.h" /* * C shell * * Bill Joy, UC Berkeley * October, 1978; May 1980 * * Jim Kulp, IIASA, Laxenburg Austria * April, 1980 */ typedef int bool; #define eq(a, b) (strcmp(a, b) == 0) #define printf shprintf /* * Global flags */ bool chkstop; /* Warned of stopped jobs... allow exit */ bool didfds; /* Have setup i/o fd's for child */ bool doneinp; /* EOF indicator after reset from readc */ bool exiterr; /* Exit if error or non-zero exit status */ bool child; /* Child shell ... errors cause exit */ bool haderr; /* Reset was because of an error */ bool intty; /* Input is a tty */ bool intact; /* We are interactive... therefore prompt */ bool justpr; /* Just print because of :p hist mod */ bool loginsh; /* We are a loginsh -> .login/.logout */ bool neednote; /* Need to pnotify() */ bool noexec; /* Don't execute, just syntax check */ bool pjobs; /* want to print jobs if interrupted */ bool setintr; /* Set interrupts on/off -> Wait intr... */ bool timflg; /* Time the next waited for command */ bool havhash; /* path hashing is available */ #ifdef FILEC bool filec; /* doing filename expansion */ #endif /* * Global i/o info */ char *arginp; /* Argument input for sh -c and internal `xx` */ int onelflg; /* 2 -> need line for -t, 1 -> exit on read */ char *file; /* Name of shell file for $0 */ char *parserr; /* Error message from scanner/parser */ int errno; /* Error from C library routines */ char *shtemp; /* Temp name for << shell files in /tmp */ struct timeval time0; /* Time at which the shell started */ struct rusage ru0; /* * Miscellany */ char *doldol; /* Character pid for $$ */ int uid; /* Invokers uid */ time_t chktim; /* Time mail last checked */ int shpgrp; /* Pgrp of shell */ int tpgrp; /* Terminal process group */ /* If tpgrp is -1, leave tty alone! */ int opgrp; /* Initial pgrp and tty pgrp */ int oldisc; /* Initial line discipline or -1 */ /* * These are declared here because they want to be * initialized in sh.init.c (to allow them to be made readonly) */ struct biltins { char *bname; int (*bfunct)(); int minargs, maxargs; }; extern struct biltins bfunc[]; extern int nbfunc; struct srch { char *s_name; int s_value; }; extern struct srch srchn[]; extern int nsrchn; /* * To be able to redirect i/o for builtins easily, the shell moves the i/o * descriptors it uses away from 0,1,2. * Ideally these should be in units which are closed across exec's * (this saves work) but for version 6, this is not usually possible. * The desired initial values for these descriptors are defined in * sh.local.h. */ int SHIN; /* Current shell input (script) */ int SHOUT; /* Shell output */ int SHDIAG; /* Diagnostic output... shell errs go here */ int OLDSTD; /* Old standard input (def for cmds) */ /* * Error control * * Errors in scanning and parsing set up an error message to be printed * at the end and complete. Other errors always cause a reset. * Because of source commands and .cshrc we need nested error catches. */ jmp_buf reslab; #define setexit() ((void) setjmp(reslab)) #define reset() longjmp(reslab, 0) /* Should use structure assignment here */ #define getexit(a) memcpy((char *)(a), (char *)reslab, sizeof reslab) #define resexit(a) memcpy((char *)reslab, ((char *)(a)), sizeof reslab) char *gointr; /* Label for an onintr transfer */ void (*parintr)(int); /* Parents interrupt catch */ void (*parterm)(int); /* Parents terminate catch */ /* * Lexical definitions. * * All lexical space is allocated dynamically. * The eighth bit of characters is used to prevent recognition, * and eventually stripped. */ #define QUOTE 0200 /* Eighth char bit used internally for 'ing */ #define TRIM 0177 /* Mask to strip quote bit */ /* * Each level of input has a buffered input structure. * There are one or more blocks of buffered input for each level, * exactly one if the input is seekable and tell is available. * In other cases, the shell buffers enough blocks to keep all loops * in the buffer. */ struct Bin { off_t Bfseekp; /* Seek pointer */ off_t Bfbobp; /* Seekp of beginning of buffers */ off_t Bfeobp; /* Seekp of end of buffers */ int Bfblocks; /* Number of buffer blocks */ char **Bfbuf; /* The array of buffer blocks */ } B; #define fseekp B.Bfseekp #define fbobp B.Bfbobp #define feobp B.Bfeobp #define fblocks B.Bfblocks #define fbuf B.Bfbuf #define btell() fseekp #ifndef btell off_t btell(); #endif /* * The shell finds commands in loops by reseeking the input * For whiles, in particular, it reseeks to the beginning of the * line the while was on; hence the while placement restrictions. */ off_t lineloc; #ifdef TELL bool cantell; /* Is current source tellable ? */ #endif /* * Input lines are parsed into doubly linked circular * lists of words of the following form. */ struct wordent { char *word; struct wordent *prev; struct wordent *next; }; /* * During word building, both in the initial lexical phase and * when expanding $ variable substitutions, expansion by `!' and `$' * must be inhibited when reading ahead in routines which are themselves * processing `!' and `$' expansion or after characters such as `\' or in * quotations. The following flags are passed to the getC routines * telling them which of these substitutions are appropriate for the * next character to be returned. */ #define DODOL 1 #define DOEXCL 2 #define DOALL DODOL|DOEXCL /* * Labuf implements a general buffer for lookahead during lexical operations. * Text which is to be placed in the input stream can be stuck here. * We stick parsed ahead $ constructs during initial input, * process id's from `$$', and modified variable values (from qualifiers * during expansion in sh.dol.c) here. */ char labuf[BUFSIZ]; char *lap; /* * Parser structure * * Each command is parsed to a tree of command structures and * flags are set bottom up during this process, to be propagated down * as needed during the semantics/exeuction pass (sh.sem.c). */ struct command { int t_dtyp; /* Type of node */ int t_dflg; /* Flags, e.g. FAND|... */ union { char *T_dlef; /* Input redirect word */ struct command *T_dcar; /* Left part of list/pipe */ } L; union { char *T_drit; /* Output redirect word */ struct command *T_dcdr; /* Right part of list/pipe */ } R; #define t_dlef L.T_dlef #define t_dcar L.T_dcar #define t_drit R.T_drit #define t_dcdr R.T_dcdr char **t_dcom; /* Command/argument vector */ struct command *t_dspr; /* Pointer to ()'d subtree */ int t_nice; }; #define TCOM 1 /* t_dcom t_drit */ #define TPAR 2 /* ( t_dspr ) t_drit */ #define TFIL 3 /* t_dlef | t_drit */ #define TLST 4 /* t_dlef ; t_drit */ #define TOR 5 /* t_dlef || t_drit */ #define TAND 6 /* t_dlef && t_drit */ #define FSAVE (FNICE|FTIME|FNOHUP) /* save these when re-doing */ #define FAND (1<<0) /* executes in background */ #define FCAT (1<<1) /* output is redirected >> */ #define FPIN (1<<2) /* input is a pipe */ #define FPOU (1<<3) /* output is a pipe */ #define FPAR (1<<4) /* don't fork, last ()ized cmd */ #define FINT (1<<5) /* should be immune from intr's */ /* spare */ #define FDIAG (1<<7) /* redirect unit 2 with unit 1 */ #define FANY (1<<8) /* output was ! */ #define FHERE (1<<9) /* input redirection is << */ #define FREDO (1<<10) /* reexec aft if, repeat,... */ #define FNICE (1<<11) /* t_nice is meaningful */ #define FNOHUP (1<<12) /* nohup this command */ #define FTIME (1<<13) /* time this command */ /* * The keywords for the parser */ #define ZBREAK 0 #define ZBRKSW 1 #define ZCASE 2 #define ZDEFAULT 3 #define ZELSE 4 #define ZEND 5 #define ZENDIF 6 #define ZENDSW 7 #define ZEXIT 8 #define ZFOREACH 9 #define ZGOTO 10 #define ZIF 11 #define ZLABEL 12 #define ZLET 13 #define ZSET 14 #define ZSWITCH 15 #define ZTEST 16 #define ZTHEN 17 #define ZWHILE 18 /* * Structure defining the existing while/foreach loops at this * source level. Loops are implemented by seeking back in the * input. For foreach (fe), the word list is attached here. */ struct whyle { off_t w_start; /* Point to restart loop */ off_t w_end; /* End of loop (0 if unknown) */ char **w_fe, **w_fe0; /* Current/initial wordlist for fe */ char *w_fename; /* Name for fe */ struct whyle *w_next; /* Next (more outer) loop */ } *whyles; /* * Variable structure * * Aliases and variables are stored in AVL balanced binary trees. */ struct varent { char **vec; /* Array of words which is the value */ char *v_name; /* Name of variable/alias */ struct varent *v_link[3]; /* The links, see below */ int v_bal; /* Balance factor */ } shvhed, aliases; #define v_left v_link[0] #define v_right v_link[1] #define v_parent v_link[2] struct varent *adrof1(); #define adrof(v) adrof1(v, &shvhed) #define value(v) value1(v, &shvhed) /* * The following are for interfacing redo substitution in * aliases to the lexical routines. */ struct wordent *alhistp; /* Argument list (first) */ struct wordent *alhistt; /* Node after last in arg list */ char **alvec; /* The (remnants of) alias vector */ /* * Filename/command name expansion variables */ int gflag; /* After tglob -> is globbing needed? */ /* * A reasonable limit on number of arguments would seem to be * the maximum number of characters in an arg list / 6. */ #ifdef pdp11 #define GAVSIZ NCARGS / 12 #else #define GAVSIZ NCARGS / 6 #endif /* * Variables for filename expansion */ char **gargv; /* Pointer to the (stack) arglist */ int gargc; /* Number args in gargv */ int gnleft; /* * Variables for command expansion. */ char **pargv; /* Pointer to the argv list space */ char *pargs; /* Pointer to start current word */ int pargc; /* Count of arguments in pargv */ int pnleft; /* Number of chars left in pargs */ char *pargcp; /* Current index into pargs */ /* * History list * * Each history list entry contains an embedded wordlist * from the scanner, a number for the event, and a reference count * to aid in discarding old entries. * * Essentially "invisible" entries are put on the history list * when history substitution includes modifiers, and thrown away * at the next discarding since their event numbers are very negative. */ struct Hist { struct wordent Hlex; int Hnum; int Href; struct Hist *Hnext; } Histlist; struct wordent paraml; /* Current lexical word list */ int eventno; /* Next events number */ int lastev; /* Last event reference (default) */ char HIST; /* history invocation character */ char HISTSUB; /* auto-substitute character */ /* * In lines for frequently called functions */ #define XFREE(cp) { \ extern char end[]; \ char stack; \ if ((cp) >= end && (cp) < &stack) \ free(cp); \ } char *alloctmp; #define xalloc(i) ((alloctmp = malloc(i)) ? alloctmp : (char *)nomem(i)) char *Dfix1(); char **blkcat(); char **blkcpy(); char **blkend(); char **blkspl(); char *cname(); char **copyblk(); char **dobackp(); char *domod(); struct wordent *dosub(); char *exp3(); char *exp3a(); char *exp4(); char *exp5(); char *exp6(); struct Hist *enthist(); struct Hist *findev(); struct wordent *freenod(); char *getenv(); char *getinx(); struct varent *getvx(); struct passwd *getpwnam(); struct wordent *gethent(); struct wordent *getsub(); char *getwd(); char **glob(); char *globone(); char *index(); struct biltins *isbfunc(); off_t lseek(); char *operate(); void pchild(int); void pintr(int); int printf(const char *format, ...); char *putn(); char *rindex(); char **saveblk(); char *savestr(); char *strcat(); char *strcpy(); char *strend(); char *strings(); char *strip(); char *strspl(); char *subword(); struct command *syntax(); struct command *syn0(); struct command *syn1(); struct command *syn1a(); struct command *syn1b(); struct command *syn2(); struct command *syn3(); char *value1(); char *xhome(); char *xname(); char *xset(); #define NOSTR ((char *) 0) /* * setname is a macro to save space (see sh.err.c) */ char *bname; #define setname(a) (bname = (a)) #ifdef VFORK char *Vsav; char **Vav; char *Vdp; #endif char **evalvec; char *evalp; struct mesg { char *iname; /* name from /usr/include */ char *pname; /* print name */ }; extern struct mesg mesg[]; ================================================ FILE: bin/csh/sh.hist.c ================================================ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley Software License Agreement * specifies the terms and conditions for redistribution. */ #if !defined(lint) && defined(DOSCCS) static char *sccsid = "@(#)sh.hist.c 5.2 (Berkeley) 6/6/85"; #endif #include "sh.h" /* * C shell */ savehist(sp) struct wordent *sp; { register struct Hist *hp, *np; register int histlen = 0; char *cp; /* throw away null lines */ if (sp->next->word[0] == '\n') return; cp = value("history"); if (*cp) { register char *p = cp; while (*p) { if (!digit(*p)) { histlen = 0; break; } histlen = histlen * 10 + *p++ - '0'; } } for (hp = &Histlist; np = hp->Hnext;) if (eventno - np->Href >= histlen || histlen == 0) hp->Hnext = np->Hnext, hfree(np); else hp = np; (void) enthist(++eventno, sp, 1); } struct Hist * enthist(event, lp, docopy) int event; register struct wordent *lp; bool docopy; { register struct Hist *np; np = (struct Hist *) xalloc(sizeof *np); np->Hnum = np->Href = event; if (docopy) copylex(&np->Hlex, lp); else { np->Hlex.next = lp->next; lp->next->prev = &np->Hlex; np->Hlex.prev = lp->prev; lp->prev->next = &np->Hlex; } np->Hnext = Histlist.Hnext; Histlist.Hnext = np; return (np); } hfree(hp) register struct Hist *hp; { freelex(&hp->Hlex); xfree((char *)hp); } dohist(vp) char **vp; { int n, rflg = 0, hflg = 0; if (getn(value("history")) == 0) return; if (setintr) (void) sigsetmask(sigblock(0L) & ~sigmask(SIGINT)); while (*++vp && **vp == '-') { char *vp2 = *vp; while (*++vp2) switch (*vp2) { case 'h': hflg++; break; case 'r': rflg++; break; case '-': /* ignore multiple '-'s */ break; default: printf("Unknown flag: -%c\n", *vp2); error("Usage: history [-rh] [# number of events]"); } } if (*vp) n = getn(*vp); else { n = getn(value("history")); } dohist1(Histlist.Hnext, &n, rflg, hflg); } dohist1(hp, np, rflg, hflg) struct Hist *hp; int *np, rflg, hflg; { bool print = (*np) > 0; top: if (hp == 0) return; (*np)--; hp->Href++; if (rflg == 0) { dohist1(hp->Hnext, np, rflg, hflg); if (print) phist(hp, hflg); return; } if (*np >= 0) phist(hp, hflg); hp = hp->Hnext; goto top; } phist(hp, hflg) register struct Hist *hp; int hflg; { if (hflg == 0) printf("%6d\t", hp->Hnum); prlex(&hp->Hlex); } ================================================ FILE: bin/csh/sh.init.c ================================================ /* * C shell * * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley Software License Agreement * specifies the terms and conditions for redistribution. */ #include "sh.local.h" extern int doalias(); extern int dobg(); extern int dobreak(); extern int dochngd(); extern int docontin(); extern int dodirs(); extern int doecho(); extern int doelse(); extern int doend(); extern int doendif(); extern int doendsw(); extern int doeval(); extern int doexit(); extern int dofg(); extern int doforeach(); extern int doglob(); extern int dogoto(); extern int dohash(); extern int dohist(); extern int doif(); extern int dojobs(); extern int dokill(); extern int dolet(); #ifndef NOLIMITS extern int dolimit(); #endif extern int dologin(); extern int dologout(); #ifdef NEWGRP extern int donewgrp(); #endif extern int donice(); extern int donotify(); extern int donohup(); extern int doonintr(); extern int dopopd(); extern int dopushd(); extern int dorepeat(); extern int doset(); extern int dosetenv(); extern int dosource(); extern int dostop(); extern int dosuspend(); extern int doswbrk(); extern int doswitch(); extern int dotime(); #ifndef NOLIMITS extern int dounlimit(); #endif extern int doumask(); extern int dowait(); extern int dowhile(); extern int dowhich(); extern int dozip(); extern int execash(); extern int goodbye(); #ifdef VFORK extern int hashstat(); #endif extern int shift(); extern int showall(); extern int unalias(); extern int dounhash(); extern int unset(); extern int dounsetenv(); #define INF 1000 struct biltins { char *bname; int (*bfunct)(); short minargs, maxargs; } bfunc[] = { "@", dolet, 0, INF, "alias", doalias, 0, INF, "alloc", showall, 0, 1, "bg", dobg, 0, INF, "break", dobreak, 0, 0, "breaksw", doswbrk, 0, 0, #ifdef IIASA "bye", goodbye, 0, 0, #endif "case", dozip, 0, 1, "cd", dochngd, 0, 1, "chdir", dochngd, 0, 1, "continue", docontin, 0, 0, "default", dozip, 0, 0, "dirs", dodirs, 0, 1, "echo", doecho, 0, INF, "else", doelse, 0, INF, "end", doend, 0, 0, "endif", dozip, 0, 0, "endsw", dozip, 0, 0, "eval", doeval, 0, INF, "exec", execash, 1, INF, "exit", doexit, 0, INF, "fg", dofg, 0, INF, "foreach", doforeach, 3, INF, #ifdef IIASA "gd", dopushd, 0, 1, #endif "glob", doglob, 0, INF, "goto", dogoto, 1, 1, #ifdef VFORK "hashstat", hashstat, 0, 0, #endif "history", dohist, 0, 2, "if", doif, 1, INF, "jobs", dojobs, 0, 1, "kill", dokill, 1, INF, #ifndef NOLIMITS "limit", dolimit, 0, 3, #endif "login", dologin, 0, 1, "logout", dologout, 0, 0, #ifdef NEWGRP "newgrp", donewgrp, 1, 1, #endif "nice", donice, 0, INF, "nohup", donohup, 0, INF, "notify", donotify, 0, INF, "onintr", doonintr, 0, 2, "popd", dopopd, 0, 1, "pushd", dopushd, 0, 1, #ifdef IIASA "rd", dopopd, 0, 1, #endif "rehash", dohash, 0, 0, "repeat", dorepeat, 2, INF, "set", doset, 0, INF, "setenv", dosetenv, 0, 2, "shift", shift, 0, 1, "source", dosource, 1, 2, "stop", dostop, 1, INF, "suspend", dosuspend, 0, 0, "switch", doswitch, 1, INF, "time", dotime, 0, INF, "umask", doumask, 0, 1, "unalias", unalias, 1, INF, "unhash", dounhash, 0, 0, #ifndef NOLIMITS "unlimit", dounlimit, 0, INF, #endif "unset", unset, 1, INF, "unsetenv", dounsetenv, 1, INF, "wait", dowait, 0, 0, "which", dowhich, 1, INF, "while", dowhile, 1, INF, }; int nbfunc = sizeof bfunc / sizeof *bfunc; #define ZBREAK 0 #define ZBRKSW 1 #define ZCASE 2 #define ZDEFAULT 3 #define ZELSE 4 #define ZEND 5 #define ZENDIF 6 #define ZENDSW 7 #define ZEXIT 8 #define ZFOREACH 9 #define ZGOTO 10 #define ZIF 11 #define ZLABEL 12 #define ZLET 13 #define ZSET 14 #define ZSWITCH 15 #define ZTEST 16 #define ZTHEN 17 #define ZWHILE 18 struct srch { char *s_name; short s_value; } srchn[] = { "@", ZLET, "break", ZBREAK, "breaksw", ZBRKSW, "case", ZCASE, "default", ZDEFAULT, "else", ZELSE, "end", ZEND, "endif", ZENDIF, "endsw", ZENDSW, "exit", ZEXIT, "foreach", ZFOREACH, "goto", ZGOTO, "if", ZIF, "label", ZLABEL, "set", ZSET, "switch", ZSWITCH, "while", ZWHILE, }; int nsrchn = sizeof srchn / sizeof *srchn; struct mesg { char *iname; char *pname; } mesg[] = { 0, 0, "HUP", "Hangup", "INT", "Interrupt", "QUIT", "Quit", "ILL", "Illegal instruction", "TRAP", "Trace/BPT trap", "IOT", "IOT trap", "EMT", "EMT trap", "FPE", "Floating exception", "KILL", "Killed", "BUS", "Bus error", "SEGV", "Segmentation fault", "SYS", "Bad system call", "PIPE", "Broken pipe", "ALRM", "Alarm clock", "TERM", "Terminated", "URG", "Urgent I/O condition", "STOP", "Stopped (signal)", "TSTP", "Stopped", "CONT", "Continued", "CHLD", "Child exited", "TTIN", "Stopped (tty input)", "TTOU", "Stopped (tty output)", "IO", "I/O possible", "XCPU", "Cputime limit exceeded", "XFSZ", "Filesize limit exceeded", "VTALRM","Virtual timer expired", "PROF", "Profiling timer expired", "WINCH","Window size changed", 0, "Signal 29", "USR1", "User defined signal 1", "USR2", "User defined signal 2", 0, "Signal 32" }; ================================================ FILE: bin/csh/sh.lex.c ================================================ /* * C shell * * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley Software License Agreement * specifies the terms and conditions for redistribution. */ #include "sh.h" #include /* * These lexical routines read input and form lists of words. * There is some involved processing here, because of the complications * of input buffering, and especially because of history substitution. */ char *word(); /* * Peekc is a peek characer for getC, peekread for readc. * There is a subtlety here in many places... history routines * will read ahead and then insert stuff into the input stream. * If they push back a character then they must push it behind * the text substituted by the history substitution. On the other * hand in several places we need 2 peek characters. To make this * all work, the history routines read with getC, and make use both * of ungetC and unreadc. The key observation is that the state * of getC at the call of a history reference is such that calls * to getC from the history routines will always yield calls of * readc, unless this peeking is involved. That is to say that during * getexcl the variables lap, exclp, and exclnxt are all zero. * * Getdol invokes history substitution, hence the extra peek, peekd, * which it can ungetD to be before history substitutions. */ char peekc, peekd; char peekread; char *exclp; /* (Tail of) current word from ! subst */ struct wordent *exclnxt; /* The rest of the ! subst words */ int exclc; /* Count of remainig words in ! subst */ char *alvecp; /* "Globp" for alias resubstitution */ /* * Lex returns to its caller not only a wordlist (as a "var" parameter) * but also whether a history substitution occurred. This is used in * the main (process) routine to determine whether to echo, and also * when called by the alias routine to determine whether to keep the * argument list. */ bool hadhist; char getCtmp; #define getC(f) ((getCtmp = peekc) ? (peekc = 0, getCtmp) : getC1(f)) #define ungetC(c) peekc = c #define ungetD(c) peekd = c lex(hp) register struct wordent *hp; { register struct wordent *wdp; int c; lineloc = btell(); hp->next = hp->prev = hp; hp->word = ""; alvecp = 0, hadhist = 0; do c = readc(0); while (c == ' ' || c == '\t'); if (c == HISTSUB && intty) /* ^lef^rit from tty is short !:s^lef^rit */ getexcl(c); else unreadc(c); wdp = hp; /* * The following loop is written so that the links needed * by freelex will be ready and rarin to go even if it is * interrupted. */ do { register struct wordent *new = (struct wordent *) xalloc(sizeof *wdp); new->word = 0; new->prev = wdp; new->next = hp; wdp->next = new; wdp = new; wdp->word = word(); } while (wdp->word[0] != '\n'); hp->prev = wdp; return (hadhist); } prlex(sp0) struct wordent *sp0; { register struct wordent *sp = sp0->next; for (;;) { printf("%s", sp->word); sp = sp->next; if (sp == sp0) break; if (sp->word[0] != '\n') putchar(' '); } } copylex(hp, fp) register struct wordent *hp; register struct wordent *fp; { register struct wordent *wdp; wdp = hp; fp = fp->next; do { register struct wordent *new = (struct wordent *) xalloc(sizeof *wdp); new->prev = wdp; new->next = hp; wdp->next = new; wdp = new; wdp->word = savestr(fp->word); fp = fp->next; } while (wdp->word[0] != '\n'); hp->prev = wdp; } freelex(vp) register struct wordent *vp; { register struct wordent *fp; while (vp->next != vp) { fp = vp->next; vp->next = fp->next; XFREE(fp->word) XFREE((char *)fp) } vp->prev = vp; } char * word() { register char c, c1; register char *wp; char wbuf[BUFSIZ]; register bool dolflg; register int i; wp = wbuf; i = BUFSIZ - 4; loop: while ((c = getC(DOALL)) == ' ' || c == '\t') ; if (cmap(c, _META|_ESC)) switch (c) { case '&': case '|': case '<': case '>': *wp++ = c; c1 = getC(DOALL); if (c1 == c) *wp++ = c1; else ungetC(c1); goto ret; case '#': if (intty) break; c = 0; do { c1 = c; c = getC(0); } while (c != '\n'); if (c1 == '\\') goto loop; /* fall into ... */ case ';': case '(': case ')': case '\n': *wp++ = c; goto ret; case '\\': c = getC(0); if (c == '\n') { if (onelflg == 1) onelflg = 2; goto loop; } if (c != HIST) *wp++ = '\\', --i; c |= QUOTE; } c1 = 0; dolflg = DOALL; for (;;) { if (c1) { if (c == c1) { c1 = 0; dolflg = DOALL; } else if (c == '\\') { c = getC(0); if (c == HIST) c |= QUOTE; else { if (c == '\n') /* if (c1 == '`') c = ' '; else */ c |= QUOTE; ungetC(c); c = '\\'; } } else if (c == '\n') { seterrc("Unmatched ", c1); ungetC(c); break; } } else if (cmap(c, _META|_Q|_Q1|_ESC)) { if (c == '\\') { c = getC(0); if (c == '\n') { if (onelflg == 1) onelflg = 2; break; } if (c != HIST) *wp++ = '\\', --i; c |= QUOTE; } else if (cmap(c, _Q|_Q1)) { /* '"` */ c1 = c; dolflg = c == '"' ? DOALL : DOEXCL; } else if (c != '#' || !intty) { ungetC(c); break; } } if (--i > 0) { *wp++ = c; c = getC(dolflg); } else { seterr("Word too long"); wp = &wbuf[1]; break; } } ret: *wp = 0; return (savestr(wbuf)); } getC1(flag) register int flag; { register char c; top: if (c = peekc) { peekc = 0; return (c); } if (lap) { if ((c = *lap++) == 0) lap = 0; else { if (cmap(c, _META|_Q|_Q1)) c |= QUOTE; return (c); } } if (c = peekd) { peekd = 0; return (c); } if (exclp) { if (c = *exclp++) return (c); if (exclnxt && --exclc >= 0) { exclnxt = exclnxt->next; setexclp(exclnxt->word); return (' '); } exclp = 0; exclnxt = 0; } if (exclnxt) { exclnxt = exclnxt->next; if (--exclc < 0) exclnxt = 0; else setexclp(exclnxt->word); goto top; } c = readc(0); if (c == '$' && (flag & DODOL)) { getdol(); goto top; } if (c == HIST && (flag & DOEXCL)) { getexcl(0); goto top; } return (c); } getdol() { register char *np; char name[40]; register int c; int sc; bool special = 0; np = name, *np++ = '$'; c = sc = getC(DOEXCL); if (any(c, "\t \n")) { ungetD(c); ungetC('$' | QUOTE); return; } if (c == '{') *np++ = c, c = getC(DOEXCL); if (c == '#' || c == '?') special++, *np++ = c, c = getC(DOEXCL); *np++ = c; switch (c) { case '<': case '$': if (special) goto vsyn; goto ret; case '\n': ungetD(c); np--; goto vsyn; case '*': if (special) goto vsyn; goto ret; default: if (digit(c)) { /* * let $?0 pass for now if (special) goto vsyn; */ while (digit(c = getC(DOEXCL))) { if (np < &name[sizeof name / 2]) *np++ = c; } } else if (letter(c)) while (letter(c = getC(DOEXCL))) { if (np < &name[sizeof name / 2]) *np++ = c; } else goto vsyn; } if (c == '[') { *np++ = c; do { c = getC(DOEXCL); if (c == '\n') { ungetD(c); np--; goto vsyn; } if (np >= &name[sizeof name - 8]) goto vsyn; *np++ = c; } while (c != ']'); c = getC(DOEXCL); } if (c == ':') { *np++ = c, c = getC(DOEXCL); if (c == 'g') *np++ = c, c = getC(DOEXCL); *np++ = c; if (!any(c, "htrqxe")) goto vsyn; } else ungetD(c); if (sc == '{') { c = getC(DOEXCL); if (c != '}') { ungetC(c); goto vsyn; } *np++ = c; } ret: *np = 0; addla(name); return; vsyn: seterr("Variable syntax"); goto ret; } addla(cp) char *cp; { char buf[BUFSIZ]; if (lap != 0 && strlen(cp) + strlen(lap) >= sizeof (labuf) - 4) { seterr("Expansion buf ovflo"); return; } if (lap) (void) strcpy(buf, lap); (void) strcpy(labuf, cp); if (lap) (void) strcat(labuf, buf); lap = labuf; } char lhsb[32]; char slhs[32]; char rhsb[64]; int quesarg; getexcl(sc) char sc; { register struct wordent *hp, *ip; int left, right, dol; register int c; if (sc == 0) { sc = getC(0); if (sc != '{') { ungetC(sc); sc = 0; } } quesarg = -1; lastev = eventno; hp = gethent(sc); if (hp == 0) return; hadhist = 1; dol = 0; if (hp == alhistp) for (ip = hp->next->next; ip != alhistt; ip = ip->next) dol++; else for (ip = hp->next->next; ip != hp->prev; ip = ip->next) dol++; left = 0, right = dol; if (sc == HISTSUB) { ungetC('s'), unreadc(HISTSUB), c = ':'; goto subst; } c = getC(0); if (!any(c, ":^$*-%")) goto subst; left = right = -1; if (c == ':') { c = getC(0); unreadc(c); if (letter(c) || c == '&') { c = ':'; left = 0, right = dol; goto subst; } } else ungetC(c); if (!getsel(&left, &right, dol)) return; c = getC(0); if (c == '*') ungetC(c), c = '-'; if (c == '-') { if (!getsel(&left, &right, dol)) return; c = getC(0); } subst: exclc = right - left + 1; while (--left >= 0) hp = hp->next; if (sc == HISTSUB || c == ':') { do { hp = getsub(hp); c = getC(0); } while (c == ':'); } unreadc(c); if (sc == '{') { c = getC(0); if (c != '}') seterr("Bad ! form"); } exclnxt = hp; } struct wordent * getsub(en) struct wordent *en; { register char *cp; int delim; register int c; int sc; bool global = 0; char orhsb[sizeof rhsb]; exclnxt = 0; sc = c = getC(0); if (c == 'g') global++, c = getC(0); switch (c) { case 'p': justpr++; goto ret; case 'x': case 'q': global++; /* fall into ... */ case 'h': case 'r': case 't': case 'e': break; case '&': if (slhs[0] == 0) { seterr("No prev sub"); goto ret; } (void) strcpy(lhsb, slhs); break; /* case '~': if (lhsb[0] == 0) goto badlhs; break; */ case 's': delim = getC(0); if (letter(delim) || digit(delim) || any(delim, " \t\n")) { unreadc(delim); bads: lhsb[0] = 0; seterr("Bad substitute"); goto ret; } cp = lhsb; for (;;) { c = getC(0); if (c == '\n') { unreadc(c); break; } if (c == delim) break; if (cp > &lhsb[sizeof lhsb - 2]) goto bads; if (c == '\\') { c = getC(0); if (c != delim && c != '\\') *cp++ = '\\'; } *cp++ = c; } if (cp != lhsb) *cp++ = 0; else if (lhsb[0] == 0) { /*badlhs:*/ seterr("No prev lhs"); goto ret; } cp = rhsb; (void) strcpy(orhsb, cp); for (;;) { c = getC(0); if (c == '\n') { unreadc(c); break; } if (c == delim) break; /* if (c == '~') { if (&cp[strlen(orhsb)] > &rhsb[sizeof rhsb - 2]) goto toorhs; (void) strcpy(cp, orhsb); cp = strend(cp); continue; } */ if (cp > &rhsb[sizeof rhsb - 2]) { /*toorhs:*/ seterr("Rhs too long"); goto ret; } if (c == '\\') { c = getC(0); if (c != delim /* && c != '~' */) *cp++ = '\\'; } *cp++ = c; } *cp++ = 0; break; default: if (c == '\n') unreadc(c); seterrc("Bad ! modifier: ", c); goto ret; } (void) strcpy(slhs, lhsb); if (exclc) en = dosub(sc, en, global); ret: return (en); } struct wordent * dosub(sc, en, global) int sc; struct wordent *en; bool global; { struct wordent lex; bool didsub = 0; struct wordent *hp = &lex; register struct wordent *wdp; register int i = exclc; wdp = hp; while (--i >= 0) { register struct wordent *new = (struct wordent *) calloc(1, sizeof *wdp); new->prev = wdp; new->next = hp; wdp->next = new; wdp = new; en = en->next; wdp->word = global || didsub == 0 ? subword(en->word, sc, &didsub) : savestr(en->word); } if (didsub == 0) seterr("Modifier failed"); hp->prev = wdp; return (&enthist(-1000, &lex, 0)->Hlex); } char * subword(cp, type, adid) char *cp; int type; bool *adid; { char wbuf[BUFSIZ]; register char *wp, *mp, *np; register int i; switch (type) { case 'r': case 'e': case 'h': case 't': case 'q': case 'x': wp = domod(cp, type); if (wp == 0) return (savestr(cp)); *adid = 1; return (wp); default: wp = wbuf; i = BUFSIZ - 4; for (mp = cp; *mp; mp++) if (matchs(mp, lhsb)) { for (np = cp; np < mp;) *wp++ = *np++, --i; for (np = rhsb; *np; np++) switch (*np) { case '\\': if (np[1] == '&') np++; /* fall into ... */ default: if (--i < 0) goto ovflo; *wp++ = *np; continue; case '&': i -= strlen(lhsb); if (i < 0) goto ovflo; *wp = 0; (void) strcat(wp, lhsb); wp = strend(wp); continue; } mp += strlen(lhsb); i -= strlen(mp); if (i < 0) { ovflo: seterr("Subst buf ovflo"); return (""); } *wp = 0; (void) strcat(wp, mp); *adid = 1; return (savestr(wbuf)); } return (savestr(cp)); } } char * domod(cp, type) char *cp; int type; { register char *wp, *xp; register int c; switch (type) { case 'x': case 'q': wp = savestr(cp); for (xp = wp; c = *xp; xp++) if ((c != ' ' && c != '\t') || type == 'q') *xp |= QUOTE; return (wp); case 'h': case 't': if (!any('/', cp)) return (type == 't' ? savestr(cp) : 0); wp = strend(cp); while (*--wp != '/') continue; if (type == 'h') xp = savestr(cp), xp[wp - cp] = 0; else xp = savestr(wp + 1); return (xp); case 'e': case 'r': wp = strend(cp); for (wp--; wp >= cp && *wp != '/'; wp--) if (*wp == '.') { if (type == 'e') xp = savestr(wp + 1); else xp = savestr(cp), xp[wp - cp] = 0; return (xp); } return (savestr(type == 'e' ? "" : cp)); } return (0); } matchs(str, pat) register char *str, *pat; { while (*str && *pat && *str == *pat) str++, pat++; return (*pat == 0); } getsel(al, ar, dol) register int *al, *ar; int dol; { register int c = getC(0); register int i; bool first = *al < 0; switch (c) { case '%': if (quesarg == -1) goto bad; if (*al < 0) *al = quesarg; *ar = quesarg; break; case '-': if (*al < 0) { *al = 0; *ar = dol - 1; unreadc(c); } return (1); case '^': if (*al < 0) *al = 1; *ar = 1; break; case '$': if (*al < 0) *al = dol; *ar = dol; break; case '*': if (*al < 0) *al = 1; *ar = dol; if (*ar < *al) { *ar = 0; *al = 1; return (1); } break; default: if (digit(c)) { i = 0; while (digit(c)) { i = i * 10 + c - '0'; c = getC(0); } if (i < 0) i = dol + 1; if (*al < 0) *al = i; *ar = i; } else if (*al < 0) *al = 0, *ar = dol; else *ar = dol - 1; unreadc(c); break; } if (first) { c = getC(0); unreadc(c); if (any(c, "-$*")) return (1); } if (*al > *ar || *ar > dol) { bad: seterr("Bad ! arg selector"); return (0); } return (1); } struct wordent * gethent(sc) int sc; { register struct Hist *hp; register char *np; register int c; int event; bool back = 0; c = sc == HISTSUB ? HIST : getC(0); if (c == HIST) { if (alhistp) return (alhistp); event = eventno; goto skip; } switch (c) { case ':': case '^': case '$': case '*': case '%': ungetC(c); if (lastev == eventno && alhistp) return (alhistp); event = lastev; break; case '-': back = 1; c = getC(0); goto number; case '#': /* !# is command being typed in (mrh) */ return(¶ml); default: if (any(c, "(=~")) { unreadc(c); ungetC(HIST); return (0); } if (digit(c)) goto number; np = lhsb; while (!any(c, ": \t\\\n}")) { if (np < &lhsb[sizeof lhsb - 2]) *np++ = c; c = getC(0); } unreadc(c); if (np == lhsb) { ungetC(HIST); return (0); } *np++ = 0; hp = findev(lhsb, 0); if (hp) lastev = hp->Hnum; return (&hp->Hlex); case '?': np = lhsb; for (;;) { c = getC(0); if (c == '\n') { unreadc(c); break; } if (c == '?') break; if (np < &lhsb[sizeof lhsb - 2]) *np++ = c; } if (np == lhsb) { if (lhsb[0] == 0) { seterr("No prev search"); return (0); } } else *np++ = 0; hp = findev(lhsb, 1); if (hp) lastev = hp->Hnum; return (&hp->Hlex); number: event = 0; while (digit(c)) { event = event * 10 + c - '0'; c = getC(0); } if (back) event = eventno + (alhistp == 0) - (event ? event : 0); unreadc(c); break; } skip: for (hp = Histlist.Hnext; hp; hp = hp->Hnext) if (hp->Hnum == event) { hp->Href = eventno; lastev = hp->Hnum; return (&hp->Hlex); } np = putn(event); noev(np); return (0); } struct Hist * findev(cp, anyarg) char *cp; bool anyarg; { register struct Hist *hp; for (hp = Histlist.Hnext; hp; hp = hp->Hnext) { char *dp; register char *p, *q; register struct wordent *lp = hp->Hlex.next; int argno = 0; if (lp->word[0] == '\n') continue; if (!anyarg) { p = cp; q = lp->word; do if (!*p) return (hp); while (*p++ == *q++); continue; } do { for (dp = lp->word; *dp; dp++) { p = cp; q = dp; do if (!*p) { quesarg = argno; return (hp); } while (*p++ == *q++); } lp = lp->next; argno++; } while (lp->word[0] != '\n'); } noev(cp); return (0); } noev(cp) char *cp; { seterr2(cp, ": Event not found"); } setexclp(cp) register char *cp; { if (cp && cp[0] == '\n') return; exclp = cp; } unreadc(c) char c; { peekread = c; } readc(wanteof) bool wanteof; { register int c; static sincereal; if (c = peekread) { peekread = 0; return (c); } top: if (alvecp) { if (c = *alvecp++) return (c); if (*alvec) { alvecp = *alvec++; return (' '); } } if (alvec) { if (alvecp = *alvec) { alvec++; goto top; } /* Infinite source! */ return ('\n'); } if (evalp) { if (c = *evalp++) return (c); if (*evalvec) { evalp = *evalvec++; return (' '); } evalp = 0; } if (evalvec) { if (evalvec == (char **)1) { doneinp = 1; reset(); } if (evalp = *evalvec) { evalvec++; goto top; } evalvec = (char **)1; return ('\n'); } do { if (arginp == (char *) 1 || onelflg == 1) { if (wanteof) return (-1); exitstat(); } if (arginp) { if ((c = *arginp++) == 0) { arginp = (char *) 1; return ('\n'); } return (c); } reread: c = bgetc(); if (c < 0) { struct sgttyb tty; if (wanteof) return (-1); /* was isatty but raw with ignoreeof yields problems */ if (ioctl(SHIN, TIOCGETP, (char *)&tty) == 0 && (tty.sg_flags & RAW) == 0) { /* was 'short' for FILEC */ int ctpgrp; if (++sincereal > 25) goto oops; if (tpgrp != -1 && ioctl(FSHTTY, TIOCGPGRP, (char *)&ctpgrp) == 0 && tpgrp != ctpgrp) { (void) ioctl(FSHTTY, TIOCSPGRP, (char *)&tpgrp); (void) killpg(ctpgrp, SIGHUP); printf("Reset tty pgrp from %d to %d\n", ctpgrp, tpgrp); goto reread; } if (adrof("ignoreeof")) { if (loginsh) printf("\nUse \"logout\" to logout.\n"); else printf("\nUse \"exit\" to leave csh.\n"); reset(); } if (chkstop == 0) panystop(1); } oops: doneinp = 1; reset(); } sincereal = 0; if (c == '\n' && onelflg) onelflg--; } while (c == 0); return (c); } bgetc() { register int buf, off, c; #ifdef FILEC char ttyline[BUFSIZ]; register int numleft = 0, roomleft; #endif #ifdef TELL if (cantell) { if (fseekp < fbobp || fseekp > feobp) { fbobp = feobp = fseekp; (void) lseek(SHIN, fseekp, 0); } if (fseekp == feobp) { fbobp = feobp; do c = read(SHIN, fbuf[0], BUFSIZ); while (c < 0 && errno == EINTR); if (c <= 0) return (-1); feobp += c; } c = fbuf[0][fseekp - fbobp]; fseekp++; return (c & 0377); } #endif again: buf = (int) fseekp / BUFSIZ; if (buf >= fblocks) { register char **nfbuf = (char **) calloc((unsigned) (fblocks + 2), sizeof (char **)); if (fbuf) { (void) blkcpy(nfbuf, fbuf); xfree((char *)fbuf); } fbuf = nfbuf; fbuf[fblocks] = calloc(BUFSIZ, sizeof (char)); fblocks++; goto again; } if (fseekp >= feobp) { buf = (int) feobp / BUFSIZ; off = (int) feobp % BUFSIZ; #ifndef FILEC for (;;) { c = read(SHIN, fbuf[buf] + off, BUFSIZ - off); #else roomleft = BUFSIZ - off; for (;;) { if (filec && intty) { c = numleft ? numleft : tenex(ttyline, BUFSIZ); if (c > roomleft) { /* start with fresh buffer */ feobp = fseekp = fblocks * BUFSIZ; numleft = c; goto again; } if (c > 0) memcpy(fbuf[buf] + off, ttyline, c); numleft = 0; } else c = read(SHIN, fbuf[buf] + off, roomleft); #endif if (c >= 0) break; if (errno == EWOULDBLOCK) { int off = 0; (void) ioctl(SHIN, FIONBIO, (char *)&off); } else if (errno != EINTR) break; } if (c <= 0) return (-1); feobp += c; #ifndef FILEC goto again; #else if (filec && !intty) goto again; #endif } c = fbuf[buf][(int) fseekp % BUFSIZ]; fseekp++; return (c & 0377); } bfree() { register int sb, i; #ifdef TELL if (cantell) return; #endif if (whyles) return; sb = (int) (fseekp - 1) / BUFSIZ; if (sb > 0) { for (i = 0; i < sb; i++) xfree(fbuf[i]); (void) blkcpy(fbuf, &fbuf[sb]); fseekp -= BUFSIZ * sb; feobp -= BUFSIZ * sb; fblocks -= sb; } } bseek(l) off_t l; { register struct whyle *wp; fseekp = l; #ifdef TELL if (!cantell) { #endif if (!whyles) return; for (wp = whyles; wp->w_next; wp = wp->w_next) continue; if (wp->w_start > l) l = wp->w_start; #ifdef TELL } #endif } /* any similarity to bell telephone is purely accidental */ #ifndef btell off_t btell() { return (fseekp); } #endif btoeof() { (void) lseek(SHIN, (off_t)0, 2); fseekp = feobp; wfree(); bfree(); } #ifdef TELL settell() { cantell = 0; if (arginp || onelflg || intty) return; if (lseek(SHIN, (off_t)0, 1) < 0 || errno == ESPIPE) return; fbuf = (char **) calloc(2, sizeof (char **)); fblocks = 1; fbuf[0] = calloc(BUFSIZ, sizeof (char)); fseekp = fbobp = feobp = lseek(SHIN, (off_t)0, 1); cantell = 1; } #endif ================================================ FILE: bin/csh/sh.local.h ================================================ /* * This file defines certain local parameters * A symbol should be defined in Makefile for local conditional * compilation, e.g. IIASA or ERNIE, to be tested here and elsewhere. * * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley Software License Agreement * specifies the terms and conditions for redistribution. */ /* * Fundamental definitions which may vary from system to system. * * BUFSIZ The i/o buffering size; also limits word size * SHELLPATH Where the shell will live; initalizes $shell * MAILINTVL How often to mailcheck; more often is more expensive * OTHERSH Shell for scripts which don't start with # */ #define BUFSIZ 1024 /* default buffer size */ #define SHELLPATH "/bin/csh" #define OTHERSH "/bin/sh" #define FORKSLEEP 10 /* delay loop on non-interactive fork failure */ #define MAILINTVL 600 /* 10 minutes */ /* * The shell moves std in/out/diag and the old std input away from units * 0, 1, and 2 so that it is easy to set up these standards for invoked * commands. */ #define FSHTTY 15 /* /dev/tty when manip pgrps */ #define FSHIN 16 /* Preferred desc for shell input */ #define FSHOUT 17 /* ... shell output */ #define FSHDIAG 18 /* ... shell diagnostics */ #define FOLDSTD 19 /* ... old std input */ #ifdef PROF #define exit(n) done(n) #endif ================================================ FILE: bin/csh/sh.misc.c ================================================ /* * C Shell * * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley Software License Agreement * specifies the terms and conditions for redistribution. */ #include "sh.h" any(c, s) register int c; register char *s; { while (*s) if (*s++ == c) return(1); return(0); } onlyread(cp) char *cp; { extern char end[]; return (cp < end); } xfree(cp) char *cp; { extern char end[]; if (cp >= end && cp < (char *) &cp) free(cp); } char * savestr(s) register char *s; { char *n; register char *p; if (s == 0) s = ""; for (p = s; *p++;) ; n = p = xalloc((unsigned) (p - s)); while (*p++ = *s++) ; return (n); } #if 0 char * calloc(i, j) register unsigned i; unsigned j; { char *cp; i *= j; cp = xalloc(i); bzero(cp, (int)i); return (cp); } #endif nomem(i) unsigned i; { #ifdef debug static char *av[2] = {0, 0}; #endif child++; #ifndef debug error("Out of memory"); #ifdef lint i = i; #endif #else showall(av); printf("i=%d: Out of memory\n", i); chdir("/tmp"); abort(); #endif return 0; /* fool lint */ } char ** blkend(up) register char **up; { while (*up) up++; return (up); } blkpr(av) register char **av; { for (; *av; av++) { printf("%s", *av); if (av[1]) printf(" "); } } blklen(av) register char **av; { register int i = 0; while (*av++) i++; return (i); } char ** blkcpy(oav, bv) char **oav; register char **bv; { register char **av = oav; while (*av++ = *bv++) continue; return (oav); } char ** blkcat(up, vp) char **up, **vp; { (void) blkcpy(blkend(up), vp); return (up); } blkfree(av0) char **av0; { register char **av = av0; for (; *av; av++) XFREE(*av) XFREE((char *)av0) } char ** saveblk(v) register char **v; { register char **newv = (char **) calloc((unsigned) (blklen(v) + 1), sizeof (char **)); char **onewv = newv; while (*v) *newv++ = savestr(*v++); return (onewv); } char * strspl(cp, dp) char *cp, *dp; { char *ep; register char *p, *q; for (p = cp; *p++;) ; for (q = dp; *q++;) ; ep = xalloc((unsigned) ((p - cp) + (q - dp) - 1)); for (p = ep, q = cp; *p++ = *q++;) ; for (p--, q = dp; *p++ = *q++;) ; return (ep); } char ** blkspl(up, vp) register char **up, **vp; { register char **wp = (char **) calloc((unsigned) (blklen(up) + blklen(vp) + 1), sizeof (char **)); (void) blkcpy(wp, up); return (blkcat(wp, vp)); } lastchr(cp) register char *cp; { if (!*cp) return (0); while (cp[1]) cp++; return (*cp); } /* * This routine is called after an error to close up * any units which may have been left open accidentally. */ closem() { register int f; for (f = 0; f < NOFILE; f++) if (f != SHIN && f != SHOUT && f != SHDIAG && f != OLDSTD && f != FSHTTY) (void) close(f); } donefds() { (void) close(0); (void) close(1); (void) close(2); didfds = 0; } /* * Move descriptor i to j. * If j is -1 then we just want to get i to a safe place, * i.e. to a unit > 2. This also happens in dcopy. */ dmove(i, j) register int i, j; { if (i == j || i < 0) return (i); if (j >= 0) { (void) dup2(i, j); return (j); } j = dcopy(i, j); if (j != i) (void) close(i); return (j); } dcopy(i, j) register int i, j; { if (i == j || i < 0 || j < 0 && i > 2) return (i); if (j >= 0) { (void) dup2(i, j); return (j); } (void) close(j); return (renum(i, j)); } renum(i, j) register int i, j; { register int k = dup(i); if (k < 0) return (-1); if (j == -1 && k > 2) return (k); if (k != j) { j = renum(k, j); (void) close(k); return (j); } return (k); } #ifndef copy copy(to, from, size) register char *to, *from; register int size; { if (size) do *to++ = *from++; while (--size != 0); } #endif /* * Left shift a command argument list, discarding * the first c arguments. Used in "shift" commands * as well as by commands like "repeat". */ lshift(v, c) register char **v; register int c; { register char **u = v; while (*u && --c >= 0) xfree(*u++); (void) blkcpy(v, u); } number(cp) char *cp; { if (*cp == '-') { cp++; if (!digit(*cp++)) return (0); } while (*cp && digit(*cp)) cp++; return (*cp == 0); } char ** copyblk(v) register char **v; { register char **nv = (char **) calloc((unsigned) (blklen(v) + 1), sizeof (char **)); return (blkcpy(nv, v)); } char * strend(cp) register char *cp; { while (*cp) cp++; return (cp); } char * strip(cp) char *cp; { register char *dp = cp; while (*dp++ &= TRIM) continue; return (cp); } udvar(name) char *name; { setname(name); bferr("Undefined variable"); } prefix(sub, str) register char *sub, *str; { for (;;) { if (*sub == 0) return (1); if (*str == 0) return (0); if (*sub++ != *str++) return (0); } } ================================================ FILE: bin/csh/sh.parse.c ================================================ /* * C shell * * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley Software License Agreement * specifies the terms and conditions for redistribution. */ #include "sh.h" /* * Perform aliasing on the word list lex * Do a (very rudimentary) parse to separate into commands. * If word 0 of a command has an alias, do it. * Repeat a maximum of 20 times. */ alias(lex) register struct wordent *lex; { int aleft = 21; jmp_buf osetexit; getexit(osetexit); setexit(); if (haderr) { resexit(osetexit); reset(); } if (--aleft == 0) error("Alias loop"); asyntax(lex->next, lex); resexit(osetexit); } asyntax(p1, p2) register struct wordent *p1, *p2; { while (p1 != p2) if (any(p1->word[0], ";&\n")) p1 = p1->next; else { asyn0(p1, p2); return; } } asyn0(p1, p2) struct wordent *p1; register struct wordent *p2; { register struct wordent *p; register int l = 0; for (p = p1; p != p2; p = p->next) switch (p->word[0]) { case '(': l++; continue; case ')': l--; if (l < 0) error("Too many )'s"); continue; case '>': if (p->next != p2 && eq(p->next->word, "&")) p = p->next; continue; case '&': case '|': case ';': case '\n': if (l != 0) continue; asyn3(p1, p); asyntax(p->next, p2); return; } if (l == 0) asyn3(p1, p2); } asyn3(p1, p2) struct wordent *p1; register struct wordent *p2; { register struct varent *ap; struct wordent alout; register bool redid; if (p1 == p2) return; if (p1->word[0] == '(') { for (p2 = p2->prev; p2->word[0] != ')'; p2 = p2->prev) if (p2 == p1) return; if (p2 == p1->next) return; asyn0(p1->next, p2); return; } ap = adrof1(p1->word, &aliases); if (ap == 0) return; alhistp = p1->prev; alhistt = p2; alvec = ap->vec; redid = lex(&alout); alhistp = alhistt = 0; alvec = 0; if (parserr) { freelex(&alout); error(parserr); } if (p1->word[0] && eq(p1->word, alout.next->word)) { char *cp = alout.next->word; alout.next->word = strspl("\200", cp); XFREE(cp) } p1 = freenod(p1, redid ? p2 : p1->next); if (alout.next != &alout) { p1->next->prev = alout.prev->prev; alout.prev->prev->next = p1->next; alout.next->prev = p1; p1->next = alout.next; XFREE(alout.prev->word) XFREE((char *)alout.prev) } reset(); /* throw! */ } struct wordent * freenod(p1, p2) register struct wordent *p1, *p2; { register struct wordent *retp = p1->prev; while (p1 != p2) { XFREE(p1->word) p1 = p1->next; XFREE((char *)p1->prev) } retp->next = p2; p2->prev = retp; return (retp); } #define PHERE 1 #define PIN 2 #define POUT 4 #define PDIAG 8 /* * syntax * empty * syn0 */ struct command * syntax(p1, p2, flags) register struct wordent *p1, *p2; int flags; { while (p1 != p2) if (any(p1->word[0], ";&\n")) p1 = p1->next; else return (syn0(p1, p2, flags)); return (0); } /* * syn0 * syn1 * syn1 & syntax */ struct command * syn0(p1, p2, flags) struct wordent *p1, *p2; int flags; { register struct wordent *p; register struct command *t, *t1; int l; l = 0; for (p = p1; p != p2; p = p->next) switch (p->word[0]) { case '(': l++; continue; case ')': l--; if (l < 0) seterr("Too many )'s"); continue; case '|': if (p->word[1] == '|') continue; /* fall into ... */ case '>': if (p->next != p2 && eq(p->next->word, "&")) p = p->next; continue; case '&': if (l != 0) break; if (p->word[1] == '&') continue; t1 = syn1(p1, p, flags); if (t1->t_dtyp == TLST || t1->t_dtyp == TAND || t1->t_dtyp == TOR) { t = (struct command *) calloc(1, sizeof (*t)); t->t_dtyp = TPAR; t->t_dflg = FAND|FINT; t->t_dspr = t1; t1 = t; } else t1->t_dflg |= FAND|FINT; t = (struct command *) calloc(1, sizeof (*t)); t->t_dtyp = TLST; t->t_dflg = 0; t->t_dcar = t1; t->t_dcdr = syntax(p, p2, flags); return(t); } if (l == 0) return (syn1(p1, p2, flags)); seterr("Too many ('s"); return (0); } /* * syn1 * syn1a * syn1a ; syntax */ struct command * syn1(p1, p2, flags) struct wordent *p1, *p2; int flags; { register struct wordent *p; register struct command *t; int l; l = 0; for (p = p1; p != p2; p = p->next) switch (p->word[0]) { case '(': l++; continue; case ')': l--; continue; case ';': case '\n': if (l != 0) break; t = (struct command *) calloc(1, sizeof (*t)); t->t_dtyp = TLST; t->t_dcar = syn1a(p1, p, flags); t->t_dcdr = syntax(p->next, p2, flags); if (t->t_dcdr == 0) t->t_dcdr = t->t_dcar, t->t_dcar = 0; return (t); } return (syn1a(p1, p2, flags)); } /* * syn1a * syn1b * syn1b || syn1a */ struct command * syn1a(p1, p2, flags) struct wordent *p1, *p2; int flags; { register struct wordent *p; register struct command *t; register int l = 0; for (p = p1; p != p2; p = p->next) switch (p->word[0]) { case '(': l++; continue; case ')': l--; continue; case '|': if (p->word[1] != '|') continue; if (l == 0) { t = (struct command *) calloc(1, sizeof (*t)); t->t_dtyp = TOR; t->t_dcar = syn1b(p1, p, flags); t->t_dcdr = syn1a(p->next, p2, flags); t->t_dflg = 0; return (t); } continue; } return (syn1b(p1, p2, flags)); } /* * syn1b * syn2 * syn2 && syn1b */ struct command * syn1b(p1, p2, flags) struct wordent *p1, *p2; int flags; { register struct wordent *p; register struct command *t; register int l = 0; l = 0; for (p = p1; p != p2; p = p->next) switch (p->word[0]) { case '(': l++; continue; case ')': l--; continue; case '&': if (p->word[1] == '&' && l == 0) { t = (struct command *) calloc(1, sizeof (*t)); t->t_dtyp = TAND; t->t_dcar = syn2(p1, p, flags); t->t_dcdr = syn1b(p->next, p2, flags); t->t_dflg = 0; return (t); } continue; } return (syn2(p1, p2, flags)); } /* * syn2 * syn3 * syn3 | syn2 * syn3 |& syn2 */ struct command * syn2(p1, p2, flags) struct wordent *p1, *p2; int flags; { register struct wordent *p, *pn; register struct command *t; register int l = 0; int f; for (p = p1; p != p2; p = p->next) switch (p->word[0]) { case '(': l++; continue; case ')': l--; continue; case '|': if (l != 0) continue; t = (struct command *) calloc(1, sizeof (*t)); f = flags | POUT; pn = p->next; if (pn != p2 && pn->word[0] == '&') { f |= PDIAG; t->t_dflg |= FDIAG; } t->t_dtyp = TFIL; t->t_dcar = syn3(p1, p, f); if (pn != p2 && pn->word[0] == '&') p = pn; t->t_dcdr = syn2(p->next, p2, flags | PIN); return (t); } return (syn3(p1, p2, flags)); } char *RELPAR = "<>()"; /* * syn3 * ( syn0 ) [ < in ] [ > out ] * word word* [ < in ] [ > out ] * KEYWORD ( word* ) word* [ < in ] [ > out ] * * KEYWORD = (@ exit foreach if set switch test while) */ struct command * syn3(p1, p2, flags) struct wordent *p1, *p2; int flags; { register struct wordent *p; struct wordent *lp, *rp; register struct command *t; register int l; char **av; int n, c; bool specp = 0; if (p1 != p2) { p = p1; again: switch (srchx(p->word)) { case ZELSE: p = p->next; if (p != p2) goto again; break; case ZEXIT: case ZFOREACH: case ZIF: case ZLET: case ZSET: case ZSWITCH: case ZWHILE: specp = 1; break; } } n = 0; l = 0; for (p = p1; p != p2; p = p->next) switch (p->word[0]) { case '(': if (specp) n++; l++; continue; case ')': if (specp) n++; l--; continue; case '>': case '<': if (l != 0) { if (specp) n++; continue; } if (p->next == p2) continue; if (any(p->next->word[0], RELPAR)) continue; n--; continue; default: if (!specp && l != 0) continue; n++; continue; } if (n < 0) n = 0; t = (struct command *) calloc(1, sizeof (*t)); av = (char **) calloc((unsigned) (n + 1), sizeof (char **)); t->t_dcom = av; n = 0; if (p2->word[0] == ')') t->t_dflg = FPAR; lp = 0; rp = 0; l = 0; for (p = p1; p != p2; p = p->next) { c = p->word[0]; switch (c) { case '(': if (l == 0) { if (lp != 0 && !specp) seterr("Badly placed ("); lp = p->next; } l++; goto savep; case ')': l--; if (l == 0) rp = p; goto savep; case '>': if (l != 0) goto savep; if (p->word[1] == '>') t->t_dflg |= FCAT; if (p->next != p2 && eq(p->next->word, "&")) { t->t_dflg |= FDIAG, p = p->next; if (flags & (POUT|PDIAG)) goto badout; } if (p->next != p2 && eq(p->next->word, "!")) t->t_dflg |= FANY, p = p->next; if (p->next == p2) { missfile: seterr("Missing name for redirect"); continue; } p = p->next; if (any(p->word[0], RELPAR)) goto missfile; if ((flags & POUT) && (flags & PDIAG) == 0 || t->t_drit) badout: seterr("Ambiguous output redirect"); else t->t_drit = savestr(p->word); continue; case '<': if (l != 0) goto savep; if (p->word[1] == '<') t->t_dflg |= FHERE; if (p->next == p2) goto missfile; p = p->next; if (any(p->word[0], RELPAR)) goto missfile; if ((flags & PHERE) && (t->t_dflg & FHERE)) seterr("Can't << within ()'s"); else if ((flags & PIN) || t->t_dlef) seterr("Ambiguous input redirect"); else t->t_dlef = savestr(p->word); continue; savep: if (!specp) continue; default: if (l != 0 && !specp) continue; if (parserr == 0) av[n] = savestr(p->word); n++; continue; } } if (lp != 0 && !specp) { if (n != 0) seterr("Badly placed ()'s"); t->t_dtyp = TPAR; t->t_dspr = syn0(lp, rp, PHERE); } else { if (n == 0) seterr("Invalid null command"); t->t_dtyp = TCOM; } return (t); } freesyn(t) register struct command *t; { register char **v; if (t == 0) return; switch (t->t_dtyp) { case TCOM: for (v = t->t_dcom; *v; v++) XFREE(*v) XFREE((char *)t->t_dcom) goto lr; case TPAR: freesyn(t->t_dspr); /* fall into ... */ lr: XFREE(t->t_dlef) XFREE(t->t_drit) break; case TAND: case TOR: case TFIL: case TLST: freesyn(t->t_dcar), freesyn(t->t_dcdr); break; } XFREE((char *)t) } ================================================ FILE: bin/csh/sh.print.c ================================================ /* * C Shell * * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley Software License Agreement * specifies the terms and conditions for redistribution. */ #include "sh.h" #include psecs(l) long l; { register int i; i = l / 3600; if (i) { printf("%d:", i); i = l % 3600; p2dig(i / 60); goto minsec; } i = l; printf("%d", i / 60); minsec: i %= 60; printf(":"); p2dig(i); } p2dig(i) register int i; { printf("%d%d", i / 10, i % 10); } char linbuf[128]; char *linp = linbuf; void putchr(c) register int c; { if ((c & QUOTE) == 0 && (c == 0177 || c < ' ' && c != '\t' && c != '\n')) { putchar('^'); if (c == 0177) c = '?'; else c |= 'A' - 1; } c &= TRIM; *linp++ = c; if (c == '\n' || linp >= &linbuf[sizeof linbuf - 2]) flush(); } draino() { linp = linbuf; } flush() { register int unit; int lmode; if (linp == linbuf) return; if (haderr) unit = didfds ? 2 : SHDIAG; else unit = didfds ? 1 : SHOUT; #ifdef TIOCLGET if (didfds == 0 && ioctl(unit, TIOCLGET, (char *)&lmode) == 0 && lmode&LFLUSHO) { lmode = LFLUSHO; (void) ioctl(unit, TIOCLBIC, (char *)&lmode); (void) write(unit, "\n", 1); } #endif (void) write(unit, linbuf, linp - linbuf); linp = linbuf; } ================================================ FILE: bin/csh/sh.proc.c ================================================ /* * C Shell - functions that manage processes, handling hanging, termination * * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley Software License Agreement * specifies the terms and conditions for redistribution. */ #include "sh.h" #include "sh.dir.h" #include "sh.proc.h" #include #include #include #define BIGINDEX 9 /* largest desirable job index */ /* * pchild - called at interrupt level by the SIGCHLD signal * indicating that at least one child has terminated or stopped * thus at least one wait system call will definitely return a * childs status. Top level routines (like pwait) must be sure * to mask interrupts when playing with the proclist data structures! */ void pchild(int sig) { register struct process *pp; register struct process *fp; register int pid; union wait w; int jobflags; struct rusage ru; loop: pid = wait3((int*) &w, (setintr ? WNOHANG|WUNTRACED:WNOHANG), &ru); if (pid <= 0) { if (errno == EINTR) { errno = 0; goto loop; } pnoprocesses = pid == -1; return; } for (pp = proclist.p_next; pp != PNULL; pp = pp->p_next) if (pid == pp->p_pid) goto found; goto loop; found: if (pid == atoi(value("child"))) unsetv("child"); pp->p_flags &= ~(PRUNNING|PSTOPPED|PREPORTED); if (WIFSTOPPED(w)) { pp->p_flags |= PSTOPPED; pp->p_reason = w.w_stopsig; } else { if (pp->p_flags & (PTIME|PPTIME) || adrof("time")) (void) gettimeofday(&pp->p_etime, (struct timezone *)0); pp->p_rusage = ru; if (WIFSIGNALED(w)) { if (w.w_termsig == SIGINT) pp->p_flags |= PINTERRUPTED; else pp->p_flags |= PSIGNALED; if (w.w_coredump) pp->p_flags |= PDUMPED; pp->p_reason = w.w_termsig; } else { pp->p_reason = w.w_retcode; if (pp->p_reason != 0) pp->p_flags |= PAEXITED; else pp->p_flags |= PNEXITED; } } jobflags = 0; fp = pp; do { if ((fp->p_flags & (PPTIME|PRUNNING|PSTOPPED)) == 0 && !child && adrof("time") && fp->p_rusage.ru_utime.tv_sec+fp->p_rusage.ru_stime.tv_sec >= atoi(value("time"))) fp->p_flags |= PTIME; jobflags |= fp->p_flags; } while ((fp = fp->p_friends) != pp); pp->p_flags &= ~PFOREGND; if (pp == pp->p_friends && (pp->p_flags & PPTIME)) { pp->p_flags &= ~PPTIME; pp->p_flags |= PTIME; } if ((jobflags & (PRUNNING|PREPORTED)) == 0) { fp = pp; do { if (fp->p_flags&PSTOPPED) fp->p_flags |= PREPORTED; } while((fp = fp->p_friends) != pp); while(fp->p_pid != fp->p_jobid) fp = fp->p_friends; if (jobflags&PSTOPPED) { if (pcurrent && pcurrent != fp) pprevious = pcurrent; pcurrent = fp; } else pclrcurr(fp); if (jobflags&PFOREGND) { if (jobflags & (PSIGNALED|PSTOPPED|PPTIME) || #ifdef IIASA jobflags & PAEXITED || #endif !eq(dcwd->di_name, fp->p_cwd->di_name)) { ; /* print in pjwait */ } /* else if ((jobflags & (PTIME|PSTOPPED)) == PTIME) ptprint(fp); */ } else { if (jobflags&PNOTIFY || adrof("notify")) { printf("\215\n"); (void) pprint(pp, NUMBER|NAME|REASON); if ((jobflags&PSTOPPED) == 0) pflush(pp); } else { fp->p_flags |= PNEEDNOTE; neednote++; } } } goto loop; } pnote() { register struct process *pp; int flags; long omask; neednote = 0; for (pp = proclist.p_next; pp != PNULL; pp = pp->p_next) { if (pp->p_flags & PNEEDNOTE) { omask = sigblock(sigmask(SIGCHLD)); pp->p_flags &= ~PNEEDNOTE; flags = pprint(pp, NUMBER|NAME|REASON); if ((flags&(PRUNNING|PSTOPPED)) == 0) pflush(pp); (void) sigsetmask(omask); } } } /* * pwait - wait for current job to terminate, maintaining integrity * of current and previous job indicators. */ pwait() { register struct process *fp, *pp; long omask; /* * Here's where dead procs get flushed. */ omask = sigblock(sigmask(SIGCHLD)); for (pp = (fp = &proclist)->p_next; pp != PNULL; pp = (fp = pp)->p_next) if (pp->p_pid == 0) { fp->p_next = pp->p_next; xfree(pp->p_command); if (pp->p_cwd && --pp->p_cwd->di_count == 0) if (pp->p_cwd->di_next == 0) dfree(pp->p_cwd); xfree((char *)pp); pp = fp; } (void) sigsetmask(omask); pjwait(pcurrjob); } /* * pjwait - wait for a job to finish or become stopped * It is assumed to be in the foreground state (PFOREGND) */ pjwait(pp) register struct process *pp; { register struct process *fp; int jobflags, reason; long omask; while (pp->p_pid != pp->p_jobid) pp = pp->p_friends; fp = pp; do { if ((fp->p_flags&(PFOREGND|PRUNNING)) == PRUNNING) printf("BUG: waiting for background job!\n"); } while ((fp = fp->p_friends) != pp); /* * Now keep pausing as long as we are not interrupted (SIGINT), * and the target process, or any of its friends, are running */ fp = pp; omask = sigblock(sigmask(SIGCHLD)); for (;;) { jobflags = 0; do jobflags |= fp->p_flags; while ((fp = (fp->p_friends)) != pp); if ((jobflags & PRUNNING) == 0) break; sigpause(sigblock(0L) &~ sigmask(SIGCHLD)); } (void) sigsetmask(omask); if (tpgrp > 0) /* get tty back */ (void) ioctl(FSHTTY, TIOCSPGRP, (char *)&tpgrp); if ((jobflags&(PSIGNALED|PSTOPPED|PTIME)) || !eq(dcwd->di_name, fp->p_cwd->di_name)) { if (jobflags&PSTOPPED) printf("\n"); (void) pprint(pp, AREASON|SHELLDIR); } if ((jobflags&(PINTERRUPTED|PSTOPPED)) && setintr && (!gointr || !eq(gointr, "-"))) { if ((jobflags & PSTOPPED) == 0) pflush(pp); pintr1(0); /*NOTREACHED*/ } reason = 0; fp = pp; do { if (fp->p_reason) reason = fp->p_flags & (PSIGNALED|PINTERRUPTED) ? fp->p_reason | QUOTE : fp->p_reason; } while ((fp = fp->p_friends) != pp); set("status", putn(reason)); if (reason && exiterr) exitstat(); pflush(pp); } /* * dowait - wait for all processes to finish */ dowait() { register struct process *pp; long omask; pjobs++; omask = sigblock(sigmask(SIGCHLD)); loop: for (pp = proclist.p_next; pp; pp = pp->p_next) if (pp->p_pid && /* pp->p_pid == pp->p_jobid && */ pp->p_flags&PRUNNING) { sigpause(0L); goto loop; } (void) sigsetmask(omask); pjobs = 0; } /* * pflushall - flush all jobs from list (e.g. at fork()) */ pflushall() { register struct process *pp; for (pp = proclist.p_next; pp != PNULL; pp = pp->p_next) if (pp->p_pid) pflush(pp); } /* * pflush - flag all process structures in the same job as the * the argument process for deletion. The actual free of the * space is not done here since pflush is called at interrupt level. */ pflush(pp) register struct process *pp; { register struct process *np; register int index; if (pp->p_pid == 0) { printf("BUG: process flushed twice"); return; } while (pp->p_pid != pp->p_jobid) pp = pp->p_friends; pclrcurr(pp); if (pp == pcurrjob) pcurrjob = 0; index = pp->p_index; np = pp; do { np->p_index = np->p_pid = 0; np->p_flags &= ~PNEEDNOTE; } while ((np = np->p_friends) != pp); if (index == pmaxindex) { for (np = proclist.p_next, index = 0; np; np = np->p_next) if (np->p_index > index) index = np->p_index; pmaxindex = index; } } /* * pclrcurr - make sure the given job is not the current or previous job; * pp MUST be the job leader */ pclrcurr(pp) register struct process *pp; { if (pp == pcurrent) if (pprevious != PNULL) { pcurrent = pprevious; pprevious = pgetcurr(pp); } else { pcurrent = pgetcurr(pp); pprevious = pgetcurr(pp); } else if (pp == pprevious) pprevious = pgetcurr(pp); } /* +4 here is 1 for '\0', 1 ea for << >& >> */ char command[PMAXLEN+4]; int cmdlen; char *cmdp; /* * palloc - allocate a process structure and fill it up. * an important assumption is made that the process is running. */ palloc(pid, t) int pid; register struct command *t; { register struct process *pp; int i; pp = (struct process *)calloc(1, sizeof(struct process)); pp->p_pid = pid; pp->p_flags = t->t_dflg & FAND ? PRUNNING : PRUNNING|PFOREGND; if (t->t_dflg & FTIME) pp->p_flags |= PPTIME; cmdp = command; cmdlen = 0; padd(t); *cmdp++ = 0; if (t->t_dflg & FPOU) { pp->p_flags |= PPOU; if (t->t_dflg & FDIAG) pp->p_flags |= PDIAG; } pp->p_command = savestr(command); if (pcurrjob) { struct process *fp; /* careful here with interrupt level */ pp->p_cwd = 0; pp->p_index = pcurrjob->p_index; pp->p_friends = pcurrjob; pp->p_jobid = pcurrjob->p_pid; for (fp = pcurrjob; fp->p_friends != pcurrjob; fp = fp->p_friends) ; fp->p_friends = pp; } else { pcurrjob = pp; pp->p_jobid = pid; pp->p_friends = pp; pp->p_cwd = dcwd; dcwd->di_count++; if (pmaxindex < BIGINDEX) pp->p_index = ++pmaxindex; else { struct process *np; for (i = 1; ; i++) { for (np = proclist.p_next; np; np = np->p_next) if (np->p_index == i) goto tryagain; pp->p_index = i; if (i > pmaxindex) pmaxindex = i; break; tryagain:; } } if (pcurrent == PNULL) pcurrent = pp; else if (pprevious == PNULL) pprevious = pp; } pp->p_next = proclist.p_next; proclist.p_next = pp; (void) gettimeofday(&pp->p_btime, (struct timezone *)0); } padd(t) register struct command *t; { char **argp; if (t == 0) return; switch (t->t_dtyp) { case TPAR: pads("( "); padd(t->t_dspr); pads(" )"); break; case TCOM: for (argp = t->t_dcom; *argp; argp++) { pads(*argp); if (argp[1]) pads(" "); } break; case TOR: case TAND: case TFIL: case TLST: padd(t->t_dcar); switch (t->t_dtyp) { case TOR: pads(" || "); break; case TAND: pads(" && "); break; case TFIL: pads(" | "); break; case TLST: pads("; "); break; } padd(t->t_dcdr); return; } if ((t->t_dflg & FPIN) == 0 && t->t_dlef) { pads((t->t_dflg & FHERE) ? " << " : " < "); pads(t->t_dlef); } if ((t->t_dflg & FPOU) == 0 && t->t_drit) { pads((t->t_dflg & FCAT) ? " >>" : " >"); if (t->t_dflg & FDIAG) pads("&"); pads(" "); pads(t->t_drit); } } pads(cp) char *cp; { register int i = strlen(cp); if (cmdlen >= PMAXLEN) return; if (cmdlen + i >= PMAXLEN) { (void) strcpy(cmdp, " ..."); cmdlen = PMAXLEN; cmdp += 4; return; } (void) strcpy(cmdp, cp); cmdp += i; cmdlen += i; } /* * psavejob - temporarily save the current job on a one level stack * so another job can be created. Used for { } in exp6 * and `` in globbing. */ psavejob() { pholdjob = pcurrjob; pcurrjob = PNULL; } /* * prestjob - opposite of psavejob. This may be missed if we are interrupted * somewhere, but pendjob cleans up anyway. */ prestjob() { pcurrjob = pholdjob; pholdjob = PNULL; } /* * pendjob - indicate that a job (set of commands) has been completed * or is about to begin. */ pendjob() { register struct process *pp, *tp; if (pcurrjob && (pcurrjob->p_flags&(PFOREGND|PSTOPPED)) == 0) { pp = pcurrjob; while (pp->p_pid != pp->p_jobid) pp = pp->p_friends; printf("[%d]", pp->p_index); tp = pp; do { printf(" %d", pp->p_pid); pp = pp->p_friends; } while (pp != tp); printf("\n"); } pholdjob = pcurrjob = 0; } /* * pprint - print a job */ pprint(pp, flag) register struct process *pp; { register status, reason; struct process *tp; extern char *linp, linbuf[]; int jobflags, pstatus; char *format; while (pp->p_pid != pp->p_jobid) pp = pp->p_friends; if (pp == pp->p_friends && (pp->p_flags & PPTIME)) { pp->p_flags &= ~PPTIME; pp->p_flags |= PTIME; } tp = pp; status = reason = -1; jobflags = 0; do { jobflags |= pp->p_flags; pstatus = pp->p_flags & PALLSTATES; if (tp != pp && linp != linbuf && !(flag&FANCY) && (pstatus == status && pp->p_reason == reason || !(flag&REASON))) printf(" "); else { if (tp != pp && linp != linbuf) printf("\n"); if(flag&NUMBER) if (pp == tp) printf("[%d]%s %c ", pp->p_index, pp->p_index < 10 ? " " : "", pp==pcurrent ? '+' : (pp == pprevious ? '-' : ' ')); else printf(" "); if (flag&FANCY) printf("%5d ", pp->p_pid); if (flag&(REASON|AREASON)) { if (flag&NAME) format = "%-21s"; else format = "%s"; if (pstatus == status) if (pp->p_reason == reason) { printf(format, ""); goto prcomd; } else reason = pp->p_reason; else { status = pstatus; reason = pp->p_reason; } switch (status) { case PRUNNING: printf(format, "Running "); break; case PINTERRUPTED: case PSTOPPED: case PSIGNALED: if ((flag&(REASON|AREASON)) && reason != SIGINT && reason != SIGPIPE) printf(format, mesg[pp->p_reason].pname); break; case PNEXITED: case PAEXITED: if (flag & REASON) if (pp->p_reason) printf("Exit %-16d", pp->p_reason); else printf(format, "Done"); break; default: printf("BUG: status=%-9o", status); } } } prcomd: if (flag&NAME) { printf("%s", pp->p_command); if (pp->p_flags & PPOU) printf(" |"); if (pp->p_flags & PDIAG) printf("&"); } if (flag&(REASON|AREASON) && pp->p_flags&PDUMPED) printf(" (core dumped)"); if (tp == pp->p_friends) { if (flag&ERSAND) printf(" &"); if (flag&JOBDIR && !eq(tp->p_cwd->di_name, dcwd->di_name)) { printf(" (wd: "); dtildepr(value("home"), tp->p_cwd->di_name); printf(")"); } } if (pp->p_flags&PPTIME && !(status&(PSTOPPED|PRUNNING))) { if (linp != linbuf) printf("\n\t"); { static struct rusage zru; prusage(&zru, &pp->p_rusage, &pp->p_etime, &pp->p_btime); } } if (tp == pp->p_friends) { if (linp != linbuf) printf("\n"); if (flag&SHELLDIR && !eq(tp->p_cwd->di_name, dcwd->di_name)) { printf("(wd now: "); dtildepr(value("home"), dcwd->di_name); printf(")\n"); } } } while ((pp = pp->p_friends) != tp); if (jobflags&PTIME && (jobflags&(PSTOPPED|PRUNNING)) == 0) { if (jobflags & NUMBER) printf(" "); ptprint(tp); } return (jobflags); } ptprint(tp) register struct process *tp; { struct timeval tetime, diff; static struct timeval ztime; struct rusage ru; static struct rusage zru; register struct process *pp = tp; ru = zru; tetime = ztime; do { ruadd(&ru, &pp->p_rusage); tvsub(&diff, &pp->p_etime, &pp->p_btime); if (timercmp(&diff, &tetime, >)) tetime = diff; } while ((pp = pp->p_friends) != tp); prusage(&zru, &ru, &tetime, &ztime); } /* * dojobs - print all jobs */ dojobs(v) char **v; { register struct process *pp; register int flag = NUMBER|NAME|REASON; int i; if (chkstop) chkstop = 2; if (*++v) { if (v[1] || !eq(*v, "-l")) error("Usage: jobs [ -l ]"); flag |= FANCY|JOBDIR; } for (i = 1; i <= pmaxindex; i++) for (pp = proclist.p_next; pp; pp = pp->p_next) if (pp->p_index == i && pp->p_pid == pp->p_jobid) { pp->p_flags &= ~PNEEDNOTE; if (!(pprint(pp, flag) & (PRUNNING|PSTOPPED))) pflush(pp); break; } } /* * dofg - builtin - put the job into the foreground */ dofg(v) char **v; { register struct process *pp; okpcntl(); ++v; do { pp = pfind(*v); pstart(pp, 1); pjwait(pp); } while (*v && *++v); } /* * %... - builtin - put the job into the foreground */ dofg1(v) char **v; { register struct process *pp; okpcntl(); pp = pfind(v[0]); pstart(pp, 1); pjwait(pp); } /* * dobg - builtin - put the job into the background */ dobg(v) char **v; { register struct process *pp; okpcntl(); ++v; do { pp = pfind(*v); pstart(pp, 0); } while (*v && *++v); } /* * %... & - builtin - put the job into the background */ dobg1(v) char **v; { register struct process *pp; pp = pfind(v[0]); pstart(pp, 0); } /* * dostop - builtin - stop the job */ dostop(v) char **v; { pkill(++v, SIGSTOP); } /* * dokill - builtin - superset of kill (1) */ dokill(v) char **v; { register int signum; register char *name; v++; if (v[0] && v[0][0] == '-') { if (v[0][1] == 'l') { for (signum = 1; signum <= NSIG; signum++) { if (name = mesg[signum].iname) printf("%s ", name); if (signum == 16) putchar('\n'); } putchar('\n'); return; } if (digit(v[0][1])) { signum = atoi(v[0]+1); if (signum < 0 || signum > NSIG) bferr("Bad signal number"); } else { name = &v[0][1]; for (signum = 1; signum <= NSIG; signum++) if (mesg[signum].iname && eq(name, mesg[signum].iname)) goto gotsig; setname(name); bferr("Unknown signal; kill -l lists signals"); } gotsig: v++; } else signum = SIGTERM; pkill(v, signum); } pkill(v, signum) char **v; int signum; { register struct process *pp, *np; register int jobflags = 0; int pid, parserr = 0; long omask; char *cp; omask = sigmask(SIGCHLD); if (setintr) omask |= sigmask(SIGINT); omask = sigblock(omask) & ~omask; while (*v) { cp = globone(*v); if (*cp == '%') { np = pp = pfind(cp); do jobflags |= np->p_flags; while ((np = np->p_friends) != pp); switch (signum) { case SIGSTOP: case SIGTSTP: case SIGTTIN: case SIGTTOU: if ((jobflags & PRUNNING) == 0) { printf("%s: Already stopped\n", cp); parserr++; goto cont; } } if (killpg(pp->p_jobid, signum) < 0) { printf("%s: ", cp); printf("%s\n", strerror(errno)); parserr++; } if (signum == SIGTERM || signum == SIGHUP) (void) killpg(pp->p_jobid, SIGCONT); } else if (!(digit(*cp) || *cp == '-')) bferr("Arguments should be jobs or process id's"); else { pid = atoi(cp); if (kill(pid, signum) < 0) { printf("%d: ", pid); printf("%s\n", strerror(errno)); parserr++; goto cont; } if (signum == SIGTERM || signum == SIGHUP) (void) kill(pid, SIGCONT); } cont: xfree(cp); v++; } (void) sigsetmask(omask); if (parserr) error(NOSTR); } /* * pstart - start the job in foreground/background */ pstart(pp, foregnd) register struct process *pp; int foregnd; { register struct process *np; int jobflags = 0; long omask; omask = sigblock(sigmask(SIGCHLD)); np = pp; do { jobflags |= np->p_flags; if (np->p_flags&(PRUNNING|PSTOPPED)) { np->p_flags |= PRUNNING; np->p_flags &= ~PSTOPPED; if (foregnd) np->p_flags |= PFOREGND; else np->p_flags &= ~PFOREGND; } } while((np = np->p_friends) != pp); if (!foregnd) pclrcurr(pp); (void) pprint(pp, foregnd ? NAME|JOBDIR : NUMBER|NAME|AMPERSAND); if (foregnd) (void) ioctl(FSHTTY, TIOCSPGRP, (char *)&pp->p_jobid); if (jobflags&PSTOPPED) (void) killpg(pp->p_jobid, SIGCONT); (void) sigsetmask(omask); } panystop(neednl) { register struct process *pp; chkstop = 2; for (pp = proclist.p_next; pp; pp = pp->p_next) if (pp->p_flags & PSTOPPED) error("\nThere are stopped jobs" + 1 - neednl); } struct process * pfind(cp) char *cp; { register struct process *pp, *np; if (cp == 0 || cp[1] == 0 || eq(cp, "%%") || eq(cp, "%+")) { if (pcurrent == PNULL) bferr("No current job"); return (pcurrent); } if (eq(cp, "%-") || eq(cp, "%#")) { if (pprevious == PNULL) bferr("No previous job"); return (pprevious); } if (digit(cp[1])) { int index = atoi(cp+1); for (pp = proclist.p_next; pp; pp = pp->p_next) if (pp->p_index == index && pp->p_pid == pp->p_jobid) return (pp); bferr("No such job"); } np = PNULL; for (pp = proclist.p_next; pp; pp = pp->p_next) if (pp->p_pid == pp->p_jobid) { if (cp[1] == '?') { register char *dp; for (dp = pp->p_command; *dp; dp++) { if (*dp != cp[2]) continue; if (prefix(cp+2, dp)) goto match; } } else if (prefix(cp+1, pp->p_command)) { match: if (np) bferr("Ambiguous"); np = pp; } } if (np) return (np); if (cp[1] == '?') bferr("No job matches pattern"); else bferr("No such job"); /*NOTREACHED*/ } /* * pgetcurr - find most recent job that is not pp, preferably stopped */ struct process * pgetcurr(pp) register struct process *pp; { register struct process *np; register struct process *xp = PNULL; for (np = proclist.p_next; np; np = np->p_next) if (np != pcurrent && np != pp && np->p_pid && np->p_pid == np->p_jobid) { if (np->p_flags & PSTOPPED) return (np); if (xp == PNULL) xp = np; } return (xp); } /* * donotify - flag the job so as to report termination asynchronously */ donotify(v) char **v; { register struct process *pp; pp = pfind(*++v); pp->p_flags |= PNOTIFY; } /* * Do the fork and whatever should be done in the child side that * should not be done if we are not forking at all (like for simple builtin's) * Also do everything that needs any signals fiddled with in the parent side * * Wanttty tells whether process and/or tty pgrps are to be manipulated: * -1: leave tty alone; inherit pgrp from parent * 0: already have tty; manipulate process pgrps only * 1: want to claim tty; manipulate process and tty pgrps * It is usually just the value of tpgrp. */ pfork(t, wanttty) struct command *t; /* command we are forking for */ int wanttty; { register int pid; bool ignint = 0; int pgrp; long omask; /* * A child will be uninterruptible only under very special * conditions. Remember that the semantics of '&' is * implemented by disconnecting the process from the tty so * signals do not need to ignored just for '&'. * Thus signals are set to default action for children unless: * we have had an "onintr -" (then specifically ignored) * we are not playing with signals (inherit action) */ if (setintr) ignint = (tpgrp == -1 && (t->t_dflg&FINT)) || (gointr && eq(gointr, "-")); /* * Hold SIGCHLD until we have the process installed in our table. */ omask = sigblock(sigmask(SIGCHLD)); while ((pid = fork()) < 0) if (setintr == 0) sleep(FORKSLEEP); else { (void) sigsetmask(omask); error("No more processes"); } if (pid == 0) { settimes(); pgrp = pcurrjob ? pcurrjob->p_jobid : getpid(); pflushall(); pcurrjob = PNULL; child++; if (setintr) { setintr = 0; /* until I think otherwise */ /* * Children just get blown away on SIGINT, SIGQUIT * unless "onintr -" seen. */ (void) signal(SIGINT, ignint ? SIG_IGN : SIG_DFL); (void) signal(SIGQUIT, ignint ? SIG_IGN : SIG_DFL); if (wanttty >= 0) { /* make stoppable */ (void) signal(SIGTSTP, SIG_DFL); (void) signal(SIGTTIN, SIG_DFL); (void) signal(SIGTTOU, SIG_DFL); } (void) signal(SIGTERM, parterm); } else if (tpgrp == -1 && (t->t_dflg&FINT)) { (void) signal(SIGINT, SIG_IGN); (void) signal(SIGQUIT, SIG_IGN); } if (wanttty > 0) (void) ioctl(FSHTTY, TIOCSPGRP, (char *)&pgrp); if (wanttty >= 0 && tpgrp >= 0) (void) setpgrp(0, pgrp); if (tpgrp > 0) tpgrp = 0; /* gave tty away */ /* * Nohup and nice apply only to TCOM's but it would be * nice (?!?) if you could say "nohup (foo;bar)" * Then the parser would have to know about nice/nohup/time */ if (t->t_dflg & FNOHUP) (void) signal(SIGHUP, SIG_IGN); if (t->t_dflg & FNICE) (void) setpriority(PRIO_PROCESS, 0, t->t_nice); } else { palloc(pid, t); (void) sigsetmask(omask); } return (pid); } okpcntl() { if (tpgrp == -1) error("No job control in this shell"); if (tpgrp == 0) error("No job control in subshells"); } ================================================ FILE: bin/csh/sh.proc.h ================================================ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley Software License Agreement * specifies the terms and conditions for redistribution. * * @(#)sh.proc.h 5.2 (Berkeley) 6/6/85 */ /* * C shell - process structure declarations */ /* * Structure for each process the shell knows about: * allocated and filled by pcreate. * flushed by pflush; freeing always happens at top level * so the interrupt level has less to worry about. * processes are related to "friends" when in a pipeline; * p_friends links makes a circular list of such jobs */ struct process { struct process *p_next; /* next in global "proclist" */ struct process *p_friends; /* next in job list (or self) */ struct directory *p_cwd; /* cwd of the job (only in head) */ short unsigned p_flags; /* various job status flags */ char p_reason; /* reason for entering this state */ char p_index; /* shorthand job index */ int p_pid; int p_jobid; /* pid of job leader */ /* if a job is stopped/background p_jobid gives its pgrp */ struct timeval p_btime; /* begin time */ struct timeval p_etime; /* end time */ struct rusage p_rusage; char *p_command; /* first PMAXLEN chars of command */ }; /* flag values for p_flags */ #define PRUNNING (1<<0) /* running */ #define PSTOPPED (1<<1) /* stopped */ #define PNEXITED (1<<2) /* normally exited */ #define PAEXITED (1<<3) /* abnormally exited */ #define PSIGNALED (1<<4) /* terminated by a signal != SIGINT */ #define PALLSTATES (PRUNNING|PSTOPPED|PNEXITED|PAEXITED|PSIGNALED|PINTERRUPTED) #define PNOTIFY (1<<5) /* notify async when done */ #define PTIME (1<<6) /* job times should be printed */ #define PAWAITED (1<<7) /* top level is waiting for it */ #define PFOREGND (1<<8) /* started in shells pgrp */ #define PDUMPED (1<<9) /* process dumped core */ #define PDIAG (1<<10) /* diagnostic output also piped out */ #define PPOU (1<<11) /* piped output */ #define PREPORTED (1<<12) /* status has been reported */ #define PINTERRUPTED (1<<13) /* job stopped via interrupt signal */ #define PPTIME (1<<14) /* time individual process */ #define PNEEDNOTE (1<<15) /* notify as soon as practical */ #define PNULL (struct process *)0 #define PMAXLEN 80 /* defines for arguments to pprint */ #define NUMBER 01 #define NAME 02 #define REASON 04 #define AMPERSAND 010 #define FANCY 020 #define SHELLDIR 040 /* print shell's dir if not the same */ #define JOBDIR 0100 /* print job's dir if not the same */ #define AREASON 0200 struct process proclist; /* list head of all processes */ bool pnoprocesses; /* pchild found nothing to wait for */ struct process *pholdjob; /* one level stack of current jobs */ struct process *pcurrjob; /* current job */ struct process *pcurrent; /* current job in table */ struct process *pprevious; /* previous job in table */ short pmaxindex; /* current maximum job index */ int psigint(); struct process *pgetcurr(); struct process *plookup(); struct process *pfind(); ================================================ FILE: bin/csh/sh.sem.c ================================================ /* * C shell * * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley Software License Agreement * specifies the terms and conditions for redistribution. */ #include "sh.h" #include "sh.proc.h" #include #include #ifdef VFORK void vffree(int sig) { register char **v; if (v = gargv) gargv = 0, blkfree(v); if (v = pargv) pargv = 0, blkfree(v); _exit(1); } #endif /*VARARGS 1*/ execute(t, wanttty, pipein, pipeout) register struct command *t; int wanttty, *pipein, *pipeout; { bool forked = 0; struct biltins *bifunc; int pid = 0; int pv[2]; if (t == 0) return; if ((t->t_dflg & FAND) && wanttty > 0) wanttty = 0; switch (t->t_dtyp) { case TCOM: if ((t->t_dcom[0][0] & (QUOTE|TRIM)) == QUOTE) (void) strcpy(t->t_dcom[0], t->t_dcom[0] + 1); if ((t->t_dflg & FREDO) == 0) Dfix(t); /* $ " ' \ */ if (t->t_dcom[0] == 0) return; /* fall into... */ case TPAR: if (t->t_dflg & FPOU) mypipe(pipeout); /* * Must do << early so parent will know * where input pointer should be. * If noexec then this is all we do. */ if (t->t_dflg & FHERE) { (void) close(0); heredoc(t->t_dlef); if (noexec) (void) close(0); } if (noexec) break; set("status", "0"); /* * This mess is the necessary kludge to handle the prefix * builtins: nice, nohup, time. These commands can also * be used by themselves, and this is not handled here. * This will also work when loops are parsed. */ while (t->t_dtyp == TCOM) if (eq(t->t_dcom[0], "nice")) if (t->t_dcom[1]) if (any(t->t_dcom[1][0], "+-")) if (t->t_dcom[2]) { setname("nice"); t->t_nice = getn(t->t_dcom[1]); lshift(t->t_dcom, 2); t->t_dflg |= FNICE; } else break; else { t->t_nice = 4; lshift(t->t_dcom, 1); t->t_dflg |= FNICE; } else break; else if (eq(t->t_dcom[0], "nohup")) if (t->t_dcom[1]) { t->t_dflg |= FNOHUP; lshift(t->t_dcom, 1); } else break; else if (eq(t->t_dcom[0], "time")) if (t->t_dcom[1]) { t->t_dflg |= FTIME; lshift(t->t_dcom, 1); } else break; else break; /* * Check if we have a builtin function and remember which one. */ bifunc = t->t_dtyp == TCOM ? isbfunc(t) : (struct biltins *) 0; /* * We fork only if we are timed, or are not the end of * a parenthesized list and not a simple builtin function. * Simple meaning one that is not pipedout, niced, nohupped, * or &'d. * It would be nice(?) to not fork in some of these cases. */ if (((t->t_dflg & FTIME) || (t->t_dflg & FPAR) == 0 && (!bifunc || t->t_dflg & (FPOU|FAND|FNICE|FNOHUP)))) #ifdef VFORK if (t->t_dtyp == TPAR || t->t_dflg&(FREDO|FAND) || bifunc) #endif { forked++; pid = pfork(t, wanttty); } #ifdef VFORK else { int ochild, osetintr, ohaderr, odidfds; int oSHIN, oSHOUT, oSHDIAG, oOLDSTD, otpgrp; long omask; /* * Prepare for the vfork by saving everything * that the child corrupts before it exec's. * Note that in some signal implementations * which keep the signal info in user space * (e.g. Sun's) it will also be necessary to * save and restore the current sigvec's for * the signals the child touches before it * exec's. */ omask = sigblock(sigmask(SIGCHLD)); ochild = child; osetintr = setintr; ohaderr = haderr; odidfds = didfds; oSHIN = SHIN; oSHOUT = SHOUT; oSHDIAG = SHDIAG; oOLDSTD = OLDSTD; otpgrp = tpgrp; Vsav = Vdp = 0; Vav = 0; pid = vfork(); if (pid < 0) { (void) sigsetmask(omask); error("No more processes"); } forked++; if (pid) { /* parent */ register char **v; child = ochild; setintr = osetintr; haderr = ohaderr; didfds = odidfds; SHIN = oSHIN; SHOUT = oSHOUT; SHDIAG = oSHDIAG; OLDSTD = oOLDSTD; tpgrp = otpgrp; xfree(Vsav); Vsav = 0; xfree(Vdp); Vdp = 0; xfree((char *)Vav); Vav = 0; if (v = gargv) gargv = 0, blkfree(v); if (v = pargv) pargv = 0, blkfree(v); /* this is from pfork() */ palloc(pid, t); (void) sigsetmask(omask); } else { /* child */ /* this is from pfork() */ int pgrp; bool ignint = 0; if (setintr) ignint = (tpgrp == -1 && (t->t_dflg&FINT)) || gointr && eq(gointr, "-"); pgrp = pcurrjob ? pcurrjob->p_jobid : getpid(); child++; if (setintr) { setintr = 0; #ifdef notdef (void) signal(SIGCHLD, SIG_DFL); #endif (void) signal(SIGINT, ignint ? SIG_IGN : vffree); (void) signal(SIGQUIT, ignint ? SIG_IGN : SIG_DFL); if (wanttty >= 0) { (void) signal(SIGTSTP, SIG_DFL); (void) signal(SIGTTIN, SIG_DFL); (void) signal(SIGTTOU, SIG_DFL); } (void) signal(SIGTERM, parterm); } else if (tpgrp == -1 && (t->t_dflg&FINT)) { (void) signal(SIGINT, SIG_IGN); (void) signal(SIGQUIT, SIG_IGN); } if (wanttty > 0) (void) ioctl(FSHTTY, TIOCSPGRP, (char *)&pgrp); if (wanttty >= 0 && tpgrp >= 0) (void) setpgrp(0, pgrp); if (tpgrp > 0) tpgrp = 0; if (t->t_dflg & FNOHUP) (void) signal(SIGHUP, SIG_IGN); if (t->t_dflg & FNICE) (void) setpriority(PRIO_PROCESS, 0, t->t_nice); } } #endif if (pid != 0) { /* * It would be better if we could wait for the * whole job when we knew the last process * had been started. Pwait, in fact, does * wait for the whole job anyway, but this test * doesn't really express our intentions. */ if (didfds==0 && t->t_dflg&FPIN) { (void) close(pipein[0]); (void) close(pipein[1]); } if ((t->t_dflg & (FPOU|FAND)) == 0) pwait(); break; } doio(t, pipein, pipeout); if (t->t_dflg & FPOU) { (void) close(pipeout[0]); (void) close(pipeout[1]); } /* * Perform a builtin function. * If we are not forked, arrange for possible stopping */ if (bifunc) { func(t, bifunc); if (forked) exitstat(); break; } if (t->t_dtyp != TPAR) { doexec(t); /*NOTREACHED*/ } /* * For () commands must put new 0,1,2 in FSH* and recurse */ OLDSTD = dcopy(0, FOLDSTD); SHOUT = dcopy(1, FSHOUT); SHDIAG = dcopy(2, FSHDIAG); (void) close(SHIN); SHIN = -1; didfds = 0; wanttty = -1; t->t_dspr->t_dflg |= t->t_dflg & FINT; execute(t->t_dspr, wanttty); exitstat(); case TFIL: t->t_dcar->t_dflg |= FPOU | (t->t_dflg & (FPIN|FAND|FDIAG|FINT)); execute(t->t_dcar, wanttty, pipein, pv); t->t_dcdr->t_dflg |= FPIN | (t->t_dflg & (FPOU|FAND|FPAR|FINT)); if (wanttty > 0) wanttty = 0; /* got tty already */ execute(t->t_dcdr, wanttty, pv, pipeout); break; case TLST: if (t->t_dcar) { t->t_dcar->t_dflg |= t->t_dflg & FINT; execute(t->t_dcar, wanttty); /* * In strange case of A&B make a new job after A */ if (t->t_dcar->t_dflg&FAND && t->t_dcdr && (t->t_dcdr->t_dflg&FAND) == 0) pendjob(); } if (t->t_dcdr) { t->t_dcdr->t_dflg |= t->t_dflg & (FPAR|FINT); execute(t->t_dcdr, wanttty); } break; case TOR: case TAND: if (t->t_dcar) { t->t_dcar->t_dflg |= t->t_dflg & FINT; execute(t->t_dcar, wanttty); if ((getn(value("status")) == 0) != (t->t_dtyp == TAND)) return; } if (t->t_dcdr) { t->t_dcdr->t_dflg |= t->t_dflg & (FPAR|FINT); execute(t->t_dcdr, wanttty); } break; } /* * Fall through for all breaks from switch * * If there will be no more executions of this * command, flush all file descriptors. * Places that turn on the FREDO bit are responsible * for doing donefds after the last re-execution */ if (didfds && !(t->t_dflg & FREDO)) donefds(); } /* * Perform io redirection. * We may or maynot be forked here. */ doio(t, pipein, pipeout) register struct command *t; int *pipein, *pipeout; { register char *cp; register int flags = t->t_dflg; if (didfds || (flags & FREDO)) return; if ((flags & FHERE) == 0) { /* FHERE already done */ (void) close(0); if (cp = t->t_dlef) { cp = globone(Dfix1(cp)); xfree(cp); if (open(cp, 0) < 0) Perror(cp); } else if (flags & FPIN) { (void) dup(pipein[0]); (void) close(pipein[0]); (void) close(pipein[1]); } else if ((flags & FINT) && tpgrp == -1) { (void) close(0); (void) open("/dev/null", 0); } else (void) dup(OLDSTD); } (void) close(1); if (cp = t->t_drit) { cp = globone(Dfix1(cp)); xfree(cp); if ((flags & FCAT) && open(cp, O_WRONLY | O_APPEND) >= 0) ; else { if (!(flags & FANY) && adrof("noclobber")) { if (flags & FCAT) Perror(cp); chkclob(cp); } if (creat(cp, 0666) < 0) Perror(cp); } } else if (flags & FPOU) (void) dup(pipeout[1]); else (void) dup(SHOUT); (void) close(2); if (flags & FDIAG) (void) dup(1); else (void) dup(SHDIAG); didfds = 1; } mypipe(pv) register int *pv; { if (pipe(pv) < 0) goto oops; pv[0] = dmove(pv[0], -1); pv[1] = dmove(pv[1], -1); if (pv[0] >= 0 && pv[1] >= 0) return; oops: error("Can't make pipe"); } chkclob(cp) register char *cp; { struct stat stb; if (stat(cp, &stb) < 0) return; if ((stb.st_mode & S_IFMT) == S_IFCHR) return; error("%s: File exists", cp); } ================================================ FILE: bin/csh/sh.set.c ================================================ /* * C Shell * * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley Software License Agreement * specifies the terms and conditions for redistribution. */ #include "sh.h" doset(v) register char **v; { register char *p; char *vp, op; char **vecp; bool hadsub; int subscr; v++; p = *v++; if (p == 0) { prvars(); return; } do { hadsub = 0; for (vp = p; alnum(*p); p++) continue; if (vp == p || !letter(*vp)) goto setsyn; if (*p == '[') { hadsub++; p = getinx(p, &subscr); } if (op = *p) { *p++ = 0; if (*p == 0 && *v && **v == '(') p = *v++; } else if (*v && eq(*v, "=")) { op = '=', v++; if (*v) p = *v++; } if (op && op != '=') setsyn: bferr("Syntax error"); if (eq(p, "(")) { register char **e = v; if (hadsub) goto setsyn; for (;;) { if (!*e) bferr("Missing )"); if (**e == ')') break; e++; } p = *e; *e = 0; vecp = saveblk(v); set1(vp, vecp, &shvhed); *e = p; v = e + 1; } else if (hadsub) asx(vp, subscr, savestr(p)); else set(vp, savestr(p)); if (eq(vp, "path")) { exportpath(adrof("path")->vec); dohash(); } else if (eq(vp, "histchars")) { register char *p = value("histchars"); HIST = *p++; HISTSUB = *p; } else if (eq(vp, "user")) setenvv("USER", value(vp)); else if (eq(vp, "term")) setenvv("TERM", value(vp)); else if (eq(vp, "home")) setenvv("HOME", value(vp)); #ifdef FILEC else if (eq(vp, "filec")) filec = 1; #endif } while (p = *v++); } char * getinx(cp, ip) register char *cp; register int *ip; { *ip = 0; *cp++ = 0; while (*cp && digit(*cp)) *ip = *ip * 10 + *cp++ - '0'; if (*cp++ != ']') bferr("Subscript error"); return (cp); } asx(vp, subscr, p) char *vp; int subscr; char *p; { register struct varent *v = getvx(vp, subscr); xfree(v->vec[subscr - 1]); v->vec[subscr - 1] = globone(p); } struct varent * getvx(vp, subscr) char *vp; { register struct varent *v = adrof(vp); if (v == 0) udvar(vp); if (subscr < 1 || subscr > blklen(v->vec)) bferr("Subscript out of range"); return (v); } char plusplus[2] = { '1', 0 }; dolet(v) char **v; { register char *p; char *vp, c, op; bool hadsub; int subscr; v++; p = *v++; if (p == 0) { prvars(); return; } do { hadsub = 0; for (vp = p; alnum(*p); p++) continue; if (vp == p || !letter(*vp)) goto letsyn; if (*p == '[') { hadsub++; p = getinx(p, &subscr); } if (*p == 0 && *v) p = *v++; if (op = *p) *p++ = 0; else goto letsyn; vp = savestr(vp); if (op == '=') { c = '='; p = xset(p, &v); } else { c = *p++; if (any(c, "+-")) { if (c != op || *p) goto letsyn; p = plusplus; } else { if (any(op, "<>")) { if (c != op) goto letsyn; c = *p++; letsyn: bferr("Syntax error"); } if (c != '=') goto letsyn; p = xset(p, &v); } } if (op == '=') if (hadsub) asx(vp, subscr, p); else set(vp, p); else if (hadsub) #ifndef V6 /* avoid bug in vax CC */ { struct varent *gv = getvx(vp, subscr); asx(vp, subscr, operate(op, gv->vec[subscr - 1], p)); } #else asx(vp, subscr, operate(op, getvx(vp, subscr)->vec[subscr - 1], p)); #endif else set(vp, operate(op, value(vp), p)); if (eq(vp, "path")) { exportpath(adrof("path")->vec); dohash(); } XFREE(vp) if (c != '=') XFREE(p) } while (p = *v++); } char * xset(cp, vp) char *cp, ***vp; { register char *dp; if (*cp) { dp = savestr(cp); --(*vp); xfree(**vp); **vp = dp; } return (putn(expr(vp))); } char * operate(op, vp, p) char op, *vp, *p; { char opr[2]; char *vec[5]; register char **v = vec; char **vecp = v; register int i; if (op != '=') { if (*vp) *v++ = vp; opr[0] = op; opr[1] = 0; *v++ = opr; if (op == '<' || op == '>') *v++ = opr; } *v++ = p; *v++ = 0; i = expr(&vecp); if (*vecp) bferr("Expression syntax"); return (putn(i)); } static char *putp; char * putn(n) register int n; { static char number[15]; putp = number; if (n < 0) { n = -n; *putp++ = '-'; } if (sizeof (int) == 2 && n == -32768) { *putp++ = '3'; n = 2768; #ifndef pdp11 } else if (sizeof (int) == 4 && n == -2147483648U) { *putp++ = '2'; n = 147483648; #endif } putn1(n); *putp = 0; return (savestr(number)); } putn1(n) register int n; { if (n > 9) putn1(n / 10); *putp++ = n % 10 + '0'; } getn(cp) register char *cp; { register int n; int sign; sign = 0; if (cp[0] == '+' && cp[1]) cp++; if (*cp == '-') { sign++; cp++; if (!digit(*cp)) goto badnum; } n = 0; while (digit(*cp)) n = n * 10 + *cp++ - '0'; if (*cp) goto badnum; return (sign ? -n : n); badnum: bferr("Badly formed number"); return (0); } char * value1(var, head) char *var; struct varent *head; { register struct varent *vp; vp = adrof1(var, head); return (vp == 0 || vp->vec[0] == 0 ? "" : vp->vec[0]); } struct varent * madrof(pat, vp) char *pat; register struct varent *vp; { register struct varent *vp1; for (; vp; vp = vp->v_right) { if (vp->v_left && (vp1 = madrof(pat, vp->v_left))) return vp1; if (Gmatch(vp->v_name, pat)) return vp; } return vp; } struct varent * adrof1(name, v) register char *name; register struct varent *v; { register cmp; v = v->v_left; while (v && ((cmp = *name - *v->v_name) || (cmp = strcmp(name, v->v_name)))) if (cmp < 0) v = v->v_left; else v = v->v_right; return v; } /* * The caller is responsible for putting value in a safe place */ set(var, val) char *var, *val; { register char **vec = (char **) xalloc(2 * sizeof (char **)); vec[0] = onlyread(val) ? savestr(val) : val; vec[1] = 0; set1(var, vec, &shvhed); } set1(var, vec, head) char *var, **vec; struct varent *head; { register char **oldv = vec; gflag = 0; tglob(oldv); if (gflag) { vec = glob(oldv); if (vec == 0) { bferr("No match"); blkfree(oldv); return; } blkfree(oldv); gargv = 0; } setq(var, vec, head); } setq(name, vec, p) char *name, **vec; register struct varent *p; { register struct varent *c; register f; f = 0; /* tree hangs off the header's left link */ while (c = p->v_link[f]) { if ((f = *name - *c->v_name) == 0 && (f = strcmp(name, c->v_name)) == 0) { blkfree(c->vec); goto found; } p = c; f = f > 0; } p->v_link[f] = c = (struct varent *)xalloc(sizeof (struct varent)); c->v_name = savestr(name); c->v_bal = 0; c->v_left = c->v_right = 0; c->v_parent = p; balance(p, f, 0); found: trim(c->vec = vec); } unset(v) char *v[]; { unset1(v, &shvhed); if (adrof("histchars") == 0) { HIST = '!'; HISTSUB = '^'; } #ifdef FILEC if (adrof("filec") == 0) filec = 0; #endif } unset1(v, head) register char *v[]; struct varent *head; { register struct varent *vp; register int cnt; while (*++v) { cnt = 0; while (vp = madrof(*v, head->v_left)) unsetv1(vp), cnt++; if (cnt == 0) setname(*v); } } unsetv(var) char *var; { register struct varent *vp; if ((vp = adrof1(var, &shvhed)) == 0) udvar(var); unsetv1(vp); } unsetv1(p) register struct varent *p; { register struct varent *c, *pp; register f; /* * Free associated memory first to avoid complications. */ blkfree(p->vec); XFREE(p->v_name); /* * If p is missing one child, then we can move the other * into where p is. Otherwise, we find the predecessor * of p, which is guaranteed to have no right child, copy * it into p, and move it's left child into it. */ if (p->v_right == 0) c = p->v_left; else if (p->v_left == 0) c = p->v_right; else { for (c = p->v_left; c->v_right; c = c->v_right) ; p->v_name = c->v_name; p->vec = c->vec; p = c; c = p->v_left; } /* * Move c into where p is. */ pp = p->v_parent; f = pp->v_right == p; if (pp->v_link[f] = c) c->v_parent = pp; /* * Free the deleted node, and rebalance. */ XFREE((char *)p); balance(pp, f, 1); } setNS(cp) char *cp; { set(cp, ""); } shift(v) register char **v; { register struct varent *argv; register char *name; v++; name = *v; if (name == 0) name = "argv"; else (void) strip(name); argv = adrof(name); if (argv == 0) udvar(name); if (argv->vec[0] == 0) bferr("No more words"); lshift(argv->vec, 1); } exportpath(val) char **val; { char exppath[BUFSIZ]; exppath[0] = 0; if (val) while (*val) { if (strlen(*val) + strlen(exppath) + 2 > BUFSIZ) { printf("Warning: ridiculously long PATH truncated\n"); break; } (void) strcat(exppath, *val++); if (*val == 0 || eq(*val, ")")) break; (void) strcat(exppath, ":"); } setenvv("PATH", exppath); } /* macros to do single rotations on node p */ #define rright(p) (\ t = (p)->v_left,\ (t)->v_parent = (p)->v_parent,\ ((p)->v_left = t->v_right) ? (t->v_right->v_parent = (p)) : 0,\ (t->v_right = (p))->v_parent = t,\ (p) = t) #define rleft(p) (\ t = (p)->v_right,\ (t)->v_parent = (p)->v_parent,\ ((p)->v_right = t->v_left) ? (t->v_left->v_parent = (p)) : 0,\ (t->v_left = (p))->v_parent = t,\ (p) = t) /* * Rebalance a tree, starting at p and up. * F == 0 means we've come from p's left child. * D == 1 means we've just done a delete, otherwise an insert. */ balance(p, f, d) register struct varent *p; register f; { register struct varent *pp; register struct varent *t; /* used by the rotate macros */ register ff; /* * Ok, from here on, p is the node we're operating on; * pp is it's parent; f is the branch of p from which we have come; * ff is the branch of pp which is p. */ for (; pp = p->v_parent; p = pp, f = ff) { ff = pp->v_right == p; if (f ^ d) { /* right heavy */ switch (p->v_bal) { case -1: /* was left heavy */ p->v_bal = 0; break; case 0: /* was balanced */ p->v_bal = 1; break; case 1: /* was already right heavy */ switch (p->v_right->v_bal) { case 1: /* sigle rotate */ pp->v_link[ff] = rleft(p); p->v_left->v_bal = 0; p->v_bal = 0; break; case 0: /* single rotate */ pp->v_link[ff] = rleft(p); p->v_left->v_bal = 1; p->v_bal = -1; break; case -1: /* double rotate */ rright(p->v_right); pp->v_link[ff] = rleft(p); p->v_left->v_bal = p->v_bal < 1 ? 0 : -1; p->v_right->v_bal = p->v_bal > -1 ? 0 : 1; p->v_bal = 0; break; } break; } } else { /* left heavy */ switch (p->v_bal) { case 1: /* was right heavy */ p->v_bal = 0; break; case 0: /* was balanced */ p->v_bal = -1; break; case -1: /* was already left heavy */ switch (p->v_left->v_bal) { case -1: /* single rotate */ pp->v_link[ff] = rright(p); p->v_right->v_bal = 0; p->v_bal = 0; break; case 0: /* signle rotate */ pp->v_link[ff] = rright(p); p->v_right->v_bal = -1; p->v_bal = 1; break; case 1: /* double rotate */ rleft(p->v_left); pp->v_link[ff] = rright(p); p->v_left->v_bal = p->v_bal < 1 ? 0 : -1; p->v_right->v_bal = p->v_bal > -1 ? 0 : 1; p->v_bal = 0; break; } break; } } /* * If from insert, then we terminate when p is balanced. * If from delete, then we terminate when p is unbalanced. */ if ((p->v_bal == 0) ^ d) break; } } plist(p) register struct varent *p; { register struct varent *c; register len; if (setintr) (void) sigsetmask(sigblock(0L) & ~ sigmask(SIGINT)); for (;;) { while (p->v_left) p = p->v_left; x: if (p->v_parent == 0) /* is it the header? */ return; len = blklen(p->vec); printf("%s", p->v_name); putchar('\t'); if (len != 1) putchar('('); blkpr(p->vec); if (len != 1) putchar(')'); putchar('\n'); if (p->v_right) { p = p->v_right; continue; } do { c = p; p = p->v_parent; } while (p->v_right == c); goto x; } } ================================================ FILE: bin/csh/sh.time.c ================================================ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley Software License Agreement * specifies the terms and conditions for redistribution. */ #if !defined(lint) && defined(DOSCCS) static char *sccsid = "@(#)sh.time.c 5.4.1 (2.11BSD GTE) 12/31/93"; #endif #include "sh.h" /* * C Shell - routines handling process timing and niceing */ settimes() { struct rusage ruch; (void) gettimeofday(&time0, (struct timezone *)0); (void) getrusage(RUSAGE_SELF, &ru0); (void) getrusage(RUSAGE_CHILDREN, &ruch); ruadd(&ru0, &ruch); } /* * dotime is only called if it is truly a builtin function and not a * prefix to another command */ dotime() { struct timeval timedol; struct rusage ru1, ruch; (void) getrusage(RUSAGE_SELF, &ru1); (void) getrusage(RUSAGE_CHILDREN, &ruch); ruadd(&ru1, &ruch); (void) gettimeofday(&timedol, (struct timezone *)0); prusage(&ru0, &ru1, &timedol, &time0); } /* * donice is only called when it on the line by itself or with a +- value */ donice(v) register char **v; { register char *cp; int nval; v++, cp = *v++; if (cp == 0) nval = 4; else if (*v == 0 && any(cp[0], "+-")) nval = getn(cp); (void) setpriority(PRIO_PROCESS, 0, nval); } ruadd(ru, ru2) register struct rusage *ru, *ru2; { register long *lp, *lp2; register int cnt; tvadd(&ru->ru_utime, &ru2->ru_utime); tvadd(&ru->ru_stime, &ru2->ru_stime); if (ru2->ru_maxrss > ru->ru_maxrss) ru->ru_maxrss = ru2->ru_maxrss; cnt = &ru->ru_last - &ru->ru_first + 1; lp = &ru->ru_first; lp2 = &ru2->ru_first; do *lp++ += *lp2++; while (--cnt > 0); } prusage(r0, r1, e, b) register struct rusage *r0, *r1; struct timeval *e, *b; { register time_t t = (r1->ru_utime.tv_sec-r0->ru_utime.tv_sec)*100+ (r1->ru_utime.tv_usec-r0->ru_utime.tv_usec)/10000+ (r1->ru_stime.tv_sec-r0->ru_stime.tv_sec)*100+ (r1->ru_stime.tv_usec-r0->ru_stime.tv_usec)/10000; register char *cp; register long i; register struct varent *vp = adrof("time"); long ms = (e->tv_sec-b->tv_sec)*100 + (e->tv_usec-b->tv_usec)/10000; #ifdef pdp11 cp = "%Uu %Ss %E %P %I+%Oio %Vov %Wsw"; #else cp = "%Uu %Ss %E %P %X+%Dk %I+%Oio %Fpf+%Ww"; #endif if (vp && vp->vec[0] && vp->vec[1]) cp = vp->vec[1]; for (; *cp; cp++) if (*cp != '%') putchar(*cp); else if (cp[1]) switch(*++cp) { case 'U': pdeltat(&r1->ru_utime, &r0->ru_utime); break; case 'S': pdeltat(&r1->ru_stime, &r0->ru_stime); break; case 'E': psecs(ms / 100); break; case 'P': printf("%d%%", (int) (t*100 / ((ms ? ms : 1)))); break; #ifdef pdp11 case 'V': printf("%ld", r1->ru_ovly - r0->ru_ovly); break; #endif case 'W': i = r1->ru_nswap - r0->ru_nswap; printf("%ld", i); break; case 'X': printf("%ld", t == 0 ? 0L : (r1->ru_ixrss-r0->ru_ixrss)/t); break; case 'D': printf("%ld", t == 0 ? 0L : (r1->ru_idrss+r1->ru_isrss-(r0->ru_idrss+r0->ru_isrss))/t); break; case 'K': printf("%ld", t == 0 ? 0L : ((r1->ru_ixrss+r1->ru_isrss+r1->ru_idrss) - (r0->ru_ixrss+r0->ru_idrss+r0->ru_isrss))/t); break; case 'M': printf("%ld", r1->ru_maxrss/2); break; case 'F': printf("%ld", r1->ru_majflt-r0->ru_majflt); break; case 'R': printf("%ld", r1->ru_minflt-r0->ru_minflt); break; case 'I': printf("%ld", r1->ru_inblock-r0->ru_inblock); break; case 'O': printf("%ld", r1->ru_oublock-r0->ru_oublock); break; } putchar('\n'); } pdeltat(t1, t0) struct timeval *t1, *t0; { struct timeval td; tvsub(&td, t1, t0); printf("%ld.%01ld", td.tv_sec, td.tv_usec/100000); } tvadd(tsum, t0) struct timeval *tsum, *t0; { tsum->tv_sec += t0->tv_sec; tsum->tv_usec += t0->tv_usec; if (tsum->tv_usec > 1000000) tsum->tv_sec++, tsum->tv_usec -= 1000000; } tvsub(tdiff, t1, t0) struct timeval *tdiff, *t1, *t0; { tdiff->tv_sec = t1->tv_sec - t0->tv_sec; tdiff->tv_usec = t1->tv_usec - t0->tv_usec; if (tdiff->tv_usec < 0) tdiff->tv_sec--, tdiff->tv_usec += 1000000; } ================================================ FILE: bin/date/date.c ================================================ /* * Copyright (c) 1985 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ /* * Date - print and set date */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define ATOI2(ar) (ar[0] - '0') * 10 + (ar[1] - '0'); ar += 2; static struct timeval tv; static int retval; static int dmsize[] = { -1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; static struct utmp wtmp[2] = { { "|", "", "", 0 }, { "{", "", "", 0 } }; /* * gtime -- * convert user's time into number of seconds */ static gtime(ap) register char *ap; /* user argument */ { register int year, month; register char *C; /* pointer into time argument */ struct tm *L; int day, hour, mins, secs; for (secs = 0, C = ap;*C;++C) { if (*C == '.') { /* seconds provided */ if (strlen(C) != 3) return(1); *C = NULL; secs = (C[1] - '0') * 10 + (C[2] - '0'); break; } if (!isdigit(*C)) return(-1); } L = localtime((time_t *)&tv.tv_sec); year = L->tm_year; /* defaults */ month = L->tm_mon + 1; day = L->tm_mday; switch ((int)(C - ap)) { /* length */ case 10: /* yymmddhhmm */ year = ATOI2(ap); case 8: /* mmddhhmm */ month = ATOI2(ap); case 6: /* ddhhmm */ day = ATOI2(ap); case 4: /* hhmm */ hour = ATOI2(ap); mins = ATOI2(ap); break; default: return(1); } if (*ap || month < 1 || month > 12 || day < 1 || day > 31 || mins < 0 || mins > 59 || secs < 0 || secs > 59) return(1); if (hour == 24) { ++day; hour = 0; } else if (hour < 0 || hour > 23) return(1); tv.tv_sec = 0; year += TM_YEAR_BASE; /* If year < EPOCH_YEAR, assume it's in the next century and the system has not yet been patched to move TM_YEAR_BASE up yet */ if (year < EPOCH_YEAR) year += 100; if (isleap(year) && month > 2) ++tv.tv_sec; for (--year;year >= EPOCH_YEAR;--year) tv.tv_sec += isleap(year) ? DAYS_PER_LYEAR : DAYS_PER_NYEAR; while (--month) tv.tv_sec += dmsize[month]; tv.tv_sec += day - 1; tv.tv_sec = HOURS_PER_DAY * tv.tv_sec + hour; tv.tv_sec = MINS_PER_HOUR * tv.tv_sec + mins; tv.tv_sec = SECS_PER_MIN * tv.tv_sec + secs; return(0); } main(argc,argv) int argc; char **argv; { static char usage[] = "usage: date [-nu] [-d dst] [-t timezone] [yymmddhhmm[.ss]]\n"; struct timezone tz; char *ap, /* time string */ *tzn; /* time zone */ int ch, /* getopts char */ uflag, /* do it in GMT */ nflag, /* only set time locally */ wf; /* wtmp file descriptor */ char *username; char do_update = 0; nflag = uflag = 0; tz.tz_dsttime = tz.tz_minuteswest = 0; while ((ch = getopt(argc,argv,"d:nut:")) != EOF) switch((char)ch) { case 'd': tz.tz_dsttime = atoi(optarg) ? 1 : 0; do_update = 1; break; case 'n': nflag = 1; break; case 't': tz.tz_minuteswest = atoi(optarg); do_update = 1; break; case 'u': uflag = 1; break; default: fputs(usage,stderr); exit(1); } argc -= optind; argv += optind; if (argc > 1) { fputs(usage,stderr); exit(1); } if ((do_update==1) && settimeofday((struct timeval *)NULL,&tz)) { perror("settimeofday"); retval = 1; goto display; } if (gettimeofday(&tv,&tz)) { perror("gettimeofday"); exit(1); } if (!argc) goto display; wtmp[0].ut_time = tv.tv_sec; if (gtime(*argv)) { fputs(usage,stderr); retval = 1; goto display; } if (!uflag) { /* convert to GMT assuming local time */ tv.tv_sec += (long)tz.tz_minuteswest * SECS_PER_MIN; /* now fix up local daylight time */ if (localtime((time_t *)&tv.tv_sec)->tm_isdst) tv.tv_sec -= SECS_PER_HOUR; } if (nflag || 1 /*!netsettime(tv)*/) { if (settimeofday(&tv,(struct timezone *)0)) { perror("settimeofday"); retval = 1; goto display; } if ((wf = open(_PATH_WTMP, O_WRONLY | O_APPEND)) < 0) fputs("date: can't write wtmp file.\n",stderr); else { (void)time((time_t *)&wtmp[1].ut_time); /*NOSTRICT*/ (void)write(wf,(char *)wtmp,sizeof(wtmp)); (void)close(wf); } } username = getlogin(); if (!username || *username == '\0') /* single-user or no tty */ username = "root"; syslog(LOG_AUTH | LOG_NOTICE,"date set by %s",username); display: if (gettimeofday(&tv,(struct timezone *)0)) { perror("gettimeofday"); exit(1); } if (uflag) { ap = asctime(gmtime((time_t *)&tv.tv_sec)); tzn = "GMT"; } else { struct tm *tp; tp = localtime((time_t *)&tv.tv_sec); ap = asctime(tp); tzn = tp->tm_zone; } printf("%.20s%s%s",ap,tzn,ap + 19); exit(retval); } ================================================ FILE: bin/date2/.gitignore ================================================ date ================================================ FILE: bin/date2/Makefile ================================================ # # Public Domain. 1995/03/13 - Steven Schultz # TOPSRC!=cd ../..; pwd include ${TOPSRC}/share/mk/sys.mk BIN = date SRCS = $(BIN).c OBJS = $(BIN).o all: $(BIN) $(BIN): ${OBJS} ${CC} ${CFLAGS} ${LDFLAGS} -o $@.elf ${OBJS} ${LIBS} ${OBJDUMP} -S $@.elf > $@.dis ${SIZE} $@.elf ${ELF2AOUT} $@.elf $@ .SUFFIXES: .0 .1 clean: rm -f *.o *.elf ${MAN} *.elf *.dis tags *~ $(BIN) depend: ${SRCS} mkdep ${CFLAGS} ${SRCS} install: all ${INSTALL} -m 755 ${BIN} ${DESTDIR}/bin lint: ${SRCS} lint -hax ${SRCS} tags: ${SRCS} ctags ${SRCS} ================================================ FILE: bin/date2/date.c ================================================ /* * Copyright (c) 1985 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ /* * Date - print and set date */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define ATOI2(ar) (ar[0] - '0') * 10 + (ar[1] - '0'); ar += 2; static struct timeval tv; static int retval; static int dmsize[] = { -1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; static struct utmp wtmp[2] = { { "|", "", "", 0 }, { "{", "", "", 0 } }; /* * gtime -- * convert user's time into number of seconds */ static int gtime(ap) register char *ap; /* user argument */ { register int year, month; register char *C; /* pointer into time argument */ struct tm *L; int day, hour, mins, secs; for (secs = 0, C = ap;*C;++C) { if (*C == '.') { /* seconds provided */ if (strlen(C) != 3) return(1); *C = NULL; secs = (C[1] - '0') * 10 + (C[2] - '0'); break; } if (!isdigit(*C)) return(-1); } L = localtime((time_t *)&tv.tv_sec); year = L->tm_year; /* defaults */ month = L->tm_mon + 1; day = L->tm_mday; switch ((int)(C - ap)) { /* length */ case 10: /* yymmddhhmm */ year = ATOI2(ap); case 8: /* mmddhhmm */ month = ATOI2(ap); case 6: /* ddhhmm */ day = ATOI2(ap); case 4: /* hhmm */ hour = ATOI2(ap); mins = ATOI2(ap); break; default: return(1); } if (*ap || month < 1 || month > 12 || day < 1 || day > 31 || mins < 0 || mins > 59 || secs < 0 || secs > 59) return(1); if (hour == 24) { ++day; hour = 0; } else if (hour < 0 || hour > 23) return(1); tv.tv_sec = 0; year += TM_YEAR_BASE; /* If year < EPOCH_YEAR, assume it's in the next century and the system has not yet been patched to move TM_YEAR_BASE up yet */ if (year < EPOCH_YEAR) year += 100; if (isleap(year) && month > 2) ++tv.tv_sec; for (--year;year >= EPOCH_YEAR;--year) tv.tv_sec += isleap(year) ? DAYS_PER_LYEAR : DAYS_PER_NYEAR; while (--month) tv.tv_sec += dmsize[month]; tv.tv_sec += day - 1; tv.tv_sec = HOURS_PER_DAY * tv.tv_sec + hour; tv.tv_sec = MINS_PER_HOUR * tv.tv_sec + mins; tv.tv_sec = SECS_PER_MIN * tv.tv_sec + secs; return(0); } const char *wday_s[] = {"Sun","Mon","Tue","Wed","Thu","Fri","Sat",0}; const char *wday_l[] = {"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday",0}; const char *month_l[] = {"January","February","March","April","May","June","July","August","September","October","November","December",0}; const char *month_s[] = {"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec",0}; void fmttime(char *fmt, struct tm *tm) { char *p; char temp[10]; for(p=fmt; *p; p++) { switch(*p) { case '%': p++; switch(*p) { case 'd': // Day of the month, 2 digits, leading 0 - 01-31 printf("%02d",tm->tm_mday); break; case 'D': printf("%s",wday_s[tm->tm_wday]); break; case 'j': printf("%d",tm->tm_mday); break; case 'l': printf("%s",wday_l[tm->tm_wday]); break; case 'N': printf("%d",tm->tm_wday == 0 ? 7 : tm->tm_wday); break; case 'S': switch(tm->tm_mday) { case 1: case 21: case 31: printf("st"); break; case 2: case 22: printf("nd"); break; case 3: case 23: printf("rd"); break; default: printf("th"); break; } break; case 'w': printf("%d",tm->tm_wday); break; case 'z': printf("%d",tm->tm_yday); break; case 'F': printf("%s",month_l[tm->tm_mon]); break; case 'm': printf("%02d",tm->tm_mon+1); break; case 'M': printf("%s",month_s[tm->tm_mon]); break; case 'n': printf("%d",tm->tm_mon+1); break; case 't': switch(tm->tm_mon) { case 0: printf("%d",31); break; // Jan case 1: printf("%d",((tm->tm_year+1900) % 4 == 0) ? 29 : 28); break; // Feb case 2: printf("%d",31); break; // Mar case 3: printf("%d",30); break; // Apr case 4: printf("%d",31); break; // May case 5: printf("%d",30); break; // Jun case 6: printf("%d",31); break; // Jul case 7: printf("%d",31); break; // Aug case 8: printf("%d",30); break; // Sep case 9: printf("%d",31); break; // Oct case 10: printf("%d",30); break; // Nov case 11: printf("%d",31); break; // Dec } break; case 'L': printf("%d",((tm->tm_year+1900) % 4 == 0) ? 1 : 0); break; case 'o': case 'Y': printf("%04d",tm->tm_year+1900); break; case 'y': printf("%02d",(tm->tm_year+1900) % 100); break; case 'a': printf("%s",(tm->tm_hour<12) ? "am" : "pm"); break; case 'A': printf("%s",(tm->tm_hour<12) ? "AM" : "PM"); break; case 'g': printf("%d",tm->tm_hour % 12); break; case 'G': printf("%d",tm->tm_hour); break; case 'h': printf("%02d",tm->tm_hour % 12); break; case 'H': printf("%02d",tm->tm_hour); break; case 'i': printf("%02d",tm->tm_min); break; case 's': printf("%02d",tm->tm_sec); break; case 'u': printf("000000"); break; case 'e': printf("%s",tm->tm_zone); break; case 'I': printf("%d",tm->tm_isdst); break; case 'O': printf("%02d%02d",tm->tm_gmtoff/60,tm->tm_gmtoff%60); break; case 'P': printf("%02d:%02d",tm->tm_gmtoff/60,tm->tm_gmtoff%60); break; case 'T': printf("%s",tm->tm_zone); break; /* int tm_sec; int tm_min; int tm_hour; int tm_mday; int tm_mon; int tm_year; int tm_wday; int tm_yday; int tm_isdst; long tm_gmtoff; char *tm_zone; */ default: printf("%c",*p); break; } break; case '\\': p++; switch(*p) { case 'n': printf("\n"); break; case 'r': printf("\r"); break; case 't': printf("\t"); break; default: printf("%c",*p); } break; default: printf("%c",*p); break; } } } int main(argc,argv) int argc; char **argv; { static char usage[] = "usage: date [-nu] [-d dst] [-t timezone] [yymmddhhmm[.ss]]\n"; struct timezone tz; char *ap, /* time string */ *tzn; /* time zone */ int ch, /* getopts char */ uflag, /* do it in GMT */ nflag, /* only set time locally */ wf; /* wtmp file descriptor */ char *username; char do_update = 0; char *fmt = "%D %M %d %H:%i:%s %T %Y\n"; nflag = uflag = 0; tz.tz_dsttime = tz.tz_minuteswest = 0; while ((ch = getopt(argc,argv,"d:nut:f:")) != EOF) switch((char)ch) { case 'd': tz.tz_dsttime = atoi(optarg) ? 1 : 0; do_update = 1; break; case 'n': nflag = 1; break; case 't': tz.tz_minuteswest = atoi(optarg); do_update = 1; break; case 'u': uflag = 1; break; case 'f': fmt = optarg; break; default: fputs(usage,stderr); exit(1); } argc -= optind; argv += optind; if (argc > 1) { fputs(usage,stderr); exit(1); } if ((do_update==1) && settimeofday((struct timeval *)NULL,&tz)) { perror("settimeofday"); retval = 1; goto display; } if (gettimeofday(&tv,&tz)) { perror("gettimeofday"); exit(1); } if (!argc) goto display; wtmp[0].ut_time = tv.tv_sec; if (gtime(*argv)) { fputs(usage,stderr); retval = 1; goto display; } if (!uflag) { /* convert to GMT assuming local time */ tv.tv_sec += (long)tz.tz_minuteswest * SECS_PER_MIN; /* now fix up local daylight time */ if (localtime((time_t *)&tv.tv_sec)->tm_isdst) tv.tv_sec -= SECS_PER_HOUR; } if (nflag || 1 /*!netsettime(tv)*/) { if (settimeofday(&tv,(struct timezone *)0)) { perror("settimeofday"); retval = 1; goto display; } if ((wf = open(_PATH_WTMP, O_WRONLY | O_APPEND)) < 0) fputs("date: can't write wtmp file.\n",stderr); else { (void)time((time_t *)&wtmp[1].ut_time); /*NOSTRICT*/ (void)write(wf,(char *)wtmp,sizeof(wtmp)); (void)close(wf); } } username = getlogin(); if (!username || *username == '\0') /* single-user or no tty */ username = "root"; syslog(LOG_AUTH | LOG_NOTICE,"date set by %s",username); display: if (gettimeofday(&tv,(struct timezone *)0)) { perror("gettimeofday"); exit(1); } if (uflag) { fmttime(fmt,gmtime((time_t *)&tv.tv_sec)); } else { struct tm *tp; tp = localtime((time_t *)&tv.tv_sec); fmttime(fmt,tp); } exit(retval); } ================================================ FILE: distrib/.gitignore ================================================ obj ================================================ FILE: distrib/base/mi ================================================ # # Machine independent root file system manifest file. # default owner 0 group 0 dirmode 0775 filemode 0664 # # Directories. # dir /bin dir /dev dir /etc dir /sbin dir /tmp dir /usr dir /home dir /usr/bin dir /usr/sbin dir /usr/libexec # # Block devices. # # Major Minor Name Device # ------------------------- # 0 0 sd0 Main SD card # 0 1 sd0a Partition 1: root file system # 0 2 sd0b Partition 2: swap space # 0 3 sd0c Partition 3 # 0 4 sd0d Partition 4 # 0 8 sd1 Second SD card # 0 9 sd1a Partition 1 # 0 10 sd1b Partition 2 # 0 11 sd1c Partition 3 # 0 12 sd1d Partition 4 # 1 0 rc0 Volatile disk - SRAM connected via CPLD (sramc) # 1 1 rc0a Partition 1: filesystem # 1 2 rc0b Partition 2: swap space # 2 0 dr0 Volatile disk - SDRAM on external memory bus (sdramp) # 2 1 dr0a Partition 1: filesystem # 2 2 dr0b Partition 2: swap space # 3 0 mr0 Volatile disk - MRAM on SPI port (mrams) # 4 64 swap Virtual swap device, mapped to real swap partition # 4 0 swap0 Virtual i/o area, allocated from swap space # 4 1 swap1 Virtual i/o area, allocated from swap space # 4 2 swap2 Virtual i/o area, allocated from swap space # 5 0 sr0 Volatile disk - serial RAM on SPI port (spirams) # bdev /dev/sd0 major 0 # Main SD card minor 0 bdev /dev/sd0a major 0 minor 1 bdev /dev/sd0b major 0 minor 2 bdev /dev/sd0c major 0 minor 3 bdev /dev/sd0d major 0 minor 4 bdev /dev/sd1 major 0 # Second SD card minor 8 bdev /dev/sd1a major 0 minor 9 bdev /dev/sd1b major 0 minor 10 bdev /dev/sd1c major 0 minor 11 bdev /dev/sd1d major 0 minor 12 bdev /dev/rc0 major 1 # Volatile disk - SRAM connected via CPLD (sramc) minor 0 bdev /dev/rc0a major 1 minor 1 bdev /dev/rc0b major 1 minor 2 bdev /dev/dr0 major 2 # Volatile disk - SDRAM on external memory bus (sdramp) minor 0 bdev /dev/dr0a major 2 minor 1 bdev /dev/dr0b major 2 minor 2 bdev /dev/mr0 major 3 # Volatile disk - MRAM on SPI port (mrams) minor 0 bdev /dev/swap major 4 # Virtual swap device, mapped to real swap partition minor 64 bdev /dev/swap0 major 4 minor 0 bdev /dev/swap1 major 4 minor 1 bdev /dev/swap2 major 4 minor 2 bdev /dev/sr0 major 5 # Volatile disk - serial RAM on SPI port (spirams) minor 0 # # Character devices. # cdev /dev/console major 0 minor 0 cdev /dev/mem major 1 minor 0 cdev /dev/kmem major 1 minor 1 cdev /dev/null major 1 minor 2 mode 666 cdev /dev/zero major 1 minor 3 mode 666 cdev /dev/tty major 2 minor 0 mode 666 cdev /dev/stdin major 3 minor 0 cdev /dev/stdout major 3 minor 1 cdev /dev/stderr major 3 minor 2 cdev /dev/temp0 major 4 minor 0 cdev /dev/temp1 major 4 minor 1 cdev /dev/temp2 major 4 minor 2 cdev /dev/klog major 5 minor 0 # # UART driver. # cdev /dev/tty0 major 6 minor 0 cdev /dev/tty1 major 6 minor 1 cdev /dev/tty2 major 6 minor 2 cdev /dev/tty3 major 6 minor 3 cdev /dev/tty4 major 6 minor 4 cdev /dev/tty5 major 6 minor 5 # # USB serial driver. # cdev /dev/ttyUSB0 major 7 minor 0 # # Pseudo-terminals. # cdev /dev/ttyp0 major 8 minor 0 cdev /dev/ttyp1 major 8 minor 1 cdev /dev/ttyp2 major 8 minor 2 cdev /dev/ttyp3 major 8 minor 3 cdev /dev/ptyp0 major 9 minor 0 cdev /dev/ptyp1 major 9 minor 1 cdev /dev/ptyp2 major 9 minor 2 cdev /dev/ptyp3 major 9 minor 3 # # GPIO driver. # cdev /dev/porta major 10 minor 0 cdev /dev/portb major 10 minor 1 cdev /dev/portc major 10 minor 2 cdev /dev/portd major 10 minor 3 cdev /dev/porte major 10 minor 4 cdev /dev/portf major 10 minor 5 cdev /dev/portg major 10 minor 6 cdev /dev/confa major 10 minor 64 cdev /dev/confb major 10 minor 65 cdev /dev/confc major 10 minor 66 cdev /dev/confd major 10 minor 67 cdev /dev/confe major 10 minor 68 cdev /dev/conff major 10 minor 69 cdev /dev/confg major 10 minor 70 # # ADC driver. # cdev /dev/adc0 major 11 minor 0 cdev /dev/adc1 major 11 minor 1 cdev /dev/adc2 major 11 minor 2 cdev /dev/adc3 major 11 minor 3 cdev /dev/adc4 major 11 minor 4 cdev /dev/adc5 major 11 minor 5 cdev /dev/adc6 major 11 minor 6 cdev /dev/adc7 major 11 minor 7 cdev /dev/adc8 major 11 minor 8 cdev /dev/adc9 major 11 minor 9 cdev /dev/adc10 major 11 minor 10 cdev /dev/adc11 major 11 minor 11 cdev /dev/adc12 major 11 minor 12 cdev /dev/adc13 major 11 minor 13 cdev /dev/adc14 major 11 minor 14 cdev /dev/adc15 major 11 minor 15 # # SPI driver. # cdev /dev/spi1 major 12 minor 0 cdev /dev/spi2 major 12 minor 1 cdev /dev/spi3 major 12 minor 2 cdev /dev/spi4 major 12 minor 3 # # GLCD driver. # cdev /dev/glcd0 major 13 minor 0 # # PWM driver. # cdev /dev/pwm1 major 14 minor 0 cdev /dev/pwm2 major 14 minor 1 cdev /dev/pwm3 major 14 minor 2 cdev /dev/pwm4 major 14 minor 3 cdev /dev/pwm5 major 14 minor 4 # # PICGA driver. # cdev /dev/picga0 major 15 minor 0 # # TFT display driver. # cdev /dev/tft0 major 16 minor 0 cdev /dev/tftin0 major 16 minor 1 # # Skeleton driver. # cdev /dev/skel1 major 17 minor 0 cdev /dev/skel2 major 17 minor 1 cdev /dev/skel3 major 17 minor 2 cdev /dev/skel4 major 17 minor 3 cdev /dev/skel5 major 17 minor 4 # # Files: /root # dir /root file /root/.profile symlink /.profile target root/.profile # # Files: /etc # file /etc/fstab file /etc/gettytab file /etc/group file /etc/MAKEDEV mode 0775 file /etc/motd file /etc/passwd file /etc/phones file /etc/rc mode 0775 file /etc/rc.local mode 0775 file /etc/remote file /etc/shadow file /etc/shells file /etc/termcap mode 0444 file /etc/ttys symlink /etc/localtime target /usr/share/zoneinfo/Canada/Mountain # # Files: /bin # default filemode 0775 file /usr/bin/aout file /usr/bin/apropos file /usr/bin/ar file /usr/bin/arch file /usr/bin/as file /usr/bin/awk file /usr/bin/basename file /usr/bin/basic file /usr/bin/bc file /usr/bin/cal file /usr/bin/calendar file /bin/cat file /usr/bin/cb file /usr/bin/cc file /usr/bin/chat-server file /usr/bin/chflags file /bin/chgrp file /bin/chmod file /usr/bin/chpass mode 04755 file /usr/bin/cmp file /usr/bin/col file /usr/bin/comm file /usr/bin/compress file /bin/cp file /usr/bin/cpp file /usr/bin/crontab file /bin/date file /usr/bin/dc file /bin/dd file /bin/df mode 02755 file /usr/bin/diff file /usr/bin/diskspeed file /usr/bin/du file /bin/echo file /bin/ed file /usr/bin/egrep file /usr/bin/emg file /usr/bin/env file /bin/expr file /usr/bin/false file /usr/bin/fgrep file /usr/bin/file file /usr/bin/find file /usr/bin/fold file /usr/bin/forth file /usr/bin/fstat mode 02755 file /usr/bin/glcdtest file /usr/bin/globdump file /usr/bin/globread file /usr/bin/globwrite file /usr/bin/grep file /usr/bin/groups file /usr/bin/head file /usr/bin/hostid file /bin/hostname file /usr/bin/id file /usr/bin/install file /usr/sbin/iostat mode 02755 file /usr/bin/join file /bin/kill file /usr/bin/la file /usr/bin/last file /usr/bin/lcc file /usr/bin/lcpp file /usr/bin/ld file /bin/ln file /usr/bin/login mode 04755 file /usr/bin/lol file /bin/ls file /usr/bin/m4 file /usr/bin/mail mode 04755 file /usr/bin/make file /usr/bin/man file /bin/md5 file /usr/bin/med file /usr/bin/mesg file /bin/mkdir file /usr/bin/more file /usr/bin/msec file /bin/mv file /usr/bin/nice file /usr/bin/nm file /usr/bin/nohup file /usr/bin/ntpdate file /usr/bin/od file /usr/bin/pagesize file /usr/bin/passwd mode 04755 file /usr/bin/pdc file /usr/bin/picoc file /usr/bin/portio file /usr/bin/pr file /usr/bin/printenv file /usr/bin/printf file /bin/ps mode 02755 file /bin/pwd file /usr/bin/pwm file /usr/bin/ranlib file /usr/bin/re file /usr/bin/renice file /usr/bin/renumber file /usr/bin/retroforth file /usr/bin/rev file /bin/rm file /bin/rmail file /bin/rmdir file /usr/bin/rz file /usr/bin/scc file /usr/bin/scm file /usr/bin/sed file /usr/bin/setty file /bin/sh file /usr/bin/size file /usr/bin/sl file /bin/sleep file /usr/bin/smux file /usr/bin/sort file /usr/bin/split file /usr/bin/strip file /bin/stty file /usr/bin/su mode 04755 file /usr/bin/sum file /bin/sync file /sbin/sysctl file /usr/bin/sz file /usr/bin/tail file /bin/tar file /usr/bin/tclsh file /usr/bin/tee file /usr/bin/telnet file /bin/test file /usr/bin/time file /usr/bin/tip file /usr/bin/touch file /usr/bin/tr file /usr/bin/true file /usr/bin/tsort file /usr/bin/tty file /usr/bin/uname file /usr/bin/uncompress file /usr/bin/uniq file /usr/bin/uucico file /usr/bin/uuclean file /usr/bin/uucp file /usr/bin/uudecode file /usr/bin/uuencode file /usr/bin/uulog file /usr/bin/uuname file /usr/bin/uupoll file /usr/bin/uuq file /usr/bin/uusend file /usr/bin/uusnap file /usr/bin/uux file /usr/bin/uuxqt file /usr/bin/vi file /usr/bin/vmstat mode 02755 file /usr/bin/w file /usr/bin/wall mode 02755 file /usr/bin/wc file /usr/bin/web-client file /usr/bin/web-server file /usr/bin/whereis file /usr/bin/who file /usr/bin/whoami file /usr/bin/write mode 02755 file /usr/bin/xargs file /usr/bin/yacc file /usr/bin/zcat link /bin/[ target /bin/test link /usr/bin/whatis target /usr/bin/apropos link /usr/bin/chfn target /usr/bin/chpass link /usr/bin/chsh target /usr/bin/chpass link /usr/bin/rb target /usr/bin/rz link /usr/bin/rx target /usr/bin/rz link /usr/bin/sb target /usr/bin/sz link /usr/bin/sx target /usr/bin/sz link /usr/bin/machine target /usr/bin/arch link /usr/bin/uptime target /usr/bin/w # # Files: /sbin # file /sbin/chown file /usr/sbin/chroot mode 04755 file /usr/sbin/cron file /usr/sbin/disktool file /sbin/fdisk file /sbin/fsck file /sbin/init mode 0700 file /sbin/mkfs file /sbin/mknod file /usr/sbin/mkpasswd file /sbin/mount file /usr/sbin/pstat mode 02755 file /sbin/reboot file /sbin/shutdown mode 04750 file /usr/sbin/talloc file /sbin/umount file /usr/sbin/update file /usr/libexec/updatedb file /usr/sbin/vipw link /sbin/bootloader target /sbin/reboot link /sbin/fastboot target /sbin/reboot link /sbin/halt target /sbin/reboot link /sbin/poweroff target /sbin/reboot # # Files: /usr/games # default filemode 0775 dir /usr/games file /usr/games/adventure file /usr/games/aclock file /usr/games/arithmetic file /usr/games/atc file /usr/games/backgammon file /usr/games/banner file /usr/games/battlestar file /usr/games/bcd file /usr/games/boggle file /usr/games/btlgammon file /usr/games/caesar file /usr/games/canfield file /usr/games/cfscores file /usr/games/cribbage file /usr/games/factor file /usr/games/fish file /usr/games/fortune file /usr/games/hangman file /usr/games/mille file /usr/games/monop file /usr/games/morse file /usr/games/number file /usr/games/pig file /usr/games/pom file /usr/games/ppt file /usr/games/primes file /usr/games/quiz file /usr/games/rain file /usr/games/robots file /usr/games/rogue file /usr/games/sail file /usr/games/snake file /usr/games/snscore file /usr/games/teachgammon file /usr/games/trek file /usr/games/worm file /usr/games/worms file /usr/games/wump # # Files: /usr/games/lib # default filemode 0444 dir /usr/games/lib file /usr/games/lib/adventure.dat file /usr/games/lib/battle_strings file /usr/games/lib/backrules file /usr/games/lib/bogdict file /usr/games/lib/cfscores file /usr/games/lib/crib.instr mode 0666 file /usr/games/lib/fortunes.dat file /usr/games/lib/cards.pck file /usr/games/lib/robots_roll mode 0666 file /usr/games/lib/snakerawscores mode 0666 dir /usr/games/lib/atc file /usr/games/lib/atc/ATC_scores file /usr/games/lib/atc/crossover file /usr/games/lib/atc/default file /usr/games/lib/atc/easy file /usr/games/lib/atc/game_2 file /usr/games/lib/atc/Game_List file /usr/games/lib/atc/Killer dir /usr/games/lib/quiz.k file /usr/games/lib/quiz.k/africa file /usr/games/lib/quiz.k/america file /usr/games/lib/quiz.k/areas file /usr/games/lib/quiz.k/arith file /usr/games/lib/quiz.k/asia file /usr/games/lib/quiz.k/babies file /usr/games/lib/quiz.k/bard file /usr/games/lib/quiz.k/chinese file /usr/games/lib/quiz.k/collectives file /usr/games/lib/quiz.k/ed file /usr/games/lib/quiz.k/elements file /usr/games/lib/quiz.k/europe file /usr/games/lib/quiz.k/greek file /usr/games/lib/quiz.k/inca file /usr/games/lib/quiz.k/index file /usr/games/lib/quiz.k/latin file /usr/games/lib/quiz.k/locomotive file /usr/games/lib/quiz.k/midearth file /usr/games/lib/quiz.k/morse file /usr/games/lib/quiz.k/murders file /usr/games/lib/quiz.k/poetry file /usr/games/lib/quiz.k/posneg file /usr/games/lib/quiz.k/pres file /usr/games/lib/quiz.k/province file /usr/games/lib/quiz.k/seq-easy file /usr/games/lib/quiz.k/seq-hard file /usr/games/lib/quiz.k/sexes file /usr/games/lib/quiz.k/sov file /usr/games/lib/quiz.k/spell file /usr/games/lib/quiz.k/state file /usr/games/lib/quiz.k/trek file /usr/games/lib/quiz.k/ucc # # Files: /usr/include # default filemode 0664 dir /usr/include dir /usr/include/arpa dir /usr/include/machine dir /usr/include/readline dir /usr/include/smallc dir /usr/include/smallc/sys dir /usr/include/sys file /usr/include/alloca.h file /usr/include/a.out.h file /usr/include/ar.h file /usr/include/arpa/inet.h file /usr/include/assert.h file /usr/include/ctype.h file /usr/include/curses.h file /usr/include/fcntl.h file /usr/include/float.h file /usr/include/fstab.h file /usr/include/grp.h file /usr/include/kmem.h file /usr/include/lastlog.h file /usr/include/libgen.h file /usr/include/limits.h file /usr/include/math.h file /usr/include/mtab.h file /usr/include/ndbm.h file /usr/include/nlist.h file /usr/include/paths.h file /usr/include/psout.h file /usr/include/pwd.h file /usr/include/ranlib.h file /usr/include/readline/history.h file /usr/include/readline/readline.h file /usr/include/regexp.h file /usr/include/setjmp.h file /usr/include/sgtty.h file /usr/include/smallc/curses.h file /usr/include/smallc/fcntl.h file /usr/include/smallc/signal.h file /usr/include/smallc/stdio.h file /usr/include/smallc/sys/gpio.h file /usr/include/smallc/sys/spi.h file /usr/include/smallc/wiznet.h file /usr/include/stdarg.h file /usr/include/stdbool.h file /usr/include/stddef.h file /usr/include/stdio.h file /usr/include/stdlib.h file /usr/include/string.h file /usr/include/strings.h file /usr/include/struct.h file /usr/include/sys/buf.h file /usr/include/syscall.h file /usr/include/sys/callout.h file /usr/include/sys/clist.h file /usr/include/sys/conf.h file /usr/include/sys/dir.h file /usr/include/sys/disk.h file /usr/include/sys/dkbad.h file /usr/include/sys/dk.h file /usr/include/sys/errno.h file /usr/include/sys/exec_aout.h file /usr/include/sys/exec_elf.h file /usr/include/sys/exec.h file /usr/include/sysexits.h file /usr/include/sys/fcntl.h file /usr/include/sys/file.h file /usr/include/sys/fs.h file /usr/include/sys/glcd.h file /usr/include/sys/glob.h file /usr/include/sys/gpanel.h file /usr/include/sys/gpio.h file /usr/include/sys/inode.h file /usr/include/sys/ioctl.h file /usr/include/sys/kernel.h file /usr/include/sys/map.h file /usr/include/sys/mount.h file /usr/include/sys/msgbuf.h file /usr/include/sys/mtio.h file /usr/include/sys/namei.h file /usr/include/sys/pwm.h file /usr/include/sys/param.h file /usr/include/sys/picga.h file /usr/include/sys/proc.h file /usr/include/sys/ptrace.h file /usr/include/sys/pty.h file /usr/include/sys/reboot.h file /usr/include/sys/resource.h file /usr/include/sys/select.h file /usr/include/sys/signal.h file /usr/include/sys/signalvar.h file /usr/include/sys/spi.h file /usr/include/sys/stat.h file /usr/include/sys/stdint.h file /usr/include/sys/swap.h file /usr/include/sys/sysctl.h file /usr/include/sys/syslimits.h file /usr/include/sys/syslog.h file /usr/include/sys/systm.h file /usr/include/sys/time.h file /usr/include/sys/times.h file /usr/include/sys/ttychars.h file /usr/include/sys/ttydev.h file /usr/include/sys/tty.h file /usr/include/sys/types.h file /usr/include/sys/uio.h file /usr/include/sys/user.h file /usr/include/sys/utsname.h file /usr/include/sys/vm.h file /usr/include/sys/vmmac.h file /usr/include/sys/vmmeter.h file /usr/include/sys/vmparam.h file /usr/include/sys/vmsystm.h file /usr/include/sys/wait.h file /usr/include/term.h file /usr/include/time.h file /usr/include/ttyent.h file /usr/include/tzfile.h file /usr/include/unistd.h file /usr/include/utmp.h file /usr/include/vmf.h symlink /usr/include/errno.h target sys/errno.h symlink /usr/include/signal.h target sys/signal.h symlink /usr/include/stdint.h target sys/stdint.h symlink /usr/include/syslog.h target sys/syslog.h # # Files: /usr/lib # dir /usr/lib file /usr/lib/crt0.o file /usr/lib/libc.a file /usr/lib/libm.a file /usr/lib/libcurses.a file /usr/lib/libgpanel.a file /usr/lib/libreadline.a file /usr/lib/libtermlib.a file /usr/lib/libwiznet.a file /usr/lib/retroImage # # Files: /usr/libexec # default filemode 0775 dir /usr/libexec file /usr/libexec/bigram file /usr/libexec/code file /usr/libexec/diffh file /usr/libexec/getty file /usr/libexec/smallc # # Files: /usr/share # default filemode 0444 dir /usr/share dir /usr/share/calendar dir /usr/share/dict dir /usr/share/misc dir /usr/share/zoneinfo dir /usr/share/zoneinfo/Australia dir /usr/share/zoneinfo/Canada dir /usr/share/zoneinfo/SystemV dir /usr/share/zoneinfo/US file /usr/share/calendar/calendar.birthday file /usr/share/calendar/calendar.christian file /usr/share/calendar/calendar.computer file /usr/share/calendar/calendar.history file /usr/share/calendar/calendar.holiday file /usr/share/calendar/calendar.judaic file /usr/share/calendar/calendar.music file /usr/share/calendar/calendar.usholiday file /usr/share/misc/emg.keys file /usr/share/misc/re.help file /usr/share/dict/words file /usr/share/misc/lib.b file /usr/share/misc/more.help file /usr/share/misc/termcap mode 0444 file /usr/share/misc/yaccpar file /usr/share/zoneinfo/Australia/North file /usr/share/zoneinfo/Australia/NSW file /usr/share/zoneinfo/Australia/Queensland file /usr/share/zoneinfo/Australia/South file /usr/share/zoneinfo/Australia/Tasmania file /usr/share/zoneinfo/Australia/Victoria file /usr/share/zoneinfo/Australia/West file /usr/share/zoneinfo/Canada/Atlantic file /usr/share/zoneinfo/Canada/Central file /usr/share/zoneinfo/Canada/Eastern file /usr/share/zoneinfo/Canada/Mountain file /usr/share/zoneinfo/Canada/Newfoundland file /usr/share/zoneinfo/Canada/Pacific file /usr/share/zoneinfo/Canada/Yukon file /usr/share/zoneinfo/CET file /usr/share/zoneinfo/CST6CDT file /usr/share/zoneinfo/EET file /usr/share/zoneinfo/EST file /usr/share/zoneinfo/EST5EDT file /usr/share/zoneinfo/GMT-12 file /usr/share/zoneinfo/GMT-11 file /usr/share/zoneinfo/GMT-10 file /usr/share/zoneinfo/GMT-9 file /usr/share/zoneinfo/GMT-8 file /usr/share/zoneinfo/GMT-7 file /usr/share/zoneinfo/GMT-6 file /usr/share/zoneinfo/GMT-5 file /usr/share/zoneinfo/GMT-4 file /usr/share/zoneinfo/GMT-3 file /usr/share/zoneinfo/GMT-2 file /usr/share/zoneinfo/GMT-1 file /usr/share/zoneinfo/GMT file /usr/share/zoneinfo/GMT+1 file /usr/share/zoneinfo/GMT+2 file /usr/share/zoneinfo/GMT+3 file /usr/share/zoneinfo/GMT+4 file /usr/share/zoneinfo/GMT+5 file /usr/share/zoneinfo/GMT+6 file /usr/share/zoneinfo/GMT+7 file /usr/share/zoneinfo/GMT+8 file /usr/share/zoneinfo/GMT+9 file /usr/share/zoneinfo/GMT+10 file /usr/share/zoneinfo/GMT+11 file /usr/share/zoneinfo/GMT+12 file /usr/share/zoneinfo/GMT+13 file /usr/share/zoneinfo/Greenwich file /usr/share/zoneinfo/HST file /usr/share/zoneinfo/Japan file /usr/share/zoneinfo/MST file /usr/share/zoneinfo/MST7MDT file /usr/share/zoneinfo/NZ file /usr/share/zoneinfo/PST8PDT file /usr/share/zoneinfo/Singapore file /usr/share/zoneinfo/SystemV/AST4 file /usr/share/zoneinfo/SystemV/AST4ADT file /usr/share/zoneinfo/SystemV/CST6 file /usr/share/zoneinfo/SystemV/CST6CDT file /usr/share/zoneinfo/SystemV/EST5 file /usr/share/zoneinfo/SystemV/EST5EDT file /usr/share/zoneinfo/SystemV/HST10 file /usr/share/zoneinfo/SystemV/MST7 file /usr/share/zoneinfo/SystemV/MST7MDT file /usr/share/zoneinfo/SystemV/PST8 file /usr/share/zoneinfo/SystemV/PST8PDT file /usr/share/zoneinfo/SystemV/YST9 file /usr/share/zoneinfo/SystemV/YST9YDT file /usr/share/zoneinfo/Turkey file /usr/share/zoneinfo/UCT file /usr/share/zoneinfo/Universal file /usr/share/zoneinfo/US/Arizona file /usr/share/zoneinfo/US/Central file /usr/share/zoneinfo/US/Eastern file /usr/share/zoneinfo/US/East-Indiana file /usr/share/zoneinfo/US/Hawaii file /usr/share/zoneinfo/US/Mountain file /usr/share/zoneinfo/US/Pacific file /usr/share/zoneinfo/US/Pacific-New file /usr/share/zoneinfo/US/Yukon file /usr/share/zoneinfo/UTC file /usr/share/zoneinfo/WET file /usr/share/zoneinfo/W-SU # # Files: /usr/share/examples/asm # default filemode 0664 dir /usr/share/examples dir /usr/share/examples/asm file /usr/share/examples/asm/Makefile file /usr/share/examples/asm/ashello.S file /usr/share/examples/asm/echo.S # # Files: /usr/share/examples/basic # dir /usr/share/examples/basic file /usr/share/examples/basic/blkjack.bas file /usr/share/examples/basic/hilow.bas file /usr/share/examples/basic/stars.bas # # Files: /usr/share/examples/forth # dir /usr/share/examples/forth file /usr/share/examples/forth/fact.fth # # Files: /usr/share/examples/scheme # dir /usr/share/examples/scheme file /usr/share/examples/scheme/prime.scm # # Files: /usr/share/examples/c # dir /usr/share/examples/c file /usr/share/examples/c/Makefile file /usr/share/examples/c/adc.c file /usr/share/examples/c/gpio.c file /usr/share/examples/c/hello.c file /usr/share/examples/c/lcd6.c file /usr/share/examples/c/primelist.c file /usr/share/examples/c/primesum.c file /usr/share/examples/c/q8.c file /usr/share/examples/c/rain.c file /usr/share/examples/c/skeleton.c file /usr/share/examples/c/stdarg.c file /usr/share/examples/c/test1.c file /usr/share/examples/c/test2.c file /usr/share/examples/c/test3.c file /usr/share/examples/c/tetris.c # # Files: /usr/share/examples/gpanel # dir /usr/share/examples/gpanel dir /usr/share/examples/gpanel/fonts file /usr/share/examples/gpanel/Makefile file /usr/share/examples/gpanel/circle.c file /usr/share/examples/gpanel/color.c file /usr/share/examples/gpanel/fill.c file /usr/share/examples/gpanel/flappy.c file /usr/share/examples/gpanel/font.c file /usr/share/examples/gpanel/line.c file /usr/share/examples/gpanel/pixel.c file /usr/share/examples/gpanel/rect.c file /usr/share/examples/gpanel/speed.c file /usr/share/examples/gpanel/tft.c file /usr/share/examples/gpanel/tftetris.c file /usr/share/examples/gpanel/fonts/5x7.c file /usr/share/examples/gpanel/fonts/6x9.c file /usr/share/examples/gpanel/fonts/digits20.c file /usr/share/examples/gpanel/fonts/digits32.c file /usr/share/examples/gpanel/fonts/lucidasans11.c file /usr/share/examples/gpanel/fonts/lucidasans15.c file /usr/share/examples/gpanel/fonts/lucidasans28.c file /usr/share/examples/gpanel/fonts/lucidasans7.c file /usr/share/examples/gpanel/fonts/lucidasans9.c file /usr/share/examples/gpanel/fonts/verdana7.c # # Files: /usr/share/examples/smallc # dir /usr/share/examples/smallc file /usr/share/examples/smallc/Makefile file /usr/share/examples/smallc/adc.c file /usr/share/examples/smallc/gpio.c file /usr/share/examples/smallc/hello.c file /usr/share/examples/smallc/primelist.c file /usr/share/examples/smallc/primesum.c file /usr/share/examples/smallc/q8.c file /usr/share/examples/smallc/rain.c file /usr/share/examples/smallc/test1.c file /usr/share/examples/smallc/test2.c file /usr/share/examples/smallc/test3.c file /usr/share/examples/smallc/webserver.c # # Files: /usr/share/examples/sensors # dir /usr/share/examples/sensors file /usr/share/examples/sensors/Makefile file /usr/share/examples/sensors/README.txt file /usr/share/examples/sensors/buzzer.c file /usr/share/examples/sensors/buzzer.sh file /usr/share/examples/sensors/irled.c file /usr/share/examples/sensors/joystick.c file /usr/share/examples/sensors/laser.c file /usr/share/examples/sensors/laser.sh file /usr/share/examples/sensors/led2.c file /usr/share/examples/sensors/led2-portio.sh file /usr/share/examples/sensors/led2.sh file /usr/share/examples/sensors/led3.c file /usr/share/examples/sensors/led3-portio.sh file /usr/share/examples/sensors/led3.sh file /usr/share/examples/sensors/led7.c file /usr/share/examples/sensors/pbuzz.c file /usr/share/examples/sensors/relay.c file /usr/share/examples/sensors/relay.sh # # Files: /usr/share/examples/cube # dir /usr/share/examples/cube file /usr/share/examples/cube/Makefile file /usr/share/examples/cube/README.txt file /usr/share/examples/cube/all.c file /usr/share/examples/cube/backlight.c file /usr/share/examples/cube/cube.c file /usr/share/examples/cube/cube.h file /usr/share/examples/cube/demo.c file /usr/share/examples/cube/fubarino.c file /usr/share/examples/cube/duinomite.c # # Files: /usr/share/examples/curses # dir /usr/share/examples/curses file /usr/share/examples/curses/Makefile file /usr/share/examples/curses/flip.c file /usr/share/examples/curses/jump.c file /usr/share/examples/curses/timer.c file /usr/share/examples/curses/typetext.c # # Files: /usr/share/examples/dhrystone # dir /usr/share/examples/dhrystone file /usr/share/examples/dhrystone/dhry_2.c file /usr/share/examples/dhrystone/VARIATIONS file /usr/share/examples/dhrystone/README file /usr/share/examples/dhrystone/dhry.h file /usr/share/examples/dhrystone/README_C file /usr/share/examples/dhrystone/Makefile file /usr/share/examples/dhrystone/dhry_1.c file /usr/share/examples/dhrystone/RATIONALE # # Files: /usr/share/examples/yacc # dir /usr/share/examples/yacc file /usr/share/examples/yacc/Makefile file /usr/share/examples/yacc/config.y file /usr/share/examples/yacc/cpy.y file /usr/share/examples/yacc/egrep.y file /usr/share/examples/yacc/expr.y file /usr/share/examples/yacc/gram.y file /usr/share/examples/yacc/grammar.y file /usr/share/examples/yacc/parser.y # # Files: /var # dir /var dir /var/lock dir /var/log dir /var/run file /var/log/messages file /var/log/wtmp # # Files: /var/cron # default dirmode 0700 dir /var/cron dir /var/cron/tabs # # Files: /usr/share/man # default dirmode 0775 dir /usr/share/man dir /usr/share/man/cat1 dir /usr/share/man/cat2 dir /usr/share/man/cat3 dir /usr/share/man/cat4 dir /usr/share/man/cat5 dir /usr/share/man/cat6 dir /usr/share/man/cat7 dir /usr/share/man/cat8 dir /usr/share/man/cat9 # # Single pages # file /usr/share/man/cat1/addbib.0 file /usr/share/man/cat1/apply.0 file /usr/share/man/cat1/apropos.0 file /usr/share/man/cat1/ar.0 file /usr/share/man/cat1/arch.0 file /usr/share/man/cat1/as.0 file /usr/share/man/cat1/at.0 file /usr/share/man/cat1/atq.0 file /usr/share/man/cat1/atrm.0 file /usr/share/man/cat1/awk.0 file /usr/share/man/cat1/basename.0 file /usr/share/man/cat1/bc.0 file /usr/share/man/cat1/biff.0 file /usr/share/man/cat1/binmail.0 file /usr/share/man/cat1/cal.0 file /usr/share/man/cat1/calendar.0 file /usr/share/man/cat1/cat.0 file /usr/share/man/cat1/cb.0 file /usr/share/man/cat1/cc.0 file /usr/share/man/cat1/cd.0 file /usr/share/man/cat1/checknr.0 file /usr/share/man/cat1/chflags.0 file /usr/share/man/cat1/chgrp.0 file /usr/share/man/cat1/chmod.0 file /usr/share/man/cat1/clear.0 file /usr/share/man/cat1/cmp.0 file /usr/share/man/cat1/col.0 file /usr/share/man/cat1/colcrt.0 file /usr/share/man/cat1/colrm.0 file /usr/share/man/cat1/comm.0 file /usr/share/man/cat1/cp.0 file /usr/share/man/cat1/cpp.0 file /usr/share/man/cat1/crontab.0 file /usr/share/man/cat1/csh.0 file /usr/share/man/cat1/ctags.0 file /usr/share/man/cat1/date.0 file /usr/share/man/cat1/dc.0 file /usr/share/man/cat1/dd.0 file /usr/share/man/cat1/deroff.0 file /usr/share/man/cat1/df.0 file /usr/share/man/cat1/diff3.0 file /usr/share/man/cat1/du.0 file /usr/share/man/cat1/echo.0 file /usr/share/man/cat1/ed.0 file /usr/share/man/cat1/efl.0 file /usr/share/man/cat1/emg.0 file /usr/share/man/cat1/env.0 file /usr/share/man/cat1/error.0 file /usr/share/man/cat1/expr.0 file /usr/share/man/cat1/f77.0 file /usr/share/man/cat1/false.0 file /usr/share/man/cat1/file.0 file /usr/share/man/cat1/find.0 file /usr/share/man/cat1/fmt.0 file /usr/share/man/cat1/fold.0 file /usr/share/man/cat1/fpr.0 file /usr/share/man/cat1/from.0 file /usr/share/man/cat1/fsplit.0 file /usr/share/man/cat1/gcore.0 file /usr/share/man/cat1/graph.0 file /usr/share/man/cat1/groups.0 file /usr/share/man/cat1/head.0 file /usr/share/man/cat1/hostid.0 file /usr/share/man/cat1/hostname.0 file /usr/share/man/cat1/id.0 file /usr/share/man/cat1/indent.0 file /usr/share/man/cat1/install.0 file /usr/share/man/cat1/intro.0 file /usr/share/man/cat1/join.0 file /usr/share/man/cat1/kill.0 file /usr/share/man/cat1/la.0 file /usr/share/man/cat1/last.0 file /usr/share/man/cat1/lastcomm.0 file /usr/share/man/cat1/lcc.0 file /usr/share/man/cat1/ld.0 file /usr/share/man/cat1/learn.0 file /usr/share/man/cat1/leave.0 file /usr/share/man/cat1/lex.0 file /usr/share/man/cat1/lint.0 file /usr/share/man/cat1/lisp.0 file /usr/share/man/cat1/ln.0 file /usr/share/man/cat1/logger.0 file /usr/share/man/cat1/login.0 file /usr/share/man/cat1/look.0 file /usr/share/man/cat1/lorder.0 file /usr/share/man/cat1/lpq.0 file /usr/share/man/cat1/lpr.0 file /usr/share/man/cat1/lprm.0 file /usr/share/man/cat1/lptest.0 file /usr/share/man/cat1/ls.0 file /usr/share/man/cat1/lxref.0 file /usr/share/man/cat1/m4.0 file /usr/share/man/cat1/mail.0 file /usr/share/man/cat1/make.0 file /usr/share/man/cat1/man.0 file /usr/share/man/cat1/md5.0 file /usr/share/man/cat1/mesg.0 file /usr/share/man/cat1/mkdep.0 file /usr/share/man/cat1/mkdir.0 file /usr/share/man/cat1/mkstr.0 file /usr/share/man/cat1/mset.0 file /usr/share/man/cat1/msgs.0 file /usr/share/man/cat1/mt.0 file /usr/share/man/cat1/mv.0 file /usr/share/man/cat1/netstat.0 file /usr/share/man/cat1/newaliases.0 file /usr/share/man/cat1/nm.0 file /usr/share/man/cat1/nroff.0 file /usr/share/man/cat1/nslookup.0 file /usr/share/man/cat1/od.0 file /usr/share/man/cat1/pagesize.0 file /usr/share/man/cat1/passwd.0 file /usr/share/man/cat1/pdx.0 file /usr/share/man/cat1/pi.0 file /usr/share/man/cat1/pix.0 file /usr/share/man/cat1/plot.0 file /usr/share/man/cat1/pmerge.0 file /usr/share/man/cat1/pr.0 file /usr/share/man/cat1/printenv.0 file /usr/share/man/cat1/printf.0 file /usr/share/man/cat1/prof.0 file /usr/share/man/cat1/ps.0 file /usr/share/man/cat1/ptx.0 file /usr/share/man/cat1/pwd.0 file /usr/share/man/cat1/px.0 file /usr/share/man/cat1/pxp.0 file /usr/share/man/cat1/pxref.0 file /usr/share/man/cat1/quota.0 file /usr/share/man/cat1/ranlib.0 file /usr/share/man/cat1/ratfor.0 file /usr/share/man/cat1/rcp.0 file /usr/share/man/cat1/rdist.0 file /usr/share/man/cat1/refer.0 file /usr/share/man/cat1/rev.0 file /usr/share/man/cat1/rlogin.0 file /usr/share/man/cat1/rm.0 file /usr/share/man/cat1/rmail.0 file /usr/share/man/cat1/rmdir.0 file /usr/share/man/cat1/roffbib.0 file /usr/share/man/cat1/rsh.0 file /usr/share/man/cat1/ruptime.0 file /usr/share/man/cat1/rwho.0 file /usr/share/man/cat1/sccs.0 file /usr/share/man/cat1/script.0 file /usr/share/man/cat1/sed.0 file /usr/share/man/cat1/sendbug.0 file /usr/share/man/cat1/size.0 file /usr/share/man/cat1/sleep.0 file /usr/share/man/cat1/soelim.0 file /usr/share/man/cat1/sort.0 file /usr/share/man/cat1/sortbib.0 file /usr/share/man/cat1/spline.0 file /usr/share/man/cat1/split.0 file /usr/share/man/cat1/strcompact.0 file /usr/share/man/cat1/strings.0 file /usr/share/man/cat1/strip.0 file /usr/share/man/cat1/stty.0 file /usr/share/man/cat1/style.0 file /usr/share/man/cat1/su.0 file /usr/share/man/cat1/sum.0 file /usr/share/man/cat1/symcompact.0 file /usr/share/man/cat1/symorder.0 file /usr/share/man/cat1/tabs.0 file /usr/share/man/cat1/tail.0 file /usr/share/man/cat1/talk.0 file /usr/share/man/cat1/tar.0 file /usr/share/man/cat1/tbl.0 file /usr/share/man/cat1/tc.0 file /usr/share/man/cat1/tcopy.0 file /usr/share/man/cat1/tee.0 file /usr/share/man/cat1/telnet.0 file /usr/share/man/cat1/test.0 file /usr/share/man/cat1/time.0 file /usr/share/man/cat1/tk.0 file /usr/share/man/cat1/tn3270.0 file /usr/share/man/cat1/touch.0 file /usr/share/man/cat1/tp.0 file /usr/share/man/cat1/tr.0 file /usr/share/man/cat1/troff.0 file /usr/share/man/cat1/true.0 file /usr/share/man/cat1/tsort.0 file /usr/share/man/cat1/tty.0 file /usr/share/man/cat1/ul.0 file /usr/share/man/cat1/uname.0 file /usr/share/man/cat1/unifdef.0 file /usr/share/man/cat1/uniq.0 file /usr/share/man/cat1/units.0 file /usr/share/man/cat1/uptime.0 file /usr/share/man/cat1/users.0 file /usr/share/man/cat1/uucp.0 file /usr/share/man/cat1/uudecode.0 file /usr/share/man/cat1/uulog.0 file /usr/share/man/cat1/uuname.0 file /usr/share/man/cat1/uuq.0 file /usr/share/man/cat1/uusend.0 file /usr/share/man/cat1/uux.0 file /usr/share/man/cat1/vacation.0 file /usr/share/man/cat1/vgrind.0 file /usr/share/man/cat1/vi.0 file /usr/share/man/cat1/vmstat.0 file /usr/share/man/cat1/vwidth.0 file /usr/share/man/cat1/w.0 file /usr/share/man/cat1/wait.0 file /usr/share/man/cat1/wall.0 file /usr/share/man/cat1/wc.0 file /usr/share/man/cat1/what.0 file /usr/share/man/cat1/whatis.0 file /usr/share/man/cat1/whereis.0 file /usr/share/man/cat1/which.0 file /usr/share/man/cat1/who.0 file /usr/share/man/cat1/whoami.0 file /usr/share/man/cat1/whois.0 file /usr/share/man/cat1/window.0 file /usr/share/man/cat1/write.0 file /usr/share/man/cat1/xargs.0 file /usr/share/man/cat1/xstr.0 file /usr/share/man/cat1/yacc.0 file /usr/share/man/cat1/yes.0 file /usr/share/man/cat2/accept.0 file /usr/share/man/cat2/access.0 file /usr/share/man/cat2/acct.0 file /usr/share/man/cat2/adjtime.0 file /usr/share/man/cat2/bind.0 file /usr/share/man/cat2/chdir.0 file /usr/share/man/cat2/chroot.0 file /usr/share/man/cat2/close.0 file /usr/share/man/cat2/connect.0 file /usr/share/man/cat2/creat.0 file /usr/share/man/cat2/execve.0 file /usr/share/man/cat2/exit.0 file /usr/share/man/cat2/fcntl.0 file /usr/share/man/cat2/fetchi.0 file /usr/share/man/cat2/flock.0 file /usr/share/man/cat2/fork.0 file /usr/share/man/cat2/fperr.0 file /usr/share/man/cat2/fsync.0 file /usr/share/man/cat2/getdtablesize.0 file /usr/share/man/cat2/getfsstat.0 file /usr/share/man/cat2/getgroups.0 file /usr/share/man/cat2/getpagesize.0 file /usr/share/man/cat2/getpeername.0 file /usr/share/man/cat2/getpgrp.0 file /usr/share/man/cat2/getrusage.0 file /usr/share/man/cat2/getsockname.0 file /usr/share/man/cat2/intro.0 file /usr/share/man/cat2/ioctl.0 file /usr/share/man/cat2/kill.0 file /usr/share/man/cat2/killpg.0 file /usr/share/man/cat2/link.0 file /usr/share/man/cat2/listen.0 file /usr/share/man/cat2/lock.0 file /usr/share/man/cat2/lseek.0 file /usr/share/man/cat2/mkdir.0 file /usr/share/man/cat2/mknod.0 file /usr/share/man/cat2/nostk.0 file /usr/share/man/cat2/open.0 file /usr/share/man/cat2/phys.0 file /usr/share/man/cat2/pipe.0 file /usr/share/man/cat2/profil.0 file /usr/share/man/cat2/ptrace.0 file /usr/share/man/cat2/quota.0 file /usr/share/man/cat2/readlink.0 file /usr/share/man/cat2/reboot.0 file /usr/share/man/cat2/rename.0 file /usr/share/man/cat2/rmdir.0 file /usr/share/man/cat2/setgroups.0 file /usr/share/man/cat2/setpgrp.0 file /usr/share/man/cat2/setquota.0 file /usr/share/man/cat2/setregid.0 file /usr/share/man/cat2/setreuid.0 file /usr/share/man/cat2/shutdown.0 file /usr/share/man/cat2/sigaction.0 file /usr/share/man/cat2/sigaltstack.0 file /usr/share/man/cat2/sigblock.0 file /usr/share/man/cat2/sigpause.0 file /usr/share/man/cat2/sigpending.0 file /usr/share/man/cat2/sigprocmask.0 file /usr/share/man/cat2/sigreturn.0 file /usr/share/man/cat2/sigsetmask.0 file /usr/share/man/cat2/sigstack.0 file /usr/share/man/cat2/sigsuspend.0 file /usr/share/man/cat2/sigvec.0 file /usr/share/man/cat2/sigwait.0 file /usr/share/man/cat2/socket.0 file /usr/share/man/cat2/socketpair.0 file /usr/share/man/cat2/swapon.0 file /usr/share/man/cat2/symlink.0 file /usr/share/man/cat2/sync.0 file /usr/share/man/cat2/syscall.0 file /usr/share/man/cat2/ucall.0 file /usr/share/man/cat2/umask.0 file /usr/share/man/cat2/unlink.0 file /usr/share/man/cat2/utimes.0 file /usr/share/man/cat2/vfork.0 file /usr/share/man/cat2/vhangup.0 file /usr/share/man/cat3/abort.0 file /usr/share/man/cat3/abs.0 file /usr/share/man/cat3/alarm.0 file /usr/share/man/cat3/assert.0 file /usr/share/man/cat3/basename.0 file /usr/share/man/cat3/curses.0 file /usr/share/man/cat3/daemon.0 file /usr/share/man/cat3/devname.0 file /usr/share/man/cat3/dirname.0 file /usr/share/man/cat3/exit.0 file /usr/share/man/cat3/getgrouplist.0 file /usr/share/man/cat3/getloadavg.0 file /usr/share/man/cat3/getmntinfo.0 file /usr/share/man/cat3/getopt.0 file /usr/share/man/cat3/getpass.0 file /usr/share/man/cat3/getsubopt.0 file /usr/share/man/cat3/getwd.0 file /usr/share/man/cat3/gpanel.0 file /usr/share/man/cat3/infnan.0 file /usr/share/man/cat3/initgroups.0 file /usr/share/man/cat3/intro.0 file /usr/share/man/cat3/ldfps.0 file /usr/share/man/cat3/lib2648.0 file /usr/share/man/cat3/math.0 file /usr/share/man/cat3/mp.0 file /usr/share/man/cat3/nice.0 file /usr/share/man/cat3/nlist.0 file /usr/share/man/cat3/pause.0 file /usr/share/man/cat3/qsort.0 file /usr/share/man/cat3/resolver.0 file /usr/share/man/cat3/rexec.0 file /usr/share/man/cat3/siginterrupt.0 file /usr/share/man/cat3/signal.0 file /usr/share/man/cat3/stdio.0 file /usr/share/man/cat3/strcspn.0 file /usr/share/man/cat3/strftime.0 file /usr/share/man/cat3/strpbrk.0 file /usr/share/man/cat3/strsep.0 file /usr/share/man/cat3/strspn.0 file /usr/share/man/cat3/strstr.0 file /usr/share/man/cat3/strtok.0 file /usr/share/man/cat3/strtol.0 file /usr/share/man/cat3/strtoul.0 file /usr/share/man/cat3/swab.0 file /usr/share/man/cat3/sysctl.0 file /usr/share/man/cat3/syserrlst.0 file /usr/share/man/cat3/system.0 file /usr/share/man/cat3/times.0 file /usr/share/man/cat3/ualarm.0 file /usr/share/man/cat3/uname.0 file /usr/share/man/cat3/ungetc.0 file /usr/share/man/cat3/utime.0 file /usr/share/man/cat3/valloc.0 file /usr/share/man/cat3/varargs.0 file /usr/share/man/cat3/vmf.0 file /usr/share/man/cat4/acc.0 file /usr/share/man/cat4/arp.0 file /usr/share/man/cat4/bk.0 file /usr/share/man/cat4/br.0 file /usr/share/man/cat4/cons.0 file /usr/share/man/cat4/css.0 file /usr/share/man/cat4/de.0 file /usr/share/man/cat4/dh.0 file /usr/share/man/cat4/dhu.0 file /usr/share/man/cat4/dhv.0 file /usr/share/man/cat4/dmc.0 file /usr/share/man/cat4/dr.0 file /usr/share/man/cat4/dz.0 file /usr/share/man/cat4/ec.0 file /usr/share/man/cat4/en.0 file /usr/share/man/cat4/hk.0 file /usr/share/man/cat4/ht.0 file /usr/share/man/cat4/hy.0 file /usr/share/man/cat4/icmp.0 file /usr/share/man/cat4/idp.0 file /usr/share/man/cat4/il.0 file /usr/share/man/cat4/imp.0 file /usr/share/man/cat4/impconf.0 file /usr/share/man/cat4/inet.0 file /usr/share/man/cat4/intro.0 file /usr/share/man/cat4/ip.0 file /usr/share/man/cat4/lo.0 file /usr/share/man/cat4/lp.0 file /usr/share/man/cat4/mtio.0 file /usr/share/man/cat4/networking.0 file /usr/share/man/cat4/ns.0 file /usr/share/man/cat4/nsip.0 file /usr/share/man/cat4/null.0 file /usr/share/man/cat4/pty.0 file /usr/share/man/cat4/qe.0 file /usr/share/man/cat4/ra.0 file /usr/share/man/cat4/ram.0 file /usr/share/man/cat4/rk.0 file /usr/share/man/cat4/rl.0 file /usr/share/man/cat4/rx.0 file /usr/share/man/cat4/si.0 file /usr/share/man/cat4/spp.0 file /usr/share/man/cat4/sri.0 file /usr/share/man/cat4/swap.0 file /usr/share/man/cat4/tb.0 file /usr/share/man/cat4/tcp.0 file /usr/share/man/cat4/tm.0 file /usr/share/man/cat4/tmscp.0 file /usr/share/man/cat4/ts.0 file /usr/share/man/cat4/tty.0 file /usr/share/man/cat4/udp.0 file /usr/share/man/cat4/vv.0 file /usr/share/man/cat5/acct.0 file /usr/share/man/cat5/aliases.0 file /usr/share/man/cat5/a.out.0 file /usr/share/man/cat5/ar.0 file /usr/share/man/cat5/core.0 file /usr/share/man/cat5/crontab.0 file /usr/share/man/cat5/dbx.0 file /usr/share/man/cat5/dir.0 file /usr/share/man/cat5/disktab.0 file /usr/share/man/cat5/dtab.0 file /usr/share/man/cat5/fstab.0 file /usr/share/man/cat5/gettytab.0 file /usr/share/man/cat5/group.0 file /usr/share/man/cat5/hosts.0 file /usr/share/man/cat5/L.aliases.0 file /usr/share/man/cat5/L.cmds.0 file /usr/share/man/cat5/L-devices.0 file /usr/share/man/cat5/L-dialcodes.0 file /usr/share/man/cat5/L.sys.0 file /usr/share/man/cat5/intro.0 file /usr/share/man/cat5/map3270.0 file /usr/share/man/cat5/networks.0 file /usr/share/man/cat5/passwd.0 file /usr/share/man/cat5/phones.0 file /usr/share/man/cat5/plot.0 file /usr/share/man/cat5/printcap.0 file /usr/share/man/cat5/protocols.0 file /usr/share/man/cat5/ranlib.0 file /usr/share/man/cat5/remote.0 file /usr/share/man/cat5/resolver.0 file /usr/share/man/cat5/services.0 file /usr/share/man/cat5/shells.0 file /usr/share/man/cat5/stack.0 file /usr/share/man/cat5/syserrlst.0 file /usr/share/man/cat5/tar.0 file /usr/share/man/cat5/termcap.0 file /usr/share/man/cat5/tp.0 file /usr/share/man/cat5/ttys.0 file /usr/share/man/cat5/types.0 file /usr/share/man/cat5/tzfile.0 file /usr/share/man/cat5/USERFILE.0 file /usr/share/man/cat5/vfont.0 file /usr/share/man/cat5/vgrindefs.0 file /usr/share/man/cat6/adventure.0 file /usr/share/man/cat6/arithmetic.0 file /usr/share/man/cat6/atc.0 file /usr/share/man/cat6/backgammon.0 file /usr/share/man/cat6/banner.0 file /usr/share/man/cat6/battlestar.0 file /usr/share/man/cat6/boggle.0 file /usr/share/man/cat6/caesar.0 file /usr/share/man/cat6/cribbage.0 file /usr/share/man/cat6/fish.0 file /usr/share/man/cat6/fortune.0 file /usr/share/man/cat6/hangman.0 file /usr/share/man/cat6/intro.0 file /usr/share/man/cat6/mille.0 file /usr/share/man/cat6/monop.0 file /usr/share/man/cat6/number.0 file /usr/share/man/cat6/pig.0 file /usr/share/man/cat6/pom.0 file /usr/share/man/cat6/quiz.0 file /usr/share/man/cat6/rain.0 file /usr/share/man/cat6/robots.0 file /usr/share/man/cat6/rogue.0 file /usr/share/man/cat6/sail.0 file /usr/share/man/cat6/trek.0 file /usr/share/man/cat6/worm.0 file /usr/share/man/cat6/worms.0 file /usr/share/man/cat6/wump.0 file /usr/share/man/cat7/ascii.0 file /usr/share/man/cat7/environ.0 file /usr/share/man/cat7/eqnchar.0 file /usr/share/man/cat7/hier.0 file /usr/share/man/cat7/hostname.0 file /usr/share/man/cat7/mailaddr.0 file /usr/share/man/cat7/man.0 file /usr/share/man/cat7/me.0 file /usr/share/man/cat7/ms.0 file /usr/share/man/cat7/term.0 file /usr/share/man/cat8/adduser.0 file /usr/share/man/cat8/autoconfig.0 file /usr/share/man/cat8/boot.0 file /usr/share/man/cat8/bugfiler.0 file /usr/share/man/cat8/chown.0 file /usr/share/man/cat8/chroot.0 file /usr/share/man/cat8/crash.0 file /usr/share/man/cat8/cron.0 file /usr/share/man/cat8/drtest.0 file /usr/share/man/cat8/dump.0 file /usr/share/man/cat8/dumpdir.0 file /usr/share/man/cat8/fdisk.0 file /usr/share/man/cat8/format.0 file /usr/share/man/cat8/fsck.0 file /usr/share/man/cat8/fstat.0 file /usr/share/man/cat8/getty.0 file /usr/share/man/cat8/htable.0 file /usr/share/man/cat8/init.0 file /usr/share/man/cat8/intro.0 file /usr/share/man/cat8/iostat.0 file /usr/share/man/cat8/lpc.0 file /usr/share/man/cat8/lpd.0 file /usr/share/man/cat8/makedev.0 file /usr/share/man/cat8/makekey.0 file /usr/share/man/cat8/mkfs.0 file /usr/share/man/cat8/mknod.0 file /usr/share/man/cat8/mkpasswd.0 file /usr/share/man/cat8/mount.0 file /usr/share/man/cat8/named.0 file /usr/share/man/cat8/pac.0 file /usr/share/man/cat8/pstat.0 file /usr/share/man/cat8/rc.0 file /usr/share/man/cat8/rdump.0 file /usr/share/man/cat8/renice.0 file /usr/share/man/cat8/routed.0 file /usr/share/man/cat8/rrestore.0 file /usr/share/man/cat8/sendmail.0 file /usr/share/man/cat8/shutdown.0 file /usr/share/man/cat8/sticky.0 file /usr/share/man/cat8/sync.0 file /usr/share/man/cat8/sysctl.0 file /usr/share/man/cat8/timed.0 file /usr/share/man/cat8/timedc.0 file /usr/share/man/cat8/umount.0 file /usr/share/man/cat8/update.0 file /usr/share/man/cat8/uuclean.0 file /usr/share/man/cat8/uupoll.0 file /usr/share/man/cat8/uusnap.0 file /usr/share/man/cat8/uuxqt.0 file /usr/share/man/cat8/vipw.0 file /usr/share/man/cat8/XNSrouted.0 file /usr/share/man/cat9/intro.0 file /usr/share/man/cat9/style.0 # # Linked pages # file /usr/share/man/cat3/cosh.0 link /usr/share/man/cat3/sinh.0 target /usr/share/man/cat3/cosh.0 link /usr/share/man/cat3/tanh.0 target /usr/share/man/cat3/cosh.0 file /usr/share/man/cat3/fputs.0 link /usr/share/man/cat3/puts.0 target /usr/share/man/cat3/fputs.0 file /usr/share/man/cat2/gethostid.0 link /usr/share/man/cat2/sethostid.0 target /usr/share/man/cat2/gethostid.0 file /usr/share/man/cat3/rand.0 link /usr/share/man/cat3/srand.0 target /usr/share/man/cat3/rand.0 file /usr/share/man/cat3/edata.0 link /usr/share/man/cat3/end.0 target /usr/share/man/cat3/edata.0 link /usr/share/man/cat3/etext.0 target /usr/share/man/cat3/edata.0 file /usr/share/man/cat3/l3tol.0 link /usr/share/man/cat3/ltol3.0 target /usr/share/man/cat3/l3tol.0 file /usr/share/man/cat1/rb.0 link /usr/share/man/cat1/rx.0 target /usr/share/man/cat1/rb.0 link /usr/share/man/cat1/rz.0 target /usr/share/man/cat1/rb.0 file /usr/share/man/cat3/j0.0 link /usr/share/man/cat3/j1.0 target /usr/share/man/cat3/j0.0 link /usr/share/man/cat3/jn.0 target /usr/share/man/cat3/j0.0 link /usr/share/man/cat3/y0.0 target /usr/share/man/cat3/j0.0 link /usr/share/man/cat3/y1.0 target /usr/share/man/cat3/j0.0 link /usr/share/man/cat3/yn.0 target /usr/share/man/cat3/j0.0 file /usr/share/man/cat3/frexp.0 link /usr/share/man/cat3/ldexp.0 target /usr/share/man/cat3/frexp.0 link /usr/share/man/cat3/modf.0 target /usr/share/man/cat3/frexp.0 file /usr/share/man/cat3/insque.0 link /usr/share/man/cat3/remque.0 target /usr/share/man/cat3/insque.0 file /usr/share/man/cat3/getdisk.0 link /usr/share/man/cat3/getdiskbyname.0 target /usr/share/man/cat3/getdisk.0 file /usr/share/man/cat3/fclose.0 link /usr/share/man/cat3/fflush.0 target /usr/share/man/cat3/fclose.0 file /usr/share/man/cat3/atof.0 link /usr/share/man/cat3/atoi.0 target /usr/share/man/cat3/atof.0 link /usr/share/man/cat3/atol.0 target /usr/share/man/cat3/atof.0 file /usr/share/man/cat1/cu.0 link /usr/share/man/cat1/tip.0 target /usr/share/man/cat1/cu.0 file /usr/share/man/cat4/fd.0 link /usr/share/man/cat4/stderr.0 target /usr/share/man/cat4/fd.0 link /usr/share/man/cat4/stdin.0 target /usr/share/man/cat4/fd.0 link /usr/share/man/cat4/stdout.0 target /usr/share/man/cat4/fd.0 file /usr/share/man/cat3/setrgid.0 link /usr/share/man/cat3/setruid.0 target /usr/share/man/cat3/setrgid.0 file /usr/share/man/cat3/cbrt.0 link /usr/share/man/cat3/sqrt.0 target /usr/share/man/cat3/cbrt.0 file /usr/share/man/cat3/ctype.0 link /usr/share/man/cat3/isalnum.0 target /usr/share/man/cat3/ctype.0 link /usr/share/man/cat3/isalpha.0 target /usr/share/man/cat3/ctype.0 link /usr/share/man/cat3/isascii.0 target /usr/share/man/cat3/ctype.0 link /usr/share/man/cat3/iscntrl.0 target /usr/share/man/cat3/ctype.0 link /usr/share/man/cat3/isdigit.0 target /usr/share/man/cat3/ctype.0 link /usr/share/man/cat3/islower.0 target /usr/share/man/cat3/ctype.0 link /usr/share/man/cat3/isprint.0 target /usr/share/man/cat3/ctype.0 link /usr/share/man/cat3/ispunct.0 target /usr/share/man/cat3/ctype.0 link /usr/share/man/cat3/isspace.0 target /usr/share/man/cat3/ctype.0 link /usr/share/man/cat3/isupper.0 target /usr/share/man/cat3/ctype.0 link /usr/share/man/cat3/isxdigit.0 target /usr/share/man/cat3/ctype.0 link /usr/share/man/cat3/toascii.0 target /usr/share/man/cat3/ctype.0 link /usr/share/man/cat3/tolower.0 target /usr/share/man/cat3/ctype.0 link /usr/share/man/cat3/toupper.0 target /usr/share/man/cat3/ctype.0 file /usr/share/man/cat3/compat-sys5.0 link /usr/share/man/cat3/memccpy.0 target /usr/share/man/cat3/compat-sys5.0 link /usr/share/man/cat3/memchr.0 target /usr/share/man/cat3/compat-sys5.0 link /usr/share/man/cat3/memcmp.0 target /usr/share/man/cat3/compat-sys5.0 link /usr/share/man/cat3/memcpy.0 target /usr/share/man/cat3/compat-sys5.0 link /usr/share/man/cat3/memset.0 target /usr/share/man/cat3/compat-sys5.0 link /usr/share/man/cat3/strchr.0 target /usr/share/man/cat3/compat-sys5.0 link /usr/share/man/cat3/strrchr.0 target /usr/share/man/cat3/compat-sys5.0 link /usr/share/man/cat3/tempnam.0 target /usr/share/man/cat3/compat-sys5.0 link /usr/share/man/cat3/tmpfile.0 target /usr/share/man/cat3/compat-sys5.0 link /usr/share/man/cat3/tmpnam.0 target /usr/share/man/cat3/compat-sys5.0 file /usr/share/man/cat3/arc.0 link /usr/share/man/cat3/circle.0 target /usr/share/man/cat3/arc.0 link /usr/share/man/cat3/cont.0 target /usr/share/man/cat3/arc.0 link /usr/share/man/cat3/erase.0 target /usr/share/man/cat3/arc.0 link /usr/share/man/cat3/label.0 target /usr/share/man/cat3/arc.0 link /usr/share/man/cat3/line.0 target /usr/share/man/cat3/arc.0 link /usr/share/man/cat3/linemod.0 target /usr/share/man/cat3/arc.0 link /usr/share/man/cat3/move.0 target /usr/share/man/cat3/arc.0 link /usr/share/man/cat3/openpl.0 target /usr/share/man/cat3/arc.0 link /usr/share/man/cat3/plot.0 target /usr/share/man/cat3/arc.0 link /usr/share/man/cat3/point.0 target /usr/share/man/cat3/arc.0 link /usr/share/man/cat3/space.0 target /usr/share/man/cat3/arc.0 file /usr/share/man/cat3/acosh.0 link /usr/share/man/cat3/asinh.0 target /usr/share/man/cat3/acosh.0 link /usr/share/man/cat3/atanh.0 target /usr/share/man/cat3/acosh.0 file /usr/share/man/cat3/index.0 link /usr/share/man/cat3/rindex.0 target /usr/share/man/cat3/index.0 link /usr/share/man/cat3/strcasecmp.0 target /usr/share/man/cat3/index.0 link /usr/share/man/cat3/strcat.0 target /usr/share/man/cat3/index.0 link /usr/share/man/cat3/strcmp.0 target /usr/share/man/cat3/index.0 link /usr/share/man/cat3/strcpy.0 target /usr/share/man/cat3/index.0 link /usr/share/man/cat3/string.0 target /usr/share/man/cat3/index.0 link /usr/share/man/cat3/strlen.0 target /usr/share/man/cat3/index.0 link /usr/share/man/cat3/strncasecmp.0 target /usr/share/man/cat3/index.0 link /usr/share/man/cat3/strncat.0 target /usr/share/man/cat3/index.0 link /usr/share/man/cat3/strncmp.0 target /usr/share/man/cat3/index.0 link /usr/share/man/cat3/strncpy.0 target /usr/share/man/cat3/index.0 file /usr/share/man/cat3/strlcpy.0 link /usr/share/man/cat3/strlcat.0 target /usr/share/man/cat3/strlcpy.0 file /usr/share/man/cat3/gtty.0 link /usr/share/man/cat3/stty.0 target /usr/share/man/cat3/gtty.0 file /usr/share/man/cat3/endusershell.0 link /usr/share/man/cat3/getusershell.0 target /usr/share/man/cat3/endusershell.0 link /usr/share/man/cat3/setusershell.0 target /usr/share/man/cat3/endusershell.0 file /usr/share/man/cat2/getegid.0 link /usr/share/man/cat2/getgid.0 target /usr/share/man/cat2/getegid.0 file /usr/share/man/cat2/geteuid.0 link /usr/share/man/cat2/getuid.0 target /usr/share/man/cat2/geteuid.0 file /usr/share/man/cat3/fgets.0 link /usr/share/man/cat3/gets.0 target /usr/share/man/cat3/fgets.0 file /usr/share/man/cat3/psignal.0 link /usr/share/man/cat3/sys_siglist.0 target /usr/share/man/cat3/psignal.0 file /usr/share/man/cat1/expand.0 link /usr/share/man/cat1/unexpand.0 target /usr/share/man/cat1/expand.0 file /usr/share/man/cat3/addr.0 link /usr/share/man/cat3/inet.0 target /usr/share/man/cat3/addr.0 link /usr/share/man/cat3/inet_addr.0 target /usr/share/man/cat3/addr.0 link /usr/share/man/cat3/inet_lnaof.0 target /usr/share/man/cat3/addr.0 link /usr/share/man/cat3/inet_makeaddr.0 target /usr/share/man/cat3/addr.0 link /usr/share/man/cat3/inet_netof.0 target /usr/share/man/cat3/addr.0 link /usr/share/man/cat3/inet_network.0 target /usr/share/man/cat3/addr.0 link /usr/share/man/cat3/inet_ntoa.0 target /usr/share/man/cat3/addr.0 link /usr/share/man/cat3/network.0 target /usr/share/man/cat3/addr.0 link /usr/share/man/cat3/ntoa.0 target /usr/share/man/cat3/addr.0 file /usr/share/man/cat3/isatty.0 link /usr/share/man/cat3/ttyname.0 target /usr/share/man/cat3/isatty.0 link /usr/share/man/cat3/ttyslot.0 target /usr/share/man/cat3/isatty.0 file /usr/share/man/cat1/diction.0 link /usr/share/man/cat1/explain.0 target /usr/share/man/cat1/diction.0 file /usr/share/man/cat1/sb.0 link /usr/share/man/cat1/sx.0 target /usr/share/man/cat1/sb.0 link /usr/share/man/cat1/sz.0 target /usr/share/man/cat1/sb.0 file /usr/share/man/cat3/fread.0 link /usr/share/man/cat3/fwrite.0 target /usr/share/man/cat3/fread.0 file /usr/share/man/cat3/mkstemp.0 link /usr/share/man/cat3/mktemp.0 target /usr/share/man/cat3/mkstemp.0 file /usr/share/man/cat3/dbm_clearerr.0 link /usr/share/man/cat3/dbm_close.0 target /usr/share/man/cat3/dbm_clearerr.0 link /usr/share/man/cat3/dbm_delete.0 target /usr/share/man/cat3/dbm_clearerr.0 link /usr/share/man/cat3/dbm_error.0 target /usr/share/man/cat3/dbm_clearerr.0 link /usr/share/man/cat3/dbm_fetch.0 target /usr/share/man/cat3/dbm_clearerr.0 link /usr/share/man/cat3/dbm_firstkey.0 target /usr/share/man/cat3/dbm_clearerr.0 link /usr/share/man/cat3/dbm_nextkey.0 target /usr/share/man/cat3/dbm_clearerr.0 link /usr/share/man/cat3/dbm_open.0 target /usr/share/man/cat3/dbm_clearerr.0 link /usr/share/man/cat3/dbm_store.0 target /usr/share/man/cat3/dbm_clearerr.0 link /usr/share/man/cat3/ndbm.0 target /usr/share/man/cat3/dbm_clearerr.0 file /usr/share/man/cat3/clearerr.0 link /usr/share/man/cat3/feof.0 target /usr/share/man/cat3/clearerr.0 link /usr/share/man/cat3/ferror.0 target /usr/share/man/cat3/clearerr.0 link /usr/share/man/cat3/fileno.0 target /usr/share/man/cat3/clearerr.0 file /usr/share/man/cat3/fseek.0 link /usr/share/man/cat3/ftell.0 target /usr/share/man/cat3/fseek.0 link /usr/share/man/cat3/rewind.0 target /usr/share/man/cat3/fseek.0 file /usr/share/man/cat3/bcmp.0 link /usr/share/man/cat3/bcopy.0 target /usr/share/man/cat3/bcmp.0 link /usr/share/man/cat3/bstring.0 target /usr/share/man/cat3/bcmp.0 link /usr/share/man/cat3/bzero.0 target /usr/share/man/cat3/bcmp.0 link /usr/share/man/cat3/ffs.0 target /usr/share/man/cat3/bcmp.0 file /usr/share/man/cat5/fs.0 link /usr/share/man/cat5/inode.0 target /usr/share/man/cat5/fs.0 file /usr/share/man/cat3/byteorder.0 link /usr/share/man/cat3/htonl.0 target /usr/share/man/cat3/byteorder.0 link /usr/share/man/cat3/htons.0 target /usr/share/man/cat3/byteorder.0 link /usr/share/man/cat3/ntohl.0 target /usr/share/man/cat3/byteorder.0 link /usr/share/man/cat3/ntohs.0 target /usr/share/man/cat3/byteorder.0 file /usr/share/man/cat3/fputc.0 link /usr/share/man/cat3/putc.0 target /usr/share/man/cat3/fputc.0 link /usr/share/man/cat3/putchar.0 target /usr/share/man/cat3/fputc.0 link /usr/share/man/cat3/putw.0 target /usr/share/man/cat3/fputc.0 file /usr/share/man/cat4/kmem.0 link /usr/share/man/cat4/mem.0 target /usr/share/man/cat4/kmem.0 file /usr/share/man/cat2/gethostname.0 link /usr/share/man/cat2/sethostname.0 target /usr/share/man/cat2/gethostname.0 file /usr/share/man/cat3/ceil.0 link /usr/share/man/cat3/fabs.0 target /usr/share/man/cat3/ceil.0 link /usr/share/man/cat3/floor.0 target /usr/share/man/cat3/ceil.0 link /usr/share/man/cat3/rint.0 target /usr/share/man/cat3/ceil.0 file /usr/share/man/cat3/getenv.0 link /usr/share/man/cat3/setenv.0 target /usr/share/man/cat3/getenv.0 link /usr/share/man/cat3/unsetenv.0 target /usr/share/man/cat3/getenv.0 file /usr/share/man/cat3/getmode.0 link /usr/share/man/cat3/setmode.0 target /usr/share/man/cat3/getmode.0 file /usr/share/man/cat3/pclose.0 link /usr/share/man/cat3/popen.0 target /usr/share/man/cat3/pclose.0 file /usr/share/man/cat3/cabs.0 link /usr/share/man/cat3/hypot.0 target /usr/share/man/cat3/cabs.0 file /usr/share/man/cat3/ecvt.0 link /usr/share/man/cat3/fcvt.0 target /usr/share/man/cat3/ecvt.0 link /usr/share/man/cat3/gcvt.0 target /usr/share/man/cat3/ecvt.0 file /usr/share/man/cat3/fgetc.0 link /usr/share/man/cat3/getc.0 target /usr/share/man/cat3/fgetc.0 link /usr/share/man/cat3/getchar.0 target /usr/share/man/cat3/fgetc.0 link /usr/share/man/cat3/getw.0 target /usr/share/man/cat3/fgetc.0 file /usr/share/man/cat1/nice.0 link /usr/share/man/cat1/nohup.0 target /usr/share/man/cat1/nice.0 file /usr/share/man/cat3/comp.0 link /usr/share/man/cat3/re_comp.0 target /usr/share/man/cat3/comp.0 link /usr/share/man/cat3/re_exec.0 target /usr/share/man/cat3/comp.0 link /usr/share/man/cat3/regex.0 target /usr/share/man/cat3/comp.0 file /usr/share/man/cat3/perror.0 link /usr/share/man/cat3/strerror.0 target /usr/share/man/cat3/perror.0 file /usr/share/man/cat3/sleep.0 link /usr/share/man/cat3/usleep.0 target /usr/share/man/cat3/sleep.0 file /usr/share/man/cat3/endfsent.0 link /usr/share/man/cat3/getfsent.0 target /usr/share/man/cat3/endfsent.0 link /usr/share/man/cat3/getfsfile.0 target /usr/share/man/cat3/endfsent.0 link /usr/share/man/cat3/getfsspec.0 target /usr/share/man/cat3/endfsent.0 link /usr/share/man/cat3/getfstype.0 target /usr/share/man/cat3/endfsent.0 link /usr/share/man/cat3/setfsent.0 target /usr/share/man/cat3/endfsent.0 file /usr/share/man/cat1/case.0 link /usr/share/man/cat1/for.0 target /usr/share/man/cat1/case.0 link /usr/share/man/cat1/if.0 target /usr/share/man/cat1/case.0 link /usr/share/man/cat1/sh.0 target /usr/share/man/cat1/case.0 link /usr/share/man/cat1/while.0 target /usr/share/man/cat1/case.0 file /usr/share/man/cat3/crypt.0 link /usr/share/man/cat3/encrypt.0 target /usr/share/man/cat3/crypt.0 link /usr/share/man/cat3/setkey.0 target /usr/share/man/cat3/crypt.0 file /usr/share/man/cat2/dup.0 link /usr/share/man/cat2/dup2.0 target /usr/share/man/cat2/dup.0 file /usr/share/man/cat1/uudecode.0 link /usr/share/man/cat1/uuencode.0 target /usr/share/man/cat1/uudecode.0 file /usr/share/man/cat3/alphasort.0 link /usr/share/man/cat3/scandir.0 target /usr/share/man/cat3/alphasort.0 file /usr/share/man/cat3/err.0 link /usr/share/man/cat3/errx.0 target /usr/share/man/cat3/err.0 link /usr/share/man/cat3/verr.0 target /usr/share/man/cat3/err.0 link /usr/share/man/cat3/verrx.0 target /usr/share/man/cat3/err.0 link /usr/share/man/cat3/vwarnx.0 target /usr/share/man/cat3/err.0 link /usr/share/man/cat3/warn.0 target /usr/share/man/cat3/err.0 link /usr/share/man/cat3/warnx.0 target /usr/share/man/cat3/err.0 file /usr/share/man/cat2/ftruncate.0 link /usr/share/man/cat2/truncate.0 target /usr/share/man/cat2/ftruncate.0 file /usr/share/man/cat3/sigaddset.0 link /usr/share/man/cat3/sigdelset.0 target /usr/share/man/cat3/sigaddset.0 link /usr/share/man/cat3/sigemptyset.0 target /usr/share/man/cat3/sigaddset.0 link /usr/share/man/cat3/sigfillset.0 target /usr/share/man/cat3/sigaddset.0 link /usr/share/man/cat3/sigismember.0 target /usr/share/man/cat3/sigaddset.0 link /usr/share/man/cat3/sigsetops.0 target /usr/share/man/cat3/sigaddset.0 file /usr/share/man/cat2/gettimeofday.0 link /usr/share/man/cat2/settimeofday.0 target /usr/share/man/cat2/gettimeofday.0 file /usr/share/man/cat2/brk.0 link /usr/share/man/cat2/sbrk.0 target /usr/share/man/cat2/brk.0 file /usr/share/man/cat2/setegid.0 link /usr/share/man/cat2/seteuid.0 target /usr/share/man/cat2/setegid.0 link /usr/share/man/cat2/setgid.0 target /usr/share/man/cat2/setegid.0 link /usr/share/man/cat2/setuid.0 target /usr/share/man/cat2/setegid.0 file /usr/share/man/cat3/endprotoent.0 link /usr/share/man/cat3/getprotobyname.0 target /usr/share/man/cat3/endprotoent.0 link /usr/share/man/cat3/getprotobynumber.0 target /usr/share/man/cat3/endprotoent.0 link /usr/share/man/cat3/getprotoent.0 target /usr/share/man/cat3/endprotoent.0 link /usr/share/man/cat3/setprotoent.0 target /usr/share/man/cat3/endprotoent.0 file /usr/share/man/cat3/ns.0 link /usr/share/man/cat3/ns_addr.0 target /usr/share/man/cat3/ns.0 link /usr/share/man/cat3/ns_ntoa.0 target /usr/share/man/cat3/ns.0 file /usr/share/man/cat3/gamma.0 link /usr/share/man/cat3/lgamma.0 target /usr/share/man/cat3/gamma.0 file /usr/share/man/cat3/endnetent.0 link /usr/share/man/cat3/getnetbyaddr.0 target /usr/share/man/cat3/endnetent.0 link /usr/share/man/cat3/getnetbyname.0 target /usr/share/man/cat3/endnetent.0 link /usr/share/man/cat3/getnetent.0 target /usr/share/man/cat3/endnetent.0 link /usr/share/man/cat3/setnetent.0 target /usr/share/man/cat3/endnetent.0 file /usr/share/man/cat2/getpriority.0 link /usr/share/man/cat2/setpriority.0 target /usr/share/man/cat2/getpriority.0 file /usr/share/man/cat3/ftime.0 link /usr/share/man/cat3/time.0 target /usr/share/man/cat3/ftime.0 file /usr/share/man/cat3/endservent.0 link /usr/share/man/cat3/getservbyname.0 target /usr/share/man/cat3/endservent.0 link /usr/share/man/cat3/getservbyport.0 target /usr/share/man/cat3/endservent.0 link /usr/share/man/cat3/getservent.0 target /usr/share/man/cat3/endservent.0 link /usr/share/man/cat3/setservent.0 target /usr/share/man/cat3/endservent.0 file /usr/share/man/cat2/getlogin.0 link /usr/share/man/cat2/setlogin.0 target /usr/share/man/cat2/getlogin.0 file /usr/share/man/cat3/_longjmp.0 link /usr/share/man/cat3/longjmp.0 target /usr/share/man/cat3/_longjmp.0 link /usr/share/man/cat3/_setjmp.0 target /usr/share/man/cat3/_longjmp.0 link /usr/share/man/cat3/setjmp.0 target /usr/share/man/cat3/_longjmp.0 file /usr/share/man/cat2/chown.0 link /usr/share/man/cat2/fchown.0 target /usr/share/man/cat2/chown.0 file /usr/share/man/cat1/indxbib.0 link /usr/share/man/cat1/lookbib.0 target /usr/share/man/cat1/indxbib.0 file /usr/share/man/cat6/snake.0 link /usr/share/man/cat6/snscore.0 target /usr/share/man/cat6/snake.0 file /usr/share/man/cat3/fdopen.0 link /usr/share/man/cat3/fopen.0 target /usr/share/man/cat3/fdopen.0 link /usr/share/man/cat3/freopen.0 target /usr/share/man/cat3/fdopen.0 file /usr/share/man/cat2/chflags.0 link /usr/share/man/cat2/fchflags.0 target /usr/share/man/cat2/chflags.0 file /usr/share/man/cat3/closedir.0 link /usr/share/man/cat3/directory.0 target /usr/share/man/cat3/closedir.0 link /usr/share/man/cat3/opendir.0 target /usr/share/man/cat3/closedir.0 link /usr/share/man/cat3/readdir.0 target /usr/share/man/cat3/closedir.0 link /usr/share/man/cat3/rewinddir.0 target /usr/share/man/cat3/closedir.0 link /usr/share/man/cat3/seekdir.0 target /usr/share/man/cat3/closedir.0 link /usr/share/man/cat3/telldir.0 target /usr/share/man/cat3/closedir.0 file /usr/share/man/cat6/bcd.0 link /usr/share/man/cat6/ppt.0 target /usr/share/man/cat6/bcd.0 file /usr/share/man/cat6/canfield.0 link /usr/share/man/cat6/cfscores.0 target /usr/share/man/cat6/canfield.0 file /usr/share/man/cat3/copysign.0 link /usr/share/man/cat3/drem.0 target /usr/share/man/cat3/copysign.0 link /usr/share/man/cat3/finite.0 target /usr/share/man/cat3/copysign.0 link /usr/share/man/cat3/ieee.0 target /usr/share/man/cat3/copysign.0 link /usr/share/man/cat3/logb.0 target /usr/share/man/cat3/copysign.0 link /usr/share/man/cat3/scalb.0 target /usr/share/man/cat3/copysign.0 file /usr/share/man/cat2/fstatfs.0 link /usr/share/man/cat2/statfs.0 target /usr/share/man/cat2/fstatfs.0 file /usr/share/man/cat1/spell.0 link /usr/share/man/cat1/spellin.0 target /usr/share/man/cat1/spell.0 link /usr/share/man/cat1/spellout.0 target /usr/share/man/cat1/spell.0 file /usr/share/man/cat2/read.0 link /usr/share/man/cat2/readv.0 target /usr/share/man/cat2/read.0 file /usr/share/man/cat2/chmod.0 link /usr/share/man/cat2/fchdir.0 target /usr/share/man/cat2/chmod.0 link /usr/share/man/cat2/fchmod.0 target /usr/share/man/cat2/chmod.0 file /usr/share/man/cat1/edit.0 link /usr/share/man/cat1/ex.0 target /usr/share/man/cat1/edit.0 file /usr/share/man/cat2/send.0 link /usr/share/man/cat2/sendmsg.0 target /usr/share/man/cat2/send.0 link /usr/share/man/cat2/sendto.0 target /usr/share/man/cat2/send.0 file /usr/share/man/cat3/alloca.0 link /usr/share/man/cat3/calloc.0 target /usr/share/man/cat3/alloca.0 link /usr/share/man/cat3/free.0 target /usr/share/man/cat3/alloca.0 link /usr/share/man/cat3/malloc.0 target /usr/share/man/cat3/alloca.0 link /usr/share/man/cat3/realloc.0 target /usr/share/man/cat3/alloca.0 file /usr/share/man/cat3/moncontrol.0 link /usr/share/man/cat3/monitor.0 target /usr/share/man/cat3/moncontrol.0 link /usr/share/man/cat3/monstartup.0 target /usr/share/man/cat3/moncontrol.0 file /usr/share/man/cat8/fastboot.0 link /usr/share/man/cat8/halt.0 target /usr/share/man/cat8/fastboot.0 link /usr/share/man/cat8/reboot.0 target /usr/share/man/cat8/fastboot.0 file /usr/share/man/cat3/dbm.0 link /usr/share/man/cat3/dbminit.0 target /usr/share/man/cat3/dbm.0 link /usr/share/man/cat3/delete.0 target /usr/share/man/cat3/dbm.0 link /usr/share/man/cat3/fetch.0 target /usr/share/man/cat3/dbm.0 link /usr/share/man/cat3/firstkey.0 target /usr/share/man/cat3/dbm.0 link /usr/share/man/cat3/nextkey.0 target /usr/share/man/cat3/dbm.0 link /usr/share/man/cat3/store.0 target /usr/share/man/cat3/dbm.0 file /usr/share/man/cat2/getitimer.0 link /usr/share/man/cat2/setitimer.0 target /usr/share/man/cat2/getitimer.0 file /usr/share/man/cat3/initstate.0 link /usr/share/man/cat3/random.0 target /usr/share/man/cat3/initstate.0 link /usr/share/man/cat3/setstate.0 target /usr/share/man/cat3/initstate.0 link /usr/share/man/cat3/srandom.0 target /usr/share/man/cat3/initstate.0 file /usr/share/man/cat2/write.0 link /usr/share/man/cat2/writev.0 target /usr/share/man/cat2/write.0 file /usr/share/man/cat3/setbuf.0 link /usr/share/man/cat3/setbuffer.0 target /usr/share/man/cat3/setbuf.0 link /usr/share/man/cat3/setlinebuf.0 target /usr/share/man/cat3/setbuf.0 link /usr/share/man/cat3/setvbuf.0 target /usr/share/man/cat3/setbuf.0 file /usr/share/man/cat3/exp.0 link /usr/share/man/cat3/expm1.0 target /usr/share/man/cat3/exp.0 link /usr/share/man/cat3/log.0 target /usr/share/man/cat3/exp.0 link /usr/share/man/cat3/log10.0 target /usr/share/man/cat3/exp.0 link /usr/share/man/cat3/log1p.0 target /usr/share/man/cat3/exp.0 link /usr/share/man/cat3/pow.0 target /usr/share/man/cat3/exp.0 file /usr/share/man/cat3/acos.0 link /usr/share/man/cat3/asin.0 target /usr/share/man/cat3/acos.0 link /usr/share/man/cat3/atan.0 target /usr/share/man/cat3/acos.0 link /usr/share/man/cat3/atan2.0 target /usr/share/man/cat3/acos.0 link /usr/share/man/cat3/cos.0 target /usr/share/man/cat3/acos.0 link /usr/share/man/cat3/sin.0 target /usr/share/man/cat3/acos.0 link /usr/share/man/cat3/tan.0 target /usr/share/man/cat3/acos.0 file /usr/share/man/cat2/getrlimit.0 link /usr/share/man/cat2/setrlimit.0 target /usr/share/man/cat2/getrlimit.0 file /usr/share/man/cat3/termcap.0 link /usr/share/man/cat3/tgetent.0 target /usr/share/man/cat3/termcap.0 link /usr/share/man/cat3/tgetflag.0 target /usr/share/man/cat3/termcap.0 link /usr/share/man/cat3/tgetnum.0 target /usr/share/man/cat3/termcap.0 link /usr/share/man/cat3/tgetstr.0 target /usr/share/man/cat3/termcap.0 link /usr/share/man/cat3/tgoto.0 target /usr/share/man/cat3/termcap.0 link /usr/share/man/cat3/tputs.0 target /usr/share/man/cat3/termcap.0 file /usr/share/man/cat5/dump.0 link /usr/share/man/cat5/dumpdates.0 target /usr/share/man/cat5/dump.0 file /usr/share/man/cat1/chfn.0 link /usr/share/man/cat1/chpass.0 target /usr/share/man/cat1/chfn.0 link /usr/share/man/cat1/chsh.0 target /usr/share/man/cat1/chfn.0 file /usr/share/man/cat2/recv.0 link /usr/share/man/cat2/recvfrom.0 target /usr/share/man/cat2/recv.0 link /usr/share/man/cat2/recvmsg.0 target /usr/share/man/cat2/recv.0 file /usr/share/man/cat3/rcmd.0 link /usr/share/man/cat3/rresvport.0 target /usr/share/man/cat3/rcmd.0 link /usr/share/man/cat3/ruserok.0 target /usr/share/man/cat3/rcmd.0 file /usr/share/man/cat5/utmp.0 link /usr/share/man/cat5/wtmp.0 target /usr/share/man/cat5/utmp.0 file /usr/share/man/cat1/egrep.0 link /usr/share/man/cat1/fgrep.0 target /usr/share/man/cat1/egrep.0 link /usr/share/man/cat1/grep.0 target /usr/share/man/cat1/egrep.0 file /usr/share/man/cat3/environ.0 link /usr/share/man/cat3/execl.0 target /usr/share/man/cat3/environ.0 link /usr/share/man/cat3/execle.0 target /usr/share/man/cat3/environ.0 link /usr/share/man/cat3/execlp.0 target /usr/share/man/cat3/environ.0 link /usr/share/man/cat3/exect.0 target /usr/share/man/cat3/environ.0 link /usr/share/man/cat3/execv.0 target /usr/share/man/cat3/environ.0 link /usr/share/man/cat3/execve.0 target /usr/share/man/cat3/environ.0 link /usr/share/man/cat3/execvp.0 target /usr/share/man/cat3/environ.0 file /usr/share/man/cat3/endpwent.0 link /usr/share/man/cat3/getpwent.0 target /usr/share/man/cat3/endpwent.0 link /usr/share/man/cat3/getpwnam.0 target /usr/share/man/cat3/endpwent.0 link /usr/share/man/cat3/getpwuid.0 target /usr/share/man/cat3/endpwent.0 link /usr/share/man/cat3/setpwent.0 target /usr/share/man/cat3/endpwent.0 link /usr/share/man/cat3/setpwfile.0 target /usr/share/man/cat3/endpwent.0 file /usr/share/man/cat3/asctime.0 link /usr/share/man/cat3/ctime.0 target /usr/share/man/cat3/asctime.0 link /usr/share/man/cat3/gmtime.0 target /usr/share/man/cat3/asctime.0 link /usr/share/man/cat3/localtime.0 target /usr/share/man/cat3/asctime.0 link /usr/share/man/cat3/timezone.0 target /usr/share/man/cat3/asctime.0 file /usr/share/man/cat2/mount.0 link /usr/share/man/cat2/umount.0 target /usr/share/man/cat2/mount.0 file /usr/share/man/cat3/endttyent.0 link /usr/share/man/cat3/getttyent.0 target /usr/share/man/cat3/endttyent.0 link /usr/share/man/cat3/getttynam.0 target /usr/share/man/cat3/endttyent.0 link /usr/share/man/cat3/setttyent.0 target /usr/share/man/cat3/endttyent.0 file /usr/share/man/cat1/compress.0 link /usr/share/man/cat1/uncompress.0 target /usr/share/man/cat1/compress.0 link /usr/share/man/cat1/zcat.0 target /usr/share/man/cat1/compress.0 file /usr/share/man/cat2/fstat.0 link /usr/share/man/cat2/lstat.0 target /usr/share/man/cat2/fstat.0 link /usr/share/man/cat2/stat.0 target /usr/share/man/cat2/fstat.0 file /usr/share/man/cat3/endhostent.0 link /usr/share/man/cat3/gethostbyaddr.0 target /usr/share/man/cat3/endhostent.0 link /usr/share/man/cat3/gethostbyname.0 target /usr/share/man/cat3/endhostent.0 link /usr/share/man/cat3/gethostent.0 target /usr/share/man/cat3/endhostent.0 link /usr/share/man/cat3/sethostent.0 target /usr/share/man/cat3/endhostent.0 link /usr/share/man/cat3/sethostfile.0 target /usr/share/man/cat3/endhostent.0 file /usr/share/man/cat3/fscanf.0 link /usr/share/man/cat3/scanf.0 target /usr/share/man/cat3/fscanf.0 link /usr/share/man/cat3/sscanf.0 target /usr/share/man/cat3/fscanf.0 file /usr/share/man/cat1/checkeq.0 link /usr/share/man/cat1/eqn.0 target /usr/share/man/cat1/checkeq.0 link /usr/share/man/cat1/neqn.0 target /usr/share/man/cat1/checkeq.0 file /usr/share/man/cat3/fprintf.0 link /usr/share/man/cat3/printf.0 target /usr/share/man/cat3/fprintf.0 link /usr/share/man/cat3/sprintf.0 target /usr/share/man/cat3/fprintf.0 link /usr/share/man/cat3/vfprintf.0 target /usr/share/man/cat3/fprintf.0 link /usr/share/man/cat3/vprintf.0 target /usr/share/man/cat3/fprintf.0 link /usr/share/man/cat3/vsprintf.0 target /usr/share/man/cat3/fprintf.0 file /usr/share/man/cat2/getpid.0 link /usr/share/man/cat2/getppid.0 target /usr/share/man/cat2/getpid.0 file /usr/share/man/cat4/dvhp.0 link /usr/share/man/cat4/hp.0 target /usr/share/man/cat4/dvhp.0 link /usr/share/man/cat4/rm.0 target /usr/share/man/cat4/dvhp.0 link /usr/share/man/cat4/rp.0 target /usr/share/man/cat4/dvhp.0 link /usr/share/man/cat4/xp.0 target /usr/share/man/cat4/dvhp.0 file /usr/share/man/cat3/closelog.0 link /usr/share/man/cat3/openlog.0 target /usr/share/man/cat3/closelog.0 link /usr/share/man/cat3/setlogmask.0 target /usr/share/man/cat3/closelog.0 link /usr/share/man/cat3/syslog.0 target /usr/share/man/cat3/closelog.0 file /usr/share/man/cat1/diff.0 link /usr/share/man/cat1/diffh.0 target /usr/share/man/cat1/diff.0 file /usr/share/man/cat8/uucico.0 link /usr/share/man/cat8/uucpd.0 target /usr/share/man/cat8/uucico.0 file /usr/share/man/cat2/pselect.0 link /usr/share/man/cat2/select.0 target /usr/share/man/cat2/pselect.0 file /usr/share/man/cat2/getsockopt.0 link /usr/share/man/cat2/setsockopt.0 target /usr/share/man/cat2/getsockopt.0 file /usr/share/man/cat7/intro.0 link /usr/share/man/cat7/miscellaneous.0 target /usr/share/man/cat7/intro.0 file /usr/share/man/cat3/erf.0 link /usr/share/man/cat3/erfc.0 target /usr/share/man/cat3/erf.0 file /usr/share/man/cat2/wait.0 link /usr/share/man/cat2/wait3.0 target /usr/share/man/cat2/wait.0 link /usr/share/man/cat2/wait4.0 target /usr/share/man/cat2/wait.0 link /usr/share/man/cat2/waitpid.0 target /usr/share/man/cat2/wait.0 file /usr/share/man/cat3/endgrent.0 link /usr/share/man/cat3/getgrent.0 target /usr/share/man/cat3/endgrent.0 link /usr/share/man/cat3/getgrgid.0 target /usr/share/man/cat3/endgrent.0 link /usr/share/man/cat3/getgrnam.0 target /usr/share/man/cat3/endgrent.0 link /usr/share/man/cat3/setgrent.0 target /usr/share/man/cat3/endgrent.0 file /usr/share/man/cat1/more.0 link /usr/share/man/cat1/page.0 target /usr/share/man/cat1/more.0 file /usr/share/man/cat1/arch.0 link /usr/share/man/cat1/machine.0 target /usr/share/man/cat1/arch.0 ================================================ FILE: distrib/base/mi.home ================================================ # # Machine independent user file system manifest file. # default owner 0 group 0 dirmode 0775 filemode 0664 file README.txt ================================================ FILE: distrib/home/.gitignore ================================================ ================================================ FILE: distrib/home/README.txt ================================================ User filesystem. ================================================ FILE: distrib/notes/ANNOUNCEMENT.md ================================================ --- DiscoBSD 2.6 RELEASED --- # DiscoBSD 2.6 Released February 11, 2026 DiscoBSD 2.6 is released. This is the seventh official release of DiscoBSD, the multi-platform 2.11BSD-based Unix-like operating system for microcontrollers. DiscoBSD 2.6 offers ports to two different microcontroller platforms: * DiscoBSD/stm32 - STM32F4 family of 32-bit Arm Cortex-M4 microcontrollers from STMicroelectronics * DiscoBSD/pic32 - PIC32MX7 family of 32-bit MIPS32 M4K microcontrollers from Microchip DiscoBSD/stm32, unique only to DiscoBSD, offers a familiar BSD environment on the many available STM32F4 development boards. DiscoBSD/pic32, inherited from RetroBSD, offers a familiar BSD environment on the many available PIC32MX7 development boards, as well as full use with the included VirtualMIPS PIC32 simulator. A nearly-complete development environment is included in DiscoBSD. There are: various text editors and compilers, a MIPS assembler and MIPS linker, and many more programming languages in addition to C and asm, such as Scheme, BASIC, Forth, RetroForth, lex, yacc, and TCL. Examples are provided in the file system at /usr/share/examples. As a descendant of 2.11BSD, DiscoBSD inherits its strong BSD heritage. The userland is powerful, full-featured, and comfortable to competent UNIX users, as it is derived from the rich 4.3BSD-Tahoe userland, modern implementations of classic utilities, and improvements along the way. Install, build, and debug instructions can be found in the README files. ## Significant Changes and Improvements ### New Features in this Release * Kernel source tree follows 4.4BSD hierarchy, to facilitate future ports. * Separate out console and {,k}mem drivers to be machine-independent. * Refresh of kernel compile Configs and Makefiles for pic32 and stm32. * Many improvements and cleanup of sysctl(8) and kernel-side sysctl code. * KNF style(9) and ANSI cleanup in kernel, ports, and userland. * Clarity, bugfixes, and improvements in documentation. ### Filesystem * Hard link uptime(1) to w(1); uptime(1) now enabled. * Properly symlink /etc/localtime with DiscoBSD zone files. * Update libc bzero(3) to take a size_t, not unsigned int or long. * FD_ZERO(2) in libc now uses memset(3) instead of bzero(3). * Many instances in tree of replacing bzero(3) with memset(3). ### Build System Continuing the overhaul of the build system. * Rename kconfig(8) back to config(8), in line with all BSDs. * 4.4BSD names for kernel files locore.S, conf.c, and sig_machdep.c. * Both BSD make and GNU make are fully supported. * FreeBSD's version of BSD make requires `MAKESYSPATH` set. * Speed up in imaging SD card with DiscoBSD file system. * Speed up in `make release`, up to 5x faster. * Releases now include ANNOUNCEMENT.md, maintained in tree. * Add back many SCCS version tags from 2.11BSD. ### DiscoBSD/stm32 Specific Improvements * Support for STM32F413H-DISCO development board. * Extensions to HAL library for the Memory Protection Unit (MPU). * MPU sysctls for Enabled, num of Regions, and CTRL register. * Add sysctl(8) support to read and display MPU information. * Clean structure for SDIO GPIO pins; extensible to new boards. * Separate nulldev() into nullopen(), nullclose(), and nullstop(). ### DiscoBSD/pic32 Specific Improvements * Refactor and normalize kernel compile options with stm32. * Consolidate compiler tools and paths under pic32/conf/compiler.mk. * Separate nulldev() into nullopen(), nullclose(), and nullstop(). ### Documentation, Bugfixes, and Corrections * Documentation to set up a Linux host development environment. * Releases are documented in ANNOUNCEMENT.md, maintained in tree. * Steady improvements and corrections in documentation. * Manual page fixes and improvements. ## Host Development Environment While DiscoBSD is primarily developed and tested on OpenBSD, Linux and FreeBSD are also supported as host environments. These host development environments have been tested: ### OpenBSD 7.6 * Host compiler Clang 16.0.6 * Host compiler GCC 11.2.0 * Host compiler Clang 17.0.6 * BSD make and GNU make * DiscoBSD/stm32 * Custom port of arm-none-eabi-gcc 12.2.0 (rmprofile) * OpenBSD package of arm-none-eabi-binutils 2.40 * Custom port of arm-none-eabi-gdb 12.1 * OpenBSD package of OpenOCD 0.11.0 * Custom port of ST-Link 1.8.0 * DiscoBSD/pic32 * Custom port of mips-elf-gcc 12.2.0 * Custom port of mips-elf-binutils 2.40 ### Ubuntu 24.04 (Zorin OS 18 Core) * Host compiler GCC 13.2.0 * Host compiler Clang 18.1.3 * BSD make and GNU make * DiscoBSD/stm32 * arm-none-eabi-gcc 13.2.1 * arm-none-eabi-binutils 2.42 * DiscoBSD/pic32 * Untested ### Ubuntu 23.04 * Host compiler GCC 12.3.0 * Host compiler Clang 15.0.7 * BSD make and GNU make * DiscoBSD/stm32 * arm-none-eabi-gcc 12.2.1 * arm-none-eabi-binutils 2.39 * DiscoBSD/pic32 * Untested ### FreeBSD 13.2 * Host compiler GCC 12.2.0 * Host compiler Clang 14.0.5 * BSD make (with MAKESYSPATH set) and GNU make * DiscoBSD/stm32 * arm-none-eabi-gcc 10.3.1 (gcc-arm-embedded) * arm-none-eabi-binutils 2.40 * DiscoBSD/pic32 * Untested ## Release Build Environment DiscoBSD distribution releases are cross-built on OpenBSD. The release build environment is configured as below: ### OpenBSD 7.6 * Host compiler Clang 16.0.6 * BSD make * DiscoBSD/stm32 * Custom port of arm-none-eabi-gcc 12.2.0 (rmprofile) * OpenBSD package of arm-none-eabi-binutils 2.40 * DiscoBSD/pic32 * Custom port of mips-elf-gcc 12.2.0 * Custom port of mips-elf-binutils 2.40 ## Developers and Contributors this Release * @chettrick ## Full Changelog https://github.com/chettrick/discobsd/compare/DISCOBSD_2_5...DISCOBSD_2_6 ================================================ FILE: distrib/pic32/.gitignore ================================================ *.img _manifest ================================================ FILE: distrib/pic32/README.md ================================================ # DiscoBSD/pic32 - 2.11BSD-based OS for PIC32MX7 MIPS MCUs ## Currently supported hardware * [Fubarino SD][1] board. * [Olimex Duinomite][2], [Duinomite-Mini][3], [Duinomite-Mega][4] and [Duinomite-eMega][5] boards. * [Olimex Pinguino-Micro][6] board with PIC32MX795F512H microcontroller. * [Maximite][7] and [Colour Maximite][8] computers. * [Majenko SDXL][9] board. * [4D Systems Picadillo-35T][10] board. * [MikroElektronika MultiMedia Board][11] for PIC32MX7. * [chipKIT Max32][12] board with SD card shield. * [chipKIT WF32][13] board with 2.4" LCD TFT display shield. * [Sparkfun UBW32][14] board with SD card slot. * [Microchip Explorer 16][15] board, with PIC32 CAN-USB plug-in module and SD & MMC pictail. * [Microchip PIC32 USB][16] or [Ethernet Starter Kit][17], with I/O Expansion board and SD & MMC pictail. * [Pontech Quick240][18] Quick Universal Industrial Control Kard system based on the chipKIT platform. [1]: https://www.fubarino.org/sd/ [2]: https://www.olimex.com/Products/Duino/Duinomite/DUINOMITE/ [3]: https://www.olimex.com/Products/Duino/Duinomite/DUINOMITE-MINI/ [4]: https://www.olimex.com/Products/Duino/Duinomite/DUINOMITE-MEGA/ [5]: https://www.olimex.com/Products/Duino/Duinomite/DUINOMITE-eMEGA/ [6]: https://www.olimex.com/Products/Duino/PIC32/PIC32-RETROBSD/ [7]: https://geoffg.net/MonoMaximite.html [8]: https://geoffg.net/OriginalColourMaximite.html [9]: https://wiki.kewl.org/boards:sdxl [10]: https://resources.4dsystems.com.au/datasheets/legacy/Picadillo-35T_datasheet_R_1_5.pdf [11]: https://web.archive.org/web/20160815090501/http://www.mikroe.com/multimedia/pic32mx7/ [12]: https://chipkit.net/wiki/index.php?title=chipKIT_Max32 [13]: https://chipkit.net/wiki/index.php?title=chipKIT_WF32 [14]: https://www.schmalzhaus.com/UBW32/ [15]: https://www.microchip.com/en-us/development-tool/dm240001 [16]: https://www.microchip.com/en-us/development-tool/dm320003-2 [17]: https://www.microchip.com/en-us/development-tool/dm320004 [18]: https://quick240.com ## Build A few packages are required to compile everything from source. Under Ubuntu installation can be done by the commands: ```sh $ apt install bison byacc flex git groff-base libbsd-dev $ apt install libelf-dev libfuse-dev sudo unzip zip ``` If a mips-elf-gcc compiler package is not available from the host distribution, then the compiler toolchain must be built following [these instructions][19]. [19]: https://web.archive.org/web/20200126100825/http://retrobsd.org/wiki/doku.php/doc/toolchain-mips The desired filesystem size and swap area size can be changed, as required. Default is: ```Makefile FS_MBYTES = 200 U_MBYTES = 200 SWAP_MBYTES = 2 ``` To compile the kernel and build a filesystem image, run: ```sh $ make MACHINE=pic32 MACHINE_ARCH=mips distribution ``` A resulting root filesystem image is in the file `sdcard.img`. Kernel files are named `unix.hex` and are in target board subdirectories. ### Filesystem image The file system image `sdcard.img` needs to be imaged onto an SD card. On Windows host systems use a disk imaging utility such as [Rufus][20]. On Unix-like host systems with `dd` run: ```sh $ dd bs=1M if=sdcard.img of=/path/to/SD/card ``` The target `installfs` can be used to image the SD card on Unix-like systems. Provide the path to the SD card via the command line: ```sh $ make MACHINE=pic32 SDCARD=/path/to/SD/card installfs ``` [20]: https://github.com/pbatard/rufus ### Install kernel The kernel image must be written to the PIC32 flash memory. The specific procedure depends on the target development board. #### PIC32-RETROBSD board: Use the [pic32prog][21] utility and a USB cable to install the kernel: ```sh $ pic32prog sys/arch/pic32/compile/PINGUINO_MICRO/unix.hex ``` #### Max32 board: Use the [pic32prog][21] utility and a USB cable to install the kernel: ```sh $ pic32prog -d /dev/ttyUSB0 sys/arch/pic32/compile/MAX32/unix.hex ``` #### UBW32 board: Use the [pic32prog][21] utility and a USB cable to install the kernel: ```sh $ pic32prog sys/arch/pic32/compile/UBW32/unix.hex ``` #### Maximite: Use the bootload program for Windows, download links are available here: https://geoffg.net/MonoMaximite.html#Downloads #### Explorer 16 board: There is an auxiliary PIC18 chip on the Explorer 16 board, which can be used as a built-in programmer device. A PICkit 2 adapter is needed to install the required firmware, as described in [this article][22] in the section "Hack #2: Lose the PICkit 2, Save $35". This should be done only once. Then, use the [pic32prog][21] utility and a USB cable to install the kernel: ``` sh $ pic32prog sys/arch/pic32/compile/EXPLORER16/unix.hex ``` #### PIC32 Starter Kit: Use the PICkit 2 adapter and software to install a boot loader from the file [starter-kit/bootloader.hex][23] in the [pic32-usb-bootloader][24] repository. This should be done only once. Then, use the [pic32prog][21] utility and a USB cable to install the kernel: ```sh $ pic32prog sys/arch/pic32/compile/STARTER_KIT/unix.hex ``` [21]: https://github.com/majenkotech/pic32prog-autotools/archive/refs/tags/2.1.57.zip [22]: https://web.archive.org/web/20160506100841/http://www.paintyourdragon.com/?p=51 [23]: https://github.com/sergev/pic32-usb-bootloader/blob/master/starter-kit/bootloader.hex [24]: https://github.com/sergev/pic32-usb-bootloader ## Simulator Use the VirtualMIPS MIPS32 simulator to develop and debug DiscoBSD/pic32 without the need for a hardware development board. By default, the simulator is configured to imitate a Max32 board. To build it: ```sh $ cd tools/virtualmips $ make ``` Run it: ```sh $ ./pic32 ``` Configuration of the simulated board is stored in the file `pic32_max32.conf`. ================================================ FILE: distrib/pic32/md.pic32 ================================================ # # Machine dependent PIC32 root file system manifest file. # default owner 0 group 0 dirmode 0775 filemode 0664 # # Directories. # dir /bin dir /dev dir /etc dir /sbin dir /tmp dir /usr dir /home # # Files: /usr/bin # default filemode 0775 dir /usr/bin file /usr/bin/adb # XXX file /usr/bin/adc-demo # # Files: /usr/include # default filemode 0664 dir /usr/include dir /usr/include/machine file /usr/include/machine/_float.h file /usr/include/machine/cpu.h file /usr/include/machine/debug.h file /usr/include/machine/elf_machdep.h file /usr/include/machine/frame.h file /usr/include/machine/io.h file /usr/include/machine/limits.h file /usr/include/machine/machparam.h file /usr/include/machine/pic32mx.h file /usr/include/machine/setjmp.h file /usr/include/machine/signal.h file /usr/include/machine/types.h # # Files: /usr/libexec # default filemode 0775 dir /usr/libexec file /usr/libexec/smlrc # # Files: /usr/share/man # default dirmode 0775 dir /usr/share/man dir /usr/share/man/cat1 # # Single pages # file /usr/share/man/cat1/adb.0 ================================================ FILE: distrib/stm32/.gitignore ================================================ *.img _manifest ================================================ FILE: distrib/stm32/README.md ================================================ # DiscoBSD/stm32 - 2.11BSD-based OS for Arm Cortex-M4 MCUs ## Currently supported hardware * [WeAct Studio STM32F405RGT6 Core board][1] * [STMicroelectronics NUCLEO-F411RE][2] * [STMicroelectronics STM32F412G-DISCO][3] * [WeAct Studio STM32F412RET6 Core board][1] * [STMicroelectronics STM32F413H-DISCO][4] * [STMicroelectronics NUCLEO-F446RE][5] * [WeAct Studio STM32F446RET6 Core board][1] * [STMicroelectronics STM32F469I-DISCO][6] * [STMicroelectronics STM32F4DISCOVERY][7] * [DevEBox STM32F407VET6 STM32F4VE][8] [1]: https://github.com/WeActStudio/WeActStudio.STM32F4_64Pin_CoreBoard [2]: https://www.st.com/en/evaluation-tools/nucleo-f411re.html [3]: https://www.st.com/en/evaluation-tools/32f412gdiscovery.html [4]: https://www.st.com/en/evaluation-tools/32f413hdiscovery.html [5]: https://www.st.com/en/evaluation-tools/nucleo-f446re.html [6]: https://www.st.com/en/evaluation-tools/32f469idiscovery.html [7]: https://www.st.com/en/evaluation-tools/stm32f4discovery.html [8]: https://stm32-base.org/boards/STM32F407VET6-STM32-F4VE-V2.0.html ## DiscoBSD/stm32 Up and Running The file system image `sdcard.img` needs to be imaged onto an SD card. On Windows host systems use a disk imaging utility such as [Rufus][20]. On Unix-like host systems with `dd` run: ```sh $ dd bs=1M if=sdcard.img of=/path/to/SD/card ``` The target `installfs` can be used to image the SD card on Unix-like systems. Provide the path to the SD card via the command line: ```sh $ make SDCARD=/path/to/SD/card installfs ``` The board-specific kernel `unix` must be loaded into the MCU's flash memory. Formats are ELF `unix.elf`, binary `unix.bin`, and Intel HEX `unix.hex`. On Windows host systems use [STM32CubeProgrammer][21] for flash programming. On Unix-like host systems use `st-flash` from the [stlink-org project][22] to load the binary-formatted kernel `unix.bin` into flash memory at 0x08000000. ```sh $ st-flash --reset write unix.bin 0x08000000 ``` [20]: https://github.com/pbatard/rufus [21]: https://www.st.com/en/development-tools/stm32cubeprog.html [22]: https://github.com/stlink-org/stlink ## Logging in to DiscoBSD First, connect to the development board via the serial port. The STM32 Disco and Nucleo boards offer a USB VCP serial port. ```sh $ cu -l /dev/cuaU0 -s 115200 ``` Other systems may use serial port utilities such as `screen`, `minicom`, `putty`, or `teraterm`. Log in to DiscoBSD with user `root` and a blank password. Shutdown DiscoBSD with: ```sh $ shutdown -h now ``` `halt` and `reboot` also bring down the system. ## Building the DiscoBSD/stm32 kernel and operating system on a Unix-like host ```sh $ make distribution ``` The kernel (for the F412GDISCO board) can be built independently by: ```sh $ cd sys/arch/stm32/compile/F412GDISCO $ make ``` Note: Building the kernel requires the `tools/config` config utility. ## Debugging DiscoBSD/stm32 on a development board via OpenOCD and GDB ```sh $ make BOARD=F412GDISCO ocd ``` In a separate terminal, run `gdb` with: ```sh $ make BOARD=F412GDISCO gdb-ocd ``` Running `make help` lists targets to debug DiscoBSD/stm32 with OpenOCD and GDB. ================================================ FILE: distrib/stm32/md.stm32 ================================================ # # Machine dependent STM32 root file system manifest file. # default owner 0 group 0 dirmode 0775 filemode 0664 # # Directories. # dir /bin dir /dev dir /etc dir /sbin dir /tmp dir /usr dir /home # # Files: /usr/bin # default filemode 0775 dir /usr/bin file /usr/bin/lex # # Files: /usr/include # default filemode 0664 dir /usr/include dir /usr/include/machine file /usr/include/machine/_float.h file /usr/include/machine/cpu.h file /usr/include/machine/debug.h file /usr/include/machine/elf_machdep.h file /usr/include/machine/fault.h file /usr/include/machine/frame.h file /usr/include/machine/intr.h file /usr/include/machine/io.h file /usr/include/machine/limits.h file /usr/include/machine/machparam.h file /usr/include/machine/mpuvar.h file /usr/include/machine/setjmp.h file /usr/include/machine/signal.h file /usr/include/machine/types.h # # Files: /usr/share # default filemode 0444 dir /usr/share dir /usr/share/misc file /usr/share/misc/ncform # # Files: /usr/share/examples/lex # default filemode 0644 dir /usr/share/examples dir /usr/share/examples/lex file /usr/share/examples/lex/Makefile file /usr/share/examples/lex/awk.lx.l file /usr/share/examples/lex/example.l file /usr/share/examples/lex/scan.l file /usr/share/examples/lex/scanner.l ================================================ FILE: etc/MAKEDEV ================================================ #!/bin/sh - # # Copyright (c) 1980 Regents of the University of California. # All rights reserved. The Berkeley software License Agreement # specifies the terms and conditions for redistribution. # # Device "make" file. Valid arguments: # std standard devices # local configuration specific devices # fd file descriptor driver # Disks: # sd* flash cards SecureDigital # Pseudo terminals: # pty* set of 16 master and slave pseudo terminals PATH=/etc:/sbin:/usr/sbin:/bin:/usr/bin umask 77 for i do case $i in std) mknod console c 0 0 mknod mem c 1 0 ; chmod 640 mem ; chgrp kmem mem mknod kmem c 1 1 ; chmod 640 kmem ; chgrp kmem kmem mknod null c 1 2 ; chmod 666 null mknod zero c 1 3 ; chmod 444 zero mknod tty c 2 0 ; chmod 666 tty mknod klog c 3 0 ; chmod 600 klog ;; fd) umask 0 rm -rf fd rm -f stdin stdout stderr mkdir fd chmod 755 fd mknod stdin c 4 0 mknod stdout c 4 1 mknod stderr c 4 2 eval `echo "" | awk '{ for (i = 0; i < 32; i++) printf("mknod fd/%d c 4 %d; ",i,i); }'` ;; rd) umask 2 rm -f rd[0123] rd[0123][abcd] mknod rd0 b 0 0 mknod rd0a b 0 1 mknod rd0b b 0 2 mknod rd0c b 0 2 mknod rd0d b 0 2 mknod rd1 b 1 0 mknod rd1a b 1 1 mknod rd1b b 1 2 mknod rd1c b 1 2 mknod rd1d b 1 2 mknod rd2 b 2 0 mknod rd2a b 2 1 mknod rd2b b 2 2 mknod rd2c b 2 2 mknod rd2d b 2 2 mknod rd3 b 3 0 mknod rd3a b 3 1 mknod rd3b b 3 2 mknod rd3c b 3 2 mknod rd3d b 3 2 chgrp operator rd[0123] chgrp operator rd[0123][abcd] chmod 640 rd[0123][abcd] chmod 640 rd[0123] ;; gpio) umask 0 rm -f port[abcdefg] conf[abcdef] mknod porta c 5 0 mknod portb c 5 1 mknod portc c 5 2 mknod portd c 5 3 mknod porte c 5 4 mknod portf c 5 5 mknod portg c 5 6 mknod confa c 5 64 mknod confb c 5 65 mknod confc c 5 66 mknod confd c 5 67 mknod confe c 5 68 mknod conff c 5 69 mknod confg c 5 70 ;; adc) umask 0 rm -f adc[0123456789] adc1[012345] mknod adc0 c 6 0 mknod adc1 c 6 1 mknod adc2 c 6 2 mknod adc3 c 6 3 mknod adc4 c 6 4 mknod adc5 c 6 5 mknod adc6 c 6 6 mknod adc7 c 6 7 mknod adc8 c 6 8 mknod adc9 c 6 9 mknod adc10 c 6 10 mknod adc11 c 6 11 mknod adc12 c 6 12 mknod adc13 c 6 13 mknod adc14 c 6 14 mknod adc15 c 6 15 ;; spi) umask 0 rm -f spi[1234] mknod spi1 c 7 0 mknod spi2 c 7 1 mknod spi3 c 7 2 mknod spi4 c 7 3 ;; glcd) umask 0 rm -f glcd0 mknod glcd0 c 8 0 ;; oc) umask 0 rm -f oc[12345] mknod oc1 c 9 0 mknod oc2 c 9 1 mknod oc3 c 9 2 mknod oc4 c 9 3 mknod oc5 c 9 4 ;; local) sh MAKEDEV.local ;; esac done ================================================ FILE: etc/MAKEDEV.local ================================================ rm -f swap ln ra0a swap chgrp kmem swap chmod 640 swap rm -f ttyi6 ttyd0; mknod ttyd0 c 3 22 rm -f ttyi7 ttyd1; mknod ttyd1 c 3 23 rm -f ttyi8 ttyd2; mknod ttyd2 c 3 24 rm -f ttyi9 ttyd3; mknod ttyd3 c 3 25 rm -f ttyia ttyd4; mknod ttyd4 c 3 26 rm -f ttyic ttyd5; mknod ttyd5 c 3 156 rm -f ttyh1 dir-shasta; mknod dir-shasta c 3 1 rm -f ttyh6 dir-rose; mknod dir-rose c 3 6 rm -f ttyh7 dir-namsan; mknod dir-namsan c 3 7 rm -f ttyid dir-ps; mknod dir-ps c 3 157 rm -f ttyie cua0; mknod cua0 c 3 158 rm -f ttyif dir-scgl; mknod dir-scgl c 3 159 chown uucp dir-* chmod 660 dir-* # Cua* can't be owned by anyone real who wants to use the dialer if the mode # 060 below and the dialer group is to work. Note that the uucp programs # must be in the dialer group. chown 32767 cua* chgrp dialer cua* chmod 060 cua* ================================================ FILE: etc/Makefile ================================================ # # Public domain - 1997/1/10 - sms # # @(#)Makefile 1.0 (2.11BSD) 1997/1/10 # # DESTDIR is defined here to be something which does *NOT* exist - it must be # specified on the command line when doing a "make DESTDIR=/mnt distribution". # This is aimed at avoiding overwriting the system disk's /etc files. # # Example: # mount /dev/ra1a /mnt # make DESTDIR=/mnt distribution TOPSRC!=cd ..; pwd include ${TOPSRC}/share/mk/sys.mk DESTDIR= /foobar RELEASEDIR= /foobaz OWN= root GRP= wheel TZDIR= /usr/share/zoneinfo LOCALTIME= Canada/Mountain FILES= fstab gettytab group motd passwd rc rc.local shells ttys all install depend lint tags: clean: rm -f *~ distribution: distribution-etc-root-var distribution-etc-root-var: distrib-dirs ${INSTALL} -d -o ${OWN} -g ${GRP} -m 755 ${DESTDIR}/dev ${INSTALL} -d -o ${OWN} -g ${GRP} -m 755 ${DESTDIR}/etc ${INSTALL} -c -o ${OWN} -g ${GRP} -m 644 ${FILES} ${DESTDIR}/etc ${INSTALL} -c -o root -g wheel -m 600 shadow ${DESTDIR}/etc # ${INSTALL} -c -o root -g wheel -m 600 master.passwd ${DESTDIR}/etc # ${INSTALL} -c -o ${OWN} -g ${GRP} -m 555 MAKEDEV.local MAKEDEV \ # ${DESTDIR}/dev ${INSTALL} -c -o ${OWN} -g ${GRP} -m 555 MAKEDEV \ ${DESTDIR}/etc cd root; \ ${INSTALL} -c -o root -g wheel -m 644 dot.profile \ ${DESTDIR}/root/.profile; \ ${INSTALL} -c -o root -g wheel -m 644 dot.profile \ ${DESTDIR}/.profile ln -sf ${TZDIR}/${LOCALTIME} ${DESTDIR}/etc/localtime ${INSTALL} -c -m 444 ${DESTDIR}/usr/share/misc/termcap \ ${DESTDIR}/etc/termcap # ${INSTALL} -c -o ${OWN} -g operator -m 664 /dev/null \ # ${DESTDIR}/etc/dumpdates ${INSTALL} -d -o ${OWN} -g ${GRP} -m 655 ${DESTDIR}/var/run ${INSTALL} -c -o ${OWN} -g wheel -m 644 /dev/null \ ${DESTDIR}/var/log/messages # ${INSTALL} -c -o ${OWN} -g ${GRP} -m 644 /dev/null \ # ${DESTDIR}/usr/adm/daemonlog # ${INSTALL} -c -o ${OWN} -g operator -m 664 /dev/null \ # ${DESTDIR}/usr/adm/shutdownlog # ${INSTALL} -c -o ${OWN} -g ${GRP} -m 644 /dev/null \ # ${DESTDIR}/var/run/utmp # ${INSTALL} -c -o nobody -g ${GRP} -m 644 /dev/null \ # ${DESTDIR}/var/db/find.codes # ${INSTALL} -c -o ${OWN} -g wheel -m 644 /dev/null \ # ${DESTDIR}/usr/adm/lastlog ${INSTALL} -c -o ${OWN} -g wheel -m 644 /dev/null \ ${DESTDIR}/var/log/wtmp # ${INSTALL} -c -o uucp -g daemon -m 600 /dev/null \ # ${DESTDIR}/usr/adm/aculog DIRS_DISTRIB= bin sbin dev etc var/log var/run root usr usr/bin usr/sbin \ usr/include usr/lib usr/libexec usr/share usr/games/lib MDIRS_DISTRIB= cat1 cat2 cat3 cat4 cat5 cat6 cat7 cat8 cat9 # XXX Keep in sync with SUBDIR in sys/arch/${MACHINE}/compile/Makefile DIRS_RELEASE!=if [ x"${MACHINE}" = x"stm32" ] ; then \ echo "F405WEACTCORE F411RENUCLEO F412GDISCO F412WEACTCORE \ F413HDISCO F446RENUCLEO F446WEACTCORE F469IDISCO \ F4DISCOVERY F4VEDEVEBOX" ; \ elif [ x"${MACHINE}" = x"pic32" ] ; then \ echo "BAREMETAL DUINOMITE DUINOMITE_EMEGA EXPLORER16 \ FUBARINO MAX32 MAXIMITE MAXIMITE_COLOR MMB_MX7 \ PICADILLO PINGUINO_MICRO QUICK240 \ SDXL SNADPIC STARTER_KIT UBW32 WF32" ; \ else \ echo "FAIL" ; \ fi # Creates an empty DiscoBSD directory tree in DESTDIR. distrib-dirs: if [ ! -d ${DESTDIR}/. ]; then \ ${INSTALL} -d -m 755 ${DESTDIR}; \ fi for dir in ${DIRS_DISTRIB}; do \ mkdir -p ${DESTDIR}/$$dir; \ done for dir in ${MDIRS_DISTRIB}; do \ mkdir -p ${DESTDIR}/usr/share/man/$$dir; \ done # Creates and populates a DiscoBSD release directory tree in RELEASEDIR. release-dirs: if [ ! -d ${RELEASEDIR}/. ]; then \ ${INSTALL} -d -m 755 ${RELEASEDIR}; \ fi ${INSTALL} -d -m 755 ${RELEASEDIR}/${MACHINE} cd ${RELEASEDIR}/${MACHINE} && \ for dir in ${DIRS_RELEASE}; do \ mkdir -p $$dir; \ cp ${TOPSRC}/sys/arch/${MACHINE}/compile/$$dir/unix* $$dir; \ done cp -f ${TOPSRC}/distrib/${MACHINE}/sdcard.img ${RELEASEDIR}/${MACHINE} cp -f ${TOPSRC}/distrib/${MACHINE}/README.md ${RELEASEDIR}/${MACHINE} cp -f ${TOPSRC}/distrib/notes/ANNOUNCEMENT.md ${RELEASEDIR} cp -f ${TOPSRC}/README.md ${RELEASEDIR} release: release-dirs cd ${RELEASEDIR} && \ tar czvf DiscoBSD_${OSRev}_${MACHINE}.tar.gz ${MACHINE} && \ zip -r DiscoBSD_${OSRev}_${MACHINE}.zip ${MACHINE} .PHONY: all distribution distribution-etc-root-var \ distrib-dirs release-dirs release clean ================================================ FILE: etc/fstab ================================================ /dev/sd0a / ufs rw,async 1 1 /dev/sd0c /home ufs rw,async 1 2 ================================================ FILE: etc/gettytab ================================================ # Copyright (c) 1980 Regents of the University of California. # All rights reserved. The Berkeley software License Agreement # specifies the terms and conditions for redistribution. # # @(#)gettytab 5.7.2 (2.11BSD GTE) 1997/3/28 # # # Most of the table entries here are just copies of the # old getty table, it is by no means certain, or even likely, # then any of them are optimal for any purpose whatever. # Nor is it likely that more than a couple are even correct # # # The default gettytab entry, used to set defaults for all other # entries, and in cases where getty is called with no table name # default:\ :ap:im=\r\n\r\n2.11 BSD UNIX (%h) (%t)\r\n\r\r\n\r:sp#1200: # # Fixed speed entries # # The "std.NNN" names are known to the special case # portselector code in getty, however they can # be assigned to any table desired. # The "NNN-baud" names are known to the special case # autobaud code in getty, and likewise can # be assigned to any table desired (hopefully the same speed). # a|std.50|50-baud:\ :sp#50: b|std.75|75-baud:\ :ep:sp#75:ht:nl: 1|std.150|150-baud:\ :ep:sp#150:ht:nl:lm=\E\72\6\6\17login\72 : c|std.300|300-baud:\ :sp#300: d|std.600|600-baud:\ :sp#600: f|std.1200|1200-baud:\ :sp#1200: 6|std.2400|2400-baud:\ :sp#2400:ht: 7|std.4800|4800-baud:\ :sp#4800:ht: 2|std.9600|9600-baud:\ :sp#9600: g|std.19200|19200-baud:\ :sp#19200: h|std.38400|38400-baud:\ :sp#38400: i|std.57600|57600-baud:\ :sp#57600: j|std.115200|115200-baud:\ :sp#115200: k|std.230400|230400-baud:\ :sp#230400: l|std.460800|460800-baud:\ :sp#460800: m|std.500000|500000-baud:\ :sp#500000: n|std.576000|576000-baud:\ :sp#576000: o|std.921600|921600-baud:\ :sp#921600: p|std.1000000|1000000-baud:\ :sp#1000000: q|std.1152000|1152000-baud:\ :sp#1152000: r|std.1500000|1500000-baud:\ :sp#1500000: s|std.2000000|2000000-baud:\ :sp#2000000: t|std.2500000|2500000-baud:\ :sp#2500000: u|std.3000000|3000000-baud:\ :sp#3000000: v|std.3500000|3500000-baud:\ :sp#3500000: w|std.4000000|4000000-baud:\ :sp#4000000: x|std.default|default-baud:\ :sp#0: # # Hardware flow control lines # t9600-hf:hf:sp#9600 t19200-hf:hf:sp#19200 t38400-hf:hf:sp#38400 # # Dial in rotary tables, speed selection via 'break' # 0|d300|Dial-300:\ :nx=d1200:sp#300: d1200|Dial-1200:\ :nx=d150:sp#1200: d150|Dial-150:\ :nx=d110:lm@:tc=150-baud: d110|Dial-110:\ :nx=d300:tc=300-baud: # # Odd special case terminals # -|tty33|asr33|Pity the poor user of this beast:\ :tc=110-baud: 4|Console|Console Decwriter II:\ :rw:tc=300-baud: e|Console-1200|Console Decwriter III:\ :rw:tc=1200-baud: l|lsi chess terminal:\ :sp#300: X|Xwindow|X window system:\ :rw:sp#9600: # # Fast dialup terminals, 2400/1200/300 rotary (can start either way) # D2400|Fast-Dial-2400:\ :nx=D1200:tc=2400-baud: 3|D1200|Fast-Dial-1200:\ :nx=D300:tc=1200-baud: 5|D300|Fast-Dial-300:\ :nx=D2400:tc=300-baud: # # Wierdo special case for fast crt's with hardcopy devices # 8|T9600|CRT with hardcopy:\ :nx=T300:tc=9600-baud: 9|T300|CRT with hardcopy (300):\ :nx=T9600:tc=300-baud: # # Plugboard, and misc other terminals # p|P9600|Plugboard-9600:\ :nx=P300:tc=9600-baud: q|P300|Plugboard-300:\ :nx=P1200:tc=300-baud: r|P1200|Plugboard-1200:\ :nx=P9600:tc=1200-baud: # # XXXX Port selector # s|DSW|Port Selector:\ :ps:sp#2400: # # Auto-baud speed detect entry for Micom 600. # Special code in getty will switch this out # to one of the NNN-baud entries. # A|Auto-baud:\ :ab:sp#2400:f0#040: ================================================ FILE: etc/group ================================================ wheel:*:0:root daemon:*:1:daemon kmem:*:2: sys:*:3: tty:*:4: operator:*:5: staff:*:10: bin:*:20: guest:*:31: ingres:*:74: ================================================ FILE: etc/motd ================================================ DiscoBSD ?.? (UNKNOWN) Welcome to DiscoBSD. ================================================ FILE: etc/passwd ================================================ root:5:0:1:The Man:/root:/bin/sh daemon:*:1:1:The devil himself:/root:/bin/sh sys:*:4:2:Operating System:/tmp:nologin operator:*:2:5:System &:/operator:/bin/sh bin:*:3:20:Binaries Commands and Source:/root:/bin/sh nobody:*:32767:31:Nobody:/nonexistent:/bin/sh uucp:*:66:1:UNIX-to-UNIX Copy:/spool/uucppublic:/usr/bin/uucico ================================================ FILE: etc/rc ================================================ #!/bin/sh HOME=/; export HOME PATH=/sbin:/bin:/usr/sbin:/usr/bin; export PATH exec >/dev/console 2>&1 if test "$1" != "autoboot"; then # # Switch from single-user to multi-user mode. # echo # Halt the processor. #reboot -l -h exit 0 fi # # Entering multiuser mode: check filesystems # # This will *only* work if fsck can do your root file system # without a temporary file, and if the root file system is # checked alone in a pass by itself -- be careful! This can # *seriously* mess you up. # echo "Automatic boot in progress: starting file system checks." fsck -p case $? in 0) # Filesystems are clean ;; 2) echo "--- Critical errors detected: run fsck to repair manually" exit 1 ;; 4) # Root filesystem modified: NO SYNC! echo "--- Errors repaired, rebooting..." reboot -n ;; 8) echo "--- Filesystem check failed... help!" exit 1 ;; 12) echo "--- Interrupted by user" exit 1 ;; *) echo "--- Unknown error in fsck" exit 1 ;; esac hostname "name.my.domain" # # First umount everything in case the system is going back into multiuser # mode. If the system is being booted for the first time nothing is mounted # except the root filesystem and umount ignores attempts to unmount /. # umount -a # # Now mount everything mentioned in /etc/fstab *except* filesystems with the # 'na' (noauto) option. # mount -a rm -f /etc/nologin # Patch /etc/motd. echo -n "Updating motd..." if [ ! -f /etc/motd ]; then echo "" >/etc/motd && chmod 664 /etc/motd && chown root.wheel /etc/motd fi T=/tmp/_motd sysctl -n kern.version | sed 1q >$T sed -n '/^$/,$p' >$T cmp -s $T /etc/motd || cp $T /etc/motd rm -f $T echo "done" echo -n "Starting daemons:" update && echo -n "update" cron && echo -n "cron" echo #/etc/rc.local date exit 0 ================================================ FILE: etc/rc.local ================================================ #! /bin/sh - # site-specific startup actions, daemons ================================================ FILE: etc/root/dot.profile ================================================ echo 'erase ^?, kill ^U, intr ^C' stty dec PATH=/sbin:/usr/sbin:/bin:/usr/bin export PATH HOME=/ export HOME export TERM ================================================ FILE: etc/shadow ================================================ root:ro46DZg1ViGBs:0:1:The Man:/root:/bin/sh daemon:*:1:1:The devil himself:/root:/bin/sh sys:*:4:2:Operating System:/tmp:nologin operator:*:2:5:System &:/operator:/bin/sh bin:*:3:20:Binaries Commands and Source:/root:/bin/sh nobody:*:32767:31:Nobody:/nonexistent:/bin/sh uucp:*:66:1:UNIX-to-UNIX Copy:/spool/uucppublic:/usr/bin/uucico ================================================ FILE: etc/shells ================================================ # List of acceptable shells for chsh/passwd -s # Ftpd will not allow users to connect who do not have one of these shells # /bin/sh /bin/csh ================================================ FILE: etc/syslog.conf ================================================ local7.debug /dev/null *.crit;*.err;kern.debug;auth.notice,local7.none /dev/console *.err;auth.notice;*.info;kern.debug;local3,local7,mail,daemon,lpr.none /usr/adm/messages cron.debug /usr/adm/cron lpr.debug /usr/adm/lpd-errs mail.debug /usr/spool/mqueue/syslog mark.debug;daemon.debug /usr/adm/daemonlog user.debug /usr/adm/debuglog *.alert;kern.err operator,root *.emerg * ================================================ FILE: etc/ttys ================================================ # # name getty type status comments # console "/usr/libexec/getty std.default" xterm on secure #special # Enable some of these for additional logins. Do NOT enable the same one as the # console port, or strange things will happen. You can turn off the console port # if you would rather use the getty on the real tty - it's up to you. tty0 "/usr/libexec/getty std.default" xterm off secure tty1 "/usr/libexec/getty std.default" xterm off secure tty2 "/usr/libexec/getty std.default" xterm off secure tty3 "/usr/libexec/getty std.default" xterm off secure tty4 "/usr/libexec/getty std.default" xterm off secure tty5 "/usr/libexec/getty std.default" xterm off secure ttyUSB0 "/usr/libexec/getty std.default" xterm off secure ================================================ FILE: games/Makefile ================================================ # # Copyright (c) 1980 Regents of the University of California. # All rights reserved. The Berkeley software License Agreement # specifies the terms and conditions for redistribution. # TOPSRC!=cd ..; pwd include ${TOPSRC}/share/mk/sys.mk SUBDIR = adventure atc backgammon battlestar boggle btlgammon \ caesar cribbage fortune hangman mille monop pom pig quiz \ robots rogue sail snake trek \ banner aclock arithmetic bcd factor fish morse \ number ppt wump primes rain worm worms canfield all: $(SUBDIR) $(SUBDIR): FRC $(MAKE) -C $@ $(MFLAGS) FRC: install: -for i in $(SUBDIR); do \ ${MAKE} -C $$i $(MFLAGS) DESTDIR=$(DESTDIR) install; done clean: rm -f a.out core *.s *.o *.dis *.elf -for i in $(SUBDIR); do ${MAKE} -C $$i $(MFLAGS) clean; done ================================================ FILE: games/hunt/Makefile ================================================ # # Hunt # Copyright (c) 1985 Conrad C. Huang, Gregory S. Couch, Kenneth C.R.C. Arnold # San Francisco, California # # Copyright (c) 1985 Regents of the University of California. # All rights reserved. The Berkeley software License Agreement # specifies the terms and conditions for redistribution. # HDR= hunt.h DSRC= answer.c driver.c draw.c execute.c expl.c makemaze.c \ shots.c terminal.c extern.c pathname.c DOBJ= answer.o driver.o draw.o execute.o expl.o makemaze.o \ shots.o terminal.o extern.o PSRC= hunt.c connect.c playit.c pathname.c POBJ= hunt.o connect.o playit.o # # Flags are: # DEBUG Don't trust everything in the code # INTERNET Use the Internet domain IPC instead of UNIX domain # BROADCAST Use internet broadcasting code when looking for driver # OLDIPC Use 4.1a internet system calls (must also define # INTERNET but not BROADCAST) # RANDOM Include doors which disperse shots randomly # REFLECT Include diagonal walls that reflect shots # MONITOR Include code for watching the game from the sidelines # OOZE Include slime shots # FLY Make people fly when walls regenerate under them # START_FLYING Players enter flying (FLY must also be defined) # VOLCANO Include occasional large slime explosions # # NOTE: if you change the domain (INTERNET vs UNIX) then "make newdomain" # DEFS= -I. -DBROADCAST -DRANDOM -DREFLECT -DMONITOR -DINTERNET \ -DOOZE -DFLY -DVOLCANO CFLAGS= -O $(DEFS) LDFLAGS= SEPFLAG= -i PROFLAGS= LD= /usr/bin/ld .SUFFIXES: .uu .obj .c,v .obj.uu: uuencode $*.obj < $*.obj > $*.uu .c,v.c: co $*.c standard: hunt hunt.driver # # For testing # debug: hunt.dbg hunt.driver.dbg hunt.dbg: $(POBJ) pathname.dbg.o $(CC) ${SEPFLAG} $(LDFLAGS) -o hunt.dbg \ $(POBJ) pathname.dbg.o -lcurses -ltermlib hunt.driver.dbg: $(DOBJ) pathname.dbg.o $(CC) ${SEPFLAG} $(PROFLAGS) $(LDFLAGS) -o hunt.driver.dbg \ $(DOBJ) pathname.dbg.o # # Binary distribution to other sites # distribution: hunt.uu hunt.driver.uu README pathname.c Makefile.dist hunt.6 @ln Makefile.dist makefile shar -a README makefile pathname.c hunt.uu hunt.driver.uu hunt.6\ > distribution @rm -f makefile hunt.uu hunt.driver.uu hunt.obj hunt.driver.obj hunt.driver.obj: $(DOBJ) pathname.o $(LD) -r -x -o hunt.driver.obj $(DOBJ) symstrip hunt.driver.obj pathname.o -lcurses -ltermcap hunt.obj: $(POBJ) pathname.o $(LD) -r -x -o hunt.obj $(POBJ) symstrip hunt.obj pathname.o -lcurses -ltermcap # # System installation # install: standard ${INSTALL} -s hunt.driver ${DESTDIR}/usr/games/lib/hunt.driver ${INSTALL} -s hunt ${DESTDIR}/usr/games/hunt hunt: $(POBJ) pathname.o $(CC) ${SEPFLAG} $(LDFLAGS) -o hunt $(POBJ) \ pathname.o -lcurses -ltermlib hunt.driver: $(DOBJ) pathname.o $(CC) ${SEPFLAG} $(PROFLAGS) $(LDFLAGS) -o hunt.driver \ $(DOBJ) pathname.o # # Object file dependencies # $(POBJ): $(HDR) $(DOBJ): $(HDR) $(CC) $(CFLAGS) $(PROFLAGS) -c $*.c pathname.dbg.o: pathname.c @echo $(CC) $(CFLAGS) -DDEBUG -c pathname.c -o pathname.dbg.o @rm -f x.c @ln pathname.c x.c @$(CC) $(CFLAGS) -DDEBUG -c x.c @mv x.o pathname.dbg.o @rm -f x.c # # Miscellaneous functions # lint: $(DSRC) $(PSRC) lint $(DEFS) -DSTANDARD $(DSRC) 2>&1 > driver.lint lint $(DEFS) -DSTANDARD $(PSRC) -lcurses 2>&1 > hunt.lint tags: $(DSRC) $(PSRC) ctags $(DSRC) $(PSRC) newdomain: rm -f hunt.o extern.o driver.o clean: rm -f hunt hunt.driver *.o tags errs ================================================ FILE: games/hunt/README ================================================ If you have an old tcp/ip you might have to turn off the BROADCAST option; see the Makefile. Hunt is not officially supported by anyone anywhere; however, bug reports will be read and bug fixes/enhancements may be sent out at irregular intervals. Enjoy. ucbvax!ucsfcgl!conrad ucsfcgl!conrad@berkeley.edu ================================================ FILE: games/hunt/answer.c ================================================ /* * Hunt * Copyright (c) 1985 Conrad C. Huang, Gregory S. Couch, Kenneth C.R.C. Arnold * San Francisco, California * * Copyright (c) 1985 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * * @(#) answer.c 1.1 (2.11BSD) 96/7/10 */ # include "hunt.h" # include # include /* for gethostid() */ # define MAXPERMACH 3 /* Max player/monitor per machine */ static char Ttyname[NAMELEN]; answer() { register PLAYER *pp; register int newsock; register FILE *tmpfd; # ifdef MONITOR static FLAG monitor; # endif MONITOR static char name[NAMELEN]; static int socklen; static u_long machine; static u_long uid; static SOCKET sockstruct; # ifdef OLDIPC extern SOCKET Daemon; # endif OLDIPC # ifdef INTERNET socklen = sizeof sockstruct; # else socklen = sizeof sockstruct - 1; # endif INTERNET errno = 0; # ifndef OLDIPC if ((newsock = accept(Socket, &sockstruct, &socklen)) < 0) # else OLDIPC if (accept(Socket, &sockstruct) < 0) # endif OLDIPC { if (errno == EINTR) return; perror("accept"); cleanup(1); } # ifdef OLDIPC newsock = Socket; Socket = socket(SOCK_STREAM, 0, (struct sockaddr *) &Daemon, SO_ACCEPTCONN); if (Socket < 0) { perror("new accept socket"); cleanup(1); } Sock_mask = (1 << Socket); Fds_mask |= Sock_mask; if (Socket >= Num_fds) Num_fds = Socket + 1; # endif OLDIPC tmpfd = fdopen(newsock, "w"); # ifdef INTERNET machine = ntohl(((struct sockaddr_in *) &sockstruct)->sin_addr.s_addr); # else INTERNET if (machine == 0) machine = gethostid(); # endif INTERNET (void) putw(getpid(), tmpfd); (void) read(newsock, (char *) &uid, sizeof uid); uid = ntohl(uid); (void) read(newsock, name, NAMELEN); (void) read(newsock, Ttyname, NAMELEN); # ifdef MONITOR (void) read(newsock, (char *) &monitor, sizeof monitor); # endif MONITOR if (reached_limit(machine)) { socklen = 0; (void) write(newsock, (char *) &socklen, sizeof socklen); (void) close(newsock); # ifdef OLDIPC Fds_mask &= ~(1 << newsock); # endif OLDIPC return; } # ifdef MONITOR if (monitor) if (End_monitor < &Monitor[MAXMON]) pp = End_monitor++; else { socklen = 0; (void) write(newsock, (char *) &socklen, sizeof socklen); (void) close(newsock); return; } else # endif MONITOR if (End_player < &Player[MAXPL]) pp = End_player++; else { socklen = 0; (void) write(newsock, (char *) &socklen, sizeof socklen); (void) close(newsock); return; } pp->p_ident = get_ident(machine, uid, name); pp->p_output = tmpfd; pp->p_death[0] = '\0'; pp->p_fd = newsock; pp->p_mask = (1 << pp->p_fd); # ifndef OLDIPC Fds_mask |= pp->p_mask; if (pp->p_fd >= Num_fds) Num_fds = pp->p_fd + 1; # endif OLDIPC pp->p_y = 0; pp->p_x = 0; # ifdef MONITOR if (monitor) stmonitor(pp); else # endif MONITOR stplayer(pp); } # ifdef MONITOR stmonitor(pp) register PLAYER *pp; { register int line; register PLAYER *npp; bcopy((char *) Maze, (char *) pp->p_maze, sizeof Maze); drawmaze(pp); (void) sprintf(Buf, "%5.5s%c%-10.10s", " ", stat_char(pp), pp->p_ident->i_name); line = STAT_MON_ROW + 1 + (pp - Monitor); for (npp = Player; npp < End_player; npp++) { cgoto(npp, line, STAT_NAME_COL); outstr(npp, Buf, STAT_NAME_LEN); } for (npp = Monitor; npp < End_monitor; npp++) { cgoto(npp, line, STAT_NAME_COL); outstr(npp, Buf, STAT_NAME_LEN); } sendcom(pp, REFRESH); sendcom(pp, READY, 0); (void) fflush(pp->p_output); } # endif MONITOR stplayer(newpp) register PLAYER *newpp; { register int x, y; register PLAYER *pp; Nplayer++; for (y = 0; y < UBOUND; y++) for (x = 0; x < WIDTH; x++) newpp->p_maze[y][x] = Maze[y][x]; for ( ; y < DBOUND; y++) { for (x = 0; x < LBOUND; x++) newpp->p_maze[y][x] = Maze[y][x]; for ( ; x < RBOUND; x++) newpp->p_maze[y][x] = SPACE; for ( ; x < WIDTH; x++) newpp->p_maze[y][x] = Maze[y][x]; } for ( ; y < HEIGHT; y++) for (x = 0; x < WIDTH; x++) newpp->p_maze[y][x] = Maze[y][x]; do { x = rand_num(WIDTH - 1) + 1; y = rand_num(HEIGHT - 1) + 1; } while (Maze[y][x] != SPACE); newpp->p_over = SPACE; newpp->p_x = x; newpp->p_y = y; newpp->p_undershot = FALSE; # ifdef START_FLYING /* This is only for debugging */ newpp->p_flying = rand_num(20); newpp->p_flyx = 2 * rand_num(6) - 5; newpp->p_flyy = 2 * rand_num(6) - 5; newpp->p_face = FLYER; # else START_FLYING newpp->p_flying = -1; rand_face(newpp); # endif START_FLYING newpp->p_damage = 0; newpp->p_damcap = MAXDAM; newpp->p_nchar = 0; newpp->p_ncount = 0; newpp->p_nexec = 0; newpp->p_ammo = ISHOTS; newpp->p_scan = -1; newpp->p_cloak = CLOAKLEN; newpp->p_ncshot = 0; do { x = rand_num(WIDTH - 1) + 1; y = rand_num(HEIGHT - 1) + 1; } while (Maze[y][x] != SPACE); Maze[y][x] = GMINE; # ifdef MONITOR for (pp = Monitor; pp < End_monitor; pp++) check(pp, y, x); # endif MONITOR do { x = rand_num(WIDTH - 1) + 1; y = rand_num(HEIGHT - 1) + 1; } while (Maze[y][x] != SPACE); Maze[y][x] = MINE; # ifdef MONITOR for (pp = Monitor; pp < End_monitor; pp++) check(pp, y, x); # endif MONITOR (void) sprintf(Buf, "%5.2f%c%-10.10s", newpp->p_ident->i_score, stat_char(newpp), newpp->p_ident->i_name); y = STAT_PLAY_ROW + 1 + (newpp - Player); for (pp = Player; pp < End_player; pp++) { if (pp != newpp) { char smallbuf[10]; pp->p_ammo += NSHOTS; newpp->p_ammo += NSHOTS; cgoto(pp, y, STAT_NAME_COL); outstr(pp, Buf, STAT_NAME_LEN); (void) sprintf(smallbuf, "%3d", pp->p_ammo); cgoto(pp, STAT_AMMO_ROW, STAT_VALUE_COL); outstr(pp, smallbuf, 3); } } # ifdef MONITOR for (pp = Monitor; pp < End_monitor; pp++) { cgoto(pp, y, STAT_NAME_COL); outstr(pp, Buf, STAT_NAME_LEN); } # endif MONITOR drawmaze(newpp); drawplayer(newpp, TRUE); look(newpp); # ifdef START_FLYING /* Make sure that the position you enter in will be erased */ showexpl(newpp->p_y, newpp->p_x, FLYER); # endif START_FLYING sendcom(newpp, REFRESH); sendcom(newpp, READY, 0); (void) fflush(newpp->p_output); } /* * rand_face: * Give the player a random facing direction */ rand_face(pp) register PLAYER *pp; { switch (rand_num(4)) { case 0: pp->p_face = LEFTS; break; case 1: pp->p_face = RIGHT; break; case 2: pp->p_face = BELOW; break; case 3: pp->p_face = ABOVE; break; } } /* * get_ident: * Get the score structure of a player */ IDENT * get_ident(machine, uid, name) u_long machine; u_long uid; char *name; { register IDENT *ip; static IDENT punt; for (ip = Scores; ip != NULL; ip = ip->i_next) if (ip->i_machine == machine && ip->i_uid == uid && strncmp(ip->i_name, name, NAMELEN) == 0) break; if (ip != NULL) { ip->i_entries++; ip->i_score = ip->i_kills / (double) ip->i_entries; } else { ip = (IDENT *) malloc(sizeof (IDENT)); if (ip == NULL) { /* Fourth down, time to punt */ ip = &punt; } ip->i_machine = machine; ip->i_uid = uid; strncpy(ip->i_name, name, NAMELEN); ip->i_kills = 0; ip->i_entries = 1; ip->i_score = 0; ip->i_next = Scores; Scores = ip; } return ip; } /* * reached_limit: * Returns whether the limit of x persons per machine has been reached */ reached_limit(machine) u_long machine; { register PLAYER *pp; register int count; count = 0; for (pp = Player; pp < End_player; pp++) if (pp->p_ident->i_machine == machine) count++; for (pp = Monitor; pp < End_monitor; pp++) if (pp->p_ident->i_machine == machine) count++; return count >= MAXPERMACH; } ================================================ FILE: games/hunt/connect.c ================================================ /* * Hunt * Copyright (c) 1985 Conrad C. Huang, Gregory S. Couch, Kenneth C.R.C. Arnold * San Francisco, California * * Copyright (c) 1985 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ # include "hunt.h" # include do_connect(name) char *name; { static long uid; extern char *ttyname(); uid = htonl(getuid()); (void) write(Socket, (char *) &uid, sizeof uid); (void) write(Socket, name, NAMELEN); (void) strcpy(Buf, ttyname(fileno(stderr))); (void) write(Socket, Buf, NAMELEN); # ifdef MONITOR (void) write(Socket, (char *) &Am_monitor, sizeof Am_monitor); # endif MONITOR } ================================================ FILE: games/hunt/draw.c ================================================ /* * Hunt * Copyright (c) 1985 Conrad C. Huang, Gregory S. Couch, Kenneth C.R.C. Arnold * San Francisco, California * * Copyright (c) 1985 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ # include "hunt.h" drawmaze(pp) register PLAYER *pp; { register int x; register char *sp; register int y; register char *endp; clrscr(pp); outstr(pp, pp->p_maze[0], WIDTH); for (y = 1; y < HEIGHT - 1; y++) { endp = &pp->p_maze[y][WIDTH]; for (x = 0, sp = pp->p_maze[y]; sp < endp; x++, sp++) if (*sp != SPACE) { cgoto(pp, y, x); if (pp->p_x == x && pp->p_y == y) outch(pp, translate(*sp)); else outch(pp, *sp); } } cgoto(pp, HEIGHT - 1, 0); outstr(pp, pp->p_maze[HEIGHT - 1], WIDTH); drawstatus(pp); } /* * drawstatus - put up the status lines (this assumes the screen * size is 80x24 with the maze being 64x24) */ drawstatus(pp) register PLAYER *pp; { register int i; register PLAYER *np; (void) sprintf(Buf, "%-13.13s", pp->p_ident->i_name); cgoto(pp, STAT_NAME_ROW, STAT_LABEL_COL); outstr(pp, Buf, 13); cgoto(pp, STAT_AMMO_ROW, STAT_LABEL_COL); outstr(pp, "Ammo:", 5); (void) sprintf(Buf, "%3d", pp->p_ammo); cgoto(pp, STAT_AMMO_ROW, STAT_VALUE_COL); outstr(pp, Buf, 3); cgoto(pp, STAT_CLOAK_ROW, STAT_LABEL_COL); outstr(pp, "Cloak:", 6); cgoto(pp, STAT_CLOAK_ROW, STAT_VALUE_COL); outstr(pp, (pp->p_cloak < 0) ? " " : " on", 3); cgoto(pp, STAT_SCAN_ROW, STAT_LABEL_COL); outstr(pp, "Scan:", 5); cgoto(pp, STAT_SCAN_ROW, STAT_VALUE_COL); outstr(pp, (pp->p_scan < 0) ? " " : " on", 3); cgoto(pp, STAT_GUN_ROW, STAT_LABEL_COL); outstr(pp, "Gun:", 4); cgoto(pp, STAT_GUN_ROW, STAT_VALUE_COL); outstr(pp, (pp->p_ncshot < MAXNCSHOT) ? " ok" : " ", 3); cgoto(pp, STAT_DAM_ROW, STAT_LABEL_COL); outstr(pp, "Damage:", 7); (void) sprintf(Buf, "%2d/%2d", pp->p_damage, pp->p_damcap); cgoto(pp, STAT_DAM_ROW, STAT_VALUE_COL); outstr(pp, Buf, 5); cgoto(pp, STAT_KILL_ROW, STAT_LABEL_COL); outstr(pp, "Kills:", 6); (void) sprintf(Buf, "%3d", (pp->p_damcap - MAXDAM) / 2); cgoto(pp, STAT_KILL_ROW, STAT_VALUE_COL); outstr(pp, Buf, 3); cgoto(pp, STAT_PLAY_ROW, STAT_LABEL_COL); outstr(pp, "Player:", 7); for (i = STAT_PLAY_ROW + 1, np = Player; np < End_player; np++) { (void) sprintf(Buf, "%5.2f%c%-10.10s", np->p_ident->i_score, stat_char(np), np->p_ident->i_name); cgoto(pp, i++, STAT_NAME_COL); outstr(pp, Buf, STAT_NAME_LEN); } # ifdef MONITOR cgoto(pp, STAT_MON_ROW, STAT_LABEL_COL); outstr(pp, "Monitor:", 8); for (i = STAT_MON_ROW + 1, np = Monitor; np < End_monitor; np++) { (void) sprintf(Buf, "%5.5s %-10.10s", " ", np->p_ident->i_name); cgoto(pp, i++, STAT_NAME_COL); outstr(pp, Buf, STAT_NAME_LEN); } # endif MONITOR } # ifndef CPUHOG look(pp) register PLAYER *pp; { register int x, y; x = pp->p_x; y = pp->p_y; check(pp, y - 1, x - 1); check(pp, y - 1, x ); check(pp, y - 1, x + 1); check(pp, y , x - 1); check(pp, y , x ); check(pp, y , x + 1); check(pp, y + 1, x - 1); check(pp, y + 1, x ); check(pp, y + 1, x + 1); switch (pp->p_face) { case LEFTS: see(pp, LEFTS); see(pp, ABOVE); see(pp, BELOW); break; case RIGHT: see(pp, RIGHT); see(pp, ABOVE); see(pp, BELOW); break; case ABOVE: see(pp, ABOVE); see(pp, LEFTS); see(pp, RIGHT); break; case BELOW: see(pp, BELOW); see(pp, LEFTS); see(pp, RIGHT); break; # ifdef FLY case FLYER: break; # endif FLY } cgoto(pp, y, x); } see(pp, face) register PLAYER *pp; int face; { register char *sp; register int y, x, i, cnt; x = pp->p_x; y = pp->p_y; switch (face) { case LEFTS: sp = &Maze[y][x]; for (i = 0; See_over[*--sp]; i++) continue; if (i == 0) break; cnt = i; x = pp->p_x - 1; --y; while (i--) check(pp, y, --x); i = cnt; x = pp->p_x - 1; ++y; while (i--) check(pp, y, --x); i = cnt; x = pp->p_x - 1; ++y; while (i--) check(pp, y, --x); break; case RIGHT: sp = &Maze[y][++x]; for (i = 0; See_over[*sp++]; i++) continue; if (i == 0) break; cnt = i; x = pp->p_x + 1; --y; while (i--) check(pp, y, ++x); i = cnt; x = pp->p_x + 1; ++y; while (i--) check(pp, y, ++x); i = cnt; x = pp->p_x + 1; ++y; while (i--) check(pp, y, ++x); break; case ABOVE: sp = &Maze[--y][x]; if (!See_over[*sp]) break; do { --y; sp -= sizeof Maze[0]; check(pp, y, x - 1); check(pp, y, x ); check(pp, y, x + 1); } while (See_over[*sp]); break; case BELOW: sp = &Maze[++y][x]; if (!See_over[*sp]) break; do { y++; sp += sizeof Maze[0]; check(pp, y, x - 1); check(pp, y, x ); check(pp, y, x + 1); } while (See_over[*sp]); break; } } # else CPUHOG look(pp) register PLAYER *pp; { switch (pp->p_face) { case LEFTS: lookquad2(pp, pp->p_y, pp->p_x); lookquad3(pp, pp->p_y, pp->p_x); break; case RIGHT: lookquad1(pp, pp->p_y, pp->p_x); lookquad4(pp, pp->p_y, pp->p_x); break; case ABOVE: lookquad3(pp, pp->p_y, pp->p_x); lookquad4(pp, pp->p_y, pp->p_x); break; case BELOW: lookquad1(pp, pp->p_y, pp->p_x); lookquad2(pp, pp->p_y, pp->p_x); break; } cgoto(pp, pp->p_y, pp->p_x); } # endif CPUHOG check(pp, y, x) PLAYER *pp; int y, x; { register int index; register int ch; register PLAYER *rpp; index = y * sizeof Maze[0] + x; ch = ((char *) Maze)[index]; if (ch != ((char *) pp->p_maze)[index]) { rpp = pp; cgoto(rpp, y, x); if (x == rpp->p_x && y == rpp->p_y) outch(rpp, translate(ch)); else outch(rpp, ch); ((char *) rpp->p_maze)[index] = ch; } } /* * showstat * Update the status of players */ showstat(pp) register PLAYER *pp; { register PLAYER *np; register int y; register char c; y = STAT_PLAY_ROW + 1 + (pp - Player); c = stat_char(pp); # ifdef MONITOR for (np = Monitor; np < End_monitor; np++) { cgoto(np, y, STAT_SCAN_COL); outch(np, c); } # endif MONITOR for (np = Player; np < End_player; np++) { cgoto(np, y, STAT_SCAN_COL); outch(np, c); } } /* * drawplayer: * Draw the player on the screen and show him to everyone who's scanning * unless he is cloaked. */ drawplayer(pp, draw) PLAYER *pp; FLAG draw; { register PLAYER *newp; register int x, y; x = pp->p_x; y = pp->p_y; Maze[y][x] = draw ? pp->p_face : pp->p_over; # ifdef MONITOR for (newp = Monitor; newp < End_monitor; newp++) check(newp, y, x); # endif MONITOR for (newp = Player; newp < End_player; newp++) { if (!draw || newp == pp) { check(newp, y, x); continue; } if (newp->p_scan == 0) { cgoto(newp, STAT_SCAN_ROW, STAT_VALUE_COL); outstr(newp, " ", 3); newp->p_scan--; showstat(newp); } else if (newp->p_scan > 0) { if (pp->p_cloak < 0) check(newp, y, x); newp->p_scan--; } } if (!draw || pp->p_cloak < 0) return; if (pp->p_cloak-- == 0) { cgoto(pp, STAT_CLOAK_ROW, STAT_VALUE_COL); outstr(pp, " ", 3); showstat(pp); } } message(pp, s) register PLAYER *pp; char *s; { cgoto(pp, HEIGHT, 0); outstr(pp, s, strlen(s)); ce(pp); } /* * translate: * Turn a charcter into the right direction character if we are * looking at the current player. */ translate(ch) char ch; { switch (ch) { case LEFTS: return '<'; case RIGHT: return '>'; case ABOVE: return '^'; case BELOW: return 'v'; } return ch; } ================================================ FILE: games/hunt/driver.c ================================================ /* * Hunt * Copyright (c) 1985 Conrad C. Huang, Gregory S. Couch, Kenneth C.R.C. Arnold * San Francisco, California * * Copyright (c) 1985 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * * 1997/9/9 - updated to use sigprocmask (and compute the alarm mask correctly) */ # include "hunt.h" # include # include # include # include # ifndef pdp11 # define RN (((Seed = Seed * 11109 + 13849) >> 16) & 0xffff) # else pdp11 # define RN ((Seed = Seed * 11109 + 13849) & 0x7fff) # endif pdp11 int Seed = 0; # ifdef CONSTANT_MOVE static struct itimerval Timing; # endif CONSTANT_MOVE SOCKET Daemon; # ifdef INTERNET int Test_socket; /* test socket to answer datagrams */ # define DAEMON_SIZE (sizeof Daemon) # else INTERNET # define DAEMON_SIZE (sizeof Daemon - 1) # endif INTERNET /* * main: * The main program. */ main() { register PLAYER *pp; register int had_char; # ifdef INTERNET register long test_mask; int msg; int namelen; SOCKET test; # endif INTERNET # ifdef CONSTANT_MOVE sigset_t alarm_sigset; # endif CONSTANT_MOVE static long read_fds; init(); Sock_mask = (1 << Socket); # ifdef INTERNET test_mask = (1 << Test_socket); # endif INTERNET # ifdef CONSTANT_MOVE (void) sigemptyset(&alarm_sigset); (void) sigaddset(&alarm_sigset, SIGALRM); (void) sigprocmask(SIG_BLOCK, &alarm_sigset, NULL); (void) signal(SIGALRM, moveshots); # endif CONSTANT_MOVE while (Nplayer > 0) { # ifdef CONSTANT_MOVE (void) sigprocmask(SIG_UNBLOCK, &alarm_sigset, NULL); # endif CONSTANT_MOVE read_fds = Fds_mask; errno = 0; # ifndef OLDIPC while (select(Num_fds, &read_fds, (int *) NULL, (int *) NULL, (struct timeval *) NULL) < 0) # else OLDIPC while (select(20, &read_fds, NULL, 32767) < 0) # endif OLDIPC { if (errno != EINTR) perror("select"); if (Nplayer == 0) goto out; errno = 0; } Have_inp = read_fds; # ifdef CONSTANT_MOVE (void) sigprocmask(SIG_BLOCK, &alarm_sigset, NULL); # endif CONSTANT_MOVE # ifdef INTERNET if (read_fds & test_mask) { namelen = DAEMON_SIZE; # ifndef OLDIPC (void) recvfrom(Test_socket, (char *) &msg, sizeof msg, 0, (struct sockaddr *) &test, &namelen); (void) sendto(Test_socket, (char *) &msg, sizeof msg, 0, (struct sockaddr *) &test, DAEMON_SIZE); # else OLDIPC (void) receive(Test_socket, (struct sockaddr *) &test, (char *) &msg, sizeof msg); (void) send(Test_socket, (struct sockaddr *) &test, (char *) &msg, sizeof msg); # endif OLDIPC } # endif INTERNET for (;;) { had_char = FALSE; for (pp = Player; pp < End_player; pp++) if (havechar(pp)) { execute(pp); pp->p_nexec++; had_char++; } # ifdef MONITOR for (pp = Monitor; pp < End_monitor; pp++) if (havechar(pp)) { mon_execute(pp); pp->p_nexec++; had_char++; } # endif MONITOR if (!had_char) break; # ifdef CONSTANT_MOVE for (pp = Player; pp < End_player; pp++) { look(pp); sendcom(pp, REFRESH); } # ifdef MONITOR for (pp = Monitor; pp < End_monitor; pp++) sendcom(pp, REFRESH); # endif MONITOR # else CONSTANT_MOVE moveshots(); # endif CONSTANT_MOVE for (pp = Player; pp < End_player; ) if (pp->p_death[0] != '\0') zap(pp, TRUE); else pp++; # ifdef MONITOR for (pp = Monitor; pp < End_monitor; ) if (pp->p_death[0] != '\0') zap(pp, FALSE); else pp++; # endif MONITOR } if (read_fds & Sock_mask) answer(); for (pp = Player; pp < End_player; pp++) { if (read_fds & pp->p_mask) sendcom(pp, READY, pp->p_nexec); pp->p_nexec = 0; (void) fflush(pp->p_output); } # ifdef MONITOR for (pp = Monitor; pp < End_monitor; pp++) { if (read_fds & pp->p_mask) sendcom(pp, READY, pp->p_nexec); pp->p_nexec = 0; (void) fflush(pp->p_output); } # endif MONITOR } out: # ifdef CONSTANT_MOVE bul_alarm(0); # endif CONSTANT_MOVE # ifdef MONITOR for (pp = Monitor; pp < End_monitor; ) zap(pp, FALSE); # endif MONITOR cleanup(0); } /* * init: * Initialize the global parameters. */ init() { register int i; # ifdef INTERNET SOCKET test_port; auto int msg; # endif INTERNET int cleanup(); # ifndef DEBUG (void) ioctl(fileno(stdout), TIOCNOTTY, NULL); (void) setpgrp(getpid(), getpid()); (void) signal(SIGHUP, SIG_IGN); (void) signal(SIGINT, SIG_IGN); (void) signal(SIGQUIT, SIG_IGN); (void) signal(SIGTERM, cleanup); # endif DEBUG (void) chdir("/usr/tmp"); /* just in case it core dumps */ (void) signal(SIGPIPE, SIG_IGN); # ifdef INTERNET Daemon.sin_family = SOCK_FAMILY; # ifdef OLD if (gethostname(local_name, sizeof local_name) < 0) { perror("gethostname"); exit(1); } if ((hp = gethostbyname(local_name)) == NULL) { fprintf(stderr, "Unknown host %s\n", local_name); exit(1); } bcopy(hp->h_addr, &(Daemon.sin_addr.s_addr), hp->h_length); # else Daemon.sin_addr.s_addr = INADDR_ANY; # endif OLD Daemon.sin_port = htons(Sock_port); # else INTERNET Daemon.sun_family = SOCK_FAMILY; (void) strcpy(Daemon.sun_path, Sock_name); # endif INTERNET # ifndef OLDIPC Socket = socket(SOCK_FAMILY, SOCK_STREAM, 0); # else OLDIPC Socket = socket(SOCK_STREAM, 0, (struct sockaddr *) &Daemon, SO_ACCEPTCONN); # endif OLDIPC # if defined(INTERNET) && !defined(OLDIPC) if (setsockopt(Socket, SOL_SOCKET, SO_USELOOPBACK, &msg, sizeof msg)<0) perror("setsockopt loopback"); # endif INTERNET # ifndef OLDIPC if (bind(Socket, (struct sockaddr *) &Daemon, DAEMON_SIZE) < 0) { if (errno == EADDRINUSE) exit(0); else { perror("bind"); cleanup(1); } } (void) listen(Socket, 5); # endif OLDIPC Fds_mask = (1 << Socket); Num_fds = Socket + 1; # ifdef INTERNET test_port = Daemon; test_port.sin_port = htons(Test_port); # ifndef OLDIPC Test_socket = socket(SOCK_FAMILY, SOCK_DGRAM, 0); if (bind(Test_socket, (struct sockaddr *) &test_port, DAEMON_SIZE) < 0) { perror("bind"); exit(1); } (void) listen(Test_socket, 5); # else OLDIPC Test_socket = socket(SOCK_DGRAM, 0, (struct sockaddr *) &test_port, 0); # endif OLDIPC Fds_mask |= (1 << Test_socket); if (Test_socket > Socket) Num_fds = Test_socket + 1; # endif INTERNET Seed = getpid() + time((time_t *) NULL); makemaze(); for (i = 0; i < NASCII; i++) See_over[i] = TRUE; See_over[DOOR] = FALSE; See_over[WALL1] = FALSE; See_over[WALL2] = FALSE; See_over[WALL3] = FALSE; # ifdef REFLECT See_over[WALL4] = FALSE; See_over[WALL5] = FALSE; # endif REFLECT # ifdef CONSTANT_MOVE getitimer(ITIMER_REAL, &Timing); Timing.it_interval.tv_sec = 0; Timing.it_interval.tv_usec = 500; Timing.it_value.tv_sec = 0; Timing.it_value.tv_usec = 0; setitimer(ITIMER_REAL, &Timing, NULL); # endif CONSTANT_MOVE answer(); } # ifdef CONSTANT_MOVE /* * bul_alarm: * Set up the alarm for the bullets */ bul_alarm(val) int val; { Timing.it_value.tv_usec = val * Timing.it_interval.tv_usec; setitimer(ITIMER_REAL, &Timing, NULL); } # endif CONSTANT_MOVE /* * checkdam: * Check the damage to the given player, and see if s/he is killed */ checkdam(ouch, gotcha, credit, amt, shot_type) register PLAYER *ouch, *gotcha; register IDENT *credit; int amt; char shot_type; { register char *cp; if (ouch->p_death[0] != '\0') return; if (rand_num(100) < 5) { message(ouch, "Missed you by a hair"); if (gotcha != NULL) message(gotcha, "Missed him"); return; } ouch->p_damage += amt; if (ouch->p_damage <= ouch->p_damcap) { (void) sprintf(Buf, "%2d", ouch->p_damage); cgoto(ouch, STAT_DAM_ROW, STAT_VALUE_COL); outstr(ouch, Buf, 2); return; } /* Someone DIED */ switch (shot_type) { default: cp = "Killed"; break; # ifdef FLY case FALL: cp = "Killed on impact"; break; # endif FLY case KNIFE: cp = "Stabbed to death"; break; case SHOT: cp = "Shot to death"; break; case GRENADE: case SATCHEL: case BOMB: cp = "Bombed"; break; case MINE: case GMINE: cp = "Blown apart"; break; # ifdef OOZE case SLIME: cp = "Slimed"; break; # endif OOZE # ifdef VOLCANO case LAVA: cp = "Baked"; break; # endif VOLCANO } if (credit == NULL) { (void) sprintf(ouch->p_death, "| %s by %s |", cp, (shot_type == MINE || shot_type == GMINE) ? "a mine" : "act of God"); return; } (void) sprintf(ouch->p_death, "| %s by %s |", cp, credit->i_name); credit->i_kills++; credit->i_score = credit->i_kills / (double) credit->i_entries; if (gotcha == NULL) return; gotcha->p_damcap += STABDAM; gotcha->p_damage -= STABDAM; if (gotcha->p_damage < 0) gotcha->p_damage = 0; (void) sprintf(Buf, "%2d/%2d", gotcha->p_damage, gotcha->p_damcap); cgoto(gotcha, STAT_DAM_ROW, STAT_VALUE_COL); outstr(gotcha, Buf, 5); (void) sprintf(Buf, "%3d", (gotcha->p_damcap - MAXDAM) / 2); cgoto(gotcha, STAT_KILL_ROW, STAT_VALUE_COL); outstr(gotcha, Buf, 3); (void) sprintf(Buf, "%5.2f", gotcha->p_ident->i_score); for (ouch = Player; ouch < End_player; ouch++) { cgoto(ouch, STAT_PLAY_ROW + 1 + (gotcha - Player), STAT_NAME_COL); outstr(ouch, Buf, 5); } } /* * zap: * Kill off a player and take him out of the game. */ zap(pp, was_player) register PLAYER *pp; FLAG was_player; { register int i, len; register BULLET *bp; register PLAYER *np; register int x, y; int savefd, savemask; if (was_player) { drawplayer(pp, FALSE); Nplayer--; } len = strlen(pp->p_death); /* Display the cause of death */ x = (WIDTH - len) / 2; cgoto(pp, HEIGHT / 2, x); outstr(pp, pp->p_death, len); for (i = 1; i < len; i++) pp->p_death[i] = '-'; pp->p_death[0] = '+'; pp->p_death[len - 1] = '+'; cgoto(pp, HEIGHT / 2 - 1, x); outstr(pp, pp->p_death, len); cgoto(pp, HEIGHT / 2 + 1, x); outstr(pp, pp->p_death, len); cgoto(pp, HEIGHT, 0); if (Nplayer == 0) { # ifdef CONSTANT_MOVE bul_alarm(0); # endif CONSTANT_MOVE cleanup(0); /* NOTREACHED */ } savefd = pp->p_fd; savemask = pp->p_mask; # ifdef MONITOR if (was_player) { # endif MONITOR for (bp = Bullets; bp != NULL; bp = bp->b_next) { if (bp->b_owner == pp) bp->b_owner = NULL; if (bp->b_x == pp->p_x && bp->b_y == pp->p_y) bp->b_over = SPACE; } i = rand_num(pp->p_ammo); if (i == pp->p_ammo - 1) { x = pp->p_ammo; len = SLIME; } else if (i >= BOMBREQ) { x = BOMBREQ; len = BOMB; } else if (i >= SSLIMEREQ) { x = SSLIMEREQ; len = SLIME; } else if (i >= SATREQ) { x = SATREQ; len = SATCHEL; } else if (i >= SLIMEREQ) { x = SLIMEREQ; len = SLIME; } else if (i >= GRENREQ) { x = GRENREQ; len = GRENADE; } else x = 0; if (x > 0) { add_shot(len, pp->p_y, pp->p_x, pp->p_face, x, (PLAYER *) NULL, TRUE, SPACE); (void) sprintf(Buf, "%s detonated.", pp->p_ident->i_name); for (np = Player; np < End_player; np++) message(np, Buf); # ifdef MONITOR for (np = Monitor; np < End_monitor; np++) message(np, Buf); # endif MONITOR } # ifdef VOLCANO volcano += pp->p_ammo - x; if (rand_num(100) < volcano / 50) { do { x = rand_num(WIDTH / 2) + WIDTH / 4; y = rand_num(HEIGHT / 2) + HEIGHT / 4; } while (Maze[y][x] != SPACE); add_shot(LAVA, y, x, LEFTS, volcano, (PLAYER *) NULL, TRUE, SPACE); for (np = Player; np < End_player; np++) message(np, "Volcano eruption."); volcano = 0; } # endif VOLCANO sendcom(pp, ENDWIN); (void) fclose(pp->p_output); End_player--; if (pp != End_player) { bcopy((char *) End_player, (char *) pp, sizeof (PLAYER)); (void) sprintf(Buf, "%5.2f%c%-10.10s", pp->p_ident->i_score, stat_char(pp), pp->p_ident->i_name); i = STAT_PLAY_ROW + 1 + (pp - Player); for (np = Player; np < End_player; np++) { cgoto(np, i, STAT_NAME_COL); outstr(np, Buf, STAT_NAME_LEN); } # ifdef MONITOR for (np = Monitor; np < End_monitor; np++) { cgoto(np, i, STAT_NAME_COL); outstr(np, Buf, STAT_NAME_LEN); } # endif MONITOR } /* Erase the last player */ i = STAT_PLAY_ROW + 1 + Nplayer; for (np = Player; np < End_player; np++) { cgoto(np, i, STAT_NAME_COL); ce(np); } # ifdef MONITOR for (np = Monitor; np < End_monitor; np++) { cgoto(np, i, STAT_NAME_COL); ce(np); } } else { sendcom(pp, ENDWIN); (void) putc(LAST_PLAYER, pp->p_output); (void) fclose(pp->p_output); End_monitor--; if (pp != End_monitor) { bcopy((char *) End_monitor, (char *) pp, sizeof (PLAYER)); (void) sprintf(Buf, "%5.5s %-10.10s", " ", pp->p_ident->i_name); i = STAT_MON_ROW + 1 + (pp - Player); for (np = Player; np < End_player; np++) { cgoto(np, i, STAT_NAME_COL); outstr(np, Buf, STAT_NAME_LEN); } for (np = Monitor; np < End_monitor; np++) { cgoto(np, i, STAT_NAME_COL); outstr(np, Buf, STAT_NAME_LEN); } } /* Erase the last monitor */ i = STAT_MON_ROW + 1 + (End_monitor - Monitor); for (np = Player; np < End_player; np++) { cgoto(np, i, STAT_NAME_COL); ce(np); } for (np = Monitor; np < End_monitor; np++) { cgoto(np, i, STAT_NAME_COL); ce(np); } } # endif MONITOR Fds_mask &= ~savemask; if (Num_fds == savefd + 1) { Num_fds = Socket; # ifdef INTERNET if (Test_socket > Socket) Num_fds = Test_socket; # endif INTERNET for (np = Player; np < End_player; np++) if (np->p_fd > Num_fds) Num_fds = np->p_fd; # ifdef MONITOR for (np = Monitor; np < End_monitor; np++) if (np->p_fd > Num_fds) Num_fds = np->p_fd; # endif MONITOR Num_fds++; } } /* * rand_num: * Return a random number in a given range. */ rand_num(range) int range; { return (range == 0 ? 0 : RN % range); } /* * havechar: * Check to see if we have any characters in the input queue; if * we do, read them, stash them away, and return TRUE; else return * FALSE. */ havechar(pp) register PLAYER *pp; { extern int errno; if (pp->p_ncount < pp->p_nchar) return TRUE; if (!(Have_inp & pp->p_mask)) return FALSE; Have_inp &= ~pp->p_mask; check_again: errno = 0; if ((pp->p_nchar = read(pp->p_fd, pp->p_cbuf, sizeof pp->p_cbuf)) <= 0) { if (errno == EINTR) goto check_again; pp->p_cbuf[0] = 'q'; } pp->p_ncount = 0; return TRUE; } /* * cleanup: * Exit with the given value, cleaning up any droppings lying around */ cleanup(eval) int eval; { register PLAYER *pp; for (pp = Player; pp < End_player; pp++) { cgoto(pp, HEIGHT, 0); sendcom(pp, ENDWIN); (void) putc(LAST_PLAYER, pp->p_output); (void) fclose(pp->p_output); } # ifdef MONITOR for (pp = Monitor; pp < End_monitor; pp++) { cgoto(pp, HEIGHT, 0); sendcom(pp, ENDWIN); (void) putc(LAST_PLAYER, pp->p_output); (void) fclose(pp->p_output); } # endif MONITOR (void) close(Socket); # ifdef AF_UNIX_HACK (void) unlink(Sock_name); # endif AF_UNIX_HACK exit(eval); } ================================================ FILE: games/hunt/execute.c ================================================ /* * Hunt * Copyright (c) 1985 Conrad C. Huang, Gregory S. Couch, Kenneth C.R.C. Arnold * San Francisco, California * * Copyright (c) 1985 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ # include "hunt.h" # undef CTRL # define CTRL(x) ('x' & 037) # ifdef MONITOR /* * mon_execute: * Execute a single monitor command */ mon_execute(pp) register PLAYER *pp; { register char ch; ch = pp->p_cbuf[pp->p_ncount++]; switch (ch) { case CTRL(L): sendcom(pp, REDRAW); break; case 'q': (void) strcpy(pp->p_death, "| Quit |"); break; } } # endif MONITOR /* * execute: * Execute a single command */ execute(pp) register PLAYER *pp; { register char ch; ch = pp->p_cbuf[pp->p_ncount++]; # ifdef FLY if (pp->p_flying >= 0) { switch (ch) { case CTRL(L): sendcom(pp, REDRAW); break; case 'q': (void) strcpy(pp->p_death, "| Quit |"); break; } return; } # endif FLY switch (ch) { case CTRL(L): sendcom(pp, REDRAW); break; case 'h': move(pp, LEFTS); break; case 'H': face(pp, LEFTS); break; case 'j': move(pp, BELOW); break; case 'J': face(pp, BELOW); break; case 'k': move(pp, ABOVE); break; case 'K': face(pp, ABOVE); break; case 'l': move(pp, RIGHT); break; case 'L': face(pp, RIGHT); break; case 'f': fire(pp, SHOT); break; case 'g': fire(pp, GRENADE); break; case 'F': fire(pp, SATCHEL); break; case 'G': fire(pp, BOMB); break; # ifdef OOZE case 'o': fire_slime(pp, SLIMEREQ); break; case 'O': fire_slime(pp, SSLIMEREQ); break; # endif OOZE case 's': scan(pp); break; case 'c': cloak(pp); break; case 'q': (void) strcpy(pp->p_death, "| Quit |"); break; } } /* * move: * Execute a move in the given direction */ move(pp, dir) register PLAYER *pp; int dir; { register PLAYER *newp; register int x, y; register FLAG moved; register BULLET *bp; y = pp->p_y; x = pp->p_x; switch (dir) { case LEFTS: x--; break; case RIGHT: x++; break; case ABOVE: y--; break; case BELOW: y++; break; } moved = FALSE; switch (Maze[y][x]) { case SPACE: # ifdef RANDOM case DOOR: # endif RANDOM moved = TRUE; break; case WALL1: case WALL2: case WALL3: # ifdef REFLECT case WALL4: case WALL5: # endif REFLECT break; case MINE: case GMINE: if (dir == pp->p_face) pickup(pp, y, x, 5, Maze[y][x]); else if (opposite(dir, pp->p_face)) pickup(pp, y, x, 95, Maze[y][x]); else pickup(pp, y, x, 50, Maze[y][x]); Maze[y][x] = SPACE; moved = TRUE; break; case SHOT: case GRENADE: case SATCHEL: case BOMB: bp = is_bullet(y, x); if (bp != NULL) bp->b_expl = TRUE; Maze[y][x] = SPACE; moved = TRUE; break; case LEFTS: case RIGHT: case ABOVE: case BELOW: # ifdef FLY case FLYER: # endif FLY if (dir != pp->p_face) sendcom(pp, BELL); else { newp = play_at(y, x); checkdam(newp, pp, pp->p_ident, STABDAM, KNIFE); } break; } if (moved) { if (pp->p_ncshot > 0) if (--pp->p_ncshot == MAXNCSHOT) { cgoto(pp, STAT_GUN_ROW, STAT_VALUE_COL); outstr(pp, " ok", 3); } if (pp->p_undershot) { fixshots(pp->p_y, pp->p_x, pp->p_over); pp->p_undershot = FALSE; } drawplayer(pp, FALSE); pp->p_over = Maze[y][x]; pp->p_y = y; pp->p_x = x; drawplayer(pp, TRUE); } } /* * face: * Change the direction the player is facing */ face(pp, dir) register PLAYER *pp; register int dir; { if (pp->p_face != dir) { pp->p_face = dir; drawplayer(pp, TRUE); } } /* * fire: * Fire a shot of the given type in the given direction */ fire(pp, type) register PLAYER *pp; register char type; { register int req_index; static int req[4] = { BULREQ, GRENREQ, SATREQ, BOMBREQ }; static int shot_type[4] = { SHOT, GRENADE, SATCHEL, BOMB }; if (pp == NULL) return; if (pp->p_ammo == 0) { message(pp, "No more charges."); return; } if (pp->p_ncshot > MAXNCSHOT) return; if (pp->p_ncshot++ == MAXNCSHOT) { cgoto(pp, STAT_GUN_ROW, STAT_VALUE_COL); outstr(pp, " ", 3); } switch (type) { case SHOT: req_index = 0; break; case GRENADE: req_index = 1; break; case SATCHEL: req_index = 2; break; case BOMB: req_index = 3; break; # ifdef DEBUG default: message(pp, "What you do!!!"); return; # endif DEBUG } while (pp->p_ammo < req[req_index]) req_index--; pp->p_ammo -= req[req_index]; (void) sprintf(Buf, "%3d", pp->p_ammo); cgoto(pp, STAT_AMMO_ROW, STAT_VALUE_COL); outstr(pp, Buf, 3); add_shot(shot_type[req_index], pp->p_y, pp->p_x, pp->p_face, req[req_index], pp, FALSE, pp->p_face); pp->p_undershot = TRUE; /* * Show the object to everyone */ showexpl(pp->p_y, pp->p_x, shot_type[req_index]); for (pp = Player; pp < End_player; pp++) sendcom(pp, REFRESH); # ifdef MONITOR for (pp = Monitor; pp < End_monitor; pp++) sendcom(pp, REFRESH); # endif MONITOR } # ifdef OOZE /* * fire_slime: * Fire a slime shot in the given direction */ fire_slime(pp, req) register PLAYER *pp; register int req; { if (pp == NULL) return; if (pp->p_ammo < req) { message(pp, "Not enough charges."); return; } if (pp->p_ncshot > MAXNCSHOT) return; if (pp->p_ncshot++ == MAXNCSHOT) { cgoto(pp, STAT_GUN_ROW, STAT_VALUE_COL); outstr(pp, " ", 3); } pp->p_ammo -= req; (void) sprintf(Buf, "%3d", pp->p_ammo); cgoto(pp, STAT_AMMO_ROW, STAT_VALUE_COL); outstr(pp, Buf, 3); add_shot(SLIME, pp->p_y, pp->p_x, pp->p_face, req, pp, FALSE, pp->p_face); /* * Show the object to everyone */ showexpl(pp->p_y, pp->p_x, SLIME); for (pp = Player; pp < End_player; pp++) sendcom(pp, REFRESH); # ifdef MONITOR for (pp = Monitor; pp < End_monitor; pp++) sendcom(pp, REFRESH); # endif MONITOR } # endif OOZE /* * create_shot: * Create a shot with the given properties */ add_shot(type, y, x, face, charge, owner, expl, over) int type; int y, x; char face; int charge; PLAYER *owner; int expl; char over; { register BULLET *bp; # ifdef CONSTANT_MOVE /* * if there are no bullets in flight, set up the alarm */ if (Bullets == NULL) bul_alarm(1); # endif CONSTANT_MOVE bp = create_shot(type, y, x, face, charge, owner, (owner == NULL) ? NULL : owner->p_ident, expl, over); bp->b_next = Bullets; Bullets = bp; } BULLET * create_shot(type, y, x, face, charge, owner, score, expl, over) int type; int y, x; char face; int charge; PLAYER *owner; IDENT *score; int expl; char over; { register BULLET *bp; bp = (BULLET *) malloc(sizeof (BULLET)); /* NOSTRICT */ if (bp == NULL) { if (owner != NULL) message(owner, "Out of memory"); return NULL; } bp->b_face = face; bp->b_x = x; bp->b_y = y; bp->b_charge = charge; bp->b_owner = owner; bp->b_score = score; bp->b_type = type; bp->b_expl = expl; bp->b_over = over; bp->b_next = NULL; return bp; } /* * cloak: * Turn on or increase length of a cloak */ cloak(pp) register PLAYER *pp; { if (pp->p_ammo <= 0) { message(pp, "No more charges"); return; } (void) sprintf(Buf, "%3d", --pp->p_ammo); cgoto(pp, STAT_AMMO_ROW, STAT_VALUE_COL); outstr(pp, Buf, 3); pp->p_cloak += CLOAKLEN; cgoto(pp, STAT_CLOAK_ROW, STAT_VALUE_COL); outstr(pp, " on", 3); if (pp->p_scan >= 0) { pp->p_scan = -1; cgoto(pp, STAT_SCAN_ROW, STAT_VALUE_COL); outstr(pp, " ", 3); } showstat(pp); } /* * scan: * Turn on or increase length of a scan */ scan(pp) register PLAYER *pp; { if (pp->p_ammo <= 0) { message(pp, "No more charges"); return; } (void) sprintf(Buf, "%3d", --pp->p_ammo); cgoto(pp, STAT_AMMO_ROW, STAT_VALUE_COL); outstr(pp, Buf, 3); pp->p_scan += SCANLEN; cgoto(pp, STAT_SCAN_ROW, STAT_VALUE_COL); outstr(pp, " on", 3); if (pp->p_cloak >= 0) { pp->p_cloak = -1; cgoto(pp, STAT_CLOAK_ROW, STAT_VALUE_COL); outstr(pp, " ", 3); } showstat(pp); } /* * pickup: * check whether the object blew up or whether he picked it up */ pickup(pp, y, x, prob, obj) register PLAYER *pp; register int y, x; int prob; int obj; { register int req; switch (obj) { case MINE: req = BULREQ; break; case GMINE: req = GRENREQ; break; default: abort(); } if (rand_num(100) < prob) add_shot(obj, y, x, LEFTS, req, (PLAYER *) NULL, TRUE, pp->p_face); else { pp->p_ammo += req; (void) sprintf(Buf, "%3d", pp->p_ammo); cgoto(pp, STAT_AMMO_ROW, STAT_VALUE_COL); outstr(pp, Buf, 3); } } ================================================ FILE: games/hunt/expl.c ================================================ /* * Hunt * Copyright (c) 1985 Conrad C. Huang, Gregory S. Couch, Kenneth C.R.C. Arnold * San Francisco, California * * Copyright (c) 1985 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ # include "hunt.h" /* * showexpl: * Show the explosions as they currently are */ showexpl(y, x, type) register int y, x; char type; { register PLAYER *pp; register EXPL *ep; if (y < 0 || y >= HEIGHT) return; if (x < 0 || x >= WIDTH) return; ep = (EXPL *) malloc(sizeof (EXPL)); /* NOSTRICT */ ep->e_y = y; ep->e_x = x; ep->e_char = type; ep->e_next = Expl[0]; Expl[0] = ep; for (pp = Player; pp < End_player; pp++) { if (pp->p_maze[y][x] == type) continue; pp->p_maze[y][x] = type; cgoto(pp, y, x); outch(pp, type); } # ifdef MONITOR for (pp = Monitor; pp < End_monitor; pp++) { if (pp->p_maze[y][x] == type) continue; pp->p_maze[y][x] = type; cgoto(pp, y, x); outch(pp, type); } # endif MONITOR switch (Maze[y][x]) { case WALL1: case WALL2: case WALL3: # ifdef RANDOM case DOOR: # endif RANDOM # ifdef REFLECT case WALL4: case WALL5: # endif REFLECT if (y >= UBOUND && y < DBOUND && x >= LBOUND && x < RBOUND) remove_wall(y, x); break; } } /* * rollexpl: * Roll the explosions over, so the next one in the list is at the * top */ rollexpl() { register EXPL *ep; register PLAYER *pp; register int y, x; register char c; register EXPL *nextep; for (ep = Expl[EXPLEN - 1]; ep != NULL; ep = nextep) { nextep = ep->e_next; y = ep->e_y; x = ep->e_x; if (y < UBOUND || y >= DBOUND || x < LBOUND || x >= RBOUND) c = Maze[y][x]; else c = SPACE; for (pp = Player; pp < End_player; pp++) if (pp->p_maze[y][x] == ep->e_char) { pp->p_maze[y][x] = c; cgoto(pp, y, x); outch(pp, c); } # ifdef MONITOR for (pp = Monitor; pp < End_monitor; pp++) check(pp, y, x); # endif MONITOR free((char *) ep); } for (x = EXPLEN - 1; x > 0; x--) Expl[x] = Expl[x - 1]; Expl[0] = NULL; } /* There's about 700 walls in the initial maze. So we pick a number * that keeps the maze relatively full. */ # define MAXREMOVE 40 static REGEN removed[MAXREMOVE]; static REGEN *rem_index = removed; /* * remove_wall - add a location where the wall was blown away. * if there is no space left over, put the a wall at * the location currently pointed at. */ remove_wall(y, x) int y, x; { register REGEN *r; # if defined(MONITOR) || defined(FLY) register PLAYER *pp; # endif MONITOR || FLY # ifdef FLY register char save_char; # endif FLY r = rem_index; while (r->r_y != 0) { # ifdef FLY switch (Maze[r->r_y][r->r_x]) { case SPACE: case LEFTS: case RIGHT: case ABOVE: case BELOW: case FLYER: save_char = Maze[r->r_y][r->r_x]; goto found; } # else FLY if (Maze[r->r_y][r->r_x] == SPACE) break; # endif FLY if (++r >= &removed[MAXREMOVE]) r = removed; } found: if (r->r_y != 0) { /* Slot being used, put back this wall */ # ifdef FLY if (save_char == SPACE) Maze[r->r_y][r->r_x] = Orig_maze[r->r_y][r->r_x]; else { pp = play_at(r->r_y, r->r_x); if (pp->p_flying >= 0) pp->p_flying += rand_num(10); else { pp->p_flying = rand_num(20); pp->p_flyx = 2 * rand_num(6) - 5; pp->p_flyy = 2 * rand_num(6) - 5; } pp->p_over = Orig_maze[r->r_y][r->r_x]; pp->p_face = FLYER; Maze[r->r_y][r->r_x] = FLYER; showexpl(r->r_y, r->r_x, FLYER); } # else FLY Maze[r->r_y][r->r_x] = Orig_maze[r->r_y][r->r_x]; # endif FLY # ifdef RANDOM if (rand_num(100) == 0) Maze[r->r_y][r->r_x] = DOOR; # endif RANDOM # ifdef REFLECT if (rand_num(100) == 0) /* one percent of the time */ Maze[r->r_y][r->r_x] = WALL4; # endif REFLECT # ifdef MONITOR for (pp = Monitor; pp < End_monitor; pp++) check(pp, r->r_y, r->r_x); # endif MONITOR } r->r_y = y; r->r_x = x; if (++r >= &removed[MAXREMOVE]) rem_index = removed; else rem_index = r; Maze[y][x] = SPACE; # ifdef MONITOR for (pp = Monitor; pp < End_monitor; pp++) check(pp, y, x); # endif MONITOR } ================================================ FILE: games/hunt/extern.c ================================================ /* * Hunt * Copyright (c) 1985 Conrad C. Huang, Gregory S. Couch, Kenneth C.R.C. Arnold * San Francisco, California * * Copyright (c) 1985 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ # include "hunt.h" # ifdef MONITOR FLAG Am_monitor = FALSE; /* current process is a monitor */ # endif MONITOR char Buf[BUFSIZ]; /* general scribbling buffer */ char Maze[HEIGHT][WIDTH2]; /* the maze */ char Orig_maze[HEIGHT][WIDTH2]; /* the original maze */ long Fds_mask; /* mask for the file descriptors */ int Have_inp; /* which file descriptors have input */ int Nplayer = 0; /* number of players */ int Num_fds; /* number of maximum file descriptor */ int Socket; /* main socket */ long Sock_mask; /* select mask for main socket */ int See_over[NASCII]; /* lookup table for determining whether * character represents "transparent" * item */ BULLET *Bullets = NULL; /* linked list of bullets */ EXPL *Expl[EXPLEN]; /* explosion lists */ PLAYER Player[MAXPL]; /* all the players */ PLAYER *End_player = Player; /* last active player slot */ IDENT *Scores; /* score cache */ # ifdef MONITOR PLAYER Monitor[MAXMON]; /* all the monitors */ PLAYER *End_monitor = Monitor; /* last active monitor slot */ # endif MONITOR # ifdef VOLCANO int volcano = 0; /* Explosion size */ # endif VOLCANO ================================================ FILE: games/hunt/hunt.6 ================================================ .\" Hunt .\" Copyright (c) 1985 Conrad C. Huang, Gregory S. Couch, Kenneth C.R.C. Arnold .\" San Francisco, California .\" .\" Copyright (c) 1985 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)hunt.6 6.3 (Berkeley) 1/9/86 .\" .TH HUNT 6 "January 9, 1986" .UC 6 .SH NAME hunt \- a multi-player multi-terminal game .SH SYNOPSIS \fB/usr/games/hunt\fP [-q] [\fB-m\fP] [hostname] [\fB-l\fP name] .SH DESCRIPTION The object of the game .I hunt is to kill off the other players. There are no rooms, no treasures, and no monsters. Instead, you wander around a maze, find grenades, trip mines, and shoot down walls and players. The more players you kill before you die, the better your score is. If the .B \-m flag is given, you enter the game as a monitor (you can see the action but you cannot play). .PP .I Hunt normally looks for an active game on the local network; if none is found, it starts one up on the local host. One may specify the location of the game by giving the \fIhostname\fP argument. The player name may be specified on the command line by using the \fB-l\fP option. This command syntax was chosen for \fIrlogin/rsh\fP compatibility. If the .B \-q flag is given, .I hunt queries the network and reports if an active game were found. This is useful for .login scripts. .PP .I Hunt only works on crt (vdt) terminals with at least 24 lines, 80 columns, and cursor addressing. The screen is divided in to 3 areas. On the right hand side is the status area. It shows you how much damage you've sustained, how many charges you have left, who's in the game, who's scanning (the asterisk in front of the name), who's cloaked (the plus sign in front of the name), and other players' scores. Most of the rest of the screen is taken up by your map of the maze, except for the 24th line, which is used for longer messages that don't fit in the status area. .PP .I Hunt uses the same keys to move as .I vi does, .IR i.e. , .BR h , j , k , and .B l for left, down, up, right respectively. To change which direction you're facing in the maze, use the upper case version of the movement key (\c .IR i.e. , HJKL). .TP Other commands are: .sp .nf .ta .ta \w'>\|<\|^\|v\ \ 'u f \- Fire (in the direction you're facing) (Takes 1 charge) g \- Throw grenade (in the direction you're facing) (Takes 9 charges) F \- Throw satchel charge (Takes 25 charges) G \- Throw bomb (Takes 49 charges) o \- Throw small slime bomb (Takes 15 charges) O \- Throw big slime bomb (Takes 30 charges) s \- Scan (show where other players are) (Takes 1 charge) c \- Cloak (hide from scanners) (Takes 1 charge) ^L \- Redraw screen q \- Quit .fi .TP Knowing what the symbols on the screen often helps: .sp .nf .ta .ta \w'>\|<\|^\|v\ \ 'u \-\||\|+ \- walls /\|\\ \- diagonal (deflecting) walls # \- doors (dispersion walls) ; \- small mine g \- large mine : \- shot o \- grenade O \- satchel charge @ \- bomb s \- small slime bomb $ \- big slime bomb >\|<\|^\|v \- you facing right, left, up, or down }\|{\|i\|! \- other players facing right, left, up, or down \(** \- explosion .ne 3 .cs R 24 .cs I 24 \fR\\|/\fP .cs R \fI\-\(**\-\fP \- grenade and large mine explosion .fl .cs R 24 \fR/|\\\fP .cs R .cs I .fi .TP Satchel and bomb explosions are larger than grenades (5x5, 7x7, and 3x3 respectively). .LP Other helpful hints: .sp .ie n .ds b [] .el .ds b \(bu .ta .ta \w'\*b\ \|'u .nr In \n(.i .de MP .br .in \n(Inu+\w'\*b\ \|'u .ti \n(Inu \*b \c .. .MP You can only fire in the direction you are facing. .MP You can only fire three shots in a row, then the gun must cool. .MP A shot only affects the square it hits. .MP Shots and grenades move 5 times faster than you do. .MP To stab someone, you must face that player and move at them. .MP Stabbing does 2 points worth of damage and shooting does 5 points. .MP Slime does 5 points of damage each time it hits. .MP You start with 15 charges and get 5 more for every new player. .MP A grenade affects the nine squares centered about the square it hits. .MP A satchel affects the twenty-five squares centered about the square it hits. .MP A bomb affects the forty-nine squares centered about the square it hits. .MP Slime affects all squares it oozes over (15 or 30 respectively). .MP One small mine and one large mine is placed in the maze for every new player. A mine has a 5% probability of tripping when you walk directly at it; 50% when going sideways on to it; 95% when backing up on to it. Tripping a mine costs you 5 points or 10 points respectively. Defusing a mine is worth 1 charge or 9 charges respectively. .MP You cannot see behind you. .MP Scanning lasts for (20 times the number of players) turns. Scanning takes 1 ammo charge, so don't waste all your charges scanning. .MP Cloaking lasts for 20 turns. .MP Whenever you kill someone, you get 2 more damage capacity points and 2 damage points taken away. .MP Maximum typeahead is 5 characters. .MP A shot destroys normal (\c .IR i.e., non-diagonal, non-door) walls. .MP Diagonal walls deflect shots and change orientation. .MP Doors disperse shots in random directions (up, down, left, right). .MP Diagonal walls and doors cannot be destroyed by direct shots but may be destroyed by an adjacent grenade explosion. .MP Slime goes around walls, not through them. .MP Walls regenerate, reappearing in the order they were destroyed. One percent of the regenerated walls will be diagonal walls or doors. When a wall is generated directly beneath a player, he is thrown in a random direction for a random period of time. When he lands, he sustains damage (up to 20 percent of the amount of damage he had before impact); that is, the less damage he had, the more nimble he is and therefore less likely to hurt himself on landing. \".MP \"There is a volcano close to the center of the maze which goes off \"close to every 100 deaths. .MP The environment variable .B HUNT is checked to get the player name. If you don't have this variable set, .I hunt will ask you what name you want to play under. If it is set, you may also set up a single character keyboard map, but then you have to enumerate the options: .br .ti +1i \fIe.g.\fP setenv HUNT ``name=Sneaky,mapkey=zoFfGg1f2g3F4G'' .br sets the player name to Sneaky, and the maps \fBz\fP to \fBo\fP, \fBF\fP to \fBf\fP, \fBG\fP to \fBg\fP, \fB1\fP to \fBf\fP, \fB2\fP to \fBg\fP, \fB3\fP to \fBF\fP, and \fB4\fP to \fBG\fP. The \fImapkey\fP option must be last. .MP It's a boring game if you're the only one playing. .PP Your score is the ratio of number of kills to number of times you entered the game and is only kept for the duration of a single session of \fIhunt\fP. .PP .I Hunt normally drives up the load average to be about (number_of_players + 0.5) greater than it would be without a .I hunt game executing. A limit of three players per host and nine players total is enforced by \fIhunt\fP. .SH FILES .nf .ta .ta \w'/usr/games/lib/hunt.driver\ \ \ 'u /usr/games/lib/hunt.driver game coordinator .DT .fi .SH AUTHORS Conrad Huang, Ken Arnold, and Greg Couch; University of California, San Francisco, Computer Graphics Lab .SH ACKNOWLEDGEMENTS We thank Don Kneller, John Thomason, Eric Pettersen, and Scott Weiner for providing endless hours of play-testing to improve the character of the game. We hope their significant others will forgive them; we certainly don't. .SH BUGS To keep up the pace, not everything is as realistic as possible. .PP There were some bugs in early releases of 4.2 BSD that .I hunt helped discover; .I hunt will crash your system if those bugs haven't been fixed. ================================================ FILE: games/hunt/hunt.c ================================================ /* * Hunt * Copyright (c) 1985 Conrad C. Huang, Gregory S. Couch, Kenneth C.R.C. Arnold * San Francisco, California * * Copyright (c) 1985 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ # include # include # include "hunt.h" # include # include # include FLAG Last_player = FALSE; # ifdef MONITOR FLAG Am_monitor = FALSE; # endif MONITOR FLAG Query_driver = FALSE; char Buf[BUFSIZ]; int Master_pid; int Socket; # ifdef INTERNET char *Sock_host; # endif INTERNET SOCKET Daemon; # ifdef INTERNET # define DAEMON_SIZE (sizeof Daemon) # else INTERNET # define DAEMON_SIZE (sizeof Daemon - 1) # endif INTERNET char map_key[256]; /* what to map keys to */ static char name[NAMELEN]; extern int cur_row, cur_col, _putchar(); extern char *tgoto(); /* * main: * Main program for local process */ main(ac, av) int ac; char **av; { char *term; extern int errno; extern int Otto_mode; int dumpit(), intr(), sigterm(), sigemt(), tstp(); for (ac--, av++; ac > 0 && av[0][0] == '-'; ac--, av++) { switch (av[0][1]) { case 'l': /* rsh compatibility */ case 'n': if (ac <= 1) goto usage; ac--, av++; (void) strcpy(name, av[0]); break; case 'o': # ifndef OTTO fputs("The -o flag is reserved for future use.\n", stderr); goto usage; # else OTTO Otto_mode = TRUE; break; # endif OTTO # ifdef MONITOR case 'm': Am_monitor = TRUE; break; # endif MONITOR # ifdef INTERNET case 'q': /* query whether hunt is running */ Query_driver = TRUE; break; case 'h': if (ac <= 1) goto usage; ac--, av++; Sock_host = av[0]; break; # endif INTERNET default: usage: # ifdef INTERNET # ifdef MONITOR # define USAGE "usage: hunt [-q] [-n name] [-h host] [-m]\n" # else MONITOR # define USAGE "usage: hunt [-q] [-n name] [-h host]\n" # endif MONITOR # else INTERNET # ifdef MONITOR # define USAGE "usage: hunt [-n name] [-m]\n" # else MONITOR # define USAGE "usage: hunt [-n name]\n" # endif MONITOR # endif INTERNET fputs(USAGE, stderr); # undef USAGE exit(1); } } # ifdef INTERNET if (ac > 1) goto usage; else if (ac > 0) Sock_host = av[0]; # else INTERNET if (ac > 0) goto usage; # endif INTERNET # ifdef INTERNET if (Query_driver) { find_driver(FALSE); if (Daemon.sin_port != 0) { struct hostent *hp; hp = gethostbyaddr(&Daemon.sin_addr, sizeof Daemon.sin_addr, AF_INET); fprintf(stderr, "HUNT!! found on %s\n", hp != NULL ? hp->h_name : inet_ntoa(Daemon.sin_addr)); } exit(Daemon.sin_port == 0); } # endif INTERNET # ifdef OTTO if (Otto_mode) (void) strcpy(name, "otto"); else # endif OTTO env_init(); (void) fflush(stdout); if (!isatty(0) || (term = getenv("TERM")) == NULL) { fprintf(stderr, "no terminal type\n"); exit(1); } _tty_ch = 0; gettmode(); setterm(term); noecho(); cbreak(); _puts(TI); _puts(VS); clear_screen(); (void) signal(SIGINT, intr); (void) signal(SIGTERM, sigterm); (void) signal(SIGEMT, sigemt); (void) signal(SIGQUIT, dumpit); (void) signal(SIGPIPE, SIG_IGN); (void) signal(SIGTSTP, tstp); do { # ifdef INTERNET find_driver(TRUE); do { int msg; # ifndef OLDIPC Socket = socket(SOCK_FAMILY, SOCK_STREAM, 0); # else OLDIPC Socket = socket(SOCK_STREAM, 0, 0, 0); # endif OLDIPC if (Socket < 0) { perror("socket"); exit(1); } # ifndef OLDIPC msg = 1; if (setsockopt(Socket, SOL_SOCKET, SO_USELOOPBACK, &msg, sizeof msg) < 0) perror("setsockopt loopback"); # endif OLDIPC errno = 0; if (connect(Socket, (struct sockaddr *) &Daemon, DAEMON_SIZE) < 0) { if (errno != ECONNREFUSED) { perror("connect"); leave(1, "connect"); } } else break; sleep(1); } while (close(Socket) == 0); # else INTERNET /* * set up a socket */ if ((Socket = socket(SOCK_FAMILY, SOCK_STREAM, 0)) < 0) { perror("socket"); exit(1); } /* * attempt to connect the socket to a name; if it fails that * usually means that the driver isn't running, so we start * up the driver. */ Daemon.sun_family = SOCK_FAMILY; (void) strcpy(Daemon.sun_path, Sock_name); if (connect(Socket, &Daemon, DAEMON_SIZE) < 0) { if (errno != ENOENT) { perror("connect"); leave(1, "connect2"); } start_driver(); do { (void) close(Socket); if ((Socket = socket(SOCK_FAMILY, SOCK_STREAM, 0)) < 0) { perror("socket"); exit(1); } sleep(2); } while (connect(Socket, &Daemon, DAEMON_SIZE) < 0); } # endif INTERNET do_connect(name); playit(); } while (!quit()); leave(0, NULL); /* NOTREACHED */ } # ifdef INTERNET # ifdef BROADCAST broadcast_vec(s, vector) int s; /* socket */ struct sockaddr **vector; { char if_buf[BUFSIZ]; struct ifconf ifc; struct ifreq *ifr; int n; int vec_cnt; *vector = NULL; ifc.ifc_len = sizeof if_buf; ifc.ifc_buf = if_buf; if (ioctl(s, SIOCGIFCONF, (char *) &ifc) < 0) return 0; vec_cnt = 0; n = ifc.ifc_len / sizeof (struct ifreq); *vector = (struct sockaddr *) malloc(n * sizeof (struct sockaddr)); for (ifr = ifc.ifc_req; n > 0; n--, ifr++) if (ioctl(s, SIOCGIFBRDADDR, ifr) >= 0) bcopy(&ifr->ifr_addr, &(*vector)[vec_cnt++], sizeof (struct sockaddr)); return vec_cnt; } # endif BROADCAST find_driver(do_startup) FLAG do_startup; { int msg; static SOCKET test; int test_socket; int namelen; char local_name[80]; static initial = TRUE; static struct in_addr local_address; register struct hostent *hp; int (*oldsigalrm)(), sigalrm(); extern int errno; # ifdef BROADCAST static int brdc; static SOCKET *brdv; int i; # endif BROADCAST if (Sock_host != NULL) { if (!initial) return; /* Daemon address already valid */ initial = FALSE; if ((hp = gethostbyname(Sock_host)) == NULL) { leave(1, "Unknown host"); /* NOTREACHED */ } Daemon.sin_family = SOCK_FAMILY; Daemon.sin_port = htons(Sock_port); Daemon.sin_addr = *((struct in_addr *) hp->h_addr); if (!Query_driver) return; } if (initial) { /* do one time initialization */ # ifndef BROADCAST sethostent(1); /* don't bother to close host file */ # endif BROADCAST if (gethostname(local_name, sizeof local_name) < 0) { leave(1, "Sorry, I have no name."); /* NOTREACHED */ } if ((hp = gethostbyname(local_name)) == NULL) { leave(1, "Can't find myself."); /* NOTREACHED */ } local_address = * ((struct in_addr *) hp->h_addr); test.sin_family = SOCK_FAMILY; test.sin_addr = local_address; test.sin_port = htons(Test_port); } # ifndef OLDIPC test_socket = socket(SOCK_FAMILY, SOCK_DGRAM, 0); # else OLDIPC test_socket = socket(SOCK_DGRAM, 0, 0, 0); # endif OLCIPC if (test_socket < 0) { perror("socket"); leave(1, "socket system call failed"); /* NOTREACHED */ } msg = 1; if (Query_driver && Sock_host != NULL) { test.sin_family = SOCK_FAMILY; test.sin_addr = Daemon.sin_addr; test.sin_port = htons(Test_port); # ifndef OLDIPC (void) sendto(test_socket, (char *) &msg, sizeof msg, 0, (struct sockaddr *) &test, DAEMON_SIZE); # else OLDIPC (void) send(test_socket, (struct sockaddr *) &test, (char *) &msg, sizeof msg); # endif OLDIPC goto get_response; } if (!initial) { /* favor host of previous session by broadcasting to it first */ test.sin_addr = Daemon.sin_addr; test.sin_port = htons(Test_port); (void) sendto(test_socket, (char *) &msg, sizeof msg, 0, (struct sockaddr *) &test, DAEMON_SIZE); } # ifdef BROADCAST if (initial) brdc = broadcast_vec(test_socket, &brdv); if (brdc <= 0) { Daemon.sin_family = SOCK_FAMILY; Daemon.sin_addr = local_address; Daemon.sin_port = htons(Sock_port); initial = FALSE; return; } if (setsockopt(test_socket, SOL_SOCKET, SO_BROADCAST, (int) &msg, sizeof msg) < 0) { perror("setsockopt broadcast"); leave(1, "setsockopt broadcast"); /* NOTREACHED */ } /* send broadcast packets on all interfaces */ for (i = 0; i < brdc; i++) { bcopy(&brdv[i], &test, sizeof (SOCKET)); test.sin_port = htons(Test_port); if (sendto(test_socket, (char *) &msg, sizeof msg, 0, (struct sockaddr *) &test, DAEMON_SIZE) < 0) { perror("sendto"); leave(1, "sendto"); /* NOTREACHED */ } } # else BROADCAST /* loop thru all hosts on local net and send msg to them. */ sethostent(0); /* rewind host file */ while (hp = gethostent()) { if (inet_netof(test.sin_addr) == inet_netof(* ((struct in_addr *) hp->h_addr))) { test.sin_addr = * ((struct in_addr *) hp->h_addr); # ifndef OLDIPC (void) sendto(test_socket, (char *) &msg, sizeof msg, 0, (struct sockaddr *) &test, DAEMON_SIZE); # else OLDIPC (void) send(test_socket, (struct sockaddr *) &test, (char *) &msg, sizeof msg); # endif OLDIPC } } # endif BROADCAST get_response: namelen = DAEMON_SIZE; oldsigalrm = signal(SIGALRM, sigalrm); errno = 0; (void) alarm(1); # ifndef OLDIPC if (recvfrom(test_socket, (char *) &msg, sizeof msg, 0, (struct sockaddr *) &Daemon, &namelen) < 0) # else OLDIPC if (receive(test_socket, (struct sockaddr *) &Daemon, &msg, sizeof msg) < 0) # endif OLDIPC { if (errno != EINTR) { perror("recvfrom"); leave(1, "recvfrom"); /* NOTREACHED */ } (void) alarm(0); (void) signal(SIGALRM, oldsigalrm); Daemon.sin_family = SOCK_FAMILY; Daemon.sin_port = htons(Sock_port); Daemon.sin_addr = local_address; if (!do_startup) Daemon.sin_port = 0; else start_driver(); } else { (void) alarm(0); (void) signal(SIGALRM, oldsigalrm); Daemon.sin_port = htons(Sock_port); } (void) close(test_socket); initial = FALSE; } # endif INTERNET start_driver() { register int procid; # ifdef MONITOR if (Am_monitor) { leave(1, "No one playing."); /* NOTREACHED */ } # endif MONITOR # ifdef INTERNET if (Sock_host != NULL) { sleep(3); return 0; } # endif INTERNET mvcur(cur_row, cur_col, 23, 0); cur_row = 23; cur_col = 0; put_str("Starting..."); fflush(stdout); procid = vfork(); if (procid == -1) { perror("fork"); leave(1, "fork failed."); } if (procid == 0) { (void) signal(SIGINT, SIG_IGN); (void) close(Socket); execl(Driver, "HUNT", NULL); /* only get here if exec failed */ kill(getppid(), SIGEMT); /* tell mom */ _exit(1); } mvcur(cur_row, cur_col, 23, 0); cur_row = 23; cur_col = 0; put_str("Connecting..."); fflush(stdout); return 0; } /* * bad_con: * We had a bad connection. For the moment we assume that this * means the game is full. */ bad_con() { leave(1, "The game is full. Sorry."); /* NOTREACHED */ } /* * dumpit: * Handle a core dump signal by not dumping core, just leaving, * so we end up with a core dump from the driver */ dumpit() { (void) kill(Master_pid, SIGQUIT); (void) chdir("coredump"); abort(); } /* * sigterm: * Handle a terminate signal */ sigterm() { leave(0, NULL); /* NOTREACHED */ } /* * sigemt: * Handle a emt signal - shouldn't happen on vaxes(?) */ sigemt() { leave(1, "Unable to start driver. Try again."); /* NOTREACHED */ } # ifdef INTERNET /* * sigalrm: * Handle an alarm signal */ sigalrm() { return; } # endif INTERNET /* * rmnl: * Remove a '\n' at the end of a string if there is one */ rmnl(s) char *s; { register char *cp; char *rindex(); cp = rindex(s, '\n'); if (cp != NULL) *cp = '\0'; } /* * intr: * Handle a interrupt signal */ intr() { register int ch; register int explained; register int y, x; (void) signal(SIGINT, SIG_IGN); y = cur_row; x = cur_col; mvcur(cur_row, cur_col, 23, 0); cur_row = 23; cur_col = 0; put_str("Really quit? "); clear_eol(); fflush(stdout); explained = FALSE; for (;;) { ch = getchar(); if (isupper(ch)) ch = tolower(ch); if (ch == 'y') { (void) write(Socket, "q", 1); (void) close(Socket); leave(0, NULL); } else if (ch == 'n') { (void) signal(SIGINT, intr); mvcur(cur_row, cur_col, y, x); cur_row = y; cur_col = x; fflush(stdout); return; } if (!explained) { put_str("(Y or N) "); fflush(stdout); explained = TRUE; } (void) putchar(CTRL(G)); (void) fflush(stdout); } } /* * leave: * Leave the game somewhat gracefully, restoring all current * tty stats. */ leave(eval, mesg) int eval; char *mesg; { mvcur(cur_row, cur_col, 23, 0); if (mesg == NULL) clear_eol(); else { put_str(mesg); clear_eol(); putchar('\n'); fflush(stdout); /* flush in case VE changes pages */ } resetty(); _puts(VE); _puts(TE); exit(eval); } /* * tstp: * Handle stop and start signals */ tstp() { static struct sgttyb tty; int y, x; tty = _tty; y = cur_row; x = cur_col; mvcur(cur_row, cur_col, 23, 0); cur_row = 23; cur_col = 0; _puts(VE); _puts(TE); (void) fflush(stdout); resetty(); (void) kill(getpid(), SIGSTOP); (void) signal(SIGTSTP, tstp); _tty = tty; (void) stty(_tty_ch, &_tty); _puts(TI); _puts(VS); cur_row = y; cur_col = x; _puts(tgoto(CM, cur_row, cur_col)); redraw_screen(); fflush(stdout); } env_init() { register int i; char *envp, *envname, *s, *index(); for (i = 0; i < 256; i++) map_key[i] = (char) i; envname = NULL; if ((envp = getenv("HUNT")) != NULL) { while ((s = index(envp, '=')) != NULL) { if (strncmp(envp, "name=", s - envp + 1) == 0) { envname = s + 1; if ((s = index(envp, ',')) == NULL) { *envp = '\0'; break; } *s = '\0'; envp = s + 1; } /* must be last option */ else if (strncmp(envp, "mapkey=", s - envp + 1) == 0) { for (s = s + 1; *s != '\0'; s += 2) { map_key[(unsigned int) *s] = *(s + 1); if (*(s + 1) == '\0') { break; } } *envp = '\0'; break; } else { *s = '\0'; printf("unknown option %s\n", envp); if ((s = index(envp, ',')) == NULL) { *envp = '\0'; break; } envp = s + 1; } } if (*envp != '\0') if (envname == NULL) envname = envp; else printf("unknown option %s\n", envp); } if (envname != NULL) { (void) strcpy(name, envname); printf("Entering as '%s'\n", envname); } else if (name[0] == '\0') { printf("Enter your code name: "); if (fgets(name, sizeof name, stdin) == NULL) exit(1); } rmnl(name); } ================================================ FILE: games/hunt/hunt.h ================================================ /* * Hunt * Copyright (c) 1985 Conrad C. Huang, Gregory S. Couch, Kenneth C.R.C. Arnold * San Francisco, California * * Copyright (c) 1985 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ # include # ifndef OLDIPC # include # include # include # else OLDIPC # include # include # include # endif OLDIPC # include # ifdef INTERNET # include # include # ifndef OLDIPC # include # endif !OLDIPC # ifdef BROADCAST # include # endif BROADCAST # else INTERNET # include # endif INTERNET # ifdef INTERNET # define SOCK_FAMILY AF_INET # else INTERNET # define SOCK_FAMILY AF_UNIX # define AF_UNIX_HACK /* 4.2 hack; leaves files around */ # endif INTERNET # define ADDCH ('a' | 0200) # define MOVE ('m' | 0200) # define REFRESH ('r' | 0200) # define CLRTOEOL ('c' | 0200) # define ENDWIN ('e' | 0200) # define CLEAR ('C' | 0200) # define REDRAW ('R' | 0200) # define LAST_PLAYER ('l' | 0200) # define BELL ('b' | 0200) # define READY ('g' | 0200) /* * Choose MAXPL and MAXMON carefully. The screen is assumed to be * 23 lines high and will only tolerate (MAXPL == 12 && MAXMON == 0) * or (MAXPL + MAXMON <= 10). */ # define MAXPL 9 # ifdef MONITOR # define MAXMON 1 # endif MONITOR # define NAMELEN 20 # define MSGLEN 80 # define DECAY 50.0 # define NASCII 128 # ifndef REFLECT # ifndef RANDOM # define RANDOM # endif RANDOM # endif REFLECT # define WIDTH 59 # define WIDTH2 64 /* Next power of 2 >= WIDTH (for fast access) */ # define HEIGHT 23 # define UBOUND 1 # define DBOUND 22 # define LBOUND 1 # define RBOUND (WIDTH - 1) # define STAT_LABEL_COL 60 # define STAT_VALUE_COL 74 # define STAT_NAME_COL 61 # define STAT_SCAN_COL (STAT_NAME_COL + 5) # define STAT_NAME_ROW 0 # define STAT_AMMO_ROW 2 # define STAT_SCAN_ROW 3 # define STAT_CLOAK_ROW 4 # define STAT_GUN_ROW 5 # define STAT_DAM_ROW 7 # define STAT_KILL_ROW 8 # define STAT_PLAY_ROW 10 # ifdef MONITOR # define STAT_MON_ROW (STAT_PLAY_ROW + MAXPL + 1) # endif MONITOR # define STAT_NAME_LEN 16 # define DOOR '#' # define WALL1 '-' # define WALL2 '|' # define WALL3 '+' # ifdef REFLECT # define WALL4 '/' # define WALL5 '\\' # endif REFLECT # define KNIFE 'K' # define SHOT ':' # define GRENADE 'o' # define SATCHEL 'O' # define BOMB '@' # define MINE ';' # define GMINE 'g' # ifdef OOZE # define SLIME '$' # endif OOZE # ifdef VOLCANO # define LAVA '~' # endif VOLCANO # ifdef FLY # define FALL 'F' # endif FLY # define SPACE ' ' # define ABOVE 'i' # define BELOW '!' # define RIGHT '}' # define LEFTS '{' # ifdef FLY # define FLYER '&' # endif FLY # define NORTH 01 # define SOUTH 02 # define EAST 010 # define WEST 020 # ifndef TRUE # define TRUE 1 # define FALSE 0 # endif TRUE # ifndef CTRL # define CTRL(x) ('x' & 037) # endif CTRL # define BULSPD 5 /* bullets movement speed */ # define ISHOTS 15 # define NSHOTS 5 # define MAXNCSHOT 2 # define MAXDAM 10 # define MINDAM 5 # define STABDAM 2 # define BULREQ 1 # define GRENREQ 9 # define SATREQ 25 # define BOMBREQ 49 # ifdef OOZE # define SLIMEREQ 15 # define SSLIMEREQ 30 # define SLIMESPEED 5 # endif OOZE # ifdef VOLCANO # define LAVASPEED 2 # endif VOLCANO # define CLOAKLEN 20 # define SCANLEN (Nplayer * 20) # define EXPLEN 4 # ifdef FLY # define _cloak_char(pp) (((pp)->p_cloak < 0) ? ' ' : '+') # define _scan_char(pp) (((pp)->p_scan < 0) ? _cloak_char(pp) : '*') # define stat_char(pp) (((pp)->p_flying < 0) ? _scan_char(pp) : FLYER) # else FLY # define _cloak_char(pp) (((pp)->p_cloak < 0) ? ' ' : '+') # define stat_char(pp) (((pp)->p_scan < 0) ? _cloak_char(pp) : '*') # endif FLY typedef int FLAG; typedef struct bullet_def BULLET; typedef struct expl_def EXPL; typedef struct player_def PLAYER; typedef struct ident_def IDENT; typedef struct regen_def REGEN; # ifdef INTERNET typedef struct sockaddr_in SOCKET; # else INTERNET typedef struct sockaddr_un SOCKET; # endif INTERNET typedef struct sgttyb TTYB; struct ident_def { char i_name[NAMELEN]; long i_machine; long i_uid; int i_kills; int i_entries; float i_score; IDENT *i_next; }; struct player_def { IDENT *p_ident; int p_face; char p_over; int p_undershot; # ifdef FLY int p_flying; int p_flyx, p_flyy; # endif FLY FILE *p_output; int p_fd; int p_mask; int p_damage; int p_damcap; int p_ammo; int p_ncshot; int p_scan; int p_cloak; int p_x, p_y; int p_ncount; int p_nexec; long p_nchar; char p_death[MSGLEN]; char p_maze[HEIGHT][WIDTH2]; int p_curx, p_cury; int p_lastx, p_lasty; int p_changed; char p_cbuf[BUFSIZ]; }; struct bullet_def { int b_x, b_y; int b_face; int b_charge; char b_type; char b_over; PLAYER *b_owner; IDENT *b_score; FLAG b_expl; BULLET *b_next; }; struct expl_def { int e_x, e_y; char e_char; EXPL *e_next; }; struct regen_def { int r_x, r_y; REGEN *r_next; }; /* * external variables */ extern FLAG Last_player; extern char Buf[BUFSIZ], Maze[HEIGHT][WIDTH2], Orig_maze[HEIGHT][WIDTH2]; extern char *Sock_name, *Driver; extern int errno, Have_inp, Nplayer, Num_fds, Socket; extern long Fds_mask, Sock_mask; # ifdef INTERNET extern int Test_port; extern int Sock_port; # else INTERNET extern char *Sock_name; # endif INTERNET # ifdef VOLCANO extern int volcano; # endif VOLCANO extern int See_over[NASCII]; extern BULLET *Bullets; extern EXPL *Expl[EXPLEN]; extern IDENT *Scores; extern PLAYER Player[MAXPL], *End_player; # ifdef MONITOR extern FLAG Am_monitor; extern PLAYER Monitor[MAXMON], *End_monitor; # endif MONITOR /* * function types */ char *getenv(), *malloc(), *sprintf(), *strcpy(), *strncpy(); IDENT *get_ident(); int moveshots(); BULLET *is_bullet(), *create_shot(); PLAYER *play_at(); ================================================ FILE: games/hunt/makemaze.c ================================================ /* * Hunt * Copyright (c) 1985 Conrad C. Huang, Gregory S. Couch, Kenneth C.R.C. Arnold * San Francisco, California * * Copyright (c) 1985 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ # include "hunt.h" # define ISCLEAR(y,x) (Maze[y][x] == SPACE) # define ODD(n) ((n) & 01) makemaze() { register char *sp; register int y, x; /* * fill maze with walls */ sp = &Maze[0][0]; while (sp < &Maze[HEIGHT - 1][WIDTH]) *sp++ = DOOR; y = rand_num(DBOUND - UBOUND) + UBOUND; x = rand_num(RBOUND - LBOUND) + LBOUND; dig(y, x); /* Dig out the maze */ remap(); } # define NPERM 24 # define NDIR 4 int dirs[NPERM][NDIR] = { {0,1,2,3}, {3,0,1,2}, {0,2,3,1}, {0,3,2,1}, {1,0,2,3}, {2,3,0,1}, {0,2,1,3}, {2,3,1,0}, {1,0,3,2}, {1,2,0,3}, {3,1,2,0}, {2,0,3,1}, {1,3,0,2}, {0,3,1,2}, {1,3,2,0}, {2,0,1,3}, {0,1,3,2}, {3,1,0,2}, {2,1,0,3}, {1,2,3,0}, {2,1,3,0}, {3,0,2,1}, {3,2,0,1}, {3,2,1,0} }; int incr[NDIR][2] = { {0, 1}, {1, 0}, {0, -1}, {-1, 0} }; dig(y, x) int y, x; { register int *dp; register int *ip; register int ny, nx; register int *endp; Maze[y][x] = SPACE; /* Clear this spot */ dp = dirs[rand_num(NPERM)]; endp = &dp[NDIR]; while (dp < endp) { ip = &incr[*dp++][0]; ny = y + *ip++; nx = x + *ip; if (candig(ny, nx)) dig(ny, nx); } } /* * candig: * Is it legal to clear this spot? */ candig(y, x) register int y, x; { register int i; if (ODD(x) && ODD(y)) return FALSE; /* can't touch ODD spots */ if (y < UBOUND || y >= DBOUND) return FALSE; /* Beyond vertical bounds, NO */ if (x < LBOUND || x >= RBOUND) return FALSE; /* Beyond horizontal bounds, NO */ if (ISCLEAR(y, x)) return FALSE; /* Already clear, NO */ i = ISCLEAR(y, x + 1); i += ISCLEAR(y, x - 1); if (i > 1) return FALSE; /* Introduces cycle, NO */ i += ISCLEAR(y + 1, x); if (i > 1) return FALSE; /* Introduces cycle, NO */ i += ISCLEAR(y - 1, x); if (i > 1) return FALSE; /* Introduces cycle, NO */ return TRUE; /* OK */ } remap() { register int y, x; register char *sp; register int stat; for (y = 0; y < HEIGHT; y++) for (x = 0; x < WIDTH; x++) { sp = &Maze[y][x]; if (*sp == SPACE) continue; stat = 0; if (y - 1 >= 0 && Maze[y - 1][x] != SPACE) stat |= NORTH; if (y + 1 < HEIGHT && Maze[y + 1][x] != SPACE) stat |= SOUTH; if (x + 1 < WIDTH && Maze[y][x + 1] != SPACE) stat |= EAST; if (x - 1 >= 0 && Maze[y][x - 1] != SPACE) stat |= WEST; switch (stat) { case WEST | EAST: *sp = WALL1; break; case NORTH | SOUTH: *sp = WALL2; break; case 0: # ifdef RANDOM *sp = DOOR; # endif RANDOM # ifdef REFLECT *sp = rand_num(2) ? WALL4 : WALL5; # endif REFLECT break; default: *sp = WALL3; break; } } bcopy((char *) Maze, (char *) Orig_maze, sizeof Maze); } ================================================ FILE: games/hunt/pathname.c ================================================ /* * Hunt * Copyright (c) 1985 Conrad C. Huang, Gregory S. Couch, Kenneth C.R.C. Arnold * San Francisco, California * * Copyright (c) 1985 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ /* * There is no particular significance to the numbers assigned * to Test_port and Sock_port. They're just random numbers greater * than then range reserved for privileged sockets. */ # ifdef DEBUG char *Driver = "/va/conrad/games/src/hunt/hunt.driver.dbg"; # ifdef INTERNET int Test_port = ('h' << 8) | 't'; int Sock_port = ('h' << 8) | 's'; # else INTERNET char *Sock_name = "/tmp/hunt"; # endif INTERNET # else DEBUG char *Driver = "/usr/games/lib/hunt.driver"; # ifdef INTERNET int Test_port = ('h' << 8) | 't'; int Sock_port = ('h' << 8) | 's'; # else INTERNET char *Sock_name = "/tmp/hunt"; # endif INTERNET # endif DEBUG ================================================ FILE: games/hunt/playit.c ================================================ /* * Hunt * Copyright (c) 1985 Conrad C. Huang, Gregory S. Couch, Kenneth C.R.C. Arnold * San Francisco, California * * Copyright (c) 1985 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ # include # include # include # include # include "hunt.h" # include # undef CTRL # define CTRL(x) ('x' & 037) int input(); static int nchar_send; static int in = FREAD; char screen[24][80], blanks[80]; int cur_row, cur_col; # ifdef OTTO int Otto_count; int Otto_mode; static int otto_y, otto_x; static char otto_face; # endif OTTO # define MAX_SEND 5 /* * ibuf is the input buffer used for the stream from the driver. * It is small because we do not check for user input when there * are characters in the input buffer. */ static char ibuf[20]; #define GETCHR(fd) (--(fd)->_cnt >= 0 ? *(fd)->_ptr++&0377 : getchr(fd)) /* * playit: * Play a given game, handling all the curses commands from * the driver. */ playit() { register FILE *inf; register int ch; register unsigned int y, x; extern int Master_pid; extern int errno; extern int _putchar(); errno = 0; while ((inf = fdopen(Socket, "r")) == NULL) if (errno == EINTR) errno = 0; else { perror("fdopen of socket"); exit(1); } setbuffer(inf, ibuf, sizeof ibuf); Master_pid = getw(inf); if (Master_pid == 0 || Master_pid == EOF) { bad_con(); /* NOTREACHED */ } # ifdef OTTO Otto_count = 0; # endif OTTO nchar_send = MAX_SEND; while ((ch = GETCHR(inf)) != EOF) { # ifdef DEBUG fputc(ch, stderr); # endif DEBUG switch (ch & 0377) { case MOVE: y = GETCHR(inf); x = GETCHR(inf); mvcur(cur_row, cur_col, y, x); cur_row = y; cur_col = x; break; case ADDCH: ch = GETCHR(inf); # ifdef OTTO switch (ch) { case '<': case '>': case '^': case 'v': otto_face = ch; getyx(stdscr, otto_y, otto_x); break; } # endif OTTO put_ch(ch); break; case CLRTOEOL: clear_eol(); break; case CLEAR: clear_screen(); break; case REFRESH: fflush(stdout); break; case REDRAW: redraw_screen(); fflush(stdout); break; case ENDWIN: fflush(stdout); if ((ch = GETCHR(inf)) == LAST_PLAYER) Last_player = TRUE; ch = EOF; goto out; case BELL: putchar(CTRL(G)); break; case READY: (void) fflush(stdout); if (nchar_send < 0) (void) ioctl(fileno(stdin), TIOCFLUSH, &in); nchar_send = MAX_SEND; # ifndef OTTO (void) GETCHR(inf); # else OTTO Otto_count -= (GETCHR(inf) & 255); if (!Am_monitor) { # ifdef DEBUG fputc('0' + Otto_count, stderr); # endif DEBUG if (Otto_count == 0 && Otto_mode) otto(otto_y, otto_x, otto_face); } # endif OTTO break; default: # ifdef OTTO switch (ch) { case '<': case '>': case '^': case 'v': otto_face = ch; getyx(stdscr, otto_y, otto_x); break; } # endif OTTO put_ch(ch); break; } } out: (void) fclose(inf); } /* * getchr: * Grab input and pass it along to the driver * Return any characters from the driver * When this routine is called by GETCHR, we already know there are * no characters in the input buffer. */ getchr(fd) register FILE *fd; { long nchar; long readfds, s_readfds; int driver_mask, stdin_mask; int nfds, s_nfds; driver_mask = 1L << fileno(fd); stdin_mask = 1L << fileno(stdin); s_readfds = driver_mask | stdin_mask; s_nfds = (driver_mask > stdin_mask) ? driver_mask : stdin_mask; s_nfds++; one_more_time: do { errno = 0; readfds = s_readfds; nfds = s_nfds; # ifndef OLDIPC nfds = select(nfds, &readfds, NULL, NULL, NULL); # else OLDIPC nfds = select(nfds, &readfds, (int *) NULL, 32767); # endif OLDIPC } while (nfds <= 0 && errno == EINTR); if (readfds & stdin_mask) send_stuff(); if ((readfds & driver_mask) == 0) goto one_more_time; return _filbuf(fd); } /* * send_stuff: * Send standard input characters to the driver */ send_stuff() { register int count; register char *sp, *nsp; static char inp[sizeof Buf]; extern char map_key[256]; count = read(fileno(stdin), Buf, sizeof Buf); if (count <= 0) return; if (nchar_send <= 0) { (void) write(1, "\7", 1); return; } /* * look for 'q'uit commands; if we find one, * confirm it. If it is not confirmed, strip * it out of the input */ Buf[count] = '\0'; nsp = inp; for (sp = Buf; *sp != '\0'; sp++) if ((*nsp = map_key[*sp]) == 'q') intr(); # ifdef OTTO else if (*nsp == CTRL(O)) Otto_mode = !Otto_mode; # endif OTTO else nsp++; count = nsp - inp; if (count) { # ifdef OTTO Otto_count += count; # endif OTTO nchar_send -= count; if (nchar_send < 0) count += nchar_send; (void) write(Socket, inp, count); } } /* * quit: * Handle the end of the game when the player dies */ quit() { register int explain, ch; if (Last_player) return TRUE; # ifdef OTTO if (Otto_mode) return FALSE; # endif OTTO mvcur(cur_row, cur_col, HEIGHT, 0); cur_row = HEIGHT; cur_col = 0; put_str("Re-enter game? "); clear_eol(); fflush(stdout); explain = FALSE; for (;;) { if (isupper(ch = getchar())) ch = tolower(ch); if (ch == 'y') { sleep(2); return FALSE; } else if (ch == 'n') return TRUE; (void) putchar(CTRL(G)); if (!explain) { put_str("(Y or N) "); explain = TRUE; } fflush(stdout); } } put_ch(ch) char ch; { if (!isprint(ch)) { fprintf(stderr, "r,c,ch: %d,%d,%d", cur_row, cur_col, ch); return; } screen[cur_row][cur_col] = ch; putchar(ch); if (++cur_col >= COLS) { if (!AM || XN) putchar('\n'); cur_col = 0; if (++cur_row >= LINES) cur_row = LINES; } } put_str(s) char *s; { while (*s) put_ch(*s++); } clear_screen() { register int i; int _putchar(); if (blanks[0] == '\0') for (i = 0; i < 80; i++) blanks[i] = ' '; if (CL != NULL) { tputs(CL, LINES, _putchar); for (i = 0; i < 24; i++) bcopy(blanks, screen[i], 80); } else { for (i = 0; i < 24; i++) { mvcur(cur_row, cur_col, i, 0); cur_row = i; cur_col = 0; clear_eol(); } mvcur(cur_row, cur_col, 0, 0); } cur_row = cur_col = 0; } clear_eol() { int _putchar(); if (CE != NULL) tputs(CE, 1, _putchar); else { fwrite(blanks, sizeof (char), 80 - cur_col, stdout); if (COLS != 80) mvcur(cur_row, 80, cur_row, cur_col); else if (AM) mvcur(cur_row + 1, 0, cur_row, cur_col); else mvcur(cur_row, 79, cur_row, cur_col); } bcopy(blanks, &screen[cur_row][cur_col], 80 - cur_col); } redraw_screen() { register int i; static int first = 1; if (first) { if ((curscr = newwin(24, 80, 0, 0)) == NULL) { fprintf(stderr, "Can't create curscr\n"); exit(1); } for (i = 0; i < 24; i++) curscr->_y[i] = screen[i]; first = 0; } curscr->_cury = cur_row; curscr->_curx = cur_col; wrefresh(curscr); #ifdef NOCURSES mvcur(cur_row, cur_col, 0, 0); for (i = 0; i < 23; i++) { fwrite(screen[i], sizeof (char), 80, stdout); if (COLS > 80 || (COLS == 80 && !AM)) putchar('\n'); } fwrite(screen[23], sizeof (char), 79, stdout); mvcur(23, 79, cur_row, cur_col); #endif } ================================================ FILE: games/hunt/shots.c ================================================ /* * Hunt * Copyright (c) 1985 Conrad C. Huang, Gregory S. Couch, Kenneth C.R.C. Arnold * San Francisco, California * * Copyright (c) 1985 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ # include "hunt.h" # include # define PLUS_DELTA(x, max) if (x < max) x++; else x-- # define MINUS_DELTA(x, min) if (x > min) x--; else x++ /* * moveshots: * Move the shots already in the air, taking explosions into account */ moveshots() { register BULLET *bp, *next; register PLAYER *pp; register int x, y; register BULLET *blist; register int i; rollexpl(); if (Bullets == NULL) goto ret; /* * First we move through the bullet list BULSPD times, looking * for things we may have run into. If we do run into * something, we set up the explosion and disappear, checking * for damage to any player who got in the way. */ blist = Bullets; Bullets = NULL; for (bp = blist; bp != NULL; bp = next) { next = bp->b_next; x = bp->b_x; y = bp->b_y; Maze[y][x] = bp->b_over; for (pp = Player; pp < End_player; pp++) check(pp, y, x); # ifdef MONITOR for (pp = Monitor; pp < End_monitor; pp++) check(pp, y, x); # endif MONITOR for (i = 0; i < BULSPD; i++) { if (bp->b_expl) break; x = bp->b_x; y = bp->b_y; switch (bp->b_face) { case LEFTS: x--; break; case RIGHT: x++; break; case ABOVE: y--; break; case BELOW: y++; break; } switch (Maze[y][x]) { case SHOT: if (rand_num(100) < 5) { zapshot(Bullets, bp); zapshot(next, bp); } break; case GRENADE: if (rand_num(100) < 10) { zapshot(Bullets, bp); zapshot(next, bp); } break; # ifdef REFLECT case WALL4: /* reflecting walls */ switch (bp->b_face) { case LEFTS: bp->b_face = BELOW; break; case RIGHT: bp->b_face = ABOVE; break; case ABOVE: bp->b_face = RIGHT; break; case BELOW: bp->b_face = LEFTS; break; } Maze[y][x] = WALL5; # ifdef MONITOR for (pp = Monitor; pp < End_monitor; pp++) check(pp, y, x); # endif MONITOR break; case WALL5: switch (bp->b_face) { case LEFTS: bp->b_face = ABOVE; break; case RIGHT: bp->b_face = BELOW; break; case ABOVE: bp->b_face = LEFTS; break; case BELOW: bp->b_face = RIGHT; break; } Maze[y][x] = WALL4; # ifdef MONITOR for (pp = Monitor; pp < End_monitor; pp++) check(pp, y, x); # endif MONITOR break; # endif REFLECT # ifdef RANDOM case DOOR: switch (rand_num(4)) { case 0: bp->b_face = ABOVE; break; case 1: bp->b_face = BELOW; break; case 2: bp->b_face = LEFTS; break; case 3: bp->b_face = RIGHT; break; } break; # endif RANDOM case LEFTS: case RIGHT: case BELOW: case ABOVE: # ifdef FLY case FLYER: # endif FLY /* * give the person a chance to catch a * grenade if s/he is facing it */ if (rand_num(100) < 10 && opposite(bp->b_face, Maze[y][x])) { if (bp->b_owner != NULL) message(bp->b_owner, "Your charge was absorbed!"); pp = play_at(y, x); pp->p_ammo += bp->b_charge; (void) sprintf(Buf, "Absorbed charge (good shield!)"); message(pp, Buf); free((char *) bp); (void) sprintf(Buf, "%3d", pp->p_ammo); cgoto(pp, STAT_AMMO_ROW, STAT_VALUE_COL); outstr(pp, Buf, 3); goto next_bullet; } /* FALLTHROUGH */ # ifndef RANDOM case DOOR: # endif RANDOM case WALL1: case WALL2: case WALL3: bp->b_expl = TRUE; break; } bp->b_x = x; bp->b_y = y; } bp->b_next = Bullets; Bullets = bp; next_bullet: ; } blist = Bullets; Bullets = NULL; for (bp = blist; bp != NULL; bp = next) { next = bp->b_next; if (!bp->b_expl) { save_bullet(bp); # ifdef MONITOR for (pp = Monitor; pp < End_monitor; pp++) check(pp, bp->b_y, bp->b_x); # endif MONITOR continue; } chkshot(bp); free((char *) bp); } for (pp = Player; pp < End_player; pp++) Maze[pp->p_y][pp->p_x] = pp->p_face; ret: for (pp = Player; pp < End_player; pp++) { # ifdef FLY if (pp->p_flying >= 0) { Maze[pp->p_y][pp->p_x] = pp->p_over; x = pp->p_x + pp->p_flyx; y = pp->p_y + pp->p_flyy; if (x < 1) { x = 1 - x; pp->p_flyx = -pp->p_flyx; } else if (x > WIDTH - 2) { x = (WIDTH - 2) - (x - (WIDTH - 2)); pp->p_flyx = -pp->p_flyx; } if (y < 1) { y = 1 - y; pp->p_flyy = -pp->p_flyy; } else if (y > HEIGHT - 2) { y = (HEIGHT - 2) - (y - (HEIGHT - 2)); pp->p_flyy = -pp->p_flyy; } again: switch (Maze[y][x]) { case LEFTS: case RIGHT: case ABOVE: case BELOW: case FLYER: switch (rand_num(4)) { case 0: PLUS_DELTA(x, WIDTH - 2); break; case 1: MINUS_DELTA(x, 1); break; case 2: PLUS_DELTA(y, HEIGHT - 2); break; case 3: MINUS_DELTA(y, 1); break; } goto again; case WALL1: case WALL2: case WALL3: # ifdef REFLECT case WALL4: case WALL5: # endif REFLECT # ifdef RANDOM case DOOR: # endif RANDOM if (pp->p_flying == 0) pp->p_flying++; break; case MINE: checkdam(pp, NULL, NULL, MINDAM, MINE); Maze[y][x] = SPACE; break; case GMINE: checkdam(pp, NULL, NULL, MINDAM, GMINE); checkdam(pp, NULL, NULL, MINDAM, GMINE); Maze[y][x] = SPACE; break; } pp->p_y = y; pp->p_x = x; pp->p_over = Maze[y][x]; if (pp->p_flying-- == 0) { checkdam(pp, NULL, NULL, rand_num(pp->p_damage / 5), FALL); rand_face(pp); showstat(pp); } Maze[y][x] = pp->p_face; showexpl(y, x, pp->p_face); } # endif FLY sendcom(pp, REFRESH); /* Flush out the explosions */ look(pp); sendcom(pp, REFRESH); } # ifdef MONITOR for (pp = Monitor; pp < End_monitor; pp++) sendcom(pp, REFRESH); # endif MONITOR # ifdef CONSTANT_MOVE if (Bullets != NULL) { bul_alarm(1); return; } for (i = 0; i < EXPLEN; i++) if (Expl[i] != NULL) { bul_alarm(1); return; } bul_alarm(0); # endif CONSTANT_MOVE return; } save_bullet(bp) register BULLET *bp; { bp->b_over = Maze[bp->b_y][bp->b_x]; switch (bp->b_over) { case SHOT: case GRENADE: case SATCHEL: case BOMB: # ifdef OOZE case SLIME: # ifdef VOLCANO case LAVA: # endif VOLCANO # endif OOZE find_under(Bullets, bp); break; } switch (bp->b_over) { case LEFTS: case RIGHT: case ABOVE: case BELOW: # ifdef FLY case FLYER: # endif FLY mark_player(bp); break; default: Maze[bp->b_y][bp->b_x] = bp->b_type; break; } bp->b_next = Bullets; Bullets = bp; } /* * chkshot * Handle explosions */ chkshot(bp) register BULLET *bp; { register int y, x; register int dy, dx, absdy; register int delta, damage; register char expl; register PLAYER *pp; switch (bp->b_type) { case SHOT: case MINE: delta = 0; break; case GRENADE: case GMINE: delta = 1; break; case SATCHEL: delta = 2; break; case BOMB: delta = 3; break; # ifdef OOZE case SLIME: # ifdef VOLCANO case LAVA: # endif VOLCANO chkslime(bp); return; # endif OOZE } for (y = bp->b_y - delta; y <= bp->b_y + delta; y++) { if (y < 0 || y >= HEIGHT) continue; dy = y - bp->b_y; absdy = (dy < 0) ? -dy : dy; for (x = bp->b_x - delta; x <= bp->b_x + delta; x++) { if (x < 0 || x >= WIDTH) continue; dx = x - bp->b_x; if (dx == 0) expl = (dy == 0) ? '*' : '|'; else if (dy == 0) expl = '-'; else if (dx == dy) expl = '\\'; else if (dx == -dy) expl = '/'; else expl = '*'; showexpl(y, x, expl); switch (Maze[y][x]) { case LEFTS: case RIGHT: case ABOVE: case BELOW: # ifdef FLY case FLYER: # endif FLY if (dx < 0) dx = -dx; if (absdy > dx) damage = delta - absdy + 1; else damage = delta - dx + 1; pp = play_at(y, x); while (damage-- > 0) checkdam(pp, bp->b_owner, bp->b_score, MINDAM, bp->b_type); break; case GMINE: case MINE: add_shot((Maze[y][x] == GMINE) ? GRENADE : SHOT, y, x, LEFTS, (Maze[y][x] == GMINE) ? GRENREQ : BULREQ, (PLAYER *) NULL, TRUE, SPACE); Maze[y][x] = SPACE; break; } } } } # ifdef OOZE /* * chkslime: * handle slime shot exploding */ chkslime(bp) register BULLET *bp; { register BULLET *nbp; switch (Maze[bp->b_y][bp->b_x]) { case WALL1: case WALL2: case WALL3: # ifdef REFLECT case WALL4: case WALL5: # endif REFLECT # ifdef RANDOM case DOOR: # endif RANDOM switch (bp->b_face) { case LEFTS: bp->b_x++; break; case RIGHT: bp->b_x--; break; case ABOVE: bp->b_y++; break; case BELOW: bp->b_y--; break; } break; } nbp = (BULLET *) malloc(sizeof (BULLET)); *nbp = *bp; # ifdef VOLCANO moveslime(nbp, nbp->b_type == SLIME ? SLIMESPEED : LAVASPEED); # else VOLCANO moveslime(nbp, SLIMESPEED); # endif VOLCANO } /* * moveslime: * move the given slime shot speed times and add it back if * it hasn't fizzled yet */ moveslime(bp, speed) register BULLET *bp; register int speed; { register int i, j, dirmask, count; register PLAYER *pp; register BULLET *nbp; if (speed == 0) { if (bp->b_charge <= 0) free((char *) bp); else save_bullet(bp); return; } # ifdef VOLCANO showexpl(bp->b_y, bp->b_x, bp->b_type == LAVA ? LAVA : '*'); # else VOLCANO showexpl(bp->b_y, bp->b_x, '*'); # endif VOLCANO switch (Maze[bp->b_y][bp->b_x]) { case LEFTS: case RIGHT: case ABOVE: case BELOW: # ifdef FLY case FLYER: # endif FLY pp = play_at(bp->b_y, bp->b_x); message(pp, "You've been slimed."); checkdam(pp, bp->b_owner, bp->b_score, MINDAM, bp->b_type); break; } if (--bp->b_charge <= 0) { free((char *) bp); return; } dirmask = 0; count = 0; switch (bp->b_face) { case LEFTS: if (!iswall(bp->b_y, bp->b_x - 1)) dirmask |= WEST, count++; if (!iswall(bp->b_y - 1, bp->b_x)) dirmask |= NORTH, count++; if (!iswall(bp->b_y + 1, bp->b_x)) dirmask |= SOUTH, count++; if (dirmask == 0) if (!iswall(bp->b_y, bp->b_x + 1)) dirmask |= EAST, count++; break; case RIGHT: if (!iswall(bp->b_y, bp->b_x + 1)) dirmask |= EAST, count++; if (!iswall(bp->b_y - 1, bp->b_x)) dirmask |= NORTH, count++; if (!iswall(bp->b_y + 1, bp->b_x)) dirmask |= SOUTH, count++; if (dirmask == 0) if (!iswall(bp->b_y, bp->b_x - 1)) dirmask |= WEST, count++; break; case ABOVE: if (!iswall(bp->b_y - 1, bp->b_x)) dirmask |= NORTH, count++; if (!iswall(bp->b_y, bp->b_x - 1)) dirmask |= WEST, count++; if (!iswall(bp->b_y, bp->b_x + 1)) dirmask |= EAST, count++; if (dirmask == 0) if (!iswall(bp->b_y + 1, bp->b_x)) dirmask |= SOUTH, count++; break; case BELOW: if (!iswall(bp->b_y + 1, bp->b_x)) dirmask |= SOUTH, count++; if (!iswall(bp->b_y, bp->b_x - 1)) dirmask |= WEST, count++; if (!iswall(bp->b_y, bp->b_x + 1)) dirmask |= EAST, count++; if (dirmask == 0) if (!iswall(bp->b_y - 1, bp->b_x)) dirmask |= NORTH, count++; break; } if (count == 0) { /* * No place to go. Just sit here for a while and wait * for adjacent squares to clear out. */ save_bullet(bp); return; } if (bp->b_charge < count) { /* Only bp->b_charge paths may be taken */ while (count > bp->b_charge) { if (dirmask & WEST) dirmask &= ~WEST; else if (dirmask & EAST) dirmask &= ~EAST; else if (dirmask & NORTH) dirmask &= ~NORTH; else if (dirmask & SOUTH) dirmask &= ~SOUTH; count--; } } i = bp->b_charge / count; j = bp->b_charge % count; if (dirmask & WEST) { count--; nbp = create_shot(bp->b_type, bp->b_y, bp->b_x - 1, LEFTS, i, bp->b_owner, bp->b_score, TRUE, SPACE); moveslime(nbp, speed - 1); } if (dirmask & EAST) { count--; nbp = create_shot(bp->b_type, bp->b_y, bp->b_x + 1, RIGHT, (count < j) ? i + 1 : i, bp->b_owner, bp->b_score, TRUE, SPACE); moveslime(nbp, speed - 1); } if (dirmask & NORTH) { count--; nbp = create_shot(bp->b_type, bp->b_y - 1, bp->b_x, ABOVE, (count < j) ? i + 1 : i, bp->b_owner, bp->b_score, TRUE, SPACE); moveslime(nbp, speed - 1); } if (dirmask & SOUTH) { count--; nbp = create_shot(bp->b_type, bp->b_y + 1, bp->b_x, BELOW, (count < j) ? i + 1 : i, bp->b_owner, bp->b_score, TRUE, SPACE); moveslime(nbp, speed - 1); } free((char *) bp); } /* * iswall: * returns whether the given location is a wall */ iswall(y, x) register int y, x; { if (y < 0 || x < 0 || y >= HEIGHT || x >= WIDTH) return TRUE; switch (Maze[y][x]) { case WALL1: case WALL2: case WALL3: # ifdef REFLECT case WALL4: case WALL5: # endif REFLECT # ifdef RANDOM case DOOR: # endif RANDOM # ifdef VOLCANO case LAVA: # endif VOLCANO return TRUE; } return FALSE; } # endif OOZE /* * zapshot: * Take a shot out of the air. */ zapshot(blist, obp) register BULLET *blist, *obp; { register BULLET *bp; register FLAG explode; explode = FALSE; for (bp = blist; bp != NULL; bp = bp->b_next) { if (bp->b_x != obp->b_x || bp->b_y != obp->b_y) continue; if (bp->b_face == obp->b_face) continue; explode = TRUE; break; } if (!explode) return; explshot(blist, obp->b_y, obp->b_x); } /* * explshot - * Make all shots at this location blow up */ explshot(blist, y, x) register BULLET *blist; register int y, x; { register BULLET *bp; for (bp = blist; bp != NULL; bp = bp->b_next) if (bp->b_x == x && bp->b_y == y) { bp->b_expl = TRUE; if (bp->b_owner != NULL) message(bp->b_owner, "Shot intercepted"); } } /* * play_at: * Return a pointer to the player at the given location */ PLAYER * play_at(y, x) register int y, x; { register PLAYER *pp; for (pp = Player; pp < End_player; pp++) if (pp->p_x == x && pp->p_y == y) return pp; fprintf(stderr, "driver: couldn't find player at (%d,%d)\n", x, y); abort(); /* NOTREACHED */ } /* * opposite: * Return TRUE if the bullet direction faces the opposite direction * of the player in the maze */ opposite(face, dir) int face; char dir; { switch (face) { case LEFTS: return (dir == RIGHT); case RIGHT: return (dir == LEFTS); case ABOVE: return (dir == BELOW); case BELOW: return (dir == ABOVE); default: return FALSE; } } /* * is_bullet: * Is there a bullet at the given coordinates? If so, return * a pointer to the bullet, otherwise return NULL */ BULLET * is_bullet(y, x) register int y, x; { register BULLET *bp; for (bp = Bullets; bp != NULL; bp = bp->b_next) if (bp->b_y == y && bp->b_x == x) return bp; return NULL; } /* * fixshots: * change the underlying character of the shots at a location * to the given character. */ fixshots(y, x, over) register int y, x; char over; { register BULLET *bp; for (bp = Bullets; bp != NULL; bp = bp->b_next) if (bp->b_y == y && bp->b_x == x) bp->b_over = over; } /* * find_under: * find the underlying character for a bullet when it lands * on another bullet. */ find_under(blist, bp) register BULLET *blist, *bp; { register BULLET *nbp; for (nbp = blist; nbp != NULL; nbp = nbp->b_next) if (bp->b_y == nbp->b_y && bp->b_x == nbp->b_x) { bp->b_over = nbp->b_over; break; } } /* * mark_player: * mark a player as under a shot */ mark_player(bp) register BULLET *bp; { register PLAYER *pp; for (pp = Player; pp < End_player; pp++) if (pp->p_y == bp->b_y && pp->p_x == bp->b_x) { pp->p_undershot = TRUE; break; } } ================================================ FILE: games/hunt/terminal.c ================================================ /* * Hunt * Copyright (c) 1985 Conrad C. Huang, Gregory S. Couch, Kenneth C.R.C. Arnold * San Francisco, California * * Copyright (c) 1985 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ # include "hunt.h" # define TERM_WIDTH 80 /* Assume terminals are 80-char wide */ /* * cgoto: * Move the cursor to the given position on the given player's * terminal. */ cgoto(pp, y, x) register PLAYER *pp; register int y, x; { if (x == pp->p_curx && y == pp->p_cury) return; sendcom(pp, MOVE, y, x); pp->p_cury = y; pp->p_curx = x; } /* * outch: * Put out a single character. */ outch(pp, ch) register PLAYER *pp; char ch; { if (++pp->p_curx >= TERM_WIDTH) { pp->p_curx = 0; pp->p_cury++; } (void) putc(ch, pp->p_output); } /* * outstr: * Put out a string of the given length. */ outstr(pp, str, len) register PLAYER *pp; register char *str; register int len; { pp->p_curx += len; pp->p_cury += (pp->p_curx / TERM_WIDTH); pp->p_curx %= TERM_WIDTH; while (len--) (void) putc(*str++, pp->p_output); } /* * clrscr: * Clear the screen, and reset the current position on the screen. */ clrscr(pp) register PLAYER *pp; { sendcom(pp, CLEAR); pp->p_cury = 0; pp->p_curx = 0; } /* * ce: * Clear to the end of the line */ ce(pp) PLAYER *pp; { sendcom(pp, CLRTOEOL); } /* * ref; * Refresh the screen */ ref(pp) register PLAYER *pp; { sendcom(pp, REFRESH); } /* * sendcom: * Send a command to the given user */ /* VARARGS2 */ sendcom(pp, command, arg1, arg2) register PLAYER *pp; register int command; int arg1, arg2; { (void) putc(command, pp->p_output); switch (command & 0377) { case MOVE: (void) putc(arg1, pp->p_output); (void) putc(arg2, pp->p_output); break; case ADDCH: case READY: (void) putc(arg1, pp->p_output); break; } } ================================================ FILE: games/phantasia/Makefile ================================================ # # Copyright (c) 1980 Regents of the University of California. # All rights reserved. The Berkeley software License Agreement # specifies the terms and conditions for redistribution. # TOPSRC!=cd ../..; pwd include ${TOPSRC}/share/mk/sys.mk CFLAGS += -DPATH=\"${DEST}\" -DWIZARD=\"daemon\" -DUID=1 \ -DRAND=32768.0 -DACCESS=\"r+\" -DENEMY -DBSD42 -O OBJS = main.o func0.o func1.o func2.o fight.o LIBS = -lm -lcurses -ltermcap MAN = phantasia.0 MANSRC = phant.nr all: phantasia $(MAN) phantasia: ${OBJS} ${CC} ${CFLAGS} ${LDFLAGS} -o phantasia.elf ${OBJS} ${LIBS} ${OBJDUMP} -S phantasia.elf > phantasia.dis ${SIZE} phantasia.elf ${ELF2AOUT} phantasia.elf $@ && rm phantasia.elf ${MAN}: ${MANSRC} tbl -TX ${MANSRC} | ${MANROFF} > $@ clean: rm -f *.o *.0 *.elf ${MAN} phantasia setfiles phant.help *.elf *.dis tags *~ install: all ${INSTALL} phantasia ${DESTDIR}/usr/games/ cp ${MAN} ${DESTDIR}/usr/share/man/cat6/ ================================================ FILE: games/phantasia/Makefile-linux ================================================ # Makefile for Phantasia 3.2 (1.2 2.11BSD - 1997/9/22) # # MODIFIED TO COMPILE WITHOUT 'XSTR'. # # To create game: # # 1) Set up a directory where the game and its support files will live. # (It is suggested that the source be kept somewhere else.) # 2) Set up the variables in Makefile to reflect your particular situation. # 3) Check out ok_to_play() at the end of main.c if you want to include # code to restrict access at certain times. # 4) 'make install' and watch it fly. LIBS = -lm -lcurses -ltermcap # DEST is where the program and its support files reside # If this changes then the symbolic link in the 'install' target must change. DEST = /usr/games/lib/phantasia # The following are program constants which are implementation dependent. # # PATH is the same as $DEST. # WIZARD is the login of the one who will clean up things. # UID is the uid of game wizard. # RAND is one more than the largest number generated by rand(). # Possible values for this are: # 32768.0 (for 15 bit rand()) # 65536.0 (for 16 bit rand()) # 2147483648.0 (for 31 bit rand()) # ACCESS is fopen() access to open a file for writing, but no # clearing the file, e.g. "a", or "r+". (Use "r+" if you have it.) # define OK_TO_PLAY to restrict playing access. Also see function ok_to_play() # in main.c, and tailor to your own needs. # define ENEMY to include code for checking of a 'hit list' of resricted # accounts. The list of logins goes in the file 'enemy'. # define BSD41 for 4.1bsd # define BSD42 for 4.2bsd # define USG3 for System III, or similar # define USG5 for System V CFLAGS = -DPATH=\"${DEST}\" \ -DWIZARD=\"daemon\" \ -DUID=1 \ -DRAND=32768.0 \ -DACCESS=\"r+\" \ -DENEMY \ -DBSD42 -O OFILES = main.o func0.o func1.o func2.o fight.o all: phantasia setfiles phant.help phantasia.0 phantasia: ${OFILES} ${CC} ${OFILES} ${LIBS} -o phantasia setfiles: phant.h setfiles.c ${CC} ${CFLAGS} setfiles.c -o setfiles -lm # the flags below on tbl and nroff are to make a line printable version phant.help: phant.nr tbl -TX phant.nr | nroff -man -Ttn300 > phant.help # DO NOT use an absolute pathname in the symbolic link below. Figure out # what the relative path is. install: all phantasia.0 rm -f ${DESTDIR}/usr/games/phantasia ln -s lib/phantasia/phantasia ${DESTDIR}/usr/games/phantasia -mkdir ${DESTDIR}${DEST} cp phantasia monsters phant.help ${DESTDIR}${DEST} chmod 755 ${DESTDIR}${DEST} chmod 4711 ${DESTDIR}${DEST}/phantasia chmod 644 ${DESTDIR}${DEST}/phant.help ./setfiles install -m 444 -o bin -g bin phantasia.0 ${DESTDIR}/usr/share/man/cat6 phantasia.0: phant.nr tbl -TX phant.nr | nroff -man -h -Tascii > phantasia.0 clean: rm -f *.o phantasia phant.help setfiles phantasia.0 ================================================ FILE: games/phantasia/fight.c ================================================ /* * fight.c Phantasia monster fighting routine * * 1.1 (2.11BSD) 1996/10/26 */ /* * The code exists here for fight to the finish. Simply add code to * set 'fgttofin = TRUE' as an option. Everything else is here. */ #include "phant.h" void fight(stat,particular) /* monster fighting routine */ register struct stats *stat; int particular; { bool fghttofin = FALSE, luckout = FALSE; char aline[80]; double monhit, mdamage, sdamage, monspd, maxspd, inflict, monstr, temp, shield; int ch; register int whichm, size, hwmany, lines; struct mstats monster; fghting = changed = TRUE; shield = 0.0; if (setjmp(fightenv) == 2) shield = roll(100 + (stat->mxn + stat->shd)*6.2,3000); hwmany = 0; size = (valhala) ? stat->lvl/5 : circ(stat->x,stat->y); if (particular >= 0) whichm = particular; else if (marsh) whichm = roll(0,15); else if (size > 24) whichm = roll(14,86); else if (size > 15) whichm = roll(0,50) + roll(14,37); else if (size > 8) whichm = roll(0,50) + roll(14,26); else if (size > 3) whichm = roll(14,50); else whichm = roll(14,25); CALL: move(3,0); clrtobot(); move(5,0); lines = 6; callmonster(whichm,size,&monster); if (stat->blind) strcpy(monster.name,"a monster"); ++hwmany; if (monster.typ == 1) /* unicorn */ if (stat->vrg) { printw("You just subdued %s, thanx to the virgin.",monster.name); stat->vrg = FALSE; goto FINISH; } else { printw("You just saw %s running away!",monster.name); goto LEAVE; } if (monster.typ == 2 && stat->typ > 20) { strcpy(monster.name,"Morgoth"); monster.str = rnd()*(stat->mxn + stat->shd)/1.4 + rnd()*(stat->mxn + stat->shd)/1.5; monster.brn = stat->brn; monster.hit = stat->str*30; monster.typ = 23; monster.spd = speed*1.1 + speed*(stat->typ == 90); monster.flk = monster.trs = monster.exp = 0; mvprintw(4,0,"You've encountered %s, Bane of the Council and Valar.",monster.name); } fghttofin = luckout = FALSE; monstr = monster.str; monhit = monster.hit; mdamage = sdamage = 0; monspd = maxspd = monster.spd; *monster.name = toupper(*monster.name); TOP: mvprintw(5,0,"You are being attacked by %s, EXP: %.0f (Size: %d)",monster.name,monster.exp,size); printstats(stat); mvprintw(1,26,"%20.0f",stat->nrg + shield); if (monster.typ == 4 && stat->bls && stat->chm) { mvprintw(6,0,"You just overpowered %s!",monster.name); lines = 7; stat->bls = FALSE; --stat->chm; goto FINISH; } monster.spd = min(monster.spd + 1,maxspd); if (rnd()*monster.spd > rnd()*speed && monster.typ != 4 && monster.typ != 16) { if (monster.typ) switch (monster.typ) /* do special things */ { case 5: /* Leanan-Sidhe */ if (rnd() > 0.25) goto NORMALHIT; inflict = roll(1,(size - 1)/2); inflict = min(stat->str,inflict); mvprintw(lines++,0,"%s sapped %0.f of your strength!",monster.name,inflict); stat->str -= inflict; strength -= inflict; break; case 6: /* Saruman */ if (stat->pal) { mvprintw(lines++,0,"Wormtongue stole your palantir!"); stat->pal = FALSE; } else if (rnd() > 0.2) goto NORMALHIT; else if (rnd() > 0.5) { mvprintw(lines++,0,"%s transformed your gems into gold!",monster.name); stat->gld += stat->gem; stat->gem = 0.0; } else { mvprintw(lines++,0,"%s scrambled your stats!",monster.name); scramble(stat); } break; case 7: /* Thaumaturgist */ if (rnd() > 0.15) goto NORMALHIT; mvprintw(lines++,0,"%s transported you!",monster.name); stat->x += sgn(stat->x)*roll(50*size,250*size); stat->y += sgn(stat->y)*roll(50*size,250*size); goto LEAVE; case 8: /* Balrog */ inflict = roll(10,monster.str); inflict = min(stat->exp,inflict); mvprintw(lines++,0,"%s took away %0.f experience points.",monster.name,inflict); stat->exp -= inflict; break; case 9: /* Vortex */ if (rnd() > 0.2) goto NORMALHIT; inflict = roll(0,7.5*size); inflict = min(stat->man,floor(inflict)); mvprintw(lines++,0,"%s sucked up %.0f of your manna!",monster.name,inflict); stat->man -= inflict; break; case 10: /* Nazgul */ if (rnd() > 0.3) goto NORMALHIT; if (stat->rng.type && stat->rng.type < 10) { mvaddstr(lines++,0,"Will you relinguish your ring ? "); ch = rgetch(); if (toupper(ch) == 'Y') { stat->rng.type = NONE; goto LEAVE; } } mvprintw(lines++,0,"%s neutralized 1/5 of your brain!",monster.name); stat->brn *= 0.8; break; case 11: /* Tiamat */ if (rnd() > 0.6) goto NORMALHIT; mvprintw(lines++,0,"%s took half your gold and gems and flew off.",monster.name); stat->gld = floor(stat->gld/2); stat->gem = floor(stat->gem/2); goto LEAVE; case 12: /* Kobold */ if (rnd() >.7) goto NORMALHIT; mvprintw(lines++,0,"%s stole one gold piece and ran away.",monster.name); stat->gld = max(0,stat->gld-1); goto LEAVE; case 13: /* Shelob */ if (rnd() > 0.5) goto NORMALHIT; mvprintw(lines++,0,"%s has bitten and poisoned you!",monster.name); ++stat->psn; break; case 14: /* Faeries */ if (!stat->hw) goto NORMALHIT; mvprintw(lines++,0,"Your holy water killed it!"); --stat->hw; goto FINISH; case 15: /* Lamprey */ if (rnd() > 0.7) goto NORMALHIT; mvprintw(lines++,0,"%s bit and poisoned you!",monster.name); stat->psn += 0.25; break; case 17: /* Bonnacon */ if (rnd() > 0.1) goto NORMALHIT; mvprintw(lines++,0,"%s farted and scampered off.",monster.name); stat->nrg /= 2; goto LEAVE; case 18: /* Smeagol */ if (rnd() > 0.5 || !stat->rng.type) goto NORMALHIT; mvprintw(lines++,0,"%s tried to steal your ring, ",monster.name); if (rnd() > 0.1) addstr("but was unsuccessful."); else { addstr("and ran away with it!"); stat->rng.type = NONE; goto LEAVE; } break; case 19: /* Succubus */ if (rnd() > 0.3) goto NORMALHIT; inflict = roll(15,size*10); inflict = min(inflict,stat->nrg); mvprintw(lines++,0,"%s sapped %0.f of your energy.",monster.name,inflict); stat->nrg -= inflict; break; case 20: /* Cerberus */ if (rnd() > 0.25) goto NORMALHIT; mvprintw(lines++,0,"%s took all your metal treasures!",monster.name); stat->swd = stat->shd =stat->gld = stat->crn = 0; goto LEAVE; case 21: /* Ungoliant */ if (rnd() > 0.1) goto NORMALHIT; mvprintw(lines++,0,"%s poisoned you, and took one quik.",monster.name); stat->psn += 5; --stat->quk; break; case 22: /* Jabberwock */ if (rnd() > 0.1) goto NORMALHIT; mvprintw(lines++,0,"%s flew away, and left you to contend with one of its friends.",monster.name); whichm = 55 + 22*(rnd() > 0.5); goto CALL; case 24: /* Troll */ if (rnd() > 0.5) goto NORMALHIT; mvprintw(lines++,0,"%s partially regenerated his energy.!",monster.name); monster.hit += floor((monhit*size - monster.hit)/2); monster.str = monstr; mdamage = sdamage = 0; maxspd = monspd; break; case 25: /* wraith */ if (rnd() > 0.3 || stat->blind) goto NORMALHIT; mvprintw(lines++,0,"%s blindeed you!",monster.name); stat->blind = TRUE; break; default: goto NORMALHIT; } else NORMALHIT: { inflict = rnd()*monster.str + 0.5; mvprintw(lines++,0,"%s hit you %.0f times!",monster.name,inflict); SPECIALHIT: if ((shield -= inflict) < 0) { stat->nrg += shield; shield = 0; } } } else { if (fghttofin) goto MELEE; mvaddstr(3,0,"1:Melee 2:Skirmish 3:Evade 4:Spell 5:Nick "); if (!luckout) if (monster.typ == 23) addstr("6:Ally "); else addstr("6:Luckout "); if (stat->rng.type > 0) addstr("7:Use Ring "); else clrtoeol(); ch = gch(stat->rng.type); move(lines = 6,0); clrtobot(); switch (ch) { default: case '1': /* melee */ MELEE: inflict = roll(strength/2 + 5,1.3*strength) + (stat->rng.type < 0 ? strength : 0); mdamage += inflict; monster.str = monstr - mdamage/monhit*monstr/4; goto HITMONSTER; case '2': /* skirmish */ inflict = roll(strength/3 + 3,1.1*strength) + (stat->rng.type < 0 ? strength : 0); sdamage += inflict; maxspd = monspd - sdamage/monhit*monspd/4; goto HITMONSTER; case '3': /* evade */ if ((monster.typ == 4 || monster.typ == 16 || rnd()*speed*stat->brn > rnd()*monster.spd*monster.brn) && (monster.typ != 23)) { mvaddstr(lines++,0,"You got away!"); stat->x += roll(-2,5); stat->y += roll(-2,5); goto LEAVE; } else mvprintw(lines++,0,"%s is still after you!",monster.name); break; case '4': /* spell */ lines = 7; mvaddstr(3,0,"\n\n"); mvaddstr(3,0,"1:All or Nothing"); if (stat->mag >= 3) mvaddstr(3,18,"2:Magic Bolt"); if (stat->mag >= 7) mvaddstr(3,32,"3:Force Field"); if (stat->mag >= 10) mvaddstr(3,47,"4:Transform"); if(stat->mag >= 15) mvaddstr(3,60,"5:Increase Might\n"); if (stat->mag >= 20) mvaddstr(4,0,"6:Invisibility"); if (stat->mag >= 25) mvaddstr(4,18,"7:Transport"); if (stat->mag >= 30) mvaddstr(4,32,"8:Paralyze"); if (stat->typ > 20) mvaddstr(4,52,"9:Specify"); mvaddstr(6,0,"Spell ? "); ch = rgetch(); mvaddstr(3,0,"\n\n"); if (monster.typ == 23 && ch != '4') illspell(); else switch (ch) { case '1': /* all or nothing */ { inflict = (rnd() < 0.25) ? (monster.hit*1.0001 + 1) : 0; if (monster.typ == 4) inflict *= .9; if (stat->man) --stat->man; maxspd *= 2; monspd *= 2; monster.spd = max(1,monster.spd * 2); monstr = monster.str *= 2; goto HITMONSTER; } case '2': /* magic bolt */ if (stat->mag < 3) illspell(); else { do { mvaddstr(6,0,"How much manna for bolt? "); getstring(aline,80); sscanf(aline,"%lf",&temp); } while (temp < 0 || temp > stat->man); stat->man -= floor(temp); inflict = temp*roll(10,sqrt(stat->mag/3.0 + 1.0)); mvaddstr(6,0,"Magic Bolt fired!\n"); if (monster.typ == 4) inflict = 0.0; goto HITMONSTER; } case '5': /* increase might */ { if (stat->mag < 15) illspell(); else if (stat->man < 55) nomanna(); else { stat->man -= 55; strength += (1.2*(stat->str+stat->swd)+5-strength)/2; mvprintw(6,0,"New strength: %.0f\n",strength); } break; } case '3': /* force field */ { if (stat->mag < 7) illspell(); else if (stat->man < 20) nomanna(); else { shield = (stat->mxn + stat->shd)*4.2 + 45; stat->man -= 20; mvaddstr(6,0,"Force Field up.\n"); } break; } case '4': /* transform */ { if (stat->mag < 10) illspell(); else if (stat->man < 35) nomanna(); else { stat->man -= 35; whichm = roll(0,100); goto CALL; } break; } case '6': /* invisible */ { if (stat->mag < 20) illspell(); else if (stat->man < 45) nomanna(); else { stat->man -= 45; speed += (1.2*(stat->quk+stat->quks)+5-speed)/2; mvprintw(6,0,"New quik : %.0f\n",speed); } break; } case '7': /* transport */ { if (stat->mag < 25) illspell(); else if (stat->man < 50) nomanna(); else { stat->man -= 50; if (stat->brn + stat->mag < monster.exp/300*rnd()) { mvaddstr(6,0,"Transport backfired!\n"); stat->x += (250*size*rnd() + 50*size)*sgn(stat->x); stat->y += (250*size*rnd() + 50*size)*sgn(stat->y); goto LEAVE; } else { mvprintw(6,0,"%s is transported.\n",monster.name); monster.trs *= (rnd() > 0.3); goto FINISH; } } break; } case '8': /* paralyze */ { if (stat->mag < 30) illspell(); else if (stat->man < 60) nomanna(); else { stat->man -= 60; if (stat->mag > monster.exp/1000*rnd()) { mvprintw(6,0,"%s is held.\n",monster.name); monster.spd = -2; } else mvaddstr(6,0,"Monster unaffected.\n"); } break; } case '9': /* specify */ { if (stat->typ < 20) illspell(); else if (stat->man < 1000) nomanna(); else { mvaddstr(6,0,"Which monster do you want [0-99] ? "); whichm = inflt(); whichm = max(0,min(99,whichm)); stat->man -= 1000; goto CALL; } break; } } break; case '5': inflict = 1 + stat->swd; stat->exp += floor(monster.exp/10); monster.exp *= 0.92; maxspd += 2; monster.spd = (monster.spd < 0) ? 0 : monster.spd + 2; if (monster.typ == 4) { mvprintw(lines++,0,"You hit %s %.0f times, and made him mad!",monster.name,inflict); stat->quk /= 2; stat->x += sgn(stat->x)*roll(50*size,250*size); stat->y += sgn(stat->y)*roll(50*size,250*size); stat->y += (250*size*rnd() + 50*size)*sgn(stat->y); goto LEAVE; } else goto HITMONSTER; case '6': /* luckout */ if (luckout) mvaddstr(lines++,0,"You already tried that."); else if (monster.typ == 23) if (rnd() < stat->sin/100) { mvprintw(lines++,0,"%s accepted!",monster.name); goto LEAVE; } else { luckout = TRUE; mvaddstr(lines++,0,"Nope, he's not interested."); } else if ((rnd() + .333)*stat->brn < (rnd() + .333)*monster.brn) { luckout = TRUE; mvprintw(lines++,0,"You blew it, %s.",stat->name); } else { mvaddstr(lines++,0,"You made it!"); goto FINISH; } break; case '\014': /* clear screen */ clear(); break; case '7': /* use ring */ if (stat->rng.type > 0) { mvaddstr(lines++,0,"Now using ring."); stat->rng.type = -stat->rng.type; if (abs(stat->rng.type) != DLREG) --stat->rng.duration; goto NORMALHIT; } break; } goto BOT; HITMONSTER: { inflict = floor(inflict); mvprintw(lines++,0,"You hit %s %.0f times!",monster.name,inflict); if ((monster.hit -= inflict) >0) switch (monster.typ) { case 4: /* dark lord */ inflict = stat->nrg + shield +1; goto SPECIALHIT; case 16: /* shrieker */ mvaddstr(lines++,0,"Shreeeek!! You scared it, and it called one of its friends."); paws(lines); whichm = roll(70,30); goto CALL; } else { if (monster.typ == 23) /* morgoth */ mvaddstr(lines++,0,"You have defeated Morgoth, but he may return. . ."); else mvprintw(lines++,0,"You killed it. Good work, %s.",stat->name); goto FINISH; } } } BOT: refresh(); if (lines == 23) { paws(23); move(lines = 6,0); clrtobot(); } if (stat->nrg <= 0) { paws(lines); death(stat); goto LEAVE; } goto TOP; FINISH: stat->exp += monster.exp; if (rnd() < monster.flk/100.0) /* flock monster */ { paws(lines); fghttofin = FALSE; goto CALL; } else if (size > 1 && monster.trs && rnd() > pow(0.6,(double) (hwmany/3 + size/3))) /* this takes # of flocks and size into account */ { paws(lines); treasure(stat,monster.trs,size); } LEAVE: stat->rng.type = abs(stat->rng.type); paws(lines+3); move(4,0); clrtobot(); fghting = FALSE; } ================================================ FILE: games/phantasia/func0.c ================================================ /* * func0.c Phantasia support routines */ #include "phant.h" void treasure(stat,treastyp,size) /* select a treasure */ register struct stats *stat; short treastyp; register int size; { register int which; int ch; double temp, temp2; char aline[35]; FILE *fp; which = roll(1,3); move(3,0); clrtobot(); move(5,0); if (rnd() > 0.65) /* gold and gems */ if (treastyp > 7) /* gems */ { temp = roll(1,(treastyp - 7)*(treastyp - 7)*(size - 1)/4); printw("You have discovered %.0f gems! Will you pick them up ? ",temp); ch = rgetch(); addch('\n'); if (toupper(ch) == 'Y') if (rnd() < treastyp/40 + 0.05) /* cursed */ { addstr("They were cursed!\n"); goto CURSE; } else stat->gem += temp; return; } else /* gold */ { temp = roll(treastyp*10,treastyp*treastyp*10*(size - 1)); printw("You have found %.0f gold pieces. Do you want to pick them up ? ",temp); ch = rgetch(); addch('\n'); if (toupper(ch) == 'Y') if (rnd() < treastyp/35 + 0.04) /* cursed */ { addstr("They were cursed!\n"); goto CURSE; } else { stat->gld += floor(0.9 * temp); fp = fopen(goldfile,"r"); if (fread((char *) &temp2,sizeof(double),1,fp) != 1) /*ignore*/; fclose(fp); fp = fopen(goldfile,"w"); temp2 += floor(temp/10); fwrite((char *) &temp2,sizeof(double),1,fp); fclose(fp); } return; } else /* other treasures */ { addstr("You have found some treasure. Do you want to inspect it ? "); ch = rgetch(); addch('\n'); if (toupper(ch) != 'Y') return; else if (rnd() < 0.08 && treastyp != 4) { addstr("It was cursed!\n"); goto CURSE; } else switch(treastyp) { case 1: switch(which) { case 1: addstr("You've discovered a power booster!\n"); stat->man += roll(size*4,size*30); break; case 2: addstr("You have encountered a druid.\n"); stat->exp += roll(0,2000 + size*400); break; case 3: addstr("You have found a holy orb.\n"); stat->sin = max(0,stat->sin - 0.25); break; } break; case 2: switch (which) { case 1: addstr("You have found an amulet.\n"); ++stat->amu; break; case 2: addstr("You've found some holy water!\n"); ++stat->hw; break; case 3: addstr("You've met a hermit!\n"); stat->sin *= 0.75; stat->man += 12*size; break; } break; case 3: switch (which) { case 1: temp = roll(7,30 + size/10); printw("You've found a +%.0f shield!\n",temp); if (temp >= stat->shd) stat->shd = temp; else somebetter(); break; case 2: addstr("You have rescued a virgin. Will you be honorable ? "); ch = rgetch(); if (toupper(ch) == 'Y') stat->vrg = TRUE; else { stat->exp += 2000*size; ++stat->sin; } break; case 3: addstr("You've discovered some athelas!\n"); --stat->psn; break; } break; case 4: addstr("You've found a scroll. Will you read it ? "); ch = rgetch(); addch('\n'); if (toupper(ch) == 'Y') switch ((int) roll(1,6)) { case 1: addstr("It throws up a shield for you next monster.\n"); paws(8); longjmp(fightenv,2); /*NOTREACHED*/ case 2: addstr("It makes you invisible for you next monster.\n"); paws(8); speed = 1e6; longjmp(fightenv,0); /*NOTREACHED*/ case 3: addstr("It increases your strength ten fold to fight your next monster.\n"); paws(8); strength *= 10; longjmp(fightenv,0); /*NOTREACHED*/ case 4: addstr("It is a general knowledge scroll.\n"); stat->brn += roll(2,size); stat->mag += roll(1,size/2); break; case 5: addstr("It tells you how to pick your next monster.\n"); addstr("Which monster do you want [0-99] ? "); which = inflt(); which = min(99,max(0,which)); fight(stat,which); break; case 6: addstr("It was cursed!\n"); goto CURSE; } break; case 5: switch (which) { case 1: temp = roll(size/4+5,size/2 + 9); printw("You've discovered a +%.0f dagger.\n",temp); if (temp >= stat->swd) stat->swd = temp; else somebetter(); break; case 2: temp = roll(7.5 + size*3,size * 2 + 160); printw("You have found some +%.0f armour!\n",temp); if (temp >= stat->shd) stat->shd = temp; else somebetter(); break; case 3: addstr("You've found a tablet.\n"); stat->brn += 4.5*size; break; } break; case 6: switch (which) { case 1: addstr("You've found a priest.\n"); stat->nrg = stat->mxn + stat->shd; stat->sin /= 2; stat->man += 24*size; stat->brn += size; break; case 2: addstr("You have come upon Robin Hood!\n"); stat->shd += size*2; stat->str += size/2.5 + 1; break; case 3: temp = roll(2 + size/4,size/1.2 + 10); printw("You have found a +%.0f axe!\n",temp); if (temp >= stat->swd) stat->swd = temp; else somebetter(); break; } break; case 7: switch (which) { case 1: addstr("You've discovered a charm!\n"); ++stat->chm; break; case 2: addstr("You have encountered Merlyn!\n"); stat->brn += size + 5; stat->mag += size/3 + 5; stat->man += size*10; break; case 3: temp = roll(5+size/3,size/1.5 + 20); printw("You have found a +%.0f war hammer!\n",temp); if (temp >= stat->swd) stat->swd = temp; else somebetter(); break; } break; case 8: switch (which) { case 1: addstr("You have found a healing potion.\n"); stat->psn = min(-2,stat->psn-2); break; case 2: addstr("You have discovered a transporter. Do you wish to go anywhere ? "); ch = rgetch(); addch('\n'); if (toupper(ch) == 'Y') { addstr("X Y Coordinates ? "); getstring(aline,80); sscanf(aline,"%lf %lf",&stat->x,&stat->y); stat->x = floor(stat->x); stat->y = floor(stat->y); } break; case 3: temp = roll(10 + size/1.2,size*3 + 30); printw("You've found a +%.0f sword!\n",temp); if (temp >= stat->swd) stat->swd = temp; else somebetter(); break; } break; case 10: case 11: case 12: case 13: if (rnd() < 0.33) { if (treastyp == 10) { addstr("You've found a pair of elven boots!\n"); stat->quk += 2; break; } else if (treastyp == 11 && !stat->pal) { addstr("You've acquired Saruman's palantir.\n"); stat->pal = TRUE; break; } else if (!stat->rng.type && stat->typ < 20 && (treastyp == 12 || treastyp == 13)) { if (treastyp == 12) if (rnd() < 0.8) { which = NAZREG; temp = 15; } else { which = NAZBAD; temp = 10 + rngcalc(stat->typ) + roll(0,5); } else if (rnd() > 0.9) { which = DLREG; temp = 0; } else { which = DLBAD; temp = 15 + rngcalc(stat->typ) + roll(0,5); } addstr("You've discovered a ring. Will you pick it up ? "); ch = rgetch(); addch('\n'); if (toupper(ch) == 'Y') { stat->rng.type = which; stat->rng.duration = temp; } } break; } case 9: switch (which) { case 1: if (!(stat->lvl > 1000 || stat->crn > floor((double) stat->lvl/100) || stat->lvl < 10)) { addstr("You have found a golden crown!\n"); ++stat->crn; break; } case 2: addstr("You've been blessed!\n"); stat->bls = TRUE; stat->sin /=3; stat->nrg = stat->mxn + stat->shd; stat->man += 100*size; break; case 3: temp = roll(1,size/5+5); temp = min(temp,99); printw("You have discovered some +%.0f quicksilver!\n",temp); if (temp >= stat->quks) stat->quks = temp; else somebetter(); break; } break; } refresh(); return; } CURSE: if (stat->chm) { addstr("But your charm saved you!\n"); --stat->chm; } else if (stat->amu) { addstr("But your amulet saved you!\n"); --stat->amu; } else { stat->nrg = (stat->mxn + stat->shd)/10; stat->psn += 0.25; } } void callmonster(which,size,mons) /* fill a structure with monster 'which' of size 'size' */ register int which, size; register struct mstats *mons; { FILE *fp; char instr[100]; which = min(which,99); fp = fopen(monsterfile,"r"); for (++which; which; --which) { if (fgets(instr,100,fp) == 0) /*ignore*/; } strncpy(mons->name,instr,24); mons->name[24] = '\0'; sscanf(instr + 24,"%lf%lf%lf%lf%lf%d%d%d",&mons->str,&mons->brn,&mons->spd,&mons->hit, &mons->exp,&mons->trs,&mons->typ,&mons->flk); if (mons->typ == 2) /* Modnar */ { mons->str *= rnd() + 0.5; mons->brn *= rnd() + 0.5; mons->spd *= rnd() + 0.5; mons->hit *= rnd() + 0.5; mons->exp *= rnd() + 0.5; mons->trs *= rnd(); } else if (mons->typ == 3) /* mimic */ { fseek(fp,0L,0); for (which = roll(0,100); which; --which) { if (fgets(instr,100,fp) == 0) /*ignore*/; } strncpy(mons->name,instr,24); } strunc(mons->name); mons->str += (size-1)*mons->str/2; mons->brn *= size; mons->spd += size * 1.e-9; mons->hit *= size; mons->exp *= size; fclose(fp); } struct /* lookup table for rolling stats and making increases upon gaining levels */ { struct { int base; int interval; float increase; } quick, strength, manna, energy, brains, magic; } table[7] = { /* mag. usr: */ 30, 6, 0.0, 20, 6, 2.0, 50,51,75.0, 30,16,20.0, 60,26, 6.0, 5, 5,2.75, /* fighter: */ 30, 6, 0.0, 40,16, 3.0, 30,21,40.0, 45,26,30.0, 25,21, 3.0, 3, 4, 1.5, /* elf: */ 32, 7, 0.0, 35,11, 2.5, 45,46,65.0, 30,21,25.0, 40,26, 4.0, 4, 4, 2.0, /* dwarf: */ 25, 6, 0.0, 45,21, 5.0, 25,21,30.0, 60,41,35.0, 20,21, 2.5, 2, 4, 1.0, /* halfling: */ 34, 0, 0.0, 20, 6, 2.0, 25,21,30.0, 55,36,30.0, 40,36, 4.5, 1, 4, 1.0, /* exprmnto: */ 27, 0, 0.0, 25, 0, 0.0, 100,0, 0.0, 35, 0, 0.0, 25, 0, 0.0, 2, 0, 0.0, /* super: */ 38, 0, 0.0, 65, 0, 0.0, 100,0, 0.0, 80, 0, 0.0, 85, 0, 0.0, 9, 0, 0.0 }; void genchar(res,type) /* init a charac struct */ int type; register struct stats *res; { register int subscript; if (type < '1' || type > '6') if (type != '7' || !su) type = '2'; /* fighter is default */ subscript = type - '1'; res->quk = roll(table[subscript].quick.base,table[subscript].quick.interval); res->str = roll(table[subscript].strength.base,table[subscript].strength.interval); res->man = roll(table[subscript].manna.base,table[subscript].manna.interval); res->mxn = res->nrg = roll(table[subscript].energy.base,table[subscript].energy.interval); res->brn = roll(table[subscript].brains.base,table[subscript].brains.interval); res->mag = roll(table[subscript].magic.base,table[subscript].magic.interval); res->typ = subscript; if (subscript < 6) ++res->typ; if (type == '5') res->exp = roll(600,200); /* give halfling some exp. */ } void movelvl(stat) /* update stats for new level */ register struct stats *stat; { register int type; register unsigned new; double inc; changed = TRUE; type = abs(stat->typ); if (type < 6) ; /* normal */ else if (type < 10) type = roll(1,5); /* experimento */ else if (type < 20) { type -= 10; /* king */ if (type > 5) type = roll(1,5); /* experimento */ } else if (type < 26) type -= 20; /* council of wise */ else type = roll(1,5); /* everything else */ new = level(stat->exp); inc = new - stat->lvl; --type; /* set up for subscripting into table */ stat->str += table[type].strength.increase * inc; stat->man += table[type].manna.increase * inc; stat->brn += table[type].brains.increase * inc; stat->mag += table[type].magic.increase * inc; stat->mxn += table[type].energy.increase * inc; stat->nrg = stat->mxn + stat->shd; if ((stat->lvl = min(10000,new)) >= 1000) { /* no longer able to be king */ stat->gld += stat->crn * 5000; stat->crn = 0; stat->typ = abs(stat->typ); } if (stat->lvl >= 3000 && stat->typ < 20) { /* make a member of the council */ mvaddstr(6,0,"You have made it to the Council of the Wise.\nGood Luck on your search for the Holy Grail.\n"); stat->rng.type = 0; stat->rng.duration = 3; stat->typ = abs(stat->typ) + (stat->typ > 10 ? 10 :20); } } char *printloc(x,y) /* return a pointer to a string specifying location */ double x,y; /* also, set some global flags */ { register int size, loc; register char *label; static char res[80], *nametable[4][4] = /* names of places */ { "Anorien", "Ithilien", "Rohan", "Lorien", "Gondor", "Mordor", "Dunland", "Rovanion", "South Gondor", "Khand", "Eriador", "The Iron Hills", "Far Harad", "Near Harad", "The Northern Waste", "Rhun" }; throne = beyond = marsh = FALSE; if (wmhl) return (strcpy(res," is in the Wormholes")); else if (valhala) return (strcpy(res," is in Valhala")); else if ((size = circ(x,y)) >= 1000) { if (max(abs(x),abs(y)) > 1100000) { label = "The Point of No Return"; beyond = TRUE; } else label = "The Ashen Mountains"; } else if (size >= 55) label = "Morannon"; else if (size >= 35) label = "Kennaquahair"; else if (size >= 20) { label = "The Dead Marshes"; marsh = TRUE; } else if (size >= 9) label = "The Outer Waste"; else if (size >= 5) label = "The Moors Adventurous"; else { if (!x && !y) { label = "The Lord's Chamber"; throne = TRUE; } else { loc = (x > 0) + 2 * (y >= 0); label = nametable[size-1][loc]; } } sprintf(res," is in %s (%.0f,%.0f)",label,x,y); return (res); } void initchar(stat) /* put in some default values */ register struct stats *stat; { stat->x = roll(-125,251); stat->y = roll(-125,251); stat->exp = stat->lvl = stat->sin = 0; stat->crn = stat->psn = 0; stat->rng.type = NONE; stat->rng.duration = 0; stat->blind = stat->vrg = stat->pal = FALSE; stat->hw = stat->amu = stat->bls = 0; stat->chm = 0; stat->gem = 0.1; stat->gld = roll(25,50) + roll(0,25) + 0.1; stat->quks = stat->swd = stat->shd = 0; stat->typ = 0; stat->status = stat->tampered = OFF; stat->scratch1 = stat->scratch2 = 0.0; stat->wormhole = 0; stat->age = 0; stat->degen = 1; } void trade(stat) /* trading post */ register struct stats *stat; { static struct { char *item; int cost; } menu[] = { "Manna",1, "Shield",5, "Book",200, "Sword",500, "Charm",1000, "Quiksilver",2500, "Blessing",7000, "Gem",1000 /* this is only to ease changing the value of gems */ }; double temp; int ch; register int size, loop; bool cheat = FALSE; changed = TRUE; clear(); addstr("You are at a trading post. All purchases must be made with gold."); size = sqrt(abs(stat->x/100)) + 1; size = min(7,size); mvprintw(4,0,"L:Leave P:Purchase S:Sell Gems ? "); move(6,0); for (loop = 0; loop < size; ++loop) printw("(%d) %-10s: %6d\n",loop+1,menu[loop].item,menu[loop].cost); PROMPT: mvprintw(1,0,"Gold: %9.0f Gems: %9.0f Level: %6u Charms: %6d\n",stat->gld,stat->gem,stat->lvl,stat->chm); printw("Shield:%9.0f Sword: %9.0f Quicksilver:%3d Blessed: %s", stat->shd,stat->swd,stat->quks,(stat->bls ? " True" : "False")); move(4,36); ch = rgetch(); move(15,0); clrtobot(); switch(toupper(ch)) { case 'L': case '\n': stat->x -= floor(stat->x/10); stat->y -= floor(stat->y/10); return; case 'P': mvaddstr(15,0,"What what would you like to buy ? "); ch = rgetch(); move(15,0); clrtoeol(); if (ch - '0' > size) addstr("Sorry, this merchant doesn't have that."); else switch (toupper(ch)) { case '1': printw("Manna is one per %d gold piece. How many do you want (%.0f max) ? ",menu[0].cost,floor(stat->gld/menu[0].cost)); temp = inflt(); if (temp * menu[0].cost > stat->gld || temp < 0) goto CHEAT; else { stat->gld -= floor(temp) * menu[0].cost; if (rnd() < 0.02) goto DISHON; else stat->man += floor(temp); } break; case '2': printw("Shields are %d per +1. How many do you want (%.0f max) ? ",menu[1].cost,floor(stat->gld/menu[1].cost)); temp = inflt(); if (!temp) break; if (temp * menu[1].cost > stat->gld || temp < 0) goto CHEAT; else { stat->gld -= floor(temp) * menu[1].cost; if (rnd() < 0.02) goto DISHON; else stat->shd = floor(temp); } break; case '3': printw("A book costs %d gp. How many do you want (%.0f max) ? ",menu[2].cost,floor(stat->gld/menu[2].cost)); temp = inflt(); if (temp * menu[2].cost > stat->gld || temp < 0) goto CHEAT; else { stat->gld -= floor(temp) * menu[2].cost; if (rnd() < 0.02) goto DISHON; else if (rnd()*temp > stat->lvl/10 && temp != 1) { printw("\nYou blew your mind!\n"); stat->brn /= 5; } else stat->brn += floor(temp)*roll(25,10); } break; case '4': printw("Swords are %d gp per +1. How many + do you want (%.0f max) ? ",menu[3].cost,floor(stat->gld/menu[3].cost)); temp = inflt(); if (!temp) break; if (temp * menu[3].cost > stat->gld || temp < 0) goto CHEAT; else { stat->gld -= floor(temp) * menu[3].cost; if (rnd() < 0.02) goto DISHON; else stat->swd = floor(temp); } break; case '5': printw("A charm costs %d gp. How many do you want (%.0f max) ? ",menu[4].cost,floor(stat->gld/menu[4].cost)); temp = inflt(); if (temp * menu[4].cost > stat->gld || temp < 0) goto CHEAT; else { stat->gld -= floor(temp) * menu[4].cost; if (rnd() < 0.02) goto DISHON; else stat->chm += floor(temp); } break; case '6': printw("Quicksilver is %d gp per +1. How many + do you want (%.0f max) ? ",menu[5].cost,floor(stat->gld/menu[5].cost)); temp = inflt(); if (!temp) break; if (temp * menu[5].cost > stat->gld || temp < 0) goto CHEAT; else { stat->gld -= floor(temp) * menu[5].cost; if (rnd() < 0.02) goto DISHON; else stat->quks = min(99,floor(temp)); } break; case '7': printw("A blessing requires a %d gp donation. Still want one ? ",menu[6].cost); ch = rgetch(); if (toupper(ch) == 'Y') if (stat->gld < menu[6].cost) goto CHEAT; else { stat->gld -= menu[6].cost; if (rnd() < 0.02) goto DISHON; else stat->bls = TRUE; } break; } break; case 'S': mvprintw(15,0,"A gem is worth %d gp. How many do you want to sell (%.0f max) ? ",menu[7].cost,stat->gem); temp = inflt(); if (temp > stat->gem || temp < 0) goto CHEAT; else { stat->gem -= floor(temp); stat->gld += floor(temp) * menu[7].cost; } } goto PROMPT; CHEAT: move(17,0); if (!cheat) { addstr("Come on, merchants aren't stupid. Stop cheating.\n"); cheat = TRUE; goto PROMPT; } else { addstr("You had your chance. This merchant happens to be\n"); printw("a %.0f level magic user, and you made %s mad!\n",roll(size*10,size*20),(rnd() < 0.5) ? "him" : "her"); stat->x += roll(-250,500)*size; stat->y += roll(-250,500)*size; stat->nrg = min(size*20,stat->mxn); ++stat->sin; paws(23); } return; DISHON: mvaddstr(17,0,"The merchant stole your money!"); refresh(); stat->x -= floor(stat->x/10); stat->y -= floor(stat->y/10); sleep(2); } void printstats(stat) /* show characteristics */ register struct stats *stat; { mvprintw(0,0,"%s%s\n",stat->name,printloc(stat->x,stat->y)); mvprintw(1,0,"Level :%7u Energy :%9.0f(%9.0f) Manna:%9.0f Users:%3d\n", stat->lvl,stat->nrg,stat->mxn + stat->shd,stat->man,users); mvprintw(2,0,"Quick :%3.0f(%3d) Strength:%9.0f(%9.0f) Gold :%9.0f ", speed,stat->quk + stat->quks,strength,stat->str + stat->swd,stat->gld); switch (stat->status) { case PLAYING: if (stat->nrg < 0.2 * (stat->mxn + stat->shd)) addstr("Low Energy\n"); else if (stat->blind) addstr("Blind\n"); else clrtoeol(); break; case CLOAKED: addstr("Cloaked\n"); break; case INBATTLE: addstr("In Battle\n"); break; case OFF: addstr("Off\n"); } } void showall(stat) /* show special items */ register struct stats *stat; { static char *flags[] = { "False", " True" }; mvprintw(6,0,"Type: %3d -- ",stat->typ); switch (abs(stat->typ)) { case 1: case 11: case 21: addstr("Magic User"); break; case 2: case 12: case 22: addstr("Fighter"); break; case 3: case 13: case 23: addstr("Elf"); break; case 4: case 14: case 24: addstr("Dwarf"); break; case 5: case 15: case 25: addstr("Halfling"); break; case 6: case 16: case 26: addstr("Experimento"); break; case 90: addstr("Ex-Valar"); break; case 99: addstr("Valar"); } if (stat->typ > 10 && stat->typ < 90) if (stat->typ > 20) addstr(" (Council of Wise)"); else addstr(" (King)"); addch('\n'); mvprintw(7,0,"Experience: %9.0f",stat->exp); mvprintw(8,0,"Brains : %9.0f",stat->brn); mvprintw(9,0,"Magic Lvl : %9.0f",stat->mag); mvprintw(10,0,"Sin : %9.5f",stat->sin); mvprintw(11,0,"Poison : %9.5f",stat->psn); mvprintw(12,0,"Gems : %9.0f",stat->gem); mvprintw(13,0,"Age : %9d",stat->age); mvprintw(7,40,"Holy Water: %9d",stat->hw); mvprintw(8,40,"Amulets : %9d",stat->amu); mvprintw(9,40,"Charms : %9d",stat->chm); mvprintw(10,40,"Crowns : %9d",stat->crn); mvprintw(11,40,"Shield : %9.0f",stat->shd); mvprintw(12,40,"Sword : %9.0f",stat->swd); mvprintw(13,40,"Quickslver: %9d",stat->quks); mvprintw(14,0,"Blessing: %s Ring: %s Virgin: %s Palantir: %s", flags[stat->bls],flags[stat->rng.type != 0],flags[stat->vrg],flags[stat->pal]); } void neatstuff(stat) /* random things */ register struct stats *stat; { double temp; int ch; switch ((int) roll(0,100)) { case 1: case 2: if (stat->psn > 0) { mvaddstr(5,0,"You've found a medic! How much will you offer to be cured ? "); temp = inflt(); if (temp < 0 || temp > stat->gld) { mvaddstr(6,0,"He was not amused, and made you worse.\n"); ++stat->psn; } else if (rnd()/2.0 > (temp + 1)/max(stat->gld,1)) mvaddstr(6,0,"Sorry, he wasn't interested.\n"); else { mvaddstr(6,0,"He accepted."); stat->psn = max(0,stat->psn-1); stat->gld -= floor(temp); } } break; case 3: mvaddstr(6,0,"You've been caught raping and pillaging!\n"); stat->exp += 4000; stat->sin += 0.5; break; case 4: temp = roll(6,50); mvprintw(5,0,"You've found %.0f gold pieces, want them ? ",temp); clrtoeol(); ch = rgetch(); if (toupper(ch) == 'Y') stat->gld += temp; break; case 5: if (stat->sin > 1) { mvaddstr(6,0,"You've found a Holy Orb!\n"); stat->sin -= 0.25; } break; case 6: if (stat->psn < 1) { mvaddstr(6,0,"You've been hit with a plague!\n"); ++stat->psn; } break; case 7: mvaddstr(6,0,"You've found some holy water.\n"); ++stat->hw; break; case 8: mvaddstr(6,0,"You've met a Guru. . ."); if (rnd()*stat->sin > 1) addstr("You disgusted him with your sins!\n"); else if (stat->psn > 0) { addstr("He looked kindly upon you, and cured you.\n"); stat->psn = 0; } else { addstr("He rewarded you for your virtue.\n"); stat->man += 50; stat->shd += 2; } break; case 9: mvaddstr(6,0,"You've found an amulet.\n"); ++stat->amu; break; case 10: if (stat->blind) { mvaddstr(6,0,"You've regained your sight!\n"); stat->blind = FALSE; } break; default: if (stat->psn > 0) stat->nrg -= min(stat->psn*stat->mxn/45,0.9*stat->mxn); stat->nrg = max(stat->nrg,floor(stat->mxn/11)); } } ================================================ FILE: games/phantasia/func1.c ================================================ /* * func1.c Phantasia support routines */ #include "phant.h" bool findname(name) /* return TRUE if name in use */ register char *name; { FILE *fp; struct stats buf; fp = fopen(peoplefile,"r"); while (fread((char *) &buf,sizeof(buf),1,fp)) if (!strcmp(buf.name,name)) { fclose(fp); mvaddstr(21,0,"Name already in use.\n"); refresh(); return (TRUE); } fclose(fp); return (FALSE); } int findspace() /* allocate space for a character in peoplefile */ { FILE *fp; struct stats buf; register int loc; loc = 0; fp = fopen(peoplefile,"r"); while (fread((char *) &buf,sizeof(buf),1,fp)) { if (!strcmp(buf.name,"")) { fclose(fp); return (loc); } else ++loc; } fclose(fp); fp = fopen(peoplefile,ACCESS); fseek(fp,(long) loc * sizeof(buf),0); initchar(&buf); strcpy(buf.name,"inuse"); fwrite((char *) &buf,sizeof(buf),1,fp); fclose(fp); return (loc); } int findchar(stat) /* retrieve a character from file */ register struct stats *stat; { register int loc = 0, loop; char name[21]; FILE *fp; if (fp = fopen(peoplefile,"r")) { clear(); mvprintw(10,0,"What was your character's name ? "); getstring(name,21); strunc(name); while (fread((char *) stat,sizeof(*stat),1,fp)) { if (!strcmp(stat->name,name)) { move(11,0); refresh(); fclose(fp); nocrmode(); for (loop = 0; loop < 2; ++loop) if (!strcmp(getpass("Password ? "),stat->pswd)) { crmode(); return (loc); } else printf("No good.\n"); exit1(); /*NOTREACHED*/ } ++loc; } } fclose(fp); addstr("\n\nNot found.\n"); exit1(); /*NOTREACHED*/ } void leave(stat) /* save character in file */ register struct stats *stat; { long ltemp; if (!stat->lvl) strcpy(stat->name,""); stat->status = OFF; time(<emp); stat->age += ltemp - secs; update(stat,fileloc); exit1(); /*NOTREACHED*/ } void talk(name) /* send message to all players */ register char *name; { FILE *fp; char aline[160]; mvaddstr(5,0,"Message ? "); getstring(aline,160); fp = fopen(messfile,"w"); if (*aline) fprintf(fp,"%s: %s",name,aline); fclose(fp); } void death(stat) /* remove a player after dying */ register struct stats *stat; { FILE *fp; char aline[100]; int ch; register int loop; long ltemp; clear(); if (stat->typ == 99) if (stat->rng.duration) { addstr("Valar should be more cautious. You've been killed.\n"); printw("You only have %d more chance(s).\n",--stat->rng.duration); paws(3); stat->nrg = stat->mxn; return; } else { addstr("You had your chances, but Valar aren't totally\n"); addstr("immortal. You are now left to wither and die . . .\n"); paws(3); stat->brn = stat->lvl /25; stat->nrg = stat->mxn; stat->quks = stat->swd = 0; stat->typ = 90; return; } if (stat->lvl > 9999) addstr("Characters greater than level 10K must be retired. Sorry."); switch(stat->rng.type) { case -DLREG: case -NAZREG: mvaddstr(4,0,"Your ring saved you from death!\n"); refresh(); stat->rng.type = NONE; stat->nrg = stat->mxn/12+1; stat->crn -= (stat->crn > 0); return; case DLBAD: case -DLBAD: case NAZBAD: case -NAZBAD: case -SPOILED: case SPOILED: mvaddstr(4,0,"Your ring has taken control of you and turned you into a monster!\n"); fp = fopen(monsterfile,"r"); for (loop = 0; loop <= 13; ++loop) { if (! fgets(aline,100,fp)) /*ignore*/; } ltemp = ftell(fp); fclose(fp); fp = fopen(monsterfile,ACCESS); fseek(fp,ltemp,0); fprintf(fp,"%-20s",stat->name); fclose(fp); } initchar(stat); fp = fopen(lastdead,"w"); fprintf(fp,"%s Login: %s",stat->name,stat->login); fclose(fp); strcpy(stat->name,""); update(stat,fileloc); clear(); move(10,0); switch ((int) roll(1,5)) { case 1: addstr("You've crapped out! "); break; case 2: addstr("You have been disemboweled. "); break; case 3: addstr("You've been mashed, mauled, and spit upon. (You're dead.)\n"); break; case 4: addstr("You died! "); break; case 5: addstr("You're a complete failure -- you've died!!\n"); } addstr("Care to give it another try ? "); ch = rgetch(); if (toupper(ch) == 'Y') { endwin(); execl(gameprog, "phantasia", "-s", (char*)0); } exit1(); /*NOTREACHED*/ } void update(stat,place) /* update charac file */ register struct stats *stat; register int place; { FILE *fp; fp = fopen(peoplefile,ACCESS); fseek(fp,(long) place*sizeof(*stat),0); fwrite((char *) stat,sizeof(*stat),1,fp); fclose(fp); } void printplayers(stat) /* show users */ register struct stats *stat; { FILE *fp; struct stats buf; register int loop = 0; double loc; long ltmp; int ch; if (stat->blind) { mvaddstr(6,0,"You can't see anyone.\n"); return; } loc = circ(stat->x,stat->y); mvaddstr(6,0,"Name X Y Lvl Type Login\n"); fp = fopen(peoplefile,"r"); while (fread((char *) &buf,sizeof(buf),1,fp)) { if (buf.status) { ch = (buf.status == CLOAKED) ? '?' : 'W'; if (stat->typ > 10 || buf.typ > 10 || loc >= circ(buf.x,buf.y) || stat->pal) if (buf.status != CLOAKED || (stat->typ == 99 && stat->pal)) if (buf.typ == 99) addstr("The Valar is watching you. . .\n"); else if (buf.wormhole) printw("%-20s %c %c %6u %3d %-9s\n", buf.name,ch,ch,buf.lvl,buf.typ,buf.login); else printw("%-20s %8.0f %8.0f %6u %3d %-9s\n", buf.name,buf.x,buf.y,buf.lvl,buf.typ,buf.login); else if (buf.typ == 99) --loop; else printw("%-20s ? ? %6u %3d %-9s\n", buf.name,buf.lvl,buf.typ,buf.login); ++loop; } } fclose(fp); time(<mp); printw("Total users = %d %s\n",loop,ctime(<mp)); refresh(); } void printhelp() /* print help file */ { FILE *fp; char instr[100]; fp = fopen(helpfile,"r"); while (fgets(instr,100,fp)) fputs(instr,stdout); fclose(fp); } void titlestuff() /* print out a header */ { FILE *fp; char instr[80], hiname[21], nxtname[21], aline[80]; bool cowfound = FALSE, kingfound = FALSE; struct stats buf; double hiexp, nxtexp; unsigned hilvl, nxtlvl; register int loop; mvaddstr(0,15,"W e l c o m e t o P h a n t a s i a (vers. 3.2)!"); fp = fopen(motd,"r"); if (fgets(instr,80,fp)) mvaddstr(2,40 - strlen(instr)/2,instr); fclose(fp); fp = fopen(peoplefile,"r"); while (fread((char *) &buf,sizeof(buf),1,fp)) if (buf.typ > 10 && buf.typ < 20) { sprintf(instr,"The present ruler is %s Level:%d",buf.name,buf.lvl); mvaddstr(4,40 - strlen(instr)/2,instr); kingfound = TRUE; break; } if (!kingfound) mvaddstr(4,24,"There is no ruler at this time."); fseek(fp,0L,0); while (fread((char *) &buf,sizeof(buf),1,fp)) if (buf.typ == 99) { sprintf(instr,"The Valar is %s Login: %s",buf.name,buf.login); mvaddstr(6,40 - strlen(instr)/2,instr); break; } fseek(fp,0L,0); while (fread((char *) &buf,sizeof(buf),1,fp)) if (buf.typ > 20 && buf.typ < 90) { if (!cowfound) { mvaddstr(8,30,"Council of the Wise:"); loop = 10; cowfound = TRUE; } /* This assumes a finite (<=7) number of C.O.W.: */ sprintf(instr,"%s Login: %s",buf.name,buf.login); mvaddstr(loop++,40 - strlen(instr)/2,instr); } fseek(fp,0L,0); *nxtname = *hiname = '\0'; hiexp = 0.0; nxtlvl = hilvl = 0; while (fread((char *) &buf,sizeof(buf),1,fp)) if (buf.exp > hiexp && buf.typ < 20) { nxtexp = hiexp; hiexp = buf.exp; nxtlvl = hilvl; hilvl = buf.lvl; strcpy(nxtname,hiname); strcpy(hiname,buf.name); } else if (buf.exp > nxtexp && buf.typ < 20) { nxtexp = buf.exp; nxtlvl = buf.lvl; strcpy(nxtname,buf.name); } fclose(fp); mvaddstr(17,28,"Highest characters are:"); sprintf(instr,"%s Level:%d and %s Level:%d",hiname,hilvl,nxtname,nxtlvl); mvaddstr(19,40 - strlen(instr)/2,instr); fp = fopen(lastdead,"r"); if (! fgets(aline,80,fp)) /*ignore*/; sprintf(instr,"The last character to die is %s",aline); mvaddstr(21,40 - strlen(instr)/2,instr); fclose(fp); refresh(); } void printmonster() /* do a monster list on the terminal */ { FILE *fp; register int count = 0; char instr[100]; puts(" # Name Str Brains Quick Hits Exp Treas Type Flock%\n"); fp = fopen(monsterfile,"r"); while (fgets(instr,100,fp)) printf("%2d %s",count++,instr); fclose(fp); } void exit1() /* exit, but cleanup */ { move(23,0); refresh(); nocrmode(); endwin(); exit(0); /*NOTREACHED*/ } void init1() /* set up for screen updating */ { /* catch/ingnore signals */ signal(SIGQUIT,SIG_IGN); signal(SIGALRM,SIG_IGN); signal(SIGTERM,SIG_IGN); signal(SIGTSTP,SIG_IGN); signal(SIGTTIN,SIG_IGN); signal(SIGTTOU,SIG_IGN); signal(SIGINT,SIG_IGN); srand((unsigned) time((long *) NULL)); /* prime random numbers */ initscr(); noecho(); crmode(); clear(); refresh(); } void getstring(cp,mx) /* get a string from the stdscr at current y,x */ register char *cp; register int mx; { register int loop = 0, x, y, xorig; int ch; getyx(stdscr,y,xorig); clrtoeol(); refresh(); while((ch = getch()) != '\n' && loop < mx - 1) switch (ch) { case '\033': /* escape */ case '\010': /* backspace */ if (loop) { --loop; getyx(stdscr,y,x); mvaddch(y,x-1,' '); move(y,x-1); refresh(); } break; case '\030': /* ctrl-x */ loop = 0; move(y,xorig); clrtoeol(); refresh(); break; default: if (ch >= ' ') /* printing char */ { addch(ch); cp[loop++] = ch; refresh(); } } cp[loop] = '\0'; } void showusers() /* print a list of all characters */ { struct stats buf; FILE *fp; if (fp = fopen(peoplefile,"r")) { puts("Current characters on file are:\n"); while (fread((char *) &buf,sizeof(buf),1,fp)) if (strcmp("",buf.name)) printf("%-20s Login: %-9s Level: %6u\n",buf.name,buf.login,buf.lvl); fclose(fp); } } void kingstuff(stat) /* stuff upon entering throne */ register struct stats *stat; { FILE *fp; struct stats buf; struct nrgvoid vbuf; register int loc = 0; if (stat->typ < 10) /* check to see if king -- assumes crown */ { fp = fopen(peoplefile,"r"); while (fread((char *) &buf,sizeof(buf),1,fp)) if (buf.typ > 10 && buf.typ < 20) /* found old king */ if (buf.status != OFF) { mvaddstr(6,0,"The king is playing, so you cannot steal his throne\n"); stat->x = stat->y = 9; move(3,0); fclose(fp); return; } else { buf.typ -= 10; if (buf.crn) --buf.crn; fclose(fp); update(&buf,loc); KING: stat->typ = abs(stat->typ) + 10; mvaddstr(6,0,"You have become king!\n"); fp = fopen(messfile,"w"); fprintf(fp,"All hail the new king!"); fclose(fp); /* clear all energy voids */ fp = fopen(voidfile,"r"); if (fread((char *) &vbuf,sizeof(vbuf),1,fp) != 1) /*ignore*/; fclose(fp); fp = fopen(voidfile,"w"); fwrite((char *) &vbuf,sizeof(vbuf),1,fp); fclose(fp); goto EXIT; } else ++loc; fclose(fp); /* old king not found -- install new one */ goto KING; } EXIT: mvaddstr(3,0,"0:Decree "); } void paws(where) /* wait for input to continue */ int where; { mvaddstr(where,0,"-- more --"); rgetch(); } void cstat() /* examine/change stats of a character */ { struct stats charac; char s[60], flag[2]; FILE *fp; register int loc = 0; int c, temp, today; long ltemp; double dtemp; flag[0] = 'F'; flag[1] = 'T'; mvaddstr(10,0,"Which character do you want to look at ? "); getstring(s,60); if (fp = fopen(peoplefile,"r")) while (fread((char *) &charac,sizeof(charac),1,fp)) if (!strcmp(s,charac.name)) goto FOUND; else ++loc; mvaddstr(11,0,"Not found."); exit1(); /*NOTREACHED*/ FOUND: fclose(fp); time(<emp); today = localtime(<emp)->tm_yday; if (!su) strcpy(charac.pswd,"XXXXXXXX"); clear(); TOP: mvprintw(0,0,"a:Name %s\n",charac.name); printw("b:Password %s\n",charac.pswd); printw(" :Login %s\n",charac.login); temp = today - charac.lastused; if (temp < 0) temp += 365; printw("c:Used %d\n",temp); mvprintw(5,0,"d:Experience %.0f\n",charac.exp); printw("e:Level %d\n",charac.lvl); printw("f:Strength %.0f\n",charac.str); printw("g:Sword %.0f\n",charac.swd); printw("h:Quickness %d\n",charac.quk); printw("i:Quikslvr %d\n",charac.quks); printw("j:Energy %.0f\n",charac.nrg); printw("k:Max-Nrg %.0f\n",charac.mxn); printw("l:Shield %.0f\n",charac.shd); printw("m:Magic %.0f\n",charac.mag); printw("n:Manna %.0f\n",charac.man); printw("o:Brains %.0f\n",charac.brn); mvprintw(0,40,"p:X-coord %.0f\n",charac.x); mvprintw(1,40,"q:Y-coord %.0f\n",charac.y); if (su) mvprintw(2,40,"r:Wormhole %d\n",charac.wormhole); else mvprintw(2,40,"r:Wormhole %c\n",flag[charac.wormhole != 0]); mvprintw(3,40,"s:Type %d\n",charac.typ); mvprintw(5,40,"t:Sin %0.3f\n",charac.sin); mvprintw(6,40,"u:Poison %0.3f\n",charac.psn); mvprintw(7,40,"v:Gold %.0f\n",charac.gld); mvprintw(8,40,"w:Gem %.0f\n",charac.gem); mvprintw(9,40,"x:Holy Water %d\n",charac.hw); mvprintw(10,40,"y:Charms %d\n",charac.chm); mvprintw(11,40,"z:Crowns %d\n",charac.crn); mvprintw(12,40,"1:Amulets %d\n",charac.amu); mvprintw(13,40,"2:Age %d\n",charac.age); mvprintw(18,5,"3:Virgin %c 4:Blessed %c 5:Ring %c 6:Blind %c 7:Palantir %c", flag[charac.vrg],flag[charac.bls],flag[charac.rng.type != 0],flag[charac.blind],flag[charac.pal]); if (!su) exit1(); mvaddstr(15,40,"!:Quit"); mvaddstr(16,40,"?:Delete"); mvaddstr(19,30,"8:Duration"); mvaddstr(21,0,"What would you like to change? "); c = rgetch(); switch(c) { case 'p': /* change x coord */ mvprintw(23,0,"x = %f; x = ",charac.x); dtemp = inflt(); if (dtemp != 0.0) charac.x = dtemp; break; case 'q': /* change y coord */ mvprintw(23,0,"y = %f; y = ",charac.y); dtemp = inflt(); if (dtemp != 0.0) charac.y = dtemp; break; case 'd': /* change Experience */ mvprintw(23,0,"exp = %f; exp = ",charac.exp); dtemp = inflt(); if (dtemp != 0.0) charac.exp = dtemp; break; case 'e': /* change level */ mvprintw(23,0,"lvl = %d; lvl;= ",charac.lvl); dtemp = inflt(); if (dtemp != 0.0) charac.lvl = dtemp; break; case 'h': /* change quickness */ mvprintw(23,0,"quk = %d; quk;= ",charac.quk); dtemp = inflt(); if (dtemp != 0.0) charac.quk = dtemp; break; case 'f': /* change strength */ mvprintw(23,0,"str = %f; str;= ",charac.str); dtemp = inflt(); if (dtemp != 0.0) charac.str = dtemp; break; case 't': /* change Sin */ mvprintw(23,0,"sin = %f; sin;= ",charac.sin); dtemp = inflt(); if (dtemp != 0.0) charac.sin = dtemp; break; case 'n': /* change manna */ mvprintw(23,0,"man = %f; man;= ",charac.man); dtemp = inflt(); if (dtemp != 0.0) charac.man = dtemp; break; case 'v': /* change gold */ mvprintw(23,0,"gld = %f; gld;= ",charac.gld); dtemp = inflt(); if (dtemp != 0.0) charac.gld = dtemp; break; case 'j': /* change energy */ mvprintw(23,0,"nrg = %f; nrg;= ",charac.nrg); dtemp = inflt(); if (dtemp != 0.0) charac.nrg = dtemp; break; case 'k': /* change Maximum energy */ mvprintw(23,0,"mxn = %f; mxn;= ",charac.mxn); dtemp = inflt(); if (dtemp != 0.0) charac.mxn = dtemp; break; case 'm': /* change magic */ mvprintw(23,0,"mag = %f; mag;= ",charac.mag); dtemp = inflt(); if (dtemp != 0.0) charac.mag = dtemp; break; case 'o': /* change brains */ mvprintw(23,0,"brn = %f; brn;= ",charac.brn); dtemp = inflt(); if (dtemp != 0.0) charac.brn = dtemp; break; case 'z': /* change crowns */ mvprintw(23,0,"crn = %d; crn;= ",charac.crn); dtemp = inflt(); if (dtemp != 0.0) charac.crn = dtemp; break; case '5': /* change ring type */ mvprintw(23,0,"rng-type = %d; rng-type;= ",charac.rng.type); dtemp = inflt(); if (dtemp != 0.0) charac.rng.type = dtemp; break; case '8': /* change ring duration */ mvprintw(23,0,"rng-duration = %d; rng-duration;= ",charac.rng.duration); dtemp = inflt(); if (dtemp != 0.0) charac.rng.duration = dtemp; break; case '7': /* change palantir */ mvprintw(23,0,"pal = %d; pal;= ",charac.pal); dtemp = inflt(); if (dtemp != 0.0) { charac.pal = dtemp; charac.pal = (charac.pal != 0); } break; case 'u': /* change poison */ mvprintw(23,0,"psn = %f; psn;= ",charac.psn); dtemp = inflt(); if (dtemp != 0.0) charac.psn = dtemp; break; case 'x': /* change holy water */ mvprintw(23,0,"hw = %d; hw;= ",charac.hw); dtemp = inflt(); if (dtemp != 0.0) charac.hw = dtemp; break; case '1': /* change amulet */ mvprintw(23,0,"amu = %d; amu;= ",charac.amu); dtemp = inflt(); if (dtemp != 0.0) charac.amu = dtemp; break; case '4': /* change Blessing */ mvprintw(23,0,"bls = %d; bls;= ",charac.bls); dtemp = inflt(); if (dtemp != 0.0) { charac.bls = dtemp; charac.bls = (charac.bls != 0); } break; case 'y': /* change Charm */ mvprintw(23,0,"chm = %d; chm;= ",charac.chm); dtemp = inflt(); if (dtemp != 0.0) charac.chm = dtemp; break; case 'w': /* change Gems */ mvprintw(23,0,"gem = %f; gem;= ",charac.gem); dtemp = inflt(); if (dtemp != 0.0) charac.gem = dtemp; break; case 'i': /* change Quicksilver */ mvprintw(23,0,"quks = %d; quks;= ",charac.quks); dtemp = inflt(); if (dtemp != 0.0) charac.quks = dtemp; break; case 'g': /* change swords */ mvprintw(23,0,"swd = %f; swd;= ",charac.swd); dtemp = inflt(); if (dtemp != 0.0) charac.swd = dtemp; break; case 'l': /* change shields */ mvprintw(23,0,"shd = %f; shd;= ",charac.shd); dtemp = inflt(); if (dtemp != 0.0) charac.shd = dtemp; break; case 's': /* change type */ mvprintw(23,0,"typ = %d; typ;= ",charac.typ); dtemp = inflt(); if (dtemp != 0.0) charac.typ = dtemp; break; case '3': /* change virgin */ mvprintw(23,0,"vrg = %d; vrg;= ",charac.vrg); dtemp = inflt(); if (dtemp != 0.0) { charac.vrg = dtemp; charac.vrg = (charac.vrg != 0); } break; case 'c': /* change last-used */ mvprintw(23,0,"last-used = %d; last-used;= ",charac.lastused); dtemp = inflt(); if (dtemp != 0.0) charac.lastused = dtemp; break; case 'b': /* change password */ mvaddstr(23,0,"New password: "); getstring(s,60); if (*s) strcpy(charac.pswd,s); break; case 'a': /* change name */ mvaddstr(23,0,"New name: "); getstring(s,60); if (*s) strcpy(charac.name,s); break; case 'r': /* change wormhole */ mvprintw(23,0,"wormhole = %d; wormhole;= ",charac.wormhole); dtemp = inflt(); if (dtemp != 0.0) charac.wormhole = dtemp; break; case '2': /* change age */ mvprintw(23,0,"age = %d; age;= ",charac.age); dtemp = inflt(); if (dtemp != 0.0) charac.age = dtemp; break; case '6': /* change blindness */ mvprintw(23,0,"blind = %d; blind;= ",charac.blind); dtemp = inflt(); if (dtemp != 0.0) { charac.blind = dtemp; charac.blind = (charac.blind != 0); } break; case '!': /* quit, update */ goto LEAVE; case '?': /* delete char */ strcpy(charac.name,""); initchar(&charac); goto LEAVE; } goto TOP; LEAVE: charac.status = OFF; update(&charac,loc); } unsigned level(expr) /* calculate level */ double expr; { if (expr < 1.1e+7) return (pow((expr/1000.0), 0.4875)); else return (pow((expr/1250.0), 0.4865)); } void strunc(str) /* remove blank spaces at the end of str[] */ register char *str; { register int loop; loop = strlen(str) - 1; while (str[--loop] == ' ') str[loop] = '\0'; } double inflt() /* get a floating point # from the terminal */ { char aline[80]; double res; getstring(aline,80); if (sscanf(aline, "%lf", &res) < 1) res = 0; return (res); } void checkmov(stat) /* see if beyond PONR */ register struct stats *stat; { if (beyond) { stat->x = sgn(stat->x) * max(abs(stat->x),1.1e+6); stat->y = sgn(stat->y) * max(abs(stat->y),1.1e+6); } } void scramble(stat) /* mix up some stats */ register struct stats *stat; { double buf[5], temp; register int first, second; register double *bp; bp = buf; *bp++ = stat->str; *bp++ = stat->man; *bp++ = stat->brn; *bp++ = stat->mag; *bp++ = stat->nrg; bp = buf; first = roll(0,5); second = roll(0,5); temp = bp[first]; bp[first] = bp[second]; bp[second] = temp; stat->str = *bp++; stat->man = *bp++; stat->brn = *bp++; stat->mag = *bp++; stat->nrg = *bp++; } ================================================ FILE: games/phantasia/func2.c ================================================ /* * func2.c Phantasia support routines */ #include "phant.h" static void voidupdate(vp,loc) /* update an energy void */ register struct nrgvoid *vp; register int loc; { FILE *fp; fp = fopen(voidfile,ACCESS); fseek(fp,(long) loc*sizeof(*vp),0); fwrite((char *) vp,sizeof(*vp),1,fp); fclose(fp); } static void statread(stat,loc) /* read a charac. structure */ register struct stats *stat; register int loc; { FILE *fp; fp = fopen(peoplefile,"r"); fseek(fp,(long) loc * sizeof(*stat),0); if (fread((char *) stat,sizeof(*stat),1,fp) != 1) /*ignore*/; fclose(fp); } static void tampered(stat,what,bufp) /* decree'd, intervened, etc. */ register struct stats *stat, *bufp; int what; { struct nrgvoid vbuf; register int loc; struct stats sbuf; FILE *fp; changed = TRUE; move(6,0); stat->tampered = OFF; switch ((int) what) { case NRGVOID: addstr("You've hit an energy void !\n"); stat->man /= 3; stat->nrg /= 2; stat->gld = floor(stat->gld/1.25) + 0.1; stat->x += 10; break; case TRANSPORT: addstr("The king transported you ! "); if (stat->chm) { addstr("But your charm save you. . .\n"); --stat->chm; } else { stat->x += roll(-50,100) * circ(stat->x,stat->y); stat->y += roll(-50,100) * circ(stat->x,stat->y); addch('\n'); } break; case GOLD: printw("The king has bestowed %.0f gold pieces on you !\n",bufp->scratch1); stat->gld += bufp->scratch1; break; case CURSED: addstr("You've been cursed ! "); if (stat->bls) { addstr("But your blessing saved you. . .\n"); stat->bls = FALSE; } else { addch('\n'); stat->psn += 2; stat->nrg = 10; stat->mxn *= 0.95; stat->status = PLAYING; } break; case VAPORIZED: addstr("Woops! You've been vaporized!\n"); death(stat); break; case MONSTER: addstr("The Valar zapped you with a monster!\n"); paws(7); fight(stat,(int) bufp->scratch1); return; case BLESS: addstr("The Valar has blessed you!\n"); stat->nrg = (stat->mxn *= 1.05) + stat->shd; stat->man += 500; stat->str += 0.5; stat->brn += 0.5; stat->mag += 0.5; stat->psn = min(0.5,stat->psn); break; case MOVED: addstr("You've been relocated. . .\n"); stat->x = bufp->scratch1; stat->y = bufp->scratch2; break; case HEAL: addstr("You've been healed!\n"); stat->psn -= 0.25; stat->nrg = stat->mxn + stat->shd; break; case STOLEN: addstr("You'Ve been bumped off as Valar!\n"); stat->typ = 20 + roll(1,6); break; case GRAIL: addstr("You have found The Holy Grail!!\n"); if (stat->typ < 20) { addstr("However, you are not experienced enough to behold it.\n"); stat->sin *= stat->sin; stat->man += 1000; } else if (stat->typ == 99 || stat->typ == 90) { addstr("You have made it to the position of Valar once already.\n"); addstr("The Grail is of no more use to you now.\n"); } else { addstr("It is now time to see if you are worthy to behold it. . .\n"); refresh(); sleep(4); if (rnd() / 2.0 < stat->sin) { addstr("You blew this one!\n"); stat->str = stat->man = stat->quk = stat->nrg = stat->mxn = stat->x = stat->y = stat->mag = stat->brn = stat->exp =1; stat->lvl = 0; } else { addstr("You made to position of Valar!\n"); stat->typ = 99; fp = fopen(peoplefile,"r"); loc = 0; while (fread((char *) &sbuf,sizeof(sbuf),1,fp)) if (sbuf.typ == 99) { sbuf.tampered = STOLEN; update(&sbuf,loc); break; } else ++loc; fclose(fp); } } vbuf.active = TRUE; vbuf.x = roll(-1e6,2e6); vbuf.y = roll(-1e6,2e6); voidupdate(&vbuf,0); break; } } void checktampered(stat) /* see if decree'd etc. */ register struct stats *stat; { struct nrgvoid vbuf; struct stats sbuf; FILE *fp; register int loc = 0; /* first check for energy voids */ fp = fopen(voidfile,"r"); while (fread((char *) &vbuf,sizeof(vbuf),1,fp)) if (vbuf.active && vbuf.x == stat->x && vbuf.y == stat->y) { fclose(fp); if (loc) { vbuf.active = FALSE; voidupdate(&vbuf,loc); tampered(stat,NRGVOID,&sbuf); } else if (stat->status != CLOAKED) tampered(stat,GRAIL,&sbuf); break; } else ++loc; fclose(fp); /* now check for other things */ statread(&sbuf,fileloc); if (sbuf.tampered) tampered(stat,sbuf.tampered,&sbuf); } void decree(stat) /* king and valar stuff */ register struct stats *stat; { FILE *fp; short arg; char aline[80], *cp; struct stats sbuf; struct nrgvoid vbuf; double temp1 = 0.0, temp2 = 0.0; int ch; register int loc = 0; move(3,0); clrtoeol(); if (stat->typ < 20 && !su) /* king */ { addstr("1:Transport 2:Curse 3:Energy Void 4:Bestow 5:Collect Taxes "); ch = rgetch(); move(3,0); clrtoeol(); switch (ch) { case '1': arg = TRANSPORT; cp = "transport"; break; case '2': arg = CURSED; cp = "curse"; break; case '3': addstr("Enter the X Y coordinates of void ? "); getstring(aline,30); sscanf(aline,"%lf %lf",&temp1,&temp2); vbuf.x = floor(temp1); vbuf.y = floor(temp2); vbuf.active = TRUE; voidupdate(&vbuf,allocvoid()); goto EXIT; case '4': arg = GOLD; addstr("How much gold to bestow ? "); temp1 = inflt(); if (temp1 > stat->gld || temp1 < 0) { mvaddstr(6,0,"You don't have that !\n"); return; } stat->gld -= floor(temp1); cp = "give gold to"; break; case '5': fp = fopen(goldfile,"r"); if (fread((char *) &temp1,sizeof(double),1,fp) != 1) /*ignore*/; fclose(fp); mvprintw(6,0,"You have collected %.0f in gold.\n",temp1); stat->gld += floor(temp1); fp = fopen(goldfile,"w"); temp1 = 0.0; fwrite((char *) &temp1,sizeof(double),1,fp); fclose(fp); return; default: return; } } else /* council of wise, valar, etc. */ { addstr("1:Heal "); if (stat->pal || su) addstr("2:Seek Grail "); if (stat->typ == 99 || su) addstr("3:Throw Monster 4:Relocate 5:Bless "); if (su) addstr("6:Vaporize "); ch = rgetch(); if (!su && ch > '2' && stat->typ != 99) { illcmd(); return; } switch (ch) { case '1': arg = HEAL; cp = "heal"; break; case '2': if (stat->pal) { fp = fopen(voidfile,"r"); if (fread((char *) &vbuf,sizeof(vbuf),1,fp) != 1) /*ignore*/; fclose(fp); temp1 = hypot(stat->x - vbuf.x,stat->y - vbuf.y); temp1 = floor(temp1 + roll(-temp1/10.0,temp1/5.0)); mvprintw(6,0,"The palantir says the Grail is about %.0f away.\n",temp1); return; } else { mvaddstr(6,0,"You need a palantir to seek the Grail.\n"); return; } case '3': mvaddstr(3,0,"Which monster [0-99] ? "); temp1 = inflt(); temp1 = max(0,min(99,temp1)); cp = "throw a monster at"; arg = MONSTER; break; case '4': mvaddstr(3,0,"New X Y coordinates ? "); getstring(aline,30); sscanf(aline,"%lf %lf",&temp1,&temp2); cp = "relocate"; arg = MOVED; break; case '5': arg = BLESS; cp = "bless"; break; case '6': if (su) { cp = "vaporize"; arg = VAPORIZED; break; } default: return; } } mvprintw(3,0,"Who do you want to %s ? ",cp); getstring(aline,21); strunc(aline); if (strcmp(stat->name,aline)) { fp = fopen(peoplefile,"r"); while (fread((char *) &sbuf,sizeof(sbuf),1,fp)) if (strcmp(aline,sbuf.name)) ++loc; else { fclose(fp); if (sbuf.tampered) { mvaddstr(6,0,"That person has something pending already.\n"); return; } else { sbuf.tampered = arg; sbuf.scratch1 = floor(temp1); sbuf.scratch2 = floor(temp2); update(&sbuf,loc); EXIT: mvaddstr(6,0,"It is done.\n"); return; } } fclose(fp); mvaddstr(6,0,"There is no one by that name.\n"); } else mvaddstr(6,0,"You may not do it to yourself!\n"); } int allocvoid() /* find a space to put an energy void */ { FILE *fp; register int loc = 0; struct nrgvoid vbuf; fp = fopen(voidfile,"r"); while (fread((char *) &vbuf,sizeof(vbuf),1,fp)) if (vbuf.active) ++loc; else { fclose(fp); return (loc); } fclose(fp); return (loc); } void adjuststats(stat) /* make sure things are within limits, etc. */ register struct stats *stat; { long ltemp; register int temp; stat->x = floor(stat->x); stat->y = floor(stat->y); valhala = (stat->typ == 99); throne = (stat->x == 0.0 && stat->y == 0.0); temp = abs(stat->x)/400; if (temp > 16) temp = 0; if (stat->y == 0.0 && !throne && !valhala && temp == abs(stat->x)/400 && sgn(stat->x) == (int) pow(-1.0, (double) temp)) { if (!wmhl) stat->wormhole = temp; wmhl = TRUE; } else wmhl = FALSE; speed = stat->quk + stat->quks - spdcalc(stat->lvl,stat->gld,stat->gem); strength = stat->str + stat->swd - strcalc(stat->str,stat->psn); time(<emp); stat->age += ltemp - secs; secs = ltemp; stat->quks = min(99,stat->quks); stat->man = min(stat->man,stat->lvl*15 + 5000); stat->chm = min(stat->chm,stat->lvl + 10); stat->typ = (stat->crn && stat->typ < 10) ? -abs(stat->typ) : abs(stat->typ); if (level(stat->exp) > stat->lvl) movelvl(stat); stat->gld = floor(stat->gld) + 0.1; stat->gem = floor(stat->gem) + 0.1; if (stat->rng.type) stat->nrg = stat->mxn + stat->shd; if (stat->rng.type && stat->rng.duration <= 0) /* clean up rings */ switch (stat->rng.type) { case DLBAD: case NAZBAD: stat->rng.type = SPOILED; stat->rng.duration = roll(10,25); break; case NAZREG: stat->rng.type = NONE; break; case SPOILED: death(stat); break; } /* DLREG is ok, so do nothing with it */ stat->nrg += (stat->mxn+stat->shd)/15+stat->lvl/3+2; stat->nrg = min(stat->nrg,stat->mxn + stat->shd); if (stat->age > stat->degen * 2500) { ++stat->degen; if (stat->quk > 23) --stat->quk; stat->str *= 0.97; stat->brn *= 0.95; stat->mag *= 0.97; stat->mxn *= 0.95; if (stat->quks) --stat->quks; stat->swd *= 0.93; stat->shd *= 0.95; } } static void interm(stat,who) /* interterminal battle routine */ register struct stats *stat; int who; { #define MAXWAIT 20 #define BLOCK sizeof(struct stats) #define RAN 1 #define STUCK 2 #define BLEWIT 3 #define KILLED 4 #define readfoe() fseek(fin,foeplace,0); \ if (fread((char *) foe,BLOCK,1,fin) != 1) /*ignore*/ #define updateme() fseek(fout,myplace,0); \ fwrite((char *) stat,BLOCK,1,fout); \ fflush(fout) FILE *fin, *fout; /* pointers for input, output */ double temp, foespeed, oldhits = 0.0, myhits; struct stats sbuf; register struct stats *foe; register int loop, lines = 5; int ch; long myplace, foeplace; int oldtags; bool luckout = FALSE; char foename[21]; fghting = TRUE; mvaddstr(4,0,"Preparing for battle!\n"); refresh(); /* set up variables, file, etc. */ myplace = fileloc * BLOCK; foeplace = who * BLOCK; fin = fopen(peoplefile,"r"); setbuf(fin, (char *) NULL); fout = fopen(peoplefile,ACCESS); stat->status = INBATTLE; myhits = stat->nrg; stat->tampered = oldtags = 1; /* this must be non-zero to prevent a king or valar from trashing it */ stat->scratch1 = stat->scratch2 = 0.0; updateme(); foe = &sbuf; readfoe(); foespeed = foe->quk + foe->quks - spdcalc(foe->lvl,foe->gld,foe->gem); if (abs(stat->lvl - foe->lvl) > 20) /* see if greatly mismatched */ { temp = ((double) (stat->lvl - foe->lvl))/((double) max(stat->lvl,foe->lvl)); if (temp > 0.5) /* this one outweighs his/her foe */ foespeed *= 2.0; else if (temp < -0.5) /* foe outweighs this one */ speed *= 2.0; } if (stat->blind) strcpy(foename,"someone"); else strcpy(foename,foe->name); mvprintw(3,0,"You have encountered %s Level: %d\n",foename,foe->lvl); refresh(); /* now wait for foe to respond */ for (loop = 1.5*MAXWAIT; foe->status != INBATTLE && loop; --loop) { readfoe(); sleep(1); } if (foe->status != INBATTLE) { mvprintw(4,0,"%s is not responding.\n",foename); goto LEAVE; } /* otherwise, everything is set to go */ move(4,0); clrtoeol(); /* check to see who goes first */ if (speed > foespeed) goto HITFOE; else if (foespeed > speed) goto WAIT; else if (stat->lvl > foe->lvl) goto HITFOE; else if (foe->lvl > stat->lvl) goto WAIT; else /* no one is faster */ { printw("You can't fight %s yet.",foename); goto LEAVE; } /* routine to hit, etc */ HITFOE: printstats(stat); mvprintw(1,26,"%20.0f",myhits); mvaddstr(4,0,"1:Fight 2:Run Away! 3:Power Blast "); if (luckout) clrtoeol(); else addstr("4:Luckout "); ch = gch(stat->rng.type); move(lines = 5,0); clrtobot(); switch (ch) { default: /* fight */ temp = roll(2,strength); HIT: mvprintw(lines++,0,"You hit %s %.0f times!",foename,temp); stat->sin += 0.5; stat->scratch1 += temp; stat->scratch2 = FALSE; break; case '2': /* run away */ --stat->scratch1; /* this value changes to indicate action */ if (rnd() > 0.25) { mvaddstr(lines++,0,"You got away!"); stat->scratch2 = RAN; goto LEAVE; } mvprintw(lines++,0,"%s is still after you!",foename); stat->scratch2 = STUCK; break; case '3': /* power blast */ temp = min(stat->man,stat->lvl*5); stat->man -= temp; temp = (rnd() + 0.5) * temp * stat->mag * 0.2 + 2; mvprintw(lines++,0,"You blasted %s !",foename); goto HIT; case '4': /* luckout */ if (luckout || rnd() > 0.1) { luckout = TRUE; mvaddstr(lines++,0,"Not this time..."); --stat->scratch1; stat->scratch2 = BLEWIT; } else { mvaddstr(lines++,0,"You just lucked out!"); stat->scratch1 = foe->nrg + 5; } break; } refresh(); stat->scratch1 = floor(stat->scratch1); /* clean up any mess */ if (stat->scratch1 > foe->nrg) stat->scratch2 = KILLED; else if (rnd() * speed < rnd() * foespeed) { /* foe's turn */ ++stat->tampered; updateme(); goto WAIT; } updateme(); if (((int) stat->scratch2) == KILLED) { mvprintw(lines++,0,"You killed %s!",foename); stat->exp += foe->exp; stat->crn += (stat->lvl < 1000) ? foe->crn : 0; stat->amu += foe->amu; stat->chm += foe->chm; stat->gld += foe->gld; stat->gem += foe->gem; stat->swd = max(stat->swd,foe->swd); stat->shd = max(stat->shd,foe->shd); stat->quks = max(stat->quks,foe->quks); sleep(3); /* give other person time to die */ goto LEAVE; } goto HITFOE; /* otherwise, my turn again */ /* routine to wait for foe to do something */ WAIT: printstats(stat); mvprintw(1,26,"%20.0f",myhits); mvaddstr(4,0,"Waiting...\n"); refresh(); for (loop = MAXWAIT; loop; --loop) { readfoe(); if (foe->scratch1 != oldhits) switch ((int) foe->scratch2) { case RAN: mvprintw(lines++,0,"%s ran away!",foename); goto LEAVE; case STUCK: mvprintw(lines++,0,"%s tried to run away.",foename); goto BOT; case BLEWIT: mvprintw(lines++,0,"%s tried to luckout!",foename); goto BOT; default: temp = foe->scratch1 - oldhits; mvprintw(lines++,0,"%s hit you %.0f times!",foename,temp); myhits -= temp; goto BOT; } sleep(1); } /* timeout */ mvaddstr(23,0,"Timeout: waiting for response. Do you want to wait ? "); refresh(); ch = getch(); move(23,0); clrtoeol(); if (toupper(ch) == 'Y') goto WAIT; goto LEAVE; /* routine to decide what happens next */ BOT: refresh(); if (lines > 21) { paws(lines); move(lines = 5,0); clrtobot(); } if (((int) foe->scratch2) == KILLED || myhits < 0.0) { myhits = -2; goto LEAVE; /* main will pick up death */ } oldhits = foe->scratch1; if (foe->tampered != oldtags) { oldtags = foe->tampered; goto HITFOE; } goto WAIT; /* routine to clean up things and leave */ LEAVE: updateme(); fclose(fin); fclose(fout); stat->x += roll(5,-10); stat->y += roll(5,-10); stat->nrg = myhits; stat->tampered = OFF; stat->status = PLAYING; changed = TRUE; paws(lines); move(3,0); clrtobot(); } void checkinterm(stat) /* see if other person on same x,y */ register struct stats *stat; { FILE *fp; struct stats sbuf; register int foeloc = 0; users = 0; fp = fopen(peoplefile,"r"); while (fread((char *) &sbuf,sizeof(sbuf),1,fp)) { if (sbuf.status && (sbuf.status != CLOAKED || sbuf.typ != 99)) { ++users; if (stat->x == sbuf.x && stat->y == sbuf.y && foeloc != fileloc && sbuf.typ != 99 && stat->typ !=99 && !stat->wormhole && !sbuf.wormhole) { fclose(fp); interm(stat,foeloc); return; } } ++foeloc; } fclose(fp); } int gch(rngtyp) /* get a character from terminal, but check ring if crazy */ int rngtyp; { refresh(); if (abs(rngtyp) != SPOILED) return (getch()); else { getch(); return (roll(0,5) + '0'); } } int rngcalc(chartyp) /* pick a duration of a ring */ int chartyp; { static int rngtab[] = { 0, 10, 20, 13, 25, 40, 20}; if (chartyp > 10) chartyp -= 10; return (rngtab[chartyp - 1]); } void interrupt(int sig) /* call when break key is hit */ { char line[81]; register int loop; int x, y, ch; #ifdef USG3 signal(SIGINT,SIG_IGN); #endif #ifdef USG5 signal(SIGINT,SIG_IGN); #endif getyx(stdscr,y,x); for (loop = 79; loop >= 0; --loop) /* snarf line */ { move(4,loop); line[loop] = inch(); } line[80] = '\0'; clrtoeol(); if (fghting) { move(4,0); clrtoeol(); addstr("Quitting now will automatically kill your character. Still want to ? "); ch = rgetch(); if (toupper(ch) == 'Y') longjmp(mainenv,DIE); } else { move(4,0); clrtoeol(); addstr("Do you really want to quit ? "); ch = rgetch(); if (toupper(ch) == 'Y') longjmp(mainenv,QUIT); } mvaddstr(4,0,line); /* return screen to previous state */ move(y,x); refresh(); #ifdef USG3 signal(SIGINT,interrupt); #endif #ifdef USG5 signal(SIGINT,interrupt); #endif } int rgetch() /* refresh, then get a char. */ { refresh(); return (getch()); } void purge() /* remove old players */ { FILE *fin, *fout; struct stats sbuf; register int loc, today, temp; long ltime; loc = 0; time(<ime); today = localtime(<ime)->tm_yday; fin = fopen(peoplefile,"r"); fout = fopen(peoplefile,ACCESS); while(fread((char *) &sbuf,sizeof(sbuf),1,fin)) { temp = today - sbuf.lastused; if (temp < 0) temp += 365; if (temp > 9) /* ten days old --> delete */ { initchar(&sbuf); strcpy(sbuf.name,""); fseek(fout,(long) loc * sizeof(sbuf),0); fwrite((char *) &sbuf,sizeof(sbuf),1,fout); } ++loc; } fclose(fin); fclose(fout); } ================================================ FILE: games/phantasia/main.c ================================================ /* * Phantasia 3.2 -- Interterminal fantasy game * * Edward A. Estes * AT&T Teletype Corp., September 4, 1984 */ /* * This is the program which drives the whole mess. Hopefully, you will be * able to wade throught the garbage if you have to fix something. * several undocumented items exist. The program checks uid and sets the * boolean flag 'su' (super user) if the person is allowed special powers. * The 'su' may execute any of the valar/council options. Also, * a 'vaporize' option exists to kill anybody at will. The 'su' can select * character type 7, which starts out with the maximum possible in each * category. (The resulting character is an experimento.) The 'su' may * also change the stats of other characters with the -x option. */ /* * The program allocates as much file space as it needs to store characters, * so the possibility exists for the character file to grow without bound. * The file is purged upon normal entry to try to avoid that problem. * A similar problem exists for energy voids. To alleviate the problem here, * the void file is cleared with every new king. */ /* * The support functions are split between various files with no apparent * order. Use of 'ctags' is recommended to find a particular function. */ /* * Put one line of text into the file 'motd' for announcements, etc. */ /* * If ENEMY is defined, a list of restricted login names is checked * in the file 'enemy'. These names are listed, one per line, with * no trailing blanks. */ #include "phant.h" double strength, speed; bool beyond, marsh, throne, valhala, changed, fghting, su, wmhl; int fileloc, users; jmp_buf fightenv, mainenv; long secs; /* * worm hole map -- This table is carefully set up so that one can always * return the way he/she came by inverting the initial path. */ struct worm_hole w_h[] = { 0,0,0,0, 35,22,2,0, 2,2,0,1, 59,34,64,0, 54,47,0,60, 50,62,0,56, 19,31,25,0, 0,35,41,41, 0,46,40,23, 24,0,29,30, 44,57,56,0, 0,44,39,40, 61,41,0,42, 32,0,17,18, 57,0,63,64, 0,33,26,34, 48,0,54,55, 28,23,22,13, 63,25,13,19, 34,6,18,20, 27,26,19,21, 15,27,20,27, 1,28,34,17, 17,29,8,24, 29,9,23,25, 18,30,24,6, 20,32,27,15, 21,20,21,26, 22,17,46,29, 23,24,28,9, 25,38,9,31, 6,39,30,32, 26,13,31,33, 15,40,32,35, 3,19,15,22, 7,1,33,36, 37,37,35,37, 36,36,36,38, 30,42,37,39, 31,43,38,11, 33,45,11,8, 12,48,7,7, 38,49,12,43, 39,51,42,44, 11,10,43,45, 40,52,44,46, 8,53,45,28, 4,54,51,48, 41,16,47,49, 42,55,48,50, 62,5,49,51, 43,56,50,47, 45,58,53,53, 46,59,52,52, 47,4,55,16, 49,61,16,54, 51,63,5,10, 10,14,59,58, 52,64,57,59, 53,3,58,57, 60,60,4,61, 55,12,60,62, 5,50,61,63, 56,18,62,14, 58,33,14,3 }; int main(argc,argv) /* Phantasia main routine */ int argc; char *argv[]; { struct stats charac; char aline[200], *login = NULL; double x = 0.0, y = 0.0; int ch, ch2; register int loop, temp; FILE *fp; bool shrt = FALSE, examine = FALSE, header = FALSE; login = getlogin(); if (! login) login = getpwuid(getuid())->pw_name; #ifdef ENEMY /* check hit list of restricted accounts */ if ((fp = fopen(enemyfile, "r")) != NULL) { char enemy[20]; while (fscanf(fp, "%s", enemy) != EOF) if (!strcmp(login,enemy)) { printf ("The Phantasia privileges for the account \"%s\" have been revoked.\n", login); printf ("Mail comments to %s.\n", WIZARD); exit (0); } fclose (fp); } #endif setbuf(stdin, (char *) NULL); /* this may or may not be necessary */ su = (getuid() == UID); fghting = FALSE; users = 0; if (argc > 1 && (*++argv)[0] == '-') switch ((*argv)[1]) { case 'h': /* help */ printhelp(); exit(0); /*NOTREACHED*/ case 's': /* short */ shrt = TRUE; break; case 'x': /* examine */ examine = TRUE; break; case 'H': /* Header */ header = TRUE; break; case 'm': /* monsters */ printmonster(); exit(0); /*NOTREACHED*/ case 'a': /* all users */ showusers(); exit(0); /*NOTREACHED*/ case 'p': /* purge old players */ purge(); exit(0); /*NOTREACHED*/ } if (!isatty(0)) /* don't let non-tty's play */ exit(0); init1(); /* set up for screen stuff */ if (examine) { cstat(); exit1(); /*NOTREACHED*/ } if (!shrt) { titlestuff(); purge(); /* clean up old characters */ } if (header) { exit1(); /*NOTREACHED*/ } #ifdef OK_TO_PLAY if (!ok_to_play()) { mvaddstr(23,27,"Sorry, you can't play now.\n"); exit1(); /*NOTREACHED*/ } #endif mvaddstr(23,24,"Do you have a character to run? "); ch = rgetch(); if (toupper(ch) == 'Y') fileloc = findchar(&charac); else { initchar(&charac); clear(); mvaddstr(5,21,"Which type of character do you want:"); mvaddstr(10,4,"1:Magic User 2:Fighter 3:Elf 4:Dwarf 5:Halfling 6:Experimento ? "); ch = rgetch(); do { genchar(&charac,ch); mvprintw(15,14,"Strength: %2.0f Manna : %3.0f Quickness : %2d", charac.str,charac.man,charac.quk); mvprintw(16,14,"Brains : %2.0f Magic Level: %2.0f Energy Level: %2.0f", charac.brn,charac.mag,charac.nrg); if (charac.typ != 6) { mvaddstr(17,14,"Type '1' to keep >"); ch2 = rgetch(); } else break; } while (ch2 != '1'); if (charac.typ == 6) { mvaddstr(19,0,"Enter the X Y coordinates of your experimento ? "); getstring(aline,80); sscanf(aline,"%lf %lf",&x,&y); charac.x = (abs(x) > 1.2e+6) ? sgn(x)*1.2e+6 : floor(x); charac.y = (abs(y) > 1.2e+6) ? sgn(y)*1.2e+6 : floor(y); } do { mvaddstr(20,0,"Give your character a name [up to 20 characters] ? "); getstring(aline,80); strncpy(charac.name,aline,20); charac.name[20] = '\0'; } while (findname(charac.name)); putchar('\n'); fflush(stdout); nocrmode(); do { strcpy(charac.pswd,getpass("Give your character a password [up to 8 characters] ? ")); putchar('\n'); strcpy(aline,getpass("One more time to verify ? ")); } while (strcmp(charac.pswd,aline)); fileloc = findspace(); } crmode(); if (charac.status) { clear(); addstr("Your character did not exit normally last time.\n"); addstr("If you think you have good cause to have you character saved,\n"); printw("you may quit and mail your reason to '%s'.\n",WIZARD); addstr("Do you want to quit ? "); ch = rgetch(); if (toupper(ch) == 'Y') { charac.quk = -100; leave(&charac); /*NOTREACHED*/ } death(&charac); } charac.status = PLAYING; strcpy(charac.login,login); time(&secs); charac.lastused = localtime(&secs)->tm_yday; update(&charac,fileloc); clear(); signal(SIGINT,interrupt); /* all set for now */ TOP: switch (setjmp(mainenv)) { case QUIT: signal(SIGINT,interrupt); leave(&charac); /*NOTREACHED*/ case DIE: signal(SIGINT,interrupt); death(&charac); break; } #ifdef OK_TO_PLAY if (!ok_to_play()) { mvaddstr(6,0,"Whoops! Can't play now.\n"); leave(&charac); /*NOTREACHED*/ } #endif fghting = FALSE; adjuststats(&charac); if (throne && !charac.crn && (charac.typ < 10 || charac.typ > 20)) { mvaddstr(6,0,"You're not allowed in the Lord's Chamber without a crown.\n"); changed = TRUE; charac.x = charac.y = 10; } if (charac.status != CLOAKED && abs(charac.x) == abs(charac.y) && floor(sqrt(fabs(charac.x/100.0))) == sqrt(fabs(charac.x/100.0)) && !throne) { trade(&charac); clear(); } checktampered(&charac); checkinterm(&charac); if (charac.nrg < 0 || (charac.lvl >= 10000 && charac.typ != 99)) death(&charac); neatstuff(&charac); if (changed) { update(&charac,fileloc); changed = FALSE; goto TOP; } move(5,0); clrtoeol(); fp = fopen(messfile,"r"); if (fgets(aline,160,fp)) addstr(aline); fclose(fp); printstats(&charac); move(3,0); clrtoeol(); if (!wmhl) { if (throne) kingstuff(&charac); addstr("1:Move 2:Players 3:Talk 4:Stats 5:Quit "); if (charac.lvl >= 5 && charac.mag >= 15) addstr("6:Cloak "); if (charac.lvl >= 10 && charac.mag >= 25) addstr("7:Teleport "); if (charac.typ > 20) addstr("8:Intervention"); ch = gch(charac.rng.type); clrtoeol(); move(6,0); clrtobot(); if (charac.typ == 99 && (ch == '1' || ch == '7')) ch = ' '; switch (ch2 = toupper(ch)) { case 'N': charac.y += maxmove; break; case 'S': charac.y -= maxmove; break; case 'E': charac.x += maxmove; break; case 'W': charac.x -= maxmove; break; default: /* rest */ if (charac.status == CLOAKED) if (charac.man > 3.0) charac.man -= 3; else { charac.status = PLAYING; changed = TRUE; } else { charac.man += circ(charac.x,charac.y)/3+0.5; charac.man += charac.lvl/5+0.5; } rndattack(); break; case '1': /* move */ for (loop = 3; loop; --loop) { mvaddstr(5,0,"X Y Coordinates ? "); getstring(aline,80); if (sscanf(aline,"%lf %lf",&x,&y) < 2) ; else if (hypot((double) charac.x - x, (double) charac.y - y) > maxmove) illmove(); else { charac.x = x; charac.y = y; break; } } break; case '2': /* players */ printplayers(&charac); break; case '3': /* message */ talk(charac.name); break; case '4': /* stats */ showall(&charac); break; case '5': /* good-bye */ leave(&charac); /*NOTREACHED*/ case '6': /* cloak */ if (charac.lvl < 5 || charac.mag < 15) illcmd(); else if (charac.status == CLOAKED) charac.status = PLAYING; else if (charac.man < 35) { mvaddstr(6,0,"No power left.\n"); refresh(); } else { changed = TRUE; charac.man -= 35; charac.status = CLOAKED; } break; case '7': /* teleport */ if (charac.lvl < 10 || charac.mag < 25) illcmd(); else for (loop = 3; loop; --loop) { mvaddstr(5,0,"X Y Coordinates ? "); getstring(aline,80); if (sscanf(aline,"%lf %lf",&x,&y) == 2) if ((temp = hypot(charac.x-x,charac.y-y)) > (charac.lvl+charac.mag)*5+((charac.typ > 20) ? 1e+6 : 0) && !throne) illmove(); else if ((temp = (temp/75+1)*20) > charac.man && !throne) mvaddstr(6,0,"Not enough power for that distance.\n"); else { charac.x = x; charac.y = y; if (!throne) charac.man -= temp; break; } } break; case '9': /* monster */ if (throne) mvaddstr(6,0,"No monsters in the chamber!\n"); else if (charac.typ != 99) { charac.status = PLAYING; changed = TRUE; charac.sin += 1e-6; fight(&charac,-1); } break; case '0': /* decree */ if (su || charac.typ > 10 && charac.typ < 20 && throne) decree(&charac); else illcmd(); break; case '8': /* intervention */ if (su || charac.typ > 20) valarstuff(&charac); else illcmd(); break; case '\014': /* redo screen */ clear(); } if (ch2 == 'E' || ch2 == 'W' || ch2 == 'N' || ch2 == 'S' || ch2 == '1' || ch2 == '7') { checkmov(&charac); rndattack(); changed = TRUE; } } else { addstr("F:Forward B:Back R:Right L:Left Q:Quit T:Talk P:Players S:Stats "); ch = rgetch(); move(6,0); clrtobot(); switch (toupper(ch)) { default: if (charac.status == CLOAKED) if (charac.man > 3.0) charac.man -= 3; else { charac.status = PLAYING; changed = TRUE; } else charac.man += charac.lvl/5+0.5; break; case 'F': temp = (int) w_h[charac.wormhole].f; goto CHKMOVE; case 'B': temp = (int) w_h[charac.wormhole].b; goto CHKMOVE; case 'R': temp = (int) w_h[charac.wormhole].r; goto CHKMOVE; case 'L': temp = (int) w_h[charac.wormhole].l; goto CHKMOVE; case 'Q': leave(&charac); /*NOTREACHED*/ case 'T': talk(charac.name); break; case 'P': printplayers(&charac); break; case 'S': showall(&charac); break; case '\014': /* redo screen */ clear(); } goto TOP; CHKMOVE: if (!temp) { charac.y = 0.0; charac.x = pow(-1.0,(double) charac.wormhole) * charac.wormhole * 400 - 1.0; charac.wormhole = 0; changed = TRUE; } else charac.wormhole = temp; } goto TOP; } /* * This function is provided to allow one to restrict access to the game. * Tailor this routine as appropriate. */ #ifdef OK_TO_PLAY #include #include /* used for counting users on system */ bool ok_to_play() /* return FALSE if playing is not allowed at this time */ { #define MAXUSERS 8 /* max. number of people on system */ register struct tm *tp; register int numusers = 0; FILE *fp; long now; struct utmp ubuf; if (su) return (TRUE); /* check time of day */ time(&now); if (((tp = localtime(&now))->tm_hour > 8 && tp->tm_hour < 12) /* 8-noon */ || (tp->tm_hour > 13 && tp->tm_hour < 16)) /* 1-4 pm */ return (FALSE); /* check # of users */ fp = fopen(_PATH_UTMP,"r"); while (fread((char *) &ubuf,sizeof(ubuf),1,fp)) #ifdef USG5 if (ubuf.ut_type == USER_PROCESS) #else if (*ubuf.ut_name) #endif ++numusers; fclose(fp); if (numusers > MAXUSERS) return (FALSE); return (TRUE); } #endif ================================================ FILE: games/phantasia/monsters ================================================ a Water Leaper 12 14 16 24 59 0 0 62 a Leech 4 19 29 30 66 0 0 73 a Urisk 13 30 15 46 127 1 0 3 Shellycoat 28 21 18 63 226 2 0 0 a Naiad 21 62 27 58 378 2 0 11 a Nixie 22 58 28 108 604 3 0 6 a Glaistig 21 106 25 127 1002 3 0 0 a Mermaid 18 116 22 108 809 3 0 0 a Merman 24 115 23 109 808 4 0 0 a Siren 22 128 31 89 915 4 0 24 a Lamprey 14 67 33 156 1562 4 15 37 a Kopoacinth 26 36 26 206 2006 5 0 20 a Kelpie 61 25 24 223 4025 5 0 0 an Aspidchelone 114 104 19 898 10041 7 0 2 an Idiot 13 14 16 28 49 0 0 0 some Green Slime 1 5 45 100 57 0 0 26 a Pixie 11 29 23 26 64 0 0 32 a Serpent 10 18 25 25 79 0 0 10 a Cluricaun 12 27 20 30 81 0 14 5 an Imp 22 30 14 40 92 0 0 1 a Centipede 3 8 18 15 33 0 0 61 a Beetle 2 11 21 26 44 0 0 48 a Fir Darrig 18 22 17 35 107 0 14 1 Modnar 15 23 20 40 101 7 2 12 a Gnome 7 45 26 23 111 0 0 21 a Sprite 9 37 25 31 132 1 0 43 a Mimic 11 55 29 47 213 1 3 2 a Kobold 13 10 14 21 121 1 12 68 a Spider 6 11 28 28 124 1 0 57 an Uldra 14 37 21 32 93 1 0 6 a Gnoll 20 25 15 40 166 1 0 61 a Bogie 23 28 19 57 189 1 0 57 a Fachan 9 40 15 45 139 1 14 10 a Moron 3 1 10 10 28 0 0 100 an Orc 25 13 16 26 141 1 0 92 a Ghillie Dhu 12 16 13 28 104 2 14 2 a Bogle 19 15 16 35 157 2 14 15 a Shrieker 2 62 27 9 213 2 16 0 a Carrion Crawler 12 20 20 65 142 2 0 42 a Trow 15 17 23 51 136 2 0 36 a Warg 20 10 17 45 152 2 0 88 a Stirge 2 6 35 25 153 2 0 95 a Crebain 5 11 31 31 82 2 0 81 a Killmoulis 30 19 8 75 175 3 14 22 a Hob-goblin 35 20 15 72 246 3 0 18 a Unicorn 27 57 27 57 627 3 1 0 a Fenoderee 16 6 21 65 222 3 0 42 an Ogre 42 14 16 115 409 3 0 19 a Dodo 62 12 11 76 563 3 0 3 a Hydra 14 27 33 99 599 3 0 27 a Hamadryad 23 47 26 62 426 3 0 12 a Bwca 21 17 19 55 387 3 14 1 an Owlbear 35 16 18 100 623 4 0 22 Black Annis 37 52 15 65 786 4 0 2 a Jello Blob 45 23 12 114 1191 4 0 0 a Wichtlein 13 40 25 61 800 4 0 8 a Cocodrill 39 28 24 206 1438 4 0 38 a Troll 75 12 20 185 1013 4 24 29 a Bonnacon 89 26 9 255 1661 4 17 14 a Gargoyle 22 21 29 200 1753 5 0 7 a Chaladrius 8 49 37 172 1929 5 0 20 a Gwyllion 27 73 20 65 1888 5 0 4 a Cinomulgus 23 2 10 199 263 5 0 18 a Peridexion 26 32 24 98 1300 5 0 2 Smeagol 41 33 27 373 2487 5 18 0 a Wraith 52 102 22 200 3112 5 25 13 a Snotgurgle 143 19 26 525 4752 6 0 3 a Phooka 42 63 21 300 4125 5 0 12 a Vortex 101 30 31 500 6992 6 9 4 Shelob 147 64 28 628 5003 7 13 0 a Thaumaturgist 35 200 23 400 7628 6 7 0 Smaug 251 76 26 1022 9877 7 0 0 a Cold-drake 301 102 24 1222 10888 7 0 0 a Red Dragon 342 141 23 1299 11649 8 0 0 Scatha the Worm 406 208 20 1790 11999 8 0 0 Tiamat 506 381 29 2000 13001 9 11 0 a Bandersnatch 105 98 22 450 7981 6 0 3 a Harpy 103 49 24 263 7582 6 0 2 a Tigris 182 38 17 809 7777 6 0 3 a Gryphon 201 45 19 813 8888 7 0 1 a Coblynau 205 46 18 585 8333 6 0 2 a Chimaera 173 109 28 947 12006 7 0 0 a Jack-in-Irons 222 36 12 1000 9119 7 0 0 Saruman 55 373 17 1500 17101 11 6 0 a Balrog 500 100 25 705 8103 7 8 0 Argus 201 87 14 1500 10010 8 0 0 a Titan 302 1483 12 1625 11011 8 0 0 Cacus 256 43 19 1750 12012 8 0 0 Begion 403 154 10 1875 13013 8 0 0 Grendel 197 262 23 2000 14014 8 0 0 a Nazgul 250 251 26 1011 9988 12 10 9 a Succubus 186 1049 27 2007 19984 9 19 0 Red Cap 143 50 35 1965 23456 9 0 0 a Nuckelavee 300 75 20 2185 11111 8 0 0 Cerberus 236 96 29 2600 25862 9 20 0 a Jabberwock 185 136 25 2265 23256 9 22 0 Ungoliant 399 2398 37 2784 27849 10 21 0 Leanan-Sidhe 486 5432 46 3000 30004 9 5 0 the Dark Lord 9999 9999 31 19999 30005 13 4 0 ================================================ FILE: games/phantasia/phant.h ================================================ /* * phant.h Include file for Phantasia */ #include #include #include #include #include #include #include #include #include /* ring constants */ #define NONE 0 #define NAZBAD 1 #define NAZREG 2 #define DLREG 3 #define DLBAD 4 #define SPOILED 5 /* some functions and pseudo-functions */ #define toupper(CH) ((CH) > 96 ? (CH) ^ 32 : (CH)) /* may be upper or lower */ #define tolower(CH) ((CH) | 32) /* must be upper */ #define rnd() (((double) rand()) / RAND) #define roll(BASE,INTERVAL) floor((BASE) + (INTERVAL) * rnd()) #define sgn(x) (-(x < 0) + (x > 0)) #define abs(x) ((x) < 0 ? -(x) : (x)) #define circ(x,y) floor(sqrt((double) ((x) * (x) + (y) * (y))) / 125 + 1) #define max(A,B) ((A) > (B) ? (A) : (B)) #define min(A,B) ((A) < (B) ? (A) : (B)) #define valarstuff(ARG) decree(ARG) #define illcmd() mvaddstr(6,0,"Illegal command.\n") #define maxmove floor(charac.lvl * 1.5 + 1) #define illmove() mvaddstr(6,0,"Too far.\n") #define rndattack() if (rnd() < 0.2 && charac.status == PLAYING && !throne) \ fight(&charac,-1) #define strcalc(STR,SICK) max(0,min(0.9 * STR, SICK * STR/20)) #define spdcalc(LVL,GLD,GEM) max(0,((GLD + GEM/2) - 1000)/200.0 - LVL) #define illspell() mvaddstr(6,0,"Illegal spell.\n") #define nomanna() mvaddstr(6,0,"Not enough manna for that spell.\n") #define somebetter() addstr("But you already have something better.\n") /* status constants */ #define OFF 0 #define PLAYING 1 #define CLOAKED 2 #define INBATTLE 3 #define DIE 4 #define QUIT 5 /* tampered constants */ #define NRGVOID 1 #define GRAIL 2 #define TRANSPORT 3 #define GOLD 4 #define CURSED 5 #define MONSTER 6 #define BLESS 7 #define MOVED 8 #define HEAL 9 #define VAPORIZED 10 #define STOLEN 11 /* structure definitions */ struct stats /* player stats */ { char name[21]; /* name */ char pswd[9]; /* password */ char login[10]; /* login */ double x; /* x coord */ double y; /* y coord */ double exp; /* experience */ int lvl; /* level */ short quk; /* quick */ double str; /* strength */ double sin; /* sin */ double man; /* manna */ double gld; /* gold */ double nrg; /* energy */ double mxn; /* max. energy */ double mag; /* magic level */ double brn; /* brains */ short crn; /* crowns */ struct { short type; short duration; } rng; /* ring stuff */ bool pal; /* palantir */ double psn; /* poison */ short hw; /* holy water */ short amu; /* amulets */ bool bls; /* blessing */ short chm; /* charms */ double gem; /* gems */ short quks; /* quicksilver */ double swd; /* sword */ double shd; /* shield */ short typ; /* character type */ bool vrg; /* virgin */ short lastused; /* day of year last used */ short status; /* playing, cloaked, etc. */ short tampered; /* decree'd, etc. flag */ double scratch1, scratch2; /* var's for above */ bool blind; /* blindness */ int wormhole; /* # of wormhole, 0 = none */ long age; /* age in seconds */ short degen; /* age/2500 last degenerated */ }; struct mstats /* monster stats */ { char name[26]; /* name */ double str; /* strength */ double brn; /* brains */ double spd; /* speed */ double hit; /* hits (energy) */ double exp; /* experience */ int trs; /* treasure type */ int typ; /* special type */ int flk; /* % flock */ }; struct nrgvoid /* energy void */ { bool active; /* active or not */ double x,y; /* coordinates */ }; struct worm_hole /* worm hole */ { char f, b, l, r; /* forward, back, left, right */ }; /* files */ #define monsterfile PATH"/monsters" #define peoplefile PATH"/characs" #define gameprog PATH"/phantasia" #define messfile PATH"/mess" #define lastdead PATH"/lastdead" #define helpfile PATH"/phant.help" #define motd PATH"/motd" #define goldfile PATH"/gold" #define voidfile PATH"/void" #define enemyfile PATH"/enemy" extern jmp_buf fightenv, mainenv; extern double strength, speed; extern bool beyond, marsh, throne, valhala, changed, fghting, su, wmhl; extern struct worm_hole w_h[]; extern long secs; extern int fileloc, users; void interrupt(int sig); void strunc(char *str); void update(struct stats *stat, int place); void exit1(void); void getstring(char *cp, int mx); void paws(int where); double inflt(void); ================================================ FILE: games/phantasia/phant.nr ================================================ .de sh .br .ne 5 .PP \fB\\$1\fR .PP .. .TH PHANTASIA 6 "May 20, 1986" .UC 4 .SH NAME phantasia \- an interterminal fantasy game .SH SYNOPSIS .B phantasia [ .B \-s ] [ .B \-m ] [ .B \-a ] [ .B \-x ] [ .B \-h ] [ .B \-H ] [ .B \-p ] .SH DESCRIPTION .I Phantasia is a role playing game vaguely similar to dungeons and dragons. It allows players to roll up characters of various types to fight monsters and other players. Progression of characters is based upon gaining experience from fighting monsters (and other players). .PP Most of the game is menu driven and self-explanatory (more or less). The screen is cursor updated, so be sure to set up the .B TERM variable in your environment. .PP The options provide for a variety of functions to support the game. They are: .PP .TP .5i .B \-s Invokes .I phantasia without header information. .TP .5i .B \-m Get a monster listing. .TP .5i .B \-a Get a listing of all character names on file. .TP .5i .B \-x Examine/change a particular character on file. .TP .5i .B \-h Get a help listing (this message). .TP .5i .B \-H Get header listing only. .TP .5i .B \-p Purge old characters. .PP The characters are saved on a common file, in order to make the game interactive between players. The characters are given a password in order to retrieve them later. Only characters above .B level zero are saved. Characters unused for more than nine days will be purged. .SH AUTHOR Edward Estes, AT&T Teletype Corp. .SH PARTICULARS .sh "Playing in General" Certain of the player's more important statistics are almost always displyed on the screen, with maximums (where applicable) in parentheses. .PP The character is placed randomly near the center of a cartesian system. One may move by hitting .B E, W, N, or .B S (lower case may also be used, at no time is the game case dependent). To move to a particular (x,y) coordinate, use the .B move ('1') command. The distance a character can move is calculated by 1 plus 1.5 per .B level. Moving in a particular compass direction will move the player the maximum allowed distance in that direction. .PP A player may at any time see who else is playing with a .B players ('2') option. One may see only those who are the same distance or closer to the origin as he/she. .B Kings, and .B council of the wise can see and can be seen by everyone. A .B palantir removes these retrictions. .PP One can talk to other players with the .B talk ('3') option. In general, this is a line or so of text. To remove a current message, just type when prompted for a message. .PP The .B stats ('4') option shows a players characteristics in more detail. .PP One may leave the game either with the .B quit ('5') option, or by hitting interrupt. Quitting during battle results in death for obvious reasons. .PP One may rest by default. Resting lets one regain maximum .B energy level, and also lets one find .B manna (more is found for larger levels and further distances from the origin). .PP One may call a monster by hitting '9'. .PP Several other options become available as the player progress in .B level and .B magic, or to other positions in the game ( .B valar, council of the wise, king ). These are described elsewhere. In general, a control-L will force the redrawing of the screen. .PP Other things which may happen are more or less self-explanatory. .sh "Fighting Monsters" A player has several options while fighting monsters. They are as follows: .TP 1.5i .B melee Inflicts damage on the monster, based upon .B strength. Also decreases the monster's .B strength some. .TP 1.5i .B skirmish Inflicts a little less damage than .B melee, but decreases the monster's .B quickness instead. .TP 1.5i .B evade Attempt to run away. Success is based upon both the player's and the monster's .B brains and .B quickness. .TP 1.5i .B spell Several options for throwing spells (described elsewhere). .TP 1.5i .B nick Hits the monster one plus the player's .B sword, and gives the player 10% of the monster's .B experience. Decreases the monster's .B experience an amount proportional to the amount granted. This also increases the monster's quickness. Paralyzed monsters wake up very fast when nicked. .TP 1.5i .B luckout This is essentially a battle of wits with the monster. Success is based upon the player's and the monster's .B brains. The player gets credit for slaying the monster if he/she succeeds. Otherwise, nothing happens, and the chance to .B luckout is lost. .sh "Character Statistics" .TP 1.5i .B strength determines how much damage a character can inflict. .TP 1.5i .B quickness determines how many chances a character gets to make decisions while fighting. .TP 1.5i .B energy level specifies how much damage a character may endure before dying. .TP 1.5i .B magic level determines which spells a character may throw, and how effective those spells will be. .TP 1.5i .B brains basically, the character's intelligence; used for various fighting options and spells. .TP 1.5i .B manna used as a power source for throwing spells. .TP 1.5i .B experience gained by fighting monsters and other characters. .TP 1.5i .B level indicative of how much experience a character has accumulated; progresses geometrically as .B experience increases. .TP 1.5i .B poison sickness which degrades a character's performance (affects .B energy level and .B strength ). .TP 1.5i .B sin accumulated as a character does certain nasty things; used only rarely in normal play of the game. .TP 1.5i .B age number of seconds of playing time for the character. As .B age increases, many personal statistics degenerate. .sh "Character Types" Character statistics are rolled randomly from the above list, according to character type. The types are as follows: .TP 1.5i .B magic user strong in .B magic level and .B brains , weak in other areas. Must rely on wits and magic to survive. .TP 1.5i .B fighter good in .B strength and .B energy level , fairly good in other areas. This adds up to a well-equipped fighter. .TP 1.5i .B elf very high .B quickness and above average .B magic level are .B elves selling points. .TP 1.5i .B dwarf very high .B strength and .B energy level , but with a tendency to be rather slow and not too bright. .TP 1.5i .B halfling rather quick and smart, with high .B energy level , but poor in .B magic and .B strength. Born with some .B experience. .TP 1.5i .B experimento very mediocre in all areas. However, the .B experimento may be placed almost anywhere within the playing grid. .PP The possible ranges for starting statistics are summarized in the following table. .PP .TS l c c c c c c l c c c c c c. Type Strength Quick Manna Energy Brains Magic _ Mag. User 20-25 30-35 50-100 30-45 60-85 5-9 Fighter 40-55 30-35 30-50 45-70 25-45 3-6 Elf 35-45 28-38 45-90 30-50 40-65 4-7 Dwarf 50-70 25-30 25-45 60-100 20-40 2-5 Halfling 20-25 34 25-45 55-90 40-75 1-4 Experimento 25 27 100 35 25 2 .TE .PP Not only are the starting characteristics different for the different character types, the characteristics progress at different rates for the different types as the character goes up in .B level. Experimentoes' characteristics progress randomly as one of the other types. The progression as characters increase in .B level is summarized in the following table. .PP .TS l c c c c c l n n n n n. Type Strength Manna Energy Brains Magic _ Mag. User 2.0 75 20 6 2.75 Fighter 3.0 40 30 3.0 1.5 Elf 2.5 65 25 4.0 2.0 Dwarf 5 30 35 2.5 1 Halfling 2.0 30 30 4.5 1 .TE .PP Character types are identified by certain numeric values as follows: .br 1: .B Magic User 2: .B Fighter 3: .B Elf 4: .B Dwarf 5: .B Halfling 6: .B Experimento .PP Characters with one or more .B crowns are designated as a negative type. .B Kings have ten added to their type; members of the .B council of the wise have twenty added to their type. .B Valar are type 99, and .B ex-valar are type 90. .sh "Spells" During the course of the game, the player may exercise his/her particular magic powers. These cases are described below. .TP 1.5i .B cloak .I magic level necessary: 15 (plus level 5) .br .I manna used: 35 plus 3 per rest period .br Used during normal play. Prevents monsters from finding the character, as well as hiding the player from other players. His/her coordinates show up as '?' in the .B players option. Players cannot collect .B manna, find trading posts, or discover the .B grail while cloaked. Calling a monster uncloaks, as well as choosing this option while cloaked. .br .TP 1.5i .B teleport .I magic level necessary: 25 (plus level 10) .br .I manna used: 20 per 75 moved .br Used during normal play. Allows the player too move with much more freedom than with the .B move option, at the price of expending manna. The maximum distance possible to move is based upon .B level and .B magic level. .TP 1.5i .B power blast .I magic level necessary: none .br .I manna used: 5 times .B level .br Used during inter-terminal battle. Damage is based upon .B magic level and .B strength. Hits much harder than a normal hit. .TP 1.5i .B all or nothing .I magic level necessary: none .br .I manna used: 1 .br Used while combatting monsters. Has a 25% chance of working. If it works it hits the monster just enough to kill it. If it fails, it doesn't hit the monster, and doubles the monster's .B quickness and .B strength. Paralyzed monsters wake up much quicker as a result of this spell. .TP 1.5i .B magic bolt .I magic level necessary: 3 .br .I manna used: variable .br Used while combatting monsters. Hits the monster based upon the amount of .B manna expended and .B magic level. Guaranteed to hit at least 10 per .B manna. .TP 1.5i .B force field .I magic level necessary: 7 .br .I manna used: 20 .br Used during monster combat. Throws up a shield to protect from damage. The shield is added to actual energy level, and is a fixed number, based upon maximum energy. Normally, damage occurs first to the shield, and then to the players actual .B energy level. .TP 1.5i .B transform .I magic level necessary: 10 .br .I manna used: 35 .br Used during monster combat. Transforms the monster randomly into one of the other 100 monsters from the monster file. .TP 1.5i .B increase might .I magic level necessary: 15 .br .I manna used: 55 .br Used during combat with monsters. Increases strength up to a certain maximum. .TP 1.5i .B invisibility .I magic level necessary: 20 .br .I manna used: 45 .br Used while fighting monsters. Makes it harder for the monster to hit, by temporarily increasing the player's .B quickness. This spell may be thrown several times, but a maximum level will be reached. .TP 1.5i .B transport .I magic level necessary: 25 .br .I manna used: 50 .br Used during monster combat. Transports the monster away from the player. Success is base upon player's .B magic and .B brains, and the monster's .B experience. If it fails the player is transported instead. 60% of the time, the monster will drop any treasure it was carrying. .TP 1.5i .B paralyze .I magic level necessary: 30 .br .I manna used: 60 .br Used during monster combat. "Freezes" the monster by putting its .B quickness slightly negative. The monster will slowly wake up. Success is based upon player's .B magic and the monster's .B experience. If it fails, nothing happens. .TP 1.5i .B specify .I magic level necessary: none .br .I manna used: 1000 .br Used during monster combat only by .B valar or .B council of the wise. Allows the player to pick which monster to fight. .sh "Monsters" Monsters get bigger as one moves farther from the origin (0,0). Rings of distance 125 from the origin determine the size. A monster's .B experience, energy level, and .B brains are multiplied by the size. .B Strength is increase 50% per size over one, and .B quickness remains the same, regardless of size. .PP Also, meaner monsters are to be found as one progress farther out from the origin. Monsters also may flock. The percent chance of that happening is designated as .B flock% in the monster listing. Monsters outside the first ring may carry treasure, as determined by their treasure type. Flocking monsters, and bigger monsters increase the chances of treasure. .PP Certain monsters have special abilities; they are as follows: .TP 1.5i .B Unicorn can only be subdued if the player is in possession of a .B virgin. .TP 1.5i .B Modnar has random characteristics, including treasure type. .TP 1.5i .B Mimic will pick another name from the list of monsters in order to confuse. .TP 1.5i .B Dark Lord very nasty person. Does not like to be hit (especially nicked), and many spells do not work well against him. One can always .B evade from the .B Dark Lord. .TP 1.5i .B Leanan-Sidhe also a very nasty person. She will permanently sap .B strength from someone. .TP 1.5i .B Saruman wanders around with .B Wormtongue , who can steal a .B palantir. Also, .B Saruman may turn a player's gems into gold pieces, or scramble her/his stats. .TP 1.5i .B Thaumaturgist can transport a player. .TP 1.5i .B Balrog inflicts damage by taking away .B experience , not .B energy. .TP 1.5i .B Vortex may take some .B manna. .TP 1.5i .B Nazgul may try to steal a .B ring or neutralize part of one's .B brains. .TP 1.5i .B Tiamat may take half a players .B gold and .B gems and escape. .TP 1.5i .B Kobold may get nasty and steal one gold piece and run away. .TP 1.5i .B Shelob may bite, inflicting the equivalent of one .B poison. .TP 1.5i .B Assorted Faeries These are killed if attacking someone carrying .B holy water. These are .B Cluricaun, Fir Darrig, Fachan, .B Ghille Dhu, Bogle, Killmoulis, and .B Bwca. .TP 1.5i .B Lamprey may bite, inflicting 1/2 of a .B poison. .TP 1.5i .B Shrieker will call one of its (much bigger) buddies if picked upon. .TP 1.5i .B Bonnacon will become bored with battle, fart, and run off. .TP 1.5i .B Smeagol will try to steal a .B ring from a player, if given the chance. .TP 1.5i .B Succubus may inflict damage through a .B force field. This subtracts from .B energy level instead of any shield the player may have thrown up. This is a very easy way to die. .TP 1.5i .B Cerberus loves metal and will steal all the metal treasures from a player if able. .TP 1.5i .B Ungoliant can bite and poison. This inflicts five .B poisons , and also takes one from the player's .B quickness. .TP 1.5i .B Jabberwock may tire of battle, and leave after calling one of his friends ( .B Jubjub Bird or .B Bandersnatch ). .TP 1.5i .B Morgoth actually .B Modnar , but reserved for .B council of the wise, valar, and .B ex-valar. Fights with .B Morgoth end when either he or the player dies. His characteristics are calculated based upon the player's. The player is given the chance to ally with him. No magic, except .B force field works when battling .B Morgoth. .TP 1.5i .B Troll may regenerate its .B energy and .B strength while in battle. .TP 1.5i .B Wraith may make a player blind. .sh "Treasures" Various treasure types are as follows: .TP 1.5i .B Type zero .I none .TP 1.5i .B Type one .I power booster \- adds manna. .br .I druid \- adds experience. .br .I holy orb \- subtracts 0.25 sin. .TP 1.5i .B Type two .I amulet \- protects from cursed treasure. .br .I holy water \- kills .B assorted faeries. .br .I hermit \- reduces sin by 25% and adds some manna. .TP 1.5i .B Type three .I shield \- adds to maximum .B energy level .br .I virgin \- used to subdue a .B unicorn , or to give much .B experience (and some .B sin ). .br .I athelas \- subtracts one .B poison. .TP 1.5i .B Type four (scrolls) .I shield * \- throws a bigger than normal .B force field. .br .I invisible * \- puts the finder's .B quickness to one million. .br .I ten fold strength * \- multiplies finder's strength by ten. .br .I pick monster \- allows finder to pick next monster to battle. .br .I general knowledge \- adds to finder's .B brains and .B magic level. .PP All the scrolls except .B general knowledge automatically call a monster. Those that are marked with a * preserve any spells that were already in effect. Those that call monsters are only in effect while in battle. .TP 1.5i .B Type five .I dagger \- adds to .B strength. .br .I armour \- same as a .B shield, but bigger. .br .I tablet \- adds brains. .TP 1.5i .B Type six .I priest \- rests to maximum; adds .B manna, brains; and halves .B sin. .br .I Robin Hood \- increases .B shield and adds permanently to .B strength. .br .I axe \- like .B dagger, but bigger. .TP 1.5i .B Type seven .I charm \- protects from cursed treasure (used before .B amulet ); used in conjunction with .B blessing to battle .B Dark Lord. .br .I Merlyn \- adds .B brains, magic, and .B manna. .br .I war hammer \- like an .B axe, but bigger. .TP 1.5i .B Type eight .I healing potion \- sets .B poison to -2, or subtracts two from .B poison, whichever is better. .br .I transporter \- allows finder to move anywhere. .br .I sword \- like a .B war hammer , but bigger. .TP 1.5i .B Type nine .I golden crown \- allows the player to become .B king, by going to (0,0). .br .I blessing \- cuts .B sin to 1/3, adds .B manna, rests to max., and kills .B Dark Lord with a .B charm. .br .I quicksilver \- adds to .B quickness. .TP 1.5i .B Type ten .I elven boots \- adds permanently to .B quickness. .TP 1.5i .B Type eleven .I palantir \- allows one to see all the other players; used by .B council of the wise to seek the .B grail. .TP 1.5i .B Type twelve/thirteen .I ring \- allows one to hit much harder in battle, etc. .PP Any treasure type 10-13 monsters may instead carry a type nine treasure. .PP A monster may also be carrying .B gold or .B gems. These are used at .B trading posts to buy things. A .B gem is worth 1000 gold pieces. Too much .B gold will slow a player down. One may carry 1000 plus 200 per .B level of .B gold. A .B gem weighs one half a gold piece. Monsters of treasure type 7 or higher may carry .B gems. .PP The chance of a cursed treasure is based upon treasure type. The more valuable treasures have a greater chance of being cursed. A cursed treasure knocks .B energy level very low, and adds 0.25 .B poison. .sh "Rings" .B Rings are only carried by .B nazguls and .B Dark Lord. They come in four different flavors. All .B rings rest the player to maximum and cause him/her to hit much harder in battle with monsters (assuming one has chosen to use the .B ring for battle.) .PP Two types of .B rings are cursed and come either from .B nazguls or .B Dark Lord. After a few times of using these types, the player falls under the control of the .B ring, and strange, random things will occur. Eventually, the player dies, and gives his/her name to a monster on the file. Dying before the .B ring is used up also renames the monster. .PP The two remaining types of .B rings are much more benign. The one from a .B nazgul is good for a limited number of battle rounds, and will save the player from death if it was being used when he/she died. The one from .B Dark Lord is the same, except that it never is used up. .B rings disappear after saving someone from death. In general, cursed .B rings occur much more often than normal ones. It is usually not a good idea to pick one up. The only way to get rid of a .B ring is to have a monster steal it. .sh "King" A player may become .B king by finding a .I crown and going to (0,0). Players must have a .B level in the range of 10 to 1000 to be able to find a .I crown. .PP Once a player is king, he/she may do certain things while in the Lord's Chamber (0,0). These fall under the .B decree ('0') option. .TP 1.5i .I transport This is done to another player. It randomly moves the affected player about. A .B charm protects from transports. .TP 1.5i .I curse This is done to another player. It is analogous to cursed treasure, but worse. It inflicts two .B poison, knocks .B energy level very low, and degrades the maximum energy. It also removes a .B cloak. A .B blessing protects from king's curses. .TP 1.5i .I energy void The king may put as many of these (within reason) scattered about his/her kingdom as he/she pleases. If a player hits one, he/she loses .B manna, energy, and .B gold. The energy void disappears after being hit. .TP 1.5i .I bestow This is also done to another player. The king may wish to reward one or more loyal subjects by sharing his/her riches ( .B gold ). Or it is a convenient way to dispose of some unwanted deadweight. .TP 1.5i .I collect taxes Everyone pays 10% tax on all .B gold collected, regardless of the existence of a .B king. The king may collect this amount with this option. .PP The .B king may also .B teleport anywhere for free by using the origin as a starting place. .sh "Special Places" Certain regions of the playing grid have different names. In general, this is only to give the player some idea of his/her present location. Some special places do exist. .TP 1.5i .I Trading Posts These are located at |x| == |y| == n*n*100 for n = 1, 2...1000. Trading posts farther out have more things for sale. Be careful about cheating merchants there, as they have short tempers. Merchants are dishonest about 5% of the time. .TP 1.5i .I Lord's Chamber This is located at (0,0). Only players with .B crowns may enter. .TP 1.5i .I Point of No Return This is located beyond 1.2e+6 in any direction. The only way to return from here is a .B transporter or to have a .B valar relocate the player. .TP 1.5i .I Dead Marshes This is a band located fairly distant from the origin. The first fourteen monsters (water monsters) can normally only be found here. .TP 1.5i .I Valhala This place is where the .B valar resides. It is associated with no particular coordinate on the playing grid. .TP 1.5i .I Wormholes At fixed locations on the grid are several holes to underground defects in the playing area. Sixty-four chambers exist; sixteen of which open to the outside world. While in the wormholes, one move by going forward, backward, left, or right. One can always undo a move by going in the opposite direction. The wormholes are mappable. For example, to move from the first wormhole {at (-400,0)} to the second wormhole, type 'LL'. .sh "Miscellaneous" There are several bits of trivial knowledge which fall under this category. .PP A .I guru will never be disgusted with your .B sins if they are less than one. .PP A .I medic wants half of a player's .B gold to be happy. Offering more than one has, or a negative amount will anger the .I medic, who will make the player worse (add one .B poison ). .PP The .B Holy Grail does little for those who are not ready to behold it. Whenever anyone finds it, it moves. It is always located within 1e+6 in any compass direction of the origin. .PP There is a maximum amount of .B manna and .B charms a player may posses, based upon .B level. .I Quicksilver is always limited to to a maximum of 99. .PP .I Books bought at a .B trading post increase .B brains, based upon the number bought. It is unwise, however to buy more than 1/10 of one's .B level in books at a time. .PP Players over level 10000 are automatically retired. .PP A .I blindness goes away in random time. .sh "Inter-terminal Battle" When two player's coordinates correspond, they may engage in battle. In general, the player with the highest .B quickness gets the first hit. If the two players are severely mis-matched, the stronger player is drastically handicapped for the battle. In order to protect from being stuck in an infinite loop, the player waiting for response may time out. Options for battle are: .TP 1.5i .I fight Inflicts damage upon other person. .TP 1.5i .I run away Escape from battle. Has a 75% chance of working. .TP 1.5i .I power blast Battle spell. .TP 1.5i .I luckout One-time chance to try to win against the foe. Has a 10% chance of working. .PP Sometimes waits for the other player may be excessive, because he/she may be battling a monster. Upon slaying a player in battle the winner gets the other's .B experience and treasures. .B Rings do not work for inter-terminal battle. .sh "Council of the Wise, Valar" A player automatically becomes a member of the .B council of the wise upon reaching level 3000. Members of the council cannot have .B rings. Members of the council have a few extra options which they can exercise. These fall under the .B intervention ('8') option. One is to .I heal another player. This is just a quick way for that player to be rested to maximum and lose a little .B poison. The main purpose in life for members of the council is to seek the .B Holy Grail. This is done with a .B palantir under the .I seek grail option. The distance cited by the seek is accurate within 10%, in order not to make it too easy to find the grail. Seeking costs 1000 .B manna. A player must have infintesimally small .B sin, or else it's all over upon finding the grail. In order to help members of the council on their quest, they may .I teleport with greater ease. .PP Upon finding the grail, the player advance to position of .B valar. He/she may then exercise more and niftier options under .I intervention. These include all of the council members' option plus the ability to move other players about, bless them, and throw monsters at them. .B Valar are essentially immortal, but are actually given five lives. If these are used up, the player is left to die, and becomes an .B ex-valar. .B Valar cannot .I move, teleport, or call monsters. Any monsters which a .B valar encounters are based upon his/her size. Only one valar may exists at a time. A player replaces the exiting valar upon finding the grail. The valar is then bumped back to the council of the wise. .SH BUGS Many. The whole program is a hack. The handling of incorrectly exitted characters is a kludge. The screen is set up assuming a 24 by 80 character screen; no attempt was made to provide otherwise. If the program is not set uid, it crashes on the first attempt to open a data file. If any of the data items get too big for the allotted space on the screen, no guarantees are made about what will happen. There should be a way to change a character's name. ================================================ FILE: games/phantasia/phant_run.c ================================================ /* This is a program to run phantasia David Wells, May, 1986 */ main(argc, argv) int argc; char **argv; { char tmp[160]; strcat(tmp,"exec nice /usr/games/lib/phantasia/phantasia "); if (argc > 1) strcat(tmp,argv[1]); system(tmp); } ================================================ FILE: games/phantasia/setfiles.c ================================================ /* * setfiles.c Program to set up all files for Phantasia * * This program tries to verify the parameters specified in * the Makefile. Since Phantasia assumes its files exist, * simple errors can result in core dumps. * * This program tries to check against this. */ #include "phant.h" #include #include int main(argc,argv) /* program to init. files for Phantasia */ int argc; char **argv; { FILE *fp; struct stats sbuf; struct nrgvoid grail; struct stat fbuf; register int loop; int foo; char stbuf[128]; #ifdef notdef srand((int) time(NULL)); /* prime random numbers */ /* try to check RAND definition */ for (loop = 1000; loop; loop--) { if ((foo = rand()) > ((int) RAND)) { sprintf(stbuf,"%f %f",(double) RAND, (double) foo); Error("%s is a bad value for RAND.\n",stbuf); } } #endif umask(077); /* check where Phantasia lives */ if (stat(PATH, &fbuf) < 0) { perror(PATH); exit(1); /*NOTREACHED*/ } if (fbuf.st_mode & S_IFDIR == 0) Error("%s is not a directory.\n", PATH); /* try to create data files */ if ((fp = fopen(goldfile,"w")) == NULL) Error("cannot create %s.\n",goldfile); else fclose(fp); if ((fp = fopen(motd,"w")) == NULL) Error("cannot create %s.\n",motd); else fclose(fp); if ((fp = fopen(messfile,"w")) == NULL) Error("cannot create %s.\n",messfile); else fclose(fp); /* do not reset character file if it already exists */ if (stat(peoplefile,&fbuf) < 0) { buildchar(&sbuf); strcpy(sbuf.name,""); if ((fp = fopen(peoplefile,"w")) == NULL) Error("cannot create %s.\n",peoplefile); else { fwrite(&sbuf,sizeof(sbuf),1,fp); fclose(fp); } } grail.active = TRUE; grail.x = roll(-1.0e6,2.0e6); grail.y = roll(-1.0e6,2.0e6); if ((fp = fopen(voidfile,"w")) == NULL) Error("cannot create %s.\n",voidfile); else { fwrite(&grail,sizeof(grail),1,fp); fclose(fp); } if ((fp = fopen(lastdead,"w")) == NULL) Error("cannot create %s.\n",lastdead); else { fputs(" ",fp); fclose(fp); } #ifdef ENEMY if ((fp = fopen(enemyfile,"w")) == NULL) Error("cannot create %s.\n",enemyfile); else { /* comment this out for now fprintf(fp,"# Use this file to restrict access from obnoxious users.\n"); fprintf(fp,"# Just put the login names of those restricted, one per\n"); fprintf(fp,"# line, below.\n"); */ fclose(fp); } #endif if (getuid() != UID) fprintf(stderr,"Warning: UID (%d) is not equal to current uid.\n",UID); } /* * Note that this function is almost the same as initchar(). * t is used to insure that unexpected values will not be found in a * new character file. */ buildchar(stat) /* put in some default values */ struct stats *stat; { stat->x = roll(-125,251); stat->y = roll(-125,251); stat->exp = stat->lvl = stat->sin = 0; stat->crn = stat->psn = 0; stat->rng.type = NONE; stat->rng.duration = 0; stat->pal = FALSE; stat->hw = stat->amu = stat->bls = 0; stat->chm = 0; stat->gem = 0.1; stat->gld = roll(25,50) + roll(0,25) + 0.1; stat->quks = stat->swd = stat->shd = 0; stat->vrg = FALSE; stat->typ = 0; } Error(str,file) /* print an error message, and exit */ char *str, *file; { fprintf(stderr,"Error: "); fprintf(stderr,str,file); exit(1); /*NOTREACHED*/ } ================================================ FILE: games/phantasia/test.c ================================================ main() { double Too_Big = 987654321; temp = Too_Big; printf("Too_Big = %f, temp = %d/n",&Too_Big, &temp); } ================================================ FILE: games/warp/.gitignore ================================================ !smp.0 ================================================ FILE: games/warp/EXTERN.h ================================================ /* $Header: EXTERN.h,v 7.0.1.1 86/12/12 16:46:50 lwall Exp $ * * $Log: EXTERN.h,v $ * Revision 7.0.1.1 86/12/12 16:46:50 lwall * Guarded the undefs. * * Revision 7.0 86/10/08 15:11:31 lwall * Split into separate files. Added amoebas and pirates. * */ #ifdef EXT #undef EXT #endif #define EXT extern #ifdef INIT #undef INIT #endif #define INIT(x) #ifdef DOINIT #undef DOINIT #endif ================================================ FILE: games/warp/INTERN.h ================================================ /* $Header: INTERN.h,v 7.0.1.1 86/12/12 16:51:45 lwall Exp $ * * $Log: INTERN.h,v $ * Revision 7.0.1.1 86/12/12 16:51:45 lwall * Guarded the undefs. * * Revision 7.0 86/10/08 15:11:37 lwall * Split into separate files. Added amoebas and pirates. * */ #ifdef EXT #undef EXT #endif #define EXT #ifdef INIT #undef INIT #endif #define INIT(x) = x #define DOINIT ================================================ FILE: games/warp/MANIFEST ================================================ After all the warp kits are run you should have the following files: Filename Kit Description -------- --- ----------- Configure 1 An entertaining little shell script EXTERN.h 6 Set up for external .h files INTERN.h 6 Set up for internal .h files MANIFEST 1 This file Makefile.SH 5 Makefile for warp README 5 Instructions--please read bang.c 5 Routines having to do with blast propagation bang.h 6 Visible declarations for above config.H 4 Sample config.h for if you can't Configure init.c 3 Initialization for a wave. init.h 2 Visible declarations for above intrp.c 4 Code to interpret % substitutions intrp.h 6 Visible declarations for above makedepend.SH 6 Generates makefile dependencies makedir.SH 6 Makes multilevel directories move.c 3 Object movement and display move.h 6 Visible declarations for above ndir.c 5 Directory manipulation routines ndir.h 5 Visible declarations for above object.c 6 Object management object.h 6 Visible declarations for above patchlevel.h 4 How patched the kit is play.c 5 What to do each second play.h 6 Visible declarations for above score.c 2 Scoring and saving score.h 6 Visible declarations for above sig.c 5 Signal handling sig.h 6 Visible declarations for above sm.c 6 Starmap translator smp.0 3 "Straight Grid" scenario smp.1 6 "Offset Grid" scenario smp.2 6 "Shooting Gallery" scenario smp.3 6 "Superfortress" scenario smp.4 6 "Blocks" scenario smp.5 6 "Microfortress" scenario smp.6 6 "Passage" scenario smp.7 6 "Wall" scenario term.c 2 Terminal handling term.h 5 Visible declarations for above them.c 5 Smarts for enemies them.h 6 Visible declarations for above us.c 4 Smarts for us us.h 6 Visible declarations for above util.c 1 Utility routines util.h 5 Visible declarations for above version.c 6 Prints version number. version.h 1 Visible declarations for above warp.c 2 Main loop warp.doc 4 How to play warp warp.h 4 Visible declarations for everyone warp.man 5 How to start warp warp.news 5 Sample startup message weapon.c 3 Our firepower weapon.h 6 Visible declarations for above ================================================ FILE: games/warp/Makefile ================================================ TOPSRC!=cd ../..; pwd include ${TOPSRC}/share/mk/sys.mk CFLAGS += -Os -Wall OBJS = bang.o init.o intrp.o move.o \ object.o play.o score.o \ sig.o term.o them.o us.o \ util.o version.o warp.o weapon.o LIBS = -ltermcap -lm MAN = warp.0 MANSRC = warp.man PRIVATE = warp.doc smap.0 smap.1 smap.2 smap.3 smap.4 smap.5 smap.6 smap.7 PRIVLIB = ${DESTDIR}/usr/games/lib/warp all: warp $(MAN) $(PRIVATE) warp: ${OBJS} ${CC} ${CFLAGS} ${LDFLAGS} -o warp.elf ${OBJS} ${LIBS} ${OBJDUMP} -S warp.elf > warp.dis ${SIZE} warp.elf ${ELF2AOUT} warp.elf $@ && rm warp.elf smap.0: smp.0 sm ./sm smap.0 smap.1: smp.1 sm ./sm smap.1 smap.2: smp.2 sm ./sm smap.2 smap.3: smp.3 sm ./sm smap.3 smap.4: smp.4 sm ./sm smap.4 smap.5: smp.5 sm ./sm smap.5 smap.6: smp.6 sm ./sm smap.6 smap.7: smp.7 sm ./sm smap.7 sm: sm.c ${HOST_CC} -O -Wall sm.c -o sm ${MAN}: ${MANSRC} ${MANROFF} ${MANSRC} > $@ clean: rm -f *.o *.elf ${MAN} warp *.elf *.dis tags *~ smap.* sm install: warp $(PRIVATE) ${INSTALL} warp ${DESTDIR}/usr/games/ cp ${MAN} ${DESTDIR}/usr/share/man/cat6/ mkdir -p $(PRIVLIB) cp $(PRIVATE) $(PRIVLIB) cp /dev/null $(PRIVLIB)/save.blurfl [ -f $(PRIVLIB)/warp.news ] || cp warp.news $(PRIVLIB) ================================================ FILE: games/warp/Makefile-linux ================================================ # $Header: Makefile.SH,v 1.1 87/07/03 01:45:30 games Exp $ # # Revision 7.0.1.1a 87/26/08 03:45:03 games # Fix minor shell continuation bug and put in a pdp-11 overlay scheme. # # Revision 7.0.1.1 86/12/12 16:54:03 lwall # Frozen for net release. # # Revision 7.0 86/10/08 15:11:42 lwall # Split into separate files. Added amoebas and pirates. # # CFLAGS = -g -O -DTERMIO #-Wall LDFLAGS = PRIVLIB = /usr/games/lib/warp LIBS = -ltermcap -lm PRIVATE = warp.doc smap.0 smap.1 smap.2 smap.3 smap.4 smap.5 smap.6 smap.7 OBJ = bang.o init.o intrp.o move.o \ object.o play.o score.o \ sig.o term.o them.o us.o \ util.o version.o warp.o weapon.o all: warp $(PRIVATE) warp: $(OBJ) $(CC) $(LDFLAGS) $(OBJ) $(LIBS) -o warp install: warp $(PRIVATE) install warp $(bin) mkdir -p $(PRIVLIB) cp $(PRIVATE) $(PRIVLIB) cp /dev/null $(PRIVLIB)/save.blurfl [ -f $(PRIVLIB)/warp.news ] || cp warp.news $(PRIVLIB) clean: rm -f core *.o warp smap.* sm smap.0: smp.0 sm ./sm smap.0 smap.1: smp.1 sm ./sm smap.1 smap.2: smp.2 sm ./sm smap.2 smap.3: smp.3 sm ./sm smap.3 smap.4: smp.4 sm ./sm smap.4 smap.5: smp.5 sm ./sm smap.5 smap.6: smp.6 sm ./sm smap.6 smap.7: smp.7 sm ./sm smap.7 sm: sm.c cc -O -Wall sm.c -o sm ================================================ FILE: games/warp/README ================================================ Warp Kit, Version 7.0 Copyright (c) 1986, Larry Wall You may copy the warp kit in whole or in part as long as you don't try to make money off it, or pretend that you wrote it. -------------------------------------------------------------------------- Warp is a real-time space war game that doesn't get boring very quickly. Read warp.doc and the manual page for more information. Warp will probably not run on V7 systems that don't have a non-blocking read, or on machines with a small address space like the PDP-11. Caveat Emptor. Please read all the directions below before you proceed any further, and then follow them carefully. Failure to do so may void your warranty. :-) After you have unpacked your kit, you should have all the files listed in MANIFEST. IMPORTANT You must choose the uid that you want warp to run under, since warp runs setuid to protect its files. Choose a uid (not root) that is used only by trustworthy persons. If you do your make install as root, the installed version will be chowned to this uid. Otherwise, you should login to your selected uid before proceeding. The Configure script will ask you which uid you want warp to run under. Installation 1) Run Configure. This will figure out various things about your system. Some things Configure will figure out for itself, other things it will ask you about. It will then proceed to make config.h, config.sh, and Makefile. You might possibly have to trim # comments from the front of Configure if your sh doesn't handle them, but all other # comments will be taken care of. (If you don't have sh, you'll have to copy the sample file config.H to config.h and edit the config.h to reflect your system's peculiarities.) 2) Glance through config.h to make sure system dependencies are correct. Most of them should have been taken care of by running the Configure script. If you have any additional changes to make to the C definitions, they can be done in the Makefile, or in config.h. Bear in mind that they will get undone next time you run Configure. 3) make depend This will look for all the includes and modify Makefile accordingly. Configure will offer to do this for you. 4) make This will attempt to make warp in the current directory. 5) make install This will put warp into a public directory (normally /usr/games). It will also try to put the man pages in a reasonable place. It will not nroff the man page, however. You may need to be root to do this. If you are not root, you must own the directories in question and you should ignore any messages about chown not working. 6) Read the manual entry before running warp. 7) Feel free to edit warp.news. 8) IMPORTANT! Help save the world! Communicate any problems and suggested patches to me, lwall@sdcrdcf.UUCP (Larry Wall), so we can keep the world in sync. If you have a problem, there's someone else out there who either has had or will have the same problem. If possible, send in patches such that the patch program will apply them. Context diffs are the best, then normal diffs. Don't send ed scripts-- I've probably changed my copy since the version you have. Watch for warp patches in comp.sources.bugs. Patches will generally be in a form usable by the patch program. If you are just now bringing up warp and aren't sure how many patches there are, write to me and I'll send any you don't have. Your current patch level is shown in patchlevel.h. NEW FEATURES IN THIS RELEASE Uses a Configure script for greater portability. Space Amoebas!!! Pirates Friendly Freighters Harry Mudd Damage Keyboard mapping ================================================ FILE: games/warp/bang.c ================================================ /* $Header: bang.c,v 7.0.1.3 86/12/12 16:57:00 lwall Exp $ */ /* $Log: bang.c,v $ * Revision 7.0.1.3 86/12/12 16:57:00 lwall * Made circular explosions. * * Revision 7.0.1.2 86/10/20 14:36:02 lwall * Picked some lint. * * Revision 7.0.1.1 86/10/16 10:49:45 lwall * Added Damage. Fixed random bugs. * * Revision 7.0 86/10/08 15:11:57 lwall * Split into separate files. Added amoebas and pirates. * */ #include "EXTERN.h" #include "warp.h" #include "object.h" #include "move.h" #include "sig.h" #include "term.h" #include "them.h" #include "INTERN.h" #include "bang.h" void bang_init() { ; } void make_plink(y,x) register int x; register int y; { register OBJECT *obj; move(y+1,x*2,0); beg_qwrite(); *filler = '@'; qwrite(); obj = occupant[y][x]; if (obj) { if (numamoebas && obj->image == ' ') qaddc(amb[y][x]); else qaddc(obj->image); } else if (numamoebas) qaddc(amb[y][x]); else qaddspace(); end_qwrite(); } void make_blast(y,x,mass,size) register int x; register int y; int size; long mass; { bangy[nxtbang] = y; bangx[nxtbang] = x; bangm[nxtbang] = mass; bangs[nxtbang++] = size; assert(nxtbang <= XSIZE * YSIZE); if (numamoebas && amb[y][x] == '~') { if (mass > 10000) modify_amoeba(y,x,1,'~', 10); else if (mass > 100) modify_amoeba(y,x,1,'~', 5); bangs[nxtbang-1] = 0; /* don't propagate */ return; } else if (mass >= 0) { register OBJECT *obj; move(y+1,x*2,0); beg_qwrite(); *filler = '@'; qwrite(); *filler = '#'; qwrite(); *filler = '@'; qwrite(); *filler = '#'; qwrite(); *filler = '@'; qwrite(); obj = occupant[y][x]; if (obj) { if (numamoebas && obj->image == ' ') qaddc(amb[y][x]); else qaddc(obj->image); } else if (numamoebas) qaddc(amb[y][x]); else qaddspace(); end_qwrite(); } } void do_bangs() { register int x; register int y; register int i; register int j; register int k; register int lastxy; register OBJECT *obj; /* read blast list and update blast array */ assert(nxtbang >= 0 && nxtbang <= XSIZE * YSIZE); for (i=0; i= MAXBDIST) lastxy = MAXBDIST - 1; for (y=bangy[i]-bangs[i],x=bangx[i]-bangs[i],j=lastxy; j>=0; y++,x++,--j) { yblasted[yy[j] = (y+YSIZE00) % YSIZE] |= 1; xblasted[xx[j] = (x+XSIZE00) % XSIZE] |= 1; } blasted = TRUE; for (y=lastxy;y>=0;--y) { for (x=lastxy;x>=0;--x) { if (lastxy > 2) { j = abs(y-bangs[i]); k = abs(x-bangs[i]); if (j < k) /* distance is long + 1/2 short */ j += k + k; else j += j + k; if (--j > lastxy) continue; } if (bangm[i] != 32767 || !(obj=occupant[yy[y]][xx[x]]) || obj->type != Web) blast[yy[y]][xx[x]] += bangm[i]; } } } } ================================================ FILE: games/warp/bang.h ================================================ /* $Header: bang.h,v 7.0 86/10/08 15:12:03 lwall Exp $ */ /* $Log: bang.h,v $ * Revision 7.0 86/10/08 15:12:03 lwall * Split into separate files. Added amoebas and pirates. * */ EXT long blast[YSIZE][XSIZE]; EXT bool blasted; EXT bool xblasted[XSIZE]; EXT bool yblasted[YSIZE]; EXT char bangy[YSIZE*XSIZE]; EXT char bangx[YSIZE*XSIZE]; EXT char bangs[YSIZE*XSIZE]; EXT long bangm[YSIZE*XSIZE]; #define MAXBDIST 40 EXT int xx[MAXBDIST]; EXT int yy[MAXBDIST]; EXT int nxtbang; EXT bool banging; void make_plink(); void make_blast(); void do_bangs(); void bang_init(); ================================================ FILE: games/warp/init.c ================================================ /* $Header: init.c,v 7.0.1.4 86/12/12 16:58:03 lwall Exp $ */ /* $Log: init.c,v $ * Revision 7.0.1.4 86/12/12 16:58:03 lwall * Baseline for net release. * * Revision 7.0.1.3 86/10/20 14:35:31 lwall * Picked some lint. * * Revision 7.0.1.2 86/10/17 15:53:30 lwall * Added random walk star fields. * * Revision 7.0.1.1 86/10/16 10:51:19 lwall * Added Damage. Fixed random bugs. * * Revision 7.0 86/10/08 15:12:10 lwall * Split into separate files. Added amoebas and pirates. * */ #include "EXTERN.h" #include "warp.h" #include "bang.h" #include "object.h" #include "move.h" #include "play.h" #include "score.h" #include "term.h" #include "them.h" #include "us.h" #include "util.h" #include "weapon.h" #include "INTERN.h" #include "init.h" void initialize() { register int i; register int x; register int y; register int dist; register int ydist; register int xdist; long e; int yoff, xoff, ypred, xpred; register OBJECT *obj; char ch; FILE *mapfp = NULL; bool tmptholspec; int inhabjackpot; long inhenergy; int walksplit = 200; static char *distname[] = {" #"," -"," \\"," /", " |"," *"," `"," '"}; cloaking = madgorns = FALSE; deados = madfriends = 0; curscore = possiblescore = 0L; yamblast = xamblast = ambsize = 0; if (smarts > 90) massacre = TRUE; scandist = (massacre?20:15); antibase = (smarts>60?1:(smarts>40?2:(smarts>25?4:100))); sm35 = (smarts>35?35:smarts); sm45 = (smarts>45?45:smarts); sm50 = (smarts>50?50:smarts); sm55 = (smarts>55?55:smarts); sm80 = (smarts>80?80:smarts); sm95 = (smarts>95?95:smarts); super = (smarts>50?smarts-50:0); enemshields = 10 + super/2; /* (scaled by 10) 1 @ 50 .. 3 @ 90 */ if (smarts>90) enemshields += (smarts-90)*10; /* lay it on thick: ~13 @ 99 */ entmax = (smarts>=75?5000:(smarts>=50?4000:(smarts>=40?3000:2000))); basemax = (smarts>=75?20000:(smarts>=50?15000:(smarts>=40?12500:10000))); clear(); while (root.next != &root) { root.next = root.next->next; free_object(root.next->prev); } root.prev = &root; enemies = movers = NULL; numos = numxes = 0; for (y=0;y 85) inumstars = exdis(800) + rand_mod(100) + 1; else /* too few stars makes 50..85 too hard */ inumstars = exdis(700) + rand_mod(150-super*2) + 50+super*2; tmptholspec = (smarts > 15 && inumstars < 450 && ! rand_mod(90-sm80)); if (!klingspec) { inumenemies = rand_mod((smarts+1)/2) + 1; if (massacre || tmptholspec) inumenemies += 10; } if (!friendspec) inumfriends = rand_mod(smarts/8+1); if (!piratespec) inumpirates = rand_mod(inumfriends/2+1); if (inumfriends+inumenemies+inumstars > YSIZE*XSIZE-20) inumstars = YSIZE*XSIZE-20 - inumenemies - inumfriends; if (inumstars < 0) { inumfriends += inumstars; inumstars = 0; } if (inumfriends < 0) { inumenemies += inumfriends; inumfriends = 0; } if (inumenemies < 0) inumenemies = 0; numstars = inumstars; inuminhab = numinhab = 0; inumroms = inumthols = inumgorns = 0; numapollos = apolspec || massacre ? 1 : ((!numstars || rand_mod(2) || smarts < 10) ? 0 : 1); inumapollos = apolloflag = 0; realapollo = NULL; inumcrushes = numcrushes = crushspec||massacre?1:(rand_mod(2000) < inumstars); inumenemies += inumcrushes; inumamoebas = numamoebas = (amoebaspec ? 1 : !rand_mod(inumcrushes?3-massacre:8) ); /* < and & are fun together */ inumenemies += inumamoebas; if (!rand_mod(40)) { inhabjackpot = 32767; inumfriends += rand_mod(10); inumpirates += rand_mod(10); } else inhabjackpot = inumpirates; inhenergy = 30000-super*150; if (!rand_mod(10)) inhenergy = 50000; if (!rand_mod(4)) inhenergy += rand_mod(3500+super*150); numfriends = inumfriends; numpirates = inumpirates; numenemies = inumenemies; deadmudds = 0; /* do stars */ stars_again: if (prespec) dist = 4; else if (numstars > 750) dist = 0; else dist = rand_mod(starspec||smarts<=5?3:5); if (debugging) { real_y = real_x = -100; printf("\r\n"); } switch (dist) { case 0: /* uniform random */ ydist = xdist = 0; if (inumstars < 700 && !rand_mod(3-(inumstars<50))) { ydist = xdist = 6; /* well, maybe not so random */ y = rand_mod(YSIZE); x = rand_mod(XSIZE); if (rand_mod(2)) walksplit = inumstars/(exdis(40)+1); } if (debugging) printf(" R\r\n"); break; case 1: case 2: /* clumped, maybe skewed, maybe superposed */ ydist = rand_mod(4); xdist = rand_mod(2); if (debugging) printf("%s\r\n",distname[ydist+4*xdist]); yoff = rand_mod(YSIZE); xoff = rand_mod(XSIZE); if (dist == 2) dist = numstars/2 + exdis(numstars/2) - exdis(numstars/2); else dist = 0; break; case 3: case 4: /* predefined or residual */ scenario_again: if (debugging) printf(" P\r\n"); dist = 0; Sprintf(spbuf,"smap.%d", (prescene>=0?prescene:rand_mod(MAPS)) ); if ((mapfp = fopen(spbuf,"r")) != NULL && fgets(spbuf,10,mapfp) != NULL ) { inumstars = numstars = atoi(spbuf); if (inumenemies+inumstars > YSIZE*XSIZE-20) inumstars = numstars = YSIZE*XSIZE-20 - inumenemies; ydist = rand_mod(2) + 4; /* flip y axis? */ xdist = rand_mod(2) + 4; /* flip x axis? */ yoff = rand_mod(YSIZE); /* how much to shift y */ xoff = rand_mod(XSIZE); /* how much to shift x */ } else { prespec = FALSE; prescene = -1; if (rand_mod(2)) goto scenario_again; goto stars_again; } break; } for (i = 1; i <= numstars; i++) { if (dist && i == dist) { /* flip to another skewing? */ ydist = rand_mod(4); xdist = rand_mod(2); if (!rand_mod(4)) { ydist = xdist = 6; if (debugging) printf("&\r\n"); } else if (debugging) printf("%s\r\n",distname[ydist+4*xdist]); yoff = rand_mod(YSIZE); xoff = rand_mod(XSIZE); dist = 0; } do { /* until an open spot found */ switch (xdist) { case 0: x = rand_mod(XSIZE); /* pick from 0..39, uniform */ break; case 1: case 2: case 3: x = (int)((((double)(myrand()-HALFRAND)) * ((double)(myrand()-HALFRAND))/RANDRAND) * 20.0) + xoff; /* pick from -20..20, clumped */ break; case 4: if (fscanf(mapfp,"%d %d\n",&ypred,&xpred) == EOF) ydist = xdist = 0; x = xpred + xoff; break; case 5: if (fscanf(mapfp,"%d %d\n",&ypred,&xpred) == EOF) ydist = xdist = 0; x = -xpred + xoff; break; case 6: x += rand_mod(3) - 1; break; } switch (ydist) { case 0: y = rand_mod(YSIZE); break; case 1: y = (int)((((double)(myrand()-HALFRAND)) * ((double)(myrand()-HALFRAND))/RANDRAND) * 12.0) + yoff; /* pick from -12..12, clumped */ break; case 2: y = (int)((((double)(myrand()-HALFRAND)) * ((double)(myrand()-HALFRAND))/RANDRAND) * 12.0) + yoff + x*YSIZE/XSIZE; /* clumped & skewed */ break; case 3: y = (int)((((double)(myrand()-HALFRAND)) * ((double)(myrand()-HALFRAND))/RANDRAND) * 12.0) + yoff - x*YSIZE/XSIZE; /* clumped & skewed */ break; case 4: y = ypred + yoff; break; case 5: y = -ypred + yoff; break; case 6: y += rand_mod(3) - 1; if (!rand_mod(walksplit)) { y = rand_mod(YSIZE); x = rand_mod(XSIZE); } break; } while (x<0) x += XSIZE00; while (y<0) y += YSIZE00; x %= XSIZE; y %= YSIZE; } while (occupant[y][x]); e = rand_mod(32768); if (--inhabjackpot > 0 || e >= inhenergy) { ch = '@'; if (inhabjackpot && e < 10000) e += 10000; inuminhab = ++numinhab; } else { ch = '*'; } obj = make_object(Star,ch,y,x,0,0,e+rand_mod(super*100+1),e/4,&root); obj->flags |= STATIC; } if (inumstars > 30 && inhabjackpot <= 0 && !rand_mod(3 - (inumstars > 400) - (inhenergy > 32768)) ) { int initx; int inity; x = initx = obj->posx; y = inity = obj->posy; while (rand_mod(2) && inuminhab < inumstars/2) { for (i=rand_mod(smarts)*2+20; i; i--) { if ((obj = occupant[y][x]) && obj->image == '*') { setimage(obj,'@'); if (obj->energy < 10000) obj->energy += 20000; /* the benefits of civilization */ inuminhab = ++numinhab; } if (i&15) { y = (y + rand_mod(3) + YSIZE99) % YSIZE; x = (x + rand_mod(3) + XSIZE99) % XSIZE; } else { /* don't wander too far */ y = inity; x = initx; } } x = initx = rand_mod(XSIZE); y = inity = rand_mod(YSIZE); } } if (mapfp != NULL) Fclose(mapfp); if (numcrushes) { do { x = rand_mod(XSIZE); y = rand_mod(YSIZE); } while (occupant[y][x]); movers = make_object(Crusher,'<',y,x,0,1,32767L,32768L,&root); possiblescore += 10000; } ient = (numents != 0); if (ient) { do { x = rand_mod(XSIZE); y = rand_mod(YSIZE); } while (occupant[y][x]); e = entmax; ent = make_object(Enterprise,'E',y,x,0,0,e,e/2,&root); if (!movers) movers = ent; } ibase = (numbases != 0); if (ibase) { e = 52-super; do { x = rand_mod(XSIZE); y = rand_mod(YSIZE); } while (occupant[y][x] || lookaround(y,x,Star) * 7 < e--); e = basemax; base = make_object(Base, 'B',y,x,0,0,e,e/4,&root); if (!movers) movers = base; } if (numamoebas) { do { x = rand_mod(XSIZE); y = rand_mod(YSIZE); } while (occupant[y][x]); nuke = make_object(Enemy,'&',y,x,0,0,32767L, (long)entmax+entmax+rand_mod(entmax),&root); possiblescore += 10000; amb[y][x] = '~'; if (rand_mod(2)) modify_amoeba(y,x,2,'~',(int)rand_mod(smarts<<1));/* just make blob */ else { for (i=smarts/10+1; i; i--) { nuke->strategy = rand_mod(256); /* random direction */ modify_amoeba(y,x,2,'~',(int)rand_mod(5)); modify_amoeba(y,x,2,'~',(int)rand_mod(5)); modify_amoeba(y,x,2,'~',(int)rand_mod(5)); modify_amoeba(y,x,2,'~',(int)rand_mod(5)); /* extend pseudopod */ } } if (!enemies) enemies = nuke; if (!movers) movers = nuke; } if (rand_mod(27-sm50/2) && !romspec && !gornspec) dist = 27-sm50/2; else dist = rand_mod(4) + 1; for (i = 1+inumcrushes+inumamoebas; i <= numenemies; i++) { do { x = rand_mod(XSIZE); y = rand_mod(YSIZE); } while (occupant[y][x]); if (rand_mod(dist)) { if (!tholspec && !tmptholspec && rand_mod((inumstars*3)/sm50+2)) ch = 'K'; else { ch = 'T'; inumthols++; } } else { if (romspec == gornspec) e = 50; else if (gornspec) e = 10; else e = 90; if (rand_mod(100) < e) { ch = 'R'; inumroms++; } else { ch = 'G'; inumgorns++; } } if (possiblescore > ENTBOUNDARY - 10000) e = (ENTBOUNDARY - possiblescore) / 5; else e = 250 + (sm50-1) * 30 * 20 / numenemies+1; e = exdis((int)e) + e - exdis((int)e); obj = make_object(Enemy,ch,y,x,0,0, e + rand_mod(super*200+2) + 10000*massacre,e/4,&root); e /= 4; switch (ch) { case 'K': possiblescore += e; break; case 'T': possiblescore += e*3/2; break; case 'G': possiblescore += e*2; break; case 'R': possiblescore += e*3; obj->flags |= CLOAKS; break; } if (!enemies) enemies = obj; if (!movers) movers = obj; } numgorns = inumgorns; for (i=0; i 0) { obj->flags |= PIRATE; if (smarts >= 20 && !rand_mod(10-smarts/10)) obj->flags |= CLOAKS; } obj->flags |= FRIENDLY; if (!enemies) enemies = obj; if (!movers) movers = obj; } if (!movers) movers = &root; if (!enemies) enemies = &root; if (ent) mvaddch(ent->posy+1, ent->posx*2, ent->image); if (base) mvaddch(base->posy+1, base->posx*2, base->image); sleep(2); { register OBJECT *curobj; for (curobj = root.next; curobj != &root; curobj = curobj->next) { mvaddch(curobj->posy+1, curobj->posx*2, curobj->image); } } for (i=0;i<2;i++) for (y=0;y<3;y++) for (x=0;x<3;x++) isatorp[i][y][x]=0; whenok = 0; timer = 0; finish = 0; bombed_out = FALSE; if (ent) entmode = status = 0; else if (base) status = 2; else status = 3; Sprintf(spbuf, "%-4s E: %4d %2d B: %5d %3d Enemies: %-3d Stars: %-3d Stardate%5d.%1d %9ld", " ", 0, 0, 0, 0, 0, 0, smarts * 100, 0, 0L); mvaddstr(0,0,spbuf); oldeenergy = oldbenergy = oldcurscore = oldstatus = oldetorp = oldbtorp = oldstrs = oldenemies = -1; /* force everything to fill in */ damage = olddamage = 0; for (i=0; i #include /* name of this host */ struct utsname uts; #ifdef TILDENAME static char *tildename = Nullch; static char *tildedir = Nullch; #endif char *dointerp(); char *getrealname(); #ifdef CONDSUB char *skipinterp(); #endif static void abort_interp(); void intrp_init(tcbuf) char *tcbuf; { /* get environmental stuff */ /* get home directory */ homedir = getenv("HOME"); if (homedir == Nullch) homedir = getenv("LOGDIR"); dotdir = getval("DOTDIR",homedir); /* get login name */ logname = getenv("USER"); if (logname == Nullch) logname = getenv("LOGNAME"); #ifdef GETLOGIN if (logname == Nullch) logname = savestr(getlogin()); #endif /* get the real name of the person (%N) */ /* Must be done after logname is read in */ strcpy(tcbuf,getrealname(getuid())); realname = savestr(tcbuf); /* name of this host (%H) */ /* get sysname */ uname(&uts); hostname = savestr(uts.nodename); warplib = savestr(filexp(WARPLIB)); if (scorespec) /* that getwd below takes ~1/3 sec. */ return; /* and we do not need it for -s */ if (! getwd(tcbuf)) { /* find working directory name */ perror("getcwd"); exit(1); } origdir = savestr(tcbuf); /* and remember it */ } /* expand filename via %, ~, and $ interpretation */ /* returns pointer to static area */ /* Note that there is a 1-deep cache of ~name interpretation */ char * filexp(s) register char *s; { static char filename[CBUFLEN]; char scrbuf[CBUFLEN]; register char *d; #ifdef DEBUGGING if (debug & DEB_FILEXP) printf("< %s\r\n",s); #endif interp(filename, (sizeof filename), s); /* interpret any % escapes */ #ifdef DEBUGGING if (debug & DEB_FILEXP) printf("%% %s\r\n",filename); #endif s = filename; if (*s == '~') { /* does destination start with ~? */ if (!*(++s) || *s == '/') { Sprintf(scrbuf,"%s%s",homedir,s); /* swap $HOME for it */ #ifdef DEBUGGING if (debug & DEB_FILEXP) printf("~ %s\r\n",scrbuf); #endif strcpy(filename,scrbuf); } else { #ifdef TILDENAME for (d=scrbuf; isalnum(*s); s++,d++) *d = *s; *d = '\0'; if (tildedir && strEQ(tildename,scrbuf)) { strcpy(scrbuf,tildedir); strcat(scrbuf, s); strcpy(filename, scrbuf); #ifdef DEBUGGING if (debug & DEB_FILEXP) printf("r %s %s\r\n",tildename,tildedir); #endif } else { if (tildename) { free(tildename); free(tildedir); } tildedir = Nullch; tildename = savestr(scrbuf); { struct passwd *pwd = getpwnam(tildename); Sprintf(scrbuf,"%s%s",pwd->pw_dir,s); tildedir = savestr(pwd->pw_dir); strcpy(filename,scrbuf); endpwent(); } } #else /* !TILDENAME */ #ifdef VERBOSE IF(verbose) fputs("~loginname not implemented.\r\n",stdout); ELSE #endif #ifdef TERSE fputs("~login not impl.\r\n",stdout); #endif #endif } } else if (*s == '$') { /* starts with some env variable? */ d = scrbuf; *d++ = '%'; if (s[1] == '{') strcpy(d,s+2); else { *d++ = '{'; for (s++; isalnum(*s); s++) *d++ = *s; /* skip over token */ *d++ = '}'; strcpy(d,s); } #ifdef DEBUGGING if (debug & DEB_FILEXP) printf("$ %s\r\n",scrbuf); #endif interp(filename, (sizeof filename), scrbuf); /* this might do some extra '%'s but */ /* that is how the Mercedes Benz */ } #ifdef DEBUGGING if (debug & DEB_FILEXP) printf("> %s\r\n",filename); #endif return filename; } #ifdef CONDSUB /* skip interpolations */ char * skipinterp(pattern,stoppers) register char *pattern; char *stoppers; { while (*pattern && (!stoppers || !strchr(stoppers,*pattern))) { #ifdef DEBUGGING if (debug & 8) printf("skipinterp till %s at %s\r\n",stoppers?stoppers:"",pattern); #endif if (*pattern == '%' && pattern[1]) { switch (*++pattern) { case '{': for (pattern++; *pattern && *pattern != '}'; pattern++) if (*pattern == '\\') pattern++; break; #ifdef CONDSUB case '(': { pattern = skipinterp(pattern+1,"!="); if (!*pattern) goto getout; for (pattern++; *pattern && *pattern != '?'; pattern++) if (*pattern == '\\') pattern++; if (!*pattern) goto getout; pattern = skipinterp(pattern+1,":)"); if (*pattern == ':') pattern = skipinterp(pattern+1,")"); break; } #endif #ifdef BACKTICK case '`': { pattern = skipinterp(pattern+1,"`"); break; } #endif #ifdef PROMPTTTY case '"': pattern = skipinterp(pattern+1,"\""); break; #endif default: break; } pattern++; } else { if (*pattern == '^' && pattern[1]) pattern += 2; else if (*pattern == '\\' && pattern[1]) pattern += 2; else pattern++; } } getout: return pattern; /* where we left off */ } #endif /* interpret interpolations */ char * dointerp(dest,destsize,pattern,stoppers) register char *dest; register int destsize; register char *pattern; char *stoppers; { register char *s; register int i; char scrbuf[512]; bool upper = FALSE; bool lastcomp = FALSE; int metabit = 0; while (*pattern && (!stoppers || !strchr(stoppers,*pattern))) { #ifdef DEBUGGING if (debug & 8) printf("dointerp till %s at %s\r\n",stoppers?stoppers:"",pattern); #endif if (*pattern == '%' && pattern[1]) { upper = FALSE; lastcomp = FALSE; for (s=Nullch; !s; ) { switch (*++pattern) { case '^': upper = TRUE; break; case '_': lastcomp = TRUE; break; case '{': pattern = cpytill(scrbuf,pattern+1,'}'); if (s = strchr(scrbuf,'-')) *s++ = '\0'; else s = nullstr; s = getval(scrbuf,s); break; #ifdef CONDSUB case '(': { char rch; bool matched; pattern = dointerp(dest,destsize,pattern+1,"!="); rch = *pattern; if (rch == '!') pattern++; if (*pattern != '=') goto getout; pattern = cpytill(scrbuf,pattern+1,'?'); if (!*pattern) goto getout; if (*scrbuf == '^' && scrbuf[strlen(scrbuf)-1] == '$') { scrbuf[strlen(scrbuf)-1] = '\0'; matched = strEQ(scrbuf+1,dest); } else matched = instr(dest,scrbuf) != Nullch; if (matched==(rch == '=')) { pattern = dointerp(dest,destsize,pattern+1,":)"); if (*pattern == ':') pattern = skipinterp(pattern+1,")"); } else { pattern = skipinterp(pattern+1,":)"); if (*pattern == ':') pattern++; pattern = dointerp(dest,destsize,pattern,")"); } s = dest; break; } #endif #ifdef BACKTICK case '`': { FILE *pipefp, *popen(); pattern = dointerp(scrbuf,(sizeof scrbuf),pattern+1,"`"); pipefp = popen(scrbuf,"r"); if (pipefp != Nullfp) { int len; len = fread(scrbuf,sizeof(char),(sizeof scrbuf)-1, pipefp); scrbuf[len] = '\0'; pclose(pipefp); } else { printf("\r\nCan't run %s\r\n",scrbuf); *scrbuf = '\0'; } for (s=scrbuf; *s; s++) { if (*s == '\n') { if (s[1]) *s = ' '; else *s = '\0'; } } s = scrbuf; break; } #endif #ifdef PROMPTTTY case '"': pattern = dointerp(scrbuf,(sizeof scrbuf),pattern+1,"\""); fputs(scrbuf,stdout); resetty(); if (! gets(scrbuf)) /* ignore */; crmode(); raw(); noecho(); nonl(); s = scrbuf; break; #endif case '~': s = homedir; break; case '.': s = dotdir; break; case '$': s = scrbuf; Sprintf(s,"%d",getpid()); break; case 'H': /* host name */ s = hostname; break; case 'L': /* login id */ s = logname; break; case 'N': /* full name */ s = getval("NAME",realname); break; case 'O': s = origdir; break; case 'p': s = cwd; break; case 'X': /* warp library */ s = warplib; break; default: if (--destsize <= 0) abort_interp(); *dest++ = *pattern | metabit; s = nullstr; break; } } if (!s) s = nullstr; pattern++; if (upper || lastcomp) { char *t; if (s != scrbuf) { Safecpy(scrbuf,s,(sizeof scrbuf)); s = scrbuf; } if (upper || !(t=strrchr(s,'/'))) t = s; while (*t && !isalpha(*t)) t++; if (islower(*t)) *t = toupper(*t); } i = metabit; /* maybe get into register */ if (s == dest) { while (*dest) { if (--destsize <= 0) abort_interp(); *dest++ |= i; } } else { while (*s) { if (--destsize <= 0) abort_interp(); *dest++ = *s++ | i; } } } else { if (--destsize <= 0) abort_interp(); if (*pattern == '^' && pattern[1]) { ++pattern; /* skip uparrow */ i = *pattern; /* get char into a register */ if (i == '?') *dest++ = '\177' | metabit; else if (i == '(') { metabit = 0200; destsize++; } else if (i == ')') { metabit = 0; destsize++; } else *dest++ = i & 037 | metabit; pattern++; } else if (*pattern == '\\' && pattern[1]) { ++pattern; /* skip backslash */ i = *pattern; /* get char into a register */ /* this used to be a switch but the if may save space */ if (i >= '0' && i <= '7') { i = 1; while (i < 01000 && *pattern >= '0' && *pattern <= '7') { i <<= 3; i += *pattern++ - '0'; } *dest++ = i & 0377 | metabit; --pattern; } else if (i == 'b') *dest++ = '\b' | metabit; else if (i == 'f') *dest++ = '\f' | metabit; else if (i == 'n') *dest++ = '\n' | metabit; else if (i == 'r') *dest++ = '\r' | metabit; else if (i == 't') *dest++ = '\t' | metabit; else *dest++ = i | metabit; pattern++; } else *dest++ = *pattern++ | metabit; } } *dest = '\0'; getout: return pattern; /* where we left off */ } void interp(dest,destsize,pattern) char *dest; int destsize; char *pattern; { (void) dointerp(dest,destsize,pattern,Nullch); #ifdef DEBUGGING if (debug & DEB_FILEXP) fputs(dest,stdout); #endif } /* get the person's real name from /etc/passwd */ /* (string is overwritten, so it must be copied) */ char * getrealname(uid) int uid; { char *s, *c; struct passwd *pwd = getpwuid(uid); s = pwd->pw_gecos; if ((c = strchr(s, ',')) != Nullch) *c = '\0'; if ((c = strchr(s, ';')) != Nullch) *c = '\0'; s = cpytill(buf,s,'&'); if (*s == '&') { /* whoever thought this one up was */ c = buf + strlen(buf); /* in the middle of the night */ strcat(c,logname); /* before the morning after */ strcat(c,s+1); if (islower(*c)) *c = toupper(*c); /* gack and double gack */ } endpwent(); return buf; /* return something static */ } static void abort_interp() { fputs("\r\n% interp buffer overflow!\r\n",stdout); sig_catcher(0); } ================================================ FILE: games/warp/intrp.h ================================================ /* $Header: intrp.h,v 7.0.1.1 86/12/12 16:59:45 lwall Exp $ * * $Log: intrp.h,v $ * Revision 7.0.1.1 86/12/12 16:59:45 lwall * Baseline for net release. * * Revision 7.0 86/10/08 15:12:27 lwall * Split into separate files. Added amoebas and pirates. * */ EXT char *origdir INIT(Nullch); /* cwd when warp invoked */ EXT char *homedir INIT(Nullch); /* login directory */ EXT char *dotdir INIT(Nullch); /* where . files go */ EXT char *logname INIT(Nullch); /* login id */ EXT char *hostname INIT(Nullch); /* host name */ EXT char *realname INIT(Nullch); /* real name from /etc/passwd */ void intrp_init(); char *filexp(); char *dointerp(); void interp(); char *getrealname(); ================================================ FILE: games/warp/move.c ================================================ /* $Header: move.c,v 7.0.1.2 86/10/20 14:37:06 lwall Exp $ */ /* $Log: move.c,v $ * Revision 7.0.1.2 86/10/20 14:37:06 lwall * Picked some lint. * * Revision 7.0.1.1 86/10/16 10:52:09 lwall * Added Damage. Fixed random bugs. * * Revision 7.0 86/10/08 15:12:40 lwall * Split into separate files. Added amoebas and pirates. * */ #include "EXTERN.h" #include "warp.h" #include "bang.h" #include "object.h" #include "move.h" #include "play.h" #include "score.h" #include "term.h" #include "them.h" #include "us.h" #include "util.h" #include "weapon.h" #include "INTERN.h" #include "move.h" void move_init() { ; } void bounce(obj) register OBJECT *obj; { register int x; register int y; register int count=0; y = (obj->posy - sgn(obj->vely) + YSIZE00) % YSIZE; x = (obj->posx - sgn(obj->velx) + XSIZE00) % XSIZE; while (occupant[y][x]) { y = (y + rand_mod(3) - 1 + YSIZE00) % YSIZE; x = (x + rand_mod(3) - 1 + XSIZE00) % XSIZE; if (++count > 10000) { /* if universe full, get out of it fast */ unmake_object(obj); if (ent) unmake_object(ent); if (base) unmake_object(base); finish = 1; return; } } obj->posy = y; obj->posx = x; obj->vely = 0; obj->velx = 0; occupant[y][x] = obj; if (numamoebas && obj->image == ' ') mvaddc(y+1, x*2, amb[y][x]); else mvaddc(y+1, x*2, obj->image); } void move_universe() { register OBJECT *curobj; register int x; register int y; register OBJECT *temp; OBJECT *thenext; for (curobj = movers; curobj != &root; curobj = curobj->next) { x = curobj->posx; y = curobj->posy; if (curobj == occupant[y][x]) { occupant[y][x] = 0; } else if (curobj->type != Torp && curobj->type != Web) { resetty(); abort(); } } for (curobj = movers; curobj != &root; curobj = thenext) { thenext = curobj->next; if (curobj->vely || curobj->velx) { y = curobj->posy; x = curobj->posx; if (curobj->image != ' ' && (!(temp=occupant[y][x]) || temp->image==' ') ) { move(y+1, x*2, numamoebas ? amb[y][x] : ' '); } y = (y + curobj->vely + YSIZE00) % YSIZE; x = (x + curobj->velx + XSIZE00) % XSIZE; if (!(temp=occupant[y][x]) || temp->type != Star || curobj->type != Torp || curobj->image == '+' || curobj->image == 'x') { curobj->posy = y; curobj->posx = x; } else { if (curobj->image == '0') { curobj->vely = rand_mod(3)-1; curobj->velx = rand_mod(3)-1; } else curobj->vely = curobj->velx = 0; y = curobj->posy; x = curobj->posx; } } else { /* not moving */ y = curobj->posy; x = curobj->posx; if (curobj->type == Torp || curobj->type == Star || curobj->type == Web) { curobj->flags |= STATIC; curobj->next->prev = curobj->prev; curobj->prev->next = curobj->next; curobj->prev = movers->prev; curobj->next = movers; movers->prev->next = curobj; movers->prev = curobj; } } if (temp = occupant[y][x]) { /* already occupied? */ if (!temp->contend) { if (temp->type == Torp) { if (temp->image == '+') blast[y][x] += 1250; else if (temp->image == 'o' && (base||ent)) blast[y][x] += 500+super*20; else if (temp->image == 'O' && (base||ent)) blast[y][x] += 5000+super*100; } } yblasted[y] |= 1; xblasted[x] |= 1; blasted = TRUE; curobj->contend = temp; occupant[y][x] = curobj; switch (curobj->type) { case Enemy: if (numamoebas && curobj == nuke && temp->image == '+') blast[y][x] += 80000; else if (temp->type == Enemy) blast[y][x] += 10; else goto defblast; break; case Crusher: if (curobj->velx) blast[y][x] += 100000; else goto defblast; break; case Torp: if (curobj->image == '+') blast[y][x] += (temp==nuke ? 80000 : 1250); else if (curobj->image == 'o') blast[y][x] += 500+super*20; else if (curobj->image == 'O') blast[y][x] += 5000+super*100; goto defblast; case Star: if (temp == ent) goto damshield; goto defblast; case Enterprise: if (temp->type == Star) { damshield: if (!rand_mod(10)) { if (!damflag[NOSHIELDS]) damage++; if (damflag[NOSHIELDS] < 100) damflag[NOSHIELDS] += rand_mod(smarts)/5+2; } } goto defblast; default: defblast: blast[y][x] += rand_mod(751)+1; break; } } else { occupant[y][x] = curobj; if (curobj->image != ' ' && (curobj->velx || curobj->vely || curobj->type == Torp || curobj->type == Web) ) { mvaddc(y+1, x*2, curobj->image); } if (curobj->type == Crusher && curobj->velx) { blast[y][x] += 100000; yblasted[y] |= 1; xblasted[x] |= 1; blasted = TRUE; } } } if (blasted) { register int minxblast = -1; register int maxxblast = -2; register long tmpblast; blasted = numamoebas; for (x=0; ximage == '&') tmpblast >>= 1; else if (temp->type == Web) tmpblast = 100000; else tmpblast += 50 + temp->energy/100; if (tmpblast > 250 && !rand_mod(5+(inumstars>>4))) modify_amoeba(y,x,1,'~',5); } xblasted[x] = 2; yblasted[y] = 2; } if (tmpblast) { register OBJECT *biggie = 0; blast[y][x] = 0; temp = occupant[y][x]; if (tmpblast < 0) { if (numamoebas && tmpblast < -1000000 && amb[y][x] == '~' && temp != nuke) { amb[y][x] = ' '; if (!temp) make_plink(y,x); ambsize--; } tmpblast = 0; } if (temp) { if ((!numamoebas || amb[y][x]==' ') && tmpblast < 100000) make_plink(y,x); for ( ;temp; temp = curobj->contend,curobj->contend = 0){ curobj = temp; switch (curobj->type) { case Enterprise: { long tmp = curobj->energy; if (ent->energy>500 || apolloflag & 1) curobj->energy -= tmpblast / ((apolloflag & 1) ? 20 : (5+abs(ent->velx)+abs(ent->vely)) / ((damflag[NOSHIELDS]>>3)+1)+1); else curobj->energy -= tmpblast; if (rand_mod(1 + tmp - curobj->energy) > 100 || ent->energy < (entmax>>1)) { if (debug & 128 || (damage <= smarts/10 && !rand_mod(6-smarts/20-massacre) )) { tmp = rand_mod(MAXDAMAGE); if (damflag[tmp]) { if (damflag[tmp] < 60) damflag[tmp] += rand_mod(60); } else { damflag[tmp] = rand_mod(smarts+10)+2; damage++; } } } break; } case Base: if (base->energy > 1000 || apolloflag & 2) curobj->energy -= tmpblast / ((apolloflag & 2)?20:5); else curobj->energy -= tmpblast; break; case Crusher: if (tmpblast > 132767) curobj->energy -= (tmpblast - 100000); else if (tmpblast >= 100000) { curobj->energy += (tmpblast - 100000); if (curobj->energy > 32767) curobj->energy = 32767; } else /* vulnerable while feeding */ curobj->energy -= tmpblast; break; case Enemy: curobj->energy -= tmpblast*10/enemshields; break; default: curobj->energy -= tmpblast; break; } if (curobj->energy < 0) { /* killed it? */ switch (curobj->image) { case 'A': tmpblast = 100000; make_blast(y,x,8192L,1); numapollos = apolloflag = 0; numstars--; numenemies--; curscore += 5000; deados = 0; break; case 'E': case 'e': case 'C': case 'c': ent = 0; numents--; if (base) status = 2; else status = 3; deados = 0; break; case 'B': case 'b': base = 0; numbases--; if (ent) status = entmode; else status = 3; deados = 0; break; case '&': { int i, xxx, yyy; for (i = 0; i < YSIZE; i++) yblasted[i] &= 1; for (i = 0; i < XSIZE; i++) xblasted[i] &= 1; numamoebas = 0; /* ignore amb[][] now */ for (yyy = 0; yyy < YSIZE; yyy++) { for (xxx = 0; xxx < XSIZE; xxx++) { if (amb[yyy][xxx] == '~' && !occupant[yyy][xxx]) { mvaddch(yyy+1,xxx*2,' '); } } } numenemies--; curscore += 10000; if (curobj == enemies) enemies = curobj->next; deados = 0; break; } case '<': case '>': { int i; numenemies--; numcrushes = 0; curscore += 10000; if (curobj == movers) movers = curobj->next; if (curobj == enemies) enemies = curobj->next; deados = 0; tmpblast = 100000; make_blast(y,(x+XSIZE00)%XSIZE,10000L,0); if (curobj->image == '<') { for (i=XSIZE00; i<=XSIZE01; i++) make_blast(y,(x+i)%XSIZE, 10000L,0); for (i=XSIZE00; i<=XSIZE02; i++) make_blast(y,(x+i)%XSIZE, 10000L,0); make_blast(y,(x+XSIZE03)%XSIZE, 10000L,1); for (i=XSIZE00; i<=XSIZE08; i++) make_blast(y,(x+i)%XSIZE, 10000L,0); } else { for (i=XSIZE00; i>=XSIZE99; i--) make_blast(y,(x+i)%XSIZE, 10000L,0); for (i=XSIZE00; i>=XSIZE98; i--) make_blast(y,(x+i)%XSIZE, 10000L,0); make_blast(y,(x+XSIZE97)%XSIZE, 10000L,1); for (i=XSIZE00; i>=XSIZE92; i--) make_blast(y,(x+i)%XSIZE, 10000L,0); } } break; case 'K': numenemies--; curscore += curobj->mass; if (curobj == enemies) enemies = curobj->next; deados = 0; break; case 'T': numenemies--; curscore += curobj->mass*3/2; if (curobj == enemies) enemies = curobj->next; deados = 0; break; case 'R': case ' ': case 'P': numenemies--; if (curobj->flags & PIRATE) curscore += curobj->mass; else curscore += curobj->mass*3; if (curobj == enemies) enemies = curobj->next; deados = 0; break; case 'G': numenemies--; numgorns--; tmpblast = 100000; if (madgorns) curscore += curobj->mass/2; else curscore += curobj->mass*2; if (curobj == enemies) enemies = curobj->next; { int xxx,yyy; for (xxx = -1; xxx<=1; xxx++) for (yyy = -1; yyy<=1; yyy++) if (rand_mod(2+massacre)) fire_torp(curobj, yyy,xxx); } deados = 0; break; case '@': numinhab--; /* FALL THROUGH */ case '*': banging = TRUE; numstars--; break; case '|': case '-': case '/': case '\\': tmpblast = 100000; make_blast(y,x,curobj->mass,1); banging = TRUE; deados = 0; break; case 'x': curscore += 10; deados = 0; break; case 'X': curscore += 100; numxes--; deados = 0; break; case '0': curscore += 35; numos--; deados += 3; break; case 'o': curscore += 100; numos--; deados++; break; case 'O': curscore += 200; numos--; deados += 2; break; case 'M': deadmudds++; inumfriends--; numfriends--; if (curobj == enemies) enemies = curobj->next; break; case 'Q': case 'W': case 'Y': case 'U': case 'I': case 'S': case 'D': case 'H': case 'J': case 'L': case 'Z': case 'V': case 'F': numfriends--; if (curobj == enemies) enemies = curobj->next; if (inumfriends < 10) madfriends += 500; else madfriends += 10000/inumfriends; break; } if (tmpblast < 100000) make_blast(y,x,curobj->mass,1); unmake_object(curobj); } else { /* didn't kill anything */ if (!biggie) biggie = curobj; else { if (biggie->mass > curobj->mass) bounce(curobj); else { bounce(biggie); biggie = curobj; } } } } if (biggie) { occupant[y][x] = biggie; if (numamoebas && biggie->image == ' ') mvaddch(y+1,x*2, amb[y][x]); else mvaddch(y+1,x*2, biggie->image); } else { occupant[y][x] = 0; mvaddch(y+1, x*2, numamoebas ? amb[y][x] : ' '); } } } } } } } do_bangs(); if (numcrushes && movers->type == Crusher) movers->vely = 0; if (curobj = base) { char ch; curobj->velx = 0; curobj->vely = 0; curobj->energy += 25*lookaround(curobj->posy,curobj->posx,Star); if (curobj->energy > basemax) curobj->energy = basemax; if (curobj->energy >= 1000) ch = 'B'; else ch = 'b'; if (ch != curobj->image) { setimage(curobj, ch); } } if (curobj = ent) { char ch; if (entmode == 0) { curobj->velx = 0; curobj->vely = 0; } if (base && !cloaking && !curobj->velx && !curobj->vely && lookfor(curobj->posy,curobj->posx,Base)) { int tmp; tmp = (int) (base->energy - 1000 < entmax - curobj->energy ? base->energy - 1000 : entmax - curobj->energy); if (tmp < 0) tmp = 0; curobj->energy += tmp; base->energy -= tmp; tmp = (btorp < 50 - etorp ? btorp : 50 - etorp); etorp += tmp; btorp -= tmp; if (damage) { tmp = rand_mod(MAXDAMAGE); if (damflag[tmp] > 5) { damflag[tmp] = rand_mod(5)+1; } } } if (curobj->energy >= 500 && (!damage || !damflag[NOSHIELDS])) ch = cloaked?'C':'E'; else ch = cloaked?'c':'e'; if (ch != curobj->image) { setimage(curobj, ch); } } } int lookaround(y, x, what) register int y; register int x; register char what; { register OBJECT *obj; register int count=0; register int xp; register int xm; if ((obj=occupant[y][xp=(x+XSIZE01)%XSIZE])&&obj->type == what) /* 0, 1 */ count++; if ((obj=occupant[y][xm=(x+XSIZE99)%XSIZE])&&obj->type == what) /* 0, -1 */ count++; if ((obj=occupant[y=(y+YSIZE99)%YSIZE][xp])&&obj->type == what) /* -1, 1 */ count++; if ((obj=occupant[y][x])&&obj->type == what) /* -1, 0 */ count++; if ((obj=occupant[y][xm])&&obj->type == what) /* -1, -1 */ count++; if ((obj=occupant[y=(y+2)%YSIZE][xp])&&obj->type == what) /* 1, 1 */ count++; if ((obj=occupant[y][x])&&obj->type == what) /* 1, 0 */ count++; if ((obj=occupant[y][xm])&&obj->type == what) /* 1, -1 */ count++; return (count); } int lookfor(y, x, what) register int y; register int x; register char what; { register OBJECT *obj; register int xp; register int xm; if ((obj=occupant[y][xp=(x+XSIZE01)%XSIZE])&&obj->type == what ||/* 0, 1 */ (obj=occupant[y][xm=(x+XSIZE99)%XSIZE])&&obj->type == what ||/* 0, -1 */ (obj=occupant[y=(y+YSIZE99)%YSIZE][xp])&&obj->type == what ||/* -1, 1 */ (obj=occupant[y][x])&&obj->type == what ||/* -1, 0 */ (obj=occupant[y][xm])&&obj->type == what ||/* -1,-1 */ (obj=occupant[y=(y+2)%YSIZE][xp])&&obj->type == what ||/* 1, 1 */ (obj=occupant[y][x])&&obj->type == what ||/* 1, 0 */ (obj=occupant[y][xm])&&obj->type == what) /* 1, -1 */ return(1); return (0); } OBJECT* lookimg(y, x, what) register int y; register int x; register char what; { register OBJECT *obj; register int xp; register int xm; if ((obj=occupant[y][xp=(x+XSIZE01)%XSIZE])&&obj->image==what ||/* 0, 1 */ (obj=occupant[y][xm=(x+XSIZE99)%XSIZE])&&obj->image==what ||/* 0, -1 */ (obj=occupant[y=(y+YSIZE99)%YSIZE][xp])&&obj->image==what ||/* -1, 1 */ (obj=occupant[y][x])&&obj->image==what ||/* -1, 0 */ (obj=occupant[y][xm])&&obj->image==what ||/* -1,-1 */ (obj=occupant[y=(y+2)%YSIZE][xp])&&obj->image==what ||/* 1, 1 */ (obj=occupant[y][x])&&obj->image==what ||/* 1, 0 */ (obj=occupant[y][xm])&&obj->image==what) /* 1, -1 */ return obj; return Null(OBJECT*); } ================================================ FILE: games/warp/move.h ================================================ /* $Header: move.h,v 7.0 86/10/08 15:12:46 lwall Exp $ */ /* $Log: move.h,v $ * Revision 7.0 86/10/08 15:12:46 lwall * Split into separate files. Added amoebas and pirates. * */ void bounce(); void move_universe(); int lookaround(); int lookfor(); OBJECT *lookimg(); void move_init(); ================================================ FILE: games/warp/object.c ================================================ /* $Header: object.c,v 7.0 86/10/08 15:12:55 lwall Exp $ */ /* $Log: object.c,v $ * Revision 7.0 86/10/08 15:12:55 lwall * Split into separate files. Added amoebas and pirates. * */ #include "EXTERN.h" #include "warp.h" #include "INTERN.h" #include "object.h" void object_init() { ; } OBJECT * make_object(typ, img, py, px, vy, vx, energ, mas, where) char typ; char img; int px, py, vx, vy; long energ, mas; OBJECT *where; { register OBJECT *obj; if (free_root.next == &free_root) obj = (OBJECT *) malloc(sizeof root); else { obj = free_root.next; free_root.next = obj->next; obj->next->prev = &free_root; } obj->type = typ; obj->image = img; obj->next = where; obj->prev = where->prev; where->prev = obj; obj->prev->next = obj; obj->velx = vx; obj->vely = vy; obj->contend = 0; obj->strategy = 0; obj->flags = 0; obj->posx = px; obj->posy = py; if (typ != Torp && typ != Web) { occupant[py][px] = obj; } obj->energy = energ; obj->mass = mas; return(obj); } void unmake_object(curobj) register OBJECT *curobj; { curobj->prev->next = curobj->next; curobj->next->prev = curobj->prev; if (curobj == movers) { movers = curobj->next; } free_object(curobj); } void free_object(curobj) register OBJECT *curobj; { curobj->next = free_root.next; curobj->prev = &free_root; free_root.next->prev = curobj; free_root.next = curobj; } ================================================ FILE: games/warp/object.h ================================================ /* $Header: object.h,v 7.0.1.2 86/12/12 17:01:38 lwall Exp $ */ /* $Log: object.h,v $ * Revision 7.0.1.2 86/12/12 17:01:38 lwall * Baseline for net release. * * Revision 7.0.1.1 86/10/16 10:52:30 lwall * Added Damage. Fixed random bugs. * * Revision 7.0 86/10/08 15:13:04 lwall * Split into separate files. Added amoebas and pirates. * */ #define Root 0 #define Base 1 #define Enterprise 2 #define Star 3 #define Torp 4 #define Enemy 5 #define Web 6 #define Crusher 7 typedef struct object { char posx, posy; char velx, vely; struct object *next, *prev, *contend; long energy; long mass; char type; char image; char strategy; char flags; } OBJECT; #define PIRATE 1 /* we may mutiny */ #define FRIENDLY 2 /* we aren't really an enemy, for now */ #define STATIC 4 /* we are not in the movers list at the moment */ #define COUNTDOWN 8 /* we are counting down for something */ #define CLOAKS 16 /* we can cloak */ #ifdef DOINIT OBJECT root = {0, 0, 0, 0, &root, &root, 0, 0, 0, Root, '?', 0, 0}; #else EXT OBJECT root; #endif #ifdef DOINIT OBJECT free_root = {0, 0, 0, 0, &free_root, &free_root, 0, 0, 0, Root, '?', 0, 0}; #else EXT OBJECT free_root; #endif EXT OBJECT *ent; EXT OBJECT *base; EXT OBJECT *enemies; EXT OBJECT *movers; EXT OBJECT *realapollo; EXT OBJECT *nuke; EXT OBJECT *occupant[YSIZE][XSIZE]; OBJECT *make_object(); void unmake_object(); void free_object(); void object_init(); ================================================ FILE: games/warp/patchlevel.h ================================================ #define PATCHLEVEL 3 ================================================ FILE: games/warp/play.c ================================================ /* $Header: play.c,v 7.0.1.1 86/10/16 10:52:39 lwall Exp $ */ /* $Log: play.c,v $ * Revision 7.0.1.1 86/10/16 10:52:39 lwall * Added Damage. Fixed random bugs. * * Revision 7.0 86/10/08 15:13:09 lwall * Split into separate files. Added amoebas and pirates. * */ #include "EXTERN.h" #include "warp.h" #include "bang.h" #include "score.h" #include "object.h" #include "move.h" #include "term.h" #include "them.h" #include "us.h" #include "util.h" #include "weapon.h" #include "INTERN.h" #include "play.h" void play_init() { ; } void play() { bool done = FALSE; register OBJECT *curobj; register OBJECT *to; register int i; register int x; register int y; display_status(); #ifdef TIOCOUTQ while (output_pending() > charsperhalfsec) sleep(1); /* allow buffers to empty */ #endif sleep(3); do { timer++; nxtbang = 0; banging = FALSE; display_status(); #ifdef TIOCOUTQ while (output_pending() > charsperhalfsec) sleep(1); #endif if (lowspeed) roundsleep(2); else roundsleep(1); if (ent) { evely = ent->vely; evelx = ent->velx; if (cloaking && ent->energy >= 250 && !damflag[NOCLOAKING]) { if (!rand_mod(300)) { damage++; damflag[NOCLOAKING] = rand_mod(smarts+1)+2; } ent->energy -= ent->energy/40; } else cloaking = FALSE; cloaked = cloaking; } if (base) { bvely = base->vely; bvelx = base->velx; } get_commands(&done); if (done) break; their_smarts(); apolloflag = 0; if (ent) { if (numapollos) { if (numstars) { if (realapollo) { if (lookfor(realapollo->posy,realapollo->posx, Enterprise)) { apolloflag = 1; } } else if (lookfor(root.next->posy,root.next->posx, Enterprise)) { apolloflag = 1; realapollo = root.next; mvaddch(realapollo->posy+1,realapollo->posx*2, 'A'); realapollo->image = 'A'; realapollo->mass = 6000; inumapollos = 1; numenemies++; inumenemies++; possiblescore += 5000; } if (apolloflag) { if (blast[realapollo->posy][realapollo->posx] <= 32000) evely = evelx = 0; realapollo->energy = 32000; } } else numapollos = 0; } ent->vely = evely; ent->velx = evelx; } if (base) { if (numapollos) { if (numstars) { if (realapollo) { if (lookfor(realapollo->posy,realapollo->posx, Base)) { apolloflag |= 2; } } else if (lookfor(root.next->posy,root.next->posx, Base)) { apolloflag |= 2; realapollo = root.next; mvaddch(realapollo->posy+1,realapollo->posx*2, 'A'); realapollo->image = 'A'; realapollo->mass = 6000; inumapollos = 1; numenemies++; inumenemies++; possiblescore += 5000; } if (apolloflag & 2) { if (blast[realapollo->posy][realapollo->posx] <= 32000) bvely = bvelx = 0; realapollo->energy = 32000; } } else numapollos = 0; } base->vely = bvely; base->velx = bvelx; } if (aretorps) { aretorps = 0; for (i=0;i<2;i++) for (y=0;y<3;y++) for (x=0;x<3;x++) { if (curobj = isatorp[i][y][x]) { to = occupant[(curobj->posy+curobj->vely+YSIZE00)%YSIZE] [(curobj->posx+curobj->velx+XSIZE00)%XSIZE]; if (to && !to->vely && !to->velx) { unmake_object(curobj); if (i) btorp++; else etorp++; } isatorp[i][y][x]=0; } } } move_universe(); if (finish) { finish--; if (!finish && (!(numenemies || numos) || (!ent && !base))) { done = TRUE; timer -= 5; } } else if (!banging && (!(numenemies || numos) || (!ent && !base))) finish = 5; } while (!done); } ================================================ FILE: games/warp/play.h ================================================ /* $Header: play.h,v 7.0 86/10/08 15:13:12 lwall Exp $ */ /* $Log: play.h,v $ * Revision 7.0 86/10/08 15:13:12 lwall * Split into separate files. Added amoebas and pirates. * */ EXT int finish INIT(0); EXT int timer; void play(); void play_init(); ================================================ FILE: games/warp/score.c ================================================ /* $Header: /usr/src/games/warp/RCS/score.c,v 1.1.1 95/01/21 02:13:26 games Exp $ */ /* $Log: score.c,v $ * Revision 7.0.1.2a 87/07/03 02:13:26 games * Fixed numerous long vs. int bugs in printfs, etc. * * Revision 7.0.1.2 86/10/20 12:06:56 lwall * Made all exits reset tty. * * Revision 7.0.1.1 86/10/16 10:52:47 lwall * Added Damage. Fixed random bugs. * * Revision 7.0 86/10/08 15:13:14 lwall * Split into separate files. Added amoebas and pirates. * */ #include "EXTERN.h" #include "warp.h" #include "intrp.h" #include "object.h" #include "play.h" #include "sig.h" #include "term.h" #include "us.h" #include "util.h" #include "weapon.h" #include "INTERN.h" #include "score.h" #include #include #include void score_init() { register char *s; register int i; FILE *savfil; if (stat(SAVEDIR,&filestat)) { printf("Cannot access %s\r\n",SAVEDIR); finalize(1); } if (filestat.st_uid != geteuid()) { printf("Warp will not run right without being setuid.\r\n"); finalize(1); } if ((filestat.st_mode & 0605) != 0605) { printf("%s is not protected correctly (must be u+rw o+rx).\r\n",SAVEDIR); finalize(1); } interp(longlognam, sizeof longlognam, "%L"); for (i=strlen(longlognam); i<8; i++) longlognam[i] = ' '; /* make sure it is 8 long for strncmp */ longlognam[8] = '\0'; if (scorespec) wscore(); Sprintf(savefilename, "save.%s", logname); savfil = experimenting ? NULL : fopen(savefilename,"r"); if (savfil != NULL && fgets(spbuf,100,savfil) != NULL) { char tmpbuf[80]; spbuf[strlen(spbuf)-1] = '\0'; if (fgets(tmpbuf,80,savfil) != NULL) { int processnum; tmpbuf[strlen(tmpbuf)-1] = '\0'; printf("You seem to have left a game %s.\r\n",tmpbuf+9); s = strchr(tmpbuf+9, ','); *s = '\0'; processnum = atoi(s+11); if (kill(processnum, SIGINT)) { /* does process not exist? */ /* (warp ignores SIGINT) */ printf("\r\n\ That process does not seem to exist anymore, so you'll have to start the\r\n"); printf( "last wave over.\r\n\n"); printf( " [type anything to continue]"); Fflush(stdout); eat_typeahead(); getcmd(tmpbuf); if (*tmpbuf == INTRCH) finalize(0); printf("\r\n"); } else { if (strcmp(term+8,tmpbuf+23)) { printf( "That is not your current terminal--you are on %s.\r\n", term+5); printf("\r\nYour options:\r\n"); printf(" 1) Exit and find the terminal it's running on\r\n"); } else { printf("\r\nYour options:\r\n"); printf(" 1) Exit and try to foreground it\r\n"); } printf(" 2) Let me terminate the other game\r\n\n"); printf("What do you want to do? "); Fflush(stdout); eat_typeahead(); getcmd(tmpbuf); printf("\r\n"); if (*tmpbuf == INTRCH) finalize(0); if (*tmpbuf == '1') { printf( "If you don't succeed, come back and do option 2 instead. Good luck.\r\n"); finalize(0); } printf( "Ok, hang on a few moments \r\n"); Fclose(savfil); if (kill(processnum, SIGQUIT)) { printf("Unable to kill process #%d!\r\n",processnum); roundsleep(2); } else { #ifdef SIGCONT kill(processnum, SIGCONT); #endif for (i=15; i; --i) { sleep(1); if (kill(processnum,SIGINT)) /* does process not exist? */ /* (warp ignores SIGINT) */ break; } didkill++; } savfil = fopen(savefilename,"r"); if (savfil != NULL) { if (fgets(spbuf,100,savfil) == 0) /*ignore*/; } } } } else savfil = NULL; if (savfil == NULL) { totalscore = smarts = cumsmarts = wave = 0; numents = 5; numbases = 3; } else { totalscore = atol(spbuf+9); smarts = atoi(spbuf+20); cumsmarts = atoi(spbuf+24); numents = atoi(spbuf+30); numbases = atoi(spbuf+33); wave = atoi(spbuf+36); apolspec = (spbuf[40] == 'a'); beginner = (spbuf[41] == 'b'); crushspec = (spbuf[42] == 'c'); gornspec = (spbuf[43] == 'g'); massacre = (spbuf[44] == 'm'); romspec = (spbuf[45] == 'r'); tholspec = (spbuf[46] == 't'); lowspeed = (spbuf[47] == 'l') || lowspeed; amoebaspec = (spbuf[48] == '&'); Fclose(savfil); } if (!ismarts) { ismarts = 1; clear(); page(NEWSFILE,FALSE); if (smarts) { printf("\r\nSaved game: SCORE DIFF CUMDIFF ENTERPRISES BASES WAVE"); printf("\r\n %7ld %2d %4d %1d %1d %3d", totalscore,smarts,cumsmarts,numents,numbases,wave); } printf("\r\nWould you like instructions? "); Fflush(stdout); eat_typeahead(); getcmd(buf); printf("\r\n"); if (*buf == INTRCH) finalize(0); if (*buf == 'Y' || *buf == 'y') { page(HELPFILE,FALSE); printf("\r\nWould you like to play easy games for a while? "); Fflush(stdout); eat_typeahead(); getcmd(buf); printf("\r\n"); if (*buf == 'Y' || *buf == 'y') { beginner = TRUE; lowspeed = TRUE; } } } if (!smarts) smarts = ismarts; } void wscore() { clear(); printf(" TOP WARPISTS\r\n\n"); printf("RANK WHO AKA SCORE DIFF CUMDIFF WHEN\r\n"); page(SCOREBOARD,TRUE); printf(" [Type anything to continue]"); Fflush(stdout); getcmd(spbuf); if (*spbuf == INTRCH) finalize(0); clear(); printf(" TOP LOW-SPEED WARPISTS\r\n\n"); printf("RANK WHO AKA SCORE DIFF CUMDIFF WHEN\r\n"); page(LSCOREBOARD,TRUE); printf(" [Type anything to continue]"); Fflush(stdout); getcmd(spbuf); if (*spbuf == INTRCH) finalize(0); clear(); printf(" TOP FUNNY WARPISTS\r\n\n"); printf("RANK WHO AKA SCORE DIFF CUMDIFF WHEN\r\n"); page(FSCOREBOARD,TRUE); printf(" [Type anything to continue]"); Fflush(stdout); getcmd(spbuf); if (*spbuf == INTRCH) finalize(0); clear(); printf(" GAMES SAVED OR IN PROGRESS\r\n\n"); printf("WHO SCORE DF CDF E B WV FLAGS\r\n"); resetty(); Sprintf(spbuf,"/bin/cat %ssave.*",SAVEDIR); execl("/bin/sh", "sh", "-c", spbuf, (char*)0); finalize(1); } void display_status() { register int tmp; static char *status_names[] = {"Impl", "Warp", "Base", "****" }; if (oldstatus != status) { Sprintf(spbuf,"%-4s",status_names[status]); mvaddstr(0,0, spbuf); oldstatus = status; } if (ent) { if (ent->energy != oldeenergy) { oldeenergy = ent->energy; Sprintf(spbuf,"%4ld",oldeenergy); mvaddstr(0,8, spbuf); } if (etorp != oldetorp) { Sprintf(spbuf,"%2d",etorp); mvaddstr(0,13, spbuf); oldetorp = etorp; } } else { if (etorp >= 0) { etorp = -1; mvaddstr(0,8,"*******"); damage = 0; } } if (base) { if (base->energy != oldbenergy) { oldbenergy = base->energy; Sprintf(spbuf,"%5ld",oldbenergy); mvaddstr(0,19, spbuf); } if (btorp != oldbtorp) { Sprintf(spbuf,"%3d",btorp); mvaddstr(0,25, spbuf); oldbtorp = btorp; } } else { if (btorp >= 0) { btorp = -1; mvaddstr(0,19,"*********"); } } if (damage) { if (!olddamage) mvaddstr(0,42,"*** "); if (damage > 1 || !damflag[dam]) { do { if (++dam == MAXDAMAGE) dam = 0; } while (!damflag[dam]); } if (!--damflag[dam]) { olddamage = damage; damage--; Sprintf(spbuf,"%s OK *** ",dammess[dam]); spbuf[15] = '\0'; mvaddstr(0,46,spbuf); } else if (dam == NOSHIELDS) { olddamage = damage; tmp = (34 - damflag[dam]) * 3 - rand_mod(3); if (tmp < 0) tmp = 0; Sprintf(spbuf,"%d%% %s *** ",tmp,dammess[dam]); spbuf[15] = '\0'; mvaddstr(0,46,spbuf); } else if (dam != lastdam || !olddamage) { olddamage = damage; Sprintf(spbuf,"NO %s *** ",dammess[dam]); spbuf[15] = '\0'; mvaddstr(0,46,spbuf); } if (status < 2) { if (dam == NOIMPULSE && !entmode) status = entmode = 1; if (dam == NOWARP && entmode) status = entmode = 0; } tmp = damflag[dam] * damage; Sprintf(spbuf,"%3d.%1d ETR",tmp/10,tmp%10); mvaddstr(0,69,spbuf); lastdam = dam; } else { if (olddamage) { Sprintf(spbuf,"Stars: %-3d Stardate",numstars); mvaddstr(0,42,spbuf); lastdam = -1; olddamage = 0; oldcurscore = -1; } else if (numstars != oldstrs) { Sprintf(spbuf,"%-3d",numstars); mvaddstr(0,49, spbuf); } oldstrs = numstars; } if (numenemies != oldenemies) { Sprintf(spbuf,"%-3d",numenemies); mvaddstr(0,38, spbuf); oldenemies = numenemies; } if (tmp = timer%10) { Sprintf(spbuf,"%1d",tmp); mvaddstr(0,67, spbuf); } else { Sprintf(spbuf,"%5d.%1d",timer/10+smarts*100,tmp); mvaddstr(0,61, spbuf); } if ((!damage || !damflag[dam]) && curscore != oldcurscore) { Sprintf(spbuf,"%9ld",curscore); mvaddstr(0,69, spbuf); oldcurscore = curscore; } } void wavescore() { double power, effectscore, starscore, pi_over_2; long bonuses; long tmp; FILE *mapfp; int row; clear(); if (curscore > possiblescore) curscore = possiblescore; pi_over_2 = 3.14159265 / 2.0; power = pow((double)inumenemies+ /* total number of enemies */ inumroms*2+ /* count roms 3 times */ inumgorns+ /* count gorns 2 times */ inumthols+ /* count thols 2 times */ inumapollos*4+ /* count apollo 5 times */ inumcrushes*3+ /* count crushers 4 times */ inumamoebas*5 /* count amoebas 6 times */ , 0.50) * /* skew it a little */ (double)smarts; /* average energy and intelligence */ if (inumstars < 350 && inumenemies > 5) power += (350.0 - (double)inumstars) * ((double)inumenemies - 5.0); if (inumstars > 850 && inumenemies > 2) power += ((double)inumstars - 850.0) * ((double)inumenemies - 2.0); effectscore = ((double)curscore / possiblescore) * atan2(power, (double) timer + 1.0) / pi_over_2; if (inumstars) starscore = (double) numstars / (double) inumstars; else starscore = 1.0; wave++; Sprintf(spbuf,"Wave = %d, Difficulty = %d, cumulative difficulty = %d", wave, smarts, cumsmarts); mvaddstr(1, 13+(smarts<10), spbuf); mvaddstr( 4, 68, " BONUS"); Sprintf(spbuf,"Efficiency rating: %1.8f (diff=%0.2f,time=%d)", effectscore, power, timer + 1); mvaddstr( 5,5, spbuf); if (effectscore < 0.8) bonuses = tmp = 0; else bonuses = tmp = (long) ((effectscore-0.8) * smarts * 1000); Sprintf(spbuf, "%6ld", tmp); mvaddstr( 5, 68, spbuf); Sprintf(spbuf,"Star save ratio: %1.8f (%d/%d)", starscore, numstars, inumstars); mvaddstr( 6,5, spbuf); bonuses += tmp = (long) (((double)curscore / possiblescore) * (starscore*starscore) * smarts * 20); Sprintf(spbuf, "%6ld", tmp); mvaddstr( 6, 68, spbuf); row = 7; if (inuminhab != numinhab) { Sprintf(spbuf, "Inhabited stars depopulated: %5d", inuminhab-numinhab); mvaddstr(row,5, spbuf); bonuses += tmp = (long) (inuminhab-numinhab) * -500; Sprintf(spbuf, "%6ld", tmp); mvaddstr(row, 68, spbuf); row++; } if (inumfriends != numfriends) { Sprintf(spbuf, "Friendly craft destroyed: %5d", inumfriends-numfriends); mvaddstr(row,5, spbuf); bonuses += tmp = (long) (inumfriends-numfriends) * -250; Sprintf(spbuf, "%6ld", tmp); mvaddstr(row, 68, spbuf); row++; } if (deadmudds) { mvaddstr(row,5,"For destroying Harry Mudd:"); bonuses += tmp = (long) rand_mod(deadmudds * 20 + 1) - deadmudds*10; Sprintf(spbuf, "%6ld", tmp); mvaddstr(row, 68, spbuf); row++; } if (bombed_out) { mvaddstr(row,5, "For running away from reality:"); bonuses += tmp = (long) -possiblescore/2; Sprintf(spbuf, "%6ld", tmp); mvaddstr(row, 68, spbuf); row++; } if (row < 9) row++; Sprintf(spbuf, "Enterprise: %-9s%5d remaining", !ient?"":ent?"saved":"destroyed", numents); mvaddstr(row,5, spbuf); bonuses += tmp = ent && !bombed_out ? (smarts+1)*15 : 0; Sprintf(spbuf, "%6ld", tmp); mvaddstr(row, 68, spbuf); row++; Sprintf(spbuf, "Base: %-9s %5d remaining", !ibase?"":base?"saved":"destroyed", numbases); mvaddstr(row,5, spbuf); bonuses += tmp = base && !bombed_out ? (smarts+1)*10 : 0; Sprintf(spbuf, "%6ld", tmp); mvaddstr(row, 68, spbuf); if (beginner) { mvaddstr(13+(row>11),19, "(Special games count only a tenth as much)"); curscore /= 10; bonuses /= 10; } Sprintf(spbuf, "Previous point total:%10ld",lastscore); mvaddstr(15,24, spbuf); Sprintf(spbuf, "Points this round: %10ld",curscore); mvaddstr(16,24, spbuf); Sprintf(spbuf, "Bonuses: %10ld",bonuses); mvaddstr(17,24, spbuf); totalscore = lastscore + curscore + bonuses; Sprintf(spbuf, "New point total: %10ld",totalscore); mvaddstr(18,24, spbuf); if (lastscore / ENTBOUNDARY < totalscore / ENTBOUNDARY) { mvaddstr(row-1,42,"+ 1 new"); numents++; } else if (numents>0 && lastscore / ENTBOUNDARY > totalscore / ENTBOUNDARY) { mvaddstr(row-1,42,"- 1 obsolete"); numents--; } if (lastscore / BASEBOUNDARY < totalscore / BASEBOUNDARY) { mvaddstr(row,42,"+ 1 new"); numbases++; } else if (numbases>0 && lastscore / BASEBOUNDARY > totalscore / BASEBOUNDARY) { mvaddstr(row,42,"- 1 obsolete"); numbases--; } if (starscore < 0.8 && inumstars > 200 && numstars > 50) { Sprintf(spbuf, "smap.%d",rand_mod(MAPS-PERMMAPS)+PERMMAPS); if ((mapfp = fopen(spbuf,"w")) != NULL) { register OBJECT *obj; fprintf(mapfp,"%d\n",numstars); for (obj = root.next; obj != &root; obj = obj->next) { if (obj->type == Star) { fprintf(mapfp,"%d %d\n",obj->posy,obj->posx); } } Fclose(mapfp); } } } void score() { char tmp, *retval, cdate[30]; register FILE *logfd; register FILE *outfd; register int i; long nowtime; char *scoreboard; for (i=0; link(LOGFILE, LOCKFILE) == -1 && i<10; i++) sleep(1); nowtime = time((long *)0); strcpy(cdate,ctime(&nowtime)); if ((logfd = fopen(LOGFILE,"a")) != NULL) { fprintf(logfd, "%-24s%-9s%7ld%c%2d %4d %s", realname, logname, totalscore, c,smarts, cumsmarts, cdate); Fclose(logfd); } strcpy(cdate+11,cdate+20); if (beginner) scoreboard = FSCOREBOARD; else if (lowspeed) scoreboard = LSCOREBOARD; else scoreboard = SCOREBOARD; if (eaccess(scoreboard,0)) { if ((logfd = fopen(scoreboard,"w")) != NULL) Fclose(logfd); } if ((logfd = fopen(scoreboard,"r")) != NULL && (outfd = fopen(TMPSCOREBOARD,"w")) != NULL) { for (i=0; i<20; i++) { if ((retval = fgets(buf, 100, logfd)) == NULL) break; if (atol(buf+32) < totalscore) break; if (strnEQ(buf+COMPOFF,COMPNAME,COMPLEN)) { i = 100; break; } fprintf(outfd, "%s", buf); } if (i == 100) { mvaddstr(20,21, "You did not better your previous score"); Fclose(outfd); unlink(TMPSCOREBOARD); } else if (i < 20) { fprintf(outfd, "%-24s%-8s%8ld%c %2d %4d %s", realname, logname, totalscore, c,smarts, cumsmarts, cdate); i++; Sprintf(spbuf, " Congratulations--you've placed %d%s", i, i==1?"st":(i==2?"nd":(i==3?"rd":"th"))); if (retval != NULL) { if (strnNE(buf+COMPOFF,COMPNAME,COMPLEN)) { fprintf(outfd, "%s", buf); i++; } else strcpy(spbuf,"Congratulations--you've bettered your score"); while (i<20) { if (fgets(buf, 100, logfd) == NULL) break; if (strnNE(buf+COMPOFF,COMPNAME,COMPLEN)) { fprintf(outfd, "%s", buf); i++; } } } mvaddstr(20,19, spbuf); Fclose(logfd); Fclose(outfd); while (unlink(scoreboard) == 0) ; link(TMPSCOREBOARD,scoreboard) >= 0; unlink(TMPSCOREBOARD); logfd = fopen(scoreboard,"r"); } else { mvaddstr(20,22,"You did not place within the top 20"); Fclose(outfd); } } else { Sprintf(spbuf,"(Cannot access %s file, error %d)", (logfd==NULL?"log":"tmp"),errno); mvaddstr(20,22,spbuf); } move(23,0,0); erase_eol(); mvaddstr(23,11, "[Hit space for scoreboard, 'r' for new game, 'q' to quit]"); unlink(LOCKFILE); Fflush(stdout); eat_typeahead(); do { getcmd(&tmp); } while (tmp != INTRCH && tmp != BREAKCH && !strchr(" rqQ",tmp)); if (strchr("qQr",tmp)) { justonemoretime = (tmp == 'r'); if (logfd != NULL) Fclose(logfd); } else { clear(); if (logfd != NULL) { fseek(logfd, 0L, 0); if (beginner) mvaddstr(0,31,"TOP FUNNY WARPISTS"); else if (lowspeed) mvaddstr(0,29,"TOP LOW-SPEED WARPISTS"); else mvaddstr(0,33,"TOP WARPISTS"); mvaddstr(2,0,"RANK WHO AKA SCORE DIFF CUMDIFF WHEN"); for (i=1; i<=20; i++) { if (fgets(buf, 100, logfd) == NULL) break; buf[strlen(buf)-1] = '\0'; Sprintf(spbuf, " %2d %s", i, buf); mvaddstr(i+2,0, spbuf); } Fclose(logfd); } roundsleep(1); mvaddstr(23,25,"Would you like to play again?"); eat_typeahead(); do { getcmd(&tmp); } while (tmp != INTRCH && tmp != BREAKCH && !strchr("nNyY \n\r",tmp)); if (tmp == 'n' || tmp == 'N' || tmp == INTRCH || tmp == BREAKCH) justonemoretime = FALSE; } smarts = ismarts; totalscore = cumsmarts = wave = 0; numents = 5; numbases = 3; apolspec = FALSE; beginner = FALSE; crushspec = FALSE; gornspec = FALSE; massacre = (ismarts >= 40); romspec = FALSE; tholspec = FALSE; } void save_game() { FILE *savfil; if (experimenting) return; if ((savfil = fopen(savefilename,"w")) == NULL) { resetty(); printf("Cannot save game\r\n"); finalize(1); } fprintf(savfil, "%-8s %10ld, %2d,%5d,%2d,%2d,%3d %c%c%c%c%c%c%c%c\n", logname, totalscore, smarts, cumsmarts, numents, numbases, wave, apolspec ? 'a' : ' ', beginner ? 'b' : ' ', crushspec ? 'c' : ' ', gornspec ? 'g' : ' ', massacre ? 'm' : ' ', romspec ? 'r' : ' ', tholspec ? 't' : ' ', lowspeed ? 'l' : ' ', amoebaspec ? '&' : ' ' ); Fclose(savfil); resetty(); if (panic) finalize(0); clear(); finalize(0); } ================================================ FILE: games/warp/score.h ================================================ /* $Header: score.h,v 7.0 86/10/08 15:13:21 lwall Exp $ */ /* $Log: score.h,v $ * Revision 7.0 86/10/08 15:13:21 lwall * Split into separate files. Added amoebas and pirates. * */ #define ENTBOUNDARY 100000 /* point boundary across which a new E is awarded */ #define BASEBOUNDARY 250000 /* point boundary across which a new B is awarded */ EXT int oldstatus; EXT int oldetorp; EXT int oldbtorp; EXT int oldstrs; EXT int oldenemies; EXT long totalscore; EXT long lastscore INIT(0); EXT long curscore; EXT long possiblescore; EXT long oldeenergy; EXT long oldbenergy; EXT long oldcurscore; EXT char savefilename[40]; #ifdef SCOREFULL #define COMPOFF 0 #define COMPNAME longlognam #define COMPLEN 24 #else #define COMPOFF 24 #define COMPNAME longlognam #define COMPLEN 8 #endif EXT char longlognam[128]; EXT char c INIT(' '); void score_init(); void wscore(); void display_status(); void wavescore(); void score(); void save_game(); ================================================ FILE: games/warp/sig.c ================================================ /* $Header: /usr/src/games/warp/RCS/sig.c,v 1.1 87/07/03 01:47:11 games Exp $ */ /* $Log: sig.c,v $ * Revision 7.0.1.2 99/10/24 * Update to sigprocmask. * * Revision 7.0.1.1a 87/07/03 01:47:11 games * Changed sigsetmask to use sigmask instead of calculating it (incorrectly) * by hand. * * Revision 7.0.1.1 86/12/12 17:02:44 lwall * Baseline for net release. * * Revision 7.0 86/10/08 15:13:24 lwall * Split into separate files. Added amoebas and pirates. * */ #include "EXTERN.h" #include "warp.h" #include "play.h" #include "score.h" #include "term.h" #include "util.h" #include "INTERN.h" #include "sig.h" void sig_init() { sigignore(SIGINT); /* for inquiry of existence via kill call */ #ifdef SIGTTOU sigignore(SIGTTOU); #endif sigset(SIGHUP, sig_catcher); if (!debugging) { sigset(SIGQUIT, sig_catcher); sigset(SIGILL, sig_catcher); sigset(SIGFPE, sig_catcher); sigset(SIGBUS, sig_catcher); sigset(SIGSEGV, sig_catcher); sigset(SIGSYS, sig_catcher); sigset(SIGTERM, sig_catcher); } #ifdef SIGXCPU sigset(SIGXCPU, sig_catcher); #endif #ifdef SIGCONT sigset(SIGCONT, cont_catcher); #endif #ifdef SIGTSTP sigset(SIGTSTP, stop_catcher); sigset(SIGSTOP, stop_catcher); #endif } #ifdef SIGTSTP void cont_catcher() { sigset(SIGCONT,cont_catcher); savetty(); crmode(); raw(); noecho(); nonl(); } #endif void mytstp() { resetty(); #ifdef SIGTSTP kill(0,SIGTSTP); #else if (fork()) wait(0); else { char *shell = getenv("SHELL"); setuid(getuid()); if (!*shell) shell = "/bin/sh"; execl(shell,shell,0); exit(1); } #endif rewrite(); } void /* very much void */ finalize(status) int status; { if (bizarre) resetty(); if (status < 0) { chdir("/usr/tmp"); sigset(SIGILL,SIG_DFL); abort(); } exit(status); } /* come here on signal other than interrupt, stop, or cont */ void sig_catcher(signo) { #ifdef VERBOSE static char *signame[] = { "", "HUP", "INT", "QUIT", "ILL", "TRAP", "IOT", "EMT", "FPE", "KILL", "BUS", "SEGV", "SYS", "PIPE", "ALRM", "TERM", "???" #ifdef SIGTSTP ,"STOP", "TSTP", "CONT", "CHLD", "TTIN", "TTOU", "TINT", "XCPU", "XFSZ" #ifdef SIGPROF ,"VTALARM", "PROF" #endif #endif }; #endif #ifdef SIGTTOU sigignore(SIGTTOU); #endif #ifdef DEBUGGING if (debug) { printf("\r\nSIG%s--game not saved in debug\r\n",signame[signo]); finalize(-1); } #endif panic++; if (panic >= 2) { if (panic >= 3) abort(); chdir(SAVEDIR); kill(0,SIGIOT); } (void) sigset(SIGILL,SIG_DFL); if (signo == SIGHUP && (timer < 10 || didkill)) signo = SIGQUIT; if (signo == SIGQUIT) { /* can't let them bomb out without penalty */ if (smarts < 20) smarts += 4; else if (smarts < 35) smarts += 2; else smarts++; totalscore -= possiblescore / 2; } save_game(); if (signo != SIGHUP && signo != SIGQUIT) #ifdef VERBOSE IF(verbose) printf("\r\nCaught %s%s--%s\r\n", signo ? "a SIG" : "an internal error", signame[signo], experimenting ? "game saved" : "bye bye"); ELSE #endif #ifdef TERSE printf("\r\nSignal %d--bye bye\r\n",signo); #endif switch (signo) { case SIGBUS: case SIGILL: case SIGSEGV: finalize(-signo); } finalize(1); /* and blow up */ } #ifdef SIGTSTP /* come here on stop signal */ void stop_catcher() { sigset_t set; if (!waiting) { resetty(); /* this is the point of all this */ #ifdef DEBUGGING if (debug) write(2,"stop_catcher\r\n",13); #endif sigset(SIGTSTP,SIG_DFL); /* enable stop */ (void)sigemptyset(&set); (void)sigaddset(&set, SIGTSTP); (void)sigprocmask(SIG_UNBLOCK, &set, NULL); kill(0,SIGTSTP); /* and do the stop */ } sigset(SIGTSTP,stop_catcher); /* unenable the stop */ } #endif ================================================ FILE: games/warp/sig.h ================================================ /* $Header: sig.h,v 7.0 86/10/08 15:13:32 lwall Exp $ */ /* $Log: sig.h,v $ * Revision 7.0 86/10/08 15:13:32 lwall * Split into separate files. Added amoebas and pirates. * */ void sig_catcher(); #ifdef SIGTSTP void cont_catcher(); void stop_catcher(); #endif void mytstp(); void sig_init(); void finalize(); ================================================ FILE: games/warp/sm.c ================================================ /* $Header: sm.c,v 7.0 86/10/08 15:13:35 lwall Exp $ */ /* $Log: sm.c,v $ * Revision 7.0 86/10/08 15:13:35 lwall * Split into separate files. Added amoebas and pirates. * */ #include #include #include int main() { char screen[23][90]; register int y; register int x; int tmpy, tmpx; for (x=0; x<79; x++) screen[0][x] = ' '; screen[0][79] = '\0'; if (fgets(screen[0], 90, stdin) == 0) { perror("stdin"); return 1; } if (isdigit(screen[0][0])) { int numstars = atoi(screen[0]); for (y=0; y<23; y++) { for (x=0; x<79; x++) screen[y][x] = ' '; screen[y][79] = '\0'; } for ( ; numstars; numstars--) { if (scanf("%d %d\n", &tmpy, &tmpx) != 2) { perror("two numbers expected"); return 1; } y = tmpy; x = tmpx; screen[y][x+x] = '*'; } for (y=0; y<23; y++) { printf("%s\n",screen[y]); } } else { register int numstars = 0; for (y=1; y<23; y++) { for (x=0; x<79; x++) screen[y][x] = ' '; screen[y][79] = '\0'; } for (y=1; y<23; y++) { if (fgets(screen[y], 90, stdin) == 0) { perror("stdin"); return 1; } } for (y=0; y<23; y++) { for (x=0; x<80; x += 2) { if (screen[y][x] == '*') { numstars++; } else if (screen[y][x] == '\t' || screen[y][x+1] == '\t') { fprintf(stderr,"Cannot have tabs in starmap--please expand.\n"); exit(1); } } } printf("%d\n",numstars); for (y=0; y<23; y++) { for (x=0; x<80; x += 2) { if (screen[y][x] == '*') { printf("%d %d\n",y,x/2); } } } } exit(0); } ================================================ FILE: games/warp/smp.0 ================================================ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ================================================ FILE: games/warp/smp.1 ================================================ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ================================================ FILE: games/warp/smp.2 ================================================ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ================================================ FILE: games/warp/smp.3 ================================================ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ================================================ FILE: games/warp/smp.4 ================================================ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ================================================ FILE: games/warp/smp.5 ================================================ * * * * * * * * * * * * * * * * ================================================ FILE: games/warp/smp.6 ================================================ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ================================================ FILE: games/warp/smp.7 ================================================ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ================================================ FILE: games/warp/term.c ================================================ /* $Header: term.c,v 7.0.1.2 86/12/12 17:04:09 lwall Exp $ */ /* $Log: term.c,v $ * Revision 7.0.1.2 86/12/12 17:04:09 lwall * Baseline for net release. * * Revision 7.0.1.1 86/10/16 10:53:20 lwall * Added Damage. Fixed random bugs. * * Revision 7.0 86/10/08 15:14:02 lwall * Split into separate files. Added amoebas and pirates. * */ #include "EXTERN.h" #include "warp.h" #include "bang.h" #include "intrp.h" #include "object.h" #include "play.h" #include "score.h" #include "sig.h" #include "us.h" #include "util.h" #include "weapon.h" #include "INTERN.h" #include "term.h" #include int typeahead = FALSE; char tcarea[TCSIZE]; /* area for "compiled" termcap strings */ /* guarantee capability pointer != Nullch */ /* (I believe terminfo will ignore the &tmpaddr argument.) */ #define Tgetstr(key) ((tstr = tgetstr(key,&tmpaddr)) ? tstr : nullstr) #ifdef PUSHBACK struct keymap { char km_type[128]; union km_union { struct keymap *km_km; char *km_str; } km_ptr[128]; }; #define KM_NOTHIN 0 #define KM_STRING 1 #define KM_KEYMAP 2 #define KM_BOGUS 3 #define KM_TMASK 3 #define KM_GSHIFT 4 #define KM_GMASK 7 typedef struct keymap KEYMAP; KEYMAP *topmap INIT(Null(KEYMAP*)); void mac_init(); KEYMAP *newkeymap(); void pushstring(); #endif /* terminal initialization */ void term_init() { savetty(); /* remember current tty state */ #ifdef TERMIO ospeed = _tty.c_cflag & CBAUD; /* for tputs() */ ERASECH = _tty.c_cc[VERASE]; /* for finish_command() */ KILLCH = _tty.c_cc[VKILL]; /* for finish_command() */ #else ospeed = _tty.sg_ospeed; /* for tputs() */ ERASECH = _tty.sg_erase; /* for finish_command() */ KILLCH = _tty.sg_kill; /* for finish_command() */ #endif } /* set terminal characteristics */ void term_set(tcbuf) char *tcbuf; /* temp area for "uncompiled" termcap entry */ { char *tmpaddr; /* must not be register */ register char *tstr; char *tgetstr(); char *s; int retval; #ifdef PENDING #ifndef FIONREAD /* do no delay reads on something that always gets closed on exit */ devtty = open("/dev/tty",0); if (devtty < 0) { printf(cantopen,"/dev/tty"); finalize(1); } fcntl(devtty,F_SETFL,O_NDELAY); #endif #endif /* get all that good termcap stuff */ retval = tgetent(tcbuf,getenv("TERM")); /* get termcap entry */ if (retval < 1) { #ifdef VERBOSE printf("No termcap %s found.\n", retval ? "file" : "entry"); #else fputs("Termcap botch\n",stdout); #endif finalize(1); } tmpaddr = tcarea; /* set up strange tgetstr pointer */ s = Tgetstr("pc"); /* get pad character */ PC = *s; /* get it where tputs wants it */ if (!tgetflag("bs")) { /* is backspace not used? */ BC = Tgetstr("bc"); /* find out what is */ if (BC == nullstr) /* terminfo grok's 'bs' but not 'bc' */ BC = Tgetstr("le"); } else BC = "\b"; /* make a backspace handy */ UP = Tgetstr("up"); /* move up a line */ ND = Tgetstr("nd"); /* non-destructive move cursor right */ DO = Tgetstr("do"); /* move cursor down */ if (!*DO) DO = Tgetstr("nl"); CL = Tgetstr("cl"); /* get clear string */ CE = Tgetstr("ce"); /* clear to end of line string */ CM = Tgetstr("cm"); /* cursor motion - PWP */ HO = Tgetstr("ho"); /* home cursor if no CM - PWP */ CD = Tgetstr("cd"); /* clear to end of display - PWP */ SO = Tgetstr("so"); /* begin standout */ SE = Tgetstr("se"); /* end standout */ if ((SG = tgetnum("sg"))<0) SG = 0; /* blanks left by SG, SE */ US = Tgetstr("us"); /* start underline */ UE = Tgetstr("ue"); /* end underline */ if ((UG = tgetnum("ug"))<0) UG = 0; /* blanks left by US, UE */ if (*US) UC = nullstr; /* UC must not be NULL */ else UC = Tgetstr("uc"); /* underline a character */ if (!*US && !*UC) { /* no underline mode? */ US = SO; /* substitute standout mode */ UE = SE; UG = SG; } LINES = tgetnum("li"); /* lines per page */ COLS = tgetnum("co"); /* columns on page */ AM = tgetflag("am"); /* terminal wraps automatically? */ XN = tgetflag("xn"); /* then eats next newline? */ VB = Tgetstr("vb"); if (!*VB) VB = "\007"; CR = Tgetstr("cr"); if (!*CR) { if (tgetflag("nc") && *UP) { CR = safemalloc((MEM_SIZE)strlen(UP)+2); Sprintf(CR,"%s\r",UP); } else CR = "\r"; } if (LINES <= 0) LINES = 24; if (COLS <= 0) COLS = 80; BCsize = comp_tc(bsptr,BC,1); BC = bsptr; if (!*ND) /* not defined? */ NDsize = 1000; /* force cursor addressing */ else { NDsize = comp_tc(cmbuffer,ND,1); myND = malloc((unsigned)NDsize); movc3(NDsize,cmbuffer,myND); if (debugging) { int scr; printf("ND"); for (scr=0; scr= B9600 ? 480 : ospeed == B4800 ? 240 : ospeed == B2400 ? 120 : ospeed == B1200 ? 60 : ospeed == B600 ? 30 : /* speed is 300 (?) */ 15; gfillen = ospeed >= B9600 ? (sizeof filler) : ospeed == B4800 ? 13 : ospeed == B2400 ? 7 : ospeed == B1200 ? 4 : 1+BCsize; if (ospeed < B2400) lowspeed = TRUE; strcpy(term,ttyname(2)); if (!*CM || !BCsize) no_can_do("dumb"); if (!scorespec && (LINES < 24 || COLS < 80)) no_can_do("puny"); crmode(); raw(); noecho(); /* turn off echo */ nonl(); #ifdef PUSHBACK mac_init(tcbuf); #endif } #ifdef PUSHBACK void mac_init(tcbuf) char *tcbuf; { char tmpbuf[1024]; tmpfp = fopen(filexp(getval("WARPMACRO",WARPMACRO)),"r"); if (tmpfp != Nullfp) { while (fgets(tcbuf,1024,tmpfp) != Nullch) { mac_line(tcbuf,tmpbuf,(sizeof tmpbuf)); } Fclose(tmpfp); } } void mac_line(line,tmpbuf,tbsize) char *line; char *tmpbuf; int tbsize; { register char *s; register char *m; register KEYMAP *curmap; register int ch; register int garbage = 0; static char override[] = "\r\nkeymap overrides string\r\n"; if (topmap == Null(KEYMAP*)) topmap = newkeymap(); if (*line == '#' || *line == '\n') return; if (line[ch = strlen(line)-1] == '\n') line[ch] = '\0'; m = dointerp(tmpbuf,tbsize,line," \t"); if (!*m) return; while (*m == ' ' || *m == '\t') m++; for (s=tmpbuf,curmap=topmap; *s; s++) { ch = *s & 0177; if (s[1] == '+' && isdigit(s[2])) { s += 2; garbage = (*s & KM_GMASK) << KM_GSHIFT; } else garbage = 0; if (s[1]) { if ((curmap->km_type[ch] & KM_TMASK) == KM_STRING) { puts(override); free(curmap->km_ptr[ch].km_str); curmap->km_ptr[ch].km_str = Nullch; } curmap->km_type[ch] = KM_KEYMAP + garbage; if (curmap->km_ptr[ch].km_km == Null(KEYMAP*)) curmap->km_ptr[ch].km_km = newkeymap(); curmap = curmap->km_ptr[ch].km_km; } else { if ((curmap->km_type[ch] & KM_TMASK) == KM_KEYMAP) puts(override); else { curmap->km_type[ch] = KM_STRING + garbage; curmap->km_ptr[ch].km_str = savestr(m); } } } } KEYMAP* newkeymap() { register int i; register KEYMAP *map; map = (KEYMAP*)safemalloc(sizeof(KEYMAP)); for (i=127; i>=0; --i) { map->km_ptr[i].km_km = Null(KEYMAP*); map->km_type[i] = KM_NOTHIN; } return map; } #endif /* print out a file, stopping at form feeds */ void page(filename,num) char *filename; bool num; { int linenum = 1; tmpfp = fopen(filename,"r"); if (tmpfp != NULL) { while (fgets(spbuf,(sizeof spbuf),tmpfp) != NULL) { if (*spbuf == '\f') { printf("[Type anything to continue] "); Fflush(stdout); getcmd(spbuf); printf("\r\n"); if (*spbuf == INTRCH) finalize(0); if (*spbuf == 'q' || *spbuf == 'Q') break; } else { if (num) printf("%3d %s\r",linenum++,spbuf); else printf("%s\r",spbuf); } } Fclose(tmpfp); } } void move(y, x, chadd) int y, x; int chadd; { register int ydist; register int xdist; register int i; register char *s; ydist = y - real_y; xdist = x - real_x; i = ydist * (ydist < 0 ? -UPsize : DOsize) + xdist * (xdist < 0 ? -BCsize : NDsize); beg_qwrite(); if (i <= CMsize) { if (ydist < 0) for (; ydist; ydist++) for (i=UPsize,s=myUP; i; i--) qaddch(*s++); else for (; ydist; ydist--) for (i=DOsize,s=myDO; i; i--) qaddch(*s++); if (xdist < 0) for (; xdist; xdist++) for (i=BCsize,s=BC; i; i--) qaddch(*s++); else for (; xdist; xdist--) for (i=NDsize,s=myND; i; i--) qaddch(*s++); } else { tputs(tgoto(CM,x,y),0,cmstore); } real_y = y; real_x = x; if (chadd) { qaddch(chadd); } if (maxcmstring != cmbuffer) end_qwrite(); } void do_tc(s,l) char *s; int l; { beg_qwrite(); tputs(s,l,cmstore); end_qwrite(); } int comp_tc(dest,s,l) char *dest; char *s; int l; { maxcmstring = dest; tputs(s,l,cmstore); return(maxcmstring-dest); } void helper() { clear(); mvaddstr(0,4,"h or 4 left"); mvaddstr(1,4,"j or 2 down Use with SHIFT to fire torpedoes."); mvaddstr(2,4,"k or 8 up Use with CTRL or FUNCT to fire"); mvaddstr(3,4,"l or 6 right phasers or turbolasers."); mvaddstr(4,4,"b or 1 down and left Use preceded by 'a' or 'r' for"); mvaddstr(5,4,"n or 3 down and right attractors or repulsors."); mvaddstr(6,4,"y or 7 up and left Use normally for E or B motion."); mvaddstr(7,4,"u or 9 up and right"); mvaddstr(8,4,""); mvaddstr(9,4,"del or % fire photon torpedoes in every (reasonable) direction."); mvaddstr(10,4,"s stop all torpedoes."); mvaddstr(11,4,"S or 0 stop the Enterprise when in warp mode."); mvaddstr(12,4,"d/D destruct all torpedoes/current vessel."); mvaddstr(13,4,"i/w switch to Enterprise & put into impulse/warp mode."); mvaddstr(14,4,"c/v switch to Enterprise & make cloaked/visible."); mvaddstr(15,4,"p switch to Base."); mvaddstr(16,4,"o toggle to other vessel (from E to B, or vice versa.)"); mvaddstr(17,4,"z zap (suppress) blasts near Enterprise next cycle"); mvaddstr(18,4,""); mvaddstr(19,4,"^R refresh the screen. ^Z suspend the game."); mvaddstr(20,4,"q exit this round (if you haven't typed q within 10 cycles)."); mvaddstr(21,4,"Q exit this game."); mvaddstr(22,4,""); mvaddstr(23,4," [Hit space to continue]"); Fflush(stdout); do { getcmd(spbuf); } while (*spbuf != ' '); rewrite(); } void rewrite() { register int x; register int y; register OBJECT *obj; clear(); for (y=0; yimage != ' ') mvaddc(y+1,x*2,obj->image); } } } Sprintf(spbuf, "%-4s E: %4d %2d B: %5d %3d Enemies: %-3d Stars: %-3d Stardate%5d.%1d %9ld", " ", 0, 0, 0, 0, 0, 0, timer/10+smarts*100, timer%10, 0L); mvaddstr(0,0,spbuf); oldeenergy = oldbenergy = oldcurscore = oldstatus = oldetorp = oldbtorp = oldstrs = oldenemies = -1; /* force everything to fill in */ if (damage) olddamage = 0; if (!ent) etorp = 0; if (!base) btorp = 0; display_status(); } char cmstore(ch) register char ch; { *maxcmstring++ = ch; } /* discard any characters typed ahead */ void eat_typeahead() { #ifdef PUSHBACK if (!typeahead && nextin==nextout) /* cancel only keyboard stuff */ #else if (!typeahead) #endif { #ifdef PENDING while (input_pending()) Read_tty(buf,sizeof(buf)); #else /* this is probably v7, with no rdchk() */ ioctl(_tty_ch,TIOCSETP,&_tty); #endif } } void settle_down() { dingaling(); Fflush(stdout); sleep(1); #ifdef PUSHBACK nextout = nextin; /* empty circlebuf */ #endif eat_typeahead(); } #ifdef PUSHBACK /* read a character from the terminal, with multi-character pushback */ int read_tty(addr,size) char *addr; int size; /* ignored for now */ { if (nextout != nextin) { *addr = circlebuf[nextout++]; nextout %= PUSHSIZE; return 1; } else { size = read(0,addr,1); if (size < 0) sig_catcher(SIGHUP); if (metakey) { if (*addr & 0200) { pushchar(*addr & 0177); *addr = '\001'; } } else *addr &= 0177; return 1; } } #ifdef PENDING #ifndef FIONREAD int circfill() { register int howmany; register int i; assert (nextin == nextout); howmany = read(devtty,circlebuf+nextin,metakey?1:PUSHSIZE-nextin); if (howmany > 0) { if (metakey) { if (circlebuf[nextin] & 0200) { circlebuf[nextin] &= 0177; pushchar('\001'); } } else for (i = howmany+nextin-1; i >= nextin; i--) circlebuf[i] &= 0177; nextin += howmany; nextin %= PUSHSIZE; /* may end up 1 if metakey */ } return howmany; } #endif /* FIONREAD */ #endif /* PENDING */ void pushchar(ch) char ch; { nextout--; if (nextout < 0) nextout = PUSHSIZE - 1; if (nextout == nextin) { fputs("\r\npushback buffer overflow\r\n",stdout); sig_catcher(0); } circlebuf[nextout] = ch; } #else /* PUSHBACK */ #ifndef read_tty /* read a character from the terminal, with hacks for O_NDELAY reads */ int read_tty(addr,size) char *addr; int size; { if (is_input) { *addr = pending_ch; is_input = FALSE; return 1; } else { size = read(0,addr,size); if (size < 0) sig_catcher(SIGHUP); if (metakey) { if (*addr & 0200) { pending_ch = *addr & 0177; is_input = TRUE; *addr = '\001'; } } else *addr &= 0177; return size; } } #endif /* read_tty */ #endif /* PUSHBACK */ int read_nd(buff, siz) char *buff; int siz; { if (!input_pending()) return 0; getcmd(buff); return 1; } /* get a character into a buffer */ void getcmd(whatbuf) register char *whatbuf; { #ifdef PUSHBACK register KEYMAP *curmap; register int i; bool no_macros; int times = 0; /* loop detector */ char scrchar; tryagain: curmap = topmap; /* no_macros = (whatbuf != buf && nextin == nextout); */ no_macros = FALSE; #endif for (;;) { errno = 0; if (read_tty(whatbuf,1) < 0 && !errno) errno = EINTR; #ifdef read_tty if (metakey) { if (*whatbuf & 0200) { *what_buf &= 037; /* punt and hope they don't notice */ } } else *whatbuf &= 0177; #endif /* read_tty */ if (errno && errno != EINTR) { perror(readerr); sig_catcher(0); } #ifdef PUSHBACK if (*whatbuf & 0200 || no_macros) { *whatbuf &= 0177; goto got_canonical; } if (curmap == Null(KEYMAP*)) goto got_canonical; for (i = (curmap->km_type[*whatbuf] >> KM_GSHIFT) & KM_GMASK; i; --i){ Read_tty(&scrchar,1); } switch (curmap->km_type[*whatbuf] & KM_TMASK) { case KM_NOTHIN: /* no entry? */ if (curmap == topmap) /* unmapped canonical */ goto got_canonical; settle_down(); goto tryagain; case KM_KEYMAP: /* another keymap? */ curmap = curmap->km_ptr[*whatbuf].km_km; assert(curmap != Null(KEYMAP*)); break; case KM_STRING: /* a string? */ pushstring(curmap->km_ptr[*whatbuf].km_str); if (++times > 20) { /* loop? */ fputs("\r\nmacro loop?\r\n",stdout); settle_down(); } no_macros = FALSE; goto tryagain; } #else *whatbuf &= 0177; break; #endif } got_canonical: #ifndef TERMIO if (*whatbuf == '\r') *whatbuf = '\n'; #endif if (whatbuf == buf) whatbuf[1] = FINISHCMD; /* tell finish_command to work */ } #ifdef PUSHBACK void pushstring(str) char *str; { register int i; char tmpbuf[PUSHSIZE]; register char *s = tmpbuf; assert(str != Nullch); interp(s,PUSHSIZE,str); for (i = strlen(s)-1; i >= 0; --i) { s[i] ^= 0200; pushchar(s[i]); } } #endif ================================================ FILE: games/warp/term.h ================================================ /* $Header: term.h,v 7.0.1.2 86/12/12 17:05:15 lwall Exp $ */ /* $Log: term.h,v $ * Revision 7.0.1.2 86/12/12 17:05:15 lwall * Baseline for net release. * * Revision 7.0.1.1 86/10/16 10:53:33 lwall * Added Damage. Fixed random bugs. * * Revision 7.0 86/10/08 15:14:07 lwall * Split into separate files. Added amoebas and pirates. * */ /* warp will still work without the following, but may get ahead at low speed */ #ifdef TIOCOUTQ /* chars left in output queue */ #define output_pending() (ioctl(1, TIOCOUTQ, &iocount),iocount) #endif /* If some of the following look something like curses calls, it is because * warp used to use curses but doesn't now. Warp was neither as efficient nor * as portable with curses, and since the program had to cheat on curses all * over the place anyway, we ripped it out. */ #define setimage(of,to) (mvaddch(of->posy+1,of->posx*2,of->image=(to))) #define mvaddch(y,x,ch) move((y),(x),(ch)) /* #define addch(ch) (tmpchr=(ch), write(1,&tmpchr,1), real_x++) */ #define mvaddc(y,x,ch) move((y),(x),(ch)) #define addc(ch) (write(1,&(ch),1), real_x++) #define addspace() (write(1," ",1), real_x++) #define mvaddstr(y,x,s) (move((y),(x),0), tmpstr = (s), \ tmplen = strlen(tmpstr), write(1, tmpstr, tmplen) >= 0, real_x += tmplen) EXT int tmplen; EXT char *tmpstr; /* EXT char tmpchr; */ /* The following macros are like the pseudo-curses macros above, but do * certain amount of controlled output buffering. * * NOTE: a beg_qwrite()..end_qwrite() sequence must NOT contain a cursor * movement (move), because the move() routine uses beg_qwrite()..end_qwrite() * itself. */ #define beg_qwrite() (maxcmstring = cmbuffer) #define qwrite() (movc3(gfillen,filler,maxcmstring), maxcmstring += gfillen) #define qaddc(ch) (*maxcmstring++ = (ch), real_x++) #define qaddch(ch) (*maxcmstring++ = (ch), real_x++) #define qaddspace() (*maxcmstring++ = ' ', real_x++) #define end_qwrite() (write(1,cmbuffer,maxcmstring-cmbuffer) > 0) /* setting a ??size to infinity forces cursor addressing in that direction */ EXT int CMsize; EXT int BCsize INIT(1); EXT int DOsize INIT(1000); EXT int UPsize INIT(1000); EXT int NDsize INIT(1000); EXT int charsperhalfsec; EXT int real_y INIT(-100); EXT int real_x INIT(-100); #ifdef DOINIT char filler[] = {0,'\b',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; #else EXT char filler[]; #endif EXT char *bsptr INIT(filler+1); EXT char term[12]; EXT char gfillen INIT(25); EXT char *maxcmstring; EXT char cmbuffer[512]; #define BREAKCH '\0' EXT char INTRCH INIT('\03'); #ifdef PUSHBACK EXT char circlebuf[PUSHSIZE]; EXT int nextin INIT(0); EXT int nextout INIT(0); # ifdef PENDING # ifdef FIONREAD EXT long iocount INIT(0); # define input_pending() (nextin!=nextout || (ioctl(0, FIONREAD, &iocount),(int)iocount)) # else /* FIONREAD */ int circfill(); # ifndef O_NDELAY /* assert O_NDELAY */ # error PENDING is not defined correctly in warp.h # endif EXT int devtty INIT(0); # define input_pending() (nextin!=nextout || circfill()) # endif /* FIONREAD */ # else /* PENDING */ # error warp wont work without PENDING # define input_pending() (nextin!=nextout) # endif /* PENDING */ #else /* PUSHBACK */ # ifdef PENDING # ifdef FIONREAD /* must have FIONREAD or O_NDELAY for input_pending() */ # define read_tty(addr,size) read(0,addr,size) # define input_pending() (ioctl(0, FIONREAD, &iocount), (int)iocount) EXT long iocount INIT(0); # else /* FIONREAD */ # ifdef RDCHK /* actually, they can have rdchk() too */ # define read_tty(addr,size) read(0,addr,size) # define input_pending() rdchk(0) # else /* RDCHK */ # ifndef O_NDELAY /* assert O_NDELAY */ # error PENDING is not defined correctly in warp.h # endif EXT int devtty INIT(0); EXT bool is_input INIT(FALSE); EXT char pending_ch INIT(0); # define input_pending() (is_input || (is_input=read(devtty,&pending_ch,1))) # endif /* RDCHK */ # endif /* FIONREAD */ # else /* PENDING */ # error warp wont work without PENDING # define read_tty(addr,size) read(0,addr,size) # define input_pending() (FALSE) # endif /* PENDING */ #endif /* PUSHBACK */ /* stuff wanted by terminal mode diddling routines */ #ifdef TERMIO EXT struct termio _tty, _oldtty; #else EXT struct sgttyb _tty; EXT int _res_flg INIT(0); #endif EXT int _tty_ch INIT(2); EXT bool bizarre INIT(FALSE); /* do we need to restore terminal? */ /* terminal mode diddling routines */ #ifdef TERMIO #define raw() ((bizarre=1),_tty.c_lflag &=~ISIG,_tty.c_cc[VMIN] = 1,ioctl(_tty_ch,TCSETAF,&_tty)) #define noraw() ((bizarre=1),_tty.c_lflag |= ISIG,_tty.c_cc[VEOF] = CEOF,ioctl(_tty_ch,TCSETAF,&_tty)) #define crmode() ((bizarre=1),_tty.c_lflag &=~ICANON,_tty.c_cc[VMIN] = 1,ioctl(_tty_ch,TCSETAF,&_tty)) #define nocrmode() ((bizarre=1),_tty.c_lflag |= ICANON,_tty.c_cc[VEOF] = CEOF,ioctl(_tty_ch,TCSETAF,&_tty)) #define echo() ((bizarre=1),_tty.c_lflag |= ECHO, ioctl(_tty_ch, TCSETAW, &_tty)) #define noecho() ((bizarre=1),_tty.c_lflag &=~ECHO, ioctl(_tty_ch, TCSETAW, &_tty)) #define nl() ((bizarre=1),_tty.c_iflag |= ICRNL,_tty.c_oflag |= ONLCR,ioctl(_tty_ch, TCSETAW, &_tty)) #define nonl() ((bizarre=1),_tty.c_iflag &=~ICRNL,_tty.c_oflag &=~ONLCR,ioctl(_tty_ch, TCSETAW, &_tty)) #define savetty() (ioctl(_tty_ch, TCGETA, &_oldtty),ioctl(_tty_ch, TCGETA, &_tty)) #define resetty() ((bizarre=0),ioctl(_tty_ch, TCSETAF, &_oldtty)) #define unflush_output() #else #define raw() ((bizarre=1),_tty.sg_flags|=RAW, stty(_tty_ch,&_tty)) #define noraw() ((bizarre=1),_tty.sg_flags&=~RAW,stty(_tty_ch,&_tty)) #define crmode() ((bizarre=1),_tty.sg_flags |= CBREAK, stty(_tty_ch,&_tty)) #define nocrmode() ((bizarre=1),_tty.sg_flags &= ~CBREAK,stty(_tty_ch,&_tty)) #define echo() ((bizarre=1),_tty.sg_flags |= ECHO, stty(_tty_ch, &_tty)) #define noecho() ((bizarre=1),_tty.sg_flags &= ~ECHO, stty(_tty_ch, &_tty)) #define nl() ((bizarre=1),_tty.sg_flags |= CRMOD,stty(_tty_ch, &_tty)) #define nonl() ((bizarre=1),_tty.sg_flags &= ~CRMOD, stty(_tty_ch, &_tty)) #define savetty() (gtty(_tty_ch, &_tty), _res_flg = _tty.sg_flags) #define resetty() ((bizarre=0),_tty.sg_flags = _res_flg, stty(_tty_ch, &_tty)) #endif /* TERMIO */ #ifdef TIOCSTI #define forceme(c) ioctl(_tty_ch,TIOCSTI,c) /* pass character in " " */ #else #define forceme(c) #endif /* termcap stuff */ /* * NOTE: if you don't have termlib you'll have to define these strings, * the tputs routine, and the tgoto routine. * The tgoto routine simply produces a cursor addressing string for a given * x and y. The 1st argument is a generic string to be interpreted. * If you are hardwiring it you might just ignore the 1st argument. * The tputs routine interprets any leading number as a padding factor, possibly * scaled by the number of lines (2nd argument), puts out the string (1st arg) * and the padding using the routine specified as the 3rd argument. */ EXT char *BC INIT(Nullch); /* backspace character */ EXT char *UP INIT(Nullch); /* move cursor up one line */ EXT char *myUP; EXT char *ND INIT(Nullch); /* non-destructive cursor right */ EXT char *myND; EXT char *DO INIT(Nullch); /* move cursor down one line */ EXT char *myDO; EXT char *CR INIT(Nullch); /* get to left margin, somehow */ EXT char *VB INIT(Nullch); /* visible bell */ EXT char *CL INIT(Nullch); /* home and clear screen */ EXT char *CE INIT(Nullch); /* clear to end of line */ EXT char *CM INIT(Nullch); /* cursor motion -- PWP */ EXT char *HO INIT(Nullch); /* home cursor -- PWP */ EXT char *CD INIT(Nullch); /* clear to end of display -- PWP */ EXT char *SO INIT(Nullch); /* begin standout mode */ EXT char *SE INIT(Nullch); /* end standout mode */ EXT int SG INIT(0); /* blanks left by SO and SE */ EXT char *US INIT(Nullch); /* start underline mode */ EXT char *UE INIT(Nullch); /* end underline mode */ EXT char *UC INIT(Nullch); /* underline a character, if that's how it's done */ EXT int UG INIT(0); /* blanks left by US and UE */ EXT bool AM INIT(FALSE); /* does terminal have automatic margins? */ EXT bool XN INIT(FALSE); /* does it eat 1st newline after automatic wrap? */ EXT char PC INIT(0); /* pad character for use by tputs() */ EXT short ospeed INIT(0); /* terminal output speed, for use by tputs() */ EXT int LINES INIT(0), COLS INIT(0); /* size of screen */ /* (number of nulls) */ EXT char ERASECH; /* rubout character */ EXT char KILLCH; /* line delete character */ /* define a few handy macros */ #define clear() (do_tc(CL,LINES),real_y=real_x=0) #define erase_eol() do_tc(CE,1) #define backspace() (do_tc(BC,0),real_x--) #define clear_rest() do_tc(CD,LINES) #define underline() do_tc(US,1) #define un_underline() do_tc(UE,1) #define underchar() do_tc(UC,0) #define standout() do_tc(SO,1) #define un_standout() do_tc(SE,1) #define up_line() do_tc(UP,1) #define carriage_return() do_tc(CR,1) #define dingaling() do_tc(VB,1) void term_init(); void term_set(); #ifdef PUSHBACK void pushchar(); void mac_init(); void mac_line(); #endif void eat_typeahead(); void settle_down(); #ifndef read_tty int read_tty(); #endif void getcmd(); int read_nd(); void page(); void move(); void do_tc(); int comp_tc(); void helper(); void rewrite(); char cmstore(); ================================================ FILE: games/warp/them.c ================================================ /* $Header: them.c,v 7.0.1.5 86/12/12 17:05:41 lwall Exp $ */ /* $Log: them.c,v $ * Revision 7.0.1.5 86/12/12 17:05:41 lwall * Baseline for net release. * * Revision 7.0.1.4 86/10/20 12:32:38 lwall * Wasn't clearing FRIENDLY flag on pirate creation. * * Revision 7.0.1.3 86/10/20 12:15:33 lwall * Was trying to create pirates from cloaked pirates. * * Revision 7.0.1.2 86/10/17 10:03:44 lwall * Fixed Romulan writing spaces while cloaked. * * Revision 7.0.1.1 86/10/16 10:53:39 lwall * Added Damage. Fixed random bugs. * * Revision 7.0 86/10/08 15:14:15 lwall * Split into separate files. Added amoebas and pirates. * */ #include "EXTERN.h" #include "warp.h" #include "bang.h" #include "object.h" #include "move.h" #include "score.h" #include "term.h" #include "us.h" #include "util.h" #include "weapon.h" #include "INTERN.h" #include "them.h" void them_init() { ; } void their_smarts() { register OBJECT *curkl; register OBJECT *obj; register int prob; register int count; register int y; register int x; if (numcrushes && (obj=movers)->type == Crusher) { if (numamoebas) { y = obj->posy; x = (obj->posx+(obj->image=='<'?1:-1)+XSIZE00)%XSIZE; if (amb[y][x] == '~') { obj->velx = 0; /* stop and munch amoeba */ modify_amoeba(y,x,1,' ',(int)rand_mod(5+ambsize/10)+1); if (occupant[y][x] == nuke) /* except go for nucleus */ obj->velx = (obj->image=='<' ? 1 : -1); } else if (!obj->velx) { if (!rand_mod(4)) obj->image = rand_mod(2) ? '<' : '>'; obj->velx = obj->image == '<' ? 1 : -1; } } obj->vely += (rand_mod(222) - 111) / 100; if (!(rand_mod(100))) { setimage(obj, (obj->velx *= -1) < 0 ? '>' : '<'); } } if (numamoebas) { if (!rand_mod(3)) nuke->velx = nuke->vely = 0; if (nuke->strategy && ambsize < 90 && !rand_mod(200-smarts)) modify_amoeba(0,0,0,'~',(int)rand_mod(10)); if (ambsize > 200 || (ambsize > 100 && !rand_mod(15))) modify_amoeba(yamblast,xamblast,2,' ',(ambsize-100)/5); } for (curkl = enemies; curkl->type == Enemy; curkl = curkl->next) { if ((curkl->flags & (CLOAKS|FRIENDLY)) == CLOAKS && (curkl->image != ' ') && (curkl->energy > 300 || massacre) ) { setimage(curkl, ' '); } if (madgorns) prob = 3; else if (curkl->vely || curkl->velx) prob = massacre?10:20; else if ((curkl->flags & (PIRATE|FRIENDLY)) == PIRATE) { /* pirates want to sit sometimes */ if (curkl->strategy) { if ((obj = lookimg(curkl->posy, curkl->posx, '@')) || (obj = lookimg(curkl->posy, curkl->posx, 'B')) ) { make_plink(obj->posy, obj->posx); if (!--curkl->strategy) { /* clock ran down */ if (obj->image == '@') { obj->image = '*'; numinhab--; if (obj->flags & STATIC) mvaddch(obj->posy+1,obj->posx*2,obj->image); if (curkl->energy < 20000) curkl->energy += 5000; } prob = 2; /* our work here is done */ } else if (obj->image == 'B') { btorp -= rand_mod(50); if (btorp < 0) btorp = 0; obj->energy -= rand_mod(500); if (obj->energy < 0) obj->energy = 0; prob = 10000; /* stay here */ } else prob = 10000; } else { /* it went away--go elsewhere */ prob = 4; curkl->strategy = 0; } } else if (lookimg(curkl->posy, curkl->posx, '@') || lookimg(curkl->posy, curkl->posx, 'B')) { curkl->strategy = rand_mod(15)+5; prob = 10000; } else prob = 4; } else if (curkl->image == 'M') { /* Mudd wants to sit sometimes */ if ((obj = lookimg(curkl->posy, curkl->posx, 'E')) || (obj = lookimg(curkl->posy, curkl->posx, 'B')) ) { if (obj->image == 'B') { btorp -= rand_mod(40); if (btorp < 0) btorp = 0; obj->energy -= rand_mod(100); if (obj->energy < 0) obj->energy = 0; } else if (!obj->vely && !obj->velx) { etorp -= rand_mod(10); if (etorp < 0) etorp = 0; obj->energy -= rand_mod(20); if (obj->energy < 0) obj->energy = 0; } prob = 10000; /* stay here */ } else /* it went away--go elsewhere */ prob = 4; } else if (curkl->flags & FRIENDLY) { if (curkl->energy < 10000 && lookimg(curkl->posy, curkl->posx, '@') ) { curkl->energy += 100; prob = 20; /* do some loading */ } else prob = 4; } else if (curkl->image == '&') { if (curkl->flags & COUNTDOWN) { if (curkl->strategy) curkl->strategy--; else curkl->flags &= ~COUNTDOWN; prob = 100; /* someone's feeding us, so sit still */ } else prob = 4; } else prob = 4; /* don't sit still too long */ count = 11; for (;;) { if (--count <= 0) /* no opening, just ram something */ break; if (!(rand_mod(prob))) /* turn randomly occasionally */ goto accell; y=(curkl->posy+curkl->vely+YSIZE00)%YSIZE; /* find prospective */ x=(curkl->posx+curkl->velx+XSIZE00)%XSIZE; /* new position */ if (numamoebas) { if (curkl == nuke) { if (amb[y][x] != '~') goto accell; /* never move nucleus from protoplasm */ } else { if (amb[y][x] == '~' && rand_mod(2)) { yamblast = y; xamblast = x; goto accell; } } } obj = occupant[y][x]; if (!obj) break; /* is anyone there? */ switch (obj->type) { case Star: if (obj->image == '@' && (curkl->flags & PIRATE)) { if (curkl->image != 'P' && curkl->image != ' ') { if (curkl->flags & FRIENDLY) { curkl->flags &= ~FRIENDLY; curkl->energy += 1000; possiblescore += curkl->mass; inumfriends--; numfriends--; inumenemies++; numenemies++; } curkl->image = 'P'; } break; /* go ahead and ram the star */ } goto accell; /* try not to ram stars */ case Torp: if (!obj->vely && !obj->velx && (rand_mod(100) <= smarts) && (obj->image == 'o' || obj->image == 'O' || obj->image == 'X')) goto accell; /* try not to ram "friendly" torps */ break; case Web: if (curkl->image != 'T') goto accell; /* non-Tholians shouldn't ram web */ if (count <= 5) break; /* Tholians retrace web if desperate */ if (obj->image == (curkl->vely? (curkl->velx? (curkl->velx==curkl->vely? '\\' : '/' ) : '|' ) : '-' ) ) goto accell; /* Tholians try not to retrace web */ break; /* No problem with crossing web */ } break; /* okay to move over object */ accell: /* determine maximum velocity */ if (massacre && curkl->image != 'T') { curkl->vely = rand_mod(7) - 3; curkl->velx = rand_mod(7) - 3; } else if (curkl->image == '&') { if (rand_mod(2)) { curkl->vely = rand_mod(3) - 1; curkl->velx = rand_mod(3) - 1; } else { curkl->vely = curkl->strategy & 3; if (curkl->vely & 2) curkl->vely = -1; curkl->velx = (curkl->strategy >> 2) & 3; if (curkl->velx & 2) curkl->velx = -1; } } else if (curkl->energy >= 2500 && curkl->image != 'T') { curkl->vely = rand_mod(5) - 2; curkl->velx = rand_mod(5) - 2; } else { curkl->vely = rand_mod(3) - 1; curkl->velx = rand_mod(3) - 1; } } if (count != 10) { if (curkl->image == ' ') { setimage(curkl, curkl->flags & PIRATE ? 'P' : 'R'); } if (!count) { curkl->vely = 0; curkl->velx = 0; } } if (curkl->image == 'G' && (base||ent) && !rand_mod((103-smarts)*10) ) { int xxx,yyy; for (xxx = -1; xxx<=1; xxx++) for (yyy = -1; yyy<=1; yyy++) if ((xxx||yyy) && rand_mod(2)) fire_torp(curkl,yyy,xxx); } else if (curkl->image == 'T' && (curkl->velx || curkl->vely)) { Make_object(Web, curkl->vely? (curkl->velx? (curkl->velx==curkl->vely? '\\' : '/' ) : '|' ) : '-', curkl->posy,curkl->posx,0,0,32767L,32767L,&root); if (obj && obj->type == Web) { unmake_object(obj); occupant[y][x] = Null(OBJECT*); } } } /* klingon-style fighting */ if (numamoebas) attack(nuke); attack(base); if (ent && (!cloaked || ent->image=='E' || ent->image=='e')) attack(ent); } void modify_amoeba(y,x,where,ch,quant) register int y; register int x; int where; register int ch; register int quant; { register int dy; register int dx; register int count = 15; if (!numamoebas) return; if (!where || (where==1 && rand_mod(2))) { y = nuke->posy; x = nuke->posx; } if (nuke->strategy && rand_mod(3)) { dy = nuke->strategy & 3; if (dy & 2) dy = -1; dx = (nuke->strategy >> 2) & 3; if (dx & 2) dx = -1; if (ch == ' ') { /* take from the tail */ dy = -dy; dx = -dx; } if (!rand_mod(100)) nuke->strategy = rand_mod(256); } else { dy = rand_mod(3) - 1; dx = rand_mod(3) - 1; } if (!dy && !dx) return; do { if (--count < 0) return; y = (y + dy + YSIZE00) % YSIZE; x = (x + dx + XSIZE00) % XSIZE; } while (amb[y][x] != ' '); if (ch == ' ') { y = (y - dy + YSIZE00) % YSIZE; x = (x - dx + XSIZE00) % XSIZE; } if (ambsize > 100 && quant > 2) { quant >>= (ambsize/100); } if ((nuke->energy += quant << 6) > 32767) nuke->energy = 32767; count = quant << 3; /* endless loop catcher */ while (count-- > 0 && quant > 0) { if (amb[y][x] != ch) { quant--; amb[y][x] = ch; if (ch == '~') { ambsize++; yblasted[y] |= 2; xblasted[x] |= 2; blasted = TRUE; } else ambsize--; if (!occupant[y][x]) mvaddch(y+1,x*2,ch); } y = (y + rand_mod(3) + YSIZE99) % YSIZE; x = (x + rand_mod(3) + XSIZE99) % XSIZE; } } ================================================ FILE: games/warp/them.h ================================================ /* $Header: them.h,v 7.0 86/10/08 15:14:19 lwall Exp $ */ /* $Log: them.h,v $ * Revision 7.0 86/10/08 15:14:19 lwall * Split into separate files. Added amoebas and pirates. * */ void their_smarts(); void modify_amoeba(); void them_init(); ================================================ FILE: games/warp/us.c ================================================ /* $Header: us.c,v 7.0.1.3 87/01/13 17:13:21 lwall Exp $ */ /* $Log: us.c,v $ * Revision 7.0.1.3 87/01/13 17:13:21 lwall * Partially fixed ^S behavior. It now just ignores ^S. * * Revision 7.0.1.2 86/12/12 17:06:09 lwall * Baseline for net release. * * Revision 7.0.1.1 86/10/16 10:53:50 lwall * Added Damage. Fixed random bugs. * * Revision 7.0 86/10/08 15:14:21 lwall * Split into separate files. Added amoebas and pirates. * */ #include "EXTERN.h" #include "warp.h" #include "bang.h" #include "object.h" #include "play.h" #include "sig.h" #include "term.h" #include "util.h" #include "weapon.h" #include "INTERN.h" #include "us.h" void us_init() { ; } void do_direction(dy,dx) int dy, dx; { register int decr; register OBJECT *obj; if (status < 2) { if (cloaking) { char ch; cloaked = FALSE; ch = (ent->energy >= 500?'E':'e'); if (ch != ent->image) { setimage(ent, ch); } } decr = 5+abs(evely)+abs(evelx)+tractor*tractor; if (ent->energy >= decr) { ent->energy -= decr; if (tractor) { if (!damage || !damflag[NOTRACTORS]) { if (!rand_mod(50)) { damage++; damflag[NOTRACTORS] = rand_mod(smarts+10)+2; } if (tract(ent,dy,dx,tractor)) { evely += tractor*dy; evelx += tractor*dx; } } } else if (!damage || (!entmode && !damflag[NOIMPULSE]) || (entmode && !damflag[NOWARP]) ) { if (!rand_mod(30+500/(abs(evely)+abs(evelx)+1))) { damage++; damflag[entmode?NOWARP:NOIMPULSE] = rand_mod(smarts+10)+2; } evely += dy; evelx += dx; } if (inumthols && (obj=occupant[(ent->posy+evely+YSIZE00)%YSIZE] [(ent->posx+evelx+XSIZE00)%XSIZE] ) && obj->type == Web) evely = evelx = 0; } } else if (status == 2) { decr = 500+abs(bvely)*5+abs(bvelx)*5+tractor*tractor*100; if (base->energy >= decr) { base->energy -= decr; if (tractor) { if (tract(base,dy,dx,tractor)) { bvely += tractor*dy; bvelx += tractor*dx; } } else { bvely += dy; bvelx += dx; } if (inumthols && (obj=occupant[(base->posy+bvely+YSIZE00)%YSIZE] [(base->posx+bvelx+XSIZE00)%XSIZE] ) && obj->type == Web) bvely = bvelx = 0; } } tractor = 0; } void ctrl_direction(dy,dx) int dy, dx; { if (status < 2) { if (cloaking) { char ch; cloaked = FALSE; ch = (ent->energy >= 500?'E':'e'); if (ch != ent->image) { setimage(ent, ch); } } if (!damage || !damflag[NOPHASERS]) { if (!rand_mod(200)) { damage++; damflag[NOPHASERS] = rand_mod(smarts+10)+2; } fire_phaser(ent, dy, dx); } } else if (status == 2) fire_phaser(base, dy, dx); } void shift_direction(dy,dx) int dy, dx; { if (status < 2) { if (cloaking) { char ch; cloaked = FALSE; ch = (ent->energy >= 500?'E':'e'); if (ch != ent->image) { setimage(ent, ch); } } if (!damage || !damflag[NOTORPS]) { if (!rand_mod(300)) { damage++; damflag[NOTORPS] = rand_mod(smarts+10)+2; } fire_torp(ent, dy, dx); } } else if (status == 2) fire_torp(base, dy, dx); } void get_commands(done) bool *done; { static char ch[80]; register int i; register int count; register bool ctrla = FALSE; char numdestructs = 0, numzaps = 0; top: while (count = read_nd(ch,(sizeof ch))) { for (i=0; i= whenok) { mvaddstr(12,22,quest); do { getcmd(&ch[i]); } while (ch[i] != 'y' && ch[i] != 'n'); if (ch[i] == 'y') { bombed_out = TRUE; *done = TRUE; return; } else { for (x=11; x<=28; x++) { mvaddch(12,x*2, occupant[11][x] ? occupant[11][x]->image : numamoebas ? amb[11][x] : ' '); addspace(); } roundsleep(2); whenok = timer + 10; goto top; } } else { write(1,"\07",1); goto top; } } } for (i=0; ienergy >= 250) cloaking = TRUE; } break; case 'z': if (ent && (!damage || !damflag[NOZAPPER])) { ++numzaps; if (!rand_mod(100/numzaps)) { damage++; damflag[NOZAPPER] = rand_mod(smarts+10)+2; } if (nxtbang && bangm[nxtbang-1] < 0) --nxtbang; /* consolidate zaps */ make_blast(evely*2+ent->posy,evelx*2+ent->posx, -5000000L, 3*numzaps); ent->energy /= 2; } break; case 'D': if (status < 2 && (!damage || !damflag[NODESTRUCT])) { if (ent && !rand_mod(10)) { damage++; damflag[NODESTRUCT] = rand_mod(smarts+10)+2; } if (++numdestructs <= 2) make_blast(evely*2+ent->posy,evelx*2+ent->posx, 15000L, 3); ent->energy /= 4; } else if (status == 2) { if (numdestructs) base->energy = base->energy / 2; if (++numdestructs <= 2) make_blast(base->posy, base->posx, 15000L, 5); } break; case 'd': if ((!damage || !damflag[NODESTRUCT]) && (base||ent)) { register OBJECT *obj; int x, y; if (ent && !rand_mod(200)) { damage++; damflag[NODESTRUCT] = rand_mod(smarts+10)+2; } for (obj = root.prev; obj != &root; obj = obj->prev) { if (obj->image == '+') { blast[y=(obj->posy+obj->vely+YSIZE00)%YSIZE] [x=(obj->posx+obj->velx+XSIZE00)%XSIZE] += 1; yblasted[y] |= 1; xblasted[x] |= 1; blasted = TRUE; obj->mass = (massacre?3000:4000); } } } break; case 's': if ((!damage || !damflag[NODESTRUCT]) && (base||ent)) { register OBJECT *obj; if (ent && !rand_mod(200)) { damage++; damflag[NODESTRUCT] = rand_mod(smarts+10)+2; } for (obj = root.prev; obj->type == Torp || obj->type == Web || obj->type == Star; obj = obj->prev) { if (obj->image == '+') obj->vely = obj->velx = 0; } } break; case '\001': ctrla = TRUE; break; case '\002': case '\003': case '\004': case '\005': case '\006': case '\007': case '\010': case '\011': case '\012': case '\013': case '\014': case '\015': case '\016': case '\017': case '\020': case '\021': case '\022': case '\023': case '\024': case '\025': case '\026': case '\027': case '\030': case '\031': case '\032': ch[i] += 96; i--; ctrla = TRUE; break; case '\033': tractor = 0; break; case 'a': tractor++; break; case 'r': tractor--; break; case '1': case 'b': do_direction(1,-1); break; case '2': case 'j': do_direction(1,0); break; case '3': case 'n': do_direction(1,1); break; case '4': case 'h': do_direction(0,-1); break; case '6': case 'l': do_direction(0,1); break; case '7': case 'y': do_direction(-1,-1); break; case '8': case 'k': do_direction(-1,0); break; case '9': case 'u': do_direction(-1,1); break; case '0': case 'S': if (status < 2) { evely = 0; evelx = 0; } break; case '-': if (status < 2 && ent->energy >= 10) { evely *= -1; evelx *= -1; ent->energy -= 10; } break; case '%': case '\177': case '_': shift_direction(0, -1); shift_direction(0, 1); shift_direction(-1, 0); shift_direction(1, 0); shift_direction(-1, -1); shift_direction(-1, 1); shift_direction(1, -1); shift_direction(1, 1); break; case '!': case 'B': shift_direction(1, -1); break; case '@': case 'J': shift_direction(1, 0); break; case '#': case 'N': shift_direction(1, 1); break; case '$': case 'H': shift_direction(0, -1); break; case '^': case 'L': shift_direction(0, 1); break; case '&': case 'Y': shift_direction(-1, -1); break; case '*': case 'K': shift_direction(-1, 0); break; case '(': case 'U': shift_direction(-1, 1); break; case '?': helper(); roundsleep(3); goto top; default: break; } } } } } ================================================ FILE: games/warp/us.h ================================================ /* $Header: us.h,v 7.0.1.1 86/10/16 10:53:58 lwall Exp $ */ /* $Log: us.h,v $ * Revision 7.0.1.1 86/10/16 10:53:58 lwall * Added Damage. Fixed random bugs. * * Revision 7.0 86/10/08 15:14:27 lwall * Split into separate files. Added amoebas and pirates. * */ EXT bool cloaking; EXT bool cloaked; EXT int status; EXT int entmode; EXT int evely; EXT int evelx; EXT int bvely; EXT int bvelx; #define MAXDAMAGE 9 #define NOWARP 0 #define NOIMPULSE 1 #define NOPHASERS 2 #define NOTORPS 3 #define NOCLOAKING 4 #define NOSHIELDS 5 #define NOZAPPER 6 #define NODESTRUCT 7 #define NOTRACTORS 8 EXT int dam INIT(0); EXT int lastdam INIT(-1); EXT int damage INIT(0); EXT int olddamage INIT(-1); #ifdef DOINIT char *dammess[MAXDAMAGE] = { "WARP", "IMPULSE", "PHASERS", "TORPS", "CLOAKING", "SHIELDS", "ZAPPER", "DESTRUCT", "TRACTORS" }; char damflag[MAXDAMAGE] = {0,0,0,0,0,0,0,0,0}; #else extern char *dammess[]; extern char damflag[]; #endif void do_direction(); void ctrl_direction(); void shift_direction(); void get_commands(); void us_init(); ================================================ FILE: games/warp/util.c ================================================ /* $Header: util.c,v 7.0.1.2 86/10/20 12:07:46 lwall Exp $ */ /* $Log: util.c,v $ * Revision 7.0.1.2 86/10/20 12:07:46 lwall * Made all exits reset tty. * * Revision 7.0.1.1 86/10/16 10:54:02 lwall * Added Damage. Fixed random bugs. * * Revision 7.0 86/10/08 15:14:31 lwall * Split into separate files. Added amoebas and pirates. * */ #include "EXTERN.h" #include "warp.h" #include "object.h" #include "sig.h" #include "term.h" #include "INTERN.h" #include "util.h" void util_init() { ; } void movc3(len,src,dest) register char *dest; register char *src; register int len; { if (dest <= src) { for (; len; len--) { *dest++ = *src++; } } else { dest += len; src += len; for (; len; len--) { *--dest = *--src; } } } void no_can_do(what) char *what; { fprintf(stderr,"Sorry, your terminal is too %s to play warp.\r\n",what); finalize(1); } int exdis(maxnum) int maxnum; { double temp, temp2; double exp(); double log(); temp = (double) maxnum; temp2 = (double) myrand(); return (int) exp(temp2 * log(temp)/0x7fff); } static char nomem[] = "warp: out of memory!\r\n"; /* paranoid version of malloc */ char * safemalloc(size) MEM_SIZE size; { char *ptr; ptr = malloc(size?size:1); /* malloc(0) is NASTY on our system */ if (ptr != Nullch) return ptr; else { fputs(nomem,stdout); sig_catcher(0); } /*NOTREACHED*/ } /* safe version of string copy */ char * safecpy(to,from,len) char *to; register char *from; register int len; { register char *dest = to; if (from != Nullch) for (len--; len && (*dest++ = *from++); len--) ; *dest = '\0'; return to; } /* copy a string up to some (non-backslashed) delimiter, if any */ char * cpytill(to,from,delim) register char *to; register char *from; register int delim; { for (; *from; from++,to++) { if (*from == '\\' && from[1] == delim) from++; else if (*from == delim) break; *to = *from; } *to = '\0'; return from; } /* return ptr to little string in big string, NULL if not found */ char * instr(big, little) char *big, *little; { register char *t; register char *s; register char *x; for (t = big; *t; t++) { for (x=t,s=little; *s; x++,s++) { if (!*x) return Nullch; if (*s != *x) break; } if (!*s) return t; } return Nullch; } /* effective access */ #ifdef SETUIDGID int eaccess(filename, mod) char *filename; int mod; { int protection, euid; mod &= 7; /* remove extraneous garbage */ if (stat(filename, &filestat) < 0) return -1; euid = geteuid(); if (euid == 0) return 0; protection = 7 & (filestat.st_mode >> (filestat.st_uid == euid ? 6 : (filestat.st_gid == getegid() ? 3 : 0) )); if ((mod & protection) == mod) return 0; errno = EACCES; return -1; } #endif /* copy a string to a safe spot */ char * savestr(str) char *str; { register char *newaddr = safemalloc((MEM_SIZE)(strlen(str)+1)); strcpy(newaddr,str); return newaddr; } char * getval(nam,def) char *nam,*def; { char *val; if ((val = getenv(nam)) == Nullch || !*val) val = def; return val; } ================================================ FILE: games/warp/util.h ================================================ /* $Header: util.h,v 7.0 86/10/08 15:14:37 lwall Exp $ */ /* $Log: util.h,v $ * Revision 7.0 86/10/08 15:14:37 lwall * Split into separate files. Added amoebas and pirates. * */ #define RANDRAND 268435456.0 /* that's 2**28 */ #define HALFRAND 0x4000 /* that's 2**14 */ int rand(); #define myrand() (rand()&32767) #define rand_mod(m) ((int)((double)myrand() / 32768.0 * ((double)(m)))) /* pick number in 0..m-1 */ #define roundsleep(x) sleep(x) void movc3(); void no_can_do(); int exdis(); EXT bool waiting INIT(FALSE); /* are we waiting for subprocess (in doshell)? */ void util_init(); char *safemalloc(); char *safecpy(); char *cpytill(); char *instr(); #ifdef SETUIDGID int eaccess(); #endif char *savestr(); char *getval(); ================================================ FILE: games/warp/version.c ================================================ /* $Header: version.c,v 7.0 86/10/08 15:14:39 lwall Exp $ * * $Log: version.c,v $ * Revision 7.0 86/10/08 15:14:39 lwall * Split into separate files. Added amoebas and pirates. * */ #include "patchlevel.h" #include "INTERN.h" #include "version.h" #include /* Print out the version number. */ void version() { extern char rcsid[]; printf("%s\r\nPatch level: %d\r\n", rcsid, PATCHLEVEL); } ================================================ FILE: games/warp/version.h ================================================ /* $Header: version.h,v 7.0 86/10/08 15:14:43 lwall Exp $ * * $Log: version.h,v $ * Revision 7.0 86/10/08 15:14:43 lwall * Split into separate files. Added amoebas and pirates. * */ void version(); ================================================ FILE: games/warp/warp.6 ================================================ .TH WARP 6 "June 20, 1987" .SH NAME warp - a real-time space war game .SH SYNOPSIS .B warp [options] .SH DESCRIPTION .I Warp is a real-time space war game that requires skill and quick thinking. "Real-time" in this context means that the enemies keep moving (and shooting) even if you don't. A unique feature of .I warp is that blast propagates; it is unhealthy to remain near things that are in the process of blowing up. If a given universe is above a critical density it may chain react. Scoring is like many popular arcade games--there are multiple waves which get harder and harder as you go along. Nobody has ever maxed out the scoreboard without cheating. .PP Unlike many space-war games, .I warp is not simply a shooting gallery. Along with phasers and photon torpedoes, you have tractor beams and a cloaking device. Skill in navigation is important. It helps to be schizophrenic, because you must manage an Enterprise and a Base simultaneously. And enemies do not simply shoot back. You can get tailed, absorbed, snuck up upon, hemmed in, rammed, loved to death, reprimanded for destroying civilized life, dragged around, robbed, damaged and eaten. And if you should happen to get bored by the enemies (a trifle unlikely), you can always watch the interesting star patterns. In fact, you'll have to, since your tactics will depend upon what kind of universe you find yourself in. .PP .I Warp is played in a double wraparound universe, i.e. the bottom is connected to the top, and the right is connected to the left. You need a crt with random cursor addressing and at least 24 lines by 80 columns. For more information about about how to play, simply run .I warp and say "y" when it asks if you want to see the instructions. There is also a single-page command summary that you can get while playing by typing a "?". .PP Command line options include: .TP 5 .B -b Put .I warp into beginner mode. Makes the difficulty increase more slowly, but penalizes you for it. .TP 5 .B -d Sets the initial difficulty to .BR n . .TP 5 .B -l Play a low-speed game. Changes the basic cycle time from 1 second to 2 seconds. This switch is automatically set at baud rates below 2400. You may want to set it at higher speeds if your terminal cannot keep up with the output. (This should never happen on BSD systems, which have an IOCTL call to determine output queue length.) Because this makes the game easier, a separate scoreboard is kept for low-speed games. .TP 5 .B -m Terminal has a meta key which turns on the eighth bit. Ordinarily the eighth bit is stripped in order to ignore parity. Metacharacters will appear to the keymap as prefixed with a ^A, and will subsequently have the same effect as a control character, unless otherwise mapped. .TP 5 .B -s Just prints out the scoreboards and saved games and then exits. .TP 5 .B -v Prints out the version number. .TP 5 .B -x Play an experimental game. This causes .I warp to ignore any saved game, and disables the ability to save the current game. Thus you can play around with something or show .I warp to someone without jeopardizing a currently saved game. .SH ENVIRONMENT .TP 5 .B WARPMACRO If defined, names a file containing keyboard mappings and macros. If not defined, the value %X/Kbmap.%{TERM} is assumed. The macro file contains lines of the following form: .sp .sp You may use certain % interpolations and ^ control characters. For possible % interpolations see warp.h. Sequences in the canonical-keystroke-sequence bounded by ^(...^) are subject to reinterpretation via the keymap. This file has two major uses. First, you can set up your commands to use any kind of prefix key your terminal might have, or change the key bindings in any other way you choose. Second, you can define arbitrary macros, such as this: .sp # define Corbamite maneuver = DDllllll .SH AUTHOR Larry Wall .SH FILES ~/.fullname, if full names aren't in /etc/passwd .SH DIAGNOSTICS Generally self-documenting, as they say. .SH BUGS Addicting. At the end of a wave, all you have to do to keep going is hit a space. You see the message "Hit space to continue" and automatically hit space. About 2 seconds later you remember you wanted to go home, but by then it's too late to escape without penalty. .PP You can't kill a backgrounded .I warp process directly, because it is running setuid. You have to use the killer built in to .IR warp . .PP Now that there is a space amoeba, there ought to be tribbles. But it might be too much trouble... ================================================ FILE: games/warp/warp.c ================================================ char rcsid[] = "@(#)$Header: warp.c,v 7.0.1.3 86/12/12 17:07:44 lwall Exp $"; /* warp -- a real-time space war program * author: Larry Wall * helpers: Jonathan and Mark Biggar, and Dan Faigin * special thanks to my sweetie Gloria who suggested the Planet Crusher * * Copyright (C) 1986, Larry Wall * * This program may be copied as long as this copyright notice is * included, and as long as it is not being copied for purposes * of profit. If you want to modify this program in any way other * than normal configuration changes, common decency would suggest * that you also modify the name of the program so that my good name * (what there is of it) is not impugned. (Calling it something like * "warpx" or "superwarp" would be fine.) Also, give it another * WARPDIR so that the scoreboards don't get confused. * * version 5.0 04/20/83 * 5.1 05/05/83 various tidbits * 5.2 05/12/83 VAX -> vax, ifdef'ed a SIGCONT * 5.3 05/24/83 RCS * * $Log: warp.c,v $ * Revision 7.0.1.3 86/12/12 17:07:44 lwall * Baseline for net release. * * Revision 7.0.1.2 86/10/20 12:08:00 lwall * Made all exits reset tty. * * Revision 7.0.1.1 86/10/16 10:54:13 lwall * Added Damage. Fixed random bugs. * * Revision 7.0 86/10/08 15:14:47 lwall * Split into separate files. Added amoebas and pirates. * * Revision 6.4 83/12/16 13:11:45 lwall * Handled 15 bit random number generators. * * Fixed array overflow bug on multiple zaps. * * Multiple zaps now consolidated to minimize output. * * Tholian jackpot games outlawed under difficulty 15. * * Revision 6.3 83/08/24 11:17:49 lwall * Fixed array overflow bug on multiple zap. * * Revision 6.2 83/08/23 18:06:37 lwall * Added zap command. * Warp -s should now work on dumb terminals * Specifying difficulty >= 40 now just makes it a special game. * SIGTTOU #ifdef'ed. * No-delay read provided as alternative to FIONREAD. * Warp won't report "-1 obsolete" when there are no Enterprises left. * Some high-difficulty tuning. * * Revision 6.1 83/08/17 08:49:03 lwall * Fixed obscure bug in storing UP that caused a %. in CM to occasionally * foist garbage onto the screen. * * Revision 6.0 83/08/08 17:09:26 lwall * New baseline version for net release. * * Revision 5.5 83/08/01 10:59:56 lwall * Cloaking for the Enterprise. * Difficulty now goes to 99, and many activities depending on difficulty * have been adjusted in frequency. * Simplified exit sequence, and reduced dependencies on control * characters. You needn't see the scoreboard if you don't want to. * Hitting i,w,c, or v switches to Enterprise. Hitting p switches to Base. * Excessive use of q is not allowed. * Excessive use of D is not allowed. * Scoreboard may depend on either full name or login name. * Integrated scoreboard lister. Login name now shows up on scoreboard. * "Hidden" startup options are now upper case. * Checks upon startup for no cursor movement, or screen too small. * Checks upon startup that WARPDIR is correctly protected, and that warp * is running setuid. As an additional bonus this prevents root from * running warp, which mucks things up, UN*X be blessed. * All gets's turned into fgets's for safety. * Bonus Enterprises and Bases. * Escalating bonuses for saving Base and Enterprise. * Escalating Enterprise energy. * Turbolasers decrease with distance. * Really smart enemies can see through stars occasionally. * Occasional Tholian jackpot waves. Tholians are a trifle nastier. * Choleric Gorns. * An O or o can miss seeing you. Enemies can avoid a stationary O, o, or X. * Warp 3 enemies and other nastinesses are possible in massacre mode. * Enemies that decide to navigate when they see you can do other things than * just come toward you. * Gorns occasionally launch a salvo for the fun of it. * Only star and enemy explosions can keep the round going now. * Bounces don't always go back to starting spot now. * Better full name processing. USG quirks handled. & substitution also * handled now (whoever dreamed up that one must have been in the middle * of the night before the morning after). * Catch ^D on fgets. * Version number printer. * Less signal catching during debugging. * * Revision 5.4 83/06/24 09:28:38 lwall * 16 bit random number generators are now supported. * Made warp not blow up on a null save file. * Warp now prints E and B before the stars. * Fixed bug which caused torp count to get decremented even when no torp * was launched because of an obstacle. * Put %ld formats where appropriate. * Fixed E: 0 0 bug on refresh. * * Revision 5.3 83/05/24 14:03:10 lwall * Starting RCS * */ #include "INTERN.h" #include "warp.h" #include "EXTERN.h" #include "bang.h" #include "init.h" #include "intrp.h" #include "object.h" #include "move.h" #include "play.h" #include "score.h" #include "sig.h" #include "term.h" #include "them.h" #include "us.h" #include "util.h" #include "version.h" #include "weapon.h" main(argc,argv) int argc; char *argv[]; { char tmp, *s, *tcbuf; int i; FILE *savfil; rand_ok: while (--argc > 0 && (*++argv)[0] == '-') for (s = argv[0]+1; *s != '\0'; s++) switch (*s) { case '&': amoebaspec = TRUE; beginner = TRUE; break; case 'A': apolspec = TRUE; beginner = TRUE; break; case 'b': beginner = TRUE; break; case 'C': crushspec = TRUE; beginner = TRUE; break; case 'D': debugging = TRUE; #ifdef DEBUGGING debug = atoi(++s); #endif s += strlen(s)-1; break; case 'd': s++; if (*s == '=') s++; ismarts = atoi(s); if (ismarts <= 0) ismarts = 1; if (ismarts > 99) ismarts = 99; if (ismarts > 40) beginner = TRUE; s += strlen(s)-1; break; case 'E': klingspec = TRUE; beginner = TRUE; s++; if (*s == '=') s++; inumenemies = atoi(s); s += strlen(s)-1; break; case 'F': friendspec = TRUE; beginner = TRUE; s++; if (*s == '=') s++; inumfriends = atoi(s); s += strlen(s)-1; break; case 'G': gornspec = TRUE; beginner = TRUE; break; case 'l': lowspeed = TRUE; break; case 'm': metakey = TRUE; break; case 'M': massacre = TRUE; break; case 'P': piratespec = TRUE; beginner = TRUE; s++; if (*s == '=') s++; inumpirates = atoi(s); s += strlen(s)-1; break; case 'S': prespec = TRUE; beginner = TRUE; s++; if (*s == '=') s++; if (*s) prescene = atoi(s); else prescene = -1; s += strlen(s)-1; break; case 'R': romspec = TRUE; beginner = TRUE; break; case '*': starspec = TRUE; beginner = TRUE; s++; if (*s == '=') s++; inumstars = atoi(s); s += strlen(s)-1; break; case 's': scorespec = TRUE; break; case 'T': tholspec = TRUE; beginner = TRUE; break; case 'x': experimenting = TRUE; break; case 'v': version(); exit(0); break; default: fprintf(stderr,"warp: illegal option %c\n", *s); fprintf(stderr, "Usage: warp -dn -b -x -v -s\n"); exit(1); } if (argc != 0) { fprintf(stderr, "Usage: warp -dn -b -x -v -s\n"); exit(1); } bang_init(); move_init(); object_init(); play_init(); them_init(); us_init(); util_init(); weapon_init(); tcbuf = malloc(1024); intrp_init(tcbuf); if (chdir(warplib) < 0) fprintf(stderr,nocd,warplib); term_init(); term_set(tcbuf); free(tcbuf); umask(022); /* mustn't rely on incoming umask--could be 033 which */ /* would disable people from running wscore */ score_init(); sig_init(); if (totalscore) { clear(); mvaddstr(12,25,"*** restoring saved game ***"); roundsleep(1); } srand(getpid()); do { for (keepgoing = TRUE;;) { if (!experimenting) { if ((savfil = fopen(savefilename,"w")) == NULL) { resetty(); printf("Can't open savefile\r\n"); finalize(1); } fprintf(savfil, "%-8s %10ld, %2d,%5d,%2d,%2d,%3d %c%c%c%c%c%c%c%c%c\n", logname, totalscore, smarts, cumsmarts, numents, numbases, wave, apolspec ? 'a' : ' ', beginner ? 'b' : ' ', crushspec ? 'c' : ' ', gornspec ? 'g' : ' ', massacre ? 'm' : ' ', romspec ? 'r' : ' ', tholspec ? 't' : ' ', lowspeed ? 'l' : ' ', amoebaspec ? '&' : ' ' ); fprintf(savfil," running on %s, process #%d\n", term+5,getpid()); Fclose(savfil); } lastscore = totalscore; initialize(); play(); cumsmarts += smarts; wavescore(); if (numents<=0 && numbases<=0) keepgoing = FALSE; if (!keepgoing) break; do { if (experimenting) { mvaddstr(23,15, " [Hit space to continue, 'q' to quit] "); } else { mvaddstr(23,15, "[Hit space to continue, 's' to save, 'q' to quit]"); } sleep(1); Fflush(stdout); eat_typeahead(); getcmd(&tmp); if (tmp == BREAKCH || tmp == INTRCH) { mvaddstr(23,15, " "); mvaddstr(23,33, "Really quit? "); getcmd(&tmp); if (tmp == 'y' || tmp == 'Y') tmp = 'q'; else tmp = 1; } } while (tmp != INTRCH && tmp != BREAKCH && !strchr(" qQs",tmp)); if (tmp != ' ' && tmp != 's') break; if (!beginner && smarts < 20) smarts += 4; else if (!beginner && smarts < 35) smarts += 2; else if (smarts < 99) smarts++; if (tmp == 's') save_game(); } score(); } while (justonemoretime); if (!experimenting) unlink(savefilename); clear(); resetty(); exit(0); } ================================================ FILE: games/warp/warp.doc ================================================ Warp is a real-time space war game. This means that the enemies will keep playing even when you sit still. Another peculiarity is that things which blow up can damage other things around them. Universes above a critical density may chain react. The game starts at difficulty 1, and gets more difficult with each succeeding wave, up to difficulty 99. You're not likely to get that far. (Invoking warp with a -b switch causes the difficulty to increase more slowly, but games count only a tenth as much.) The game starts with 5 Enterprises and 3 Bases, and you get more for surviving long enough. The game is over when you run out of Enterprises and Bases. The object of the game is to get as many points as possible. This is done by destroying as many enemies as possible. This is not a trivial task. Each wave starts with one Enterprise and one Base, and continues until either both the Enterprise and Base are destroyed, or all the enemies (including any homing torpedoes) are destroyed. It is possible to abort a wave, but you will be penalized for it. The game may be saved between waves. A -x switch causes any saved game to be ignored, and causes the new game not to be saveable. Hence it is possible to run test games without invalidating a currently saved game. The game is played in a 23 x 40 double wrap-around universe. Everybody (both you and the enemies) gets the chance to move once every second, unless a -l (low-speed) switch was given or you are under 2400 baud, in which case it's every two seconds. The following symbols are displayed: FRIENDS E Enterprise with shields e Enterprise without shields C Cloaked E with shields c Cloaked E without shields B Base with shields b Base without shields + Friendly torpedo M Harry Mudd ENEMIES K Klingon G Gorn R Romulan A Apollo Romulan with cloaking device! & Space Amoeba Nucleus T Tholian >,< Planet crusher x,X Hostile torpedo o,O Homing torpedo P Pirate M Harry Mudd MISCELLANEOUS * Star @ Inhabited star |,-,/,\ Web ~ Protoplasm other Friendly Freighter, for now... The following keys control the DIRECTION of your various actions: h or 4 left j or 2 down k or 8 up l or 6 right b or 1 down and left n or 3 down and right y or 7 up and left u or 9 up and right (You will note that the letters are the same as other visual games, and the numbers are for use with a keypad.) By themselves, these keys move either the Enterprise or the Base, whichever is the current vessel. When shifted, they fire photon torpedoes in the specified direction from the current vessel. When used with either the CTRL key or the FUNCT key, phasers (turbo-lasers for the Base) are fired in the specified direction. (CTRL won't work with numbers, and FUNCT probably doesn't exist on non-TVI terminals.) When preceded by an 'a', an attractor beam is fired in the specified direction, and when preceded by an 'r', a repulsor beam is fired. These keys have special functions: del or % fire photon torpedoes in every (reasonable) direction s stop all friendly torpedoes S or 0 stop the Enterprise when in warp mode d destruct all friendly torpedoes (quite useful) D destruct the current vessel (commit suicide) i/w switch to Enterprise and put into impulse/warp mode c/v switch to Enterprise and put into cloaking/visible mode p switch to Base (not very mnemonic, but 'b' is taken) o switch from Enterprise to Base, or vice versa z zap explosions (multiple zaps extend further) (E only) ^R refresh the screen ^Z suspend the game (on a bsd system) q asks if you want to exit this wave (will not work within 10 cycles of previous q command) Q exit this game (not wave) ? display a summary of these commands There may be additional commands listed in your terminal's keymap file. Unrecognized keystrokes are ignored. IF YOU FORGET ALL THE OTHER COMMANDS, REMEMBER "?", which gives you help. Commands for moving the Enterprise may operate in one of two ways. If it is in impulse mode, movement commands affect the position of the ship; if it is in warp mode, movement commands affect the velocity instead. The Base always moves in impulse mode. Since multiple commands may be entered in one turn (if you can type fast enough), it is possible to jump over things even in impulse mode. In a crowded universe this may be the only way to go. (Actually, motion commands always change the velocity--the actual motion does not occur until the next turn. Impulse mode simply causes the velocity to be zeroed out at the end of every turn. Phaser commands, on the other hand, are executed immediately. If you want to move and fire a phaser, you must wait for the motion to actually occur before typing the phaser command, or the phaser fires from your old position. This is a feature, not a bug, and is intended to reflect reality. Really.) If multiple torpedo launching commands are given in a turn, a single torpedo is launched with extra velocity. You can thus launch photon torpedoes over objects in the way, and get them where you want them quickly. This feature works well with the destruct button. Variations on this may be useful against the Space Amoeba. NOTE: Phasers destroy the target by blasting the projected next location of the object hit. This means that if the object hit, be it Klingon, Romulan or Enterprise, changes velocity in the same turn, it can elude the effect of the phaser! (Note that this also means that if you phaser a Klingon or torpedo that is about to ram you, you will be phasered as well as he/she/it. This can be embarrassing, not to mention deadly.) Smart players move immediately upon phasering something at short range, or whenever they think they might get phasered (in other words, most of the time). Objects with larger mass can bounce objects with smaller mass out of the way. In a crowded universe the bouncee can bounce quite a way before finding an empty place to land. If you let the Tholians fill up the universe with web, so that there is no place to bounce to, the Tholians win that wave. The status line across the top gives the current mode, the number of points accumulated this wave, the Enterprise's energy and torpedoes, the Base's energy and torpedoes, the number of stars, the number of enemies, and the stardate. You will note that nice things happen to your energy levels when you put the Enterprise next to the Base, or the Base next to some stars. Bad things happen inside an Amoeba. An object is destroyed when its energy goes negative, either from a direct hit, or from the blast of the previous turn's explosions. Enemies and stars start with random amounts of energy. High energy enemies can go warp 2. A Romulan with sufficient energy maintains a cloaking device. Tholians spin web, Gorns shoot homing torpedoes, and the Planet Crusher munches anything in its way, even Apollo. Apollo won't let you go unless you kill him, but he loves you very much and beefs up your shields considerably. Both Apollo and the Planet Crusher recharge themselves, so you must hit them hard in a single turn to do them in. (Yes, the Planet Crusher must be shot in the mouth--he can only die of gluttony--and he blasts out of his mouth when he dies.) Tholian web may be crossed only by coasting across it in warp mode, or by blasting it (but web blasts extend twice as far as normal blasts, so keep your distance). The Space Amoeba sucks energy and grows, and you must destroy the nucleus. Somehow. There are at least four ways. Phasers won't work on the big ones. Pirates turn inhabited star systems into uninhabited ones. Even Friendly Freighters will take potshots at you if you get them mad enough. Note that because of the size of the Base's turbo-lasers (the Base does not have phasers) they cannot shoot anything next to the Base. (This is why the Death Star died!) In part, this is to protect the Enterprise. It also lets you shoot over one adjacent star. The Enterprise's phasers will shoot over a arbitrary number of adjacent, contiguous stars, including inhabited ones. Phasers die away with distance, so don't expect them to kill everything with one blow. While the Enterprise's shields are up (when it is displayed as "E" rather than "e"), hits on it count only a fifth as much (or even less if you are moving in warp mode). The shields are automatically maintained as long as there are more than 500 units of energy for the Enterprise. The Base also has shields, which stay up as long as it has at least 1000 units of energy. Aside from losing energy, the Enterprise can also take damage, either random damage from getting blasted, or specific damage when a system is in use and breaks down under the load. In place of the score you will see the Estimated Time to Repair. Sometimes docking helps to get things fixed faster. If you lose both your warp and impulse engines, try the tractors. The Base doesn't take damage because it has much more redundancy than the Enterprise. You get points for destroying enemies and hostile torpedoes. At the end of a wave, you also get bonus points for saving stars, saving the Enterprise and Base, and for having an efficiency rating higher that 0.8. You get NEGATIVE bonus points for letting friendly life forms get blown up, and for giving up. Bonuses tend to be scaled by the ratio of the number of points you got over the number of points you could have got. If you think you are done with a wave, but it won't quit, there may be homing torpedoes that you haven't destroyed--you must make the universe safe for posterity, you know. When you have used up your Enterprises and Bases (or quit), your score will be posted to the scoreboard. You may see the scoreboard outside of the game simply by giving the command "warp -s". If you get bored, you can always play with some of the undocumented switches that are used to test warp. Such funny games go on their own scoreboard. For kicks try "warp -x -d50 -C -\& -G -T -E400 -S5" and then go hide. Quick. ================================================ FILE: games/warp/warp.h ================================================ /* $Header: warp.h,v 7.0.1.3 95/21/1 17:08:42 lwall Exp $ */ /* $Log: warp.h,v $ * Revision 7.0.1.3 95/21/1 18:40:00 sms * Remove ifdefs around pwd.h * * Revision 7.0.1.2 86/12/12 17:08:42 lwall * Baseline for net release. * * Revision 7.0.1.1 86/10/16 10:54:26 lwall * Added Damage. Fixed random bugs. * * Revision 7.0 86/10/08 15:17:55 lwall * Split into separate files. Added amoebas and pirates. * */ #include #include #include #include #include #include #include #include /* WARPLIB must be readable and writeable by warp, but not by anyone who you * don't trust. In other words, to set up warp so everyone can play and * no one can cheat, give warp a uid of its own and make warp setuid to * that uid. WARPLIB must then NOT be made writeable by the world, * since no attempt is made to encrypt saved games or anything. * (It must be readable by the world, however, due to a strangeness in * access.) */ #define SAVEDIR "./" #define NEWSFILE "warp.news" #define HELPFILE "warp.doc" #define LOCKFILE ".warp.lock" #define LOGFILE "warp.log" #define SCOREBOARD "warp.top" #define LSCOREBOARD "warp.lowtop" #define FSCOREBOARD "warp.funtop" #define TMPSCOREBOARD "warp.topnew" #define WARPMACRO "%X/Kbmap.%{TERM}" /* warp library */ #ifndef WARPLIB /* ~ and %l only ("~%l" is permissable) */ # define WARPLIB "/usr/games/warp" #endif EXT char *warplib; #define PERMMAPS 8 /* how many starmaps are permanent */ #define MAPS 20 /* how many starmaps to choose from */ /* (MAPS - PERMMAPS is # of half-gone universes) */ /* * Screen size info, minimum screen size is 23x40 (actually 24x80). * YSIZE and XSIZE should be relatively prime so that a torpedo launched * at an angle will eventually cover the whole screen. * To calculate a new position for something: * new_position = (current_position + delta + ?SIZE00) % ?SIZE * This allows for negative deltas of up to ?SIZE00 (% doesn't work right * on negative numbers). * ?SIZE01, etc. are fudges for efficiency--they already include a delta. */ #define XYSIZE 920 #define XYSIZEx4 3680 #define YSIZE 23 #define YSIZE00 2300 #define YSIZE01 2301 #define YSIZE99 2299 #define XSIZE 40 #define XSIZE00 4000 #define XSIZE01 4001 #define XSIZE99 3999 #define XSIZE02 4002 #define XSIZE98 3998 #define XSIZE03 4003 #define XSIZE97 3997 #define XSIZE08 4008 #define XSIZE92 3992 EXT char amb[YSIZE][XSIZE]; #ifndef isalnum # define isalnum(c) (isalpha(c) || isdigit(c)) #endif #include #include #include #ifdef TERMIO # include #else # include #endif #define BITSPERBYTE 8 #define LBUFLEN 512 /* line buffer length */ #define CBUFLEN 256 /* command buffer length */ #define PUSHSIZE 128 #define MAXFILENAME 128 #define FINISHCMD 0177 /* some handy defs */ #define bool char #define TRUE (1) #define FALSE (0) #define Null(t) ((t)0) #define Nullch Null(char *) #define Nullfp Null(FILE *) #define Ctl(ch) (ch & 037) #define strNE(s1,s2) (strcmp(s1,s2)) #define strEQ(s1,s2) (!strcmp(s1,s2)) #define strnNE(s1,s2,l) (strncmp(s1,s2,l)) #define strnEQ(s1,s2,l) (!strncmp(s1,s2,l)) #define sgn(x) ((x) < 0 ? -1 : (x) > 0) /* Things we can figure out ourselves */ #ifdef SIGPROF # define BSD42 /* do we have Berkeley 4.2? */ #endif #ifdef FIONREAD # define PENDING #else # ifdef O_NDELAY # define PENDING # endif #endif #ifdef EUNICE # define UNLINK(victim) while (!unlink(victim)) #else # define UNLINK(victim) unlink(victim) #endif /* Valid substitutions for strings marked with % comment are: * %H Host name (yours) * %L Login name (yours) * %N Full name (yours) * %O Original working directory (where you ran warp from) * %X Warp library directory * %~ Home directory * %. Directory containing . files * %$ current process number * %{name} Environment variable "name". %{name-default} form allowed. * %"prompt" * Print prompt and insert what is typed. * %`command` * Insert output of command. * %(test_text=pattern?if_text:else_text) * Substitute if_text if test_text matches pattern, otherwise * substitute else_text. Use != for negated match. * % substitutions are done on test_text, if_text, and else_text. * (Note: %() only works if CONDSUB defined.) */ /* *** System Dependent Stuff *** */ /* NOTE: many of these are defined in the config.h file */ #ifndef LOGDIRFIELD # define LOGDIRFIELD 6 /* Which field (origin 1) is the */ /* login directory in /etc/passwd? */ /* (If it is not kept in passwd, */ /* but getpwnam() returns it, */ /* define the symbol GETPWENT) */ #endif #ifndef GCOSFIELD # define GCOSFIELD 5 #endif /* Undefine any of the following features to save both I and D space */ /* In general, earlier ones are easier to get along without */ /* Pdp11's without split I and D may have to undefine them all */ #define DEBUGGING /* include debugging code */ #define PUSHBACK /* macros and keymaps using pushback buffer */ #define CONDSUB /* allow %(cond?text:text) */ #define BACKTICK /* allow %`command` */ #define PROMPTTTY /* allow %"prompt" */ #define GETLOGIN /* use getlogin() routine as backup to environment */ /* variables USER or LOGNAME */ #define TILDENAME /* allow ~logname expansion */ #define SETUIDGID /* substitute eaccess() for access() so that rn */ /* can run setuid or setgid */ /* if not setuid or setgid, you don't need it */ #define VERBOSE /* compile in more informative messages */ #define TERSE /* compile in shorter messages */ /* some dependencies among options */ #ifndef SETUIDGID # define eaccess access #endif #ifdef VERBOSE # ifdef TERSE # define IF(c) if (c) # define ELSE else # else /* !TERSE */ # define IF(c) # define ELSE # endif #else /* !VERBOSE */ # ifndef TERSE # define TERSE # endif # define IF(c) "IF" outside of VERBOSE??? # define ELSE "ELSE" outside of VERBOSE??? #endif #ifdef DEBUGGING # define assert(ex) {if (!(ex)){fprintf(stderr,"Assertion failed: file %s, line %d\r\n", __FILE__, __LINE__);sig_catcher(0);}} #else # define assert(ex) ; #endif #define TCSIZE 512 /* capacity for termcap strings */ /* End of Space Conservation Section */ /* More System Dependencies */ #define sigset signal #define sigignore(sig) signal(sig,SIG_IGN) /* preferred shell for use in doshell routine */ /* ksh or sh would be okay here */ #ifndef PREFSHELL # define PREFSHELL "/bin/csh" #endif /* path to fastest starting shell */ #ifndef SH # define SH "/bin/sh" #endif /* location of macro file */ #ifndef WARPMACRO # ifdef PUSHBACK # define WARPMACRO "%./.warpmac" # endif #endif /* a motd-like file for warp */ #ifndef WARPNEWSNAME /* % and ~ */ # define WARPNEWSNAME "%X/warp.news" #endif /* typedefs */ typedef unsigned int MEM_SIZE; /* for passing to malloc */ /* *** end of the machine dependent stuff *** */ /* GLOBAL THINGS */ /* file statistics area */ EXT struct stat filestat; EXT char buf[LBUFLEN+1]; /* general purpose line buffer */ EXT char *cwd INIT(Nullch); /* current working directory */ /* switches */ #ifdef DEBUGGING EXT int debug INIT(0); /* -D */ # define DEB_FILEXP 64 #endif #ifdef VERBOSE # ifdef TERSE EXT bool verbose INIT(TRUE); /* +t */ # endif #endif /* miscellania */ EXT FILE *tmpfp INIT(Nullfp); /* scratch fp */ #define NOMARKING 0 #define STANDOUT 1 #define UNDERLINE 2 /* Factored strings */ EXT char nullstr[] INIT(""); EXT char readerr[] INIT("warp read error"); EXT char cantopen[] INIT("Can't open %s\r\n"); #ifdef VERBOSE EXT char nocd[] INIT("Can't chdir to directory %s\r\n"); #else EXT char nocd[] INIT("Can't find %s\r\n"); #endif extern int errno; EXT bool justonemoretime INIT(TRUE); EXT bool keepgoing INIT(TRUE); EXT bool friendspec INIT(FALSE); EXT bool piratespec INIT(FALSE); EXT bool amoebaspec INIT(FALSE); EXT bool starspec INIT(FALSE); EXT bool klingspec INIT(FALSE); EXT bool apolspec INIT(FALSE); EXT bool crushspec INIT(FALSE); EXT bool romspec INIT(FALSE); EXT bool prespec INIT(FALSE); EXT bool tholspec INIT(FALSE); EXT bool gornspec INIT(FALSE); EXT bool beginner INIT(FALSE); EXT bool massacre INIT(FALSE); EXT bool lowspeed INIT(FALSE); EXT bool debugging INIT(FALSE); EXT bool didkill INIT(FALSE); EXT bool experimenting INIT(FALSE); EXT bool scorespec INIT(FALSE); EXT bool metakey INIT(FALSE); EXT bool bombed_out; EXT bool panic INIT(FALSE); EXT bool madgorns; EXT int madfriends; EXT int inumpirates; EXT int numpirates; EXT int inumfriends; EXT int numfriends; EXT int inumamoebas; EXT int numamoebas; EXT int inumstars; EXT int numstars; EXT int inumenemies; EXT int numenemies; EXT int inumroms; EXT int inumthols; EXT int inumapollos; EXT int numapollos; EXT int apolloflag; EXT int inumcrushes; EXT int numcrushes; EXT int inumgorns; EXT int numgorns; EXT int deados; EXT int deadmudds; EXT int smarts; EXT int ismarts INIT(0); EXT int numos INIT(0); EXT int numxes INIT(0); EXT int ient; EXT int numents; EXT int ibase; EXT int numbases; EXT int inuminhab; EXT int numinhab; EXT int wave; EXT int cumsmarts; EXT int prescene INIT(-1); EXT int scandist; EXT int antibase; EXT int sm35; EXT int sm45; EXT int sm50; EXT int sm55; EXT int sm80; EXT int sm95; EXT int entmax; EXT int basemax; EXT int enemshields; EXT int super; EXT int whenok; EXT int yamblast; EXT int xamblast; EXT int ambsize; EXT char spbuf[512]; #define Fclose (void)fclose #define Fflush (void)fflush #define Sprintf (void)sprintf #define Signal (void)signal #define Safecpy (void)safecpy #define Cpytill (void)cpytill #define Tract (void)tract #define Make_object (void)make_object #define Read_tty (void)read_tty ================================================ FILE: games/warp/warp.man ================================================ .TH WARP 6 "June 20, 1987" .SH NAME warp - a real-time space war game .SH SYNOPSIS .B warp [options] .SH DESCRIPTION .I Warp is a real-time space war game that requires skill and quick thinking. "Real-time" in this context means that the enemies keep moving (and shooting) even if you don't. A unique feature of .I warp is that blast propagates; it is unhealthy to remain near things that are in the process of blowing up. If a given universe is above a critical density it may chain react. Scoring is like many popular arcade games--there are multiple waves which get harder and harder as you go along. Nobody has ever maxed out the scoreboard without cheating. .PP Unlike many space-war games, .I warp is not simply a shooting gallery. Along with phasers and photon torpedoes, you have tractor beams and a cloaking device. Skill in navigation is important. It helps to be schizophrenic, because you must manage an Enterprise and a Base simultaneously. And enemies do not simply shoot back. You can get tailed, absorbed, snuck up upon, hemmed in, rammed, loved to death, reprimanded for destroying civilized life, dragged around, robbed, damaged and eaten. And if you should happen to get bored by the enemies (a trifle unlikely), you can always watch the interesting star patterns. In fact, you'll have to, since your tactics will depend upon what kind of universe you find yourself in. .PP .I Warp is played in a double wraparound universe, i.e. the bottom is connected to the top, and the right is connected to the left. You need a crt with random cursor addressing and at least 24 lines by 80 columns. For more information about about how to play, simply run .I warp and say "y" when it asks if you want to see the instructions. There is also a single-page command summary that you can get while playing by typing a "?". .PP Command line options include: .TP 5 .B -b Put .I warp into beginner mode. Makes the difficulty increase more slowly, but penalizes you for it. .TP 5 .B -d Sets the initial difficulty to .BR n . .TP 5 .B -l Play a low-speed game. Changes the basic cycle time from 1 second to 2 seconds. This switch is automatically set at baud rates below 2400. You may want to set it at higher speeds if your terminal cannot keep up with the output. (This should never happen on BSD systems, which have an IOCTL call to determine output queue length.) Because this makes the game easier, a separate scoreboard is kept for low-speed games. .TP 5 .B -m Terminal has a meta key which turns on the eighth bit. Ordinarily the eighth bit is stripped in order to ignore parity. Metacharacters will appear to the keymap as prefixed with a ^A, and will subsequently have the same effect as a control character, unless otherwise mapped. .TP 5 .B -s Just prints out the scoreboards and saved games and then exits. .TP 5 .B -v Prints out the version number. .TP 5 .B -x Play an experimental game. This causes .I warp to ignore any saved game, and disables the ability to save the current game. Thus you can play around with something or show .I warp to someone without jeopardizing a currently saved game. .SH ENVIRONMENT .TP 5 .B WARPMACRO If defined, names a file containing keyboard mappings and macros. If not defined, the value %X/Kbmap.%{TERM} is assumed. The macro file contains lines of the following form: .sp .sp You may use certain % interpolations and ^ control characters. For possible % interpolations see warp.h. Sequences in the canonical-keystroke-sequence bounded by ^(...^) are subject to reinterpretation via the keymap. This file has two major uses. First, you can set up your commands to use any kind of prefix key your terminal might have, or change the key bindings in any other way you choose. Second, you can define arbitrary macros, such as this: .sp # define Corbamite maneuver = DDllllll .SH AUTHOR Larry Wall .SH FILES ~/.fullname, if full names aren't in /etc/passwd .SH DIAGNOSTICS Generally self-documenting, as they say. .SH BUGS Addicting. At the end of a wave, all you have to do to keep going is hit a space. You see the message "Hit space to continue" and automatically hit space. About 2 seconds later you remember you wanted to go home, but by then it's too late to escape without penalty. .PP You can't kill a backgrounded .I warp process directly, because it is running setuid. You have to use the killer built in to .IR warp . .PP Now that there is a space amoeba, there ought to be tribbles. But it might be too much trouble... ================================================ FILE: games/warp/warp.news ================================================ *** WARP NEWS *** Welcome to warp! Please send any gripes, comments, fantastic ideas, etc. to lwall@sdcrdcf.uucp (Larry Wall). ================================================ FILE: games/warp/weapon.c ================================================ /* $Header: weapon.c,v 7.0.1.2 86/10/20 14:36:33 lwall Exp $ */ /* $Log: weapon.c,v $ * Revision 7.0.1.2 86/10/20 14:36:33 lwall * Picked some lint. * * Revision 7.0.1.1 86/10/16 10:54:42 lwall * Added Damage. Fixed random bugs. * * Revision 7.0 86/10/08 15:18:08 lwall * Split into separate files. Added amoebas and pirates. * */ #include "EXTERN.h" #include "warp.h" #include "bang.h" #include "object.h" #include "move.h" #include "score.h" #include "sig.h" #include "term.h" #include "them.h" #include "us.h" #include "util.h" #include "INTERN.h" #include "weapon.h" void weapon_init() { ; } void fire_torp(from, ydir, xdir) register OBJECT *from; register int ydir; register int xdir; { register OBJECT *to; if (from->type == Enemy || (from == ent && etorp > 0) || (from == base && btorp > 0)) { to = occupant[(from->posy+from->vely+ydir+YSIZE00)%YSIZE] [(from->posx+from->velx+xdir+XSIZE00)%XSIZE]; if (from->type != Enemy || !to || to->vely || to->velx) { if (from->type != Enemy && (to = isatorp[from==base][ydir+1][xdir+1])) { to->vely += ydir; to->velx += xdir; } else { if (from == ent) { to = make_object(Torp, '+', from->posy,from->posx, from->vely+ydir,from->velx+xdir, 0L, 1L,&root); aretorps++; isatorp[0][ydir+1][xdir+1] = to; etorp--; } else if (from == base) { to = make_object(Torp, '+', from->posy,from->posx, from->vely+ydir,from->velx+xdir, 0L, 1L,&root); aretorps++; isatorp[1][ydir+1][xdir+1] = to; btorp--; } else if (from->image == 'G') { numos++; to = make_object(Torp, 'o', from->posy,from->posx, from->vely+ydir,from->velx+xdir, 100L, 1L,&root); if (madgorns) { possiblescore += 35; to->image = '0'; to->mass = 2000; to->energy = 2000; } else if (rand_mod(120)+10 > smarts) possiblescore += 100; else { possiblescore += 200; to->image = 'O'; } } else { to = make_object(Torp, 'x', from->posy,from->posx, from->vely+ydir,from->velx+xdir, 0L, 1L,&root); if (rand_mod(160)+10 > smarts) possiblescore += 10; else { possiblescore += 100; to->image = 'X'; to->mass = 1000+super*20; numxes++; } } } } } } void attack(attackee) register OBJECT *attackee; { register int dx; register int dy; register int curx; register int cury; register int prob; register OBJECT *obj; register bool torps; register bool webnear = FALSE; register bool thru_stars; int nukey; int nukex; int nukedist; if (attackee) { if (attackee == nuke) { if (amb[attackee->posy][attackee->posx] != '~') return; nukey = nukex = 0; nukedist = 100; } for (dx= -1; dx<=1 ; dx++) { for (dy= -1; dy<=1; dy++) { if (dx||dy) { cury = attackee->posy; curx = attackee->posx; torps = thru_stars = FALSE; if (massacre || madgorns || !rand_mod(53-super) ) webnear += rand_mod(2); else webnear = FALSE; for (prob = scandist;prob;prob--) { cury = (cury + dy + YSIZE00) % YSIZE; curx = (curx + dx + XSIZE00) % XSIZE; if (obj = occupant[cury][curx]) { switch (obj->image) { case 'P': case 'K': case 'R': case ' ': pot_shot: if (attackee == nuke) { if (rand_mod(2+scandist-prob) < rand_mod(smarts/40+1)) Tract(nuke,dy,dx,rand_mod(3)?1:-1); } if (rand_mod(51 - sm50) <= prob) { switch (obj->strategy||thru_stars?0: rand_mod(ent?4:2)) { case 1: case 2: if (-dy + attackee->vely == obj->vely && -dx + attackee->velx == obj->velx) fire_torp(obj, -dy + attackee->vely, -dx + attackee->velx); else fire_torp(obj, -dy + attackee->vely - obj->vely, -dx + attackee->velx - obj->velx); if (obj->image == ' ') setimage(obj, obj->flags & PIRATE ? 'P' : 'R'); break; case 3: { int newspeed = rand_mod(prob<5&&smarts>70?4:3)-1; obj->vely = -dy * newspeed; obj->velx = -dx * newspeed; if (newspeed >= 0 && !rand_mod(82-sm80)) { obj->vely += attackee->vely; obj->velx += attackee->velx; } break; } case 0: if (!torps && obj->energy > 1000) { fire_phaser(obj, -dy, -dx); if (smarts > 40 && (scandist-prob > 5 || attackee==base) && (massacre || obj->strategy || rand_mod(2))) while (rand_mod(2)) fire_phaser(obj, -dy, -dx); if (obj->image == ' ') setimage(obj, obj->flags&PIRATE ? 'P':'R'); } if (obj->strategy) { obj->velx = obj->vely = 0; if (obj->energy < 1000 || bvely || bvelx) obj->strategy = 0; } else if ((attackee==base || (cloaking && attackee==ent) ) && scandist-prob > 5 && !(rand_mod( ent?antibase*2:antibase)) ) obj->strategy = 1; break; } } goto bombout; case 'G': if (thru_stars && obj->strategy < 7) goto bombout; if (attackee == nuke) { if (rand_mod(2+scandist-prob) < rand_mod(smarts/40+1)) Tract(nuke,dy,dx,rand_mod(3)?1:-1); goto bombout; } if (obj->strategy) { if (madgorns || !rand_mod(4)) { obj->vely = attackee->vely; obj->velx = attackee->velx; } obj->strategy += (!torps && deados > 10); if (obj->strategy > 4) madgorns = TRUE; if (!torps && obj->strategy > 5) { do { fire_phaser(obj, -dy, -dx); } while (rand_mod(2)); } } else if (numgorns >= numenemies-1 && deados > 15+numgorns*5) obj->strategy = 1; if (madgorns || rand_mod(51 - sm50) <= prob) { if (-dy + attackee->vely == obj->vely && -dx + attackee->velx == obj->velx) fire_torp(obj, -dy + attackee->vely, -dx + attackee->velx); else fire_torp(obj, -dy + attackee->vely - obj->vely, -dx + attackee->velx - obj->velx); } goto bombout; case 'T': if (attackee == nuke) { if (rand_mod(2+scandist-prob) < rand_mod(smarts/40+1)) Tract(nuke,dy,dx,rand_mod(3)?1:-1); } if (thru_stars) goto bombout; if (webnear && scandist-prob > 5) { if (massacre || rand_mod(50) < super) { if (!torps && obj->energy > 1000) { fire_phaser(obj, -dy, -dx); while (!rand_mod(57-sm55)) fire_phaser(obj, -dy, -dx); } } } goto bombout; case 'C': case 'c': if (thru_stars) goto bombout; break; case 'Q': case 'W': case 'Y': case 'U': case 'I': case 'S': case 'D': case 'H': case 'J': case 'L': case 'Z': case 'V': case 'M': case 'F': if (attackee == nuke) { if (rand_mod(2+scandist-prob) < rand_mod(smarts/40+1)) Tract(nuke,dy,dx,rand_mod(3)?1:-1); if (rand_mod(2)) goto pot_shot; } if (madfriends > 1000) { madfriends -= 200; goto pot_shot; } /* FALL THROUGH */ case '+': if (attackee == nuke) { if (smarts > 70) { if ( (obj->posx + obj->velx + XSIZE00)%XSIZE == attackee->posx && (obj->posy + obj->vely + YSIZE00)%YSIZE == attackee->posy ) { Tract(nuke,dy,dx,-1); } else while (!rand_mod(82-sm80)) Tract(nuke,dy,dx,-1); } else if (smarts > 60 || rand_mod(2+scandist-prob) < rand_mod(smarts/20+1)) Tract(nuke,dy,dx,rand_mod(3)?1:-1); } torps = FALSE; thru_stars = FALSE; break; case '|': case '-': case '/': case '\\': if (thru_stars) goto bombout; webnear = (scandist-prob < 3); torps = FALSE; break; case 'x': if (attackee == nuke) { if (rand_mod(2+scandist-prob) < rand_mod(smarts/20+1)) Tract(nuke,dy,dx,rand_mod(3)?1:-1); } if (thru_stars) goto bombout; torps = TRUE; break; case 'o': case 'O': case '0': if (attackee == nuke) { if (rand_mod(2+scandist-prob) < rand_mod(smarts/20+1)) Tract(nuke,dy,dx,rand_mod(3)?1:-1); } if (thru_stars) goto bombout; torps = TRUE; if (rand_mod(99+3*scandist) < smarts+3*prob) { obj->vely = -dy + attackee->vely; obj->velx = -dx + attackee->velx; if (obj->flags & STATIC) {/* not a mover? */ obj->flags &= ~STATIC; obj->prev->next = obj->next; obj->next->prev = obj->prev; root.prev->next = obj; obj->prev = root.prev; root.prev = obj; obj->next = &root; } } if (obj->image != '0') break; /* DROP THROUGH! */ case 'X': if (attackee == nuke) { if (rand_mod(2+scandist-prob) < rand_mod(smarts/20+1)) Tract(nuke,dy,dx,rand_mod(3)?1:-1); } torps = TRUE; if (thru_stars) goto bombout; if (prob == scandist) { int y, x; blast[y=(obj->posy+obj->vely+YSIZE00)%YSIZE] [x=(obj->posx+obj->velx+XSIZE00)%XSIZE] += (obj->image == '0' ? 2000 : 200); yblasted[y] |= 1; xblasted[x] |= 1; blasted = TRUE; } break; case 'A': if (attackee != nuke) { if (scandist-prob>1 && !rand_mod(51-super)) Tract(obj,-dy,-dx,1); } /* FALL THROUGH */ case '*': case '@': if (attackee == nuke) { if (amb[cury][curx] != '~') { if (scandist-prob < nukedist) { nukedist = scandist-prob; nukey = dy; /* nearest food in */ nukex = dx; /* this direction */ } if (smarts > 55 && scandist-prob > 8) { if (rand_mod(30+scandist-prob) < rand_mod(smarts/20+1)) Tract(nuke,dy,dx,1); } } else if (obj->vely || obj->velx) { Tract(nuke,dy,dx,1); /* for looks */ obj->vely = obj->velx = 0; } } if (!thru_stars) if (rand_mod(97-sm95)) goto bombout; else thru_stars = TRUE; break; case '<': case '>': if (attackee == nuke) { if ((!dy && scandist-prob < 8) || rand_mod(2+scandist-prob) < rand_mod(smarts/20+1) ) { nuke->mass += 10000; Tract(nuke,dy,dx,-1); nuke->mass -= 10000; } } goto bombout; case 'E': case 'B': if (attackee == nuke) { if (rand_mod(2+scandist-prob) < rand_mod(smarts/40+1)) Tract(nuke,dy,dx,rand_mod(3)?1:-1); } goto bombout; default: goto bombout; } } else { if (thru_stars) goto bombout; } } bombout: ; /* end of loop */ } } } if (attackee == nuke && nukedist < 100) {/* aim amoeba at nearest */ if (nukey < 0) /* free star */ nukey = 2; if (nukex < 0) nukex = 2; nuke->strategy = nukey + (nukex << 2); } } } void fire_phaser(obj, dy, dx) register OBJECT *obj; register int dy; register int dx; { register int y; register int x; register int skipping; register int size=5000; int decr = 50, oldy, oldx; static char curchar[] = "@* "; if (obj == ent) decr = 100; else if (obj == base) { decr = 1000; size = 200; } if (!dy) curchar[2] = '-'; else if (!dx) curchar[2] = '!'; else if (dy == dx) curchar[2] = '\\'; else curchar[2] = '/'; if (obj->energy >= decr) { obj->energy -= decr; for ( /* initialize */ skipping = (obj != base), y = (obj->posy+(obj==base?dy*2:dy)+YSIZE00)%YSIZE, x = (obj->posx+(obj==base?dx*2:dx)+XSIZE00)%XSIZE; /* while */ size && (!occupant[y][x]||(skipping && occupant[y][x]->type==Star)); /* at end of loop */ y = (y+dy+YSIZE00) % YSIZE, x = (x+dx+XSIZE00) % XSIZE, size = size * 3 / 4 ) { move(y+1,x*2,0); beg_qwrite(); if (obj == base || obj->image == 'T') { *filler = '@'; qwrite(); *filler = '#'; qwrite(); *filler = '~'; qwrite(); *filler = '%'; qwrite(); *filler = ':'; qwrite(); *filler = '@'; } else { *filler = size >= 500 ? *curchar : (size >= 50 ? curchar[1] : curchar[2]); } qwrite(); if (occupant[y][x]) qaddc(occupant[y][x]->image); else { if (numamoebas) qaddc(amb[y][x]); else qaddspace(); if (skipping) skipping = 0; } end_qwrite(); } if (size) { char img; assert(occupant[y][x]); img = occupant[y][x]->image; if (occupant[y][x]->type == Crusher) { if (dy) return; if (dx==(img == '<' ? 1 : -1) ) { occupant[y][x]->image = (occupant[y][x]->velx *= -1) < 0 ? '>' : '<'; return; } } else if (occupant[y][x]->flags & FRIENDLY) madfriends += 200; if (numamoebas && amb[y][x] == '~' && smarts % 3 && (smarts > 70 || rand_mod(smarts) > rand_mod(20)) ) { if (size > 10000) modify_amoeba(y,x,1,'~',10); else if (size > 1000) modify_amoeba(y,x,1,'~',7); else if (size > 50) modify_amoeba(y,x,1,'~',5); else modify_amoeba(y,x,1,'~',2); if (occupant[y][x] == nuke) { nuke->strategy = rand_mod(30); nuke->flags |= COUNTDOWN; } return; } else { move(y+1,x*2,0); beg_qwrite(); if (img == ' ') { *filler = occupant[y][x]->flags & PIRATE ? 'P' : 'R'; occupant[y][x]->image = *filler; occupant[y][x]->strategy = 0; qwrite(); qwrite(); } else if (img == 'C' || img == 'c') { cloaked = 0; img += 2; occupant[y][x]->image = img; *filler = img; qwrite(); qwrite(); } else if (img == 'K' && size > 50) occupant[y][x]->strategy = 0; *filler = '@'; qwrite(); *filler = '#'; qwrite(); *filler = '@'; qwrite(); *filler = '#'; qwrite(); *filler = '@'; qwrite(); qaddc(img); end_qwrite(); oldy = y; oldx = x; y = (occupant[oldy][oldx]->posy + occupant[oldy][oldx]->vely + YSIZE00) % YSIZE; x = (occupant[oldy][oldx]->posx + occupant[oldy][oldx]->velx + XSIZE00) % XSIZE; if (occupant[y][x] && occupant[y][x]->type == Star) { y = occupant[oldy][oldx]->posy; x = occupant[oldy][oldx]->posx; } if (obj==base) blast[y][x] += size>50 ? 15000 : (size>15 ? 1500 : 150); else if (obj==ent) blast[y][x] += size*4; else if (obj->image=='T') blast[y][x] += 15000; else blast[y][x] += size*smarts/25; yblasted[y] |= 1; xblasted[x] |= 1; blasted = TRUE; } } } } int tract(obj, dy, dx, to_or_fro) register OBJECT *obj; register int dy; register int dx; int to_or_fro; { register int y; register int x; register int size=10; static char ch; register OBJECT *tractee; if (!dy) ch = '|'; else if (!dx) ch = '-'; else if (dy == dx) ch = '/'; else ch = '\\'; { for ( y = (obj->posy+dy+YSIZE00)%YSIZE, x = (obj->posx+dx+XSIZE00)%XSIZE; size && (!occupant[y][x]); y = (y+dy+YSIZE00) % YSIZE, x = (x+dx+XSIZE00) % XSIZE, size--) { move(y+1,x*2,0); beg_qwrite(); *filler = ch; qwrite(); qwrite(); if (numamoebas) qaddch(amb[y][x]); else qaddspace(); end_qwrite(); } tractee = occupant[y][x]; if (size) { assert(tractee); if (numamoebas && obj != nuke && amb[y][x] == '~') { if (to_or_fro > 0) modify_amoeba(y,x,2,'~',size); else modify_amoeba(y,x,1,' ',size); } if (tractee->type != Web && (tractee->mass < obj->mass * 5 || (tractee->type == Crusher && !dx) ) ) { if (tractee == ent) { evely -= dy * to_or_fro; evelx -= dx * to_or_fro; } else if (tractee == base) { bvely -= dy * to_or_fro; bvelx -= dx * to_or_fro; } else { tractee->vely -= dy * to_or_fro; tractee->velx -= dx * to_or_fro; } if (tractee->type == Torp || tractee->type == Star) { if (tractee->flags & STATIC) { /* not a mover? */ tractee->flags &= ~STATIC; tractee->prev->next = tractee->next; tractee->next->prev = tractee->prev; root.prev->next = tractee; tractee->prev = root.prev; root.prev = tractee; tractee->next = &root; } } } else if (tractee->type == Crusher && !dy && dx==(tractee->image == '<' ? 1 : -1) ) { setimage(tractee, (tractee->velx *= -1) < 0 ? '>' : '<'); } if (tractee->mass * 5 > obj->mass) return(1); } } return(0); } ================================================ FILE: games/warp/weapon.h ================================================ /* $Header: weapon.h,v 7.0 86/10/08 15:18:20 lwall Exp $ */ /* $Log: weapon.h,v $ * Revision 7.0 86/10/08 15:18:20 lwall * Split into separate files. Added amoebas and pirates. * */ EXT int tractor INIT(0); EXT int etorp; EXT int btorp; EXT OBJECT *isatorp[2][3][3]; EXT int aretorps; void fire_torp(); void attack(); void fire_phaser(); int tract(); void weapon_init(); ================================================ FILE: include/.gitignore ================================================ machine ================================================ FILE: include/Makefile ================================================ # # Copyright (c) 1980 Regents of the University of California. # All rights reserved. The Berkeley software License Agreement # specifies the terms and conditions for redistribution. # # @(#)Makefile 5.16.1 (2.11BSD GTE) 1997/9/22 # # Doing a ``make includes'' builds ${DESTDIR}/usr/include # # Define SHARED to indicate whether you want # symbolic links to the system source (``symlinks''), # or a separate copy (``copies''). # (latter useful in environments where it's # not possible to keep /sys publicly readable) # # The ``rm -rf''s used below are safe because rm doesn't # follow symbolic links. # TOPSRC!=cd ..; pwd include ${TOPSRC}/share/mk/sys.mk STD= a.out.h alloca.h ar.h assert.h \ ctype.h curses.h \ fcntl.h float.h fstab.h \ grp.h kmem.h lastlog.h libgen.h limits.h \ math.h mtab.h ndbm.h nlist.h \ paths.h psout.h pwd.h \ ranlib.h regexp.h \ setjmp.h sgtty.h \ stdarg.h stdbool.h stddef.h stdint.h stdio.h stdlib.h \ string.h strings.h struct.h syscall.h sysexits.h \ term.h time.h ttyent.h tzfile.h \ unistd.h utmp.h vmf.h LINKS= errno.h signal.h stdint.h syslog.h SUBDIRS=arpa # XXX This is temporary SUBDIRS+=smallc smallc/sys MACHDEP=${MACHINE} NETDIRS=netinet SYSDIRS=${NETDIRS} ${MACHDEP} #SHARED= symlinks SHARED= copies TAGSFILE=tags all: includes: ${SHARED} -for i in ${STD}; do \ cmp -s $$i ${DESTDIR}/usr/include/$$i || \ ${INSTALL} -c -m 444 $$i ${DESTDIR}/usr/include/$$i; \ done -for i in ${SUBDIRS}; do \ if [ ! -d ${DESTDIR}/usr/include/$$i ]; \ then \ mkdir ${DESTDIR}/usr/include/$$i; \ fi; \ (cd $$i; for j in *.[ih]; do \ cmp -s $$j ${DESTDIR}/usr/include/$$i/$$j || \ ${INSTALL} -c -m 444 $$j ${DESTDIR}/usr/include/$$i/$$j; \ done); \ done # XXX -cmp -s Makefile.install ${DESTDIR}/usr/include/Makefile || \ # XXX ${INSTALL} -c -m 444 Makefile.install ${DESTDIR}/usr/include/Makefile -for i in ${LINKS}; do \ rm -f ${DESTDIR}/usr/include/$$i; \ ln -s sys/$$i ${DESTDIR}/usr/include/$$i; \ done rm -f ${DESTDIR}/usr/include/machine ln -s ${MACHINE} ${DESTDIR}/usr/include/machine # XXX rm -f ${DESTDIR}/usr/include/frame.h # XXX ln -s machine/frame.h ${DESTDIR}/usr/include/frame.h # XXX symlinks: # XXX -for i in ${SYSDIRS}; do \ # XXX rm -rf ${DESTDIR}/usr/include/$$i; \ # XXX if [ ! -s ${DESTDIR}/usr/include/$$i ]; \ # XXX then \ # XXX ln -s ../../sys/$$i ${DESTDIR}/usr/include/$$i; \ # XXX else \ # XXX echo ${DESTDIR}/usr/include/$$i not removed; \ # XXX fi; \ # XXX done # XXX rm -rf ${DESTDIR}/usr/include/sys # XXX -if [ ! -s ${DESTDIR}/usr/include/sys ]; \ # XXX then \ # XXX ln -s ../../sys/h ${DESTDIR}/usr/include/sys; \ # XXX else \ # XXX echo ${DESTDIR}/usr/include/sys not removed; \ # XXX fi copies: if [ -z "${DESTDIR}" ] || [ "${DESTDIR}" = "/" ]; \ then \ echo "DESTDIR must be set and must not be /"; \ exit 1; \ fi; \ if [ -z "${DESTDIR}" ] || [ "${DESTDIR}" = "${TOPSRC}" ]; \ then \ echo "DESTDIR is same as TOPSRC: skip copying SYSDIRS"; \ else \ if [ ! -d ${DESTDIR}/usr/include ]; \ then \ mkdir ${DESTDIR}/usr/include; \ fi; \ for i in ${SYSDIRS}; do \ rm -rf ${DESTDIR}/usr/include/$$i; \ tar cf - $$i/*.h | \ (cd ${DESTDIR}/usr/include; tar xpf -); \ done; \ rm -rf ${DESTDIR}/usr/include/sys; \ mkdir ${DESTDIR}/usr/include/sys; \ chmod 775 ${DESTDIR}/usr/include/sys; \ (cd ../sys/sys; tar cf - *.h | \ (cd ${DESTDIR}/usr/include/sys; tar xpf -)); \ fi # XXX tags: # XXX cwd=${TOPSRC}/include; \ # XXX for i in ${STD} ${LINKS}; do \ # XXX ctags -a -f ${TAGSFILE} $$cwd/$$i; \ # XXX done clean: rm -f tags ================================================ FILE: include/Makefile.install ================================================ # # Copyright (c) 1983,1986 Regents of the University of California. # All rights reserved. The Berkeley software License Agreement # specifies the terms and conditions for redistribution. # # @(#)Makefile.install 5.3 (Berkeley) 10/13/86 # # Makefile for /usr/include, used to convert system include subdirectories # between symbolic links and copies of kernel headers. # May also be used to update copies from kernel header files. # # The ``rm -rf''s used below are safe because rm doesn't # follow symbolic links. # DESTDIR= #ifdef vax #MACHINE=vax #MACHDEP=${MACHINE} vaxif vaxmba vaxuba #endif MACHINE=pdp MACHDEP=${MACHINE} pdpmba pdpuba stand vaxif vaxuba NETDIRS=net netimp netinet netns netpup SYSDIRS=${NETDIRS} ${MACHDEP} SYS=/sys all: @echo "\"make symlinks\", \"make copies\", or \"make update\" only" @false symlinks: for i in ${SYSDIRS}; do \ rm -rf $$i; \ ln -s ../../${SYS}/$$i $$i; \ done rm -rf sys ln -s ../../${SYS}/h sys copies: -for i in ${SYSDIRS}; do \ rm -rf $$i; \ (cd ${SYS}; tar cf - $$i/*.h) | tar xpfB -; \ done rm -rf sys; mkdir sys; chmod 775 sys; -(cd ${SYS}/h; tar cf - *.h) | (cd sys; tar xpfB -) update: -for i in ${SYSDIRS}; do \ if [ ! -d $$i ]; \ then \ mkdir $$i; \ fi; \ for j in `cd ${SYS}/$$i; echo *.[ih]`; do \ cmp -s ${SYS}/$$i/$$j $$i/$$j || \ install -c -m 444 ${SYS}/$$i/$$j $$i/$$j; \ done; \ done for j in `cd ${SYS}/h; echo *.[ih]`; do \ cmp -s ${SYS}/h/$$j sys/$$j || \ { echo "install -c -m 444 ${SYS}/h/$$j sys/$$j"; \ install -c -m 444 ${SYS}/h/$$j sys/$$j; } \ done; ================================================ FILE: include/a.out.h ================================================ /*- * Copyright (c) 1991 The Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #ifndef _AOUT_H_ #define _AOUT_H_ #include #define _AOUT_INCLUDE_ #include /* Relocations */ struct reloc { unsigned flags; #define RSMASK 0x70 /* bitmask for segments */ #define RABS 0 #define RTEXT 0x20 #define RDATA 0x30 #define RBSS 0x40 #define RSTRNG 0x60 /* for assembler */ #define REXT 0x70 /* externals and bitmask */ #define RGPREL 0x08 /* gp relative */ #define RFMASK 0x07 /* bitmask for format */ #define RBYTE16 0x00 /* low part of byte address: bits 15:0 */ #define RBYTE32 0x01 /* 32-bit byte address */ #define RHIGH16 0x02 /* upper part of byte address: bits 31:16 */ #define RHIGH16S 0x03 /* upper part of address with signed offset */ #define RWORD16 0x04 /* word address: bits 17:2 */ #define RWORD26 0x05 /* word address: bits 27:2 */ unsigned index; /* 24-bit index in symbol table, * for REXT */ unsigned offset; /* 16-bit offset, * for RIGH16 and RIGH16S */ }; #endif /* !_AOUT_H_ */ ================================================ FILE: include/alloca.h ================================================ /* alloca.h - Allocate memory on stack */ #ifndef ALLOCA_H #define ALLOCA_H #undef alloca #ifdef __GNUC__ #define alloca(size) __builtin_alloca(size) #else #include void *alloca(size_t); #endif #endif ================================================ FILE: include/ar.h ================================================ /*- * Copyright (c) 1991 The Regents of the University of California. * All rights reserved. * * This code is derived from software contributed to Berkeley by * Hugh Smith at The University of Guelph. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #ifndef _AR_H_ #define _AR_H_ #define ARMAG "!\n" /* ar "magic number" */ #define SARMAG 8 /* strlen(ARMAG); */ #define AR_EFMT1 "#1/" /* extended format #1 */ struct ar_hdr { char ar_name[16]; /* name */ char ar_date[12]; /* modification time */ char ar_uid[6]; /* user id */ char ar_gid[6]; /* group id */ char ar_mode[8]; /* octal file permissions */ char ar_size[10]; /* size in bytes */ #define ARFMAG "`\n" char ar_fmag[2]; /* consistency check */ }; #define ARHDRSZ 60 #endif /* !_AR_H_ */ ================================================ FILE: include/arpa/inet.h ================================================ /* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the University of California, Berkeley. The name of the * University may not be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ /* * External definitions for * functions in inet(3N) */ struct in_addr; unsigned long inet_addr (char *); char *inet_ntoa (struct in_addr); struct in_addr inet_makeaddr (long, long); unsigned long inet_network (char *); unsigned long inet_netof (struct in_addr); unsigned long inet_lnaof (struct in_addr); /* * Macros for number representation conversion. */ unsigned htonl (unsigned hostlong); unsigned htons (unsigned hostshort); unsigned ntohl (unsigned netlong); unsigned ntohs (unsigned netshort); ================================================ FILE: include/assert.h ================================================ # ifndef NDEBUG # define _assert(ex) {if (!(ex)){fprintf(stderr,"Assertion failed: file \"%s\", line %d\n", __FILE__, __LINE__);exit(1);}} # define assert(ex) _assert(ex) # else # define _assert(ex) # define assert(ex) # endif ================================================ FILE: include/ctype.h ================================================ #define _U 01 #define _L 02 #define _N 04 #define _S 010 #define _P 020 #define _C 040 #define _X 0100 #define _B 0200 extern char _ctype_[]; #define isalpha(c) ((_ctype_+1)[(int)(c)]&(_U|_L)) #define isupper(c) ((_ctype_+1)[(int)(c)]&_U) #define islower(c) ((_ctype_+1)[(int)(c)]&_L) #define isdigit(c) ((_ctype_+1)[(int)(c)]&_N) #define isxdigit(c) ((_ctype_+1)[(int)(c)]&(_N|_X)) #define isspace(c) ((_ctype_+1)[(int)(c)]&_S) #define ispunct(c) ((_ctype_+1)[(int)(c)]&_P) #define isalnum(c) ((_ctype_+1)[(int)(c)]&(_U|_L|_N)) #define isprint(c) ((_ctype_+1)[(int)(c)]&(_P|_U|_L|_N|_B)) #define isgraph(c) ((_ctype_+1)[(int)(c)]&(_P|_U|_L|_N)) #define iscntrl(c) ((_ctype_+1)[(int)(c)]&_C) #define isascii(c) ((unsigned)(c)<=0177) #define toupper(c) ((c)-'a'+'A') #define tolower(c) ((c)-'A'+'a') #define toascii(c) ((c)&0177) ================================================ FILE: include/curses.h ================================================ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #ifndef CURSES_H #include #include #include #define bool int #define TRUE (1) #define FALSE (0) #define ERR (0) #define OK (1) #define _ENDLINE 001 #define _FULLWIN 002 #define _SCROLLWIN 004 #define _FLUSH 010 #define _FULLLINE 020 #define _IDLINE 040 #define _STANDOUT 0200 #define _NOCHANGE -1 #define _puts(s) tputs(s, 0, _putchar) typedef struct sgttyb SGTTY; /* * Capabilities from termcap */ extern bool AM, BS, CA, DA, DB, EO, HC, HZ, IN, MI, MS, NC, NS, OS, UL, XB, XN, XT, XS, XX; extern char *AL, *BC, *BT, *CD, *CE, *CL, *CM, *CR, *CS, *DC, *DL, *DM, *DO, *ED, *EI, *K0, *K1, *K2, *K3, *K4, *K5, *K6, *K7, *K8, *K9, *HO, *IC, *IM, *IP, *KD, *KE, *KH, *KL, *KR, *KS, *KU, *LL, *MA, *ND, *NL, *RC, *SC, *SE, *SF, *SO, *SR, *TA, *TE, *TI, *UC, *UE, *UP, *US, *VB, *VS, *VE, *AL_PARM, *DL_PARM, *UP_PARM, *DOWN_PARM, *LEFT_PARM, *RIGHT_PARM; extern char PC; /* * From the tty modes... */ extern bool GT, NONL, UPPERCASE, normtty, _pfast; struct _win_st { short _cury, _curx; short _maxy, _maxx; short _begy, _begx; short _flags; short _ch_off; bool _clear; bool _leave; bool _scroll; char **_y; short *_firstch; short *_lastch; struct _win_st *_nextp, *_orig; }; #define WINDOW struct _win_st extern bool My_term, _echoit, _rawmode, _endwin; extern char *Def_term, ttytype[]; extern int LINES, COLS, _tty_ch, _res_flg; extern SGTTY _tty; extern WINDOW *stdscr, *curscr; /* * Define VOID to stop lint from generating "null effect" * comments. */ #ifdef lint int __void__; #define VOID(x) (__void__ = (int) (x)) #else #define VOID(x) (x) #endif /* * psuedo functions for standard screen */ #define addch(ch) VOID(waddch(stdscr, ch)) #define getch() VOID(wgetch(stdscr)) #define addstr(str) VOID(waddstr(stdscr, str)) #define getstr(str) VOID(wgetstr(stdscr, str)) #define move(y, x) VOID(wmove(stdscr, y, x)) #define clear() VOID(wclear(stdscr)) #define erase() VOID(werase(stdscr)) #define clrtobot() VOID(wclrtobot(stdscr)) #define clrtoeol() VOID(wclrtoeol(stdscr)) #define insertln() VOID(winsertln(stdscr)) #define deleteln() VOID(wdeleteln(stdscr)) #define refresh() VOID(wrefresh(stdscr)) #define inch() VOID(winch(stdscr)) #define insch(c) VOID(winsch(stdscr,c)) #define delch() VOID(wdelch(stdscr)) #define standout() VOID(wstandout(stdscr)) #define standend() VOID(wstandend(stdscr)) /* * mv functions */ #define mvwaddch(win,y,x,ch) VOID(wmove(win,y,x)==ERR?ERR:waddch(win,ch)) #define mvwgetch(win,y,x) VOID(wmove(win,y,x)==ERR?ERR:wgetch(win)) #define mvwaddstr(win,y,x,str) VOID(wmove(win,y,x)==ERR?ERR:waddstr(win,str)) #define mvwgetstr(win,y,x,str) VOID(wmove(win,y,x)==ERR?ERR:wgetstr(win,str)) #define mvwinch(win,y,x) VOID(wmove(win,y,x) == ERR ? ERR : winch(win)) #define mvwdelch(win,y,x) VOID(wmove(win,y,x) == ERR ? ERR : wdelch(win)) #define mvwinsch(win,y,x,c) VOID(wmove(win,y,x) == ERR ? ERR:winsch(win,c)) #define mvaddch(y,x,ch) mvwaddch(stdscr,y,x,ch) #define mvgetch(y,x) mvwgetch(stdscr,y,x) #define mvaddstr(y,x,str) mvwaddstr(stdscr,y,x,str) #define mvgetstr(y,x,str) mvwgetstr(stdscr,y,x,str) #define mvinch(y,x) mvwinch(stdscr,y,x) #define mvdelch(y,x) mvwdelch(stdscr,y,x) #define mvinsch(y,x,c) mvwinsch(stdscr,y,x,c) /* * psuedo functions */ #define clearok(win,bf) (win->_clear = bf) #define leaveok(win,bf) (win->_leave = bf) #define scrollok(win,bf) (win->_scroll = bf) #define flushok(win,bf) (bf ? (win->_flags |= _FLUSH):(win->_flags &= ~_FLUSH)) #define getyx(win,y,x) y = win->_cury, x = win->_curx #define winch(win) (win->_y[win->_cury][win->_curx] & 0177) #define raw() (_tty.sg_flags|=RAW, _pfast=_rawmode=TRUE, ioctl(_tty_ch,TIOCSETP,&_tty)) #define noraw() (_tty.sg_flags&=~RAW,_rawmode=FALSE,_pfast=!(_tty.sg_flags&CRMOD),ioctl(_tty_ch,TIOCSETP,&_tty)) #define cbreak() (_tty.sg_flags |= CBREAK, _rawmode = TRUE, ioctl(_tty_ch,TIOCSETP,&_tty)) #define nocbreak() (_tty.sg_flags &= ~CBREAK,_rawmode=FALSE,ioctl(_tty_ch,TIOCSETP,&_tty)) #define crmode() cbreak() /* backwards compatability */ #define nocrmode() nocbreak() /* backwards compatability */ #define echo() (_tty.sg_flags |= ECHO, _echoit = TRUE, ioctl(_tty_ch, TIOCSETP, &_tty)) #define noecho() (_tty.sg_flags &= ~ECHO, _echoit = FALSE, ioctl(_tty_ch, TIOCSETP, &_tty)) #define nl() (_tty.sg_flags |= CRMOD, _pfast = _rawmode,ioctl(_tty_ch, TIOCSETP, &_tty)) #define nonl() (_tty.sg_flags &= ~CRMOD,_pfast = TRUE, ioctl(_tty_ch, TIOCSETP,&_tty)) #define savetty() ((void) ioctl(_tty_ch, TIOCGETP, &_tty), _res_flg = _tty.sg_flags) #define resetty() (_tty.sg_flags = _res_flg, (void) ioctl(_tty_ch, TIOCSETP, &_tty)) #define erasechar() (_tty.sg_erase) #define killchar() (_tty.sg_kill) #define baudrate() (_tty.sg_ospeed) WINDOW *initscr(), *newwin(), *subwin(); char *longname(), *getcap(); int wmove (WINDOW *, int, int); int wrefresh (WINDOW *); int wclear (WINDOW *); int waddch (WINDOW *, char); int wgetch (WINDOW *); char *wstandout (WINDOW *); char *wstandend (WINDOW *); int touchwin (WINDOW *); int touchline (WINDOW *, int, int, int); void box (WINDOW *, char, char); void endwin (void); int printw (char *, ...); int wprintw (WINDOW *, char *, ...); int scroll (WINDOW *); void wclrtoeol (WINDOW *); void werase (WINDOW *); int setterm (char *); int delwin (WINDOW *); int waddstr (WINDOW *, char *); int wgetstr (WINDOW *, char *); int wdeleteln (WINDOW *); void mvcur(int ly, int lx, int y, int x); void overwrite(WINDOW *win1, WINDOW *win2); void wclrtobot(WINDOW *win); int mvprintw(int y, int x, char *fmt, ...); int mvwprintw(WINDOW *win, int y, int x, char *fmt, ...); /* * Used to be in unctrl.h. */ #define unctrl(c) _unctrl[(c) & 0177] extern char *_unctrl[]; #endif ================================================ FILE: include/fcntl.h ================================================ /*- * Copyright (c) 1983, 1990, 1993 * The Regents of the University of California. All rights reserved. * (c) UNIX System Laboratories, Inc. * All or some portions of this file are derived from material licensed * to the University of California by American Telephone and Telegraph * Co. or Unix System Laboratories, Inc. and are reproduced herein with * the permission of UNIX System Laboratories, Inc. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)fcntl.h 8.3.1 (2.11BSD GTE) 11/25/94 * * Copied from 4.4-Lite and modified for 2.11BSD. The modifications consisted * of removing: function prototypes (I don't like them, the compiler does not * support them, and it would mean dragging in cdefs.h to leave them in here), * #ifndef _POSIX_SOURCE lines (silly) and record locking related definitions * If anyone adds any of the above it will be easy enough to modify this file. * In the meantime why bog down (or blow up) cpp any further? */ #include int open (const char *path, int oflag, ...); int creat (const char *path, mode_t mode); int fcntl (int fildes, int cmd, ...); ================================================ FILE: include/float.h ================================================ #ifndef _FLOAT_H_ #define _FLOAT_H_ #include #endif /* _FLOAT_H_ */ ================================================ FILE: include/fstab.h ================================================ /* * Copyright (c) 1980, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)fstab.h 8.1.1 (2.11BSD) 1996/1/15 */ #ifndef _FSTAB_H_ #define _FSTAB_H_ /* * File system table, see fstab(5). * * Used by dump, mount, umount, swapon, fsck, df, ... * * For ufs fs_spec field is the block special name. Programs that want to * use the character special name must create that name by prepending a 'r' * after the right most slash. Quota files are always named "quotas", so * if type is "rq", then use concatenation of fs_file and "quotas" to locate * quota file. */ #define FSTAB_RW "rw" /* read/write device */ #define FSTAB_RQ "rq" /* read/write with quotas */ #define FSTAB_RO "ro" /* read-only device */ #define FSTAB_SW "sw" /* swap device */ #define FSTAB_XX "xx" /* ignore totally */ struct fstab { char *fs_spec; /* block special device name */ char *fs_file; /* file system path prefix */ char *fs_vfstype; /* File system type, ufs, nfs */ char *fs_mntops; /* Mount options ala -o */ char *fs_type; /* FSTAB_* from fs_mntops */ int fs_freq; /* dump frequency, in days */ int fs_passno; /* pass number on parallel dump */ }; struct fstab *getfsent(); struct fstab *getfsspec(); struct fstab *getfsfile(); int setfsent(); void endfsent(); #endif /* !_FSTAB_H_ */ ================================================ FILE: include/grp.h ================================================ /* grp.h 4.1 83/05/03 */ struct group { /* see getgrent(3) */ char *gr_name; char *gr_passwd; int gr_gid; char **gr_mem; }; struct group *getgrent(void); struct group *getgrnam(const char *name); struct group *getgrgid(gid_t gid); void setgrent(void); void endgrent(void); int setgroups(size_t size, const gid_t *list); ================================================ FILE: include/kmem.h ================================================ #ifndef _KMEM_H #define _KMEM_H extern dev_t kmemdev(); #endif ================================================ FILE: include/lastlog.h ================================================ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * * @(#)lastlog.h 5.1 (Berkeley) 5/30/85 */ struct lastlog { time_t ll_time; char ll_line[8]; char ll_host[16]; /* same as in utmp */ }; ================================================ FILE: include/libgen.h ================================================ /* $OpenBSD: libgen.h,v 1.10 2020/10/20 19:30:14 naddy Exp $ */ /* * Copyright (c) 1997 Todd C. Miller * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #ifndef _LIBGEN_H_ #define _LIBGEN_H_ char *basename(char *); char *dirname(char *); #endif /* _LIBGEN_H_ */ ================================================ FILE: include/limits.h ================================================ /* * Copyright (c) 1988, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)limits.h 8.2.1 (2.11BSD) 1996/1/11 */ #ifndef _LIMITS_H_ #define _LIMITS_H_ #include #include #endif /* !_LIMITS_H_ */ ================================================ FILE: include/math.h ================================================ /* * Copyright (c) 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ double fabs(double), floor(double), ceil(double); double sqrt(double), hypot(double, double); double sin(double), cos(double), tan(double); double asin(double), acos(double), atan(double), atan2(double, double); double exp(double), log(double), log10(double), pow(double, double); double sinh(double), cosh(double), tanh(double); double j0(double), j1(double), jn(int, double); double y0(double), y1(double), yn(int, double); #define HUGE_VAL 3.40282347e+38 /* TBD??? use infinity? */ int isnanf(float x); int isnan(double x); int isinff(float x); int isinf(double x); float modff(float x, float *iptr); double modf(double x, double *iptr); float frexpf(float x, int *exp); double frexp(double x, int *exp); float ldexpf(float x, int exp); double ldexp(double x, int exp); double fmod(double x, double y); #if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE) #define M_E 2.7182818284590452354 /* e */ #define M_LOG2E 1.4426950408889634074 /* log 2e */ #define M_LOG10E 0.43429448190325182765 /* log 10e */ #define M_LN2 0.69314718055994530942 /* log e2 */ #define M_LN10 2.30258509299404568402 /* log e10 */ #define M_PI 3.14159265358979323846 /* pi */ #define M_PI_2 1.57079632679489661923 /* pi/2 */ #define M_PI_4 0.78539816339744830962 /* pi/4 */ #define M_1_PI 0.31830988618379067154 /* 1/pi */ #define M_2_PI 0.63661977236758134308 /* 2/pi */ #define M_2_SQRTPI 1.12837916709551257390 /* 2/sqrt(pi) */ #define M_SQRT2 1.41421356237309504880 /* sqrt(2) */ #define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */ #endif /* !_ANSI_SOURCE && !_POSIX_SOURCE */ ================================================ FILE: include/mtab.h ================================================ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * * @(#)mtab.h 5.1 (Berkeley) 5/30/85 */ /* * Mounted device accounting file. */ struct mtab { char m_path[32]; /* mounted on pathname */ char m_dname[32]; /* block device pathname */ char m_type[4]; /* read-only, quotas */ }; ================================================ FILE: include/ndbm.h ================================================ /* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * * @(#)ndbm.h 5.1.1 (2.11BSD GTE) 12/31/93 */ /* * Hashed key data base library. */ #define PBLKSIZ 1024 #define DBLKSIZ 1024 typedef struct { int dbm_dirf; /* open directory file */ int dbm_pagf; /* open page file */ int dbm_flags; /* flags, see below */ long dbm_maxbno; /* last ``bit'' in dir file */ long dbm_bitno; /* current bit number */ long dbm_hmask; /* hash mask */ long dbm_blkptr; /* current block for dbm_nextkey */ int dbm_keyptr; /* current key for dbm_nextkey */ long dbm_blkno; /* current page to read/write */ long dbm_pagbno; /* current page in pagbuf */ char dbm_pagbuf[PBLKSIZ]; /* page file block buffer */ long dbm_dirbno; /* current block in dirbuf */ char dbm_dirbuf[DBLKSIZ]; /* directory file block buffer */ } DBM; #define _DBM_RDONLY 0x1 /* data base open read-only */ #define _DBM_IOERR 0x2 /* data base I/O error */ #define dbm_rdonly(db) ((db)->dbm_flags & _DBM_RDONLY) #define dbm_error(db) ((db)->dbm_flags & _DBM_IOERR) /* use this one at your own risk! */ #define dbm_clearerr(db) ((db)->dbm_flags &= ~_DBM_IOERR) /* for flock(2) and fstat(2) */ #define dbm_dirfno(db) ((db)->dbm_dirf) #define dbm_pagfno(db) ((db)->dbm_pagf) typedef struct { char *dptr; int dsize; } datum; /* * flags to dbm_store() */ #define DBM_INSERT 0 #define DBM_REPLACE 1 DBM *dbm_open(); void dbm_close(); datum dbm_fetch(); datum dbm_firstkey(); datum dbm_nextkey(); long dbm_forder(); int dbm_delete(); int dbm_store(); ================================================ FILE: include/netinet/in.h ================================================ /* * Copyright (c) 1982, 1986 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that this notice is preserved and that due credit is given * to the University of California at Berkeley. The name of the University * may not be used to endorse or promote products derived from this * software without specific prior written permission. This software * is provided ``as is'' without express or implied warranty. */ /* * Constants and structures defined by the internet system, * Per RFC 790, September 1981. */ /* * Protocols */ #define IPPROTO_IP 0 /* dummy for IP */ #define IPPROTO_ICMP 1 /* control message protocol */ #define IPPROTO_GGP 3 /* gateway^2 (deprecated) */ #define IPPROTO_TCP 6 /* tcp */ #define IPPROTO_EGP 8 /* exterior gateway protocol */ #define IPPROTO_PUP 12 /* pup */ #define IPPROTO_UDP 17 /* user datagram protocol */ #define IPPROTO_IDP 22 /* xns idp */ #define IPPROTO_RAW 255 /* raw IP packet */ #define IPPROTO_MAX 256 /* * Ports < IPPORT_RESERVED are reserved for * privileged processes (e.g. root). * Ports > IPPORT_USERRESERVED are reserved * for servers, not necessarily privileged. */ #define IPPORT_RESERVED 1024 #define IPPORT_USERRESERVED 5000 /* * Link numbers */ #define IMPLINK_IP 155 #define IMPLINK_LOWEXPER 156 #define IMPLINK_HIGHEXPER 158 /* * Internet address (a structure for historical reasons) */ struct in_addr { u_long s_addr; }; /* * Definitions of bits in internet address integers. * On subnets, the decomposition of addresses to host and net parts * is done according to subnet mask, not the masks here. */ #define IN_CLASSA(i) (((long)(i) & 0x80000000L) == 0) #define IN_CLASSA_NET 0xff000000L #define IN_CLASSA_NSHIFT 24 #define IN_CLASSA_HOST 0x00ffffffL #define IN_CLASSA_MAX 128 #define IN_CLASSB(i) (((long)(i) & 0xc0000000L) == 0x80000000L) #define IN_CLASSB_NET 0xffff0000L #define IN_CLASSB_NSHIFT 16 #define IN_CLASSB_HOST 0x0000ffffL #define IN_CLASSB_MAX 65536 #define IN_CLASSC(i) (((long)(i) & 0xe0000000L) == 0xc0000000L) #define IN_CLASSC_NET 0xffffff00L #define IN_CLASSC_NSHIFT 8 #define IN_CLASSC_HOST 0x000000ffL #define IN_CLASSD(i) (((long)(i) & 0xf0000000L) == 0xe0000000L) #define IN_MULTICAST(i) IN_CLASSD(i) #define IN_EXPERIMENTAL(i) (((long)(i) & 0xe0000000L) == 0xe0000000L) #define IN_BADCLASS(i) (((long)(i) & 0xf0000000L) == 0xf0000000L) #define INADDR_ANY 0x00000000L #define INADDR_BROADCAST 0xffffffffL /* must be masked */ #ifndef KERNEL #define INADDR_NONE 0xffffffffL /* -1 return */ #endif #define IN_LOOPBACKNET 127 /* official! */ /* * Socket address, internet style. */ struct sockaddr_in { short sin_family; u_short sin_port; struct in_addr sin_addr; char sin_zero[8]; }; /* * Options for use with [gs]etsockopt at the IP level. */ #define IP_OPTIONS 1 /* set/get IP per-packet options */ /* * Definitions for inet sysctl operations. * * Third level is protocol number. * Fourth level is desired variable within that protocol. */ #define IPPROTO_MAXID (IPPROTO_IDP + 1) /* don't list to IPPROTO_MAX */ #ifndef KERNEL #define CTL_IPPROTO_NAMES { \ { "ip", CTLTYPE_NODE }, \ { "icmp", CTLTYPE_NODE }, \ { "igmp", CTLTYPE_NODE }, \ { 0, 0 }, \ { 0, 0 }, \ { 0, 0 }, \ { "tcp", CTLTYPE_NODE }, \ { 0, 0 }, \ { 0, 0 }, \ { 0, 0 }, \ { 0, 0 }, \ { 0, 0 }, \ { 0, 0 }, \ { 0, 0 }, \ { 0, 0 }, \ { 0, 0 }, \ { 0, 0 }, \ { "udp", CTLTYPE_NODE }, \ { 0, 0 }, \ { 0, 0 }, \ { 0, 0 }, \ { 0, 0 }, \ { "idp", CTLTYPE_NODE }, \ } #endif /* KERNEL */ /* * Names for IP sysctl objects */ #define IPCTL_FORWARDING 1 /* act as router */ #define IPCTL_SENDREDIRECTS 2 /* may send redirects when forwarding */ #define IPCTL_DEFTTL 3 /* default TTL */ #ifdef notyet #define IPCTL_DEFMTU 4 /* default MTU */ #endif #define IPCTL_FORWSRCRT 5 /* forward source-routed dgrams */ #define IPCTL_MAXID 6 #ifndef KERNEL #define IPCTL_NAMES { \ { 0, 0 }, \ { "forwarding", CTLTYPE_INT }, \ { "redirect", CTLTYPE_INT }, \ { "ttl", CTLTYPE_INT }, \ { "mtu", CTLTYPE_INT }, \ { "forwsrcrt", CTLTYPE_INT }, \ } #endif /* KERNEL */ ================================================ FILE: include/nlist.h ================================================ /*- * Copyright (c) 1991 The Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #ifndef _NLIST_H_ #define _NLIST_H_ #include /* * Symbol table entry format. */ struct nlist { char *n_name; /* In memory address of symbol name, * or string table offset (file) */ u_short n_len; /* Length of name in bytes */ u_short n_type; /* Type of symbol - see below */ u_int n_value; /* Symbol value */ }; /* * Simple values for n_type. */ #define N_UNDF 0x00 /* undefined */ #define N_ABS 0x01 /* absolute */ #define N_TEXT 0x02 /* text segment */ #define N_DATA 0x03 /* data segment */ #define N_BSS 0x04 /* bss segment */ #define N_STRNG 0x05 /* string segment (for assembler) */ #define N_COMM 0x06 /* .comm segment (for assembler) */ #define N_FN 0x1f /* file name */ #define N_TYPE 0x1f /* mask for all the type bits */ #define N_EXT 0x20 /* external (global) bit, OR'ed in */ #define N_WEAK 0x40 /* weak reference bit, OR'ed in */ #define N_LOC 0x80 /* local, for assembler */ /* * Get symbols from a file. */ int nlist (char *name, struct nlist *list); /* * Get kernel symbols. */ int knlist (struct nlist *list); #endif /* !_NLIST_H_ */ ================================================ FILE: include/paths.h ================================================ /* * Copyright (c) 1989 The Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the University of California, Berkeley. The name of the * University may not be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #define _PATH_BSHELL "/bin/sh" #define _PATH_CSHELL "/bin/csh" #define _PATH_CP "/bin/cp" #define _PATH_ECHO "/bin/echo" #define _PATH_MORE "/usr/bin/more" #define _PATH_RSH "/bin/rsh" #define _PATH_VI "/usr/bin/vi" #define _PATH_CORE "/core" #define _PATH_DEV "/dev/" #define _PATH_CONSOLE "/dev/console" #define _PATH_LOG "/dev/log" #define _PATH_DEVNULL "/dev/null" #define _PATH_TTY "/dev/tty" #define _PATH_MEM "/dev/mem" #define _PATH_SWAP "/dev/swap" #define _PATH_FSTAB "/etc/fstab" #define _PATH_LOCALTIME "/etc/localtime" #define _PATH_MOTD "/etc/motd" #define _PATH_NOLOGIN "/etc/nologin" #define _PATH_PASSWD "/etc/passwd" #define _PATH_PTMP "/etc/ptmp" #define _PATH_SHADOW "/etc/shadow" #define _PATH_TERMCAP "/etc/termcap" #define _PATH_USRLIB "/usr/lib/" #define _PATH_CTIMED "/usr/libexec/ctimed" #define _PATH_LOCALLIB "/local/lib/" #define _PATH_SBIN "/sbin/" #define _PATH_USRSBIN "/usr/sbin/" #define _PATH_MKPASSWD "/usr/sbin/mkpasswd" #define _PATH_SENDMAIL "/sbin/sendmail" #define _PATH_SHARE "/usr/share/" #define _PATH_ZONEINFO "/usr/share/zoneinfo" /* Time zone object file directory */ #define _PATH_TMP "/tmp/" #define _PATH_USRTMP "/tmp/" #define _PATH_LASTLOG "/var/log/lastlog" #define _PATH_MESSAGES "/var/log/messages" #define _PATH_WTMP "/var/log/wtmp" #define _PATH_MAIL "/var/mail/" #define _PATH_VARRUN "/var/run/" #define _PATH_DEVDB "/var/run/dev" #define _PATH_UTMP "/var/run/utmp" #define _PATH_ARTMP "/tmp/ar.XXXXXX" #define _PATH_RANTMP "/tmp/ranlib.XXXXXX" #define _PATH_STDPATH "/usr/bin:/bin:/usr/sbin:/sbin" #define _PATH_SYSPATH "/usr/bin:/bin:/usr/sbin:/sbin:/local" #define _PATH_MAN "/usr/share/man" #define _PATH_LOCALMAN "/local/man" #define _PATH_HUSHLOGIN ".hushlogin" ================================================ FILE: include/psout.h ================================================ /* * Copyright (c) 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ /* * psout: structure output by 'ps -U'. * Mostly the pre-processed /dev directory. */ #ifndef makedev #include #endif struct psout { dev_t o_ttyd; /* u_ttyd */ int o_flag; /* p_flag */ short o_pid; /* p_pid */ char o_tty[3]; /* 1st 2 chars of tty after 'tty' */ char o_stat; /* p_stat */ short o_uid; /* p_uid */ char o_uname[UT_NAMESIZE]; /* login name of process owner */ short o_ppid; /* p_ppid */ char o_cpu; /* p_cpu */ char o_pri; /* p_pri */ char o_nice; /* p_nice */ short o_addr0; /* p_addr[0] */ short o_size; /* p_size */ caddr_t o_wchan; /* p_wchan */ time_t o_utime; /* u_utime */ time_t o_stime; /* u_stime */ time_t o_cutime; /* u_cutime */ time_t o_cstime; /* u_cstime */ short o_pgrp; /* p_pgrp */ int o_sigs; /* sum of SIGINT & SIGQUIT, * if == 2 proc is ignoring both.*/ char o_comm[MAXCOMLEN+1]; /* u_comm */ char o_args[64]; /* best guess at args to process */ }; ================================================ FILE: include/pwd.h ================================================ /* * Copyright (c) 1988 The Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the University of California, Berkeley. The name of the * University may not be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #define _PW_KEYBYNAME '0' #define _PW_KEYBYUID '1' struct passwd { char *pw_name; /* user name */ char *pw_passwd; /* encrypted password */ int pw_uid; /* user uid */ int pw_gid; /* user gid */ char *pw_gecos; /* real name */ char *pw_dir; /* home directory */ char *pw_shell; /* default shell */ }; struct passwd *getpwent(), *getpwuid(), *getpwnam(); void endpwent(), setpwfile(); int setpwent(); int setpassent (int); ================================================ FILE: include/ranlib.h ================================================ /*- * Copyright (c) 1990 The Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #ifndef _RANLIB_H_ #define _RANLIB_H_ #define RANLIBMAG "__.SYMDEF" /* archive file name */ #define RANLIBSKEW 3 /* creation time offset */ struct ranlib { int ran_len; /* 1 byte - name length in bytes */ unsigned ran_off; /* 4 bytes - file offset */ char *ran_name; /* in memory symbol name */ }; #endif /* !_RANLIB_H_ */ ================================================ FILE: include/regexp.h ================================================ /* * Definitions etc. for regexp(3) routines. * * Caveat: this is V8 regexp(3) [actually, a reimplementation thereof], * not the System V one. */ #define NSUBEXP 10 typedef struct regexp { char *startp[NSUBEXP]; char *endp[NSUBEXP]; char regstart; /* Internal use only. */ char reganch; /* Internal use only. */ char *regmust; /* Internal use only. */ int regmlen; /* Internal use only. */ char program[1]; /* Unwarranted chumminess with compiler. */ } regexp; extern regexp *regcomp(); extern int regexec(); extern void regsub(); extern void regerror(); ================================================ FILE: include/setjmp.h ================================================ #ifndef _SETJMP_H #define _SETJMP_H #include typedef int jmp_buf[_JBLEN]; typedef jmp_buf sigjmp_buf; /* * Save and restore only CPU state. * Signal mask is not saved. */ int _setjmp (jmp_buf env); void _longjmp (jmp_buf env, int val); /* * Save and restore CPU state and signal mask. */ int setjmp (jmp_buf env); void longjmp (jmp_buf env, int val); /* * Save and restore CPU state and optionally a signal mask. * Signal mask is saved only when savesigs is nonzero. */ int sigsetjmp (sigjmp_buf env, int savesigs); void siglongjmp (sigjmp_buf env, int val); #endif /* !_SETJMP_H */ ================================================ FILE: include/sgtty.h ================================================ /* sgtty.h 4.2 85/01/03 */ #ifndef _IOCTL_ #include #endif ================================================ FILE: include/smallc/curses.h ================================================ /* * SmallC: interface to curses library. */ #define WINDOW int extern WINDOW *stdscr, *curscr; extern int LINES, COLS; /* * pseudo functions for standard screen */ #define addch(ch) waddch(stdscr, ch) #define getch() wgetch(stdscr) #define addstr(str) waddstr(stdscr, str) #define getstr(str) wgetstr(stdscr, str) #define move(y, x) wmove(stdscr, y, x) #define clear() wclear(stdscr) #define erase() werase(stdscr) #define clrtobot() wclrtobot(stdscr) #define clrtoeol() wclrtoeol(stdscr) #define insertln() winsertln(stdscr) #define deleteln() wdeleteln(stdscr) #define refresh() wrefresh(stdscr) #define inch() winch(stdscr) #define insch(c) winsch(stdscr,c) #define delch() wdelch(stdscr) #define standout() wstandout(stdscr) #define standend() wstandend(stdscr) /* * mv functions */ #define mvwaddch(win,y,x,ch) wmove(win,y,x) == 0 ? 0 : waddch(win,ch) #define mvwgetch(win,y,x) wmove(win,y,x) == 0 ? 0 : wgetch(win) #define mvwaddstr(win,y,x,str) wmove(win,y,x) == 0 ? 0 : waddstr(win,str) #define mvwgetstr(win,y,x,str) wmove(win,y,x) == 0 ? 0 : wgetstr(win,str) #define mvwinch(win,y,x) wmove(win,y,x) == 0 ? 0 : winch(win) #define mvwdelch(win,y,x) wmove(win,y,x) == 0 ? 0 : wdelch(win) #define mvwinsch(win,y,x,c) wmove(win,y,x) == 0 ? 0 : winsch(win,c) #define mvaddch(y,x,ch) mvwaddch(stdscr,y,x,ch) #define mvgetch(y,x) mvwgetch(stdscr,y,x) #define mvaddstr(y,x,str) mvwaddstr(stdscr,y,x,str) #define mvgetstr(y,x,str) mvwgetstr(stdscr,y,x,str) #define mvinch(y,x) mvwinch(stdscr,y,x) #define mvdelch(y,x) mvwdelch(stdscr,y,x) #define mvinsch(y,x,c) mvwinsch(stdscr,y,x,c) #ifdef TODO #define TRUE (1) #define FALSE (0) #define ERR (0) #define OK (1) /* * Capabilities from termcap */ extern int AM, BS, CA, DA, DB, EO, HC, HZ, IN, MI, MS, NC, NS, OS, UL, XB, XN, XT, XS, XX; extern char *AL, *BC, *BT, *CD, *CE, *CL, *CM, *CR, *CS, *DC, *DL, *DM, *DO, *ED, *EI, *K0, *K1, *K2, *K3, *K4, *K5, *K6, *K7, *K8, *K9, *HO, *IC, *IM, *IP, *KD, *KE, *KH, *KL, *KR, *KS, *KU, *LL, *MA, *ND, *NL, *RC, *SC, *SE, *SF, *SO, *SR, *TA, *TE, *TI, *UC, *UE, *UP, *US, *VB, *VS, *VE, *AL_PARM, *DL_PARM, *UP_PARM, *DOWN_PARM, *LEFT_PARM, *RIGHT_PARM; extern char PC; /* * From the tty modes... */ extern int GT, NONL, UPPERCASE, normtty, _pfast; extern int My_term, _echoit, _rawmode, _endwin; extern char *Def_term, ttytype[]; extern int _tty_ch, _res_flg; extern SGTTY _tty; /* * pseudo functions */ #define clearok(win,bf) (win->_clear = bf) #define leaveok(win,bf) (win->_leave = bf) #define scrollok(win,bf) (win->_scroll = bf) #define flushok(win,bf) (bf ? (win->_flags |= _FLUSH):(win->_flags &= ~_FLUSH)) #define getyx(win,y,x) y = win->_cury, x = win->_curx #define winch(win) (win->_y[win->_cury][win->_curx] & 0177) #define raw() (_tty.sg_flags|=RAW, _pfast=_rawmode=TRUE, ioctl(_tty_ch,TIOCSETP,&_tty)) #define noraw() (_tty.sg_flags&=~RAW,_rawmode=FALSE,_pfast=!(_tty.sg_flags&CRMOD),ioctl(_tty_ch,TIOCSETP,&_tty)) #define cbreak() (_tty.sg_flags |= CBREAK, _rawmode = TRUE, ioctl(_tty_ch,TIOCSETP,&_tty)) #define nocbreak() (_tty.sg_flags &= ~CBREAK,_rawmode=FALSE,ioctl(_tty_ch,TIOCSETP,&_tty)) #define echo() (_tty.sg_flags |= ECHO, _echoit = TRUE, ioctl(_tty_ch, TIOCSETP, &_tty)) #define noecho() (_tty.sg_flags &= ~ECHO, _echoit = FALSE, ioctl(_tty_ch, TIOCSETP, &_tty)) #define nl() (_tty.sg_flags |= CRMOD, _pfast = _rawmode,ioctl(_tty_ch, TIOCSETP, &_tty)) #define nonl() (_tty.sg_flags &= ~CRMOD,_pfast = TRUE, ioctl(_tty_ch, TIOCSETP,&_tty)) #define savetty() ((void) ioctl(_tty_ch, TIOCGETP, &_tty), _res_flg = _tty.sg_flags) #define resetty() (_tty.sg_flags = _res_flg, (void) ioctl(_tty_ch, TIOCSETP, &_tty)) #define erasechar() (_tty.sg_erase) #define killchar() (_tty.sg_kill) #define baudrate() (_tty.sg_ospeed) /* * Used to be in unctrl.h. */ #define unctrl(c) _unctrl[(c) & 0177] extern char *_unctrl[]; #endif ================================================ FILE: include/smallc/fcntl.h ================================================ /* open-only flags */ #define O_RDONLY 0x0000 /* open for reading only */ #define O_WRONLY 0x0001 /* open for writing only */ #define O_RDWR 0x0002 /* open for reading and writing */ #define O_ACCMODE 0x0003 /* mask for above modes */ #define O_NONBLOCK 0x0004 /* no delay */ #define O_APPEND 0x0008 /* set append mode */ #define O_SHLOCK 0x0010 /* open with shared file lock */ #define O_EXLOCK 0x0020 /* open with exclusive file lock */ #define O_ASYNC 0x0040 /* signal pgrp when data ready */ #define O_FSYNC 0x0080 /* synchronous writes */ #define O_CREAT 0x0200 /* create if nonexistant */ #define O_TRUNC 0x0400 /* truncate to zero length */ #define O_EXCL 0x0800 /* error if already exists */ /* * Constants used for fcntl(2) */ /* command values */ #define F_DUPFD 0 /* duplicate file descriptor */ #define F_GETFD 1 /* get file descriptor flags */ #define F_SETFD 2 /* set file descriptor flags */ #define F_GETFL 3 /* get file status flags */ #define F_SETFL 4 /* set file status flags */ #define F_GETOWN 5 /* get SIGIO/SIGURG proc/pgrp */ #define F_SETOWN 6 /* set SIGIO/SIGURG proc/pgrp */ /* file descriptor flags (F_GETFD, F_SETFD) */ #define FD_CLOEXEC 1 /* close-on-exec flag */ /* lock operations for flock() */ #define LOCK_SH 1 /* shared file lock */ #define LOCK_EX 2 /* exclusive file lock */ #define LOCK_NB 4 /* don't block when locking */ #define LOCK_UN 8 /* unlock file */ ================================================ FILE: include/smallc/signal.h ================================================ /* * Copyright (c) 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #ifndef NSIG #define NSIG 32 #define SIGHUP 1 /* hangup */ #define SIGINT 2 /* interrupt */ #define SIGQUIT 3 /* quit */ #define SIGILL 4 /* illegal instruction (not reset when caught) */ #define SIGTRAP 5 /* trace trap (not reset when caught) */ #define SIGIOT 6 /* IOT instruction */ #define SIGABRT SIGIOT /* compatibility */ #define SIGEMT 7 /* EMT instruction */ #define SIGFPE 8 /* floating point exception */ #define SIGKILL 9 /* kill (cannot be caught or ignored) */ #define SIGBUS 10 /* bus error */ #define SIGSEGV 11 /* segmentation violation */ #define SIGSYS 12 /* bad argument to system call */ #define SIGPIPE 13 /* write on a pipe with no one to read it */ #define SIGALRM 14 /* alarm clock */ #define SIGTERM 15 /* software termination signal from kill */ #define SIGURG 16 /* urgent condition on IO channel */ #define SIGSTOP 17 /* sendable stop signal not from tty */ #define SIGTSTP 18 /* stop signal from tty */ #define SIGCONT 19 /* continue a stopped process */ #define SIGCHLD 20 /* to parent on child stop or exit */ #define SIGCLD SIGCHLD /* compatibility */ #define SIGTTIN 21 /* to readers pgrp upon background tty read */ #define SIGTTOU 22 /* like TTIN for output if (tp->t_local<OSTOP) */ #define SIGIO 23 /* input/output possible signal */ #define SIGXCPU 24 /* exceeded CPU time limit */ #define SIGXFSZ 25 /* exceeded file size limit */ #define SIGVTALRM 26 /* virtual time alarm */ #define SIGPROF 27 /* profiling time alarm */ #define SIGWINCH 28 /* window size changes */ #define SIGUSR1 30 /* user defined signal 1 */ #define SIGUSR2 31 /* user defined signal 2 */ #define SIG_ERR -1 #define SIG_DFL 0 #define SIG_IGN 1 #define BADSIG SIG_ERR #define SA_ONSTACK 0x0001 /* take signal on signal stack */ #define SA_RESTART 0x0002 /* restart system on signal return */ #define SA_DISABLE 0x0004 /* disable taking signals on alternate stack */ #define SA_NOCLDSTOP 0x0008 /* do not generate SIGCHLD on child stop */ /* * Flags for sigprocmask: */ #define SIG_BLOCK 1 /* block specified signal set */ #define SIG_UNBLOCK 2 /* unblock specified signal set */ #define SIG_SETMASK 3 /* set specified signal set */ #define MINSIGSTKSZ 128 /* minimum allowable stack */ #define SIGSTKSZ (MINSIGSTKSZ + 384) /* recommended stack size */ #define SV_ONSTACK SA_ONSTACK /* take signal on signal stack */ #define SV_INTERRUPT SA_RESTART /* same bit, opposite sense */ /* * Macro for converting signal number to a mask suitable for * sigblock(). */ #define sigmask(m) (1L << ((m)-1)) #define sigaddset(set, signo) (*(set) |= 1L << ((signo) - 1), 0) #define sigdelset(set, signo) (*(set) &= ~(1L << ((signo) - 1)), 0) #define sigemptyset(set) (*(set) = (sigset_t)0, (int)0) #define sigfillset(set) (*(set) = ~(sigset_t)0, (int)0) #define sigismember(set, signo) ((*(set) & (1L << ((signo) - 1))) != 0) #endif /* NSIG */ ================================================ FILE: include/smallc/stdio.h ================================================ /* * SmallC: interface to stdio library. */ #define BUFSIZ 1024 #ifndef NULL #define NULL 0 #endif #define FILE int #define EOF (-1) extern int _iob[]; #define stdin (&_iob[0]) #define stdout (&_iob[5]) #define stderr (&_iob[10]) #define SEEK_SET 0 /* set file offset to offset */ #define SEEK_CUR 1 /* set file offset to current plus offset */ #define SEEK_END 2 /* set file offset to EOF plus offset */ #define getc fgetc #define putc fputc ================================================ FILE: include/smallc/sys/gpio.h ================================================ /* * Ioctl definitions for GPIO driver. */ #define GPIO_PORT(n) (n) /* port number */ #define GPIO_PORTA 0 #define GPIO_PORTB 1 #define GPIO_PORTC 2 #define GPIO_PORTD 3 #define GPIO_PORTE 4 #define GPIO_PORTF 5 #define GPIO_PORTG 6 #define GPIO_CONFIN 0x20016700 /* configure as input */ #define GPIO_CONFOUT 0x20026700 /* configure as output */ #define GPIO_CONFOD 0x20046700 /* configure as open drain */ #define GPIO_DECONF 0x20086700 /* deconfigure */ #define GPIO_STORE 0x20106700 /* store all outputs */ #define GPIO_SET 0x20206700 /* set to 1 by mask */ #define GPIO_CLEAR 0x20406700 /* set to 0 by mask */ #define GPIO_INVERT 0x20806700 /* invert by mask */ #define GPIO_POLL 0x21006700 /* poll */ #define GPIO_LOL 0x82006700 /* display lol picture */ ================================================ FILE: include/smallc/sys/spi.h ================================================ /* * Ioctl definitions for SPI driver. */ #define SPICTL_SETMODE 0x20007000 /* set SPI mode */ #define SPICTL_SETRATE 0x20007001 /* set clock rate, kHz */ #define SPICTL_SETSELPIN 0x20007002 /* set select pin */ #define SPICTL_IO8(n) (0xc0007003 | (n)<<16) /* transfer n*8 bits */ #define SPICTL_IO16(n) (0xc0007004 | (n)<<16) /* transfer n*16 bits */ #define SPICTL_IO32(n) (0xc0007005 | (n)<<16) /* transfer n*32 bits */ ================================================ FILE: include/smallc/wiznet.h ================================================ /* * SmallC: interface to wiznet library. */ #define MAX_SOCK_NUM 4 /* Max number of sockets per chip */ #define CLIENT_SIZE 3 /* Size of client structure in words */ #define UDP_SIZE 2 /* Size of UDP structure in words */ extern unsigned _socket_port[]; extern unsigned _client_srcport; extern unsigned _server_port; ================================================ FILE: include/stdarg.h ================================================ /* * ISO C Standard: 7.15 Variable arguments */ #ifndef _STDARG_H #define _STDARG_H /* * Define va_start, va_arg, va_end, va_copy. */ #if defined(__GNUC__) /* Gnu C */ # define va_start(ap, last) __builtin_va_start((ap), last) # define va_arg(ap, type) __builtin_va_arg((ap), type) # define va_end(ap) __builtin_va_end((ap)) # define va_copy(dest, src) __builtin_va_copy((dest), (src)) #elif defined(__PCC__) /* PCC */ # define va_start(ap, last) __builtin_stdarg_start((ap), last) # define va_arg(ap, type) __builtin_va_arg((ap), type) # define va_end(ap) __builtin_va_end((ap)) # define va_copy(dest, src) __builtin_va_copy((dest), (src)) #else /* SmallerC, LCC */ # define va_start(ap, last) (ap = ((char*)&(last) + \ (((sizeof(last) + sizeof(int) - 1) / sizeof(int)) * sizeof(int)))) # define va_arg(ap, type) ((type*)(ap += \ sizeof(type) == sizeof(int) ? sizeof(type) : \ (-(int)(ap) & (sizeof(type) - 1)) + sizeof(type)))[-1] # define va_end(ap) # define va_copy(dest, src) (dest = (src)) #endif /* * Define va_list. */ #ifndef _VA_LIST_T # define _VA_LIST_T # if defined(__GNUC__) || defined(__PCC__) typedef __builtin_va_list va_list; # else typedef char *va_list; # endif #endif /* * Define __gnuc_va_list. */ #if defined(__GNUC__) && !defined(__GNUC_VA_LIST) # define __GNUC_VA_LIST typedef __builtin_va_list __gnuc_va_list; #endif #endif /* not _STDARG_H */ ================================================ FILE: include/stdbool.h ================================================ /* $OpenBSD: stdbool.h,v 1.7 2015/09/04 23:47:09 daniel Exp $ */ /* * Written by Marc Espie, September 25, 1999 * Public domain. */ #ifndef _STDBOOL_H_ #define _STDBOOL_H_ #ifndef __cplusplus #if defined(__GNUC__) || \ (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901) /* Support for C99: type _Bool is already built-in. */ #define false 0 #define true 1 #else /* `_Bool' type must promote to `int' or `unsigned int'. */ typedef enum { false = 0, true = 1 } _Bool; /* And those constants must also be available as macros. */ #define false false #define true true #endif /* User visible type `bool' is provided as a macro which may be redefined. */ #define bool _Bool #else /* __cplusplus */ #define _Bool bool #define bool bool #define false false #define true true #endif /* __cplusplus */ /* Inform that everything is fine. */ #define __bool_true_false_are_defined 1 #endif /* _STDBOOL_H_ */ ================================================ FILE: include/stddef.h ================================================ #ifndef _STDDEF_H_ #define _STDDEF_H_ typedef int ptrdiff_t; #ifndef _SIZE_T #define _SIZE_T typedef unsigned size_t; #endif #ifndef NULL #define NULL 0 #endif /* Offset of member MEMBER in a struct of type TYPE. */ #if defined(__GNUC__) && __GNUC__ > 3 #define offsetof(TYPE, MEMBER) __builtin_offsetof (TYPE, MEMBER) #else #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE*)0)->MEMBER) #endif #endif /* _STDDEF_H_ */ ================================================ FILE: include/stdio.h ================================================ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #ifndef FILE #define BUFSIZ 1024 extern struct _iobuf { int _cnt; char *_ptr; /* should be unsigned char */ char *_base; /* ditto */ int _bufsiz; short _flag; short _file; } _iob[]; #define _IOREAD 01 #define _IOWRT 02 #define _IONBF 04 #define _IOMYBUF 010 #define _IOEOF 020 #define _IOERR 040 #define _IOSTRG 0100 #define _IOLBF 0200 #define _IORW 0400 /* * The following definition is for ANSI C, which took them * from System V, which brilliantly took internal interface macros and * made them official arguments to setvbuf(), without renaming them. * Hence, these ugly _IOxxx names are *supposed* to appear in user code. */ #define _IOFBF 0 /* setvbuf should set fully buffered */ /* _IONBF and _IOLBF are used from the flags above */ #ifndef NULL #define NULL 0 #endif #ifndef _SIZE_T #define _SIZE_T typedef unsigned size_t; #endif #define FILE struct _iobuf #define EOF (-1) #define stdin (&_iob[0]) #define stdout (&_iob[1]) #define stderr (&_iob[2]) #define SEEK_SET 0 /* set file offset to offset */ #define SEEK_CUR 1 /* set file offset to current plus offset */ #define SEEK_END 2 /* set file offset to EOF plus offset */ void clearerr(FILE *); int feof(FILE *); int ferror(FILE *); int fileno(FILE *); FILE *fopen (const char *, const char *); FILE *fdopen (int, const char *); FILE *freopen (const char *, const char *, FILE *); FILE *popen (const char *, const char *); int pclose (FILE *); FILE *tmpfile (void); int fclose (FILE *); long ftell (FILE *); int fflush (FILE *); int fgetc (FILE *); int ungetc (int, FILE *); int fputc (int, FILE *); int fputs (const char *, FILE *); int puts (const char *); char *fgets (char *, int, FILE *); char *gets (char *); FILE *_findiop (void); int _filbuf (FILE *); int _flsbuf (unsigned char, FILE *); void setbuf (FILE *, char *); void setbuffer (FILE *, char *, size_t); void setlinebuf (FILE *); int setvbuf (FILE *, char *, int, size_t); int fseek (FILE *, long, int); void rewind (FILE *); int remove (const char *); int rename (const char *, const char *); int getw(FILE *stream); int putw(int w, FILE *stream); size_t fread (void *, size_t, size_t, FILE *); size_t fwrite (const void *, size_t, size_t, FILE *); int fprintf (FILE *, const char *, ...); int printf (const char *, ...); int sprintf (char *, const char *, ...); int snprintf (char *, size_t, const char *, ...); int fscanf (FILE *, const char *, ...); int scanf (const char *, ...); int sscanf (const char *, const char *, ...); #ifndef _VA_LIST_ # ifdef __GNUC__ # define va_list __builtin_va_list /* For Gnu C */ # endif # ifdef __SMALLER_C__ # define va_list char * /* For Smaller C */ # endif #endif int vfprintf (FILE *, const char *, va_list); int vprintf (const char *, va_list); int vsprintf (char *, const char *, va_list); int vsnprintf (char *, size_t, const char *, va_list); int vfscanf (FILE *, const char *, va_list); int vscanf (const char *, va_list); int vsscanf (const char *, const char *, va_list); int _doprnt (const char *, va_list, FILE *); int _doscan (FILE *, const char *, va_list); #ifndef _VA_LIST_ # undef va_list #endif void perror (const char *); #ifndef lint #define getc(p) (--(p)->_cnt>=0? (int)(*(unsigned char *)(p)->_ptr++):_filbuf(p)) #define putc(x, p) (--(p)->_cnt >= 0 ?\ (int)(*(unsigned char *)(p)->_ptr++ = (x)) :\ (((p)->_flag & _IOLBF) && -(p)->_cnt < (p)->_bufsiz ?\ ((*(p)->_ptr = (x)) != '\n' ?\ (int)(*(unsigned char *)(p)->_ptr++) :\ _flsbuf(*(unsigned char *)(p)->_ptr, p)) :\ _flsbuf((unsigned char)(x), p))) #endif /* not lint */ #define getchar() getc(stdin) #define putchar(x) putc(x,stdout) #define __sfeof(p) (((p)->_flag&_IOEOF)!=0) #define __sferror(p) (((p)->_flag&_IOERR)!=0) #define __sfileno(p) ((p)->_file) #define __sclearerr(p) ((p)->_flag &= ~(_IOERR|_IOEOF)) #define feof(p) __sfeof(p) #define ferror(p) __sferror(p) #define fileno(p) __sfileno(p) #define clearerr(p) __sclearerr(p) #endif /* _FILE */ ================================================ FILE: include/stdlib.h ================================================ /*- * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)stdlib.h 8.3.2 (2.11BSD) 1996/1/12 * * Adapted from the 4.4-Lite CD. The odds of a ANSI C compiler for 2.11BSD * being slipped under the door are not distinguishable from 0 - so the * prototypes and ANSI ifdefs have been removed from this file. * * Some functions (strtoul for example) do not exist yet but are retained in * this file because additions to libc.a are anticipated shortly. */ #ifndef _STDLIB_H_ #define _STDLIB_H_ #ifndef NULL #define NULL 0 #endif #define EXIT_FAILURE 1 #define EXIT_SUCCESS 0 #define RAND_MAX 0x7fff #ifndef _SIZE_T #define _SIZE_T typedef unsigned size_t; #endif void abort (void); int abs (int); int atexit (void (*)(void)); int atoi (const char *); long atol (const char *); void *calloc (size_t, size_t); void exit (int); void free (void *); char *getenv (const char *); long labs (long); void *malloc (size_t); char *mktemp (char *); int mkstemp (char *); void qsort (void *, size_t, size_t, int (*)(const void *, const void *)); int rand (void); void *realloc (void*, size_t); void srand (unsigned); long strtol (const char *, char **, int); unsigned long strtoul (const char *, char **, int); int system (const char *); int putenv (char *string); int setenv (const char *name, const char *value, int overwrite); int unsetenv (const char *name); char *_findenv (const char *name, int *offset); void *alloca (size_t size); int daemon (int, int); char *devname (int dev, int type); int getloadavg (unsigned loadavg[], int nelem); extern char *suboptarg; /* getsubopt(3) external variable */ int getsubopt (char **, char **, char **); long random (void); char *setstate (char *); void srandom (unsigned); double atof (const char *); double strtod (const char *, char **); char *ecvt (double, int, int *, int *); char *fcvt (double, int, int *, int *); char *gcvt (double, int, char *); int ttyslot (void); #endif /* _STDLIB_H_ */ ================================================ FILE: include/string.h ================================================ /* * Copyright (c) 1985 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * * @(#)string.h 5.1.3 (2.11BSD) 1996/3/20 */ #ifndef NULL #define NULL 0 #endif #ifndef _SIZE_T #define _SIZE_T typedef unsigned int size_t; #endif char *strcat(char *, const char *); char *strncat(char *, const char *, size_t); size_t strlcat(char *, const char *, size_t); char *strcpy(char *, const char *); char *strncpy(char *, const char *, size_t); size_t strlcpy(char *, const char *, size_t); char *strstr(const char *, const char *); int strcmp(const char *, const char *); int strncmp(const char *, const char *, size_t); size_t strlen(const char *); int memcmp(const void *, const void *, size_t); void *memmove(void *, const void *, size_t); void *memccpy(void *, const void *, int, size_t); void *memchr(const void *, int, size_t); void *memcpy(void *, const void *, size_t); void *memset(void *, int, size_t); char *strchr(const char *, int); char *strdup(const char *); char *strpbrk(const char *, const char *); char *strrchr(const char *, int); char *strsep(char **, const char *); char *strtok(char *, const char *); char *strtok_r(char *, const char *, char **); size_t strcspn(const char *, const char *); size_t strspn(const char *, const char *); char *strerror(int); const char *syserrlst(int); ================================================ FILE: include/strings.h ================================================ /*- * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)strings.h 8.1 (Berkeley) 6/2/93 */ #ifndef _SIZE_T #define _SIZE_T typedef unsigned int size_t; #endif int bcmp(const void *, const void *, size_t); void bcopy(const void *, void *, size_t); void bzero(void *, size_t); int ffs(int); char *index(const char *, int); char *rindex(const char *, int); int strcasecmp(const char *, const char *); int strncasecmp(const char *, const char *, size_t); ================================================ FILE: include/struct.h ================================================ /* struct.h 4.1 83/05/03 */ /* * access to information relating to the fields of a structure */ #define fldoff(str, fld) ((int)&(((struct str *)0)->fld)) #define fldsiz(str, fld) (sizeof(((struct str *)0)->fld)) #define strbase(str, ptr, fld) ((struct str *)((char *)(ptr)-fldoff(str, fld))) ================================================ FILE: include/syscall.h ================================================ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ /* * DO NOT place any comments on the same line as a SYS_* definition. This * causes cpp to leave a trailing tab when expanding macros in pdp/sys/SYS.h */ #define SYS_exit 1 #define SYS_fork 2 #define SYS_read 3 #define SYS_write 4 #define SYS_open 5 #define SYS_close 6 #define SYS_wait4 7 /* 8 is old; creat */ #define SYS_link 9 #define SYS_unlink 10 #define SYS_execv 11 #define SYS_chdir 12 #define SYS_fchdir 13 #define SYS_mknod 14 #define SYS_chmod 15 #define SYS_chown 16 #define SYS_chflags 17 #define SYS_fchflags 18 #define SYS_lseek 19 #define SYS_getpid 20 #define SYS_mount 21 #define SYS_umount 22 #define SYS___sysctl 23 #define SYS_getuid 24 #define SYS_geteuid 25 #define SYS_ptrace 26 #define SYS_getppid 27 #define SYS_statfs 28 #define SYS_fstatfs 29 #define SYS_getfsstat 30 #define SYS_sigaction 31 #define SYS_sigprocmask 32 #define SYS_access 33 #define SYS_sigpending 34 #define SYS_sigaltstack 35 #define SYS_sync 36 #define SYS_kill 37 #define SYS_stat 38 /* 39 was getlogin */ #define SYS_lstat 40 #define SYS_dup 41 #define SYS_pipe 42 /* 43 was setlogin */ #define SYS_profil 44 #define SYS_setuid 45 #define SYS_seteuid 46 #define SYS_getgid 47 #define SYS_getegid 48 #define SYS_setgid 49 #define SYS_setegid 50 #define SYS_kmemdev 51 #define SYS_phys 52 #define SYS_lock 53 #define SYS_ioctl 54 #define SYS_reboot 55 #define SYS_sigwait 56 #define SYS_symlink 57 #define SYS_readlink 58 #define SYS_execve 59 #define SYS_umask 60 #define SYS_chroot 61 #define SYS_fstat 62 /* 63 is unused */ /* 64 is old; getpagesize */ #define SYS_pselect 65 #define SYS_vfork 2 /* 66 - not fixed yet */ /* 67 is old; vread */ /* 68 is old; vwrite */ #define SYS_sbrk 69 #define SYS_rdglob 70 #define SYS_wrglob 71 /* 71 is unused 4.3: mmap */ #define SYS_msec 72 /* 72 is unused 4.3: vadvise */ /* 73 is unused 4.3: munmap */ /* 74 is unused 4.3: mprotect */ /* 75 is unused 4.3: madvise */ #define SYS_vhangup 76 /* 77 is old; vlimit */ /* 78 is unused 4.3: mincore */ #define SYS_getgroups 79 #define SYS_setgroups 80 #define SYS_getpgrp 81 #define SYS_setpgrp 82 #define SYS_setitimer 83 /* 84 is old; wait,wait3 */ #define SYS_swapon 85 #define SYS_getitimer 86 /* 87 is old; gethostname */ /* 88 is old; sethostname */ #define SYS_getdtablesize 89 #define SYS_dup2 90 /* 91 is unused 4.3: getdopt */ #define SYS_fcntl 92 #define SYS_select 93 /* 94 is unused 4.3: setdopt */ #define SYS_fsync 95 #define SYS_setpriority 96 #define SYS_socket 97 #define SYS_connect 98 #define SYS_accept 99 #define SYS_getpriority 100 #define SYS_send 101 #define SYS_recv 102 #define SYS_sigreturn 103 #define SYS_bind 104 #define SYS_setsockopt 105 #define SYS_listen 106 #define SYS_sigsuspend 107 /* * 108 thru 112 are 4.3BSD compatibility syscalls. sigstack has to remain * defined because no replacement routine exists. Sigh. */ /* 108 is old; sigvec */ /* 109 is old; sigblock */ /* 110 is old; sigsetmask */ /* 111 is old; sigpause */ #define SYS_sigstack 112 #define SYS_recvmsg 113 #define SYS_sendmsg 114 /* 115 is old; vtrace */ #define SYS_gettimeofday 116 #define SYS_getrusage 117 #define SYS_getsockopt 118 /* 119 is old; resuba */ #define SYS_readv 120 #define SYS_writev 121 #define SYS_settimeofday 122 #define SYS_fchown 123 #define SYS_fchmod 124 #define SYS_recvfrom 125 /* 126 is old; setreuid */ /* 127 is old; setregid */ #define SYS_rename 128 #define SYS_truncate 129 #define SYS_ftruncate 130 #define SYS_flock 131 /* 132 is unused */ #define SYS_sendto 133 #define SYS_shutdown 134 #define SYS_socketpair 135 #define SYS_mkdir 136 #define SYS_rmdir 137 #define SYS_utimes 138 /* 139 is unused */ #define SYS_adjtime 140 #define SYS_getpeername 141 /* 142 is old; gethostid */ /* 143 is old; sethostid */ #define SYS_getrlimit 144 #define SYS_setrlimit 145 #define SYS_killpg 146 /* 147 is unused */ #define SYS_setquota 148 #define SYS_quota 149 #define SYS_getsockname 150 /* * 2BSD special calls */ /* 151 is unused */ #define SYS_ustore 152 #define SYS_ufetch 153 #define SYS_ucall 154 /* 155 is unused */ ================================================ FILE: include/sysexits.h ================================================ /* * Copyright (c) 1987 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that this notice is preserved and that due credit is given * to the University of California at Berkeley. The name of the University * may not be used to endorse or promote products derived from this * software without specific prior written permission. This software * is provided ``as is'' without express or implied warranty. * * @(#)sysexits.h 4.4.1 (2.11BSD) 1996/11/29 */ /* ** SYSEXITS.H -- Exit status codes for system programs. ** ** This include file attempts to categorize possible error ** exit statuses for system programs, notably delivermail ** and the Berkeley network. ** ** Error numbers begin at EX__BASE to reduce the possibility of ** clashing with other exit statuses that random programs may ** already return. The meaning of the codes is approximately ** as follows: ** ** EX_USAGE -- The command was used incorrectly, e.g., with ** the wrong number of arguments, a bad flag, a bad ** syntax in a parameter, or whatever. ** EX_DATAERR -- The input data was incorrect in some way. ** This should only be used for user's data & not ** system files. ** EX_NOINPUT -- An input file (not a system file) did not ** exist or was not readable. This could also include ** errors like "No message" to a mailer (if it cared ** to catch it). ** EX_NOUSER -- The user specified did not exist. This might ** be used for mail addresses or remote logins. ** EX_NOHOST -- The host specified did not exist. This is used ** in mail addresses or network requests. ** EX_UNAVAILABLE -- A service is unavailable. This can occur ** if a support program or file does not exist. This ** can also be used as a catchall message when something ** you wanted to do doesn't work, but you don't know ** why. ** EX_SOFTWARE -- An internal software error has been detected. ** This should be limited to non-operating system related ** errors as possible. ** EX_OSERR -- An operating system error has been detected. ** This is intended to be used for such things as "cannot ** fork", "cannot create pipe", or the like. It includes ** things like getuid returning a user that does not ** exist in the passwd file. ** EX_OSFILE -- Some system file (e.g., /etc/passwd, /var/run/utmp, ** etc.) does not exist, cannot be opened, or has some ** sort of error (e.g., syntax error). ** EX_CANTCREAT -- A (user specified) output file cannot be ** created. ** EX_IOERR -- An error occurred while doing I/O on some file. ** EX_TEMPFAIL -- temporary failure, indicating something that ** is not really an error. In sendmail, this means ** that a mailer (e.g.) could not create a connection, ** and the request should be reattempted later. ** EX_PROTOCOL -- the remote system returned something that ** was "not possible" during a protocol exchange. ** EX_NOPERM -- You did not have sufficient permission to ** perform the operation. This is not intended for ** file system problems, which should use NOINPUT or ** CANTCREAT, but rather for higher level permissions. ** For example, kre uses this to restrict who students ** can send mail to. ** ** Maintained by Eric Allman (eric@berkeley, ucbvax!eric) -- ** please mail changes to me. ** ** @(#)sysexits.h 4.4 3/24/88 */ # define EX_OK 0 /* successful termination */ # define EX__BASE 64 /* base value for error messages */ # define EX_USAGE 64 /* command line usage error */ # define EX_DATAERR 65 /* data format error */ # define EX_NOINPUT 66 /* cannot open input */ # define EX_NOUSER 67 /* addressee unknown */ # define EX_NOHOST 68 /* host name unknown */ # define EX_UNAVAILABLE 69 /* service unavailable */ # define EX_SOFTWARE 70 /* internal software error */ # define EX_OSERR 71 /* system error (e.g., can't fork) */ # define EX_OSFILE 72 /* critical OS file missing */ # define EX_CANTCREAT 73 /* can't create (user) output file */ # define EX_IOERR 74 /* input/output error */ # define EX_TEMPFAIL 75 /* temp failure; user is invited to retry */ # define EX_PROTOCOL 76 /* remote error in protocol */ # define EX_NOPERM 77 /* permission denied */ # define EX_CONFIG 78 /* configuration error */ ================================================ FILE: include/tcl/tcl.h ================================================ /* * tcl.h -- * * This header file describes the externally-visible facilities * of the Tcl interpreter. * * Copyright 1987-1991 Regents of the University of California * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without * fee is hereby granted, provided that the above copyright * notice appear in all copies. The University of California * makes no representations about the suitability of this * software for any purpose. It is provided "as is" without * express or implied warranty. */ #ifndef _TCL #define _TCL #define TCL_VERSION "6.7" #define TCL_MAJOR_VERSION 6 #define TCL_MINOR_VERSION 7 /* * Data structures defined opaquely in this module. The definitions * below just provide dummy types. A few fields are made visible in * Tcl_Interp structures, namely those for returning string values. * Note: any change to the Tcl_Interp definition below must be mirrored * in the "real" definition in tclInt.h. */ typedef struct Tcl_Interp { unsigned char *result; /* Points to result string returned by last * command. */ void (*freeProc) (unsigned char *blockPtr); /* Zero means result is statically allocated. * If non-zero, gives address of procedure * to invoke to free the result. Must be * freed by Tcl_Eval before executing next * command. */ unsigned short errorLine; /* When TCL_ERROR is returned, this gives * the line number within the command where * the error occurred (1 means first line). */ } Tcl_Interp; typedef void *Tcl_Trace; typedef void *Tcl_CmdBuf; /* * When a TCL command returns, the string pointer interp->result points to * a string containing return information from the command. In addition, * the command procedure returns an integer value, which is one of the * following: * * TCL_OK Command completed normally; interp->result contains * the command's result. * TCL_ERROR The command couldn't be completed successfully; * interp->result describes what went wrong. * TCL_RETURN The command requests that the current procedure * return; interp->result contains the procedure's * return value. * TCL_BREAK The command requests that the innermost loop * be exited; interp->result is meaningless. * TCL_CONTINUE Go on to the next iteration of the current loop; * interp->result is meaninless. */ #define TCL_OK 0 #define TCL_ERROR 1 #define TCL_RETURN 2 #define TCL_BREAK 3 #define TCL_CONTINUE 4 #define TCL_RESULT_SIZE 199 /* * Procedure types defined by Tcl: */ typedef void (Tcl_CmdDeleteProc) (void *clientData); typedef int (Tcl_CmdProc) (void *clientData, Tcl_Interp *interp, int argc, unsigned char *argv[]); typedef void (Tcl_CmdTraceProc) (void *clientData, Tcl_Interp *interp, int level, unsigned char *command, Tcl_CmdProc *proc, void *cmdClientData, int argc, unsigned char *argv[]); typedef void (Tcl_FreeProc) (unsigned char *blockPtr); typedef unsigned char *(Tcl_VarTraceProc) (void *clientData, Tcl_Interp *interp, unsigned char *part1, unsigned char *part2, int flags); /* * Flag values passed to Tcl_Eval (see the man page for details; also * see tclInt.h for additional flags that are only used internally by * Tcl): */ #define TCL_BRACKET_TERM 1 /* * Flag that may be passed to Tcl_ConvertElement to force it not to * output braces (careful! if you change this flag be sure to change * the definitions at the front of tclUtil.c). */ #define TCL_DONT_USE_BRACES 1 /* * Flag value passed to Tcl_RecordAndEval to request no evaluation * (record only). */ #define TCL_NO_EVAL -1 /* * Specil freeProc values that may be passed to Tcl_SetResult (see * the man page for details): */ #define TCL_STATIC ((Tcl_FreeProc *) 0) #define TCL_VOLATILE ((Tcl_FreeProc *) -1) #define TCL_DYNAMIC ((Tcl_FreeProc *) -2) /* * Flag values passed to variable-related procedures. */ #define TCL_GLOBAL_ONLY 1 #define TCL_APPEND_VALUE 2 #define TCL_LIST_ELEMENT 4 #define TCL_NO_SPACE 8 #define TCL_TRACE_READS 0x10 #define TCL_TRACE_WRITES 0x20 #define TCL_TRACE_UNSETS 0x40 #define TCL_TRACE_DESTROYED 0x80 #define TCL_INTERP_DESTROYED 0x100 #define TCL_LEAVE_ERR_MSG 0x200 /* * Additional flag passed back to variable watchers. This flag must * not overlap any of the TCL_TRACE_* flags defined above or the * TRACE_* flags defined in tclInt.h. */ #define TCL_VARIABLE_UNDEFINED 8 /* * Exported Tcl procedures: */ extern void Tcl_AppendElement (Tcl_Interp *interp, unsigned char *string, int noSep); extern void Tcl_AppendResult (Tcl_Interp *interp, ...); extern unsigned char * Tcl_AssembleCmd (Tcl_CmdBuf buffer, unsigned char *string); extern void Tcl_AddErrorInfo (Tcl_Interp *interp, unsigned char *message); extern char Tcl_Backslash (unsigned char *src, int *readPtr); extern int Tcl_CommandComplete (unsigned char *cmd); extern unsigned char * Tcl_Concat (int argc, unsigned char **argv); extern int Tcl_ConvertElement (unsigned char *src, unsigned char *dst, int flags); extern Tcl_CmdBuf Tcl_CreateCmdBuf (void); extern void Tcl_CreateCommand (Tcl_Interp *interp, unsigned char *cmdName, Tcl_CmdProc *proc, void *clientData, Tcl_CmdDeleteProc *deleteProc); extern Tcl_Interp * Tcl_CreateInterp (void); extern int Tcl_CreatePipeline (Tcl_Interp *interp, int argc, unsigned char **argv, int **pidArrayPtr, int *inPipePtr, int *outPipePtr, int *errFilePtr); extern Tcl_Trace Tcl_CreateTrace (Tcl_Interp *interp, int level, Tcl_CmdTraceProc *proc, void *clientData); extern void Tcl_DeleteCmdBuf (Tcl_CmdBuf buffer); extern int Tcl_DeleteCommand (Tcl_Interp *interp, unsigned char *cmdName); extern void Tcl_DeleteInterp (Tcl_Interp *interp); extern void Tcl_DeleteTrace (Tcl_Interp *interp, Tcl_Trace trace); extern void Tcl_DetachPids (int numPids, int *pidPtr); extern unsigned char * Tcl_ErrnoId (void); extern int Tcl_Eval (Tcl_Interp *interp, unsigned char *cmd, int flags, unsigned char **termPtr); extern int Tcl_EvalFile (Tcl_Interp *interp, unsigned char *fileName); extern int Tcl_ExprBoolean (Tcl_Interp *interp, unsigned char *string, int *ptr); extern int Tcl_ExprLong (Tcl_Interp *interp, unsigned char *string, long *ptr); extern int Tcl_ExprString (Tcl_Interp *interp, unsigned char *string); extern int Tcl_Fork (void); extern void Tcl_FreeResult (Tcl_Interp *interp); extern int Tcl_GetBoolean (Tcl_Interp *interp, unsigned char *string, int *boolPtr); extern int Tcl_GetInt (Tcl_Interp *interp, char *string, int *intPtr); extern unsigned char * Tcl_GetVar (Tcl_Interp *interp, unsigned char *varName, int flags); extern unsigned char * Tcl_GetVar2 (Tcl_Interp *interp, unsigned char *part1, unsigned char *part2, int flags); extern int Tcl_GlobalEval (Tcl_Interp *interp, unsigned char *command); extern void Tcl_InitHistory (Tcl_Interp *interp); extern void Tcl_InitMemory (Tcl_Interp *interp); extern unsigned char * Tcl_Merge (int argc, unsigned char **argv); extern unsigned char * Tcl_ParseVar (Tcl_Interp *interp, unsigned char *string, unsigned char **termPtr); extern int Tcl_RecordAndEval (Tcl_Interp *interp, unsigned char *cmd, int flags); extern void Tcl_ResetResult (Tcl_Interp *interp); extern int Tcl_ScanElement (unsigned char *string, int *flagPtr); extern void Tcl_SetErrorCode (Tcl_Interp *interp, ...); extern void Tcl_SetResult (Tcl_Interp *interp, unsigned char *string, Tcl_FreeProc *freeProc); extern unsigned char * Tcl_SetVar (Tcl_Interp *interp, unsigned char *varName, unsigned char *newValue, int flags); extern unsigned char * Tcl_SetVar2 (Tcl_Interp *interp, unsigned char *part1, unsigned char *part2, unsigned char *newValue, int flags); extern unsigned char * Tcl_SignalId (int sig); extern unsigned char * Tcl_SignalMsg (int sig); extern int Tcl_SplitList (Tcl_Interp *interp, unsigned char *list, int *argcPtr, unsigned char ***argvPtr); extern int Tcl_StringMatch (unsigned char *string, unsigned char *pattern); extern unsigned char * Tcl_TildeSubst (Tcl_Interp *interp, unsigned char *name); extern int Tcl_TraceVar (Tcl_Interp *interp, unsigned char *varName, int flags, Tcl_VarTraceProc *proc, void *clientData); extern int Tcl_TraceVar2 (Tcl_Interp *interp, unsigned char *part1, unsigned char *part2, int flags, Tcl_VarTraceProc *proc, void *clientData); extern int Tcl_UnsetVar (Tcl_Interp *interp, unsigned char *varName, int flags); extern int Tcl_UnsetVar2 (Tcl_Interp *interp, unsigned char *part1, unsigned char *part2, int flags); extern void Tcl_UntraceVar (Tcl_Interp *interp, unsigned char *varName, int flags, Tcl_VarTraceProc *proc, void *clientData); extern void Tcl_UntraceVar2 (Tcl_Interp *interp, unsigned char *part1, unsigned char *part2, int flags, Tcl_VarTraceProc *proc, void *clientData); extern int Tcl_VarEval (Tcl_Interp *interp, ...); extern void * Tcl_VarTraceInfo (Tcl_Interp *interp, unsigned char *varName, int flags, Tcl_VarTraceProc *procPtr, void *prevClientData); extern void * Tcl_VarTraceInfo2 (Tcl_Interp *interp, unsigned char *part1, unsigned char *part2, int flags, Tcl_VarTraceProc *procPtr, void *prevClientData); extern int Tcl_WaitPids (int numPids, int *pidPtr, int *statusPtr); #endif /* _TCL */ ================================================ FILE: include/term.h ================================================ #ifndef _TERM_H #define _TERM_H extern int tgetent(char *, char *); extern int tgetnum(char *); extern int tgetflag(char *); extern char *tgetstr(char *, char **); extern char *tgoto(char *, int, int); extern int tputs(register char *, int, int (*)()); #endif ================================================ FILE: include/termios-todo.h ================================================ #ifndef _TERMIOS_H #define _TERMIOS_H #include #include typedef unsigned char cc_t; typedef unsigned int speed_t; typedef unsigned int tcflag_t; #define NCCS 32 struct termios { tcflag_t c_iflag; /* input mode flags */ tcflag_t c_oflag; /* output mode flags */ tcflag_t c_cflag; /* control mode flags */ tcflag_t c_lflag; /* local mode flags */ cc_t c_line; /* line discipline */ cc_t c_cc[NCCS]; /* control characters */ speed_t c_ispeed; /* input speed */ speed_t c_ospeed; /* output speed */ #define _HAVE_STRUCT_TERMIOS_C_ISPEED 1 #define _HAVE_STRUCT_TERMIOS_C_OSPEED 1 }; extern int tcgetattr(int, struct termios *); extern int tcsetattr(int, int, struct termios *); /* c_cc characters */ #define VINTR 0 #define VQUIT 1 #define VERASE 2 #define VKILL 3 #define VEOF 4 #define VTIME 5 #define VMIN 6 #define VSWTC 7 #define VSTART 8 #define VSTOP 9 #define VSUSP 10 #define VEOL 11 #define VREPRINT 12 #define VDISCARD 13 #define VWERASE 14 #define VLNEXT 15 #define VEOL2 16 /* c_iflag bits */ #define IGNBRK 0000001 #define BRKINT 0000002 #define IGNPAR 0000004 #define PARMRK 0000010 #define INPCK 0000020 #define ISTRIP 0000040 #define INLCR 0000100 #define IGNCR 0000200 #define ICRNL 0000400 #define IUCLC 0001000 #define IXON 0002000 #define IXANY 0004000 #define IXOFF 0010000 #define IMAXBEL 0020000 #define IUTF8 0040000 /* c_oflag bits */ #define OPOST 0000001 #define OLCUC 0000002 #define ONLCR 0000004 #define OCRNL 0000010 #define ONOCR 0000020 #define ONLRET 0000040 #define OFILL 0000100 #define OFDEL 0000200 #if defined __USE_MISC || defined __USE_XOPEN # define NLDLY 0000400 # define NL0 0000000 # define NL1 0000400 # define CRDLY 0003000 # define CR0 0000000 # define CR1 0001000 # define CR2 0002000 # define CR3 0003000 # define TABDLY 0014000 # define TAB0 0000000 # define TAB1 0004000 # define TAB2 0010000 # define TAB3 0014000 # define BSDLY 0020000 # define BS0 0000000 # define BS1 0020000 # define FFDLY 0100000 # define FF0 0000000 # define FF1 0100000 #endif #define VTDLY 0040000 #define VT0 0000000 #define VT1 0040000 #ifdef __USE_MISC # define XTABS 0014000 #endif /* c_lflag bits */ #define ISIG 0000001 #define ICANON 0000002 #define CSIZE 0000060 #define CS5 0000000 #define CS6 0000020 #define CS7 0000040 #define CS8 0000060 #define CSTOPB 0000100 #define CREAD 0000200 #define PARENB 0000400 #define PARODD 0001000 #define HUPCL 0002000 #define CLOCAL 0004000 #define IEXTEN 0100000 /* tcflow() and TCXONC use these */ #define TCOOFF 0 #define TCOON 1 #define TCIOFF 2 #define TCION 3 /* tcflush() and TCFLSH use these */ #define TCIFLUSH 0 #define TCOFLUSH 1 #define TCIOFLUSH 2 /* tcsetattr uses these */ #define TCSANOW 0 #define TCSADRAIN 1 #define TCSAFLUSH 2 #define TCSASOFT 0x10 #define CIGNORE 0x00000001 #define TIOCGETA _IOR(i, 92, struct termios) #define TIOCSETA _IOW(i, 92, struct termios) #define TIOCSETAW _IOW(i, 92, struct termios) #define TIOCSETAF _IOW(i, 92, struct termios) #endif ================================================ FILE: include/time.h ================================================ /* * Copyright (c) 1983, 1987 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #ifndef _TIME_H #define _TIME_H #ifndef NULL #define NULL 0 #endif #ifndef _TIME_T #define _TIME_T typedef long time_t; #endif #ifndef _SIZE_T #define _SIZE_T typedef unsigned size_t; #endif /* * Structure returned by gmtime and localtime calls (see ctime(3)). */ struct tm { int tm_sec; int tm_min; int tm_hour; int tm_mday; int tm_mon; int tm_year; int tm_wday; int tm_yday; int tm_isdst; long tm_gmtoff; char *tm_zone; }; struct tm *gmtime(const time_t *); struct tm *localtime(const time_t *); char *asctime(const struct tm *); char *ctime(const time_t *); time_t time(time_t *); size_t strftime (char *s, size_t maxsize, const char *format, const struct tm *timeptr); #endif ================================================ FILE: include/ttyent.h ================================================ /* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ struct ttyent { /* see getttyent(3) */ char *ty_name; /* terminal device name */ char *ty_getty; /* command to execute, usually getty */ char *ty_type; /* terminal type for termcap (3X) */ int ty_status; /* status flags (see below for defines) */ char *ty_window; /* command to start up window manager */ char *ty_comment; /* usually the location of the terminal */ }; #define TTY_ON 0x1 /* enable logins (startup getty) */ #define TTY_SECURE 0x2 /* allow root to login */ struct ttyent *getttyent (void); struct ttyent *getttynam (const char *name); void setttyent (void); void endttyent (void); ================================================ FILE: include/tzfile.h ================================================ /* * @(#)tzfile.h 5.2.1 (2.11BSD) 1996/11/29 */ /* ** Information about time zone files. */ /* Time zone object file directory */ #define TZDIR "/usr/share/zoneinfo" #define TZDEFAULT "/etc/localtime" /* ** Each file begins with. . . */ struct tzhead { char tzh_reserved[32]; /* reserved for future use */ char tzh_timecnt[4]; /* coded number of transition times */ char tzh_typecnt[4]; /* coded number of local time types */ char tzh_charcnt[4]; /* coded number of abbr. chars */ }; /* ** . . .followed by. . . ** ** tzh_timecnt (char [4])s coded transition times a la time(2) ** tzh_timecnt (unsigned char)s types of local time starting at above ** tzh_typecnt repetitions of ** one (char [4]) coded GMT offset in seconds ** one (unsigned char) used to set tm_isdt ** one (unsigned char) that's an abbreviation list index ** tzh_charcnt (char)s '\0'-terminated zone abbreviaton strings */ /* ** In the current implementation, "tzset()" refuses to deal with files that ** exceed any of the limits below. */ /* ** The TZ_MAX_TIMES value below is enough to handle a bit more than a ** year's worth of solar time (corrected daily to the nearest second) or ** 138 years of Pacific Presidential Election time ** (where there are three time zone transitions every fourth year). */ #define TZ_MAX_TIMES 370 #define NOSOLAR /* We currently don't handle solar time */ #ifndef NOSOLAR #define TZ_MAX_TYPES 256 /* Limited by what (unsigned char)'s can hold */ #else /* !NOSOLAR */ #define TZ_MAX_TYPES 10 /* Maximum number of local time types */ #endif /* !NOSOLAR */ #define TZ_MAX_CHARS 50 /* Maximum number of abbreviation characters */ #define SECS_PER_MIN 60 #define MINS_PER_HOUR 60 #define HOURS_PER_DAY 24 #define DAYS_PER_WEEK 7 #define DAYS_PER_NYEAR 365 #define DAYS_PER_LYEAR 366 #define SECS_PER_HOUR (SECS_PER_MIN * MINS_PER_HOUR) #define SECS_PER_DAY ((long) SECS_PER_HOUR * HOURS_PER_DAY) #define MONS_PER_YEAR 12 #define TM_SUNDAY 0 #define TM_MONDAY 1 #define TM_TUESDAY 2 #define TM_WEDNESDAY 3 #define TM_THURSDAY 4 #define TM_FRIDAY 5 #define TM_SATURDAY 6 #define TM_JANUARY 0 #define TM_FEBRUARY 1 #define TM_MARCH 2 #define TM_APRIL 3 #define TM_MAY 4 #define TM_JUNE 5 #define TM_JULY 6 #define TM_AUGUST 7 #define TM_SEPTEMBER 8 #define TM_OCTOBER 9 #define TM_NOVEMBER 10 #define TM_DECEMBER 11 #define TM_SUNDAY 0 #define TM_YEAR_BASE 1900 #define EPOCH_YEAR 1970 #define EPOCH_WDAY TM_THURSDAY /* ** Accurate only for the past couple of centuries; ** that will probably do. */ #define isleap(y) ((((y) % 4) == 0 && ((y) % 100) != 0) || ((y) % 400) == 0) ================================================ FILE: include/unistd.h ================================================ /*- * Copyright (c) 1991, 1993, 1994 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ /* * Modified for 2.11BSD by removing prototypes. To save time and space * functions not returning 'int' and functions not present in the system * are not listed. */ #ifndef _UNISTD_H_ #define _UNISTD_H_ #include #define STDIN_FILENO 0 /* standard input file descriptor */ #define STDOUT_FILENO 1 /* standard output file descriptor */ #define STDERR_FILENO 2 /* standard error file descriptor */ #ifndef NULL #define NULL 0 /* null pointer constant */ #endif /* Values for the second argument to access. These may be OR'd together. */ #define R_OK 4 /* Test for read permission. */ #define W_OK 2 /* Test for write permission. */ #define X_OK 1 /* Test for execute permission. */ #define F_OK 0 /* Test for existence. */ void _exit (int); int access(); unsigned int alarm(); pid_t fork(); gid_t getegid(); uid_t geteuid(); gid_t getgid(); char *getlogin(); pid_t getpgrp(); pid_t getpid(); pid_t getppid(); uid_t getuid(); off_t lseek(); ssize_t read(); unsigned int sleep(); char *ttyname(); ssize_t write (int fd, const void *buf, size_t count); int truncate (const char *path, off_t length); int ftruncate (int fd, off_t length); void *brk (const void *addr); int _brk (const void *addr); char *crypt(); void endusershell(); long gethostid(); char *getpass(); char *getusershell(); char *getwd(); void psignal(); extern char *sys_siglist[]; char *re_comp(); void *sbrk (int incr); int sethostid(); int sethostname(char *name, int namelen); int setlogin(const char *name); void setusershell(); void sync(); int fsync(int fd); unsigned int ualarm(); void usleep(); int pause (void); pid_t vfork(); int pipe (int pipefd[2]); int close (int fd); int dup (int oldfd); int dup2 (int oldfd, int newfd); int unlink (const char *pathname); int link (const char *oldpath, const char *newpath); int symlink (const char *, const char *); ssize_t readlink (const char *path, char *buf, size_t bufsiz); int chown (const char *path, uid_t owner, gid_t group); int nice (int inc); int setuid (uid_t uid); int setgid (gid_t gid); int seteuid (uid_t euid); int setegid (gid_t egid); int setreuid (uid_t ruid, uid_t euid); int setregid (gid_t rgid, gid_t egid); int setpgrp (pid_t pid, pid_t pgrp); int isatty (int fd); int chdir (const char *path); int fchdir (int fd); int fchown (int fd, uid_t owner, gid_t group); int chflags (const char *path, u_long flags); int chroot (const char *); int fchflags (int fd, u_long flags); int getgroups (int size, gid_t list[]); int getgrouplist (char *name, gid_t basegid, gid_t *groups, int *ngroups); int initgroups (const char *, gid_t); int gethostname (char *name, size_t namelen); int getdtablesize (void); int getpagesize (void); int rmdir (const char *pathname); int reboot(int howto); mode_t getmode(void *set, mode_t mode); void *setmode(char *mode_str); struct stat; int stat (const char *path, struct stat *buf); int fstat (int fd, struct stat *buf); int lstat (const char *path, struct stat *buf); int execl (const char *path, const char *arg0, ... /* NULL */); int execle (const char *path, const char *arg0, ... /* NULL, char *envp[] */); int execlp (const char *file, const char *arg0, ... /* NULL */); int execv (const char *path, char *const argv[]); int execve (const char *path, char *const arg0[], char *const envp[]); int execvp (const char *file, char *const argv[]); extern char **environ; /* Environment, from crt0. */ extern const char *__progname; /* Program name, from crt0. */ int getopt (int argc, char * const argv[], const char *optstring); extern char *optarg; /* getopt(3) external variables */ extern int opterr, optind, optopt; #ifndef _VA_LIST_ # ifdef __GNUC__ # define va_list __builtin_va_list /* For Gnu C */ # endif # ifdef __SMALLER_C__ # define va_list char * /* For Smaller C */ # endif #endif void err (int eval, const char *fmt, ...); void errx (int eval, const char *fmt, ...); void warn (const char *fmt, ...); void warnx (const char *fmt, ...); void verr (int eval, const char *fmt, va_list ap); void verrx (int eval, const char *fmt, va_list ap); void vwarn (const char *fmt, va_list ap); void vwarnx (const char *fmt, va_list ap); #ifndef _VA_LIST_ # undef va_list #endif #endif /* !_UNISTD_H_ */ ================================================ FILE: include/utmp.h ================================================ /* * Copyright (c) 1988 The Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the University of California, Berkeley. The name of the * University may not be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #define UT_NAMESIZE 15 #define UT_LINESIZE 8 #define UT_HOSTSIZE 16 struct utmp { char ut_line[UT_LINESIZE]; char ut_name[UT_NAMESIZE]; char ut_host[UT_HOSTSIZE]; long ut_time; }; ================================================ FILE: include/vmf.h ================================================ /* Program Name: vmf.h * Author: S.M. Schultz * * ----------- Modification History ------------ * Version Date Reason For Modification * 1.0 01Jan80 1. Initial release. * 2.0 31Mar83 2. Cleanup. * 3.0 08Sep93 3. Change v_foffset to off_t instead of int. * 3.1 21Oct93 4. Create union member of structure to * make 'int' or 'char' access to data easy. * Define segment+offset and modified macros. * Place into the public domain. * -------------------------------------------------- */ #include #define MAXSEGNO 16384 /* max number of segments in a space */ #define BYTESPERSEG 1024 /* must be power of two! */ #define LOG2BPS 10 /* log2(BYTESPERSEG) */ #define WORDSPERSEG (BYTESPERSEG/sizeof (int)) struct vspace { int v_fd; /* file for swapping */ off_t v_foffset; /* offset for computing file addresses */ int v_maxsegno; /* number of segments in this space */ }; struct dlink { /* general double link structure */ struct dlink *fwd; /* forward link */ struct dlink *back; /* back link */ }; struct vseg { /* structure of a segment in memory */ struct dlink s_link; /* for linking into lru list */ int s_segno; /* segment number */ struct vspace *s_vspace; /* which virtual space */ int s_lock_count; int s_flags; union { int _winfo[WORDSPERSEG]; /* the actual segment */ char _cinfo[BYTESPERSEG]; } v_un; }; #define s_winfo v_un._winfo #define s_cinfo v_un._cinfo /* masks for s_flags */ #define S_DIRTY 01 /* segment has been modified */ long nswaps; /* number of swaps */ long nmapsegs; /* number of mapseg calls */ int vminit(), vmopen(); struct vseg *vmmapseg(); void vmlock(), vmunlock(), vmclrseg(), vmmodify(); void vmflush(), vmclose(); typedef long VADDR; #define VMMODIFY(seg) (seg->s_flags |= S_DIRTY) #define VSEG(va) ((short)(va >> LOG2BPS)) #define VOFF(va) ((u_short)va % BYTESPERSEG) ================================================ FILE: include/wiznet/client.h ================================================ #ifndef client_h #define client_h struct _client_t { unsigned sock; uint8_t *ip; unsigned port; }; typedef struct _client_t client_t; extern unsigned _client_srcport; void client_init (client_t *c, uint8_t *ip, unsigned port); void client_init_sock (client_t *c, unsigned sock); unsigned client_status (client_t *); int client_connect (client_t *); void client_putc (client_t *, uint8_t); void client_puts (client_t *c, const char *str); void client_write (client_t *c, const uint8_t *buf, unsigned size); int client_available (client_t *); int client_getc (client_t *); int client_read (client_t *c, uint8_t *buf, unsigned size); int client_peek (client_t *); void client_flush (client_t *); void client_stop (client_t *); int client_connected (client_t *); #endif ================================================ FILE: include/wiznet/ethernet.h ================================================ #ifndef ethernet_h #define ethernet_h #include #include "client.h" #include "server.h" #define MAX_SOCK_NUM 4 void ethernet_init (void); #endif ================================================ FILE: include/wiznet/server.h ================================================ #ifndef server_h #define server_h #include "client.h" extern unsigned _server_port; void server_init (unsigned port); int server_available (client_t *); void server_accept (void); void server_putc (uint8_t byte); void server_puts (const char *str); void server_write (const uint8_t *buf, unsigned size); #endif ================================================ FILE: include/wiznet/socket.h ================================================ #ifndef _SOCKET_H_ #define _SOCKET_H_ #include "w5100.h" extern unsigned _socket_port [MAX_SOCK_NUM]; /* * Opens a socket(TCP or UDP or IP_RAW mode) */ unsigned socket_init (unsigned sock, unsigned protocol, unsigned port, unsigned flag); /* * Close socket */ void socket_close (unsigned sock); /* * Establish TCP connection (Active connection) */ unsigned socket_connect (unsigned sock, uint8_t *addr, unsigned port); /* * disconnect the connection */ void socket_disconnect (unsigned sock); /* * Establish TCP connection (Passive connection) */ unsigned socket_listen (unsigned sock); /* * Send data (TCP) */ unsigned socket_send (unsigned sock, const uint8_t *buf, unsigned len); /* * Receive data (TCP) */ unsigned socket_recv (unsigned sock, uint8_t *buf, unsigned len); unsigned socket_peek (unsigned sock); /* * Send data (UDP/IP RAW) */ unsigned socket_sendto (unsigned sock, const uint8_t *buf, unsigned len, uint8_t *addr, unsigned port); /* * Receive data (UDP/IP RAW) */ unsigned socket_recvfrom (unsigned sock, uint8_t *buf, unsigned len, uint8_t *addr, unsigned *port); unsigned socket_igmpsend (unsigned sock, const uint8_t *buf, unsigned len); #endif /* _SOCKET_H_ */ ================================================ FILE: include/wiznet/udp.h ================================================ /* * Udp.cpp: Library to send/receive UDP packets with the Arduino ethernet shield. * This version only offers minimal wrapping of socket.c/socket.h * * NOTE: UDP is fast, but has some important limitations (thanks to Warren Gray for mentioning these) * 1) UDP does not guarantee the order in which assembled UDP packets are received. This * might not happen often in practice, but in larger network topologies, a UDP * packet can be received out of sequence. * 2) UDP does not guard against lost packets - so packets *can* disappear without the sender being * aware of it. Again, this may not be a concern in practice on small local networks. * For more information, see http://www.cafeaulait.org/course/week12/35.html * * MIT License: * Copyright (c) 2008 Bjoern Hartmann * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * bjoern@cs.stanford.edu 12/30/2008 */ #ifndef udp_h #define udp_h #define UDP_TX_PACKET_MAX_SIZE 24 struct _udp_t { unsigned port; // local port to listen on unsigned sock; // socket ID for Wiz5100 }; typedef struct _udp_t udp_t; /* * Initialize, start listening on specified port. * Returns 1 if successful, 0 if there are no sockets available to use. */ int udp_init (udp_t *u, unsigned port); /* * Has data been received? */ unsigned udp_available (udp_t *u); /* * Finish with the UDP socket. */ void udp_stop (udp_t *u); /* * Send a packet to specified peer. */ unsigned udp_send_packet (udp_t *u, const uint8_t *data, unsigned len, uint8_t *ip, unsigned port); /* * Send a zero-terminated string to specified peer. */ unsigned udp_send_string (udp_t *u, const char *data, uint8_t *ip, unsigned port); /* * Read a received packet, also return sender's ip and port. */ int udp_read_packet (udp_t *u, uint8_t *buf, unsigned len, uint8_t *ip, unsigned *port); #endif ================================================ FILE: include/wiznet/w5100.h ================================================ /* * Copyright (c) 2010 by Cristian Maglie * * This file is free software; you can redistribute it and/or modify * it under the terms of either the GNU General Public License version 2 * or the GNU Lesser General Public License version 2.1, both as * published by the Free Software Foundation. * * Updated August/3/2011 by Lowell Scott Hanson to be compatable with chipKIT boards * Updated April/13/2012 by Serge Vakulenko for RetroBSD project */ #ifndef W5100_H_INCLUDED #define W5100_H_INCLUDED #include #define MAX_SOCK_NUM 4 /* * Common Mode Register. */ #define MR_IND 0x01 /* Indirect bus interface mode */ #define MR_AI 0x02 /* Address auto-increment for indirect mode */ #define MR_PPPoE 0x08 /* PPPoE mode */ #define MR_PB 0x10 /* Ping block mode */ #define MR_RST 0x80 /* Software reset */ /* * Socket Mode Register. */ #define SnMR_CLOSE 0x00 #define SnMR_TCP 0x01 #define SnMR_UDP 0x02 #define SnMR_IPRAW 0x03 #define SnMR_MACRAW 0x04 #define SnMR_PPPOE 0x05 #define SnMR_ND 0x20 /* No delayed ACK */ #define SnMR_MULTI 0x80 /* Enable multicasting */ /* * Socket Command Register. */ #define Sock_OPEN 0x01 #define Sock_LISTEN 0x02 #define Sock_CONNECT 0x04 #define Sock_DISCON 0x08 #define Sock_CLOSE 0x10 #define Sock_SEND 0x20 #define Sock_SEND_MAC 0x21 #define Sock_SEND_KEEP 0x22 #define Sock_RECV 0x40 /* * Socket Interrupt Register. */ #define SnIR_SEND_OK 0x10 #define SnIR_TIMEOUT 0x08 #define SnIR_RECV 0x04 #define SnIR_DISCON 0x02 #define SnIR_CON 0x01 /* * Socket Status Register. */ #define SnSR_CLOSED 0x00 #define SnSR_INIT 0x13 #define SnSR_LISTEN 0x14 #define SnSR_SYNSENT 0x15 #define SnSR_SYNRECV 0x16 #define SnSR_ESTABLISHED 0x17 #define SnSR_FIN_WAIT 0x18 #define SnSR_CLOSING 0x1A #define SnSR_TIME_WAIT 0x1B #define SnSR_CLOSE_WAIT 0x1C #define SnSR_LAST_ACK 0x1D #define SnSR_UDP 0x22 #define SnSR_IPRAW 0x32 #define SnSR_MACRAW 0x42 #define SnSR_PPPOE 0x5F #define TXBUF_SIZE 2048 // Max Tx buffer size #define RXBUF_SIZE 2048 // Max Rx buffer size #define CH_BASE 0x0400 #define CH_SIZE 0x0100 /*---------------------------------------------- * W5100 Registers */ unsigned w5100_write_byte (unsigned addr, int byte); unsigned w5100_write (unsigned addr, const uint8_t *buf, unsigned len); unsigned w5100_read_byte (unsigned addr); unsigned w5100_read (unsigned addr, uint8_t *buf, unsigned len); #define __GP_REGISTER8(name, address) \ static inline void w5100_write##name (unsigned data) { \ w5100_write_byte (address, data); \ } \ static inline unsigned w5100_read##name() { \ return w5100_read_byte (address); \ } #define __GP_REGISTER16(name, address) \ static inline void w5100_write##name(unsigned data) { \ w5100_write_byte (address, data >> 8); \ w5100_write_byte (address+1, data & 0xFF); \ } \ static inline unsigned w5100_read##name() { \ unsigned res = w5100_read_byte (address); \ res = (res << 8) + w5100_read_byte (address + 1); \ return res; \ } #define __GP_REGISTER_N(name, address, size) \ static inline unsigned w5100_write##name(uint8_t *buff) { \ return w5100_write(address, buff, size); \ } \ static inline unsigned w5100_read##name(uint8_t *buff) { \ return w5100_read(address, buff, size); \ } __GP_REGISTER8 (MR, 0x0000); // Mode __GP_REGISTER_N(GAR, 0x0001, 4); // Gateway IP address __GP_REGISTER_N(SUBR, 0x0005, 4); // Subnet mask address __GP_REGISTER_N(SHAR, 0x0009, 6); // Source MAC address __GP_REGISTER_N(SIPR, 0x000F, 4); // Source IP address __GP_REGISTER8 (IR, 0x0015); // Interrupt __GP_REGISTER8 (IMR, 0x0016); // Interrupt Mask __GP_REGISTER16(RTR, 0x0017); // Timeout address __GP_REGISTER8 (RCR, 0x0019); // Retry count __GP_REGISTER8 (RMSR, 0x001A); // Receive memory size __GP_REGISTER8 (TMSR, 0x001B); // Transmit memory size __GP_REGISTER8 (PATR, 0x001C); // Authentication type address in PPPoE mode __GP_REGISTER8 (PTIMER, 0x0028); // PPP LCP Request Timer __GP_REGISTER8 (PMAGIC, 0x0029); // PPP LCP Magic Number __GP_REGISTER_N(UIPR, 0x002A, 4); // Unreachable IP address in UDP mode __GP_REGISTER16(UPORT, 0x002E); // Unreachable Port address in UDP mode #undef __GP_REGISTER8 #undef __GP_REGISTER16 #undef __GP_REGISTER_N /*---------------------------------------------- * W5100 Socket registers */ static inline unsigned w5100_readSn_byte (unsigned sock, unsigned addr) { return w5100_read_byte (CH_BASE + sock*CH_SIZE + addr); } static inline unsigned w5100_writeSn_byte (unsigned sock, unsigned addr, unsigned data) { return w5100_write_byte (CH_BASE + sock*CH_SIZE + addr, data); } static inline unsigned w5100_readSn (unsigned sock, unsigned addr, uint8_t *buf, unsigned len) { return w5100_read (CH_BASE + sock*CH_SIZE + addr, buf, len); } static inline unsigned w5100_writeSn (unsigned sock, unsigned addr, uint8_t *buf, unsigned len) { return w5100_write (CH_BASE + sock*CH_SIZE + addr, buf, len); } #define __SOCKET_REGISTER8(name, address) \ static inline void w5100_write##name (unsigned sock, unsigned data) { \ w5100_writeSn_byte (sock, address, data); \ } \ static inline unsigned w5100_read##name (unsigned sock) { \ return w5100_readSn_byte (sock, address); \ } #define __SOCKET_REGISTER16(name, address) \ static inline void w5100_write##name (unsigned sock, unsigned data) { \ w5100_writeSn_byte (sock, address, data >> 8); \ w5100_writeSn_byte (sock, address+1, data & 0xFF); \ } \ static inline unsigned w5100_read##name (unsigned sock) { \ unsigned res = w5100_readSn_byte (sock, address); \ res = (res << 8) + w5100_readSn_byte (sock, address + 1); \ return res; \ } #define __SOCKET_REGISTER_N(name, address, size) \ static inline unsigned w5100_write##name (unsigned sock, uint8_t *buf) { \ return w5100_writeSn (sock, address, buf, size); \ } \ static inline unsigned read##name (unsigned sock, uint8_t *buf) { \ return w5100_readSn (sock, address, buf, size); \ } __SOCKET_REGISTER8(SnMR, 0x0000) // Mode __SOCKET_REGISTER8(SnCR, 0x0001) // Command __SOCKET_REGISTER8(SnIR, 0x0002) // Interrupt __SOCKET_REGISTER8(SnSR, 0x0003) // Status __SOCKET_REGISTER16(SnPORT, 0x0004) // Source Port __SOCKET_REGISTER_N(SnDHAR, 0x0006, 6) // Destination Hardw Addr __SOCKET_REGISTER_N(SnDIPR, 0x000C, 4) // Destination IP Addr __SOCKET_REGISTER16(SnDPORT, 0x0010) // Destination Port __SOCKET_REGISTER16(SnMSSR, 0x0012) // Max Segment Size __SOCKET_REGISTER8(SnPROTO, 0x0014) // Protocol in IP RAW Mode __SOCKET_REGISTER8(SnTOS, 0x0015) // IP TOS __SOCKET_REGISTER8(SnTTL, 0x0016) // IP TTL __SOCKET_REGISTER16(SnTX_FSR, 0x0020) // TX Free Size __SOCKET_REGISTER16(SnTX_RD, 0x0022) // TX Read Pointer __SOCKET_REGISTER16(SnTX_WR, 0x0024) // TX Write Pointer __SOCKET_REGISTER16(SnRX_RSR, 0x0026) // RX Free Size __SOCKET_REGISTER16(SnRX_RD, 0x0028) // RX Read Pointer __SOCKET_REGISTER16(SnRX_WR, 0x002A) // RX Write Pointer (supported?) #undef __SOCKET_REGISTER8 #undef __SOCKET_REGISTER16 #undef __SOCKET_REGISTER_N /*---------------------------------------------- * W5100 functions */ void w5100_init(); /* * This function is being used for copy the data form Receive buffer * of the chip to application buffer. * * It calculate the actual physical address where one has to read * the data from Receive buffer. Here also take care of the condition * while it exceed the Rx memory uper-bound of socket. */ void w5100_read_data (unsigned sock, unsigned src, uint8_t *dst, unsigned len); /* * This function is being called by send() and sendto() function also. * * This function read the Tx write pointer register and after copy the data * in buffer update the Tx write pointer register. */ void w5100_send_chunk (unsigned sock, const uint8_t *data, unsigned len); /* * This function is being called by recv() also. * * This function read the Rx read pointer register and after copy * the data from receive buffer update the Rx write pointer register. */ void w5100_recv_chunk (unsigned sock, uint8_t *data, unsigned len); unsigned w5100_recv_peek (unsigned sock); void w5100_socket_cmd (unsigned sock, int cmd); unsigned w5100_getTXFreeSize (unsigned sock); unsigned w5100_getRXReceivedSize (unsigned sock); /* * Debug output. */ //#define W5100_DEBUG printf #ifndef W5100_DEBUG # define W5100_DEBUG(...) /* empty */ #endif #endif ================================================ FILE: lib/Makefile ================================================ # # Copyright (c) 1980 Regents of the University of California. # All rights reserved. The Berkeley software License Agreement # specifies the terms and conditions for redistribution. # TOPSRC!=cd ..; pwd include ${TOPSRC}/share/mk/sys.mk SUBDIR= libc_aout \ startup-${MACHINE_ARCH} libc libm libcurses libtermlib \ libutil libvmf libtcl libreadline libgpanel libwiznet all: $(SUBDIR) $(SUBDIR): FRC $(MAKE) -C $@ FRC: install: elf32-$(MACHINE_ARCH).ld -for i in $(SUBDIR); do \ ${MAKE} -C $$i DESTDIR=${DESTDIR} install; done # cp -p elf32-$(MACHINE_ARCH).ld $(DESTDIR)/usr/lib/elf32-$(MACHINE_ARCH).ld clean: rm -f a.out core *.s *.o *.a *~ -for i in $(SUBDIR); do $(MAKE) -C $$i clean; done ================================================ FILE: lib/elf32-arm.ld ================================================ /* Script for -z combreloc: combine and sort reloc sections */ /* Copyright (C) 2014-2016 Free Software Foundation, Inc. Copying and distribution of this script, with or without modification, are permitted in any medium without royalty provided the copyright notice and this notice are preserved. */ /* * Linker script for user executables. */ OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", "elf32-littlearm") OUTPUT_ARCH(arm) ENTRY(_start) SEARCH_DIR("/usr/local/arm-none-eabi/lib"); SECTIONS { /* Read-only sections, merged into text segment: */ /* XXX PROVIDE (__executable_start = SEGMENT_START("text-segment", 0x8000)); . = SEGMENT_START("text-segment", 0x8000); */ PROVIDE (__executable_start = 0x20000000); . = 0x20000000; .interp : { *(.interp) } .note.gnu.build-id : { *(.note.gnu.build-id) } .hash : { *(.hash) } .gnu.hash : { *(.gnu.hash) } .dynsym : { *(.dynsym) } .dynstr : { *(.dynstr) } .gnu.version : { *(.gnu.version) } .gnu.version_d : { *(.gnu.version_d) } .gnu.version_r : { *(.gnu.version_r) } .rel.dyn : { *(.rel.init) *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*) *(.rel.fini) *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*) *(.rel.data.rel.ro .rel.data.rel.ro.* .rel.gnu.linkonce.d.rel.ro.*) *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*) *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*) *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*) *(.rel.ctors) *(.rel.dtors) *(.rel.got) *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*) PROVIDE_HIDDEN (__rel_iplt_start = .); *(.rel.iplt) PROVIDE_HIDDEN (__rel_iplt_end = .); } .rela.dyn : { *(.rela.init) *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*) *(.rela.fini) *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*) *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*) *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*) *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*) *(.rela.ctors) *(.rela.dtors) *(.rela.got) *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) PROVIDE_HIDDEN (__rela_iplt_start = .); *(.rela.iplt) PROVIDE_HIDDEN (__rela_iplt_end = .); } .rel.plt : { *(.rel.plt) } .rela.plt : { *(.rela.plt) } .init : { KEEP (*(SORT_NONE(.init))) } .plt : { *(.plt) } .iplt : { *(.iplt) } .text : { *(.text.unlikely .text.*_unlikely .text.unlikely.*) *(.text.exit .text.exit.*) *(.text.startup .text.startup.*) *(.text.hot .text.hot.*) *(.text .stub .text.* .gnu.linkonce.t.*) /* .gnu.warning sections are handled specially by elf32.em. */ *(.gnu.warning) *(.glue_7t) *(.glue_7) *(.vfp11_veneer) *(.v4_bx) } .fini : { KEEP (*(SORT_NONE(.fini))) } PROVIDE (__etext = .); PROVIDE (_etext = .); PROVIDE (etext = .); .rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) } .rodata1 : { *(.rodata1) } /* XXX elf2aout cannot handle these optional sections. .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } PROVIDE_HIDDEN (__exidx_start = .); .ARM.exidx : { *(.ARM.exidx* .gnu.linkonce.armexidx.*) } PROVIDE_HIDDEN (__exidx_end = .); XXX */ .eh_frame_hdr : { *(.eh_frame_hdr) *(.eh_frame_entry .eh_frame_entry.*) } .eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) *(.eh_frame.*) } .gcc_except_table : ONLY_IF_RO { *(.gcc_except_table .gcc_except_table.*) } .gnu_extab : ONLY_IF_RO { *(.gnu_extab*) } /* These sections are generated by the Sun/Oracle C++ compiler. */ .exception_ranges : ONLY_IF_RO { *(.exception_ranges .exception_ranges*) } /* Adjust the address for the data segment. We want to adjust up to the same address within the page on the next page up. */ /* XXX . = ALIGN(CONSTANT (MAXPAGESIZE)) + (. & (CONSTANT (MAXPAGESIZE) - 1)); XXX */ /* Exception handling */ .eh_frame : ONLY_IF_RW { KEEP (*(.eh_frame)) *(.eh_frame.*) } .gnu_extab : ONLY_IF_RW { *(.gnu_extab) } .gcc_except_table : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) } .exception_ranges : ONLY_IF_RW { *(.exception_ranges .exception_ranges*) } /* Thread Local Storage sections */ .tdata : { *(.tdata .tdata.* .gnu.linkonce.td.*) } .tbss : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) } .preinit_array : { PROVIDE_HIDDEN (__preinit_array_start = .); KEEP (*(.preinit_array)) PROVIDE_HIDDEN (__preinit_array_end = .); } .init_array : { PROVIDE_HIDDEN (__init_array_start = .); KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*))) KEEP (*(.init_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .ctors)) PROVIDE_HIDDEN (__init_array_end = .); } .fini_array : { PROVIDE_HIDDEN (__fini_array_start = .); KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*))) KEEP (*(.fini_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .dtors)) PROVIDE_HIDDEN (__fini_array_end = .); } .ctors : { /* gcc uses crtbegin.o to find the start of the constructors, so we make sure it is first. Because this is a wildcard, it doesn't matter if the user does not actually link against crtbegin.o; the linker won't look for a file to match a wildcard. The wildcard also means that it doesn't matter which directory crtbegin.o is in. */ KEEP (*crtbegin.o(.ctors)) KEEP (*crtbegin?.o(.ctors)) /* We don't want to include the .ctor section from the crtend.o file until after the sorted ctors. The .ctor section from the crtend file contains the end of ctors marker and it must be last */ KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors)) KEEP (*(SORT(.ctors.*))) KEEP (*(.ctors)) } .dtors : { KEEP (*crtbegin.o(.dtors)) KEEP (*crtbegin?.o(.dtors)) KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors)) KEEP (*(SORT(.dtors.*))) KEEP (*(.dtors)) } .jcr : { KEEP (*(.jcr)) } .data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro .data.rel.ro.* .gnu.linkonce.d.rel.ro.*) } .dynamic : { *(.dynamic) } .got : { *(.got.plt) *(.igot.plt) *(.got) *(.igot) } .data : { __data_start = . ; *(.data .data.* .gnu.linkonce.d.*) SORT(CONSTRUCTORS) } .data1 : { *(.data1) } _edata = .; PROVIDE (edata = .); . = .; __bss_start = .; __bss_start__ = .; .bss : { *(.dynbss) *(.bss .bss.* .gnu.linkonce.b.*) *(COMMON) /* Align here to ensure that the .bss section occupies space up to _end. Align after .bss to ensure correct alignment even if the .bss section disappears because there are no input sections. FIXME: Why do we need it? When there is no .bss section, we don't pad the .data section. */ . = ALIGN(. != 0 ? 32 / 8 : 1); } _bss_end__ = . ; __bss_end__ = . ; . = ALIGN(32 / 8); . = SEGMENT_START("ldata-segment", .); . = ALIGN(32 / 8); __end__ = . ; _end = .; PROVIDE (end = .); /* Stabs debugging sections. */ .stab 0 : { *(.stab) } .stabstr 0 : { *(.stabstr) } .stab.excl 0 : { *(.stab.excl) } .stab.exclstr 0 : { *(.stab.exclstr) } .stab.index 0 : { *(.stab.index) } .stab.indexstr 0 : { *(.stab.indexstr) } .comment 0 : { *(.comment) } /* DWARF debug sections. Symbols in the DWARF debugging sections are relative to the beginning of the section so we begin them at 0. */ /* DWARF 1 */ .debug 0 : { *(.debug) } .line 0 : { *(.line) } /* GNU DWARF 1 extensions */ .debug_srcinfo 0 : { *(.debug_srcinfo) } .debug_sfnames 0 : { *(.debug_sfnames) } /* DWARF 1.1 and DWARF 2 */ .debug_aranges 0 : { *(.debug_aranges) } .debug_pubnames 0 : { *(.debug_pubnames) } /* DWARF 2 */ .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) } .debug_abbrev 0 : { *(.debug_abbrev) } .debug_line 0 : { *(.debug_line .debug_line.* .debug_line_end ) } .debug_frame 0 : { *(.debug_frame) } .debug_str 0 : { *(.debug_str) } .debug_loc 0 : { *(.debug_loc) } .debug_macinfo 0 : { *(.debug_macinfo) } /* SGI/MIPS DWARF 2 extensions */ .debug_weaknames 0 : { *(.debug_weaknames) } .debug_funcnames 0 : { *(.debug_funcnames) } .debug_typenames 0 : { *(.debug_typenames) } .debug_varnames 0 : { *(.debug_varnames) } /* DWARF 3 */ .debug_pubtypes 0 : { *(.debug_pubtypes) } .debug_ranges 0 : { *(.debug_ranges) } /* DWARF Extension. */ .debug_macro 0 : { *(.debug_macro) } .stack 0x80000 : { _stack = .; *(.stack) } .ARM.attributes 0 : { KEEP (*(.ARM.attributes)) KEEP (*(.gnu.attributes)) } .note.gnu.arm.ident 0 : { KEEP (*(.note.gnu.arm.ident)) } /DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) } /DISCARD/ : { *(.ARM.exidx) *(.ARM.extab) } } ================================================ FILE: lib/elf32-mips.ld ================================================ /* * Linker script for user executables. */ OUTPUT_FORMAT("elf32-littlemips", "elf32-bigmips", "elf32-littlemips") OUTPUT_ARCH(mips) ENTRY(_start) /* Required by Microchip C32 linker */ /*MEMORY { kseg0_program_mem (rx) : ORIGIN = 0x9D000000, LENGTH = 0x80000 kseg0_boot_mem : ORIGIN = 0x9FC00490, LENGTH = 0x970 exception_mem : ORIGIN = 0x9FC01000, LENGTH = 0x1000 kseg1_boot_mem : ORIGIN = 0xBFC00000, LENGTH = 0x490 kseg1_data_mem (w!x) : ORIGIN = 0xA0000000, LENGTH = 0x20000 }*/ SECTIONS { /* Read-only sections, merged into text segment: */ PROVIDE (__executable_start = 0x7f008000); . = 0x7f008000; .interp : { *(.interp) } /*.reginfo : { *(.reginfo) }*/ .note.gnu.build-id : { *(.note.gnu.build-id) } .dynamic : { *(.dynamic) } .hash : { *(.hash) } .gnu.hash : { *(.gnu.hash) } .dynsym : { *(.dynsym) } .dynstr : { *(.dynstr) } .gnu.version : { *(.gnu.version) } .gnu.version_d : { *(.gnu.version_d) } .gnu.version_r : { *(.gnu.version_r) } .rel.init : { *(.rel.init) } .rela.init : { *(.rela.init) } .rel.text : { *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*) } .rela.text : { *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*) } .rel.fini : { *(.rel.fini) } .rela.fini : { *(.rela.fini) } .rel.rodata : { *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*) } .rela.rodata : { *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*) } .rel.data.rel.ro : { *(.rel.data.rel.ro* .rel.gnu.linkonce.d.rel.ro.*) } .rela.data.rel.ro : { *(.rela.data.rel.ro* .rela.gnu.linkonce.d.rel.ro.*) } .rel.data : { *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*) } .rela.data : { *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*) } .rel.tdata : { *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*) } .rela.tdata : { *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*) } .rel.tbss : { *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*) } .rela.tbss : { *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*) } .rel.ctors : { *(.rel.ctors) } .rela.ctors : { *(.rela.ctors) } .rel.dtors : { *(.rel.dtors) } .rela.dtors : { *(.rela.dtors) } .rel.got : { *(.rel.got) } .rela.got : { *(.rela.got) } .rel.sdata : { *(.rel.sdata .rel.sdata.* .rel.gnu.linkonce.s.*) } .rela.sdata : { *(.rela.sdata .rela.sdata.* .rela.gnu.linkonce.s.*) } .rel.sbss : { *(.rel.sbss .rel.sbss.* .rel.gnu.linkonce.sb.*) } .rela.sbss : { *(.rela.sbss .rela.sbss.* .rela.gnu.linkonce.sb.*) } .rel.sdata2 : { *(.rel.sdata2 .rel.sdata2.* .rel.gnu.linkonce.s2.*) } .rela.sdata2 : { *(.rela.sdata2 .rela.sdata2.* .rela.gnu.linkonce.s2.*) } .rel.sbss2 : { *(.rel.sbss2 .rel.sbss2.* .rel.gnu.linkonce.sb2.*) } .rela.sbss2 : { *(.rela.sbss2 .rela.sbss2.* .rela.gnu.linkonce.sb2.*) } .rel.bss : { *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*) } .rela.bss : { *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) } .rel.plt : { *(.rel.plt) } .rela.plt : { *(.rela.plt) } .init : { KEEP (*(.init)) } =0 .plt : { *(.plt) } .text : { _ftext = . ; *(.text .stub .text.* .gnu.linkonce.t.*) /* .gnu.warning sections are handled specially by elf32.em. */ *(.gnu.warning) *(.mips16.fn.*) *(.mips16.call.*) } =0 .fini : { KEEP (*(.fini)) } =0 PROVIDE (__etext = .); PROVIDE (_etext = .); PROVIDE (etext = .); .rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) } .rodata1 : { *(.rodata1) } .sdata2 : { *(.sdata2 .sdata2.* .gnu.linkonce.s2.*) } .sbss2 : { *(.sbss2 .sbss2.* .gnu.linkonce.sb2.*) } .eh_frame_hdr : { *(.eh_frame_hdr) *(.eh_frame_entry .eh_frame_entry.*) } .eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) } .gcc_except_table : ONLY_IF_RO { *(.gcc_except_table .gcc_except_table.*) } /* Adjust the address for the data segment. */ . = ALIGN (16) - ((16 - .) & (16 - 1)); . = DATA_SEGMENT_ALIGN (16, 16); /* Exception handling */ .eh_frame : ONLY_IF_RW { KEEP (*(.eh_frame)) } .gcc_except_table : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) } /* Thread Local Storage sections */ .tdata : { *(.tdata .tdata.* .gnu.linkonce.td.*) } .tbss : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) } .preinit_array : { PROVIDE_HIDDEN (__preinit_array_start = .); KEEP (*(.preinit_array)) PROVIDE_HIDDEN (__preinit_array_end = .); } .init_array : { PROVIDE_HIDDEN (__init_array_start = .); KEEP (*(SORT(.init_array.*))) KEEP (*(.init_array)) PROVIDE_HIDDEN (__init_array_end = .); } .fini_array : { PROVIDE_HIDDEN (__fini_array_start = .); KEEP (*(.fini_array)) KEEP (*(SORT(.fini_array.*))) PROVIDE_HIDDEN (__fini_array_end = .); } .ctors : { /* gcc uses crtbegin.o to find the start of the constructors, so we make sure it is first. Because this is a wildcard, it doesn't matter if the user does not actually link against crtbegin.o; the linker won't look for a file to match a wildcard. The wildcard also means that it doesn't matter which directory crtbegin.o is in. */ KEEP (*crtbegin.o(.ctors)) KEEP (*crtbegin?.o(.ctors)) /* We don't want to include the .ctor section from the crtend.o file until after the sorted ctors. The .ctor section from the crtend file contains the end of ctors marker and it must be last */ KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors)) KEEP (*(SORT(.ctors.*))) KEEP (*(.ctors)) } .dtors : { KEEP (*crtbegin.o(.dtors)) KEEP (*crtbegin?.o(.dtors)) KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors)) KEEP (*(SORT(.dtors.*))) KEEP (*(.dtors)) } .jcr : { KEEP (*(.jcr)) } .data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro* .gnu.linkonce.d.rel.ro.*) } . = DATA_SEGMENT_RELRO_END (0, .); .data : { __data_start = .; _fdata = . ; *(.data .data.* .gnu.linkonce.d.*) SORT(CONSTRUCTORS) } .data1 : { *(.data1) } .got.plt : { *(.got.plt) } . = .; _gp = ALIGN(16) + 0x7ff0; .got : { *(.got) } /* We want the small data sections together, so single-instruction offsets can access them all, and initialized data all before uninitialized, so we can shorten the on-disk segment size. */ .sdata : { *(.sdata .sdata.* .gnu.linkonce.s.*) } .lit8 : { *(.lit8) } .lit4 : { *(.lit4) } _edata = .; PROVIDE (edata = .); __bss_start = .; _fbss = .; .sbss : { *(.dynsbss) *(.sbss .sbss.* .gnu.linkonce.sb.*) *(.scommon) } .bss : { *(.dynbss) *(.bss .bss.* .gnu.linkonce.b.*) *(COMMON) /* Align here to ensure that the .bss section occupies space up to _end. Align after .bss to ensure correct alignment even if the .bss section disappears because there are no input sections. FIXME: Why do we need it? When there is no .bss section, we don't pad the .data section. */ . = ALIGN(. != 0 ? 32 / 8 : 1); } . = ALIGN(32 / 8); . = ALIGN(32 / 8); _end = .; PROVIDE (end = .); . = DATA_SEGMENT_END (.); /* Stabs debugging sections. */ .stab 0 : { *(.stab) } .stabstr 0 : { *(.stabstr) } .stab.excl 0 : { *(.stab.excl) } .stab.exclstr 0 : { *(.stab.exclstr) } .stab.index 0 : { *(.stab.index) } .stab.indexstr 0 : { *(.stab.indexstr) } .comment 0 : { *(.comment) } /* DWARF debug sections. Symbols in the DWARF debugging sections are relative to the beginning of the section so we begin them at 0. */ /* DWARF 1 */ .debug 0 : { *(.debug) } .line 0 : { *(.line) } /* GNU DWARF 1 extensions */ .debug_srcinfo 0 : { *(.debug_srcinfo) } .debug_sfnames 0 : { *(.debug_sfnames) } /* DWARF 1.1 and DWARF 2 */ .debug_aranges 0 : { *(.debug_aranges) } .debug_pubnames 0 : { *(.debug_pubnames) } /* DWARF 2 */ .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) } .debug_abbrev 0 : { *(.debug_abbrev) } .debug_line 0 : { *(.debug_line) } .debug_frame 0 : { *(.debug_frame) } .debug_str 0 : { *(.debug_str) } .debug_loc 0 : { *(.debug_loc) } .debug_macinfo 0 : { *(.debug_macinfo) } /* SGI/MIPS DWARF 2 extensions */ .debug_weaknames 0 : { *(.debug_weaknames) } .debug_funcnames 0 : { *(.debug_funcnames) } .debug_typenames 0 : { *(.debug_typenames) } .debug_varnames 0 : { *(.debug_varnames) } /* DWARF 3 */ .debug_pubtypes 0 : { *(.debug_pubtypes) } .debug_ranges 0 : { *(.debug_ranges) } .gnu.attributes 0 : { KEEP (*(.gnu.attributes)) } .gptab.sdata : { *(.gptab.data) *(.gptab.sdata) } .gptab.sbss : { *(.gptab.bss) *(.gptab.sbss) } .mdebug.abi32 : { KEEP(*(.mdebug.abi32)) } .mdebug.abiN32 : { KEEP(*(.mdebug.abiN32)) } .mdebug.abi64 : { KEEP(*(.mdebug.abi64)) } .mdebug.abiO64 : { KEEP(*(.mdebug.abiO64)) } .mdebug.eabi32 : { KEEP(*(.mdebug.eabi32)) } .mdebug.eabi64 : { KEEP(*(.mdebug.eabi64)) } .gcc_compiled_long32 : { KEEP(*(.gcc_compiled_long32)) } .gcc_compiled_long64 : { KEEP(*(.gcc_compiled_long64)) } /DISCARD/ : { *(.MIPS.abiflags) } /DISCARD/ : { *(.rel.dyn) } /DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) } } ================================================ FILE: lib/libc/Makefile ================================================ # # Copyright (c) 1980 Regents of the University of California. # All rights reserved. The Berkeley software License Agreement # specifies the terms and conditions for redistribution. # # Machine dependent routines are located in a subtree which parallels # the top directories. This subtree is identified by the machine name. # # Compatibility routines are kept in directories with a prefixing # ``compat'' (so they all sort together). # # The C run-time startup code is always machine dependent and expected # to be located in ../startup-${MACHINE_ARCH}. # # All files contain sccsid strings, but these are not compiled into # library objects by default, as a space-saving measure. To produce # a library that contains these strings in every object except # system call stubs, add -DLIBC_SCCS to DEFS below; to put these # strings into system call stubs, use -DSYSLIBC_SCCS. # # To compile a non-floating point versions of some standard library # routines add -DNONFP. This will speed up some operations if you don't # have hardware floating point. To compile a non-separate I&D version add # -DNONSEPARATE. # TOPSRC!=cd ../..; pwd include ${TOPSRC}/share/mk/sys.mk DEFS = -Wall -ffreestanding ALL = gen stdio stdlib string inet compat ${MACHINE_ARCH} all: ../libc.a ../libc.a: ${ALL} rm -rf tmp mkdir tmp cd tmp; for i in ${ALL}; do $(AR) x ../$$i/$$i.a; done; \ $(AR) cr ../$@ *.o # $(AR) cr ../$@ `sh ../../cmd/lorder.sh *.o | tsort` rm -rf tmp ${ALL}: FRC cd $@; ${MAKE} ${MFLAGS} DEFS="${DEFS}" FRC: install: ../libc.a # ${INSTALL} -d ${DESTDIR}/usr/lib # ${INSTALL} ../libc.a ${DESTDIR}/usr/lib/libc.a # $(RANLIB) ${DESTDIR}/usr/lib/libc.a clean: for i in ${ALL}; \ do (cd $$i; ${MAKE} ${MFLAGS} clean); done rm -rf tmp *.a *~ depend: for i in ${ALL}; \ do (cd $$i; ${MAKE} ${MFLAGS} DEFS="${DEFS}" depend); done ================================================ FILE: lib/libc/arm/Makefile ================================================ # # Copyright (c) 1987 Regents of the University of California. # All rights reserved. The Berkeley software License Agreement # specifies the terms and conditions for redistribution. # # Machine dependent routines for the Arm are located here # TOPSRC!=cd ../../..; pwd include ${TOPSRC}/share/mk/sys.mk ALL = gen string sys arm.a: ${ALL} -mkdir tmp for i in ${ALL}; do (cd tmp; $(AR) x ../$$i/$$i.a); done $(AR) cr arm.a `ls tmp/*.o | sort` rm -rf tmp ${ALL}: FRC cd $@; ${MAKE} ${MFLAGS} DEFS="${DEFS}" FRC: tags: for i in ${ALL}; do \ (cd $$i; ${MAKE} ${MFLAGS} TAGSFILE=../${TAGSFILE} tags); \ done clean: for i in ${ALL}; do (cd $$i; ${MAKE} ${MFLAGS} clean); done rm -rf *.a tmp *~ depend: for i in ${ALL}; do \ (cd $$i; ${MAKE} ${MFLAGS} DEFS="${DEFS}" depend); done ================================================ FILE: lib/libc/arm/gen/Makefile ================================================ # # Copyright (c) 1980 Regents of the University of California. # All rights reserved. The Berkeley software License Agreement # specifies the terms and conditions for redistribution. # TOPSRC!=cd ../../../..; pwd include ${TOPSRC}/share/mk/sys.mk CFLAGS += ${DEFS} SRCS = _setjmp.S htonl.S htons.S setjmp.S sigsetjmp.S OBJS = _setjmp.o htonl.o htons.o setjmp.o sigsetjmp.o gen.a: ${OBJS} @echo "building gen.a" @${AR} cr gen.a ${OBJS} tags: cwd=`pwd`; \ for i in ${SRCS}; do \ ctags -a -f ${TAGSFILE} $$cwd/$$i; \ done clean: rm -f gen.a *.o *~ profiled/*.o tags Makefile.bak depend: for i in ${SRCS}; do \ cc -M ${CFLAGS} $$i | awk ' { if ($$1 != prev) \ { if (rec != "") print rec; rec = $$0; prev = $$1; } \ else { if (length(rec $$2) > 78) { print rec; rec = $$0; } \ else rec = rec " " $$2 } } \ END { print rec } ' >> makedep; done echo '/^# DO NOT DELETE THIS LINE/+2,$$d' >eddep echo '$$r makedep' >>eddep echo 'w' >>eddep cp Makefile Makefile.bak ed - Makefile < eddep rm eddep makedep echo '# DEPENDENCIES MUST END AT END OF FILE' >> Makefile echo '# IF YOU PUT STUFF HERE IT WILL GO AWAY' >> Makefile echo '# see make depend above' >> Makefile # DO NOT DELETE THIS LINE -- make depend uses it ================================================ FILE: lib/libc/arm/gen/_setjmp.S ================================================ /* * Copyright (c) 2022 Christopher Hettrick * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ .syntax unified .thumb /* * int * _setjmp(jmp_buf env); */ .text .align 2 .thumb_func .globl _setjmp .type _setjmp, %function _setjmp: movs r1, #0 /* Not saving sigmask, env[0]=0.. */ stmia r0!, {r1} /* so _longjmp ignores sigmask. */ stmia r0!, {r1} /* Ignore sigmask, so env[1]=0. */ mov ip, sp /* Save stack pointer (via ip). */ #ifdef __thumb2__ stmia r0, {r4-r11,ip,lr} /* Save regs in env[2-11]. */ #else /* __thumb__ */ stmia r0!, {r4-r7} /* Save regs in env[2-5]. */ mov r2, r8 /* Move high regs to low.. */ mov r3, r9 mov r4, r10 mov r5, r11 mov r6, ip mov r7, lr stmia r0!, {r2-r7} /* Save regs in env[6-11]. */ subs r0, r0, #(10 * 4) /* Index back to &env[2]. */ ldmia r0!, {r4-r7} /* Bring back the low regs. */ #endif movs r0, #0 /* Always return a 0. */ bx lr .size _setjmp, . - _setjmp /* * void * _longjmp(jmp_buf env, int val); */ .text .align 2 .thumb_func .globl _longjmp .type _longjmp, %function _longjmp: adds r0, r0, #(2 * 4) /* Skip savesigs and signal mask. */ #ifdef __thumb2__ ldmia r0, {r4-r11,ip,lr} /* Restore regs from env[2-11]. */ #else /* __thumb__ */ adds r0, r0, #(4 * 4) /* Index to &env[6]. */ ldmia r0!, {r2-r7} /* Restore regs from env[6-11]. */ mov r8, r2 /* Move low regs to high.. */ mov r9, r3 mov r10, r4 mov r11, r5 mov ip, r6 mov lr, r7 subs r0, r0, #(10 * 4) /* Index back to &env[2]. */ ldmia r0!, {r4-r7} /* Restore regs from env[2-5]. */ #endif mov sp, ip /* Restore stack pointer (via ip). */ movs r0, r1 /* Return val.. */ cmp r0, #0 /* but first test if val is 0.. */ bne 1f movs r0, #1 /* and return a 1 if val is 0. */ 1: bx lr .size _longjmp, . - _longjmp ================================================ FILE: lib/libc/arm/gen/htonl.S ================================================ /* * Copyright (c) 2022 Christopher Hettrick * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ .syntax unified .thumb /* * uint32_t * htonl(uint32_t host32); * * Host order -> Network order * 0x78.56.34.12 -> 0x12.34.56.78 */ .text .align 2 .thumb_func .globl htonl .type htonl, %function htonl: rev r0, r0 /* Swap byte order in 32-bit word. */ bx lr .size htonl, . - htonl /* * uint32_t * ntohl(uint32_t net32); * * Network order -> Host order * 0x12.34.56.78 -> 0x78.56.34.12 */ .text .align 2 .thumb_func .globl ntohl .type ntohl, %function ntohl: rev r0, r0 /* Swap byte order in 32-bit word. */ bx lr .size ntohl, . - ntohl ================================================ FILE: lib/libc/arm/gen/htons.S ================================================ /* * Copyright (c) 2022 Christopher Hettrick * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ .syntax unified .thumb /* * uint16_t * htons(uint16_t host16); * * Host order -> Half-word rev -> Network order * 0x78.56.34.12 -> 0x56.78.12.34 -> 0x00.00.12.34 * * Note: host16 parameter is a half-word, but registers are 32-bit words. */ .text .align 2 .thumb_func .globl htons .type htons, %function htons: rev16 r0, r0 /* Swap bytes in each half-word. */ uxth r0, r0 /* Unsigned extend half-word to word. */ bx lr .size htons, . - htons /* * uint16_t * ntohs(uint16_t net16); * * Network order -> Half-word rev -> Host order * 0x12.34.56.78 -> 0x34.12.78.56 -> 0x00.00.78.56 * * Note: net16 parameter is a half-word, but registers are 32-bit words. */ .text .align 2 .thumb_func .globl ntohs .type ntohl, %function ntohs: rev16 r0, r0 /* Swap bytes in each half-word. */ uxth r0, r0 /* Unsigned extend half-word to word. */ bx lr .size ntohs, . - ntohs ================================================ FILE: lib/libc/arm/gen/setjmp.S ================================================ /* * Copyright (c) 2022 Christopher Hettrick * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ .syntax unified .thumb /* * int * setjmp(jmp_buf env); */ .text .align 2 .thumb_func .globl setjmp .type setjmp, %function setjmp: push {lr} /* Save return address. */ movs r1, #1 /* When saving sigmask, env[0]=1.. */ str r1, [r0] /* so longjmp restores sigmask; */ adds r0, r0, #(2 * 4) /* skip over sigmask in env[1]. */ mov r1, r0 /* Save env for sigprocmask. */ mov ip, sp /* Save stack pointer (via ip). */ #ifdef __thumb2__ stmia r0, {r4-r11,ip,lr} /* Save regs in env[2-11]. */ #else /* __thumb__ */ stmia r0!, {r4-r7} /* Save regs in env[2-5]. */ mov r2, r8 /* Move high regs to low.. */ mov r3, r9 mov r4, r10 mov r5, r11 mov r6, ip mov r7, lr stmia r0!, {r2-r7} /* Save regs in env[6-11]. */ subs r0, r0, #(10 * 4) /* Index back to &env[2]. */ ldmia r0!, {r4-r7} /* Bring back the low regs. */ #endif subs r2, r1, #(1 * 4) /* &env[1] signal mask for oset. */ movs r1, #0 /* Null for set. Mask is unchanged. */ movs r0, #1 /* SIG_BLOCK, but how is irrelevant. */ bl sigprocmask /* Get current sigmask into env[1]. */ movs r0, #0 /* Always return a 0. */ pop {pc} /* Return to whence we came. */ .size setjmp, . - setjmp /* * void * longjmp(jmp_buf env, int val); */ .text .align 2 .thumb_func .globl longjmp .type longjmp, %function longjmp: mov r3, r0 /* Save env before sigprocmask. */ movs r2, #0 /* Null for oset. */ adds r1, r0, #(1 * 4) /* &env[1] signal mask for set. */ movs r0, #3 /* SIG_SETMASK for how. */ bl sigprocmask /* Restore sigmask from env[1]. */ mov r0, r3 /* Restore env after sigprocmask. */ adds r0, r0, #(2 * 4) /* Skip savesigs and signal mask. */ #ifdef __thumb2__ ldmia r0, {r4-r11,ip,lr} /* Restore regs from env[2-11]. */ #else /* __thumb__ */ adds r0, r0, #(4 * 4) /* Index to &env[6]. */ ldmia r0!, {r2-r7} /* Restore regs from env[6-11]. */ mov r8, r2 /* Move low regs to high.. */ mov r9, r3 mov r10, r4 mov r11, r5 mov ip, r6 mov lr, r7 subs r0, r0, #(10 * 4) /* Index back to &env[2]. */ ldmia r0!, {r4-r7} /* Restore regs from env[2-5]. */ #endif mov sp, ip /* Restore stack pointer (via ip). */ movs r0, r1 /* Return val.. */ cmp r0, #0 /* but first test if val is 0.. */ bne 1f movs r0, #1 /* and return a 1 if val is 0. */ 1: bx lr .size longjmp, . - longjmp ================================================ FILE: lib/libc/arm/gen/sigsetjmp.S ================================================ /* * Copyright (c) 2022 Christopher Hettrick * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ .syntax unified .thumb /* * int * sigsetjmp(sigjmp_buf env, int savesigs); */ .text .align 2 .thumb_func .globl sigsetjmp .type sigsetjmp, %function sigsetjmp: cmp r1, #0 /* If savesigs is zero.. */ bne 1f ldr r3, =_setjmp /* skip signal mask handling; */ bx r3 1: ldr r3, =setjmp /* else handle signal mask. */ bx r3 .size sigsetjmp, . - sigsetjmp /* * void * siglongjmp(sigjmp_buf env, int val); */ .text .align 2 .thumb_func .globl siglongjmp .type siglongjmp, %function siglongjmp: ldr r2, [r0] /* Get savesigs. */ cmp r2, #0 /* If savesigs was zero.. */ bne 1f ldr r3, =_longjmp /* skip signal mask handling; */ bx r3 1: ldr r3, =longjmp /* else handle signal mask. */ bx r3 .size siglongjmp, . - siglongjmp ================================================ FILE: lib/libc/arm/string/Makefile ================================================ # # Copyright (c) 1980 Regents of the University of California. # All rights reserved. The Berkeley software License Agreement # specifies the terms and conditions for redistribution. # TOPSRC!=cd ../../../..; pwd include ${TOPSRC}/share/mk/sys.mk CFLAGS += ${DEFS} SRCS = memmove.S strcmp.S OBJS = memmove.o strcmp.o string.a: ${OBJS} @echo "building string.a" @${AR} cr string.a ${OBJS} tags: cwd=`pwd`; \ for i in ${SRCS}; do \ ctags -a -f ${TAGSFILE} $$cwd/$$i; \ done clean: rm -f string.a *.o *~ profiled/*.o tags Makefile.bak depend: for i in ${SRCS}; do \ cc -M ${CFLAGS} $$i | awk ' { if ($$1 != prev) \ { if (rec != "") print rec; rec = $$0; prev = $$1; } \ else { if (length(rec $$2) > 78) { print rec; rec = $$0; } \ else rec = rec " " $$2 } } \ END { print rec } ' >> makedep; done echo '/^# DO NOT DELETE THIS LINE/+2,$$d' >eddep echo '$$r makedep' >>eddep echo 'w' >>eddep cp Makefile Makefile.bak ed - Makefile < eddep rm eddep makedep echo '# DEPENDENCIES MUST END AT END OF FILE' >> Makefile echo '# IF YOU PUT STUFF HERE IT WILL GO AWAY' >> Makefile echo '# see make depend above' >> Makefile # DO NOT DELETE THIS LINE -- make depend uses it ================================================ FILE: lib/libc/arm/string/memmove.S ================================================ /* * Copyright (c) 2015 ARM Ltd * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the company may not be used to endorse or promote * products derived from this software without specific prior written * permission. * * THIS SOFTWARE IS PROVIDED BY ARM LTD ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL ARM LTD BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ .syntax unified .thumb .text .align 2 .thumb_func .globl memmove .type memmove, %function memmove: push {r4, lr} cmp r0, r1 bls 3f adds r4, r1, r2 cmp r0, r4 bcs 3f subs r3, r2, #1 cmp r2, #0 beq 2f subs r2, r4, r2 1: ldrb r1, [r2, r3] strb r1, [r0, r3] subs r3, r3, #1 bcs 1b 2: pop {r4, pc} 3: movs r3, #0 cmp r2, #0 beq 2b 4: ldrb r4, [r1, r3] strb r4, [r0, r3] adds r3, r3, #1 cmp r2, r3 bne 4b b 2b .size memmove, . - memmove ================================================ FILE: lib/libc/arm/string/strcmp.S ================================================ /* * Copyright (c) 2012-2014 ARM Ltd * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the company may not be used to endorse or promote * products derived from this software without specific prior written * permission. * * THIS SOFTWARE IS PROVIDED BY ARM LTD ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL ARM LTD BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ .syntax unified .thumb .text .align 2 .thumb_func .globl strcmp .type strcmp, %function strcmp: 1: #ifdef __thumb2__ /* Tiny version of strcmp in ARM state. Used only when optimizing for size. Also supports Thumb-2. */ ldrb r2, [r0], #1 ldrb r3, [r1], #1 cmp r2, #1 it cs cmpcs r2, r3 beq 1b #else /* __thumb__ */ /* This version is only used when we want a very basic Thumb1 implementation or for size, otherwise we use the base ARMv4 version. This is also suitable for ARMv6-M. */ ldrb r2, [r0] ldrb r3, [r1] cmp r2, #0 beq 2f adds r0, r0, #1 adds r1, r1, #1 cmp r2, r3 beq 1b #endif 2: subs r0, r2, r3 bx lr .size strcmp, . - strcmp ================================================ FILE: lib/libc/arm/sys/Makefile ================================================ TOPSRC!=cd ../../../..; pwd include ${TOPSRC}/share/mk/sys.mk ASFLAGS += ${DEFS} CFLAGS += -Os # modules which can not use SYSCALL and must be assembled from sources. The # rest of the system calls are generated with printf(1) and do not have # source files associated with them. COBJS = sbrk.o execl.o execle.o execv.o ASMOBJS = _exit.o _brk.o pipe.o ptrace.o sigaction.o SYSOBJS = __sysctl.o accept.o access.o adjtime.o bind.o chdir.o \ chflags.o chmod.o chown.o chroot.o close.o connect.o dup.o \ dup2.o execve.o fchdir.o fchflags.o fchmod.o fchown.o \ fcntl.o flock.o fork.o fstat.o fsync.o ftruncate.o \ getdtablesize.o getgroups.o getitimer.o getsockname.o \ getpeername.o getpriority.o getrlimit.o getrusage.o getsockopt.o \ gettimeofday.o ioctl.o kill.o killpg.o link.o listen.o lstat.o mkdir.o \ mknod.o mount.o open.o pselect.o quota.o read.o readlink.o readv.o \ reboot.o \ recv.o recvfrom.o recvmsg.o rename.o rmdir.o select.o send.o sendmsg.o \ sendto.o setgroups.o setitimer.o setpgrp.o setpriority.o setquota.o \ setuid.o seteuid.o setgid.o setegid.o \ setrlimit.o setsockopt.o settimeofday.o shutdown.o \ sigaltstack.o socket.o socketpair.o stat.o symlink.o \ sigprocmask.o sigstack.o sigwait.o \ statfs.o fstatfs.o getfsstat.o \ truncate.o umount.o unlink.o utimes.o wait4.o write.o writev.o \ lseek.o sigsuspend.o \ getgid.o getegid.o getpgrp.o getpid.o \ getppid.o getuid.o geteuid.o profil.o sigpending.o sync.o \ ufetch.o ustore.o ucall.o umask.o vfork.o vhangup.o \ rdglob.o wrglob.o msec.o kmemdev.o OBJS = ${COBJS} ${ASMOBJS} ${SYSOBJS} TAGSFILE = tags sys.a: ${OBJS} @echo "building sys.a" @${AR} cr sys.a ${OBJS} ${SYSOBJS}: SYS.h # @echo creating $*.o @printf '#include "SYS.h"\nSYS($*)\n' | $(AS) ${ASFLAGS} - -c -o $*.o clean: rm -f *~ *.o a.out sys.a ================================================ FILE: lib/libc/arm/sys/SYS.h ================================================ /* * Copyright (c) 2022 Christopher Hettrick * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include #define ENTRY(x) \ .text; \ .align 2; \ .thumb_func; \ .globl x; \ .type x, %function; \ x: #define END(x) \ .size x, . - x #define SYS(x) \ ENTRY(x); \ svc #SYS_##x; \ bcs 1f; \ bx lr; \ 1: ldr r1, =errno; \ str r0, [r1]; \ mov r0, #0; \ mvn r0, r0; \ bx lr; \ END(x) ================================================ FILE: lib/libc/arm/sys/_brk.S ================================================ /* * Copyright (c) 2022 Christopher Hettrick * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include "SYS.h" ENTRY(_brk) svc #SYS_sbrk bcs 1f /* Error if carry set. */ bx lr /* Success return. */ 1: ldr r1, =errno str r0, [r1] mov r0, #0 mvn r0, r0 bx lr /* Error return. */ END(_brk) ================================================ FILE: lib/libc/arm/sys/_exit.S ================================================ /* * Copyright (c) 1987 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include "SYS.h" ENTRY(_exit) svc #SYS_exit END(_exit) ================================================ FILE: lib/libc/arm/sys/execl.c ================================================ /* * Copyright (c) 1987 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include extern char **environ; int execl (const char *name, const char *arg, ...) { return execve (name, (char *const*) &arg, environ); } ================================================ FILE: lib/libc/arm/sys/execle.c ================================================ /* * Copyright (c) 1987 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include #include int execle (const char *name, const char *arg, ...) { va_list ap; char **envp; va_start (ap, arg); while ((va_arg (ap, char *)) != NULL) continue; envp = va_arg (ap, char **); va_end (ap); return execve (name, (char *const*) &arg, envp); } ================================================ FILE: lib/libc/arm/sys/execv.c ================================================ /* * Copyright (c) 1987 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include extern char **environ; int execv (name, argv) const char *name; char *const *argv; { return execve (name, argv, environ); } ================================================ FILE: lib/libc/arm/sys/pipe.S ================================================ /* * Copyright (c) 2022 Christopher Hettrick * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include "SYS.h" ENTRY(pipe) mov r3, r0 /* Copy &filedes[0] to r3. */ svc #SYS_pipe bcs 1f /* Error if carry set. */ str r0, [r3, #0] /* Save read fd in &filedes[0]. */ str r1, [r3, #4] /* Save write fd in &filedes[1]. */ mov r0, #0 bx lr /* Success return. */ 1: ldr r1, =errno str r0, [r1] mov r0, #0 mvn r0, r0 bx lr /* Error return. */ END(pipe) ================================================ FILE: lib/libc/arm/sys/ptrace.S ================================================ /* * Copyright (c) 1987 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include "SYS.h" ENTRY(ptrace) #if 0 /* XXX Arm ASM */ # -1 is a legitimate return # value so we must clear errno # so the caller may disambiguate lui $t1, %hi(errno) sw $zero, %lo(errno)($t1) .set noreorder syscall SYS_ptrace lui $t1, %hi(errno) # return here on error sw $t0, %lo(errno)($t1) .set reorder jr $ra # return here on success #endif /* XXX Arm ASM */ ================================================ FILE: lib/libc/arm/sys/sbrk.c ================================================ /* * Copyright (c) 1987 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include extern char _end[]; const char *_curbrk = _end; void * sbrk (incr) int incr; { void *oldbrk = (void*) _curbrk; if (incr != 0) { /* calculate and pass break address */ const void *addr = _curbrk + incr; if (_brk (addr) != -1) { /* add increment to curbrk */ _curbrk = addr; } } /* return old break address */ return oldbrk; } void * brk (addr) const void *addr; { int ret; if (addr < (void*) _end) /* break request too low? */ addr = _end; /* yes, knock the request up to _end */ ret = _brk (addr); /* ask for break */ if (ret != -1) _curbrk = addr; /* and remember it if it succeeded */ return (void*) ret; } ================================================ FILE: lib/libc/arm/sys/sigaction.S ================================================ /* * Copyright (c) 1987 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include "SYS.h" /* * error = sigaction(sig, vec, ovec) * int error, sig; * struct sigaction *vec, *ovec; * * We pass one additional parameter to the sigaction sys call: the address of * the "Trampoline Code", sigtramp - the code that handles saving and restoring * register context and so on for signals. On the VAX-11 under BSD4.3 it isn't * necessary to pass this address since the trampoline code is stored in the * user structure in u.u_pcb.pcb_sigc at a known address in user space. It * really doesn't introduce much extra overhead, so our method for doing it on * a PDP-11 is alright too. */ ENTRY(sigaction) ldr r3, =sigtramp /* arg4: address of sigtramp. */ svc SYS_sigaction bcs 1f /* Error if carry set. */ bx lr /* Success return. */ 1: ldr r1, =errno str r0, [r1] mov r0, #0 mvn r0, r0 bx lr /* Error return. */ END(sigaction) /* * sigtramp - Signal "Trampoline Code" * * This code is transfered to by the kernel when a signal is delivered to a * process. In general, the idea is that sigtramp saves the process' register * context and then vectors on to the real signal action routine. Upon return * from the signal action routine sigtramp restores the process' register * context and performs a sigreturn. * * In the case of the PDP-11, the kernel will have already saved r0 and r1 for * sigtramp in a sigcontext structure it passes to us. Sigtramp vectors onto * the signal action routine whose address has been left in r0 by the kernel * (sigtramp assumes the signal action routine will save any other registers * it uses (as all C routines will)). Upon return from the signal action * routine, sigtramp will execute a sigreturn with the sigcontext structure * given to us by the kernel. * * When the kernel transfers control to sigtramp the stack looks like: * * ------------------------- * | sigcontext structure | SIG_SC = sp + 8 * |-----------------------| * | unused | * |-----------------------| * | $a3: ptr to sigcontext| * |-----------------------| * | $a2: code | * |-----------------------| *sp -> | $a1: signal number | * ------------------------- * * The important features of this as far as sigtramp is concerned are: * 1. The fact that the signal number, signal code, and signal context * pointer are already set up as parameters to the signal action * routine. * 2. There's no need to save r0 & r1 because the kernel's already saved * them for us in the sigcontext structure (C routines save all * registers except r0 & r1 automatically). * * Note that the stack offset SIG_SC will NOT have to be recomputed if the * sigcontext structure changes. */ ENTRY(sigtramp) svc SYS_sigreturn /* Attempt the sigreturn. */ svc SYS_exit /* Die if the sigreturn fails ... */ END(sigtramp) ================================================ FILE: lib/libc/compat/Makefile ================================================ # # Copyright (c) 1980 Regents of the University of California. # All rights reserved. The Berkeley software License Agreement # specifies the terms and conditions for redistribution. # TOPSRC!=cd ../../..; pwd include ${TOPSRC}/share/mk/sys.mk CFLAGS += ${DEFS} -Os SRCS = creat.c ftime.c gethostid.c memccpy.c memchr.c memcmp.c \ memcpy.c memset.c nice.c pause.c rand.c sethostid.c \ setregid.c setreuid.c setrgid.c setruid.c sigcompat.c \ strchr.c strrchr.c times.c tmpnam.c utime.c OBJS = creat.o ftime.o gethostid.o memccpy.o memchr.o memcmp.o \ memcpy.o memset.o nice.o pause.o rand.o sethostid.o \ setregid.o setreuid.o setrgid.o setruid.o sigcompat.o \ strchr.o strrchr.o times.o tmpnam.o utime.o compat.a: ${OBJS} @echo "building compat.a" @${AR} cr compat.a ${OBJS} tags: cwd=`pwd`; \ for i in ${SRCS}; do \ ctags -a -f ${TAGSFILE} $$cwd/$$i; \ done clean: rm -f compat.a *.o *~ profiled/*.o tags Makefile.bak depend: for i in ${SRCS}; do \ cc -M ${CFLAGS} $$i | awk ' { if ($$1 != prev) \ { if (rec != "") print rec; rec = $$0; prev = $$1; } \ else { if (length(rec $$2) > 78) { print rec; rec = $$0; } \ else rec = rec " " $$2 } } \ END { print rec } ' >> makedep; done echo '/^# DO NOT DELETE THIS LINE/+2,$$d' >eddep echo '$$r makedep' >>eddep echo 'w' >>eddep cp Makefile Makefile.bak ed - Makefile < eddep rm eddep makedep echo '# DEPENDENCIES MUST END AT END OF FILE' >> Makefile echo '# IF YOU PUT STUFF HERE IT WILL GO AWAY' >> Makefile echo '# see make depend above' >> Makefile # DO NOT DELETE THIS LINE -- make depend uses it ================================================ FILE: lib/libc/compat/creat.c ================================================ /* * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include int creat (path, mode) const char *path; mode_t mode; { return open (path, O_WRONLY | O_CREAT | O_TRUNC, mode); } ================================================ FILE: lib/libc/compat/ftime.c ================================================ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include #include /* * Backwards compatible ftime. */ /* from old timeb.h */ struct timeb { time_t time; u_short millitm; short timezone; short dstflag; }; int ftime(tp) register struct timeb *tp; { struct timeval t; struct timezone tz; if (gettimeofday(&t, &tz) < 0) return (-1); tp->time = t.tv_sec; tp->millitm = t.tv_usec / 1000; tp->timezone = tz.tz_minuteswest; tp->dstflag = tz.tz_dsttime; return 0; } ================================================ FILE: lib/libc/compat/gethostid.c ================================================ /* * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #include u_long gethostid() { int mib[2]; size_t size; u_long value; mib[0] = CTL_KERN; mib[1] = KERN_HOSTID; size = sizeof value; if (sysctl(mib, 2, &value, &size, NULL, 0) == -1) return (-1); return (value); } ================================================ FILE: lib/libc/compat/memccpy.c ================================================ /* * Copyright (c) 1985 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include /* * Sys5 compat routine */ void * memccpy(vt, vf, c, n) void *vt; const void *vf; register int c; register size_t n; { register char *t = vt; register const char *f = vf; while (n-- > 0) if ((*t++ = *f++) == c) return (t); return (0); } ================================================ FILE: lib/libc/compat/memchr.c ================================================ /* * Copyright (c) 1985 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include /* * Sys5 compat routine */ void * memchr(vs, c, n) const void *vs; register int c; register size_t n; { register const char *s = vs; while (n-- > 0) if (*s++ == c) return (void*) --s; return (0); } ================================================ FILE: lib/libc/compat/memcmp.c ================================================ /* * Copyright (c) 1985 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include /* * Sys5 compat routine */ int memcmp (vs1, vs2, n) const void *vs1, *vs2; register size_t n; { register const char *s1 = vs1, *s2 = vs2; while (n-- > 0) if (*s1++ != *s2++) return (*--s1 - *--s2); return (0); } ================================================ FILE: lib/libc/compat/memcpy.c ================================================ /* * Copyright (c) 1985 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include /* * Sys5 compat routine */ void * memcpy (vt, vf, n) void *vt; const void *vf; register size_t n; { register char *t = vt; register const char *f = vf; while (n-- > 0) *t++ = *f++; return vt; } ================================================ FILE: lib/libc/compat/memset.c ================================================ /* * Copyright (c) 1985 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include /* * Sys5 compat routine */ void * memset (vs, c, n) void *vs; register int c; register size_t n; { register char *s = vs; while (n-- > 0) *s++ = c; return vs; } ================================================ FILE: lib/libc/compat/nice.c ================================================ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include #include /* * Backwards compatible nice. */ int nice(incr) int incr; { int prio; extern int errno; errno = 0; prio = getpriority(PRIO_PROCESS, 0); if (prio == -1 && errno) return (-1); return setpriority(PRIO_PROCESS, 0, prio + incr); } ================================================ FILE: lib/libc/compat/pause.c ================================================ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include /* * Backwards compatible pause. */ int pause() { sigset_t set; (void)sigemptyset(&set); sigsuspend(&set); return 0; } ================================================ FILE: lib/libc/compat/rand.c ================================================ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ static long randx = 1; void srand(x) unsigned x; { randx = x; } int rand() { randx = randx * 1103515245 + 12345; return (randx >> 16) & 0x7fff; } ================================================ FILE: lib/libc/compat/sethostid.c ================================================ /* * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #include u_long sethostid(hostid) u_long hostid; { int mib[2]; mib[0] = CTL_KERN; mib[1] = KERN_HOSTID; if (sysctl(mib, 2, NULL, NULL, &hostid, sizeof hostid) == -1) return (-1); return (0); } ================================================ FILE: lib/libc/compat/setregid.c ================================================ /* * Copyright (c) 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #include #include int setregid(rgid, egid) register gid_t rgid, egid; { static gid_t savedgid = -1; if (savedgid == -1) savedgid = getegid(); /* * we assume that the intent here is to be able to * get back rgid priviledge. So we make sure that * we will be able to do so, but do not actually * set the rgid. */ if (rgid != -1 && rgid != getgid() && rgid != savedgid) { errno = EPERM; return (-1); } if (egid != -1 && setegid(egid) < 0) return (-1); return (0); } ================================================ FILE: lib/libc/compat/setreuid.c ================================================ /* * Copyright (c) 1992, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #include #include int setreuid(ruid, euid) register uid_t ruid, euid; { static uid_t saveduid = -1; if (saveduid == -1) saveduid = geteuid(); /* * we assume that the intent here is to be able to * get back ruid priviledge. So we make sure that * we will be able to do so, but do not actually * set the ruid. */ if (ruid != -1 && ruid != getuid() && ruid != saveduid) { errno = EPERM; return (-1); } if (euid != -1 && seteuid(euid) < 0) return (-1); return (0); } ================================================ FILE: lib/libc/compat/setrgid.c ================================================ /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include int setrgid(rgid) int rgid; { return (setregid(rgid, -1)); } ================================================ FILE: lib/libc/compat/setruid.c ================================================ /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include int setruid(ruid) int ruid; { return (setreuid(ruid, -1)); } ================================================ FILE: lib/libc/compat/sigcompat.c ================================================ /* * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #include int sigvec(signo, sv, osv) int signo; register struct sigvec *sv, *osv; { int ret; if (sv) sv->sv_flags ^= SV_INTERRUPT; /* !SA_INTERRUPT */ ret = sigaction(signo, (struct sigaction *)sv, (struct sigaction *)osv); if (ret == 0 && osv) osv->sv_flags ^= SV_INTERRUPT; /* !SA_INTERRUPT */ return(ret); } int sigsetmask(mask) int mask; { long omask; int n; n = sigprocmask(SIG_SETMASK, (sigset_t *) &mask, (sigset_t *) &omask); if (n) return((long)n); return(omask); } int sigblock(mask) int mask; { long omask; int n; n = sigprocmask(SIG_BLOCK, (sigset_t *) &mask, (sigset_t *) &omask); if (n) return((long)n); return(omask); } int sigpause(mask) int mask; { return(sigsuspend((sigset_t *)&mask)); } ================================================ FILE: lib/libc/compat/strchr.c ================================================ /* * Return the ptr in sp at which the character c appears; * NULL if not found * * this routine is just "index" renamed. */ char * strchr (sp, c) register const char *sp; register int c; { do { if (*sp == c) return (char*) sp; } while (*sp++); return 0; } ================================================ FILE: lib/libc/compat/strrchr.c ================================================ /* * Return the ptr in sp at which the character c last * appears; NULL if not found * * This routine is just "rindex" renamed. */ char * strrchr(sp, c) register const char *sp; register int c; { register char *r; r = 0; do { if (*sp == c) r = (char*) sp; } while (*sp++); return(r); } ================================================ FILE: lib/libc/compat/times.c ================================================ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include #include #include #include static long scale60(tvp) register struct timeval *tvp; { return (tvp->tv_sec * 60 + tvp->tv_usec / 16667); } int times(tmsp) register struct tms *tmsp; { struct rusage ru; long scale60(); if (getrusage(RUSAGE_SELF, &ru) < 0) return (-1); tmsp->tms_utime = scale60(&ru.ru_utime); tmsp->tms_stime = scale60(&ru.ru_stime); if (getrusage(RUSAGE_CHILDREN, &ru) < 0) return (-1); tmsp->tms_cutime = scale60(&ru.ru_utime); tmsp->tms_cstime = scale60(&ru.ru_stime); return (0); } ================================================ FILE: lib/libc/compat/tmpnam.c ================================================ /* * Copyright (c) 1988 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the University of California, Berkeley. The name of the * University may not be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #include #include #include #include #include #include FILE * tmpfile() { FILE *fp; char *f, *tmpnam(); if (!(f = tmpnam((char *)NULL)) || !(fp = fopen(f, "w+"))) { fprintf(stderr, "tmpfile: cannot open %s.\n", f); return(NULL); } (void)unlink(f); return(fp); } char * tmpnam(s) char *s; { if (!s && !(s = malloc((u_int)MAXPATHLEN))) return(NULL); strcpy(s, _PATH_USRTMP "XXXXXX"); return mktemp(s); } char * tempnam(dir, pfx) char *dir, *pfx; { char *f, *name; if (!(name = malloc((u_int)MAXPATHLEN))) return(NULL); f = getenv("TMPDIR"); if (f) { (void)sprintf(name, "%s/%sXXXXXX", f, pfx ? "" : pfx); f = mktemp(name); if (f) return(f); } if (dir) { (void)sprintf(name, "%s/%sXXXXXX", dir, pfx ? "" : pfx); f = mktemp(name); if (f) return(f); } (void)sprintf(name, _PATH_USRTMP "%sXXXXXX", pfx ? "" : pfx); f = mktemp(name); if (f) return(f); (void)sprintf(name, "/tmp/%sXXXXXX", pfx ? "" : pfx); return(mktemp(name)); } ================================================ FILE: lib/libc/compat/utime.c ================================================ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include #include /* * Backwards compatible utime. */ int utime(name, otv) char *name; time_t otv[]; { struct timeval tv[2]; tv[0].tv_sec = otv[0]; tv[0].tv_usec = 0; tv[1].tv_sec = otv[1]; tv[1].tv_usec = 0; return utimes(name, tv); } ================================================ FILE: lib/libc/gen/Makefile ================================================ # # Copyright (c) 1980 Regents of the University of California. # All rights reserved. The Berkeley software License Agreement # specifies the terms and conditions for redistribution. # TOPSRC!=cd ../../..; pwd include ${TOPSRC}/share/mk/sys.mk CFLAGS += ${DEFS} -Os -Wno-attributes -Wno-attribute-alias SRCS = ${STDSRC} OBJS = ${STDOBJ} STDSRC = abort.c alarm.c atof.c atoi.c atol.c \ basename.c bcmp.c bcopy.c \ bzero.c calloc.c closedir.c crypt.c ctime.c ctype_.c \ daemon.c devname.c dirname.c \ ecvt.c err.c execvp.c fakcu.c ffs.c \ frexp.c fstab.c gcvt.c getenv.c getgrent.c getgrgid.c \ getgrnam.c getgrouplist.c gethostname.c getloadavg.c \ getlogin.c getmntinfo.c getpagesize.c getpass.c \ getpwent.c getttyent.c getttynam.c getusershell.c \ getwd.c index.c initgroups.c isatty.c isinff.c isnanf.c \ knlist.c ldexp.c malloc.c mktemp.c modff.c ndbm.c \ nlist.c opendir.c perror.c popen.c psignal.c qsort.c \ random.c readdir.c regex.c rindex.c scandir.c seekdir.c \ setenv.c sethostname.c setmode.c siginterrupt.c \ siglist.c signal.c sigsetops.c sleep.c strcasecmp.c \ strcat.c strcmp.c strcpy.c strdup.c strftime.c strlen.c \ strncat.c strncmp.c strncpy.c swab.c sysctl.c syslog.c \ system.c telldir.c time.c timezone.c ttyname.c ttyslot.c \ ualarm.c uname.c usleep.c wait.c wait3.c waitpid.c STDOBJ = abort.o alarm.o atof.o atoi.o atol.o \ basename.o bcmp.o bcopy.o \ bzero.o calloc.o closedir.o crypt.o ctime.o ctype_.o \ daemon.o devname.o dirname.o \ ecvt.o err.o execvp.o fakcu.o ffs.o \ frexp.o fstab.o gcvt.o getenv.o getgrent.o getgrgid.o \ getgrnam.o getgrouplist.o gethostname.o getloadavg.o \ getlogin.o getmntinfo.o getpagesize.o getpass.o \ getpwent.o getttyent.o getttynam.o getusershell.o \ getwd.o index.o initgroups.o isatty.o isinff.o isnanf.o \ knlist.o ldexp.o malloc.o mktemp.o modff.o ndbm.o \ nlist.o opendir.o perror.o popen.o psignal.o qsort.o \ random.o readdir.o regex.o rindex.o scandir.o seekdir.o \ setenv.o sethostname.o setmode.o siginterrupt.o \ siglist.o signal.o sigsetops.o sleep.o strcasecmp.o \ strcat.o strcmp.o strcpy.o strdup.o strftime.o strlen.o \ strncat.o strncmp.o strncpy.o swab.o sysctl.o syslog.o \ system.o telldir.o time.o timezone.o ttyname.o ttyslot.o \ ualarm.o uname.o usleep.o wait.o wait3.o waitpid.o gen.a: ${OBJS} @echo "building gen.a" @${AR} cr gen.a ${OBJS} tags: cwd=`pwd`; \ for i in ${SRCS}; do \ ctags -a -f ${TAGSFILE} $$cwd/$$i; \ done clean: rm -f gen.a *.o *~ profiled/*.o tags Makefile.bak depend: for i in ${SRCS}; do \ cc -M ${CFLAGS} $$i | awk ' { if ($$1 != prev) \ { if (rec != "") print rec; rec = $$0; prev = $$1; } \ else { if (length(rec $$2) > 78) { print rec; rec = $$0; } \ else rec = rec " " $$2 } } \ END { print rec } ' >> makedep; done echo '/^# DO NOT DELETE THIS LINE/+2,$$d' >eddep echo '$$r makedep' >>eddep echo 'w' >>eddep cp Makefile Makefile.bak ed - Makefile < eddep rm eddep makedep echo '# DEPENDENCIES MUST END AT END OF FILE' >> Makefile echo '# IF YOU PUT STUFF HERE IT WILL GO AWAY' >> Makefile echo '# see make depend above' >> Makefile # DO NOT DELETE THIS LINE -- make depend uses it ================================================ FILE: lib/libc/gen/abort.c ================================================ /* * Copyright (c) 1985, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #include #include void abort() { sigset_t mask; (void)sigfillset(&mask); /* * don't block SIGABRT to give any handler a chance; we ignore * any errors -- X311J doesn't allow abort to return anyway. */ (void)sigdelset(&mask, SIGABRT); (void)sigprocmask(SIG_SETMASK, &mask, (sigset_t *)NULL); (void)kill(getpid(), SIGABRT); /* * if SIGABRT ignored, or caught and the handler returns, do * it again, only harder. */ (void)signal(SIGABRT, SIG_DFL); (void)sigprocmask(SIG_SETMASK, &mask, (sigset_t *)NULL); (void)kill(getpid(), SIGABRT); exit(1); } ================================================ FILE: lib/libc/gen/abs.c ================================================ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ abs(arg) int arg; { return(arg < 0 ? -arg : arg); } ================================================ FILE: lib/libc/gen/alarm.c ================================================ /* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ /* * Backwards compatible alarm. */ #include int alarm(secs) int secs; { struct itimerval it, oitv; register struct itimerval *itp = ⁢ timerclear(&itp->it_interval); itp->it_value.tv_sec = secs; itp->it_value.tv_usec = 0; if (setitimer(ITIMER_REAL, itp, &oitv) < 0) return (-1); if (oitv.it_value.tv_usec) oitv.it_value.tv_sec++; return (oitv.it_value.tv_sec); } ================================================ FILE: lib/libc/gen/atof.c ================================================ /* * C library - ascii to floating * Copyright (c) 1987 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include #include #include /* * BIG = 2**(DBL_MANT_DIG+3) defines how many decimal digits * to take into account from the input. It doesn't make sense * to use more digits than log10(2**DBL_MANT_DIG)+1. * BIG is equal 2**27 or 2**56, depending on whether double * is single or double precision. */ #define BIG (8 * (double)(1L << (DBL_MANT_DIG/2)) * \ (double)(1L << (DBL_MANT_DIG/2 + DBL_MANT_DIG%2))) double atof(p) register char *p; { register int c; double fl, flexp, exp5; double big = BIG; int nd; register int eexp, exp, neg, negexp, bexp; neg = 1; while((c = *p++) == ' ') ; if (c == '-') neg = -1; else if (c=='+') ; else --p; exp = 0; fl = 0; nd = 0; while ((c = *p++), isdigit(c)) { if (fl>= 1; if (exp==0) break; exp5 *= exp5; } if (negexp<0) fl /= flexp; else fl *= flexp; fl = ldexp(fl, negexp*bexp); if (neg<0) fl = -fl; return(fl); } ================================================ FILE: lib/libc/gen/atoi.c ================================================ int atoi(p) register char *p; { register int n; register int f; n = 0; f = 0; for(;;p++) { switch(*p) { case ' ': case '\t': continue; case '-': f++; case '+': p++; } break; } while(*p >= '0' && *p <= '9') n = n*10 + *p++ - '0'; return(f? -n: n); } ================================================ FILE: lib/libc/gen/atol.c ================================================ long atol(p) register char *p; { long n; register int f; n = 0; f = 0; for(;;p++) { switch(*p) { case ' ': case '\t': continue; case '-': f++; case '+': p++; } break; } while(*p >= '0' && *p <= '9') n = n*10 + *p++ - '0'; return(f? -n: n); } ================================================ FILE: lib/libc/gen/basename.c ================================================ /* $OpenBSD: basename.c,v 1.17 2020/10/20 19:30:14 naddy Exp $ */ /* * Copyright (c) 1997, 2004 Todd C. Miller * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include #include #include #include char * basename(char *path) { static char bname[PATH_MAX]; size_t len; const char *endp, *startp; /* Empty or NULL string gets treated as "." */ if (path == NULL || *path == '\0') { bname[0] = '.'; bname[1] = '\0'; return (bname); } /* Strip any trailing slashes */ endp = path + strlen(path) - 1; while (endp > path && *endp == '/') endp--; /* All slashes becomes "/" */ if (endp == path && *endp == '/') { bname[0] = '/'; bname[1] = '\0'; return (bname); } /* Find the start of the base */ startp = endp; while (startp > path && *(startp - 1) != '/') startp--; len = endp - startp + 1; if (len >= sizeof(bname)) { errno = ENAMETOOLONG; return (NULL); } memcpy(bname, startp, len); bname[len] = '\0'; return (bname); } ================================================ FILE: lib/libc/gen/bcmp.c ================================================ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include /* * bcmp -- vax cmpc3 instruction */ int bcmp(v1, v2, length) const void *v1, *v2; size_t length; { register const char *b1 = v1; register const char *b2 = v2; if (length) do if (*b1++ != *b2++) break; while (--length); return(length); } ================================================ FILE: lib/libc/gen/bcopy.c ================================================ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ /* * bcopy -- vax movc3 instruction */ void bcopy(src0, dst0, length) register const void *src0; register void *dst0; register unsigned int length; { const char *src = src0; char *dst = dst0; if (length && src != dst) { if (dst < src) { do *dst++ = *src++; while (--length); } else { /* copy backwards */ src += length; dst += length; do *--dst = *--src; while (--length); } } return; } ================================================ FILE: lib/libc/gen/bzero.c ================================================ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * * @(#)bzero.c 1.1 (Berkeley) 1/19/87 */ #include /* * bzero -- vax movc5 instruction */ void bzero(void *b, size_t length) { char *p; if (length) { p = b; do { *p++ = '\0'; } while (--length); } } ================================================ FILE: lib/libc/gen/calloc.c ================================================ /* * Calloc - allocate and clear memory block */ #include #include #include void * calloc(num, size) size_t num, size; { register char *p; size *= num; p = malloc(size); if (p) bzero(p, size); return (p); } void cfree(p, num, size) char *p; unsigned num; unsigned size; { free(p); } ================================================ FILE: lib/libc/gen/closedir.c ================================================ /* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include #include #include #include /* * close a directory. */ void closedir(dirp) register DIR *dirp; { close(dirp->dd_fd); dirp->dd_fd = -1; dirp->dd_loc = 0; free(dirp); } ================================================ FILE: lib/libc/gen/crypt.c ================================================ /* * This program implements the * Proposed Federal Information Processing * Data Encryption Standard. * See Federal Register, March 17, 1975 (40FR12134) */ /* * Initial permutation, */ static char IP[] = { 58,50,42,34,26,18,10, 2, 60,52,44,36,28,20,12, 4, 62,54,46,38,30,22,14, 6, 64,56,48,40,32,24,16, 8, 57,49,41,33,25,17, 9, 1, 59,51,43,35,27,19,11, 3, 61,53,45,37,29,21,13, 5, 63,55,47,39,31,23,15, 7, }; /* * Final permutation, FP = IP^(-1) */ static char FP[] = { 40, 8,48,16,56,24,64,32, 39, 7,47,15,55,23,63,31, 38, 6,46,14,54,22,62,30, 37, 5,45,13,53,21,61,29, 36, 4,44,12,52,20,60,28, 35, 3,43,11,51,19,59,27, 34, 2,42,10,50,18,58,26, 33, 1,41, 9,49,17,57,25, }; /* * Permuted-choice 1 from the key bits * to yield C and D. * Note that bits 8,16... are left out: * They are intended for a parity check. */ static char PC1_C[] = { 57,49,41,33,25,17, 9, 1,58,50,42,34,26,18, 10, 2,59,51,43,35,27, 19,11, 3,60,52,44,36, }; static char PC1_D[] = { 63,55,47,39,31,23,15, 7,62,54,46,38,30,22, 14, 6,61,53,45,37,29, 21,13, 5,28,20,12, 4, }; /* * Sequence of shifts used for the key schedule. */ static char shifts[] = { 1,1,2,2,2,2,2,2,1,2,2,2,2,2,2,1, }; /* * Permuted-choice 2, to pick out the bits from * the CD array that generate the key schedule. */ static char PC2_C[] = { 14,17,11,24, 1, 5, 3,28,15, 6,21,10, 23,19,12, 4,26, 8, 16, 7,27,20,13, 2, }; static char PC2_D[] = { 41,52,31,37,47,55, 30,40,51,45,33,48, 44,49,39,56,34,53, 46,42,50,36,29,32, }; /* * The C and D arrays used to calculate the key schedule. */ static char C[28]; static char D[28]; /* * The key schedule. * Generated from the key. */ static char KS[16][48]; /* * The E bit-selection table. */ static char E[48]; static char e[] = { 32, 1, 2, 3, 4, 5, 4, 5, 6, 7, 8, 9, 8, 9,10,11,12,13, 12,13,14,15,16,17, 16,17,18,19,20,21, 20,21,22,23,24,25, 24,25,26,27,28,29, 28,29,30,31,32, 1, }; /* * Set up the key schedule from the key. */ void setkey(key) char *key; { register int i, j, k; int t; /* * First, generate C and D by permuting * the key. The low order bit of each * 8-bit char is not used, so C and D are only 28 * bits apiece. */ for (i=0; i<28; i++) { C[i] = key[PC1_C[i]-1]; D[i] = key[PC1_D[i]-1]; } /* * To generate Ki, rotate C and D according * to schedule and pick up a permutation * using PC2. */ for (i=0; i<16; i++) { /* * rotate. */ for (k=0; k>3)&01; f[t+1] = (k>>2)&01; f[t+2] = (k>>1)&01; f[t+3] = (k>>0)&01; } /* * The new R is L ^ f(R, K). * The f here has to be permuted first, though. */ for (j=0; j<32; j++) R[j] = L[j] ^ f[P[j]-1]; /* * Finally, the new L (the original R) * is copied back. */ for (j=0; j<32; j++) L[j] = tempL[j]; } /* * The output L and R are reversed. */ for (j=0; j<32; j++) { t = L[j]; L[j] = R[j]; R[j] = t; } /* * The final output * gets the inverse permutation of the very original. */ for (j=0; j<64; j++) block[j] = L[FP[j]-1]; } char * crypt(pw,salt) char *pw; char *salt; { register int i, j, c; int temp; static char block[66], iobuf[16]; for(i=0; i<66; i++) block[i] = 0; for(i=0; (c= *pw) && i<64; pw++){ for(j=0; j<7; j++, i++) block[i] = (c>>(6-j)) & 01; i++; } setkey(block); for(i=0; i<66; i++) block[i] = 0; for(i=0;i<2;i++){ c = *salt++; iobuf[i] = c; if(c>'Z') c -= 6; if(c>'9') c -= 7; c -= '.'; for(j=0;j<6;j++){ if((c>>j) & 01){ temp = E[6*i+j]; E[6*i+j] = E[6*i+j+24]; E[6*i+j+24] = temp; } } } for(i=0; i<25; i++) encrypt(block,0); for(i=0; i<11; i++){ c = 0; for(j=0; j<6; j++){ c <<= 1; c |= block[6*i+j]; } c += '.'; if(c>'9') c += 7; if(c>'Z') c += 6; iobuf[i+2] = c; } iobuf[i+2] = 0; if(iobuf[1]==0) iobuf[1] = iobuf[0]; return(iobuf); } ================================================ FILE: lib/libc/gen/ctime.c ================================================ /* * Copyright (c) 1987 Regents of the University of California. * This file may be freely redistributed provided that this * notice remains attached. */ #include "sys/param.h" #include "sys/time.h" #include "stdio.h" #include "string.h" #include "unistd.h" #include "fcntl.h" #include "alloca.h" #include "tzfile.h" #include "paths.h" char * ctime(t) const time_t *t; { return asctime(localtime(t)); } /* ** A la X3J11 */ char * asctime(timeptr) register const struct tm *timeptr; { static char wday_name[DAYS_PER_WEEK][3] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" }; static char mon_name[MONS_PER_YEAR][3] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; static char result[26]; (void) sprintf(result, "%.3s %.3s%3d %02d:%02d:%02d %d\n", wday_name[timeptr->tm_wday], mon_name[timeptr->tm_mon], timeptr->tm_mday, timeptr->tm_hour, timeptr->tm_min, timeptr->tm_sec, TM_YEAR_BASE + timeptr->tm_year); return result; } #ifndef TRUE #define TRUE 1 #define FALSE 0 #endif /* !TRUE */ extern char * getenv(); extern char * strcpy(); extern char * strcat(); struct tm * offtime(); struct ttinfo { /* time type information */ long tt_gmtoff; /* GMT offset in seconds */ int tt_isdst; /* used to set tm_isdst */ int tt_abbrind; /* abbreviation list index */ }; struct state { int timecnt; int typecnt; int charcnt; time_t ats[TZ_MAX_TIMES]; unsigned char types[TZ_MAX_TIMES]; struct ttinfo ttis[TZ_MAX_TYPES]; char chars[TZ_MAX_CHARS + 1]; }; static struct state s; static int tz_is_set; char * tzname[2] = { "GMT", "GMT" }; #ifdef USG_COMPAT time_t timezone = 0; int daylight = 0; #endif /* USG_COMPAT */ static long detzcode(codep) char * codep; { register long result; register int i; result = 0; for (i = 0; i < 4; ++i) result = (result << 8) | (codep[i] & 0xff); return result; } static int tzload(name) register char * name; { register int i; register int fid; if (name == 0 && (name = _PATH_LOCALTIME) == 0) return -1; { register char * p; register int doaccess; char * fullname; doaccess = name[0] == '/'; if (!doaccess) { if ((p = _PATH_ZONEINFO) == 0) return -1; if ((strlen(p) + strlen(name) + 1) >= MAXPATHLEN) return -1; fullname = alloca(MAXPATHLEN); (void) strcpy(fullname, p); (void) strcat(fullname, "/"); (void) strcat(fullname, name); /* ** Set doaccess if '.' (as in "../") shows up in name. */ while (*name != '\0') if (*name++ == '.') doaccess = TRUE; name = fullname; } if (doaccess && access(name, 4) != 0) return -1; if ((fid = open(name, 0)) == -1) return -1; } { register char * p; register struct tzhead * tzhp; char * buf; buf = alloca(sizeof s); i = read(fid, buf, sizeof s); if (close(fid) != 0 || i < sizeof *tzhp) return -1; tzhp = (struct tzhead *) buf; s.timecnt = (int) detzcode(tzhp->tzh_timecnt); s.typecnt = (int) detzcode(tzhp->tzh_typecnt); s.charcnt = (int) detzcode(tzhp->tzh_charcnt); if (s.timecnt > TZ_MAX_TIMES || s.typecnt == 0 || s.typecnt > TZ_MAX_TYPES || s.charcnt > TZ_MAX_CHARS) return -1; if (i < sizeof *tzhp + s.timecnt * (4 + sizeof (char)) + s.typecnt * (4 + 2 * sizeof (char)) + s.charcnt * sizeof (char)) return -1; p = buf + sizeof *tzhp; for (i = 0; i < s.timecnt; ++i) { s.ats[i] = detzcode(p); p += 4; } for (i = 0; i < s.timecnt; ++i) s.types[i] = (unsigned char) *p++; for (i = 0; i < s.typecnt; ++i) { register struct ttinfo * ttisp; ttisp = &s.ttis[i]; ttisp->tt_gmtoff = detzcode(p); p += 4; ttisp->tt_isdst = (unsigned char) *p++; ttisp->tt_abbrind = (unsigned char) *p++; } for (i = 0; i < s.charcnt; ++i) s.chars[i] = *p++; s.chars[i] = '\0'; /* ensure '\0' at end */ } /* ** Check that all the local time type indices are valid. */ for (i = 0; i < s.timecnt; ++i) if (s.types[i] >= s.typecnt) return -1; /* ** Check that all abbreviation indices are valid. */ for (i = 0; i < s.typecnt; ++i) if (s.ttis[i].tt_abbrind >= s.charcnt) return -1; /* ** Set tzname elements to initial values. */ tzname[0] = tzname[1] = &s.chars[0]; #ifdef USG_COMPAT timezone = s.ttis[0].tt_gmtoff; daylight = 0; #endif /* USG_COMPAT */ for (i = 1; i < s.typecnt; ++i) { register struct ttinfo * ttisp; ttisp = &s.ttis[i]; if (ttisp->tt_isdst) { tzname[1] = &s.chars[ttisp->tt_abbrind]; #ifdef USG_COMPAT daylight = 1; #endif /* USG_COMPAT */ } else { tzname[0] = &s.chars[ttisp->tt_abbrind]; #ifdef USG_COMPAT timezone = ttisp->tt_gmtoff; #endif /* USG_COMPAT */ } } return 0; } static int tzsetkernel() { struct timeval tv; struct timezone tz; if (gettimeofday(&tv, &tz)) return -1; s.timecnt = 0; /* UNIX counts *west* of Greenwich */ s.ttis[0].tt_gmtoff = tz.tz_minuteswest * -SECS_PER_MIN; s.ttis[0].tt_abbrind = 0; (void)strcpy(s.chars, tztab(tz.tz_minuteswest, 0)); tzname[0] = tzname[1] = s.chars; #ifdef USG_COMPAT timezone = tz.tz_minuteswest * 60; daylight = tz.tz_dsttime; #endif /* USG_COMPAT */ return 0; } static void tzsetgmt() { s.timecnt = 0; s.ttis[0].tt_gmtoff = 0; s.ttis[0].tt_abbrind = 0; (void) strcpy(s.chars, "GMT"); tzname[0] = tzname[1] = s.chars; #ifdef USG_COMPAT timezone = 0; daylight = 0; #endif /* USG_COMPAT */ } void tzset() { register char * name; tz_is_set = TRUE; name = getenv("TZ"); if (!name || *name) { /* did not request GMT */ if (name && !tzload(name)) /* requested name worked */ return; if (!tzload((char *)0)) /* default name worked */ return; if (!tzsetkernel()) /* kernel guess worked */ return; } tzsetgmt(); /* GMT is default */ } struct tm * localtime(timep) const time_t *timep; { register struct ttinfo * ttisp; register struct tm * tmp; register int i; time_t t; if (!tz_is_set) (void) tzset(); t = *timep; if (s.timecnt == 0 || t < s.ats[0]) { i = 0; while (s.ttis[i].tt_isdst) if (++i >= s.timecnt) { i = 0; break; } } else { for (i = 1; i < s.timecnt; ++i) if (t < s.ats[i]) break; i = s.types[i - 1]; } ttisp = &s.ttis[i]; /* ** To get (wrong) behavior that's compatible with System V Release 2.0 ** you'd replace the statement below with ** tmp = offtime((time_t) (t + ttisp->tt_gmtoff), 0L); */ tmp = offtime(&t, ttisp->tt_gmtoff); tmp->tm_isdst = ttisp->tt_isdst; tzname[tmp->tm_isdst] = &s.chars[ttisp->tt_abbrind]; tmp->tm_zone = &s.chars[ttisp->tt_abbrind]; return tmp; } struct tm * gmtime(clock) const time_t *clock; { register struct tm * tmp; tmp = offtime(clock, 0L); tzname[0] = "GMT"; tmp->tm_zone = "GMT"; /* UCT ? */ return tmp; } static int mon_lengths[2][MONS_PER_YEAR] = { { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }, { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }, }; static int year_lengths[2] = { DAYS_PER_NYEAR, DAYS_PER_LYEAR }; struct tm * offtime(clock, offset) time_t * clock; long offset; { register struct tm * tmp; register long days; register long rem; register int y; register int yleap; register int * ip; static struct tm tm; tmp = &tm; days = *clock / SECS_PER_DAY; rem = *clock % SECS_PER_DAY; rem += offset; while (rem < 0) { rem += SECS_PER_DAY; --days; } while (rem >= SECS_PER_DAY) { rem -= SECS_PER_DAY; ++days; } tmp->tm_hour = (int) (rem / SECS_PER_HOUR); rem = rem % SECS_PER_HOUR; tmp->tm_min = (int) (rem / SECS_PER_MIN); tmp->tm_sec = (int) (rem % SECS_PER_MIN); tmp->tm_wday = (int) ((EPOCH_WDAY + days) % DAYS_PER_WEEK); if (tmp->tm_wday < 0) tmp->tm_wday += DAYS_PER_WEEK; y = EPOCH_YEAR; if (days >= 0) for ( ; ; ) { yleap = isleap(y); if (days < (long) year_lengths[yleap]) break; ++y; days = days - (long) year_lengths[yleap]; } else do { --y; yleap = isleap(y); days = days + (long) year_lengths[yleap]; } while (days < 0); tmp->tm_year = y - TM_YEAR_BASE; tmp->tm_yday = (int) days; ip = mon_lengths[yleap]; for (tmp->tm_mon = 0; days >= (long) ip[tmp->tm_mon]; ++(tmp->tm_mon)) days = days - (long) ip[tmp->tm_mon]; tmp->tm_mday = (int) (days + 1); tmp->tm_isdst = 0; tmp->tm_zone = ""; tmp->tm_gmtoff = offset; return tmp; } ================================================ FILE: lib/libc/gen/ctype_.c ================================================ #include char _ctype_[1 + 256] = { 0, _C, _C, _C, _C, _C, _C, _C, _C, _C, _C|_S, _C|_S, _C|_S, _C|_S, _C|_S, _C, _C, _C, _C, _C, _C, _C, _C, _C, _C, _C, _C, _C, _C, _C, _C, _C, _C, _S|_B, _P, _P, _P, _P, _P, _P, _P, _P, _P, _P, _P, _P, _P, _P, _P, _N, _N, _N, _N, _N, _N, _N, _N, _N, _N, _P, _P, _P, _P, _P, _P, _P, _U|_X, _U|_X, _U|_X, _U|_X, _U|_X, _U|_X, _U, _U, _U, _U, _U, _U, _U, _U, _U, _U, _U, _U, _U, _U, _U, _U, _U, _U, _U, _U, _P, _P, _P, _P, _P, _P, _L|_X, _L|_X, _L|_X, _L|_X, _L|_X, _L|_X, _L, _L, _L, _L, _L, _L, _L, _L, _L, _L, _L, _L, _L, _L, _L, _L, _L, _L, _L, _L, _P, _P, _P, _P, _C }; ================================================ FILE: lib/libc/gen/daemon.c ================================================ /*- * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #include #include #include int daemon(nochdir, noclose) int nochdir, noclose; { register int fd; switch (fork()) { case -1: return (-1); case 0: break; default: _exit(0); } if ((fd = open(_PATH_TTY, O_RDWR)) >= 0) { ioctl(fd, TIOCNOTTY, 0); close(fd); } if (!nochdir) (void)chdir("/"); if (!noclose && (fd = open(_PATH_DEVNULL, O_RDWR, 0)) != -1) { (void)dup2(fd, 0); (void)dup2(fd, 1); (void)dup2(fd, 2); if (fd > 2) (void)close(fd); } return(0); } ================================================ FILE: lib/libc/gen/devname.c ================================================ /* * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #include #include #include #include #include #include #include char * devname(dev, type) dev_t dev; mode_t type; { DIR *dir; struct direct *entry; char filename[40]; struct stat st; dir = opendir("/dev"); if (dir == NULL) { perror("/dev"); return "??"; } strcpy(filename, "/dev/"); while ((entry = readdir(dir)) != NULL) { strcpy(filename+5, entry->d_name); if (stat (filename, &st) < 0) continue; if (! S_ISCHR(st.st_mode) && ! S_ISBLK(st.st_mode)) continue; if (st.st_rdev == dev) { closedir(dir); return entry->d_name; } } closedir(dir); return "??"; } ================================================ FILE: lib/libc/gen/dirname.c ================================================ /* $OpenBSD: dirname.c,v 1.17 2020/10/20 19:30:14 naddy Exp $ */ /* * Copyright (c) 1997, 2004 Todd C. Miller * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include #include #include #include char * dirname(char *path) { static char dname[PATH_MAX]; size_t len; const char *endp; /* Empty or NULL string gets treated as "." */ if (path == NULL || *path == '\0') { dname[0] = '.'; dname[1] = '\0'; return (dname); } /* Strip any trailing slashes */ endp = path + strlen(path) - 1; while (endp > path && *endp == '/') endp--; /* Find the start of the dir */ while (endp > path && *endp != '/') endp--; /* Either the dir is "/" or there are no slashes */ if (endp == path) { dname[0] = *endp == '/' ? '/' : '.'; dname[1] = '\0'; return (dname); } else { /* Move forward past the separating slashes */ do { endp--; } while (endp > path && *endp == '/'); } len = endp - path + 1; if (len >= sizeof(dname)) { errno = ENAMETOOLONG; return (NULL); } memcpy(dname, path, len); dname[len] = '\0'; return (dname); } ================================================ FILE: lib/libc/gen/ecvt.c ================================================ /* * ecvt converts to decimal * the number of digits is specified by ndigit * decpt is set to the position of the decimal point * sign is set to 0 for positive, 1 for negative */ #include #define NDIG 80 static char * cvt(arg, ndigits, decpt, sign, eflag) double arg; int ndigits, *decpt, *sign, eflag; { register int r2; double fi, fj; register char *p, *p1; static char buf[NDIG]; double modf(); if (ndigits < 0) ndigits = 0; if (ndigits >= NDIG-1) ndigits = NDIG-2; r2 = 0; *sign = 0; p = &buf[0]; if (arg < 0) { *sign = 1; arg = -arg; } arg = modf(arg, &fi); p1 = &buf[NDIG]; /* * Do integer part */ if (fi != 0) { p1 = &buf[NDIG]; while (fi != 0) { fj = modf(fi/10, &fi); *--p1 = (int)((fj+.03)*10) + '0'; r2++; } while (p1 < &buf[NDIG]) *p++ = *p1++; } else if (arg > 0) { while ((fj = arg*10) < 1) { arg = fj; r2--; } } p1 = &buf[ndigits]; if (eflag == 0) p1 += r2; *decpt = r2; if (p1 < &buf[0]) { buf[0] = '\0'; return(buf); } while (p <= p1 && p < &buf[NDIG]) { arg *= 10; arg = modf(arg, &fj); *p++ = (int)fj + '0'; } if (p1 >= &buf[NDIG]) { buf[NDIG-1] = '\0'; return(buf); } p = p1; *p1 += 5; while (*p1 > '9') { *p1 = '0'; if (p1 > buf) ++*--p1; else { *p1 = '1'; (*decpt)++; if (eflag == 0) { if (p > buf) *p = '0'; p++; } } } *p = '\0'; return(buf); } char * ecvt(arg, ndigits, decpt, sign) double arg; int ndigits, *decpt, *sign; { return cvt(arg, ndigits, decpt, sign, 1); } char * fcvt(arg, ndigits, decpt, sign) double arg; int ndigits, *decpt, *sign; { return cvt(arg, ndigits, decpt, sign, 0); } ================================================ FILE: lib/libc/gen/err.c ================================================ /*- * Copyright (c) 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #include #include #include #include #ifdef __STDC__ #include #else #include #endif /* * Helper routines. Repeated constructs of the form "%s: " used up too * much D space. On a pdp-11 code can be overlaid but Data space is worth * conserving. An extra function call or two handling an error condition is * a reasonable trade for 20 or 30 bytes of D space. */ static void putcolsp() { fputc (':', stderr); fputc (' ', stderr); } static void putprog() { fputs (__progname, stderr); putcolsp(); } void verr (eval, fmt, ap) int eval; const char *fmt; va_list ap; { int sverrno; sverrno = errno; putprog(); if (fmt != NULL) { (void)vfprintf(stderr, fmt, ap); putcolsp(); } (void)fputs(strerror(sverrno), stderr); (void)fputc('\n', stderr); exit(eval); } void #ifdef __STDC__ err (int eval, const char *fmt, ...) #else err (eval, fmt, va_alist) int eval; const char *fmt; va_dcl #endif { va_list ap; #if __STDC__ va_start(ap, fmt); #else va_start(ap); #endif verr(eval, fmt, ap); va_end(ap); } void verrx (eval, fmt, ap) int eval; const char *fmt; va_list ap; { putprog(); if (fmt != NULL) (void)vfprintf(stderr, fmt, ap); (void)fputc('\n', stderr); exit(eval); } void #if __STDC__ errx (int eval, const char *fmt, ...) #else errx (eval, fmt, va_alist) int eval; const char *fmt; va_dcl #endif { va_list ap; #if __STDC__ va_start(ap, fmt); #else va_start(ap); #endif verrx(eval, fmt, ap); va_end(ap); } void vwarn (fmt, ap) const char *fmt; va_list ap; { int sverrno; sverrno = errno; putprog(); if (fmt != NULL) { (void)vfprintf(stderr, fmt, ap); putcolsp(); } (void)fputs(strerror(sverrno), stderr); (void)fputc('\n', stderr); } void #if __STDC__ warn (const char *fmt, ...) #else warn(fmt, va_alist) const char *fmt; va_dcl #endif { va_list ap; #if __STDC__ va_start(ap, fmt); #else va_start(ap); #endif vwarn(fmt, ap); va_end(ap); } void vwarnx (fmt, ap) const char *fmt; va_list ap; { putprog(); if (fmt != NULL) (void)vfprintf(stderr, fmt, ap); (void)fputc('\n', stderr); } void #ifdef __STDC__ warnx (const char *fmt, ...) #else warnx(fmt, va_alist) char *fmt; va_dcl #endif { va_list ap; #ifdef __STDC__ va_start(ap, fmt); #else va_start(ap); #endif vwarnx(fmt, ap); va_end(ap); } ================================================ FILE: lib/libc/gen/execvp.c ================================================ /* * execlp(name, arg,...,0) (like execl, but does path search) * execvp(name, argv) (like execv, but does path search) */ #include #include #include #include #include static char shell[] = "/bin/sh"; int execlp(const char *name, const char *argv, ...) { return execvp (name, (char * const*) &argv); } static char * execat(s1, s2, si) register char *s1, *s2; char *si; { register char *s; s = si; while (*s1 && *s1 != ':') *s++ = *s1++; if (si != s) *s++ = '/'; while (*s2) *s++ = *s2++; *s = '\0'; return(*s1? ++s1: 0); } int execvp(name, argv) const char *name; char *const *argv; { char *pathstr; register char *cp; char fname[128]; char *newargs[256]; int i; register unsigned etxtbsy = 1; register int eacces = 0; pathstr = getenv("PATH"); if (! pathstr) pathstr = _PATH_STDPATH; cp = strchr(name, '/') ? "" : pathstr; do { cp = execat(cp, name, fname); retry: execv(fname, argv); switch(errno) { case ENOEXEC: newargs[0] = "sh"; newargs[1] = fname; for (i=1; (newargs[i+1] = argv[i]); i++) { if (i>=254) { errno = E2BIG; return(-1); } } execv(shell, newargs); return(-1); case ETXTBSY: if (++etxtbsy > 5) return(-1); sleep(etxtbsy); goto retry; case EACCES: eacces++; break; case ENOMEM: case E2BIG: return(-1); } } while (cp); if (eacces) errno = EACCES; return(-1); } ================================================ FILE: lib/libc/gen/fabs.c ================================================ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ double fabs(arg) double arg; { return(arg < 0 ? -arg : arg); } ================================================ FILE: lib/libc/gen/fakcu.c ================================================ /* * Null cleanup routine to resolve reference in exit() * if not using stdio. */ void __attribute__((weak)) _cleanup() { } ================================================ FILE: lib/libc/gen/ffs.c ================================================ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ /* * ffs -- vax ffs instruction */ int ffs(mask) register int mask; { register int cnt; if (mask == 0) return(0); for (cnt = 1; !(mask&1); cnt++) mask >>= 1; return(cnt); } ================================================ FILE: lib/libc/gen/frexp.c ================================================ /* * the call * x = frexp(arg,&exp); * must return a double fp quantity x which is <1.0 * and the corresponding binary exponent "exp". * such that * arg = x*2^exp * if the argument is 0.0, return 0.0 mantissa and 0 exponent. */ #include double frexp(x, i) double x; int *i; { int neg; int j; j = 0; neg = 0; if (x < 0) { x = -x; neg = 1; } if (x >= 1.0) while (x >= 1.0) { j = j+1; x = x/2; } else if (x < 0.5 && x != 0.0) while (x < 0.5) { j = j-1; x = 2*x; } *i = j; if (neg) x = -x; return(x); } ================================================ FILE: lib/libc/gen/fstab.c ================================================ /* * Copyright (c) 1980, 1988, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #include #include #include #include #include #include #include #include static FILE *_fs_fp; static struct fstab _fs_fstab; static void error(); static int fstabscan(); static int fstabscan() { char *cp; register char *bp; #define MAXLINELENGTH 256 static char line[MAXLINELENGTH]; char subline[MAXLINELENGTH], *colon = ":"; int typexx; for (;;) { if (!fgets(line, sizeof(line), _fs_fp)) return(0); bp = index(line, '\n'); if (!bp) return(0); *bp = '\0'; cp = line; /* OLD_STYLE_FSTAB */ if (!strpbrk(cp, " \t")) { _fs_fstab.fs_spec = strsep(&cp, colon); _fs_fstab.fs_file = strsep(&cp, colon); _fs_fstab.fs_type = strsep(&cp, colon); if (_fs_fstab.fs_type) { if (!strcmp(_fs_fstab.fs_type, FSTAB_XX)) continue; _fs_fstab.fs_mntops = _fs_fstab.fs_type; _fs_fstab.fs_vfstype = strcmp(_fs_fstab.fs_type, FSTAB_SW) ? "ufs" : "swap"; bp = strsep(&cp, colon); if (bp) { _fs_fstab.fs_freq = atoi(bp); bp = strsep(&cp, colon); if (bp) { _fs_fstab.fs_passno = atoi(bp); return(1); } } } goto bad; } /* OLD_STYLE_FSTAB */ _fs_fstab.fs_spec = strtok(cp, " \t"); if (!_fs_fstab.fs_spec || *_fs_fstab.fs_spec == '#') continue; _fs_fstab.fs_file = strtok((char *)NULL, " \t"); _fs_fstab.fs_vfstype = strtok((char *)NULL, " \t"); _fs_fstab.fs_mntops = strtok((char *)NULL, " \t"); if (_fs_fstab.fs_mntops == NULL) goto bad; _fs_fstab.fs_freq = 0; _fs_fstab.fs_passno = 0; if ((cp = strtok((char *)NULL, " \t")) != NULL) { _fs_fstab.fs_freq = atoi(cp); if ((cp = strtok((char *)NULL, " \t")) != NULL) _fs_fstab.fs_passno = atoi(cp); } strcpy(subline, _fs_fstab.fs_mntops); for (typexx = 0, cp = strtok(subline, ","); cp; cp = strtok((char *)NULL, ",")) { if (strlen(cp) != 2) continue; if (!strcmp(cp, FSTAB_RW)) { _fs_fstab.fs_type = FSTAB_RW; break; } if (!strcmp(cp, FSTAB_RQ)) { _fs_fstab.fs_type = FSTAB_RQ; break; } if (!strcmp(cp, FSTAB_RO)) { _fs_fstab.fs_type = FSTAB_RO; break; } if (!strcmp(cp, FSTAB_SW)) { _fs_fstab.fs_type = FSTAB_SW; break; } if (!strcmp(cp, FSTAB_XX)) { _fs_fstab.fs_type = FSTAB_XX; typexx++; break; } } if (typexx) continue; if (cp != NULL) return(1); bad: /* no way to distinguish between EOF and syntax error */ error(EFTYPE); } /* NOTREACHED */ } struct fstab * getfsent() { if (! _fs_fp && ! setfsent()) return 0; if (! fstabscan()) return 0; return &_fs_fstab; } struct fstab * getfsspec(name) register char *name; { if (setfsent()) while (fstabscan()) if (!strcmp(_fs_fstab.fs_spec, name)) return(&_fs_fstab); return((struct fstab *)NULL); } struct fstab * getfsfile(name) register char *name; { if (setfsent()) while (fstabscan()) if (!strcmp(_fs_fstab.fs_file, name)) return(&_fs_fstab); return((struct fstab *)NULL); } int setfsent() { if (_fs_fp) { rewind(_fs_fp); return(1); } _fs_fp = fopen(_PATH_FSTAB, "r"); if (_fs_fp) return(1); error(errno); return(0); } void endfsent() { if (_fs_fp) { (void)fclose(_fs_fp); _fs_fp = NULL; } } static void error(err) int err; { register int saverrno; saverrno = errno; errno = err; warn("%s", _PATH_FSTAB); errno = saverrno; } ================================================ FILE: lib/libc/gen/gcvt.c ================================================ /* * gcvt - Floating output conversion to * minimal length string */ #include char * gcvt(number, ndigit, buf) double number; int ndigit; char *buf; { int sign, decpt; register char *p1, *p2; register int i; p1 = ecvt(number, ndigit, &decpt, &sign); p2 = buf; if (sign) *p2++ = '-'; for (i=ndigit-1; i>0 && p1[i]=='0'; i--) ndigit--; if ((decpt >= 0 && decpt-ndigit > 4) || (decpt < 0 && decpt < -3)) { /* use E-style */ decpt--; *p2++ = *p1++; *p2++ = '.'; for (i=1; i #include #include #include /* * getenv(name) -- * Returns ptr to value associated with name, if any, else NULL. */ char * getenv(name) const char *name; { int offset; char *_findenv(); return(_findenv(name,&offset)); } /* * _findenv(name,offset) -- * Returns pointer to value associated with name, if any, else NULL. * Sets offset to be the offset of the name/value combination in the * environmental array, for use by setenv(3) and unsetenv(3). * Explicitly removes '=' in argument name. * * This routine *should* be a static; don't use it. */ char * _findenv(name, offset) register const char *name; int *offset; { register int len; register char **P, *C; register const char *E; len = 0; for (E = name; *E && *E != '='; ++E) ++len; for (P = environ; *P; ++P) if (!strncmp(*P, name, len)) if (*(C = *P + len) == '=') { *offset = P - environ; return(++C); } return(NULL); } ================================================ FILE: lib/libc/gen/getgrent.c ================================================ #include #include #include #include #define MAXGRP 200 static char GROUP[] = "/etc/group"; static FILE *grf = NULL; static char line[256+1]; static struct group group; static char *gr_mem[MAXGRP]; void setgrent() { if (!grf) grf = fopen(GROUP, "r"); else rewind(grf); } void endgrent() { if (grf) { fclose(grf); grf = NULL; } } static char * grskip(p,c) register char *p; register int c; { while(*p && *p != c) ++p; if (*p) *p++ = 0; return(p); } struct group * getgrent() { register char *p, **q; if (!grf && !(grf = fopen(GROUP, "r"))) return(NULL); if (!(p = fgets(line, sizeof(line)-1, grf))) return(NULL); group.gr_name = p; group.gr_passwd = p = grskip(p,':'); group.gr_gid = atoi(p = grskip(p,':')); group.gr_mem = gr_mem; p = grskip(p,':'); grskip(p,'\n'); q = gr_mem; while (*p) { if (q < &gr_mem[MAXGRP-1]) *q++ = p; p = grskip(p,','); } *q = NULL; return(&group); } ================================================ FILE: lib/libc/gen/getgrgid.c ================================================ #include #include struct group * getgrgid(gid) register gid_t gid; { register struct group *p; setgrent(); while ((p = getgrent()) && p->gr_gid != gid); endgrent(); return(p); } ================================================ FILE: lib/libc/gen/getgrnam.c ================================================ #include #include #include struct group * getgrnam(name) register const char *name; { register struct group *p; setgrent(); while ((p = getgrent()) && strcmp(p->gr_name, name)); endgrent(); return(p); } ================================================ FILE: lib/libc/gen/getgrouplist.c ================================================ /* * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ /* * get credential */ #include #include #include int getgrouplist(uname, agroup, groups, grpcnt) char *uname; gid_t agroup; register gid_t *groups; int *grpcnt; { register struct group *grp; int i, ngroups, ret, maxgroups; ret = 0; ngroups = 0; maxgroups = *grpcnt; /* * When installing primary group, duplicate it; * the first element of groups is the effective gid * and will be overwritten when a setgid file is executed. */ groups[ngroups++] = agroup; if (maxgroups > 1) groups[ngroups++] = agroup; /* * Scan the group file to find additional groups. */ setgrent(); while ((grp = getgrent())) { if (grp->gr_gid == agroup) continue; for (i = 0; grp->gr_mem[i]; i++) { if (!strcmp(grp->gr_mem[i], uname)) { if (ngroups >= maxgroups) { ret = -1; break; } groups[ngroups++] = grp->gr_gid; break; } } } endgrent(); *grpcnt = ngroups; return (ret); } ================================================ FILE: lib/libc/gen/gethostname.c ================================================ /* * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #include int gethostname(name, namelen) char *name; int namelen; { int mib[2]; size_t size; mib[0] = CTL_KERN; mib[1] = KERN_HOSTNAME; size = namelen; if (sysctl(mib, 2, name, &size, NULL, 0) == -1) return (-1); return (0); } ================================================ FILE: lib/libc/gen/getloadavg.c ================================================ /*- * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #include #include /* * getloadavg() -- Get system load averages. * * Put `nelem' samples into `loadavg' array. * Return number of samples retrieved, or -1 on error. */ int getloadavg(loadavg, nelem) unsigned loadavg[]; register int nelem; { struct loadavg loadinfo; register int i; int mib[2]; size_t size; mib[0] = CTL_VM; mib[1] = VM_LOADAVG; size = sizeof(loadinfo); if (sysctl(mib, 2, &loadinfo, &size, NULL, 0) < 0) return (-1); nelem = MIN(nelem, sizeof(loadinfo.ldavg) / sizeof(short)); for (i = 0; i < nelem; i++) loadavg[i] = 100 * loadinfo.ldavg[i] / loadinfo.fscale; return (nelem); } ================================================ FILE: lib/libc/gen/getlogin.c ================================================ /* * Copyright (c) 1988, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include char * getlogin() { return 0; } int setlogin (name) const char *name; { return 0; } ================================================ FILE: lib/libc/gen/getmntinfo.c ================================================ /* * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #include #include /* * Return information about mounted filesystems. */ int getmntinfo(mntbufp, flags) register struct statfs **mntbufp; int flags; { static struct statfs *mntbuf; static int mntsize; static int bufsize; if (mntsize <= 0 && (mntsize = getfsstat(0, 0, MNT_NOWAIT)) < 0) return (0); if (bufsize > 0 && (mntsize = getfsstat(mntbuf, bufsize, flags)) < 0) return (0); while (bufsize <= mntsize * sizeof(struct statfs)) { if (mntbuf) free(mntbuf); bufsize = (mntsize + 1) * sizeof(struct statfs); if ((mntbuf = (struct statfs *)malloc(bufsize)) == 0) return (0); if ((mntsize = getfsstat(mntbuf, bufsize, flags)) < 0) return (0); } *mntbufp = mntbuf; return (mntsize); } ================================================ FILE: lib/libc/gen/getpagesize.c ================================================ /* * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #include int getpagesize() { size_t size; int mib[2], value; mib[0] = CTL_HW; mib[1] = HW_PAGESIZE; size = sizeof(value); if (sysctl(mib, 2, &value, &size, NULL, 0) == -1) return (-1); return (value); } ================================================ FILE: lib/libc/gen/getpass.c ================================================ #include #include #include #include char * getpass(prompt) char *prompt; { struct sgttyb ttyb; int flags; register char *p; register int c; FILE *fi; static char pbuf[9]; sig_t sig; fi = fdopen(open("/dev/tty", 2), "r"); if (! fi) fi = stdin; else setbuf(fi, (char *)NULL); sig = signal(SIGINT, SIG_IGN); ioctl(fileno(fi), TIOCGETP, &ttyb); flags = ttyb.sg_flags; ttyb.sg_flags &= ~ECHO; ioctl(fileno(fi), TIOCSETP, &ttyb); fprintf(stderr, "%s", prompt); fflush(stderr); for (p=pbuf; (c = getc(fi))!='\n' && c!=EOF;) { if (p < &pbuf[8]) *p++ = c; } *p = '\0'; fprintf(stderr, "\n"); fflush(stderr); ttyb.sg_flags = flags; ioctl(fileno(fi), TIOCSETP, &ttyb); signal(SIGINT, sig); if (fi != stdin) fclose(fi); return(pbuf); } ================================================ FILE: lib/libc/gen/getpwent.c ================================================ /* * Copyright (c) 1988 The Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the University of California, Berkeley. The name of the * University may not be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #include #include #include #include #include #include #include #include #include #include static FILE *_pw_fp; static struct passwd _pw_entry; static int _pw_stayopen; static char *_pw_file = _PATH_PASSWD; #define MAXLINELENGTH 256 static char line[MAXLINELENGTH]; static int start_pw() { if (_pw_fp) { rewind(_pw_fp); return(1); } _pw_fp = fopen(_pw_file, "r"); if (_pw_fp) return(1); return(0); } static int scanpw() { register char *cp; char *bp; register int ch; for (;;) { if (!(fgets(line, sizeof(line), _pw_fp))) return(0); /* skip lines that are too big */ cp = strchr(line, '\n'); if (! cp) { while ((ch = fgetc(_pw_fp)) != '\n' && ch != EOF) ; continue; } *cp = '\0'; bp = line; _pw_entry.pw_name = strsep(&bp, ":"); _pw_entry.pw_passwd = strsep(&bp, ":"); cp = strsep(&bp, ":"); if (! cp) continue; _pw_entry.pw_uid = atoi(cp); cp = strsep(&bp, ":"); if (! cp) continue; _pw_entry.pw_gid = atoi(cp); _pw_entry.pw_gecos = strsep(&bp, ":"); _pw_entry.pw_dir = strsep(&bp, ":"); _pw_entry.pw_shell = strsep(&bp, ":"); if (!_pw_entry.pw_shell) continue; return(1); } /* NOTREACHED */ } static void getpw() { static char pwbuf[50]; off_t lseek(); long pos; int fd, n; register char *p; if (geteuid()) return; /* * special case; if it's the official password file, look in * the master password file, otherwise, look in the file itself. */ p = strcmp(_pw_file, _PATH_PASSWD) == 0 ? _PATH_SHADOW : _pw_file; if ((fd = open(p, O_RDONLY, 0)) < 0) return; pos = atol(_pw_entry.pw_passwd); if (lseek(fd, pos, L_SET) != pos) goto bad; if ((n = read(fd, pwbuf, sizeof(pwbuf) - 1)) < 0) goto bad; pwbuf[n] = '\0'; for (p = pwbuf; *p; ++p) if (*p == ':') { *p = '\0'; _pw_entry.pw_passwd = pwbuf; break; } bad: (void)close(fd); } struct passwd * getpwent() { register int rval; if (!_pw_fp && !start_pw()) return((struct passwd *)NULL); rval = scanpw(); if (! rval) return 0; getpw(); return &_pw_entry; } struct passwd * getpwnam(nam) char *nam; { register int rval; if (!start_pw()) return((struct passwd *)NULL); for (rval = 0; scanpw();) { if (!strcmp(nam, _pw_entry.pw_name)) { rval = 1; break; } } if (!_pw_stayopen) endpwent(); if (! rval) return 0; getpw(); return &_pw_entry; } struct passwd * getpwuid(uid) int uid; { register int rval; if (!start_pw()) return((struct passwd *)NULL); for (rval = 0; scanpw();) { if (_pw_entry.pw_uid == uid) { rval = 1; break; } } if (!_pw_stayopen) endpwent(); if (! rval) return 0; getpw(); return &_pw_entry; } int setpwent() { return(setpassent(0)); } int setpassent(stayopen) int stayopen; { if (!start_pw()) return(0); _pw_stayopen = stayopen; return(1); } void endpwent() { if (_pw_fp) { (void)fclose(_pw_fp); _pw_fp = 0; } } void setpwfile(file) char *file; { _pw_file = file; } ================================================ FILE: lib/libc/gen/getttyent.c ================================================ /* * Copyright (c) 1985 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include #include #include #include static char TTYFILE[] = "/etc/ttys"; static int zapchar; static FILE *tf = NULL; #define LINE 256 static char line[LINE]; static struct ttyent tty; void setttyent() { if (tf == NULL) tf = fopen(TTYFILE, "r"); else rewind(tf); } void endttyent() { if (tf != NULL) { (void) fclose(tf); tf = NULL; } } #define QUOTED 1 /* * Skip over the current field, removing quotes, * and return a pointer to the next field. */ static char * skip(p) register char *p; { register char *t = p; register int c; register int q = 0; for (; (c = *p) != '\0'; p++) { if (c == '"') { q ^= QUOTED; /* obscure, but nice */ continue; } if (q == QUOTED && *p == '\\' && *(p+1) == '"') p++; *t++ = *p; if (q == QUOTED) continue; if (c == '#') { zapchar = c; *p = 0; break; } if (c == '\t' || c == ' ' || c == '\n') { zapchar = c; *p++ = 0; while ((c = *p) == '\t' || c == ' ' || c == '\n') p++; break; } } *--t = '\0'; return (p); } static char * value(p) register char *p; { if ((p = index(p,'=')) == 0) return(NULL); p++; /* get past the = sign */ return(p); } struct ttyent * getttyent() { register char *p; register int c; if (tf == NULL) { if ((tf = fopen(TTYFILE, "r")) == NULL) return (NULL); } do { p = fgets(line, LINE, tf); if (p == NULL) return (NULL); while ((c = *p) == '\t' || c == ' ' || c == '\n') p++; } while (c == '\0' || c == '#'); zapchar = 0; tty.ty_name = p; p = skip(p); tty.ty_getty = p; p = skip(p); tty.ty_type = p; p = skip(p); tty.ty_status = 0; tty.ty_window = NULL; for (; *p; p = skip(p)) { #define space(x) ((c = p[x]) == ' ' || c == '\t' || c == '\n') if (strncmp(p, "on", 2) == 0 && space(2)) tty.ty_status |= TTY_ON; else if (strncmp(p, "off", 3) == 0 && space(3)) tty.ty_status &= ~TTY_ON; else if (strncmp(p, "secure", 6) == 0 && space(6)) tty.ty_status |= TTY_SECURE; else if (strncmp(p, "window=", 7) == 0) tty.ty_window = value(p); else break; } if (zapchar == '#' || *p == '#') while ((c = *++p) == ' ' || c == '\t') ; tty.ty_comment = p; if (*p == 0) tty.ty_comment = 0; p = index(p, '\n'); if (p) *p = '\0'; return(&tty); } ================================================ FILE: lib/libc/gen/getttynam.c ================================================ /* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include #include struct ttyent * getttynam(tty) const char *tty; { register struct ttyent *t; setttyent(); while ((t = getttyent())) { if (strcmp(tty, t->ty_name) == 0) break; } endttyent(); return (t); } ================================================ FILE: lib/libc/gen/getusershell.c ================================================ /* * Copyright (c) 1985 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the University of California, Berkeley. The name of the * University may not be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #include #include #include #include #include #include #include #define SHELLS "/etc/shells" /* * Do not add local shells here. They should be added in /etc/shells */ static char *okshells[] = { "/bin/sh", "/bin/csh", 0 }; static char **shells, *strings; static char **curshell = NULL; static char ** initshells() { register char **sp, *cp; register FILE *fp; struct stat statb; if (shells != NULL) free((char *)shells); shells = NULL; if (strings != NULL) free(strings); strings = NULL; if ((fp = fopen(SHELLS, "r")) == (FILE *)0) return(okshells); if (fstat(fileno(fp), &statb) == -1) { (void)fclose(fp); return(okshells); } if ((strings = malloc((unsigned)statb.st_size)) == NULL) { (void)fclose(fp); return(okshells); } shells = (char **)calloc((unsigned)statb.st_size / 3, sizeof (char *)); if (shells == NULL) { (void)fclose(fp); free(strings); strings = NULL; return(okshells); } sp = shells; cp = strings; while (fgets(cp, MAXPATHLEN + 1, fp) != NULL) { while (*cp != '#' && *cp != '/' && *cp != '\0') cp++; if (*cp == '#' || *cp == '\0') continue; *sp++ = cp; while (!isspace(*cp) && *cp != '#' && *cp != '\0') cp++; *cp++ = '\0'; } *sp = (char *)0; (void)fclose(fp); return (shells); } /* * Get a list of shells from SHELLS, if it exists. */ char * getusershell() { char *ret; if (curshell == NULL) curshell = initshells(); ret = *curshell; if (ret != NULL) curshell++; return (ret); } void endusershell() { if (shells != NULL) free((char *)shells); shells = NULL; if (strings != NULL) free(strings); strings = NULL; curshell = NULL; } void setusershell() { curshell = initshells(); } ================================================ FILE: lib/libc/gen/getwd.c ================================================ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ /* * getwd() returns the pathname of the current working directory. On error * an error message is copied to pathname and null pointer is returned. */ #include #include #include #include #include #define GETWDERR(s) strcpy(pathname, (s)); static int pathsize; /* pathname length */ /* * prepend() tacks a directory name onto the front of a pathname. */ static char * prepend(dirname, pathname) register char *dirname; register char *pathname; { register int i; /* directory name size counter */ for (i = 0; *dirname != '\0'; i++, dirname++) continue; if ((pathsize += i) < MAXPATHLEN) while (i-- > 0) *--pathname = *--dirname; return (pathname); } char * getwd(pathname) char *pathname; { char pathbuf[MAXPATHLEN]; /* temporary pathname buffer */ char *pnptr = &pathbuf[(sizeof pathbuf)-1]; /* pathname pointer */ char curdir[MAXPATHLEN]; /* current directory buffer */ char *dptr = curdir; /* directory pointer */ dev_t cdev, rdev; /* current & root device number */ ino_t cino, rino; /* current & root inode number */ DIR *dirp; /* directory stream */ struct direct *dir; /* directory entry struct */ struct stat d, dd; /* file status struct */ pathsize = 0; *pnptr = '\0'; if (stat("/", &d) < 0) { GETWDERR("getwd: can't stat /"); return (NULL); } rdev = d.st_dev; rino = d.st_ino; strcpy(dptr, "./"); dptr += 2; if (stat(curdir, &d) < 0) { GETWDERR("getwd: can't stat ."); return (NULL); } for (;;) { if (d.st_ino == rino && d.st_dev == rdev) break; /* reached root directory */ cino = d.st_ino; cdev = d.st_dev; strcpy(dptr, "../"); dptr += 3; if ((dirp = opendir(curdir)) == NULL) { GETWDERR("getwd: can't open .."); return (NULL); } fstat(dirp->dd_fd, &d); if (cdev == d.st_dev) { if (cino == d.st_ino) { /* reached root directory */ closedir(dirp); break; } do { if ((dir = readdir(dirp)) == NULL) { closedir(dirp); GETWDERR("getwd: read error in .."); return (NULL); } } while (dir->d_ino != cino); } else do { if ((dir = readdir(dirp)) == NULL) { closedir(dirp); GETWDERR("getwd: read error in .."); return (NULL); } strcpy(dptr, dir->d_name); lstat(curdir, &dd); } while(dd.st_ino != cino || dd.st_dev != cdev); closedir(dirp); pnptr = prepend("/", prepend(dir->d_name, pnptr)); } if (*pnptr == '\0') /* current dir == root dir */ strcpy(pathname, "/"); else strcpy(pathname, pnptr); return (pathname); } ================================================ FILE: lib/libc/gen/index.c ================================================ /* * Return the ptr in sp at which the character c appears; * NULL if not found */ #define NULL 0 char * index(sp, c) register const char *sp; register int c; { do { if (*sp == c) return((char *)sp); } while (*sp++); return(NULL); } ================================================ FILE: lib/libc/gen/initgroups.c ================================================ /* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ /* * initgroups */ #include #include #include #include int initgroups(uname, agroup) char *uname; int agroup; { gid_t groups[NGROUPS]; register struct group *grp; register int i, ngroups = 0; if (agroup >= 0) groups[ngroups++] = agroup; setgrent(); while ((grp = getgrent())) { if (grp->gr_gid == agroup) continue; for (i = 0; grp->gr_mem[i]; i++) if (!strcmp(grp->gr_mem[i], uname)) { if (ngroups == NGROUPS) { fprintf(stderr, "initgroups: %s is in too many groups\n", uname); goto toomany; } groups[ngroups++] = grp->gr_gid; } } toomany: endgrent(); if (setgroups(ngroups, groups) < 0) { perror("setgroups"); return (-1); } return (0); } ================================================ FILE: lib/libc/gen/insque.c ================================================ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ /* * insque -- vax insque instruction * * NOTE: this implementation is non-atomic!! */ struct vaxque { /* queue format expected by VAX queue instructions */ struct vaxque *vq_next; struct vaxque *vq_prev; }; insque(e, prev) register struct vaxque *e, *prev; { e->vq_prev = prev; e->vq_next = prev->vq_next; prev->vq_next->vq_prev = e; prev->vq_next = e; } ================================================ FILE: lib/libc/gen/isatty.c ================================================ /* * Returns 1 iff file is a tty */ #include int isatty(f) int f; { struct sgttyb ttyb; if (ioctl(f, TIOCGETP, &ttyb) < 0) return(0); return(1); } ================================================ FILE: lib/libc/gen/isinf.c ================================================ /* * Written by J.T. Conklin . * Changed to return -1 for -Inf by Ulrich Drepper . * Public domain. */ #include /* * isinf(x) returns 1 is x is inf, -1 if x is -inf, else 0; * no branching! */ int isinf (double x) { long hx, lx; lx = *(unsigned long long*) &x; hx = (*(unsigned long long*) &x) >> 32; lx |= (hx & 0x7fffffff) ^ 0x7ff00000; lx |= -lx; return ~(lx >> 31) & (hx >> 30); } ================================================ FILE: lib/libc/gen/isinff.c ================================================ /* * Written by Serge Vakulenko . * * Permission to use, copy, modify, and distribute this * software is freely granted, provided that this notice * is preserved. */ #include /* * isinff(x) returns 1 is x is inf, -1 if x is -inf, else 0; * no branching! */ int isinff (float x) { union { long s32; float f32; } u; long v; u.f32 = x; v = (u.s32 & 0x7fffffff) ^ 0x7f800000; return ~((v | -v) >> 31) & (u.s32 >> 30); } /* * For PIC32, double is the same as float. */ int isinf (double x) __attribute__((alias ("isinff"))); ================================================ FILE: lib/libc/gen/isnan.c ================================================ /* * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. * * Developed at SunPro, a Sun Microsystems, Inc. business. * Permission to use, copy, modify, and distribute this * software is freely granted, provided that this notice * is preserved. */ #include /* * isnan(x) returns 1 is x is nan, else 0; * no branching! */ int isnan (double x) { long hx, lx; lx = *(unsigned long long*) &x; hx = (*(unsigned long long*) &x) >> 32; hx &= 0x7fffffff; hx |= (unsigned long) (lx | (-lx)) >> 31; hx = 0x7ff00000 - hx; return (int) (((unsigned long) hx) >> 31); } ================================================ FILE: lib/libc/gen/isnanf.c ================================================ /* * Written by Serge Vakulenko . * * Permission to use, copy, modify, and distribute this * software is freely granted, provided that this notice * is preserved. */ #include /* * isnan(x) returns 1 is x is nan, else 0; * no branching! */ int isnanf (float x) { union { long s32; float f32; } u; unsigned long ul; u.f32 = x; ul = 0x7f800000 - (u.s32 & 0x7fffffff); return ul >> 31; } /* * For PIC32, double is the same as float. */ int isnan (double x) __attribute__((alias ("isnanf"))); ================================================ FILE: lib/libc/gen/knlist.c ================================================ #include #include #include #include #include int knlist(list) struct nlist *list; { register struct nlist *p; int mib[2], entries = 0; size_t size; mib[0] = CTL_MACHDEP; mib[1] = CPU_NLIST; /* * Clean out any left-over information for all valid entries. * Type and value defined to be 0 if not found; historical * versions cleared other and desc as well. */ for (p=list; p->n_name && p->n_name[0]; ++p) { size = sizeof(p->n_value); if (sysctl(mib, 2, &p->n_value, &size, p->n_name, 1 + strlen(p->n_name)) < 0) { p->n_value = 0; continue; } ++entries; } return entries; } ================================================ FILE: lib/libc/gen/ldexp.c ================================================ #include #include double ldexp(fr, exp) double fr; int exp; { int neg; int i; if (fr == 0) return 0; neg = 0; if (fr < 0) { fr = -fr; neg = 1; } fr = frexp(fr, &i); while (fr < 0.5) { fr = 2*fr; i = i-1; } exp = exp+i; if (exp >= DBL_MAX_EXP) { if (neg) return(-HUGE_VAL); else return(HUGE_VAL); } if (exp < DBL_MIN_EXP - 2) return(0); while (exp > 30) { fr = fr*(1L<<30); exp = exp-30; } while (exp < -30) { fr = fr/(1L<<30); exp = exp+30; } if (exp > 0) fr = fr*(1L< #include #ifdef debug #include #include #define ASSERT(p) if(!(p))botch("p") /* * Can't use 'printf' below because that can call malloc(). If the malloc * arena is corrupt malloc() calls botch() which calls printf which calls malloc * ... result is a recursive loop which underflows the stack. */ static botch(s) char *s; { struct iovec iov[3]; register struct iovec *v = iov; char *ab = "assertion botched: "; v->iov_base = ab; v->iov_len = strlen(ab); v++; v->iov_base = s; v->iov_len = strlen(s); v++; v->iov_base = "\n"; v->iov_len = 1; writev(STDOUT_FILENO, iov, 3); abort(); } #else #define ASSERT(p) #endif /* debug */ /* * The origins of the following ifdef are lost. The only comment attached * to it, "avoid break bug", probably has something to do with a bug in * an older PDP-11 kernel. Maybe it's still a bug in the current kernel. * We'll probably never know ... */ #ifdef pdp11 # define GRANULE 64 #else # define GRANULE 0 #endif /* * C storage allocator * * Uses circular first-fit strategy. Works with a noncontiguous, but * monotonically linked, arena. Each block is preceded by a ptr to the * pointer of the next following block. Blocks are exact number of words * long aligned to the data type requirements of ALIGN. * * Bit 0 (LSB) of pointers is used to indicate whether the block associated * with the pointer is in use. A 1 indicates a busy block and a 0 a free * block (obviously pointers can't point at odd addresses). Gaps in arena * are merely noted as busy blocks. The last block of the arena (pointed * to by alloct) is empty and has a pointer to first. Idle blocks are * coalesced during space search * * Different implementations may need to redefine ALIGN, NALIGN, BLOCK, * BUSY, INT where INT is integer type to which a pointer can be cast. */ #define INT int #define ALIGN int #define NALIGN 1 #define WORD sizeof(union store) #define BLOCK 1024 /* a multiple of WORD */ #define BUSY 1 #define testbusy(p) ((INT)(p)&BUSY) #define setbusy(p) (union store *)((INT)(p)|BUSY) #define clearbusy(p) (union store *)((INT)(p)&~BUSY) union store { union store *ptr; ALIGN dummy[NALIGN]; int calloc; /* calloc clears an array of integers */ }; static union store allocs[2]; /* initial arena */ static union store *allocp; /* search ptr */ static union store *alloct; /* arena top */ static union store *allocx; /* for benefit of realloc */ void * malloc(nbytes) size_t nbytes; { register union store *p, *q; register int nw; static int temp; /* coroutines assume no auto */ if (nbytes == 0) return(NULL); if (allocs[0].ptr == 0) { /* first time */ allocs[0].ptr = setbusy(&allocs[1]); allocs[1].ptr = setbusy(&allocs[0]); alloct = &allocs[1]; allocp = &allocs[0]; } nw = (nbytes+WORD+WORD-1)/WORD; ASSERT(allocp >= allocs && allocp <= alloct); ASSERT(allock()); for (p = allocp; ; ) { for (temp = 0; ; ) { if (!testbusy(p->ptr)) { while(!testbusy((q = p->ptr)->ptr)) { ASSERT(q > p && q < alloct); p->ptr = q->ptr; } if (q >= p+nw && p+nw >= p) goto found; } q = p; p = clearbusy(p->ptr); if (p > q) ASSERT(p <= alloct); else if (q != alloct || p != allocs) { ASSERT(q == alloct && p == allocs); return(NULL); } else if (++temp > 1) break; } q = (union store *)sbrk(0); /* * Line up on page boundry so we can get the last drip at * the end ... */ temp = ((((unsigned)q + WORD*nw + BLOCK-1)/BLOCK)*BLOCK - (unsigned)q) / WORD; if (q+temp+GRANULE < q) return(NULL); q = (union store *)sbrk(temp*WORD); if ((INT)q == -1) return(NULL); ASSERT(q > alloct); alloct->ptr = q; if (q != alloct+1) alloct->ptr = setbusy(alloct->ptr); alloct = q->ptr = q+temp-1; alloct->ptr = setbusy(allocs); } found: allocp = p + nw; ASSERT(allocp <= alloct); if (q > allocp) { allocx = allocp->ptr; allocp->ptr = p->ptr; } p->ptr = setbusy(allocp); return((char *)(p+1)); } /* * Freeing strategy tuned for LIFO allocation. */ void free(ap) register void *ap; { register union store *p = (union store *)ap; if (p == NULL) return; ASSERT(p > clearbusy(allocs[1].ptr) && p <= alloct); ASSERT(allock()); allocp = --p; ASSERT(testbusy(p->ptr)); p->ptr = clearbusy(p->ptr); ASSERT(p->ptr > allocp && p->ptr <= alloct); } /* * Realloc(p, nbytes) reallocates a block obtained from malloc() and freed * since last call of malloc() to have new size nbytes, and old content * returns new location, or 0 on failure. */ void * realloc(vp, nbytes) register void *vp; size_t nbytes; { register union store *p = vp; register union store *q; union store *s, *t; register unsigned nw; unsigned onw; if (p == NULL) return malloc(nbytes); if (testbusy(p[-1].ptr)) free((char *)p); onw = p[-1].ptr - p; q = (union store *)malloc(nbytes); if (q == NULL || q == p) return((char *)q); s = p; t = q; nw = (nbytes+WORD-1)/WORD; if (nw < onw) onw = nw; while (onw-- != 0) *t++ = *s++; if (q < p && q+nw >= p) (q+(q+nw-p))->ptr = allocx; return((char *)q); } #ifdef debug static allock() { #ifdef longdebug register union store *p; int x; x = 0; for (p= &allocs[0]; clearbusy(p->ptr) > p; p=clearbusy(p->ptr)) { if (p == allocp) x++; } ASSERT(p == alloct); return((x == 1) | (p == allocp)); #else return(1); #endif } #endif /* debug */ ================================================ FILE: lib/libc/gen/mktemp.c ================================================ /* * Copyright (c) 1987 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include #include #include #include #include #include #include #include #define YES 1 #define NO 0 static int _gettemp(as, doopen) char *as; register int *doopen; { extern int errno; register char *start, *trv; struct stat sbuf; u_int pid; pid = getpid(); /* extra X's get set to 0's */ for (trv = as; *trv; ++trv); while (*--trv == 'X') { *trv = (pid % 10) + '0'; pid /= 10; } /* * check for write permission on target directory; if you have * six X's and you can't write the directory, this will run for * a *very* long time. */ for (start = ++trv; trv > as && *trv != '/'; --trv); if (*trv == '/') { *trv = '\0'; if (stat(as, &sbuf) || !(sbuf.st_mode & S_IFDIR)) return(NO); *trv = '/'; } else if (stat(".", &sbuf) == -1) return(NO); for (;;) { if (doopen) { if ((*doopen = open(as, O_CREAT|O_EXCL|O_RDWR, 0600)) >= 0) return(YES); if (errno != EEXIST) return(NO); } else if (stat(as, &sbuf)) return(errno == ENOENT ? YES : NO); /* tricky little algorithm for backward compatibility */ for (trv = start;;) { if (!*trv) return(NO); if (*trv == 'z') *trv++ = 'a'; else { if (isdigit(*trv)) *trv = 'a'; else ++*trv; break; } } } /*NOTREACHED*/ } int mkstemp(as) char *as; { int fd; return (_gettemp(as, &fd) ? fd : -1); } char * mktemp(as) char *as; { return(_gettemp(as, (int *)NULL) ? as : (char *)NULL); } ================================================ FILE: lib/libc/gen/modf.c ================================================ /* * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. * * Developed at SunPro, a Sun Microsystems, Inc. business. * Permission to use, copy, modify, and distribute this * software is freely granted, provided that this notice * is preserved. */ #include /* Get two 32 bit ints from a double. */ #define EXTRACT_WORDS(high,low,d) \ high = *(unsigned long long*) &d; \ low = (*(unsigned long long*) &d) >> 32 /* Set a double from two 32 bit ints. */ #define INSERT_WORDS(d,high,low) \ *(unsigned long long*) &(x) = (unsigned long long) (high) << 32 | (low) /* * modf(double x, double *iptr) * return fraction part of x, and return x's integral part in *iptr. * Method: * Bit twiddling. * * Exception: * No exception. */ static const double one = 1.0; double modf (double x, double *iptr) { long i0, i1, j0; unsigned long i; EXTRACT_WORDS (i0, i1, x); j0 = ((i0 >> 20) & 0x7ff) - 0x3ff; /* exponent of x */ if (j0 < 20) { /* integer part in high x */ if (j0 < 0) { /* |x|<1 */ INSERT_WORDS (*iptr, i0 & 0x80000000, 0); /* *iptr = +-0 */ return x; } else { i = (0x000fffff) >> j0; if (((i0 & i) | i1) == 0) { /* x is integral */ *iptr = x; INSERT_WORDS (x, i0 & 0x80000000, 0); /* return +-0 */ return x; } else { INSERT_WORDS (*iptr, i0 & (~i), 0); return x - *iptr; } } } else if (j0 > 51) { /* no fraction part */ *iptr = x * one; /* We must handle NaNs separately. */ if (j0 == 0x400 && ((i0 & 0xfffff) | i1)) return x * one; INSERT_WORDS (x, i0 & 0x80000000, 0); /* return +-0 */ return x; } else { /* fraction part in low x */ i = ((unsigned long) (0xffffffff)) >> (j0 - 20); if ((i1 & i) == 0) { /* x is integral */ *iptr = x; INSERT_WORDS (x, i0 & 0x80000000, 0); /* return +-0 */ return x; } else { INSERT_WORDS (*iptr, i0, i1 & (~i)); return x - *iptr; } } } ================================================ FILE: lib/libc/gen/modff.c ================================================ /* * Written by Serge Vakulenko . * * Permission to use, copy, modify, and distribute this * software is freely granted, provided that this notice * is preserved. */ #include /* * modff(float x, float *iptr) * return fraction part of x, and return x's integral part in *iptr. */ float modff (float fx, float *iptr) { union { unsigned u32; float f32; } x; unsigned hx, s; x.f32 = fx; hx = x.u32 & ~0x80000000; if (hx >= 0x4b000000) { /* x is NaN, infinite, or integral */ *iptr = x.f32; if (hx <= 0x7f800000) x.u32 &= 0x80000000; return x.f32; } if (hx < 0x3f800000) { /* |x| < 1 */ float ret = x.f32; x.u32 &= 0x80000000; *iptr = x.f32; return ret; } /* split x at the binary point */ s = x.u32 & 0x80000000; fx = x.f32; x.u32 &= ~((1 << (0x96 - (hx >> 23))) - 1); *iptr = x.f32; x.f32 = fx - *iptr; /* restore sign in case difference is 0 */ x.u32 = (x.u32 & ~0x80000000) | s; return x.f32; } /* * For PIC32, double is the same as float. */ double modf (double x, double *iptr) __attribute__((alias ("modff"))); ================================================ FILE: lib/libc/gen/ndbm.c ================================================ /* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include #include #include #include #include #include #include #include #include #include #include #define BYTESIZ 8 #undef setbit static int hitab[16] /* ken's { 055,043,036,054,063,014,004,005, 010,064,077,000,035,027,025,071, }; */ = { 61, 57, 53, 49, 45, 41, 37, 33, 29, 25, 21, 17, 13, 9, 5, 1, }; static long hltab[64] = { 06100151277L,06106161736L,06452611562L,05001724107L, 02614772546L,04120731531L,04665262210L,07347467531L, 06735253126L,06042345173L,03072226605L,01464164730L, 03247435524L,07652510057L,01546775256L,05714532133L, 06173260402L,07517101630L,02431460343L,01743245566L, 00261675137L,02433103631L,03421772437L,04447707466L, 04435620103L,03757017115L,03641531772L,06767633246L, 02673230344L,00260612216L,04133454451L,00615531516L, 06137717526L,02574116560L,02304023373L,07061702261L, 05153031405L,05322056705L,07401116734L,06552375715L, 06165233473L,05311063631L,01212221723L,01052267235L, 06000615237L,01075222665L,06330216006L,04402355630L, 01451177262L,02000133436L,06025467062L,07121076461L, 03123433522L,01010635225L,01716177066L,05161746527L, 01736635071L,06243505026L,03637211610L,01756474365L, 04723077174L,03642763134L,05750130273L,03655541561L, }; static long dcalchash(item) datum item; { register int s, c, j; register char *cp; register long hashl; register int hashi; hashl = 0; hashi = 0; for (cp = item.dptr, s=item.dsize; --s >= 0; ) { c = *cp++; for (j=0; j>= 4; } } return (hashl); } static datum makdatum(buf, n) char buf[PBLKSIZ]; int n; { register short *sp; register int t; datum item; sp = (short *)buf; if ((unsigned)n >= sp[0]) { item.dptr = NULL; item.dsize = 0; return (item); } t = PBLKSIZ; if (n > 0) t = sp[n]; item.dptr = buf+sp[n+1]; item.dsize = t - sp[n+1]; return (item); } DBM * dbm_open(file, flags, mode) char *file; int flags, mode; { struct stat statb; register DBM *db; if ((db = (DBM *)malloc(sizeof *db)) == 0) { errno = ENOMEM; return ((DBM *)0); } db->dbm_flags = (flags & 03) == O_RDONLY ? _DBM_RDONLY : 0; if ((flags & 03) == O_WRONLY) flags = (flags & ~03) | O_RDWR; strcpy(db->dbm_pagbuf, file); strcat(db->dbm_pagbuf, ".pag"); db->dbm_pagf = open(db->dbm_pagbuf, flags, mode); if (db->dbm_pagf < 0) goto bad; strcpy(db->dbm_pagbuf, file); strcat(db->dbm_pagbuf, ".dir"); db->dbm_dirf = open(db->dbm_pagbuf, flags, mode); if (db->dbm_dirf < 0) goto bad1; fstat(db->dbm_dirf, &statb); db->dbm_maxbno = statb.st_size*BYTESIZ-1; db->dbm_pagbno = db->dbm_dirbno = -1; return (db); bad1: (void) close(db->dbm_pagf); bad: free((char *)db); return ((DBM *)0); } void dbm_close(db) DBM *db; { (void) close(db->dbm_dirf); (void) close(db->dbm_pagf); free((char *)db); } static int getbit(db) register DBM *db; { long bn, b; register int i, n; if (db->dbm_bitno > db->dbm_maxbno) return (0); n = db->dbm_bitno % BYTESIZ; bn = db->dbm_bitno / BYTESIZ; i = bn % DBLKSIZ; b = bn / DBLKSIZ; if (b != db->dbm_dirbno) { db->dbm_dirbno = b; (void) lseek(db->dbm_dirf, b*DBLKSIZ, L_SET); if (read(db->dbm_dirf, db->dbm_dirbuf, DBLKSIZ) != DBLKSIZ) bzero(db->dbm_dirbuf, DBLKSIZ); } return (db->dbm_dirbuf[i] & (1<dbm_hmask=0;; db->dbm_hmask=(db->dbm_hmask<<1)+1) { db->dbm_blkno = hash & db->dbm_hmask; db->dbm_bitno = db->dbm_blkno + db->dbm_hmask; if (getbit(db) == 0) break; } return (db->dbm_blkno); } static void dbm_access(db, hash) register DBM *db; long hash; { for (db->dbm_hmask=0;; db->dbm_hmask=(db->dbm_hmask<<1)+1) { db->dbm_blkno = hash & db->dbm_hmask; db->dbm_bitno = db->dbm_blkno + db->dbm_hmask; if (getbit(db) == 0) break; } if (db->dbm_blkno != db->dbm_pagbno) { db->dbm_pagbno = db->dbm_blkno; (void) lseek(db->dbm_pagf, db->dbm_blkno*PBLKSIZ, L_SET); if (read(db->dbm_pagf, db->dbm_pagbuf, PBLKSIZ) != PBLKSIZ) bzero(db->dbm_pagbuf, PBLKSIZ); #ifdef DEBUG else if (chkblk(db->dbm_pagbuf) < 0) db->dbm_flags |= _DBM_IOERR; #endif } } static int finddatum(buf, item) char buf[PBLKSIZ]; datum item; { register short *sp; register int i, n, j; sp = (short *)buf; n = PBLKSIZ; for (i=0, j=sp[0]; idbm_pagbuf, key)) >= 0) { item = makdatum(db->dbm_pagbuf, i+1); if (item.dptr != NULL) return (item); } err: item.dptr = NULL; item.dsize = 0; return (item); } /* * Delete pairs of items (n & n+1). */ static int delitem(buf, n) char buf[PBLKSIZ]; int n; { register short *sp, *sp1; register int i1, i2; sp = (short *)buf; i2 = sp[0]; if ((unsigned)n >= i2 || (n & 1)) return (0); if (n == i2-2) { sp[0] -= 2; return (1); } i1 = PBLKSIZ; if (n > 0) i1 = sp[n]; i1 -= sp[n+2]; if (i1 > 0) { i2 = sp[i2]; bcopy(&buf[i2], &buf[i2 + i1], sp[n+2] - i2); } sp[0] -= 2; for (sp1 = sp + sp[0], sp += n+1; sp <= sp1; sp++) sp[0] = sp[2] + i1; return (1); } int dbm_delete(db, key) register DBM *db; datum key; { register int i; if (dbm_error(db)) return (-1); if (dbm_rdonly(db)) { errno = EPERM; return (-1); } dbm_access(db, dcalchash(key)); if ((i = finddatum(db->dbm_pagbuf, key)) < 0) return (-1); if (!delitem(db->dbm_pagbuf, i)) goto err; db->dbm_pagbno = db->dbm_blkno; (void) lseek(db->dbm_pagf, db->dbm_blkno*PBLKSIZ, L_SET); if (write(db->dbm_pagf, db->dbm_pagbuf, PBLKSIZ) != PBLKSIZ) { err: db->dbm_flags |= _DBM_IOERR; return (-1); } return (0); } static void setbit(db) register DBM *db; { long bn, b; register int i, n; if (db->dbm_bitno > db->dbm_maxbno) db->dbm_maxbno = db->dbm_bitno; n = db->dbm_bitno % BYTESIZ; bn = db->dbm_bitno / BYTESIZ; i = bn % DBLKSIZ; b = bn / DBLKSIZ; if (b != db->dbm_dirbno) { db->dbm_dirbno = b; (void) lseek(db->dbm_dirf, b*DBLKSIZ, L_SET); if (read(db->dbm_dirf, db->dbm_dirbuf, DBLKSIZ) != DBLKSIZ) bzero(db->dbm_dirbuf, DBLKSIZ); } db->dbm_dirbuf[i] |= 1<dbm_dirbno = b; (void) lseek(db->dbm_dirf, (long)b*DBLKSIZ, L_SET); if (write(db->dbm_dirf, db->dbm_dirbuf, DBLKSIZ) != DBLKSIZ) db->dbm_flags |= _DBM_IOERR; } /* * Add pairs of items (item & item1). */ static int additem(buf, item, item1) char buf[PBLKSIZ]; datum item, item1; { register short *sp; register int i1, i2; sp = (short *)buf; i1 = PBLKSIZ; i2 = sp[0]; if (i2 > 0) i1 = sp[i2]; i1 -= item.dsize + item1.dsize; if (i1 <= (int)((i2+3) * sizeof(short))) return (0); sp[0] += 2; sp[++i2] = i1 + item1.dsize; bcopy(item.dptr, &buf[i1 + item1.dsize], item.dsize); sp[++i2] = i1; bcopy(item1.dptr, &buf[i1], item1.dsize); return (1); } int dbm_store(db, key, dat, replace) register DBM *db; datum key, dat; int replace; { register int i; datum item, item1; char ovfbuf[PBLKSIZ]; if (dbm_error(db)) return (-1); if (dbm_rdonly(db)) { errno = EPERM; return (-1); } loop: dbm_access(db, dcalchash(key)); if ((i = finddatum(db->dbm_pagbuf, key)) >= 0) { if (!replace) return (1); if (!delitem(db->dbm_pagbuf, i)) { db->dbm_flags |= _DBM_IOERR; return (-1); } } if (!additem(db->dbm_pagbuf, key, dat)) goto split; db->dbm_pagbno = db->dbm_blkno; (void) lseek(db->dbm_pagf, db->dbm_blkno*PBLKSIZ, L_SET); if (write(db->dbm_pagf, db->dbm_pagbuf, PBLKSIZ) != PBLKSIZ) { db->dbm_flags |= _DBM_IOERR; return (-1); } return (0); split: if (key.dsize+dat.dsize+3*sizeof(short) >= PBLKSIZ) { db->dbm_flags |= _DBM_IOERR; errno = ENOSPC; return (-1); } bzero(ovfbuf, PBLKSIZ); for (i=0;;) { item = makdatum(db->dbm_pagbuf, i); if (item.dptr == NULL) break; if (dcalchash(item) & (db->dbm_hmask+1)) { item1 = makdatum(db->dbm_pagbuf, i+1); if (item1.dptr == NULL) { fprintf(stderr, "ndbm: split not paired\n"); db->dbm_flags |= _DBM_IOERR; break; } if (!additem(ovfbuf, item, item1) || !delitem(db->dbm_pagbuf, i)) { db->dbm_flags |= _DBM_IOERR; return (-1); } continue; } i += 2; } db->dbm_pagbno = db->dbm_blkno; (void) lseek(db->dbm_pagf, db->dbm_blkno*PBLKSIZ, L_SET); if (write(db->dbm_pagf, db->dbm_pagbuf, PBLKSIZ) != PBLKSIZ) { db->dbm_flags |= _DBM_IOERR; return (-1); } (void) lseek(db->dbm_pagf, (db->dbm_blkno+db->dbm_hmask+1)*PBLKSIZ, L_SET); if (write(db->dbm_pagf, ovfbuf, PBLKSIZ) != PBLKSIZ) { db->dbm_flags |= _DBM_IOERR; return (-1); } setbit(db); goto loop; } datum dbm_firstkey(db) DBM *db; { db->dbm_blkptr = 0L; db->dbm_keyptr = 0; return (dbm_nextkey(db)); } datum dbm_nextkey(db) register DBM *db; { struct stat statb; datum item; if (dbm_error(db) || fstat(db->dbm_pagf, &statb) < 0) goto err; statb.st_size /= PBLKSIZ; for (;;) { if (db->dbm_blkptr != db->dbm_pagbno) { db->dbm_pagbno = db->dbm_blkptr; (void) lseek(db->dbm_pagf, db->dbm_blkptr*PBLKSIZ, L_SET); if (read(db->dbm_pagf, db->dbm_pagbuf, PBLKSIZ) != PBLKSIZ) bzero(db->dbm_pagbuf, PBLKSIZ); #ifdef DEBUG else if (chkblk(db->dbm_pagbuf) < 0) db->dbm_flags |= _DBM_IOERR; #endif } if (db->dbm_pagbuf[0] != 0 && db->dbm_pagbuf[1] != 0) { item = makdatum(db->dbm_pagbuf, db->dbm_keyptr); if (item.dptr != NULL) { db->dbm_keyptr += 2; return (item); } db->dbm_keyptr = 0; } if (++db->dbm_blkptr >= statb.st_size) break; } err: item.dptr = NULL; item.dsize = 0; return (item); } #ifdef DEBUG static chkblk(buf) char buf[PBLKSIZ]; { register short *sp; register t, i; sp = (short *)buf; t = PBLKSIZ; for (i=0; i t) return (-1); t = sp[i+1]; } if (t < (sp[0]+1)*sizeof(short)) return (-1); return (0); } #endif ================================================ FILE: lib/libc/gen/nlist.c ================================================ /* * Copyright (c) 1989 The Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that: (1) source distributions retain this entire copyright * notice and comment, and (2) distributions including binaries display * the following acknowledgement: ``This product includes software * developed by the University of California, Berkeley and its contributors'' * in the documentation or other materials provided with the distribution * and in all advertising materials mentioning features or use of this * software. Neither the name of the University nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #include #include #include #include #include #define ISVALID(p) (p->n_name && p->n_name[0]) int nlist(name, list) char *name; struct nlist *list; { register struct nlist *p; struct exec ebuf; register FILE *fsym; off_t symbol_offset, symbol_size; int entries, len, maxlen, type; register int c; register unsigned value; char sbuf[128]; entries = -1; if (!(fsym = fopen(name, "r"))) return(-1); if (fread((char *)&ebuf, 1, sizeof(ebuf), fsym) != sizeof (ebuf) || N_BADMAG(ebuf)) goto done; symbol_offset = N_SYMOFF(ebuf); symbol_size = ebuf.a_syms; if (fseek(fsym, symbol_offset, L_SET)) goto done; /* * clean out any left-over information for all valid entries. * Type and value defined to be 0 if not found; historical * versions cleared other and desc as well. Also figure out * the largest string length so don't read any more of the * string table than we have to. */ for (p = list, entries = maxlen = 0; ISVALID(p); ++p, ++entries) { p->n_type = 0; p->n_value = 0; if ((len = strlen(p->n_name)) > maxlen) maxlen = len; } if (++maxlen > sizeof(sbuf)) { /* for the NULL */ (void)fprintf(stderr, "nlist: sym 2 big\n"); entries = -1; goto done; } for (; symbol_size; symbol_size -= len + 6) { len = getc (fsym); if (len <= 0) break; type = getc (fsym); value = getc (fsym); value |= getc (fsym) << 8; value |= getc (fsym) << 16; value |= getc (fsym) << 24; for (c=0; cn_name, sbuf) == 0) { p->n_value = value; p->n_type = type; if (!--entries) goto done; } } done: (void)fclose(fsym); return(entries); } ================================================ FILE: lib/libc/gen/opendir.c ================================================ /* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include #include #include #include #include /* * open a directory. */ DIR * opendir(name) const char *name; { register DIR *dirp; register int fd; if ((fd = open(name, 0)) == -1) return NULL; if ((dirp = (DIR *)malloc(sizeof(DIR))) == NULL) { close (fd); return NULL; } dirp->dd_fd = fd; dirp->dd_loc = 0; return dirp; } ================================================ FILE: lib/libc/gen/perror.c ================================================ /* * Copyright (c) 1988, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #include #include #include #include #include void perror(s) const char *s; { register struct iovec *v; struct iovec iov[4]; v = iov; if (s && *s) { v->iov_base = (char *)s; v->iov_len = strlen(s); v++; v->iov_base = ": "; v->iov_len = 2; v++; } v->iov_base = (void*) strerror(errno); v->iov_len = strlen(v->iov_base); v++; v->iov_base = "\n"; v->iov_len = 1; (void)writev(STDERR_FILENO, iov, (v - iov) + 1); } ================================================ FILE: lib/libc/gen/popen.c ================================================ /* * Copyright (c) 1988 The Regents of the University of California. * All rights reserved. * * This code is derived from software written by Ken Arnold and * published in UNIX Review, Vol. 6, No. 8. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #include #include #include #include #include #include #include static int *pids; FILE * popen(program, type) const char *program; register const char *type; { register FILE *iop; int pdes[2], fds, pid; if (*type != 'r' && *type != 'w') return (NULL); if (type[1]) return (NULL); if (pids == NULL) { if ((fds = getdtablesize()) <= 0) return (NULL); if ((pids = (int *)malloc((u_int)(fds * sizeof(int)))) == NULL) return (NULL); bzero((char *)pids, fds * sizeof(int)); } if (pipe(pdes) < 0) return (NULL); switch (pid = vfork()) { case -1: /* error */ (void) close(pdes[0]); (void) close(pdes[1]); return (NULL); /* NOTREACHED */ case 0: /* child */ if (*type == 'r') { if (pdes[1] != fileno(stdout)) { (void) dup2(pdes[1], fileno(stdout)); (void) close(pdes[1]); } (void) close(pdes[0]); } else { if (pdes[0] != fileno(stdin)) { (void) dup2(pdes[0], fileno(stdin)); (void) close(pdes[0]); } (void) close(pdes[1]); } execl("/bin/sh", "sh", "-c", program, (char*)0); _exit(127); /* NOTREACHED */ } /* parent; assume fdopen can't fail... */ if (*type == 'r') { iop = fdopen(pdes[0], type); (void) close(pdes[1]); } else { iop = fdopen(pdes[1], type); (void) close(pdes[0]); } pids[fileno(iop)] = pid; return (iop); } int pclose(iop) FILE *iop; { register int fdes; sigset_t omask, nmask; union wait pstat; register int pid; /* * pclose returns -1 if stream is not associated with a * `popened' command, if already `pclosed', or waitpid * returns an error. */ if (pids == NULL || pids[fdes = fileno(iop)] == 0) return (-1); (void) fclose(iop); (void) sigemptyset(&nmask); (void) sigaddset(&nmask, SIGINT); (void) sigaddset(&nmask, SIGQUIT); (void) sigaddset(&nmask, SIGHUP); (void) sigprocmask(SIG_BLOCK, &nmask, &omask); do { pid = waitpid(pids[fdes], (int *) &pstat, 0); } while (pid == -1 && errno == EINTR); (void) sigprocmask(SIG_SETMASK, &omask, NULL); pids[fdes] = 0; return (pid == -1 ? -1 : pstat.w_status); } ================================================ FILE: lib/libc/gen/psignal.c ================================================ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include #include #include /* * Print the name of the signal indicated * along with the supplied message. */ extern char *sys_siglist[]; void psignal(sig, s) unsigned sig; char *s; { register char *c; register int n; c = "Unknown signal"; if (sig < NSIG) c = sys_siglist[sig]; n = strlen(s); if (n) { write(2, s, n); write(2, ": ", 2); } write(2, c, strlen(c)); write(2, "\n", 1); } ================================================ FILE: lib/libc/gen/qsort.c ================================================ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ /* * qsort.c: * Our own version of the system qsort routine which is faster by an average * of 25%, with lows and highs of 10% and 50%. * The THRESHold below is the insertion sort threshold, and has been adjusted * for records of size 48 bytes. * The MTHREShold is where we stop finding a better median. */ #define THRESH 4 /* threshold for insertion */ #define MTHRESH 6 /* threshold for median */ static int (*qcmp)(); /* the comparison routine */ static int qsz; /* size of each record */ static int thresh; /* THRESHold in chars */ static int mthresh; /* MTHRESHold in chars */ /* * qst: * Do a quicksort * First, find the median element, and put that one in the first place as the * discriminator. (This "median" is just the median of the first, last and * middle elements). (Using this median instead of the first element is a big * win). Then, the usual partitioning/swapping, followed by moving the * discriminator into the right place. Then, figure out the sizes of the two * partions, do the smaller one recursively and the larger one via a repeat of * this code. Stopping when there are less than THRESH elements in a partition * and cleaning up with an insertion sort (in our caller) is a huge win. * All data swaps are done in-line, which is space-losing but time-saving. * (And there are only three places where this is done). */ static void qst(base, max) char *base, *max; { register char c, *i, *j, *jj; register int ii; char *mid, *tmp; unsigned int lo, hi; /* * At the top here, lo is the number of characters of elements in the * current partition. (Which should be max - base). * Find the median of the first, last, and middle element and make * that the middle element. Set j to largest of first and middle. * If max is larger than that guy, then it's that guy, else compare * max with loser of first and take larger. Things are set up to * prefer the middle, then the first in case of ties. */ lo = max - base; /* number of elements as chars */ do { mid = i = base + qsz * ((lo / qsz) >> 1); if (lo >= mthresh) { j = (qcmp((jj = base), i) > 0 ? jj : i); if (qcmp(j, (tmp = max - qsz)) > 0) { /* switch to first loser */ j = (j == jj ? i : jj); if (qcmp(j, tmp) < 0) j = tmp; } if (j != i) { ii = qsz; do { c = *i; *i++ = *j; *j++ = c; } while (--ii); } } /* * Semi-standard quicksort partitioning/swapping */ for (i = base, j = max - qsz; ; ) { while (i < mid && qcmp(i, mid) <= 0) i += qsz; while (j > mid) { if (qcmp(mid, j) <= 0) { j -= qsz; continue; } tmp = i + qsz; /* value of i after swap */ if (i == mid) { /* j <-> mid, new mid is j */ mid = jj = j; } else { /* i <-> j */ jj = j; j -= qsz; } goto swap; } if (i == mid) { break; } else { /* i <-> mid, new mid is i */ jj = mid; tmp = mid = i; /* value of i after swap */ j -= qsz; } swap: ii = qsz; do { c = *i; *i++ = *jj; *jj++ = c; } while (--ii); i = tmp; } /* * Look at sizes of the two partitions, do the smaller * one first by recursion, then do the larger one by * making sure lo is its size, base and max are update * correctly, and branching back. But only repeat * (recursively or by branching) if the partition is * of at least size THRESH. */ i = (j = mid) + qsz; if ((lo = j - base) <= (hi = max - i)) { if (lo >= thresh) qst(base, j); base = i; lo = hi; } else { if (hi >= thresh) qst(i, max); max = j; } } while (lo >= thresh); } /* * qsort: * First, set up some global parameters for qst to share. Then, quicksort * with qst(), and then a cleanup insertion sort ourselves. Sound simple? * It's not... */ void qsort(base, n, size, compar) char *base; int n; int size; int (*compar)(); { register char c, *i, *j, *lo, *hi; char *min, *max; if (n <= 1) return; qsz = size; qcmp = compar; thresh = qsz * THRESH; mthresh = qsz * MTHRESH; max = base + n * qsz; if (n >= THRESH) { qst(base, max); hi = base + thresh; } else { hi = max; } /* * First put smallest element, which must be in the first THRESH, in * the first position as a sentinel. This is done just by searching * the first THRESH elements (or the first n if n < THRESH), finding * the min, and swapping it into the first position. */ for (j = lo = base; (lo += qsz) < hi; ) if (qcmp(j, lo) > 0) j = lo; if (j != base) { /* swap j into place */ for (i = base, hi = base + qsz; i < hi; ) { c = *j; *j++ = *i; *i++ = c; } } /* * With our sentinel in place, we now run the following hyper-fast * insertion sort. For each remaining element, min, from [1] to [n-1], * set hi to the index of the element AFTER which this one goes. * Then, do the standard insertion sort shift on a character at a time * basis for each element in the frob. */ for (min = base; (hi = min += qsz) < max; ) { while (qcmp(hi -= qsz, min) > 0) /* void */; if ((hi += qsz) != min) { for (lo = min + qsz; --lo >= min; ) { c = *lo; for (i = j = lo; (j -= qsz) >= hi; i = j) *i = *j; *i = c; } } } } ================================================ FILE: lib/libc/gen/random.c ================================================ /* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include #include /* * random.c: * An improved random number generation package. In addition to the standard * rand()/srand() like interface, this package also has a special state info * interface. The initstate() routine is called with a seed, an array of * bytes, and a count of how many bytes are being passed in; this array is then * initialized to contain information for random number generation with that * much state information. Good sizes for the amount of state information are * 32, 64, 128, and 256 bytes. The state can be switched by calling the * setstate() routine with the same array as was initiallized with initstate(). * By default, the package runs with 128 bytes of state information and * generates far better random numbers than a linear congruential generator. * If the amount of state information is less than 32 bytes, a simple linear * congruential R.N.G. is used. * Internally, the state information is treated as an array of longs; the * zeroeth element of the array is the type of R.N.G. being used (small * integer); the remainder of the array is the state information for the * R.N.G. Thus, 32 bytes of state information will give 7 longs worth of * state information, which will allow a degree seven polynomial. (Note: the * zeroeth word of state information also has some other information stored * in it -- see setstate() for details). * The random number generation technique is a linear feedback shift register * approach, employing trinomials (since there are fewer terms to sum up that * way). In this approach, the least significant bit of all the numbers in * the state table will act as a linear feedback shift register, and will have * period 2^deg - 1 (where deg is the degree of the polynomial being used, * assuming that the polynomial is irreducible and primitive). The higher * order bits will have longer periods, since their values are also influenced * by pseudo-random carries out of the lower bits. The total period of the * generator is approximately deg*(2**deg - 1); thus doubling the amount of * state information has a vast influence on the period of the generator. * Note: the deg*(2**deg - 1) is an approximation only good for large deg, * when the period of the shift register is the dominant factor. With deg * equal to seven, the period is actually much longer than the 7*(2**7 - 1) * predicted by this formula. */ /* * For each of the currently supported random number generators, we have a * break value on the amount of state information (you need at least this * many bytes of state info to support this random number generator), a degree * for the polynomial (actually a trinomial) that the R.N.G. is based on, and * the separation between the two lower order coefficients of the trinomial. */ #define TYPE_0 0 /* linear congruential */ #define BREAK_0 8 #define DEG_0 0 #define SEP_0 0 #define TYPE_1 1 /* x**7 + x**3 + 1 */ #define BREAK_1 32 #define DEG_1 7 #define SEP_1 3 #define TYPE_2 2 /* x**15 + x + 1 */ #define BREAK_2 64 #define DEG_2 15 #define SEP_2 1 #define TYPE_3 3 /* x**31 + x**3 + 1 */ #define BREAK_3 128 #define DEG_3 31 #define SEP_3 3 #define TYPE_4 4 /* x**63 + x + 1 */ #define BREAK_4 256 #define DEG_4 63 #define SEP_4 1 /* * Array versions of the above information to make code run faster -- relies * on fact that TYPE_i == i. */ #define MAX_TYPES 5 /* max number of types above */ static int degrees[MAX_TYPES] = { DEG_0, DEG_1, DEG_2, DEG_3, DEG_4 }; static int seps[MAX_TYPES] = { SEP_0, SEP_1, SEP_2, SEP_3, SEP_4 }; /* * Initially, everything is set up as if from : * initstate(1, &randtbl, 128); * Note that this initialization takes advantage of the fact that srandom() * advances the front and rear pointers 10*rand_deg times, and hence the * rear pointer which starts at 0 will also end up at zero; thus the zeroeth * element of the state information, which contains info about the current * position of the rear pointer is just * MAX_TYPES*(rptr - state) + TYPE_3 == TYPE_3. */ static long randtbl[DEG_3 + 1] = { TYPE_3, 0x9a319039, 0x32d9c024, 0x9b663182, 0x5da1f342, 0xde3b81e0, 0xdf0a6fb5, 0xf103bc02, 0x48f340fb, 0x7449e56b, 0xbeb1dbb0, 0xab5c5918, 0x946554fd, 0x8c2e680f, 0xeb3d799f, 0xb11ee0b7, 0x2d436b86, 0xda672e2a, 0x1588ca88, 0xe369735d, 0x904f35f7, 0xd7158fd6, 0x6fa6f051, 0x616e6b96, 0xac94efdc, 0x36413f93, 0xc622c298, 0xf5a42ab8, 0x8a88d77b, 0xf5ad9d0e, 0x8999220b, 0x27fb47b9 }; /* * fptr and rptr are two pointers into the state info, a front and a rear * pointer. These two pointers are always rand_sep places aparts, as they cycle * cyclically through the state information. (Yes, this does mean we could get * away with just one pointer, but the code for random() is more efficient this * way). The pointers are left positioned as they would be from the call * initstate(1, randtbl, 128) * (The position of the rear pointer, rptr, is really 0 (as explained above * in the initialization of randtbl) because the state table pointer is set * to point to randtbl[1] (as explained below). */ static long *fptr = &randtbl[SEP_3 + 1]; static long *rptr = &randtbl[1]; /* * The following things are the pointer to the state information table, * the type of the current generator, the degree of the current polynomial * being used, and the separation between the two pointers. * Note that for efficiency of random(), we remember the first location of * the state information, not the zeroeth. Hence it is valid to access * state[-1], which is used to store the type of the R.N.G. * Also, we remember the last location, since this is more efficient than * indexing every time to find the address of the last element to see if * the front and rear pointers have wrapped. */ static long *state = &randtbl[1]; static int rand_type = TYPE_3; static int rand_deg = DEG_3; static int rand_sep = SEP_3; static long *end_ptr = &randtbl[DEG_3 + 1]; /* * srandom: * Initialize the random number generator based on the given seed. If the * type is the trivial no-state-information type, just remember the seed. * Otherwise, initializes state[] based on the given "seed" via a linear * congruential generator. Then, the pointers are set to known locations * that are exactly rand_sep places apart. Lastly, it cycles the state * information a given number of times to get rid of any initial dependencies * introduced by the L.C.R.N.G. * Note that the initialization of randtbl[] for default usage relies on * values produced by this routine. */ void srandom (x) unsigned x; { register int i; if (rand_type == TYPE_0) { state[0] = x; } else { state[0] = x; for(i = 1; i < rand_deg; i++) { state[i] = 1103515245*state[i - 1] + 12345; } fptr = &state[rand_sep]; rptr = &state[0]; for(i = 0; i < 10*rand_deg; i++) random(); } } /* * initstate: * Initialize the state information in the given array of n bytes for * future random number generation. Based on the number of bytes we * are given, and the break values for the different R.N.G.'s, we choose * the best (largest) one we can and set things up for it. srandom() is * then called to initialize the state information. * Note that on return from srandom(), we set state[-1] to be the type * multiplexed with the current value of the rear pointer; this is so * successive calls to initstate() won't lose this information and will * be able to restart with setstate(). * Note: the first thing we do is save the current state, if any, just like * setstate() so that it doesn't matter when initstate is called. * Returns a pointer to the old state. */ char * initstate (seed, arg_state, n) unsigned seed; /* seed for R. N. G. */ char *arg_state; /* pointer to state array */ int n; /* # bytes of state info */ { register char *ostate = (char *)(&state[-1]); if (rand_type == TYPE_0) state[-1] = rand_type; else state[-1] = MAX_TYPES*(rptr - state) + rand_type; if (n < BREAK_1) { if (n < BREAK_0) { fprintf(stderr, "initstate: not enough state (%d bytes) with which to do jack; ignored.\n", n); return 0; } rand_type = TYPE_0; rand_deg = DEG_0; rand_sep = SEP_0; } else { if (n < BREAK_2) { rand_type = TYPE_1; rand_deg = DEG_1; rand_sep = SEP_1; } else { if (n < BREAK_3) { rand_type = TYPE_2; rand_deg = DEG_2; rand_sep = SEP_2; } else { if (n < BREAK_4) { rand_type = TYPE_3; rand_deg = DEG_3; rand_sep = SEP_3; } else { rand_type = TYPE_4; rand_deg = DEG_4; rand_sep = SEP_4; } } } } state = &(((long *)arg_state)[1]); /* first location */ end_ptr = &state[rand_deg]; /* must set end_ptr before srandom */ srandom(seed); if (rand_type == TYPE_0) state[-1] = rand_type; else state[-1] = MAX_TYPES*(rptr - state) + rand_type; return(ostate); } /* * setstate: * Restore the state from the given state array. * Note: it is important that we also remember the locations of the pointers * in the current state information, and restore the locations of the pointers * from the old state information. This is done by multiplexing the pointer * location into the zeroeth word of the state information. * Note that due to the order in which things are done, it is OK to call * setstate() with the same state as the current state. * Returns a pointer to the old state information. */ char * setstate (arg_state) char *arg_state; { register long *new_state = (long *)arg_state; register int type = new_state[0]%MAX_TYPES; register int rear = new_state[0]/MAX_TYPES; char *ostate = (char *)(&state[-1]); if (rand_type == TYPE_0) state[-1] = rand_type; else state[-1] = MAX_TYPES*(rptr - state) + rand_type; switch(type) { case TYPE_0: case TYPE_1: case TYPE_2: case TYPE_3: case TYPE_4: rand_type = type; rand_deg = degrees[type]; rand_sep = seps[type]; break; default: fprintf(stderr, "setstate: state info has been munged; not changed.\n"); } state = &new_state[1]; if (rand_type != TYPE_0) { rptr = &state[rear]; fptr = &state[(rear + rand_sep)%rand_deg]; } end_ptr = &state[rand_deg]; /* set end_ptr too */ return(ostate); } /* * random: * If we are using the trivial TYPE_0 R.N.G., just do the old linear * congruential bit. Otherwise, we do our fancy trinomial stuff, which is the * same in all ther other cases due to all the global variables that have been * set up. The basic operation is to add the number at the rear pointer into * the one at the front pointer. Then both pointers are advanced to the next * location cyclically in the table. The value returned is the sum generated, * reduced to 31 bits by throwing away the "least random" low bit. * Note: the code takes advantage of the fact that both the front and * rear pointers can't wrap on the same call by not testing the rear * pointer if the front one has wrapped. * Returns a 31-bit random number. */ long random() { long i; if (rand_type == TYPE_0) { i = state[0] = (state[0]*1103515245 + 12345)&0x7fffffff; } else { *fptr += *rptr; i = (*fptr >> 1)&0x7fffffff; /* chucking least random bit */ if (++fptr >= end_ptr) { fptr = state; ++rptr; } else { if (++rptr >= end_ptr) rptr = state; } } return(i); } ================================================ FILE: lib/libc/gen/readdir.c ================================================ /* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include #include #include /* * get next entry in a directory. */ struct direct * readdir(dirp) register DIR *dirp; { register struct direct *dp; for (;;) { if (dirp->dd_loc == 0) { dirp->dd_size = read(dirp->dd_fd, dirp->dd_buf, DIRBLKSIZ); if (dirp->dd_size <= 0) return NULL; } if (dirp->dd_loc >= dirp->dd_size) { dirp->dd_loc = 0; continue; } dp = (struct direct *)(dirp->dd_buf + dirp->dd_loc); if (dp->d_reclen <= 0 || dp->d_reclen > DIRBLKSIZ + 1 - dirp->dd_loc) return NULL; dirp->dd_loc += dp->d_reclen; if (dp->d_ino == 0) continue; return (dp); } } ================================================ FILE: lib/libc/gen/regex.c ================================================ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ /* * routines to do regular expression matching * * Entry points: * * re_comp(s) * char *s; * ... returns 0 if the string s was compiled successfully, * a pointer to an error message otherwise. * If passed 0 or a null string returns without changing * the currently compiled re (see note 11 below). * * re_exec(s) * char *s; * ... returns 1 if the string s matches the last compiled regular * expression, * 0 if the string s failed to match the last compiled * regular expression, and * -1 if the compiled regular expression was invalid * (indicating an internal error). * * The strings passed to both re_comp and re_exec may have trailing or * embedded newline characters; they are terminated by nulls. * * The identity of the author of these routines is lost in antiquity; * this is essentially the same as the re code in the original V6 ed. * * The regular expressions recognized are described below. This description * is essentially the same as that for ed. * * A regular expression specifies a set of strings of characters. * A member of this set of strings is said to be matched by * the regular expression. In the following specification for * regular expressions the word `character' means any character but NUL. * * 1. Any character except a special character matches itself. * Special characters are the regular expression delimiter plus * \ [ . and sometimes ^ * $. * 2. A . matches any character. * 3. A \ followed by any character except a digit or ( ) * matches that character. * 4. A nonempty string s bracketed [s] (or [^s]) matches any * character in (or not in) s. In s, \ has no special meaning, * and ] may only appear as the first letter. A substring * a-b, with a and b in ascending ASCII order, stands for * the inclusive range of ASCII characters. * 5. A regular expression of form 1-4 followed by * matches a * sequence of 0 or more matches of the regular expression. * 6. A regular expression, x, of form 1-8, bracketed \(x\) * matches what x matches. * 7. A \ followed by a digit n matches a copy of the string that the * bracketed regular expression beginning with the nth \( matched. * 8. A regular expression of form 1-8, x, followed by a regular * expression of form 1-7, y matches a match for x followed by * a match for y, with the x match being as long as possible * while still permitting a y match. * 9. A regular expression of form 1-8 preceded by ^ (or followed * by $), is constrained to matches that begin at the left * (or end at the right) end of a line. * 10. A regular expression of form 1-9 picks out the longest among * the leftmost matches in a line. * 11. An empty regular expression stands for a copy of the last * regular expression encountered. */ /* * constants for re's */ #define CBRA 1 #define CCHR 2 #define CDOT 4 #define CCL 6 #define NCCL 8 #define CDOL 10 #define CEOF 11 #define CKET 12 #define CBACK 18 #define CSTAR 01 #define ESIZE 512 #define NBRA 9 static char expbuf[ESIZE], *braslist[NBRA], *braelist[NBRA]; static char circf; /* * compile the regular expression argument into a dfa */ char * re_comp(sp) register char *sp; { register int c; register char *ep = expbuf; int cclcnt, numbra = 0; char *lastep = 0; char bracket[NBRA]; char *bracketp = &bracket[0]; static char *retoolong = "Regular expression too long"; #define comerr(msg) {expbuf[0] = 0; numbra = 0; return(msg); } if (sp == 0 || *sp == '\0') { if (*ep == 0) return("No previous regular expression"); return(0); } if (*sp == '^') { circf = 1; sp++; } else circf = 0; for (;;) { if (ep >= &expbuf[ESIZE]) comerr(retoolong); if ((c = *sp++) == '\0') { if (bracketp != bracket) comerr("unmatched \\("); *ep++ = CEOF; *ep++ = 0; return(0); } if (c != '*') lastep = ep; switch (c) { case '.': *ep++ = CDOT; continue; case '*': if (lastep == 0 || *lastep == CBRA || *lastep == CKET) goto defchar; *lastep |= CSTAR; continue; case '$': if (*sp != '\0') goto defchar; *ep++ = CDOL; continue; case '[': *ep++ = CCL; *ep++ = 0; cclcnt = 1; if ((c = *sp++) == '^') { c = *sp++; ep[-2] = NCCL; } do { if (c == '\0') comerr("missing ]"); if (c == '-' && ep [-1] != 0) { if ((c = *sp++) == ']') { *ep++ = '-'; cclcnt++; break; } while (ep[-1] < c) { *ep = ep[-1] + 1; ep++; cclcnt++; if (ep >= &expbuf[ESIZE]) comerr(retoolong); } } *ep++ = c; cclcnt++; if (ep >= &expbuf[ESIZE]) comerr(retoolong); } while ((c = *sp++) != ']'); lastep[1] = cclcnt; continue; case '\\': if ((c = *sp++) == '(') { if (numbra >= NBRA) comerr("too many \\(\\) pairs"); *bracketp++ = numbra; *ep++ = CBRA; *ep++ = numbra++; continue; } if (c == ')') { if (bracketp <= bracket) comerr("unmatched \\)"); *ep++ = CKET; *ep++ = *--bracketp; continue; } if (c >= '1' && c < ('1' + NBRA)) { *ep++ = CBACK; *ep++ = c - '1'; continue; } *ep++ = CCHR; *ep++ = c; continue; defchar: default: *ep++ = CCHR; *ep++ = c; } } } static int cclass(set, c, af) register char *set, c; int af; { register int n; if (c == 0) return(0); n = *set++; while (--n) if (*set++ == c) return(af); return(! af); } static int backref(i, lp) register int i; register char *lp; { register char *bp; bp = braslist[i]; while (*bp++ == *lp++) if (bp >= braelist[i]) return(1); return(0); } /* * try to match the next thing in the dfa */ static int advance(lp, ep) register char *lp, *ep; { register char *curlp; int ct, i; int rv; for (;;) switch (*ep++) { case CCHR: if (*ep++ == *lp++) continue; return(0); case CDOT: if (*lp++) continue; return(0); case CDOL: if (*lp == '\0') continue; return(0); case CEOF: return(1); case CCL: if (cclass(ep, *lp++, 1)) { ep += *ep; continue; } return(0); case NCCL: if (cclass(ep, *lp++, 0)) { ep += *ep; continue; } return(0); case CBRA: braslist[(unsigned char)*ep++] = lp; continue; case CKET: braelist[(unsigned char)*ep++] = lp; continue; case CBACK: if (braelist[i = *ep++] == 0) return(-1); if (backref(i, lp)) { lp += braelist[i] - braslist[i]; continue; } return(0); case CBACK|CSTAR: if (braelist[i = *ep++] == 0) return(-1); curlp = lp; ct = braelist[i] - braslist[i]; while (backref(i, lp)) lp += ct; while (lp >= curlp) { rv = advance(lp, ep); if (rv) return(rv); lp -= ct; } continue; case CDOT|CSTAR: curlp = lp; while (*lp++) ; goto star; case CCHR|CSTAR: curlp = lp; while (*lp++ == *ep) ; ep++; goto star; case CCL|CSTAR: case NCCL|CSTAR: curlp = lp; while (cclass(ep, *lp++, ep[-1] == (CCL|CSTAR))) ; ep += *ep; goto star; star: do { lp--; rv = advance(lp, ep); if (rv) return(rv); } while (lp > curlp); return(0); default: return(-1); } } /* * match the argument string against the compiled re */ int re_exec(p1) register char *p1; { register char *p2 = expbuf; register int c; int rv; for (c = 0; c < NBRA; c++) { braslist[c] = 0; braelist[c] = 0; } if (circf) return((advance(p1, p2))); /* * fast check for first character */ if (*p2 == CCHR) { c = p2[1]; do { if (*p1 != c) continue; rv = advance(p1, p2); if (rv) return(rv); } while (*p1++); return(0); } /* * regular algorithm */ do { rv = advance(p1, p2); if (rv) return(rv); } while (*p1++); return(0); } ================================================ FILE: lib/libc/gen/remque.c ================================================ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ /* * remque -- vax remque instruction * * NOTE: this implementation is non-atomic!! */ struct vaxque { /* queue format expected by VAX queue instructions */ struct vaxque *vq_next; struct vaxque *vq_prev; }; remque(e) register struct vaxque *e; { e->vq_prev->vq_next = e->vq_next; e->vq_next->vq_prev = e->vq_prev; } ================================================ FILE: lib/libc/gen/rindex.c ================================================ /* * Return the ptr in sp at which the character c last * appears; NULL if not found */ #define NULL 0 char * rindex(sp, c) register const char *sp; register int c; { register char *r; r = NULL; do { if (*sp == (char)c) r = (char *)sp; } while (*sp++); return(r); } ================================================ FILE: lib/libc/gen/scandir.c ================================================ /* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ /* * Scan the directory dirname calling select to make a list of selected * directory entries then sort using qsort and compare routine dcomp. * Returns the number of entries and a pointer to a list of pointers to * struct direct (through namelist). Returns -1 if there were any errors. */ #include #include #include #include #include #include int scandir(dirname, namelist, select, dcomp) char *dirname; struct direct *(*namelist[]); int (*select)(), (*dcomp)(); { register struct direct *d, *p, **names; register int nitems; register char *cp1, *cp2; struct stat stb; int arraysz; DIR *dirp; if ((dirp = opendir(dirname)) == NULL) return(-1); if (fstat(dirp->dd_fd, &stb) < 0) return(-1); /* * estimate the array size by taking the size of the directory file * and dividing it by a multiple of the minimum size entry. */ arraysz = (stb.st_size / 24); names = (struct direct **)malloc(arraysz * sizeof(struct direct *)); if (names == NULL) return(-1); nitems = 0; while ((d = readdir(dirp)) != NULL) { if (select != NULL && !(*select)(d)) continue; /* just selected names */ /* * Make a minimum size copy of the data */ p = (struct direct *)malloc(DIRSIZ(d)); if (p == NULL) return(-1); p->d_ino = d->d_ino; p->d_reclen = d->d_reclen; p->d_namlen = d->d_namlen; for (cp1 = p->d_name, cp2 = d->d_name; (*cp1++ = *cp2++); ); /* * Check to make sure the array has space left and * realloc the maximum size. */ if (++nitems >= arraysz) { if (fstat(dirp->dd_fd, &stb) < 0) return(-1); /* just might have grown */ arraysz = stb.st_size / 12; names = (struct direct **)realloc((char *)names, arraysz * sizeof(struct direct *)); if (names == NULL) return(-1); } names[nitems-1] = p; } closedir(dirp); if (nitems && dcomp != NULL) qsort(names, nitems, sizeof(struct direct *), dcomp); *namelist = names; return(nitems); } /* * Alphabetic order comparison routine for those who want it. */ int alphasort(d1, d2) struct direct **d1, **d2; { return(strcmp((*d1)->d_name, (*d2)->d_name)); } ================================================ FILE: lib/libc/gen/seekdir.c ================================================ /* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include #include /* * seek to an entry in a directory. * Only values returned by "telldir" should be passed to seekdir. */ void seekdir(dirp, loc) register DIR *dirp; long loc; { long curloc, base, offset; struct direct *dp; extern long lseek(); curloc = telldir(dirp); if (loc == curloc) return; base = loc & ~(DIRBLKSIZ - 1); offset = loc & (DIRBLKSIZ - 1); (void) lseek(dirp->dd_fd, base, 0); dirp->dd_loc = 0; while (dirp->dd_loc < offset) { dp = readdir(dirp); if (dp == NULL) return; } } ================================================ FILE: lib/libc/gen/setenv.c ================================================ /* * Copyright (c) 1987 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include #include #include #include #include #include /* * setenv(name,value,rewrite) * Set the value of the environmental variable "name" to be * "value". If rewrite is set, replace any current value. */ int setenv(name, value, rewrite) register const char *name, *value; int rewrite; { static int alloced; /* if allocated space before */ register char *C; register const char *E; int l_value, offset; if (*value == '=') /* no `=' in value */ ++value; l_value = strlen(value); if ((C = _findenv(name,&offset))) { /* find if already exists */ if (!rewrite) return(0); if (strlen(C) >= l_value) { /* old larger; copy over */ while ((*C++ = *value++)); return(0); } } else { /* create new slot */ register int cnt; register char **P; for (P = environ,cnt = 0;*P;++P,++cnt); if (alloced) { /* just increase size */ environ = (char **)realloc((char *)environ, (u_int)(sizeof(char *) * (cnt + 2))); if (!environ) return(-1); } else { /* get new space */ alloced = 1; /* copy old entries into it */ P = (char **)malloc((u_int)(sizeof(char *) * (cnt + 2))); if (!P) return(-1); bcopy(environ,P,cnt * sizeof(char *)); environ = P; } environ[cnt + 1] = NULL; offset = cnt; } for (E = name; *E && *E != '='; ++E); /* no `=' in name */ if (!(environ[offset] = /* name + `=' + value */ malloc((u_int)((int)(E - name) + l_value + 2)))) return(-1); for (C = environ[offset]; (*C = *name++) && *C != '='; ++C); for (*C++ = '='; (*C++ = *value++); ); return(0); } /* * unsetenv(name) -- * Delete environmental variable "name". */ int unsetenv(name) const char *name; { register char **P; int offset; while (_findenv(name,&offset)) /* if set multiple times */ for (P = &environ[offset];;++P) if (!(*P = *(P + 1))) break; return 0; } ================================================ FILE: lib/libc/gen/sethostname.c ================================================ /* * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #include int sethostname(name, namelen) char *name; int namelen; { int mib[2]; mib[0] = CTL_KERN; mib[1] = KERN_HOSTNAME; if (sysctl(mib, 2, NULL, NULL, (void *)name, namelen) == -1) return (-1); return (0); } ================================================ FILE: lib/libc/gen/setmode.c ================================================ /* * Copyright (c) 1989, 1993, 1994 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Dave Borman at Cray Research, Inc. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #include #include #include #include #include #ifdef SETMODE_DEBUG #include #endif #define SET_LEN 6 /* initial # of bitcmd struct to malloc */ #define SET_LEN_INCR 4 /* # of bitcmd structs to add as needed */ typedef struct bitcmd { char cmd; char cmd2; mode_t bits; } BITCMD; #define CMD2_CLR 0x01 #define CMD2_SET 0x02 #define CMD2_GBITS 0x04 #define CMD2_OBITS 0x08 #define CMD2_UBITS 0x10 static BITCMD *addcmd(); static int compress_mode(); #ifdef SETMODE_DEBUG static void dumpmode(); #endif /* * Given the old mode and an array of bitcmd structures, apply the operations * described in the bitcmd structures to the old mode, and return the new mode. * Note that there is no '=' command; a strict assignment is just a '-' (clear * bits) followed by a '+' (set bits). */ mode_t getmode(bbox, omode) void *bbox; mode_t omode; { register BITCMD *set; register mode_t clrval, newmode, value; set = (BITCMD *)bbox; newmode = omode; for (value = 0;; set++) switch(set->cmd) { /* * When copying the user, group or other bits around, we "know" * where the bits are in the mode so that we can do shifts to * copy them around. If we don't use shifts, it gets real * grundgy with lots of single bit checks and bit sets. */ case 'u': value = (newmode & S_IRWXU) >> 6; goto common; case 'g': value = (newmode & S_IRWXG) >> 3; goto common; case 'o': value = newmode & S_IRWXO; common: if (set->cmd2 & CMD2_CLR) { clrval = (set->cmd2 & CMD2_SET) ? S_IRWXO : value; if (set->cmd2 & CMD2_UBITS) newmode &= ~((clrval<<6) & set->bits); if (set->cmd2 & CMD2_GBITS) newmode &= ~((clrval<<3) & set->bits); if (set->cmd2 & CMD2_OBITS) newmode &= ~(clrval & set->bits); } if (set->cmd2 & CMD2_SET) { if (set->cmd2 & CMD2_UBITS) newmode |= (value<<6) & set->bits; if (set->cmd2 & CMD2_GBITS) newmode |= (value<<3) & set->bits; if (set->cmd2 & CMD2_OBITS) newmode |= value & set->bits; } break; case '+': newmode |= set->bits; break; case '-': newmode &= ~set->bits; break; case 'X': if (omode & (S_IFDIR|S_IXUSR|S_IXGRP|S_IXOTH)) newmode |= set->bits; break; case '\0': default: #ifdef SETMODE_DEBUG (void)printf("getmode:%04o -> %04o\n", omode, newmode); #endif return (newmode); } } #define ADDCMD(a, b, c, d) \ if (set >= endset) { \ register BITCMD *newset; \ setlen += SET_LEN_INCR; \ newset = (BITCMD *)realloc(saveset, sizeof(BITCMD) * setlen); \ if (!saveset) \ return ((void *)NULL); \ set = newset + (set - saveset); \ saveset = newset; \ endset = newset + (setlen - 2); \ } \ set = addcmd(set, (a), (b), (c), (d)) #define STANDARD_BITS (S_ISUID|S_ISGID|S_IRWXU|S_IRWXG|S_IRWXO) void * setmode(p) register char *p; { register int perm, who; char op; BITCMD *set, *saveset, *endset; #ifdef notnow sigset_t sigset, sigoset; #endif mode_t mask; int equalopdone = 0, permXbits, setlen; if (!*p) return ((void *)NULL); #ifdef notnow /* * Get a copy of the mask for the permissions that are mask relative. * Flip the bits, we want what's not set. Since it's possible that * the caller is opening files inside a signal handler, protect them * as best we can. */ (void)sigfillset(&sigset); (void)sigprocmask(SIG_BLOCK, &sigset, &sigoset); #endif (void)umask(mask = umask(0)); mask = ~mask; #ifdef notnow (void)sigprocmask(SIG_SETMASK, &sigoset, NULL); #endif setlen = SET_LEN + 2; if ((set = (BITCMD *)malloc((u_int)(sizeof(BITCMD) * setlen))) == NULL) return ((void *)NULL); saveset = set; endset = set + (setlen - 2); /* * If an absolute number, get it and return; disallow non-octal digits * or illegal bits. */ if (isdigit(*p)) { perm = (mode_t)strtol(p, NULL, 8); if (perm & ~(STANDARD_BITS|S_ISVTX)) { free(saveset); return ((void *)NULL); } while (*++p) if (*p < '0' || *p > '7') { free(saveset); return ((void *)NULL); } ADDCMD('=', (STANDARD_BITS|S_ISVTX), perm, mask); return ((void *)saveset); } /* * Build list of structures to set/clear/copy bits as described by * each clause of the symbolic mode. */ for (;;) { /* First, find out which bits might be modified. */ for (who = 0;; ++p) { switch (*p) { case 'a': who |= STANDARD_BITS; break; case 'u': who |= S_ISUID|S_IRWXU; break; case 'g': who |= S_ISGID|S_IRWXG; break; case 'o': who |= S_IRWXO; break; default: goto getop; } } getop: if ((op = *p++) != '+' && op != '-' && op != '=') { free(saveset); return ((void *)NULL); } if (op == '=') equalopdone = 0; who &= ~S_ISVTX; for (perm = 0, permXbits = 0;; ++p) { switch (*p) { case 'r': perm |= S_IRUSR|S_IRGRP|S_IROTH; break; case 's': /* If only "other" bits ignore set-id. */ if (who & ~S_IRWXO) perm |= S_ISUID|S_ISGID; break; case 't': /* If only "other" bits ignore sticky. */ if (who & ~S_IRWXO) { who |= S_ISVTX; perm |= S_ISVTX; } break; case 'w': perm |= S_IWUSR|S_IWGRP|S_IWOTH; break; case 'X': permXbits = S_IXUSR|S_IXGRP|S_IXOTH; break; case 'x': perm |= S_IXUSR|S_IXGRP|S_IXOTH; break; case 'u': case 'g': case 'o': /* * When ever we hit 'u', 'g', or 'o', we have * to flush out any partial mode that we have, * and then do the copying of the mode bits. */ if (perm) { ADDCMD(op, who, perm, mask); perm = 0; } if (op == '=') equalopdone = 1; if (op == '+' && permXbits) { ADDCMD('X', who, permXbits, mask); permXbits = 0; } ADDCMD(*p, who, op, mask); break; default: /* * Add any permissions that we haven't already * done. */ if (perm || (op == '=' && !equalopdone)) { if (op == '=') equalopdone = 1; ADDCMD(op, who, perm, mask); perm = 0; } if (permXbits) { ADDCMD('X', who, permXbits, mask); permXbits = 0; } goto apply; } } apply: if (!*p) break; if (*p != ',') goto getop; ++p; } set->cmd = 0; #ifdef SETMODE_DEBUG (void)printf("Before compress_mode()\n"); dumpmode(saveset); #endif compress_mode(saveset); #ifdef SETMODE_DEBUG (void)printf("After compress_mode()\n"); dumpmode(saveset); #endif return ((void *)saveset); } static BITCMD * addcmd(set, op, who, oparg, mask) BITCMD *set; register int oparg, who; register int op; u_int mask; { switch (op) { case '=': set->cmd = '-'; set->bits = who ? who : STANDARD_BITS; set++; op = '+'; /* FALLTHROUGH */ case '+': case '-': case 'X': set->cmd = op; set->bits = (who ? who : mask) & oparg; break; case 'u': case 'g': case 'o': set->cmd = op; if (who) { set->cmd2 = ((who & S_IRUSR) ? CMD2_UBITS : 0) | ((who & S_IRGRP) ? CMD2_GBITS : 0) | ((who & S_IROTH) ? CMD2_OBITS : 0); set->bits = ~0; } else { set->cmd2 = CMD2_UBITS | CMD2_GBITS | CMD2_OBITS; set->bits = mask; } if (oparg == '+') set->cmd2 |= CMD2_SET; else if (oparg == '-') set->cmd2 |= CMD2_CLR; else if (oparg == '=') set->cmd2 |= CMD2_SET|CMD2_CLR; break; } return (set + 1); } #ifdef SETMODE_DEBUG static void dumpmode(set) register BITCMD *set; { for (; set->cmd; ++set) (void)printf("cmd: '%c' bits %04o%s%s%s%s%s%s\n", set->cmd, set->bits, set->cmd2 ? " cmd2:" : "", set->cmd2 & CMD2_CLR ? " CLR" : "", set->cmd2 & CMD2_SET ? " SET" : "", set->cmd2 & CMD2_UBITS ? " UBITS" : "", set->cmd2 & CMD2_GBITS ? " GBITS" : "", set->cmd2 & CMD2_OBITS ? " OBITS" : ""); } #endif /* * Given an array of bitcmd structures, compress by compacting consecutive * '+', '-' and 'X' commands into at most 3 commands, one of each. The 'u', * 'g' and 'o' commands continue to be separate. They could probably be * compacted, but it's not worth the effort. */ static int compress_mode(set) register BITCMD *set; { register BITCMD *nset; register int setbits, clrbits, Xbits, op; for (nset = set;;) { /* Copy over any 'u', 'g' and 'o' commands. */ while ((op = nset->cmd) != '+' && op != '-' && op != 'X') { *set++ = *nset++; if (!op) return 0; } for (setbits = clrbits = Xbits = 0;; nset++) { if ((op = nset->cmd) == '-') { clrbits |= nset->bits; setbits &= ~nset->bits; Xbits &= ~nset->bits; } else if (op == '+') { setbits |= nset->bits; clrbits &= ~nset->bits; Xbits &= ~nset->bits; } else if (op == 'X') Xbits |= nset->bits & ~setbits; else break; } if (clrbits) { set->cmd = '-'; set->cmd2 = 0; set->bits = clrbits; set++; } if (setbits) { set->cmd = '+'; set->cmd2 = 0; set->bits = setbits; set++; } if (Xbits) { set->cmd = 'X'; set->cmd2 = 0; set->bits = Xbits; set++; } } } ================================================ FILE: lib/libc/gen/siginterrupt.c ================================================ /* * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include /* * Set signal state to prevent restart of system calls * after an instance of the indicated signal. */ int siginterrupt(sig, flag) int sig, flag; { extern sigset_t _sigintr; struct sigaction sa; int ret; if ((ret = sigaction(sig, (struct sigaction *)0, &sa)) < 0) return (ret); if (flag) { (void)sigaddset(&_sigintr, sig); sa.sa_flags &= ~SA_RESTART; } else { (void)sigdelset(&_sigintr, sig); sa.sa_flags |= SA_RESTART; } return (sigaction(sig, &sa, (struct sigaction *)0)); } ================================================ FILE: lib/libc/gen/siglist.c ================================================ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include char *sys_siglist[NSIG] = { "Signal 0", "Hangup", /* SIGHUP */ "Interrupt", /* SIGINT */ "Quit", /* SIGQUIT */ "Illegal instruction", /* SIGILL */ "Trace/BPT trap", /* SIGTRAP */ "IOT trap", /* SIGIOT */ "EMT trap", /* SIGEMT */ "Floating point exception", /* SIGFPE */ "Killed", /* SIGKILL */ "Bus error", /* SIGBUS */ "Segmentation fault", /* SIGSEGV */ "Bad system call", /* SIGSYS */ "Broken pipe", /* SIGPIPE */ "Alarm clock", /* SIGALRM */ "Terminated", /* SIGTERM */ "Urgent I/O condition", /* SIGURG */ "Stopped (signal)", /* SIGSTOP */ "Stopped", /* SIGTSTP */ "Continued", /* SIGCONT */ "Child exited", /* SIGCHLD */ "Stopped (tty input)", /* SIGTTIN */ "Stopped (tty output)", /* SIGTTOU */ "I/O possible", /* SIGIO */ "Cputime limit exceeded", /* SIGXCPU */ "Filesize limit exceeded", /* SIGXFSZ */ "Virtual timer expired", /* SIGVTALRM */ "Profiling timer expired", /* SIGPROF */ "Window size changes", /* SIGWINCH */ "Signal 29", "User defined signal 1", /* SIGUSR1 */ "User defined signal 2" /* SIGUSR2 */ }; ================================================ FILE: lib/libc/gen/signal.c ================================================ /* * Copyright (c) 1985, 1989, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ /* * Almost backwards compatible signal. */ #include sigset_t _sigintr; /* shared with siginterrupt */ sig_t signal(s, a) int s; sig_t a; { struct sigaction sa, osa; sa.sa_handler = a; (void)sigemptyset(&sa.sa_mask); sa.sa_flags = 0; if (!sigismember(&_sigintr, s)) sa.sa_flags |= SA_RESTART; if (sigaction(s, &sa, &osa) < 0) return (SIG_ERR); return (osa.sa_handler); } ================================================ FILE: lib/libc/gen/sigsetops.c ================================================ /*- * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #undef sigemptyset #undef sigfillset #undef sigaddset #undef sigdelset #undef sigismember int sigemptyset(set) sigset_t *set; { *set = 0; return (0); } int sigfillset(set) sigset_t *set; { *set = ~(sigset_t)0; return (0); } int sigaddset(set, signo) sigset_t *set; int signo; { *set |= sigmask(signo); return (0); } int sigdelset(set, signo) sigset_t *set; int signo; { *set &= ~sigmask(signo); return (0); } int sigismember(set, signo) sigset_t *set; int signo; { return ((*set & ~sigmask(signo)) != 0); } ================================================ FILE: lib/libc/gen/sleep.c ================================================ /* * Program: sleep.c * Copyright: 1997, sms * Author: Steven M. Schultz * * Version Date Modification * 1.0 1997/9/25 1. Initial release. */ #include /* For NULL */ #include #include #include /* * This implements the sleep(3) function using only 3 system calls instead of * the 9 that the old implementation required. Also this version avoids using * signals (with the attendant system overhead) and returns the amount of * time left unslept if an interrupt occurs. * * The error status of gettimeofday is not checked because if that fails the * program has scrambled the stack so badly that a sleep() failure is the least * problem the program has. The select() call either completes successfully * or is interrupted - no errors to be checked for. */ u_int sleep(seconds) u_int seconds; { struct timeval f, s; if (seconds) { gettimeofday(&f, NULL); s.tv_sec = seconds; s.tv_usec = 0; select(0, NULL, NULL, NULL, &s); gettimeofday(&s, NULL); seconds -= (s.tv_sec - f.tv_sec); /* * ONLY way this can happen is if the system time gets set back while we're * in the select() call. In this case return 0 instead of a bogus number. */ if (seconds < 0) seconds = 0; } return(seconds); } ================================================ FILE: lib/libc/gen/strcasecmp.c ================================================ /* * Copyright (c) 1987 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include /* * This array is designed for mapping upper and lower case letter * together for a case independent comparison. The mappings are * based upon ascii character sequences. */ static char charmap[] = { '\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007', '\010', '\011', '\012', '\013', '\014', '\015', '\016', '\017', '\020', '\021', '\022', '\023', '\024', '\025', '\026', '\027', '\030', '\031', '\032', '\033', '\034', '\035', '\036', '\037', '\040', '\041', '\042', '\043', '\044', '\045', '\046', '\047', '\050', '\051', '\052', '\053', '\054', '\055', '\056', '\057', '\060', '\061', '\062', '\063', '\064', '\065', '\066', '\067', '\070', '\071', '\072', '\073', '\074', '\075', '\076', '\077', '\100', '\141', '\142', '\143', '\144', '\145', '\146', '\147', '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157', '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167', '\170', '\171', '\172', '\133', '\134', '\135', '\136', '\137', '\140', '\141', '\142', '\143', '\144', '\145', '\146', '\147', '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157', '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167', '\170', '\171', '\172', '\173', '\174', '\175', '\176', '\177', '\200', '\201', '\202', '\203', '\204', '\205', '\206', '\207', '\210', '\211', '\212', '\213', '\214', '\215', '\216', '\217', '\220', '\221', '\222', '\223', '\224', '\225', '\226', '\227', '\230', '\231', '\232', '\233', '\234', '\235', '\236', '\237', '\240', '\241', '\242', '\243', '\244', '\245', '\246', '\247', '\250', '\251', '\252', '\253', '\254', '\255', '\256', '\257', '\260', '\261', '\262', '\263', '\264', '\265', '\266', '\267', '\270', '\271', '\272', '\273', '\274', '\275', '\276', '\277', '\300', '\341', '\342', '\343', '\344', '\345', '\346', '\347', '\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357', '\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367', '\370', '\371', '\372', '\333', '\334', '\335', '\336', '\337', '\340', '\341', '\342', '\343', '\344', '\345', '\346', '\347', '\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357', '\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367', '\370', '\371', '\372', '\373', '\374', '\375', '\376', '\377', }; int strcasecmp(s1, s2) register const char *s1, *s2; { register char *cm = charmap; while (cm[(unsigned char)*s1] == cm[(unsigned char)*s2++]) if (*s1++ == '\0') return(0); return(cm[(unsigned char)*s1] - cm[(unsigned char)*--s2]); } int strncasecmp(s1, s2, n) register const char *s1, *s2; register size_t n; { register char *cm = charmap; while (n-- > 0 && cm[(unsigned char)*s1] == cm[(unsigned char)*s2++]) if (*s1++ == '\0') return(0); return(n == -1 ? 0 : cm[(unsigned char)*s1] - cm[(unsigned char)*--s2]); } ================================================ FILE: lib/libc/gen/strcat.c ================================================ /* * Concatenate s2 on the end of s1. S1's space must be large enough. * Return s1. */ #include char * strcat(s1, s2) register char *s1; register const char *s2; { register char *os1; os1 = s1; while (*s1++) ; --s1; while ((*s1++ = *s2++)) ; return(os1); } ================================================ FILE: lib/libc/gen/strcmp.c ================================================ /* * Compare strings: s1>s2: >0 s1==s2: 0 s1 int strcmp(s1, s2) register const char *s1, *s2; { while (*s1 == *s2++) if (*s1++=='\0') return(0); return(*s1 - *--s2); } ================================================ FILE: lib/libc/gen/strcpy.c ================================================ /* * Copy string s2 to s1. s1 must be large enough. * return s1 */ #include char * strcpy(s1, s2) register char *s1; register const char *s2; { register char *os1; os1 = s1; while ((*s1++ = *s2++)) ; return(os1); } ================================================ FILE: lib/libc/gen/strdup.c ================================================ /* * Copyright (c) 1988 The Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the University of California, Berkeley. The name of the * University may not be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #include #include #include #include #include char * strdup(str) const char *str; { int len; char *copy; len = strlen(str) + 1; if (!(copy = malloc((u_int)len))) return((char *)NULL); bcopy(str, copy, len); return(copy); } ================================================ FILE: lib/libc/gen/strftime.c ================================================ /* * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #include #include #include #include static char *Afmt[] = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", }; static char *Bfmt[] = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December", }; static size_t gsize; static char *pt; static int _add(char *str) { for (;; ++pt, --gsize) { if (!gsize) return(0); if (!(*pt = *str++)) return(1); } } static int _conv(int n, int digits, char pad) { static char buf[10]; register char *p; for (p = buf + sizeof(buf) - 2; n > 0 && p > buf; n /= 10, --digits) *p-- = n % 10 + '0'; while (p > buf && digits-- > 0) *p-- = pad; return(_add(++p)); } static size_t _fmt(const char *format, const struct tm *t) { char ch, *cp, junk[4]; for (; *format; ++format) { if (*format == '%') switch(ch = *++format) { case '\0': --format; break; case 'A': case 'a': if (t->tm_wday < 0 || t->tm_wday > 6) return(0); if (ch == 'a') { bcopy(Afmt[t->tm_wday], junk, 3); junk[3] = '\0'; cp = junk; } else cp = Afmt[t->tm_wday]; if (!_add(cp)) return(0); continue; case 'B': case 'b': case 'h': if (t->tm_mon < 0 || t->tm_mon > 11) return(0); if (ch == 'b') { bcopy(Bfmt[t->tm_mon], junk, 3); junk[3] = '\0'; cp = junk; } else cp = Bfmt[t->tm_mon]; if (!_add(cp)) return(0); continue; case 'C': if (!_fmt("%a %b %e %H:%M:%S %Y", t)) return(0); continue; case 'c': if (!_fmt("%m/%d/%y %H:%M:%S", t)) return(0); continue; case 'D': if (!_fmt("%m/%d/%y", t)) return(0); continue; case 'd': if (!_conv(t->tm_mday, 2, '0')) return(0); continue; case 'e': if (!_conv(t->tm_mday, 2, ' ')) return(0); continue; case 'H': if (!_conv(t->tm_hour, 2, '0')) return(0); continue; case 'I': if (!_conv(t->tm_hour % 12 ? t->tm_hour % 12 : 12, 2, '0')) return(0); continue; case 'j': if (!_conv(t->tm_yday + 1, 3, '0')) return(0); continue; case 'k': if (!_conv(t->tm_hour, 2, ' ')) return(0); continue; case 'l': if (!_conv(t->tm_hour % 12 ? t->tm_hour % 12 : 12, 2, ' ')) return(0); continue; case 'M': if (!_conv(t->tm_min, 2, '0')) return(0); continue; case 'm': if (!_conv(t->tm_mon + 1, 2, '0')) return(0); continue; case 'n': if (!_add("\n")) return(0); continue; case 'p': if (!_add(t->tm_hour >= 12 ? "PM" : "AM")) return(0); continue; case 'R': if (!_fmt("%H:%M", t)) return(0); continue; case 'r': if (!_fmt("%I:%M:%S %p", t)) return(0); continue; case 'S': if (!_conv(t->tm_sec, 2, '0')) return(0); continue; case 'T': case 'X': if (!_fmt("%H:%M:%S", t)) return(0); continue; case 't': if (!_add("\t")) return(0); continue; case 'U': if (!_conv((t->tm_yday + 7 - t->tm_wday) / 7, 2, '0')) return(0); continue; case 'W': if (!_conv((t->tm_yday + 7 - (t->tm_wday ? (t->tm_wday - 1) : 6)) / 7, 2, '0')) return(0); continue; case 'w': if (!_conv(t->tm_wday, 1, '0')) return(0); continue; case 'x': if (!_fmt("%m/%d/%y", t)) return(0); continue; case 'y': if (!_conv((t->tm_year + TM_YEAR_BASE) % 100, 2, '0')) return(0); continue; case 'Y': if (!_conv(t->tm_year + TM_YEAR_BASE, 4, '0')) return(0); continue; case 'Z': if (!t->tm_zone || !_add(t->tm_zone)) return(0); continue; case '%': /* * X311J/88-090 (4.12.3.5): if conversion char is * undefined, behavior is undefined. Print out the * character itself as printf(3) does. */ default: break; } if (!gsize--) return(0); *pt++ = *format; } return(gsize); } size_t strftime(char *s, size_t maxsize, const char *format, const struct tm *t) { pt = s; if ((gsize = maxsize) < 1) return(0); if (_fmt(format, t)) { *pt = '\0'; return(maxsize - gsize); } return(0); } ================================================ FILE: lib/libc/gen/strlen.c ================================================ /* * Returns the number of * non-NULL bytes in string argument. */ #include size_t strlen(s) register const char *s; { register int n; n = 0; while (*s++) n++; return(n); } ================================================ FILE: lib/libc/gen/strncat.c ================================================ /* * Concatenate s2 on the end of s1. S1's space must be large enough. * At most n characters are moved. * Return s1. */ #include char * strncat(s1, s2, n) register char *s1; register const char *s2; register size_t n; { register char *os1; os1 = s1; while (*s1++) ; --s1; while ((*s1++ = *s2++)) if (n-- == 0) { *--s1 = '\0'; break; } return(os1); } ================================================ FILE: lib/libc/gen/strncmp.c ================================================ /* * Compare strings (at most n bytes): s1>s2: >0 s1==s2: 0 s1 int strncmp (s1, s2, n) register const char *s1, *s2; register size_t n; { for (;;) { if (n-- == 0) return 0; if (*s1 != *s2++) return *s1 - *--s2; if (*s1++ == '\0') return 0; } } ================================================ FILE: lib/libc/gen/strncpy.c ================================================ /* * Copy s2 to s1, truncating or null-padding to always copy n bytes * return s1 */ #include char * strncpy(s1, s2, n) register char *s1; register const char *s2; size_t n; { size_t i; register char *os1; os1 = s1; for (i = 0; i < n; i++) if ((*s1++ = *s2++) == '\0') { while (++i < n) *s1++ = '\0'; return(os1); } return(os1); } ================================================ FILE: lib/libc/gen/swab.c ================================================ /* * Swab bytes * Jeffrey Mogul, Stanford */ void swab (from, to, n) register char *from, *to; register int n; { #ifdef pdp11 register int temp; #else register unsigned long temp; #endif n >>= 1; n++; #define STEP temp = *from++,*to++ = *from++,*to++ = temp /* round to multiple of 8 */ while ((--n) & 07) STEP; n >>= 3; while (--n >= 0) { STEP; STEP; STEP; STEP; STEP; STEP; STEP; STEP; } } ================================================ FILE: lib/libc/gen/sysctl.c ================================================ /*- * Copyright (c) 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #include #include #include #include int sysctl(name, namelen, oldp, oldlenp, newp, newlen) int *name; u_int namelen; void *oldp, *newp; size_t *oldlenp, newlen; { if (name[0] != CTL_USER) return (__sysctl(name, namelen, oldp, oldlenp, newp, newlen)); if (newp != NULL) { errno = EPERM; return (-1); } if (namelen != 2) { errno = EINVAL; return (-1); } /* * This idea behind this section is silly. Other than 'bc' who cares about * half of these? A 3/4 hearted attempt is made however to return numbers * that are not totally bogus. * * Rather than port over the raft of include files with the attendant plethora * of #define statements we just plug in the numbers from 4.4-Lite. */ switch (name[1]) { case USER_CS_PATH: if (oldp && *oldlenp < sizeof(_PATH_SYSPATH)) return (ENOMEM); *oldlenp = sizeof(_PATH_SYSPATH); if (oldp != NULL) strcpy(oldp, _PATH_SYSPATH); return (0); } if (oldp && *oldlenp < sizeof(int)) return (ENOMEM); *oldlenp = sizeof(int); if (oldp == NULL) return (0); switch (name[1]) { case USER_BC_BASE_MAX: case USER_BC_SCALE_MAX: *(int *)oldp = 99; return (0); case USER_BC_DIM_MAX: *(int *)oldp = 2048; return (0); case USER_BC_STRING_MAX: *(int *)oldp = 1000; return (0); case USER_EXPR_NEST_MAX: *(int *)oldp = 32; return (0); case USER_LINE_MAX: *(int *)oldp = 1024; return (0); case USER_RE_DUP_MAX: *(int *)oldp = 255; return (0); case USER_COLL_WEIGHTS_MAX: case USER_POSIX2_VERSION: case USER_POSIX2_C_BIND: case USER_POSIX2_C_DEV: case USER_POSIX2_CHAR_TERM: case USER_POSIX2_FORT_DEV: case USER_POSIX2_FORT_RUN: case USER_POSIX2_LOCALEDEF: case USER_POSIX2_SW_DEV: case USER_POSIX2_UPE: *(int *)oldp = 0; return (0); case USER_STREAM_MAX: *(int *)oldp = 20; return (0); case USER_TZNAME_MAX: *(int *)oldp = 63; return (0); default: errno = EINVAL; return (-1); } /* NOTREACHED */ } ================================================ FILE: lib/libc/gen/syslog.c ================================================ /* * Copyright (c) 1983, 1988, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #define STDERR_FILENO 2 static int LogFile = -1; /* fd for log */ static int connected; /* have done connect */ static int LogStat = 0; /* status bits, set by openlog() */ static const char *LogTag = NULL; /* string to tag the entry with */ static int LogFacility = LOG_USER; /* default facility code */ static int LogMask = 0xff; /* mask of priorities to be logged */ static char logfile[] = _PATH_MESSAGES; extern int errno; /* error number */ /* * syslog, vsyslog -- * print message on log file; output is intended for syslogd(8). * No sockets: logfile is used. */ void vsyslog(pri, fmt, ap) int pri; register const char *fmt; va_list ap; { int cnt; char ch; register char *p, *t; time_t now; int fd, saved_errno; char *stdp = 0, tbuf[640], fmt_cpy[512]; pid_t pid; #define INTERNALLOG LOG_ERR|LOG_CONS|LOG_PERROR|LOG_PID /* Check for invalid bits. */ if (pri & ~(LOG_PRIMASK|LOG_FACMASK)) { syslog(INTERNALLOG, "syslog: bad fac/pri: %x", pri); pri &= LOG_PRIMASK|LOG_FACMASK; } /* Check priority against setlogmask values. */ if (!(LOG_MASK(LOG_PRI(pri)) & LogMask)) return; saved_errno = errno; /* Set default facility if none specified. */ if ((pri & LOG_FACMASK) == 0) pri |= LogFacility; /* Build the message. */ (void)time(&now); p = tbuf + sprintf(tbuf, "<%d>", pri); p += strftime(p, sizeof (tbuf) - (p - tbuf), "%h %e %T ", localtime(&now)); if (LogStat & LOG_PERROR) stdp = p; if (LogTag == NULL) LogTag = __progname; if (LogTag != NULL) p += sprintf(p, "%s", LogTag); if (LogStat & LOG_PID) p += sprintf(p, "[%d]", getpid()); if (LogTag != NULL) { *p++ = ':'; *p++ = ' '; } /* Substitute error message for %m. */ for (t = fmt_cpy; (ch = *fmt); ++fmt) if (ch == '%' && fmt[1] == 'm') { ++fmt; t += sprintf(t, "%s", strerror(saved_errno)); } else *t++ = ch; *t = '\0'; p += vsprintf(p, fmt_cpy, ap); cnt = p - tbuf; /* Output to stderr if requested. */ if (LogStat & LOG_PERROR) { struct iovec iov[2]; register struct iovec *v = iov; v->iov_base = stdp; v->iov_len = cnt - (stdp - tbuf); ++v; v->iov_base = "\n"; v->iov_len = 1; (void)writev(STDERR_FILENO, iov, 2); } /* Get connected, output the message to the local logger. */ if (!connected) openlog(LogTag, LogStat | LOG_NDELAY, 0); (void)strcat(tbuf, "\r\n"); cnt += 2; if (write(LogFile, tbuf, cnt) == cnt) return; /* * Output the message to the console; don't worry about blocking, * if console blocks everything will. Make sure the error reported * is the one from the syslogd failure. * * 2.11BSD has to do a more complicated dance because we do not * want to acquire a controlling terminal (bad news for 'init'!). * Until either the tty driver is ported from 4.4 or O_NOCTTY * is implemented we have to fork and let the child do the open of * the console. */ if (LogStat & LOG_CONS) { pid = vfork(); if (pid == -1) return; if (pid == 0) { fd = open(_PATH_CONSOLE, O_WRONLY, 0); p = index(tbuf, '>') + 1; (void)write(fd, p, cnt - (p - tbuf)); (void)close(fd); _exit(0); } while (waitpid(pid, NULL, NULL) == -1 && (errno == EINTR)) ; } } void syslog (int pri, const char *fmt, ...) { va_list ap; va_start (ap, fmt); vsyslog (pri, fmt, ap); va_end (ap); } void openlog(ident, logstat, logfac) const char *ident; int logstat; register int logfac; { if (ident != NULL) LogTag = ident; LogStat = logstat; if (logfac != 0 && (logfac &~ LOG_FACMASK) == 0) LogFacility = logfac; if (LogFile == -1) { if (LogStat & LOG_NDELAY) { LogFile = open(logfile, O_WRONLY|O_APPEND); connected = 1; if (LogFile == -1) return; (void)fcntl(LogFile, F_SETFD, 1); } } if (LogFile != -1 && !connected) { (void)close(LogFile); LogFile = -1; } } void closelog() { (void)close(LogFile); LogFile = -1; connected = 0; } /* setlogmask -- set the log mask level */ int setlogmask(pmask) register int pmask; { register int omask; omask = LogMask; if (pmask != 0) LogMask = pmask; return (omask); } ================================================ FILE: lib/libc/gen/system.c ================================================ /* * Copyright (c) 1988 The Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #include #include #include #include int system(command) char *command; { union wait pstat; register int pid; sigset_t omask, nmask; sig_t intsave, quitsave; if (!command) /* just checking... */ return(1); (void)sigemptyset(&nmask); (void)sigaddset(&nmask, SIGCHLD); (void)sigprocmask(SIG_BLOCK, &nmask, &omask); switch(pid = vfork()) { case -1: /* error */ (void)sigprocmask(SIG_SETMASK, &omask, NULL); pstat.w_status = 0; pstat.w_retcode = 127; return(pstat.w_status); case 0: /* child */ (void)sigprocmask(SIG_SETMASK, &omask, NULL); execl("/bin/sh", "sh", "-c", command, (char *)NULL); _exit(127); } intsave = signal(SIGINT, SIG_IGN); quitsave = signal(SIGQUIT, SIG_IGN); pid = waitpid(pid, (int *)&pstat, 0); (void)sigprocmask(SIG_SETMASK, &omask, NULL); (void)signal(SIGINT, intsave); (void)signal(SIGQUIT, quitsave); return(pid == -1 ? -1 : pstat.w_status); } ================================================ FILE: lib/libc/gen/telldir.c ================================================ /* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include #include /* * return a pointer into a directory */ long telldir(dirp) DIR *dirp; { extern long lseek(); return (lseek(dirp->dd_fd, 0L, 1) - dirp->dd_size + dirp->dd_loc); } ================================================ FILE: lib/libc/gen/time.c ================================================ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ /* * Backwards compatible time call. */ #include #include long time(t) time_t *t; { struct timeval tt; if (gettimeofday(&tt, (struct timezone *)0) < 0) return (-1); if (t) *t = tt.tv_sec; return (tt.tv_sec); } ================================================ FILE: lib/libc/gen/timezone.c ================================================ /* * Copyright (c) 1987 Regents of the University of California. * This file may be freely redistributed provided that this * notice remains attached. */ #include #include #include #include #include #include #include /* * timezone -- * The arguments are the number of minutes of time you are westward * from Greenwich and whether DST is in effect. It returns a string * giving the name of the local timezone. Should be replaced, in the * application code, by a call to localtime. */ static char czone[TZ_MAX_CHARS]; /* space for zone name */ char * timezone(zone, dst) int zone, dst; { register char *beg, *end; beg = getenv("TZNAME"); if (beg) { /* set in environment */ end = index(beg, ','); if (end) { /* "PST,PDT" */ if (dst) return(++end); *end = '\0'; (void)strncpy(czone,beg,sizeof(czone) - 1); czone[sizeof(czone) - 1] = '\0'; *end = ','; return(czone); } return(beg); } return(tztab(zone,dst)); /* default: table or created zone */ } static struct zone { int offset; char *stdzone; char *dlzone; } zonetab[] = { { -1*60, "MET", "MET DST" }, /* Middle European */ { -2*60, "EET", "EET DST" }, /* Eastern European */ { 4*60, "AST", "ADT" }, /* Atlantic */ { 5*60, "EST", "EDT" }, /* Eastern */ { 6*60, "CST", "CDT" }, /* Central */ { 7*60, "MST", "MDT" }, /* Mountain */ { 8*60, "PST", "PDT" }, /* Pacific */ { 0, "GMT", 0 }, /* Greenwich */ { -10*60, "EST", "EST" }, /* Aust: Eastern */ { -10*60+30, "CST", "CST" }, /* Aust: Central */ { -8*60, "WST", 0 }, /* Aust: Western */ { -1 }, }; /* * tztab -- * check static tables or create a new zone name; broken out so that * we can make a guess as to what the zone is if the standard tables * aren't in place in /usr/share/misc. DO NOT USE THIS ROUTINE OUTSIDE * OF THE STANDARD LIBRARY. */ char * tztab(zone,dst) register int zone; int dst; { register struct zone *zp; register char sign; for (zp = zonetab; zp->offset != -1;++zp) /* static tables */ if (zp->offset == zone) { if (dst && zp->dlzone) return(zp->dlzone); if (!dst && zp->stdzone) return(zp->stdzone); } if (zone < 0) { /* create one */ zone = -zone; sign = '+'; } else sign = '-'; (void)sprintf(czone,"GMT%c%d:%02d",sign,zone / 60,zone % 60); return(czone); } ================================================ FILE: lib/libc/gen/ttyname.c ================================================ /* * ttyname(f): return "/dev/ttyXX" which the the name of the * tty belonging to file f. * NULL if it is not a tty */ #include #include #include #include #include static char dev[] = "/dev/"; char * ttyname(f) int f; { struct stat fsb; struct stat tsb; register struct direct *db; register DIR *df; static char rbuf[32]; if (isatty(f)==0) return 0; if (fstat(f, &fsb) < 0) return 0; if ((fsb.st_mode&S_IFMT) != S_IFCHR) return 0; df = opendir(dev); if (! df) return 0; while ((db = readdir(df))) { if (db->d_ino != fsb.st_ino) continue; strcpy(rbuf, dev); strcat(rbuf, db->d_name); if (stat(rbuf, &tsb) < 0) continue; if (tsb.st_dev == fsb.st_dev && tsb.st_ino == fsb.st_ino) { closedir(df); return(rbuf); } } closedir(df); return 0; } ================================================ FILE: lib/libc/gen/ttyslot.c ================================================ /* * Copyright (c) 1984 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ /* * Return the number of the slot in the utmp file * corresponding to the current user: try for file 0, 1, 2. * Definition is the line number in the /etc/ttys file. */ #include #include #include int ttyslot() { register struct ttyent *ty; register char *tp, *p; register int s; if (! (tp = ttyname(0)) && ! (tp = ttyname(1)) && ! (tp = ttyname(2))) return 0; p = strrchr(tp, '/'); if (! p) p = tp; else p++; setttyent(); s = 0; while ((ty = getttyent())) { s++; if (strcmp(ty->ty_name, p) == 0) { endttyent(); return s; } } endttyent(); return 0; } ================================================ FILE: lib/libc/gen/ualarm.c ================================================ /* * Copyright (c) 1985 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include #define USPS 1000000 /* # of microseconds in a second */ /* * Generate a SIGALRM signal in ``usecs'' microseconds. * If ``reload'' is non-zero, keep generating SIGALRM * every ``reload'' microseconds after the first signal. */ unsigned ualarm(usecs, reload) register unsigned usecs; register unsigned reload; { struct itimerval new, old; new.it_interval.tv_usec = reload % USPS; new.it_interval.tv_sec = reload / USPS; new.it_value.tv_usec = usecs % USPS; new.it_value.tv_sec = usecs / USPS; if (setitimer(ITIMER_REAL, &new, &old) == 0) return (old.it_value.tv_sec * USPS + old.it_value.tv_usec); /* else */ return (-1); } ================================================ FILE: lib/libc/gen/uname.c ================================================ /*- * Copyright (c) 1994 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #include #include int uname(struct utsname *name) { int mib[2], rval; size_t len; char *p; rval = 0; mib[0] = CTL_KERN; mib[1] = KERN_OSTYPE; len = sizeof(name->sysname); if (sysctl(mib, 2, &name->sysname, &len, NULL, 0) == -1) rval = -1; mib[0] = CTL_KERN; mib[1] = KERN_HOSTNAME; len = sizeof(name->nodename); if (sysctl(mib, 2, &name->nodename, &len, NULL, 0) == -1) rval = -1; mib[0] = CTL_KERN; mib[1] = KERN_OSRELEASE; len = sizeof(name->release); if (sysctl(mib, 2, &name->release, &len, NULL, 0) == -1) rval = -1; mib[0] = CTL_KERN; mib[1] = KERN_OSVERSION; len = sizeof(name->version); if (sysctl(mib, 2, &name->version, &len, NULL, 0) == -1) { /* Fall back to old behaviour. */ mib[0] = CTL_KERN; mib[1] = KERN_VERSION; len = sizeof(name->version); if (sysctl(mib, 2, &name->version, &len, NULL, 0) == -1) rval = -1; /* If version has newlines in it, turn them into spaces. */ for (p = name->version; len--; ++p) { if (*p == '\n' || *p == '\t') { if (len > 1) *p = ' '; else *p = '\0'; } } } mib[0] = CTL_HW; mib[1] = HW_MACHINE; len = sizeof(name->machine); if (sysctl(mib, 2, &name->machine, &len, NULL, 0) == -1) rval = -1; return (rval); } ================================================ FILE: lib/libc/gen/usleep.c ================================================ /* * Program: sleep.c * Copyright: 1997, sms * Author: Steven M. Schultz * * Version Date Modification * 1.0 1997/9/26 1. Initial release. */ #include /* For NULL */ #include #include /* * This implements the usleep(3) function using only 1 system call (select) * instead of the 9 that the old implementation required. Also this version * avoids using signals (with the attendant system overhead). * * Nothing is returned and if less than ~20000 microseconds is specified the * select will return without any delay at all. */ void usleep(micros) long micros; { struct timeval s; if (micros > 0) { s.tv_sec = micros / 1000000L; s.tv_usec = micros % 1000000L; select(0, NULL, NULL, NULL, &s); } } ================================================ FILE: lib/libc/gen/valloc.c ================================================ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include char * valloc(i) int i; { #ifdef pdp11 /* * page boudaries don't mean anything on a PDP-11 and the cost in * memory is just too prohibitive to blindly use the non-PDP-11 * algorithm. */ return(malloc(i)); #else int valsiz = getpagesize(), j; char *cp = malloc(i + (valsiz-1)); j = ((int)cp + (valsiz-1)) &~ (valsiz-1); return ((char *)j); #endif } ================================================ FILE: lib/libc/gen/wait.c ================================================ /* * Copyright (c) 1988 The Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #include #include #include int wait(istat) int *istat; { return (wait4(WAIT_ANY, istat, 0, (struct rusage *)0)); } ================================================ FILE: lib/libc/gen/wait3.c ================================================ /* * Copyright (c) 1988 The Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #include #include #include int wait3(istat, options, rup) int *istat; int options; struct rusage *rup; { return (wait4(WAIT_ANY, istat, options, rup)); } ================================================ FILE: lib/libc/gen/waitpid.c ================================================ /* * Copyright (c) 1988 The Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #include #include #include int waitpid(pid, istat, options) int pid; int *istat; int options; { return (wait4(pid, istat, options, (struct rusage *)0)); } ================================================ FILE: lib/libc/inet/Makefile ================================================ # # Copyright (c) 1980 Regents of the University of California. # All rights reserved. The Berkeley software License Agreement # specifies the terms and conditions for redistribution. # TOPSRC!=cd ../../..; pwd include ${TOPSRC}/share/mk/sys.mk SRCS = inet_addr.c inet_network.c inet_netof.c \ inet_ntoa.c inet_lnaof.c inet_maddr.c OBJS = inet_addr.o inet_network.o inet_netof.o \ inet_ntoa.o inet_lnaof.o inet_maddr.o CFLAGS += ${DEFS} -Os inet.a: ${OBJS} @echo "building inet.a" @${AR} cr inet.a ${OBJS} tags: cwd=`pwd`; \ for i in ${SRCS}; do \ ctags -a -f ${TAGSFILE} $$cwd/$$i; \ done clean: rm -f *.a *~ *.o profiled/*.o errs a.out core tags Makefile.bak depend: for i in ${SRCS}; do \ cc -M ${CFLAGS} $$i | awk ' { if ($$1 != prev) \ { if (rec != "") print rec; rec = $$0; prev = $$1; } \ else { if (length(rec $$2) > 78) { print rec; rec = $$0; } \ else rec = rec " " $$2 } } \ END { print rec } ' >> makedep; done echo '/^# DO NOT DELETE THIS LINE/+2,$$d' >eddep echo '$$r makedep' >>eddep echo 'w' >>eddep cp Makefile Makefile.bak ed - Makefile < eddep rm eddep makedep echo '# DEPENDENCIES MUST END AT END OF FILE' >> Makefile echo '# IF YOU PUT STUFF HERE IT WILL GO AWAY' >> Makefile echo '# see make depend above' >> Makefile # DO NOT DELETE THIS LINE -- make depend uses it ================================================ FILE: lib/libc/inet/inet_addr.c ================================================ /* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include #include #include #include /* * Internet address interpretation routine. * All the network library routines call this * routine to interpret entries in the data bases * which are expected to be an address. * The value returned is in network order. */ u_long inet_addr(cp) register char *cp; { register u_long val, base; register u_int n; /* can't switch on longs - should be an int anyway */ register char c; u_long parts[4], *pp = parts; again: /* * Collect number up to ``.''. * Values are specified as for C: * 0x=hex, 0=octal, other=decimal. */ val = 0; base = 10; if (*cp == '0') base = 8, cp++; if (*cp == 'x' || *cp == 'X') base = 16, cp++; while ((c = *cp)) { if (isdigit(c)) { val = (val * base) + (c - '0'); cp++; continue; } if (base == 16 && isxdigit(c)) { val = (val << 4) + (c + 10 - (islower(c) ? 'a' : 'A')); cp++; continue; } break; } if (*cp == '.') { /* * Internet format: * a.b.c.d * a.b.c (with c treated as 16-bits) * a.b (with b treated as 24 bits) */ if (pp >= parts + 4) return (-1); *pp++ = val, cp++; goto again; } /* * Check for trailing characters. */ if (*cp && !isspace(*cp)) return (-1); *pp++ = val; /* * Concoct the address according to * the number of parts specified. */ n = pp - parts; switch (n) { case 1: /* a -- 32 bits */ val = parts[0]; break; case 2: /* a.b -- 8.24 bits */ val = (parts[0] << 24) | (parts[1] & 0xffffff); break; case 3: /* a.b.c -- 8.8.16 bits */ val = (parts[0] << 24) | ((parts[1] & 0xff) << 16) | (parts[2] & 0xffffL); break; case 4: /* a.b.c.d -- 8.8.8.8 bits */ val = (parts[0] << 24) | ((parts[1] & 0xff) << 16) | ((parts[2] & 0xff) << 8) | (parts[3] & 0xff); break; default: return (-1); } val = htonl(val); return (val); } ================================================ FILE: lib/libc/inet/inet_lnaof.c ================================================ /* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include #include #include /* * Return the local network address portion of an * internet address; handles class a/b/c network * number formats. */ u_long inet_lnaof(in) struct in_addr in; { register u_long i = ntohl(in.s_addr); if (IN_CLASSA(i)) return ((i)&IN_CLASSA_HOST); else if (IN_CLASSB(i)) return ((i)&IN_CLASSB_HOST); else return ((i)&IN_CLASSC_HOST); } ================================================ FILE: lib/libc/inet/inet_maddr.c ================================================ /* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include #include #include /* * Formulate an Internet address from network + host. Used in * building addresses stored in the ifnet structure. */ struct in_addr inet_makeaddr(net, host) long net, host; { u_long addr; if (net < 128) addr = (net << IN_CLASSA_NSHIFT) | (host & IN_CLASSA_HOST); else if (net < 65536L) addr = (net << IN_CLASSB_NSHIFT) | (host & IN_CLASSB_HOST); else addr = (net << IN_CLASSC_NSHIFT) | (host & IN_CLASSC_HOST); addr = htonl(addr); return (*(struct in_addr *)&addr); } ================================================ FILE: lib/libc/inet/inet_netof.c ================================================ /* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #include #include /* * Return the network number from an internet * address; handles class a/b/c network #'s. */ u_long inet_netof(in) struct in_addr in; { u_long i = ntohl(in.s_addr); if (IN_CLASSA(i)) return (((i)&IN_CLASSA_NET) >> IN_CLASSA_NSHIFT); else if (IN_CLASSB(i)) return (((i)&IN_CLASSB_NET) >> IN_CLASSB_NSHIFT); else return (((i)&IN_CLASSC_NET) >> IN_CLASSC_NSHIFT); } ================================================ FILE: lib/libc/inet/inet_network.c ================================================ /* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include #include #include #include /* * Internet network address interpretation routine. * The library routines call this routine to interpret * network numbers. */ u_long inet_network(cp) register char *cp; { register u_long val, base, n; register char c; u_long parts[4], *pp = parts; register int i; again: val = 0; base = 10; if (*cp == '0') base = 8, cp++; if (*cp == 'x' || *cp == 'X') base = 16, cp++; while ((c = *cp)) { if (isdigit(c)) { val = (val * base) + (c - '0'); cp++; continue; } if (base == 16 && isxdigit(c)) { val = (val << 4) + (c + 10 - (islower(c) ? 'a' : 'A')); cp++; continue; } break; } if (*cp == '.') { if (pp >= parts + 4) return (-1); *pp++ = val, cp++; goto again; } if (*cp && !isspace(*cp)) return (-1); *pp++ = val; n = pp - parts; if (n > 4) return (-1); for (val = 0, i = 0; i < n; i++) { val <<= 8; val |= parts[i] & 0xff; } return (val); } ================================================ FILE: lib/libc/inet/inet_ntoa.c ================================================ /* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ /* * Convert network-format internet address * to base 256 d.d.d.d representation. */ #include #include #include #include char * inet_ntoa(in) struct in_addr in; { static char b[18]; register char *p; p = (char *)∈ #define UC(b) (((int)b)&0xff) sprintf(b, "%d.%d.%d.%d", UC(p[0]), UC(p[1]), UC(p[2]), UC(p[3])); return (b); } ================================================ FILE: lib/libc/mips/Makefile ================================================ # # Copyright (c) 1987 Regents of the University of California. # All rights reserved. The Berkeley software License Agreement # specifies the terms and conditions for redistribution. # # Machine dependent routines for the MIPS are located here # TOPSRC!=cd ../../..; pwd include ${TOPSRC}/share/mk/sys.mk ALL = gen string sys mips.a: ${ALL} -mkdir tmp for i in ${ALL}; do (cd tmp; $(AR) x ../$$i/$$i.a); done $(AR) cr mips.a `ls tmp/*.o | sort` rm -rf tmp ${ALL}: FRC cd $@; ${MAKE} ${MFLAGS} DEFS="${DEFS}" FRC: tags: for i in ${ALL}; do \ (cd $$i; ${MAKE} ${MFLAGS} TAGSFILE=../${TAGSFILE} tags); \ done clean: for i in ${ALL}; do (cd $$i; ${MAKE} ${MFLAGS} clean); done rm -rf *.a tmp *~ depend: for i in ${ALL}; do \ (cd $$i; ${MAKE} ${MFLAGS} DEFS="${DEFS}" depend); done ================================================ FILE: lib/libc/mips/gen/Makefile ================================================ # # Copyright (c) 1980 Regents of the University of California. # All rights reserved. The Berkeley software License Agreement # specifies the terms and conditions for redistribution. # TOPSRC!=cd ../../../..; pwd include ${TOPSRC}/share/mk/sys.mk CFLAGS += ${DEFS} SRCS = _setjmp.S htonl.S htons.S setjmp.S sigsetjmp.S OBJS = _setjmp.o htonl.o htons.o setjmp.o sigsetjmp.o gen.a: ${OBJS} @echo "building gen.a" @${AR} cr gen.a ${OBJS} tags: cwd=`pwd`; \ for i in ${SRCS}; do \ ctags -a -f ${TAGSFILE} $$cwd/$$i; \ done clean: rm -f gen.a *.o *~ profiled/*.o tags Makefile.bak depend: for i in ${SRCS}; do \ cc -M ${CFLAGS} $$i | awk ' { if ($$1 != prev) \ { if (rec != "") print rec; rec = $$0; prev = $$1; } \ else { if (length(rec $$2) > 78) { print rec; rec = $$0; } \ else rec = rec " " $$2 } } \ END { print rec } ' >> makedep; done echo '/^# DO NOT DELETE THIS LINE/+2,$$d' >eddep echo '$$r makedep' >>eddep echo 'w' >>eddep cp Makefile Makefile.bak ed - Makefile < eddep rm eddep makedep echo '# DEPENDENCIES MUST END AT END OF FILE' >> Makefile echo '# IF YOU PUT STUFF HERE IT WILL GO AWAY' >> Makefile echo '# see make depend above' >> Makefile # DO NOT DELETE THIS LINE -- make depend uses it ================================================ FILE: lib/libc/mips/gen/_setjmp.S ================================================ /*- * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Ralph Campbell. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ /* * C library -- _setjmp, _longjmp * * _longjmp(a,v) * will generate a "return(v)" from * the last call to * _setjmp(a) * by restoring registers from the stack, * The previous signal state is NOT restored. */ .set noreorder .type _setjmp, @function _setjmp: .globl _setjmp sw $s0, (0 * 4) ($a0) # save register variables s0-s8 sw $s1, (1 * 4) ($a0) sw $s2, (2 * 4) ($a0) sw $s3, (3 * 4) ($a0) sw $s4, (4 * 4) ($a0) sw $s5, (5 * 4) ($a0) sw $s6, (6 * 4) ($a0) sw $s7, (7 * 4) ($a0) sw $s8, (8 * 4) ($a0) # frame pointer sw $ra, (9 * 4) ($a0) # return address sw $gp, (10 * 4) ($a0) # global data pointer sw $sp, (11 * 4) ($a0) # stack pointer # For compatibility with longjmp and siglongjmp sw $zero, (12 * 4) ($a0) # signal mask saved sw $zero, (13 * 4) ($a0) # signal mask j $ra move $v0, $zero # return a zero for the setjmp call .type _longjmp, @function _longjmp: .globl _longjmp lw $s0, (0 * 4) ($a0) # restore register variables s0-s8 lw $s1, (1 * 4) ($a0) lw $s2, (2 * 4) ($a0) lw $s3, (3 * 4) ($a0) lw $s4, (4 * 4) ($a0) lw $s5, (5 * 4) ($a0) lw $s6, (6 * 4) ($a0) lw $s7, (7 * 4) ($a0) lw $s8, (8 * 4) ($a0) # frame pointer lw $ra, (9 * 4) ($a0) # return address lw $gp, (10 * 4) ($a0) # global data pointer lw $sp, (11 * 4) ($a0) # stack pointer j $ra # transfer back to setjmp() move $v0, $a1 # get return value in 1st arg ================================================ FILE: lib/libc/mips/gen/htonl.S ================================================ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Neil A. Carson * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the NetBSD * Foundation, Inc. and its contributors. * 4. Neither the name of The NetBSD Foundation nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ # # a0 = 0x11223344, return 0x44332211 # .type htonl, @function htonl: .globl htonl .type ntohl, @function ntohl: .globl ntohl #ifdef __MIPSEB__ move $v0, $a0 #else srl $v1, $a0, 24 # v1 = 0x00000011 sll $v0, $a0, 24 # v0 = 0x44000000 or $v0, $v0, $v1 andi $v1, $a0, 0xff00 sll $v1, $v1, 8 # v1 = 0x00330000 or $v0, $v0, $v1 srl $v1, $a0, 8 andi $v1, $v1, 0xff00 # v1 = 0x00002200 or $v0, $v0, $v1 #endif j $ra ================================================ FILE: lib/libc/mips/gen/htons.S ================================================ /*- * Copyright (c) 1999 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Charles M. Hannum. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the NetBSD * Foundation, Inc. and its contributors. * 4. Neither the name of The NetBSD Foundation nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ .type htons, @function htons: .globl htons .type ntohs, @function ntohs: .globl ntohs #ifdef __MIPSEB__ move $v0, $a0 #else srl $v0, $a0, 8 andi $v0, $v0, 0xff sll $v1, $a0, 8 andi $v1, $v1, 0xff00 or $v0, $v0, $v1 #endif j $ra ================================================ FILE: lib/libc/mips/gen/setjmp.S ================================================ /*- * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Ralph Campbell. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ /* * C library -- setjmp, longjmp * * longjmp(a,v) * will generate a "return(v)" from * the last call to * setjmp(a) * by restoring registers from the stack, * and a struct sigcontext, see * * From: Chris Dearman */ .set noreorder .type setjmp, @function setjmp: .globl setjmp subu $sp, $sp, 24 sw $ra, 20($sp) sw $a0, 24($sp) /* Get the signal mask. */ addu $a2, $a0, 13*4 # &omask li $a0, 1 # SIG_BLOCK jal sigprocmask # get current signal mask move $a1, $0 # BDS: NULL lw $a0, 24($sp) lw $ra, 20($sp) addu $sp, $sp, 24 li $t0, 1 sw $t0, (12 * 4)($a0) sw $s0, (0 * 4) ($a0) # save register variables s0-s8 sw $s1, (1 * 4) ($a0) sw $s2, (2 * 4) ($a0) sw $s3, (3 * 4) ($a0) sw $s4, (4 * 4) ($a0) sw $s5, (5 * 4) ($a0) sw $s6, (6 * 4) ($a0) sw $s7, (7 * 4) ($a0) sw $s8, (8 * 4) ($a0) # frame pointer sw $ra, (9 * 4) ($a0) # return address sw $gp, (10 * 4) ($a0) # global data pointer sw $sp, (11 * 4) ($a0) # stack pointer j $ra move $v0, $zero # BDS: return a zero for the setjmp call .type longjmp, @function longjmp: .globl longjmp subu $sp, $sp, 24 sw $ra, 20($sp) sw $a0, 24($sp) sw $a1, 28($sp) /* Restore signal mask. */ addu $a1, $a0, 13*4 # &omask move $a2, $0 # NULL jal sigprocmask # set current signal mask li $a0, 3 # BDS: SIG_SETMASK lw $a1, 28($sp) lw $a0, 24($sp) lw $ra, 20($sp) addu $sp, $sp, 24 lw $s0, (0 * 4) ($a0) # restore register variables s0-s8 lw $s1, (1 * 4) ($a0) lw $s2, (2 * 4) ($a0) lw $s3, (3 * 4) ($a0) lw $s4, (4 * 4) ($a0) lw $s5, (5 * 4) ($a0) lw $s6, (6 * 4) ($a0) lw $s7, (7 * 4) ($a0) lw $s8, (8 * 4) ($a0) # frame pointer lw $ra, (9 * 4) ($a0) # return address lw $gp, (10 * 4) ($a0) # global data pointer lw $sp, (11 * 4) ($a0) # stack pointer j $ra move $v0, $a1 # BDS: return value from longjmp ================================================ FILE: lib/libc/mips/gen/sigsetjmp.S ================================================ /*- * Copyright (c) 1991, 1993, 1995, * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Havard Eidnes. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ /* * C library -- sigsetjmp, siglongjmp * * siglongjmp(a,v) * will generate a "return(v)" from * the last call to * sigsetjmp(a, savemask) * by restoring registers from the stack, * and dependent on savemask restores the * signal mask. * * From: Chris Dearman */ .set noreorder .type sigsetjmp, @function sigsetjmp: .globl sigsetjmp bne $a1, 0x0, 1f # do saving of signal mask? nop j _setjmp nop 1: j setjmp nop .type siglongjmp, @function siglongjmp: .globl siglongjmp lw $t0, (12 * 4)($a0) bnez $t0, 1f nop j _longjmp nop 1: j longjmp nop ================================================ FILE: lib/libc/mips/string/Makefile ================================================ # # Copyright (c) 1980 Regents of the University of California. # All rights reserved. The Berkeley software License Agreement # specifies the terms and conditions for redistribution. # TOPSRC!=cd ../../../..; pwd include ${TOPSRC}/share/mk/sys.mk CFLAGS += ${DEFS} # # Endian-independent assembly-code aliases for unaligned memory accesses. # Little endian. # ASFLAGS += -DLWHI=lwr -DLWLO=lwl -DSWHI=swr -DSWLO=swl SRCS = bcopy.S bzero.S ffs.S memcpy.S memmove.S memset.S \ strlen.S bcmp.S index.S rindex.S strcmp.S OBJS = bcopy.o bzero.o ffs.o memcpy.o memmove.o memset.o \ strlen.o bcmp.o index.o rindex.o strcmp.o string.a: ${OBJS} @echo "building string.a" @${AR} cr string.a ${OBJS} tags: cwd=`pwd`; \ for i in ${SRCS}; do \ ctags -a -f ${TAGSFILE} $$cwd/$$i; \ done clean: rm -f string.a *.o *~ profiled/*.o tags Makefile.bak depend: for i in ${SRCS}; do \ cc -M ${CFLAGS} $$i | awk ' { if ($$1 != prev) \ { if (rec != "") print rec; rec = $$0; prev = $$1; } \ else { if (length(rec $$2) > 78) { print rec; rec = $$0; } \ else rec = rec " " $$2 } } \ END { print rec } ' >> makedep; done echo '/^# DO NOT DELETE THIS LINE/+2,$$d' >eddep echo '$$r makedep' >>eddep echo 'w' >>eddep cp Makefile Makefile.bak ed - Makefile < eddep rm eddep makedep echo '# DEPENDENCIES MUST END AT END OF FILE' >> Makefile echo '# IF YOU PUT STUFF HERE IT WILL GO AWAY' >> Makefile echo '# see make depend above' >> Makefile # DO NOT DELETE THIS LINE -- make depend uses it ================================================ FILE: lib/libc/mips/string/bcmp.S ================================================ /*- * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Ralph Campbell. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ /* bcmp(s1, s2, n) */ .type bcmp, @function bcmp: .globl bcmp .set noreorder .set noat slti $at, $a2, 16 # small amount to clear? bnez $at, small # is it worth any trouble? xor $v0, $a0, $a1 # compare low two bits of addresses andi $v0, $v0, 3 subu $a3, $zero, $a1 # compute # bytes to word align address bne $v0, $zero, unaligned # not possible to align addresses andi $a3, $a3, 3 beq $a3, $zero, 1f subu $a2, $a2, $a3 # subtract from remaining count move $v0, $v1 # init v0,v1 so unmodified bytes match LWHI $v0, 0($a0) # read 1, 2, or 3 bytes LWHI $v1, 0($a1) addu $a1, $a1, $a3 bne $v0, $v1, nomatch addu $a0, $a0, $a3 1: li $at, ~3 and $a3, $a2, $at # compute number of whole words left subu $a2, $a2, $a3 # which has to be >= (16-3) & ~3 addu $a3, $a3, $a0 # compute ending address 2: lw $v0, 0($a0) # compare words lw $v1, 0($a1) addiu $a0, $a0, 4 bne $v0, $v1, nomatch addiu $a1, $a1, 4 bne $a0, $a3, 2b nop b small # finish remainder nop unaligned: beq $a3, $zero, 2f subu $a2, $a2, $a3 # subtract from remaining count addu $a3, $a3, $a0 # compute ending address 1: lbu $v0, 0($a0) # compare bytes until a1 word aligned lbu $v1, 0($a1) addiu $a0, $a0, 1 bne $v0, $v1, nomatch addiu $a1, $a1, 1 bne $a0, $a3, 1b nop 2: li $at, ~3 and $a3, $a2, $at # compute number of whole words left subu $a2, $a2, $a3 # which has to be >= (16-3) & ~3 addu $a3, $a3, $a0 # compute ending address 3: LWHI $v0, 0($a0) # compare words a0 unaligned, a1 aligned LWLO $v0, 3($a0) lw $v1, 0($a1) addiu $a0, $a0, 4 bne $v0, $v1, nomatch addiu $a1, $a1, 4 bne $a0, $a3, 3b nop small: blez $a2, match addu $a3, $a2, $a0 # compute ending address 1: lbu $v0, 0($a0) lbu $v1, 0($a1) addiu $a0, $a0, 1 bne $v0, $v1, nomatch addiu $a1, $a1, 1 bne $a0, $a3, 1b nop match: j $ra move $v0, $zero nomatch: j $ra li $v0, 1 ================================================ FILE: lib/libc/mips/string/bcopy.S ================================================ /* * Fast copy routine. Derived from aligned_block_copy. ^ * bcopy(caddr_t src, caddr_t dst, unsigned int len) * * a0 src address * a1 dst address * a2 length * * Author: Chris Maeda * Date: June 1993 * * Mach Operating System * Copyright (c) 1993 Carnegie Mellon University * All Rights Reserved. * * Permission to use, copy, modify and distribute this software and its * documentation is hereby granted, provided that both the copyright * notice and this permission notice appear in all copies of the * software, derivative works or modified versions, and any portions * thereof, and that both notices appear in supporting documentation. * * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. * * Carnegie Mellon requests users of this software to return to * * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU * School of Computer Science * Carnegie Mellon University * Pittsburgh PA 15213-3890 * * any improvements or extensions that they make and grant Carnegie Mellon * the rights to redistribute these changes. */ #if defined(MEMCOPY) || defined(MEMMOVE) # ifdef MEMCOPY # define FUNCTION memcpy # else # define FUNCTION memmove # endif # define SRCREG $a1 # define DSTREG $a0 #else # define FUNCTION bcopy # define SRCREG $a0 # define DSTREG $a1 #endif #define SIZEREG $a2 .globl FUNCTION .type FUNCTION, @function FUNCTION: .set noat .set noreorder #if defined(MEMCOPY) || defined(MEMMOVE) /* set up return value, while we still can */ move $v0,DSTREG #endif # # Make sure we can copy forwards. # sltu $t0,SRCREG,DSTREG # t0 == SRCREG < DSTREG bne $t0,$zero,6f # copy backwards # # There are four alignment cases (with frequency) # (Based on measurements taken with a DECstation 5000/200 # inside a Mach kernel.) # # aligned -> aligned (mostly) # unaligned -> aligned (sometimes) # aligned,unaligned -> unaligned (almost never) # # Note that we could add another case that checks if # the destination and source are unaligned but the # copy is alignable. eg if src and dest are both # on a halfword boundary. # andi $t1,DSTREG,3 # get last 3 bits of dest bne $t1,$zero,3f andi $t0,SRCREG,3 # get last 3 bits of src bne $t0,$zero,5f # # Forward aligned->aligned copy, 8*4 bytes at a time. # li $at,-32 and $t0,SIZEREG,$at # count truncated to multiple of 32 */ addu $a3,SRCREG,$t0 # run fast loop up to this address sltu $at,SRCREG,$a3 # any work to do? beq $at,$zero,2f subu SIZEREG,$t0 # # loop body # 1: # cp lw $t3,0(SRCREG) lw $v1,4(SRCREG) lw $t0,8(SRCREG) lw $t1,12(SRCREG) addiu SRCREG,32 sw $t3,0(DSTREG) sw $v1,4(DSTREG) sw $t0,8(DSTREG) sw $t1,12(DSTREG) lw $t1,-4(SRCREG) lw $t0,-8(SRCREG) lw $v1,-12(SRCREG) lw $t3,-16(SRCREG) addiu DSTREG,32 sw $t1,-4(DSTREG) sw $t0,-8(DSTREG) sw $v1,-12(DSTREG) bne SRCREG,$a3,1b sw $t3,-16(DSTREG) # # Copy a word at a time, no loop unrolling. # 2: # wordcopy andi $t2,SIZEREG,3 # get byte count / 4 subu $t2,SIZEREG,$t2 # t2 = number of words to copy * 4 beq $t2,$zero,3f addu $t0,SRCREG,$t2 # stop at t0 subu SIZEREG,SIZEREG,$t2 1: lw $t3,0(SRCREG) addiu SRCREG,4 sw $t3,0(DSTREG) bne SRCREG,$t0,1b addiu DSTREG,4 3: # bytecopy beq SIZEREG,$zero,4f # nothing left to do? nop 1: lb $t3,0(SRCREG) addiu SRCREG,1 sb $t3,0(DSTREG) addiu SIZEREG,-1 bgtz SIZEREG,1b addiu DSTREG,1 4: # copydone j $ra nop # # Copy from unaligned source to aligned dest. # 5: # destaligned andi $t0,SIZEREG,3 # t0 = bytecount mod 4 subu $a3,SIZEREG,$t0 # number of words to transfer beq $a3,$zero,3b nop move SIZEREG,$t0 # this many to do after we are done addu $a3,SRCREG,$a3 # stop point 1: LWHI $t3,0(SRCREG) LWLO $t3,3(SRCREG) addi SRCREG,4 sw $t3,0(DSTREG) bne SRCREG,$a3,1b addi DSTREG,4 j 3b nop 6: # backcopy -- based on above addu SRCREG,SIZEREG addu DSTREG,SIZEREG andi $t1,DSTREG,3 # get last 3 bits of dest bne $t1,$zero,3f andi $t0,SRCREG,3 # get last 3 bits of src bne $t0,$zero,5f # # Forward aligned->aligned copy, 8*4 bytes at a time. # li $at,-32 and $t0,SIZEREG,$at # count truncated to multiple of 32 beq $t0,$zero,2f # any work to do? subu SIZEREG,$t0 subu $a3,SRCREG,$t0 # # loop body # 1: # cp lw $t3,-16(SRCREG) lw $v1,-12(SRCREG) lw $t0,-8(SRCREG) lw $t1,-4(SRCREG) addiu SRCREG,-32 sw $t3,-16(DSTREG) sw $v1,-12(DSTREG) sw $t0,-8(DSTREG) sw $t1,-4(DSTREG) lw $t1,12(SRCREG) lw $t0,8(SRCREG) lw $v1,4(SRCREG) lw $t3,0(SRCREG) addiu DSTREG,-32 sw $t1,12(DSTREG) sw $t0,8(DSTREG) sw $v1,4(DSTREG) bne SRCREG,$a3,1b sw $t3,0(DSTREG) # # Copy a word at a time, no loop unrolling. # 2: # wordcopy andi $t2,SIZEREG,3 # get byte count / 4 subu $t2,SIZEREG,$t2 # t2 = number of words to copy * 4 beq $t2,$zero,3f subu $t0,SRCREG,$t2 # stop at t0 subu SIZEREG,SIZEREG,$t2 1: lw $t3,-4(SRCREG) addiu SRCREG,-4 sw $t3,-4(DSTREG) bne SRCREG,$t0,1b addiu DSTREG,-4 3: # bytecopy beq SIZEREG,$zero,4f # nothing left to do? nop 1: lb $t3,-1(SRCREG) addiu SRCREG,-1 sb $t3,-1(DSTREG) addiu SIZEREG,-1 bgtz SIZEREG,1b addiu DSTREG,-1 4: # copydone j $ra nop # # Copy from unaligned source to aligned dest. # 5: # destaligned andi $t0,SIZEREG,3 # t0 = bytecount mod 4 subu $a3,SIZEREG,$t0 # number of words to transfer beq $a3,$zero,3b nop move SIZEREG,$t0 # this many to do after we are done subu $a3,SRCREG,$a3 # stop point 1: LWHI $t3,-4(SRCREG) LWLO $t3,-1(SRCREG) addiu SRCREG,-4 sw $t3,-4(DSTREG) bne SRCREG,$a3,1b addiu DSTREG,-4 j 3b nop .set reorder .set at ================================================ FILE: lib/libc/mips/string/bzero.S ================================================ /*- * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Ralph Campbell. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ /* bzero(s1, n) */ #define SZREG 4 .type bzero, @function bzero: .globl bzero .set noreorder .set noat slti $at, $a1, 3*SZREG # small amount to clear? bnez $at, smallclr subu $a3, $zero, $a0 # compute # bytes to word align address andi $a3, $a3, SZREG-1 beqz $a3, 1f # skip if word aligned subu $a1, $a1, $a3 # subtract from remaining count SWHI $zero, 0($a0) # clear 1, 2, or 3 bytes to align addu $a0, $a0, $a3 1: andi $v0, $a1, SZREG-1 # compute number of words left subu $a3, $a1, $v0 move $a1, $v0 addu $a3, $a3, $a0 # compute ending address 2: addiu $a0, $a0, SZREG # clear words bne $a0, $a3, 2b # unrolling loop doesnt help sw $zero, -SZREG($a0) # since we are limited by memory speed smallclr: blez $a1, 2f addu $a3, $a1, $a0 # compute ending address 1: addiu $a0, $a0, 1 # clear bytes bne $a0, $a3, 1b sb $zero, -1($a0) 2: j $ra nop ================================================ FILE: lib/libc/mips/string/ffs.S ================================================ /*- * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Ralph Campbell. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ /* bit = ffs(value) */ .set reorder .type ffs, @function ffs: .globl ffs move $v0, $zero beq $a0, $zero, done 1: andi $v1, $a0, 1 # bit set? addiu $v0, $v0, 1 srl $a0, $a0, 1 beq $v1, $zero, 1b # no, continue done: j $ra ================================================ FILE: lib/libc/mips/string/index.S ================================================ /*- * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Ralph Campbell. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ .set reorder .type index, @function index: .globl index 1: lbu $a2, 0($a0) # get a byte addiu $a0, $a0, 1 beq $a2, $a1, fnd bnez $a2, 1b notfnd: move $v0, $zero j $ra fnd: addiu $v0, $a0, -1 j $ra ================================================ FILE: lib/libc/mips/string/memcpy.S ================================================ #define MEMCOPY #include "bcopy.S" ================================================ FILE: lib/libc/mips/string/memmove.S ================================================ #define MEMMOVE #include "bcopy.S" ================================================ FILE: lib/libc/mips/string/memset.S ================================================ # # memset(void *s1, int c, int len) # .type memset, @function memset: .globl memset .set noreorder .set noat slti $at, $a2, 12 # small amount to clear? bnez $at, smallclr move $v0, $a0 # save s1 for result sll $t1, $a1, 8 # compute c << 8 in t1 or $t1, $t1, $a1 # compute c << 8 | c in 11 sll $t2, $t1, 16 # shift that left 16 or $t1, $t2, $t1 # or together subu $t0, $zero, $a0 # compute # bytes to word align address andi $t0, $t0, 3 beqz $t0, 1f # skip if word aligned subu $a2, $a2, $t0 # subtract from remaining count SWHI $t1, 0($a0) # store 1, 2, or 3 bytes to align addu $a0, $a0, $t0 1: andi $v1, $a2, 3 # compute number of whole words left subu $t0, $a2, $v1 subu $a2, $a2, $t0 addu $t0, $t0, $a0 # compute ending address 2: addiu $a0, $a0, 4 # clear words bne $a0, $t0, 2b # unrolling loop does not help sw $t1, -4($a0) # since we are limited by memory speed smallclr: blez $a2, 2f addu $t0, $a2, $a0 # compute ending address 1: addiu $a0, $a0, 1 # clear bytes bne $a0, $t0, 1b sb $a1, -1($a0) 2: j $ra nop ================================================ FILE: lib/libc/mips/string/rindex.S ================================================ /*- * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Ralph Campbell. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ .set reorder .type rindex, @function rindex: .globl rindex move $v0, $zero # default if not found 1: lbu $a3, 0($a0) # get a byte addiu $a0, $a0, 1 bne $a3, $a1, 2f addiu $v0, $a0, -1 # save address of last match 2: bnez $a3, 1b # continue if not end j $ra ================================================ FILE: lib/libc/mips/string/strcmp.S ================================================ /*- * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Ralph Campbell. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ # # NOTE: this version assumes unsigned chars in order to be "8 bit clean". # .set reorder .type strcmp, @function strcmp: .globl strcmp 1: lbu $t0, 0($a0) # get two bytes and compare them lbu $t1, 0($a1) beqz $t0, LessOrEq # end of first string? bne $t0, $t1, NotEq lbu $t0, 1($a0) # unroll loop lbu $t1, 1($a1) addi $a0, $a0, 2 beqz $t0, LessOrEq # end of first string? addi $a1, $a1, 2 beq $t0, $t1, 1b NotEq: subu $v0, $t0, $t1 j $ra LessOrEq: subu $v0, $zero, $t1 j $ra ================================================ FILE: lib/libc/mips/string/strlen.S ================================================ /*- * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Ralph Campbell. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ .set reorder .type strlen, @function strlen: .globl strlen addiu $v1, $a0, 1 1: lb $v0, 0($a0) # get byte from string addiu $a0, $a0, 1 # increment pointer bne $v0, $zero, 1b # continue if not end subu $v0, $a0, $v1 # compute length - 1 for '\0' char j $ra ================================================ FILE: lib/libc/mips/sys/Makefile ================================================ TOPSRC!=cd ../../../..; pwd include ${TOPSRC}/share/mk/sys.mk ASFLAGS += ${DEFS} CFLAGS += -Os # modules which can not use SYSCALL and must be assembled from sources. The # rest of the system calls are generated with printf(1) and do not have # source files associated with them. COBJS = sbrk.o execl.o execle.o execv.o ASMOBJS = _exit.o _brk.o pipe.o ptrace.o sigaction.o SYSOBJS = __sysctl.o accept.o access.o adjtime.o bind.o chdir.o \ chflags.o chmod.o chown.o chroot.o close.o connect.o dup.o \ dup2.o execve.o fchdir.o fchflags.o fchmod.o fchown.o \ fcntl.o flock.o fork.o fstat.o fsync.o ftruncate.o \ getdtablesize.o getgroups.o getitimer.o getsockname.o \ getpeername.o getpriority.o getrlimit.o getrusage.o getsockopt.o \ gettimeofday.o ioctl.o kill.o killpg.o link.o listen.o lstat.o mkdir.o \ mknod.o mount.o open.o pselect.o quota.o read.o readlink.o readv.o \ reboot.o \ recv.o recvfrom.o recvmsg.o rename.o rmdir.o select.o send.o sendmsg.o \ sendto.o setgroups.o setitimer.o setpgrp.o setpriority.o setquota.o \ setuid.o seteuid.o setgid.o setegid.o \ setrlimit.o setsockopt.o settimeofday.o shutdown.o \ sigaltstack.o socket.o socketpair.o stat.o symlink.o \ sigprocmask.o sigstack.o sigwait.o \ statfs.o fstatfs.o getfsstat.o \ truncate.o umount.o unlink.o utimes.o wait4.o write.o writev.o \ lseek.o sigsuspend.o \ getgid.o getegid.o getpgrp.o getpid.o \ getppid.o getuid.o geteuid.o profil.o sigpending.o sync.o \ ufetch.o ustore.o ucall.o umask.o vfork.o vhangup.o \ rdglob.o wrglob.o msec.o kmemdev.o OBJS = ${COBJS} ${ASMOBJS} ${SYSOBJS} TAGSFILE = tags sys.a: ${OBJS} @echo "building sys.a" @${AR} cr sys.a ${OBJS} ${SYSOBJS}: SYS.h # @echo creating $*.o @printf '#include "SYS.h"\nSYS($*)\n' | $(AS) ${ASFLAGS} - -c -o $*.o clean: rm -f *~ *.o a.out sys.a ================================================ FILE: lib/libc/mips/sys/SYS.h ================================================ /* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include #define ENTRY(s) s: .globl s; \ .type s, @function #define SYS(s) ENTRY(s); \ .set noreorder; \ syscall SYS_##s; \ lui $t1, %hi(errno); \ sw $t0, %lo(errno)($t1); \ .set reorder; \ jr $ra ================================================ FILE: lib/libc/mips/sys/_brk.S ================================================ /* * Copyright (c) 1987 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include "SYS.h" ENTRY(_brk) .set noreorder syscall SYS_sbrk lui $t1, %hi(errno) # return here on error sw $t0, %lo(errno)($t1) .set reorder jr $ra # return here on success ================================================ FILE: lib/libc/mips/sys/_exit.S ================================================ /* * Copyright (c) 1987 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include "SYS.h" ENTRY(_exit) syscall SYS_exit ================================================ FILE: lib/libc/mips/sys/execl.c ================================================ /* * Copyright (c) 1987 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include extern char **environ; int execl (const char *name, const char *arg, ...) { return execve (name, (char *const*) &arg, environ); } ================================================ FILE: lib/libc/mips/sys/execle.c ================================================ /* * Copyright (c) 1987 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include #include int execle (const char *name, const char *arg, ...) { va_list ap; char **envp; va_start (ap, arg); while ((va_arg (ap, char *)) != NULL) continue; envp = va_arg (ap, char **); va_end (ap); return execve (name, (char *const*) &arg, envp); } ================================================ FILE: lib/libc/mips/sys/execv.c ================================================ /* * Copyright (c) 1987 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include extern char **environ; int execv (name, argv) const char *name; char *const *argv; { return execve (name, argv, environ); } ================================================ FILE: lib/libc/mips/sys/pipe.S ================================================ /* * Copyright (c) 1987 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include "SYS.h" ENTRY(pipe) .set noreorder syscall SYS_pipe j 1f # return here on error nop .set reorder sw $v0, 0($a0) # return here on success sw $v1, 4($a0) move $v0, $zero jr $ra 1: lui $t1, %hi(errno) sw $t0, %lo(errno)($t1) jr $ra ================================================ FILE: lib/libc/mips/sys/ptrace.S ================================================ /* * Copyright (c) 1987 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include "SYS.h" ENTRY(ptrace) # -1 is a legitimate return # value so we must clear errno # so the caller may disambiguate lui $t1, %hi(errno) sw $zero, %lo(errno)($t1) .set noreorder syscall SYS_ptrace lui $t1, %hi(errno) # return here on error sw $t0, %lo(errno)($t1) .set reorder jr $ra # return here on success ================================================ FILE: lib/libc/mips/sys/sbrk.c ================================================ /* * Copyright (c) 1987 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include extern char _end[]; const char *_curbrk = _end; void * sbrk (incr) int incr; { void *oldbrk = (void*) _curbrk; if (incr != 0) { /* calculate and pass break address */ const void *addr = _curbrk + incr; if (_brk (addr) != -1) { /* add increment to curbrk */ _curbrk = addr; } } /* return old break address */ return oldbrk; } void * brk (addr) const void *addr; { int ret; if (addr < (void*) _end) /* break request too low? */ addr = _end; /* yes, knock the request up to _end */ ret = _brk (addr); /* ask for break */ if (ret != -1) _curbrk = addr; /* and remember it if it succeeded */ return (void*) ret; } ================================================ FILE: lib/libc/mips/sys/sigaction.S ================================================ /* * Copyright (c) 1987 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ /* * error = sigaction(sig, vec, ovec) * int error, sig; * struct sigaction *vec, *ovec; * * We pass one additional parameter to the sigaction sys call: the address of * the "Trampoline Code", sigtramp - the code that handles saving and restoring * register context and so on for signals. On the VAX-11 under BSD4.3 it isn't * necessary to pass this address since the trampoline code is stored in the * user structure in u.u_pcb.pcb_sigc at a known address in user space. It * really doesn't introduce much extra overhead, so our method for doing it on * a PDP-11 is alright too. */ #include "SYS.h" ENTRY(sigaction) la $a3, sigtramp # arg4: address of sigtramp .set noreorder syscall SYS_sigaction lui $t1, %hi(errno) # return here on error sw $t0, %lo(errno)($t1) .set reorder jr $ra # return here on success /* * sigtramp - Signal "Trampoline Code" * * This code is transfered to by the kernel when a signal is delivered to a * process. In general, the idea is that sigtramp saves the process' register * context and then vectors on to the real signal action routine. Upon return * from the signal action routine sigtramp restores the process' register * context and performs a sigreturn. * * In the case of the PDP-11, the kernel will have already saved r0 and r1 for * sigtramp in a sigcontext structure it passes to us. Sigtramp vectors onto * the signal action routine whose address has been left in r0 by the kernel * (sigtramp assumes the signal action routine will save any other registers * it uses (as all C routines will)). Upon return from the signal action * routine, sigtramp will execute a sigreturn with the sigcontext structure * given to us by the kernel. * * When the kernel transfers control to sigtramp the stack looks like: * * ------------------------- * | sigcontext structure | SIG_SC = sp + 8 * |-----------------------| * | unused | * |-----------------------| * | $a2: ptr to sigcontext| * |-----------------------| * | $a1: code | * |-----------------------| *sp -> | $a0: signal number | * ------------------------- * * The important features of this as far as sigtramp is concerned are: * 1. The fact that the signal number, signal code, and signal context * pointer are already set up as parameters to the signal action * routine. * 2. There's no need to save r0 & r1 because the kernel's already saved * them for us in the sigcontext structure (C routines save all * registers except r0 & r1 automatically). * * Note that the stack offset SIG_SC will NOT have to be recomputed if the * sigcontext structure changes. */ sigtramp: syscall SYS_sigreturn # attempt the sigreturn syscall SYS_exit # die if the sigreturn fails ... ================================================ FILE: lib/libc/net/Makefile ================================================ # # Copyright (c) 1988 Regents of the University of California. # All rights reserved. # # Redistribution and use in source and binary forms are permitted # provided that this notice is preserved and that due credit is given # to the University of California at Berkeley. The name of the University # may not be used to endorse or promote products derived from this # software without specific prior written permission. This software # is provided ``as is'' without express or implied warranty. # # @(#)Makefile 5.16 (Berkeley) 3/14/88 # SRCS= getnbyaddr.c getnbyname.c getnent.c getpent.c getpname.c \ getproto.c getsbyname.c getsbyport.c getsent.c herror.c \ rcmd.c res_comp.c res_debug.c res_init.c res_mkquery.c \ res_query.c res_send.c \ rexec.c ruserpass.c OBJS= getnbyaddr.o getnbyname.o getnent.o getpent.o getpname.o \ getproto.o getsbyname.o getsbyport.o getsent.o rcmd.o herror.o \ rcmd.o res_comp.o res_debug.o res_init.o res_mkquery.o \ res_query.o res_send.o rexec.o ruserpass.o CFLAGS+= ${DEFS} TAGSFILE=tags .c.o: ${CC} -p -c ${CFLAGS} $*.c -ld -X -r $*.o mv a.out profiled/$*.o ${CC} ${CFLAGS} -c $*.c -ld -x -r $*.o mv a.out $*.o netlib netlib_p: ${OBJS} @echo "building profiled netlib" @cd profiled; ${AR} cr ../netlib_p ${OBJS} @echo "building normal netlib" @${AR} cr netlib ${OBJS} tags: cwd=`pwd`; \ for i in ${SRCS}; do \ ctags -a -f ${TAGSFILE} $$cwd/$$i; \ done clean: rm -f *.o profiled/*.o errs a.out core netlib netlib_p tags depend: mkdep ${CFLAGS} ${SRCS} # DO NOT DELETE THIS LINE -- mkdep uses it. # DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY. getnbyaddr.o: getnbyaddr.c /usr/include/netdb.h getnbyname.o: getnbyname.c /usr/include/netdb.h getnent.o: getnent.c /usr/include/stdio.h /usr/include/sys/types.h getnent.o: /usr/include/sys/socket.h /usr/include/arpa/inet.h getnent.o: /usr/include/netdb.h /usr/include/ctype.h getpent.o: getpent.c /usr/include/stdio.h /usr/include/sys/types.h getpent.o: /usr/include/sys/socket.h /usr/include/netdb.h /usr/include/ctype.h getpname.o: getpname.c /usr/include/netdb.h getproto.o: getproto.c /usr/include/netdb.h getsbyname.o: getsbyname.c /usr/include/netdb.h getsbyport.o: getsbyport.c /usr/include/netdb.h getsent.o: getsent.c /usr/include/stdio.h /usr/include/sys/types.h getsent.o: /usr/include/sys/socket.h /usr/include/netinet/in.h getsent.o: /usr/include/netdb.h /usr/include/ctype.h herror.o: herror.c /usr/include/sys/types.h /usr/include/sys/uio.h rcmd.o: rcmd.c /usr/include/stdio.h /usr/include/ctype.h /usr/include/pwd.h rcmd.o: /usr/include/sys/param.h /usr/include/sys/localopts.h rcmd.o: /usr/include/machine/machparam.h /usr/include/sys/types.h rcmd.o: /usr/include/signal.h /usr/include/sys/types.h /usr/include/sys/file.h rcmd.o: /usr/include/sys/signal.h /usr/include/sys/socket.h rcmd.o: /usr/include/sys/stat.h /usr/include/netinet/in.h /usr/include/netdb.h rcmd.o: /usr/include/errno.h res_comp.o: res_comp.c /usr/include/sys/types.h /usr/include/stdio.h res_comp.o: /usr/include/arpa/nameser.h res_debug.o: res_debug.c /usr/include/sys/types.h /usr/include/netinet/in.h res_debug.o: /usr/include/stdio.h /usr/include/arpa/nameser.h res_init.o: res_init.c /usr/include/sys/types.h /usr/include/sys/socket.h res_init.o: /usr/include/netinet/in.h /usr/include/stdio.h res_init.o: /usr/include/arpa/nameser.h /usr/include/resolv.h res_mkquery.o: res_mkquery.c /usr/include/stdio.h /usr/include/sys/types.h res_mkquery.o: /usr/include/netinet/in.h /usr/include/arpa/nameser.h res_mkquery.o: /usr/include/resolv.h res_query.o: res_query.c /usr/include/sys/param.h /usr/include/sys/localopts.h res_query.o: /usr/include/machine/machparam.h /usr/include/sys/types.h res_query.o: /usr/include/signal.h /usr/include/sys/types.h res_query.o: /usr/include/sys/socket.h /usr/include/netinet/in.h res_query.o: /usr/include/ctype.h /usr/include/netdb.h /usr/include/stdio.h res_query.o: /usr/include/errno.h /usr/include/strings.h res_query.o: /usr/include/arpa/inet.h /usr/include/arpa/nameser.h res_query.o: /usr/include/resolv.h res_send.o: res_send.c /usr/include/sys/param.h /usr/include/sys/localopts.h res_send.o: /usr/include/machine/machparam.h /usr/include/sys/types.h res_send.o: /usr/include/signal.h /usr/include/sys/types.h res_send.o: /usr/include/sys/time.h /usr/include/time.h res_send.o: /usr/include/sys/socket.h /usr/include/sys/uio.h res_send.o: /usr/include/netinet/in.h /usr/include/stdio.h /usr/include/errno.h res_send.o: /usr/include/arpa/nameser.h /usr/include/resolv.h rexec.o: rexec.c /usr/include/sys/types.h /usr/include/sys/socket.h rexec.o: /usr/include/netinet/in.h /usr/include/stdio.h /usr/include/netdb.h rexec.o: /usr/include/errno.h ruserpass.o: ruserpass.c /usr/include/stdio.h /usr/include/utmp.h ruserpass.o: /usr/include/ctype.h /usr/include/sys/types.h ruserpass.o: /usr/include/sys/stat.h /usr/include/errno.h # IF YOU PUT ANYTHING HERE IT WILL GO AWAY ================================================ FILE: lib/libc/net/getnbyaddr.c ================================================ /* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)getnetbyaddr.c 5.3 (Berkeley) 5/19/86"; #endif LIBC_SCCS and not lint #include extern int _net_stayopen; struct netent * getnetbyaddr(net, type) register long net; register int type; { register struct netent *p; setnetent(_net_stayopen); while (p = getnetent()) if (p->n_addrtype == type && p->n_net == net) break; if (!_net_stayopen) endnetent(); return (p); } ================================================ FILE: lib/libc/net/getnbyname.c ================================================ /* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)getnetbyname.c 5.3 (Berkeley) 5/19/86"; #endif LIBC_SCCS and not lint #include extern int _net_stayopen; struct netent * getnetbyname(name) register char *name; { register struct netent *p; register char **cp; setnetent(_net_stayopen); while (p = getnetent()) { if (strcmp(p->n_name, name) == 0) break; for (cp = p->n_aliases; *cp != 0; cp++) if (strcmp(*cp, name) == 0) goto found; } found: if (!_net_stayopen) endnetent(); return (p); } ================================================ FILE: lib/libc/net/getnent.c ================================================ /* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)getnetent.c 5.3 (Berkeley) 5/19/86"; #endif LIBC_SCCS and not lint #include #include #include #include #include #include #define MAXALIASES 35 static char NETDB[] = "/etc/networks"; static FILE *netf = NULL; static char line[256+1]; static struct netent net; static char *net_aliases[MAXALIASES]; int _net_stayopen; static char *any(); setnetent(f) int f; { if (netf == NULL) netf = fopen(NETDB, "r" ); else rewind(netf); _net_stayopen |= f; } endnetent() { if (netf) { fclose(netf); netf = NULL; } _net_stayopen = 0; } struct netent * getnetent() { char *p; register char *cp, **q; if (netf == NULL && (netf = fopen(NETDB, "r" )) == NULL) return (NULL); again: p = fgets(line, sizeof(line)-1, netf); if (p == NULL) return (NULL); if (*p == '#') goto again; cp = any(p, "#\n"); if (cp == NULL) goto again; *cp = '\0'; net.n_name = p; cp = any(p, " \t"); if (cp == NULL) goto again; *cp++ = '\0'; while (*cp == ' ' || *cp == '\t') cp++; p = any(cp, " \t"); if (p != NULL) *p++ = '\0'; net.n_net = inet_network(cp); net.n_addrtype = AF_INET; q = net.n_aliases = net_aliases; if (p != NULL) cp = p; while (cp && *cp) { if (*cp == ' ' || *cp == '\t') { cp++; continue; } if (q < &net_aliases[MAXALIASES - 1]) *q++ = cp; cp = any(cp, " \t"); if (cp != NULL) *cp++ = '\0'; } *q = NULL; return (&net); } static char * any(cp, match) register char *cp; char *match; { register char *mp, c; while (c = *cp) { for (mp = match; *mp; mp++) if (*mp == c) return (cp); cp++; } return ((char *)0); } ================================================ FILE: lib/libc/net/getpent.c ================================================ /* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)getprotoent.c 5.3 (Berkeley) 5/19/86"; #endif LIBC_SCCS and not lint #include #include #include #include #include #define MAXALIASES 35 static char PROTODB[] = "/etc/protocols"; static FILE *protof = NULL; static char line[256+1]; static struct protoent proto; static char *proto_aliases[MAXALIASES]; static char *any(); int _proto_stayopen; setprotoent(f) int f; { if (protof == NULL) protof = fopen(PROTODB, "r" ); else rewind(protof); _proto_stayopen |= f; } endprotoent() { if (protof) { fclose(protof); protof = NULL; } _proto_stayopen = 0; } struct protoent * getprotoent() { char *p; register char *cp, **q; if (protof == NULL && (protof = fopen(PROTODB, "r" )) == NULL) return (NULL); again: if ((p = fgets(line, sizeof(line)-1, protof)) == NULL) return (NULL); if (*p == '#') goto again; cp = any(p, "#\n"); if (cp == NULL) goto again; *cp = '\0'; proto.p_name = p; cp = any(p, " \t"); if (cp == NULL) goto again; *cp++ = '\0'; while (*cp == ' ' || *cp == '\t') cp++; p = any(cp, " \t"); if (p != NULL) *p++ = '\0'; proto.p_proto = atoi(cp); q = proto.p_aliases = proto_aliases; if (p != NULL) { cp = p; while (cp && *cp) { if (*cp == ' ' || *cp == '\t') { cp++; continue; } if (q < &proto_aliases[MAXALIASES - 1]) *q++ = cp; cp = any(cp, " \t"); if (cp != NULL) *cp++ = '\0'; } } *q = NULL; return (&proto); } static char * any(cp, match) register char *cp; char *match; { register char *mp, c; while (c = *cp) { for (mp = match; *mp; mp++) if (*mp == c) return (cp); cp++; } return ((char *)0); } ================================================ FILE: lib/libc/net/getpname.c ================================================ /* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)getprotoname.c 5.3 (Berkeley) 5/19/86"; #endif LIBC_SCCS and not lint #include extern int _proto_stayopen; struct protoent * getprotobyname(name) register char *name; { register struct protoent *p; register char **cp; setprotoent(_proto_stayopen); while (p = getprotoent()) { if (strcmp(p->p_name, name) == 0) break; for (cp = p->p_aliases; *cp != 0; cp++) if (strcmp(*cp, name) == 0) goto found; } found: if (!_proto_stayopen) endprotoent(); return (p); } ================================================ FILE: lib/libc/net/getproto.c ================================================ /* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)getproto.c 5.3 (Berkeley) 5/19/86"; #endif LIBC_SCCS and not lint #include extern int _proto_stayopen; struct protoent * getprotobynumber(proto) register int proto; { register struct protoent *p; setprotoent(_proto_stayopen); while (p = getprotoent()) if (p->p_proto == proto) break; if (!_proto_stayopen) endprotoent(); return (p); } ================================================ FILE: lib/libc/net/getsbyname.c ================================================ /* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)getservbyname.c 5.3 (Berkeley) 5/19/86"; #endif LIBC_SCCS and not lint #include extern int _serv_stayopen; struct servent * getservbyname(name, proto) char *name, *proto; { register struct servent *p; register char **cp; setservent(_serv_stayopen); while (p = getservent()) { if (strcmp(name, p->s_name) == 0) goto gotname; for (cp = p->s_aliases; *cp; cp++) if (strcmp(name, *cp) == 0) goto gotname; continue; gotname: if (proto == 0 || strcmp(p->s_proto, proto) == 0) break; } if (!_serv_stayopen) endservent(); return (p); } ================================================ FILE: lib/libc/net/getsbyport.c ================================================ /* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)getservbyport.c 5.3 (Berkeley) 5/19/86"; #endif LIBC_SCCS and not lint #include extern int _serv_stayopen; struct servent * getservbyport(port, proto) int port; char *proto; { register struct servent *p; setservent(_serv_stayopen); while (p = getservent()) { if (p->s_port != port) continue; if (proto == 0 || strcmp(p->s_proto, proto) == 0) break; } if (!_serv_stayopen) endservent(); return (p); } ================================================ FILE: lib/libc/net/getsent.c ================================================ /* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)getservent.c 5.3.1 (2.11BSD GTE) 6/27/94"; #endif LIBC_SCCS and not lint #include #include #include #include #include #include #define MAXALIASES 16 static char SERVDB[] = "/etc/services"; static FILE *servf = NULL; static char line[160+1]; static struct servent serv; static char *serv_aliases[MAXALIASES]; static char *any(); int _serv_stayopen; setservent(f) int f; { if (servf == NULL) servf = fopen(SERVDB, "r" ); else rewind(servf); _serv_stayopen |= f; } endservent() { if (servf) { fclose(servf); servf = NULL; } _serv_stayopen = 0; } struct servent * getservent() { char *p; register char *cp, **q; if (servf == NULL && (servf = fopen(SERVDB, "r" )) == NULL) return (NULL); again: if ((p = fgets(line, sizeof(line)-1, servf)) == NULL) return (NULL); if (*p == '#') goto again; cp = any(p, "#\n"); if (cp == NULL) goto again; *cp = '\0'; serv.s_name = p; p = any(p, " \t"); if (p == NULL) goto again; *p++ = '\0'; while (*p == ' ' || *p == '\t') p++; cp = any(p, ",/"); if (cp == NULL) goto again; *cp++ = '\0'; serv.s_port = htons((u_short)atoi(p)); serv.s_proto = cp; q = serv.s_aliases = serv_aliases; cp = any(cp, " \t"); if (cp != NULL) *cp++ = '\0'; while (cp && *cp) { if (*cp == ' ' || *cp == '\t') { cp++; continue; } if (q < &serv_aliases[MAXALIASES - 1]) *q++ = cp; cp = any(cp, " \t"); if (cp != NULL) *cp++ = '\0'; } *q = NULL; return (&serv); } static char * any(cp, match) register char *cp; char *match; { register char *mp, c; while (c = *cp) { for (mp = match; *mp; mp++) if (*mp == c) return (cp); cp++; } return ((char *)0); } ================================================ FILE: lib/libc/net/herror.c ================================================ /* * Copyright (c) 1987 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)herror.c 6.1 (Berkeley) 12/4/87"; #endif LIBC_SCCS and not lint #include #include char *h_errlist[] = { "Error 0", "Unknown host", /* 1 HOST_NOT_FOUND */ "Host name lookup failure", /* 2 TRY_AGAIN */ "Unknown server error", /* 3 NO_RECOVERY */ "No address associated with name", /* 4 NO_ADDRESS */ }; int h_nerr = { sizeof(h_errlist)/sizeof(h_errlist[0]) }; extern int h_errno; /* * herror -- * print the error indicated by the h_errno value. */ herror(s) char *s; { struct iovec iov[4]; register struct iovec *v = iov; if (s && *s) { v->iov_base = s; v->iov_len = strlen(s); v++; v->iov_base = ": "; v->iov_len = 2; v++; } v->iov_base = h_errno < h_nerr ? h_errlist[h_errno] : "Unknown error"; v->iov_len = strlen(v->iov_base); v++; v->iov_base = "\n"; v->iov_len = 1; writev(2, iov, (v - iov) + 1); } ================================================ FILE: lib/libc/net/hosttable/Makefile ================================================ # # Copyright (c) 1983 Regents of the University of California. # All rights reserved. The Berkeley software License Agreement # specifies the terms and conditions for redistribution. # # @(#)Makefile 5.4 (Berkeley) 9/5/85 # OBJS= gethnamadr.o gethostent.o SRCS= gethnamadr.c gethostent.c CFLAGS+=-O ${DEFS} .c.o: ${CC} -p -c ${CFLAGS} $*.c -ld -X -r $*.o mv a.out profiled/$*.o ${CC} ${CFLAGS} -c $*.c -ld -x -r $*.o mv a.out $*.o hostlib hostlib_p: ${OBJS} @echo "building profiled hostlib" @cd profiled; ${AR} cr ../hostlib_p ${OBJS} @echo "building normal netlib" @${AR} cr hostlib ${OBJS} tags: cwd=`pwd`; \ for i in ${SRCS}; do \ ctags -a -f ${TAGSFILE} $$cwd/$$i; \ done clean: rm -f *.o errs a.out core hostlib hostlib_p profiled/*.o \ tags Makefile.bak depend: for i in ${SRCS}; do \ cc -M ${CFLAGS} $$i | awk ' { if ($$1 != prev) \ { if (rec != "") print rec; rec = $$0; prev = $$1; } \ else { if (length(rec $$2) > 78) { print rec; rec = $$0; } \ else rec = rec " " $$2 } } \ END { print rec } ' >> makedep; done echo '/^# DO NOT DELETE THIS LINE/+2,$$d' >eddep echo '$$r makedep' >>eddep echo 'w' >>eddep cp Makefile Makefile.bak ed - Makefile < eddep rm eddep makedep echo '# DEPENDENCIES MUST END AT END OF FILE' >> Makefile echo '# IF YOU PUT STUFF HERE IT WILL GO AWAY' >> Makefile echo '# see make depend above' >> Makefile # DO NOT DELETE THIS LINE -- make depend uses it ================================================ FILE: lib/libc/net/hosttable/gethnamadr.c ================================================ /* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)gethostnamadr.c 5.5 (Berkeley) 3/9/86"; #endif LIBC_SCCS and not lint #include #include #include #include #include #include #define MAXALIASES 20 #define MAXADDRS 10 static struct hostent host; static char hostbuf[256]; static char *host_aliases[MAXALIASES]; static char *host_addrs[MAXADDRS]; int h_errno; /* * The following is shared with gethostent.c */ extern char *_host_file; DBM *_host_db = (DBM *)NULL; int _host_stayopen; /* set by sethostent(), cleared by endhostent() */ static struct hostent * fetchhost(key) datum key; { register char *cp, *tp, **ap; int naliases, naddrs; if (key.dptr == 0) return ((struct hostent *)NULL); key = dbm_fetch(_host_db, key); if (key.dptr == 0) return ((struct hostent *)NULL); cp = key.dptr; tp = hostbuf; host.h_name = tp; while (*tp++ = *cp++) ; bcopy(cp, (char *)&naliases, sizeof(int)); cp += sizeof (int); for (ap = host_aliases; naliases > 0; naliases--) { *ap++ = tp; while (*tp++ = *cp++) ; } *ap = (char *)NULL; host.h_aliases = host_aliases; bcopy(cp, (char *)&host.h_addrtype, sizeof (int)); cp += sizeof (int); bcopy(cp, (char *)&host.h_length, sizeof (int)); cp += sizeof (int); host.h_addr_list = host_addrs; naddrs = (key.dsize - (cp - key.dptr)) / host.h_length; if (naddrs > MAXADDRS) naddrs = MAXADDRS; for (ap = host_addrs; naddrs; naddrs--) { *ap++ = tp; bcopy(cp, tp, host.h_length); cp += host.h_length; tp += host.h_length; } *ap = (char *)NULL; return (&host); } struct hostent * gethostbyname(nam) register char *nam; { register struct hostent *hp; register char **cp; datum key; char lowname[128]; register char *lp = lowname; while (*nam) if (isupper(*nam)) *lp++ = tolower(*nam++); else *lp++ = *nam++; *lp = '\0'; if ((_host_db == (DBM *)NULL) && ((_host_db = dbm_open(_host_file, O_RDONLY)) == (DBM *)NULL)) { sethostent(_host_stayopen); while (hp = gethostent()) { if (strcmp(hp->h_name, lowname) == 0) break; for (cp = hp->h_aliases; cp != 0 && *cp != 0; cp++) if (strcmp(*cp, lowname) == 0) goto found; } found: if (!_host_stayopen) endhostent(); return (hp); } key.dptr = lowname; key.dsize = strlen(lowname); hp = fetchhost(key); if (!_host_stayopen) { dbm_close(_host_db); _host_db = (DBM *)NULL; } if ( hp == NULL) h_errno = HOST_NOT_FOUND; return (hp); } struct hostent * gethostbyaddr(addr, length, type) char *addr; register int length; register int type; { register struct hostent *hp; datum key; if ((_host_db == (DBM *)NULL) && ((_host_db = dbm_open(_host_file, O_RDONLY)) == (DBM *)NULL)) { sethostent(_host_stayopen); while (hp = gethostent()) { if (hp->h_addrtype == type && hp->h_length == length && bcmp(hp->h_addr, addr, length) == 0) break; } if (!_host_stayopen) endhostent(); if ( hp == NULL) h_errno = HOST_NOT_FOUND; return (hp); } key.dptr = addr; key.dsize = length; hp = fetchhost(key); if (!_host_stayopen) { dbm_close(_host_db); _host_db = (DBM *)NULL; } if ( hp == NULL) h_errno = HOST_NOT_FOUND; return (hp); } ================================================ FILE: lib/libc/net/hosttable/gethostent.c ================================================ /* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)gethostent.c 5.3 (Berkeley) 3/9/86"; #endif LIBC_SCCS and not lint #include #include #include #include #include #include #include /* * Internet version. */ #define MAXALIASES 20 #define MAXADDRSIZE (sizeof (u_long)) static FILE *hostf = NULL; static char line[160+1]; static char hostaddr[MAXADDRSIZE]; static struct hostent host; static char *host_aliases[MAXALIASES]; static char *host_addrs[] = { hostaddr, NULL }; /* * The following is shared with gethostnamadr.c */ char *_host_file = "/etc/hosts"; int _host_stayopen; DBM *_host_db; /* set by gethostbyname(), gethostbyaddr() */ static char *any(); sethostent(f) int f; { if (hostf != NULL) rewind(hostf); _host_stayopen |= f; } endhostent() { if (hostf) { fclose(hostf); hostf = NULL; } if (_host_db) { dbm_close(_host_db); _host_db = (DBM *)NULL; } _host_stayopen = 0; } struct hostent * gethostent() { char *p; register char *cp, **q; if (hostf == NULL && (hostf = fopen(_host_file, "r" )) == NULL) return (NULL); again: if ((p = fgets(line, sizeof(line)-1, hostf)) == NULL) return (NULL); if (*p == '#') goto again; cp = any(p, "#\n"); if (cp == NULL) goto again; *cp = '\0'; cp = any(p, " \t"); if (cp == NULL) goto again; *cp++ = '\0'; /* THIS STUFF IS INTERNET SPECIFIC */ host.h_addr_list = host_addrs; *((u_long *)host.h_addr) = inet_addr(p); host.h_length = sizeof (u_long); host.h_addrtype = AF_INET; while (*cp == ' ' || *cp == '\t') cp++; host.h_name = cp; q = host.h_aliases = host_aliases; cp = any(cp, " \t"); if (cp != NULL) *cp++ = '\0'; while (cp && *cp) { if (*cp == ' ' || *cp == '\t') { cp++; continue; } if (q < &host_aliases[MAXALIASES - 1]) *q++ = cp; cp = any(cp, " \t"); if (cp != NULL) *cp++ = '\0'; } *q = NULL; return (&host); } sethostfile(file) char *file; { _host_file = file; } static char * any(cp, match) register char *cp; char *match; { register char *mp, c; while (c = *cp) { for (mp = match; *mp; mp++) if (*mp == c) return (cp); cp++; } return ((char *)0); } ================================================ FILE: lib/libc/net/named/Makefile ================================================ # # Copyright (c) 1983 Regents of the University of California. # All rights reserved. The Berkeley software License Agreement # specifies the terms and conditions for redistribution. # # @(#)Makefile 6.4 (Berkeley) 6/6/87 # OBJS= gethnamadr.o sethostent.o SRCS= gethnamadr.c sethostent.c CFLAGS+=-O ${DEFS} TAGSFILE= tags .c.o: ${CC} -p -c ${CFLAGS} $*.c -ld -X -r $*.o mv a.out profiled/$*.o ${CC} ${CFLAGS} -c $*.c -ld -x -r $*.o mv a.out $*.o hostlib hostlib_p: ${OBJS} @echo "building profiled hostlib" @cd profiled; ${AR} cr ../hostlib_p ${OBJS} @echo "building normal hostlib" @${AR} cr hostlib ${OBJS} tags: cwd=`pwd`; \ for i in ${SRCS}; do \ ctags -a -f ${TAGSFILE} $$cwd/$$i; \ done clean: rm -f *.o errs a.out core hostlib hostlib_p profiled/*.o tags depend: mkdep ${CFLAGS} ${SRCS} # DO NOT DELETE THIS LINE -- mkdep uses it. # DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY. gethnamadr.o: gethnamadr.c /usr/include/sys/param.h gethnamadr.o: /usr/include/sys/localopts.h /usr/include/machine/machparam.h gethnamadr.o: /usr/include/sys/types.h /usr/include/signal.h gethnamadr.o: /usr/include/sys/types.h /usr/include/sys/socket.h gethnamadr.o: /usr/include/netinet/in.h /usr/include/ctype.h gethnamadr.o: /usr/include/netdb.h /usr/include/stdio.h /usr/include/errno.h gethnamadr.o: /usr/include/arpa/inet.h /usr/include/arpa/nameser.h gethnamadr.o: /usr/include/resolv.h sethostent.o: sethostent.c /usr/include/sys/types.h /usr/include/arpa/nameser.h sethostent.o: /usr/include/netinet/in.h /usr/include/resolv.h # IF YOU PUT ANYTHING HERE IT WILL GO AWAY ================================================ FILE: lib/libc/net/named/gethnamadr.c ================================================ /* * Copyright (c) 1985, 1988 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that this notice is preserved and that due credit is given * to the University of California at Berkeley. The name of the University * may not be used to endorse or promote products derived from this * software without specific prior written permission. This software * is provided ``as is'' without express or implied warranty. */ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)gethostnamadr.c 6.31.2 (2.11BSD GTE) 6/27/94"; #endif /* LIBC_SCCS and not lint */ #include #include #include #include #include #include #include #include #include #include #define MAXALIASES 16 #define MAXADDRS 16 static char *h_addr_ptrs[MAXADDRS + 1]; static struct hostent host; static char *host_aliases[MAXALIASES]; static char hostbuf[256+1]; static struct in_addr host_addr; static char HOSTDB[] = "/etc/hosts"; static FILE *hostf = NULL; static char hostaddr[MAXADDRS]; static char *host_addrs[2]; static int stayopen = 0; static char *any(); #if PACKETSZ > 1024 #define MAXPACKET PACKETSZ #else #define MAXPACKET 1024 #endif typedef union { HEADER hdr; u_char buf[MAXPACKET]; } querybuf; static union { long al; char ac; } align; int h_errno; extern errno; static struct hostent * getanswer(answer, anslen, iquery) querybuf *answer; int anslen; int iquery; { register HEADER *hp; register u_char *cp; register int n; u_char *eom; char *bp, **ap; int type, class, buflen, ancount, qdcount; int haveanswer, getclass = C_ANY; char **hap; eom = answer->buf + anslen; /* * find first satisfactory answer */ hp = &answer->hdr; ancount = ntohs(hp->ancount); qdcount = ntohs(hp->qdcount); bp = hostbuf; buflen = sizeof(hostbuf); cp = answer->buf + sizeof(HEADER); if (qdcount) { if (iquery) { if ((n = dn_expand((char *)answer->buf, eom, cp, bp, buflen)) < 0) { h_errno = NO_RECOVERY; return ((struct hostent *) NULL); } cp += n + QFIXEDSZ; host.h_name = bp; n = strlen(bp) + 1; bp += n; buflen -= n; } else cp += dn_skipname(cp, eom) + QFIXEDSZ; while (--qdcount > 0) cp += dn_skipname(cp, eom) + QFIXEDSZ; } else if (iquery) { if (hp->aa) h_errno = HOST_NOT_FOUND; else h_errno = TRY_AGAIN; return ((struct hostent *) NULL); } ap = host_aliases; host.h_aliases = host_aliases; hap = h_addr_ptrs; #if BSD >= 43 || defined(h_addr) /* new-style hostent structure */ host.h_addr_list = h_addr_ptrs; #endif haveanswer = 0; while (--ancount >= 0 && cp < eom) { if ((n = dn_expand((char *)answer->buf, eom, cp, bp, buflen)) < 0) break; cp += n; type = _getshort(cp); cp += sizeof(u_short); class = _getshort(cp); cp += sizeof(u_short) + sizeof(u_long); n = _getshort(cp); cp += sizeof(u_short); if (type == T_CNAME) { cp += n; if (ap >= &host_aliases[MAXALIASES-1]) continue; *ap++ = bp; n = strlen(bp) + 1; bp += n; buflen -= n; continue; } if (iquery && type == T_PTR) { if ((n = dn_expand((char *)answer->buf, eom, cp, bp, buflen)) < 0) { cp += n; continue; } cp += n; host.h_name = bp; return(&host); } if (iquery || type != T_A) { #ifdef DEBUG if (_res.options & RES_DEBUG) printf("unexpected answer type %d, size %d\n", type, n); #endif cp += n; continue; } if (haveanswer) { if (n != host.h_length) { cp += n; continue; } if (class != getclass) { cp += n; continue; } } else { host.h_length = n; getclass = class; host.h_addrtype = (class == C_IN) ? AF_INET : AF_UNSPEC; if (!iquery) { host.h_name = bp; bp += strlen(bp) + 1; } } bp += sizeof(align) - ((u_long)bp % sizeof(align)); if (bp + n >= &hostbuf[sizeof(hostbuf)]) { #ifdef DEBUG if (_res.options & RES_DEBUG) printf("size (%d) too big\n", n); #endif break; } bcopy(cp, *hap++ = bp, n); bp +=n; cp += n; haveanswer++; } if (haveanswer) { *ap = NULL; #if BSD >= 43 || defined(h_addr) /* new-style hostent structure */ *hap = NULL; #else host.h_addr = h_addr_ptrs[0]; #endif return (&host); } else { h_errno = TRY_AGAIN; return ((struct hostent *) NULL); } } struct hostent * gethostbyname(name) char *name; { querybuf buf; register char *cp; int n; struct hostent *hp, *gethostdomain(); extern struct hostent *_gethtbyname(); /* * disallow names consisting only of digits/dots, unless * they end in a dot. */ if (isdigit(name[0])) for (cp = name;; ++cp) { if (!*cp) { if (*--cp == '.') break; h_errno = HOST_NOT_FOUND; return ((struct hostent *) NULL); } if (!isdigit(*cp) && *cp != '.') break; } if ((n = res_search(name, C_IN, T_A, buf.buf, sizeof(buf))) < 0) { #ifdef DEBUG if (_res.options & RES_DEBUG) printf("res_search failed\n"); #endif if (errno == ECONNREFUSED) return (_gethtbyname(name)); else return ((struct hostent *) NULL); } return (getanswer(&buf, n, 0)); } struct hostent * gethostbyaddr(addr, len, type) char *addr; int len, type; { int n; querybuf buf; register struct hostent *hp; char qbuf[MAXDNAME]; extern struct hostent *_gethtbyaddr(); if (type != AF_INET) return ((struct hostent *) NULL); (void)sprintf(qbuf, "%d.%d.%d.%d.in-addr.arpa", ((unsigned)addr[3] & 0xff), ((unsigned)addr[2] & 0xff), ((unsigned)addr[1] & 0xff), ((unsigned)addr[0] & 0xff)); n = res_query(qbuf, C_IN, T_PTR, (char *)&buf, sizeof(buf)); if (n < 0) { #ifdef DEBUG if (_res.options & RES_DEBUG) printf("res_query failed\n"); #endif if (errno == ECONNREFUSED) hp = _gethtbyaddr(addr, len, type); return ((struct hostent *) NULL); } hp = getanswer(&buf, n, 1); if (hp == NULL) return ((struct hostent *) NULL); hp->h_addrtype = type; hp->h_length = len; h_addr_ptrs[0] = (char *)&host_addr; h_addr_ptrs[1] = (char *)0; host_addr = *(struct in_addr *)addr; return(hp); } _sethtent(f) int f; { if (hostf == NULL) hostf = fopen(HOSTDB, "r" ); else rewind(hostf); stayopen |= f; } _endhtent() { if (hostf && !stayopen) { (void) fclose(hostf); hostf = NULL; } } struct hostent * _gethtent() { char *p; register char *cp, **q; if (hostf == NULL && (hostf = fopen(HOSTDB, "r" )) == NULL) return (NULL); again: if ((p = fgets(hostbuf, sizeof(hostbuf)-1, hostf)) == NULL) return (NULL); if (*p == '#') goto again; cp = any(p, "#\n"); if (cp == NULL) goto again; *cp = '\0'; cp = any(p, " \t"); if (cp == NULL) goto again; *cp++ = '\0'; /* THIS STUFF IS INTERNET SPECIFIC */ #if BSD >= 43 || defined(h_addr) /* new-style hostent structure */ host.h_addr_list = host_addrs; #endif host.h_addr = hostaddr; *((u_long *)host.h_addr) = inet_addr(p); host.h_length = sizeof (u_long); host.h_addrtype = AF_INET; while (*cp == ' ' || *cp == '\t') cp++; host.h_name = cp; q = host.h_aliases = host_aliases; cp = any(cp, " \t"); if (cp != NULL) *cp++ = '\0'; while (cp && *cp) { if (*cp == ' ' || *cp == '\t') { cp++; continue; } if (q < &host_aliases[MAXALIASES - 1]) *q++ = cp; cp = any(cp, " \t"); if (cp != NULL) *cp++ = '\0'; } *q = NULL; return (&host); } static char * any(cp, match) register char *cp; char *match; { register char *mp, c; while (c = *cp) { for (mp = match; *mp; mp++) if (*mp == c) return (cp); cp++; } return ((char *)0); } struct hostent * _gethtbyname(name) char *name; { register struct hostent *p; register char **cp; _sethtent(0); while (p = _gethtent()) { if (strcasecmp(p->h_name, name) == 0) break; for (cp = p->h_aliases; *cp != 0; cp++) if (strcasecmp(*cp, name) == 0) goto found; } found: _endhtent(); return (p); } struct hostent * _gethtbyaddr(addr, len, type) char *addr; int len, type; { register struct hostent *p; _sethtent(0); while (p = _gethtent()) if (p->h_addrtype == type && !bcmp(p->h_addr, addr, len)) break; _endhtent(); return (p); } ================================================ FILE: lib/libc/net/named/sethostent.c ================================================ /* * Copyright (c) 1985 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)sethostent.c 6.3 (Berkeley) 4/10/86"; #endif LIBC_SCCS and not lint #include #include #include #include sethostent(stayopen) { if (stayopen) _res.options |= RES_STAYOPEN | RES_USEVC; } endhostent() { _res.options &= ~(RES_STAYOPEN | RES_USEVC); _res_close(); } sethostfile(name) char *name; { #ifdef lint name = name; #endif } ================================================ FILE: lib/libc/net/rcmd.c ================================================ /* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the University of California, Berkeley. The name of the * University may not be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)rcmd.c 5.20.1 (2.11BSD) 1999/10/24"; #endif /* LIBC_SCCS and not lint */ #include #include #include #include #include #include #include #include #include #include #include #include rcmd(ahost, rport, locuser, remuser, cmd, fd2p) char **ahost; u_short rport; char *locuser, *remuser, *cmd; int *fd2p; { int s, timo = 1, pid; sigset_t oldmask, nmask; struct sockaddr_in sin, sin2, from; char c; int lport = IPPORT_RESERVED - 1; struct hostent *hp; fd_set reads; pid = getpid(); hp = gethostbyname(*ahost); if (hp == 0) { herror(*ahost); return (-1); } *ahost = hp->h_name; (void)sigemptyset(&nmask); (void)sigaddset(&nmask, SIGURG); (void)sigprocmask(SIG_BLOCK, &nmask, &oldmask); for (;;) { s = rresvport(&lport); if (s < 0) { if (errno == EAGAIN) fprintf(stderr, "socket: All ports in use\n"); else perror("rcmd: socket"); sigprocmask(SIG_SETMASK, &oldmask, NULL); return (-1); } fcntl(s, F_SETOWN, pid); sin.sin_family = hp->h_addrtype; bcopy(hp->h_addr_list[0], (caddr_t)&sin.sin_addr, hp->h_length); sin.sin_port = rport; if (connect(s, (caddr_t)&sin, sizeof (sin), 0) >= 0) break; (void) close(s); if (errno == EADDRINUSE) { lport--; continue; } if (errno == ECONNREFUSED && timo <= 16) { sleep(timo); timo *= 2; continue; } if (hp->h_addr_list[1] != NULL) { int oerrno = errno; fprintf(stderr, "connect to address %s: ", inet_ntoa(sin.sin_addr)); errno = oerrno; perror(0); hp->h_addr_list++; bcopy(hp->h_addr_list[0], (caddr_t)&sin.sin_addr, hp->h_length); fprintf(stderr, "Trying %s...\n", inet_ntoa(sin.sin_addr)); continue; } perror(hp->h_name); sigprocmask(SIG_SETMASK, &oldmask, NULL); return (-1); } lport--; if (fd2p == 0) { write(s, "", 1); lport = 0; } else { char num[8]; int s2 = rresvport(&lport), s3; int len = sizeof (from); if (s2 < 0) goto bad; listen(s2, 1); (void) sprintf(num, "%d", lport); if (write(s, num, strlen(num)+1) != strlen(num)+1) { perror("write: setting up stderr"); (void) close(s2); goto bad; } FD_ZERO(&reads); FD_SET(s, &reads); FD_SET(s2, &reads); errno = 0; if (select(32, &reads, 0, 0, 0) < 1 || !FD_ISSET(s2, &reads)) { if (errno != 0) perror("select: setting up stderr"); else fprintf(stderr, "select: protocol failure in circuit setup.\n"); (void) close(s2); goto bad; } s3 = accept(s2, &from, &len, 0); (void) close(s2); if (s3 < 0) { perror("accept"); lport = 0; goto bad; } *fd2p = s3; from.sin_port = ntohs((u_short)from.sin_port); if (from.sin_family != AF_INET || from.sin_port >= IPPORT_RESERVED || from.sin_port < IPPORT_RESERVED / 2) { fprintf(stderr, "socket: protocol failure in circuit setup.\n"); goto bad2; } } (void) write(s, locuser, strlen(locuser)+1); (void) write(s, remuser, strlen(remuser)+1); (void) write(s, cmd, strlen(cmd)+1); if (read(s, &c, 1) != 1) { perror(*ahost); goto bad2; } if (c != 0) { while (read(s, &c, 1) == 1) { (void) write(2, &c, 1); if (c == '\n') break; } goto bad2; } sigprocmask(SIG_SETMASK, &oldmask, NULL); return (s); bad2: if (lport) (void) close(*fd2p); bad: (void) close(s); sigprocmask(SIG_SETMASK, &oldmask, NULL); return (-1); } rresvport(alport) int *alport; { struct sockaddr_in sin; int s; sin.sin_family = AF_INET; sin.sin_addr.s_addr = INADDR_ANY; s = socket(AF_INET, SOCK_STREAM, 0); if (s < 0) return (-1); for (;;) { sin.sin_port = htons((u_short)*alport); if (bind(s, (caddr_t)&sin, sizeof (sin)) >= 0) return (s); if (errno != EADDRINUSE) { (void) close(s); return (-1); } (*alport)--; if (*alport == IPPORT_RESERVED/2) { (void) close(s); errno = EAGAIN; /* close */ return (-1); } } } int _check_rhosts_file = 1; ruserok(rhost, superuser, ruser, luser) char *rhost; int superuser; char *ruser, *luser; { FILE *hostf; char fhost[MAXHOSTNAMELEN]; int first = 1; register char *sp, *p; int baselen = -1; sp = rhost; p = fhost; while (*sp) { if (*sp == '.') { if (baselen == -1) baselen = sp - rhost; *p++ = *sp++; } else { *p++ = isupper(*sp) ? tolower(*sp++) : *sp++; } } *p = '\0'; hostf = superuser ? (FILE *)0 : fopen("/etc/hosts.equiv", "r"); again: if (hostf) { if (!_validuser(hostf, fhost, luser, ruser, baselen)) { (void) fclose(hostf); return(0); } (void) fclose(hostf); } if (first == 1 && (_check_rhosts_file || superuser)) { struct stat sbuf; struct passwd *pwd; char pbuf[MAXPATHLEN]; first = 0; if ((pwd = getpwnam(luser)) == NULL) return(-1); (void)strcpy(pbuf, pwd->pw_dir); (void)strcat(pbuf, "/.rhosts"); if ((hostf = fopen(pbuf, "r")) == NULL) return(-1); /* * if owned by someone other than user or root or if * writeable by anyone but the owner, quit */ if (fstat(fileno(hostf), &sbuf) || sbuf.st_uid && sbuf.st_uid != pwd->pw_uid || sbuf.st_mode&022) { fclose(hostf); return(-1); } goto again; } return (-1); } /* don't make static, used by lpd(8) */ _validuser(hostf, rhost, luser, ruser, baselen) char *rhost, *luser, *ruser; FILE *hostf; int baselen; { char *user; char ahost[MAXHOSTNAMELEN]; register char *p; while (fgets(ahost, sizeof (ahost), hostf)) { p = ahost; while (*p != '\n' && *p != ' ' && *p != '\t' && *p != '\0') { *p = isupper(*p) ? tolower(*p) : *p; p++; } if (*p == ' ' || *p == '\t') { *p++ = '\0'; while (*p == ' ' || *p == '\t') p++; user = p; while (*p != '\n' && *p != ' ' && *p != '\t' && *p != '\0') p++; } else user = p; *p = '\0'; if (_checkhost(rhost, ahost, baselen) && !strcmp(ruser, *user ? user : luser)) { return (0); } } return (-1); } static _checkhost(rhost, lhost, len) char *rhost, *lhost; int len; { static char ldomain[MAXHOSTNAMELEN + 1]; static char *domainp = NULL; static int nodomain = 0; register char *cp; if (len == -1) return(!strcmp(rhost, lhost)); if (strncmp(rhost, lhost, len)) return(0); if (!strcmp(rhost, lhost)) return(1); if (*(lhost + len) != '\0') return(0); if (nodomain) return(0); if (!domainp) { if (gethostname(ldomain, sizeof(ldomain)) == -1) { nodomain = 1; return(0); } ldomain[MAXHOSTNAMELEN] = NULL; if ((domainp = index(ldomain, '.')) == (char *)NULL) { nodomain = 1; return(0); } for (cp = ++domainp; *cp; ++cp) if (isupper(*cp)) *cp = tolower(*cp); } return(!strcmp(domainp, rhost + len +1)); } ================================================ FILE: lib/libc/net/res_comp.c ================================================ /* * Copyright (c) 1985 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that this notice is preserved and that due credit is given * to the University of California at Berkeley. The name of the University * may not be used to endorse or promote products derived from this * software without specific prior written permission. This software * is provided ``as is'' without express or implied warranty. */ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)res_comp.c 6.13 (Berkeley) 3/13/88"; #endif /* LIBC_SCCS and not lint */ #include #include #include /* * Expand compressed domain name 'comp_dn' to full domain name. * 'msg' is a pointer to the begining of the message, * 'eomorig' points to the first location after the message, * 'exp_dn' is a pointer to a buffer of size 'length' for the result. * Return size of compressed name or -1 if there was an error. */ dn_expand(msg, eomorig, comp_dn, exp_dn, length) u_char *msg, *eomorig, *comp_dn, *exp_dn; int length; { register u_char *cp, *dn; register int n, c; u_char *eom; int len = -1, checked = 0; dn = exp_dn; cp = comp_dn; eom = exp_dn + length - 1; /* * fetch next label in domain name */ while (n = *cp++) { /* * Check for indirection */ switch (n & INDIR_MASK) { case 0: if (dn != exp_dn) { if (dn >= eom) return (-1); *dn++ = '.'; } if (dn+n >= eom) return (-1); checked += n + 1; while (--n >= 0) { if ((c = *cp++) == '.') { if (dn+n+1 >= eom) return (-1); *dn++ = '\\'; } *dn++ = c; if (cp >= eomorig) /* out of range */ return(-1); } break; case INDIR_MASK: if (len < 0) len = cp - comp_dn + 1; cp = msg + (((n & 0x3f) << 8) | (*cp & 0xff)); if (cp < msg || cp >= eomorig) /* out of range */ return(-1); checked += 2; /* * Check for loops in the compressed name; * if we've looked at the whole message, * there must be a loop. */ if (checked >= eomorig - msg) return (-1); break; default: return (-1); /* flag error */ } } *dn = '\0'; if (len < 0) len = cp - comp_dn; return (len); } /* * Compress domain name 'exp_dn' into 'comp_dn'. * Return the size of the compressed name or -1. * 'length' is the size of the array pointed to by 'comp_dn'. * 'dnptrs' is a list of pointers to previous compressed names. dnptrs[0] * is a pointer to the beginning of the message. The list ends with NULL. * 'lastdnptr' is a pointer to the end of the arrary pointed to * by 'dnptrs'. Side effect is to update the list of pointers for * labels inserted into the message as we compress the name. * If 'dnptr' is NULL, we don't try to compress names. If 'lastdnptr' * is NULL, we don't update the list. */ dn_comp(exp_dn, comp_dn, length, dnptrs, lastdnptr) u_char *exp_dn, *comp_dn; int length; u_char **dnptrs, **lastdnptr; { register u_char *cp, *dn; register int c, l; u_char **cpp, **lpp, *sp, *eob; u_char *msg; dn = exp_dn; cp = comp_dn; eob = cp + length; if (dnptrs != NULL) { if ((msg = *dnptrs++) != NULL) { for (cpp = dnptrs; *cpp != NULL; cpp++) ; lpp = cpp; /* end of list to search */ } } else msg = NULL; for (c = *dn++; c != '\0'; ) { /* look to see if we can use pointers */ if (msg != NULL) { if ((l = dn_find(dn-1, msg, dnptrs, lpp)) >= 0) { if (cp+1 >= eob) return (-1); *cp++ = (l >> 8) | INDIR_MASK; *cp++ = l % 256; return (cp - comp_dn); } /* not found, save it */ if (lastdnptr != NULL && cpp < lastdnptr-1) { *cpp++ = cp; *cpp = NULL; } } sp = cp++; /* save ptr to length byte */ do { if (c == '.') { c = *dn++; break; } if (c == '\\') { if ((c = *dn++) == '\0') break; } if (cp >= eob) return (-1); *cp++ = c; } while ((c = *dn++) != '\0'); /* catch trailing '.'s but not '..' */ if ((l = cp - sp - 1) == 0 && c == '\0') { cp--; break; } if (l <= 0 || l > MAXLABEL) return (-1); *sp = l; } if (cp >= eob) return (-1); *cp++ = '\0'; return (cp - comp_dn); } /* * Skip over a compressed domain name. Return the size or -1. */ dn_skipname(comp_dn, eom) u_char *comp_dn, *eom; { register u_char *cp; register int n; cp = comp_dn; while (cp < eom && (n = *cp++)) { /* * check for indirection */ switch (n & INDIR_MASK) { case 0: /* normal case, n == len */ cp += n; continue; default: /* illegal type */ return (-1); case INDIR_MASK: /* indirection */ cp++; } break; } return (cp - comp_dn); } /* * Search for expanded name from a list of previously compressed names. * Return the offset from msg if found or -1. * dnptrs is the pointer to the first name on the list, * not the pointer to the start of the message. */ static dn_find(exp_dn, msg, dnptrs, lastdnptr) u_char *exp_dn, *msg; u_char **dnptrs, **lastdnptr; { register u_char *dn, *cp, **cpp; register int n; u_char *sp; for (cpp = dnptrs; cpp < lastdnptr; cpp++) { dn = exp_dn; sp = cp = *cpp; while (n = *cp++) { /* * check for indirection */ switch (n & INDIR_MASK) { case 0: /* normal case, n == len */ while (--n >= 0) { if (*dn == '\\') dn++; if (*dn++ != *cp++) goto next; } if ((n = *dn++) == '\0' && *cp == '\0') return (sp - msg); if (n == '.') continue; goto next; default: /* illegal type */ return (-1); case INDIR_MASK: /* indirection */ cp = msg + (((n & 0x3f) << 8) | *cp); } } if (*dn == '\0') return (sp - msg); next: ; } return (-1); } /* * Routines to insert/extract short/long's. Must account for byte * order and non-alignment problems. This code at least has the * advantage of being portable. * * used by sendmail. */ u_short _getshort(msgp) u_char *msgp; { register u_char *p = (u_char *) msgp; #ifdef vax /* * vax compiler doesn't put shorts in registers */ register u_long u; #else register u_short u; #endif u = *p++ << 8; return ((u_short)(u | *p)); } u_long _getlong(msgp) u_char *msgp; { register u_char *p = (u_char *) msgp; register u_long u; u = *p++; u <<= 8; u |= *p++; u <<= 8; u |= *p++; u <<= 8; return (u | *p); } putshort(s, msgp) register u_short s; register u_char *msgp; { msgp[1] = s; msgp[0] = s >> 8; } putlong(l, msgp) register u_long l; register u_char *msgp; { msgp[3] = l; msgp[2] = (l >>= 8); msgp[1] = (l >>= 8); msgp[0] = l >> 8; } ================================================ FILE: lib/libc/net/res_debug.c ================================================ /* * Copyright (c) 1985 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that this notice is preserved and that due credit is given * to the University of California at Berkeley. The name of the University * may not be used to endorse or promote products derived from this * software without specific prior written permission. This software * is provided ``as is'' without express or implied warranty. */ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)res_debug.c 5.22 (Berkeley) 3/7/88"; #endif /* LIBC_SCCS and not lint */ #if defined(lint) && !defined(DEBUG) #define DEBUG #endif #include #include #include #include extern char *p_cdname(), *p_rr(), *p_type(), *p_class(); extern char *inet_ntoa(); char *_res_opcodes[] = { "QUERY", "IQUERY", "CQUERYM", "CQUERYU", "4", "5", "6", "7", "8", "UPDATEA", "UPDATED", "UPDATEDA", "UPDATEM", "UPDATEMA", "ZONEINIT", "ZONEREF", }; char *_res_resultcodes[] = { "NOERROR", "FORMERR", "SERVFAIL", "NXDOMAIN", "NOTIMP", "REFUSED", "6", "7", "8", "9", "10", "11", "12", "13", "14", "NOCHANGE", }; p_query(msg) char *msg; { #ifdef DEBUG fp_query(msg,stdout); #endif } /* * Print the contents of a query. * This is intended to be primarily a debugging routine. */ fp_query(msg,file) char *msg; FILE *file; { #ifdef DEBUG register char *cp; register HEADER *hp; register int n; /* * Print header fields. */ hp = (HEADER *)msg; cp = msg + sizeof(HEADER); fprintf(file,"HEADER:\n"); fprintf(file,"\topcode = %s", _res_opcodes[hp->opcode]); fprintf(file,", id = %d", ntohs(hp->id)); fprintf(file,", rcode = %s\n", _res_resultcodes[hp->rcode]); fprintf(file,"\theader flags: "); if (hp->qr) fprintf(file," qr"); if (hp->aa) fprintf(file," aa"); if (hp->tc) fprintf(file," tc"); if (hp->rd) fprintf(file," rd"); if (hp->ra) fprintf(file," ra"); if (hp->pr) fprintf(file," pr"); fprintf(file,"\n\tqdcount = %d", ntohs(hp->qdcount)); fprintf(file,", ancount = %d", ntohs(hp->ancount)); fprintf(file,", nscount = %d", ntohs(hp->nscount)); fprintf(file,", arcount = %d\n\n", ntohs(hp->arcount)); /* * Print question records. */ if (n = ntohs(hp->qdcount)) { fprintf(file,"QUESTIONS:\n"); while (--n >= 0) { fprintf(file,"\t"); cp = p_cdname(cp, msg, file); if (cp == NULL) return; fprintf(file,", type = %s", p_type(_getshort(cp))); cp += sizeof(u_short); fprintf(file,", class = %s\n\n", p_class(_getshort(cp))); cp += sizeof(u_short); } } /* * Print authoritative answer records */ if (n = ntohs(hp->ancount)) { fprintf(file,"ANSWERS:\n"); while (--n >= 0) { fprintf(file,"\t"); cp = p_rr(cp, msg, file); if (cp == NULL) return; } } /* * print name server records */ if (n = ntohs(hp->nscount)) { fprintf(file,"NAME SERVERS:\n"); while (--n >= 0) { fprintf(file,"\t"); cp = p_rr(cp, msg, file); if (cp == NULL) return; } } /* * print additional records */ if (n = ntohs(hp->arcount)) { fprintf(file,"ADDITIONAL RECORDS:\n"); while (--n >= 0) { fprintf(file,"\t"); cp = p_rr(cp, msg, file); if (cp == NULL) return; } } #endif } char * p_cdname(cp, msg, file) char *cp, *msg; FILE *file; { #ifdef DEBUG char name[MAXDNAME]; int n; if ((n = dn_expand(msg, msg + 512, cp, name, sizeof(name))) < 0) return (NULL); if (name[0] == '\0') { name[0] = '.'; name[1] = '\0'; } fputs(name, file); return (cp + n); #endif } /* * Print resource record fields in human readable form. */ char * p_rr(cp, msg, file) char *cp, *msg; FILE *file; { #ifdef DEBUG int type, class, dlen, n, c; struct in_addr inaddr; char *cp1; if ((cp = p_cdname(cp, msg, file)) == NULL) return (NULL); /* compression error */ fprintf(file,"\n\ttype = %s", p_type(type = _getshort(cp))); cp += sizeof(u_short); fprintf(file,", class = %s", p_class(class = _getshort(cp))); cp += sizeof(u_short); fprintf(file,", ttl = %lu", _getlong(cp)); cp += sizeof(u_long); fprintf(file,", dlen = %d\n", dlen = _getshort(cp)); cp += sizeof(u_short); cp1 = cp; /* * Print type specific data, if appropriate */ switch (type) { case T_A: switch (class) { case C_IN: bcopy(cp, (char *)&inaddr, sizeof(inaddr)); if (dlen == 4) { fprintf(file,"\tinternet address = %s\n", inet_ntoa(inaddr)); cp += dlen; } else if (dlen == 7) { fprintf(file,"\tinternet address = %s", inet_ntoa(inaddr)); fprintf(file,", protocol = %d", cp[4]); fprintf(file,", port = %d\n", (cp[5] << 8) + cp[6]); cp += dlen; } break; default: cp += dlen; } break; case T_CNAME: case T_MB: #ifdef OLDRR case T_MD: case T_MF: #endif /* OLDRR */ case T_MG: case T_MR: case T_NS: case T_PTR: fprintf(file,"\tdomain name = "); cp = p_cdname(cp, msg, file); fprintf(file,"\n"); break; case T_HINFO: if (n = *cp++) { fprintf(file,"\tCPU=%.*s\n", n, cp); cp += n; } if (n = *cp++) { fprintf(file,"\tOS=%.*s\n", n, cp); cp += n; } break; case T_SOA: fprintf(file,"\torigin = "); cp = p_cdname(cp, msg, file); fprintf(file,"\n\tmail addr = "); cp = p_cdname(cp, msg, file); fprintf(file,"\n\tserial=%ld", _getlong(cp)); cp += sizeof(u_long); fprintf(file,", refresh=%ld", _getlong(cp)); cp += sizeof(u_long); fprintf(file,", retry=%ld", _getlong(cp)); cp += sizeof(u_long); fprintf(file,", expire=%ld", _getlong(cp)); cp += sizeof(u_long); fprintf(file,", min=%ld\n", _getlong(cp)); cp += sizeof(u_long); break; case T_MX: fprintf(file,"\tpreference = %d,",_getshort(cp)); cp += sizeof(u_short); fprintf(file," name = "); cp = p_cdname(cp, msg, file); break; case T_MINFO: fprintf(file,"\trequests = "); cp = p_cdname(cp, msg, file); fprintf(file,"\n\terrors = "); cp = p_cdname(cp, msg, file); break; case T_UINFO: fprintf(file,"\t%s\n", cp); cp += dlen; break; case T_UID: case T_GID: if (dlen == 4) { fprintf(file,"\t%ld\n", _getlong(cp)); cp += sizeof(int); } break; case T_WKS: if (dlen < sizeof(u_long) + 1) break; bcopy(cp, (char *)&inaddr, sizeof(inaddr)); cp += sizeof(u_long); fprintf(file,"\tinternet address = %s, protocol = %d\n\t", inet_ntoa(inaddr), *cp++); n = 0; while (cp < cp1 + dlen) { c = *cp++; do { if (c & 0200) fprintf(file," %d", n); c <<= 1; } while (++n & 07); } putc('\n',file); break; #ifdef ALLOW_T_UNSPEC case T_UNSPEC: { int NumBytes = 8; char *DataPtr; int i; if (dlen < NumBytes) NumBytes = dlen; fprintf(file, "\tFirst %d bytes of hex data:", NumBytes); for (i = 0, DataPtr = cp; i < NumBytes; i++, DataPtr++) fprintf(file, " %x", *DataPtr); fputs("\n", file); cp += dlen; } break; #endif /* ALLOW_T_UNSPEC */ default: fprintf(file,"\t???\n"); cp += dlen; } if (cp != cp1 + dlen) fprintf(file,"packet size error (%#x != %#x)\n", cp, cp1+dlen); fprintf(file,"\n"); return (cp); #endif } static char nbuf[20]; /* * Return a string for the type */ char * p_type(type) int type; { switch (type) { case T_A: return("A"); case T_NS: /* authoritative server */ return("NS"); #ifdef OLDRR case T_MD: /* mail destination */ return("MD"); case T_MF: /* mail forwarder */ return("MF"); #endif /* OLDRR */ case T_CNAME: /* connonical name */ return("CNAME"); case T_SOA: /* start of authority zone */ return("SOA"); case T_MB: /* mailbox domain name */ return("MB"); case T_MG: /* mail group member */ return("MG"); case T_MX: /* mail routing info */ return("MX"); case T_MR: /* mail rename name */ return("MR"); case T_NULL: /* null resource record */ return("NULL"); case T_WKS: /* well known service */ return("WKS"); case T_PTR: /* domain name pointer */ return("PTR"); case T_HINFO: /* host information */ return("HINFO"); case T_MINFO: /* mailbox information */ return("MINFO"); case T_AXFR: /* zone transfer */ return("AXFR"); case T_MAILB: /* mail box */ return("MAILB"); case T_MAILA: /* mail address */ return("MAILA"); case T_ANY: /* matches any type */ return("ANY"); case T_UINFO: return("UINFO"); case T_UID: return("UID"); case T_GID: return("GID"); #ifdef ALLOW_T_UNSPEC case T_UNSPEC: return("UNSPEC"); #endif /* ALLOW_T_UNSPEC */ default: (void)sprintf(nbuf, "%d", type); return(nbuf); } } /* * Return a mnemonic for class */ char * p_class(class) int class; { switch (class) { case C_IN: /* internet class */ return("IN"); case C_ANY: /* matches any class */ return("ANY"); default: (void)sprintf(nbuf, "%d", class); return(nbuf); } } ================================================ FILE: lib/libc/net/res_init.c ================================================ /* * Copyright (c) 1985 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that this notice is preserved and that due credit is given * to the University of California at Berkeley. The name of the University * may not be used to endorse or promote products derived from this * software without specific prior written permission. This software * is provided ``as is'' without express or implied warranty. */ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)res_init.c 6.8 (Berkeley) 3/7/88"; #endif /* LIBC_SCCS and not lint */ #include #include #include #include #include #include /* * Resolver configuration file. Contains the address of the * inital name server to query and the default domain for * non fully qualified domain names. */ #ifndef CONFFILE #define CONFFILE "/etc/resolv.conf" #endif /* * Resolver state default settings */ struct state _res = { RES_TIMEOUT, /* retransmition time interval */ 4, /* number of times to retransmit */ RES_DEFAULT, /* options flags */ 1, /* number of name servers */ }; /* * Set up default settings. If the configuration file exist, the values * there will have precedence. Otherwise, the server address is set to * INADDR_ANY and the default domain name comes from the gethostname(). * * The configuration file should only be used if you want to redefine your * domain or run without a server on your machine. * * Return 0 if completes successfully, -1 on error */ res_init() { register FILE *fp; register char *cp, **pp; char buf[BUFSIZ]; extern u_long inet_addr(); extern char *index(); extern char *strcpy(), *strncpy(); extern char *getenv(); int n = 0; /* number of nameserver records read from file */ _res.nsaddr.sin_addr.s_addr = INADDR_ANY; _res.nsaddr.sin_family = AF_INET; _res.nsaddr.sin_port = htons(NAMESERVER_PORT); _res.nscount = 1; _res.defdname[0] = '\0'; if ((fp = fopen(CONFFILE, "r")) != NULL) { /* read the config file */ while (fgets(buf, sizeof(buf), fp) != NULL) { /* read default domain name */ if (!strncmp(buf, "domain", sizeof("domain") - 1)) { cp = buf + sizeof("domain") - 1; while (*cp == ' ' || *cp == '\t') cp++; if (*cp == '\0') continue; (void)strncpy(_res.defdname, cp, sizeof(_res.defdname)); _res.defdname[sizeof(_res.defdname) - 1] = '\0'; if ((cp = index(_res.defdname, '\n')) != NULL) *cp = '\0'; continue; } /* read nameservers to query */ if (!strncmp(buf, "nameserver", sizeof("nameserver") - 1) && (n < MAXNS)) { cp = buf + sizeof("nameserver") - 1; while (*cp == ' ' || *cp == '\t') cp++; if (*cp == '\0') continue; _res.nsaddr_list[n].sin_addr.s_addr = inet_addr(cp); if (_res.nsaddr_list[n].sin_addr.s_addr == (unsigned)-1) _res.nsaddr_list[n].sin_addr.s_addr = INADDR_ANY; _res.nsaddr_list[n].sin_family = AF_INET; _res.nsaddr_list[n].sin_port = htons(NAMESERVER_PORT); if ( ++n >= MAXNS) { n = MAXNS; #ifdef DEBUG if ( _res.options & RES_DEBUG ) printf("MAXNS reached, reading resolv.conf\n"); #endif DEBUG } continue; } } if ( n > 1 ) _res.nscount = n; (void) fclose(fp); } if (_res.defdname[0] == 0) { if (gethostname(buf, sizeof(_res.defdname)) == 0 && (cp = index(buf, '.'))) (void)strcpy(_res.defdname, cp + 1); } /* Allow user to override the local domain definition */ if ((cp = getenv("LOCALDOMAIN")) != NULL) (void)strncpy(_res.defdname, cp, sizeof(_res.defdname)); /* find components of local domain that might be searched */ pp = _res.dnsrch; *pp++ = _res.defdname; for (cp = _res.defdname, n = 0; *cp; cp++) if (*cp == '.') n++; cp = _res.defdname; for (; n >= LOCALDOMAINPARTS && pp < _res.dnsrch + MAXDNSRCH; n--) { cp = index(cp, '.'); *pp++ = ++cp; } _res.options |= RES_INIT; return(0); } ================================================ FILE: lib/libc/net/res_mkquery.c ================================================ /* * Copyright (c) 1985 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that this notice is preserved and that due credit is given * to the University of California at Berkeley. The name of the University * may not be used to endorse or promote products derived from this * software without specific prior written permission. This software * is provided ``as is'' without express or implied warranty. */ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)res_mkquery.c 6.7 (Berkeley) 3/7/88"; #endif /* LIBC_SCCS and not lint */ #include #include #include #include #include /* * Form all types of queries. * Returns the size of the result or -1. */ res_mkquery(op, dname, class, type, data, datalen, newrr, buf, buflen) int op; /* opcode of query */ char *dname; /* domain name */ int class, type; /* class and type of query */ char *data; /* resource record data */ int datalen; /* length of data */ struct rrec *newrr; /* new rr for modify or append */ char *buf; /* buffer to put query */ int buflen; /* size of buffer */ { register HEADER *hp; register char *cp; register int n; char dnbuf[MAXDNAME]; char *dnptrs[10], **dpp, **lastdnptr; extern char *index(); #ifdef DEBUG if (_res.options & RES_DEBUG) printf("res_mkquery(%d, %s, %d, %d)\n", op, dname, class, type); #endif DEBUG /* * Initialize header fields. */ hp = (HEADER *) buf; hp->id = htons(++_res.id); hp->opcode = op; hp->qr = hp->aa = hp->tc = hp->ra = 0; hp->pr = (_res.options & RES_PRIMARY) != 0; hp->rd = (_res.options & RES_RECURSE) != 0; hp->rcode = NOERROR; hp->qdcount = 0; hp->ancount = 0; hp->nscount = 0; hp->arcount = 0; cp = buf + sizeof(HEADER); buflen -= sizeof(HEADER); dpp = dnptrs; *dpp++ = buf; *dpp++ = NULL; lastdnptr = dnptrs + sizeof(dnptrs)/sizeof(dnptrs[0]); /* * If the domain name contains no dots (single label), then * append the default domain name to the one given. */ if ((_res.options & RES_DEFNAMES) && dname != 0 && dname[0] != '\0' && index(dname, '.') == NULL) { if (!(_res.options & RES_INIT)) if (res_init() == -1) return(-1); if (_res.defdname[0] != '\0') { (void)sprintf(dnbuf, "%s.%s", dname, _res.defdname); dname = dnbuf; } } /* * perform opcode specific processing */ switch (op) { case QUERY: buflen -= QFIXEDSZ; if ((n = dn_comp(dname, cp, buflen, dnptrs, lastdnptr)) < 0) return (-1); cp += n; buflen -= n; putshort(type, cp); cp += sizeof(u_short); putshort(class, cp); cp += sizeof(u_short); hp->qdcount = htons(1); if (op == QUERY || data == NULL) break; /* * Make an additional record for completion domain. */ buflen -= RRFIXEDSZ; if ((n = dn_comp(data, cp, buflen, dnptrs, lastdnptr)) < 0) return (-1); cp += n; buflen -= n; putshort(T_NULL, cp); cp += sizeof(u_short); putshort(class, cp); cp += sizeof(u_short); putlong((long)0, cp); cp += sizeof(u_long); putshort(0, cp); cp += sizeof(u_short); hp->arcount = htons(1); break; case IQUERY: /* * Initialize answer section */ if (buflen < 1 + RRFIXEDSZ + datalen) return (-1); *cp++ = '\0'; /* no domain name */ putshort(type, cp); cp += sizeof(u_short); putshort(class, cp); cp += sizeof(u_short); putlong((long)0, cp); cp += sizeof(u_long); putshort(datalen, cp); cp += sizeof(u_short); if (datalen) { bcopy(data, cp, datalen); cp += datalen; } hp->ancount = htons(1); break; #ifdef ALLOW_UPDATES /* * For UPDATEM/UPDATEMA, do UPDATED/UPDATEDA followed by UPDATEA * (Record to be modified is followed by its replacement in msg.) */ case UPDATEM: case UPDATEMA: case UPDATED: /* * The res code for UPDATED and UPDATEDA is the same; user * calls them differently: specifies data for UPDATED; server * ignores data if specified for UPDATEDA. */ case UPDATEDA: buflen -= RRFIXEDSZ + datalen; if ((n = dn_comp(dname, cp, buflen, dnptrs, lastdnptr)) < 0) return (-1); cp += n; putshort(type, cp); cp += sizeof(u_short); putshort(class, cp); cp += sizeof(u_short); putlong((long)0, cp); cp += sizeof(u_long); putshort(datalen, cp); cp += sizeof(u_short); if (datalen) { bcopy(data, cp, datalen); cp += datalen; } if ( (op == UPDATED) || (op == UPDATEDA) ) { hp->ancount = htons(0); break; } /* Else UPDATEM/UPDATEMA, so drop into code for UPDATEA */ case UPDATEA: /* Add new resource record */ buflen -= RRFIXEDSZ + datalen; if ((n = dn_comp(dname, cp, buflen, dnptrs, lastdnptr)) < 0) return (-1); cp += n; putshort(newrr->r_type, cp); cp += sizeof(u_short); putshort(newrr->r_class, cp); cp += sizeof(u_short); putlong((long)0, cp); cp += sizeof(u_long); putshort(newrr->r_size, cp); cp += sizeof(u_short); if (newrr->r_size) { bcopy(newrr->r_data, cp, newrr->r_size); cp += newrr->r_size; } hp->ancount = htons(0); break; #endif ALLOW_UPDATES } return (cp - buf); } ================================================ FILE: lib/libc/net/res_query.c ================================================ /* * Copyright (c) 1988 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that this notice is preserved and that due credit is given * to the University of California at Berkeley. The name of the University * may not be used to endorse or promote products derived from this * software without specific prior written permission. This software * is provided ``as is'' without express or implied warranty. */ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)res_query.c 5.3 (Berkeley) 4/5/88"; #endif /* LIBC_SCCS and not lint */ #include #include #include #include #include #include #include #include #include #include #include #if PACKETSZ > 1024 #define MAXPACKET PACKETSZ #else #define MAXPACKET 1024 #endif extern int errno; int h_errno; /* * Formulate a normal query, send, and await answer. * Returned answer is placed in supplied buffer "answer". * Perform preliminary check of answer, returning success only * if no error is indicated and the answer count is nonzero. * Return the size of the response on success, -1 on error. * Error number is left in h_errno. * Caller must parse answer and determine whether it answers the question. */ res_query(name, class, type, answer, anslen) char *name; /* domain name */ int class, type; /* class and type of query */ u_char *answer; /* buffer to put answer */ int anslen; /* size of answer buffer */ { char buf[MAXPACKET]; HEADER *hp; int n; if ((_res.options & RES_INIT) == 0 && res_init() == -1) return (-1); #ifdef DEBUG if (_res.options & RES_DEBUG) printf("res_query(%s, %d, %d)\n", name, class, type); #endif n = res_mkquery(QUERY, name, class, type, (char *)NULL, 0, NULL, buf, sizeof(buf)); if (n <= 0) { #ifdef DEBUG if (_res.options & RES_DEBUG) printf("res_query: mkquery failed\n"); #endif h_errno = NO_RECOVERY; return (n); } n = res_send(buf, n, answer, anslen); if (n < 0) { #ifdef DEBUG if (_res.options & RES_DEBUG) printf("res_query: send error\n"); #endif h_errno = TRY_AGAIN; return(n); } hp = (HEADER *) answer; if (hp->rcode != NOERROR || ntohs(hp->ancount) == 0) { #ifdef DEBUG if (_res.options & RES_DEBUG) printf("rcode = %d, ancount=%d\n", hp->rcode, ntohs(hp->ancount)); #endif switch (hp->rcode) { case NXDOMAIN: h_errno = HOST_NOT_FOUND; break; case SERVFAIL: h_errno = TRY_AGAIN; break; case NOERROR: h_errno = NO_DATA; break; case FORMERR: case NOTIMP: case REFUSED: default: h_errno = NO_RECOVERY; break; } return (-1); } return(n); } /* * Formulate a normal query, send, and retrieve answer in supplied buffer. * Return the size of the response on success, -1 on error. * If enabled, implement search rules until answer or unrecoverable failure * is detected. Error number is left in h_errno. * Only useful for queries in the same name hierarchy as the local host * (not, for example, for host address-to-name lookups in domain in-addr.arpa). */ res_search(name, class, type, answer, anslen) char *name; /* domain name */ int class, type; /* class and type of query */ u_char *answer; /* buffer to put answer */ int anslen; /* size of answer */ { register char *cp, **domain; int n, ret; char *hostalias(); if ((_res.options & RES_INIT) == 0 && res_init() == -1) return (-1); errno = 0; h_errno = HOST_NOT_FOUND; /* default, if we never query */ for (cp = name, n = 0; *cp; cp++) if (*cp == '.') n++; if (n == 0 && (cp = hostalias(name))) return (res_query(cp, class, type, answer, anslen)); if ((n == 0 || *--cp != '.') && (_res.options & RES_DEFNAMES)) for (domain = _res.dnsrch; *domain; domain++) { h_errno = 0; ret = res_querydomain(name, *domain, class, type, answer, anslen); if (ret > 0) return (ret); /* * If no server present, give up. * If name isn't found in this domain, * keep trying higher domains in the search list * (if that's enabled). * On a NO_DATA error, keep trying, otherwise * a wildcard entry of another type could keep us * from finding this entry higher in the domain. * If we get some other error (non-authoritative negative * answer or server failure), then stop searching up, * but try the input name below in case it's fully-qualified. */ if (errno == ECONNREFUSED) { h_errno = TRY_AGAIN; return (-1); } if ((h_errno != HOST_NOT_FOUND && h_errno != NO_DATA) || (_res.options & RES_DNSRCH) == 0) break; } /* * If the search/default failed, try the name as fully-qualified, * but only if it contained at least one dot (even trailing). */ if (n) return (res_querydomain(name, (char *)NULL, class, type, answer, anslen)); return (-1); } /* * Perform a call on res_query on the concatenation of name and domain, * removing a trailing dot from name if domain is NULL. */ res_querydomain(name, domain, class, type, answer, anslen) char *name, *domain; int class, type; /* class and type of query */ u_char *answer; /* buffer to put answer */ int anslen; /* size of answer */ { char nbuf[2*MAXDNAME+2]; char *longname = nbuf; int n; #ifdef DEBUG if (_res.options & RES_DEBUG) printf("res_querydomain(%s, %s, %d, %d)\n", name, domain, class, type); #endif if (domain == NULL) { /* * Check for trailing '.'; * copy without '.' if present. */ n = strlen(name) - 1; if (name[n] == '.' && n < sizeof(nbuf) - 1) { bcopy(name, nbuf, n); nbuf[n] = '\0'; } else longname = name; } else (void)sprintf(nbuf, "%.*s.%.*s", MAXDNAME, name, MAXDNAME, domain); return (res_query(longname, class, type, answer, anslen)); } char * hostalias(name) register char *name; { register char *C1, *C2; FILE *fp; char *file, *getenv(), *strcpy(), *strncpy(); char buf[BUFSIZ]; static char abuf[MAXDNAME]; file = getenv("HOSTALIASES"); if (file == NULL || (fp = fopen(file, "r")) == NULL) return (NULL); buf[sizeof(buf) - 1] = '\0'; while (fgets(buf, sizeof(buf), fp)) { for (C1 = buf; *C1 && !isspace(*C1); ++C1); if (!*C1) break; *C1 = '\0'; if (!strcasecmp(buf, name)) { while (isspace(*++C1)); if (!*C1) break; for (C2 = C1 + 1; *C2 && !isspace(*C2); ++C2); abuf[sizeof(abuf) - 1] = *C2 = '\0'; (void)strncpy(abuf, C1, sizeof(abuf) - 1); fclose(fp); return (abuf); } } fclose(fp); return (NULL); } ================================================ FILE: lib/libc/net/res_send.c ================================================ /* * Copyright (c) 1985 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that this notice is preserved and that due credit is given * to the University of California at Berkeley. The name of the University * may not be used to endorse or promote products derived from this * software without specific prior written permission. This software * is provided ``as is'' without express or implied warranty. */ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)res_send.c 6.19.1 (Berkeley) 6/27/94"; #endif /* LIBC_SCCS and not lint */ /* * Send query to name server and wait for reply. */ #include #include #include #include #include #include #include #include #include extern int errno; static int s = -1; /* socket used for communications */ static struct sockaddr no_addr; #ifndef FD_SET #define NFDBITS 32 #define FD_SETSIZE 32 #define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS))) #define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS))) #define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS))) #define FD_ZERO(p) bzero((char *)(p), sizeof(*(p))) #endif #define KEEPOPEN (RES_USEVC|RES_STAYOPEN) res_send(buf, buflen, answer, anslen) char *buf; int buflen; char *answer; int anslen; { register int n; int retry, v_circuit, resplen, ns; int gotsomewhere = 0, connected = 0; u_short id, len; char *cp; fd_set dsmask; struct timeval timeout; HEADER *hp = (HEADER *) buf; HEADER *anhp = (HEADER *) answer; struct iovec iov[2]; int terrno = ETIMEDOUT; char junk[16]; #ifdef DEBUG if (_res.options & RES_DEBUG) { printf("res_send()\n"); p_query(buf); } #endif DEBUG if (!(_res.options & RES_INIT)) if (res_init() == -1) { return(-1); } v_circuit = (_res.options & RES_USEVC) || buflen > PACKETSZ; id = hp->id; /* * Send request, RETRY times, or until successful */ for (retry = _res.retry; retry > 0; retry--) { for (ns = 0; ns < _res.nscount; ns++) { #ifdef DEBUG if (_res.options & RES_DEBUG) printf("Querying server (# %d) address = %s\n", ns+1, inet_ntoa(_res.nsaddr_list[ns].sin_addr)); #endif DEBUG if (v_circuit) { int truncated = 0; /* * Use virtual circuit. */ if (s < 0) { s = socket(AF_INET, SOCK_STREAM, 0); if (s < 0) { terrno = errno; #ifdef DEBUG if (_res.options & RES_DEBUG) perror("socket failed"); #endif DEBUG continue; } if (connect(s, &(_res.nsaddr_list[ns]), sizeof(struct sockaddr)) < 0) { terrno = errno; #ifdef DEBUG if (_res.options & RES_DEBUG) perror("connect failed"); #endif DEBUG (void) close(s); s = -1; continue; } } /* * Send length & message */ len = htons((u_short)buflen); iov[0].iov_base = (caddr_t)&len; iov[0].iov_len = sizeof(len); iov[1].iov_base = buf; iov[1].iov_len = buflen; if (writev(s, iov, 2) != sizeof(len) + buflen) { terrno = errno; #ifdef DEBUG if (_res.options & RES_DEBUG) perror("write failed"); #endif DEBUG (void) close(s); s = -1; continue; } /* * Receive length & response */ cp = answer; len = sizeof(short); while (len != 0 && (n = read(s, (char *)cp, (int)len)) > 0) { cp += n; len -= n; } if (n <= 0) { terrno = errno; #ifdef DEBUG if (_res.options & RES_DEBUG) perror("read failed"); #endif DEBUG (void) close(s); s = -1; continue; } cp = answer; if ((resplen = ntohs(*(u_short *)cp)) > anslen) { #ifdef DEBUG if (_res.options & RES_DEBUG) fprintf(stderr, "response truncated\n"); #endif DEBUG len = anslen; truncated = 1; } else len = resplen; while (len != 0 && (n = read(s, (char *)cp, (int)len)) > 0) { cp += n; len -= n; } if (n <= 0) { terrno = errno; #ifdef DEBUG if (_res.options & RES_DEBUG) perror("read failed"); #endif DEBUG (void) close(s); s = -1; continue; } if (truncated) { /* * Flush rest of answer * so connection stays in synch. */ anhp->tc = 1; len = resplen - anslen; while (len != 0) { n = (len > sizeof(junk) ? sizeof(junk) : len); if ((n = read(s, junk, n)) > 0) len -= n; else break; } } } else { /* * Use datagrams. */ if (s < 0) s = socket(AF_INET, SOCK_DGRAM, 0); #if BSD >= 43 if (_res.nscount == 1 || retry == _res.retry) { /* * Don't use connect if we might * still receive a response * from another server. */ if (connected == 0) { if (connect(s, &_res.nsaddr_list[ns], sizeof(struct sockaddr)) < 0) { #ifdef DEBUG if (_res.options & RES_DEBUG) perror("connect"); #endif DEBUG continue; } connected = 1; } if (send(s, buf, buflen, 0) != buflen) { #ifdef DEBUG if (_res.options & RES_DEBUG) perror("send"); #endif DEBUG continue; } } else #endif BSD if (sendto(s, buf, buflen, 0, &_res.nsaddr_list[ns], sizeof(struct sockaddr)) != buflen) { #ifdef DEBUG if (_res.options & RES_DEBUG) perror("sendto"); #endif DEBUG continue; } /* * Wait for reply */ timeout.tv_sec = (_res.retrans << (_res.retry - retry)) / _res.nscount; if (timeout.tv_sec <= 0) timeout.tv_sec = 1; timeout.tv_usec = 0; wait: FD_ZERO(&dsmask); FD_SET(s, &dsmask); n = select(s+1, &dsmask, (fd_set *)NULL, (fd_set *)NULL, &timeout); if (n < 0) { #ifdef DEBUG if (_res.options & RES_DEBUG) perror("select"); #endif DEBUG continue; } if (n == 0) { /* * timeout */ #ifdef DEBUG if (_res.options & RES_DEBUG) printf("timeout\n"); #endif DEBUG /* * Disconnect if we want to listen * for responses from more than one server. */ if (_res.nscount > 1 && connected) { (void) connect(s, &no_addr, sizeof(no_addr)); connected = 0; } gotsomewhere = 1; continue; } if ((resplen = recv(s, answer, anslen, 0)) <= 0) { #ifdef DEBUG if (_res.options & RES_DEBUG) perror("recvfrom"); #endif DEBUG continue; } gotsomewhere = 1; if (id != anhp->id) { /* * response from old query, ignore it */ #ifdef DEBUG if (_res.options & RES_DEBUG) { printf("old answer:\n"); p_query(answer); } #endif DEBUG goto wait; } if (!(_res.options & RES_IGNTC) && anhp->tc) { /* * get rest of answer */ #ifdef DEBUG if (_res.options & RES_DEBUG) printf("truncated answer\n"); #endif DEBUG (void) close(s); s = -1; /* * retry decremented on continue * to desired starting value */ retry = _res.retry + 1; v_circuit = 1; continue; } } #ifdef DEBUG if (_res.options & RES_DEBUG) { printf("got answer:\n"); p_query(answer); } #endif DEBUG /* * We are going to assume that the first server is preferred * over the rest (i.e. it is on the local machine) and only * keep that one open. */ if ((_res.options & KEEPOPEN) == KEEPOPEN && ns == 0) { return (resplen); } else { (void) close(s); s = -1; return (resplen); } } } if (s >= 0) { (void) close(s); s = -1; } if (v_circuit == 0) if (gotsomewhere == 0) errno = ECONNREFUSED; else errno = ETIMEDOUT; else errno = terrno; return (-1); } /* * This routine is for closing the socket if a virtual circuit is used and * the program wants to close it. This provides support for endhostent() * which expects to close the socket. * * This routine is not expected to be user visible. */ _res_close() { if (s != -1) { (void) close(s); s = -1; } } ================================================ FILE: lib/libc/net/rexec.c ================================================ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)rexec.c 5.2.1 (2.11BSD) 1997/10/2"; #endif LIBC_SCCS and not lint #include #include #include #include #include #include int rexecoptions; rexec(ahost, rport, name, pass, cmd, fd2p) char **ahost; int rport; char *name, *pass, *cmd; int *fd2p; { int s, timo = 1, s3; struct sockaddr_in sin, sin2, from; char c; u_short port; struct hostent *hp; hp = gethostbyname(*ahost); if (hp == 0) { fprintf(stderr, "%s: unknown host\n", *ahost); return (-1); } *ahost = hp->h_name; ruserpass(hp->h_name, &name, &pass); retry: s = socket(AF_INET, SOCK_STREAM, 0); if (s < 0) { perror("rexec: socket"); return (-1); } sin.sin_family = hp->h_addrtype; sin.sin_port = rport; bcopy(hp->h_addr, (caddr_t)&sin.sin_addr, hp->h_length); if (connect(s, &sin, sizeof(sin)) < 0) { if (errno == ECONNREFUSED && timo <= 16) { (void) close(s); sleep(timo); timo *= 2; goto retry; } perror(hp->h_name); return (-1); } if (fd2p == 0) { (void) write(s, "", 1); port = 0; } else { char num[8]; int s2, sin2len; s2 = socket(AF_INET, SOCK_STREAM, 0); if (s2 < 0) { (void) close(s); return (-1); } listen(s2, 1); sin2len = sizeof (sin2); if (getsockname(s2, (char *)&sin2, &sin2len) < 0 || sin2len != sizeof (sin2)) { perror("getsockname"); (void) close(s2); goto bad; } port = ntohs((u_short)sin2.sin_port); (void) sprintf(num, "%u", port); (void) write(s, num, strlen(num)+1); { int len = sizeof (from); s3 = accept(s2, &from, &len, 0); close(s2); if (s3 < 0) { perror("accept"); port = 0; goto bad; } } *fd2p = s3; } (void) write(s, name, strlen(name) + 1); /* should public key encypt the password here */ (void) write(s, pass, strlen(pass) + 1); (void) write(s, cmd, strlen(cmd) + 1); if (read(s, &c, 1) != 1) { perror(*ahost); goto bad; } if (c != 0) { while (read(s, &c, 1) == 1) { (void) write(2, &c, 1); if (c == '\n') break; } goto bad; } return (s); bad: if (port) (void) close(*fd2p); (void) close(s); return (-1); } ================================================ FILE: lib/libc/net/ruserpass.c ================================================ /* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)ruserpass.c 5.2.1 (2.11BSD) 1996/11/16"; #endif LIBC_SCCS and not lint #include #include #include #include #include #include #include #include #include char *renvlook(); struct utmp *getutmp(); static FILE *cfile; ruserpass(host, aname, apass) char *host, **aname, **apass; { renv(host, aname, apass); if (*aname == 0 || *apass == 0) rnetrc(host, aname, apass); if (*aname == 0) { char *myname = getlogin(); *aname = (char *)malloc(16); printf("Name (%s:%s): ", host, myname); fflush(stdout); if (read(2, *aname, 16) <= 0) exit(1); if ((*aname)[0] == '\n') *aname = myname; else if (index(*aname, '\n')) *index(*aname, '\n') = 0; } if (*aname && *apass == 0) { printf("Password (%s:%s): ", host, *aname); fflush(stdout); *apass = getpass(""); } } static renv(host, aname, apass) char *host, **aname, **apass; { register char *cp; char *stemp, fgetlogin, *comma; cp = renvlook(host); if (cp == NULL) return; if (!isalpha(cp[0])) return; comma = index(cp, ','); if (comma == 0) return; if (*aname == 0) { *aname = (char *)malloc(comma - cp + 1); strncpy(*aname, cp, comma - cp); } else if (strncmp(*aname, cp, comma - cp)) return; comma++; cp = (char *)malloc(strlen(comma)+1); strcpy(cp, comma); *apass = (char *)malloc(16); mkpwclear(cp, host[0], *apass); } static char * renvlook(host) char *host; { register char *cp, **env; env = environ; for (env = environ; *env != NULL; env++) if (!strncmp(*env, "MACH", 4)) { cp = index(*env, '='); if (cp == 0) continue; if (strncmp(*env+4, host, cp-(*env+4))) continue; return (cp+1); } return (NULL); } #define DEFAULT 1 #define LOGIN 2 #define PASSWD 3 #define NOTIFY 4 #define WRITE 5 #define YES 6 #define NO 7 #define COMMAND 8 #define FORCE 9 #define ID 10 #define MACHINE 11 static char tokval[100]; static struct toktab { char *tokstr; int tval; } toktab[]= { "default", DEFAULT, "login", LOGIN, "password", PASSWD, "notify", NOTIFY, "write", WRITE, "yes", YES, "y", YES, "no", NO, "n", NO, "command", COMMAND, "force", FORCE, "machine", MACHINE, 0, 0 }; static rnetrc(host, aname, apass) char *host, **aname, **apass; { char *hdir, buf[BUFSIZ]; int t; struct stat stb; extern int errno; hdir = getenv("HOME"); if (hdir == NULL) hdir = "."; sprintf(buf, "%s/.netrc", hdir); cfile = fopen(buf, "r"); if (cfile == NULL) { if (errno != ENOENT) perror(buf); return; } next: while ((t = token())) switch(t) { case DEFAULT: (void) token(); continue; case MACHINE: if (token() != ID || strcmp(host, tokval)) continue; while ((t = token()) && t != MACHINE) switch(t) { case LOGIN: if (token()) if (*aname == 0) { *aname = (char *)malloc(strlen(tokval) + 1); strcpy(*aname, tokval); } else { if (strcmp(*aname, tokval)) goto next; } break; case PASSWD: if (fstat(fileno(cfile), &stb) >= 0 && (stb.st_mode & 077) != 0) { fprintf(stderr, "Error - .netrc file not correct mode.\n"); fprintf(stderr, "Remove password or correct mode.\n"); exit(1); } if (token() && *apass == 0) { *apass = (char *)malloc(strlen(tokval) + 1); strcpy(*apass, tokval); } break; case COMMAND: case NOTIFY: case WRITE: case FORCE: (void) token(); break; default: fprintf(stderr, "Unknown .netrc option %s\n", tokval); break; } goto done; } done: fclose(cfile); } static token() { char *cp; int c; struct toktab *t; if (feof(cfile)) return (0); while ((c = getc(cfile)) != EOF && (c == '\n' || c == '\t' || c == ' ' || c == ',')) continue; if (c == EOF) return (0); cp = tokval; if (c == '"') { while ((c = getc(cfile)) != EOF && c != '"') { if (c == '\\') c = getc(cfile); *cp++ = c; } } else { *cp++ = c; while ((c = getc(cfile)) != EOF && c != '\n' && c != '\t' && c != ' ' && c != ',') { if (c == '\\') c = getc(cfile); *cp++ = c; } } *cp = 0; if (tokval[0] == 0) return (0); for (t = toktab; t->tokstr; t++) if (!strcmp(t->tokstr, tokval)) return (t->tval); return (ID); } /* rest is nbs.c stolen from berknet */ char *deblknot(), *deblkclr(); char *nbs8decrypt(), *nbs8encrypt(); static char E[48]; /* * The E bit-selection table. */ static char e[] = { 32, 1, 2, 3, 4, 5, 4, 5, 6, 7, 8, 9, 8, 9,10,11,12,13, 12,13,14,15,16,17, 16,17,18,19,20,21, 20,21,22,23,24,25, 24,25,26,27,28,29, 28,29,30,31,32, 1, }; static char *nbsencrypt(str,key,result) char *result; char *str, *key; { static char buf[20],oldbuf[20]; register int j; result[0] = 0; strcpy(oldbuf,key); while(*str){ for(j=0;j<10;j++)buf[j] = 0; for(j=0;j<8 && *str;j++)buf[j] = *str++; strcat(result,nbs8encrypt(buf,oldbuf)); strcat(result,"$"); strcpy(oldbuf,buf); } return(result); } static char *nbsdecrypt(cpt,key,result) char *result; char *cpt,*key; { char *s; char c,oldbuf[20]; result[0] = 0; strcpy(oldbuf,key); while(*cpt){ for(s = cpt;*s && *s != '$';s++); c = *s; *s = 0; strcpy(oldbuf,nbs8decrypt(cpt,oldbuf)); strcat(result,oldbuf); if(c == 0)break; cpt = s + 1; } return(result); } static char *nbs8encrypt(str,key) char *str, *key; { static char keyblk[100], blk[100]; register int i; enblkclr(keyblk,key); nbssetkey(keyblk); for(i=0;i<48;i++) E[i] = e[i]; enblkclr(blk,str); blkencrypt(blk,0); /* forward dir */ return(deblknot(blk)); } static char *nbs8decrypt(crp,key) char *crp, *key; { static char keyblk[100], blk[100]; register int i; enblkclr(keyblk,key); nbssetkey(keyblk); for(i=0;i<48;i++) E[i] = e[i]; enblknot(blk,crp); blkencrypt(blk,1); /* backward dir */ return(deblkclr(blk)); } static enblkclr(blk,str) /* ignores top bit of chars in string str */ char *blk,*str; { register int i,j; char c; for(i=0;i<70;i++)blk[i] = 0; for(i=0; (c= *str) && i<64; str++){ for(j=0; j<7; j++, i++) blk[i] = (c>>(6-j)) & 01; i++; } } static char *deblkclr(blk) char *blk; { register int i,j; char c; static char iobuf[30]; for(i=0; i<10; i++){ c = 0; for(j=0; j<7; j++){ c <<= 1; c |= blk[8*i+j]; } iobuf[i] = c; } iobuf[i] = 0; return(iobuf); } static enblknot(blk,crp) char *blk; char *crp; { register int i,j; char c; for(i=0;i<70;i++)blk[i] = 0; for(i=0; (c= *crp) && i<64; crp++){ if(c>'Z') c -= 6; if(c>'9') c -= 7; c -= '.'; for(j=0; j<6; j++, i++) blk[i] = (c>>(5-j)) & 01; } } static char *deblknot(blk) char *blk; { register int i,j; char c; static char iobuf[30]; for(i=0; i<11; i++){ c = 0; for(j=0; j<6; j++){ c <<= 1; c |= blk[6*i+j]; } c += '.'; if(c > '9')c += 7; if(c > 'Z')c += 6; iobuf[i] = c; } iobuf[i] = 0; return(iobuf); } /* * This program implements the * Proposed Federal Information Processing * Data Encryption Standard. * See Federal Register, March 17, 1975 (40FR12134) */ /* * Initial permutation, */ static char IP[] = { 58,50,42,34,26,18,10, 2, 60,52,44,36,28,20,12, 4, 62,54,46,38,30,22,14, 6, 64,56,48,40,32,24,16, 8, 57,49,41,33,25,17, 9, 1, 59,51,43,35,27,19,11, 3, 61,53,45,37,29,21,13, 5, 63,55,47,39,31,23,15, 7, }; /* * Final permutation, FP = IP^(-1) */ static char FP[] = { 40, 8,48,16,56,24,64,32, 39, 7,47,15,55,23,63,31, 38, 6,46,14,54,22,62,30, 37, 5,45,13,53,21,61,29, 36, 4,44,12,52,20,60,28, 35, 3,43,11,51,19,59,27, 34, 2,42,10,50,18,58,26, 33, 1,41, 9,49,17,57,25, }; /* * Permuted-choice 1 from the key bits * to yield C and D. * Note that bits 8,16... are left out: * They are intended for a parity check. */ static char PC1_C[] = { 57,49,41,33,25,17, 9, 1,58,50,42,34,26,18, 10, 2,59,51,43,35,27, 19,11, 3,60,52,44,36, }; static char PC1_D[] = { 63,55,47,39,31,23,15, 7,62,54,46,38,30,22, 14, 6,61,53,45,37,29, 21,13, 5,28,20,12, 4, }; /* * Sequence of shifts used for the key schedule. */ static char shifts[] = { 1,1,2,2,2,2,2,2,1,2,2,2,2,2,2,1, }; /* * Permuted-choice 2, to pick out the bits from * the CD array that generate the key schedule. */ static char PC2_C[] = { 14,17,11,24, 1, 5, 3,28,15, 6,21,10, 23,19,12, 4,26, 8, 16, 7,27,20,13, 2, }; static char PC2_D[] = { 41,52,31,37,47,55, 30,40,51,45,33,48, 44,49,39,56,34,53, 46,42,50,36,29,32, }; /* * The C and D arrays used to calculate the key schedule. */ static char C[28]; static char D[28]; /* * The key schedule. * Generated from the key. */ static char KS[16][48]; /* * Set up the key schedule from the key. */ static nbssetkey(key) char *key; { register i, j, k; int t; /* * First, generate C and D by permuting * the key. The low order bit of each * 8-bit char is not used, so C and D are only 28 * bits apiece. */ for (i=0; i<28; i++) { C[i] = key[PC1_C[i]-1]; D[i] = key[PC1_D[i]-1]; } /* * To generate Ki, rotate C and D according * to schedule and pick up a permutation * using PC2. */ for (i=0; i<16; i++) { /* * rotate. */ for (k=0; k>3)&01; f[t+1] = (k>>2)&01; f[t+2] = (k>>1)&01; f[t+3] = (k>>0)&01; } /* * The new R is L ^ f(R, K). * The f here has to be permuted first, though. */ for (j=0; j<32; j++) R[j] = L[j] ^ f[P[j]-1]; /* * Finally, the new L (the original R) * is copied back. */ for (j=0; j<32; j++) L[j] = tempL[j]; } /* * The output L and R are reversed. */ for (j=0; j<32; j++) { t = L[j]; L[j] = R[j]; R[j] = t; } /* * The final output * gets the inverse permutation of the very original. */ for (j=0; j<64; j++) block[j] = L[FP[j]-1]; } /* getutmp() return a pointer to the system utmp structure associated with terminal sttyname, e.g. "/dev/tty3" Is version independent-- will work on v6 systems return NULL if error */ static struct utmp *getutmp(sttyname) char *sttyname; { static struct utmp utmpstr; FILE *fdutmp; if(sttyname == NULL || sttyname[0] == 0)return(NULL); fdutmp = fopen(_PATH_UTMP,"r"); if(fdutmp == NULL)return(NULL); while(fread(&utmpstr,1,sizeof utmpstr,fdutmp) == sizeof utmpstr) if(strcmp(utmpstr.ut_line,sttyname+5) == 0){ fclose(fdutmp); return(&utmpstr); } fclose(fdutmp); return(NULL); } static sreverse(sto, sfrom) register char *sto, *sfrom; { register int i; i = strlen(sfrom); while (i >= 0) *sto++ = sfrom[i--]; } static char *mkenvkey(mch) char mch; { static char skey[40]; register struct utmp *putmp; char stemp[40], stemp1[40], sttyname[30]; register char *sk,*p; if (isatty(2)) strcpy(sttyname,ttyname(2)); else if (isatty(0)) strcpy(sttyname,ttyname(0)); else if (isatty(1)) strcpy(sttyname,ttyname(1)); else return (NULL); putmp = getutmp(sttyname); if (putmp == NULL) return (NULL); sk = skey; p = putmp->ut_line; while (*p) *sk++ = *p++; *sk++ = mch; sprintf(stemp, "%ld", putmp->ut_time); sreverse(stemp1, stemp); p = stemp1; while (*p) *sk++ = *p++; *sk = 0; return (skey); } mkpwunclear(spasswd,mch,sencpasswd) char mch, *spasswd, *sencpasswd; { register char *skey; if (spasswd[0] == 0) { sencpasswd[0] = 0; return; } skey = mkenvkey(mch); if (skey == NULL) { fprintf(stderr, "Can't make key\n"); exit(1); } nbsencrypt(spasswd, skey, sencpasswd); } mkpwclear(sencpasswd,mch,spasswd) char mch, *spasswd, *sencpasswd; { register char *skey; if (sencpasswd[0] == 0) { spasswd[0] = 0; return; } skey = mkenvkey(mch); if (skey == NULL) { fprintf(stderr, "Can't make key\n"); exit(1); } nbsdecrypt(sencpasswd, skey, spasswd); } ================================================ FILE: lib/libc/ns/Makefile ================================================ # # Copyright (c) 1980 Regents of the University of California. # All rights reserved. The Berkeley software License Agreement # specifies the terms and conditions for redistribution. # # @(#)Makefile 6.1 (Berkeley) 1/29/86 # SRCS= ns_addr.c ns_ntoa.c OBJS= ns_addr.o ns_ntoa.o CFLAGS+= ${DEFS} TAGSFILE=tags .c.o: ${CC} -p -c ${CFLAGS} $*.c -ld -X -r $*.o mv a.out profiled/$*.o ${CC} ${CFLAGS} -c $*.c -ld -x -r $*.o mv a.out $*.o nslib nslib_p: ${OBJS} @echo "building profiled nslib" @cd profiled; ${AR} cr ../nslib_p ${OBJS} @echo "building normal nslib" @${AR} cr nslib ${OBJS} tags: cwd=`pwd`; \ for i in ${SRCS}; do \ ctags -a -f ${TAGSFILE} $$cwd/$$i; \ done clean: rm -f nslib nslib_p *.o profiled/*.o errs a.out core \ tags Makefile.bak depend: for i in ${SRCS}; do \ cc -M ${CFLAGS} $$i | awk ' { if ($$1 != prev) \ { if (rec != "") print rec; rec = $$0; prev = $$1; } \ else { if (length(rec $$2) > 78) { print rec; rec = $$0; } \ else rec = rec " " $$2 } } \ END { print rec } ' >> makedep; done echo '/^# DO NOT DELETE THIS LINE/+2,$$d' >eddep echo '$$r makedep' >>eddep echo 'w' >>eddep cp Makefile Makefile.bak ed - Makefile < eddep rm eddep makedep echo '# DEPENDENCIES MUST END AT END OF FILE' >> Makefile echo '# IF YOU PUT STUFF HERE IT WILL GO AWAY' >> Makefile echo '# see make depend above' >> Makefile # DO NOT DELETE THIS LINE -- make depend uses it ns_addr.o: ns_addr.c /usr/include/sys/types.h /usr/include/netns/ns.h ns_ntoa.o: ns_ntoa.c /usr/include/sys/types.h /usr/include/netns/ns.h # DEPENDENCIES MUST END AT END OF FILE # IF YOU PUT STUFF HERE IT WILL GO AWAY # see make depend above ================================================ FILE: lib/libc/ns/ns_addr.c ================================================ /* * Copyright (c) 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * * Includes material written at Cornell University, by J. Q. Johnson. * Used by permission. */ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)ns_addr.c 6.2 (Berkeley) 3/9/86"; #endif LIBC_SCCS and not lint #include #include static struct ns_addr addr, zero_addr; struct ns_addr ns_addr(name) char *name; { u_long net; u_short socket; char separator = '.'; char *hostname, *socketname, *cp; char buf[50]; extern char *index(); addr = zero_addr; strncpy(buf, name, 49); /* * First, figure out what he intends as a field separtor. * Despite the way this routine is written, the prefered * form 2-272.AA001234H.01777, i.e. XDE standard. * Great efforts are made to insure backward compatability. */ if (hostname = index(buf, '#')) separator = '#'; else { hostname = index(buf, '.'); if ((cp = index(buf, ':')) && ( (hostname && cp < hostname) || (hostname == 0))) { hostname = cp; separator = ':'; } } if (hostname) *hostname++ = 0; Field(buf, addr.x_net.c_net, 4); if (hostname == 0) return (addr); /* No separator means net only */ socketname = index(hostname, separator); if (socketname) { *socketname++ = 0; Field(socketname, &addr.x_port, 2); } Field(hostname, addr.x_host.c_host, 6); return (addr); } static Field(buf, out, len) char *buf; u_char *out; int len; { register char *bp = buf; int i, ibase, base16 = 0, base10 = 0, clen = 0; int hb[6], *hp; char *fmt; /* * first try 2-273#2-852-151-014#socket */ if ((*buf != '-') && (1 < (i = sscanf(buf, "%d-%d-%d-%d-%d", &hb[0], &hb[1], &hb[2], &hb[3], &hb[4])))) { cvtbase(1000, 256, hb, i, out, len); return; } /* * try form 8E1#0.0.AA.0.5E.E6#socket */ if (1 < (i = sscanf(buf,"%x.%x.%x.%x.%x.%x", &hb[0], &hb[1], &hb[2], &hb[3], &hb[4], &hb[5]))) { cvtbase(256, 256, hb, i, out, len); return; } /* * try form 8E1#0:0:AA:0:5E:E6#socket */ if (1 < (i = sscanf(buf,"%x:%x:%x:%x:%x:%x", &hb[0], &hb[1], &hb[2], &hb[3], &hb[4], &hb[5]))) { cvtbase(256, 256, hb, i, out, len); return; } /* * This is REALLY stretching it but there was a * comma notation separting shorts -- definitely non standard */ if (1 < (i = sscanf(buf,"%x,%x,%x", &hb[0], &hb[1], &hb[2]))) { hb[0] = htons(hb[0]); hb[1] = htons(hb[1]); hb[2] = htons(hb[2]); cvtbase(65536, 256, hb, i, out, len); return; } /* Need to decide if base 10, 16 or 8 */ while (*bp) switch (*bp++) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '-': break; case '8': case '9': base10 = 1; break; case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': base16 = 1; break; case 'x': case 'X': *--bp = '0'; base16 = 1; break; case 'h': case 'H': base16 = 1; /* fall into */ default: *--bp = 0; /* Ends Loop */ } if (base16) { fmt = "%3x"; ibase = 4096; } else if (base10 == 0 && *buf == '0') { fmt = "%3o"; ibase = 512; } else { fmt = "%3d"; ibase = 1000; } for (bp = buf; *bp++; ) clen++; if (clen == 0) clen++; if (clen > 18) clen = 18; i = ((clen - 1) / 3) + 1; bp = clen + buf - 3; hp = hb + i - 1; while (hp > hb) { sscanf(bp, fmt, hp); bp[0] = 0; hp--; bp -= 3; } sscanf(buf, fmt, hp); cvtbase(ibase, 256, hb, i, out, len); } static cvtbase(oldbase,newbase,input,inlen,result,reslen) long oldbase; int newbase; int input[]; int inlen; unsigned char result[]; int reslen; { int d, e; long sum; e = 1; while (e > 0 && reslen > 0) { d = 0; e = 0; sum = 0; /* long division: input=input/newbase */ while (d < inlen) { sum = sum*oldbase + (long) input[d]; e += (sum > 0); input[d++] = sum / newbase; sum %= newbase; } result[--reslen] = sum; /* accumulate remainder */ } for (d=0; d < reslen; d++) result[d] = 0; } ================================================ FILE: lib/libc/ns/ns_ntoa.c ================================================ /* * Copyright (c) 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * */ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)ns_ntoa.c 6.3 (Berkeley) 3/9/86"; #endif LIBC_SCCS and not lint #include #include char * ns_ntoa(addr) struct ns_addr addr; { static char obuf[40]; char *spectHex(); union { union ns_net net_e; u_long long_e; } net; u_short port = htons(addr.x_port); register char *cp; char *cp2; register u_char *up = addr.x_host.c_host; u_char *uplim = up + 6; net.net_e = addr.x_net; sprintf(obuf, "%lx", ntohl(net.long_e)); cp = spectHex(obuf); cp2 = cp + 1; while (*up==0 && up < uplim) up++; if (up == uplim) { if (port) { sprintf(cp, ".0"); cp += 2; } } else { sprintf(cp, ".%x", *up++); while (up < uplim) { while (*cp) cp++; sprintf(cp, "%02x", *up++); } cp = spectHex(cp2); } if (port) { sprintf(cp, ".%x", port); spectHex(cp + 1); } return (obuf); } static char * spectHex(p0) char *p0; { int ok = 0; int nonzero = 0; register char *p = p0; for (; *p; p++) switch (*p) { case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': *p += ('A' - 'a'); /* fall into . . . */ case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': ok = 1; case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': nonzero = 1; } if (nonzero && !ok) { *p++ = 'H'; *p = 0; } return (p); } ================================================ FILE: lib/libc/runtime/CREDITS.txt ================================================ This file is a partial list of people who have contributed to the LLVM/CompilerRT project. If you have contributed a patch or made some other contribution to LLVM/CompilerRT, please submit a patch to this file to add yourself, and it will be done! The list is sorted by surname and formatted to allow easy grepping and beautification by scripts. The fields are: name (N), email (E), web-address (W), PGP key ID and fingerprint (P), description (D), and snail-mail address (S). N: Craig van Vliet E: cvanvliet@auroraux.org W: http://www.auroraux.org D: Code style and Readability fixes. N: Edward O'Callaghan E: eocallaghan@auroraux.org W: http://www.auroraux.org D: CMake'ify Compiler-RT build system D: Maintain Solaris & AuroraUX ports of Compiler-RT N: Howard Hinnant E: hhinnant@apple.com D: Architect and primary author of compiler-rt N: Guan-Hong Liu E: koviankevin@hotmail.com D: IEEE Quad-precision functions N: Joerg Sonnenberger E: joerg@NetBSD.org D: Maintains NetBSD port. N: Matt Thomas E: matt@NetBSD.org D: ARM improvements. ================================================ FILE: lib/libc/runtime/LICENSE.txt ================================================ ============================================================================== compiler_rt License ============================================================================== The compiler_rt library is dual licensed under both the University of Illinois "BSD-Like" license and the MIT license. As a user of this code you may choose to use it under either license. As a contributor, you agree to allow your code to be used under both. Full text of the relevant licenses is included below. ============================================================================== University of Illinois/NCSA Open Source License Copyright (c) 2009-2018 by the contributors listed in CREDITS.TXT All rights reserved. Developed by: LLVM Team University of Illinois at Urbana-Champaign http://llvm.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal with the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimers. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimers in the documentation and/or other materials provided with the distribution. * Neither the names of the LLVM Team, University of Illinois at Urbana-Champaign, nor the names of its contributors may be used to endorse or promote products derived from this Software without specific prior written permission. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE. ============================================================================== Copyright (c) 2009-2015 by the contributors listed in CREDITS.TXT Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ============================================================================== Copyrights and Licenses for Third Party Software Distributed with LLVM: ============================================================================== The LLVM software contains code written by third parties. Such software will have its own individual LICENSE.TXT file in the directory in which it appears. This file will describe the copyrights, license, and restrictions which apply to that code. The disclaimer of warranty in the University of Illinois Open Source License applies to all code in the LLVM Distribution, and nothing in any of the other licenses gives permission to use the names of the LLVM Team or the University of Illinois to endorse or promote products derived from this Software. ================================================ FILE: lib/libc/runtime/Makefile ================================================ # # Copyright (c) 1988 Regents of the University of California. # All rights reserved. # # Redistribution and use in source and binary forms are permitted # provided that the above copyright notice and this paragraph are # duplicated in all such forms and that any documentation, advertising # materials, and other materials related to such redistribution and # use acknowledge that the software was developed by the University # of California, Berkeley. The name of the University may not be # used to endorse or promote products derived from this software # without specific prior written permission. THIS SOFTWARE IS PROVIDED # ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, # WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND # FITNESS FOR A PARTICULAR PURPOSE. # TOPSRC!=cd ../../..; pwd include ${TOPSRC}/share/mk/sys.mk CFLAGS += ${DEFS} OBJS= addsf3.o comparesf2.o divsf3.o fixsfsi.o fixunssfsi.o \ floatsisf.o floatunsisf.o mulsf3.o negsf2.o subsf3.o \ adddf3.o comparedf2.o divdf3.o fixdfsi.o fixunsdfsi.o \ floatsidf.o floatunsidf.o muldf3.o negdf2.o subdf3.o \ ashldi3.o lshrdi3.o \ sc_case.o all: ${OBJS} clean: rm -f *.a *.o *~ profiled/*.o tags cleandir: clean rm -f .depend install: all # cp ../libgcc.a ${DESTDIR}/usr/lib/ # $(RANLIB) -t ${DESTDIR}/usr/lib/libgcc.a # cp libgcc_p.a ${DESTDIR}/usr/lib/ # $(RANLIB) -t ${DESTDIR}/usr/lib/libgcc_p.a ================================================ FILE: lib/libc/runtime/README.txt ================================================ Compiler-RT ================================ This directory and its subdirectories contain source code for the compiler support routines. Compiler-RT is open source software. You may freely distribute it under the terms of the license agreement found in LICENSE.txt. ================================ This is a replacement library for libgcc. Each function is contained in its own file. Each function has a corresponding unit test under test/Unit. A rudimentary script to test each file is in the file called test/Unit/test. Here is the specification for this library: http://gcc.gnu.org/onlinedocs/gccint/Libgcc.html#Libgcc Here is a synopsis of the contents of this library: typedef int si_int; typedef unsigned su_int; typedef long long di_int; typedef unsigned long long du_int; // Integral bit manipulation di_int __ashldi3(di_int a, si_int b); // a << b ti_int __ashlti3(ti_int a, si_int b); // a << b di_int __ashrdi3(di_int a, si_int b); // a >> b arithmetic (sign fill) ti_int __ashrti3(ti_int a, si_int b); // a >> b arithmetic (sign fill) di_int __lshrdi3(di_int a, si_int b); // a >> b logical (zero fill) ti_int __lshrti3(ti_int a, si_int b); // a >> b logical (zero fill) si_int __clzsi2(si_int a); // count leading zeros si_int __clzdi2(di_int a); // count leading zeros si_int __clzti2(ti_int a); // count leading zeros si_int __ctzsi2(si_int a); // count trailing zeros si_int __ctzdi2(di_int a); // count trailing zeros si_int __ctzti2(ti_int a); // count trailing zeros si_int __ffssi2(si_int a); // find least significant 1 bit si_int __ffsdi2(di_int a); // find least significant 1 bit si_int __ffsti2(ti_int a); // find least significant 1 bit si_int __paritysi2(si_int a); // bit parity si_int __paritydi2(di_int a); // bit parity si_int __parityti2(ti_int a); // bit parity si_int __popcountsi2(si_int a); // bit population si_int __popcountdi2(di_int a); // bit population si_int __popcountti2(ti_int a); // bit population uint32_t __bswapsi2(uint32_t a); // a byteswapped uint64_t __bswapdi2(uint64_t a); // a byteswapped // Integral arithmetic di_int __negdi2 (di_int a); // -a ti_int __negti2 (ti_int a); // -a di_int __muldi3 (di_int a, di_int b); // a * b ti_int __multi3 (ti_int a, ti_int b); // a * b si_int __divsi3 (si_int a, si_int b); // a / b signed di_int __divdi3 (di_int a, di_int b); // a / b signed ti_int __divti3 (ti_int a, ti_int b); // a / b signed su_int __udivsi3 (su_int n, su_int d); // a / b unsigned du_int __udivdi3 (du_int a, du_int b); // a / b unsigned tu_int __udivti3 (tu_int a, tu_int b); // a / b unsigned si_int __modsi3 (si_int a, si_int b); // a % b signed di_int __moddi3 (di_int a, di_int b); // a % b signed ti_int __modti3 (ti_int a, ti_int b); // a % b signed su_int __umodsi3 (su_int a, su_int b); // a % b unsigned du_int __umoddi3 (du_int a, du_int b); // a % b unsigned tu_int __umodti3 (tu_int a, tu_int b); // a % b unsigned du_int __udivmoddi4(du_int a, du_int b, du_int* rem); // a / b, *rem = a % b unsigned tu_int __udivmodti4(tu_int a, tu_int b, tu_int* rem); // a / b, *rem = a % b unsigned su_int __udivmodsi4(su_int a, su_int b, su_int* rem); // a / b, *rem = a % b unsigned si_int __divmodsi4(si_int a, si_int b, si_int* rem); // a / b, *rem = a % b signed // Integral arithmetic with trapping overflow si_int __absvsi2(si_int a); // abs(a) di_int __absvdi2(di_int a); // abs(a) ti_int __absvti2(ti_int a); // abs(a) si_int __negvsi2(si_int a); // -a di_int __negvdi2(di_int a); // -a ti_int __negvti2(ti_int a); // -a si_int __addvsi3(si_int a, si_int b); // a + b di_int __addvdi3(di_int a, di_int b); // a + b ti_int __addvti3(ti_int a, ti_int b); // a + b si_int __subvsi3(si_int a, si_int b); // a - b di_int __subvdi3(di_int a, di_int b); // a - b ti_int __subvti3(ti_int a, ti_int b); // a - b si_int __mulvsi3(si_int a, si_int b); // a * b di_int __mulvdi3(di_int a, di_int b); // a * b ti_int __mulvti3(ti_int a, ti_int b); // a * b // Integral arithmetic which returns if overflow si_int __mulosi4(si_int a, si_int b, int* overflow); // a * b, overflow set to one if result not in signed range di_int __mulodi4(di_int a, di_int b, int* overflow); // a * b, overflow set to one if result not in signed range ti_int __muloti4(ti_int a, ti_int b, int* overflow); // a * b, overflow set to one if result not in signed range // Integral comparison: a < b -> 0 // a == b -> 1 // a > b -> 2 si_int __cmpdi2 (di_int a, di_int b); si_int __cmpti2 (ti_int a, ti_int b); si_int __ucmpdi2(du_int a, du_int b); si_int __ucmpti2(tu_int a, tu_int b); // Integral / floating point conversion di_int __fixsfdi( float a); di_int __fixdfdi( double a); di_int __fixxfdi(long double a); ti_int __fixsfti( float a); ti_int __fixdfti( double a); ti_int __fixxfti(long double a); uint64_t __fixtfdi(long double input); // ppc only, doesn't match documentation su_int __fixunssfsi( float a); su_int __fixunsdfsi( double a); su_int __fixunsxfsi(long double a); du_int __fixunssfdi( float a); du_int __fixunsdfdi( double a); du_int __fixunsxfdi(long double a); tu_int __fixunssfti( float a); tu_int __fixunsdfti( double a); tu_int __fixunsxfti(long double a); uint64_t __fixunstfdi(long double input); // ppc only float __floatdisf(di_int a); double __floatdidf(di_int a); long double __floatdixf(di_int a); long double __floatditf(int64_t a); // ppc only float __floattisf(ti_int a); double __floattidf(ti_int a); long double __floattixf(ti_int a); float __floatundisf(du_int a); double __floatundidf(du_int a); long double __floatundixf(du_int a); long double __floatunditf(uint64_t a); // ppc only float __floatuntisf(tu_int a); double __floatuntidf(tu_int a); long double __floatuntixf(tu_int a); // Floating point raised to integer power float __powisf2( float a, si_int b); // a ^ b double __powidf2( double a, si_int b); // a ^ b long double __powixf2(long double a, si_int b); // a ^ b long double __powitf2(long double a, si_int b); // ppc only, a ^ b // Complex arithmetic // (a + ib) * (c + id) float _Complex __mulsc3( float a, float b, float c, float d); double _Complex __muldc3(double a, double b, double c, double d); long double _Complex __mulxc3(long double a, long double b, long double c, long double d); long double _Complex __multc3(long double a, long double b, long double c, long double d); // ppc only // (a + ib) / (c + id) float _Complex __divsc3( float a, float b, float c, float d); double _Complex __divdc3(double a, double b, double c, double d); long double _Complex __divxc3(long double a, long double b, long double c, long double d); long double _Complex __divtc3(long double a, long double b, long double c, long double d); // ppc only // Runtime support // __clear_cache() is used to tell process that new instructions have been // written to an address range. Necessary on processors that do not have // a unified instruction and data cache. void __clear_cache(void* start, void* end); // __enable_execute_stack() is used with nested functions when a trampoline // function is written onto the stack and that page range needs to be made // executable. void __enable_execute_stack(void* addr); // __gcc_personality_v0() is normally only called by the system unwinder. // C code (as opposed to C++) normally does not need a personality function // because there are no catch clauses or destructors to be run. But there // is a C language extension __attribute__((cleanup(func))) which marks local // variables as needing the cleanup function "func" to be run when the // variable goes out of scope. That includes when an exception is thrown, // so a personality handler is needed. _Unwind_Reason_Code __gcc_personality_v0(int version, _Unwind_Action actions, uint64_t exceptionClass, struct _Unwind_Exception* exceptionObject, _Unwind_Context_t context); // for use with some implementations of assert() in void __eprintf(const char* format, const char* assertion_expression, const char* line, const char* file); // for systems with emulated thread local storage void* __emutls_get_address(struct __emutls_control*); // Power PC specific functions // There is no C interface to the saveFP/restFP functions. They are helper // functions called by the prolog and epilog of functions that need to save // a number of non-volatile float point registers. saveFP restFP // PowerPC has a standard template for trampoline functions. This function // generates a custom trampoline function with the specific realFunc // and localsPtr values. void __trampoline_setup(uint32_t* trampOnStack, int trampSizeAllocated, const void* realFunc, void* localsPtr); // adds two 128-bit double-double precision values ( x + y ) long double __gcc_qadd(long double x, long double y); // subtracts two 128-bit double-double precision values ( x - y ) long double __gcc_qsub(long double x, long double y); // multiples two 128-bit double-double precision values ( x * y ) long double __gcc_qmul(long double x, long double y); // divides two 128-bit double-double precision values ( x / y ) long double __gcc_qdiv(long double a, long double b); // ARM specific functions // There is no C interface to the switch* functions. These helper functions // are only needed by Thumb1 code for efficient switch table generation. switch16 switch32 switch8 switchu8 // There is no C interface to the *_vfp_d8_d15_regs functions. There are // called in the prolog and epilog of Thumb1 functions. When the C++ ABI use // SJLJ for exceptions, each function with a catch clause or destructors needs // to save and restore all registers in it prolog and epilog. But there is // no way to access vector and high float registers from thumb1 code, so the // compiler must add call outs to these helper functions in the prolog and // epilog. restore_vfp_d8_d15_regs save_vfp_d8_d15_regs // Note: long ago ARM processors did not have floating point hardware support. // Floating point was done in software and floating point parameters were // passed in integer registers. When hardware support was added for floating // point, new *vfp functions were added to do the same operations but with // floating point parameters in floating point registers. // Undocumented functions float __addsf3vfp(float a, float b); // Appears to return a + b double __adddf3vfp(double a, double b); // Appears to return a + b float __divsf3vfp(float a, float b); // Appears to return a / b double __divdf3vfp(double a, double b); // Appears to return a / b int __eqsf2vfp(float a, float b); // Appears to return one // iff a == b and neither is NaN. int __eqdf2vfp(double a, double b); // Appears to return one // iff a == b and neither is NaN. double __extendsfdf2vfp(float a); // Appears to convert from // float to double. int __fixdfsivfp(double a); // Appears to convert from // double to int. int __fixsfsivfp(float a); // Appears to convert from // float to int. unsigned int __fixunssfsivfp(float a); // Appears to convert from // float to unsigned int. unsigned int __fixunsdfsivfp(double a); // Appears to convert from // double to unsigned int. double __floatsidfvfp(int a); // Appears to convert from // int to double. float __floatsisfvfp(int a); // Appears to convert from // int to float. double __floatunssidfvfp(unsigned int a); // Appears to convert from // unsigned int to double. float __floatunssisfvfp(unsigned int a); // Appears to convert from // unsigned int to float. int __gedf2vfp(double a, double b); // Appears to return __gedf2 // (a >= b) int __gesf2vfp(float a, float b); // Appears to return __gesf2 // (a >= b) int __gtdf2vfp(double a, double b); // Appears to return __gtdf2 // (a > b) int __gtsf2vfp(float a, float b); // Appears to return __gtsf2 // (a > b) int __ledf2vfp(double a, double b); // Appears to return __ledf2 // (a <= b) int __lesf2vfp(float a, float b); // Appears to return __lesf2 // (a <= b) int __ltdf2vfp(double a, double b); // Appears to return __ltdf2 // (a < b) int __ltsf2vfp(float a, float b); // Appears to return __ltsf2 // (a < b) double __muldf3vfp(double a, double b); // Appears to return a * b float __mulsf3vfp(float a, float b); // Appears to return a * b int __nedf2vfp(double a, double b); // Appears to return __nedf2 // (a != b) double __negdf2vfp(double a); // Appears to return -a float __negsf2vfp(float a); // Appears to return -a float __negsf2vfp(float a); // Appears to return -a double __subdf3vfp(double a, double b); // Appears to return a - b float __subsf3vfp(float a, float b); // Appears to return a - b float __truncdfsf2vfp(double a); // Appears to convert from // double to float. int __unorddf2vfp(double a, double b); // Appears to return __unorddf2 int __unordsf2vfp(float a, float b); // Appears to return __unordsf2 Preconditions are listed for each function at the definition when there are any. Any preconditions reflect the specification at http://gcc.gnu.org/onlinedocs/gccint/Libgcc.html#Libgcc. Assumptions are listed in "int_lib.h", and in individual files. Where possible assumptions are checked at compile time. ================================================ FILE: lib/libc/runtime/adddf3.c ================================================ //===-- lib/adddf3.c - Double-precision addition ------------------*- C -*-===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // This file implements double-precision soft-float addition with the IEEE-754 // default rounding (to nearest, ties to even). // //===----------------------------------------------------------------------===// #define DOUBLE_PRECISION #include "fp_add_impl.inc" COMPILER_RT_ABI double __adddf3(double a, double b){ return __addXf3__(a, b); } #if defined(__ARM_EABI__) #if defined(COMPILER_RT_ARMHF_TARGET) AEABI_RTABI double __aeabi_dadd(double a, double b) { return __adddf3(a, b); } #else AEABI_RTABI double __aeabi_dadd(double a, double b) COMPILER_RT_ALIAS(__adddf3); #endif #endif ================================================ FILE: lib/libc/runtime/addsf3.c ================================================ //===-- lib/addsf3.c - Single-precision addition ------------------*- C -*-===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // This file implements single-precision soft-float addition with the IEEE-754 // default rounding (to nearest, ties to even). // //===----------------------------------------------------------------------===// #define SINGLE_PRECISION #include "fp_add_impl.inc" COMPILER_RT_ABI float __addsf3(float a, float b) { return __addXf3__(a, b); } #if defined(__ARM_EABI__) #if defined(COMPILER_RT_ARMHF_TARGET) AEABI_RTABI float __aeabi_fadd(float a, float b) { return __addsf3(a, b); } #else AEABI_RTABI float __aeabi_fadd(float a, float b) COMPILER_RT_ALIAS(__addsf3); #endif #endif ================================================ FILE: lib/libc/runtime/ashldi3.c ================================================ /* ====-- ashldi3.c - Implement __ashldi3 -----------------------------------=== * * The LLVM Compiler Infrastructure * * This file is dual licensed under the MIT and the University of Illinois Open * Source Licenses. See LICENSE.TXT for details. * * ===----------------------------------------------------------------------=== * * This file implements __ashldi3 for the compiler_rt library. * * ===----------------------------------------------------------------------=== */ #include "int_lib.h" /* Returns: a << b */ /* Precondition: 0 <= b < bits_in_dword */ COMPILER_RT_ABI di_int __ashldi3(di_int a, si_int b) { const int bits_in_word = (int)(sizeof(si_int) * CHAR_BIT); dwords input; dwords result; input.all = a; if (b & bits_in_word) /* bits_in_word <= b < bits_in_dword */ { result.s.low = 0; result.s.high = input.s.low << (b - bits_in_word); } else /* 0 <= b < bits_in_word */ { if (b == 0) return a; result.s.low = input.s.low << b; result.s.high = (input.s.high << b) | (input.s.low >> (bits_in_word - b)); } return result.all; } #if defined(__ARM_EABI__) AEABI_RTABI di_int __aeabi_llsl(di_int a, si_int b) COMPILER_RT_ALIAS(__ashldi3); #endif ================================================ FILE: lib/libc/runtime/comparedf2.c ================================================ //===-- lib/comparedf2.c - Double-precision comparisons -----------*- C -*-===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // // This file implements the following soft-float comparison routines: // // __eqdf2 __gedf2 __unorddf2 // __ledf2 __gtdf2 // __ltdf2 // __nedf2 // // The semantics of the routines grouped in each column are identical, so there // is a single implementation for each, and wrappers to provide the other names. // // The main routines behave as follows: // // __ledf2(a,b) returns -1 if a < b // 0 if a == b // 1 if a > b // 1 if either a or b is NaN // // __gedf2(a,b) returns -1 if a < b // 0 if a == b // 1 if a > b // -1 if either a or b is NaN // // __unorddf2(a,b) returns 0 if both a and b are numbers // 1 if either a or b is NaN // // Note that __ledf2( ) and __gedf2( ) are identical except in their handling of // NaN values. // //===----------------------------------------------------------------------===// #define DOUBLE_PRECISION #include "fp_lib.h" enum LE_RESULT { LE_LESS = -1, LE_EQUAL = 0, LE_GREATER = 1, LE_UNORDERED = 1 }; COMPILER_RT_ABI enum LE_RESULT __ledf2(fp_t a, fp_t b) { const srep_t aInt = toRep(a); const srep_t bInt = toRep(b); const rep_t aAbs = aInt & absMask; const rep_t bAbs = bInt & absMask; // If either a or b is NaN, they are unordered. if (aAbs > infRep || bAbs > infRep) return LE_UNORDERED; // If a and b are both zeros, they are equal. if ((aAbs | bAbs) == 0) return LE_EQUAL; // If at least one of a and b is positive, we get the same result comparing // a and b as signed integers as we would with a floating-point compare. if ((aInt & bInt) >= 0) { if (aInt < bInt) return LE_LESS; else if (aInt == bInt) return LE_EQUAL; else return LE_GREATER; } // Otherwise, both are negative, so we need to flip the sense of the // comparison to get the correct result. (This assumes a twos- or ones- // complement integer representation; if integers are represented in a // sign-magnitude representation, then this flip is incorrect). else { if (aInt > bInt) return LE_LESS; else if (aInt == bInt) return LE_EQUAL; else return LE_GREATER; } } #if defined(__ELF__) // Alias for libgcc compatibility FNALIAS(__cmpdf2, __ledf2); #endif enum GE_RESULT { GE_LESS = -1, GE_EQUAL = 0, GE_GREATER = 1, GE_UNORDERED = -1 // Note: different from LE_UNORDERED }; COMPILER_RT_ABI enum GE_RESULT __gedf2(fp_t a, fp_t b) { const srep_t aInt = toRep(a); const srep_t bInt = toRep(b); const rep_t aAbs = aInt & absMask; const rep_t bAbs = bInt & absMask; if (aAbs > infRep || bAbs > infRep) return GE_UNORDERED; if ((aAbs | bAbs) == 0) return GE_EQUAL; if ((aInt & bInt) >= 0) { if (aInt < bInt) return GE_LESS; else if (aInt == bInt) return GE_EQUAL; else return GE_GREATER; } else { if (aInt > bInt) return GE_LESS; else if (aInt == bInt) return GE_EQUAL; else return GE_GREATER; } } COMPILER_RT_ABI int __unorddf2(fp_t a, fp_t b) { const rep_t aAbs = toRep(a) & absMask; const rep_t bAbs = toRep(b) & absMask; return aAbs > infRep || bAbs > infRep; } // The following are alternative names for the preceding routines. COMPILER_RT_ABI enum LE_RESULT __eqdf2(fp_t a, fp_t b) { return __ledf2(a, b); } COMPILER_RT_ABI enum LE_RESULT __ltdf2(fp_t a, fp_t b) { return __ledf2(a, b); } COMPILER_RT_ABI enum LE_RESULT __nedf2(fp_t a, fp_t b) { return __ledf2(a, b); } COMPILER_RT_ABI enum GE_RESULT __gtdf2(fp_t a, fp_t b) { return __gedf2(a, b); } #if defined(__ARM_EABI__) #if defined(COMPILER_RT_ARMHF_TARGET) AEABI_RTABI int __aeabi_dcmpun(fp_t a, fp_t b) { return __unorddf2(a, b); } #else AEABI_RTABI int __aeabi_dcmpun(fp_t a, fp_t b) COMPILER_RT_ALIAS(__unorddf2); #endif #endif ================================================ FILE: lib/libc/runtime/comparesf2.c ================================================ //===-- lib/comparesf2.c - Single-precision comparisons -----------*- C -*-===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // This file implements the following soft-float comparison routines: // // __eqsf2 __gesf2 __unordsf2 // __lesf2 __gtsf2 // __ltsf2 // __nesf2 // // The semantics of the routines grouped in each column are identical, so there // is a single implementation for each, and wrappers to provide the other names. // // The main routines behave as follows: // // __lesf2(a,b) returns -1 if a < b // 0 if a == b // 1 if a > b // 1 if either a or b is NaN // // __gesf2(a,b) returns -1 if a < b // 0 if a == b // 1 if a > b // -1 if either a or b is NaN // // __unordsf2(a,b) returns 0 if both a and b are numbers // 1 if either a or b is NaN // // Note that __lesf2( ) and __gesf2( ) are identical except in their handling of // NaN values. // //===----------------------------------------------------------------------===// #define SINGLE_PRECISION #include "fp_lib.h" enum LE_RESULT { LE_LESS = -1, LE_EQUAL = 0, LE_GREATER = 1, LE_UNORDERED = 1 }; COMPILER_RT_ABI enum LE_RESULT __lesf2(fp_t a, fp_t b) { const srep_t aInt = toRep(a); const srep_t bInt = toRep(b); const rep_t aAbs = aInt & absMask; const rep_t bAbs = bInt & absMask; // If either a or b is NaN, they are unordered. if (aAbs > infRep || bAbs > infRep) return LE_UNORDERED; // If a and b are both zeros, they are equal. if ((aAbs | bAbs) == 0) return LE_EQUAL; // If at least one of a and b is positive, we get the same result comparing // a and b as signed integers as we would with a floating-point compare. if ((aInt & bInt) >= 0) { if (aInt < bInt) return LE_LESS; else if (aInt == bInt) return LE_EQUAL; else return LE_GREATER; } // Otherwise, both are negative, so we need to flip the sense of the // comparison to get the correct result. (This assumes a twos- or ones- // complement integer representation; if integers are represented in a // sign-magnitude representation, then this flip is incorrect). else { if (aInt > bInt) return LE_LESS; else if (aInt == bInt) return LE_EQUAL; else return LE_GREATER; } } #if defined(__ELF__) // Alias for libgcc compatibility FNALIAS(__cmpsf2, __lesf2); #endif enum GE_RESULT { GE_LESS = -1, GE_EQUAL = 0, GE_GREATER = 1, GE_UNORDERED = -1 // Note: different from LE_UNORDERED }; COMPILER_RT_ABI enum GE_RESULT __gesf2(fp_t a, fp_t b) { const srep_t aInt = toRep(a); const srep_t bInt = toRep(b); const rep_t aAbs = aInt & absMask; const rep_t bAbs = bInt & absMask; if (aAbs > infRep || bAbs > infRep) return GE_UNORDERED; if ((aAbs | bAbs) == 0) return GE_EQUAL; if ((aInt & bInt) >= 0) { if (aInt < bInt) return GE_LESS; else if (aInt == bInt) return GE_EQUAL; else return GE_GREATER; } else { if (aInt > bInt) return GE_LESS; else if (aInt == bInt) return GE_EQUAL; else return GE_GREATER; } } COMPILER_RT_ABI int __unordsf2(fp_t a, fp_t b) { const rep_t aAbs = toRep(a) & absMask; const rep_t bAbs = toRep(b) & absMask; return aAbs > infRep || bAbs > infRep; } // The following are alternative names for the preceding routines. COMPILER_RT_ABI enum LE_RESULT __eqsf2(fp_t a, fp_t b) { return __lesf2(a, b); } COMPILER_RT_ABI enum LE_RESULT __ltsf2(fp_t a, fp_t b) { return __lesf2(a, b); } COMPILER_RT_ABI enum LE_RESULT __nesf2(fp_t a, fp_t b) { return __lesf2(a, b); } COMPILER_RT_ABI enum GE_RESULT __gtsf2(fp_t a, fp_t b) { return __gesf2(a, b); } #if defined(__ARM_EABI__) #if defined(COMPILER_RT_ARMHF_TARGET) AEABI_RTABI int __aeabi_fcmpun(fp_t a, fp_t b) { return __unordsf2(a, b); } #else AEABI_RTABI int __aeabi_fcmpun(fp_t a, fp_t b) COMPILER_RT_ALIAS(__unordsf2); #endif #endif ================================================ FILE: lib/libc/runtime/divdf3.c ================================================ //===-- lib/divdf3.c - Double-precision division ------------------*- C -*-===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // This file implements double-precision soft-float division // with the IEEE-754 default rounding (to nearest, ties to even). // // For simplicity, this implementation currently flushes denormals to zero. // It should be a fairly straightforward exercise to implement gradual // underflow with correct rounding. // //===----------------------------------------------------------------------===// #define DOUBLE_PRECISION #include "fp_lib.h" COMPILER_RT_ABI fp_t __divdf3(fp_t a, fp_t b) { const unsigned int aExponent = toRep(a) >> significandBits & maxExponent; const unsigned int bExponent = toRep(b) >> significandBits & maxExponent; const rep_t quotientSign = (toRep(a) ^ toRep(b)) & signBit; rep_t aSignificand = toRep(a) & significandMask; rep_t bSignificand = toRep(b) & significandMask; int scale = 0; // Detect if a or b is zero, denormal, infinity, or NaN. if (aExponent-1U >= maxExponent-1U || bExponent-1U >= maxExponent-1U) { const rep_t aAbs = toRep(a) & absMask; const rep_t bAbs = toRep(b) & absMask; // NaN / anything = qNaN if (aAbs > infRep) return fromRep(toRep(a) | quietBit); // anything / NaN = qNaN if (bAbs > infRep) return fromRep(toRep(b) | quietBit); if (aAbs == infRep) { // infinity / infinity = NaN if (bAbs == infRep) return fromRep(qnanRep); // infinity / anything else = +/- infinity else return fromRep(aAbs | quotientSign); } // anything else / infinity = +/- 0 if (bAbs == infRep) return fromRep(quotientSign); if (!aAbs) { // zero / zero = NaN if (!bAbs) return fromRep(qnanRep); // zero / anything else = +/- zero else return fromRep(quotientSign); } // anything else / zero = +/- infinity if (!bAbs) return fromRep(infRep | quotientSign); // one or both of a or b is denormal, the other (if applicable) is a // normal number. Renormalize one or both of a and b, and set scale to // include the necessary exponent adjustment. if (aAbs < implicitBit) scale += normalize(&aSignificand); if (bAbs < implicitBit) scale -= normalize(&bSignificand); } // Or in the implicit significand bit. (If we fell through from the // denormal path it was already set by normalize( ), but setting it twice // won't hurt anything.) aSignificand |= implicitBit; bSignificand |= implicitBit; int quotientExponent = aExponent - bExponent + scale; // Align the significand of b as a Q31 fixed-point number in the range // [1, 2.0) and get a Q32 approximate reciprocal using a small minimax // polynomial approximation: reciprocal = 3/4 + 1/sqrt(2) - b/2. This // is accurate to about 3.5 binary digits. const uint32_t q31b = bSignificand >> 21; uint32_t recip32 = UINT32_C(0x7504f333) - q31b; // Now refine the reciprocal estimate using a Newton-Raphson iteration: // // x1 = x0 * (2 - x0 * b) // // This doubles the number of correct binary digits in the approximation // with each iteration, so after three iterations, we have about 28 binary // digits of accuracy. uint32_t correction32; correction32 = -((uint64_t)recip32 * q31b >> 32); recip32 = (uint64_t)recip32 * correction32 >> 31; correction32 = -((uint64_t)recip32 * q31b >> 32); recip32 = (uint64_t)recip32 * correction32 >> 31; correction32 = -((uint64_t)recip32 * q31b >> 32); recip32 = (uint64_t)recip32 * correction32 >> 31; // recip32 might have overflowed to exactly zero in the preceding // computation if the high word of b is exactly 1.0. This would sabotage // the full-width final stage of the computation that follows, so we adjust // recip32 downward by one bit. recip32--; // We need to perform one more iteration to get us to 56 binary digits; // The last iteration needs to happen with extra precision. const uint32_t q63blo = bSignificand << 11; uint64_t correction, reciprocal; correction = -((uint64_t)recip32*q31b + ((uint64_t)recip32*q63blo >> 32)); uint32_t cHi = correction >> 32; uint32_t cLo = correction; reciprocal = (uint64_t)recip32*cHi + ((uint64_t)recip32*cLo >> 32); // We already adjusted the 32-bit estimate, now we need to adjust the final // 64-bit reciprocal estimate downward to ensure that it is strictly smaller // than the infinitely precise exact reciprocal. Because the computation // of the Newton-Raphson step is truncating at every step, this adjustment // is small; most of the work is already done. reciprocal -= 2; // The numerical reciprocal is accurate to within 2^-56, lies in the // interval [0.5, 1.0), and is strictly smaller than the true reciprocal // of b. Multiplying a by this reciprocal thus gives a numerical q = a/b // in Q53 with the following properties: // // 1. q < a/b // 2. q is in the interval [0.5, 2.0) // 3. the error in q is bounded away from 2^-53 (actually, we have a // couple of bits to spare, but this is all we need). // We need a 64 x 64 multiply high to compute q, which isn't a basic // operation in C, so we need to be a little bit fussy. rep_t quotient, quotientLo; wideMultiply(aSignificand << 2, reciprocal, "ient, "ientLo); // Two cases: quotient is in [0.5, 1.0) or quotient is in [1.0, 2.0). // In either case, we are going to compute a residual of the form // // r = a - q*b // // We know from the construction of q that r satisfies: // // 0 <= r < ulp(q)*b // // if r is greater than 1/2 ulp(q)*b, then q rounds up. Otherwise, we // already have the correct result. The exact halfway case cannot occur. // We also take this time to right shift quotient if it falls in the [1,2) // range and adjust the exponent accordingly. rep_t residual; if (quotient < (implicitBit << 1)) { residual = (aSignificand << 53) - quotient * bSignificand; quotientExponent--; } else { quotient >>= 1; residual = (aSignificand << 52) - quotient * bSignificand; } const int writtenExponent = quotientExponent + exponentBias; if (writtenExponent >= maxExponent) { // If we have overflowed the exponent, return infinity. return fromRep(infRep | quotientSign); } else if (writtenExponent < 1) { // Flush denormals to zero. In the future, it would be nice to add // code to round them correctly. return fromRep(quotientSign); } else { const bool round = (residual << 1) > bSignificand; // Clear the implicit bit rep_t absResult = quotient & significandMask; // Insert the exponent absResult |= (rep_t)writtenExponent << significandBits; // Round absResult += round; // Insert the sign and return const double result = fromRep(absResult | quotientSign); return result; } } #if defined(__ARM_EABI__) #if defined(COMPILER_RT_ARMHF_TARGET) AEABI_RTABI fp_t __aeabi_ddiv(fp_t a, fp_t b) { return __divdf3(a, b); } #else AEABI_RTABI fp_t __aeabi_ddiv(fp_t a, fp_t b) COMPILER_RT_ALIAS(__divdf3); #endif #endif ================================================ FILE: lib/libc/runtime/divsf3.c ================================================ //===-- lib/divsf3.c - Single-precision division ------------------*- C -*-===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // This file implements single-precision soft-float division // with the IEEE-754 default rounding (to nearest, ties to even). // // For simplicity, this implementation currently flushes denormals to zero. // It should be a fairly straightforward exercise to implement gradual // underflow with correct rounding. // //===----------------------------------------------------------------------===// #define SINGLE_PRECISION #include "fp_lib.h" COMPILER_RT_ABI fp_t __divsf3(fp_t a, fp_t b) { const unsigned int aExponent = toRep(a) >> significandBits & maxExponent; const unsigned int bExponent = toRep(b) >> significandBits & maxExponent; const rep_t quotientSign = (toRep(a) ^ toRep(b)) & signBit; rep_t aSignificand = toRep(a) & significandMask; rep_t bSignificand = toRep(b) & significandMask; int scale = 0; // Detect if a or b is zero, denormal, infinity, or NaN. if (aExponent-1U >= maxExponent-1U || bExponent-1U >= maxExponent-1U) { const rep_t aAbs = toRep(a) & absMask; const rep_t bAbs = toRep(b) & absMask; // NaN / anything = qNaN if (aAbs > infRep) return fromRep(toRep(a) | quietBit); // anything / NaN = qNaN if (bAbs > infRep) return fromRep(toRep(b) | quietBit); if (aAbs == infRep) { // infinity / infinity = NaN if (bAbs == infRep) return fromRep(qnanRep); // infinity / anything else = +/- infinity else return fromRep(aAbs | quotientSign); } // anything else / infinity = +/- 0 if (bAbs == infRep) return fromRep(quotientSign); if (!aAbs) { // zero / zero = NaN if (!bAbs) return fromRep(qnanRep); // zero / anything else = +/- zero else return fromRep(quotientSign); } // anything else / zero = +/- infinity if (!bAbs) return fromRep(infRep | quotientSign); // one or both of a or b is denormal, the other (if applicable) is a // normal number. Renormalize one or both of a and b, and set scale to // include the necessary exponent adjustment. if (aAbs < implicitBit) scale += normalize(&aSignificand); if (bAbs < implicitBit) scale -= normalize(&bSignificand); } // Or in the implicit significand bit. (If we fell through from the // denormal path it was already set by normalize( ), but setting it twice // won't hurt anything.) aSignificand |= implicitBit; bSignificand |= implicitBit; int quotientExponent = aExponent - bExponent + scale; // Align the significand of b as a Q31 fixed-point number in the range // [1, 2.0) and get a Q32 approximate reciprocal using a small minimax // polynomial approximation: reciprocal = 3/4 + 1/sqrt(2) - b/2. This // is accurate to about 3.5 binary digits. uint32_t q31b = bSignificand << 8; uint32_t reciprocal = UINT32_C(0x7504f333) - q31b; // Now refine the reciprocal estimate using a Newton-Raphson iteration: // // x1 = x0 * (2 - x0 * b) // // This doubles the number of correct binary digits in the approximation // with each iteration, so after three iterations, we have about 28 binary // digits of accuracy. uint32_t correction; correction = -((uint64_t)reciprocal * q31b >> 32); reciprocal = (uint64_t)reciprocal * correction >> 31; correction = -((uint64_t)reciprocal * q31b >> 32); reciprocal = (uint64_t)reciprocal * correction >> 31; correction = -((uint64_t)reciprocal * q31b >> 32); reciprocal = (uint64_t)reciprocal * correction >> 31; // Exhaustive testing shows that the error in reciprocal after three steps // is in the interval [-0x1.f58108p-31, 0x1.d0e48cp-29], in line with our // expectations. We bump the reciprocal by a tiny value to force the error // to be strictly positive (in the range [0x1.4fdfp-37,0x1.287246p-29], to // be specific). This also causes 1/1 to give a sensible approximation // instead of zero (due to overflow). reciprocal -= 2; // The numerical reciprocal is accurate to within 2^-28, lies in the // interval [0x1.000000eep-1, 0x1.fffffffcp-1], and is strictly smaller // than the true reciprocal of b. Multiplying a by this reciprocal thus // gives a numerical q = a/b in Q24 with the following properties: // // 1. q < a/b // 2. q is in the interval [0x1.000000eep-1, 0x1.fffffffcp0) // 3. the error in q is at most 2^-24 + 2^-27 -- the 2^24 term comes // from the fact that we truncate the product, and the 2^27 term // is the error in the reciprocal of b scaled by the maximum // possible value of a. As a consequence of this error bound, // either q or nextafter(q) is the correctly rounded rep_t quotient = (uint64_t)reciprocal*(aSignificand << 1) >> 32; // Two cases: quotient is in [0.5, 1.0) or quotient is in [1.0, 2.0). // In either case, we are going to compute a residual of the form // // r = a - q*b // // We know from the construction of q that r satisfies: // // 0 <= r < ulp(q)*b // // if r is greater than 1/2 ulp(q)*b, then q rounds up. Otherwise, we // already have the correct result. The exact halfway case cannot occur. // We also take this time to right shift quotient if it falls in the [1,2) // range and adjust the exponent accordingly. rep_t residual; if (quotient < (implicitBit << 1)) { residual = (aSignificand << 24) - quotient * bSignificand; quotientExponent--; } else { quotient >>= 1; residual = (aSignificand << 23) - quotient * bSignificand; } const int writtenExponent = quotientExponent + exponentBias; if (writtenExponent >= maxExponent) { // If we have overflowed the exponent, return infinity. return fromRep(infRep | quotientSign); } else if (writtenExponent < 1) { // Flush denormals to zero. In the future, it would be nice to add // code to round them correctly. return fromRep(quotientSign); } else { const bool round = (residual << 1) > bSignificand; // Clear the implicit bit rep_t absResult = quotient & significandMask; // Insert the exponent absResult |= (rep_t)writtenExponent << significandBits; // Round absResult += round; // Insert the sign and return return fromRep(absResult | quotientSign); } } #if defined(__ARM_EABI__) #if defined(COMPILER_RT_ARMHF_TARGET) AEABI_RTABI fp_t __aeabi_fdiv(fp_t a, fp_t b) { return __divsf3(a, b); } #else AEABI_RTABI fp_t __aeabi_fdiv(fp_t a, fp_t b) COMPILER_RT_ALIAS(__divsf3); #endif #endif ================================================ FILE: lib/libc/runtime/fixdfsi.c ================================================ /* ===-- fixdfsi.c - Implement __fixdfsi -----------------------------------=== * * The LLVM Compiler Infrastructure * * This file is dual licensed under the MIT and the University of Illinois Open * Source Licenses. See LICENSE.TXT for details. * * ===----------------------------------------------------------------------=== */ #define DOUBLE_PRECISION #include "fp_lib.h" typedef si_int fixint_t; typedef su_int fixuint_t; #include "fp_fixint_impl.inc" COMPILER_RT_ABI si_int __fixdfsi(fp_t a) { return __fixint(a); } #if defined(__ARM_EABI__) #if defined(COMPILER_RT_ARMHF_TARGET) AEABI_RTABI si_int __aeabi_d2iz(fp_t a) { return __fixdfsi(a); } #else AEABI_RTABI si_int __aeabi_d2iz(fp_t a) COMPILER_RT_ALIAS(__fixdfsi); #endif #endif ================================================ FILE: lib/libc/runtime/fixsfsi.c ================================================ /* ===-- fixsfsi.c - Implement __fixsfsi -----------------------------------=== * * The LLVM Compiler Infrastructure * * This file is dual licensed under the MIT and the University of Illinois Open * Source Licenses. See LICENSE.TXT for details. * * ===----------------------------------------------------------------------=== */ #define SINGLE_PRECISION #include "fp_lib.h" typedef si_int fixint_t; typedef su_int fixuint_t; #include "fp_fixint_impl.inc" COMPILER_RT_ABI si_int __fixsfsi(fp_t a) { return __fixint(a); } #if defined(__ARM_EABI__) #if defined(COMPILER_RT_ARMHF_TARGET) AEABI_RTABI si_int __aeabi_f2iz(fp_t a) { return __fixsfsi(a); } #else AEABI_RTABI si_int __aeabi_f2iz(fp_t a) COMPILER_RT_ALIAS(__fixsfsi); #endif #endif ================================================ FILE: lib/libc/runtime/fixunsdfsi.c ================================================ /* ===-- fixunsdfsi.c - Implement __fixunsdfsi -----------------------------=== * * The LLVM Compiler Infrastructure * * This file is dual licensed under the MIT and the University of Illinois Open * Source Licenses. See LICENSE.TXT for details. * * ===----------------------------------------------------------------------=== */ #define DOUBLE_PRECISION #include "fp_lib.h" typedef su_int fixuint_t; #include "fp_fixuint_impl.inc" COMPILER_RT_ABI su_int __fixunsdfsi(fp_t a) { return __fixuint(a); } #if defined(__ARM_EABI__) #if defined(COMPILER_RT_ARMHF_TARGET) AEABI_RTABI su_int __aeabi_d2uiz(fp_t a) { return __fixunsdfsi(a); } #else AEABI_RTABI su_int __aeabi_d2uiz(fp_t a) COMPILER_RT_ALIAS(__fixunsdfsi); #endif #endif ================================================ FILE: lib/libc/runtime/fixunssfsi.c ================================================ /* ===-- fixunssfsi.c - Implement __fixunssfsi -----------------------------=== * * The LLVM Compiler Infrastructure * * This file is dual licensed under the MIT and the University of Illinois Open * Source Licenses. See LICENSE.TXT for details. * * ===----------------------------------------------------------------------=== * * This file implements __fixunssfsi for the compiler_rt library. * * ===----------------------------------------------------------------------=== */ #define SINGLE_PRECISION #include "fp_lib.h" typedef su_int fixuint_t; #include "fp_fixuint_impl.inc" COMPILER_RT_ABI su_int __fixunssfsi(fp_t a) { return __fixuint(a); } #if defined(__ARM_EABI__) #if defined(COMPILER_RT_ARMHF_TARGET) AEABI_RTABI su_int __aeabi_f2uiz(fp_t a) { return __fixunssfsi(a); } #else AEABI_RTABI su_int __aeabi_f2uiz(fp_t a) COMPILER_RT_ALIAS(__fixunssfsi); #endif #endif ================================================ FILE: lib/libc/runtime/floatsidf.c ================================================ //===-- lib/floatsidf.c - integer -> double-precision conversion --*- C -*-===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // This file implements integer to double-precision conversion for the // compiler-rt library in the IEEE-754 default round-to-nearest, ties-to-even // mode. // //===----------------------------------------------------------------------===// #define DOUBLE_PRECISION #include "fp_lib.h" #include "int_lib.h" COMPILER_RT_ABI fp_t __floatsidf(int a) { const int aWidth = sizeof a * CHAR_BIT; // Handle zero as a special case to protect clz if (a == 0) return fromRep(0); // All other cases begin by extracting the sign and absolute value of a rep_t sign = 0; if (a < 0) { sign = signBit; a = -a; } // Exponent of (fp_t)a is the width of abs(a). const int exponent = (aWidth - 1) - __builtin_clz(a); rep_t result; // Shift a into the significand field and clear the implicit bit. Extra // cast to unsigned int is necessary to get the correct behavior for // the input INT_MIN. const int shift = significandBits - exponent; result = (rep_t)(unsigned int)a << shift ^ implicitBit; // Insert the exponent result += (rep_t)(exponent + exponentBias) << significandBits; // Insert the sign bit and return return fromRep(result | sign); } #if defined(__ARM_EABI__) #if defined(COMPILER_RT_ARMHF_TARGET) AEABI_RTABI fp_t __aeabi_i2d(int a) { return __floatsidf(a); } #else AEABI_RTABI fp_t __aeabi_i2d(int a) COMPILER_RT_ALIAS(__floatsidf); #endif #endif ================================================ FILE: lib/libc/runtime/floatsisf.c ================================================ //===-- lib/floatsisf.c - integer -> single-precision conversion --*- C -*-===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // This file implements integer to single-precision conversion for the // compiler-rt library in the IEEE-754 default round-to-nearest, ties-to-even // mode. // //===----------------------------------------------------------------------===// #define SINGLE_PRECISION #include "fp_lib.h" #include "int_lib.h" COMPILER_RT_ABI fp_t __floatsisf(int a) { const int aWidth = sizeof a * CHAR_BIT; // Handle zero as a special case to protect clz if (a == 0) return fromRep(0); // All other cases begin by extracting the sign and absolute value of a rep_t sign = 0; if (a < 0) { sign = signBit; a = -a; } // Exponent of (fp_t)a is the width of abs(a). const int exponent = (aWidth - 1) - __builtin_clz(a); rep_t result; // Shift a into the significand field, rounding if it is a right-shift if (exponent <= significandBits) { const int shift = significandBits - exponent; result = (rep_t)a << shift ^ implicitBit; } else { const int shift = exponent - significandBits; result = (rep_t)a >> shift ^ implicitBit; rep_t round = (rep_t)a << (typeWidth - shift); if (round > signBit) result++; if (round == signBit) result += result & 1; } // Insert the exponent result += (rep_t)(exponent + exponentBias) << significandBits; // Insert the sign bit and return return fromRep(result | sign); } #if defined(__ARM_EABI__) #if defined(COMPILER_RT_ARMHF_TARGET) AEABI_RTABI fp_t __aeabi_i2f(int a) { return __floatsisf(a); } #else AEABI_RTABI fp_t __aeabi_i2f(int a) COMPILER_RT_ALIAS(__floatsisf); #endif #endif ================================================ FILE: lib/libc/runtime/floatunsidf.c ================================================ //===-- lib/floatunsidf.c - uint -> double-precision conversion ---*- C -*-===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // This file implements unsigned integer to double-precision conversion for the // compiler-rt library in the IEEE-754 default round-to-nearest, ties-to-even // mode. // //===----------------------------------------------------------------------===// #define DOUBLE_PRECISION #include "fp_lib.h" #include "int_lib.h" COMPILER_RT_ABI fp_t __floatunsidf(unsigned int a) { const int aWidth = sizeof a * CHAR_BIT; // Handle zero as a special case to protect clz if (a == 0) return fromRep(0); // Exponent of (fp_t)a is the width of abs(a). const int exponent = (aWidth - 1) - __builtin_clz(a); rep_t result; // Shift a into the significand field and clear the implicit bit. const int shift = significandBits - exponent; result = (rep_t)a << shift ^ implicitBit; // Insert the exponent result += (rep_t)(exponent + exponentBias) << significandBits; return fromRep(result); } #if defined(__ARM_EABI__) #if defined(COMPILER_RT_ARMHF_TARGET) AEABI_RTABI fp_t __aeabi_ui2d(unsigned int a) { return __floatunsidf(a); } #else AEABI_RTABI fp_t __aeabi_ui2d(unsigned int a) COMPILER_RT_ALIAS(__floatunsidf); #endif #endif ================================================ FILE: lib/libc/runtime/floatunsisf.c ================================================ //===-- lib/floatunsisf.c - uint -> single-precision conversion ---*- C -*-===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // This file implements unsigned integer to single-precision conversion for the // compiler-rt library in the IEEE-754 default round-to-nearest, ties-to-even // mode. // //===----------------------------------------------------------------------===// #define SINGLE_PRECISION #include "fp_lib.h" #include "int_lib.h" COMPILER_RT_ABI fp_t __floatunsisf(unsigned int a) { const int aWidth = sizeof a * CHAR_BIT; // Handle zero as a special case to protect clz if (a == 0) return fromRep(0); // Exponent of (fp_t)a is the width of abs(a). const int exponent = (aWidth - 1) - __builtin_clz(a); rep_t result; // Shift a into the significand field, rounding if it is a right-shift if (exponent <= significandBits) { const int shift = significandBits - exponent; result = (rep_t)a << shift ^ implicitBit; } else { const int shift = exponent - significandBits; result = (rep_t)a >> shift ^ implicitBit; rep_t round = (rep_t)a << (typeWidth - shift); if (round > signBit) result++; if (round == signBit) result += result & 1; } // Insert the exponent result += (rep_t)(exponent + exponentBias) << significandBits; return fromRep(result); } #if defined(__ARM_EABI__) #if defined(COMPILER_RT_ARMHF_TARGET) AEABI_RTABI fp_t __aeabi_ui2f(unsigned int a) { return __floatunsisf(a); } #else AEABI_RTABI fp_t __aeabi_ui2f(unsigned int a) COMPILER_RT_ALIAS(__floatunsisf); #endif #endif ================================================ FILE: lib/libc/runtime/fp_add_impl.inc ================================================ //===----- lib/fp_add_impl.inc - floating point addition ----------*- C -*-===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // This file implements soft-float addition with the IEEE-754 default rounding // (to nearest, ties to even). // //===----------------------------------------------------------------------===// #include "fp_lib.h" static __inline fp_t __addXf3__(fp_t a, fp_t b) { rep_t aRep = toRep(a); rep_t bRep = toRep(b); const rep_t aAbs = aRep & absMask; const rep_t bAbs = bRep & absMask; // Detect if a or b is zero, infinity, or NaN. if (aAbs - REP_C(1) >= infRep - REP_C(1) || bAbs - REP_C(1) >= infRep - REP_C(1)) { // NaN + anything = qNaN if (aAbs > infRep) return fromRep(toRep(a) | quietBit); // anything + NaN = qNaN if (bAbs > infRep) return fromRep(toRep(b) | quietBit); if (aAbs == infRep) { // +/-infinity + -/+infinity = qNaN if ((toRep(a) ^ toRep(b)) == signBit) return fromRep(qnanRep); // +/-infinity + anything remaining = +/- infinity else return a; } // anything remaining + +/-infinity = +/-infinity if (bAbs == infRep) return b; // zero + anything = anything if (!aAbs) { // but we need to get the sign right for zero + zero if (!bAbs) return fromRep(toRep(a) & toRep(b)); else return b; } // anything + zero = anything if (!bAbs) return a; } // Swap a and b if necessary so that a has the larger absolute value. if (bAbs > aAbs) { const rep_t temp = aRep; aRep = bRep; bRep = temp; } // Extract the exponent and significand from the (possibly swapped) a and b. int aExponent = aRep >> significandBits & maxExponent; int bExponent = bRep >> significandBits & maxExponent; rep_t aSignificand = aRep & significandMask; rep_t bSignificand = bRep & significandMask; // Normalize any denormals, and adjust the exponent accordingly. if (aExponent == 0) aExponent = normalize(&aSignificand); if (bExponent == 0) bExponent = normalize(&bSignificand); // The sign of the result is the sign of the larger operand, a. If they // have opposite signs, we are performing a subtraction; otherwise addition. const rep_t resultSign = aRep & signBit; const bool subtraction = (aRep ^ bRep) & signBit; // Shift the significands to give us round, guard and sticky, and or in the // implicit significand bit. (If we fell through from the denormal path it // was already set by normalize( ), but setting it twice won't hurt // anything.) aSignificand = (aSignificand | implicitBit) << 3; bSignificand = (bSignificand | implicitBit) << 3; // Shift the significand of b by the difference in exponents, with a sticky // bottom bit to get rounding correct. const unsigned int align = aExponent - bExponent; if (align) { if (align < typeWidth) { const bool sticky = bSignificand << (typeWidth - align); bSignificand = bSignificand >> align | sticky; } else { bSignificand = 1; // sticky; b is known to be non-zero. } } if (subtraction) { aSignificand -= bSignificand; // If a == -b, return +zero. if (aSignificand == 0) return fromRep(0); // If partial cancellation occurred, we need to left-shift the result // and adjust the exponent: if (aSignificand < implicitBit << 3) { const int shift = rep_clz(aSignificand) - rep_clz(implicitBit << 3); aSignificand <<= shift; aExponent -= shift; } } else /* addition */ { aSignificand += bSignificand; // If the addition carried up, we need to right-shift the result and // adjust the exponent: if (aSignificand & implicitBit << 4) { const bool sticky = aSignificand & 1; aSignificand = aSignificand >> 1 | sticky; aExponent += 1; } } // If we have overflowed the type, return +/- infinity: if (aExponent >= maxExponent) return fromRep(infRep | resultSign); if (aExponent <= 0) { // Result is denormal before rounding; the exponent is zero and we // need to shift the significand. const int shift = 1 - aExponent; const bool sticky = aSignificand << (typeWidth - shift); aSignificand = aSignificand >> shift | sticky; aExponent = 0; } // Low three bits are round, guard, and sticky. const int roundGuardSticky = aSignificand & 0x7; // Shift the significand into place, and mask off the implicit bit. rep_t result = aSignificand >> 3 & significandMask; // Insert the exponent and sign. result |= (rep_t)aExponent << significandBits; result |= resultSign; // Final rounding. The result may overflow to infinity, but that is the // correct result in that case. if (roundGuardSticky > 0x4) result++; if (roundGuardSticky == 0x4) result += result & 1; return fromRep(result); } ================================================ FILE: lib/libc/runtime/fp_fixint_impl.inc ================================================ //===-- lib/fixdfsi.c - Double-precision -> integer conversion ----*- C -*-===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // This file implements float to integer conversion for the // compiler-rt library. // //===----------------------------------------------------------------------===// #include "fp_lib.h" static __inline fixint_t __fixint(fp_t a) { const fixint_t fixint_max = (fixint_t)((~(fixuint_t)0) / 2); const fixint_t fixint_min = -fixint_max - 1; // Break a into sign, exponent, significand const rep_t aRep = toRep(a); const rep_t aAbs = aRep & absMask; const fixint_t sign = aRep & signBit ? -1 : 1; const int exponent = (aAbs >> significandBits) - exponentBias; const rep_t significand = (aAbs & significandMask) | implicitBit; // If exponent is negative, the result is zero. if (exponent < 0) return 0; // If the value is too large for the integer type, saturate. if ((unsigned)exponent >= sizeof(fixint_t) * CHAR_BIT) return sign == 1 ? fixint_max : fixint_min; // If 0 <= exponent < significandBits, right shift to get the result. // Otherwise, shift left. if (exponent < significandBits) return sign * (significand >> (significandBits - exponent)); else return sign * ((fixint_t)significand << (exponent - significandBits)); } ================================================ FILE: lib/libc/runtime/fp_fixuint_impl.inc ================================================ //===-- lib/fixdfsi.c - Double-precision -> integer conversion ----*- C -*-===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // This file implements float to unsigned integer conversion for the // compiler-rt library. // //===----------------------------------------------------------------------===// #include "fp_lib.h" static __inline fixuint_t __fixuint(fp_t a) { // Break a into sign, exponent, significand const rep_t aRep = toRep(a); const rep_t aAbs = aRep & absMask; const int sign = aRep & signBit ? -1 : 1; const int exponent = (aAbs >> significandBits) - exponentBias; const rep_t significand = (aAbs & significandMask) | implicitBit; // If either the value or the exponent is negative, the result is zero. if (sign == -1 || exponent < 0) return 0; // If the value is too large for the integer type, saturate. if ((unsigned)exponent >= sizeof(fixuint_t) * CHAR_BIT) return ~(fixuint_t)0; // If 0 <= exponent < significandBits, right shift to get the result. // Otherwise, shift left. if (exponent < significandBits) return significand >> (significandBits - exponent); else return (fixuint_t)significand << (exponent - significandBits); } ================================================ FILE: lib/libc/runtime/fp_lib.h ================================================ //===-- lib/fp_lib.h - Floating-point utilities -------------------*- C -*-===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // This file is a configuration header for soft-float routines in compiler-rt. // This file does not provide any part of the compiler-rt interface, but defines // many useful constants and utility routines that are used in the // implementation of the soft-float routines in compiler-rt. // // Assumes that float, double and long double correspond to the IEEE-754 // binary32, binary64 and binary128 types, respectively, and that integer // endianness matches floating point endianness on the target platform. // //===----------------------------------------------------------------------===// #ifndef FP_LIB_HEADER #define FP_LIB_HEADER #include #include #include #include "int_lib.h" // x86_64 FreeBSD prior v9.3 define fixed-width types incorrectly in // 32-bit mode. #if defined(__FreeBSD__) && defined(__i386__) # include # if __FreeBSD_version < 903000 // v9.3 # define uint64_t unsigned long long # define int64_t long long # undef UINT64_C # define UINT64_C(c) (c ## ULL) # endif #endif #if defined SINGLE_PRECISION typedef uint32_t rep_t; typedef int32_t srep_t; typedef float fp_t; #define REP_C UINT32_C #define significandBits 23 static __inline int rep_clz(rep_t a) { return __builtin_clz(a); } // 32x32 --> 64 bit multiply static __inline void wideMultiply(rep_t a, rep_t b, rep_t *hi, rep_t *lo) { const uint64_t product = (uint64_t)a*b; *hi = product >> 32; *lo = product; } COMPILER_RT_ABI fp_t __addsf3(fp_t a, fp_t b); #elif defined DOUBLE_PRECISION typedef uint64_t rep_t; typedef int64_t srep_t; typedef double fp_t; #define REP_C UINT64_C #define significandBits 52 static __inline int rep_clz(rep_t a) { #if defined __LP64__ return __builtin_clzl(a); #else if (a & REP_C(0xffffffff00000000)) return __builtin_clz(a >> 32); else return 32 + __builtin_clz(a & REP_C(0xffffffff)); #endif } #define loWord(a) (a & 0xffffffffU) #define hiWord(a) (a >> 32) // 64x64 -> 128 wide multiply for platforms that don't have such an operation; // many 64-bit platforms have this operation, but they tend to have hardware // floating-point, so we don't bother with a special case for them here. static __inline void wideMultiply(rep_t a, rep_t b, rep_t *hi, rep_t *lo) { // Each of the component 32x32 -> 64 products const uint64_t plolo = loWord(a) * loWord(b); const uint64_t plohi = loWord(a) * hiWord(b); const uint64_t philo = hiWord(a) * loWord(b); const uint64_t phihi = hiWord(a) * hiWord(b); // Sum terms that contribute to lo in a way that allows us to get the carry const uint64_t r0 = loWord(plolo); const uint64_t r1 = hiWord(plolo) + loWord(plohi) + loWord(philo); *lo = r0 + (r1 << 32); // Sum terms contributing to hi with the carry from lo *hi = hiWord(plohi) + hiWord(philo) + hiWord(r1) + phihi; } #undef loWord #undef hiWord COMPILER_RT_ABI fp_t __adddf3(fp_t a, fp_t b); #elif defined QUAD_PRECISION #if __LDBL_MANT_DIG__ == 113 #define CRT_LDBL_128BIT typedef __uint128_t rep_t; typedef __int128_t srep_t; typedef long double fp_t; #define REP_C (__uint128_t) // Note: Since there is no explicit way to tell compiler the constant is a // 128-bit integer, we let the constant be casted to 128-bit integer #define significandBits 112 static __inline int rep_clz(rep_t a) { const union { __uint128_t ll; #if _YUGA_BIG_ENDIAN struct { uint64_t high, low; } s; #else struct { uint64_t low, high; } s; #endif } uu = { .ll = a }; uint64_t word; uint64_t add; if (uu.s.high){ word = uu.s.high; add = 0; } else{ word = uu.s.low; add = 64; } return __builtin_clzll(word) + add; } #define Word_LoMask UINT64_C(0x00000000ffffffff) #define Word_HiMask UINT64_C(0xffffffff00000000) #define Word_FullMask UINT64_C(0xffffffffffffffff) #define Word_1(a) (uint64_t)((a >> 96) & Word_LoMask) #define Word_2(a) (uint64_t)((a >> 64) & Word_LoMask) #define Word_3(a) (uint64_t)((a >> 32) & Word_LoMask) #define Word_4(a) (uint64_t)(a & Word_LoMask) // 128x128 -> 256 wide multiply for platforms that don't have such an operation; // many 64-bit platforms have this operation, but they tend to have hardware // floating-point, so we don't bother with a special case for them here. static __inline void wideMultiply(rep_t a, rep_t b, rep_t *hi, rep_t *lo) { const uint64_t product11 = Word_1(a) * Word_1(b); const uint64_t product12 = Word_1(a) * Word_2(b); const uint64_t product13 = Word_1(a) * Word_3(b); const uint64_t product14 = Word_1(a) * Word_4(b); const uint64_t product21 = Word_2(a) * Word_1(b); const uint64_t product22 = Word_2(a) * Word_2(b); const uint64_t product23 = Word_2(a) * Word_3(b); const uint64_t product24 = Word_2(a) * Word_4(b); const uint64_t product31 = Word_3(a) * Word_1(b); const uint64_t product32 = Word_3(a) * Word_2(b); const uint64_t product33 = Word_3(a) * Word_3(b); const uint64_t product34 = Word_3(a) * Word_4(b); const uint64_t product41 = Word_4(a) * Word_1(b); const uint64_t product42 = Word_4(a) * Word_2(b); const uint64_t product43 = Word_4(a) * Word_3(b); const uint64_t product44 = Word_4(a) * Word_4(b); const __uint128_t sum0 = (__uint128_t)product44; const __uint128_t sum1 = (__uint128_t)product34 + (__uint128_t)product43; const __uint128_t sum2 = (__uint128_t)product24 + (__uint128_t)product33 + (__uint128_t)product42; const __uint128_t sum3 = (__uint128_t)product14 + (__uint128_t)product23 + (__uint128_t)product32 + (__uint128_t)product41; const __uint128_t sum4 = (__uint128_t)product13 + (__uint128_t)product22 + (__uint128_t)product31; const __uint128_t sum5 = (__uint128_t)product12 + (__uint128_t)product21; const __uint128_t sum6 = (__uint128_t)product11; const __uint128_t r0 = (sum0 & Word_FullMask) + ((sum1 & Word_LoMask) << 32); const __uint128_t r1 = (sum0 >> 64) + ((sum1 >> 32) & Word_FullMask) + (sum2 & Word_FullMask) + ((sum3 << 32) & Word_HiMask); *lo = r0 + (r1 << 64); *hi = (r1 >> 64) + (sum1 >> 96) + (sum2 >> 64) + (sum3 >> 32) + sum4 + (sum5 << 32) + (sum6 << 64); } #undef Word_1 #undef Word_2 #undef Word_3 #undef Word_4 #undef Word_HiMask #undef Word_LoMask #undef Word_FullMask #endif // __LDBL_MANT_DIG__ == 113 #else #error SINGLE_PRECISION, DOUBLE_PRECISION or QUAD_PRECISION must be defined. #endif #if defined(SINGLE_PRECISION) || defined(DOUBLE_PRECISION) || defined(CRT_LDBL_128BIT) #define typeWidth (sizeof(rep_t)*CHAR_BIT) #define exponentBits (typeWidth - significandBits - 1) #define maxExponent ((1 << exponentBits) - 1) #define exponentBias (maxExponent >> 1) #define implicitBit (REP_C(1) << significandBits) #define significandMask (implicitBit - 1U) #define signBit (REP_C(1) << (significandBits + exponentBits)) #define absMask (signBit - 1U) #define exponentMask (absMask ^ significandMask) #define oneRep ((rep_t)exponentBias << significandBits) #define infRep exponentMask #define quietBit (implicitBit >> 1) #define qnanRep (exponentMask | quietBit) static __inline rep_t toRep(fp_t x) { const union { fp_t f; rep_t i; } rep = {.f = x}; return rep.i; } static __inline fp_t fromRep(rep_t x) { const union { fp_t f; rep_t i; } rep = {.i = x}; return rep.f; } static __inline int normalize(rep_t *significand) { const int shift = rep_clz(*significand) - rep_clz(implicitBit); *significand <<= shift; return 1 - shift; } static __inline void wideLeftShift(rep_t *hi, rep_t *lo, int count) { *hi = *hi << count | *lo >> (typeWidth - count); *lo = *lo << count; } static __inline void wideRightShiftWithSticky(rep_t *hi, rep_t *lo, unsigned int count) { if (count < typeWidth) { const bool sticky = *lo << (typeWidth - count); *lo = *hi << (typeWidth - count) | *lo >> count | sticky; *hi = *hi >> count; } else if (count < 2*typeWidth) { const bool sticky = *hi << (2*typeWidth - count) | *lo; *lo = *hi >> (count - typeWidth) | sticky; *hi = 0; } else { const bool sticky = *hi | *lo; *lo = sticky; *hi = 0; } } #endif #endif // FP_LIB_HEADER ================================================ FILE: lib/libc/runtime/fp_mul_impl.inc ================================================ //===---- lib/fp_mul_impl.inc - floating point multiplication -----*- C -*-===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // This file implements soft-float multiplication with the IEEE-754 default // rounding (to nearest, ties to even). // //===----------------------------------------------------------------------===// #include "fp_lib.h" static __inline fp_t __mulXf3__(fp_t a, fp_t b) { const unsigned int aExponent = toRep(a) >> significandBits & maxExponent; const unsigned int bExponent = toRep(b) >> significandBits & maxExponent; const rep_t productSign = (toRep(a) ^ toRep(b)) & signBit; rep_t aSignificand = toRep(a) & significandMask; rep_t bSignificand = toRep(b) & significandMask; int scale = 0; // Detect if a or b is zero, denormal, infinity, or NaN. if (aExponent-1U >= maxExponent-1U || bExponent-1U >= maxExponent-1U) { const rep_t aAbs = toRep(a) & absMask; const rep_t bAbs = toRep(b) & absMask; // NaN * anything = qNaN if (aAbs > infRep) return fromRep(toRep(a) | quietBit); // anything * NaN = qNaN if (bAbs > infRep) return fromRep(toRep(b) | quietBit); if (aAbs == infRep) { // infinity * non-zero = +/- infinity if (bAbs) return fromRep(aAbs | productSign); // infinity * zero = NaN else return fromRep(qnanRep); } if (bAbs == infRep) { // non-zero * infinity = +/- infinity if (aAbs) return fromRep(bAbs | productSign); // zero * infinity = NaN else return fromRep(qnanRep); } // zero * anything = +/- zero if (!aAbs) return fromRep(productSign); // anything * zero = +/- zero if (!bAbs) return fromRep(productSign); // one or both of a or b is denormal, the other (if applicable) is a // normal number. Renormalize one or both of a and b, and set scale to // include the necessary exponent adjustment. if (aAbs < implicitBit) scale += normalize(&aSignificand); if (bAbs < implicitBit) scale += normalize(&bSignificand); } // Or in the implicit significand bit. (If we fell through from the // denormal path it was already set by normalize( ), but setting it twice // won't hurt anything.) aSignificand |= implicitBit; bSignificand |= implicitBit; // Get the significand of a*b. Before multiplying the significands, shift // one of them left to left-align it in the field. Thus, the product will // have (exponentBits + 2) integral digits, all but two of which must be // zero. Normalizing this result is just a conditional left-shift by one // and bumping the exponent accordingly. rep_t productHi, productLo; wideMultiply(aSignificand, bSignificand << exponentBits, &productHi, &productLo); int productExponent = aExponent + bExponent - exponentBias + scale; // Normalize the significand, adjust exponent if needed. if (productHi & implicitBit) productExponent++; else wideLeftShift(&productHi, &productLo, 1); // If we have overflowed the type, return +/- infinity. if (productExponent >= maxExponent) return fromRep(infRep | productSign); if (productExponent <= 0) { // Result is denormal before rounding // // If the result is so small that it just underflows to zero, return // a zero of the appropriate sign. Mathematically there is no need to // handle this case separately, but we make it a special case to // simplify the shift logic. const unsigned int shift = REP_C(1) - (unsigned int)productExponent; if (shift >= typeWidth) return fromRep(productSign); // Otherwise, shift the significand of the result so that the round // bit is the high bit of productLo. wideRightShiftWithSticky(&productHi, &productLo, shift); } else { // Result is normal before rounding; insert the exponent. productHi &= significandMask; productHi |= (rep_t)productExponent << significandBits; } // Insert the sign of the result: productHi |= productSign; // Final rounding. The final result may overflow to infinity, or underflow // to zero, but those are the correct results in those cases. We use the // default IEEE-754 round-to-nearest, ties-to-even rounding mode. if (productLo > signBit) productHi++; if (productLo == signBit) productHi += productHi & 1; return fromRep(productHi); } ================================================ FILE: lib/libc/runtime/int_endianness.h ================================================ /* ===-- int_endianness.h - configuration header for compiler-rt ------------=== * * The LLVM Compiler Infrastructure * * This file is dual licensed under the MIT and the University of Illinois Open * Source Licenses. See LICENSE.TXT for details. * * ===----------------------------------------------------------------------=== * * This file is a configuration header for compiler-rt. * This file is not part of the interface of this library. * * ===----------------------------------------------------------------------=== */ #ifndef INT_ENDIANNESS_H #define INT_ENDIANNESS_H #if defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && \ defined(__ORDER_LITTLE_ENDIAN__) /* Clang and GCC provide built-in endianness definitions. */ #if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ #define _YUGA_LITTLE_ENDIAN 0 #define _YUGA_BIG_ENDIAN 1 #elif __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ #define _YUGA_LITTLE_ENDIAN 1 #define _YUGA_BIG_ENDIAN 0 #endif /* __BYTE_ORDER__ */ #else /* Compilers other than Clang or GCC. */ #if defined(__SVR4) && defined(__sun) #include #if defined(_BIG_ENDIAN) #define _YUGA_LITTLE_ENDIAN 0 #define _YUGA_BIG_ENDIAN 1 #elif defined(_LITTLE_ENDIAN) #define _YUGA_LITTLE_ENDIAN 1 #define _YUGA_BIG_ENDIAN 0 #else /* !_LITTLE_ENDIAN */ #error "unknown endianness" #endif /* !_LITTLE_ENDIAN */ #endif /* Solaris and AuroraUX. */ /* .. */ #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__) || \ defined(__minix) #include #if _BYTE_ORDER == _BIG_ENDIAN #define _YUGA_LITTLE_ENDIAN 0 #define _YUGA_BIG_ENDIAN 1 #elif _BYTE_ORDER == _LITTLE_ENDIAN #define _YUGA_LITTLE_ENDIAN 1 #define _YUGA_BIG_ENDIAN 0 #endif /* _BYTE_ORDER */ #endif /* *BSD */ #if defined(__OpenBSD__) #include #if _BYTE_ORDER == _BIG_ENDIAN #define _YUGA_LITTLE_ENDIAN 0 #define _YUGA_BIG_ENDIAN 1 #elif _BYTE_ORDER == _LITTLE_ENDIAN #define _YUGA_LITTLE_ENDIAN 1 #define _YUGA_BIG_ENDIAN 0 #endif /* _BYTE_ORDER */ #endif /* OpenBSD */ /* .. */ /* Mac OSX has __BIG_ENDIAN__ or __LITTLE_ENDIAN__ automatically set by the * compiler (at least with GCC) */ #if defined(__APPLE__) || defined(__ellcc__ ) #ifdef __BIG_ENDIAN__ #if __BIG_ENDIAN__ #define _YUGA_LITTLE_ENDIAN 0 #define _YUGA_BIG_ENDIAN 1 #endif #endif /* __BIG_ENDIAN__ */ #ifdef __LITTLE_ENDIAN__ #if __LITTLE_ENDIAN__ #define _YUGA_LITTLE_ENDIAN 1 #define _YUGA_BIG_ENDIAN 0 #endif #endif /* __LITTLE_ENDIAN__ */ #endif /* Mac OSX */ /* .. */ #if defined(_WIN32) #define _YUGA_LITTLE_ENDIAN 1 #define _YUGA_BIG_ENDIAN 0 #endif /* Windows */ #endif /* Clang or GCC. */ /* . */ #if !defined(_YUGA_LITTLE_ENDIAN) || !defined(_YUGA_BIG_ENDIAN) #error Unable to determine endian #endif /* Check we found an endianness correctly. */ #endif /* INT_ENDIANNESS_H */ ================================================ FILE: lib/libc/runtime/int_lib.h ================================================ /* ===-- int_lib.h - configuration header for compiler-rt -----------------=== * * The LLVM Compiler Infrastructure * * This file is dual licensed under the MIT and the University of Illinois Open * Source Licenses. See LICENSE.TXT for details. * * ===----------------------------------------------------------------------=== * * This file is a configuration header for compiler-rt. * This file is not part of the interface of this library. * * ===----------------------------------------------------------------------=== */ #ifndef INT_LIB_H #define INT_LIB_H /* Assumption: Signed integral is 2's complement. */ /* Assumption: Right shift of signed negative is arithmetic shift. */ /* Assumption: Endianness is little or big (not mixed). */ #if defined(__ELF__) #define FNALIAS(alias_name, original_name) \ void alias_name() __attribute__((__alias__(#original_name))) #define COMPILER_RT_ALIAS(aliasee) __attribute__((__alias__(#aliasee))) #else #define FNALIAS(alias, name) _Pragma("GCC error(\"alias unsupported on this file format\")") #define COMPILER_RT_ALIAS(aliasee) _Pragma("GCC error(\"alias unsupported on this file format\")") #endif /* ABI macro definitions */ #if __ARM_EABI__ # ifdef COMPILER_RT_ARMHF_TARGET # define COMPILER_RT_ABI # else # define COMPILER_RT_ABI __attribute__((__pcs__("aapcs"))) # endif #else # define COMPILER_RT_ABI #endif #define AEABI_RTABI __attribute__((__pcs__("aapcs"))) #ifdef _MSC_VER #define ALWAYS_INLINE __forceinline #define NOINLINE __declspec(noinline) #define NORETURN __declspec(noreturn) #define UNUSED #else #define ALWAYS_INLINE __attribute__((always_inline)) #define NOINLINE __attribute__((noinline)) #define NORETURN __attribute__((noreturn)) #define UNUSED __attribute__((unused)) #endif #if defined(__NetBSD__) && (defined(_KERNEL) || defined(_STANDALONE)) /* * Kernel and boot environment can't use normal headers, * so use the equivalent system headers. */ # include # include # include #else /* Include the standard compiler builtin headers we use functionality from. */ # include # include # include # include #endif /* Include the commonly used internal type definitions. */ #include "int_types.h" /* Include internal utility function declarations. */ #include "int_util.h" COMPILER_RT_ABI si_int __paritysi2(si_int a); COMPILER_RT_ABI si_int __paritydi2(di_int a); COMPILER_RT_ABI di_int __divdi3(di_int a, di_int b); COMPILER_RT_ABI si_int __divsi3(si_int a, si_int b); COMPILER_RT_ABI su_int __udivsi3(su_int n, su_int d); COMPILER_RT_ABI su_int __udivmodsi4(su_int a, su_int b, su_int* rem); COMPILER_RT_ABI du_int __udivmoddi4(du_int a, du_int b, du_int* rem); #ifdef CRT_HAS_128BIT COMPILER_RT_ABI si_int __clzti2(ti_int a); COMPILER_RT_ABI tu_int __udivmodti4(tu_int a, tu_int b, tu_int* rem); #endif /* Definitions for builtins unavailable on MSVC */ #if defined(_MSC_VER) && !defined(__clang__) #include uint32_t __inline __builtin_ctz(uint32_t value) { unsigned long trailing_zero = 0; if (_BitScanForward(&trailing_zero, value)) return trailing_zero; return 32; } uint32_t __inline __builtin_clz(uint32_t value) { unsigned long leading_zero = 0; if (_BitScanReverse(&leading_zero, value)) return 31 - leading_zero; return 32; } #if defined(_M_ARM) || defined(_M_X64) uint32_t __inline __builtin_clzll(uint64_t value) { unsigned long leading_zero = 0; if (_BitScanReverse64(&leading_zero, value)) return 63 - leading_zero; return 64; } #else uint32_t __inline __builtin_clzll(uint64_t value) { if (value == 0) return 64; uint32_t msh = (uint32_t)(value >> 32); uint32_t lsh = (uint32_t)(value & 0xFFFFFFFF); if (msh != 0) return __builtin_clz(msh); return 32 + __builtin_clz(lsh); } #endif #define __builtin_clzl __builtin_clzll #endif /* defined(_MSC_VER) && !defined(__clang__) */ #endif /* INT_LIB_H */ ================================================ FILE: lib/libc/runtime/int_types.h ================================================ /* ===-- int_lib.h - configuration header for compiler-rt -----------------=== * * The LLVM Compiler Infrastructure * * This file is dual licensed under the MIT and the University of Illinois Open * Source Licenses. See LICENSE.TXT for details. * * ===----------------------------------------------------------------------=== * * This file is not part of the interface of this library. * * This file defines various standard types, most importantly a number of unions * used to access parts of larger types. * * ===----------------------------------------------------------------------=== */ #ifndef INT_TYPES_H #define INT_TYPES_H #include "int_endianness.h" /* si_int is defined in Linux sysroot's asm-generic/siginfo.h */ #ifdef si_int #undef si_int #endif typedef int si_int; typedef unsigned su_int; typedef long long di_int; typedef unsigned long long du_int; typedef union { di_int all; struct { #if _YUGA_LITTLE_ENDIAN su_int low; si_int high; #else si_int high; su_int low; #endif /* _YUGA_LITTLE_ENDIAN */ }s; } dwords; typedef union { du_int all; struct { #if _YUGA_LITTLE_ENDIAN su_int low; su_int high; #else su_int high; su_int low; #endif /* _YUGA_LITTLE_ENDIAN */ }s; } udwords; #if (defined(__LP64__) || defined(__wasm__) || defined(__mips64)) || defined(__riscv) #define CRT_HAS_128BIT #endif #ifdef CRT_HAS_128BIT typedef int ti_int __attribute__ ((mode (TI))); typedef unsigned tu_int __attribute__ ((mode (TI))); typedef union { ti_int all; struct { #if _YUGA_LITTLE_ENDIAN du_int low; di_int high; #else di_int high; du_int low; #endif /* _YUGA_LITTLE_ENDIAN */ }s; } twords; typedef union { tu_int all; struct { #if _YUGA_LITTLE_ENDIAN du_int low; du_int high; #else du_int high; du_int low; #endif /* _YUGA_LITTLE_ENDIAN */ }s; } utwords; static __inline ti_int make_ti(di_int h, di_int l) { twords r; r.s.high = h; r.s.low = l; return r.all; } static __inline tu_int make_tu(du_int h, du_int l) { utwords r; r.s.high = h; r.s.low = l; return r.all; } #endif /* CRT_HAS_128BIT */ typedef union { su_int u; float f; } float_bits; typedef union { udwords u; double f; } double_bits; typedef struct { #if _YUGA_LITTLE_ENDIAN udwords low; udwords high; #else udwords high; udwords low; #endif /* _YUGA_LITTLE_ENDIAN */ } uqwords; typedef union { uqwords u; long double f; } long_double_bits; #if __STDC_VERSION__ >= 199901L typedef float _Complex Fcomplex; typedef double _Complex Dcomplex; typedef long double _Complex Lcomplex; #define COMPLEX_REAL(x) __real__(x) #define COMPLEX_IMAGINARY(x) __imag__(x) #else typedef struct { float real, imaginary; } Fcomplex; typedef struct { double real, imaginary; } Dcomplex; typedef struct { long double real, imaginary; } Lcomplex; #define COMPLEX_REAL(x) (x).real #define COMPLEX_IMAGINARY(x) (x).imaginary #endif #endif /* INT_TYPES_H */ ================================================ FILE: lib/libc/runtime/int_util.h ================================================ /* ===-- int_util.h - internal utility functions ----------------------------=== * * The LLVM Compiler Infrastructure * * This file is dual licensed under the MIT and the University of Illinois Open * Source Licenses. See LICENSE.TXT for details. * * ===-----------------------------------------------------------------------=== * * This file is not part of the interface of this library. * * This file defines non-inline utilities which are available for use in the * library. The function definitions themselves are all contained in int_util.c * which will always be compiled into any compiler-rt library. * * ===-----------------------------------------------------------------------=== */ #ifndef INT_UTIL_H #define INT_UTIL_H /** \brief Trigger a program abort (or panic for kernel code). */ #define compilerrt_abort() compilerrt_abort_impl(__FILE__, __LINE__, __func__) NORETURN void compilerrt_abort_impl(const char *file, int line, const char *function); #define COMPILE_TIME_ASSERT(expr) COMPILE_TIME_ASSERT1(expr, __COUNTER__) #define COMPILE_TIME_ASSERT1(expr, cnt) COMPILE_TIME_ASSERT2(expr, cnt) #define COMPILE_TIME_ASSERT2(expr, cnt) \ typedef char ct_assert_##cnt[(expr) ? 1 : -1] UNUSED #endif /* INT_UTIL_H */ ================================================ FILE: lib/libc/runtime/lshrdi3.c ================================================ /* ===-- lshrdi3.c - Implement __lshrdi3 -----------------------------------=== * * The LLVM Compiler Infrastructure * * This file is dual licensed under the MIT and the University of Illinois Open * Source Licenses. See LICENSE.TXT for details. * * ===----------------------------------------------------------------------=== * * This file implements __lshrdi3 for the compiler_rt library. * * ===----------------------------------------------------------------------=== */ #include "int_lib.h" /* Returns: logical a >> b */ /* Precondition: 0 <= b < bits_in_dword */ COMPILER_RT_ABI di_int __lshrdi3(di_int a, si_int b) { const int bits_in_word = (int)(sizeof(si_int) * CHAR_BIT); udwords input; udwords result; input.all = a; if (b & bits_in_word) /* bits_in_word <= b < bits_in_dword */ { result.s.high = 0; result.s.low = input.s.high >> (b - bits_in_word); } else /* 0 <= b < bits_in_word */ { if (b == 0) return a; result.s.high = input.s.high >> b; result.s.low = (input.s.high << (bits_in_word - b)) | (input.s.low >> b); } return result.all; } #if defined(__ARM_EABI__) AEABI_RTABI di_int __aeabi_llsr(di_int a, si_int b) COMPILER_RT_ALIAS(__lshrdi3); #endif ================================================ FILE: lib/libc/runtime/muldf3.c ================================================ //===-- lib/muldf3.c - Double-precision multiplication ------------*- C -*-===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // This file implements double-precision soft-float multiplication // with the IEEE-754 default rounding (to nearest, ties to even). // //===----------------------------------------------------------------------===// #define DOUBLE_PRECISION #include "fp_mul_impl.inc" COMPILER_RT_ABI fp_t __muldf3(fp_t a, fp_t b) { return __mulXf3__(a, b); } #if defined(__ARM_EABI__) #if defined(COMPILER_RT_ARMHF_TARGET) AEABI_RTABI fp_t __aeabi_dmul(fp_t a, fp_t b) { return __muldf3(a, b); } #else AEABI_RTABI fp_t __aeabi_dmul(fp_t a, fp_t b) COMPILER_RT_ALIAS(__muldf3); #endif #endif ================================================ FILE: lib/libc/runtime/mulsf3.c ================================================ //===-- lib/mulsf3.c - Single-precision multiplication ------------*- C -*-===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // This file implements single-precision soft-float multiplication // with the IEEE-754 default rounding (to nearest, ties to even). // //===----------------------------------------------------------------------===// #define SINGLE_PRECISION #include "fp_mul_impl.inc" COMPILER_RT_ABI fp_t __mulsf3(fp_t a, fp_t b) { return __mulXf3__(a, b); } #if defined(__ARM_EABI__) #if defined(COMPILER_RT_ARMHF_TARGET) AEABI_RTABI fp_t __aeabi_fmul(fp_t a, fp_t b) { return __mulsf3(a, b); } #else AEABI_RTABI fp_t __aeabi_fmul(fp_t a, fp_t b) COMPILER_RT_ALIAS(__mulsf3); #endif #endif ================================================ FILE: lib/libc/runtime/negdf2.c ================================================ //===-- lib/negdf2.c - double-precision negation ------------------*- C -*-===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // This file implements double-precision soft-float negation. // //===----------------------------------------------------------------------===// #define DOUBLE_PRECISION #include "fp_lib.h" COMPILER_RT_ABI fp_t __negdf2(fp_t a) { return fromRep(toRep(a) ^ signBit); } #if defined(__ARM_EABI__) #if defined(COMPILER_RT_ARMHF_TARGET) AEABI_RTABI fp_t __aeabi_dneg(fp_t a) { return __negdf2(a); } #else AEABI_RTABI fp_t __aeabi_dneg(fp_t a) COMPILER_RT_ALIAS(__negdf2); #endif #endif ================================================ FILE: lib/libc/runtime/negsf2.c ================================================ //===-- lib/negsf2.c - single-precision negation ------------------*- C -*-===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // This file implements single-precision soft-float negation. // //===----------------------------------------------------------------------===// #define SINGLE_PRECISION #include "fp_lib.h" COMPILER_RT_ABI fp_t __negsf2(fp_t a) { return fromRep(toRep(a) ^ signBit); } #if defined(__ARM_EABI__) #if defined(COMPILER_RT_ARMHF_TARGET) AEABI_RTABI fp_t __aeabi_fneg(fp_t a) { return __negsf2(a); } #else AEABI_RTABI fp_t __aeabi_fneg(fp_t a) COMPILER_RT_ALIAS(__negsf2); #endif #endif ================================================ FILE: lib/libc/runtime/sc_case.S ================================================ #if __mips__ /* XXX */ .set reorder #endif /* __mips__ XXX */ .text # # $v0 = value to switch on # 0($sp) = pointer to list of value,ptr cases # ended where ptr=0, value is used as pointer to jump to in default case # looks like stack is popped as part of this # FIXME - The assembler/linker only stores the bottom 16 bits # of the labels in pair, so we construct the address by merging the 16 bits # in the cell with the upper 16 bits in the return address of the code that # called this. Is there a way to get the assembler linker to store the full # address? If so, that should be used instead. # .globl __sc_case __sc_case: #if __mips__ /* XXX */ lw $t1, 16($sp) # t1=pointer to list of value/ptr pairs addiu $sp, $sp, 4 # pop stack that held pointer 1: lw $t2, 0($t1) # get value from pair lw $t3, 4($t1) # get ptr from pair beq $t3, $zero, 2f beq $t2, $v0, 3f addiu $t1, $t1, 8 # t1 += size of pair j 1b 2: move $t3, $t2 3: lui $t2, 0xffff and $t2, $t2, $ra or $t3, $t3, $t2 jr $t3 #endif /* __mips__ XXX */ ================================================ FILE: lib/libc/runtime/subdf3.c ================================================ //===-- lib/adddf3.c - Double-precision subtraction ---------------*- C -*-===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // This file implements double-precision soft-float subtraction with the // IEEE-754 default rounding (to nearest, ties to even). // //===----------------------------------------------------------------------===// #define DOUBLE_PRECISION #include "fp_lib.h" // Subtraction; flip the sign bit of b and add. COMPILER_RT_ABI fp_t __subdf3(fp_t a, fp_t b) { return __adddf3(a, fromRep(toRep(b) ^ signBit)); } #if defined(__ARM_EABI__) #if defined(COMPILER_RT_ARMHF_TARGET) AEABI_RTABI fp_t __aeabi_dsub(fp_t a, fp_t b) { return __subdf3(a, b); } #else AEABI_RTABI fp_t __aeabi_dsub(fp_t a, fp_t b) COMPILER_RT_ALIAS(__subdf3); #endif #endif ================================================ FILE: lib/libc/runtime/subsf3.c ================================================ //===-- lib/subsf3.c - Single-precision subtraction ---------------*- C -*-===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // This file implements single-precision soft-float subtraction with the // IEEE-754 default rounding (to nearest, ties to even). // //===----------------------------------------------------------------------===// #define SINGLE_PRECISION #include "fp_lib.h" // Subtraction; flip the sign bit of b and add. COMPILER_RT_ABI fp_t __subsf3(fp_t a, fp_t b) { return __addsf3(a, fromRep(toRep(b) ^ signBit)); } #if defined(__ARM_EABI__) #if defined(COMPILER_RT_ARMHF_TARGET) AEABI_RTABI fp_t __aeabi_fsub(fp_t a, fp_t b) { return __subsf3(a, b); } #else AEABI_RTABI fp_t __aeabi_fsub(fp_t a, fp_t b) COMPILER_RT_ALIAS(__subsf3); #endif #endif ================================================ FILE: lib/libc/stdio/Makefile ================================================ # # Copyright (c) 1980 Regents of the University of California. # All rights reserved. The Berkeley software License Agreement # specifies the terms and conditions for redistribution. # TOPSRC!=cd ../../..; pwd include ${TOPSRC}/share/mk/sys.mk CFLAGS += ${DEFS} -Os SRCS = ${STDSRC} fgetc.c fgets.c fputc.c fputs.c gets.c puts.c \ feof.c ferror.c fileno.c OBJS = ${STDOBJ} fgetc.o fgets.o fputc.o fputs.o gets.o puts.o \ feof.o ferror.o fileno.o STDSRC = clrerr.c doscan.c exit.c clnup.c fdopen.c filbuf.c findiop.c \ flsbuf.c fopen.c fprintf.c fread.c freopen.c fseek.c \ ftell.c fwrite.c getchar.c getw.c printf.c putchar.c putw.c \ rew.c scanf.c setbuf.c setbuffer.c setvbuf.c snprintf.c sprintf.c \ strout.c ungetc.c vfprintf.c vprintf.c vsprintf.c doprnt.c \ remove.c STDOBJ = clrerr.o doscan.o exit.o fdopen.o filbuf.o findiop.o \ flsbuf.o fopen.o fprintf.o fread.o freopen.o fseek.o \ ftell.o fwrite.o getchar.o getw.o printf.o putchar.o putw.o \ rew.o scanf.o setbuf.o setbuffer.o setvbuf.o snprintf.o sprintf.o \ strout.o ungetc.o vfprintf.o vprintf.o vsprintf.o doprnt.o \ remove.o TAGSFILE = tags stdio.a: ${OBJS} @echo "building stdio.a" @${AR} cr stdio.a ${OBJS} tags: cwd=`pwd`; \ for i in ${SRCS}; do \ ctags -a -f ${TAGSFILE} $$cwd/$$i; \ done clean: rm -f stdio.a *.o *~ profiled/*.o tags Makefile.bak depend: for i in ${SRCS}; do \ cc -M ${CFLAGS} $$i | awk ' { if ($$1 != prev) \ { if (rec != "") print rec; rec = $$0; prev = $$1; } \ else { if (length(rec $$2) > 78) { print rec; rec = $$0; } \ else rec = rec " " $$2 } } \ END { print rec } ' >> makedep; done echo '/^# DO NOT DELETE THIS LINE/+2,$$d' >eddep echo '$$r makedep' >>eddep echo 'w' >>eddep cp Makefile Makefile.bak ed - Makefile < eddep rm eddep makedep echo '# DEPENDENCIES MUST END AT END OF FILE' >> Makefile echo '# IF YOU PUT STUFF HERE IT WILL GO AWAY' >> Makefile echo '# see make depend above' >> Makefile # DO NOT DELETE THIS LINE -- make depend uses it ================================================ FILE: lib/libc/stdio/clnup.c ================================================ /* * This stub is linked in, when application uses no stdio calls. */ __attribute__((weak)) void _cleanup() { /* Nothing to do. */ } ================================================ FILE: lib/libc/stdio/clrerr.c ================================================ /* $OpenBSD: clrerr.c,v 1.6 2005/08/08 08:05:36 espie Exp $ */ /*- * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Chris Torek. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include /* * A subroutine version of the macro clearerr. */ #undef clearerr void clearerr(FILE *fp) { __sclearerr(fp); } ================================================ FILE: lib/libc/stdio/doprnt.c ================================================ /* * Scaled down version of printf(3). * Based on FreeBSD sources, heavily rewritten. * * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ /* * Two additional formats: * * The format %b is supported to decode error registers. * Its usage is: * * printf("reg=%b\n", regval, "*"); * * where is the output base expressed as a control character, e.g. * \10 gives octal; \20 gives hex. Each arg is a sequence of characters, * the first of which gives the bit number to be inspected (origin 1), and * the next characters (up to a control character, i.e. a character <= 32), * give the name of the register. Thus: * * kvprintf("reg=%b\n", 3, "\10\2BITTWO\1BITONE\n"); * * would produce output: * * reg=3 * * The format %D -- Hexdump, takes a pointer. Sharp flag - use `:' as * a separator, instead of a space. For example: * * ("%6D", ptr) -> XX XX XX XX XX XX * ("%#*D", len, ptr) -> XX:XX:XX:XX ... */ #include #include #include #include #include #include #include /* Max number conversion buffer length. */ #define MAXNBUF \ (1/*sign*/ + DBL_MAX_10_EXP+1/*max integral digits*/ + \ 1/*.*/ + DBL_DIG+1/*max fractional digits*/ + 1/*NUL*/) static unsigned char *ksprintn (unsigned char *buf, unsigned long v, unsigned char base, int width, unsigned char *lp); static unsigned char mkhex (unsigned char ch); static int cvt (double number, int prec, int sharpflag, unsigned char *negp, unsigned char fmtch, unsigned char *startp, unsigned char *endp); int _doprnt (char const *fmt, va_list ap, FILE *stream) { #define PUTC(c) { putc (c, stream); ++retval; } unsigned char nbuf [MAXNBUF], padding, *q; const unsigned char *s; unsigned char c, base, lflag, ladjust, sharpflag, neg, dot, size; int n, width, dwidth, retval, uppercase, extrazeros, sign; unsigned long ul; if (! stream) return 0; if (! fmt) fmt = "(null)\n"; retval = 0; for (;;) { while ((c = *fmt++) != '%') { if (! c) return retval; PUTC (c); } padding = ' '; width = 0; extrazeros = 0; lflag = 0; ladjust = 0; sharpflag = 0; neg = 0; sign = 0; dot = 0; uppercase = 0; dwidth = -1; reswitch: switch (c = *fmt++) { case '.': dot = 1; padding = ' '; dwidth = 0; goto reswitch; case '#': sharpflag = 1; goto reswitch; case '+': sign = -1; goto reswitch; case '-': ladjust = 1; goto reswitch; case '%': PUTC (c); break; case '*': if (! dot) { width = va_arg (ap, int); if (width < 0) { ladjust = !ladjust; width = -width; } } else { dwidth = va_arg (ap, int); } goto reswitch; case '0': if (! dot) { padding = '0'; goto reswitch; } case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': for (n=0; ; ++fmt) { n = n * 10 + c - '0'; c = *fmt; if (c < '0' || c > '9') break; } if (dot) dwidth = n; else width = n; goto reswitch; case 'b': ul = va_arg (ap, int); s = va_arg (ap, const unsigned char*); q = ksprintn (nbuf, ul, *s++, -1, 0); while (*q) PUTC (*q--); if (! ul) break; size = 0; while (*s) { n = *s++; if ((char) (ul >> (n-1)) & 1) { PUTC (size ? ',' : '<'); for (; (n = *s) > ' '; ++s) PUTC (n); size = 1; } else while (*s > ' ') ++s; } if (size) PUTC ('>'); break; case 'c': if (! ladjust && width > 0) while (width--) PUTC (' '); PUTC (va_arg (ap, int)); if (ladjust && width > 0) while (width--) PUTC (' '); break; case 'D': lflag=1; /* FALLTHROUGH */ case 'd': case 'i': ul = lflag ? va_arg (ap, long) : va_arg (ap, int); if (! sign) sign = 1; base = 10; goto number; case 'l': lflag = 1; goto reswitch; case 'o': ul = lflag ? va_arg (ap, unsigned long) : va_arg (ap, unsigned int); base = 8; goto nosign; case 'p': ul = (size_t) va_arg (ap, void*); if (! ul) { s = (const unsigned char*) "(nil)"; goto string; } base = 16; sharpflag = (width == 0); goto nosign; case 'n': /* TBD!!! fix this non-standard %n */ ul = lflag ? va_arg (ap, unsigned long) : sign ? (unsigned long) va_arg (ap, int) : va_arg (ap, unsigned int); base = 10; goto number; case 's': s = va_arg (ap, unsigned char*); if (! s) s = (const unsigned char*) "(null)"; string: if (! dot) n = strlen ((char*)s); else for (n=0; n 0) while (width--) PUTC (' '); while (n--) PUTC (*s++); if (ladjust && width > 0) while (width--) PUTC (' '); break; case 'r': /* Saturated counters. */ base = 10; if (lflag) { ul = va_arg (ap, unsigned long); if (ul == -1) { cnt_unknown: if (ladjust) PUTC ('-'); while (--width > 0) PUTC (' '); if (! ladjust) PUTC ('-'); break; } if (ul >= -2) { ul = -3; neg = '>'; goto nosign; } } else { ul = va_arg (ap, unsigned int); if (ul == (unsigned short) -1) goto cnt_unknown; if (ul >= (unsigned short) -2) { ul = (unsigned short) -3; neg = '>'; goto nosign; } } goto nosign; case 'u': ul = lflag ? va_arg (ap, unsigned long) : va_arg (ap, unsigned int); base = 10; goto nosign; case 'x': case 'X': ul = lflag ? va_arg (ap, unsigned long) : va_arg (ap, unsigned int); base = 16; uppercase = (c == 'X'); goto nosign; case 'z': case 'Z': ul = lflag ? va_arg (ap, unsigned long) : sign ? (unsigned long) va_arg (ap, int) : va_arg (ap, unsigned int); base = 16; uppercase = (c == 'Z'); goto number; nosign: sign = 0; number: if (sign) { if ((long) ul < 0L) { neg = '-'; ul = -(long) ul; } else if (sign < 0) neg = '+'; } if (dwidth >= (int) sizeof(nbuf)) { extrazeros = dwidth - sizeof(nbuf) + 1; dwidth = sizeof(nbuf) - 1; } s = ksprintn (nbuf, ul, base, dwidth, &size); if (sharpflag && ul != 0) { if (base == 8) size++; else if (base == 16) size += 2; } if (neg) size++; if (! ladjust && width && padding == ' ' && (width -= size) > 0) do { PUTC (' '); } while (--width > 0); if (neg) PUTC (neg); if (sharpflag && ul != 0) { if (base == 8) { PUTC ('0'); } else if (base == 16) { PUTC ('0'); PUTC (uppercase ? 'X' : 'x'); } } if (extrazeros) do { PUTC ('0'); } while (--extrazeros > 0); if (! ladjust && width && (width -= size) > 0) do { PUTC (padding); } while (--width > 0); for (; *s; --s) { if (uppercase && *s>='a' && *s<='z') { PUTC (*s + 'A' - 'a'); } else { PUTC (*s); } } if (ladjust && width && (width -= size) > 0) do { PUTC (' '); } while (--width > 0); break; case 'e': case 'E': case 'f': case 'F': case 'g': case 'G': { double d = va_arg (ap, double); /* * don't do unrealistic precision; just pad it with * zeroes later, so buffer size stays rational. */ if (dwidth > DBL_DIG) { if ((c != 'g' && c != 'G') || sharpflag) extrazeros = dwidth - DBL_DIG; dwidth = DBL_DIG; } else if (dwidth == -1) { dwidth = (lflag ? DBL_DIG : FLT_DIG); } /* * softsign avoids negative 0 if d is < 0 and * no significant digits will be shown */ if (d < 0) { neg = 1; d = -d; } /* * cvt may have to round up past the "start" of the * buffer, i.e. ``intf("%.2f", (double)9.999);''; * if the first char isn't NULL, it did. */ if (isnan (d) || isinf (d)) { strcpy ((char*)nbuf, isnan (d) ? "NaN" : "Inf"); size = 3; extrazeros = 0; s = nbuf; } else { *nbuf = 0; size = cvt (d, dwidth, sharpflag, &neg, c, nbuf, nbuf + sizeof(nbuf) - 1); if (*nbuf) { s = nbuf; nbuf [size] = 0; } else { s = nbuf + 1; nbuf [size + 1] = 0; } } if (neg || sign) size++; if (! ladjust && width && padding == ' ' && (width -= size) > 0) do { PUTC (' '); } while (--width > 0); if (neg) { PUTC ('-'); } else if (sign) { PUTC ('+'); } if (! ladjust && width && (width -= size) > 0) do { PUTC (padding); } while (--width > 0); for (; *s; ++s) { if (extrazeros && (*s == 'e' || *s == 'E')) do { PUTC ('0'); } while (--extrazeros > 0); PUTC (*s); } if (extrazeros) do { PUTC ('0'); } while (--extrazeros > 0); if (ladjust && width && (width -= size) > 0) do { PUTC (' '); } while (--width > 0); break; } default: PUTC ('%'); if (lflag) PUTC ('l'); PUTC (c); break; } } } /* * Put a NUL-terminated ASCII number (base <= 16) in a buffer in reverse * order; return an optional length and a pointer to the last character * written in the buffer (i.e., the first character of the string). * The buffer pointed to by `nbuf' must have length >= MAXNBUF. */ static unsigned char * ksprintn (unsigned char *nbuf, unsigned long ul, unsigned char base, int width, unsigned char *lenp) { unsigned char *p; p = nbuf; *p = 0; for (;;) { *++p = mkhex (ul % base); ul /= base; if (--width > 0) continue; if (! ul) break; } if (lenp) *lenp = p - nbuf; return (p); } static unsigned char mkhex (unsigned char ch) { ch &= 15; if (ch > 9) return ch + 'a' - 10; return ch + '0'; } static unsigned char * cvtround (double fract, int *exp, unsigned char *start, unsigned char *end, unsigned char ch, unsigned char *negp) { double tmp; if (fract) { modf (fract * 10, &tmp); } else { tmp = ch - '0'; } if (tmp > 4) { for (;; --end) { if (*end == '.') { --end; } if (++*end <= '9') { break; } *end = '0'; if (end == start) { if (exp) { /* e/E; increment exponent */ *end = '1'; ++*exp; } else { /* f; add extra digit */ *--end = '1'; --start; } break; } } } else if (*negp) { /* * ``"%.3f", (double)-0.0004'' gives you a negative 0. */ for (;; --end) { if (*end == '.') { --end; } if (*end != '0') { break; } if (end == start) { *negp = 0; } } } return start; } static unsigned char * exponent (unsigned char *p, int exp, unsigned char fmtch) { unsigned char expbuf [8], *t; *p++ = fmtch; if (exp < 0) { exp = -exp; *p++ = '-'; } else { *p++ = '+'; } t = expbuf + sizeof(expbuf); if (exp > 9) { do { *--t = exp % 10 + '0'; } while ((exp /= 10) > 9); *--t = exp + '0'; for (; t < expbuf + sizeof(expbuf); *p++ = *t++) continue; } else { *p++ = '0'; *p++ = exp + '0'; } return p; } static int cvt (double number, int prec, int sharpflag, unsigned char *negp, unsigned char fmtch, unsigned char *startp, unsigned char *endp) { unsigned char *p, *t; double fract; int dotrim, expcnt, gformat; double integer, tmp; expcnt = 0; dotrim = expcnt = gformat = 0; fract = modf (number, &integer); /* * get an extra slot for rounding */ t = ++startp; /* * get integer portion of number; put into the end of the buffer; the * .01 is added for modf (356.0 / 10, &integer) returning .59999999... */ for (p = endp - 1; integer; ++expcnt) { tmp = modf (integer / 10, &integer); *p-- = (int) ((tmp + .01) * 10) + '0'; } switch (fmtch) { case 'f': /* reverse integer into beginning of buffer */ if (expcnt) { for (; ++p < endp; *t++ = *p); } else { *t++ = '0'; } /* * if precision required or alternate flag set, add in a * decimal point. */ if (prec || sharpflag) { *t++ = '.'; } /* * if requires more precision and some fraction left */ if (fract) { if (prec) { do { fract = modf (fract * 10, &tmp); *t++ = (int)tmp + '0'; } while (--prec && fract); } if (fract) { startp = cvtround (fract, 0, startp, t - 1, '0', negp); } } for (; prec--; *t++ = '0'); break; case 'e': case 'E': eformat: if (expcnt) { *t++ = *++p; if (prec || sharpflag) { *t++ = '.'; } /* * if requires more precision and some integer left */ for (; prec && ++p < endp; --prec) { *t++ = *p; } /* * if done precision and more of the integer component, * round using it; adjust fract so we don't re-round * later. */ if (! prec && ++p < endp) { fract = 0; startp = cvtround (0, &expcnt, startp, t - 1, *p, negp); } /* * adjust expcnt for digit in front of decimal */ --expcnt; } /* * until first fractional digit, decrement exponent */ else if (fract) { /* * adjust expcnt for digit in front of decimal */ for (expcnt = -1;; --expcnt) { fract = modf (fract * 10, &tmp); if (tmp) { break; } } *t++ = (int)tmp + '0'; if (prec || sharpflag) { *t++ = '.'; } } else { *t++ = '0'; if (prec || sharpflag) { *t++ = '.'; } } /* * if requires more precision and some fraction left */ if (fract) { if (prec) { do { fract = modf (fract * 10, &tmp); *t++ = (int)tmp + '0'; } while (--prec && fract); } if (fract) { startp = cvtround (fract, &expcnt, startp, t - 1, '0', negp); } } /* * if requires more precision */ for (; prec--; *t++ = '0'); /* * unless alternate flag, trim any g/G format trailing 0's */ if (gformat && ! sharpflag) { while (t > startp && *--t == '0'); if (*t == '.') { --t; } ++t; } t = exponent (t, expcnt, fmtch); break; case 'g': case 'G': /* * a precision of 0 is treated as a precision of 1 */ if (!prec) { ++prec; } /* * ``The style used depends on the value converted; style e * will be used only if the exponent resulting from the * conversion is less than -4 or greater than the precision.'' * -- ANSI X3J11 */ if (expcnt > prec || (! expcnt && fract && fract < .0001)) { /* * g/G format counts "significant digits, not digits of * precision; for the e/E format, this just causes an * off-by-one problem, i.e. g/G considers the digit * before the decimal point significant and e/E doesn't * count it as precision. */ --prec; fmtch -= 2; /* G->E, g->e */ gformat = 1; goto eformat; } /* * reverse integer into beginning of buffer, * note, decrement precision */ if (expcnt) { for (; ++p < endp; *t++ = *p, --prec); } else { *t++ = '0'; } /* * if precision required or alternate flag set, add in a * decimal point. If no digits yet, add in leading 0. */ if (prec || sharpflag) { dotrim = 1; *t++ = '.'; } else { dotrim = 0; } /* * if requires more precision and some fraction left */ while (prec && fract) { fract = modf (fract * 10, &tmp); *t++ = (int)tmp + '0'; prec--; } if (fract) { startp = cvtround (fract, 0, startp, t - 1, '0', negp); } /* * alternate format, adds 0's for precision, else trim 0's */ if (sharpflag) { for (; prec--; *t++ = '0'); } else if (dotrim) { while (t > startp && *--t == '0'); if (*t != '.') { ++t; } } } return t - startp; } ================================================ FILE: lib/libc/stdio/doscan.c ================================================ #include #include #include #define SPC 01 #define STP 02 #define SHORT 0 #define REGULAR 1 #define LONG 2 #define INT 0 #define FLOAT 1 static char *_getccl(); static char _sctab[256] = { 0,0,0,0,0,0,0,0, 0,SPC,SPC,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, SPC,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, }; static int _instr (ptr, type, len, iop, eofptr) register char *ptr; int type, len; register FILE *iop; int *eofptr; { register int ch; register char *optr; int ignstp; *eofptr = 0; optr = ptr; if (type=='c' && len==30000) len = 1; ignstp = 0; if (type=='s') ignstp = SPC; while ((ch = getc(iop)) != EOF && _sctab[ch] & ignstp) ; ignstp = SPC; if (type=='c') ignstp = 0; else if (type=='[') ignstp = STP; while (ch!=EOF && (_sctab[ch]&ignstp)==0) { if (ptr) *ptr++ = ch; if (--len <= 0) break; ch = getc(iop); } if (ch != EOF) { if (len > 0) ungetc(ch, iop); *eofptr = 0; } else *eofptr = 1; if (ptr && ptr!=optr) { if (type!='c') *ptr++ = '\0'; return(1); } return(0); } static int _innum (ptr, type, len, size, iop, eofptr) int *ptr, *eofptr; int type, len, size; FILE *iop; { register char *np; char numbuf[64]; register int c, base; int expseen, scale, negflg, c1, ndigit; long lcval; if (type=='c' || type=='s' || type=='[') return(_instr((char*)ptr, type, len, iop, eofptr)); lcval = 0; ndigit = 0; scale = INT; if (type=='e'||type=='f') scale = FLOAT; base = 10; if (type=='o') base = 8; else if (type=='x') base = 16; np = numbuf; expseen = 0; negflg = 0; while ((c = getc(iop))==' ' || c=='\t' || c=='\n'); if (c=='-') { negflg++; *np++ = c; c = getc(iop); len--; } else if (c=='+') { len--; c = getc(iop); } for ( ; --len>=0; *np++ = c, c = getc(iop)) { if (isdigit(c) || (base==16 && (('a'<=c && c<='f') || ('A'<=c && c<='F')))) { ndigit++; if (base==8) lcval <<=3; else if (base==10) lcval = ((lcval<<2) + lcval)<<1; else lcval <<= 4; c1 = c; if (isdigit(c)) c -= '0'; else if ('a'<=c && c<='f') c -= 'a'-10; else c -= 'A'-10; lcval += c; c = c1; continue; } else if (c=='.') { if (base!=10 || scale==INT) break; ndigit++; continue; } else if ((c=='e'||c=='E') && expseen==0) { if (base!=10 || scale==INT || ndigit==0) break; expseen++; *np++ = c; c = getc(iop); if (c!='+'&&c!='-'&&('0'>c||c>'9')) break; } else break; } if (negflg) lcval = -lcval; if (c != EOF) { ungetc(c, iop); *eofptr = 0; } else *eofptr = 1; if (ptr==NULL || np==numbuf || (negflg && np==numbuf+1) )/* gene dykes*/ return(0); *np++ = 0; switch((scale<<4) | size) { #if HAVE_FLOAT case (FLOAT<<4) | SHORT: case (FLOAT<<4) | REGULAR: *(float*)ptr = atof(numbuf); break; case (FLOAT<<4) | LONG: *(double*)ptr = atof(numbuf); break; #endif case (INT<<4) | SHORT: *(short*)ptr = lcval; break; case (INT<<4) | REGULAR: *(int*)ptr = lcval; break; case (INT<<4) | LONG: *(long*)ptr = lcval; break; } return(1); } int _doscan (iop, fmt, argp) FILE *iop; register const char *fmt; va_list argp; { register int ch; int nmatch, len, ch1; int *ptr, fileended, size; nmatch = 0; fileended = 0; for (;;) switch (ch = *fmt++) { case '\0': return (nmatch); case '%': if ((ch = *fmt++) == '%') goto def; if (ch == '*') { ptr = 0; ch = *fmt++; } else ptr = va_arg (argp, int*); len = 0; size = REGULAR; while (isdigit(ch)) { len = len*10 + ch - '0'; ch = *fmt++; } if (len == 0) len = 30000; if (ch=='l') { size = LONG; ch = *fmt++; } else if (ch=='h') { size = SHORT; ch = *fmt++; } else if (ch=='[') fmt = _getccl(fmt); if (isupper(ch)) { ch = tolower(ch); size = LONG; } if (ch == '\0') return(-1); if (_innum(ptr, ch, len, size, iop, &fileended) && ptr) nmatch++; if (fileended) return(nmatch? nmatch: -1); break; case ' ': case '\n': case '\t': while ((ch1 = getc(iop))==' ' || ch1=='\t' || ch1=='\n') ; if (ch1 != EOF) ungetc(ch1, iop); break; default: def: ch1 = getc(iop); if (ch1 != ch) { if (ch1==EOF) return(-1); ungetc(ch1, iop); return(nmatch); } } } static char * _getccl(s) register unsigned char *s; { register int c, t; t = 0; if (*s == '^') { t++; s++; } for (c = 0; c < (sizeof _sctab / sizeof _sctab[0]); c++) if (t) _sctab[c] &= ~STP; else _sctab[c] |= STP; if ((c = *s) == ']' || c == '-') { /* first char is special */ if (t) _sctab[c] |= STP; else _sctab[c] &= ~STP; s++; } while ((c = *s++) != ']') { if (c==0) return((char *)--s); else if (c == '-' && *s != ']' && s[-2] < *s) { for (c = s[-2] + 1; c < *s; c++) if (t) _sctab[c] |= STP; else _sctab[c] &= ~STP; } else if (t) _sctab[c] |= STP; else _sctab[c] &= ~STP; } return((char *)s); } ================================================ FILE: lib/libc/stdio/exit.c ================================================ #include #include struct atexit { /* entry allocated per atexit() call */ struct atexit *next; /* next enty in a list */ void (*func)(void); /* callback function */ }; int errno; struct atexit *__atexit; /* points to head of LIFO stack */ extern void _cleanup(); void exit (code) int code; { register struct atexit *p; for (p = __atexit; p; p = p->next) (*p->func)(); _cleanup(); _exit (code); } /* * Register a function to be performed at exit. */ int atexit(fn) void (*fn)(); { static struct atexit __atexit0; /* one guaranteed table */ register struct atexit *p; p = __atexit; if (! p) { p = &__atexit0; } else { p = malloc(sizeof(struct atexit)); if (! p) return -1; p->next = __atexit; } p->func = fn; __atexit = p; return 0; } ================================================ FILE: lib/libc/stdio/fdopen.c ================================================ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ /* * Unix routine to do an "fopen" on file descriptor * The mode has to be repeated because you can't query its * status */ #include #include #include #include FILE * fdopen(fd, mode) int fd; register const char *mode; { static int nofile = -1; register FILE *iop; if (nofile < 0) nofile = getdtablesize(); if (fd < 0 || fd >= nofile) return (NULL); iop = _findiop(); if (iop == NULL) return (NULL); iop->_cnt = 0; iop->_file = fd; iop->_bufsiz = 0; iop->_base = iop->_ptr = NULL; switch (*mode) { case 'r': iop->_flag = _IOREAD; break; case 'a': lseek(fd, (off_t)0, L_XTND); /* fall into ... */ case 'w': iop->_flag = _IOWRT; break; default: return (NULL); } if (mode[1] == '+') iop->_flag = _IORW; return (iop); } ================================================ FILE: lib/libc/stdio/feof.c ================================================ /* $OpenBSD: feof.c,v 1.5 2005/08/08 08:05:36 espie Exp $ */ /*- * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Chris Torek. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include /* * A subroutine version of the macro feof. */ #undef feof int feof(FILE *fp) { return (__sfeof(fp)); } ================================================ FILE: lib/libc/stdio/ferror.c ================================================ /* $OpenBSD: ferror.c,v 1.5 2005/08/08 08:05:36 espie Exp $ */ /*- * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Chris Torek. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include /* * A subroutine version of the macro ferror. */ #undef ferror int ferror(FILE *fp) { return (__sferror(fp)); } ================================================ FILE: lib/libc/stdio/fgetc.c ================================================ #include int fgetc(fp) register FILE *fp; { return getc(fp); } ================================================ FILE: lib/libc/stdio/fgets.c ================================================ #include char * fgets(s, n, iop) char *s; int n; register FILE *iop; { register int c = EOF; register char *cs; cs = s; while (--n>0 && (c = getc(iop)) != EOF) { *cs++ = c; if (c=='\n') break; } if (c == EOF && cs==s) return(NULL); *cs++ = '\0'; return(s); } ================================================ FILE: lib/libc/stdio/filbuf.c ================================================ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include #include #include #include #include int _filbuf(iop) register FILE *iop; { int size; struct stat stbuf; extern char *_smallbuf; char c; if (iop->_flag & _IORW) iop->_flag |= _IOREAD; if ((iop->_flag&_IOREAD) == 0) return(EOF); if (iop->_flag&(_IOSTRG|_IOEOF)) return(EOF); tryagain: if (iop->_base==NULL) { if (iop->_flag&_IONBF) { iop->_base = _smallbuf ? &_smallbuf[fileno(iop)] : &c; goto tryagain; } if (fstat(fileno(iop), &stbuf) < 0 || stbuf.st_blksize <= NULL) size = BUFSIZ; else size = stbuf.st_blksize; if ((iop->_base = malloc(size)) == NULL) { iop->_flag |= _IONBF; goto tryagain; } iop->_flag |= _IOMYBUF; iop->_bufsiz = size; } if (iop == stdin) { if (stdout->_flag&_IOLBF) fflush(stdout); if (stderr->_flag&_IOLBF) fflush(stderr); } iop->_cnt = read(fileno(iop), iop->_base, iop->_flag & _IONBF ? 1 : iop->_bufsiz); iop->_ptr = iop->_base; if (iop->_flag & _IONBF && iop->_base == &c) iop->_base = NULL; if (--iop->_cnt < 0) { if (iop->_cnt == -1) { iop->_flag |= _IOEOF; if (iop->_flag & _IORW) iop->_flag &= ~_IOREAD; } else iop->_flag |= _IOERR; iop->_cnt = 0; return(EOF); } return(*iop->_ptr++&0377); } ================================================ FILE: lib/libc/stdio/fileno.c ================================================ /* $OpenBSD: fileno.c,v 1.5 2005/08/08 08:05:36 espie Exp $ */ /*- * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Chris Torek. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include /* * A subroutine version of the macro fileno. */ #undef fileno int fileno(FILE *fp) { return (__sfileno(fp)); } ================================================ FILE: lib/libc/stdio/findiop.c ================================================ /* * Copyright (c) 1983, 1985 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include #include #include #include extern int errno; #define active(iop) ((iop)->_flag & (_IOREAD|_IOWRT|_IORW)) #define NSTATIC 20 /* stdin + stdout + stderr + the usual */ FILE _iob[NSTATIC] = { { 0, NULL, NULL, 0, _IOREAD, 0 }, /* stdin */ { 0, NULL, NULL, 0, _IOWRT, 1 }, /* stdout */ { 0, NULL, NULL, 0, _IOWRT|_IONBF, 2 }, /* stderr */ }; static char sbuf[NSTATIC]; char *_smallbuf = sbuf; static FILE **iobglue; static FILE **endglue; static int _f_morefiles() { register FILE **iov; register FILE *fp; int nfiles; nfiles = getdtablesize(); iobglue = (FILE **)calloc(nfiles, sizeof *iobglue); if (iobglue == NULL) return (0); endglue = iobglue + nfiles; for (fp = _iob, iov = iobglue; fp < &_iob[NSTATIC]; /* void */) *iov++ = fp++; _smallbuf = calloc(nfiles, sizeof(*_smallbuf)); return (1); } /* * Find a free FILE for fopen et al. * We have a fixed static array of entries, and in addition * may allocate additional entries dynamically, up to the kernel * limit on the number of open files. * At first just check for a free slot in the fixed static array. * If none are available, then we allocate a structure to glue together * the old and new FILE entries, which are then no longer contiguous. */ FILE * _findiop() { register FILE **iov, *iop; if (iobglue == 0) { for (iop = _iob; iop < _iob + NSTATIC; iop++) if (!active(iop)) return (iop); if (_f_morefiles() == 0) { errno = ENOMEM; return (NULL); } } iov = iobglue; while (*iov != NULL && active(*iov)) if (++iov >= endglue) { errno = EMFILE; return (NULL); } if (*iov == NULL) *iov = (FILE *)calloc(1, sizeof **iov); return (*iov); } void f_prealloc() { register FILE **iov; if (iobglue == NULL && _f_morefiles() == 0) return; for (iov = iobglue; iov < endglue; iov++) if (*iov == NULL) *iov = (FILE *)calloc(1, sizeof **iov); } void _fwalk(function) register int (*function)(); { register FILE **iov; register FILE *fp; if (iobglue == NULL) { for (fp = _iob; fp < &_iob[NSTATIC]; fp++) if (active(fp)) (*function)(fp); } else { for (iov = iobglue; iov < endglue; iov++) if (*iov && active(*iov)) (*function)(*iov); } } void _cleanup() { extern int fclose(); _fwalk(fclose); } ================================================ FILE: lib/libc/stdio/flsbuf.c ================================================ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include #include #include #include #include int _flsbuf(c, iop) unsigned char c; register FILE *iop; { register char *base; register int n, rn; char c1; int size; struct stat stbuf; if (iop->_flag & _IORW) { iop->_flag |= _IOWRT; iop->_flag &= ~(_IOEOF|_IOREAD); } if ((iop->_flag&_IOWRT)==0) return(EOF); tryagain: if (iop->_flag&_IOLBF) { base = iop->_base; *iop->_ptr++ = c; if (iop->_ptr >= base+iop->_bufsiz || c == '\n') { n = write(fileno(iop), base, rn = iop->_ptr - base); iop->_ptr = base; iop->_cnt = 0; } else rn = n = 0; } else if (iop->_flag&_IONBF) { c1 = c; rn = 1; n = write(fileno(iop), &c1, rn); iop->_cnt = 0; } else { if ((base=iop->_base)==NULL) { if (fstat(fileno(iop), &stbuf) < 0 || stbuf.st_blksize <= NULL) size = BUFSIZ; else size = stbuf.st_blksize; if ((iop->_base=base=malloc(size)) == NULL) { iop->_flag |= _IONBF; goto tryagain; } iop->_flag |= _IOMYBUF; iop->_bufsiz = size; if (iop==stdout && isatty(fileno(stdout))) { iop->_flag |= _IOLBF; iop->_ptr = base; goto tryagain; } rn = n = 0; } else if ((rn = n = iop->_ptr - base) > 0) { iop->_ptr = base; n = write(fileno(iop), base, n); } iop->_cnt = iop->_bufsiz-1; *base++ = c; iop->_ptr = base; } if (rn != n) { iop->_flag |= _IOERR; return(EOF); } return(c); } int fflush(iop) register FILE *iop; { register char *base; register int n; if ((iop->_flag&(_IONBF|_IOWRT))==_IOWRT && (base=iop->_base)!=NULL && (n=iop->_ptr-base)>0) { iop->_ptr = base; iop->_cnt = (iop->_flag&(_IOLBF|_IONBF)) ? 0 : iop->_bufsiz; if (write(fileno(iop), base, n)!=n) { iop->_flag |= _IOERR; return(EOF); } } return(0); } int fclose(iop) register FILE *iop; { register int r; r = EOF; if (iop->_flag&(_IOREAD|_IOWRT|_IORW) && (iop->_flag&_IOSTRG)==0) { r = fflush(iop); if (close(fileno(iop)) < 0) r = EOF; if (iop->_flag&_IOMYBUF) free(iop->_base); } iop->_cnt = 0; iop->_base = (char *)NULL; iop->_ptr = (char *)NULL; iop->_bufsiz = 0; iop->_flag = 0; iop->_file = 0; return(r); } ================================================ FILE: lib/libc/stdio/fopen.c ================================================ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include #include #include #include #include FILE * fopen(file, mode) const char *file; register const char *mode; { register FILE *iop; register int f, rw, oflags; extern FILE *_findiop(); iop = _findiop(); if (iop == NULL) return (NULL); rw = (mode[1] == '+'); switch (*mode) { case 'a': oflags = O_CREAT | (rw ? O_RDWR : O_WRONLY); break; case 'r': oflags = rw ? O_RDWR : O_RDONLY; break; case 'w': oflags = O_TRUNC | O_CREAT | (rw ? O_RDWR : O_WRONLY); break; default: return (NULL); } f = open(file, oflags, 0666); if (f < 0) return (NULL); if (*mode == 'a') lseek(f, (off_t)0, L_XTND); iop->_cnt = 0; iop->_file = f; iop->_bufsiz = 0; if (rw) iop->_flag = _IORW; else if (*mode == 'r') iop->_flag = _IOREAD; else iop->_flag = _IOWRT; iop->_base = iop->_ptr = NULL; return (iop); } ================================================ FILE: lib/libc/stdio/fprintf.c ================================================ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include #include #include int fprintf (register FILE *iop, const char *fmt, ...) { va_list ap; va_start (ap, fmt); if (iop->_flag & _IONBF) { iop->_flag &= ~_IONBF; iop->_ptr = iop->_base = alloca(BUFSIZ); iop->_bufsiz = BUFSIZ; _doprnt(fmt, ap, iop); fflush(iop); iop->_flag |= _IONBF; iop->_base = NULL; iop->_bufsiz = NULL; iop->_cnt = 0; } else _doprnt(fmt, ap, iop); va_end (ap); return(ferror(iop)? EOF: 0); } ================================================ FILE: lib/libc/stdio/fputc.c ================================================ #include int fputc (c, fp) register int c; register FILE *fp; { return putc (c, fp); } ================================================ FILE: lib/libc/stdio/fputs.c ================================================ /* * Copyright (c) 1984 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include #include int fputs(s, iop) register const char *s; register FILE *iop; { register int r = 0, c; int unbuffered; unbuffered = iop->_flag & _IONBF; if (unbuffered) { iop->_flag &= ~_IONBF; iop->_ptr = iop->_base = alloca(BUFSIZ); iop->_bufsiz = BUFSIZ; } while ((c = *s++)) r = putc(c, iop); if (unbuffered) { fflush(iop); iop->_flag |= _IONBF; iop->_base = NULL; iop->_bufsiz = NULL; iop->_cnt = 0; } return(r); } ================================================ FILE: lib/libc/stdio/fread.c ================================================ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include #include size_t fread (vptr, size, count, iop) register void *vptr; size_t size, count; register FILE *iop; { register char *ptr = vptr; register unsigned s; int c; s = size * count; while (s > 0) { if (iop->_cnt < s) { if (iop->_cnt > 0) { bcopy(iop->_ptr, ptr, iop->_cnt); ptr += iop->_cnt; s -= iop->_cnt; } /* * filbuf clobbers _cnt & _ptr, * so don't waste time setting them. */ if ((c = _filbuf(iop)) == EOF) break; *ptr++ = c; s--; } if (iop->_cnt >= s) { bcopy(iop->_ptr, ptr, s); iop->_ptr += s; iop->_cnt -= s; return (count); } } return (size != 0 ? count - ((s + size - 1) / size) : 0); } ================================================ FILE: lib/libc/stdio/freopen.c ================================================ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include #include #include #include #include FILE * freopen(file, mode, iop) const char *file; register const char *mode; register FILE *iop; { register int f, rw, oflags; rw = (mode[1] == '+'); fclose(iop); switch (*mode) { case 'a': oflags = O_CREAT | (rw ? O_RDWR : O_WRONLY); break; case 'r': oflags = rw ? O_RDWR : O_RDONLY; break; case 'w': oflags = O_TRUNC | O_CREAT | (rw ? O_RDWR : O_WRONLY); break; default: return (NULL); } f = open(file, oflags, 0666); if (f < 0) return (NULL); if (*mode == 'a') lseek(f, (off_t)0, L_XTND); iop->_cnt = 0; iop->_file = f; iop->_bufsiz = 0; if (rw) iop->_flag = _IORW; else if (*mode == 'r') iop->_flag = _IOREAD; else iop->_flag = _IOWRT; iop->_base = iop->_ptr = NULL; return (iop); } ================================================ FILE: lib/libc/stdio/fseek.c ================================================ /* * Seek for standard library. Coordinates with buffering. */ #include #include int fseek(iop, offset, ptrname) register FILE *iop; long offset; int ptrname; { register int resync, c; long p = -1; /* can't happen? */ iop->_flag &= ~_IOEOF; if (iop->_flag&_IOREAD) { if (ptrname<2 && iop->_base && !(iop->_flag&_IONBF)) { c = iop->_cnt; p = offset; if (ptrname==0) { long curpos = lseek(fileno(iop), 0L, 1); if (curpos == -1) return (-1); p += c - curpos; } else offset -= c; if(!(iop->_flag&_IORW) && c>0&&p<=c && p>=iop->_base-iop->_ptr){ iop->_ptr += (int)p; iop->_cnt -= (int)p; return(0); } resync = offset&01; } else resync = 0; if (iop->_flag & _IORW) { iop->_ptr = iop->_base; iop->_flag &= ~_IOREAD; resync = 0; } p = lseek(fileno(iop), offset-resync, ptrname); iop->_cnt = 0; if (resync && p != -1) if (getc(iop) == EOF) p = -1; } else if (iop->_flag & (_IOWRT|_IORW)) { p = fflush(iop); if (iop->_flag & _IORW) { iop->_cnt = 0; iop->_flag &= ~_IOWRT; iop->_ptr = iop->_base; } return(lseek(fileno(iop), offset, ptrname) == -1 || p == EOF ? -1 : 0); } return(p==-1?-1:0); } ================================================ FILE: lib/libc/stdio/ftell.c ================================================ /* * Return file offset. * Coordinates with buffering. */ #include #include long ftell(iop) register FILE *iop; { register long tres; register int adjust; if (iop->_cnt < 0) iop->_cnt = 0; if (iop->_flag&_IOREAD) adjust = - iop->_cnt; else if (iop->_flag&(_IOWRT|_IORW)) { adjust = 0; if (iop->_flag&_IOWRT && iop->_base && (iop->_flag&_IONBF)==0) adjust = iop->_ptr - iop->_base; } else return(-1); tres = lseek(fileno(iop), 0L, 1); if (tres<0) return(tres); tres += adjust; return(tres); } ================================================ FILE: lib/libc/stdio/fwrite.c ================================================ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include #include size_t fwrite(vptr, size, count, iop) const void *vptr; size_t size, count; register FILE *iop; { register const char *ptr = vptr; register unsigned s; s = size * count; if (iop->_flag & _IOLBF) while (s > 0) { if (--iop->_cnt > -iop->_bufsiz && *ptr != '\n') *iop->_ptr++ = *ptr++; else if (_flsbuf(*(unsigned char *)ptr++, iop) == EOF) break; s--; } else while (s > 0) { if (iop->_cnt < s) { if (iop->_cnt > 0) { bcopy(ptr, iop->_ptr, iop->_cnt); ptr += iop->_cnt; iop->_ptr += iop->_cnt; s -= iop->_cnt; } if (_flsbuf(*(unsigned char *)ptr++, iop) == EOF) break; s--; } if (iop->_cnt >= s) { bcopy(ptr, iop->_ptr, s); iop->_ptr += s; iop->_cnt -= s; return (count); } } return (size != 0 ? count - ((s + size - 1) / size) : 0); } ================================================ FILE: lib/libc/stdio/getchar.c ================================================ /* * A subroutine version of the macro getchar. */ #define USE_STDIO_MACROS #include #undef getchar int getchar() { return getc(stdin); } ================================================ FILE: lib/libc/stdio/gets.c ================================================ #include char * gets(s) char *s; { register int c; register char *cs; cs = s; while ((c = getchar()) != '\n' && c != EOF) *cs++ = c; if (c == EOF && cs==s) return(NULL); *cs++ = '\0'; return(s); } ================================================ FILE: lib/libc/stdio/getw.c ================================================ #include int getw(iop) register FILE *iop; { register int i; register char *p; int w; p = (char *)&w; for (i=sizeof(int); --i>=0;) *p++ = getc(iop); if (feof(iop)) return(EOF); return(w); } #ifdef pdp11 long getlw(iop) register FILE *iop; { register int i; register char *p; long w; p = (char *)&w; for (i=sizeof(long); --i>=0;) *p++ = getc(iop); if (feof(iop)) return(EOF); return(w); } #endif ================================================ FILE: lib/libc/stdio/printf.c ================================================ #include #include int printf (const char *fmt, ...) { va_list args; va_start (args, fmt); _doprnt (fmt, args, stdout); va_end (args); return ferror (stdout) ? EOF : 0; } ================================================ FILE: lib/libc/stdio/putchar.c ================================================ /* * A subroutine version of the macro putchar */ #define USE_STDIO_MACROS #include #undef putchar int putchar(c) register int c; { return putc(c, stdout); } ================================================ FILE: lib/libc/stdio/puts.c ================================================ #include int puts(s) register const char *s; { register int c; while ((c = *s++)) putchar(c); return(putchar('\n')); } ================================================ FILE: lib/libc/stdio/putw.c ================================================ #include int putw(w, iop) int w; register FILE *iop; { register char *p; register int i; p = (char *)&w; for (i=sizeof(int); --i>=0;) putc(*p++, iop); return(ferror(iop)); } #ifdef pdp11 int putlw(w, iop) long w; register FILE *iop; { register char *p; register int i; p = (char *)&w; for (i=sizeof(long); --i>=0;) putc(*p++, iop); return(ferror(iop)); } #endif ================================================ FILE: lib/libc/stdio/remove.c ================================================ /*- * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Chris Torek. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #include #include #include int remove(file) const char *file; { struct stat sb; if (lstat(file, &sb) < 0) return (-1); if (S_ISDIR(sb.st_mode)) return (rmdir(file)); return (unlink(file)); } ================================================ FILE: lib/libc/stdio/rew.c ================================================ #include #include void rewind(iop) register FILE *iop; { fflush(iop); lseek(fileno(iop), 0L, 0); iop->_cnt = 0; iop->_ptr = iop->_base; iop->_flag &= ~(_IOERR|_IOEOF); if (iop->_flag & _IORW) iop->_flag &= ~(_IOREAD|_IOWRT); } ================================================ FILE: lib/libc/stdio/scanf.c ================================================ #include #include int scanf (const char *fmt, ...) { va_list args; int n; va_start (args, fmt); n = _doscan (stdin, fmt, args); va_end (args); return n; } int fscanf (FILE *iop, const char *fmt, ...) { va_list args; int n; va_start (args, fmt); n = _doscan(iop, fmt, args); va_end (args); return n; } int sscanf (const char *str, const char *fmt, ...) { FILE _strbuf; va_list args; int n; _strbuf._flag = _IOREAD|_IOSTRG; _strbuf._ptr = _strbuf._base = (void*) str; _strbuf._cnt = 0; while (*str++) _strbuf._cnt++; _strbuf._bufsiz = _strbuf._cnt; va_start (args, fmt); n = _doscan(&_strbuf, fmt, args); va_end (args); return n; } ================================================ FILE: lib/libc/stdio/setbuf.c ================================================ /*- * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Chris Torek. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include void setbuf(fp, buf) FILE *fp; char *buf; { (void) setvbuf(fp, buf, buf ? _IOFBF : _IONBF, BUFSIZ); } ================================================ FILE: lib/libc/stdio/setbuffer.c ================================================ /*- * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Chris Torek. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #include void setbuffer(fp, buf, size) register FILE *fp; char *buf; size_t size; { setvbuf(fp, buf, buf ? _IOFBF : _IONBF, size); } /* * set line buffering */ void setlinebuf(fp) FILE *fp; { setvbuf(fp, (char *)NULL, _IOLBF, (size_t)0); } ================================================ FILE: lib/libc/stdio/setvbuf.c ================================================ /*- * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Chris Torek. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #include #include /* * This has been slightly trimmed from the 4.4BSD version for use with 2.11BSD. * In particular 1) the flag names were changed back to the original ones * since I didn't feel like porting all of 4.4's stdio package right now and * 2) The constant BUFSIZ is used rather than importing the "optimum buffer * size selection" logic from 4.4 (besides, a PDP11 can't afford more than 1kb * most of the time anyhow). * * Set one of the three kinds of buffering, optionally including * a buffer. */ int setvbuf(fp, buf, mode, size) register FILE *fp; char *buf; register int mode; size_t size; { int ret; register int flags; /* * Verify arguments. Note, buf and size are ignored when setting _IONBF. */ if (mode != _IONBF) if ((mode != _IOFBF && mode != _IOLBF) || (int)size < 0) return (EOF); /* * Write current buffer, if any. Discard unread input, cancel * line buffering, and free old buffer if malloc()ed. */ (void)fflush(fp); fp->_cnt = fp->_bufsiz = 0; flags = fp->_flag; if (flags & _IOMYBUF) free((void *)fp->_base); flags &= ~(_IOLBF | _IONBF | _IOMYBUF); ret = 0; /* If setting unbuffered mode, skip all the hard work. */ if (mode == _IONBF) goto nbf; if (size == 0) { buf = NULL; /* force local allocation */ size = BUFSIZ; } /* Allocate buffer if needed. */ if (buf == NULL) { if ((buf = (char *)malloc(size)) == NULL) { /* * Unable to honor user's request. We will return * failure, but try again with file system size. */ ret = EOF; if (size != BUFSIZ) { size = BUFSIZ; buf = (char *)malloc(size); } } if (buf == NULL) { /* No luck; switch to unbuffered I/O. */ nbf: fp->_flag = flags | _IONBF; fp->_base = fp->_ptr = NULL; return (ret); } flags |= _IOMYBUF; } /* * Fix up the FILE fields. If in r/w mode, go to the unknown state * so that the the first read performs its initial call to _filbuf and * the first write has an empty buffer to fill. */ if (mode == _IOLBF) flags |= _IOLBF; if (flags & _IORW) flags &= ~(_IOREAD | _IOWRT); fp->_flag = flags; fp->_base = fp->_ptr = (char *)buf; fp->_bufsiz = size; return (ret); } ================================================ FILE: lib/libc/stdio/snprintf.c ================================================ /* * Copyright (c) 1988 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the University of California, Berkeley. The name of the * University may not be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #include #include int snprintf (char *str, size_t nbytes, const char *fmt, ...) { FILE _strbuf; va_list args; _strbuf._flag = _IOWRT+_IOSTRG; _strbuf._ptr = str; _strbuf._cnt = nbytes; va_start (args, fmt); _doprnt (fmt, args, &_strbuf); va_end (args); *_strbuf._ptr = 0; return _strbuf._ptr - str; } ================================================ FILE: lib/libc/stdio/sprintf.c ================================================ /* * Copyright (c) 1988 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the University of California, Berkeley. The name of the * University may not be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #include #include int sprintf (char *str, const char *fmt, ...) { FILE _strbuf; va_list args; _strbuf._flag = _IOWRT+_IOSTRG; _strbuf._ptr = str; _strbuf._cnt = 32767; va_start (args, fmt); _doprnt (fmt, args, &_strbuf); va_end (args); *_strbuf._ptr = 0; return _strbuf._ptr - str; } ================================================ FILE: lib/libc/stdio/strout.c ================================================ #include void _strout(count, string, adjust, file, fillch) register char *string; register int count; int adjust; register FILE *file; int fillch; { while (adjust < 0) { if (*string=='-' && fillch=='0') { putc(*string++, file); count--; } putc(fillch, file); adjust++; } while (--count>=0) putc(*string++, file); while (adjust) { putc(fillch, file); adjust--; } } ================================================ FILE: lib/libc/stdio/ungetc.c ================================================ #include int ungetc(c, iop) int c; register FILE *iop; { if (c == EOF || (iop->_flag & (_IOREAD|_IORW)) == 0 || iop->_ptr == NULL || iop->_base == NULL) return (EOF); if (iop->_ptr == iop->_base) { if (iop->_cnt == 0) iop->_ptr++; else return (EOF); } iop->_cnt++; *--iop->_ptr = c; return (c); } ================================================ FILE: lib/libc/stdio/vfprintf.c ================================================ /* * Copyright (c) 1988 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the University of California, Berkeley. The name of the * University may not be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #include #include #include int vfprintf(FILE *iop, const char *fmt, va_list ap) { int len; if (iop->_flag & _IONBF) { iop->_flag &= ~_IONBF; iop->_ptr = iop->_base = alloca(BUFSIZ); len = _doprnt(fmt, ap, iop); (void) fflush(iop); iop->_flag |= _IONBF; iop->_base = NULL; iop->_bufsiz = 0; iop->_cnt = 0; } else len = _doprnt(fmt, ap, iop); return (ferror(iop) ? EOF : len); } ================================================ FILE: lib/libc/stdio/vprintf.c ================================================ /* * Copyright (c) 1988 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the University of California, Berkeley. The name of the * University may not be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #include #include int vprintf(const char *fmt, va_list ap) { int len; len = _doprnt(fmt, ap, stdout); return (ferror(stdout) ? EOF : len); } ================================================ FILE: lib/libc/stdio/vsprintf.c ================================================ /* * Copyright (c) 1988 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the University of California, Berkeley. The name of the * University may not be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #include #include int vsprintf(char *str, const char *fmt, va_list ap) { FILE f; f._flag = _IOWRT+_IOSTRG; f._ptr = str; f._cnt = 32767; _doprnt(fmt, ap, &f); *f._ptr = 0; return (f._ptr - str); } ================================================ FILE: lib/libc/stdlib/Makefile ================================================ # # This is the Makefile for 'stdlib'. New routines ported from 4.4BSD's # libc/stdlib directory go here but existing libc/gen files are being left # where they are. # TOPSRC!=cd ../../..; pwd include ${TOPSRC}/share/mk/sys.mk DEFS = CFLAGS += ${DEFS} -Os SRCS = getopt.c getsubopt.c strtol.c strtoul.c strtod.c OBJS = getopt.o getsubopt.o strtol.o strtoul.o strtod.o all: stdlib.a stdlib.a: ${OBJS} @echo "building stdlib.a" @${AR} cr stdlib.a ${OBJS} clean: rm -f *.o *~ profiled/*.o tags Makefile.bak stdlib.a stdlib_p.s depend: ${SRCS} mkdep ${CFLAGS} ${SRCS} tags: cwd=`pwd`; \ for i in ${SRCS}; do \ ctags -a -f ${TAGSFILE} $$cwd/$$i; \ done # DO NOT DELETE THIS LINE -- mkdep uses it. # DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY. ================================================ FILE: lib/libc/stdlib/getopt.c ================================================ /* * Copyright (c) 1987, 1993, 1994 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #include #include #include int opterr = 1, /* if error message should be printed */ optind = 1, /* index into parent argv vector */ optopt, /* character checked for validity */ optreset; /* reset getopt */ char *optarg; /* argument associated with option */ #define BADCH (int)'?' #define BADARG (int)':' #define EMSG "" /* * getopt -- * Parse argc/argv argument vector. */ int getopt(nargc, nargv, ostr) int nargc; char * const nargv[]; const char *ostr; { static char *place = EMSG; /* option letter processing */ char *oli; /* option letter list index */ if (optreset || !*place) { /* update scanning pointer */ optreset = 0; if (optind >= nargc || *(place = nargv[optind]) != '-') { place = EMSG; return (EOF); } if (place[1] && *++place == '-') { /* found "--" */ ++optind; place = EMSG; return (EOF); } } /* option letter okay? */ if ((optopt = (int)*place++) == (int)':' || !(oli = strchr(ostr, optopt))) { /* * if the user didn't specify '-' as an option, * assume it means EOF. */ if (optopt == (int)'-') return (EOF); if (!*place) ++optind; if (opterr && *ostr != ':') (void)fprintf(stderr, "%s: illegal option -- %c\n", __progname, optopt); return (BADCH); } if (*++oli != ':') { /* don't need argument */ optarg = NULL; if (!*place) ++optind; } else { /* need an argument */ if (*place) /* no white space */ optarg = place; else if (nargc <= ++optind) { /* no arg */ place = EMSG; if (*ostr == ':') return (BADARG); if (opterr) (void)fprintf(stderr, "%s: option requires an argument -- %c\n", __progname, optopt); return (BADCH); } else /* white space */ optarg = nargv[optind]; place = EMSG; ++optind; } return (optopt); /* dump back option letter */ } ================================================ FILE: lib/libc/stdlib/getsubopt.c ================================================ /*- * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #include /* * The SVID interface to getsubopt provides no way of figuring out which * part of the suboptions list wasn't matched. This makes error messages * tricky... The extern variable suboptarg is a pointer to the token * which didn't match. */ char *suboptarg; int getsubopt(optionp, tokens, valuep) register char **optionp; register char **valuep; register char **tokens; { register int cnt; register char *p; suboptarg = *valuep = NULL; if (!optionp || !*optionp) return(-1); /* skip leading white-space, commas */ for (p = *optionp; *p && (*p == ',' || *p == ' ' || *p == '\t'); ++p); if (!*p) { *optionp = p; return(-1); } /* save the start of the token, and skip the rest of the token. */ for (suboptarg = p; *++p && *p != ',' && *p != '=' && *p != ' ' && *p != '\t';); if (*p) { /* * If there's an equals sign, set the value pointer, and * skip over the value part of the token. Terminate the * token. */ if (*p == '=') { *p = '\0'; for (*valuep = ++p; *p && *p != ',' && *p != ' ' && *p != '\t'; ++p); if (*p) *p++ = '\0'; } else *p++ = '\0'; /* Skip any whitespace or commas after this token. */ for (; *p && (*p == ',' || *p == ' ' || *p == '\t'); ++p); } /* set optionp for next round. */ *optionp = p; for (cnt = 0; *tokens; ++tokens, ++cnt) if (!strcmp(suboptarg, *tokens)) return(cnt); return(-1); } ================================================ FILE: lib/libc/stdlib/strtod.c ================================================ /* * double strtodx (char *string, char **endPtr, int radix) * This procedure converts a floating-point number from an ASCII * decimal representation to internal double-precision format. * * Original sources taken from 386bsd and modified for variable radix * by Serge Vakulenko, . * * Arguments: * string * A decimal ASCII floating-point number, optionally preceded * by white space. Must have form "-I.FE-X", where I is the integer * part of the mantissa, F is the fractional part of the mantissa, * and X is the exponent. Either of the signs may be "+", "-", or * omitted. Either I or F may be omitted, or both. The decimal point * isn't necessary unless F is present. The "E" may actually be an "e", * or "E", "S", "s", "F", "f", "D", "d", "L", "l". * E and X may both be omitted (but not just one). * * endPtr * If non-NULL, store terminating character's address here. * * radix * Radix of floating point, one of 2, 8, 10, 16. * * The return value is the double-precision floating-point * representation of the characters in string. If endPtr isn't * NULL, then *endPtr is filled in with the address of the * next character after the last one that was part of the * floating-point number. */ #include #include double strtod (const char *string, char **endPtr) { int sign = 0, expSign = 0, i; double fraction, dblExp; register const char *p; register char c; /* Exponent read from "EX" field. */ int exp = 0; /* Exponent that derives from the fractional part. Under normal * circumstances, it is the negative of the number of digits in F. * However, if I is very long, the last digits of I get dropped * (otherwise a long I with a large negative exponent could cause an * unnecessary overflow on I alone). In this case, fracExp is * incremented one for each dropped digit. */ int fracExp = 0; /* Number of digits in mantissa. */ int mantSize; /* Number of mantissa digits BEFORE decimal point. */ int decPt; /* Temporarily holds location of exponent in string. */ const char *pExp; /* Largest possible base 10 exponent. * Any exponent larger than this will already * produce underflow or overflow, so there's * no need to worry about additional digits. */ static int maxExponent = 307; /* Table giving binary powers of 10. * Entry is 10^2^i. Used to convert decimal * exponents into floating-point numbers. */ static double powersOf10[] = { 1e1, 1e2, 1e4, 1e8, 1e16, 1e32, /*1e64, 1e128, 1e256,*/ }; #if 0 static double powersOf2[] = { 2, 4, 16, 256, 65536, 4.294967296e9, 1.8446744073709551616e19, /*3.4028236692093846346e38, 1.1579208923731619542e77, 1.3407807929942597099e154,*/ }; static double powersOf8[] = { 8, 64, 4096, 2.81474976710656e14, 7.9228162514264337593e28, /*6.2771017353866807638e57, 3.9402006196394479212e115, 1.5525180923007089351e231,*/ }; static double powersOf16[] = { 16, 256, 65536, 1.8446744073709551616e19, /*3.4028236692093846346e38, 1.1579208923731619542e77, 1.3407807929942597099e154,*/ }; #endif /* * Strip off leading blanks and check for a sign. */ p = string; while (*p==' ' || *p=='\t') ++p; if (*p == '-') { sign = 1; ++p; } else if (*p == '+') ++p; /* * Count the number of digits in the mantissa (including the decimal * point), and also locate the decimal point. */ decPt = -1; for (mantSize=0; ; ++mantSize) { c = *p; if (! isdigit (c)) { if (c != '.' || decPt >= 0) break; decPt = mantSize; } ++p; } /* * Now suck up the digits in the mantissa. Use two integers to * collect 9 digits each (this is faster than using floating-point). * If the mantissa has more than 18 digits, ignore the extras, since * they can't affect the value anyway. */ pExp = p; p -= mantSize; if (decPt < 0) decPt = mantSize; else --mantSize; /* One of the digits was the point. */ if (mantSize > 2 * 9) mantSize = 2 * 9; fracExp = decPt - mantSize; if (mantSize == 0) { fraction = 0.0; p = string; goto done; } else { int frac1, frac2; for (frac1=0; mantSize>9; --mantSize) { c = *p++; if (c == '.') c = *p++; frac1 = frac1 * 10 + (c - '0'); } for (frac2=0; mantSize>0; --mantSize) { c = *p++; if (c == '.') c = *p++; frac2 = frac2 * 10 + (c - '0'); } fraction = (double) 1000000000 * frac1 + frac2; } /* * Skim off the exponent. */ p = pExp; if (*p=='E' || *p=='e' || *p=='S' || *p=='s' || *p=='F' || *p=='f' || *p=='D' || *p=='d' || *p=='L' || *p=='l') { ++p; if (*p == '-') { expSign = 1; ++p; } else if (*p == '+') ++p; while (isdigit (*p)) exp = exp * 10 + (*p++ - '0'); } if (expSign) exp = fracExp - exp; else exp = fracExp + exp; /* * Generate a floating-point number that represents the exponent. * Do this by processing the exponent one bit at a time to combine * many powers of 2 of 10. Then combine the exponent with the * fraction. */ if (exp < 0) { expSign = 1; exp = -exp; } else expSign = 0; if (exp > maxExponent) exp = maxExponent; dblExp = 1.0; for (i=0; exp; exp>>=1, ++i) if (exp & 01) dblExp *= powersOf10[i]; if (expSign) fraction /= dblExp; else fraction *= dblExp; done: if (endPtr) *endPtr = (char*) p; return sign ? -fraction : fraction; } ================================================ FILE: lib/libc/stdlib/strtol.c ================================================ /*- * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #include #include #include /* * Convert a string to a long integer. * * Ignores `locale' stuff. Assumes that the upper and lower case * alphabets and digits are each contiguous. */ long strtol(nptr, endptr, base) const char *nptr; char **endptr; register int base; { register const char *s = nptr; register unsigned long acc; register int c; register unsigned long cutoff; register int neg = 0, any, cutlim; /* * Skip white space and pick up leading +/- sign if any. * If base is 0, allow 0x for hex and 0 for octal, else * assume decimal; if base is already 16, allow 0x. */ do { c = *s++; } while (isspace(c)); if (c == '-') { neg = 1; c = *s++; } else if (c == '+') c = *s++; if ((base == 0 || base == 16) && c == '0' && (*s == 'x' || *s == 'X')) { c = s[1]; s += 2; base = 16; } if (base == 0) base = c == '0' ? 8 : 10; /* * Compute the cutoff value between legal numbers and illegal * numbers. That is the largest legal value, divided by the * base. An input number that is greater than this value, if * followed by a legal input character, is too big. One that * is equal to this value may be valid or not; the limit * between valid and invalid numbers is then based on the last * digit. For instance, if the range for longs is * [-2147483648..2147483647] and the input base is 10, * cutoff will be set to 214748364 and cutlim to either * 7 (neg==0) or 8 (neg==1), meaning that if we have accumulated * a value > 214748364, or equal but the next digit is > 7 (or 8), * the number is too big, and we will return a range error. * * Set any if any `digits' consumed; make it negative to indicate * overflow. */ cutoff = neg ? -(unsigned long)LONG_MIN : LONG_MAX; cutlim = cutoff % (unsigned long)base; cutoff /= (unsigned long)base; for (acc = 0, any = 0;; c = *s++) { if (isdigit(c)) c -= '0'; else if (isalpha(c)) c -= isupper(c) ? 'A' - 10 : 'a' - 10; else break; if (c >= base) break; if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim)) any = -1; else { any = 1; acc *= base; acc += c; } } if (any < 0) { acc = neg ? LONG_MIN : LONG_MAX; errno = ERANGE; } else if (neg) acc = -acc; if (endptr != 0) *endptr = (char *)(any ? s - 1 : nptr); return (acc); } ================================================ FILE: lib/libc/stdlib/strtoul.c ================================================ /* * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #include #include #include /* * Convert a string to an unsigned long integer. * * Ignores `locale' stuff. Assumes that the upper and lower case * alphabets and digits are each contiguous. */ unsigned long strtoul(nptr, endptr, base) const char *nptr; char **endptr; register int base; { register const char *s = nptr; register unsigned long acc; register int c; register unsigned long cutoff; register int neg = 0, any, cutlim; /* * See strtol for comments as to the logic used. */ do { c = *s++; } while (isspace(c)); if (c == '-') { neg = 1; c = *s++; } else if (c == '+') c = *s++; if ((base == 0 || base == 16) && c == '0' && (*s == 'x' || *s == 'X')) { c = s[1]; s += 2; base = 16; } if (base == 0) base = c == '0' ? 8 : 10; cutoff = (unsigned long)ULONG_MAX / (unsigned long)base; cutlim = (unsigned long)ULONG_MAX % (unsigned long)base; for (acc = 0, any = 0;; c = *s++) { if (isdigit(c)) c -= '0'; else if (isalpha(c)) c -= isupper(c) ? 'A' - 10 : 'a' - 10; else break; if (c >= base) break; if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim)) any = -1; else { any = 1; acc *= base; acc += c; } } if (any < 0) { acc = ULONG_MAX; errno = ERANGE; } else if (neg) acc = -acc; if (endptr != 0) *endptr = (char *)(any ? s - 1 : nptr); return (acc); } ================================================ FILE: lib/libc/string/Makefile ================================================ # # This is the Makefile for the 'string' functions. New routines ported from # 4.4BSD's libc/string directory go here but existing libc/gen files are # being left where they are. # TOPSRC!=cd ../../..; pwd include ${TOPSRC}/share/mk/sys.mk DEFS = CFLAGS += ${DEFS} -Os SRCS= strcspn.c strerror.c strlcat.c strlcpy.c strpbrk.c \ strsep.c strspn.c strstr.c strtok.c strtok_r.c OBJS= strcspn.o strerror.o strlcat.o strlcpy.o strpbrk.o \ strsep.o strspn.o strstr.o strtok.o strtok_r.o all: string.a string.a: ${OBJS} @echo "building normal string.a" @${AR} cr string.a ${OBJS} clean: rm -f *.o *~ profiled/*.o tags Makefile.bak string.a string_p.a depend: ${SRCS} mkdep ${CFLAGS} ${SRCS} tags: cwd=`pwd`; \ for i in ${SRCS}; do \ ctags -a -f ${TAGSFILE} $$cwd/$$i; \ done # DO NOT DELETE THIS LINE -- mkdep uses it. # DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY. ================================================ FILE: lib/libc/string/strcspn.c ================================================ /*- * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Chris Torek. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #include /* * Span the complement of string s2. */ size_t strcspn (s1, s2) const char *s1; const char *s2; { register const char *p, *spanp; register char c, sc; /* * Stop as soon as we find any character from s2. Note that there * must be a NUL in s2; it suffices to stop when we find that, too. */ for (p = s1;;) { c = *p++; spanp = s2; do { if ((sc = *spanp++) == c) return (p - 1 - s1); } while (sc != 0); } /* NOTREACHED */ } ================================================ FILE: lib/libc/string/strerror.c ================================================ /* * Copyright (c) 1988, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #include #include char * strerror(errnum) register int errnum; { static char msgstr[64]; int mib[3]; size_t size; /* Read an error message from kernel to a static buffer. */ mib[0] = CTL_MACHDEP; mib[1] = CPU_ERRMSG; mib[2] = errnum; size = sizeof (msgstr); if (sysctl(mib, 3, msgstr, &size, NULL, 0) == -1) { /* Do this by hand, so we don't include stdio(3). */ static const char unknown[] = "Unknown error: "; register char *p, *t; const char *q; char tmp[20]; t = tmp; do { *t++ = '0' + ((unsigned)errnum % 10); errnum = (unsigned)errnum / 10; } while (errnum != 0); p = msgstr; for (q=unknown; *q; q++) { *p++ = *q; } do { *p++ = *--t; } while (t > tmp); *p = 0; } return msgstr; } ================================================ FILE: lib/libc/string/strlcat.c ================================================ /* $OpenBSD: strlcat.c,v 1.19 2019/01/25 00:19:25 millert Exp $ */ /* * Copyright (c) 1998, 2015 Todd C. Miller * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include #include /* * Appends src to string dst of size dsize (unlike strncat, dsize is the * full size of dst, not space left). At most dsize-1 characters * will be copied. Always NUL terminates (unless dsize <= strlen(dst)). * Returns strlen(src) + MIN(dsize, strlen(initial dst)). * If retval >= dsize, truncation occurred. */ size_t strlcat(char *dst, const char *src, size_t dsize) { const char *odst = dst; const char *osrc = src; size_t n = dsize; size_t dlen; /* Find the end of dst and adjust bytes left but don't go past end. */ while (n-- != 0 && *dst != '\0') dst++; dlen = dst - odst; n = dsize - dlen; if (n-- == 0) return(dlen + strlen(src)); while (*src != '\0') { if (n != 0) { *dst++ = *src; n--; } src++; } *dst = '\0'; return(dlen + (src - osrc)); /* count does not include NUL */ } ================================================ FILE: lib/libc/string/strlcpy.c ================================================ /* $OpenBSD: strlcpy.c,v 1.16 2019/01/25 00:19:25 millert Exp $ */ /* * Copyright (c) 1998, 2015 Todd C. Miller * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include #include /* * Copy string src to buffer dst of size dsize. At most dsize-1 * chars will be copied. Always NUL terminates (unless dsize == 0). * Returns strlen(src); if retval >= dsize, truncation occurred. */ size_t strlcpy(char *dst, const char *src, size_t dsize) { const char *osrc = src; size_t nleft = dsize; /* Copy as many bytes as will fit. */ if (nleft != 0) { while (--nleft != 0) { if ((*dst++ = *src++) == '\0') break; } } /* Not enough room in dst, add NUL and traverse rest of src. */ if (nleft == 0) { if (dsize != 0) *dst = '\0'; /* NUL-terminate dst */ while (*src++) ; } return(src - osrc - 1); /* count does not include NUL */ } ================================================ FILE: lib/libc/string/strpbrk.c ================================================ /* * Copyright (c) 1985, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #include #include /* for NULL */ /* * Find the first occurrence in s1 of a character in s2 (excluding NUL). */ char * strpbrk(s1, s2) register const char *s1; const char *s2; { register const char *scanp; register int c; int sc; while ((c = *s1++) != 0) { for (scanp = s2; (sc = *scanp++) != 0;) if (sc == c) return ((char *)(s1 - 1)); } return (NULL); } ================================================ FILE: lib/libc/string/strsep.c ================================================ /*- * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #include #include /* * Get next token from string *stringp, where tokens are possibly-empty * strings separated by characters from delim. * * Writes NULs into the string at *stringp to end tokens. * delim need not remain constant from call to call. * On return, *stringp points past the last NUL written (if there might * be further tokens), or is NULL (if there are definitely no more tokens). * * If *stringp is NULL, strsep returns NULL. */ char * strsep(stringp, delim) register char **stringp; const char *delim; { register char *s; register const char *spanp; int c, sc; char *tok; if ((s = *stringp) == NULL) return (NULL); for (tok = s;;) { c = *s++; spanp = delim; do { if ((sc = *spanp++) == c) { if (c == 0) s = NULL; else s[-1] = 0; *stringp = s; return (tok); } } while (sc != 0); } /* NOTREACHED */ } ================================================ FILE: lib/libc/string/strspn.c ================================================ /* * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #include /* * Span the string s2 (skip characters that are in s2). */ size_t strspn(s1, s2) const char *s1; const char *s2; { register const char *p = s1, *spanp; register char c, sc; /* * Skip any characters in s2, excluding the terminating \0. */ cont: c = *p++; for (spanp = s2; (sc = *spanp++) != 0;) if (sc == c) goto cont; return (p - 1 - s1); } ================================================ FILE: lib/libc/string/strstr.c ================================================ /*- * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Chris Torek. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include /* * Find the first occurrence of find in s. */ char * strstr(s, find) register const char *s, *find; { register char c; char sc; size_t len; if ((c = *find++) != 0) { len = strlen(find); do { do { if ((sc = *s++) == 0) return (NULL); } while (sc != c); } while (strncmp(s, find, len) != 0); s--; } return ((char *)s); } ================================================ FILE: lib/libc/string/strtok.c ================================================ /* * Copyright (c) 1988, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #include char * strtok(s, delim) register char *s; register const char *delim; { register char *spanp; int c, sc; char *tok; static char *last; if (s == NULL && (s = last) == NULL) return (NULL); /* * Skip (span) leading delimiters (s += strspn(s, delim), sort of). */ cont: c = *s++; for (spanp = (char *)delim; (sc = *spanp++) != 0;) { if (c == sc) goto cont; } if (c == 0) { /* no non-delimiter characters */ last = NULL; return (NULL); } tok = s - 1; /* * Scan token (scan for delimiters: s += strcspn(s, delim), sort of). * Note that delim must have one NUL; we stop if we see that, too. */ for (;;) { c = *s++; spanp = (char *)delim; do { if ((sc = *spanp++) == c) { if (c == 0) s = NULL; else s[-1] = 0; last = s; return (tok); } } while (sc != 0); } /* NOTREACHED */ } ================================================ FILE: lib/libc/string/strtok_r.c ================================================ /* * Copyright (c) 1988, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #include char *strtok_r(char *s, const char *delim, char **last) { char *spanp, *tok; int c, sc; if (s == NULL && (s = *last) == NULL) return (NULL); /* * Skip (span) leading delimiters (s += strspn(s, delim), sort of). */ cont: c = *s++; for (spanp = (char *)delim; (sc = *spanp++) != 0;) { if (c == sc) goto cont; } if (c == 0) { /* no non-delimiter characters */ *last = NULL; return (NULL); } tok = s - 1; /* * Scan token (scan for delimiters: s += strcspn(s, delim), sort of). * Note that delim must have one NUL; we stop if we see that, too. */ for (;;) { c = *s++; spanp = (char *)delim; do { if ((sc = *spanp++) == c) { if (c == 0) s = NULL; else s[-1] = '\0'; *last = s; return (tok); } } while (sc != 0); } /* NOTREACHED */ } ================================================ FILE: lib/libc_aout/Makefile ================================================ # # libc_aout - a.out libraries, built with a.out utilities # SUBDIR= startup libc libm libcurses libtermlib \ libreadline libgpanel libwiznet all install: -for dir in ${SUBDIR}; do \ ${MAKE} -C $$dir ${MFLAGS} $@; \ done clean: rm -f *~ *.o *.a for dir in ${SUBDIR}; do \ ${MAKE} -C $$dir ${MFLAGS} clean; \ done ================================================ FILE: lib/libc_aout/libc/Makefile ================================================ TOPSRC!=cd ../../..; pwd include ${TOPSRC}/share/mk/sys.mk # Favor assembler source files over their C source equivalent. .SUFFIXES: .SUFFIXES: .o .S .c LIBCDIR = $(TOPSRC)/lib/libc .PATH: ${LIBCDIR}/${MACHINE_ARCH}/sys ${LIBCDIR}/${MACHINE_ARCH}/string \ ${LIBCDIR}/${MACHINE_ARCH}/gen ${LIBCDIR}/gen ${LIBCDIR}/stdio \ ${LIBCDIR}/stdlib ${LIBCDIR}/string ${LIBCDIR}/inet \ ${LIBCDIR}/compat ${LIBCDIR}/runtime VPATH= ${LIBCDIR}/${MACHINE_ARCH}/sys ${LIBCDIR}/${MACHINE_ARCH}/string \ ${LIBCDIR}/${MACHINE_ARCH}/gen ${LIBCDIR}/gen ${LIBCDIR}/stdio \ ${LIBCDIR}/stdlib ${LIBCDIR}/string ${LIBCDIR}/inet \ ${LIBCDIR}/compat ${LIBCDIR}/runtime COPTS!=if [ x"${MACHINE_ARCH}" = x"mips" ] ; then \ echo "-Wa,-x -B${TOOLBINDIR}/" ; \ else \ echo "" ; \ fi ASOPTS!=if [ x"${MACHINE_ARCH}" = x"mips" ] ; then \ echo "-Wa,-x -B${TOOLBINDIR}/ -DLWHI=lwr -DLWLO=lwl -DSWHI=swr -DSWLO=swl" ; \ else \ echo "" ; \ fi DEFS = -Wall -ffreestanding CFLAGS = ${DEFS} -Os -Wno-attributes -Wno-attribute-alias ${COPTS} ASFLAGS = ${DEFS} -I${LIBCDIR}/${MACHINE_ARCH}/sys ${ASOPTS} # modules which can not use SYSCALL and must be assembled from sources. The # rest of the system calls are generated with printf(1) and do not have # source files associated with them. # libc/$(MACHINE_ARCH)/sys SYSOBJS = __sysctl.o accept.o access.o adjtime.o bind.o chdir.o \ chflags.o chmod.o chown.o chroot.o close.o connect.o dup.o \ dup2.o execve.o fchdir.o fchflags.o fchmod.o fchown.o \ fcntl.o flock.o fork.o fstat.o fsync.o ftruncate.o \ getdtablesize.o getgroups.o getitimer.o getsockname.o \ getpeername.o getpriority.o getrlimit.o getrusage.o \ getsockopt.o gettimeofday.o ioctl.o kill.o killpg.o link.o \ listen.o lstat.o mkdir.o mknod.o mount.o open.o pselect.o \ quota.o read.o readlink.o readv.o reboot.o recv.o \ recvfrom.o recvmsg.o rename.o rmdir.o select.o send.o \ sendmsg.o sendto.o setgroups.o setitimer.o setpgrp.o \ setpriority.o setquota.o setuid.o seteuid.o setgid.o \ setegid.o setrlimit.o setsockopt.o settimeofday.o \ shutdown.o sigaltstack.o socket.o socketpair.o stat.o \ symlink.o sigprocmask.o sigstack.o sigwait.o statfs.o \ fstatfs.o getfsstat.o truncate.o umount.o unlink.o \ utimes.o wait4.o write.o writev.o lseek.o sigsuspend.o \ getgid.o getegid.o getpgrp.o getpid.o getppid.o getuid.o \ geteuid.o profil.o sigpending.o sync.o ufetch.o ustore.o \ ucall.o umask.o vfork.o vhangup.o rdglob.o wrglob.o OBJS = $(SYSOBJS) sbrk.o execl.o execle.o execv.o \ _exit.o _brk.o pipe.o ptrace.o sigaction.o # libc/$(MACHINE_ARCH)/string OBJS += bcopy.o bzero.o ffs.o memcpy.o memmove.o memset.o \ strlen.o bcmp.o index.o rindex.o strcmp.o # libc/$(MACHINE_ARCH)/gen OBJS += _setjmp.o htonl.o htons.o # libc/gen OBJS += abort.o alarm.o atof.o atoi.o atol.o basename.o \ calloc.o closedir.o crypt.o ctime.o ctype_.o \ daemon.o devname.o dirname.o ecvt.o err.o \ execvp.o fakcu.o frexp.o fstab.o gcvt.o getenv.o getgrent.o \ getgrgid.o getgrnam.o getlogin.o \ getgrouplist.o gethostname.o getpagesize.o \ getpass.o getpwent.o getloadavg.o getmntinfo.o \ getttyent.o getttynam.o getusershell.o getwd.o \ initgroups.o isatty.o isinff.o isnanf.o ldexp.o malloc.o mktemp.o \ modff.o ndbm.o nlist.o knlist.o opendir.o perror.o popen.o \ psignal.o qsort.o random.o readdir.o regex.o scandir.o \ seekdir.o setmode.o sethostname.o setenv.o siglist.o \ signal.o siginterrupt.o sigsetops.o \ sleep.o strcasecmp.o strftime.o swab.o sysctl.o syslog.o system.o \ strcat.o strncat.o strcpy.o strncpy.o strncmp.o \ telldir.o time.o timezone.o ttyname.o ttyslot.o ualarm.o usleep.o \ strdup.o uname.o wait.o wait3.o waitpid.o # libc/stdio OBJS += fgetc.o fgets.o fputc.o fputs.o gets.o puts.o \ clrerr.o doscan.o exit.o fdopen.o filbuf.o findiop.o \ flsbuf.o fopen.o fprintf.o fread.o freopen.o fseek.o \ ftell.o fwrite.o getchar.o getw.o printf.o putchar.o putw.o \ rew.o scanf.o setbuf.o setbuffer.o setvbuf.o snprintf.o sprintf.o \ strout.o ungetc.o vfprintf.o vprintf.o vsprintf.o doprnt.o \ remove.o feof.o ferror.o fileno.o # libc/stdlib OBJS += getopt.o getsubopt.o strtol.o strtoul.o strtod.o # libc/string OBJS += strcspn.o strerror.o strlcat.o strlcpy.o strpbrk.o \ strsep.o strspn.o strstr.o strtok.o strtok_r.o # libc/inet OBJS += inet_addr.o inet_network.o inet_netof.o \ inet_ntoa.o inet_lnaof.o inet_maddr.o # libc/compat OBJS += creat.o ftime.o gethostid.o memccpy.o memchr.o \ memcmp.o memcpy.o memset.o nice.o pause.o rand.o \ sethostid.o setregid.o setreuid.o setrgid.o setruid.o \ sigcompat.o strchr.o strrchr.o times.o tmpnam.o \ utime.o # libc/runtime OBJS+= addsf3.o comparesf2.o divsf3.o fixsfsi.o fixunssfsi.o \ floatsisf.o floatunsisf.o mulsf3.o negsf2.o subsf3.o \ adddf3.o comparedf2.o divdf3.o fixdfsi.o fixunsdfsi.o \ floatsidf.o floatunsidf.o muldf3.o negdf2.o subdf3.o \ ashldi3.o lshrdi3.o \ sc_case.o all: ../libc.a ../libc.a: ${OBJS} rm -f $@ ${AOUT_AR} rc $@ ${OBJS} ${AOUT_RANLIB} $@ ${OBJS}: FRC FRC: $(SYSOBJS): $(LIBCDIR)/$(MACHINE_ARCH)/sys/SYS.h # @echo creating $*.o @printf '#include "SYS.h"\nSYS($*)\n' | $(AS) $(ASFLAGS) - -c -o $*.o # Build objects here instead of ${LIBCDIR} with BSD make. .OBJDIR: ${.CURDIR} install: ../libc.a ${INSTALL} -d ${DESTDIR}/usr/lib ${INSTALL} ../libc.a ${DESTDIR}/usr/lib/libc.a ${AOUT_RANLIB} -t ${DESTDIR}/usr/lib/libc.a clean: rm -f *~ *.o a.out *.a ../libc.a ================================================ FILE: lib/libc_aout/libcurses/Makefile ================================================ TOPSRC!=cd ../../..; pwd include ${TOPSRC}/share/mk/sys.mk LIBDIR= ${TOPSRC}/lib/libcurses COPTS!=if [ x"${MACHINE_ARCH}" = x"mips" ] ; then \ echo "-Wa,-x -B${TOOLBINDIR}/" ; \ else \ echo "" ; \ fi CFLAGS = -Os ${DEFS} -Wall ${COPTS} OBJS = addch.o addstr.o box.o clear.o clrtobot.o clrtoeol.o cr_put.o \ cr_tty.o curses.o delch.o deleteln.o delwin.o endwin.o erase.o \ fullname.o getch.o getstr.o idlok.o id_subwins.o initscr.o insch.o \ insertln.o longname.o move.o mvprintw.o mvscanw.o mvwin.o newwin.o \ overlay.o overwrite.o printw.o putchar.o refresh.o scanw.o scroll.o \ toucholap.o standout.o touchwin.o tstp.o unctrl.o all: ../libcurses.a %.o: ${LIBDIR}/%.c ${CC} ${DEFS} ${CFLAGS} -c $< -o $@ ../libcurses.a: ${OBJS} rm -f $@ ${AOUT_AR} rc $@ ${OBJS} ${AOUT_RANLIB} $@ install: ../libcurses.a ${INSTALL} -d ${DESTDIR}/usr/lib ${INSTALL} ../libcurses.a ${DESTDIR}/usr/lib/libcurses.a ${AOUT_RANLIB} -t ${DESTDIR}/usr/lib/libcurses.a clean: rm -f *~ *.o a.out *.a ../libcurses.a addch.o: ${LIBDIR}/addch.c addstr.o: ${LIBDIR}/addstr.c box.o: ${LIBDIR}/box.c clear.o: ${LIBDIR}/clear.c clrtobot.o: ${LIBDIR}/clrtobot.c clrtoeol.o: ${LIBDIR}/clrtoeol.c cr_put.o: ${LIBDIR}/cr_put.c cr_tty.o: ${LIBDIR}/cr_tty.c curses.o: ${LIBDIR}/curses.c delch.o: ${LIBDIR}/delch.c deleteln.o: ${LIBDIR}/deleteln.c delwin.o: ${LIBDIR}/delwin.c endwin.o: ${LIBDIR}/endwin.c erase.o: ${LIBDIR}/erase.c fullname.o: ${LIBDIR}/fullname.c getch.o: ${LIBDIR}/getch.c getstr.o: ${LIBDIR}/getstr.c idlok.o: ${LIBDIR}/idlok.c id_subwins.o: ${LIBDIR}/id_subwins.c initscr.o: ${LIBDIR}/initscr.c insch.o: ${LIBDIR}/insch.c insertln.o: ${LIBDIR}/insertln.c longname.o: ${LIBDIR}/longname.c move.o: ${LIBDIR}/move.c mvprintw.o: ${LIBDIR}/mvprintw.c mvscanw.o: ${LIBDIR}/mvscanw.c mvwin.o: ${LIBDIR}/mvwin.c newwin.o: ${LIBDIR}/newwin.c overlay.o: ${LIBDIR}/overlay.c overwrite.o: ${LIBDIR}/overwrite.c printw.o: ${LIBDIR}/printw.c putchar.o: ${LIBDIR}/putchar.c refresh.o: ${LIBDIR}/refresh.c scanw.o: ${LIBDIR}/scanw.c scroll.o: ${LIBDIR}/scroll.c toucholap.o: ${LIBDIR}/toucholap.c standout.o: ${LIBDIR}/standout.c touchwin.o: ${LIBDIR}/touchwin.c tstp.o: ${LIBDIR}/tstp.c unctrl.o: ${LIBDIR}/unctrl.c ================================================ FILE: lib/libc_aout/libgpanel/Makefile ================================================ TOPSRC!=cd ../../..; pwd include ${TOPSRC}/share/mk/sys.mk LIBDIR= ${TOPSRC}/lib/libgpanel COPTS!=if [ x"${MACHINE_ARCH}" = x"mips" ] ; then \ echo "-Wa,-x -B${TOOLBINDIR}/" ; \ else \ echo "" ; \ fi CFLAGS = -Os ${DEFS} -Wall ${COPTS} OBJS = open.o clear.o pixel.o line.o rect.o fill.o fill_triangle.o \ circle.o image.o char.o text.o text_width.o all: ../libgpanel.a %.o: ${LIBDIR}/%.c ${CC} ${DEFS} ${CFLAGS} -c $< -o $@ ../libgpanel.a: ${OBJS} rm -f $@ ${AOUT_AR} rc $@ ${OBJS} ${AOUT_RANLIB} $@ install: ../libgpanel.a ${INSTALL} -d ${DESTDIR}/usr/lib ${INSTALL} ../libgpanel.a ${DESTDIR}/usr/lib/libgpanel.a ${AOUT_RANLIB} -t ${DESTDIR}/usr/lib/libgpanel.a clean: rm -f *~ *.o a.out *.a ../libgpanel.a open.o: ${LIBDIR}/open.c clear.o: ${LIBDIR}/clear.c pixel.o: ${LIBDIR}/pixel.c line.o: ${LIBDIR}/line.c rect.o: ${LIBDIR}/rect.c fill.o: ${LIBDIR}/fill.c fill_triangle.o:${LIBDIR}/fill_triangle.c circle.o: ${LIBDIR}/circle.c image.o: ${LIBDIR}/image.c char.o: ${LIBDIR}/char.c text.o: ${LIBDIR}/text.c text_width.o: ${LIBDIR}/text_width.c ================================================ FILE: lib/libc_aout/libm/Makefile ================================================ TOPSRC!=cd ../../..; pwd include ${TOPSRC}/share/mk/sys.mk LIBDIR= ${TOPSRC}/lib/libm COPTS!=if [ x"${MACHINE_ARCH}" = x"mips" ] ; then \ echo "-Wa,-x -B${TOOLBINDIR}/" ; \ else \ echo "" ; \ fi CFLAGS = -Os ${DEFS} -Wall ${COPTS} OBJS = asin.o atan.o exp.o erf.o floor.o fmod.o hypot.o j0.o j1.o \ jn.o log.o pow.o sin.o sinh.o sqrt.o tan.o tanh.o all: ../libm.a %.o: ${LIBDIR}/%.c ${CC} ${DEFS} ${CFLAGS} -c $< -o $@ ../libm.a: ${OBJS} rm -f $@ ${AOUT_AR} rc $@ ${OBJS} ${AOUT_RANLIB} $@ install: ../libm.a ${INSTALL} -d ${DESTDIR}/usr/lib ${INSTALL} ../libm.a ${DESTDIR}/usr/lib/libm.a ${AOUT_RANLIB} -t ${DESTDIR}/usr/lib/libm.a clean: rm -f *~ *.o a.out *.a ../libm.a asin.o: ${LIBDIR}/asin.c atan.o: ${LIBDIR}/atan.c exp.o: ${LIBDIR}/exp.c erf.o: ${LIBDIR}/erf.c floor.o: ${LIBDIR}/floor.c fmod.o: ${LIBDIR}/fmod.c hypot.o: ${LIBDIR}/hypot.c j0.o: ${LIBDIR}/j0.c j1.o: ${LIBDIR}/j1.c jn.o: ${LIBDIR}/jn.c log.o: ${LIBDIR}/log.c pow.o: ${LIBDIR}/pow.c sin.o: ${LIBDIR}/sin.c sinh.o: ${LIBDIR}/sinh.c sqrt.o: ${LIBDIR}/sqrt.c tan.o: ${LIBDIR}/tan.c tanh.o: ${LIBDIR}/tanh.c ================================================ FILE: lib/libc_aout/libreadline/Makefile ================================================ TOPSRC!=cd ../../..; pwd include ${TOPSRC}/share/mk/sys.mk LIBDIR= ${TOPSRC}/lib/libreadline COPTS!=if [ x"${MACHINE_ARCH}" = x"mips" ] ; then \ echo "-Wa,-x -B${TOOLBINDIR}/" ; \ else \ echo "" ; \ fi CFLAGS = -Os ${DEFS} -Wall ${COPTS} OBJS = readline.o all: ../libreadline.a %.o: ${LIBDIR}/%.c ${CC} ${DEFS} ${CFLAGS} -c $< -o $@ ../libreadline.a: ${OBJS} rm -f $@ ${AOUT_AR} rc $@ ${OBJS} ${AOUT_RANLIB} $@ install: ../libreadline.a ${INSTALL} -d ${DESTDIR}/usr/lib ${INSTALL} ../libreadline.a ${DESTDIR}/usr/lib/libreadline.a ${AOUT_RANLIB} -t ${DESTDIR}/usr/lib/libreadline.a clean: rm -f *~ *.o a.out *.a ../libreadline.a readline.o: ${LIBDIR}/readline.c ================================================ FILE: lib/libc_aout/libtermlib/Makefile ================================================ TOPSRC!=cd ../../..; pwd include ${TOPSRC}/share/mk/sys.mk LIBDIR= ${TOPSRC}/lib/libtermlib COPTS!=if [ x"${MACHINE_ARCH}" = x"mips" ] ; then \ echo "-Wa,-x -B${TOOLBINDIR}/" ; \ else \ echo "" ; \ fi CFLAGS = -Os ${DEFS} -Wall ${COPTS} OBJS = termcap.o tgoto.o tputs.o tcattr.o all: ../libtermlib.a %.o: ${LIBDIR}/%.c ${CC} ${DEFS} ${CFLAGS} -c $< -o $@ ../libtermlib.a: ${OBJS} rm -f $@ ${AOUT_AR} rc $@ ${OBJS} ${AOUT_RANLIB} $@ install: ../libtermlib.a ${INSTALL} -d ${DESTDIR}/usr/lib ${INSTALL} ../libtermlib.a ${DESTDIR}/usr/lib/libtermlib.a ${AOUT_RANLIB} -t ${DESTDIR}/usr/lib/libtermlib.a clean: rm -f *~ *.o a.out *.a ../libtermlib.a termcap.o: ${LIBDIR}/termcap.c tgoto.o: ${LIBDIR}/tgoto.c tputs.o: ${LIBDIR}/tputs.c tcattr.o: ${LIBDIR}/tcattr.c ================================================ FILE: lib/libc_aout/libwiznet/Makefile ================================================ TOPSRC!=cd ../../..; pwd include ${TOPSRC}/share/mk/sys.mk LIBDIR= ${TOPSRC}/lib/libwiznet COPTS!=if [ x"${MACHINE_ARCH}" = x"mips" ] ; then \ echo "-Wa,-x -B${TOOLBINDIR}/" ; \ else \ echo "" ; \ fi CFLAGS = -Os ${DEFS} -Wall ${COPTS} OBJS = w5100.o socket.o ethernet.o client.o server.o udp.o all: ../libwiznet.a %.o: ${LIBDIR}/%.c ${CC} ${DEFS} ${CFLAGS} -c $< -o $@ ../libwiznet.a: ${OBJS} rm -f $@ ${AOUT_AR} rc $@ ${OBJS} ${AOUT_RANLIB} $@ install: ../libwiznet.a ${INSTALL} -d ${DESTDIR}/usr/lib ${INSTALL} ../libwiznet.a ${DESTDIR}/usr/lib/libwiznet.a ${AOUT_RANLIB} -t ${DESTDIR}/usr/lib/libwiznet.a clean: rm -f *~ *.o a.out *.a ../libwiznet.a w5100.o: ${LIBDIR}/w5100.c socket.o: ${LIBDIR}/socket.c ethernet.o: ${LIBDIR}/ethernet.c client.o: ${LIBDIR}/client.c server.o: ${LIBDIR}/server.c udp.o: ${LIBDIR}/udp.c ================================================ FILE: lib/libc_aout/startup/Makefile ================================================ # # Copyright (c) 1987 Regents of the University of California. # All rights reserved. The Berkeley software License Agreement # specifies the terms and conditions for redistribution. # # crt0 Normal C run time startoff # TOPSRC!=cd ../../..; pwd include ${TOPSRC}/share/mk/sys.mk COPTS!=if [ x"${MACHINE_ARCH}" = x"mips" ] ; then \ echo "-Wa,-x -B${TOOLBINDIR}/" ; \ else \ echo "" ; \ fi CFLAGS= -Os ${DEFS} -Wall ${COPTS} SRCS= ${TOPSRC}/lib/startup-${MACHINE_ARCH}/crt0.c OBJS= ../crt0.o all: ${OBJS} ${OBJS}: ${SRCS} ${CC} ${DEFS} ${CFLAGS} -c ${SRCS} -o $@ install: ${OBJS} ${INSTALL} -d ${DESTDIR}/usr/lib ${INSTALL} ${OBJS} ${DESTDIR}/usr/lib/crt0.o clean: rm -f ${OBJS} *~ ================================================ FILE: lib/libcurses/Makefile ================================================ # Copyright (c) 1980 Regents of the University of California. # All rights reserved. The Berkeley software License Agreement # specifies the terms and conditions for redistribution. # # curses package # TOPSRC!=cd ../..; pwd include ${TOPSRC}/share/mk/sys.mk CFILES= addch.c addstr.c box.c clear.c clrtobot.c clrtoeol.c cr_put.c \ cr_tty.c curses.c delch.c deleteln.c delwin.c endwin.c erase.c \ fullname.c getch.c getstr.c idlok.c id_subwins.c initscr.c insch.c \ insertln.c longname.c move.c mvprintw.c mvscanw.c mvwin.c newwin.c \ overlay.c overwrite.c printw.c putchar.c refresh.c scanw.c scroll.c \ toucholap.c standout.c touchwin.c tstp.c unctrl.c OBJS= addch.o addstr.o box.o clear.o clrtobot.o clrtoeol.o cr_put.o \ cr_tty.o curses.o delch.o deleteln.o delwin.o endwin.o erase.o \ fullname.o getch.o getstr.o idlok.o id_subwins.o initscr.o insch.o \ insertln.o longname.o move.o mvprintw.o mvscanw.o mvwin.o newwin.o \ overlay.o overwrite.o printw.o putchar.o refresh.o scanw.o scroll.o \ toucholap.o standout.o touchwin.o tstp.o unctrl.o POBJS= ../addch.o ../addstr.o ../box.o ../clear.o ../clrtobot.o ../clrtoeol.o ../cr_put.o \ ../cr_tty.o ../curses.o ../delch.o ../deleteln.o ../delwin.o ../endwin.o ../erase.o \ ../fullname.o ../getch.o ../getstr.o ../idlok.o ../id_subwins.o ../initscr.o ../insch.o \ ../insertln.o ../longname.o ../move.o ../mvprintw.o ../mvscanw.o ../mvwin.o ../newwin.o \ ../overlay.o ../overwrite.o ../printw.o ../putchar.o ../refresh.o ../scanw.o ../scroll.o \ ../toucholap.o ../standout.o ../touchwin.o ../tstp.o ../unctrl.o CTAGS= ctags DEFS= -DNOSCCS CFLAGS+=-O -Wall ${DEFS} TAGSFILE=tags all: ../libcurses.a ../libcurses.a: ${OBJS} @echo building normal ../libcurses.a @${AR} cr ../libcurses.a ${OBJS} $(RANLIB) ../libcurses.a ../libcurses_p.a: ${OBJS} @echo building profiled ../libcurses.a @cd profiled; ${AR} cr ../../libcurses_p.a ${POBJS} $(RANLIB) ../libcurses_p.a install: all # cp ../libcurses.a ${DESTDIR}/usr/lib/libcurses.a # $(RANLIB) ${DESTDIR}/usr/lib/libcurses.a # cp ../libcurses_p.a ${DESTDIR}/usr/lib/libcurses_p.a # $(RANLIB) ${DESTDIR}/usr/lib/libcurses_p.a tags: cwd=`pwd`; \ for i in ${CFILES}; do \ ctags -a -f ${TAGSFILE} $$cwd/$$i; \ done clean: rm -f ${OBJS} profiled/*.o a.out core test errs \ ../libcurses.a ../libcurses_p.a tags ctags: ${CTAGS} ${CFILES} curses.h lint: lint -hxb ${CFILES} -lcurses > lint.out test: libcurses test.o ${CC} ${LDFLAGS} ${CFLAGS} -o test test.o libcurses -ltermlib test.o: test.c ${CC} ${CFLAGS} -c test.c ar: ar crv curses.ar ${CFILES} curses.h curses.ext Makefile ================================================ FILE: lib/libcurses/addch.c ================================================ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include "curses.ext" /* * set_ch: * Set the first and last change flags for this window. */ static void set_ch(win, y, x, ch) WINDOW *win; int y, x, ch; { # ifdef FULLDEBUG fprintf(outf, "SET_CH(%0.2o, %d, %d)\n", win, y, x); # endif if (win->_y[y][x] != ch) { x += win->_ch_off; if (win->_firstch[y] == _NOCHANGE) win->_firstch[y] = win->_lastch[y] = x; else if (x < win->_firstch[y]) win->_firstch[y] = x; else if (x > win->_lastch[y]) win->_lastch[y] = x; # ifdef FULLDEBUG fprintf(outf, "SET_CH: change gives f/l: %d/%d [%d/%d]\n", win->_firstch[y], win->_lastch[y], win->_firstch[y] - win->_ch_off, win->_lastch[y] - win->_ch_off); # endif } } /* * This routine adds the character to the current position */ int waddch(win, c) WINDOW *win; char c; { int x, y; int newx; x = win->_curx; y = win->_cury; # ifdef FULLDEBUG fprintf(outf, "ADDCH('%c') at (%d, %d)\n", c, y, x); # endif switch (c) { case '\t': for (newx = x + (8 - (x & 07)); x < newx; x++) if (waddch(win, ' ') == ERR) return ERR; return OK; default: # ifdef FULLDEBUG fprintf(outf, "ADDCH: 1: y = %d, x = %d, firstch = %d, lastch = %d\n", y, x, win->_firstch[y], win->_lastch[y]); # endif if (win->_flags & _STANDOUT) c |= _STANDOUT; set_ch(win, y, x, c); win->_y[y][x++] = c; if (x >= win->_maxx) { x = 0; newline: if (++y >= win->_maxy) { if (! win->_scroll) return ERR; scroll(win); --y; } } # ifdef FULLDEBUG fprintf(outf, "ADDCH: 2: y = %d, x = %d, firstch = %d, lastch = %d\n", y, x, win->_firstch[y], win->_lastch[y]); # endif break; case '\n': wclrtoeol(win); if (!NONL) x = 0; goto newline; case '\r': x = 0; break; case '\b': if (--x < 0) x = 0; break; } win->_curx = x; win->_cury = y; return OK; } ================================================ FILE: lib/libcurses/addstr.c ================================================ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include "curses.ext" /* * This routine adds a string starting at (_cury,_curx) */ int waddstr(win, str) WINDOW *win; char *str; { # ifdef DEBUG fprintf(outf, "WADDSTR(\"%s\")\n", str); # endif while (*str) if (waddch(win, *str++) == ERR) return ERR; return OK; } ================================================ FILE: lib/libcurses/box.c ================================================ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include "curses.ext" /* * This routine draws a box around the given window with "vert" * as the vertical delimiting char, and "hor", as the horizontal one. * */ void box(win, vert, hor) WINDOW *win; char vert, hor; { int i; int endy, endx; char *fp, *lp; endx = win->_maxx; endy = win->_maxy - 1; fp = win->_y[0]; lp = win->_y[endy]; for (i = 0; i < endx; i++) fp[i] = lp[i] = hor; endx--; for (i = 0; i <= endy; i++) win->_y[i][0] = (win->_y[i][endx] = vert); if (!win->_scroll && (win->_flags&_SCROLLWIN)) fp[0] = fp[endx] = lp[0] = lp[endx] = ' '; touchwin(win); } ================================================ FILE: lib/libcurses/clear.c ================================================ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include "curses.ext" /* * This routine clears the window. */ int wclear(win) WINDOW *win; { werase(win); win->_clear = TRUE; return OK; } ================================================ FILE: lib/libcurses/clrtobot.c ================================================ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include "curses.ext" /* * This routine erases everything on the window. */ void wclrtobot(win) WINDOW *win; { int y; char *sp, *end, *maxx; int startx, minx; startx = win->_curx; for (y = win->_cury; y < win->_maxy; y++) { minx = _NOCHANGE; maxx = 0; end = &win->_y[y][win->_maxx]; for (sp = &win->_y[y][startx]; sp < end; sp++) if (*sp != ' ') { maxx = sp; if (minx == _NOCHANGE) minx = sp - win->_y[y]; *sp = ' '; } if (minx != _NOCHANGE) touchline(win, y, minx, maxx - &win->_y[y][0]); startx = 0; } } ================================================ FILE: lib/libcurses/clrtoeol.c ================================================ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include "curses.ext" /* * This routine clears up to the end of line */ void wclrtoeol(win) WINDOW *win; { char *sp, *end; int y, x; char *maxx; int minx; y = win->_cury; x = win->_curx; end = &win->_y[y][win->_maxx]; minx = _NOCHANGE; maxx = &win->_y[y][x]; for (sp = maxx; sp < end; sp++) if (*sp != ' ') { maxx = sp; if (minx == _NOCHANGE) minx = sp - win->_y[y]; *sp = ' '; } /* * update firstch and lastch for the line */ touchline(win, y, win->_curx, win->_maxx - 1); # ifdef DEBUG fprintf(outf, "CLRTOEOL: minx = %d, maxx = %d, firstch = %d, lastch = %d\n", minx, maxx - win->_y[y], win->_firstch[y], win->_lastch[y]); # endif } ================================================ FILE: lib/libcurses/cr_put.c ================================================ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include "curses.ext" #include #define HARDTABS 8 /* * Terminal driving and line formatting routines. * Basic motion optimizations are done here as well * as formatting of lines (printing of control characters, * line numbering and the like). */ /* * Sync the position of the output cursor. * Most work here is rounding for terminal boundaries getting the * column position implied by wraparound or the lack thereof and * rolling up the screen to get destline on the screen. */ static int outcol, outline, destcol, destline; WINDOW *_win; /* * Move (slowly) to destination. * Hard thing here is using home cursor on really deficient terminals. * Otherwise just use cursor motions, hacking use of tabs and overtabbing * and backspace. */ static int plodcnt, plodflg; static int plodput(c) int c; { if (plodflg) { plodcnt--; return 0; } return _putchar(c); } /* * Return the column number that results from being in column col and * hitting a tab, where tabs are set every ts columns. Work right for * the case where col > COLS, even if ts does not divide COLS. */ static int tabcol(col, ts) int col, ts; { int offset; if (col >= COLS) { offset = COLS * (col / COLS); col -= offset; } else offset = 0; return col + ts - (col % ts) + offset; } static int plod(cnt) int cnt; { register int i, j, k; register int soutcol, soutline; plodcnt = plodflg = cnt; soutcol = outcol; soutline = outline; /* * Consider homing and moving down/right from there, vs moving * directly with local motions to the right spot. */ if (HO) { /* * i is the cost to home and tab/space to the right to * get to the proper column. This assumes ND space costs * 1 char. So i+destcol is cost of motion with home. */ if (GT) i = (destcol / HARDTABS) + (destcol % HARDTABS); else i = destcol; /* * j is cost to move locally without homing */ if (destcol >= outcol) { /* if motion is to the right */ j = destcol / HARDTABS - outcol / HARDTABS; if (GT && j) j += destcol % HARDTABS; else j = destcol - outcol; } else /* leftward motion only works if we can backspace. */ if (outcol - destcol <= i && (BS || BC)) i = j = outcol - destcol; /* cheaper to backspace */ else j = i + 1; /* impossibly expensive */ /* k is the absolute value of vertical distance */ k = outline - destline; if (k < 0) k = -k; j += k; /* * Decision. We may not have a choice if no UP. */ if (i + destline < j || (!UP && destline < outline)) { /* * Cheaper to home. Do it now and pretend it's a * regular local motion. */ tputs(HO, 0, plodput); outcol = outline = 0; } else if (LL) { /* * Quickly consider homing down and moving from there. * Assume cost of LL is 2. */ k = (LINES - 1) - destline; if (i + k + 2 < j && (k<=0 || UP)) { tputs(LL, 0, plodput); outcol = 0; outline = LINES - 1; } } } else /* * No home and no up means it's impossible. */ if (!UP && destline < outline) return -1; if (GT) i = destcol % HARDTABS + destcol / HARDTABS; else i = destcol; /* if (BT && outcol > destcol && (j = (((outcol+7) & ~7) - destcol - 1) >> 3)) { j *= (k = strlen(BT)); if ((k += (destcol&7)) > 4) j += 8 - (destcol&7); else j += k; } else */ j = outcol - destcol; /* * If we will later need a \n which will turn into a \r\n by * the system or the terminal, then don't bother to try to \r. */ if (!_pfast && outline < destline) goto dontcr; /* * If the terminal will do a \r\n and there isn't room for it, * then we can't afford a \r. */ if (NC && outline >= destline) goto dontcr; /* * If it will be cheaper, or if we can't back up, then send * a return preliminarily. */ if (j > i + 1 || (outcol > destcol && !BS && !BC)) { /* * BUG: this doesn't take the (possibly long) length * of CR into account. */ if (CR) tputs(CR, 0, plodput); else plodput('\r'); if (NC) { if (NL) tputs(NL, 0, plodput); else plodput('\n'); outline++; } outcol = 0; } dontcr: while (outline < destline) { outline++; if (NL) tputs(NL, 0, plodput); else { plodput('\n'); if (!_pfast) outcol = 0; } if (plodcnt < 0) goto out; } if (BT) k = strlen(BT); while (outcol > destcol) { if (plodcnt < 0) goto out; /* if (BT && outcol - destcol > k + 4) { tputs(BT, 0, plodput); outcol--; outcol &= ~7; continue; } */ outcol--; if (BC) tputs(BC, 0, plodput); else plodput('\b'); } while (outline > destline) { outline--; tputs(UP, 0, plodput); if (plodcnt < 0) goto out; } if (GT && destcol - outcol > 1) { for (;;) { i = tabcol(outcol, HARDTABS); if (i > destcol) break; if (TA) tputs(TA, 0, plodput); else plodput('\t'); outcol = i; } if (destcol - outcol > 4 && i < COLS && (BC || BS)) { if (TA) tputs(TA, 0, plodput); else plodput('\t'); outcol = i; while (outcol > destcol) { outcol--; if (BC) tputs(BC, 0, plodput); else plodput('\b'); } } } while (outcol < destcol) { /* * move one char to the right. We don't use ND space * because it's better to just print the char we are * moving over. */ if (_win != NULL) if (plodflg) /* avoid a complex calculation */ plodcnt--; else { i = curscr->_y[outline][outcol]; if ((i&_STANDOUT) == (curscr->_flags&_STANDOUT)) _putchar(i); else goto nondes; } else nondes: if (ND) tputs(ND, 0, plodput); else plodput(' '); outcol++; if (plodcnt < 0) goto out; } out: if (plodflg) { outcol = soutcol; outline = soutline; } return(plodcnt); } void fgoto() { char *cgp; int l, c; if (destcol >= COLS) { destline += destcol / COLS; destcol %= COLS; } if (outcol >= COLS) { l = (outcol + 1) / COLS; outline += l; outcol %= COLS; if (AM == 0) { while (l > 0) { if (_pfast) { if (CR) _puts(CR); else _putchar('\r'); } if (NL) _puts(NL); else _putchar('\n'); l--; } outcol = 0; } if (outline > LINES - 1) { destline -= outline - (LINES - 1); outline = LINES - 1; } } if (destline >= LINES) { l = destline; destline = LINES - 1; if (outline < LINES - 1) { c = destcol; if (_pfast == 0 && !CA) destcol = 0; fgoto(); destcol = c; } while (l >= LINES) { /* * The following linefeed (or simulation thereof) * is supposed to scroll up the screen, since we * are on the bottom line. We make the assumption * that linefeed will scroll. If ns is in the * capability list this won't work. We should * probably have an sc capability but sf will * generally take the place if it works. * * Superbee glitch: in the middle of the screen we * have to use esc B (down) because linefeed screws up * in "Efficient Paging" (what a joke) mode (which is * essential in some SB's because CRLF mode puts garbage * in at end of memory), but you must use linefeed to * scroll since down arrow won't go past memory end. * I turned this off after recieving Paul Eggert's * Superbee description which wins better. */ if (NL /* && !XB */ && _pfast) _puts(NL); else _putchar('\n'); l--; if (_pfast == 0) outcol = 0; } } if (destline < outline && !(CA || UP)) destline = outline; if (CA) { cgp = tgoto(CM, destcol, destline); if (plod(strlen(cgp)) > 0) plod(0); else tputs(cgp, 0, _putchar); } else plod(0); outline = destline; outcol = destcol; } void mvcur(ly, lx, y, x) int ly, lx, y, x; { #ifdef DEBUG fprintf(outf, "MVCUR: moving cursor from (%d,%d) to (%d,%d)\n", ly, lx, y, x); #endif destcol = x; destline = y; outcol = lx; outline = ly; fgoto(); } ================================================ FILE: lib/libcurses/cr_tty.c ================================================ /* * Terminal initialization routines. * * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include "curses.ext" #include #include static bool *sflags[] = { &AM, &BS, &DA, &DB, &EO, &HC, &HZ, &IN, &MI, &MS, &NC, &NS, &OS, &UL, &XB, &XN, &XT, &XS, &XX }; static char *_PC, **sstrs[] = { &AL, &BC, &BT, &CD, &CE, &CL, &CM, &CR, &CS, &DC, &DL, &DM, &DO, &ED, &EI, &K0, &K1, &K2, &K3, &K4, &K5, &K6, &K7, &K8, &K9, &HO, &IC, &IM, &IP, &KD, &KE, &KH, &KL, &KR, &KS, &KU, &LL, &MA, &ND, &NL, &_PC, &RC, &SC, &SE, &SF, &SO, &SR, &TA, &TE, &TI, &UC, &UE, &UP, &US, &VB, &VS, &VE, &AL_PARM, &DL_PARM, &UP_PARM, &DOWN_PARM, &LEFT_PARM, &RIGHT_PARM, }; char _tspace[2048]; /* Space for capability strings */ static char *aoftspace; /* Address of _tspace for relocation */ static int destcol, destline; /* * This routine does terminal type initialization routines, and * calculation of flags at entry. It is almost entirely stolen from * Bill Joy's ex version 2.6. */ short ospeed = -1; void gettmode() { if (ioctl(_tty_ch, TIOCGETP, &_tty) < 0) return; savetty(); if (ioctl(_tty_ch, TIOCSETP, &_tty) < 0) _tty.sg_flags = _res_flg; ospeed = _tty.sg_ospeed; _res_flg = _tty.sg_flags; GT = ((_tty.sg_flags & XTABS) == 0); NONL = ((_tty.sg_flags & CRMOD) == 0); _pfast = NONL; _tty.sg_flags &= ~XTABS; ioctl(_tty_ch, TIOCSETP, &_tty); # ifdef DEBUG fprintf(outf, "GETTMODE: GT = %s\n", GT ? "TRUE" : "FALSE"); fprintf(outf, "GETTMODE: NONL = %s\n", NONL ? "TRUE" : "FALSE"); fprintf(outf, "GETTMODE: ospeed = %d\n", ospeed); # endif } /* * This routine gets all the terminal flags from the termcap database */ static void zap() { register char *namp; register bool **fp; register char ***sp; #ifdef DEBUG register char *cp; #endif namp = "ambsdadbeohchzinmimsncnsosulxbxnxtxsxx"; fp = sflags; do { *(*fp++) = tgetflag(namp); #ifdef DEBUG fprintf(outf, "%2.2s = %s\n", namp, *fp[-1] ? "TRUE" : "FALSE"); #endif namp += 2; } while (*namp); namp = "albcbtcdceclcmcrcsdcdldmdoedeik0k1k2k3k4k5k6k7k8k9hoicimipkdkekhklkrkskullmandnlpcrcscsesfsosrtatetiucueupusvbvsveALDLUPDOLERI"; sp = sstrs; do { *(*sp++) = tgetstr(namp, &aoftspace); #ifdef DEBUG fprintf(outf, "%2.2s = %s", namp, *sp[-1] == NULL ? "NULL\n" : "\""); if (*sp[-1] != NULL) { for (cp = *sp[-1]; *cp; cp++) fprintf(outf, "%s", unctrl(*cp)); fprintf(outf, "\"\n"); } #endif namp += 2; } while (*namp); if (XS) SO = SE = NULL; else { if (tgetnum("sg") > 0) SO = NULL; if (tgetnum("ug") > 0) US = NULL; if (!SO && US) { SO = US; SE = UE; } } if (DO && !NL) NL = DO; } int setterm(type) char *type; { int unknown; static char genbuf[1024]; # ifdef TIOCGWINSZ struct winsize win; # endif # ifdef DEBUG fprintf(outf, "SETTERM(\"%s\")\n", type); fprintf(outf, "SETTERM: LINES = %d, COLS = %d\n", LINES, COLS); # endif if (type[0] == '\0') type = "xx"; unknown = FALSE; if (tgetent(genbuf, type) != 1) { unknown++; strcpy(genbuf, "xx|dumb:"); } # ifdef DEBUG fprintf(outf, "SETTERM: tty = %s\n", type); # endif # ifdef TIOCGWINSZ if (ioctl(_tty_ch, TIOCGWINSZ, &win) >= 0) { if (LINES == 0) LINES = win.ws_row; if (COLS == 0) COLS = win.ws_col; } # endif if (LINES == 0) LINES = tgetnum("li"); if (LINES <= 5) LINES = 24; if (COLS == 0) COLS = tgetnum("co"); if (COLS <= 4) COLS = 80; # ifdef DEBUG fprintf(outf, "SETTERM: LINES = %d, COLS = %d\n", LINES, COLS); # endif aoftspace = _tspace; zap(); /* get terminal description */ /* * Handle funny termcap capabilities */ if (CS && SC && RC) AL=DL=""; if (AL_PARM && AL==NULL) AL=""; if (DL_PARM && DL==NULL) DL=""; if (IC && IM==NULL) IM=""; if (IC && EI==NULL) EI=""; if (!GT) BT=NULL; /* If we can't tab, we can't backtab either */ if (tgoto(CM, destcol, destline)[0] == 'O') CA = FALSE, CM = 0; else CA = TRUE; PC = _PC ? _PC[0] : FALSE; aoftspace = _tspace; strncpy(ttytype, longname(genbuf, type), sizeof(ttytype) - 1); ttytype[sizeof(ttytype) - 1] = '\0'; if (unknown) return ERR; return OK; } /* * return a capability from termcap */ char * getcap(name) char *name; { char *tgetstr(); return tgetstr(name, &aoftspace); } ================================================ FILE: lib/libcurses/curses.c ================================================ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ /* * Define global variables * */ #include "curses.h" bool _echoit = TRUE, /* set if stty indicates ECHO */ _rawmode = FALSE,/* set if stty indicates RAW mode */ My_term = FALSE,/* set if user specifies terminal type */ _endwin = FALSE;/* set if endwin has been called */ char ttytype[50], /* long name of tty */ *Def_term = "unknown"; /* default terminal type */ int _tty_ch = 1, /* file channel which is a tty */ LINES, /* number of lines allowed on screen */ COLS, /* number of columns allowed on screen */ _res_flg; /* sgtty flags for reseting later */ WINDOW *stdscr = NULL, *curscr = NULL; # ifdef DEBUG FILE *outf; /* debug output file */ # endif SGTTY _tty; /* tty modes */ bool AM, BS, CA, DA, DB, EO, HC, HZ, IN, MI, MS, NC, NS, OS, UL, XB, XN, XT, XS, XX; char *AL, *BC, *BT, *CD, *CE, *CL, *CM, *CR, *CS, *DC, *DL, *DM, *DO, *ED, *EI, *K0, *K1, *K2, *K3, *K4, *K5, *K6, *K7, *K8, *K9, *HO, *IC, *IM, *IP, *KD, *KE, *KH, *KL, *KR, *KS, *KU, *LL, *MA, *ND, *NL, *RC, *SC, *SE, *SF, *SO, *SR, *TA, *TE, *TI, *UC, *UE, *UP, *US, *VB, *VS, *VE, *AL_PARM, *DL_PARM, *UP_PARM, *DOWN_PARM, *LEFT_PARM, *RIGHT_PARM; char PC; /* * From the tty modes... */ bool GT, NONL, normtty, _pfast; ================================================ FILE: lib/libcurses/curses.ext ================================================ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * * @(#)curses.ext 5.2 (Berkeley) 6/19/85 */ /* * External variables for the curses library */ /* LINTLIBRARY */ #include "curses.h" #include extern bool _echoit, _rawmode, My_term, _endwin; extern char ttytype[50], *_unctrl[]; extern int _tty_ch, LINES, COLS; extern SGTTY _tty; int _putchar (int); void _id_subwins (WINDOW *); void gettmode (void); void tstp (int); int _sprintw (WINDOW *, char *, va_list); int _sscans (WINDOW *, char *, va_list); /* XXX */ void _swflags_ (WINDOW *); void _set_subwin_ (WINDOW *, WINDOW *); void mvcur (int, int, int, int); #ifdef DEBUG # define outf _outf FILE *outf; #endif ================================================ FILE: lib/libcurses/delch.c ================================================ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include "curses.ext" /* * This routine performs an insert-char on the line, leaving * (_cury,_curx) unchanged. */ int wdelch(win) WINDOW *win; { char *temp1, *temp2; char *end; end = &win->_y[win->_cury][win->_maxx - 1]; temp1 = &win->_y[win->_cury][win->_curx]; temp2 = temp1 + 1; while (temp1 < end) *temp1++ = *temp2++; *temp1 = ' '; touchline(win, win->_cury, win->_curx, win->_maxx - 1); return OK; } ================================================ FILE: lib/libcurses/deleteln.c ================================================ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include "curses.ext" #include /* * This routine deletes a line from the screen. It leaves * (_cury,_curx) unchanged. */ int wdeleteln(win) WINDOW *win; { char *temp; int y; char *end; # ifdef DEBUG fprintf(outf, "DELETELN(%0.2o)\n", win); # endif temp = win->_y[win->_cury]; for (y = win->_cury; y < win->_maxy - 1; y++) { if (win->_orig == NULL) win->_y[y] = win->_y[y + 1]; else bcopy(win->_y[y + 1], win->_y[y], win->_maxx); touchline(win, y, 0, win->_maxx - 1); } if (win->_orig == NULL) win->_y[y] = temp; else temp = win->_y[y]; for (end = &temp[win->_maxx]; temp < end; ) *temp++ = ' '; touchline(win, win->_cury, 0, win->_maxx - 1); if (win->_orig == NULL) _id_subwins(win); return OK; } ================================================ FILE: lib/libcurses/delwin.c ================================================ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include "curses.ext" #include /* * This routine deletes a window and releases it back to the system. */ int delwin(win) WINDOW *win; { int i; WINDOW *wp, *np; if (win->_orig == NULL) { /* * If we are the original window, delete the space for * all the subwindows, and the array of space as well. */ for (i = 0; i < win->_maxy && win->_y[i]; i++) free(win->_y[i]); free(win->_firstch); free(win->_lastch); wp = win->_nextp; while (wp != win) { np = wp->_nextp; delwin(wp); wp = np; } } else { /* * If we are a subwindow, take ourselves out of the * list. NOTE: if we are a subwindow, the minimum list * is orig followed by this subwindow, so there are * always at least two windows in the list. */ for (wp = win->_nextp; wp->_nextp != win; wp = wp->_nextp) continue; wp->_nextp = win->_nextp; } free(win->_y); free(win); return 0; } ================================================ FILE: lib/libcurses/endwin.c ================================================ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include "curses.ext" /* * Clean things up before exiting */ void endwin() { resetty(); _puts(VE); _puts(TE); if (curscr) { if (curscr->_flags & _STANDOUT) { _puts(SE); curscr->_flags &= ~_STANDOUT; } _endwin = TRUE; } } ================================================ FILE: lib/libcurses/erase.c ================================================ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include "curses.ext" /* * This routine erases everything on the window. */ void werase(win) WINDOW *win; { int y; char *sp, *end, *start, *maxx; int minx; # ifdef DEBUG fprintf(outf, "WERASE(%0.2o)\n", win); # endif for (y = 0; y < win->_maxy; y++) { minx = _NOCHANGE; maxx = 0; start = win->_y[y]; end = &start[win->_maxx]; for (sp = start; sp < end; sp++) if (*sp != ' ') { maxx = sp; if (minx == _NOCHANGE) minx = sp - start; *sp = ' '; } if (minx != _NOCHANGE) touchline(win, y, minx, maxx - win->_y[y]); } win->_curx = win->_cury = 0; } ================================================ FILE: lib/libcurses/fullname.c ================================================ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ /* * This routine fills in "def" with the full name of the terminal. * This is assumed to be the last name in the list of aliases. * */ char * fullname(bp, def) char *bp, *def; { char *cp; *def = 0; /* in case no name */ while (*bp && *bp != ':') { cp = def; /* start of answer */ while (*bp && *bp != ':' && *bp != '|') { *cp++ = *bp++; /* copy name over */ } *cp = 0; /* zero end of name */ if (*bp == '|') { bp++; /* skip over '|' if that is case */ } } return(def); } ================================================ FILE: lib/libcurses/getch.c ================================================ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include "curses.ext" /* * This routine reads in a character from the window. */ int wgetch(win) WINDOW *win; { bool weset = FALSE; char inp; if (!win->_scroll && (win->_flags&_FULLWIN) && win->_curx == win->_maxx - 1 && win->_cury == win->_maxy - 1) return ERR; # ifdef DEBUG fprintf(outf, "WGETCH: _echoit = %c, _rawmode = %c\n", _echoit ? 'T' : 'F', _rawmode ? 'T' : 'F'); # endif if (_echoit && !_rawmode) { cbreak(); weset++; } inp = getchar(); # ifdef DEBUG fprintf(outf,"WGETCH got '%s'\n",unctrl(inp)); # endif if (_echoit) { mvwaddch(curscr, win->_cury + win->_begy, win->_curx + win->_begx, inp); waddch(win, inp); } if (weset) nocbreak(); return inp; } ================================================ FILE: lib/libcurses/getstr.c ================================================ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include "curses.ext" /* * This routine gets a string starting at (_cury,_curx) */ int wgetstr(win, str) WINDOW *win; char *str; { while ((*str = wgetch(win)) != ERR && *str != '\n') str++; if (*str == ERR) { *str = '\0'; return ERR; } *str = '\0'; return OK; } ================================================ FILE: lib/libcurses/id_subwins.c ================================================ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include "curses.ext" /* * _id_subwins: * Re-sync the pointers to _y for all the subwindows. */ void _id_subwins(orig) WINDOW *orig; { WINDOW *win; int realy; int y, oy; realy = orig->_begy + orig->_cury; for (win = orig->_nextp; win != orig; win = win->_nextp) { /* * If the window ends before our current position, * don't need to do anything. */ if (win->_begy + win->_maxy <= realy) continue; oy = orig->_cury; for (y = realy - win->_begy; y < win->_maxy; y++, oy++) win->_y[y] = &orig->_y[oy][win->_ch_off]; } } ================================================ FILE: lib/libcurses/idlok.c ================================================ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include "curses.ext" /* * idlok: * Turn on and off using insert/deleteln sequences for the given * window. */ void idlok(win, bf) WINDOW *win; bool bf; { if (bf) win->_flags |= _IDLINE; else win->_flags &= ~_IDLINE; } ================================================ FILE: lib/libcurses/initscr.c ================================================ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include "curses.ext" #include #include #include /* * This routine initializes the current and standard screen. */ WINDOW * initscr() { char *sp; int nfd; # ifdef DEBUG fprintf(outf, "INITSCR()\n"); # endif if (My_term) setterm(Def_term); else { nfd = getdtablesize(); for (_tty_ch = 0; _tty_ch < nfd; _tty_ch++) if (isatty(_tty_ch)) break; gettmode(); sp = getenv("TERM"); if (! sp) sp = Def_term; setterm(sp); # ifdef DEBUG fprintf(outf, "INITSCR: term = %s\n", sp); # endif } _puts(TI); _puts(VS); # ifdef SIGTSTP signal(SIGTSTP, (sig_t)tstp); # endif if (curscr != NULL) { # ifdef DEBUG fprintf(outf, "INITSCR: curscr = 0%o\n", curscr); # endif delwin(curscr); } # ifdef DEBUG fprintf(outf, "LINES = %d, COLS = %d\n", LINES, COLS); # endif if ((curscr = newwin(LINES, COLS, 0, 0)) == ERR) return ERR; clearok(curscr, TRUE); curscr->_flags &= ~_FULLLINE; if (stdscr != NULL) { # ifdef DEBUG fprintf(outf, "INITSCR: stdscr = 0%o\n", stdscr); # endif delwin(stdscr); } stdscr = newwin(LINES, COLS, 0, 0); return stdscr; } ================================================ FILE: lib/libcurses/insch.c ================================================ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include "curses.ext" /* * This routine performs an insert-char on the line, leaving * (_cury,_curx) unchanged. */ int winsch(win, c) WINDOW *win; char c; { char *temp1, *temp2; char *end; end = &win->_y[win->_cury][win->_curx]; temp1 = &win->_y[win->_cury][win->_maxx - 1]; temp2 = temp1 - 1; while (temp1 > end) *temp1-- = *temp2--; *temp1 = c; touchline(win, win->_cury, win->_curx, win->_maxx - 1); if (win->_cury == LINES - 1 && win->_y[LINES-1][COLS-1] != ' ') { if (! win->_scroll) return ERR; wrefresh(win); scroll(win); win->_cury--; } return OK; } ================================================ FILE: lib/libcurses/insertln.c ================================================ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include "curses.ext" #include /* * This routine performs an insert-line on the window, leaving * (_cury,_curx) unchanged. */ void winsertln(win) WINDOW *win; { char *temp = 0; int y; char *end; #ifdef DEBUG fprintf(outf, "INSERTLN(%0.2o)\n", win); #endif if (win->_orig == NULL) temp = win->_y[win->_maxy - 1]; for (y = win->_maxy - 1; y > win->_cury; --y) { if (win->_orig == NULL) win->_y[y] = win->_y[y - 1]; else bcopy(win->_y[y - 1], win->_y[y], win->_maxx); touchline(win, y, 0, win->_maxx - 1); } if (win->_orig == NULL) win->_y[y] = temp; else temp = win->_y[y]; for (end = &temp[win->_maxx]; temp < end; ) *temp++ = ' '; touchline(win, y, 0, win->_maxx - 1); if (win->_orig == NULL) _id_subwins(win); } ================================================ FILE: lib/libcurses/longname.c ================================================ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ /* * This routine fills in "def" with the long name of the terminal. */ char * longname(bp, def) char *bp, *def; { char *cp; while (*bp && *bp != ':' && *bp != '|') bp++; if (*bp == '|') { bp++; cp = def; while (*bp && *bp != ':' && *bp != '|') *cp++ = *bp++; *cp = 0; } return def; } ================================================ FILE: lib/libcurses/move.c ================================================ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include "curses.ext" /* * This routine moves the cursor to the given point */ int wmove(win, y, x) WINDOW *win; int y, x; { #ifdef DEBUG fprintf(outf, "MOVE to (%d, %d)\n", y, x); #endif if (x < 0 || y < 0) return ERR; if (x >= win->_maxx || y >= win->_maxy) return ERR; win->_curx = x; win->_cury = y; return OK; } ================================================ FILE: lib/libcurses/mvprintw.c ================================================ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include "curses.ext" /* * implement the mvprintw commands. Due to the variable number of * arguments, they cannot be macros. Sigh.... * */ int mvprintw(int y, int x, char *fmt, ...) { va_list args; int ret; if (move(y, x) != OK) return ERR; va_start (args, fmt); ret = _sprintw (stdscr, fmt, args); va_end (args); return ret; } int mvwprintw(WINDOW *win, int y, int x, char *fmt, ...) { va_list args; int ret; if (wmove(win, y, x) != OK) return ERR; va_start (args, fmt); ret = _sprintw (win, fmt, args); va_end (args); return ret; } ================================================ FILE: lib/libcurses/mvscanw.c ================================================ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include "curses.ext" /* * implement the mvscanw commands. Due to the variable number of * arguments, they cannot be macros. Another sigh.... */ int mvscanw(y, x, fmt, args) int y, x; char *fmt; va_list args; /* XXX */ { return move(y, x) == OK ? _sscans(stdscr, fmt, args) : ERR; /* XXX */ } int mvwscanw(win, y, x, fmt, args) WINDOW *win; int y, x; char *fmt; va_list args; /* XXX */ { return wmove(win, y, x) == OK ? _sscans(win, fmt, args) : ERR; /* XXX */ } ================================================ FILE: lib/libcurses/mvwin.c ================================================ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include "curses.ext" /* * relocate the starting position of a window */ int mvwin(win, by, bx) WINDOW *win; int by, bx; { WINDOW *orig; int dy, dx; if (by + win->_maxy > LINES || bx + win->_maxx > COLS) return ERR; dy = by - win->_begy; dx = bx - win->_begx; orig = win->_orig; if (orig == NULL) { orig = win; do { win->_begy += dy; win->_begx += dx; _swflags_(win); win = win->_nextp; } while (win != orig); } else { if (by < orig->_begy || win->_maxy + dy > orig->_maxy) return ERR; if (bx < orig->_begx || win->_maxx + dx > orig->_maxx) return ERR; win->_begy = by; win->_begx = bx; _swflags_(win); _set_subwin_(orig, win); } touchwin(win); return OK; } ================================================ FILE: lib/libcurses/newwin.c ================================================ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ /* * allocate space for and set up defaults for a new window * */ #include "curses.ext" #include #define SMALLOC (short*)malloc #undef nl /* don't need it here, and it interferes */ /* * This routine sets up a window buffer and returns a pointer to it. */ static WINDOW * makenew(num_lines, num_cols, begy, begx) int num_lines, num_cols, begy, begx; { WINDOW *win; int by, bx, nl, nc; by = begy; bx = begx; nl = num_lines; nc = num_cols; # ifdef DEBUG fprintf(outf, "MAKENEW(%d, %d, %d, %d)\n", nl, nc, by, bx); # endif if ((win = (WINDOW *) malloc(sizeof *win)) == NULL) return NULL; # ifdef DEBUG fprintf(outf, "MAKENEW: nl = %d\n", nl); # endif if ((win->_y = (char **) malloc(nl * sizeof win->_y[0])) == NULL) { free(win); return NULL; } # ifdef DEBUG fprintf(outf, "MAKENEW: nc = %d\n", nc); # endif win->_cury = win->_curx = 0; win->_clear = FALSE; win->_maxy = nl; win->_maxx = nc; win->_begy = by; win->_begx = bx; win->_flags = 0; win->_scroll = win->_leave = FALSE; _swflags_(win); # ifdef DEBUG fprintf(outf, "MAKENEW: win->_clear = %d\n", win->_clear); fprintf(outf, "MAKENEW: win->_leave = %d\n", win->_leave); fprintf(outf, "MAKENEW: win->_scroll = %d\n", win->_scroll); fprintf(outf, "MAKENEW: win->_flags = %0.2o\n", win->_flags); fprintf(outf, "MAKENEW: win->_maxy = %d\n", win->_maxy); fprintf(outf, "MAKENEW: win->_maxx = %d\n", win->_maxx); fprintf(outf, "MAKENEW: win->_begy = %d\n", win->_begy); fprintf(outf, "MAKENEW: win->_begx = %d\n", win->_begx); # endif return win; } WINDOW * newwin(num_lines, num_cols, begy, begx) int num_lines, num_cols, begy, begx; { WINDOW *win; char *sp; int i, by, bx, nl, nc; int j; by = begy; bx = begx; nl = num_lines; nc = num_cols; if (nl == 0) nl = LINES - by; if (nc == 0) nc = COLS - bx; if ((win = makenew(nl, nc, by, bx)) == NULL) return ERR; if ((win->_firstch = SMALLOC(nl * sizeof win->_firstch[0])) == NULL) { free(win->_y); free(win); return NULL; } if ((win->_lastch = SMALLOC(nl * sizeof win->_lastch[0])) == NULL) { free(win->_y); free(win->_firstch); free(win); return NULL; } win->_nextp = win; for (i = 0; i < nl; i++) { win->_firstch[i] = _NOCHANGE; win->_lastch[i] = _NOCHANGE; } for (i = 0; i < nl; i++) if ((win->_y[i] = malloc(nc * sizeof win->_y[0])) == NULL) { for (j = 0; j < i; j++) free(win->_y[j]); free(win->_firstch); free(win->_lastch); free(win->_y); free(win); return ERR; } else for (sp = win->_y[i]; sp < win->_y[i] + nc; ) *sp++ = ' '; win->_ch_off = 0; # ifdef DEBUG fprintf(outf, "NEWWIN: win->_ch_off = %d\n", win->_ch_off); # endif return win; } WINDOW * subwin(orig, num_lines, num_cols, begy, begx) WINDOW *orig; int num_lines, num_cols, begy, begx; { WINDOW *win; int by, bx, nl, nc; by = begy; bx = begx; nl = num_lines; nc = num_cols; /* * make sure window fits inside the original one */ # ifdef DEBUG fprintf(outf, "SUBWIN(%0.2o, %d, %d, %d, %d)\n", orig, nl, nc, by, bx); # endif if (by < orig->_begy || bx < orig->_begx || by + nl > orig->_maxy + orig->_begy || bx + nc > orig->_maxx + orig->_begx) return ERR; if (nl == 0) nl = orig->_maxy + orig->_begy - by; if (nc == 0) nc = orig->_maxx + orig->_begx - bx; if ((win = makenew(nl, nc, by, bx)) == NULL) return ERR; win->_nextp = orig->_nextp; orig->_nextp = win; win->_orig = orig; _set_subwin_(orig, win); return win; } /* * this code is shared with mvwin() */ void _set_subwin_(orig, win) register WINDOW *orig, *win; { register int i, j, k; j = win->_begy - orig->_begy; k = win->_begx - orig->_begx; win->_ch_off = k; # ifdef DEBUG fprintf(outf, "_SET_SUBWIN_: win->_ch_off = %d\n", win->_ch_off); # endif win->_firstch = &orig->_firstch[j]; win->_lastch = &orig->_lastch[j]; for (i = 0; i < win->_maxy; i++, j++) win->_y[i] = &orig->_y[j][k]; } void _swflags_(win) register WINDOW *win; { win->_flags &= ~(_ENDLINE|_FULLLINE|_FULLWIN|_SCROLLWIN); if (win->_begx + win->_maxx == COLS) { win->_flags |= _ENDLINE; if (win->_begx == 0) { if (AL && DL) win->_flags |= _FULLLINE; if (win->_maxy == LINES && win->_begy == 0) win->_flags |= _FULLWIN; } if (win->_begy + win->_maxy == LINES) win->_flags |= _SCROLLWIN; } } ================================================ FILE: lib/libcurses/overlay.c ================================================ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include "curses.ext" #include #include #define min(a,b) (a < b ? a : b) #define max(a,b) (a > b ? a : b) /* * This routine writes win1 on win2 non-destructively. */ void overlay(win1, win2) WINDOW *win1, *win2; { char *sp, *end; int x, y, endy, endx, starty, startx; int y1,y2; # ifdef DEBUG fprintf(outf, "OVERLAY(%0.2o, %0.2o);\n", win1, win2); # endif starty = max(win1->_begy, win2->_begy); startx = max(win1->_begx, win2->_begx); endy = min(win1->_maxy + win1->_begy, win2->_maxy + win2->_begx); endx = min(win1->_maxx + win1->_begx, win2->_maxx + win2->_begx); # ifdef DEBUG fprintf(outf, "OVERLAY:from (%d,%d) to (%d,%d)\n", starty, startx, endy, endx); # endif if (starty >= endy || startx >= endx) return; x = endx - startx; for (y = starty; y < endy; y++) { bcopy(&win1->_y[y - win1->_begy][startx - win1->_begx], &win2->_y[y - win2->_begy][startx - win2->_begx], x); touchline(win2, y, startx - win2->_begx, endx - win2->_begx); } y1 = starty - win1->_begy; y2 = starty - win2->_begy; for (y = starty; y < endy; y++, y1++, y2++) { end = &win1->_y[y1][endx - win1->_begx]; x = startx - win2->_begx; for (sp = &win1->_y[y1][startx - win1->_begx]; sp < end; sp++) { if (!isspace(*sp)) mvwaddch(win2, y2, x, *sp); x++; } } } ================================================ FILE: lib/libcurses/overwrite.c ================================================ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include "curses.ext" #include #include #define min(a,b) (a < b ? a : b) #define max(a,b) (a > b ? a : b) /* * This routine writes win1 on win2 destructively. */ void overwrite(win1, win2) WINDOW *win1, *win2; { int x, y, endy, endx, starty, startx; # ifdef DEBUG fprintf(outf, "OVERWRITE(%0.2o, %0.2o);\n", win1, win2); # endif starty = max(win1->_begy, win2->_begy); startx = max(win1->_begx, win2->_begx); endy = min(win1->_maxy + win1->_begy, win2->_maxy + win2->_begx); endx = min(win1->_maxx + win1->_begx, win2->_maxx + win2->_begx); if (starty >= endy || startx >= endx) return; # ifdef DEBUG fprintf(outf, "OVERWRITE:from (%d,%d) to (%d,%d)\n", starty, startx, endy, endx); # endif x = endx - startx; for (y = starty; y < endy; y++) { bcopy(&win1->_y[y - win1->_begy][startx - win1->_begx], &win2->_y[y - win2->_begy][startx - win2->_begx], x); touchline(win2, y, startx - win2->_begx, endx - win2->_begx); } } ================================================ FILE: lib/libcurses/printw.c ================================================ /* * printw and friends * * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include "curses.ext" /* * This routine actually executes the printf and adds it to the window * * This is really a modified version of "sprintf". As such, * it assumes that sprintf interfaces with the other printf functions * in a certain way. If this is not how your system works, you * will have to modify this routine to use the interface that your * "sprintf" uses. */ int _sprintw (WINDOW *win, char *fmt, va_list args) { FILE junk; char buf[512]; junk._flag = _IOWRT + _IOSTRG; junk._ptr = buf; junk._cnt = 32767; _doprnt(fmt, args, &junk); putc('\0', &junk); return waddstr(win, buf); } /* * This routine implements a printf on the standard screen. */ int printw (char *fmt, ...) { va_list args; int ret; va_start (args, fmt); ret = _sprintw (stdscr, fmt, args); va_end (args); return ret; } /* * This routine implements a printf on the given window. */ int wprintw (WINDOW *win, char *fmt, ...) { va_list args; int ret; va_start (args, fmt); ret = _sprintw (win, fmt, args); /* XXX */ va_end (args); return ret; } ================================================ FILE: lib/libcurses/putchar.c ================================================ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include "curses.ext" int _putchar(c) int c; { putchar(c); #ifdef DEBUG fprintf(outf, "_PUTCHAR(%s)\n", unctrl(c)); #endif return 0; } ================================================ FILE: lib/libcurses/refresh.c ================================================ /* * make the current screen look like "win" over the area coverd by * win. * * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include #include "curses.ext" #ifdef DEBUG # define STATIC #else # define STATIC static #endif STATIC short ly, lx; STATIC bool curwin; WINDOW *_win = NULL; /* * perform a mvcur, leaving standout mode if necessary */ STATIC void domvcur(oy, ox, ny, nx) int oy, ox, ny, nx; { if (curscr->_flags & _STANDOUT && !MS) { _puts(SE); curscr->_flags &= ~_STANDOUT; } mvcur(oy, ox, ny, nx); } /* * make a change on the screen */ STATIC int makech(win, wy) WINDOW *win; short wy; { char *nsp, *csp, *ce; short wx, lch, y; int nlsp = 0, clsp; /* last space in lines */ wx = win->_firstch[wy] - win->_ch_off; if (wx >= win->_maxx) return OK; else if (wx < 0) wx = 0; lch = win->_lastch[wy] - win->_ch_off; if (lch < 0) return OK; else if (lch >= win->_maxx) lch = win->_maxx - 1;; y = wy + win->_begy; if (curwin) csp = " "; else csp = &curscr->_y[wy + win->_begy][wx + win->_begx]; nsp = &win->_y[wy][wx]; if (CE && !curwin) { for (ce = &win->_y[wy][win->_maxx - 1]; *ce == ' '; ce--) if (ce <= win->_y[wy]) break; nlsp = ce - win->_y[wy]; } if (!curwin) ce = CE; else ce = NULL; while (wx <= lch) { if (*nsp != *csp) { domvcur(ly, lx, y, wx + win->_begx); # ifdef DEBUG fprintf(outf, "MAKECH: 1: wx = %d, lx = %d\n", wx, lx); # endif ly = y; lx = wx + win->_begx; while (*nsp != *csp && wx <= lch) { if (ce != NULL && wx >= nlsp && *nsp == ' ') { /* * check for clear to end-of-line */ ce = &curscr->_y[ly][COLS - 1]; while (*ce == ' ') if (ce-- <= csp) break; clsp = ce - curscr->_y[ly] - win->_begx; # ifdef DEBUG fprintf(outf, "MAKECH: clsp = %d, nlsp = %d\n", clsp, nlsp); # endif if (clsp - nlsp >= strlen(CE) && clsp < win->_maxx) { # ifdef DEBUG fprintf(outf, "MAKECH: using CE\n"); # endif _puts(CE); lx = wx + win->_begx; while (wx++ <= clsp) *csp++ = ' '; return OK; } ce = NULL; } /* * enter/exit standout mode as appropriate */ if (SO && (*nsp&_STANDOUT) != (curscr->_flags&_STANDOUT)) { if (*nsp & _STANDOUT) { _puts(SO); curscr->_flags |= _STANDOUT; } else { _puts(SE); curscr->_flags &= ~_STANDOUT; } } wx++; if (wx >= win->_maxx && wy == win->_maxy - 1) { if (win->_scroll) { if ((curscr->_flags&_STANDOUT) && (win->_flags & _ENDLINE)) if (!MS) { _puts(SE); curscr->_flags &= ~_STANDOUT; } if (!curwin) _putchar((*csp = *nsp) & 0177); else _putchar(*nsp & 0177); if (win->_flags&_FULLWIN && !curwin) scroll(curscr); ly = win->_begy+win->_cury; lx = win->_begx+win->_curx; return OK; } else if (win->_flags&_SCROLLWIN) { lx = --wx; return ERR; } } if (!curwin) _putchar((*csp++ = *nsp) & 0177); else _putchar(*nsp & 0177); # ifdef FULLDEBUG fprintf(outf, "MAKECH:putchar(%c)\n", *nsp & 0177); # endif if (UC && (*nsp & _STANDOUT)) { _putchar('\b'); _puts(UC); } nsp++; } # ifdef DEBUG fprintf(outf, "MAKECH: 2: wx = %d, lx = %d\n", wx, lx); # endif if (lx == wx + win->_begx) /* if no change */ break; lx = wx + win->_begx; if (lx >= COLS && AM) { lx = 0; ly++; /* * xn glitch: chomps a newline after auto-wrap. * we just feed it now and forget about it. */ if (XN) { _putchar('\n'); _putchar('\r'); } } } else if (wx <= lch) while (*nsp == *csp && wx <= lch) { nsp++; if (!curwin) csp++; ++wx; } else break; # ifdef DEBUG fprintf(outf, "MAKECH: 3: wx = %d, lx = %d\n", wx, lx); # endif } return OK; } int wrefresh(win) WINDOW *win; { short wy; int retval; /* * make sure were in visual state */ if (_endwin) { _puts(VS); _puts(TI); _endwin = FALSE; } /* * initialize loop parameters */ ly = curscr->_cury; lx = curscr->_curx; wy = 0; _win = win; curwin = (win == curscr); if (win->_clear || curscr->_clear || curwin) { if ((win->_flags & _FULLWIN) || curscr->_clear) { _puts(CL); ly = 0; lx = 0; if (!curwin) { curscr->_clear = FALSE; curscr->_cury = 0; curscr->_curx = 0; werase(curscr); } touchwin(win); } win->_clear = FALSE; } if (!CA) { if (win->_curx != 0) _putchar('\n'); if (!curwin) werase(curscr); } # ifdef DEBUG fprintf(outf, "REFRESH(%0.2o): curwin = %d\n", win, curwin); fprintf(outf, "REFRESH:\n\tfirstch\tlastch\n"); # endif for (wy = 0; wy < win->_maxy; wy++) { # ifdef DEBUG fprintf(outf, "%d\t%d\t%d\n", wy, win->_firstch[wy], win->_lastch[wy]); # endif if (win->_firstch[wy] != _NOCHANGE) { if (makech(win, wy) == ERR) return ERR; else { if (win->_firstch[wy] >= win->_ch_off) win->_firstch[wy] = win->_maxx + win->_ch_off; if (win->_lastch[wy] < win->_maxx + win->_ch_off) win->_lastch[wy] = win->_ch_off; if (win->_lastch[wy] < win->_firstch[wy]) win->_firstch[wy] = _NOCHANGE; } } # ifdef DEBUG fprintf(outf, "\t%d\t%d\n", win->_firstch[wy], win->_lastch[wy]); # endif } if (win == curscr) domvcur(ly, lx, win->_cury, win->_curx); else { if (win->_leave) { curscr->_cury = ly; curscr->_curx = lx; ly -= win->_begy; lx -= win->_begx; if (ly >= 0 && ly < win->_maxy && lx >= 0 && lx < win->_maxx) { win->_cury = ly; win->_curx = lx; } else win->_cury = win->_curx = 0; } else { domvcur(ly, lx, win->_cury + win->_begy, win->_curx + win->_begx); curscr->_cury = win->_cury + win->_begy; curscr->_curx = win->_curx + win->_begx; } } retval = OK; _win = NULL; fflush(stdout); return retval; } ================================================ FILE: lib/libcurses/scanw.c ================================================ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ /* * scanw and friends * */ #include #include "curses.ext" /* * This routine implements a scanf on the standard screen. */ int scanw(fmt, args) char *fmt; va_list args; /* XXX */ { return _sscans(stdscr, fmt, args); /* XXX */ } /* * This routine implements a scanf on the given window. */ int wscanw(win, fmt, args) WINDOW *win; char *fmt; va_list args; /* XXX */ { return _sscans(win, fmt, args); /* XXX */ } /* * This routine actually executes the scanf from the window. * * This is really a modified version of "sscanf". As such, * it assumes that sscanf interfaces with the other scanf functions * in a certain way. If this is not how your system works, you * will have to modify this routine to use the interface that your * "sscanf" uses. */ int _sscans(win, fmt, args) WINDOW *win; char *fmt; va_list args; /* XXX */ { char buf[100]; FILE junk; junk._flag = _IOREAD|_IOSTRG; junk._base = junk._ptr = buf; if (wgetstr(win, buf) == ERR) return ERR; junk._cnt = strlen(buf); return _doscan(&junk, fmt, args); /* XXX */ } ================================================ FILE: lib/libcurses/scroll.c ================================================ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include "curses.ext" /* * This routine scrolls the window up a line. */ int scroll(win) WINDOW *win; { int oy, ox; # ifdef DEBUG fprintf(outf, "SCROLL(%0.2o)\n", win); # endif if (! win->_scroll) return ERR; getyx(win, oy, ox); wmove(win, 0, 0); wdeleteln(win); wmove(win, oy, ox); if (win == curscr) { _putchar('\n'); if (!NONL) win->_curx = 0; # ifdef DEBUG fprintf(outf, "SCROLL: win == curscr\n"); # endif } return OK; } ================================================ FILE: lib/libcurses/standout.c ================================================ /* * routines dealing with entering and exiting standout mode * * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include "curses.ext" /* * enter standout mode */ char * wstandout(win) WINDOW *win; { if (!SO && !UC) return FALSE; win->_flags |= _STANDOUT; return (SO ? SO : UC); } /* * exit standout mode */ char * wstandend(win) WINDOW *win; { if (!SO && !UC) return FALSE; win->_flags &= ~_STANDOUT; return (SE ? SE : UC); } ================================================ FILE: lib/libcurses/test.c ================================================ #include #define YPOSBOX 0 #define XPOSBOX 0 #define YBOX 20 #define XBOX 80 #define YPOSSBOX 2 #define XPOSSBOX 10 #define YSBOX 17 #define XSBOX 66 WINDOW *boxing,*sub_box; main() { boxing = newwin(YBOX,XBOX,YPOSBOX,XPOSBOX); sub_box = subwin(boxing,YSBOX,XSBOX,YPOSSBOX,XPOSSBOX); initscr(); box(boxing,'|','-'); wrefresh(boxing); box(sub_box,'.','.'); overlay(sub_box,boxing);/* overlays sub_box on top of boxing */ wrefresh(sub_box); mvcur(0,COLS-1,LINES-1,0); /* move to bottom of screen */ endwin(); } ================================================ FILE: lib/libcurses/toucholap.c ================================================ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include "curses.ext" #define min(a,b) (a < b ? a : b) #define max(a,b) (a > b ? a : b) /* * Touch, on win2, the part that overlaps with win1. */ void touchoverlap(win1, win2) WINDOW *win1, *win2; { int y, endy, endx, starty, startx; # ifdef DEBUG fprintf(outf, "TOUCHOVERLAP(%0.2o, %0.2o);\n", win1, win2); # endif starty = max(win1->_begy, win2->_begy); startx = max(win1->_begx, win2->_begx); endy = min(win1->_maxy + win1->_begy, win2->_maxy + win2->_begx); endx = min(win1->_maxx + win1->_begx, win2->_maxx + win2->_begx); # ifdef DEBUG fprintf(outf, "TOUCHOVERLAP:from (%d,%d) to (%d,%d)\n", starty, startx, endy, endx); fprintf(outf, "TOUCHOVERLAP:win1 (%d,%d) to (%d,%d)\n", win1->_begy, win1->_begx, win1->_begy + win1->_maxy, win1->_begx + win1->_maxx); fprintf(outf, "TOUCHOVERLAP:win2 (%d,%d) to (%d,%d)\n", win2->_begy, win2->_begx, win2->_begy + win2->_maxy, win2->_begx + win2->_maxx); # endif if (starty >= endy || startx >= endx) return; starty -= win2->_begy; startx -= win2->_begx; endy -= win2->_begy; endx -= win2->_begx; endx--; for (y = starty; y < endy; y++) touchline(win2, y, startx, endx); } ================================================ FILE: lib/libcurses/touchwin.c ================================================ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include "curses.ext" /* * make it look like the whole window has been changed. * */ int touchwin(win) WINDOW *win; { int y, maxy; # ifdef DEBUG fprintf(outf, "TOUCHWIN(%0.2o)\n", win); # endif maxy = win->_maxy; for (y = 0; y < maxy; y++) touchline(win, y, 0, win->_maxx - 1); return OK; } /* * touch a given line */ int touchline(win, y, sx, ex) WINDOW *win; int y, sx, ex; { # ifdef DEBUG fprintf(outf, "TOUCHLINE(%0.2o, %d, %d, %d)\n", win, y, sx, ex); fprintf(outf, "TOUCHLINE:first = %d, last = %d\n", win->_firstch[y], win->_lastch[y]); # endif sx += win->_ch_off; ex += win->_ch_off; if (win->_firstch[y] == _NOCHANGE) { win->_firstch[y] = sx; win->_lastch[y] = ex; } else { if (win->_firstch[y] > sx) win->_firstch[y] = sx; if (win->_lastch[y] < ex) win->_lastch[y] = ex; } # ifdef DEBUG fprintf(outf, "TOUCHLINE:first = %d, last = %d\n", win->_firstch[y], win->_lastch[y]); # endif return OK; } ================================================ FILE: lib/libcurses/tstp.c ================================================ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include #include "curses.ext" /* * handle stop and start signals */ void tstp(sig) int sig; { SGTTY tty; sigset_t oset, set; #ifdef DEBUG if (outf) fflush(outf); #endif /* * Block window change and timer signals. The latter is because * applications use timers to decide when to repaint the screen. */ (void)sigemptyset(&set); (void)sigaddset(&set, SIGALRM); (void)sigaddset(&set, SIGWINCH); (void)sigprocmask(SIG_BLOCK, &set, &oset); tty = _tty; mvcur(0, COLS - 1, LINES - 1, 0); endwin(); fflush(stdout); /* Unblock SIGTSTP. */ (void)sigemptyset(&set); (void)sigaddset(&set, SIGTSTP); (void)sigprocmask(SIG_UNBLOCK, &set, NULL); /* Stop ourselves. */ signal(SIGTSTP, SIG_DFL); kill(0, SIGTSTP); /* Time passes ... */ /* Reset the SIGTSTP handler. */ signal(SIGTSTP, (sig_t)tstp); _tty = tty; ioctl(_tty_ch, TIOCSETP, &_tty); /* Repaint the screen. */ wrefresh(curscr); /* Reset the signals. */ (void)sigprocmask(SIG_SETMASK, &oset, NULL); } ================================================ FILE: lib/libcurses/unctrl.c ================================================ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ /* * define unctrl codes for each character * */ /* LINTLIBRARY */ char *_unctrl[] = { /* unctrl codes for ttys */ "^@", "^A", "^B", "^C", "^D", "^E", "^F", "^G", "^H", "^I", "^J", "^K", "^L", "^M", "^N", "^O", "^P", "^Q", "^R", "^S", "^T", "^U", "^V", "^W", "^X", "^Y", "^Z", "^[", "^\\", "^]", "^~", "^_", " ", "!", "\"", "#", "$", "%", "&", "'", "(", ")", "*", "+", ",", "-", ".", "/", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", ":", ";", "<", "=", ">", "?", "@", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "[", "\\", "]", "^", "_", "`", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "{", "|", "}", "~", "^?" }; ================================================ FILE: lib/libgpanel/Makefile ================================================ TOPSRC!=cd ../..; pwd include ${TOPSRC}/share/mk/sys.mk CFLAGS += -O -Wall MAN = gpanel.0 MANSRC = gpanel.3 OBJS = open.o clear.o pixel.o line.o rect.o fill.o fill_triangle.o \ circle.o image.o char.o text.o text_width.o all: ../libgpanel.a $(MAN) ../libgpanel.a: ${OBJS} @${AR} cr $@ ${OBJS} $(RANLIB) $@ $(MAN): $(MANSRC) ${MANROFF} ${MANSRC} > $@ install: all cp ${MAN} ${DESTDIR}/usr/share/man/cat3/ clean: rm -f *.o a.out core test errs ../libgpanel*.a $(MAN) ================================================ FILE: lib/libgpanel/char.c ================================================ /* * Draw a single character glyph. * * Copyright (C) 2015 Serge Vakulenko, * * Permission to use, copy, modify, and distribute this software * and its documentation for any purpose and without fee is hereby * granted, provided that the above copyright notice appear in all * copies and that both that the copyright notice and this * permission notice and warranty disclaimer appear in supporting * documentation, and that the name of the author not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * * The author disclaim all warranties with regard to this * software, including all implied warranties of merchantability * and fitness. In no event shall the author be liable for any * special, indirect or consequential damages or any damages * whatsoever resulting from loss of use, data or profits, whether * in an action of contract, negligence or other tortious action, * arising out of or in connection with the use or performance of * this software. */ #include #include void gpanel_char(const struct gpanel_font_t *font, int color, int background, int x, int y, int sym) { struct gpanel_char_t param; param.font = font; param.color = color; param.background = background; param.x = x; param.y = y; param.sym = sym; ioctl(_gpanel_fd, GPANEL_CHAR, ¶m); } ================================================ FILE: lib/libgpanel/circle.c ================================================ /* * Draw a circle (no fill). * * Copyright (C) 2015 Serge Vakulenko, * * Permission to use, copy, modify, and distribute this software * and its documentation for any purpose and without fee is hereby * granted, provided that the above copyright notice appear in all * copies and that both that the copyright notice and this * permission notice and warranty disclaimer appear in supporting * documentation, and that the name of the author not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * * The author disclaim all warranties with regard to this * software, including all implied warranties of merchantability * and fitness. In no event shall the author be liable for any * special, indirect or consequential damages or any damages * whatsoever resulting from loss of use, data or profits, whether * in an action of contract, negligence or other tortious action, * arising out of or in connection with the use or performance of * this software. */ #include #include void gpanel_circle(int color, int x, int y, int radius) { struct gpanel_circle_t param; param.color = color; param.x = x; param.y = y; param.radius = radius; ioctl(_gpanel_fd, GPANEL_CIRCLE, ¶m); } ================================================ FILE: lib/libgpanel/clear.c ================================================ /* * Clear the screen. * * Copyright (C) 2015 Serge Vakulenko, * * Permission to use, copy, modify, and distribute this software * and its documentation for any purpose and without fee is hereby * granted, provided that the above copyright notice appear in all * copies and that both that the copyright notice and this * permission notice and warranty disclaimer appear in supporting * documentation, and that the name of the author not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * * The author disclaim all warranties with regard to this * software, including all implied warranties of merchantability * and fitness. In no event shall the author be liable for any * special, indirect or consequential damages or any damages * whatsoever resulting from loss of use, data or profits, whether * in an action of contract, negligence or other tortious action, * arising out of or in connection with the use or performance of * this software. */ #include #include void gpanel_clear(int color, int *xsize, int *ysize) { struct gpanel_clear_t param; param.color = color; param.xsize = xsize ? *xsize : 0; param.ysize = ysize ? *ysize : 0; ioctl(_gpanel_fd, GPANEL_CLEAR, ¶m); if (xsize) *xsize = param.xsize; if (ysize) *ysize = param.ysize; } ================================================ FILE: lib/libgpanel/fill.c ================================================ /* * Fill a rectangle. * * Copyright (C) 2015 Serge Vakulenko, * * Permission to use, copy, modify, and distribute this software * and its documentation for any purpose and without fee is hereby * granted, provided that the above copyright notice appear in all * copies and that both that the copyright notice and this * permission notice and warranty disclaimer appear in supporting * documentation, and that the name of the author not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * * The author disclaim all warranties with regard to this * software, including all implied warranties of merchantability * and fitness. In no event shall the author be liable for any * special, indirect or consequential damages or any damages * whatsoever resulting from loss of use, data or profits, whether * in an action of contract, negligence or other tortious action, * arising out of or in connection with the use or performance of * this software. */ #include #include void gpanel_fill(int color, int x0, int y0, int x1, int y1) { struct gpanel_rect_t param; param.color = color; param.x0 = x0; param.y0 = y0; param.x1 = x1; param.y1 = y1; ioctl(_gpanel_fd, GPANEL_FILL, ¶m); } ================================================ FILE: lib/libgpanel/fill_triangle.c ================================================ /* * Fill a triangle. * Code ported from AdaFruit TFT LCD library. * * Copyright (C) 2015 Serge Vakulenko, * * Permission to use, copy, modify, and distribute this software * and its documentation for any purpose and without fee is hereby * granted, provided that the above copyright notice appear in all * copies and that both that the copyright notice and this * permission notice and warranty disclaimer appear in supporting * documentation, and that the name of the author not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * * The author disclaim all warranties with regard to this * software, including all implied warranties of merchantability * and fitness. In no event shall the author be liable for any * special, indirect or consequential damages or any damages * whatsoever resulting from loss of use, data or profits, whether * in an action of contract, negligence or other tortious action, * arising out of or in connection with the use or performance of * this software. */ #include #include /* * Swap values of two integer variables. */ #define swapi(x,y) { int _t = x; x = y; y = _t; } void gpanel_fill_triangle(int color, int x0, int y0, int x1, int y1, int x2, int y2) { int a, b, y, last; // Sort coordinates by Y order (y2 >= y1 >= y0) if (y0 > y1) { swapi(y0, y1); swapi(x0, x1); } if (y1 > y2) { swapi(y2, y1); swapi(x2, x1); } if (y0 > y1) { swapi(y0, y1); swapi(x0, x1); } if (y0 == y2) { // Handle awkward all-on-same-line case as its own thing a = b = x0; if (x1 < a) a = x1; else if (x1 > b) b = x1; if (x2 < a) a = x2; else if (x2 > b) b = x2; gpanel_fill(color, a, y0, b, y0); return; } int dx01 = x1 - x0; int dy01 = y1 - y0; int dx02 = x2 - x0; int dy02 = y2 - y0; int dx12 = x2 - x1; int dy12 = y2 - y1; int sa = 0; int sb = 0; // For upper part of triangle, find scanline crossings for segments // 0-1 and 0-2. If y1=y2 (flat-bottomed triangle), the scanline y1 // is included here (and second loop will be skipped, avoiding a /0 // error there), otherwise scanline y1 is skipped here and handled // in the second loop...which also avoids a /0 error here if y0=y1 // (flat-topped triangle). if (y1 == y2) last = y1; // Include y1 scanline else last = y1-1; // Skip it for (y=y0; y<=last; y++) { a = x0 + sa / dy01; b = x0 + sb / dy02; sa += dx01; sb += dx02; /* longhand: * a = x0 + (x1 - x0) * (y - y0) / (y1 - y0); * b = x0 + (x2 - x0) * (y - y0) / (y2 - y0); */ if (a > b) swapi(a, b); gpanel_fill(color, a, y, b, y); } // For lower part of triangle, find scanline crossings for segments // 0-2 and 1-2. This loop is skipped if y1=y2. sa = dx12 * (y - y1); sb = dx02 * (y - y0); for (; y<=y2; y++) { a = x1 + sa / dy12; b = x0 + sb / dy02; sa += dx12; sb += dx02; /* longhand: * a = x1 + (x2 - x1) * (y - y1) / (y2 - y1); * b = x0 + (x2 - x0) * (y - y0) / (y2 - y0); */ if (a > b) swapi(a, b); gpanel_fill(color, a, y, b, y); } } ================================================ FILE: lib/libgpanel/gpanel.3 ================================================ .\" No copyright (2015) - Serge Vakulenko (serge@vak.ru) .\" .TH GPANEL 3 "June 10, 2023" .UC 6 .SH NAME gpanel_open, gpanel_close, gpanel_clear, gpanel_pixel, gpanel_line, gpanel_rect, gpanel_fill, gpanel_circle, gpanel_image, gpanel_char, gpanel_text, panel_text_width \- graphics panel routines .SH SYNOPSIS .nf .PP .ft B #include .PP .ft B int gpanel_open(const char *devname); .PP .ft B void gpanel_close(void); .PP .ft B void gpanel_clear(int color, int *xsize, int *ysize); .PP .ft B void gpanel_pixel(int color, int x, int y); .PP .ft B void gpanel_line(int color, int x0, int y0, int x1, int y1); .PP .ft B void gpanel_rect(int color, int x0, int y0, int x1, int y1); .PP .ft B void gpanel_fill(int color, int x0, int y0, int x1, int y1); .PP .ft B void gpanel_circle(int color, int x, int y, int radius); .PP .ft B void gpanel_image(int x, int y, int width, int height, const unsigned short *data); .PP .ft B void gpanel_char(const struct gpanel_font_t *font, int color, int background, int x, int y, int sym); .PP .ft B void gpanel_text(const struct gpanel_font_t *font, int color, int background, int x, int y, const char *text); .PP .ft B int gpanel_text_width(const struct gpanel_font_t *font, const char *text, int nchars); .fi .bp .SH DESCRIPTION This library provides a set of routines for access to a graphics panel like TFT LCD or OLED displays. HX8357 display on a Picadillo-35T board is an example of such display. Use cc option .I -lgpanel to link the gpanel library. .PP .IR gpanel_open \- This routine opens a connection to the display driver. The argument to this function is the name of the device, like "/dev/tft0". Negative value is returned in case of error. .PP .IR gpanel_close \- Close a connection to the device. .PP .IR gpanel_clear \- This routine is used to clear the whole screen to a given color, optionally switch the display resolution and orientation, and get the display size in pixels. On input, parameters .I xsize and .I ysize should contain the desired dimensions of the display, or zeros to use the default screen size and orientation. On output, .I xsize and .I ysize are set to the current display size. .PP .IR gpanel_pixel \- Draw a single pixel of a specified color. .PP .IR gpanel_line \- Draw a line. .PP .IR gpanel_rect \- Draw a rectangular frame (not filled). .PP .IR gpanel_fill \- Draw a rectangle filled with specified color. .PP .IR gpanel_circle \- Draw a circle with a given center and radius. .PP .IR gpanel_image \- Draw an arbitrary image: fill a rectangular area with pixel values from a user-supplied data. .PP .IR gpanel_char \- Draw a single character with a specified Unicode encoding. .PP .IR gpanel_text \- Draw a text string in UTF-8 encoding. .PP .IR gpanel_text_width \- Compute a width in pixels for a text string in UTF-8 encoding. .PP .SH EXAMPLE .ft R #include .br #include int main() .br { int xsize, ysize; if (gpanel_open("/dev/tft0") < 0) { printf("Cannot open display\n"); exit(-1); } /* Get screen size */ gpanel_clear(0, &xsize, &ysize); /* Draw a white rectangle of max size */ gpanel_rect(0xffff, 0, 0, xsize-1, ysize-1); return 0; .br } .fi .SH FONTS .ft R struct gpanel_font_t { const char * name; /* font name */ int maxwidth; /* max width in pixels */ unsigned int height; /* height in pixels */ int ascent; /* ascent (baseline) height */ int firstchar; /* first character in bitmap */ int size; /* font size in characters */ const unsigned short *bits; /* 16-bit right-padded bitmap data */ const unsigned short *offset; /* offsets into bitmap data */ const unsigned char *width; /* character widths or 0 if fixed */ int defaultchar; /* default char (not glyph index) */ long bits_size; /* number of words of bits */ .br }; .PP Fonts are specified via a data structure .I struct\ gpanel_font_t , which defines character sizes and glyph images. Font data for some commonly used fonts are available in .I /usr/share/examples/gpanel/fonts directory. A utility .I convbdf can be used to convert XWindows BDF fonts to a struct gpanel_font_t data. When combined with .I otf2bdf utility, this allows to generate font data for any TrueType font, like Verdana or Lucida Sans Unicode. .SH BUGS Data and font pointers in gpanel_image and gpanel_text routines are not checked for validity, and can cause unexpected errors when not correct. .SH FILES .ta \w'/usr/share/examples/gpanel 'u /usr/share/examples/gpanel Examples of using the \fIlibgpanel\fP library. .PP /dev/tft0 Device name for hx8357 TFT display driver. ================================================ FILE: lib/libgpanel/image.c ================================================ /* * Draw a rectangular image. * * Copyright (C) 2015 Serge Vakulenko, * * Permission to use, copy, modify, and distribute this software * and its documentation for any purpose and without fee is hereby * granted, provided that the above copyright notice appear in all * copies and that both that the copyright notice and this * permission notice and warranty disclaimer appear in supporting * documentation, and that the name of the author not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * * The author disclaim all warranties with regard to this * software, including all implied warranties of merchantability * and fitness. In no event shall the author be liable for any * special, indirect or consequential damages or any damages * whatsoever resulting from loss of use, data or profits, whether * in an action of contract, negligence or other tortious action, * arising out of or in connection with the use or performance of * this software. */ #include #include void gpanel_image(int x, int y, int width, int height, const unsigned short *data) { struct gpanel_image_t param; param.x = x; param.y = y; param.width = width; param.height = height; param.image = data; ioctl(_gpanel_fd, GPANEL_IMAGE, ¶m); } ================================================ FILE: lib/libgpanel/line.c ================================================ /* * Draw a line. * * Copyright (C) 2015 Serge Vakulenko, * * Permission to use, copy, modify, and distribute this software * and its documentation for any purpose and without fee is hereby * granted, provided that the above copyright notice appear in all * copies and that both that the copyright notice and this * permission notice and warranty disclaimer appear in supporting * documentation, and that the name of the author not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * * The author disclaim all warranties with regard to this * software, including all implied warranties of merchantability * and fitness. In no event shall the author be liable for any * special, indirect or consequential damages or any damages * whatsoever resulting from loss of use, data or profits, whether * in an action of contract, negligence or other tortious action, * arising out of or in connection with the use or performance of * this software. */ #include #include void gpanel_line(int color, int x0, int y0, int x1, int y1) { struct gpanel_line_t param; param.color = color; param.x0 = x0; param.y0 = y0; param.x1 = x1; param.y1 = y1; ioctl(_gpanel_fd, GPANEL_LINE, ¶m); } ================================================ FILE: lib/libgpanel/open.c ================================================ /* * Device open and close routines. * * Copyright (C) 2015 Serge Vakulenko, * * Permission to use, copy, modify, and distribute this software * and its documentation for any purpose and without fee is hereby * granted, provided that the above copyright notice appear in all * copies and that both that the copyright notice and this * permission notice and warranty disclaimer appear in supporting * documentation, and that the name of the author not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * * The author disclaim all warranties with regard to this * software, including all implied warranties of merchantability * and fitness. In no event shall the author be liable for any * special, indirect or consequential damages or any damages * whatsoever resulting from loss of use, data or profits, whether * in an action of contract, negligence or other tortious action, * arising out of or in connection with the use or performance of * this software. */ #include #include #include int _gpanel_fd = -1; /* * Open a graphics panel device. */ int gpanel_open(const char *devname) { _gpanel_fd = open(devname, O_RDWR); if (_gpanel_fd < 0) return -1; return 0; } /* * Close gpanel device. */ void gpanel_close(void) { if (_gpanel_fd >= 0) { close(_gpanel_fd); _gpanel_fd = -1; } } ================================================ FILE: lib/libgpanel/pixel.c ================================================ /* * Draw a single pixel. * * Copyright (C) 2015 Serge Vakulenko, * * Permission to use, copy, modify, and distribute this software * and its documentation for any purpose and without fee is hereby * granted, provided that the above copyright notice appear in all * copies and that both that the copyright notice and this * permission notice and warranty disclaimer appear in supporting * documentation, and that the name of the author not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * * The author disclaim all warranties with regard to this * software, including all implied warranties of merchantability * and fitness. In no event shall the author be liable for any * special, indirect or consequential damages or any damages * whatsoever resulting from loss of use, data or profits, whether * in an action of contract, negligence or other tortious action, * arising out of or in connection with the use or performance of * this software. */ #include #include void gpanel_pixel(int color, int x, int y) { struct gpanel_pixel_t param; param.color = color; param.x = x; param.y = y; ioctl(_gpanel_fd, GPANEL_PIXEL, ¶m); } ================================================ FILE: lib/libgpanel/rect.c ================================================ /* * Draw a rectangle frame (no fill). * * Copyright (C) 2015 Serge Vakulenko, * * Permission to use, copy, modify, and distribute this software * and its documentation for any purpose and without fee is hereby * granted, provided that the above copyright notice appear in all * copies and that both that the copyright notice and this * permission notice and warranty disclaimer appear in supporting * documentation, and that the name of the author not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * * The author disclaim all warranties with regard to this * software, including all implied warranties of merchantability * and fitness. In no event shall the author be liable for any * special, indirect or consequential damages or any damages * whatsoever resulting from loss of use, data or profits, whether * in an action of contract, negligence or other tortious action, * arising out of or in connection with the use or performance of * this software. */ #include #include void gpanel_rect(int color, int x0, int y0, int x1, int y1) { struct gpanel_rect_t param; param.color = color; param.x0 = x0; param.y0 = y0; param.x1 = x1; param.y1 = y1; ioctl(_gpanel_fd, GPANEL_RECT, ¶m); } ================================================ FILE: lib/libgpanel/text.c ================================================ /* * Draw a string. * * Copyright (C) 2015 Serge Vakulenko, * * Permission to use, copy, modify, and distribute this software * and its documentation for any purpose and without fee is hereby * granted, provided that the above copyright notice appear in all * copies and that both that the copyright notice and this * permission notice and warranty disclaimer appear in supporting * documentation, and that the name of the author not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * * The author disclaim all warranties with regard to this * software, including all implied warranties of merchantability * and fitness. In no event shall the author be liable for any * special, indirect or consequential damages or any damages * whatsoever resulting from loss of use, data or profits, whether * in an action of contract, negligence or other tortious action, * arising out of or in connection with the use or performance of * this software. */ #include #include void gpanel_text(const struct gpanel_font_t *font, int color, int background, int x, int y, const char *text) { struct gpanel_text_t param; param.font = font; param.color = color; param.background = background; param.x = x; param.y = y; param.text = text; ioctl(_gpanel_fd, GPANEL_TEXT, ¶m); } ================================================ FILE: lib/libgpanel/text_width.c ================================================ /* * Compute a string width in pixels. * * Copyright (C) 2015 Serge Vakulenko, * * Permission to use, copy, modify, and distribute this software * and its documentation for any purpose and without fee is hereby * granted, provided that the above copyright notice appear in all * copies and that both that the copyright notice and this * permission notice and warranty disclaimer appear in supporting * documentation, and that the name of the author not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * * The author disclaim all warranties with regard to this * software, including all implied warranties of merchantability * and fitness. In no event shall the author be liable for any * special, indirect or consequential damages or any damages * whatsoever resulting from loss of use, data or profits, whether * in an action of contract, negligence or other tortious action, * arising out of or in connection with the use or performance of * this software. */ #include #include #include /* * Calculate a width of text output. * Handle both fixed and proportional fonts. * TODO: UTF8 decoding. */ int gpanel_text_width(const struct gpanel_font_t *font, const char *text, int nchars) { int width, c; if (! nchars) nchars = strlen (text); if (! font->width) { /* Fixed-width font. */ return nchars * font->maxwidth; } width = 0; while (--nchars >= 0) { c = (unsigned char) *text++; if (c < font->firstchar || c >= font->firstchar + font->size) c = font->defaultchar; width += font->width[c - font->firstchar]; } return width; } ================================================ FILE: lib/libicache/icache.ld ================================================ OUTPUT_FORMAT("elf32-tradlittlemips") OUTPUT_FORMAT("elf32-tradlittlemips") OUTPUT_ARCH(pic32mx) ENTRY(_icstart_) MEMORY { /* 96K internal CPU RAM */ cpu_ram (rwx) : ORIGIN = 0x7F008000, LENGTH = 0x18000 /* 512K, loaded on demand into instruction cache from executable file */ file_rom (rx!w) : ORIGIN = 0x40000000, LENGTH = 0x80000 } SECTIONS { /* Code Sections */ /* !!! fix this ugliness with '.', 'ORIGIN(cpu_ram)' and 'ORIGIN(file_rom)' !!! */ . = ORIGIN(cpu_ram); .ictext ALIGN(4): { *icache?.o(.text .stub .text.* .gnu.linkonce.t.*) . = ALIGN(4); } > cpu_ram .startup : /* contains code */ { KEEP (*(.startup)) } > cpu_ram __icache_tmp__ = .; . = ORIGIN(file_rom); .text ALIGN(64): /* instruction cache uses 32-byte cache lines 32-bytes-aligned */ { _text_begin = .; *(.text .stub .text.* .gnu.linkonce.t.*) KEEP (*(.text.*personality*)) *(.gnu.warning) *(.mips16.fn.*) *(.mips16.call.*) . = ALIGN(64); /* instruction cache uses 32-byte cache lines 32-bytes-aligned */ _text_end = .; } > file_rom = 0 . = __icache_tmp__; /* Various initialization/finalization constructor/destructor sections */ .init : /* contains code, right? */ { KEEP (*crti.o(.init)) KEEP (*crtbegin.o(.init)) KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o *crtn.o ).init)) KEEP (*crtend.o(.init)) KEEP (*crtn.o(.init)) } > cpu_ram .fini : /* contains code, right? */ { KEEP (*(.fini)) } > cpu_ram .preinit_array : /* contains data, right? */ { PROVIDE_HIDDEN (__preinit_array_start = .); KEEP (*(.preinit_array)) PROVIDE_HIDDEN (__preinit_array_end = .); } > cpu_ram .init_array : /* contains data, right? */ { PROVIDE_HIDDEN (__init_array_start = .); KEEP (*(SORT(.init_array.*))) KEEP (*(.init_array)) PROVIDE_HIDDEN (__init_array_end = .); } > cpu_ram .fini_array : /* contains data, right? */ { PROVIDE_HIDDEN (__fini_array_start = .); KEEP (*(SORT(.fini_array.*))) KEEP (*(.fini_array)) PROVIDE_HIDDEN (__fini_array_end = .); } > cpu_ram .ctors : /* contains data */ { /* gcc uses crtbegin.o to find the start of the constructors, so we make sure it is first. Because this is a wildcard, it doesn't matter if the user does not actually link against crtbegin.o; the linker won't look for a file to match a wildcard. The wildcard also means that it doesn't matter which directory crtbegin.o is in. */ KEEP (*crtbegin.o(.ctors)) KEEP (*crtbegin?.o(.ctors)) /* We don't want to include the .ctor section from the crtend.o file until after the sorted ctors. The .ctor section from the crtend file contains the end of ctors marker and it must be last */ KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors)) KEEP (*(SORT(.ctors.*))) KEEP (*(.ctors)) } > cpu_ram .dtors : /* contains data */ { KEEP (*crtbegin.o(.dtors)) KEEP (*crtbegin?.o(.dtors)) KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors)) KEEP (*(SORT(.dtors.*))) KEEP (*(.dtors)) } > cpu_ram .preinit_array : /* contains data, right? */ { KEEP (*(.preinit_array)) } > cpu_ram /* Data Sections */ /* Read-only sections */ /* * Small initialized constant global and static data can be placed in the * .sdata2 section. This is different from .sdata, which contains small * initialized non-constant global and static data. */ .sdata2 ALIGN(4): { *(.sdata2 .sdata2.* .gnu.linkonce.s2.*) . = ALIGN(4); } > cpu_ram /* * Uninitialized constant global and static data (i.e., variables which will * always be zero). Again, this is different from .sbss, which contains * small non-initialized, non-constant global and static data. */ .sbss2 ALIGN(4): { *(.sbss2 .sbss2.* .gnu.linkonce.sb2.*) . = ALIGN(4); } > cpu_ram .dbg_data (NOLOAD): { . += (DEFINED (_DEBUGGER) ? 0x200 : 0x0); } > cpu_ram /* Persistent data */ .persist ALIGN(4): { _persist_begin = .; *(.persist .persist.*) . = ALIGN(4); _persist_end = .; } > cpu_ram /* !!! .rodata moved from code sections !!! */ .rodata ALIGN(4): { *(.rodata .rodata.* .gnu.linkonce.r.*) *(.rodata1) . = ALIGN(4); } > cpu_ram _data_begin = .; .data ALIGN(4): { *(.data .data.* .gnu.linkonce.d.*) KEEP (*(.gnu.linkonce.d.*personality*)) *(.data1) . = ALIGN(4); } > cpu_ram . = .; _gp = ALIGN(16) + 0x7ff0; .got ALIGN(4): { *(.got.plt) *(.got) } > cpu_ram /* * We want the small data sections together, so single-instruction offsets * can access them all, and initialized data all before uninitialized, so * we can shorten the on-disk segment size. */ .sdata ALIGN(4): { _sdata_begin = .; *(.sdata .sdata.* .gnu.linkonce.s.*) _sdata_end = .; } > cpu_ram .lit8 : { *(.lit8) } > cpu_ram .lit4 : { *(.lit4) } > cpu_ram . = ALIGN(4); _data_end = .; _bss_begin = .; .sbss ALIGN(4): { _sbss_begin = .; *(.dynsbss) *(.sbss .sbss.* .gnu.linkonce.sb.*) *(.scommon) . = ALIGN(4); _sbss_end = .; } > cpu_ram .bss ALIGN(4): { *(.dynbss) *(.bss .bss.* .gnu.linkonce.b.*) *(COMMON) /* * Align here to ensure that the .bss section occupies space up to * _end. Align after .bss to ensure correct alignment even if the * .bss section disappears because there are no input sections. */ . = ALIGN(4); } > cpu_ram . = ALIGN(4); _bss_end = .; _end = .; /* The .pdr section belongs in the absolute section */ /DISCARD/ : { *(.pdr) } /* We don't load .reginfo onto the target, so don't locate it * in real memory */ /DISCARD/ : { *(.reginfo) } /* Stabs debugging sections. */ .stab 0 : { *(.stab) } .stabstr 0 : { *(.stabstr) } .stab.excl 0 : { *(.stab.excl) } .stab.exclstr 0 : { *(.stab.exclstr) } .stab.index 0 : { *(.stab.index) } .stab.indexstr 0 : { *(.stab.indexstr) } .comment 0 : { *(.comment) } /* DWARF debug sections. Symbols in the DWARF debugging sections are relative to the beginning of the section so we begin them at 0. */ /* DWARF 1 */ .debug 0 : { *(.debug) } .line 0 : { *(.line) } /* GNU DWARF 1 extensions */ .debug_srcinfo 0 : { *(.debug_srcinfo) } .debug_sfnames 0 : { *(.debug_sfnames) } /* DWARF 1.1 and DWARF 2 */ .debug_aranges 0 : { *(.debug_aranges) } .debug_pubnames 0 : { *(.debug_pubnames) } /* DWARF 2 */ .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) } .debug_abbrev 0 : { *(.debug_abbrev) } /DISCARD/ : { *(.debug_line) } .debug_frame 0 : { *(.debug_frame) } .debug_str 0 : { *(.debug_str) } /DISCARD/ : { *(.debug_loc) } .debug_macinfo 0 : { *(.debug_macinfo) } /* SGI/MIPS DWARF 2 extensions */ .debug_weaknames 0 : { *(.debug_weaknames) } .debug_funcnames 0 : { *(.debug_funcnames) } .debug_typenames 0 : { *(.debug_typenames) } .debug_varnames 0 : { *(.debug_varnames) } /* DWARF 3 */ .debug_pubtypes 0 : { *(.debug_pubtypes) } .debug_ranges 0 : { *(.debug_ranges) } .gnu.attributes 0 : { KEEP (*(.gnu.attributes)) } .gptab.sdata : { *(.gptab.data) *(.gptab.sdata) } .gptab.sbss : { *(.gptab.bss) *(.gptab.sbss) } .mdebug.abi32 : { KEEP(*(.mdebug.abi32)) } .mdebug.abiN32 : { KEEP(*(.mdebug.abiN32)) } .mdebug.abi64 : { KEEP(*(.mdebug.abi64)) } .mdebug.abiO64 : { KEEP(*(.mdebug.abiO64)) } .mdebug.eabi32 : { KEEP(*(.mdebug.eabi32)) } .mdebug.eabi64 : { KEEP(*(.mdebug.eabi64)) } /DISCARD/ : { *(.MIPS.abiflags) } /DISCARD/ : { *(.rel.dyn) } /DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) } } ================================================ FILE: lib/libicache/icachec.c ================================================ /* Copyright (c) 2013, Alexey Frunze All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. The views and conclusions contained in the software and documentation are those of the authors and should not be interpreted as representing official policies, either expressed or implied, of the FreeBSD Project. */ /*****************************************************************************/ /* */ /* MIPS icache */ /* */ /*****************************************************************************/ // the For best performance, this file should be compiled using gcc's -O3 option. // Define this macro to enable statistics //#define STATS // Define this macro to do a more rigorous check // for invalid/unsupported instructions // (at the expense of performance, of course). //#define CHECK_INVALID_INSTR #define STATIC static // Rename non-static functions and variables // to prevent name collisions with other code // when compiling together with it. #define DoSysCall _icDoSysCall_ #define main _icmain_ #define Regs _icRegs_ #define HostRegs _icHostRegs_ typedef unsigned char uchar, uint8; typedef signed char schar, int8; typedef unsigned short ushort, uint16; typedef short int16; typedef unsigned uint, uint32, size_t; typedef int int32, ssize_t, off_t; typedef unsigned long ulong; typedef long long longlong, int64; typedef unsigned long long ulonglong, uint64; #define C_ASSERT(expr) extern char CAssertExtern[(expr)?1:-1] //C_ASSERT(CHAR_BIT == 8); C_ASSERT(sizeof(int) == 4); C_ASSERT(sizeof(long) == 4); C_ASSERT(sizeof(longlong) == 8); C_ASSERT(sizeof(void*) == 4); C_ASSERT(sizeof(void(*)()) == 4); C_ASSERT(sizeof(size_t) == 4); C_ASSERT(sizeof(ssize_t) == 4); C_ASSERT(sizeof(off_t) == 4); C_ASSERT(sizeof(uint16) == 2); C_ASSERT(sizeof(uint32) == 4); C_ASSERT(sizeof(uint64) == 8); #pragma pack(push,1) typedef struct { uint32 a_magic; /* magic number */ #define OMAGIC 0407 /* old impure format */ uint32 a_text; /* size of text segment */ uint32 a_data; /* size of initialized data */ uint32 a_bss; /* size of uninitialized data */ uint32 a_reltext; /* size of text relocation info */ uint32 a_reldata; /* size of data relocation info */ uint32 a_syms; /* size of symbol table */ uint32 a_entry; /* entry point */ } AoutHdr; #pragma pack(pop) C_ASSERT(sizeof(AoutHdr) == 32); static inline void* memset(void* dst, int ch, size_t size) { unsigned char *p = dst; while (size--) *p++ = ch; return dst; } // flags for RetroBSD's open(): #define O_RDONLY 0x0000 #define O_WRONLY 0x0001 #define O_RDWR 0x0002 #define O_APPEND 0x0008 #define O_CREAT 0x0200 #define O_TRUNC 0x0400 #define O_TEXT 0x0000 #define O_BINARY 0x0000 // flags for RetroBSD's lseek(): #define SEEK_SET 0 #define SEEK_CUR 1 #define SEEK_END 2 static void exit(int code) { asm volatile ("move $4, %0\n" "syscall 1" // SYS_exit : : "r" (code) : "$2", "$4"); } static int open(const char* name, int oflags) { int handle; asm volatile ("move $4, %1\n" "move $5, %2\n" "syscall 5\n" // SYS_open "nop\n" "nop\n" "move %0, $2\n" : "=r" (handle) : "r" (name), "r" (oflags) : "$2", "$4", "$5"); return handle; } static ssize_t read(int handle, void* buf, size_t size) { ssize_t sz; asm volatile ("move $4, %1\n" "move $5, %2\n" "move $6, %3\n" "syscall 3\n" // SYS_read "nop\n" "nop\n" "move %0, $2\n" : "=r" (sz) : "r" (handle), "r" (buf), "r" (size) : "$2", "$4", "$5", "$6", "memory"); return sz; } static ssize_t write(int handle, const void* buf, size_t size) { ssize_t sz; asm volatile ("move $4, %1\n" "move $5, %2\n" "move $6, %3\n" "syscall 4\n" // SYS_write "nop\n" "nop\n" "move %0, $2\n" : "=r" (sz) : "r" (handle), "r" (buf), "r" (size) : "$2", "$4", "$5", "$6", "memory"); // WTF? I shouldn't need "memory" here !!! return sz; } static off_t lseek(int handle, off_t pos, int whence) { off_t p; asm volatile ("move $4, %1\n" "move $5, %2\n" "move $6, %3\n" "syscall 19\n" // SYS_lseek "nop\n" "nop\n" "move %0, $2\n" : "=r" (p) : "r" (handle), "r" (pos), "r" (whence) : "$2", "$4", "$5", "$6"); return p; } #if 0 // close() is unused. We rely on the system to close // all files/handles on process termination. static int close(int handle) { int err; asm volatile ("move $4, %1\n" "syscall 6\n" // SYS_close "nop\n" "nop\n" "move %0, $2\n" : "=r" (err) : "r" (handle) : "$2", "$4"); return err; } #endif static void printchr(int ch) { char c = ch; write(1, &c, 1); } static void printstr(const char* s) { while (*s != '\0') write(1, s++, 1); } #ifdef STATS static void printdec(int n) { unsigned un = n; if (n < 0) { un = -un; printchr('-'); } if (un >= 10) printdec(un / 10); printchr('0' + un % 10); } static char* Bin64ToDec(uint64 n) { // log10(x) = log2(x) / log2(10) ~= log2(x) / 3.322 static char s[64 / 3 + 1 + 1]; char* p = s; int i; memset(s, '0', sizeof s - 1); s[sizeof s - 1] = '\0'; for (i = 0; i < 64; i++) { int j, carry; // Extract the most significant bit of n into carry carry = (n >> 63) & 1; // Shift n left n <<= 1; // Add s[] to itself in decimal, doubling it, // and add carry to it for (j = sizeof s - 2; j >= 0; j--) { s[j] += s[j] - '0' + carry; carry = s[j] > '9'; if (carry) s[j] -= 10; } } while ((*p == '0') && (p < &s[sizeof s - 2])) p++; return p; } static void printdec64(int64 n) { uint64 un = n; if (n < 0) { un = -un; printchr('-'); } printstr(Bin64ToDec(un)); } #endif static void printhex(unsigned n) { int i; for (i = 0; i < 8; i++) printchr("0123456789ABCDEF"[(n >> 28) & 15]), n <<= 4; } #ifdef STATS uint64 EmulateCnt = 0; uint64 CacheHits = 0; uint64 CacheHits2 = 0; uint64 CacheMisses = 0; #endif #define REG_GP 28 #define REG_SP 29 #define REG_RA 31 #define REG_LO 32 #define REG_HI 33 #define REG_PC 34 uint32 Regs[32 + 3]; uint32 HostRegs[32 + 3]; #define CACHE_BYTES_PER_INSTR 4 #ifndef CACHE_INSTRS_PER_ENTRY #define CACHE_INSTRS_PER_ENTRY 8 #endif #define CACHE_BYTES_PER_ENTRY (CACHE_BYTES_PER_INSTR * CACHE_INSTRS_PER_ENTRY) #ifndef CACHE_ENTRIES_PER_WAY #define CACHE_ENTRIES_PER_WAY 64 #endif #ifndef CACHE_WAYS #define CACHE_WAYS 4 #endif #define CACHE_ENTRIES_TOTAL (CACHE_ENTRIES_PER_WAY * CACHE_WAYS) #define CACHE_SIZE (CACHE_BYTES_PER_ENTRY * CACHE_ENTRIES_TOTAL) STATIC uint32 Cache[CACHE_ENTRIES_PER_WAY][CACHE_WAYS][CACHE_INSTRS_PER_ENTRY]; STATIC uint32 CacheTagAndValid[CACHE_ENTRIES_PER_WAY][CACHE_WAYS]; STATIC int CachedCnt = 0; STATIC uint32* CachedInstr = &Cache[0][0][0]; extern void _icstart_(int argc, char** argv, char** env); STATIC void Emulate(void); STATIC int ExeHandle = -1; STATIC uint32 ExeOffs = 0; int main(int argc, char** argv, char** env) { AoutHdr aoutHdr; if ((ExeHandle = open(argv[0], O_BINARY | O_RDONLY)) < 0) { printstr("Can't open "); printstr(argv[0]); printchr('\n'); exit(-1); } if (read(ExeHandle, &aoutHdr, sizeof aoutHdr) != sizeof aoutHdr) { printstr("Can't read "); printstr(argv[0]); printchr('\n'); exit(-1); } if (aoutHdr.a_magic != OMAGIC) { printstr(argv[0]); printstr(" is not an a.out file\n"); exit(-1); } ExeOffs = sizeof aoutHdr + aoutHdr.a_text + aoutHdr.a_data; memset(CacheTagAndValid, 0xFF, sizeof CacheTagAndValid); // invalidate cache Regs[4] = argc; Regs[5] = (uint32)argv; Regs[6] = (uint32)env; // Regs[REG_SP] = ...; // _icstart() has done this // Regs[REG_GP] = (uint32)&_gp; // _start() will do this if needed Regs[REG_PC] = (uint32)&_icstart_; Emulate(); // isn't supposed to return... exit(-1); // ... but let's exit explicitly just in case return -1; } extern const char _text_begin; extern const char _text_end; STATIC inline uint32 FetchProgramWord(uint32 Addr) { uint32 ofs, idx, tag, way; if (CachedCnt > 0) { CachedCnt--; // Cache hit #ifdef STATS CacheHits++; CacheHits2++; #endif return *++CachedInstr; } if (Addr < (uint32)&_text_begin || Addr >= (uint32)&_text_end) { CachedCnt = 0; CachedInstr = (uint32*)Addr; return *CachedInstr; } ofs = Addr % CACHE_BYTES_PER_ENTRY / CACHE_BYTES_PER_INSTR; idx = Addr / CACHE_BYTES_PER_ENTRY % CACHE_ENTRIES_PER_WAY; tag = Addr / CACHE_BYTES_PER_ENTRY / CACHE_ENTRIES_PER_WAY; for (way = 0; way < CACHE_WAYS; way++) { if (CacheTagAndValid[idx][way] == tag) { // Cache hit #ifdef STATS CacheHits++; #endif CachedCnt = CACHE_INSTRS_PER_ENTRY - 1 - ofs; CachedInstr = &Cache[idx][way][ofs]; return *CachedInstr; } } // Cache miss #ifdef STATS CacheMisses++; #endif for (way = 0; way < CACHE_WAYS; way++) { if (CacheTagAndValid[idx][way] & 0x80000000) { // Use an invalid entry goto lreuse; } } // Reuse a valid entry (need to choose one for eviction and refill, // preferably not penalizing the same entry over and over again) { static uint32 w = CACHE_WAYS - 1; w = (w + 1) % CACHE_WAYS; // pseudo-LRU way = w; } lreuse: if (lseek(ExeHandle, ExeOffs + (Addr / CACHE_BYTES_PER_ENTRY * CACHE_BYTES_PER_ENTRY - (uint32)&_text_begin), SEEK_SET) < 0 || read(ExeHandle, Cache[idx][way], CACHE_BYTES_PER_ENTRY) != CACHE_BYTES_PER_ENTRY) { printstr("\nCan't read into the cache from the executable file\n"); exit(-1); } CacheTagAndValid[idx][way] = tag; CachedCnt = CACHE_INSTRS_PER_ENTRY - 1 - ofs; CachedInstr = &Cache[idx][way][ofs]; return *CachedInstr; } extern int DoSysCall(uint32 instr); #ifdef STATS STATIC int DoSysCall2(uint32 instr) { uint32 code = (instr >> 6) & 0xFFFFF; // intercept exit() syscall if ((code == 0 && Regs[2] == 10) || // SPIM's exit() (code == /*SYS_exit*/1)) // RetroBSD's exit() { uint32 idx, way, used = 0; for (idx = 0; idx < CACHE_ENTRIES_PER_WAY; idx++) for (way = 0; way < CACHE_WAYS; way++) used += CacheTagAndValid[idx][way] < 0x80000000; printstr("\n"); printdec64(EmulateCnt); printstr(" instruction(s) emulated\n"); printdec((int)used); printchr('/'); printdec(CACHE_ENTRIES_TOTAL); printstr(" cache entries used\n"); printdec64(CacheHits); printchr('('); printdec64(CacheHits2); printstr(")/"); printdec64(CacheMisses); printstr(" cache hits(hits2)/misses\n"); } return DoSysCall(instr); } #undef DoSysCall #define DoSysCall DoSysCall2 #endif static inline uint8 ReadByte(uint32 Addr) { return *(uint8*)Addr; } static inline void WriteByte(uint32 Addr, uint8 Val) { *(uint8*)Addr = Val; } static inline uint16 ReadHalfWord(uint32 Addr) { return *(uint16*)Addr; } static inline void WriteHalfWord(uint32 Addr, uint16 Val) { *(uint16*)Addr = Val; } static inline uint32 ReadWord(uint32 Addr) { return *(uint32*)Addr; } static inline void WriteWord(uint32 Addr, uint32 Val) { *(uint32*)Addr = Val; } /* Supported instructions: add, addi, addiu, addu, and, andi, bal, beq, beql, bgez, bgezal, bgezall, bgezl, bgtz, bgtzl, blez, blezl, bltz, bltzal, bltzall, bltzl, bne, bnel, break, clo, clz, div, divu, ext, ins, j, jal, jalr, jr, lb, lbu, lh, lhu, lui, lw, lwl, lwr, madd, maddu, mfhi, mflo, movn, movz, msub, msubu, mthi, mtlo, mul, mult, multu, nop, nor, or, ori, rotr, rotrv, sb, seb, seh, sh, sll, sllv, slt, slti, sltiu, sltu, sra, srav, srl, srlv, sub, subu, sw, swl, swlr, syscall, teq, teqi, tge, tgei, tgeiu, tgeu, tlt, tlti, tltiu, tltu, tne, tnei, wsbh, xor, xori Unsupported instructions: bc2f, bc2fl, bc2t, bc2tl, cache, cfc2, cop0, cop2, ctc2, deret, di, ehb, ei, eret, jalr.hb, jr.hb, ll, lwc2, mfc0, mfc2, mtc0, mtc2, mthc2, pref, rdhwr, rdpgpr, sc, sdbbp, ssnop, swc2, sync, synci, wait, wrpgpr */ STATIC void DoBreak(uint32 instr); STATIC void DoTrap(uint32 instr); STATIC void DoOverflow(void); STATIC void DoInvalidInstruction(uint32 instr); STATIC uint32 CountLeadingZeroes(uint32 n) { #if 0 uint32 c = 0; if (n == 0) return 32; while (n < 0x80000000) n <<= 1, c++; #else uint32 c; asm volatile("clz %0, %1" : "=r" (c) : "r" (n)); #endif return c; } STATIC uint32 CountLeadingOnes(uint32 n) { #if 0 uint32 c = 0; while (n >= 0x80000000) n <<= 1, c++; #else uint32 c; asm volatile("clo %0, %1" : "=r" (c) : "r" (n)); #endif return c; } STATIC uint32 ShiftRightArithm(uint32 n, uint32 c) { #if 0 uint32 s = -(n >> 31); n >>= c; n |= s << (31 - c) << 1; return n; #else uint32 nn; asm volatile("srav %0, %1, %2" : "=r" (nn) : "r" (n), "r" (c)); return nn; #endif } STATIC uint32 RotateRight(uint32 n, uint32 c) { #if 0 return (n >> c) | (n << (31 - c) << 1); #else uint32 nn; asm volatile("rotrv %0, %1, %2" : "=r" (nn) : "r" (n), "r" (c)); return nn; #endif } STATIC void Emulate(void) { int delaySlot = 0; uint32 postDelaySlotPc = 0; uint32 instr = 0; for (;;) { const uint32 pc = Regs[REG_PC]; uint32 nextPc = pc + 4; /*const uint32*/ instr = FetchProgramWord(pc); #if 0 const uint32 op = instr >> 26; const uint32 r1 = (instr >> 21) & 0x1F; const uint32 r2 = (instr >> 16) & 0x1F; const uint32 r3 = (instr >> 11) & 0x1F; const uint32 shft = (instr >> 6) & 0x1F; const uint32 fxn = instr & 0x3F; const uint32 imm16 = instr & 0xFFFF; const uint32 simm16 = (int16)imm16; const uint32 jtgt = instr & 0x3FFFFFF; #else #define op (instr >> 26) #define r1 ((instr >> 21) & 0x1F) #define r2 ((instr >> 16) & 0x1F) #define r3 ((instr >> 11) & 0x1F) #define shft ((instr >> 6) & 0x1F) #define fxn (instr & 0x3F) #define imm16 (instr & 0xFFFF) #define simm16 ((int16)imm16) #define jtgt (instr & 0x3FFFFFF) #endif switch (op) { case 0: switch (fxn) { case 0: #ifdef CHECK_INVALID_INSTR if (r1) goto lInvalidInstruction; #endif Regs[r3] = Regs[r2] << shft; break; // sll d,w,shft case 2: switch (r1) { case 0: Regs[r3] = Regs[r2] >> shft; break; // srl d,w,shft case 1: Regs[r3] = RotateRight(Regs[r2], shft); break; // rotr d,w,shft default: goto lInvalidInstruction; } break; case 3: #ifdef CHECK_INVALID_INSTR if (r1) goto lInvalidInstruction; #endif Regs[r3] = ShiftRightArithm(Regs[r2], shft); break; // sra d,w,shft case 4: #ifdef CHECK_INVALID_INSTR if (shft) goto lInvalidInstruction; #endif Regs[r3] = Regs[r2] << (Regs[r1] & 31); break; // sllv d,w,s case 6: switch (shft) { case 0: Regs[r3] = Regs[r2] >> (Regs[r1] & 31); break; // srlv d,w,s case 1: Regs[r3] = RotateRight(Regs[r2], Regs[r1] & 31); break; // rotrv d,w,s default: goto lInvalidInstruction; } break; case 7: #ifdef CHECK_INVALID_INSTR if (shft) goto lInvalidInstruction; #endif Regs[r3] = ShiftRightArithm(Regs[r2], Regs[r1] & 31); break; // srav d,w,s case 8: #ifdef CHECK_INVALID_INSTR if (r2 | r3 | shft) goto lInvalidInstruction; #endif nextPc = Regs[r1]; delaySlot = 1; break; // jr s case 9: #ifdef CHECK_INVALID_INSTR if (r2 | shft) goto lInvalidInstruction; #endif Regs[r3] = nextPc + 4; nextPc = Regs[r1]; delaySlot = 1; break; // jalr [d,] s case 10: #ifdef CHECK_INVALID_INSTR if (shft) goto lInvalidInstruction; #endif if (Regs[r2] == 0) Regs[r3] = Regs[r1]; break; // movz d,s,t case 11: #ifdef CHECK_INVALID_INSTR if (shft) goto lInvalidInstruction; #endif if (Regs[r2]) Regs[r3] = Regs[r1]; break; // movn d,s,t case 12: { // RetroBSD may advance PC on returning from a syscall handler, // skipping 2 instructions that follow the syscall instruction. // Those 2 instructions typically set C's errno variable and // are either executed on error or skipped on success. // Account for this peculiarity. uint32 skip = DoSysCall(instr); nextPc += skip * 4; CachedCnt -= skip; CachedInstr += skip; } break; // syscall code case 13: goto lBreak; break; // break code case 16: #ifdef CHECK_INVALID_INSTR if (r1 | r2 | shft) goto lInvalidInstruction; #endif Regs[r3] = Regs[REG_HI]; break; // mfhi d case 17: #ifdef CHECK_INVALID_INSTR if (r2 | r3 | shft) goto lInvalidInstruction; #endif Regs[REG_HI] = Regs[r1]; break; // mthi s case 18: #ifdef CHECK_INVALID_INSTR if (r1 | r2 | shft) goto lInvalidInstruction; #endif Regs[r3] = Regs[REG_LO]; break; // mflo d case 19: #ifdef CHECK_INVALID_INSTR if (r2 | r3 | shft) goto lInvalidInstruction; #endif Regs[REG_LO] = Regs[r1]; break; // mtlo s case 24: #ifdef CHECK_INVALID_INSTR if (r3 | shft) goto lInvalidInstruction; #endif { int64 p = (int64)(int32)Regs[r1] * (int32)Regs[r2]; Regs[REG_LO] = (uint32)p; Regs[REG_HI] = (uint32)(p >> 32); } break; // mult s,t case 25: #ifdef CHECK_INVALID_INSTR if (r3 | shft) goto lInvalidInstruction; #endif { uint64 p = (uint64)Regs[r1] * Regs[r2]; Regs[REG_LO] = (uint32)p; Regs[REG_HI] = (uint32)(p >> 32); } break; // multu s,t case 26: #ifdef CHECK_INVALID_INSTR if (r3 | shft) goto lInvalidInstruction; #endif if (!(Regs[r2] == 0 || (Regs[r1] == 0x80000000 && Regs[r2] == 0xFFFFFFFF))) Regs[REG_LO] = (int32)Regs[r1] / (int32)Regs[r2], Regs[REG_HI] = (int32)Regs[r1] % (int32)Regs[r2]; break; // div s,t case 27: #ifdef CHECK_INVALID_INSTR if (r3 | shft) goto lInvalidInstruction; #endif if (Regs[r2]) Regs[REG_LO] = Regs[r1] / Regs[r2], Regs[REG_HI] = Regs[r1] % Regs[r2]; break; // divu s,t case 32: #ifdef CHECK_INVALID_INSTR if (shft) goto lInvalidInstruction; #endif { uint32 sum = Regs[r1] + Regs[r2]; if (((Regs[r1] ^ Regs[r2] ^ 0x80000000) & 0x80000000) && ((sum ^ Regs[r1]) & 0x80000000)) goto lOverflow; Regs[r3] = sum; } break; // add d,s,t case 33: #ifdef CHECK_INVALID_INSTR if (shft) goto lInvalidInstruction; #endif Regs[r3] = Regs[r1] + Regs[r2]; break; // addu d,s,t case 34: #ifdef CHECK_INVALID_INSTR if (shft) goto lInvalidInstruction; #endif { uint32 diff = Regs[r1] - Regs[r2]; if (((Regs[r1] ^ Regs[r2]) & 0x80000000) && ((diff ^ Regs[r1]) & 0x80000000)) goto lOverflow; Regs[r3] = diff; } break; // sub d,s,t case 35: #ifdef CHECK_INVALID_INSTR if (shft) goto lInvalidInstruction; #endif Regs[r3] = Regs[r1] - Regs[r2]; break; // subu d,s,t case 36: #ifdef CHECK_INVALID_INSTR if (shft) goto lInvalidInstruction; #endif Regs[r3] = Regs[r1] & Regs[r2]; break; // and d,s,t case 37: #ifdef CHECK_INVALID_INSTR if (shft) goto lInvalidInstruction; #endif Regs[r3] = Regs[r1] | Regs[r2]; break; // or d,s,t case 38: #ifdef CHECK_INVALID_INSTR if (shft) goto lInvalidInstruction; #endif Regs[r3] = Regs[r1] ^ Regs[r2]; break; // xor d,s,t case 39: #ifdef CHECK_INVALID_INSTR if (shft) goto lInvalidInstruction; #endif Regs[r3] = ~(Regs[r1] | Regs[r2]); break; // nor d,s,t case 42: #ifdef CHECK_INVALID_INSTR if (shft) goto lInvalidInstruction; #endif Regs[r3] = (int32)Regs[r1] < (int32)Regs[r2]; break; // slt d,s,t case 43: #ifdef CHECK_INVALID_INSTR if (shft) goto lInvalidInstruction; #endif Regs[r3] = Regs[r1] < Regs[r2]; break; // sltu d,s,t case 48: if ((int32)Regs[r1] >= (int32)Regs[r2]) goto lTrap; break; // tge s,t case 49: if (Regs[r1] >= Regs[r2]) goto lTrap; break; // tgeu s,t case 50: if ((int32)Regs[r1] < (int32)Regs[r2]) goto lTrap; break; // tlt s,t case 51: if (Regs[r1] < Regs[r2]) goto lTrap; break; // tltu s,t case 52: if (Regs[r1] == Regs[r2]) goto lTrap; break; // teq s,t case 53: if (Regs[r1] != Regs[r2]) goto lTrap; break; // tne s,t default: goto lInvalidInstruction; } break; case 1: switch (r2) { case 0: if ((int32)Regs[r1] < 0) nextPc += simm16 << 2, delaySlot = 1; break; // bltz s,p case 1: if ((int32)Regs[r1] >= 0) nextPc += simm16 << 2, delaySlot = 1; break; // bgez s,p case 2: if ((int32)Regs[r1] < 0) nextPc += simm16 << 2, delaySlot = 1; else nextPc += 4, CachedCnt--, ++CachedInstr; break; // bltzl s,p case 3: if ((int32)Regs[r1] >= 0) nextPc += simm16 << 2, delaySlot = 1; else nextPc += 4, CachedCnt--, ++CachedInstr; break; // bgezl s,p case 8: if ((int32)Regs[r1] >= (int32)simm16) goto lTrap; break; // tgei s,j case 9: if (Regs[r1] >= (uint32)simm16) goto lTrap; break; // tgeiu s,j case 10: if ((int32)Regs[r1] < (int32)simm16) goto lTrap; break; // tlti s,j case 11: if (Regs[r1] < (uint32)simm16) goto lTrap; break; // tltiu s,j case 12: if (Regs[r1] == (uint32)simm16) goto lTrap; break; // teqi s,j case 14: if (Regs[r1] != (uint32)simm16) goto lTrap; break; // tnei s,j case 16: Regs[REG_RA] = nextPc + 4; if ((int32)Regs[r1] < 0) nextPc += simm16 << 2, delaySlot = 1; break; // bltzal s,p case 17: Regs[REG_RA] = nextPc + 4; if ((int32)Regs[r1] >= 0) nextPc += simm16 << 2, delaySlot = 1; break; // bgezal s,p case 18: Regs[REG_RA] = nextPc + 4; if ((int32)Regs[r1] < 0) nextPc += simm16 << 2, delaySlot = 1; else nextPc += 4, CachedCnt--, ++CachedInstr; break; // bltzall s,p case 19: Regs[REG_RA] = nextPc + 4; if ((int32)Regs[r1] >= 0) nextPc += simm16 << 2, delaySlot = 1; else nextPc += 4, CachedCnt--, ++CachedInstr; break; // bgezall s,p default: goto lInvalidInstruction; } break; case 2: nextPc = (pc & 0xF0000000) | (jtgt << 2); delaySlot = 1; break; // j target case 3: Regs[REG_RA] = nextPc + 4; nextPc = (pc & 0xF0000000) | (jtgt << 2); delaySlot = 1; break; // jal target case 4: if (Regs[r1] == Regs[r2]) nextPc += simm16 << 2, delaySlot = 1; break; // beq s,t,p case 5: if (Regs[r1] != Regs[r2]) nextPc += simm16 << 2, delaySlot = 1; break; // bne s,t,p case 6: #ifdef CHECK_INVALID_INSTR if (r2) goto lInvalidInstruction; #endif if ((int32)Regs[r1] <= 0) nextPc += simm16 << 2, delaySlot = 1; break; // blez s,p case 7: #ifdef CHECK_INVALID_INSTR if (r2) goto lInvalidInstruction; #endif if ((int32)Regs[r1] > 0) nextPc += simm16 << 2, delaySlot = 1; break; // bgtz s,p case 8: { uint32 sum = Regs[r1] + simm16; if (((Regs[r1] ^ simm16 ^ 0x80000000) & 0x80000000) && ((sum ^ Regs[r1]) & 0x80000000)) goto lOverflow; Regs[r2] = sum; } break; // addi d,s,const case 9: Regs[r2] = Regs[r1] + simm16; break; // addiu d,s,const case 10: Regs[r2] = (int32)Regs[r1] < (int32)simm16; break; // slti d,s,const case 11: Regs[r2] = Regs[r1] < (uint32)simm16; break; // sltiu d,s,const case 12: Regs[r2] = Regs[r1] & imm16; break; // andi d,s,const case 13: Regs[r2] = Regs[r1] | imm16; break; // ori d,s,const case 14: Regs[r2] = Regs[r1] ^ imm16; break; // xori d,s,const case 15: #ifdef CHECK_INVALID_INSTR if (r1) goto lInvalidInstruction; #endif Regs[r2] = imm16 << 16; break; // lui d,const case 20: if (Regs[r1] == Regs[r2]) nextPc += simm16 << 2, delaySlot = 1; else nextPc += 4, CachedCnt--, ++CachedInstr; break; // beql s,t,p case 21: if (Regs[r1] != Regs[r2]) nextPc += simm16 << 2, delaySlot = 1; else nextPc += 4, CachedCnt--, ++CachedInstr; break; // bnel s,t,p case 22: #ifdef CHECK_INVALID_INSTR if (r2) goto lInvalidInstruction; #endif if ((int32)Regs[r1] <= 0) nextPc += simm16 << 2, delaySlot = 1; else nextPc += 4, CachedCnt--, ++CachedInstr; break; // blezl s,p case 23: #ifdef CHECK_INVALID_INSTR if (r2) goto lInvalidInstruction; #endif if ((int32)Regs[r1] > 0) nextPc += simm16 << 2, delaySlot = 1; else nextPc += 4, CachedCnt--, ++CachedInstr; break; // bgtzl s,p case 28: #ifdef CHECK_INVALID_INSTR if (shft) goto lInvalidInstruction; #endif switch (fxn) { case 0: #ifdef CHECK_INVALID_INSTR if (r3) goto lInvalidInstruction; #endif { int64 p = (int64)(int32)Regs[r1] * (int32)Regs[r2]; if (Regs[REG_LO] > 0xFFFFFFFF - (uint32)p) Regs[REG_HI]++; Regs[REG_LO] += (uint32)p; Regs[REG_HI] += (uint32)(p >> 32); } break; // madd s,t case 1: #ifdef CHECK_INVALID_INSTR if (r3) goto lInvalidInstruction; #endif { uint64 p = (uint64)Regs[r1] * Regs[r2]; if (Regs[REG_LO] > 0xFFFFFFFF - (uint32)p) Regs[REG_HI]++; Regs[REG_LO] += (uint32)p; Regs[REG_HI] += (uint32)(p >> 32); } break; // maddu s,t case 2: Regs[r3] = Regs[r1] * Regs[r2]; break; // mul d,s,t case 4: #ifdef CHECK_INVALID_INSTR if (r3) goto lInvalidInstruction; #endif { int64 p = (int64)(int32)Regs[r1] * (int32)Regs[r2]; if (Regs[REG_LO] < (uint32)p) Regs[REG_HI]--; Regs[REG_LO] -= (uint32)p; Regs[REG_HI] -= (uint32)(p >> 32); } break; // msub s,t case 5: #ifdef CHECK_INVALID_INSTR if (r3) goto lInvalidInstruction; #endif { uint64 p = (uint64)Regs[r1] * Regs[r2]; if (Regs[REG_LO] < (uint32)p) Regs[REG_HI]--; Regs[REG_LO] -= (uint32)p; Regs[REG_HI] -= (uint32)(p >> 32); } break; // msubu s,t case 32: #ifdef CHECK_INVALID_INSTR if (r1 != r2) goto lInvalidInstruction; #endif Regs[r3] = CountLeadingZeroes(Regs[r2]); break; // clz d,s case 33: #ifdef CHECK_INVALID_INSTR if (r1 != r2) goto lInvalidInstruction; #endif Regs[r3] = CountLeadingOnes(Regs[r2]); break; // clo d,s default: goto lInvalidInstruction; } break; case 31: switch (fxn) { case 0: if (shft + r3 <= 31) { uint size = r3 + 1; uint32 mask = (0xFFFFFFFF >> (32 - size)) << shft; Regs[r2] = (Regs[r1] & mask) >> shft; } break; // ext t,s,pos,sz case 4: if (r3 >= shft) { uint size = r3 - shft + 1; uint32 mask = (0xFFFFFFFF >> (32 - size)) << shft; Regs[r2] = (Regs[r2] & ~mask) | ((Regs[r1] << shft) & mask); } break; // ins t,s,pos,sz case 32: #ifdef CHECK_INVALID_INSTR if (r1) goto lInvalidInstruction; #endif switch (shft) { case 2: Regs[r3] = ((Regs[r2] & 0x00FF) << 8) | ((Regs[r2] & 0xFF00) >> 8) | ((Regs[r2] & 0x00FF0000) << 8) | ((Regs[r2] & 0xFF000000) >> 8); break; // wsbh d,t case 16: Regs[r3] = (int8)Regs[r2]; break; // seb d,t case 24: Regs[r3] = (int16)Regs[r2]; break; // seh d,t default: goto lInvalidInstruction; } break; default: goto lInvalidInstruction; } break; case 32: Regs[r2] = (int8)ReadByte(Regs[r1] + simm16); break; // lb t,o(b) case 33: Regs[r2] = (int16)ReadHalfWord(Regs[r1] + simm16); break; // lh t,o(b) case 34: { uint32 v = ReadByte(Regs[r1] + simm16); v = (v << 8) | ReadByte(Regs[r1] + simm16 - 1); Regs[r2] = (Regs[r2] & 0xFFFF) | (v << 16); } break; // lwl t,o(b) case 35: Regs[r2] = ReadWord(Regs[r1] + simm16); break; // lw t,o(b) case 36: Regs[r2] = ReadByte(Regs[r1] + simm16); break; // lbu t,o(b) case 37: Regs[r2] = ReadHalfWord(Regs[r1] + simm16); break; // lhu t,o(b) case 38: { uint32 v = ReadByte(Regs[r1] + simm16); v |= (uint32)ReadByte(Regs[r1] + simm16 + 1) << 8; Regs[r2] = (Regs[r2] & 0xFFFF0000) | v; } break; // lwr t,o(b) case 40: WriteByte(Regs[r1] + simm16, (uint8)Regs[r2]); break; // sb t,o(b) case 41: WriteHalfWord(Regs[r1] + simm16, (uint16)Regs[r2]); break; // sh t,o(b) case 42: WriteByte(Regs[r1] + simm16, (uint8)(Regs[r2] >> 24)); WriteByte(Regs[r1] + simm16 - 1, (uint8)(Regs[r2] >> 16)); break; // swl t,o(b) case 43: WriteWord(Regs[r1] + simm16, Regs[r2]); break; // sw t,o(b) case 46: WriteByte(Regs[r1] + simm16, (uint8)Regs[r2]); WriteByte(Regs[r1] + simm16 + 1, (uint8)(Regs[r2] >> 8)); break; // swr t,o(b) default: goto lInvalidInstruction; } Regs[0] = 0; Regs[REG_PC] = nextPc; if (delaySlot) { if (delaySlot == 1) { postDelaySlotPc = nextPc; Regs[REG_PC] = pc + 4; delaySlot = 2; } else { Regs[REG_PC] = postDelaySlotPc; delaySlot = 0; CachedCnt = 0; } } #ifdef STATS EmulateCnt++; #endif } // for (;;) lBreak: DoBreak(instr); return; lTrap: DoTrap(instr); return; lOverflow: DoOverflow(); return; lInvalidInstruction: DoInvalidInstruction(instr); return; #if 01 #undef op #undef r1 #undef r2 #undef r3 #undef shft #undef fxn #undef imm16 #undef simm16 #undef jtgt #endif } STATIC void DoBreak(uint32 instr) { uint32 code = (instr >> 16) & 0x3FF; // are there really another/extra 10 bits of the code? switch (code) { case 6: printstr("\nBreak: Signed division overflow"); break; case 7: printstr("\nBreak: Division by 0"); break; default: printstr("\nBreak: Code: 0x"); printhex(code); break; } printstr(" at PC = 0x"); printhex(Regs[REG_PC]); printchr('\n'); exit(-1); } STATIC void DoTrap(uint32 instr) { uint32 code = (instr >> 6) & 0x3FF; switch (code) { case 6: printstr("\nTrap: Signed division overflow"); break; case 7: printstr("\nTrap: Division by 0"); break; default: printstr("\nTrap: Code: 0x"); printhex(code); break; } printstr(" at PC = 0x"); printhex(Regs[REG_PC]); printchr('\n'); exit(-1); } STATIC void DoOverflow(void) { printstr("Signed integer addition/subtraction overflow"); printstr(" at PC = 0x"); printhex(Regs[REG_PC]); printchr('\n'); exit(-1); } STATIC void DoInvalidInstruction(uint32 instr) { printstr("Invalid/unsupported instruction: Opcode: 0x"); printhex(instr); printstr(" at PC = 0x"); printhex(Regs[REG_PC]); printchr('\n'); exit(-1); } ================================================ FILE: lib/libicache/icaches.s ================================================ # /* # Copyright (c) 2013, Alexey Frunze # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # 1. Redistributions of source code must retain the above copyright notice, this # list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright notice, # this list of conditions and the following disclaimer in the documentation # and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # # The views and conclusions contained in the software and documentation are those # of the authors and should not be interpreted as representing official policies, # either expressed or implied, of the FreeBSD Project. # */ # # /*****************************************************************************/ # /* */ # /* MIPS icache */ # /* */ # /*****************************************************************************/ .text .extern _gp .extern _icRegs_ .extern _icHostRegs_ .extern _icmain_ .globl _icstart_ .type _icstart_, @function _icstart_: la $28, _gp subu $29, $29, 1024 # allocate 1K of stack for us sw $29, _icRegs_ + 4*29 # leave the rest to the program addu $29, $29, 1024 - 16 j _icmain_ .globl _icDoSysCall_ .type _icDoSysCall_, @function _icDoSysCall_: sw $4, $_icsyscall_ # patch the syscall instruction # We need to write back the data cache and invalidate the instruction # cache for the location of the modified instruction before we can # actually execute it la $4, $_icsyscall_ synci 0($4) # does nothing on MIPS32 M4K since it has no caches # sw $1, _icHostRegs_ + 4*1 # ar # lw $1, _icRegs_ + 4*1 # # sw $2, _icHostRegs_ + 4*2 # v0 lw $2, _icRegs_ + 4*2 # # sw $3, _icHostRegs_ + 4*3 # v1 lw $3, _icRegs_ + 4*3 # # sw $4, _icHostRegs_ + 4*4 # a0 lw $4, _icRegs_ + 4*4 # # sw $5, _icHostRegs_ + 4*5 # a1 lw $5, _icRegs_ + 4*5 # # sw $6, _icHostRegs_ + 4*6 # a2 lw $6, _icRegs_ + 4*6 # # sw $7, _icHostRegs_ + 4*7 # a3 lw $7, _icRegs_ + 4*7 # # sw $8, _icHostRegs_ + 4*8 # t0 lw $8, _icRegs_ + 4*8 # # sw $9, _icHostRegs_ + 4*9 # t1 lw $9, _icRegs_ + 4*9 # # sw $10, _icHostRegs_ + 4*10 # t2 lw $10, _icRegs_ + 4*10 # # sw $11, _icHostRegs_ + 4*11 # t3 lw $11, _icRegs_ + 4*11 # # sw $12, _icHostRegs_ + 4*12 # t4 lw $12, _icRegs_ + 4*12 # # sw $13, _icHostRegs_ + 4*13 # t5 lw $13, _icRegs_ + 4*13 # # sw $14, _icHostRegs_ + 4*14 # t6 lw $14, _icRegs_ + 4*14 # # sw $15, _icHostRegs_ + 4*15 # t7 lw $15, _icRegs_ + 4*15 # sw $16, _icHostRegs_ + 4*16 lw $16, _icRegs_ + 4*16 sw $17, _icHostRegs_ + 4*17 lw $17, _icRegs_ + 4*17 sw $18, _icHostRegs_ + 4*18 lw $18, _icRegs_ + 4*18 sw $19, _icHostRegs_ + 4*19 lw $19, _icRegs_ + 4*19 sw $20, _icHostRegs_ + 4*20 lw $20, _icRegs_ + 4*20 sw $21, _icHostRegs_ + 4*21 lw $21, _icRegs_ + 4*21 sw $22, _icHostRegs_ + 4*22 lw $22, _icRegs_ + 4*22 sw $23, _icHostRegs_ + 4*23 lw $23, _icRegs_ + 4*23 # sw $24, _icHostRegs_ + 4*24 # t8 lw $24, _icRegs_ + 4*24 # # sw $25, _icHostRegs_ + 4*25 # t9 lw $25, _icRegs_ + 4*25 # # sw $26, _icHostRegs_ + 4*26 # k0 # lw $26, _icRegs_ + 4*26 # # sw $27, _icHostRegs_ + 4*27 # k1 # lw $27, _icRegs_ + 4*27 # sw $28, _icHostRegs_ + 4*28 # gp lw $28, _icRegs_ + 4*28 # sw $29, _icHostRegs_ + 4*29 # sp # lw $29, _icRegs_ + 4*29 # # Make sure sp is updated "atomically" and not part by part .set noat lw $1, _icRegs_ + 4*29 # move $29, $1 # .set at sw $30, _icHostRegs_ + 4*30 lw $30, _icRegs_ + 4*30 # sw $31, _icHostRegs_ + 4*31 # ra # lw $31, _icRegs_ + 4*31 # ra $_icsyscall_: # This instruction gets patched, so it can have # the requested system call number embedded in it syscall # RetroBSD may advance PC on returning from a syscall handler, # skipping 2 instructions that follow the syscall instruction. # Those 2 instructions typically set C's errno variable and # are either executed on error or skipped on success. # Account for this peculiarity. j $_icsyscall_error_ nop $_icsyscall_success_: # sw $1, _icRegs_ + 4*1 # ar # lw $1, _icHostRegs_ + 4*1 # sw $2, _icRegs_ + 4*2 # v0 # lw $2, _icHostRegs_ + 4*2 # sw $3, _icRegs_ + 4*3 # v1 # lw $3, _icHostRegs_ + 4*3 # sw $4, _icRegs_ + 4*4 # a0 # lw $4, _icHostRegs_ + 4*4 # sw $5, _icRegs_ + 4*5 # a1 # lw $5, _icHostRegs_ + 4*5 # sw $6, _icRegs_ + 4*6 # a2 # lw $6, _icHostRegs_ + 4*6 # sw $7, _icRegs_ + 4*7 # a3 # lw $7, _icHostRegs_ + 4*7 # sw $8, _icRegs_ + 4*8 # t0 # lw $8, _icHostRegs_ + 4*8 # sw $9, _icRegs_ + 4*9 # t1 # lw $9, _icHostRegs_ + 4*9 # sw $10, _icRegs_ + 4*10 # t2 # lw $10, _icHostRegs_ + 4*10 # sw $11, _icRegs_ + 4*11 # t3 # lw $11, _icHostRegs_ + 4*11 # sw $12, _icRegs_ + 4*12 # t4 # lw $12, _icHostRegs_ + 4*12 # sw $13, _icRegs_ + 4*13 # t5 # lw $13, _icHostRegs_ + 4*13 # sw $14, _icRegs_ + 4*14 # t6 # lw $14, _icHostRegs_ + 4*14 # sw $15, _icRegs_ + 4*15 # t7 # lw $15, _icHostRegs_ + 4*15 # sw $16, _icRegs_ + 4*16 lw $16, _icHostRegs_ + 4*16 sw $17, _icRegs_ + 4*17 lw $17, _icHostRegs_ + 4*17 sw $18, _icRegs_ + 4*18 lw $18, _icHostRegs_ + 4*18 sw $19, _icRegs_ + 4*19 lw $19, _icHostRegs_ + 4*19 sw $20, _icRegs_ + 4*20 lw $20, _icHostRegs_ + 4*20 sw $21, _icRegs_ + 4*21 lw $21, _icHostRegs_ + 4*21 sw $22, _icRegs_ + 4*22 lw $22, _icHostRegs_ + 4*22 sw $23, _icRegs_ + 4*23 lw $23, _icHostRegs_ + 4*23 sw $24, _icRegs_ + 4*24 # t8 # lw $24, _icHostRegs_ + 4*24 # sw $25, _icRegs_ + 4*25 # t9 # lw $25, _icHostRegs_ + 4*25 # # sw $26, _icRegs_ + 4*26 # k0 # lw $26, _icHostRegs_ + 4*26 # # sw $27, _icRegs_ + 4*27 # k1 # lw $27, _icHostRegs_ + 4*27 # sw $28, _icRegs_ + 4*28 # gp lw $28, _icHostRegs_ + 4*28 # sw $29, _icRegs_ + 4*29 # sp # lw $29, _icHostRegs_ + 4*29 # # Make sure sp is updated "atomically" and not part by part .set noat lw $1, _icHostRegs_ + 4*29 # move $29, $1 .set at sw $30, _icRegs_ + 4*30 lw $30, _icHostRegs_ + 4*30 # sw $31, _icRegs_ + 4*31 # ra # lw $31, _icHostRegs_ + 4*31 # li $2, 2 # success, 2 instructions skipped j $31 $_icsyscall_error_: # sw $1, _icRegs_ + 4*1 # ar # lw $1, _icHostRegs_ + 4*1 # sw $2, _icRegs_ + 4*2 # v0 # lw $2, _icHostRegs_ + 4*2 # sw $3, _icRegs_ + 4*3 # v1 # lw $3, _icHostRegs_ + 4*3 # sw $4, _icRegs_ + 4*4 # a0 # lw $4, _icHostRegs_ + 4*4 # sw $5, _icRegs_ + 4*5 # a1 # lw $5, _icHostRegs_ + 4*5 # sw $6, _icRegs_ + 4*6 # a2 # lw $6, _icHostRegs_ + 4*6 # sw $7, _icRegs_ + 4*7 # a3 # lw $7, _icHostRegs_ + 4*7 # sw $8, _icRegs_ + 4*8 # t0 # lw $8, _icHostRegs_ + 4*8 # sw $9, _icRegs_ + 4*9 # t1 # lw $9, _icHostRegs_ + 4*9 # sw $10, _icRegs_ + 4*10 # t2 # lw $10, _icHostRegs_ + 4*10 # sw $11, _icRegs_ + 4*11 # t3 # lw $11, _icHostRegs_ + 4*11 # sw $12, _icRegs_ + 4*12 # t4 # lw $12, _icHostRegs_ + 4*12 # sw $13, _icRegs_ + 4*13 # t5 # lw $13, _icHostRegs_ + 4*13 # sw $14, _icRegs_ + 4*14 # t6 # lw $14, _icHostRegs_ + 4*14 # sw $15, _icRegs_ + 4*15 # t7 # lw $15, _icHostRegs_ + 4*15 # sw $16, _icRegs_ + 4*16 lw $16, _icHostRegs_ + 4*16 sw $17, _icRegs_ + 4*17 lw $17, _icHostRegs_ + 4*17 sw $18, _icRegs_ + 4*18 lw $18, _icHostRegs_ + 4*18 sw $19, _icRegs_ + 4*19 lw $19, _icHostRegs_ + 4*19 sw $20, _icRegs_ + 4*20 lw $20, _icHostRegs_ + 4*20 sw $21, _icRegs_ + 4*21 lw $21, _icHostRegs_ + 4*21 sw $22, _icRegs_ + 4*22 lw $22, _icHostRegs_ + 4*22 sw $23, _icRegs_ + 4*23 lw $23, _icHostRegs_ + 4*23 sw $24, _icRegs_ + 4*24 # t8 # lw $24, _icHostRegs_ + 4*24 # sw $25, _icRegs_ + 4*25 # t9 # lw $25, _icHostRegs_ + 4*25 # # sw $26, _icRegs_ + 4*26 # k0 # lw $26, _icHostRegs_ + 4*26 # # sw $27, _icRegs_ + 4*27 # k1 # lw $27, _icHostRegs_ + 4*27 # sw $28, _icRegs_ + 4*28 # gp lw $28, _icHostRegs_ + 4*28 # sw $29, _icRegs_ + 4*29 # sp # lw $29, _icHostRegs_ + 4*29 # # Make sure sp is updated "atomically" and not part by part .set noat lw $1, _icHostRegs_ + 4*29 # move $29, $1 # .set at sw $30, _icRegs_ + 4*30 lw $30, _icHostRegs_ + 4*30 # sw $31, _icRegs_ + 4*31 # ra # lw $31, _icHostRegs_ + 4*31 # li $2, 0 # failure, 0 instructions skipped j $31 ================================================ FILE: lib/libicache/license.txt ================================================ Copyright (c) 2013, Alexey Frunze All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. The views and conclusions contained in the software and documentation are those of the authors and should not be interpreted as representing official policies, either expressed or implied, of the FreeBSD Project. ================================================ FILE: lib/libicache/readme.txt ================================================ icache is a MIPS emulator + software instruction cache. With it one may be able to run large programs on MIPS32 processors that would otherwise not fit into small on-chip RAMs of ~128KB. Supported platform: RetroBSD. http://www.retrobsd.org/ See the Wiki for more up-to-date details: http://github.com/alexfru/icacheMips/wiki ================================================ FILE: lib/libm/Makefile ================================================ TOPSRC!=cd ../..; pwd include ${TOPSRC}/share/mk/sys.mk CFLAGS += ${DEFS} -Wall SRCS = login.c logout.c logwtmp.c OBJS = asin.o atan.o exp.o erf.o floor.o fmod.o hypot.o j0.o j1.o \ jn.o log.o pow.o sin.o sinh.o sqrt.o tan.o tanh.o all: ../libm.a ../libm.a: ${OBJS} ${AR} cr $@ ${OBJS} $(RANLIB) $@ install: all # ${INSTALL} -d ${DESTDIR}/usr/lib # ${INSTALL} ../libm.a ${DESTDIR}/usr/lib/libm.a # $(RANLIB) ${DESTDIR}/usr/lib/libm.a clean: rm -f ../libm.a *.o *~ tags cleandir: clean rm -f .depend depend: mkdep ${CFLAGS} ${SRCS} tags: ctags ${SRCS} ================================================ FILE: lib/libm/asin.c ================================================ /* * asin(arg) and acos(arg) return the arcsin, arccos, * respectively of their arguments. * * Arctan is called after appropriate range reduction. */ #include #include int errno; static double pio2 = 1.570796326794896619; double asin(arg) double arg; { double sign, temp; sign = 1.; if(arg <0){ arg = -arg; sign = -1.; } if(arg > 1.){ errno = EDOM; return(0.); } temp = sqrt(1. - arg*arg); if(arg > 0.7) temp = pio2 - atan(temp/arg); else temp = atan(arg/temp); return(sign*temp); } double acos(arg) double arg; { if(arg < 0) arg = -arg; if(arg > 1.){ errno = EDOM; return(0.); } return(pio2 - asin(arg)); } ================================================ FILE: lib/libm/atan.c ================================================ /* * floating-point arctangent * * atan returns the value of the arctangent of its * argument in the range [-pi/2,pi/2]. * * atan2 returns the arctangent of arg1/arg2 * in the range [-pi,pi]. * * there are no error returns. * * coefficients are #5077 from Hart & Cheney. (19.56D) */ #include double static sq2p1 =2.414213562373095048802e0; static double sq2m1 = .414213562373095048802e0; static double pio2 =1.570796326794896619231e0; static double pio4 = .785398163397448309615e0; static double p4 = .161536412982230228262e2; static double p3 = .26842548195503973794141e3; static double p2 = .11530293515404850115428136e4; static double p1 = .178040631643319697105464587e4; static double p0 = .89678597403663861959987488e3; static double q4 = .5895697050844462222791e2; static double q3 = .536265374031215315104235e3; static double q2 = .16667838148816337184521798e4; static double q1 = .207933497444540981287275926e4; static double q0 = .89678597403663861962481162e3; /* * xatan evaluates a series valid in the * range [-0.414...,+0.414...]. */ static double xatan(arg) double arg; { double argsq; double value; argsq = arg*arg; value = ((((p4*argsq + p3)*argsq + p2)*argsq + p1)*argsq + p0); value = value/(((((argsq + q4)*argsq + q3)*argsq + q2)*argsq + q1)*argsq + q0); return(value*arg); } /* * satan reduces its argument (known to be positive) * to the range [0,0.414...] and calls xatan. */ static double satan(arg) double arg; { if(arg < sq2m1) return(xatan(arg)); else if(arg > sq2p1) return(pio2 - xatan(1.0/arg)); else return(pio4 + xatan((arg-1.0)/(arg+1.0))); } /* * atan makes its argument positive and * calls the inner routine satan. */ double atan(arg) double arg; { if(arg>0) return(satan(arg)); else return(-satan(-arg)); } /* * atan2 discovers what quadrant the angle * is in and calls atan. */ double atan2(arg1,arg2) double arg1,arg2; { if((arg1+arg2)==arg1) if(arg1 >= 0.) return(pio2); else return(-pio2); else if(arg2 <0.) if(arg1 >= 0.) return(pio2+pio2 - satan(-arg1/arg2)); else return(-pio2-pio2 + satan(arg1/arg2)); else if(arg1>0) return(satan(arg1/arg2)); else return(-satan(-arg1/arg2)); } ================================================ FILE: lib/libm/erf.c ================================================ /* * C program for floating point error function * * erf(x) returns the error function of its argument * erfc(x) returns 1.0-erf(x) * * erf(x) is defined by * ${2 over sqrt(pi)} int from 0 to x e sup {-t sup 2} dt$ * * the entry for erfc is provided because of the * extreme loss of relative accuracy if erf(x) is * called for large x and the result subtracted * from 1. (e.g. for x= 10, 12 places are lost). * * There are no error returns. * * Calls exp. * * Coefficients for large x are #5667 from Hart & Cheney (18.72D). */ #include #define M 7 #define N 9 int errno; static double torp = 1.1283791670955125738961589031; static double p1[] = { 0.804373630960840172832162e5, 0.740407142710151470082064e4, 0.301782788536507577809226e4, 0.380140318123903008244444e2, 0.143383842191748205576712e2, -.288805137207594084924010e0, 0.007547728033418631287834e0, }; static double q1[] = { 0.804373630960840172826266e5, 0.342165257924628539769006e5, 0.637960017324428279487120e4, 0.658070155459240506326937e3, 0.380190713951939403753468e2, 0.100000000000000000000000e1, 0.0, }; static double p2[] = { 0.18263348842295112592168999e4, 0.28980293292167655611275846e4, 0.2320439590251635247384768711e4, 0.1143262070703886173606073338e4, 0.3685196154710010637133875746e3, 0.7708161730368428609781633646e2, 0.9675807882987265400604202961e1, 0.5641877825507397413087057563e0, 0.0, }; static double q2[] = { 0.18263348842295112595576438e4, 0.495882756472114071495438422e4, 0.60895424232724435504633068e4, 0.4429612803883682726711528526e4, 0.2094384367789539593790281779e4, 0.6617361207107653469211984771e3, 0.1371255960500622202878443578e3, 0.1714980943627607849376131193e2, 1.0, }; double erf(arg) double arg;{ double erfc(); int sign; double argsq; double d, n; int i; errno = 0; sign = 1; if(arg < 0.){ arg = -arg; sign = -1; } if(arg < 0.5){ argsq = arg*arg; for(n=0,d=0,i=M-1; i>=0; i--){ n = n*argsq + p1[i]; d = d*argsq + q1[i]; } return(sign*torp*arg*n/d); } if(arg >= 10.) return(sign*1.); return(sign*(1. - erfc(arg))); } double erfc(arg) double arg;{ double erf(); double exp(); double n, d; int i; errno = 0; if(arg < 0.) return(2. - erfc(-arg)); /* if(arg < 0.5) return(1. - erf(arg)); */ if(arg >= 10.) return(0.); for(n=0,d=0,i=N-1; i>=0; i--){ n = n*arg + p2[i]; d = d*arg + q2[i]; } return(exp(-arg*arg)*n/d); } ================================================ FILE: lib/libm/exp.c ================================================ /* * exp returns the exponential function of its * floating-point argument. * * The coefficients are #1069 from Hart and Cheney. (22.35D) */ #include #include #include int errno; static double p0 = .2080384346694663001443843411e7; static double p1 = .3028697169744036299076048876e5; static double p2 = .6061485330061080841615584556e2; static double q0 = .6002720360238832528230907598e7; static double q1 = .3277251518082914423057964422e6; static double q2 = .1749287689093076403844945335e4; static double log2e = 1.4426950408889634073599247; static double sqrt2 = 1.4142135623730950488016887; static double maxf = DBL_MAX_10_EXP * 2.5/*>ln(10)*/; double exp(arg) double arg; { double fract; double temp1, temp2, xsq; int ent; if(arg == 0.) return(1.); if(arg < -maxf) return(0.); if(arg > maxf) { errno = ERANGE; return(HUGE_VAL); } arg *= log2e; ent = floor(arg); fract = (arg-ent) - 0.5; xsq = fract*fract; temp1 = ((p2*xsq+p1)*xsq+p0)*fract; temp2 = ((1.0*xsq+q2)*xsq+q1)*xsq + q0; return(ldexp(sqrt2*(temp2+temp1)/(temp2-temp1), ent)); } ================================================ FILE: lib/libm/fabs.c ================================================ #include double fabs(arg) double arg; { if(arg < 0.) arg = -arg; return(arg); } ================================================ FILE: lib/libm/floor.c ================================================ /* * floor and ceil-- greatest integer <= arg * (resp least >=) */ #include double floor(d) double d; { double fract; if (d<0.0) { d = -d; fract = modf(d, &d); if (fract != 0.0) d += 1; d = -d; } else modf(d, &d); return(d); } double ceil(d) double d; { return(-floor(-d)); } ================================================ FILE: lib/libm/fmod.c ================================================ #include #include typedef union { double value; struct { uint32_t lo; uint32_t hi; } uns; } union64_t; /* * Get two 32 bit ints from a double. */ #define UNPACK_DOUBLE(high,low,d) {\ union64_t u = {0}; \ u.value = d; \ high = u.uns.hi; \ low = u.uns.lo; \ } /* * Set a double from two 32 bit ints. */ #define PACK_DOUBLE(d,high,low) { \ union64_t u = {0}; \ u.uns.hi = high; \ u.uns.lo = low; \ d = u.value; \ } typedef union { float value; uint32_t word; } union32_t; /* * Get two 32 bit ints from a double. */ #define UNPACK_FLOAT(w,f) {\ union32_t u = {0}; \ u.value = f; \ w = u.word; \ } /* * Set a double from two 32 bit ints. */ #define PACK_FLOAT(f,w) { \ union32_t u = {0}; \ u.word = w; \ f = u.value; \ } static const double one = 1.0, Zero[] = {0.0, -0.0,}; double fmod(double x, double y) { int32_t n=0, hx=0, hy=0, hz=0, ix=0, iy=0, sx=0, i=0; if (sizeof(float) == sizeof(double)) { /* * Double is 32-bit. */ UNPACK_FLOAT(hx,x); UNPACK_FLOAT(hy,y); sx = hx & 0x80000000; /* sign of x */ hx ^= sx; /* |x| */ hy &= 0x7fffffff; /* |y| */ /* purge off exception values */ if (hy == 0 || hx >= 0x7f800000 || /* y=0, or x not finite */ hy > 0x7f800000) /* or y is NaN */ return (x*y) / (x*y); if (hx < hy) return x; /* |x| < |y| return x */ if (hx == hy) return Zero[(uint32_t)sx >> 31]; /* |x| = |y| return x*0*/ /* determine ix = ilogb(x) */ if (hx < 0x00800000) { /* subnormal x */ for (ix= -126, i=hx<<8; i>0; i<<=1) ix -= 1; } else ix = (hx >> 23) - 127; /* determine iy = ilogb(y) */ if (hy < 0x00800000) { /* subnormal y */ for (iy= -126, i=hy<<8; i>=0; i<<=1) iy -= 1; } else iy = (hy >> 23) - 127; /* set up {hx,lx}, {hy,ly} and align y to x */ if (ix >= -126) hx = 0x00800000 | (0x007fffff & hx); else { /* subnormal x, shift x to normal */ n = -126 - ix; hx = hx << n; } if (iy >= -126) hy = 0x00800000 | (0x007fffff & hy); else { /* subnormal y, shift y to normal */ n = -126 - iy; hy = hy << n; } /* fix point fmod */ n = ix - iy; while (n--) { hz = hx - hy; if (hz < 0) { hx = hx + hx; } else { if (hz == 0) /* return sign(x)*0 */ return Zero[(uint32_t)sx >> 31]; hx = hz + hz; } } hz = hx - hy; if (hz >= 0) { hx = hz; } /* convert back to floating value and restore the sign */ if (hx == 0) /* return sign(x)*0 */ return Zero[(uint32_t)sx >> 31]; while (hx < 0x00800000) { /* normalize x */ hx = hx + hx; iy -= 1; } if (iy >= -126) { /* normalize output */ hx = (hx - 0x00800000) | ((iy + 127) << 23); PACK_FLOAT(x, hx | sx); } else { /* subnormal output */ n = -126 - iy; hx >>= n; PACK_FLOAT(x, hx | sx); x *= one; /* create necessary signal */ } } else { /* * Double is 64-bit. */ uint32_t lx=0, ly=0, lz=0; UNPACK_DOUBLE(hx, lx, x); UNPACK_DOUBLE(hy, ly, y); sx = hx & 0x80000000; /* sign of x */ hx ^= sx; /* |x| */ hy &= 0x7fffffff; /* |y| */ /* purge off exception values */ if ((hy | ly) == 0 || hx >= 0x7ff00000 || /* y=0,or x not finite */ (hy | ((ly | -ly) >> 31)) > 0x7ff00000) /* or y is NaN */ return (x*y) / (x*y); if (hx <= hy) { if (hx < hy || lx < ly) return x; /* |x| < |y| return x */ if (lx == ly) return Zero[(uint32_t)sx >> 31]; /* |x| = |y| return x*0 */ } /* determine ix = ilogb(x) */ if (hx < 0x00100000) { /* subnormal x */ if (hx == 0) { for (ix = -1043, i=lx; i>0; i<<=1) ix -= 1; } else { for (ix = -1022, i=hx<<11; i>0; i<<=1) ix -= 1; } } else ix = (hx >> 20) - 1023; /* determine iy = ilogb(y) */ if (hy < 0x00100000) { /* subnormal y */ if(hy==0) { for (iy = -1043, i=ly; i>0; i<<=1) iy -= 1; } else { for (iy = -1022,i=(hy<<11); i>0; i<<=1) iy -= 1; } } else iy = (hy >> 20) - 1023; /* set up {hx,lx}, {hy,ly} and align y to x */ if (ix >= -1022) hx = 0x00100000 | (0x000fffff & hx); else { /* subnormal x, shift x to normal */ n = -1022 - ix; if (n <= 31) { hx = (hx << n) | (lx >> (32 - n)); lx <<= n; } else { hx = lx << (n - 32); lx = 0; } } if (iy >= -1022) hy = 0x00100000 | (0x000fffff & hy); else { /* subnormal y, shift y to normal */ n = -1022 - iy; if (n <= 31) { hy = (hy << n) | (ly >> (32 - n)); ly <<= n; } else { hy = ly << (n - 32); ly = 0; } } /* fix point fmod */ n = ix - iy; while (n--) { hz = hx - hy; lz = lx - ly; if (lx < ly) hz -= 1; if (hz < 0) { hx = hx + hx + (lx >> 31); lx = lx + lx; } else { if ((hz | lz) == 0) /* return sign(x)*0 */ return Zero[(uint32_t)sx >> 31]; hx = hz + hz + (lz >> 31); lx = lz + lz; } } hz = hx - hy; lz = lx - ly; if (lx < ly) hz -= 1; if (hz >= 0) { hx = hz; lx = lz; } /* convert back to floating value and restore the sign */ if ((hx | lx) == 0) /* return sign(x)*0 */ return Zero[(uint32_t)sx >> 31]; while (hx < 0x00100000) { /* normalize x */ hx = hx + hx + (lx >> 31); lx = lx + lx; iy -= 1; } if (iy >= -1022) { /* normalize output */ hx = (hx - 0x00100000) | ((iy + 1023) << 20); PACK_DOUBLE(x, hx | sx, lx); } else { /* subnormal output */ n = -1022 - iy; if (n <= 20) { lx = (lx >> n) | ((uint32_t)hx << (32 - n)); hx >>= n; } else if (n <= 31) { lx = (hx << (32 - n)) | (lx >> n); hx = sx; } else { lx = hx >> (n - 32); hx = sx; } PACK_DOUBLE(x, hx | sx, lx); x *= one; /* create necessary signal */ } } return x; /* exact output */ } ================================================ FILE: lib/libm/hypot.c ================================================ /* * sqrt(a^2 + b^2) * (but carefully) */ #include double hypot(a, b) double a, b; { double t; if (a < 0) a = -a; if (b < 0) b = -b; if (a > b) { t = a; a = b; b = t; } if (b==0) return(0.); a /= b; /* * pathological overflow possible * in the next line. */ return(b*sqrt(1. + a*a)); } #if 0 struct complex { double r; double i; }; double cabs(arg) struct complex arg; { return(hypot(arg.r, arg.i)); } #endif ================================================ FILE: lib/libm/j0.c ================================================ /* * floating point Bessel's function * of the first and second kinds * of order zero * * j0(x) returns the value of J0(x) * for all real values of x. * * There are no error returns. * Calls sin, cos, sqrt. * * There is a niggling bug in J0 which * causes errors up to 2e-16 for x in the * interval [-8,8]. * The bug is caused by an inappropriate order * of summation of the series. rhm will fix it * someday. * * Coefficients are from Hart & Cheney. * #5849 (19.22D) * #6549 (19.25D) * #6949 (19.41D) * * y0(x) returns the value of Y0(x) * for positive real values of x. * For x<=0, error number EDOM is set and a * large negative value is returned. * * Calls sin, cos, sqrt, log, j0. * * The values of Y0 have not been checked * to more than ten places. * * Coefficients are from Hart & Cheney. * #6245 (18.78D) * #6549 (19.25D) * #6949 (19.41D) */ #include #include int errno; static double pzero, qzero; static double tpi = .6366197723675813430755350535e0; static double pio4 = .7853981633974483096156608458e0; static double p1[] = { 0.4933787251794133561816813446e21, -.1179157629107610536038440800e21, 0.6382059341072356562289432465e19, -.1367620353088171386865416609e18, 0.1434354939140344111664316553e16, -.8085222034853793871199468171e13, 0.2507158285536881945555156435e11, -.4050412371833132706360663322e8, 0.2685786856980014981415848441e5, }; static double q1[] = { 0.4933787251794133562113278438e21, 0.5428918384092285160200195092e19, 0.3024635616709462698627330784e17, 0.1127756739679798507056031594e15, 0.3123043114941213172572469442e12, 0.6699987672982239671814028660e9, 0.1114636098462985378182402543e7, 0.1363063652328970604442810507e4, 1.0 }; static double p2[] = { 0.5393485083869438325262122897e7, 0.1233238476817638145232406055e8, 0.8413041456550439208464315611e7, 0.2016135283049983642487182349e7, 0.1539826532623911470917825993e6, 0.2485271928957404011288128951e4, 0.0, }; static double q2[] = { 0.5393485083869438325560444960e7, 0.1233831022786324960844856182e8, 0.8426449050629797331554404810e7, 0.2025066801570134013891035236e7, 0.1560017276940030940592769933e6, 0.2615700736920839685159081813e4, 1.0, }; static double p3[] = { -.3984617357595222463506790588e4, -.1038141698748464093880530341e5, -.8239066313485606568803548860e4, -.2365956170779108192723612816e4, -.2262630641933704113967255053e3, -.4887199395841261531199129300e1, 0.0, }; static double q3[] = { 0.2550155108860942382983170882e6, 0.6667454239319826986004038103e6, 0.5332913634216897168722255057e6, 0.1560213206679291652539287109e6, 0.1570489191515395519392882766e5, 0.4087714673983499223402830260e3, 1.0, }; static double p4[] = { -.2750286678629109583701933175e20, 0.6587473275719554925999402049e20, -.5247065581112764941297350814e19, 0.1375624316399344078571335453e18, -.1648605817185729473122082537e16, 0.1025520859686394284509167421e14, -.3436371222979040378171030138e11, 0.5915213465686889654273830069e8, -.4137035497933148554125235152e5, }; static double q4[] = { 0.3726458838986165881989980e21, 0.4192417043410839973904769661e19, 0.2392883043499781857439356652e17, 0.9162038034075185262489147968e14, 0.2613065755041081249568482092e12, 0.5795122640700729537480087915e9, 0.1001702641288906265666651753e7, 0.1282452772478993804176329391e4, 1.0, }; static void asympt(arg) double arg; { double zsq, n, d; int i; zsq = 64./(arg*arg); for(n=0,d=0,i=6;i>=0;i--){ n = n*zsq + p2[i]; d = d*zsq + q2[i]; } pzero = n/d; for(n=0,d=0,i=6;i>=0;i--){ n = n*zsq + p3[i]; d = d*zsq + q3[i]; } qzero = (8./arg)*(n/d); } double j0(arg) double arg; { double argsq, n, d; double sin(), cos(), sqrt(); int i; if(arg < 0.) arg = -arg; if(arg > 8.){ asympt(arg); n = arg - pio4; return(sqrt(tpi/arg)*(pzero*cos(n) - qzero*sin(n))); } argsq = arg*arg; for(n=0,d=0,i=8;i>=0;i--){ n = n*argsq + p1[i]; d = d*argsq + q1[i]; } return(n/d); } double y0(arg) double arg; { double argsq, n, d; double sin(), cos(), sqrt(), log(), j0(); int i; errno = 0; if(arg <= 0.){ errno = EDOM; return(-HUGE_VAL); } if(arg > 8.){ asympt(arg); n = arg - pio4; return(sqrt(tpi/arg)*(pzero*sin(n) + qzero*cos(n))); } argsq = arg*arg; for(n=0,d=0,i=8;i>=0;i--){ n = n*argsq + p4[i]; d = d*argsq + q4[i]; } return(n/d + tpi*j0(arg)*log(arg)); } ================================================ FILE: lib/libm/j1.c ================================================ /* * floating point Bessel's function * of the first and second kinds * of order one * * j1(x) returns the value of J1(x) * for all real values of x. * * There are no error returns. * Calls sin, cos, sqrt. * * There is a niggling bug in J1 which * causes errors up to 2e-16 for x in the * interval [-8,8]. * The bug is caused by an inappropriate order * of summation of the series. rhm will fix it * someday. * * Coefficients are from Hart & Cheney. * #6050 (20.98D) * #6750 (19.19D) * #7150 (19.35D) * * y1(x) returns the value of Y1(x) * for positive real values of x. * For x<=0, error number EDOM is set and a * large negative value is returned. * * Calls sin, cos, sqrt, log, j1. * * The values of Y1 have not been checked * to more than ten places. * * Coefficients are from Hart & Cheney. * #6447 (22.18D) * #6750 (19.19D) * #7150 (19.35D) */ #include #include int errno; static double pzero, qzero; static double tpi = .6366197723675813430755350535e0; static double pio4 = .7853981633974483096156608458e0; static double p1[] = { 0.581199354001606143928050809e21, -.6672106568924916298020941484e20, 0.2316433580634002297931815435e19, -.3588817569910106050743641413e17, 0.2908795263834775409737601689e15, -.1322983480332126453125473247e13, 0.3413234182301700539091292655e10, -.4695753530642995859767162166e7, 0.2701122710892323414856790990e4, }; static double q1[] = { 0.1162398708003212287858529400e22, 0.1185770712190320999837113348e20, 0.6092061398917521746105196863e17, 0.2081661221307607351240184229e15, 0.5243710262167649715406728642e12, 0.1013863514358673989967045588e10, 0.1501793594998585505921097578e7, 0.1606931573481487801970916749e4, 1.0, }; static double p2[] = { -.4435757816794127857114720794e7, -.9942246505077641195658377899e7, -.6603373248364939109255245434e7, -.1523529351181137383255105722e7, -.1098240554345934672737413139e6, -.1611616644324610116477412898e4, 0.0, }; static double q2[] = { -.4435757816794127856828016962e7, -.9934124389934585658967556309e7, -.6585339479723087072826915069e7, -.1511809506634160881644546358e7, -.1072638599110382011903063867e6, -.1455009440190496182453565068e4, 1.0, }; static double p3[] = { 0.3322091340985722351859704442e5, 0.8514516067533570196555001171e5, 0.6617883658127083517939992166e5, 0.1849426287322386679652009819e5, 0.1706375429020768002061283546e4, 0.3526513384663603218592175580e2, 0.0, }; static double q3[] = { 0.7087128194102874357377502472e6, 0.1819458042243997298924553839e7, 0.1419460669603720892855755253e7, 0.4002944358226697511708610813e6, 0.3789022974577220264142952256e5, 0.8638367769604990967475517183e3, 1.0, }; static double p4[] = { -.9963753424306922225996744354e23, 0.2655473831434854326894248968e23, -.1212297555414509577913561535e22, 0.2193107339917797592111427556e20, -.1965887462722140658820322248e18, 0.9569930239921683481121552788e15, -.2580681702194450950541426399e13, 0.3639488548124002058278999428e10, -.2108847540133123652824139923e7, 0.0, }; static double q4[] = { 0.5082067366941243245314424152e24, 0.5435310377188854170800653097e22, 0.2954987935897148674290758119e20, 0.1082258259408819552553850180e18, 0.2976632125647276729292742282e15, 0.6465340881265275571961681500e12, 0.1128686837169442121732366891e10, 0.1563282754899580604737366452e7, 0.1612361029677000859332072312e4, 1.0, }; static void asympt(arg) double arg; { double zsq, n, d; int i; zsq = 64./(arg*arg); for(n=0,d=0,i=6;i>=0;i--){ n = n*zsq + p2[i]; d = d*zsq + q2[i]; } pzero = n/d; for(n=0,d=0,i=6;i>=0;i--){ n = n*zsq + p3[i]; d = d*zsq + q3[i]; } qzero = (8./arg)*(n/d); } double j1(arg) double arg; { double xsq, n, d, x; double sin(), cos(), sqrt(); int i; x = arg; if(x < 0.) x = -x; if(x > 8.){ asympt(x); n = x - 3.*pio4; n = sqrt(tpi/x)*(pzero*cos(n) - qzero*sin(n)); if(arg <0.) n = -n; return(n); } xsq = x*x; for(n=0,d=0,i=8;i>=0;i--){ n = n*xsq + p1[i]; d = d*xsq + q1[i]; } return(arg*n/d); } double y1(arg) double arg; { double xsq, n, d, x; double sin(), cos(), sqrt(), log(), j1(); int i; errno = 0; x = arg; if(x <= 0.){ errno = EDOM; return(-HUGE_VAL); } if(x > 8.){ asympt(x); n = x - 3*pio4; return(sqrt(tpi/x)*(pzero*sin(n) + qzero*cos(n))); } xsq = x*x; for(n=0,d=0,i=9;i>=0;i--){ n = n*xsq + p4[i]; d = d*xsq + q4[i]; } return(x*n/d + tpi*(j1(x)*log(x)-1./x)); } ================================================ FILE: lib/libm/jn.c ================================================ /* * floating point Bessel's function of * the first and second kinds and of integer order. * * int n; * double x; * jn(n,x); * * returns the value of Jn(x) for all * integer values of n and all real values of x. * * There are no error returns. * Calls j0, j1. * * For n=0, j0(x) is called, * for n=1, j1(x) is called, * for nx, a continued fraction approximation to * j(n,x)/j(n-1,x) is evaluated and then backward * recursion is used starting from a supposed value * for j(n,x). The resulting value of j(0,x) is * compared with the actual value to correct the * supposed value of j(n,x). * * yn(n,x) is similar in all respects, except * that forward recursion is used for all values of n>1. */ #include #include int errno; double jn(n,x) int n; double x;{ int i; double a, b, temp; double xsq, t; double j0(), j1(); if(n<0){ n = -n; x = -x; } if(n==0) return(j0(x)); if(n==1) return(j1(x)); if(x == 0.) return(0.); if(n>x) goto recurs; a = j0(x); b = j1(x); for(i=1;in;i--){ t = xsq/(2.*i - t); } t = x/(2.*n-t); a = t; b = 1; for(i=n-1;i>0;i--){ temp = b; b = (2.*i/x)*b - a; a = temp; } return(t*j0(x)/b); } double yn(n,x) int n; double x;{ int i; int sign; double a, b, temp; double y0(), y1(); if (x <= 0) { errno = EDOM; return(-HUGE_VAL); } sign = 1; if(n<0){ n = -n; if(n%2 == 1) sign = -1; } if(n==0) return(y0(x)); if(n==1) return(sign*y1(x)); a = y0(x); b = y1(x); for(i=1;i #include int errno; static double _log2 = 0.693147180559945309e0; static double ln10 = 2.302585092994045684; static double sqrto2 = 0.707106781186547524e0; static double p0 = -.240139179559210510e2; static double p1 = 0.309572928215376501e2; static double p2 = -.963769093368686593e1; static double p3 = 0.421087371217979714e0; static double q0 = -.120069589779605255e2; static double q1 = 0.194809660700889731e2; static double q2 = -.891110902798312337e1; double log(arg) double arg; { double x,z, zsq, temp; int exp; if(arg <= 0.) { errno = EDOM; return(-HUGE_VAL); } x = frexp(arg,&exp); while(x<0.5) { x = x*2; exp = exp-1; } if(x #include int errno; double pow(arg1,arg2) double arg1, arg2; { double temp; long l; if(arg1 <= 0.) { if(arg1 == 0.) { if(arg2 <= 0.) goto domain; return(0.); } l = arg2; if(l != arg2) goto domain; temp = exp(arg2 * log(-arg1)); if(l & 1) temp = -temp; return(temp); } return(exp(arg2 * log(arg1))); domain: errno = EDOM; return(0.); } ================================================ FILE: lib/libm/sin.c ================================================ /* * C program for floating point sin/cos. * Calls modf. * There are no error exits. * Coefficients are #3370 from Hart & Cheney (18.80D). */ #include static double twoopi = 0.63661977236758134308; static double p0 = .1357884097877375669092680e8; static double p1 = -.4942908100902844161158627e7; static double p2 = .4401030535375266501944918e6; static double p3 = -.1384727249982452873054457e5; static double p4 = .1459688406665768722226959e3; static double q0 = .8644558652922534429915149e7; static double q1 = .4081792252343299749395779e6; static double q2 = .9463096101538208180571257e4; static double q3 = .1326534908786136358911494e3; static double sinus(arg, quad) double arg; int quad; { double modf(); double e, f; double ysq; double x,y; int k; double temp1, temp2; x = arg; if(x<0) { x = -x; quad = quad + 2; } x = x*twoopi; /*underflow?*/ if(x>32764){ y = modf(x,&e); e = e + quad; modf(0.25*e,&f); quad = e - 4*f; }else{ k = x; y = x - k; quad = (quad + k) & 03; } if (quad & 01) y = 1-y; if(quad > 1) y = -y; ysq = y*y; temp1 = ((((p4*ysq+p3)*ysq+p2)*ysq+p1)*ysq+p0)*y; temp2 = ((((ysq+q3)*ysq+q2)*ysq+q1)*ysq+q0); return(temp1/temp2); } double cos(arg) double arg; { double sinus(); if(arg<0) arg = -arg; return(sinus(arg, 1)); } double sin(arg) double arg; { double sinus(); return(sinus(arg, 0)); } ================================================ FILE: lib/libm/sinh.c ================================================ /* * sinh(arg) returns the hyperbolic sine of its floating- * point argument. * * The exponential function is called for arguments * greater in magnitude than 0.5. * * A series is used for arguments smaller in magnitude than 0.5. * The coefficients are #2029 from Hart & Cheney. (20.36D) * * cosh(arg) is computed from the exponential function for * all arguments. */ #include static double p0 = -0.6307673640497716991184787251e+6; static double p1 = -0.8991272022039509355398013511e+5; static double p2 = -0.2894211355989563807284660366e+4; static double p3 = -0.2630563213397497062819489e+2; static double q0 = -0.6307673640497716991212077277e+6; static double q1 = 0.1521517378790019070696485176e+5; static double q2 = -0.173678953558233699533450911e+3; double sinh(arg) double arg; { double temp, argsq; register int sign; sign = 1; if(arg < 0) { arg = - arg; sign = -1; } if(arg > 21.) { temp = exp(arg)/2; if (sign>0) return(temp); else return(-temp); } if(arg > 0.5) { return(sign*(exp(arg) - exp(-arg))/2); } argsq = arg*arg; temp = (((p3*argsq+p2)*argsq+p1)*argsq+p0)*arg; temp /= (((argsq+q2)*argsq+q1)*argsq+q0); return(sign*temp); } double cosh(arg) double arg; { if(arg < 0) arg = - arg; if(arg > 21.) { return(exp(arg)/2); } return((exp(arg) + exp(-arg))/2); } ================================================ FILE: lib/libm/sqrt.c ================================================ /* * sqrt returns the square root of its floating * point argument. Newton's method. * * calls frexp */ #include #include int errno; double sqrt(arg) double arg; { double x, temp; int exp; int i; if(arg <= 0.) { if(arg < 0.) errno = EDOM; return(0.); } x = frexp(arg,&exp); while(x < 0.5) { x *= 2; exp--; } /* * NOTE * this wont work on 1's comp */ if(exp & 1) { x *= 2; exp--; } temp = 0.5*(1.0+x); while(exp > 60) { temp *= (1L<<30); exp -= 60; } while(exp < -60) { temp /= (1L<<30); exp += 60; } if(exp >= 0) temp *= 1L << (exp/2); else temp /= 1L << (-exp/2); for(i=0; i<=4; i++) temp = 0.5*(temp + arg/temp); return(temp); } ================================================ FILE: lib/libm/tan.c ================================================ /* * floating point tangent * * A series is used after range reduction. * Coefficients are #4285 from Hart & Cheney. (19.74D) */ #include #include int errno; static double invpi = 1.27323954473516268; static double p0 = -0.1306820264754825668269611177e+5; static double p1 = 0.1055970901714953193602353981e+4; static double p2 = -0.1550685653483266376941705728e+2; static double p3 = 0.3422554387241003435328470489e-1; static double p4 = 0.3386638642677172096076369e-4; static double q0 = -0.1663895238947119001851464661e+5; static double q1 = 0.4765751362916483698926655581e+4; static double q2 = -0.1555033164031709966900124574e+3; double tan(arg) double arg; { double modf(); double sign, temp, e, x, xsq; int flag, i; flag = 0; sign = 1.; if(arg < 0.){ arg = -arg; sign = -1.; } arg = arg*invpi; /*overflow?*/ x = modf(arg,&e); i = e; switch(i%4) { case 1: x = 1. - x; flag = 1; break; case 2: sign = - sign; flag = 1; break; case 3: x = 1. - x; sign = - sign; break; case 0: break; } xsq = x*x; temp = ((((p4*xsq+p3)*xsq+p2)*xsq+p1)*xsq+p0)*x; temp = temp/(((1.0*xsq+q2)*xsq+q1)*xsq+q0); if(flag == 1) { if(temp == 0.) { errno = ERANGE; if (sign>0) return(HUGE_VAL); return(-HUGE_VAL); } temp = 1./temp; } return(sign*temp); } ================================================ FILE: lib/libm/tanh.c ================================================ /* * tanh(arg) computes the hyperbolic tangent of its floating * point argument. * * sinh and cosh are called except for large arguments, which * would cause overflow improperly. */ #include double tanh(arg) double arg; { double sign; sign = 1.; if(arg < 0.){ arg = -arg; sign = -1.; } if(arg > 21.) return(sign); return(sign*sinh(arg)/cosh(arg)); } ================================================ FILE: lib/libreadline/LICENSE ================================================ Copyright (c) 2010-2014, Salvatore Sanfilippo Copyright (c) 2010-2013, Pieter Noordhuis All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ================================================ FILE: lib/libreadline/Makefile ================================================ TOPSRC!=cd ../..; pwd include ${TOPSRC}/share/mk/sys.mk CFLAGS += -O -Wall OBJS = readline.o HDRS = readline/readline.h readline/history.h all: ../libreadline.a ../libreadline.a: ${OBJS} @${AR} cr $@ ${OBJS} $(RANLIB) $@ install: all ${HDRS} ${INSTALL} -d ${DESTDIR}/usr/include/readline/ cp -p ${HDRS} ${DESTDIR}/usr/include/readline/ clean: rm -f *~ *.o a.out ../libreadline*.a ================================================ FILE: lib/libreadline/Makefile-unix ================================================ CFLAGS += -Wall -Os -g example: readline.o example.o $(CC) $(LDFLAGS) -o $@ readline.o example.o clean: rm -rf *.o example example.dSYM history.txt ### example.o: example.c readline/readline.h readline/history.h readline.o: readline.c readline/readline.h readline/history.h ================================================ FILE: lib/libreadline/README ================================================ Linenoise ~~~~~~~~~ A minimal, zero-config, BSD licensed, readline replacement used in Redis, MongoDB, and Android. * Single and multi line editing mode with the usual key bindings implemented. * History handling. * Completion. * About 1,100 lines of BSD license source code. * Only uses a subset of VT100 escapes (ANSI.SYS compatible). Can a line editing library be 20k lines of code? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Line editing with some support for history is a really important feature for command line utilities. Instead of retyping almost the same stuff again and again it's just much better to hit the up arrow and edit on syntax errors, or in order to try a slightly different command. But apparently code dealing with terminals is some sort of Black Magic: readline is 30k lines of code, libedit 20k. Is it reasonable to link small utilities to huge libraries just to get a minimal support for line editing? So what usually happens is either: * Large programs with configure scripts disabling line editing if readline is not present in the system, or not supporting it at all since readline is GPL licensed and libedit (the BSD clone) is not as known and available as readline is (Real world example of this problem: Tclsh). * Smaller programs not using a configure script not supporting line editing at all (A problem we had with Redis-cli for instance). The result is a pollution of binaries without line editing support. So I spent more or less two hours doing a reality check resulting in this little library: is it *really* needed for a line editing library to be 20k lines of code? Apparently not, it is possibe to get a very small, zero configuration, trivial to embed library, that solves the problem. Smaller programs will just include this, supporing line editing out of the box. Larger programs may use this little library or just checking with configure if readline/libedit is available and resorting to linenoise if not. Terminals, in 2010 ~~~~~~~~~~~~~~~~~~ Apparently almost every terminal you can happen to use today has some kind of support for basic VT100 escape sequences. So I tried to write a lib using just very basic VT100 features. The resulting library appears to work everywhere I tried to use it, and now can work even on ANSI.SYS compatible terminals, since no VT220 specific sequences are used anymore. The library is currently about 1100 lines of code. In order to use it in your project just look at the *example.c* file in the source distribution, it is trivial. Linenoise is BSD code, so you can use both in free software and commercial software. Tested with... ~~~~~~~~~~~~~~ * Linux text only console ($TERM = linux) * Linux KDE terminal application ($TERM = xterm) * Linux xterm ($TERM = xterm) * Linux Buildroot ($TERM = vt100) * Mac OS X iTerm ($TERM = xterm) * Mac OS X default Terminal.app ($TERM = xterm) * OpenBSD 4.5 through an OSX Terminal.app ($TERM = screen) * IBM AIX 6.1 * FreeBSD xterm ($TERM = xterm) * ANSI.SYS * Emacs comint mode ($TERM = dumb) Please test it everywhere you can and report back! Let's push this forward! ~~~~~~~~~~~~~~~~~~~~~~~~ Patches should be provided in the respect of linenoise sensibility for small easy to understand code. Send feedbacks to antirez at gmail ================================================ FILE: lib/libreadline/example.c ================================================ #include #include #include #include "readline/readline.h" #include "readline/history.h" int main(int argc, char **argv) { char *line; char *prgname = argv[0]; /* Parse options, with --multiline we enable multi line editing. */ while(argc > 1) { argc--; argv++; if (!strcmp(*argv,"--multiline")) { readline_set_multiline(1); printf("Multi-line mode enabled.\n"); } else if (!strcmp(*argv,"--keycodes")) { readline_print_keycodes(); exit(0); } else { fprintf(stderr, "Usage: %s [--multiline] [--keycodes]\n", prgname); exit(1); } } /* Load history from file. The history file is just a plain text file * where entries are separated by newlines. */ add_history("history.txt"); /* Load the history at startup */ /* Now this is the main loop of the typical readline-based application. * The call to readline() will block as long as the user types something * and presses enter. * * The typed string is returned as a malloc() allocated string by * readline, so the user needs to free() it. */ while((line = readline("hello> ")) != NULL) { /* Do something with the string. */ if (line[0] != '\0' && line[0] != '/') { printf("echo: '%s'\n", line); add_history(line); /* Add to the history. */ write_history("history.txt"); /* Save the history on disk. */ } else if (!strncmp(line,"/historylen",11)) { /* The "/historylen" command will change the history len. */ int len = atoi(line+11); history_set_length(len); } else if (line[0] == '/') { printf("Unrecognized command: %s\n", line); } free(line); } return 0; } ================================================ FILE: lib/libreadline/readline/history.h ================================================ /* * Guerrilla line editing library against the idea that a line editing lib * needs to be 20,000 lines of C code. * * Based on linenoise.c with API modified for compatibility with * traditional readline library. * * ------------------------------------------------------------------------ * * Copyright (c) 2010-2014, Salvatore Sanfilippo * Copyright (c) 2010-2013, Pieter Noordhuis * Copyright (c) 2015, Serge Vakulenko * * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef __HISTORY_H #define __HISTORY_H #ifdef __cplusplus extern "C" { #endif /* * Place STRING at the end of the history list. * The associated data field (if any) is set to NULL. */ void add_history(const char *line); /* * Set the maximum length of the current history array. */ int history_set_length(int len); /* * Add the contents of FILENAME to the history list, a line at a time. * If FILENAME is NULL, then read from ~/.history. Returns 0 if * successful, or errno if not. */ int read_history(const char *filename); /* * Write the current history to FILENAME. If FILENAME is NULL, * then write the history list to ~/.history. Values returned * are as in read_history (). */ int write_history(const char *filename); #ifdef __cplusplus } #endif #endif /* __HISTORY_H */ ================================================ FILE: lib/libreadline/readline/readline.h ================================================ /* * Guerrilla line editing library against the idea that a line editing lib * needs to be 20,000 lines of C code. * * Based on linenoise.c with API modified for compatibility with * traditional readline library. * * ------------------------------------------------------------------------ * * Copyright (c) 2010-2014, Salvatore Sanfilippo * Copyright (c) 2010-2013, Pieter Noordhuis * Copyright (c) 2015, Serge Vakulenko * * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef __READLINE_H #define __READLINE_H #ifdef __cplusplus extern "C" { #endif /* * Read a line of input. * Prompt with PROMPT. * A NULL PROMPT means none. */ char *readline(const char *prompt); /* * Clear the screen. * Used to handle Ctrl+L. */ void readline_clear_screen(void); /* * Set if to use or not the multi line mode. */ void readline_set_multiline(int ml); /* * This routine is used in order to print scan codes on screen * for debugging / development purposes. */ void readline_print_keycodes(void); #ifdef __cplusplus } #endif #endif /* __READLINE_H */ ================================================ FILE: lib/libreadline/readline.c ================================================ /* * Guerrilla line editing library against the idea that a line editing lib * needs to be 20,000 lines of C code. * Based on linenoise.c with API modified for compatibility with * traditional readline library. * * Does a number of crazy assumptions that happen to be true in 99.9999% of * the 2010 UNIX computers around. * * You can find the original linenoise source code at: * * http://github.com/antirez/linenoise * * ------------------------------------------------------------------------ * * Copyright (c) 2010-2014, Salvatore Sanfilippo * Copyright (c) 2010-2013, Pieter Noordhuis * Copyright (c) 2015, Serge Vakulenko * * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * ------------------------------------------------------------------------ * * References: * - http://invisible-island.net/xterm/ctlseqs/ctlseqs.html * - http://www.3waylabs.com/nw/WWW/products/wizcon/vt220.html * * Todo list: * - Filter bogus Ctrl+ combinations. * - Win32 support * * Bloat: * - History search like Ctrl+r in readline? * * List of escape sequences used by this program, we do everything just * with three sequences. In order to be so cheap we may have some * flickering effect with some slow terminal, but the lesser sequences * the more compatible. * * EL (Erase Line) * Sequence: ESC [ n K * Effect: if n is 0 or missing, clear from cursor to end of line * Effect: if n is 1, clear from beginning of line to cursor * Effect: if n is 2, clear entire line * * CUF (CUrsor Forward) * Sequence: ESC [ n C * Effect: moves cursor forward n chars * * CUB (CUrsor Backward) * Sequence: ESC [ n D * Effect: moves cursor backward n chars * * The following is used to get the terminal width if getting * the width with the TIOCGWINSZ ioctl fails * * DSR (Device Status Report) * Sequence: ESC [ 6 n * Effect: reports the current cusor position as ESC [ n ; m R * where n is the row and m is the column * * When multi line mode is enabled, we also use an additional escape * sequence. However multi line editing is disabled by default. * * CUU (Cursor Up) * Sequence: ESC [ n A * Effect: moves cursor up of n chars. * * CUD (Cursor Down) * Sequence: ESC [ n B * Effect: moves cursor down of n chars. * * When readline_clear_screen() is called, two additional escape sequences * are used in order to clear the screen and position the cursor at home * position. * * CUP (Cursor position) * Sequence: ESC [ H * Effect: moves the cursor to upper left corner * * ED (Erase display) * Sequence: ESC [ 2 J * Effect: clear the whole screen * */ #include #include #include #include #include #include #include #include #include #include #include #include "readline/readline.h" #include "readline/history.h" #ifdef USE_TERMIOS # include #else # define termios sgttyb #endif #define LINENOISE_DEFAULT_HISTORY_MAX_LEN 100 #define LINENOISE_MAX_LINE 4096 static char *unsupported_term[] = {"dumb", "cons25", "emacs", NULL}; static struct termios term_orig; /* In order to restore at exit. */ static int rawmode = 0; /* For atexit() function to check if restore is needed */ static int mlmode = 0; /* Multi line mode. Default is single line. */ static int atexit_registered = 0; /* Register atexit just 1 time. */ static int history_max_len = LINENOISE_DEFAULT_HISTORY_MAX_LEN; static int history_len = 0; static char **history = NULL; /* The linenoiseState structure represents the state during line editing. * We pass this state to functions implementing specific editing * functionalities. */ struct linenoiseState { int ifd; /* Terminal stdin file descriptor. */ int ofd; /* Terminal stdout file descriptor. */ char *buf; /* Edited line buffer. */ size_t buflen; /* Edited line buffer size. */ const char *prompt; /* Prompt to display. */ size_t plen; /* Prompt length. */ size_t pos; /* Current cursor position. */ size_t oldpos; /* Previous refresh cursor position. */ size_t len; /* Current edited line length. */ size_t cols; /* Number of columns in terminal. */ size_t maxrows; /* Maximum num of rows used so far (multiline mode) */ int history_index; /* The history index we are currently editing. */ }; enum KEY_ACTION{ KEY_NULL = 0, /* NULL */ CTRL_A = 1, /* Ctrl+a */ CTRL_B = 2, /* Ctrl-b */ CTRL_C = 3, /* Ctrl-c */ CTRL_D = 4, /* Ctrl-d */ CTRL_E = 5, /* Ctrl-e */ CTRL_F = 6, /* Ctrl-f */ CTRL_H = 8, /* Ctrl-h */ TAB = 9, /* Tab */ CTRL_K = 11, /* Ctrl+k */ CTRL_L = 12, /* Ctrl+l */ ENTER = 13, /* Enter */ CTRL_N = 14, /* Ctrl-n */ CTRL_P = 16, /* Ctrl-p */ CTRL_T = 20, /* Ctrl-t */ CTRL_U = 21, /* Ctrl+u */ CTRL_W = 23, /* Ctrl+w */ ESC = 27, /* Escape */ BACKSPACE = 127, /* Backspace */ }; static void linenoiseAtExit(void); static void refreshLine(struct linenoiseState *l); /* Debugging macro. */ #if 0 FILE *lndebug_fp = NULL; #define lndebug(...) \ do { \ if (lndebug_fp == NULL) { \ lndebug_fp = fopen("/tmp/lndebug.txt","a"); \ fprintf(lndebug_fp, \ "[%d %d %d] p: %d, rows: %d, rpos: %d, max: %d, oldmax: %d\n", \ (int)l->len,(int)l->pos,(int)l->oldpos,plen,rows,rpos, \ (int)l->maxrows,old_rows); \ } \ fprintf(lndebug_fp, ", " __VA_ARGS__); \ fflush(lndebug_fp); \ } while (0) #else #define lndebug(fmt, ...) #endif /* ======================= Low level terminal handling ====================== */ /* Set if to use or not the multi line mode. */ void readline_set_multiline(int ml) { mlmode = ml; } /* Return true if the terminal name is in the list of terminals we know are * not able to understand basic escape sequences. */ static int isUnsupportedTerm(void) { char *term = getenv("TERM"); int j; if (term == NULL) return 0; for (j = 0; unsupported_term[j]; j++) if (!strcasecmp(term, unsupported_term[j])) return 1; return 0; } /* Raw mode: 1960 magic shit. */ static int enableRawMode(int fd) { struct termios raw; if (!isatty(STDIN_FILENO)) goto fatal; if (!atexit_registered) { atexit(linenoiseAtExit); atexit_registered = 1; } #ifdef TCSAFLUSH /* Modern POSIX style of tty control. */ if (tcgetattr(fd, &term_orig) < 0) goto fatal; raw = term_orig; /* modify the original mode */ /* input modes: no break, no CR to NL, no parity check, no strip char, * no start/stop output control. */ raw.c_iflag &= ~(BRKINT | ICRNL | INPCK | ISTRIP | IXON); /* output modes - disable post processing */ raw.c_oflag &= ~(OPOST); /* control modes - set 8 bit chars */ raw.c_cflag |= (CS8); /* local modes - choing off, canonical off, no extended functions, * no signal chars (^Z,^C) */ raw.c_lflag &= ~(ECHO | ICANON | IEXTEN); // leave ISIG ON- allow intr's /* control chars - set return condition: min number of bytes and timer. * We want read to return every single byte, without timeout. */ raw.c_cc[VMIN] = 1; raw.c_cc[VTIME] = 0; /* 1 byte, no timer */ /* put terminal in raw mode after flushing */ if (tcsetattr(fd, TCSAFLUSH, &raw) < 0) goto fatal; #else /* Outdated SysV Unix style of tty control. */ if (ioctl(fd, TIOCGETP, &term_orig) < 0) goto fatal; raw = term_orig; /* modify the original mode */ raw.sg_flags &= ~(ECHO | CRMOD | XTABS | RAW); raw.sg_flags |= CBREAK; /* put terminal in raw mode */ if (ioctl(fd, TIOCSETP, &raw) < 0) goto fatal; #endif rawmode = 1; return 0; fatal: errno = ENOTTY; return -1; } static void disableRawMode(int fd) { /* Don't even check the return value as it's too late. */ if (rawmode) { #ifdef TCSAFLUSH if (tcsetattr(fd, TCSAFLUSH, &term_orig) < 0) return; #else if (ioctl(fd, TIOCSETP, &term_orig) < 0) return; #endif rawmode = 0; } } /* Use the ESC [6n escape sequence to query the horizontal cursor position * and return it. On error -1 is returned, on success the position of the * cursor. */ static int getCursorPosition(int ifd, int ofd) { char buf[32]; int cols, rows; unsigned int i = 0; /* Report cursor location */ if (write(ofd, "\x1b[6n", 4) != 4) return -1; /* Read the response: ESC [ rows ; cols R */ while (i < sizeof(buf)-1) { if (read(ifd,buf+i,1) != 1) break; if (buf[i] == 'R') break; i++; } buf[i] = '\0'; /* Parse it. */ if (buf[0] != ESC || buf[1] != '[') return -1; if (sscanf(buf+2,"%d;%d",&rows,&cols) != 2) return -1; return cols; } /* Try to get the number of columns in the current terminal, or assume 80 * if it fails. */ static int getColumns(int ifd, int ofd) { struct winsize ws; if (ioctl(1, TIOCGWINSZ, &ws) == -1 || ws.ws_col == 0) { /* ioctl() failed. Try to query the terminal itself. */ int start, cols; /* Get the initial position so we can restore it later. */ start = getCursorPosition(ifd,ofd); if (start == -1) goto failed; /* Go to right margin and get position. */ if (write(ofd,"\x1b[999C",6) != 6) goto failed; cols = getCursorPosition(ifd,ofd); if (cols == -1) goto failed; /* Restore position. */ if (cols > start) { char seq[32]; snprintf(seq,32,"\x1b[%dD",cols-start); if (write(ofd,seq,strlen(seq)) == -1) { /* Can't recover... */ } } return cols; } else { return ws.ws_col; } failed: return 80; } /* Clear the screen. Used to handle ctrl+l */ void readline_clear_screen(void) { if (write(STDOUT_FILENO,"\x1b[H\x1b[2J",7) <= 0) { /* nothing to do, just to avoid warning. */ } } /* =========================== Line editing ================================= */ /* We define a very simple "append buffer" structure, that is an heap * allocated string where we can append to. This is useful in order to * write all the escape sequences in a buffer and flush them to the standard * output in a single call, to avoid flickering effects. */ struct abuf { char *b; int len; }; static void abInit(struct abuf *ab) { ab->b = NULL; ab->len = 0; } static void abAppend(struct abuf *ab, const char *s, int len) { char *new = realloc(ab->b,ab->len+len); if (new == NULL) return; memcpy(new+ab->len,s,len); ab->b = new; ab->len += len; } static void abFree(struct abuf *ab) { free(ab->b); } /* Single line low level line refresh. * * Rewrite the currently edited line accordingly to the buffer content, * cursor position, and number of columns of the terminal. */ static void refreshSingleLine(struct linenoiseState *l) { char seq[64]; size_t plen = strlen(l->prompt); int fd = l->ofd; char *buf = l->buf; size_t len = l->len; size_t pos = l->pos; struct abuf ab; while((plen+pos) >= l->cols) { buf++; len--; pos--; } while (plen+len > l->cols) { len--; } abInit(&ab); /* Cursor to left edge */ snprintf(seq,64,"\r"); abAppend(&ab,seq,strlen(seq)); /* Write the prompt and the current buffer content */ abAppend(&ab,l->prompt,strlen(l->prompt)); abAppend(&ab,buf,len); /* Erase to right */ snprintf(seq,64,"\x1b[0K"); abAppend(&ab,seq,strlen(seq)); /* Move cursor to original position. */ snprintf(seq,64,"\r\x1b[%dC", (int)(pos+plen)); abAppend(&ab,seq,strlen(seq)); if (write(fd,ab.b,ab.len) == -1) { /* Can't recover from write error. */ } abFree(&ab); } /* Multi line low level line refresh. * * Rewrite the currently edited line accordingly to the buffer content, * cursor position, and number of columns of the terminal. */ static void refreshMultiLine(struct linenoiseState *l) { char seq[64]; int plen = strlen(l->prompt); int rows = (plen+l->len+l->cols-1)/l->cols; /* rows used by current buf. */ int rpos = (plen+l->oldpos+l->cols)/l->cols; /* cursor relative row. */ int rpos2; /* rpos after refresh. */ int col; /* colum position, zero-based. */ int old_rows = l->maxrows; int fd = l->ofd, j; struct abuf ab; /* Update maxrows if needed. */ if (rows > (int)l->maxrows) l->maxrows = rows; /* First step: clear all the lines used before. To do so start by * going to the last row. */ abInit(&ab); if (old_rows-rpos > 0) { lndebug("go down %d", old_rows-rpos); snprintf(seq,64,"\x1b[%dB", old_rows-rpos); abAppend(&ab,seq,strlen(seq)); } /* Now for every row clear it, go up. */ for (j = 0; j < old_rows-1; j++) { lndebug("clear+up"); snprintf(seq,64,"\r\x1b[0K\x1b[1A"); abAppend(&ab,seq,strlen(seq)); } /* Clean the top line. */ lndebug("clear"); snprintf(seq,64,"\r\x1b[0K"); abAppend(&ab,seq,strlen(seq)); /* Write the prompt and the current buffer content */ abAppend(&ab,l->prompt,strlen(l->prompt)); abAppend(&ab,l->buf,l->len); /* If we are at the very end of the screen with our prompt, we need to * emit a newline and move the prompt to the first column. */ if (l->pos && l->pos == l->len && (l->pos+plen) % l->cols == 0) { lndebug(""); abAppend(&ab,"\n",1); snprintf(seq,64,"\r"); abAppend(&ab,seq,strlen(seq)); rows++; if (rows > (int)l->maxrows) l->maxrows = rows; } /* Move cursor to right position. */ rpos2 = (plen+l->pos+l->cols)/l->cols; /* current cursor relative row. */ lndebug("rpos2 %d", rpos2); /* Go up till we reach the expected positon. */ if (rows-rpos2 > 0) { lndebug("go-up %d", rows-rpos2); snprintf(seq,64,"\x1b[%dA", rows-rpos2); abAppend(&ab,seq,strlen(seq)); } /* Set column. */ col = (plen+(int)l->pos) % (int)l->cols; lndebug("set col %d", 1+col); if (col) snprintf(seq,64,"\r\x1b[%dC", col); else snprintf(seq,64,"\r"); abAppend(&ab,seq,strlen(seq)); lndebug("\n"); l->oldpos = l->pos; if (write(fd,ab.b,ab.len) == -1) { /* Can't recover from write error. */ } abFree(&ab); } /* Calls the two low level functions refreshSingleLine() or * refreshMultiLine() according to the selected mode. */ static void refreshLine(struct linenoiseState *l) { if (mlmode) refreshMultiLine(l); else refreshSingleLine(l); } /* Insert the character 'c' at cursor current position. * * On error writing to the terminal -1 is returned, otherwise 0. */ static int edit_insert(struct linenoiseState *l, char c) { if (l->len < l->buflen) { if (l->len == l->pos) { l->buf[l->pos] = c; l->pos++; l->len++; l->buf[l->len] = '\0'; if ((!mlmode && l->plen+l->len < l->cols) /* || mlmode */) { /* Avoid a full update of the line in the * trivial case. */ if (write(l->ofd,&c,1) == -1) return -1; } else { refreshLine(l); } } else { memmove(l->buf+l->pos+1,l->buf+l->pos,l->len-l->pos); l->buf[l->pos] = c; l->len++; l->pos++; l->buf[l->len] = '\0'; refreshLine(l); } } return 0; } /* Move cursor on the left. */ static void edit_move_left(struct linenoiseState *l) { if (l->pos > 0) { l->pos--; refreshLine(l); } } /* Move cursor on the right. */ static void edit_move_right(struct linenoiseState *l) { if (l->pos != l->len) { l->pos++; refreshLine(l); } } /* Move cursor to the start of the line. */ static void edit_move_home(struct linenoiseState *l) { if (l->pos != 0) { l->pos = 0; refreshLine(l); } } /* Move cursor to the end of the line. */ static void edit_move_end(struct linenoiseState *l) { if (l->pos != l->len) { l->pos = l->len; refreshLine(l); } } /* Substitute the currently edited line with the next or previous history * entry as specified by 'dir'. */ #define LINENOISE_HISTORY_NEXT 0 #define LINENOISE_HISTORY_PREV 1 static void edit_history_next(struct linenoiseState *l, int dir) { if (history_len > 1) { /* Update the current history entry before to * overwrite it with the next one. */ free(history[history_len - 1 - l->history_index]); history[history_len - 1 - l->history_index] = strdup(l->buf); /* Show the new entry */ l->history_index += (dir == LINENOISE_HISTORY_PREV) ? 1 : -1; if (l->history_index < 0) { l->history_index = 0; return; } else if (l->history_index >= history_len) { l->history_index = history_len-1; return; } strncpy(l->buf,history[history_len - 1 - l->history_index],l->buflen); l->buf[l->buflen-1] = '\0'; l->len = l->pos = strlen(l->buf); refreshLine(l); } } /* Delete the character at the right of the cursor without altering the cursor * position. Basically this is what happens with the "Delete" keyboard key. */ static void edit_delete(struct linenoiseState *l) { if (l->len > 0 && l->pos < l->len) { memmove(l->buf+l->pos,l->buf+l->pos+1,l->len-l->pos-1); l->len--; l->buf[l->len] = '\0'; refreshLine(l); } } /* Backspace implementation. */ static void edit_backspace(struct linenoiseState *l) { if (l->pos > 0 && l->len > 0) { memmove(l->buf+l->pos-1,l->buf+l->pos,l->len-l->pos); l->pos--; l->len--; l->buf[l->len] = '\0'; refreshLine(l); } } /* Delete the previosu word, maintaining the cursor at the start of the * current word. */ static void edit_delete_prev_word(struct linenoiseState *l) { size_t old_pos = l->pos; size_t diff; while (l->pos > 0 && l->buf[l->pos-1] == ' ') l->pos--; while (l->pos > 0 && l->buf[l->pos-1] != ' ') l->pos--; diff = old_pos - l->pos; memmove(l->buf+l->pos,l->buf+old_pos,l->len-old_pos+1); l->len -= diff; refreshLine(l); } /* This function is the core of the line editing capability of linenoise. * It expects 'fd' to be already in "raw mode" so that every key pressed * will be returned ASAP to read(). * * The resulting string is put into 'buf' when the user type enter, or * when ctrl+d is typed. * * The function returns the length of the current buffer. */ static int edit(int stdin_fd, int stdout_fd, char *buf, size_t buflen, const char *prompt) { struct linenoiseState l; /* Populate the linenoise state that we pass to functions implementing * specific editing functionalities. */ l.ifd = stdin_fd; l.ofd = stdout_fd; l.buf = buf; l.buflen = buflen; l.prompt = prompt; l.plen = strlen(prompt); l.oldpos = l.pos = 0; l.len = 0; l.cols = getColumns(stdin_fd, stdout_fd); l.maxrows = 0; l.history_index = 0; /* Buffer starts empty. */ l.buf[0] = '\0'; l.buflen--; /* Make sure there is always space for the nulterm */ /* The latest history entry is always our current buffer, that * initially is just an empty string. */ add_history(""); if (write(l.ofd,prompt,l.plen) == -1) return -1; while(1) { char c; int nread; char seq[3]; nread = read(l.ifd,&c,1); if (nread <= 0) return l.len; switch(c) { case ENTER: /* enter */ history_len--; free(history[history_len]); if (mlmode) edit_move_end(&l); return (int)l.len; case CTRL_C: /* ctrl-c */ errno = EAGAIN; return -1; case BACKSPACE: /* backspace */ case 8: /* ctrl-h */ edit_backspace(&l); break; case CTRL_D: /* ctrl-d, remove char at right of cursor, or if the line is empty, act as end-of-file. */ if (l.len > 0) { edit_delete(&l); } else { history_len--; free(history[history_len]); return -1; } break; case CTRL_T: /* ctrl-t, swaps current character with previous. */ if (l.pos > 0 && l.pos < l.len) { int aux = buf[l.pos-1]; buf[l.pos-1] = buf[l.pos]; buf[l.pos] = aux; if (l.pos != l.len-1) l.pos++; refreshLine(&l); } break; case CTRL_B: /* ctrl-b */ edit_move_left(&l); break; case CTRL_F: /* ctrl-f */ edit_move_right(&l); break; case CTRL_P: /* ctrl-p */ edit_history_next(&l, LINENOISE_HISTORY_PREV); break; case CTRL_N: /* ctrl-n */ edit_history_next(&l, LINENOISE_HISTORY_NEXT); break; case ESC: /* escape sequence */ /* Read the next two bytes representing the escape sequence. * Use two calls to handle slow terminals returning the two * chars at different times. */ if (read(l.ifd,seq,1) == -1) break; if (read(l.ifd,seq+1,1) == -1) break; /* ESC [ sequences. */ if (seq[0] == '[') { if (seq[1] >= '0' && seq[1] <= '9') { /* Extended escape, read additional byte. */ if (read(l.ifd,seq+2,1) == -1) break; if (seq[2] == '~') { switch(seq[1]) { case '3': /* Delete key. */ edit_delete(&l); break; } } } else { switch(seq[1]) { case 'A': /* Up */ edit_history_next(&l, LINENOISE_HISTORY_PREV); break; case 'B': /* Down */ edit_history_next(&l, LINENOISE_HISTORY_NEXT); break; case 'C': /* Right */ edit_move_right(&l); break; case 'D': /* Left */ edit_move_left(&l); break; case 'H': /* Home */ edit_move_home(&l); break; case 'F': /* End*/ edit_move_end(&l); break; } } } /* ESC O sequences. */ else if (seq[0] == 'O') { switch(seq[1]) { case 'H': /* Home */ edit_move_home(&l); break; case 'F': /* End*/ edit_move_end(&l); break; } } break; default: if (edit_insert(&l,c)) return -1; break; case CTRL_U: /* Ctrl+u, delete the whole line. */ buf[0] = '\0'; l.pos = l.len = 0; refreshLine(&l); break; case CTRL_K: /* Ctrl+k, delete from current to end of line. */ buf[l.pos] = '\0'; l.len = l.pos; refreshLine(&l); break; case CTRL_A: /* Ctrl+a, go to the start of the line */ edit_move_home(&l); break; case CTRL_E: /* ctrl+e, go to the end of the line */ edit_move_end(&l); break; case CTRL_L: /* ctrl+l, clear screen */ readline_clear_screen(); refreshLine(&l); break; case CTRL_W: /* ctrl+w, delete previous word */ edit_delete_prev_word(&l); break; } } return l.len; } /* This special mode is used by linenoise in order to print scan codes * on screen for debugging / development purposes. It is implemented * by the linenoise_example program using the --keycodes option. */ void readline_print_keycodes(void) { char quit[4]; printf("Linenoise key codes debugging mode.\n" "Press keys to see scan codes. Type 'quit' at any time to exit.\n"); if (enableRawMode(STDIN_FILENO) == -1) return; memset(quit,' ',4); while(1) { char c; int nread; nread = read(STDIN_FILENO,&c,1); if (nread <= 0) continue; memmove(quit,quit+1,sizeof(quit)-1); /* shift string to left. */ quit[sizeof(quit)-1] = c; /* Insert current char on the right. */ if (memcmp(quit,"quit",sizeof(quit)) == 0) break; printf("'%c' %02x (%d) (type quit to exit)\n", isprint(c) ? c : '?', (int)c, (int)c); printf("\r"); /* Go left edge manually, we are in raw mode. */ fflush(stdout); } disableRawMode(STDIN_FILENO); } /* This function calls the line editing function edit() using * the STDIN file descriptor set in raw mode. */ static int linenoiseRaw(char *buf, size_t buflen, const char *prompt) { int count; if (buflen == 0) { errno = EINVAL; return -1; } if (!isatty(STDIN_FILENO)) { /* Not a tty: read from file / pipe. */ if (fgets(buf, buflen, stdin) == NULL) return -1; count = strlen(buf); if (count && buf[count-1] == '\n') { count--; buf[count] = '\0'; } } else { /* Interactive editing. */ if (enableRawMode(STDIN_FILENO) == -1) return -1; count = edit(STDIN_FILENO, STDOUT_FILENO, buf, buflen, prompt); disableRawMode(STDIN_FILENO); printf("\n"); } return count; } /* The high level function that is the main API of the linenoise library. * This function checks if the terminal has basic capabilities, just checking * for a blacklist of stupid terminals, and later either calls the line * editing function or uses dummy fgets() so that you will be able to type * something even in the most desperate of the conditions. */ char *readline(const char *prompt) { char buf[LINENOISE_MAX_LINE]; int count; if (isUnsupportedTerm()) { size_t len; printf("%s",prompt); fflush(stdout); if (fgets(buf,LINENOISE_MAX_LINE,stdin) == NULL) return NULL; len = strlen(buf); while(len && (buf[len-1] == '\n' || buf[len-1] == '\r')) { len--; buf[len] = '\0'; } return strdup(buf); } else { count = linenoiseRaw(buf,LINENOISE_MAX_LINE,prompt); if (count == -1) return NULL; return strdup(buf); } } /* ================================ History ================================= */ /* Free the history, but does not reset it. Only used when we have to * exit() to avoid memory leaks are reported by valgrind & co. */ static void freeHistory(void) { if (history) { int j; for (j = 0; j < history_len; j++) free(history[j]); free(history); } } /* At exit we'll try to fix the terminal to the initial conditions. */ static void linenoiseAtExit(void) { disableRawMode(STDIN_FILENO); freeHistory(); } /* This is the API call to add a new entry in the linenoise history. * It uses a fixed array of char pointers that are shifted (memmoved) * when the history max length is reached in order to remove the older * entry and make room for the new one, so it is not exactly suitable for huge * histories, but will work well for a few hundred of entries. * * Using a circular buffer is smarter, but a bit more complex to handle. */ void add_history(const char *line) { char *linecopy; if (history_max_len == 0) return; /* Initialization on first call. */ if (history == NULL) { history = malloc(sizeof(char*)*history_max_len); if (history == NULL) return; memset(history,0,(sizeof(char*)*history_max_len)); } /* Don't add duplicated lines. */ if (history_len && !strcmp(history[history_len-1], line)) return; /* Add an heap allocated copy of the line in the history. * If we reached the max length, remove the older line. */ linecopy = strdup(line); if (!linecopy) return; if (history_len == history_max_len) { free(history[0]); memmove(history,history+1,sizeof(char*)*(history_max_len-1)); history_len--; } history[history_len] = linecopy; history_len++; } /* Set the maximum length for the history. This function can be called even * if there is already some history, the function will make sure to retain * just the latest 'len' elements if the new history length value is smaller * than the amount of items already inside the history. */ int history_set_length(int len) { char **new; if (len < 1) return 0; if (history) { int tocopy = history_len; new = malloc(sizeof(char*)*len); if (new == NULL) return 0; /* If we can't copy everything, free the elements we'll not use. */ if (len < tocopy) { int j; for (j = 0; j < tocopy-len; j++) free(history[j]); tocopy = len; } memset(new,0,sizeof(char*)*len); memcpy(new,history+(history_len-tocopy), sizeof(char*)*tocopy); free(history); history = new; } history_max_len = len; if (history_len > history_max_len) history_len = history_max_len; return 1; } /* Save the history in the specified file. On success 0 is returned * otherwise -1 is returned. */ int write_history(const char *filename) { FILE *fp = fopen(filename,"w"); int j; if (fp == NULL) return -1; for (j = 0; j < history_len; j++) fprintf(fp,"%s\n",history[j]); fclose(fp); return 0; } /* Load the history from the specified file. If the file does not exist * zero is returned and no operation is performed. * * If the file exists and the operation succeeded 0 is returned, otherwise * on error -1 is returned. */ int read_history(const char *filename) { FILE *fp = fopen(filename,"r"); char buf[LINENOISE_MAX_LINE]; if (fp == NULL) return -1; while (fgets(buf,LINENOISE_MAX_LINE,fp) != NULL) { char *p; p = strchr(buf,'\r'); if (!p) p = strchr(buf,'\n'); if (p) *p = '\0'; add_history(buf); } fclose(fp); return 0; } ================================================ FILE: lib/libtcl/Makefile ================================================ TOPSRC!=cd ../..; pwd include ${TOPSRC}/share/mk/sys.mk CFLAGS += ${DEFS} -Os -Wall -Wno-pointer-sign CFLAGS += -DTCL_FILE_CMDS -DTCL_ENV_CMDS OBJS = tclget.o tclproc.o tclvar.o tclassem.o \ tclcmdah.o tclcmdmz.o tclhash.o tclparse.o \ tclcmdil.o tclbasic.o tclexpr.o tclutil.o \ regexp.o regsub.o tclenv.o tclglob.o \ tclunxaz.o tcluxstr.o tcluxutl.o all: ../libtcl.a ../libtcl.a: ${OBJS} ${AR} cr $@ ${OBJS} $(RANLIB) $@ install: all clean: rm -f ../libtcl.a *.o *~ ### regexp.o: regexp.c regexp.h regpriv.h regsub.o: regsub.c regexp.h regpriv.h tclassem.o: tclassem.c internal.h hash.h tclbasic.o: tclbasic.c internal.h hash.h tclcmdah.o: tclcmdah.c internal.h hash.h tclcmdil.o: tclcmdil.c internal.h hash.h tclcmdmz.o: tclcmdmz.c internal.h hash.h regexp.h regpriv.h tclenv.o: tclenv.c internal.h hash.h tclexpr.o: tclexpr.c internal.h hash.h tclget.o: tclget.c internal.h hash.h tclglob.o: tclglob.c internal.h hash.h tclhash.o: tclhash.c internal.h hash.h tclparse.o: tclparse.c internal.h hash.h tclproc.o: tclproc.c internal.h hash.h tclunxaz.o: tclunxaz.c internal.h hash.h tclutil.o: tclutil.c internal.h hash.h regexp.h tcluxstr.o: tcluxstr.c internal.h hash.h tcluxutl.o: tcluxutl.c internal.h hash.h tclvar.o: tclvar.c internal.h hash.h ================================================ FILE: lib/libtcl/doc/AddErrInfo.3 ================================================ '\" '\" Copyright 1989 Regents of the University of California '\" Permission to use, copy, modify, and distribute this '\" documentation for any purpose and without fee is hereby '\" granted, provided that this notice appears in all copies. '\" The University of California makes no representations about '\" the suitability of this material for any purpose. It is '\" provided "as is" without express or implied warranty. '\" '\" $Header: /cvsroot/PROCPLACE/pptinytcl/doc/AddErrInfo.3,v 1.1.1.1 2001/04/20 15:03:06 karl Exp $ SPRITE (Berkeley) '\" .so man.macros .HS Tcl_AddErrorInfo tcl .BS .SH NAME Tcl_AddErrorInfo, Tcl_SetErrorCode, Tcl_UnixError, Tcl_CheckStatus \- record information about errors .SH SYNOPSIS .nf \fB#include \fR .sp char * \fBTcl_AddErrorInfo\fR(\fIinterp, message\fR) .sp .VS void \fBTcl_SetErrorCode\fR(\fIinterp, element, element, ...\fR) .sp char * \fBTcl_UnixError\fR(\fIinterp\fR) .VE .SH ARGUMENTS .AS Tcl_Interp *message .AP Tcl_Interp *interp in Interpreter in which to record information. .AP char *message in Identifying string to record in \fBerrorInfo\fR variable. .AP char *element in .VS String to record as one element of \fBerrorCode\fR variable. Last \fIelement\fR argument must be NULL. .VE .BE .SH DESCRIPTION .PP .VS These procedures are used to manipulate two global variables that hold information about errors. The variable \fBerrorInfo\fR holds a stack trace of the operations that were in progress when an error occurred, and is intended to be human-readable. The variable \fBerrorCode\fR holds a list of items that are intended to be machine-readable. The first item in \fBerrorCode\fR identifies the class of error that occurred (e.g. UNIX means an error occurred in a Unix system call) and additional elements in \fBerrorCode\fR hold additional pieces of information that depend on the class. See the Tcl overview manual entry for details on the various formats for \fBerrorCode\fR. .PP The \fBerrorInfo\fR variable is gradually built up as an error unwinds through the nested operations. Each time an error code is returned to \fBTcl_Eval\fR it calls the procedure \fBTcl_AddErrorInfo\fR to add additional text to \fBerrorInfo\fR describing the command that was being executed when the error occurred. By the time the error has been passed all the way back to the application, it will contain a complete trace of the activity in progress when the error occurred. .PP It is sometimes useful to add additional information to \fBerrorInfo\fR beyond what can be supplied automatically by \fBTcl_Eval\fR. \fBTcl_AddErrorInfo\fR may be used for this purpose: its \fImessage\fR argument contains an additional string to be appended to \fBerrorInfo\fR. For example, the \fBsource\fR command calls \fBTcl_AddErrorInfo\fR to record the name of the file being processed and the line number on which the error occurred; for Tcl procedures, the procedure name and line number within the procedure are recorded, and so on. The best time to call \fBTcl_AddErrorInfo\fR is just after \fBTcl_Eval\fR has returned \fBTCL_ERROR\fR. In calling \fBTcl_AddErrorInfo\fR, you may find it useful to use the \fBerrorLine\fR field of the interpreter (see the \fBTcl_Interp\fR manual entry for details). .PP The procedure \fBTcl_SetErrorCode\fR is used to set the \fBerrorCode\fR variable. Its \fIelement\fR arguments give one or more strings to record in \fBerrorCode\fR: each \fIelement\fR will become one item of a properly-formed Tcl list stored in \fBerrorCode\fR. \fBTcl_SetErrorCode\fR is typically invoked just before returning an error. If an error is returned without calling \fBTcl_SetErrorCode\fR then the Tcl interpreter automatically sets \fBerrorCode\fR to \fBNONE\fR. .PP \fBTcl_UnixError\fR sets the \fBerrorCode\fR variable after an error in a UNIX kernel call. It reads the value of the \fBerrno\fR C variable and calls \fBTcl_SetErrorCode\fR to set \fBerrorCode\fR in the \fBUNIX\fR format. In addition, \fBTcl_UnixError\fR returns a human-readable diagnostic message for the error (this is the same value that will appear as the third element in \fBerrorCode\fR). It may be convenient to include this string as part of the error message returned to the application in \fIinterp->result\fR. .PP It is important to call the procedures described here rather than setting \fBerrorInfo\fR or \fBerrorCode\fR directly with \fBTcl_SetVar\fR. The reason for this is that the Tcl interpreter keeps information about whether these procedures have been called. For example, the first time \fBTcl_AppendResult\fR is called for an error, it clears the existing value of \fBerrorInfo\fR and adds the error message in \fIinterp->result\fR to the variable before appending \fImessage\fR; in subsequent calls, it just appends the new \fImessage\fR. When \fBTcl_SetErrorCode\fR is called, it sets a flag indicating that \fBerrorCode\fR has been set; this allows the Tcl interpreter to set \fBerrorCode\fR to \fBNONE\fB if it receives an error return when \fBTcl_SetErrorCode\fR hasn't been called. .PP If the procedure \fBTcl_ResetResult\fR is called, it clears all of the state associated with \fBerrorInfo\fR and \fBerrorCode\fR (but it doesn't actually modify the variables). If an error had occurred, this will clear the error state to make it appear as if no error had occurred after all. .VE .SH "SEE ALSO" Tcl_ResetResult, Tcl_Interp .SH KEYWORDS error, stack, trace, variable ================================================ FILE: lib/libtcl/doc/AssembCmd.3 ================================================ '\" '\" Copyright 1989-1992 Regents of the University of California '\" Permission to use, copy, modify, and distribute this '\" documentation for any purpose and without fee is hereby '\" granted, provided that this notice appears in all copies. '\" The University of California makes no representations about '\" the suitability of this material for any purpose. It is '\" provided "as is" without express or implied warranty. '\" '\" $Header: /cvsroot/PROCPLACE/pptinytcl/doc/AssembCmd.3,v 1.1.1.1 2001/04/20 15:03:06 karl Exp $ SPRITE (Berkeley) '\" .so man.macros .HS Tcl_AssembleCmd tcl .BS .SH NAME Tcl_CreateCmdBuf, Tcl_AssembleCmd, Tcl_DeleteCmdBuf \- buffer pieces of Tcl commands .SH SYNOPSIS .nf \fB#include \fR .sp Tcl_CmdBuf \fBTcl_CreateCmdBuf\fR() .sp \fBTcl_DeleteCmdBuf\fR(\fIbuffer\fR) .sp char * .VS \fBTcl_AssembleCmd\fR(\fIbuffer\fR, \fIstring\fR) .VE .sp int \fBTcl_CommandComplete\fR(\fIcmd\fR) .SH ARGUMENTS .AS Tcl_CmdBuf *string; .AP Tcl_CmdBuf buffer in Token for a command buffer (the result of some previous call to \fBTcl_CreateCmdBuf\fR). .AP char *string in Additional piece of command input to be added to anything currently buffered. .AP char *cmd in .VS Command string to test for completeness. .VE .BE .SH DESCRIPTION .PP These procedures provide a convenient mechanism for assembling Tcl commands from an input source where command boundaries are not obvious. For example, if input is being read from a terminal, a user may type commands that span multiple lines. In situations like this, \fBTcl_AssembleCmd\fR can be called with the individual lines as they are received. It buffers the lines internally and returns full commands when they are complete. .PP A command buffer is created by calling \fBTcl_CreateCmdBuf\fR, and it is deleted by calling \fBTcl_DeleteCmdBuf\fR. There may be any number of command buffers for a particular program or even for a particular interpreter; in most cases there should be one buffer for each independent source of command input. .PP When input arrives from a source you should call \fBTcl_AssembleCmd\fR, passing it the new input as the \fIstring\fR argument. \fBTcl_AssembleCmd\fR will add the new input to anything currently buffered in \fIbuffer\fR. If the information now buffered represents a complete Tcl command (i.e. there are no unclosed quotes, braces, brackets, or variable references), then \fBTcl_AssembleCmd\fR returns a pointer to the complete command and arranges for the buffer to be cleared on the next call to \fBTcl_AssembleCmd\fR. If the command is still incomplete (because, for example, there are unmatched braces) then \fBTcl_AssembleCmd\fR returns NULL. \fBTcl_AssembleCmd\fR keeps a private copy of the command being assembled, so that the caller need not preserve the contents of \fIstring\fR between calls to \fBTcl_AssembleCmd\fR. \fBTcl_AssembleCmd\fR supports commands of arbitrary length (up to the total memory limit imposed by the operating system, if any). .PP .VS The procedure \fBTcl_CommandComplete\fR takes a Tcl command string as argument and determines whether the command string is complete in the sense defined above. If so then it returns 1; otherwise it returns 0. .VE .SH KEYWORDS assemble, buffer, partial command ================================================ FILE: lib/libtcl/doc/Backslash.3 ================================================ '\" '\" Copyright 1989 Regents of the University of California '\" Permission to use, copy, modify, and distribute this '\" documentation for any purpose and without fee is hereby '\" granted, provided that this notice appears in all copies. '\" The University of California makes no representations about '\" the suitability of this material for any purpose. It is '\" provided "as is" without express or implied warranty. '\" '\" $Header: /cvsroot/PROCPLACE/pptinytcl/doc/Backslash.3,v 1.1.1.1 2001/04/20 15:03:06 karl Exp $ SPRITE (Berkeley) '\" .so man.macros .HS Tcl_Backslash tcl .BS .SH NAME Tcl_Backslash \- parse a backslash sequence .SH SYNOPSIS .nf \fB#include \fR .sp char \fBTcl_Backslash\fR(\fIsrc, countPtr\fR) .SH ARGUMENTS .AS char *countPtr .AP char *src in Pointer to a string starting with a backslash. .AP int *countPtr out If \fIcountPtr\fR isn't NULL, \fI*countPtr\fR gets filled in with number of characters in the backslash sequence, including the backslash character. .BE .SH DESCRIPTION .PP This is a utility procedure used by several of the Tcl commands. It parses a backslash sequence and returns the single character corresponding to the sequence. .VS If the backslash sequence should be replaced by no character at all (e.g. backslash-newline) then \fBTcl_Backslash\fR returns 0. .VE \fBTcl_Backslash\fR modifies \fI*countPtr\fR to contain the number of characters in the backslash sequence. If \fIsrc\fR doesn't point to a backslash sequence understood by Tcl, then Tcl_Backslash returns a backslash as its result and \fI*countPtr\fR gets set to 1 (in this case the backslash character should not get any special treatment). .PP See the Tcl manual entry for information on the valid backslash sequences. .VS All of the sequences described in the Tcl manual entry are supported by \fBTcl_Backslash\fR. .VE .SH KEYWORDS backslash, parse ================================================ FILE: lib/libtcl/doc/Concat.3 ================================================ '\" '\" Copyright 1989 Regents of the University of California '\" Permission to use, copy, modify, and distribute this '\" documentation for any purpose and without fee is hereby '\" granted, provided that this notice appears in all copies. '\" The University of California makes no representations about '\" the suitability of this material for any purpose. It is '\" provided "as is" without express or implied warranty. '\" '\" $Header: /cvsroot/PROCPLACE/pptinytcl/doc/Concat.3,v 1.1.1.1 2001/04/20 15:03:06 karl Exp $ SPRITE (Berkeley) '\" .so man.macros .HS Tcl_Concat tcl .BS .SH NAME Tcl_Concat \- concatenate a collection of strings .SH SYNOPSIS .nf \fB#include \fR .sp char * \fBTcl_Concat\fR(\fIargc, argv\fR) .SH ARGUMENTS .AP int argc in Number of strings. .AP char *argv[] in Array of strings to concatenate. Must have \fIargc\fR entries. .BE .SH DESCRIPTION .PP \fBTcl_Concat\fR is a utility procedure used by several of the Tcl commands. Given a collection of strings, it concatenates them together into a single string, with the original strings separated by spaces. This procedure behaves differently than \fBTcl_Merge\fR, in that the arguments are simply concatenated: no effort is made to ensure proper list structure. .VS However, in most common usage the arguments will all be proper lists themselves; if this is true, then the result will also have proper list structure. .PP \fBTcl_Concat\fR eliminates leading and trailing white space as it copies strings from \fBargv\fR to the result. If an element of \fBargv\fR consists of nothing but white space, then that string is ignored entirely. This white-space removal was added to make the output of the \fBconcat\fR command cleaner-looking. .VE .PP The result string is dynamically allocated using \fBmalloc()\fR; the caller must eventually release the space by calling \fBfree()\fR. .SH KEYWORDS concatenate, strings ================================================ FILE: lib/libtcl/doc/CrtCommand.3 ================================================ '\" '\" Copyright 1989 Regents of the University of California '\" Permission to use, copy, modify, and distribute this '\" documentation for any purpose and without fee is hereby '\" granted, provided that this notice appears in all copies. '\" The University of California makes no representations about '\" the suitability of this material for any purpose. It is '\" provided "as is" without express or implied warranty. '\" '\" $Header: /cvsroot/PROCPLACE/pptinytcl/doc/CrtCommand.3,v 1.1.1.1 2001/04/20 15:03:06 karl Exp $ SPRITE (Berkeley) '\" .so man.macros .HS Tcl_CreateCommand tcl .BS .SH NAME Tcl_CreateCommand, Tcl_DeleteCommand \- define application-specific command bindings .SH SYNOPSIS .nf \fB#include \fR .sp \fBTcl_CreateCommand\fR(\fIinterp, cmdName, proc, clientData, deleteProc\fR) .sp int \fBTcl_DeleteCommand\fR(\fIinterp, cmdName\fR) .SH ARGUMENTS .AS Tcl_CmdDeleteProc (*deleteProc)() .AP Tcl_Interp *interp in Interpreter in which to create new command. .AP char *cmdName in Name of command to create or delete. .AP Tcl_CmdProc *proc in Implementation of new command: \fIproc\fR will be called whenever \fIcmdName\fR is invoked as a command. .AP ClientData clientData in Arbitrary one-word value to pass to \fIproc\fR and \fIdeleteProc\fR. .AP Tcl_CmdDeleteProc *deleteProc in Procedure to call before \fIcmdName\fR is deleted from the interpreter; allows for command-specific cleanup. If NULL, then no procedure is called before the command is deleted. .BE .SH DESCRIPTION .PP \fBTcl_CreateCommand\fR defines a new command in \fIinterp\fR and associates it with procedure \fIproc\fR such that whenever \fIcmdName\fR is invoked as a Tcl command (via a call to \fBTcl_Eval\fR) the Tcl interpreter will call \fIproc\fR to process the command. If there is already a command \fIcmdName\fR associated with the interpreter, it is deleted. \fIProc\fP should have arguments and result that match the type \fBTcl_CmdProc\fR: .nf .RS typedef int Tcl_CmdProc( .RS ClientData \fIclientData\fR, Tcl_Interp *\fIinterp\fR, int \fIargc\fR, char *\fIargv\fR[]); .RE .RE .fi When \fIproc\fR is invoked the \fIclientData\fP and \fIinterp\fR parameters will be copies of the \fIclientData\fP and \fIinterp\fR arguments given to \fBTcl_CreateCommand\fR. Typically, \fIclientData\fR points to an application-specific data structure that describes what to do when the command procedure is invoked. \fIArgc\fR and \fIargv\fR describe the arguments to the command, \fIargc\fR giving the number of arguments (including the command name) and \fIargv\fR giving the values of the arguments as strings. The \fIargv\fR array will contain \fIargc\fR+1 values; the first \fIargc\fR values point to the argument strings, and the last value is NULL. .PP \fIProc\fR must return an integer code that is either \fBTCL_OK\fR, \fBTCL_ERROR\fR, \fBTCL_RETURN\fR, \fBTCL_BREAK\fR, or \fBTCL_CONTINUE\fR. See the Tcl overview man page for details on what these codes mean. Most normal commands will only return \fBTCL_OK\fR or \fBTCL_ERROR\fR. In addition, \fIproc\fR must set \fIinterp->result\fR to point to a string value; in the case of a \fBTCL_OK\fR return code this gives the result of the command, and in the case of \fBTCL_ERROR\fR it gives an error message. The \fBTcl_SetResult\fR procedure provides an easy interface for setting the return value; for complete details on how the \fIinterp->result\fR field is managed, see the \fBTcl_Interp\fR man page. Before invoking a command procedure, \fBTcl_Eval\fR sets \fIinterp->result\fR to point to an empty string, so simple commands can return an empty result by doing nothing at all. .PP The contents of the \fIargv\fR array are copies made by the Tcl interpreter for the use of \fIproc\fR. \fIProc\fR may alter any of the strings in \fIargv\fR. However, the \fIargv\fR array is recycled as soon as \fIproc\fR returns, so \fIproc\fR must not set \fIinterp->result\fR to point anywhere within the \fIargv\fR values (call Tcl_SetResult with status \fBTCL_VOLATILE\fR if you want to return something from the \fIargv\fR array). .PP \fIDeleteProc\fR will be invoked when (if) \fIcmdName\fR is deleted. This can occur through a call to \fBTcl_DeleteCommand\fR or \fBTcl_DeleteInterp\fR, or by replacing \fIcmdName\fR in another call to Tcl_CreateCommand. \fIDeleteProc\fR is invoked before the command is deleted, and gives the application an opportunity to release any structures associated with the command. \fIDeleteProc\fR should have arguments and result that match the type \fBTcl_CmdDeleteProc\fR: .nf .RS .sp typedef void Tcl_CmdDeleteProc(ClientData \fIclientData\fR); .sp .RE .fi The \fIclientData\fR argument will be the same as the \fIclientData\fR argument passed to \fBTcl_CreateCommand\fR. .PP \fBTcl_DeleteCommand\fR deletes a command from a command interpreter. Once the call completes, attempts to invoke \fIcmdName\fR in \fIinterp\fR will result in errors. If \fIcmdName\fR isn't bound as a command in \fIinterp\fR then \fBTcl_DeleteCommand\fR does nothing and returns -1; otherwise it returns 0. There are no restrictions on \fIcmdName\fR: it may refer to a built-in command, an application-specific command, or a Tcl procedure. .SH KEYWORDS bind, command, create, delete, interpreter ================================================ FILE: lib/libtcl/doc/CrtInterp.3 ================================================ '\" '\" Copyright 1989 Regents of the University of California '\" Permission to use, copy, modify, and distribute this '\" documentation for any purpose and without fee is hereby '\" granted, provided that this notice appears in all copies. '\" The University of California makes no representations about '\" the suitability of this material for any purpose. It is '\" provided "as is" without express or implied warranty. '\" '\" $Header: /cvsroot/PROCPLACE/pptinytcl/doc/CrtInterp.3,v 1.1.1.1 2001/04/20 15:03:06 karl Exp $ SPRITE (Berkeley) '\" .so man.macros .HS Tcl_CreateInterp tcl .BS .SH NAME Tcl_CreateInterp, Tcl_DeleteInterp \- create and delete Tcl command interpreters .SH SYNOPSIS .nf \fB#include \fR .sp Tcl_Interp * \fBTcl_CreateInterp\fR() .sp \fBTcl_DeleteInterp\fR(\fIinterp\fR) .SH ARGUMENTS .AS Tcl_Interp *interp .AP Tcl_Interp *interp in Token for interpreter to be destroyed. .BE .SH DESCRIPTION .PP \fBTcl_CreateInterp\fR creates a new interpreter structure and returns a token for it. The token is required in calls to most other Tcl procedures, such as \fBTcl_CreateCommand\fR, \fBTcl_Eval\fR, and \fBTcl_DeleteInterp\fR. Clients are only allowed to access a few of the fields of Tcl_Interp structures; see the Tcl_Interp and \fBTcl_CreateCommand\fR man pages for details. The new interpreter is initialized with no defined variables and only the built-in Tcl commands. To bind in additional commands, call \fBTcl_CreateCommand\fR. .PP \fBTcl_DeleteInterp\fR destroys a command interpreter and releases all of the resources associated with it, including variables, procedures, and application-specific command bindings. After \fBTcl_DeleteInterp\fR returns the caller should never again use the \fIinterp\fR token. .SH KEYWORDS command, create, delete, interpreter ================================================ FILE: lib/libtcl/doc/CrtPipelin.3 ================================================ '\" '\" Copyright 1989 Regents of the University of California '\" Permission to use, copy, modify, and distribute this '\" documentation for any purpose and without fee is hereby '\" granted, provided that this notice appears in all copies. '\" The University of California makes no representations about '\" the suitability of this material for any purpose. It is '\" provided "as is" without express or implied warranty. '\" '\" $Header: /cvsroot/PROCPLACE/pptinytcl/doc/CrtPipelin.3,v 1.1.1.1 2001/04/20 15:03:06 karl Exp $ SPRITE (Berkeley) '\" .so man.macros .HS Tcl_CreatePipeline tcl .VS .BS .SH NAME Tcl_CreatePipeline \- create one or more child processes, with I/O redirection .SH SYNOPSIS .nf \fB#include \fR .sp int \fBTcl_CreatePipeline\fR(\fIinterp, argc, argv, pidArrayPtr, inPipePtr, outPipePtr, errFilePtr\fR) .SH ARGUMENTS .AS Tcl_Interp **pidArrayPtr .AP Tcl_Interp *interp in Interpreter to use for error reporting. .AP int argc in Number of strings in \fIargv\fR array. .AP char **argv in Array of strings describing command(s) and I/O redirection. .AP int **pidArrayPtr out The value at \fI*pidArrayPtr\fR is modified to hold a pointer to an array of process identifiers. The array is dynamically allocated and must be freed by the caller. .AP char *inPipePtr out If this argument is NULL then standard input for the first command in the pipeline comes from the current standard input. If \fIinPipePtr\fR is not NULL then \fBTcl_CreatePipeline\fR will create a pipe, arrange for it to be used for standard input to the first command, and store a file id for writing to that pipe at \fI*inPipePtr\fR. If the command specified its own input using redirection, then no pipe is created and -1 is stored at \fI*inPipePtr\fR. .AP char *outPipePtr out If this argument is NULL then standard output for the last command in the pipeline goes to the current standard output. If \fIoutPipePtr\fR is not NULL then \fBTcl_CreatePipeline\fR will create a pipe, arrange for it to be used for standard output from the last command, and store a file id for reading from that pipe at \fI*outPipePtr\fR. If the command specified its own output using redirection then no pipe is created and -1 is stored at \fI*outPipePtr\fR. .AP char *errFilePtr out If this argument is NULL then error output for all the commands in the pipeline will go to the current standard error file. If \fIerrFilePtr\fR is not NULL, error output from all the commands in the pipeline will go to a temporary file created by \fBTcl_CreatePipeline\fR. A file id to read from that file will be stored at \fI*errFilePtr\fR. The file will already have been removed, so closing the file descriptor at \fI*errFilePtr\fR will cause the file to be flushed completely. .BE .SH DESCRIPTION .PP \fBTcl_CreatePipeline\fR processes the \fIargv\fR array and sets up one or more child processes in a pipeline configuration. \fBTcl_CreatePipeline\fR handles pipes specified with ``|'', input redirection specified with ``<'' or ``<<'', and output redirection specified with ``>''; see the documentation for the \fBexec\fR command for details on these specifications. The return value from \fBTcl_CreatePipeline\fR is a count of the number of child processes created; the process identifiers for those processes are stored in a \fImalloc\fR-ed array and a pointer to that array is stored at \fI*pidArrayPtr\fR. It is the caller's responsibility to free the array when finished with it. .PP If the \fIinPipePtr\fR, \fIoutPipePtr\fR, and \fIerrFilePtr\fR arguments are NULL then the pipeline's standard input, standard output, and standard error are taken from the corresponding streams of the process. Non-NULL values may be specified for these arguments to use pipes for standard input and standard output and a file for standard error. \fBTcl_CreatePipeline\fR will create the requested pipes or file and return file identifiers that may be used to read or write them. It is the caller's responsibility to close all of these files when they are no longer needed. If \fIargv\fR specifies redirection for standard input or standard output, then pipes will not be created even if requested by the \fIinPipePtr\fR and \fIoutPipePtr\fR arguments. .PP If an error occurs in \fBTcl_CreatePipeline\fR (e.g. ``|'' or ``<'' was the last argument in \fIargv\fR, or it wasn't possible to fork off a child), then -1 is returned and \fIinterp->result\fR is set to an error message. .SH "SEE ALSO" \fBTcl_WaitPids\fR, \fBTcl_DetachPids\fR .SH KEYWORDS background, child, detach, fork, process, status, wait .VE ================================================ FILE: lib/libtcl/doc/CrtTrace.3 ================================================ '\" '\" Copyright 1989 Regents of the University of California '\" Permission to use, copy, modify, and distribute this '\" documentation for any purpose and without fee is hereby '\" granted, provided that this notice appears in all copies. '\" The University of California makes no representations about '\" the suitability of this material for any purpose. It is '\" provided "as is" without express or implied warranty. '\" '\" $Header: /cvsroot/PROCPLACE/pptinytcl/doc/CrtTrace.3,v 1.1.1.1 2001/04/20 15:03:06 karl Exp $ SPRITE (Berkeley) '\" .so man.macros .HS Tcl_CreateTrace tcl .BS .SH NAME Tcl_CreateTrace, Tcl_DeleteTrace \- arrange for command execution to be traced .SH SYNOPSIS .nf \fB#include \fR .sp Tcl_Trace \fBTcl_CreateTrace\fR(\fIinterp, level, proc, clientData\fR) .sp \fBTcl_DeleteTrace\fR(\fIinterp, trace\fR) .SH ARGUMENTS .AS Tcl_CmdTraceProc (clientData)() .AP Tcl_Interp *interp in Interpreter containing command to be traced or untraced. .AP int level in Only commands at or below this nesting level will be traced. 1 means top-level commands only, 2 means top-level commands or those that are invoked as immediate consequences of executing top-level commands (procedure bodies, bracketed commands, etc.) and so on. .AP Tcl_CmdTraceProc *proc in Procedure to call for each command that's executed. See below for details on the calling sequence. .AP ClientData clientData in Arbitrary one-word value to pass to \fIproc\fR. .AP Tcl_Trace trace in Token for trace to be removed (return value from previous call to \fBTcl_CreateTrace\fR). .BE .SH DESCRIPTION .PP \fBTcl_CreateTrace\fR arranges for command tracing. From now on, \fIproc\fR will be invoked before Tcl calls command procedures to process commands in \fIinterp\fR. The return value from \fBTcl_CreateTrace\fR is a token for the trace, which may be passed to \fBTcl_DeleteTrace\fR to remove the trace. There may be many traces in effect simultaneously for the same command interpreter. .PP \fIProc\fR should have arguments and result that match the type \fBTcl_CmdTraceProc\fR: .nf .sp .RS typedef void Tcl_CmdTraceProc( .RS ClientData \fIclientData\fR, Tcl_Interp *\fIinterp\fR, int \fIlevel\fR, char *\fIcommand\fR, Tcl_CmdProc *\fIcmdProc\fR, ClientData \fIcmdClientData\fR, int \fIargc\fR, char *\fIargv\fR[])); .sp .RE .RE .fi The \fIclientData\fP and \fIinterp\fP parameters are copies of the corresponding arguments given to \fBTcl_CreateTrace\fR. \fIClientData\fR typically points to an application-specific data structure that describes what to do when \fIproc\fR is invoked. \fILevel\fR gives the nesting level of the command (1 for top-level commands passed to \fBTcl_Eval\fR by the application, 2 for the next-level commands passed to \fBTcl_Eval\fR as part of parsing or interpreting level-1 commands, and so on). \fICommand\fR points to a string containing the text of the command, before any argument substitution. \fICmdProc\fR contains the address of the command procedure that will be called to process the command (i.e. the \fIproc\fR argument of some previous call to \fBTcl_CreateCommand\fR) and \fIcmdClientData\fR contains the associated client data for \fIcmdProc\fR (the \fIclientData\fR value passed to \fBTcl_CreateCommand\fR). \fIArgc\fR and \fIargv\fR give the final argument information that will be passed to \fIcmdProc\fR, after command, variable, and backslash substitution. \fIProc\fR must not modify the \fIcommand\fR or \fIargv\fR strings. .PP Tracing will only occur for commands at nesting level less than or equal to the \fIlevel\fR parameter (i.e. the \fIlevel\fR parameter to \fIproc\fR will always be less than or equal to the \fIlevel\fR parameter to \fBTcl_CreateTrace\fR). .PP Calls to \fIproc\fR will be made by the Tcl parser immediately before it calls the command procedure for the command (\fIcmdProc\fR). This occurs after argument parsing and substitution, so tracing for substituted commands occurs before tracing of the commands containing the substitutions. If there is a syntax error in a command, or if there is no command procedure associated with a command name, then no tracing will occur for that command. If a string passed to Tcl_Eval contains multiple commands (bracketed, or on different lines) then multiple calls to \fIproc\fR will occur, one for each command. The \fIcommand\fR string for each of these trace calls will reflect only a single command, not the entire string passed to Tcl_Eval. .PP \fBTcl_DeleteTrace\fR removes a trace, so that no future calls will be made to the procedure associated with the trace. After \fBTcl_DeleteTrace\fR returns, the caller should never again use the \fItrace\fR token. .SH KEYWORDS command, create, delete, interpreter, trace ================================================ FILE: lib/libtcl/doc/Eval.3 ================================================ '\" '\" Copyright 1989 Regents of the University of California '\" Permission to use, copy, modify, and distribute this '\" documentation for any purpose and without fee is hereby '\" granted, provided that this notice appears in all copies. '\" The University of California makes no representations about '\" the suitability of this material for any purpose. It is '\" provided "as is" without express or implied warranty. '\" '\" $Header: /cvsroot/PROCPLACE/pptinytcl/doc/Eval.3,v 1.1.1.1 2001/04/20 15:03:06 karl Exp $ SPRITE (Berkeley) '\" .so man.macros .HS Tcl_Eval tcl .BS .SH NAME Tcl_Eval, Tcl_VarEval, Tcl_EvalFile, Tcl_GlobalEval \- execute Tcl commands .SH SYNOPSIS .nf \fB#include \fR .sp int \fBTcl_Eval\fR(\fIinterp, cmd, flags, termPtr\fR) .sp int \fBTcl_VarEval\fR(\fIinterp, string, string, ... \fB(char *) NULL\fR) .sp int \fBTcl_EvalFile\fR(\fIinterp, fileName\fR) .sp .VS int \fBTcl_GlobalEval\fR(\fIinterp, cmd\fR) .VE .SH ARGUMENTS .AS Tcl_Interp **termPtr; .AP Tcl_Interp *interp in Interpreter in which to execute the command. String result will be stored in \fIinterp->result\fR. .AP char *cmd in Command (or sequence of commands) to execute. Must be in writable memory (Tcl_Eval makes temporary modifications to the command). .AP int flags in Either \fBTCL_BRACKET_TERM\fR or 0. If 0, then \fBTcl_Eval\fR will process commands from \fIcmd\fR until it reaches the null character at the end of the string. If \fBTCL_BRACKET_TERM\fR, then \fBTcl_Eval\fR will process comands from \fIcmd\fR until either it reaches a null character or it encounters a close bracket that isn't backslashed or enclosed in braces, at which point it will return. Under normal conditions, \fIflags\fR should be 0. .AP char **termPtr out If \fItermPtr\fR is non-NULL, \fBTcl_Eval\fR fills in *\fItermPtr\fR with the address of the character just after the last one in the last command successfully executed (normally the null character at the end of \fIcmd\fR). If an error occurs in the first command in \fIcmd\fR, then \fI*termPtr\fR will be set to \fIcmd\fR. .AP char *string in String forming part of Tcl command. .AP char *fileName in Name of file containing Tcl command string. .BE .SH DESCRIPTION .PP All four of these procedures execute Tcl commands. \fBTcl_Eval\fR is the core procedure: it parses commands from \fIcmd\fR and executes them in order until either an error occurs or \fBTcl_Eval\fR reaches a terminating character (']' or '\e0', depending on the value of \fIflags\fR). The return value from \fBTcl_Eval\fR is one of the Tcl return codes \fBTCL_OK\fR, \fBTCL_ERROR\fR, \fBTCL_RETURN\fR, \fBTCL_BREAK\fR, or \fBTCL_CONTINUE\fR, and \fIinterp->result\fR will point to a string with additional information (result value or error message). This return information corresponds to the last command executed from \fIcmd\fR. .PP \fBTcl_VarEval\fR takes any number of string arguments of any length, concatenates them into a single string, then calls \fBTcl_Eval\fR to execute that string as a Tcl command. It returns the result of the command and also modifies \fIinterp->result\fR in the usual fashion for Tcl commands. The last argument to \fBTcl_VarEval\fR must be NULL to indicate the end of arguments. .PP \fBTcl_EvalFile\fR reads the file given by \fIfileName\fR and evaluates its contents as a Tcl command by calling \fBTcl_Eval\fR. It returns a standard Tcl result that reflects the result of evaluating the file. If the file couldn't be read then a Tcl error is returned to describe why the file couldn't be read. .PP .VS \fBTcl_GlobalEval\fR is similar to \fBTcl_Eval\fR except that it processes the command at global level. This means that the variable context for the command consists of global variables only (it ignores any Tcl procedure that is active). This produces an effect similar to the Tcl command ``\fBuplevel 0\fR''. .VE .PP During the processing of a Tcl command it is legal to make nested calls to evaluate other commands (this is how conditionals, loops, and procedures are implemented). If a code other than \fBTCL_OK\fR is returned from a nested \fBTcl_Eval\fR invocation, then the caller should normally return immediately, passing that same return code back to its caller, and so on until the top-level application is reached. A few commands, like \fBfor\fR, will check for certain return codes, like \fBTCL_BREAK\fR and \fBTCL_CONTINUE\fR, and process them specially without returning. .PP \fBTcl_Eval\fR keeps track of how many nested Tcl_Eval invocations are in progress for \fIinterp\fR. If a code of \fBTCL_RETURN\fR, \fBTCL_BREAK\fR, or \fBTCL_CONTINUE\fR is about to be returned from the topmost \fBTcl_Eval\fR invocation for \fIinterp\fR, then \fBTcl_Eval\fR converts the return code to \fBTCL_ERROR\fR and sets \fIinterp->result\fR to point to an error message indicating that the \fBreturn\fR, \fBbreak\fR, or \fBcontinue\fR command was invoked in an inappropriate place. This means that top-level applications should never see a return code from \fBTcl_Eval\fR other then \fBTCL_OK\fR or \fBTCL_ERROR\fR. .SH KEYWORDS command, execute, file, global, interpreter, variable ================================================ FILE: lib/libtcl/doc/ExprLong.3 ================================================ '\" '\" Copyright 1989 Regents of the University of California '\" Permission to use, copy, modify, and distribute this '\" documentation for any purpose and without fee is hereby '\" granted, provided that this notice appears in all copies. '\" The University of California makes no representations about '\" the suitability of this material for any purpose. It is '\" provided "as is" without express or implied warranty. '\" '\" $Header: /cvsroot/PROCPLACE/pptinytcl/doc/ExprLong.3,v 1.1.1.1 2001/04/20 15:03:06 karl Exp $ SPRITE (Berkeley) '\" .so man.macros .HS Tcl_ExprLong tcl .BS .SH NAME Tcl_ExprLong, Tcl_ExprDouble, Tcl_ExprBool, Tcl_ExprString \- evaluate an expression .SH SYNOPSIS .nf \fB#include \fR .VS .sp int \fBTcl_ExprLong\fR(\fIinterp, string, longPtr\fR) .sp int \fBTcl_ExprDouble\fR(\fIinterp, string, doublePtr\fR) .sp int \fBTcl_ExprBoolean\fR(\fIinterp, string, booleanPtr\fR) .sp int \fBTcl_ExprString\fR(\fIinterp, string\fR) .SH ARGUMENTS .AS Tcl_Interp *booleanPtr .AP Tcl_Interp *interp in Interpreter in whose context to evaluate \fIstring\fR. .AP char *string in Expression to be evaluated. Must be in writable memory (the expression parser makes temporary modifications to the string during parsing, which it undoes before returning). .AP long *longPtr out Pointer to location in which to store the integer value of the expression. .AP int *doublePtr out Pointer to location in which to store the floating-point value of the expression. .AP int *booleanPtr out Pointer to location in which to store the 0/1 boolean value of the expression. .BE .SH DESCRIPTION .PP These four procedures all evaluate a string expression, returning the result in one of four different forms. The expression is given by the \fIstring\fR argument, and it can have any of the forms accepted by the \fBexpr\fR command. The \fIinterp\fR argument refers to an interpreter used to evaluate the expression (e.g. for variables and nested Tcl commands) and to return error information. \fIInterp->result\fR is assumed to be initialized in the standard fashion when any of the procedures are invoked. .PP For all of these procedures the return value is a standard Tcl result: \fBTCL_OK\fR means the expression was succesfully evaluated, and \fBTCL_ERROR\fR means that an error occurred while evaluating the expression. If \fBTCL_ERROR\fR is returned then \fIinterp->result\fR will hold a message describing the error. If an error occurs while executing a Tcl command embedded in \fIstring\fR, then that error will be returned. .PP If the expression is successfully evaluated, then its value will be returned in one of four forms, depending on which procedure is invoked. \fBTcl_ExprLong\fR stores an integer value at \fI*longPtr\fR. If the expression's actual value was a floating-point number, then it is truncated to an integer. If the expression's actual value was a non-numeric string then an error is returned. .PP \fBTcl_ExprDouble\fR stores a floating-point value at \fI*doublePtr\fR. If the expression's actual value was an integer, it is converted to floating-point. If the expression's actual value was a non-numeric string then an error is returned. .PP \fBTcl_ExprBoolean\fR stores a 0/1 integer value at \fI*booleanPtr\fR. If the expression's actual value was an integer or floating-point number, then \fBTcl_ExprBoolean\fR stores 0 at \fI*booleanPtr\fR if the value was zero and 1 otherwise. If the expression's actual value was a non-numeric string then an error is returned. .PP \fBTcl_ExprString\fR returns the value of the expression as a string stored in \fIinterp->result\fR. If the expression's actual value was an integer or floating-point number, then \fBTcl_ExprString\fR converts it to string (using \fBsprintf\fR with a ``%d'' or ``%g'' converter). .SH KEYWORDS boolean, double, evaluate, expression, integer, string .VE ================================================ FILE: lib/libtcl/doc/Fork.3 ================================================ '\" '\" Copyright 1989 Regents of the University of California '\" Permission to use, copy, modify, and distribute this '\" documentation for any purpose and without fee is hereby '\" granted, provided that this notice appears in all copies. '\" The University of California makes no representations about '\" the suitability of this material for any purpose. It is '\" provided "as is" without express or implied warranty. '\" '\" $Header: /cvsroot/PROCPLACE/pptinytcl/doc/Fork.3,v 1.1.1.1 2001/04/20 15:03:06 karl Exp $ SPRITE (Berkeley) '\" .so man.macros .HS Tcl_Fork tcl .BS .VS .SH NAME Tcl_Fork, Tcl_WaitPids, Tcl_DetachPids \- manage child processes .SH SYNOPSIS .nf \fB#include \fR .sp int \fBTcl_Fork\fR( ) .sp int \fBTcl_WaitPids\fR(\fInumPids, pidPtr, statusPtr\fR) .sp int \fBTcl_DetachPids\fR(\fInumPids, pidPtr\fR) .SH ARGUMENTS .AS int *statusPtr .AP int numPids in Number of process ids contained in the array pointed to by \fIpidPtr\fR. .AP int *pidPtr in Address of array containing \fInumPids\fR process ids. .AP int *statusPtr out Address of place to store status returned by exited/suspended process. .BE .SH DESCRIPTION .PP These procedures keep track of child processes in order to make it easier for one application to manage several children. If an application uses the UNIX \fIfork\fR and \fIwait\fR kernel calls directly, problems occur in situations like the following: .IP [1] One part of an application creates child C1. It plans to let the child run in background, then later wait for it to complete. .IP [2] Some other part of the application creates another child C2, not knowing anything about C1. .IP [3] The second part of the application uses \fIwait\fR to wait for C2 to complete. .IP [4] C1 completes before C2, so C1 is returned by the \fIwait\fR kernel call. .IP [5] The second part of the application doesn't recognize C1, so it ignores it and calls \fIwait\fR again. This time C2 completes. .IP [6] The first part of the application eventually decides to wait for its child to complete. When it calls \fIwait\fR there are no children left, so \fIwait\fR returns an error and the application never gets to examine the exit status for C1. .PP The procedures \fBTcl_Fork\fR, \fBTcl_WaitPids\fR, and \fBTcl_DetachPids\fR get around this problem by keeping a table of child processes and their exit statuses. They also provide a more flexible waiting mechanism than the \fIwait\fR kernel call. Tcl-based applications should never call \fIfork\fR and \fIwait\fR directly; they should use \fBTcl_Fork\fR, \fBTcl_WaitPids\fR, and \fBTcl_DetachPids\fR. .PP \fBTcl_Fork\fR calls \fIfork\fR and returns the result of the \fIfork\fR kernel call. If the \fIfork\fR call was successful then \fBTcl_Fork\fR also enters the new process into its internal table of child proceses. If \fIfork\fR returns an error then \fBTcl_Fork\fR returns that same error. .PP \fBTcl_WaitPids\fR calls \fIwait\fR repeatedly until one of the processes in the \fIpidPtr\fR array has exited or been killed or suspended by a signal. When this occurs, \fBTcl_WaitPids\fR returns the process identifier for the process and stores its wait status at \fI*statusPtr\fR. If the process no longer exists (it exited or was killed by a signal), then \fBTcl_WaitPids\fR removes its entry from the internal process table. If \fIwait\fR returns a process that isn't in the \fIpidPtr\fR array, \fBTcl_WaitPids\fR saves its wait status in the internal process table and calls \fIwait\fR again. If one of the processes in the \fIpidPtr\fR array has already exited (or suspended or been killed) when \fBTcl_WaitPids\fR is called, that process and its wait status are returned immediately without calling \fIwait\fR. .PP \fBTcl_WaitPids\fR provides two advantages. First, it allows processes to exit in any order, and saves their wait statuses. Second, it allows waiting on a number of processes simultaneously, returning when any of the processes is returned by \fIwait\fR. .PP \fBTcl_DetachPids\fR is used to indicate that the application no longer cares about the processes given by the \fIpidPtr\fR array and will never use \fBTcl_WaitPids\fR to wait for them. This occurs, for example, if one or more children are to be executed in background and the parent doesn't care whether they complete successfully. When \fBTcl_DetachPids\fR is called, the internal process table entries for the processes are marked so that the entries will be removed as soon as the processes exit or are killed. .PP If none of the pids passed to \fBTcl_WaitPids\fR exists in the internal process table, then -1 is returned and \fIerrno\fR is set to ECHILD. If a \fIwait\fR kernel call returns an error, then \fBTcl_WaitPids\fR returns that same error. If a \fIwait\fR kernel call returns a process that isn't in the internal process table, \fBTcl_WaitPids\fR panics and aborts the application. If this situation occurs, it means that a process has been created without calling \fBTcl_Fork\fR and that its exit status is about to be lost. .PP \fBTcl_WaitPids\fR defines wait statuses to have type \fIint\fR, which is correct for POSIX and many variants of UNIX. Some BSD-based UNIX systems still use type \fIunion wait\fR for wait statuses; it should be safe to cast a pointer to a \fIunion wait\fR structure to \fI(int *)\fR before passing it to \fBTcl_WaitPids\fR as in the following code: .nf .RS \fBunion wait status; int pid1, pid2; \&... pid2 = Tcl_WaitPids(1, &pid1, (int *) &status);\fR .RE .fi .SH KEYWORDS background, child, detach, fork, process, status, wait .VE ================================================ FILE: lib/libtcl/doc/GetInt.3 ================================================ '\" '\" Copyright 1989 Regents of the University of California '\" Permission to use, copy, modify, and distribute this '\" documentation for any purpose and without fee is hereby '\" granted, provided that this notice appears in all copies. '\" The University of California makes no representations about '\" the suitability of this material for any purpose. It is '\" provided "as is" without express or implied warranty. '\" '\" $Header: /cvsroot/PROCPLACE/pptinytcl/doc/GetInt.3,v 1.1.1.1 2001/04/20 15:03:06 karl Exp $ SPRITE (Berkeley) '\" .so man.macros .HS Tcl_GetInt tcl .BS .SH NAME Tcl_GetInt, Tcl_GetDouble, Tcl_GetBoolean \- convert from string to integer, double, or boolean .SH SYNOPSIS .nf \fB#include \fR .sp int \fBTcl_GetInt\fR(\fIinterp, string, intPtr\fR) .sp int \fBTcl_GetDouble\fR(\fIinterp, string, doublePtr\fR) .sp int \fBTcl_GetBoolean\fR(\fIinterp, string, boolPtr\fR) .SH ARGUMENTS .AS Tcl_Interp *doublePtr .AP Tcl_Interp *interp in Interpreter to use for error reporting. .AP char *string in Textual value to be converted. .AP int *intPtr out Points to place to store integer value converted from \fIstring\fR. .AP double *doublePtr out Points to place to store double-precision floating-point value converted from \fIstring\fR. .AP int *boolPtr out Points to place to store boolean value (0 or 1) converted from \fIstring\fR. .BE .SH DESCRIPTION .PP These procedures convert from strings to integers or double-precision floating-point values or booleans (represented as 0- or 1-valued integers). Each of the procedures takes a \fIstring\fR argument, converts it to an internal form of a particular type, and stores the converted value at the location indicated by the procedure's third argument. If all goes well, each of the procedures returns TCL_OK. If \fIstring\fR doesn't have the proper syntax for the desired type then TCL_ERROR is returned, an error message is left in \fIinterp->result\fR, and nothing is stored at *\fIintPtr\fR or *\fIdoublePtr\fR or *\fIboolPtr\fR. .PP \fBTcl_GetInt\fR expects \fIstring\fR to consist of a collection of integer digits, optionally signed and optionally preceded by white space. If the first two characters of \fIstring\fR are ``0x'' then \fIstring\fR is expected to be in hexadecimal form; otherwise, if the first character of \fIstring\fR is ``0'' then \fIstring\fR is expected to be in octal form; otherwise, \fIstring\fR is expected to be in decimal form. .PP \fBTcl_GetDouble\fR expects \fIstring\fR to consist of a floating-point number, which is: white space; a sign; a sequence of digits; a decimal point; a sequence of digits; the letter ``e''; and a signed decimal exponent. Any of the fields may be omitted, except that the digits either before or after the decimal point must be present and if the ``e'' is present then it must be followed by the exponent number. .PP \fBTcl_GetBoolean\fR expects \fIstring\fR to specify a boolean value. If \fIstring\fR is any of \fB0\fR, \fBfalse\fR, .VS \fBno\fR, or \fBoff\fR, then \fBTcl_GetBoolean\fR stores a zero value at \fI*boolPtr\fR. If \fIstring\fR is any of \fB1\fR, \fBtrue\fR, \fByes\fR, or \fBon\fR, .VE then 1 is stored at \fI*boolPtr\fR. Any of these values may be abbreviated, and upper-case spellings are also acceptable. .SH KEYWORDS boolean, conversion, double, floating-point, integer ================================================ FILE: lib/libtcl/doc/Hash.3 ================================================ '\" '\" Copyright 1989 Regents of the University of California '\" Permission to use, copy, modify, and distribute this '\" documentation for any purpose and without fee is hereby '\" granted, provided that this notice appears in all copies. '\" The University of California makes no representations about '\" the suitability of this material for any purpose. It is '\" provided "as is" without express or implied warranty. '\" '\" $Header: /cvsroot/PROCPLACE/pptinytcl/doc/Hash.3,v 1.1.1.1 2001/04/20 15:03:06 karl Exp $ SPRITE (Berkeley) '\" .so man.macros .HS Tcl_Hash tcl .BS .SH NAME .na Tcl_InitHashTable, Tcl_DeleteHashTable, Tcl_CreateHashEntry, Tcl_DeleteHashEntry, Tcl_FindHashEntry, Tcl_GetHashValue, Tcl_SetHashValue, Tcl_GetHashKey, Tcl_FirstHashEntry, Tcl_NextHashEntry, Tcl_HashStats \- procedures to manage hash tables .SH SYNOPSIS .nf \fB#include \fR .sp \fBTcl_InitHashTable\fR(\fItablePtr, keyType\fR) .sp \fBTcl_DeleteHashTable\fR(\fItablePtr\fR) .sp Tcl_HashEntry * \fBTcl_CreateHashEntry\fR(\fItablePtr, key, newPtr\fR) .sp \fBTcl_DeleteHashEntry\fR(\fIentryPtr\fR) .sp Tcl_HashEntry * \fBTcl_FindHashEntry\fR(\fItablePtr, key\fR) .sp ClientData \fBTcl_GetHashValue\fR(\fIentryPtr\fR) .sp \fBTcl_SetHashValue\fR(\fIentryPtr, value\fR) .sp char * \fBTcl_GetHashKey\fR(\fItablePtr, entryPtr\fR) .sp Tcl_HashEntry * \fBTcl_FirstHashEntry\fR(\fItablePtr, searchPtr\fR) .sp Tcl_HashEntry * \fBTcl_NextHashEntry\fR(\fIsearchPtr\fR) .sp char * \fBTcl_HashStats\fR(\fItablePtr\fR) .SH ARGUMENTS .AS Tcl_HashSearch *searchPtr .AP Tcl_HashTable *tablePtr in Address of hash table structure (for all procedures but \fBTcl_InitHashTable\fR, this must have been initialized by previous call to \fBTcl_InitHashTable\fR). .AP int keyType in Kind of keys to use for new hash table. Must be either TCL_STRING_KEYS, TCL_ONE_WORD_KEYS, or an integer value greater than 1. .AP char *key in Key to use for probe into table. Exact form depends on \fIkeyType\fR used to create table. .AP int *newPtr out The word at \fI*newPtr\fR is set to 1 if a new entry was created and 0 if there was already an entry for \fIkey\fR. .AP Tcl_HashEntry *entryPtr in Pointer to hash table entry. .AP ClientData value in New value to assign to hash table entry. Need not have type ClientData, but must fit in same space as ClientData. .AP Tcl_HashSearch *searchPtr in Pointer to record to use to keep track of progress in enumerating all the entries in a hash table. .BE .SH DESCRIPTION .PP A hash table consists of zero or more entries, each consisting of a key and a value. Given the key for an entry, the hashing routines can very quickly locate the entry, and hence its value. There may be at most one entry in a hash table with a particular key, but many entries may have the same value. Keys can take one of three forms: strings, one-word values, or integer arrays. All of the keys in a given table have the same form, which is specified when the table is initialized. .PP The value of a hash table entry can be anything that fits in the same space as a ``char *'' pointer. Values for hash table entries are managed entirely by clients, not by the hash module itself. Typically each entry's value is a pointer to a data structure managed by client code. .PP Hash tables grow gracefully as the number of entries increases, so that there are always less than three entries per hash bucket, on average. This allows for fast lookups regardless of the number of entries in a table. .PP \fBTcl_InitHashTable\fR initializes a structure that describes a new hash table. The space for the structure is provided by the caller, not by the hash module. The value of \fIkeyType\fR indicates what kinds of keys will be used for all entries in the table. \fIKeyType\fR must have one of the following values: .IP \fBTCL_STRING_KEYS\fR 25 Keys are null-terminated ASCII strings. They are passed to hashing routines using the address of the first character of the string. .IP \fBTCL_ONE_WORD_KEYS\fR 25 Keys are single-word values; they are passed to hashing routines and stored in hash table entries as ``char *'' values. The pointer value is the key; it need not (and usually doesn't) actually point to a string. .IP \fIother\fR 25 If \fIkeyType\fR is not TCL_STRING_KEYS or TCL_ONE_WORD_KEYS, then it must be an integer value greater than 1. In this case the keys will be arrays of ``int'' values, where \fIkeyType\fR gives the number of ints in each key. This allows structures to be used as keys. All keys must have the same size. Array keys are passed into hashing functions using the address of the first int in the array. .PP \fBTcl_DeleteHashTable\fR deletes all of the entries in a hash table and frees up the memory associated with the table's bucket array and entries. It does not free the actual table structure (pointed to by \fItablePtr\fR), since that memory is assumed to be managed by the client. \fBTcl_DeleteHashTable\fR also does not free or otherwise manipulate the values of the hash table entries. If the entry values point to dynamically-allocated memory, then it is the client's responsibility to free these structures before deleting the table. .PP \fBTcl_CreateHashEntry\fR locates the entry corresponding to a particular key, creating a new entry in the table if there wasn't already one with the given key. If an entry already existed with the given key then \fI*newPtr\fR is set to zero. If a new entry was created, then \fI*newPtr\fR is set to a non-zero value and the value of the new entry will be set to zero. The return value from \fBTcl_CreateHashEntry\fR is a pointer to the entry, which may be used to retrieve and modify the entry's value or to delete the entry from the table. .PP \fBTcl_DeleteHashEntry\fR will remove an existing entry from a table. The memory associated with the entry itself will be freed, but the client is responsible for any cleanup associated with the entry's value, such as freeing a structure that it points to. .PP \fBTcl_FindHashEntry\fR is similar to \fBTcl_CreateHashEntry\fR except that it doesn't create a new entry if the key doesn't exist; instead, it returns NULL as result. .PP \fBTcl_GetHashValue\fR and \fBTcl_SetHashValue\fR are used to read and write an entry's value, respectively. Values are stored and retrieved as type ``ClientData'', which is large enough to hold a pointer value. On almost all machines this is large enough to hold an integer value too. .PP \fBTcl_GetHashKey\fR returns the key for a given hash table entry, either as a pointer to a string, a one-word (``char *'') key, or as a pointer to the first word of an array of integers, depending on the \fIkeyType\fR used to create a hash table. In all cases \fBTcl_GetHashKey\fR returns a result with type ``char *''. When the key is a string or array, the result of \fBTcl_GetHashKey\fR points to information in the table entry; this information will remain valid until the entry is deleted or its table is deleted. .PP \fBTcl_FirstHashEntry\fR and \fBTcl_NextHashEntry\fR may be used to scan all of the entries in a hash table. A structure of type ``Tcl_HashSearch'', provided by the client, is used to keep track of progress through the table. \fBTcl_FirstHashEntry\fR initializes the search record and returns the first entry in the table (or NULL if the table is empty). Each susequent call to \fBTcl_NextHashEntry\fR returns the next entry in the table or NULL if the end of the table has been reached. A call to \fBTcl_FirstHashEntry\fR followed by calls to \fBTcl_NextHashEntry\fR will return each of the entries in the table exactly once, in an arbitrary order. It is unadvisable to modify the structure of the table, e.g. by creating or deleting entries, while the search is in progress. .PP \fBTcl_HashStats\fR returns a dynamically-allocated string with overall information about a hash table, such as the number of entries it contains, the number of buckets in its hash array, and the utilization of the buckets. It is the caller's responsibility to free the result string by passing it to \fBfree\fR. .PP The header file \fBtclHash.h\fR defines the actual data structures used to implement hash tables. This is necessary so that clients can allocate Tcl_HashTable structures and so that macros can be used to read and write the values of entries. However, users of the hashing routines should never refer directly to any of the fields of any of the hash-related data structures; use the procedures and macros defined here. .SH KEYWORDS hash table, key, lookup, search, value ================================================ FILE: lib/libtcl/doc/History.3 ================================================ '\" '\" Copyright 1989 Regents of the University of California '\" Permission to use, copy, modify, and distribute this '\" documentation for any purpose and without fee is hereby '\" granted, provided that this notice appears in all copies. '\" The University of California makes no representations about '\" the suitability of this material for any purpose. It is '\" provided "as is" without express or implied warranty. '\" '\" $Header: /cvsroot/PROCPLACE/pptinytcl/doc/History.3,v 1.1.1.1 2001/04/20 15:03:06 karl Exp $ SPRITE (Berkeley) '\" .so man.macros .HS Tcl_InitHistory tcl .BS .SH NAME Tcl_InitHistory, Tcl_RecordAndEval \- procedures for managing history list .SH SYNOPSIS .nf \fB#include \fR .sp .VS \fBTcl_InitHistory\fR(\fIinterp\fR) .VE .sp int \fBTcl_RecordAndEval\fR(\fIinterp, cmd, flags\fR) .SH ARGUMENTS .AS Tcl_Interp *interp; .AP Tcl_Interp *interp in Tcl interpreter in which history facilities are being used. .AP char *cmd in Command (or sequence of commands) to execute. .AP char flags in Flags to pass to \fBTcl_Eval\fR (normally 0). If -1, then the command is not executed; it's just recorded. .BE .SH DESCRIPTION .PP The procedure \fBTcl_InitHistory\fR is invoked to enable the .VS history facilities in an interpreter (by default there is no \fBhistory\fR command in an interpreter). After this command has been executed the \fBhistory\fR command will be available in \fIinterp\fR and the history facilities will be initialized. \fBTcl_InitHistory\fR is invoked automatically by \fBTcl_RecordAndEval\fR, so it need not be invoked explicitly unless the \fBhistory\fR command is to be used before \fBTcl_RecordAndEval\fR has been called. .VE .PP \fBTcl_RecordAndEval\fR is invoked to record a command on the history list and then execute it. Programs that do not wish to use the history mechanism should not call \fBTcl_RecordAndEval\fR; they should call \fBTcl_Eval\fR instead. Furthermore, \fBTcl_RecordAndEval\fR should only be called with top-level commands typed by the user, since the purpose of history is to allow the user to re-issue recently-invoked commands. .PP \fBTcl_RecordAndEval\fR does three things. First, it calls \fBTcl_InitHistory\fR to initialize history for the interpreter \fIinterp\fR, if this hasn't already been done. Second, \fBTcl_RecordAndEval\fR saves \fIcommand\fR in the history list for \fIinterp\fR, making a new event to hold the command. Third, \fBTcl_RecordAndEval\fR executes the command by passing it and \fIflags\fR to \fBTcl_Eval\fR. If \fIflags\fR is -1 then only the first two steps are taken; the command will not be executed. .SH KEYWORDS command, event, execute, history, interpreter, record ================================================ FILE: lib/libtcl/doc/Interp.3 ================================================ '\" '\" Copyright 1989 Regents of the University of California '\" Permission to use, copy, modify, and distribute this '\" documentation for any purpose and without fee is hereby '\" granted, provided that this notice appears in all copies. '\" The University of California makes no representations about '\" the suitability of this material for any purpose. It is '\" provided "as is" without express or implied warranty. '\" '\" $Header: /cvsroot/PROCPLACE/pptinytcl/doc/Interp.3,v 1.1.1.1 2001/04/20 15:03:06 karl Exp $ SPRITE (Berkeley) '\" .so man.macros .HS Tcl_Interp tcl .BS .SH NAME Tcl_Interp \- client-visible fields of interpreter structures .SH SYNOPSIS .nf \fB#include \fR .sp typedef struct { char *\fIresult\fR; .VS Tcl_FreeProc *\fIfreeProc\fR; .VE int \fIerrorLine\fR; } Tcl_Interp; .VS typedef void Tcl_FreeProc(char *\fIblockPtr\fR); .VE .BE .SH DESCRIPTION .PP The \fBTcl_CreateInterp\fR procedure returns a pointer to a Tcl_Interp structure. This pointer is then passed into other Tcl procedures to process commands in the interpreter and perform other operations on the interpreter. Interpreter structures contain many many fields that are used by Tcl, but only three that may be accessed by .VS clients: \fIresult\fR, \fIfreeProc\fR, and \fIerrorLine\fR. .PP The \fIresult\fR and \fIfreeProc\fR fields are used to return results or error messages from commands. This information is returned by command procedures back to \fBTcl_Eval\fR, and by \fBTcl_Eval\fR back to its callers. The \fIresult\fR field points to the string that represents the result or error message, and the \fIfreeProc\fR field tells how to dispose of the storage for the string when it isn't needed anymore. The easiest way for command procedures to manipulate these fields is to call procedures like \fBTcl_SetResult\fR or \fBTcl_AppendResult\fR; they will hide all the details of managing the fields. The description below is for those procedures that manipulate the fields directly. .PP Whenever a command procedure returns, it must ensure that the \fIresult\fR field of its interpreter points to the string being returned by the command. The \fIresult\fR field must always point to a valid string. If a command wishes to return no result then \fIinterp->result\fR should point to an empty string. Normally, results are assumed to be statically allocated, which means that the contents will not change before the next time \fBTcl_Eval\fR is called or some other command procedure is invoked. In this case, the \fIfreeProc\fR field must be zero. Alternatively, a command procedure may dynamically allocate its return value (e.g. using \fBmalloc\fR) and store a pointer to it in \fIinterp->result\fR. In this case, the command procedure must also set \fIinterp->freeProc\fR to the address of a procedure that can free the value (usually \fBfree\fR). If \fIinterp->freeProc\fR is non-zero, then Tcl will call \fIfreeProc\fR to free the space pointed to by \fIinterp->result\fR before it invokes the next command. If a client procedure overwrites \fIinterp->result\fR when \fIinterp->freeProc\fR is non-zero, then it is responsible for calling \fIfreeProc\fR to free the old \fIinterp->result\fR (the \fBTcl_FreeResult\fR macro should be used for this purpose). .PP \fIFreeProc\fR should have arguments and result that match the \fBTcl_FreeProc\fR declaration above: it receives a single argument which is a pointer to the result value to free. In most applications \fBfree\fR is the only non-zero value ever used for \fIfreeProc\fR. However, an application may store a different procedure address in \fIfreeProc\fR in order to use an alternate memory allocator or in order to do other cleanup when the result memory is freed. .PP As part of processing each command, \fBTcl_Eval\fR initializes \fIinterp->result\fR and \fIinterp->freeProc\fR just before calling the command procedure for the command. The \fIfreeProc\fR field will be initialized to zero, and \fIinterp->result\fR will point to an empty string. Commands that do not return any value can simply leave the fields alone. .VE Furthermore, the empty string pointed to by \fIresult\fR is actually part of an array of \fBTCL_RESULT_SIZE\fR characters (approximately 200). If a command wishes to return a short string, it can simply copy it to the area pointed to by \fIinterp->result\fR. Or, it can use the sprintf procedure to generate a short result string at the location pointed to by \fIinterp->result\fR. .PP It is a general convention in Tcl-based applications that the result of an interpreter is normally in the initialized state described in the previous paragraph. Procedures that manipulate an interpreter's result (e.g. by returning an error) will generally assume that the result has been initialized when the procedure is called. If such a procedure is to be called after the result has been changed, then \fBTcl_ResetResult\fR should be called first to reset the result to its initialized state. .PP The \fIerrorLine\fR field is valid only after \fBTcl_Eval\fR returns a \fBTCL_ERROR\fR return code. In this situation the \fIerrorLine\fR field identifies the line number of the command being executed when the error occurred. The line numbers are relative to the command being executed: 1 means the first line of the command passed to \fBTcl_Eval\fR, 2 means the second line, and so on. The \fIerrorLine\fR field is typically used in conjunction with \fBTcl_AddErrorInfo\fR to report information about where an error occurred. \fIErrorLine\fR should not normally be modified except by \fBTcl_Eval\fR. .SH KEYWORDS free, initialized, interpreter, malloc, result ================================================ FILE: lib/libtcl/doc/SetResult.3 ================================================ '\" '\" Copyright 1989 Regents of the University of California '\" Permission to use, copy, modify, and distribute this '\" documentation for any purpose and without fee is hereby '\" granted, provided that this notice appears in all copies. '\" The University of California makes no representations about '\" the suitability of this material for any purpose. It is '\" provided "as is" without express or implied warranty. '\" '\" $Header: /cvsroot/PROCPLACE/pptinytcl/doc/SetResult.3,v 1.1.1.1 2001/04/20 15:03:06 karl Exp $ SPRITE (Berkeley) '\" .so man.macros .HS Tcl_SetResult tcl .BS .SH NAME Tcl_SetResult, Tcl_AppendResult, Tcl_AppendElement, Tcl_ResetResult \- manipulate Tcl result string .SH SYNOPSIS .nf \fB#include \fR .sp .VS \fBTcl_SetResult\fR(\fIinterp, string, freeProc\fR) .VE .sp \fBTcl_AppendResult(\fIinterp, string, string, ... , \fB(char *) NULL\fR) .sp .VS \fBTcl_AppendElement\fR(\fIinterp, string, noSep\fR) .sp \fBTcl_ResetResult\fR(\fIinterp\fR) .sp \fBTcl_FreeResult\fR(\fIinterp\fR) .VE .SH ARGUMENTS .AS Tcl_FreeProc freeProc .AP Tcl_Interp *interp out Interpreter whose result is to be modified. .AP char *string in String value to become result for \fIinterp\fR or to be appended to existing result. .AP Tcl_FreeProc freeProc in .VS Address of procedure to call to release storage at \fIstring\fR, or \fBTCL_STATIC\fR, \fBTCL_DYNAMIC\fR, or \fBTCL_VOLATILE\fR. .AP int noSep in If non-zero then don't output a space character before this element, even if the element isn't the first thing in the result string. .VE .BE .SH DESCRIPTION .PP The procedures described here are utilities for setting the result/error string in a Tcl interpreter. .PP \fBTcl_SetResult\fR arranges for \fIstring\fR to be the return string for the current Tcl command in \fIinterp\fR, replacing any existing result. .VS If \fIfreeProc\fR is \fBTCL_STATIC\fR it means that \fIstring\fR refers to an area of static storage that is guaranteed not to be modified until at least the next call to \fBTcl_Eval\fR. If \fIfreeProc\fR is \fBTCL_DYNAMIC\fR it means that \fIstring\fR was allocated with a call to \fBmalloc()\fR and is now the property of the Tcl system. \fBTcl_SetResult\fR will arrange for the string's storage to be released by calling \fBfree()\fR when it is no longer needed. If \fIfreeProc\fR is \fBTCL_VOLATILE\fR it means that \fIstring\fR points to an area of memory that is likely to be overwritten when \fBTcl_SetResult\fR returns (e.g. it points to something in a stack frame). In this case \fBTcl_SetResult\fR will make a copy of the string in dynamically allocated storage and arrange for the copy to be the return string for the current Tcl command. .PP If \fIfreeProc\fR isn't one of the values \fBTCL_STATIC\fR, \fBTCL_DYNAMIC\fR, and \fBTCL_VOLATILE\fR, then it is the address of a procedure that Tcl should call to free the string. This allows applications to use non-standard storage allocators. When Tcl no longer needs the storage for the string, it will call \fIfreeProc\fR. \fIFreeProc\fR should have arguments and result that match the type \fBTcl_FreeProc\fR: .nf .RS typedef void Tcl_FreeProc(char *\fIblockPtr\fR); .RE .fi When \fIfreeProc\fR is called, its \fIblockPtr\fR will be set to the value of \fIstring\fR passed to \fBTcl_SetResult\fR. .VE .PP If \fIstring\fR is \fBNULL\fR, then \fIfreeProc\fR is ignored and \fBTcl_SetResult\fR re-initializes \fIinterp\fR's result to point to the pre-allocated result area, with an empty string in the result area. .PP .VS If \fBTcl_SetResult\fR is called at a time when \fIinterp\fR holds a result, \fBTcl_SetResult\fR does whatever is necessary to dispose of the old result (see the \fBTcl_Interp\fR manual entry for details on this). .VE .PP \fBTcl_AppendResult\fR makes it easy to build up Tcl results in pieces. It takes each of its \fIstring\fR arguments and appends them in order to the current result associated with \fIinterp\fR. .VS If the result is in its initialized empty state (e.g. a command procedure was just invoked or \fBTcl_ResetResult\fR was just called), then \fBTcl_AppendResult\fR sets the result to the concatenation of its \fIstring\fR arguments. .VE \fBTcl_AppendResult\fR may be called repeatedly as additional pieces of the result are produced. \fBTcl_AppendResult\fR takes care of all the storage management issues associated with managing \fIinterp\fR's result, such as allocating a larger result area if necessary. Any number of \fIstring\fR arguments may be passed in a single call; the last argument in the list must be a NULL pointer. .PP \fBTcl_AppendElement\fR is similar to \fBTcl_AppendResult\fR in .VS that it allows results to be built up in pieces. However, \fBTcl_AppendElement\fR takes only a single \fIstring\fR argument and it appends that argument to the current result as a proper Tcl list element. \fBTcl_AppendElement\fR adds backslashes or braces if necessary to ensure that \fIinterp\fR's result can be parsed as a list and that \fIstring\fR will be extracted as a single element. Under normal conditions, \fBTcl_AppendElement\fR will add a space character to \fIinterp\fR's result just before adding the new list element, so that the list elements in the result are properly separated. However, if \fIinterp\fR's result is empty when \fBTcl_AppendElement\fR is called, or if the \fInoSep\fR argument is 1, then no space is added. .PP \fBTcl_ResetResult\fR clears the result for \fIinterp\fR, freeing the memory associated with it if the current result was dynamically allocated. It leaves the result in its normal initialized state with \fIinterp->result\fR pointing to a static buffer containing \fBTCL_RESULT_SIZE\fR characters, of which the first character is zero. \fBTcl_ResetResult\fR also clears the error state managed by \fBTcl_AddErrorInfo\fR and \fBTcl_SetErrorCode\fR. .PP \fBTcl_FreeResult\fR is a macro that performs part of the work of \fBTcl_ResetResult\fR. It frees up the memory associated with \fIinterp\fR's result and sets \fIinterp->freeProc\fR to zero, but it doesn't change \fIinterp->result\fR or clear error state. \fBTcl_FreeResult\fR is most commonly used when a procedure is about to replace one result value with another. .VE .SH "SEE ALSO" Tcl_AddErrorInfo, Tcl_SetErrorCode, Tcl_Interp .SH KEYWORDS append, command, element, list, result, return value, interpreter ================================================ FILE: lib/libtcl/doc/SetVar.3 ================================================ '\" '\" Copyright 1989 Regents of the University of California '\" Permission to use, copy, modify, and distribute this '\" documentation for any purpose and without fee is hereby '\" granted, provided that this notice appears in all copies. '\" The University of California makes no representations about '\" the suitability of this material for any purpose. It is '\" provided "as is" without express or implied warranty. '\" '\" $Header: /cvsroot/PROCPLACE/pptinytcl/doc/SetVar.3,v 1.1.1.1 2001/04/20 15:03:06 karl Exp $ SPRITE (Berkeley) '\" .so man.macros .HS Tcl_SetVar tcl .BS .VS .SH NAME Tcl_SetVar, Tcl_SetVar2, Tcl_GetVar, Tcl_GetVar2, Tcl_UnsetVar, Tcl_UnsetVar2 \- manipulate Tcl variables .SH SYNOPSIS .nf \fB#include \fR .sp char * \fBTcl_SetVar\fR(\fIinterp, varName, newValue, flags\fR) .sp char * \fBTcl_SetVar2\fR(\fIinterp, name1, name2, newValue, flags\fR) .sp char * \fBTcl_GetVar\fR(\fIinterp, varName, flags\fR) .sp char * \fBTcl_GetVar2\fR(\fIinterp, name1, name2, flags\fR) .sp int \fBTcl_UnsetVar\fR(\fIinterp, varName, flags\fR) .sp int \fBTcl_UnsetVar2\fR(\fIinterp, name1, name2, flags\fR) .SH ARGUMENTS .AS Tcl_Interp *newValue .AP Tcl_Interp *interp in Interpreter containing variable. .AP char *varName in Name of variable. May refer to a scalar variable or an element of an array variable. .AP char *newValue in New value for variable. .AP int flags in OR-ed combination of bits providing additional information for operation. See below for valid values. .AP char *name1 in Name of scalar variable, or name of array variable if \fIname2\fR is non-NULL. .AP char *name2 in If non-NULL, gives name of element within array and \fIname1\fR must refer to an array variable. .BE .SH DESCRIPTION .PP These procedures may be used to create, modify, read, and delete Tcl variables from C code. \fBTcl_SetVar\fR and \fBTcl_SetVar2\fR will create a new variable or modify an existing one. Both of these procedures set the given variable to the value given by \fInewValue\fR, and they return a pointer to a copy of the variable's new value, which is stored in Tcl's variable structure. Tcl keeps a private copy of the variable's value, so the caller may change \fInewValue\fR after these procedures return without affecting the value of the variable. If an error occurs in setting the variable (e.g. an array variable is referenced without giving an index into the array), then NULL is returned. .PP The name of the variable may be specified in either of two ways. If \fBTcl_SetVar\fR is called, the variable name is given as a single string, \fIvarName\fR. If \fIvarName\fR contains an open parenthesis and ends with a close parenthesis, then the value between the parentheses is treated as an index (which can have any string value) and the characters before the first open parenthesis are treated as the name of an array variable. If \fIvarName\fR doesn't have parentheses as described above, then the entire string is treated as the name of a scalar variable. If \fBTcl_SetVar2\fR is called, then the array name and index have been separated by the caller into two separate strings, \fIname1\fR and \fIname2\fR respectively; if \fIname2\fR is zero it means that a scalar variable is being referenced. .PP The \fIflags\fR argument may be used to specify any of several options to the procedures. It consists of an OR-ed combination of any of the following bits: .IP TCL_GLOBAL_ONLY Under normal circumstances the procedures look up variables at the current level of procedure call for \fIinterp\fR, or at global level if there is no call active. However, if this bit is set in \fIflags\fR then the variable is looked up at global level even if there is a procedure call active. .IP TCL_LEAVE_ERR_MSG If an error is returned and this bit is set in \fIflags\fR, then an error message will be left in \fI\%interp->result\fR. If this flag bit isn't set then no error message is left (\fI\%interp->result\fR will not be modified). .IP TCL_APPEND_VALUE If this bit is set then \fInewValue\fR is appended to the current value, instead of replacing it. If the variable is currently undefined, then this bit is ignored. .IP TCL_LIST_ELEMENT If this bit is set, then \fInewValue\fR is converted to a valid Tcl list element before setting (or appending to) the variable. If the list element is being appended to an non-empty value, then a space character is appended before the new list element to separate it from previous elements. .IP TCL_NO_SPACE If this bit is set, it prevents the output of a separating space character in TCL_LIST_ELEMENT appends. This bit has no effect if the TCL_LIST_ELEMENT bit isn't set. .PP \fBTcl_GetVar\fR and \fBTcl_GetVar2\fR return the current value of a variable. The arguments to these procedures are treated in the same way as the arguments to \fBTcl_SetVar\fR and \fBTcl_SetVar2\fR. Under normal circumstances, the return value is a pointer to the variable's value (which is stored in Tcl's variable structure and will not change before the next call to \fBTcl_SetVar\fR or \fBTcl_SetVar2\fR). The only bits of \fIflags\fR that are used are TCL_GLOBAL_ONLY and TCL_LEAVE_ERR_MSG, both of which have the same meaning as for \fBTcl_SetVar\fR. If an error occurs in reading the variable (e.g. the variable doesn't exist or an array element is specified for a scalar variable), then NULL is returned. .PP \fBTcl_UnsetVar\fR and \fBTcl_UnsetVar2\fR may be used to remove a variable, so that future calls to \fBTcl_GetVar\fR or \fBTcl_GetVar2\fR for the variable will return an error. The arguments to these procedures are treated in the same way as the arguments to \fBTcl_GetVar\fR and \fBTcl_GetVar2\fR. If the variable is successfully removed then 0 is returned. If the variable cannot be removed because it doesn't exist or because a trace is active for it, then -1 is returned. If an array element is specified, the given element is removed but the array remains. If an array name is specified without an index, then the entire array is removed. .SH "SEE ALSO" Tcl_TraceVar .SH KEYWORDS array, interpreter, scalar, set, unset, variable .VE ================================================ FILE: lib/libtcl/doc/SplitList.3 ================================================ '\" '\" Copyright 1989-1991 Regents of the University of California '\" Permission to use, copy, modify, and distribute this '\" documentation for any purpose and without fee is hereby '\" granted, provided that this notice appears in all copies. '\" The University of California makes no representations about '\" the suitability of this material for any purpose. It is '\" provided "as is" without express or implied warranty. '\" '\" $Header: /cvsroot/PROCPLACE/pptinytcl/doc/SplitList.3,v 1.1.1.1 2001/04/20 15:03:06 karl Exp $ SPRITE (Berkeley) '\" .so man.macros .HS Tcl_SplitList tcl .BS .SH NAME Tcl_SplitList, Tcl_Merge, Tcl_ScanElement, Tcl_ConvertElement \- manipulate Tcl lists .SH SYNOPSIS .nf \fB#include \fR .sp int \fBTcl_SplitList\fR(\fIinterp, list, argcPtr, argvPtr\fR) .sp char * \fBTcl_Merge\fR(\fIargc, argv\fR) .sp .VS int \fBTcl_ScanElement\fR(\fIsrc, flagsPtr\fR) .sp int \fBTcl_ConvertElement\fR(\fIsrc, dst, flags\fR) .VE .SH ARGUMENTS .AS Tcl_Interp ***argvPtr .AP Tcl_Interp *interp out Interpreter to use for error reporting. .AP char *list in Pointer to a string with proper list structure. .AP int *argcPtr out Filled in with number of elements in \fIlist\fR. .AP char ***argvPtr out \fI*argvPtr\fR will be filled in with the address of an array of pointers to the strings that are the extracted elements of \fIlist\fR. There will be \fI*argcPtr\fR valid entries in the array, followed by a NULL entry. .AP int argc in Number of elements in \fIargv\fR. .AP char **argv in Array of strings to merge together into a single list. Each string will become a separate element of the list. .AP char *src in .VS String that is to become an element of a list. .AP int *flagsPtr in Pointer to word to fill in with information about \fIsrc\fR. The value of *\fIflagsPtr\fR must be passed to \fBTcl_ConvertElement\fR. .AP char *dst in Place to copy converted list element. Must contain enough characters to hold converted string. .AP int flags in Information about \fIsrc\fR. Must be value returned by previous call to \fBTcl_ScanElement\fR, possibly OR-ed with \fBTCL_DONT_USE_BRACES\fR. .VE .BE .SH DESCRIPTION .PP These procedures may be used to disassemble and reassemble Tcl lists. \fBTcl_SplitList\fR breaks a list up into its constituent elements, returning an array of pointers to the elements using \fIargcPtr\fR and \fIargvPtr\fR. While extracting the arguments, \fBTcl_SplitList\fR obeys the usual rules for backslash substitutions and braces. The area of memory pointed to by \fI*argvPtr\fR is dynamically allocated; in addition to the array of pointers, it also holds copies of all the list elements. It is the caller's responsibility to free up all of this storage by calling .DS \fBfree\fR((char *) \fI*argvPtr\fR) .DE when the list elements are no longer needed. .PP \fBTcl_SplitList\fR normally returns \fBTCL_OK\fR, which means the list was successfully parsed. If there was a syntax error in \fIlist\fR, then \fBTCL_ERROR\fR is returned and \fIinterp->result\fR will point to an error message describing the problem. If \fBTCL_ERROR\fR is returned then no memory is allocated and \fI*argvPtr\fR is not modified. .PP \fBTcl_Merge\fR is the inverse of \fBTcl_SplitList\fR: it takes a collection of strings given by \fIargc\fR and \fIargv\fR and generates a result string that has proper list structure. This means that commands like \fBindex\fR may be used to extract the original elements again. In addition, if the result of \fBTcl_Merge\fR is passed to \fBTcl_Eval\fR, it will be parsed into \fIargc\fR words whose values will be the same as the \fIargv\fR strings passed to \fBTcl_Merge\fR. \fBTcl_Merge\fR will modify the list elements with braces and/or backslashes in order to produce proper Tcl list structure. The result string is dynamically allocated using \fBmalloc()\fR; the caller must eventually release the space using \fBfree()\fR. .PP If the result of \fBTcl_Merge\fR is passed to \fBTcl_SplitList\fR, the elements returned by \fBTcl_SplitList\fR will be identical to those passed into \fBTcl_Merge\fR. However, the converse is not true: if \fBTcl_SplitList\fR is passed a given string, and the resulting \fIargc\fR and \fIargv\fR are passed to \fBTcl_Merge\fR, the resulting string may not be the same as the original string passed to \fBTcl_SplitList\fR. This is because \fBTcl_Merge\fR may use backslashes and braces differently than the original string. .PP .VS \fBTcl_ScanElement\fR and \fBTcl_ConvertElement\fR are the procedures that do all of the real work of \fBTcl_Merge\fR. \fBTcl_ScanElement\fR scans its \fIsrc\fR argument and determines how to use backslashes and braces when converting it to a list element. It returns an overestimate of the number of characters required to represent \fIsrc\fR as a list element, and it stores information in \fI*flagsPtr\fR that is needed by \fBTcl_ConvertElement\fR. .PP \fBTcl_ConvertElement\fR is a companion procedure to \fBTcl_ScanElement\fR. It does the actual work of converting a string to a list element. Its \fIflags\fR argument must be the same as the value returned by \fBTcl_ScanElement\fR. \fBTcl_ConvertElement\fR writes a proper list element to memory starting at *\fIdst\fR and returns a count of the total number of characters written, which will be no more than the result returned by \fBTcl_ScanElement\fR. \fBTcl_ConvertElement\fR writes out only the actual list element without any leading or trailing spaces: it is up to the caller to include spaces between adjacent list elements. .PP \fBTcl_ConvertElement\fR uses one of two different approaches to handle the special characters in \fIsrc\fR. Wherever possible, it handles special characters by surrounding the string with braces. This produces clean-looking output, but can't be used in some situations, such as when \fIsrc\fR contains unmatched braces. In these situations, \fBTcl_ConvertElement\fR handles special characters by generating backslash sequences for them. The caller may insist on the second approach by OR-ing the flag value returned by \fBTcl_ScanElement\fR with \fBTCL_DONT_USE_BRACES\fR. Although this will produce an uglier result, it is useful in some special situations, such as when \fBTcl_ConvertElement\fR is being used to generate a portion of an argument for a Tcl command. In this case, surrounding \fIsrc\fR with curly braces would cause the command not to be parsed correctly. .VE .SH KEYWORDS backslash, convert, element, list, merge, split, strings ================================================ FILE: lib/libtcl/doc/StrMatch.3 ================================================ '\" '\" Copyright 1989 Regents of the University of California '\" Permission to use, copy, modify, and distribute this '\" documentation for any purpose and without fee is hereby '\" granted, provided that this notice appears in all copies. '\" The University of California makes no representations about '\" the suitability of this material for any purpose. It is '\" provided "as is" without express or implied warranty. '\" '\" $Header: /cvsroot/PROCPLACE/pptinytcl/doc/StrMatch.3,v 1.1.1.1 2001/04/20 15:03:06 karl Exp $ SPRITE (Berkeley) '\" .so man.macros .HS Tcl_StringMatch tcl .BS .SH NAME Tcl_StringMatch \- test whether a string matches a pattern .SH SYNOPSIS .nf \fB#include \fR .sp int \fBTcl_StringMatch\fR(\fIstring\fR, \fIpattern\fR) .SH ARGUMENTS .AP char *string in String to test. .AP char *pattern in Pattern to match against string. May contain special characters from the set *?\e[]. .BE .SH DESCRIPTION .PP This utility procedure determines whether a string matches a given pattern. If it does, then \fBTcl_StringMatch\fR returns 1. Otherwise \fBTcl_StringMatch\fR returns 0. The algorithm used for matching is the same algorithm used in the ``string match'' Tcl command and is similar to the algorithm used by the C-shell for file name matching; see the Tcl manual entry for details. .SH KEYWORDS match, pattern, string ================================================ FILE: lib/libtcl/doc/Tcl.n ================================================ '\" '\" Copyright 1989-1992 Regents of the University of California '\" Permission to use, copy, modify, and distribute this '\" documentation for any purpose and without fee is hereby '\" granted, provided that this notice appears in all copies. '\" The University of California makes no representations about '\" the suitability of this material for any purpose. It is '\" provided "as is" without express or implied warranty. '\" '\" $Header: /cvsroot/PROCPLACE/pptinytcl/doc/Tcl.n,v 1.1.1.1 2001/04/20 15:03:06 karl Exp $ SPRITE (Berkeley) ' .so man.macros .de UL \\$1\l'|0\(ul'\\$2 .. .HS Tcl tcl .BS .SH NAME Tcl \- overview of tool command language facilities .BE .SH INTRODUCTION .PP Tcl stands for ``tool command language'' and is pronounced ``tickle.'' It is actually two things: a language and a library. First, Tcl is a simple textual language, intended primarily for issuing commands to interactive programs such as text editors, debuggers, illustrators, and shells. It has a simple syntax and is also programmable, so Tcl users can write command procedures to provide more powerful commands than those in the built-in set. .PP Second, Tcl is a library package that can be embedded in application programs. The Tcl library consists of a parser for the Tcl language, routines to implement the Tcl built-in commands, and procedures that allow each application to extend Tcl with additional commands specific to that application. The application program generates Tcl commands and passes them to the Tcl parser for execution. Commands may be generated by reading characters from an input source, or by associating command strings with elements of the application's user interface, such as menu entries, buttons, or keystrokes. When the Tcl library receives commands it parses them into component fields and executes built-in commands directly. For commands implemented by the application, Tcl calls back to the application to execute the commands. In many cases commands will invoke recursive invocations of the Tcl interpreter by passing in additional strings to execute (procedures, looping commands, and conditional commands all work in this way). .PP An application program gains three advantages by using Tcl for its command language. First, Tcl provides a standard syntax: once users know Tcl, they will be able to issue commands easily to any Tcl-based application. Second, Tcl provides programmability. All a Tcl application needs to do is to implement a few application-specific low-level commands. Tcl provides many utility commands plus a general programming interface for building up complex command procedures. By using Tcl, applications need not re-implement these features. Third, Tcl can be used as .VS a common language for communicating between applications. Inter-application communication is not built into the Tcl core described here, but various add-on libraries, such as the Tk toolkit, allow applications to issue commands to each other. This makes it possible for applications to work together in much more powerful ways than was previously possible. .VE .PP This manual page focuses primarily on the Tcl language. It describes the language syntax and the built-in commands that will be available in any application based on Tcl. The individual library procedures are described in more detail in separate manual pages, one per procedure. .SH "INTERPRETERS" .PP The central data structure in Tcl is an interpreter (C type ``Tcl_Interp''). An interpreter consists of a set of command bindings, a set of variable values, and a few other miscellaneous pieces of state. Each Tcl command is interpreted in the context of a particular interpreter. Some Tcl-based applications will maintain multiple interpreters simultaneously, each associated with a different widget or portion of the application. Interpreters are relatively lightweight structures. They can be created and deleted quickly, so application programmers should feel free to use multiple interpreters if that simplifies the application. Eventually Tcl will provide a mechanism for sending Tcl commands and results back and forth between interpreters, even if the interpreters are managed by different processes. .SH "DATA TYPES" .PP Tcl supports only one type of data: strings. All commands, all arguments to commands, all command results, and all variable values are strings. Where commands require numeric arguments or return numeric results, the arguments and results are passed as strings. Many commands expect their string arguments to have certain formats, but this interpretation is up to the individual commands. For example, arguments often contain Tcl command strings, which may get executed as part of the commands. The easiest way to understand the Tcl interpreter is to remember that everything is just an operation on a string. In many cases Tcl constructs will look similar to more structured constructs from other languages. However, the Tcl constructs are not structured at all; they are just strings of characters, and this gives them a different behavior than the structures they may look like. .PP Although the exact interpretation of a Tcl string depends on who is doing the interpretation, there are three common forms that strings take: commands, expressions, and lists. The major sections below discuss these three forms in more detail. .SH "BASIC COMMAND SYNTAX" .PP The Tcl language has syntactic similarities to both the Unix shells and Lisp. However, the interpretation of commands is different in Tcl than in either of those other two systems. A Tcl command string consists of one or more commands separated by newline characters or semi-colons. Each command consists of a collection of fields separated by white space (spaces or tabs). The first field must be the name of a command, and the additional fields, if any, are arguments that will be passed to that command. For example, the command .DS \fBset a 22\fR .DE has three fields: the first, \fBset\fR, is the name of a Tcl command, and the last two, \fBa\fR and \fB22\fR, will be passed as arguments to the \fBset\fR command. The command name may refer either to a built-in Tcl command, an application-specific command bound in with the library procedure \fBTcl_CreateCommand\fR, or a command procedure defined with the \fBproc\fR built-in command. Arguments are passed literally as text strings. Individual commands may interpret those strings in any fashion they wish. The \fBset\fR command, for example, will treat its first argument as the name of a variable and its second argument as a string value to assign to that variable. For other commands arguments may be interpreted as integers, lists, file names, or Tcl commands. .PP .VS Command names should normally be typed completely (e.g. no abbreviations). However, if the Tcl interpreter cannot locate a command it invokes a special command named \fBunknown\fR which attempts to find or create the command. For example, at many sites \fBunknown\fR will search through library directories for the desired command and create it as a Tcl procedure if it is found. The \fBunknown\fR command often provides automatic completion of abbreviated commands, but usually only for commands that were typed interactively. It's probably a bad idea to use abbreviations in command scripts and other forms that will be re-used over time: changes to the command set may cause abbreviations to become ambiguous, resulting in scripts that no longer work. .VE .SH "COMMENTS" .PP If the first non-blank character in a command is \fB#\fR, then everything from the \fB#\fR up through the next newline character is treated as a comment and ignored. When comments are embedded inside nested commands (e.g. fields enclosed in braces) they must have properly-matched braces (this is necessary because when Tcl parses the top-level command it doesn't yet know that the nested field will be used as a command so it cannot process the nested comment character as a comment). .SH "GROUPING ARGUMENTS WITH DOUBLE-QUOTES" .PP Normally each argument field ends at the next white space, but double-quotes may be used to create arguments with embedded space. If an argument field begins with a double-quote, then the argument isn't terminated by white space (including newlines) or a semi-colon (see below for information on semi-colons); instead it ends at the next double-quote character. The double-quotes are not included in the resulting argument. For example, the command .DS \fBset a "This is a single argument"\fR .DE will pass two arguments to \fBset\fR: \fBa\fR and \fBThis is a single argument\fR. Within double-quotes, command substitutions, variable substitutions, and backslash substitutions still occur, as described below. If the first character of a command field is not a quote, then quotes receive no special interpretation in the parsing of that field. .SH "GROUPING ARGUMENTS WITH BRACES" .PP Curly braces may also be used for grouping arguments. They are similar to quotes except for two differences. First, they nest; this makes them easier to use for complicated arguments like nested Tcl command strings. Second, the substitutions described below for commands, variables, and backslashes do \fInot\fR occur in arguments enclosed in braces, so braces can be used to prevent substitutions where they are undesirable. If an argument field begins with a left brace, then the argument ends at the matching right brace. Tcl will strip off the outermost layer of braces and pass the information between the braces to the command without any further modification. For example, in the command .DS \fBset a {xyz a {b c d}}\fR .DE the \fBset\fR command will receive two arguments: \fBa\fR and \fBxyz a {b c d}\fR. .PP When braces or quotes are in effect, the matching brace or quote need not be on the same line as the starting quote or brace; in this case the newline will be included in the argument field along with any other characters up to the matching brace or quote. For example, the \fBeval\fR command takes one argument, which is a command string; \fBeval\fR invokes the Tcl interpreter to execute the command string. The command .DS \fBeval { set a 22 set b 33 }\fR .DE will assign the value \fB22\fR to \fBa\fR and \fB33\fR to \fBb\fR. .PP If the first character of a command field is not a left brace, then neither left nor right braces in the field will be treated specially (except as part of variable substitution; see below). .SH "COMMAND SUBSTITUTION WITH BRACKETS" .PP If an open bracket occurs in a field of a command, then command substitution occurs (except for fields enclosed in braces). All of the text up to the matching close bracket is treated as a Tcl command and executed immediately. Then the result of that command is substituted for the bracketed text. For example, consider the command .DS \fBset a [set b]\fR .DE When the \fBset\fR command has only a single argument, it is the name of a variable and \fBset\fR returns the contents of that variable. In this case, if variable \fBb\fR has the value \fBfoo\fR, then the command above is equivalent to the command .DS \fBset a foo\fR .DE Brackets can be used in more complex ways. For example, if the variable \fBb\fR has the value \fBfoo\fR and the variable \fBc\fR has the value \fBgorp\fR, then the command .DS \fBset a xyz[set b].[set c]\fR .DE is equivalent to the command .DS \fBset a xyzfoo.gorp\fR .DE .VS A bracketed command may contain multiple commands separated by newlines or semi-colons in the usual fashion. In this case the value of the last command is used for substitution. For example, the command .DS \fBset a x[set b 22 expr $b+2]x\fR .DE is equivalent to the command .DS \fBset a x24x\fR .DE .VE If a field is enclosed in braces then the brackets and the characters between them are not interpreted specially; they are passed through to the argument verbatim. .SH "VARIABLE SUBSTITUTION WITH $" .PP The dollar sign (\fB$\fR) may be used as a special shorthand form for substituting variable values. If \fB$\fR appears in an argument that isn't enclosed in braces then variable substitution will occur. The characters after the \fB$\fR, up to the first character that isn't a number, letter, or underscore, are taken as a variable name and the string value of that variable is substituted for the name. .VS For example, if variable \fBfoo\fR has the value \fBtest\fR, then the command .DS C \fBset a $foo.c\fR .DE is equivalent to the command .DS C \fBset a test.c\fR .DE .PP There are two special forms for variable substitution. If the next character after the name of the variable is an open parenthesis, then the variable is assumed to be an array name, and all of the characters between the open parenthesis and the next close parenthesis are taken as an index into the array. Command substitutions and variable substitutions are performed on the information between the parentheses before it is used as an index. For example, if the variable \fBx\fR is an array with one element named \fBfirst\fR and value \fB87\fR and another element named \fB14\fR and value \fBmore\fR, then the command .DS C \fBset a xyz$x(first)zyx .DE is equivalent to the command .DS C \fBset a xyz87zyx\fR .DE If the variable \fBindex\fR has the value \fB14\fR, then the command .DS C \fBset a xyz$x($index)zyx .DE is equivalent to the command .DS C \fBset a xyzmorezyx .DE For more information on arrays, see VARIABLES AND ARRAYS below. .PP The second special form for variables occurs when the dollar sign is followed by an open curly brace. In this case the variable name consists of all the characters up to the next curly brace. Array references are not possible in this form: the name between braces is assumed to refer to a scalar variable. For example, if variable \fBfoo\fR has the value \fBtest\fR, then the command .DS C \fBset a abc${foo}bar\fR .DE is equivalent to the command .DS C \fBset a abctestbar\fR .DE .VE Variable substitution does not occur in arguments that are enclosed in braces: the dollar sign and variable name are passed through to the argument verbatim. .PP The dollar sign abbreviation is simply a shorthand form. \fB$a\fR is completely equivalent to \fB[set a]\fR; it is provided as a convenience to reduce typing. .SH "SEPARATING COMMANDS WITH SEMI-COLONS" .PP Normally, each command occupies one line (the command is terminated by a newline character). However, semi-colon (``;'') is treated as a command separator character; multiple commands may be placed on one line by separating them with a semi-colon. Semi-colons are not treated as command separators if they appear within curly braces or double-quotes. .SH "BACKSLASH SUBSTITUTION" .PP Backslashes may be used to insert non-printing characters into command fields and also to insert special characters like braces and brackets into fields without them being interpreted specially as described above. The backslash sequences understood by the Tcl interpreter are listed below. In each case, the backslash sequence is replaced by the given character: .TP 20 \fB\eb\fR Backspace (0x8). .TP 20 \fB\ef\fR Form feed (0xc). .TP 20 \fB\en\fR Newline (0xa). .TP 20 \fB\er\fR Carriage-return (0xd). .TP 20 \fB\et\fR Tab (0x9). .TP 20 \fB\ev\fR Vertical tab (0xb). .TP 20 \fB\e{\fR Left brace (``{''). .TP 20 \fB\e}\fR Right brace (``}''). .TP 20 \fB\e[\fR Open bracket (``[''). .TP 20 \fB\e]\fR Close bracket (``]''). .TP 20 \fB\e$\fR Dollar sign (``$''). .TP 20 \fB\e\fR Space (`` ''): doesn't terminate argument. .br .TP 20 \fB\e;\fR Semi-colon: doesn't terminate command. .TP 20 \fB\e"\fR Double-quote. .TP 20 \fB\e\fR Nothing: this joins two lines together into a single line. This backslash feature is unique in that it will be applied even when the sequence occurs within braces. .TP 20 \fB\e\e\fR Backslash (``\e''). .TP 20 \fB\e\fIddd\fR The digits \fIddd\fR (one, two, or three of them) give the octal value of the character. Null characters may not be embedded in command fields; if \fIddd\fR is zero then the backslash sequence is ignored (i.e. it maps to an empty string). .PP For example, in the command .DS \fBset a \e{x\e[\e\0yz\e141\fR .DE the second argument to \fBset\fR will be ``\fB{x[\0yza\fR''. .PP If a backslash is followed by something other than one of the options described above, then the backslash is transmitted to the argument field without any special processing, and the Tcl scanner continues normal processing with the next character. For example, in the command .DS \fBset \e*a \e\e\e{foo\fR .DE The first argument to \fBset\fR will be \fB\e*a\fR and the second argument will be \fB\e{foo\fR. .PP If an argument is enclosed in braces, then backslash sequences inside the argument are parsed but no substitution occurs (except for backslash-newline): the backslash sequence is passed through to the argument as is, without making any special interpretation of the characters in the backslash sequence. In particular, backslashed braces are not counted in locating the matching right brace that terminates the argument. For example, in the command .DS \fBset a {\e{abc}\fR .DE the second argument to \fBset\fR will be \fB\e{abc\fR. .PP This backslash mechanism is not sufficient to generate absolutely any argument structure; it only covers the most common cases. To produce particularly complicated arguments it is probably easiest to use the \fBformat\fR command along with command substitution. .SH "COMMAND SUMMARY" .IP [1] A command is just a string. .IP [2] Within a string commands are separated by newlines or semi-colons (unless the newline or semi-colon is within braces or brackets or is backslashed). .IP [3] A command consists of fields. The first field is the name of the command. The other fields are strings that are passed to that command as arguments. .IP [4] Fields are normally separated by white space. .IP [5] Double-quotes allow white space and semi-colons to appear within a single argument. Command substitution, variable substitution, and backslash substitution still occur inside quotes. .IP [6] Braces defer interpretation of special characters. If a field begins with a left brace, then it consists of everything between the left brace and the matching right brace. The braces themselves are not included in the argument. No further processing is done on the information between the braces except that backslash-newline sequences are eliminated. .IP [7] If a field doesn't begin with a brace then backslash, variable, and command substitution are done on the field. Only a single level of processing is done: the results of one substitution are not scanned again for further substitutions or any other special treatment. Substitution can occur on any field of a command, including the command name as well as the arguments. .IP [8] If the first non-blank character of a command is a \fB#\fR, everything from the \fB#\fR up through the next newline is treated as a comment and ignored. .SH "EXPRESSIONS" .VS .PP The second major interpretation applied to strings in Tcl is as expressions. Several commands, such as \fBexpr\fR, \fBfor\fR, and \fBif\fR, treat one or more of their arguments as expressions and call the Tcl expression processors (\fBTcl_ExprLong\fR, \fBTcl_ExprBoolean\fR, etc.) to evaluate them. The operators permitted in Tcl expressions are a subset of the operators permitted in C expressions, and they have the same meaning and precedence as the corresponding C operators. Expressions almost always yield numeric results (integer or floating-point values). For example, the expression .DS \fB8.2 + 6\fR .DE evaluates to 14.2. Tcl expressions differ from C expressions in the way that operands are specified, and in that Tcl expressions support non-numeric operands and string comparisons. .PP A Tcl expression consists of a combination of operands, operators, and parentheses. White space may be used between the operands and operators and parentheses; it is ignored by the expression processor. Where possible, operands are interpreted as integer values. Integer values may be specified in decimal (the normal case), in octal (if the first character of the operand is \fB0\fR), or in hexadecimal (if the first two characters of the operand are \fB0x\fR). If an operand does not have one of the integer formats given above, then it is treated as a floating-point number if that is possible. Floating-point numbers may be specified in any of the ways accepted by an ANSI-compliant C compiler (except that the ``f'', ``F'', ``l'', and ``L'' suffixes will not be permitted in most installations). For example, all of the following are valid floating-point numbers: 2.1, 3., 6e4, 7.91e+16. If no numeric interpretation is possible, then an operand is left as a string (and only a limited set of operators may be applied to it). .PP Operands may be specified in any of the following ways: .IP [1] As an numeric value, either integer or floating-point. .IP [2] As a Tcl variable, using standard \fB$\fR notation. The variable's value will be used as the operand. .IP [3] As a string enclosed in double-quotes. The expression parser will perform backslash, variable, and command substitutions on the information between the quotes, and use the resulting value as the operand .IP [4] As a string enclosed in braces. The characters between the open brace and matching close brace will be used as the operand without any substitutions. .IP [5] As a Tcl command enclosed in brackets. The command will be executed and its result will be used as the operand. .LP Where substitutions occur above (e.g. inside quoted strings), they are performed by the expression processor. However, an additional layer of substitution may already have been performed by the command parser before the expression processor was called. As discussed below, it is usually best to enclose expressions in braces to prevent the command parser from performing substitutions on the contents. .PP For some examples of simple expressions, suppose the variable \fBa\fR has the value 3 and the variable \fBb\fR has the value 6. Then the expression on the left side of each of the lines below will evaluate to the value on the right side of the line: .DS .ta 6c \fB3.1 + $a 6.1 2 + "$a.$b" 5.6 4*[llength "6 2"] 8 {word one} < "word $a" 0\fR .DE .PP The valid operators are listed below, grouped in decreasing order of precedence: .TP 20 \fB\-\0\0~\0\0!\fR Unary minus, bit-wise NOT, logical NOT. None of these operands may be applied to string operands, and bit-wise NOT may be applied only to integers. .TP 20 \fB*\0\0/\0\0%\fR Multiply, divide, remainder. None of these operands may be applied to string operands, and remainder may be applied only to integers. .TP 20 \fB+\0\0\-\fR Add and subtract. Valid for any numeric operands. .TP 20 \fB<<\0\0>>\fR Left and right shift. Valid for integer operands only. .TP 20 \fB<\0\0>\0\0<=\0\0>=\fR Boolean less, greater, less than or equal, and greater than or equal. Each operator produces 1 if the condition is true, 0 otherwise. These operators may be applied to strings as well as numeric operands, in which case string comparison is used. .TP 20 \fB==\0\0!=\fR Boolean equal and not equal. Each operator produces a zero/one result. Valid for all operand types. .TP 20 \fB&\fR Bit-wise AND. Valid for integer operands only. .TP 20 \fB^\fR Bit-wise exclusive OR. Valid for integer operands only. .TP 20 \fB|\fR Bit-wise OR. Valid for integer operands only. .TP 20 \fB&&\fR Logical AND. Produces a 1 result if both operands are non-zero, 0 otherwise. Valid for numeric operands only (integers or floating-point). .TP 20 \fB||\fR Logical OR. Produces a 0 result if both operands are zero, 1 otherwise. Valid for numeric operands only (integers or floating-point). .TP 20 \fIx\fB?\fIy\fB:\fIz\fR If-then-else, as in C. If \fIx\fR evaluates to non-zero, then the result is the value of \fIy\fR. Otherwise the result is the value of \fIz\fR. The \fIx\fR operand must have a numeric value. .LP See the C manual for more details on the results produced by each operator. All of the binary operators group left-to-right within the same precedence level. For example, the expression .DS \fB4*2 < 7\fR .DE evaluates to 0. .PP The \fB&&\fP, \fB||\fP, and \fB?:\fP operators have ``lazy evaluation'', just as in C, which means that operands are not evaluated if they are not needed to determine the outcome. For example, in .DS \fB$v ? [a] : [b]\fR .DE only one of \fB[a]\fR or \fB[b]\fR will actually be evaluated, depending on the value of \fB$v\fP. .PP All internal computations involving integers are done with the C type \fIlong\fP, and all internal computations involving floating-point are done with the C type \fIdouble\fP. When converting a string to floating-point, exponent overflow is detected and results in a Tcl error. For conversion to integer from string, detection of overflow depends on the behavior of some routines in the local C library, so it should be regarded as unreliable. In any case, overflow and underflow are generally not detected reliably for intermediate results. .PP Conversion among internal representations for integer, floating-point, and string operands is done automatically as needed. For arithmetic computations, integers are used until some floating-point number is introduced, after which floating-point is used. For example, .DS \fB5 / 4\fR .DE yields the result 1, while .DS \fB5 / 4.0\fR \fB5 / ( [string length "abcd"] + 0.0 ) .DE both yield the result 1.25. .PP String values may be used as operands of the comparison operators, although the expression evaluator tries to do comparisons as integer or floating-point when it can. If one of the operands of a comparison is a string and the other has a numeric value, the numeric operand is converted back to a string using the C \fIsprintf\fP format specifier \fB%d\fR for integers and \fB%g\fR for floating-point values. For example, the expressions .DS \fB"0x03" > "2"\fR \fB"0y" < "0x12"\fR .DE both evaluate to 1. The first comparison is done using integer comparison, and the second is done using string comparison after the second operand is converted to the string ``18''. .VE .PP In general it is safest to enclose an expression in braces when entering it in a command: otherwise, if the expression contains any white space then the Tcl interpreter will split it among several arguments. For example, the command .DS C \fBexpr $a + $b\fR .DE results in three arguments being passed to \fBexpr\fR: \fB$a\fR, \fB+\fR, and \fB$b\fR. In addition, if the expression isn't in braces then the Tcl interpreter will perform variable and command substitution immediately (it will happen in the command parser rather than in the expression parser). In many cases the expression is being passed to a command that will evaluate the expression later (or even many times if, for example, the expression is to be used to decide when to exit a loop). Usually the desired goal is to re-do the variable or command substitutions each time the expression is evaluated, rather than once and for all at the beginning. For example, the command .DS C .ta 7c \fBfor {set i 1} $i<=10 {incr i} {...}\fR *** WRONG *** .DE is probably intended to iterate over all values of \fBi\fR from 1 to 10. After each iteration of the body of the loop, \fBfor\fR will pass its second argument to the expression evaluator to see whether or not to continue processing. Unfortunately, in this case the value of \fBi\fR in the second argument will be substituted once and for all when the \fBfor\fR command is parsed. If \fBi\fR was 0 before the \fBfor\fR command was invoked then \fBfor\fR's second argument will be \fB0<=10\fR which will always evaluate to 1, even though \fBi\fR's value eventually becomes greater than 10. In the above case the loop will never terminate. Instead, the expression should be placed in braces: .DS C .ta 7c \fBfor {set i 1} {$i<=10} {incr i} {...}\fR *** RIGHT *** .DE This causes the substitution of \fBi\fR's value to be delayed; it will be re-done each time the expression is evaluated, which is the desired result. .SH LISTS .PP The third major way that strings are interpreted in Tcl is as lists. A list is just a string with a list-like structure consisting of fields separated by white space. For example, the string .DS \fBAl Sue Anne John\fR .DE is a list with four elements or fields. Lists have the same basic structure as command strings, except that a newline character in a list is treated as a field separator just like space or tab. Conventions for braces and quotes and backslashes are the same for lists as for commands. For example, the string .DS \fBa b\e c {d e {f g h}}\fR .DE is a list with three elements: \fBa\fR, \fBb c\fR, and \fBd e {f g h}\fR. Whenever an element is extracted from a list, the same rules about braces and quotes and backslashes are applied as for commands. Thus in the example above when the third element is extracted from the list, the result is .DS \fBd e {f g h}\fR .DE (when the field was extracted, all that happened was to strip off the outermost layer of braces). Command substitution and variable substitution are never made on a list (at least, not by the list-processing commands; the list can always be passed to the Tcl interpreter for evaluation). .PP The Tcl commands \fBconcat\fR, \fBforeach\fR, .VS \fBlappend\fR, \fBlindex\fR, \fBlinsert\fR, \fBlist\fR, \fBllength\fR, \fBlrange\fR, \fBlreplace\fR, \fBlsearch\fR, and \fBlsort\fR allow you to build lists, .VE extract elements from them, search them, and perform other list-related functions. .SH "REGULAR EXPRESSIONS" .VS .PP Tcl provides two commands that support string matching using \fBegrep\fR-style regular expressions: \fBregexp\fR and \fBregsub\fR. Regular expressions are implemented using Henry Spencer's package, and the description of regular expressions below is copied verbatim from his manual entry. .PP A regular expression is zero or more \fIbranches\fR, separated by ``|''. It matches anything that matches one of the branches. .PP A branch is zero or more \fIpieces\fR, concatenated. It matches a match for the first, followed by a match for the second, etc. .PP A piece is an \fIatom\fR possibly followed by ``*'', ``+'', or ``?''. An atom followed by ``*'' matches a sequence of 0 or more matches of the atom. An atom followed by ``+'' matches a sequence of 1 or more matches of the atom. An atom followed by ``?'' matches a match of the atom, or the null string. .PP An atom is a regular expression in parentheses (matching a match for the regular expression), a \fIrange\fR (see below), ``.'' (matching any single character), ``^'' (matching the null string at the beginning of the input string), ``$'' (matching the null string at the end of the input string), a ``\e'' followed by a single character (matching that character), or a single character with no other significance (matching that character). .PP A \fIrange\fR is a sequence of characters enclosed in ``[]''. It normally matches any single character from the sequence. If the sequence begins with ``^'', it matches any single character \fInot\fR from the rest of the sequence. If two characters in the sequence are separated by ``\-'', this is shorthand for the full list of ASCII characters between them (e.g. ``[0-9]'' matches any decimal digit). To include a literal ``]'' in the sequence, make it the first character (following a possible ``^''). To include a literal ``\-'', make it the first or last character. .PP If a regular expression could match two different parts of a string, it will match the one which begins earliest. If both begin in the same place but match different lengths, or match the same length in different ways, life gets messier, as follows. .PP In general, the possibilities in a list of branches are considered in left-to-right order, the possibilities for ``*'', ``+'', and ``?'' are considered longest-first, nested constructs are considered from the outermost in, and concatenated constructs are considered leftmost-first. The match that will be chosen is the one that uses the earliest possibility in the first choice that has to be made. If there is more than one choice, the next will be made in the same manner (earliest possibility) subject to the decision on the first choice. And so forth. .PP For example, ``(ab|a)b*c'' could match ``abc'' in one of two ways. The first choice is between ``ab'' and ``a''; since ``ab'' is earlier, and does lead to a successful overall match, it is chosen. Since the ``b'' is already spoken for, the ``b*'' must match its last possibility\(emthe empty string\(emsince it must respect the earlier choice. .PP In the particular case where no ``|''s are present and there is only one ``*'', ``+'', or ``?'', the net effect is that the longest possible match will be chosen. So ``ab*'', presented with ``xabbbby'', will match ``abbbb''. Note that if ``ab*'' is tried against ``xabyabbbz'', it will match ``ab'' just after ``x'', due to the begins-earliest rule. (In effect, the decision on where to start the match is the first choice to be made, hence subsequent choices must respect it even if this leads them to less-preferred alternatives.) .VE .SH "COMMAND RESULTS" .PP Each command produces two results: a code and a string. The code indicates whether the command completed successfully or not, and the string gives additional information. The valid codes are defined in tcl.h, and are: .RS .TP 20 \fBTCL_OK\fR This is the normal return code, and indicates that the command completed successfully. The string gives the command's return value. .TP 20 \fBTCL_ERROR\fR Indicates that an error occurred; the string gives a message describing the error. .VS In addition, the global variable \fBerrorInfo\fR will contain human-readable information describing which commands and procedures were being executed when the error occurred, and the global variable \fBerrorCode\fR will contain machine-readable details about the error, if they are available. See the section BUILT-IN VARIABLES below for more information. .VE .VE .TP 20 \fBTCL_RETURN\fR Indicates that the \fBreturn\fR command has been invoked, and that the current procedure (or top-level command or \fBsource\fR command) should return immediately. The string gives the return value for the procedure or command. .TP 20 \fBTCL_BREAK\fR Indicates that the \fBbreak\fR command has been invoked, so the innermost loop should abort immediately. The string should always be empty. .TP 20 \fBTCL_CONTINUE\fR Indicates that the \fBcontinue\fR command has been invoked, so the innermost loop should go on to the next iteration. The string should always be empty. .RE Tcl programmers do not normally need to think about return codes, since TCL_OK is almost always returned. If anything else is returned by a command, then the Tcl interpreter immediately stops processing commands and returns to its caller. If there are several nested invocations of the Tcl interpreter in progress, then each nested command will usually return the error to its caller, until eventually the error is reported to the top-level application code. The application will then display the error message for the user. .PP In a few cases, some commands will handle certain ``error'' conditions themselves and not return them upwards. For example, the \fBfor\fR command checks for the TCL_BREAK code; if it occurs, then \fBfor\fR stops executing the body of the loop and returns TCL_OK to its caller. The \fBfor\fR command also handles TCL_CONTINUE codes and the procedure interpreter handles TCL_RETURN codes. The \fBcatch\fR command allows Tcl programs to catch errors and handle them without aborting command interpretation any further. .SH PROCEDURES .PP Tcl allows you to extend the command interface by defining procedures. A Tcl procedure can be invoked just like any other Tcl command (it has a name and it receives one or more arguments). The only difference is that its body isn't a piece of C code linked into the program; it is a string containing one or more other Tcl commands. See the \fBproc\fR command for information on how to define procedures and what happens when they are invoked. .SH VARIABLES \- SCALARS AND ARRAYS .VS .PP Tcl allows the definition of variables and the use of their values either through \fB$\fR-style variable substitution, the \fBset\fR command, or a few other mechanisms. Variables need not be declared: a new variable will automatically be created each time a new variable name is used. .PP Tcl supports two types of variables: scalars and arrays. A scalar variable has a single value, whereas an array variable can have any number of elements, each with a name (called its ``index'') and a value. Array indexes may be arbitrary strings; they need not be numeric. Parentheses are used refer to array elements in Tcl commands. For example, the command .DS C \fBset x(first) 44\fR .DE will modify the element of \fBx\fR whose index is \fBfirst\fR so that its new value is \fB44\fR. Two-dimensional arrays can be simulated in Tcl by using indexes that contain multiple concatenated values. For example, the commands .DS C \fBset a(2,3) 1\fR \fBset a(3,6) 2\fR .DE set the elements of \fBa\fR whose indexes are \fB2,3\fR and \fB3,6\fR. .PP In general, array elements may be used anywhere in Tcl that scalar variables may be used. If an array is defined with a particular name, then there may not be a scalar variable with the same name. Similarly, if there is a scalar variable with a particular name then it is not possible to make array references to the variable. To convert a scalar variable to an array or vice versa, remove the existing variable with the \fBunset\fR command. .PP The \fBarray\fR command provides several features for dealing with arrays, such as querying the names of all the elements of the array and searching through the array one element at a time. .VE .PP Variables may be either global or local. If a variable name is used when a procedure isn't being executed, then it automatically refers to a global variable. Variable names used within a procedure normally refer to local variables associated with that invocation of the procedure. Local variables are deleted whenever a procedure exits. The \fBglobal\fR command may be used to request that a name refer to a global variable for the duration of the current procedure (this is somewhat analogous to \fBextern\fR in C). .SH "BUILT-IN COMMANDS" .PP The Tcl library provides the following built-in commands, which will be available in any application using Tcl. In addition to these built-in commands, there may be additional commands defined by each application, plus commands defined as Tcl procedures. In the command syntax descriptions below, words in boldface are literals that you type verbatim to Tcl. Words in italics are meta-symbols; they serve as names for any of a range of values that you can type. Optional arguments or groups of arguments are indicated by enclosing them in question-marks. Ellipses (``...'') indicate that any number of additional arguments or groups of arguments may appear, in the same format as the preceding argument(s). .TP \fBappend \fIvarName value \fR?\fIvalue value ...\fR? .VS Append all of the \fIvalue\fR arguments to the current value of variable \fIvarName\fR. If \fIvarName\fR doesn't exist, it is given a value equal to the concatenation of all the \fIvalue\fR arguments. This command provides an efficient way to build up long variables incrementally. For example, ``\fBappend a $b\fR'' is much more efficient than ``\fBset a $a$b\fR'' if \fB$a\fR is long. .VE .TP \fBarray \fIoption arrayName\fR ?\fIarg arg ...\fR? .VS This command performs one of several operations on the variable given by \fIarrayName\fR. \fIArrayName\fR must be the name of an existing array variable. The \fIoption\fR argument determines what action is carried out by the command. The legal \fIoptions\fR (which may be abbreviated) are: .RS .TP \fBarray anymore \fIarrayName searchId\fR Returns 1 if there are any more elements left to be processed in an array search, 0 if all elements have already been returned. \fISearchId\fR indicates which search on \fIarrayName\fR to check, and must have been the return value from a previous invocation of \fBarray startsearch\fR. This option is particularly useful if an array has an element with an empty name, since the return value from \fBarray nextelement\fR won't indicate whether the search has been completed. .TP \fBarray donesearch \fIarrayName searchId\fR This command terminates an array search and destroys all the state associated with that search. \fISearchId\fR indicates which search on \fIarrayName\fR to destroy, and must have been the return value from a previous invocation of \fBarray startsearch\fR. Returns an empty string. .TP \fBarray names \fIarrayName\fR Returns a list containing the names of all of the elements in the array. If there are no elements in the array then an empty string is returned. .TP \fBarray nextelement \fIarrayName searchId\fR Returns the name of the next element in \fIarrayName\fR, or an empty string if all elements of \fIarrayName\fR have already been returned in this search. The \fIsearchId\fR argument identifies the search, and must have been the return value of an \fBarray startsearch\fR command. Warning: if elements are added to or deleted from the array, then all searches are automatically terminated just as if \fBarray donesearch\fR had been invoked; this will cause \fBarray nextelement\fR operations to fail for those searches. .TP \fBarray size \fIarrayName\fR Returns a decimal string giving the number of elements in the array. .TP \fBarray startsearch \fIarrayName\fR This command initializes an element-by-element search through the array given by \fIarrayName\fR, such that invocations of the \fBarray nextelement\fR command will return the names of the individual elements in the array. When the search has been completed, the \fBarray donesearch\fR command should be invoked. The return value is a search identifier that must be used in \fBarray nextelement\fR and \fBarray donesearch\fR commands; it allows multiple searches to be underway simultaneously for the same array. .VE .RE .TP \fBbreak\fR This command may be invoked only inside the body of a loop command such as \fBfor\fR or \fBforeach\fR or \fBwhile\fR. It returns a TCL_BREAK code to signal the innermost containing loop command to return immediately. .TP \fBcase\fI string \fR?\fBin\fR? \fIpatList body \fR?\fIpatList body \fR...? .TP \fBcase\fI string \fR?\fBin\fR? {\fIpatList body \fR?\fIpatList body \fR...?} Match \fIstring\fR against each of the \fIpatList\fR arguments in order. If one matches, then evaluate the following \fIbody\fR argument by passing it recursively to the Tcl interpreter, and return the result of that evaluation. Each \fIpatList\fR argument consists of a single pattern or list of patterns. Each pattern may contain any of the wild-cards described under \fBstring match\fR. If a \fIpatList\fR argument is \fBdefault\fR, the corresponding body will be evaluated if no \fIpatList\fR matches \fIstring\fR. If no \fIpatList\fR argument matches \fIstring\fR and no default is given, then the \fBcase\fR command returns an empty string. .RS .PP Two syntaxes are provided. The first uses a separate argument for each of the patterns and commands; this form is convenient if substitutions are desired on some of the patterns or commands. .VS The second form places all of the patterns and commands together into a single argument; the argument must have proper list structure, with the elements of the list being the patterns and commands. The second form makes it easy to construct multi-line case commands, since the braces around the whole list make it unnecessary to include a backslash at the end of each line. Since the \fIpatList\fR arguments are in braces in the second form, no command or variable substitutions are performed on them; this makes the behavior of the second form different than the first form in some cases. .PP Below are some examples of \fBcase\fR commands: .DS \fBcase abc in {a b} {format 1} default {format 2} a* {format 3} .DE will return \fB3\fR, .DS .ta .5c 1c \fBcase a in { {a b} {format 1} default {format 2} a* {format 3} } .DE will return \fB1\fR, and .DS .ta .5c 1c \fBcase xyz { {a b} {format 1} default {format 2} a* {format 3} } .DE will return \fB2\fR. .VE .RE .TP \fBcatch\fI command \fR?\fIvarName\fR? The \fBcatch\fR command may be used to prevent errors from aborting command interpretation. \fBCatch\fR calls the Tcl interpreter recursively to execute \fIcommand\fR, and always returns a TCL_OK code, regardless of any errors that might occur while executing \fIcommand\fR. The return value from \fBcatch\fR is a decimal string giving the code returned by the Tcl interpreter after executing \fIcommand\fR. This will be \fB0\fR (TCL_OK) if there were no errors in \fIcommand\fR; otherwise it will have a non-zero value corresponding to one of the exceptional return codes (see tcl.h for the definitions of code values). If the \fIvarName\fR argument is given, then it gives the name of a variable; \fBcatch\fR will set the value of the variable to the string returned from \fIcommand\fR (either a result or an error message). .TP \fBcd \fR?\fIdirName\fR? .VS Change the current working directory to \fIdirName\fR, or to the home directory (as specified in the HOME environment variable) if \fIdirName\fR is not given. If \fIdirName\fR starts with a tilde, then tilde-expansion is done as described for \fBTcl_TildeSubst\fR. Returns an empty string. This command can potentially be disruptive to an application, so it may be removed in some applications. .TP \fBclose \fIfileId\fR Closes the file given by \fIfileId\fR. \fIFileId\fR must be the return value from a previous invocation of the \fBopen\fR command; after this command, it should not be used anymore. If \fIfileId\fR refers to a command pipeline instead of a file, then \fBclose\fR waits for the children to complete. The normal result of this command is an empty string, but errors are returned if there are problems in closing the file or waiting for children to complete. .VE .TP \fBconcat\fI arg \fR?\fIarg ...\fR? This command treats each argument as a list and concatenates them into a single list. It permits any number of arguments. For example, the command .RS .DS \fBconcat a b {c d e} {f {g h}}\fR .DE will return .DS \fBa b c d e f {g h}\fR .DE as its result. .RE .TP \fBcontinue\fR This command may be invoked only inside the body of a loop command such as \fBfor\fR or \fBforeach\fR or \fBwhile\fR. It returns a TCL_CONTINUE code to signal the innermost containing loop command to skip the remainder of the loop's body but continue with the next iteration of the loop. .TP \fBeof \fIfileId\fR .VS Returns 1 if an end-of-file condition has occurred on \fIfileId\fR, 0 otherwise. \fIFileId\fR must have been the return value from a previous call to \fBopen\fR, or it may be \fBstdin\fR, \fBstdout\fR, or \fBstderr\fR to refer to one of the standard I/O channels. .VE .TP \fBerror \fImessage\fR ?\fIinfo\fR? ?\fIcode\fR? Returns a TCL_ERROR code, which causes command interpretation to be unwound. \fIMessage\fR is a string that is returned to the application to indicate what went wrong. .RS .PP If the \fIinfo\fR argument is provided and is non-empty, it is used to initialize the global variable \fBerrorInfo\fR. \fBerrorInfo\fR is used to accumulate a stack trace of what was in progress when an error occurred; as nested commands unwind, the Tcl interpreter adds information to \fBerrorInfo\fR. If the \fIinfo\fR argument is present, it is used to initialize \fBerrorInfo\fR and the first increment of unwind information will not be added by the Tcl interpreter. In other words, the command containing the \fBerror\fR command will not appear in \fBerrorInfo\fR; in its place will be \fIinfo\fR. This feature is most useful in conjunction with the \fBcatch\fR command: if a caught error cannot be handled successfully, \fIinfo\fR can be used to return a stack trace reflecting the original point of occurrence of the error: .DS \fBcatch {...} errMsg set savedInfo $errorInfo \&... error $errMsg $savedInfo\fR .DE .PP .VS If the \fIcode\fR argument is present, then its value is stored in the \fBerrorCode\fR global variable. This variable is intended to hold a machine-readable description of the error in cases where such information is available; see the section BUILT-IN VARIABLES below for information on the proper format for the variable. If the \fIcode\fR argument is not present, then \fBerrorCode\fR is automatically reset to ``NONE'' by the Tcl interpreter as part of processing the error generated by the command. .VE .RE .TP \fBeval \fIarg \fR?\fIarg ...\fR? \fBEval\fR takes one or more arguments, which together comprise a Tcl command (or collection of Tcl commands separated by newlines in the usual way). \fBEval\fR concatenates all its arguments in the same fashion as the \fBconcat\fR command, passes the concatenated string to the Tcl interpreter recursively, and returns the result of that evaluation (or any error generated by it). .TP \fBexec \fIarg \fR?\fIarg ...\fR? .VS This command treats its arguments as the specification of one or more UNIX commands to execute as subprocesses. The commands take the form of a standard shell pipeline; ``|'' arguments separate commands in the pipeline and cause standard output of the preceding command to be piped into standard input of the next command. .RS .PP Under normal conditions the result of the \fBexec\fR command consists of the standard output produced by the last command in the pipeline. If any of the commands in the pipeline exit abnormally or are killed or suspended, then \fBexec\fR will return an error and the error message will include the pipeline's output followed by error messages describing the abnormal terminations; the \fBerrorCode\fR variable will contain additional information about the last abnormal termination encountered. If any of the commands writes to its standard error file, then \fBexec\fR will return an error, and the error message will include the pipeline's output, followed by messages about abnormal terminations (if any), followed by the standard error output. .PP If the last character of the result or error message is a newline then that character is deleted from the result or error message for consistency with normal Tcl return values. .PP If an \fIarg\fR has the value ``>'' then the following argument is taken as the name of a file and the standard output of the last command in the pipeline is redirected to the file. In this situation \fBexec\fR will normally return an empty string. .PP If an \fIarg\fR has the value ``<'' then the following argument is taken as the name of a file to use for standard input to the first command in the pipeline. If an argument has the value ``<<'' then the following argument is taken as an immediate value to be passed to the first command as standard input. If there is no ``<'' or ``<<'' argument then the standard input for the first command in the pipeline is taken from the application's current standard input. .PP If the last \fIarg\fR is ``&'' then the command will be executed in background. In this case the standard output from the last command in the pipeline will go to the application's standard output unless redirected in the command, and error output from all the commands in the pipeline will go to the application's standard error file. .PP Each \fIarg\fR becomes one word for a command, except for ``|'', ``<'', ``<<'', ``>'', and ``&'' arguments, and the arguments that follow ``<'', ``<<'', and ``>''. The first word in each command is taken as the command name; tilde-substitution is performed on it, and the directories in the PATH environment variable are searched for an executable by the given name. No ``glob'' expansion or other shell-like substitutions are performed on the arguments to commands. .RE .TP \fBexit \fR?returnCode\fR? Terminate the process, returning \fIreturnCode\fR to the parent as the exit status. If \fIreturnCode\fR isn't specified then it defaults to 0. .VE .TP \fBexpr \fIarg\fR Calls the expression processor to evaluate \fIarg\fR, and returns the result as a string. See the section EXPRESSIONS above. .TP \fBfile \fIoption\fR \fIname\fR ?\fIarg arg ...\fR? .VS Operate on a file or a file name. \fIName\fR is the name of a file; if it starts with a tilde, then tilde substitution is done before executing the command (see the manual entry for \fBTcl_TildeSubst\fR for details). \fIOption\fR indicates what to do with the file name. Any unique abbreviation for \fIoption\fR is acceptable. The valid options are: .RS .TP \fBfile \fBatime \fIname\fR Return a decimal string giving the time at which file \fIname\fR was last accessed. The time is measured in the standard UNIX fashion as seconds from a fixed starting time (often January 1, 1970). If the file doesn't exist or its access time cannot be queried then an error is generated. .TP \fBfile \fBdirname \fIname\fR Return all of the characters in \fIname\fR up to but not including the last slash character. If there are no slashes in \fIname\fR then return ``.''. If the last slash in \fIname\fR is its first character, then return ``/''. .TP \fBfile \fBexecutable \fIname\fR Return \fB1\fR if file \fIname\fR is executable by the current user, \fB0\fR otherwise. .TP \fBfile \fBexists \fIname\fR Return \fB1\fR if file \fIname\fR exists and the current user has search privileges for the directories leading to it, \fB0\fR otherwise. .TP \fBfile \fBextension \fIname\fR Return all of the characters in \fIname\fR after and including the last dot in \fIname\fR. If there is no dot in \fIname\fR then return the empty string. .TP \fBfile \fBisdirectory \fIname\fR Return \fB1\fR if file \fIname\fR is a directory, \fB0\fR otherwise. .TP \fBfile \fBisfile \fIname\fR Return \fB1\fR if file \fIname\fR is a regular file, \fB0\fR otherwise. .TP \fBfile lstat \fIname varName\fR Same as \fBstat\fR option (see below) except uses the \fIlstat\fR kernel call instead of \fIstat\fR. This means that if \fIname\fR refers to a symbolic link the information returned in \fIvarName\fR is for the link rather than the file it refers to. On systems that don't support symbolic links this option behaves exactly the same as the \fBstat\fR option. .TP \fBfile \fBmtime \fIname\fR Return a decimal string giving the time at which file \fIname\fR was last modified. The time is measured in the standard UNIX fashion as seconds from a fixed starting time (often January 1, 1970). If the file doesn't exist or its modified time cannot be queried then an error is generated. .TP \fBfile \fBowned \fIname\fR Return \fB1\fR if file \fIname\fR is owned by the current user, \fB0\fR otherwise. .TP \fBfile \fBreadable \fIname\fR Return \fB1\fR if file \fIname\fR is readable by the current user, \fB0\fR otherwise. .TP \fBfile readlink \fIname\fR Returns the value of the symbolic link given by \fIname\fR (i.e. the name of the file it points to). If \fIname\fR isn't a symbolic link or its value cannot be read, then an error is returned. On systems that don't support symbolic links this option is undefined. .TP \fBfile \fBrootname \fIname\fR Return all of the characters in \fIname\fR up to but not including the last ``.'' character in the name. If \fIname\fR doesn't contain a dot, then return \fIname\fR. .TP \fBfile \fBsize \fIname\fR Return a decimal string giving the size of file \fIname\fR in bytes. If the file doesn't exist or its size cannot be queried then an error is generated. .TP \fBfile \fBstat \fIname varName\fR Invoke the \fBstat\fR kernel call on \fIname\fR, and use the variable given by \fIvarName\fR to hold information returned from the kernel call. \fIVarName\fR is treated as an array variable, and the following elements of that variable are set: \fBatime\fR, \fBctime\fR, \fBdev\fR, \fBgid\fR, \fBino\fR, \fBmode\fR, \fBmtime\fR, \fBnlink\fR, \fBsize\fR, \fBtype\fR, \fBuid\fR. Each element except \fBtype\fR is a decimal string with the value of the corresponding field from the \fBstat\fR return structure; see the manual entry for \fBstat\fR for details on the meanings of the values. The \fBtype\fR element gives the type of the file in the same form returned by the command \fBfile type\fR. This command returns an empty string. .TP \fBfile \fBtail \fIname\fR Return all of the characters in \fIname\fR after the last slash. If \fIname\fR contains no slashes then return \fIname\fR. .TP \fBfile \fBtype \fIname\fR Returns a string giving the type of file \fIname\fR, which will be one of \fBfile\fR, \fBdirectory\fR, \fBcharacterSpecial\fR, \fBblockSpecial\fR, \fBfifo\fR, \fBlink\fR, or \fBsocket\fR. .TP \fBfile \fBwritable \fIname\fR Return \fB1\fR if file \fIname\fR is writable by the current user, \fB0\fR otherwise. .RE .IP The \fBfile\fR commands that return 0/1 results are often used in conditional or looping commands, for example: .RS .DS \fBif {![file exists foo]} then {error {bad file name}} else {...}\fR .DE .VE .RE .TP \fBflush \fIfileId\fR .VS Flushes any output that has been buffered for \fIfileId\fR. \fIFileId\fR must have been the return value from a previous call to \fBopen\fR, or it may be \fBstdout\fR or \fBstderr\fR to access one of the standard I/O streams; it must refer to a file that was opened for writing. This command returns an empty string. .VE .TP \fBfor \fIstart test next body\fR \fBFor\fR is a looping command, similar in structure to the C \fBfor\fR statement. The \fIstart\fR, \fInext\fR, and \fIbody\fR arguments must be Tcl command strings, and \fItest\fR is an expression string. The \fBfor\fR command first invokes the Tcl interpreter to execute \fIstart\fR. Then it repeatedly evaluates \fItest\fR as an expression; if the result is non-zero it invokes the Tcl interpreter on \fIbody\fR, then invokes the Tcl interpreter on \fInext\fR, then repeats the loop. The command terminates when \fItest\fR evaluates to 0. If a \fBcontinue\fR command is invoked within \fIbody\fR then any remaining commands in the current execution of \fIbody\fR are skipped; processing continues by invoking the Tcl interpreter on \fInext\fR, then evaluating \fItest\fR, and so on. If a \fBbreak\fR command is invoked within \fIbody\fR or \fInext\fR, then the \fBfor\fR command will return immediately. The operation of \fBbreak\fR and \fBcontinue\fR are similar to the corresponding statements in C. \fBFor\fR returns an empty string. .TP \fBforeach \fIvarname list body\fR In this command, \fIvarname\fR is the name of a variable, \fIlist\fR is a list of values to assign to \fIvarname\fR, and \fIbody\fR is a collection of Tcl commands. For each field in \fIlist\fR (in order from left to right), \fBforeach\fR assigns the contents of the field to \fIvarname\fR (as if the \fBlindex\fR command had been used to extract the field), then calls the Tcl interpreter to execute \fIbody\fR. The \fBbreak\fR and \fBcontinue\fR statements may be invoked inside \fIbody\fR, with the same effect as in the \fBfor\fR command. \fBForeach\fR returns an empty string. .TP \fBformat \fIformatString \fR?\fIarg arg ...\fR? This command generates a formatted string in the same way as the C \fBsprintf\fR procedure (it uses \fBsprintf\fR in its implementation). \fIFormatString\fR indicates how to format the result, using \fB%\fR fields as in \fBsprintf\fR, and the additional arguments, if any, provide values to be substituted into the result. All of the \fBsprintf\fR options are valid; see the \fBsprintf\fR man page for details. Each \fIarg\fR must match the expected type from the \fB%\fR field in \fIformatString\fR; the \fBformat\fR command converts each argument to the correct type (floating, integer, etc.) before passing it to \fBsprintf\fR for formatting. The only unusual conversion is for \fB%c\fR; in this case the argument must be a decimal string, which will then be converted to the corresponding ASCII character value. \fBFormat\fR does backslash substitution on its \fIformatString\fR argument, so backslash sequences in \fIformatString\fR will be handled correctly even if the argument is in braces. The return value from \fBformat\fR is the formatted string. .TP \fBgets \fIfileId\fR ?\fIvarName\fR? .VS Reads the next line from the file given by \fIfileId\fR and discards the terminating newline character. If \fIvarName\fR is specified, then the line is placed in the variable by that name and the return value is a count of the number of characters read (not including the newline). If the end of the file is reached before reading any characters then \-1 is returned and \fIvarName\fR is set to an empty string. If \fIvarName\fR is not specified then the return value will be the line (minus the newline character) or an empty string if the end of the file is reached before reading any characters. An empty string will also be returned if a line contains no characters except the newline, so \fBeof\fR may have to be used to determine what really happened. If the last character in the file is not a newline character, then \fBgets\fR behaves as if there were an additional newline character at the end of the file. \fIFileId\fR must be \fBstdin\fR or the return value from a previous call to \fBopen\fR; it must refer to a file that was opened for reading. .VE .TP \fBglob \fR?\fB\-nocomplain\fR? \fIfilename\fR ?\fIfilename ...\fR? This command performs filename globbing, using csh rules. The returned value from \fBglob\fR is the list of expanded filenames. .VS If \fB\-nocomplain\fR is specified as the first argument then an empty list may be returned; otherwise an error is returned if the expanded list is empty. The \fB\-nocomplain\fR argument must be provided exactly: an abbreviation will not be accepted. .VE .TP \fBglobal \fIvarname \fR?\fIvarname ...\fR? This command is ignored unless a Tcl procedure is being interpreted. If so, then it declares the given \fIvarname\fR's to be global variables rather than local ones. For the duration of the current procedure (and only while executing in the current procedure), any reference to any of the \fIvarname\fRs will be bound to a global variable instead of a local one. .TP \fBhistory \fR?\fIoption\fR? ?\fIarg arg ...\fR? Note: this command may not be available in all Tcl-based applications. Typically, only those that receive command input in a typescript form will support history. The \fBhistory\fR command performs one of several operations related to recently-executed commands recorded in a history list. Each of these recorded commands is referred to as an ``event''. When specifying an event to the \fBhistory\fR command, the following forms may be used: .RS .IP [1] A number: if positive, it refers to the event with that number (all events are numbered starting at 1). If the number is negative, it selects an event relative to the current event (\fB\-1\fR refers to the previous event, \fB\-2\fR to the one before that, and so on). .IP [2] A string: selects the most recent event that matches the string. An event is considered to match the string either if the string is the same as the first characters of the event, or if the string matches the event in the sense of the \fBstring match\fR command. .LP The \fBhistory\fR command can take any of the following forms: .TP \fBhistory\fR Same .VS as \fBhistory info\fR, described below. .VE .TP \fBhistory add\fI command \fR?\fBexec\fR? Add the \fIcommand\fR argument to the history list as a new event. If \fBexec\fR is specified (or abbreviated) then the command is also executed and its result is returned. If \fBexec\fR isn't specified then an empty string is returned as result. .TP \fBhistory change\fI newValue\fR ?\fIevent\fR? Replace the value recorded for an event with \fInewValue\fR. \fIEvent\fR specifies the event to replace, and defaults to the \fIcurrent\fR event (not event \fB\-1\fR). This command is intended for use in commands that implement new forms of history substitution and wish to replace the current event (which invokes the substitution) with the command created through substitution. The return value is an empty string. .TP \fBhistory event\fR ?\fIevent\fR? Returns the value of the event given by \fIevent\fR. \fIEvent\fR defaults to \fB\-1\fR. This command causes history revision to occur: see below for details. .TP \fBhistory info \fR?\fIcount\fR? Returns a formatted string (intended for humans to read) giving the event number and contents for each of the events in the history list except the current event. If \fIcount\fR is specified then only the most recent \fIcount\fR events are returned. .TP \fBhistory keep \fIcount\fR This command may be used to change the size of the history list to \fIcount\fR events. Initially, 20 events are retained in the history list. This command returns an empty string. .TP \fBhistory nextid\fR Returns the number of the next event to be recorded in the history list. It is useful for things like printing the event number in command-line prompts. .TP \fBhistory redo \fR?\fIevent\fR? Re-execute the command indicated by \fIevent\fR and return its result. \fIEvent\fR defaults to \fB\-1\fR. This command results in history revision: see below for details. .TP \fBhistory substitute \fIold new \fR?\fIevent\fR? Retrieve the command given by \fIevent\fR (\fB\-1\fR by default), replace any occurrences of \fIold\fR by \fInew\fR in the command (only simple character equality is supported; no wild cards), execute the resulting command, and return the result of that execution. This command results in history revision: see below for details. .TP \fBhistory words \fIselector\fR ?\fIevent\fR? Retrieve from the command given by \fIevent\fR (\fB\-1\fR by default) the words given by \fIselector\fR, and return those words in a string separated by spaces. The \fBselector\fR argument has three forms. If it is a single number then it selects the word given by that number (\fB0\fR for the command name, \fB1\fR for its first argument, and so on). If it consists of two numbers separated by a dash, then it selects all the arguments between those two. Otherwise \fBselector\fR is treated as a pattern; all words matching that pattern (in the sense of \fBstring match\fR) are returned. In the numeric forms \fB$\fR may be used to select the last word of a command. For example, suppose the most recent command in the history list is .RS .DS \fBformat {%s is %d years old} Alice [expr $ageInMonths/12]\fR .DE Below are some history commands and the results they would produce: .DS .ta 4c .fi .UL Command " " .UL Result .nf \fBhistory words $ [expr $ageInMonths/12]\fR \fBhistory words 1-2 {%s is %d years old} Alice\fR \fBhistory words *a*o* {%s is %d years old} [expr $ageInMonths/12]\fR .DE \fBHistory words\fR results in history revision: see below for details. .RE The history options \fBevent\fR, \fBredo\fR, \fBsubstitute\fR, and \fBwords\fR result in ``history revision''. When one of these options is invoked then the current event is modified to eliminate the history command and replace it with the result of the history command. For example, suppose that the most recent command in the history list is .DS \fBset a [expr $b+2]\fR .DE and suppose that the next command invoked is one of the ones on the left side of the table below. The command actually recorded in the history event will be the corresponding one on the right side of the table. .ne 1.5c .DS .ta 4c .fi .UL "Command Typed" " " .UL "Command Recorded" .nf \fBhistory redo set a [expr $b+2]\fR \fBhistory s a b set b [expr $b+2]\fR \fBset c [history w 2] set c [expr $b+2]\fR .DE .VS History revision is needed because event specifiers like \fB\-1\fR are only valid at a particular time: once more events have been added to the history list a different event specifier would be needed. History revision occurs even when \fBhistory\fR is invoked indirectly from the current event (e.g. a user types a command that invokes a Tcl procedure that invokes \fBhistory\fR): the top-level command whose execution eventually resulted in a \fBhistory\fR command is replaced. If you wish to invoke commands like \fBhistory words\fR without history revision, you can use \fBhistory event\fR to save the current history event and then use \fBhistory change\fR to restore it later. .VE .RE .TP \fBif \fIexpr1 \fR?\fBthen\fR? \fIbody1 \fBelseif \fIexpr2 \fR?\fBthen\fR? \fIbody2\fR \fBelseif\fR ... \fR?\fBelse\fR? ?\fIbodyN\fR? .VS The \fIif\fR command evaluates \fIexpr1\fR as an expression (in the same way that \fBexpr\fR evaluates its argument). The value of the expression must be numeric; if it is non-zero then \fIbody1\fR is executed by passing it to the Tcl interpreter. Otherwise \fIexpr2\fR is evaluated as an expression and if it is non-zero then \fBbody2\fR is executed, and so on. If none of the expressions evaluates to non-zero then \fIbodyN\fR is executed. The \fBthen\fR and \fBelse\fR arguments are optional ``noise words'' to make the command easier to read. There may be any number of \fBelseif\fR clauses, including zero. \fIBodyN\fR may also be omitted as long as \fBelse\fR is omitted too. The return value from the command is the result of the body script that was executed, or an empty string if none of the expressions was non-zero and there was no \fIbodyN\fR. .VE .TP \fBincr \fIvarName \fR?\fIincrement\fR? .VS Increment the value stored in the variable whose name is \fIvarName\fR. The value of the variable must be integral. If \fIincrement\fR is supplied then its value (which must be an integer) is added to the value of variable \fIvarName\fR; otherwise 1 is added to \fIvarName\fR. The new value is stored as a decimal string in variable \fIvarName\fR and also returned as result. .VE .TP \fBinfo \fIoption \fR?\fIarg arg ...\fR? Provide information about various internals to the Tcl interpreter. The legal \fIoption\fR's (which may be abbreviated) are: .RS .TP \fBinfo args \fIprocname\fR Returns a list containing the names of the arguments to procedure \fIprocname\fR, in order. \fIProcname\fR must be the name of a Tcl command procedure. .TP \fBinfo body \fIprocname\fR Returns the body of procedure \fIprocname\fR. \fIProcname\fR must be the name of a Tcl command procedure. .TP \fBinfo cmdcount\fR Returns a count of the total number of commands that have been invoked in this interpreter. .TP \fBinfo commands \fR?\fIpattern\fR? If \fIpattern\fR isn't specified, returns a list of names of all the Tcl commands, including both the built-in commands written in C and the command procedures defined using the \fBproc\fR command. If \fIpattern\fR is specified, only those names matching \fIpattern\fR are returned. Matching is determined using the same rules as for \fBstring match\fR. .TP \fBinfo complete \fIcommand\fR .VS Returns 1 if \fIcommand\fR is a complete Tcl command in the sense of having no unclosed quotes, braces, brackets or array element names, If the command doesn't appear to be complete then 0 is returned. This command is typically used in line-oriented input environments to allow users to type in commands that span multiple lines; if the command isn't complete, the script can delay evaluating it until additional lines have been typed to complete the command. .VE .TP \fBinfo default \fIprocname arg varname\fR \fIProcname\fR must be the name of a Tcl command procedure and \fIarg\fR must be the name of an argument to that procedure. If \fIarg\fR doesn't have a default value then the command returns \fB0\fR. Otherwise it returns \fB1\fR and places the default value of \fIarg\fR into variable \fIvarname\fR. .TP \fBinfo exists \fIvarName\fR Returns \fB1\fR if the variable named \fIvarName\fR exists in the current context (either as a global or local variable), returns \fB0\fR otherwise. .TP \fBinfo globals \fR?\fIpattern\fR? If \fIpattern\fR isn't specified, returns a list of all the names of currently-defined global variables. If \fIpattern\fR is specified, only those names matching \fIpattern\fR are returned. Matching is determined using the same rules as for \fBstring match\fR. .TP \fBinfo level\fR ?\fInumber\fR? If \fInumber\fR is not specified, this command returns a number giving the stack level of the invoking procedure, or 0 if the command is invoked at top-level. If \fInumber\fR is specified, then the result is a list consisting of the name and arguments for the procedure call at level \fInumber\fR on the stack. If \fInumber\fR is positive then it selects a particular stack level (1 refers to the top-most active procedure, 2 to the procedure it called, and so on); otherwise it gives a level relative to the current level (0 refers to the current procedure, -1 to its caller, and so on). See the \fBuplevel\fR command for more information on what stack levels mean. .TP \fBinfo library\fR .VS Returns the name of the library directory in which standard Tcl scripts are stored. The default value for the library is compiled into Tcl, but it .VS may be overridden by setting the TCL_LIBRARY environment variable. If there is no TCL_LIBRARY variable and no compiled-in value then and error is generated. .VE See the \fBlibrary\fR manual entry for details of the facilities provided by the Tcl script library. Normally each application will have its own application-specific script library in addition to the Tcl script library; I suggest that each application set a global variable with a name like .VS \fB$\fIapp\fB_library\fR (where \fIapp\fR is the application's name) .VE to hold the location of that application's library directory. .VE .TP \fBinfo locals \fR?\fIpattern\fR? If \fIpattern\fR isn't specified, returns a list of all the names of currently-defined local variables, including arguments to the current procedure, if any. .VS Variables defined with the \fBglobal\fR and \fBupvar\fR commands will not be returned. .VE If \fIpattern\fR is specified, only those names matching \fIpattern\fR are returned. Matching is determined using the same rules as for \fBstring match\fR. .TP \fBinfo procs \fR?\fIpattern\fR? If \fIpattern\fR isn't specified, returns a list of all the names of Tcl command procedures. If \fIpattern\fR is specified, only those names matching \fIpattern\fR are returned. Matching is determined using the same rules as for \fBstring match\fR. .TP \fBinfo script\fR .VS If a Tcl script file is currently being evaluated (i.e. there is a call to \fBTcl_EvalFile\fR active or there is an active invocation of the \fBsource\fR command), then this command returns the name of the innermost file being processed. Otherwise the command returns an empty string. .VE .TP \fBinfo tclversion\fR Returns the version number for this version of Tcl in the form \fIx.y\fR, where changes to \fIx\fR represent major changes with probable incompatibilities and changes to \fIy\fR represent small enhancements and bug fixes that retain backward compatibility. .TP \fBinfo vars\fR ?\fIpattern\fR? If \fIpattern\fR isn't specified, returns a list of all the names of currently-visible variables, including both locals and currently-visible globals. If \fIpattern\fR is specified, only those names matching \fIpattern\fR are returned. Matching is determined using the same rules as for \fBstring match\fR. .RE .TP \fBjoin \fIlist \fR?\fIjoinString\fR? .VS The \fIlist\fR argument must be a valid Tcl list. This command returns the string formed by joining all of the elements of \fIlist\fR together with \fIjoinString\fR separating each adjacent pair of elements. The \fIjoinString\fR argument defaults to a space character. .VE .TP \fBlappend \fIvarName value \fR?\fIvalue value ...\fR? .VS Treat the variable given by \fIvarName\fR as a list and append each of the \fIvalue\fR arguments to that list as a separate element, with spaces between elements. If \fIvarName\fR doesn't exist, it is created as a list with elements given by the \fIvalue\fR arguments. \fBLappend\fR is similar to \fBappend\fR except that the \fIvalue\fRs are appended as list elements rather than raw text. This command provides a relatively efficient way to build up large lists. For example, ``\fBlappend a $b\fR'' is much more efficient than ``\fBset a [concat $a [list $b]]\fR'' when \fB$a\fR is long. .TP \fBlindex \fIlist index\fR Treats \fIlist\fR as a Tcl list and returns the \fIindex\fR'th element from it (0 refers to the first element of the list). In extracting the element, \fIlindex\fR observes the same rules concerning braces and quotes and backslashes as the Tcl command interpreter; however, variable substitution and command substitution do not occur. If \fIindex\fR is negative or greater than or equal to the number of elements in \fIvalue\fR, then an empty string is returned. .TP \fBlinsert \fIlist index element \fR?\fIelement element ...\fR? This command produces a new list from \fIlist\fR by inserting all of the \fIelement\fR arguments just before the \fIindex\fRth element of \fIlist\fR. Each \fIelement\fR argument will become a separate element of the new list. If \fIindex\fR is less than or equal to zero, then the new elements are inserted at the beginning of the list. If \fIindex\fR is greater than or equal to the number of elements in the list, then the new elements are appended to the list. .VE .TP \fBlist \fIarg \fR?\fIarg ...\fR? This command returns a list comprised of all the \fIarg\fRs. Braces and backslashes get added as necessary, so that the \fBindex\fR command may be used on the result to re-extract the original arguments, and also so that \fBeval\fR may be used to execute the resulting list, with \fIarg1\fR comprising the command's name and the other \fIarg\fRs comprising its arguments. \fBList\fR produces slightly different results than \fBconcat\fR: \fBconcat\fR removes one level of grouping before forming the list, while \fBlist\fR works directly from the original arguments. For example, the command .RS .DS \fBlist a b {c d e} {f {g h}} .DE will return .DS \fBa b {c d e} {f {g h}} .DE while \fBconcat\fR with the same arguments will return .DS \fBa b c d e f {g h}\fR .DE .RE .br .VS .TP \fBllength \fIlist\fR Treats \fIlist\fR as a list and returns a decimal string giving the number of elements in it. .TP \fBlrange \fIlist first last \fIList\fR must be a valid Tcl list. This command will return a new list consisting of elements \fIfirst\fR through \fIlast\fR, inclusive. \fILast\fR may be \fBend\fR (or any abbreviation of it) to refer to the last element of the list. If \fIfirst\fR is less than zero, it is treated as if it were zero. If \fIlast\fR is greater than or equal to the number of elements in the list, then it is treated as if it were \fBend\fR. If \fIfirst\fR is greater than \fIlast\fR then an empty string is returned. Note: ``\fBlrange \fIlist first first\fR'' does not always produce the same result as ``\fBlindex \fIlist first\fR'' (although it often does for simple fields that aren't enclosed in braces); it does, however, produce exactly the same results as ``\fBlist [lindex \fIlist first\fB]\fR'' .TP \fBlreplace \fIlist first last \fR?\fIelement element ...\fR? Returns a new list formed by replacing one or more elements of \fIlist\fR with the \fIelement\fR arguments. \fIFirst\fR gives the index in \fIlist\fR of the first element to be replaced. If \fIfirst\fR is less than zero then it refers to the first element of \fIlist\fR; the element indicated by \fIfirst\fR must exist in the list. \fILast\fR gives the index in \fIlist\fR of the last element to be replaced; it must be greater than or equal to \fIfirst\fR. \fILast\fR may be \fBend\fR (or any abbreviation of it) to indicate that all elements between \fIfirst\fR and the end of the list should be replaced. The \fIelement\fR arguments specify zero or more new arguments to be added to the list in place of those that were deleted. Each \fIelement\fR argument will become a separate element of the list. If no \fIelement\fR arguments are specified, then the elements between \fIfirst\fR and \fIlast\fR are simply deleted. .TP \fBlsearch \fIlist pattern\fR Search the elements of \fIlist\fR to see if one of them matches \fIpattern\fR. If so, the command returns the index of the first matching element. If not, the command returns \fB\-1\fR. Pattern matching is done in the same way as for the \fBstring match\fR command. .TP \fBlsort \fIlist\fR Sort the elements of \fIlist\fR, returning a new list in sorted order. ASCII sorting is used, with the result in increasing order. .VE .TP \fBopen \fIfileName\fR ?\fIaccess\fR? .VS Opens a file and returns an identifier that may be used in future invocations of commands like \fBread\fR, \fBputs\fR, and \fBclose\fR. \fIFileName\fR gives the name of the file to open; if it starts with a tilde then tilde substitution is performed as described for \fBTcl_TildeSubst\fR. If the first character of \fIfileName\fR is ``|'' then the remaining characters of \fIfileName\fR are treated as a command pipeline to invoke, in the same style as for \fBexec\fR. In this case, the identifier returned by \fBopen\fR may be used to write to the command's input pipe or read from its output pipe. The \fIaccess\fR argument indicates the way in which the file (or command pipeline) is to be accessed. It may have any of the following values: .RS .TP \fBr\fR Open the file for reading only; the file must already exist. .TP \fBr+\fR Open the file for both reading and writing; the file must already exist. .TP \fBw\fR Open the file for writing only. Truncate it if it exists. If it doesn't exist, create a new file. .TP \fBw+\fR Open the file for reading and writing. Truncate it if it exists. If it doesn't exist, create a new file. .TP \fBa\fR Open the file for writing only. The file must already exist, and the file is positioned so that new data is appended to the file. .TP \fBa+\fR Open the file for reading and writing. If the file doesn't exist, create a new empty file. Set the initial access position to the end of the file. .PP \fIAccess\fR defaults to \fBr\fR. If a file is opened for both reading and writing, then \fBseek\fR must be invoked between a read and a write, or vice versa (this restriction does not apply to command pipelines opened with \fBopen\fR). When \fIfileName\fR specifies a command pipeline and a write-only access is used, then standard output from the pipeline is directed to the current standard output unless overridden by the command. When \fIfileName\fR specifies a command pipeline and a read-only access is used, then standard input from the pipeline is taken from the current standard input unless overridden by the command. .RE .VE .TP \fBproc \fIname args body\fR The \fBproc\fR command creates a new Tcl command procedure, \fIname\fR, replacing any existing command there may have been by that name. Whenever the new command is invoked, the contents of \fIbody\fR will be executed by the Tcl interpreter. \fIArgs\fR specifies the formal arguments to the procedure. It consists of a list, possibly empty, each of whose elements specifies one argument. Each argument specifier is also a list with either one or two fields. If there is only a single field in the specifier, then it is the name of the argument; if there are two fields, then the first is the argument name and the second is its default value. braces and backslashes may be used in the usual way to specify complex default values. .IP When \fIname\fR is invoked, a local variable will be created for each of the formal arguments to the procedure; its value will be the value of corresponding argument in the invoking command or the argument's default value. Arguments with default values need not be specified in a procedure invocation. However, there must be enough actual arguments for all the formal arguments that don't have defaults, and there must not be any extra actual arguments. There is one special case to permit procedures with variable numbers of arguments. If the last formal argument has the name \fBargs\fR, then a call to the procedure may contain more actual arguments than the procedure has formals. In this case, all of the actual arguments starting at the one that would be assigned to \fBargs\fR are combined into a list (as if the \fBlist\fR command had been used); this combined value is assigned to the local variable \fBargs\fR. .IP When \fIbody\fR is being executed, variable names normally refer to local variables, which are created automatically when referenced and deleted when the procedure returns. One local variable is automatically created for each of the procedure's arguments. Global variables can only be accessed by invoking the \fBglobal\fR command. .IP The \fBproc\fR command returns the null string. When a procedure is invoked, the procedure's return value is the value specified in a \fBreturn\fR command. If the procedure doesn't execute an explicit \fBreturn\fR, then its return value is the value of the last command executed in the procedure's body. If an error occurs while executing the procedure body, then the procedure-as-a-whole will return that same error. .TP \fBputs \fR?\fB\-nonewline\fR? ?\fIfileId\fR? \fIstring\fR .VS Writes the characters given by \fIstring\fR to the file given by \fIfileId\fR. \fIFileId\fR must have been the return value from a previous call to \fBopen\fR, or it may be \fBstdout\fR or \fBstderr\fR to refer to one of the standard I/O channels; it must refer to a file that was opened for writing. If no \fIfileId\fR is specified then it defaults to \fBstdout\fR. \fBPuts\fR normally outputs a newline character after \fIstring\fR, .VS but this feature may be suppressed by specifying the \fB\-nonewline\fR switch. .VE Output to files is buffered internally by Tcl; the \fBflush\fR command may be used to force buffered characters to be output. .TP \fBpwd\fR .br Returns the path name of the current working directory. .TP \fBread \fR?\fB\-nonewline\fR? \fIfileId\fR .VS .TP \fBread \fIfileId numBytes\fR In the first form, all of the remaining bytes are read from the file given by \fIfileId\fR; they are returned as the result of the command. If the \fB\-nonewline\fR switch is specified then the last character of the file is discarded if it is a newline. .VE In the second form, the extra argument specifies how many bytes to read; exactly this many bytes will be read and returned, unless there are fewer than \fInumBytes\fR bytes left in the file; in this case, all the remaining bytes are returned. \fIFileId\fR must be \fBstdin\fR or the return value from a previous call to \fBopen\fR; it must refer to a file that was opened for reading. .TP \fBregexp \fR?\fB\-indices\fR? \fR?\fB\-nocase\fR? \fIexp string \fR?\fImatchVar\fR? ?\fIsubMatchVar subMatchVar ...\fR? Determines whether the regular expression \fIexp\fR matches part or all of \fIstring\fR and returns 1 if it does, 0 if it doesn't. See REGULAR EXPRESSIONS above for complete information on the syntax of \fIexp\fR and how it is matched against \fIstring\fR. .RS .LP If the \fB\-nocase\fR switch is specified then upper-case characters in \fIstring\fR are treated as lower case during the matching process. The \fB\-nocase\fR switch must be specified before \fIexp\fR and may not be abbreviated. .LP If additional arguments are specified after \fIstring\fR then they are treated as the names of variables to use to return information about which part(s) of \fIstring\fR matched \fIexp\fR. \fIMatchVar\fR will be set to the range of \fIstring\fR that matched all of \fIexp\fR. The first \fIsubMatchVar\fR will contain the characters in \fIstring\fR that matched the leftmost parenthesized subexpression within \fIexp\fR, the next \fIsubMatchVar\fR will contain the characters that matched the next parenthesized subexpression to the right in \fIexp\fR, and so on. .LP Normally, \fImatchVar\fR and the \fIsubMatchVar\fRs are set to hold the matching characters from \fBstring\fR. However, if the \fB\-indices\fR switch is specified then each variable will contain a list of two decimal strings giving the indices in \fIstring\fR of the first and last characters in the matching range of characters. The \fB\-indices\fR switch must be specified before the \fIexp\fR argument and may not be abbreviated. .LP If there are more \fIsubMatchVar\fR's than parenthesized subexpressions within \fIexp\fR, or if a particular subexpression in \fIexp\fR doesn't match the string (e.g. because it was in a portion of the expression that wasn't matched), then the corresponding \fIsubMatchVar\fR will be set to ``\fB\-1 \-1\fR'' if \fB\-indices\fR has been specified or to an empty string otherwise. .RE .TP \fBregsub \fR?\fB\-all\fR? ?\fB\-nocase\fR? \fIexp string subSpec varName\fR This command matches the regular expression \fIexp\fR against \fIstring\fR using the rules described in REGULAR EXPRESSIONS above. If there is no match, then the command returns 0 and does nothing else. If there is a match, then the command returns 1 and also copies \fIstring\fR to the variable whose name is given by \fIvarName\fR. When copying \fIstring\fR, the portion of \fIstring\fR that matched \fIexp\fR is replaced with \fIsubSpec\fR. If \fIsubSpec\fR contains a ``&'' or ``\e0'', then it is replaced in the substitution with the portion of \fIstring\fR that matched \fIexp\fR. If \fIsubSpec\fR contains a ``\e\fIn\fR'', where \fIn\fR is a digit between 1 and 9, then it is replaced in the substitution with the portion of \fIstring\fR that matched the \fIn\fR-th parenthesized subexpression of \fIexp\fR. Additional backslashes may be used in \fIsubSpec\fR to prevent special interpretation of ``&'' or ``\e0'' or ``\e\fIn\fR'' or backslash. The use of backslashes in \fIsubSpec\fR tends to interact badly with the Tcl parser's use of backslashes, so it's generally safest to enclose \fIsubSpec\fR in braces if it includes backslashes. If the \fB\-all\fR argument is specified, then all ranges in \fIstring\fR that match \fIexp\fR are found and substitution is performed for each of these ranges; otherwise only the first matching range is found and substituted. If \fB\-all\fR is specified, then ``&'' and ``\e\fIn\fR'' sequences are handled for each substitution using the information from the corresponding match. If the \fB\-nocase\fR argument is specified, then upper-case characters in \fIstring\fR are converted to lower-case before matching against \fIexp\fR; however, substitutions specified by \fIsubSpec\fR use the original unconverted form of \fIstring\fR. The \fB\-all\fR and \fB\-nocase\fR arguments must be specified exactly: no abbreviations are permitted. .VE .TP \fBrename \fIoldName newName\fR Rename the command that used to be called \fIoldName\fR so that it is now called \fInewName\fR. If \fInewName\fR is an empty string (e.g. {}) then \fIoldName\fR is deleted. The \fBrename\fR command returns an empty string as result. .TP \fBreturn \fR?\fIvalue\fR? Return immediately from the current procedure (or top-level command or \fBsource\fR command), with \fIvalue\fR as the return value. If \fIvalue\fR is not specified, an empty string will be returned as result. .TP \fBscan \fIstring format varname1 \fR?\fIvarname2 ...\fR? This command parses fields from an input string in the same fashion as the C \fBsscanf\fR procedure. \fIString\fR gives the input to be parsed and \fIformat\fR indicates how to parse it, using \fB%\fR fields as in \fBsscanf\fR. All of the \fBsscanf\fR options are valid; see the \fBsscanf\fR man page for details. Each \fIvarname\fR gives the name of a variable; when a field is scanned from \fIstring\fR, the result is converted back into a string and assigned to the corresponding \fIvarname\fR. The only unusual conversion is for \fB%c\fR. For \fB%c\fR conversions a single character value is converted to a decimal string, which is then assigned to the corresponding \fIvarname\fR; .VS no field width may be specified for this conversion. .TP \fBseek \fIfileId offset \fR?\fIorigin\fR? Change the current access position for \fIfileId\fR. The \fIoffset\fR and \fIorigin\fR arguments specify the position at which the next read or write will occur for \fIfileId\fR. \fIOffset\fR must be a number (which may be negative) and \fIorigin\fR must be one of the following: .RS .TP \fBstart\fR The new access position will be \fIoffset\fR bytes from the start of the file. .TP \fBcurrent\fR The new access position will be \fIoffset\fR bytes from the current access position; a negative \fIoffset\fR moves the access position backwards in the file. .TP \fBend\fR The new access position will be \fIoffset\fR bytes from the end of the file. A negative \fIoffset\fR places the access position before the end-of-file, and a positive \fIoffset\fR places the access position after the end-of-file. .LP The \fIorigin\fR argument defaults to \fBstart\fR. \fIFileId\fR must have been the return value from a previous call to \fBopen\fR, or it may be \fBstdin\fR, \fBstdout\fR, or \fBstderr\fR to refer to one of the standard I/O channels. This command returns an empty string. .RE .VE .TP \fBset \fIvarname \fR?\fIvalue\fR? Returns the value of variable \fIvarname\fR. If \fIvalue\fR is specified, then set the value of \fIvarname\fR to \fIvalue\fR, creating a new variable if one doesn't already exist, and return its value. .VS If \fIvarName\fR contains an open parenthesis and ends with a close parenthesis, then it refers to an array element: the characters before the open parenthesis are the name of the array, and the characters between the parentheses are the index within the array. Otherwise \fIvarName\fR refers to a scalar variable. .VE If no procedure is active, then \fIvarname\fR refers to a global variable. If a procedure is active, then \fIvarname\fR refers to a parameter or local variable of the procedure, unless the \fIglobal\fR command has been invoked to declare \fIvarname\fR to be global. .TP \fBsource \fIfileName\fR Read file \fIfileName\fR and pass the contents to the Tcl interpreter as a sequence of commands to execute in the normal fashion. The return value of \fBsource\fR is the return value of the last command executed from the file. If an error occurs in executing the contents of the file, then the \fBsource\fR command will return that error. If a \fBreturn\fR command is invoked from within the file, the remainder of the file will be skipped and the \fBsource\fR command will return normally with the result from the \fBreturn\fR command. If \fIfileName\fR starts with a tilde, then it is tilde-substituted as described in the \fBTcl_TildeSubst\fR manual entry. .TP \fBsplit \fIstring \fR?\fIsplitChars\fR? Returns a list created by splitting \fIstring\fR at each character that is in the \fIsplitChars\fR argument. Each element of the result list will consist of the characters from \fIstring\fR between instances of the characters in \fIsplitChars\fR. Empty list elements will be generated if \fIstring\fR contains adjacent characters in \fIsplitChars\fR, or if the first or last character of \fIstring\fR is in \fIsplitChars\fR. If \fIsplitChars\fR is an empty string then each character of \fIstring\fR becomes a separate element of the result list. \fISplitChars\fR defaults to the standard white-space characters. For example, .RS .DS \fBsplit "comp.unix.misc" .\fR .DE returns \fB"comp unix misc"\fR and .DS \fBsplit "Hello world" {}\fR .DE returns \fB"H e l l o { } w o r l d"\fR. .VE .RE .TP \fBstring \fIoption arg \fR?\fIarg ...?\fR Perform one of several string operations, depending on \fIoption\fR. The legal \fIoption\fRs (which may be abbreviated) are: .RS .TP \fBstring compare \fIstring1 string2\fR Perform a character-by-character comparison of strings \fIstring1\fR and \fIstring2\fR in the same way as the C \fBstrcmp\fR procedure. Return -1, 0, or 1, depending on whether \fIstring1\fR is lexicographically less than, equal to, or greater than \fIstring2\fR. .TP \fBstring first \fIstring1 string2\fR Search \fIstring2\fR for a sequence of characters that exactly match the characters in \fIstring1\fR. If found, return the index of the first character in the first such match within \fIstring2\fR. If not found, return -1. .br .VS .TP \fBstring index \fIstring charIndex\fR Returns the \fIcharIndex\fR'th character of the \fIstring\fR argument. A \fIcharIndex\fR of 0 corresponds to the first character of the string. If \fIcharIndex\fR is less than 0 or greater than or equal to the length of the string then an empty string is returned. .VE .TP \fBstring last \fIstring1 string2\fR Search \fIstring2\fR for a sequence of characters that exactly match the characters in \fIstring1\fR. If found, return the index of the first character in the last such match within \fIstring2\fR. If there is no match, then return \-1. .br .VS .TP \fBstring length \fIstring\fR Returns a decimal string giving the number of characters in \fIstring\fR. .VE .TP \fBstring match \fIpattern\fR \fIstring\fR See if \fIpattern\fR matches \fIstring\fR; return 1 if it does, 0 if it doesn't. Matching is done in a fashion similar to that used by the C-shell. For the two strings to match, their contents must be identical except that the following special sequences may appear in \fIpattern\fR: .RS .IP \fB*\fR 10 Matches any sequence of characters in \fIstring\fR, including a null string. .IP \fB?\fR 10 Matches any single character in \fIstring\fR. .IP \fB[\fIchars\fB]\fR 10 Matches any character in the set given by \fIchars\fR. If a sequence of the form \fIx\fB\-\fIy\fR appears in \fIchars\fR, then any character between \fIx\fR and \fIy\fR, inclusive, will match. .IP \fB\e\fIx\fR 10 Matches the single character \fIx\fR. This provides a way of avoiding the special interpretation of the characters \fB*?[]\e\fR in \fIpattern\fR. .RE .br .VS .TP \fBstring range \fIstring first last\fR Returns a range of consecutive characters from \fIstring\fR, starting with the character whose index is \fIfirst\fR and ending with the character whose index is \fIlast\fR. An index of 0 refers to the first character of the string. \fILast\fR may be \fBend\fR (or any abbreviation of it) to refer to the last character of the string. If \fIfirst\fR is less than zero then it is treated as if it were zero, and if \fIlast\fR is greater than or equal to the length of the string then it is treated as if it were \fBend\fR. If \fIfirst\fR is greater than \fIlast\fR then an empty string is returned. .TP \fBstring tolower \fIstring\fR Returns a value equal to \fIstring\fR except that all upper case letters have been converted to lower case. .TP \fBstring toupper \fIstring\fR Returns a value equal to \fIstring\fR except that all lower case letters have been converted to upper case. .TP \fBstring trim \fIstring\fR ?\fIchars\fR? Returns a value equal to \fIstring\fR except that any leading or trailing characters from the set given by \fIchars\fR are removed. If \fIchars\fR is not specified then white space is removed (spaces, tabs, newlines, and carriage returns). .TP \fBstring trimleft \fIstring\fR ?\fIchars\fR? Returns a value equal to \fIstring\fR except that any leading characters from the set given by \fIchars\fR are removed. If \fIchars\fR is not specified then white space is removed (spaces, tabs, newlines, and carriage returns). .TP \fBstring trimright \fIstring\fR ?\fIchars\fR? Returns a value equal to \fIstring\fR except that any trailing characters from the set given by \fIchars\fR are removed. If \fIchars\fR is not specified then white space is removed (spaces, tabs, newlines, and carriage returns). .RE .TP \fBtell \fIfileId\fR Returns a decimal string giving the current access position in \fIfileId\fR. \fIFileId\fR must have been the return value from a previous call to \fBopen\fR, or it may be \fBstdin\fR, \fBstdout\fR, or \fBstderr\fR to refer to one of the standard I/O channels. .VE .TP \fBtime \fIcommand\fR ?\fIcount\fR? This command will call the Tcl interpreter \fIcount\fR times to execute \fIcommand\fR (or once if \fIcount\fR isn't specified). It will then return a string of the form .RS .DS \fB503 microseconds per iteration\fR .DE which indicates the average amount of time required per iteration, in microseconds. Time is measured in elapsed time, not CPU time. .RE .TP \fBtrace \fIoption\fR ?\fIarg arg ...\fR? .VS Cause Tcl commands to be executed whenever certain operations are invoked. At present, only variable tracing is implemented. The legal \fIoption\fR's (which may be abbreviated) are: .RS .TP \fBtrace variable \fIname ops command\fR Arrange for \fIcommand\fR to be executed whenever variable \fIname\fR is accessed in one of the ways given by \fIops\fR. \fIName\fR may refer to a normal variable, an element of an array, or to an array as a whole (i.e. \fIname\fR may be just the name of an array, with no parenthesized index). If \fIname\fR refers to a whole array, then \fIcommand\fR is invoked whenever any element of the array is manipulated. .RS .LP \fIOps\fR indicates which operations are of interest, and consists of one or more of the following letters: .RS .TP \fBr\fR Invoke \fIcommand\fR whenever the variable is read. .TP \fBw\fR Invoke \fIcommand\fR whenever the variable is written. .TP \fBu\fR Invoke \fIcommand\fR whenever the variable is unset. Variables can be unset explicitly with the \fBunset\fR command, or implicitly when procedures return (all of their local variables are unset). Variables are also unset when interpreters are deleted, but traces will not be invoked because there is no interpreter in which to execute them. .RE .LP When the trace triggers, three arguments are appended to \fIcommand\fR so that the actual command is as follows: .DS C \fIcommand name1 name2 op\fR .DE \fIName1\fR and \fIname2\fR give the name(s) for the variable being accessed: if the variable is a scalar then \fIname1\fR gives the variable's name and \fIname2\fR is an empty string; if the variable is an array element then \fIname1\fR gives the name of the array and name2 gives the index into the array; if an entire array is being deleted and the trace was registered on the overall array, rather than a single element, then \fIname1\fR gives the array name and \fIname2\fR is an empty string. \fIOp\fR indicates what operation is being performed on the variable, and is one of \fBr\fR, \fBw\fR, or \fBu\fR as defined above. .LP \fICommand\fR executes in the same context as the code that invoked the traced operation: if the variable was accessed as part of a Tcl procedure, then \fIcommand\fR will have access to the same local variables as code in the procedure. This context may be different than the context in which the trace was created. If \fIcommand\fR invokes a procedure (which it normally does) then the procedure will have to use \fBupvar\fR or \fBuplevel\fR if it wishes to access the traced variable. Note also that \fIname1\fR may not necessarily be the same as the name used to set the trace on the variable; differences can occur if the access is made through a variable defined with the \fBupvar\fR command. .LP For read and write traces, \fIcommand\fR can modify the variable to affect the result of the traced operation. If \fIcommand\fR modifies the value of a variable during a read or write trace, then the new value will be returned as the result of the traced operation. The return value from \fIcommand\fR is ignored except that if it returns an error of any sort then the traced operation is aborted with an error message saying that the access was denied (this mechanism can be used to implement read-only variables, for example). For write traces, \fIcommand\fR is invoked after the variable's value has been changed; it can write a new value into the variable to override the original value specified in the write operation. To implement read-only variables, \fIcommand\fR will have to restore the old value of the variable. .LP While \fIcommand\fR is executing during a read or write trace, traces on the variable are temporarily disabled. This means that reads and writes invoked by \fIcommand\fR will occur directly, without invoking \fIcommand\fR (or any other traces) again. .LP When an unset trace is invoked, the variable has already been deleted: it will appear to be undefined with no traces. If an unset occurs because of a procedure return, then the trace will be invoked in the variable context of the procedure being returned to: the stack frame of the returning procedure will no longer exist. Traces are not disabled during unset traces, so if an unset trace command creates a new trace and accesses the variable, the trace will be invoked. .LP If there are multiple traces on a variable they are invoked in order of creation, most-recent first. If one trace returns an error, then no further traces are invoked for the variable. If an array element has a trace set, and there is also a trace set on the array as a whole, the trace on the overall array is invoked before the one on the element. .LP Once created, the trace remains in effect either until the trace is removed with the \fBtrace vdelete\fR command described below, until the variable is unset, or until the interpreter is deleted. Unsetting an element of array will remove any traces on that element, but will not remove traces on the overall array. .LP This command returns an empty string. .RE .TP \fBtrace vdelete \fIname ops command\fR If there is a trace set on variable \fIname\fR with the operations and command given by \fIops\fR and \fIcommand\fR, then the trace is removed, so that \fIcommand\fR will never again be invoked. Returns an empty string. .TP \fBtrace vinfo \fIname\fR Returns a list containing one element for each trace currently set on variable \fIname\fR. Each element of the list is itself a list containing two elements, which are the \fIops\fR and \fIcommand\fR associated with the trace. If \fIname\fR doesn't exist or doesn't have any traces set, then the result of the command will be an empty string. .RE .TP \fBunknown \fIcmdName \fR?\fIarg arg ...\fR? This command doesn't actually exist as part of Tcl, but Tcl will invoke it if it does exist. If the Tcl interpreter encounters a command name for which there is not a defined command, then Tcl checks for the existence of a command named \fBunknown\fR. If there is no such command, then the interpeter returns an error. If the \fBunknown\fR command exists, then it is invoked with arguments consisting of the fully-substituted name and arguments for the original non-existent command. The \fBunknown\fR command typically does things like searching through library directories for a command procedure with the name \fIcmdName\fR, or expanding abbreviated command names to full-length, or automatically executing unknown commands as UNIX sub-processes. In some cases (such as expanding abbreviations) \fBunknown\fR will change the original command slightly and then (re-)execute it. The result of the \fBunknown\fR command is used as the result for the original non-existent command. .TP \fBunset \fIname \fR?\fIname name ...\fR? Remove one or more variables. Each \fIname\fR is a variable name, specified in any of the ways acceptable to the \fBset\fR command. If a \fIname\fR refers to an element of an array, then that element is removed without affecting the rest of the array. If a \fIname\fR consists of an array name with no parenthesized index, then the entire array is deleted. The \fBunset\fR command returns an empty string as result. An error occurs if any of the variables doesn't exist. .VE .TP \fBuplevel \fR?\fIlevel\fR?\fI command \fR?\fIcommand ...\fR? All of the \fIcommand\fR arguments are concatenated as if they had been passed to \fBconcat\fR; the result is then evaluated in the variable context indicated by \fIlevel\fR. \fBUplevel\fR returns the result of that evaluation. If \fIlevel\fR is an integer, then it gives a distance (up the procedure calling stack) to move before executing the command. If \fIlevel\fR consists of \fB#\fR followed by a number then the number gives an absolute level number. If \fIlevel\fR is omitted then it defaults to \fB1\fR. \fILevel\fR cannot be defaulted if the first \fIcommand\fR argument starts with a digit or \fB#\fR. For example, suppose that procedure \fBa\fR was invoked from top-level, and that it called \fBb\fR, and that \fBb\fR called \fBc\fR. Suppose that \fBc\fR invokes the \fBuplevel\fR command. If \fIlevel\fR is \fB1\fR or \fB#2\fR or omitted, then the command will be executed in the variable context of \fBb\fR. If \fIlevel\fR is \fB2\fR or \fB#1\fR then the command will be executed in the variable context of \fBa\fR. If \fIlevel\fR is \fB3\fR or \fB#0\fR then the command will be executed at top-level (only global variables will be visible). The \fBuplevel\fR command causes the invoking procedure to disappear from the procedure calling stack while the command is being executed. In the above example, suppose \fBc\fR invokes the command .RS .DS \fBuplevel 1 {set x 43; d} .DE where \fBd\fR is another Tcl procedure. The \fBset\fR command will modify the variable \fBx\fR in \fBb\fR's context, and \fBd\fR will execute at level 3, as if called from \fBb\fR. If it in turn executes the command .DS \fBuplevel {set x 42} .DE then the \fBset\fR command will modify the same variable \fBx\fR in \fBb\fR's context: the procedure \fBc\fR does not appear to be on the call stack when \fBd\fR is executing. The command ``\fBinfo level\fR'' may be used to obtain the level of the current procedure. \fBUplevel\fR makes it possible to implement new control constructs as Tcl procedures (for example, \fBuplevel\fR could be used to implement the \fBwhile\fR construct as a Tcl procedure). .RE .TP \fBupvar \fR?\fIlevel\fR? \fIotherVar myVar \fR?\fIotherVar myVar \fR...? .VS This command arranges for one or more local variables in the current procedure to refer to variables in an enclosing procedure call or to global variables. \fILevel\fR may have any of the forms permitted for the \fBuplevel\fR command, and may be omitted if the first letter of the first \fIotherVar\fR isn't \fB#\fR or a digit (it defaults to \fB1\fR). For each \fIotherVar\fR argument, \fBupvar\fR makes the variable by that name in the procedure frame given by \fIlevel\fR (or at global level, if \fIlevel\fR is \fB#0\fR) accessible in the current procedure by the name given in the corresponding \fImyVar\fR argument. The variable named by \fIotherVar\fR need not exist at the time of the call; it will be created the first time \fImyVar\fR is referenced, just like an ordinary variable. \fBUpvar\fR may only be invoked from within procedures. Neither \fIotherVar\fR or \fImyVar\fR may refer to an element of an array. \fBUpvar\fR returns an empty string. .RS .LP The \fBupvar\fR command simplifies the implementation of call-by-name procedure calling and also makes it easier to build new control constructs as Tcl procedures. For example, consider the following procedure: .DS .ta 1c 2c 3c \fBproc add2 name { upvar $name x set x [expr $x+2] } .DE \fBAdd2\fR is invoked with an argument giving the name of a variable, and it adds two to the value of that variable. Although \fBadd2\fR could have been implemented using \fBuplevel\fR instead of \fBupvar\fR, \fBupvar\fR makes it simpler for \fBadd2\fR to access the variable in the caller's procedure frame. .VE .RE .TP \fBwhile \fItest body .VS The \fIwhile\fR command evaluates \fItest\fR as an expression (in the same way that \fBexpr\fR evaluates its argument). The value of the expression must be numeric; if it is non-zero then \fIbody\fR is executed by passing it to the Tcl interpreter. Once \fIbody\fR has been executed then \fItest\fR is evaluated again, and the process repeats until eventually \fItest\fR evaluates to a zero numeric value. \fBContinue\fR commands may be executed inside \fIbody\fR to terminate the current iteration of the loop, and \fBbreak\fR commands may be executed inside \fIbody\fR to cause immediate termination of the \fBwhile\fR command. The \fBwhile\fR command always returns an empty string. .VE .SH "BUILT-IN VARIABLES" .PP The following global variables are created and managed automatically by the Tcl library. Except where noted below, these variables should normally be treated as read-only by application-specific code and by users. .TP \fBenv\fR .br .VS This variable is maintained by Tcl as an array whose elements are the environment variables for the process. Reading an element will return the value of the corresponding environment variable. Setting an element of the array will modify the corresponding environment variable or create a new one if it doesn't already exist. Unsetting an element of \fBenv\fR will remove the corresponding environment variable. Changes to the \fBenv\fR array will affect the environment passed to children by commands like \fBexec\fR. If the entire \fBenv\fR array is unset then Tcl will stop monitoring \fBenv\fR accesses and will not update environment variables. .TP \fBerrorCode\fR After an error has occurred, this variable will be set to hold additional information about the error in a form that is easy to process with programs. \fBerrorCode\fR consists of a Tcl list with one or more elements. The first element of the list identifies a general class of errors, and determines the format of the rest of the list. The following formats for \fBerrorCode\fR are used by the Tcl core; individual applications may define additional formats. .RS .TP \fBCHILDKILLED\fI pid sigName msg\fR This format is used when a child process has been killed because of a signal. The second element of \fBerrorCode\fR will be the process's identifier (in decimal). The third element will be the symbolic name of the signal that caused the process to terminate; it will be one of the names from the include file signal.h, such as \fBSIGPIPE\fR. The fourth element will be a short human-readable message describing the signal, such as ``write on pipe with no readers'' for \fBSIGPIPE\fR. .TP \fBCHILDSTATUS\fI pid code\fR This format is used when a child process has exited with a non-zero exit status. The second element of \fBerrorCode\fR will be the process's identifier (in decimal) and the third element will be the exit code returned by the process (also in decimal). .TP \fBCHILDSUSP\fI pid sigName msg\fR This format is used when a child process has been suspended because of a signal. The second element of \fBerrorCode\fR will be the process's identifier, in decimal. The third element will be the symbolic name of the signal that caused the process to suspend; this will be one of the names from the include file signal.h, such as \fBSIGTTIN\fR. The fourth element will be a short human-readable message describing the signal, such as ``background tty read'' for \fBSIGTTIN\fR. .TP \fBNONE\fR .br This format is used for errors where no additional information is available for an error besides the message returned with the error. In these cases \fBerrorCode\fR will consist of a list containing a single element whose contents are \fBNONE\fR. .TP \fBUNIX \fIerrName msg\fR If the first element of \fBerrorCode\fR is \fBUNIX\fR, then the error occurred during a UNIX kernel call. The second element of the list will contain the symbolic name of the error that occurred, such as \fBENOENT\fR; this will be one of the values defined in the include file errno.h. The third element of the list will be a human-readable message corresponding to \fIerrName\fR, such as ``no such file or directory'' for the \fBENOENT\fR case. .PP To set \fBerrorCode\fR, applications should use library procedures such as \fBTcl_SetErrorCode\fR and \fBTcl_UnixError\fR, or they may invoke the \fBerror\fR command. If one of these methods hasn't been used, then the Tcl interpreter will reset the variable to \fBNONE\fR after the next error. .RE .VE .TP \fBerrorInfo\fR After an error has occurred, this string will contain one or more lines identifying the Tcl commands and procedures that were being executed when the most recent error occurred. Its contents take the form of a stack trace showing the various nested Tcl commands that had been invoked at the time of the error. .SH AUTHOR John Ousterhout, University of California at Berkeley (ouster@sprite.berkeley.edu) .sp Many people have contributed to Tcl in various ways, but the following people have made unusually large contributions: .sp .nf Bill Carpenter Peter Da Silva Mark Diekhans Karl Lehenbauer Mary Ann May-Pumphrey ================================================ FILE: lib/libtcl/doc/TildeSubst.3 ================================================ '\" '\" Copyright 1989 Regents of the University of California '\" Permission to use, copy, modify, and distribute this '\" documentation for any purpose and without fee is hereby '\" granted, provided that this notice appears in all copies. '\" The University of California makes no representations about '\" the suitability of this material for any purpose. It is '\" provided "as is" without express or implied warranty. '\" '\" $Header: /cvsroot/PROCPLACE/pptinytcl/doc/TildeSubst.3,v 1.1.1.1 2001/04/20 15:03:06 karl Exp $ SPRITE (Berkeley) '\" .so man.macros .HS Tcl_TildeSubst tcl .BS .SH NAME Tcl_TildeSubst \- replace tilde with home directory in a file name .SH SYNOPSIS .nf \fB#include \fR .sp char * \fBTcl_TildeSubst\fR(\fIinterp\fR, \fIname\fR) .SH ARGUMENTS .AS Tcl_Interp *interp .AP Tcl_Interp *interp in Interpreter in which to report an error, if any. .AP char *name in File name, which may start with a ``~''. .BE .SH DESCRIPTION .PP This utility procedure does tilde substition. If \fIname\fR doesn't start with a ``~'' character, then the procedure returns \fIname\fR. If \fIname\fR does start with a tilde, then \fBTcl_TildeSubst\fR returns a new string identical to \fIname\fR except that the first element of \fIname\fR is replaced with the location of the home directory for the given user. The substitution is carried out in the same way that it would be done by \fIcsh\fR. If the tilde is followed immediately by a slash, then the \fB$HOME\fR environment variable is substituted. Otherwise the characters between the tilde and the next slash are taken as a user name, which is looked up in the password file; the user's home directory is retrieved from the password file and substituted. .PP The string returned by \fBTcl_TildeSubst\fR is a static string belonging to \fBTcl_TildeSubst\fR. Its value will only persist until the next call to \fBTcl_TildeSubst\fR; the caller should make a copy of the result if it needs to live a long time. .PP If an error occurs (e.g. because there was no user by the given name) then NULL is returned and an error message will be left at \fIinterp->result\fR. It is assumed that \fIinterp->result\fR has been initialized in the standard way when \fBTcl_TildeSubst\fR is invoked. .SH KEYWORDS file name, home directory, tilde, user ================================================ FILE: lib/libtcl/doc/TraceVar.3 ================================================ '\" '\" Copyright 1989 Regents of the University of California '\" Permission to use, copy, modify, and distribute this '\" documentation for any purpose and without fee is hereby '\" granted, provided that this notice appears in all copies. '\" The University of California makes no representations about '\" the suitability of this material for any purpose. It is '\" provided "as is" without express or implied warranty. '\" '\" $Header: /cvsroot/PROCPLACE/pptinytcl/doc/TraceVar.3,v 1.1.1.1 2001/04/20 15:03:06 karl Exp $ SPRITE (Berkeley) '\" .so man.macros .HS Tcl_TraceVar tcl .VS .BS .SH NAME Tcl_TraceVar, Tcl_TraceVar2, Tcl_UntraceVar, Tcl_UntraceVar2, Tcl_VarTraceInfo, Tcl_VarTraceInfo2 \- monitor accesses to a variable .SH SYNOPSIS .nf \fB#include \fR .sp int \fBTcl_TraceVar(\fIinterp, varName, flags, proc, clientData\fB)\fR .sp int \fBTcl_TraceVar2(\fIinterp, name1, name2, flags, proc, clientData\fB)\fR .sp \fBTcl_UnTraceVar(\fIinterp, varName, flags, proc, clientData\fB)\fR .sp \fBTcl_UnTraceVar2(\fIinterp, name1, name2, flags, proc, clientData\fB)\fR .sp ClientData \fBTcl_VarTraceInfo(\fIinterp, varName, flags, proc, prevClientData\fB)\fR .sp ClientData \fBTcl_VarTraceInfo2(\fIinterp, name1, name2, flags, proc, prevClientData\fB)\fR .SH ARGUMENTS .AS Tcl_VarTraceProc prevClientData .AP Tcl_Interp *interp in Interpreter containing variable. .AP char *varName in Name of variable. May refer to a scalar variable, to an array variable with no index, or to an array variable with a parenthesized index. .AP int flags in OR-ed combination of the values TCL_TRACE_READS, TCL_TRACE_WRITES, and TCL_TRACE_UNSETS, and TCL_GLOBAL_ONLY. Not all flags are used by all procedures. See below for more information. .AP Tcl_VarTraceProc *proc in Procedure to invoke whenever one of the traced operations occurs. .AP ClientData clientData in Arbitrary one-word value to pass to \fIproc\fR. .AP char *name1 in Name of scalar or array variable (without array index). .AP char *name2 in For a trace on an element of an array, gives the index of the element. For traces on scalar variables or on whole arrays, is NULL. .AP ClientData prevClientData in If non-NULL, gives last value returned by \fBTcl_VarTraceInfo\fR or \fBTcl_VarTraceInfo2\fR, so this call will return information about next trace. If NULL, this call will return information about first trace. .BE .SH DESCRIPTION .PP \fBTcl_TraceVar\fR allows a C procedure to monitor and control access to a Tcl variable, so that the C procedure is invoked whenever the variable is read or written or unset. If the trace is created successfully then \fBTcl_TraceVar\fR returns TCL_OK. If an error occurred (e.g. \fIvarName\fR specifies an element of an array, but the actual variable isn't an array) then TCL_ERROR is returned and an error message is left in \fIinterp->result\fR. .PP The \fIflags\fR argument to \fBTcl_TraceVar\fR indicates when the trace procedure is to be invoked and provides information for setting up the trace. It consists of an OR-ed combination of any of the following values: .TP \fBTCL_GLOBAL_ONLY\fR Normally, the variable will be looked up at the current level of procedure call; if this bit is set then the variable will be looked up at global level, ignoring any active procedures. .TP \fBTCL_TRACE_READS\fR Invoke \fIproc\fR whenever an attempt is made to read the variable. .TP \fBTCL_TRACE_WRITES\fR Invoke \fIproc\fR whenever an attempt is made to modify the variable. .TP \fBTCL_TRACE_UNSETS\fR Invoke \fIproc\fR whenever the variable is unset. A variable may be unset either explicitly by an \fBunset\fR command, or implicitly when a procedure returns (its local variables are automatically unset) or when the interpreter is deleted (all variables are automatically unset). .PP Whenever one of the specified operations occurs on the variable, \fIproc\fR will be invoked. It should have arguments and result that match the type \fBTcl_VarTraceProc\fR: .nf .RS typedef char *Tcl_VarTraceProc( .RS ClientData \fIclientData\fR, Tcl_Interp *\fIinterp\fR, char *\fIname1\fR, char *\fIname2\fR, int \fIflags\fR); .RE .RE .fi The \fIclientData\fP and \fIinterp\fP parameters will have the same values as those passed to \fBTcl_TraceVar\fR when the trace was created. \fIClientData\fR typically points to an application-specific data structure that describes what to do when \fIproc\fR is invoked. \fIName1\fR and \fIname2\fR give the name of the traced variable in the normal two-part form (see the description of \fBTcl_TraceVar2\fR below for details). \fIFlags\fR is an OR-ed combination of bits providing several pieces of information. One of the bits TCL_TRACE_READS, TCL_TRACE_WRITES, or TCL_TRACE_UNSETS will be set in \fIflags\fR to indicate which operation is being performed on the variable. The bit TCL_GLOBAL_ONLY will be set whenever the variable being accessed is a global one not accessible from the current level of procedure call: the trace procedure will need to pass this flag back to variable-related procedures like \fBTcl_GetVar\fR if it attempts to access the variable. The bit TCL_TRACE_DESTROYED will be set in \fIflags\fR if the trace is about to be destroyed; this information may be useful to \fIproc\fR so that it can clean up its own internal data structures (see the section TCL_TRACE_DESTROYED below for more details). Lastly, the bit TCL_INTERP_DESTROYED will be set if the entire interpreter is being destroyed. When this bit is set, \fIproc\fR must be especially careful in the things it does (see the section TCL_INTERP_DESTROYED below). The trace procedure's return value should normally be NULL; see ERROR RETURNS below for information on other possibilities. .PP \fBTcl_UntraceVar\fR may be used to remove a trace. If the variable specified by \fIinterp\fR, \fIvarName\fR, and \fIflags\fR has a trace set with \fIflags\fR, \fIproc\fR, and \fIclientData\fR, then the corresponding trace is removed. If no such trace exists, then the call to \fBTcl_UntraceVar\fR has no effect. The same bits are valid for \fIflags\fR as for calls to \fBTcl_TraceVars\fR. .PP \fBTcl_VarTraceInfo\fR may be used to retrieve information about traces set on a given variable. The return value from \fBTcl_VarTraceInfo\fR is the \fIclientData\fR associated with a particular trace. The trace must be on the variable specified by the \fIinterp\fR, \fIvarName\fR, and \fIflags\fR arguments (only the TCL_GLOBAL_ONLY bit from \fIflags\fR is used; other bits are ignored) and its trace procedure must the same as the \fIproc\fR argument. If the \fIprevClientData\fR argument is NULL then the return value corresponds to the first (most recently created) matching trace, or NULL if there are no matching traces. If the \fIprevClientData\fR argument isn't NULL, then it should be the return value from a previous call to \fBTcl_VarTraceInfo\fR. In this case, the new return value will correspond to the next matching trace after the one whose \fIclientData\fR matches \fIprevClientData\fR, or NULL if no trace matches \fIprevClientData\fR or if there are no more matching traces after it. This mechanism makes it possible to step through all of the traces for a given variable that have the same \fIproc\fR. .SH "TWO-PART NAMES" .PP The procedures \fBTcl_TraceVar2\fR, \fBTcl_UntraceVar2\fR, and \fBTcl_VarTraceInfo2\fR are identical to \fBTcl_TraceVar\fR, \fBTcl_UntraceVar\fR, and \fBTcl_VarTraceInfo\fR, respectively, except that the name of the variable has already been separated by the caller into two parts. \fIName1\fR gives the name of a scalar variable or array, and \fIname2\fR gives the name of an element within an array. If \fIname2\fR is NULL it means that either the variable is a scalar or the trace is to be set on the entire array rather than an individual element (see WHOLE-ARRAY TRACES below for more information). .SH "ACCESSING VARIABLES DURING TRACES" .PP During read and write traces, the trace procedure can read or write the value of the traced variable using \fBTcl_GetVar2\fR, \fBTcl_SetVar2\fR, and other procedures. While \fIproc\fR is executing, traces are temporarily disabled for the variable, so that calls to \fBTcl_GetVar2\fR and \fBTcl_SetVar2\fR will not cause \fIproc\fR or other trace procedures to be invoked again. Disabling only occurs for the variable whose trace procedure is active; accesses to other variables will still be traced. .PP During unset traces the variable has already been completely expunged. It is possible for the trace procedure to read or write the variable, but this will be a new version of the variable. Traces are not disabled during unset traces as they are for read and write traces, but existing traces have been removed from the variable before any trace procedures are invoked. If new traces are set by unset trace procedures, these traces will be invoked on accesses to the variable by the trace procedures. .SH "CALLBACK TIMING" .PP When read tracing has been specified for a variable, the trace procedure will be invoked whenever the variable's value is read. This includes \fBset\fR Tcl commands, \fB$\fR-notation in Tcl commands, and invocations of the \fBTcl_GetVar\fR and \fBTcl_GetVar2\fR procedures. \fIProc\fR is invoked just before the variable's value is returned. It may modify the value of the variable to affect what is returned by the traced access. .PP When write tracing has been specified for a variable, the trace procedure will be invoked whenever the variable's value is modified. This includes \fBset\fR commands\fR, commands that modify variables as side effects (such as \fBcatch\fR and \fBscan\fR), and calls to the \fBTcl_SetVar\fR and \fBTcl_SetVar2\fR procedures). \fIProc\fR will be invoked after the variable's value has been modified, but before the new value of the variable has been returned. It may modify the value of the variable to override the change and to determine the value actually returned by the traced access. .PP When unset tracing has been specified, the trace procedure will be invoked whenever the variable is destroyed. The traces will be called after the variable has been completely unset. .SH "WHOLE-ARRAY TRACES" .PP If a call to \fBTcl_TraceVar\fR or \fBTcl_TraceVar2\fR specifies the name of an array variable without an index into the array, then the trace will be set on the array as a whole. This means that \fIproc\fR will be invoked whenever any element of the array is accessed in the ways specified by \fIflags\fR. When an array is unset, a whole-array trace will be invoked just once, with \fIname1\fR equal to the name of the array and \fIname2\fR NULL; it will not be invoked once for each element. .SH "MULTIPLE TRACES" .PP It is possible for multiple traces to exist on the same variable. When this happens, all of the trace procedures will be invoked on each access, in order from most-recently-created to least-recently-created. When there exist whole-array traces for an array as well as traces on individual elements, the whole-array traces are invoked before the individual-element traces. .SH "ERROR RETURNS" .PP Under normal conditions trace procedures should return NULL, indicating successful completion. If \fIproc\fR returns a non-NULL value it signifies that an error occurred. The return value must be a pointer to a static character string containing an error message. If a trace procedure returns an error, no further traces are invoked for the access and the traced access aborts with the given message. Trace procedures can use this facility to make variables read-only, for example (but note that the value of the variable will already have been modified before the trace procedure is called, so the trace procedure will have to restore the correct value). .PP The return value from \fIproc\fR is only used during read and write tracing. During unset traces, the return value is ignored and all relevant trace procedures will always be invoked. .SH "RESTRICTIONS" .PP It is not legal to delete a variable while a trace procedure is active for the variable. .PP .VS Also, a trace procedure can be called at any time, even when there is a partically-formed result in the interpreter's result area. If the trace procedure does anything that could damage this result (such as calling \fBTcl_Eval\fR) then it must save the original values of the interpreter's \fBresult\fR and \fBfreeProc\fR fields and restore them before it returns. .VE .SH "UNDEFINED VARIABLES" .PP It is legal to set a trace on an undefined variable. The variable will still appear to be undefined until the first time its value is set. If an undefined variable is traced and then unset, the unset will fail with an error (``no such variable''), but the trace procedure will still be invoked. .SH "TCL_TRACE_DELETED FLAG" .PP In an unset callback to \fIproc\fR, the TCL_TRACE_DELETED bit is set in \fIflags\fR if the trace is being removed as part of the deletion. Traces on a variable are always removed whenever the variable is deleted; the only time TCL_TRACE_DELETED isn't set is for a whole-array trace invoked when only a single element of an array is unset. .SH "TCL_INTERP_DESTROYED" .PP When an interpreter is destroyed, unset traces are called for all of its variables. The TCL_INTERP_DESTROYED bit will be set in the \fIflags\fR argument passed to the trace procedures. Trace procedures must be extremely careful in what they do if the TCL_INTERP_DESTROYED bit is set. It is not safe for the procedures to invoke any Tcl procedures on the interpreter, since its state is partially deleted. All that trace procedures should do under these circumstances is to clean up and free their own internal data structures. .SH BUGS .PP Tcl doesn't do any error checking to prevent trace procedures from misusing the interpreter during traces with TCL_INTERP_DESTROYED set. .SH KEYWORDS clientData, trace, variable .VE ================================================ FILE: lib/libtcl/doc/library.n ================================================ '\" '\" Copyright 1991-1992 Regents of the University of California '\" Permission to use, copy, modify, and distribute this '\" documentation for any purpose and without fee is hereby '\" granted, provided that this notice appears in all copies. '\" The University of California makes no representations about '\" the suitability of this material for any purpose. It is '\" provided "as is" without express or implied warranty. '\" '\" $Header: /cvsroot/PROCPLACE/pptinytcl/doc/library.n,v 1.1.1.1 2001/04/20 15:03:06 karl Exp $ SPRITE (Berkeley) ' .so man.macros .de UL \\$1\l'|0\(ul'\\$2 .. .HS library tcl .BS .SH NAME library \- standard library of Tcl procedures .SH SYNOPSIS .nf \fBauto_execok \fIcmd\fR \fBauto_load \fIcmd\fR \fBauto_mkindex \fIdir pattern\fR \fBauto_reset\fR \fBparray \fIarrayName\fR \fBunknown \fIcmd \fR?\fIarg arg ...\fR? .fi .BE .SH INTRODUCTION .PP Tcl includes a library of Tcl procedures for commonly-needed functions. The procedures defined in the Tcl library are generic ones suitable for use by many different applications. The location of the Tcl library is returned by the \fBinfo library\fR command. In addition to the Tcl library, each application will normally have its own library of support procedures as well; the location of this .VS library is normally given by the value of the \fB$\fIapp\fB_library\fR global variable, where \fIapp\fR is the name of the application. For example, the location of the Tk library is kept in the variable \fB$tk_library\fR. .VE .PP To access the procedures in the Tcl library, an application should source the file \fBinit.tcl\fR in the library, for example with the Tcl command .DS \fBsource [info library]/init.tcl .DE This will define the \fBunknown\fR procedure and arrange for the other procedures to be loaded on-demand using the auto-load mechanism defined below. .SH "COMMAND PROCEDURES" .PP The following procedures are provided in the Tcl library: .TP \fBauto_execok \fIcmd\fR Determines whether there is an executable file by the name \fIcmd\fR. This command examines the directories in the current search path (given by the PATH enviornment variable) to see if there is an executable file named \fIcmd\fR in any of those directories. If so, it returns 1; if not it returns 0. \fBAuto_exec\fR remembers information about previous searches in an array named \fBauto_execs\fR; this avoids the path search in future calls for the same \fIcmd\fR. The command \fBauto_reset\fR may be used to force \fBauto_execok\fR to forget its cached information. .TP \fBauto_load \fIcmd\fR This command attempts to load the definition for a Tcl procedure named \fIcmd\fR. To do this, it searches an \fIauto-load path\fR, which is a list of one or more directories. The auto-load path is given by the global variable \fB$auto_path\fR if it exists. If there is no \fB$auto_path\fR variable, then the TCLLIBPATH environment variable is used, if it exists. Otherwise the auto-load path consists of just the Tcl library directory. Within each directory in the auto-load path there must be a file \fBtclIndex\fR that describes the procedures defined in that directory and the file in which each procedure is defined. The \fBtclIndex\fR file should be generated with the \fBauto_mkindex\fR command. If \fIcmd\fR is found in an index file, then the appropriate script is \fBsource\fRd to create the procedure. The \fBauto_load\fR command returns 1 if the script was successfully sourced and \fIcmd\fR now exists. The command returns 0 if there was no index entry for \fIcmd\fR or if the script didn't actually define \fIcmd\fR (e.g. because index information is out of date). If an error occurs while processing the script, then that error is returned. \fBAuto_load\fR only reads the index information once and saves it in the array \fBauto_index\fR; future calls to \fBauto_load\fR check for \fIcmd\fR in the array rather than re-reading the index files. The cached index information may be deleted with the command \fBauto_reset\fR. This will force the next \fBauto_load\fR command to reload the index database from disk. .TP \fBauto_mkindex \fIdir pattern\fR Generates an index suitable for use by \fBauto_load\fR. The command searches \fIdir\fR for all files whose names match \fIpattern\fR (matching is done with the \fBglob\fR command), generates an index of all the Tcl command procedures defined in all the matching files, and stores the index information in a file named \fBtclIndex\fR in \fIdir\fR. For example, the command .RS .DS \fBauto_mkindex foo *.tcl\fR .DE .LP will read all the \fB.tcl\fR files in subdirectory \fBfoo\fR and generate a new index file \fBfoo/tclIndex\fR. .PP \fBAuto_mkindex\fR parses the Tcl scripts in a relatively unsophisticated way: if any line contains the word \fBproc\fR as its first characters then it is assumed to be a procedure definition and the next word of the line is taken as the procedure's name. Procedure definitions that don't appear in this way (e.g. they have spaces before the \fBproc\fR) will not be indexed. .RE .TP \fBauto_reset\fR Destroys all the information cached by \fBauto_execok\fR and \fBauto_load\fR. This information will be re-read from disk the next time it is needed. .VS \fBAuto_reset\fR also deletes any procedures listed in the auto-load index, so that fresh copies of them will be loaded the next time that they're used. .VE .TP \fBparray \fIarrayName\fR Prints on standard output the names and values of all the elements in the array \fIarrayName\fR. .VS \fBArrayName\fR must be an array accessible to the caller of \fBparray\fR. It may be either local or global. .VE .TP \fBunknown \fIcmd \fR?\fIarg arg ...\fR? This procedure is invoked automatically by the Tcl interpreter whenever the name of a command doesn't exist. The \fBunknown\fR procedure receives as its arguments the name and arguments of the missing command. \fBUnknown\fR first calls \fBauto_load\fR to load a procedure for the command. If this succeeds, then it executes the original command with its original arguments. If the auto-load fails then \fBunknown\fR calls \fBauto_execok\fR to see if there is an executable file by the name \fIcmd\fR. If so, it invokes the Tcl \fBexec\fR command with \fIcmd\fR and all the \fIargs\fR as arguments. If \fIcmd\fR can't be auto-executed, \fBunknown\fR checks to see if the command was invoked at top-level and outside of any script. If so, then \fBunknown\fR takes takes two additional steps. First, it sees if \fIcmd\fR has one of the following three forms: \fB!!\fR, \fB!\fIevent\fR, or \fB^\fIold\fB^\fInew\fR?\fB^\fR?. If so, then \fBunknown\fR carries out history substitution in the same way that \fBcsh\fR would for these constructs. Second, and last, \fBunknown\fR checks to see if \fIcmd\fR is a unique abbreviation for an existing Tcl command. If so, it expands the command name and executes the command with the original arguments. If none of the above efforts has been able to execute the command, \fBunknown\fR generates an error return. If the global variable \fBauto_noload\fR is defined, then the auto-load step is skipped. If the global variable \fBauto_noexec\fR is defined then the auto-exec step is skipped. Under normal circumstances the return value from \fBunknown\fR is the return value from the command that was eventually executed. .SH "VARIABLES" .PP The following global variables are defined or used by the procedures in the Tcl library: .TP \fBauto_execs\fR Used by \fBauto_execok\fR to record information about whether particular commands exist as executable files. .TP \fBauto_index\fR Used by \fBauto_load\fR to save the index information read from disk. .TP \fBauto_noexec\fR If set to any value, then \fBunknown\fR will not attempt to auto-exec any commands. .TP \fBauto_noload\fR If set to any value, then \fBunknown\fR will not attempt to auto-load any commands. .TP \fBauto_path\fR If set, then it must contain a valid Tcl list giving directories to search during auto-load operations. .TP \fBenv(TCL_LIBRARY)\fR .VS If set, then it specifies the location of the directory containing library scripts (the value of this variable will be returned by the command \fBinfo library\fR). If this variable isn't set then a default value is used. .VE .TP \fBenv(TCLLIBPATH)\fR If set, then it must contain a valid Tcl list giving directories to search during auto-load operations. This variable is only used if \fBauto_path\fR is not defined. .TP \fBunknown_active\fR This variable is set by \fBunknown\fR to indicate that it is active. It is used to detect errors where \fBunknown\fR recurses on itself infinitely. The variable is unset before \fBunknown\fR returns. .SH KEYWORDS auto-exec, auto-load, library, unknown ================================================ FILE: lib/libtcl/doc/man.macros ================================================ .\" The definitions below are for supplemental macros used in Tcl/Tk .\" manual entries. .\" .\" .HS name section [date [version]] .\" Replacement for .TH in other man pages. See below for valid .\" section names. .\" .\" .AP type name in/out [indent] .\" Start paragraph describing an argument to a library procedure. .\" type is type of argument (int, etc.), in/out is either "in", "out", .\" or "in/out" to describe whether procedure reads or modifies arg, .\" and indent is equivalent to second arg of .IP (shouldn't ever be .\" needed; use .AS below instead) .\" .\" .AS [type [name]] .\" Give maximum sizes of arguments for setting tab stops. Type and .\" name are examples of largest possible arguments that will be passed .\" to .AP later. If args are omitted, default tab stops are used. .\" .\" .BS .\" Start box enclosure. From here until next .BE, everything will be .\" enclosed in one large box. .\" .\" .BE .\" End of box enclosure. .\" .\" .VS .\" Begin vertical sidebar, for use in marking newly-changed parts .\" of man pages. .\" .\" .VE .\" End of vertical sidebar. .\" .\" .DS .\" Begin an indented unfilled display. .\" .\" .DE .\" End of indented unfilled display. .\" '\" # Heading for Tcl/Tk man pages .de HS .if '\\$2'cmds' .TH \\$1 1 \\$3 \\$4 .if '\\$2'lib' .TH \\$1 3 \\$3 \\$4 .if '\\$2'tcl' .TH \\$1 3 \\$3 \\$4 .if '\\$2'tk' .TH \\$1 3 \\$3 \\$4 .if t .wh -1.3i ^B .nr ^l \\n(.l .ad b .. '\" # Start an argument description .de AP .ie !"\\$4"" .TP \\$4 .el \{\ . ie !"\\$2"" .TP \\n()Cu . el .TP 15 .\} .ie !"\\$3"" \{\ .ta \\n()Au \\n()Bu \&\\$1 \\fI\\$2\\fP (\\$3) .\".b .\} .el \{\ .br .ie !"\\$2"" \{\ \&\\$1 \\fI\\$2\\fP .\} .el \{\ \&\\fI\\$1\\fP .\} .\} .. '\" # define tabbing values for .AP .de AS .nr )A 10n .if !"\\$1"" .nr )A \\w'\\$1'u+3n .nr )B \\n()Au+15n .\" .if !"\\$2"" .nr )B \\w'\\$2'u+\\n()Au+3n .nr )C \\n()Bu+\\w'(in/out)'u+2n .. '\" # BS - start boxed text '\" # ^y = starting y location '\" # ^b = 1 .de BS .br .mk ^y .nr ^b 1u .if n .nf .if n .ti 0 .if n \l'\\n(.lu\(ul' .if n .fi .. '\" # BE - end boxed text (draw box now) .de BE .nf .ti 0 .mk ^t .ie n \l'\\n(^lu\(ul' .el \{\ .\" Draw four-sided box normally, but don't draw top of .\" box if the box started on an earlier page. .ie !\\n(^b-1 \{\ \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul' .\} .el \}\ \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul' .\} .\} .fi .br .nr ^b 0 .. '\" # VS - start vertical sidebar '\" # ^Y = starting y location '\" # ^v = 1 (for troff; for nroff this doesn't matter) .de VS .mk ^Y .ie n 'mc \s12\(br\s0 .el .nr ^v 1u .. '\" # VE - end of vertical sidebar .de VE .ie n 'mc .el \{\ .ev 2 .nf .ti 0 .mk ^t \h'|\\n(^lu+3n'\L'|\\n(^Yu-1v\(bv'\v'\\n(^tu+1v-\\n(^Yu'\h'-|\\n(^lu+3n' .sp -1 .fi .ev .\} .nr ^v 0 .. '\" # Special macro to handle page bottom: finish off current '\" # box/sidebar if in box/sidebar mode, then invoked standard '\" # page bottom macro. .de ^B .ev 2 'ti 0 'nf .mk ^t .if \\n(^b \{\ .\" Draw three-sided box if this is the box's first page, .\" draw two sides but no top otherwise. .ie !\\n(^b-1 \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c .el \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c .\} .if \\n(^v \{\ .nr ^x \\n(^tu+1v-\\n(^Yu \kx\h'-\\nxu'\h'|\\n(^lu+3n'\ky\L'-\\n(^xu'\v'\\n(^xu'\h'|0u'\c .\} .bp 'fi .ev .if \\n(^b \{\ .mk ^y .nr ^b 2 .\} .if \\n(^v \{\ .mk ^Y .\} .. '\" # DS - begin display .de DS .RS .nf .sp .. '\" # DE - end display .de DE .fi .RE .sp .5 .. ================================================ FILE: lib/libtcl/hash.h ================================================ /* * tclHash.h -- * * This header file declares the facilities provided by the * Tcl hash table procedures. * * Copyright 1991 Regents of the University of California * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without * fee is hereby granted, provided that the above copyright * notice appear in all copies. The University of California * makes no representations about the suitability of this * software for any purpose. It is provided "as is" without * express or implied warranty. */ /* * Structure definition for an entry in a hash table. No-one outside * Tcl should access any of these fields directly; use the macros * defined below. */ typedef struct Tcl_HashEntry { struct Tcl_HashEntry *nextPtr; /* Pointer to next entry in this * hash bucket, or NULL for end of * chain. */ struct Tcl_HashTable *tablePtr; /* Pointer to table containing entry. */ struct Tcl_HashEntry **bucketPtr; /* Pointer to bucket that points to * first entry in this entry's chain: * used for deleting the entry. */ void *clientData; /* Application stores something here * with Tcl_SetHashValue. */ union { /* Key has one of these forms: */ unsigned char *oneWordValue; /* One-word value for key. */ int words[1]; /* Multiple integer words for key. * The actual size will be as large * as necessary for this table's * keys. */ unsigned char string[4]; /* String for key. The actual size * will be as large as needed to hold * the key. */ } key; /* MUST BE LAST FIELD IN RECORD!! */ } Tcl_HashEntry; /* * Structure definition for a hash table. Must be in tcl.h so clients * can allocate space for these structures, but clients should never * access any fields in this structure. */ #define TCL_SMALL_HASH_TABLE 4 typedef struct Tcl_HashTable { Tcl_HashEntry **buckets; /* Pointer to bucket array. Each * element points to first entry in * bucket's hash chain, or NULL. */ Tcl_HashEntry *staticBuckets[TCL_SMALL_HASH_TABLE]; /* Bucket array used for small tables * (to avoid mallocs and frees). */ int numBuckets; /* Total number of buckets allocated * at **bucketPtr. */ int numEntries; /* Total number of entries present * in table. */ int rebuildSize; /* Enlarge table when numEntries gets * to be this large. */ int downShift; /* Shift count used in hashing * function. Designed to use high- * order bits of randomized keys. */ int mask; /* Mask value used in hashing * function. */ int keyType; /* Type of keys used in this table. * It's either TCL_STRING_KEYS, * TCL_ONE_WORD_KEYS, or an integer * giving the number of ints in a */ Tcl_HashEntry *(*findProc) (struct Tcl_HashTable *tablePtr, unsigned char *key); Tcl_HashEntry *(*createProc) (struct Tcl_HashTable *tablePtr, unsigned char *key, int *newPtr); } Tcl_HashTable; /* * Structure definition for information used to keep track of searches * through hash tables: */ typedef struct Tcl_HashSearch { Tcl_HashTable *tablePtr; /* Table being searched. */ int nextIndex; /* Index of next bucket to be * enumerated after present one. */ Tcl_HashEntry *nextEntryPtr; /* Next entry to be enumerated in the * the current bucket. */ } Tcl_HashSearch; /* * Acceptable key types for hash tables: */ #define TCL_STRING_KEYS 0 #define TCL_ONE_WORD_KEYS 1 /* * Macros for clients to use to access fields of hash entries: */ #define Tcl_GetHashValue(h) ((h)->clientData) #define Tcl_SetHashValue(h, value) ((h)->clientData = (void*) (value)) #define Tcl_GetHashKey(tablePtr, h) \ (((tablePtr)->keyType == TCL_ONE_WORD_KEYS) ? (h)->key.oneWordValue \ : (h)->key.string) /* * Macros to use for clients to use to invoke find and create procedures * for hash tables: */ #define Tcl_FindHashEntry(tablePtr, key) \ (*((tablePtr)->findProc))(tablePtr, key) #define Tcl_CreateHashEntry(tablePtr, key, newPtr) \ (*((tablePtr)->createProc))(tablePtr, key, newPtr) /* * Exported procedures: */ extern void Tcl_DeleteHashEntry (Tcl_HashEntry *entryPtr); extern void Tcl_DeleteHashTable (Tcl_HashTable *tablePtr); extern Tcl_HashEntry * Tcl_FirstHashEntry (Tcl_HashTable *tablePtr, Tcl_HashSearch *searchPtr); extern unsigned char * Tcl_HashStats (Tcl_HashTable *tablePtr); extern void Tcl_InitHashTable (Tcl_HashTable *tablePtr, int keyType); extern Tcl_HashEntry * Tcl_NextHashEntry (Tcl_HashSearch *searchPtr); ================================================ FILE: lib/libtcl/internal.h ================================================ /* * tclInt.h -- * * Declarations of things used internally by the Tcl interpreter. * * Copyright 1987-1991 Regents of the University of California * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without * fee is hereby granted, provided that the above copyright * notice appear in all copies. The University of California * makes no representations about the suitability of this * software for any purpose. It is provided "as is" without * express or implied warranty. */ /* * Common include files needed by most of the Tcl source files are * included here, so that system-dependent personalizations for the * include files only have to be made in once place. */ #ifdef CROSS # include # include #else # include # include #endif #include #include #include #include "hash.h" /* *---------------------------------------------------------------- * Data structures related to variables. These are used primarily * in tclVar.c *---------------------------------------------------------------- */ /* * The following structure defines a variable trace, which is used to * invoke a specific C procedure whenever certain operations are performed * on a variable. */ typedef struct VarTrace { Tcl_VarTraceProc *traceProc;/* Procedure to call when operations given * by flags are performed on variable. */ void *clientData; /* Argument to pass to proc. */ unsigned char flags; /* What events the trace procedure is * interested in: OR-ed combination of * TCL_TRACE_READS, TCL_TRACE_WRITES, and * TCL_TRACE_UNSETS. */ struct VarTrace *nextPtr; /* Next in list of traces associated with * a particular variable. */ } VarTrace; /* * When a variable trace is active (i.e. its associated procedure is * executing), one of the following structures is linked into a list * associated with the variable's interpreter. The information in * the structure is needed in order for Tcl to behave reasonably * if traces are deleted while traces are active. */ typedef struct ActiveVarTrace { struct ActiveVarTrace *nextPtr; /* Next in list of all active variable * traces for the interpreter, or NULL * if no more. */ VarTrace *nextTracePtr; /* Next trace to check after current * trace procedure returns; if this * trace gets deleted, must update pointer * to avoid using free'd memory. */ } ActiveVarTrace; /* * The following structure describes an enumerative search in progress on * an array variable; this are invoked with options to the "array" * command. */ typedef struct ArraySearch { unsigned short id; /* Integer id used to distinguish among * multiple concurrent searches for the * same array. */ struct Var *varPtr; /* Pointer to array variable that's being * searched. */ Tcl_HashSearch search; /* Info kept by the hash module about * progress through the array. */ Tcl_HashEntry *nextEntry; /* Non-null means this is the next element * to be enumerated (it's leftover from * the Tcl_FirstHashEntry call or from * an "array anymore" command). NULL * means must call Tcl_NextHashEntry * to get value to return. */ struct ArraySearch *nextPtr;/* Next in list of all active searches * for this variable, or NULL if this is * the last one. */ } ArraySearch; /* * The structure below defines a variable, which associates a string name * with a string value. Pointers to these structures are kept as the * values of hash table entries, and the name of each variable is stored * in the hash entry. */ typedef struct Var { unsigned short valueLength; /* Holds the number of non-null bytes * actually occupied by the variable's * current value in value.string (extra * space is sometimes left for expansion). * For array and global variables this is * meaningless. */ unsigned short valueSpace; /* Total number of bytes of space allocated * at value. */ unsigned short upvarUses; /* Counts number of times variable is * is referenced via global or upvar variables * (i.e. how many variables have "upvarPtr" * pointing to this variable). Variable * can't be deleted until this count reaches * 0. */ VarTrace *tracePtr; /* First in list of all traces set for this * variable. */ ArraySearch *searchPtr; /* First in list of all searches active * for this variable, or NULL if none. */ unsigned char flags; /* Miscellaneous bits of information about * variable. See below for definitions. */ union { unsigned char string[4]; /* String value of variable. The actual * length of this field is given by the * valueSpace field above. */ Tcl_HashTable *tablePtr;/* For array variables, this points to * information about the hash table used * to implement the associative array. * Points to malloc-ed data. */ Tcl_HashEntry *upvarPtr; /* If this is a global variable being * referred to in a procedure, or a variable * created by "upvar", this field points to * the hash table entry for the higher-level * variable. */ } value; /* MUST BE LAST FIELD IN STRUCTURE!!! */ } Var; /* * Flag bits for variables: * * VAR_ARRAY - 1 means this is an array variable rather * than a scalar variable. * VAR_UPVAR - 1 means this variable just contains a * pointer to another variable that has the * real value. Variables like this come * about through the "upvar" and "global" * commands. * VAR_UNDEFINED - 1 means that the variable is currently * undefined. Undefined variables usually * go away completely, but if an undefined * variable has a trace on it, or if it is * a global variable being used by a procedure, * then it stays around even when undefined. * VAR_ELEMENT_ACTIVE - Used only in array variables; 1 means that * an element of the array is currently being * manipulated in some way, so that it isn't * safe to delete the whole array. * VAR_TRACE_ACTIVE - 1 means that trace processing is currently * underway for a read or write access, so * new read or write accesses should not cause * trace procedures to be called and the * variable can't be deleted. */ #define VAR_ARRAY 1 #define VAR_UPVAR 2 #define VAR_UNDEFINED 4 #define VAR_ELEMENT_ACTIVE 0x10 #define VAR_TRACE_ACTIVE 0x20 #define VAR_SEARCHES_POSSIBLE 0x40 /* *---------------------------------------------------------------- * Data structures related to procedures. These are used primarily * in tclProc.c *---------------------------------------------------------------- */ /* * The structure below defines an argument to a procedure, which * consists of a name and an (optional) default value. */ typedef struct Arg { struct Arg *nextPtr; /* Next argument for this procedure, * or NULL if this is the last argument. */ unsigned char *defValue; /* Pointer to arg's default value, or NULL * if no default value. */ unsigned char name[4]; /* Name of argument starts here. The name * is followed by space for the default, * if there is one. The actual size of this * field will be as large as necessary to * hold both name and default value. THIS * MUST BE THE LAST FIELD IN THE STRUCTURE!! */ } Arg; /* * The structure below defines a command procedure, which consists of * a collection of Tcl commands plus information about arguments and * variables. */ typedef struct Proc { struct Interp *iPtr; /* Interpreter for which this command * is defined. */ unsigned char *command; /* Command that constitutes the body of * the procedure (dynamically allocated). */ Arg *argPtr; /* Pointer to first of procedure's formal * arguments, or NULL if none. */ } Proc; /* * The structure below defines a command trace. This is used to allow Tcl * clients to find out whenever a command is about to be executed. */ typedef struct Trace { unsigned short level; /* Only trace commands at nesting level * less than or equal to this. */ Tcl_CmdTraceProc *proc; /* Procedure to call to trace command. */ void *clientData; /* Arbitrary value to pass to proc. */ struct Trace *nextPtr; /* Next in list of traces for this interp. */ } Trace; /* * The structure below defines a frame, which is a procedure invocation. * These structures exist only while procedures are being executed, and * provide a sort of call stack. */ typedef struct CallFrame { Tcl_HashTable varTable; /* Hash table containing all of procedure's * local variables. */ unsigned short level; /* Level of this procedure, for "uplevel" * purposes (i.e. corresponds to nesting of * callerVarPtr's, not callerPtr's). 1 means * outer-most procedure, 0 means top-level. */ int argc; /* This and argv below describe name and * arguments for this procedure invocation. */ unsigned char **argv; /* Array of arguments. */ struct CallFrame *callerPtr; /* Value of interp->framePtr when this * procedure was invoked (i.e. next in * stack of all active procedures). */ struct CallFrame *callerVarPtr; /* Value of interp->varFramePtr when this * procedure was invoked (i.e. determines * variable scoping within caller; same * as callerPtr unless an "uplevel" command * or something equivalent was active in * the caller). */ } CallFrame; /* * The structure below defines one history event (a previously-executed * command that can be re-executed in whole or in part). */ typedef struct { unsigned char *command; /* String containing previously-executed * command. */ unsigned short bytesAvl; /* Total # of bytes available at *event (not * all are necessarily in use now). */ } HistoryEvent; /* *---------------------------------------------------------------- * Data structures related to history. These are used primarily * in tclHistory.c *---------------------------------------------------------------- */ /* * The structure below defines a pending revision to the most recent * history event. Changes are linked together into a list and applied * during the next call to Tcl_RecordHistory. See the comments at the * beginning of tclHistory.c for information on revisions. */ typedef struct HistoryRev { unsigned short firstIndex; /* Index of the first byte to replace in * current history event. */ unsigned short lastIndex; /* Index of last byte to replace in * current history event. */ unsigned short newSize; /* Number of bytes in newBytes. */ unsigned char *newBytes; /* Replacement for the range given by * firstIndex and lastIndex. */ struct HistoryRev *nextPtr; /* Next in chain of revisions to apply, or * NULL for end of list. */ } HistoryRev; /* *---------------------------------------------------------------- * Data structures related to files. These are used primarily in * tclUnixUtil.c and tclUnixAZ.c. *---------------------------------------------------------------- */ /* * The data structure below defines an open file (or connection to * a process pipeline) as returned by the "open" command. */ typedef struct OpenFile { FILE *f; /* Stdio file to use for reading and/or * writing. */ FILE *f2; /* Normally NULL. In the special case of * a command pipeline with pipes for both * input and output, this is a stdio file * to use for writing to the pipeline. */ int readable; /* Non-zero means file may be read. */ int writable; /* Non-zero means file may be written. */ int numPids; /* If this is a connection to a process * pipeline, gives number of processes * in pidPtr array below; otherwise it * is 0. */ int *pidPtr; /* Pointer to malloc-ed array of child * process ids (numPids of them), or NULL * if this isn't a connection to a process * pipeline. */ int errorId; /* File id of file that receives error * output from pipeline. -1 means not * used (i.e. this is a normal file). */ } OpenFile; /* *---------------------------------------------------------------- * This structure defines an interpreter, which is a collection of * commands plus other state information related to interpreting * commands, such as variable storage. Primary responsibility for * this data structure is in tclBasic.c, but almost every Tcl * source file uses something in here. *---------------------------------------------------------------- */ typedef struct Command { Tcl_CmdProc *proc; /* Procedure to process command. */ void *clientData; /* Arbitrary value to pass to proc. */ Tcl_CmdDeleteProc *deleteProc; /* Procedure to invoke when deleting * command. */ } Command; #define CMD_SIZE(nameLength) ((unsigned) sizeof(Command) + nameLength - 3) typedef struct Interp { /* * Note: the first four fields must match exactly the fields in * a Tcl_Interp struct (see tcl.h). If you change one, be sure to * change the other. */ unsigned char *result; /* Points to result returned by last * command. */ Tcl_FreeProc *freeProc; /* Zero means result is statically allocated. * If non-zero, gives address of procedure * to invoke to free the result. Must be * freed by Tcl_Eval before executing next * command. */ int errorLine; /* When TCL_ERROR is returned, this gives * the line number within the command where * the error occurred (1 means first line). */ Tcl_HashTable commandTable; /* Contains all of the commands currently * registered in this interpreter. Indexed * by strings; values have type (Command *). */ /* * Information related to procedures and variables. See tclProc.c * and tclvar.c for usage. */ Tcl_HashTable globalTable; /* Contains all global variables for * interpreter. */ unsigned short numLevels; /* Keeps track of how many nested calls to * Tcl_Eval are in progress for this * interpreter. It's used to delay deletion * of the table until all Tcl_Eval invocations * are completed. */ CallFrame *framePtr; /* Points to top-most in stack of all nested * procedure invocations. NULL means there * are no active procedures. */ CallFrame *varFramePtr; /* Points to the call frame whose variables * are currently in use (same as framePtr * unless an "uplevel" command is being * executed). NULL means no procedure is * active or "uplevel 0" is being exec'ed. */ ActiveVarTrace *activeTracePtr; /* First in list of active traces for interp, * or NULL if no active traces. */ /* * Information related to history: */ unsigned short numEvents; /* Number of previously-executed commands * to retain. */ HistoryEvent *events; /* Array containing numEvents entries * (dynamically allocated). */ unsigned short curEvent; /* Index into events of place where current * (or most recent) command is recorded. */ unsigned short curEventNum; /* Event number associated with the slot * given by curEvent. */ HistoryRev *revPtr; /* First in list of pending revisions. */ unsigned char *historyFirst; /* First char. of current command executed * from history module or NULL if none. */ unsigned short revDisables; /* 0 means history revision OK; > 0 gives * a count of number of times revision has * been disabled. */ unsigned char *evalFirst; /* If TCL_RECORD_BOUNDS flag set, Tcl_Eval * sets this field to point to the first * char. of text from which the current * command came. Otherwise Tcl_Eval sets * this to NULL. */ unsigned char *evalLast; /* Similar to evalFirst, except points to * last character of current command. */ /* * Information used by Tcl_AppendResult to keep track of partial * results. See Tcl_AppendResult code for details. */ unsigned char *appendResult; /* Storage space for results generated * by Tcl_AppendResult. Malloc-ed. NULL * means not yet allocated. */ unsigned short appendAvl; /* Total amount of space available at * partialResult. */ unsigned short appendUsed; /* Number of non-null bytes currently * stored at partialResult. */ /* * Information related to files. See tclUnixAZ.c and tclUnixUtil.c * for details. */ unsigned short numFiles; /* Number of entries in filePtrArray * below. 0 means array hasn't been * created yet. */ OpenFile **filePtrArray; /* Pointer to malloc-ed array of pointers * to information about open files. Entry * N corresponds to the file with fileno N. * If an entry is NULL then the corresponding * file isn't open. If filePtrArray is NULL * it means no files have been used, so even * stdin/stdout/stderr entries haven't been * setup yet. */ /* * A cache of compiled regular expressions. See TclCompileRegexp * in tclUtil.c for details. */ #define NUM_REGEXPS 5 unsigned char *patterns [NUM_REGEXPS]; /* Strings corresponding to compiled * regular expression patterns. NULL * means that this slot isn't used. * Malloc-ed. */ unsigned short patLengths [NUM_REGEXPS]; /* Number of non-null characters in * corresponding entry in patterns. * -1 means entry isn't used. */ struct _regexp_t *regexps [NUM_REGEXPS]; /* Compiled forms of above strings. Also * malloc-ed, or NULL if not in use yet. */ /* * Miscellaneous information: */ unsigned long cmdCount; /* Total number of times a command procedure * has been called for this interpreter. */ unsigned char *scriptFile; /* NULL means there is no nested source * command active; otherwise this points to * the name of the file being sourced (it's * not malloc-ed: it points to an argument * to Tcl_EvalFile. */ unsigned char noEval; /* Non-zero means no commands should actually * be executed: just parse only. Used in * expressions when the result is already * determined. */ unsigned char flags; /* Various flag bits. See below. */ Trace *tracePtr; /* List of traces for this interpreter. */ unsigned char resultSpace [TCL_RESULT_SIZE+1]; /* Static space for storing small results. */ } Interp; /* * Flag bits for Interp structures: * * DELETED: Non-zero means the interpreter has been deleted: * don't process any more commands for it, and destroy * the structure as soon as all nested invocations of * Tcl_Eval are done. * ERR_IN_PROGRESS: Non-zero means an error unwind is already in progress. * Zero means a command proc has been invoked since last * error occured. * ERR_ALREADY_LOGGED: Non-zero means information has already been logged * in $errorInfo for the current Tcl_Eval instance, * so Tcl_Eval needn't log it (used to implement the * "error message log" command). * ERROR_CODE_SET: Non-zero means that Tcl_SetErrorCode has been * called to record information for the current * error. Zero means Tcl_Eval must clear the * errorCode variable if an error is returned. */ #define DELETED 1 #define ERR_IN_PROGRESS 2 #define ERR_ALREADY_LOGGED 4 #define ERROR_CODE_SET 8 /* *---------------------------------------------------------------- * Data structures related to command parsing. These are used in * tclParse.c and its clients. *---------------------------------------------------------------- */ /* * The following data structure is used by various parsing procedures * to hold information about where to store the results of parsing * (e.g. the substituted contents of a quoted argument, or the result * of a nested command). At any given time, the space available * for output is fixed, but a procedure may be called to expand the * space available if the current space runs out. */ typedef struct ParseValue { unsigned char *buffer; /* Address of first character in * output buffer. */ unsigned char *next; /* Place to store next character in * output buffer. */ unsigned char *end; /* Address of the last usable character * in the buffer. */ void (*expandProc) (struct ParseValue *pvPtr, unsigned short needed); /* Procedure to call when space runs out; * it will make more space. */ void *clientData; /* Arbitrary information for use of * expandProc. */ } ParseValue; /* * Possible values returned by CHAR_TYPE: * * TCL_NORMAL - All characters that don't have special significance * to the Tcl language. * TCL_SPACE - Character is space, tab, or return. * TCL_COMMAND_END - Character is newline or null or semicolon or * close-bracket. * TCL_QUOTE - Character is a double-quote. * TCL_OPEN_BRACKET - Character is a "[". * TCL_OPEN_BRACE - Character is a "{". * TCL_CLOSE_BRACE - Character is a "}". * TCL_BACKSLASH - Character is a "\". * TCL_DOLLAR - Character is a "$". */ #define TCL_NORMAL 0 #define TCL_SPACE 1 #define TCL_COMMAND_END 2 #define TCL_QUOTE 3 #define TCL_OPEN_BRACKET 4 #define TCL_OPEN_BRACE 5 #define TCL_CLOSE_BRACE 6 #define TCL_BACKSLASH 7 #define TCL_DOLLAR 8 /* * Additional flags passed to Tcl_Eval. See tcl.h for other flags to * Tcl_Eval; these ones are only used internally by Tcl. * * TCL_RECORD_BOUNDS Tells Tcl_Eval to record information in the * evalFirst and evalLast fields for each command * executed directly from the string (top-level * commands and those from command substitution). */ #define TCL_RECORD_BOUNDS 0x100 /* * Maximum number of levels of nesting permitted in Tcl commands. */ #define MAX_NESTING_DEPTH 100 /* *---------------------------------------------------------------- * Procedures shared among Tcl modules but not used by the outside * world: *---------------------------------------------------------------- */ extern struct _regexp_t *TclCompileRegexp (Tcl_Interp *interp, unsigned char *string); extern void TclCopyAndCollapse (int count, unsigned char *src, unsigned char *dst); extern void TclDeleteVars (Interp *iPtr, Tcl_HashTable *tablePtr); extern void TclExpandParseValue (ParseValue *pvPtr, unsigned short needed); extern int TclFindElement (Tcl_Interp *interp, unsigned char *list, unsigned char **elementPtr, unsigned char **nextPtr, int *sizePtr, int *bracePtr); extern Proc * TclFindProc (Interp *iPtr, unsigned char *procName); extern int TclGetFrame (Tcl_Interp *interp, unsigned char *string, CallFrame **framePtrPtr); extern int TclGetListIndex (Tcl_Interp *interp, unsigned char *string, int *indexPtr); extern int TclGetOpenFile (Tcl_Interp *interp, char *string, OpenFile **filePtrPtr); extern Proc * TclIsProc (Command *cmdPtr); extern void TclMakeFileTable (Interp *iPtr, int index); extern int TclParseBraces (Tcl_Interp *interp, unsigned char *string, unsigned char **termPtr, ParseValue *pvPtr); extern int TclParseNestedCmd (Tcl_Interp *interp, unsigned char *string, int flags, unsigned char **termPtr, ParseValue *pvPtr); extern int TclParseQuotes (Tcl_Interp *interp, unsigned char *string, int termChar, int flags, unsigned char **termPtr, ParseValue *pvPtr); extern int TclParseWords (Tcl_Interp *interp, unsigned char *string, int flags, int maxWords, unsigned char **termPtr, int *argcPtr, unsigned char **argv, ParseValue *pvPtr); extern void TclSetupEnv (Tcl_Interp *interp); extern unsigned char * TclWordEnd (unsigned char *start, int nested); extern unsigned char * Tcl_UnixError (Tcl_Interp *interp); /* *---------------------------------------------------------------- * Command procedures in the generic core: *---------------------------------------------------------------- */ extern int Tcl_AppendCmd (void *clientData, Tcl_Interp *interp, int argc, unsigned char **argv); extern int Tcl_ArrayCmd (void *clientData, Tcl_Interp *interp, int argc, unsigned char **argv); extern int Tcl_BreakCmd (void *clientData, Tcl_Interp *interp, int argc, unsigned char **argv); extern int Tcl_CaseCmd (void *clientData, Tcl_Interp *interp, int argc, unsigned char **argv); extern int Tcl_CatchCmd (void *clientData, Tcl_Interp *interp, int argc, unsigned char **argv); extern int Tcl_ConcatCmd (void *clientData, Tcl_Interp *interp, int argc, unsigned char **argv); extern int Tcl_ContinueCmd (void *clientData, Tcl_Interp *interp, int argc, unsigned char **argv); extern int Tcl_ErrorCmd (void *clientData, Tcl_Interp *interp, int argc, unsigned char **argv); extern int Tcl_EvalCmd (void *clientData, Tcl_Interp *interp, int argc, unsigned char **argv); extern int Tcl_ExprCmd (void *clientData, Tcl_Interp *interp, int argc, unsigned char **argv); extern int Tcl_ForCmd (void *clientData, Tcl_Interp *interp, int argc, unsigned char **argv); extern int Tcl_ForeachCmd (void *clientData, Tcl_Interp *interp, int argc, unsigned char **argv); extern int Tcl_FormatCmd (void *clientData, Tcl_Interp *interp, int argc, unsigned char **argv); extern int Tcl_GlobalCmd (void *clientData, Tcl_Interp *interp, int argc, unsigned char **argv); extern int Tcl_HistoryCmd (void *clientData, Tcl_Interp *interp, int argc, unsigned char **argv); extern int Tcl_IfCmd (void *clientData, Tcl_Interp *interp, int argc, unsigned char **argv); extern int Tcl_IncrCmd (void *clientData, Tcl_Interp *interp, int argc, unsigned char **argv); extern int Tcl_InfoCmd (void *clientData, Tcl_Interp *interp, int argc, unsigned char **argv); extern int Tcl_JoinCmd (void *clientData, Tcl_Interp *interp, int argc, unsigned char **argv); extern int Tcl_LappendCmd (void *clientData, Tcl_Interp *interp, int argc, unsigned char **argv); extern int Tcl_LindexCmd (void *clientData, Tcl_Interp *interp, int argc, unsigned char **argv); extern int Tcl_LinsertCmd (void *clientData, Tcl_Interp *interp, int argc, unsigned char **argv); extern int Tcl_LlengthCmd (void *clientData, Tcl_Interp *interp, int argc, unsigned char **argv); extern int Tcl_ListCmd (void *clientData, Tcl_Interp *interp, int argc, unsigned char **argv); extern int Tcl_LrangeCmd (void *clientData, Tcl_Interp *interp, int argc, unsigned char **argv); extern int Tcl_LreplaceCmd (void *clientData, Tcl_Interp *interp, int argc, unsigned char **argv); extern int Tcl_LsearchCmd (void *clientData, Tcl_Interp *interp, int argc, unsigned char **argv); extern int Tcl_LsortCmd (void *clientData, Tcl_Interp *interp, int argc, unsigned char **argv); extern int Tcl_ProcCmd (void *clientData, Tcl_Interp *interp, int argc, unsigned char **argv); extern int Tcl_RegexpCmd (void *clientData, Tcl_Interp *interp, int argc, unsigned char **argv); extern int Tcl_RegsubCmd (void *clientData, Tcl_Interp *interp, int argc, unsigned char **argv); extern int Tcl_RenameCmd (void *clientData, Tcl_Interp *interp, int argc, unsigned char **argv); extern int Tcl_ReturnCmd (void *clientData, Tcl_Interp *interp, int argc, unsigned char **argv); extern int Tcl_ScanCmd (void *clientData, Tcl_Interp *interp, int argc, unsigned char **argv); extern int Tcl_SetCmd (void *clientData, Tcl_Interp *interp, int argc, unsigned char **argv); extern int Tcl_SplitCmd (void *clientData, Tcl_Interp *interp, int argc, unsigned char **argv); extern int Tcl_StringCmd (void *clientData, Tcl_Interp *interp, int argc, unsigned char **argv); extern int Tcl_TraceCmd (void *clientData, Tcl_Interp *interp, int argc, unsigned char **argv); extern int Tcl_UnsetCmd (void *clientData, Tcl_Interp *interp, int argc, unsigned char **argv); extern int Tcl_UplevelCmd (void *clientData, Tcl_Interp *interp, int argc, unsigned char **argv); extern int Tcl_UpvarCmd (void *clientData, Tcl_Interp *interp, int argc, unsigned char **argv); extern int Tcl_WhileCmd (void *clientData, Tcl_Interp *interp, int argc, unsigned char **argv); extern int Tcl_Cmd (void *clientData, Tcl_Interp *interp, int argc, unsigned char **argv); extern int Tcl_Cmd (void *clientData, Tcl_Interp *interp, int argc, unsigned char **argv); /* *---------------------------------------------------------------- * Command procedures in the UNIX core: *---------------------------------------------------------------- */ extern int Tcl_CdCmd (void *clientData, Tcl_Interp *interp, int argc, unsigned char **argv); extern int Tcl_CloseCmd (void *clientData, Tcl_Interp *interp, int argc, unsigned char **argv); extern int Tcl_EofCmd (void *clientData, Tcl_Interp *interp, int argc, unsigned char **argv); extern int Tcl_ExecCmd (void *clientData, Tcl_Interp *interp, int argc, unsigned char **argv); extern int Tcl_ExitCmd (void *clientData, Tcl_Interp *interp, int argc, unsigned char **argv); extern int Tcl_FileCmd (void *clientData, Tcl_Interp *interp, int argc, unsigned char **argv); extern int Tcl_FlushCmd (void *clientData, Tcl_Interp *interp, int argc, unsigned char **argv); extern int Tcl_GetsCmd (void *clientData, Tcl_Interp *interp, int argc, unsigned char **argv); extern int Tcl_GlobCmd (void *clientData, Tcl_Interp *interp, int argc, unsigned char **argv); extern int Tcl_OpenCmd (void *clientData, Tcl_Interp *interp, int argc, unsigned char **argv); extern int Tcl_PutsCmd (void *clientData, Tcl_Interp *interp, int argc, unsigned char **argv); extern int Tcl_PwdCmd (void *clientData, Tcl_Interp *interp, int argc, unsigned char **argv); extern int Tcl_ReadCmd (void *clientData, Tcl_Interp *interp, int argc, unsigned char **argv); extern int Tcl_SeekCmd (void *clientData, Tcl_Interp *interp, int argc, unsigned char **argv); extern int Tcl_SourceCmd (void *clientData, Tcl_Interp *interp, int argc, unsigned char **argv); extern int Tcl_TellCmd (void *clientData, Tcl_Interp *interp, int argc, unsigned char **argv); extern int Tcl_TimeCmd (void *clientData, Tcl_Interp *interp, int argc, unsigned char **argv); ================================================ FILE: lib/libtcl/regexp.c ================================================ /* * regcomp and regexec -- regsub is elsewhere * * Copyright (c) 1986 by University of Toronto. * Written by Henry Spencer. Not derived from licensed software. * * Permission is granted to anyone to use this software for any * purpose on any computer system, and to redistribute it freely, * subject to the following restrictions: * * 1. The author is not responsible for the consequences of use of * this software, no matter how awful, even if they arise * from defects in it. * * 2. The origin of this software must not be misrepresented, either * by explicit claim or by omission. * * 3. Altered versions must be plainly marked as such, and must not * be misrepresented as being the original software. *** THIS IS AN ALTERED VERSION. It was altered by Serge Vakulenko, *** vak@cronyx.ru, on 10 Novc 2002, to make it thread-safe. *** THIS IS AN ALTERED VERSION. It was altered by John Gilmore, *** hoptoad!gnu, on 27 Dec 1986, to add \n as an alternative to | *** to assist in implementing egrep. *** THIS IS AN ALTERED VERSION. It was altered by John Gilmore, *** hoptoad!gnu, on 27 Dec 1986, to add \< and \> for word-matching *** as in BSD grep and ex. *** THIS IS AN ALTERED VERSION. It was altered by John Gilmore, *** hoptoad!gnu, on 28 Dec 1986, to optimize characters quoted with \. *** THIS IS AN ALTERED VERSION. It was altered by James A. Woods, *** ames!jaw, on 19 June 1987, to quash a regcomp() redundancy. * * Beware that some of this code is subtly aware of the way operator * precedence is structured in regular expressions. Serious changes in * regular-expression syntax might require a total rethink. */ #include #include #include "regexp.h" #include "regpriv.h" /* * Structure for regexp "program". This is essentially a linear encoding * of a nondeterministic finite-state machine (aka syntax charts or * "railroad normal form" in parsing technology). Each node is an opcode * plus a "next" pointer, possibly plus an operand. "Next" pointers of * all nodes except BRANCH implement concatenation; a "next" pointer with * a BRANCH on both ends of it is connecting two alternatives. (Here we * have one of the subtle syntax dependencies: an individual BRANCH (as * opposed to a collection of them) is never concatenated with anything * because of operator precedence.) The operand of some types of node is * a literal string; for others, it is a node leading into a sub-FSM. In * particular, the operand of a BRANCH node is the first node of the branch. * (NB this is *not* a tree structure: the tail of the branch connects * to the thing following the set of BRANCHes.) The opcodes are: */ /* definition number opnd? meaning */ #define END 0 /* no End of program. */ #define BOL 1 /* no Match "" at beginning of line. */ #define EOL 2 /* no Match "" at end of line. */ #define ANY 3 /* no Match any one character. */ #define ANYOF 4 /* str Match any character in this string. */ #define ANYBUT 5 /* str Match any character not in this string. */ #define BRANCH 6 /* node Match this alternative, or the next... */ #define BACK 7 /* no Match "", "next" ptr points backward. */ #define EXACTLY 8 /* str Match this string. */ #define NOTHING 9 /* no Match empty string. */ #define STAR 10 /* node Match this (simple) thing 0 or more times. */ #define PLUS 11 /* node Match this (simple) thing 1 or more times. */ #define WORDA 12 /* no Match "" at wordchar, where prev is nonword */ #define WORDZ 13 /* no Match "" at nonwordchar, where prev is word */ #define OPEN 20 /* no Mark this point in input as start of #n. */ /* OPEN+1 is number 1, etc. */ #define CLOSE 30 /* no Analogous to OPEN. */ /* * Opcode notes: * * BRANCH The set of branches constituting a single choice are hooked * together with their "next" pointers, since precedence prevents * anything being concatenated to any individual branch. The * "next" pointer of the last BRANCH in a choice points to the * thing following the whole choice. This is also where the * final "next" pointer of each individual branch points; each * branch starts with the operand node of a BRANCH node. * * BACK Normal "next" pointers all implicitly point forward; BACK * exists to make loop structures possible. * * STAR,PLUS '?', and complex '*' and '+', are implemented as circular * BRANCH structures using BACK. Simple cases (one character * per match) are implemented with STAR and PLUS for speed * and to minimize recursive plunges. * * OPEN,CLOSE ...are numbered at compile time. */ /* * A node is one char of opcode followed by two chars of "next" pointer. * "Next" pointers are stored as two 8-bit pieces, high order first. The * value is a positive offset from the opcode of the node containing it. * An operand, if any, simply follows the node. (Note that much of the * code generation knows about this implicit relationship.) * * Using two bytes for the "next" pointer is vast overkill for most things, * but allows patterns to get big without disasters. */ #define OP(p) (*(p)) #define NEXT(p) (((*((p)+1)&0377)<<8) + (*((p)+2)&0377)) #define OPERAND(p) ((p) + 3) /* * Utility definitions. */ #define ISMULT(c) ((c) == '*' || (c) == '+' || (c) == '?') #define ISALNUM(c) (((c)>='a' && (c)<='z') || \ ((c)>='A' && (c)<='Z') || \ ((c)>='0' && (c)<='9') || \ ((c)>=0300)) /* * Flags to be passed up and down. */ #define HASWIDTH 01 /* Known never to match null string. */ #define SIMPLE 02 /* Simple enough to be STAR/PLUS operand. */ #define SPSTART 04 /* Starts with * or +. */ #define WORST 0 /* Worst case. */ /* * Global work variables for regcomp(). */ typedef struct { unsigned const char *parse; /* Input-scan pointer. */ unsigned char npar; /* () count. */ unsigned char *code; /* Code-emit pointer; ®dummy = don't. */ unsigned short size; /* Code size. */ } compile_t; static unsigned char regdummy; /* * Forward declarations for regcomp()'s friends. */ static unsigned char *reg (compile_t *x, unsigned char paren, unsigned char *flagp); static unsigned char *regbranch (compile_t *x, unsigned char *flagp); static unsigned char *regpiece (compile_t *x, unsigned char *flagp); static unsigned char *regatom (compile_t *x, unsigned char *flagp); static unsigned char *regnode (compile_t *x, unsigned char op); static void regc (compile_t *x, unsigned char b); static void reginsert (compile_t *x, unsigned char op, unsigned char *opnd); static unsigned char *regnext (unsigned char *p); static void regtail (unsigned char *p, unsigned char *val); static void regoptail (unsigned char *p, unsigned char *val); /* * Global work variables for regexec(). */ typedef struct { const unsigned char *input; /* String-input pointer. */ const unsigned char *bol; /* Beginning of input, for ^ check. */ const unsigned char **startp; /* Pointer to startp array. */ const unsigned char **endp; /* Ditto for endp. */ } execute_t; /* * Forwards. */ static unsigned char regtry (regexp_t *prog, execute_t *z, const unsigned char *string); static unsigned char regmatch (execute_t *z, unsigned char *prog); static unsigned short regrepeat (execute_t *z, unsigned char *p); #ifdef DEBUG_REGEXP #include static unsigned char *regprop (unsigned char *op); #endif /* * Determine the required size. * On failure, returns 0. */ unsigned regexp_size (const unsigned char *exp) { compile_t x; unsigned char flags; if (! exp) { /* FAIL("NULL argument"); */ return 0; } x.parse = exp; x.npar = 1; x.size = 0L; x.code = ®dummy; regc (&x, MAGIC); if (! reg (&x, 0, &flags)) return 0; return sizeof (regexp_t) + x.size; } /* * Compile a regular expression into internal code. * Returns 1 on success, or 0 on failure. * * We can't allocate space until we know how big the compiled form will be, * but we can't compile it (and thus know how big it is) until we've got a * place to put the code. So we cheat: we compile it twice, once with code * generation turned off and size counting turned on, and once "for real". * This also means that we don't allocate space until we are sure that the * thing really will compile successfully, and we never have to move the * code and thus invalidate pointers into it. (Note that it has to be in * one piece because free() must be able to free it all.) * * Beware that the optimization-preparation code in here knows about some * of the structure of the compiled regexp. */ bool_t regexp_compile (regexp_t *r, const unsigned char *exp) { unsigned char *scan; unsigned char *longest; compile_t x; unsigned short len; unsigned char flags; if (! r || ! exp) { /* FAIL("NULL argument"); */ return 0; } /* Second pass: emit code. */ x.parse = exp; x.npar = 1; x.code = r->program; regc (&x, MAGIC); if (! reg (&x, 0, &flags)) return 0; /* Dig out information for optimizations. */ r->start = '\0'; /* Worst-case defaults. */ r->anchor = 0; r->must = 0; r->mustlen = 0; scan = r->program+1; /* First BRANCH. */ if (OP (regnext (scan)) == END) { /* Only one top-level choice. */ scan = OPERAND(scan); /* Starting-point info. */ if (OP(scan) == EXACTLY) r->start = *OPERAND(scan); else if (OP(scan) == BOL) r->anchor++; /* * If there's something expensive in the r.e., find the * longest literal string that must appear and make it the * `must'. Resolve ties in favor of later strings, since * the start check works with the beginning of the r.e. * and avoiding duplication strengthens checking. Not a * strong reason, but sufficient in the absence of others. */ if (flags & SPSTART) { longest = 0; len = 0; for (; scan; scan=regnext(scan)) if (OP(scan) == EXACTLY && strlen (OPERAND (scan)) >= len) { longest = OPERAND (scan); len = strlen(OPERAND (scan)); } r->must = longest; r->mustlen = len; } } return 1; } /* - reg - regular expression, i.e. main body or parenthesized thing * * Caller must absorb opening parenthesis. * * Combining parenthesis handling with the base level of regular expression * is a trifle forced, but the need to tie the tails of the branches to what * follows makes it hard to avoid. */ static unsigned char * reg (compile_t *x, unsigned char paren, unsigned char *flagp) { unsigned char *ret; unsigned char *br; unsigned char *ender; unsigned char parno = 0; unsigned char flags; *flagp = HASWIDTH; /* Tentatively. */ /* Make an OPEN node, if parenthesized. */ if (paren) { if (x->npar >= NSUBEXP) { /* FAIL("too many ()"); */ return 0; } parno = x->npar; x->npar++; ret = regnode (x, OPEN+parno); } else ret = 0; /* Pick up the branches, linking them together. */ br = regbranch (x, &flags); if (! br) return 0; if (ret) regtail (ret, br); /* OPEN -> first. */ else ret = br; if (!(flags&HASWIDTH)) *flagp &= ~HASWIDTH; *flagp |= flags & SPSTART; while (*x->parse == '|' || *x->parse == '\n') { x->parse++; br = regbranch (x, &flags); if (! br) return 0; regtail (ret, br); /* BRANCH -> BRANCH. */ if (!(flags & HASWIDTH)) *flagp &= ~HASWIDTH; *flagp |= flags & SPSTART; } /* Make a closing node, and hook it on the end. */ ender = regnode (x, paren ? CLOSE+parno : END); regtail (ret, ender); /* Hook the tails of the branches to the closing node. */ for (br=ret; br; br=regnext(br)) regoptail (br, ender); /* Check for proper termination. */ if (paren && *x->parse++ != ')') { /* FAIL("unmatched ()"); */ return 0; } if (! paren && *x->parse != '\0') { if (*x->parse == ')') { /* FAIL("unmatched ()"); */ return 0; } /* "Can't happen". */ /* FAIL("junk on end"); */ return 0; /* NOTREACHED */ } return ret; } /* - regbranch - one alternative of an | operator * * Implements the concatenation operator. */ static unsigned char * regbranch (compile_t *x, unsigned char *flagp) { unsigned char *ret; unsigned char *chain; unsigned char *latest; unsigned char flags; *flagp = WORST; /* Tentatively. */ ret = regnode (x, BRANCH); chain = 0; while (*x->parse != '\0' && *x->parse != ')' && *x->parse != '\n' && *x->parse != '|') { latest = regpiece (x, &flags); if (! latest) return 0; *flagp |= flags & HASWIDTH; if (! chain) /* First piece. */ *flagp |= flags & SPSTART; else regtail (chain, latest); chain = latest; } if (! chain) /* Loop ran zero times. */ regnode (x, NOTHING); return ret; } /* - regpiece - something followed by possible [*+?] * * Note that the branching code sequences used for ? and the general cases * of * and + are somewhat optimized: they use the same NOTHING node as * both the endmarker for their branch list and the body of the last branch. * It might seem that this node could be dispensed with entirely, but the * endmarker role is not redundant. */ static unsigned char * regpiece (compile_t *x, unsigned char *flagp) { unsigned char *ret; unsigned char op; unsigned char *next; unsigned char flags; ret = regatom (x, &flags); if (! ret) return 0; op = *x->parse; if (! ISMULT (op)) { *flagp = flags; return ret; } if (!(flags&HASWIDTH) && op != '?') { /* FAIL("*+ operand could be empty"); */ return 0; } *flagp = (op != '+') ? (WORST | SPSTART) : (WORST | HASWIDTH); if (op == '*' && (flags&SIMPLE)) reginsert (x, STAR, ret); else if (op == '*') { /* Emit x* as (x&|), where & means "self". */ reginsert (x, BRANCH, ret); /* Either x */ regoptail (ret, regnode (x, BACK)); /* and loop */ regoptail (ret, ret); /* back */ regtail (ret, regnode (x, BRANCH)); /* or */ regtail (ret, regnode (x, NOTHING)); /* null. */ } else if (op == '+' && (flags&SIMPLE)) reginsert (x, PLUS, ret); else if (op == '+') { /* Emit x+ as x(&|), where & means "self". */ next = regnode (x, BRANCH); /* Either */ regtail (ret, next); regtail (regnode (x, BACK), ret); /* loop back */ regtail (next, regnode (x, BRANCH)); /* or */ regtail (ret, regnode (x, NOTHING)); /* null. */ } else if (op == '?') { /* Emit x? as (x|) */ reginsert (x, BRANCH, ret); /* Either x */ regtail (ret, regnode (x, BRANCH)); /* or */ next = regnode (x, NOTHING); /* null. */ regtail (ret, next); regoptail (ret, next); } x->parse++; if (ISMULT (*x->parse)) { /* FAIL("nested *?+"); */ return 0; } return ret; } /* - regatom - the lowest level * * Optimization: gobbles an entire sequence of ordinary characters so that * it can turn them into a single node, which is smaller to store and * faster to run. Backslashed characters are exceptions, each becoming a * separate node; the code is simpler that way and it's not worth fixing. */ static unsigned char * regatom (compile_t *x, unsigned char *flagp) { unsigned char *ret; unsigned char flags; *flagp = WORST; /* Tentatively. */ switch (*x->parse++) { /* FIXME: these chars only have meaning at beg/end of pat? */ case '^': ret = regnode (x, BOL); break; case '$': ret = regnode (x, EOL); break; case '.': ret = regnode (x, ANY); *flagp |= HASWIDTH | SIMPLE; break; case '[': { unsigned char class, classend; if (*x->parse == '^') { /* Complement of range. */ ret = regnode (x, ANYBUT); x->parse++; } else ret = regnode (x, ANYOF); if (*x->parse == ']' || *x->parse == '-') regc (x, *x->parse++); while (*x->parse != '\0' && *x->parse != ']') { if (*x->parse == '-') { x->parse++; if (*x->parse == ']' || *x->parse == '\0') regc (x, '-'); else { class = UCHARAT(x->parse-2); classend = UCHARAT(x->parse); if (class > classend) { /* FAIL("invalid [] range"); */ return 0; } for (class++; class <= classend; class++) regc (x, class); x->parse++; } } else regc (x, *x->parse++); } regc (x, '\0'); if (*x->parse != ']') { /* FAIL("unmatched []"); */ return 0; } x->parse++; *flagp |= HASWIDTH | SIMPLE; } break; case '(': ret = reg (x, 1, &flags); if (! ret) return 0; *flagp |= flags & (HASWIDTH | SPSTART); break; case '\0': case '|': case '\n': case ')': /* Supposed to be caught earlier. */ /* FAIL("internal urp"); */ return 0; case '?': case '+': case '*': /* FAIL("?+* follows nothing"); */ return 0; case '\\': switch (*x->parse++) { case '\0': /* FAIL("trailing \\"); */ return 0; case '<': ret = regnode (x, WORDA); break; case '>': ret = regnode (x, WORDZ); break; /* FIXME: Someday handle \1, \2, ... */ default: /* Handle general quoted chars in exact-match routine */ goto de_fault; } break; de_fault: default: /* * Encode a string of characters to be matched exactly. * * This is a bit tricky due to quoted chars and due to * '*', '+', and '?' taking the SINGLE char previous * as their operand. * * On entry, the char at regparse[-1] is going to go * into the string, no matter what it is. (It could be * following a \ if we are entered from the '\' case.) * * Basic idea is to pick up a good char in ch and * examine the next char. If it's *+? then we twiddle. * If it's \ then we frozzle. If it's other magic char * we push ch and terminate the string. If none of the * above, we push ch on the string and go around again. * * `Regprev' is used to remember where "the current char" * starts in the string, if due to a *+? we need to back * up and put the current char in a separate, 1-char, string. * When `regprev' is NULL, ch is the only char in the * string; this is used in *+? handling, and in setting * flags |= SIMPLE at the end. */ { const unsigned char *regprev; unsigned char ch; x->parse--; /* Look at cur char */ ret = regnode (x, EXACTLY); regprev = 0; for (;;) { ch = *x->parse++; /* Get current char */ switch (*x->parse) { /* look at next one */ default: regc (x, ch); /* Add cur to string */ break; case '.': case '[': case '(': case ')': case '|': case '\n': case '$': case '^': case '\0': /* FIXME, $ and ^ should not always be magic */ magic: regc (x, ch); /* dump cur char */ goto done; /* and we are done */ case '?': case '+': case '*': if (! regprev) /* If just ch in str, */ goto magic; /* use it */ /* End mult-char string one early */ x->parse = regprev; /* Back up parse */ goto done; case '\\': regc (x, ch); /* Cur char OK */ switch (x->parse[1]){ /* Look after \ */ case '\0': case '<': case '>': /* FIXME: Someday handle \1, \2, ... */ goto done; /* Not quoted */ default: /* Backup point is \, scan * point is after it. */ regprev = x->parse; x->parse++; continue; /* NOT break; */ } } regprev = x->parse; /* Set backup point */ } done: regc (x, '\0'); *flagp |= HASWIDTH; if (! regprev) /* One char? */ *flagp |= SIMPLE; } break; } return ret; } /* - regnode - emit a node */ static unsigned char * /* Location. */ regnode (compile_t *x, unsigned char op) { unsigned char *ret; unsigned char *ptr; ret = x->code; if (ret == ®dummy) { x->size += 3; return ret; } ptr = ret; *ptr++ = op; *ptr++ = '\0'; /* Null "next" pointer. */ *ptr++ = '\0'; x->code = ptr; return ret; } /* - regc - emit (if appropriate) a byte of code */ static void regc (compile_t *x, unsigned char b) { if (x->code != ®dummy) *x->code++ = b; else x->size++; } /* - reginsert - insert an operator in front of already-emitted operand * * Means relocating the operand. */ static void reginsert (compile_t *x, unsigned char op, unsigned char *opnd) { unsigned char *src; unsigned char *dst; unsigned char *place; if (x->code == ®dummy) { x->size += 3; return; } src = x->code; x->code += 3; dst = x->code; while (src > opnd) *--dst = *--src; place = opnd; /* Op node, where operand used to be. */ *place++ = op; *place++ = '\0'; *place++ = '\0'; } /* - regtail - set the next-pointer at the end of a node chain */ static void regtail (unsigned char *p, unsigned char *val) { unsigned char *scan; unsigned char *temp; unsigned short offset; if (p == ®dummy) return; /* Find last node. */ scan = p; for (;;) { temp = regnext (scan); if (! temp) break; scan = temp; } if (OP(scan) == BACK) offset = scan - val; else offset = val - scan; *(scan+1) = (offset >> 8) & 0377; *(scan+2) = offset & 0377; } /* - regoptail - regtail on operand of first argument; nop if operandless */ static void regoptail (unsigned char *p, unsigned char *val) { /* "Operandless" and "op != BRANCH" are synonymous in practice. */ if (! p || p == ®dummy || OP(p) != BRANCH) return; regtail (OPERAND(p), val); } /* * regexec and friends */ /* * Match a regular expression against a string. * Returns 1 on success, or 0 on failure. */ bool_t regexp_execute (regexp_t *prog, const unsigned char *string) { execute_t z; const unsigned char *s; /* Be paranoid... */ if (! prog || ! string) { /* regerror("NULL parameter"); */ return 0; } /* Check validity of program. */ if (UCHARAT (prog->program) != MAGIC) { /* regerror("corrupted program"); */ return 0; } /* If there is a "must appear" string, look for it. */ if (prog->must) { s = string; while ((s = strchr (s, prog->must[0])) != 0) { if (strncmp (s, prog->must, prog->mustlen) == 0) break; /* Found it. */ s++; } if (! s) /* Not present. */ return 0; } /* Mark beginning of line for ^ . */ z.bol = string; /* Simplest case: anchored match need be tried only once. */ if (prog->anchor) return regtry (prog, &z, string); /* Messy cases: unanchored match. */ s = string; if (prog->start != '\0') /* We know what char it must start with. */ while ((s = strchr (s, prog->start)) != 0) { if (regtry (prog, &z, s)) return 1; s++; } else /* We don't -- general case. */ do { if (regtry (prog, &z, s)) return 1; } while (*s++ != '\0'); /* Failure. */ return 0; } /* - regtry - try match at specific point */ static unsigned char /* 0 failure, 1 success */ regtry (regexp_t *prog, execute_t *z, const unsigned char *string) { unsigned char i; const unsigned char **sp; const unsigned char **ep; z->input = string; z->startp = prog->startp; z->endp = prog->endp; sp = prog->startp; ep = prog->endp; for (i=NSUBEXP; i>0; i--) { *sp++ = 0; *ep++ = 0; } if (regmatch (z, prog->program + 1)) { prog->startp[0] = string; prog->endp[0] = z->input; return 1; } return 0; } /* - regmatch - main matching routine * * Conceptually the strategy is simple: check to see whether the current * node matches, call self recursively to see whether the rest matches, * and then act accordingly. In practice we make some effort to avoid * recursion, in particular by going through "ordinary" nodes (that don't * need to know whether the rest of the match failed) by a loop instead of * by recursion. */ static unsigned char /* 0 failure, 1 success */ regmatch (execute_t *z, unsigned char *prog) { unsigned char *scan; /* Current node. */ unsigned char *next; /* Next node. */ scan = prog; #ifdef DEBUG_REGEXP if (scan && regsub_narrate) fprintf (stderr, "%s(\n", regprop (scan)); #endif while (scan) { #ifdef DEBUG_REGEXP if (regsub_narrate) fprintf (stderr, "%s...\n", regprop (scan)); #endif next = regnext (scan); switch (OP(scan)) { case BOL: if (z->input != z->bol) return 0; break; case EOL: if (*z->input != '\0') return 0; break; case WORDA: /* Must be looking at a letter, digit, or _ */ if ((!ISALNUM((unsigned char)*z->input)) && *z->input != '_') return 0; /* Prev must be BOL or nonword */ if (z->input > z->bol && (ISALNUM((unsigned char)z->input[-1]) || z->input[-1] == '_')) return 0; break; case WORDZ: /* Must be looking at non letter, digit, or _ */ if (ISALNUM((unsigned char)*z->input) || *z->input == '_') return 0; /* We don't care what the previous char was */ break; case ANY: if (*z->input == '\0') return 0; z->input++; break; case EXACTLY: { unsigned short len; unsigned char *opnd; opnd = OPERAND(scan); /* Inline the first character, for speed. */ if (*opnd != *z->input) return 0; len = strlen(opnd); if (len > 1 && strncmp(opnd, z->input, len) != 0) return 0; z->input += len; } break; case ANYOF: if (*z->input == '\0' || strchr(OPERAND(scan), *z->input) == 0) return 0; z->input++; break; case ANYBUT: if (*z->input == '\0' || strchr(OPERAND(scan), *z->input) != 0) return 0; z->input++; break; case NOTHING: break; case BACK: break; case OPEN+1: case OPEN+2: case OPEN+3: case OPEN+4: case OPEN+5: case OPEN+6: case OPEN+7: case OPEN+8: case OPEN+9: { unsigned char no; const unsigned char *save; no = OP(scan) - OPEN; save = z->input; if (regmatch (z, next)) { /* * Don't set startp if some later * invocation of the same parentheses * already has. */ if (! z->startp[no]) z->startp[no] = save; return 1; } return 0; } break; case CLOSE+1: case CLOSE+2: case CLOSE+3: case CLOSE+4: case CLOSE+5: case CLOSE+6: case CLOSE+7: case CLOSE+8: case CLOSE+9: { unsigned char no; const unsigned char *save; no = OP(scan) - CLOSE; save = z->input; if (regmatch (z, next)) { /* * Don't set endp if some later * invocation of the same parentheses * already has. */ if (! z->endp[no]) z->endp[no] = save; return 1; } return 0; } break; case BRANCH: { const unsigned char *save; if (OP(next) != BRANCH) /* No choice. */ next = OPERAND(scan); /* Avoid recursion. */ else { do { save = z->input; if (regmatch (z, OPERAND(scan))) return 1; z->input = save; scan = regnext (scan); } while (scan && OP(scan) == BRANCH); return 0; /* NOTREACHED */ } } break; case STAR: case PLUS: { unsigned char nextch; unsigned short no, min; const unsigned char *save; /* * Lookahead to avoid useless match attempts * when we know what character comes next. */ nextch = '\0'; if (OP(next) == EXACTLY) nextch = *OPERAND(next); min = (OP(scan) == STAR) ? 0 : 1; save = z->input; no = regrepeat (z, OPERAND(scan)); while (no >= min) { /* If it could work, try it. */ if (nextch == '\0' || *z->input == nextch) if (regmatch (z, next)) return 1; /* Couldn't or didn't -- back up. */ no--; z->input = save + no; } return 0; } break; case END: return 1; /* Success! */ default: /* regerror("memory corruption"); */ return 0; } scan = next; } /* * We get here only if there's trouble -- normally "case END" is * the terminating point. */ /* regerror("corrupted pointers"); */ return 0; } /* - regrepeat - repeatedly match something simple, report how many */ static unsigned short regrepeat (execute_t *z, unsigned char *p) { unsigned short count = 0; const unsigned char *scan; unsigned char *opnd; scan = z->input; opnd = OPERAND(p); switch (OP(p)) { case ANY: count = strlen(scan); scan += count; break; case EXACTLY: while (*opnd == *scan) { count++; scan++; } break; case ANYOF: while (*scan != '\0' && strchr(opnd, *scan) != 0) { count++; scan++; } break; case ANYBUT: while (*scan != '\0' && strchr(opnd, *scan) == 0) { count++; scan++; } break; default: /* Oh dear. Called inappropriately. */ /* regerror("internal foulup"); */ count = 0; /* Best compromise. */ break; } z->input = scan; return count; } /* - regnext - dig the "next" pointer out of a node */ static unsigned char * regnext (unsigned char *p) { unsigned short offset; if (p == ®dummy) return 0; offset = NEXT(p); if (offset == 0) return 0; if (OP(p) == BACK) return p - offset; else return p + offset; } #ifdef DEBUG_REGEXP /* * Dump a regexp onto stdout in vaguely comprehensible form */ void regsub_dump (regexp_t *r) { unsigned char *s; unsigned char op = EXACTLY; /* Arbitrary non-END op. */ unsigned char *next; s = r->program + 1; while (op != END) { /* While that wasn't END last time... */ op = OP(s); printf("%2d%s", s-r->program, regprop (s)); /* Where, what. */ next = regnext (s); if (! next) /* Next ptr. */ printf("(0)"); else printf("(%d)", (s-r->program)+(next-s)); s += 3; if (op == ANYOF || op == ANYBUT || op == EXACTLY) { /* Literal string, where present. */ while (*s != '\0') { putchar(*s); s++; } s++; } putchar('\n'); } /* Header fields of interest. */ if (r->start != '\0') printf("start `%c' ", r->start); if (r->anchor) printf("anchored "); if (r->must) printf("must have \"%s\"", r->must); printf("\n"); } /* - regprop - printable representation of opcode */ static unsigned char * regprop (unsigned char *op) { unsigned char *p; static unsigned char buf[50]; strcpy (buf, ":"); switch (OP(op)) { case BOL: p = "BOL"; break; case EOL: p = "EOL"; break; case ANY: p = "ANY"; break; case ANYOF: p = "ANYOF"; break; case ANYBUT: p = "ANYBUT"; break; case BRANCH: p = "BRANCH"; break; case EXACTLY: p = "EXACTLY"; break; case NOTHING: p = "NOTHING"; break; case BACK: p = "BACK"; break; case END: p = "END"; break; case STAR: p = "STAR"; break; case PLUS: p = "PLUS"; break; case WORDA: p = "WORDA"; break; case WORDZ: p = "WORDZ"; break; case OPEN+1: case OPEN+2: case OPEN+3: case OPEN+4: case OPEN+5: case OPEN+6: case OPEN+7: case OPEN+8: case OPEN+9: sprintf (buf + strlen (buf), "OPEN%d", OP(op) - OPEN); p = 0; break; case CLOSE+1: case CLOSE+2: case CLOSE+3: case CLOSE+4: case CLOSE+5: case CLOSE+6: case CLOSE+7: case CLOSE+8: case CLOSE+9: sprintf (buf + strlen (buf), "CLOSE%d", OP(op) - CLOSE); p = 0; break; default: /* corrupted opcode */ p = "???"; break; } if (p) strcat (buf, p); return buf; } #endif ================================================ FILE: lib/libtcl/regexp.h ================================================ /* * Definitions etc. for regexp(3) routines. */ typedef struct _regexp_t regexp_t; typedef int bool_t; /* * Determine the required size. * On failure, returns 0. */ unsigned regexp_size (const unsigned char *pattern); /* * Compile a regular expression into internal code. * Returns 1 on success, or 0 on failure. */ bool_t regexp_compile (regexp_t *re, const unsigned char *pattern); /* * Match a regular expression against a string. * Returns 1 on success, or 0 on failure. */ bool_t regexp_execute (regexp_t *re, const unsigned char *str); /* * Perform substitutions after a regexp match. * Returns 1 on success, or 0 on failure. */ bool_t regexp_substitute (const regexp_t *re, const unsigned char *src, unsigned char *dst); ================================================ FILE: lib/libtcl/regpriv.h ================================================ /* * Internal definitions for regexp(3) routines. */ #define NSUBEXP 10 /* * The "internal use only" fields in regexp.h are present to pass info from * compile to execute that permits the execute phase to run lots faster on * simple cases. They are: * * start char that must begin a match; '\0' if none obvious * anchor is the match anchored (at beginning-of-line only)? * must string (pointer into program) that match must include, or NULL * mustlen length of `must' string * * `Start' and `anchor' permit very fast decisions on suitable starting points * for a match, cutting down the work a lot. `Must' permits fast rejection * of lines that cannot possibly match. The `must' tests are costly enough * that regcomp() supplies a `must' only if the r.e. contains something * potentially expensive (at present, the only such thing detected is * or + * at the start of the r.e., which can involve a lot of backup). `Mustlen' is * supplied because the test in regexec() needs it and regcomp() is computing * it anyway. */ struct _regexp_t { const unsigned char *startp [NSUBEXP]; const unsigned char *endp [NSUBEXP]; unsigned char start; unsigned char anchor; unsigned char *must; unsigned short mustlen; unsigned char program [1]; }; /* * Utility definitions. */ #define UCHARAT(p) (*(unsigned char*)(p)) /* * The first byte of the regexp internal "program" is actually this magic * number; the start node begins in the second byte. */ #define MAGIC 0234 #ifdef DEBUG_REGEXP unsigned char regsub_narrate; void regsub_dump (regexp_t *r); #endif ================================================ FILE: lib/libtcl/regsub.c ================================================ /* * Copyright (c) 1986 by University of Toronto. * Written by Henry Spencer. Not derived from licensed software. * * Permission is granted to anyone to use this software for any * purpose on any computer system, and to redistribute it freely, * subject to the following restrictions: * * 1. The author is not responsible for the consequences of use of * this software, no matter how awful, even if they arise * from defects in it. * * 2. The origin of this software must not be misrepresented, either * by explicit claim or by omission. * * 3. Altered versions must be plainly marked as such, and must not * be misrepresented as being the original software. */ #include #include #include "regexp.h" #include "regpriv.h" /* * Perform substitutions after a regexp match. * Returns 1 on success, or 0 on failure. */ bool_t regexp_substitute (const regexp_t *prog, const unsigned char *src, unsigned char *dst) { unsigned char c; unsigned char no; unsigned short len; if (! prog || ! src || ! dst) { /* regerror("NULL parm to regsub"); */ return 0; } if (UCHARAT(prog->program) != MAGIC) { /* regerror("damaged regexp fed to regsub"); */ return 0; } while ((c = *src++) != '\0') { if (c == '&') no = 0; else if (c == '\\' && '0' <= *src && *src <= '9') no = *src++ - '0'; else no = 10; if (no > 9) { /* Ordinary character. */ if (c == '\\' && (*src == '\\' || *src == '&')) c = *src++; *dst++ = c; } else if (prog->startp[no] && prog->endp[no]) { len = prog->endp[no] - prog->startp[no]; strncpy (dst, prog->startp[no], len); dst += len; if (len != 0 && dst[-1] == '\0') { /* strncpy hit NUL. */ /* regerror("damaged match string"); */ return 0; } } } *dst = '\0'; return 1; } ================================================ FILE: lib/libtcl/tclassem.c ================================================ /* * tclAssem.c -- * * This file contains procedures to help assemble Tcl commands * from an input source where commands may arrive in pieces, e.g. * several lines of type-in corresponding to one command. * * Copyright 1990-1991 Regents of the University of California * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without * fee is hereby granted, provided that the above copyright * notice appear in all copies. The University of California * makes no representations about the suitability of this * software for any purpose. It is provided "as is" without * express or implied warranty. */ #include "internal.h" /* * The structure below is the internal representation for a command * buffer, which is used to hold a piece of a command until a full * command is available. When a full command is available, it will * be returned to the user, but it will also be retained in the buffer * until the NEXT call to Tcl_AssembleCmd, at which point it will be * removed. */ typedef struct { unsigned char *buffer; /* Storage for command being assembled. * Malloc-ed, and grows as needed. */ int bufSize; /* Total number of bytes in buffer. */ int bytesUsed; /* Number of bytes in buffer currently * occupied (0 means there is not a * buffered incomplete command). */ } CmdBuf; /* * Default amount of space to allocate in command buffer: */ #define CMD_BUF_SIZE 100 /* *---------------------------------------------------------------------- * * Tcl_CreateCmdBuf -- * * Allocate and initialize a command buffer. * * Results: * The return value is a token that may be passed to * Tcl_AssembleCmd and Tcl_DeleteCmdBuf. * * Side effects: * Memory is allocated. * *---------------------------------------------------------------------- */ Tcl_CmdBuf Tcl_CreateCmdBuf () { register CmdBuf *cbPtr; cbPtr = (CmdBuf*) malloc (sizeof(CmdBuf)); cbPtr->buffer = malloc (CMD_BUF_SIZE); cbPtr->buffer[0] = '\0'; cbPtr->bufSize = CMD_BUF_SIZE; cbPtr->bytesUsed = 0; return (Tcl_CmdBuf) cbPtr; } /* *---------------------------------------------------------------------- * * Tcl_DeleteCmdBuf -- * * Release all of the resources associated with a command buffer. * The caller should never again use buffer again. * * Results: * None. * * Side effects: * Memory is released. * *---------------------------------------------------------------------- */ void Tcl_DeleteCmdBuf(buffer) Tcl_CmdBuf buffer; /* Token for command buffer (return value * from previous call to Tcl_CreateCmdBuf). */ { register CmdBuf *cbPtr = (CmdBuf *) buffer; free (cbPtr->buffer); free (cbPtr); } /* *---------------------------------------------------------------------- * * Tcl_AssembleCmd -- * * This is a utility procedure to assist in situations where * commands may be read piece-meal from some input source. Given * some input text, it adds the text to an input buffer and returns * whole commands when they are ready. * * Results: * If the addition of string to any currently-buffered information * results in one or more complete Tcl commands, then the return value * is a pointer to the complete command(s). The command value will * only be valid until the next call to this procedure with the * same buffer. If the addition of string leaves an incomplete * command at the end of the buffer, then NULL is returned. * * Side effects: * If string leaves a command incomplete, the partial command * information is buffered for use in later calls to this procedure. * Once a command has been returned, that command is deleted from * the buffer on the next call to this procedure. * *---------------------------------------------------------------------- */ unsigned char * Tcl_AssembleCmd (buffer, string) Tcl_CmdBuf buffer; /* Token for a command buffer previously * created by Tcl_CreateCmdBuf. */ unsigned char *string; /* Bytes to be appended to command stream. * Note: if the string is zero length, * then whatever is buffered will be * considered to be a complete command * regardless of whether parentheses are * matched or not. */ { register CmdBuf *cbPtr = (CmdBuf *) buffer; int length, totalLength, c; /* * If an empty string is passed in, just pretend the current * command is complete, whether it really is or not. */ length = strlen(string); if (length == 0) { cbPtr->buffer[cbPtr->bytesUsed] = 0; cbPtr->bytesUsed = 0; return cbPtr->buffer; } /* * Add the new information to the buffer. If the current buffer * isn't large enough, grow it by at least a factor of two, or * enough to hold the new text. */ length = strlen(string); totalLength = cbPtr->bytesUsed + length + 1; if (totalLength > cbPtr->bufSize) { unsigned int newSize; unsigned char *newBuf; newSize = cbPtr->bufSize*2; if (newSize < totalLength) { newSize = totalLength; } newBuf = malloc (newSize); strcpy(newBuf, cbPtr->buffer); free(cbPtr->buffer); cbPtr->buffer = newBuf; cbPtr->bufSize = newSize; } strcpy(cbPtr->buffer+cbPtr->bytesUsed, string); cbPtr->bytesUsed += length; /* * See if there is now a complete command in the buffer. */ c = cbPtr->buffer[cbPtr->bytesUsed-1]; if ((c != '\n') && (c != ';')) { return 0; } if (Tcl_CommandComplete(cbPtr->buffer)) { cbPtr->bytesUsed = 0; return cbPtr->buffer; } return 0; } /* *---------------------------------------------------------------------- * * Tcl_CommandComplete -- * * Given a partial or complete Tcl command, this procedure * determines whether the command is complete in the sense * of having matched braces and quotes and brackets. * * Results: * 1 is returned if the command is complete, 0 otherwise. * * Side effects: * None. * *---------------------------------------------------------------------- */ int Tcl_CommandComplete(cmd) unsigned char *cmd; /* Command to check. */ { register unsigned char *p = cmd; p = cmd; while (1) { while (isspace(*p)) { p++; } if (*p == 0) { return 1; } p = TclWordEnd(p, 0); if (*p == 0) { return 0; } p++; } } ================================================ FILE: lib/libtcl/tclbasic.c ================================================ /* * tclBasic.c -- * * Contains the basic facilities for TCL command interpretation, * including interpreter creation and deletion, command creation * and deletion, and command parsing and execution. * * Copyright 1987-1992 Regents of the University of California * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without * fee is hereby granted, provided that the above copyright * notice appear in all copies. The University of California * makes no representations about the suitability of this * software for any purpose. It is provided "as is" without * express or implied warranty. */ #include "internal.h" #include /* * The following structure defines all of the commands in the Tcl core, * and the C procedures that execute them. */ typedef struct { unsigned char *name; /* Name of command. */ Tcl_CmdProc *proc; /* Procedure that executes command. */ } CmdInfo; /* * Built-in commands, and the procedures associated with them: */ static CmdInfo builtin_cmds[] = { /* * Commands in the generic core: */ {(unsigned char*) "append", Tcl_AppendCmd}, {(unsigned char*) "array", Tcl_ArrayCmd}, {(unsigned char*) "break", Tcl_BreakCmd}, {(unsigned char*) "case", Tcl_CaseCmd}, {(unsigned char*) "catch", Tcl_CatchCmd}, {(unsigned char*) "concat", Tcl_ConcatCmd}, {(unsigned char*) "continue", Tcl_ContinueCmd}, {(unsigned char*) "error", Tcl_ErrorCmd}, {(unsigned char*) "eval", Tcl_EvalCmd}, {(unsigned char*) "expr", Tcl_ExprCmd}, {(unsigned char*) "for", Tcl_ForCmd}, {(unsigned char*) "foreach", Tcl_ForeachCmd}, {(unsigned char*) "format", Tcl_FormatCmd}, {(unsigned char*) "global", Tcl_GlobalCmd}, {(unsigned char*) "if", Tcl_IfCmd}, {(unsigned char*) "incr", Tcl_IncrCmd}, {(unsigned char*) "info", Tcl_InfoCmd}, {(unsigned char*) "join", Tcl_JoinCmd}, {(unsigned char*) "lappend", Tcl_LappendCmd}, {(unsigned char*) "lindex", Tcl_LindexCmd}, {(unsigned char*) "linsert", Tcl_LinsertCmd}, {(unsigned char*) "list", Tcl_ListCmd}, {(unsigned char*) "llength", Tcl_LlengthCmd}, {(unsigned char*) "lrange", Tcl_LrangeCmd}, {(unsigned char*) "lreplace", Tcl_LreplaceCmd}, {(unsigned char*) "lsearch", Tcl_LsearchCmd}, {(unsigned char*) "lsort", Tcl_LsortCmd}, {(unsigned char*) "proc", Tcl_ProcCmd}, {(unsigned char*) "regexp", Tcl_RegexpCmd}, {(unsigned char*) "regsub", Tcl_RegsubCmd}, {(unsigned char*) "rename", Tcl_RenameCmd}, {(unsigned char*) "return", Tcl_ReturnCmd}, {(unsigned char*) "scan", Tcl_ScanCmd}, {(unsigned char*) "set", Tcl_SetCmd}, {(unsigned char*) "split", Tcl_SplitCmd}, {(unsigned char*) "string", Tcl_StringCmd}, {(unsigned char*) "trace", Tcl_TraceCmd}, {(unsigned char*) "unset", Tcl_UnsetCmd}, {(unsigned char*) "uplevel", Tcl_UplevelCmd}, {(unsigned char*) "upvar", Tcl_UpvarCmd}, {(unsigned char*) "while", Tcl_WhileCmd}, /* * Commands in the UNIX core: */ #ifdef TCL_FILE_CMDS {(unsigned char*) "glob", Tcl_GlobCmd}, {(unsigned char*) "cd", Tcl_CdCmd}, {(unsigned char*) "close", Tcl_CloseCmd}, {(unsigned char*) "eof", Tcl_EofCmd}, {(unsigned char*) "exit", Tcl_ExitCmd}, {(unsigned char*) "file", Tcl_FileCmd}, {(unsigned char*) "flush", Tcl_FlushCmd}, {(unsigned char*) "gets", Tcl_GetsCmd}, {(unsigned char*) "open", Tcl_OpenCmd}, {(unsigned char*) "puts", Tcl_PutsCmd}, {(unsigned char*) "pwd", Tcl_PwdCmd}, {(unsigned char*) "read", Tcl_ReadCmd}, {(unsigned char*) "seek", Tcl_SeekCmd}, {(unsigned char*) "source", Tcl_SourceCmd}, {(unsigned char*) "tell", Tcl_TellCmd}, #endif {0, 0} }; /* *---------------------------------------------------------------------- * * Tcl_CreateInterp -- * * Create a new TCL command interpreter. * * Results: * The return value is a token for the interpreter, which may be * used in calls to procedures like Tcl_CreateCmd, Tcl_Eval, or * Tcl_DeleteInterp. * * Side effects: * The command interpreter is initialized with an empty variable * table and the built-in commands. * *---------------------------------------------------------------------- */ Tcl_Interp * Tcl_CreateInterp () { Interp *iPtr; Command *c; CmdInfo *ci; int i; iPtr = (Interp*) malloc (sizeof(Interp)); iPtr->result = iPtr->resultSpace; iPtr->freeProc = 0; iPtr->errorLine = 0; Tcl_InitHashTable (&iPtr->commandTable, TCL_STRING_KEYS); Tcl_InitHashTable (&iPtr->globalTable, TCL_STRING_KEYS); iPtr->numLevels = 0; iPtr->framePtr = 0; iPtr->varFramePtr = 0; iPtr->activeTracePtr = 0; iPtr->numEvents = 0; iPtr->events = 0; iPtr->curEvent = 0; iPtr->curEventNum = 0; iPtr->revPtr = 0; iPtr->historyFirst = 0; iPtr->revDisables = 1; iPtr->evalFirst = iPtr->evalLast = 0; iPtr->appendResult = 0; iPtr->appendAvl = 0; iPtr->appendUsed = 0; iPtr->numFiles = 0; iPtr->filePtrArray = 0; for (i = 0; i < NUM_REGEXPS; i++) { iPtr->patterns[i] = 0; iPtr->patLengths[i] = -1; iPtr->regexps[i] = 0; } iPtr->cmdCount = 0; iPtr->noEval = 0; iPtr->scriptFile = 0; iPtr->flags = 0; iPtr->tracePtr = 0; iPtr->resultSpace[0] = 0; /* * Create the built-in commands. Do it here, rather than calling * Tcl_CreateCommand, because it's faster (there's no need to * check for a pre-existing command by the same name). */ for (ci = builtin_cmds; ci->name != 0; ci++) { int new; Tcl_HashEntry *he; he = Tcl_CreateHashEntry (&iPtr->commandTable, ci->name, &new); if (new) { c = (Command*) malloc (sizeof(Command)); c->proc = ci->proc; c->clientData = (void*) 0; c->deleteProc = 0; Tcl_SetHashValue (he, c); } } #ifdef TCL_ENV_CMDS TclSetupEnv ((Tcl_Interp *) iPtr); #endif return (Tcl_Interp *) iPtr; } /* *---------------------------------------------------------------------- * * Tcl_DeleteInterp -- * * Delete an interpreter and free up all of the resources associated * with it. * * Results: * None. * * Side effects: * The interpreter is destroyed. The caller should never again * use the interp token. * *---------------------------------------------------------------------- */ void Tcl_DeleteInterp(interp) Tcl_Interp *interp; /* Token for command interpreter (returned * by a previous call to Tcl_CreateInterp). */ { Interp *iPtr = (Interp *) interp; Tcl_HashEntry *he; Tcl_HashSearch search; register Command *c; int i; /* * If the interpreter is in use, delay the deletion until later. */ iPtr->flags |= DELETED; if (iPtr->numLevels != 0) { return; } /* * Free up any remaining resources associated with the * interpreter. */ for (he = Tcl_FirstHashEntry(&iPtr->commandTable, &search); he != 0; he = Tcl_NextHashEntry(&search)) { c = (Command *) Tcl_GetHashValue(he); if (c->deleteProc != 0) { (*c->deleteProc)(c->clientData); } free (c); } Tcl_DeleteHashTable(&iPtr->commandTable); TclDeleteVars(iPtr, &iPtr->globalTable); if (iPtr->events != 0) { int i; for (i = 0; i < iPtr->numEvents; i++) { free(iPtr->events[i].command); } free (iPtr->events); } while (iPtr->revPtr != 0) { HistoryRev *nextPtr = iPtr->revPtr->nextPtr; free (iPtr->revPtr); iPtr->revPtr = nextPtr; } if (iPtr->appendResult != 0) { free(iPtr->appendResult); } #ifdef TCL_FILE_CMDS if (iPtr->numFiles > 0) { for (i = 0; i < iPtr->numFiles; i++) { OpenFile *filePtr; filePtr = iPtr->filePtrArray[i]; if (filePtr == 0) { continue; } if (i >= 3) { fclose(filePtr->f); if (filePtr->f2 != 0) { fclose(filePtr->f2); } if (filePtr->numPids > 0) { /* Tcl_DetachPids(filePtr->numPids, filePtr->pidPtr); */ free (filePtr->pidPtr); } } free (filePtr); } free (iPtr->filePtrArray); } #endif for (i = 0; i < NUM_REGEXPS; i++) { if (iPtr->patterns[i] == 0) { break; } free (iPtr->patterns[i]); free (iPtr->regexps[i]); } while (iPtr->tracePtr != 0) { Trace *nextPtr = iPtr->tracePtr->nextPtr; free (iPtr->tracePtr); iPtr->tracePtr = nextPtr; } free (iPtr); } /* *---------------------------------------------------------------------- * * Tcl_CreateCommand -- * * Define a new command in a command table. * * Results: * None. * * Side effects: * If a command named cmdName already exists for interp, it is * deleted. In the future, when cmdName is seen as the name of * a command by Tcl_Eval, proc will be called. When the command * is deleted from the table, deleteProc will be called. See the * manual entry for details on the calling sequence. * *---------------------------------------------------------------------- */ void Tcl_CreateCommand(interp, cmdName, proc, clientData, deleteProc) Tcl_Interp *interp; /* Token for command interpreter (returned * by a previous call to Tcl_CreateInterp). */ unsigned char *cmdName; /* Name of command. */ Tcl_CmdProc *proc; /* Command procedure to associate with * cmdName. */ void *clientData; /* Arbitrary one-word value to pass to proc. */ Tcl_CmdDeleteProc *deleteProc; /* If not NULL, gives a procedure to call when * this command is deleted. */ { Interp *iPtr = (Interp *) interp; register Command *c; Tcl_HashEntry *he; int new; he = Tcl_CreateHashEntry(&iPtr->commandTable, cmdName, &new); if (!new) { /* * Command already exists: delete the old one. */ c = (Command *) Tcl_GetHashValue(he); if (c->deleteProc != 0) { (*c->deleteProc)(c->clientData); } } else { c = (Command*) malloc (sizeof(Command)); Tcl_SetHashValue(he, c); } c->proc = proc; c->clientData = clientData; c->deleteProc = deleteProc; } /* *---------------------------------------------------------------------- * * Tcl_DeleteCommand -- * * Remove the given command from the given interpreter. * * Results: * 0 is returned if the command was deleted successfully. * -1 is returned if there didn't exist a command by that * name. * * Side effects: * CmdName will no longer be recognized as a valid command for * interp. * *---------------------------------------------------------------------- */ int Tcl_DeleteCommand(interp, cmdName) Tcl_Interp *interp; /* Token for command interpreter (returned * by a previous call to Tcl_CreateInterp). */ unsigned char *cmdName; /* Name of command to remove. */ { Interp *iPtr = (Interp *) interp; Tcl_HashEntry *he; Command *c; he = Tcl_FindHashEntry(&iPtr->commandTable, cmdName); if (he == 0) { return -1; } c = (Command *) Tcl_GetHashValue(he); if (c->deleteProc != 0) { (*c->deleteProc)(c->clientData); } free (c); Tcl_DeleteHashEntry(he); return 0; } /* *----------------------------------------------------------------- * * Tcl_Eval -- * * Parse and execute a command in the Tcl language. * * Results: * The return value is one of the return codes defined in tcl.hd * (such as TCL_OK), and interp->result contains a string value * to supplement the return code. The value of interp->result * will persist only until the next call to Tcl_Eval: copy it or * lose it! *TermPtr is filled in with the character just after * the last one that was part of the command (usually a NULL * character or a closing bracket). * * Side effects: * Almost certainly; depends on the command. * *----------------------------------------------------------------- */ int Tcl_Eval(interp, cmd, flags, termPtr) Tcl_Interp *interp; /* Token for command interpreter (returned * by a previous call to Tcl_CreateInterp). */ unsigned char *cmd; /* Pointer to TCL command to interpret. */ int flags; /* OR-ed combination of flags like * TCL_BRACKET_TERM and TCL_RECORD_BOUNDS. */ unsigned char **termPtr; /* If non-NULL, fill in the address it points * to with the address of the char. just after * the last one that was part of cmd. See * the man page for details on this. */ { /* * The storage immediately below is used to generate a copy * of the command, after all argument substitutions. Pv will * contain the argv values passed to the command procedure. */ # define NUM_CHARS 200 unsigned char copyStorage[NUM_CHARS]; ParseValue pv; unsigned char *oldBuffer; /* * This procedure generates an (argv, argc) array for the command, * It starts out with stack-allocated space but uses dynamically- * allocated storage to increase it if needed. */ # define NUM_ARGS 10 unsigned char *(argStorage[NUM_ARGS]); unsigned char **argv = argStorage; int argc; int argSize = NUM_ARGS; register unsigned char *src; /* Points to current character * in cmd. */ char termChar; /* Return when this character is found * (either ']' or '\0'). Zero means * that newlines terminate commands. */ int result; /* Return value. */ register Interp *iPtr = (Interp *) interp; Tcl_HashEntry *he; Command *c; unsigned char *dummy; /* Make termPtr point here if it was * originally NULL. */ unsigned char *cmdStart; /* Points to first non-blank char. in * command (used in calling trace * procedures). */ unsigned char *ellipsis = (unsigned char*) ""; /* Used in setting errorInfo variable; * set to "..." to indicate that not * all of offending command is included * in errorInfo. "" means that the * command is all there. */ register Trace *tracePtr; /* * Initialize the result to an empty string and clear out any * error information. This makes sure that we return an empty * result if there are no commands in the command string. */ Tcl_FreeResult((Tcl_Interp *) iPtr); iPtr->result = iPtr->resultSpace; iPtr->resultSpace[0] = 0; result = TCL_OK; /* * Check depth of nested calls to Tcl_Eval: if this gets too large, * it's probably because of an infinite loop somewhere. */ iPtr->numLevels++; if (iPtr->numLevels > MAX_NESTING_DEPTH) { iPtr->numLevels--; iPtr->result = (unsigned char*) "too many nested calls to Tcl_Eval (infinite loop?)"; return TCL_ERROR; } /* * Initialize the area in which command copies will be assembled. */ pv.buffer = copyStorage; pv.end = copyStorage + NUM_CHARS - 1; pv.expandProc = TclExpandParseValue; pv.clientData = (void*) 0; src = cmd; if (flags & TCL_BRACKET_TERM) { termChar = ']'; } else { termChar = 0; } if (termPtr == 0) { termPtr = &dummy; } *termPtr = src; cmdStart = src; /* * There can be many sub-commands (separated by semi-colons or * newlines) in one command string. This outer loop iterates over * individual commands. */ while (*src != termChar) { iPtr->flags &= ~(ERR_IN_PROGRESS | ERROR_CODE_SET); /* * Skim off leading white space and semi-colons, and skip * comments. */ while (1) { switch (*src) { case '\t': case '\v': case '\f': case '\r': case '\n': case ' ': case ':': ++src; continue; } break; } if (*src == '#') { for (src++; *src != 0; src++) { if ((*src == '\n') && (src[-1] != '\\')) { src++; break; } } continue; } cmdStart = src; /* * Parse the words of the command, generating the argc and * argv for the command procedure. May have to call * TclParseWords several times, expanding the argv array * between calls. */ pv.next = oldBuffer = pv.buffer; argc = 0; while (1) { int newArgs, maxArgs; unsigned char **newArgv; int i; /* * Note: the "- 2" below guarantees that we won't use the * last two argv slots here. One is for a NULL pointer to * mark the end of the list, and the other is to leave room * for inserting the command name "unknown" as the first * argument (see below). */ maxArgs = argSize - argc - 2; result = TclParseWords((Tcl_Interp *) iPtr, src, flags, maxArgs, termPtr, &newArgs, &argv[argc], &pv); src = *termPtr; if (result != TCL_OK) { ellipsis = (unsigned char*) "..."; goto done; } /* * Careful! Buffer space may have gotten reallocated while * parsing words. If this happened, be sure to update all * of the older argv pointers to refer to the new space. */ if (oldBuffer != pv.buffer) { int i; for (i = 0; i < argc; i++) { argv[i] = pv.buffer + (argv[i] - oldBuffer); } oldBuffer = pv.buffer; } argc += newArgs; if (newArgs < maxArgs) { argv[argc] = 0; break; } /* * Args didn't all fit in the current array. Make it bigger. */ argSize *= 2; newArgv = (unsigned char**) malloc ((unsigned) argSize * sizeof(char *)); for (i = 0; i < argc; i++) { newArgv[i] = argv[i]; } if (argv != argStorage) { free (argv); } argv = newArgv; } /* * If this is an empty command (or if we're just parsing * commands without evaluating them), then just skip to the * next command. */ if ((argc == 0) || iPtr->noEval) { continue; } argv[argc] = 0; /* * Save information for the history module, if needed. */ if (flags & TCL_RECORD_BOUNDS) { iPtr->evalFirst = cmdStart; iPtr->evalLast = src-1; } /* * Find the procedure to execute this command. If there isn't * one, then see if there is a command "unknown". If so, * invoke it instead, passing it the words of the original * command as arguments. */ he = Tcl_FindHashEntry(&iPtr->commandTable, argv[0]); if (he == 0) { int i; he = Tcl_FindHashEntry(&iPtr->commandTable, (unsigned char*) "unknown"); if (he == 0) { Tcl_ResetResult(interp); Tcl_AppendResult(interp, "invalid command name: \"", argv[0], "\"", 0); result = TCL_ERROR; goto done; } for (i = argc; i >= 0; i--) { argv[i+1] = argv[i]; } argv[0] = (unsigned char*) "unknown"; argc++; } c = (Command *) Tcl_GetHashValue(he); /* * Call trace procedures, if any. */ for (tracePtr = iPtr->tracePtr; tracePtr != 0; tracePtr = tracePtr->nextPtr) { char saved; if (tracePtr->level < iPtr->numLevels) { continue; } saved = *src; *src = 0; (*tracePtr->proc)(tracePtr->clientData, interp, iPtr->numLevels, cmdStart, c->proc, c->clientData, argc, argv); *src = saved; } /* * At long last, invoke the command procedure. Reset the * result to its default empty value first (it could have * gotten changed by earlier commands in the same command * string). */ iPtr->cmdCount++; Tcl_FreeResult ((Tcl_Interp*) iPtr); iPtr->result = iPtr->resultSpace; iPtr->resultSpace[0] = 0; result = (*c->proc)(c->clientData, interp, argc, argv); if (result != TCL_OK) { break; } } /* * Free up any extra resources that were allocated. */ done: if (pv.buffer != copyStorage) { free (pv.buffer); } if (argv != argStorage) { free (argv); } iPtr->numLevels--; if (iPtr->numLevels == 0) { if (result == TCL_RETURN) { result = TCL_OK; } if ((result != TCL_OK) && (result != TCL_ERROR)) { Tcl_ResetResult(interp); if (result == TCL_BREAK) { iPtr->result = (unsigned char*) "invoked \"break\" outside of a loop"; } else if (result == TCL_CONTINUE) { iPtr->result = (unsigned char*) "invoked \"continue\" outside of a loop"; } else { iPtr->result = iPtr->resultSpace; sprintf(iPtr->resultSpace, "command returned bad code: %d", result); } result = TCL_ERROR; } if (iPtr->flags & DELETED) { Tcl_DeleteInterp(interp); } } /* * If an error occurred, record information about what was being * executed when the error occurred. */ if ((result == TCL_ERROR) && !(iPtr->flags & ERR_ALREADY_LOGGED)) { int numChars; register unsigned char *p; /* * Compute the line number where the error occurred. */ iPtr->errorLine = 1; for (p = cmd; p != cmdStart; p++) { if (*p == '\n') { iPtr->errorLine++; } } for ( ; isspace(*p) || (*p == ';'); p++) { if (*p == '\n') { iPtr->errorLine++; } } /* * Figure out how much of the command to print in the error * message (up to a certain number of characters, or up to * the first new-line). */ numChars = src - cmdStart; if (numChars > (NUM_CHARS-50)) { numChars = NUM_CHARS-50; ellipsis = (unsigned char*) " ..."; } if (!(iPtr->flags & ERR_IN_PROGRESS)) { sprintf(copyStorage, "\n while executing\n\"%.*s%s\"", numChars, cmdStart, ellipsis); } else { sprintf(copyStorage, "\n invoked from within\n\"%.*s%s\"", numChars, cmdStart, ellipsis); } Tcl_AddErrorInfo(interp, copyStorage); iPtr->flags &= ~ERR_ALREADY_LOGGED; } else { iPtr->flags &= ~ERR_ALREADY_LOGGED; } return result; } /* *---------------------------------------------------------------------- * * Tcl_CreateTrace -- * * Arrange for a procedure to be called to trace command execution. * * Results: * The return value is a token for the trace, which may be passed * to Tcl_DeleteTrace to eliminate the trace. * * Side effects: * From now on, proc will be called just before a command procedure * is called to execute a Tcl command. Calls to proc will have the * following form: * * void * proc(clientData, interp, level, command, cmdProc, cmdClientData, * argc, argv) * void *clientData; * Tcl_Interp *interp; * int level; * unsigned char *command; * int (*cmdProc)(); * void *cmdClientData; * int argc; * unsigned char **argv; * { * } * * The clientData and interp arguments to proc will be the same * as the corresponding arguments to this procedure. Level gives * the nesting level of command interpretation for this interpreter * (0 corresponds to top level). Command gives the ASCII text of * the raw command, cmdProc and cmdClientData give the procedure that * will be called to process the command and the ClientData value it * will receive, and argc and argv give the arguments to the * command, after any argument parsing and substitution. Proc * does not return a value. * *---------------------------------------------------------------------- */ Tcl_Trace Tcl_CreateTrace(interp, level, proc, clientData) Tcl_Interp *interp; /* Interpreter in which to create the trace. */ int level; /* Only call proc for commands at nesting level * <= level (1 => top level). */ Tcl_CmdTraceProc *proc; /* Procedure to call before executing each * command. */ void *clientData; /* Arbitrary one-word value to pass to proc. */ { register Trace *tracePtr; register Interp *iPtr = (Interp *) interp; tracePtr = (Trace*) malloc (sizeof(Trace)); tracePtr->level = level; tracePtr->proc = proc; tracePtr->clientData = clientData; tracePtr->nextPtr = iPtr->tracePtr; iPtr->tracePtr = tracePtr; return (Tcl_Trace) tracePtr; } /* *---------------------------------------------------------------------- * * Tcl_DeleteTrace -- * * Remove a trace. * * Results: * None. * * Side effects: * From now on there will be no more calls to the procedure given * in trace. * *---------------------------------------------------------------------- */ void Tcl_DeleteTrace(interp, trace) Tcl_Interp *interp; /* Interpreter that contains trace. */ Tcl_Trace trace; /* Token for trace (returned previously by * Tcl_CreateTrace). */ { register Interp *iPtr = (Interp *) interp; register Trace *tracePtr = (Trace *) trace; register Trace *tracePtr2; if (iPtr->tracePtr == tracePtr) { iPtr->tracePtr = tracePtr->nextPtr; free (tracePtr); } else { for (tracePtr2 = iPtr->tracePtr; tracePtr2 != 0; tracePtr2 = tracePtr2->nextPtr) { if (tracePtr2->nextPtr == tracePtr) { tracePtr2->nextPtr = tracePtr->nextPtr; free (tracePtr); return; } } } } /* *---------------------------------------------------------------------- * * Tcl_AddErrorInfo -- * * Add information to a message being accumulated that describes * the current error. * * Results: * None. * * Side effects: * The contents of message are added to the "errorInfo" variable. * If Tcl_Eval has been called since the current value of errorInfo * was set, errorInfo is cleared before adding the new message. * *---------------------------------------------------------------------- */ void Tcl_AddErrorInfo(interp, message) Tcl_Interp *interp; /* Interpreter to which error information * pertains. */ unsigned char *message; /* Message to record. */ { register Interp *iPtr = (Interp *) interp; /* * If an error is already being logged, then the new errorInfo * is the concatenation of the old info and the new message. * If this is the first piece of info for the error, then the * new errorInfo is the concatenation of the message in * interp->result and the new message. */ if (!(iPtr->flags & ERR_IN_PROGRESS)) { Tcl_SetVar2(interp, (unsigned char*) "errorInfo", 0, interp->result, TCL_GLOBAL_ONLY); iPtr->flags |= ERR_IN_PROGRESS; /* * If the errorCode variable wasn't set by the code that generated * the error, set it to "NONE". */ if (!(iPtr->flags & ERROR_CODE_SET)) { Tcl_SetVar2(interp, (unsigned char*) "errorCode", 0, (unsigned char*) "NONE", TCL_GLOBAL_ONLY); } } Tcl_SetVar2(interp, (unsigned char*) "errorInfo", 0, message, TCL_GLOBAL_ONLY|TCL_APPEND_VALUE); } /* *---------------------------------------------------------------------- * * Tcl_VarEval -- * * Given a variable number of string arguments, concatenate them * all together and execute the result as a Tcl command. * * Results: * A standard Tcl return result. An error message or other * result may be left in interp->result. * * Side effects: * Depends on what was done by the command. * *---------------------------------------------------------------------- */ /* VARARGS2 */ /* ARGSUSED */ int Tcl_VarEval (Tcl_Interp *interp,/* Interpreter in which to execute command. */ ...) /* One or more strings to concatenate, * terminated with a NULL string. */ { va_list argList; #define FIXED_SIZE 200 unsigned char fixedSpace[FIXED_SIZE+1]; int spaceAvl, spaceUsed, length; unsigned char *string, *cmd; int result; /* * Copy the strings one after the other into a single larger * string. Use stack-allocated space for small commands, but if * the commands gets too large than call mem_alloc to create the * space. */ va_start(argList, interp); spaceAvl = FIXED_SIZE; spaceUsed = 0; cmd = fixedSpace; while (1) { string = va_arg(argList, unsigned char *); if (string == 0) { break; } length = strlen(string); if ((spaceUsed + length) > spaceAvl) { unsigned char *new; spaceAvl = spaceUsed + length; spaceAvl += spaceAvl/2; new = malloc ((unsigned) spaceAvl); memcpy ((void*) new, (void*) cmd, spaceUsed); if (cmd != fixedSpace) { free(cmd); } cmd = new; } strcpy(cmd + spaceUsed, string); spaceUsed += length; } va_end(argList); cmd[spaceUsed] = '\0'; result = Tcl_Eval(interp, cmd, 0, 0); if (cmd != fixedSpace) { free(cmd); } return result; } /* *---------------------------------------------------------------------- * * Tcl_GlobalEval -- * * Evaluate a command at global level in an interpreter. * * Results: * A standard Tcl result is returned, and interp->result is * modified accordingly. * * Side effects: * The command string is executed in interp, and the execution * is carried out in the variable context of global level (no * procedures active), just as if an "uplevel #0" command were * being executed. * *---------------------------------------------------------------------- */ int Tcl_GlobalEval(interp, command) Tcl_Interp *interp; /* Interpreter in which to evaluate command. */ unsigned char *command; /* Command to evaluate. */ { register Interp *iPtr = (Interp *) interp; int result; CallFrame *savedVarFramePtr; savedVarFramePtr = iPtr->varFramePtr; iPtr->varFramePtr = 0; result = Tcl_Eval(interp, command, 0, 0); iPtr->varFramePtr = savedVarFramePtr; return result; } ================================================ FILE: lib/libtcl/tclcmdah.c ================================================ /* * tclCmdAH.c -- * * This file contains the top-level command routines for most of * the Tcl built-in commands whose names begin with the letters * A to H. * * Copyright 1987-1991 Regents of the University of California * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without * fee is hereby granted, provided that the above copyright * notice appear in all copies. The University of California * makes no representations about the suitability of this * software for any purpose. It is provided "as is" without * express or implied warranty. */ #include "internal.h" /* *---------------------------------------------------------------------- * * Tcl_BreakCmd -- * * This procedure is invoked to process the "break" Tcl command. * See the user documentation for details on what it does. * * Results: * A standard Tcl result. * * Side effects: * See the user documentation. * *---------------------------------------------------------------------- */ /* ARGSUSED */ int Tcl_BreakCmd(dummy, interp, argc, argv) void *dummy; /* Not used. */ Tcl_Interp *interp; /* Current interpreter. */ int argc; /* Number of arguments. */ unsigned char **argv; /* Argument strings. */ { if (argc != 1) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], "\"", 0); return TCL_ERROR; } return TCL_BREAK; } /* *---------------------------------------------------------------------- * * Tcl_CaseCmd -- * * This procedure is invoked to process the "case" Tcl command. * See the user documentation for details on what it does. * * Results: * A standard Tcl result. * * Side effects: * See the user documentation. * *---------------------------------------------------------------------- */ /* ARGSUSED */ int Tcl_CaseCmd(dummy, interp, argc, argv) void *dummy; /* Not used. */ Tcl_Interp *interp; /* Current interpreter. */ int argc; /* Number of arguments. */ unsigned char **argv; /* Argument strings. */ { int i, result; int body; unsigned char *string; int caseArgc, splitArgs; unsigned char **caseArgv; if (argc < 3) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " string ?in? patList body ... ?default body?\"", 0); return TCL_ERROR; } string = argv[1]; body = -1; if (strcmp(argv[2], (unsigned char*) "in") == 0) { i = 3; } else { i = 2; } caseArgc = argc - i; caseArgv = argv + i; /* * If all of the pattern/command pairs are lumped into a single * argument, split them out again. */ splitArgs = 0; if (caseArgc == 1) { result = Tcl_SplitList(interp, caseArgv[0], &caseArgc, &caseArgv); if (result != TCL_OK) { return result; } splitArgs = 1; } for (i = 0; i < caseArgc; i += 2) { int patArgc, j; unsigned char **patArgv; register unsigned char *p; if (i == (caseArgc-1)) { interp->result = (unsigned char*) "extra case pattern with no body"; result = TCL_ERROR; goto cleanup; } /* * Check for special case of single pattern (no list) with * no backslash sequences. */ for (p = caseArgv[i]; *p != 0; p++) { if (isspace(*p) || (*p == '\\')) { break; } } if (*p == 0) { if ((*caseArgv[i] == 'd') && (strcmp(caseArgv[i], (unsigned char*) "default") == 0)) { body = i+1; } if (Tcl_StringMatch(string, caseArgv[i])) { body = i+1; goto match; } continue; } /* * Break up pattern lists, then check each of the patterns * in the list. */ result = Tcl_SplitList(interp, caseArgv[i], &patArgc, &patArgv); if (result != TCL_OK) { goto cleanup; } for (j = 0; j < patArgc; j++) { if (Tcl_StringMatch(string, patArgv[j])) { body = i+1; break; } } free (patArgv); if (j < patArgc) { break; } } match: if (body != -1) { result = Tcl_Eval(interp, caseArgv[body], 0, 0); if (result == TCL_ERROR) { unsigned char msg[100]; sprintf(msg, "\n (\"%.50s\" arm line %d)", caseArgv[body-1], interp->errorLine); Tcl_AddErrorInfo(interp, msg); } goto cleanup; } /* * Nothing matched: return nothing. */ result = TCL_OK; cleanup: if (splitArgs) { free (caseArgv); } return result; } /* *---------------------------------------------------------------------- * * Tcl_CatchCmd -- * * This procedure is invoked to process the "catch" Tcl command. * See the user documentation for details on what it does. * * Results: * A standard Tcl result. * * Side effects: * See the user documentation. * *---------------------------------------------------------------------- */ /* ARGSUSED */ int Tcl_CatchCmd(dummy, interp, argc, argv) void *dummy; /* Not used. */ Tcl_Interp *interp; /* Current interpreter. */ int argc; /* Number of arguments. */ unsigned char **argv; /* Argument strings. */ { int result; if ((argc != 2) && (argc != 3)) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " command ?varName?\"", 0); return TCL_ERROR; } result = Tcl_Eval(interp, argv[1], 0, 0); if (argc == 3) { if (Tcl_SetVar(interp, argv[2], interp->result, 0) == 0) { Tcl_SetResult(interp, (unsigned char*) "couldn't save command result in variable", TCL_STATIC); return TCL_ERROR; } } Tcl_ResetResult(interp); sprintf(interp->result, "%d", result); return TCL_OK; } /* *---------------------------------------------------------------------- * * Tcl_ConcatCmd -- * * This procedure is invoked to process the "concat" Tcl command. * See the user documentation for details on what it does. * * Results: * A standard Tcl result. * * Side effects: * See the user documentation. * *---------------------------------------------------------------------- */ /* ARGSUSED */ int Tcl_ConcatCmd(dummy, interp, argc, argv) void *dummy; /* Not used. */ Tcl_Interp *interp; /* Current interpreter. */ int argc; /* Number of arguments. */ unsigned char **argv; /* Argument strings. */ { if (argc == 1) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " arg ?arg ...?\"", 0); return TCL_ERROR; } interp->result = Tcl_Concat (argc-1, argv+1); interp->freeProc = (Tcl_FreeProc *) free; return TCL_OK; } /* *---------------------------------------------------------------------- * * Tcl_ContinueCmd -- * * This procedure is invoked to process the "continue" Tcl command. * See the user documentation for details on what it does. * * Results: * A standard Tcl result. * * Side effects: * See the user documentation. * *---------------------------------------------------------------------- */ /* ARGSUSED */ int Tcl_ContinueCmd(dummy, interp, argc, argv) void *dummy; /* Not used. */ Tcl_Interp *interp; /* Current interpreter. */ int argc; /* Number of arguments. */ unsigned char **argv; /* Argument strings. */ { if (argc != 1) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], "\"", 0); return TCL_ERROR; } return TCL_CONTINUE; } /* *---------------------------------------------------------------------- * * Tcl_ErrorCmd -- * * This procedure is invoked to process the "error" Tcl command. * See the user documentation for details on what it does. * * Results: * A standard Tcl result. * * Side effects: * See the user documentation. * *---------------------------------------------------------------------- */ /* ARGSUSED */ int Tcl_ErrorCmd(dummy, interp, argc, argv) void *dummy; /* Not used. */ Tcl_Interp *interp; /* Current interpreter. */ int argc; /* Number of arguments. */ unsigned char **argv; /* Argument strings. */ { Interp *iPtr = (Interp *) interp; if ((argc < 2) || (argc > 4)) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " message ?errorInfo? ?errorCode?\"", 0); return TCL_ERROR; } if ((argc >= 3) && (argv[2][0] != 0)) { Tcl_AddErrorInfo(interp, argv[2]); iPtr->flags |= ERR_ALREADY_LOGGED; } if (argc == 4) { Tcl_SetVar2(interp, (unsigned char*) "errorCode", 0, argv[3], TCL_GLOBAL_ONLY); iPtr->flags |= ERROR_CODE_SET; } Tcl_SetResult(interp, argv[1], TCL_VOLATILE); return TCL_ERROR; } /* *---------------------------------------------------------------------- * * Tcl_EvalCmd -- * * This procedure is invoked to process the "eval" Tcl command. * See the user documentation for details on what it does. * * Results: * A standard Tcl result. * * Side effects: * See the user documentation. * *---------------------------------------------------------------------- */ /* ARGSUSED */ int Tcl_EvalCmd(dummy, interp, argc, argv) void *dummy; /* Not used. */ Tcl_Interp *interp; /* Current interpreter. */ int argc; /* Number of arguments. */ unsigned char **argv; /* Argument strings. */ { int result; unsigned char *cmd; if (argc < 2) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " arg ?arg ...?\"", 0); return TCL_ERROR; } if (argc == 2) { result = Tcl_Eval(interp, argv[1], 0, 0); } else { /* * More than one argument: concatenate them together with spaces * between, then evaluate the result. */ cmd = Tcl_Concat (argc-1, argv+1); result = Tcl_Eval(interp, cmd, 0, 0); free(cmd); } if (result == TCL_ERROR) { unsigned char msg[60]; sprintf(msg, "\n (\"eval\" body line %d)", interp->errorLine); Tcl_AddErrorInfo(interp, msg); } return result; } /* *---------------------------------------------------------------------- * * Tcl_ExprCmd -- * * This procedure is invoked to process the "expr" Tcl command. * See the user documentation for details on what it does. * * Results: * A standard Tcl result. * * Side effects: * See the user documentation. * *---------------------------------------------------------------------- */ /* ARGSUSED */ int Tcl_ExprCmd(dummy, interp, argc, argv) void *dummy; /* Not used. */ Tcl_Interp *interp; /* Current interpreter. */ int argc; /* Number of arguments. */ unsigned char **argv; /* Argument strings. */ { if (argc != 2) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " expression\"", 0); return TCL_ERROR; } return Tcl_ExprString(interp, argv[1]); } /* *---------------------------------------------------------------------- * * Tcl_ForCmd -- * * This procedure is invoked to process the "for" Tcl command. * See the user documentation for details on what it does. * * Results: * A standard Tcl result. * * Side effects: * See the user documentation. * *---------------------------------------------------------------------- */ /* ARGSUSED */ int Tcl_ForCmd(dummy, interp, argc, argv) void *dummy; /* Not used. */ Tcl_Interp *interp; /* Current interpreter. */ int argc; /* Number of arguments. */ unsigned char **argv; /* Argument strings. */ { int result, value; if (argc != 5) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " start test next command\"", 0); return TCL_ERROR; } result = Tcl_Eval(interp, argv[1], 0, 0); if (result != TCL_OK) { if (result == TCL_ERROR) { Tcl_AddErrorInfo(interp, (unsigned char*) "\n (\"for\" initial command)"); } return result; } while (1) { result = Tcl_ExprBoolean(interp, argv[2], &value); if (result != TCL_OK) { return result; } if (!value) { break; } result = Tcl_Eval(interp, argv[4], 0, 0); if (result == TCL_CONTINUE) { result = TCL_OK; } else if (result != TCL_OK) { if (result == TCL_ERROR) { unsigned char msg[60]; sprintf(msg, "\n (\"for\" body line %d)", interp->errorLine); Tcl_AddErrorInfo(interp, msg); } break; } result = Tcl_Eval(interp, argv[3], 0, 0); if (result == TCL_BREAK) { break; } else if (result != TCL_OK) { if (result == TCL_ERROR) { Tcl_AddErrorInfo(interp, (unsigned char*) "\n (\"for\" loop-end command)"); } return result; } } if (result == TCL_BREAK) { result = TCL_OK; } if (result == TCL_OK) { Tcl_ResetResult(interp); } return result; } /* *---------------------------------------------------------------------- * * Tcl_ForeachCmd -- * * This procedure is invoked to process the "foreach" Tcl command. * See the user documentation for details on what it does. * * Results: * A standard Tcl result. * * Side effects: * See the user documentation. * *---------------------------------------------------------------------- */ /* ARGSUSED */ int Tcl_ForeachCmd(dummy, interp, argc, argv) void *dummy; /* Not used. */ Tcl_Interp *interp; /* Current interpreter. */ int argc; /* Number of arguments. */ unsigned char **argv; /* Argument strings. */ { int listArgc, i, result; unsigned char **listArgv; if (argc != 4) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " varName list command\"", 0); return TCL_ERROR; } /* * Break the list up into elements, and execute the command once * for each value of the element. */ result = Tcl_SplitList(interp, argv[2], &listArgc, &listArgv); if (result != TCL_OK) { return result; } for (i = 0; i < listArgc; i++) { if (Tcl_SetVar(interp, argv[1], listArgv[i], 0) == 0) { Tcl_SetResult(interp, (unsigned char*) "couldn't set loop variable", TCL_STATIC); result = TCL_ERROR; break; } result = Tcl_Eval(interp, argv[3], 0, 0); if (result != TCL_OK) { if (result == TCL_CONTINUE) { result = TCL_OK; } else if (result == TCL_BREAK) { result = TCL_OK; break; } else if (result == TCL_ERROR) { unsigned char msg[100]; sprintf(msg, "\n (\"foreach\" body line %d)", interp->errorLine); Tcl_AddErrorInfo(interp, msg); break; } else { break; } } } free (listArgv); if (result == TCL_OK) { Tcl_ResetResult(interp); } return result; } /* *---------------------------------------------------------------------- * * Tcl_FormatCmd -- * * This procedure is invoked to process the "format" Tcl command. * See the user documentation for details on what it does. * * Results: * A standard Tcl result. * * Side effects: * See the user documentation. * *---------------------------------------------------------------------- */ /* ARGSUSED */ int Tcl_FormatCmd(dummy, interp, argc, argv) void *dummy; /* Not used. */ Tcl_Interp *interp; /* Current interpreter. */ int argc; /* Number of arguments. */ unsigned char **argv; /* Argument strings. */ { register unsigned char *format; /* Used to read characters from the format * string. */ unsigned char newFormat[40]; /* A new format specifier is generated here. */ int width; /* Field width from field specifier, or 0 if * no width given. */ int precision; /* Field precision from field specifier, or 0 * if no precision given. */ int size; /* Number of bytes needed for result of * conversion, based on type of conversion * ("e", "s", etc.) and width from above. */ unsigned char *oneWordValue = 0; /* Used to hold value to pass to sprintf, if * it's a one-word value. */ unsigned char *dst = interp->result; /* Where result is stored. Starts off at * interp->resultSpace, but may get dynamically * re-allocated if this isn't enough. */ int dstSize = 0; /* Number of non-null characters currently * stored at dst. */ int dstSpace = TCL_RESULT_SIZE; /* Total amount of storage space available * in dst (not including null terminator. */ int noPercent; /* Special case for speed: indicates there's * no field specifier, just a string to copy. */ unsigned char **curArg; /* Remainder of argv array. */ int useShort; /* Value to be printed is short (half word). */ /* * This procedure is a bit nasty. The goal is to use sprintf to * do most of the dirty work. There are several problems: * 1. this procedure can't trust its arguments. * 2. we must be able to provide a large enough result area to hold * whatever's generated. This is hard to estimate. * 2. there's no way to move the arguments from argv to the call * to sprintf in a reasonable way. This is particularly nasty * because some of the arguments may be two-word values (doubles). * So, what happens here is to scan the format string one % group * at a time, making many individual calls to sprintf. */ if (argc < 2) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " formatString ?arg arg ...?\"", 0); return TCL_ERROR; } curArg = argv+2; argc -= 2; for (format = argv[1]; *format != 0; ) { register unsigned char *newPtr = newFormat; width = precision = noPercent = useShort = 0; /* * Get rid of any characters before the next field specifier. * Collapse backslash sequences found along the way. */ if (*format != '%') { register unsigned char *p; int bsSize; oneWordValue = p = format; while ((*format != '%') && (*format != 0)) { if (*format == '\\') { *p = Tcl_Backslash(format, &bsSize); if (*p != 0) { p++; } format += bsSize; } else { *p = *format; p++; format++; } } size = p - oneWordValue; noPercent = 1; goto doField; } if (format[1] == '%') { oneWordValue = format; size = 1; noPercent = 1; format += 2; goto doField; } /* * Parse off a field specifier, compute how many characters * will be needed to store the result, and substitute for * "*" size specifiers. */ *newPtr = '%'; newPtr++; format++; while ((*format == '-') || (*format == '#') || (*format == '0') || (*format == ' ') || (*format == '+')) { *newPtr = *format; newPtr++; format++; } if (isdigit(*format)) { width = atoi(format); do { format++; } while (isdigit(*format)); } else if (*format == '*') { if (argc <= 0) { goto notEnoughArgs; } if (Tcl_GetInt(interp, *curArg, &width) != TCL_OK) { goto fmtError; } argc--; curArg++; format++; } if (width != 0) { sprintf(newPtr, "%d", width); while (*newPtr != 0) { newPtr++; } } if (*format == '.') { *newPtr = '.'; newPtr++; format++; } if (isdigit(*format)) { precision = atoi(format); do { format++; } while (isdigit(*format)); } else if (*format == '*') { if (argc <= 0) { goto notEnoughArgs; } if (Tcl_GetInt(interp, *curArg, &precision) != TCL_OK) { goto fmtError; } argc--; curArg++; format++; } if (precision != 0) { sprintf(newPtr, "%d", precision); while (*newPtr != 0) { newPtr++; } } if (*format == 'l') { format++; } else if (*format == 'h') { useShort = 1; *newPtr = 'h'; newPtr++; format++; } *newPtr = *format; newPtr++; *newPtr = 0; if (argc <= 0) { goto notEnoughArgs; } switch (*format) { case 'D': case 'O': case 'U': if (!useShort) { newPtr++; } else { useShort = 0; } newPtr[-1] = tolower(*format); newPtr[-2] = 'l'; *newPtr = 0; case 'd': case 'o': case 'u': case 'x': case 'X': if (Tcl_GetInt(interp, *curArg, (void*) &oneWordValue) != TCL_OK) { goto fmtError; } size = 40; break; case 's': oneWordValue = *curArg; size = strlen(*curArg); break; case 'c': if (Tcl_GetInt(interp, *curArg, (void*) &oneWordValue) != TCL_OK) { goto fmtError; } size = 1; break; case 0: interp->result = (unsigned char*) "format string ended in middle of field specifier"; goto fmtError; default: sprintf(interp->result, "bad field specifier \"%c\"", *format); goto fmtError; } argc--; curArg++; format++; /* * Make sure that there's enough space to hold the formatted * result, then format it. */ doField: if (width > size) { size = width; } if ((dstSize + size) > dstSpace) { unsigned char *newDst; int newSpace; newSpace = 2*(dstSize + size); newDst = malloc ((unsigned) newSpace+1); if (dstSize != 0) { memcpy ((void*) newDst, (void*) dst, dstSize); } if (dstSpace != TCL_RESULT_SIZE) { free (dst); } dst = newDst; dstSpace = newSpace; } if (noPercent) { memcpy ((void*) (dst+dstSize), (void*) oneWordValue, size); dstSize += size; dst[dstSize] = 0; } else { if (useShort) { /* * The double cast below is needed for a few machines * (e.g. Pyramids as of 1/93) that don't like casts * directly from pointers to shorts. */ sprintf(dst+dstSize, (char*) newFormat, (short) (int) oneWordValue); } else { sprintf(dst+dstSize, (char*) newFormat, oneWordValue); } dstSize += strlen(dst+dstSize); } } interp->result = dst; if (dstSpace != TCL_RESULT_SIZE) { interp->freeProc = (Tcl_FreeProc *) free; } else { interp->freeProc = 0; } return TCL_OK; notEnoughArgs: interp->result = (unsigned char*) "not enough arguments for all format specifiers"; fmtError: if (dstSpace != TCL_RESULT_SIZE) { free(dst); } return TCL_ERROR; } ================================================ FILE: lib/libtcl/tclcmdil.c ================================================ /* * tclCmdIL.c -- * * This file contains the top-level command routines for most of * the Tcl built-in commands whose names begin with the letters * I through L. It contains only commands in the generic core * (i.e. those that don't depend much upon UNIX facilities). * * Copyright 1987-1991 Regents of the University of California * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without * fee is hereby granted, provided that the above copyright * notice appear in all copies. The University of California * makes no representations about the suitability of this * software for any purpose. It is provided "as is" without * express or implied warranty. */ #include "internal.h" /* * Forward declarations for procedures defined in this file: */ static int SortCompareProc (const void *first, const void *second); /* *---------------------------------------------------------------------- * * Tcl_IfCmd -- * * This procedure is invoked to process the "if" Tcl command. * See the user documentation for details on what it does. * * Results: * A standard Tcl result. * * Side effects: * See the user documentation. * *---------------------------------------------------------------------- */ /* ARGSUSED */ int Tcl_IfCmd(dummy, interp, argc, argv) void *dummy; /* Not used. */ Tcl_Interp *interp; /* Current interpreter. */ int argc; /* Number of arguments. */ unsigned char **argv; /* Argument strings. */ { int i, result, value; i = 1; while (1) { /* * At this point in the loop, argv and argc refer to an expression * to test, either for the main expression or an expression * following an "elseif". The arguments after the expression must * be "then" (optional) and a script to execute if the expression is * true. */ if (i >= argc) { Tcl_AppendResult(interp, "wrong # args: no expression after \"", argv[i-1], "\" argument", 0); return TCL_ERROR; } result = Tcl_ExprBoolean(interp, argv[i], &value); if (result != TCL_OK) { return result; } i++; if ((i < argc) && (strcmp(argv[i], (unsigned char*) "then") == 0)) { i++; } if (i >= argc) { Tcl_AppendResult(interp, "wrong # args: no script following \"", argv[i-1], "\" argument", 0); return TCL_ERROR; } if (value) { return Tcl_Eval(interp, argv[i], 0, 0); } /* * The expression evaluated to false. Skip the command, then * see if there is an "else" or "elseif" clause. */ i++; if (i >= argc) { return TCL_OK; } if ((argv[i][0] == 'e') && (strcmp(argv[i], (unsigned char*) "elseif") == 0)) { i++; continue; } break; } /* * Couldn't find a "then" or "elseif" clause to execute. Check now * for an "else" clause. We know that there's at least one more * argument when we get here. */ if (strcmp(argv[i], (unsigned char*) "else") == 0) { i++; if (i >= argc) { Tcl_AppendResult(interp, "wrong # args: no script following \"else\" argument", 0); return TCL_ERROR; } } return Tcl_Eval(interp, argv[i], 0, 0); } /* *---------------------------------------------------------------------- * * Tcl_IncrCmd -- * * This procedure is invoked to process the "incr" Tcl command. * See the user documentation for details on what it does. * * Results: * A standard Tcl result. * * Side effects: * See the user documentation. * *---------------------------------------------------------------------- */ /* ARGSUSED */ int Tcl_IncrCmd(dummy, interp, argc, argv) void *dummy; /* Not used. */ Tcl_Interp *interp; /* Current interpreter. */ int argc; /* Number of arguments. */ unsigned char **argv; /* Argument strings. */ { int value; unsigned char *oldString, *result; unsigned char newString[30]; if ((argc != 2) && (argc != 3)) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " varName ?increment?\"", 0); return TCL_ERROR; } oldString = Tcl_GetVar(interp, argv[1], TCL_LEAVE_ERR_MSG); if (oldString == 0) { return TCL_ERROR; } if (Tcl_GetInt(interp, oldString, &value) != TCL_OK) { Tcl_AddErrorInfo(interp, (unsigned char*) "\n (reading value of variable to increment)"); return TCL_ERROR; } if (argc == 2) { value += 1; } else { int increment; if (Tcl_GetInt(interp, argv[2], &increment) != TCL_OK) { Tcl_AddErrorInfo(interp, (unsigned char*) "\n (reading increment)"); return TCL_ERROR; } value += increment; } sprintf(newString, "%d", value); result = Tcl_SetVar(interp, argv[1], newString, TCL_LEAVE_ERR_MSG); if (result == 0) { return TCL_ERROR; } interp->result = result; return TCL_OK; } /* *---------------------------------------------------------------------- * * Tcl_InfoCmd -- * * This procedure is invoked to process the "info" Tcl command. * See the user documentation for details on what it does. * * Results: * A standard Tcl result. * * Side effects: * See the user documentation. * *---------------------------------------------------------------------- */ /* ARGSUSED */ int Tcl_InfoCmd(dummy, interp, argc, argv) void *dummy; /* Not used. */ Tcl_Interp *interp; /* Current interpreter. */ int argc; /* Number of arguments. */ unsigned char **argv; /* Argument strings. */ { register Interp *iPtr = (Interp *) interp; int length; char c; Arg *argPtr; Proc *procPtr; Var *varPtr; Command *cmdPtr; Tcl_HashEntry *hPtr; Tcl_HashSearch search; if (argc < 2) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " option ?arg arg ...?\"", 0); return TCL_ERROR; } c = argv[1][0]; length = strlen(argv[1]); if ((c == 'a') && (strncmp(argv[1], (unsigned char*) "args", length)) == 0) { if (argc != 3) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " args procname\"", 0); return TCL_ERROR; } procPtr = TclFindProc(iPtr, argv[2]); if (procPtr == 0) { infoNoSuchProc: Tcl_AppendResult(interp, "\"", argv[2], "\" isn't a procedure", 0); return TCL_ERROR; } for (argPtr = procPtr->argPtr; argPtr != 0; argPtr = argPtr->nextPtr) { Tcl_AppendElement(interp, argPtr->name, 0); } return TCL_OK; } else if ((c == 'b') && (strncmp(argv[1], (unsigned char*) "body", length)) == 0) { if (argc != 3) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " body procname\"", 0); return TCL_ERROR; } procPtr = TclFindProc(iPtr, argv[2]); if (procPtr == 0) { goto infoNoSuchProc; } iPtr->result = procPtr->command; return TCL_OK; } else if ((c == 'c') && (strncmp(argv[1], (unsigned char*) "cmdcount", length) == 0) && (length >= 2)) { if (argc != 2) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " cmdcount\"", 0); return TCL_ERROR; } sprintf(iPtr->result, "%ld", iPtr->cmdCount); return TCL_OK; } else if ((c == 'c') && (strncmp(argv[1], (unsigned char*) "commands", length) == 0) && (length >= 4)) { if (argc > 3) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " commands [pattern]\"", 0); return TCL_ERROR; } for (hPtr = Tcl_FirstHashEntry(&iPtr->commandTable, &search); hPtr != 0; hPtr = Tcl_NextHashEntry(&search)) { unsigned char *name = Tcl_GetHashKey(&iPtr->commandTable, hPtr); if ((argc == 3) && !Tcl_StringMatch(name, argv[2])) { continue; } Tcl_AppendElement(interp, name, 0); } return TCL_OK; } else if ((c == 'c') && (strncmp(argv[1], (unsigned char*) "complete", length) == 0) && (length >= 4)) { if (argc != 3) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " complete command\"", 0); return TCL_ERROR; } if (Tcl_CommandComplete(argv[2])) { interp->result = (unsigned char*) "1"; } else { interp->result = (unsigned char*) "0"; } return TCL_OK; } else if ((c == 'd') && (strncmp(argv[1], (unsigned char*) "default", length)) == 0) { if (argc != 5) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " default procname arg varname\"", 0); return TCL_ERROR; } procPtr = TclFindProc(iPtr, argv[2]); if (procPtr == 0) { goto infoNoSuchProc; } for (argPtr = procPtr->argPtr; ; argPtr = argPtr->nextPtr) { if (argPtr == 0) { Tcl_AppendResult(interp, "procedure \"", argv[2], "\" doesn't have an argument \"", argv[3], "\"", 0); return TCL_ERROR; } if (strcmp(argv[3], argPtr->name) == 0) { if (argPtr->defValue != 0) { if (Tcl_SetVar((Tcl_Interp *) iPtr, argv[4], argPtr->defValue, 0) == 0) { defStoreError: Tcl_AppendResult(interp, "couldn't store default value in variable \"", argv[4], "\"", 0); return TCL_ERROR; } iPtr->result = (unsigned char*) "1"; } else { if (Tcl_SetVar((Tcl_Interp *) iPtr, argv[4], (unsigned char*) "", 0) == 0) { goto defStoreError; } iPtr->result = (unsigned char*) "0"; } return TCL_OK; } } } else if ((c == 'e') && (strncmp(argv[1], (unsigned char*) "exists", length) == 0)) { unsigned char *p; if (argc != 3) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " exists varName\"", 0); return TCL_ERROR; } p = Tcl_GetVar((Tcl_Interp *) iPtr, argv[2], 0); /* * The code below handles the special case where the name is for * an array: Tcl_GetVar will reject this since you can't read * an array variable without an index. */ if (p == 0) { Tcl_HashEntry *hPtr; Var *varPtr; if (strchr(argv[2], '(') != 0) { noVar: iPtr->result = (unsigned char*) "0"; return TCL_OK; } if (iPtr->varFramePtr == 0) { hPtr = Tcl_FindHashEntry(&iPtr->globalTable, argv[2]); } else { hPtr = Tcl_FindHashEntry(&iPtr->varFramePtr->varTable, argv[2]); } if (hPtr == 0) { goto noVar; } varPtr = (Var *) Tcl_GetHashValue(hPtr); if (varPtr->flags & VAR_UPVAR) { varPtr = (Var *) Tcl_GetHashValue(varPtr->value.upvarPtr); } if (!(varPtr->flags & VAR_ARRAY)) { goto noVar; } } iPtr->result = (unsigned char*) "1"; return TCL_OK; } else if ((c == 'g') && (strncmp(argv[1], (unsigned char*) "globals", length) == 0)) { unsigned char *name; if (argc > 3) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " globals [pattern]\"", 0); return TCL_ERROR; } for (hPtr = Tcl_FirstHashEntry(&iPtr->globalTable, &search); hPtr != 0; hPtr = Tcl_NextHashEntry(&search)) { varPtr = (Var *) Tcl_GetHashValue(hPtr); if (varPtr->flags & VAR_UNDEFINED) { continue; } name = Tcl_GetHashKey(&iPtr->globalTable, hPtr); if ((argc == 3) && !Tcl_StringMatch(name, argv[2])) { continue; } Tcl_AppendElement(interp, name, 0); } return TCL_OK; } else if ((c == 'l') && (strncmp(argv[1], (unsigned char*) "level", length) == 0) && (length >= 2)) { if (argc == 2) { if (iPtr->varFramePtr == 0) { iPtr->result = (unsigned char*) "0"; } else { sprintf(iPtr->result, "%d", iPtr->varFramePtr->level); } return TCL_OK; } else if (argc == 3) { int level; CallFrame *framePtr; if (Tcl_GetInt(interp, argv[2], &level) != TCL_OK) { return TCL_ERROR; } if (level <= 0) { if (iPtr->varFramePtr == 0) { levelError: Tcl_AppendResult(interp, "bad level \"", argv[2], "\"", 0); return TCL_ERROR; } level += iPtr->varFramePtr->level; } for (framePtr = iPtr->varFramePtr; framePtr != 0; framePtr = framePtr->callerVarPtr) { if (framePtr->level == level) { break; } } if (framePtr == 0) { goto levelError; } iPtr->result = Tcl_Merge (framePtr->argc, framePtr->argv); iPtr->freeProc = (Tcl_FreeProc *) free; return TCL_OK; } Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " level [number]\"", 0); return TCL_ERROR; #ifdef TCL_FILE_CMDS } else if ((c == 'l') && (strncmp(argv[1], "library", length) == 0) && (length >= 2)) { if (argc != 2) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " library\"", 0); return TCL_ERROR; } interp->result = getenv("TCL_LIBRARY"); if (interp->result == 0) { #ifdef TCL_LIBRARY interp->result = TCL_LIBRARY; #else interp->result = "there is no Tcl library at this installation"; return TCL_ERROR; #endif } return TCL_OK; #endif } else if ((c == 'l') && (strncmp(argv[1], (unsigned char*) "locals", length) == 0) && (length >= 2)) { unsigned char *name; if (argc > 3) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " locals [pattern]\"", 0); return TCL_ERROR; } if (iPtr->varFramePtr == 0) { return TCL_OK; } for (hPtr = Tcl_FirstHashEntry(&iPtr->varFramePtr->varTable, &search); hPtr != 0; hPtr = Tcl_NextHashEntry(&search)) { varPtr = (Var *) Tcl_GetHashValue(hPtr); if (varPtr->flags & (VAR_UNDEFINED|VAR_UPVAR)) { continue; } name = Tcl_GetHashKey(&iPtr->varFramePtr->varTable, hPtr); if ((argc == 3) && !Tcl_StringMatch(name, argv[2])) { continue; } Tcl_AppendElement(interp, name, 0); } return TCL_OK; } else if ((c == 'p') && (strncmp(argv[1], (unsigned char*) "procs", length)) == 0) { if (argc > 3) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " procs [pattern]\"", 0); return TCL_ERROR; } for (hPtr = Tcl_FirstHashEntry(&iPtr->commandTable, &search); hPtr != 0; hPtr = Tcl_NextHashEntry(&search)) { unsigned char *name = Tcl_GetHashKey(&iPtr->commandTable, hPtr); cmdPtr = (Command *) Tcl_GetHashValue(hPtr); if (!TclIsProc(cmdPtr)) { continue; } if ((argc == 3) && !Tcl_StringMatch(name, argv[2])) { continue; } Tcl_AppendElement(interp, name, 0); } return TCL_OK; } else if ((c == 's') && (strncmp(argv[1], (unsigned char*) "script", length) == 0)) { if (argc != 2) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " script\"", 0); return TCL_ERROR; } if (iPtr->scriptFile != 0) { interp->result = iPtr->scriptFile; } return TCL_OK; } else if ((c == 't') && (strncmp(argv[1], (unsigned char*) "tclversion", length) == 0)) { if (argc != 2) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " tclversion\"", 0); return TCL_ERROR; } /* * Note: TCL_VERSION below is expected to be set with a "-D" * switch in the Makefile. */ strcpy(iPtr->result, (unsigned char*) TCL_VERSION); return TCL_OK; } else if ((c == 'v') && (strncmp(argv[1], (unsigned char*) "vars", length)) == 0) { Tcl_HashTable *tablePtr; unsigned char *name; if (argc > 3) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " vars [pattern]\"", 0); return TCL_ERROR; } if (iPtr->varFramePtr == 0) { tablePtr = &iPtr->globalTable; } else { tablePtr = &iPtr->varFramePtr->varTable; } for (hPtr = Tcl_FirstHashEntry(tablePtr, &search); hPtr != 0; hPtr = Tcl_NextHashEntry(&search)) { varPtr = (Var *) Tcl_GetHashValue(hPtr); if (varPtr->flags & VAR_UNDEFINED) { continue; } name = Tcl_GetHashKey(tablePtr, hPtr); if ((argc == 3) && !Tcl_StringMatch(name, argv[2])) { continue; } Tcl_AppendElement(interp, name, 0); } return TCL_OK; } else { Tcl_AppendResult(interp, "bad option \"", argv[1], "\": should be args, body, cmdcount, commands, ", "complete, default, ", "exists, globals, level, library, locals, procs, ", "script, tclversion, or vars", 0); return TCL_ERROR; } } /* *---------------------------------------------------------------------- * * Tcl_JoinCmd -- * * This procedure is invoked to process the "join" Tcl command. * See the user documentation for details on what it does. * * Results: * A standard Tcl result. * * Side effects: * See the user documentation. * *---------------------------------------------------------------------- */ /* ARGSUSED */ int Tcl_JoinCmd(dummy, interp, argc, argv) void *dummy; /* Not used. */ Tcl_Interp *interp; /* Current interpreter. */ int argc; /* Number of arguments. */ unsigned char **argv; /* Argument strings. */ { unsigned char *joinString; unsigned char **listArgv; int listArgc, i; if (argc == 2) { joinString = (unsigned char*) " "; } else if (argc == 3) { joinString = argv[2]; } else { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " list ?joinString?\"", 0); return TCL_ERROR; } if (Tcl_SplitList(interp, argv[1], &listArgc, &listArgv) != TCL_OK) { return TCL_ERROR; } for (i = 0; i < listArgc; i++) { if (i == 0) { Tcl_AppendResult(interp, listArgv[0], 0); } else { Tcl_AppendResult(interp, joinString, listArgv[i], 0); } } free (listArgv); return TCL_OK; } /* *---------------------------------------------------------------------- * * Tcl_LindexCmd -- * * This procedure is invoked to process the "lindex" Tcl command. * See the user documentation for details on what it does. * * Results: * A standard Tcl result. * * Side effects: * See the user documentation. * *---------------------------------------------------------------------- */ /* ARGSUSED */ int Tcl_LindexCmd(dummy, interp, argc, argv) void *dummy; /* Not used. */ Tcl_Interp *interp; /* Current interpreter. */ int argc; /* Number of arguments. */ unsigned char **argv; /* Argument strings. */ { unsigned char *p, *element; int index, size, parenthesized, result; if (argc != 3) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " list index\"", 0); return TCL_ERROR; } if (Tcl_GetInt(interp, argv[2], &index) != TCL_OK) { return TCL_ERROR; } if (index < 0) { return TCL_OK; } for (p = argv[1] ; index >= 0; index--) { result = TclFindElement(interp, p, &element, &p, &size, &parenthesized); if (result != TCL_OK) { return result; } } if (size == 0) { return TCL_OK; } if (size >= TCL_RESULT_SIZE) { interp->result = malloc ((unsigned) size + 1); interp->freeProc = (Tcl_FreeProc *) free; } if (parenthesized) { memcpy((void *) interp->result, (void *) element, size); interp->result[size] = 0; } else { TclCopyAndCollapse(size, element, interp->result); } return TCL_OK; } /* *---------------------------------------------------------------------- * * Tcl_LinsertCmd -- * * This procedure is invoked to process the "linsert" Tcl command. * See the user documentation for details on what it does. * * Results: * A standard Tcl result. * * Side effects: * See the user documentation. * *---------------------------------------------------------------------- */ /* ARGSUSED */ int Tcl_LinsertCmd(dummy, interp, argc, argv) void *dummy; /* Not used. */ Tcl_Interp *interp; /* Current interpreter. */ int argc; /* Number of arguments. */ unsigned char **argv; /* Argument strings. */ { unsigned char *p, *element, savedChar; int i, index, count, result, size; if (argc < 4) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " list index element ?element ...?\"", 0); return TCL_ERROR; } if (Tcl_GetInt(interp, argv[2], &index) != TCL_OK) { return TCL_ERROR; } /* * Skip over the first "index" elements of the list, then add * all of those elements to the result. */ size = 0; element = argv[1]; for (count = 0, p = argv[1]; (count < index) && (*p != 0); count++) { result = TclFindElement(interp, p, &element, &p, &size, (int *) 0); if (result != TCL_OK) { return result; } } if (*p == 0) { Tcl_AppendResult(interp, argv[1], 0); } else { unsigned char *end; end = element+size; if (element != argv[1]) { while ((*end != 0) && !isspace(*end)) { end++; } } savedChar = *end; *end = 0; Tcl_AppendResult(interp, argv[1], 0); *end = savedChar; } /* * Add the new list elements. */ for (i = 3; i < argc; i++) { Tcl_AppendElement(interp, argv[i], 0); } /* * Append the remainder of the original list. */ if (*p != 0) { Tcl_AppendResult(interp, " ", p, 0); } return TCL_OK; } /* *---------------------------------------------------------------------- * * Tcl_ListCmd -- * * This procedure is invoked to process the "list" Tcl command. * See the user documentation for details on what it does. * * Results: * A standard Tcl result. * * Side effects: * See the user documentation. * *---------------------------------------------------------------------- */ /* ARGSUSED */ int Tcl_ListCmd(dummy, interp, argc, argv) void *dummy; /* Not used. */ Tcl_Interp *interp; /* Current interpreter. */ int argc; /* Number of arguments. */ unsigned char **argv; /* Argument strings. */ { if (argc < 2) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " arg ?arg ...?\"", 0); return TCL_ERROR; } interp->result = Tcl_Merge (argc-1, argv+1); interp->freeProc = (Tcl_FreeProc *) free; return TCL_OK; } /* *---------------------------------------------------------------------- * * Tcl_LlengthCmd -- * * This procedure is invoked to process the "llength" Tcl command. * See the user documentation for details on what it does. * * Results: * A standard Tcl result. * * Side effects: * See the user documentation. * *---------------------------------------------------------------------- */ /* ARGSUSED */ int Tcl_LlengthCmd(dummy, interp, argc, argv) void *dummy; /* Not used. */ Tcl_Interp *interp; /* Current interpreter. */ int argc; /* Number of arguments. */ unsigned char **argv; /* Argument strings. */ { int count, result; unsigned char *element, *p; if (argc != 2) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " list\"", 0); return TCL_ERROR; } for (count = 0, p = argv[1]; *p != 0 ; count++) { result = TclFindElement(interp, p, &element, &p, (int *) 0, (int *) 0); if (result != TCL_OK) { return result; } if (*element == 0) { break; } } sprintf(interp->result, "%d", count); return TCL_OK; } /* *---------------------------------------------------------------------- * * Tcl_LrangeCmd -- * * This procedure is invoked to process the "lrange" Tcl command. * See the user documentation for details on what it does. * * Results: * A standard Tcl result. * * Side effects: * See the user documentation. * *---------------------------------------------------------------------- */ /* ARGSUSED */ int Tcl_LrangeCmd(notUsed, interp, argc, argv) void *notUsed; /* Not used. */ Tcl_Interp *interp; /* Current interpreter. */ int argc; /* Number of arguments. */ unsigned char **argv; /* Argument strings. */ { int first, last, result; unsigned char *begin, *end, c, *dummy; int count; if (argc != 4) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " list first last\"", 0); return TCL_ERROR; } if (Tcl_GetInt(interp, argv[2], &first) != TCL_OK) { return TCL_ERROR; } if (first < 0) { first = 0; } if ((*argv[3] == 'e') && (strncmp(argv[3], (unsigned char*) "end", strlen(argv[3])) == 0)) { last = 30000; } else { if (Tcl_GetInt(interp, argv[3], &last) != TCL_OK) { Tcl_ResetResult(interp); Tcl_AppendResult(interp, "expected integer or \"end\" but got \"", argv[3], "\"", 0); return TCL_ERROR; } } if (first > last) { return TCL_OK; } /* * Extract a range of fields. */ for (count = 0, begin = argv[1]; count < first; count++) { result = TclFindElement(interp, begin, &dummy, &begin, (int *) 0, (int *) 0); if (result != TCL_OK) { return result; } if (*begin == 0) { break; } } for (count = first, end = begin; (count <= last) && (*end != 0); count++) { result = TclFindElement(interp, end, &dummy, &end, (int *) 0, (int *) 0); if (result != TCL_OK) { return result; } } /* * Chop off trailing spaces. */ while (isspace(end[-1])) { end--; } c = *end; *end = 0; Tcl_SetResult(interp, begin, TCL_VOLATILE); *end = c; return TCL_OK; } /* *---------------------------------------------------------------------- * * Tcl_LreplaceCmd -- * * This procedure is invoked to process the "lreplace" Tcl command. * See the user documentation for details on what it does. * * Results: * A standard Tcl result. * * Side effects: * See the user documentation. * *---------------------------------------------------------------------- */ /* ARGSUSED */ int Tcl_LreplaceCmd(notUsed, interp, argc, argv) void *notUsed; /* Not used. */ Tcl_Interp *interp; /* Current interpreter. */ int argc; /* Number of arguments. */ unsigned char **argv; /* Argument strings. */ { unsigned char *p1, *p2, *element, savedChar, *dummy; int i, first, last, count, result, size; if (argc < 4) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " list first last ?element element ...?\"", 0); return TCL_ERROR; } if (Tcl_GetInt(interp, argv[2], &first) != TCL_OK) { return TCL_ERROR; } if (TclGetListIndex(interp, argv[3], &last) != TCL_OK) { return TCL_ERROR; } if (first < 0) { first = 0; } if (last < 0) { last = 0; } if (first > last) { Tcl_AppendResult(interp, "first index must not be greater than second", 0); return TCL_ERROR; } /* * Skip over the elements of the list before "first". */ size = 0; element = argv[1]; for (count = 0, p1 = argv[1]; (count < first) && (*p1 != 0); count++) { result = TclFindElement(interp, p1, &element, &p1, &size, (int *) 0); if (result != TCL_OK) { return result; } } if (*p1 == 0) { Tcl_AppendResult(interp, "list doesn't contain element ", argv[2], 0); return TCL_ERROR; } /* * Skip over the elements of the list up through "last". */ for (p2 = p1 ; (count <= last) && (*p2 != 0); count++) { result = TclFindElement(interp, p2, &dummy, &p2, (int *) 0, (int *) 0); if (result != TCL_OK) { return result; } } /* * Add the elements before "first" to the result. Be sure to * include quote or brace characters that might terminate the * last of these elements. */ p1 = element+size; if (element != argv[1]) { while ((*p1 != 0) && !isspace(*p1)) { p1++; } } savedChar = *p1; *p1 = 0; Tcl_AppendResult(interp, argv[1], 0); *p1 = savedChar; /* * Add the new list elements. */ for (i = 4; i < argc; i++) { Tcl_AppendElement(interp, argv[i], 0); } /* * Append the remainder of the original list. */ if (*p2 != 0) { if (*interp->result == 0) { Tcl_SetResult(interp, p2, TCL_VOLATILE); } else { Tcl_AppendResult(interp, " ", p2, 0); } } return TCL_OK; } /* *---------------------------------------------------------------------- * * Tcl_LsearchCmd -- * * This procedure is invoked to process the "lsearch" Tcl command. * See the user documentation for details on what it does. * * Results: * A standard Tcl result. * * Side effects: * See the user documentation. * *---------------------------------------------------------------------- */ /* ARGSUSED */ int Tcl_LsearchCmd(notUsed, interp, argc, argv) void *notUsed; /* Not used. */ Tcl_Interp *interp; /* Current interpreter. */ int argc; /* Number of arguments. */ unsigned char **argv; /* Argument strings. */ { int listArgc; unsigned char **listArgv; int i, match; if (argc != 3) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " list pattern\"", 0); return TCL_ERROR; } if (Tcl_SplitList(interp, argv[1], &listArgc, &listArgv) != TCL_OK) { return TCL_ERROR; } match = -1; for (i = 0; i < listArgc; i++) { if (Tcl_StringMatch(listArgv[i], argv[2])) { match = i; break; } } sprintf (interp->result, "%d", match); free (listArgv); return TCL_OK; } /* *---------------------------------------------------------------------- * * Tcl_LsortCmd -- * * This procedure is invoked to process the "lsort" Tcl command. * See the user documentation for details on what it does. * * Results: * A standard Tcl result. * * Side effects: * See the user documentation. * *---------------------------------------------------------------------- */ /* ARGSUSED */ int Tcl_LsortCmd(notUsed, interp, argc, argv) void *notUsed; /* Not used. */ Tcl_Interp *interp; /* Current interpreter. */ int argc; /* Number of arguments. */ unsigned char **argv; /* Argument strings. */ { int listArgc; unsigned char **listArgv; if (argc != 2) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " list\"", 0); return TCL_ERROR; } if (Tcl_SplitList(interp, argv[1], &listArgc, &listArgv) != TCL_OK) { return TCL_ERROR; } qsort((void *) listArgv, listArgc, sizeof (char*), SortCompareProc); interp->result = Tcl_Merge (listArgc, listArgv); interp->freeProc = (Tcl_FreeProc *) free; free (listArgv); return TCL_OK; } /* * The procedure below is called back by qsort to determine * the proper ordering between two elements. */ static int SortCompareProc(first, second) const void *first, *second; /* Elements to be compared. */ { return strcmp(*((unsigned char **) first), *((unsigned char **) second)); } ================================================ FILE: lib/libtcl/tclcmdmz.c ================================================ /* * tclCmdMZ.c -- * * This file contains the top-level command routines for most of * the Tcl built-in commands whose names begin with the letters * M to Z. It contains only commands in the generic core (i.e. * those that don't depend much upon UNIX facilities). * * Copyright 1987-1991 Regents of the University of California * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without * fee is hereby granted, provided that the above copyright * notice appear in all copies. The University of California * makes no representations about the suitability of this * software for any purpose. It is provided "as is" without * express or implied warranty. */ #include "internal.h" #include "regexp.h" #include "regpriv.h" /* * Structure used to hold information about variable traces: */ typedef struct { int flags; /* Operations for which Tcl command is * to be invoked. */ int length; /* Number of non-NULL chars. in command. */ unsigned char command[4]; /* Space for Tcl command to invoke. Actual * size will be as large as necessary to * hold command. This field must be the * last in the structure, so that it can * be larger than 4 bytes. */ } TraceVarInfo; /* * Forward declarations for procedures defined in this file: */ static unsigned char * TraceVarProc (void *clientData, Tcl_Interp *interp, unsigned char *name1, unsigned char *name2, int flags); /* *---------------------------------------------------------------------- * * Tcl_RegexpCmd -- * * This procedure is invoked to process the "regexp" Tcl command. * See the user documentation for details on what it does. * * Results: * A standard Tcl result. * * Side effects: * See the user documentation. * *---------------------------------------------------------------------- */ /* ARGSUSED */ int Tcl_RegexpCmd(dummy, interp, argc, argv) void *dummy; /* Not used. */ Tcl_Interp *interp; /* Current interpreter. */ int argc; /* Number of arguments. */ unsigned char **argv; /* Argument strings. */ { int noCase = 0; int indices = 0; regexp_t *regexpPtr; unsigned char **argPtr, *string; int match, i; if (argc < 3) { wrongNumArgs: Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " ?-nocase? exp string ?matchVar? ?subMatchVar ", "subMatchVar ...?\"", 0); return TCL_ERROR; } argPtr = argv+1; argc--; while ((argc > 0) && (argPtr[0][0] == '-')) { if (strcmp(argPtr[0], (unsigned char*) "-indices") == 0) { argPtr++; argc--; indices = 1; } else if (strcmp(argPtr[0], (unsigned char*) "-nocase") == 0) { argPtr++; argc--; noCase = 1; } else { break; } } if (argc < 2) { goto wrongNumArgs; } regexpPtr = TclCompileRegexp(interp, argPtr[0]); if (regexpPtr == 0) { return TCL_ERROR; } /* * Convert the string to lower case, if desired, and perform * the match. */ if (noCase) { register unsigned char *dst, *src; string = malloc (strlen(argPtr[1]) + 1); for (src = argPtr[1], dst = string; *src != 0; src++, dst++) { if (isupper(*src)) { *dst = tolower(*src); } else { *dst = *src; } } *dst = 0; } else { string = argPtr[1]; } match = regexp_execute (regexpPtr, string); if (string != argPtr[1]) { free(string); } if (match) { interp->result = (unsigned char*) "0"; return TCL_OK; } /* * If additional variable names have been specified, return * index information in those variables. */ argc -= 2; if (argc > 10) { interp->result = (unsigned char*) "too many substring variables"; return TCL_ERROR; } for (i = 0; i < argc; i++) { unsigned char *result, info[50]; if (regexpPtr->startp[i] == 0) { if (indices) { result = Tcl_SetVar(interp, argPtr[i+2], (unsigned char*) "-1 -1", 0); } else { result = Tcl_SetVar(interp, argPtr[i+2], (unsigned char*) "", 0); } } else { if (indices) { sprintf(info, "%d %d", (int) (regexpPtr->startp[i] - string), (int) (regexpPtr->endp[i] - string - 1)); result = Tcl_SetVar(interp, argPtr[i+2], info, 0); } else { unsigned char savedChar, *first, *last; first = argPtr[1] + (regexpPtr->startp[i] - string); last = argPtr[1] + (regexpPtr->endp[i] - string); savedChar = *last; *last = 0; result = Tcl_SetVar(interp, argPtr[i+2], first, 0); *last = savedChar; } } if (result == 0) { Tcl_AppendResult(interp, "couldn't set variable \"", argPtr[i+2], "\"", 0); return TCL_ERROR; } } interp->result = (unsigned char*) "1"; return TCL_OK; } /* *---------------------------------------------------------------------- * * Tcl_RegsubCmd -- * * This procedure is invoked to process the "regsub" Tcl command. * See the user documentation for details on what it does. * * Results: * A standard Tcl result. * * Side effects: * See the user documentation. * *---------------------------------------------------------------------- */ /* ARGSUSED */ int Tcl_RegsubCmd(dummy, interp, argc, argv) void *dummy; /* Not used. */ Tcl_Interp *interp; /* Current interpreter. */ int argc; /* Number of arguments. */ unsigned char **argv; /* Argument strings. */ { int noCase = 0, all = 0; regexp_t *regexpPtr; unsigned char *string, *p, *firstChar, *newValue, **argPtr; int match, result, flags; register unsigned char *src, c; if (argc < 5) { wrongNumArgs: Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " ?-nocase? ?-all? exp string subSpec varName\"", 0); return TCL_ERROR; } argPtr = argv+1; argc--; while (argPtr[0][0] == '-') { if (strcmp(argPtr[0], (unsigned char*) "-nocase") == 0) { argPtr++; argc--; noCase = 1; } else if (strcmp(argPtr[0], (unsigned char*) "-all") == 0) { argPtr++; argc--; all = 1; } else { break; } } if (argc != 4) { goto wrongNumArgs; } regexpPtr = TclCompileRegexp(interp, argPtr[0]); if (regexpPtr == 0) { return TCL_ERROR; } /* * Convert the string to lower case, if desired. */ if (noCase) { register unsigned char *dst; string = malloc (strlen(argPtr[1]) + 1); for (src = argPtr[1], dst = string; *src != 0; src++, dst++) { if (isupper(*src)) { *dst = tolower(*src); } else { *dst = *src; } } *dst = 0; } else { string = argPtr[1]; } /* * The following loop is to handle multiple matches within the * same source string; each iteration handles one match and its * corresponding substitution. If "-all" hasn't been specified * then the loop body only gets executed once. */ flags = 0; for (p = string; *p != 0; ) { match = regexp_execute (regexpPtr, p); if (match) { break; } /* * Copy the portion of the source string before the match to the * result variable. */ src = argPtr[1] + (regexpPtr->startp[0] - string); c = *src; *src = 0; newValue = Tcl_SetVar(interp, argPtr[3], argPtr[1] + (p - string), flags); *src = c; flags = TCL_APPEND_VALUE; if (newValue == 0) { cantSet: Tcl_AppendResult(interp, "couldn't set variable \"", argPtr[3], "\"", 0); result = TCL_ERROR; goto done; } /* * Append the subSpec argument to the variable, making appropriate * substitutions. This code is a bit hairy because of the backslash * conventions and because the code saves up ranges of characters in * subSpec to reduce the number of calls to Tcl_SetVar. */ for (src = firstChar = argPtr[2], c = *src; c != 0; src++, c = *src) { int index; if (c == '&') { index = 0; } else if (c == '\\') { c = src[1]; if ((c >= '0') && (c <= '9')) { index = c - '0'; } else if ((c == '\\') || (c == '&')) { *src = c; src[1] = 0; newValue = Tcl_SetVar(interp, argPtr[3], firstChar, TCL_APPEND_VALUE); *src = '\\'; src[1] = c; if (newValue == 0) { goto cantSet; } firstChar = src+2; src++; continue; } else { continue; } } else { continue; } if (firstChar != src) { c = *src; *src = 0; newValue = Tcl_SetVar(interp, argPtr[3], firstChar, TCL_APPEND_VALUE); *src = c; if (newValue == 0) { goto cantSet; } } if ((index < 10) && (regexpPtr->startp[index] != 0) && (regexpPtr->endp[index] != 0)) { unsigned char *first, *last, saved; first = argPtr[1] + (regexpPtr->startp[index] - string); last = argPtr[1] + (regexpPtr->endp[index] - string); saved = *last; *last = 0; newValue = Tcl_SetVar(interp, argPtr[3], first, TCL_APPEND_VALUE); *last = saved; if (newValue == 0) { goto cantSet; } } if (*src == '\\') { src++; } firstChar = src+1; } if (firstChar != src) { if (Tcl_SetVar(interp, argPtr[3], firstChar, TCL_APPEND_VALUE) == 0) { goto cantSet; } } p = (unsigned char*) regexpPtr->endp[0]; if (!all) { break; } } /* * If there were no matches at all, then return a "0" result. */ if (p == string) { interp->result = (unsigned char*) "0"; result = TCL_OK; goto done; } /* * Copy the portion of the source string after the last match to the * result variable. */ if (*p != 0) { if (Tcl_SetVar(interp, argPtr[3], p, TCL_APPEND_VALUE) == 0) { goto cantSet; } } interp->result = (unsigned char*) "1"; result = TCL_OK; done: if (string != argPtr[1]) { free(string); } return result; } /* *---------------------------------------------------------------------- * * Tcl_RenameCmd -- * * This procedure is invoked to process the "rename" Tcl command. * See the user documentation for details on what it does. * * Results: * A standard Tcl result. * * Side effects: * See the user documentation. * *---------------------------------------------------------------------- */ /* ARGSUSED */ int Tcl_RenameCmd(dummy, interp, argc, argv) void *dummy; /* Not used. */ Tcl_Interp *interp; /* Current interpreter. */ int argc; /* Number of arguments. */ unsigned char **argv; /* Argument strings. */ { register Command *cmdPtr; Interp *iPtr = (Interp *) interp; Tcl_HashEntry *hPtr; int new; if (argc != 3) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " oldName newName\"", 0); return TCL_ERROR; } if (argv[2][0] == '\0') { if (Tcl_DeleteCommand(interp, argv[1]) != 0) { Tcl_AppendResult(interp, "can't delete \"", argv[1], "\": command doesn't exist", 0); return TCL_ERROR; } return TCL_OK; } hPtr = Tcl_FindHashEntry(&iPtr->commandTable, argv[2]); if (hPtr != 0) { Tcl_AppendResult(interp, "can't rename to \"", argv[2], "\": command already exists", 0); return TCL_ERROR; } hPtr = Tcl_FindHashEntry(&iPtr->commandTable, argv[1]); if (hPtr == 0) { Tcl_AppendResult(interp, "can't rename \"", argv[1], "\": command doesn't exist", 0); return TCL_ERROR; } cmdPtr = (Command *) Tcl_GetHashValue(hPtr); Tcl_DeleteHashEntry(hPtr); hPtr = Tcl_CreateHashEntry(&iPtr->commandTable, argv[2], &new); Tcl_SetHashValue(hPtr, cmdPtr); return TCL_OK; } /* *---------------------------------------------------------------------- * * Tcl_ReturnCmd -- * * This procedure is invoked to process the "return" Tcl command. * See the user documentation for details on what it does. * * Results: * A standard Tcl result. * * Side effects: * See the user documentation. * *---------------------------------------------------------------------- */ /* ARGSUSED */ int Tcl_ReturnCmd(dummy, interp, argc, argv) void *dummy; /* Not used. */ Tcl_Interp *interp; /* Current interpreter. */ int argc; /* Number of arguments. */ unsigned char **argv; /* Argument strings. */ { if (argc > 2) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " ?value?\"", 0); return TCL_ERROR; } if (argc == 2) { Tcl_SetResult(interp, argv[1], TCL_VOLATILE); } return TCL_RETURN; } /* * This procedure is invoked to process the "scan" Tcl command. * See the user documentation for details on what it does. * * Results: * A standard Tcl result. * * Side effects: * See the user documentation. */ /* ARGSUSED */ int Tcl_ScanCmd(dummy, interp, argc, argv) void *dummy; /* Not used. */ Tcl_Interp *interp; /* Current interpreter. */ int argc; /* Number of arguments. */ unsigned char **argv; /* Argument strings. */ { int arg1Length; /* Number of bytes in argument to be * scanned. This gives an upper limit * on string field sizes. */ # define MAX_FIELDS 20 typedef struct { unsigned char fmt; /* Format for field. */ int size; /* How many bytes to allow for * field. */ unsigned char *location; /* Where field will be stored. */ } Field; Field fields[MAX_FIELDS]; /* Info about all the fields in the * format string. */ register Field *curField; int numFields = 0; /* Number of fields actually * specified. */ int suppress; /* Current field is assignment- * suppressed. */ int totalSize = 0; /* Number of bytes needed to store * all results combined. */ unsigned char *results; /* Where scanned output goes. */ int numScanned; /* sscanf's result. */ register unsigned char *fmt; int i, widthSpecified; if (argc < 3) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " string format ?varName varName ...?\"", 0); return TCL_ERROR; } /* * This procedure operates in four stages: * 1. Scan the format string, collecting information about each field. * 2. Allocate an array to hold all of the scanned fields. * 3. Call sscanf to do all the dirty work, and have it store the * parsed fields in the array. * 4. Pick off the fields from the array and assign them to variables. */ arg1Length = (strlen(argv[1]) + 4) & ~03; for (fmt = argv[2]; *fmt != 0; fmt++) { if (*fmt != '%') { continue; } fmt++; if (*fmt == '*') { suppress = 1; fmt++; } else { suppress = 0; } widthSpecified = 0; while (isdigit(*fmt)) { widthSpecified = 1; fmt++; } if (suppress) { continue; } if (numFields == MAX_FIELDS) { interp->result = (unsigned char*) "too many fields to scan"; return TCL_ERROR; } curField = &fields[numFields]; numFields++; switch (*fmt) { case 'D': case 'O': case 'X': case 'd': case 'o': case 'x': curField->fmt = 'd'; curField->size = sizeof(int); break; case 's': curField->fmt = 's'; curField->size = arg1Length; break; case 'c': if (widthSpecified) { interp->result = (unsigned char*) "field width may not be specified in %c conversion"; return TCL_ERROR; } curField->fmt = 'c'; curField->size = sizeof(int); break; case '[': curField->fmt = 's'; curField->size = arg1Length; do { fmt++; } while (*fmt != ']'); break; default: sprintf(interp->result, "bad scan conversion character \"%c\"", *fmt); return TCL_ERROR; } totalSize += curField->size; } if (numFields != (argc-3)) { interp->result = (unsigned char*) "different numbers of variable names and field specifiers"; return TCL_ERROR; } /* * Step 2: */ results = malloc (totalSize); for (i = 0, totalSize = 0, curField = fields; i < numFields; i++, curField++) { curField->location = results + totalSize; totalSize += curField->size; } /* * Fill in the remaining fields with NULL; the only purpose of * this is to keep some memory analyzers, like Purify, from * complaining. */ for ( ; i < MAX_FIELDS; i++, curField++) { curField->location = 0; } /* * Step 3: */ numScanned = sscanf(argv[1], (char*) argv[2], fields[0].location, fields[1].location, fields[2].location, fields[3].location, fields[4].location, fields[5].location, fields[6].location, fields[7].location, fields[8].location, fields[9].location, fields[10].location, fields[11].location, fields[12].location, fields[13].location, fields[14].location, fields[15].location, fields[16].location, fields[17].location, fields[18].location, fields[19].location); /* * Step 4: */ if (numScanned < numFields) { numFields = numScanned; } for (i = 0, curField = fields; i < numFields; i++, curField++) { switch (curField->fmt) { unsigned char string[120]; case 'd': sprintf(string, "%d", *((int *) curField->location)); if (Tcl_SetVar(interp, argv[i+3], string, 0) == 0) { storeError: Tcl_AppendResult(interp, "couldn't set variable \"", argv[i+3], "\"", 0); free (results); return TCL_ERROR; } break; case 'c': sprintf(string, "%d", *curField->location & 0xff); if (Tcl_SetVar(interp, argv[i+3], string, 0) == 0) { goto storeError; } break; case 's': if (Tcl_SetVar(interp, argv[i+3], curField->location, 0) == 0) { goto storeError; } break; } } free(results); sprintf(interp->result, "%d", numScanned); return TCL_OK; } /* *---------------------------------------------------------------------- * * Tcl_SplitCmd -- * * This procedure is invoked to process the "split" Tcl command. * See the user documentation for details on what it does. * * Results: * A standard Tcl result. * * Side effects: * See the user documentation. * *---------------------------------------------------------------------- */ /* ARGSUSED */ int Tcl_SplitCmd(dummy, interp, argc, argv) void *dummy; /* Not used. */ Tcl_Interp *interp; /* Current interpreter. */ int argc; /* Number of arguments. */ unsigned char **argv; /* Argument strings. */ { unsigned char *splitChars; register unsigned char *p, *p2; unsigned char *elementStart; if (argc == 2) { splitChars = (unsigned char*) " \n\t\r"; } else if (argc == 3) { splitChars = argv[2]; } else { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " string ?splitChars?\"", 0); return TCL_ERROR; } /* * Handle the special case of splitting on every character. */ if (*splitChars == 0) { unsigned char string[2]; string[1] = 0; for (p = argv[1]; *p != 0; p++) { string[0] = *p; Tcl_AppendElement(interp, string, 0); } return TCL_OK; } /* * Normal case: split on any of a given set of characters. * Discard instances of the split characters. */ for (p = elementStart = argv[1]; *p != 0; p++) { unsigned char c = *p; for (p2 = splitChars; *p2 != 0; p2++) { if (*p2 == c) { *p = 0; Tcl_AppendElement(interp, elementStart, 0); *p = c; elementStart = p+1; break; } } } if (p != argv[1]) { Tcl_AppendElement(interp, elementStart, 0); } return TCL_OK; } /* *---------------------------------------------------------------------- * * Tcl_StringCmd -- * * This procedure is invoked to process the "string" Tcl command. * See the user documentation for details on what it does. * * Results: * A standard Tcl result. * * Side effects: * See the user documentation. * *---------------------------------------------------------------------- */ /* ARGSUSED */ int Tcl_StringCmd(dummy, interp, argc, argv) void *dummy; /* Not used. */ Tcl_Interp *interp; /* Current interpreter. */ int argc; /* Number of arguments. */ unsigned char **argv; /* Argument strings. */ { int length; register unsigned char *p, c; int match; int first; int left = 0, right = 0; if (argc < 2) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " option arg ?arg ...?\"", 0); return TCL_ERROR; } c = argv[1][0]; length = strlen(argv[1]); if ((c == 'c') && (strncmp(argv[1], (unsigned char*) "compare", length) == 0)) { if (argc != 4) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " compare string1 string2\"", 0); return TCL_ERROR; } match = strcmp(argv[2], argv[3]); if (match > 0) { interp->result = (unsigned char*) "1"; } else if (match < 0) { interp->result = (unsigned char*) "-1"; } else { interp->result = (unsigned char*) "0"; } return TCL_OK; } else if ((c == 'f') && (strncmp(argv[1], (unsigned char*) "first", length) == 0)) { if (argc != 4) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " first string1 string2\"", 0); return TCL_ERROR; } first = 1; firstLast: match = -1; c = *argv[2]; length = strlen(argv[2]); for (p = argv[3]; *p != 0; p++) { if (*p != c) { continue; } if (strncmp(argv[2], p, length) == 0) { match = p-argv[3]; if (first) { break; } } } sprintf(interp->result, "%d", match); return TCL_OK; } else if ((c == 'i') && (strncmp(argv[1], (unsigned char*) "index", length) == 0)) { int index; if (argc != 4) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " index string charIndex\"", 0); return TCL_ERROR; } if (Tcl_GetInt(interp, argv[3], &index) != TCL_OK) { return TCL_ERROR; } if ((index >= 0) && (index < strlen(argv[2]))) { interp->result[0] = argv[2][index]; interp->result[1] = 0; } return TCL_OK; } else if ((c == 'l') && (strncmp(argv[1], (unsigned char*) "last", length) == 0) && (length >= 2)) { if (argc != 4) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " last string1 string2\"", 0); return TCL_ERROR; } first = 0; goto firstLast; } else if ((c == 'l') && (strncmp(argv[1], (unsigned char*) "length", length) == 0) && (length >= 2)) { if (argc != 3) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " length string\"", 0); return TCL_ERROR; } sprintf(interp->result, "%u", (unsigned int) strlen(argv[2])); return TCL_OK; } else if ((c == 'm') && (strncmp(argv[1], (unsigned char*) "match", length) == 0)) { if (argc != 4) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " match pattern string\"", 0); return TCL_ERROR; } if (Tcl_StringMatch(argv[3], argv[2]) != 0) { interp->result = (unsigned char*) "1"; } else { interp->result = (unsigned char*) "0"; } return TCL_OK; } else if ((c == 'r') && (strncmp(argv[1], (unsigned char*) "range", length) == 0)) { int first, last, stringLength; if (argc != 5) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " range string first last\"", 0); return TCL_ERROR; } stringLength = strlen(argv[2]); if (Tcl_GetInt(interp, argv[3], &first) != TCL_OK) { return TCL_ERROR; } if ((*argv[4] == 'e') && (strncmp(argv[4], (unsigned char*) "end", strlen(argv[4])) == 0)) { last = stringLength-1; } else { if (Tcl_GetInt(interp, argv[4], &last) != TCL_OK) { Tcl_ResetResult(interp); Tcl_AppendResult(interp, "expected integer or \"end\" but got \"", argv[4], "\"", 0); return TCL_ERROR; } } if (first < 0) { first = 0; } if (last >= stringLength) { last = stringLength-1; } if (last >= first) { unsigned char saved, *p; p = argv[2] + last + 1; saved = *p; *p = 0; Tcl_SetResult(interp, argv[2] + first, TCL_VOLATILE); *p = saved; } return TCL_OK; } else if ((c == 't') && (strncmp(argv[1], (unsigned char*) "tolower", length) == 0) && (length >= 3)) { register unsigned char *p; if (argc != 3) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " tolower string\"", 0); return TCL_ERROR; } Tcl_SetResult(interp, argv[2], TCL_VOLATILE); for (p = interp->result; *p != 0; p++) { if (isupper(*p)) { *p = tolower(*p); } } return TCL_OK; } else if ((c == 't') && (strncmp(argv[1], (unsigned char*) "toupper", length) == 0) && (length >= 3)) { register unsigned char *p; if (argc != 3) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " toupper string\"", 0); return TCL_ERROR; } Tcl_SetResult(interp, argv[2], TCL_VOLATILE); for (p = interp->result; *p != 0; p++) { if (islower(*p)) { *p = toupper(*p); } } return TCL_OK; } else if ((c == 't') && (strncmp(argv[1], (unsigned char*) "trim", length) == 0) && (length == 4)) { unsigned char *trimChars; register unsigned char *p, *checkPtr; left = right = 1; trim: if (argc == 4) { trimChars = argv[3]; } else if (argc == 3) { trimChars = (unsigned char*) " \t\n\r"; } else { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " ", argv[1], " string ?chars?\"", 0); return TCL_ERROR; } p = argv[2]; if (left) { for (c = *p; c != 0; p++, c = *p) { for (checkPtr = trimChars; *checkPtr != c; checkPtr++) { if (*checkPtr == 0) { goto doneLeft; } } } } doneLeft: Tcl_SetResult(interp, p, TCL_VOLATILE); if (right) { unsigned char *donePtr; p = interp->result + strlen(interp->result) - 1; donePtr = &interp->result[-1]; for (c = *p; p != donePtr; p--, c = *p) { for (checkPtr = trimChars; *checkPtr != c; checkPtr++) { if (*checkPtr == 0) { goto doneRight; } } } doneRight: p[1] = 0; } return TCL_OK; } else if ((c == 't') && (strncmp(argv[1], (unsigned char*) "trimleft", length) == 0) && (length > 4)) { left = 1; argv[1] = (unsigned char*) "trimleft"; goto trim; } else if ((c == 't') && (strncmp(argv[1], (unsigned char*) "trimright", length) == 0) && (length > 4)) { right = 1; argv[1] = (unsigned char*) "trimright"; goto trim; } else { Tcl_AppendResult(interp, "bad option \"", argv[1], "\": should be compare, first, index, last, length, match, ", "range, tolower, toupper, trim, trimleft, or trimright", 0); return TCL_ERROR; } } /* *---------------------------------------------------------------------- * * Tcl_TraceCmd -- * * This procedure is invoked to process the "trace" Tcl command. * See the user documentation for details on what it does. * * Results: * A standard Tcl result. * * Side effects: * See the user documentation. * *---------------------------------------------------------------------- */ /* ARGSUSED */ int Tcl_TraceCmd(dummy, interp, argc, argv) void *dummy; /* Not used. */ Tcl_Interp *interp; /* Current interpreter. */ int argc; /* Number of arguments. */ unsigned char **argv; /* Argument strings. */ { char c; int length; if (argc < 2) { Tcl_AppendResult(interp, "too few args: should be \"", argv[0], " option [arg arg ...]\"", 0); return TCL_ERROR; } c = argv[1][1]; length = strlen(argv[1]); if ((c == 'a') && (strncmp(argv[1], (unsigned char*) "variable", length) == 0) && (length >= 2)) { unsigned char *p; int flags, length; TraceVarInfo *tvarPtr; if (argc != 5) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " variable name ops command\"", 0); return TCL_ERROR; } flags = 0; for (p = argv[3] ; *p != 0; p++) { if (*p == 'r') { flags |= TCL_TRACE_READS; } else if (*p == 'w') { flags |= TCL_TRACE_WRITES; } else if (*p == 'u') { flags |= TCL_TRACE_UNSETS; } else { goto badOps; } } if (flags == 0) { goto badOps; } length = strlen(argv[4]); tvarPtr = (TraceVarInfo*) malloc ((unsigned) (sizeof(TraceVarInfo) - sizeof(tvarPtr->command) + length + 1)); tvarPtr->flags = flags; tvarPtr->length = length; flags |= TCL_TRACE_UNSETS; strcpy(tvarPtr->command, argv[4]); if (Tcl_TraceVar(interp, argv[2], flags, TraceVarProc, (void*) tvarPtr) != TCL_OK) { free (tvarPtr); return TCL_ERROR; } } else if ((c == 'd') && (strncmp(argv[1], (unsigned char*) "vdelete", length) && (length >= 2)) == 0) { unsigned char *p; int flags, length; TraceVarInfo *tvarPtr; void *clientData; if (argc != 5) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " vdelete name ops command\"", 0); return TCL_ERROR; } flags = 0; for (p = argv[3] ; *p != 0; p++) { if (*p == 'r') { flags |= TCL_TRACE_READS; } else if (*p == 'w') { flags |= TCL_TRACE_WRITES; } else if (*p == 'u') { flags |= TCL_TRACE_UNSETS; } else { goto badOps; } } if (flags == 0) { goto badOps; } /* * Search through all of our traces on this variable to * see if there's one with the given command. If so, then * delete the first one that matches. */ length = strlen(argv[4]); clientData = 0; while ((clientData = Tcl_VarTraceInfo(interp, argv[2], 0, TraceVarProc, clientData)) != 0) { tvarPtr = (TraceVarInfo *) clientData; if ((tvarPtr->length == length) && (tvarPtr->flags == flags) && (strncmp(argv[4], tvarPtr->command, length) == 0)) { Tcl_UntraceVar(interp, argv[2], flags | TCL_TRACE_UNSETS, TraceVarProc, clientData); free (tvarPtr); break; } } } else if ((c == 'i') && (strncmp(argv[1], (unsigned char*) "vinfo", length) == 0) && (length >= 2)) { void *clientData; unsigned char ops[4], *p; unsigned char *prefix = (unsigned char*) "{"; if (argc != 3) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " vinfo name\"", 0); return TCL_ERROR; } clientData = 0; while ((clientData = Tcl_VarTraceInfo(interp, argv[2], 0, TraceVarProc, clientData)) != 0) { TraceVarInfo *tvarPtr = (TraceVarInfo *) clientData; p = ops; if (tvarPtr->flags & TCL_TRACE_READS) { *p = 'r'; p++; } if (tvarPtr->flags & TCL_TRACE_WRITES) { *p = 'w'; p++; } if (tvarPtr->flags & TCL_TRACE_UNSETS) { *p = 'u'; p++; } *p = '\0'; Tcl_AppendResult(interp, prefix, 0); Tcl_AppendElement(interp, ops, 1); Tcl_AppendElement(interp, tvarPtr->command, 0); Tcl_AppendResult(interp, "}", 0); prefix = (unsigned char*) " {"; } } else { Tcl_AppendResult(interp, "bad option \"", argv[1], "\": should be variable, vdelete, or vinfo", 0); return TCL_ERROR; } return TCL_OK; badOps: Tcl_AppendResult(interp, "bad operations \"", argv[3], "\": should be one or more of rwu", 0); return TCL_ERROR; } /* *---------------------------------------------------------------------- * * TraceVarProc -- * * This procedure is called to handle variable accesses that have * been traced using the "trace" command. * * Results: * Normally returns NULL. If the trace command returns an error, * then this procedure returns an error string. * * Side effects: * Depends on the command associated with the trace. * *---------------------------------------------------------------------- */ /* ARGSUSED */ static unsigned char * TraceVarProc(clientData, interp, name1, name2, flags) void *clientData; /* Information about the variable trace. */ Tcl_Interp *interp; /* Interpreter containing variable. */ unsigned char *name1; /* Name of variable or array. */ unsigned char *name2; /* Name of element within array; NULL means * scalar variable is being referenced. */ int flags; /* OR-ed bits giving operation and other * information. */ { TraceVarInfo *tvarPtr = (TraceVarInfo *) clientData; unsigned char *result; int code, cmdLength, flags1, flags2; Interp dummy; #define STATIC_SIZE 199 unsigned char staticSpace[STATIC_SIZE+1]; unsigned char *cmdPtr, *p; result = 0; if ((tvarPtr->flags & flags) && !(flags & TCL_INTERP_DESTROYED)) { /* * Generate a command to execute by appending list elements * for the two variable names and the operation. The five * extra characters are for three space, the opcode character, * and the terminating null. */ if (name2 == 0) { name2 = (unsigned char*) ""; } cmdLength = tvarPtr->length + Tcl_ScanElement(name1, &flags1) + Tcl_ScanElement(name2, &flags2) + 5; if (cmdLength < STATIC_SIZE) { cmdPtr = staticSpace; } else { cmdPtr = malloc (cmdLength); } p = cmdPtr; strcpy(p, tvarPtr->command); p += tvarPtr->length; *p = ' '; p++; p += Tcl_ConvertElement(name1, p, flags1); *p = ' '; p++; p += Tcl_ConvertElement(name2, p, flags2); *p = ' '; if (flags & TCL_TRACE_READS) { p[1] = 'r'; } else if (flags & TCL_TRACE_WRITES) { p[1] = 'w'; } else if (flags & TCL_TRACE_UNSETS) { p[1] = 'u'; } p[2] = '\0'; /* * Execute the command. Be careful to save and restore the * result from the interpreter used for the command. */ if (interp->freeProc == 0) { dummy.freeProc = (Tcl_FreeProc *) 0; dummy.result = (unsigned char*) ""; Tcl_SetResult((Tcl_Interp *) &dummy, interp->result, TCL_VOLATILE); } else { dummy.freeProc = interp->freeProc; dummy.result = interp->result; } code = Tcl_Eval(interp, cmdPtr, 0, 0); if (cmdPtr != staticSpace) { free(cmdPtr); } if (code != TCL_OK) { result = (unsigned char*) "access disallowed by trace command"; Tcl_ResetResult(interp); /* Must clear error state. */ } Tcl_FreeResult(interp); interp->result = dummy.result; interp->freeProc = dummy.freeProc; } if (flags & TCL_TRACE_DESTROYED) { free (tvarPtr); } return result; } /* *---------------------------------------------------------------------- * * Tcl_WhileCmd -- * * This procedure is invoked to process the "while" Tcl command. * See the user documentation for details on what it does. * * Results: * A standard Tcl result. * * Side effects: * See the user documentation. * *---------------------------------------------------------------------- */ /* ARGSUSED */ int Tcl_WhileCmd(dummy, interp, argc, argv) void *dummy; /* Not used. */ Tcl_Interp *interp; /* Current interpreter. */ int argc; /* Number of arguments. */ unsigned char **argv; /* Argument strings. */ { int result, value; if (argc != 3) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " test command\"", 0); return TCL_ERROR; } while (1) { result = Tcl_ExprBoolean(interp, argv[1], &value); if (result != TCL_OK) { return result; } if (!value) { break; } result = Tcl_Eval(interp, argv[2], 0, 0); if (result == TCL_CONTINUE) { result = TCL_OK; } else if (result != TCL_OK) { if (result == TCL_ERROR) { unsigned char msg[60]; sprintf(msg, "\n (\"while\" body line %d)", interp->errorLine); Tcl_AddErrorInfo(interp, msg); } break; } } if (result == TCL_BREAK) { result = TCL_OK; } if (result == TCL_OK) { Tcl_ResetResult(interp); } return result; } ================================================ FILE: lib/libtcl/tclenv.c ================================================ /* * tclEnv.c -- * * Tcl support for environment variables, including a setenv * procedure. * * Copyright 1991 Regents of the University of California * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without * fee is hereby granted, provided that this copyright * notice appears in all copies. The University of California * makes no representations about the suitability of this * software for any purpose. It is provided "as is" without * express or implied warranty. */ #include "internal.h" extern char **environ; /* * The structure below is used to keep track of all of the interpereters * for which we're managing the "env" array. It's needed so that they * can all be updated whenever an environment variable is changed * anywhere. */ typedef struct EnvInterp { Tcl_Interp *interp; /* Interpreter for which we're managing * the env array. */ struct EnvInterp *nextPtr; /* Next in list of all such interpreters, * or zero. */ } EnvInterp; static EnvInterp *firstInterpPtr; /* First in list of all managed interpreters, * or NULL if none. */ static int environSize = 0; /* Non-zero means that the all of the * environ-related information is malloc-ed * and the environ array itself has this * many total entries allocated to it (not * all may be in use at once). Zero means * that the environment array is in its * original static state. */ /* * Declarations for local procedures defined in this file: */ static void EnvInit (void); static unsigned char * EnvTraceProc (void *clientData, Tcl_Interp *interp, unsigned char *name1, unsigned char *name2, int flags); static int FindVariable (const char *name, int *lengthPtr); int unsetenv (const char *name); /* *---------------------------------------------------------------------- * * TclSetupEnv -- * * This procedure is invoked for an interpreter to make environment * variables accessible from that interpreter via the "env" * associative array. * * Results: * None. * * Side effects: * The interpreter is added to a list of interpreters managed * by us, so that its view of envariables can be kept consistent * with the view in other interpreters. If this is the first * call to Tcl_SetupEnv, then additional initialization happens, * such as copying the environment to dynamically-allocated space * for ease of management. * *---------------------------------------------------------------------- */ void TclSetupEnv(interp) Tcl_Interp *interp; /* Interpreter whose "env" array is to be * managed. */ { EnvInterp *eiPtr; int i; /* * First, initialize our environment-related information, if * necessary. */ if (environSize == 0) { EnvInit(); } /* * Next, add the interpreter to the list of those that we manage. */ eiPtr = (EnvInterp *) malloc(sizeof(EnvInterp)); eiPtr->interp = interp; eiPtr->nextPtr = firstInterpPtr; firstInterpPtr = eiPtr; /* * Store the environment variable values into the interpreter's * "env" array, and arrange for us to be notified on future * writes and unsets to that array. */ (void) Tcl_UnsetVar2(interp, "env", (char *) NULL, TCL_GLOBAL_ONLY); for (i = 0; ; i++) { char *p, *p2; p = environ[i]; if (p == NULL) { break; } for (p2 = p; *p2 != '='; p2++) { /* Empty loop body. */ } *p2 = 0; (void) Tcl_SetVar2(interp, "env", p, p2+1, TCL_GLOBAL_ONLY); *p2 = '='; } Tcl_TraceVar2(interp, "env", (char *) NULL, TCL_GLOBAL_ONLY | TCL_TRACE_WRITES | TCL_TRACE_UNSETS, EnvTraceProc, (void*) NULL); } /* *---------------------------------------------------------------------- * * FindVariable -- * * Locate the entry in environ for a given name. * * Results: * The return value is the index in environ of an entry with the * name "name", or -1 if there is no such entry. The integer at * *lengthPtr is filled in with the length of name (if a matching * entry is found) or the length of the environ array (if no matching * entry is found). * * Side effects: * None. * *---------------------------------------------------------------------- */ static int FindVariable(name, lengthPtr) const char *name; /* Name of desired environment variable. */ int *lengthPtr; /* Used to return length of name (for * successful searches) or number of non-NULL * entries in environ (for unsuccessful * searches). */ { int i; const register char *p1, *p2; for (i = 0, p1 = environ[i]; p1 != NULL; i++, p1 = environ[i]) { for (p2 = name; *p2 == *p1; p1++, p2++) { /* NULL loop body. */ } if ((*p1 == '=') && (*p2 == '\0')) { *lengthPtr = p2-name; return i; } } *lengthPtr = i; return -1; } /* *---------------------------------------------------------------------- * * setenv -- * * Set an environment variable, replacing an existing value * or creating a new variable if there doesn't exist a variable * by the given name. * * Results: * None. * * Side effects: * The environ array gets updated, as do all of the interpreters * that we manage. * *---------------------------------------------------------------------- */ int setenv(name, value, overwrite) const char *name; /* Name of variable whose value is to be * set. */ const char *value; /* New value for variable. */ int overwrite; { int index, length, nameLength; char *p; EnvInterp *eiPtr; if (environSize == 0) { EnvInit(); } /* * Figure out where the entry is going to go. If the name doesn't * already exist, enlarge the array if necessary to make room. If * the name exists, free its old entry. */ index = FindVariable(name, &length); if (index == -1) { if ((length+2) > environSize) { char **newEnviron; newEnviron = (char **) malloc((unsigned) ((length+5) * sizeof(char *))); memcpy((void *) newEnviron, (void *) environ, length*sizeof(char *)); free((char *) environ); environ = newEnviron; environSize = length+5; } index = length; environ[index+1] = NULL; nameLength = strlen(name); } else { /* * Compare the new value to the existing value. If they're * the same then quit immediately (e.g. don't rewrite the * value or propagate it to other interpeters). Otherwise, * when there are N interpreters there will be N! propagations * of the same value among the interpreters. */ if (strcmp(value, environ[index]+length+1) == 0) { return 0; } free(environ[index]); nameLength = length; } /* * Create a new entry and enter it into the table. */ p = (char *) malloc((unsigned) (nameLength + strlen(value) + 2)); environ[index] = p; strcpy(p, name); p += nameLength; *p = '='; strcpy(p+1, value); /* * Update all of the interpreters. */ for (eiPtr= firstInterpPtr; eiPtr != NULL; eiPtr = eiPtr->nextPtr) { (void) Tcl_SetVar2(eiPtr->interp, "env", (char *) name, p+1, TCL_GLOBAL_ONLY); } return 0; } /* *---------------------------------------------------------------------- * * putenv -- * * Set an environment variable. Similar to setenv except that * the information is passed in a single string of the form * NAME=value, rather than as separate name strings. This procedure * is a stand-in for the standard UNIX procedure by the same name, * so that applications using that procedure will interface * properly to Tcl. * * Results: * None. * * Side effects: * The environ array gets updated, as do all of the interpreters * that we manage. * *---------------------------------------------------------------------- */ int putenv(string) char *string; /* Info about environment variable in the * form NAME=value. */ { int nameLength; char *name, *value; if (string == NULL) { return 0; } /* * Separate the string into name and value parts, then call * setenv to do all of the real work. */ value = strchr(string, '='); if (value == NULL) { return 0; } nameLength = value - string; if (nameLength == 0) { return 0; } name = malloc(nameLength+1); memcpy(name, string, nameLength); name[nameLength] = 0; setenv(name, value+1, 1); free(name); return 0; } /* *---------------------------------------------------------------------- * * unsetenv -- * * Remove an environment variable, updating the "env" arrays * in all interpreters managed by us. * * Results: * None. * * Side effects: * Interpreters are updated, as is environ. * *---------------------------------------------------------------------- */ int unsetenv(name) const char *name; /* Name of variable to remove. */ { int index, dummy; char **envPtr; EnvInterp *eiPtr; if (environSize == 0) { EnvInit(); } /* * Update the environ array. */ index = FindVariable(name, &dummy); if (index == -1) { return 0; } free(environ[index]); for (envPtr = environ+index+1; ; envPtr++) { envPtr[-1] = *envPtr; if (*envPtr == NULL) { break; } } /* * Update all of the interpreters. */ for (eiPtr = firstInterpPtr; eiPtr != NULL; eiPtr = eiPtr->nextPtr) { (void) Tcl_UnsetVar2(eiPtr->interp, "env", (char *) name, TCL_GLOBAL_ONLY); } return 0; } /* *---------------------------------------------------------------------- * * EnvTraceProc -- * * This procedure is invoked whenever an environment variable * is modified or deleted. It propagates the change to the * "environ" array and to any other interpreters for whom * we're managing an "env" array. * * Results: * Always returns NULL to indicate success. * * Side effects: * Environment variable changes get propagated. If the whole * "env" array is deleted, then we stop managing things for * this interpreter (usually this happens because the whole * interpreter is being deleted). * *---------------------------------------------------------------------- */ /* ARGSUSED */ static unsigned char * EnvTraceProc(clientData, interp, name1, name2, flags) void *clientData; /* Not used. */ Tcl_Interp *interp; /* Interpreter whose "env" variable is * being modified. */ unsigned char *name1; /* Better be "env". */ unsigned char *name2; /* Name of variable being modified, or * NULL if whole array is being deleted. */ int flags; /* Indicates what's happening. */ { /* * First see if the whole "env" variable is being deleted. If * so, just forget about this interpreter. */ if (name2 == NULL) { register EnvInterp *eiPtr, *prevPtr; if ((flags & (TCL_TRACE_UNSETS|TCL_TRACE_DESTROYED)) != (TCL_TRACE_UNSETS|TCL_TRACE_DESTROYED)) { fprintf(stderr, "EnvTraceProc called with confusing arguments\n"); abort(); } eiPtr = firstInterpPtr; if (eiPtr->interp == interp) { firstInterpPtr = eiPtr->nextPtr; } else { for (prevPtr = eiPtr, eiPtr = eiPtr->nextPtr; ; prevPtr = eiPtr, eiPtr = eiPtr->nextPtr) { if (eiPtr == NULL) { fprintf(stderr, "EnvTraceProc couldn't find interpreter\n"); abort(); } if (eiPtr->interp == interp) { prevPtr->nextPtr = eiPtr->nextPtr; break; } } } free((char *) eiPtr); return NULL; } /* * If a value is being set, call setenv to do all of the work. */ if (flags & TCL_TRACE_WRITES) { setenv(name2, Tcl_GetVar2(interp, "env", name2, TCL_GLOBAL_ONLY), 1); } if (flags & TCL_TRACE_UNSETS) { unsetenv(name2); } return NULL; } /* *---------------------------------------------------------------------- * * EnvInit -- * * This procedure is called to initialize our management * of the environ array. * * Results: * None. * * Side effects: * Environ gets copied to malloc-ed storage, so that in * the future we don't have to worry about which entries * are malloc-ed and which are static. * *---------------------------------------------------------------------- */ static void EnvInit() { char **newEnviron; int i, length; if (environSize != 0) { return; } for (length = 0; environ[length] != NULL; length++) { /* Empty loop body. */ } environSize = length+5; newEnviron = (char **) malloc((unsigned) (environSize * sizeof(char *))); for (i = 0; i < length; i++) { newEnviron[i] = (char *) malloc((unsigned) (strlen(environ[i]) + 1)); strcpy(newEnviron[i], environ[i]); } newEnviron[length] = NULL; environ = newEnviron; } ================================================ FILE: lib/libtcl/tclexpr.c ================================================ /* * tclExpr.c -- * * This file contains the code to evaluate expressions for * Tcl. * * This implementation of floating-point support was modelled * after an initial implementation by Bill Carpenter. * * Copyright 1987-1991 Regents of the University of California * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without * fee is hereby granted, provided that the above copyright * notice appear in all copies. The University of California * makes no representations about the suitability of this * software for any purpose. It is provided "as is" without * express or implied warranty. */ #include "internal.h" /* * The data structure below is used to describe an expression value, * which can be either an integer (the usual case), or a string. * A given number has only one value at a time. */ #define STATIC_STRING_SPACE 40 typedef struct { unsigned char type; /* Type: TYPE_INT or TYPE_STRING. */ long int_value; /* Integer value, if any. */ ParseValue pv; /* A string value, if any. */ unsigned char static_space [STATIC_STRING_SPACE]; /* Storage for small strings; * large ones are malloc-ed. */ } Value_t; /* * Valid values for type: */ #define TYPE_INT 0 #define TYPE_STRING 1 /* * The data structure below describes the state of parsing an expression. * It's passed among the routines in this module. */ typedef struct { unsigned char *original_expr; /* The entire expression, as originally * passed to Tcl_Expr. */ unsigned char *expr; /* Position to the next character to be * scanned from the expression string. */ unsigned char token; /* Type of the last token to be parsed from * expr. See below for definitions. * Corresponds to the characters just * before expr. */ } Expr_info_t; /* * The token types are defined below. In addition, there is a table * associating a precedence with each operator. The order of types * is important. Consult the code before changing it. */ #define VALUE 0 #define OPEN_PAREN 1 #define CLOSE_PAREN 2 #define END 3 #define UNKNOWN 4 /* * Binary operators: */ #define MULT 8 #define DIVIDE 9 #define MOD 10 #define PLUS 11 #define MINUS 12 #define LEFT_SHIFT 13 #define RIGHT_SHIFT 14 #define LESS 15 #define GREATER 16 #define LEQ 17 #define GEQ 18 #define EQUAL 19 #define NEQ 20 #define BIT_AND 21 #define BIT_XOR 22 #define BIT_OR 23 #define AND 24 #define OR 25 #define QUESTY 26 #define COLON 27 /* * Unary operators: */ #define UNARY_MINUS 28 #define NOT 29 #define BIT_NOT 30 /* * Precedence table. The values for non-operator token types are ignored. */ static unsigned char prec_table [] = { 0, 0, 0, 0, 0, 0, 0, 0, 11, 11, 11, /* MULT, DIVIDE, MOD */ 10, 10, /* PLUS, MINUS */ 9, 9, /* LEFT_SHIFT, RIGHT_SHIFT */ 8, 8, 8, 8, /* LESS, GREATER, LEQ, GEQ */ 7, 7, /* EQUAL, NEQ */ 6, /* BIT_AND */ 5, /* BIT_XOR */ 4, /* BIT_OR */ 3, /* AND */ 2, /* OR */ 1, 1, /* QUESTY, COLON */ 12, 12, 12 /* UNARY_MINUS, NOT, BIT_NOT */ }; /* * Mapping from operator numbers to strings; used for error messages. */ static char *operator_strings[] = { "VALUE", "(", ")", "END", "UNKNOWN", "5", "6", "7", "*", "/", "%", "+", "-", "<<", ">>", "<", ">", "<=", ">=", "==", "!=", "&", "^", "|", "&&", "||", "?", ":", "-", "!", "~" }; /* * Declarations for local procedures to this file: */ static void make_string (Value_t *valuePtr); /* * Given a string (such as one coming from command or variable * substitution), make a Value_t based on the string. The value * will be a floating-point or integer, if possible, or else it * will just be a copy of the string. * * Results: * TCL_OK is returned under normal circumstances, and TCL_ERROR * is returned if a floating-point overflow or underflow occurred * while reading in a number. The value at *valuePtr is modified * to hold a number, if possible. * * Side effects: * None. */ static unsigned char parse_string (Tcl_Interp *interp, /* Where to store error message. */ unsigned char *string, /* String to turn into value. */ Value_t *valuePtr) /* Where to store value information. * Caller must have initialized pv field. */ { char c; /* * Try to convert the string to a number. */ c = *string; if (((c >= '0') && (c <= '9')) || (c == '-')) { char *term; valuePtr->type = TYPE_INT; valuePtr->int_value = strtol (string, &term, 0); c = *term; if (c == '\0') { return TCL_OK; } } /* * Not a valid number. Save a string value (but don't do anything * if it's already the value). */ valuePtr->type = TYPE_STRING; if (string != valuePtr->pv.buffer) { unsigned short length, space; length = strlen (string); valuePtr->pv.next = valuePtr->pv.buffer; space = valuePtr->pv.end - valuePtr->pv.buffer; if (length > space) { (*valuePtr->pv.expandProc) (&valuePtr->pv, length - space); } strcpy (valuePtr->pv.buffer, string); } return TCL_OK; } /* * Lexical analyzer for expression parser: parses a single value, * operator, or other syntactic element from an expression string. * * Results: * TCL_OK is returned unless an error occurred while doing lexical * analysis or executing an embedded command. In that case a * standard Tcl error is returned, using interp->result to hold * an error message. In the event of a successful return, the token * and field in infoPtr is updated to refer to the next symbol in * the expression string, and the expr field is advanced past that * token; if the token is a value, then the value is stored at * valuePtr. * * Side effects: * None. */ static unsigned char get_lex (Tcl_Interp *interp, /* Interpreter to use for error reporting. */ Expr_info_t *infoPtr, /* Describes the state of the parse. */ Value_t *valuePtr) /* Where to store value, if that is * what's parsed from string. Caller * must have initialized pv field correctly. */ { char *p, c, *var, *term; unsigned char result; p = infoPtr->expr; c = *p; while (isspace(c)) { p++; c = *p; } infoPtr->expr = p+1; switch (c) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': /* * Number. First read an integer. Then if it looks like * there's a floating-point number (or if it's too big a * number to fit in an integer), parse it as a floating-point * number. */ infoPtr->token = VALUE; valuePtr->type = TYPE_INT; valuePtr->int_value = strtoul (p, &term, 0); c = *term; infoPtr->expr = term; return TCL_OK; case '$': /* * Variable. Fetch its value, then see if it makes sense * as an integer or floating-point number. */ infoPtr->token = VALUE; var = Tcl_ParseVar(interp, p, &infoPtr->expr); if (var == 0) { return TCL_ERROR; } if (((Interp *) interp)->noEval) { valuePtr->type = TYPE_INT; valuePtr->int_value = 0; return TCL_OK; } return parse_string(interp, var, valuePtr); case '[': infoPtr->token = VALUE; result = Tcl_Eval(interp, p+1, TCL_BRACKET_TERM, &infoPtr->expr); if (result != TCL_OK) { return result; } infoPtr->expr++; if (((Interp *) interp)->noEval) { valuePtr->type = TYPE_INT; valuePtr->int_value = 0; Tcl_ResetResult(interp); return TCL_OK; } result = parse_string(interp, interp->result, valuePtr); if (result != TCL_OK) { return result; } Tcl_ResetResult(interp); return TCL_OK; case '"': infoPtr->token = VALUE; result = TclParseQuotes(interp, infoPtr->expr, '"', 0, &infoPtr->expr, &valuePtr->pv); if (result != TCL_OK) { return result; } return parse_string(interp, valuePtr->pv.buffer, valuePtr); case '{': infoPtr->token = VALUE; result = TclParseBraces(interp, infoPtr->expr, &infoPtr->expr, &valuePtr->pv); if (result != TCL_OK) { return result; } return parse_string(interp, valuePtr->pv.buffer, valuePtr); case '(': infoPtr->token = OPEN_PAREN; return TCL_OK; case ')': infoPtr->token = CLOSE_PAREN; return TCL_OK; case '*': infoPtr->token = MULT; return TCL_OK; case '/': infoPtr->token = DIVIDE; return TCL_OK; case '%': infoPtr->token = MOD; return TCL_OK; case '+': infoPtr->token = PLUS; return TCL_OK; case '-': infoPtr->token = MINUS; return TCL_OK; case '?': infoPtr->token = QUESTY; return TCL_OK; case ':': infoPtr->token = COLON; return TCL_OK; case '<': switch (p[1]) { case '<': infoPtr->expr = p+2; infoPtr->token = LEFT_SHIFT; break; case '=': infoPtr->expr = p+2; infoPtr->token = LEQ; break; default: infoPtr->token = LESS; break; } return TCL_OK; case '>': switch (p[1]) { case '>': infoPtr->expr = p+2; infoPtr->token = RIGHT_SHIFT; break; case '=': infoPtr->expr = p+2; infoPtr->token = GEQ; break; default: infoPtr->token = GREATER; break; } return TCL_OK; case '=': if (p[1] == '=') { infoPtr->expr = p+2; infoPtr->token = EQUAL; } else { infoPtr->token = UNKNOWN; } return TCL_OK; case '!': if (p[1] == '=') { infoPtr->expr = p+2; infoPtr->token = NEQ; } else { infoPtr->token = NOT; } return TCL_OK; case '&': if (p[1] == '&') { infoPtr->expr = p+2; infoPtr->token = AND; } else { infoPtr->token = BIT_AND; } return TCL_OK; case '^': infoPtr->token = BIT_XOR; return TCL_OK; case '|': if (p[1] == '|') { infoPtr->expr = p+2; infoPtr->token = OR; } else { infoPtr->token = BIT_OR; } return TCL_OK; case '~': infoPtr->token = BIT_NOT; return TCL_OK; case 0: infoPtr->token = END; infoPtr->expr = p; return TCL_OK; default: infoPtr->expr = p+1; infoPtr->token = UNKNOWN; return TCL_OK; } } /* * Parse a "value" from the remainder of the expression in infoPtr. * * Results: * Normally TCL_OK is returned. The value of the expression is * returned in *valuePtr. If an error occurred, then interp->result * contains an error message and TCL_ERROR is returned. * InfoPtr->token will be left pointing to the token AFTER the * expression, and infoPtr->expr will point to the character just * after the terminating token. * * Side effects: * None. */ static unsigned char get_value (Tcl_Interp *interp, /* Interpreter to use for error reporting. */ Expr_info_t *infoPtr, /* Describes the state of the parse just * before the value (i.e. get_lex will be * called to get first token of value). */ int prec, /* Treat any un-parenthesized operator * with precedence <= this as the end * of the expression. */ Value_t *valuePtr) /* Where to store the value of the * expression. Caller must have * initialized pv field. */ { Interp *iPtr = (Interp *) interp; Value_t value2; /* Second operand for current * operator. */ int operator; /* Current operator (either unary * or binary). */ int gotOp; /* Non-zero means already lexed the * operator (while picking up value * for unary operator). Don't lex * again. */ unsigned char result; /* * There are two phases to this procedure. First, pick off an initial * value. Then, parse (binary operator, value) pairs until done. */ gotOp = 0; value2.pv.buffer = value2.pv.next = value2.static_space; value2.pv.end = value2.pv.buffer + STATIC_STRING_SPACE - 1; value2.pv.expandProc = TclExpandParseValue; value2.pv.clientData = (void*) 0; result = get_lex(interp, infoPtr, valuePtr); if (result != TCL_OK) { goto done; } if (infoPtr->token == OPEN_PAREN) { /* * Parenthesized sub-expression. */ result = get_value(interp, infoPtr, -1, valuePtr); if (result != TCL_OK) { goto done; } if (infoPtr->token != CLOSE_PAREN) { Tcl_ResetResult(interp); Tcl_AppendResult(interp, "unmatched parentheses in expression \"", infoPtr->original_expr, "\"", 0); result = TCL_ERROR; goto done; } } else { if (infoPtr->token == MINUS) { infoPtr->token = UNARY_MINUS; } if (infoPtr->token >= UNARY_MINUS) { /* * Process unary operators. */ operator = infoPtr->token; result = get_value(interp, infoPtr, prec_table[infoPtr->token], valuePtr); if (result != TCL_OK) { goto done; } switch (operator) { case UNARY_MINUS: if (valuePtr->type == TYPE_INT) { valuePtr->int_value = -valuePtr->int_value; } else { goto illegalType; } break; case NOT: if (valuePtr->type == TYPE_INT) { valuePtr->int_value = !valuePtr->int_value; } else { goto illegalType; } break; case BIT_NOT: if (valuePtr->type == TYPE_INT) { valuePtr->int_value = ~valuePtr->int_value; } else { goto illegalType; } break; } gotOp = 1; } else if (infoPtr->token != VALUE) { goto syntaxError; } } /* * Got the first operand. Now fetch (operator, operand) pairs. */ if (!gotOp) { result = get_lex(interp, infoPtr, &value2); if (result != TCL_OK) { goto done; } } while (1) { operator = infoPtr->token; value2.pv.next = value2.pv.buffer; if ((operator < MULT) || (operator >= UNARY_MINUS)) { if ((operator == END) || (operator == CLOSE_PAREN)) { result = TCL_OK; goto done; } else { goto syntaxError; } } if (prec_table[operator] <= prec) { result = TCL_OK; goto done; } /* * If we're doing an AND or OR and the first operand already * determines the result, don't execute anything in the * second operand: just parse. Same style for ?: pairs. */ if ((operator == AND) || (operator == OR) || (operator == QUESTY)) { if (valuePtr->type == TYPE_STRING) { goto illegalType; } if (((operator == AND) && !valuePtr->int_value) || ((operator == OR) && valuePtr->int_value)) { iPtr->noEval++; result = get_value(interp, infoPtr, prec_table[operator], &value2); iPtr->noEval--; } else if (operator == QUESTY) { if (valuePtr->int_value != 0) { valuePtr->pv.next = valuePtr->pv.buffer; result = get_value(interp, infoPtr, prec_table[operator], valuePtr); if (result != TCL_OK) { goto done; } if (infoPtr->token != COLON) { goto syntaxError; } value2.pv.next = value2.pv.buffer; iPtr->noEval++; result = get_value(interp, infoPtr, prec_table[operator], &value2); iPtr->noEval--; } else { iPtr->noEval++; result = get_value(interp, infoPtr, prec_table[operator], &value2); iPtr->noEval--; if (result != TCL_OK) { goto done; } if (infoPtr->token != COLON) { goto syntaxError; } valuePtr->pv.next = valuePtr->pv.buffer; result = get_value(interp, infoPtr, prec_table[operator], valuePtr); } } else { result = get_value(interp, infoPtr, prec_table[operator], &value2); } } else { result = get_value(interp, infoPtr, prec_table[operator], &value2); } if (result != TCL_OK) { goto done; } if ((infoPtr->token < MULT) && (infoPtr->token != VALUE) && (infoPtr->token != END) && (infoPtr->token != CLOSE_PAREN)) { goto syntaxError; } /* * At this point we've got two values and an operator. Check * to make sure that the particular data types are appropriate * for the particular operator, and perform type conversion * if necessary. */ switch (operator) { /* * For the operators below, no strings are allowed and * ints get converted to floats if necessary. */ case MULT: case DIVIDE: case PLUS: case MINUS: if ((valuePtr->type == TYPE_STRING) || (value2.type == TYPE_STRING)) { goto illegalType; } break; /* * For the operators below, only integers are allowed. */ case MOD: case LEFT_SHIFT: case RIGHT_SHIFT: case BIT_AND: case BIT_XOR: case BIT_OR: if (valuePtr->type != TYPE_INT) { goto illegalType; } else if (value2.type != TYPE_INT) { goto illegalType; } break; /* * For the operators below, any type is allowed but the * two operands must have the same type. Convert integers * to floats and either to strings, if necessary. */ case LESS: case GREATER: case LEQ: case GEQ: case EQUAL: case NEQ: if (valuePtr->type == TYPE_STRING) { if (value2.type != TYPE_STRING) { make_string (&value2); } } else if (value2.type == TYPE_STRING) { if (valuePtr->type != TYPE_STRING) { make_string (valuePtr); } } break; /* * For the operators below, no strings are allowed. */ case AND: case OR: if (valuePtr->type == TYPE_STRING) { goto illegalType; } if (value2.type == TYPE_STRING) { goto illegalType; } break; /* * For the operators below, type and conversions are * irrelevant: they're handled elsewhere. */ case QUESTY: case COLON: break; /* * Any other operator is an error. */ default: interp->result = (unsigned char*) "unknown operator in expression"; result = TCL_ERROR; goto done; } /* * If necessary, convert one of the operands to the type * of the other. If the operands are incompatible with * the operator (e.g. "+" on strings) then return an * error. */ switch (operator) { case MULT: if (valuePtr->type == TYPE_INT) { valuePtr->int_value *= value2.int_value; } break; case DIVIDE: if (valuePtr->type == TYPE_INT) { if (value2.int_value == 0) { divideByZero: interp->result = (unsigned char*) "divide by zero"; result = TCL_ERROR; goto done; } valuePtr->int_value /= value2.int_value; } break; case MOD: if (value2.int_value == 0) { goto divideByZero; } valuePtr->int_value %= value2.int_value; break; case PLUS: if (valuePtr->type == TYPE_INT) { valuePtr->int_value += value2.int_value; } break; case MINUS: if (valuePtr->type == TYPE_INT) { valuePtr->int_value -= value2.int_value; } break; case LEFT_SHIFT: valuePtr->int_value <<= value2.int_value; break; case RIGHT_SHIFT: /* * The following code is a bit tricky: it ensures that * right shifts propagate the sign bit even on machines * where ">>" won't do it by default. */ if (valuePtr->int_value < 0) { valuePtr->int_value = ~((~valuePtr->int_value) >> value2.int_value); } else { valuePtr->int_value >>= value2.int_value; } break; case LESS: if (valuePtr->type == TYPE_INT) { valuePtr->int_value = valuePtr->int_value < value2.int_value; } else { valuePtr->int_value = strcmp(valuePtr->pv.buffer, value2.pv.buffer) < 0; } valuePtr->type = TYPE_INT; break; case GREATER: if (valuePtr->type == TYPE_INT) { valuePtr->int_value = valuePtr->int_value > value2.int_value; } else { valuePtr->int_value = strcmp(valuePtr->pv.buffer, value2.pv.buffer) > 0; } valuePtr->type = TYPE_INT; break; case LEQ: if (valuePtr->type == TYPE_INT) { valuePtr->int_value = valuePtr->int_value <= value2.int_value; } else { valuePtr->int_value = strcmp(valuePtr->pv.buffer, value2.pv.buffer) <= 0; } valuePtr->type = TYPE_INT; break; case GEQ: if (valuePtr->type == TYPE_INT) { valuePtr->int_value = valuePtr->int_value >= value2.int_value; } else { valuePtr->int_value = strcmp(valuePtr->pv.buffer, value2.pv.buffer) >= 0; } valuePtr->type = TYPE_INT; break; case EQUAL: if (valuePtr->type == TYPE_INT) { valuePtr->int_value = valuePtr->int_value == value2.int_value; } else { valuePtr->int_value = strcmp(valuePtr->pv.buffer, value2.pv.buffer) == 0; } valuePtr->type = TYPE_INT; break; case NEQ: if (valuePtr->type == TYPE_INT) { valuePtr->int_value = valuePtr->int_value != value2.int_value; } else { valuePtr->int_value = strcmp(valuePtr->pv.buffer, value2.pv.buffer) != 0; } valuePtr->type = TYPE_INT; break; case BIT_AND: valuePtr->int_value &= value2.int_value; break; case BIT_XOR: valuePtr->int_value ^= value2.int_value; break; case BIT_OR: valuePtr->int_value |= value2.int_value; break; case AND: valuePtr->int_value = valuePtr->int_value && value2.int_value; break; case OR: valuePtr->int_value = valuePtr->int_value || value2.int_value; break; case COLON: interp->result = (unsigned char*) "can't have : operator without ? first"; result = TCL_ERROR; goto done; } } done: if (value2.pv.buffer != value2.static_space) { free (value2.pv.buffer); } return result; syntaxError: Tcl_ResetResult(interp); Tcl_AppendResult(interp, "syntax error in expression \"", infoPtr->original_expr, "\"", 0); result = TCL_ERROR; goto done; illegalType: Tcl_AppendResult(interp, "can't use non-numeric string as operand of \"", operator_strings[operator], "\"", 0); result = TCL_ERROR; goto done; } /* * Convert a value from int representation to a string. * * Results: * The information at *valuePtr gets converted to string * format, if it wasn't that way already. * * Side effects: * None. */ static void make_string (Value_t *valuePtr) /* Value to be converted. */ { unsigned short space; space = valuePtr->pv.end - valuePtr->pv.buffer; if (20 > space) { (*valuePtr->pv.expandProc) (&valuePtr->pv, 20 - space); } if (valuePtr->type == TYPE_INT) { sprintf (valuePtr->pv.buffer, "%ld", valuePtr->int_value); } valuePtr->type = TYPE_STRING; } /* * This procedure provides top-level functionality shared by * procedures like Tcl_ExprInt, etc. * * Results: * The result is a standard Tcl return value. If an error * occurs then an error message is left in interp->result. * The value of the expression is returned in *valuePtr, in * whatever form it ends up in (could be string or integer). * Caller may need to convert result. Caller * is also responsible for freeing string memory in *valuePtr, * if any was allocated. * * Side effects: * None. */ static unsigned char evaluate (Tcl_Interp *interp, /* Context in which to evaluate the * expression. */ unsigned char *string, /* Expression to evaluate. */ Value_t *valuePtr) /* Where to store result. Should * not be initialized by caller. */ { Expr_info_t info; unsigned char result; info.original_expr = string; info.expr = string; valuePtr->pv.buffer = valuePtr->pv.next = valuePtr->static_space; valuePtr->pv.end = valuePtr->pv.buffer + STATIC_STRING_SPACE - 1; valuePtr->pv.expandProc = TclExpandParseValue; valuePtr->pv.clientData = (void*) 0; result = get_value(interp, &info, -1, valuePtr); if (result != TCL_OK) { return result; } if (info.token != END) { Tcl_AppendResult(interp, "syntax error in expression \"", string, "\"", 0); return TCL_ERROR; } return TCL_OK; } /* * Procedures to evaluate an expression and return its value * in a particular form. * * Results: * Each of the procedures below returns a standard Tcl result. * If an error occurs then an error message is left in * interp->result. Otherwise the value of the expression, * in the appropriate form, is stored at *resultPtr. If * the expression had a result that was incompatible with the * desired form then an error is returned. * * Side effects: * None. */ int Tcl_ExprLong (Tcl_Interp *interp, /* Context in which to evaluate the * expression. */ unsigned char *string, /* Expression to evaluate. */ long *ptr) /* Where to store result. */ { Value_t value; unsigned char result; result = evaluate (interp, string, &value); if (result == TCL_OK) { if (value.type == TYPE_INT) { *ptr = value.int_value; } else { interp->result = (unsigned char*) "expression didn't have numeric value"; result = TCL_ERROR; } } if (value.pv.buffer != value.static_space) { free (value.pv.buffer); } return result; } int Tcl_ExprBoolean (Tcl_Interp *interp, /* Context in which to evaluate the * expression. */ unsigned char *string, /* Expression to evaluate. */ int *ptr) /* Where to store 0/1 result. */ { Value_t value; unsigned char result; result = evaluate (interp, string, &value); if (result == TCL_OK) { if (value.type == TYPE_INT) { *ptr = value.int_value != 0; } else { interp->result = (unsigned char*) "expression didn't have numeric value"; result = TCL_ERROR; } } if (value.pv.buffer != value.static_space) { free (value.pv.buffer); } return result; } /* * Evaluate an expression and return its value in string form. * * Results: * A standard Tcl result. If the result is TCL_OK, then the * interpreter's result is set to the string value of the * expression. If the result is TCL_OK, then interp->result * contains an error message. * * Side effects: * None. */ int Tcl_ExprString (Tcl_Interp *interp, /* Context in which to evaluate the * expression. */ unsigned char *string) /* Expression to evaluate. */ { Value_t value; unsigned char result; result = evaluate (interp, string, &value); if (result == TCL_OK) { if (value.type == TYPE_INT) { sprintf (interp->result, "%ld", value.int_value); } else { if (value.pv.buffer != value.static_space) { interp->result = value.pv.buffer; interp->freeProc = (Tcl_FreeProc *) free; value.pv.buffer = value.static_space; } else { Tcl_SetResult (interp, value.pv.buffer, TCL_VOLATILE); } } } if (value.pv.buffer != value.static_space) { free (value.pv.buffer); } return result; } ================================================ FILE: lib/libtcl/tclget.c ================================================ /* * tclGet.c -- * * This file contains procedures to convert strings into * other forms, like integers or floating-point numbers or * booleans, doing syntax checking along the way. * * Copyright 1990-1991 Regents of the University of California * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without * fee is hereby granted, provided that the above copyright * notice appear in all copies. The University of California * makes no representations about the suitability of this * software for any purpose. It is provided "as is" without * express or implied warranty. */ #include "internal.h" /* *---------------------------------------------------------------------- * * Tcl_GetInt -- * * Given a string, produce the corresponding integer value. * * Results: * The return value is normally TCL_OK; in this case *intPtr * will be set to the integer value equivalent to string. If * string is improperly formed then TCL_ERROR is returned and * an error message will be left in interp->result. * * Side effects: * None. * *---------------------------------------------------------------------- */ int Tcl_GetInt(interp, string, intPtr) Tcl_Interp *interp; /* Interpreter to use for error reporting. */ char *string; /* String containing a (possibly signed) * integer in a form acceptable to strtol. */ int *intPtr; /* Place to store converted result. */ { char *end; int i; i = strtol(string, &end, 0); while ((*end != '\0') && isspace(*end)) { end++; } if ((end == string) || (*end != 0)) { Tcl_AppendResult(interp, "expected integer but got \"", string, "\"", (char *) 0); return TCL_ERROR; } *intPtr = i; return TCL_OK; } /* *---------------------------------------------------------------------- * * Tcl_GetBoolean -- * * Given a string, return a 0/1 boolean value corresponding * to the string. * * Results: * The return value is normally TCL_OK; in this case *boolPtr * will be set to the 0/1 value equivalent to string. If * string is improperly formed then TCL_ERROR is returned and * an error message will be left in interp->result. * * Side effects: * None. * *---------------------------------------------------------------------- */ int Tcl_GetBoolean(interp, string, boolPtr) Tcl_Interp *interp; /* Interpreter to use for error reporting. */ unsigned char *string; /* String containing a boolean number * specified either as 1/0 or true/false or * yes/no. */ int *boolPtr; /* Place to store converted result, which * will be 0 or 1. */ { char c; unsigned char lowerCase[10]; int i, length; /* * Convert the input string to all lower-case. */ for (i = 0; i < 9; i++) { c = string[i]; if (c == 0) { break; } if ((c >= 'A') && (c <= 'Z')) { c += 'a' - 'A'; } lowerCase[i] = c; } lowerCase[i] = 0; length = strlen(lowerCase); c = lowerCase[0]; if ((c == '0') && (lowerCase[1] == '\0')) { *boolPtr = 0; } else if ((c == '1') && (lowerCase[1] == '\0')) { *boolPtr = 1; } else if ((c == 'y') && (strncmp(lowerCase, (unsigned char*) "yes", length) == 0)) { *boolPtr = 1; } else if ((c == 'n') && (strncmp(lowerCase, (unsigned char*) "no", length) == 0)) { *boolPtr = 0; } else if ((c == 't') && (strncmp(lowerCase, (unsigned char*) "true", length) == 0)) { *boolPtr = 1; } else if ((c == 'f') && (strncmp(lowerCase, (unsigned char*) "false", length) == 0)) { *boolPtr = 0; } else if ((c == 'o') && (length >= 2)) { if (strncmp(lowerCase, (unsigned char*) "on", length) == 0) { *boolPtr = 1; } else if (strncmp(lowerCase, (unsigned char*) "off", length) == 0) { *boolPtr = 0; } } else { Tcl_AppendResult(interp, "expected boolean value but got \"", string, "\"", (char *) 0); return TCL_ERROR; } return TCL_OK; } ================================================ FILE: lib/libtcl/tclglob.c ================================================ /* * tclGlob.c -- * * This file provides procedures and commands for file name * manipulation, such as tilde expansion and globbing. * * Copyright 1990-1991 Regents of the University of California * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without * fee is hereby granted, provided that the above copyright * notice appear in all copies. The University of California * makes no representations about the suitability of this * software for any purpose. It is provided "as is" without * express or implied warranty. */ #include "internal.h" #include #include #include #ifdef CROSS # include #else # include # define dirent direct #endif /* * The structure below is used to keep track of a globbing result * being built up (i.e. a partial list of file names). The list * grows dynamically to be as big as needed. */ typedef struct { char *result; /* Pointer to result area. */ int totalSpace; /* Total number of characters allocated * for result. */ int spaceUsed; /* Number of characters currently in use * to hold the partial result (not including * the terminating NULL). */ int dynamic; /* 0 means result is static space, 1 means * it's dynamic. */ } GlobResult; /* * Declarations for procedures local to this file: */ static void AppendResult (Tcl_Interp *interp, char *dir, char *separator, char *name, int nameLength); static int DoGlob (Tcl_Interp *interp, char *dir, char *rem); /* *---------------------------------------------------------------------- * * AppendResult -- * * Given two parts of a file name (directory and element within * directory), concatenate the two together and append them to * the result building up in interp. * * Results: * There is no return value. * * Side effects: * Interp->result gets extended. * *---------------------------------------------------------------------- */ static void AppendResult(interp, dir, separator, name, nameLength) Tcl_Interp *interp; /* Interpreter whose result should be * appended to. */ char *dir; /* Name of directory, without trailing * slash except for root directory. */ char *separator; /* Separator string so use between dir and * name: either "/" or "" depending on dir. */ char *name; /* Name of file withing directory (NOT * necessarily null-terminated!). */ int nameLength; /* Number of characters in name. */ { int dirFlags, nameFlags; char *p, saved; /* * Next, see if we can put together a valid list element from dir * and name by calling Tcl_AppendResult. */ if (*dir == 0) { dirFlags = 0; } else { Tcl_ScanElement(dir, &dirFlags); } saved = name[nameLength]; name[nameLength] = 0; Tcl_ScanElement(name, &nameFlags); if ((dirFlags == 0) && (nameFlags == 0)) { if (*interp->result != 0) { Tcl_AppendResult(interp, " ", dir, separator, name, (char *) NULL); } else { Tcl_AppendResult(interp, dir, separator, name, (char *) NULL); } name[nameLength] = saved; return; } /* * This name has weird characters in it, so we have to convert it to * a list element. To do that, we have to merge the characters * into a single name. To do that, malloc a buffer to hold everything. */ p = (char *) malloc((unsigned) (strlen(dir) + strlen(separator) + nameLength + 1)); sprintf(p, "%s%s%s", dir, separator, name); name[nameLength] = saved; Tcl_AppendElement(interp, p, 0); free(p); } /* *---------------------------------------------------------------------- * * DoGlob -- * * This recursive procedure forms the heart of the globbing * code. It performs a depth-first traversal of the tree * given by the path name to be globbed. * * Results: * The return value is a standard Tcl result indicating whether * an error occurred in globbing. After a normal return the * result in interp will be set to hold all of the file names * given by the dir and rem arguments. After an error the * result in interp will hold an error message. * * Side effects: * None. * *---------------------------------------------------------------------- */ static int DoGlob(interp, dir, rem) Tcl_Interp *interp; /* Interpreter to use for error * reporting (e.g. unmatched brace). */ char *dir; /* Name of a directory at which to * start glob expansion. This name * is fixed: it doesn't contain any * globbing chars. */ char *rem; /* Path to glob-expand. */ { /* * When this procedure is entered, the name to be globbed may * already have been partly expanded by ancestor invocations of * DoGlob. The part that's already been expanded is in "dir" * (this may initially be empty), and the part still to expand * is in "rem". This procedure expands "rem" one level, making * recursive calls to itself if there's still more stuff left * in the remainder. */ register char *p; register char c; char *openBrace, *closeBrace; int gotSpecial, result; char *separator; /* * Figure out whether we'll need to add a slash between the directory * name and file names within the directory when concatenating them * together. */ if ((dir[0] == 0) || ((dir[0] == '/') && (dir[1] == 0))) { separator = ""; } else { separator = "/"; } /* * When generating information for the next lower call, * use static areas if the name is short, and malloc if the name * is longer. */ #define STATIC_SIZE 200 /* * First, find the end of the next element in rem, checking * along the way for special globbing characters. */ gotSpecial = 0; openBrace = closeBrace = NULL; for (p = rem; ; p++) { c = *p; if ((c == '\0') || (c == '/')) { break; } if ((c == '{') && (openBrace == NULL)) { openBrace = p; } if ((c == '}') && (closeBrace == NULL)) { closeBrace = p; } if ((c == '*') || (c == '[') || (c == '\\') || (c == '?')) { gotSpecial = 1; } } /* * If there is an open brace in the argument, then make a recursive * call for each element between the braces. In this case, the * recursive call to DoGlob uses the same "dir" that we got. * If there are several brace-pairs in a single name, we just handle * one here, and the others will be handled in recursive calls. */ if (openBrace != NULL) { int remLength, l1, l2; char static1[STATIC_SIZE]; char *element, *newRem; if (closeBrace == NULL) { Tcl_ResetResult(interp); interp->result = "unmatched open-brace in file name"; return TCL_ERROR; } remLength = strlen(rem) + 1; if (remLength <= STATIC_SIZE) { newRem = static1; } else { newRem = (char *) malloc((unsigned) remLength); } l1 = openBrace-rem; strncpy(newRem, rem, l1); p = openBrace; for (p = openBrace; *p != '}'; ) { element = p+1; for (p = element; ((*p != '}') && (*p != ',')); p++) { /* Empty loop body: just find end of this element. */ } l2 = p - element; strncpy(newRem+l1, element, l2); strcpy(newRem+l1+l2, closeBrace+1); if (DoGlob(interp, dir, newRem) != TCL_OK) { return TCL_ERROR; } } if (remLength > STATIC_SIZE) { free(newRem); } return TCL_OK; } /* * If there were any pattern-matching characters, then scan through * the directory to find all the matching names. */ if (gotSpecial) { DIR *d; struct dirent *entryPtr; int l1, l2; char *pattern, *newDir, *dirName; char static1[STATIC_SIZE], static2[STATIC_SIZE]; struct stat statBuf; /* * Be careful not to do any actual file system operations on a * directory named ""; instead, use ".". This is needed because * some versions of UNIX don't treat "" like "." automatically. */ if (*dir == '\0') { dirName = "."; } else { dirName = dir; } if ((stat(dirName, &statBuf) != 0) || !S_ISDIR(statBuf.st_mode)) { return TCL_OK; } d = opendir(dirName); if (d == NULL) { Tcl_ResetResult(interp); Tcl_AppendResult(interp, "couldn't read directory \"", dirName, "\": ", Tcl_UnixError(interp), (char *) NULL); return TCL_ERROR; } l1 = strlen(dir); l2 = (p - rem); if (l2 < STATIC_SIZE) { pattern = static2; } else { pattern = (char *) malloc((unsigned) (l2+1)); } strncpy(pattern, rem, l2); pattern[l2] = '\0'; result = TCL_OK; while (1) { entryPtr = readdir(d); if (entryPtr == NULL) { break; } /* * Don't match names starting with "." unless the "." is * present in the pattern. */ if ((*entryPtr->d_name == '.') && (*pattern != '.')) { continue; } if (Tcl_StringMatch(entryPtr->d_name, pattern)) { int nameLength = strlen(entryPtr->d_name); if (*p == 0) { AppendResult(interp, dir, separator, entryPtr->d_name, nameLength); } else { if ((l1+nameLength+2) <= STATIC_SIZE) { newDir = static1; } else { newDir = (char *) malloc((unsigned) (l1+nameLength+2)); } sprintf(newDir, "%s%s%s", dir, separator, entryPtr->d_name); result = DoGlob(interp, newDir, p+1); if (newDir != static1) { free(newDir); } if (result != TCL_OK) { break; } } } } closedir(d); if (pattern != static2) { free(pattern); } return result; } /* * This is the simplest case: just another path element. Move * it to the dir side and recurse (or just add the name to the * list, if we're at the end of the path). */ if (*p == 0) { AppendResult(interp, dir, separator, rem, p-rem); } else { int l1, l2; char *newDir; char static1[STATIC_SIZE]; l1 = strlen(dir); l2 = l1 + (p - rem) + 2; if (l2 <= STATIC_SIZE) { newDir = static1; } else { newDir = (char *) malloc((unsigned) l2); } sprintf(newDir, "%s%s%.*s", dir, separator, (int) (p - rem), rem); result = DoGlob(interp, newDir, p+1); if (newDir != static1) { free(newDir); } if (result != TCL_OK) { return TCL_ERROR; } } return TCL_OK; } /* *---------------------------------------------------------------------- * * Tcl_TildeSubst -- * * Given a name starting with a tilde, produce a name where * the tilde and following characters have been replaced by * the home directory location for the named user. * * Results: * The result is a pointer to a static string containing * the new name. This name will only persist until the next * call to Tcl_TildeSubst; save it if you care about it for * the long term. If there was an error in processing the * tilde, then an error message is left in interp->result * and the return value is NULL. * * Side effects: * None that the caller needs to worry about. * *---------------------------------------------------------------------- */ unsigned char * Tcl_TildeSubst(interp, name) Tcl_Interp *interp; /* Interpreter in which to store error * message (if necessary). */ unsigned char *name; /* File name, which may begin with "~/" * (to indicate current user's home directory) * or "~/" (to indicate any user's * home directory). */ { #define STATIC_BUF_SIZE 50 static char staticBuf[STATIC_BUF_SIZE]; static int curSize = STATIC_BUF_SIZE; static char *curBuf = staticBuf; char *dir; int length; int fromPw = 0; register unsigned char *p; if (name[0] != '~') { return name; } /* * First, find the directory name corresponding to the tilde entry. */ if ((name[1] == '/') || (name[1] == '\0')) { dir = getenv("HOME"); if (dir == NULL) { Tcl_ResetResult(interp); Tcl_AppendResult(interp, "couldn't find HOME environment ", "variable to expand \"", name, "\"", (char *) NULL); return NULL; } p = name+1; } else { struct passwd *pwPtr; for (p = &name[1]; (*p != 0) && (*p != '/'); p++) { /* Null body; just find end of name. */ } length = p - &name[1]; if (length >= curSize) { length = curSize-1; } memcpy((void *) curBuf, (void *) (name+1), length); curBuf[length] = '\0'; pwPtr = getpwnam(curBuf); if (pwPtr == NULL) { endpwent(); Tcl_ResetResult(interp); Tcl_AppendResult(interp, "user \"", curBuf, "\" doesn't exist", (char *) NULL); return NULL; } dir = pwPtr->pw_dir; fromPw = 1; } /* * Grow the buffer if necessary to make enough space for the * full file name. */ length = strlen(dir) + strlen(p); if (length >= curSize) { if (curBuf != staticBuf) { free(curBuf); } curSize = length + 1; curBuf = (char *) malloc((unsigned) curSize); } /* * Finally, concatenate the directory name with the remainder * of the path in the buffer. */ strcpy(curBuf, dir); strcat(curBuf, p); if (fromPw) { endpwent(); } return curBuf; } /* *---------------------------------------------------------------------- * * Tcl_GlobCmd -- * * This procedure is invoked to process the "glob" Tcl command. * See the user documentation for details on what it does. * * Results: * A standard Tcl result. * * Side effects: * See the user documentation. * *---------------------------------------------------------------------- */ /* ARGSUSED */ int Tcl_GlobCmd(dummy, interp, argc, argv) void *dummy; /* Not used. */ Tcl_Interp *interp; /* Current interpreter. */ int argc; /* Number of arguments. */ unsigned char **argv; /* Argument strings. */ { int i, result, noComplain; if (argc < 2) { notEnoughArgs: Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " ?-nocomplain? name ?name ...?\"", (char *) NULL); return TCL_ERROR; } noComplain = 0; if ((argv[1][0] == '-') && (strcmp(argv[1], "-nocomplain") == 0)) { if (argc < 3) { goto notEnoughArgs; } noComplain = 1; } for (i = 1 + noComplain; i < argc; i++) { char *thisName; /* * Do special checks for names starting at the root and for * names beginning with ~. Then let DoGlob do the rest. */ thisName = argv[i]; if (*thisName == '~') { thisName = Tcl_TildeSubst(interp, thisName); if (thisName == NULL) { return TCL_ERROR; } } if (*thisName == '/') { result = DoGlob(interp, "/", thisName+1); } else { result = DoGlob(interp, "", thisName); } if (result != TCL_OK) { return result; } } if ((*interp->result == 0) && !noComplain) { char *sep = ""; Tcl_AppendResult(interp, "no files matched glob pattern", (argc == 2) ? " \"" : "s \"", (char *) NULL); for (i = 1; i < argc; i++) { Tcl_AppendResult(interp, sep, argv[i], (char *) NULL); sep = " "; } Tcl_AppendResult(interp, "\"", (char *) NULL); return TCL_ERROR; } return TCL_OK; } ================================================ FILE: lib/libtcl/tclhash.c ================================================ /* * tclHash.c -- * * Implementation of in-memory hash tables for Tcl and Tcl-based * applications. * * Copyright 1991 Regents of the University of California * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without * fee is hereby granted, provided that this copyright * notice appears in all copies. The University of California * makes no representations about the suitability of this * software for any purpose. It is provided "as is" without * express or implied warranty. */ #include "internal.h" #include /* * When there are this many entries per bucket, on average, rebuild * the hash table to make it larger. */ #define REBUILD_MULTIPLIER 3 /* * The following macro takes a preliminary integer hash value and * produces an index into a hash tables bucket list. The idea is * to make it so that preliminary values that are arbitrarily similar * will end up in different buckets. The hash function was taken * from a random-number generator. */ #define RANDOM_INDEX(tablePtr, i) \ (((((size_t) (i))*1103515245) >> (tablePtr)->downShift) & (tablePtr)->mask) /* * Procedure prototypes for static procedures in this file: */ static Tcl_HashEntry * ArrayFind (Tcl_HashTable *tablePtr, unsigned char *key); static Tcl_HashEntry * ArrayCreate (Tcl_HashTable *tablePtr, unsigned char *key, int *newPtr); static Tcl_HashEntry * BogusFind (Tcl_HashTable *tablePtr, unsigned char *key); static Tcl_HashEntry * BogusCreate (Tcl_HashTable *tablePtr, unsigned char *key, int *newPtr); static unsigned int HashString (unsigned char *string); static void RebuildTable (Tcl_HashTable *tablePtr); static Tcl_HashEntry * StringFind (Tcl_HashTable *tablePtr, unsigned char *key); static Tcl_HashEntry * StringCreate (Tcl_HashTable *tablePtr, unsigned char *key, int *newPtr); static Tcl_HashEntry * OneWordFind (Tcl_HashTable *tablePtr, unsigned char *key); static Tcl_HashEntry * OneWordCreate (Tcl_HashTable *tablePtr, unsigned char *key, int *newPtr); /* *---------------------------------------------------------------------- * * Tcl_InitHashTable -- * * Given storage for a hash table, set up the fields to prepare * the hash table for use. * * Results: * None. * * Side effects: * TablePtr is now ready to be passed to Tcl_FindHashEntry and * Tcl_CreateHashEntry. * *---------------------------------------------------------------------- */ void Tcl_InitHashTable(Tcl_HashTable *tablePtr, /* Pointer to table record, which * is supplied by the caller. */ int keyType) /* Type of keys to use in table: * TCL_STRING_KEYS, TCL_ONE_WORD_KEYS, * or an integer >= 2. */ { tablePtr->buckets = tablePtr->staticBuckets; tablePtr->staticBuckets[0] = tablePtr->staticBuckets[1] = 0; tablePtr->staticBuckets[2] = tablePtr->staticBuckets[3] = 0; tablePtr->numBuckets = TCL_SMALL_HASH_TABLE; tablePtr->numEntries = 0; tablePtr->rebuildSize = TCL_SMALL_HASH_TABLE*REBUILD_MULTIPLIER; tablePtr->downShift = 28; tablePtr->mask = 3; tablePtr->keyType = keyType; if (keyType == TCL_STRING_KEYS) { tablePtr->findProc = StringFind; tablePtr->createProc = StringCreate; } else if (keyType == TCL_ONE_WORD_KEYS) { tablePtr->findProc = OneWordFind; tablePtr->createProc = OneWordCreate; } else { tablePtr->findProc = ArrayFind; tablePtr->createProc = ArrayCreate; }; } /* *---------------------------------------------------------------------- * * Tcl_DeleteHashEntry -- * * Remove a single entry from a hash table. * * Results: * None. * * Side effects: * The entry given by entryPtr is deleted from its table and * should never again be used by the caller. It is up to the * caller to free the clientData field of the entry, if that * is relevant. * *---------------------------------------------------------------------- */ void Tcl_DeleteHashEntry(entryPtr) Tcl_HashEntry *entryPtr; { register Tcl_HashEntry *prevPtr; if (*entryPtr->bucketPtr == entryPtr) { *entryPtr->bucketPtr = entryPtr->nextPtr; } else { for (prevPtr = *entryPtr->bucketPtr; ; prevPtr = prevPtr->nextPtr) { assert (prevPtr != 0); if (prevPtr->nextPtr == entryPtr) { prevPtr->nextPtr = entryPtr->nextPtr; break; } } } entryPtr->tablePtr->numEntries--; free (entryPtr); } /* *---------------------------------------------------------------------- * * Tcl_DeleteHashTable -- * * Free up everything associated with a hash table except for * the record for the table itself. * * Results: * None. * * Side effects: * The hash table is no longer useable. * *---------------------------------------------------------------------- */ void Tcl_DeleteHashTable(tablePtr) register Tcl_HashTable *tablePtr; /* Table to delete. */ { register Tcl_HashEntry *hPtr, *nextPtr; int i; /* * Free up all the entries in the table. */ for (i = 0; i < tablePtr->numBuckets; i++) { hPtr = tablePtr->buckets[i]; while (hPtr != 0) { nextPtr = hPtr->nextPtr; free (hPtr); hPtr = nextPtr; } } /* * Free up the bucket array, if it was dynamically allocated. */ if (tablePtr->buckets != tablePtr->staticBuckets) { free (tablePtr->buckets); } /* * Arrange for panics if the table is used again without * re-initialization. */ tablePtr->findProc = BogusFind; tablePtr->createProc = BogusCreate; } /* *---------------------------------------------------------------------- * * Tcl_FirstHashEntry -- * * Locate the first entry in a hash table and set up a record * that can be used to step through all the remaining entries * of the table. * * Results: * The return value is a pointer to the first entry in tablePtr, * or NULL if tablePtr has no entries in it. The memory at * *searchPtr is initialized so that subsequent calls to * Tcl_NextHashEntry will return all of the entries in the table, * one at a time. * * Side effects: * None. * *---------------------------------------------------------------------- */ Tcl_HashEntry * Tcl_FirstHashEntry(tablePtr, searchPtr) Tcl_HashTable *tablePtr; /* Table to search. */ Tcl_HashSearch *searchPtr; /* Place to store information about * progress through the table. */ { searchPtr->tablePtr = tablePtr; searchPtr->nextIndex = 0; searchPtr->nextEntryPtr = 0; return Tcl_NextHashEntry(searchPtr); } /* *---------------------------------------------------------------------- * * Tcl_NextHashEntry -- * * Once a hash table enumeration has been initiated by calling * Tcl_FirstHashEntry, this procedure may be called to return * successive elements of the table. * * Results: * The return value is the next entry in the hash table being * enumerated, or NULL if the end of the table is reached. * * Side effects: * None. * *---------------------------------------------------------------------- */ Tcl_HashEntry * Tcl_NextHashEntry(searchPtr) register Tcl_HashSearch *searchPtr; /* Place to store information about * progress through the table. Must * have been initialized by calling * Tcl_FirstHashEntry. */ { Tcl_HashEntry *hPtr; while (searchPtr->nextEntryPtr == 0) { if (searchPtr->nextIndex >= searchPtr->tablePtr->numBuckets) { return 0; } searchPtr->nextEntryPtr = searchPtr->tablePtr->buckets[searchPtr->nextIndex]; searchPtr->nextIndex++; } hPtr = searchPtr->nextEntryPtr; searchPtr->nextEntryPtr = hPtr->nextPtr; return hPtr; } /* *---------------------------------------------------------------------- * * Tcl_HashStats -- * * Return statistics describing the layout of the hash table * in its hash buckets. * * Results: * The return value is a malloc-ed string containing information * about tablePtr. It is the caller's responsibility to free * this string. * * Side effects: * None. * *---------------------------------------------------------------------- */ unsigned char * Tcl_HashStats (Tcl_HashTable *tablePtr) /* Table for which to produce stats. */ { #define NUM_COUNTERS 10 int count[NUM_COUNTERS], overflow, i, j, size; /* double average, tmp;*/ register Tcl_HashEntry *hPtr; unsigned char *result, *p; /* * Compute a histogram of bucket usage. */ memset (count, 0, sizeof (count)); overflow = 0; /* average = 0.0;*/ for (i = 0; i < tablePtr->numBuckets; i++) { j = 0; for (hPtr = tablePtr->buckets[i]; hPtr != 0; hPtr = hPtr->nextPtr) { j++; } if (j < NUM_COUNTERS) { count[j]++; } else { overflow++; } /* tmp = j;*/ /* average += (tmp+1.0)*(tmp/tablePtr->numEntries)/2.0;*/ } /* * Print out the histogram and a few other pieces of information. */ size = NUM_COUNTERS*60 + 300; result = malloc (size); sprintf(result, "%d entries in table, %d buckets\n", tablePtr->numEntries, tablePtr->numBuckets); p = result + strlen(result); for (i = 0; i < NUM_COUNTERS; i++) { sprintf(p, "number of buckets with %d entries: %d\n", i, count[i]); p += strlen(p); } sprintf(p, "number of buckets with more %d or more entries: %d", NUM_COUNTERS, overflow); /* p += strlen(p);*/ /* sprintf(p, "\naverage search distance for entry: %.1f", average);*/ return result; } /* *---------------------------------------------------------------------- * * HashString -- * * Compute a one-word summary of a text string, which can be * used to generate a hash index. * * Results: * The return value is a one-word summary of the information in * string. * * Side effects: * None. * *---------------------------------------------------------------------- */ static unsigned int HashString(string) register unsigned char *string; /* String from which to compute hash value. */ { register unsigned int result; register int c; /* * I tried a zillion different hash functions and asked many other * people for advice. Many people had their own favorite functions, * all different, but no-one had much idea why they were good ones. * I chose the one below (multiply by 9 and add new character) * because of the following reasons: * * 1. Multiplying by 10 is perfect for keys that are decimal strings, * and multiplying by 9 is just about as good. * 2. Times-9 is (shift-left-3) plus (old). This means that each * character's bits hang around in the low-order bits of the * hash value for ever, plus they spread fairly rapidly up to * the high-order bits to fill out the hash value. This seems * works well both for decimal and non-decimal strings. */ result = 0; while (1) { c = *string; string++; if (c == 0) { break; } result += (result<<3) + c; } return result; } /* *---------------------------------------------------------------------- * * StringFind -- * * Given a hash table with string keys, and a string key, find * the entry with a matching key. * * Results: * The return value is a token for the matching entry in the * hash table, or NULL if there was no matching entry. * * Side effects: * None. * *---------------------------------------------------------------------- */ static Tcl_HashEntry * StringFind(tablePtr, key) Tcl_HashTable *tablePtr; /* Table in which to lookup entry. */ unsigned char *key; /* Key to use to find matching entry. */ { register Tcl_HashEntry *hPtr; register unsigned char *p1, *p2; int index; index = HashString(key) & tablePtr->mask; /* * Search all of the entries in the appropriate bucket. */ for (hPtr = tablePtr->buckets[index]; hPtr != 0; hPtr = hPtr->nextPtr) { for (p1 = key, p2 = hPtr->key.string; ; p1++, p2++) { if (*p1 != *p2) { break; } if (*p1 == '\0') { return hPtr; } } } return 0; } /* *---------------------------------------------------------------------- * * StringCreate -- * * Given a hash table with string keys, and a string key, find * the entry with a matching key. If there is no matching entry, * then create a new entry that does match. * * Results: * The return value is a pointer to the matching entry. If this * is a newly-created entry, then *newPtr will be set to a non-zero * value; otherwise *newPtr will be set to 0. If this is a new * entry the value stored in the entry will initially be 0. * * Side effects: * A new entry may be added to the hash table. * *---------------------------------------------------------------------- */ static Tcl_HashEntry * StringCreate(tablePtr, key, newPtr) Tcl_HashTable *tablePtr; /* Table in which to lookup entry. */ unsigned char *key; /* Key to use to find or create matching * entry. */ int *newPtr; /* Store info here telling whether a new * entry was created. */ { register Tcl_HashEntry *hPtr; register unsigned char *p1, *p2; int index; index = HashString(key) & tablePtr->mask; /* * Search all of the entries in this bucket. */ for (hPtr = tablePtr->buckets[index]; hPtr != 0; hPtr = hPtr->nextPtr) { for (p1 = key, p2 = hPtr->key.string; ; p1++, p2++) { if (*p1 != *p2) { break; } if (*p1 == '\0') { *newPtr = 0; return hPtr; } } } /* * Entry not found. Add a new one to the bucket. */ *newPtr = 1; hPtr = (Tcl_HashEntry*) malloc ((unsigned) (sizeof(Tcl_HashEntry) + strlen(key) - (sizeof(hPtr->key) -1))); hPtr->tablePtr = tablePtr; hPtr->bucketPtr = &(tablePtr->buckets[index]); hPtr->nextPtr = *hPtr->bucketPtr; hPtr->clientData = 0; strcpy(hPtr->key.string, key); *hPtr->bucketPtr = hPtr; tablePtr->numEntries++; /* * If the table has exceeded a decent size, rebuild it with many * more buckets. */ if (tablePtr->numEntries >= tablePtr->rebuildSize) { RebuildTable(tablePtr); } return hPtr; } /* *---------------------------------------------------------------------- * * OneWordFind -- * * Given a hash table with one-word keys, and a one-word key, find * the entry with a matching key. * * Results: * The return value is a token for the matching entry in the * hash table, or NULL if there was no matching entry. * * Side effects: * None. * *---------------------------------------------------------------------- */ static Tcl_HashEntry * OneWordFind(tablePtr, key) Tcl_HashTable *tablePtr; /* Table in which to lookup entry. */ register unsigned char *key; /* Key to use to find matching entry. */ { register Tcl_HashEntry *hPtr; int index; index = RANDOM_INDEX(tablePtr, key); /* * Search all of the entries in the appropriate bucket. */ for (hPtr = tablePtr->buckets[index]; hPtr != 0; hPtr = hPtr->nextPtr) { if (hPtr->key.oneWordValue == key) { return hPtr; } } return 0; } /* *---------------------------------------------------------------------- * * OneWordCreate -- * * Given a hash table with one-word keys, and a one-word key, find * the entry with a matching key. If there is no matching entry, * then create a new entry that does match. * * Results: * The return value is a pointer to the matching entry. If this * is a newly-created entry, then *newPtr will be set to a non-zero * value; otherwise *newPtr will be set to 0. If this is a new * entry the value stored in the entry will initially be 0. * * Side effects: * A new entry may be added to the hash table. * *---------------------------------------------------------------------- */ static Tcl_HashEntry * OneWordCreate(tablePtr, key, newPtr) Tcl_HashTable *tablePtr; /* Table in which to lookup entry. */ register unsigned char *key; /* Key to use to find or create matching * entry. */ int *newPtr; /* Store info here telling whether a new * entry was created. */ { register Tcl_HashEntry *hPtr; int index; index = RANDOM_INDEX(tablePtr, key); /* * Search all of the entries in this bucket. */ for (hPtr = tablePtr->buckets[index]; hPtr != 0; hPtr = hPtr->nextPtr) { if (hPtr->key.oneWordValue == key) { *newPtr = 0; return hPtr; } } /* * Entry not found. Add a new one to the bucket. */ *newPtr = 1; hPtr = (Tcl_HashEntry*) malloc (sizeof(Tcl_HashEntry)); hPtr->tablePtr = tablePtr; hPtr->bucketPtr = &(tablePtr->buckets[index]); hPtr->nextPtr = *hPtr->bucketPtr; hPtr->clientData = 0; hPtr->key.oneWordValue = key; *hPtr->bucketPtr = hPtr; tablePtr->numEntries++; /* * If the table has exceeded a decent size, rebuild it with many * more buckets. */ if (tablePtr->numEntries >= tablePtr->rebuildSize) { RebuildTable(tablePtr); } return hPtr; } /* *---------------------------------------------------------------------- * * ArrayFind -- * * Given a hash table with array-of-int keys, and a key, find * the entry with a matching key. * * Results: * The return value is a token for the matching entry in the * hash table, or NULL if there was no matching entry. * * Side effects: * None. * *---------------------------------------------------------------------- */ static Tcl_HashEntry * ArrayFind(tablePtr, key) Tcl_HashTable *tablePtr; /* Table in which to lookup entry. */ unsigned char *key; /* Key to use to find matching entry. */ { register Tcl_HashEntry *hPtr; int *arrayPtr = (int *) key; register int *iPtr1, *iPtr2; int index, count; for (index = 0, count = tablePtr->keyType, iPtr1 = arrayPtr; count > 0; count--, iPtr1++) { index += *iPtr1; } index = RANDOM_INDEX(tablePtr, index); /* * Search all of the entries in the appropriate bucket. */ for (hPtr = tablePtr->buckets[index]; hPtr != 0; hPtr = hPtr->nextPtr) { for (iPtr1 = arrayPtr, iPtr2 = hPtr->key.words, count = tablePtr->keyType; ; count--, iPtr1++, iPtr2++) { if (count == 0) { return hPtr; } if (*iPtr1 != *iPtr2) { break; } } } return 0; } /* *---------------------------------------------------------------------- * * ArrayCreate -- * * Given a hash table with one-word keys, and a one-word key, find * the entry with a matching key. If there is no matching entry, * then create a new entry that does match. * * Results: * The return value is a pointer to the matching entry. If this * is a newly-created entry, then *newPtr will be set to a non-zero * value; otherwise *newPtr will be set to 0. If this is a new * entry the value stored in the entry will initially be 0. * * Side effects: * A new entry may be added to the hash table. * *---------------------------------------------------------------------- */ static Tcl_HashEntry * ArrayCreate(tablePtr, key, newPtr) Tcl_HashTable *tablePtr; /* Table in which to lookup entry. */ register unsigned char *key; /* Key to use to find or create matching * entry. */ int *newPtr; /* Store info here telling whether a new * entry was created. */ { register Tcl_HashEntry *hPtr; int *arrayPtr = (int *) key; register int *iPtr1, *iPtr2; int index, count; for (index = 0, count = tablePtr->keyType, iPtr1 = arrayPtr; count > 0; count--, iPtr1++) { index += *iPtr1; } index = RANDOM_INDEX(tablePtr, index); /* * Search all of the entries in the appropriate bucket. */ for (hPtr = tablePtr->buckets[index]; hPtr != 0; hPtr = hPtr->nextPtr) { for (iPtr1 = arrayPtr, iPtr2 = hPtr->key.words, count = tablePtr->keyType; ; count--, iPtr1++, iPtr2++) { if (count == 0) { *newPtr = 0; return hPtr; } if (*iPtr1 != *iPtr2) { break; } } } /* * Entry not found. Add a new one to the bucket. */ *newPtr = 1; hPtr = (Tcl_HashEntry*) malloc ((unsigned) (sizeof(Tcl_HashEntry) + (tablePtr->keyType*sizeof(int)) - 4)); hPtr->tablePtr = tablePtr; hPtr->bucketPtr = &(tablePtr->buckets[index]); hPtr->nextPtr = *hPtr->bucketPtr; hPtr->clientData = 0; for (iPtr1 = arrayPtr, iPtr2 = hPtr->key.words, count = tablePtr->keyType; count > 0; count--, iPtr1++, iPtr2++) { *iPtr2 = *iPtr1; } *hPtr->bucketPtr = hPtr; tablePtr->numEntries++; /* * If the table has exceeded a decent size, rebuild it with many * more buckets. */ if (tablePtr->numEntries >= tablePtr->rebuildSize) { RebuildTable(tablePtr); } return hPtr; } /* *---------------------------------------------------------------------- * * BogusFind -- * * This procedure is invoked when an Tcl_FindHashEntry is called * on a table that has been deleted. * * Results: * If panic returns (which it shouldn't) this procedure returns * NULL. * * Side effects: * Generates a panic. * *---------------------------------------------------------------------- */ /* ARGSUSED */ static Tcl_HashEntry * BogusFind(tablePtr, key) Tcl_HashTable *tablePtr; /* Table in which to lookup entry. */ unsigned char *key; /* Key to use to find matching entry. */ { assert (0); return 0; } /* *---------------------------------------------------------------------- * * BogusCreate -- * * This procedure is invoked when an Tcl_CreateHashEntry is called * on a table that has been deleted. * * Results: * If panic returns (which it shouldn't) this procedure returns * NULL. * * Side effects: * Generates a panic. * *---------------------------------------------------------------------- */ /* ARGSUSED */ static Tcl_HashEntry * BogusCreate(tablePtr, key, newPtr) Tcl_HashTable *tablePtr; /* Table in which to lookup entry. */ unsigned char *key; /* Key to use to find or create matching * entry. */ int *newPtr; /* Store info here telling whether a new * entry was created. */ { assert (0); return 0; } /* *---------------------------------------------------------------------- * * RebuildTable -- * * This procedure is invoked when the ratio of entries to hash * buckets becomes too large. It creates a new table with a * larger bucket array and moves all of the entries into the * new table. * * Results: * None. * * Side effects: * Memory gets reallocated and entries get re-hashed to new * buckets. * *---------------------------------------------------------------------- */ static void RebuildTable(tablePtr) register Tcl_HashTable *tablePtr; /* Table to enlarge. */ { int oldSize, count, index; Tcl_HashEntry **oldBuckets; register Tcl_HashEntry **oldChainPtr, **newChainPtr; register Tcl_HashEntry *hPtr; oldSize = tablePtr->numBuckets; oldBuckets = tablePtr->buckets; /* * Allocate and initialize the new bucket array, and set up * hashing constants for new array size. */ tablePtr->numBuckets *= 4; tablePtr->buckets = (Tcl_HashEntry**) malloc ((unsigned) (tablePtr->numBuckets * sizeof(Tcl_HashEntry *))); for (count = tablePtr->numBuckets, newChainPtr = tablePtr->buckets; count > 0; count--, newChainPtr++) { *newChainPtr = 0; } tablePtr->rebuildSize *= 4; tablePtr->downShift -= 2; tablePtr->mask = (tablePtr->mask << 2) + 3; /* * Rehash all of the existing entries into the new bucket array. */ for (oldChainPtr = oldBuckets; oldSize > 0; oldSize--, oldChainPtr++) { for (hPtr = *oldChainPtr; hPtr != 0; hPtr = *oldChainPtr) { *oldChainPtr = hPtr->nextPtr; if (tablePtr->keyType == TCL_STRING_KEYS) { index = HashString(hPtr->key.string) & tablePtr->mask; } else if (tablePtr->keyType == TCL_ONE_WORD_KEYS) { index = RANDOM_INDEX(tablePtr, hPtr->key.oneWordValue); } else { register int *iPtr; int count; for (index = 0, count = tablePtr->keyType, iPtr = hPtr->key.words; count > 0; count--, iPtr++) { index += *iPtr; } index = RANDOM_INDEX(tablePtr, index); } hPtr->bucketPtr = &(tablePtr->buckets[index]); hPtr->nextPtr = *hPtr->bucketPtr; *hPtr->bucketPtr = hPtr; } } /* * Free up the old bucket array, if it was dynamically allocated. */ if (oldBuckets != tablePtr->staticBuckets) { free (oldBuckets); } } ================================================ FILE: lib/libtcl/tclparse.c ================================================ /* * tclParse.c -- * * This file contains a collection of procedures that are used * to parse Tcl commands or parts of commands (like quoted * strings or nested sub-commands). * * Copyright 1991 Regents of the University of California. * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without * fee is hereby granted, provided that the above copyright * notice appear in all copies. The University of California * makes no representations about the suitability of this * software for any purpose. It is provided "as is" without * express or implied warranty. */ #include "internal.h" /* * A table used to classify input characters to assist in parsing * Tcl commands. The table should be indexed with a signed character * using the CHAR_TYPE macro. The character may have a negative * value. */ #define CHAR_TYPE(c) tclTypeTable [(unsigned char)(c)] /* * The following table assigns a type to each character. Only types * meaningful to Tcl parsing are represented here. The table indexes * all 256 characters, with the negative ones first, then the positive * ones. */ static const char tclTypeTable[] = { /*0*/ TCL_COMMAND_END, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_SPACE, TCL_COMMAND_END, TCL_SPACE, TCL_SPACE, TCL_SPACE, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, /*32*/ TCL_SPACE, TCL_NORMAL, TCL_QUOTE, TCL_NORMAL, TCL_DOLLAR, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_COMMAND_END, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, /*64*/ TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_OPEN_BRACKET, TCL_BACKSLASH, TCL_COMMAND_END, TCL_NORMAL, TCL_NORMAL, /*96*/ TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_OPEN_BRACE, TCL_NORMAL, TCL_CLOSE_BRACE, TCL_NORMAL, TCL_NORMAL, /*-128*/ TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, /*-96*/ TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, /*-64*/ TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, /*-32*/ TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, TCL_NORMAL, }; /* * Function prototypes for procedures local to this file: */ static unsigned char * QuoteEnd (unsigned char *string, int term); static unsigned char * VarNameEnd (unsigned char *string); /* *---------------------------------------------------------------------- * * Tcl_Backslash -- * * Figure out how to handle a backslash sequence. * * Results: * The return value is the character that should be substituted * in place of the backslash sequence that starts at src, or 0 * if the backslash sequence should be replace by nothing (e.g. * backslash followed by newline). If readPtr isn't NULL then * it is filled in with a count of the number of characters in * the backslash sequence. Note: if the backslash isn't followed * by characters that are understood here, then the backslash * sequence is only considered to be one character long, and it * is replaced by a backslash char. * * Side effects: * None. * *---------------------------------------------------------------------- */ char Tcl_Backslash(src, readPtr) unsigned char *src; /* Points to the backslash character of * a backslash sequence. */ int *readPtr; /* Fill in with number of characters read * from src, unless NULL. */ { register unsigned char *p = src+1; char result; int count; count = 2; switch (*p) { case 'b': result = '\b'; break; case 'e': result = 033; break; case 'f': result = '\f'; break; case 'n': result = '\n'; break; case 'r': result = '\r'; break; case 't': result = '\t'; break; case 'v': result = '\v'; break; case 'C': p++; if (isspace(*p) || (*p == 0)) { result = 'C'; count = 1; break; } count = 3; if (*p == 'M') { p++; if (isspace(*p) || (*p == 0)) { result = 'M' & 037; break; } count = 4; result = (*p & 037) | '\200'; break; } count = 3; result = *p & 037; break; case 'M': p++; if (isspace(*p) || (*p == 0)) { result = 'M'; count = 1; break; } count = 3; result = *p + '\200'; break; case '}': case '{': case ']': case '[': case '$': case ' ': case ';': case '"': case '\\': result = *p; break; case '\n': result = 0; break; default: if (isdigit(*p)) { result = *p - '0'; p++; if (!isdigit(*p)) { break; } count = 3; result = (result << 3) + (*p - '0'); p++; if (!isdigit(*p)) { break; } count = 4; result = (result << 3) + (*p - '0'); break; } result = '\\'; count = 1; break; } if (readPtr != 0) { *readPtr = count; } return result; } /* *-------------------------------------------------------------- * * TclParseQuotes -- * * This procedure parses a double-quoted string such as a * quoted Tcl command argument or a quoted value in a Tcl * expression. This procedure is also used to parse array * element names within parentheses, or anything else that * needs all the substitutions that happen in quotes. * * Results: * The return value is a standard Tcl result, which is * TCL_OK unless there was an error while parsing the * quoted string. If an error occurs then interp->result * contains a standard error message. *TermPtr is filled * in with the address of the character just after the * last one successfully processed; this is usually the * character just after the matching close-quote. The * fully-substituted contents of the quotes are stored in * standard fashion in *pvPtr, null-terminated with * pvPtr->next pointing to the terminating null character. * * Side effects: * The buffer space in pvPtr may be enlarged by calling its * expandProc. * *-------------------------------------------------------------- */ int TclParseQuotes(interp, string, termChar, flags, termPtr, pvPtr) Tcl_Interp *interp; /* Interpreter to use for nested command * evaluations and error messages. */ unsigned char *string; /* Character just after opening double- * quote. */ int termChar; /* Character that terminates "quoted" string * (usually double-quote, but sometimes * right-paren or something else). */ int flags; /* Flags to pass to nested Tcl_Eval calls. */ unsigned char **termPtr; /* Store address of terminating character * here. */ ParseValue *pvPtr; /* Information about where to place * fully-substituted result of parse. */ { register unsigned char *src, *dst, c; src = string; dst = pvPtr->next; while (1) { if (dst == pvPtr->end) { /* * Target buffer space is about to run out. Make more space. */ pvPtr->next = dst; (*pvPtr->expandProc) (pvPtr, 1); dst = pvPtr->next; } c = *src; src++; if (c == termChar) { *dst = '\0'; pvPtr->next = dst; *termPtr = src; return TCL_OK; } else if (CHAR_TYPE(c) == TCL_NORMAL) { copy: *dst = c; dst++; continue; } else if (c == '$') { int length; unsigned char *value; value = Tcl_ParseVar(interp, src-1, termPtr); if (value == 0) { return TCL_ERROR; } src = *termPtr; length = strlen(value); if ((pvPtr->end - dst) <= length) { pvPtr->next = dst; (*pvPtr->expandProc) (pvPtr, length); dst = pvPtr->next; } strcpy(dst, value); dst += length; continue; } else if (c == '[') { int result; pvPtr->next = dst; result = TclParseNestedCmd(interp, src, flags, termPtr, pvPtr); if (result != TCL_OK) { return result; } src = *termPtr; dst = pvPtr->next; continue; } else if (c == '\\') { int numRead; src--; *dst = Tcl_Backslash(src, &numRead); if (*dst != 0) { dst++; } src += numRead; continue; } else if (c == '\0') { Tcl_ResetResult(interp); sprintf(interp->result, "missing %c", termChar); *termPtr = string-1; return TCL_ERROR; } else { goto copy; } } } /* *-------------------------------------------------------------- * * TclParseNestedCmd -- * * This procedure parses a nested Tcl command between * brackets, returning the result of the command. * * Results: * The return value is a standard Tcl result, which is * TCL_OK unless there was an error while executing the * nested command. If an error occurs then interp->result * contains a standard error message. *TermPtr is filled * in with the address of the character just after the * last one processed; this is usually the character just * after the matching close-bracket, or the null character * at the end of the string if the close-bracket was missing * (a missing close bracket is an error). The result returned * by the command is stored in standard fashion in *pvPtr, * null-terminated, with pvPtr->next pointing to the null * character. * * Side effects: * The storage space at *pvPtr may be expanded. * *-------------------------------------------------------------- */ int TclParseNestedCmd(interp, string, flags, termPtr, pvPtr) Tcl_Interp *interp; /* Interpreter to use for nested command * evaluations and error messages. */ unsigned char *string; /* Character just after opening bracket. */ int flags; /* Flags to pass to nested Tcl_Eval. */ unsigned char **termPtr; /* Store address of terminating character * here. */ register ParseValue *pvPtr; /* Information about where to place * result of command. */ { int result, length, shortfall; Interp *iPtr = (Interp *) interp; result = Tcl_Eval(interp, string, flags | TCL_BRACKET_TERM, termPtr); if (result != TCL_OK) { /* * The increment below results in slightly cleaner message in * the errorInfo variable (the close-bracket will appear). */ if (**termPtr == ']') { *termPtr += 1; } return result; } (*termPtr) += 1; length = strlen(iPtr->result); shortfall = length + 1 - (pvPtr->end - pvPtr->next); if (shortfall > 0) { (*pvPtr->expandProc) (pvPtr, shortfall); } strcpy(pvPtr->next, iPtr->result); pvPtr->next += length; Tcl_FreeResult ((Tcl_Interp*) iPtr); iPtr->result = iPtr->resultSpace; iPtr->resultSpace[0] = '\0'; return TCL_OK; } /* *-------------------------------------------------------------- * * TclParseBraces -- * * This procedure scans the information between matching * curly braces. * * Results: * The return value is a standard Tcl result, which is * TCL_OK unless there was an error while parsing string. * If an error occurs then interp->result contains a * standard error message. *TermPtr is filled * in with the address of the character just after the * last one successfully processed; this is usually the * character just after the matching close-brace. The * information between curly braces is stored in standard * fashion in *pvPtr, null-terminated with pvPtr->next * pointing to the terminating null character. * * Side effects: * The storage space at *pvPtr may be expanded. * *-------------------------------------------------------------- */ int TclParseBraces(interp, string, termPtr, pvPtr) Tcl_Interp *interp; /* Interpreter to use for nested command * evaluations and error messages. */ unsigned char *string; /* Character just after opening bracket. */ unsigned char **termPtr; /* Store address of terminating character * here. */ register ParseValue *pvPtr; /* Information about where to place * result of command. */ { int level; register unsigned char *src, *dst, *end; register char c; src = string; dst = pvPtr->next; end = pvPtr->end; level = 1; /* * Copy the characters one at a time to the result area, stopping * when the matching close-brace is found. */ while (1) { c = *src; src++; if (dst == end) { pvPtr->next = dst; (*pvPtr->expandProc) (pvPtr, 20); dst = pvPtr->next; end = pvPtr->end; } *dst = c; dst++; if (CHAR_TYPE(c) == TCL_NORMAL) { continue; } else if (c == '{') { level++; } else if (c == '}') { level--; if (level == 0) { dst--; /* Don't copy the last close brace. */ break; } } else if (c == '\\') { int count; /* * Must always squish out backslash-newlines, even when in * braces. This is needed so that this sequence can appear * anywhere in a command, such as the middle of an expression. */ if (*src == '\n') { dst--; src++; } else { (void) Tcl_Backslash(src-1, &count); while (count > 1) { if (dst == end) { pvPtr->next = dst; (*pvPtr->expandProc) (pvPtr, 20); dst = pvPtr->next; end = pvPtr->end; } *dst = *src; dst++; src++; count--; } } } else if (c == '\0') { Tcl_SetResult(interp, (unsigned char*) "missing close-brace", TCL_STATIC); *termPtr = string-1; return TCL_ERROR; } } *dst = '\0'; pvPtr->next = dst; *termPtr = src; return TCL_OK; } /* *-------------------------------------------------------------- * * TclParseWords -- * * This procedure parses one or more words from a command * string and creates argv-style pointers to fully-substituted * copies of those words. * * Results: * The return value is a standard Tcl result. * * *argcPtr is modified to hold a count of the number of words * successfully parsed, which may be 0. At most maxWords words * will be parsed. If 0 <= *argcPtr < maxWords then it * means that a command separator was seen. If *argcPtr * is maxWords then it means that a command separator was * not seen yet. * * *TermPtr is filled in with the address of the character * just after the last one successfully processed in the * last word. This is either the command terminator (if * *argcPtr < maxWords), the character just after the last * one in a word (if *argcPtr is maxWords), or the vicinity * of an error (if the result is not TCL_OK). * * The pointers at *argv are filled in with pointers to the * fully-substituted words, and the actual contents of the * words are copied to the buffer at pvPtr. * * If an error occurrs then an error message is left in * interp->result and the information at *argv, *argcPtr, * and *pvPtr may be incomplete. * * Side effects: * The buffer space in pvPtr may be enlarged by calling its * expandProc. * *-------------------------------------------------------------- */ int TclParseWords(interp, string, flags, maxWords, termPtr, argcPtr, argv, pvPtr) Tcl_Interp *interp; /* Interpreter to use for nested command * evaluations and error messages. */ unsigned char *string; /* First character of word. */ int flags; /* Flags to control parsing (same values as * passed to Tcl_Eval). */ int maxWords; /* Maximum number of words to parse. */ unsigned char **termPtr; /* Store address of terminating character * here. */ int *argcPtr; /* Filled in with actual number of words * parsed. */ unsigned char **argv; /* Store addresses of individual words here. */ register ParseValue *pvPtr; /* Information about where to place * fully-substituted word. */ { register unsigned char *src, *dst; register char c; int type, result, argc; unsigned char *oldBuffer; /* Used to detect when pvPtr's buffer gets * reallocated, so we can adjust all of the * argv pointers. */ src = string; oldBuffer = pvPtr->buffer; dst = pvPtr->next; for (argc = 0; argc < maxWords; argc++) { argv[argc] = dst; /* * Skip leading space. */ skipSpace: c = *src; type = CHAR_TYPE(c); while (type == TCL_SPACE) { src++; c = *src; type = CHAR_TYPE(c); } /* * Handle the normal case (i.e. no leading double-quote or brace). */ if (type == TCL_NORMAL) { normalArg: while (1) { if (dst == pvPtr->end) { /* * Target buffer space is about to run out. Make * more space. */ pvPtr->next = dst; (*pvPtr->expandProc) (pvPtr, 1); dst = pvPtr->next; } if (type == TCL_NORMAL) { copy: *dst = c; dst++; src++; } else if (type == TCL_SPACE) { goto wordEnd; } else if (type == TCL_DOLLAR) { int length; unsigned char *value; value = Tcl_ParseVar(interp, src, termPtr); if (value == 0) { return TCL_ERROR; } src = *termPtr; length = strlen(value); if ((pvPtr->end - dst) <= length) { pvPtr->next = dst; (*pvPtr->expandProc) (pvPtr, length); dst = pvPtr->next; } strcpy(dst, value); dst += length; } else if (type == TCL_COMMAND_END) { if ((c == ']') && !(flags & TCL_BRACKET_TERM)) { goto copy; } /* * End of command; simulate a word-end first, so * that the end-of-command can be processed as the * first thing in a new word. */ goto wordEnd; } else if (type == TCL_OPEN_BRACKET) { pvPtr->next = dst; result = TclParseNestedCmd(interp, src+1, flags, termPtr, pvPtr); if (result != TCL_OK) { return result; } src = *termPtr; dst = pvPtr->next; } else if (type == TCL_BACKSLASH) { int numRead; *dst = Tcl_Backslash(src, &numRead); if (*dst != 0) { dst++; } src += numRead; } else { goto copy; } c = *src; type = CHAR_TYPE(c); } } else { /* * Check for the end of the command. */ if (type == TCL_COMMAND_END) { if (flags & TCL_BRACKET_TERM) { if (c == '\0') { Tcl_SetResult(interp, (unsigned char*) "missing close-bracket", TCL_STATIC); return TCL_ERROR; } } else { if (c == ']') { goto normalArg; } } goto done; } /* * Now handle the special cases: open braces, double-quotes, * and backslash-newline. */ pvPtr->next = dst; if (type == TCL_QUOTE) { result = TclParseQuotes(interp, src+1, '"', flags, termPtr, pvPtr); } else if (type == TCL_OPEN_BRACE) { result = TclParseBraces(interp, src+1, termPtr, pvPtr); } else if ((type == TCL_BACKSLASH) && (src[1] == '\n')) { src += 2; goto skipSpace; } else { goto normalArg; } if (result != TCL_OK) { return result; } /* * Back from quotes or braces; make sure that the terminating * character was the end of the word. Have to be careful here * to handle continuation lines (i.e. lines ending in backslash). */ c = **termPtr; if ((c == '\\') && ((*termPtr)[1] == '\n')) { c = (*termPtr)[2]; } type = CHAR_TYPE(c); if ((type != TCL_SPACE) && (type != TCL_COMMAND_END)) { if (*src == '"') { Tcl_SetResult(interp, (unsigned char*) "extra characters after close-quote", TCL_STATIC); } else { Tcl_SetResult(interp, (unsigned char*) "extra characters after close-brace", TCL_STATIC); } return TCL_ERROR; } src = *termPtr; dst = pvPtr->next; } /* * We're at the end of a word, so add a null terminator. Then * see if the buffer was re-allocated during this word. If so, * update all of the argv pointers. */ wordEnd: *dst = '\0'; dst++; if (oldBuffer != pvPtr->buffer) { int i; for (i = 0; i <= argc; i++) { argv[i] = pvPtr->buffer + (argv[i] - oldBuffer); } oldBuffer = pvPtr->buffer; } } done: pvPtr->next = dst; *termPtr = src; *argcPtr = argc; return TCL_OK; } /* *-------------------------------------------------------------- * * TclExpandParseValue -- * * This procedure is commonly used as the value of the * expandProc in a ParseValue. It uses malloc to allocate * more space for the result of a parse. * * Results: * The buffer space in *pvPtr is reallocated to something * larger, and if pvPtr->clientData is non-zero the old * buffer is freed. Information is copied from the old * buffer to the new one. * * Side effects: * None. * *-------------------------------------------------------------- */ void TclExpandParseValue (ParseValue *pvPtr, /* Information about buffer that * must be expanded. If the clientData * in the structure is non-zero, it * means that the current buffer is * dynamically allocated. */ unsigned short needed) /* Minimum amount of additional space * to allocate. */ { int newSpace; unsigned char *new; /* * Either double the size of the buffer or add enough new space * to meet the demand, whichever produces a larger new buffer. */ newSpace = (pvPtr->end - pvPtr->buffer) + 1; if (newSpace < needed) { newSpace += needed; } else { newSpace += newSpace; } new = malloc (newSpace); /* * Copy from old buffer to new, free old buffer if needed, and * mark new buffer as malloc-ed. */ memcpy ((void*) new, (void*) pvPtr->buffer, pvPtr->next - pvPtr->buffer); pvPtr->next = new + (pvPtr->next - pvPtr->buffer); if (pvPtr->clientData != 0) { free(pvPtr->buffer); } pvPtr->buffer = new; pvPtr->end = new + newSpace - 1; pvPtr->clientData = (void*) 1; } /* *---------------------------------------------------------------------- * * TclWordEnd -- * * Given a pointer into a Tcl command, find the end of the next * word of the command. * * Results: * The return value is a pointer to the last character that's part * of the word pointed to by "start". If the word doesn't end * properly within the string then the return value is the address * of the null character at the end of the string. * * Side effects: * None. * *---------------------------------------------------------------------- */ unsigned char * TclWordEnd(start, nested) unsigned char *start; /* Beginning of a word of a Tcl command. */ int nested; /* Zero means this is a top-level command. * One means this is a nested command (close * brace is a word terminator). */ { register unsigned char *p; int count; p = start; while (isspace(*p)) { p++; } /* * Handle words beginning with a double-quote or a brace. */ if (*p == '"') { p = QuoteEnd(p+1, '"'); if (*p == 0) { return p; } p++; } else if (*p == '{') { int braces = 1; while (braces != 0) { p++; while (*p == '\\') { (void) Tcl_Backslash(p, &count); p += count; } if (*p == '}') { braces--; } else if (*p == '{') { braces++; } else if (*p == 0) { return p; } } p++; } /* * Handle words that don't start with a brace or double-quote. * This code is also invoked if the word starts with a brace or * double-quote and there is garbage after the closing brace or * quote. This is an error as far as Tcl_Eval is concerned, but * for here the garbage is treated as part of the word. */ while (1) { if (*p == '[') { for (p++; *p != ']'; p++) { p = TclWordEnd(p, 1); if (*p == 0) { return p; } } p++; } else if (*p == '\\') { (void) Tcl_Backslash(p, &count); p += count; if ((*p == 0) && (count == 2) && (p[-1] == '\n')) { return p; } } else if (*p == '$') { p = VarNameEnd(p); if (*p == 0) { return p; } p++; } else if (*p == ';') { /* * Include the semi-colon in the word that is returned. */ return p; } else if (isspace(*p)) { return p-1; } else if ((*p == ']') && nested) { return p-1; } else if (*p == 0) { if (nested) { /* * Nested commands can't end because of the end of the * string. */ return p; } return p-1; } else { p++; } } } /* *---------------------------------------------------------------------- * * QuoteEnd -- * * Given a pointer to a string that obeys the parsing conventions * for quoted things in Tcl, find the end of that quoted thing. * The actual thing may be a quoted argument or a parenthesized * index name. * * Results: * The return value is a pointer to the last character that is * part of the quoted string (i.e the character that's equal to * term). If the quoted string doesn't terminate properly then * the return value is a pointer to the null character at the * end of the string. * * Side effects: * None. * *---------------------------------------------------------------------- */ static unsigned char * QuoteEnd(string, term) unsigned char *string; /* Pointer to character just after opening * "quote". */ int term; /* This character will terminate the * quoted string (e.g. '"' or ')'). */ { register unsigned char *p = string; int count; while (*p != term) { if (*p == '\\') { (void) Tcl_Backslash(p, &count); p += count; } else if (*p == '[') { for (p++; *p != ']'; p++) { p = TclWordEnd(p, 1); if (*p == 0) { return p; } } p++; } else if (*p == '$') { p = VarNameEnd(p); if (*p == 0) { return p; } p++; } else if (*p == 0) { return p; } else { p++; } } return p-1; } /* *---------------------------------------------------------------------- * * VarNameEnd -- * * Given a pointer to a variable reference using $-notation, find * the end of the variable name spec. * * Results: * The return value is a pointer to the last character that * is part of the variable name. If the variable name doesn't * terminate properly then the return value is a pointer to the * null character at the end of the string. * * Side effects: * None. * *---------------------------------------------------------------------- */ static unsigned char * VarNameEnd(string) unsigned char *string; /* Pointer to dollar-sign character. */ { register unsigned char *p = string+1; if (*p == '{') { for (p++; (*p != '}') && (*p != 0); p++) { /* Empty loop body. */ } return p; } while (isalnum(*p) || (*p == '_')) { p++; } if ((*p == '(') && (p != string+1)) { return QuoteEnd(p+1, ')'); } return p-1; } /* *---------------------------------------------------------------------- * * Tcl_ParseVar -- * * Given a string starting with a $ sign, parse off a variable * name and return its value. * * Results: * The return value is the contents of the variable given by * the leading characters of string. If termPtr isn't NULL, * *termPtr gets filled in with the address of the character * just after the last one in the variable specifier. If the * variable doesn't exist, then the return value is NULL and * an error message will be left in interp->result. * * Side effects: * None. * *---------------------------------------------------------------------- */ unsigned char * Tcl_ParseVar(interp, string, termPtr) Tcl_Interp *interp; /* Context for looking up variable. */ register unsigned char *string; /* String containing variable name. * First character must be "$". */ unsigned char **termPtr; /* If non-NULL, points to word to fill * in with character just after last * one in the variable specifier. */ { unsigned char *name1, *name1End, c, *result; register unsigned char *name2; #define NUM_CHARS 200 unsigned char copyStorage[NUM_CHARS]; ParseValue pv; /* * There are three cases: * 1. The $ sign is followed by an open curly brace. Then the variable * name is everything up to the next close curly brace, and the * variable is a scalar variable. * 2. The $ sign is not followed by an open curly brace. Then the * variable name is everything up to the next character that isn't * a letter, digit, or underscore. If the following character is an * open parenthesis, then the information between parentheses is * the array element name, which can include any of the substitutions * permissible between quotes. * 3. The $ sign is followed by something that isn't a letter, digit, * or underscore: in this case, there is no variable name, and "$" * is returned. */ name2 = 0; string++; if (*string == '{') { string++; name1 = string; while (*string != '}') { if (*string == 0) { Tcl_SetResult(interp, (unsigned char*) "missing close-brace for variable name", TCL_STATIC); if (termPtr != 0) { *termPtr = string; } return 0; } string++; } name1End = string; string++; } else { name1 = string; while (isalnum(*string) || (*string == '_')) { string++; } if (string == name1) { if (termPtr != 0) { *termPtr = string; } return (unsigned char*) "$"; } name1End = string; if (*string == '(') { unsigned char *end; /* * Perform substitutions on the array element name, just as * is done for quotes. */ pv.buffer = pv.next = copyStorage; pv.end = copyStorage + NUM_CHARS - 1; pv.expandProc = TclExpandParseValue; pv.clientData = (void*) 0; if (TclParseQuotes(interp, string+1, ')', 0, &end, &pv) != TCL_OK) { unsigned char msg[100]; sprintf(msg, "\n (parsing index for array \"%.*s\")", (int) (string - name1), name1); Tcl_AddErrorInfo(interp, msg); result = 0; name2 = pv.buffer; if (termPtr != 0) { *termPtr = end; } goto done; } string = end; name2 = pv.buffer; } } if (termPtr != 0) { *termPtr = string; } if (((Interp *) interp)->noEval) { return (unsigned char*) ""; } c = *name1End; *name1End = 0; result = Tcl_GetVar2(interp, name1, name2, TCL_LEAVE_ERR_MSG); *name1End = c; done: if ((name2 != 0) && (pv.buffer != copyStorage)) { free(pv.buffer); } return result; } ================================================ FILE: lib/libtcl/tclproc.c ================================================ /* * tclProc.c -- * * This file contains routines that implement Tcl procedures, * including the "proc" and "uplevel" commands. * * Copyright 1987-1991 Regents of the University of California * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without * fee is hereby granted, provided that the above copyright * notice appear in all copies. The University of California * makes no representations about the suitability of this * software for any purpose. It is provided "as is" without * express or implied warranty. */ #include "internal.h" /* * Forward references to procedures defined later in this file: */ static int InterpProc (void *clientData, Tcl_Interp *interp, int argc, unsigned char **argv); static void ProcDeleteProc (void *clientData); /* *---------------------------------------------------------------------- * * Tcl_ProcCmd -- * * This procedure is invoked to process the "proc" Tcl command. * See the user documentation for details on what it does. * * Results: * A standard Tcl result value. * * Side effects: * A new procedure gets created. * *---------------------------------------------------------------------- */ /* ARGSUSED */ int Tcl_ProcCmd(dummy, interp, argc, argv) void *dummy; /* Not used. */ Tcl_Interp *interp; /* Current interpreter. */ int argc; /* Number of arguments. */ unsigned char **argv; /* Argument strings. */ { register Interp *iPtr = (Interp *) interp; register Proc *procPtr; int result, argCount, i; unsigned char **argArray = 0; Arg *lastArgPtr; register Arg *argPtr = 0; /* Initialization not needed, but * prevents compiler warning. */ if (argc != 4) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " name args body\"", (char *) 0); return TCL_ERROR; } procPtr = (Proc*) malloc (sizeof(Proc)); procPtr->iPtr = iPtr; procPtr->command = malloc (strlen(argv[3]) + 1); strcpy(procPtr->command, argv[3]); procPtr->argPtr = 0; /* * Break up the argument list into argument specifiers, then process * each argument specifier. */ result = Tcl_SplitList(interp, argv[2], &argCount, &argArray); if (result != TCL_OK) { goto procError; } lastArgPtr = 0; for (i = 0; i < argCount; i++) { int fieldCount, nameLength, valueLength; unsigned char **fieldValues; /* * Now divide the specifier up into name and default. */ result = Tcl_SplitList(interp, argArray[i], &fieldCount, &fieldValues); if (result != TCL_OK) { goto procError; } if (fieldCount > 2) { free((char *) fieldValues); Tcl_AppendResult(interp, "too many fields in argument specifier \"", argArray[i], "\"", (char *) 0); result = TCL_ERROR; goto procError; } if ((fieldCount == 0) || (*fieldValues[0] == 0)) { free((char *) fieldValues); Tcl_AppendResult(interp, "procedure \"", argv[1], "\" has argument with no name", (char *) 0); result = TCL_ERROR; goto procError; } nameLength = strlen(fieldValues[0]) + 1; if (fieldCount == 2) { valueLength = strlen(fieldValues[1]) + 1; } else { valueLength = 0; } argPtr = (Arg*) malloc ((unsigned) (sizeof(Arg) - sizeof(argPtr->name) + nameLength + valueLength)); if (lastArgPtr == 0) { procPtr->argPtr = argPtr; } else { lastArgPtr->nextPtr = argPtr; } lastArgPtr = argPtr; argPtr->nextPtr = 0; strcpy(argPtr->name, fieldValues[0]); if (fieldCount == 2) { argPtr->defValue = argPtr->name + nameLength; strcpy(argPtr->defValue, fieldValues[1]); } else { argPtr->defValue = 0; } free((char *) fieldValues); } Tcl_CreateCommand(interp, argv[1], InterpProc, (void*) procPtr, ProcDeleteProc); free((char *) argArray); return TCL_OK; procError: free(procPtr->command); while (procPtr->argPtr != 0) { argPtr = procPtr->argPtr; procPtr->argPtr = argPtr->nextPtr; free((char *) argPtr); } free((char *) procPtr); if (argArray != 0) { free((char *) argArray); } return result; } /* *---------------------------------------------------------------------- * * TclGetFrame -- * * Given a description of a procedure frame, such as the first * argument to an "uplevel" or "upvar" command, locate the * call frame for the appropriate level of procedure. * * Results: * The return value is -1 if an error occurred in finding the * frame (in this case an error message is left in interp->result). * 1 is returned if string was either a number or a number preceded * by "#" and it specified a valid frame. 0 is returned if string * isn't one of the two things above (in this case, the lookup * acts as if string were "1"). The variable pointed to by * framePtrPtr is filled in with the address of the desired frame * (unless an error occurs, in which case it isn't modified). * * Side effects: * None. * *---------------------------------------------------------------------- */ int TclGetFrame(interp, string, framePtrPtr) Tcl_Interp *interp; /* Interpreter in which to find frame. */ unsigned char *string; /* String describing frame. */ CallFrame **framePtrPtr; /* Store pointer to frame here (or NULL * if global frame indicated). */ { register Interp *iPtr = (Interp *) interp; int level, result; CallFrame *framePtr; if (iPtr->varFramePtr == 0) { iPtr->result = (unsigned char*) "already at top level"; return -1; } /* * Parse string to figure out which level number to go to. */ result = 1; if (*string == '#') { if (Tcl_GetInt(interp, string+1, &level) != TCL_OK) { return -1; } if (level < 0) { levelError: Tcl_AppendResult(interp, "bad level \"", string, "\"", (char *) 0); return -1; } } else if (isdigit(*string)) { if (Tcl_GetInt(interp, string, &level) != TCL_OK) { return -1; } level = iPtr->varFramePtr->level - level; } else { level = iPtr->varFramePtr->level - 1; result = 0; } /* * Figure out which frame to use, and modify the interpreter so * its variables come from that frame. */ if (level == 0) { framePtr = 0; } else { for (framePtr = iPtr->varFramePtr; framePtr != 0; framePtr = framePtr->callerVarPtr) { if (framePtr->level == level) { break; } } if (framePtr == 0) { goto levelError; } } *framePtrPtr = framePtr; return result; } /* *---------------------------------------------------------------------- * * Tcl_UplevelCmd -- * * This procedure is invoked to process the "uplevel" Tcl command. * See the user documentation for details on what it does. * * Results: * A standard Tcl result value. * * Side effects: * See the user documentation. * *---------------------------------------------------------------------- */ /* ARGSUSED */ int Tcl_UplevelCmd(dummy, interp, argc, argv) void *dummy; /* Not used. */ Tcl_Interp *interp; /* Current interpreter. */ int argc; /* Number of arguments. */ unsigned char **argv; /* Argument strings. */ { register Interp *iPtr = (Interp *) interp; int result; CallFrame *savedVarFramePtr, *framePtr; if (argc < 2) { uplevelSyntax: Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " ?level? command ?arg ...?\"", (char *) 0); return TCL_ERROR; } /* * Find the level to use for executing the command. */ result = TclGetFrame(interp, argv[1], &framePtr); if (result == -1) { return TCL_ERROR; } argc -= (result+1); if (argc == 0) { goto uplevelSyntax; } argv += (result+1); /* * Modify the interpreter state to execute in the given frame. */ savedVarFramePtr = iPtr->varFramePtr; iPtr->varFramePtr = framePtr; /* * Execute the residual arguments as a command. */ if (argc == 1) { result = Tcl_Eval(interp, argv[0], 0, 0); } else { unsigned char *cmd; cmd = Tcl_Concat (argc, argv); result = Tcl_Eval (interp, cmd, 0, 0); free(cmd); } if (result == TCL_ERROR) { unsigned char msg[60]; sprintf(msg, "\n (\"uplevel\" body line %d)", interp->errorLine); Tcl_AddErrorInfo(interp, msg); } /* * Restore the variable frame, and return. */ iPtr->varFramePtr = savedVarFramePtr; return result; } /* *---------------------------------------------------------------------- * * TclFindProc -- * * Given the name of a procedure, return a pointer to the * record describing the procedure. * * Results: * NULL is returned if the name doesn't correspond to any * procedure. Otherwise the return value is a pointer to * the procedure's record. * * Side effects: * None. * *---------------------------------------------------------------------- */ Proc * TclFindProc(iPtr, procName) Interp *iPtr; /* Interpreter in which to look. */ unsigned char *procName; /* Name of desired procedure. */ { Tcl_HashEntry *hPtr; Command *cmdPtr; hPtr = Tcl_FindHashEntry(&iPtr->commandTable, procName); if (hPtr == 0) { return 0; } cmdPtr = (Command *) Tcl_GetHashValue(hPtr); if (cmdPtr->proc != InterpProc) { return 0; } return (Proc *) cmdPtr->clientData; } /* *---------------------------------------------------------------------- * * TclIsProc -- * * Tells whether a command is a Tcl procedure or not. * * Results: * If the given command is actuall a Tcl procedure, the * return value is the address of the record describing * the procedure. Otherwise the return value is 0. * * Side effects: * None. * *---------------------------------------------------------------------- */ Proc * TclIsProc(cmdPtr) Command *cmdPtr; /* Command to test. */ { if (cmdPtr->proc == InterpProc) { return (Proc *) cmdPtr->clientData; } return (Proc *) 0; } /* *---------------------------------------------------------------------- * * InterpProc -- * * When a Tcl procedure gets invoked, this routine gets invoked * to interpret the procedure. * * Results: * A standard Tcl result value, usually TCL_OK. * * Side effects: * Depends on the commands in the procedure. * *---------------------------------------------------------------------- */ static int InterpProc(clientData, interp, argc, argv) void *clientData; /* Record describing procedure to be * interpreted. */ Tcl_Interp *interp; /* Interpreter in which procedure was * invoked. */ int argc; /* Count of number of arguments to this * procedure. */ unsigned char **argv; /* Argument values. */ { register Proc *procPtr = (Proc *) clientData; register Arg *argPtr; register Interp *iPtr = (Interp *) interp; unsigned char **args; CallFrame frame; unsigned char *value, *end; int result; /* * Set up a call frame for the new procedure invocation. */ iPtr = procPtr->iPtr; Tcl_InitHashTable (&frame.varTable, TCL_STRING_KEYS); if (iPtr->varFramePtr != 0) { frame.level = iPtr->varFramePtr->level + 1; } else { frame.level = 1; } frame.argc = argc; frame.argv = argv; frame.callerPtr = iPtr->framePtr; frame.callerVarPtr = iPtr->varFramePtr; iPtr->framePtr = &frame; iPtr->varFramePtr = &frame; /* * Match the actual arguments against the procedure's formal * parameters to compute local variables. */ for (argPtr = procPtr->argPtr, args = argv+1, argc -= 1; argPtr != 0; argPtr = argPtr->nextPtr, args++, argc--) { /* * Handle the special case of the last formal being "args". When * it occurs, assign it a list consisting of all the remaining * actual arguments. */ if ((argPtr->nextPtr == 0) && (strcmp (argPtr->name, (unsigned char*) "args") == 0)) { if (argc < 0) { argc = 0; } value = Tcl_Merge (argc, args); Tcl_SetVar (interp, argPtr->name, value, 0); free (value); argc = 0; break; } else if (argc > 0) { value = *args; } else if (argPtr->defValue != 0) { value = argPtr->defValue; } else { Tcl_AppendResult(interp, "no value given for parameter \"", argPtr->name, "\" to \"", argv[0], "\"", 0); result = TCL_ERROR; goto procDone; } Tcl_SetVar(interp, argPtr->name, value, 0); } if (argc > 0) { Tcl_AppendResult(interp, "called \"", argv[0], "\" with too many arguments", 0); result = TCL_ERROR; goto procDone; } /* * Invoke the commands in the procedure's body. */ result = Tcl_Eval(interp, procPtr->command, 0, &end); if (result == TCL_RETURN) { result = TCL_OK; } else if (result == TCL_ERROR) { unsigned char msg[100]; /* * Record information telling where the error occurred. */ sprintf(msg, "\n (procedure \"%.50s\" line %d)", argv[0], iPtr->errorLine); Tcl_AddErrorInfo(interp, msg); } else if (result == TCL_BREAK) { iPtr->result = (unsigned char*) "invoked \"break\" outside of a loop"; result = TCL_ERROR; } else if (result == TCL_CONTINUE) { iPtr->result = (unsigned char*) "invoked \"continue\" outside of a loop"; result = TCL_ERROR; } /* * Delete the call frame for this procedure invocation (it's * important to remove the call frame from the interpreter * before deleting it, so that traces invoked during the * deletion don't see the partially-deleted frame). */ procDone: iPtr->framePtr = frame.callerPtr; iPtr->varFramePtr = frame.callerVarPtr; TclDeleteVars(iPtr, &frame.varTable); return result; } /* *---------------------------------------------------------------------- * * ProcDeleteProc -- * * This procedure is invoked just before a command procedure is * removed from an interpreter. Its job is to release all the * resources allocated to the procedure. * * Results: * None. * * Side effects: * Memory gets freed. * *---------------------------------------------------------------------- */ static void ProcDeleteProc(clientData) void *clientData; /* Procedure to be deleted. */ { register Proc *procPtr = (Proc *) clientData; register Arg *argPtr; free (procPtr->command); for (argPtr = procPtr->argPtr; argPtr != 0; ) { Arg *nextPtr = argPtr->nextPtr; free (argPtr); argPtr = nextPtr; } free (procPtr); } /* * Free up result of interpreter. */ void Tcl_FreeResult (Tcl_Interp *interp) { if (interp->freeProc != 0) { if (interp->freeProc == TCL_DYNAMIC) free (interp->result); else (*interp->freeProc) (interp->result); interp->freeProc = 0; } } ================================================ FILE: lib/libtcl/tclunxaz.c ================================================ /* * tclUnixAZ.c -- * * This file contains the top-level command procedures for * commands in the Tcl core that require UNIX facilities * such as files and process execution. Much of the code * in this file is based on earlier versions contributed * by Karl Lehenbauer, Mark Diekhans and Peter da Silva. * * Copyright 1991 Regents of the University of California * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without * fee is hereby granted, provided that this copyright * notice appears in all copies. The University of California * makes no representations about the suitability of this * software for any purpose. It is provided "as is" without * express or implied warranty. */ #include "internal.h" #include #include #include #include #include #ifdef CROSS # include #else # include #endif /* * The variable below caches the name of the current working directory * in order to avoid repeated calls to getwd. The string is malloc-ed. * NULL means the cache needs to be refreshed. */ static char *currentDir = NULL; /* * Prototypes for local procedures defined in this file: */ static int CleanupChildren (Tcl_Interp *interp, int numPids, int *pidPtr, int errorId); static char * GetFileType (int mode); static int StoreStatData (Tcl_Interp *interp, char *varName, struct stat *statPtr); /* *---------------------------------------------------------------------- * * Tcl_CdCmd -- * * This procedure is invoked to process the "cd" Tcl command. * See the user documentation for details on what it does. * * Results: * A standard Tcl result. * * Side effects: * See the user documentation. * *---------------------------------------------------------------------- */ /* ARGSUSED */ int Tcl_CdCmd(dummy, interp, argc, argv) void *dummy; /* Not used. */ Tcl_Interp *interp; /* Current interpreter. */ int argc; /* Number of arguments. */ unsigned char **argv; /* Argument strings. */ { char *dirName; if (argc > 2) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " dirName\"", (char *) NULL); return TCL_ERROR; } if (argc == 2) { dirName = argv[1]; } else { dirName = "~"; } dirName = Tcl_TildeSubst(interp, dirName); if (dirName == NULL) { return TCL_ERROR; } if (currentDir != NULL) { free(currentDir); currentDir = NULL; } if (chdir(dirName) != 0) { Tcl_AppendResult(interp, "couldn't change working directory to \"", dirName, "\": ", Tcl_UnixError(interp), (char *) NULL); return TCL_ERROR; } return TCL_OK; } /* *---------------------------------------------------------------------- * * Tcl_CloseCmd -- * * This procedure is invoked to process the "close" Tcl command. * See the user documentation for details on what it does. * * Results: * A standard Tcl result. * * Side effects: * See the user documentation. * *---------------------------------------------------------------------- */ /* ARGSUSED */ int Tcl_CloseCmd(dummy, interp, argc, argv) void *dummy; /* Not used. */ Tcl_Interp *interp; /* Current interpreter. */ int argc; /* Number of arguments. */ unsigned char **argv; /* Argument strings. */ { OpenFile *filePtr; int result = TCL_OK; if (argc != 2) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " fileId\"", (char *) NULL); return TCL_ERROR; } if (TclGetOpenFile(interp, argv[1], &filePtr) != TCL_OK) { return TCL_ERROR; } ((Interp *) interp)->filePtrArray[(int)fileno(filePtr->f)] = NULL; /* * First close the file (in the case of a process pipeline, there may * be two files, one for the pipe at each end of the pipeline). */ if (filePtr->f2 != NULL) { if (fclose(filePtr->f2) == EOF) { Tcl_AppendResult(interp, "error closing \"", argv[1], "\": ", Tcl_UnixError(interp), "\n", (char *) NULL); result = TCL_ERROR; } } if (fclose(filePtr->f) == EOF) { Tcl_AppendResult(interp, "error closing \"", argv[1], "\": ", Tcl_UnixError(interp), "\n", (char *) NULL); result = TCL_ERROR; } /* * If the file was a connection to a pipeline, clean up everything * associated with the child processes. */ if (filePtr->numPids > 0) { if (CleanupChildren(interp, filePtr->numPids, filePtr->pidPtr, filePtr->errorId) != TCL_OK) { result = TCL_ERROR; } } free((char *) filePtr); return result; } /* *---------------------------------------------------------------------- * * Tcl_EofCmd -- * * This procedure is invoked to process the "eof" Tcl command. * See the user documentation for details on what it does. * * Results: * A standard Tcl result. * * Side effects: * See the user documentation. * *---------------------------------------------------------------------- */ /* ARGSUSED */ int Tcl_EofCmd(notUsed, interp, argc, argv) void *notUsed; /* Not used. */ Tcl_Interp *interp; /* Current interpreter. */ int argc; /* Number of arguments. */ unsigned char **argv; /* Argument strings. */ { OpenFile *filePtr; if (argc != 2) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " fileId\"", (char *) NULL); return TCL_ERROR; } if (TclGetOpenFile(interp, argv[1], &filePtr) != TCL_OK) { return TCL_ERROR; } if (feof(filePtr->f)) { interp->result = "1"; } else { interp->result = "0"; } return TCL_OK; } /* *---------------------------------------------------------------------- * * Tcl_ExecCmd -- * * This procedure is invoked to process the "exec" Tcl command. * See the user documentation for details on what it does. * * Results: * A standard Tcl result. * * Side effects: * See the user documentation. * *---------------------------------------------------------------------- */ /* ARGSUSED */ int Tcl_ExecCmd(dummy, interp, argc, argv) void *dummy; /* Not used. */ Tcl_Interp *interp; /* Current interpreter. */ int argc; /* Number of arguments. */ unsigned char **argv; /* Argument strings. */ { int outputId; /* File id for output pipe. -1 * means command overrode. */ int errorId; /* File id for temporary file * containing error output. */ int *pidPtr; int numPids, result; /* * See if the command is to be run in background; if so, create * the command, detach it, and return. */ if ((argv[argc-1][0] == '&') && (argv[argc-1][1] == 0)) { argc--; argv[argc] = NULL; numPids = Tcl_CreatePipeline(interp, argc-1, argv+1, &pidPtr, (int *) NULL, (int *) NULL, (int *) NULL); if (numPids < 0) { return TCL_ERROR; } Tcl_DetachPids(numPids, pidPtr); free((char *) pidPtr); return TCL_OK; } /* * Create the command's pipeline. */ numPids = Tcl_CreatePipeline(interp, argc-1, argv+1, &pidPtr, (int *) NULL, &outputId, &errorId); if (numPids < 0) { return TCL_ERROR; } /* * Read the child's output (if any) and put it into the result. */ result = TCL_OK; if (outputId != -1) { while (1) { # define BUFFER_SIZE 1000 char buffer[BUFFER_SIZE+1]; int count; count = read(outputId, buffer, BUFFER_SIZE); if (count == 0) { break; } if (count < 0) { Tcl_ResetResult(interp); Tcl_AppendResult(interp, "error reading from output pipe: ", Tcl_UnixError(interp), (char *) NULL); result = TCL_ERROR; break; } buffer[count] = 0; Tcl_AppendResult(interp, buffer, (char *) NULL); } close(outputId); } if (CleanupChildren(interp, numPids, pidPtr, errorId) != TCL_OK) { result = TCL_ERROR; } return result; } /* *---------------------------------------------------------------------- * * Tcl_ExitCmd -- * * This procedure is invoked to process the "exit" Tcl command. * See the user documentation for details on what it does. * * Results: * A standard Tcl result. * * Side effects: * See the user documentation. * *---------------------------------------------------------------------- */ /* ARGSUSED */ int Tcl_ExitCmd(dummy, interp, argc, argv) void *dummy; /* Not used. */ Tcl_Interp *interp; /* Current interpreter. */ int argc; /* Number of arguments. */ unsigned char **argv; /* Argument strings. */ { int value; if ((argc != 1) && (argc != 2)) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " ?returnCode?\"", (char *) NULL); return TCL_ERROR; } if (argc == 1) { exit(0); } if (Tcl_GetInt(interp, argv[1], &value) != TCL_OK) { return TCL_ERROR; } exit(value); return TCL_OK; /* Better not ever reach this! */ } /* *---------------------------------------------------------------------- * * Tcl_FileCmd -- * * This procedure is invoked to process the "file" Tcl command. * See the user documentation for details on what it does. * * Results: * A standard Tcl result. * * Side effects: * See the user documentation. * *---------------------------------------------------------------------- */ /* ARGSUSED */ int Tcl_FileCmd(dummy, interp, argc, argv) void *dummy; /* Not used. */ Tcl_Interp *interp; /* Current interpreter. */ int argc; /* Number of arguments. */ unsigned char **argv; /* Argument strings. */ { char *p; int length, statOp; int mode = 0; /* Initialized only to prevent * compiler warning message. */ struct stat statBuf; char *fileName, c; if (argc < 3) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " option name ?arg ...?\"", (char *) NULL); return TCL_ERROR; } c = argv[1][0]; length = strlen(argv[1]); /* * First handle operations on the file name. */ fileName = Tcl_TildeSubst(interp, argv[2]); if (fileName == NULL) { return TCL_ERROR; } if ((c == 'd') && (strncmp(argv[1], "dirname", length) == 0)) { if (argc != 3) { argv[1] = "dirname"; not3Args: Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " ", argv[1], " name\"", (char *) NULL); return TCL_ERROR; } p = strrchr(fileName, '/'); if (p == NULL) { interp->result = "."; } else if (p == fileName) { interp->result = "/"; } else { *p = 0; Tcl_SetResult(interp, fileName, TCL_VOLATILE); *p = '/'; } return TCL_OK; } else if ((c == 'r') && (strncmp(argv[1], "rootname", length) == 0) && (length >= 2)) { char *lastSlash; if (argc != 3) { argv[1] = "rootname"; goto not3Args; } p = strrchr(fileName, '.'); lastSlash = strrchr(fileName, '/'); if ((p == NULL) || ((lastSlash != NULL) && (lastSlash > p))) { Tcl_SetResult(interp, fileName, TCL_VOLATILE); } else { *p = 0; Tcl_SetResult(interp, fileName, TCL_VOLATILE); *p = '.'; } return TCL_OK; } else if ((c == 'e') && (strncmp(argv[1], "extension", length) == 0) && (length >= 3)) { char *lastSlash; if (argc != 3) { argv[1] = "extension"; goto not3Args; } p = strrchr(fileName, '.'); lastSlash = strrchr(fileName, '/'); if ((p != NULL) && ((lastSlash == NULL) || (lastSlash < p))) { Tcl_SetResult(interp, p, TCL_VOLATILE); } return TCL_OK; } else if ((c == 't') && (strncmp(argv[1], "tail", length) == 0) && (length >= 2)) { if (argc != 3) { argv[1] = "tail"; goto not3Args; } p = strrchr(fileName, '/'); if (p != NULL) { Tcl_SetResult(interp, p+1, TCL_VOLATILE); } else { Tcl_SetResult(interp, fileName, TCL_VOLATILE); } return TCL_OK; } /* * Next, handle operations that can be satisfied with the "access" * kernel call. */ if (fileName == NULL) { return TCL_ERROR; } if ((c == 'r') && (strncmp(argv[1], "readable", length) == 0) && (length >= 5)) { if (argc != 3) { argv[1] = "readable"; goto not3Args; } mode = R_OK; checkAccess: if (access(fileName, mode) == -1) { interp->result = "0"; } else { interp->result = "1"; } return TCL_OK; } else if ((c == 'w') && (strncmp(argv[1], "writable", length) == 0)) { if (argc != 3) { argv[1] = "writable"; goto not3Args; } mode = W_OK; goto checkAccess; } else if ((c == 'e') && (strncmp(argv[1], "executable", length) == 0) && (length >= 3)) { if (argc != 3) { argv[1] = "executable"; goto not3Args; } mode = X_OK; goto checkAccess; } else if ((c == 'e') && (strncmp(argv[1], "exists", length) == 0) && (length >= 3)) { if (argc != 3) { argv[1] = "exists"; goto not3Args; } mode = F_OK; goto checkAccess; } /* * Lastly, check stuff that requires the file to be stat-ed. */ if ((c == 'a') && (strncmp(argv[1], "atime", length) == 0)) { if (argc != 3) { argv[1] = "atime"; goto not3Args; } if (stat(fileName, &statBuf) == -1) { goto badStat; } sprintf(interp->result, "%ld", statBuf.st_atime); return TCL_OK; } else if ((c == 'i') && (strncmp(argv[1], "isdirectory", length) == 0) && (length >= 3)) { if (argc != 3) { argv[1] = "isdirectory"; goto not3Args; } statOp = 2; } else if ((c == 'i') && (strncmp(argv[1], "isfile", length) == 0) && (length >= 3)) { if (argc != 3) { argv[1] = "isfile"; goto not3Args; } statOp = 1; } else if ((c == 'l') && (strncmp(argv[1], "lstat", length) == 0)) { if (argc != 4) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " lstat name varName\"", (char *) NULL); return TCL_ERROR; } if (lstat(fileName, &statBuf) == -1) { Tcl_AppendResult(interp, "couldn't lstat \"", argv[2], "\": ", Tcl_UnixError(interp), (char *) NULL); return TCL_ERROR; } return StoreStatData(interp, argv[3], &statBuf); } else if ((c == 'm') && (strncmp(argv[1], "mtime", length) == 0)) { if (argc != 3) { argv[1] = "mtime"; goto not3Args; } if (stat(fileName, &statBuf) == -1) { goto badStat; } sprintf(interp->result, "%ld", statBuf.st_mtime); return TCL_OK; } else if ((c == 'o') && (strncmp(argv[1], "owned", length) == 0)) { if (argc != 3) { argv[1] = "owned"; goto not3Args; } statOp = 0; #ifdef S_IFLNK /* * This option is only included if symbolic links exist on this system * (in which case S_IFLNK should be defined). */ } else if ((c == 'r') && (strncmp(argv[1], "readlink", length) == 0) && (length >= 5)) { char linkValue[MAXPATHLEN+1]; int linkLength; if (argc != 3) { argv[1] = "readlink"; goto not3Args; } linkLength = readlink(fileName, linkValue, sizeof(linkValue) - 1); if (linkLength == -1) { Tcl_AppendResult(interp, "couldn't readlink \"", argv[2], "\": ", Tcl_UnixError(interp), (char *) NULL); return TCL_ERROR; } linkValue[linkLength] = 0; Tcl_SetResult(interp, linkValue, TCL_VOLATILE); return TCL_OK; #endif } else if ((c == 's') && (strncmp(argv[1], "size", length) == 0) && (length >= 2)) { if (argc != 3) { argv[1] = "size"; goto not3Args; } if (stat(fileName, &statBuf) == -1) { goto badStat; } sprintf(interp->result, "%ld", statBuf.st_size); return TCL_OK; } else if ((c == 's') && (strncmp(argv[1], "stat", length) == 0) && (length >= 2)) { if (argc != 4) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " stat name varName\"", (char *) NULL); return TCL_ERROR; } if (stat(fileName, &statBuf) == -1) { badStat: Tcl_AppendResult(interp, "couldn't stat \"", argv[2], "\": ", Tcl_UnixError(interp), (char *) NULL); return TCL_ERROR; } return StoreStatData(interp, argv[3], &statBuf); } else if ((c == 't') && (strncmp(argv[1], "type", length) == 0) && (length >= 2)) { if (argc != 3) { argv[1] = "type"; goto not3Args; } if (lstat(fileName, &statBuf) == -1) { goto badStat; } interp->result = GetFileType((int) statBuf.st_mode); return TCL_OK; } else { Tcl_AppendResult(interp, "bad option \"", argv[1], "\": should be atime, dirname, executable, exists, ", "extension, isdirectory, isfile, lstat, mtime, owned, ", "readable, ", #ifdef S_IFLNK "readlink, ", #endif "root, size, stat, tail, type, ", "or writable", (char *) NULL); return TCL_ERROR; } if (stat(fileName, &statBuf) == -1) { interp->result = "0"; return TCL_OK; } switch (statOp) { case 0: mode = (geteuid() == statBuf.st_uid); break; case 1: mode = S_ISREG(statBuf.st_mode); break; case 2: mode = S_ISDIR(statBuf.st_mode); break; } if (mode) { interp->result = "1"; } else { interp->result = "0"; } return TCL_OK; } /* *---------------------------------------------------------------------- * * StoreStatData -- * * This is a utility procedure that breaks out the fields of a * "stat" structure and stores them in textual form into the * elements of an associative array. * * Results: * Returns a standard Tcl return value. If an error occurs then * a message is left in interp->result. * * Side effects: * Elements of the associative array given by "varName" are modified. * *---------------------------------------------------------------------- */ static int StoreStatData(interp, varName, statPtr) Tcl_Interp *interp; /* Interpreter for error reports. */ char *varName; /* Name of associative array variable * in which to store stat results. */ struct stat *statPtr; /* Pointer to buffer containing * stat data to store in varName. */ { char string[30]; sprintf(string, "%d", statPtr->st_dev); if (Tcl_SetVar2(interp, varName, "dev", string, TCL_LEAVE_ERR_MSG) == NULL) { return TCL_ERROR; } sprintf(string, "%d", statPtr->st_ino); if (Tcl_SetVar2(interp, varName, "ino", string, TCL_LEAVE_ERR_MSG) == NULL) { return TCL_ERROR; } sprintf(string, "%d", statPtr->st_mode); if (Tcl_SetVar2(interp, varName, "mode", string, TCL_LEAVE_ERR_MSG) == NULL) { return TCL_ERROR; } sprintf(string, "%d", statPtr->st_nlink); if (Tcl_SetVar2(interp, varName, "nlink", string, TCL_LEAVE_ERR_MSG) == NULL) { return TCL_ERROR; } sprintf(string, "%d", statPtr->st_uid); if (Tcl_SetVar2(interp, varName, "uid", string, TCL_LEAVE_ERR_MSG) == NULL) { return TCL_ERROR; } sprintf(string, "%d", statPtr->st_gid); if (Tcl_SetVar2(interp, varName, "gid", string, TCL_LEAVE_ERR_MSG) == NULL) { return TCL_ERROR; } sprintf(string, "%ld", statPtr->st_size); if (Tcl_SetVar2(interp, varName, "size", string, TCL_LEAVE_ERR_MSG) == NULL) { return TCL_ERROR; } sprintf(string, "%ld", statPtr->st_atime); if (Tcl_SetVar2(interp, varName, "atime", string, TCL_LEAVE_ERR_MSG) == NULL) { return TCL_ERROR; } sprintf(string, "%ld", statPtr->st_mtime); if (Tcl_SetVar2(interp, varName, "mtime", string, TCL_LEAVE_ERR_MSG) == NULL) { return TCL_ERROR; } sprintf(string, "%ld", statPtr->st_ctime); if (Tcl_SetVar2(interp, varName, "ctime", string, TCL_LEAVE_ERR_MSG) == NULL) { return TCL_ERROR; } if (Tcl_SetVar2(interp, varName, "type", GetFileType((int) statPtr->st_mode), TCL_LEAVE_ERR_MSG) == NULL) { return TCL_ERROR; } return TCL_OK; } /* *---------------------------------------------------------------------- * * GetFileType -- * * Given a mode word, returns a string identifying the type of a * file. * * Results: * A static text string giving the file type from mode. * * Side effects: * None. * *---------------------------------------------------------------------- */ static char * GetFileType(mode) int mode; { if (S_ISREG(mode)) { return "file"; } else if (S_ISDIR(mode)) { return "directory"; } else if (S_ISCHR(mode)) { return "characterSpecial"; } else if (S_ISBLK(mode)) { return "blockSpecial"; #ifdef S_ISFIFO } else if (S_ISFIFO(mode)) { return "fifo"; #endif } else if (S_ISLNK(mode)) { return "link"; } else if (S_ISSOCK(mode)) { return "socket"; } return "unknown"; } /* *---------------------------------------------------------------------- * * Tcl_FlushCmd -- * * This procedure is invoked to process the "flush" Tcl command. * See the user documentation for details on what it does. * * Results: * A standard Tcl result. * * Side effects: * See the user documentation. * *---------------------------------------------------------------------- */ /* ARGSUSED */ int Tcl_FlushCmd(notUsed, interp, argc, argv) void *notUsed; /* Not used. */ Tcl_Interp *interp; /* Current interpreter. */ int argc; /* Number of arguments. */ unsigned char **argv; /* Argument strings. */ { OpenFile *filePtr; FILE *f; if (argc != 2) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " fileId\"", (char *) NULL); return TCL_ERROR; } if (TclGetOpenFile(interp, argv[1], &filePtr) != TCL_OK) { return TCL_ERROR; } if (!filePtr->writable) { Tcl_AppendResult(interp, "\"", argv[1], "\" wasn't opened for writing", (char *) NULL); return TCL_ERROR; } f = filePtr->f2; if (f == NULL) { f = filePtr->f; } if (fflush(f) == EOF) { Tcl_AppendResult(interp, "error flushing \"", argv[1], "\": ", Tcl_UnixError(interp), (char *) NULL); clearerr(f); return TCL_ERROR; } return TCL_OK; } /* *---------------------------------------------------------------------- * * Tcl_GetsCmd -- * * This procedure is invoked to process the "gets" Tcl command. * See the user documentation for details on what it does. * * Results: * A standard Tcl result. * * Side effects: * See the user documentation. * *---------------------------------------------------------------------- */ /* ARGSUSED */ int Tcl_GetsCmd(notUsed, interp, argc, argv) void *notUsed; /* Not used. */ Tcl_Interp *interp; /* Current interpreter. */ int argc; /* Number of arguments. */ unsigned char **argv; /* Argument strings. */ { # define BUF_SIZE 200 char buffer[BUF_SIZE+1]; int totalCount, done, flags; OpenFile *filePtr; register FILE *f; if ((argc != 2) && (argc != 3)) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " fileId ?varName?\"", (char *) NULL); return TCL_ERROR; } if (TclGetOpenFile(interp, argv[1], &filePtr) != TCL_OK) { return TCL_ERROR; } if (!filePtr->readable) { Tcl_AppendResult(interp, "\"", argv[1], "\" wasn't opened for reading", (char *) NULL); return TCL_ERROR; } /* * We can't predict how large a line will be, so read it in * pieces, appending to the current result or to a variable. */ totalCount = 0; done = 0; flags = 0; f = filePtr->f; while (!done) { register int c, count; register char *p; for (p = buffer, count = 0; count < BUF_SIZE-1; count++, p++) { c = getc(f); if (c == EOF) { if (ferror(filePtr->f)) { Tcl_ResetResult(interp); Tcl_AppendResult(interp, "error reading \"", argv[1], "\": ", Tcl_UnixError(interp), (char *) NULL); clearerr(filePtr->f); return TCL_ERROR; } else if (feof(filePtr->f)) { if ((totalCount == 0) && (count == 0)) { totalCount = -1; } done = 1; break; } } if (c == '\n') { done = 1; break; } *p = c; } *p = 0; if (argc == 2) { Tcl_AppendResult(interp, buffer, (char *) NULL); } else { if (Tcl_SetVar(interp, argv[2], buffer, flags|TCL_LEAVE_ERR_MSG) == NULL) { return TCL_ERROR; } flags = TCL_APPEND_VALUE; } totalCount += count; } if (argc == 3) { sprintf(interp->result, "%d", totalCount); } return TCL_OK; } /* *---------------------------------------------------------------------- * * Tcl_OpenCmd -- * * This procedure is invoked to process the "open" Tcl command. * See the user documentation for details on what it does. * * Results: * A standard Tcl result. * * Side effects: * See the user documentation. * *---------------------------------------------------------------------- */ /* ARGSUSED */ int Tcl_OpenCmd(notUsed, interp, argc, argv) void *notUsed; /* Not used. */ Tcl_Interp *interp; /* Current interpreter. */ int argc; /* Number of arguments. */ unsigned char **argv; /* Argument strings. */ { Interp *iPtr = (Interp *) interp; int pipeline, fd; char *access; register OpenFile *filePtr; if (argc == 2) { access = "r"; } else if (argc == 3) { access = argv[2]; } else { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " filename ?access?\"", (char *) NULL); return TCL_ERROR; } filePtr = (OpenFile *) malloc(sizeof(OpenFile)); filePtr->f = NULL; filePtr->f2 = NULL; filePtr->readable = 0; filePtr->writable = 0; filePtr->numPids = 0; filePtr->pidPtr = NULL; filePtr->errorId = -1; /* * Verify the requested form of access. */ pipeline = 0; if (argv[1][0] == '|') { pipeline = 1; } switch (access[0]) { case 'r': filePtr->readable = 1; break; case 'w': filePtr->writable = 1; break; case 'a': filePtr->writable = 1; break; default: badAccess: Tcl_AppendResult(interp, "illegal access mode \"", access, "\"", (char *) NULL); goto error; } if (access[1] == '+') { filePtr->readable = filePtr->writable = 1; if (access[2] != 0) { goto badAccess; } } else if (access[1] != 0) { goto badAccess; } /* * Open the file or create a process pipeline. */ if (!pipeline) { char *fileName = argv[1]; if (fileName[0] == '~') { fileName = Tcl_TildeSubst(interp, fileName); if (fileName == NULL) { goto error; } } filePtr->f = fopen(fileName, access); if (filePtr->f == NULL) { Tcl_AppendResult(interp, "couldn't open \"", argv[1], "\": ", Tcl_UnixError(interp), (char *) NULL); goto error; } } else { int *inPipePtr, *outPipePtr; int cmdArgc, inPipe, outPipe; unsigned char **cmdArgv; if (Tcl_SplitList(interp, argv[1]+1, &cmdArgc, &cmdArgv) != TCL_OK) { goto error; } inPipePtr = (filePtr->writable) ? &inPipe : NULL; outPipePtr = (filePtr->readable) ? &outPipe : NULL; inPipe = outPipe = -1; filePtr->numPids = Tcl_CreatePipeline(interp, cmdArgc, cmdArgv, &filePtr->pidPtr, inPipePtr, outPipePtr, &filePtr->errorId); free((char *) cmdArgv); if (filePtr->numPids < 0) { goto error; } if (filePtr->readable) { if (outPipe == -1) { if (inPipe != -1) { close(inPipe); } Tcl_AppendResult(interp, "can't read output from command:", " standard output was redirected", (char *) NULL); goto error; } filePtr->f = fdopen(outPipe, "r"); } if (filePtr->writable) { if (inPipe == -1) { Tcl_AppendResult(interp, "can't write input to command:", " standard input was redirected", (char *) NULL); goto error; } if (filePtr->f != NULL) { filePtr->f2 = fdopen(inPipe, "w"); } else { filePtr->f = fdopen(inPipe, "w"); } } } /* * Enter this new OpenFile structure in the table for the * interpreter. May have to expand the table to do this. */ fd = fileno(filePtr->f); TclMakeFileTable(iPtr, fd); if (iPtr->filePtrArray[fd] != NULL) { fprintf (stderr, "Tcl_OpenCmd found file already open\n"); abort(); } iPtr->filePtrArray[fd] = filePtr; sprintf(interp->result, "file%d", fd); return TCL_OK; error: if (filePtr->f != NULL) { fclose(filePtr->f); } if (filePtr->f2 != NULL) { fclose(filePtr->f2); } if (filePtr->numPids > 0) { Tcl_DetachPids(filePtr->numPids, filePtr->pidPtr); free((char *) filePtr->pidPtr); } if (filePtr->errorId != -1) { close(filePtr->errorId); } free((char *) filePtr); return TCL_ERROR; } /* *---------------------------------------------------------------------- * * Tcl_PwdCmd -- * * This procedure is invoked to process the "pwd" Tcl command. * See the user documentation for details on what it does. * * Results: * A standard Tcl result. * * Side effects: * See the user documentation. * *---------------------------------------------------------------------- */ /* ARGSUSED */ int Tcl_PwdCmd(dummy, interp, argc, argv) void *dummy; /* Not used. */ Tcl_Interp *interp; /* Current interpreter. */ int argc; /* Number of arguments. */ unsigned char **argv; /* Argument strings. */ { char buffer[MAXPATHLEN+1]; if (argc != 1) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], "\"", (char *) NULL); return TCL_ERROR; } if (currentDir == NULL) { #if TCL_GETWD if (getwd(buffer) == NULL) { Tcl_AppendResult(interp, "error getting working directory name: ", buffer, (char *) NULL); return TCL_ERROR; } #else if (getwd(buffer) == NULL) { if (errno == ERANGE) { interp->result = "working directory name is too long"; } else { Tcl_AppendResult(interp, "error getting working directory name: ", Tcl_UnixError(interp), (char *) NULL); } return TCL_ERROR; } #endif currentDir = (char *) malloc((unsigned) (strlen(buffer) + 1)); strcpy(currentDir, buffer); } interp->result = currentDir; return TCL_OK; } /* *---------------------------------------------------------------------- * * Tcl_PutsCmd -- * * This procedure is invoked to process the "puts" Tcl command. * See the user documentation for details on what it does. * * Results: * A standard Tcl result. * * Side effects: * See the user documentation. * *---------------------------------------------------------------------- */ /* ARGSUSED */ int Tcl_PutsCmd(dummy, interp, argc, argv) void *dummy; /* Not used. */ Tcl_Interp *interp; /* Current interpreter. */ int argc; /* Number of arguments. */ unsigned char **argv; /* Argument strings. */ { OpenFile *filePtr; FILE *f; int i, newline; char *fileId; i = 1; newline = 1; if ((argc >= 2) && (strcmp(argv[1], "-nonewline") == 0)) { newline = 0; i++; } if ((i < (argc-3)) || (i >= argc)) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], "\" ?-nonewline? ?fileId? string", (char *) NULL); return TCL_ERROR; } /* * The code below provides backwards compatibility with an old * form of the command that is no longer recommended or documented. */ if (i == (argc-3)) { if (strncmp(argv[i+2], "nonewline", strlen(argv[i+2])) != 0) { Tcl_AppendResult(interp, "bad argument \"", argv[i+2], "\": should be \"nonewline\"", (char *) NULL); return TCL_ERROR; } newline = 0; } if (i == (argc-1)) { fileId = "stdout"; } else { fileId = argv[i]; i++; } if (TclGetOpenFile(interp, fileId, &filePtr) != TCL_OK) { return TCL_ERROR; } if (!filePtr->writable) { Tcl_AppendResult(interp, "\"", fileId, "\" wasn't opened for writing", (char *) NULL); return TCL_ERROR; } f = filePtr->f2; if (f == NULL) { f = filePtr->f; } fputs(argv[i], f); if (newline) { fputc('\n', f); } if (ferror(f)) { Tcl_AppendResult(interp, "error writing \"", fileId, "\": ", Tcl_UnixError(interp), (char *) NULL); clearerr(f); return TCL_ERROR; } return TCL_OK; } /* *---------------------------------------------------------------------- * * Tcl_ReadCmd -- * * This procedure is invoked to process the "read" Tcl command. * See the user documentation for details on what it does. * * Results: * A standard Tcl result. * * Side effects: * See the user documentation. * *---------------------------------------------------------------------- */ /* ARGSUSED */ int Tcl_ReadCmd(dummy, interp, argc, argv) void *dummy; /* Not used. */ Tcl_Interp *interp; /* Current interpreter. */ int argc; /* Number of arguments. */ unsigned char **argv; /* Argument strings. */ { OpenFile *filePtr; int bytesLeft, bytesRead, count; #define READ_BUF_SIZE 4096 char buffer[READ_BUF_SIZE+1]; int newline, i; if ((argc != 2) && (argc != 3)) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " fileId ?numBytes?\" or \"", argv[0], " ?-nonewline? fileId\"", (char *) NULL); return TCL_ERROR; } i = 1; newline = 1; if ((argc == 3) && (strcmp(argv[1], "-nonewline") == 0)) { newline = 0; i++; } if (TclGetOpenFile(interp, argv[i], &filePtr) != TCL_OK) { return TCL_ERROR; } if (!filePtr->readable) { Tcl_AppendResult(interp, "\"", argv[i], "\" wasn't opened for reading", (char *) NULL); return TCL_ERROR; } /* * Compute how many bytes to read, and see whether the final * newline should be dropped. */ if ((argc >= (i + 2)) && isdigit(argv[i+1][0])) { if (Tcl_GetInt(interp, argv[i+1], &bytesLeft) != TCL_OK) { return TCL_ERROR; } } else { bytesLeft = 1<<30; /* * The code below provides backward compatibility for an * archaic earlier version of this command. */ if (argc >= (i + 2)) { if (strncmp(argv[i+1], "nonewline", strlen(argv[i+1])) == 0) { newline = 0; } else { Tcl_AppendResult(interp, "bad argument \"", argv[i+1], "\": should be \"nonewline\"", (char *) NULL); return TCL_ERROR; } } } /* * Read the file in one or more chunks. */ bytesRead = 0; while (bytesLeft > 0) { count = READ_BUF_SIZE; if (bytesLeft < READ_BUF_SIZE) { count = bytesLeft; } count = fread(buffer, 1, count, filePtr->f); if (ferror(filePtr->f)) { Tcl_ResetResult(interp); Tcl_AppendResult(interp, "error reading \"", argv[i], "\": ", Tcl_UnixError(interp), (char *) NULL); clearerr(filePtr->f); return TCL_ERROR; } if (count == 0) { break; } buffer[count] = 0; Tcl_AppendResult(interp, buffer, (char *) NULL); bytesLeft -= count; bytesRead += count; } if ((newline == 0) && (bytesRead > 0) && (interp->result[bytesRead-1] == '\n')) { interp->result[bytesRead-1] = 0; } return TCL_OK; } /* *---------------------------------------------------------------------- * * Tcl_SeekCmd -- * * This procedure is invoked to process the "seek" Tcl command. * See the user documentation for details on what it does. * * Results: * A standard Tcl result. * * Side effects: * See the user documentation. * *---------------------------------------------------------------------- */ /* ARGSUSED */ int Tcl_SeekCmd(notUsed, interp, argc, argv) void *notUsed; /* Not used. */ Tcl_Interp *interp; /* Current interpreter. */ int argc; /* Number of arguments. */ unsigned char **argv; /* Argument strings. */ { OpenFile *filePtr; int offset, mode; if ((argc != 3) && (argc != 4)) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " fileId offset ?origin?\"", (char *) NULL); return TCL_ERROR; } if (TclGetOpenFile(interp, argv[1], &filePtr) != TCL_OK) { return TCL_ERROR; } if (Tcl_GetInt(interp, argv[2], &offset) != TCL_OK) { return TCL_ERROR; } mode = SEEK_SET; if (argc == 4) { int length; char c; length = strlen(argv[3]); c = argv[3][0]; if ((c == 's') && (strncmp(argv[3], "start", length) == 0)) { mode = SEEK_SET; } else if ((c == 'c') && (strncmp(argv[3], "current", length) == 0)) { mode = SEEK_CUR; } else if ((c == 'e') && (strncmp(argv[3], "end", length) == 0)) { mode = SEEK_END; } else { Tcl_AppendResult(interp, "bad origin \"", argv[3], "\": should be start, current, or end", (char *) NULL); return TCL_ERROR; } } if (fseek(filePtr->f, (long) offset, mode) == -1) { Tcl_AppendResult(interp, "error during seek: ", Tcl_UnixError(interp), (char *) NULL); clearerr(filePtr->f); return TCL_ERROR; } return TCL_OK; } /* *---------------------------------------------------------------------- * * Tcl_SourceCmd -- * * This procedure is invoked to process the "source" Tcl command. * See the user documentation for details on what it does. * * Results: * A standard Tcl result. * * Side effects: * See the user documentation. * *---------------------------------------------------------------------- */ /* ARGSUSED */ int Tcl_SourceCmd(dummy, interp, argc, argv) void *dummy; /* Not used. */ Tcl_Interp *interp; /* Current interpreter. */ int argc; /* Number of arguments. */ unsigned char **argv; /* Argument strings. */ { if (argc != 2) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " fileName\"", (char *) NULL); return TCL_ERROR; } return Tcl_EvalFile(interp, argv[1]); } /* *---------------------------------------------------------------------- * * Tcl_TellCmd -- * * This procedure is invoked to process the "tell" Tcl command. * See the user documentation for details on what it does. * * Results: * A standard Tcl result. * * Side effects: * See the user documentation. * *---------------------------------------------------------------------- */ /* ARGSUSED */ int Tcl_TellCmd(notUsed, interp, argc, argv) void *notUsed; /* Not used. */ Tcl_Interp *interp; /* Current interpreter. */ int argc; /* Number of arguments. */ unsigned char **argv; /* Argument strings. */ { OpenFile *filePtr; if (argc != 2) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " fileId\"", (char *) NULL); return TCL_ERROR; } if (TclGetOpenFile(interp, argv[1], &filePtr) != TCL_OK) { return TCL_ERROR; } sprintf(interp->result, "%ld", ftell(filePtr->f)); return TCL_OK; } /* *---------------------------------------------------------------------- * * Tcl_TimeCmd -- * * This procedure is invoked to process the "time" Tcl command. * See the user documentation for details on what it does. * * Results: * A standard Tcl result. * * Side effects: * See the user documentation. * *---------------------------------------------------------------------- */ /* ARGSUSED */ int Tcl_TimeCmd(dummy, interp, argc, argv) void *dummy; /* Not used. */ Tcl_Interp *interp; /* Current interpreter. */ int argc; /* Number of arguments. */ unsigned char **argv; /* Argument strings. */ { int count, i, result; double timePer; struct timeval start, stop; struct timezone tz; int micros; if (argc == 2) { count = 1; } else if (argc == 3) { if (Tcl_GetInt(interp, argv[2], &count) != TCL_OK) { return TCL_ERROR; } } else { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " command ?count?\"", (char *) NULL); return TCL_ERROR; } gettimeofday(&start, &tz); for (i = count ; i > 0; i--) { result = Tcl_Eval(interp, argv[1], 0, NULL); if (result != TCL_OK) { if (result == TCL_ERROR) { char msg[60]; sprintf(msg, "\n (\"time\" body line %d)", interp->errorLine); Tcl_AddErrorInfo(interp, msg); } return result; } } gettimeofday(&stop, &tz); micros = (stop.tv_sec - start.tv_sec)*1000000 + (stop.tv_usec - start.tv_usec); timePer = micros; Tcl_ResetResult(interp); sprintf(interp->result, "%.0f microseconds per iteration", timePer/count); return TCL_OK; } /* *---------------------------------------------------------------------- * * CleanupChildren -- * * This is a utility procedure used to wait for child processes * to exit, record information about abnormal exits, and then * collect any stderr output generated by them. * * Results: * The return value is a standard Tcl result. If anything at * weird happened with the child processes, TCL_ERROR is returned * and a message is left in interp->result. * * Side effects: * If the last character of interp->result is a newline, then it * is removed. File errorId gets closed, and pidPtr is freed * back to the storage allocator. * *---------------------------------------------------------------------- */ static int CleanupChildren(interp, numPids, pidPtr, errorId) Tcl_Interp *interp; /* Used for error messages. */ int numPids; /* Number of entries in pidPtr array. */ int *pidPtr; /* Array of process ids of children. */ int errorId; /* File descriptor index for file containing * stderr output from pipeline. -1 means * there isn't any stderr output. */ { int result = TCL_OK; int i, pid, length; #define WAIT_STATUS_TYPE int WAIT_STATUS_TYPE waitStatus; for (i = 0; i < numPids; i++) { pid = Tcl_WaitPids(1, &pidPtr[i], (int *) &waitStatus); if (pid == -1) { Tcl_AppendResult(interp, "error waiting for process to exit: ", Tcl_UnixError(interp), (char *) NULL); continue; } /* * Create error messages for unusual process exits. An * extra newline gets appended to each error message, but * it gets removed below (in the same fashion that an * extra newline in the command's output is removed). */ if (!WIFEXITED(waitStatus) || (WEXITSTATUS(waitStatus) != 0)) { char msg1[20], msg2[20]; result = TCL_ERROR; sprintf(msg1, "%d", pid); if (WIFEXITED(waitStatus)) { sprintf(msg2, "%d", WEXITSTATUS(waitStatus)); Tcl_SetErrorCode(interp, "CHILDSTATUS", msg1, msg2, (char *) NULL); } else if (WIFSIGNALED(waitStatus)) { char *p; p = Tcl_SignalMsg((int) (WTERMSIG(waitStatus))); Tcl_SetErrorCode(interp, "CHILDKILLED", msg1, Tcl_SignalId((int) (WTERMSIG(waitStatus))), p, (char *) NULL); Tcl_AppendResult(interp, "child killed: ", p, "\n", (char *) NULL); } else if (WIFSTOPPED(waitStatus)) { char *p; p = Tcl_SignalMsg((int) (WSTOPSIG(waitStatus))); Tcl_SetErrorCode(interp, "CHILDSUSP", msg1, Tcl_SignalId((int) (WSTOPSIG(waitStatus))), p, (char *) NULL); Tcl_AppendResult(interp, "child suspended: ", p, "\n", (char *) NULL); } else { Tcl_AppendResult(interp, "child wait status didn't make sense\n", (char *) NULL); } } } free((char *) pidPtr); /* * Read the standard error file. If there's anything there, * then return an error and add the file's contents to the result * string. */ if (errorId >= 0) { while (1) { # define BUFFER_SIZE 1000 char buffer[BUFFER_SIZE+1]; int count; count = read(errorId, buffer, BUFFER_SIZE); if (count == 0) { break; } if (count < 0) { Tcl_AppendResult(interp, "error reading stderr output file: ", Tcl_UnixError(interp), (char *) NULL); break; } buffer[count] = 0; Tcl_AppendResult(interp, buffer, (char *) NULL); } close(errorId); } /* * If the last character of interp->result is a newline, then remove * the newline character (the newline would just confuse things). */ length = strlen(interp->result); if ((length > 0) && (interp->result[length-1] == '\n')) { interp->result[length-1] = '\0'; } return result; } ================================================ FILE: lib/libtcl/tclutil.c ================================================ /* * tclUtil.c -- * * This file contains utility procedures that are used by many Tcl * commands. * * Copyright 1987-1991 Regents of the University of California * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without * fee is hereby granted, provided that the above copyright * notice appear in all copies. The University of California * makes no representations about the suitability of this * software for any purpose. It is provided "as is" without * express or implied warranty. */ #include "internal.h" #include "regexp.h" #include /* * The following values are used in the flags returned by Tcl_ScanElement * and used by Tcl_ConvertElement. The value TCL_DONT_USE_BRACES is also * defined in tcl.h; make sure its value doesn't overlap with any of the * values below. * * TCL_DONT_USE_BRACES - 1 means the string mustn't be enclosed in * braces (e.g. it contains unmatched braces, * or ends in a backslash character, or user * just doesn't want braces); handle all * special characters by adding backslashes. * USE_BRACES - 1 means the string contains a special * character that can be handled simply by * enclosing the entire argument in braces. * BRACES_UNMATCHED - 1 means that braces aren't properly matched * in the argument. */ #define USE_BRACES 2 #define BRACES_UNMATCHED 4 /* * Function prototypes for local procedures in this file: */ static void SetupAppendBuffer (Interp *iPtr, int newSpace); /* *---------------------------------------------------------------------- * * TclFindElement -- * * Given a pointer into a Tcl list, locate the first (or next) * element in the list. * * Results: * The return value is normally TCL_OK, which means that the * element was successfully located. If TCL_ERROR is returned * it means that list didn't have proper list structure; * interp->result contains a more detailed error message. * * If TCL_OK is returned, then *elementPtr will be set to point * to the first element of list, and *nextPtr will be set to point * to the character just after any white space following the last * character that's part of the element. If this is the last argument * in the list, then *nextPtr will point to the NULL character at the * end of list. If sizePtr is non-NULL, *sizePtr is filled in with * the number of characters in the element. If the element is in * braces, then *elementPtr will point to the character after the * opening brace and *sizePtr will not include either of the braces. * If there isn't an element in the list, *sizePtr will be zero, and * both *elementPtr and *termPtr will refer to the null character at * the end of list. Note: this procedure does NOT collapse backslash * sequences. * * Side effects: * None. * *---------------------------------------------------------------------- */ int TclFindElement(interp, list, elementPtr, nextPtr, sizePtr, bracePtr) Tcl_Interp *interp; /* Interpreter to use for error reporting. */ register unsigned char *list; /* String containing Tcl list with zero * or more elements (possibly in braces). */ unsigned char **elementPtr; /* Fill in with location of first significant * character in first element of list. */ unsigned char **nextPtr; /* Fill in with location of character just * after all white space following end of * argument (i.e. next argument or end of * list). */ int *sizePtr; /* If non-zero, fill in with size of * element. */ int *bracePtr; /* If non-zero fill in with non-zero/zero * to indicate that arg was/wasn't * in braces. */ { register unsigned char *p; int openBraces = 0; int inQuotes = 0; int size; /* * Skim off leading white space and check for an opening brace or quote. */ while (isspace (*list)) { list++; } if (*list == '{') { openBraces = 1; list++; } else if (*list == '"') { inQuotes = 1; list++; } if (bracePtr != 0) { *bracePtr = openBraces; } p = list; /* * Find the end of the element (either a space or a close brace or * the end of the string). */ while (1) { switch (*p) { /* * Open brace: don't treat specially unless the element is * in braces. In this case, keep a nesting count. */ case '{': if (openBraces != 0) { openBraces++; } break; /* * Close brace: if element is in braces, keep nesting * count and quit when the last close brace is seen. */ case '}': if (openBraces == 1) { unsigned char *p2; size = p - list; p++; if ((isspace (*p)) || (*p == 0)) { goto done; } for (p2 = p; (*p2 != 0) && (!isspace(*p2)) && (p2 < p+20); p2++) { /* null body */ } Tcl_ResetResult(interp); sprintf(interp->result, "list element in braces followed by \"%.*s\" instead of space", (int) (p2 - p), p); return TCL_ERROR; } else if (openBraces != 0) { openBraces--; } break; /* * Backslash: skip over everything up to the end of the * backslash sequence. */ case '\\': { int size; (void) Tcl_Backslash(p, &size); p += size - 1; break; } /* * Space: ignore if element is in braces or quotes; otherwise * terminate element. */ case ' ': case '\f': case '\n': case '\r': case '\t': case '\v': if ((openBraces == 0) && !inQuotes) { size = p - list; goto done; } break; /* * Double-quote: if element is in quotes then terminate it. */ case '"': if (inQuotes) { unsigned char *p2; size = p-list; p++; if (isspace (*p) || (*p == 0)) { goto done; } for (p2 = p; (*p2 != 0) && (!isspace(*p2)) && (p2 < p+20); p2++) { /* null body */ } Tcl_ResetResult(interp); sprintf(interp->result, "list element in quotes followed by \"%.*s\" %s", (int) (p2 - p), p, "instead of space"); return TCL_ERROR; } break; /* * End of list: terminate element. */ case 0: if (openBraces != 0) { Tcl_SetResult(interp, (unsigned char*) "unmatched open brace in list", TCL_STATIC); return TCL_ERROR; } else if (inQuotes) { Tcl_SetResult(interp, (unsigned char*) "unmatched open quote in list", TCL_STATIC); return TCL_ERROR; } size = p - list; goto done; } p++; } done: while (isspace (*p)) { p++; } *elementPtr = list; *nextPtr = p; if (sizePtr != 0) { *sizePtr = size; } return TCL_OK; } /* *---------------------------------------------------------------------- * * TclCopyAndCollapse -- * * Copy a string and eliminate any backslashes that aren't in braces. * * Results: * There is no return value. Count chars. get copied from src * to dst. Along the way, if backslash sequences are found outside * braces, the backslashes are eliminated in the copy. * After scanning count chars. from source, a null character is * placed at the end of dst. * * Side effects: * None. * *---------------------------------------------------------------------- */ void TclCopyAndCollapse(count, src, dst) int count; /* Total number of characters to copy * from src. */ register unsigned char *src; /* Copy from here... */ register unsigned char *dst; /* ... to here. */ { register char c; int numRead; for (c = *src; count > 0; src++, c = *src, count--) { if (c == '\\') { *dst = Tcl_Backslash(src, &numRead); if (*dst != 0) { dst++; } src += numRead-1; count -= numRead-1; } else { *dst = c; dst++; } } *dst = 0; } /* *---------------------------------------------------------------------- * * Tcl_SplitList -- * * Splits a list up into its constituent fields. * * Results * The return value is normally TCL_OK, which means that * the list was successfully split up. If TCL_ERROR is * returned, it means that "list" didn't have proper list * structure; interp->result will contain a more detailed * error message. * * *argvPtr will be filled in with the address of an array * whose elements point to the elements of list, in order. * *argcPtr will get filled in with the number of valid elements * in the array. A single block of memory is dynamically allocated * to hold both the argv array and a copy of the list (with * backslashes and braces removed in the standard way). * The caller must eventually free this memory by calling free() * on *argvPtr. Note: *argvPtr and *argcPtr are only modified * if the procedure returns normally. * * Side effects: * Memory is allocated. * *---------------------------------------------------------------------- */ int Tcl_SplitList(interp, list, argcPtr, argvPtr) Tcl_Interp *interp; /* Interpreter to use for error reporting. */ unsigned char *list; /* Pointer to string with list structure. */ int *argcPtr; /* Pointer to location to fill in with * the number of elements in the list. */ unsigned char ***argvPtr; /* Pointer to place to store pointer to array * of pointers to list elements. */ { unsigned char **argv; register unsigned char *p; int size, i, result, elSize, brace; unsigned char *element; /* * Figure out how much space to allocate. There must be enough * space for both the array of pointers and also for a copy of * the list. To estimate the number of pointers needed, count * the number of space characters in the list. */ for (size = 1, p = list; *p != 0; p++) { if (isspace(*p)) { size++; } } size++; /* Leave space for final NULL pointer. */ argv = (unsigned char**) malloc ((unsigned) ((size * sizeof(char *)) + (p - list) + 1)); for (i = 0, p = ((unsigned char *) argv) + size*sizeof(char *); *list != 0; i++) { result = TclFindElement(interp, list, &element, &list, &elSize, &brace); if (result != TCL_OK) { free (argv); return result; } if (*element == 0) { break; } if (i >= size) { free (argv); Tcl_SetResult(interp, (unsigned char*) "internal error in Tcl_SplitList", TCL_STATIC); return TCL_ERROR; } argv[i] = p; if (brace) { strncpy(p, element, elSize); p += elSize; *p = 0; p++; } else { TclCopyAndCollapse(elSize, element, p); p += elSize+1; } } argv[i] = 0; *argvPtr = argv; *argcPtr = i; return TCL_OK; } /* *---------------------------------------------------------------------- * * Tcl_ScanElement -- * * This procedure is a companion procedure to Tcl_ConvertElement. * It scans a string to see what needs to be done to it (e.g. * add backslashes or enclosing braces) to make the string into * a valid Tcl list element. * * Results: * The return value is an overestimate of the number of characters * that will be needed by Tcl_ConvertElement to produce a valid * list element from string. The word at *flagPtr is filled in * with a value needed by Tcl_ConvertElement when doing the actual * conversion. * * Side effects: * None. * *---------------------------------------------------------------------- */ int Tcl_ScanElement(string, flagPtr) unsigned char *string; /* String to convert to Tcl list element. */ int *flagPtr; /* Where to store information to guide * Tcl_ConvertElement. */ { int flags, nestingLevel; register unsigned char *p; /* * This procedure and Tcl_ConvertElement together do two things: * * 1. They produce a proper list, one that will yield back the * argument strings when evaluated or when disassembled with * Tcl_SplitList. This is the most important thing. * * 2. They try to produce legible output, which means minimizing the * use of backslashes (using braces instead). However, there are * some situations where backslashes must be used (e.g. an element * like "{abc": the leading brace will have to be backslashed. For * each element, one of three things must be done: * * (a) Use the element as-is (it doesn't contain anything special * characters). This is the most desirable option. * * (b) Enclose the element in braces, but leave the contents alone. * This happens if the element contains embedded space, or if it * contains characters with special interpretation ($, [, ;, or \), * or if it starts with a brace or double-quote, or if there are * no characters in the element. * * (c) Don't enclose the element in braces, but add backslashes to * prevent special interpretation of special characters. This is a * last resort used when the argument would normally fall under case * (b) but contains unmatched braces. It also occurs if the last * character of the argument is a backslash or if the element contains * a backslash followed by newline. * * The procedure figures out how many bytes will be needed to store * the result (actually, it overestimates). It also collects information * about the element in the form of a flags word. */ nestingLevel = 0; flags = 0; if (string == 0) { string = (unsigned char*) ""; } p = string; if ((*p == '{') || (*p == '"') || (*p == 0)) { flags |= USE_BRACES; } for ( ; *p != 0; p++) { switch (*p) { case '{': nestingLevel++; break; case '}': nestingLevel--; if (nestingLevel < 0) { flags |= TCL_DONT_USE_BRACES|BRACES_UNMATCHED; } break; case '[': case '$': case ';': case ' ': case '\f': case '\n': case '\r': case '\t': case '\v': flags |= USE_BRACES; break; case '\\': if ((p[1] == 0) || (p[1] == '\n')) { flags = TCL_DONT_USE_BRACES; } else { int size; (void) Tcl_Backslash(p, &size); p += size-1; flags |= USE_BRACES; } break; } } if (nestingLevel != 0) { flags = TCL_DONT_USE_BRACES | BRACES_UNMATCHED; } *flagPtr = flags; /* * Allow enough space to backslash every character plus leave * two spaces for braces. */ return 2*(p-string) + 2; } /* *---------------------------------------------------------------------- * * Tcl_ConvertElement -- * * This is a companion procedure to Tcl_ScanElement. Given the * information produced by Tcl_ScanElement, this procedure converts * a string to a list element equal to that string. * * Results: * Information is copied to *dst in the form of a list element * identical to src (i.e. if Tcl_SplitList is applied to dst it * will produce a string identical to src). The return value is * a count of the number of characters copied (not including the * terminating NULL character). * * Side effects: * None. * *---------------------------------------------------------------------- */ int Tcl_ConvertElement(src, dst, flags) register unsigned char *src; /* Source information for list element. */ unsigned char *dst; /* Place to put list-ified element. */ int flags; /* Flags produced by Tcl_ScanElement. */ { register unsigned char *p = dst; /* * See the comment block at the beginning of the Tcl_ScanElement * code for details of how this works. */ if (src == 0) { src = (unsigned char*) ""; } if ((flags & USE_BRACES) && !(flags & TCL_DONT_USE_BRACES)) { *p = '{'; p++; for ( ; *src != 0; src++, p++) { *p = *src; } *p = '}'; p++; } else if (*src == 0) { /* * If string is empty but can't use braces, then use special * backslash sequence that maps to empty string. */ p[0] = '\\'; p[1] = '0'; p += 2; } else { for (; *src != 0 ; src++) { switch (*src) { case ']': case '[': case '$': case ';': case ' ': case '\\': case '"': *p = '\\'; p++; break; case '{': case '}': if (flags & BRACES_UNMATCHED) { *p = '\\'; p++; } break; case '\f': *p = '\\'; p++; *p = 'f'; p++; continue; case '\n': *p = '\\'; p++; *p = 'n'; p++; continue; case '\r': *p = '\\'; p++; *p = 'r'; p++; continue; case '\t': *p = '\\'; p++; *p = 't'; p++; continue; case '\v': *p = '\\'; p++; *p = 'v'; p++; continue; } *p = *src; p++; } } *p = '\0'; return p-dst; } /* *---------------------------------------------------------------------- * * Tcl_Merge -- * * Given a collection of strings, merge them together into a * single string that has proper Tcl list structured (i.e. * Tcl_SplitList may be used to retrieve strings equal to the * original elements, and Tcl_Eval will parse the string back * into its original elements). * * Results: * The return value is the address of a dynamically-allocated * string containing the merged list. * * Side effects: * None. * *---------------------------------------------------------------------- */ unsigned char * Tcl_Merge (int argc, /* How many strings to merge. */ unsigned char **argv) /* Array of string values. */ { # define LOCAL_SIZE 20 int localFlags[LOCAL_SIZE], *flagPtr; int numChars; unsigned char *result; register unsigned char *dst; int i; /* * Pass 1: estimate space, gather flags. */ if (argc <= LOCAL_SIZE) { flagPtr = localFlags; } else { flagPtr = (int*) malloc ((unsigned) argc*sizeof(int)); } numChars = 1; for (i = 0; i < argc; i++) { numChars += Tcl_ScanElement(argv[i], &flagPtr[i]) + 1; } /* * Pass two: copy into the result area. */ result = malloc (numChars); dst = result; for (i = 0; i < argc; i++) { numChars = Tcl_ConvertElement(argv[i], dst, flagPtr[i]); dst += numChars; *dst = ' '; dst++; } if (dst == result) { *dst = 0; } else { dst[-1] = 0; } if (flagPtr != localFlags) { free (flagPtr); } return result; } /* *---------------------------------------------------------------------- * * Tcl_Concat -- * * Concatenate a set of strings into a single large string. * * Results: * The return value is dynamically-allocated string containing * a concatenation of all the strings in argv, with spaces between * the original argv elements. * * Side effects: * Memory is allocated for the result; the caller is responsible * for freeing the memory. * *---------------------------------------------------------------------- */ unsigned char * Tcl_Concat (int argc, /* Number of strings to concatenate. */ unsigned char **argv) /* Array of strings to concatenate. */ { int totalSize, i; register unsigned char *p; unsigned char *result; for (totalSize = 1, i = 0; i < argc; i++) { totalSize += strlen(argv[i]) + 1; } result = malloc (totalSize); if (argc == 0) { *result = '\0'; return result; } for (p = result, i = 0; i < argc; i++) { unsigned char *element; int length; /* * Clip white space off the front and back of the string * to generate a neater result, and ignore any empty * elements. */ element = argv[i]; while (isspace(*element)) { element++; } for (length = strlen(element); (length > 0) && (isspace(element[length-1])); length--) { /* Null loop body. */ } if (length == 0) { continue; } (void) strncpy(p, element, length); p += length; *p = ' '; p++; } if (p != result) { p[-1] = 0; } else { *p = 0; } return result; } /* *---------------------------------------------------------------------- * * Tcl_StringMatch -- * * See if a particular string matches a particular pattern. * * Results: * The return value is 1 if string matches pattern, and * 0 otherwise. The matching operation permits the following * special characters in the pattern: *?\[] (see the manual * entry for details on what these mean). * * Side effects: * None. * *---------------------------------------------------------------------- */ int Tcl_StringMatch(string, pattern) register unsigned char *string; /* String. */ register unsigned char *pattern; /* Pattern, which may contain * special characters. */ { char c2; while (1) { /* See if we're at the end of both the pattern and the string. * If so, we succeeded. If we're at the end of the pattern * but not at the end of the string, we failed. */ if (*pattern == 0) { if (*string == 0) { return 1; } else { return 0; } } if ((*string == 0) && (*pattern != '*')) { return 0; } /* Check for a "*" as the next pattern character. It matches * any substring. We handle this by calling ourselves * recursively for each postfix of string, until either we * match or we reach the end of the string. */ if (*pattern == '*') { pattern += 1; if (*pattern == 0) { return 1; } while (1) { if (Tcl_StringMatch(string, pattern)) { return 1; } if (*string == 0) { return 0; } string += 1; } } /* Check for a "?" as the next pattern character. It matches * any single character. */ if (*pattern == '?') { goto thisCharOK; } /* Check for a "[" as the next pattern character. It is followed * by a list of characters that are acceptable, or by a range * (two characters separated by "-"). */ if (*pattern == '[') { pattern += 1; while (1) { if ((*pattern == ']') || (*pattern == 0)) { return 0; } if (*pattern == *string) { break; } if (pattern[1] == '-') { c2 = pattern[2]; if (c2 == 0) { return 0; } if ((*pattern <= *string) && (c2 >= *string)) { break; } if ((*pattern >= *string) && (c2 <= *string)) { break; } pattern += 2; } pattern += 1; } while ((*pattern != ']') && (*pattern != 0)) { pattern += 1; } goto thisCharOK; } /* If the next pattern character is '/', just strip off the '/' * so we do exact matching on the character that follows. */ if (*pattern == '\\') { pattern += 1; if (*pattern == 0) { return 0; } } /* There's no special character. Just make sure that the next * characters of each string match. */ if (*pattern != *string) { return 0; } thisCharOK: pattern += 1; string += 1; } } /* *---------------------------------------------------------------------- * * Tcl_SetResult -- * * Arrange for "string" to be the Tcl return value. * * Results: * None. * * Side effects: * interp->result is left pointing either to "string" (if "copy" is 0) * or to a copy of string. * *---------------------------------------------------------------------- */ void Tcl_SetResult(interp, string, freeProc) Tcl_Interp *interp; /* Interpreter with which to associate the * return value. */ unsigned char *string; /* Value to be returned. If NULL, * the result is set to an empty string. */ Tcl_FreeProc *freeProc; /* Gives information about the string: * TCL_STATIC, TCL_VOLATILE, or the address * of a Tcl_FreeProc such as free. */ { register Interp *iPtr = (Interp *) interp; int length; Tcl_FreeProc *oldFreeProc = iPtr->freeProc; unsigned char *oldResult = iPtr->result; iPtr->freeProc = freeProc; if (string == 0) { iPtr->resultSpace[0] = 0; iPtr->result = iPtr->resultSpace; iPtr->freeProc = 0; } else if (freeProc == TCL_VOLATILE) { length = strlen(string); if (length > TCL_RESULT_SIZE) { iPtr->result = malloc (length+1); iPtr->freeProc = (Tcl_FreeProc *) free; } else { iPtr->result = iPtr->resultSpace; iPtr->freeProc = 0; } strcpy(iPtr->result, string); } else { iPtr->result = string; } /* * If the old result was dynamically-allocated, free it up. Do it * here, rather than at the beginning, in case the new result value * was part of the old result value. */ if (oldFreeProc != 0) { if (oldFreeProc == TCL_DYNAMIC) { free(oldResult); } else { (*oldFreeProc)(oldResult); } } } /* *---------------------------------------------------------------------- * * Tcl_AppendResult -- * * Append a variable number of strings onto the result already * present for an interpreter. * * Results: * None. * * Side effects: * The result in the interpreter given by the first argument * is extended by the strings given by the second and following * arguments (up to a terminating NULL argument). * *---------------------------------------------------------------------- */ /* VARARGS2 */ void Tcl_AppendResult (Tcl_Interp *interp, /* Interpreter whose result is to be * extended. */ ...) /* One or more strings to add to the * result, terminated with NULL. */ { va_list argList; register Interp *iPtr = (Interp *) interp; unsigned char *string; int newSpace; /* * First, scan through all the arguments to see how much space is * needed. */ va_start(argList, interp); newSpace = 0; while (1) { string = va_arg(argList, unsigned char *); if (string == 0) { break; } newSpace += strlen(string); } va_end(argList); /* * If the append buffer isn't already setup and large enough * to hold the new data, set it up. */ if ((iPtr->result != iPtr->appendResult) || ((newSpace + iPtr->appendUsed) >= iPtr->appendAvl)) { SetupAppendBuffer(iPtr, newSpace); } /* * Final step: go through all the argument strings again, copying * them into the buffer. */ va_start(argList, interp); while (1) { string = va_arg(argList, unsigned char *); if (string == 0) { break; } strcpy(iPtr->appendResult + iPtr->appendUsed, string); iPtr->appendUsed += strlen(string); } va_end(argList); } /* *---------------------------------------------------------------------- * * Tcl_AppendElement -- * * Convert a string to a valid Tcl list element and append it * to the current result (which is ostensibly a list). * * Results: * None. * * Side effects: * The result in the interpreter given by the first argument * is extended with a list element converted from string. If * the original result wasn't empty, then a blank is added before * the converted list element. * *---------------------------------------------------------------------- */ void Tcl_AppendElement(interp, string, noSep) Tcl_Interp *interp; /* Interpreter whose result is to be * extended. */ unsigned char *string; /* String to convert to list element and * add to result. */ int noSep; /* If non-zero, then don't output a * space character before this element, * even if the element isn't the first * thing in the output buffer. */ { register Interp *iPtr = (Interp *) interp; int size, flags; unsigned char *dst; /* * See how much space is needed, and grow the append buffer if * needed to accommodate the list element. */ size = Tcl_ScanElement(string, &flags) + 1; if ((iPtr->result != iPtr->appendResult) || ((size + iPtr->appendUsed) >= iPtr->appendAvl)) { SetupAppendBuffer(iPtr, size+iPtr->appendUsed); } /* * Convert the string into a list element and copy it to the * buffer that's forming. */ dst = iPtr->appendResult + iPtr->appendUsed; if (!noSep && (iPtr->appendUsed != 0)) { iPtr->appendUsed++; *dst = ' '; dst++; } iPtr->appendUsed += Tcl_ConvertElement(string, dst, flags); } /* *---------------------------------------------------------------------- * * SetupAppendBuffer -- * * This procedure makes sure that there is an append buffer * properly initialized for interp, and that it has at least * enough room to accommodate newSpace new bytes of information. * * Results: * None. * * Side effects: * None. * *---------------------------------------------------------------------- */ static void SetupAppendBuffer(iPtr, newSpace) register Interp *iPtr; /* Interpreter whose result is being set up. */ int newSpace; /* Make sure that at least this many bytes * of new information may be added. */ { int totalSpace; /* * Make the append buffer larger, if that's necessary, then * copy the current result into the append buffer and make the * append buffer the official Tcl result. */ if (iPtr->result != iPtr->appendResult) { /* * If an oversized buffer was used recently, then free it up * so we go back to a smaller buffer. This avoids tying up * memory forever after a large operation. */ if (iPtr->appendAvl > 500) { free (iPtr->appendResult); iPtr->appendResult = 0; iPtr->appendAvl = 0; } iPtr->appendUsed = strlen(iPtr->result); } totalSpace = newSpace + iPtr->appendUsed; if (totalSpace >= iPtr->appendAvl) { unsigned char *new; if (totalSpace < 100) { totalSpace = 200; } else { totalSpace *= 2; } new = malloc (totalSpace); strcpy(new, iPtr->result); if (iPtr->appendResult != 0) { free (iPtr->appendResult); } iPtr->appendResult = new; iPtr->appendAvl = totalSpace; } else if (iPtr->result != iPtr->appendResult) { strcpy(iPtr->appendResult, iPtr->result); } Tcl_FreeResult ((Tcl_Interp*) iPtr); iPtr->result = iPtr->appendResult; } /* *---------------------------------------------------------------------- * * Tcl_ResetResult -- * * This procedure restores the result area for an interpreter * to its default initialized state, freeing up any memory that * may have been allocated for the result and clearing any * error information for the interpreter. * * Results: * None. * * Side effects: * None. * *---------------------------------------------------------------------- */ void Tcl_ResetResult(interp) Tcl_Interp *interp; /* Interpreter for which to clear result. */ { register Interp *iPtr = (Interp *) interp; Tcl_FreeResult ((Tcl_Interp*) iPtr); iPtr->result = iPtr->resultSpace; iPtr->resultSpace[0] = 0; iPtr->flags &= ~(ERR_ALREADY_LOGGED | ERR_IN_PROGRESS | ERROR_CODE_SET); } /* *---------------------------------------------------------------------- * * Tcl_SetErrorCode -- * * This procedure is called to record machine-readable information * about an error that is about to be returned. * * Results: * None. * * Side effects: * The errorCode global variable is modified to hold all of the * arguments to this procedure, in a list form with each argument * becoming one element of the list. A flag is set internally * to remember that errorCode has been set, so the variable doesn't * get set automatically when the error is returned. * *---------------------------------------------------------------------- */ /* VARARGS2 */ void Tcl_SetErrorCode (Tcl_Interp *interp, /* Interpreter whose errorCode variable is * to be set. */ ...) /* One or more elements to add to errorCode, * terminated with NULL. */ { va_list argList; unsigned char *string; int flags; Interp *iPtr = (Interp *) interp; /* * Scan through the arguments one at a time, appending them to * $errorCode as list elements. */ va_start(argList, interp); flags = TCL_GLOBAL_ONLY | TCL_LIST_ELEMENT; while (1) { string = va_arg(argList, unsigned char *); if (string == 0) { break; } Tcl_SetVar2((Tcl_Interp *) iPtr, (unsigned char*) "errorCode", 0, string, flags); flags |= TCL_APPEND_VALUE; } va_end(argList); iPtr->flags |= ERROR_CODE_SET; } /* *---------------------------------------------------------------------- * * TclGetListIndex -- * * Parse a list index, which may be either an integer or the * value "end". * * Results: * The return value is either TCL_OK or TCL_ERROR. If it is * TCL_OK, then the index corresponding to string is left in * *indexPtr. If the return value is TCL_ERROR, then string * was bogus; an error message is returned in interp->result. * If a negative index is specified, it is rounded up to 0. * The index value may be larger than the size of the list * (this happens when "end" is specified). * * Side effects: * None. * *---------------------------------------------------------------------- */ int TclGetListIndex(interp, string, indexPtr) Tcl_Interp *interp; /* Interpreter for error reporting. */ unsigned char *string; /* String containing list index. */ int *indexPtr; /* Where to store index. */ { if (isdigit(*string) || (*string == '-')) { if (Tcl_GetInt(interp, string, indexPtr) != TCL_OK) { return TCL_ERROR; } if (*indexPtr < 0) { *indexPtr = 0; } } else if (strncmp(string, (unsigned char*) "end", strlen(string)) == 0) { *indexPtr = 32767; } else { Tcl_AppendResult(interp, "bad index \"", string, "\": must be integer or \"end\"", 0); return TCL_ERROR; } return TCL_OK; } /* *---------------------------------------------------------------------- * * TclCompileRegexp -- * * Compile a regular expression into a form suitable for fast * matching. This procedure retains a small cache of pre-compiled * regular expressions in the interpreter, in order to avoid * compilation costs as much as possible. * * Results: * The return value is a pointer to the compiled form of string, * suitable for passing to regexec. If an error occurred while * compiling the pattern, then NULL is returned and an error * message is left in interp->result. * * Side effects: * The cache of compiled regexp's in interp will be modified to * hold information for string, if such information isn't already * present in the cache. * *---------------------------------------------------------------------- */ regexp_t * TclCompileRegexp(interp, string) Tcl_Interp *interp; /* For use in error reporting. */ unsigned char *string; /* String for which to produce * compiled regular expression. */ { register Interp *iPtr = (Interp *) interp; int i, length, size; regexp_t *result; length = strlen(string); for (i = 0; i < NUM_REGEXPS; i++) { if ((length == iPtr->patLengths[i]) && (strcmp(string, iPtr->patterns[i]) == 0)) { /* * Move the matched pattern to the first slot in the * cache and shift the other patterns down one position. */ if (i != 0) { int j; unsigned char *cachedString; cachedString = iPtr->patterns[i]; result = iPtr->regexps[i]; for (j = i-1; j >= 0; j--) { iPtr->patterns[j+1] = iPtr->patterns[j]; iPtr->patLengths[j+1] = iPtr->patLengths[j]; iPtr->regexps[j+1] = iPtr->regexps[j]; } iPtr->patterns[0] = cachedString; iPtr->patLengths[0] = length; iPtr->regexps[0] = result; } return iPtr->regexps[0]; } } /* * No match in the cache. Compile the string and add it to the * cache. */ size = regexp_size (string); if (size <= 0) { Tcl_AppendResult(interp, "invalid regular expression pattern", 0); return 0; } result = (regexp_t*) malloc (size); if (! regexp_compile (result, string)) { Tcl_AppendResult(interp, "couldn't compile regular expression pattern", 0); return 0; } if (iPtr->patterns[NUM_REGEXPS-1] != 0) { free (iPtr->patterns[NUM_REGEXPS-1]); free (iPtr->regexps[NUM_REGEXPS-1]); } for (i = NUM_REGEXPS - 2; i >= 0; i--) { iPtr->patterns[i+1] = iPtr->patterns[i]; iPtr->patLengths[i+1] = iPtr->patLengths[i]; iPtr->regexps[i+1] = iPtr->regexps[i]; } iPtr->patterns[0] = malloc (length+1); strcpy(iPtr->patterns[0], string); iPtr->patLengths[0] = length; iPtr->regexps[0] = result; return result; } ================================================ FILE: lib/libtcl/tcluxstr.c ================================================ /* * tclUnixStr.c -- * * This file contains procedures that generate strings * corresponding to various UNIX-related codes, such * as errno and signals. * * Copyright 1991 Regents of the University of California * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without * fee is hereby granted, provided that this copyright * notice appears in all copies. The University of California * makes no representations about the suitability of this * software for any purpose. It is provided "as is" without * express or implied warranty. */ #include "internal.h" #ifdef CROSS # include #else # include #endif /* *---------------------------------------------------------------------- * * Tcl_ErrnoId -- * * Return a textual identifier for the current errno value. * * Results: * This procedure returns a machine-readable textual identifier * that corresponds to the current errno value (e.g. "EPERM"). * The identifier is the same as the #define name in errno.h. * * Side effects: * None. * *---------------------------------------------------------------------- */ unsigned char * Tcl_ErrnoId() { switch (errno) { #ifdef E2BIG case E2BIG: return "E2BIG"; #endif #ifdef EACCES case EACCES: return "EACCES"; #endif #ifdef EADDRINUSE case EADDRINUSE: return "EADDRINUSE"; #endif #ifdef EADDRNOTAVAIL case EADDRNOTAVAIL: return "EADDRNOTAVAIL"; #endif #ifdef EADV case EADV: return "EADV"; #endif #ifdef EAFNOSUPPORT case EAFNOSUPPORT: return "EAFNOSUPPORT"; #endif #ifdef EAGAIN case EAGAIN: return "EAGAIN"; #endif #ifdef EALIGN case EALIGN: return "EALIGN"; #endif #ifdef EALREADY case EALREADY: return "EALREADY"; #endif #ifdef EBADE case EBADE: return "EBADE"; #endif #ifdef EBADF case EBADF: return "EBADF"; #endif #ifdef EBADFD case EBADFD: return "EBADFD"; #endif #ifdef EBADMSG case EBADMSG: return "EBADMSG"; #endif #ifdef EBADR case EBADR: return "EBADR"; #endif #ifdef EBADRPC case EBADRPC: return "EBADRPC"; #endif #ifdef EBADRQC case EBADRQC: return "EBADRQC"; #endif #ifdef EBADSLT case EBADSLT: return "EBADSLT"; #endif #ifdef EBFONT case EBFONT: return "EBFONT"; #endif #ifdef EBUSY case EBUSY: return "EBUSY"; #endif #ifdef ECHILD case ECHILD: return "ECHILD"; #endif #ifdef ECHRNG case ECHRNG: return "ECHRNG"; #endif #ifdef ECOMM case ECOMM: return "ECOMM"; #endif #ifdef ECONNABORTED case ECONNABORTED: return "ECONNABORTED"; #endif #ifdef ECONNREFUSED case ECONNREFUSED: return "ECONNREFUSED"; #endif #ifdef ECONNRESET case ECONNRESET: return "ECONNRESET"; #endif #if defined(EDEADLK) && (!defined(EWOULDBLOCK) || (EDEADLK != EWOULDBLOCK)) case EDEADLK: return "EDEADLK"; #endif /* #ifdef EDEADLOCK case EDEADLOCK: return "EDEADLOCK"; #endif */ #ifdef EDESTADDRREQ case EDESTADDRREQ: return "EDESTADDRREQ"; #endif #ifdef EDIRTY case EDIRTY: return "EDIRTY"; #endif #ifdef EDOM case EDOM: return "EDOM"; #endif #ifdef EDOTDOT case EDOTDOT: return "EDOTDOT"; #endif #ifdef EDQUOT case EDQUOT: return "EDQUOT"; #endif #ifdef EDUPPKG case EDUPPKG: return "EDUPPKG"; #endif #ifdef EEXIST case EEXIST: return "EEXIST"; #endif #ifdef EFAULT case EFAULT: return "EFAULT"; #endif #ifdef EFBIG case EFBIG: return "EFBIG"; #endif #ifdef EHOSTDOWN case EHOSTDOWN: return "EHOSTDOWN"; #endif #ifdef EHOSTUNREACH case EHOSTUNREACH: return "EHOSTUNREACH"; #endif #ifdef EIDRM case EIDRM: return "EIDRM"; #endif #ifdef EINIT case EINIT: return "EINIT"; #endif #ifdef EINPROGRESS case EINPROGRESS: return "EINPROGRESS"; #endif #ifdef EINTR case EINTR: return "EINTR"; #endif #ifdef EINVAL case EINVAL: return "EINVAL"; #endif #ifdef EIO case EIO: return "EIO"; #endif #ifdef EISCONN case EISCONN: return "EISCONN"; #endif #ifdef EISDIR case EISDIR: return "EISDIR"; #endif #ifdef EISNAME case EISNAM: return "EISNAM"; #endif #ifdef ELBIN case ELBIN: return "ELBIN"; #endif #ifdef EL2HLT case EL2HLT: return "EL2HLT"; #endif #ifdef EL2NSYNC case EL2NSYNC: return "EL2NSYNC"; #endif #ifdef EL3HLT case EL3HLT: return "EL3HLT"; #endif #ifdef EL3RST case EL3RST: return "EL3RST"; #endif #ifdef ELIBACC case ELIBACC: return "ELIBACC"; #endif #ifdef ELIBBAD case ELIBBAD: return "ELIBBAD"; #endif #ifdef ELIBEXEC case ELIBEXEC: return "ELIBEXEC"; #endif #ifdef ELIBMAX case ELIBMAX: return "ELIBMAX"; #endif #ifdef ELIBSCN case ELIBSCN: return "ELIBSCN"; #endif #ifdef ELNRNG case ELNRNG: return "ELNRNG"; #endif #ifdef ELOOP case ELOOP: return "ELOOP"; #endif #ifdef EMFILE case EMFILE: return "EMFILE"; #endif #ifdef EMLINK case EMLINK: return "EMLINK"; #endif #ifdef EMSGSIZE case EMSGSIZE: return "EMSGSIZE"; #endif #ifdef EMULTIHOP case EMULTIHOP: return "EMULTIHOP"; #endif #ifdef ENAMETOOLONG case ENAMETOOLONG: return "ENAMETOOLONG"; #endif #ifdef ENAVAIL case ENAVAIL: return "ENAVAIL"; #endif #ifdef ENET case ENET: return "ENET"; #endif #ifdef ENETDOWN case ENETDOWN: return "ENETDOWN"; #endif #ifdef ENETRESET case ENETRESET: return "ENETRESET"; #endif #ifdef ENETUNREACH case ENETUNREACH: return "ENETUNREACH"; #endif #ifdef ENFILE case ENFILE: return "ENFILE"; #endif #ifdef ENOANO case ENOANO: return "ENOANO"; #endif #if defined(ENOBUFS) && (!defined(ENOSR) || (ENOBUFS != ENOSR)) case ENOBUFS: return "ENOBUFS"; #endif #ifdef ENOCSI case ENOCSI: return "ENOCSI"; #endif #ifdef ENODATA case ENODATA: return "ENODATA"; #endif #ifdef ENODEV case ENODEV: return "ENODEV"; #endif #ifdef ENOENT case ENOENT: return "ENOENT"; #endif #ifdef ENOEXEC case ENOEXEC: return "ENOEXEC"; #endif #ifdef ENOLCK case ENOLCK: return "ENOLCK"; #endif #ifdef ENOLINK case ENOLINK: return "ENOLINK"; #endif #ifdef ENOMEM case ENOMEM: return "ENOMEM"; #endif #ifdef ENOMSG case ENOMSG: return "ENOMSG"; #endif #ifdef ENONET case ENONET: return "ENONET"; #endif #ifdef ENOPKG case ENOPKG: return "ENOPKG"; #endif #ifdef ENOPROTOOPT case ENOPROTOOPT: return "ENOPROTOOPT"; #endif #ifdef ENOSPC case ENOSPC: return "ENOSPC"; #endif #ifdef ENOSR case ENOSR: return "ENOSR"; #endif #ifdef ENOSTR case ENOSTR: return "ENOSTR"; #endif #ifdef ENOSYM case ENOSYM: return "ENOSYM"; #endif #ifdef ENOSYS case ENOSYS: return "ENOSYS"; #endif #ifdef ENOTBLK case ENOTBLK: return "ENOTBLK"; #endif #ifdef ENOTCONN case ENOTCONN: return "ENOTCONN"; #endif #ifdef ENOTDIR case ENOTDIR: return "ENOTDIR"; #endif #if defined(ENOTEMPTY) && (!defined(EEXIST) || (ENOTEMPTY != EEXIST)) case ENOTEMPTY: return "ENOTEMPTY"; #endif #ifdef ENOTNAM case ENOTNAM: return "ENOTNAM"; #endif #ifdef ENOTSOCK case ENOTSOCK: return "ENOTSOCK"; #endif #ifdef ENOTTY case ENOTTY: return "ENOTTY"; #endif #ifdef ENOTUNIQ case ENOTUNIQ: return "ENOTUNIQ"; #endif #ifdef ENXIO case ENXIO: return "ENXIO"; #endif #ifdef EOPNOTSUPP case EOPNOTSUPP: return "EOPNOTSUPP"; #endif #ifdef EPERM case EPERM: return "EPERM"; #endif #ifdef EPFNOSUPPORT case EPFNOSUPPORT: return "EPFNOSUPPORT"; #endif #ifdef EPIPE case EPIPE: return "EPIPE"; #endif #ifdef EPROCLIM case EPROCLIM: return "EPROCLIM"; #endif #ifdef EPROCUNAVAIL case EPROCUNAVAIL: return "EPROCUNAVAIL"; #endif #ifdef EPROGMISMATCH case EPROGMISMATCH: return "EPROGMISMATCH"; #endif #ifdef EPROGUNAVAIL case EPROGUNAVAIL: return "EPROGUNAVAIL"; #endif #ifdef EPROTO case EPROTO: return "EPROTO"; #endif #ifdef EPROTONOSUPPORT case EPROTONOSUPPORT: return "EPROTONOSUPPORT"; #endif #ifdef EPROTOTYPE case EPROTOTYPE: return "EPROTOTYPE"; #endif #ifdef ERANGE case ERANGE: return "ERANGE"; #endif #if defined(EREFUSED) && (!defined(ECONNREFUSED) || (EREFUSED != ECONNREFUSED)) case EREFUSED: return "EREFUSED"; #endif #ifdef EREMCHG case EREMCHG: return "EREMCHG"; #endif #ifdef EREMDEV case EREMDEV: return "EREMDEV"; #endif #ifdef EREMOTE case EREMOTE: return "EREMOTE"; #endif #ifdef EREMOTEIO case EREMOTEIO: return "EREMOTEIO"; #endif #ifdef EREMOTERELEASE case EREMOTERELEASE: return "EREMOTERELEASE"; #endif #ifdef EROFS case EROFS: return "EROFS"; #endif #ifdef ERPCMISMATCH case ERPCMISMATCH: return "ERPCMISMATCH"; #endif #ifdef ERREMOTE case ERREMOTE: return "ERREMOTE"; #endif #ifdef ESHUTDOWN case ESHUTDOWN: return "ESHUTDOWN"; #endif #ifdef ESOCKTNOSUPPORT case ESOCKTNOSUPPORT: return "ESOCKTNOSUPPORT"; #endif #ifdef ESPIPE case ESPIPE: return "ESPIPE"; #endif #ifdef ESRCH case ESRCH: return "ESRCH"; #endif #ifdef ESRMNT case ESRMNT: return "ESRMNT"; #endif #ifdef ESTALE case ESTALE: return "ESTALE"; #endif #ifdef ESUCCESS case ESUCCESS: return "ESUCCESS"; #endif #ifdef ETIME case ETIME: return "ETIME"; #endif #ifdef ETIMEDOUT case ETIMEDOUT: return "ETIMEDOUT"; #endif #ifdef ETOOMANYREFS case ETOOMANYREFS: return "ETOOMANYREFS"; #endif #ifdef ETXTBSY case ETXTBSY: return "ETXTBSY"; #endif #ifdef EUCLEAN case EUCLEAN: return "EUCLEAN"; #endif #ifdef EUNATCH case EUNATCH: return "EUNATCH"; #endif #ifdef EUSERS case EUSERS: return "EUSERS"; #endif #ifdef EVERSION case EVERSION: return "EVERSION"; #endif #if defined(EWOULDBLOCK) && (!defined(EAGAIN) || (EWOULDBLOCK != EAGAIN)) case EWOULDBLOCK: return "EWOULDBLOCK"; #endif #ifdef EXDEV case EXDEV: return "EXDEV"; #endif #ifdef EXFULL case EXFULL: return "EXFULL"; #endif } return "unknown error"; } /* *---------------------------------------------------------------------- * * Tcl_SignalId -- * * Return a textual identifier for a signal number. * * Results: * This procedure returns a machine-readable textual identifier * that corresponds to sig. The identifier is the same as the * #define name in signal.h. * * Side effects: * None. * *---------------------------------------------------------------------- */ unsigned char * Tcl_SignalId(sig) int sig; /* Number of signal. */ { switch (sig) { #ifdef SIGABRT case SIGABRT: return "SIGABRT"; #endif #ifdef SIGALRM case SIGALRM: return "SIGALRM"; #endif #ifdef SIGBUS case SIGBUS: return "SIGBUS"; #endif #ifdef SIGCHLD case SIGCHLD: return "SIGCHLD"; #endif #if defined(SIGCLD) && (!defined(SIGCHLD) || (SIGCLD != SIGCHLD)) case SIGCLD: return "SIGCLD"; #endif #ifdef SIGCONT case SIGCONT: return "SIGCONT"; #endif #if defined(SIGEMT) && (!defined(SIGXCPU) || (SIGEMT != SIGXCPU)) case SIGEMT: return "SIGEMT"; #endif #ifdef SIGFPE case SIGFPE: return "SIGFPE"; #endif #ifdef SIGHUP case SIGHUP: return "SIGHUP"; #endif #ifdef SIGILL case SIGILL: return "SIGILL"; #endif #ifdef SIGINT case SIGINT: return "SIGINT"; #endif #ifdef SIGIO case SIGIO: return "SIGIO"; #endif #if defined(SIGIOT) && (!defined(SIGABRT) || (SIGIOT != SIGABRT)) case SIGIOT: return "SIGIOT"; #endif #ifdef SIGKILL case SIGKILL: return "SIGKILL"; #endif #if defined(SIGLOST) && (!defined(SIGIOT) || (SIGLOST != SIGIOT)) && (!defined(SIGURG) || (SIGLOST != SIGURG)) case SIGLOST: return "SIGLOST"; #endif #ifdef SIGPIPE case SIGPIPE: return "SIGPIPE"; #endif #if defined(SIGPOLL) && (!defined(SIGIO) || (SIGPOLL != SIGIO)) case SIGPOLL: return "SIGPOLL"; #endif #ifdef SIGPROF case SIGPROF: return "SIGPROF"; #endif #if defined(SIGPWR) && (!defined(SIGXFSZ) || (SIGPWR != SIGXFSZ)) case SIGPWR: return "SIGPWR"; #endif #ifdef SIGQUIT case SIGQUIT: return "SIGQUIT"; #endif #ifdef SIGSEGV case SIGSEGV: return "SIGSEGV"; #endif #ifdef SIGSTOP case SIGSTOP: return "SIGSTOP"; #endif #ifdef SIGSYS case SIGSYS: return "SIGSYS"; #endif #ifdef SIGTERM case SIGTERM: return "SIGTERM"; #endif #ifdef SIGTRAP case SIGTRAP: return "SIGTRAP"; #endif #ifdef SIGTSTP case SIGTSTP: return "SIGTSTP"; #endif #ifdef SIGTTIN case SIGTTIN: return "SIGTTIN"; #endif #ifdef SIGTTOU case SIGTTOU: return "SIGTTOU"; #endif #if defined(SIGURG) && (!defined(SIGIO) || (SIGURG != SIGIO)) case SIGURG: return "SIGURG"; #endif #ifdef SIGUSR1 case SIGUSR1: return "SIGUSR1"; #endif #ifdef SIGUSR2 case SIGUSR2: return "SIGUSR2"; #endif #ifdef SIGVTALRM case SIGVTALRM: return "SIGVTALRM"; #endif #ifdef SIGWINCH case SIGWINCH: return "SIGWINCH"; #endif #ifdef SIGXCPU case SIGXCPU: return "SIGXCPU"; #endif #ifdef SIGXFSZ case SIGXFSZ: return "SIGXFSZ"; #endif } return "unknown signal"; } /* *---------------------------------------------------------------------- * * Tcl_SignalMsg -- * * Return a human-readable message describing a signal. * * Results: * This procedure returns a string describing sig that should * make sense to a human. It may not be easy for a machine * to parse. * * Side effects: * None. * *---------------------------------------------------------------------- */ unsigned char * Tcl_SignalMsg(sig) int sig; /* Number of signal. */ { switch (sig) { #ifdef SIGABRT case SIGABRT: return "SIGABRT"; #endif #ifdef SIGALRM case SIGALRM: return "alarm clock"; #endif #ifdef SIGBUS case SIGBUS: return "bus error"; #endif #ifdef SIGCHLD case SIGCHLD: return "child status changed"; #endif #if defined(SIGCLD) && (!defined(SIGCHLD) || (SIGCLD != SIGCHLD)) case SIGCLD: return "child status changed"; #endif #ifdef SIGCONT case SIGCONT: return "continue after stop"; #endif #if defined(SIGEMT) && (!defined(SIGXCPU) || (SIGEMT != SIGXCPU)) case SIGEMT: return "EMT instruction"; #endif #ifdef SIGFPE case SIGFPE: return "floating-point exception"; #endif #ifdef SIGHUP case SIGHUP: return "hangup"; #endif #ifdef SIGILL case SIGILL: return "illegal instruction"; #endif #ifdef SIGINT case SIGINT: return "interrupt"; #endif #ifdef SIGIO case SIGIO: return "input/output possible on file"; #endif #if defined(SIGIOT) && (!defined(SIGABRT) || (SIGABRT != SIGIOT)) case SIGIOT: return "IOT instruction"; #endif #ifdef SIGKILL case SIGKILL: return "kill signal"; #endif #if defined(SIGLOST) && (!defined(SIGIOT) || (SIGLOST != SIGIOT)) && (!defined(SIGURG) || (SIGLOST != SIGURG)) case SIGLOST: return "resource lost"; #endif #ifdef SIGPIPE case SIGPIPE: return "write on pipe with no readers"; #endif #if defined(SIGPOLL) && (!defined(SIGIO) || (SIGPOLL != SIGIO)) case SIGPOLL: return "input/output possible on file"; #endif #ifdef SIGPROF case SIGPROF: return "profiling alarm"; #endif #if defined(SIGPWR) && (!defined(SIGXFSZ) || (SIGPWR != SIGXFSZ)) case SIGPWR: return "power-fail restart"; #endif #ifdef SIGQUIT case SIGQUIT: return "quit signal"; #endif #ifdef SIGSEGV case SIGSEGV: return "segmentation violation"; #endif #ifdef SIGSTOP case SIGSTOP: return "stop"; #endif #ifdef SIGSYS case SIGSYS: return "bad argument to system call"; #endif #ifdef SIGTERM case SIGTERM: return "software termination signal"; #endif #ifdef SIGTRAP case SIGTRAP: return "trace trap"; #endif #ifdef SIGTSTP case SIGTSTP: return "stop signal from tty"; #endif #ifdef SIGTTIN case SIGTTIN: return "background tty read"; #endif #ifdef SIGTTOU case SIGTTOU: return "background tty write"; #endif #if defined(SIGURG) && (!defined(SIGIO) || (SIGURG != SIGIO)) case SIGURG: return "urgent I/O condition"; #endif #ifdef SIGUSR1 case SIGUSR1: return "user-defined signal 1"; #endif #ifdef SIGUSR2 case SIGUSR2: return "user-defined signal 2"; #endif #ifdef SIGVTALRM case SIGVTALRM: return "virtual time alarm"; #endif #ifdef SIGWINCH case SIGWINCH: return "window changed"; #endif #ifdef SIGXCPU case SIGXCPU: return "exceeded CPU time limit"; #endif #ifdef SIGXFSZ case SIGXFSZ: return "exceeded file size limit"; #endif } return "unknown signal"; } ================================================ FILE: lib/libtcl/tcluxutl.c ================================================ /* * tclUnixUtil.c -- * * This file contains a collection of utility procedures that * are present in the Tcl's UNIX core but not in the generic * core. For example, they do file manipulation and process * manipulation. * * The Tcl_Fork and Tcl_WaitPids procedures are based on code * contributed by Karl Lehenbauer, Mark Diekhans and Peter * da Silva. * * Copyright 1991 Regents of the University of California * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without * fee is hereby granted, provided that this copyright * notice appears in all copies. The University of California * makes no representations about the suitability of this * software for any purpose. It is provided "as is" without * express or implied warranty. */ #include "internal.h" #include #include #include #include #include #ifdef CROSS # include #else # include #endif /* * Data structures of the following type are used by Tcl_Fork and * Tcl_WaitPids to keep track of child processes. */ #define WAIT_STATUS_TYPE int typedef struct { int pid; /* Process id of child. */ WAIT_STATUS_TYPE status; /* Status returned when child exited or * suspended. */ int flags; /* Various flag bits; see below for * definitions. */ } WaitInfo; /* * Flag bits in WaitInfo structures: * * WI_READY - Non-zero means process has exited or * suspended since it was forked or last * returned by Tcl_WaitPids. * WI_DETACHED - Non-zero means no-one cares about the * process anymore. Ignore it until it * exits, then forget about it. */ #define WI_READY 1 #define WI_DETACHED 2 static WaitInfo *waitTable = NULL; static int waitTableSize = 0; /* Total number of entries available in * waitTable. */ static int waitTableUsed = 0; /* Number of entries in waitTable that * are actually in use right now. Active * entries are always at the beginning * of the table. */ #define WAIT_TABLE_GROW_BY 4 /* *---------------------------------------------------------------------- * * Tcl_EvalFile -- * * Read in a file and process the entire file as one gigantic * Tcl command. * * Results: * A standard Tcl result, which is either the result of executing * the file or an error indicating why the file couldn't be read. * * Side effects: * Depends on the commands in the file. * *---------------------------------------------------------------------- */ int Tcl_EvalFile(interp, fileName) Tcl_Interp *interp; /* Interpreter in which to process file. */ unsigned char *fileName; /* Name of file to process. Tilde-substitution * will be performed on this name. */ { int fileId, result; struct stat statBuf; unsigned char *cmdBuffer, *end, *oldScriptFile; Interp *iPtr = (Interp *) interp; oldScriptFile = iPtr->scriptFile; iPtr->scriptFile = fileName; fileName = Tcl_TildeSubst(interp, fileName); if (fileName == NULL) { goto error; } fileId = open(fileName, O_RDONLY, 0); if (fileId < 0) { Tcl_AppendResult(interp, "couldn't read file \"", fileName, "\": ", Tcl_UnixError(interp), (char *) NULL); goto error; } if (fstat(fileId, &statBuf) == -1) { Tcl_AppendResult(interp, "couldn't stat file \"", fileName, "\": ", Tcl_UnixError(interp), (char *) NULL); close(fileId); goto error; } cmdBuffer = (unsigned char *) malloc((unsigned) statBuf.st_size+1); if (read(fileId, cmdBuffer, (int) statBuf.st_size) != statBuf.st_size) { Tcl_AppendResult(interp, "error in reading file \"", fileName, "\": ", Tcl_UnixError(interp), (char *) NULL); close(fileId); free(cmdBuffer); goto error; } if (close(fileId) != 0) { Tcl_AppendResult(interp, "error closing file \"", fileName, "\": ", Tcl_UnixError(interp), (char *) NULL); free(cmdBuffer); goto error; } cmdBuffer[statBuf.st_size] = 0; result = Tcl_Eval(interp, cmdBuffer, 0, &end); if (result == TCL_RETURN) { result = TCL_OK; } if (result == TCL_ERROR) { char msg[200]; /* * Record information telling where the error occurred. */ sprintf(msg, "\n (file \"%.150s\" line %d)", fileName, interp->errorLine); Tcl_AddErrorInfo(interp, msg); } free(cmdBuffer); iPtr->scriptFile = oldScriptFile; return result; error: iPtr->scriptFile = oldScriptFile; return TCL_ERROR; } /* *---------------------------------------------------------------------- * * Tcl_Fork -- * * Create a new process using the vfork system call, and keep * track of it for "safe" waiting with Tcl_WaitPids. * * Results: * The return value is the value returned by the vfork system * call (0 means child, > 0 means parent (value is child id), * < 0 means error). * * Side effects: * A new process is created, and an entry is added to an internal * table of child processes if the process is created successfully. * *---------------------------------------------------------------------- */ int Tcl_Fork() { WaitInfo *waitPtr; pid_t pid; /* * Disable SIGPIPE signals: if they were allowed, this process * might go away unexpectedly if children misbehave. This code * can potentially interfere with other application code that * expects to handle SIGPIPEs; what's really needed is an * arbiter for signals to allow them to be "shared". */ if (waitTable == NULL) { (void) signal(SIGPIPE, SIG_IGN); } /* * Enlarge the wait table if there isn't enough space for a new * entry. */ if (waitTableUsed == waitTableSize) { int newSize; WaitInfo *newWaitTable; newSize = waitTableSize + WAIT_TABLE_GROW_BY; newWaitTable = (WaitInfo *) malloc((unsigned) (newSize * sizeof(WaitInfo))); memcpy((void *) newWaitTable, (void *) waitTable, (waitTableSize * sizeof(WaitInfo))); if (waitTable != NULL) { free((char *) waitTable); } waitTable = newWaitTable; waitTableSize = newSize; } /* * Make a new process and enter it into the table if the fork * is successful. */ waitPtr = &waitTable[waitTableUsed]; pid = fork(); if (pid > 0) { waitPtr->pid = pid; waitPtr->flags = 0; waitTableUsed++; } return pid; } /* *---------------------------------------------------------------------- * * Tcl_WaitPids -- * * This procedure is used to wait for one or more processes created * by Tcl_Fork to exit or suspend. It records information about * all processes that exit or suspend, even those not waited for, * so that later waits for them will be able to get the status * information. * * Results: * -1 is returned if there is an error in the wait kernel call. * Otherwise the pid of an exited/suspended process from *pidPtr * is returned and *statusPtr is set to the status value returned * by the wait kernel call. * * Side effects: * Doesn't return until one of the pids at *pidPtr exits or suspends. * *---------------------------------------------------------------------- */ int Tcl_WaitPids(numPids, pidPtr, statusPtr) int numPids; /* Number of pids to wait on: gives size * of array pointed to by pidPtr. */ int *pidPtr; /* Pids to wait on: return when one of * these processes exits or suspends. */ int *statusPtr; /* Wait status is returned here. */ { int i, count, pid; register WaitInfo *waitPtr; int anyProcesses; WAIT_STATUS_TYPE status; while (1) { /* * Scan the table of child processes to see if one of the * specified children has already exited or suspended. If so, * remove it from the table and return its status. */ anyProcesses = 0; for (waitPtr = waitTable, count = waitTableUsed; count > 0; waitPtr++, count--) { for (i = 0; i < numPids; i++) { if (pidPtr[i] != waitPtr->pid) { continue; } anyProcesses = 1; if (waitPtr->flags & WI_READY) { *statusPtr = *((int *) &waitPtr->status); pid = waitPtr->pid; if (WIFEXITED(waitPtr->status) || WIFSIGNALED(waitPtr->status)) { *waitPtr = waitTable[waitTableUsed-1]; waitTableUsed--; } else { waitPtr->flags &= ~WI_READY; } return pid; } } } /* * Make sure that the caller at least specified one valid * process to wait for. */ if (!anyProcesses) { errno = ECHILD; return -1; } /* * Wait for a process to exit or suspend, then update its * entry in the table and go back to the beginning of the * loop to see if it's one of the desired processes. */ pid = wait(&status); if (pid < 0) { return pid; } for (waitPtr = waitTable, count = waitTableUsed; ; waitPtr++, count--) { if (count == 0) { break; /* Ignore unknown processes. */ } if (pid != waitPtr->pid) { continue; } /* * If the process has been detached, then ignore anything * other than an exit, and drop the entry on exit. */ if (waitPtr->flags & WI_DETACHED) { if (WIFEXITED(status) || WIFSIGNALED(status)) { *waitPtr = waitTable[waitTableUsed-1]; waitTableUsed--; } } else { waitPtr->status = status; waitPtr->flags |= WI_READY; } break; } } } /* *---------------------------------------------------------------------- * * Tcl_DetachPids -- * * This procedure is called to indicate that one or more child * processes have been placed in background and are no longer * cared about. They should be ignored in future calls to * Tcl_WaitPids. * * Results: * None. * * Side effects: * None. * *---------------------------------------------------------------------- */ void Tcl_DetachPids(numPids, pidPtr) int numPids; /* Number of pids to detach: gives size * of array pointed to by pidPtr. */ int *pidPtr; /* Array of pids to detach: must have * been created by Tcl_Fork. */ { register WaitInfo *waitPtr; int i, count, pid; for (i = 0; i < numPids; i++) { pid = pidPtr[i]; for (waitPtr = waitTable, count = waitTableUsed; count > 0; waitPtr++, count--) { if (pid != waitPtr->pid) { continue; } /* * If the process has already exited then destroy its * table entry now. */ if ((waitPtr->flags & WI_READY) && (WIFEXITED(waitPtr->status) || WIFSIGNALED(waitPtr->status))) { *waitPtr = waitTable[waitTableUsed-1]; waitTableUsed--; } else { waitPtr->flags |= WI_DETACHED; } goto nextPid; } fprintf (stderr, "Tcl_Detach couldn't find process\n"); abort(); nextPid: continue; } } /* *---------------------------------------------------------------------- * * Tcl_CreatePipeline -- * * Given an argc/argv array, instantiate a pipeline of processes * as described by the argv. * * Results: * The return value is a count of the number of new processes * created, or -1 if an error occurred while creating the pipeline. * *pidArrayPtr is filled in with the address of a dynamically * allocated array giving the ids of all of the processes. It * is up to the caller to free this array when it isn't needed * anymore. If inPipePtr is non-NULL, *inPipePtr is filled in * with the file id for the input pipe for the pipeline (if any): * the caller must eventually close this file. If outPipePtr * isn't NULL, then *outPipePtr is filled in with the file id * for the output pipe from the pipeline: the caller must close * this file. If errFilePtr isn't NULL, then *errFilePtr is filled * with a file id that may be used to read error output after the * pipeline completes. * * Side effects: * Processes and pipes are created. * *---------------------------------------------------------------------- */ int Tcl_CreatePipeline(interp, argc, argv, pidArrayPtr, inPipePtr, outPipePtr, errFilePtr) Tcl_Interp *interp; /* Interpreter to use for error reporting. */ int argc; /* Number of entries in argv. */ unsigned char **argv; /* Array of strings describing commands in * pipeline plus I/O redirection with <, * <<, and >. Argv[argc] must be NULL. */ int **pidArrayPtr; /* Word at *pidArrayPtr gets filled in with * address of array of pids for processes * in pipeline (first pid is first process * in pipeline). */ int *inPipePtr; /* If non-NULL, input to the pipeline comes * from a pipe (unless overridden by * redirection in the command). The file * id with which to write to this pipe is * stored at *inPipePtr. -1 means command * specified its own input source. */ int *outPipePtr; /* If non-NULL, output to the pipeline goes * to a pipe, unless overriden by redirection * in the command. The file id with which to * read frome this pipe is stored at * *outPipePtr. -1 means command specified * its own output sink. */ int *errFilePtr; /* If non-NULL, all stderr output from the * pipeline will go to a temporary file * created here, and a descriptor to read * the file will be left at *errFilePtr. * The file will be removed already, so * closing this descriptor will be the end * of the file. If this is NULL, then * all stderr output goes to our stderr. */ { int *pidPtr = NULL; /* Points to malloc-ed array holding all * the pids of child processes. */ int numPids = 0; /* Actual number of processes that exist * at *pidPtr right now. */ int cmdCount; /* Count of number of distinct commands * found in argc/argv. */ char *input = NULL; /* Describes input for pipeline, depending * on "inputFile". NULL means take input * from stdin/pipe. */ int inputFile = 0; /* Non-zero means input is name of input * file. Zero means input holds actual * text to be input to command. */ char *output = NULL; /* Holds name of output file to pipe to, * or NULL if output goes to stdout/pipe. */ int inputId = -1; /* Readable file id input to current command in * pipeline (could be file or pipe). -1 * means use stdin. */ int outputId = -1; /* Writable file id for output from current * command in pipeline (could be file or pipe). * -1 means use stdout. */ int errorId = -1; /* Writable file id for all standard error * output from all commands in pipeline. -1 * means use stderr. */ int lastOutputId = -1; /* Write file id for output from last command * in pipeline (could be file or pipe). * -1 means use stdout. */ int pipeIds[2]; /* File ids for pipe that's being created. */ int firstArg, lastArg; /* Indexes of first and last arguments in * current command. */ int lastBar; char *execName; int i, j, pid; if (inPipePtr != NULL) { *inPipePtr = -1; } if (outPipePtr != NULL) { *outPipePtr = -1; } if (errFilePtr != NULL) { *errFilePtr = -1; } pipeIds[0] = pipeIds[1] = -1; /* * First, scan through all the arguments to figure out the structure * of the pipeline. Count the number of distinct processes (it's the * number of "|" arguments). If there are "<", "<<", or ">" arguments * then make note of input and output redirection and remove these * arguments and the arguments that follow them. */ cmdCount = 1; lastBar = -1; for (i = 0; i < argc; i++) { if ((argv[i][0] == '|') && ((argv[i][1] == 0))) { if ((i == (lastBar+1)) || (i == (argc-1))) { interp->result = "illegal use of | in command"; return -1; } lastBar = i; cmdCount++; continue; } else if (argv[i][0] == '<') { if (argv[i][1] == 0) { input = argv[i+1]; inputFile = 1; } else if ((argv[i][1] == '<') && (argv[i][2] == 0)) { input = argv[i+1]; inputFile = 0; } else { continue; } } else if ((argv[i][0] == '>') && (argv[i][1] == 0)) { output = argv[i+1]; } else { continue; } if (i >= (argc-1)) { Tcl_AppendResult(interp, "can't specify \"", argv[i], "\" as last word in command", (char *) NULL); return -1; } for (j = i+2; j < argc; j++) { argv[j-2] = argv[j]; } argc -= 2; i--; /* Process new arg from same position. */ } if (argc == 0) { interp->result = "didn't specify command to execute"; return -1; } /* * Set up the redirected input source for the pipeline, if * so requested. */ if (input != NULL) { if (!inputFile) { /* * Immediate data in command. Create temporary file and * put data into file. */ # define TMP_STDIN_NAME "/tmp/tcl.in.XXXXXX" char inName[sizeof(TMP_STDIN_NAME) + 1]; int length; strcpy(inName, TMP_STDIN_NAME); mktemp(inName); inputId = open(inName, O_RDWR|O_CREAT|O_TRUNC, 0600); if (inputId < 0) { Tcl_AppendResult(interp, "couldn't create input file for command: ", Tcl_UnixError(interp), (char *) NULL); goto error; } length = strlen(input); if (write(inputId, input, length) != length) { Tcl_AppendResult(interp, "couldn't write file input for command: ", Tcl_UnixError(interp), (char *) NULL); goto error; } if ((lseek(inputId, 0L, 0) == -1) || (unlink(inName) == -1)) { Tcl_AppendResult(interp, "couldn't reset or remove input file for command: ", Tcl_UnixError(interp), (char *) NULL); goto error; } } else { /* * File redirection. Just open the file. */ inputId = open(input, O_RDONLY, 0); if (inputId < 0) { Tcl_AppendResult(interp, "couldn't read file \"", input, "\": ", Tcl_UnixError(interp), (char *) NULL); goto error; } } } else if (inPipePtr != NULL) { if (pipe(pipeIds) != 0) { Tcl_AppendResult(interp, "couldn't create input pipe for command: ", Tcl_UnixError(interp), (char *) NULL); goto error; } inputId = pipeIds[0]; *inPipePtr = pipeIds[1]; pipeIds[0] = pipeIds[1] = -1; } /* * Set up the redirected output sink for the pipeline from one * of two places, if requested. */ if (output != NULL) { /* * Output is to go to a file. */ lastOutputId = open(output, O_WRONLY|O_CREAT|O_TRUNC, 0666); if (lastOutputId < 0) { Tcl_AppendResult(interp, "couldn't write file \"", output, "\": ", Tcl_UnixError(interp), (char *) NULL); goto error; } } else if (outPipePtr != NULL) { /* * Output is to go to a pipe. */ if (pipe(pipeIds) != 0) { Tcl_AppendResult(interp, "couldn't create output pipe: ", Tcl_UnixError(interp), (char *) NULL); goto error; } lastOutputId = pipeIds[1]; *outPipePtr = pipeIds[0]; pipeIds[0] = pipeIds[1] = -1; } /* * Set up the standard error output sink for the pipeline, if * requested. Use a temporary file which is opened, then deleted. * Could potentially just use pipe, but if it filled up it could * cause the pipeline to deadlock: we'd be waiting for processes * to complete before reading stderr, and processes couldn't complete * because stderr was backed up. */ if (errFilePtr != NULL) { # define TMP_STDERR_NAME "/tmp/tcl.err.XXXXXX" char errName[sizeof(TMP_STDERR_NAME) + 1]; strcpy(errName, TMP_STDERR_NAME); mktemp(errName); errorId = open(errName, O_WRONLY|O_CREAT|O_TRUNC, 0600); if (errorId < 0) { errFileError: Tcl_AppendResult(interp, "couldn't create error file for command: ", Tcl_UnixError(interp), (char *) NULL); goto error; } *errFilePtr = open(errName, O_RDONLY, 0); if (*errFilePtr < 0) { goto errFileError; } if (unlink(errName) == -1) { Tcl_AppendResult(interp, "couldn't remove error file for command: ", Tcl_UnixError(interp), (char *) NULL); goto error; } } /* * Scan through the argc array, forking off a process for each * group of arguments between "|" arguments. */ pidPtr = (int *) malloc((unsigned) (cmdCount * sizeof(int))); for (i = 0; i < numPids; i++) { pidPtr[i] = -1; } for (firstArg = 0; firstArg < argc; numPids++, firstArg = lastArg+1) { for (lastArg = firstArg; lastArg < argc; lastArg++) { if ((argv[lastArg][0] == '|') && (argv[lastArg][1] == 0)) { break; } } argv[lastArg] = NULL; if (lastArg == argc) { outputId = lastOutputId; } else { if (pipe(pipeIds) != 0) { Tcl_AppendResult(interp, "couldn't create pipe: ", Tcl_UnixError(interp), (char *) NULL); goto error; } outputId = pipeIds[1]; } execName = Tcl_TildeSubst(interp, argv[firstArg]); pid = Tcl_Fork(); if (pid == -1) { Tcl_AppendResult(interp, "couldn't fork child process: ", Tcl_UnixError(interp), (char *) NULL); goto error; } if (pid == 0) { char errSpace[200]; if (((inputId != -1) && (dup2(inputId, 0) == -1)) || ((outputId != -1) && (dup2(outputId, 1) == -1)) || ((errorId != -1) && (dup2(errorId, 2) == -1))) { char *err; err = "forked process couldn't set up input/output\n"; write(errorId < 0 ? 2 : errorId, err, strlen(err)); _exit(1); } for (i = 3; (i <= outputId) || (i <= inputId) || (i <= errorId); i++) { close(i); } execvp(execName, (char**) &argv[firstArg]); sprintf(errSpace, "couldn't find \"%.150s\" to execute\n", argv[firstArg]); write(2, errSpace, strlen(errSpace)); _exit(1); } else { pidPtr[numPids] = pid; } /* * Close off our copies of file descriptors that were set up for * this child, then set up the input for the next child. */ if (inputId != -1) { close(inputId); } if (outputId != -1) { close(outputId); } inputId = pipeIds[0]; pipeIds[0] = pipeIds[1] = -1; } *pidArrayPtr = pidPtr; /* * All done. Cleanup open files lying around and then return. */ cleanup: if (inputId != -1) { close(inputId); } if (lastOutputId != -1) { close(lastOutputId); } if (errorId != -1) { close(errorId); } return numPids; /* * An error occurred. There could have been extra files open, such * as pipes between children. Clean them all up. Detach any child * processes that have been created. */ error: if ((inPipePtr != NULL) && (*inPipePtr != -1)) { close(*inPipePtr); *inPipePtr = -1; } if ((outPipePtr != NULL) && (*outPipePtr != -1)) { close(*outPipePtr); *outPipePtr = -1; } if ((errFilePtr != NULL) && (*errFilePtr != -1)) { close(*errFilePtr); *errFilePtr = -1; } if (pipeIds[0] != -1) { close(pipeIds[0]); } if (pipeIds[1] != -1) { close(pipeIds[1]); } if (pidPtr != NULL) { for (i = 0; i < numPids; i++) { if (pidPtr[i] != -1) { Tcl_DetachPids(1, &pidPtr[i]); } } free((char *) pidPtr); } numPids = -1; goto cleanup; } /* *---------------------------------------------------------------------- * * Tcl_UnixError -- * * This procedure is typically called after UNIX kernel calls * return errors. It stores machine-readable information about * the error in $errorCode returns an information string for * the caller's use. * * Results: * The return value is a human-readable string describing the * error, as returned by strerror. * * Side effects: * The global variable $errorCode is reset. * *---------------------------------------------------------------------- */ unsigned char * Tcl_UnixError(interp) Tcl_Interp *interp; /* Interpreter whose $errorCode variable * is to be changed. */ { char *id; const char *msg; id = Tcl_ErrnoId(); msg = strerror(errno); Tcl_SetErrorCode(interp, "UNIX", id, msg, (char *) NULL); return (unsigned char *) msg; } /* *---------------------------------------------------------------------- * * TclMakeFileTable -- * * Create or enlarge the file table for the interpreter, so that * there is room for a given index. * * Results: * None. * * Side effects: * The file table for iPtr will be created if it doesn't exist * (and entries will be added for stdin, stdout, and stderr). * If it already exists, then it will be grown if necessary. * *---------------------------------------------------------------------- */ void TclMakeFileTable(iPtr, index) Interp *iPtr; /* Interpreter whose table of files is * to be manipulated. */ int index; /* Make sure table is large enough to * hold at least this index. */ { /* * If the table doesn't even exist, then create it and initialize * entries for standard files. */ if (iPtr->numFiles == 0) { OpenFile *filePtr; int i; if (index < 2) { iPtr->numFiles = 3; } else { iPtr->numFiles = index+1; } iPtr->filePtrArray = (OpenFile **) malloc((unsigned) ((iPtr->numFiles)*sizeof(OpenFile *))); for (i = iPtr->numFiles-1; i >= 0; i--) { iPtr->filePtrArray[i] = NULL; } filePtr = (OpenFile *) malloc(sizeof(OpenFile)); filePtr->f = stdin; filePtr->f2 = NULL; filePtr->readable = 1; filePtr->writable = 0; filePtr->numPids = 0; filePtr->pidPtr = NULL; filePtr->errorId = -1; iPtr->filePtrArray[0] = filePtr; filePtr = (OpenFile *) malloc(sizeof(OpenFile)); filePtr->f = stdout; filePtr->f2 = NULL; filePtr->readable = 0; filePtr->writable = 1; filePtr->numPids = 0; filePtr->pidPtr = NULL; filePtr->errorId = -1; iPtr->filePtrArray[1] = filePtr; filePtr = (OpenFile *) malloc(sizeof(OpenFile)); filePtr->f = stderr; filePtr->f2 = NULL; filePtr->readable = 0; filePtr->writable = 1; filePtr->numPids = 0; filePtr->pidPtr = NULL; filePtr->errorId = -1; iPtr->filePtrArray[2] = filePtr; } else if (index >= iPtr->numFiles) { int newSize; OpenFile **newPtrArray; int i; newSize = index+1; newPtrArray = (OpenFile **) malloc((unsigned) ((newSize)*sizeof(OpenFile *))); memcpy((void *) newPtrArray, (void *) iPtr->filePtrArray, iPtr->numFiles*sizeof(OpenFile *)); for (i = iPtr->numFiles; i < newSize; i++) { newPtrArray[i] = NULL; } free((char *) iPtr->filePtrArray); iPtr->numFiles = newSize; iPtr->filePtrArray = newPtrArray; } } /* *---------------------------------------------------------------------- * * TclGetOpenFile -- * * Given a string identifier for an open file, find the corresponding * open file structure, if there is one. * * Results: * A standard Tcl return value. If the open file is successfully * located, *filePtrPtr is modified to point to its structure. * If TCL_ERROR is returned then interp->result contains an error * message. * * Side effects: * None. * *---------------------------------------------------------------------- */ int TclGetOpenFile(interp, string, filePtrPtr) Tcl_Interp *interp; /* Interpreter in which to find file. */ char *string; /* String that identifies file. */ OpenFile **filePtrPtr; /* Address of word in which to store pointer * to structure about open file. */ { int fd = 0; /* Initial value needed only to stop compiler * warnings. */ Interp *iPtr = (Interp *) interp; if ((string[0] == 'f') && (string[1] == 'i') && (string[2] == 'l') & (string[3] == 'e')) { char *end; fd = strtoul(string+4, &end, 10); if ((end == string+4) || (*end != 0)) { goto badId; } } else if ((string[0] == 's') && (string[1] == 't') && (string[2] == 'd')) { if (strcmp(string+3, "in") == 0) { fd = 0; } else if (strcmp(string+3, "out") == 0) { fd = 1; } else if (strcmp(string+3, "err") == 0) { fd = 2; } else { goto badId; } } else { badId: Tcl_AppendResult(interp, "bad file identifier \"", string, "\"", (char *) NULL); return TCL_ERROR; } if (fd >= iPtr->numFiles) { if ((iPtr->numFiles == 0) && (fd <= 2)) { TclMakeFileTable(iPtr, fd); } else { notOpen: Tcl_AppendResult(interp, "file \"", string, "\" isn't open", (char *) NULL); return TCL_ERROR; } } if (iPtr->filePtrArray[fd] == NULL) { goto notOpen; } *filePtrPtr = iPtr->filePtrArray[fd]; return TCL_OK; } ================================================ FILE: lib/libtcl/tclvar.c ================================================ /* * tclVar.c -- * * This file contains routines that implement Tcl variables * (both scalars and arrays). * * The implementation of arrays is modelled after an initial * implementation by Karl Lehenbauer, Mark Diekhans and * Peter da Silva. * * Copyright 1987-1991 Regents of the University of California * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without * fee is hereby granted, provided that the above copyright * notice appear in all copies. The University of California * makes no representations about the suitability of this * software for any purpose. It is provided "as is" without * express or implied warranty. */ #include "internal.h" #include /* * The strings below are used to indicate what went wrong when a * variable access is denied. */ static unsigned char *noSuchVar = (unsigned char*) "no such variable"; static unsigned char *isArray = (unsigned char*) "variable is array"; static unsigned char *needArray = (unsigned char*) "variable isn't array"; static unsigned char *noSuchElement = (unsigned char*) "no such element in array"; static unsigned char *traceActive = (unsigned char*) "trace is active on variable"; /* * Forward references to procedures defined later in this file: */ static unsigned char * CallTraces (Interp *iPtr, Var *arrayPtr, Tcl_HashEntry *hPtr, unsigned char *part1, unsigned char *part2, int flags); static void DeleteSearches (Var *arrayVarPtr); static void DeleteArray (Interp *iPtr, unsigned char *arrayName, Var *varPtr, int flags); static Var * NewVar (int space); static ArraySearch * ParseSearchId (Tcl_Interp *interp, Var *varPtr, unsigned char *varName, char *string); static void VarErrMsg (Tcl_Interp *interp, unsigned char *part1, unsigned char *part2, unsigned char *operation, unsigned char *reason); /* *---------------------------------------------------------------------- * * Tcl_GetVar -- * * Return the value of a Tcl variable. * * Results: * The return value points to the current value of varName. If * the variable is not defined or can't be read because of a clash * in array usage then a NULL pointer is returned and an error * message is left in interp->result if the TCL_LEAVE_ERR_MSG * flag is set. Note: the return value is only valid up until * the next call to Tcl_SetVar or Tcl_SetVar2; if you depend on * the value lasting longer than that, then make yourself a private * copy. * * Side effects: * None. * *---------------------------------------------------------------------- */ unsigned char * Tcl_GetVar(interp, varName, flags) Tcl_Interp *interp; /* Command interpreter in which varName is * to be looked up. */ unsigned char *varName; /* Name of a variable in interp. */ int flags; /* OR-ed combination of TCL_GLOBAL_ONLY * or TCL_LEAVE_ERR_MSG bits. */ { register unsigned char *p; /* * If varName refers to an array (it ends with a parenthesized * element name), then handle it specially. */ for (p = varName; *p != '\0'; p++) { if (*p == '(') { unsigned char *result; unsigned char *open = p; do { p++; } while (*p != '\0'); p--; if (*p != ')') { goto scalar; } *open = '\0'; *p = '\0'; result = Tcl_GetVar2(interp, varName, open+1, flags); *open = '('; *p = ')'; return result; } } scalar: return Tcl_GetVar2(interp, varName, 0, flags); } /* *---------------------------------------------------------------------- * * Tcl_GetVar2 -- * * Return the value of a Tcl variable, given a two-part name * consisting of array name and element within array. * * Results: * The return value points to the current value of the variable * given by part1 and part2. If the specified variable doesn't * exist, or if there is a clash in array usage, then NULL is * returned and a message will be left in interp->result if the * TCL_LEAVE_ERR_MSG flag is set. Note: the return value is * only valid up until the next call to Tcl_SetVar or Tcl_SetVar2; * if you depend on the value lasting longer than that, then make * yourself a private copy. * * Side effects: * None. * *---------------------------------------------------------------------- */ unsigned char * Tcl_GetVar2(interp, part1, part2, flags) Tcl_Interp *interp; /* Command interpreter in which variable is * to be looked up. */ unsigned char *part1; /* Name of array (if part2 is NULL) or * name of variable. */ unsigned char *part2; /* If non-null, gives name of element in * array. */ int flags; /* OR-ed combination of TCL_GLOBAL_ONLY * or TCL_LEAVE_ERR_MSG bits. */ { Tcl_HashEntry *hPtr; Var *varPtr; Interp *iPtr = (Interp *) interp; Var *arrayPtr = 0; /* * Lookup the first name. */ if ((flags & TCL_GLOBAL_ONLY) || (iPtr->varFramePtr == 0)) { hPtr = Tcl_FindHashEntry(&iPtr->globalTable, part1); } else { hPtr = Tcl_FindHashEntry(&iPtr->varFramePtr->varTable, part1); } if (hPtr == 0) { if (flags & TCL_LEAVE_ERR_MSG) { VarErrMsg(interp, part1, part2, (unsigned char*) "read", noSuchVar); } return 0; } varPtr = (Var *) Tcl_GetHashValue(hPtr); if (varPtr->flags & VAR_UPVAR) { hPtr = varPtr->value.upvarPtr; varPtr = (Var *) Tcl_GetHashValue(hPtr); } /* * If this is an array reference, then remember the traces on the array * and lookup the element within the array. */ if (part2 != 0) { if (varPtr->flags & VAR_UNDEFINED) { if (flags & TCL_LEAVE_ERR_MSG) { VarErrMsg(interp, part1, part2, (unsigned char*) "read", noSuchVar); } return 0; } else if (!(varPtr->flags & VAR_ARRAY)) { if (flags & TCL_LEAVE_ERR_MSG) { VarErrMsg(interp, part1, part2, (unsigned char*) "read", needArray); } return 0; } arrayPtr = varPtr; hPtr = Tcl_FindHashEntry(varPtr->value.tablePtr, part2); if (hPtr == 0) { if (flags & TCL_LEAVE_ERR_MSG) { VarErrMsg(interp, part1, part2, (unsigned char*) "read", noSuchElement); } return 0; } varPtr = (Var *) Tcl_GetHashValue(hPtr); } /* * Invoke any traces that have been set for the variable. */ if ((varPtr->tracePtr != 0) || ((arrayPtr != 0) && (arrayPtr->tracePtr != 0))) { unsigned char *msg; msg = CallTraces(iPtr, arrayPtr, hPtr, part1, part2, (flags & TCL_GLOBAL_ONLY) | TCL_TRACE_READS); if (msg != 0) { VarErrMsg(interp, part1, part2, (unsigned char*) "read", msg); return 0; } /* * Watch out! The variable could have gotten re-allocated to * a larger size. Fortunately the hash table entry will still * be around. */ varPtr = (Var *) Tcl_GetHashValue(hPtr); } if (varPtr->flags & (VAR_UNDEFINED|VAR_UPVAR|VAR_ARRAY)) { if (flags & TCL_LEAVE_ERR_MSG) { VarErrMsg(interp, part1, part2, (unsigned char*) "read", noSuchVar); } return 0; } return varPtr->value.string; } /* *---------------------------------------------------------------------- * * Tcl_SetVar -- * * Change the value of a variable. * * Results: * Returns a pointer to the malloc'ed string holding the new * value of the variable. The caller should not modify this * string. If the write operation was disallowed then NULL * is returned; if the TCL_LEAVE_ERR_MSG flag is set, then * an explanatory message will be left in interp->result. * * Side effects: * If varName is defined as a local or global variable in interp, * its value is changed to newValue. If varName isn't currently * defined, then a new global variable by that name is created. * *---------------------------------------------------------------------- */ unsigned char * Tcl_SetVar(interp, varName, newValue, flags) Tcl_Interp *interp; /* Command interpreter in which varName is * to be looked up. */ unsigned char *varName; /* Name of a variable in interp. */ unsigned char *newValue; /* New value for varName. */ int flags; /* Various flags that tell how to set value: * any of TCL_GLOBAL_ONLY, TCL_APPEND_VALUE, * TCL_LIST_ELEMENT, TCL_NO_SPACE, or * TCL_LEAVE_ERR_MSG. */ { register unsigned char *p; /* * If varName refers to an array (it ends with a parenthesized * element name), then handle it specially. */ for (p = varName; *p != '\0'; p++) { if (*p == '(') { unsigned char *result; unsigned char *open = p; do { p++; } while (*p != '\0'); p--; if (*p != ')') { goto scalar; } *open = '\0'; *p = '\0'; result = Tcl_SetVar2(interp, varName, open+1, newValue, flags); *open = '('; *p = ')'; return result; } } scalar: return Tcl_SetVar2(interp, varName, 0, newValue, flags); } /* *---------------------------------------------------------------------- * * Tcl_SetVar2 -- * * Given a two-part variable name, which may refer either to a * scalar variable or an element of an array, change the value * of the variable. If the named scalar or array or element * doesn't exist then create one. * * Results: * Returns a pointer to the malloc'ed string holding the new * value of the variable. The caller should not modify this * string. If the write operation was disallowed because an * array was expected but not found (or vice versa), then NULL * is returned; if the TCL_LEAVE_ERR_MSG flag is set, then * an explanatory message will be left in interp->result. * * Side effects: * The value of the given variable is set. If either the array * or the entry didn't exist then a new one is created. * *---------------------------------------------------------------------- */ unsigned char * Tcl_SetVar2(interp, part1, part2, newValue, flags) Tcl_Interp *interp; /* Command interpreter in which variable is * to be looked up. */ unsigned char *part1; /* If part2 is NULL, this is name of scalar * variable. Otherwise it is name of array. */ unsigned char *part2; /* Name of an element within array, or NULL. */ unsigned char *newValue; /* New value for variable. */ int flags; /* Various flags that tell how to set value: * any of TCL_GLOBAL_ONLY, TCL_APPEND_VALUE, * TCL_LIST_ELEMENT, and TCL_NO_SPACE, or * TCL_LEAVE_ERR_MSG . */ { Tcl_HashEntry *hPtr; register Var *varPtr = 0; /* Initial value only used to stop compiler * from complaining; not really needed. */ register Interp *iPtr = (Interp *) interp; int length, new, listFlags; Var *arrayPtr = 0; /* * Lookup the first name. */ if ((flags & TCL_GLOBAL_ONLY) || (iPtr->varFramePtr == 0)) { hPtr = Tcl_CreateHashEntry(&iPtr->globalTable, part1, &new); } else { hPtr = Tcl_CreateHashEntry(&iPtr->varFramePtr->varTable, part1, &new); } if (!new) { varPtr = (Var *) Tcl_GetHashValue(hPtr); if (varPtr->flags & VAR_UPVAR) { hPtr = varPtr->value.upvarPtr; varPtr = (Var *) Tcl_GetHashValue(hPtr); } } /* * If this is an array reference, then create a new array (if * needed), remember any traces on the array, and lookup the * element within the array. */ if (part2 != 0) { if (new) { varPtr = NewVar (0); Tcl_SetHashValue(hPtr, varPtr); varPtr->flags = VAR_ARRAY; varPtr->value.tablePtr = (Tcl_HashTable*) malloc (sizeof(Tcl_HashTable)); Tcl_InitHashTable (varPtr->value.tablePtr, TCL_STRING_KEYS); } else { if (varPtr->flags & VAR_UNDEFINED) { varPtr->flags = VAR_ARRAY; varPtr->value.tablePtr = (Tcl_HashTable*) malloc (sizeof(Tcl_HashTable)); Tcl_InitHashTable (varPtr->value.tablePtr, TCL_STRING_KEYS); } else if (!(varPtr->flags & VAR_ARRAY)) { if (flags & TCL_LEAVE_ERR_MSG) { VarErrMsg(interp, part1, part2, (unsigned char*) "set", needArray); } return 0; } arrayPtr = varPtr; } hPtr = Tcl_CreateHashEntry(varPtr->value.tablePtr, part2, &new); } /* * Compute how many bytes will be needed for newValue (leave space * for a separating space between list elements). */ if (flags & TCL_LIST_ELEMENT) { length = Tcl_ScanElement(newValue, &listFlags) + 1; } else { length = strlen(newValue); } /* * If the variable doesn't exist then create a new one. If it * does exist then clear its current value unless this is an * append operation. */ if (new) { varPtr = NewVar (length); Tcl_SetHashValue(hPtr, varPtr); if ((arrayPtr != 0) && (arrayPtr->searchPtr != 0)) { DeleteSearches(arrayPtr); } } else { varPtr = (Var *) Tcl_GetHashValue(hPtr); if (varPtr->flags & VAR_ARRAY) { if (flags & TCL_LEAVE_ERR_MSG) { VarErrMsg(interp, part1, part2, (unsigned char*) "set", isArray); } return 0; } if (!(flags & TCL_APPEND_VALUE) || (varPtr->flags & VAR_UNDEFINED)) { varPtr->valueLength = 0; } } /* * Make sure there's enough space to hold the variable's * new value. If not, enlarge the variable's space. */ if ((length + varPtr->valueLength) >= varPtr->valueSpace) { Var *newVarPtr; int newSize; newSize = 2*varPtr->valueSpace; if (newSize <= (length + varPtr->valueLength)) { newSize += length; } newVarPtr = NewVar (newSize); newVarPtr->valueLength = varPtr->valueLength; newVarPtr->upvarUses = varPtr->upvarUses; newVarPtr->tracePtr = varPtr->tracePtr; newVarPtr->searchPtr = varPtr->searchPtr; newVarPtr->flags = varPtr->flags; strcpy(newVarPtr->value.string, varPtr->value.string); Tcl_SetHashValue(hPtr, newVarPtr); free (varPtr); varPtr = newVarPtr; } /* * Append the new value to the variable, either as a list * element or as a string. */ if (flags & TCL_LIST_ELEMENT) { if ((varPtr->valueLength > 0) && !(flags & TCL_NO_SPACE)) { varPtr->value.string[varPtr->valueLength] = ' '; varPtr->valueLength++; } varPtr->valueLength += Tcl_ConvertElement(newValue, varPtr->value.string + varPtr->valueLength, listFlags); varPtr->value.string[varPtr->valueLength] = 0; } else { strcpy(varPtr->value.string + varPtr->valueLength, newValue); varPtr->valueLength += length; } varPtr->flags &= ~VAR_UNDEFINED; /* * Invoke any write traces for the variable. */ if ((varPtr->tracePtr != 0) || ((arrayPtr != 0) && (arrayPtr->tracePtr != 0))) { unsigned char *msg; msg = CallTraces(iPtr, arrayPtr, hPtr, part1, part2, (flags & TCL_GLOBAL_ONLY) | TCL_TRACE_WRITES); if (msg != 0) { VarErrMsg(interp, part1, part2, (unsigned char*) "set", msg); return 0; } /* * Watch out! The variable could have gotten re-allocated to * a larger size. Fortunately the hash table entry will still * be around. */ varPtr = (Var *) Tcl_GetHashValue(hPtr); } return varPtr->value.string; } /* *---------------------------------------------------------------------- * * Tcl_UnsetVar -- * * Delete a variable, so that it may not be accessed anymore. * * Results: * Returns 0 if the variable was successfully deleted, -1 * if the variable can't be unset. In the event of an error, * if the TCL_LEAVE_ERR_MSG flag is set then an error message * is left in interp->result. * * Side effects: * If varName is defined as a local or global variable in interp, * it is deleted. * *---------------------------------------------------------------------- */ int Tcl_UnsetVar(interp, varName, flags) Tcl_Interp *interp; /* Command interpreter in which varName is * to be looked up. */ unsigned char *varName; /* Name of a variable in interp. May be * either a scalar name or an array name * or an element in an array. */ int flags; /* OR-ed combination of any of * TCL_GLOBAL_ONLY or TCL_LEAVE_ERR_MSG. */ { register unsigned char *p; int result; /* * Figure out whether this is an array reference, then call * Tcl_UnsetVar2 to do all the real work. */ for (p = varName; *p != '\0'; p++) { if (*p == '(') { unsigned char *open = p; do { p++; } while (*p != '\0'); p--; if (*p != ')') { goto scalar; } *open = '\0'; *p = '\0'; result = Tcl_UnsetVar2(interp, varName, open+1, flags); *open = '('; *p = ')'; return result; } } scalar: return Tcl_UnsetVar2(interp, varName, 0, flags); } /* *---------------------------------------------------------------------- * * Tcl_UnsetVar2 -- * * Delete a variable, given a 2-part name. * * Results: * Returns 0 if the variable was successfully deleted, -1 * if the variable can't be unset. In the event of an error, * if the TCL_LEAVE_ERR_MSG flag is set then an error message * is left in interp->result. * * Side effects: * If part1 and part2 indicate a local or global variable in interp, * it is deleted. If part1 is an array name and part2 is NULL, then * the whole array is deleted. * *---------------------------------------------------------------------- */ int Tcl_UnsetVar2(interp, part1, part2, flags) Tcl_Interp *interp; /* Command interpreter in which varName is * to be looked up. */ unsigned char *part1; /* Name of variable or array. */ unsigned char *part2; /* Name of element within array or NULL. */ int flags; /* OR-ed combination of any of * TCL_GLOBAL_ONLY or TCL_LEAVE_ERR_MSG. */ { Tcl_HashEntry *hPtr, dummyEntry; Var *varPtr, dummyVar; Interp *iPtr = (Interp *) interp; Var *arrayPtr = 0; if ((flags & TCL_GLOBAL_ONLY) || (iPtr->varFramePtr == 0)) { hPtr = Tcl_FindHashEntry(&iPtr->globalTable, part1); } else { hPtr = Tcl_FindHashEntry(&iPtr->varFramePtr->varTable, part1); } if (hPtr == 0) { if (flags & TCL_LEAVE_ERR_MSG) { VarErrMsg(interp, part1, part2, (unsigned char*) "unset", noSuchVar); } return -1; } varPtr = (Var *) Tcl_GetHashValue(hPtr); /* * For global variables referenced in procedures, leave the procedure's * reference variable in place, but unset the global variable. Can't * decrement the actual variable's use count, since we didn't delete * the reference variable. */ if (varPtr->flags & VAR_UPVAR) { hPtr = varPtr->value.upvarPtr; varPtr = (Var *) Tcl_GetHashValue(hPtr); } /* * If the variable being deleted is an element of an array, then * remember trace procedures on the overall array and find the * element to delete. */ if (part2 != 0) { if (!(varPtr->flags & VAR_ARRAY)) { if (flags & TCL_LEAVE_ERR_MSG) { VarErrMsg(interp, part1, part2, (unsigned char*) "unset", needArray); } return -1; } if (varPtr->searchPtr != 0) { DeleteSearches(varPtr); } arrayPtr = varPtr; hPtr = Tcl_FindHashEntry(varPtr->value.tablePtr, part2); if (hPtr == 0) { if (flags & TCL_LEAVE_ERR_MSG) { VarErrMsg(interp, part1, part2, (unsigned char*) "unset", noSuchElement); } return -1; } varPtr = (Var *) Tcl_GetHashValue(hPtr); } /* * If there is a trace active on this variable or if the variable * is already being deleted then don't delete the variable: it * isn't safe, since there are procedures higher up on the stack * that will use pointers to the variable. Also don't delete an * array if there are traces active on any of its elements. */ if (varPtr->flags & (VAR_TRACE_ACTIVE|VAR_ELEMENT_ACTIVE)) { if (flags & TCL_LEAVE_ERR_MSG) { VarErrMsg(interp, part1, part2, (unsigned char*) "unset", traceActive); } return -1; } /* * The code below is tricky, because of the possibility that * a trace procedure might try to access a variable being * deleted. To handle this situation gracefully, copy the * contents of the variable and its hash table entry to * dummy variables, then clean up the actual variable so that * it's been completely deleted before the traces are called. * Then call the traces, and finally clean up the variable's * storage using the dummy copies. */ dummyVar = *varPtr; Tcl_SetHashValue(&dummyEntry, &dummyVar); if (varPtr->upvarUses == 0) { Tcl_DeleteHashEntry(hPtr); free (varPtr); } else { varPtr->flags = VAR_UNDEFINED; varPtr->tracePtr = 0; } /* * Call trace procedures for the variable being deleted and delete * its traces. */ if ((dummyVar.tracePtr != 0) || ((arrayPtr != 0) && (arrayPtr->tracePtr != 0))) { (void) CallTraces(iPtr, arrayPtr, &dummyEntry, part1, part2, (flags & TCL_GLOBAL_ONLY) | TCL_TRACE_UNSETS); while (dummyVar.tracePtr != 0) { VarTrace *tracePtr = dummyVar.tracePtr; dummyVar.tracePtr = tracePtr->nextPtr; free (tracePtr); } } /* * If the variable is an array, delete all of its elements. This * must be done after calling the traces on the array, above (that's * the way traces are defined). */ if (dummyVar.flags & VAR_ARRAY) { DeleteArray(iPtr, part1, &dummyVar, (flags & TCL_GLOBAL_ONLY) | TCL_TRACE_UNSETS); } if (dummyVar.flags & VAR_UNDEFINED) { if (flags & TCL_LEAVE_ERR_MSG) { VarErrMsg(interp, part1, part2, (unsigned char*) "unset", (part2 == 0) ? noSuchVar : noSuchElement); } return -1; } return 0; } /* *---------------------------------------------------------------------- * * Tcl_TraceVar -- * * Arrange for reads and/or writes to a variable to cause a * procedure to be invoked, which can monitor the operations * and/or change their actions. * * Results: * A standard Tcl return value. * * Side effects: * A trace is set up on the variable given by varName, such that * future references to the variable will be intermediated by * proc. See the manual entry for complete details on the calling * sequence for proc. * *---------------------------------------------------------------------- */ int Tcl_TraceVar(interp, varName, flags, proc, clientData) Tcl_Interp *interp; /* Interpreter in which variable is * to be traced. */ unsigned char *varName; /* Name of variable; may end with "(index)" * to signify an array reference. */ int flags; /* OR-ed collection of bits, including any * of TCL_TRACE_READS, TCL_TRACE_WRITES, * TCL_TRACE_UNSETS, and TCL_GLOBAL_ONLY. */ Tcl_VarTraceProc *proc; /* Procedure to call when specified ops are * invoked upon varName. */ void *clientData; /* Arbitrary argument to pass to proc. */ { register unsigned char *p; /* * If varName refers to an array (it ends with a parenthesized * element name), then handle it specially. */ for (p = varName; *p != '\0'; p++) { if (*p == '(') { int result; unsigned char *open = p; do { p++; } while (*p != '\0'); p--; if (*p != ')') { goto scalar; } *open = '\0'; *p = '\0'; result = Tcl_TraceVar2(interp, varName, open+1, flags, proc, clientData); *open = '('; *p = ')'; return result; } } scalar: return Tcl_TraceVar2(interp, varName, 0, flags, proc, clientData); } /* *---------------------------------------------------------------------- * * Tcl_TraceVar2 -- * * Arrange for reads and/or writes to a variable to cause a * procedure to be invoked, which can monitor the operations * and/or change their actions. * * Results: * A standard Tcl return value. * * Side effects: * A trace is set up on the variable given by part1 and part2, such * that future references to the variable will be intermediated by * proc. See the manual entry for complete details on the calling * sequence for proc. * *---------------------------------------------------------------------- */ int Tcl_TraceVar2(interp, part1, part2, flags, proc, clientData) Tcl_Interp *interp; /* Interpreter in which variable is * to be traced. */ unsigned char *part1; /* Name of scalar variable or array. */ unsigned char *part2; /* Name of element within array; NULL means * trace applies to scalar variable or array * as-a-whole. */ int flags; /* OR-ed collection of bits, including any * of TCL_TRACE_READS, TCL_TRACE_WRITES, * TCL_TRACE_UNSETS, and TCL_GLOBAL_ONLY. */ Tcl_VarTraceProc *proc; /* Procedure to call when specified ops are * invoked upon varName. */ void *clientData; /* Arbitrary argument to pass to proc. */ { Tcl_HashEntry *hPtr; Var *varPtr = 0; /* Initial value only used to stop compiler * from complaining; not really needed. */ Interp *iPtr = (Interp *) interp; register VarTrace *tracePtr; int new; /* * Locate the variable, making a new (undefined) one if necessary. */ if ((flags & TCL_GLOBAL_ONLY) || (iPtr->varFramePtr == 0)) { hPtr = Tcl_CreateHashEntry(&iPtr->globalTable, part1, &new); } else { hPtr = Tcl_CreateHashEntry(&iPtr->varFramePtr->varTable, part1, &new); } if (!new) { varPtr = (Var *) Tcl_GetHashValue(hPtr); if (varPtr->flags & VAR_UPVAR) { hPtr = varPtr->value.upvarPtr; varPtr = (Var *) Tcl_GetHashValue(hPtr); } } /* * If the trace is to be on an array element, make sure that the * variable is an array variable. If the variable doesn't exist * then define it as an empty array. Then find the specific * array element. */ if (part2 != 0) { if (new) { varPtr = NewVar (0); Tcl_SetHashValue(hPtr, varPtr); varPtr->flags = VAR_ARRAY; varPtr->value.tablePtr = (Tcl_HashTable*) malloc (sizeof(Tcl_HashTable)); Tcl_InitHashTable (varPtr->value.tablePtr, TCL_STRING_KEYS); } else { if (varPtr->flags & VAR_UNDEFINED) { varPtr->flags = VAR_ARRAY; varPtr->value.tablePtr = (Tcl_HashTable*) malloc (sizeof(Tcl_HashTable)); Tcl_InitHashTable (varPtr->value.tablePtr, TCL_STRING_KEYS); } else if (!(varPtr->flags & VAR_ARRAY)) { iPtr->result = needArray; return TCL_ERROR; } } hPtr = Tcl_CreateHashEntry(varPtr->value.tablePtr, part2, &new); } if (new) { if ((part2 != 0) && (varPtr->searchPtr != 0)) { DeleteSearches(varPtr); } varPtr = NewVar (0); varPtr->flags = VAR_UNDEFINED; Tcl_SetHashValue(hPtr, varPtr); } else { varPtr = (Var *) Tcl_GetHashValue(hPtr); } /* * Set up trace information. */ tracePtr = (VarTrace*) malloc (sizeof(VarTrace)); tracePtr->traceProc = proc; tracePtr->clientData = clientData; tracePtr->flags = flags & (TCL_TRACE_READS|TCL_TRACE_WRITES|TCL_TRACE_UNSETS); tracePtr->nextPtr = varPtr->tracePtr; varPtr->tracePtr = tracePtr; return TCL_OK; } /* *---------------------------------------------------------------------- * * Tcl_UntraceVar -- * * Remove a previously-created trace for a variable. * * Results: * None. * * Side effects: * If there exists a trace for the variable given by varName * with the given flags, proc, and clientData, then that trace * is removed. * *---------------------------------------------------------------------- */ void Tcl_UntraceVar(interp, varName, flags, proc, clientData) Tcl_Interp *interp; /* Interpreter containing traced variable. */ unsigned char *varName; /* Name of variable; may end with "(index)" * to signify an array reference. */ int flags; /* OR-ed collection of bits describing * current trace, including any of * TCL_TRACE_READS, TCL_TRACE_WRITES, * TCL_TRACE_UNSETS, and TCL_GLOBAL_ONLY. */ Tcl_VarTraceProc *proc; /* Procedure assocated with trace. */ void *clientData; /* Arbitrary argument to pass to proc. */ { register unsigned char *p; /* * If varName refers to an array (it ends with a parenthesized * element name), then handle it specially. */ for (p = varName; *p != '\0'; p++) { if (*p == '(') { unsigned char *open = p; do { p++; } while (*p != '\0'); p--; if (*p != ')') { goto scalar; } *open = '\0'; *p = '\0'; Tcl_UntraceVar2(interp, varName, open+1, flags, proc, clientData); *open = '('; *p = ')'; return; } } scalar: Tcl_UntraceVar2(interp, varName, 0, flags, proc, clientData); } /* *---------------------------------------------------------------------- * * Tcl_UntraceVar2 -- * * Remove a previously-created trace for a variable. * * Results: * None. * * Side effects: * If there exists a trace for the variable given by part1 * and part2 with the given flags, proc, and clientData, then * that trace is removed. * *---------------------------------------------------------------------- */ void Tcl_UntraceVar2(interp, part1, part2, flags, proc, clientData) Tcl_Interp *interp; /* Interpreter containing traced variable. */ unsigned char *part1; /* Name of variable or array. */ unsigned char *part2; /* Name of element within array; NULL means * trace applies to scalar variable or array * as-a-whole. */ int flags; /* OR-ed collection of bits describing * current trace, including any of * TCL_TRACE_READS, TCL_TRACE_WRITES, * TCL_TRACE_UNSETS, and TCL_GLOBAL_ONLY. */ Tcl_VarTraceProc *proc; /* Procedure assocated with trace. */ void *clientData; /* Arbitrary argument to pass to proc. */ { register VarTrace *tracePtr; VarTrace *prevPtr; Var *varPtr; Interp *iPtr = (Interp *) interp; Tcl_HashEntry *hPtr; ActiveVarTrace *activePtr; /* * First, lookup the variable. */ if ((flags & TCL_GLOBAL_ONLY) || (iPtr->varFramePtr == 0)) { hPtr = Tcl_FindHashEntry(&iPtr->globalTable, part1); } else { hPtr = Tcl_FindHashEntry(&iPtr->varFramePtr->varTable, part1); } if (hPtr == 0) { return; } varPtr = (Var *) Tcl_GetHashValue(hPtr); if (varPtr->flags & VAR_UPVAR) { hPtr = varPtr->value.upvarPtr; varPtr = (Var *) Tcl_GetHashValue(hPtr); } if (part2 != 0) { if (!(varPtr->flags & VAR_ARRAY)) { return; } hPtr = Tcl_FindHashEntry(varPtr->value.tablePtr, part2); if (hPtr == 0) { return; } varPtr = (Var *) Tcl_GetHashValue(hPtr); } flags &= (TCL_TRACE_READS | TCL_TRACE_WRITES | TCL_TRACE_UNSETS); for (tracePtr = varPtr->tracePtr, prevPtr = 0; ; prevPtr = tracePtr, tracePtr = tracePtr->nextPtr) { if (tracePtr == 0) { return; } if ((tracePtr->traceProc == proc) && (tracePtr->flags == flags) && (tracePtr->clientData == clientData)) { break; } } /* * The code below makes it possible to delete traces while traces * are active: it makes sure that the deleted trace won't be * processed by CallTraces. */ for (activePtr = iPtr->activeTracePtr; activePtr != 0; activePtr = activePtr->nextPtr) { if (activePtr->nextTracePtr == tracePtr) { activePtr->nextTracePtr = tracePtr->nextPtr; } } if (prevPtr == 0) { varPtr->tracePtr = tracePtr->nextPtr; } else { prevPtr->nextPtr = tracePtr->nextPtr; } free (tracePtr); } /* *---------------------------------------------------------------------- * * Tcl_VarTraceInfo -- * * Return the clientData value associated with a trace on a * variable. This procedure can also be used to step through * all of the traces on a particular variable that have the * same trace procedure. * * Results: * The return value is the clientData value associated with * a trace on the given variable. Information will only be * returned for a trace with proc as trace procedure. If * the clientData argument is NULL then the first such trace is * returned; otherwise, the next relevant one after the one * given by clientData will be returned. If the variable * doesn't exist, or if there are no (more) traces for it, * then NULL is returned. * * Side effects: * None. * *---------------------------------------------------------------------- */ void * Tcl_VarTraceInfo(interp, varName, flags, proc, prevClientData) Tcl_Interp *interp; /* Interpreter containing variable. */ unsigned char *varName; /* Name of variable; may end with "(index)" * to signify an array reference. */ int flags; /* 0 or TCL_GLOBAL_ONLY. */ Tcl_VarTraceProc *proc; /* Procedure assocated with trace. */ void *prevClientData; /* If non-NULL, gives last value returned * by this procedure, so this call will * return the next trace after that one. * If NULL, this call will return the * first trace. */ { register unsigned char *p; /* * If varName refers to an array (it ends with a parenthesized * element name), then handle it specially. */ for (p = varName; *p != '\0'; p++) { if (*p == '(') { void *result; unsigned char *open = p; do { p++; } while (*p != '\0'); p--; if (*p != ')') { goto scalar; } *open = '\0'; *p = '\0'; result = Tcl_VarTraceInfo2(interp, varName, open+1, flags, proc, prevClientData); *open = '('; *p = ')'; return result; } } scalar: return Tcl_VarTraceInfo2(interp, varName, 0, flags, proc, prevClientData); } /* *---------------------------------------------------------------------- * * Tcl_VarTraceInfo2 -- * * Same as Tcl_VarTraceInfo, except takes name in two pieces * instead of one. * * Results: * Same as Tcl_VarTraceInfo. * * Side effects: * None. * *---------------------------------------------------------------------- */ void * Tcl_VarTraceInfo2(interp, part1, part2, flags, proc, prevClientData) Tcl_Interp *interp; /* Interpreter containing variable. */ unsigned char *part1; /* Name of variable or array. */ unsigned char *part2; /* Name of element within array; NULL means * trace applies to scalar variable or array * as-a-whole. */ int flags; /* 0 or TCL_GLOBAL_ONLY. */ Tcl_VarTraceProc *proc; /* Procedure assocated with trace. */ void *prevClientData; /* If non-NULL, gives last value returned * by this procedure, so this call will * return the next trace after that one. * If NULL, this call will return the * first trace. */ { register VarTrace *tracePtr; Var *varPtr; Interp *iPtr = (Interp *) interp; Tcl_HashEntry *hPtr; /* * First, lookup the variable. */ if ((flags & TCL_GLOBAL_ONLY) || (iPtr->varFramePtr == 0)) { hPtr = Tcl_FindHashEntry(&iPtr->globalTable, part1); } else { hPtr = Tcl_FindHashEntry(&iPtr->varFramePtr->varTable, part1); } if (hPtr == 0) { return 0; } varPtr = (Var *) Tcl_GetHashValue(hPtr); if (varPtr->flags & VAR_UPVAR) { hPtr = varPtr->value.upvarPtr; varPtr = (Var *) Tcl_GetHashValue(hPtr); } if (part2 != 0) { if (!(varPtr->flags & VAR_ARRAY)) { return 0; } hPtr = Tcl_FindHashEntry(varPtr->value.tablePtr, part2); if (hPtr == 0) { return 0; } varPtr = (Var *) Tcl_GetHashValue(hPtr); } /* * Find the relevant trace, if any, and return its clientData. */ tracePtr = varPtr->tracePtr; if (prevClientData != 0) { for ( ; tracePtr != 0; tracePtr = tracePtr->nextPtr) { if ((tracePtr->clientData == prevClientData) && (tracePtr->traceProc == proc)) { tracePtr = tracePtr->nextPtr; break; } } } for ( ; tracePtr != 0; tracePtr = tracePtr->nextPtr) { if (tracePtr->traceProc == proc) { return tracePtr->clientData; } } return 0; } /* *---------------------------------------------------------------------- * * Tcl_SetCmd -- * * This procedure is invoked to process the "set" Tcl command. * See the user documentation for details on what it does. * * Results: * A standard Tcl result value. * * Side effects: * A variable's value may be changed. * *---------------------------------------------------------------------- */ /* ARGSUSED */ int Tcl_SetCmd(dummy, interp, argc, argv) void *dummy; /* Not used. */ register Tcl_Interp *interp; /* Current interpreter. */ int argc; /* Number of arguments. */ unsigned char **argv; /* Argument strings. */ { if (argc == 2) { unsigned char *value; value = Tcl_GetVar(interp, argv[1], TCL_LEAVE_ERR_MSG); if (value == 0) { return TCL_ERROR; } interp->result = value; return TCL_OK; } else if (argc == 3) { unsigned char *result; result = Tcl_SetVar(interp, argv[1], argv[2], TCL_LEAVE_ERR_MSG); if (result == 0) { return TCL_ERROR; } interp->result = result; return TCL_OK; } else { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " varName ?newValue?\"", 0); return TCL_ERROR; } } /* *---------------------------------------------------------------------- * * Tcl_UnsetCmd -- * * This procedure is invoked to process the "unset" Tcl command. * See the user documentation for details on what it does. * * Results: * A standard Tcl result value. * * Side effects: * See the user documentation. * *---------------------------------------------------------------------- */ /* ARGSUSED */ int Tcl_UnsetCmd(dummy, interp, argc, argv) void *dummy; /* Not used. */ register Tcl_Interp *interp; /* Current interpreter. */ int argc; /* Number of arguments. */ unsigned char **argv; /* Argument strings. */ { int i; if (argc < 2) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " varName ?varName ...?\"", 0); return TCL_ERROR; } for (i = 1; i < argc; i++) { if (Tcl_UnsetVar(interp, argv[i], TCL_LEAVE_ERR_MSG) != 0) { return TCL_ERROR; } } return TCL_OK; } /* *---------------------------------------------------------------------- * * Tcl_AppendCmd -- * * This procedure is invoked to process the "append" Tcl command. * See the user documentation for details on what it does. * * Results: * A standard Tcl result value. * * Side effects: * A variable's value may be changed. * *---------------------------------------------------------------------- */ /* ARGSUSED */ int Tcl_AppendCmd(dummy, interp, argc, argv) void *dummy; /* Not used. */ register Tcl_Interp *interp; /* Current interpreter. */ int argc; /* Number of arguments. */ unsigned char **argv; /* Argument strings. */ { int i; unsigned char *result = 0; /* (Initialization only needed to keep * the compiler from complaining) */ if (argc < 3) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " varName value ?value ...?\"", 0); return TCL_ERROR; } for (i = 2; i < argc; i++) { result = Tcl_SetVar(interp, argv[1], argv[i], TCL_APPEND_VALUE|TCL_LEAVE_ERR_MSG); if (result == 0) { return TCL_ERROR; } } interp->result = result; return TCL_OK; } /* *---------------------------------------------------------------------- * * Tcl_LappendCmd -- * * This procedure is invoked to process the "lappend" Tcl command. * See the user documentation for details on what it does. * * Results: * A standard Tcl result value. * * Side effects: * A variable's value may be changed. * *---------------------------------------------------------------------- */ /* ARGSUSED */ int Tcl_LappendCmd(dummy, interp, argc, argv) void *dummy; /* Not used. */ register Tcl_Interp *interp; /* Current interpreter. */ int argc; /* Number of arguments. */ unsigned char **argv; /* Argument strings. */ { int i; unsigned char *result = 0; /* (Initialization only needed to keep * the compiler from complaining) */ if (argc < 3) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " varName value ?value ...?\"", 0); return TCL_ERROR; } for (i = 2; i < argc; i++) { result = Tcl_SetVar(interp, argv[1], argv[i], TCL_APPEND_VALUE|TCL_LIST_ELEMENT|TCL_LEAVE_ERR_MSG); if (result == 0) { return TCL_ERROR; } } interp->result = result; return TCL_OK; } /* *---------------------------------------------------------------------- * * Tcl_ArrayCmd -- * * This procedure is invoked to process the "array" Tcl command. * See the user documentation for details on what it does. * * Results: * A standard Tcl result value. * * Side effects: * See the user documentation. * *---------------------------------------------------------------------- */ /* ARGSUSED */ int Tcl_ArrayCmd(dummy, interp, argc, argv) void *dummy; /* Not used. */ register Tcl_Interp *interp; /* Current interpreter. */ int argc; /* Number of arguments. */ unsigned char **argv; /* Argument strings. */ { int length; char c; Var *varPtr; Tcl_HashEntry *hPtr; Interp *iPtr = (Interp *) interp; if (argc < 3) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " option arrayName ?arg ...?\"", 0); return TCL_ERROR; } /* * Locate the array variable (and it better be an array). */ if (iPtr->varFramePtr == 0) { hPtr = Tcl_FindHashEntry(&iPtr->globalTable, argv[2]); } else { hPtr = Tcl_FindHashEntry(&iPtr->varFramePtr->varTable, argv[2]); } if (hPtr == 0) { notArray: Tcl_AppendResult(interp, "\"", argv[2], "\" isn't an array", 0); return TCL_ERROR; } varPtr = (Var *) Tcl_GetHashValue(hPtr); if (varPtr->flags & VAR_UPVAR) { varPtr = (Var *) Tcl_GetHashValue(varPtr->value.upvarPtr); } if (!(varPtr->flags & VAR_ARRAY)) { goto notArray; } /* * Dispatch based on the option. */ c = argv[1][0]; length = strlen(argv[1]); if ((c == 'a') && (strncmp(argv[1], (unsigned char*) "anymore", length) == 0)) { ArraySearch *searchPtr; if (argc != 4) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " anymore arrayName searchId\"", 0); return TCL_ERROR; } searchPtr = ParseSearchId(interp, varPtr, argv[2], argv[3]); if (searchPtr == 0) { return TCL_ERROR; } while (1) { Var *varPtr2; if (searchPtr->nextEntry != 0) { varPtr2 = (Var *) Tcl_GetHashValue(searchPtr->nextEntry); if (!(varPtr2->flags & VAR_UNDEFINED)) { break; } } searchPtr->nextEntry = Tcl_NextHashEntry(&searchPtr->search); if (searchPtr->nextEntry == 0) { interp->result = (unsigned char*) "0"; return TCL_OK; } } interp->result = (unsigned char*) "1"; return TCL_OK; } else if ((c == 'd') && (strncmp(argv[1], (unsigned char*) "donesearch", length) == 0)) { ArraySearch *searchPtr, *prevPtr; if (argc != 4) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " donesearch arrayName searchId\"", 0); return TCL_ERROR; } searchPtr = ParseSearchId(interp, varPtr, argv[2], argv[3]); if (searchPtr == 0) { return TCL_ERROR; } if (varPtr->searchPtr == searchPtr) { varPtr->searchPtr = searchPtr->nextPtr; } else { for (prevPtr = varPtr->searchPtr; ; prevPtr = prevPtr->nextPtr) { if (prevPtr->nextPtr == searchPtr) { prevPtr->nextPtr = searchPtr->nextPtr; break; } } } free (searchPtr); } else if ((c == 'n') && (strncmp(argv[1], (unsigned char*) "names", length) == 0) && (length >= 2)) { Tcl_HashSearch search; Var *varPtr2; if (argc != 3) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " names arrayName\"", 0); return TCL_ERROR; } for (hPtr = Tcl_FirstHashEntry(varPtr->value.tablePtr, &search); hPtr != 0; hPtr = Tcl_NextHashEntry(&search)) { varPtr2 = (Var *) Tcl_GetHashValue(hPtr); if (varPtr2->flags & VAR_UNDEFINED) { continue; } Tcl_AppendElement(interp, Tcl_GetHashKey(varPtr->value.tablePtr, hPtr), 0); } } else if ((c == 'n') && (strncmp(argv[1], (unsigned char*) "nextelement", length) == 0) && (length >= 2)) { ArraySearch *searchPtr; Tcl_HashEntry *hPtr; if (argc != 4) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " nextelement arrayName searchId\"", 0); return TCL_ERROR; } searchPtr = ParseSearchId(interp, varPtr, argv[2], argv[3]); if (searchPtr == 0) { return TCL_ERROR; } while (1) { Var *varPtr2; hPtr = searchPtr->nextEntry; if (hPtr == 0) { hPtr = Tcl_NextHashEntry(&searchPtr->search); if (hPtr == 0) { return TCL_OK; } } else { searchPtr->nextEntry = 0; } varPtr2 = (Var *) Tcl_GetHashValue(hPtr); if (!(varPtr2->flags & VAR_UNDEFINED)) { break; } } interp->result = Tcl_GetHashKey(varPtr->value.tablePtr, hPtr); } else if ((c == 's') && (strncmp(argv[1], (unsigned char*) "size", length) == 0) && (length >= 2)) { Tcl_HashSearch search; Var *varPtr2; int size; if (argc != 3) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " size arrayName\"", 0); return TCL_ERROR; } size = 0; for (hPtr = Tcl_FirstHashEntry(varPtr->value.tablePtr, &search); hPtr != 0; hPtr = Tcl_NextHashEntry(&search)) { varPtr2 = (Var *) Tcl_GetHashValue(hPtr); if (varPtr2->flags & VAR_UNDEFINED) { continue; } size++; } sprintf(interp->result, "%d", size); } else if ((c == 's') && (strncmp(argv[1], (unsigned char*) "startsearch", length) == 0) && (length >= 2)) { ArraySearch *searchPtr; if (argc != 3) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " startsearch arrayName\"", 0); return TCL_ERROR; } searchPtr = (ArraySearch*) malloc (sizeof(ArraySearch)); if (varPtr->searchPtr == 0) { searchPtr->id = 1; Tcl_AppendResult(interp, "s-1-", argv[2], 0); } else { unsigned char string[20]; searchPtr->id = varPtr->searchPtr->id + 1; sprintf(string, "%u", searchPtr->id); Tcl_AppendResult(interp, "s-", string, "-", argv[2], 0); } searchPtr->varPtr = varPtr; searchPtr->nextEntry = Tcl_FirstHashEntry(varPtr->value.tablePtr, &searchPtr->search); searchPtr->nextPtr = varPtr->searchPtr; varPtr->searchPtr = searchPtr; } else { Tcl_AppendResult(interp, "bad option \"", argv[1], "\": should be anymore, donesearch, names, nextelement, ", "size, or startsearch", 0); return TCL_ERROR; } return TCL_OK; } /* *---------------------------------------------------------------------- * * Tcl_GlobalCmd -- * * This procedure is invoked to process the "global" Tcl command. * See the user documentation for details on what it does. * * Results: * A standard Tcl result value. * * Side effects: * See the user documentation. * *---------------------------------------------------------------------- */ /* ARGSUSED */ int Tcl_GlobalCmd(dummy, interp, argc, argv) void *dummy; /* Not used. */ Tcl_Interp *interp; /* Current interpreter. */ int argc; /* Number of arguments. */ unsigned char **argv; /* Argument strings. */ { Var *varPtr, *gVarPtr; register Interp *iPtr = (Interp *) interp; Tcl_HashEntry *hPtr, *hPtr2; int new; if (argc < 2) { Tcl_AppendResult((Tcl_Interp *) iPtr, "wrong # args: should be \"", argv[0], " varName ?varName ...?\"", 0); return TCL_ERROR; } if (iPtr->varFramePtr == 0) { return TCL_OK; } for (argc--, argv++; argc > 0; argc--, argv++) { hPtr = Tcl_CreateHashEntry(&iPtr->globalTable, *argv, &new); if (new) { gVarPtr = NewVar (0); gVarPtr->flags |= VAR_UNDEFINED; Tcl_SetHashValue(hPtr, gVarPtr); } else { gVarPtr = (Var *) Tcl_GetHashValue(hPtr); } hPtr2 = Tcl_CreateHashEntry(&iPtr->varFramePtr->varTable, *argv, &new); if (!new) { Var *varPtr; varPtr = (Var *) Tcl_GetHashValue(hPtr2); if (varPtr->flags & VAR_UPVAR) { continue; } else { Tcl_AppendResult((Tcl_Interp *) iPtr, "variable \"", *argv, "\" already exists", 0); return TCL_ERROR; } } varPtr = NewVar (0); varPtr->flags |= VAR_UPVAR; varPtr->value.upvarPtr = hPtr; gVarPtr->upvarUses++; Tcl_SetHashValue(hPtr2, varPtr); } return TCL_OK; } /* *---------------------------------------------------------------------- * * Tcl_UpvarCmd -- * * This procedure is invoked to process the "upvar" Tcl command. * See the user documentation for details on what it does. * * Results: * A standard Tcl result value. * * Side effects: * See the user documentation. * *---------------------------------------------------------------------- */ /* ARGSUSED */ int Tcl_UpvarCmd(dummy, interp, argc, argv) void *dummy; /* Not used. */ Tcl_Interp *interp; /* Current interpreter. */ int argc; /* Number of arguments. */ unsigned char **argv; /* Argument strings. */ { register Interp *iPtr = (Interp *) interp; int result; CallFrame *framePtr; Var *varPtr = 0; Tcl_HashTable *upVarTablePtr; Tcl_HashEntry *hPtr, *hPtr2; int new; Var *upVarPtr; if (argc < 3) { upvarSyntax: Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " ?level? otherVar localVar ?otherVar localVar ...?\"", 0); return TCL_ERROR; } /* * Find the hash table containing the variable being referenced. */ result = TclGetFrame(interp, argv[1], &framePtr); if (result == -1) { return TCL_ERROR; } argc -= result+1; argv += result+1; if (framePtr == 0) { upVarTablePtr = &iPtr->globalTable; } else { upVarTablePtr = &framePtr->varTable; } if ((argc & 1) != 0) { goto upvarSyntax; } /* * Iterate over all the pairs of (local variable, other variable) * names. For each pair, create a hash table entry in the upper * context (if the name wasn't there already), then associate it * with a new local variable. */ while (argc > 0) { hPtr = Tcl_CreateHashEntry(upVarTablePtr, argv[0], &new); if (new) { upVarPtr = NewVar (0); upVarPtr->flags |= VAR_UNDEFINED; Tcl_SetHashValue(hPtr, upVarPtr); } else { upVarPtr = (Var *) Tcl_GetHashValue(hPtr); if (upVarPtr->flags & VAR_UPVAR) { hPtr = upVarPtr->value.upvarPtr; upVarPtr = (Var *) Tcl_GetHashValue(hPtr); } } hPtr2 = Tcl_CreateHashEntry(&iPtr->varFramePtr->varTable, argv[1], &new); if (!new) { Tcl_AppendResult((Tcl_Interp *) iPtr, "variable \"", argv[1], "\" already exists", 0); return TCL_ERROR; } varPtr = NewVar (0); varPtr->flags |= VAR_UPVAR; varPtr->value.upvarPtr = hPtr; upVarPtr->upvarUses++; Tcl_SetHashValue(hPtr2, varPtr); argc -= 2; argv += 2; } return TCL_OK; } /* *---------------------------------------------------------------------- * * TclDeleteVars -- * * This procedure is called to recycle all the storage space * associated with a table of variables. For this procedure * to work correctly, it must not be possible for any of the * variable in the table to be accessed from Tcl commands * (e.g. from trace procedures). * * Results: * None. * * Side effects: * Variables are deleted and trace procedures are invoked, if * any are declared. * *---------------------------------------------------------------------- */ void TclDeleteVars(iPtr, tablePtr) Interp *iPtr; /* Interpreter to which variables belong. */ Tcl_HashTable *tablePtr; /* Hash table containing variables to * delete. */ { Tcl_HashSearch search; Tcl_HashEntry *hPtr; register Var *varPtr; int flags, globalFlag; flags = TCL_TRACE_UNSETS; if (tablePtr == &iPtr->globalTable) { flags |= TCL_INTERP_DESTROYED | TCL_GLOBAL_ONLY; } for (hPtr = Tcl_FirstHashEntry(tablePtr, &search); hPtr != 0; hPtr = Tcl_NextHashEntry(&search)) { varPtr = (Var *) Tcl_GetHashValue(hPtr); /* * For global/upvar variables referenced in procedures, free up the * local space and then decrement the reference count on the * variable referred to. If there are no more references to the * global/upvar and it is undefined and has no traces set, then * follow on and delete the referenced variable too. */ globalFlag = 0; if (varPtr->flags & VAR_UPVAR) { hPtr = varPtr->value.upvarPtr; free (varPtr); varPtr = (Var *) Tcl_GetHashValue(hPtr); varPtr->upvarUses--; if ((varPtr->upvarUses != 0) || !(varPtr->flags & VAR_UNDEFINED) || (varPtr->tracePtr != 0)) { continue; } globalFlag = TCL_GLOBAL_ONLY; } /* * Invoke traces on the variable that is being deleted, then * free up the variable's space (no need to free the hash entry * here, unless we're dealing with a global variable: the * hash entries will be deleted automatically when the whole * table is deleted). */ if (varPtr->tracePtr != 0) { (void) CallTraces(iPtr, (Var *) 0, hPtr, Tcl_GetHashKey(tablePtr, hPtr), 0, flags | globalFlag); while (varPtr->tracePtr != 0) { VarTrace *tracePtr = varPtr->tracePtr; varPtr->tracePtr = tracePtr->nextPtr; free (tracePtr); } } if (varPtr->flags & VAR_ARRAY) { DeleteArray(iPtr, Tcl_GetHashKey(tablePtr, hPtr), varPtr, flags | globalFlag); } if (globalFlag) { Tcl_DeleteHashEntry(hPtr); } free (varPtr); } Tcl_DeleteHashTable(tablePtr); } /* *---------------------------------------------------------------------- * * CallTraces -- * * This procedure is invoked to find and invoke relevant * trace procedures associated with a particular operation on * a variable. This procedure invokes traces both on the * variable and on its containing array (where relevant). * * Results: * The return value is 0 if no trace procedures were invoked, or * if all the invoked trace procedures returned successfully. * The return value is non-zero if a trace procedure returned an * error (in this case no more trace procedures were invoked after * the error was returned). In this case the return value is a * pointer to a static string describing the error. * * Side effects: * Almost anything can happen, depending on trace; this procedure * itself doesn't have any side effects. * *---------------------------------------------------------------------- */ static unsigned char * CallTraces (iPtr, arrayPtr, hPtr, part1, part2, flags) Interp *iPtr; /* Interpreter containing variable. */ register Var *arrayPtr; /* Pointer to array variable that * contains the variable, or 0 if * the variable isn't an element of an * array. */ Tcl_HashEntry *hPtr; /* Hash table entry corresponding to * variable whose traces are to be * invoked. */ unsigned char *part1, *part2; /* Variable's two-part name. */ int flags; /* Flags to pass to trace procedures: * indicates what's happening to * variable, plus other stuff like * TCL_GLOBAL_ONLY and * TCL_INTERP_DESTROYED. */ { Var *varPtr; register VarTrace *tracePtr; ActiveVarTrace active; unsigned char *result; int savedArrayFlags = 0; /* (Initialization not needed except * to prevent compiler warning) */ /* * If there are already similar trace procedures active for the * variable, don't call them again. */ varPtr = (Var *) Tcl_GetHashValue(hPtr); if (varPtr->flags & VAR_TRACE_ACTIVE) { return 0; } varPtr->flags |= VAR_TRACE_ACTIVE; /* * Invoke traces on the array containing the variable, if relevant. */ result = 0; active.nextPtr = iPtr->activeTracePtr; iPtr->activeTracePtr = &active; if (arrayPtr != 0) { savedArrayFlags = arrayPtr->flags; arrayPtr->flags |= VAR_ELEMENT_ACTIVE; for (tracePtr = arrayPtr->tracePtr; tracePtr != 0; tracePtr = active.nextTracePtr) { active.nextTracePtr = tracePtr->nextPtr; if (!(tracePtr->flags & flags)) { continue; } result = (*tracePtr->traceProc)(tracePtr->clientData, (Tcl_Interp *) iPtr, part1, part2, flags); if (result != 0) { if (flags & TCL_TRACE_UNSETS) { result = 0; } else { goto done; } } } } /* * Invoke traces on the variable itself. */ if (flags & TCL_TRACE_UNSETS) { flags |= TCL_TRACE_DESTROYED; } for (tracePtr = varPtr->tracePtr; tracePtr != 0; tracePtr = active.nextTracePtr) { active.nextTracePtr = tracePtr->nextPtr; if (!(tracePtr->flags & flags)) { continue; } result = (*tracePtr->traceProc)(tracePtr->clientData, (Tcl_Interp *) iPtr, part1, part2, flags); if (result != 0) { if (flags & TCL_TRACE_UNSETS) { result = 0; } else { goto done; } } } /* * Restore the variable's flags, remove the record of our active * traces, and then return. Remember that the variable could have * been re-allocated during the traces, but its hash entry won't * change. */ done: if (arrayPtr != 0) { arrayPtr->flags = savedArrayFlags; } varPtr = (Var *) Tcl_GetHashValue(hPtr); varPtr->flags &= ~VAR_TRACE_ACTIVE; iPtr->activeTracePtr = active.nextPtr; return result; } /* *---------------------------------------------------------------------- * * NewVar -- * * Create a new variable with a given initial value. * * Results: * The return value is a pointer to the new variable structure. * The variable will not be part of any hash table yet, and its * upvarUses count is initialized to 0. Its initial value will * be empty, but "space" bytes will be available in the value * area. * * Side effects: * Storage gets allocated. * *---------------------------------------------------------------------- */ static Var * NewVar (int space) /* Minimum amount of space to allocate * for variable's value. */ { int extra; register Var *varPtr; extra = space - sizeof(varPtr->value); if (extra < 0) { extra = 0; space = sizeof(varPtr->value); } varPtr = (Var*) malloc ((unsigned) (sizeof(Var) + extra)); varPtr->valueLength = 0; varPtr->valueSpace = space; varPtr->upvarUses = 0; varPtr->tracePtr = 0; varPtr->searchPtr = 0; varPtr->flags = 0; varPtr->value.string[0] = 0; return varPtr; } /* *---------------------------------------------------------------------- * * ParseSearchId -- * * This procedure translates from a string to a pointer to an * active array search (if there is one that matches the string). * * Results: * The return value is a pointer to the array search indicated * by string, or 0 if there isn't one. If 0 is returned, * interp->result contains an error message. * * Side effects: * None. * *---------------------------------------------------------------------- */ static ArraySearch * ParseSearchId(interp, varPtr, varName, string) Tcl_Interp *interp; /* Interpreter containing variable. */ Var *varPtr; /* Array variable search is for. */ unsigned char *varName; /* Name of array variable that search is * supposed to be for. */ char *string; /* String containing id of search. Must have * form "search-num-var" where "num" is a * decimal number and "var" is a variable * name. */ { char *end; int id; ArraySearch *searchPtr; /* * Parse the id into the three parts separated by dashes. */ if ((string[0] != 's') || (string[1] != '-')) { syntax: Tcl_AppendResult(interp, "illegal search identifier \"", string, "\"", 0); return 0; } id = strtoul(string+2, &end, 10); if ((end == (string+2)) || (*end != '-')) { goto syntax; } if (strcmp(end+1, varName) != 0) { Tcl_AppendResult(interp, "search identifier \"", string, "\" isn't for variable \"", varName, "\"", 0); return 0; } /* * Search through the list of active searches on the interpreter * to see if the desired one exists. */ for (searchPtr = varPtr->searchPtr; searchPtr != 0; searchPtr = searchPtr->nextPtr) { if (searchPtr->id == id) { return searchPtr; } } Tcl_AppendResult(interp, "couldn't find search \"", string, "\"", 0); return 0; } /* *---------------------------------------------------------------------- * * DeleteSearches -- * * This procedure is called to free up all of the searches * associated with an array variable. * * Results: * None. * * Side effects: * Memory is released to the storage allocator. * *---------------------------------------------------------------------- */ static void DeleteSearches(arrayVarPtr) register Var *arrayVarPtr; /* Variable whose searches are * to be deleted. */ { ArraySearch *searchPtr; while (arrayVarPtr->searchPtr != 0) { searchPtr = arrayVarPtr->searchPtr; arrayVarPtr->searchPtr = searchPtr->nextPtr; free (searchPtr); } } /* *---------------------------------------------------------------------- * * DeleteArray -- * * This procedure is called to free up everything in an array * variable. It's the caller's responsibility to make sure * that the array is no longer accessible before this procedure * is called. * * Results: * None. * * Side effects: * All storage associated with varPtr's array elements is deleted * (including the hash table). Any delete trace procedures for * array elements are invoked. * *---------------------------------------------------------------------- */ static void DeleteArray(iPtr, arrayName, varPtr, flags) Interp *iPtr; /* Interpreter containing array. */ unsigned char *arrayName; /* Name of array (used for trace * callbacks). */ Var *varPtr; /* Pointer to variable structure. */ int flags; /* Flags to pass to CallTraces: * TCL_TRACE_UNSETS and sometimes * TCL_INTERP_DESTROYED and/or * TCL_GLOBAL_ONLY. */ { Tcl_HashSearch search; register Tcl_HashEntry *hPtr; register Var *elPtr; DeleteSearches(varPtr); for (hPtr = Tcl_FirstHashEntry(varPtr->value.tablePtr, &search); hPtr != 0; hPtr = Tcl_NextHashEntry(&search)) { elPtr = (Var *) Tcl_GetHashValue(hPtr); if (elPtr->tracePtr != 0) { (void) CallTraces(iPtr, (Var *) 0, hPtr, arrayName, Tcl_GetHashKey(varPtr->value.tablePtr, hPtr), flags); while (elPtr->tracePtr != 0) { VarTrace *tracePtr = elPtr->tracePtr; elPtr->tracePtr = tracePtr->nextPtr; free (tracePtr); } } assert ((elPtr->flags & VAR_SEARCHES_POSSIBLE) == 0); free (elPtr); } Tcl_DeleteHashTable(varPtr->value.tablePtr); free (varPtr->value.tablePtr); } /* *---------------------------------------------------------------------- * * VarErrMsg -- * * Generate a reasonable error message describing why a variable * operation failed. * * Results: * None. * * Side effects: * Interp->result is reset to hold a message identifying the * variable given by part1 and part2 and describing why the * variable operation failed. * *---------------------------------------------------------------------- */ static void VarErrMsg(interp, part1, part2, operation, reason) Tcl_Interp *interp; /* Interpreter in which to record message. */ unsigned char *part1, *part2; /* Variable's two-part name. */ unsigned char *operation; /* String describing operation that failed, * e.g. "read", "set", or "unset". */ unsigned char *reason; /* String describing why operation failed. */ { Tcl_ResetResult(interp); Tcl_AppendResult(interp, "can't ", operation, " \"", part1, 0); if (part2 != 0) { Tcl_AppendResult(interp, "(", part2, ")", 0); } Tcl_AppendResult(interp, "\": ", reason, 0); } ================================================ FILE: lib/libtermlib/Makefile ================================================ # # Copyright (c) 1980 Regents of the University of California. # All rights reserved. The Berkeley software License Agreement # specifies the terms and conditions for redistribution. # TOPSRC!=cd ../..; pwd include ${TOPSRC}/share/mk/sys.mk DEFS = -DNOSCCS CFLAGS += -O -DCM_N -DCM_GT -DCM_B -DCM_D ${DEFS} -Wall LD = $(CC) SRCS = termcap.c tgoto.c tputs.c tcattr.c OBJS = termcap.o tgoto.o tputs.o tcattr.o POBJS = ../termcap.o ../tgoto.o ../tputs.o ../tcattr.o TAGSFILE= tags #.c.o: # $(CC) $(CFLAGS) -c -p $*.c # $(LD) $(LDFLAGS) -x -r -o profiled/$*.o $*.o # $(CC) $(CFLAGS) -c $*.c # $(LD) $(LDFLAGS) -X -r $*.o # mv a.out $*.o all: ../libtermcap.a termcap .PHONY: termcap termcap: cd termcap && ${MAKE} ../libtermcap.a: ${OBJS} $(AR) cr ../libtermcap.a ${OBJS} ../libtermcap_p.a: ${OBJS} cd profiled; $(AR) cr ../../libtermcap_p.a ${POBJS} install: all # cp ../libtermcap.a ${DESTDIR}/usr/lib/libtermcap.a # @-rm -f ${DESTDIR}/usr/lib/libtermlib.a # ln ${DESTDIR}/usr/lib/libtermcap.a ${DESTDIR}/usr/lib/libtermlib.a # $(RANLIB) ${DESTDIR}/usr/lib/libtermcap.a $(MAKE) -C termcap install # cp ../libtermcap_p.a ${DESTDIR}/usr/lib/libtermcap_p.a # @-rm -f ${DESTDIR}/usr/lib/libtermlib_p.a # ln ${DESTDIR}/usr/lib/libtermcap_p.a ${DESTDIR}/usr/lib/libtermlib_p.a # $(RANLIB) ${DESTDIR}/usr/lib/libtermcap_p.a tags: cwd=`pwd`; \ for i in ${SRCS}; do \ ctags -a -f ${TAGSFILE} $$cwd/$$i; \ done clean: -rm -f *.o profiled/*.o -rm -f ../libtermcap.a ../libtermcap_p.a -rm -f termcap/termcap termcap/termcap.full VGRIND= csh /usr/ucb/vgrind vgrind: cp /dev/null index ${VGRIND} -h "Termcap library" termcap.c tputs.c tgoto.c ${VGRIND} -h "Termcap library" -x index ================================================ FILE: lib/libtermlib/tc1.c ================================================ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ /* * tc1 [term] * dummy program to test termlib. * gets entry, counts it, and prints it. */ #include char buf[1024]; char *getenv(); main(argc, argv) char **argv; { char *p; int rc; if (argc < 2) p = getenv("TERM"); else p = argv[1]; rc = tgetent(buf,p); printf("tgetent returns %d, len=%d, text=\n'%s'\n",rc,strlen(buf),buf); } ================================================ FILE: lib/libtermlib/tc2.c ================================================ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ /* * tc2 [term] * Dummy program to test out termlib. * Commands are "tcc\n" where t is type (s for string, f for flag, * or n for number) and cc is the name of the capability. */ #include char buf[1024]; char *getenv(), *tgetstr(); main(argc, argv) char **argv; { char *p, *q; int rc; char b[3], c; char area[200]; if (argc < 2) p = getenv("TERM"); else p = argv[1]; rc = tgetent(buf,p); for (;;) { c = getchar(); if (c < 0) exit(0); b[0] = getchar(); if (b[0] < ' ') exit(0); b[1] = getchar(); b[2] = 0; getchar(); switch(c) { case 'f': printf("%s: %d\n",b,tgetflag(b)); break; case 'n': printf("%s: %d\n",b,tgetnum(b)); break; case 's': q = area; printf("%s: %s\n",b,tgetstr(b,&q)); break; default: exit(0); } } } ================================================ FILE: lib/libtermlib/tc3.c ================================================ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ /* * tc3 [term] * Dummy program to test out termlib. * Input two numbers and it prints out the tgoto string generated. */ #include char buf[1024]; char *getenv(), *tgetstr(); char *rdchar(); char *tgoto(); char *CM; char cmbuff[30]; char *x; char *UP; char *tgout; main(argc, argv) char **argv; { char *p; int rc; int row, col; if (argc < 2) p = getenv("TERM"); else p = argv[1]; rc = tgetent(buf,p); x = cmbuff; UP = tgetstr("up", &x); printf("UP = %x = ", UP); pr(UP); printf("\n"); if (UP && *UP==0) UP = 0; CM = tgetstr("cm", &x); printf("CM = "); pr(CM); printf("\n"); for (;;) { if (scanf("%d %d", &row, &col) < 2) exit(0); tgout = tgoto(CM, row, col); pr(tgout); printf("\n"); } } pr(p) register char *p; { for (; *p; p++) printf("%s", rdchar(*p)); } /* * rdchar: returns a readable representation of an ASCII char, using ^ notation. */ #include char *rdchar(c) char c; { static char ret[4]; register char *p; /* * Due to a bug in isprint, this prints spaces as ^`, but this is OK * because we want something to show up on the screen. */ ret[0] = ((c&0377) > 0177) ? '\'' : ' '; c &= 0177; ret[1] = isprint(c) ? ' ' : '^'; ret[2] = isprint(c) ? c : c^0100; ret[3] = 0; for (p=ret; *p==' '; p++) ; return (p); } ================================================ FILE: lib/libtermlib/tcattr.c ================================================ // // TODO: termios support // #if 0 #include #include int tcgetattr(int fd, struct termios *t) { return (ioctl(fd, TIOCGETA, t)); } int tcsetattr(int fd, int opt, struct termios *t) { struct termios localterm; if (opt & TCSASOFT) { localterm = *t; localterm.c_cflag |= CIGNORE; t = &localterm; } switch (opt & ~TCSASOFT) { case TCSANOW: return (ioctl(fd, TIOCSETA, t)); case TCSADRAIN: return (ioctl(fd, TIOCSETAW, t)); case TCSAFLUSH: return (ioctl(fd, TIOCSETAF, t)); default: errno = EINVAL; return (-1); } } #endif ================================================ FILE: lib/libtermlib/termcap/.gitignore ================================================ termcap.full ================================================ FILE: lib/libtermlib/termcap/Makefile ================================================ # # Copyright (c) 1980 Regents of the University of California. # All rights reserved. The Berkeley software License Agreement # specifies the terms and conditions for redistribution. # # @(#)Makefile 5.2.4 (2.11BSD GTE) 1997/9/22 # # reorder gives an editor command for most common terminals # (in reverse order from n'th to 1'st most commonly used) # to move them to the front of termcap # TOPSRC!=cd ../../..; pwd include ${TOPSRC}/share/mk/sys.mk termcap.full: reorder termcap.src ex - termcap.src < reorder install: termcap.small termcap.full rm -f ${DESTDIR}/usr/share/misc/termcap ${INSTALL} -c -m 444 termcap.small ${DESTDIR}/usr/share/misc/termcap # ${INSTALL} -c -m 444 termcap.full ${DESTDIR}/etc/termcap.full tabset: FRC rm -fr ${DESTDIR}/usr/share/tabset mkdir ${DESTDIR}/usr/share/tabset chmod 755 ${DESTDIR}/usr/share/tabset ${INSTALL} -c -m 444 tabset/* ${DESTDIR}/usr/share/tabset clean: rm -f termcap.full FRC: ================================================ FILE: lib/libtermlib/termcap/README ================================================ To install this directory on your system: First determine a list of "common terminals" for your system. This list will probably be small, and can be empty if you like, but you should probably put your own terminal in it. Second, edit the editor script "reorder" to use this list instead of the list built in to it. The changes will be evident from looking at the script. Notice that the script contains the terminals in order from least common to most common, since the move commands will move them to the front in that order, the effect will be to put the most common at the front of termcap since that's moved last. The s.* terminals are specials, and although they don't have to go to the front, they are probably quite common and really should go near the front. Third, if you are not a super user and cannot create the directory /usr/share/tabset, make a corresponding directory somewhere you can and add a line to reorder to globally change all /usr/share/tabset's to your own path name. This change is better than just changing the termcap.src file because it makes it easier to diff it from newer distributed versions. Try to keep the source as is whenever possible, and put mungings into reorder. Now you can run "make install" which will create an /etc/termcap. Again, if you aren't a super user change the cp command to put it where you can. In this case you will have to redefine E_TERMCAP in "local/uparm.h", which will probably be in subdirectories with the other UCB software. Finally, if you make additions or fixes to termcap, please mail a note explaining what you did with the fixed termcap entry (not the whole file, please!) to me at one of the addresses below, so it can be incorporated back into the original source. I will normally include anything unless there is a good reason not to, but I reserve the right to redo it differently. ucbvax!termcap (uucp) termcap@berkeley (Arpanet) or Kevin Layer Computer Science Division Evans Hall University of California Berkeley, California 94720 ================================================ FILE: lib/libtermlib/termcap/map3270 ================================================ # /usr/share/misc/map3270 # mail corrections and additions to "termcap" # # this file contains mappings between characters entered from the keyboard, # and 3270 keys, for use by programs (like tn3270) doing 3270 emulation # from unix. # # inside the single quotes, a caret ("^") introduces a control character # sequence (rub out = ^?, by the way). also inside the single quotes, # a backslash ('\') introduces an escaped character. Also, \n, \r, \t, # are all as in c, and \E is another way of representing escape. # # NOTE that while we are defining lots of function, much of that # function (ie: local editing keys) may not yet be available from # tn3270. 3a | adm3a { enter = '^m'; clear = '^z'; nl = '^n' | '^^'; tab = '^i'; btab = '^b'; left = '^h'; right = '^l'; up = '^k'; down = '^j'; home = '^@'; delete = '^d' | '^?'; eeof = '^e'; einp = '^w'; insrt = '\E '; dp = '^u'; fm = '^y'; # pf keys pfk1 = '\E1'; pfk2 = '\E2'; pfk3 = '\E3'; pfk4 = '\E4'; pfk5 = '\E5'; pfk6 = '\E6'; pfk7 = '\E7'; pfk8 = '\E8'; pfk9 = '\E9'; pfk10 = '\E0'; pfk11 = '\E:'; pfk12 = '\E-'; pfk13 = '^f13'; pfk14 = '^f14'; pfk15 = '^f15'; pfk16 = '^f16'; pfk17 = '^f17'; pfk18 = '^f18'; pfk19 = '^f19'; pfk20 = '^f20'; pfk21 = '^f21'; pfk22 = '^f22'; pfk23 = '^f23'; pfk24 = '^f24'; # program attention keys pa1 = '^p1'; pa2 = '^p2'; pa3 = '^p3'; # other keys cursel = '\E.'; # local control keys reset = '^t'; # well, there is a little confusion here... master_reset = '^g'; flinp = '^x'; reshow = '^v'; # redisplay screen escape = '^c'; # escape to telnet command mode # local editing keys settab = '\E;'; clrtab = '\E+'; setmrg = '\E('; sethom = '\E!'; coltab = '\Ei'; colbak = '\Eb'; indent = '\El'; undent = '\Eh'; } # end of adm3a 920c | tvi920c { # tvi920c definitions... # command keys enter = '^m'; clear = '^z'; # cursor movement keys nl = '^^'; tab = '^i'; btab = '^b'; left = '^h'; right = '^l'; up = '^k'; down = '^j'; home = '^@'; # edit control keys delete = '^?' | '^d'; eeof = '^e'; einp = '^w'; insrt = '\E '; dp = '^u'; fm = '^y'; # program function keys pfk1 = '^a@^m'; pfk2 = '^aA^m'; pfk3 = '^aB^m'; pfk4 = '^aC^m'; pfk5 = '^aD^m'; pfk6 = '^aE^m'; pfk7 = '^aF^m'; pfk8 = '^aG^m'; pfk9 = '^aH^m'; pfk10 = '^aI^m'; pfk11 = '^aJ^m' | '\E^a@^m'; pfk12 = '^aj^m' | '\E^aA^m'; pfk13 = '\E^aB^m'; pfk14 = '\E^aC^m'; pfk15 = '\E^aD^m'; pfk16 = '\E^aE^m'; pfk17 = '\E^aF^m'; pfk18 = '\E^aG^m'; pfk19 = '\E^aH^m'; pfk20 = '\E^aI^m'; pfk21 = '\E^a`^m'; pfk22 = '\E^aa^m'; pfk23 = '\E^ab^m'; pfk24 = '\E^ac^m'; # program attention keys pa1 = '^a`^m'; pa2 = '^aa^m'; pa3 = '^ab^m'; # miscellaneous 3270 keys cursel = '\E.'; # local control keys reset = '^t'; # there is some confusion here... master_reset = '^g'; flinp = '^x'; reshow = '^v'; escape = '^c'; # escape to telnet command mode # local editing keys settab = '\E;'; clrtab = '\E:'; setmrg = '\E*'; sethom = '\E!'; coltab = '\Ei' | '\EI'; colbak = '\Eb' | '\EB'; indent = '\El' | '\EL'; undent = '\Eh' | '\EH'; } # end of tvi920c table... 925 | tvi925 | 925vb | tvi925vb | televideo 925 { # command keys enter = '^m'; clear = '^z'; # cursor movement keys nl = '^j'; tab = '^i'; btab = '\EI'; left = '^h'; right = '^l'; up = '^k'; down = '^v'; home = '^^'; # edit control keys delete = '^?'; # that's rubout... eeof = '^e'; einp = '^w'; insrt = '\E ' | '\EW'; # program function keys pfk1 = '^a@^m'; pfk2 = '^aA^m'; pfk3 = '^aB^m'; pfk4 = '^aC^m'; pfk5 = '^aD^m'; pfk6 = '^aE^m'; pfk7 = '^aF^m'; pfk8 = '^aG^m'; pfk9 = '^aH^m'; pfk10 = '^aI^m'; pfk11 = '^aJ^m'; pfk12 = '\EQ'; pfk13 = '\E^a@^m'; pfk14 = '\E^aA^m'; pfk15 = '\E^aB^m'; pfk16 = '\E^aC^m'; pfk17 = '\E^aD^m'; pfk18 = '\E^aE^m'; pfk19 = '\E^aF^m'; pfk20 = '\E^aG^m'; pfk21 = '\E^aH^m'; pfk22 = '\E^aI^m'; pfk23 = '\E^aJ^m'; pfk24 = '\E\EQ'; # program attention keys pa1 = '^a`^m'; pa2 = '^aa^m'; pa3 = '^ab^m'; # other keys # local control keys reset = '^t'; # again, there is some confusion here... master_reset = '^g'; flinp = '^x'; reshow = '^b'; escape = '^c'; # escape to telnet command mode # local editing keys settab = '\EY'; deltab = '\Ey'; clrtab = '\E:'; setmrg = '\ET'; sethom = '\Et'; coltab = '^p'; colbak = '^o'; indent = '\ER'; undent = '\EE'; } 924 | tvi924 { # command keys enter = '^m'; clear = '^z'; # cursor movement keys nl = '^j'; tab = '^i'; btab = '\EI'; left = '^h'; right = '^l'; up = '^k'; down = '^v'; home = '^^'; # edit control keys delete = '^?'; # that's rubout... eeof = '^e'; einp = '^w'; insrt = '\E ' | '\EW'; dp = '^u'; fm = '^y'; # program function keys pfk1 = '^a@^m'; pfk2 = '^aA^m'; pfk3 = '^aB^m'; pfk4 = '^aC^m'; pfk5 = '^aD^m'; pfk6 = '^aE^m'; pfk7 = '^aF^m'; pfk8 = '^aG^m'; pfk9 = '^aH^m'; pfk10 = '^aI^m'; pfk11 = '^aJ^m'; pfk12 = '^aK^m'; pfk13 = '\E^a@^m'; pfk14 = '\E^aA^m'; pfk15 = '\E^aB^m'; pfk16 = '\E^aC^m'; pfk17 = '\E^aD^m'; pfk18 = '\E^aE^m'; pfk19 = '\E^aF^m'; pfk20 = '\E^aG^m'; pfk21 = '\E^aH^m'; pfk22 = '\E^aI^m'; pfk23 = '\E^aJ^m'; pfk24 = '\E^aK^m'; # program attention keys pa1 = '^a`^m'; pa2 = '^aa^m'; pa3 = '^ab^m'; # other keys # local control keys reset = '^t'; # again, there is some confusion here... master_reset = '^g'; flinp = '^x'; reshow = '^b'; escape = '^c'; # escape to telnet command mode # local editing keys settab = '\EY'; deltab = '\Ey'; clrtab = '\E:'; setmrg = '\ET'; sethom = '\Et'; coltab = '^p'; colbak = '^o'; indent = '\ER'; undent = '\EE'; } #kb | h19 | heath | h19b | heathkit | heath-19 | z19 | zenith { kb | h19 | heath | h19b | heathkit | z19 | zenith { #coughs on heath-19 enter = '^m'; clear = '^z'; nl = '^n' | '^?'; tab = '^i'; btab = '^b'; left = '^h'; right = '^l'; up = '^k'; down = '^j'; home = '^@'; delete = '^d'; eeof = '^e'; einp = '^w'; insrt = '\E '; # pf keys pfk1 = '\E?p\E?q'; pfk2 = '\E?p\E?r'; pfk3 = '\E?p\E?s'; pfk4 = '\E?p\E?t'; pfk5 = '\E?p\E?u'; pfk6 = '\E?p\E?v'; pfk7 = '\E?p\E?w'; pfk8 = '\E?p\E?x'; pfk9 = '\E?p\E?y'; pfk10 = '\E?q\E?p'; pfk11 = '\E?q\E?q'; pfk12 = '\E?q\E?r'; pfk13 = '\E?q\E?s'; pfk14 = '\E?q\E?t'; pfk15 = '\E?q\E?u'; pfk16 = '\E?q\E?v'; pfk17 = '\E?q\E?w'; pfk18 = '\E?q\E?x'; pfk19 = '\E?q\E?y'; pfk20 = '\E?r\E?p'; pfk21 = '\E?r\E?q'; pfk22 = '\E?r\E?r'; pfk23 = '\E?r\E?s'; pfk24 = '\E?r\E?t'; # program attention keys pa1 = '\EP'; pa2 = '\EQ'; pa3 = '\ER'; # other keys # cursel = '\E.'; # find out what this does master_reset = '^g'; # local control keys reset = '^t'; # well, there is a little confusion here... flinp = '^x'; reshow = '^v'; # redisplay screen escape = '^c'; # escape to telnet command mode # local editing keys settab = '\E;'; clrtab = '\E:'; setmrg = '\E\''; sethom = '\E!'; coltab = '\Ei'; colbak = '\Eb'; indent = '\El'; undent = '\Eh'; } # end of h19 #co | c100 | concept | c100-4p | concept100 { co | c100 | concept | concept100 { # coughs on c100-4p enter = '^m'; clear = '^z' | '^\2'; nl = '^n'; tab = '^i'; btab = '^b'; left = '^h' | '\E>'; right = '^l' | '\E='; up = '^k' | '\E;'; down = '^j' | '\E<'; home = '\E?'; delete = '^d' | '^?' | '^\1'; eeof = '^e' | '^\3'; einp = '^w'; insrt = '^\0'; # pf keys pfk1 = '\E\E1' | '^\5'; pfk2 = '\E\E2' | '^\6'; pfk3 = '\E\E3' | '^\7'; pfk4 = '\E\E4' | '^\8'; pfk5 = '\E\E5' | '^\9'; pfk6 = '\E\E6' | '^\:'; pfk7 = '\E\E7' | '^\;'; pfk8 = '\E\E8' | '^\<'; pfk9 = '\E\E9' | '^\='; pfk10 = '\E\E0' | '^\>'; pfk11 = '\E\E-' | '^\?'; pfk12 = '^\@'; pfk13 = '^\A'; pfk14 = '^\B'; pfk15 = '^\)'; pfk16 = '^\*'; pfk17 = '^\+'; pfk18 = '^\,'; pfk19 = '^\-'; pfk20 = '^\.'; pfk21 = '^\/'; pfk22 = '^\C'; pfk23 = '^\D'; pfk24 = '^\E'; # program attention keys pa1 = '^\%'; pa2 = '^\&' | '\E+'; pa3 = '^\\''; # other keys cursel = '\E.'; aplon = '\E{'; aplend = '\E}'; aploff = '\E_'; master_reset = '^g'; # local control keys reset = '^t'; # well, there is a little confusion here... flinp = '^x'; reshow = '^v'; # redisplay screen escape = '^c'; # escape to telnet command mode # local editing keys settab = '\E\E;'; clrtab = '\E\E:'; setmrg = '\E\E*'; sethom = '\E\E!'; coltab = '\E\Ei'; colbak = '\E\Eb'; indent = '\E\El'; undent = '\E\Eh'; } # end of concept avt | vt100 | vt100nam | pt100 | vt125 | vt102 | direct831 { enter = '^m'; clear = '^z' | '\EOM'; # Keypad enter key nl = '^?'; tab = '^i'; btab = '^b'; left = '^h' | '\E[D' | '\EOD'; # Arrow key (application/numeric modes) right = '^l' | '\E[C' | '\EOC'; # Arrow key (application/numeric modes) up = '^k' | '\E[A' | '\EOA'; # Arrow key (application/numeric modes) down = '^j' | '\E[B' | '\EOB'; # Arrow key (application/numeric modes) home = '\EOn'; # Keypad period key delete = '^d'; eeof = '^e'; einp = '^w'; insrt = '^ '; # pfk keys # Keypad digits 1-9 correspond to pf keys 1-9 pfk1 = '\EOq' | '\E1'; pfk2 = '\EOr' | '\E2'; pfk3 = '\EOs' | '\E3'; pfk4 = '\EOt' | '\E4'; pfk5 = '\EOu' | '\E5'; pfk6 = '\EOv' | '\E6'; pfk7 = '\EOw' | '\E7'; pfk8 = '\EOx' | '\E8'; pfk9 = '\EOy' | '\E9'; # Keypad digits 0-9 prefixed by pf1 (gold key) correspond to pfk10-19 pfk10 = '\EOP\EOp' | '\E0'; pfk11 = '\EOP\EOq' | '\E-'; pfk12 = '\EOP\EOr' | '\E='; pfk13 = '\EOP\EOs' | '^f13'; pfk14 = '\EOP\EOt' | '^f14'; pfk15 = '\EOP\EOu' | '^f15'; pfk16 = '\EOP\EOv' | '^f16'; pfk17 = '\EOP\EOw' | '^f17'; pfk18 = '\EOP\EOx' | '^f18'; pfk19 = '\EOP\EOy' | '^f19'; # Keypad digits 0-9 prefixed by pf2 correspond to pfk20,21 pfk20 = '\EOQ\EOp' | '^f20'; pfk21 = '\EOQ\EOq' | '^f21'; # program attention keys pa1 = '\E\EOP' | '^p1'; # pa1 is Escape pf1 pa2 = '\E\EOQ' | '^p2'; # pa2 is Escape pf2 # local control keys reset = '^t'; # well, there is a little confusion here... flinp = '^x'; reshow = '^v'; # redisplay screen escape = '^c'; # escape to telnet command mode master_reset = '^g'; # local editing keys settab = '\E;'; # Escape key deltab = '\E\''; # Escape \ clrtab = '\E:'; # Escape : setmrg = '\E,'; # Escape , sethom = '\E.'; # Escape . coltab = '\E\E[B' | '\E\EOB'; # Escape down-arrow colbak = '\E\E[A' | '\E\EOA'; # Escape up-arrow indent = '\E\E[C' | '\E\EOC'; # Escape right-arrow undent = '\E\E[D' | '\E\EOD'; # Escape left-arrow } # end of vt100, etc. tvipt | vp | televideopt { enter = '^m'; clear = '^z'; nl = '^n'; tab = '^i'; btab = '^b'; left = '^h'; right = '^l'; up = '^k'; down = '^j'; home = '^^'; delete = '^?'; eeof = '^e'; einp = '^w'; insrt = '\E '; # pf keys pfk1 = '\E1' | '^A@^m'; pfk2 = '\E2' | '^AA^m'; pfk3 = '\E3' | '^AB^m'; pfk4 = '\E4' | '^AC^m'; pfk5 = '\E5' | '^AD^m'; pfk6 = '\E6' | '^AE^m'; pfk7 = '\E7' | '^AF^m'; pfk8 = '\E8'; pfk9 = '\E9'; pfk10 = '\E0'; pfk11 = '\E!' | '\E^A@^m'; pfk12 = '\E@' | '\E^AA^m'; pfk13 = '\E#' | '\E^AB^m'; pfk14 = '\E$' | '\E^AC^m'; pfk15 = '\E%' | '\E^AD^m'; pfk16 = '\E^AE^m' | '\E\^'; pfk17 = '\E&' | '\E^AF^m'; pfk18 = '\E*'; pfk19 = '\E('; pfk20 = '\E)'; # program attention keys pa1 = '^AG^m'; pa2 = '^AH^m'; pa3 = '^AI^m'; # other keys # # cursel = '\E.'; # local control keys reset = '^t'; # well, there is a little confusion here... master_reset = '^g'; flinp = '^x'; reshow = '^v'; # redisplay screen escape = '^c'; # escape to telnet command mode # local editing keys settab = '\E;'; clrtab = '\E:'; setmrg = '\E['; sethom = '\E+'; coltab = '\Ei' | '\EI'; colbak = '\Eb' | '\EB'; indent = '\El' | '\EL'; undent = '\Eh' | '\EH'; } # end of tvipt ================================================ FILE: lib/libtermlib/termcap/reorder ================================================ $r termcap.local /|c100|/;.,/^[^ ]/-m9 /|c100-rv|/;.,/^[^ ]/-m9 /|c100-rv-pp|/;.,/^[^ ]/-m9 /|c108-4p|/;.,/^[^ ]/-m9 /|c108-rv-4p|/;.,/^[^ ]/-m9 /|c108-8p|/;.,/^[^ ]/-m9 /|c108-rv-8p|/;.,/^[^ ]/-m9 /|avt|/;.,/^[^ ]/-m9 /|avt-rv|/;.,/^[^ ]/-m9 /|avt-4p-s|/;.,/^[^ ]/-m9 /|avt-8p-s|/;.,/^[^ ]/-m9 /|sun-17|/;.,/^[^ ]/-m9 /|sun-24|/;.,/^[^ ]/-m9 /|sun-34|/;.,/^[^ ]/-m9 /|sun-48|/;.,/^[^ ]/-m9 /|sun-s-e|/;.,/^[^ ]/-m9 /|sun-s|/;.,/^[^ ]/-m9 /|sun-e|/;.,/^[^ ]/-m9 /|sun|/;.,/^[^ ]/-m9 /|xterms|/;.,/^[^ ]/-m9 /|xterm|/;.,/^[^ ]/-m9 /|adm3|/;.,/^[^ ]/-m9 /|adm31|/;.,/^[^ ]/-m9 /|adm3a|/;.,/^[^ ]/-m9 /|vt100|/;.,/^[^ ]/-m9 /|vt220|/;.,/^[^ ]/-m9 /|2645|/;.,/^[^ ]/-m9 /|2621-nl|/;.,/^[^ ]/-m9 /|2621|/;.,/^[^ ]/-m9 /|h29|/;.,/^[^ ]/-m9 /|h19|/;.,/^[^ ]/-m9 /|h19-u|/;.,/^[^ ]/-m9 /|h19-us|/;.,/^[^ ]/-m9 /|h19-e|/;.,/^[^ ]/-m9 /|h19-g|/;.,/^[^ ]/-m9 /|5620|/;.,/^[^ ]/-m9 /^s/;.,/^#/-m9 w! termcap.full q ================================================ FILE: lib/libtermlib/termcap/tabset/3101 ================================================ H 0 0 0 0 0 0 0 0 0 ================================================ FILE: lib/libtermlib/termcap/tabset/aa ================================================  1 1 1 1 1 1 1 1 1  ================================================ FILE: lib/libtermlib/termcap/tabset/aed512 ================================================ \EG1MMM.`40K0001202080K8001????00^L\EC80L80{80^L\EK010100????K0601??0000c818100\EG1HHH.\07210000019A27FD006A280D002A200A52429FE8524861086118612861360N031B4C3F3F1800N041B0C1B4C38301800N001B3B313030301800N011B3B313030341800N021B3B313030381800N050800N061B3B313335301800\07211000015A58E8D5011A58F8D5111A5908D5211A5918D531160\07212000015AD5011858EAD5111858FAD52118590AD5311859160\0721300004B2071C5858E0A18658E0A0A858EA900858F268FA5278590A50A29018591A9F51865908590A90165918591A59038E58E8590A591E58F290185912071C5180A0A0A0901858EA900858F268F60\0721350000BA9472031DEA9502031DE60\E\E\E\EG1MMM.^A ================================================ FILE: lib/libtermlib/termcap/tabset/beehive ================================================                                                                                 ================================================ FILE: lib/libtermlib/termcap/tabset/diablo ================================================  9 2 1 1 1 !1 )1 11 91 A1 I1 Q1 Y1 a1 i1 q1 y1 9 ================================================ FILE: lib/libtermlib/termcap/tabset/dtc382 ================================================  1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ================================================ FILE: lib/libtermlib/termcap/tabset/ibm3101 ================================================ H 0 0 0 0 0 0 0 0 0 ================================================ FILE: lib/libtermlib/termcap/tabset/std ================================================ 3 1 1 1 1 1 1 1 1 1 1 1 1 1 ================================================ FILE: lib/libtermlib/termcap/tabset/stdcrt ================================================ 3 1 1 1 1 1 1 1 1 1 ================================================ FILE: lib/libtermlib/termcap/tabset/tandem653 ================================================ 3 1 1 1 1 1 1 1 1 1 1 ================================================ FILE: lib/libtermlib/termcap/tabset/teleray ================================================ GY9(FY90FY98FY9@FY9HFY9PFY9XFY9`FY9hF ================================================ FILE: lib/libtermlib/termcap/tabset/vt100 ================================================  H H H H H H H H H H H H H H H H ================================================ FILE: lib/libtermlib/termcap/tabset/wyse-adds ================================================ Setting tabs... 2 2 2 2 2 2 2 2 1 2 2 2 2 2 2 2 1 2 2 2 2 2 2 2 1 2 2 2 2 2 2 2 1 2 2 2 2 2 2 2 1 2 2 2 2 2 2 2 1 2 2 2 2 2 2 2 1 2 2 2 2 2 2 2 1 2 2 2 2 2 2 2 1 2 2 2 2 2 2 2 ================================================ FILE: lib/libtermlib/termcap/tabset/xerox1720 ================================================ 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ================================================ FILE: lib/libtermlib/termcap/tabset/zenith29 ================================================  H H H H H H H H H H ================================================ FILE: lib/libtermlib/termcap/termcap.local ================================================ # # END OF LOCAL TERMCAP # -------------------------- ================================================ FILE: lib/libtermlib/termcap/termcap.small ================================================ # Copyright (c) 1980, 1985, 1989 The Regents of the University of California. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # 3. All advertising materials mentioning features or use of this software # must display the following acknowledgement: # This product includes software developed by the University of # California, Berkeley and its contributors. # 4. Neither the name of the University nor the names of its contributors # may be used to endorse or promote products derived from this software # without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # @(#)termcap.src 5.88 (Berkeley) 4/30/91 # $FreeBSD$ # cons25|ansi|ansi80x25:\ :am:bs:NP:ms:pt:AX:eo:bw:ut:km:\ :co#80:li#25:pa#64:Co#8:it#8:\ :al=\E[L:cd=\E[J:ce=\E[K:cl=\E[H\E[J:cm=\E[%i%d;%dH:\ :dc=\E[P:dl=\E[M:do=\E[B:bt=\E[Z:ho=\E[H:ic=\E[@:cb=\E[1K:\ :nd=\E[C:rs=\Ec:so=\E[7m:se=\E[27m:up=\E[A:cr=^M:ta=^I:\ :AF=\E[3%dm:AB=\E[4%dm:op=\E[39;49m:sc=\E7:rc=\E8:\ :k1=\E[M:k2=\E[N:k3=\E[O:k4=\E[P:k5=\E[Q:k6=\E[R:k7=\E[S:k8=\E[T:\ :k9=\E[U:k;=\E[V:F1=\E[W:F2=\E[X:K2=\E[E:nw=\E[E:ec=\E[%dX:\ :kb=^H:kh=\E[H:ku=\E[A:kd=\E[B:kl=\E[D:kr=\E[C:le=^H:sf=\E[S:sr=\E[T:\ :kN=\E[G:kP=\E[I:@7=\E[F:kI=\E[L:kD=\177:kB=\E[Z:\ :IC=\E[%d@:DC=\E[%dP:SF=\E[%dS:SR=\E[%dT:AL=\E[%dL:DL=\E[%dM:\ :DO=\E[%dB:LE=\E[%dD:RI=\E[%dC:UP=\E[%dA:cv=\E[%i%dd:ch=\E[%i%d`:\ :mb=\E[5m:md=\E[1m:mr=\E[7m:me=\E[m:bl=^G:\ :ve=\E[=S:vi=\E[=1S:vs=\E[=2S: vt100|dec-vt100|vt100-am|vt100am|dec vt100:\ :do=2\E[B:co#80:li#24:cl=50\E[H\E[J:sf=2*\ED:\ :le=^H:bs:am:cm=5\E[%i%d;%dH:nd=2\E[C:up=2\E[A:\ :ce=3\E[K:cd=50\E[J:so=2\E[7m:se=2\E[m:us=2\E[4m:ue=2\E[m:\ :md=2\E[1m:mr=2\E[7m:mb=2\E[5m:me=2\E[m:\ :is=\E>\E[?1;3;4;5l\E[?7;8h\E[1;24r\E[24;1H:\ :if=/usr/share/tabset/vt100:nw=2\EE:ho=\E[H:\ :as=2\E(0:ae=2\E(B:\ :ac=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||:\ :rs=\E>\E[?1;3;4;5l\E[?7;8h:ks=\E[?1h\E=:ke=\E[?1l\E>:\ :ku=\EOA:kd=\EOB:kr=\EOC:kl=\EOD:kb=\177:\ :k0=\EOy:k1=\EOP:k2=\EOQ:k3=\EOR:k4=\EOS:k5=\EOt:\ :k6=\EOu:k7=\EOv:k8=\EOl:k9=\EOw:k;=\EOx:@8=\EOM:\ :K1=\EOq:K2=\EOr:K3=\EOs:K4=\EOp:K5=\EOn:pt:sr=2*\EM:xn:\ :sc=2\E7:rc=2\E8:cs=5\E[%i%d;%dr:UP=2\E[%dA:DO=2\E[%dB:RI=2\E[%dC:\ :LE=2\E[%dD:ct=2\E[3g:st=2\EH:ta=^I:ms:bl=^G:cr=^M:eo:it#8:\ :RA=\E[?7l:SA=\E[?7h:po=\E[5i:pf=\E[4i: # $XTermId: termcap,v 1.78 2009/11/09 00:24:26 tom Exp $ # xterm|linux|modern xterm:\ :@7=\EOF:@8=\EOM:F1=\E[23~:F2=\E[24~:K2=\EOE:Km=\E[M:\ :k1=\EOP:k2=\EOQ:k3=\EOR:k4=\EOS:k5=\E[15~:k6=\E[17~:\ :k7=\E[18~:k8=\E[19~:k9=\E[20~:k;=\E[21~:kI=\E[2~:\ :kN=\E[6~:kP=\E[5~:kd=\EOB:kh=\EOH:kl=\EOD:kr=\EOC:ku=\EOA:\ :tc=xterm-basic: # # This chunk is used for building the VT220/Sun/PC keyboard variants. xterm-basic|modern xterm common:\ :am:bs:km:mi:ms:ut:xn:AX:\ :Co#8:co#80:kn#12:li#24:pa#64:\ :AB=\E[4%dm:AF=\E[3%dm:AL=\E[%dL:DC=\E[%dP:DL=\E[%dM:\ :DO=\E[%dB:LE=\E[%dD:RI=\E[%dC:UP=\E[%dA:ae=\E(B:al=\E[L:\ :as=\E(0:bl=^G:cd=\E[J:ce=\E[K:cl=\E[H\E[2J:\ :cm=\E[%i%d;%dH:cs=\E[%i%d;%dr:ct=\E[3g:dc=\E[P:dl=\E[M:do=\E[B:\ :ei=\E[4l:ho=\E[H:im=\E[4h:is=\E[!p\E[?3;4l\E[4l\E>:\ :kD=\E[3~:kb=^H:ke=\E[?1l\E>:ks=\E[?1h\E=:le=^H:md=\E[1m:\ :me=\E[m:ml=\El:mr=\E[7m:mu=\Em:nd=\E[C:op=\E[39;49m:\ :rc=\E8:rs=\E[!p\E[?3;4l\E[4l\E>:sc=\E7:se=\E[27m:sf=^J:\ :so=\E[7m:sr=\EM:st=\EH:\ :ue=\E[24m:up=\E[A:us=\E[4m:ve=\E[?12l\E[?25h:vi=\E[?25l:vs=\E[?12;25h: # # This should work for the commonly used "color xterm" variations (XFree86 # xterm, color_xterm, nxterm, rxvt). Note that it does not set 'bce', so for # XFree86 and rxvt, some applications that use colors will be less efficient, # and in a few special cases (with "smart" optimization) the wrong color will # be painted in spots. xterm-color|generic "ANSI" color xterm:\ :Co#8:NC@:pa#64:\ :AB=\E[4%dm:AF=\E[3%dm:ac=:op=\E[m:tc=xterm-r6: ================================================ FILE: lib/libtermlib/termcap/termcap.src ================================================ # ------------------------ # # Termcap source file @(#)termcap.src 5.40.1 (2.11BSD) 1996/10/21 # John Kunze, Berkeley # Craig Leres, Berkeley # # Please mail changes to (arpanet): termcap@berkeley # See DESCRIPTION section for information about contents. # # Copyright (c) 1980 Regents of the University of California. # All rights reserved. The Berkeley software License Agreement # specifies the terms and conditions for redistribution. # # DESCRIPTION: # This file describes capabilities of various terminals, as needed by # software such as screen editors. It does not attempt to describe # printing terminals very well, nor graphics terminals. Someday. # See termcap(5) in the Unix Programmers Manual for documentation. # # Conventions: First entry is two chars, first char is manufacturer, # second char is canonical name for model or mode. # Third entry is the one the editor will print with "set" command. # Last entry is verbose description. # Others are mnemonic synonyms for the terminal. # # Terminal naming conventions: # Terminal names look like - # Certain abbreviations (e.g. c100 for concept100) are also allowed # for upward compatibility. The part to the left of the dash, if a # dash is present, describes the particular hardware of the terminal. # The part to the right can be used for flags indicating special ROM's, # extra memory, particular terminal modes, or user preferences. # All names are always in lower case, for consistency in typing. # # The following are conventionally used flags: # rv Terminal in reverse video mode (black on white) # 2p Has two pages of memory. Likewise 4p, 8p, etc. # w Wide - in 132 column mode. # pp Has a printer port which is used. # na No arrow keys - termcap ignores arrow keys which are # actually there on the terminal, so the user can use # the arrow keys locally. # # There are some cases where the same name is used for two different # terminals, e.g. "teleray" or "2621" or "vt100". In these cases, # if a site has one of these, they should choose a local default and # bring that terminal to the front in the reorder script. This works # because tgetent picks the first match in /etc/termcap. # The list of names intentionally duplicated is: # 2621, c108, dtc, hp2621, teleray, tvi, vt100. # # To easily test a new terminal description, put it in $HOME/.termcap # and programs will look there before looking in /etc/termcap. # You can also setenv TERMPATH to a list of full pathnames (separated # by spaces or colons) to be searched by tgetent() in the order listed. # The TERMCAP environment variable is usually set to the termcap # entry itself to avoid reading files when starting up a program. # # If you absolutely MUST check for a specific terminal (this is discouraged) # check for the 2nd entry (the canonical form) since all other codes are # subject to change. The two letter codes are there for version 6 and are # EXTREMELY subject to change, or even to go away if version 6 becomes for # all practical purposes obsolete. We would much rather put in special # capabilities to describe your terminal rather than having you key on the # name. # # Special manufacturer codes: # A: hardcopy daisy wheel terminals # M: Misc. (with only a few terminals) # q: Homemade # s: special (dialup, etc.) # # Comments in this file begin with # - they cannot appear in the middle # of a termcap entry. Individual entries are commented out by # placing a period between the colon and the capability name. # # This file is to be installed with an editor script (reorder) # that moves the most common terminals to the front of the file. # If the source is not available, it can be constructed by sorting # the above entries by the 2 char initial code. # # -------------------------------- # # A: DAISY WHEEL PRINTERS # # The A manufacturer represents Diablo, DTC, Xerox, Qume, and other Daisy # wheel terminals until such time as termcap distinguishes between them # enough to justify separate codes. # This is an "experimental" entry for the SRI Agiles. # It has been tried in a minimal way -- the Agile did not blow up! # However, it has not been exhaustively tested. # Anyone who tries it and finds it wanting should get in touch with: # Ralph Keirstead (ralph@sri-unix); # EK352; SRI International; 333 Ravenswood Avenue; Menlo Park, CA 94025 Aa|agile|agiles|sri agiles:\ :bs:hc:os:pl:co#132:do=^J:kb=^H:up=\E\n:\ :hu=\E0:hd=\E9:if=/usr/share/tabset/std:is=\EE\EF\EJ: A6|1620|1720|450|ipsi|diablo 1620:\ :do=^J:ct=\E2:st=\E1:ch=\E\t%i%.:\ :if=/usr/share/tabset/xerox1720:\ :kb=^H:le=^H:bs:co#132:hc:hu=\EU:hd=\ED:os:pt:up=\E\n: A7|1620-m8|1640-m8|diablo 1620 w/8 column left margin:\ :do=^J:co#124:is=\r \E9:tc=1620: A8|1640|1740|630|1730|x1700|diablo|xerox|diablo 1640:\ :if=/usr/share/tabset/xerox1730:\ :us=\EE:ue=\ER:so=\EW:se=\E&:tc=1620: Am|1640-lm|1740-lm|630-lm|1730-lm|x1700-lm|diablo-lm|xerox-lm|\ diablo 1640 with idented left margin:\ :if=/usr/share/tabset/xerox1730-lm:\ :co#124:us=\EE:ue=\ER:so=\EW:se=\E&:tc=1620: # DTC 382 with VDU. Has no cd so we fake it with ce. Standout works but # won't go away without dynamite. The terminal has tabs, but I'm getting # tired of fighting the braindamage. If no tab is set or the terminal's # in a bad mood, it glitches the screen around all of memory. Note that # return puts a blank ("a return character") in the space the cursor was # at, so we use ^P return (and thus ^P newline for newline). Note also # that if you turn off pt and let Unix expand tabs, curses won't work # (current version) because it doesn't turn off this bit, and cursor # addressing sends a tab for row/column 9. What a losing terminal! I # have been unable to get tabs set in all 96 lines - it always leaves at # least one line with no tabs in it, and once you tab through that line, # it completely weirds out. Ac|dtc|ps|dtc382|382:\ :do=^J:al=^P^Z:am:le=^H:\ :bs:co#80:ce=^P^U:cl=20^P^]:cm=%r^P^Q%.%.:dc=^X:\ :dl=^P^S:ei=^Pi:ho=^P^R:im=^PI:ve=^Pb:vs=^PB:pc=\177:te=20^P^]:\ :li#24:nd=^PR:.se=^P \200:.so=^P \002^PF:us=^P \020:ue=^P \200:\ :up=^P^L:nc:xr:xs:da:db:.pt:cr=^P^M:cd=^P^U^P^S^P^S:\ :if=/usr/share/tabset/dtc382: Ad|dtc300s|300|300s|dtc 300s:\ :ct=\E3:st=\E1:do=^J:\ :kb=^h:le=^H:bs:co#132:hc:hu=\EH:hd=\Eh:os:pt:up=^Z: Ag|gsi:\ :le=^H:bs:co#132:hc:hd=\Eh:hu=\EH:os:pt:up=^Z:do=^J: # This used to have :pl: - maybe they meant :pt:? Aj|aj830|aj832|aj|anderson jacobson:\ :do=^J:le=^H:bs:hc:hd=\E9:hu=\E8:os:up=\E7: # From Chris Torek Thu, 7 Nov 85 18:21:58 EST AJ|aj510|AJ510|Anderson-Jacobson model 510:\ :ic=:ip=.1*:so=\E"I:us=\E"U:cd=\E'P:ce=\E'L:cl=^L:cm=\E#%+ %+ :\ :dl=2*\E&D:ue=\E"U:co#80:li#24:se=\E"I:al=2*\E&I:im=\E'I:ei=\E'J:\ :dc=.1*\E'D:up=\EY:nd=\EX:bs:am:mi:ti=\E"N:te=\E"N:\ :ku=\EY:kd=\EZ:kl=\EW:kr=\EX:pc=\177: # From cbosg!ucbvax!pur-ee!cincy!chris Thu Aug 20 09:09:18 1981 # This is incomplete, but it's a start. An|5520|nec|spinwriter|nec 5520:\ :ct=\E3:st=\E1:do=^J:kb=^h:le=^H:bs:co#132:hc:hu=\E]s\E9\E]W:\ :hd=\E]s\n\E]W:os:pt:up=\E9: Aq|qume5|qume|Qume Sprint 5:\ :ct=\E3:st=\E1:do=^J:\ :kb=^h:le=^H:bs:co#80:hc:hu=\EH:hd=\Eh:os:pt:up=^Z: Ar|q102|qume102|Qume 102:\ :al=\EE:am:bs:bt=\EI:\ :cd=\EY:ce=\ET:cl=^Z:cm=\E=%+ %+ :co#80:ct=\E3:\ :dc=\EW:dl=\ER:do=^J:ei=:ho=^^:ic=\EQ:im=:\ :k0=^A@\r:k1=^AA\r:k2=^AB\r:k3=^AC\r:kd=^J:kl=^H:kr=^L:ku=^K:\ :le=^H:li#24:ma=^K^P^L :nd=^L:\ :se=\EG0:sg#1:so=\EG4:st=\E1:\ :ue=\EG0:ug#1:up=^K:us=\EG8: # From ucbvax!mtxinu!sybase!tim (Tim Wood) Fri Sep 27 10:25:24 PDT 1985 # This entry supports line and character insert and delete, scroll up and # down and the arrow keys. To use it, perform the following on your qvt-101 # 1) enter SET-UP mode, select the SET 3 line; # 2) move the cursor to the EMULATION item and hit SPACE # until QVT-101B appears # 3) enter SHIFT-S # 4) exit SET-UP - the terminal is now configured Aq|q101|qvt101|qvt-101|Qume 101 $310 special:\ :al=\EE:am:bt=\EI:ce=\Et:cl=\E*:dc=\EW:\ :dl=\ER:do=^J:ic=\EQ:ei=:im=:md=\E(:me=\EG0:mh=\E):\ :le=^H:bs:cm=\E=%+ %+ :cl=1^Z:co#80:ho=^^:li#24:ma=^K^P:nd=^L:ku=^K:\ :vs=\EM4\040\200\200\200:mr=\EG4:ms:so=\EG4:se=\EG1: # I suspect the xerox1720 is the same as the diablo 1620. Ax|x1720|x1700|1700|x1750|xerox 1720:\ :co#132:le=^H:bs:hc:os:pt:do=^J:ct=\E2:st=\E1: # # -------------------------------- # # B: AT&T ATT # # AT&T Teletype 5410 Terminal (a.k.a. 4410) # From: carvalho%kepler@Berkeley.EDU (Marcio de Carvalho) # Date: Thu, 26 Feb 87 09:16:50 PST # # Although the 5410 supports labels, it blanks the screen after # each label is programmed creating to much visual activity. # To use the labels, use FL=\E[%d;00q%-16s # Ba|5410|4410|tty5410|att4410|AT&T Teletype 5410 terminal with 80 columns:\ :al=\E[L:am:bs:cd=\E[J:ce=\E[K:cl=\E[H\E[J:\ :cm=5\E[%i%2;%2H:co#80:dc=\E[P:dl=\E[M:im=:ei=:ic=\E[@:\ :kd=\E[B:kh=\E[H:kl=\E[D:kr=\E[C:ku=\E[A:\ :li#24:nd=\E[C:se=\E[m:so=\E[2;7m:sr=\EM:\ :ue=\E[m:up=\E[A:us=\E[4m:EE=\E[m:BO=\E[0;7m:DS=\E[2m:\ :KM=/usr/share/ua/kmap.5410:is=\E[0m^O\E[?6l:kn#8:\ :k1=\EOc:k2=\EOd:k3=\EOe:k4=\EOf:k4=\EOg:k6=\EOh:\ :k7=\EOi:k8=\EOj:ko=nd,up,ho: # AT&T Teletype 5420 Terminal (a.k.a. 4415) June 5, 1985 Bb|5420|4415|tty5420|att4415|AT&T Teletype 5420 terminal:\ :al=\E[L:am:bs:cd=\E[J:ce=\E[K:cl=\E[H\E[J:\ :cm=\E[%i%2;%2H:co#80:dc=\E[P:dl=\E[M:im=\E[4h:ei=\E[4l:\ :kd=\E[B:kh=\E[H:kl=\E[D:kr=\E[C:ku=\E[A:\ :li#24:nd=\E[C:se=\E[m:so=\E[2;7m:sr=\EM:\ :ue=\E[m:up=\E[A:us=\E[4m:EE=\E[m:BO=\E[0;7m:DS=\E[2m:\ :KM=/usr/share/ua/kmap.5420:\ :is=\E[0m^O\E[1;2;3;4;6l\E[12;13;14;20l\E[?6;97;99l\E[?7h\E[4i\Ex\E[25;1j\212\E[8;0j\E[9;0j\E[10;0j\E[19;1j:\ :db:mi:pt:kn#8:k1=\EOc:k2=\EOd:k3=\EOe:k4=\EOf:k5=\EOg:k6=\EOh:\ :k7=\EOi:k8=\EOj:ve=\E[11;0j:\ :vs=\E[11;1j:ko=bt,nd,up,dc,dl,ho,im,al: # AT&T Teletype 5425 Terminal (a.k.a 4425) June 5, 1985 Bc|5425|4425|tty5425|att4425|AT&T Teletype 5425:\ :FL=\E[%d;00q%-16s\E~:FE=\E|:KM=/usr/share/ua/kmap.5425:\ :is=\E[0m^O\E[1;2;3;4;6l\E[12;13;14;20l\E[?6l\E[?7h\E[4i\E[9;0j\E[10;0j\E[11;0j\E[21;1j\E[25;1j\212:\ :ve=\E[12;0j:vs=\E[12;1j:tc=5420: Bd|t4|4420|tty4420|Teletype 4420:\ :vs=\ER:ve=\ER:am:da:db:mi:cr=\EG:\ :im=:ei=:dm=:ed=:nl=\EG\EB:li#23:\ :co#80:cl=\EH\EJ:cd=\EJ:cm=\EY%+ %+ :\ :bs:up=\E7:do=\EB:nd=\EC:al=\EL:\ :dl=\EM:dc=\EP:ic=\E\136:sf=\EH\EM\EY5 :sr=\ET:kb=^H: Be|pc6300plus|6300|6300plus:\ :al=\E[1L:am:bs:cd=\E[0J:ce=\E[0K:cl=\E[2J\E[H:cm=\E[%i%2;%2H:co#80:\ :dc=\E[1P:dl=\E[1M:do=\E[B:ei=:ho=\E[H:\ :ic=\E[1@:im=:kb=\10:kd=\E[B:kl=\E[D:kr=\E[C:ku=\E[A:li#24:\ :k1=\EOc:k2=\EOd:k3=\EOe:k4=\EOf:k5=\EOg:k6=\EOh:k7=\EOi:k8=\EOj:\ :k9=\EOk:k10=\EOu:nd=\E[C:se=\E[m:so=\E[7m:ue=\E[m:up=\E[A:us=\E[4m:\ :EE=\E[m:BO=\E[0;7m:CV=\E[=C:CI=\E[=1C:KM=/usr/share/ua/kmap.s5: Bf|s4|PC7300|unixpc|pc7300|7300|3b1|Safari 4:\ :so=\E[2;7m:DS=\E[2m:XS=\E[9m:KM=/usr/share/ua/kmap.s4:tc=pc6300plus: # AT&T Teletype 610 Terminal Bg|b610|610|610bct|tty610:\ :CV=\E[25h:CI=\E[25l:KM=/usr/share/ua/kmap.s4:\ :FL=\E[%d;00q%-16s\E[0p:FE=\E[2p:cl=\E[1;1H\E[J:\ :is=\E[0m^O\E[25;1|^J\E[8;0|\E[4;13;20l\E[?5l\E[12h\E[?7h\E[?4i:\ :ve=\E[?12l:vs=\E[?12h:tc=5420: # # -------------------------------- # # C: CONTROL DATA # Ca|cdc456|cdc:\ :do=^J:li#24:co#80:cl=^Y^X:nd=^L:up=^Z:le=^H:bs:\ :cm=\E1%+ %+ :ho=^Y:al=\E\114:dl=\E\112:ce=^V:cd=^X:am: Cc|cdc456tst:\ :do=^J:li#24:co#80:cl=^y^x:le=^H:bs:cm=\E1%+ %+ :am: # # -------------------------------- # # D: DATAMEDIA # D0|dm1520|dm1521|1521|1520|datamedia 1520:\ :do=^J:am:le=^H:bs:cd=^K:ce=^]:cl=^L:cm=^^%r%+ %+ :co#80:ho=^Y:\ :ku=^_:kd=^J:kl=^H:kr=^\:kh=^Y:\ :li#24:nd=^\:up=^_:xn:ma=^\ ^_^P^YH:pt: D2|dm2500|datamedia2500|2500|datamedia 2500:\ :do=^J:al=15^P\n^X^]^X^]:le=^H:bs:ce=^W:cl=^^^^\177:\ :cm=^L%r%n%.%.:co#80:dc=10*^P\b^X^]:dl=10*^P^Z^X^]:\ :dm=^P:ed=^X^]:ei=10\377\377^X^]:ho=^B:ic=10*^P^\^X^]:\ :im=^P:li#24:nc:nd=^\:pc=\377:so@=^N:se=^X^]:up=^Z: D3|dm3025|datamedia 3025a:\ :MT:is=\EQ\EU\EV:do=^J:\ :al=130\EP\n\EQ:le=^H:bs:cd=2\EJ:ce=\EK:cl=2\EM:cm=\EY%r%+ %+ :\ :co#80:dc=6\b:dl=130\EP\EA\EQ:dm=\EP:ed=\EQ:ei=\EQ:ho=\EH:\ :im=\EP:ip=6:li#24:nd=\EC:pt:so=\EO1:se=\EO0:up=\EA: D4|3045|dm3045|datamedia 3045a:\ :is=\EU\EV:do=^J:\ :am:le=^H:bs:cd=2\EJ:ce=\EK:cl=2\EM:cm=\EY%r%+ %+ :co#80:\ :dc=6\EB:dm=:ed=:ei=\EP:ho=\EH:ic=:im=\EP:ip=6:\ :k0=\Ey\r:k1=\Ep\r:k2=\Eq\r:k3=\Er\r:k4=\Es\r:\ :k5=\Et\r:k6=\Eu\r:k7=\Ev\r:k8=\Ew\r:k9=\Ex\r:\ :kh=\EH:ku=\EA:kr=\EC:li#24:nd=\EC:pc=\177:pt:eo:ul:up=\EA:xn: # dt80/1 is a vt100 lookalike, but it doesn't seem to need any padding. D5|dt80|dmdt80|dm80|datamedia dt80/1:\ :do=^J:cd=\E[J:ce=\E[K:cl=\E[2J\E[H:cm=%i\E[%d;%dH:ho=\E[H:\ :nd=\E[C:sr=\EM:so=\E[7m:se=\E[m:up=\E[A:us=\E[4m:ue=\E[m:tc=vt100: # except in 132 column mode, where it needs a little padding. # This is still less padding than the vt100, and you can always turn on # the ^S/^Q handshaking, so you can use vt100 flavors for things like # reverse video. D6|dt80w|dmdt80w|dm80w|datamedia dt80/1 in 132 char mode:\ :do=^J:cd=20\E[0J:co#132:ce=20\E[0K:\ :cm=5\E[%i%d;%dH:cl=50\E[H\E[2J:up=5\E[A:tc=dmdt80: # # -------------------------------- # # H: HAZELTINE # # Since nd is blank, when you want to erase something you # are out of luck. You will have to do ^L's a lot to # redraw the screen. h1000 is untested. It doesn't work in # vi - this terminal is too dumb for even vi. (The code is # there but it isn't debugged for this case.) H1|h1000|hazeltine 1000:\ :le=^H:bs:ho=^K:cl=^L:nd= :co#80:li#12:do=^J: # Note: the h1552 appears to be the first Hazeltine terminal which # is not braindamaged. It has tildes and backprimes and everything! # Be sure the auto lf/cr switch is set to cr. H2|h1552|hazeltine 1552:\ :do=^J:al=\EE:dl=\EO:k1=\EP:l1=blue:k2=\EQ:\ :l2=red:k3=\ER:l3=green:tc=vt52: H3|h1552rv|hazeltine 1552 reverse video:\ :do=^J:so=\ES:se=\ET:tc=h1552: # From cbosg!ucbvax!pur-ee!cincy!chris Thu Aug 20 09:09:18 1981 H4|h1420|hazeltine 1420:\ :do=^J:le=^H:bs:am:li#24:co#80:al=\E^Z:dl=\E^S:cd=\E^X:cl=\E\034:\ :up=\E^L:nd=^P:ce=\E^O:ta=^N:cm=\E^Q%r%.%+ :so=\E\037:se=\E^Y: H5|h1500|hazeltine 1500:\ :do=^J:al=40~^Z:am:le=^H:bs:cd=10~^X:ce=~^O:cl=~^\:cm=~^Q%r%.%.:\ :co#80:dl=40~^S:do=~^K:hz:li#24:nd=^P:.se=~^_:.so=~^Y:up=~^L: # h1510 assumed to be in sane escape mode. Else use h1500. H6|h1510|hazeltine 1510:\ :do=^J:al=\E^Z:am:le=^H:bs:cd=\E^X:ce=\E^O:cl=\E^\:cm=\E^Q%r%.%.:\ :co#80:dl=\E^S:do=\E^K:hz:li#24:nd=^P:.se=\E^_:.so=\E^Y:up=\E^L: H8|h1520|hazeltine 1520:\ :do=^J:al=~^Z:am:le=^H:bs:cd=~^X:ce=~^O:cl=~\034:cm=~^Q%r%.%.\200:\ :co#80:dl=~^S:do=~^K:hz:li#24:nd=^P:se=~^Y:so=~\037:up=~^L:ho=~^R: # Note: h2000 won't work well because of a clash between upper case and ~'s. H7|h2000|hazeltine 2000:\ :do=^J:al=6~^z:am:le=^H:bs:cl=6~^\:cm=~^q%r%.%.:co#74:\ :dl=6~^s:ho=~^r:li#27:nc:pc=\177: # Hazeltine esprit entries from Univ of Utah Tue Feb 1 06:39:37 1983 # J.Lepreau, lepreau@utah-cs, harpo!utah-cs!lepreau HE|esprit|hazeltine esprit:\ :al=40\E^Z:bs:cd=5\E^X:ce=\E^O:cl=\E^\:cm=\E^Q%r%>^^ %+`%+`:co#80:\ :dl=40\E^S:do=\E^K:ho=\E^R:li#24:nd=^P:se=\E^Y:so=\E^_:up=\E^L: HF|esprit-am|hazeltine esprit auto-margin:\ :am:tc=esprit: # # -------------------------------- # # I: IBM # # ibm61 and ibm63 from Warren Gish (cswarren@violet.berkeley.edu). # installed 12-17-86. # 3161 only opens a new line if a null line exists on the screen. # To ensure a null line exists, an SBA is performed, positioning the # Buffer Address in column 0 of the last line. The last line is then # cleared to nulls, BA mode is cancelled, and the new line is opened # at the cursor position. I1|ibm61|ibm3161|3161|IBM 3161-11:\ :am:bs:bw:cl=\EL:li#24:co#80:cd=\EJ:al=\EX7 \EI\E Z\EN:\ :ce=\EI:cm=\EY%+\040%+\040:nd=\EC:up=\EA:do=\EB:\ :dl=\EO:dc=\EQ:kd=\EB:ku=\EA:kl=\ED:kr=\EC:kh=\EH:\ :us=\E4\102:ue=\E4\100:so=\E4\110:se=\E4\100: I3|ibm63|ibm3163|3163|i3163|IBM 3163:\ :tc=ibm61: I4|ibm|ibm3101|3101|i3101|IBM 3101-10:\ :do=^J:ct=\EH:st=\E0:\ :if=/usr/share/tabset/ibm3101:\ :am:le=^H:bs:cl=\EK:li#24:co#80:nd=\EC:up=\EA:cd=\EJ:ce=\EI:\ :kd=\EB:kl=\ED:kr=\EC:ku=\EA:ho=\EH:cm=\EY%+\40%+\40:pt: Ia|ibm-apl|apl|IBM apl terminal simulator:\ :li#25:tc=dm1520: # ibmapa* and ibmmono entries come from ACIS 4.3 distribution Ib|rtpc|ibmapa16|ibm6155|IBM 6155 Extended Monochrome Graphics Display:\ :ts=\Ej\EY@%+ \Eo:ds=\Ej\EY@\40\EI\Ek:li#32:tc=ibmconsole: # Advanced Monochrome (6153) and Color (6154) Graphics Display: Ic|ibmapa8c|ibmapa8|ibm6154|ibm6153|IBM 6153/4 Advanced Graphics Display:\ :ts=\Ej\EY?%+ \Eo:ds=\Ej\EY?\40\EI\Ek:li#31:tc=ibmconsole: Id|ibmapa8c-c|ibm6154-c|IBM 6154 Advanced Color Graphics Display color termcap:\ :ts=\Ej\EY?%+ \Eo:ds=\Ej\EY?\40\EI\Ek:li#31:mh=\EF\Ef7;:tc=ibmega-c: Ie|ibmmono|ibmconsole|ibm5151|IBM workstation monochrome:\ :se=\Ez:so=\EZ:sr=\EA:al=\EL:dl=\EM:\ :kb=^H:us=\EW:ue=\Ew:\ :k1=\ES:k2=\ET:k3=\EU:k4=\EV:k5=\EW:k6=\EP:k7=\EQ:k8=\ER:k9=\EY:\ :k0=\E<:I0=f10:kI=\000:kh=\EH:kR=\EG:kP=\Eg:kF=\EE:kN=\EE:\ :md=\EZ:me=\Ew\Eq\Ez\EB:mk=\EF\Ef0;\Eb0;:mr=\Ep:\ :ts=\Ej\EY8%+ \Eo:fs=\Ek:ds=\Ej\EY8\40\EI\Ek:es:hs:sb:tc=ibm3101: If|ibmega-c|ibm5154-c|IBM Enhanced Color Display color termcap:\ :se=\EB:so=\EF\Ef3;:ue=\EB:us=\EF\Ef2;:tc=ibmconsole: # # -------------------------------- # # M: MISCELLANEOUS TERMINALS # # The tab 132 uses xon/xoff, so no padding needed. # ks/ke have nothing to do with arrow keys. # is sets 80 col mode, normal video, autowrap on (for am). # Seems to be no way to get rid of status line. M0|abm80|amtek business machines 80:\ :do=^J:al=\E^Z:am:le=^H:bs:cd=\E^X:ce=\E^O:cl=\E^\:cm=\E^Q%r%+ %+ :\ :co#80:dl=\E^S:do=\E^K:li#24:nd=^P:.so=\E^_:.se=\E^Y:up=\E^L:\ :bw:bt=^T:ho=\E^R: M1|tab132|tab|tab132/15|tab 132/15:\ :is=\E[?7h\E[?3l\E[?5l:dN@:ks@:ke@:do=^J:\ :da:db:al=\E[L:dl=\E[M:dc=\E[P:ei=\E[4l:im=\E[4h:cm=\E[%i%d;%dH:\ :ku=\E[A:kd=\E[B:kl=\E[D:tc=vt100: M2|tab132w:\ :co#132:is=\E[?7h\E[?3h\E[?5l:tc=tab132: M3|tab132rv:\ :is=\E[?7h\E[?3l\E[?5h:tc=tab132: M4|tab132wrv:\ :is=\E[?7h\E[?3h\E[?5h:tc=tab132w: # This used to say "de#001202" which presumably refers to the stty bits # that need to be set for some version of Unix. We need the real delay # requirements in MS. M5|mw2|Multiwriter 2:\ :do=^J:co#132:hc:os: M6|trs80|trs-80|radio shack trs-80 Model I:\ :do=^J:am:le=^H:bs:co#64:li#16: M7|d800|Direct 800/A:\ :do=^J:co#80:li#24:am:cl=\E[1;1H\E[2J:le=^H:bs:cm=\E[%i%d;%dH:\ :nd=\E[C:up=\E[A:ce=\E[K:cd=\E[J:\ :so=\E[7m:se=\E[0m:us=\E[4m:ue=\E[0m:xs:vs=\E[>12l:ve=\E[>12h:\ :sf=\ED:sr=\EM:da:db:as=\E[1m:ae=\E[0m:ms:pt:\ :kl=\E[D:kr=\E[C:ku=\E[A:kd=\E[B:\ :k1=\EOP:k2=\EOQ:k3=\EOR:k4=\EOS:\ :k5=\EOT:k6=\EOU:k7=\EOV:k8=\EOW: M8|vc404|volker-craig 404:\ :do=^J:am:le=^H:bs:cd=40^W:ce=20^V:cl=40^X:cm=^P%+ %+ :co#80:\ :ho=40^Y:kd=^J:kl=^H:kr=^U:ku=^Z:li#24:ma=^Z^P^U :nd=^U:up=^Z: M9|vc404-s|volker-craig 404 w/standout mode:\ :do=^J:se=^O:so=^N:tc=vc404: MA|vc404-na|volker-craig 404 w/no arrow keys:\ :ma@:kr@:ku@:tc=vc404: MB|vc404-s-na|volker-craig 404 w/standout mode and no arrow keys:\ :se=^O:so=^N:tc=vc404-na: # missing in vc303a and vc303 descriptions: they scroll 2 lines at a time MC|vc303a|vc403a|volker-craig 303a:\ :do=^J:am:le=^H:bs:ce=20^V:cl=40^X:co#80:ho=40^Y:kd=^J:kl=^H::kr=^U:\ :ku=^Z:li#24:ll=^P^@W:nd=^U:ns:up=^Z: MD|vc303|vc103|vc203|volker-craig 303:\ :do=^J:am:le=^H:bs:cl=40^L:co#80:ho=40^K:kd=^J:kl=^H:\ :kr=^I:ku=^N:li#24:ll=^O\200W:nd=^I:ns:up=^N: # Test version for Falco ts-1. See "arpavax.hickman@ucb" for info ME|falco|ts1|ts-1|falco ts-1:is=\Eu\E3:\ :do=^J:al=\EE:am:bs:ce=\ET\EG0^h:cm=\E=%+ %+ :cl=\E*:cd=\EY:co#80:\ :dc=\EW:dl=\ER:ei=\Er:ho=^^:im=\Eq:k0=^A0\r:kd=^J:kl=^H:pt:\ :kr=^L:ku=^K:li#24:nd=^L:se=\Eg0:so=\Eg1:up=^K:us=\Eg1:ue=\Eg0: MF|falco-p|falco ts-1sp|falco with paging option:\ :is=\EZ\E3\E_c:\ :al=\EE:am:bs:ce=\ET\EG0^H\Eg0:cl=\E*:cd=\EY:co#80:dc=\EW:\ :dl=\ER:kd=\E[B:kl=\E[D:ei=\Er:im=\Eq:pt:db:\ :kr=\E[C:ku=\E[A:li#24:nd=\E[C:se=\Eg0:so=\Eg4:\ :up=\E[A:us=\Eg1:ti=\E_d:te=\E_b:\ :ue=\Eg0:do=\E[B:cm=\E=%+ %+ :ms:kh=\E[H:da:mi:bt=\EI: #NOTE: bg can scroll, it just would rather not (ns) - rwells 3/13/81. # (Shouldn't you take out ns and put in an nl instead? - mrh) MG|bg|bitgraph|BBN BitGraph terminal:\ :do=^J:al=2*\E[L:bs:cd=150\E[J:ce=2\E[K:\ :cl=150\E[H\E[J:cm=%i\E[%d;%dH:co#85:\ :dl=2*\E[M:k0=\EP:k1=\EQ:k2=\ER:k3=\ES:kd=\EB:ke=\E>:kl=\ED:kr=\EC:\ :ks=\E=:ku=\EA:li#64:nd=\E[C:ns:pt:se=\E[0m:so=\E[7m:up=\E[A:sf=280\n: MH|d132|datagraphix|datagraphix 132a:\ :do=^J:co#80:li#30:cl=^l:ho=\Et:da:db:sf=\Ev:sr=\Ew:\ :up=\Ek:nd=\El:vs=\ex:ve=\Em\En:\ :al=\E3:ic=\E5:dc=\E6:in:ic=\E5: MI|soroc|Soroc 120:\ :do=^J:cd=\EY:ce=\ET:cl=2\E*:ma=^K^P^R^L^L :\ :kl=^H:ku=^K:kr=^L:kd=^J:tc=adm3a: # From: ma179abu%sdcc3@sdcsvax.ucsd.edu (Bill Houle) MI|iq140|soroc140|Soroc IQ140 with inverse & dim:\ :ic=\EQ:dc=\EW:al=\EE:dl=\ER:ce=\ET:cd=\EY:cl=\E+:cm=\E=%+ %+ :\ :up=^K:do=^J:le=^H:nd=^L:ho=^^:ta=\Ei:ma=^Kk^Jj^Hh^Ll^^h:am:bs:\ :co#80:li#24:ei=:im=:kb=^H:kh=^^:ku=^K:kd=^J:kl=^H:kr=^L:\ :k0=^AI:k1=^A@:k2=^AA:k3=^AB:k4=^AC:k5=^AD:k6=^AE:k7=^AF:\ :k8=^AG:k9=^AH:se=\E:so=\E:us=\E):ue=\E(: # tec is untested, and taken from CB/Unix virtual terminal driver. # Upper case terminal, uses lower case for control sequences!!! # The driver shows the C ~ operator used on CM coordinates. # Without the terminal in front of me, I can't figure out what's # going on, so I've dotted out the cm. Note there is no ~ in tgoto. MJ|tec400|tec scope:\ :do=^J:.cm=l%r%.%.:up=x:do=h:nd=g:le=w:ho=i:so={:se=|:sg#1:\ :cl=f:al=e:dl=u:ic=d:dc=t:ce=c:cd=s: # From ucbvax!geoff Mon Sep 21 21:15:45 1981 # This entry has been tested. MK|tec500|tec 500:\ :do=^J:am:le=^H:bs:cm=\E=%+ %+ :cl=20^Z:\ :co#80:ho=^^:li#24:nd=^L:up=^K:so=^]:se=^\: # I would appreciate more information on this terminal, such as the # manufacturer and the model number. There are too many tecs in here. ML|tec:\ :li#24:co#80:cl=^l:up=^k:nd=\037:\ :am:le=^H:bs:ho=\036:ma=^K^P^_ :do=^J: MM|teletec|Teletec Datascreen:\ :do=^J:am:le=^H:bs:co#80:cl=^l:ho=^^:li#24:nd=^_:up=^k: # From cbosg!ucbvax!SRC:george Fri Sep 11 22:38:32 1981 MN|ampex|d80|dialogue|dialogue80|ampex dialogue 80:\ :ct=\E3:st=\E1:do=^J:is=\EA:us=\El:ue=\Em:\ :am:le=^H:bs:pt:cl=75\E*:cm=\E=%+ %+ :\ :al=5*\EE:bt=\EI:ic=\EQ:im=:ei=:dl=5*\ER:dc=\EW:\ :ce=\Et:cd=\Ey:so=\Ej:se=\Ek:li#24:co#80:nd=^L:up=^K: # From: atd!dsd!rcb@ucbvax.berkeley.edu (Richard Bascove) A2|a210|210|ampex210|ampex a210:\ :am:bs:cl=\E*:cm=\E=%+ %+ :al=\EE:bt=\EI:ic=\EQ:im=:ei=:\ :dl=\ER:dc=\EW:ho=^^:xn:ce=\Et:cd=\Ey:li#24:co#80:nd=^L:up=^K:\ :pt:if=/usr/share/tabset/std:is=\EC\Eu\E'\E(\El\EA\E%\E{\E.2\EG0\Ed\En:\ :kl=^H:kr=^L:kd=^V:ku=^K:kh=^^:hs:ts=\E.0\Eg\E}\Ef:fs=\E.2:\ :kn#10:k0=^A0^M:k1=^A1^M:k2=^A2^M:k3=^A3^M:k4=^A4^M:k5=^A5^M:\ :vb=\EU\EX\EU\EX\EU\EX\EU\EX:k6=^A6^M:k7=^A7^M:k8=^A8^M:k9=^A9^M:\ :so=\EG4:se=\EG0:us=\EG8:ue=\EG0:ug#1:sg#1: MO|digilog|333|digilog 333:\ :le=^H:bs:co#80:ce=\030:ho=^n:li#16:nd=^i:up=^o:do=^J: MP|ep48|ep4080|execuport 4080:\ :am:le=^H:bs:os:co#80:hu=\036:hd=\034:do=^J: MQ|ep40|ep4000|execuport 4000:\ :am:le=^H:bs:os:co#136:hu=\036:hd=\034:do=^J: MR|terminet1200|terminet300|tn1200|tn300|terminet|GE terminet 1200:\ :co#120:hc:os:do=^J: # AED 512 # by giles Billingsley (gilesb%ucbcad@berkeley) # rewritten 8/82 for newer AEDs and better operation of vi,etc. MS|aed|AED|aed512|AED512|aed 512:\ :db:co#64:li#40:cl=^L:bs:nd=\Ei0800\001:\ :up=^K:ve=\E\E\E\E\E\E\E\072004=000200??\001:\ :vb=\EK0001??0000K0001202080\001:\ :us=\E\07200>8000140\001:ue=\E\07200>8000100\001:\ :uc=\Ei???>l0800i0102\001:\ :ti=\E\07200>8000140{<04<0??00001010L<0\072004=0002??00\001:\ :te=\E\07200>8000100{804<0??00001000L80\072004=000200??\001:\ :so=\E\07200>8000140[80C00\001:se=\E[00C80\001:\ :is=\EG1MMM.`40K0001202080K8001????00^L\EC80L80{80^L\EK010100????K060\ 1??0000c818100\EG1HHH.\07210000019A27FD006A280D002A200A52429FE852486108611861\ 2861360N031B4C3F3F1800N041B0C1B4C38301800N001B3B313030301800N011B3B3130303418\ 00N021B3B313030381800N050800N061B3B313335301800\07211000015A58E8D5011A58F8D51\ 11A5908D5211A5918D531160\07212000015AD5011858EAD5111858FAD52118590AD531185916\ 0\0721300004B2071C5858E0A18658E0A0A858EA900858F268FA5278590A50A29018591A9F518\ 65908590A90165918591A59038E58E8590A591E58F290185912071C5180A0A0A0901858EA9008\ 58F268F60\0721350000BA9472031DEA9502031DE60\E\E\E\EG1MMM.^A: zL|aed-ucb|AED-UCB|aed512-ucb|AED512-UCB|aed 512 w/o UCB ROM:\ :db:co#64:li#40:cl=^L:bs:nd=\Ei0800\001:up=^K:\ :ve=\E\E\E\E\E\E\E\072004=000200??\001:\ :vb=\EK0001??0000K0001202080\001:\ :us=\E\07200>8000140\001:ue=\E\07200>8000100\001:\ :uc=\Ei???>l0800i0102\001:\ :ti=\E\07200>8000140{<04<0??00001010L<0\072004=0002??00\001:\ :te=\E\07200>8000100{804<0??00001000L80\072004=000200??\001:\ :so=\E\07200>8000140[80C00\001:se=\E[00C80\001:\ :if=/usr/share/tabset/aed512: # CIT 80 - vt 100 emulator, the termcap has been modified to remove # the delay times and do an auto tab set rather than the indirect # file used in vt100. MT|cit80|cit 80|Citoh 80:\ :co#80:li#24:am:cl=\E[;H\EJ:bs:cm=\E[%i%2;%2H:nd=\E[C:up=\E[A:\ :ce=\EK:cd=\EJ:is=\E>:ks=\E[?1h\E=:ke=\E[?1l\E>:\ :ku=\EOA:kd=\EOB:kr=\EOC:kl=\EOD: # From mtxinu!sybase!tim (Tim Wood) Fri Sep 27 09:39:12 PDT 1985 # Alternate cit101 (vt100 em) file used in vt100. # Uses 23 lines so can run citsys (like h19sys). # 24 May 85 (mtxinu!sybase!tim) - removed 2-byte limit on 'cm' cursor # coordinates otherwise there is garbling on long lines in # co#132 mode; also added support for multipage memory on the Itoh. MU|citc|Citoh fast vt100:\ :co#80:li#23:am:cl=\E[;H\E[2J:bs:cm=\E[%i%d;%dH:nd=\E[C:up=\E[A:\ :ce=\E[K:cd=\E[J:so=\E[7m:se=\E[m:us=\E[4m:ue=\E[m:\ :is=\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h\E[3g\E[>5g:\ :ks=\E[?1h\E=:ke=\E[?1l\E>:ku=\EOA:kd=\EOB:kr=\EOC:kl=\EOD:\ :vb=\E[?5h\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\E[?5l:\ :dc=\E[P:al=\E[L:im=:ei=:dl=\E[M:ic=\E[@:vs=\E7\E[U:ve=\E[V\E8:xn: MV|cita|:\ :co#80:li#23:am:cl=\E[;H\E[2J:bs:cm=\E[%i%d;%dH:nd=\E[C:up=\E[A:\ :ce=\E[K:cd=\E[J:so=\E[7m:se=\E[m:us=\E[4m:ue=\E[m:\ :is=\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h\E[3g\E[>5g:\ :ks=\E[?1h\E=:ke=\E[?1l\E>:\ :ku=\EOA:kd=\EOB:kr=\EOC:kl=\EOD:vs=\E7\E[U:ve=\E[V\E8:\ :vb=\E[?5h\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\E[?5l:xn: MW|cit101:li#24:vb@:tc=citc MX|cit101b:li#24:tc=citc Mh|cit500|cit-500|cit 500:\ :co#80:li#40:cl=50\E[;H\E[2J:bs:am:cm=5\E[%i%2;%2H:nd=2\E[C:up=2\E[A:\ :ce=3\E[K:cd=50\E[J:so=2\E[7m:se=2\E[m:us=2\E[4m:ue=2\E[m:\ :is=\E(B\E)0\E>\E[?3l\E[?7h\E[?8h:ks=\E[?1h\E=:ke=\E[?1l\E>:\ :if=/usr/share/tabset/vt100:ku=\EOA:kd=\EOB:kr=\EOC:kl=\EOD:\ :kh=\E[H:k1=\EOP:k2=\EOQ:k3=\EOR:k4=\EOS:pt:sr=5\EM:xn:\ :do=\ED:al=\E[L:dc=\E[P:dl=\E[M: # Note several versions of blit. I don't know exactly what is what # so please send me any corrections to this -- mrh # From research!ikeya!rob Tue Aug 31 23:41 EDT 1982 MY|blit|jerq|blit-pb|blit running teletype rom:\ :do=^J:IC=\Ef%+ :DC=\Ee%+ :AL=\EF%+ :DL=\EE%+ :\ :mi:dl=\EE!:ic=\Ef!:dc=\Ee!:al=\EF!:\ :ce=\EK:cl=^L:cm=\EY%r%+ %+ :co#87:li#72:nd=\EC:\ :up=\EA:ku=\EA:kd=\EB:kr=\EC:kl=\ED:kb=^H:am:ul:pt:eo: MZ|cbblit|columbus enhanced tty blit:\ :vb=\E^G:so=\EU!:se=\EV!:us=\EU":ue=\EV":cd=\EJ:\ :im=\EQ:ei=\ER:ic@:co#88:sf=\EG:tc=blit: Ma|oblit|ojerq|first version of blit rom:\ :do=^J:AL=\Ef%+ :DL=\Ee%+ :mi:dl=\EE:ei=\ER:im=\EQ:dc=\EO:da:db:\ :al=\EF:cd=\EJ:ce=\EK:cl=^L:cm=\EY%r%+ %+ :co#88:li#72:nd=\EC:\ :up=\EA:vb=\E^G:am:ul:pt:eo: Mb|daleblit|daleterm|blit running Dale DeJager's ROM:\ :ku=\EA:kd=\EB:kr=\EC:kl=\ED:so=\EU!:se=\EV!:us=\EU":ue=\EV":\ :da@:db@:tc=oblit: Mc|datapoint|dp3|dp3360|datapoint 3360:\ :do=^J:am:le=^H:bs:cd=^_:ce=^^:cl=^]^_:co#82:ho=^]:li#25:nd=^x:up=^z: #From: cbosgd!utcs!romwa@ucbvax.berkeley.edu (mark dornfeld) # This termcap is for the LANPAR Technologies VISION 3220 # terminal. The function key definitions k0-k5 represent the # edit keypad: FIND, INSERT HERE, REMOVE, SELECT, PREV SCREEN, # NEXT SCREEN. The key definitions k6-k9 represent the PF1 to # PF4 keys. v0|v3220|LANPAR Vision II model 3220/3221/3222:\ :co#80:li#24:cl=\E[H\E[J:bs:am:cm=\E[%i%d;%dH:nd=\E[C:up=\E[A:\ :ce=\E[K:cd=\E[J:so=\E[7m:se=\E[m:us=\E[4m:ue=\E[m:\ :is=\E>\E[?3l\E[?7h\E[?8h\E[p:ks=\E=:ke=\E>:\ :kn#10:k0=\E[1~:k1=\E[2~:k2=\E[3~:k3=\E[4~:k4=\E[5~:k5=\E[6~:\ :k6=\E[OP:k7=\E[OQ:k8=\E[OR:k9=\E[OS:\ :ku=\E[A:kd=\E[B:kr=\E[C:kl=\E[D:\ :kh=\E[H:pt:sr=\EM:xn:\ :dl=\E[M:dc=\E[P:ei=\E[4l:al=\E[L:im=\E[4h:mi: # From ucbvax!faletti (Faletti@Berkeley) # FREEDOM 100 by Liberty Electronics USA, SF. # :kh=^^: left out because it precludes using change-to-alternate-file in vi. # Basic Freedom 100 entry, works with VI at 1200 baud. Md|f100|freedom100|freedom|freedom 100 no padding:\ :am:bs:bw:mi:ms:pt:co#80:kn#20:li#24:\ :ct=\E3:st=\E1:is=\Eg\Ef\r\Ed:kr=^L:\ :cl=^Z:do=^J:ho=^^:kb=^H:kl=^H:\:kd=^V:\ :ko=dc,al,dl,cl,bt,ce,cd:ku=^K:le=^H:nd=^L:\ :ch=\E]%+ :cm=\E=%+ %+ :cv=\E[%+ :sr=\Ej:up=^K:\ :al=\EE:bt=\EI:cd=\EY:ce=\ET:dc=\EW:dl=\ER:ei=\Er:im=\Eq:\ :se=\EG0:so=\EG4:ue=\EG0:us=\EG8:as=\E$:ae=\E%:\ :vb=\Eb\200\200\Ed:\ :k1=^A@\r:k2=^AA\r:k3=^AB\r:k4=^AC\r:k5=^AD\r:\ :k6=^AE\r:k7=^AF\r:k8=^AG\r:k9=^AH\r:k0=^AI\r:\ :hs:ts=\Eg\Ef:fs=\r:ds=\Eg\Ef\r: Me|f100-rv|freedom100-rv|freedom-rv|freedom100 with reverse video at 1200:\ :is=\Eg\Ef\r\Eb:vb=\Ed\200\200\Eb:tc=freedom100: # VI at 9600 baud (or EMACS at 1200 -- but may be more than is needed for emacs) Mf|f100-v|freedom100-v|freedom-v|freedom100 for 9600 vi or 1200 emacs:\ :al=6.5*\EE:dl=11.5*\ER:\ :vb=\Eb\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\Ed:\ :tc=freedom100: Mx|f100-v-rv|freedom100-v-rv|freedom-v-rv|freedom100 rev. vid. for 9600 vi:\ :al=6.5*\EE:dl=11.5*\ER:is=\Eg\Ef\r\Eb:\ :vb=\Ed\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\Eb:\ :tc=freedom100: # EMACS at 9600 baud -- this still needs some more work on the padding My|f100-e|freedom100-e|freedom-e|freedom100 for 9600 emacs:\ :al=8.5*\EE:dl=11.5*\ER:ip=6:\ :vb=\Eb\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\Ed:\ :tc=freedom100: Mz|f100-e-rv|freedom100-e-rv|freedom-e-rv|freedom100 rev. vid. for emacs 9600:\ :al=8.5*\EE:dl=11.5*\ER:ip=6:is=\Eg\Ef\r\Eb:\ :vb=\Ed\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\Eb:\ :tc=freedom100: zM|f110-v|freedom110-v|freedom110 for 9600 vi or 1200 emacs:\ :is=\Eg\Ef\r\Ed\EO:dc=\EO\EW:im=\EO\Eq:\ :al=6.5*\EE:dl=11.5*\ER:\ :vb=\Eb\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\Ed:\ :tc=freedom100: # (from kerch@lll-crg) Q1|f200|freedom200| Freedom 200 VDT by Liberty Electronics :\ :if=/usr/share/tabset/stdcrt:al=\EE:am:bs:bt=\EI:cd=\EY:\ :ce=\ET:cl=^Z:cm=\E=%+ %+ :co#80:dc=\EW:dl=\ER:do=^V:\ :ds=\Eh:ei=\Er:im=\Eq:is=\Eg\El\E\041\062:\ :k1=^A@\r:k2=^AA\r:k3=^AB\r:k4=^AC\r:k5=^AD\r:\ :k6=^AE\r:k7=^AE\r:k8=^AF\r:k9=^AG\r:kd=^V:kr=L:\ :ku=^K:li#24:ms:nd=^L:se=\EG0:so=\EG4:sr=\Ej:\ :te=\EJ\E\\2\E|\041\061^L^Y:ti=\E\\1\EK\E|\041\061L^Y:\ :ts=\Ef:ue=\EG0:up=^K:us=\EG8:vb=\Eb\Ed:hs:i2=\E^O\Eg:\ :ts=\Ef:fs=^M:ds=\E^N: Mg|dg|dg6053|data general 6053:\ :do=^J:am:le=^H:bs:cm=^P%r%.%.:cl=^L:ho=^H:nd=^S:\ :up=^W:ce=^K:co#80:li#24: # dg450 and dg200 from cornell Mj|dg450|dg6134|data general 6134:\ :nd=\030:bs@:tc=dg200: Mk|dg200|data general Dasher 200:\ :am:bc=^Y:bs=0:ce=^K:cl=^L:cm=^P%r%+\200%+\200:co#80:do=^Z:\ :ho=^H:li#24:\ :ll=\036FP0017:se=\036E:so=\036D:up=^W:\ :is=\036O\036FQ2\036FB000\036FE\036FA\036FQ2: # Note: lesser Dasher terminals will not work with vi because vi insists upon # having a command to move straight down from any position on the bottom line # and scroll the screen up, or a direct vertical scroll command. The 460 and # above have both, the D210/211, for instance, has neither. We must use ANSI # mode rather than DG mode because standard UNIX tty drivers assume that ^H is # backspace on all terminals. This is not so in DG mode. zF|dg460-ansi|Data General Dasher 460, ANSI-mode:\ :al=\E[L:am:bs:cd=\E[J:ce=\E[K:cl=\E[2J:\ :cm=\E[%i%2;%2H:co#80:dc=\E[P:dl=\E[M:do=\E[B:\ :ei=:ho=\E[H:ic=\E[@:im=:ue=\E[05:ul:up=\E[A:us=\E[4m:is=\036F@:\ :k0=\E[001z:k1=\E[002z:k2=\E[003z:k3=\E[004z:k4=\E[005z:k5=\E[006z:\ :k6=\E[007z:k7=\E[008z:k8=\E[009z:k9=\E[00\:z:\ :kb=\E[D:kd=\E[B:kh=\E[H:kl=\E[D:kr=\E[C:ku=\E[A:kn#6:\ :l0=f1:l1=f2:l2=f3:l3=f4:l4=f5:l5=f6:l6=f7:l7=f8:l9=f10:\ :le=^H:li#24:mb=\E[5m:me=\E[0m:mh=\E[2m:mr=\E[7m:ms:mu=\EW:\ :nd=\E[C:nl=\ED:pt:se=\E[0m:sf=\E[S:so=\E[7m:sr=\E[T: Mi|cdi|cdi1203:\ :am:le=^H:bs:hc:os:co#80:dC#200:do=^J: # ^S is an arrow key! Boy is this guy in for a surprise on v7! Ml|sol:\ :do=^J:am:le=^Y:ho=^H:bs:cm=\E^1%.\E^2%.:cl=^K:ho=^N:co#64:li#16:\ :nd=^S:up=^W:kl=^A:kr=^S:ku=^W:kd=^Z:ma=^A^H^S ^W^P^Z^N: Mn|xl83|Cybernex XL-83:\ :do=^J:am:le=^H:bs:cd=62^P:ce=3^O:cl=62^L:cm=^W%+ %+ :co#80:ho=^K:\ :kd=^J:kl=^H:ku=^N:li#24:up=^N:nd=^I: Mo|omron|Omron 8025AG:\ :do=^J:al=\EL:am:le=^H:bs:cd=\ER:co#80:ce=\EK:cl=\EJ:\ :da:db:dc=\EP:dl=\EM:ho=\EH:li#24:nd=\EC:se=\E4:sf=\ES:\ :so=\Ef:sr=\ET:up=\EA:ve=:vs=\EN: Mp|plasma|plasma panel:\ :am:le=^H:bs:cl=^L:co#85:ho=^^:li#45:nd=\030:up=\026:do=^J: Mq|pty|psuedo teletype:\ :do=^J:co#80:li#24:am:cl=\EJ:le=^H:bs:cm=\EG%+ %+ :nd=\EC:\ :up=\EA:ce=\EK:cd=\EL:al=\EP:dl=\EN:ic=\EO:\ :so=\Ea$:se=\Eb$:us=\Ea!:ue=\Eb!: Mr|remote|virtual remote terminal:\ :co#79:am@:nl@:tc=virtual: Ms|swtp|ct82|southwest technical products ct82:\ :do=^J:am:le=^d:bc=^d:\ :al=^\^y:cd=^v:ce=^F:cl=^L:cm=%r^k%.%.:co#82:li#20:\ :dl=^z:nd=^s:up=^a:so=^^^v:se=^^^F:dc=^\^h:ic=^\^x:ho=^p:\ :ei=:sf=^n:sr=^o:ll=^c:im=:\ :is=^\^r^^^s^^^d^]^w^i^s^^^]^^^o^]^w^r^i: Mt|terak|Terak emulating Datamedia 1520:\ :tc=dm1520: Mu|sun|Sun Microsystems Workstation console:\ :li#34:co#80:cl=^L:cm=\E[%i%d;%dH:nd=\E[C:up=\E[A:\ :am:bs:mi:ms:pt:\ :ce=\E[K:cd=\E[J:so=\E[7m:se=\E[m:\ :kd=\E[B:kl=\E[D:ku=\E[A:kr=\E[C:kh=\E[H:\ :k1=\EOP:k2=\EOQ:k3=\EOR:k4=\EOS:\ :al=\E[L:dl=\E[M:im=:ei=:ic=\E[@:dc=\E[P:\ :AL=\E[%dL:DL=\E[%dM: # From john@ucbrenoir Tue Sep 24 13:14:44 1985 Mu|sun-s|Sun Microsystems Workstation window with status line:\ :hs:ts=\E]l:fs=\E\\:ds=\E]l\E\\:tc=sun: Mu|sun-e-s|sun-s-e|Sun Microsystems Workstation with status hacked for emacs:\ :hs:ts=\E]l:fs=\E\\:ds=\E]l\E\\:tc=sun-e: M0|sun-48|Sun 48-line window:\ :li#48:co#80:tc=sun: M1|sun-34|Sun 34-line window:\ :li#34:co#80:tc=sun: M2|sun-24|Sun 24-line window:\ :li#24:co#80:tc=sun: M3|sun-17|Sun 17-line window:\ :li#17:co#80:tc=sun: M4|sun-12|Sun 12-line window:\ :li#12:co#80:tc=sun: M5|sun-1|Sun 1-line window for sysline:\ :li#1:co#80:es:hs:ts=\r:fs=\E[K:ds=^L:tc=sun: M6|sun-e|sun-nic|sune|Sun Microsystems Workstation without insert character:\ :ic@:im@:ei@:tc=sun: LS|apollo:\ :al=\EI:am:bs:cd=\EJ:ce=\EK:ch=\EN%d:cl=^L:cm=\EM%+ %d):\ :cv=\EO+ :dc=\EP:dl=\EL:do=\EB:ei=\ER:im=\EQ:mi:nd=\EC:se=\ET:sf=\EE:\ :so=\ES:sr=\ED:te=\EX:ti=\EW:ue=\EV:up=\EA:us=\EU:co#88:li#53: # Apollo termcaps from Gary Darland, goodmanc@garnet LP|apollo_15P|apollo 15 inch display:\ :dN@:tc=vt132: LQ|apollo_19L|apollo 19 inch display:\ :dN@:tc=vt132: LR|apollo_color|apollo color display:\ :dN@:tc=vt132: Mv|virtual|VIRTUAL|cb unix virtual terminal:\ :do=^J:co#80:li#24:am:cl=\E\112:le=^H:bs:cm=\E\107%r%.%.:nd=\E\103:\ :up=\E\101:ce=\E\113:cd=\E\114:al=\E\120:dl=\E\116:im=:ei=:ic=\E\117:\ :da:db:kl=\E\104:kr=\E\103:ku=\E\101:kd=\E\102:kh=\E\105:\ :so=\E\141\004:se=\E\142\004:us=\E\141\001:ue=\E\142\001: Mw|it2|intertube2|intertec data systems intertube 2:\ :do=^J:am:bs:cl=^L:co#80:ho=^A:li#25:up=^Z:ce=\EK:\ :cm=^N%+ %+ :ch=^P%\102%.:cv=^K%.:nd=^F:do=\n:ll=^K^X\r:\ :so=\E0P:se=\E0@: Mx|delta|dd5000|delta data 5000:\ :do=^J:am:le=^H:bs:cl=^NR:cm=^O%\068%+9%\068%+9:co#80:li#27:\ :ho=^NQ:nc:nd=^Y:up=^Z:ce=^NU:dc=^NV:ma=^K^J^Z^P^Y :xr: My|mdl110|cybernex mdl-110:\ :cm=^P%+ %+ :co#80:li#24:am:cl=70^X:le=^H:bs:do=^J:\ :nd=^U:up=^Z:ho=^Y:ce=145^N@^V:cd=145^NA^W:al=65^NA^N^]:\ :dl=40^NA^N^^:im=:ei=:ic=3.5^NA^]:dm=:ed=:dc=3.5^NA^^:\ :so=^NF:se=^NG:ta=43\t:ma=^Z^P:cd=6^N@^V Mz|zen30|z30|zentec 30:\ :do=^J:mi:co#80:li#24:ma=^L ^R^L^K^P:ul:\ :al=1.5*\EE:le=^H:bs:ce=1.0*\ET:cm=\E=%+ %+ :cl=\E*:\ :ho=^^:nd=^L:se=\EG0:so=\EG6:up=^K:im=\Eq:ei=\Er:\ :am:dc=\EW:dl=1.5*\ER:cd=\EY: m0|modgraph|mod|Modgraph terminal emulating vt100, 24x80:\ :xn@:rf@:sr=5\EM\E[K:vs=\E\^9;0s\E\^7;1s:\ :is=\E\^9;0s\E\^7;1s\E[3g\E\^11;9s\E\^11;17s\E\^11;25s\E\^11;33s\E\^11;41s\E\^11;49s\E\^11;57s\E\^11;65s\E\^11;73s\E\^11;81s\E\^11;89s:\ :tc=vt100: # dmchat is like DM2500, but DOES need "all that padding" (jcm 1/31/82) # also, has a meta-key (MT) # from goldberger@su-csli.arpa MX|dmchat|dmchat version of datamedia 2500:\ :al=1*^P\n^X^]^X^]:\ :MT:km:\ :dl=2^P^Z^X^]:\ :tc=dm2500: #from Carol Block at ear (cblock@ear) # m7|mt70|m70|morrow mt70:\ :is=EGO\E"5:\ :cl=^Z:\ :cm=\E=%+ %+ :\ :do=^J:\ :im=:ic=\EQ:ei:\ :dm=:dc=\EW:ed=:\ :kl=\034L:kr=\034M:ku=\034J:kd=\034K:\ :so=\EG4:se=\EGO:\ :us=\EG1:ue=\EGO:\ :vs=\E"2:ve=\E"5\E(:\ :tc=adm31: # from keith bostic (bostic@monet) # m2|mod2|Modgraph GX-1000, set to 80x24, keypad not enabled:\ :is=\E<\E\^5;2s\E\^7;1s\E[3g\E\^11;9s\E\^11;17s\E\^11;25s\E\^11;33s\E\^11;41s\E\^11;49s\E\^11;57s\E\^11;65s\E\^11;73s\E\^11;81s\E\^11;89s\E\^12;0s\E\^14;2s\E\^15;9s\E\^25;1s\E\^9;1s\E\^27;1:\ :bs:cd=50\EJ:ce=3\EK:cl=50\EH\EJ:cm=5\EY%+ %+ :co#80:li#24:nd=2\EC:\ :pt:sr=5\EI:up=2\EA:da:db:am: S1|wsiris|iris40|iris emulating a 40 line visual 50 (approximately):\ :am:al=\EL:is=\E7B0\E7F7\E7C2\E7R3:\ :bs:cd=\EJ:ce=\EK:cl=\EH\EJ:ho=\EH:cm=\EY%+ %+ :co#80:li#40:nd=\EC:\ :pt:sr=\EI:up=\EA:ku=\EA:kd=\EB:kr=\EC:kl=\ED:\ :k0=\E0:k1=\E1:k2=\E2:k3=\E3:k4=\E4:k5=\E5:k6=\E6:k7=\E7:k8=\E8:k9=\E9:\ :vs=\E;:ve=\E>:cl=\Ev:ho=\EH:dl=\EM:so=\E9P:se=\E0@:\ :HS=\E7F2:HE=\E7F7:\ :us=\E7R2\E9P:ue=\E7R3\E0@:\ :CT#2:CZ=*Bblack,red,green,yellow,blue,magenta,cyan,*Fwhite: # # -------------------------------- # # N: ANN ARBOR # # Needs function keys added. # Originally from Mike O'Brien@Rand and Howard Katseff at Bell Labs. # Highly modified 6/22 by Mike O'Brien. # split out into several for the various screen sizes by dave-yost@rand # Modifications made 3/82 by Mark Horton # Modified by Tom Quarles at UCB for greater efficiency and more diversity # status line moved to top of screen, vb removed 5/82 # # assumes the following setup: # A menu: 0000 1010 0001 0000 # B menu: 9600 0100 1000 0000 0000 1000 0000 17 19 # C menu: 56 66 0 0 9600 0110 1100 # D menu: 0110 1001 1 0 # # Briefly, the settings are for the following modes: # (values are for bit set/clear with * indicating our preference # and the value used to test these termcaps) # Note that many of these settings are irelevent to the termcap # and are just set to the default mode of the terminal as shipped # by the factory. # # A menu: 0000 1010 0001 0000 # Block/underline cursor* # blinking/nonblinking cursor* # key click/no key click* # bell/no bell at column 72* # # key pad is cursor control*/key pad is numeric # return and line feed/return for key * # repeat after .5 sec*/no repeat # repeat at 25/15 chars per sec. * # # hold data until pause pressed/process data unless pause pressed* # slow scroll/no slow scroll* # Hold in area/don't hold in area* # functions keys have default*/function keys disabled on powerup # # show/don't show position of cursor during page transmit* # unused # unused # unused # # B menu: 9600 0100 1000 0000 0000 1000 0000 17 19 # Baud rate (9600*) # # 2 bits of parity - 00=odd,01=even*,10=space,11=mark # 1 stop bit*/2 stop bits # parity error detection off*/on # # keyboard local/on line* # half/full duplex* # disable/do not disable keyboard after data transmission* # # transmit entire page/stop transmission at cursor* # transfer/do not transfer protected characters* # transmit all characters/transmit only selected characters* # transmit all selected areas/transmit only 1 selected area* # # transmit/do not transmit line seperators to host* # transmit/do not transmit page tab stops tabs to host* # transmit/do not transmit column tab stop tabs to host* # transmit/do not transmit graphics control (underline,inverse..)* # # enable*/disable auto XON/XOFF control # require/do not require receipt of a DC1 from host after each LF* # pause key acts as a meta key/pause key is pause* # unused # # unused # unused # unused # unused # # XON character (17*) # XOFF character (19*) # # C menu: 56 66 0 0 9600 0110 1100 # number of lines to print data on (printer) (56*) # # number of lines on a sheet of paper (printer) (66*) # # left margin (printer) (0*) # # number of pad chars on new line to printer (0*) # # printer baud rate (9600*) # # printer parity: 00=odd,01=even*,10=space,11=mark # printer stop bits: 2*/1 # print/do not print guarded areas* # # new line is: 01=LF,10=CR,11=CRLF* # unused # unused # # D menu: 0110 1001 1 0 # LF is newline/LF is down one line, same column* # wrap to preceeding line if move left from col 1*/don't wrap # wrap to next line if move right from col 80*/don't wrap # backspace is/is not destructive* # # display*/ignore DEL character # display will not/will scroll* # page/column tab stops* # erase everything*/erase unprotected only # # editing extent: 0=display,1=line*,2=field,3=area # # unused # NA|aaa-unk|ann arbor ambassador (internal - don't use this directly):\ :do=^J:al=3\E[L:am:le=^H:bs:\ :cd=\E[J:ce=5\E[K:cl=156\E[H\E[J:cm=\E[%i%d;%dH:co#80:\ :dc=4\E[P:dl=3\E[M:ho=\E[H:ic=4\E[@:\ :md=\E[1m:mr=\E[7m:mb=\E[5m:mk=\E[8m:me=\E[m:\ :ku=\EM:kd=\ED:kl=\E[D:kr=\E[C:kh=\E[H:ko=cl,dc,dl,ce,cd:\ :ks=\EP`?z~[H~[[J`>z~[[J`8xz~[M`4xz~[[D`6xz~[[C`2xz~[D\E\\:\ :ke=\EP`?y~[H~[[J`>y~[[2J`8xy~[M`4xy~[[D`6xy~[[C`2xy~[D\E\\:\ :ch=\E[%i%d`:ei=:im=:pt:bw:bt=\E[Z:\ :mi:nd=\E[C:se=\E[m:so=\E[7m:ue=\E[m:us=\E[4m:up=\EM: NB|aaa-18|ann arbor ambassador/18 lines:\ :ti=\E[2J\E[18;0;0;18p:te=\E[60;0;0;18p\E[18;1H\E[J:\ :is=\EP`+x~M\E\\\E[m\E7\E[60;0;0;18p\E[3g\E[f\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E8\E[>6h\E[1Q:\ :li#18:tc=aaa-unk: NC|aaa-20|ann arbor ambassador/20 lines:\ :ti=\E[2J\E[20;0;0;20p:te=\E[60;0;0;20p\E[20;1H\E[J:\ :is=\EP`+x~M\E\\\E[m\E7\E[60;0;0;20p\E[3g\E[f\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E8\E[>6h\E[1Q:\ :li#20:tc=aaa-unk: ND|aaa-22|ann arbor ambassador/22 lines:\ :ti=\E[2J\E[22;0;0;22p:te=\E[60;0;0;22p\E[22;1H\E[J:\ :is=\EP`+x~M\E\\\E[m\E7\E[60;0;0;22p\E[3g\E[f\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E8\E[>6h\E[1Q:\ :li#22:tc=aaa-unk: NE|aaa-24|ann arbor ambassador/24 lines:\ :ti=\E[2J\E[24;0;0;24p:te=\E[60;0;0;24p\E[24;1H\E[J:\ :is=\EP`+x~M\E\\\E[m\E7\E[60;0;0;24p\E[3g\E[f\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E8\E[>6h\E[1Q:\ :li#24:tc=aaa-unk: NF|aaa-26|ann arbor ambassador/26 lines:\ :ti=\E[2J\E[26;0;0;26p:te=\E[60;0;0;26p\E[26;1H\E[J:\ :is=\EP`+x~M\E\\\E[m\E7\E[60;0;0;26p\E[3g\E[f\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E8\E[>6h\E[1Q:\ :li#26:tc=aaa-unk: NG|aaa-28|ann arbor ambassador/28 lines:\ :ti=\E[2J\E[28;0;0;28p:te=\E[60;0;0;28p\E[28;1H\E[J:\ :is=\EP`+x~M\E\\\E[m\E7\E[60;0;0;28p\E[3g\E[f\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E8\E[>6h\E[1Q:\ :li#28:tc=aaa-unk: NH|aaa|aaa-30|ambas|ambassador|ann arbor ambassador/30 lines:\ :ti=\E[2J\E[30;0;0;30p:te=\E[60;0;0;30p\E[30;1H\E[J:\ :is=\EP`+x~M\E\\\E[m\E7\E[60;0;0;30p\E[3g\E[f\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E8\E[>6h\E[1Q:\ :li#30:tc=aaa-unk: NI|aaa-36|ann arbor ambassador/36 lines:\ :ti=\E[2J\E[36;0;0;36p:te=\E[60;0;0;36p\E[36;1H\E[J:\ :is=\EP`+x~M\E\\\E[m\E7\E[60;0;0;36p\E[3g\E[f\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E8\E[>6h\E[1Q:\ :li#36:tc=aaa-unk: NJ|aaa-40|ann arbor ambassador/40 lines:\ :ti=\E[2J\E[40;0;0;40p:te=\E[60;0;0;40p\E[40;1H\E[J:\ :is=\EP`+x~M\E\\\E[m\E7\E[60;0;0;40p\E[3g\E[f\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E8\E[>6h\E[1Q:\ :li#40:tc=aaa-unk: NK|aaa-48|ann arbor ambassador/48 lines:\ :ti=\E[2J\E[48;0;0;48p:te=\E[60;0;0;48p\E[48;1H\E[J:\ :is=\EP`+x~M\E\\\E[m\E7\E[60;0;0;48p\E[3g\E[f\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E8\E[>6h\E[1Q:\ :li#48:tc=aaa-unk: NL|aaa-60|ann arbor ambassador/60 lines:\ :ti=\E[2J\E[60;0;0;60p:te=\E[60;0;0;60p\E[60;1H\E[J:\ :is=\EP`+x~M\E\\\E[m\E7\E[60;0;0;60p\E[3g\E[f\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E8\E[>6h\E[1Q:\ :li#60:tc=aaa-unk: NS|aaa-unk-s|ann arbor ambassador unknown with/status:\ :es:hs:i2=\E7\E[>51h\E[H\E[2K\E[>51l\E8:\ :ts=\E7\E[>51h\E[H\E[2K\E[%i%d`:fs=\E[>51l\E8:\ :ds=\E7\E[>51h\E[H\E[2K\E[>51l\E8:\ :tc=aaa-unk: NM|aaa-18-s|ambassador|ann arbor ambassador/18 lines + status line:\ :ti=\E[2J\E[18;1;0;18p:\ :te=\E[60;1;0;18p\E[17;1H\E[J:\ :is=\EP`+x~M\E\\\E[m\E7\E[60;1;0;18p\E[3g\E[f\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E8\E[>6h\E[1Q:\ :li#17:tc=aaa-unk-s: NN|aaa-20-s|ambassador|ann arbor ambassador/20 lines + status line:\ :ti=\E[2J\E[20;1;0;20p:\ :te=\E[60;1;0;20p\E[19;1H\E[J:\ :is=\EP`+x~M\E\\\E[m\E7\E[60;1;0;20p\E[3g\E[f\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E8\E[>6h\E[1Q:\ :li#19:tc=aaa-unk-s: NO|aaa-22-s|ambassador|ann arbor ambassador/22 lines + status line:\ :ti=\E[2J\E[22;1;0;22p:\ :te=\E[60;1;0;22p\E[21;1H\E[J:\ :is=\EP`+x~M\E\\\E[m\E7\E[60;1;0;22p\E[3g\E[f\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E8\E[>6h\E[1Q:\ :li#21:tc=aaa-unk-s: NP|aaa-24-s|ambassador|ann arbor ambassador/24 lines + status line:\ :ti=\E[2J\E[24;1;0;24p:\ :te=\E[60;1;0;24p\E[23;1H\E[J:\ :is=\EP`+x~M\E\\\E[m\E7\E[60;1;0;24p\E[3g\E[f\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E8\E[>6h\E[1Q:\ :li#23:tc=aaa-unk-s: NQ|aaa-26-s|ambassador|ann arbor ambassador/26 lines + status line:\ :ti=\E[2J\E[26;1;0;26p:\ :te=\E[60;1;0;26p\E[25;1H\E[J:\ :is=\EP`+x~M\E\\\E[m\E7\E[60;1;0;26p\E[3g\E[f\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E8\E[>6h\E[1Q:\ :li#25:tc=aaa-unk-s: NR|aaa-28-s|ambassador|ann arbor ambassador/28 lines + status line:\ :ti=\E[2J\E[28;1;0;28p:\ :te=\E[60;1;0;28p\E[27;1H\E[J:\ :is=\EP`+x~M\E\\\E[m\E7\E[60;1;0;28p\E[3g\E[f\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E8\E[>6h\E[1Q:\ :li#27:tc=aaa-unk-s: NT|aaa-30-s|ambassador|ann arbor ambassador/30 lines + status line:\ :ti=\E[2J\E[30;1;0;30p:\ :te=\E[60;1;0;30p\E[29;1H\E[J:\ :is=\EP`+x~M\E\\\E[m\E7\E[60;1;0;30p\E[3g\E[f\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E8\E[>6h\E[1Q:\ :li#29:tc=aaa-unk-s: NU|aaa-36-s|ambassador|ann arbor ambassador/36 lines + status line:\ :ti=\E[2J\E[36;1;0;36p:\ :te=\E[60;1;0;36p\E[35;1H\E[J:\ :is=\EP`+x~M\E\\\E[m\E7\E[60;1;0;36p\E[3g\E[f\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E8\E[>6h\E[1Q:\ :li#35:tc=aaa-unk-s: NV|aaa-40-s|ambassador|ann arbor ambassador/40 lines + status line:\ :ti=\E[2J\E[40;1;0;40p:\ :te=\E[60;1;0;40p\E[39;1H\E[J:\ :is=\EP`+x~M\E\\\E[m\E7\E[60;1;0;40p\E[3g\E[f\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E8\E[>6h\E[1Q:\ :li#39:tc=aaa-unk-s: NW|aaa-48-s|ann arbor ambassador/48 lines+sl:\ :ti=\E[2J\E[48;1;0;48p:te=\E[60;1;0;48p\E[47;1H\E[J:\ :is=\EP`+x~M\E\\\E[m\EP`?y~[[2J~[[H\E7\E[60;1;0;48p\E[3g\E[f\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E8\E[>6h\E[1Q:\ :li#47:tc=aaa-unk-s: NX|aaa-60-s|ambassador|ann arbor ambassador/60 lines + status line:\ :ti=\E[2J\E[60;1;0;60p:te=\E[60;1;0;60p\E[59;1H\E[J:\ :is=\EP`+x~M\E\\\E[m\E7\E[60;1;0;60p\E[3g\E[f\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E8\E[>6h\E[1Q:\ :li#59:tc=aaa-unk-s: NY|aaa-18-rv|ambassador/18 lines+rv:\ :md=\E[1;7m:mr=\E[m:mb=\E[5;7m:mk=\E[7;8m:me=\E[7m:\ :us=\E[4;7m:ue=\E[7m:se=\E[7m:so=\E[m:\ :is=\EP`+x~M\E\\\E[7m\E7\E[60;0;0;18p\E[3g\E[f\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E8\E[>6h\E[1Q:\ :tc=aaa-18: NZ|aaa-20-rv|ambassador/20 lines+rv:\ :md=\E[1;7m:mr=\E[m:mb=\E[5;7m:mk=\E[7;8m:me=\E[7m:\ :us=\E[4;7m:ue=\E[7m:se=\E[7m:so=\E[m:\ :is=\EP`+x~M\E\\\E[7m\E7\E[60;0;0;20p\E[3g\E[f\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E8\E[>6h\E[1Q:\ :tc=aaa-20: Na|aaa-22-rv|ambassador/22 lines+rv:\ :md=\E[1;7m:mr=\E[m:mb=\E[5;7m:mk=\E[7;8m:me=\E[7m:\ :us=\E[4;7m:ue=\E[7m:se=\E[7m:so=\E[m:\ :is=\EP`+x~M\E\\\E[7m\E7\E[60;0;0;22p\E[3g\E[f\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E8\E[>6h\E[1Q:\ :tc=aaa-22: Nb|aaa-24-rv|ambassador/24 lines+rv:\ :md=\E[1;7m:mr=\E[m:mb=\E[5;7m:mk=\E[7;8m:me=\E[7m:\ :us=\E[4;7m:ue=\E[7m:se=\E[7m:so=\E[m:\ :is=\EP`+x~M\E\\\E[7m\E7\E[60;0;0;24p\E[3g\E[f\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E8\E[>6h\E[1Q:\ :tc=aaa-24: Nc|aaa-26-rv|ambassador/26 lines+rv:\ :md=\E[1;7m:mr=\E[m:mb=\E[5;7m:mk=\E[7;8m:me=\E[7m:\ :us=\E[4;7m:ue=\E[7m:se=\E[7m:so=\E[m:\ :is=\EP`+x~M\E\\\E[7m\E7\E[60;0;0;26p\E[3g\E[f\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E8\E[>6h\E[1Q:\ :tc=aaa-26: Nd|aaa-28-rv|ambassador/28 lines+rv:\ :md=\E[1;7m:mr=\E[m:mb=\E[5;7m:mk=\E[7;8m:me=\E[7m:\ :us=\E[4;7m:ue=\E[7m:se=\E[7m:so=\E[m:\ :is=\EP`+x~M\E\\\E[7m\E7\E[60;0;0;28p\E[3g\E[f\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E8\E[>6h\E[1Q:\ :tc=aaa-28: Ne|aaa-30-rv|ann arbor ambassador/30 lines in reverse video:\ :md=\E[1;7m:mr=\E[m:mb=\E[5;7m:mk=\E[7;8m:me=\E[7m:\ :us=\E[4;7m:ue=\E[7m:se=\E[7m:so=\E[m:\ :is=\EP`+x~M\E\\\E[7m\E7\E[60;0;0;30p\E[3g\E[f\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E8\E[>6h\E[1Q:\ :tc=aaa-30: Nf|aaa-36-rv|ann arbor ambassador/36 lines in reverse video:\ :md=\E[1;7m:mr=\E[m:mb=\E[5;7m:mk=\E[7;8m:me=\E[7m:\ :us=\E[4;7m:ue=\E[7m:se=\E[7m:so=\E[m:\ :is=\EP`+x~M\E\\\E[7m\E7\E[60;0;0;36p\E[3g\E[f\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E8\E[>6h\E[1Q:\ :tc=aaa-36: Ng|aaa-40-rv|ann arbor ambassador/40 lines in reverse video:\ :md=\E[1;7m:mr=\E[m:mb=\E[5;7m:mk=\E[7;8m:me=\E[7m:\ :us=\E[4;7m:ue=\E[7m:se=\E[7m:so=\E[m:\ :is=\EP`+x~M\E\\\E[7m\E7\E[60;0;0;40p\E[3g\E[f\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E8\E[>6h\E[1Q:\ :tc=aaa-40: Nh|aaa-48-rv|ann arbor ambassador/48 lines in reverse video:\ :md=\E[1;7m:mr=\E[m:mb=\E[5;7m:mk=\E[7;8m:me=\E[7m:\ :us=\E[4;7m:ue=\E[7m:se=\E[7m:so=\E[m:\ :is=\EP`+x~M\E\\\E[7m\E7\E[60;0;0;48p\E[3g\E[f\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E8\E[>6h\E[1Q:\ :tc=aaa-48: Ni|aaa-60-rv|ann arbor ambassador/60 lines in reverse video:\ :md=\E[1;7m:mr=\E[m:mb=\E[5;7m:mk=\E[7;8m:me=\E[7m:\ :us=\E[4;7m:ue=\E[7m:se=\E[7m:so=\E[m:\ :is=\EP`+x~M\E\\\E[7m\E7\E[60;0;0;60p\E[3g\E[f\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E8\E[>6h\E[1Q:\ :tc=aaa-60: Nj|aaa-18-rv-s|aaa-18-s-rv|ambassador/18 lines+sl+rv:\ :md=\E[1;7m:mr=\E[m:mb=\E[5;7m:mk=\E[7;8m:me=\E[7m:\ :us=\E[4;7m:ue=\E[7m:se=\E[7m:so=\E[m:\ :ti=\E[2J\E[18;1;0;18p:te=\E[60;1;0;18p\E[17;1H\E[J:li#17:\ :is=\EP`+x~M\E\\\E[7m\E7\E[60;1;0;18p\E[3g\E[f\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E8\E[>6h\E[1Q:\ :tc=aaa-unk-s: Nk|aaa-20-rv-s|aaa-20-s-rv|ambassador/20 lines+sl+rv:\ :md=\E[1;7m:mr=\E[m:mb=\E[5;7m:mk=\E[7;8m:me=\E[7m:\ :us=\E[4;7m:ue=\E[7m:se=\E[7m:so=\E[m:\ :ti=\E[2J\E[20;1;0;20p:te=\E[60;1;0;20p\E[19;1H\E[J:li#19:\ :is=\EP`+x~M\E\\\E[7m\E7\E[60;1;0;20p\E[3g\E[f\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E8\E[>6h\E[1Q:\ :tc=aaa-unk-s: Nl|aaa-22-rv-s|aaa-22-s-rv|ambassador/22 lines+sl+rv:\ :md=\E[1;7m:mr=\E[m:mb=\E[5;7m:mk=\E[7;8m:me=\E[7m:\ :us=\E[4;7m:ue=\E[7m:se=\E[7m:so=\E[m:\ :ti=\E[2J\E[22;1;0;22p:te=\E[60;1;0;22p\E[21;1H\E[J:li#21:\ :is=\EP`+x~M\E\\\E[7m\E7\E[60;1;0;22p\E[3g\E[f\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E8\E[>6h\E[1Q:\ :tc=aaa-unk-s: Nm|aaa-24-rv-s|aaa-24-s-rv|ambassador/24 lines+sl+rv:\ :md=\E[1;7m:mr=\E[m:mb=\E[5;7m:mk=\E[7;8m:me=\E[7m:\ :us=\E[4;7m:ue=\E[7m:se=\E[7m:so=\E[m:\ :ti=\E[2J\E[24;1;0;24p:te=\E[60;1;0;24p\E[23;1H\E[J:li#23:\ :is=\EP`+x~M\E\\\E[7m\E7\E[60;1;0;24p\E[3g\E[f\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E8\E[>6h\E[1Q:\ :tc=aaa-unk-s: Nn|aaa-26-rv-s|aaa-26-s-rv|ambassador/26 lines+sl+rv:\ :md=\E[1;7m:mr=\E[m:mb=\E[5;7m:mk=\E[7;8m:me=\E[7m:\ :us=\E[4;7m:ue=\E[7m:se=\E[7m:so=\E[m:\ :ti=\E[2J\E[26;1;0;26p:te=\E[60;1;0;26p\E[25;1H\E[J:li#25:\ :is=\EP`+x~M\E\\\E[7m\E7\E[60;1;0;26p\E[3g\E[f\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E8\E[>6h\E[1Q:\ :tc=aaa-unk-s: No|aaa-28-rv-s|aaa-28-s-rv|ambassador/28 lines+sl+rv:\ :md=\E[1;7m:mr=\E[m:mb=\E[5;7m:mk=\E[7;8m:me=\E[7m:\ :us=\E[4;7m:ue=\E[7m:se=\E[7m:so=\E[m:\ :ti=\E[2J\E[28;1;0;28p:te=\E[60;1;0;28p\E[27;1H\E[J:li#27:\ :is=\EP`+x~M\E\\\E[7m\E7\E[60;1;0;28p\E[3g\E[f\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E8\E[>6h\E[1Q:\ :tc=aaa-unk-s: Np|aaa-rv|aaa-30-rv-s|aaa-30-s-rv|ambassador/30 lines+sl+rv:\ :md=\E[1;7m:mr=\E[m:mb=\E[5;7m:mk=\E[7;8m:me=\E[7m:\ :us=\E[4;7m:ue=\E[7m:se=\E[7m:so=\E[m:\ :ti=\E[2J\E[30;1;0;30p:te=\E[60;1;0;30p\E[29;1H\E[J:li#29:\ :is=\EP`+x~M\E\\\E[7m\E7\E[60;1;0;30p\E[3g\E[f\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E8\E[>6h\E[1Q:\ :tc=aaa-unk-s: Nq|aaa-36-rv-s|aaa-36-s-rv|ambassador/36 lines+sl+rv:\ :md=\E[1;7m:mr=\E[m:mb=\E[5;7m:mk=\E[7;8m:me=\E[7m:\ :us=\E[4;7m:ue=\E[7m:se=\E[7m:so=\E[m:\ :ti=\E[2J\E[36;1;0;36p:te=\E[60;1;0;36p\E[35;1H\E[J:li#35:\ :is=\EP`+x~M\E\\\E[7m\E7\E[60;1;0;36p\E[3g\E[f\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E8\E[>6h\E[1Q:\ :tc=aaa-unk-s: Nr|aaa-40-rv-s|aaa-40-s-rv|ambassador/40 lines+sl+rv:\ :md=\E[1;7m:mr=\E[m:mb=\E[5;7m:mk=\E[7;8m:me=\E[7m:\ :us=\E[4;7m:ue=\E[7m:se=\E[7m:so=\E[m:\ :ti=\E[2J\E[40;1;0;40p:te=\E[60;1;0;40p\E[39;1H\E[J:li#39:\ :is=\EP`+x~M\E\\\E[7m\E7\E[60;1;0;40p\E[3g\E[f\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E8\E[>6h\E[1Q:\ :tc=aaa-unk-s: Ns|aaa-48-rv-s|aaa-48-s-rv|ambassador/48 lines+sl+rv:\ :md=\E[1;7m:mr=\E[m:mb=\E[5;7m:mk=\E[7;8m:me=\E[7m:\ :us=\E[4;7m:ue=\E[7m:se=\E[7m:so=\E[m:\ :ti=\E[2J\E[48;1;0;48p:te=\E[60;1;0;48p\E[47;1H\E[J:li#47:\ :is=\EP`+x~M\E\\\E[7m\E7\E[60;1;0;48p\E[3g\E[f\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E8\E[>6h\E[1Q:\ :tc=aaa-unk-s: Nt|aaa-60-rv-s|aaa-60-s-rv|ambassador/60 lines+sl+rv:\ :md=\E[1;7m:mr=\E[m:mb=\E[5;7m:mk=\E[7;8m:me=\E[7m:\ :us=\E[4;7m:ue=\E[7m:se=\E[7m:so=\E[m:\ :ti=\E[2J\E[60;1;0;60p:te=\E[60;1;0;60p\E[59;1H\E[J:li#59:\ :is=\EP`+x~M\E\\\E[7m\E7\E[60;1;0;60p\E[3g\E[f\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E8\E[>6h\E[1Q:\ :tc=aaa-unk-s: NL|aaa-24-ctxt|ann arbor ambassador/24 lines:\ :ti=\E[30;1H\E[K\E[24;0;0;24p:te=\E[60;1;0;24p\E[60;1H\E[K:tc=aaa-24: NL|aaa-24-rv-ctxt|ambassador/24+rv:\ :ti=\E[30;1H\E[K\E[24;0;0;24p:te=\E[60;1;0;24p\E[60;1H\E[K:tc=aaa-24-rv: NL|aaa-s-ctxt|aaa-30-s-ctxt|hairy aaa:\ :ti=\E[30;1H\E[K\E[30;1;0;30p:te=\E[60;1;0;30p\E[59;1H\E[K:tc=aaa-30-s: NL|aaa-s-rv-ctxt|aaa-30-s-rv-ctxt|hairy aaa:\ :md=\E[1;7m:mr=\E[m:mb=\E[5;7m:mk=\E[7;8m:me=\E[7m:\ :us=\E[4;7m:ue=\E[7m:se=\E[7m:so=\E[m:\ :is=\EP`+x~M\E\\\E[7m\E7\E[60;1;0;30p\E[3g\E[f\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E8\E[>6h\E[1Q:\ :ti=\E[30;1H\E[K\E[30;1;0;30p:te=\E[60;1;0;30p\E[59;1H\E[K:\ :li#29:tc=aaa-unk-s: NH|aaa-ctxt|aaa-30-ctxt|ann arbor ambassador/30 lines:\ :ti=\E[30;0;0;30p:te=\E[60;0;0;30p\E[60;1H\E[K:tc=aaa-30: NH|aaa-rv-ctxt|aaa-30-rv-ctxt|ann arbor ambassador/30 lines:\ :ti=\E[30;0;0;30p:te=\E[60;0;0;30p\E[60;1H\E[K:\ :md=\E[1;7m:mr=\E[m:mb=\E[5;7m:mk=\E[7;8m:me=\E[7m:\ :us=\E[4;7m:ue=\E[7m:se=\E[7m:so=\E[m:\ :is=\EP`+x~M\E\\\E[7m\E7\E[60;0;0;30p\E[3g\E[f\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E[8a\EH\E8\E[>6h\E[1Q:\ :li#30:tc=aaa-unk: Nd|aaa-db|ann arbor ambassador 30/destructive backspace:\ :ti=\E[H\E[J\E[30;0;0;30p:te=\E7\E[60;0;0;30p\E8:li#30:\ :is=\E[60;0;0;30p\E[H\E[J\E[1Q\E[m\E[20l\E[>30h:le=\E[D:bc=\E[D:bs@:\ :tc=aaa-unk: N1|aa|annarbor|4080|ann arbor 4080:\ :do=^J:pt:ct=^\^P^P:st=^]^P1:cm=^O%r%\066%.%>^S^L%+@:\ :co#80:li#40:le=^H:bs:cl=2^L:up=^N:nd=^_:ho=^K:am:\ :kb=^^:kd=^J:ku=^N:kl=^H:kr=^_:kh=^K:ma=^_ ^N^P: # # -------------------------------- # # P: PC entries for use with kermit # # greg small (gts@populi) # # Cannot use :pt:, it does not work (why?). :ho: seems required (why?). [gts] # Caution: 4.3 BSD tset does not pass li#25 to stty rows except during login? # :cl: clears attributes and sets wrap at margin before clearing the screen. P1|ansi.sys|ansisys|PC-DOS 3.1 ANSI.SYS:\ :am:bs:ce=\E[K:cl=\E[m\E[7h\E[2J:cm=\E[%i%d;%dH:co#80:\ :ku=^K:kd=^J:kl=^H:kr=^L:kh=^^:ma=^Hh\012j^Kk^Ll^^H:\ :ho=\E[H:li#25:nd=\E[C:up=\E[A:\ :ms:md=\E[1m:me=\E[m:mr=\E[7m:se=\E[m:so=\E[1m:ue=\E[m:us=\E[4m:\ :is=U1 PC-DOS 3.1 ANSI.SYS 9-23-86\n\E[m\E[7h: # # Define IBM PC keypad keys for vi as per MS-Kermit while using ANSI.SYS. # This should only be used when the terminal emulator cannot redefine the keys. # Since redefining keys with ansi.sys also affects PC-DOS programs, the key # definitions must be restored. If the terminal emulator is quit while in vi # or others using :ks:ke:, the keypad keys will not be defined as per PC-DOS. # The PgUp and PgDn are prefixed with ESC so that tn3270 can be used on Unix # (^U and ^D are already defined for tn3270). The ESC is safe for vi but it # does "beep". ESC ESC i is used for Ins to avoid tn3270 ESC i for coltab. # Left arrow is always BS, because PC-dos can tolerate this change. # Caution: vi is limited to 256 string bytes, longer crashes or wierds vi. # Consequently the End keypad key could not be set (it is relatively safe and # actually useful because it sends ^@ O, which beeps and opens a line above). P2|ansi.sysk|ansisysk|PC-DOS 3.1 ANSI.SYS with keypad redefined for vi:\ :ks=\E[;71;30p\E[;72;11p\E[;73;27;21p\E[;77;12p\E[;80;10p\E[;81;27;4p\E[;82;27;27;105p\E[;83;127p:\ :ke=\E[;71;0;71p\E[;72;0;72p\E[;73;0;73p\E[;77;0;77p\E[;80;0;80p\E[;81;0;81p\E[;82;0;82p\E[;83;0;83p:\ :is=U2 PC-DOS 3.1 ANSI.SYS with keypad redefined for vi 9-29-86\n\E[;75;8p:\ :tc=ansi.sys # # Adds ins/del line/character, hence vi reverse scrolls/inserts/deletes nicer. P3|nansi.sys|nansisys||PC-DOS Public Domain NANSI.SYS:\ :al=\E[1L:dl=\E[1M:ic=\E[1@:dc=\E[1P:\ :is=U3 PC-DOS Public Domain NANSI.SYS 9-23-86\n:\ :tc=ansi.sys: # # See U2 ansi.sysk and U3 nansi.sys above. P4|nansi.sysk|nansisysk|PC-DOS Public Domain NANSI.SYS with keypad redefined for vi:\ :al=\E[1L:dl=\E[1M:ic=\E[1@:dc=\E[1P:\ :is=U4 PC-DOS Public Domain NANSI.SYS with keypad redefined for vi 9-29-86\n\E[;75;8p:\ :tc=ansi.sysk: # # -------------------------------- # # T: TELETYPE # # We need descriptions for the model 40. There are known to be at least three # flavors of the 40, both seem more like IBM half duplex forms fillers than # ASCII terminals. They have lots of awful braindamage, such as printing # a visible newline indicator after each newline. The 40-1 is a half duplex # terminal and is hopeless. The 40-2 is braindamaged but has hope and is # described here. The 40-4 is a 3270 lookalike and beyond hope. # The terminal has visible bell but I don't know it - it's # null here to prevent it from showing the BL character. # There is an \EG in nl because of a bug in vi (if stty says you have # a "newline" style terminal (-crmode) vi figures all it needs is nl # to get crlf, even if cr is not ^M.) T0|40|tty40|ds40|ds40/2|ds40-2|dataspeed40|teletype dataspeed 40/2:\ :cl=160\ER:cd=160\EJ:al=160\EL:dl=160\EM:dc=50\EP:im=:ei=:ic=50\E\^:\ :nd=\EC:up=\E7:bs:cr=\EG:nl=\EG\EB:do=\EB:co#80:li#24:vb=:\ :so=\E3:se=\E4: T3|33|tty33|tty|model 33 teletype:\ :do=^J:co#72:hc:os: T4|43|tty43|model 43 teletype:\ :do=^J:kb=^h:am:le=^H:bs:hc:os:co#132: T7|37|tty37|model 37 teletype:\ :do=^J:le=^H:bs:hc:hu=\E8:hd=\E9:up=\E7:os: # From jwb Wed Mar 31 13:25:09 1982 remote from ihuxp # This entry appears to avoid the top line - I have no idea why. TT|4424|tty4424|teletype 4424M:\ :al=\EL:da:db:ip=2:im=:ei=:ic=\E\^:dc=\EP:dl=\EM:\ :co#80:li#23:am:cl=\E[2;H\E[J:bs:cm=\E[%i%2;%2H\E[B:\ :nd=\E[C:up=\E[A:pt:mi:sr=\ET:\ :ce=\E[K:so=\E[7m:se=\E[m:us=\E[4m:ue=\E[m:\ :is=\E[m\E[2;24r:\ :kd=\E[B:kl=\E[D:ku=\E[A:kr=\E[C:\ :kh=\E[H:k1=\EOP:k2=\EOQ:k3=\EOR:k4=\EOS: # Teletype blit. TD|dmd|5620|ttydmd|tty5620|5620 terminal 88 columns:\ :co#88:li#70:am:bs:pt:cm=\E[%i%d;%dH:nd=\E[C:up=\E[A:\ :cl=\E[H\E[J:cd=\E[J:ce=\E[K:al=\E[L:dl=\E[M:do=^J:\ :im=:ei=:ic=\E[@:dc=\E[P:sr=\E[T:sf=\E[S:le=^H:kb=^H:\ :kl=\E[D:kr=\E[C:ku=\E[A:kd=\E[B:kh=\E[H:ho=\E[H:ll=\E[70;1H:\ :AL=\E[%dL:DL=\E[%dM:IC=\E[%d@:DC=\E[%dP:rc=\E8:rs=\Ec:sc=\E7:\ :so=\E[7m:se=\E[0m:us=\E[4m:ue=\E[0m:ms:me=\E[0m:mr=\E[7m: # # -------------------------------- # # V: VISUAL # # The Visual 200 beeps when you type a character in insert mode. # This is a horribly obnoxious misfeature, and some of the entries # below try to get around the problem by ignoring the feature or # turning it off when inputting a character. They are said not to # work well at 300 baud. (You could always cut the wire to the bell!) #From mike@brl-vgr Mon Nov 14 08:34:29 1983 V2|vi200|vis200|visual 200 with function keys:\ :so=\E4:se=\E3:ms:do=^J:\ :al=\EL:am:le=^H:bs:cd=\Ey:ce=\Ex:cl=\Ev:\ :cm=\EY%+ %+ :co#80:dc=\EO:dl=\EM:ho=\EH:\ :im=:ei=:ic=\Ei \b\Ej:\ :is=\E3\Eb\Ej\E\\\El\EG\Ec\Ek:\ :k0=\EP:k1=\EQ:k2=\ER:k3=\E :k4=\E!:k5=\E":k6=\E#:\ :k7=\E$:k8=\E%:k9=\E&:kl=\ED:kr=\EC:ku=\EA:kd=\EB:kh=\EH:\ :li#24:nd=\EC:pt:sr=\EI:up=\EA:vs=\Ed:ve=\Ec: VR|vi200-rv-ic|visual 200 reverse video using insert char:\ :ei=\Ej:im=\Ei:ic@:tc=vi200-rv: # The older Visuals didn't come with function keys. This entry uses # ks and ke so that the keypad keys can be used as function keys. # If your version of vi doesn't support function keys you may want # to use V2. Vf|vi200-f|visual|visual 200 no function keys:\ :do=^J:al=\EL:am:le=^H:bs:cd=\Ey:ce=4*\Ex:cl=\Ev:\ :cm=\EY%+ %+ :co#80:dc=4*\EO:dl=4*\EM:ho=\EH:\ :im=:ei=:ic=\Ei \b\Ej:\ :is=\E3\Eb\Ej\E\\\El\EG\Ed\Ek:ks=\E=:ke=\E>:\ :k0=\E?p:k1=\E?q:k2=\E?r:k3=\E?s:k4=\E?t:k5=\E?u:k6=\E?v:\ :k7=\E?w:k8=\E?x:k9=\E?y:kl=\ED:kr=\EC:ku=\EA:kd=\EB:kh=\EH:\ :li#24:nd=\EC:pt:sr=\EI:up=\EA:vs=\Ed:ve=\Ec: Vr|vi200-rv|visual 200 reverse video:\ :so=\E4:se=\E3:sr@:vs@:ve@:tc=vi200: Vt|vi200-ic|visual 200 using insert char:\ :ei=\Ej:im=\Ei:ic@:tc=vi200: # From: jbs@athena.mit.edu Jeff Siegal V5|vi55|Visual 55:\ :im=\Ea:ei=\Eb:mi:dc=\Ew:dm=:ed=:al=\EL:dl=\EM:cs=\E_%+A%+A:\ :ho=\EH:cl=\Ev:is=\Ev\E_AX\Eb\EW\E9P\ET:so=\EU:se=\ET:ms:\ :do=^J:le=^H:bs:cd=\EJ:ce=\EK:cm=\EY%+ %+ :co#80:li#24:\ :nd=\EC:pt:sr=\EI:up=\EA:ku=\EA:kd=\EB:kr=\EC:kl=\ED:kb=^H: # # -------------------------------- # # X: TEKTRONIX # Xa|tek|tek4012|4012|tektronix 4012:\ :do=^J:is=\E^O:le=^H:bs:cl=1000\E^L:co#75:ns:li#35:os: Xb|tek4013|4013|tektronix 4013:\ :as=\E^N:ae=\E^O:dF#1000:tc=4012: Xc|tek4014|4014|tektronix 4014:\ :is=\E^O\E9:co#81:li#38:dF#1000:tc=tek4012: Xd|tek4015|4015|tektronix 4015:\ :as=\E^N:ae=\E^O:tc=4014: Xe|tek4014-sm|4014-sm|tektronix 4014 in small font:\ :is=\E^O\E\072:co#121:li#58:tc=tek4014: Xf|tek4015-sm|4015-sm|tektronix 4015 in small font:\ :as=\E^N:ae=\E^O:tc=4014-sm: # I think the 1000UP is supposed to be so expensive it never happens. X4|tek4023|4023|tex|tektronix 4023:\ :do=^J:so=^_P:se=^_@:cm=\034%r%+ %+ :nd=\t:le=^H:\ :bs:cl=4\E^L:co#80:li#24:am:up=1000UP:vt#4: # Can't use cursor motion because it's memory relative, and because # it only works in the workspace, not the monitor. Same for home. # Likewise, standout only works in the workspace. # 145 ms padding on al and AL taken out since it doesn't seem to be needed much. X5|4025|4027|4024|tek4025|tek4027|tek4024|4025cu|4027cu|tektronix 4024/4025/4027:\ :sf=^F^J:do=^F^J:is=\41com 31\r\n^_sto 9 17 25 33 41 49 57 65 73\r:\ :ks=^_lea p4 /h/\r^_lea p8 /k/\r^_lea p6 / /\r^_lea p2 /j/\r^_lea f5 /H/\r^_lea p5 /H/\r:\ :ke=^_lea p2\r^_lea p4\r^_lea p6\r^_lea p8\r^_lea p5\r^_lea f5\r:\ :am:le=^H:bs:da:db:pt:li#34:co#80:cl=^_era\r\n\n:up=^K:nd=^_rig\r:\ :al=^_up\r^_ili\r:dl=^_dli\r^F:\ :dc=^_dch\r:im=^_ich\r:ei=^F^_dow\r^K:nl=^F\n:\ :cd=^_dli 50\r:CC=^_:AL=^_up\r^_ili %d\r:DL=^_dli %d\r^F:\ :UP=^_up %d\r:DO=^_dow %d\r:LE=^_lef %d\r:RI=^_rig %d\r: X7|4025-17|4027-17|tek 4025 17 line window:\ :li#17:tc=4025: X8|4025-17ws|4027-17ws|tek 4025 17 line window in workspace:\ :is=\41com 31\r\n^_sto 9,17,25,33,41,49,57,65,73\r^_wor 17\r^_mon 17\r:\ :ti=^_wor h\r:te=^_mon h\r:so=^_att e\r:se=^_att s\r:tc=4025-17: X9|4025ex|4027ex|tek 4025 w/!:\ :ti=\41com 31\r:te=^_com 33\r:\ :is=^_com 33\r\n\41sto 9,17,25,33,41,49,57,65,73\r:tc=4025: # From jcoker@ucbic Xp|4107|tek4107|Tektronix 4107 graphics terminal with memory:\ :ti=\E[?6l\E[H\E[J:te=\E[?6h\E%!0\ELBP0\E%!1\E[32;1f:\ :is=\E%!0\ELBP0\E%!1\E[H\E[2g\EH\E[8C\EH\E[8C\EH\E[8C\EH\E[8C\EH\E[8C\EH\E[8C\EH\E[8C\EH\E[8C\EH\E[8C\EH\E[J:\ :li#32:do=^J:al=3\E[L:xn:am:le=^H:bs:cd=\E[J:\ :ce=5\E[K:cl=156\E[H\E[J:cm=\E[%i%d;%dH:co#80:dc=4\E[P:dl=3\E[M:\ :ho=\E[H:ic=4\E[@:md=\E[1m:mr=\E[7m:mb=\E[5m:me=\E[m:ku=\EM:\ :kd=\ED:kl=\E[D:kr=\E[C:kh=\E[H:\ :ei=:im=:pt:bw:bt=\E[Z:mi:nd=\E[C:se=\E[m:so=\E[7m:\ :ue=\E[m:us=\E[4m:up=\EM: # Tektronix 4107 with sysline Xq|4107-s|tek4107-s|Tektronix 4107 with sysline but no memory:\ :is=\E%!1\E[2;32r\E[132D\E[2g\EH\E[8C\EH\E[8C\EH\E[8C\EH\E[8C\EH\E[8C\EH\E[8C\EH\E[8C\EH\E[8C\EH\E[8C\EH\E[J:\ :es:hs:i2=\E7\E[?6l\E[2K\E[?6h\E8:ts=\E7\E[?6l\E[2K\E[;%i%df:\ :fs=\E[?6h\E8:ds=\E7\E[?6l\E[2K\E[?6h\E8:tc=4107: # From cbosg!teklabs!davem Wed Sep 16 21:11:41 1981 # Here's the comamnd file that I use to get rogue to work on the 4025. # It should work with any program using the old curses (e.g. it better # not try to scroll, or cursor addressing won't work. Also, you can't # see the cursor.) # (This "learns" the arrow keys for rogue. I have adapted it for termcap - mrh) Xr|4025-cr|tek 4025 for curses and rogue:\ :is=\41com 31\r\n^_sto 9 17 25 33 41 49 57 65 73\r:\ :am:le=^H:bs:pt:li#33:co#80:cm=^_jum%i%d,%d;:up=^K:\ :do=^F^J:cl=^_era;:nd=^_rig;:nl=^F\n:ti=^_wor 33h:te=^_wor 0: # next two lines commented out since curses only allows 128 chars, sigh. # :ti=^_lea p1/b/^_lea p2/j/^_lea p3/n/^_lea p4/h/^_lea p5/ /^_lea p6/l/^_lea p7/y/^_lea p8/k/^_lea p9/u/^_lea p./f/^_lea pt/`era w/13^_lea p0/s/^_wor 33h:\ # :te=^_lea p1^_lea p2^_lea p3^_lea p4^_lea pt^_lea p5^_lea p6^_lea p7^_lea p8^_lea p9/la/13^_lea p.^_lea p0^_wor 0: # The 4110 series may be a wonderful graphics series, but they make the 4025 # look good for screen editing. In the dialog area, you can't move the cursor # off the bottom line. Out of the dialog area, ^K moves it up, but there # is no way to scroll. Xs|4112|4114|tek4112|tektronix 4110 series:\ :is=\E3!1:li#34:co#80:am:al=\E[L:bs:bt=\E[Z:\ :cd=\E[0J:ce=\E[0K:cl=\E[2J\E[0;0H:cm=\E[%i%d;%dH:\ :db:dc=\E[P:dl=\E[M:ic=\E[@:im=:nd=\E[C:se=\E[m:\ :so=\E[7m:ue=\E[m:up=\EM:us=\E[4m:vs=:ve=:\ :sr=\E7\E[0;0H\E[L\E8:sf=\E7\E[0;0H\E[M\E8: Xt|4112-nd|4112 not in dialog area:up=^K:ns:tc=4112: Xu|4112-5|4112 in 5 line dialog area:li#5:tc=4112: Xv|4113|tek4113|tektronix 4113 color graphics, 5 line dialog area:\ :le=^H:do=^J:eo:da:bs:am:li#5:co#80:is=\EKA1\ELL5\ELV0\ELV1:\ :vb=\ERBA4\ERBA4\ERBA4\ERBA4\ERBA4\ERBA4\ERBA4\ERBA4\ERBA4\ERBA4\ERB0:\ :cl=\ELZ:uc=^H\ELM1_\ELM0:nd=\LM1 \LM0:\ :.as=\E^N:.ae=\E^O: Xw|4113-34|tek4113-34|tektronix 4113 color graphics, 34 line dialog area:\ :is=\EKA1\ELLB2\ELV0\ELV1:li#34:tc=tek4113: # ns hidden from vi to allow visual mode. APL font (as, ae) not supported here. # uc is slow, but looks nice. Suggest setenv MORE -up . vb needs enough delay # to let you see the background color being toggled. Xy|4113-nd|tek4113-nd|tektronix 4113 color graphics, no dialog area:\ :le=^H:do=^J:nd=\t:up=^K:ll=\ELF hl @:ho=\ELF7l\177 @:\ :eo:bs:am:li#34:co#80:is=\ELZ\EKA0\ELF7l\177 @:vs=\ELZ\EKA0:\ :vb=\ERBA4\ERBA4\ERBA4\ERBA4\ERBA4\ERBA4\ERBA4\ERBA4\ERBA4\ERBA4\ERB0:\ :cl=\E\f:uc=^H\EMG1_\EMG0:so=\EMT2:se=\EMT1:\ :.ns:.as=\E^N:.ae=\E^O: Xz|4105|tek4105:\ :al=\E[1L:am:bs:cd=\E[J:ce=\E[K:cl=\E[2J\E[H:cm=\E[%i%2;%2H:co#80:\ :dc=\E[1P:dl=\E[1M:dn=\E[1B:ho=\E[H:im=\E[4h:li#30:mi:nd=\E[1C:\ :as=\E[1m:ae=\E[0m:ms:pt:se=\E[0m:so=\E[7m:up=\E[1A:kb=^h:ku=\E[1A:\ :kd=\E[1B:kl=\E[1D:kr=\E[1C:us=\E[4m:ue=\E[0m:is=\E%!1\E[?6l\E[0m:\ :mr=\E[<3m:md=\E[<4m:mh=\E[<6m:mb=\E[<7m:me=\E[<1m:ti=\E%!1\E[?6l:xt: # This entry is from Tek. Inc. (Brian Biehl) Xz|4115|tek4115|Tektronix 4115:\ :co#80:li#34:\ :al=\E[L:am:bc=\E[D:bs:bt=\E[Z:cd=\E[J:ce=\E[K:\ :cl=\E[;H\E[2J:cm=\E[%i%d;%dH:da:db:dc=\E[P:dl=\E[M:do=\E[B:\ :ei=\E[4l:eo:ho=\E[;H:im=\E[4h:if=/usr/share/tabset/vt100:\ :is=\E%\0410\E%\014\ELV0\EKA1\ELBB2\ENU@\075\ELLB2\ELM0\ELV1\EKYA?\E%\0411\E[<1l\E[?7h\E[?8h\E[34;1H\E[34B\E[0m:\ :kb=^H:ke=\E>:ks=\E=:nd=\E[C:pt:se=\E[m:so=\E[7m:sr=\EM:\ :te=\E%\0410\ELBG8\E%\0411\E[34;1H\E[J: :ti=\E%\0410\ELBB2\E%\0411:\ :ue=\E[m:up=\E[A:us=\E[4m:\ :ve=\E%\0410\ELBG8\E%\0411\E[34;1H:\ :vs=\E%\0410\ELBB2\E%\0411: # The tek4125 emulates a vt100 incorrectly - the scrolling region # command is ignored. The following entry replaces the cs with the # needed al, dl, and im; removes some cursor pad commands that the tek4125 # chokes on; and adds a lot of initialization for the tek dialog area. # Note that this entry uses all 34 lines and sets the cursor color to green. # Steve Jacobson 8/85 XB|tek4125:\ :ks=\E=:li#34:\ :is=\E%\!0\EQD1\EUX03\EKA\ELBB2\ELCE0\ELI100\ELJ2\ELLB2\ELM0\ELS1\ELX00\ELV1\E%\!1\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h:dl=\E[1M:\ :al=\E[1L:cs@:sc@:rc@:im=\E1:tc=vt100: # From carolyn@dali.berkeley.edu Thu Oct 31 12:54:27 1985 XA|4404|tek4404:\ :al=\E[1L:bs:cd=\E[J:ce=\E[K:cl=\E[;H\E[2J:cm=\E[%i%d;%dH:co#80:\ :cs=\E[%i%d;%dr:dc=\E[P:dl=\E[1M:do=^J:ei=\E[4l:ho=\E[H:im=\E[4h:\ :kd=\E[B:ke=\E[?1h:kl=\E[D:kr=\E[C:ks=\E[?1l:ku=\E[A:li#32::mb=\E[5m:\ :md=\E[1m:me=\E[m:nd=\E[C:pt:rc=\E8:sc=\E7:se=\E[27m:so=\E[7m:\ :ta=\E[2I:ti=\E%\!1\E[1;32r\E[?6l\E>:te=\E[1;1H\E[0J\E[?6h\E[?1l:\ :ue=\E[m:up=\E[A:us=\E[4m: # # -------------------------------- # # Z: Miscellaneous # # These compucolors appear similar, but they at least have different # sized screens. I don't know what's going on here. Z1|8001|ISC8001|compucolor|intecolor:\ :do=^J:al=\EU:am:le=^Z:bc=^Z:cl=3*^L:cm=^C%r%.%.:\ :co#80:cd=\EQ:dm=\EQ:ed=\EF:dc=\177:dl=\EV:ei=\EF:\ :im=\EQ:li#40:nd=1^Y:ta=8\t:up=^\:ho=1^H:pc=^@: Z2|compucolor2|compucolorII:\ :do=^J:pt:am:cm=%r^C%.%.:le=^Z:bc=^Z:li#32:co#64:\ :cl=^L:ho=^H:nd=^Y:up=^\: # From cithep!eric Wed Sep 16 08:06:44 1981 Z3|intext|Interactive Systems Corporation modified owl 1200:\ :do=^J:al=5.5*\020:am:le=^_:bc=^_:le=^H:bs:bt=^Y:cd=5.5*\026J:\ :ce=^K\160^R:cl=132\014:cm=\017%+ %+ :co#80:dc=5.5*\022:dl=5.5*\021:\ :ei=\026\074:im=\026\073:ip=5.5*:li#24:nd=\036:pt:up=\034:\ :se=^V# :sg#1:so=^V$,:ma=^K^P^R^L^L :\ :kl=^_:kd=^J:kr=^^:ku=\034:kb=^H:kh=^Z:\ :k1=^VA\r:k2=^VB\r:k3=^VC\r:k4=^VD\r:k5=^VE\r:\ :k6=^VF\r:k7=^VG\r:k8=^VH\r:k9=^VI\r:k0=^VJ\r: # # -------------------------------- # # a: ADDS # # Regent: lowest common denominator, works on all regents. a0|regent|Adds Regent Series:li#24:co#80:am:cl=^L:ll=^A:up=^Z:\ :bs:bc=^U:nd=^F:do=^J:ho=\EY : # Regent 100 has a bug where if computer sends escape when user is holding # down shift key it gets confused, so we avoid escape. a1|regent100|Adds Regent 100:k0=^B1^M:k1=^B2^M:k2=^B3^M:k3=^B4^M:\ :k4=^B5^M:k5=^B6^M:k6=^B7^M:k7=^B8^M:\ :l0=F1:l1=F2:l2=F3:l3=F4:l4=F5:l5=F6:l6=F7:l7=F8:\ :so=\E0P:ue=\E0@:us=\E0`:se=\E0@:\ :cm=^K%+ %B^P%.:ug#1:sg#1:tc=regent: a2|regent20|Adds Regent 20:cd=\Ek:ce=\EK:cm=\EY%+ %+ :tc=regent: a3|regent25|Adds Regent 25:kh=^A:kl=^U:kr=^F:ku=^Z:kd=^J:tc=regent20: a4|regent40|Adds Regent 40:k0=^B1^M:k1=^B2^M:k2=^B3^M:k3=^B4^M:\ :k4=^B5^M:k5=^B6^M:k6=^B7^M:k7=^B8^M:\ :l0=F1:l1=F2:l2=F3:l3=F4:l4=F5:l5=F6:l6=F7:l7=F8:\ :al=2*\EM:dl=2*\El:\ :so=\E0P:ue=\E0@:us=\E0`:se=\E0@:ug#1:sg#1:tc=regent25: a5|regent40+|Adds Regent 40+:is=\EB:tc=regent40: a6|regent60|regent200|Adds Regent 60:se=\ER\E0@\EV:so=\ER\E0P\EV:dc=\EE:ei=\EF:\ :im=\EF:is=\EV\EB:ko=dc,im,ei:tc=regent40+: a7|regent60na|regent 60 w/no arrow keys:\ kl@:kr@:ku@:kd@:tc=regent60: # # adds viewpoint 90 - from cornell # Note: emacs sends ei occasionally to insure the terminal is out of # insert mode. This unfortunately puts the viewpoint90 IN insert # mode. A hack to get around this is: ic=\EF \EF^U. (Also, # - ei=:im=: must be present.) # - xs indicates glich that attributes stick to location # - bs save to move in standout mode # - cl=\EG\Ek clears screen and visual attributes without affecting # the status line a9|vp90|viewpoint90|adds viewpoint 90:\ :bs:bw:cd=\Ek:ce=\EK:cl=\EG\Ek:cm=\EY%+ %+ :co#80:\ :dc=\EE:dl=\El:dm=:do=^J:ed=:ei=:im=:ic=\EF \EF^U:ho=\EY :\ :nd=^F:up=^Z:\ :kb=^H:kd=^J:kh=^A:kl=^U:kr=^F:ku=^Z:li#24:ll=^A:\ :so=\ER\E0Q\EV:se=\ER\E0@\EV:\ :us=\ER\E0`\EV:ue=\ER\E0@\EV:\ :xs:ms: # Note: if return acts weird on a980, check internal switch #2 # on the top chip on the CONTROL pc board. ac|a980|adds consul 980:\ :do=^J:al=13\E^N:am:le=^H:bs:cl=^L\200^K@:cm=^K%+@\E^E%2:co#80:\ :dl=13\E^O:k0=\E0:k1=\E1:k2=\E2:k3=\E3:k4=\E4:k5=\E5:k6=\E6:k7=\E7:\ :k8=\E8:k9=\E9:li#24:nd=\E^E01:so=^Y^^^N:se=^O:up=9: as|viewpt60|viewpoint60|addsviewpoint60|adds viewpoint60:\ :tc=regent40: # From Onyx:edward Thu Jul 9 09:27:33 1981 av|viewpoint|addsviewpoint|adds viewpoint:\ :do=^J:am:le=^H:bs:li#24:co#80:cm=\EY%+ %+ :cd=\Ek:ce=\EK:\ :up=^Z:cl=^L:ll=^A:kl=^U:kd=^J:ku=^Z:kh=^A:\ :so=^N:se=^O:us=^N:ue=^O:is=^O\E0`:vs=^O\E0P:ve=^O\E0`: # # -------------------------------- # # b: BEEHIVE # # Reports are that most of these Beehive entries (except superbee) have not been # tested and do not work right. se is a trouble spot. Be warned. b2|sb2|sb3|fixed superbee:\ :xb@:tc=superbee: # set tab is ^F, clear (one) tab is ^V, no way to clear all tabs. # good grief - does this entry make sg/ug when it doesn't have to? # look at those spaces in se/so. Seems strange to me... bh|bh3m|beehiveIIIm:\ :if=/usr/share/tabset/beehive:do=^J:\ :al=160^S:am:le=^H:bs:cd=^R:ce=^P:cl=^E^R:\ :co#80:dl=350^Q:ho=^E:li#20:ll=^E^K:\ :nd=^L:pt:se= ^_:so=^] :up=^K: # This loses on lines > 80 chars long, use at your own risk bi|superbeeic|super bee with insert char:\ :ic=:im=\EQ:ei=\ER:tc=superbee: bm|microb|microbee|micro bee series:\ :do=^J:am:le=^H:bs:cd=\EJ:ce=\EK:cl=\EE:co#80:cm=\EF%+ %+ :\ :k1=\Ep:k2=\Eq:k3=\Er:k4=\Es:k5=\Et:k6=\Eu:k7=\Ev:k8=\Ew:k9=\Ex:\ :kd=\EB:kh=\EH:kl=\ED:kr=\EC:ku=\EA:\ :li#24:nd=\EC:pt:se=\Ed@ :so= \EdP:ue=\Ed@:up=\EA:us=\Ed`: # Superbee - f1=escape, f2=^C. # Note: there are at least 3 kinds of superbees in the world. The sb1 # holds onto escapes and botches ^C's. The sb2 is the best of the 3. # The sb3 puts garbage on the bottom of the screen when you scroll with # the switch in the back set to CRLF instead of AEP. This description # is tested on the sb2 but should work on all with either switch setting. # The f1/f2 business is for the sb1 and the :xb: can be taken out for # the other two if you want to try to hit that tiny escape key. # This description is tricky: being able to use cm depends on there being # 2048 bytes of memory and the hairy nl string. bs|sb1|superbee|superb|beehive super bee:\ :ct=\E3:st=\E1:is=\EH\EJ:do=^J:\ :sf=\n\200\200\200\n\200\200\200\EA\EK\200\200\200\ET\ET:\ :am:le=^H:bs:cd=3\EJ:ce=3\EK:cl=3\EH\EJ:co#80:cm=\EF%r%3%3:cr=1000\r:\ :dC#10:da:db:xb:dc=3\EP:dl=100\EM:so=\E_1:se=\E_3:\ :li#25:nl=\n\200\200\200\n\200\200\200\EA\EK\200\200\200\ET\ET:\ :nd=\EC:pt:up=\EA:ho=\EH:ve=\n:\ :k1=\Ep:k2=\Eq:k3=\Er:k4=\Es:k5=\Et:k6=\Eu:k7=\Ev:k8=\Ew:\ :kd=\EB:kh=\EH:kl=\ED:kr=\EC:ku=\EA: # 8675, 8686, and bee from Cyrus Rahman b7|8675|harris 8675:\ :k1=^F:k2=^P:k3=^N:k4=^V:k5=^J:k6=^T:k7=^H:k8=\177:k9=\Ee:k10=\Ed:\ :k11=^W:k12=\ER:k13=\EE:k14=\EI:k15=\Ei:k16=\Eg:\ :is=\ES\E#\E*\Eh\Em\E?\E1\E9\E@\EX\EU:\ :tc=bee: b8|8686|harris 8686:\ :k1=^B^[p^C:k2=^B^[q^C:k3=^B^[r^C:k4=^B^[s^C:k5=\E3:\ :k6=\EI:k7=\ER:k8=\EJ:k9=\E(:k10=\Ej:k11=\EW:\ :k12=^B^[{^C:k13=^B^[|^C:k14=^B^[}^C:k15=^B^[~^C:k16=^B^[\177^C:\ :is=\ES\E#\E*\Eh\Em\E?\E1\E9\E@\EX\EU\E"*Z01\ \E"8F35021B7C83#\E"8F45021B7D83#\E"8F55021B7E83#\E"8F65021B7F83#\ \E"8F75021B7383#\E"8F851BD7#\E"8F95021B7083#\E"8FA5021B7183#\ \E"8FB5021B7283#:\ :tc=bee: be|bee|harris beehive:\ :co#80:li#24:am:bs:cd=\EJ:ce=\EK:cl=\EE:nd=\EC:\ :cm=\EF%+ %+ :up=\EA:do=\EB:ho=\EH:bt=\E>:\ :al=\EL:dc=\EP:dl=\EM:ei=\E@:im=\EQ:ic=:mi:\ :kl=\ED:kr=\EC:ku=\EA:kd=\EB:kh=\EH:kb=^H:\ :us=\Ed`:ue=\Ed@:so=\EdP:se=\Ed@:\ :ko=al,bt,ce,cl,dc,dl,ei,ho,ic,im: # # -------------------------------- # # c: CONCEPT (HUMAN DESIGNED SYSTEMS) # # From vax135!hpk Sat Jun 27 07:41:20 1981 # Extensive changes to c108 by arpavax:eric Feb 1982 # # There seem to be a number of different versions of the C108 PROMS # (with bug fixes in its Z-80 program). # The first one that we had would lock out the keyboard of you # sent lots of short lines (like /usr/dict/words) at 9600 baud. # Try that on your C108 and see if it sends a ^S when you type it. # If so, you have an old version of the PROMs. # The old one also messed up running vi with a 132-character line-length. # You should configure the C108 to send ^S/^Q before running this. # It is much faster (at 9600 baud) than the c100 because the delays # are not fixed. # new status line display entries for c108: # hs - has status capability # es - escape sequences are OK on status line # i2 - second init str - setup term for status display - set programmer mode, # select window 2, define window at last line of memory, # set bkgnd stat mesg there, select window 0. # ts - to status line - select window 2, home cursor, erase to end-of-window, # 1/2 bright on, goto(line#0, col#?) # fs - from status line - 1/2 bright off, select window 0 # ds - disable status display - set bkgnd status mesg with illegal window # # # the following two entries are for emacs -- they are just like the regular # entries except that they have buffer overflow control OFF c0|e108-8p:\ :i2=\EU\E z"\Ev^A\177 !p\E ;"\E z \Ev ^A\177p\Ep\n:\ :te=\Ev ^A\177p\Ep\r\n:tc=e108-4p: c1|e108-4p:\ :is=\EU\E f\Ef\E7\E5\E8\El\ENH\EK\E\200\Eo&\200\Eo\47\E\E!\E^G!\E^HA@ :\ :tc=c108-4p: c2|c108|c108-8p|concept108-8p|concept 108 w/8 pages:\ :i2=\EU\E z"\Ev^A\177 !p\E ;"\E z \Ev ^A\177p\Ep\n:\ :te=\Ev ^A\177p\Ep\r\n:tc=c108-4p: c3|c108-4p|concept108-4p|concept 108 w/4 pages:\ :es:hs:ts=\E z"\E?\E^C\Ea %+ :fs=\E z :ds=\E ;\177:\ :i2=\EU\E z"\Ev\177 !p\E ;"\E z \Ev \177p\Ep\n:do=^J:pt:\ :is=\EU\E F\Ef\E7\E5\E8\El\ENH\EK\E\200\Eo&\200\Eo\47\E\E!\E^G!\E^HA@ :\ :ti=\EU\Ev 8p\Ep\r:te=\Ev \177p\Ep\r\n:\ :al=\E^R:le=^H:bs:cd=\E^C:ce=\E^S:cl=\E?\E^E:cm=\Ea%+ %+ :co#80:\ :dc=\E^Q:dl=\E^B:ei=\E\200:eo:im=\E^P:li#24:mi:nd=\E=:\ :kb=^h:up=\E;:db:us=\EG:ue=\Eg:vs=\EW:ve=\Ew:am:xn:\ :vb=\Ek\200\200\200\200\200\200\200\200\200\200\200\200\200\200\EK:\ :ks=\EX:ke=\Ex:ku=\E;:kd=\E<:kl=\E>:kr=\E=:kh=\E?:\ :k1=\E5:k2=\E6:k3=\E7:k4=\E8:k5=\E9:k6=\E\72:\ :so=\ED:se=\Ed:mh=\EE:md=\ED:mr=\ED:me=\Ee\Ed\Eg\Ec: c4|c108-rv-8p|concept108-rv-8p|concept 108 w/8 pages, in reverse video:\ :vb=\EK\200\200\200\200\200\200\200\200\200\200\200\200\200\200\Ek:\ :is=\EU\E F\Ef\E7\E5\E8\El\ENH\Ek\E\200\Eo&\200\Eo\47\E\E!\E^G!\E^HA@ :\ :ts=\E z"\E?\E^C\EE\Ea %+ :fs=\Ee\E z :tc=c108-8p: c5|c108-rv-4p|concept108-rv-4p|concept 108 w/4 pages, in reverse video:\ :vb=\EK\200\200\200\200\200\200\200\200\200\200\200\200\200\200\Ek:\ :is=\EU\E F\Ef\E7\E5\E8\El\ENH\Ek\E\200\Eo&\200\Eo\47\E\E!\E^G!\E^HA@ :\ :ts=\E z"\E?\E^C\EE\Ea %+ :fs=\Ee\E z :tc=c108-4p: c6|c108-na|c108-na-8p|concept108-na-8p|concept 108 w/8 pages, no arrows:\ :ks@:ke@:k7=\E;:k8=\E<:k9=\E=:tc=c108-8p c7|c108-rv-na|c108-rv-na-8p|concept 108 w/8 pages, no arrows in rev video:\ :ts=\E z"\E?\E^C\EE\Ea %+ :fs=\Ee\E z :\ :ks@:ke@:k7=\E;:k8=\E<:k9=\E=:tc=c108-rv-8p # this needs new frotz in the cm capability for 2-char addrs when > 95.... c8|c108-w|c108-w-8p|concept108-w-8p|concept 108 w/8 pages in wide mode:\ :is=\EU\E F\Ef\E7\E5\E8\El\ENH\EK\E\200\Eo&\200\Eo\47\E\E"\E^G!\E^HA@ :\ :ti=\EU\Ev 8^AD\Ep\r:te=\Ev ^A0^AD\Ep\r\n:pt@:cm@:\ :co#132:tc=c108-8p cA|avt-w|avtw|HDS concept avt w/4 or 8 pages; 132 columns:\ :is=\E[1*q\E[2!t\E[7!t\E[=4;101;119l\E[=103;107;118;207h\E)1\E[1Q\EW\E[7!y\E[0\0720\07232!r\E[w\E2\r\n:\ :ch=\E[%i%3G:cm=\E[%i%2;%3H:co#132:tc=avt: cB|avt-8p-s|concept avt w/8 pages & 80 cols running sysline:\ :is=\E[1*q\E[2!t\E[7!t\E[=4;101;103;119l\E[=107;118;207h\E)1\E[1Q\EW\E[0!y\E[0\0720\07232!r\E[2!w\E[192w\E[2*w\E[!w\E[1;191w\E2\r\n:\ :hs:es:ts=\E[2!w\E[H\E[J\E[%i%dG:fs=\E[!w:\ :ds=\E[2!w\E[2J\E[!w\E[*w:te=\E[1;191w\E2\n:tc=avt: cC|avt-4p-s|concept avt w/4 pages & 80 cols running sysline:\ :is=\E[1*q\E[2!t\E[7!t\E[=4;101;103;119l\E[=107;118;207h\E)1\E[1Q\EW\E[0!y\E[0\0720\07232!r\E[2!w\E[96w\E[2*w\E[!w\E[1;95w\E2\r\n:\ :hs:es:ts=\E[2!w\E[H\E[J\E[%i%dG:fs=\E[!w:\ :ds=\E[2!w\E[2J\E[!w\E[*w:te=\E[1;95w\E2\n:tc=avt: cD|avt-rv|HDS concept avt w/4 or 8 pages, 80 columns, reverse video:\ :is=\E[1*q\E[2!t\E[7!t\E[=4;101;103;119l\E[=107;118;205;207h\E)1\E[1Q\EW\E[0!y\E[0\0720\07232!r\E[w\E2\r\n:\ :ve=\E[4l:vs=\E[4l:tc=avt cE|avt|HDS concept avt w/4 or 8 pages, 80 columns:\ :is=\E[1*q\E[2!t\E[7!t\E[=4;101;103;119;205l\E[=107;118;207h\E)1\E[1Q\EW\E[0!y\E[0\0720\07232!r\E[w\E2\r\n\E[*w:\ :ae=^O:al=\E[L:am:as=^N:bs:bt=\E[Z:cd=\E[J:ce=\E[K:\ :ch=\E[%i%2G:cl=\E[H\E[J:cm=\E[%i%2;%2H:co#80:cv=\E[%i%2d:\ :dc=\E[P:dl=\E[M:do=\E[B:ei=\E1:eo:ho=\E[H:im=\E1:kb=^H:kd=\E[B:\ :kh=\E[H:kl=\E[D:ko=do,ho,nd,up:kr=\E[C:\ :ks=\E[1;4!z\E[1;8!z\E[1;10!z\E[1;11!z\E[1;12!z\E[1;14!z\E[3;7!z\E[3;9!z:\ :ke=\E[;4!z\E[;8!z\E[;10!z\E[;11!z\E[;12!z\E[3;14!z\E[;7!z\E[;9!z:\ :ku=\E[A:li#24:mi:nd=\E[C:pt:se=\E[7!{:so=\E[7m:\ :te=\E[w\E2\n:ti=\E[1;24w\E2\n:ue=\E[4!{:\ :up=\E[A:us=\E[4m:ve=\E[=4;119l:vs=\E[4l\E[=119h:xn: # # Concepts have only window relative cursor addressing, not screen relative. # To get it to work right here, ti/te (which were invented for the concept) # lock you into a one page window for screen style programs. To get out of # the one page window, we use a clever trick: we set the window size to zero # ("\Ev " in te) which the terminal recognizes as an error and resets the # window to all of memory. # # Some tty drivers use cr3 for concept, others use nl3, hence dN/dC below. # This padding is only needed at 9600 baud. # 2 nulls padding on te isn't always enough. 6 works fine. Maybe less # than 6 but more than 2 will work. ca|c100|concept|c1004p|c100-4p|concept100|concept 100:\ :is=\EU\Ef\E7\200\200\E5\E8\200\200\El\ENH\EK\E\200\Eo&\200\Eo\47\E\E^G\041\E^HA@ :\ :ti=\EU\Ev 8p\Ep\r:te=\Ev \200\200\200\200\200\200\Ep\r\n:\ :al=3*\E^R:am:le=^H:bs:cd=16*\E^C:ce=16\E^U:cl=2*^L:cm=\Ea%+ %+ :co#80:\ :dc=16\E^Q:dl=3*\E^B:ei=\E\200:eo:im=\E^P:ip=16*:li#24:mi:nd=\E=:\ :pt:kb=^h:ta=8\t:up=\E;:db:us=\EG:ue=\Eg:xn:\ :vb=\Ek\200\200\200\200\200\200\200\200\200\200\200\200\200\200\EK:\ :.dN#9:dC#9:pb#9600:vt#8:us=\EG:ue=\Eg:so=\EE\ED:se=\Ed\Ee:\ :mh=\EE:mr=\ED:mb=\EC:mp=\EI:mk=\EH:me=\EN\200:do=^J:\ :ks=\EX:ke=\Ex:ku=\E;:kd=\E<:kl=\E>:kr=\E=:kh=\E?:k1=\E5:k2=\E6:k3=\E7: cb|c100-rv-pp|c100-rv-4p-pp|concept100-rv-pp|c100rv4ppp|w/ printer port:\ :is=\EU\Ef\E7\200\200\E5\E8\200\200\El\ENH\Ek\E\200\Eo&\200\Eo\041\200\EQ"\EY(^W\Eo\47\E\E^G\041\E^HA@ :\ :tc=c100-rv: cc|c100-rv-na|c100-rv-4p-na|concept100-rv-na|c100rv4pna|c100 with no arrows:\ :ks@:ke@:tc=c100-rv: cd|c100-rv|c100-rv-4p|concept100-rv|c100rv4p|c100rv|c100 rev video:\ :is=\EU\Ef\E7\200\200\E5\E8\200\200\El\ENH\Ek\E\200\Eo&\200\Eo\47\E\E^G\041\E^HA@ :\ :vb=\EK\200\200\200\200\200\200\200\200\200\200\200\200\200\200\Ek:\ :so=\EE:se=\Ee:tc=c100: # This is useful at 1200 baud. ce|c100-s|concept-s|concept100-s|slow concept 100:\ :vb=\Ek\200\EK:pt:dC@:dN@:tc=c100: cf|c100-rv-s|concept-rv-s|concept100-rv-s|c100rvs|slow reverse concept 100:\ :vb=\EK\200\Ek:pt:dC@:dN@:tc=c100-rv: # # -------------------------------- # # d: DEC (DIGITAL EQUIPMENT CORPORATION) # # Note that xn glitch in vt100 is not quite the same as concept, since # the cursor is left in a different position while in the weird state # (concept at beginning of next line, vt100 at end of this line) so # all versions of vi before 3.7 don't handle xn right on vt100. # I assume you have smooth scroll off or are at a slow enough baud # rate that it doesn't matter (1200? or less). Also this assumes # that you set auto-nl to "on", if you set it off use vt100-nam below. # # Since there are two things here called vt100, the installer can make # a local decision to make either one standard "vt100" by including # it in the list of terminals in reorder, since the first vt100 in # /etc/termcap is the one that it will find. The choice is between # nam (no automatic margins) and am (automatic margins), as determined # by the wrapline switch (group 3 #2). I presonally recommend turning # on the bit and using vt100-am, since having stuff hammer on the right # margin is sort of hard to read. However, the xn glitch does not occur # if you turn the bit off. # # I am unsure about the padding requirements listed here. I have heard # a claim that the vt100 needs no padding. It's possible that it needs # padding only if the xon/xoff switch is off. For UNIX, this switch # should probably be on. # # The vt100 uses rs and rf rather than is/ct/st because the tab settings # are in non-volatile memory and don't need to be reset upon login. # You can type "reset" to get them set. dp|vt100-np|vt100 with no padding (for psl games):\ :cl=\E[H\E[2J:sr=\EM:cm=\E[%i%d;%dH:nd=\E[C:up=\E[A:\ :ce=\E[K:cd=\E[J:so=\E[7m:se=\E[m:us=\E[4m:ue=\E[m:\ :md=\E[1m:mr=\E[7m:mb=\E[5m:me=\E[m:tc=vt100: d0|vt100|vt100-am|vt100am|dec vt100:\ :do=^J:co#80:li#24:cl=50\E[;H\E[2J:sf=2*\ED:\ :le=^H:bs:am:cm=5\E[%i%d;%dH:nd=2\E[C:up=2\E[A:\ :ce=3\E[K:cd=50\E[J:so=2\E[7m:se=2\E[m:us=2\E[4m:ue=2\E[m:\ :md=2\E[1m:mr=2\E[7m:mb=2\E[5m:me=2\E[m:is=\E[1;24r\E[24;1H:\ :rf=/usr/share/tabset/vt100:\ :rs=\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h:ks=\E[?1h\E=:ke=\E[?1l\E>:\ :ku=\EOA:kd=\EOB:kr=\EOC:kl=\EOD:kb=^H:\ :ho=\E[H:k1=\EOP:k2=\EOQ:k3=\EOR:k4=\EOS:pt:sr=2*\EM:vt#3:xn:\ :sc=\E7:rc=\E8:cs=\E[%i%d;%dr: d1|vt100-nam|vt100nam|vt100 w/no am:\ :am@:xn@:\ :is=\E>\E[?3l\E[?4l\E[?5l\E[?7l\E[?8h:ks=\E[?1h\E=:ke=\E[?1l\E>:\ :tc=vt100-am: d2|gt42|dec gt42:\ :do=^J:le=^H:bs:co#72:ns:li#40:os: d3|vt132|vt132:\ :al=99\E[L:dl=99\E[M:ip=7:dc=7\E[P:ei=\E[4l:im=\E[4h:xn:dN#30:tc=vt100: d4|gt40|dec gt40:\ :do=^J:le=^H:bs:co#72:ns:li#30:os: d5|vt50|dec vt50:\ :do=^J:le=^H:bs:cd=\EJ:ce=\EK:cl=\EH\EJ:co#80:li#12:nd=\EC:pt:up=\EA: d6|vt125|vt125-am|DEC vt125:\ :xn:do=^J:co#80:li#24:cl=50\E[H\E[2J:dC=10:dN=10:\ :le=^H:am:bs:cm=5\E[%i%d;%dH:nd=2\E[C:up=2\E[A:ce=3\E[K:cd=50\E[J:\ :so=2\E[7m:se=2\E[m:us=2\E[4m:ue=2\E[m:md=2\E[1m:mr=2\E[7m:mb=2\E[5m:\ :me=2\E[m:is=\E[1;24r\E[24;1H\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h:\ :ks=\E[?1h\E=:ke=\E[?1l\E>:if=/usr/share/tabset/vt100:ku=\EOA:kd=\EOB:\ :kr=\EOC:kl=\EOD:kb=^H:ho=\E[H:k1=\EOP:k2=\EOQ:k3=\EOR:k4=\EOS:\ :pt:sr=5\EM:vt#3:sc=\E7:rc=\E8:cs=\E[%i%d;%dr: d9|vt125-nam|DEC vt125 no automatic margin:\ :am@:tc=vt125-am: # DEC gigi color graphic terminal, same as vt52 d7|gigi|dec gigi terminal:\ :co#80:is=200\E>\E[?4l\E[?5l\E[?7h\E[?8h:\ :li#24:cl=100\E[;H\E[2J:bs:cm=50\E[%i%2;%2H:nd=200\E[C:up=100\E[A:\ :ce=120\E[K:cd=100\E[J:so=20\E[7m:se=20\E[m:us=20\E[4m:ue=20\E[m:\ :ks=200\E[?1h\E=:ke=200\E[?1l\E>:\ :ku=\EOA:kd=\EOB:kr=\EOC:kl=\EOD:\ :kh=\E[H:k1=\EOP:k2=\EOQ:k3=\EOR:k4=\EOS:pt:sr=200\EM:\ :dC=50:dF=200:dN=50:dT=50: dI|dw1|decwriter I:\ :do=^J:le=^H:bs:co#72:hc:os: # From tut@Topaz.CC Thu May 12 14:49:02 1983 dJ|dw3|la120|decwriter III:\ :bs:kb=^H:co#132:hc:os:pt:\ :is=\E(B\E[20l\E[w\E[1;132s\E[2g\E[9;17;25;33;41;49;57;65;73;81;89;97;105;113;121;129u\E[z\E[66t\E[1;66r\E[4g\E>\r: # From tut@topaz.CC Thu Sep 24 22:10:46 1981 df|dw4|decwriter IV:\ :do=^J:le=^H:bs:co#132:hc:os:am:\ :pt:is=\Ec:k0=\EOP:k1=\EOQ:k2=\EOR:k3=\EOS:kb=^H: dh|vt50h|dec vt50h:\ :do=^J:le=^H:bs:cd=\EJ:ce=\EK:cl=\EH\EJ:cm=\EY%+ %+ :\ :co#80:li#12:nd=\EC:pt:sr=\EI:up=\EA: di|vt100-s|vt100 with status line at top:\ :li#23:i2=\E[2;24r\E[24;1H:cm@:ho=\E[H^J:cl=50\E[;H^J\E[0J:\ :hs:es:ts=\E7\E[1;%dH\E[1K:fs=\E8:tc=vt100-am: dj|vt100-s-bot|vt100 with status line at bottom:\ :li#23:i2=\E[1;23r\E[23;1H:\ :hs:es:ts=\E7\E[24;%dH\E[1K:fs=\E8:tc=vt100-am: ds|vt100-nav|dec vt100 132 cols 14 lines (w/o advanced video option):\ :li#14:tc=vt100-w: dt|vt100-w|dec vt100 132 cols (w/advanced video):\ :co#132:li#24:rs=\E>\E[?3h\E[?4l\E[?5l\E[?8h:tc=vt100-am: dv|vt100-w-nam|dec vt100 132 cols (w/advanced video), no am:\ :co#132:li#24:rs=\E>\E[?3h\E[?4l\E[?5l\E[?8h:vt@:tc=vt100-nam: d8|vt102|vt100 w/adv. video:\ :al=\E[1L:dl=\E[1M:im=\E[4h:ei=\E[4l:mi:dc=\E[1P:ku=\EOA:kd=\EOB:\ :kr=\EOC:kl=\EOD:k0=\EOp:k1=\EOq:k2=\EOr:k3=\EOs:k4=\EOt:k5=\EOu:\ :k6=\EOv:k7=\EOw:k8=\EOx:k9=\EOy:as=\E(0:ae=\E(B:am@:xn@:tc=vt100am: # (from lai@decwrl) should be a vt102, but have heard enough # unsubstantiated complaints to make it an alternate (obsolete) version dy|vt102-obs|dec vt102:\ :do=^J:co#80:li#24:cl=50\E[;H\E[2J:\ :le=^H:bs:cm=5\E[%i%d;%dH:nd=2\E[C:up=2\E[A:\ :ce=3\E[K:cd=50\E[J:so=2\E[7m:se=2\E[m:us=2\E[4m:ue=2\E[m:\ :md=2\E[1m:mr=2\E[7m:mb=2\E[5m:me=2\E[m:is=\E[1;24r\E[24;1H:\ :rs=\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h:ks=\E[?1h\E=:ke=\E[?1l\E>:\ :ku=\EOA:kd=\EOB:kr=\EOC:kl=\EOD:kb=^H:\ :ho=\E[H:k1=\EOP:k2=\EOQ:k3=\EOR:k4=\EOS:pt:sr=5\EM:vt#3:\ :sc=\E7:rc=\E8:cs=\E[%i%d;%dr:vs=\E[?7l:ve=\E[?7h: dw|vt52|dec vt52:\ :do=^J:le=^H:bs:cd=\EJ:ce=\EK:cl=\EH\EJ:cm=\EY%+ %+ :co#80:li#24:\ :nd=\EC:pt:sr=\EI:up=\EA:ku=\EA:kd=\EB:kr=\EC:kl=\ED:kb=^H: # vt61 created by Roger Sacilotto Massachusetts Computer Associates, Inc # Similar to vt52 but add al and dl # dq|vt61|dec vt61:\ :al=\EPf:dl=\EPd:tc=vt52: dx|dw2|decwriter II:\ :do=^J:kb=^h:le=^H:bs:co#132:hc:os: # DEC PRO-350 console (VT220-style) dP|pro350|decpro|dec pro console:\ :bs:cd=\EJ:ce=\EK:cl=\EH\EJ:\ :cm=\EY%+ %+ :co#80:ho=\EH:\ :kl=\ED:kr=\EC:ku=\EA:kd=\EB:kh=\EH:\ :k0=\EE:k1=\EF:k2=\EG:k3=\EH:k4=\EI:k5=\EJ:k6=\Ei:k7=\Ej:\ :li#24:nd=\EC:pt:sr=\EI:up=\EA:do=\EB:\ :se=\E^N:so=\E^H:us=\E^D:ue=\E^C:\ :ae=\EG:as=\EF: # # From: Bracy H. Elton dl|vt200|vt220|vt200-js|vt220-js|dec vt200 series with jump scroll:\ :im=\E[4h:ei=\E[4l:mi:dc=\E[P:dm=:ed=:al=\E[L:dl=\E[M:\ :cs=\E[%i%d;%dr:sf=\ED:sr=\EM:sb=\EM:\ :ce=\E[K:cl=\E[H\E[J:cd=\E[J:cm=\E[%i%d;%dH:nd=\E[C:up=\E[A:\ :so=\E[7m:se=\E[27m:us=\E[4m:ue=\E[24m:\ :md=\E[1m:mr=\E[7m:mb=\E[5m:me=\E[m:\ :is=\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h\E[1;24r\E[24;1H:\ :rs=\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h:\ :tc=vt100: dm|vt200-ss|vt220-ss|dec vt200 series with smooth scroll:\ :is=\E>\E[?3l\E[?4h\E[?5l\E[?7h\E[?8h\E[1;24r\E[24;1H:\ :rs=\E>\E[?3l\E[?4h\E[?5l\E[?7h\E[?8h:\ :tc=vt200: dn|vt200-w|vt220-w|vt200-wj|vt220-wj|dec vt200 series; 132 col.; jump scroll:\ :is=\E>\E[?3h\E[?4l\E[?5l\E[?7h\E[?8h\E[1;24r\E[24;1H:\ :rs=\E>\E[?3h\E[?4l\E[?5l\E[?7h\E[?8h:\ :co#132:tc=vt200: do|vt200-ws|vt220-ws|dec vt200 series; 132 col.; smooth scroll:\ :is=\E>\E[?3h\E[?4h\E[?5l\E[?7h\E[?8h\E[1;24r\E[24;1H:\ :rs=\E>\E[?3h\E[?4h\E[?5l\E[?7h\E[?8h:\ :co#132:tc=vt200: dl|vt300|vt320|vt340|dec vt300 series with jump scroll:\ :im=\E[4h:ei=\E[4l:mi:dc=\E[P:dm=:ed=:al=\E[L:\ :cs=\E[%i%d;%dr:sf=\ED:sr=\EM:sb=\EM:\ :ce=\E[K:cl=\E[H\E[J:cd=\E[J:cm=\E[%i%d;%dH:nd=\E[C:up=\E[A:\ :so=\E[7m:se=\E[27m:us=\E[4m:ue=\E[24m:\ :md=\E[1m:mr=\E[7m:mb=\E[5m:me=\E[m:\ :is=\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h\E[1;24r\E[24;1H:\ :rs=\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h:\ :tc=vt100: # @(#)termcap X10/6.6 11/7/86, minus alternate screen, plus :cs vs|xterm|vs100|xterm terminal emulator (X window system):\ :do=^J:le=^H:ho=\E[H:\ :co#80:li#65:cl=\E[H\E[2J:bs:am:cm=\E[%i%d;%dH:nd=\E[C:up=\E[A:\ :ce=\E[K:cd=\E[J:so=\E[7m:se=\E[m:us=\E[4m:ue=\E[m:\ :md=\E[1m:mr=\E[7m:me=\E[m:\ :ku=\EOA:kd=\EOB:kr=\EOC:kl=\EOD:kb=^H:\ :k1=\EOP:k2=\EOQ:k3=\EOR:k4=\EOS:pt:sf=\n:sr=\EM:\ :al=\E[L:dl=\E[M:im=\E[4h:ei=\E[4l:mi:dc=\E[P:\ :MT:ks=\E[?1h\E=:ke=\E[?1l\E>:xn:\ :AL=\E[%dL:DL=\E[%dM:IC=\E[%d@:DC=\E[%dP:\ :hs:ts=\E[?E\E[?%i%dT:fs=\E[?F:es:ds=\E[?E:\ :is=\E\E[m\E[?7h\E[?1;4l:cs=\E[%i%d;%dr:\ :rs=\E[r\E<\E[m\E[H\E[2J\E[?7h\E[?1;3;4;6l: v2|xterms|vs100s|xterm terminal emulator (small)(X window system):\ :co#80:li#24:tc=xterm: # vs100 emulator using tsim (from lai@decwrl) vt|vs100t|tsim|vs100-tsim:\ :bs:cm=\EM%+ %+ :ho=\EH:do=^J:up=^K:cl=\EE:ce=\EL:cs=\ES%+ %+ :\ :so=\Eh:se=\Er:us=\Eu:ue=\Ev:al=\EI:Al=\E+%+ :dl=\ED:Dl=\E-%+ :\ :ic=\Ei:dc=\Ed:is=\ER:rs=\ER:am:cd=\EQ:pt:nd=\En:li#24:co#80: # # -------------------------------- # # h: HEWLETT PACKARD # # Note: no "ho" on HP's since that homes to top of memory, not screen. # Due to severe 2621 braindamage, the only way to get the arrow keys to # transmit anything at all is to turn on the function key labels # (f1-f8) with ks, and even then the poor user has to hold down shift! # The default 2621 turns off the labels except when it has to to enable # the function keys. If your installation prefers labels on all the time, # or off all the time (at the "expense" of the function keys) move the # 2621-nl or 2621-wl labels to the front using reorder. # Note: there are newer ROM's for 2621's that allow you to set strap A # so the regular arrow keys xmit \EA, etc, as with the 2645. However, # even with this strap set, the terminal stops xmitting if you reset it, # until you unset and reset the strap! Since there is no way to set/unset # the strap with an escape sequence, we don't use it in the default. # If you like, you can use 2621-ba (braindamaged arrow keys). h1|2621-ba|2621 w/new rom, strap A set:\ :ks@:ke@:ku=\EA:kd=\EB:kl=\ED:kr=\EC:kh=\Eh:tc=hp2621: # 2621 with function labels. Most of the time they are off, # but inside vi, the function key labels appear. You have to # hold down shift to get them to xmit. h2|2621|hp2621|hp2621a|hp2621p|2621a|2621p|2621-pb|hp2621-fl|hp 2621:\ :is=\E&j@\r:bt=\Ei:cm=\E&a%r%dc%dY:dc=2\EP:ip=2:pb#19200:\ :so=\E&dD:se=\E&d@:us=\E&dD:ue=\E&d@:me=\E&d@:\ :kh=\Ep\r:ku=\Et\r:kl=\Eu\r:kr=\Ev\r:kd=\Ew\r:\ :kn#8:k1=\Ep\r:k2=\Eq\r:k3=\Er\r:k4=\Es\r:k5=\Et\r:k6=\Eu\r:k7=\Ev\r:\ :k8=\Ew\r:ks=\E&jB:ke=\E&j@:ta=2^I:tc=hp: # 2621k45: untested # 2622: unsure if this is quite it, have only heard about the terminal. h3|2621k45|hp2621k45|k45|2622|hp2622|hp 2621 with 45 keyboard:\ :kb=^H:ku=\EA:kd=\EB:kl=\ED:kr=\EC:kh=\Eh:ks=\E&s1A:ke=\E&s0A:tc=2621: h4|hp2645|2645|hp45:\ :mh=\E&dH:mr=\E&dB:us=\E&dD:mb=\E&dA:me=\E&d@:\ :ku=\EA:kd=\EB:kl=\ED:kr=\EC:kh=\Eh:ks=\E&s1A:ke=\E&s0A:tc=hp: h5|hp|hewlett-packard:\ :ct=\E3:st=\E1:do=^J:al=\EL:am:le=^H:bs:\ :cd=\EJ:ce=\EK:ch=\E&a%dC:cl=\EH\EJ:cm=6\E&a%r%dc%dY:\ :co#80:cv=\E&a%dY:da:db:dc=\EP:dl=\EM:ei=\ER:im=\EQ:\ :kb=^H:li#24:mi:nd=\EC:pt:se=\E&d@:so=\E&dJ:\ :us=\E&dD:ue=\E&d@:up=\EA:xs:vt#6:pb#9600: # This entry does not use any of the fancy windowing stuff of the 2621. # Indeed, termcap does not yet handle such stuff. We are looking at it. h6|hp2626|hp2626a|hp2626p|2626|2626a|2626p|hp 2626:\ :dc=2\EP:ip=2:se=\E&d@:so=\E&dB:cd=500\EJ:\ :mr=\E&dB:us=\E&dD:mb=\E&dA:mk=\E&dS:me=\E&d@:ue=\E&d@:\ :kh=\Eh:ku=\EA:kl=\ED:kr=\EC:kd=\EB:ks=\E&s1A:ke=\E&s0A:\ :sf=\ES:ta=2^I:xs:tc=2621: # cD is a pain - but it only screws up at 9600 baud. # You should use this terminal at 4800 baud or less. h8|hp2648|hp2648a|2648a|2648|HP 2648a graphics terminal:\ :cl=50\EH\EJ:cm=20\E&a%r%dc%dY:dc=7\EP:ip=5:tc=2645: # This terminal should be used at 4800 baud or less. h9|hp2645-np|2645 w/no padding:cm=\E&a%r%dc%dY:tc=hp2645: # 2640a doesn't have the Y cursor addressing feature, and C is memory relative # instead of screen relative, as we need. ha|2640|hp2640a|2640a|hp 2640a:\ :cm@:ks@:ke@:tc=2645: hb|2640b|hp2640b|2644a|hp2644a|hp 264x series:\ :ks@:ke@:tc=2645: # 2621 using all 48 lines of memory, only 24 visible at any time. Untested. hl|2621-48|48 line 2621:\ :li#48:ho=\EH:cm=\E&a%r%dc%dR:tc=2621: # Hp 110 computer is the same as 2621 except has 16 lines hm|hp110|110|hp 110 computer:\ :li#16:tc=2621: # 2621 with no labels ever. Also prevents vi delays on escape. hn|2621-nl|hp2621nl|2621nl|hp2621-nl|hp 2621 with no labels:\ :ks@:ke@:kh@:ku@:kl@:kr@:kd@:tc=hp2621-fl: # Needed for UCB ARPAVAX console, since lsi-11 expands tabs (wrong). ht|hp2621-nt|2621nt|2621-nt|hp2621nt|hp 2621 w/no tabs:\ :pt@:tc=hp2621: # 2621 with labels on all the time - normal outside vi, function inside vi. hw|hp2621wl|2621wl|2621-wl|hp2621-wl|hp 2621 w/labels:\ :is=\E&jA\r:ke=\E&jA:tc=hp2621-fl: # 2392 (from haddix@arpa?) hz|2392|hp2392|hp2392a:\ :bt=\Ei:ip=2:is=\E&j@\E3\r:if=/usr/share/tabset/stdcrt:\ :ml=\El:MT:mu=\Em:km:\ :mh=\E&dH:mr=\E&dB:us=\E&dD:mb=\E&dA:me=\E&d@:\ :ku=\EA:kd=\EB:kl=\ED:kr=\EC:kh=\Eh:ks=\E&s1A:ke=\E&s0A:tc=hp: #HP 236 console #from ddavis@ic.berkeley.edu h7|236|hp236|HP236 internal terminal emulator:\ :am:bs:li#24:co#80:cl=\EF:cm=\EE%+ %+ :\ :dc=\EJ:dl=\EH:ic=\EI:al=\EG:up=^K:im=:ei=:\ :so=\EBI:se=\ECI:vs=\EDB:ve=\EDE: # hp150 from ddavis@ic.berkeley.edu h0|150|hp150|hp150a|150a:\ :is=\E&s1A\E&f0a1k2L\Ep\r\E&k0K\E&f0a2k2L\Eq\r\E&f0a3k2L\Er\r\E&f0a4k2L\Es\r\E&f0a5k2L\Et\r\E&f0a6k2L\Eu\r\E&f0a7k2L\Ev\r\E&f0a8k2L\Ew\r\E&k0D\E&s0A:\ :bt=\Ei:li#24:cm=\E&a%r%dc%dY:dc=2\EP:ip=2:pb#19200:so=\E&dJ:\ :se=\E&d@:us=\E&dD:ue=\E&d@:me=\E&d@:kh=\Eh:ku=\EA:kl=\ED:kr=\EC:\ :kd=\EB:kn#8:k1=\Ep:k2=\Eq:k3=\Er:k4=\Es:k5=\Et:k6=\Eu:k7=\Ev:\ :k8=\Ew:ta=2^I:ct=\E3:st=\E1:do=^J:al=\EL:am:le=^H:\ :bs:cd=\EJ:ce=\EK:ch=\E&a%dC:cl=\Eh\EJ:co#80:cv=\E&a%dY:da:db:dl=\EM:\ :ei=\ER:im=\EQ:kb=^H:mi:nd=\EC:pt:up=\EA:xs:vt#6:sf=\ES:sr=\ET:\ :vs=\E&s1A:ve=\E&s0A:ks=\E&jB\E&j@:ke=\E&j@: # # -------------------------------- # # i: INFOTON (GENERAL TERMINAL) # # Infoton is now called General Terminal Corp. or some such thing. # gt100 sounds like something DEC would come out with. Lets hope they don't. i1|i100|gt100|gt100a|General Terminal 100A (formerly Infoton 100):\ :do=^J:cl=^L:cd=\EJ:ce=\EK:li#24:co#80:\ :al=\EL:dl=\EM:up=\EA:nd=\EC:ho=\EH:cm=\Ef%r%+ %+ :vb=\Eb\Ea:\ :am:le=^H:bs:so=\Eb:se=\Ea: i4|i400|400|infoton 400:\ :do=^J:al=\E[L:am:le=^H:bs:ce=\E[N:cl=\E[2J:cm=%i\E[%3;%3H:co#80:\ :dl=\E[M:li#25:nd=\E[C:up=\E[A:im=\E[4h\E[2Q:ei=\E[4l\E[0Q:\ :dc=\E[4h\E[2Q\E[P\E[4l\E[0Q: ia|addrinfo:\ :do=^J:li#24:co#80:cl=^L:ho=^H:nd=^Y:cd=^K:\ :up=^\:am:le=^Z:bc=^Z:cm=\037%+\377%+\377:ll=^H^\: ik|infotonKAS:\ :do=^J:am:le=^Z:bc=^Z:cd=^K:cl=^L:co#80:li#24:nd=^Y:up=^\:ll=^H^\: # # -------------------------------- # # k: HEATHKIT (ZENITH) # kA|h19-a|h19a|heath-ansi|heathkit-a|heathkit h19 ansi mode:\ :\ :al=1*\E[1L:am:le=^H:bs:cd=\E[J:ce=\E[K:cl=\E[2J:cm=\E[%i%2;%2H:co#80:\ :dc=\E[1P:dl=1*\E[1M:do=\E[1B:ei=\E[4l:ho=\E[H:im=\E[4h:li#24:mi:\ :nd=\E[1C:as=\E[10m:ae=\E[11m:ms:pt:se=\E[0m:so=\E[7m:up=\E[1A:\ :vs=\E[>4h:ve=\E[>4l:kb=^h:ku=\E[1A:kd=\E[1B:kl=\E[1D:kr=\E[1C:\ :kh=\E[H:kn#8:k1=\EOS:k2=\EOT:k3=\EOU:k4=\EOV:k5=\EOW:l6=blue:\ :l7=red:l8=white:k6=\EOP:k7=\EOQ:k8=\EOR:\ :sr=\EM:is=\E<\E[>1;2;3;4;5;6;7;8;9l\E[0m\E[11m\E[?7h: kB|h19-bs|h19bs|heathkit w/keypad shifted:\ :ks=\Et:ke=\Eu:tc=h19-b: #written by David Shewmake, UCSF Medical Information Science #ucbvax!ucsfmis!shewmake kC|h29|heath-29|z29|zenith-29:\ :am:bc=\ED:bt=\E-:do=^J:\ :al=\EL:le=^H:bs:cd=\EJ:ce=\EK:cl=\EE:cm=\EY%+ %+ :co#80:dc=\EN:\ :dl=1*\EM:do=\EB:ei=\EO:ho=\EH:im=\E@:li#24:mi:nd=\EC:as=\EF:ae=\EG:\ :ms:pt:sr=\EI:se=\Eq:so=\Ep:up=\EA:vs=\Ex4:ve=\Ey4:\ :kb=^H:ku=\EA:kd=\EB:kl=\ED:kr=\EC:kh=\EH:kn#1:k0=\E~:l0=HOME:\ :k1=\ES:k2=\ET:k3=\EU:k4=\EV:k5=\EW:k6=\EP:k7=\EQ:k8=\ER:k9=\E0I:\ :es:hs:ts=\Ej\Ex5\Ex1\EY8%+ \Eo:fs=\Ek\Ey5:ds=\Ey1:us=\Es8:ue=\Es0: #the z29-e entry sucks...but it works with emacs kD|z29-e|zenith 29 hacked for emacs:\ :ip=1.5:ks=\Et:ke=\Eu:vs@:ve@:al=1*\EL:am:le=^H:\ :bs:cd=\EJ:ce=\EK:cl=\EE:cm=\EY%+ %+ :co#80:dc=\EN:dl=1*\EM:\ :do=\EB:ho=\EH:li#24:nd=\EC:as=\EF:ae=\EG:ms:\ :pt:sr=\EI:se=\Eq:so=\Ep:up=\EA:vs=\Ex4:ve=\Ey4:kb=^h:\ :ku=\EA:kd=\EB:kl=\ED:kr=\EC:kh=\EH:kn#8:k1=\ES:k2=\ET:k3=\EU:\ :k4=\EV:k5=\EW:l6=blue:l7=red:l8=white:k6=\EP:k7=\EQ:k8=\ER:es:hs:\ :ts=\Ej\Ex5\Ex1\EY8%+ \Eo:fs=\Ek\Ey5:ds=\Ey1: # z29 in ansi mode. Assumes that the cursor is in the correct state, and that # the world is stable. `rs' causes the terminal to be reset to the state # indicated by the name. kc -> key click, nkc -> no key click, uc -> underscore # cursor, bc -> block cursor. # from Mike Meyers kF|z29a|z29a-kc-bc|h29a-kc-bc|heath/zenith 29 in ansi mode:\ :do=^J:co#80:li#24:cl=\E[2J:pt:ho=\E[H:\ :le=^H:bs:cm=\E[%i%d;%dH:nd=\E[C:up=\E[A:mb=\E[5m:mr=\E7m:\ :ce=\E[K:cd=\E[J:so=\E[7;2m:se=\E[m:us=\E[4m:ue=\E[m:mh=\E[2m:\ :md=\E[2m:mr=\E[7m:mb=\E[5m:me=\E[m:\ :rs=\E<\E[1;24r\E[24;1H\E[?7h\E[>4h\E[>1;2;3;5;6;7;8;9l\E[m\E[11m:\ :ku=\EOA:kd=\EOB:kr=\EOC:kl=\EOD:kb=^H:\ :k1=\EOS:k2=\EOT:k3=\EOU:k4=\EOV:k5=\EOW:k6=\EOP:k7=\EOQ:k8=\EOR:\ :k9=\EOX:k0=\E[~:l0=help:kn#2:ko=ho,cd:if=/usr/share/tabset/zenith29:\ :es:hs:ts=\E[s\E[>5;1h\E[25;%i%dH\E[1K:fs=\E[u\E[>5l:ds=\E[>1l:\ :cs=\E[%i%d;%dr:sr=\EM:sf=\ED:DO=\E[%dB:UP=\E[%dA:LE=\E[%dD:\ :RI=\E[%dC:AL=\E[%dL:DL=\E[%dM:sc=\E[s:rc=\E[r:dc=\E[1P:DC=\E[%dP:\ :kC=\E[J:ct=\E[3g:st=\EH:ti=\E[?7l:te=\E[?7h:ps=\E#7: kG|z29a-kc-uc|h29a-kc-uc|heath/zenith 29 in ansi mode:\ :rs=\E<\E[1;24r\E[24;1H\E[?7h\E[>1;2;3;4;5;6;7;8;9l\E[m\E[11m:\ :tc=z29a: kH|z29a-nkc-bc|h29a-nkc-bc|heath/zenith 29 in ansi mode:\ :rs=\E<\E[1;24r\E[24;1H\E[?7h\E[>2;4h\E[>1;3;5;6;7;8;9l\E[m\E[11m:\ :tc=z29a: kI|z29a-nkc-uc|h29a-nkc-uc|heath/zenith 29 in ansi mode:\ :rs=\E<\E[1;24r\E[24;1H\E[?7h\E[>2h\E[>1;3;4;5;6;7;8;9l\E[m\E[11m:\ :tc=z29a: #z100 entry from Brad Brahms at TRW (Brahms@USC-ECLC) # usenet: {decvax,ucbvax}!trwrb!trwspp!brahms kc|z100|h100|z110|z-100|h-100|heath/zenith z-100 pc with color monitor:\ :vs=\Ex4\Em71:ve=\Ey4\Em70:tc=z100bw: kY|z100bw|h100bw|z110bw|z-100bw|h-100bw|heath/zenith z-100 pc:\ :al=5*\EL:bs:cd=\EJ:ce=\EK:cl=5*\EE:cm=1*\EY%+ %+ :co#80:dc=1*\EN:\ :dl=5*\EM:do=\EB:ei=\EO:ho=\EH:im=\E@:li#24:mi:nd=\EC:as=\EF:ae=\EG:\ :ms:pt:sr=\EI:se=\Eq:so=\Ep:up=\EA:vs=\Ex4:ve=\Ey4:\ :kb=^h:ku=\EA:kd=\EB:kl=\ED:kr=\EC:kh=\EH:kn#10:\ :k0=\EJ:k1=\ES:k2=\ET:k3=\EU:k4=\EV:k5=\EW:\k6=\EP:k7=\EQ:\ :k8=\ER:k9=\EOI: kp|p19:\ :al=2*\EL:dl=2*\EM:tc=h19-b: kU|h19-us|h19us|heathkit w/keypad shifted/underscore cursor:\ :ks=\Et:ke=\Eu:tc=h19-u: kb|h19|heath|h19-b|h19b|heathkit|heath-19|z19|zenith|heathkit h19:\ :al=1*\EL:am:le=^H:bs:cd=\EJ:ce=\EK:cl=\EE:cm=\EY%+ %+ :co#80:dc=\EN:\ :dl=1*\EM:do=\EB:ei=\EO:ho=\EH:im=\E@:li#24:mi:nd=\EC:as=\EF:ae=\EG:\ :ms:pt:sr=\EI:se=\Eq:so=\Ep:up=\EA:vs=\Ex4:ve=\Ey4:\ :kb=^h:ku=\EA:kd=\EB:kl=\ED:kr=\EC:kh=\EH:kn#8:ke=\E>:ks=\E=:\ :k1=\ES:k2=\ET:k3=\EU:k4=\EV:k5=\EW:\ :l6=blue:l7=red:l8=white:k6=\EP:k7=\EQ:k8=\ER:\ :es:hs:ts=\Ej\Ex5\Ex1\EY8%+ \Eo:fs=\Ek\Ey5:ds=\Ey1: ke|h19-e|h19e|h19 for emacs:ip=1.5:tc=h19-us: ku|h19-u|h19u|heathkit with underscore cursor:\ :vs@:ve@:tc=h19-b: kg|h19-g|h19g|heathkit w/block cursor:\ :ve=\Ex4:tc=h19-b: # from ucscc!B.fiatlux@ucbvax.berkeley.edu zx|ztx|ztx11|zt-1|htx11|ztx-1-a|ztx-10/11:\ :al=\EL:am:bs:cd=\EJ:ce=\EK:cl=\EE:cm=\EY%+ %+ :co#80:\ :dl=\EM:do=^J:ho=\EH:is=\Ej\EH\Eq\Ek\Ev\Ey1\Ey5\EG\Ey8\Ey9\Ey>:\ :k0=\ES:k1=\EB:k2=\EU:k3=\EV:k4=\EW:k5=\EP:k6=\EQ:k7=\ER:kb=^H:kd=\EB:\ :kl=\ED:kr=\EC:ku=\EA:le=^H:li#24:nd=\EC:pt:se=\Eq:so=\Es5:\ :sr=\EI:sr=\EI:ue=\Eq:up=\EA:us=\Es2:\ :es:hs:ts=\Ej\Ex5\Ex1\EY8%+ \Eo:fs=\Ek\Ey5:ds=\Ey1: # # -------------------------------- # # l: LEAR SIEGLER (ADM) # # If the adm31 gives you trouble with standout mode, check the DIP switch # in position 6, bank @c11, 25% from back end of pc. Should be OFF. # If there is no such switch, you have an old adm31 and must use oadm31 l1|adm31|31|lsi adm31:\ :is=\Eu\E0:do=^J:al=\EE:am:le=^H:bs:ce=\ET:cm=\E=%+ %+ :\ :cl=\E*:cd=\EY:co#80:dc=\EW:dl=\ER:ei=\Er:ho=^^:im=\Eq:\ :k0=^A0\r:k1=^A1\r:k2=^A2\r:k3=^A3\r:k4=^A4\r:\ :k5=^A5\r:k6=^A6\r:k7=^A7\r:k8=^A8\r:k9=^A9\r:kd=^J:kl=^H:kr=^L:ku=^K:\ :li#24:ma=j^Jk^P^K^Pl ^R^L^L :mi:nd=^L:\ :se=\EG0:so=\EG1:up=^K:us=\EG1:ue=\EG0: l2|adm2|lsi adm2:\ :do=^J:al=\EE:am:le=^H:bs:cd=\EY:ce=\ET:cl=\E;:\ :cm=\E=%+ %+ :co#80:dc=\EW:dl=\ER:\ :ei=:ho=^^:ic=\EQ:im=:kd=^J:kh=^^:kl=^H:kr=^L:ku=^K:li#24:nd=^L:up=^K: l3|adm3|3|lsi adm3:\ :do=^J:am:le=^H:bs:cl=^Z:li#24:ma=^K^P:co#80: l4|adm42|42|lsi adm42:\ :vs=\EC\E3 \E3(:do=^J:al=270\EE:am:le=^H:bs:cd=\EY:ce=\ET:cl=\E;:\ :cm=\E=%+ %+ :co#80:dc=\EW:dl=\ER:ei=\Er:im=\Eq:ip=6*:li#24:\ :bt=\EI:nd=^L:se=\EG0:so=\EG4:up=^k:ma=^K^P:pc=\177: l5|adm5|5|lsi adm5:\ :do=^J:cd=\EY:ce=\ET:do=^J:kb=^H:kh=^^:\ :ma=^Hh^Jj^Kk^Ll^^H:se=\EG:sg#1:so=\EG:tc=adm3aplus: l7|adm20|lear siegler adm20:\ :am:li#24:co#80:bs:cl=^Z:cm=\E=%i%r%+^_%+^_:nd=^L:up=^K:ho=^^:ce=\ET:\ :cd=\EY:al=\EE:dl=\ER:im=:ei=:ic=\EQ:dm=:ed=:dc=\EW:so=\E):se=\E(:\ :bt=\EI:pt:kn#7:k1=^A:k2=^B:k3=^W:k4=^D:k5=^E:k6:^X:k7=^Z: # From Andrew Scott Beals l8|adm12|12|lsi adm12:\ :is=\Eq:do=^J:al=\EE:am:le=^H:bs:ce=\ET:cm=\E=%+ %+ :cl=^Z:cd=\EY:\ :co#80:dc=\EW:dl=\ER:ei=\Er:ho=^^:im=\Eq:\ :k0=^A0\r:k1=^A1\r:k2=^A2\r:k3=^A3\r:k4=^A4\r:\ :k5=^A5\r:k6=^A6\r:k7=^A7\r:k8=^A8\r:k9=^A9\r:kd=^J:kl=^H:kr=^L:ku=^K:\ :li#24:ma=j^Jk^P^K^Pl ^R^L^L :mi:nd=^L:\ :se=\EG0:so=\EG4:up=^K:us=\EG1:ue=\EG0: la|adm3a|3a|lsi adm3a:\ :am:do=^J:le=^H:bs:cm=\E=%+ %+ :cl=1^Z:co#80:ho=^^:\ :li#24:ma=^K^P:nd=^L:up=^K: lb|adm3a+|3a+|adm3aplus:\ :kl=^H:kd=^J:ku=^K:kr=^L:tc=adm3a: lc|adm22|22|lsi adm22:\ :is=\E%\014\014\014\016\003\000\003\002\003\002\000\000\000\000\000\000\000\000\000\000\000:\ :al=\EE:am:bs:bt=\EI:cd=\Ey:ce=\Et:cl=\E+:cm=\000\E=%+ %+ :co#80:\ :dc=\EW:dl=\ER:do=^J:em=:ho=^^:ic=\EQ:im=:\ :k1=\001@\015:k2=\001A\015:k3=\001B\015:k4=\001C\015:\ :k5=\001D\015:k6=\001E\015:k7=\001F\015:kn#7:\ :ko=ho:l1=F1:l2=F2:l3=F3:l4=F4:l5=F5:l6=F6:l7=F7:\ :kb=^H:kd=^J:kh=^^:kl=^H:kr=^L:ku=^K:li#24:\ :ma=j^Jk^P^K^Pl ^R^L^L :nd=^L:se=\E(:so=\E):ta=\Ei:up=^K: #From: stephen%comp.lancs.ac.uk@ucl-cs.arpa le|adm11|lsi adm11:\ :do=^J:bs:\ :cd=\EY:ce=\ET:kb=^H:kh=^^:\ :ma=^Hh^Jj^Kk^Ll^^H:so=\E):se=\E(:\ :kl=^H:kd=^J:ku=^K:kr=^L:\ :am:cm=\E=%+ %+ :cl=^Z:co#80:li#24:nd=^L:up=^K:\ :hs:ts=\EF\E):fs=\E(^M:ds=\Eh: # # -------------------------------- # # m: MICROTERM # # These mime1 entries refer to the Microterm Mime I or Mime II. # The default mime is assumed to be in enhanced act iv mode. m3|mime3a|mime1 emulating 3a:\ :am@:ma=^X ^K^J^Z^P:ku=^Z:kd=^K:kl=^H:kr=^X:tc=adm3a: m4|microterm|act4|microterm act iv:\ :am:do=^J:le=^H:bs:cd=^_:ce=^^:cl=^L:cm=^T%.%.:\ :co#80:li#24:nd=^X:up=^Z:ho=^]: # The padding on sr and ta for act5 and mime is a guess and not final. # The act 5 has hardware tabs, but they are in columns 8, 16, 24, 32, 41 (!)... m5|microterm5|act5|microterm act v:\ :uc=^H\EA:sr=3\EH:ku=^Z:kd=^K:kl=^H:kr=^X:ma=^Z^P^Xl^Kj:tc=act4: # Act V in split screen mode. act5s is not tested and said not to work. mS|act5s|skinny act5:\ :ti=\EP:te=\EQ:li#48:co#39:tc=act5: # Mimes using brightness for standout. Half bright is really dim unless # you turn up the brightness so far that lines show up on the screen. # uc is disabled to get around a curses bug, should be put back in someday. mf|mime-fb|full bright mime1:\ :so=^Y:se=^S:is=^S\E:tc=mime: mh|mime-hb|half bright mime1:\ :so=^S:se=^Y:is=^Y\E:tc=mime: mm|mime|mime1|mime2|mimei|mimeii|microterm mime1:\ :do=^J:al=80^A:am:le=^H:bs:cd=^_:ce=^^:cl=\035^C:cm=^T%+^X%> 0%+P:\ :co#80:dl=80^W:ta=2^I:li#24:nd=^X:pt:uc=^U:up=^z:ho=\035:do=^K:\ :is=^S\E^Q:ma=^X ^K^J^Z^P:ku=^Z:kd=^K:kl=^H:kr=^X:sr=3^R:vt#9: # These termcaps (for mime 2a) put the terminal in low intensity mode # since high intensity mode is so obnoxious. ms|mime2a-s|microterm mime2a (emulating an enhanced soroc iq120):\ :do=^J:\ :al=20*^A:am:le=^H:bs:cd=20*\EJ:ce=\EK:cl=\EL:cm=\E=%+ %+ :co#80:dc=\ED:\ :dl=20*^W:kl=^H:kr=^L:ku=^K:kd=^J:ho=^^:is=\E):sr=\EI\ :im=\EE:ei=^Z:ip=2:li#24:nd=^L:so=\E\072:se=\E;:up=\EI:\ :us=\E6:ue=\E7: # This is the preferred mode (but ^X can't be used as a kill character) mv|mime2a|mime2a-v|microterm mime2a (emulating an enhanced vt52):\ :do=^J:al=20*^A:le=^H:bs:cd=20*\EQ:co#80:ce=\EP:cl=\EL:cm=\EY%+ %+ :\ :is=^Ydc=^N:dl=20*^W:ip=2:ei=^Z:ho=\EH:im=^O:kd=\EB:kl=\ED:kr=\EC:\ :ku=\EA:li#24:nd=\EC:pt:se=\E9:so=\E8:up=\EA:sr=\EA:us=\E4:ue=\E5: mx|mime3ax|mime-3ax|mime1 emulating enhanced 3a:\ :al=80^A:dl=80^W:pt:ce=^X:cd=^_:tc=mime3a: # # -------------------------------- # # p: PERKIN ELMER # pe|pe550|bantam|perkin elmer 550:\ :do=^J:le=^H:bs:co#80:ce=20\EI:cl=20\EK:cm=\EX%+ \EY%+ :\ :ho=\EH:li#24:ll=\EH\EA:nd=\EC:up=\EA:ma=^Z^P:cd=6^N@^V: pf|fox|perkin elmer 1100:\ :ct=\E3:st=\E1:do=^J:\ :am:le=^H:bs:cd=5.5*\EJ:ce=\EI:cl=132\EH\EJ:co#80:ho=\EH:li#24:\ :ll=\EH\EA:nd=\EC:cm=\EX%+ \EY%+ :up=\EA:vb=^P^B^P^C: po|owl|perkin elmer 1200:\ :ct=\E3:st=\E1:do=^J:al=5.5*\EL:am:le=^H:\ :bs:cd=5.5*\EJ:ce=5.5\EI:cl=132\EH\EJ:ho=\EH:ll=\EH\EA:\ :cm=\EX%+ \EY%+ :co#80:dc=5.5*\EO:dl=5.5*\EM:ei=:ic=\EN:im=:ip=5.5*:\ :kb=^h:in:li#24:nd=\EC:up=\EA:se?=\E!\200:so?=\E!^H:vb=^P^B^P^C:\ :k1=\ERA:k2=\ERB:k3=\ERC:k4=\ERD:k5=\ERE:k6=\ERF:\ :k7=\ERG:k8=\ERH:k9=\ERI:k0=\ERJ: # # -------------------------------- # # q: HOME MADE TERMINALS # qB|bc|bill croft homebrew:\ :do=^J:am:le=^H:bs:cm=\E=%+ %+ :cl=^Z:co#96:ho=^^:li#72:\ :nd=^L:up=^K:vb=: qN|nucterm|rayterm|NUC homebrew:\ :do=^J:am:le=^H:bs:cl=1^L:li#24:co#80:nd=^C:\ :up=^N:ho=^B:ll=^K:ce=^A:cd=^E: qb|ex3000:\ :do=^J:li#24:co#80:ho=^Q: qc|carlock|klc:\ :do=^J:al=^E:am:bs:ce=^U:cl=100^Z:cm=\E=%+ %+ :co#80:dc=\177:dl=^D:\ :dm=:ed=:ei=^T:ho=^^:im=^T:li#24:nd=^L:se=^V:so=^V:up=^K:vb=\EV\EV: # uVAX qd|qdss|qdcons|qdss glass tty:\ :am:do=^J:le=^H:bs:cm=\E=%.%.:cl=1^Z:co#128:li#57::nd=^L:up=^K: qe|exidy|exidy2500|exidy sorcerer as dm2500:\ :do=^J:al=^P^J^X:am:le=^H:bs:ce=^W:cl=^^:cm=^L%r%n%.%.:co#64:\ :dc=\b:dl=^P^Z^X:dm=^P:ed=^X:ei=^X:ho=^B:ic=^\:\ :im=^P:li#30:nd=^\:pt:so=^N:se=^X:up=^Z: qn|netx|netronics:\ :do=^J:le=^H:bs:cd=2000^F^E:ce=1600^E:cl=466^L:cm=\E=%+@%+@:\ :co#64:ho=^D:li#16:ma=j^Jk^Pl :nd=\E+@A:pc=\200:sr=\E=@@^K:up=^K: # This came from the comp ctr who got it from some user. Smart indeed! qs|sexidy|exidy smart:\ :do=^J:li#24:co#64:cl=^l:ho=^q:nd=^s:\ :up=^w:le=^H:bs:le=^a:bc=^a:ma=^x^J:kd=^S: qu|ubell|ubellchar:\ :if=/usr/share/tabset/ubell:do=^J:am:le=^H:bs:pt:ce=\Ed:cl=^Z:\ :cm=\E=%+ %+ :co#80:li#24:nd=^L:up=^K:ma=j^Jk^P^K^Pl :ho=^^: qw|ttyWilliams:\ :do=^J:co#80:li#12:le=^Y:bc=^Y:do=^K:up=^Z:cl=^^:ce=^_:am:ho=^]:nd=^X: qx|xitex|xitex sct-100:\ :do=^J:le=^H:bs:cd=2000^F^E:ce=1600^E:cl=400^L:cm=\E=%+@%+@:co#64:\ :ho=^D:li#16:ma=j^Jk^Pl :nd=\E+@A:pc=\200:sr=\E=@@^K:up=^K: # # -------------------------------- # # s: SPECIALS # # Special "terminals". These are used to label tty lines when you don't # know what kind of terminal is on it. The characteristics of an unknown # terminal are the lowest common denominator - they look about like a ti 700. sa|network:\ :tc=unknown: sb|arpanet:\ :tc=unknown: sc|bussiplexer:\ :tc=unknown: sd|du|dialup:\ :tc=unknown: se|ethernet:\ :tc=unknown: sl|lpr|printer|print|printing|line printer:\ :do=^J:le=^H:bs:co#132:hc:os: sp|plugboard|patch|patchboard:\ :tc=unknown: su|dumb|un|unknown:\ :am:co#80:do=^J: sw|switch|intelligent switch:\ :tc=unknown: sx|ansi|any ansi terminal with pessimistic assumptions:\ :co#80:li#24:cl=50\E[;H\E[2J:bs:am:cm=\E[%i%d;%dH:\ :nd=\E[C:up=\E[A:ce=\E[K:ho=\E[H:pt: # # -------------------------------- # # t: TEXAS INSTRUMENTS # t3|ti|ti700|ti733|735|ti735|ti silent 700:\ :do=^J:le=^H:bs:co#80:hc:os:dC#162: t4|ti745|745|743|ti silent 745:\ :do=^J:le=^H:bs:co#80:hc:os: t8|ti800|ti omni 800:\ :do=^J:le=^H:bs:co#132:hc:os: # From lesleymw@topaz.berkeley.edu t9|ti931|ti 931:\ al=\EN:am:bs:cd=\EJ:ce=\EI:cl=\EL:cm=\EY%+ %+ :co=#80:dl=\EO:do=\EB:\ eo:ho=\EH:li=#24:ku=\EA:kd=\EB:kr=\EC:kl=\ED:mi:nd:sf=\Eb:sr=\Ea:up=\EA: # # -------------------------------- # # v: TELEVIDEO # # There are some tvi's that require incredible amounts of padding and # some that don't. I'm assuming 912 and 920 are the old slow ones, # and 912b, 912c, 920b, 920c are the new ones that don't need padding. v1|tvi912|912|920|tvi920|old televideo:\ :ct=\E3:st=\E1:do=^J:\ :al=33*\EE:le=^H:ce=\ET:cm=\E=%+ %+ :cl=^Z:co#80:dc=\EW:dl=33*\ER:ei=:\ :kb=^H:ku=^K:kd=^J:kl=^H:kr=^L:k0=^AI\r:k1=^A@\r:k2=^AA\r:k3=^AB\r:\ :bs:am:k4=^AC\r:k5=^AD\r:k6=^AE\r:k7=^AF\r:k8=^AG\r:k9=^AH\r:\ :ho=^^:im=:ic=\EQ:li#24:nd=^L:pt:se=\Ek:so=\Ej:up=^K:us=\El:ue=\Em:\ :ma=^K^P^L :sg#1:ug#1:if=/usr/share/tabset/stdcrt # the 912 has a key that's like shift: 8 xmits "^A8\r". # The 920 has this plus real function keys that xmit different things. # Termcap makes you use the funct key on the 912 but the real keys on the 920. v2|912b|912c|tvi912b|tvi912c|tvi|new televideo 912:\ :al=5*\EE:dl=5*\ER:tc=tvi912: v3|920b|920c|tvi920b|tvi920c|new televideo 920:\ :k0=^AI\r:k1=^A@\r:k2=^AA\r:k3=^AB\r:k4=^AC\r:k5=^AD\r:\ :k6=^AE\r:k7=^AF\r:k8=^AG\r:k9=^AH\r:al=5*\EE:dl=5*\ER:tc=tvi912: # set to page 1 when entering ex (\E-17 ) # reset to page 0 when exiting ex (\E-07 ) v4|tvi912-2p|tvi920-2p|912-2p|920-2p|tvi-2p|televideo w/2 pages:\ :ti=\E-17 :te=\E-07 :tc=tvi912: v5|tvi950-ap|tvi 950 w/alt pages:\ :is=\E\\1:ti=\E-06 :te=\E-16 :tc=tvi950: v6|tvi950-b|bare tvi950 no is:\ :is@:tc=tvi950: v7|tvi950-ns|tvi950 w/no standout:\ :so@:se@:us@:ue@:tc=tvi950: vi|tvi925|925|televideo model 925:\ :hs:xn:am:bs:co#80:li#24:cm=\E=%+ %+ :cl=\E*:cd=\Ey:ce=\Et:is=\El\E":\ :al=\EE:dl=\ER:im=:ei=:ic=\EQ:dc=\EW:if=/usr/share/tabset/stdcrt:\ :ho=^^:nd=^L:bt=\EI:pt:so=\EG4:se=\EG0:sg#1:us=\EG8:ue=\EG0:ug#1:\ :up=^K:do=^V:kb=^H:ku=^K:kd=^V:kl=^H:kr=^L:kh=^^:ma=^V^J^L :\ :k1=^A@\r:k2=^AA\r:k3=^AB\r:k4=^AC\r:k5=^AD\r:k6=^AE\r:k7=^AF\r:\ :k8=^AG\r:k9=^AH\r:k0=^AI\r:ko=ic,dc,al,dl,cl,ce,cd,bt:\ :ts=\Ef:fs=^M\Eg:ds=\Eh:sr=\Ej: vj|tvi925vb|925vb|televideo model 925 visual bells:\ :vb=\Eb\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\Ed:\ :tc=tvi925: # Since the 925's uses a character position to store the escape sequences to go # in and out of both stand out and underline modes, screen positioning is # difficult. The following 925 entries don't use these modes. vn|tvi925n|925n|televideo model 925 no standout or underline:\ :so@:se@:us@:ue@:tc=tvi925: vk|tvi925vbn|925vbn|televideo model 925 visual bells no so or ul:\ :vb=\Eb\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\Ed:\ :tc=tvi925n: # entry by Tim Curry 5/21/82 Univ. of Central Fla. duke!ucf-cs!tim v9|925a|tvi925a|TeleVideo Model 925:\ :al=\EE:am:bs:bt=\EI:bw:cd=\EY:ce=\ET:cl=^Z:cm=\E=%+ %+ :co#80:dc=\EW:\ :dl=\ER:do=^V:ei=:ic=\EQ:if=/usr/share/tabset/std:im=:kb=^H:kd=^V:\ :kh=^^:kl=^H:kn#12:kr=^L:ku=^K:li#24:nd=^L:pt:se=\EG0:sg=#1:so=\EG4:\ :ue=\EG0:ug#1:up=^K:us=\EG8:is=\El\ :vb=\Eb\200\200\200\200\200\200\200\200\200\200\200\200\200\200\Ed:\ :ve=\E.4:vs=\E.2: # The following tvi descriptions from B:pjphar and virus!mike # is for all 950's. It sets the following attributes: # full duplex (\EDF) write protect off (\E() # conversation mode (\EC) graphics mode off (\E%) # white on black (\Ed) auto page flip off (\Ew) # turn off status line (\Eg) clear status line (\Ef\r) # normal video (\E0) monitor mode off (\EX or \Eu) # edit mode (\Er) load blank char to space (\Ee\040) # line edit mode (\EO) enable buffer control (^O) # protect mode off (\E\047) duplex edit keys (\El) # program unshifted send key to send line all (\E016) # program shifted send key to send line unprotected (\E004) # set the following to nulls: # field delimiter (\Ex0\200\200) # line delimiter (\Ex1\200\200) # start-protected field delimiter (\Ex2\200\200) # end-protected field delimiter (\Ex3\200\200) # set end of text delimiter to carriage return/null (\Ex4\r\200) # CHANGED 4-29-87 to set tabs and keep status line --John Kunze (jak@opal) va|tvi950|950|televideo950:\ :ct=\E3:st=\E1:do=^J:\ :is=\EDF\EC\Ed\EG0\Er\EO\E\047\E(\E%\Ew\EX\Ee ^O\ \El\E016\E004\Ex0\200\200\Ex1\200\200\Ex2\200\200\ \Ex3\200\200\Ex4\r\200\Ef\r:if=/usr/share/tabset/stdcrt:\ :al=\EE:am:le=^H:bs:bt=\EI:cd=\Ey:ce=\Et:cl=\E*:cm=\E=%+ %+ :\ :co#80:dc=\EW:dl=\ER:do=^V:ei=\Er:ho=^^:im=\Eq:k0=^A0\r:\ :k1=^A@\r:k2=^AA\r:k3=^AB\r:k4=^AC\r:k5=^AD\r:k6=^AE\r:\ :k7=^AF\r:k8=^AG\r:k9=^AH\r:kb=^H:kd=^V:kh=^^:kl=^H:\ :ko=ic\054dc\054al\054dl\054cl\054bt\054ce\054cd:kr=^L:\ :ku=^K:li#24:ma=^Vj^Kk^Hh^Ll^^H:mi:ms:nd=^L:pt:se=\EG0:\ :sg#1:so=\EG4:sr=\Ej:ue=\EG0:ug#1:up=^K:us=\EG8:\ :vb=\Eb\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\Ed:\ :xn:hs:ts=\Eg\Ef:fs=\r:ds=\Eg\Ef\r: # # is for 950 with two pages adds the following: # set 48 line page (\E\\2) # place cursor at page 0, line 24, column 1 (\E-07 ) # set local (no send) edit keys (\Ek) # # two page 950 adds the following: # when entering ex, set 24 line page (\E\\1) # when exiting ex, reset 48 line page (\E\\2) # place cursor at 0,24,1 (\E-07 ) # set duplex (send) edit keys (\El) when entering vi # set local (no send) edit keys (\Ek) when exiting vi # vb|tvi950-2p|950-2p|televideo950 w/2 pages:\ :is=\EDF\EC\Ed\EG0\Eg\Er\EO\E\047\E(\E%\Ew\EX\Ee ^O\ \Ek\E016\E004\Ex0\200\200\Ex1\200\200\Ex2\200\200\ \Ex3\200\200\Ex4\r\200\E\\2\E-07 \ :te=\E\\2\E-07 :ti=\E\\1\E-07 :ks=\El:ke=\Ek:tc=tvi950: # # is for 950 with four pages adds the following: # set 96 line page (\E\\3) # place cursor at page 0, line 24, column 1 (\E-07 ) # # four page 950 adds the following: # when entering ex, set 24 line page (\E\\1) # when exiting ex, reset 96 line page (\E\\3) # place cursor at 0,24,1 (\E-07 ) # vc|tvi950-4p|950-4p|televideo950 w/4 pages:\ :is=\EDF\EC\Ed\EG0\Eg\Er\EO\E\047\E(\E%\Ew\EX\Ee ^O\ \Ek\E016\E004\Ex0\200\200\Ex1\200\200\Ex2\200\200\ \Ex3\200\200\Ex4\r\200\E\\3\E-07 \ :te=\E\\3\E-07 :ti=\E\\1\E-07 :ks=\El:ke=\Ek:tc=tvi950: # # is for reverse video 950 changes the following: # set reverse video (\Ed) # # set vb accordingly (\Ed ...nulls... \Eb) # vd|tvi950-rv|950-rv|televideo950 rev video:\ :is=\EDF\EC\Eb\EG0\Eg\Er\EO\E\047\E(\E%\Ew\EX\Ee ^O\ \El\E016\E004\Ex0\200\200\Ex1\200\200\Ex2\200\200\ \Ex3\200\200\Ex4\r\200:\ :vb=\Ed\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\Eb:\ :tc=tvi950: # # uses the appropriate entries from 950-2p and 950-rv # ve|tvi950-rv-2p|950-rv-2p|televideo950 rev video w/2 pages:\ :is=\EDF\EC\Eb\EG0\Eg\Er\EO\E\047\E(\E%\Ew\EX\Ee ^O\ \Ek\E016\E004\Ex0\200\200\Ex1\200\200\Ex2\200\200\ \Ex3\200\200\Ex4\r\200\E\\2\E-07 :\ :vb=\Ed\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\Eb:\ :te=\E\\2\E-07 :ti=\E\\1\E-07 :ks=\El:ke=\Ek:tc=tvi950: # # uses the appropriate entries from 950-4p and 950-rv # vf|tvi950-rv-4p|950-rv-4p|televideo950 rev video w/4 pages:\ :is=\EDF\EC\Eb\EG0\Er\EO\E\047\E(\E%\Ew\EX\Ee ^O\ \Ek\E016\E004\Ex0\200\200\Ex1\200\200\Ex2\200\200\ \Ex3\200\200\Ex4\r\200\E\\3\E-07 :\ :vb=\Ed\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\Eb:\ :te=\E\\3\E-07 :ti=\E\\1\E-07 :ks=\El:ke=\Ek:tc=tvi950: vg|tvi924|924|televideo model 924:\ :am:bs:xn:co#80:li#24:cm=\E=%+ %+ :cl=\E*0:cd=\Ey:ce=\Et:is=\Ek0\E"^O:\ :al=\EE:dl=\ER:im=:ei=:ic=\EQ:dc=\EW:if=/usr/share/tabset/stdcrt:ho=^^:\ :nd=^L:bt=\EI:pt:so=\EG4:se=\EG0:us=\EG8:ue=\EG0:up=^K:do=^V:kb=^H:\ :ku=^K:kd=^V:kl=^H:kr=^L:kh=^^:ma=^Vj^Kk^Ll^^H^R^L:k1=^A@\r:k2=^AA\r:\ :k3=^AB\r:k4=^AC\r:k5=^AD\r:k6=^AE\r:k7=^AF\r:k8=^AG\r:k9=^AH\r:\ :k0=^AI\r:ko=ic,dc,al,dl,cl,ce,cd,bt:sr=\Ej:\ :hs:fs=^Y\Es1:ts=\Ef:ds=\Es0\Ef^Y: vo|tvi924vb|924vb|televideo model 924 visual bells:\ :vb=\Eb\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\Ed:\ :tc=tvi924: # tvipt termcap from armsis@amber (Gene Rochlin), 9/19/84. Works with vi and # rogue. NOTE: Esc v sets autowrap on, Esc u sets 80 char/line (rather than # 40), Esc K chooses the normal character set. Not sure padding is needed, but # adapted from the tvi920c termcap. so and us are klutzy, but at least use no # screen space. vp|tvipt|televideopt:if=/usr/share/tabset/stdcrt:\ :is=\Ev\Eu\EK:al=5*\EE:am:bs:bt=\EI:ce=\ET:cm=\E=%+ %+ :cl=^Z:co#80:\ :dl=5*\ER:kb=^H:ku=^K:kd=^J:kl=^H:kr=^L:ho=^^:li#24:nd=^L:se=\EF:\ :so=\EG1@A\EH:ue=\EF:us=\EG1B@\EH:up=^K:ma=^Kk^Ll^R^L: # Vanilla tvi910 -- W. Gish (cswarren@violet) 10/29/86 vm|tvi910|910|televideo model 910:if=/usr/share/tabset/stdcrt:\ :bs:bt=\EI:cd=\EY:ce=\ET:cm=\E=%+ %+ :cl=^Z:co#80:\ :kb=^H:ku=^K:kd=^J:kl=^H:kr=^L:k1=^A@\r:k2=^AA\r:k3=^AB\r:k4=^AC\r:\ :k5=^AD\r:k6=^AE\r:k7=^AF\r:k8=^AG\r:k9=^AH\r:k0=^AI\r:\ :li#24:nd=^L:pt:se=\EG0:so=\EG4:up=^K:us=\EG8:ue=\EG0:\ :ho=\E=\001\001:ma=^Kk^Ll^R^L:sg#1: # from Alan R. Rogers (rogers%albany@csnet-relay) vh|tvi910+|910+|televideo 910+:\ :al=5*\EE:am:bs:bt=\EI:cd=\EY:ce=\ET:cl=^Z:cm=\E=%+\040%+\040:\ :co#80:dc=\EW:dl=\ER:do=^J:ei=:ho=^^:ic=\EQ:\ :if=/usr/share/tabset/stdcrt:im=:k0=^A@\r:k1=^AA\r:k2=^AB\r:k3=^AC\r:\ :k4=^AD\r:k5=^AE\r:k6=^AF\r:k7=^AG\r:k8=^AH\r:k9=^AI\r:kb=^H:\ :kd=^J:kh=^^:kl=^H:kr=^L:ku=^K:li#24:ll=\E=7\040:ma=^K^P^L\040:\ :nd=^L:pt:se=\EG0:sg#1:so=\EG4:ue=\EG0:up=^K:us=\EG8:xn: # From fair@ucbarpa Sun Oct 27 07:21:05 1985 v6|ims950-b|bare ims950 no is:\ :is@:tc=ims950: v7|ims950-ns|ims950 w/no standout:\ :so@:se@:us@:ue@:tc=ims950: va|ims950|ims televideo 950 emulation:\ :k0@:k1@:k2@:k3@:k4@:k5@:k6@:k7@:k8@:k9@:kb@:kd@:kh@:kl@:ko@:kr@:ku@:\ :vb@:xn@:tc=tvi950: vd|ims950-rv|ims tvi950 rev video:\ :k0@:k1@:k2@:k3@:k4@:k5@:k6@:k7@:k8@:k9@:kb@:kd@:kh@:kl@:ko@:kr@:ku@:\ :vb@:xn@:tc=tvi950-rv: vx|ims-ansi|ultima2|ultimaII|IMS Ultima II:\ :pt:am:bs:co#80:li#24:\ :is=\E[0m\E[>14l\E[?1;?5;20l\E>\E[1m^M:if=/usr/share/tabset/vt100:\ :cl=\E[;H\E[2J:cd=\E[0J:ce=\E[0K:cm=\E[%i%2;%2H:up=\EM:do=\ED:\ :ku=\E[A:kd=\E[B:kr=\E[C:kl=\E[D:kh=\E[H:\ :so=\E[7m:se=\E[0m\E[1m:us=\E[4m:ue=\E[0m\E[1m:sr=\EM: # # -------------------------------- # # y: TELERAY # # Note two things called "teleray". Reorder should move the common one # to the front if you have either. A dumb teleray with the cursor stuck # on the bottom and no obvious model number is probably a 3700. y1|t3700|teleray|dumb teleray 3700:\ :do=^J:le=^H:bs:cl=^L:co#80:li#24: y3|t3800|teleray 3800 series:\ :do=^J:le=^H:bs:cd=\EJ:ce=\EK:cl=^L:cm=\EY%+ %+ :co#80: \ :do=\n:ho=\EH:li#24:ll=\EY7 :nd=\EC:pt:up=^K: y6|t1061|teleray 1061:\ :if=/usr/share/tabset/teleray:\ :ct=\EG:st=\EF:do=^J:\ :al=2*\EL:am:le=^H:bs:cd=1\EJ:ce=\EK:cl=1^L:cm=\EY%+ %+ :co#80:\ :dc=\EQ:dl=2*\EM:ei=:ho=\EH:ic=\EP:im=:ip=0.4*:\ :k1=^Z1:k2=^Z2:k3=^Z3:k4=^Z4:k5=^Z5:k6=^Z6:k7=^Z7:k8=^Z8:\ :li#24:nd=\EC:pt:se=\ER@:so= \ERD:\ :is=\Ee\EU01^Z1\EV\EU02^Z2\EV\EU03^Z3\EV\EU04^Z4\EV\EU05^Z5\EV\EU06^Z6\EV\EU07^Z7\EV\EU08^Z8\EV\Ef:\ :up=\EA:us=\ERH:ue=\ER@:xs:xt:sg#2:ug#1: # "Teleray Arpa Special", offically designated as # "Teleray Arpa network model 10" with "Special feature 720". # This is the new (1981) fast microcode updating the older "arpa" proms # (which gave meta-key and pgmmable-fxn keys). 720 is much much faster, # converts the keypad to programmable function keys, and has other goodies. # Standout mode is still broken (magic cookie, etc) so is suppressed as no # programs handle such lossage properly. # Note: this is NOT the old termcap's "t1061f with fast proms." # From Univ of Utah, J.Lepreau Tue Feb 1 06:39:37 1983 # lepreau@utah-cs, harpo!utah-cs!lepreau # y7|t10|teleray 10 special:\ :so@:se@:us@:ue@:\ :al=\EL:bs:cd=\EJ:ce=\EK:cl=30\Ej:cm=\EY%+ %+ :co#80:\ :dc=\EQ:dl=\EM:ei=:ho=\EH:ic=\EP:im=:km:li#24:nd=\EC:pc=\200:pt:\ :se=\ER@:so=\ERD:sf=\Eq:sg#2:sr=\Ep:up=\EA:ug#1:ue=\ER@:us=\ERH:\ :xs:xt: yf|t1061f|teleray 1061 with fast PROMs:\ :al=\EL:ip@:dl=\EM:tc=t1061: # Wyse 50 entry by Toni Guttman extended by Jeff Anton ye|w50|wyse50|Wyse 50:\ :al=\EE:am:bs:bt=\EI:cd=\EY:ce=\ET:cl=^Z:cm=\E=%+ %+ :co#80:\ :dc=\EW:dl=\ER:do=^J:ei=\Er:im=\Eq:is=\E`\072\200\EC\EDF\E0\E'\E(\EA21:\ :kd=^J:kl=^H:kr=^L:ku=^K:li#24:nd=^L:up=^K:us=\EG8:ue=\EG0:\ :so=\EG4:se=\EG0:sg#1:sr=\Ej:ho=^^:ug#1: # it is not known if the status line works with sysline yh|w50-s|wyse50-s|Wyse 50 for sysline:\ :hs:ts=\Ef:fs=\r:ds=\Ef\r:es:tc=w50: yg|w50-w|w50-132|wyse50-132|Wyse 50-132:\ :cm=\Ea%i%dR%dC:co#132:is=\E`;\200\EC\EDF\E0\E'\E(\EA21:tc=w50: w6|w60|wyse60|Wyse 60 in native mode:\ :ae=\EcD:al=\EE:am:as=\EcE:bs:bt=\EI:bw:cd=\Ey:ce=\Et:\ :cl=^Z:cm=\E=%+\040%+\040:co#80:ct=\E0:dc=\EW:dl=\ER:do=^J:\ :ei=\Er:im=\Eq:is=:kb=^?:kd=^N:ke=\E~2:kl=^B:kr=^F:ks=\E~3:ku=^P:\ :le=^H:li#43:ll=^^^K:mb=\EG2:me=\EG0:mh=\EGp:mi:mr=\EG4:ms:\ :nd=^L:pt:se=\EG0:sf=\n:so=\EG4:sr=\Ej:ue=\EG0:up=^K:us=\EG8: # from John Gillmore hoptoad!gnu@lll-crg.arpa wv|wyse-vp|wyse|Wyse 50 in ADDS Viewpoint emulation mode with "enhance" on:\ :am:do=^J:if=/usr/share/tabset/wyse-adds:\ :le=^H:bs:li#24:co#80:cm=\EY%+ %+ :cd=\Ek:ce=\EK:nd=^F:\ :up=^Z:cl=^L:ho=^A:ll=^A^Z:kl=^U:kr=^F:kd=^J:ku=^Z:kh=^A:\ :pt:so=^N:se=^O:us=^N:ue=^O:dl=\El:al=\EM:im=\Eq:ei=\Er:dc=\EW:\ :is=\E`\072\E`9^O\Er:rs=\E`\072\E`9^O\Er: wk|wyse-vp-nk|Wyse 50 in ADDS Viewpoint enhanced mode with cursor keys gone:\ :kl@:kr@:kd@:ku@:kh@:tc=wyse-vp: vw|wyse925|Wyse-50 emulating tvi925:\ :xn@:tc=tvi925: # wyse 75 series from JLarson.pa@xerox.arpa wx|wyse75|wy75|wyse 75 terminal :\ :co#80:li#24:cl=50\E[H\E[2J:bs:cm=5\E[%i%d;%dH:nd=\E[C:up=\E[A:\ :al=3\E[L:dl=3\E[M:ku=\E[A:kd=\E[B:kr=\E[C:kl=\E[D:do=\E[B:\ :ic=\E[@:ei=:im=:pt:bw:dc=\E[P:ce=3\E[K:ho=10\E[H:pt:\ :mi:nd=\E[C:bt=\E[Z:us=\E[8p:ue=\E[p:so=\E[5m:se=\E[m:\ :md=\E[1p:mr=\E[16p:mb=\E[2p:mk=\E[4p:me=\E[0p:hs:ll=\E[24;1H:\ :cd=50\E[J:cs=9\E[%i%d;%dr:ae=\E(B:as=\E(0:kh=\E[H:kb=^H:\ :k0=\EOP:k1=\EOQ:k2=\EOR:k3=\EOS:k4=\E[M:\ :k5=\E[17~:k6=\E[31~:k7=\E[18~:k8=\E[19~:k9=\E[20~:kn#10:\ :l0=PF1:l1=PF2:l2=PF3:l3=PF4:l4=F5:\ :l5=F6:l6=F7:l7=F8:l8=F9:l9=F10:\ :is=\E[1;24r\E[24;1H\E[35;?25h\E[4;?10;3;1l\E[m\E(B\E>:\ :ds=\E7\E[>,//\E8:ts=\E7\E[>,^A:fs=^A\E8: wx|wyse75-80|wy75-80|wyse 75 terminal with 80-column initialization:\ :is=\E[?3l:tc=wy75: wl|wyse75-132|wy75-132|wyse 75 terminal with 132 columns :\ :is=\E[?3h:co#132:tc=wy75: # # Wyse WY75 utilizing keypad # w5|wy75ap|wyse75ap|wy-75ap|wyse-75ap|Wyse WY-75 Applications and Cursor keypad:\ :is=\E[1;24r\E[?10;3l\E[?1;25h\E[4l\E[m\E(B\E=:\ :kd=\EOB:ke=10\E[?1l\E>:kh=\EOH:kl=\EOD:kr=\EOC:\ :ks=10\E[?1h\E=:ku=\EOA:\ :tc=wyse75: # from ucbvax!ucsfmis!shewmake Wc|wy85|wyse85|wyse-85:\ :do=^J:co#80:li#24:cl=\E[;H\E[2J:\ :le=^H:bs:cm=\E[%i%d;%dH:nd=\E[C:up=\E[A:\ :ce=\E[0K:cd=\E[0J:so=\E[7m:se=\E[27m:\ :us=\E[4m:ue=\E[24m:\ :is=\E[1;24r\E[24;1H\E[0m:\ :ks=\E[?1h\E=:ke=\E[?1l\E>:\ :ku=\EOA:kd=\EOB:kr=\EOC:kl=\EOD:kb=^H:\ :ho=\E[H:k1=\EOP:k2=\EOQ:k3=\EOR:k4=\EOS:kh=\E[H"ta=^I:pt:sr=\EM:\ :sc=\E7:rc=\E8:cs=\E[%i%d;%dr:as=^N:ae=^O:bt=\E[Z:\ :dc=\E[P:dl=\E[M:al=\E[L:ei=\E[4l:im=\E[4h:\ :vb=\E[?5h\E[?5l:\ :hs:es:ts=\E7\E[?25l\E[40h\E[25;%dH\E[2K:fs=\E[1;24r\E8\E[?25h: # # -------------------------------- # # z: Miscellaneous # z0|wind:\ :bs:cm=\Ep%r%.%.:cl=\En\120\030\Eo:co#80:\ :ho=\Ep\200\200:li#24:nd=^L:up=^K:nl=\035:\ :kl=\E3:kr=\E4:ku=\E1:kd=\E2:k1=\E5:k2=\E6:k3=\E7:k4=\E8:\ :so=\Em\014:se=\Em\003: z1|wind16:\ :bs:cm=\Ep%r%.%.:cl=\En\120\020\Eo:co#80:\ :ho=\Ep\200\200:li#16:nd=^L:up=^K:nl=\035:\ :so=\Em\014:se=\Em\003: z2|wind40:\ :bs:cm=\Ep%r%.%.:cl=\En\120\050\Eo:co#80:\ :ho=\Ep\200\200:li#40:nd=^L:up=^K:nl=\035:\ :so=\Em\014:se=\Em\003: z3|wind50:\ :bs:cm=\Ep%r%.%.:cl=\En\128\062\Eo:co#88:\ :ho=\Ep\200\200:li#50:nd=^L:up=^K:nl=\035:\ :kl=\E3:kr=\E4:ku=\E1:kd=\E2:k1=\E5:k2=\E6:k3=\E7:k4=\E8:\ :so=\Em\014:se=\Em\003: z4|cad68-3|cgc3|cad68 basic monitor transparent mode size 3 chars:\ :am:bs:cl=^Z:co#73:ho=\036:li#36:nd=^L:up=^K: z5|cad68-2|cgc2|cad68 basic monitor transparent mode size 2 chars:\ :am:bs:cl=^Z:co#85:ho=\036:li#39:nd=^L:up=^K:\ :kl=\E3:kr=\E4:ku=\E1:kd=\E2:k1=\E5:k2=\E6:k3=\E7:k4=\E8:\ :so=\Em\014:se=\Em\003: z6|v50|visual 50:\ :am:bs:al=\EL:dl=\EM:\ :cd=\Ek:ce=\EK:cl=^Z:cm=\E=%+\040%+\040:co#80:do=^J:ho=\EH:\ :kb=^H:kd=\EB:kh=\EH:kl=\ED:kr=\EC:ku=\EA:li#24:ms:nd=^L:pt:\ :so=\EU:se=\ET:up=^K: z7|trs2|trsII|trs80II|Radio Shack Model II using P&T CP/M:\ :nl=^_:al=^D:am:bs:cd=^B:ce=^A:cl=^L:cm=\EY%+ %+ :co#80:\ :dl=^K:do=^_:ho=^F:li#24:nd=^]:ms:pt:se=^O:so=^N:up:=^^:\ :kb=^H:kd=^_:kl=^\:kr=^]:ku=^^: z9|ps300|Picture System 300:us@:ue@:so@:se@:xt:pt@:tc=vt100: za|masscomp2:co#64:li#21:tc=masscomp: zb|masscomp1:co#104:li#36:tc=masscomp: zc|masscomp:\ :al=\E[L:bs:cd=\E[J:ce=\E[K:co#80:dc=\E[P:dl=\E[M:do=\E[B:\ :ei=\E[4l:im=\E[4h:is=\EGc\EGb\EGw:li#24:mi:MT:nd=\E[C:pt:se=\E[0m:\ :sg#0:so=\E[7m:cm=\E[%i%d;%dH:ue=\EGau:us=\EGu:up=\E[A:\ :ku=\EOA:kd=\EOB:kr=\EOC:kl=\EOD:kb=^h:cl=\E[2J: # Kimtron TC entries include (undocumented) codes for: enter dim mode (mh), # enter bold mode (md), enter reverse mode (mr), turn off all attributes (me) # Kimtron ABM 85 added by Dual Systems zd|abm85|Kimtron ABM 85:\ :is=\EC\EX\Eg\En\E%\Er\E(\Ek\Em\Eq:if=/usr/share/tabset/stdcrt:\ :li#24:co#80:am:bs:bw:ms:pt:\ :cl=\E*:cd=\Ey:dl=\ER:al=\EE:ce=\Et:dc=\EW:im=\EQ:ei=\Er:\ :cm=\E=%+ %+ :do=^J:nd=^L:up=^K:bt=\EI:\ :kh=^^:kb=^H:kd=^J:ku=^K:kd=^J:kl=^H:kr=^L:\ :so=\Ej:se=\Ek:sg#1:us=\El:ue=\Em:ug#1: # Kimtron ABM 85H added by Dual Systems. # Some notes about the 85h entries: # 1) there are several firmware revs of 85H in the world. Use o85h for # firmware revs prior to SP51 # 2) Make sure to use 85h entry if the terminal is in 85H mode and the # 85e entry if it is in 920 emulation mode. They are incompatible in # some places and NOT software settable i.e., `is' can't fix change it) # 3) In 85h mode, the arrow keys and special functions transmit when # the terminal is in dup-edit, and work only locally in local-edit. # Vi won't swallow `del char' for instance, but `vs' turns on # dup-edit anyway so that the arrow keys will work right. If the # arrow keys don't work the way you like, change `vs', `ve', and `is'. # 920E mode does not have software commands to toggle between dup # and local edit, so you get whatever was set last on the terminal. # 4) vb attribute is nice, but seems too slow to work correctly (\Eb\Ed) # 5) Make sure `hidden' attributes are selected. If `embedded' attributes # are selected, the entries :sg@: and :ug@: should be removed. # 6) auto new-line should be on (selectable from setup mode only) # # From fair@ucbarpa Sun Oct 27 07:21:05 1985 ze|85h|85H|abm85h|Kimtron ABM 85H, 85H mode:\ :is=\EC\EN\EX^T^N\EA\Ea\E%\E9\Ee\Er\En\E"\E}\E'\E(\Ef^M\EG0\Ed\E.4\El:\ :im=\EZ:kd=^V:so=\EG4:se=\EG0:us=\EG8:ue=\EG0:vb@:vs=\E.2:ve=\E.4:\ :mh=\E):mr=\EG4:me=\E(\EG0:sg@:ug@:ds=\Ee:fs=^M:hs:ts=\Eg\Ef:tc=abm85: zf|85e|85E|abm85e|Kimtron ABM 85H, 920E mode:\ :is=\EC\EX\EA\E%\E9\Ee\Er\En\E"\E}\E'\E(\Ef^M\Ek\Eq\Em:\ :mh=\E):mr=\Ej:me=\E(\Ek:im=\EZ:sg@:ug@:vb@:tc=abm85: zg|o85h|oabm85h|Kimtron ABM 85H, old firmware rev.:\ :is=\E}\EC\EX\Ee\En\E%\Er\E(\Ek\Em\Eq\Ed\ET\EC\E9\EF:\ :im=\EZ:sg@:ug@:vb=\200\200\200^G\200\200\200:\ :mh=\E):mr=\Ej:me=\E(\Ek:tc=abm85: #from malman@bbn-vax.arpa zE|kt7|kimtron model kt-7:\ :am:bs:co#80:li#24:cm=\E=%+ %+ :cl=^Z:cd=\EY:ce=\ET:is=\El\E":\ :al=\EE:dl=\ER:im=:ei=:ic=\EQ:dc=\EW:if=/usr/share/tabset/stdcrt:\ :ho=^^:nd=^L:bt=\EI:pt:so=\EG4:se=\EG0:sg#0:us=\EG8:ue=\EG0:ug#0:\ :up=^K:do=^V:kb=^H:ku=^K:kd=^V:kl=^H:kr=^L:kh=^^:ma=^V^J^L :\ :k1=^A@\r:k2=^AA\r:k3=^AB\r:k4=^AC\r:k5=^AD\r:k6=^AE\r:k7=^AF\r:\ :k8=^AG\r:k9=^AH\r:k0=^AI\r:ko=ic,dc,al,dl,cl,ce,cd,bt:\ :ts=\Ef:fs=\Eg: zh|appleII|apple ii plus:vs=\024\103\066:ve=\024\103\062:\ :am:co#80:ce=\035:li#24:cl=\014:bs:nd=\034:up=\037:ho=\E\031:pt:\ :cd=\013:so=\017:se=\016:cm=\036%r%+ %+ :is=\024T1\016:do=^J:kd=^J:\ :vb=\024G1\024T1:kr=: # Gary Ford 21NOV83 # New version from ee178aci%sdcc7@SDCSVAX.ARPA Fri Oct 11 21:27:00 1985 zi|apple-80|apple II with smarterm 80 col:\ :am:bs:bt=^R:bw:cd=10*^K:ce=10^]:cl=10*^L:cm=^^%r%+ %+ :\ :co#80:cr=10*^M:do=^J:ho=^Y:le=^H:li#24:nd=^\\:up=^_: # zj|lisa|apple lisa xenix console display (white on black):\ :al=\E[L:am:bs:cd=\E[J:ce=\E[K:cl=^L:cm=\E[%i%d;%dH:co#88:\ :dc=\E[P:dl=\E[M:dn=\E[B:ei=:ho=\E[H:ic=\E[@:im=:li#32:\ :nd=\E[C:ms:pt:so=\E[m:se=\E[7m:us=\E[4m:ue=\E[7m:up=\E[A:\ :kb=^h:ku=\E[A:kd=\E[B:kl=\E[D:kr=\E[C:eo:\ :is=\E[7m^L:GS=\E[11m:GE=\E[10m:GV=\140:GH=a:G1=c:\ :G2=f:G3=e:G4=d:GU=u:GD=s:GC=b:GL=v:GR=t: # The following is a version of the ibm-pc entry distributed with PC/IX, # (Interactive Systems' System 3 for the Big Blue), modified by Richard # McIntosh at UCB/CSM. The :pt: and :uc: have been removed from the original, # (the former is untrue, and the latter failed under UCB/man); standout and # underline modes have been added. Note: this entry describes the "native" # capabilities of the PC monochrome display, without ANY emulation; most # communications packages (but NOT PC/IX connect) do some kind of emulation. pc|ibmpc|ibm pc PC/IX:\ :li#24:co#80:am:bs:bw:eo:\ :cd=\E[J:ce=\E[K:cl=\Ec:cm=\E[%i%2;%2H:do=\E[B:ho=\E[;H:\ :nd=\E[C:up=\E[A:so=\E[7m:se=\E[0m:us=\E[4m:ue=\E[0m: pc3-bold|ibmpc3|IBM PC BSD/386 Console with bold instead of underline:\ :us=\E[=15F:ue=\E[=R:tc=pc3:\ pc3|ibmpc3|IBM PC BSD/386 Console:\ :li#25:al=\E[L:dl=\E[M:md=\E[=15F:me=\E[=R:mh=\E[=8F:\ :kh=\E[H:kH=\E[F:kP=\E[I:kN=\E[G:kI=\E[L:\ :ku=\E[A:kd=\E[B:kl=\E[D:kr=\E[C:tc=pc: zk|ibmx|ibmpcx|IBM PC xenix console display:\ :al=\E[L:am:bs:cd=\E[J:ce=\E[K:cl=^L:cm=\E[%d;%dH:co#80:\ :dc=\E[P:dl=\E[M:dn=\E[B:ei=:ho=\E[H:ic=\E[@:im=:li#25:\ :nd=\E[C:ms:se=\E[0m:so=\E[7m:us=\E[4m:\ :ue=\E[m:up=\E[A:MR=\E[0m:\ :kb=^h:kh=\E[Y:ku=\E[A:kd=\E[B:kl=\E[D:kr=\E[C:eo:\ :GS=\E[11m:GE=\E[10m:\ :GC=b:GL=v:GR=t:RT=^J:\ :GH=\E[196g:GV=\E[179g:\ :GU=\E[193g:GD=\E[194g:\ :G1=\E[191g:G2=\E[218g:G3=\E[192g:G4=\E[217g:\ :CW=\E[E:NU=\E[F:RF=\E[G:RC=\E[H:\ :WL=\E[K:WR=\E[L:CL=\E[M:CR=\E[N:\ :HM=\E[Y:EN=\E[d:PU=\E[Z:PD=\E[e: zl|ibmc|ibmcpc|IBM PC xenix color console display:\ :tc=ibm: zl|ibmcx|ibmcpcx|IBM PC xenix color console display:\ :tc=ibmx: zm|kaypro|kaypro2|kaypro II:\ :am:bs:cm=\E=%+ %+ :cl=1^Z:co#80:ho=^^:li#24:ma=^K^P:nd=^L:up=^K:\ :kr= :kl=^H:ku= :kd=^J: # From Suk Lee ..!{decvax,linus,allegra,ihnp4}!utcsrgv!spoo zn|trs100|Radio Shack Model 100:\ :am:bs:le=^H:li#8:co#40:ku=^^:kd=^_:kl=^]:kr=^\:up=\EA:\ :nd=\EC:ho=\EH:ce=\EK:cd=\EJ:cl=\EE:xt:cm=\EY%+ %+ :\ :so=\Ep:se=\Eq:al=\EL:dl=\EM: zt|mac|macintosh|Macintosh with MacTerminal:\ :al=20\E[L:dl=20\E[M:ip=7:dc=7\E[P:ic=9\E[@:xn:dN#30:tc=vt100: zs|zen50|z50:zephyr:\ :cm=\E=%+ %+ :cd=\EY:co#80:li#24:\ :am:al=\EE:ce=\ET:dc=\EW:dl=\ER:ic=\EQ:im=:ei=:\ :cl=\E+:bs:ma=^Hh^Ll^Jj^Kk:sg#1:se=\EGO:so=\EG4:\ :kl=^H:kr=^L:ku=^K:kd=^J:kh=\036:up=^K:\ :BS=^U:CL=^V:CR=^B:RK=^L:UK=^K:LK=^H:DK=^J:HM=\036: zu|go140|graphon go-140:\ :co#80:li#24:cl=10\E[;H\E[2J:bs:cm=\E[%i%2;%2H:nd=\E[C:up=\E[A:\ :ce=\E[K:cd=10\E[J:so=\E[7m:se=\E[m:us=\E[4m:ue=\E[m:\ :is=\E<\E=\E[?3l\E[?7l\E(B\E[J\E7\E[;r\E8\E[m\E[q:\ :dl=\E[M:al=\E[L:dc=\E[P:im=\E[4h:ei=\E[4l:\ :ks=\E[?1h\E=:ke=\E[?1l\E>:\ :if=/usr/share/tabset/vt100:ku=\EOA:kd=\EOB:kr=\EOC:kl=\EOD:\ :kh=\E[H:k1=\EOP:k2=\EOQ:k3=\EOR:k4=\EOS:pt:sr=\EM: zv|go140w|graphon go-140 in 132 column mode:\ :co#132:is=\E<\E=\E[?3h\E[?7h\E(B\E[J\E7\E[;r\E8\E[m\E[q:\ :tc=go140: zw|sanyo55|sanyo|sanyo mbc-55x pc compatible:\ :co#80:li#25:am:cl=\E[H\E[J:bs:cm=\E[%i%d;%dH:nd=\E[C:up=\E[A:\ :ce=\E[K:cd=\E[J:so=\E[7m:se=\E[m:us=\E[4m:ue=\E[m: #From: Simson L. Garfinkel zC|ST|atari st:\ :bs:cd=\EJ:ce=\EK:cl=\EH\EJ:cm=\EY%+ %+ :co#80:li#25:nd=\EC:\ :pt:sr=\EI:up=\EA:ku=\EA:kd=\EB:kr=\EC:kl=\ED:\ :do=\EB:\ :so=\Ep:se=\Eq:dl=\EM:al=\EL:am: # UniTerm terminal program for the Atari ST: 49-line VT220 emulation mode # From Paul M. Aoki, aoki@ucbvax.Berkeley.EDU zD|uniterm|uniterm49|UniTerm VT200 emulator, 49 lines:\ :li#49:is=\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h\E[1;49r\E[49;1H:\ :tc=vt200: # YTERM standard version 1.0. (gts 9-25-84) # Straight old ascii keyboard except function keys are Yale (e.g.,ASCII.KBD). # Only 80 tab columns (else yterm 1.1 bug). No :xn: in 1.0. # Cannot use termcap :sr=\EM: because vi will not work, too bad. # vi string is given so that yterm is reset each vi startup. Y0|yterm10|yterm 1.0 UCB ascii.kbd:\ :am:bs:cd=^K:ce=^]:cl=^L:cm=^^%r%+ %+ :co#80:EP:ho=^Y:li#24:nd=^\:pt:\ :rc=\E8:sc=\E7:so=\E[7m:se=\E[m:up=^_:us=\E[4m:ue=\E[m:\ :is=^O\E[7i\E[m\E[?7h\E[?3g\r\EHY0 for \EHYTERM 1.\EH0 with A\EHSCII.KBD\EH 9-13-84\EH \EH \EH \EH \EH\n:\ :ku=^K:kd=^J:kl=^H:kr=^L:kh=^^:ma=h\012j k lH:\ :k0=\E0:k1=\E1:k2=\E2:k3=\E3:k4=\E4:k5=\E5:k6=\E6:k7=\E7:k8=\E8:k9=\E9:\ :vs=^O\E[7i\E[m\E[?7h\E[?3g\r\EHY0 \EH \EH \EH \EH \EH \EH \EH \EH \EH\r: # YTERM varient version 1.1. (gts 9-13-84) Version 1.1 has :xn:. Y1|yterm11|yterm 1.1 UCB ascii.kbd:\ :xn:is=^O\E[7i\E[m\E[?7h\E[?3g\r\EHY1 for \EHYTERM 1.\EH1 with A\EHSCII.KBD\EH 9-13-84\EH \EH \EH \EH \EH\n:\ :tc=yterm10 # YTERM 1.0 varient no autowrap or tabs # X does not remember autowrap or tabs when T is deleted and restarted. Y2|yterm10nat|yterm 1.0 UCB ascii.kbd no autowrap or tabs:\ :am@:pt@:vs=^O\E[7i\E[m\E[?7l\E[?3g\rY2\r:\ :is=^O\E[7i\E[m\E[?7l\E[?3g\rY2 for YTERM 1.0 with ASCII.KBD 9-20-84 no autowrap or tabs\n:\ :tc=yterm10 # KERMIT standard all versions. (gts 9-25-84) # Straight ascii keyboard. :sr=\EI: not avail. many versions + bug prone in vi. K0|kermit|standard kermit:\ :bs:cd=\EJ:ce=\EK:cl=\EE:cm=\EY%+ %+ :co#80:ho=\EH:li#24:nd=\EC:up=\EA:\ :ku=^K:kd=^J:kl=^H:kr=^L:kh=^^:ma=^Hh\012j^Kk^Ll^^H:\ :is=K0 Standard Kermit 9-25-84\n: K1|kermitam|standard kermit plus am:\ :am:is=K1 Standard Kermit plus Automatic Margins\n:tc=kermit: # IBMPC Kermit 1.2. (gts 8-30-84) # Bugs :cd:ce: do not work except at beginning of line! :cl: does not work, # but fake with :cl=\EH\EJ (since :cd=\EJ: works at beginning of line). K2|pckermit|pckermit12|UCB IBMPC Kermit 1.2:\ :am:li#25:cd@:ce@:cl=\EH\EJ:\ :is=K2 UCB IBMPC Kermit 1.2 8-30-84\n:tc=kermit: # IBMPC Kermit 1.20 (gts 12-19-84) # Cannot use line 25, now acts funny like ansi special scrolling region. # Initialization must escape from that region by cursor position to line 24. # Cannot use character insert because 1.20 goes crazy if insert at col 80. # Does not use am: because autowrap mode lost when kermit dropped and restarted. K3|pckermit120|UCB IBMPC Kermit 1.20:\ :al=\EL:am@:dc=\EN:dl=\EM:do=\EB:ei@:im@:li#24:pt:se=\Eq:so=\Ep:\ :is=\EO\Eq\EJ\EY7 K3 UCB IBMPC Kermit 1.20 12-19-84\n:\ :vs=\EO\Eq\EEK3:tc=kermit: # MS-DOS Kermit 2.27 for the IBMPC (UCB gts 3-17-85) # Straight ascii keyboard. :sr=\EI: not avail. many versions + bug prone in vi. # Cannot use line 25, now acts funny like ansi special scrolling region. # Initialization must escape from that region by cursor position to line 24. # Does not use am: because autowrap mode lost when kermit dropped and restarted. # Reverse video for standout like H19. K4|msk227|mskermit227|MS-DOS Kermit 2.27 for the IBMPC:\ :al=\EL:am@:bs:cd=\EJ:ce=\EK:cl=\EE:cm=\EY%+ %+ :co#80:\ :dc=\EN:dl=\EM:do=\EB:ei=\EO:im=\E@:\ :ho=\EH:li#24:nd=\EC:up=\EA:pt:rc=\Ek:sc=\Ej:se=\Eq:so=\Ep:\ :ku=^K:kd=^J:kl=^H:kr=^L:kh=^^:ma=^Hh\012j^Kk^Ll^^H:\ :is=\EO\Eq\EG\Ew\EJ\EY7 K4 MS Kermit 2.27 for the IBMPC 3-17-85\n:\ :vs=\EO\Eq\EG\EwK4: # MS-DOS Kermit 2.27 with automatic margins (UCB gts 3-17-85) K5|msk227am|mskermit227am|UCB MS-DOS Kermit 2.27 with automatic margins:\ :am:\ :is=\EO\Eq\EG\Ev\EJ\EY7 K5 MS Kermit 2.27 +automatic margins 3-17-85\n:\ :vs=\EO\Eq\EG\EvK5:tc=mskermit227: # MS-DOS Kermit 2.27 UCB 227.14 for the IBM PC (UCB gts 3-17-85) # Automatic margins now default. Use ansi set graphic rendition for standout, # underline and ul codes (md,me,mr). Define function keys. K6|msk22714|mskermit22714|UCB MS-DOS Kermit 2.27 UCB 227.14 IBM PC:\ :am:kn#10:\ :k0=\E0:k1=\E1:k2=\E2:k3=\E3:k4=\E4:k5=\E5:k6=\E6:k7=\E7:k8=\E8:k9=\E9:\ :md=\E[1m:me=\E[m:mr=\E[7m:se=\E[m:so=\E[1m:ue=\E[m:us=\E[4m:\ :is=\EO\Eq\EG\Ev\EJ\EY7 K6 MS Kermit 2.27 UCB 227.14 IBM PC 3-17-85\n:\ :vs=\EO\Eq\EG\EvK6:tc=mskermit227: # From earle@smeagol.UUCP 29 Oct 85 05:40:18 GMT # MS-Kermit with Heath-19 emulation mode enabled Kh|h19k|h19kermit|heathkit emulation provided by Kermit (no auto margin):\ :am@:ta@:pt@:xt:da:db:tc=h19-u: # rough draft of Amiga termcap by Mike Meyer AA|amiga|Amiga ANSI:\ :co#80:li#25:am:do=\E[B:ce=\E[K:cd=\E[J:\ :cl=\E[H\E[J:ku=\E[A:kd=\E[B:kl=\E[C:kr=\E[D:kb=^H:\ :al=\E[L:dl=\E[M:le=^H:cm=\E[%i%d;%dH:nd=\E[C:up=\E[A:\ :ce=\E[K:ho=\E[H:dc=\E[P:ic=\E[@:\ :so=\E[2m:se=\E[m:us=\E[4m:ue=\E[m:mr=\E[7m:mb=\E[7;2m:me=\E[m: # The pcplot IBM-PC terminal emulation program is really messed up. It is # supposed to emulate a vt-100, but emulates the wraparound bug incorrectly, # doesn't support scrolling regions, ignores add line commands, and ignores # delete line commands. Consequently, the resulting behavior looks like a # crude adm3a-type terminal. # Steve Jacobson 8/85 pp|pcplot:\ :cs@:sc@:rc@:xn@:tc=vt100: # From Joel Rubin, jmrubin@coral, a preliminary TERMCAP for VIDTEX, # a terminal program sold by Compuserve. Line and column numbers are # computer-dependent (I have a Commodore '64); you should use the meta-B # option to shut off clean-breaking of lines. No key codes included # since some of them are programmable and most are machine-specific. # Works on vi if you don't use clean-breaking. Very similar to the IBM 3101 # termcap. Escape-D used for backspace because control-H is destructive # backspace. There seem to be a few weirdnesses (especially at the beginning # of a wrapped line), and the cursor does not, unfortunately, flash. zQ|vid|vidtex|Compuserve vidtex program:\ :am:bc=\ED:cl=^L:li#25:co#40:nd=\EC:up=\EA:cd=\EJ:ce=\EK:\ :ho=\EH:cm=\EY%+\40%+\40:pt: # Fortune from c160-3bp@Coral (Robert Nathanson) via tut Wed Oct 5, 1983 zK|fos|fortune|Fortune system:\ :is=^_..:li#25:co#80:am:bs:bw:cl=20^L:cd=3*^\Y:\ :ic=5^\Q:dc=5^\W:dl=15^\R:al=15^\E:cm=^\C%+ %+ :ta=^Z:ho=10^^:do=3^J:\ :up=3^K:bs=^H:kb=^H:kd=^Ay\r:kh=^A?\r:kl=^Aw\r:kr=^Az\r:ku=^Ax\r:\ :nl=5^J:so=^\H`:se=^\I`:sg=0:us=^\HP:ue=^\IP:ug=0:ce=^\Z:rv=\EH:re=\EI:\ :rg=0:GS=\Eo:GE=^O:GG=0:GV=-:GH=&:GU=%:GD=#:G1=(:G2= :G3=":G4=*:CF=\E]:\ :CO=\E\\:WL=^Aa\r:WR=^Ab\r:CL=^Ac\r:CR=^Ad\r:DL=^Ae\r:RF=^Af\r:\ :RC=^Ag\r:CW=^Ah\r:NU=^Aj\r:EN=^Ak\r:HM=^Al:PL=^Am\r:PU=^An\r:PD=^Ao\r:\ :PR=^Ap\r:HP=^A@\r:RT=^Aq\r:TB=\r:CN=\177:MP=\E+F: # basis from Peter Harrison, Computer Graphics Lab, San Francisco # ucbvax!ucsfmis!harrison ...uucp / ucbvax!ucsfmis!harrison@BERKELEY ...ARPA ba|basis|BASIS108 computer with terminal translation table active:\ :do=5000^J:nl=5000*^J:\ :cd=\EY:ce=\ET:cl=300\E*:ma=^K^P^R^L^L :\ :kb=^H:kl=^H:ku=^K:kr=^L:kd=^J:so=\E(:se=\E):tc=adm3a: # From Peter Harrison, Computer Graphics Lab, San Francisco # ucbvax!ucsfmis!harrison .....uucp # ucbvax!ucsfmis!harrison@BERKELEY .......ARPA # "These two work. If you don't have the inverse video chip for the # Apple with videx then remove the so and se fields." zO|DaleApple|Apple with videx videoterm 80 column board with inverse video:\ :do=^J:am:le=^H:bs:cd=^K:ce=^]:cl=300^L:cm=^^%r%+ %+ :co#80:ho=^Y:\ :kd=^J:kl=^H:kr=^U:kh=^Y:\ :li#24:nd=^\:pt:so=^Z3:se=^Z2:up=^_:xn: zJ|ibmaed|IBM Experimental display:\ :al=\EN:am:bs:cd=\EJ:ce=\EI:cl=\EH\EK:cm=\EY%+\40%+\40:co#80:\ :dc=\EQ:dl=\EO:do=\EB:ei=:ho=\EH:ic=\EP:im=:li#52:\ :nd=\EC:ms:so=\E0:se=\E0:us=:ue=:up=\EA:\ :kb=^h:ku=\EA:kd=\EB:kl=\ED:kr=\EC:eo:vb=\EG:pt: # funny terminal that the TANDEM uses. zA|653|t653x|Tandem 653x multipage terminal:\ :li#24:co#80:ho=\EH:cm=\023%+ %+ :cl=\EI:cd=\EJ:ce=\EK:am:bs:\ :if=/usr/share/tabset/tandem653:sb=\ES:sr=\ET:da:db:so=\E6$:se=\E6 :\ :us=\E60:ue=\E6 :sg#1:ug#1:up=\EA:do=\012:le=\010:nd=\EC:\ :hs:ts=\Eo:fs=\r:ds=\Eo\r:ws#64: # From Paul Leondis, unllab@amber.berkeley.edu zB|ifmr|Informer D304:\ :am:bs:cd=\E/:ce=\EQ:cl=\EZ:cm=\EY%r%+ %+ :co#80:dc=\E\\:\ :do=^J:im=:ei=:ic=\E[:li#24:nd=\EC:so=\EJ:se=\EK:up=\EA:\ :sr=\En:ho=\EH: # # END OF TERMCAP # ------------------------ ================================================ FILE: lib/libtermlib/termcap.c ================================================ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include #include #include #include #include #include #define BUFSIZ 1024 #define MAXHOP 32 /* max number of tc= indirections */ #define E_TERMCAP "/etc/termcap" /* * termcap - routines for dealing with the terminal capability data base * * BUG: Should use a "last" pointer in tbuf, so that searching * for capabilities alphabetically would not be a n**2/2 * process when large numbers of capabilities are given. * Note: If we add a last pointer now we will screw up the * tc capability. We really should compile termcap. * * Essentially all the work here is scanning and decoding escapes * in string capabilities. We don't use stdio because the editor * doesn't, and because living w/o it is not hard. */ static char *tbuf; static int hopcount; /* detect infinite loops in termcap, init 0 */ /* * Tnamatch deals with name matching. The first field of the termcap * entry is a sequence of names separated by |'s, so we compare * against each such name. The normal : terminator after the last * name (before the first field) stops us. */ static int tnamatch(np) char *np; { register char *Np, *Bp; Bp = tbuf; if (*Bp == '#') return(0); for (;;) { for (Np = np; *Np && *Bp == *Np; Bp++, Np++) continue; if (*Np == 0 && (*Bp == '|' || *Bp == ':' || *Bp == 0)) return (1); while (*Bp && *Bp != ':' && *Bp != '|') Bp++; if (*Bp == 0 || *Bp == ':') return (0); Bp++; } } /* * tnchktc: check the last entry, see if it's tc=xxx. If so, * recursively find xxx and append that entry (minus the names) * to take the place of the tc=xxx entry. This allows termcap * entries to say "like an HP2621 but doesn't turn on the labels". * Note that this works because of the left to right scan. */ static int tnchktc() { register char *p, *q; char tcname[16]; /* name of similar terminal */ char tcbuf[BUFSIZ]; char *holdtbuf = tbuf; int l; p = tbuf + strlen(tbuf) - 2; /* before the last colon */ while (*--p != ':') if (p MAXHOP) { write(2, "Infinite tc= loop\n", 18); return (0); } if (tgetent(tcbuf, tcname) != 1) { hopcount = 0; /* unwind recursion */ return(0); } for (q=tcbuf; *q != ':'; q++) ; l = p - holdtbuf + strlen(q); if (l > BUFSIZ) { write(2, "Termcap entry too long\n", 23); q[BUFSIZ - (p-tbuf)] = 0; } strcpy(p, q+1); tbuf = holdtbuf; hopcount = 0; /* unwind recursion */ return(1); } /* * Get an entry for terminal name in buffer bp, * from the termcap file. Parse is very rudimentary; * we just notice escaped newlines. */ int tgetent(bp, name) char *bp, *name; { register char *cp; register int c; register int i = 0, cnt = 0; char ibuf[BUFSIZ]; int tf; tbuf = bp; tf = -1; #ifndef V6 cp = getenv("TERMCAP"); /* * TERMCAP can have one of two things in it. It can be the * name of a file to use instead of /etc/termcap. In this * case it better start with a "/". Or it can be an entry to * use so we don't have to read the file. In this case it * has to already have the newlines crunched out. */ if (cp && *cp) { if (*cp == '/') { tf = open(cp, 0); } else { tbuf = cp; c = tnamatch(name); tbuf = bp; if (c) { strcpy(bp,cp); return(tnchktc()); } } } if (tf < 0) tf = open(E_TERMCAP, 0); #else tf = open(E_TERMCAP, 0); #endif if (tf < 0) return (-1); for (;;) { cp = bp; for (;;) { if (i == cnt) { cnt = read(tf, ibuf, BUFSIZ); if (cnt <= 0) { close(tf); return (0); } i = 0; } c = ibuf[i++]; if (c == '\n') { if (cp > bp && cp[-1] == '\\'){ cp--; continue; } break; } if (cp >= bp+BUFSIZ) { write(2,"Termcap entry too long\n", 23); break; } else *cp++ = c; } *cp = 0; /* * The real work for the match. */ if (tnamatch(name)) { close(tf); return(tnchktc()); } } } /* * Skip to the next field. Notice that this is very dumb, not * knowing about \: escapes or any such. If necessary, :'s can be put * into the termcap file in octal. */ static char * tskip(bp) register char *bp; { while (*bp && *bp != ':') bp++; if (*bp == ':') bp++; return (bp); } /* * Return the (numeric) option id. * Numeric options look like * li#80 * i.e. the option string is separated from the numeric value by * a # character. If the option is not found we return -1. * Note that we handle octal numbers beginning with 0. */ int tgetnum(id) char *id; { register int i, base; register char *bp = tbuf; for (;;) { bp = tskip(bp); if (*bp == 0) return (-1); if (*bp++ != id[0] || *bp == 0 || *bp++ != id[1]) continue; if (*bp == '@') return(-1); if (*bp != '#') continue; bp++; base = 10; if (*bp == '0') base = 8; i = 0; while (isdigit(*bp)) i *= base, i += *bp++ - '0'; return (i); } } /* * Handle a flag option. * Flag options are given "naked", i.e. followed by a : or the end * of the buffer. Return 1 if we find the option, or 0 if it is * not given. */ int tgetflag(id) char *id; { register char *bp = tbuf; for (;;) { bp = tskip(bp); if (!*bp) return (0); if (*bp++ == id[0] && *bp != 0 && *bp++ == id[1]) { if (!*bp || *bp == ':') return (1); else if (*bp == '@') return(0); } } } /* * Tdecode does the grung work to decode the * string capability escapes. */ static char * tdecode(str, area) register char *str; char **area; { register char *cp; register int c; register char *dp; int i; cp = *area; while ((c = *str++) && c != ':') { switch (c) { case '^': c = *str++ & 037; break; case '\\': dp = "E\033^^\\\\::n\nr\rt\tb\bf\f"; c = *str++; nextc: if (*dp++ == c) { c = *dp++; break; } dp++; if (*dp) goto nextc; if (isdigit(c)) { c -= '0', i = 2; do c <<= 3, c |= *str++ - '0'; while (--i && isdigit(*str)); } break; } *cp++ = c; } *cp++ = 0; str = *area; *area = cp; return (str); } /* * Get a string valued option. * These are given as * cl=^Z * Much decoding is done on the strings, and the strings are * placed in area, which is a ref parameter which is updated. * No checking on area overflow. */ char * tgetstr(id, area) char *id, **area; { register char *bp = tbuf; for (;;) { bp = tskip(bp); if (!*bp) return (0); if (*bp++ != id[0] || *bp == 0 || *bp++ != id[1]) continue; if (*bp == '@') return(0); if (*bp != '=') continue; bp++; return (tdecode(bp, area)); } } ================================================ FILE: lib/libtermlib/tgoto.c ================================================ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include #define CTRL(c) ('c' & 037) #define MAXRETURNSIZE 64 char *UP; char *BC; /* * Routine to perform cursor addressing. * CM is a string containing printf type escapes to allow * cursor addressing. We start out ready to print the destination * line, and switch each time we print row or column. * The following escapes are defined for substituting row/column: * * %d as in printf * %2 like %2d * %3 like %3d * %. gives %c hacking special case characters * %+x like %c but adding x first * * The codes below affect the state but don't use up a value. * * %>xy if value > x add y * %r reverses row/column * %i increments row/column (for one origin indexing) * %% gives % * %B BCD (2 decimal digits encoded in one byte) * %D Delta Data (backwards bcd) * * all other characters are ``self-inserting''. */ char * tgoto(CM, destcol, destline) char *CM; int destcol, destline; { static char result[MAXRETURNSIZE]; static char added[10]; char *cp = CM; register char *dp = result; register int c; int oncol = 0; register int which = destline; if (cp == 0) { toohard: /* * ``We don't do that under BOZO's big top'' */ return ("OOPS"); } added[0] = 0; while ((c = *cp++)) { if (c != '%') { *dp++ = c; continue; } switch (c = *cp++) { #ifdef CM_N case 'n': destcol ^= 0140; destline ^= 0140; goto setwhich; #endif case 'd': if (which < 10) goto one; if (which < 100) goto two; /* fall into... */ case '3': *dp++ = (which / 100) | '0'; which %= 100; /* fall into... */ case '2': two: *dp++ = which / 10 | '0'; one: *dp++ = which % 10 | '0'; swap: oncol = 1 - oncol; setwhich: which = oncol ? destcol : destline; continue; #ifdef CM_GT case '>': if (which > *cp++) which += *cp++; else cp++; continue; #endif case '+': which += *cp++; /* fall into... */ case '.': /* * This code is worth scratching your head at for a * while. The idea is that various weird things can * happen to nulls, EOT's, tabs, and newlines by the * tty driver, arpanet, and so on, so we don't send * them if we can help it. * * Tab is taken out to get Ann Arbors to work, otherwise * when they go to column 9 we increment which is wrong * because bcd isn't continuous. We should take out * the rest too, or run the thing through more than * once until it doesn't make any of these, but that * would make termlib (and hence pdp-11 ex) bigger, * and also somewhat slower. This requires all * programs which use termlib to stty tabs so they * don't get expanded. They should do this anyway * because some terminals use ^I for other things, * like nondestructive space. */ if (which == 0 || which == CTRL(d) || /* which == '\t' || */ which == '\n') { if (oncol || UP) /* Assumption: backspace works */ /* * Loop needed because newline happens * to be the successor of tab. */ do { strcat(added, oncol ? (BC ? BC : "\b") : UP); which++; } while (which == '\n'); } *dp++ = which; goto swap; case 'r': oncol = 1; goto setwhich; case 'i': destcol++; destline++; which++; continue; case '%': *dp++ = c; continue; #ifdef CM_B case 'B': which = (which/10 << 4) + which%10; continue; #endif #ifdef CM_D case 'D': which = which - 2 * (which%16); continue; #endif default: goto toohard; } } strcpy(dp, added); return (result); } ================================================ FILE: lib/libtermlib/tputs.c ================================================ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include #include /* * The following array gives the number of tens of milliseconds per * character for each speed as returned by gtty. Thus since 300 * baud returns a 7, there are 33.3 milliseconds per char at 300 baud. */ static short tmspc10[] = { 0, 2000, 1333, 909, 743, 666, 500, 333, 166, 83, 55, 41, 20, 10, 5 }; short ospeed; char PC; /* * Put the character string cp out, with padding. * The number of affected lines is affcnt, and the routine * used to output one character is outc. */ void tputs(cp, affcnt, outc) register char *cp; int affcnt; int (*outc)(); { register int i = 0; register int mspc10; if (cp == 0) return; /* * Convert the number representing the delay. */ if (isdigit(*cp)) { do i = i * 10 + *cp++ - '0'; while (isdigit(*cp)); } i *= 10; if (*cp == '.') { cp++; if (isdigit(*cp)) i += *cp - '0'; /* * Only one digit to the right of the decimal point. */ while (isdigit(*cp)) cp++; } /* * If the delay is followed by a `*', then * multiply by the affected lines count. */ if (*cp == '*') cp++, i *= affcnt; /* * The guts of the string. */ while (*cp) (*outc)(*cp++); /* * If no delay needed, or output speed is * not comprehensible, then don't try to delay. */ if (i == 0) return; if (ospeed <= 0 || ospeed >= (sizeof tmspc10 / sizeof tmspc10[0])) return; /* * Round up by a half a character frame, * and then do the delay. * Too bad there are no user program accessible programmed delays. * Transmitting pad characters slows many * terminals down and also loads the system. */ mspc10 = tmspc10[ospeed]; i += mspc10 / 2; for (i /= mspc10; i > 0; i--) (*outc)(PC); } ================================================ FILE: lib/libutil/Makefile ================================================ # # Copyright (c) 1988 Regents of the University of California. # All rights reserved. # # Redistribution and use in source and binary forms are permitted # provided that the above copyright notice and this paragraph are # duplicated in all such forms and that any documentation, advertising # materials, and other materials related to such redistribution and # use acknowledge that the software was developed by the University # of California, Berkeley. The name of the University may not be # used to endorse or promote products derived from this software # without specific prior written permission. THIS SOFTWARE IS PROVIDED # ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, # WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND # FITNESS FOR A PARTICULAR PURPOSE. # TOPSRC!=cd ../..; pwd include ${TOPSRC}/share/mk/sys.mk CFLAGS += ${DEFS} SRCS = login.c logout.c logwtmp.c OBJS = login.o logout.o logwtmp.o all: ../libutil.a ../libutil.a: ${OBJS} ${AR} cr $@ ${OBJS} $(RANLIB) $@ clean: rm -f *.a *.o *~ profiled/*.o tags cleandir: clean rm -f .depend depend: mkdep ${CFLAGS} ${SRCS} install: all # cp ../libutil.a ${DESTDIR}/usr/lib/ # $(RANLIB) -t ${DESTDIR}/usr/lib/libutil.a # cp libutil_p.a ${DESTDIR}/usr/lib/ # $(RANLIB) -t ${DESTDIR}/usr/lib/libutil_p.a tags: ctags ${SRCS} ================================================ FILE: lib/libutil/login.c ================================================ /* * Copyright (c) 1988 The Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the University of California, Berkeley. The name of the * University may not be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #include #include #include #include #include #include #include #include void login(ut) struct utmp *ut; { register int fd; int tty; off_t lseek(); tty = ttyslot(); if (tty > 0 && (fd = open(_PATH_UTMP, O_WRONLY, 0)) >= 0) { (void)lseek(fd, (long)(tty * sizeof(struct utmp)), L_SET); (void)write(fd, (char *)ut, sizeof(struct utmp)); (void)close(fd); } if ((fd = open(_PATH_WTMP, O_WRONLY|O_APPEND, 0)) >= 0) { (void)write(fd, (char *)ut, sizeof(struct utmp)); (void)close(fd); } } ================================================ FILE: lib/libutil/logout.c ================================================ /* * Copyright (c) 1988 The Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the University of California, Berkeley. The name of the * University may not be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #include #include #include #include #include #include #include #include typedef struct utmp UTMP; int logout(char *line) { int fd; UTMP ut; int rval; off_t lseek(); time_t time(); if ((fd = open(_PATH_UTMP, O_RDWR)) < 0) return (0); rval = 0; while (read(fd, (char *)&ut, sizeof(UTMP)) == sizeof(UTMP)) { if (!ut.ut_name[0] || strncmp(ut.ut_line, line, UT_LINESIZE)) continue; memset(ut.ut_name, 0, UT_NAMESIZE); memset(ut.ut_host, 0, UT_HOSTSIZE); (void)time(&ut.ut_time); (void)lseek(fd, -(long)sizeof(UTMP), L_INCR); (void)write(fd, (char *)&ut, sizeof(UTMP)); rval = 1; } (void)close(fd); return (rval); } ================================================ FILE: lib/libutil/logwtmp.c ================================================ /* * Copyright (c) 1988 The Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the University of California, Berkeley. The name of the * University may not be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #include #include #include #include #include #include #include #include #include void logwtmp(line, name, host) char *line, *name, *host; { struct utmp ut; struct stat buf; int fd; time_t time(); char *strncpy(); if ((fd = open(_PATH_WTMP, O_WRONLY|O_APPEND, 0)) < 0) return; if (!fstat(fd, &buf)) { (void)strncpy(ut.ut_line, line, sizeof(ut.ut_line)); (void)strncpy(ut.ut_name, name, sizeof(ut.ut_name)); (void)strncpy(ut.ut_host, host, sizeof(ut.ut_host)); (void)time(&ut.ut_time); if (write(fd, (char *)&ut, sizeof(struct utmp)) != sizeof(struct utmp)) (void)ftruncate(fd, buf.st_size); } (void)close(fd); } ================================================ FILE: lib/libvmf/.gitignore ================================================ *.0 ================================================ FILE: lib/libvmf/Makefile ================================================ # Copyright (c) 1980 Regents of the University of California. # All rights reserved. The Berkeley software License Agreement # specifies the terms and conditions for redistribution. # # vmf package # TOPSRC!=cd ../..; pwd include ${TOPSRC}/share/mk/sys.mk CFILES = vmf.c OBJS = vmf.o POBJS = ../vmf.o MAN = vmf.0 MANSRC = vmf.3 CTAGS = ctags #DEFS = -DNOSCCS #CFLAGS += -O ${DEFS} TAGSFILE = tags all: ../libvmf.a $(MAN) ../libvmf.a: ${OBJS} @echo building normal ../libvmf.a @${AR} cr ../libvmf.a ${OBJS} $(RANLIB) ../libvmf.a ../libvmf_p.a: ${OBJS} @echo building profiled ../libvmf.a @cd profiled; ${AR} cr ../../libvmf_p.a ${POBJS} $(RANLIB) ../libvmf_p.a $(MAN): $(MANSRC) ${MANROFF} ${MANSRC} > $@ install: all cp ${MAN} ${DESTDIR}/usr/share/man/cat3/ # cp ../libvmf.a ${DESTDIR}/usr/lib/libvmf.a # $(RANLIB) ${DESTDIR}/usr/lib/libvmf.a # cp ../libvmf_p.a ${DESTDIR}/usr/lib/libvmf_p.a # $(RANLIB) ${DESTDIR}/usr/lib/libvmf_p.a clean: rm -f *.o profiled/*.o a.out core test errs ../libvmf*.a vmf.0 ================================================ FILE: lib/libvmf/vmf.3 ================================================ .\" No copyright (1993) - Steven M. Schultz (sms@wlv.iipo.gtegsc.com) .\" @(#)vmf.3 3.0 (2.11BSD) 9/24/93 .\" .TH VMF 3 "September 24, 1993" .UC 6 .SH NAME vminit, vmopen, vmclose, vmmapseg, vmmodify, vmlock, vmunlock, vmclrseg, vmflush, \- disk based virtual memory routines .SH SYNOPSIS .nf .PP .ft B #include .PP .ft B struct vspace { int v_fd; /* file for swapping */ off_t v_foffset; /* offset for computing file addresses */ int v_maxsegno; /* number of segments in this space */ }; .PP .ft B struct vseg { /* structure of a segment in memory */ struct dlink s_link; /* for linking into lru list */ int s_segno; /* segment number */ struct vspace *s_vspace; /* which virtual space */ int s_lock_count; int s_flags; union { int _winfo[WORDSPERSEG]; /* the actual segment */ char _cinfo[BYTESPERSEG]; } v_un; }; #define s_winfo v_un._winfo #define s_cinfo v_un._cinfo .PP .ft B int vminit(nseg); int nseg; .PP .ft B int vmopen(space, filename); struct vspace *space; char *filename; .PP .ft B struct vseg *vmmapseg(space, segno); struct vspace *space; int segno; .PP .ft B void vmlock(seg); struct vseg *seg; .PP .ft B void vmunlock(seg); struct vseg *seg; .PP .ft B void vmclrseg(seg); struct vseg *seg; .PP .ft B void vmmodify(seg); .PP .ft B void vmflush(); .PP .ft B void vmclose(space); struct vspace *space; .fi .bp .SH DESCRIPTION This library provides a standard set of routines for managing large virtual memory spaces. It supports creation of multiple concurrent virtual spaces, mapping of virtual pages into real memory, a lock/unlock mechanism, and a capability to clear specified virtual pages. .PP .IR vminit\ - This routine initializes the virtual memory system by setting up the pool of in-memory segment buffers. The argument to this function is the number of memory segments to allocate (typically 4 to 8 but can be higher as long as memory can be malloc'd). It must be called before any other "libvmf" routine is called. .PP .IR vmopen\ - For each virtual space that a program uses, the program must allocate an instance of the space structure ('struct vspace'). This routine is used to initialize a virtual space structure using the specified address of a space structure and the name of the file that will serve as swap file for the space. If the second argument is \fBNULL\fP an invisible temporary file is used rather than a named (permanent) file. .PP .IR vmclose\ - This routine is used to close the UNIX file descriptor associated with the swap file for a virtual space. Any modified in-memory segments belonging to the specified address space are flushed to the paging file. .PP .IR vmmapseg\ - This routine is the primary interface to the virtual memory mechanism. It is executed with a specified virtual space address and a segment number (between 0 and 511), and returns a pointer to an in-memory page containing the specified segment. .PP .IR vmmodify\ - Whenever a program modifies the data of a segment, it is the program's responsibility to inform the virtual memory system of the modification. This function is also available as a macro (\fBVMMODIFY\fP) for use in-line. .PP .IR vmlock\ - This routine increments the lock count of the specified segment buffer. A buffer with a nonzero lock count is .I locked and cannot be swapped out. .PP .IR vmunlock\ - This routine decrements the lock count of the specified buffer. It is a serious error to decrement the count below zero (lock underflow). .PP .IR vmclrseg\ - This routine clears the user data area (page) of the specified segment buffer. .IR vmflush\ - This routine simply swaps out all segments that are marked as modified. .SH BUGS Not as transparent (or as fast) as a larger hardware address space. .PP There is no automatic segment crossing capability, the application must check if a .I virtual address crosses page/segment boundaries and perform a .I vmmapseg call. .SH SEE ALSO There is a nroff document (using the \-ms macros) in the \fIlibvmf\fP source directory which goes into more details about the \fBvm\fP functions. ================================================ FILE: lib/libvmf/vmf.c ================================================ /* Program Name: vmf.c * Author: S.M. Schultz * * ----------- Modification History ------------ * Version Date Reason For Modification * 1.0 1JAN80 1. Initial release. * 2.0 31Mar83 2. Cleanup. * 2.1 19Oct87 3. Experiment increasing number of segments. * 2.2 03Dec90 4. Merged error.c into this because it had * been reduced to two write() statements. * 3.0 08Sep93 5. Polish it up for use in 'ld.c' (2.11BSD). * Release into the Public Domain. * -------------------------------------------------- */ #include #include #include #include #include #include #include #include #include /* * Choose ONE and only one of the following swap policies */ /* #define LRU /* Least Recently Used */ /* #define PERC 3 /* Percolation */ #define LRS /* Least Recently Swapped */ #ifndef DEBUG #define debugseg(s,m) /* do nothing */ #else static void debugseg(); #endif /* * This is vfm.c, the file of virtual memory management primitives. * Call vminit first to get the in memory segments set up. * Then call vmopen for each virtual space to be used. * Normal transactions against segments are handled via vmmapseg. * At wrapup time, call vmflush if any modified segments are * assigned to permanent files. */ #define NOSEGNO (-1) /* can never match a segment number */ static struct dlink seghead[1]; long nswaps, nmapsegs; /* statistics */ extern int read(), write(), errno; static int swap(); static void promote(), vmerror(); /* * vminit --- initialize virtual memory system with 'n' in-memory segments */ int vminit(n) int n; { register struct vseg *s; static struct vseg *segs; segs = (struct vseg *)calloc(n, sizeof (struct vseg)); if (!segs) { errno = ENOMEM; return(-1); } seghead[0].fwd = seghead[0].back = seghead; /* selfpoint */ for (s = segs; s < &segs[n] ; s++) { s->s_link.fwd = seghead; s->s_link.back = seghead[0].back; s->s_link.back->fwd = s->s_link.fwd->back = (struct dlink *)s; s->s_segno = NOSEGNO; s->s_vspace = NULL; s->s_lock_count = 0; /* vmunlocked */ s->s_flags = 0; /* not DIRTY */ } return(0); } /* * vmmapseg --- convert segment number to real memory address */ struct vseg * vmmapseg(vspace, segno) struct vspace *vspace; u_short segno; { register struct vseg *s; nmapsegs++; if (segno >= vspace->v_maxsegno || segno < 0) { #ifdef DEBUG fprintf(stderr,"vmmapseg vspace0%o segno%d\n", vspace, segno); #endif vmerror("vmmapseg: bad segno"); } /* look for segment in memory */ for (s = (struct vseg *)seghead[0].fwd; s->s_segno != segno || s->s_vspace != vspace; s = (struct vseg *)s->s_link.fwd) { if (s == (struct vseg *)seghead) { /* not in memory */ int status; for (s = (struct vseg *)s->s_link.back; s->s_lock_count != 0; s = (struct vseg *)s->s_link.back) { if (s == (struct vseg *)seghead) vmerror("Too many locked segs!"); debugseg(s, "back skip"); } debugseg(s, "dump on"); if (s->s_flags & S_DIRTY) if (swap(s, write) != 0) { fprintf(stderr, "write swap, v=%d fd=%d\n", s->s_vspace,s->s_vspace->v_fd); exit(-2); } s->s_vspace = vspace; s->s_segno = segno; s->s_flags &= ~S_DIRTY; status = swap(s, read); if (status == -2) { fprintf(stderr, "can't read swap file"); exit(-2); } else if (status == -1) (void)vmclrseg(s); #ifdef LRS /* Least Recently Swapped */ promote(s); #endif break; } debugseg(s, "forward skip"); } #ifdef PERC { /* percolate just-referenced segment up list */ register struct dlink *neighbor, *target; int count; s->fwd->back = s->back; /* delete */ s->back->fwd = s->fwd; count = PERC; /* upward mobility */ for (target = s; target != seghead && count-- > 0; ) target = target->back; neighbor = target->fwd; s->back = target; /* reinsert */ s->fwd = neighbor; target->fwd = neighbor->back = s; } #endif #ifdef LRU /* Least Recently Used */ promote(s); #endif debugseg(s, "vmmapseg returns"); return(s); } /* * swap --- swap a segment in or out * (called only from this file) */ static int swap(seg, iofunc) /* used only from this file */ register struct vseg *seg; int (*iofunc)(); { off_t file_address; register struct vspace *v; v = seg->s_vspace; nswaps++; file_address = seg->s_segno; file_address *= (BYTESPERSEG); file_address += v->v_foffset; #ifdef SWAPTRACE printf("fd%d blk%d\tswap %s\n", v->v_fd, file_address, iofunc == read ? "in" : "out"); #endif if (lseek(v->v_fd, file_address, L_SET) == -1L) return(-2); switch ((*iofunc)(v->v_fd, seg->s_cinfo, BYTESPERSEG)) { case BYTESPERSEG: return(0); case 0: return(-1); default: return(-2); } } void vmclrseg(seg) register struct vseg *seg; { (void)bzero(seg->s_cinfo, BYTESPERSEG); vmmodify(seg); } /* * vmlock --- vmlock a segment into real memory */ void vmlock(seg) register struct vseg *seg; { seg->s_lock_count++; if (seg->s_lock_count < 0) vmerror("vmlock: overflow"); } /* * vmunlock --- unlock a segment */ void vmunlock(seg) register struct vseg *seg; { --seg->s_lock_count; if (seg->s_lock_count < 0) vmerror("vmlock: underflow"); } /* * vmmodify --- declare a segment to have been modified */ void vmmodify(seg) register struct vseg *seg; { VMMODIFY(seg); debugseg(seg, "vmmodify"); } /* * vmflush --- flush out virtual space buffers */ void vmflush() { register struct vseg *s; for (s = (struct vseg *)seghead[0].fwd; s != (struct vseg *)seghead; s = (struct vseg *)s->s_link.fwd) if (s->s_flags & S_DIRTY) swap(s, write); } /* * debugseg --- output debugging information about a seg in mem */ #ifdef DEBUG static void debugseg(s, msg) char *msg; register struct vseg *s; { fprintf(stderr, "seg%o vspace%o segno%d flags%o vmlock%d %s\r\n", s, s->s_vspace, s->s_segno, s->s_flags, s->s_lock_count, msg); } #endif /* * vmopen --- open a virtual space associated with a file */ int vmopen(vs, filename) register struct vspace *vs; char *filename; { register int fd; char junk[32]; if (!filename) { strcpy(junk, "/tmp/vmXXXXXX"); fd = mkstemp(junk); unlink(junk); } else fd = open(filename, O_RDWR|O_CREAT, 0664); if (fd != -1) { vs->v_fd = fd; vs->v_foffset = 0; vs->v_maxsegno = MAXSEGNO; } return(fd); } /* * vmclose --- closes a virtual space associated with a file * invalidates all segments associated with that file */ void vmclose(vs) register struct vspace *vs; { register struct vseg *s; vmflush(); /* invalidate all segments associated with that file */ for (s = (struct vseg *)seghead[0].fwd; s != (struct vseg *)seghead; s = (struct vseg *)s->s_link.fwd) { if (s->s_vspace == vs) { s->s_segno = NOSEGNO; s->s_vspace = NULL; s->s_lock_count = 0; /* vmunlocked */ s->s_flags &= ~S_DIRTY; } } close(vs->v_fd); } /* * promote --- put a segment at the top of the list */ static void promote(s) register struct vseg *s; { s->s_link.fwd->back = s->s_link.back; /* delete */ s->s_link.back->fwd = s->s_link.fwd; s->s_link.fwd = seghead[0].fwd; /* insert at top of totem pole */ s->s_link.back = seghead; seghead[0].fwd = s->s_link.fwd->back = (struct dlink *)s; } /* * vmerror --- print error message and commit suicide * Message should always make clear where called from. * Example: vmerror("In floogle: can't happen!"); */ static void vmerror(msg) char *msg; { fprintf(stderr, "%s\n", msg); abort(); /* terminate process with core dump */ } ================================================ FILE: lib/libvmf/vmlib.ms ================================================ .NH 1 VMF -- Virtual Memory Facility .NH 2 Introduction .PP Since 2.11BSD is not a virtual memory operating system, a user level "virtual memory" system can be of great utility to programs with large address space requirements. This library provides a standard set of routines for managing large virtual memory spaces. It supports creation of multiple concurrent virtual spaces, mapping of virtual pages into real memory, a lock/unlock mechanism, and a capability to clear specified virtual pages. .NH 3 Concepts .PP The virtual memory scheme supports any number (subject to open file limitations) of virtual .I spaces, each of which is made up of up to 512 .I segments (pages), each of which is 512 words (16 bit shorts) long. The 512 ints (1024 chars) of a segment can be used for any purpose. .PP Each space may be temporary or permanent, in the sense that it is or is not forgotten when the program ends. Between program invocations, each permanent space resides in a named file. The most common (by far) type is temporary using a file which is unlinked immediately after opening the virtual address space. .PP At any time during the lifetime of a process that uses the virtual memory facility, some number of segments will be in real memory, but typically most will be "swapped out" to a file. When the calling program knows the real memory address of a segment, the segment may be viewed and accessed as an array of 512 integers or as an array of 1024 characters. .NH 3 Data Structures .PP Two structures are associated with the virtual memory scheme: the space structure and the segment buffer structure. .IP Space\ Structure 4 .sp One instance of the space structure must be allocated by the user for each space to be used. Spaces are identified by the address of their space structures. Included in the structure is the UNIX file descriptor of the "swap" file to be used for the space, the offset (in bytes) into the file at which the room allocated for the virtual space begins (currently this is always zero and is reserved for future use), and the number of segments in the space (currently always 512). The user must never be concerned with any element of the space structure. .IP Segment\ Buffer\ Structure 4 .sp The virtual memory system includes a pool of buffers for holding segments while they reside in real memory. .sp The segment buffer structure (see 'struct seg' definition below) includes: a double link, the segment number (in range [0, 511]), the address of the virtual space structure instance for the virtual space of which the segment is a member, a lock count, a "modified" flag, and an array of 512 shorts (1024 bytes) for the segment itself. This array represents the virtual page which is accessed directly by the user. .NH 2 Defined Constants and Global Variables .PP The following defined symbolic constants are specified as either calling parameters or returned values of the routines in the "dtlib" facility. .IP MAXSEGNO 18 Specifies the maximum number of segments (pages) in a virtual space. .IP WORDSPERSEG 18 Specifies the number of words in a segment. .IP BYTESPERSEG 18 Specifies the number of bytes in a segment. This is always a power of 2. .IP LOG2BPS 18 The base 2 logarithm of BYTESPERSEG. .PP There are several global variables defined by the "vmlib" facility that an applications programmer may examine. .IP nswaps 18 This is a 32 bit value which gives the number of pages swapped to or from the paging file. .IP nmapsegs 18 This 32 bit value holds the number of calls made to map a segment into memory via \fIvmmapseg\fP. .PP The following defined "C" Language structures are specified as calling parameters and/or returned values of the routines in the "vmlib" facility. .PP .nf struct vspace { int v_fd; /* file for swapping */ off_t v_foffset; /* offset for computing file addresses */ int v_maxsegno; /* number of segments in this space */ }; struct dlink { /* general double link structure */ struct dlink *fwd; /* forward link */ struct dlink *back; /* back link */ }; struct vseg { /* structure of a segment in memory */ struct dlink s_link; /* for linking into lru list */ int s_segno; /* segment number */ struct vspace *s_vspace; /* which virtual space */ int s_lock_count; int s_flags; union { int _winfo[WORDSPERSEG]; /* the actual segment */ char _cinfo[BYTESPERSEG]; } v_un; }; #define s_winfo v_un._winfo #define s_cinfo v_un._cinfo .fi .NH 2 Routine Synopsis .PP Below are listed the names of each function in the "vmlib" facility along with a brief synopsis of what each routine does. .IP vminit 14 This routine initializes the virtual memory system by setting up the pool of in-memory segment buffers. The argument to this function is the number (typically 4 to 8 but can be higher as long as memory can be malloc'd). It must be called before any other "vmlib" facility routine is called. .IP vmopen 14 For each virtual space that a program uses, the program must allocate an instance of the space structure (see definition of 'struct vspace' above). This routine is used to initialize a virtual space structure using the specified address of a space structure and the name of the file that will serve as swap file for the space. If the second argument is \fBNULL\fP an invisible temporary file is used rather than a named (permanent) file. .IP vmclose 14 This routine is used to close the UNIX file descriptor associated with the swap file for a virtual space. Any modified in-memory segments belonging to the specified address space are flushed to the paging file. .IP vmmapseg 14 This routine is the primary interface to the virtual memory mechanism. It is executed with a specified virtual space address and a segment number ( in range [0, 511]), and returns a pointer to an in-memory page containing the specified segment. .IP vmmodify 14 Whenever a program modifies the data of a segment, it is the program's responsibility to inform the virtual memory system of the modification. This routine flags the specified segment as modified and should be executed before any future execution of 'vmmapseg' that could overlay the modified buffer. This function is also available as a macro (\fBVMMODIFY\fP) for use in-line. The macro form is actually preferred since only a single bit is being set in a word. .IP vmlock 14 This routine increments the lock count of the specified segment buffer. A buffer with a nonzero lock count is .I locked and cannot be overlayed. The utility of this feature to the user is that a locked segment buffer will stay at the same real memory address until unlocked, hence real memory pointers into or to it can remain valid. Overuse of this feature will result in not being able to page any new segments into memory from the paging file. .IP vmunlock 14 This routine decrements the lock count of the specified buffer. It is a serious error to decrement the count below zero (lock underflow). .IP vmclrseg 14 This routine clears the user data area (page) of the specified segment buffer. .IP vmflush 14 This routine simply swaps out all segments that are marked as "modified". It may be called at any time and is always called when \fIvmclose\fP is called. .bp .NH 2 Detailed Description of Virtual Memory Functions .NH 3 vminit -- Initialize Virtual Memory Interface .NH 4 .PP The "vminit" routine initializes the virtual memory system by setting up the pool of in-memory segment buffers. It must be called before any other "vmlib" facility routine is called. .NH 4 CALLING SEQUENCE .PP .in +8 .nf status = vminit(nseg) int nseg; int status; .fi .in -8 .IP status The return value will be \-1 and \fIerrno\fP will be set to ENOMEM if memory for the specified number of segments can not be allocated. .IP nseg This is the number of in-memory segments to allocate. These are shared between all virtual spaces opened. Each segment is 1kb plus overhead, so the number of segments should be chosen with care (if all data could be held in memory we wouldn't need a virtual memory system after all). Typical number of segments is between 4 and 8 although some applications such as \fBld\fP(1) use 12 or more. .NH 3 vmopen -- Open a Virtual Space .NH 4 .PP For each virtual space that a program uses, the program must allocate an instance of the space structure (see definition of 'struct vspace' above). The "vmopen" routine is used to initialize a virtual space structure using the specified address of a space structure and the name of the file that will serve as swap file for the space. If the filename is NULL then an invisible temporary file created in /tmp will be used and the address space will be vanish when the program exits or calls \fIvmclose\fP. .NH 4 CALLING SEQUENCE .PP .in +8 .nf status = vmopen(vsptr,filename) struct vspace *vsptr; char *filename; int status; .fi .in -8 .IP status Indicates success if 0, an error if \-1. An error is caused by failure to create (or open for update) the specified file. The global \fBerrno\fP will be set if \-1 is returned by \fIvmopen\fP. .NH 3 vmclose -- Close a Virtual Space .NH 4 .PP Close the UNIX file descriptor associated with the swap file for a virtual space. Modified segments belonging to the specified virtual space are flushed. .NH 4 CALLING SEQUENCE .PP .in +8 .nf void vmclose(vsptr) struct vspace *vsptr; .fi .in -8 .IP vsptr The address of the virtual space structure to be closed. No status is returned. .NH 3 vmmapseg -- Map a Virtual Segment into Real Memory .NH 4 .PP The "vmmapseg" routine is the primary interface to the virtual memory mechanism. It is executed with a specified virtual space address and a segment number ( in range [0, 511]), and returns the real memory address of a buffer guaranteed to contain the segment requested. The address returned is that of the 'struct vseg' not that of the data portion. It is up to the program to refer to the 's_cinfo' or 's_winfo' member to refer to the byte or word oriented data respectively. .NH 4 CALLING SEQUENCE .PP .in +8 .nf segptr = vmmapseg(vsptr,segno) struct vspace *vsptr; int segno; struct vseg *segptr; .fi .in -8 .NH 4 .IP vsptr Specifies the address of a virtual space structure allocated by the calling program. A previous vmopen call using this structure must have been performed before calling \fIvmmapseg\fP. .IP segno Specifies the segment i.e., virtual page, number to be mapped into real physical memory. The value must be in the range [0 to MAXSEGNO-1]. There are two macros (defined in \fIvmf.h\fP) which are useful in calculating segment numbers: \fBVSEG\fP and \fBVOFF\fP. .IP segptr The address of a virtual seg structure which contains the virtual space segment associated with segno. The data is referred to with the 's_cinfo' or 's_winfo' structure members: segptr->s_cinfo or segptr->s_winfo respectively. .PP Currently this routine aborts the program on an error condition. .NH 3 vmmodify -- Mark a Segment as Modified .NH 4 .PP Whenever the user program modifies any segment, it is the program's responsibility to inform the virtual memory system of the modification. The "vmmodify" routine flags the specified segment as modified and should be executed before any future execution of 'vmmapseg' that could reuse the modified buffer. Note that a locked segment buffer cannot be reused, until it is unlocked. A macro form of this routine exists, \fBVMMODIFY\fP may be used to mark a segment as modified. .NH 4 CALLING SEQUENCE .PP .in +8 .nf void vmmodify(segptr) struct vseg *segptr; .fi .in -8 .IP segptr Specifies the address of a seg structure associated with a current incore virtual memory segment which has been modified. .NH 3 vmlock -- Lock a Virtual Segment into Real Memory .NH 4 .PP Increment the lock count of the specified segment buffer. A buffer with a nonzero lock count is .I locked and cannot be reused/swapped-out. The utility of this feature to the user is that a locked segment buffer will stay at the same real memory address until unlocked, hence real memory pointers into or to it can remain valid. Overuse of \fIvmlock\fP will cause errors in \fIvmmapseg\fP when no segments are available to satisfy swap in/out requests. .NH 4 CALLING SEQUENCE .PP .in +8 .nf void vmlock(segptr1) struct vseg *segptr; .fi .in -8 .NH 4 .IP segptr Specifies the address of a seg structure associated with a current incore virtual memory segment. No information is returned. .NH 3 vmunlock -- Unlock a Previously Locked Virtual Memory Segment .NH 4 .PP Decrement the lock count of the specified buffer. It is a serious error to decrement the count below zero, this typically means that the segment was never locked in the first place. .NH 4 CALLING SEQUENCE .PP .in +8 .nf void vmunlock(segptr) struct vseg *segptr; .fi .in -8 .NH 4 .IP segptr1 Specifies the address of a seg structure associated with a current incore virtual memory segment. No information is returned from this routine. .NH 3 vmclrseg -- Clear a Virtual Memory Segment to Zeros .NH 4 .PP Clear the data area of the specified segement buffer. No information is returned by this function. .NH 4 CALLING SEQUENCE .PP .in +8 .nf void vmclrseg(segptr) struct vseg *segptr .fi .in -8 .NH 4 .IP segptr Specifies the address of a seg structure associated with a current incore virtual memory segment. The data portion (segptr->s_cinfo) is cleared by a call to \fIbzero\fP(3). .NH 3 vmflush -- Flush Virtual Memory Cache to Swap File .NH 4 .PP Swap out all segments that are marked as "modified". It may be called just prior to program termination if there are any permanent spaces that have been modified but normally a program will simply call \fIvmclose\fP which takes care of flushing modified pages as part of its normal duties. .NH 4 CALLING SEQUENCE .PP .in +8 .nf void vmflush() .fi .in -8 ================================================ FILE: lib/libwiznet/Makefile ================================================ TOPSRC!=cd ../..; pwd include ${TOPSRC}/share/mk/sys.mk CFLAGS += -O -Wall OBJS = w5100.o socket.o ethernet.o client.o server.o udp.o all: ../libwiznet.a ../libwiznet.a: ${OBJS} @${AR} cr $@ ${OBJS} $(RANLIB) $@ install: all clean: rm -f *.o a.out core test errs ../libwiznet*.a ================================================ FILE: lib/libwiznet/client.c ================================================ #include #include #include #include unsigned _client_srcport = 1024; void client_init (client_t *c, uint8_t *ip, unsigned port) { c->ip = ip; c->port = port; c->sock = MAX_SOCK_NUM; } void client_init_sock (client_t *c, unsigned sock) { c->sock = sock; } int client_connect (client_t *c) { int i; if (c->sock != MAX_SOCK_NUM) return 0; for (i = 0; i < MAX_SOCK_NUM; i++) { unsigned s = w5100_readSnSR (i); if (s == SnSR_CLOSED || s == SnSR_FIN_WAIT) { c->sock = i; break; } } if (c->sock == MAX_SOCK_NUM) return 0; _client_srcport++; if (_client_srcport == 0) _client_srcport = 1024; socket_init (c->sock, SnMR_TCP, _client_srcport, 0); if (! socket_connect (c->sock, c->ip, c->port)) { c->sock = MAX_SOCK_NUM; return 0; } while (client_status(c) != SnSR_ESTABLISHED) { usleep (10000); if (client_status(c) == SnSR_CLOSED) { c->sock = MAX_SOCK_NUM; return 0; } } return 1; } void client_putc (client_t *c, uint8_t b) { if (c->sock != MAX_SOCK_NUM) socket_send (c->sock, &b, 1); } void client_puts (client_t *c, const char *str) { if (c->sock != MAX_SOCK_NUM) socket_send (c->sock, (const uint8_t *)str, strlen(str)); } void client_write (client_t *c, const uint8_t *buf, size_t size) { if (c->sock != MAX_SOCK_NUM) socket_send (c->sock, buf, size); } int client_available (client_t *c) { if (c->sock != MAX_SOCK_NUM) return w5100_getRXReceivedSize (c->sock); return 0; } int client_getc (client_t *c) { uint8_t b; if (socket_recv (c->sock, &b, 1) <= 0) { // No data available return -1; } return b; } int client_read (client_t *c, uint8_t *buf, size_t size) { return socket_recv (c->sock, buf, size); } int client_peek (client_t *c) { uint8_t b; // Unlike recv, peek doesn't check to see if there's any data available, so we must if (! client_available (c)) return -1; b = socket_peek (c->sock); return b; } void client_flush (client_t *c) { while (client_available (c)) client_getc (c); } void client_stop (client_t *c) { int i; if (c->sock == MAX_SOCK_NUM) return; // attempt to close the connection gracefully (send a FIN to other side) socket_disconnect (c->sock); // wait a second for the connection to close for (i=0; i<100; i++) { if (client_status (c) == SnSR_CLOSED) break; usleep (10000); } // if it hasn't closed, close it forcefully if (client_status(c) != SnSR_CLOSED) socket_close (c->sock); _socket_port[c->sock] = 0; c->sock = MAX_SOCK_NUM; } int client_connected (client_t *c) { if (c->sock == MAX_SOCK_NUM) return 0; unsigned s = client_status (c); return ! (s == SnSR_LISTEN || s == SnSR_CLOSED || s == SnSR_FIN_WAIT || (s == SnSR_CLOSE_WAIT && ! client_available (c))); } unsigned client_status (client_t *c) { if (c->sock == MAX_SOCK_NUM) return SnSR_CLOSED; return w5100_readSnSR (c->sock); } ================================================ FILE: lib/libwiznet/ethernet.c ================================================ #include #include #include #include #include unsigned char ethernet_mac [6]; unsigned char ethernet_ip [4]; unsigned char ethernet_gateway [4]; unsigned char ethernet_netmask [4]; /* * Get MAC address from string to byte array. */ static void parse_mac (unsigned char *macp, char *str) { unsigned char *limit = macp + 6; register unsigned c, val; do { /* Collect number up to ":". */ val = 0; while ((c = (unsigned char) *str)) { if (c >= '0' && c <= '9') val = (val << 4) + (c - '0'); else if (c >= 'a' && c <= 'f') val = (val << 4) + (c - 'a' + 10); else if (c >= 'A' && c <= 'F') val = (val << 4) + (c - 'A' + 10); else break; str++; } *macp++ = val; } while (*str++ == ':' && macp < limit); } /* * Get IP address from string to byte array. */ static void parse_ip (unsigned char *val, char *str) { unsigned long addr; if (! str) return; addr = inet_addr (str); val[0] = addr >> 0; val[1] = addr >> 8; val[2] = addr >> 16; val[3] = addr >> 24; } /* * Initialize Ethernet controller. * Get parameters from environment: * MAC=aa:bb:cc:dd:ee:ff - unique MAC address * IP=12.34.56.78 - IP address * GATEWAY=12.34.56.1 - gateway to Internet (optional) * NETMASK=255.255.255.0 - netmask of local Ethernet network (optional) */ void ethernet_init () { char *mac, *ip, *gateway, *netmask; mac = getenv("MAC"); if (! mac) { fprintf (stderr, "Please set MAC environment variable\n"); exit (-1); } parse_mac (ethernet_mac, mac); ip = getenv("IP"); if (! ip) { fprintf (stderr, "Please set IP environment variable\n"); exit (-1); } parse_ip (ethernet_ip, ip); gateway = getenv("GATEWAY"); if (gateway != 0) { parse_ip (ethernet_gateway, gateway); } else { ethernet_gateway[0] = ethernet_ip[0]; ethernet_gateway[1] = ethernet_ip[1]; ethernet_gateway[2] = ethernet_ip[2]; ethernet_gateway[3] = 1; } netmask = getenv("NETMASK"); if (netmask != 0) { parse_ip (ethernet_netmask, netmask); } else { ethernet_netmask[0] = 255; ethernet_netmask[1] = 255; ethernet_netmask[2] = 255; ethernet_netmask[3] = 0; } printf("local MAC address %02x:%02x:%02x:%02x:%02x:%02x\n", ethernet_mac[0], ethernet_mac[1], ethernet_mac[2], ethernet_mac[3], ethernet_mac[4], ethernet_mac[5]); printf("local IP address %u.%u.%u.%u\n", ethernet_ip[0], ethernet_ip[1], ethernet_ip[2], ethernet_ip[3]); printf("gateway %u.%u.%u.%u\n", ethernet_gateway[0], ethernet_gateway[1], ethernet_gateway[2], ethernet_gateway[3]); printf("netmask %u.%u.%u.%u\n", ethernet_netmask[0], ethernet_netmask[1], ethernet_netmask[2], ethernet_netmask[3]); w5100_init(); /* Set Ethernet MAC address. */ w5100_writeSHAR (ethernet_mac); /* Set local IP address. */ w5100_writeSIPR (ethernet_ip); /* Set gateway IP address. */ w5100_writeGAR (ethernet_gateway); /* Set subnet mask. */ w5100_writeSUBR (ethernet_netmask); /* Set retransmission timeout to 200 msec. */ w5100_writeRTR (200*10); /* Set retransmission count. */ //w5100_writeRCR (3); } ================================================ FILE: lib/libwiznet/server.c ================================================ #include #include #include unsigned _server_port; void server_init (unsigned port) { unsigned sock; client_t client; _server_port = port; for (sock = 0; sock < MAX_SOCK_NUM; sock++) { client_init_sock (&client, sock); if (client_status (&client) == SnSR_CLOSED) { socket_init (sock, SnMR_TCP, port, 0); socket_listen (sock); _socket_port[sock] = port; break; } } } void server_accept() { unsigned sock; client_t client; int listening = 0; for (sock = 0; sock < MAX_SOCK_NUM; sock++) { client_init_sock (&client, sock); if (_socket_port[sock] == _server_port) { if (client_status (&client) == SnSR_LISTEN) { listening = 1; } else if (client_status (&client) == SnSR_CLOSE_WAIT && ! client_available (&client)) { client_stop (&client); } } } if (! listening) { server_init (_server_port); } } int server_available (client_t *client) { unsigned sock; server_accept(); for (sock = 0; sock < MAX_SOCK_NUM; sock++) { client_init_sock (client, sock); if (_socket_port[sock] == _server_port && (client_status (client) == SnSR_ESTABLISHED || client_status (client) == SnSR_CLOSE_WAIT)) { if (client_available (client)) { // XXX: don't always pick the lowest numbered socket. return 1; } } } return 0; } void server_putc (uint8_t b) { server_write (&b, 1); } void server_puts (const char *str) { server_write ((const uint8_t *)str, strlen(str)); } void server_write (const uint8_t *buffer, size_t size) { unsigned sock; client_t client; server_accept(); for (sock = 0; sock < MAX_SOCK_NUM; sock++) { client_init_sock (&client, sock); if (_socket_port[sock] == _server_port && client_status (&client) == SnSR_ESTABLISHED) { client_write (&client, buffer, size); } } } ================================================ FILE: lib/libwiznet/socket.c ================================================ #include #include #include unsigned _socket_port [MAX_SOCK_NUM] = { 0 }; static unsigned local_port; /* * This Socket function initialize the channel in perticular mode, * and set the port and wait for W5100 done it. * Return 1 for success else 0. */ unsigned socket_init (unsigned sock, unsigned protocol, unsigned port, unsigned flag) { if ((protocol == SnMR_TCP) || (protocol == SnMR_UDP) || (protocol == SnMR_IPRAW) || (protocol == SnMR_MACRAW) || (protocol == SnMR_PPPOE)) { socket_close (sock); w5100_writeSnMR (sock, protocol | flag); if (port != 0) { w5100_writeSnPORT (sock, port); } else { /* if don't set the source port, set local_port number. */ local_port++; w5100_writeSnPORT (sock, local_port); } w5100_socket_cmd (sock, Sock_OPEN); return 1; } return 0; } /* * This function close the socket and parameter is "sock" which represent * the socket number. */ void socket_close (unsigned sock) { w5100_socket_cmd (sock, Sock_CLOSE); w5100_writeSnIR (sock, 0xFF); } /* * This function established the connection for the channel in passive * (server) mode. This function waits for the request from the peer. * Return 1 for success else 0. */ unsigned socket_listen (unsigned sock) { if (w5100_readSnSR (sock) != SnSR_INIT) return 0; w5100_socket_cmd (sock, Sock_LISTEN); return 1; } /* * This function established the connection for the channel in Active * (client) mode. This function waits for the untill the connection * is established. * Return 1 for success else 0. */ unsigned socket_connect (unsigned sock, uint8_t * addr, unsigned port) { if (((addr[0] == 0xFF) && (addr[1] == 0xFF) && (addr[2] == 0xFF) && (addr[3] == 0xFF)) || ((addr[0] == 0x00) && (addr[1] == 0x00) && (addr[2] == 0x00) && (addr[3] == 0x00)) || (port == 0)) return 0; /* set destination IP */ w5100_writeSnDIPR (sock, addr); w5100_writeSnDPORT (sock, port); w5100_socket_cmd (sock, Sock_CONNECT); return 1; } /* * This function used for disconnect the socket and parameter is "sock" * which represent the socket number * Return 1 for success else 0. */ void socket_disconnect (unsigned sock) { w5100_socket_cmd (sock, Sock_DISCON); } /* * This function used to send the data in TCP mode * Return 1 for success else 0. */ unsigned socket_send (unsigned sock, const uint8_t * buf, unsigned nbytes) { unsigned status = 0; unsigned freesize = 0; /* check size not to exceed MAX size. */ if (nbytes > TXBUF_SIZE) nbytes = TXBUF_SIZE; /* if freebuf is available, start. */ do { freesize = w5100_getTXFreeSize (sock); status = w5100_readSnSR (sock); if ((status != SnSR_ESTABLISHED) && (status != SnSR_CLOSE_WAIT)) { return 0; } } while (freesize < nbytes); /* copy data */ w5100_send_chunk (sock, buf, nbytes); w5100_socket_cmd (sock, Sock_SEND); /* +2008.01 bj */ while ((w5100_readSnIR (sock) & SnIR_SEND_OK) != SnIR_SEND_OK) { /* m2008.01 [bj] : reduce code */ if (w5100_readSnSR (sock) == SnSR_CLOSED) { socket_close (sock); return 0; } } /* +2008.01 bj */ w5100_writeSnIR (sock, SnIR_SEND_OK); return nbytes; } /* * This function is an application I/F function which is used to receive * the data in TCP mode. It continues to wait for data as much as * the application wants to receive. * Return received data size for success else -1. */ unsigned socket_recv (unsigned sock, uint8_t *buf, unsigned len) { /* Check how much data is available */ unsigned navail = w5100_getRXReceivedSize (sock); if (navail == 0) { /* No data available. */ w5100_readSnSR (sock); if (sock == SnSR_LISTEN || sock == SnSR_CLOSED || sock == SnSR_CLOSE_WAIT) { /* The remote end has closed its side of the connection, * so this is the eof state */ return 0; } /* The connection is still up, but there's no data waiting * to be read */ return -1; } if (navail > len) { navail = len; } w5100_recv_chunk (sock, buf, navail); w5100_socket_cmd (sock, Sock_RECV); return navail; } /* * Returns the first byte in the receive queue (no checking) */ unsigned socket_peek (unsigned sock) { return w5100_recv_peek (sock); } /* * This function is an application I/F function which is used to send * the data for other then TCP mode. Unlike TCP transmission, the peer's * destination address and the port is needed. * * This function return send data size for success else -1. */ unsigned socket_sendto (unsigned sock, const uint8_t *buf, unsigned len, uint8_t *addr, unsigned port) { unsigned ret = 0; /* check size not to exceed MAX size. */ if (len > TXBUF_SIZE) ret = TXBUF_SIZE; else ret = len; if (((addr[0] == 0x00) && (addr[1] == 0x00) && (addr[2] == 0x00) && (addr[3] == 0x00)) || (port == 0) || (ret == 0)) { /* +2008.01 [bj] : added return value */ ret = 0; } else { w5100_writeSnDIPR (sock, addr); w5100_writeSnDPORT (sock, port); /* copy data */ w5100_send_chunk (sock, buf, ret); w5100_socket_cmd (sock, Sock_SEND); /* +2008.01 bj */ while ((w5100_readSnIR (sock) & SnIR_SEND_OK) != SnIR_SEND_OK) { if (w5100_readSnIR (sock) & SnIR_TIMEOUT) { /* +2008.01 [bj]: clear interrupt */ /* clear SEND_OK & TIMEOUT */ w5100_writeSnIR (sock, SnIR_SEND_OK | SnIR_TIMEOUT); return 0; } } /* +2008.01 bj */ w5100_writeSnIR (sock, SnIR_SEND_OK); } return ret; } /* * This function is an application I/F function which is used to receive * the data in other then TCP mode. This function is used to receive UDP, * IP_RAW and MAC_RAW mode, and handle the header as well. * * This function return received data size for success else -1. */ unsigned socket_recvfrom (unsigned sock, uint8_t *buf, unsigned len, uint8_t *addr, unsigned *port) { uint8_t head[8]; unsigned nreceived = 0; unsigned ptr, mode; if (len <= 0) return 0; ptr = w5100_readSnRX_RD (sock); mode = w5100_readSnMR (sock); W5100_DEBUG ("socket_recvfrom: mode %02x, RX pointer = %04x\n", mode, ptr); switch (mode & 0x07) { case SnMR_UDP: w5100_read_data (sock, ptr, head, 8); ptr += 8; /* read peer's IP address, port number. */ W5100_DEBUG ("UDP peer %u.%u.%u.%u, port %u\n", head[0], head[1], head[2], head[3], (head[4] << 8) | head[5]); if (addr) { addr[0] = head[0]; addr[1] = head[1]; addr[2] = head[2]; addr[3] = head[3]; } if (port) *port = (head[4] << 8) | head[5]; nreceived = (head[6] << 8) + head[7]; break; case SnMR_IPRAW: w5100_read_data (sock, ptr, head, 6); ptr += 6; /* read peer's IP address. */ W5100_DEBUG ("IPRAW peer %u.%u.%u.%u\n", head[0], head[1], head[2], head[3]); if (addr) { addr[0] = head[0]; addr[1] = head[1]; addr[2] = head[2]; addr[3] = head[3]; } nreceived = (head[4] << 8) + head[5]; break; case SnMR_MACRAW: w5100_read_data (sock, ptr, head, 2); ptr += 2; nreceived = (head[0] << 8) + head[1] - 2; break; default: W5100_DEBUG ("unknown mode %02x\n", mode); return 0; } W5100_DEBUG ("received %u bytes\n", nreceived); /* data copy. */ w5100_read_data (sock, ptr, buf, nreceived); ptr += nreceived; w5100_writeSnRX_RD (sock, ptr); W5100_DEBUG ("set RX pointer = %04x\n", ptr); w5100_socket_cmd (sock, Sock_RECV); return nreceived; } unsigned socket_igmpsend (unsigned sock, const uint8_t * buf, unsigned len) { unsigned ret = 0; if (len > TXBUF_SIZE) ret = TXBUF_SIZE; /* check size not to exceed MAX size. */ else ret = len; if (ret == 0) return 0; w5100_send_chunk (sock, buf, ret); w5100_socket_cmd (sock, Sock_SEND); while ((w5100_readSnIR (sock) & SnIR_SEND_OK) != SnIR_SEND_OK) { w5100_readSnSR (sock); if (w5100_readSnIR (sock) & SnIR_TIMEOUT) { /* in case of igmp, if send fails, then socket closed */ /* if you want change, remove this code. */ socket_close (sock); return 0; } } w5100_writeSnIR (sock, SnIR_SEND_OK); return ret; } ================================================ FILE: lib/libwiznet/udp.c ================================================ /* * Udp.cpp: Library to send/receive UDP packets with the Arduino ethernet shield. * This version only offers minimal wrapping of socket.c/socket.h * * MIT License: * Copyright (c) 2008 Bjoern Hartmann * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * bjoern@cs.stanford.edu 12/30/2008 */ #include #include #include #include /* * Start UDP socket, listening at local port PORT */ int udp_init (udp_t *u, unsigned port) { int i; for (i = 0; i < MAX_SOCK_NUM; i++) { uint8_t s = w5100_readSnSR(i); if (s == SnSR_CLOSED || s == SnSR_FIN_WAIT) { u->sock = i; break; } } if (u->sock == MAX_SOCK_NUM) return 0; u->port = port; socket_init (u->sock, SnMR_UDP, u->port, 0); return 1; } /* * Is data available in rx buffer? * Returns 0 if no, number of available bytes if yes. * returned value includes 8 byte UDP header! */ unsigned udp_available (udp_t *u) { return w5100_getRXReceivedSize (u->sock); } /* * Release any resources being used by this UDP instance. */ void udp_stop (udp_t *u) { if (u->sock == MAX_SOCK_NUM) return; socket_close (u->sock); _socket_port[u->sock] = 0; u->sock = MAX_SOCK_NUM; } /* * Send packet contained in buf of length len to peer at specified ip, and port. * Use this function to transmit binary data that might contain 0x00 bytes. * This function returns sent data size for success else -1. */ unsigned udp_send_packet (udp_t *u, const uint8_t *buf, unsigned len, uint8_t *ip, unsigned port) { return socket_sendto (u->sock, buf, len, ip, port); } /* * Send zero-terminated string str as packet to peer at specified ip, and port. * This function returns sent data size for success else -1. */ unsigned udp_send_string (udp_t *u, const char *str, uint8_t *ip, unsigned port) { unsigned len = strlen (str); return socket_sendto (u->sock, (const uint8_t *) str, len, ip, port); } /* * Read a received packet into buffer buf (which is of maximum length len); * store calling ip and port as well. Call available() to make sure data is * ready first. * NOTE: I don't believe len is ever checked in implementation of recvfrom(), * so it's easy to overflow buffer. so we check and truncate. * Returns number of bytes read, or negative number of bytes we would have * needed if we truncated. */ int udp_read_packet (udp_t *u, uint8_t *buf, unsigned len, uint8_t *ip, unsigned *port) { int nbytes = udp_available (u) - 8; /* skip UDP header */ if (nbytes < 0) { /* No real data here. */ return 0; } if (nbytes > (int)len) { /* Packet is too large - truncate. * HACK: hand-parse the UDP packet using TCP recv method. */ uint8_t tmpBuf[8]; int i; /* Read 8 header bytes and get IP and port from it. */ socket_recv (u->sock, tmpBuf, 8); if (ip != 0) { ip[0] = tmpBuf[0]; ip[1] = tmpBuf[1]; ip[2] = tmpBuf[2]; ip[3] = tmpBuf[3]; } if (port != 0) *port = (tmpBuf[4] << 8) + tmpBuf[5]; /* Now copy first (len) bytes into buf. */ for (i=0; i<(int)len; i++) { socket_recv (u->sock, tmpBuf, 1); buf[i] = tmpBuf[0]; } /* And just read the rest byte by byte and throw it away. */ while (udp_available (u)) { socket_recv (u->sock, tmpBuf, 1); } return -nbytes; } return socket_recvfrom (u->sock, buf, len, ip, port); } ================================================ FILE: lib/libwiznet/w5100.c ================================================ /* * Copyright (c) 2010 by Cristian Maglie * * This file is free software; you can redistribute it and/or modify * it under the terms of either the GNU General Public License version 2 * or the GNU Lesser General Public License version 2.1, both as * published by the Free Software Foundation. * * Edit History * Aug 3, 2011 ported toh chipKIT boards * Sept 13, 2011 change SPI clock divider from DIV8 to DIV32 * Apr 16, 2012 ported to RetroBSD */ #include #include #include #include #include #include #define SPI_DEVNAME "/dev/spi2" // W5100 chip is connected to SPI2 #define SPI_KHZ 5000 // Clock speed 5 MHz #define SPI_SELPIN 0x0404 // chipKIT board: select pin D4 #define TXBUF_BASE 0x4000 #define RXBUF_BASE 0x6000 #define RST 7 // Reset BIT #define TXBUF_MASK (TXBUF_SIZE-1) // Tx buffer MASK #define RXBUF_MASK (RXBUF_SIZE-1) // Rx buffer MASK static uint16_t SBASE [MAX_SOCK_NUM]; // Tx buffer base address static uint16_t RBASE [MAX_SOCK_NUM]; // Rx buffer base address static int spi; // SPI driver descriptor void w5100_init() { int i, failed; spi = open (SPI_DEVNAME, O_RDWR); if (spi < 0) { perror (SPI_DEVNAME); exit (-1); } ioctl (spi, SPICTL_SETRATE, SPI_KHZ); ioctl (spi, SPICTL_SETSELPIN, SPI_SELPIN); /* Reset the chip. */ w5100_writeMR (MR_RST); /* Assign 2 kbytes of memory to RX and TX of each socket. */ w5100_writeTMSR (0x55); w5100_writeRMSR (0x55); for (i=0; i TXBUF_SIZE) { // Wrap around circular buffer unsigned size = TXBUF_SIZE - offset; w5100_write (dstAddr, data, size); w5100_write (SBASE[sock], data + size, len - size); W5100_DEBUG ("TX %04x-%04x, %04x-%04x\n", dstAddr, dstAddr+size-1, SBASE[sock], SBASE[sock]+len-size-1); } else { w5100_write (dstAddr, data, len); W5100_DEBUG ("TX %04x-%04x\n", dstAddr, dstAddr+len-1); } ptr += len; w5100_writeSnTX_WR (sock, ptr); W5100_DEBUG ("set TX write pointer = %04x\n", ptr); } void w5100_recv_chunk (unsigned sock, uint8_t *data, unsigned len) { unsigned ptr = w5100_readSnRX_RD (sock); W5100_DEBUG ("recv chunk: RX pointer = %04x\n", ptr); w5100_read_data (sock, ptr, data, len); ptr += len; w5100_writeSnRX_RD (sock, ptr); W5100_DEBUG ("set RX pointer = %04x\n", ptr); } unsigned w5100_recv_peek (unsigned sock) { unsigned ptr = w5100_readSnRX_RD (sock); unsigned char byte; w5100_read_data (sock, ptr, &byte, 1); return byte; } void w5100_socket_cmd (unsigned sock, int cmd) { // Send command to socket w5100_writeSnCR (sock, cmd); // Wait for command to complete while (w5100_readSnCR (sock)) ; } void w5100_read_data (unsigned sock, unsigned ptr, uint8_t *dst, unsigned len) { unsigned offset = ptr & RXBUF_MASK; unsigned srcAddr = offset + RBASE[sock]; if (offset + len > RXBUF_SIZE) { unsigned size = RXBUF_SIZE - offset; w5100_read (srcAddr, dst, size); w5100_read (RBASE[sock], dst + size, len - size); W5100_DEBUG ("RX %04x-%04x, %04x-%04x\n", srcAddr, srcAddr+size-1, SBASE[sock], SBASE[sock]+len-size-1); } else { w5100_read (srcAddr, dst, len); W5100_DEBUG ("RX %04x-%04x\n", srcAddr, srcAddr+len-1); } } unsigned w5100_write_byte (unsigned addr, int byte) { uint8_t data[4]; data[0] = 0xF0; data[1] = addr >> 8; data[2] = addr; data[3] = byte; ioctl (spi, SPICTL_IO8(4), data); return 1; } unsigned w5100_write (unsigned addr, const uint8_t *buf, unsigned len) { uint8_t data[4]; unsigned i; for (i=0; i> 8; data[2] = addr; data[3] = buf[i]; ioctl (spi, SPICTL_IO8(4), data); addr++; } return len; } unsigned w5100_read_byte (unsigned addr) { uint8_t data[4]; data[0] = 0x0F; data[1] = addr >> 8; data[2] = addr; data[3] = 0xFF; ioctl (spi, SPICTL_IO8(4), data); return data[3]; } unsigned w5100_read (unsigned addr, uint8_t *buf, unsigned len) { uint8_t data[4]; unsigned i; for (i=0; i> 8; data[2] = addr; data[3] = 0xFF; ioctl (spi, SPICTL_IO8(4), data); addr++; buf[i] = data[3]; } return len; } ================================================ FILE: lib/startup-arm/Makefile ================================================ # # Copyright (c) 1987 Regents of the University of California. # All rights reserved. The Berkeley software License Agreement # specifies the terms and conditions for redistribution. # # crt0 Normal C run time startoff # TOPSRC!=cd ../..; pwd include ${TOPSRC}/share/mk/sys.mk CFLAGS += -O ${DEFS} SRCS = crt0.c OBJS = crt0.o TAGSFILE = tags all: ${OBJS} cp crt0.o ../ install: ${OBJS} # ${INSTALL} -d ${DESTDIR}/usr/lib # $(INSTALL) crt0.o ${DESTDIR}/usr/lib/crt0.o # $(INSTALL) mcrt0.o ${DESTDIR}/usr/lib/mcrt0.o # $(INSTALL) gcrt0.o ${DESTDIR}/usr/lib/gcrt0.o crt0.o: crt0.c ${CC} ${DEFS} ${CFLAGS} -c crt0.c -o $@ tags: cwd=`pwd`; \ for i in *.c; do \ ctags -a -f ${TAGSFILE} $$cwd/$$i; \ done clean: rm -f *.o *~ core errs tags Makefile.bak depend: for i in ${SRCS}; do \ cc -M ${DEFS} ${DFLAGS} $$i | awk ' { if ($$1 != prev) \ { if (rec != "") print rec; rec = $$0; prev = $$1; } \ else { if (length(rec $$2) > 78) { print rec; rec = $$0; } \ else rec = rec " " $$2 } } \ END { print rec } ' >> makedep; done echo '/^# DO NOT DELETE THIS LINE/+2,$$d' >eddep echo '$$r makedep' >>eddep echo 'w' >>eddep cp Makefile Makefile.bak ed - Makefile < eddep rm eddep makedep echo '# DEPENDENCIES MUST END AT END OF FILE' >> Makefile echo '# IF YOU PUT STUFF HERE IT WILL GO AWAY' >> Makefile echo '# see make depend above' >> Makefile # DO NOT DELETE THIS LINE -- make depend uses it ================================================ FILE: lib/startup-arm/crt0.c ================================================ /* * Copyright (c) 1987 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include #include /* * C runtime startoff. When an a.out is loaded by the kernel, the kernel * sets up the stack as follows: * * --------------------------------- top of memory * | (NULL) | end of command-line args and env * |-------------------------------| * | | * | environment strings | * | | * |-------------------------------| * | | * | argument strings | * | | * |-------------------------------| * | envv[envc] (NULL) | end of environment vector tag, a 0 * |-------------------------------| * | envv[envc-1] | pointer to last environment string * |-------------------------------| * | ... | * |-------------------------------| * | envv[0] | pointer to first environment string * |-------------------------------| * | argv[argc] (NULL) | end of argument vector tag, a 0 * |-------------------------------| * | argv[argc-1] | pointer to last argument string * |-------------------------------| * | ... | * |-------------------------------| * | argv[0] | pointer to first argument string * |-------------------------------| * | &envv[0] | pointer to array of env pointers * |-------------------------------| * | &argv[0] | pointer to array of arg pointers * |-------------------------------| * sp-> | argc | number of command-line arguments * --------------------------------- * * Arguments are passed in registers $a1, $a2 and $a3. * * Crt0 simply moves the env to environ variable, calculates * the __progname and then calls main. */ extern int main (int, char **, char **); char **environ; const char *__progname = ""; void _start (int, char **, char **); /* The entry function. */ void _start (argc, argv, env) int argc; char **argv; char **env; { environ = env; if (argc > 0 && argv[0] != 0) { const char *s; __progname = argv[0]; for (s = __progname; *s != '\0'; s++) if (*s == '/') __progname = s + 1; } exit (main (argc, argv, environ)); } ================================================ FILE: lib/startup-arm/mon.c ================================================ /* * Copyright (c) 1987 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)mon.c 5.5 (GTE) 3/23/92"; #endif LIBC_SCCS and not lint #define ARCDENSITY 1 /* density of routines per 100 bytes */ #define MINARCS 50 /* minimum number of counters */ #define HISTFRACTION 8 /* fraction of text space for histograms */ struct phdr { /* mon.out header */ int *lpc; /* low pc of histogramed text space */ int *hpc; /* high pc */ int ncnt; /* number of functions counted */ }; struct cnt { /* function entry count structure */ int (*pc)(); /* address of profiled function */ long ncall; /* number of time function called */ }; static struct cnt *countbase; /* next free cnt struct */ static struct cnt *countend; /* first address past cnt structs */ static short *s_sbuf; /* start of histogram buffer */ static unsigned s_bufsize; /* size of histogram buffer (in chars) */ static char *s_lowpc; /* low pc for histgram recording */ static unsigned s_scale; /* histogram scale */ #define PERROR(s) write(2, s, sizeof(s)-1) monstartup(lowpc, highpc) char *lowpc; char *highpc; { unsigned int cntsize, monsize; char *buffer; extern char *sbrk(); extern char *minbrk; cntsize = (unsigned)(highpc - lowpc) * ARCDENSITY / 100; if (cntsize < MINARCS) cntsize = MINARCS; monsize = (unsigned)(highpc - lowpc + HISTFRACTION - 1) / HISTFRACTION + sizeof(struct phdr) + cntsize * sizeof(struct cnt); monsize = (monsize + 1) & ~1; buffer = sbrk(monsize); if (buffer == (char *)-1) { PERROR("monstartup: no space for monitor buffer(s)\n"); return; } minbrk = sbrk(0); monitor(lowpc, highpc, buffer, monsize>>1, cntsize); } monitor(lowpc, highpc, buf, bufsize, cntsize) char *lowpc, *highpc; char *buf; /* really (short *) but easier this way */ unsigned bufsize, cntsize; { register unsigned o; register struct phdr *php; static char *sbuf; /* saved base of profiling buffer */ static unsigned ssize; /* saved buffer size */ if (lowpc == 0) { moncontrol(0); o = creat("mon.out", 0666); write(o, sbuf, ssize); close(o); return; } bufsize *= sizeof(short); if (bufsize < sizeof(struct phdr)+sizeof(struct cnt)+sizeof(short)) { PERROR("monitor: buffer too small"); return; } sbuf = buf; ssize = bufsize; countbase = (struct cnt *)(buf + sizeof(struct phdr)); o = sizeof(struct phdr) + cntsize * sizeof(struct cnt); if (o > bufsize) { cntsize = (bufsize - sizeof(struct phdr))/sizeof(struct cnt); o = sizeof(struct phdr) + cntsize * sizeof(struct cnt); } countend = (struct cnt *)(buf + o); php = (struct phdr *)buf; php->lpc = (int *)lowpc; php->hpc = (int *)highpc; php->ncnt = cntsize; s_sbuf = (short *)countend; s_bufsize = bufsize - o; s_lowpc = lowpc; o = highpc - lowpc; if(s_bufsize < o) o = ((long)s_bufsize << 16) / o; else o = 0xffff; s_scale = o; moncontrol(1); } /* * Control profiling */ moncontrol(mode) int mode; { if (mode) { /* start */ profil(s_sbuf, s_bufsize, s_lowpc, s_scale); } else { /* stop */ profil((char *)0, 0, 0, 0); } } ================================================ FILE: lib/startup-arm/mon.ex ================================================ " @(#)mon.ex 4.4 (Berkeley) 7/26/83" " fix funny name for minbrk used by monstartup() to limit brk()" g/_minbrk/s//minbrk/g w q ================================================ FILE: lib/startup-mips/Makefile ================================================ # # Copyright (c) 1987 Regents of the University of California. # All rights reserved. The Berkeley software License Agreement # specifies the terms and conditions for redistribution. # # crt0 Normal C run time startoff # TOPSRC!=cd ../..; pwd include ${TOPSRC}/share/mk/sys.mk # Do not include -mips16 as it chokes on `la $gp,_gp'. CFLAGS = -O ${DEFS} SRCS = crt0.c OBJS = crt0.o TAGSFILE = tags all: ${OBJS} cp crt0.o ../ install: ${OBJS} # ${INSTALL} -d ${DESTDIR}/usr/lib # $(INSTALL) crt0.o ${DESTDIR}/usr/lib/crt0.o # $(INSTALL) mcrt0.o ${DESTDIR}/usr/lib/mcrt0.o # $(INSTALL) gcrt0.o ${DESTDIR}/usr/lib/gcrt0.o crt0.o: crt0.c ${CC} ${DEFS} ${CFLAGS} -c crt0.c -o $@ tags: cwd=`pwd`; \ for i in *.c; do \ ctags -a -f ${TAGSFILE} $$cwd/$$i; \ done clean: rm -f *.o *~ core errs tags Makefile.bak depend: for i in ${SRCS}; do \ cc -M ${DEFS} ${DFLAGS} $$i | awk ' { if ($$1 != prev) \ { if (rec != "") print rec; rec = $$0; prev = $$1; } \ else { if (length(rec $$2) > 78) { print rec; rec = $$0; } \ else rec = rec " " $$2 } } \ END { print rec } ' >> makedep; done echo '/^# DO NOT DELETE THIS LINE/+2,$$d' >eddep echo '$$r makedep' >>eddep echo 'w' >>eddep cp Makefile Makefile.bak ed - Makefile < eddep rm eddep makedep echo '# DEPENDENCIES MUST END AT END OF FILE' >> Makefile echo '# IF YOU PUT STUFF HERE IT WILL GO AWAY' >> Makefile echo '# see make depend above' >> Makefile # DO NOT DELETE THIS LINE -- make depend uses it ================================================ FILE: lib/startup-mips/crt0.c ================================================ /* * Copyright (c) 1987 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include #include /* * C runtime startoff. When an a.out is loaded by the kernel, the kernel * sets up the stack as follows: * * _________________________________ * | (NULL) | top of memory * |-------------------------------| * | | * | environment strings | * | | * |-------------------------------| * | | * | argument strings | * | | * |-------------------------------| * | envv[envc] (NULL) | end of environment vector tag, a 0 * |-------------------------------| * | envv[envc-1] | pointer to last environment string * |-------------------------------| * | ... | * |-------------------------------| * | envv[0] | pointer to first environment string * |-------------------------------| * | argv[argc] (NULL) | end of argument vector tag, a 0 * |-------------------------------| * | argv[argc-1] | pointer to last argument string * |-------------------------------| * | ... | * |-------------------------------| * | argv[0] | pointer to first argument string * |-------------------------------| * | | space for fourth argument * |-------------------------------| * | | space for third argument * |-------------------------------| * | | space for second argument * |-------------------------------| * sp-> | | space for first * --------------------------------- * * Arguments are passed in registers $a0, $a1 and $a2. * Register $gp is set to the start of data section. * * Crt0 simply moves the env to environ variable, calculates * the __progname and then calls main. */ extern int main (int, char **, char **); char **environ; const char *__progname = ""; void _start (int, char **, char **); /* The entry function. */ void _start (argc, argv, env) int argc; char **argv; char **env; { asm volatile ("la $gp, _gp"); environ = env; if (argc > 0 && argv[0] != 0) { const char *s; __progname = argv[0]; for (s = __progname; *s != '\0'; s++) if (*s == '/') __progname = s + 1; } exit (main (argc, argv, env)); } ================================================ FILE: lib/startup-mips/mcount.S ================================================ /* * Copyright (c) 1987 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #ifdef LIBC_SCCS <@(#)mcount.s 1.1 (Berkeley) 5/2/87\0> .even #endif LIBC_SCCS /* * Count subroutine calls during simple (non-gprof) profiling. This file is * appended to the compiled assembly output of mon.c. * * struct cnt { * int (*pc)(); / address of function * long ncall; / number of times _foo entered * } * * mcount(cntp::r0) * long **cntp; * * Mcount is called with a pointer to a function's local call count pointer in * r0. On first entry, mcount allocates a (struct cnt) and initializes it with * the function's base segment address and points the functions local call * counter pointer just past the structure's ncall field. (we do this so we * can do long increments slightly faster) * * The C compiler generates the following preamble for every function * compiled with profiling: * * .data * 1: _foo+1 * .text * * _foo: / unique name of foo (always in base) * ~foo: / real address of foo * +0 jsr r5,csv / perform standard C entry * +4 mov $1b,r0 / point to local call counter pointer * +8 jsr pc,mcount / and have mcount do its thing * +12 ... / first `real' word of ~foo * * Function and ncall field addresses are always even so the "_foo+1" doesn't * destroy information and can be used to determine a first call to mcount. * * Note that because we now use functions' base segment address rather than * our own return address (as was done in the past) and because the call to * mcount is after that to csv, profiling now works for overlaid objects. * Only static routines in overlays which are assigned the same address by * the loader may be counted incorrectly. */ #include "../sys/SYS.h" #undef PROF .text ASENTRY(mcount) tst _countbase / buffer set up yet? beq 2f / nope, just exit mov (r0),r1 / cnt struct allocated yet? bit $1,r1 bne 3f / nope, grab one 1: add $1,-(r1) / increment *(*cnt-1) adc -(r1) 2: rts pc / and return 3: mov _countbase,r1 cmp r1,_countend / no, out of cnt structs? bhis 3f / yes, output error message mov (r0),(r1) / save _foo bic $1,(r1)+ cmp (r1)+,(r1)+ / move on to next cnt struct and mov r1,_countbase / save in _countbase mov r1,(r0) / save pointer to &ncall+1 in *cntp br 1b / increment ncall (to 1) 3: mov $9f-8f,-(sp) / ran out cnt structs, output an mov $8f,-(sp) / error message mov $2,-(sp) tst -(sp) / simulate return address stack SYS(write) / spacing and perform write (we add $8.,sp / have to do the syscall because rts pc / _write calls mcount) .data 8: 9: .text ================================================ FILE: lib/startup-mips/mon.c ================================================ /* * Copyright (c) 1987 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)mon.c 5.5 (GTE) 3/23/92"; #endif LIBC_SCCS and not lint #define ARCDENSITY 1 /* density of routines per 100 bytes */ #define MINARCS 50 /* minimum number of counters */ #define HISTFRACTION 8 /* fraction of text space for histograms */ struct phdr { /* mon.out header */ int *lpc; /* low pc of histogramed text space */ int *hpc; /* high pc */ int ncnt; /* number of functions counted */ }; struct cnt { /* function entry count structure */ int (*pc)(); /* address of profiled function */ long ncall; /* number of time function called */ }; static struct cnt *countbase; /* next free cnt struct */ static struct cnt *countend; /* first address past cnt structs */ static short *s_sbuf; /* start of histogram buffer */ static unsigned s_bufsize; /* size of histogram buffer (in chars) */ static char *s_lowpc; /* low pc for histgram recording */ static unsigned s_scale; /* histogram scale */ #define PERROR(s) write(2, s, sizeof(s)-1) monstartup(lowpc, highpc) char *lowpc; char *highpc; { unsigned int cntsize, monsize; char *buffer; extern char *sbrk(); extern char *minbrk; cntsize = (unsigned)(highpc - lowpc) * ARCDENSITY / 100; if (cntsize < MINARCS) cntsize = MINARCS; monsize = (unsigned)(highpc - lowpc + HISTFRACTION - 1) / HISTFRACTION + sizeof(struct phdr) + cntsize * sizeof(struct cnt); monsize = (monsize + 1) & ~1; buffer = sbrk(monsize); if (buffer == (char *)-1) { PERROR("monstartup: no space for monitor buffer(s)\n"); return; } minbrk = sbrk(0); monitor(lowpc, highpc, buffer, monsize>>1, cntsize); } monitor(lowpc, highpc, buf, bufsize, cntsize) char *lowpc, *highpc; char *buf; /* really (short *) but easier this way */ unsigned bufsize, cntsize; { register unsigned o; register struct phdr *php; static char *sbuf; /* saved base of profiling buffer */ static unsigned ssize; /* saved buffer size */ if (lowpc == 0) { moncontrol(0); o = creat("mon.out", 0666); write(o, sbuf, ssize); close(o); return; } bufsize *= sizeof(short); if (bufsize < sizeof(struct phdr)+sizeof(struct cnt)+sizeof(short)) { PERROR("monitor: buffer too small"); return; } sbuf = buf; ssize = bufsize; countbase = (struct cnt *)(buf + sizeof(struct phdr)); o = sizeof(struct phdr) + cntsize * sizeof(struct cnt); if (o > bufsize) { cntsize = (bufsize - sizeof(struct phdr))/sizeof(struct cnt); o = sizeof(struct phdr) + cntsize * sizeof(struct cnt); } countend = (struct cnt *)(buf + o); php = (struct phdr *)buf; php->lpc = (int *)lowpc; php->hpc = (int *)highpc; php->ncnt = cntsize; s_sbuf = (short *)countend; s_bufsize = bufsize - o; s_lowpc = lowpc; o = highpc - lowpc; if(s_bufsize < o) o = ((long)s_bufsize << 16) / o; else o = 0xffff; s_scale = o; moncontrol(1); } /* * Control profiling */ moncontrol(mode) int mode; { if (mode) { /* start */ profil(s_sbuf, s_bufsize, s_lowpc, s_scale); } else { /* stop */ profil((char *)0, 0, 0, 0); } } ================================================ FILE: lib/startup-mips/mon.ex ================================================ " @(#)mon.ex 4.4 (Berkeley) 7/26/83" " fix funny name for minbrk used by monstartup() to limit brk()" g/_minbrk/s//minbrk/g w q ================================================ FILE: libexec/Makefile ================================================ # # Public domain - 1996/10/26 - sms # # @(#)Makefile 1.3 (2.11BSD) 1999/7/21 # TOPSRC!=cd ..; pwd include ${TOPSRC}/share/mk/sys.mk SUBDIR= getty all: ${SUBDIR} ${SUBDIR}: FRC cd $@; ${MAKE} ${MFLAGS} all FRC: install: FRC -for i in ${SUBDIR}; do \ (cd $$i; ${MAKE} ${MFLAGS} DESTDIR=${DESTDIR} install); done clean: -for i in ${SUBDIR}; do (cd $$i; ${MAKE} ${MFLAGS} clean); done rm -f *~ ================================================ FILE: sbin/Makefile ================================================ # # Public domain - 1996/10/26 - sms # # @(#)Makefile 1.3 (2.11BSD) 1999/7/21 # TOPSRC!=cd ..; pwd include ${TOPSRC}/share/mk/sys.mk SUBDIR= chown fdisk fsck init mkfs mknod mount \ reboot shutdown sysctl umount all: ${SUBDIR} ${SUBDIR}: FRC cd $@; ${MAKE} ${MFLAGS} all FRC: install: FRC -for i in ${SUBDIR}; do \ (cd $$i; ${MAKE} ${MFLAGS} DESTDIR=${DESTDIR} install); done clean: for i in ${SUBDIR}; do (cd $$i; ${MAKE} ${MFLAGS} clean); done rm -f *~ ================================================ FILE: share/Makefile ================================================ # # Public domain - 1996/10/21 - sms # # @(#)Makefile 1.1 (2.11BSD) 1996/11/29 # TOPSRC!=cd ..; pwd include ${TOPSRC}/share/mk/sys.mk SUBDIR = dict examples man misc zoneinfo all: ${SUBDIR} ${SUBDIR}: FRC cd $@; ${MAKE} ${MFLAGS} FRC: install: FRC -for i in ${SUBDIR}; do \ (cd $$i; ${MAKE} ${MFLAGS} DESTDIR=${DESTDIR} install); done clean: rm -f *~ for i in ${SUBDIR}; do (cd $$i; ${MAKE} ${MFLAGS} clean); done ================================================ FILE: share/dict/Makefile ================================================ # @(#)Makefile 8.1 (Berkeley) 6/5/93 TOPSRC!=cd ../..; pwd include ${TOPSRC}/share/mk/sys.mk FILES= words all clean cleandir depend lint tags: install: ${INSTALL} -d ${DESTDIR}/usr/share/dict ${INSTALL} -c -m 444 ${FILES} ${DESTDIR}/usr/share/dict ================================================ FILE: share/dict/words ================================================ a AAA AAAS aardvark Aarhus Aaron ABA Ababa aback abacus abalone abandon abase abash abate abbas abbe abbey abbot Abbott abbreviate abc abdicate abdomen abdominal abduct Abe abed Abel Abelian Abelson Aberdeen Abernathy aberrant aberrate abet abetted abetting abeyance abeyant abhor abhorred abhorrent abide Abidjan Abigail abject abjure ablate ablaze able ablution abnegation Abner abnormal Abo aboard abode abolish abolition abominable abominate aboriginal aborigine aborning abort abound about above aboveboard aboveground abovementioned abrade Abraham Abram Abramson abrasion abrasive abreact abreast abridge abridgment abroad abrogate abrupt abscess abscissa abscissae abscond absent absentee absenteeism absentia absentminded absinthe absolute absolution absolve absorb absorbent absorption absorptive abstain abstention abstinent abstract abstractor abstruse absurd absurdum abuilding abundant abusable abuse abusive abut abutted abutting abysmal abyss Abyssinia AC acacia academia academic academician academy Acadia acanthus Acapulco accede accelerate accelerometer accent accentual accentuate accept acceptant acceptor access accessible accession accessory accident accidental accipiter acclaim acclamation acclimate accolade accommodate accompaniment accompanist accompany accomplice accomplish accord accordant accordion accost account accountant accouter Accra accredit accreditation accretion accrual accrue acculturate accumulate accuracy accurate accusation accusative accusatory accuse accustom ace acerbic acerbity acetaminophen acetate acetic acetone acetylene Achaean ache achieve Achilles aching achromatic acid acidic acidify acidulate acidulous Ackerman Ackley acknowledge acknowledgeable ACM acme acolyte acorn acoustic acquaint acquaintance acquiesce acquiescent acquire acquisition acquisitive acquit acquittal acquitting acre acreage acrid acrimonious acrimony acrobacy acrobat acrobatic acronym acrophobia acrophobic acropolis across acrylate acrylic act Actaeon actinic actinide actinium actinolite actinometer activate Acton actor actress actual actuarial actuate acuity acumen acupuncture acute acyclic ad Ada adage adagio Adair Adam adamant Adamson adapt adaptation adaptive add addend addenda addendum addict Addis Addison addition additive addle address addressee Addressograph adduce Adelaide Adele Adelia Aden adenine adenoma adenosine adept adequacy adequate adhere adherent adhesion adhesive adiabatic adieu adipic Adirondack adjacent adject adjectival adjoin adjoint adjourn adjudge adjudicate adjunct adjust adjutant Adkins Adler Adlerian administer administrable administrate administratrix admiral admiralty admiration admire admissible admission admit admittance admitted admitting admix admixture admonish admonition ado adobe adolescent Adolph Adolphus Adonis adopt adoption adoptive adoration adore adorn adposition adrenal adrenalin adrenaline Adrian Adriatic Adrienne adrift adroit adsorb adsorbate adsorption adsorptive adulate adult adulterate adulterous adultery advance advantage advantageous advent adventitious adventure adventurous adverb adverbial adversary adverse advert advertise advice advisable advise advisee advisor advisory advocacy advocate Aegean aegis Aeneas Aeneid aeolian Aeolus aerate aerial aerie Aerobacter aerobic aerodynamic aerofoil aerogene aeronautic aerosol aerospace Aeschylus Aesop aesthete aesthetic afar affable affair affect affectate affectionate afferent affiance affidavit affiliate affine affirm affirmation affirmative affix afflict affluent afford afforest afforestation affricate affront Afghan Afghanistan aficionado afield afire aflame afloat afoot aforementioned aforesaid aforethought afraid afreet afresh Africa Afrikaans Afrikaner afro aft afterbirth aftereffect afterglow afterimage afterlife aftermath afternoon afterthought afterward afterword again against Agamemnon agar agate Agatha agave age Agee agenda agent agglomerate agglutinate agglutinin aggravate aggregate aggression aggressive aggressor aggrieve aghast agile agitate agleam Agnes Agnew agnomen agnostic ago agog agone agony agouti agrarian agree agreeable agreeing agribusiness Agricola agricultural agriculture agrimony agronomist agronomy ague Agway ah ahead ahem Ahmedabad ahoy aid Aida aide Aides Aiken ail ailanthus aile aileron aim ain't Ainu air airborne airbrush aircraft airdrop airedale Aires airfare airfield airflow airframe airlift airline airlock airmail airman airmass airmen airpark airplane airport airspeed airstrip airtight airway airy aisle Aitken ajar Ajax AK Akers akin Akron AL ala Alabama Alabamian alabaster alacrity Aladdin alai Alameda Alamo alan alarm Alasdair Alaska Alastair alb alba albacore Albania Albany albatross albeit Alberich Albert Alberta Alberto albino Albrecht Albright album albumin Albuquerque Alcestis alchemist alchemy Alcmena Alcoa alcohol alcoholic Alcott alcove Aldebaran aldehyde Alden alder alderman aldermen Aldrich aldrin ale Alec Aleck aleph alert Aleutian alewife Alex Alexander Alexandra Alexandre Alexandria Alexei Alexis alfalfa alfonso Alfred Alfredo alfresco alga algae algaecide algal algebra algebraic Algenib Alger Algeria Algiers alginate Algol Algonquian Algonquin algorithm algorithmic Alhambra Ali alia alias alibi Alice Alicia alien alienate alight align alike alimentary alimony aliphatic aliquot Alison Alistair alive alizarin alkali alkaline alkaloid all Allah Allan allay allegate allege Allegheny allegiant allegoric allegory Allegra allegro allele allemand Allen Allentown allergic allergy alleviate alley alleyway alliance alligator Allis Allison alliterate allmsgs allocable allocate allot allotropic allotted allotting allow allowance alloy allspice Allstate allude allure allusion allusive alluvial alluvium ally allyl Allyn alma Almaden almagest almanac almighty almond almost aloe aloft aloha alone along alongside aloof aloud alp alpaca alpenstock Alpert alpha alphabet alphabetic alphanumeric Alpheratz Alphonse alpine already Alsatian also Alsop Altair altar alter alterate altercate altern alternate althea although altimeter altitude alto altogether Alton altruism altruist alum alumina aluminate alumna alumnae alumni alumnus alundum Alva Alvarez alveolar alveoli alveolus Alvin always alyssum A&M am AMA Amadeus amalgam amalgamate amanita amanuensis amaranth Amarillo amass amateur amateurish amatory amaze Amazon ambassador amber ambiance ambidextrous ambient ambiguity ambiguous ambition ambitious ambivalent amble ambrose ambrosia ambrosial ambulant ambulatory ambuscade ambush Amelia ameliorate amen amend amende Amerada America Americana americium Ames amethyst amethystine Amharic Amherst ami amicable amid amide amidst amigo amino aminobenzoic amiss amity Amman Ammerman ammeter ammo ammonia ammoniac ammonite ammonium ammunition amnesia amnesiac amnesty amniocentesis amniotic Amoco amoeba amoebae amoeboid amok among amongst amoral amorphous amort Amos amount amp amperage ampere ampersand Ampex amphetamine amphibian amphibious amphibole amphibology amphioxis ample amplify amplitude amply amputate amra Amsterdam Amtrak amulet amuse amy amygdaloid an ana Anabaptist Anabel anachronism anachronistic anaconda Anacreon anaerobic anaglyph anagram Anaheim Analects analeptic analgesic analogous analogue analogy analyses analysis analyst analytic anamorphic anaphora anaphoric anaplasmosis anarch anarchic anarchy Anastasia anastigmat anastigmatic anastomosis anastomotic anathema Anatole anatomic anatomist anatomy ancestor ancestral ancestry anchor anchorage anchorite anchovy ancient ancillary and Andalusia Andean Andersen Anderson Andes andesine andesite Andorra Andover Andre Andrea Andrei Andrew androgen Andromache Andromeda Andy anecdotal anecdote anemone anent anew angel Angela Angeles angelfish angelic Angelica Angelina Angeline Angelo anger Angie angiosperm angle Angles Anglican Anglo Anglophobia Angola Angora angry angst angstrom anguish angular Angus anharmonic Anheuser anhydride anhydrite anhydrous ani aniline animadversion animadvert animal animate animism animist animosity anion anionic anise aniseikonic anisotropic anisotropy Anita Ankara ankle Ann Anna annal Annale Annalen Annapolis Anne anneal annelid Annette annex Annie annihilate anniversary annotate announce annoy annoyance annual annuity annul annular annuli annulled annulling annulus annum annunciate anode anodic anoint anomalous anomaly anomie anonymity anonymous anorexia anorthic anorthite anorthosite another Anselm Anselmo ANSI answer ant antacid Antaeus antagonism antagonist antarctic Antarctica Antares ante anteater antebellum antecedent antedate antelope antenna antennae anterior anthem anther anthology Anthony anthracite anthracnose anthropocentric anthropogenic anthropoid anthropology anthropomorphic anthropomorphism anti antic anticipate anticipatory anticonvulsant Antietam antigen Antigone antigorite Antilles antimony Antioch antipasto antipathy antiperspirant antiphonal antipodal antipode antiquarian antiquary antiquated antique antiquity antisemite antisemitic antithetic antivenin antler Antoine Antoinette Anton Antonio Antony antonym Antwerp anus anvil anxiety anxious any anybody anybody'd anyhow anyone anyplace anything anyway anywhere aorta A&P apache apart apartheid apathetic apathy apatite ape aperiodic aperture apex aphasia aphasic aphelion aphid aphorism aphrodisiac Aphrodite apiary apical apices apiece aplomb apocalypse apocalyptic Apocrypha apocryphal apogee Apollo Apollonian apologetic apologia apology apoplectic apoplexy apostasy apostate apostle apostolic apostrophe apothecary apothegm apotheosis Appalachia appall appanage apparatus apparel apparent apparition appeal appear appearance appeasable appease appellant appellate append appendage appendices appendix appertain appetite Appian applaud applause apple Appleby applejack Appleton appliance applicable applicant applicate applique apply appoint appointe appointee apport apposite apposition appraisal appraise appreciable appreciate apprehend apprehension apprehensive apprentice apprise approach approbation appropriable appropriate approval approve approximable approximant approximate apricot April apron apropos apse apt aptitude aqua aquarium Aquarius aquatic aqueduct aqueous aquifer Aquila Aquinas AR Arab arabesque Arabia Arabic Araby Arachne arachnid Arapaho arbiter arbitrage arbitrary arbitrate arboreal arborescent arboretum arbutus arc arcade Arcadia arcana arcane arccos arccosine arch archae archaic archaism archangel archbishop archdiocese archenemy archery archetype archetypical archfool Archibald Archimedes archipelago architect architectonic architectural architecture archival archive arcing arclength arcsin arcsine arctan arctangent arctic Arcturus Arden ardent arduous are area areaway areawide arena arenaceous aren't Arequipa Ares Argentina Argentine Argentinian argillaceous arginine Argive argo argon Argonaut Argonne argot argue argument argumentation argumentative Argus arhat aria Ariadne Arianism arid Aries arise arisen aristocracy aristocrat aristocratic Aristotelean Aristotelian Aristotle arithmetic Arizona ark Arkansan Arkansas Arlen Arlene Arlington arm armada armadillo Armageddon armament Armata armature armchair Armco Armenia armful armhole armillaria armistice armload armoire Armonk Armour armpit Armstrong army Arnold aroma aromatic arose around arousal arouse ARPA arpeggio arrack Arragon arraign arrange arrangeable array arrear arrest Arrhenius arrival arrive arrogant arrogate arrow arrowhead arrowroot arroyo arsenal arsenate arsenic arsenide arsine arson art Artemis artemisia arterial arteriole arteriolosclerosis arteriosclerosis artery artful arthritis arthropod Arthur artichoke article articulate articulatory Artie artifact artifice artificial artillery artisan artistry Arturo artwork arty Aruba arum aryl a's as asbestos ascend ascendant ascension ascent ascertain ascetic ascii ascomycetes ascribe ascription aseptic ash ashame ashen Asher Asheville Ashland Ashley ashman ashmen Ashmolean ashore ashram ashtray ashy Asia Asiatic aside Asilomar asinine ask askance askew asleep asocial asparagine asparagus aspartic aspect aspen asperity aspersion asphalt aspheric asphyxiate aspidistra aspirant aspirate aspire aspirin asplenium ass assai assail assailant Assam assassin assassinate assault assay assemblage assemble assent assert assess assessor asset assiduity assiduous assign assignation assignee assimilable assimilate assist assistant associable associate assonant assort assuage assume assumption assurance assure Assyria Assyriology Astarte astatine aster asteria asterisk asteroid asteroidal asthma astigmat astigmatic ASTM astonish Astor Astoria astound astraddle astral astray astride astringent astrologer astrology astronaut astronautic astronomer astronomic astronomy astrophysical astrophysicist astrophysics astute Asuncion asunder asylum asymmetry asymptomatic asymptote asymptotic asynchronous asynchrony at Atalanta atavism atavistic Atchison ate Athabascan atheism atheist Athena Athenian Athens athlete athletic athwart Atkins Atkinson Atlanta atlantes atlantic Atlantis atlas atmosphere atmospheric atoll atom atomic atonal atone atonic atop Atreus atrocious atrocity atrophic atrophy Atropos AT&T attach attache attack attain attainder attempt attend attendant attendee attention attentive attenuate attest attestation attic Attica attire attitude Attlee attorney attract attribute attribution attributive attrition attune Atwater Atwood atypic Auberge Aubrey auburn Auckland auction auctioneer audacious audacity audible audience audio audiotape audiovisual audit audition auditor auditorium auditory Audrey Audubon Auerbach Aug Augean auger augite augment augmentation augur august Augusta Augustine Augustus auk aunt auntie aura aural Aurelius aureomycin auric Auriga aurochs aurora Auschwitz auspice auspices auspicious austenite austere Austin austral Australia Australis australite Austria authentic authenticate author authoritarian authoritative autism autistic auto autobiography autochthonous autoclave autocollimate autocorrelate autocracy autocrat autocratic autograph automat automata automate automatic automaton automobile automorphism automotive autonomic autonomous autonomy autopilot autopsy autosuggestible autotransformer autumn autumnal auxiliary auxin avail avalanche avarice avaricious Ave avenge Aventine avenue aver average Avernus averred averring averse aversion avert Avery Avesta avian aviary aviate aviatrix avid Avignon avionic Avis Aviv avocado avocate avocet Avogadro avoid avoidance Avon avow avowal await awake awaken award aware awash away awe awesome awful awhile awkward awl awn awoke awry ax axe axial axiology axiom axiomatic axis axisymmetric axle axolotl axon aye Ayers Aylesbury AZ azalea Azerbaijan azimuth azimuthal Azores Aztec Aztecan azure b babbitt babble Babcock babe Babel baboon baby Babylon babysat babysit babysitting baccalaureate baccarat bacchanalian Bacchus Bach bachelor bacilli bacillus back backboard backbone backdrop backfill backgammon background backhand backlash backlog backorder backpack backpedal backplane backplate backscatter backside backslash backslide backspace backstage backstitch backstop backtrack backup backward backwash backwater backwood backyard bacon bacteria bacterial bacterium bad bade Baden badge badinage badland badminton Baffin baffle bag bagatelle baggage bagging baggy Baghdad Bagley bagpipe bah Bahama Bahrein bail Bailey bailiff bainite Baird bait Baja bake Bakelite Bakersfield bakery Bakhtiari baklava Baku balance Balboa balcony bald baldpate Baldwin baldy bale baleen baleful Balfour Bali Balinese balk Balkan balky ball ballad Ballard ballast ballerina ballet balletomane ballfield balloon ballot ballroom ballyhoo balm balmy balsa balsam Baltic Baltimore Baltimorean balustrade Balzac bam Bamako Bamberger Bambi bamboo ban Banach banal banana Banbury band bandage bandgap bandit bandpass bandstand bandstop bandwagon bandwidth bandy bane baneberry baneful bang bangkok Bangladesh bangle Bangor Bangui banish banister banjo bank bankrupt bankruptcy bannock banquet banshee bantam banter Bantu Bantus baobab baptism baptismal Baptist Baptiste baptistery bar barb Barbados Barbara barbarian barbaric barbarism barbarous barbecue barbell barber barberry barbital barbiturate Barbour barbudo Barcelona Barclay bard bare bareback barefaced barefoot barfly bargain barge baritone barium bark barkeep barley Barlow barn Barnabas barnacle Barnard Barnes Barnet Barnett Barney Barnhard barnstorm Barnum barnyard barometer baron baroness baronet baronial barony baroque Barr barrack barracuda barrage barre barrel barren Barrett barrette barricade barrier Barrington barrow Barry Barrymore Barstow bartend bartender barter Barth Bartholomew Bartlett Bartok Barton barycentric baryon basal basalt basaltic base baseball baseband baseboard Basel baseline baseman basemen baseplate basepoint bash bashaw bashful basic basidiomycetes basil basilar basilica basilisk basin basis bask basket basketball basketry basophilic Basque bass Bassett bassi bassinet basso bassoon basswood bastard baste bastion bat Batavia batch Batchelder bate bateau Bateman bater bath bathe bathos bathrobe bathroom bathtub Bathurst batik baton Bator batt battalion Battelle batten battery battle battlefield battlefront battleground batwing bauble baud Baudelaire Bauer Bauhaus Bausch bauxite Bavaria bawd bawdy bawl Baxter bay bayberry Bayda Bayesian Baylor bayonet Bayonne bayou Bayport Bayreuth bazaar be beach beachhead beacon bead beadle beady beagle beak beam bean bear bearberry beard Beardsley bearish beast beastie beat beaten beater beatific beatify beatitude beatnik Beatrice beau Beaujolais Beaumont Beauregard beauteous beautiful beautify beauty beaux beaver bebop becalm became because Bechtel beck becket Beckman beckon Becky become bed bedazzle bedbug bedevil bedfast bedfellow Bedford bedim bedimmed bedimming bedlam bedpost bedraggle bedridden bedrock bedroom bedside bedspread bedspring bedstraw bedtime bee Beebe beebread beech Beecham beechwood beef beefsteak beefy beehive been beep beer beeswax beet Beethoven beetle befall befallen befell befit befitting befog befogging before beforehand befoul befriend befuddle beg began begat beget begetting beggar beggary begging begin beginner beginning begonia begot begotten begrudge beguile begun behalf behave behead beheld behind behold beige Beijing being Beirut bel Bela belate belch Belfast belfry Belgian Belgium Belgrade belie belief believe belittle Belize bell Bella belladonna Bellamy Bellatrix bellboy belle bellflower bellhop bellicose belligerent Bellingham Bellini bellman bellmen bellow bellum bellwether belly bellyache bellyaching bellyful Belmont Beloit belong belove below Belshazzar belt Beltsville beluga belvedere BEMA bemadden beman bemoan bemuse Ben Benares bench benchmark bend Bendix beneath Benedict Benedictine benediction Benedikt benefactor benefice beneficent beneficial beneficiary benefit Benelux benevolent Bengal Bengali benight benign Benjamin Bennett Bennington Benny Benson bent Bentham benthic Bentley Benton Benz Benzedrine benzene Beograd Beowulf beplaster bequeath bequest berate Berea bereave bereft Berenices Beresford beret berg bergamot Bergen Bergland Berglund Bergman Bergson Bergstrom beribbon beriberi Berkeley berkelium Berkowitz Berkshire Berlin Berlioz Berlitz Berman Bermuda Bern Bernadine Bernard Bernardino Bernardo berne Bernet Bernhard Bernice Bernie Berniece Bernini Bernoulli Bernstein Berra berry berserk Bert berth Bertha Bertie Bertram Bertrand Berwick beryl beryllium beseech beset besetting beside besiege besmirch besotted bespeak bespectacled bespoke Bess Bessel Bessemer Bessie best bestial bestiary bestir bestirring bestow bestowal bestseller bestselling bestubble bet beta betatron betel Betelgeuse beth bethel Bethesda Bethlehem bethought betide betoken betony betray betrayal betroth betrothal Betsey Betsy Bette bettor Betty between betwixt bevel beverage Beverly bevy bewail beware bewhisker bewilder bewitch bey beyond bezel Bhagavadgita bhoy Bhutan Bialystok bianco bias biaxial bib bibb Bible biblical bibliography bibliophile bicameral bicarbonate bicep bichromate bicker biconcave biconnected bicycle bid bidden biddy bide bidiagonal bidirectional bien biennial biennium bifocal bifurcate big bigamy Bigelow Biggs bighorn bigot bigotry biharmonic bijection bijective bijouterie bike bikini bilabial bilateral bilayer Bilbao bile bilge bilharziasis bilinear bilingual bilk bill billboard billet billfold billiard Billie Billiken billion billionth billow billy Biltmore bimetallic bimetallism Bimini bimodal bimolecular bimonthly bin binary binaural bind bindery bindle bindweed bing binge Bingham Binghamton bingle Bini binocular binomial binuclear biochemic biography biology biometry biopsy biota biotic biotite bipartisan bipartite bipedal biplane bipolar biracial birch bird birdbath birdcage birdie birdseed birdwatch birefringent Birgit Birmingham birth birthday birthplace birthrate birthright biscuit bisect bisexual bishop bishopric Bismarck Bismark bismuth bison bisque Bissau bistable bistate bit bitch bite bitnet bitt bitten bittern bitternut bitterroot bittersweet bitumen bituminous bitwise bivalve bivariate bivouac biz bizarre Bizet blab black blackball blackberry blackbird blackboard blackbody Blackburn blacken Blackfeet Blackfoot blackguard blackjack blackmail Blackman blackout blacksmith Blackstone blacktop Blackwell bladder bladdernut bladderwort blade Blaine Blair Blake blame blameworthy blanc blanch Blanchard Blanche bland blandish blank blanket blare blaspheme blasphemous blasphemy blast blastula blat blatant blather Blatz blaze blazon bleach bleak bleary bleat bled bleed Bleeker blemish blend Blenheim bless blest blew blight blimp blind blindfold blink Blinn blip bliss blissful blister blithe blitz blitzkrieg blizzard bloat blob bloc Bloch block blockade blockage blockhouse blocky bloke Blomberg Blomquist blond blonde blood bloodbath bloodhound bloodletting bloodline bloodroot bloodshed bloodshot bloodstain bloodstone bloodstream bloody bloom Bloomfield Bloomington bloop blossom blot blotch blouse blow blowfish blown blowup blubber bludgeon blue blueback blueberry bluebill bluebird bluebonnet bluebook bluebush bluefish bluegill bluegrass bluejacket blueprint bluestocking bluet bluff bluish Blum Blumenthal blunder blunderbuss blunt blur blurb blurry blurt blush bluster blustery blutwurst Blvd Blythe BMW boa boar board boardinghouse boast boastful boat boathouse boatload boatman boatmen boatswain boatyard bob Bobbie bobbin bobble bobby bobcat bobolink Boca bock bode bodhisattva bodice Bodleian body bodybuilder bodybuilding bodyguard Boeing Boeotia bog bogey bogeyman bogeymen bogging boggle boggy Bogota bogus bogy Bohemia Bohr boil Bois Boise boisterous bold boldface bole boletus bolivar Bolivia bolo Bologna bolometer Bolshevik Bolshevism Bolshevist Bolshoi bolster bolt Bolton Boltzmann bomb bombard bombast bombastic Bombay bombproof bon bona bonanza Bonaparte Bonaventure bond bondage bondsman bondsmen bone bonfire bong bongo Boniface bonito Bonn bonnet Bonneville Bonnie bonus bony bonze boo booby boogie book bookbind bookcase bookend bookie bookish bookkeep booklet bookmark bookplate bookseller bookshelf bookshelves bookstore bookworm booky boolean boom boomerang boon Boone boor boorish boost boot Bootes booth bootleg bootlegger bootlegging bootstrap bootstrapping booty booze bop borate borax Bordeaux bordello Borden border borderland borderline bore boreal Borealis Boreas boredom Borg boric Boris born borne Borneo boron borosilicate borough Borroughs borrow Bosch Bose bosom boson bosonic Bosporus boss bossy Boston Boswell botanic botanist botany botch botfly both bothersome Botswana bottle bottlecap bottleneck bottom bottommost botulin botulism Boucher bouffant bough bought bouillabaisse bouillon boulder boulevard bounce bouncy bound boundary bountiful bounty bouquet Bourbaki bourbon bourgeois bourgeoisie bourn boustrophedon bout boutique bovine bow Bowditch Bowdoin bowel Bowen bowerbird bowfin bowie bowl bowline bowman bowmen bowstring box boxcar boxwood boxy boy boyar Boyce boycott Boyd boyish Boyle Boylston BP brace bracelet bracken bracket brackish bract brad Bradbury Bradford Bradley Bradshaw Brady brae brag Bragg bragging Brahmaputra Brahms Brahmsian braid Braille brain Brainard brainchild brainstorm brainwash brainy brake brakeman brakemen bramble bran branch brand Brandeis Brandenburg brandish Brandon Brandt brandy brandywine Braniff brant brash Brasilia brass brassiere brassy bratwurst Braun bravado brave bravery bravo bravura brawl bray brazen brazier Brazil Brazilian Brazzaville breach bread breadboard breadfruit breadroot breadth break breakage breakaway breakdown breakfast breakneck breakoff breakpoint breakthrough breakup breakwater bream breast breastplate breastwork breath breathe breathtaking breathy breccia bred breech breed breeze breezy Bremen bremsstrahlung Brenda Brendan Brennan Brenner Brent Brest brethren Breton Brett breve brevet brevity brew brewery Brewster Brian briar bribe bribery Brice brick brickbat bricklayer bricklaying bridal bride bridegroom bridesmaid bridge bridgeable bridgehead Bridgeport Bridget Bridgetown Bridgewater bridgework bridle Brie brief briefcase brig brigade brigadier brigand brigantine Briggs Brigham bright brighten Brighton brilliant Brillouin brim brimful brimstone Brindisi brindle brine bring brink brinkmanship briny Brisbane brisk bristle bristlecone bristly Bristol Britain Britannic Britannica britches British Briton Brittany Britten brittle broach broad broadcast broaden broadloom broadminded broadside Broadway brocade broccoli brochure Brock brockle Broglie broil broke broken brokerage Bromfield bromide bromine Bromley bronchi bronchial bronchiolar bronchiole bronchitis bronchus bronco Brontosaurus Bronx bronze bronzy brood broody brook Brooke Brookhaven Brookline Brooklyn brookside broom broomcorn broth brothel brother brought brouhaha brow browbeaten brown Browne Brownell Brownian brownie brownish browse Bruce brucellosis Bruckner Bruegel bruise bruit Brumidi brunch brunette Brunhilde Bruno Brunswick brunt brush brushfire brushstroke brushwork brushy brusque Brussels brutal brute Bryan Bryant Bryce Bryn bryophyta bryophyte bryozoa b's BSTJ BTL bub bubble bubonic buccaneer Buchanan Bucharest Buchenwald Buchwald buck buckaroo buckboard bucket bucketful buckeye buckhorn buckle Buckley Bucknell buckshot buckskin buckthorn buckwheat bucolic bud Budapest Budd Buddha Buddhism Buddhist buddy budge budget budgetary Budweiser Buena Buenos buff buffalo buffet bufflehead buffoon bug bugaboo bugeyed bugging buggy bugle Buick build buildup built builtin Bujumbura bulb bulblet bulbous Bulgaria bulge bulk bulkhead bulky bull bulldog bulldoze bullet bulletin bullfinch bullfrog bullhead bullhide bullish bullock bullrush bullseye bullwhack bully bullyboy bulrush bulwark bum bumble bumblebee bump bumpkin bumptious bumpy bun bunch Bundestag bundle Bundoora bundy bungalow bungle bunk bunkmate bunny Bunsen bunt Bunyan buoy buoyant burbank Burch burden burdensome burdock bureau bureaucracy bureaucrat bureaucratic buret burette burg burgeon burgess burgher burglar burglarproof burglary Burgundian Burgundy burial Burke burl burlap burlesque burley Burlington burly Burma Burmese burn Burnett Burnham burnish burnout Burnside burnt burp Burr burro Burroughs burrow bursitis burst bursty Burt Burton Burtt Burundi bury bus busboy Busch bush bushel bushland bushmaster Bushnell bushwhack bushy business businessman businessmen businesswoman businesswomen busload buss bust bustard bustle busy busywork but butadiene butane butch butchery butene buteo butler butt butte butterball buttercup butterfat Butterfield butterfly buttermilk butternut butterscotch buttery buttock button buttonhole buttonweed buttress Buttrick butyl butyrate butyric buxom Buxtehude Buxton buy buzz buzzard buzzing buzzword buzzy by bye bygone bylaw byline bypass bypath byproduct Byrd Byrne byroad Byron Byronic bystander byte byway byword Byzantine Byzantium c CA cab cabal cabana cabaret cabbage cabdriver cabin cabinet cabinetmake cabinetry cable Cabot cacao cachalot cache caching cackle CACM cacophonist cacophonous cacophony cacti cactus cadaver cadaverous caddis caddy cadent cadenza cadet Cadillac cadmium cadre Cady Caesar Caesarian cafe cafeteria cage cagey Cahill cahoot caiman Cain Caine cairn Cairo cajole Cajun cake Cal calabash Calais calamitous calamity calamus calcareous calcify calcite calcium calculable calculate calculi calculus Calcutta Calder caldera Caldwell Caleb calendar calendrical calf calfskin Calgary Calhoun caliber calibrate calibre calico California californium caliper caliph caliphate calisthenic Calkins call calla Callaghan Callahan calligraph calligraphy calliope Callisto callosity callous callus calm caloric calorie calorimeter Calumet calumniate calumny Calvary calve Calvert Calvin calypso calyx cam camaraderie camber Cambodia Cambrian cambric Cambridge Camden came camel camelback camellia camelopard Camelot Camembert cameo camera cameraman cameramen Cameron Cameroon Cameroun camilla Camille Camino camouflage camp campaign campanile Campbell campfire campground campion campsite campus can Canaan Canada Canadian canal canary Canaveral Canberra cancel cancellate cancelled cancelling cancer cancerous candela candelabra candid candidacy candidate Candide candle candlelight candlestick candlewick candy cane Canfield canine Canis canister canker cankerworm canna cannabis cannel cannery cannibal cannister cannon cannonball cannot canny canoe canoeist Canoga canon canonic Canopus canopy can't cant Cantabrigian cantaloupe canteen Canterbury canterelle canticle cantilever cantle canto canton Cantonese cantor canvas canvasback canvass canyon cap capacious capacitance capacitate capacitive capacitor capacity cape capella caper Capetown capillary Capistrano capita capital capitol Capitoline capitulate capo caprice capricious Capricorn capsize capstan capstone capsule captain captaincy caption captious captivate captive captor capture capuchin Caputo capybara car carabao Caracas caramel carapace caravan caraway carbide carbine carbohydrate Carboloy carbon carbonaceous carbonate Carbondale Carbone carbonic Carboniferous carbonium carbonyl carborundum carboxy carboxylic carboy carbuncle carcass carcinogen carcinogenic carcinoma card cardamom cardboard cardiac Cardiff cardigan cardinal cardioid cardiology cardiovascular care careen career carefree careful caress caret caretaker careworn Carey Cargill cargo cargoes Carib Caribbean caribou caricature Carl Carla Carleton Carlin Carlisle Carlo carload Carlsbad Carlson Carlton Carlyle Carmela Carmen Carmichael carmine carnage carnal carnation carne Carnegie carney carnival carob carol Carolina Caroline Carolingian Carolinian Carolyn carouse carousel carp carpal Carpathia carpenter carpentry carpet carpetbag carpetbagger carpetbagging carport Carr carrageen Carrara carrel carriage Carrie carrion Carroll carrot Carruthers carry carryover Carson cart carte cartel Cartesian Carthage cartilage cartilaginous cartographer cartography carton cartoon cartridge cartwheel Caruso carve carven Casanova casbah cascade cascara case casebook casein casework Casey cash cashew cashier cashmere casino cask casket Cassandra cassava casserole cassette Cassiopeia Cassius cassock cast castanet caste casteth castigate Castillo castle castor castrate Castro casual casualty cat cataclysmic cataleptic Catalina catalogue Catalonia catalpa catalysis catalyst catalytic catapult cataract catastrophe catastrophic catatonia catatonic catawba catbird catch catchup catchword catchy catechism categoric category catenate cater caterpillar catfish catharsis cathedral Catherine Catherwood catheter cathode cathodic catholic Cathy cation cationic catkin catnip Catskill catsup cattail cattle cattleman cattlemen catwalk Caucasian Caucasus Cauchy caucus caudal caught cauliflower caulk causal causate cause caustic caution cautionary cautious cavalcade cavalier cavalry cave caveat caveman cavemen Cavendish cavern cavernous caviar cavil cavilling Caviness cavort caw cayenne Cayley Cayuga CBS CDC cease ceasefire Cecil Cecilia Cecropia cedar cede cedilla Cedric ceil celandine Celanese Celebes celebrant celebrate celebratory celebrity celerity celery celesta celestial Celia cell cellar cellophane cellular celluloid cellulose Celsius Celt Celtic cement cemetery Cenozoic censor censorial censure census cent centaur centenary centennial centerline centerpiece centigrade centipede central centrex centric centrifugal centrifugate centrifuge centripetal centrist centroid centum century Cepheus ceramic ceramium Cerberus cereal cerebellum cerebral cerebrate ceremonial ceremonious ceremony Ceres cereus cerise cerium CERN certain certainty certificate certify certiorari certitude cerulean Cervantes cervix Cesare cesium cessation cession Cessna cetacean cetera Cetus Ceylon Cezanne cf Chablis Chad Chadwick chafe chaff chagrin chain chair chairlady chairman chairmen chairperson chairwoman chairwomen chaise chalcedony chalcocite chalice chalk chalkline chalky challenge Chalmers chamber chamberlain chambermaid chameleon chamfer chamois chamomile champ champagne Champaign champion Champlain chance chancel chancellor chancery chancy chandelier Chandigarh chandler Chang change changeable changeover channel chanson chant chantey Chantilly chantry Chao chaos chaotic chap chaparral chapati chapel chaperon chaperone chaplain Chaplin Chapman chapter char character characteristic charcoal charcuterie chard charge chargeable chariot charisma charismatic charitable charity Charlemagne Charles Charleston Charley Charlie Charlotte Charlottesville charm Charon chart Charta Chartres chartreuse chartroom Charybdis chase chasm chassis chaste chastise chastity chat chateau chateaux Chatham Chattanooga chattel chatty Chaucer chauffeur Chauncey Chautauqua chauvinism chauvinist chaw cheap cheat cheater check checkbook checkerberry checkerboard checklist checkout checkpoint checksum checksummed checksumming checkup Cheddar cheek cheekbone cheeky cheer cheerful cheerleader cheery cheese cheesecake cheesecloth cheesemaking cheesy cheetah chef chelate Chelsea chemic chemise chemisorb chemisorption chemist chemistry chemotherapy Chen Cheney chenille cherish Cherokee cherry chert cherub cherubim Cheryl Chesapeake Cheshire chess chest Chester Chesterton chestnut chevalier Chevrolet chevron chevy chew chewy Cheyenne chi Chiang chianti chic Chicago Chicagoan chicanery Chicano chick chickadee chicken chickpea chickweed chicory chide chief chiefdom chieftain chiffon chigger chignon chilblain child childbearing childbirth childish childrearing children Chile chili chill chilly chime chimera chimeric Chimique chimney chimpanzee chin china Chinaman Chinamen Chinatown chinch chinchilla chine Chinese chink Chinook chinquapin chintz chintzy chip chipboard chipmunk Chippendale chiropractor chirp chisel Chisholm chit chitin chitinous chiton chivalrous chivalry chive Chloe chlorate chlordane chloride chlorine chloroform chlorophyll chloroplast chloroplatinate chock chocolate Choctaw choice choir choirmaster choke chokeberry cholera cholesterol choline cholinesterase chomp Chomsky chondrite choose choosy chop Chopin choppy chopstick choral chorale chord chordal chordata chordate chore choreograph choreography chorine chortle chorus choryza chose chosen Chou chow chowder Chris Christ christen Christendom Christensen Christenson Christian Christiana Christianson Christie Christina Christine Christmas Christoffel Christoph Christopher Christy chromate chromatic chromatin chromatogram chromatograph chromatography chrome chromic chromium chromosomal chromosome chromosphere chronic chronicle chronograph chronography chronology chrysalis chrysanthemum Chrysler chrysolite chub chubby chuck chuckle chuckwalla chuff chug chugging chum chummy chump Chungking chunk chunky church churchgoer churchgoing Churchill Churchillian churchman churchmen churchwoman churchwomen churchyard churn chute chutney CIA cicada Cicero Ciceronian cider cigar cigarette cilia ciliate cinch Cincinnati cinder Cinderella Cindy cinema cinematic Cinerama cinnabar cinnamon cinquefoil cipher circa circadian Circe circle circlet circuit circuitous circuitry circulant circular circulate circulatory circumcircle circumcise circumcision circumference circumferential circumflex circumlocution circumpolar circumscribe circumscription circumspect circumsphere circumstance circumstantial circumvent circumvention circus cistern cit citadel citation cite citizen citizenry citrate citric Citroen citron citrus city cityscape citywide civet civic civil civilian clad cladophora claim claimant Claire clairvoyant clam clamber clammy clamp clamshell clan clandestine clang clank clannish clap clapboard Clapeyron Clara Clare Claremont Clarence Clarendon claret clarify clarinet clarity Clark Clarke clash clasp class classic classificatory classify classmate classroom classy clatter clattery Claude Claudia Claudio Claus clause Clausen Clausius claustrophobia claustrophobic clavicle claw clay Clayton clean cleanse cleanup clear clearance clearheaded Clearwater cleat cleavage cleave clef cleft Clemens clement Clemson clench clergy clergyman clergymen cleric clerk Cleveland clever cliche click client clientele cliff cliffhang Clifford Clifton climactic climate climatic climatology climax climb clime clinch cling clinic clinician clink Clint Clinton Clio clip clipboard clique clitoris Clive cloaca cloacal cloak cloakroom clobber clock clockwatcher clockwise clockwork clod cloddish clog clogging cloister clomp clone clonic close closet closeup closure clot cloth clothbound clothe clothesbrush clotheshorse clothesline clothesman clothesmen clothier Clotho cloture cloud cloudburst cloudy clout clove clown clownish cloy club clubhouse clubroom cluck clue Cluj clump clumsy clung cluster clutch clutter Clyde Clytemnestra CO co coach coachman coachmen coachwork coadjutor coagulable coagulate coal coalesce coalescent coalition coarse coarsen coast coastal coastline coat Coates coattail coauthor coax coaxial cob cobalt Cobb cobble cobblestone Cobol cobra cobweb coca cocaine coccidiosis cochineal cochlea Cochran Cochrane cock cockatoo cockcrow cockeye cockfight cockle cocklebur cockleshell cockpit cockroach cocksure cocktail cocky coco cocoa coconut cocoon cod coda Coddington coddle code codebreak codeposit codetermine codeword codex codfish codicil codify codomain codon codpiece Cody coed coeditor coeducation coefficient coequal coerce coercible coercion coercive coevolution coexist coexistent coextensive cofactor coffee coffeecup coffeepot coffer Coffey coffin Coffman cog cogent cogitate cognac cognate cognition cognitive cognoscenti Cohen cohere coherent cohesion cohesive Cohn cohomology cohort cohosh coiffure coil coin coinage coincide coincident coincidental coke col cola colander colatitude Colby cold coldhearted Cole Coleman Coleridge Colette coleus Colgate colic colicky coliform coliseum collaborate collage collagen collapse collapsible collar collarbone collard collate collateral colleague collect collectible collector college collegian collegiate collet collide collie Collier collimate collinear Collins collision collocate colloidal Colloq colloquia colloquial colloquium colloquy collude collusion cologne Colombia Colombo colon colonel colonial colonist colonnade colony Colorado colorate coloratura colorimeter colossal Colosseum colossi colossus colt coltish coltsfoot Columbia columbine Columbus column columnar colza coma Comanche comatose comb combat combatant combatted combinate combinatorial combinatoric combine combustible combustion come comeback comedian comedy comestible comet cometary cometh comfort comic Cominform comma command commandant commandeer commando commemorate commend commendation commendatory commensal commensurable commensurate comment commentary commentator commerce commercial commingle commiserate commissariat commissary commission commit committable committal committed committee committeeman committeemen committeewoman committeewomen committing commodious commodity commodore common commonality commonplace commonweal commonwealth commotion communal commune communicable communicant communicate communion communique commutate commute compact compactify Compagnie companion companionway company comparative comparator compare comparison compartment compass compassion compassionate compatible compatriot compel compellable compelled compelling compendia compendium compensable compensate compensatory compete competent competition competitive competitor compilation compile complacent complain complainant complaint complaisant complement complementarity complementary complementation complete completion complex complexion compliant complicate complicity compliment complimentary compline comply component componentry comport compose composite composition compositor compost composure compote compound comprehend comprehensible comprehension comprehensive compress compressible compression compressive compressor comprise compromise Compton comptroller compulsion compulsive compulsory compunction computation compute comrade con Conakry Conant concatenate concave conceal concede conceit conceive concentrate concentric concept conception conceptual concern concert concerti concertina concertmaster concerto concession concessionaire conch concierge conciliate conciliatory concise concision conclave conclude conclusion conclusive concoct concomitant concord concordant concourse concrete concretion concubine concur concurred concurrent concurring concussion condemn condemnate condemnatory condensate condense condensible condescend condescension condiment condition condolence condominium condone conduce conducive conduct conductance conductor conduit cone coneflower Conestoga coney confabulate confect confectionery confederacy confederate confer conferee conference conferrable conferred conferring confess confession confessor confidant confidante confide confident confidential configuration configure confine confirm confirmation confirmatory confiscable confiscate confiscatory conflagrate conflict confluent confocal conform conformal conformance conformation confound confrere confront confrontation Confucian Confucius confuse confusion confute congeal congener congenial congenital congest congestion congestive conglomerate Congo Congolese congratulate congratulatory congregate congress congressional congressman congressmen congresswoman congresswomen congruent conic conifer coniferous conjectural conjecture conjoin conjoint conjugacy conjugal conjugate conjunct conjuncture conjure Conklin Conley conn Connally connect Connecticut connector Conner Connie connivance connive connoisseur Connors connotation connotative connote connubial conquer conqueror conquest conquistador Conrad Conrail consanguine consanguineous conscience conscientious conscionable conscious conscript conscription consecrate consecutive consensus consent consequent consequential conservation conservatism conservative conservator conservatory conserve consider considerate consign consignee consignor consist consistent consolation console consolidate consonant consonantal consort consortium conspecific conspicuous conspiracy conspirator conspiratorial conspire constant Constantine Constantinople constellate consternate constipate constituent constitute constitution constitutive constrain constraint constrict constrictor construal construct constructible constructor construe consul consular consulate consult consultant consultation consultative consume consummate consumption consumptive contact contagion contagious contain contaminant contaminate contemplate contemporaneous contemporary contempt contemptible contemptuous contend content contention contentious contest contestant context contextual contiguity contiguous continent continental contingent continua continual continuant continuation continue continuity continuo continuous continuum contort contour contraband contrabass contraception contraceptive contract contractor contractual contradict contradictory contradistinct contradistinguish contraindicate contralateral contralto contrapositive contraption contrariety contrary contrast contravariant contravene contravention contretemps contribute contribution contributor contributory contrite contrition contrivance contrive control controllable controlled controller controlling controversial controversy controvertible contumacy contusion conundrum Convair convalesce convalescent convect convene convenient convent convention converge convergent conversant conversation converse conversion convert convertible convex convey conveyance conveyor convict convince convivial convocate convoke convolute convolution convolve convoy convulse convulsion convulsive Conway cony coo cook cookbook Cooke cookery cookie cooky cool coolant Cooley coolheaded Coolidge coon coop cooperate coordinate Coors coot cop cope Copeland Copenhagen Copernican Copernicus copious coplanar copolymer copperas Copperfield copperhead coppery copra coprinus coprocessor coproduct copter copulate copy copybook copyright copywriter coquette coquina coral coralberry coralline corbel Corbett Corcoran cord cordage cordial cordite cordon corduroy core Corey coriander Corinth Corinthian Coriolanus cork corkscrew cormorant corn cornbread cornea Cornelia Cornelius Cornell cornerstone cornet cornfield cornflower cornish cornmeal cornstarch cornucopia Cornwall corny corolla corollary corona Coronado coronary coronate coroner coronet coroutine Corp corpora corporal corporate corporeal corps corpse corpsman corpsmen corpulent corpus corpuscle corpuscular corral corralled correct corrector correlate correspond correspondent corridor corrigenda corrigendum corrigible corroborate corroboree corrode corrodible corrosion corrosive corrugate corrupt corruptible corruption corsage corset Corsica cortege cortex Cortez cortical Cortland corundum coruscate Corvallis corvette Corvus cos cosec coset Cosgrove cosh cosine cosmetic cosmic cosmology cosmopolitan cosmos cosponsor Cossack cost Costa Costello costume cosy cot cotangent coterie cotillion cotman cotoneaster cotta cottage cotton cottonmouth cottonseed cottontail cottonwood cottony Cottrell cotty cotyledon couch cougar cough could couldn't coulomb Coulter council councilman councilmen councilwoman councilwomen counsel counselor count countdown countenance counteract counterargument counterattack counterbalance counterclockwise counterexample counterfeit counterflow counterintuitive counterman countermand countermeasure countermen counterpart counterpoint counterpoise counterproductive counterproposal counterrevolution counterrevolutionary countersink countersunk counterthreat countervail counterweight countrify country countryman countrymen countryside countrywide county countywide coup coupe couple couplet coupon courage courageous courier course court courteous courtesan courtesy courthouse courtier Courtney courtroom courtyard couscous cousin couturier covalent covariant covariate covary cove coven covenant Coventry cover coverage coverall coverlet covert covet covetous cow Cowan coward cowardice cowbell cowbird cowboy cowhand cowherd cowhide cowl cowlick cowman cowmen coworker cowpea cowpoke cowpony cowpox cowpunch cowry cowslip cox coxcomb coy coyly coyote coypu cozen cozy CPA cpu crab crabapple crack crackle crackpot cradle craft craftsman craftsmen craftspeople craftsperson crafty crag craggy Craig cram Cramer cramp crampon cranberry Crandall crane Cranford crania cranium crank crankcase crankshaft cranky cranny Cranston crap crappie crash crass crate crater cravat crave craven craw Crawford crawl crawlspace crayfish crayon craze crazy creak creaky cream creamery creamy crease create creature creche credent credential credenza credible credit creditor credo credulity credulous creed creedal creek creekside creep creepy cremate crematory Creole Creon creosote crepe crept crescendo crescent cress crest crestfallen Crestview Cretaceous Cretan Crete cretin cretinous crevice crew crewcut crewel crewman crewmen crib cribbage cricket crime Crimea criminal crimp crimson cringe crinkle crinoid cripple crises crisis crisp Crispin criss crisscross criteria criterion critic critique critter croak Croatia crochet crock crockery Crockett crocodile crocodilian crocus croft Croix Cromwell Cromwellian crone crony crook croon crop cropland crore Crosby cross crossarm crossbar crossbill crosscut crosshatch crosslink crossover crosspoint crossroad crosstalk crosswalk crossway crosswise crossword crosswort crotch crotchety crouch croupier crow crowbait crowbar crowberry crowd crowfoot Crowley crown croydon CRT crucial crucible crucifix crucifixion crucify crud cruddy crude cruel cruelty Cruickshank cruise crumb crumble crummy crump crumple crunch crunchy crupper crusade crush Crusoe crust crustacean crusty crutch crux Cruz cry cryogenic cryostat crypt cryptanalysis cryptanalyst cryptanalytic cryptic crypto cryptogram cryptographer cryptography crystal crystalline crystallite crystallographer crystallography c's csnet CT cub Cuba cubby cubbyhole cube cubic cubicle cubit cuckoo cucumber cud cuddle cuddly cudgel cue cuff cufflink cuisine Culbertson culinary cull culminate culpa culpable culprit cult cultivable cultivar cultivate cultural culture Culver culvert Cumberland cumbersome cumin Cummings Cummins cumulate cumulus Cunard cuneiform cunning Cunningham CUNY cup cupboard cupful Cupid cupidity cupric cuprous cur curate curb curbside curd curdle cure curfew curia curie curio curiosity curious curium curl curlew curlicue curmudgeon Curran currant current curricula curricular curriculum curry curse cursive cursor cursory curt curtail curtain Curtis curtsey curvaceous curvature curve curvilinear Cushing cushion Cushman cusp Custer custodial custodian custody custom customary customhouse cut cutaneous cutback cute cutlass cutler cutlet cutoff cutout cutover cutset cutthroat cuttlebone cuttlefish cutworm Cuvier Cuzco Cyanamid cyanate cyanic cyanide cybernetic cycad Cyclades cycle cyclic cyclist cyclone cyclopean Cyclops cyclorama cyclotomic cyclotron cygnet Cygnus cylinder cylindric cymbal cynic Cynthia cypress Cyprian Cypriot Cyprus Cyril Cyrillic Cyrus cyst cysteine cytochemistry cytolysis cytoplasm cytosine CZ czar czarina Czech Czechoslovakia Czerniak d dab dabble Dacca dachshund dactyl dactylic dad Dada daddy Dade Daedalus daemon daffodil daffy dagger daguerreotype Dahl dahlia Dahomey Dailey Daimler dainty dairy Dairylea dairyman dairymen dais daisy Dakar Dakota dal dale Daley Dalhousie Dallas dally Dalton Daly Dalzell dam damage Damascus damask dame damn damnation Damocles Damon damp dampen damsel damselfly Dan Dana Danbury dance dandelion dandy Dane dang danger dangerous dangle Daniel Danielson Danish dank Danny Dante Danube Danubian Danzig Daphne dapper dapple Dar dare Darius dark darken darkle Darlene darling darn DARPA Darrell Darry d'art dart Dartmouth Darwin Darwinian dash dashboard dastard data database date dateline dater Datsun datum datura daub Daugherty daughter daunt dauphin dauphine Dave davenport David Davidson Davies Davis Davison davit Davy dawdle dawn Dawson day daybed daybreak daydream daylight daytime Dayton Daytona daze dazzle DC de deacon deaconess deactivate dead deaden deadhead deadline deadlock deadwood deaf deafen deal deallocate dealt dean Deane Deanna dear Dearborn dearie dearth death deathbed deathward debacle debar debarring debase debate debater debauch debauchery Debbie Debby debenture debilitate debility debit debonair Deborah Debra debrief debris debt debtor debug debugged debugger debugging debunk Debussy debut debutante Dec decade decadent decal decant decapitate decapod decathlon Decatur decay Decca decease decedent deceit deceitful deceive decelerate December decennial decent deception deceptive decertify decibel decide deciduous decile decimal decimate decipher decision decisive deck declaim declamation declamatory declaration declarative declarator declaratory declare declassify declination decline declivity decode decolletage decollimate decompile decomposable decompose decomposition decompress decompression decontrol decontrolled decontrolling deconvolution deconvolve decor decorate decorous decorticate decorum decouple decoy decrease decree decreeing decrement decry decrypt decryption dedicate deduce deducible deduct deductible Dee deed deem deep deepen deer Deere deerskin deerstalker deface default defeat defecate defect defector defend defendant defensible defensive defer deferent deferrable deferred deferring defiant deficient deficit define definite definition definitive deflate deflater deflect deflector defocus defoliate deforest deforestation deform deformation defraud defray defrost deft defunct defy degas degassing degeneracy degenerate degradation degrade degrease degree degum degumming dehumidify dehydrate deify deign Deimos Deirdre deity deja deject Del Delaney Delano Delaware delay delectable delectate delegable delegate delete deleterious deletion Delft Delhi Delia deliberate delicacy delicate delicatessen delicious delicti delight delightful Delilah delimit delimitation delineament delineate delinquent deliquesce deliquescent delirious delirium deliver deliverance delivery deliveryman deliverymen dell Della Delmarva delouse Delphi Delphic delphine delphinium Delphinus delta deltoid delude deluge delusion delusive deluxe delve demagnify demagogue demand demarcate demark demean demented dementia demerit Demeter demi demigod demijohn demiscible demise demit demitted demitting democracy democrat democratic demodulate demographer demography demolish demolition demon demoniac demonic demonstrable demonstrate demote demountable Dempsey demultiplex demur demure demurred demurrer demurring demystify den denature dendrite dendritic Deneb Denebola deniable denial denigrate denizen Denmark Dennis Denny denominate denotation denotative denote denouement denounce dense densitometer dent dental dentistry dentition Denton denture denudation denude denumerable denunciate Denver deny deodorant deoxyribonucleic deoxyribose depart departure depend dependent depict deplane deplete depletion deplore deploy deport deportation deportee depose deposit depositary deposition depositor depository depot deprave deprecate deprecatory depreciable depreciate depredation depress depressant depressible depression depressive depressor deprivation deprive depth deputation depute deputy derail derange derate derby Derbyshire dereference deregulate Derek derelict deride derision derisive derivate derive dermatology derogate derogatory derrick derriere dervish Des descant Descartes descend descendant descendent descent describe description descriptive descriptor desecrate desecrater desegregate desert deserve desiccant desiccate desiderata desideratum design designate desire desirous desist desk Desmond desolate desolater desorption despair desperado desperate despicable despise despite despoil despond despondent despot despotic dessert destinate destine destiny destitute destroy destruct destructor desuetude desultory detach detail detain d'etat detect detector detent detente detention deter detergent deteriorate determinacy determinant determinate determine deterred deterrent deterring detest detestation detonable detonate detour detoxify detract detractor detriment detritus Detroit deuce deus deuterate deuterium deuteron devastate develop deviant deviate device devil devilish devious devise devisee devoid devolve Devon Devonshire devote devotee devotion devour devout dew dewar dewdrop Dewey Dewitt dewy dexter dexterity dextrose dextrous dey Dhabi dharma diabase diabetes diabetic diabolic diachronic diacritic diadem diagnosable diagnose diagnosis diagnostic diagnostician diagonal diagram diagrammatic diagrammed diagramming dial dialect dialectic dialogue dialup dialysis diamagnetic diamagnetism diameter diamond Diana Diane Dianne diaper diaphanous diaphragm diary diathermy diathesis diatom diatomaceous diatomic diatonic diatribe dibble dice dichloride dichondra dichotomy dick dickcissel dickens Dickerson dickey Dickinson Dickson dicotyledon dicta dictate dictatorial diction dictionary dictum did didactic diddle didn't Dido die Diebold Diego diehard dieldrin dielectric diem dieresis diesel diet dietary dietetic diethylstilbestrol dietician Dietrich diety Dietz diffeomorphic diffeomorphism differ different differentiable differential differentiate difficult difficulty diffident diffract diffractometer diffuse diffusible diffusion diffusive difluoride dig digamma digest digestible digestion digestive digging digit digital digitalis dignify dignitary dignity digram digress digression dihedral dilapidate dilatation dilate dilatory dilemma dilettante diligent dill Dillon dilogarithm diluent dilute dilution dim dime dimension dimethyl diminish diminuendo diminution diminutive dimorphic dimorphism dimple din Dinah dine ding dinghy dingo dingy dinnertime dinnerware dinosaur dint diocesan diocese Diocletian diode Diogenes Dionysian Dionysus Diophantine diopter diorama diorite dioxide dip diphtheria diphthong diploid diploidy diploma diplomacy diplomat diplomatic dipole Dirac dire direct director directorate directory directrices directrix dirge Dirichlet dirt dirty Dis disaccharide disambiguate disastrous disburse disc discern discernible disciple disciplinary discipline discoid discomfit discordant discovery discreet discrepant discrete discretion discretionary discriminable discriminant discriminate discriminatory discus discuss discussant discussion disdain disdainful disembowel disgruntle disgustful dish dishevel dishwasher dishwater disjunct disk dismal dismissal Disney Disneyland disparage disparate dispel dispelled dispelling dispensable dispensary dispensate dispense dispersal disperse dispersible dispersion dispersive disposable disposal disputant dispute disquietude disquisition disrupt disruption disruptive dissemble disseminate dissension dissertation dissident dissipate dissociate dissuade distaff distal distant distillate distillery distinct distinguish distort distraught distribution distributive distributor district disturb disturbance disulfide disyllable ditch dither ditto ditty diurnal diva divalent divan dive diverge divergent diverse diversify diversion diversionary divert divest divestiture divide dividend divination divine divisible division divisive divisor divorce divorcee divulge Dixie dixieland Dixon dizzy Djakarta DNA Dnieper do Dobbin Dobbs doberman dobson docile dock docket dockside dockyard doctor doctoral doctorate doctrinaire doctrinal doctrine document documentary documentation DOD Dodd doddering dodecahedra dodecahedral dodecahedron dodge dodo Dodson doe doesn't d'oeuvre doff dog dogbane dogberry Doge dogfish dogging doggone doghouse dogleg dogma dogmatic dogmatism dogmatist dogtooth dogtrot dogwood Doherty Dolan dolce doldrum dole doleful doll dollar dollop dolly dolomite dolomitic Dolores dolphin dolt doltish domain dome Domenico Domesday domestic domesticate domicile dominant dominate domineer Domingo Dominic Dominican Dominick dominion Dominique domino don Donahue Donald Donaldson donate done Doneck donkey Donna Donnelly Donner donnybrook donor Donovan don't doodle Dooley Doolittle doom doomsday door doorbell doorkeep doorkeeper doorknob doorman doormen doorstep doorway dopant dope Doppler Dora Dorado Dorcas Dorchester Doreen Doria Doric Doris dormant dormitory dormouse Dorothea Dorothy dorsal Dorset Dortmund dosage dose dosimeter dossier Dostoevsky dot dote double Doubleday doubleheader doublet doubleton doubloon doubt doubtful douce Doug dough Dougherty doughnut Douglas Douglass dour douse dove dovekie dovetail Dow dowager dowel dowitcher Dowling down downbeat downcast downdraft Downey downfall downgrade downhill downplay downpour downright downside downslope downspout downstairs downstream downtown downtrend downtrodden downturn downward downwind downy dowry Doyle doze dozen Dr drab drably Draco Draconian draft draftee draftsman draftsmen draftsperson drafty drag dragging dragnet dragon dragonfly dragonhead dragoon drain drainage drake dram drama dramatic dramatist dramaturgy drank drape drapery drastic draught Dravidian draw drawback drawbridge drawl drawn drawstring drayman dread dreadful dreadnought dream dreamboat dreamt dreamy dreary dredge dreg drench dress dressmake dressy drew Drexel Dreyfuss drib dribble drift driftwood drill drink drip drippy Driscoll drive driven driveway drizzle drizzly droll dromedary drone drool droop droopy drop drophead droplet dropout drosophila dross drought drove drown drowse drowsy drub drudge drudgery drug drugging drugstore druid drum drumhead drumlin Drummond drunk drunkard drunken drupe Drury dry dryad Dryden d's du dual Duane dub Dubhe dubious dubitable Dublin ducat duchess duck duckbilled duckling duckweed duct ductile ductwork dud Dudley due duel duet duff duffel Duffy dug Dugan dugong dugout duke dulcet dull dully dulse Duluth duly Duma dumb dumbbell dumbly dummy dump dumpling dumpster Dumpty dumpy dun Dunbar Duncan dunce dune Dunedin dung dungeon Dunham dunk Dunkirk Dunlap Dunlop Dunn duodenal duodenum duopolist duopoly dupe duplex duplicable duplicate duplicity DuPont Duquesne durable durance Durango duration Durer duress Durham during Durkee Durkin Durrell Durward Dusenberg Dusenbury dusk dusky Dusseldorf dust dustbin dusty Dutch dutchess Dutchman Dutchmen dutiable dutiful Dutton duty dwarf dwarves dwell dwelt Dwight dwindle Dwyer dyad dyadic dye dyeing dyestuff dying Dyke Dylan dynamic dynamism dynamite dynamo dynast dynastic dynasty dyne dysentery dyspeptic dysplasia dysprosium dystrophy e each Eagan eager eagle ear eardrum earl earmark earn earnest earphone earring earshot earsplitting earth earthen earthenware Earthman Earthmen earthmover earthmoving earthquake earthworm earthy earwig ease easel east eastbound eastern easternmost Eastland Eastman eastward Eastwood easy easygoing eat eaten eater Eaton eave eavesdrop eavesdropping ebb Eben ebony ebullient eccentric Eccles ecclesiastic echelon echidna echinoderm echo echoes echolocation eclat eclectic eclipse ecliptic eclogue Ecole ecology econometric economic economist economy ecosystem ecstasy ecstatic ectoderm ectopic Ecuador ecumenic ecumenist Ed Eddie eddy edelweiss edematous Eden Edgar edge Edgerton edgewise edgy edible edict edifice edify Edinburgh Edison edit Edith edition editor editorial Edmonds Edmondson Edmonton Edmund Edna EDT Eduardo educable educate Edward Edwardian Edwardine Edwin Edwina eel eelgrass EEOC e'er eerie eerily efface effaceable effect effectual effectuate effeminate efferent effete efficacious efficacy efficient Effie effloresce efflorescent effluent effluvia effluvium effort effusion effusive eft e.g egalitarian Egan egg egghead eggplant eggshell ego egocentric egotism egotist egregious egress egret Egypt Egyptian Egyptology eh Ehrlich eider eidetic eigenfunction eigenspace eigenstate eigenvalue eigenvector eight eighteen eighteenth eightfold eighth eightieth eighty eightyfold Eileen Einstein Einsteinian einsteinium Eire Eisenhower Eisner either ejaculate eject ejector eke Ekstrom Ektachrome el elaborate Elaine elan elapse elastic elastomer elate Elba elbow elder eldest Eldon Eleanor Eleazar elect elector electoral electorate Electra electress electret electric electrician electrify electro electrocardiogram electrocardiograph electrode electroencephalogram electroencephalograph electroencephalography electrolysis electrolyte electrolytic electron electronic electrophoresis electrophorus elegant elegiac elegy element elementary Elena elephant elephantine elevate eleven elevenfold eleventh elfin Elgin Eli elicit elide eligible Elijah eliminable eliminate Elinor Eliot Elisabeth Elisha elision elite Elizabeth Elizabethan elk Elkhart ell Ella Ellen Elliot Elliott ellipse ellipsis ellipsoid ellipsoidal ellipsometer elliptic Ellis Ellison Ellsworth Ellwood elm Elmer Elmhurst Elmira Elmsford Eloise elongate elope eloquent else Elsevier elsewhere Elsie Elsinore Elton eluate elucidate elude elusive elute elution elver elves Ely Elysee elysian em emaciate emacs emanate emancipate Emanuel emasculate embalm embank embarcadero embargo embargoes embark embarrass embassy embattle embed embeddable embedded embedder embedding embellish ember embezzle embitter emblazon emblem emblematic embodiment embody embolden emboss embouchure embower embrace embraceable embrittle embroider embroidery embroil embryo embryology embryonic emcee emendable emerald emerge emergent emeriti emeritus Emerson Emery emetic emigrant emigrate emigre emigree Emil Emile Emilio Emily eminent emirate emissary emission emissive emit emittance emitted emitter emitting emma Emmanuel Emmett emolument Emory emotion empathic empathy emperor emphases emphasis emphatic emphysema emphysematous empire empiric emplace employ employee emporium empower empress empty emptyhanded emulate emulsify emulsion en enamel encapsulate encephalitis enchantress enclave encomia encomium encore encroach encryption encumber encumbrance encyclopedic end endemic endgame Endicott endoderm endogamous endogamy endogenous endometrial endometriosis endomorphism endorse endosperm endothelial endothermic endow endpoint endure enemy energetic energy enervate enfant enforceable enforcible Eng engage Engel engine engineer England Englander Engle Englewood English Englishman Englishmen enhance Enid enigma enigmatic enjoinder enlargeable enmity Enoch enol enormity enormous Enos enough enquire enquiry Enrico enrollee ensconce ensemble enstatite entendre enter enterprise entertain enthalpy enthusiasm enthusiast enthusiastic entice entire entirety entity entomology entourage entranceway entrant entrepreneur entrepreneurial entropy entry enumerable enumerate enunciable enunciate envelop envelope enviable envious environ envoy envy enzymatic enzyme enzymology Eocene eohippus eosine EPA epaulet ephemeral ephemerides ephemeris Ephesian Ephesus Ephraim epic epicure Epicurean epicycle epicyclic epidemic epidemiology epidermic epidermis epigenetic epigram epigrammatic epigraph epilepsy epileptic epilogue epimorphism Epiphany epiphany epiphyseal epiphysis epiphyte epiphytic episcopal Episcopalian episcopate episode episodic epistemology epistle epistolatory epitaph epitaxial epitaxy epithelial epithelium epithet epitome epoch epochal eponymous epoxy epsilon Epsom Epstein equable equal equanimity equate equatorial equestrian equidistant equilateral equilibrate equilibria equilibrium equine equinoctial equinox equip equipoise equipotent equipped equipping equitable equitation equity equivalent equivocal equivocate era eradicable eradicate erasable erase Erasmus Erastus erasure Erato Eratosthenes erbium ERDA ere erect erg ergative ergodic Eric Erich Erickson Ericsson Erie Erik Erlenmeyer ermine Ernest Ernestine Ernie Ernst erode erodible Eros erosible erosion erosive erotic erotica err errand errant errantry errata erratic erratum Errol erroneous error ersatz Erskine erudite erudition erupt eruption Ervin Erwin e's escadrille escalate escapade escape escapee escarpment escheat Escherichia eschew escort escritoire escrow escutcheon Eskimo Esmark esophagi esoteric especial espionage esplanade Esposito espousal espouse esprit esquire essay Essen essence essential Essex EST establish estate esteem Estella ester Estes Esther estimable estimate Estonia estop estoppal estrange estrogen estrous estrus estuarine estuary et eta etc etch eternal eternity Ethan ethane ethanol Ethel ether ethereal ethernet ethic Ethiopia ethnic ethnography ethnology ethnomusicology ethology ethos ethyl ethylene etiology etiquette Etruria Etruscan etude etymology eucalyptus Eucharist Euclid Euclidean eucre Eugene Eugenia eugenic euglena eukaryote eukaryotic Euler Eulerian eulogy Eumenides Eunice euphemism euphemist euphonious euphony euphorbia euphoria euphoric Euphrates Eurasia eureka Euridyce Euripides Europa Europe European europium Eurydice eutectic Euterpe euthanasia eutrophication Eva evacuate evade evaluable evaluate evanescent evangel evangelic Evans Evanston Evansville evaporate evasion evasive eve Evelyn even evenhanded evensong event eventful eventide eventual eventuate Eveready Everett Everglade evergreen Everhart everlasting every everybody everyday everyman everyone everything everywhere evict evident evidential evil evildoer evince eviscerate evocable evocate evoke evolution evolutionary evolve evzone ewe ex exacerbate exact exactitude exaggerate exalt exaltation exam examination examine example exasperate exasperater excavate exceed excel excelled excellent excelling excelsior except exception excerpt excess excessive exchange exchangeable exchequer excisable excise excision excitation excitatory excite exciton exclaim exclamation exclamatory exclude exclusion exclusionary exclusive excommunicate excoriate excrement excrescent excrete excretion excretory excruciate exculpate exculpatory excursion excursus excusable excuse exec execrable execrate execute execution executive executor executrix exegesis exegete exemplar exemplary exemplify exempt exemption exercisable exercise exert Exeter exfoliate exhale exhaust exhaustible exhaustion exhaustive exhibit exhibition exhibitor exhilarate exhort exhortation exhumation exhume exigent exile exist existent existential exit exodus exogamous exogamy exogenous exonerate exorbitant exorcise exorcism exorcist exoskeleta exoskeleton exothermic exotic exotica expand expanse expansible expansion expansive expatiate expatriate expect expectant expectation expectorant expectorate expedient expedite expedition expeditious expel expellable expelled expelling expend expenditure expense expensive experience experiential experiment experimentation expert expertise expiable expiate expiration expire expiry explain explanation explanatory expletive explicable explicate explicit explode exploit exploitation exploration exploratory explore explosion explosive exponent exponential exponentiate export exportation expose exposit exposition expositor expository exposure expound express expressible expression expressive expressway expropriate expulsion expunge expurgate exquisite extant extemporaneous extempore extend extendible extensible extension extensive extensor extent extenuate exterior exterminate external extinct extinguish extirpate extol extolled extoller extolling extort extra extracellular extract extractor extracurricular extradite extradition extralegal extramarital extramural extraneous extraordinary extrapolate extraterrestrial extraterritorial extravagant extravaganza extrema extremal extreme extremum extricable extricate extrinsic extroversion extrovert extrude extrusion extrusive exuberant exudate exude exult exultant exultation Exxon eye eyeball eyebright eyebrow eyeful eyeglass eyelash eyelet eyelid eyepiece eyesight eyesore eyewitness Ezekiel Ezra f FAA Faber Fabian fable fabric fabricate fabulous facade face faceplate facet facetious facial facile facilitate facsimile fact factious facto factor factorial factory factual faculty fad fade fadeout faery Fafnir fag Fahey Fahrenheit faience fail failsafe failsoft failure fain faint fair Fairchild Fairfax Fairfield fairgoer Fairport fairway fairy faith faithful fake falcon falconry Falkland fall fallacious fallacy fallen fallible falloff Fallopian fallout fallow Falmouth false falsetto falsify Falstaff falter fame familial familiar familism family famine famish famous fan fanatic fanciful fancy fanfare fanfold fang fangled Fanny fanout fantasia fantasist fantastic fantasy fantod far farad Faraday Farber farce farcical fare farewell farfetched Fargo farina Farkas Farley farm farmhouse Farmington farmland Farnsworth faro Farrell farsighted farther farthest fascicle fasciculate fascinate fascism fascist fashion fast fasten fastidious fat fatal fate fateful father fathom fatigue Fatima fatten fatty fatuous faucet Faulkner fault faulty faun fauna faunal Faust Faustian Faustus fawn fay Fayette Fayetteville faze FBI FCC FDA Fe fealty fear fearful fearsome feasible feast feat feather featherbed featherbedding featherbrain feathertop featherweight feathery feature Feb febrile February fecal feces feckless fecund fed federal federate Fedora fee feeble feed feedback feel Feeney feet feign feint feisty Feldman feldspar Felice Felicia felicitous felicity feline Felix fell fellow felon felonious felony felsite felt female feminine feminism feminist femoral femur fence fencepost fend fennec fennel Fenton fenugreek Ferber Ferdinand Ferguson Fermat ferment fermentation Fermi fermion fermium fern Fernando fernery ferocious ferocity Ferreira Ferrer ferret ferric ferris ferrite ferroelectric ferromagnet ferromagnetic ferrous ferruginous ferrule ferry fertile fervent fervid fescue fest festival festive festoon fetal fetch fete fetid fetish fetter fettle fetus feud feudal feudatory fever feverish few fiance fiancee fiasco fiat fib fiberboard Fiberglas Fibonacci fibration fibrin fibrosis fibrous fiche fickle fiction fictitious fictive fiddle fiddlehead fiddlestick fide fidelity fidget fiducial fief fiefdom field fieldstone fieldwork fiend fiendish fierce fiery fiesta fife FIFO fifteen fifteenth fifth fiftieth fifty fiftyfold fig figaro fight figural figurate figure figurine Fiji Fijian filament filamentary filamentous filbert filch file filet filial filibuster filigree Filipino fill fillet fillip filly film filmdom filmmake filmstrip filmy filter filth filthy filtrate fin final finale finance financial financier finch find fine finery finesse finessing finger fingerling fingernail fingerprint fingertip finial finicky finish finite finitude fink Finland Finley Finn Finnegan Finnish finny fir fire firearm fireboat firebreak firebug firecracker firefly firehouse firelight fireman firemen fireplace firepower fireproof fireside Firestone firewall firewood firework firm firmware first firsthand fiscal Fischbein Fischer fish fisherman fishermen fishery fishmonger fishpond fishy Fisk Fiske fissile fission fissure fist fisticuff fit Fitch Fitchburg fitful Fitzgerald Fitzpatrick Fitzroy five fivefold fix fixate fixture Fizeau fizzle fjord FL flabbergast flack flag flagellate flageolet flagging Flagler flagpole flagrant Flagstaff flagstone flail flair flak flake flaky flam flamboyant flame flamingo flammable flan Flanagan Flanders flange flank flannel flap flare flash flashback flashlight flashy flask flat flatbed flathead flatiron flatland flatten flattery flatulent flatus flatworm flaunt flautist flaw flax flaxen flaxseed flea fleabane fleawort fleck fled fledge fledgling flee fleece fleeing fleet Fleming flemish flesh fleshy fletch Fletcher flew flex flexible flexural flexure flick flight flimsy flinch fling flint flintlock flinty flip flipflop flippant flirt flirtation flirtatious flit Flo float floc flocculate flock floe flog flogging flood floodgate floodlight floodlit floodwater floor floorboard flop floppy flora floral Florence Florentine florican florid Florida Floridian florin florist floruit flotation flotilla flounce flounder flour flourish floury flout flow flowchart flowerpot flowery flown Floyd flu flub fluctuate flue fluent fluff fluffy fluid fluke flung flunk flunky fluoresce fluorescein fluorescent fluoridate fluoride fluorine fluorite fluorocarbon fluorspar flurry flush fluster flute flutter flux fly flycatcher flyer Flynn flyway FM FMC foal foam foamflower foamy fob focal foci focus focussed fodder foe fog Fogarty fogging foggy fogy foible foil foist fold foldout Foley foliage foliate folic folio folk folklore folksinger folksinging folksong folksy folktale follicle follicular follow followeth folly Fomalhaut foment fond fondle font Fontaine Fontainebleau food foodstuff fool foolhardy foolish foolproof foolscap foot footage football footbridge Foote footfall foothill foothold footman footmen footnote footpad footpath footprint footstep footstool footwear footwork fop foppish for forage foraminifera foray forbade forbear forbearance Forbes forbid forbidden forbidding forbore forborne force forceful forcible ford Fordham fore foreign forensic forest forestry forever forfeit forfeiture forfend forgather forgave forge forgery forget forgetful forgettable forgetting forgive forgiven forgo forgone forgot forgotten fork forklift forlorn form formal formaldehyde formant format formate formatted formatting formic Formica formidable Formosa formula formulae formulaic formulate forsake forsaken forsook forswear forswore forsworn Forsythe fort forte Fortescue forth forthcome forthcoming forthright forthwith fortieth fortify fortin fortiori fortitude fortnight fortran fortress fortuitous fortunate fortune forty fortyfold forum forward forwent Foss fossil fossiliferous foster fosterite fought foul foulmouth found foundation foundling foundry fount fountain fountainhead four fourfold Fourier foursome foursquare fourteen fourteenth fourth fovea fowl fox foxglove Foxhall foxhole foxhound foxtail foxtrot foxy foyer FPC fractal fraction fractionate fractious fracture fragile fragment fragmentary fragmentation fragrant frail frailty frambesia frame framework Fran franc franca France Frances franchise Francine Francis Franciscan Francisco francium franco Francoise frangipani frank Frankel Frankfort Frankfurt frankfurter franklin frantic Franz Fraser fraternal fraternity Frau fraud fraudulent fraught fray Frazier frazzle freak freakish freckle Fred Freddie Freddy Frederic Frederick Fredericksburg Fredericton Fredholm Fredrickson free freeboot freedman freedmen freedom freehand freehold freeing freeload freeman freemen Freeport freestone freethink Freetown freeway freewheel freeze freight French Frenchman Frenchmen frenetic frenzy freon frequent fresco frescoes fresh freshen freshman freshmen freshwater Fresnel Fresno fret Freud Freudian Frey Freya friable friar fricative Frick friction Friday fridge Friedman Friedrich friend Friesland frieze frigate Frigga fright frighten frightful frigid Frigidaire frill frilly fringe Frisian frisky fritillary fritter Fritz frivolity frivolous frizzle frizzy fro frock frog frolic frolicked frolicking from frond front frontage frontal frontier frontiersman frontiersmen frost frostbite frostbitten frosty froth frothy frown frowzy froze frozen fructose Fruehauf frugal fruit fruitful fruition frustrate frustrater frustum fry Frye f's Ft FTC Fuchs Fuchsia fudge fuel fugal fugitive fugue Fuji Fujitsu Fulbright fulcrum fulfill full fullback Fullerton fully fulminate fulsome Fulton fum fumarole fumble fume fumigant fumigate fun function functionary functor functorial fund fundamental fundraiser fundraising funeral funerary funereal fungal fungi fungible fungicide fungoid fungus funk funky funnel funny fur furbish furious furl furlong furlough Furman furnace furnish furniture furrier furrow furry further furthermore furthermost furthest furtive fury furze fuse fuselage fusible fusiform fusillade fusion fuss fussy fusty futile future fuzz fuzzy g GA gab gabardine gabble gabbro Gaberones gable Gabon Gabriel Gabrielle gad gadfly gadget gadgetry gadolinium gadwall Gaelic gaff gaffe gag gage gagging gaggle gagwriter gaiety Gail gaillardia gain Gaines Gainesville gainful gait Gaithersburg gal gala galactic galactose Galapagos Galatea Galatia galaxy Galbreath gale Galen galena galenite Galilean Galilee Galileo gall Gallagher gallant gallantry gallberry gallery galley gallinule gallium gallivant gallon gallonage gallop Galloway gallows gallstone Gallup gallus Galois Galt galvanic galvanism galvanometer Galveston Galway gam Gambia gambit gamble gambol game gamecock gamesmanship gamete gamin gamma gamut gander Gandhi Gandhian gang Ganges gangland gangling ganglion gangplank gangster gangway gannet Gannett gantlet gantry Ganymede GAO gap gape gar garage garb garbage garble Garcia garden gardenia Gardner Garfield gargantuan gargle Garibaldi garish garland garlic garner garnet garnish Garrett garrison Garrisonian garrulous Garry garter Garth Garvey Gary gas Gascony gaseous gases gash gasify gasket gaslight gasoline gasp Gaspee gassy Gaston gastrointestinal gastronome gastronomic gastronomy gate gatekeeper Gates gateway gather Gatlinburg gator gauche gaucherie gaudy gauge gaugeable Gauguin Gaul gauleiter Gaulle gaunt gauntlet gaur gauss Gaussian Gautama gauze gauzy gave gavel Gavin gavotte gawk gawky gay Gaylord gaze gazebo gazelle gazette gazpacho GE gear gecko gee geese Gegenschein Geiger Geigy geisha gel gelable gelatin gelatine gelatinous geld gem geminate Gemini Geminid Gemma gemsbok gemstone gender gene genealogy genera general generate generic generosity generous Genesco genesis genetic Geneva Genevieve genial genie genii genital genitive genius Genoa genotype genre gent genteel gentian gentile gentle gentleman gentlemen gentlewoman gentlewomen gentry genuflect genuine genus geocentric geochemical geochemistry geochronology geode geodesic geodesy geodetic geoduck Geoffrey geographer geography geology geometer geometrician geophysical geophysics geopolitic George Georgetown Georgia geothermal Gerald Geraldine geranium Gerard Gerber gerbil Gerhard Gerhardt geriatric germ German germane Germanic germanium Germantown Germany germicidal germicide germinal germinate Gerry Gershwin Gertrude gerund gerundial gerundive gestalt Gestapo gestation gesticulate gestural gesture get getaway Getty Gettysburg geyser Ghana Ghanian ghastly Ghent gherkin ghetto ghost ghoul ghoulish Giacomo giant giantess gibberellin gibberish gibbet gibbon gibbous Gibbs gibby gibe giblet Gibraltar Gibson giddap giddy Gideon Gifford gift gig gigacycle gigahertz gigantic gigavolt gigawatt gigging giggle Gil gila gilbert Gilbertson Gilchrist gild Gilead Giles gill Gillespie Gillette Gilligan Gilmore gilt gimbal Gimbel gimlet gimpy gin Gina ginger gingham ginkgo ginmill Ginn Gino Ginsberg Ginsburg ginseng Giovanni giraffe gird girdle girl girlie girlish girt girth gist Giuliano Giuseppe give giveaway given giveth gizmo gizzard gjetost glacial glaciate glacier glacis glad gladden gladdy glade gladiator gladiolus Gladstone Gladys glamor glamorous glamour glance gland glandular glans glare Glasgow glass glassine glassware glasswort glassy Glaswegian glaucoma glaucous glaze gleam glean Gleason glee gleeful glen Glenda Glendale Glenn glib glibly Glidden glide glimmer glimpse glint glissade glisten glitch glitter gloat glob global globe globular globule globulin glom glomerular gloom gloomy Gloria Gloriana glorify glorious glory gloss glossary glossolalia glossy glottal glottis Gloucester glove glow glucose glue gluey glum glut glutamate glutamic glutamine gluten glutinous glutton gluttonous gluttony glyceride glycerin glycerinate glycerine glycerol glycine glycogen glycol glyph GM GMT gnarl gnash gnat gnaw gneiss gnome gnomon gnomonic gnostic GNP gnu go Goa goad goal goat gob gobble gobbledygook Gobi goblet god Goddard goddess godfather Godfrey godhead godkin godmother godparent godsend godson Godwin godwit goes Goethe Goff gog goggle Gogh gogo gold Goldberg golden goldeneye goldenrod goldenseal goldfinch goldfish Goldman goldsmith Goldstein Goldstine Goldwater Goleta golf Goliath golly gonad gonadotropic gondola gone gong Gonzales Gonzalez goober good goodbye Goode Goodman Goodrich goodwill Goodwin goody Goodyear goof goofy goose gooseberry GOP gopher Gordian Gordon gore Goren gorge gorgeous gorgon Gorham gorilla Gorky gorse Gorton gory gosh goshawk gosling gospel gossamer gossip got Gotham Gothic gotten Gottfried Goucher Gouda gouge Gould gourd gourmet gout govern governance governess governor gown GPO grab grace graceful gracious grackle grad gradate grade gradient gradual graduate Grady Graff graft graham grail grain grainy grammar grammarian grammatic gramophone granary grand grandchild grandchildren granddaughter grandeur grandfather grandiloquent grandiose grandma grandmother grandnephew grandniece grandpa grandparent grandson grandstand granite granitic granny granola grant grantee grantor granular granulate granule Granville grape grapefruit grapevine graph grapheme graphic graphite grapple grasp grass grasshopper grassland grassy grata grate grateful grater gratify gratis gratitude gratuitous gratuity grave gravel graven gravestone graveyard gravid gravitate gravitometer graviton gravy Grayson graze grease greasy great greatcoat greater grebe Grecian Greece greed greedy Greek green Greenbelt Greenberg Greenblatt Greenbriar Greene greenery Greenfield greengrocer greenhouse greenish Greenland Greensboro greensward greenware Greenwich greenwood Greer greet Greg gregarious Gregg Gregory gremlin grenade Grendel Grenoble grep Gresham Greta Gretchen grew grey greyhound greylag grid griddle gridiron gridlock grief grievance grieve grievous griffin Griffith grill grille grillwork grim grimace Grimaldi grime Grimm grimy grin grind grindstone grip gripe grippe grisly grist gristmill Griswold grit gritty grizzle grizzly groan groat grocer grocery groggy groin grommet groom groove grope grosbeak gross Grosset Grossman Grosvenor grotesque Groton grotto grottoes grouch grouchy ground groundhog groundsel groundskeep groundwork group groupoid grouse grout grove grovel Grover grow growl grown grownup growth grub grubby grudge gruesome gruff grumble Grumman grump grumpy grunt Gruyere gryphon g's GSA GU Guam guanidine guanine guano guarantee guaranteeing guaranty guard guardhouse Guardia guardian Guatemala gubernatorial Guelph Guenther guerdon guernsey guerrilla guess guesswork guest guffaw Guggenheim Guiana guidance guide guidebook guideline guidepost guignol guild guildhall guile Guilford guillemot guillotine guilt guilty guinea Guinevere guise guitar Gujarat Gujarati gulch gules gulf gull Gullah gullet gullible gully gulp gum gumbo gumdrop gummy gumption gumshoe gun Gunderson gunfight gunfire gunflint gunk gunky gunman gunmen gunnery gunny gunplay gunpoint gunpowder gunshot gunsling Gunther gurgle Gurkha guru Gus gush gusset gust Gustafson Gustav Gustave Gustavus gusto gusty gut Gutenberg Guthrie gutsy guttural guy Guyana guzzle Gwen Gwyn gym gymnasium gymnast gymnastic gymnosperm gyp gypsite gypsum gypsy gyrate gyrfalcon gyro gyrocompass gyroscope h ha Haag Haas habeas haberdashery Haberman Habib habit habitant habitat habitation habitual habituate hacienda hack hackberry Hackett hackle hackmatack hackney hacksaw had Hadamard Haddad haddock Hades Hadley hadn't Hadrian hadron hafnium Hagen Hager haggard haggis haggle hagiography Hagstrom Hague Hahn Haifa haiku hail hailstone hailstorm Haines hair haircut hairdo hairpin hairspring hairy Haiti Haitian Hal halcyon hale Haley half halfback halfhearted halftone halfway halibut halide Halifax halite hall hallelujah Halley hallmark hallow Halloween hallucinate hallucinatory hallucinogen hallucinogenic hallway halma halo halocarbon halogen Halpern Halsey Halstead halt halvah halve Halverson ham Hamal Hamburg hamburger Hamilton hamlet Hamlin hammerhead hammock Hammond hamper Hampshire Hampton hamster hamstrung Han Hancock hand handbag handbook handclasp handcuff Handel handful handgun handhold handicap handicapped handicapper handicapping handicraft handicraftsman handicraftsmen handiwork handkerchief handle handleable handlebar handline handmade handmaiden handout handpicked handprint handset handshake handsome handspike handstand handwaving handwrite handwritten handy handyman handymen Haney Hanford hang hangable hangar hangdog hangman hangmen hangnail hangout hangover hank Hankel Hanley Hanlon Hanna Hannah Hannibal Hanoi Hanover Hanoverian Hans Hansel Hansen hansom Hanson Hanukkah hap haphazard haploid haploidy haplology happen happenstance happy Hapsburg harangue harass Harbin harbinger Harcourt hard hardbake hardboard hardboiled hardbound hardcopy hardcover harden hardhat hardhearted Hardin hardscrabble hardtack hardtop hardware hardwire hardwood hardworking hardy hare harebrained harelip harem hark harken Harlan Harlem Harley harm harmful Harmon harmonic harmonica harmonious harmony harness Harold harp harpoon harpsichord harpy Harriet Harriman Harrington Harris Harrisburg Harrison harrow harry harsh harshen hart Hartford Hartley Hartman Harvard harvest harvestman Harvey has hash hashish hasn't hasp hassle hast haste hasten Hastings hasty hat hatch hatchery hatchet hatchway hate hateful hater Hatfield hath Hathaway hatred Hatteras Hattie Hattiesburg Haugen haughty haul haulage haunch haunt Hausa Hausdorff Havana have haven haven't haversack Havilland havoc haw Hawaii Hawaiian hawk Hawkins Hawley hawthorn Hawthorne hay Hayden Haydn Hayes hayfield Haynes haystack hayward hazard hazardous haze hazel hazelnut hazy he head headache headboard headcount headdress headland headlight headline headlong headman headmaster headmen headphone headquarter headroom headset headsman headsmen headstand headstone headstrong headwall headwater headway headwind heady heal Healey health healthful healthy Healy heap hear heard hearken hearsay hearse Hearst heart heartbeat heartbreak hearten heartfelt hearth heartland heartrending heartthrob hearty heat heater heath heathen heathenish Heathkit heave heaven heavenward heavy heavyset heavyweight Hebe hebephrenic Hebraic Hebrew Hebrides Hecate hecatomb heck heckle Heckman hectic hector Hecuba he'd hedge hedgehog hedonism hedonist heed heel heft hefty Hegelian hegemony Heidegger Heidelberg heifer heigh height heighten Heine Heinrich Heinz heir heiress Heisenberg held Helen Helena Helene Helga helical helicopter heliocentric heliotrope helium helix he'll hell hellbender hellebore Hellenic Hellespont hellfire hellgrammite hellish hello helm helmet Helmholtz helmsman helmsmen Helmut help helpful helpmate Helsinki Helvetica hem hematite Hemingway hemisphere hemispheric hemlock hemp Hempstead hen henbane hence henceforth henchman henchmen Henderson Hendrick Hendrickson henequen Henley henpeck Henri Henrietta henry hepatica hepatitis Hepburn heptane her Hera Heraclitus herald herb herbarium Herbert herbicide herbivore herbivorous Herculean Hercules herd herdsman herdsmen here hereabout hereafter hereby hereditary heredity Hereford herein hereinabove hereinafter hereinbelow hereof heresy heretic hereto heretofore hereunder hereunto herewith heritable heritage Herkimer Herman Hermann hermaphrodite hermaphroditic hermeneutic Hermes hermetic hermit hermitage Hermite hermitian Hermosa Hernandez hernia hero Herodotus heroes heroic heroin heroine heroism heron herpes herpetology Herr herringbone Herschel herself Hershel Hershey hertz Hertzog hesitant hesitate hesitater Hesperus Hess Hesse Hessian Hester heterocyclic heterodyne heterogamous heterogeneity heterogeneous heterosexual heterostructure heterozygous Hetman Hettie Hetty Heublein heuristic Heusen Heuser hew Hewett Hewitt Hewlett hewn hex hexachloride hexadecimal hexafluoride hexagon hexagonal hexameter hexane hey heyday hi Hiatt hiatus Hiawatha hibachi Hibbard hibernate Hibernia hick Hickey Hickman hickory hid hidalgo hidden hide hideaway hidebound hideous hideout hierarchal hierarchic hierarchy hieratic hieroglyphic Hieronymus hifalutin Higgins high highball highboy highfalutin highhanded highland highlight highroad hightail highway highwayman highwaymen hijack hike hilarious hilarity Hilbert Hildebrand hill hillbilly Hillcrest Hillel hillman hillmen hillock hillside hilltop hilly hilt Hilton hilum him Himalaya himself hind Hindi hindmost hindquarters hindrance hindsight Hindu Hindustan Hines hinge Hinman hint hinterland hip hippie hippo Hippocrates Hippocratic hippodrome hippopotamus hippy hipster Hiram hire hireling Hiroshi Hiroshima Hirsch hirsute his Hispanic hiss histamine histidine histochemic histochemistry histogram histology historian historic historiography history histrionic hit Hitachi hitch Hitchcock hither hitherto Hitler hive ho hoagie Hoagland hoagy hoar hoard hoarfrost hoarse hoax hob Hobart Hobbes hobble Hobbs hobby hobbyhorse hobo Hoboken hoc hock hockey hodge hodgepodge Hodges Hodgkin hoe Hoff Hoffman hog hogan hogging hoi Hokan Holbrook Holcomb hold holden holdover holdup hole holeable holiday Holland hollandaise holler Hollerith Hollingsworth Hollister hollow Holloway hollowware holly hollyhock Hollywood Holm Holman Holmdel Holmes holmium holocaust Holocene hologram holography Holst Holstein holster holt Holyoke holystone Hom homage home homebound homebuilder homebuilding homecoming homeland homemade homemake homeobox homeomorph homeomorphic homeopath homeopathic homeowner Homeric homesick homespun homestead homeward homework homicidal homicide homily hominid homo homogenate homogeneity homogeneous homologous homologue homology homomorphic homomorphism homonym homophobia homosexual homotopy homozygous homunculus Honda hondo Honduras hone honest honesty honey honeybee honeycomb honeydew honeymoon honeysuckle Honeywell hong honk honky Honolulu honoraria honorarium honorary honoree honorific Honshu hooch hood hoodlum hoof hoofmark hoofprint hook hookup hookworm hooligan hoop hoopla hoosegow Hoosier hoot Hoover hooves hop hope hopeful Hopi Hopkins Hopkinsian hopple hopscotch Horace Horatio horde horehound horizon horizontal hormonal hormone horn hornbeam hornblende Hornblower hornet hornmouth hornpipe horntail hornwort horny horology horoscope Horowitz horrendous horrible horrid horrify horror horse horseback horsedom horseflesh horsefly horsehair horseman horsemen horseplay horsepower horseshoe horsetail horsewoman horsewomen horticulture Horton Horus hose hosiery hospice hospitable hospital host hostage hostelry hostess hostile hostler hot hotbed hotbox hotel hotelman hotfoot hothead hothouse hotrod Hottentot Houdaille Houdini hough Houghton hound hour hourglass house houseboat housebreak housebroken housefly household housekeep housemate housewife housewives housework Houston hove hovel hover how Howard howdy Howe Howell however howl howsoever howsomever hoy hoyden hoydenish Hoyt Hrothgar h's hub Hubbard Hubbell hubbub hubby hubcap Huber Hubert hubris huck huckleberry huckster huddle Hudson hue huff Huffman hug huge hugging Huggins Hugh Hughes Hugo huh hulk hull hullaballoo hullabaloo hum human humane humanitarian humble Humboldt humdrum humerus humid humidify humidistat humiliate humility Hummel hummingbird hummock humorous hump humpback Humphrey humpty humus Hun hunch hunchback hundred hundredfold hundredth hung Hungarian Hungary hungry hunk hunt Huntington Huntley Huntsville Hurd hurdle hurl hurley Huron hurrah hurray hurricane hurry Hurst hurt hurtle hurty Hurwitz husband husbandman husbandmen husbandry hush husky hustle Huston hut hutch Hutchins Hutchinson Hutchison Huxley Huxtable huzzah hyacinth Hyades hyaline Hyannis hybrid Hyde hydra hydrangea hydrant hydrate hydraulic hydride hydro hydrocarbon hydrochemistry hydrochloric hydrochloride hydrocyanic hydrodynamic hydroelectric hydrofluoric hydrogen hydrogenate hydrology hydrolysis hydrometer hydronium hydrophilic hydrophobia hydrophobic hydrophone hydrosphere hydrostatic hydrothermal hydrous hydroxide hydroxy hydroxyl hydroxylate hyena hygiene hygrometer hygroscopic hying Hyman hymen hymn hymnal hyper hyperbola hyperbolic hyperboloid hyperboloidal hypertensive hyperthermia hyphen hyphenate hypnosis hypnotic hypoactive hypochlorite hypochlorous hypocrisy hypocrite hypocritic hypocycloid hypodermic hypophyseal hypotenuse hypothalamic hypothalamus hypothalmus hypothermia hypotheses hypothesis hypothetic hypothyroid hypotonic hysterectomy hysteresis hysteria hysteric hysteron i IA iambic Ian Iberia ibex ibid ibis IBM Ibn Icarus ICC ice iceberg icebox icecap iceland Icelandic iceman ichneumon icicle icky icon iconoclasm iconoclast iconography icosahedra icosahedral icosahedron icy I'd id Ida Idaho idea ideal ideate idempotent identical identify identity ideogram ideolect ideology idetic idiocy idiom idiomatic idiosyncrasy idiosyncratic idiot idiotic idle idly idol idolatry idyll idyllic i.e IEEE if iffy Ifni igloo igneous ignite ignition ignoble ignominious ignominy ignoramus ignorant ignore Igor ii iii Ike IL ileum iliac Iliad I'll ill illegal illegible illegitimacy illegitimate illicit illimitable Illinois illiteracy illiterate illogic illume illuminate illumine illusion illusionary illusive illusory illustrate illustrious Ilona Ilyushin I'm image imagen imagery imaginary imaginate imagine imbalance imbecile imbibe Imbrium imbroglio imbrue imbue imitable imitate immaculate immanent immaterial immature immeasurable immediacy immediate immemorial immense immerse immersion immigrant immigrate imminent immiscible immobile immobility immoderate immodest immodesty immoral immortal immovable immune immunoelectrophoresis immunology immutable imp impact impair impale impalpable impart impartation impartial impassable impasse impassion impassive impatient impeach impeccable impedance impede impediment impel impelled impeller impelling impend impenetrable imperate imperceivable imperceptible imperfect imperial imperil imperious imperishable impermeable impermissible impersonal impersonate impertinent imperturbable impervious impetuous impetus impiety impinge impious impish implacable implant implantation implausible implement implementation implementer implementor implicant implicate implicit implore impolite impolitic imponderable import important importation importunate importune impose imposition impossible impost imposture impotent impound impoverish impracticable impractical imprecate imprecise impregnable impregnate impresario impress impressible impression impressive imprimatur imprint imprison improbable impromptu improper impropriety improve improvident improvisate improvise imprudent impudent impugn impulse impulsive impunity impure imputation impute in inability inaccessible inaccuracy inaccurate inaction inactivate inactive inadequacy inadequate inadmissible inadvertent inadvisable inalienable inalterable inane inanimate inappeasable inapplicable inappreciable inapproachable inappropriate inapt inaptitude inarticulate inasmuch inattention inattentive inaudible inaugural inaugurate inauspicious inauthentic inboard inborn inbred inbreed Inc Inca incalculable incandescent incant incantation incapable incapacitate incapacity incarcerate incarnate incautious incendiary incense incentive inception inceptor incessant incest incestuous inch inchoate inchworm incident incidental incinerate incipient incise incisive incisor incite inclement inclination incline inclose include inclusion inclusive incognito incoherent incombustible income incommensurable incommensurate incommunicable incommutable incomparable incompatible incompetent incomplete incompletion incomprehensible incomprehension incompressible incomputable inconceivable inconclusive incondensable incongruity incongruous inconsequential inconsiderable inconsiderate inconsistent inconsolable inconspicuous inconstant incontestable incontrollable incontrovertible inconvenient inconvertible incorporable incorporate incorrect incorrigible incorruptible increasable increase incredible incredulity incredulous increment incriminate incubate incubi incubus inculcate inculpable incumbent incur incurred incurrer incurring incursion indebted indecent indecipherable indecision indecisive indecomposable indeed indefatigable indefensible indefinable indefinite indelible indelicate indemnity indent indentation indenture independent indescribable indestructible indeterminable indeterminacy indeterminate index India Indiana Indianapolis indicant indicate indices indict Indies indifferent indigene indigenous indigent indigestible indigestion indignant indignation indignity indigo Indira indirect indiscernible indiscoverable indiscreet indiscretion indiscriminate indispensable indispose indisposition indisputable indissoluble indistinct indistinguishable indium individual individuate indivisible Indo Indochina Indochinese indoctrinate Indoeuropean indolent indomitable Indonesia indoor indorse indubitable induce inducible induct inductance inductee inductor indulge indulgent Indus industrial industrious industry indwell indy inebriate inedible ineducable ineffable ineffective ineffectual inefficacy inefficient inelastic inelegant ineligible ineluctable inept inequality inequitable inequity inequivalent ineradicable inert inertance inertia inertial inescapable inessential inestimable inevitable inexact inexcusable inexhaustible inexorable inexpedient inexpensive inexperience inexpert inexpiable inexplainable inexplicable inexplicit inexpressible inextinguishable inextricable infallible infamous infamy infant infanticide infantile infantry infantryman infantrymen infarct infatuate infeasible infect infectious infelicitous infelicity infer inference inferential inferior infernal inferno inferred inferring infertile infest infestation infidel infield infighting infiltrate infima infimum infinite infinitesimal infinitive infinitude infinitum infinity infirm infirmary infix inflame inflammable inflammation inflammatory inflate inflater inflationary inflect inflexible inflict inflorescent inflow influence influent influential influenza influx info inform informal informant information informative infra infract infrared infrastructure infrequent infringe infuriate infuse infusible infusion infusoria ingather ingenious ingenuity ingenuous Ingersoll ingest ingestible ingestion inglorious ingot ingrained Ingram ingrate ingratiate ingratitude ingredient ingrown inhabit inhabitant inhabitation inhalation inhale inharmonious inhere inherent inherit inheritance inheritor inhibit inhibition inhibitor inhibitory inholding inhomogeneity inhomogeneous inhospitable inhuman inhumane inimical inimitable iniquitous iniquity initial initiate inject injudicious Injun injunct injure injurious injury injustice ink inkling inlaid inland inlay inlet Inman inmate inn innard innate innermost innkeeper innocent innocuous innovate innuendo innumerable inoculate inoperable inoperative inopportune inordinate inorganic input inputting inquest inquire inquiry inquisition inquisitive inquisitor inroad insane insatiable inscribe inscription inscrutable insect insecticide insectivore insectivorous insecure inseminate insensible insensitive inseparable insert inset inshore inside insidious insight insightful insignia insignificant insincere insinuate insipid insist insistent insofar insolate insolent insoluble insolvable insolvent insomnia insomniac insouciant inspect inspector inspiration inspire instable install installation instant instantaneous instantiate instar instead instep instigate instill instillation instinct instinctual institute institution instruct instructor instrument instrumentation insubordinate insubstantial insufferable insufficient insular insulate insulin insult insuperable insupportable insuppressible insurance insure insurgent insurmountable insurrect intact intake intangible integer integrable integral integrand integrate integrity integument intellect intellectual intelligent intelligentsia intelligible intemperance intemperate intend intendant intense intensify intensive intent intention inter intercalate intercept interception interceptor intercom interdict interdigitate interest interfere interference interferometer interferon interim interior interject interlude intermediary intermit intermittent intern internal internescine Interpol interpolate interpolatory interpret interpretation interpretive interregnum interrogate interrogatory interrupt interruptible interruption intersect intersperse interstice interstitial interval intervene intervenor intervention interviewee intestate intestinal intestine intimacy intimal intimate intimater intimidate into intolerable intolerant intonate intone intoxicant intoxicate intra intractable intransigent intransitive intrepid intricacy intricate intrigue intrinsic introduce introduction introductory introit introject introspect introversion introvert intrude intrusion intrusive intuit intuition intuitive inundate inure invade invalid invalidate invaluable invariable invariant invasion invasive invective inveigh inveigle invent invention inventive inventor inventory Inverness inverse inversion invert invertebrate invertible invest investigate investigatory investor inveterate inviable invidious invigorate invincible inviolable inviolate invisible invitation invite invitee invocable invocate invoice invoke involuntary involute involution involutorial involve invulnerable inward Io iodate iodide iodinate iodine ion ionic ionosphere ionospheric iota Iowa ipecac ipsilateral ipso IQ IR Ira Iran Iranian Iraq Iraqi irate ire Ireland Irene iridium iris Irish Irishman Irishmen irk irksome Irma iron ironbound ironic ironside ironstone ironwood irony Iroquois irradiate irrational Irrawaddy irreclaimable irreconcilable irreconciliable irrecoverable irredeemable irredentism irredentist irreducible irrefutable irregular irrelevant irremediable irremovable irreparable irreplaceable irrepressible irreproachable irreproducible irresistible irresolute irresolution irresolvable irrespective irresponsible irretrievable irreverent irreversible irrevocable irrigate irritable irritant irritate irruption IRS Irvin Irvine Irving Irwin i's is Isaac Isaacson Isabel Isabella Isadore Isaiah isentropic Isfahan Ising isinglass Isis Islam Islamabad Islamic island isle islet isn't isochronal isochronous isocline isolate Isolde isomer isomorph isomorphic isopleth isotherm isotope isotropy Israel Israeli Israelite issuant issue Istanbul isthmus Istvan it Italian italic Italy itch itchy it'd item iterate Ithaca itinerant itinerary it'll Ito itself IT&T ITT iv Ivan Ivanhoe I've Iverson ivory ivy ix Izvestia j jab Jablonsky jack jackal jackanapes jackass jackboot jackdaw jacket Jackie jackknife Jackman jackpot Jackson Jacksonville Jacky JACM Jacob Jacobean Jacobi Jacobian Jacobite Jacobsen Jacobson Jacobus Jacqueline Jacques jade Jaeger jag jagging jaguar Jaime Jakarta jake jalopy jam Jamaica jamboree James Jamestown Jan Jane Janeiro Janet jangle Janice janissary janitor janitorial Janos Jansenist January Janus Japan Japanese jar jargon Jarvin Jason jasper jaundice jaunty Java java javelin jaw jawbone jay jazz jazzy jealous jealousy jean Jeannie Jed jeep Jeff Jefferson Jeffrey Jehovah jejune jejunum jelly jellyfish Jenkins Jennie Jennifer Jennings jenny Jensen jeopard jeopardy Jeremiah Jeremy Jeres Jericho jerk jerky Jeroboam Jerome jerry jersey Jerusalem jess Jesse Jessica Jessie jest Jesuit Jesus jet jetliner jettison Jew jewel Jewell jewelry Jewett Jewish jibe jiffy jig jigging jiggle jigsaw Jill jilt Jim Jimenez Jimmie jimmy jingle jinx jitter jitterbug jittery jive Jo Joan Joanna Joanne Joaquin job jobholder jock jockey jockstrap jocose jocular jocund Joe Joel joey jog jogging joggle Johann Johanna Johannes Johannesburg Johansen Johanson John Johnny Johnsen Johnson Johnston Johnstown join joint joke Joliet Jolla jolly jolt Jon Jonas Jonathan Jones jonquil Jordan Jorge Jorgensen Jorgenson Jose Josef Joseph Josephine Josephson Josephus Joshua Josiah joss jostle jot joule jounce journal journalese journey journeyman journeymen joust Jovanovich Jove jovial Jovian jowl jowly joy Joyce joyful joyous joyride joystick Jr j's Juan Juanita jubilant jubilate Judaica Judaism Judas Judd Jude judge judicable judicatory judicature judicial judiciary judicious Judith judo Judson Judy jug jugate juggernaut jugging juggle Jugoslavia juice juicy juju jujube juke jukebox Jukes julep Jules Julia Julie Juliet Julio Julius July jumble jumbo jump jumpy junco junction junctor juncture June Juneau Jung Jungian jungle junior juniper junk junkerdom junketeer junky Juno junta Jupiter Jura Jurassic jure juridic jurisdiction jurisprudent jurisprudential juror jury just justice justiciable justify Justine Justinian jut jute Jutish Jutland juvenile juxtapose juxtaposition k Kabuki Kabul Kaddish Kafka Kafkaesque Kahn kaiser Kajar Kalamazoo kale kaleidescope kaleidoscope kalmia Kalmuk Kamchatka kamikaze Kampala Kampuchea Kane kangaroo Kankakee Kannada Kansas Kant kaolin kaolinite Kaplan kapok kappa Karachi Karamazov karate Karen Karl karma Karol Karp karyatid Kashmir Kaskaskia Kate Katharine Katherine Kathleen Kathy Katie Katmandu Katowice katydid Katz Kauffman Kaufman kava Kay kayo kazoo Keaton Keats keddah keel keelson keen Keenan keep keeshond keg Keith Keller Kelley Kellogg kelly kelp Kelsey Kelvin Kemp ken Kendall Kennan Kennecott Kennedy kennel Kenneth Kenney keno Kensington Kent Kenton Kentucky Kenya Kenyon Kepler kept kerchief Kermit kern kernel Kernighan kerosene Kerouac Kerr kerry kerygma Kessler kestrel ketch ketchup keto ketone ketosis Kettering kettle Kevin key keyboard Keyes keyhole Keynes Keynesian keynote keypunch keystone keyword khaki khan Khartoum Khmer Khrushchev kibbutzim kibitz kick kickback kickoff kid Kidde kiddie kidnap kidnapped kidnapping kidney Kieffer Kiev Kiewit Kigali Kikuyu Kilgore Kilimanjaro kill killdeer killjoy kilohm Kim Kimball Kimberly kimono kin kind kindergarten kindle kindred kinematic kinesic kinetic king kingbird kingdom kingfisher kinglet kingpin Kingsbury Kingsley Kingston kink kinkajou kinky Kinney Kinshasha kinsman kinsmen kiosk Kiowa Kipling Kirby Kirchner Kirchoff kirk Kirkland Kirkpatrick Kirov kiss kit Kitakyushu kitchen kitchenette kite kitten kittenish kittle kitty kiva kivu Kiwanis kiwi Klan Klaus klaxon kleenex Klein Kline Klux klystron knack Knapp knapsack Knauer knead knee kneecap kneel knelt knew knick Knickerbocker knife knight Knightsbridge knit knives knob knobby knock knockdown knockout knoll Knossos knot Knott knotty know knoweth knowhow knowledge knowledgeable Knowles Knowlton known Knox Knoxville knuckle knuckleball Knudsen Knudson knurl Knutsen Knutson koala Kobayashi Koch Kochab Kodachrome kodak Kodiak Koenig Koenigsberg kohlrabi koinonia kola kolkhoz kombu Kong Konrad Koppers Koran Korea kosher Kovacs Kowalewski Kowalski Kowloon kraft Krakatoa Krakow Kramer Krause kraut Krebs Kremlin Kresge Krieger krill Krishna Kristin Kronecker Krueger Kruger krummholz Kruse krypton KS k's Ku kudo kudzu Kuhn kulak Kumar kumquat Kurd Kurt Kuwait kwashiorkor KY Kyle Kyoto l la lab Laban label labia labial labile lability labium laboratory laborious labour Labrador labradorite labyrinth lac lace lacerate Lacerta lacewing Lachesis lachrymose lack lackadaisic lackey laconic lacquer lacrosse lactate lactose lacuna lacunae lacustrine lacy lad laden ladle lady ladybird ladybug ladyfern Lafayette lag lager lagging lagoon Lagos Lagrange Lagrangian Laguerre Lahore laid Laidlaw lain lair laissez laity lake Lakehurst lakeside lakh lam lama Lamar Lamarck lamb lambda lambert lame lamellar lament lamentation laminar laminate lamp lampblack lamplight lampoon lamprey Lana Lancashire Lancaster lance Lancelot lancet land landau landfill landhold Landis landlady landlocked landlord landlubber landmark landmass landowner landowning landscape landslide lane Lang Lange Langley Langmuir language languid languish langur Lanka lanky Lansing lantern lanthanide lanthanum Lao Laocoon Laos Laotian lap lapel lapelled lapidary Laplace lappet lapse Laramie larceny larch lard Laredo Lares large largemouth largesse lariat lark Larkin larkspur Larry Lars Larsen Larson larva larvae larval laryngeal larynges larynx lascar lascivious lase lash lass lasso last Laszlo latch late latent later latera lateral Lateran laterite latex lath lathe Lathrop Latin Latinate latitude latitudinal latitudinary Latrobe latter lattice latus Latvia laud laudanum laudatory Lauderdale Laue laugh laughingstock Laughlin laughter launch launder laundry laura laureate laurel Lauren Laurent Laurentian Laurie Lausanne lava lavabo lavatory lavender lavish Lavoisier law lawbreaker lawbreaking lawful lawgiver lawgiving lawmake lawman lawmen lawn Lawrence lawrencium Lawson lawsuit lawyer lax laxative lay layette layman laymen layoff layout layperson Layton layup Lazarus laze lazy lazybones lea leach leachate lead leaden leadeth leadsman leadsmen leaf leaflet leafy league leak leakage leaky lean Leander leap leapfrog leapt Lear learn lease leasehold leash least leather leatherback leatherneck leatherwork leathery leave leaven Leavenworth Lebanese Lebanon lebensraum Lebesgue lecher lechery lectern lectionary lecture led ledge lee leech Leeds leek leer leery Leeuwenhoek leeward leeway left leftmost leftover leftward lefty leg legacy legal legate legatee legato legend legendary Legendre legerdemain legging leggy leghorn legible legion legislate legislature legitimacy legitimate legume leguminous Lehigh Lehman Leibniz Leigh Leighton Leila leisure leitmotif leitmotiv Leland lemma lemming lemon lemonade Lemuel lemur Len Lena lend length lengthen lengthwise lengthy lenient Lenin Leningrad Lennox Lenny Lenore lens lent Lenten lenticular lentil Leo Leon Leona Leonard Leonardo Leone Leonid leonine leopard Leopold leper lepidolite lepidopterist leprosy Leroy Lesbian lesion Leslie Lesotho less lessee lessen lesson lessor lest Lester let lethal lethargy Lethe Letitia letterhead letterman lettermen lettuce leucine Lev levee level lever leverage Levi leviathan Levin Levine Levis levitate Leviticus Levitt levity levulose levy lew lewd lewis lexical lexicographer lexicography lexicon Lexington Leyden liable liaison liana liar libation libel libelous liberal liberate Liberia libertarian libertine liberty libidinous libido Libra librarian library librate librettist libretto Libreville Libya lice licensable licensee licensor licentious lichen lick licorice lid lie Lieberman Liechtenstein lien lieu lieutenant life lifeblood lifeboat lifeguard lifelong lifespan lifestyle lifetime LIFO lift ligament ligand ligature Ligget Liggett light lighten lightface lightfooted lighthearted lighthouse lightning lightproof lightweight lignite lignum like likeable liken likewise Lila lilac Lilian Lillian Lilliputian Lilly lilt lily lim Lima limb limbic limbo lime limelight limerick limestone limit limitate limnology limousine limp limpet limpid limpkin Lin linchpin Lincoln Lind Linda Lindberg Lindbergh linden Lindholm Lindquist Lindsay Lindsey Lindstrom line lineage lineal linear linebacker lineman linemen linen lineprinter lineup linger lingerie lingo lingua lingual linguist liniment link linkage Linnaeus linoleic linoleum Linotype linseed lint Linton Linus lion Lionel lioness lip lipid Lippincott Lipschitz Lipscomb lipstick Lipton liquefaction liquefy liqueur liquid liquidate liquor Lisa Lisbon Lise lisle lisp Lissajous list listen lit litany literacy literal literary literate literature lithe lithic lithium lithograph lithography lithology lithosphere lithospheric Lithuania litigant litigate litigious litmus litterbug littermate little littleneck Littleton Litton littoral liturgic liturgy live liven Livermore Liverpool Liverpudlian liverwort livery livestock liveth livid Livingston livre Liz lizard Lizzie llama Lloyd lo load loaf loam loamy loan loanword loath loathe loathsome loaves lob lobar lobby lobe Lobelia loblolly lobo lobscouse lobster lobular lobule local locale locate loch loci lock Locke Lockhart Lockheed Lockian locknut lockout locksmith lockup Lockwood locomote locomotion locomotive locomotor locomotory locoweed locus locust locutor lodestone lodge lodgepole Lodowick Loeb l'oeil loess loft lofty log Logan logarithm logarithmic loge loggerhead logging logic logician login logistic logjam loin loincloth Loire Lois loiter Loki Lola loll lollipop lolly Lomb Lombard Lombardy Lome London lone lonesome long longevity Longfellow longhand longhorn longish longitude longitudinal longleg longstanding longtime longue longwinded look lookout lookup loom Loomis loon loop loophole loose looseleaf loosen loosestrife loot lop lope Lopez lopseed lopsided loquacious loquacity loquat lord lordosis lore Lorelei Loren Lorenz Lorinda loris Lorraine lorry losable lose loss lossy lost lot lotion Lotte lottery Lottie lotus Lou loud loudspeaker loudspeaking Louis Louisa Louise Louisiana Louisville lounge Lounsbury Lourdes louse lousewort lousy Louvre love lovebird Lovelace Loveland lovelorn low lowboy lowdown Lowe Lowell lowland Lowry lox loy loyal loyalty lozenge l's LSI LTV Lubbock Lubell lubricant lubricate lubricious lubricity Lucas Lucerne Lucia Lucian lucid Lucifer Lucille Lucius luck lucky lucrative lucre Lucretia Lucretius lucy ludicrous Ludlow Ludwig Lufthansa Luftwaffe lug luge luger luggage lugging lugubrious Luis luke lukewarm lull lullaby lulu lumbago lumbar lumber lumberjack lumberman lumbermen lumen luminance luminary luminescent luminosity luminous lummox lump lumpish Lumpur lumpy lunacy lunar lunary lunate lunatic lunch luncheon lunchroom lunchtime Lund Lundberg Lundquist lung lunge lupine Lura lurch lure lurid lurk Lusaka luscious lush lust lustful lustrous lusty lutanist lute lutetium Luther Lutheran Lutz lux luxe Luxembourg luxuriant luxuriate luxurious luxury Luzon L'vov lycee lycopodium Lydia lye lying Lykes Lyle Lyman lymph lymphocyte lymphoma lynch Lynchburg Lynn lynx Lyon Lyra lyre lyrebird lyric Lysenko lysergic lysine m ma Mabel Mac macabre Macadamia macaque MacArthur Macassar macaw Macbeth MacDonald MacDougall mace Macedon Macedonia macerate MacGregor Mach machete Machiavelli machination machine machinery machismo macho macintosh mack MacKenzie mackerel Mackey Mackinac Mackinaw mackintosh MacMahon MacMillan Macon macro macromolecular macromolecule macrophage macroscopic macrostructure mad Madagascar madam Madame madcap madden Maddox made Madeira Madeleine Madeline madhouse Madhya Madison madman madmen Madonna Madras Madrid madrigal Madsen madstone Mae maelstrom maestro Mafia Mafioso magazine Magdalene Magellanic magenta Maggie maggot maggoty magi magic magician magisterial magistrate magma magna magnanimity magnanimous magnate magnesia magnesite magnesium magnet magnetic magnetite magneto magnetron magnificent magnify magnitude magnolia magnum Magnuson Magog magpie Magruder maharaja Maharashtra Mahayana Mahayanist mahogany Mahoney maid maiden maidenhair maidservant Maier mail mailbox mailman mailmen maim main Maine mainframe mainland mainline mainstay mainstream maintain maintenance maitre majestic majesty major Majorca make makeshift makeup Malabar maladapt maladaptive maladjust maladroit malady Malagasy malaise malaprop malaria malarial Malawi Malay Malaysia Malcolm malconduct malcontent Malden maldistribute Maldive male maledict malevolent malfeasant malformation malformed malfunction Mali malice malicious malign malignant mall mallard malleable mallet Mallory mallow malnourished malnutrition malocclusion Malone Maloney malposed malpractice Malraux malt Malta Maltese Malthus Malthusian Malton maltose maltreat maltster mambo mamma mammal mammalian mammary mammoth man mana manage manageable managerial Managua Manama manatee Manchester Manchuria mandamus mandarin mandate mandatory mandible mandrake mandrel mandrill mane maneuver Manfred manganese mange mangel mangle mango mangrove mangy Manhattan manhole mania maniac maniacal manic manicure manifest manifestation manifesto manifold manikin Manila manioc manipulable manipulate Manitoba mankind Manley Mann manna mannequin mannitol manometer manor manpower manse manservant Mansfield mansion manslaughter mantel mantelpiece mantic mantis mantissa mantle mantrap manual Manuel manufacture manumission manumit manumitted manure manuscript Manville many manzanita Mao Maori map maple mar marathon maraud marble Marc Marceau Marcel Marcello march Marcia Marco Marcus Marcy Mardi mare Margaret margarine Margery margin marginal marginalia Margo Marguerite maria Marianne Marie Marietta marigold marijuana Marilyn marimba Marin marina marinade marinate marine Marino Mario Marion marionette marital maritime marjoram Marjorie Marjory mark market marketeer marketplace marketwise Markham Markov Markovian marksman marksmen Marlboro Marlborough Marlene marlin Marlowe marmalade marmoset marmot maroon marque marquee marquess Marquette marquis marriage marriageable Marrietta Marriott marrow marrowbone marry Marseilles marsh Marsha marshal Marshall marshland marshmallow marshy marsupial mart marten martensite Martha martial Martian martin Martinez martingale martini Martinique Martinson Marty martyr martyrdom marvel marvelous Marvin Marx Mary Maryland marzipan mascara masculine maser Maseru mash mask masochism masochist mason Masonic Masonite masonry masque masquerade mass Massachusetts massacre massage masseur Massey massif massive mast masterful mastermind masterpiece mastery mastic mastiff mastodon mat match matchbook matchmake mate Mateo mater material materiel maternal maternity math mathematic mathematician Mathews Mathewson Mathias Mathieu Matilda matinal matinee matins Matisse matriarch matriarchal matriarchy matrices matriculate matrilineal matrimonial matrimony matrix matroid matron Matson Matsumoto matte Matthew mattock mattress Mattson maturate mature maudlin maul Maureen Maurice Mauricio Maurine Mauritania Mauritius mausoleum mauve maverick Mavis maw mawkish Mawr max maxim maxima maximal Maximilian maximum Maxine maxwell Maxwellian may Maya mayapple maybe Mayer Mayfair Mayflower mayfly mayhem Maynard Mayo mayonnaise mayor mayoral mayst Mazda maze mazurka MBA Mbabane McAdams McAllister McBride McCabe McCall McCallum McCann McCarthy McCarty McCauley McClain McClellan McClure McCluskey McConnel McConnell McCormick McCoy McCracken McCullough McDaniel McDermott McDonald McDonnell McDougall McDowell McElroy McFadden McFarland McGee McGill McGinnis McGovern McGowan McGrath McGraw McGregor McGuire McHugh McIntosh McIntyre McKay McKee McKenna McKenzie McKeon McKesson McKinley McKinney McKnight McLaughlin McLean McLeod McMahon McMillan McMullen McNally McNaughton McNeil McNulty McPherson MD me mead meadow meadowland meadowlark meadowsweet meager meal mealtime mealy mean meander meaningful meant meantime meanwhile measle measure meat meaty Mecca mechanic mechanism mechanist mecum medal medallion meddle Medea Medford media medial median mediate medic medicate Medici medicinal medicine medico mediocre mediocrity meditate Mediterranean medium medlar medley Medusa meek meet meetinghouse Meg megabit megabyte megahertz megalomania megalomaniac megalopolis megaton megavolt megawatt megaword megohm Meier Meiji meiosis Meistersinger Mekong Mel melamine melancholy Melanesia melange Melanie melanin melanism melanoma Melbourne Melcher meld melee Melinda meliorate Melissa Mellon mellow melodic melodious melodrama melodramatic melody melon Melpomene melt meltdown Melville Melvin member membrane memento memo memoir memorabilia memorable memoranda memorandum memorial memory Memphis men menace menagerie menarche mend mendacious mendacity Mendel mendelevium Mendelian Mendelssohn Menelaus menfolk menhaden menial meningitis meniscus Menlo Mennonite menopausal menopause Menorca menstrual menstruate mensurable mensuration mental mention mentor menu Menzies meow Mephistopheles mercantile Mercator Mercedes mercenary mercer merchandise merchant merciful Merck mercurial mercuric mercury mercy mere Meredith meretricious merganser merge meridian meridional meringue merit meritorious Merle merlin mermaid Merriam Merrill Merrimack merriment Merritt merry merrymake Mervin mesa mescal mescaline mesenteric mesh mesmeric mesoderm meson Mesopotamia Mesozoic mesquite mess message messenger Messiah messiah messianic messieurs Messrs messy mestizo met metabole metabolic metabolism metabolite metal metallic metalliferous metallography metalloid metallurgic metallurgist metallurgy metalwork metamorphic metamorphism metamorphose metamorphosis metaphor metaphoric metazoa metazoan Metcalf mete meteor meteoric meteorite meteoritic meteorology meter methacrylate methane methanol methionine method methodic methodology Methuen Methuselah methyl methylene meticulous metier metonymy metric metro metronome metropolis metropolitan mettle mettlesome Metzler mew Mexican Mexico Meyer mezzanine mezzo mi Miami miaow miasma miasmal mica mice Michael Michaelangelo Michel Michelangelo Michele Michelin Michelson michigan Mickelson Mickey Micky micro microbe microbial microcosm micrography micron Micronesia microscopy mid Midas midband midday middle Middlebury middleman middlemen Middlesex Middleton Middletown middleweight midge midget midland midmorn midnight midpoint midrange midscale midsection midshipman midshipmen midspan midst midstream midterm midway midweek Midwest Midwestern midwife midwinter midwives midyear mien miff mig might mightn't mighty mignon migrant migrate migratory Miguel mike mila Milan milch mild mildew Mildred mile mileage Miles milestone milieu militant militarism militarist military militate militia militiaman militiamen milk milkweed milky mill Millard millenarian millenia millennia millennium millet Millie Millikan millinery million millionaire millionfold millionth millipede millstone milord milt Milton Miltonic Milwaukee mimeograph mimesis mimetic Mimi mimic mimicked mimicking mimicry mimosa min minaret mince mincemeat mind Mindanao mindful mine minefield mineral mineralogy Minerva minestrone minesweeper mingle mini miniature minicomputer minim minima minimal minimax minimum minion ministerial ministry mink Minneapolis Minnesota Minnie minnow Minoan minor Minos minot Minotaur Minsk Minsky minstrel minstrelsy mint minuend minuet minus minuscule minute minuteman minutemen minutiae Miocene Mira miracle miraculous mirage Miranda mire Mirfak Miriam mirror mirth misanthrope misanthropic miscegenation miscellaneous miscellany mischievous miscible miscreant miser misery misnomer misogynist misogyny miss misshapen missile mission missionary Mississippi Mississippian missive Missoula Missouri Missy mist mistletoe mistress misty MIT Mitchell mite miterwort mitigate mitochondria mitosis mitral mitre mitt mitten mix mixture mixup Mizar MN mnemonic MO moan moat mob mobcap Mobil mobile mobility mobster moccasin mocha mock mockernut mockery mockingbird mockup modal mode model modem moderate modern modest Modesto modesty modicum modify modish modular modulate module moduli modulo modulus Moe Moen Mogadiscio Moghul Mohammed Mohammedan Mohawk Mohr moiety Moines moire Moiseyev moist moisten moisture molal molar molasses mold Moldavia moldboard moldy mole molecular molecule molehill molest Moliere Moline Moll Mollie mollify mollusk Molly mollycoddle Moloch molt molten Moluccas molybdate molybdenite molybdenum moment momenta momentary momentous momentum mommy Mona Monaco monad monadic monarch monarchic monarchy Monash monastery monastic monaural Monday monel monetarism monetary money moneymake moneywort Mongolia mongoose monic Monica monies monitor monitory monk monkey monkeyflower monkish Monmouth Monoceros monochromator monocular monogamous monogamy monolith monologist monologue monomer monomeric monomial Monongahela monopoly monotonous monotreme monoxide Monroe Monrovia Monsanto monsieur monsoon monster monstrosity monstrous Mont montage Montague Montana Montclair monte Montenegrin Monterey Monteverdi Montevideo Montgomery month Monticello Montmartre Montpelier Montrachet Montreal Monty monument moo mooch mood moody moon moonbeam Mooney moonlight moonlit moor Moore Moorish moose moot mop moraine moral morale Moran morass moratorium Moravia morbid more morel Moreland moreover Moresby Morgan morgen morgue Moriarty moribund Morley Mormon morn Moroccan Morocco moron morose morpheme morphemic morphine morphism morphology morphophonemic Morrill morris Morrison Morrissey Morristown morrow Morse morsel mort mortal mortar mortem mortgage mortgagee mortgagor mortician mortify mortise Morton mortuary mosaic Moscow Moser Moses Moslem mosque mosquito mosquitoes moss mossy most mot motel motet moth mother motherland motif motion motivate motive motley motor motorcade motorcar motorcycle Motorola mottle motto mould Moulton mound mount mountain mountaineer mountainous mountainside mountaintop mountebank mourn mournful mouse mousse moustache mousy mouth mouthful mouthpart mouthpiece Mouton move movie mow Moyer Mozart mozzarella MPH Mr Mrs Ms m's Mt mu much mucilage muck mucosa mucus mud Mudd muddle muddlehead muddy mudguard mudhole mudsling Mueller Muenster muezzin muff muffin muffle mug mugging muggy mugho Muir Mukden mukluk mulatto mulberry mulch mulct mule mulish mull mullah mullein Mullen mulligan mulligatawny mullion multi Multics multifarious multinomial multiple multiplet multiplex multiplexor multiplicand multiplication multiplicative multiplicity multitude multitudinous mum mumble Mumford mummify mummy munch Muncie mundane mung Munich municipal munificent munition Munson muon Muong mural murder murderous muriatic Muriel murk murky murmur Murphy Murray murre Muscat muscle Muscovite Muscovy muscular musculature muse museum mush mushroom mushy music musicale musician musicology musk Muskegon muskellunge musket muskmelon muskox muskoxen muskrat musky muslim muslin mussel must mustache mustachio mustang mustard mustn't musty mutagen mutandis mutant mutate mutatis mute mutilate mutineer mutiny mutt mutter mutton mutual mutuel Muzak Muzo muzzle my Mycenae Mycenaean mycobacteria mycology mycoplasma mycorrhiza myel myeline myeloid Myers mylar mynah Mynheer myocardial myocardium myofibril myoglobin myopia myopic myosin Myra myriad Myron myrrh myrtle myself Mysore mysterious mystery mystic mystify mystique myth mythic mythology n NAACP nab Nabisco Nadine nadir nag Nagasaki nagging Nagoya Nagy naiad nail Nair Nairobi naive naivete Nakayama naked name nameable nameplate namesake Nan Nancy Nanette Nanking nanosecond Nantucket Naomi nap napkin Naples Napoleon Napoleonic Narbonne narcissist narcissus narcosis narcotic Narragansett narrate narrow narrowminded narwhal nary NASA nasal nascent Nash Nashua Nashville Nassau nasturtium nasty Nat natal Natalie Natchez Nate Nathan Nathaniel nation nationwide native NATO natty natural nature naturopath naughty nausea nauseate nauseum nautical nautilus Navajo naval nave navel navigable navigate navy nawab nay Nazarene Nazareth Nazi Nazism NBC NBS NC NCAA NCO NCR ND Ndjamena ne Neal Neanderthal Neapolitan near nearby nearsighted neat neater neath Nebraska Nebuchadnezzar nebula nebulae nebular nebulous necessary necessitate necessity neck necklace neckline necktie necromancer necromancy necromantic necropsy necrosis necrotic nectar nectareous nectarine nectary Ned nee need needful needham needle needlepoint needn't needy nefarious Neff negate neglect negligee negligent negligible negotiable negotiate Negro Negroes Negroid Nehru neigh Neil neither Nell Nellie Nelsen Nelson nematocyst nematode nemesis neo neoclassic neodymium neolithic neologism neon neonatal neonate neophyte neoprene neoteny Nepal nepenthe nephew nepotism nepotistic Neptune neptunium nereid Nero nerve nervous Ness nest nestle Nestor net nether Netherlands netherworld nettle nettlesome network Neumann neural neuralgia neurasthenic neuritis neuroanatomic neuroanatomy neuroanotomy neurology neuromuscular neuron neuronal neuropathology neurophysiology neuropsychiatric neuroses neurosis neurotic neuter neutral neutrino neutron neutronium Neva Nevada never nevertheless Nevins new Newark Newbold newborn Newcastle newcomer newel Newell newfound Newfoundland newline newlywed Newman Newport newsboy newscast newsletter newsman newsmen newspaper newspaperman newspapermen newsreel newsstand Newsweek newt newton Newtonian next Nguyen NH niacin Niagara Niamey nib nibble Nibelung Nicaragua nice nicety niche Nicholas Nicholls Nichols Nicholson nichrome nick nickel nickname Nicodemus Nicosia nicotinamide nicotine niece Nielsen Nielson Nietzsche nifty Niger Nigeria niggardly nigger niggle nigh night nightcap nightclub nightdress nightfall nightgown nighthawk nightingale nightmare nightmarish nightshade nightshirt nighttime NIH nihilism nihilist Nikko Nikolai nil Nile nilpotent nimble nimbus NIMH Nina nine ninebark ninefold nineteen nineteenth ninetieth ninety ninetyfold Nineveh ninth Niobe niobium nip nipple Nippon nirvana nit nitpick nitrate nitric nitride nitrite nitrogen nitrogenous nitroglycerine nitrous nitty Nixon NJ NM NNE NNW no NOAA Noah nob Nobel nobelium noble nobleman noblemen noblesse nobody nobody'd nocturnal nocturne nod nodal node nodular nodule Noel Noetherian noise noisemake noisome noisy Nolan Noll nolo nomad nomadic nomenclature nominal nominate nominee nomogram nomograph non nonce nonchalant nondescript none nonetheless nonogenarian nonsensic noodle nook noon noontime noose nor Nora Nordhoff Nordic Nordstrom Noreen Norfolk norm Norma normal normalcy Norman Normandy normative Norris Norse north Northampton northbound northeast northeastern northerly northern northernmost northland Northrop Northrup Northumberland northward northwest northwestern Norton Norwalk Norway Norwegian Norwich nose nosebag nosebleed nostalgia nostalgic Nostradamus Nostrand nostril nosy not notary notate notch note notebook noteworthy nothing notice noticeable notify notion notocord notoriety notorious Notre Nottingham notwithstanding Nouakchott nought noun nourish nouveau Nov nova novae Novak novel novelty November novice novitiate novo Novosibirsk now nowadays nowhere nowise noxious nozzle NRC nroff n's NSF NTIS nu nuance Nubia nubile nucleant nuclear nucleate nuclei nucleic nucleoli nucleolus nucleon nucleotide nucleus nuclide nude nudge nudibranch nugatory nugget nuisance null nullify Nullstellensatz numb numbly numerable numeral numerate numeric numerology numerous numinous numismatic numismatist nun nuptial nurse nursery nurturant nurture nut nutate nutcrack nuthatch nutmeg nutria nutrient nutrition nutritious nutritive nutshell nuzzle NV NW NY NYC nylon nymph nymphomania nymphomaniac Nyquist NYU o oaf oak oaken Oakland Oakley oakwood oar oases oasis oat oatcake oath oatmeal obduracy obdurate obedient obeisant obelisk Oberlin obese obey obfuscate obfuscatory obituary object objectify objector objet oblate obligate obligatory oblige oblique obliterate oblivion oblivious oblong obnoxious oboe oboist O'Brien obscene obscure obsequious obsequy observant observation observatory observe obsess obsession obsessive obsidian obsolescent obsolete obstacle obstetric obstetrician obstinacy obstinate obstruct obstruent obtain obtrude obtrusive obtuse obverse obviate obvious ocarina occasion occident occidental occipital occlude occlusion occlusive occult occultate occupant occupation occupy occur occurred occurrent occurring ocean Oceania oceanic oceanographer oceanography oceanside ocelot o'clock O'Connell O'Connor Oct octagon octagonal octahedra octahedral octahedron octal octane octant octave Octavia octennial octet octile octillion October octogenarian octopus octoroon ocular odd oddball ode O'Dell Odessa Odin odious odium odometer O'Donnell odorous O'Dwyer Odysseus odyssey oedipal Oedipus oenology o'er oersted of off offal offbeat Offenbach offend offensive offer offertory offhand office officeholder officemate official officialdom officiate officio officious offload offprint offsaddle offset offsetting offshoot offshore offspring offstage oft often oftentimes Ogden ogle ogre ogress oh O'Hare Ohio ohm ohmic ohmmeter oil oilcloth oilman oilmen oilseed oily oint Ojibwa OK okapi okay Okinawa Oklahoma okra Olaf Olav old olden Oldenburg Oldsmobile oldster Olduvai oldy oleander O'Leary olefin oleomargarine olfactory Olga oligarchic oligarchy Oligocene oligoclase oligopoly Olin olive Olivetti Olivia Olivier olivine Olsen Olson Olympia Olympic Omaha Oman ombudsman ombudsperson omega omelet omen omicron ominous omission omit omitted omitting omnibus omnipotent omnipresent omniscient omnivore omnivorous on once oncology oncoming one Oneida O'Neill onerous oneself onetime oneupmanship ongoing onion onlooker onlooking only onomatopoeia onomatopoeic Onondaga onrush onrushing onset onslaught Ontario onto ontogeny ontology onus onward onyx oocyte oodles ooze opacity opal opalescent opaque OPEC Opel open opera operable operand operant operate operatic operetta operon Ophiucus opiate opinion opinionate opium opossum Oppenheimer opponent opportune opposable oppose opposite opposition oppress oppression oppressive oppressor opprobrium opt opthalmic opthalmology optic optima optimal optimism optimist optimum option optoacoustic optoisolate optometrist optometry opulent opus or oracle oracular oral orange orangeroot orangutan orate oratoric oratorio oratory orb orbit orbital Orca orchard orchestra orchestral orchestrate orchid orchis ordain ordeal order ordinal ordinance ordinary ordinate ordnance ore oregano Oregon Oresteia Orestes organ organdy organic organismic organometallic orgasm orgiastic orgy orient oriental orifice origami origin original originate Orin Orinoco oriole Orion Orkney Orlando Orleans ornament ornamentation ornate ornery ornithology orography Orono orphan orphanage Orpheus Orphic Orr Ortega orthant orthicon orthoclase orthodontic orthodontist orthodox orthodoxy orthogonal orthography orthonormal orthopedic orthophosphate orthorhombic Orville Orwell Orwellian o's Osaka Osborn Osborne Oscar oscillate oscillatory oscilloscope Osgood O'Shea Oshkosh osier Osiris Oslo osmium osmosis osmotic osprey osseous ossify ostensible ostentation ostentatious osteology osteopath osteopathic osteopathy osteoporosis ostracism ostracod Ostrander ostrich O'Sullivan Oswald Othello other otherwise otherworld otiose Otis Ott Ottawa otter Otto Ottoman Ouagadougou ouch ought oughtn't ounce our ourselves oust out outermost outlandish outlawry outrageous ouvre ouzel ouzo ova oval ovary ovate oven ovenbird over overt overture Ovid oviduct oviform oviparous ovipositor ovoviviparous ovulate ovum ow owe Owens owl owlet owly own ox oxalate oxalic oxbow oxcart oxen oxeye Oxford oxidant oxidate oxide Oxnard Oxonian oxygen oxygenate oyster Ozark ozone p pa Pablo Pabst pace pacemake pacesetting pacific pacifism pacifist pacify pack package Packard packet pact pad paddle paddock paddy padlock padre paean pagan page pageant pageantry paginate pagoda paid pail pain Paine painful painstaking paint paintbrush pair pairwise Pakistan Pakistani pal palace palaeontology palate Palatine palazzi palazzo pale paleoanthropology Paleolithic Paleozoic Palermo Palestine palette palfrey palindrome palindromic palisade pall palladia Palladian palladium pallet palliate pallid palm palmate palmetto Palmolive Palmyra Palo Palomar palp palpate palsy Pam Pamela pampa pamper pamphlet pan panacea panama Panamanian pancake Pancho pancreas pancreatic panda Pandanus pandemic pandemonium pander Pandora pane panel pang Pangaea panhandle panic panicked panicking panicky panicle panjandrum panoply panorama panoramic pansy pant pantaloon pantheism pantheist pantheon panther pantomime pantomimic pantothenic pantry panty Paoli pap papa papacy papal papaw paper paperback paperweight paperwork papery papillary papoose Pappas pappy paprika Papua papyri papyrus par parabola parabolic paraboloid paraboloidal parachute parade paradigm paradigmatic paradise paradox paradoxic paraffin paragon paragonite paragraph Paraguay Paraguayan parakeet paralinguistic parallax parallel parallelepiped parallelogram paralysis paralytic paramagnet paramagnetic parameter paramilitary paramount Paramus paranoia paranoiac paranoid paranormal parapet paraphernalia paraphrase parapsychology parasite parasitic parasol parasympathetic paratroop paraxial parboil parcel parch pardon pare paregoric parent parentage parental parentheses parenthesis parenthetic Pareto pariah parimutuel Paris parish parishioner Parisian park parka Parke Parkinson parkish parkland parkway parlance parlay parley parliament parliamentarian parliamentary Parmesan parochial parody parole parolee paroxysm parquet Parr Parrish parrot parry parse Parsi Parsifal parsimonious parsimony parsley parsnip parson parsonage part partake Parthenon Parthia partial participant participate participle particle particular particulate partisan partition partner partook partridge party parvenu Pasadena Pascal paschal pasha Paso pass passage passageway Passaic passarine passband passbook passe passenger passerby passim passion passionate passivate passive Passover passport password past paste pasteboard pastel pasteup Pasteur pastiche pastime pastor pastoral pastry pasture pasty pat Patagonia patch patchwork patchy pate patent patentee pater paternal paternoster Paterson path pathbreaking pathetic pathogen pathogenesis pathogenic pathology pathos pathway patient patina patio patois patriarch patriarchal patriarchy Patrice Patricia patrician Patrick patrilineage patrilineal patrimonial patrimony patriot patriotic patristic patrol patrolled patrolling patrolman patrolmen patron patronage patroness Patsy pattern Patterson Patti Patton patty paucity Paul Paula Paulette Pauli Pauline Paulo Paulsen Paulson Paulus paunch paunchy pauper pause pavanne pave pavilion Pavlov Pavlovian paw pawn pawnbroker pawnshop pawpaw Pawtucket pax pay paycheck payday payload paymaster Payne payoff payroll Paz PBS PDP pea Peabody peace peaceable peaceful peacemake peacetime peach Peachtree peacock peafowl peahen peak peaky peal Peale peanut pear Pearce pearl pearlite pearlstone Pearson peasant Pease peat pebble pecan peccary peck Pecos pectoral pectoralis peculate peculiar pecuniary pedagogic pedagogue pedagogy pedal pedant pedantic pedantry peddle pedestal pedestrian pediatric pediatrician pedigree pediment Pedro pee peek peel peep peephole peepy peer peg Pegasus pegboard pegging Peggy pejorative Peking pelagic Pelham pelican pellagra pellet pellucid Peloponnese pelt peltry pelvic pelvis Pembroke pemmican pen penal penalty penance penates pence penchant pencil pencilled pend pendant pendulous pendulum Penelope penetrable penetrate penguin Penh penicillin peninsula peninsular penis penitent penitential penitentiary penman penmen Penn penna pennant Pennsylvania penny pennyroyal Penrose Pensacola pension pensive pent pentagon pentagonal pentagram pentane Pentateuch pentatonic Pentecost pentecostal penthouse penultimate penumbra penumbral penurious penury peon peony people Peoria pep peppercorn peppergrass peppermint pepperoni peppery peppy Pepsi PepsiCo peptide per perceive percent percentage percentile percept perceptible perception perceptive perceptual perch perchance perchlorate Percival percolate percussion percussive Percy perdition peregrine peremptory perennial Perez perfect perfectible perfidious perfidy perforate perforce perform performance perfume perfumery perfunctory perfusion Pergamon perhaps Periclean Pericles peridotite perigee perihelion peril Perilla perilous perimeter period periodic peripatetic peripheral periphery periphrastic periscope perish peritectic periwinkle perjure perjury perk Perkins perky Perle permafrost permalloy permanent permeable permeate Permian permissible permission permissive permit permitted permitting permutation permute pernicious peroxide perpendicular perpetrate perpetual perpetuate perpetuity perplex perquisite Perry persecute persecution persecutory Perseid Persephone Perseus perseverant persevere Pershing Persia persiflage persimmon persist persistent person persona personage personal personify personnel perspective perspicacious perspicacity perspicuity perspicuous perspiration perspire persuade persuasion persuasive pert pertain Perth pertinacious pertinent perturb perturbate Peru perusal peruse Peruvian pervade pervasion pervasive perverse perversion pervert pessimal pessimism pessimist pessimum pest peste pesticide pestilent pestilential pestle pet petal Pete peter Petersburg Petersen Peterson petiole petit petite petition petrel petri petrify petrochemical petroglyph petrol petroleum petrology petticoat petty petulant petunia Peugeot pew pewee pewter pfennig Pfizer pH phage phagocyte phalanger phalanges phalanx phalarope phantasm phantasy phantom pharmaceutic pharmacist pharmacology pharmacopoeia pharmacy phase Ph.D PhD pheasant Phelps phenol phenolic phenomena phenomenal phenomenology phenomenon phenotype phenyl phenylalanine pheromone phi Phil Philadelphia philanthrope philanthropic philanthropy philharmonic Philip Philippine Philistine Phillip philodendron philology philosoph philosophic philosophy Phipps phloem phlox phobic Phobos phoebe Phoenicia phoenix phon phone phoneme phonemic phonetic phonic phonograph phonology phonon phony phosgene phosphate phosphide phosphine phosphite phosphor phosphoresce phosphorescent phosphoric phosphorous phosphorus phosphorylate photo photogenic photography photolysis photolytic photometry photon phrase phrasemake phraseology phthalate phycomycetes phyla Phyllis phylogenetic phylogeny phylum physic physician physiochemical physiognomy physiology physiotherapist physiotherapy physique phytoplankton pi pianissimo pianist piano pianoforte piazza pica Picasso picayune Piccadilly piccolo pick pickaxe pickerel Pickering picket Pickett Pickford pickle Pickman pickoff pickup picky picnic picnicked picnicker picnicking picofarad picojoule picosecond Pict pictorial picture picturesque piddle pidgin pie piece piecemeal piecewise Piedmont pier pierce Pierre Pierson pietism piety piezoelectric pig pigeon pigeonberry pigeonfoot pigeonhole pigging piggish piggy pigment pigmentation pigpen pigroot pigskin pigtail pike Pilate pile pilewort pilfer pilferage pilgrim pilgrimage pill pillage pillar pillory pillow Pillsbury piloerection pilot pimp pimple pin pinafore pinball pincer pinch pincushion pine pineapple Pinehurst ping pinhead pinhole pinion pink pinkie pinkish pinnacle pinnate pinniped pinochle pinpoint pinscher Pinsky pint pintail pinto pinwheel pinxter pion pioneer Piotr pious pip pipe pipeline pipette pipetting pipsissewa piquant pique piracy Piraeus pirate pirogue pirouette pirouetting Piscataway Pisces piss pistachio pistol pistole piston pit pitch pitchblende pitchfork pitchstone piteous pitfall pith pithy pitiable pitiful pitman Pitney Pitt Pittsburgh Pittsfield Pittston pituitary pity Pius pivot pivotal pixel pixy Pizarro pizza pizzicato Pl placate placater place placeable placebo placeholder placemat placenta placental placid plagiarism plagiarist plagioclase plague plaguey plaid plain Plainfield plaintiff plaintive plait plan planar Planck plane planeload planet planetaria planetarium planetary planetesimal planetoid plank plankton planoconcave planoconvex plant plantain plantation plaque plasm plasma plasmid plasmon plaster plastic plastisol plastron plat plate plateau platelet platen platform platinum platitude platitudinous Plato platonic Platonism Platonist platoon Platte platypus plaudit plausible play playa playback playboy playful playground playhouse playmate playoff playpen playroom plaything playtime playwright playwriting plaza plea plead pleasant please pleasure pleat plebeian plebian plebiscite plectrum pledge Pleiades Pleistocene plenary plenipotentiary plenitude plentiful plenty plenum plethora pleura pleural pleurisy Plexiglas pliable pliant plight Pliny Pliocene plod plop plot plover plow plowman plowmen plowshare ploy pluck plucky plug plugboard pluggable plugging plum plumage plumb plumbago plumbate plume plummet plump plunder plunge plunk pluperfect plural plus plush plushy Plutarch Pluto pluton plutonium ply Plymouth plyscore plywood PM pneumatic pneumococcus pneumonia Po poach POBox pocket pocketbook pocketful Pocono pod podge podia podium Poe poem poesy poet poetic poetry pogo pogrom poi poignant Poincare poinsettia point pointwise poise poison poisonous Poisson poke pokerface pol Poland polar polarimeter Polaris polariscope polariton polarogram polarograph polarography Polaroid polaron pole polecat polemic police policeman policemen policewoman policy polio poliomyelitis polis polish Politburo polite politic politician politicking politico Polk polka polkadot poll Pollard pollen pollinate pollock polloi pollutant pollute pollution Pollux pollywog polo polonaise polonium polopony polyandrous polyandry polygamous polygamy polygon polygonal polygynous polygyny polyhedra polyhedral polyhedron Polyhymnia polymer polymerase polymeric polymorph polymorphic Polynesia polynomial Polyphemus polyphony polyploidy polysaccharide polysemous polysemy polytechnic polytope polytypy pomade pomegranate pomelo pomology Pomona pomp pompadour pompano Pompeii pompey pompon pomposity pompous Ponce Ponchartrain poncho pond ponder ponderosa ponderous pong pont Pontiac pontiff pontific pontificate pontification pony pooch poodle pooh pool Poole poop poor pop pope popish poplar poplin poppy populace popular populate populism populist populous porcelain porch porcine porcupine pore pork pornographer pornography porosity porous porphyry porpoise porridge port portage portal Porte portend portent portentous porterhouse portfolio Portia portico portland portmanteau Porto portrait portraiture portray portrayal Portsmouth Portugal Portuguese portulaca posable pose Poseidon poseur posey posh posit position positive positron Posner posse posseman possemen possess possession possessive possessor possible possum post postage postal postcard postcondition postdoctoral posterior posteriori posterity postfix postgraduate posthumous postlude postman postmark postmaster postmen postmodern postmortem postmultiply postoperative postorder postpone postposition postprocess postprocessor postscript postulate posture postwar posy pot potable potash potassium potato potatoes potbelly potboil potent potentate potential potentiometer pothole potion potlatch Potomac potpourri potsherd pottery Potts pouch Poughkeepsie poultice poultry pounce pound pour pout poverty pow powder powderpuff powdery Powell power powerful powerhouse Poynting ppm PR practicable practical practice practise practitioner Pradesh Prado praecox pragmatic pragmatism pragmatist Prague prairie praise praiseworthy praline pram prance prank praseodymium Pratt Pravda pray prayerful pre preach preachy Precambrian precarious precedent precept precess precinct precious precipice precipitable precipitate precipitous precise precision preclude precocious precocity predacious predatory predecessor predicament predicate predict predictor predilect preempt preemption preemptive preemptor preen prefab prefatory prefect prefecture prefer preference preferential preferred preferring pregnant prehensile prejudice preliminary prelude premier premiere premise premium premonition Prentice prep preparation preparative preparator preparatory prepare preponderant preponderate preposterous prerogative Presbyterian Prescott prescription prescriptive presentation preservation preside president presidential press pressure prestidigitate prestige prestigious presto Preston presume presumption presumptive pretentious Pretoria pretty prevail prevalent prevention preventive previous prexy prey Priam price prick prickle pride priest priestess Priestley prig priggish prim prima primacy primal primary primate prime primeval primitive primordial primp primrose prince princess Princeton principal Principia principle print printmake printout prior priori priory Priscilla prism prismatic prison prissy pristine Pritchard privacy private privet privilege privy prize prizewinning pro probabilist probate probationary probe problem problematic probosces proboscis procaine procedural procedure proceed process procession processor proclaim proclamation proclivity procrastinate procreate procrustean Procrustes Procter proctor procure Procyon prod prodigal prodigious prodigy produce producible product Prof profane profess profession professor professorial proffer proficient profile profit profiteer profligate profound profundity profuse profusion progenitor progeny prognosis prognosticate programmable programmatic programmed programmer programming progress progression progressive prohibit prohibition prohibitive prohibitory project projectile projector prokaryote prokaryotic Prokofieff prolate proletariat proliferate prolific proline prolix prologue prolong prolongate prolusion prom promenade Promethean Prometheus promethium prominent promiscuity promiscuous promise promote promotion prompt promptitude promulgate prone prong pronghorn pronominal pronoun pronounce pronounceable pronto pronunciation proof proofread prop propaganda propagandist propagate propane propel propellant propelled propeller propelling propensity proper property prophecy prophesy prophet prophetic propionate propitiate propitious proponent proportion proportionate propos proposal propose proposition proprietary proprietor propriety proprioception proprioceptive propulsion propyl propylene prorate prorogue prosaic proscenium prosciutto proscribe proscription prose prosecute prosecution prosecutor proselyte Proserpine prosodic prosody prosopopoeia prospect prospector prospectus prosper prosperous prostaglandin prostate prosthetic prostitute prostitution prostrate protactinium protagonist protean protease protect protector protectorate protege protein proteolysis proteolytic protest protestant protestation prothonotary Protista proto protocol proton Protophyta protoplasm protoplasmic prototype prototypic Protozoa protozoan protract protractor protrude protrusion protrusive protuberant proud Proust prove proven provenance Provence proverb proverbial provide provident providential province provincial provision proviso provocateur provocation provocative provoke provost prow prowess prowl proximal proximate proximity proxy prude prudent prudential prudish prune prurient Prussia prussic pry p's psalm psalter pseudo pseudonym pseudonymous psi psych psyche psychiatric psychiatrist psychiatry psychic psycho psychoacoustic psychoanalysis psychoanalyst psychoanalytic psychobiology psychology psychometry psychopath psychopathic psychophysic psychophysiology psychopomp psychoses psychosis psychosomatic psychotherapeutic psychotherapist psychotherapy psychotic psyllium PTA ptarmigan pterodactyl Ptolemaic Ptolemy pub puberty pubescent public publication publish Puccini puck puckish pudding puddingstone puddle puddly pueblo puerile Puerto puff puffball puffery puffin puffy pug Pugh puissant puke Pulaski Pulitzer pull pullback pulley Pullman pullover pulmonary pulp pulpit pulsar pulsate pulse pulverable puma pumice pummel pump pumpkin pumpkinseed pun punch punctilio punctilious punctual punctuate puncture pundit punditry pungent Punic punish punitive Punjab Punjabi punk punky punster punt puny pup pupa pupae pupal pupate pupil puppet puppeteer puppy puppyish Purcell purchasable purchase Purdue pure puree purgation purgative purgatory purge purify Purina purine Puritan puritanic purl purloin purple purport purpose purposeful purposive purr purse purslane pursuant pursue pursuit purvey purveyor purview pus Pusan Pusey push pushbutton pushout pushover pushpin pushy pussy pussycat put putative putdown Putnam putrefaction putrefy putrid putt putty puzzle PVC Pygmalion pygmy pyknotic Pyle Pyongyang pyracanth pyramid pyramidal pyre Pyrex pyridine pyridoxine pyrimidine pyrite pyroelectric pyrolyse pyrolysis pyrometer pyrophosphate pyrotechnic pyroxene pyroxenite Pyrrhic Pythagoras Pythagorean python q Qatar QED q's qua quack quackery quad quadrangle quadrangular quadrant quadratic quadrature quadrennial quadric quadriceps quadrilateral quadrille quadrillion quadripartite quadrivium quadrupedal quadruple quadruplet quadrupole quaff quagmire quahog quail quaint quake Quakeress qualify qualitative quality qualm quandary quanta Quantico quantify quantile quantitative quantity quantum quarantine quark quarrel quarrelsome quarry quarryman quarrymen quart quarterback quartermaster quartet quartic quartile quarto quartz quartzite quasar quash quasi quasiparticle quaternary quatrain quaver quay queasy Quebec queen Queensland queer quell quench quern querulous query quest question questionnaire quetzal queue queueing Quezon quibble Quichua quick quicken quickie quicklime quicksand quicksilver quickstep quid quiescent quiet quietus quill quillwort quilt quince quinine Quinn quint quintessence quintessential quintet quintic quintillion quintuplet quintus quip quipped quipping Quirinal quirk quirky quirt quit quite Quito quitter quitting quiver Quixote quixotic quiz quizzed quizzes quizzical quizzing quo quod quonset quorum quota quotation quote quotient r rabat rabbet rabbi rabbinate rabbinical rabbit rabble rabid rabies Rabin raccoon race racemose racetrack raceway Rachel Rachmaninoff racial rack racket racketeer rackety racy radar Radcliffe radial radian radiant radiate radical radices radii radio radioactive radioastronomy radiocarbon radiochemical radiochemistry radiography radiology radiometer radiophysics radiosonde radiotherapy radish radium radius radix radon Rae Rafael Rafferty raffia raffish raft rag rage ragging ragout Ragusan ragweed raid rail railbird railhead raillery railroad railway rain rainbow raincoat raindrop rainfall rainstorm rainwater rainy raise raisin raj rajah rake rakish Raleigh rally Ralph Ralston ram Ramada Raman ramble rambunctious ramify Ramo ramp rampage rampant rampart ramrod Ramsey ramshackle ran ranch rancho rancid rancorous Rand Randall Randolph random randy rang range rangeland Rangoon rangy Ranier rank Rankin Rankine rankle ransack ransom rant Raoul rap rapacious rapacity rape Raphael rapid rapier rapport rapprochement rapt raptor raptorial rapture rare rarefy Raritan rasa rascal rash Rasmussen rasp raspberry raster Rastus rat rata rate rater rather ratify ratio ratiocinate rationale rattail rattle rattlesnake raucous Raul raunchy ravage rave ravel raven ravenous ravine ravish raw rawboned rawhide Rawlinson ray Rayleigh Raymond Raytheon raze razor razorback RCA R&D Rd re reach reactant reactionary read readout ready Reagan real realm realtor realty ream reap rear reason reave reb Rebecca rebel rebellion rebellious rebuke rebuttal recalcitrant receipt receive receptacle reception receptive receptor recess recessive recherche Recife recipe recipient reciprocal reciprocate reciprocity recital recitative reck reckon reclamation recline recluse reclusive recompense reconcile recondite reconnaissance recovery recriminate recrudescent recruit rectangle rectangular rectifier rectify rectilinear rectitude rector rectory recumbent recuperate recursion recusant recuse red redact redactor redbird redbud redcoat redden reddish redemption redemptive redhead Redmond redneck redolent redound redpoll redshank redstart Redstone redtop reduce reducible reductio redundant redwood reed reedbuck reedy reef reek reel Reese refectory refer referee refereeing referenda referendum referent referential referral referred referring reflect reflectance reflector reflexive reformatory refract refractometer refractory refrain refrigerate refuge refugee refusal refutation refute regal regalia regard regatta regent regime regimen regiment regimentation Regina Reginald region Regis registrable registrant registrar registration registry regress regression regressive regret regretful regrettable regretted regretting regular regulate regulatory Regulus regurgitate rehabilitate rehearsal Reich Reid reign Reilly reimbursable reimburse rein reindeer reinforce Reinhold reinstate reject rejoice rejoinder relaxation releasable relevant reliant relic relict relief relieve religion religiosity religious relinquish reliquary relish reluctant remainder remand Rembrandt remediable remedy remembrance Remington reminisce reminiscent remit remittance remnant remonstrate remorse remorseful remote removal remunerate Rena renaissance renal Renault rend render rendezvous rendition Rene renewal rennet Renoir renounce renovate renown Rensselaer rent rental renunciate rep repairman repairmen reparation repartee repeater repel repelled repellent repelling repentant repertoire repertory repetitious repetitive replenish replete replica replicate reportorial repository reprehensible representative repression repressive reprieve reprimand reprisal reprise reproach reptile reptilian republican repudiate repugnant repulsion repulsive reputation repute require requisite requisition rescind rescue resemblant resemble resentful reserpine reservation reservoir resident residential residual residuary residue residuum resignation resilient resiny resist resistant resistible resistive resistor resonate resorcinol resourceful respect respectful respiration respirator respiratory resplendent respond respondent response responsible responsive rest restaurant restaurateur restful restitution restive restoration restorative restraint restroom result resultant resume resumption resurgent resurrect resuscitate ret retain retaliate retaliatory retard retardant retardation retch retention retentive reticent reticulate reticulum retina retinal retinue retiree retribution retrieval retrieve retroactive retrofit retrofitted retrofitting retrograde retrogress retrogressive retrorocket retrospect retrovision returnee Reub Reuben Reuters rev revel revelation revelatory revelry revenge revenue rever reverberate revere reverend reverent reverie reversal reversible revert revisable revisal revival revive revocable revoke revolution revolutionary revolve revulsion revved revving Rex Reykjavik Reynolds rhapsodic rhapsody Rhea Rhenish rhenium rheology rheostat rhesus rhetoric rhetorician rheum rheumatic rheumatism Rhine rhinestone rhino rhinoceros rhizome rho Rhoda Rhode Rhodes Rhodesia rhodium rhododendron rhodolite rhodonite rhombi rhombic rhombus rhubarb rhyme rhythm rhythmic RI rib ribald ribbon riboflavin ribonucleic ribose ribosome Rica rice rich Richard Richardson Richfield Richmond Richter rick rickets Rickettsia rickety rickshaw Rico ricochet ricotta rid riddance ridden riddle ride ridge ridgepole Ridgway ridicule ridiculous Riemann Riemannian rife riffle rifle rifleman riflemen rift rig Riga Rigel rigging Riggs right righteous rightful rightmost rightward rigid rigorous Riley rill rilly rim rime rimy Rinehart ring ringlet ringside rink rinse Rio Riordan riot riotous rip riparian ripe ripen Ripley ripoff ripple rise risen risible risk risky Ritchie rite Ritter ritual Ritz rival rivalry riven river riverbank riverfront riverine riverside rivet Riviera rivulet Riyadh RNA roach road roadbed roadblock roadhouse roadrunner roadside roadster roadway roam roar roast rob robbery robbin robe Robert Roberta Roberto Robertson robin Robinson robot robotics robust Rochester rock rockabye rockaway rockbound Rockefeller rocket Rockford Rockies Rockland Rockwell rocky rococo rod rode rodent rodeo Rodgers Rodney Rodriguez roe roebuck Roentgen Roger rogue roguish roil roister Roland role roll rollback rollick Rollins Roman romance Romanesque Romania Romano romantic Rome Romeo romp Romulus Ron Ronald rondo Ronnie rood roof rooftop rooftree rook rookie rooky room roomful roommate roomy Roosevelt Rooseveltian roost root rootstock rope ropy Rosa Rosalie rosary rose rosebud rosebush Roseland rosemary Rosen Rosenberg Rosenblum Rosenthal Rosenzweig Rosetta rosette Ross roster rostrum rosy rot Rotarian rotary rotate ROTC rote rotenone Roth Rothschild rotogravure rotor rototill rotten rotund rotunda rouge rough roughcast roughen roughish roughneck roughshod roulette round roundabout roundhead roundhouse roundoff roundtable roundup roundworm rouse Rousseau roustabout rout route routine rove row rowboat rowdy Rowe Rowena Rowland Rowley Roxbury Roy royal royalty Royce RPM r's RSVP Ruanda rub Rubaiyat rubbery rubbish rubble rubdown Rube Ruben rubicund rubidium Rubin rubric ruby ruckus rudder ruddy rude rudiment rudimentary Rudolf Rudolph Rudy Rudyard rue rueful ruffian ruffle rufous Rufus rug ruin ruination ruinous rule rum Rumania rumble rumen Rumford ruminant ruminate rummage rummy rump rumple rumpus run runabout runaway rundown rune rung Runge runic runneth runny Runnymede runoff runt runty runway Runyon rupee rupture rural ruse rush Rushmore rusk Russ Russell russet Russia Russo russula rust rustic rustle rustproof rusty rut rutabaga Rutgers Ruth ruthenium Rutherford ruthless rutile Rutland Rutledge rutty Rwanda Ryan Rydberg Ryder rye s sa sabbath sabbatical Sabina Sabine sable sabotage sabra sac saccharine sachem Sachs sack sacral sacrament Sacramento sacred sacrifice sacrificial sacrilege sacrilegious sacristan sacrosanct sad sadden saddle saddlebag Sadie sadism sadist Sadler safari safe safeguard safekeeping safety saffron sag saga sagacious sagacity sage sagebrush sagging Saginaw sagittal Sagittarius sago saguaro Sahara said Saigon sail sailboat sailfish sailor saint sake Sal salaam salacious salad salamander salami salary sale Salem Salerno salesgirl Salesian saleslady salesman salesmen salesperson salient Salina saline Salisbury Salish saliva salivary salivate Salk Salle sallow sally salmon salmonberry salmonella salon saloon saloonkeep salsify salt saltbush Salton saltwater salty salubrious salutary salutation salute salutory Salvador salvage salvageable salvation Salvatore salve salvo Sam samarium samba same Sammy Samoa samovar sample Sampson Samson Samuel Samuelson samurai San Sana sanatoria sanatorium Sanborn Sanchez Sancho sanctify sanctimonious sanction sanctity sanctuary sand sandal sandalwood sandbag sandblast Sandburg sanderling Sanderson sandhill Sandia sandman sandpaper sandpile sandpiper Sandra sandstone Sandusky sandwich sandy sane Sanford sang sangaree sanguinary sanguine sanguineous Sanhedrin sanicle sanitarium sanitary sanitate sank sans Sanskrit Santa Santayana Santiago Santo Sao sap sapiens sapient sapling saponify sapphire Sappho sappy saprophyte saprophytic sapsucker Sara Saracen Sarah Saran Sarasota Saratoga sarcasm sarcastic sarcoma sarcophagus sardine Sardinia sardonic Sargent sari sarong sarsaparilla sarsparilla sash sashay sashimi Saskatchewan Saskatoon sassafras sat satan satanic satellite satiable satiate satiety satin satire satiric satisfaction satisfactory satisfy saturable saturate saturater Saturday Saturn Saturnalia saturnine satyr sauce saucepan saucy Saud Saudi sauerkraut Saul Sault sauna Saunders saunter sausage saute sauterne savage savagery savanna Savannah savant save Saviour Savonarola savoy Savoyard savvy saw sawbelly sawdust sawfish sawfly sawmill sawtimber sawtooth sawyer sax saxifrage Saxon Saxony saxophone say SC scab scabbard scabious scabrous scad scaffold Scala scalar scald scale scallop scalp scaly scam scamp scan scandal scandalous Scandinavia scandium scant scanty scapegoat scapula scapular scar Scarborough scarce scare scarecrow scarf scarface scarify Scarlatti scarlet scarp Scarsdale scarves scary scat scathe scathing scatterbrain scattergun scaup scavenge scenario scene scenery scenic scent sceptic Schaefer Schafer Schantz schedule Scheherazade schelling schema schemata schematic scheme Schenectady scherzo Schiller schism schist schizoid schizomycetes schizophrenia schizophrenic Schlesinger schlieren Schlitz Schloss Schmidt Schmitt Schnabel schnapps Schneider Schoenberg Schofield scholar scholastic school schoolbook schoolboy schoolgirl schoolgirlish schoolhouse schoolmarm schoolmaster schoolmate schoolroom schoolteacher schoolwork schoolyard schooner Schottky Schroeder Schroedinger Schubert Schultz Schulz Schumacher Schumann Schuster Schuyler Schuylkill Schwab Schwartz Schweitzer Sci sciatica science scientific scientist scimitar scintillate scion scissor sclerosis sclerotic SCM scoff scold scoop scoot scope scopic scops scorch score scoreboard scorecard scoria scorn scornful Scorpio scorpion Scot scotch Scotia Scotland Scotsman Scotsmen Scott Scottish Scottsdale Scotty scoundrel scour scourge scout scowl scrabble scraggly scram scramble Scranton scrap scrapbook scrape scrappy scratch scratchy scrawl scrawny scream screech screechy screed screen screenful screenplay screw screwball screwbean screwdriver screwworm screwy scribble scribe Scribners scrim scrimmage Scripps script scription scriptural scripture scriptwriter scriven scroll scrooge scrotum scrounge scrub scrubby scruffy scrumptious scruple scrupulosity scrupulous scrutable scrutiny scuba scud scuff scuffle scull sculpin sculpt sculptor sculptural sculpture scum scurrilous scurry scurvy scuttle scutum Scylla scythe Scythia SD SE sea seabed seaboard Seaborg seacoast seafare seafood Seagram seagull seahorse seal sealant seam seaman seamen seamstress seamy Sean seance seaport seaquake sear search searchlight seashell seashore seaside season seasonal seat seater Seattle seaward seawater seaweed seaworthy sebaceous Sebastian sec secant secede secession seclude seclusion second secondary secondhand secrecy secret secretarial secretariat secretary secrete secretion secretive sect sectarian section sector secular secure sedan sedate sedentary seder sedge sediment sedimentary sedimentation sedition seditious seduce seduction seductive sedulous see seeable seed seedbed seedling seedy seeing seek seem seen seep seepage seersucker seethe seething segment segmentation Segovia segregant segregate Segundo Seidel seismic seismograph seismography seismology seize seizure seldom select selectman selectmen selector Selectric Selena selenate selenite selenium self selfadjoint selfish Selfridge Selkirk sell sellout Selma seltzer selves Selwyn semantic semaphore semblance semester semi seminal seminar seminarian seminary Seminole Semiramis Semite Semitic semper sen senate senatorial send Seneca Senegal senescent senile senior senor Senora senorita sensate sense sensible sensitive sensor sensory sensual sensuous sent sentence sentential sentient sentiment sentinel sentry Seoul sepal separable separate sepia Sepoy sept septa septate September septennial septic septillion septuagenarian septum sepulchral seq sequel sequent sequential sequester sequestration sequin sequitur Sequoia sera seraglio serape seraphim Serbia serenade serendipitous serendipity serene serf serge sergeant Sergei serial seriatim sericulture series serif serine serious sermon serology Serpens serpent serpentine serum servant serve service serviceable serviceberry serviceman servicemen serviette servile servitor servitude servo servomechanism sesame session set setback Seth Seton setscrew settle setup seven sevenfold seventeen seventeenth seventh seventieth seventy seventyfold sever several severalfold severalty severe Severn Seville sew sewage Seward sewerage sewn sex Sextans sextet sextic sextillion sexton sextuple sextuplet sexual sexy Seychelle Seymour sforzando shabby shack shackle shad shadbush shade shadflower shadow shadowy shady Shafer Shaffer shaft shag shagbark shagging shaggy shah shake shakeable shakedown shaken Shakespeare Shakespearean Shakespearian shako shaky shale shall shallot shallow shalom sham shaman shamble shame shameface shameful shampoo shamrock Shanghai shank Shannon shan't Shantung shanty shape Shapiro shard share sharecrop sharecropper shareholder Shari shark Sharon sharp Sharpe sharpen sharpshoot Shasta shatter shatterproof Shattuck shave shaven shaw shawl Shawnee shay she Shea sheaf shear Shearer sheath sheathe sheave shebang she'd shed Shedir Sheehan sheen sheep sheepherder sheepskin sheer sheet Sheffield sheik Sheila Shelby Sheldon shelf she'll shell Shelley shellfish shelter Shelton shelve Shenandoah shenanigan Shepard shepherd shepherdess Sheppard Sheraton sherbet Sheridan sheriff Sherlock Sherman Sherrill sherry Sherwin Sherwood shibboleth shield shift shifty shill Shiloh shim shimmy shin shinbone shine shingle Shinto shiny ship shipboard shipbuild shipbuilding shiplap Shipley shipload shipman shipmate shipmen shipshape shipwreck shipyard shire shirk Shirley shirt shirtmake shish shitepoke shiv Shiva shiver shivery Shmuel shoal shock Shockley shod shoddy shoe shoehorn shoelace shoemake shoestring shoji shone shoo shoofly shook shoot shop shopkeep shopworn shore shorebird shorefront shoreline short shortage shortcake shortcoming shortcut shorten shortfall shorthand shortish shortsighted shortstop Shoshone shot shotbush shotgun should shoulder shouldn't shout shove shovel show showboat showcase showdown showman showmen shown showpiece showplace showroom showy shrank shrapnel shred Shreveport shrew shrewd shrewish shriek shrift shrike shrill shrilly shrimp shrine shrink shrinkage shrive shrivel shroud shrove shrub shrubbery shrug shrugging shrunk shrunken Shu shuck shudder shuddery shuffle shuffleboard Shulman shun shunt shut shutdown shutoff shutout shuttle shuttlecock shy Shylock shyly sial SIAM Siamese Sian sib Siberia sibilant Sibley sibling sibyl sic Sicilian Sicily sick sickbed sicken sickish sickle sicklewort sickroom side sidearm sideband sideboard sidecar sidelight sideline sidelong sideman sidemen sidereal siderite sidesaddle sideshow sidestep sidestepped sidestepping sidetrack sidewalk sidewall sideway sidewinder sidewise sidle Sidney siege Siegel Siegfried Sieglinda Siegmund Siemens Siena sienna sierra siesta sieve sift sigh sight sightsee sightseeing sightseer sigma Sigmund sign signal signature signboard signet significant signify Signor Signora signpost Sikh Sikkim Sikorsky silage silane Silas silent silhouette silica silicate siliceous silicic silicide silicon silicone silicosis silk silken silkworm silky sill silly silo silt siltation siltstone silty silver Silverman silversmith silverware silvery sima simian similar simile similitude Simla simmer Simmons Simon Simonson simper simple simplectic simpleminded simpleton simplex simplicial simplicity simplify simplistic simply Simpson Sims simulate simulcast simultaneity simultaneous sin Sinai Sinbad since sincere Sinclair sine sinew sinewy sinful sing singable Singapore singe single singlehanded singleminded singlet singleton singsong singular sinh sinister sinistral sink sinkhole Sino Sinology sinter sinuous sinus sinusoid sinusoidal Sioux sip sir sire siren Sirius sis sisal siskin sister Sistine Sisyphean Sisyphus sit site situ situate situs siva six sixfold sixgun sixteen sixteenth sixth sixtieth sixty sixtyfold size sizzle skat skate skateboard skater skeet skein skeleta skeletal skeleton skeptic sketch sketchbook sketchpad sketchy skew ski skid skiddy skiff skill skillet skillful skim skimp skimpy skin skindive skinflint skinny skintight skip skipjack Skippy skirmish skirt skit skittle Skopje skulk skull skullcap skullduggery skunk sky Skye skyhook skyjack skylark skylight skyline skyrocket skyscrape skyward skywave skyway slab slack slacken sladang slag slain slake slam slander slanderous slang slant slap slapdash slapstick slash slat slate slater slaughter slaughterhouse Slav slave slavery Slavic slavish Slavonic slay sleazy sled sledge sledgehammer sleek sleep sleepwalk sleepy sleet sleety sleeve sleigh sleight slender slept sleuth slew slice slick slid slide slight slim slime slimy sling slingshot slink slip slippage slippery slipshod slit slither sliver slivery Sloan Sloane slob Slocum sloe slog slogan sloganeer slogging sloop slop slope sloppy slosh slot sloth slothful slouch slough Slovakia sloven Slovenia slow slowdown sludge slug slugging sluggish sluice slum slumber slump slung slunk slur slurp slurry slush slushy sly smack small Smalley smallish smallpox smalltime smart smash smattering smear smell smelly smelt smile smirk smite smith smithereens Smithfield Smithson smithy smitten smog smoke smokehouse smokescreen smokestack smoky smolder smooch smooth smoothbore smote smother Smucker smudge smudgy smug smuggle smut smutty Smyrna Smythe snack snafu snag snagging snail snake snakebird snakebite snakeroot snap snapback snapdragon snappish snappy snapshot snare snark snarl snatch snazzy sneak sneaky sneer sneeze snell snick Snider sniff sniffle snifter snigger snip snipe snippet snippy snivel snob snobbery snobbish snook snoop snoopy snore snorkel snort snotty snout snow snowball snowbank snowfall snowflake snowshoe snowstorm snowy snub snuff snuffle snug snuggle snuggly Snyder so soak soap soapstone soapsud soapy soar sob sober sobriety sobriquet Soc soccer sociable social societal Societe society socioeconomic sociolinguistic sociology sociometry sock socket sockeye Socrates Socratic sod soda sodden sodium sofa soffit Sofia soft softball softcover soften software softwood soggy soignee soil soiree sojourn Sol solace solar sold solder soldier soldiery sole solecism solemn solenoid solicit solicitation solicitor solicitous solicitude solid solidarity solidify soliloquy solipsism solitary soliton solitude solo Solomon Solon solstice soluble solute solution solvate solve solvent soma somal Somali Somalia somatic somber sombre some somebody somebody'll someday somehow someone someone'll someplace Somers somersault Somerset Somerville something sometime somewhat somewhere sommelier Sommerfeld somnolent son sonant sonar sonata song songbag songbird songbook songful sonic sonnet sonny Sonoma Sonora sonorant sonority sonorous Sony soon soot sooth soothe soothsay soothsayer sop sophia Sophie sophism sophisticate sophistry Sophoclean Sophocles sophomore sophomoric soprano sora sorb sorcery sordid sore Sorensen Sorenson sorghum sorority sorption sorrel sorrow sorrowful sorry sort sortie sou souffle sough sought soul soulful sound soundproof soup soupy sour sourberry source sourdough sourwood Sousa soutane south Southampton southbound southeast southeastern southern southernmost Southey southland southpaw southward southwest southwestern souvenir sovereign sovereignty soviet sovkhoz sow sowbelly sowbug sown soy soya soybean spa space spacecraft spacesuit spacetime spacious spade spaghetti Spain spalding span spandrel spangle Spaniard spaniel Spanish spar spare sparge spark sparkle Sparkman sparky sparling sparrow sparse Sparta spartan spasm spasmodic spastic spat spate spatial spatlum spatterdock spatula Spaulding spavin spawn spay speak speakeasy spear spearhead spearmint spec special speciate specie species specific specify specimen specious speck speckle spectacle spectacular spectator Spector spectra spectral spectrogram spectrograph spectrography spectrometer spectrophotometer spectroscope spectroscopic spectroscopy spectrum specular speculate sped speech speed speedboat speedometer speedup speedwell speedy spell spellbound Spencer Spencerian spend spent sperm spermatophyte spermatozoa spermatozoon Sperry spew sphagnum sphalerite sphere spheric spheroid spheroidal spherule sphinx sphygmomanometer Spica spice spicebush spicy spider spiderwort spidery Spiegel spigot spike spikenard spiky spill spillover spilt spin spinach spinal spindle spindly spine spinel spinnaker spinneret spinodal spinoff spinster spiny spiral spire spirit spiritual Spiro spirochaete Spirogyra spit spite spiteful spitfire spittle spitz splash splashy splat splay spleen spleenwort splendid splenetic splice spline splint splintery split splotch splotchy splurge splutter spoil spoilage Spokane spoke spoken spokesman spokesmen spokesperson sponge spongy sponsor spontaneity spontaneous spoof spook spooky spool spoon spoonful sporadic spore sport sportsman sportsmen sportswear sportswriter sportswriting sporty spot spotlight spotty spouse spout Sprague sprain sprang sprawl spray spread spree sprig sprightly spring springboard springe Springfield springtail springtime springy sprinkle sprint sprite sprocket Sproul sprout spruce sprue sprung spud spume spumoni spun spunk spunky spur spurge spurious spurn spurt sputnik sputter spy spyglass squabble squad squadron squalid squall squamous squander square squash squashberry squashy squat squatted squatter squatting squaw squawbush squawk squawroot squeak squeaky squeal squeamish squeegee squeeze squelch Squibb squid squill squint squire squirm squirmy squirrel squirt squishy Sri s's SSE SST SSW St stab stabile stable stableman stablemen staccato stack Stacy stadia stadium staff Stafford stag stage stagecoach stagnant stagnate stagy Stahl staid stain stair staircase stairway stairwell stake stalactite stalagmite stale stalemate Staley Stalin stalk stall stallion stalwart stamen Stamford stamina staminate stammer stamp stampede Stan stance stanch stanchion stand standard standby standeth Standish standoff standpoint standstill Stanford Stanhope stank Stanley stannic stannous Stanton stanza staph staphylococcus staple Stapleton star starboard starch starchy stardom stare starfish stargaze stark Starkey starlet starlight starling Starr starry start startle startup starvation starve stash stasis state Staten stater stateroom statesman statesmen statewide static stationarity stationary stationery stationmaster statistician Statler stator statuary statue statuesque statuette stature status statute statutory Stauffer staunch Staunton stave stay stead steadfast steady steak steal stealth stealthy steam steamboat steamy stearate stearic Stearns steed steel Steele steelmake steely Steen steep steepen steeple steeplebush steeplechase steer steeve Stefan Stegosaurus stein Steinberg Steiner stella stellar stem stench stencil stenographer stenography stenotype step stepchild Stephanie stephanotis Stephen Stephenson stepmother steppe steprelation stepson stepwise steradian stereo stereography stereoscopy sterile sterling stern sternal Sternberg Sterno sternum steroid stethoscope Stetson Steuben Steve stevedore Steven Stevenson stew steward stewardess Stewart stick stickle stickleback stickpin sticktight sticky stiff stiffen stifle stigma stigmata stile stiletto still stillbirth stillwater stilt stimulant stimulate stimulatory stimuli stimulus sting stingray stingy stink stinkbug stinkpot stinky stint stipend stipple stipulate stir Stirling stirrup stitch stoat stochastic stock stockade stockbroker stockholder Stockholm stockpile stockroom Stockton stocky stodgy stoic stoichiometry stoke Stokes stole stolen stolid stomach stomp stone stonecrop Stonehenge stonewall stoneware stonewort stony stood stooge stool stoop stop stopband stopcock stopgap stopover stoppage stopwatch storage store storefront storehouse storekeep storeroom Storey stork storm stormbound stormy story storyboard storyteller storytelling stout stove stow stowage stowaway strabismic strabismus straddle strafe straggle straight straightaway straighten straightforward straightway strain strait strand strange strangle strangulate strap strata stratagem strategic strategist strategy Stratford stratify stratosphere stratospheric Stratton stratum stratus Strauss straw strawberry strawflower stray streak stream streamline streamside street streetcar strength strengthen strenuous streptococcus streptomycin stress stressful stretch strewn striate stricken Strickland strict stricture stride strident strife strike strikebreak string stringent stringy strip stripe striptease strive striven strobe stroboscopic strode stroke stroll Strom Stromberg strong stronghold strongroom strontium strop strophe strove struck structural structure struggle strum strung strut strychnine Stuart stub stubble stubborn stubby stucco stuck stud Studebaker student studio studious study stuff stuffy stultify stumble stump stumpage stumpy stun stung stunk stunt stupa stupefy stupendous stupid stupor Sturbridge sturdy sturgeon Sturm stutter Stuttgart Stuyvesant Stygian style styli stylish stylites stylus stymie styrene Styrofoam Styx suave sub subject subjunctive sublimate subliminal submersible submit submittal submitted submitting subpoena subrogation subservient subsidiary subsidy subsist subsistent substantial substantiate substantive substituent substitute substitution substitutionary substrate subsume subterfuge subterranean subtle subtlety subtly subtrahend suburb suburbia subversive subvert succeed success successful succession successive successor succinct succubus succumb such suck suckle sucrose suction sud Sudan Sudanese sudden sudorific suds sue suet suey Suez suffer suffice sufficient suffix suffocate Suffolk suffrage suffragette suffuse sugar sugary suggest suggestible suggestion suggestive suicidal suicide suit suitcase suite suitor sukiyaki sulfa sulfanilamide sulfate sulfide sulfite sulfonamide sulfur sulfuric sulfurous sulk sulky sullen Sullivan sully sulphur sultan sultry sum sumac Sumatra Sumeria summand summary summate summer summertime summit summitry summon Sumner sumptuous Sumter sun sunbeam sunbonnet sunburn sunburnt Sunday sunder sundew sundial sundown sundry sunfish sunflower sung sunglasses sunk sunken sunlight sunlit sunny Sunnyvale sunrise sunscreen sunset sunshade sunshine sunshiny sunspot suntan suntanned suntanning SUNY sup super superannuate superb superbly supercilious superficial superfluity superfluous superintendent superior superlative superlunary supernatant supersede superstition superstitious supervene supervisory supine supplant supple supplementary supplicant supplicate supply support supposable suppose supposition suppress suppressible suppression suppressor supra supranational supremacy supreme supremum surah surcease surcharge sure surefire surety surf surface surfactant surfeit surge surgeon surgery surgical surjection surjective surly surmise surmount surname surpass surplus surprise surreal surrender surreptitious surrey surrogate surround surtax surtout surveillant survey surveyor survival survive survivor Sus Susan Susanne susceptance susceptible sushi Susie suspect suspend suspense suspension suspensor suspicion suspicious Sussex sustain sustenance Sutherland Sutton suture Suzanne suzerain suzerainty Suzuki svelte Svetlana SW swab swabby swag Swahili swain swallow swallowtail swam swami swamp swampland swampy swan swank swanky Swanson swap swarm swart Swarthmore Swarthout swarthy swastika swat swatch swath swathe sway Swaziland swear sweat sweatband sweater sweatpants sweatshirt sweatshop sweatsocks sweaty Swede Sweden Swedish Sweeney sweep sweepstake sweet sweetbread sweeten sweetheart sweetie sweetish swell swelt swelter Swenson swept swerve swidden swift swig swigging swill swim swimsuit swindle swine swing swingable swingy swipe swirl swirly swish swishy swiss switch switchback switchblade switchboard switchgear switchman switchmen Switzer Switzerland swivel swizzle swollen swoop sword swordfish swordplay swordtail swore sworn swum swung sybarite Sybil sycamore sycophant sycophantic Sydney syenite Sykes syllabi syllabic syllabify syllable syllabus syllogism syllogistic Sylow sylvan Sylvania Sylvester Sylvia symbiont symbiosis symbiote symbiotic symbol symbolic symmetry sympathetic sympathy symphonic symphony symplectic symposia symposium symptom symptomatic synagogue synapse synaptic synchronism synchronous synchrony synchrotron syncopate syndic syndicate syndrome synecdoche synergism synergistic synergy Synge synod synonym synonymous synonymy synopses synopsis synoptic syntactic syntax synthesis synthetic syphilis syphilitic Syracuse Syria syringa syringe syrinx syrup syrupy system systematic systemic systemwide syzygy Szilard t TA tab tabernacle table tableau tableaux tablecloth tableland tablespoon tablespoonful tablet tabletop tabloid taboo tabu tabula tabular tabulate tachinid tachometer tachyon tacit taciturn Tacitus tack tackle tacky Tacoma tact tactful tactic tactile tactual tad tadpole taffeta taffy taft tag tagging Tahiti Tahoe taiga tail tailgate taillight tailor tailspin tailwind taint Taipei Taiwan take taken takeoff takeover talc talcum tale talent talisman talismanic talk talkative talkie talky tall Tallahassee tallow tally tallyho Talmud Talmudic talon talus tam tamale tamarack tamarind tamarisk tambourine tame Tamil Tammany tamp Tampa tampon tan tanager Tanaka Tananarive tandem tang Tanganyika tangent tangential tangerine tangible tangle tango tangy tanh tank tankard tannin tansy tantalum Tantalus tantamount Tantric tantrum Tanya Tanzania tao tap tapa tape taper tapestry tapeworm tapioca tapir tapis tappa tappet taproot tar tara tarantara tarantula Tarbell tardy target tariff tarnish taro tarpaper tarpaulin tarpon tarry Tarrytown tarsier tart tartar Tartary Tarzan task taskmaster Tasmania Tass tassel taste tasteful tasting tasty tat tate tater tattle tattler tattletale tattoo tatty tau taught taunt Taurus taut tautology tavern taverna tawdry tawny tax taxa taxation taxi taxicab taxidermist taxidermy taxied taxiway taxon taxonomic taxonomist taxonomy taxpayer taxpaying Taylor tea teacart teach teacup teahouse teak teakettle teakwood teal team teammate teamster teamwork teapot tear teardrop tearful tease teasel teaspoon teaspoonful teat tech technetium technic technician Technion technique technology tectonic tecum Ted Teddy tedious tedium tee teeing teem teen teenage teensy teet teeth teethe teetotal Teflon Tegucigalpa Teheran Tehran tektite Tektronix Tel telecommunicate teleconference Teledyne Telefunken telegram telegraph telegraphy telekinesis telemeter teleology teleost telepathic telepathy telephone telephonic telephony telephoto telephotography teleprinter teleprocessing teleprompter telescope telescopic teletype teletypesetting teletypewrite televise television Telex tell telltale tellurium temerity temper tempera temperance temperate temperature tempest tempestuous template temple Templeton tempo temporal temporary tempt temptation temptress ten tenable tenacious tenacity tenant tend tendency tenderfoot tenderhearted tenderloin tendon tenebrous tenement tenet tenfold Tenneco Tennessee Tenney tennis Tennyson tenon tenor tense tensile tension tensor tenspot tent tentacle tentative tenth tenuous tenure tepee tepid teratogenic teratology terbium tercel Teresa term termcap terminable terminal terminate termini terminology terminus termite tern ternary Terpsichore terpsichorean Terra terrace terrain terramycin terrapin Terre terrestrial terrible terrier terrific terrify territorial territory terror terry terse tertiary Tess tessellate test testament testamentary testate testes testicle testicular testify testimonial testimony testosterone testy tetanus tete tether tetrachloride tetrafluoride tetragonal tetrahedra tetrahedral tetrahedron tetravalent Teutonic TEX Texaco Texan Texas text textbook textile Textron textual textural texture Thai Thailand Thalia thallium thallophyte than thank thankful thanksgiving that thatch that'd that'll thaw Thayer the Thea theatric Thebes thee theft their theism theist Thelma them thematic theme themselves then thence thenceforth theocracy theocratic Theodore Theodosian theologian theology theorem theoretic theoretician theorist theory therapeutic therapist therapy there thereabouts thereafter thereat thereby there'd therefor therefore therefrom therein there'll thereof thereon Theresa thereto theretofore thereunder thereupon therewith thermal thermionic thermistor thermo Thermofax thermophilic thermostat thesaurus these theses Theseus thesis thespian Thessalonian Thessaly theta Thetis they they'd they'll they're they've thiamin thick thicken thicket thickish thief thieves thieving thigh thimble thimbleful Thimbu thin thine thing think thinnish thiocyanate thiouracil third thirdhand thirst thirsty thirteen thirteenth thirtieth thirty thirtyfold this this'll thistle thistledown thither Thomas Thomistic Thompson Thomson thong Thor thoracic thorax Thoreau thoriate thorium thorn Thornton thorny thorough thoroughbred thoroughfare thoroughgoing Thorpe Thorstein those thou though thought thoughtful thousand thousandfold thousandth Thrace Thracian thrall thrash thread threadbare threat threaten three threefold threesome threonine thresh threshold threw thrice thrift thrifty thrill thrips thrive throat throaty throb throes thrombosis throne throng throttle through throughout throughput throw throwback thrown thrum thrush thrust Thruway Thuban thud thug thuggee Thule thulium thumb thumbnail thumbprint thump thunder thunderclap thundercloud thunderflower thunderous thundershower thunderstorm Thurman Thursday thus thwack thwart thy thyme thymine thymus thyratron thyroglobulin thyroid thyroidal thyronine thyrotoxic thyroxine thyself ti Tiber tibet Tibetan tibia tic tick ticket tickle ticklish tid tidal tidbit tide tideland tidewater tidy tie Tientsin tier Tiffany tift tiger tight tighten tightwad tigress Tigris til tilde tile till tilt tilth Tim timber timberland timbre time timeout timepiece timeshare timetable timeworn Timex timid Timon timothy tin Tina tincture tinder tine tinfoil tinge tingle tinker tinkle tinny tinsel tint tintype tiny Tioga tip tipoff Tipperary tipple tippy tipsy tiptoe tirade Tirana tire tiresome tissue tit Titan titanate titanic titanium tithe tithing titian titillate title titmice titmouse Tito titrate titular Titus tizzy TN TNT to toad toady toast tobacco Tobago Toby toccata today today'll Todd toddle toddy toe TOEFL toehold toenail toffee tofu tog together togging toggle Togo togs toil toilet toilsome tokamak token Tokyo told Toledo tolerable tolerant tolerate toll tollbooth tollgate tollhouse Tolstoy toluene Tom tomahawk tomato tomatoes tomb tombstone tome Tomlinson Tommie tommy tomography tomorrow Tompkins ton tonal tone tong tongue Toni tonic tonight tonk tonnage tonsil tonsillitis tony too toodle took tool toolkit toolmake toolsmith toot tooth toothache toothbrush toothpaste toothpick toothy tootle top topaz topcoat Topeka topgallant topheavy topic topmost topnotch topocentric topography topology toponym toponymy topple topsoil Topsy tor torah torch tore tori torn tornado toroid toroidal Toronto torpedo torpedoes torpid torpor torque torr Torrance torrent torrential torrid torsion torso tort tortoise tortoiseshell tortuous torture torus tory Toshiba toss tot total totalitarian tote totem totemic toto touch touchdown touchstone touchy tough tour tournament tousle tout tow toward towboat towel tower towhead towhee town townhouse Townsend townsman townsmen toxic toxicology toxin toy Toyota trace traceable tracery trachea tracheae track trackage tract tractor Tracy trade trademark tradeoff tradesman tradesmen tradition traffic trafficked trafficker trafficking trag tragedian tragedy tragic tragicomic trail trailblazer trailblazing trailhead trailside train trainee trainload trainman trainmen traipse trait traitor traitorous trajectory tram trammel tramp trample tramway trance tranquil tranquillity trans transact transalpine transatlantic transceiver transcend transcendent transcendental transconductance transcontinental transcribe transcript transcription transducer transduction transect transept transfer transferee transference transferor transferral transferred transferring transfinite transfix transform transformation transfusable transfuse transfusion transgress transgression transgressor transient transistor transit Transite transition transitive transitory translate transliterate translucent transmissible transmission transmit transmittable transmittal transmittance transmitted transmitter transmitting transmutation transmute transoceanic transom transonic transpacific transparent transpiration transpire transplant transplantation transport transportation transposable transpose transposition transship transshipping transudate Transvaal transversal transverse transvestite Transylvania trap trapezium trapezoid trapezoidal trash trashy Trastevere trauma traumatic travail travel travelogue traversable traversal traverse travertine travesty Travis trawl tray treacherous treachery tread treadle treadmill treason treasonous treasure treasury treat treatise treaty treble tree treetop trefoil trek trellis tremble tremendous tremolo tremor tremulous trench trenchant trencherman trenchermen trend trendy Trenton trepidation trespass tress trestle Trevelyan triable triad trial triangle triangular triangulate Triangulum Trianon Triassic triatomic tribal tribe tribesman tribesmen tribulate tribunal tribune tributary tribute Triceratops Trichinella trichloroacetic trichloroethane trichrome trick trickery trickle trickster tricky trident tridiagonal triennial trifle trifluoride trig trigonal trigonometry trigram trilingual trill trillion trillium trilobite trilogy trim trimer trimester Trinidad trinitarian trinity trinket trio triode trioxide trip tripartite tripe triphammer triphenylphosphine triple triplet Triplett triplex triplicate triploid triploidy tripod tripoli triptych trisodium Tristan tristate trisyllable trite tritium triton triumph triumphal triumphant triune trivalent trivia trivial trivium Trobriand trod trodden troff troglodyte troika Trojan troll trolley trollop trombone trompe troop trophic trophy tropic tropopause troposphere tropospheric trot trouble troubleshoot troublesome trough trounce troupe trouser trout Troutman troy truant truce truck truckload truculent trudge Trudy true truffle truism Truk truly Truman Trumbull trump trumpery trumpet truncate trundle trunk trunkful truss trust trustee trustful trustworthy trusty truth truthful TRW try trypsin trytophan t's tsar tsarina tset tsunami TTL TTY tty tub tuba tube tuberculin tuberculosis tuberous tubular tubule tuck Tucson Tudor Tuesday tuff tuft tug tugboat tugging tuition Tulane tularemia tulip tulle Tulsa tum tumble tumbrel tumult tumultuous tun tuna tundra tune tuneful tung tungstate tungsten tunic Tunis Tunisia tunnel tupelo tuple turban turbid turbidity turbinate turbine turbofan turbojet turbulent turf Turin Turing turk turkey Turkish turmeric turmoil turn turnabout turnaround turnery turnip turnkey turnoff turnout turnover turnpike turnstone turntable turpentine turpitude turquoise turret turtle turtleback turtleneck turvy Tuscaloosa Tuscan Tuscany Tuscarora tusk Tuskegee tussle tussock Tutankhamen tutelage Tutenkhamon tutor tutorial Tuttle tutu tuxedo TV TVA TWA twaddle twain tweak tweed tweedy tweeze twelfth twelve twelvefold twentieth twenty twentyfold twice twiddle twig twigging twilight twill twin twine twinge twinkle twirl twirly twist twisty twit twitch twitchy two twofold Twombly twosome TWX TX Tyburn tycoon tying tyke Tyler tympanum type typeface typescript typeset typesetter typesetting typewrite typewritten typhoid Typhon typhoon typhus typic typify typo typographer typography typology tyrannic tyrannicide Tyrannosaurus tyranny tyrant tyrosine Tyson Tzeltal u ubiquitous ubiquity UCLA Uganda ugh ugly UK Ukraine Ukrainian Ulan ulcer ulcerate Ullman ulna Ulster ulterior ultimate ultimatum ultra Ulysses umber umbilical umbilici umbilicus umbra umbrage umbrella umpire UN un unanimity unanimous unary unbeknownst unchristian uncle uncouth unction unctuous under underclassman underclassmen underivable underived underling undulate UNESCO ungulate uniaxial unicorn unidimensional unidirectional uniform unify unilateral unimodal uninominal union uniplex unipolar uniprocessor unique Uniroyal unisex unison unit unital unitarian unitary unite unity Univac univalent univariate universal universe Unix unkempt unruly until unwieldy up upbeat upbraid upbring upcome update updraft upend upgrade upheaval upheld uphill uphold upholster upholstery upkeep upland uplift upon upperclassman upperclassmen uppercut uppermost upraise upright uprise upriver uproar uproarious uproot upset upsetting upshot upside upsilon upslope upstage upstair upstand upstart upstate upstater upstream upsurge upswing uptake Upton uptown uptrend upturn upward upwell upwind uracil urania uranium Uranus uranyl urban Urbana urbane urbanite urchin Urdu urea uremia urethane urethra urge urgent Uri urinal urinary urinate urine Uris urn urology Urquhart Ursa Ursula Ursuline Uruguay urushiol U.S u's us U.S.A USA usable USAF usage USC USC&GS USDA use useful USGS usher USIA USN USPS USSR usual usurer usurious usurp usurpation usury UT Utah utensil uterine uterus Utica utile utilitarian utility utmost utopia utopian Utrecht utter utterance uttermost v VA vacant vacate vacationland vaccinate vaccine vacillate vacua vacuo vacuolate vacuole vacuous vacuum vade Vaduz vagabond vagary vagina vaginal vagrant vague Vail vain vainglorious vale valedictorian valedictory valent valentine Valerie Valery valet valeur Valhalla valiant valid validate valine Valkyrie Valletta valley Valois Valparaiso valuate value valve vamp vampire van vanadium Vance Vancouver vandal Vandenberg Vanderbilt Vanderpoel vane vanguard vanilla vanish vanity vanquish vantage variable variac Varian variant variate variegate variety various varistor Varitype varnish varsity vary vascular vase vasectomy vasoconstriction Vasquez vassal Vassar vast vat Vatican vaudeville Vaudois Vaughan Vaughn vault veal vector vectorial Veda vee veer veery Vega vegetable vegetarian vegetate vehement vehicle vehicular veil vein velar Velasquez veldt Vella vellum velocity velours velvet velvety venal vend vendetta vendible vendor veneer venerable venerate venereal Venetian venetian Veneto Venezuela vengeance vengeful venial Venice venison venom venomous venous vent ventilate ventral ventricle ventriloquism ventriloquist venture venturesome venturi Venus Venusian Vera veracious veracity veranda verandah verb verbal verbatim verbena verbiage verbose verdant Verde Verdi verdict verge veridic verify verisimilitude veritable verity Verlag vermeil vermiculite vermilion vermin Vermont vermouth Verna vernacular vernal Verne vernier Vernon Verona Veronica versa Versailles versatec versatile verse version versus vertebra vertebrae vertebral vertebrate vertex vertical vertices vertigo verve very vesicular vesper vessel vest vestal vestibule vestige vestigial vestry Vesuvius vet vetch veteran veterinarian veterinary veto vex vexation vexatious vi via viaduct vial vibrant vibrate vibrato viburnum vicar vicarious vice viceroy Vichy vicinal vicinity vicious vicissitude Vicksburg Vicky victim victor Victoria victorious victory victrola victual Vida video videotape vie Vienna Viennese Vientiane Viet Vietnam Vietnamese view viewpoint vigil vigilant vigilante vignette vigorous vii viii Viking Vikram vile vilify villa village villain villainous villein vinaigrette Vincent Vinci vindicate vindictive vine vinegar vineyard Vinson vintage vintner vinyl viola violate violent violet violin viper viral Virgil virgin virginal Virginia Virgo virgule virile virtual virtue virtuosi virtuosity virtuoso virtuous virulent virus visa visage viscera visceral viscid viscoelastic viscometer viscosity viscount viscous vise Vishnu visible Visigoth vision visionary visit visitation visitor visor vista visual vita vitae vital vitamin vitiate Vito vitreous vitrify vitriol vitriolic vitro viva vivace vivacious vivacity Vivaldi Vivian vivid vivify viviparous vivisection vivo vixen viz Vladimir Vladivostok vocable vocabularian vocabulary vocal vocalic vocate vociferous vodka Vogel vogue voice voiceband void volatile volcanic volcanism volcano volcanoes vole volition Volkswagen volley volleyball Volstead volt Volta voltage voltaic Voltaire Volterra voltmeter voluble volume volumetric voluminous voluntary volunteer voluptuous Volvo vomit von voodoo voracious voracity vortex vortices vorticity Voss votary vote votive vouch vouchsafe Vought vow vowel voyage Vreeland v's vs VT Vulcan vulgar vulnerable vulpine vulture vying w WA Waals Wabash WAC wack wacke wacky Waco wad waddle wade wadi Wadsworth wafer waffle wag wage wagging waggle Wagner wagoneer wagonload wah Wahl wail wainscot Wainwright waist waistcoat waistline wait Waite waitress waive wake Wakefield wakeful waken wakerobin wakeup Walcott Walden Waldo Waldorf Waldron wale Walgreen walk walkie walkout walkover walkway wall walla wallaby Wallace wallboard Waller wallet Wallis wallop wallow wallpaper wally walnut Walpole walrus Walsh Walt Walter Waltham Walton waltz wan wand wander wane Wang wangle want wanton wapato wapiti Wappinger war warble Warburton ward warden wardrobe wardroom ware warehouse warehouseman warehousemen warfare warhead Waring warm warmhearted warmish warmonger warmth warmup warn warp warplane warrant warranty warren warrior Warsaw wart wartime warty Warwick wary was wash washbasin washboard washbowl Washburn Washington washout washy wasn't wasp waspish Wasserman wast wastage waste wastebasket wasteful wasteland wastewater wasting wastrel Watanabe watch watchband watchdog watchful watchmake watchman watchmen watchword watchworks water Waterbury watercourse watercress waterfall waterfowl waterfront Watergate waterhole Waterhouse waterline Waterloo Waterman watermelon waterproof watershed waterside watertight Watertown waterway watery Watkins Watson watt wattage wattle wave waveform wavefront waveguide wavelength wavenumber wavy wax waxen waxwing waxwork waxy way waybill waylaid waylay Wayne wayside wayward we weak weaken weal wealth wealthy wean weapon weaponry wear wearisome weary weasel weather weatherbeaten weatherproof weatherstrip weatherstripping weave web Webb weber Webster WECo we'd wed wedge wedlock Wednesday wee weed weedy week weekday weekend weep Wehr Wei Weierstrass weigh weight weighty Weinberg Weinstein weir weird Weiss Welch welcome weld Weldon welfare we'll well wellbeing Weller Welles Wellesley wellington wellwisher welsh welt Wendell Wendy went wept we're were weren't Werner wert Werther Wesley Wesleyan west westbound Westchester westerly western westernmost Westfield Westinghouse Westminster Weston westward wet wetland we've Weyerhauser whack whale whalebone Whalen wham wharf Wharton wharves what what'd whatever Whatley whatnot what're whatsoever wheat Wheatstone whee wheedle wheel wheelbarrow wheelbase wheelchair wheelhouse wheeze wheezy Whelan whelk Wheller whelm whelp when whence whenever where whereabout whereas whereby where'd wherefore wherein whereof whereon where're wheresoever whereupon wherever wherewith whet whether whey which whichever whiff whig while whim whimper whimsey whimsic whimsy whine whinny whip whiplash Whippany whippet Whipple whipsaw whir whirl whirligig whirlpool whirlwind whisk whisper whistle whistleable whit Whitaker Whitcomb white whiteface Whitehall whitehead Whitehorse whiten whitetail whitewash whither whitish Whitlock Whitman Whitney Whittaker Whittier whittle whiz whizzing who whoa who'd whodunit whoever whole wholehearted wholesale wholesome who'll wholly whom whomever whomsoever whoop whoopee whoosh whop whore whorl whose whosoever whup why WI Wichita wick wicket wide widen widespread widgeon widget widow width widthwise wield wiener Wier wife wig wigging Wiggins wiggle wiggly Wightman wigmake wigwam Wilbur Wilcox wild wildcat wildcatter wildebeest wilderness wildfire wildflower wildlife wile Wiley Wilfred wilful Wilhelm Wilhelmina Wilkes Wilkie Wilkins Wilkinson will Willa Willard willful William Williamsburg Williamson Willie Willis Willoughby willow willowy Wilma Wilmington Wilshire Wilson wilt wily win wince winch Winchester wind windbag windblown windbreak windfall windmill window windowpane windowsill windshield Windsor windstorm windsurf windswept windup windward windy wine winemake winemaster winery wineskin Winfield wing wingback wingbeat wingman wingmen wingspan wingspread wingtip Winifred wink winkle Winnetka Winnie Winnipeg Winnipesaukee winnow wino Winslow winsome Winston winter wintergreen wintertime Winthrop wintry winy wipe wire wireman wiremen wiry Wisconsin wisdom wise wiseacre wisecrack wisenheimer wish wishbone wishful wishy wisp wispy wistful wit witch witchcraft with withal withdraw withdrawal withdrawn withdrew withe wither withheld withhold within without withstand withstood withy witness Witt Wittgenstein witty wive wizard wobble woe woebegone woeful wok woke Wolcott wold wolf Wolfe Wolff Wolfgang wolfish wolve wolverine woman womb wombat women won wonder wonderful wonderland wondrous Wong won't wont woo wood Woodard Woodbury woodcarver woodchuck woodcock woodcut wooden woodgrain woodhen woodland Woodlawn woodlot woodpeck woodrow woodruff woodshed woodside Woodstock woodward woodwind woodwork woody woodyard wool woolgather Woolworth Wooster wop Worcester Worcestershire word Wordsworth wordy wore work workbench workbook workday workforce workhorse workload workman workmen workout workpiece workplace worksheet workshop workspace workstation worktable world worldwide worm wormy worn worrisome worry worse worsen worship worshipful worst worth Worthington worthwhile worthy Wotan would wouldn't wound wove woven wow wrack wraith wrangle wrap wraparound wrapup wrasse wrath wrathful wreak wreath wreathe wreck wreckage wren wrench wrest wrestle wretch wriggle wright Wrigley wring wrinkle wrist wristband wristwatch writ write writeup writhe writhing written wrong wrongdoer wrongdoing wrongful Wronskian wrote wrought wry w's Wu Wuhan WV WY Wyandotte Wyatt Wyeth Wylie Wyman Wyner wynn Wyoming wysiwyg x Xavier xenon xenophobia xerography xerox Xerxes Xhosa xi x's xylem xylene xylophone y yacht yachtsman yachtsmen yah yak Yakima Yale Yalta yam Yamaha yang yank Yankee Yankton Yaounde yap yapping Yaqui yard yardage yardstick Yarmouth yarmulke yarn yarrow Yates yaw yawl yawn ye yea Yeager yeah year yearbook yearn yeast yeasty Yeats yell yellow yellowish Yellowknife Yellowstone yelp Yemen yen yeoman yeomanry yeomen yeshiva yesterday yesteryear yet yew Yiddish yield yin yip yipping YMCA yodel Yoder yoga yoghurt yogi yogurt yoke yokel Yokohama Yokuts yolk yon yond Yonkers yore York Yorkshire Yorktown Yosemite Yost you you'd you'll young youngish youngster Youngstown your you're yourself yourselves youth youthful you've yow Ypsilanti y's ytterbium yttrium Yucatan yucca yuck Yugoslav Yugoslavia yuh Yuki Yukon yule Yves Yvette YWCA z Zachary zag zagging Zagreb Zaire Zambia Zan Zanzibar zap zazen zeal Zealand zealot zealous zebra Zeiss Zellerbach Zen zenith zero zeroes zeroth zest zesty zeta Zeus Ziegler zig zigging zigzag zigzagging zilch zillion Zimmerman zinc zing zinnia Zion zip zircon zirconium zither zloty zodiac zodiacal Zoe Zomba zombie zone zoo zoology zoom zooplankton Zorn Zoroaster Zoroastrian zounds z's zucchini Zulu Zurich zygote ================================================ FILE: share/examples/Makefile ================================================ # Public Domain. 2023/02/21 - Christopher Hettrick TOPSRC!=cd ../..; pwd include ${TOPSRC}/share/mk/sys.mk all clean cleandir depend lint tags: install: ${INSTALL} -d ${DESTDIR}/usr/share/examples tar cf - . | (cd ${DESTDIR}/usr/share/examples && tar xpf -) ================================================ FILE: share/examples/asm/Makefile ================================================ all: ashello echo ashello: ashello.o $(LD) ashello.o -o $@ echo: echo.o $(LD) $@.o -o $@ clean: rm -f *.o ashello echo *.dis *~ ================================================ FILE: share/examples/asm/Makefile-host ================================================ TOPSRC!=cd ../../..; pwd include ${TOPSRC}/share/mk/sys.mk CFLAGS += -Werror ASFLAGS += -DCROSS ASLDFLAGS = --oformat=elf32-tradlittlemips -N -nostartfiles -T $(TOPSRC)/src/elf32-mips.ld all: echo echo: echo.o ${LD} ${ASLDFLAGS} -o $@.elf $@.o ${OBJDUMP} -S $@.elf > $@.dis ${SIZE} $@.elf ${ELF2AOUT} $@.elf $@ clean: rm -f *.o *.elf ${MAN} echo *.elf *.dis tags *~ ================================================ FILE: share/examples/asm/ashello.S ================================================ /* * This is an example of MIPS assembly program for RetroBSD. * * To compile this program, type: * cc -c ashello.S * ld ashello.o -o ashello */ #include .data // begin data segment hello: .ascii "Hello, assembly world!\n" // a string .text // begin code segment .globl start // entry point for ld start: li $a0, 0 // arg 1: stdout fd la $a1, hello // arg 2: string address li $a2, 23 // arg 3: string length syscall SYS_write // call the kernel: write() nop // returns here on error nop // skips two words on success li $a0, 0 // arg 1: exit status syscall SYS_exit // call the kernel: exit() // no return ================================================ FILE: share/examples/asm/echo.S ================================================ /* * This is a standard /bin/echo utility, rewritten in MIPS assembler. * * To compile this program, type: * cc -c echo.S * ld echo.o -o echo * * Run as: * ./echo Make love not war */ #include .data // begin data segment eoln: .ascii "\n" space: .ascii " " .text // begin code segment start: .globl start // entry point for ld // // Program gets three arguments: // argc in $a0 - number of words in command line // argv in $a1 - address of list of pointers to words // env in $a2 - address of list of pointers to environment variables // addi $s0, $a0, -1 // argc - 1 beq $s0, $zero, done // if (argc == 0) goto gone addi $s1, $a1, 4 // argv + 4 loop: jal print // print string lw $a0, 0($s1) // arg 1: *argv addi $s0, $s0, -1 // --argc la $a1, eoln // arg2: newline beq $s0, $zero, last // if (argc == 0) goto last li $a0, 1 // arg1: stdout la $a1, space // arg2: space last: li $a2, 1 // arg3: length syscall SYS_write // call the kernel: write() nop // ignore errors nop bne $s0, $zero, loop // if (argc == 0) goto gone addi $s1, $s1, 4 // ++argv done: li $a0, 0 // arg1: exit status syscall SYS_exit // call the kernel: exit() // no return print: move $a1, $a0 // arg2: string addi $a2, $a0, 1 // compute length strlen: lb $v0, 0($a0) // get byte from string bne $v0, $zero, strlen // continue if not end addi $a0, $a0, 1 // increment pointer subu $a2, $a0, $a2 // arg3: length li $a0, 1 // arg1: stdout syscall SYS_write // call the kernel: write() nop // ignore errors nop jr $ra nop ================================================ FILE: share/examples/basic/blkjack.bas ================================================ 10 rem ************************************** 20 rem *** Play the "blackjack" (21) game *** 30 rem ************************************** 40 dim C(52): m = 1000 50 rem 60 rem Create deck of cards and shuffle it 70 rem 80 for i=0 to 51: c(i) = i: next i 90 for i=0 to 51: i1=rnd(52): i2=c(i): c(i)=c(i2): c(i2)=i1: next i 100 rem 110 rem Prompt for amount of bet (on this game) 120 rem 130 print "You have", m, " dollars" 140 input "How much do you wish to bet?", b: if b=0 then stop 150 lif b>m then print "You don't have enough money":goto 140 160 t = 0: d = 0 170 rem 180 rem Prompt PLAYER for another card 190 rem 200 print "Total:", t,:Input " Another card (Y/N)?", a$ 210 if a$="n" then 380 220 lif a$<>"y" then print "Please answer y-Yes or n-No":goto 200 230 c = c(d): d = d + 1: gosub 530 240 c = c % 13: if c > 9 then c = 9 250 if c > 0 then 300 260 input "(1)one or (t)ten ?", a$ 270 if a$="1" then 300 280 if a$<>"t" then 260 290 c = 9 300 t = t + c + 1 310 if t <= 21 then 200 320 print "You went over 21! - you LOSE!" 330 m = m - b: if m > 0 then 80 340 print "You went BUST!":end 350 rem 360 rem Play DEALER 370 rem 380 t1 = 0 390 c = c(d): d = d + 1: print "Dealer draws ",: gosub 530 400 c = c % 13: if c > 9 then c = 9 410 if c > 0 then 470 420 if t1 < 10 then 450 430 if (t1+10) > 23 then 460 440 if (t1+10) >= t then 450 450 c = 9 460 print "Dealer chooses", c+1 470 t1 = t1 + c + 1: print "Dealer totals", t1: if t1 < t then 390 480 lif t1 <= 21 then print "Dealer wins - You LOSE!": goto 330 490 print "Dealer loses - You WIN!!!": m = m + b: goto 80 500 rem 510 rem Subroutine to display text description of a card 520 rem 530 order 590 540 for a = 0 to c / 13: read a$: next a 550 order 600 560 for a = 0 to c % 13: read a1$:next a 570 print a1$, " of ", a$ 580 return 590 data "Hearts", "Diamonds", "Clubs", "Spades" 600 data "Ace", "Two", "Three", "Four", "Five", "Six", "Seven" 610 data "Eight", "Nine", "Ten", "Jack", "Queen", "King" ================================================ FILE: share/examples/basic/hilow.bas ================================================ 10 rem **************************** 20 rem *** Play the HI/LOW game *** 30 rem **************************** 40 n = rnd(100) 50 c = 0 60 input "Guess a number? ", g 70 c = c+1 80 if g=n then 120 90 if g>n then print "lower" 100 if g chello.dis ${SIZE} chello.elf ${ELF2AOUT} chello.elf $@ tetris: tetris.o ${CC} ${LDFLAGS} -o tetris.elf tetris.o ${LIBS} ${OBJDUMP} -S tetris.elf > tetris.dis ${SIZE} tetris.elf ${ELF2AOUT} tetris.elf $@ lcd6: lcd6.o ${CC} ${LDFLAGS} -o lcd6.elf lcd6.o ${LIBS} ${OBJDUMP} -S lcd6.elf > lcd6.dis ${SIZE} lcd6.elf ${ELF2AOUT} lcd6.elf $@ clean: rm -f *.o *.elf ${MAN} chello stdarg lcd6 *.elf *.dis tags *~ ================================================ FILE: share/examples/c/adc.c ================================================ /* * Example of reading ADC data. */ #include #include #include #include char buf[100]; int main(void) { int i, fd, value; for (i=0; i<16; i++) { sprintf(buf, "/dev/adc%d", i); fd = open(buf, O_RDWR); if (fd < 0) { printf("Error: unable to open %s\n", buf); } else { if (read(fd, buf, 20) > 0) { value = strtol (buf, 0, 0); printf("adc%-2d = %d\n", i, value); } close(fd); } } return 0; } ================================================ FILE: share/examples/c/gpio.c ================================================ /* * Example of polling general purpose i/o pins. */ #include #include #include #include int main(void) { int fd, pnum, value; fd = open ("/dev/porta", O_RDWR); if (fd < 0) { perror ("/dev/porta"); return -1; } for (pnum=0; pnum<7; pnum++) { value = ioctl (fd, GPIO_POLL | GPIO_PORT (pnum), 0); if (value < 0) perror ("GPIO_POLL"); printf ("port%c = 0x%04x\n", pnum + 'A', value); } return 0; } ================================================ FILE: share/examples/c/hello.c ================================================ #include int main() { printf ("Hello, C World!\n"); return 0; } ================================================ FILE: share/examples/c/lcd6.c ================================================ /* * Demo for 6 digit LCD module based on HT1261 controller. * Based on example sources from http://www.canton-electronics.com * * Copyright (C) 2015 Serge Vakulenko * * Permission to use, copy, modify, and distribute this software * and its documentation for any purpose and without fee is hereby * granted, provided that the above copyright notice appear in all * copies and that both that the copyright notice and this * permission notice and warranty disclaimer appear in supporting * documentation, and that the name of the author not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * * The author disclaim all warranties with regard to this * software, including all implied warranties of merchantability * and fitness. In no event shall the author be liable for any * special, indirect or consequential damages or any damages * whatsoever resulting from loss of use, data or profits, whether * in an action of contract, negligence or other tortious action, * arising out of or in connection with the use or performance of * this software. */ #include #include #include #include #include #include /* * Digits, decimal dots and battery levels: * A B C D E F * -- -- -- -- -- -- z * | | | | | | | | | | | | y * -- -- -- -- -- -- x * | | | | | | | | | | | | * -- -- -- c -- d -- e -- * * Memory map: * Byte 0, bits 0-6 - segments of digit 'F' * Byte 0, bit 7 - decimal dot 'e' * Byte 1, bits 0-6 - segments of digit 'E' * Byte 1, bit 7 - decimal dot 'd' * Byte 2, bits 0-6 - segments of digit 'D' * Byte 2, bit 7 - decimal dot 'c' * Byte 3, bits 0-6 - segments of digit 'C' * Byte 3, bit 7 - battery level 'x' * Byte 4, bits 0-6 - segments of digit 'B' * Byte 4, bit 7 - battery level 'y' * Byte 5, bits 0-6 - segments of digit 'A' * Byte 5, bit 7 - battery level 'z' * * Segments are mapped to bits 0-6: * --4-- * 0---5 * --1-- * 2---6 * --3-- */ /* * Signal assignment. * LED modulee is connected to pins 16,17,18 of Fubarino SD board. * * Fubarino PIC32 LED module * -------------------------- * 16 RE0 CS * 17 RE1 WR * 18 RE2 DATA */ #define gpio_cs_clear() ioctl(gpio, GPIO_PORTE | GPIO_CLEAR, 1 << 0) #define gpio_cs_set() ioctl(gpio, GPIO_PORTE | GPIO_SET, 1 << 0) #define gpio_wr_clear() ioctl(gpio, GPIO_PORTE | GPIO_CLEAR, 1 << 1) #define gpio_wr_set() ioctl(gpio, GPIO_PORTE | GPIO_SET, 1 << 1) #define gpio_data_clear() ioctl(gpio, GPIO_PORTE | GPIO_CLEAR, 1 << 2) #define gpio_data_set() ioctl(gpio, GPIO_PORTE | GPIO_SET, 1 << 2) /* * HT1621 commands */ #define HT_SYS_DIS 0x00 /* Turn off system osc and bias generator */ #define HT_SYS_EN 0x01 /* Turn on system oscillator */ #define HT_LCD_OFF 0x02 /* Turn off LCD bias generator */ #define HT_LCD_ON 0x03 /* Turn on LCD bias generator */ #define HT_CLOCK_XTAL 0x14 /* Crystal 32kHz */ #define HT_CLOCK_RC 0x18 /* On-chip RC oscillator 256kHz */ #define HT_CLOCK_EXT 0x1c /* External clock */ #define HT_BIAS_1_3 0x21 /* LCD 1/3 bias option, 2 commons default */ #define HT_COMMONS_3 0x04 /* 3 commons option */ #define HT_COMMONS_4 0x08 /* 4 commons option */ /* * Mapping of symbols to segments. * 0, 1, 2, 3, 4, 5, 6, 7, * 8, 9, A, b, C, c, d, E, * F, H, h, L, n, N, o, P, * r, t, U, -, , */ const char char_to_segm[] = { 0x7D, 0x60, 0x3E, 0x7A, 0x63, 0x5B, 0x5F, 0x70, 0x7F, 0x7B, 0x77, 0x4F, 0x1D, 0x0E, 0x6E, 0x1F, 0x17, 0x67, 0x47, 0x0D, 0x46, 0x75, 0x37, 0x06, 0x0F, 0x6D, 0x02, 0x00, }; /* * File descriptor for GPIO driver. */ int gpio; /* * Suspend the process for some amount of milliseconds. */ void mdelay(unsigned msec) { usleep(msec * 1000); } /* * Send a series of bits to HT1621. * Up to 8 bits, high bit first. * Max clock rate is 150kHz. */ void ht_send(int nbits, int data) { data <<= (8 - nbits); gpio_wr_clear(); while (nbits-- > 0) { if (data & 0x80) gpio_data_set(); else gpio_data_clear(); gpio_wr_set(); gpio_wr_clear(); data <<= 1; } } /* * Send command to HT1621. */ void ht_cmd(int command) { gpio_cs_clear(); ht_send(3, 0x4); /* Mode "100" */ ht_send(8, command); gpio_cs_set(); } /* * Send data and command. */ void ht_write(int addr, int data) { gpio_cs_clear(); ht_send(3, 0x5); /* Mode "101" */ ht_send(6, addr << 1); /* Half-byte address 6 bits */ ht_send(8, data); /* Data 8 bits */ gpio_cs_set(); } /* * Initialize LCD controller. */ void lcd_init() { /* Open GPIO driver. */ gpio = open("/dev/porta", 1); if (gpio < 0) { perror("/dev/porta"); exit(-1); } /* Configure pins RE0-RE2 as outputs. */ ioctl(gpio, GPIO_PORTE | GPIO_CONFOUT, 0x07); gpio_cs_set(); gpio_wr_clear(); /* Setup appropriate HT1621 mode. */ ht_cmd(HT_SYS_EN); ht_cmd(HT_CLOCK_RC); ht_cmd(HT_BIAS_1_3 | HT_COMMONS_4); ht_cmd(HT_LCD_ON); } /* * Set display memory to given value. */ void lcd_clear(int value) { int i; for (i=0; i<6; i++) { ht_write(i, value); } } /* * LCD on/off. */ void lcd_enable(int on) { if (on) ht_cmd(HT_LCD_ON); else ht_cmd(HT_LCD_OFF); } /* * Display data. * val - Data to be displayed, 0-999999 * dot - Display decimal dot, 0-3 * bat - Battery level, 0-3 */ void lcd_display(unsigned val, int dot, int bat) { int i, byte[6]; /* Set numeric value. */ byte[5] = char_to_segm[val / 100000]; byte[4] = char_to_segm[(val / 10000) % 10]; byte[3] = char_to_segm[(val / 1000) % 10]; byte[2] = char_to_segm[(val / 100) % 10]; byte[1] = char_to_segm[(val / 10) % 10]; byte[0] = char_to_segm[val % 10]; /* Enable decimal dot/ */ switch (dot) { case 1: byte[0] |= 1 << 7; break; case 2: byte[1] |= 1 << 7; break; case 3: byte[2] |= 1 << 7; break; default: break; } if (bat > 0) byte[3] |= 1 << 7; if (bat > 1) byte[4] |= 1 << 7; if (bat > 2) byte[5] |= 1 << 7; for (i=0; i<6; i++) { ht_write(i, byte[i]); } } int main() { int i; /* Initialize hardware. */ lcd_init(); /* Blink all segments twice. */ lcd_clear(0xff); mdelay(1000); lcd_clear(0); mdelay(1000); lcd_clear(0xff); mdelay(1000); lcd_clear(0); mdelay(1000); /* Show all characters on all segments. */ for (i=0; i int isprime(int); int main(void) { int n; for (n=2; n<100; ++n) { if (isprime(n)) { printf("%d ", n); } } printf("\n"); } int isprime(int n) { int j; if (n == 2) return 1; if (n % 2 == 0) return 0; for (j=3; j*j<=n; j+=2) if (n % j == 0) return 0; return 1; } ================================================ FILE: share/examples/c/primesum.c ================================================ /* * Compute the sum of prime numbers up to 10000. */ #include int isprime(int); int main(void) { int sum, n; sum = 0; for (n=2; n<10000; ++n) { if (isprime(n)) { sum += n; } } printf("Sum of primes less than 10000: %d\n", sum); } int isprime(int n) { int j; if (n == 2) return 1; if (n % 2 == 0) return 0; for (j=3; j*j<=n; j+=2) if (n % j == 0) return 0; return 1; } ================================================ FILE: share/examples/c/q8.c ================================================ /* * Eight Queens puzzle * * (C) 2010 by Mark Sproul * Open source as per standard Arduino code * Modified by Pito 12/2012 for SmallC and then by Alexey Frunze for Smaller C */ #include #define TRUE 1 #define FALSE 0 unsigned int gChessBoard[8]; unsigned int gLoopCounter; int gValidCount; int CheckCurrentBoard(void) { int ii; int jj; int theRow; int theLongRow; int theLongColumns; int bitCount; //* we know we have 1 in each row, //* Check for 1 in each column theRow = 0; for (ii=0; ii<8; ii++) { theRow |= gChessBoard[ii]; } if (theRow != 0x0ff) { return FALSE; } //* we have 1 in each column, now check the diagonals theLongColumns = 0; for (ii=0; ii<8; ii++) { theLongRow = gChessBoard[ii] & 0x0ff; theLongRow = theLongRow << ii; theLongColumns |= theLongRow; } //* now count the bits bitCount = 0; for (ii=0; ii<16; ii++) { if ((theLongColumns & 0x01) == 0x01) { bitCount++; } theLongColumns = theLongColumns >> 1; } if (bitCount != 8) { return FALSE; } //* we now have to check the other diagonal theLongColumns = 0; for (ii=0; ii<8; ii++) { theLongRow = gChessBoard[ii] & 0x0ff; theLongRow = theLongRow << 8; theLongRow = theLongRow >> ii; theLongColumns |= theLongRow; } //* now count the bits bitCount = 0; for (ii=0; ii<16; ii++) { if ((theLongColumns & 0x01) == 0x01) { bitCount++; } theLongColumns = theLongColumns >> 1; } if (bitCount != 8) { return FALSE; } return TRUE; } int CheckForDone(void) { int ii; int weAreDone; int theRow; weAreDone = FALSE; //* we know we have 1 in each row, //* Check for 1 in each column theRow = 0; for (ii=0; ii<8; ii++) { theRow |= gChessBoard[ii]; } if (theRow == 0x01) { weAreDone = TRUE; } return weAreDone; } void RotateQueens(void) { int ii; int keepGoing; int theRow; ii = 0; keepGoing = TRUE; while (keepGoing && (ii < 8)) { theRow = gChessBoard[ii] & 0x0ff; theRow = (theRow >> 1) & 0x0ff; if (theRow != 0) { gChessBoard[ii] = theRow; keepGoing = FALSE; } else { gChessBoard[ii] = 0x080; } ii++; } } void PrintChessBoard(void) { int ii; int jj; int theRow; char textString[32]; printf("\nLoop= %d\n", gLoopCounter); printf("Solution count= %d\n", gValidCount); printf("+----------------+\n"); for (ii=0; ii<8; ii++) { theRow = gChessBoard[ii]; printf("|"); for (jj=0; jj<8; jj++) { if (theRow & 0x080) { printf("Q "); } else { printf(". "); } theRow = theRow << 1; } printf("|\n"); } printf("+----------------+\n"); } int main(void) { int ii; printf("\nEight Queens brute force"); printf("\n************************\n"); //* put the 8 queens on the board, 1 in each row for (ii=0; ii<8; ii++) { gChessBoard[ii] = 0x080; } PrintChessBoard(); gLoopCounter = 0; gValidCount = 0; while (1) { gLoopCounter++; if (CheckCurrentBoard()) { gValidCount++; PrintChessBoard(); } else if ((gLoopCounter % 1000) == 0) { //PrintChessBoard(); } RotateQueens(); if (CheckForDone()) { //int elapsedSeconds; //int elapsedMinutes; //int elapsedHours; //elapsedSeconds = millis() / 1000; //elapsedMinutes = elapsedSeconds / 60; //elapsedHours = elapsedMinutes / 60; printf("----------------------------------\n"); printf("All done\n"); PrintChessBoard(); printf("----------------------------------\n"); //Serial.print("total seconds="); //Serial.println(elapsedSeconds); //Serial.print("hours="); //Serial.println(elapsedHours); //Serial.print("minutes="); //Serial.println(elapsedMinutes % 60); //Serial.print("seconds="); //Serial.println(elapsedSeconds % 60); return (1); } } } ================================================ FILE: share/examples/c/rain.c ================================================ /* * Example of using termcap library for SmallC. * 11/3/1980 EPS/CITHEP * * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include #include #include #include #define CO 80 /* number of columns */ #define LI 24 /* number of lines */ #define CL "\33[H\33[J" /* clear the screen */ #define CM "\33[%u;%uH" /* move the cursor to row, column */ #define BC "\b" /* move cursor left */ #define DN "\33[B" /* move cursor down */ #define ND " " /* move cursor right */ int xpos[5], ypos[5]; char outbuf[BUFSIZ]; void moveto(int col, int row) { printf(CM, row, col); } void onsig(int n) { moveto(0, LI - 1); fflush(stdout); _exit(0); } int main(void) { int x, y, j; setbuf(stdout, outbuf); for (j = SIGHUP; j <= SIGTERM; j++) if (signal(j, SIG_IGN) != SIG_IGN) signal(j, onsig); fputs(CL, stdout); fflush(stdout); for (j = 5; --j >= 0; ) { xpos[j] = 2 + rand() % (CO - 4); ypos[j] = 2 + rand() % (LI - 4); } for (j = 0; ; ) { x = 2 + rand() % (CO - 4); y = 2 + rand() % (LI - 4); moveto(x, y); putchar('.'); moveto(xpos[j], ypos[j]); putchar('o'); if (j == 0) j = 4; else --j; moveto(xpos[j], ypos[j]); putchar('O'); if (j == 0) j = 4; else --j; moveto(xpos[j], ypos[j]-1); putchar('-'); fputs(DN, stdout); fputs(BC, stdout); fputs(BC, stdout); fputs("|.|", stdout); fputs(DN, stdout); fputs(BC, stdout); fputs(BC, stdout); putchar('-'); if (j == 0) j = 4; else --j; moveto(xpos[j], ypos[j]-2); putchar('-'); fputs(DN, stdout); fputs(BC, stdout); fputs(BC, stdout); fputs("/ \\", stdout); moveto(xpos[j]-2, ypos[j]); fputs("| O |", stdout); moveto(xpos[j]-1, ypos[j]+1); fputs("\\ /", stdout); fputs(DN, stdout); fputs(BC, stdout); fputs(BC, stdout); putchar('-'); if (j == 0) j = 4; else --j; moveto(xpos[j], ypos[j]-2); putchar(' '); fputs(DN, stdout); fputs(BC, stdout); fputs(BC, stdout); putchar(' '); fputs(ND, stdout); putchar(' '); moveto(xpos[j]-2, ypos[j]); putchar(' '); fputs(ND, stdout); putchar(' '); fputs(ND, stdout); putchar(' '); moveto(xpos[j]-1, ypos[j]+1); putchar(' '); fputs(ND, stdout); putchar(' '); fputs(DN, stdout); fputs(BC, stdout); fputs(BC, stdout); putchar(' '); xpos[j] = x; ypos[j] = y; fflush(stdout); usleep(100000); } } ================================================ FILE: share/examples/c/skeleton.c ================================================ /* * Generic skeleton for a C program. * When you create your own program based on this skeleton, * you can replace the author's name and copyright with * whatever your want. When you redistribute this skeleton or * enhance it, please leave my name and copyright on it. * * Copyright (C) 1993-2014 Serge Vakulenko, * * Permission to use, copy, modify, and distribute this software * and its documentation for any purpose and without fee is hereby * granted, provided that the above copyright notice appear in all * copies and that both that the copyright notice and this * permission notice and warranty disclaimer appear in supporting * documentation, and that the name of the author not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * * The author disclaim all warranties with regard to this * software, including all implied warranties of merchantability * and fitness. In no event shall the author be liable for any * special, indirect or consequential damages or any damages * whatsoever resulting from loss of use, data or profits, whether * in an action of contract, negligence or other tortious action, * arising out of or in connection with the use or performance of * this software. */ #include #include #include const char version[] = "1.0"; const char copyright[] = "Copyright (C) 1993-2014 Serge Vakulenko"; char *progname; /* Name of the current program (argv[0]) */ int verbose; /* Option -v */ int trace; /* Option -t */ int debug; /* Option -d */ void usage () { fprintf (stderr, "Generic C skeleton, Version %s, %s\n", version, copyright); fprintf (stderr, "Usage:\n\t%s [-vtd] [-r count] file...\n", progname); fprintf (stderr, "Options:\n"); fprintf (stderr, "\t-v\tverbose mode\n"); fprintf (stderr, "\t-t\ttrace mode\n"); fprintf (stderr, "\t-d\tdebug\n"); fprintf (stderr, "\t-r #\trepeat count\n"); exit (-1); } int main (int argc, char **argv) { int count = 1; /* Option -r # */ progname = *argv; for (;;) { switch (getopt (argc, argv, "vtdr:")) { case EOF: break; case 'v': ++verbose; continue; case 't': ++trace; continue; case 'd': ++debug; continue; case 'r': count = strtol (optarg, 0, 0); continue; default: usage (); } break; } argc -= optind; argv += optind; if (argc < 1) usage (); while (count-- > 0) { int i; for (i=0; i #include void print(char *fmt, ...) { va_list ap; int d; char c, *s; va_start(ap, fmt); while (*fmt) { switch (*fmt++) { case 's': /* string */ s = va_arg(ap, char*); printf("string %s\n", s); break; case 'd': /* int */ d = va_arg(ap, int); printf("int %d\n", d); break; case 'c': /* char */ c = va_arg(ap, int); printf("char %c\n", c); break; } } va_end(ap); } int main() { print("sdcsdc", "abracadabra", 12345, 'Z', "foo", 365, '%'); return 0; } ================================================ FILE: share/examples/c/test1.c ================================================ #include int ga[5]; int main(void) { int a, b, c, d; int arr[5]; int *pi; char arrc[5]; char *pic; int s1, s2; int z; int t; int *pip; int *picp; int e1, e2; ga[0] = 10; ga[1] = 20; ga[2] = 30; ga[3] = 40; ga[4] = 50; a = 21; b = 31; c = 71; d = 82; arr[0] = 10; arr[1] = 20; arr[2] = 30; arr[3] = 40; arr[4] = 50; pi = &arr[0]; arrc[0] = 13; arrc[1] = 23; arrc[2] = 33; arrc[3] = 43; arrc[4] = 53; pic = &arrc[0]; printf(" 21 + 31 = %d (52)\n", a + b); printf(" 21 - 31 = %d (-10)\n", a - b); printf(" 21 & 71 = %d (5)\n", a & c); printf(" 21 | 82 = %d (87)\n", a | d); printf(" 21 ^ 82 = %d (71)\n", a ^ d); printf(" 21 * 82 = %d (1722)\n", a * d); printf(" 82 %% 21 = %d (19)\n", d % a); printf(" 82 / 21 = %d (3)\n", d / a); printf(" *pi = %d (10)\n", *pi); printf(" *pi + 1 = %d (11)\n", *pi + 1); printf(" *(pi + 1) = %d (20)\n", *(pi + 1)); printf("&arr[3] - &arr[0] = %d (3)\n", &arr[3] - &arr[0]); printf(" arr[3]-arr[0] = %d (30)\n", arr[3] - arr[0]); printf(" arr[3]+arr[0] = %d (50)\n", arr[3] + arr[0]); printf(" &ga[3] - &ga[0] = %d (3)\n", &ga[3] - &ga[0]); printf(" ga[3]-ga[0] = %d (30)\n", ga[3] - ga[0]); printf(" ga[3]+ga[0] = %d (50)\n", ga[3] + ga[0]); printf("\n"); printf(" *pic = %d (13)\n", *pic); printf(" *pic + 1 = %d (14)\n", *pic+1); printf(" *(pic + 1) = %d (23)\n", *(pic+1)); printf("&arrc[3] - &arrc[0] = %d (3)\n", &arrc[3]-&arrc[0]); printf("\n"); s1 = 3; s2 = -200; printf(" 82 << 3 = %d (656)\n", d << s1); printf(" 82 >> 3 = %d (10)\n", d >> s1); printf("-200 >> 3 = %d (-25)\n", s2 >> s1); printf("-200 << 3 = %d (-1600)\n", s2 << s1); printf("\n"); printf("-s1 = %d (-3)\n", -s1); printf("-s2 = %d (200)\n", -s2); printf("\n"); printf("~82 = %d (-83)\n", ~d); printf("\n"); z = 0; printf("!82 = %d (0)\n", !d); printf(" !0 = %d (1)\n", !z); printf("\n"); printf(" 0 && 0 = %d (0)\n", z && z); printf(" 0 && 21 = %d (0)\n", z && a); printf(" 3 && 21 = %d (1)\n", s1 && a); printf("21 && 3 = %d (1)\n", a && s1); printf("\n"); printf(" 0 || 0 = %d (0)\n", z || z); printf(" 0 || 21 = %d (1)\n", z || a); printf(" 3 || 21 = %d (1)\n", s1 || a); printf("21 || 3 = %d (1)\n", a || s1); printf("\n"); pi = 4; printf("pi++ = %d (4)\n", pi++); printf(" pi = %d (8)\n", pi); printf("++pi = %d (12)\n", ++pi); printf("pi-- = %d (12)\n", pi--); printf(" pi = %d (8)\n", pi); printf("--pi = %d (4)\n", --pi); printf("\n"); pic = 4; printf("pic++ = %d (4)\n", pic++); printf(" pic = %d (5)\n", pic); printf("++pic = %d (6)\n", ++pic); printf("pic-- = %d (6)\n", pic--); printf(" pic = %d (5)\n", pic); printf("--pic = %d (4)\n", --pic); printf("\n"); t = 4; printf("t++ = %d (4)\n", t++); printf(" t = %d (5)\n", t); printf("++t = %d (6)\n", ++t); printf("t-- = %d (6)\n", t--); printf(" t = %d (5)\n", t); printf("--t = %d (4)\n", --t); printf("\n"); t = 4; printf(" t==4 = %d (1)\n", t == 4); printf(" t==3 = %d (0)\n", t == 3); printf(" t==5 = %d (0)\n", t == 5); t = -4; printf("t==-4 = %d (1)\n", t == -4); printf("t==-3 = %d (0)\n", t == -3); printf("t==-5 = %d (0)\n", t == -5); printf(" t==4 = %d (0)\n", t == 4); printf(" t==3 = %d (0)\n", t == 3); printf(" t==5 = %d (0)\n", t == 5); printf("\n"); t = 4; printf(" t!=4 = %d (0)\n", t != 4); printf(" t!=3 = %d (1)\n", t != 3); printf(" t!=5 = %d (1)\n", t != 5); t = -4; printf("t!=-4 = %d (0)\n", t != -4); printf("t!=-3 = %d (1)\n", t != -3); printf("t!=-5 = %d (1)\n", t != -5); printf(" t!=4 = %d (1)\n", t != 4); printf(" t!=3 = %d (1)\n", t != 3); printf(" t!=5 = %d (1)\n", t != 5); printf("\n"); t = 4; printf(" t<4 = %d (0)\n", t < 4); printf(" t<3 = %d (0)\n", t < 3); printf(" t<5 = %d (1)\n", t < 5); printf("t<-1 = %d (0)\n", t < -1); printf("\n"); printf(" t<=4 = %d (1)\n", t <= 4); printf(" t<=3 = %d (0)\n", t <= 3); printf(" t<=5 = %d (1)\n", t <= 5); printf("t<=-1 = %d (0)\n", t <= -1); printf("\n"); t = 4; printf(" t>4 = %d (0)\n", t > 4); printf(" t>3 = %d (1)\n", t > 3); printf(" t>5 = %d (0)\n", t > 5); printf("t>-1 = %d (1)\n", t > -1); printf("\n"); printf(" t>=4 = %d (1)\n", t >= 4); printf(" t>=3 = %d (1)\n", t >= 3); printf(" t>=5 = %d (0)\n", t >= 5); printf("t>=-1 = %d (1)\n", t >= -1); printf("\n"); pi = -100; printf(" pi<4 = %d (0)\n", pi < (int*)4); printf(" pi<3 = %d (0)\n", pi < (int*)3); printf("pi<-100 = %d (0)\n", pi < (int*)-100); printf(" pi<-1 = %d (1)\n", pi < (int*)-1); printf("\n"); printf(" pi<=4 = %d (0)\n", pi <= (int*)4); printf(" pi<=3 = %d (0)\n", pi <= (int*)3); printf("pi<=-100 = %d (1)\n", pi <= (int*)-100); printf(" pi<=-1 = %d (1)\n", pi <= (int*)-1); printf("\n"); pi = -100; printf(" pi>4 = %d (1)\n", pi > (int*)4); printf(" pi>3 = %d (1)\n", pi > (int*)3); printf("pi>-100 = %d (0)\n", pi > (int*)-100); printf(" pi>-1 = %d (0)\n", pi > (int*)-1); printf("\n"); printf(" pi>=4 = %d (1)\n", pi >= (int*)4); printf(" pi>=3 = %d (1)\n", pi >= (int*)3); printf("pi>=-100 = %d (1)\n", pi >= (int*)-100); printf(" pi>=-1 = %d (0)\n", pi >= (int*)-1); printf("\n"); pi = &arr[0]; pip = &arr[3]; printf(" *pip - *pi: %d (30)\n", *pip - *pi); printf(" pip - pi: %d (3)\n", pip - pi); printf(" *pip: %d (40)\n", *pip); printf(" *(pip - 3): %d (10)\n", *(pip - 3)); printf(" *&arr[3]: %d (40)\n", *&arr[3]); printf("*(&arr[3] - 3): %d (10)\n", *(&arr[3]-3)); } ================================================ FILE: share/examples/c/test2.c ================================================ #include #include #include #include int aaa; int bbb; int ccc; char gc; char gbuffer[3]; int gibuffer[4]; int main(void) { char b; int la; unsigned int u1, u2; int s1, s2; unsigned char uc1, uc2; char sc1, sc2; int fd; char buffer[6]; int ibuffer[7]; printf(" sizeof(uc1): %d 1\n", sizeof(uc1)); printf(" sizeof(sc1): %d 1\n", sizeof(sc1)); printf(" sizeof(u1): %d 4\n", sizeof(u1)); printf(" sizeof(s1): %d 4\n", sizeof(s1)); printf(" sizeof(aaa): %d 4\n", sizeof(aaa)); printf(" sizeof(bbb): %d 4\n", sizeof(bbb)); printf(" sizeof(gc): %d 1\n", sizeof(gc)); printf(" sizeof(buffer): %d 6\n", sizeof(buffer)); printf(" sizeof(ibuffer): %d 28\n", sizeof(ibuffer)); printf(" sizeof(char): %d 1\n", sizeof(char)); printf(" sizeof(int): %d 4\n", sizeof(int)); printf(" sizeof(gbuffer): %d 3\n", sizeof(gbuffer)); printf(" sizeof(gibuffer): %d 16\n", sizeof(gibuffer)); // sizeof(ibuffer[0]) is not supported, so the following can be used... printf("sizeof(ibuffer)/sizeof(int): %d 7\n", sizeof(ibuffer)/sizeof(int)); aaa = 1; bbb = 2; la = 4; printf("%d 1\n", aaa); printf("%d 2\n", bbb); printf("%d 4\n", la); uc1 = 0x80; sc1 = 0x80; s1 = uc1; s2 = sc1; printf("unsigned char (0x80) -> int: %d 128\n", s1); printf(" signed char (0x80) -> int: %d -128\n", s2); u1 = uc1; u2 = sc1; printf("unsigned char (0x80) -> unsigned: %d 128\n", u1); printf(" signed char (0x80) -> unsigned: %d -128\n", u2); la = errno; printf("errno: %d 0\n", la); write(1, "abcd ", 5); la = errno; printf("errno after good write call: %d 0\n", la); write(10, "abcde", 5); la = errno; printf("errno after bad write call: %d 9\n", la); write(1, "abcd ", 5); la = errno; printf("good write after failed should not overwrite errno: %d 9\n", la); errno = 0; write(1, "abcd ", 5); la = errno; printf("good write after errno set to zero: %d 0\n", la); la = write(1, "abcd ", 5); printf("write() return: %d 5\n", la); la = write(10, "abcd ", 5); printf("write(bad fd) return: %d -1\n", la); fd = open("/a.txt", O_WRONLY | O_CREAT, 0666); if (fd != -1) { printf("open success\n"); la = write(fd, "abcd\n", 5); if (la == 5) printf("write success\n"); else printf("write failed\n"); la = close(fd); if (la != -1) printf("close success\n"); else printf("close failed\n"); } else { printf("open failed\n"); } buffer[0] = 0; buffer[1] = 0; buffer[2] = 0; buffer[3] = 0; buffer[4] = 0; buffer[5] = 0; fd = open("/a.txt", O_RDONLY, 0666); if (fd != -1) { printf("open success\n"); la = read(fd, buffer, 5); printf(buffer); if (la == 5) printf("read success\n"); else printf("read failed\n"); la = close(fd); if (la != -1) printf("close success\n"); else printf("close failed\n"); } else { printf("open failed\n"); } if (buffer[0] != 'a') printf("data0 readback from file MISMATCH\n"); if (buffer[1] != 'b') printf("data1 readback from file MISMATCH\n"); if (buffer[2] != 'c') printf("data2 readback from file MISMATCH\n"); if (buffer[3] != 'd') printf("data3 readback from file MISMATCH\n"); if (buffer[4] != '\n') printf("data4 readback from file MISMATCH\n"); if (buffer[0] != 'a' || buffer[1] != 'b' || buffer[2] != 'c' || buffer[3] != 'd' || buffer[4] != '\n') { printf("data readback from file MISMATCH\n"); } else { printf("data readback from file OK\n"); } } ================================================ FILE: share/examples/c/test3.c ================================================ #include void printt(int t, char* str); int main(void) { int t; t = 0; if (t) printt(t, "failure"); else printt(t, "success"); t = 1; if (t) printt(t, "success"); else printt(t, "failure"); t = 8; if (t) printt(t, "success"); else printt(t, "failure"); t = -2; if (t) printt(t, "success"); else printt(t, "failure"); printf("\n"); t = 4; printf("switch test: "); switch (t) { case 3: printf("failure"); break; case 4: printf("success"); break; case 5: printf("failure"); break; } printf("\n"); printf("switch fallthrough test: "); switch (t) { case 3: printf("failure"); break; case 4: printf("OKSOFAR: "); case 5: printf("success if oksofar printed before this in caps"); break; } printf("\n"); } void printt(int t, char* str) { printf("bool test on value %d %s\n", t, str); } ================================================ FILE: share/examples/c/tetris.c ================================================ /* * Tetris (C) Copyright 1995, Vadim Antonov * Port to RetroBSD (C) 2015, Serge Vakulenko * * This program is designed to run on Olimex Duinomite board * with SainSmart Graphic LCD4884 shield, modified for 3.3V. * * Permission to use, copy, modify, and distribute this software * and its documentation for any purpose and without fee is hereby * granted, provided that the above copyright notice appear in all * copies and that both that the copyright notice and this * permission notice and warranty disclaimer appear in supporting * documentation, and that the name of the author not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * * The author disclaim all warranties with regard to this * software, including all implied warranties of merchantability * and fitness. In no event shall the author be liable for any * special, indirect or consequential damages or any damages * whatsoever resulting from loss of use, data or profits, whether * in an action of contract, negligence or other tortious action, * arising out of or in connection with the use or performance of * this software. */ #include #include #include #include #include #include #define PITWIDTH 12 #define PITDEPTH 21 #define NSHAPES 7 #define NBLOCKS 5 #define FIN 999 typedef struct { int x, y; } coord_t; typedef struct { int dx, dy; coord_t p[NBLOCKS]; } shape_t; const shape_t shape [NSHAPES] = { /* OOOO */ { 0, 3, { {0,0}, {0,1}, {0,2}, {0,3}, {FIN,FIN} } }, /* O */ { 1, 2, { {0,0}, {1,0}, {1,1}, {1,2}, {FIN,FIN} } }, /* OOO */ /* O */ { 1, 2, { {0,1}, {1,0}, {1,1}, {1,2}, {FIN,FIN} } }, /* OOO */ /* O */ { 1, 2, { {0,2}, {1,0}, {1,1}, {1,2}, {FIN,FIN} } }, /* OOO */ /* OO */ { 1, 2, { {0,0}, {0,1}, {1,1}, {1,2}, {FIN,FIN} } }, /* OO */ /* OO */ { 1, 2, { {0,1}, {0,2}, {1,0}, {1,1}, {FIN,FIN} } }, /* OO */ /* OO */ { 1, 1, { {0,0}, {0,1}, {1,0}, {1,1}, {FIN,FIN} } }, /* OO */ }; int pit [PITDEPTH+1] [PITWIDTH]; int pitcnt [PITDEPTH]; coord_t old [NBLOCKS], new [NBLOCKS], chk [NBLOCKS]; int gpio; /* File descriptor of GPIO driver. */ int adc3; /* File descriptor of ADC3 driver. */ /*------------------------------------------------------------- * Definitions for a "digital" joystick at A0 analog input. * Button values are determined by resistors on a board. */ enum { JOYSTICK_LEFT, JOYSTICK_SELECT, JOYSTICK_DOWN, JOYSTICK_RIGHT, JOYSTICK_UP, JOYSTICK_IDLE = -1, }; /* * Initialize ADC for a joystick. */ void joystick_init() { /* Open ADC driver. */ adc3 = open("/dev/adc3", 0); if (adc3 < 0) { perror("/dev/adc3"); exit(-1); } } /* * Get a state of joystick. * Convert ADC value to key number. * Input buttons are connected to a series network of resistors: * GND - 3.3k - 1k - 620 - 330 - 2k - +3.3V * Expected values are: * 0 - 144 - 329 - 506 - 741 - 1023 */ int joystick_get() { static const unsigned level[5] = { 72, 236, 417, 623, 882 }; unsigned input, k; char buf[16]; if (read(adc3, buf, sizeof(buf)) <= 0) { perror("adc"); exit(-1); } input = strtol(buf, 0, 10); for (k=0; k<5; k++) { if (input < level[k]) { return k; } } return JOYSTICK_IDLE; } /*------------------------------------------------------------- * Routines for Nokia 5110 display. * See Philips PCD8544 datasheet. */ #define NROW 48 #define NCOL 84 /* * Pinout for SainSmart Graphic LCD4884 Shield. */ #define MASKE_LCD_SCK (1 << 2) /* signal D2, pin RE2 */ #define MASKE_LCD_MOSI (1 << 3) /* signal D3, pin RE3 */ #define MASKE_LCD_DC (1 << 4) /* signal D4, pin RE4 */ #define MASKE_LCD_CS (1 << 5) /* signal D5, pin RE5 */ #define MASKE_LCD_RST (1 << 6) /* signal D6, pin RE6 */ #define MASKE_LCD_BL (1 << 7) /* signal D7, pin RE7 */ static unsigned char gpanel_screen [NROW*NCOL/8]; int gpanel_row, gpanel_col; static void lcd_cs(unsigned on) { if (on) { ioctl(gpio, GPIO_PORTE | GPIO_SET, MASKE_LCD_CS); } else { ioctl(gpio, GPIO_PORTE | GPIO_CLEAR, MASKE_LCD_CS); } } static void lcd_rst(unsigned on) { if (on) { ioctl(gpio, GPIO_PORTE | GPIO_SET, MASKE_LCD_RST); } else { ioctl(gpio, GPIO_PORTE | GPIO_CLEAR, MASKE_LCD_RST); } } static void lcd_dc(unsigned on) { if (on) { ioctl(gpio, GPIO_PORTE | GPIO_SET, MASKE_LCD_DC); } else { ioctl(gpio, GPIO_PORTE | GPIO_CLEAR, MASKE_LCD_DC); } } static void lcd_bl(unsigned on) { if (on) { ioctl(gpio, GPIO_PORTE | GPIO_SET, MASKE_LCD_BL); } else { ioctl(gpio, GPIO_PORTE | GPIO_CLEAR, MASKE_LCD_BL); } } static void lcd_mosi(unsigned on) { if (on) { ioctl(gpio, GPIO_PORTE | GPIO_SET, MASKE_LCD_MOSI); } else { ioctl(gpio, GPIO_PORTE | GPIO_CLEAR, MASKE_LCD_MOSI); } } static void lcd_sck(unsigned on) { if (on) { ioctl(gpio, GPIO_PORTE | GPIO_SET, MASKE_LCD_SCK); } else { ioctl(gpio, GPIO_PORTE | GPIO_CLEAR, MASKE_LCD_SCK); } } static void lcd_write(unsigned byte, unsigned data_flag) { unsigned i; lcd_cs(0); lcd_dc(data_flag); for (i=0; i<8; i++, byte<<=1) { lcd_mosi(byte & 0x80); /* SDIN = bit[i] */ lcd_sck(0); /* SCLK = 0 */ lcd_sck(1); /* SCLK = 1 */ } lcd_cs(1); } /* * Set up hardware for communication to Nokia 5110 LCD Display. * Do not clear the display. * Leave backlight turned off. */ void gpanel_init() { gpanel_row = 0; gpanel_col = 0; /* Open GPIO driver. */ gpio = open("/dev/porta", 0); if (gpio < 0) { perror("/dev/porta"); exit(-1); } /* * Set pins as outputs. */ ioctl(gpio, GPIO_PORTE | GPIO_CONFOUT, MASKE_LCD_SCK | MASKE_LCD_MOSI | MASKE_LCD_DC | MASKE_LCD_CS | MASKE_LCD_RST | MASKE_LCD_BL); ioctl(gpio, GPIO_PORTE | GPIO_SET, MASKE_LCD_RST | MASKE_LCD_CS); ioctl(gpio, GPIO_PORTE | GPIO_CLEAR, MASKE_LCD_SCK | MASKE_LCD_MOSI | MASKE_LCD_DC | MASKE_LCD_BL); /* Turn off backlight. */ lcd_bl(0); /* Reset the display. */ lcd_rst(0); usleep(10000); // need 1 usec lcd_rst(1); usleep(10000); // need 1 usec lcd_write(0x21, 0); // Enable extended instruction set lcd_write(0xbf, 0); // Set Vop - contrast level lcd_write(0x04, 0); // Set temperature coefficient to 0 lcd_write(0x14, 0); // Set bias to 4 lcd_write(0x20, 0); // Back to normal instruction set lcd_write(0x0c, 0); // Set normal mode /* Enable backlight. */ lcd_bl(1); } /* * Clear the the LCD screen. */ void gpanel_clear() { unsigned i; /* Clear data */ lcd_write(0x40, 0); lcd_write(0x80, 0); for (i=0; i= NCOL || y >= NROW) return; data = &gpanel_screen [(y >> 3) * NCOL + x]; if (color) *data |= 1 << (y & 7); else *data &= ~(1 << (y & 7)); lcd_write(0x40 | (y >> 3), 0); lcd_write(0x80 | x, 0); lcd_write(*data, 1); } /* * Draw a filled rectangle in the specified color from (x1,y1) to (x2,y2). * * The best way to fill a rectangle is to take advantage of the "wrap-around" featute * built into the Philips PCF8833 controller. By defining a drawing box, the memory can * be simply filled by successive memory writes until all pixels have been illuminated. */ void gpanel_rect_filled(int x0, int y0, int x1, int y1, int color) { /* Temporary solution */ int xmin, xmax, ymin, ymax, x, y; /* calculate the min and max for x and y directions */ if (x0 <= x1) { xmin = x0; xmax = x1; } else { xmin = x1; xmax = x0; } if (y0 <= y1) { ymin = y0; ymax = y1; } else { ymin = y1; ymax = y0; } for (y=ymin; y<=ymax; y++) for (x=xmin; x<=xmax; x++) gpanel_pixel(x, y, color); } /*------------------------------------------------------------- * Output piece coordinates given its center and angle */ void translate(const shape_t *t, const coord_t *c, int a, coord_t *res) { coord_t org, tmp; int yw, xw, i; if (a & 1) { /* 90 deg */ xw = t->dy; yw = t->dx; } else { xw = t->dx; yw = t->dy; } org = *c; org.x -= (xw + 1) / 2; org.y -= yw / 2; if (org.y < 0) org.y = 0; if (org.y + yw >= PITWIDTH && c->y <= PITWIDTH) org.y = PITWIDTH-1 - yw; for (i=0; t->p[i].x!=FIN; i++) { switch (a) { case 0: res[i].x = t->p[i].x; res[i].y = t->p[i].y; break; case 3: res[i].x = xw - t->p[i].y; res[i].y = t->p[i].x; break; case 2: res[i].x = xw - t->p[i].x; res[i].y = yw - t->p[i].y; break; case 1: res[i].x = t->p[i].y; res[i].y = yw - t->p[i].x; } res[i].x += org.x; res[i].y += org.y; } res[i].x = res[i].y = FIN; do { xw = 0; for (i=0; res[i+1].x!=FIN; i++) { if (res[i].x < res[i+1].x) continue; if (res[i].x == res[i+1].x && res[i].y <= res[i+1].y) continue; xw++; tmp = res[i]; res[i] = res[i+1]; res[i+1] = tmp; } } while (xw); } /* * Draw the block */ void draw_block(int h, int w, int visible) { h *= 4; w *= 4; if (visible) { gpanel_rect_filled(NCOL-1 - h, w, NCOL-1 - (h + 3), w + 3, 1); } else { gpanel_rect_filled(NCOL-1 - h, w, NCOL-1 - (h + 3), w + 3, 0); if (h == (PITDEPTH-1)*5) gpanel_pixel(NCOL-1 - (h + 3), w + 2, 1); if (w == 0) gpanel_pixel(NCOL-1 - (h + 2), w, 1); else if (w % 16 == 12) gpanel_pixel(NCOL-1 - (h + 2), w + 3, 1); } } /* * Move the piece */ void move(coord_t *old, coord_t *new) { for (;;) { if (old->x == FIN) { draw: if (new->x == FIN) break; if (new->x >= 0) draw_block(new->x, new->y, 1); new++; continue; } if (new->x == FIN) { clear: if (old->x >= 0) draw_block(old->x, old->y, 0); old++; continue; } if (old->x > new->x) goto draw; if (old->x < new->x) goto clear; if (old->y > new->y) goto draw; if (old->y != new->y) goto clear; /* old & new at the same place */ old++; new++; } } /* * Draw the pit */ void clear() { int h, w; for (h=0; hx!=FIN; c++) { if (c->x <= 0) { /* Game over. */ clear(); return; } pit[c->x][c->y] = 1; ++pitcnt[c->x]; if (pitcnt[c->x] == PITWIDTH) nfull++; } if (! nfull) return; /* Clear upper nfull lines */ for (h=0; h0; h++) { if (pitcnt[h-k] == PITWIDTH) { k--; h--; continue; } for (w=0; w0; h--) { if (pitcnt[h] != PITWIDTH) continue; memmove(pit[0]+PITWIDTH, pit[0], h * sizeof(pit[0])); memset(pit[0], 0, sizeof(pit[0])); memmove(pitcnt+1, pitcnt, h * sizeof(pitcnt[0])); pitcnt[0] = 0; h++; } } int main() { int ptype; /* Piece type */ int angle, anew; /* Angle */ int msec; /* Timeout */ coord_t c, cnew, *cp; unsigned up_pressed = 0, left_pressed = 0; unsigned right_pressed = 0, down_pressed = 0; joystick_init(); gpanel_init(); gpanel_clear(); /* Draw the pit */ clear(); newpiece: ptype = rand() % NSHAPES; angle = rand() % 3; c.y = PITWIDTH/2 - 1; for (c.x= -2; ; c.x++) { translate(&shape[ptype], &c, angle, new); for (cp=new; cp->x!=FIN; cp++) { if (cp->x >= 0) goto ok; } } ok: /* Draw new piece */ for (cp=new; cp->x!=FIN; cp++) { if (cp->x >= 0) { draw_block(cp->x, cp->y, 1); } } memcpy(old, new, sizeof old); msec = 500; for (;;) { cnew = c; anew = angle; if (msec <= 0) { /* Timeout: move down */ msec = 500; cnew.x++; translate(&shape[ptype], &cnew, anew, chk); for (cp=chk; cp->x!=FIN; cp++) { if (cp->x >= 0 && pit[cp->x][cp->y]) { stopped(new); goto newpiece; } } goto check; } int key = joystick_get(); if (key != JOYSTICK_RIGHT) right_pressed = 0; else if (! right_pressed) { right_pressed = 1; /* Right: rotate */ if (--anew < 0) anew = 3; translate(&shape[ptype], &cnew, anew, chk); goto check; } if (key != JOYSTICK_UP) up_pressed = 0; else if (! up_pressed) { up_pressed = 1; /* Up: move left. */ if (cnew.y <= 0) continue; cnew.y--; translate(&shape[ptype], &cnew, anew, chk); goto check; } if (key != JOYSTICK_DOWN) down_pressed = 0; else if (! down_pressed) { down_pressed = 1; /* Down: move right */ if (cnew.y >= PITWIDTH-1) continue; cnew.y++; translate(&shape[ptype], &cnew, anew, chk); goto check; } if (key != JOYSTICK_LEFT) left_pressed = 0; else if (! left_pressed) { left_pressed = 1; /* Right: drop */ for (;;) { cnew.x++; translate(&shape[ptype], &cnew, anew, chk); for (cp=chk; cp->x!=FIN; cp++) { if (cp->x >= 0 && pit[cp->x][cp->y]) { cnew.x--; translate(&shape[ptype], &cnew, anew, chk); move(new, chk); stopped(chk); goto newpiece; } } } } usleep(10000); msec -= 10; continue; check: for (cp=chk; cp->x!=FIN; cp++) { if (cp->y < 0 || cp->y >= PITWIDTH) goto done; } for (cp=chk; cp->x!=FIN; cp++) { if (cp->x >= 0 && pit[cp->x][cp->y]) goto done; } c = cnew; angle = anew; memcpy(old, new, sizeof old); memcpy(new, chk, sizeof new); move(old, new); done: ; } } ================================================ FILE: share/examples/cube/Makefile ================================================ PROG = all backlight cube demo # Duinomite board #OBJS = duinomite.o # Fubarino board OBJS = fubarino.o all: $(PROG) all: all.c $(OBJS) cc $@.c $(OBJS) -o $@ backlight: backlight.c $(OBJS) cc $@.c $(OBJS) -o $@ cube: cube.c $(OBJS) cc $@.c $(OBJS) -o $@ demo: demo.c $(OBJS) cc $@.c $(OBJS) -o $@ clean: rm -f *.o *~ $(PROG) ================================================ FILE: share/examples/cube/Makefile-host ================================================ TOPSRC!=cd ../../..; pwd include ${TOPSRC}/share/mk/sys.mk CFLAGS += -Werror LIBS += -lm #all: demo demo: demo.o fubarino.o ${CC} ${LDFLAGS} -o demo.elf demo.o fubarino.o ${LIBS} ${OBJDUMP} -S demo.elf > demo.dis ${SIZE} demo.elf ${ELF2AOUT} demo.elf $@ clean: rm -f *.o *.elf ${MAN} demo *.elf *.dis tags *~ ================================================ FILE: share/examples/cube/README.txt ================================================ Examples for LED cube 8x8x8. ================================================ FILE: share/examples/cube/all.c ================================================ /* * Demo for LED cube 8x8x8. * Turn on all LEDs. */ #include #include "cube.h" int main() { static unsigned char data[8] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, }; int i; gpio_init(); gpio_le(0); gpio_plane(data); gpio_ext(1); for (;;) { for (i=0; i<8; i++) { gpio_layer(i); } } return 0; } ================================================ FILE: share/examples/cube/backlight.c ================================================ /* * Demo for LED cube 8x8x8. * Test backlight LEDs. */ #include #include "cube.h" int main() { gpio_init(); for (;;) { gpio_backlight_upper(1); usleep(500000); gpio_backlight_upper(0); gpio_backlight_lower(1); usleep(500000); gpio_backlight_lower(0); } return 0; } ================================================ FILE: share/examples/cube/cube.c ================================================ /* * Demo for LED cube 8x8x8. * Switch between two static images. */ #include #include #include "cube.h" void display(int duration, unsigned char *data) { struct timeval t0, now; int z, msec; gettimeofday(&t0, 0); z = 0; for (;;) { /* Send layer data. Latch is active, * so previous layer is still displayed. */ gpio_plane(data + z*CUBE_SIZE); /* Disable output, activate latch, * switch to next layer. */ gpio_oe(0); gpio_le(0); gpio_le(1); gpio_layer(z); gpio_oe(1); /* Next layer. */ z++; if (z >= CUBE_SIZE) { z = 0; /* Check time. */ gettimeofday(&now, 0); msec = (now.tv_sec - t0.tv_sec) * 1000; msec += (now.tv_usec - t0.tv_usec) / 1000; if (msec >= duration) break; } } } int main() { static unsigned char foo[64] = { 0xff, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0xff, 0x81, 0, 0, 0, 0, 0, 0, 0x81, 0x81, 0, 0, 0, 0, 0, 0, 0x81, 0x81, 0, 0, 0, 0, 0, 0, 0x81, 0x81, 0, 0, 0, 0, 0, 0, 0x81, 0x81, 0, 0, 0, 0, 0, 0, 0x81, 0x81, 0, 0, 0, 0, 0, 0, 0x81, 0xff, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0xff, }; static unsigned char bar[64] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x7e, 0x42, 0x42, 0x42, 0x42, 0x7e, 0, 0, 0x42, 0, 0, 0, 0, 0x42, 0, 0, 0x42, 0, 0, 0, 0, 0x42, 0, 0, 0x42, 0, 0, 0, 0, 0x42, 0, 0, 0x42, 0, 0, 0, 0, 0x42, 0, 0, 0x7e, 0x42, 0x42, 0x42, 0x42, 0x7e, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; gpio_init(); gpio_ext(1); for (;;) { display(500, foo); display(500, bar); } return 0; } ================================================ FILE: share/examples/cube/cube.h ================================================ /* * Interface to LED cube 8x8x8. */ #define CUBE_SIZE 8 void gpio_init(void); void gpio_ext(int on); void gpio_oe(int active); void gpio_le(int active); void gpio_backlight_upper(int on); void gpio_backlight_lower(int on); void gpio_layer(int z); void gpio_plane(unsigned char *data); ================================================ FILE: share/examples/cube/demo.c ================================================ #include #include #include #include "cube.h" #define AXIS_X 1 #define AXIS_Y 2 #define AXIS_Z 3 unsigned char cube[8][8]; // Delay loop. // This is not calibrated to milliseconds, // but we had allready made to many effects using this // calibration when we figured it might be a good idea // to calibrate it. void delay_ms(unsigned duration) { struct timeval t0, now; int z, msec; gettimeofday(&t0, 0); z = 0; for (;;) { /* Send layer data. Latch is active, * so previous layer is still displayed. */ gpio_plane(cube[z]); /* Disable output, activate latch, * switch to next layer. */ gpio_oe(0); gpio_le(0); gpio_le(1); gpio_layer(z); gpio_oe(1); /* Next layer. */ z++; if (z >= CUBE_SIZE) { z = 0; /* Check time. */ gettimeofday(&now, 0); msec = (now.tv_sec - t0.tv_sec) * 1000; msec += (now.tv_usec - t0.tv_usec) / 1000; if (msec >= duration) break; } } } // ========================================================================================== // Draw functions // ========================================================================================== // Set a single voxel to ON void setvoxel(int x, int y, int z) { if (inrange(x, y, z)) cube[z][y] |= (1 << x); } // Set a single voxel to ON void clrvoxel(int x, int y, int z) { if (inrange(x, y, z)) cube[z][y] &= ~(1 << x); } // This function validates that we are drawing inside the cube. int inrange(int x, int y, int z) { return x >= 0 && x < 8 && y >= 0 && y < 8 && z >= 0 && z < 8; } // Get the current status of a voxel int getvoxel(int x, int y, int z) { if (! inrange(x, y, z)) return 0; return (cube[z][y] >> x) & 1; } // In some effect we want to just take bool and write it to a voxel // this function calls the apropriate voxel manipulation function. void altervoxel(int x, int y, int z, int state) { if (state == 1) { setvoxel(x, y, z); } else { clrvoxel(x, y, z); } } // Flip the state of a voxel. // If the voxel is 1, its turned into a 0, and vice versa. void flpvoxel(int x, int y, int z) { if (inrange(x, y, z)) cube[z][y] ^= (1 << x); } // Makes sure x1 is alwas smaller than x2 // This is usefull for functions that uses for loops, // to avoid infinite loops void argorder(int ix1, int ix2, int *ox1, int *ox2) { if (ix1>ix2) { int tmp; tmp = ix1; ix1= ix2; ix2 = tmp; } *ox1 = ix1; *ox2 = ix2; } // Sets all voxels along a X/Y plane at a given point // on axis Z void setplane_z(int z) { int i; if (z>=0 && z<8) { for (i=0;i<8;i++) cube[z][i] = 0xff; } } // Clears voxels in the same manner as above void clrplane_z (int z) { int i; if (z>=0 && z<8) { for (i=0;i<8;i++) cube[z][i] = 0x00; } } void setplane_x(int x) { int z, y; if (x>=0 && x<8) { for (z=0;z<8;z++) { for (y=0;y<8;y++) { cube[z][y] |= (1 << x); } } } } void clrplane_x(int x) { int z; int y; if (x>=0 && x<8) { for (z=0;z<8;z++) { for (y=0;y<8;y++) { cube[z][y] &= ~(1 << x); } } } } void setplane_y(int y) { int z; if (y>=0 && y<8) { for (z=0;z<8;z++) cube[z][y] = 0xff; } } void clrplane_y(int y) { int z; if (y>=0 && y<8) { for (z=0;z<8;z++) cube[z][y] = 0x00; } } void setplane(char axis, unsigned char i) { switch (axis) { case AXIS_X: setplane_x(i); break; case AXIS_Y: setplane_y(i); break; case AXIS_Z: setplane_z(i); break; } } void clrplane(char axis, unsigned char i) { switch (axis) { case AXIS_X: clrplane_x(i); break; case AXIS_Y: clrplane_y(i); break; case AXIS_Z: clrplane_z(i); break; } } // Fill a value into all 64 byts of the cube buffer // Mostly used for clearing. fill(0x00) // or setting all on. fill(0xff) void fill(unsigned char pattern) { int z; int y; for (z=0;z<8;z++) { for (y=0;y<8;y++) { cube[z][y] = pattern; } } } // Returns a byte with a row of 1's drawn in it. // byteline(2,5) gives 0b00111100 char byteline(int start, int end) { return (0xff << start) & ~(0xff << (end+1)); } // Draw a box with all walls drawn and all voxels inside set void box_filled(int x1, int y1, int z1, int x2, int y2, int z2) { int iy; int iz; argorder(x1, x2, &x1, &x2); argorder(y1, y2, &y1, &y2); argorder(z1, z2, &z1, &z2); for (iz=z1;iz<=z2;iz++) { for (iy=y1;iy<=y2;iy++) { cube[iz][iy] |= byteline(x1, x2); } } } // Darw a hollow box with side walls. void box_walls(int x1, int y1, int z1, int x2, int y2, int z2) { int iy; int iz; argorder(x1, x2, &x1, &x2); argorder(y1, y2, &y1, &y2); argorder(z1, z2, &z1, &z2); for (iz=z1;iz<=z2;iz++) { for (iy=y1;iy<=y2;iy++) { if (iy == y1 || iy == y2 || iz == z1 || iz == z2) { cube[iz][iy] = byteline(x1, x2); } else { cube[iz][iy] |= ((0x01 << x1) | (0x01 << x2)); } } } } // Draw a wireframe box. This only draws the corners and edges, // no walls. void box_wireframe(int x1, int y1, int z1, int x2, int y2, int z2) { int iy; int iz; argorder(x1, x2, &x1, &x2); argorder(y1, y2, &y1, &y2); argorder(z1, z2, &z1, &z2); // Lines along X axis cube[z1][y1] = byteline(x1, x2); cube[z1][y2] = byteline(x1, x2); cube[z2][y1] = byteline(x1, x2); cube[z2][y2] = byteline(x1, x2); // Lines along Y axis for (iy=y1;iy<=y2;iy++) { setvoxel(x1, iy, z1); setvoxel(x1, iy, z2); setvoxel(x2, iy, z1); setvoxel(x2, iy, z2); } // Lines along Z axis for (iz=z1;iz<=z2;iz++) { setvoxel(x1, y1, iz); setvoxel(x1, y2, iz); setvoxel(x2, y1, iz); setvoxel(x2, y2, iz); } } // Draw a line between any coordinates in 3d space. // Uses integer values for input, so dont expect smooth animations. void line(int x1, int y1, int z1, int x2, int y2, int z2) { int x, y, z, dx, dy, dz; int lasty, lastz; // We always want to draw the line from x=0 to x=7. // If x1 is bigget than x2, we need to flip all the values. if (x1 > x2) { int tmp; tmp = x2; x2 = x1; x1 = tmp; tmp = y2; y2 = y1; y1 = tmp; tmp = z2; z2 = z1; z1 = tmp; } dx = x2 - x1; if (y1 > y2) { dy = y1 - y2; lasty = y2; } else { dy = y2 - y1; lasty = y1; } if (z1 > z2) { dz = z1 - z2; lastz = z2; } else { dz = z2 - z1; lastz = z1; } // For each step of x, y increments by: for (x = x1; x <= x2; x++) { y = (dy * (x-x1) / dx) + y1; z = (dz * (x-x1) / dx) + z1; setvoxel(x, y, z); } } // Shift the entire contents of the cube along an axis // This is great for effects where you want to draw something // on one side of the cube and have it flow towards the other // side. Like rain flowing down the Z axiz. void shift(char axis, int direction) { int i, x, y; int ii, iii; int state; for (i = 0; i < 8; i++) { if (direction == -1) { ii = i; } else { ii = (7-i); } for (x = 0; x < 8; x++) { for (y = 0; y < 8; y++) { if (direction == -1) { iii = ii+1; } else { iii = ii-1; } if (axis == AXIS_Z) { state = getvoxel(x, y, iii); altervoxel(x, y, ii, state); } if (axis == AXIS_Y) { state = getvoxel(x, iii, y); altervoxel(x, ii, y, state); } if (axis == AXIS_X) { state = getvoxel(iii, y, x); altervoxel(ii, y, x, state); } } } } if (direction == -1) { i = 7; } else { i = 0; } for (x = 0; x < 8; x++) { for (y = 0; y < 8; y++) { if (axis == AXIS_Z) clrvoxel(x, y, i); if (axis == AXIS_Y) clrvoxel(x, i, y); if (axis == AXIS_X) clrvoxel(i, y, x); } } } // ========================================================================================== // Effect functions // ========================================================================================== void fireworks(int iterations, int delay) { #define NFIREWORKS 30 int i, f, e; int origin_x = 3; int origin_y = 3; int origin_z = 3; int rand_y, rand_x, rand_z; int slowrate, gravity; // Particles and their position, x,y,z and their movement, dx,dy,dz. // Scaled by 100 for integer arith. int particles[NFIREWORKS][6]; fill(0x00); for (i=0; i 64) { sin_of -= 64; inv = 1-inv; } if (inv) return -LUT[sin_of]; else return LUT[sin_of]; } int totty_cos(int cos_of) { unsigned char inv = 0; cos_of += 32; // Simply rotate by 90 degrees for COS cos_of &= 0x7f; // 127 if (cos_of > 64) { cos_of -= 64; inv = 1; } if (inv) return -LUT[cos_of]; else return LUT[cos_of]; } void quad_ripples(int iterations, int delay) { // 16 values for square root of a^2+b^2. index a*4+b = 10*sqrt // This gives the distance to 3.5,3.5 from the point unsigned char sqrt_LUT[] = { 49, 43, 38, 35, 43, 35, 29, 26, 38, 29, 21, 16, 35, 25, 16, 7 }; unsigned char x, y, height, distance; int i; for (i=0; i=1;i--) { effect_random_sparkle_flash(5, i, 100); } } int effect_telcstairs_do(int x, int val, int delay) { int y, z; for(y = 0, z = x; y <= z; y++, x--) { if(x < CUBE_SIZE && y < CUBE_SIZE) { cube[x][y] = val; } } delay_ms(delay); return z; } void effect_telcstairs(int invert, int delay, int val) { int x; if(invert) { for(x = CUBE_SIZE*2; x >= 0; x--) { x = effect_telcstairs_do(x, val, delay); } } else { for(x = 0; x < CUBE_SIZE*2; x++) { x = effect_telcstairs_do(x, val, delay); } } } void draw_positions_axis(char axis, unsigned char positions[64], int invert) { int x, y, p; fill(0x00); for (x=0; x<8; x++) { for (y=0; y<8; y++) { if (invert) { p = (7-positions[(x*8)+y]); } else { p = positions[(x*8)+y]; } if (axis == AXIS_Z) setvoxel(x, y, p); if (axis == AXIS_Y) setvoxel(x, p, y); if (axis == AXIS_X) setvoxel(p, y, x); } } } void effect_wormsqueeze(int size, int axis, int direction, int iterations, int delay) { int x, y, i, j, k, dx, dy; int cube_size; int origin = 0; if (direction == -1) origin = 7; cube_size = 8-(size-1); x = rand()%cube_size; y = rand()%cube_size; for (i=0; i 0 && (x+dx) < cube_size) x += dx; if ((y+dy) > 0 && (y+dy) < cube_size) y += dy; shift(axis, direction); for (j=0; j= 0) { x_inc = 1; l = dx; } else { x_inc = -1; l = -dx; } if (dy >= 0) { y_inc = 1; m = dy; } else { y_inc = -1; m = -dy; } if (dz >= 0) { z_inc = 1; n = dz; } else { z_inc = -1; n = -dz; } dx2 = l << 1; dy2 = m << 1; dz2 = n << 1; if ((l >= m) && (l >= n)) { err_1 = dy2 - l; err_2 = dz2 - l; for (i = 0; i < l; i++) { //PUT_PIXEL(pixel); setvoxel(pixel[0], pixel[1], pixel[2]); //printf("Setting %i %i %i \n", pixel[0], pixel[1], pixel[2]); if (err_1 > 0) { pixel[1] += y_inc; err_1 -= dx2; } if (err_2 > 0) { pixel[2] += z_inc; err_2 -= dx2; } err_1 += dy2; err_2 += dz2; pixel[0] += x_inc; } } else if ((m >= l) && (m >= n)) { err_1 = dx2 - m; err_2 = dz2 - m; for (i = 0; i < m; i++) { //PUT_PIXEL(pixel); setvoxel(pixel[0], pixel[1], pixel[2]); //printf("Setting %i %i %i \n", pixel[0], pixel[1], pixel[2]); if (err_1 > 0) { pixel[0] += x_inc; err_1 -= dy2; } if (err_2 > 0) { pixel[2] += z_inc; err_2 -= dy2; } err_1 += dx2; err_2 += dz2; pixel[1] += y_inc; } } else { err_1 = dy2 - n; err_2 = dx2 - n; for (i = 0; i < n; i++) { setvoxel(pixel[0], pixel[1], pixel[2]); //printf("Setting %i %i %i \n", pixel[0], pixel[1], pixel[2]); //PUT_PIXEL(pixel); if (err_1 > 0) { pixel[1] += y_inc; err_1 -= dz2; } if (err_2 > 0) { pixel[0] += x_inc; err_2 -= dz2; } err_1 += dy2; err_2 += dx2; pixel[2] += z_inc; } } setvoxel(pixel[0], pixel[1], pixel[2]); //printf("Setting %i %i %i \n", pixel[0], pixel[1], pixel[2]); //PUT_PIXEL(pixel); } #if 0 void sinelines(int iterations, int delay) { int i, x; float left, right, sine_base, x_dividor, ripple_height; for (i=0; i 0 && pos[i] <7) { pos[i] += 1; } if (pos[i] == 7) done++; } if (done == 64) notdone = 0; for (i=0;i<64;i++) { if (origin == 0) { cubepos[i] = pos[i]; } else { cubepos[i] = (7-pos[i]); } } delay_ms(delay); draw_positions_axis(axis, cubepos, 0); } } void effect_rain(int iterations) { int i, ii; int rnd_x; int rnd_y; int rnd_num; for (ii=0;iidestinations[px]) { positions[px]--; } } draw_positions_axis(axis, positions, invert); delay_ms(delay); } } void effect_blinky2() { int i, r; fill(0x00); for (r=0;r<2;r++) { i = 350; while (i>0) { fill(0x00); delay_ms(i); fill(0xff); delay_ms(100); i = i - (7 + (500 / (i/10))); } delay_ms(500); i = 350; while (i>0) { fill(0x00); delay_ms(351-i); fill(0xff); delay_ms(100); i = i - (7 + (500 / (i/10))); } } } // Draw a plane on one axis and send it back and forth once. void effect_planboing(int plane, int speed) { int i; for (i=0;i<8;i++) { fill(0x00); setplane(plane, i); delay_ms(speed); } for (i=7;i>=0;i--) { fill(0x00); setplane(plane, i); delay_ms(speed); } } //******************************************************** // ******************************************************** const char font_data[128][8] = { { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, // 0 : // | | // | | // | | // | | // | | // | | // | | // | | { 0x00, 0x3E, 0x41, 0x55, 0x41, 0x55, 0x49, 0x3E }, // 1 :  // | | // | ***** | // | * * | // | * * * * | // | * * | // | * * * * | // | * * * | // | ***** | { 0x00, 0x3E, 0x7F, 0x6B, 0x7F, 0x6B, 0x77, 0x3E }, // 2 :  // | | // | ***** | // | ******* | // | ** * ** | // | ******* | // | ** * ** | // | *** *** | // | ***** | { 0x00, 0x22, 0x77, 0x7F, 0x7F, 0x3E, 0x1C, 0x08 }, // 3 :  // | | // | * * | // | *** *** | // | ******* | // | ******* | // | ***** | // | *** | // | * | { 0x00, 0x08, 0x1C, 0x3E, 0x7F, 0x3E, 0x1C, 0x08 }, // 4 :  // | | // | * | // | *** | // | ***** | // | ******* | // | ***** | // | *** | // | * | { 0x00, 0x08, 0x1C, 0x2A, 0x7F, 0x2A, 0x08, 0x1C }, // 5 :  // | | // | * | // | *** | // | * * * | // | ******* | // | * * * | // | * | // | *** | { 0x00, 0x08, 0x1C, 0x3E, 0x7F, 0x3E, 0x08, 0x1C }, // 6 :  // | | // | * | // | *** | // | ***** | // | ******* | // | ***** | // | * | // | *** | { 0x00, 0x00, 0x1C, 0x3E, 0x3E, 0x3E, 0x1C, 0x00 }, // 7 : // | | // | | // | *** | // | ***** | // | ***** | // | ***** | // | *** | // | | { 0xFF, 0xFF, 0xE3, 0xC1, 0xC1, 0xC1, 0xE3, 0xFF }, // 8 :  // | ******** | // | ******** | // | *** ** | // | ** * | // | ** * | // | ** * | // | *** ** | // | ******** | { 0x00, 0x00, 0x1C, 0x22, 0x22, 0x22, 0x1C, 0x00 }, // 9 : // | | // | | // | *** | // | * * | // | * * | // | * * | // | *** | // | | { 0xFF, 0xFF, 0xE3, 0xDD, 0xDD, 0xDD, 0xE3, 0xFF }, // 10 : // | ******** | // | ******** | // | *** ** | // | ** *** * | // | ** *** * | // | ** *** * | // | *** ** | // | ******** | { 0x00, 0x0F, 0x03, 0x05, 0x39, 0x48, 0x48, 0x30 }, // 11 : // | | // | **** | // | ** | // | * * | // | *** * | // | * * | // | * * | // | ** | { 0x00, 0x08, 0x3E, 0x08, 0x1C, 0x22, 0x22, 0x1C }, // 12 : // | | // | * | // | ***** | // | * | // | *** | // | * * | // | * * | // | *** | { 0x00, 0x18, 0x14, 0x10, 0x10, 0x30, 0x70, 0x60 }, // 13 : // | | // | ** | // | * * | // | * | // | * | // | ** | // | *** | // | ** | { 0x00, 0x0F, 0x19, 0x11, 0x13, 0x37, 0x76, 0x60 }, // 14 :  // | | // | **** | // | ** * | // | * * | // | * ** | // | ** *** | // | *** ** | // | ** | { 0x00, 0x08, 0x2A, 0x1C, 0x77, 0x1C, 0x2A, 0x08 }, // 15 :  // | | // | * | // | * * * | // | *** | // | *** *** | // | *** | // | * * * | // | * | { 0x00, 0x60, 0x78, 0x7E, 0x7F, 0x7E, 0x78, 0x60 }, // 16 :  // | | // | ** | // | **** | // | ****** | // | ******* | // | ****** | // | **** | // | ** | { 0x00, 0x03, 0x0F, 0x3F, 0x7F, 0x3F, 0x0F, 0x03 }, // 17 :  // | | // | ** | // | **** | // | ****** | // | ******* | // | ****** | // | **** | // | ** | { 0x00, 0x08, 0x1C, 0x2A, 0x08, 0x2A, 0x1C, 0x08 }, // 18 :  // | | // | * | // | *** | // | * * * | // | * | // | * * * | // | *** | // | * | { 0x00, 0x66, 0x66, 0x66, 0x66, 0x00, 0x66, 0x66 }, // 19 :  // | | // | ** ** | // | ** ** | // | ** ** | // | ** ** | // | | // | ** ** | // | ** ** | { 0x00, 0x3F, 0x65, 0x65, 0x3D, 0x05, 0x05, 0x05 }, // 20 :  // | | // | ****** | // | ** * * | // | ** * * | // | **** * | // | * * | // | * * | // | * * | { 0x00, 0x0C, 0x32, 0x48, 0x24, 0x12, 0x4C, 0x30 }, // 21 :  // | | // | ** | // | ** * | // | * * | // | * * | // | * * | // | * ** | // | ** | { 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x7F, 0x7F }, // 22 :  // | | // | | // | | // | | // | | // | ******* | // | ******* | // | ******* | { 0x00, 0x08, 0x1C, 0x2A, 0x08, 0x2A, 0x1C, 0x3E }, // 23 :  // | | // | * | // | *** | // | * * * | // | * | // | * * * | // | *** | // | ***** | { 0x00, 0x08, 0x1C, 0x3E, 0x7F, 0x1C, 0x1C, 0x1C }, // 24 :  // | | // | * | // | *** | // | ***** | // | ******* | // | *** | // | *** | // | *** | { 0x00, 0x1C, 0x1C, 0x1C, 0x7F, 0x3E, 0x1C, 0x08 }, // 25 :  // | | // | *** | // | *** | // | *** | // | ******* | // | ***** | // | *** | // | * | { 0x00, 0x08, 0x0C, 0x7E, 0x7F, 0x7E, 0x0C, 0x08 }, // 26 :  // | | // | * | // | ** | // | ****** | // | ******* | // | ****** | // | ** | // | * | { 0x00, 0x08, 0x18, 0x3F, 0x7F, 0x3F, 0x18, 0x08 }, // 27 :  // | | // | * | // | ** | // | ****** | // | ******* | // | ****** | // | ** | // | * | { 0x00, 0x00, 0x00, 0x70, 0x70, 0x70, 0x7F, 0x7F }, // 28 :  // | | // | | // | | // | *** | // | *** | // | *** | // | ******* | // | ******* | { 0x00, 0x00, 0x14, 0x22, 0x7F, 0x22, 0x14, 0x00 }, // 29 :  // | | // | | // | * * | // | * * | // | ******* | // | * * | // | * * | // | | { 0x00, 0x08, 0x1C, 0x1C, 0x3E, 0x3E, 0x7F, 0x7F }, // 30 :  // | | // | * | // | *** | // | *** | // | ***** | // | ***** | // | ******* | // | ******* | { 0x00, 0x7F, 0x7F, 0x3E, 0x3E, 0x1C, 0x1C, 0x08 }, // 31 :  // | | // | ******* | // | ******* | // | ***** | // | ***** | // | *** | // | *** | // | * | { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, // 32 : // | | // | | // | | // | | // | | // | | // | | // | | { 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x18 }, // 33 : ! // | | // | ** | // | ** | // | ** | // | ** | // | ** | // | | // | ** | { 0x00, 0x36, 0x36, 0x14, 0x00, 0x00, 0x00, 0x00 }, // 34 : " // | | // | ** ** | // | ** ** | // | * * | // | | // | | // | | // | | { 0x00, 0x36, 0x36, 0x7F, 0x36, 0x7F, 0x36, 0x36 }, // 35 : # // | | // | ** ** | // | ** ** | // | ******* | // | ** ** | // | ******* | // | ** ** | // | ** ** | { 0x00, 0x08, 0x1E, 0x20, 0x1C, 0x02, 0x3C, 0x08 }, // 36 : $ // | | // | * | // | **** | // | * | // | *** | // | * | // | **** | // | * | { 0x00, 0x60, 0x66, 0x0C, 0x18, 0x30, 0x66, 0x06 }, // 37 : % // | | // | ** | // | ** ** | // | ** | // | ** | // | ** | // | ** ** | // | ** | { 0x00, 0x3C, 0x66, 0x3C, 0x28, 0x65, 0x66, 0x3F }, // 38 : & // | | // | **** | // | ** ** | // | **** | // | * * | // | ** * * | // | ** ** | // | ****** | { 0x00, 0x18, 0x18, 0x18, 0x30, 0x00, 0x00, 0x00 }, // 39 : ' // | | // | ** | // | ** | // | ** | // | ** | // | | // | | // | | { 0x00, 0x60, 0x30, 0x18, 0x18, 0x18, 0x30, 0x60 }, // 40 : ( // | | // | ** | // | ** | // | ** | // | ** | // | ** | // | ** | // | ** | { 0x00, 0x06, 0x0C, 0x18, 0x18, 0x18, 0x0C, 0x06 }, // 41 : ) // | | // | ** | // | ** | // | ** | // | ** | // | ** | // | ** | // | ** | { 0x00, 0x00, 0x36, 0x1C, 0x7F, 0x1C, 0x36, 0x00 }, // 42 : * // | | // | | // | ** ** | // | *** | // | ******* | // | *** | // | ** ** | // | | { 0x00, 0x00, 0x08, 0x08, 0x3E, 0x08, 0x08, 0x00 }, // 43 : + // | | // | | // | * | // | * | // | ***** | // | * | // | * | // | | { 0x00, 0x00, 0x00, 0x00, 0x30, 0x30, 0x30, 0x60 }, // 44 : , // | | // | | // | | // | | // | ** | // | ** | // | ** | // | ** | { 0x00, 0x00, 0x00, 0x00, 0x3C, 0x00, 0x00, 0x00 }, // 45 : - // | | // | | // | | // | | // | **** | // | | // | | // | | { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x60 }, // 46 : . // | | // | | // | | // | | // | | // | | // | ** | // | ** | { 0x00, 0x00, 0x06, 0x0C, 0x18, 0x30, 0x60, 0x00 }, // 47 : / // | | // | | // | ** | // | ** | // | ** | // | ** | // | ** | // | | { 0x00, 0x3C, 0x66, 0x6E, 0x76, 0x66, 0x66, 0x3C }, // 48 : 0 // | | // | **** | // | ** ** | // | ** *** | // | *** ** | // | ** ** | // | ** ** | // | **** | { 0x00, 0x18, 0x18, 0x38, 0x18, 0x18, 0x18, 0x7E }, // 49 : 1 // | | // | ** | // | ** | // | *** | // | ** | // | ** | // | ** | // | ****** | { 0x00, 0x3C, 0x66, 0x06, 0x0C, 0x30, 0x60, 0x7E }, // 50 : 2 // | | // | **** | // | ** ** | // | ** | // | ** | // | ** | // | ** | // | ****** | { 0x00, 0x3C, 0x66, 0x06, 0x1C, 0x06, 0x66, 0x3C }, // 51 : 3 // | | // | **** | // | ** ** | // | ** | // | *** | // | ** | // | ** ** | // | **** | { 0x00, 0x0C, 0x1C, 0x2C, 0x4C, 0x7E, 0x0C, 0x0C }, // 52 : 4 // | | // | ** | // | *** | // | * ** | // | * ** | // | ****** | // | ** | // | ** | { 0x00, 0x7E, 0x60, 0x7C, 0x06, 0x06, 0x66, 0x3C }, // 53 : 5 // | | // | ****** | // | ** | // | ***** | // | ** | // | ** | // | ** ** | // | **** | { 0x00, 0x3C, 0x66, 0x60, 0x7C, 0x66, 0x66, 0x3C }, // 54 : 6 // | | // | **** | // | ** ** | // | ** | // | ***** | // | ** ** | // | ** ** | // | **** | { 0x00, 0x7E, 0x66, 0x0C, 0x0C, 0x18, 0x18, 0x18 }, // 55 : 7 // | | // | ****** | // | ** ** | // | ** | // | ** | // | ** | // | ** | // | ** | { 0x00, 0x3C, 0x66, 0x66, 0x3C, 0x66, 0x66, 0x3C }, // 56 : 8 // | | // | **** | // | ** ** | // | ** ** | // | **** | // | ** ** | // | ** ** | // | **** | { 0x00, 0x3C, 0x66, 0x66, 0x3E, 0x06, 0x66, 0x3C }, // 57 : 9 // | | // | **** | // | ** ** | // | ** ** | // | ***** | // | ** | // | ** ** | // | **** | { 0x00, 0x00, 0x18, 0x18, 0x00, 0x18, 0x18, 0x00 }, // 58 : : // | | // | | // | ** | // | ** | // | | // | ** | // | ** | // | | { 0x00, 0x00, 0x18, 0x18, 0x00, 0x18, 0x18, 0x30 }, // 59 : ; // | | // | | // | ** | // | ** | // | | // | ** | // | ** | // | ** | { 0x00, 0x06, 0x0C, 0x18, 0x30, 0x18, 0x0C, 0x06 }, // 60 : < // | | // | ** | // | ** | // | ** | // | ** | // | ** | // | ** | // | ** | { 0x00, 0x00, 0x00, 0x3C, 0x00, 0x3C, 0x00, 0x00 }, // 61 : = // | | // | | // | | // | **** | // | | // | **** | // | | // | | { 0x00, 0x60, 0x30, 0x18, 0x0C, 0x18, 0x30, 0x60 }, // 62 : > // | | // | ** | // | ** | // | ** | // | ** | // | ** | // | ** | // | ** | { 0x00, 0x3C, 0x66, 0x06, 0x1C, 0x18, 0x00, 0x18 }, // 63 : ? // | | // | **** | // | ** ** | // | ** | // | *** | // | ** | // | | // | ** | { 0x00, 0x38, 0x44, 0x5C, 0x58, 0x42, 0x3C, 0x00 }, // 64 : @ // | | // | *** | // | * * | // | * *** | // | * ** | // | * * | // | **** | // | | { 0x00, 0x3C, 0x66, 0x66, 0x7E, 0x66, 0x66, 0x66 }, // 65 : A // | | // | **** | // | ** ** | // | ** ** | // | ****** | // | ** ** | // | ** ** | // | ** ** | { 0x00, 0x7C, 0x66, 0x66, 0x7C, 0x66, 0x66, 0x7C }, // 66 : B // | | // | ***** | // | ** ** | // | ** ** | // | ***** | // | ** ** | // | ** ** | // | ***** | { 0x00, 0x3C, 0x66, 0x60, 0x60, 0x60, 0x66, 0x3C }, // 67 : C // | | // | **** | // | ** ** | // | ** | // | ** | // | ** | // | ** ** | // | **** | { 0x00, 0x7C, 0x66, 0x66, 0x66, 0x66, 0x66, 0x7C }, // 68 : D // | | // | ***** | // | ** ** | // | ** ** | // | ** ** | // | ** ** | // | ** ** | // | ***** | { 0x00, 0x7E, 0x60, 0x60, 0x7C, 0x60, 0x60, 0x7E }, // 69 : E // | | // | ****** | // | ** | // | ** | // | ***** | // | ** | // | ** | // | ****** | { 0x00, 0x7E, 0x60, 0x60, 0x7C, 0x60, 0x60, 0x60 }, // 70 : F // | | // | ****** | // | ** | // | ** | // | ***** | // | ** | // | ** | // | ** | { 0x00, 0x3C, 0x66, 0x60, 0x60, 0x6E, 0x66, 0x3C }, // 71 : G // | | // | **** | // | ** ** | // | ** | // | ** | // | ** *** | // | ** ** | // | **** | { 0x00, 0x66, 0x66, 0x66, 0x7E, 0x66, 0x66, 0x66 }, // 72 : H // | | // | ** ** | // | ** ** | // | ** ** | // | ****** | // | ** ** | // | ** ** | // | ** ** | { 0x00, 0x3C, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3C }, // 73 : I // | | // | **** | // | ** | // | ** | // | ** | // | ** | // | ** | // | **** | { 0x00, 0x1E, 0x0C, 0x0C, 0x0C, 0x6C, 0x6C, 0x38 }, // 74 : J // | | // | **** | // | ** | // | ** | // | ** | // | ** ** | // | ** ** | // | *** | { 0x00, 0x66, 0x6C, 0x78, 0x70, 0x78, 0x6C, 0x66 }, // 75 : K // | | // | ** ** | // | ** ** | // | **** | // | *** | // | **** | // | ** ** | // | ** ** | { 0x00, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x7E }, // 76 : L // | | // | ** | // | ** | // | ** | // | ** | // | ** | // | ** | // | ****** | { 0x00, 0x63, 0x77, 0x7F, 0x6B, 0x63, 0x63, 0x63 }, // 77 : M // | | // | ** ** | // | *** *** | // | ******* | // | ** * ** | // | ** ** | // | ** ** | // | ** ** | { 0x00, 0x63, 0x73, 0x7B, 0x6F, 0x67, 0x63, 0x63 }, // 78 : N // | | // | ** ** | // | *** ** | // | **** ** | // | ** **** | // | ** *** | // | ** ** | // | ** ** | { 0x00, 0x3C, 0x66, 0x66, 0x66, 0x66, 0x66, 0x3C }, // 79 : O // | | // | **** | // | ** ** | // | ** ** | // | ** ** | // | ** ** | // | ** ** | // | **** | { 0x00, 0x7C, 0x66, 0x66, 0x66, 0x7C, 0x60, 0x60 }, // 80 : P // | | // | ***** | // | ** ** | // | ** ** | // | ** ** | // | ***** | // | ** | // | ** | { 0x00, 0x3C, 0x66, 0x66, 0x66, 0x6E, 0x3C, 0x06 }, // 81 : Q // | | // | **** | // | ** ** | // | ** ** | // | ** ** | // | ** *** | // | **** | // | ** | { 0x00, 0x7C, 0x66, 0x66, 0x7C, 0x78, 0x6C, 0x66 }, // 82 : R // | | // | ***** | // | ** ** | // | ** ** | // | ***** | // | **** | // | ** ** | // | ** ** | { 0x00, 0x3C, 0x66, 0x60, 0x3C, 0x06, 0x66, 0x3C }, // 83 : S // | | // | **** | // | ** ** | // | ** | // | **** | // | ** | // | ** ** | // | **** | { 0x00, 0x7E, 0x5A, 0x18, 0x18, 0x18, 0x18, 0x18 }, // 84 : T // | | // | ****** | // | * ** * | // | ** | // | ** | // | ** | // | ** | // | ** | { 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x3E }, // 85 : U // | | // | ** ** | // | ** ** | // | ** ** | // | ** ** | // | ** ** | // | ** ** | // | ***** | { 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x3C, 0x18 }, // 86 : V // | | // | ** ** | // | ** ** | // | ** ** | // | ** ** | // | ** ** | // | **** | // | ** | { 0x00, 0x63, 0x63, 0x63, 0x6B, 0x7F, 0x77, 0x63 }, // 87 : W // | | // | ** ** | // | ** ** | // | ** ** | // | ** * ** | // | ******* | // | *** *** | // | ** ** | { 0x00, 0x63, 0x63, 0x36, 0x1C, 0x36, 0x63, 0x63 }, // 88 : X // | | // | ** ** | // | ** ** | // | ** ** | // | *** | // | ** ** | // | ** ** | // | ** ** | { 0x00, 0x66, 0x66, 0x66, 0x3C, 0x18, 0x18, 0x18 }, // 89 : Y // | | // | ** ** | // | ** ** | // | ** ** | // | **** | // | ** | // | ** | // | ** | { 0x00, 0x7E, 0x06, 0x0C, 0x18, 0x30, 0x60, 0x7E }, // 90 : Z // | | // | ****** | // | ** | // | ** | // | ** | // | ** | // | ** | // | ****** | { 0x00, 0x1E, 0x18, 0x18, 0x18, 0x18, 0x18, 0x1E }, // 91 : [ // | | // | **** | // | ** | // | ** | // | ** | // | ** | // | ** | // | **** | { 0x00, 0x00, 0x60, 0x30, 0x18, 0x0C, 0x06, 0x00 }, // 92 : \ // | | // | | // | ** | // | ** | // | ** | // | ** | // | ** | // | | { 0x00, 0x78, 0x18, 0x18, 0x18, 0x18, 0x18, 0x78 }, // 93 : ] // | | // | **** | // | ** | // | ** | // | ** | // | ** | // | ** | // | **** | { 0x00, 0x08, 0x14, 0x22, 0x41, 0x00, 0x00, 0x00 }, // 94 : ^ // | | // | * | // | * * | // | * * | // | * * | // | | // | | // | | { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F }, // 95 : _ // | | // | | // | | // | | // | | // | | // | | // | ******* | { 0x00, 0x0C, 0x0C, 0x06, 0x00, 0x00, 0x00, 0x00 }, // 96 : ` // | | // | ** | // | ** | // | ** | // | | // | | // | | // | | { 0x00, 0x00, 0x00, 0x3C, 0x06, 0x3E, 0x66, 0x3E }, // 97 : a // | | // | | // | | // | **** | // | ** | // | ***** | // | ** ** | // | ***** | { 0x00, 0x60, 0x60, 0x60, 0x7C, 0x66, 0x66, 0x7C }, // 98 : b // | | // | ** | // | ** | // | ** | // | ***** | // | ** ** | // | ** ** | // | ***** | { 0x00, 0x00, 0x00, 0x3C, 0x66, 0x60, 0x66, 0x3C }, // 99 : c // | | // | | // | | // | **** | // | ** ** | // | ** | // | ** ** | // | **** | { 0x00, 0x06, 0x06, 0x06, 0x3E, 0x66, 0x66, 0x3E }, // 100 : d // | | // | ** | // | ** | // | ** | // | ***** | // | ** ** | // | ** ** | // | ***** | { 0x00, 0x00, 0x00, 0x3C, 0x66, 0x7E, 0x60, 0x3C }, // 101 : e // | | // | | // | | // | **** | // | ** ** | // | ****** | // | ** | // | **** | { 0x00, 0x1C, 0x36, 0x30, 0x30, 0x7C, 0x30, 0x30 }, // 102 : f // | | // | *** | // | ** ** | // | ** | // | ** | // | ***** | // | ** | // | ** | { 0x00, 0x00, 0x3E, 0x66, 0x66, 0x3E, 0x06, 0x3C }, // 103 : g // | | // | | // | ***** | // | ** ** | // | ** ** | // | ***** | // | ** | // | **** | { 0x00, 0x60, 0x60, 0x60, 0x7C, 0x66, 0x66, 0x66 }, // 104 : h // | | // | ** | // | ** | // | ** | // | ***** | // | ** ** | // | ** ** | // | ** ** | { 0x00, 0x00, 0x18, 0x00, 0x18, 0x18, 0x18, 0x3C }, // 105 : i // | | // | | // | ** | // | | // | ** | // | ** | // | ** | // | **** | { 0x00, 0x0C, 0x00, 0x0C, 0x0C, 0x6C, 0x6C, 0x38 }, // 106 : j // | | // | ** | // | | // | ** | // | ** | // | ** ** | // | ** ** | // | *** | { 0x00, 0x60, 0x60, 0x66, 0x6C, 0x78, 0x6C, 0x66 }, // 107 : k // | | // | ** | // | ** | // | ** ** | // | ** ** | // | **** | // | ** ** | // | ** ** | { 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18 }, // 108 : l // | | // | ** | // | ** | // | ** | // | ** | // | ** | // | ** | // | ** | { 0x00, 0x00, 0x00, 0x63, 0x77, 0x7F, 0x6B, 0x6B }, // 109 : m // | | // | | // | | // | ** ** | // | *** *** | // | ******* | // | ** * ** | // | ** * ** | { 0x00, 0x00, 0x00, 0x7C, 0x7E, 0x66, 0x66, 0x66 }, // 110 : n // | | // | | // | | // | ***** | // | ****** | // | ** ** | // | ** ** | // | ** ** | { 0x00, 0x00, 0x00, 0x3C, 0x66, 0x66, 0x66, 0x3C }, // 111 : o // | | // | | // | | // | **** | // | ** ** | // | ** ** | // | ** ** | // | **** | { 0x00, 0x00, 0x7C, 0x66, 0x66, 0x7C, 0x60, 0x60 }, // 112 : p // | | // | | // | ***** | // | ** ** | // | ** ** | // | ***** | // | ** | // | ** | { 0x00, 0x00, 0x3C, 0x6C, 0x6C, 0x3C, 0x0D, 0x0F }, // 113 : q // | | // | | // | **** | // | ** ** | // | ** ** | // | **** | // | ** * | // | **** | { 0x00, 0x00, 0x00, 0x7C, 0x66, 0x66, 0x60, 0x60 }, // 114 : r // | | // | | // | | // | ***** | // | ** ** | // | ** ** | // | ** | // | ** | { 0x00, 0x00, 0x00, 0x3E, 0x40, 0x3C, 0x02, 0x7C }, // 115 : s // | | // | | // | | // | ***** | // | * | // | **** | // | * | // | ***** | { 0x00, 0x00, 0x18, 0x18, 0x7E, 0x18, 0x18, 0x18 }, // 116 : t // | | // | | // | ** | // | ** | // | ****** | // | ** | // | ** | // | ** | { 0x00, 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x3E }, // 117 : u // | | // | | // | | // | ** ** | // | ** ** | // | ** ** | // | ** ** | // | ***** | { 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x3C, 0x18 }, // 118 : v // | | // | | // | | // | | // | ** ** | // | ** ** | // | **** | // | ** | { 0x00, 0x00, 0x00, 0x63, 0x6B, 0x6B, 0x6B, 0x3E }, // 119 : w // | | // | | // | | // | ** ** | // | ** * ** | // | ** * ** | // | ** * ** | // | ***** | { 0x00, 0x00, 0x00, 0x66, 0x3C, 0x18, 0x3C, 0x66 }, // 120 : x // | | // | | // | | // | ** ** | // | **** | // | ** | // | **** | // | ** ** | { 0x00, 0x00, 0x00, 0x66, 0x66, 0x3E, 0x06, 0x3C }, // 121 : y // | | // | | // | | // | ** ** | // | ** ** | // | ***** | // | ** | // | **** | { 0x00, 0x00, 0x00, 0x3C, 0x0C, 0x18, 0x30, 0x3C }, // 122 : z // | | // | | // | | // | **** | // | ** | // | ** | // | ** | // | **** | { 0x00, 0x0E, 0x18, 0x18, 0x30, 0x18, 0x18, 0x0E }, // 123 : { // | | // | *** | // | ** | // | ** | // | ** | // | ** | // | ** | // | *** | { 0x00, 0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18 }, // 124 : | // | | // | ** | // | ** | // | ** | // | | // | ** | // | ** | // | ** | { 0x00, 0x70, 0x18, 0x18, 0x0C, 0x18, 0x18, 0x70 }, // 125 : } // | | // | *** | // | ** | // | ** | // | ** | // | ** | // | ** | // | *** | { 0x00, 0x00, 0x00, 0x3A, 0x6C, 0x00, 0x00, 0x00 }, // 126 : ~ // | | // | | // | | // | *** * | // | ** ** | // | | // | | // | | { 0x00, 0x08, 0x1C, 0x36, 0x63, 0x41, 0x41, 0x7F } // 127 :  // | | // | * | // | *** | // | ** ** | // | ** ** | // | * * | // | * * | // | ******* | }; void effect_text(char *string, int delayt) { int ltr, dist, rw; fill(0x00); for (ltr=0; string[ltr]; ltr++) { // For each letter in string array for (dist = 0; dist < 8; dist++) { // bring letter forward int rev = 0; fill(0x00); // blank cube for (rw = 7; rw >= 0; rw--) { // copy rows #if 0 // put this in for normal cube cube[rev][dist] = bitswap(font_data[string[ltr]][rw]); #else cube[rev][dist] = font_data[string[ltr]][rw]; // use above line for backward ass cubes #endif rev++; } delay_ms(delayt); } } } void effect_text_up(char *string, int delayt) { int ltr, dist, rw; fill(0x00); for (ltr=0; string[ltr]; ltr++) { // For each letter in string array for (dist = 0; dist < 8; dist++) { // bring letter forward int rev = 0; fill(0x00); // blank cube for (rw = 7; rw >= 0; rw--) { // copy rows #if 0 // put this in for miswired backwards cube cube[rev][dist] = bitswap(font_data[string[ltr]][rw]); #else cube[dist][rev] = font_data[string[ltr]][rw]; // use above line for proper cubes #endif rev++; } delay_ms(delayt); } } } void int_ripples(int iterations, int delay) { // 16 values for square root of a^2+b^2. index a*4+b = 10*sqrt // This gives the distance to 3.5,3.5 from the point unsigned char sqrt_LUT[]={ 49, 43, 38, 35, 43, 35, 29, 26, 38, 29, 21, 16, 35, 25, 16, 7 }; unsigned char x, y, height, distance; int i; for (i=0;i=0; cnt_2--) { shift(AXIS_Z, -1); for (cnt=0; cnt<=7; cnt++) { setvoxel(cnt, cnt_2, 0); } for (cnt=6; cnt>cnt_2; cnt--) { setvoxel(0, cnt, 0); setvoxel(7, cnt, 0); } delay_ms(300); } // Make All Wall Box for (cnt=0; cnt<=6; cnt++) { fill(0x00); box_walls(0, 0, 0, 7, 7, cnt); delay_ms(300); } time = 500; for (cnt_2=0; cnt_2<5; cnt_2++) { time -= 75; // Make Box Smaller for (cnt=0; cnt<=3; cnt++) { fill(0x00); box_walls(cnt, cnt, cnt, 7-cnt, 7-cnt, 7-cnt); delay_ms(time); } // Make Box Bigger for (cnt=0; cnt<=3; cnt++) { fill(0x00); box_walls(3-cnt, 3-cnt, 3-cnt, 4+cnt, 4+cnt, 4+cnt); delay_ms(time); } } for (cnt_2=0; cnt_2<5; cnt_2++) { time += 75; // Make Box Smaller for (cnt=0; cnt<=3; cnt++) { fill(0x00); box_walls(cnt, cnt, cnt, 7-cnt, 7-cnt, 7-cnt); delay_ms(time); } // Make Box Bigger for (cnt=0; cnt<=3; cnt++) { fill(0x00); box_walls(3-cnt, 3-cnt, 3-cnt, 4+cnt, 4+cnt, 4+cnt); delay_ms(time); } } delay_ms(500); } // ****************************************** // 3D addins ******************************** // ****************************************** #if 0 void linespin(int iterations, int delay) { float top_x, top_y, top_z, bot_x, bot_y, bot_z, sin_base; float center_x, center_y; center_x = 4; center_y = 4; int i, z; for (i=0;i=1;i--) { for (z=0;z<8;z++) { state = getvoxel(((path[(i-1)]>>4) & 0x0f), (path[(i-1)] & 0x0f), z); altervoxel(((path[i]>>4) & 0x0f), (path[i] & 0x0f), z, state); } } for (i=0;i<8;i++) clrvoxel(((path[0]>>4) & 0x0f), (path[0] & 0x0f), i); } void effect_rand_patharound(int iterations, int delay) { int z, dz, i; z = 4; unsigned char path[28]; font_getpath(0, path, 28); for (i = 0; i < iterations; i++) { dz = ((rand()%3)-1); z += dz; if (z>7) z = 7; if (z<0) z = 0; effect_pathmove(path, 28); setvoxel(0, 7, z); delay_ms(delay); } } void main() { int i, x, y, z, m, n; gpio_init(); gpio_ext(1); for (y=0; y<8; y++) { for (x=0; x<8; x++) { for (z=0; z<8; z++) { setvoxel(x, y, z); } delay_ms(20); for (z=0; z<8; z++) { clrvoxel(x, y, z); } } } for (z=0; z<8; z++) { for (y=0; y<8; y++) { for (x=0; x<8; x++) { setvoxel(x, y, z); delay_ms(5); } } } fill(0); for (;;) { printf("intro\n"); effect_intro(); printf("wormsqueeze\n"); effect_wormsqueeze(2, AXIS_Z, -1, 100, 500); printf("pyramid\n"); zoom_pyramid(); zoom_pyramid_clear(); printf("text\n"); effect_text("MIPS RETROBSD", 600); //sinelines(4000, 10); //linespin(1500, 10); printf("planboing\n"); effect_planboing(AXIS_Z, 450); effect_planboing(AXIS_Y, 450); effect_planboing(AXIS_X, 450); printf("blinky2\n"); effect_blinky2(); printf("mirror ripples\n"); mirror_ripples(600, 200); printf("axis_updown_randsuspend\n"); effect_axis_updown_randsuspend(AXIS_Z, 250, 2500, 0); effect_axis_updown_randsuspend(AXIS_Z, 250, 2500, 1); effect_axis_updown_randsuspend(AXIS_Z, 250, 2500, 0); effect_axis_updown_randsuspend(AXIS_Z, 250, 2500, 1); effect_axis_updown_randsuspend(AXIS_X, 250, 2500, 0); effect_axis_updown_randsuspend(AXIS_X, 250, 2500, 1); effect_axis_updown_randsuspend(AXIS_Y, 250, 2500, 0); effect_axis_updown_randsuspend(AXIS_Y, 250, 2500, 1); printf("rand_patharound\n"); effect_rand_patharound(200, 250); printf("fireworks\n"); fireworks(10, 250); //printf("random_filler\n"); //effect_random_filler(35, 1); //effect_random_filler(35, 0); printf("rain\n"); effect_rain(100); printf("side ripples\n"); side_ripples(300, 250); printf("text up\n"); effect_text_up("MIPS RETROBSD", 600); printf("random sparkle\n"); effect_random_sparkle(); printf("quad ripples\n"); quad_ripples(600, 150); printf("boxside_randsend_parallel\n"); effect_boxside_randsend_parallel(AXIS_X, 0, 70, 1); effect_boxside_randsend_parallel(AXIS_X, 1, 70, 1); effect_boxside_randsend_parallel(AXIS_Y, 0, 70, 1); effect_boxside_randsend_parallel(AXIS_Y, 1, 70, 1); effect_boxside_randsend_parallel(AXIS_Z, 0, 70, 1); effect_boxside_randsend_parallel(AXIS_Z, 1, 70, 1); } } ================================================ FILE: share/examples/cube/duinomite.c ================================================ /* * Interface to LED cube 8x8x8. * The cube is connected to pins D0-D9 of Duinomite board. * * Pin PIC32 Function * --------------- * D0 RE0 Y0 \ * D1 RE1 Y1 | Layer select * D2 RE2 Y2 / * D3 RE3 Y3 - Upper backlignt * D4 RE4 Y4 - Lower backlight * D5 RE5 SDI - Serial data \ * D6 RE6 CLK - Clock | to shift registers * D7 RE7 /LE - Latch enable | * D8 RB11 /OE - Output enable / * D10 RD11 EXT - Unknown */ #include #include #include #include #include "cube.h" static int gpio; void gpio_init() { char *devname = "/dev/porta"; /* Open GPIO driver. */ gpio = open(devname, 1); if (gpio < 0) { perror(devname); exit(-1); } /* Configure pins RE0-RE7, RB11 and RD11 as output. */ ioctl(gpio, GPIO_PORTE | GPIO_CONFOUT, 0xff); ioctl(gpio, GPIO_PORTE | GPIO_CLEAR, 0xff); ioctl(gpio, GPIO_PORTB | GPIO_CONFOUT, 1 << 11); ioctl(gpio, GPIO_PORTB | GPIO_CLEAR, 1 << 11); ioctl(gpio, GPIO_PORTD | GPIO_CONFOUT, 1 << 11); ioctl(gpio, GPIO_PORTD | GPIO_CLEAR, 1 << 11); } void gpio_ext(int on) { /* EXT signal at RD11. */ if (on) ioctl(gpio, GPIO_PORTD | GPIO_SET, 1 << 11); else ioctl(gpio, GPIO_PORTD | GPIO_CLEAR, 1 << 11); } void gpio_oe(int active) { /* /OE signal at RB11, active low. */ if (active) ioctl(gpio, GPIO_PORTB | GPIO_CLEAR, 1 << 11); else ioctl(gpio, GPIO_PORTB | GPIO_SET, 1 << 11); } void gpio_le(int active) { /* /LE signal at RE7, active low. */ if (active) ioctl(gpio, GPIO_PORTE | GPIO_CLEAR, 1 << 7); else ioctl(gpio, GPIO_PORTE | GPIO_SET, 1 << 7); } void gpio_backlight_upper(int on) { /* Y4 signal at RE4. */ if (on) ioctl(gpio, GPIO_PORTE | GPIO_SET, 1 << 4); else ioctl(gpio, GPIO_PORTE | GPIO_CLEAR, 1 << 4); } void gpio_backlight_lower(int on) { /* Y3 signal at RE3. */ if (on) ioctl(gpio, GPIO_PORTE | GPIO_SET, 1 << 3); else ioctl(gpio, GPIO_PORTE | GPIO_CLEAR, 1 << 3); } void gpio_layer(int z) { /* Y0-Y2 signals at RE0-RE23. */ if (z & 1) ioctl(gpio, GPIO_PORTE | GPIO_CLEAR, 1 << 0); else ioctl(gpio, GPIO_PORTE | GPIO_SET, 1 << 0); if (z & 2) ioctl(gpio, GPIO_PORTE | GPIO_CLEAR, 1 << 1); else ioctl(gpio, GPIO_PORTE | GPIO_SET, 1 << 1); if (z & 4) ioctl(gpio, GPIO_PORTE | GPIO_CLEAR, 1 << 2); else ioctl(gpio, GPIO_PORTE | GPIO_SET, 1 << 2); } void gpio_plane(unsigned char *data) { int i, n, val; /* Send 8 bytes of tada to shift registers. */ for (i=0; i<8; i+=2) { val = *data++; for (n=0; n<8; n++) { /* SDI signal at RE5. */ if (val & 0x80) ioctl(gpio, GPIO_PORTE | GPIO_SET, 1 << 5); else ioctl(gpio, GPIO_PORTE | GPIO_CLEAR, 1 << 5); /* CLK signal at RE6. */ ioctl(gpio, GPIO_PORTE | GPIO_SET, 1 << 6); ioctl(gpio, GPIO_PORTE | GPIO_CLEAR, 1 << 6); val <<= 1; } val = *data++; for (n=0; n<8; n++) { /* SDI signal at RE5. */ if (val & 1) ioctl(gpio, GPIO_PORTE | GPIO_SET, 1 << 5); else ioctl(gpio, GPIO_PORTE | GPIO_CLEAR, 1 << 5); /* CLK signal at RE6. */ ioctl(gpio, GPIO_PORTE | GPIO_SET, 1 << 6); ioctl(gpio, GPIO_PORTE | GPIO_CLEAR, 1 << 6); val >>= 1; } } } ================================================ FILE: share/examples/cube/fubarino.c ================================================ /* * Interface to LED cube 8x8x8. * The cube is connected to pins 4-13 of Fubarino board. * * Pin PIC32 Function * --------------- * 4 RD0 Y0 \ * 5 RC13 Y1 | Layer select * 6 RC14 Y2 / * 7 RD1 Y3 - Upper backlignt * 8 RD2 Y4 - Lower backlight * 9 RD3 SDI - Serial data \ * 10 RD4 CLK - Clock | to shift registers * 11 RD5 /LE - Latch enable | * 12 RD6 /OE - Output enable / * 13 RD7 EXT - Unknown */ #include #include #include #include #include "cube.h" static int gpio; void gpio_init() { char *devname = "/dev/porta"; /* Open GPIO driver. */ gpio = open(devname, 1); if (gpio < 0) { perror(devname); exit(-1); } /* Configure pins RD0-RD7, RC13 and RC14 as output. */ ioctl(gpio, GPIO_PORTD | GPIO_CONFOUT, 0xff); ioctl(gpio, GPIO_PORTD | GPIO_CLEAR, 0xff); ioctl(gpio, GPIO_PORTC | GPIO_CONFOUT, 3 << 13); ioctl(gpio, GPIO_PORTC | GPIO_CLEAR, 3 << 13); } void gpio_ext(int on) { /* EXT signal at RD7. */ if (on) ioctl(gpio, GPIO_PORTD | GPIO_SET, 1 << 7); else ioctl(gpio, GPIO_PORTD | GPIO_CLEAR, 1 << 7); } void gpio_oe(int active) { /* /OE signal at RD6, active low. */ if (active) ioctl(gpio, GPIO_PORTD | GPIO_CLEAR, 1 << 6); else ioctl(gpio, GPIO_PORTD | GPIO_SET, 1 << 6); } void gpio_le(int active) { /* /LE signal at RD5, active low. */ if (active) ioctl(gpio, GPIO_PORTD | GPIO_CLEAR, 1 << 5); else ioctl(gpio, GPIO_PORTD | GPIO_SET, 1 << 5); } void gpio_backlight_upper(int on) { /* Y4 signal at RD2. */ if (on) ioctl(gpio, GPIO_PORTD | GPIO_SET, 1 << 2); else ioctl(gpio, GPIO_PORTD | GPIO_CLEAR, 1 << 2); } void gpio_backlight_lower(int on) { /* Y3 signal at RD1. */ if (on) ioctl(gpio, GPIO_PORTD | GPIO_SET, 1 << 1); else ioctl(gpio, GPIO_PORTD | GPIO_CLEAR, 1 << 1); } void gpio_layer(int z) { /* Y0-Y2 signals at RD0, RC13, RC14. */ if (z & 1) ioctl(gpio, GPIO_PORTD | GPIO_CLEAR, 1 << 0); else ioctl(gpio, GPIO_PORTD | GPIO_SET, 1 << 0); if (z & 2) ioctl(gpio, GPIO_PORTC | GPIO_CLEAR, 1 << 13); else ioctl(gpio, GPIO_PORTC | GPIO_SET, 1 << 13); if (z & 4) ioctl(gpio, GPIO_PORTC | GPIO_CLEAR, 1 << 14); else ioctl(gpio, GPIO_PORTC | GPIO_SET, 1 << 14); } void gpio_plane(unsigned char *data) { int i, n, val; /* Send 8 bytes of tada to shift registers. */ for (i=0; i<8; i+=2) { val = *data++; for (n=0; n<8; n++) { /* SDI signal at RD3. */ if (val & 0x80) ioctl(gpio, GPIO_PORTD | GPIO_SET, 1 << 3); else ioctl(gpio, GPIO_PORTD | GPIO_CLEAR, 1 << 3); /* CLK signal at RD4. */ ioctl(gpio, GPIO_PORTD | GPIO_SET, 1 << 4); ioctl(gpio, GPIO_PORTD | GPIO_CLEAR, 1 << 4); val <<= 1; } val = *data++; for (n=0; n<8; n++) { /* SDI signal at RD3. */ if (val & 1) ioctl(gpio, GPIO_PORTD | GPIO_SET, 1 << 3); else ioctl(gpio, GPIO_PORTD | GPIO_CLEAR, 1 << 3); /* CLK signal at RD4. */ ioctl(gpio, GPIO_PORTD | GPIO_SET, 1 << 4); ioctl(gpio, GPIO_PORTD | GPIO_CLEAR, 1 << 4); val >>= 1; } } } ================================================ FILE: share/examples/curses/Makefile ================================================ PROG = flip jump timer typetext #CFLAGS = -DNCURSES_OPAQUE=0 LIBS = -lcurses -ltermlib all: $(PROG) clean: rm -f *.o *~ $(PROG) flip: flip.c cc $(CFLAGS) -o $@ $@.c $(LIBS) jump: jump.c cc $(CFLAGS) -o $@ $@.c $(LIBS) timer: timer.c cc $(CFLAGS) -o $@ $@.c $(LIBS) typetext: typetext.c cc $(CFLAGS) -o $@ $@.c $(LIBS) ================================================ FILE: share/examples/curses/flip.c ================================================ #include #include #include #include #include #define W_LINES 10 #define W_COLS 30 #define center(WIND,LN,TEXT) \ mvwaddstr((WIND), (LN), (W_COLS - strlen(TEXT))/2, (TEXT)) void die(int sig) { signal(sig, SIG_IGN); clear(); refresh(); endwin(); exit(0); } int main() { WINDOW *win1, *win2; if (! initscr()) { fprintf(stderr, "Sorry, unknown terminal.\n"); exit(1); } signal(SIGINT, die); signal(SIGQUIT, die); signal(SIGHUP, die); noecho(); win1 = newwin(W_LINES, W_COLS, ((LINES - W_LINES)/2), ((COLS - W_COLS)/2)); win2 = newwin(W_LINES, W_COLS, ((LINES - W_LINES)/2 + 4), ((COLS - W_COLS)/2 + 10)); scrollok(win1, FALSE); scrollok(win2, FALSE); box(win1, '*', '*'); box(win2, '*', '*'); center(win1, 3, "This is window 1"); center(win2, 3, "This is window 2"); for (;;) { wrefresh(win1); touchwin(win1); usleep(200000); wrefresh(win2); touchwin(win2); usleep(200000); } } ================================================ FILE: share/examples/curses/jump.c ================================================ #include #include #include #include #include #include #define W_LINES 7 #define W_COLS 11 void die(int sig) { signal(sig, SIG_IGN); werase(curscr); wmove(curscr, 0, 0); wrefresh(curscr); endwin(); exit(0); } int main() { WINDOW *win, *blank; int x, y; if (! initscr()) { fprintf(stderr, "Sorry, unknown terminal.\n"); exit(1); } signal(SIGINT, die); signal(SIGQUIT, die); signal(SIGHUP, die); noecho(); //delwin(stdscr); win = newwin(W_LINES, W_COLS, 0, 0); blank = newwin(W_LINES, W_COLS, 0, 0); box(win, '*', '*'); mvwaddstr(win, W_LINES/2, (W_COLS - strlen("RetroBSD"))/2, "RetroBSD"); srand(time(0)); for (;;) { x = rand() % (COLS - W_COLS); y = rand() % (LINES - W_LINES); wrefresh(blank); if (mvwin(win, y, x) == OK) { wrefresh(win); usleep(500000); mvwin(blank, y, x); } } } ================================================ FILE: share/examples/curses/timer.c ================================================ #include #include #include #include #include #include #include #define centered(y,str) mvaddstr(y, (COLS - strlen(str))/2, str) void die() { alarm(0); signal(SIGINT, SIG_IGN); signal(SIGQUIT, SIG_IGN); signal(SIGHUP, SIG_IGN); signal(SIGTERM, SIG_IGN); clear(); refresh(); endwin(); exit(0); } int main(int ac, char **av) { int move_col, msec; int time_line, move_line; long num_start_time, num_now_time; char str_start_time[60], str_now_time[60]; msec = 0; if (ac > 1) { msec = atoi(av[1]); if (msec < 10) msec = 10; else if (msec > 1000) msec = 1000; } if (! initscr()) exit(1); signal(SIGINT, die); signal(SIGQUIT, die); signal(SIGHUP, die); signal(SIGTERM, die); box(stdscr, '*', '*'); time(&num_start_time); strcpy(str_start_time, ctime(&num_start_time)); *(index(str_start_time, '\n')) = '\0'; centered(3, "*** Test started at: ***"); centered(4, str_start_time); move_col = 1; move_line = (LINES - 2) / 2; time_line = move_line + (LINES - move_line - 1) / 2; while (TRUE) { time(&num_now_time); strcpy(str_now_time, ctime(&num_now_time)); *(index(str_now_time, '\n')) = '\0'; centered(time_line, str_now_time); mvaddstr(move_line, move_col, "<-*->"); refresh(); mvaddstr(move_line, move_col, " "); if (++move_col >= (COLS - 6)) move_col = 1; if (msec) usleep(msec * 1000); } } ================================================ FILE: share/examples/curses/typetext.c ================================================ #include #include #include #include #define CNTRL(c) ((c) &037) void die(int sig) { signal(sig, SIG_IGN); move((LINES - 1), 0); refresh(); endwin(); exit(0); } int main() { WINDOW *win, *boxing; int c; int x, y; initscr(); signal(SIGINT, die); noecho(); crmode(); win = subwin(stdscr, LINES / 2, COLS / 2, LINES / 4, COLS / 4); scrollok(win, TRUE); boxing = subwin(stdscr, LINES / 2 + 2, COLS / 2 + 2, LINES / 4 - 1, COLS / 4 - 1); box(boxing, '!', '-'); refresh(); wmove(win, 0, 0); wrefresh(win); while ((c = wgetch(win)) != '#') { if (iscntrl(c)) { switch (c) { case CNTRL('E'): werase(win); wrefresh(win); continue; case CNTRL('R'): wrefresh(curscr); continue; case CNTRL('['): getyx(win, y, x); c = wgetch(win); if (c == '[' || c == 'O') c = wgetch(win); switch (c) { case 'H': x = 0; y = 0; goto change; case 'A': y--; goto change; case 'B': y++; goto change; case 'C': x++; goto change; case 'D': x--; change: if (x >= win->_maxx) { x = 0; y++; } if (y >= win->_maxy) y = 0; wmove(win, y, x); wrefresh(win); continue; default: break; } break; default: continue; } } waddch(win, c); wrefresh(win); } die(SIGINT); } ================================================ FILE: share/examples/dhrystone/Makefile ================================================ OBJS = dhry_1.o dhry_2.o all: dhrystone dhrystone: $(OBJS) $(CC) $(LDFLAGS) -o $@ $(OBJS) clean: rm -f *.o dhrystone ================================================ FILE: share/examples/dhrystone/RATIONALE ================================================ Dhrystone Benchmark: Rationale for Version 2 and Measurement Rules [published in SIGPLAN Notices 23,8 (Aug. 1988), 49-62] Reinhold P. Weicker Siemens AG, E STE 35 [now: Siemens AG, AUT E 51] Postfach 3220 D-8520 Erlangen Germany (West) 1. Why a Version 2 of Dhrystone? The Dhrystone benchmark program [1] has become a popular benchmark for CPU/compiler performance measurement, in particular in the area of minicomputers, workstations, PC's and microprocesors. It apparently satisfies a need for an easy-to-use integer benchmark; it gives a first performance indication which is more meaningful than MIPS numbers which, in their literal meaning (million instructions per second), cannot be used across different instruction sets (e.g. RISC vs. CISC). With the increasing use of the benchmark, it seems necessary to reconsider the benchmark and to check whether it can still fulfill this function. Version 2 of Dhrystone is the result of such a re-evaluation, it has been made for two reasons: o Dhrystone has been published in Ada [1], and Versions in Ada, Pascal and C have been distributed by Reinhold Weicker via floppy disk. However, the version that was used most often for benchmarking has been the version made by Rick Richardson by another translation from the Ada version into the C programming language, this has been the version distributed via the UNIX network Usenet [2]. There is an obvious need for a common C version of Dhrystone, since C is at present the most popular system programming language for the class of systems (microcomputers, minicomputers, workstations) where Dhrystone is used most. There should be, as far as possible, only one C version of Dhrystone such that results can be compared without restrictions. In the past, the C versions distributed by Rick Richardson (Version 1.1) and by Reinhold Weicker had small (though not significant) differences. Together with the new C version, the Ada and Pascal versions have been updated as well. o As far as it is possible without changes to the Dhrystone statistics, optimizing compilers should be prevented from removing significant statements. It has turned out in the past that optimizing compilers suppressed code generation for too many statements (by "dead code removal" or "dead variable elimination"). This has lead to the danger that benchmarking results obtained by a naive application of Dhrystone - without inspection of the code that was generated - could become meaningless. The overall policiy for version 2 has been that the distribution of statements, operand types and operand locality described in [1] should remain unchanged as much as possible. (Very few changes were necessary; their impact should be negligible.) Also, the order of statements should remain unchanged. Although I am aware of some critical remarks on the benchmark - I agree with several of them - and know some suggestions for improvement, I didn't want to change the benchmark into something different from what has become known as "Dhrystone"; the confusion generated by such a change would probably outweight the benefits. If I were to write a new benchmark program, I wouldn't give it the name "Dhrystone" since this denotes the program published in [1]. However, I do recognize the need for a larger number of representative programs that can be used as benchmarks; users should always be encouraged to use more than just one benchmark. The new versions (version 2.1 for C, Pascal and Ada) will be distributed as widely as possible. (Version 2.1 differs from version 2.0 distributed via the UNIX Network Usenet in March 1988 only in a few corrections for minor deficiencies found by users of version 2.0.) Readers who want to use the benchmark for their own measurements can obtain a copy in machine-readable form on floppy disk (MS-DOS or XENIX format) from the author. 2. Overall Characteristics of Version 2 In general, version 2 follows - in the parts that are significant for performance measurement, i.e. within the measurement loop - the published (Ada) version and the C versions previously distributed. Where the versions distributed by Rick Richardson [2] and Reinhold Weicker have been different, it follows the version distributed by Reinhold Weicker. (However, the differences have been so small that their impact on execution time in all likelihood has been negligible.) The initialization and UNIX instrumentation part - which had been omitted in [1] - follows mostly the ideas of Rick Richardson [2]. However, any changes in the initialization part and in the printing of the result have no impact on performance measurement since they are outside the measaurement loop. As a concession to older compilers, names have been made unique within the first 8 characters for the C version. The original publication of Dhrystone did not contain any statements for time measurement since they are necessarily system-dependent. However, it turned out that it is not enough just to inclose the main procedure of Dhrystone in a loop and to measure the execution time. If the variables that are computed are not used somehow, there is the danger that the compiler considers them as "dead variables" and suppresses code generation for a part of the statements. Therefore in version 2 all variables of "main" are printed at the end of the program. This also permits some plausibility control for correct execution of the benchmark. At several places in the benchmark, code has been added, but only in branches that are not executed. The intention is that optimizing compilers should be prevented from moving code out of the measurement loop, or from removing code altogether. Statements that are executed have been changed in very few places only. In these cases, only the role of some operands has been changed, and it was made sure that the numbers defining the "Dhrystone distribution" (distribution of statements, operand types and locality) still hold as much as possible. Except for sophisticated optimizing compilers, execution times for version 2.1 should be the same as for previous versions. Because of the self-imposed limitation that the order and distribution of the executed statements should not be changed, there are still cases where optimizing compilers may not generate code for some statements. To a certain degree, this is unavoidable for small synthetic benchmarks. Users of the benchmark are advised to check code listings whether code is generated for all statements of Dhrystone. Contrary to the suggestion in the published paper and its realization in the versions previously distributed, no attempt has been made to subtract the time for the measurement loop overhead. (This calculation has proven difficult to implement in a correct way, and its omission makes the program simpler.) However, since the loop check is now part of the benchmark, this does have an impact - though a very minor one - on the distribution statistics which have been updated for this version. 3. Discussion of Individual Changes In this section, all changes are described that affect the measurement loop and that are not just renamings of variables. All remarks refer to the C version; the other language versions have been updated similarly. In addition to adding the measurement loop and the printout statements, changes have been made at the following places: o In procedure "main", three statements have been added in the non-executed "then" part of the statement if (Enum_Loc == Func_1 (Ch_Index, 'C')) they are strcpy (Str_2_Loc, "DHRYSTONE PROGRAM, 3'RD STRING"); Int_2_Loc = Run_Index; Int_Glob = Run_Index; The string assignment prevents movement of the preceding assignment to Str_2_Loc (5'th statement of "main") out of the measurement loop (This probably will not happen for the C version, but it did happen with another language and compiler.) The assignment to Int_2_Loc prevents value propagation for Int_2_Loc, and the assignment to Int_Glob makes the value of Int_Glob possibly dependent from the value of Run_Index. o In the three arithmetic computations at the end of the measurement loop in "main ", the role of some variables has been exchanged, to prevent the division from just cancelling out the multiplication as it was in [1]. A very smart compiler might have recognized this and suppressed code generation for the division. o For Proc_2, no code has been changed, but the values of the actual parameter have changed due to changes in "main". o In Proc_4, the second assignment has been changed from Bool_Loc = Bool_Loc | Bool_Glob; to Bool_Glob = Bool_Loc | Bool_Glob; It now assigns a value to a global variable instead of a local variable (Bool_Loc); Bool_Loc would be a "dead variable" which is not used afterwards. o In Func_1, the statement Ch_1_Glob = Ch_1_Loc; was added in the non-executed "else" part of the "if" statement, to prevent the suppression of code generation for the assignment to Ch_1_Loc. o In Func_2, the second character comparison statement has been changed to if (Ch_Loc == 'R') ('R' instead of 'X') because a comparison with 'X' is implied in the preceding "if" statement. Also in Func_2, the statement Int_Glob = Int_Loc; has been added in the non-executed part of the last "if" statement, in order to prevent Int_Loc from becoming a dead variable. o In Func_3, a non-executed "else" part has been added to the "if" statement. While the program would not be incorrect without this "else" part, it is considered bad programming practice if a function can be left without a return value. To compensate for this change, the (non-executed) "else" part in the "if" statement of Proc_3 was removed. The distribution statistics have been changed only by the addition of the measurement loop iteration (1 additional statement, 4 additional local integer operands) and by the change in Proc_4 (one operand changed from local to global). The distribution statistics in the comment headers have been updated accordingly. 4. String Operations The string operations (string assignment and string comparison) have not been changed, to keep the program consistent with the original version. There has been some concern that the string operations are over-represented in the program, and that execution time is dominated by these operations. This was true in particular when optimizing compilers removed too much code in the main part of the program, this should have been mitigated in version 2. It should be noted that this is a language-dependent issue: Dhrystone was first published in Ada, and with Ada or Pascal semantics, the time spent in the string operations is, at least in all implementations known to me, considerably smaller. In Ada and Pascal, assignment and comparison of strings are operators defined in the language, and the upper bounds of the strings occuring in Dhrystone are part of the type information known at compilation time. The compilers can therefore generate efficient inline code. In C, string assignemt and comparisons are not part of the language, so the string operations must be expressed in terms of the C library functions "strcpy" and "strcmp". (ANSI C allows an implementation to use inline code for these functions.) In addition to the overhead caused by additional function calls, these functions are defined for null-terminated strings where the length of the strings is not known at compilation time; the function has to check every byte for the termination condition (the null byte). Obviously, a C library which includes efficiently coded "strcpy" and "strcmp" functions helps to obtain good Dhrystone results. However, I don't think that this is unfair since string functions do occur quite frequently in real programs (editors, command interpreters, etc.). If the strings functions are implemented efficiently, this helps real programs as well as benchmark programs. I admit that the string comparison in Dhrystone terminates later (after scanning 20 characters) than most string comparisons in real programs. For consistency with the original benchmark, I didn't change the program despite this weakness. 5. Intended Use of Dhrystone When Dhrystone is used, the following "ground rules" apply: o Separate compilation (Ada and C versions) As mentioned in [1], Dhrystone was written to reflect actual programming practice in systems programming. The division into several compilation units (5 in the Ada version, 2 in the C version) is intended, as is the distribution of inter-module and intra-module subprogram calls. Although on many systems there will be no difference in execution time to a Dhrystone version where all compilation units are merged into one file, the rule is that separate compilation should be used. The intention is that real programming practice, where programs consist of several independently compiled units, should be reflected. This also has implies that the compiler, while compiling one unit, has no information about the use of variables, register allocation etc. occuring in other compilation units. Although in real life compilation units will probably be larger, the intention is that these effects of separate compilation are modeled in Dhrystone. A few language systems have post-linkage optimization available (e.g., final register allocation is performed after linkage). This is a borderline case: Post-linkage optimization involves additional program preparation time (although not as much as compilation in one unit) which may prevent its general use in practical programming. I think that since it defeats the intentions given above, it should not be used for Dhrystone. Unfortunately, ISO/ANSI Pascal does not contain language features for separate compilation. Although most commercial Pascal compilers provide separate compilation in some way, we cannot use it for Dhrystone since such a version would not be portable. Therefore, no attempt has been made to provide a Pascal version with several compilation units. o No procedure merging Although Dhrystone contains some very short procedures where execution would benefit from procedure merging (inlining, macro expansion of procedures), procedure merging is not to be used. The reason is that the percentage of procedure and function calls is part of the "Dhrystone distribution" of statements contained in [1]. This restriction does not hold for the string functions of the C version since ANSI C allows an implementation to use inline code for these functions. o Other optimizations are allowed, but they should be indicated It is often hard to draw an exact line between "normal code generation" and "optimization" in compilers: Some compilers perform operations by default that are invoked in other compilers only when optimization is explicitly requested. Also, we cannot avoid that in benchmarking people try to achieve results that look as good as possible. Therefore, optimizations performed by compilers - other than those listed above - are not forbidden when Dhrystone execution times are measured. Dhrystone is not intended to be non-optimizable but is intended to be similarly optimizable as normal programs. For example, there are several places in Dhrystone where performance benefits from optimizations like common subexpression elimination, value propagation etc., but normal programs usually also benefit from these optimizations. Therefore, no effort was made to artificially prevent such optimizations. However, measurement reports should indicate which compiler optimization levels have been used, and reporting results with different levels of compiler optimization for the same hardware is encouraged. o Default results are those without "register" declarations (C version) When Dhrystone results are quoted without additional qualification, they should be understood as results obtained without use of the "register" attribute. Good compilers should be able to make good use of registers even without explicit register declarations ([3], p. 193). Of course, for experimental purposes, post-linkage optimization, procedure merging and/or compilation in one unit can be done to determine their effects. However, Dhrystone numbers obtained under these conditions should be explicitly marked as such; "normal" Dhrystone results should be understood as results obtained following the ground rules listed above. In any case, for serious performance evaluation, users are advised to ask for code listings and to check them carefully. In this way, when results for different systems are compared, the reader can get a feeling how much performance difference is due to compiler optimization and how much is due to hardware speed. 6. Acknowledgements The C version 2.1 of Dhrystone has been developed in cooperation with Rick Richardson (Tinton Falls, NJ), it incorporates many ideas from the "Version 1.1" distributed previously by him over the UNIX network Usenet. Through his activity with Usenet, Rick Richardson has made a very valuable contribution to the dissemination of the benchmark. I also thank Chaim Benedelac (National Semiconductor), David Ditzel (SUN), Earl Killian and John Mashey (MIPS), Alan Smith and Rafael Saavedra-Barrera (UC at Berkeley) for their help with comments on earlier versions of the benchmark. 7. Bibliography [1] Reinhold P. Weicker: Dhrystone: A Synthetic Systems Programming Benchmark. Communications of the ACM 27, 10 (Oct. 1984), 1013-1030 [2] Rick Richardson: Dhrystone 1.1 Benchmark Summary (and Program Text) Informal Distribution via "Usenet", Last Version Known to me: Sept. 21, 1987 [3] Brian W. Kernighan and Dennis M. Ritchie: The C Programming Language. Prentice-Hall, Englewood Cliffs (NJ) 1978 ================================================ FILE: share/examples/dhrystone/README ================================================ Downloaded from: http://www.netlib.org/benchmark/dhry-c Calls time() and times() replaced by gettimeofday(). ================================================ FILE: share/examples/dhrystone/README_C ================================================ This "shar" file contains the documentation for the electronic mail distribution of the Dhrystone benchmark (C version 2.1); a companion "shar" file contains the source code. (Because of mail length restrictions for some mailers, I have split the distribution in two parts.) For versions in other languages, see the other "shar" files. Files containing the C version (*.h: Header File, *.c: C Modules) dhry.h dhry_1.c dhry_2.c The file RATIONALE contains the article "Dhrystone Benchmark: Rationale for Version 2 and Measurement Rules" which has been published, together with the C source code (Version 2.0), in SIGPLAN Notices vol. 23, no. 8 (Aug. 1988), pp. 49-62. This article explains all changes that have been made for Version 2, compared with the version of the original publication in Communications of the ACM vol. 27, no. 10 (Oct. 1984), pp. 1013-1030. It also contains "ground rules" for benchmarking with Dhrystone which should be followed by everyone who uses the program and publishes Dhrystone results. Compared with the Version 2.0 published in SIGPLAN Notices, Version 2.1 contains a few corrections that have been made after Version 2.0 was distriobuted over the UNIX network Usenet. These small differences between Version 2.0 and 2.1 should not affect execution time measurements. For those who want to compare the exact contents of both versions, the file "dhry_c.dif" contains the differences between the two versions, as generated by a file comparison of the corresponding files with the UNIX utility "diff". The file VARIATIONS contains the article "Understanding Variations in Dhrystone Performance" which has been published in Microprocessor Report, May 1989 (Editor: M. Slater), pp. 16-17. It describes the points that users should know if C Dhrystone results are compared. Recipients of this shar file who perform measurements are asked to send measurement results to the author and/or to Rick Richardson. Rick Richardson publishes regularly Dhrystone results on the UNIX network Usenet. For submissions of results to him (preferably by electronic mail, see address in the program header), he has provided a form which is contained in the file "submit.frm". The following files are contained in other "shar" files: Files containing the Ada version (*.s: Specifications, *.b: Bodies): d_global.s d_main.b d_pack_1.b d_pack_1.s d_pack_2.b d_pack_2.s File containing the Pascal version: dhry.p February 22, 1990 Reinhold P. Weicker Siemens AG, AUT E 51 Postfach 3220 D-8520 Erlangen Germany (West) Phone: [xxx-49]-9131-7-20330 (8-17 Central European Time) UUCP: ..!mcsun!unido!estevax!weicker ================================================ FILE: share/examples/dhrystone/VARIATIONS ================================================ Understanding Variations in Dhrystone Performance By Reinhold P. Weicker, Siemens AG, AUT E 51, Erlangen April 1989 This article has appeared in: Microprocessor Report, May 1989 (Editor: M. Slater), pp. 16-17 Microprocessor manufacturers tend to credit all the performance measured by benchmarks to the speed of their processors, they often don't even mention the programming language and compiler used. In their detailed documents, usually called "performance brief" or "performance report," they usually do give more details. However, these details are often lost in the press releases and other marketing statements. For serious performance evaluation, it is necessary to study the code generated by the various compilers. Dhrystone was originally published in Ada (Communications of the ACM, Oct. 1984). However, since good Ada compilers were rare at this time and, together with UNIX, C became more and more popular, the C version of Dhrystone is the one now mainly used in industry. There are "official" versions 2.1 for Ada, Pascal, and C, which are as close together as the languages' semantic differences permit. Dhrystone contains two statements where the programming language and its translation play a major part in the execution time measured by the benchmark: o String assignment (in procedure Proc_0 / main) o String comparison (in function Func_2) In Ada and Pascal, strings are arrays of characters where the length of the string is part of the type information known at compile time. In C, strings are also arrays of characters, but there are no operators defined in the language for assignment and comparison of strings. Instead, functions "strcpy" and "strcmp" are used. These functions are defined for strings of arbitrary length, and make use of the fact that strings in C have to end with a terminating null byte. For general-purpose calls to these functions, the implementor can assume nothing about the length and the alignment of the strings involved. The C version of Dhrystone spends a relatively large amount of time in these two functions. Some time ago, I made measurements on a VAX 11/785 with the Berkeley UNIX (4.2) compilers (often-used compilers, but certainly not the most advanced). In the C version, 23% of the time was spent in the string functions; in the Pascal version, only 10%. On good RISC machines (where less time is spent in the procedure calling sequence than on a VAX) and with better optimizing compilers, the percentage is higher; MIPS has reported 34% for an R3000. Because of this effect, Pascal and Ada Dhrystone results are usually better than C results (except when the optimization quality of the C compiler is considerably better than that of the other compilers). Several people have noted that the string operations are over-represented in Dhrystone, mainly because the strings occurring in Dhrystone are longer than average strings. I admit that this is true, and have said so in my SIGPLAN Notices paper (Aug. 1988); however, I didn't want to generate confusion by changing the string lengths from version 1 to version 2. Even if they are somewhat over-represented in Dhrystone, string operations are frequent enough that it makes sense to implement them in the most efficient way possible, not only for benchmarking purposes. This means that they can and should be written in assembly language code. ANSI C also explicitly allows the strings functions to be implemented as macros, i.e. by inline code. There is also a third way to speed up the "strcpy" statement in Dhrystone: For this particular "strcpy" statement, the source of the assignment is a string constant. Therefore, in contrast to calls to "strcpy" in the general case, the compiler knows the length and alignment of the strings involved at compile time and can generate code in the same efficient way as a Pascal compiler (word instructions instead of byte instructions). This is not allowed in the case of the "strcmp" call: Here, the addresses are formal procedure parameters, and no assumptions can be made about the length or alignment of the strings. Any such assumptions would indicate an incorrect implementation. They might work for Dhrystone, where the strings are in fact word-aligned with typical compilers, but other programs would deliver incorrect results. So, for an apple-to-apple comparison between processors, and not between several possible (legal or illegal) degrees of compiler optimization, one should check that the systems are comparable with respect to the following three points: (1) String functions in assembly language vs. in C Frequently used functions such as the string functions can and should be written in assembly language, and all serious C language systems known to me do this. (I list this point for completeness only.) Note that processors with an instruction that checks a word for a null byte (such as AMD's 29000 and Intel's 80960) have an advantage here. (This advantage decreases relatively if optimization (3) is applied.) Due to the length of the strings involved in Dhrystone, this advantage may be considered too high in perspective, but it is certainly legal to use such instructions - after all, these situations are what they were invented for. (2) String function code inline vs. as library functions. ANSI C has created a new situation, compared with the older Kernighan/Ritchie C. In the original C, the definition of the string function was not part of the language. Now it is, and inlining is explicitly allowed. I probably should have stated more clearly in my SIGPLAN Notices paper that the rule "No procedure inlining for Dhrystone" referred to the user level procedures only and not to the library routines. (3) Fixed-length and alignment assumptions for the strings Compilers should be allowed to optimize in these cases if (and only if) it is safe to do so. For Dhrystone, this is the "strcpy" statement, but not the "strcmp" statement (unless, of course, the "strcmp" code explicitly checks the alignment at execution time and branches accordingly). A "Dhrystone switch" for the compiler that causes the generation of code that may not work under certain circumstances is certainly inappropriate for comparisons. It has been reported in Usenet that some C compilers provide such a compiler option; since I don't have access to all C compilers involved, I cannot verify this. If the fixed-length and word-alignment assumption can be used, a wide bus that permits fast multi-word load instructions certainly does help; however, this fact by itself should not make a really big difference. A check of these points - something that is necessary for a thorough evaluation and comparison of the Dhrystone performance claims - requires object code listings as well as listings for the string functions (strcpy, strcmp) that are possibly called by the program. I don't pretend that Dhrystone is a perfect tool to measure the integer performance of microprocessors. The more it is used and discussed, the more I myself learn about aspects that I hadn't noticed yet when I wrote the program. And of course, the very success of a benchmark program is a danger in that people may tune their compilers and/or hardware to it, and with this action make it less useful. Whetstone and Linpack have their critical points also: The Whetstone rating depends heavily on the speed of the mathematical functions (sine, sqrt, ...), and Linpack is sensitive to data alignment for some cache configurations. Introduction of a standard set of public domain benchmark software (something the SPEC effort attempts) is certainly a worthwhile thing. In the meantime, people will continue to use whatever is available and widely distributed, and Dhrystone ratings are probably still better than MIPS ratings if these are - as often in industry - based on no reproducible derivation. However, any serious performance evaluation requires more than just a comparison of raw numbers; one has to make sure that the numbers have been obtained in a comparable way. ================================================ FILE: share/examples/dhrystone/dhry.h ================================================ /* **************************************************************************** * * "DHRYSTONE" Benchmark Program * ----------------------------- * * Version: C, Version 2.1 * * File: dhry.h (part 1 of 3) * * Date: May 25, 1988 * * Author: Reinhold P. Weicker * Siemens AG, AUT E 51 * Postfach 3220 * 8520 Erlangen * Germany (West) * Phone: [+49]-9131-7-20330 * (8-17 Central European Time) * Usenet: ..!mcsun!unido!estevax!weicker * * Original Version (in Ada) published in * "Communications of the ACM" vol. 27., no. 10 (Oct. 1984), * pp. 1013 - 1030, together with the statistics * on which the distribution of statements etc. is based. * * In this C version, the following C library functions are used: * - strcpy, strcmp (inside the measurement loop) * - printf, scanf (outside the measurement loop) * In addition, Berkeley UNIX system calls "times ()" or "time ()" * are used for execution time measurement. For measurements * on other systems, these calls have to be changed. * * Collection of Results: * Reinhold Weicker (address see above) and * * Rick Richardson * PC Research. Inc. * 94 Apple Orchard Drive * Tinton Falls, NJ 07724 * Phone: (201) 389-8963 (9-17 EST) * Usenet: ...!uunet!pcrat!rick * * Please send results to Rick Richardson and/or Reinhold Weicker. * Complete information should be given on hardware and software used. * Hardware information includes: Machine type, CPU, type and size * of caches; for microprocessors: clock frequency, memory speed * (number of wait states). * Software information includes: Compiler (and runtime library) * manufacturer and version, compilation switches, OS version. * The Operating System version may give an indication about the * compiler; Dhrystone itself performs no OS calls in the measurement loop. * * The complete output generated by the program should be mailed * such that at least some checks for correctness can be made. * *************************************************************************** * * History: This version C/2.1 has been made for two reasons: * * 1) There is an obvious need for a common C version of * Dhrystone, since C is at present the most popular system * programming language for the class of processors * (microcomputers, minicomputers) where Dhrystone is used most. * There should be, as far as possible, only one C version of * Dhrystone such that results can be compared without * restrictions. In the past, the C versions distributed * by Rick Richardson (Version 1.1) and by Reinhold Weicker * had small (though not significant) differences. * * 2) As far as it is possible without changes to the Dhrystone * statistics, optimizing compilers should be prevented from * removing significant statements. * * This C version has been developed in cooperation with * Rick Richardson (Tinton Falls, NJ), it incorporates many * ideas from the "Version 1.1" distributed previously by * him over the UNIX network Usenet. * I also thank Chaim Benedelac (National Semiconductor), * David Ditzel (SUN), Earl Killian and John Mashey (MIPS), * Alan Smith and Rafael Saavedra-Barrera (UC at Berkeley) * for their help with comments on earlier versions of the * benchmark. * * Changes: In the initialization part, this version follows mostly * Rick Richardson's version distributed via Usenet, not the * version distributed earlier via floppy disk by Reinhold Weicker. * As a concession to older compilers, names have been made * unique within the first 8 characters. * Inside the measurement loop, this version follows the * version previously distributed by Reinhold Weicker. * * At several places in the benchmark, code has been added, * but within the measurement loop only in branches that * are not executed. The intention is that optimizing compilers * should be prevented from moving code out of the measurement * loop, or from removing code altogether. Since the statements * that are executed within the measurement loop have NOT been * changed, the numbers defining the "Dhrystone distribution" * (distribution of statements, operand types and locality) * still hold. Except for sophisticated optimizing compilers, * execution times for this version should be the same as * for previous versions. * * Since it has proven difficult to subtract the time for the * measurement loop overhead in a correct way, the loop check * has been made a part of the benchmark. This does have * an impact - though a very minor one - on the distribution * statistics which have been updated for this version. * * All changes within the measurement loop are described * and discussed in the companion paper "Rationale for * Dhrystone version 2". * * Because of the self-imposed limitation that the order and * distribution of the executed statements should not be * changed, there are still cases where optimizing compilers * may not generate code for some statements. To a certain * degree, this is unavoidable for small synthetic benchmarks. * Users of the benchmark are advised to check code listings * whether code is generated for all statements of Dhrystone. * * Version 2.1 is identical to version 2.0 distributed via * the UNIX network Usenet in March 1988 except that it corrects * some minor deficiencies that were found by users of version 2.0. * The only change within the measurement loop is that a * non-executed "else" part was added to the "if" statement in * Func_3, and a non-executed "else" part removed from Proc_3. * *************************************************************************** * * Compilation model and measurement (IMPORTANT): * * This C version of Dhrystone consists of three files: * - dhry.h (this file, containing global definitions and comments) * - dhry_1.c (containing the code corresponding to Ada package Pack_1) * - dhry_2.c (containing the code corresponding to Ada package Pack_2) * * The following "ground rules" apply for measurements: * - Separate compilation * - No procedure merging * - Otherwise, compiler optimizations are allowed but should be indicated * - Default results are those without register declarations * See the companion paper "Rationale for Dhrystone Version 2" for a more * detailed discussion of these ground rules. * * For 16-Bit processors (e.g. 80186, 80286), times for all compilation * models ("small", "medium", "large" etc.) should be given if possible, * together with a definition of these models for the compiler system used. * ************************************************************************** * * Dhrystone (C version) statistics: * * [Comment from the first distribution, updated for version 2. * Note that because of language differences, the numbers are slightly * different from the Ada version.] * * The following program contains statements of a high level programming * language (here: C) in a distribution considered representative: * * assignments 52 (51.0 %) * control statements 33 (32.4 %) * procedure, function calls 17 (16.7 %) * * 103 statements are dynamically executed. The program is balanced with * respect to the three aspects: * * - statement type * - operand type * - operand locality * operand global, local, parameter, or constant. * * The combination of these three aspects is balanced only approximately. * * 1. Statement Type: * ----------------- number * * V1 = V2 9 * (incl. V1 = F(..) * V = Constant 12 * Assignment, 7 * with array element * Assignment, 6 * with record component * -- * 34 34 * * X = Y +|-|"&&"|"|" Z 5 * X = Y +|-|"==" Constant 6 * X = X +|- 1 3 * X = Y *|/ Z 2 * X = Expression, 1 * two operators * X = Expression, 1 * three operators * -- * 18 18 * * if .... 14 * with "else" 7 * without "else" 7 * executed 3 * not executed 4 * for ... 7 | counted every time * while ... 4 | the loop condition * do ... while 1 | is evaluated * switch ... 1 * break 1 * declaration with 1 * initialization * -- * 34 34 * * P (...) procedure call 11 * user procedure 10 * library procedure 1 * X = F (...) * function call 6 * user function 5 * library function 1 * -- * 17 17 * --- * 103 * * The average number of parameters in procedure or function calls * is 1.82 (not counting the function values as implicit parameters). * * * 2. Operators * ------------ * number approximate * percentage * * Arithmetic 32 50.8 * * + 21 33.3 * - 7 11.1 * * 3 4.8 * / (int div) 1 1.6 * * Comparison 27 42.8 * * == 9 14.3 * /= 4 6.3 * > 1 1.6 * < 3 4.8 * >= 1 1.6 * <= 9 14.3 * * Logic 4 6.3 * * && (AND-THEN) 1 1.6 * | (OR) 1 1.6 * ! (NOT) 2 3.2 * * -- ----- * 63 100.1 * * * 3. Operand Type (counted once per operand reference): * --------------- * number approximate * percentage * * Integer 175 72.3 % * Character 45 18.6 % * Pointer 12 5.0 % * String30 6 2.5 % * Array 2 0.8 % * Record 2 0.8 % * --- ------- * 242 100.0 % * * When there is an access path leading to the final operand (e.g. a record * component), only the final data type on the access path is counted. * * * 4. Operand Locality: * ------------------- * number approximate * percentage * * local variable 114 47.1 % * global variable 22 9.1 % * parameter 45 18.6 % * value 23 9.5 % * reference 22 9.1 % * function result 6 2.5 % * constant 55 22.7 % * --- ------- * 242 100.0 % * * * The program does not compute anything meaningful, but it is syntactically * and semantically correct. All variables have a value assigned to them * before they are used as a source operand. * * There has been no explicit effort to account for the effects of a * cache, or to balance the use of long or short displacements for code or * data. * *************************************************************************** */ /* Compiler and system dependent definitions: */ typedef enum { Ident_1, Ident_2, Ident_3, Ident_4, Ident_5 } Enumeration; /* General definitions: */ #define true 1 #define false 0 typedef int One_Thirty; typedef int One_Fifty; typedef char Capital_Letter; typedef int Boolean; typedef char Str_30 [31]; typedef int Arr_1_Dim [50]; typedef int Arr_2_Dim [50] [50]; typedef struct record { struct record *Ptr_Comp; Enumeration Discr; union { struct { Enumeration Enum_Comp; int Int_Comp; char Str_Comp [31]; } var_1; struct { Enumeration E_Comp_2; char Str_2_Comp [31]; } var_2; struct { char Ch_1_Comp; char Ch_2_Comp; } var_3; } variant; } Rec_Type, *Rec_Pointer; /* Forward declaration necessary since Enumeration may not simply be int */ void Proc_1 (Rec_Pointer); void Proc_2 (One_Fifty *); void Proc_3 (Rec_Pointer *); void Proc_4 (void); void Proc_5 (void); void Proc_6 (Enumeration, Enumeration *); void Proc_7 (One_Fifty, One_Fifty, One_Fifty *); void Proc_8 (Arr_1_Dim, Arr_2_Dim, int, int); Enumeration Func_1 (Capital_Letter, Capital_Letter); Boolean Func_2 (Str_30, Str_30); Boolean Func_3 (Enumeration); ================================================ FILE: share/examples/dhrystone/dhry_1.c ================================================ /* **************************************************************************** * * "DHRYSTONE" Benchmark Program * ----------------------------- * * Version: C, Version 2.1 * * File: dhry_1.c (part 2 of 3) * * Date: May 25, 1988 * * Author: Reinhold P. Weicker * **************************************************************************** */ #include #include #include #include #include "dhry.h" /* Speed of Vak-11/780, 1 DMIPS by definition */ #define DHRYSTONES_PER_DMIPS 1757 /* Global Variables: */ Rec_Pointer Ptr_Glob, Next_Ptr_Glob; int Int_Glob; Boolean Bool_Glob; char Ch_1_Glob, Ch_2_Glob; int Arr_1_Glob [50]; int Arr_2_Glob [50] [50]; /* variables for time measurement: */ struct timeval time_info; long Begin_Time, End_Time, Microseconds, Dhrystones_per_Millisecond, Dmips; /* end of variables for time measurement */ int main () /*****/ /* main program, corresponds to procedures */ /* Main and Proc_0 in the Ada version */ { One_Fifty Int_1_Loc; One_Fifty Int_2_Loc; One_Fifty Int_3_Loc; char Ch_Index; Enumeration Enum_Loc; Str_30 Str_1_Loc; Str_30 Str_2_Loc; int Run_Index; int Number_Of_Runs = 1000000; /* Initializations */ Next_Ptr_Glob = (Rec_Pointer) malloc (sizeof (Rec_Type)); Ptr_Glob = (Rec_Pointer) malloc (sizeof (Rec_Type)); Ptr_Glob->Ptr_Comp = Next_Ptr_Glob; Ptr_Glob->Discr = Ident_1; Ptr_Glob->variant.var_1.Enum_Comp = Ident_3; Ptr_Glob->variant.var_1.Int_Comp = 40; strcpy (Ptr_Glob->variant.var_1.Str_Comp, "DHRYSTONE PROGRAM, SOME STRING"); strcpy (Str_1_Loc, "DHRYSTONE PROGRAM, 1'ST STRING"); Arr_2_Glob [8][7] = 10; /* Was missing in published program. Without this statement, */ /* Arr_2_Glob [8][7] would have an undefined value. */ /* Warning: With 16-Bit processors and Number_Of_Runs > 32000, */ /* overflow may occur for this array element. */ printf ("\n"); printf ("Dhrystone Benchmark, Version 2.1 (Language: C)\n"); printf ("\n"); again: printf ("Execution starts, %d runs through Dhrystone\n", Number_Of_Runs); /***************/ /* Start timer */ /***************/ gettimeofday(&time_info, 0); Begin_Time = time_info.tv_sec * 1000000L + time_info.tv_usec; for (Run_Index = 1; Run_Index <= Number_Of_Runs; ++Run_Index) { Proc_5(); Proc_4(); /* Ch_1_Glob == 'A', Ch_2_Glob == 'B', Bool_Glob == true */ Int_1_Loc = 2; Int_2_Loc = 3; strcpy (Str_2_Loc, "DHRYSTONE PROGRAM, 2'ND STRING"); Enum_Loc = Ident_2; Bool_Glob = ! Func_2 (Str_1_Loc, Str_2_Loc); /* Bool_Glob == 1 */ while (Int_1_Loc < Int_2_Loc) /* loop body executed once */ { Int_3_Loc = 5 * Int_1_Loc - Int_2_Loc; /* Int_3_Loc == 7 */ Proc_7 (Int_1_Loc, Int_2_Loc, &Int_3_Loc); /* Int_3_Loc == 7 */ Int_1_Loc += 1; } /* while */ /* Int_1_Loc == 3, Int_2_Loc == 3, Int_3_Loc == 7 */ Proc_8 (Arr_1_Glob, Arr_2_Glob, Int_1_Loc, Int_3_Loc); /* Int_Glob == 5 */ Proc_1 (Ptr_Glob); for (Ch_Index = 'A'; Ch_Index <= Ch_2_Glob; ++Ch_Index) /* loop body executed twice */ { if (Enum_Loc == Func_1 (Ch_Index, 'C')) /* then, not executed */ { Proc_6 (Ident_1, &Enum_Loc); strcpy (Str_2_Loc, "DHRYSTONE PROGRAM, 3'RD STRING"); Int_2_Loc = Run_Index; Int_Glob = Run_Index; } } /* Int_1_Loc == 3, Int_2_Loc == 3, Int_3_Loc == 7 */ Int_2_Loc = Int_2_Loc * Int_1_Loc; Int_1_Loc = Int_2_Loc / Int_3_Loc; Int_2_Loc = 7 * (Int_2_Loc - Int_3_Loc) - Int_1_Loc; /* Int_1_Loc == 1, Int_2_Loc == 13, Int_3_Loc == 7 */ Proc_2 (&Int_1_Loc); /* Int_1_Loc == 5 */ } /* loop "for Run_Index" */ /**************/ /* Stop timer */ /**************/ gettimeofday(&time_info, 0); End_Time = time_info.tv_sec * 1000000L + time_info.tv_usec; /* Measurements should last at least 2 seconds */ Microseconds = End_Time - Begin_Time; if (Microseconds < 2000000) { printf ("Measured time too small to obtain meaningful results\n"); printf ("Increasing the number of runs\n"); printf ("\n"); Number_Of_Runs *= 10; goto again; } printf ("Execution ends\n"); printf ("\n"); printf ("Final values of the variables used in the benchmark:\n"); printf ("\n"); printf ("Int_Glob: %d\n", Int_Glob); printf (" should be: %d\n", 5); printf ("Bool_Glob: %d\n", Bool_Glob); printf (" should be: %d\n", 1); printf ("Ch_1_Glob: %c\n", Ch_1_Glob); printf (" should be: %c\n", 'A'); printf ("Ch_2_Glob: %c\n", Ch_2_Glob); printf (" should be: %c\n", 'B'); printf ("Arr_1_Glob[8]: %d\n", Arr_1_Glob[8]); printf (" should be: %d\n", 7); printf ("Arr_2_Glob[8][7]: %d\n", Arr_2_Glob[8][7]); printf (" should be: Number_Of_Runs + 10\n"); printf ("Ptr_Glob->\n"); printf (" Ptr_Comp: %p\n", Ptr_Glob->Ptr_Comp); printf (" should be: (implementation-dependent)\n"); printf (" Discr: %d\n", Ptr_Glob->Discr); printf (" should be: %d\n", 0); printf (" Enum_Comp: %d\n", Ptr_Glob->variant.var_1.Enum_Comp); printf (" should be: %d\n", 2); printf (" Int_Comp: %d\n", Ptr_Glob->variant.var_1.Int_Comp); printf (" should be: %d\n", 17); printf (" Str_Comp: %s\n", Ptr_Glob->variant.var_1.Str_Comp); printf (" should be: DHRYSTONE PROGRAM, SOME STRING\n"); printf ("Next_Ptr_Glob->\n"); printf (" Ptr_Comp: %p\n", Next_Ptr_Glob->Ptr_Comp); printf (" should be: (implementation-dependent), same as above\n"); printf (" Discr: %d\n", Next_Ptr_Glob->Discr); printf (" should be: %d\n", 0); printf (" Enum_Comp: %d\n", Next_Ptr_Glob->variant.var_1.Enum_Comp); printf (" should be: %d\n", 1); printf (" Int_Comp: %d\n", Next_Ptr_Glob->variant.var_1.Int_Comp); printf (" should be: %d\n", 18); printf (" Str_Comp: %s\n", Next_Ptr_Glob->variant.var_1.Str_Comp); printf (" should be: DHRYSTONE PROGRAM, SOME STRING\n"); printf ("Int_1_Loc: %d\n", Int_1_Loc); printf (" should be: %d\n", 5); printf ("Int_2_Loc: %d\n", Int_2_Loc); printf (" should be: %d\n", 13); printf ("Int_3_Loc: %d\n", Int_3_Loc); printf (" should be: %d\n", 7); printf ("Enum_Loc: %d\n", Enum_Loc); printf (" should be: %d\n", 1); printf ("Str_1_Loc: %s\n", Str_1_Loc); printf (" should be: DHRYSTONE PROGRAM, 1'ST STRING\n"); printf ("Str_2_Loc: %s\n", Str_2_Loc); printf (" should be: DHRYSTONE PROGRAM, 2'ND STRING\n"); printf ("\n"); /* Dhrystones per 10^-5 sec. */ Dhrystones_per_Millisecond = Number_Of_Runs / (Microseconds / 1000); Dmips = Dhrystones_per_Millisecond * 10000 / DHRYSTONES_PER_DMIPS; printf ("Nanoseconds for one run through Dhrystone: %lu \n", Microseconds / (Number_Of_Runs / 1000)); printf (" Million Dhrystones per Second: %lu.%03lu \n", Dhrystones_per_Millisecond / 1000, Dhrystones_per_Millisecond % 1000); printf (" DMIPS: %lu.%lu \n", Dmips / 10, Dmips % 10); printf ("\n"); return 0; } void Proc_1 (Rec_Pointer Ptr_Val_Par) /******************/ /* executed once */ { Rec_Pointer Next_Record = Ptr_Val_Par->Ptr_Comp; /* == Ptr_Glob_Next */ /* Local variable, initialized with Ptr_Val_Par->Ptr_Comp, */ /* corresponds to "rename" in Ada, "with" in Pascal */ *Ptr_Val_Par->Ptr_Comp = *Ptr_Glob; Ptr_Val_Par->variant.var_1.Int_Comp = 5; Next_Record->variant.var_1.Int_Comp = Ptr_Val_Par->variant.var_1.Int_Comp; Next_Record->Ptr_Comp = Ptr_Val_Par->Ptr_Comp; Proc_3 (&Next_Record->Ptr_Comp); /* Ptr_Val_Par->Ptr_Comp->Ptr_Comp == Ptr_Glob->Ptr_Comp */ if (Next_Record->Discr == Ident_1) /* then, executed */ { Next_Record->variant.var_1.Int_Comp = 6; Proc_6 (Ptr_Val_Par->variant.var_1.Enum_Comp, &Next_Record->variant.var_1.Enum_Comp); Next_Record->Ptr_Comp = Ptr_Glob->Ptr_Comp; Proc_7 (Next_Record->variant.var_1.Int_Comp, 10, &Next_Record->variant.var_1.Int_Comp); } else /* not executed */ *Ptr_Val_Par = *Ptr_Val_Par->Ptr_Comp; } /* Proc_1 */ void Proc_2 (One_Fifty *Int_Par_Ref) /******************/ /* executed once */ /* *Int_Par_Ref == 1, becomes 4 */ { One_Fifty Int_Loc; Enumeration Enum_Loc; Int_Loc = *Int_Par_Ref + 10; do /* executed once */ if (Ch_1_Glob == 'A') /* then, executed */ { Int_Loc -= 1; *Int_Par_Ref = Int_Loc - Int_Glob; Enum_Loc = Ident_1; } /* if */ while (Enum_Loc != Ident_1); /* true */ } /* Proc_2 */ void Proc_3 (Rec_Pointer *Ptr_Ref_Par) /******************/ /* executed once */ /* Ptr_Ref_Par becomes Ptr_Glob */ { if (Ptr_Glob != 0) /* then, executed */ *Ptr_Ref_Par = Ptr_Glob->Ptr_Comp; Proc_7 (10, Int_Glob, &Ptr_Glob->variant.var_1.Int_Comp); } /* Proc_3 */ void Proc_4 () /* without parameters */ /*******/ /* executed once */ { Boolean Bool_Loc; Bool_Loc = Ch_1_Glob == 'A'; Bool_Glob = Bool_Loc | Bool_Glob; Ch_2_Glob = 'B'; } /* Proc_4 */ void Proc_5 () /* without parameters */ /*******/ /* executed once */ { Ch_1_Glob = 'A'; Bool_Glob = false; } /* Proc_5 */ ================================================ FILE: share/examples/dhrystone/dhry_2.c ================================================ /* **************************************************************************** * * "DHRYSTONE" Benchmark Program * ----------------------------- * * Version: C, Version 2.1 * * File: dhry_2.c (part 3 of 3) * * Date: May 25, 1988 * * Author: Reinhold P. Weicker * **************************************************************************** */ #include #include "dhry.h" extern int Int_Glob; extern char Ch_1_Glob; void Proc_6 (Enumeration Enum_Val_Par, Enumeration *Enum_Ref_Par) /*********************************/ /* executed once */ /* Enum_Val_Par == Ident_3, Enum_Ref_Par becomes Ident_2 */ { *Enum_Ref_Par = Enum_Val_Par; if (! Func_3 (Enum_Val_Par)) /* then, not executed */ *Enum_Ref_Par = Ident_4; switch (Enum_Val_Par) { case Ident_1: *Enum_Ref_Par = Ident_1; break; case Ident_2: if (Int_Glob > 100) /* then */ *Enum_Ref_Par = Ident_1; else *Enum_Ref_Par = Ident_4; break; case Ident_3: /* executed */ *Enum_Ref_Par = Ident_2; break; case Ident_4: break; case Ident_5: *Enum_Ref_Par = Ident_3; break; } /* switch */ } /* Proc_6 */ void Proc_7 (One_Fifty Int_1_Par_Val, One_Fifty Int_2_Par_Val, One_Fifty *Int_Par_Ref) /**********************************************/ /* executed three times */ /* first call: Int_1_Par_Val == 2, Int_2_Par_Val == 3, */ /* Int_Par_Ref becomes 7 */ /* second call: Int_1_Par_Val == 10, Int_2_Par_Val == 5, */ /* Int_Par_Ref becomes 17 */ /* third call: Int_1_Par_Val == 6, Int_2_Par_Val == 10, */ /* Int_Par_Ref becomes 18 */ { One_Fifty Int_Loc; Int_Loc = Int_1_Par_Val + 2; *Int_Par_Ref = Int_2_Par_Val + Int_Loc; } /* Proc_7 */ void Proc_8 (Arr_1_Dim Arr_1_Par_Ref, Arr_2_Dim Arr_2_Par_Ref, int Int_1_Par_Val, int Int_2_Par_Val) /*********************************************************************/ /* executed once */ /* Int_Par_Val_1 == 3 */ /* Int_Par_Val_2 == 7 */ { One_Fifty Int_Index; One_Fifty Int_Loc; Int_Loc = Int_1_Par_Val + 5; Arr_1_Par_Ref [Int_Loc] = Int_2_Par_Val; Arr_1_Par_Ref [Int_Loc+1] = Arr_1_Par_Ref [Int_Loc]; Arr_1_Par_Ref [Int_Loc+30] = Int_Loc; for (Int_Index = Int_Loc; Int_Index <= Int_Loc+1; ++Int_Index) Arr_2_Par_Ref [Int_Loc] [Int_Index] = Int_Loc; Arr_2_Par_Ref [Int_Loc] [Int_Loc-1] += 1; Arr_2_Par_Ref [Int_Loc+20] [Int_Loc] = Arr_1_Par_Ref [Int_Loc]; Int_Glob = 5; } /* Proc_8 */ Enumeration Func_1 (Capital_Letter Ch_1_Par_Val, Capital_Letter Ch_2_Par_Val) /*************************************************/ /* executed three times */ /* first call: Ch_1_Par_Val == 'H', Ch_2_Par_Val == 'R' */ /* second call: Ch_1_Par_Val == 'A', Ch_2_Par_Val == 'C' */ /* third call: Ch_1_Par_Val == 'B', Ch_2_Par_Val == 'C' */ { Capital_Letter Ch_1_Loc; Capital_Letter Ch_2_Loc; Ch_1_Loc = Ch_1_Par_Val; Ch_2_Loc = Ch_1_Loc; if (Ch_2_Loc != Ch_2_Par_Val) /* then, executed */ return (Ident_1); else /* not executed */ { Ch_1_Glob = Ch_1_Loc; return (Ident_2); } } /* Func_1 */ Boolean Func_2 (Str_30 Str_1_Par_Ref, Str_30 Str_2_Par_Ref) /*************************************************/ /* executed once */ /* Str_1_Par_Ref == "DHRYSTONE PROGRAM, 1'ST STRING" */ /* Str_2_Par_Ref == "DHRYSTONE PROGRAM, 2'ND STRING" */ { One_Thirty Int_Loc; Capital_Letter Ch_Loc; Int_Loc = 2; while (Int_Loc <= 2) /* loop body executed once */ if (Func_1 (Str_1_Par_Ref[Int_Loc], Str_2_Par_Ref[Int_Loc+1]) == Ident_1) /* then, executed */ { Ch_Loc = 'A'; Int_Loc += 1; } /* if, while */ if (Ch_Loc >= 'W' && Ch_Loc < 'Z') /* then, not executed */ Int_Loc = 7; if (Ch_Loc == 'R') /* then, not executed */ return (true); else /* executed */ { if (strcmp (Str_1_Par_Ref, Str_2_Par_Ref) > 0) /* then, not executed */ { Int_Loc += 7; Int_Glob = Int_Loc; return (true); } else /* executed */ return (false); } /* if Ch_Loc */ } /* Func_2 */ Boolean Func_3 (Enumeration Enum_Par_Val) /***************************/ /* executed once */ /* Enum_Par_Val == Ident_3 */ { Enumeration Enum_Loc; Enum_Loc = Enum_Par_Val; if (Enum_Loc == Ident_3) /* then, executed */ return (true); else /* not executed */ return (false); } /* Func_3 */ ================================================ FILE: share/examples/forth/fact.fth ================================================ \ Iterative factorial function. ." Defining fact function ... " : fact ( n -- n! ) dup 2 < if drop 1 else dup begin 1- swap over * swap dup 1 = until drop then ; ." done." cr ." 1! = " 1 fact . cr ." 2! = " 2 fact . cr ." 3! = " 3 fact . cr ." 4! = " 4 fact . cr ." 5! = " 5 fact . cr ." 6! = " 6 fact . cr ." 7! = " 7 fact . cr ." 8! = " 8 fact . cr ." 9! = " 9 fact . cr ." 10! = " 10 fact . cr ." 11! = " 11 fact . cr ." 12! = " 12 fact . cr halt ================================================ FILE: share/examples/gpanel/Makefile ================================================ CC = cc LIBS = -lgpanel PROG = tft tftetris pixel line rect fill circle font color speed flappy FONTS = 5x7.o 6x9.o digits20.o digits32.o lucidasans11.o lucidasans15.o \ lucidasans28.o lucidasans7.o lucidasans9.o verdana7.o all: $(PROG) clean: rm -f *.o *~ $(PROG) tft: tft.c $(CC) $(CFLAGS) -o $@ $(LDFLAGS) $? tftetris: tftetris.c $(CC) $(CFLAGS) -o $@ $(LDFLAGS) $? pixel: pixel.c $(CC) $(CFLAGS) -o $@ $(LDFLAGS) $? $(LIBS) line: line.c $(CC) $(CFLAGS) -o $@ $(LDFLAGS) $? $(LIBS) rect: rect.c $(CC) $(CFLAGS) -o $@ $(LDFLAGS) $? $(LIBS) fill: fill.c $(CC) $(CFLAGS) -o $@ $(LDFLAGS) $? $(LIBS) circle: circle.c $(CC) $(CFLAGS) -o $@ $(LDFLAGS) $? $(LIBS) color: color.c $(CC) $(CFLAGS) -o $@ $(LDFLAGS) $? $(LIBS) speed: speed.c lucidasans15.o $(CC) $(CFLAGS) -o $@ $(LDFLAGS) speed.c lucidasans15.o $(LIBS) flappy: flappy.c lucidasans15.o lucidasans28.o $(CC) $(CFLAGS) -o $@ $(LDFLAGS) flappy.c lucidasans15.o lucidasans28.o $(LIBS) font: font.c $(FONTS) $(CC) $(CFLAGS) -o $@ $(LDFLAGS) font.c $(FONTS) $(LIBS) 5x7.o: fonts/5x7.c $(CC) $(CFLAGS) -o $@ -c $? 6x9.o: fonts/6x9.c $(CC) $(CFLAGS) -o $@ -c $? digits20.o: fonts/digits20.c $(CC) $(CFLAGS) -o $@ -c $? digits32.o: fonts/digits32.c $(CC) $(CFLAGS) -o $@ -c $? lucidasans11.o: fonts/lucidasans11.c $(CC) $(CFLAGS) -o $@ -c $? lucidasans15.o: fonts/lucidasans15.c $(CC) $(CFLAGS) -o $@ -c $? lucidasans28.o: fonts/lucidasans28.c $(CC) $(CFLAGS) -o $@ -c $? lucidasans7.o: fonts/lucidasans7.c $(CC) $(CFLAGS) -o $@ -c $? lucidasans9.o: fonts/lucidasans9.c $(CC) $(CFLAGS) -o $@ -c $? verdana7.o: fonts/verdana7.c $(CC) $(CFLAGS) -o $@ -c $? ================================================ FILE: share/examples/gpanel/circle.c ================================================ /* * Draw random circles. */ #include #include int xsize, ysize; int main() { char *devname = "/dev/tft0"; int x, y, r, color; if (gpanel_open(devname) < 0) { printf("Cannot open %s\n", devname); exit(-1); } gpanel_clear(0, &xsize, &ysize); printf("Screen size %u x %u.\n", xsize, ysize); srand(time(0)); printf("Draw random circles.\n"); printf("Press ^C to stop.\n"); for (;;) { x = rand() % xsize; y = rand() % ysize; r = rand() % ysize; color = rand() << 1; gpanel_circle(color, x, y, r); } return 0; } ================================================ FILE: share/examples/gpanel/color.c ================================================ /* * Display a color palette. * Assume RGB 5-6-5 color format. * Color is a 16-bit value: rrrrrggggggbbbbb, where rrrrr, * gggggg and bbbbb are red, green and blue components. */ #include #include int xsize, ysize; int scale_red(int x, int y) { int r; r = 32 * y * (xsize-x-1) / xsize / ysize; if (r > 31) r = 31; return r; } int scale_green(int x, int y) { int g; g = 64 * x / xsize; if (g > 63) g = 63; return g; } int scale_blue(int x, int y) { int b; b = 32 * (ysize-y-1) * (xsize-x-1) / xsize / ysize; if (b > 31) b = 31; return b; } int main() { char *devname = "/dev/tft0"; int x, y, r, g, b, color; if (gpanel_open(devname) < 0) { printf("Cannot open %s\n", devname); exit(-1); } gpanel_clear(0, &xsize, &ysize); printf("Screen size %u x %u.\n", xsize, ysize); printf("Display color palette.\n"); for (y=0; y #include int xsize, ysize; int main() { char *devname = "/dev/tft0"; int x0, y0, x1, y1, color; if (gpanel_open(devname) < 0) { printf("Cannot open %s\n", devname); exit(-1); } gpanel_clear(0, &xsize, &ysize); printf("Screen size %u x %u.\n", xsize, ysize); srand(time(0)); printf("Draw random filled rectangles.\n"); printf("Press ^C to stop.\n"); for (;;) { x0 = rand() % xsize; y0 = rand() % ysize; x1 = rand() % xsize; y1 = rand() % ysize; color = rand() << 1; gpanel_fill(color, x0, y0, x1, y1); } return 0; } ================================================ FILE: share/examples/gpanel/flappy.c ================================================ #include #include #include #include #include #include #include #include #include /* * Assign human-readable names to some common 16-bit color values: */ #define BLACK 0x0000 #define BLUE 0x002F #define RED 0xF800 #define GREEN 0x07E0 #define CYAN 0x07FF #define MAGENTA 0xF81F #define YELLOW 0xFFE0 #define WHITE 0xFFFF /* * Redraw every 50 msec */ #define DRAW_LOOP_INTERVAL 50 /* * File name for saving the high score. */ #define SCORE_FILENAME "flappy.score" /* * Data from external font files. */ extern const struct gpanel_font_t font_lucidasans15; extern const struct gpanel_font_t font_lucidasans28; int wing; int fx, fy, fall_rate; int pillar_pos, gap_pos; int score; int high_score = 0; int running = 0; int crashed = 0; int scr_press = 0; time_t next_draw_time; void rect(int color, int x, int y, int w, int h) { gpanel_rect(color, x, y, x+w-1, y+h-1); } void fill(int color, int x, int y, int w, int h) { gpanel_fill(color, x, y, x+w-1, y+h-1); } void draw_pillar(int x, int gap) { if (x >= 320) return; fill(GREEN, x+2, 2, 46, gap-4); fill(GREEN, x+2, gap+92, 46, 136-gap); rect(BLACK, x, 0, 50, gap); rect(BLACK, x+1, 1, 48, gap-2); rect(BLACK, x, gap+90, 50, 140-gap); rect(BLACK, x+1, gap+91, 48, 138-gap); } void clear_pillar(int x, int gap) { if (x >= 320) return; /* "Cheat" slightly and just clear the right hand pixels * to help minimise flicker, the rest will be overdrawn. */ fill(BLUE, x+45, 0, 5, gap); fill(BLUE, x+45, gap+90, 5, 140-gap); } void clear_flappy(int x, int y) { fill(BLUE, x, y, 34, 24); } void draw_flappy(int x, int y) { /* Upper & lower body */ fill(BLACK, x+2, y+8, 2, 10); fill(BLACK, x+4, y+6, 2, 2); fill(BLACK, x+6, y+4, 2, 2); fill(BLACK, x+8, y+2, 4, 2); fill(BLACK, x+12, y, 12, 2); fill(BLACK, x+24, y+2, 2, 2); fill(BLACK, x+26, y+4, 2, 2); fill(BLACK, x+28, y+6, 2, 6); fill(BLACK, x+10, y+22, 10, 2); fill(BLACK, x+4, y+18, 2, 2); fill(BLACK, x+6, y+20, 4, 2); /* Body fill */ fill(YELLOW, x+12, y+2, 6, 2); fill(YELLOW, x+8, y+4, 8, 2); fill(YELLOW, x+6, y+6, 10, 2); fill(YELLOW, x+4, y+8, 12, 2); fill(YELLOW, x+4, y+10, 14, 2); fill(YELLOW, x+4, y+12, 16, 2); fill(YELLOW, x+4, y+14, 14, 2); fill(YELLOW, x+4, y+16, 12, 2); fill(YELLOW, x+6, y+18, 12, 2); fill(YELLOW, x+10, y+20, 10, 2); /* Eye */ fill(BLACK, x+18, y+2, 2, 2); fill(BLACK, x+16, y+4, 2, 6); fill(BLACK, x+18, y+10, 2, 2); fill(WHITE, x+18, y+4, 2, 6); fill(WHITE, x+20, y+2, 4, 10); fill(WHITE, x+24, y+4, 2, 8); fill(WHITE, x+26, y+6, 2, 6); fill(BLACK, x+24, y+6, 2, 4); /* Beak */ fill(BLACK, x+20, y+12, 12, 2); fill(BLACK, x+18, y+14, 2, 2); fill(RED, x+20, y+14, 12, 2); fill(BLACK, x+32, y+14, 2, 2); fill(BLACK, x+16, y+16, 2, 2); fill(RED, x+18, y+16, 2, 2); fill(BLACK, x+20, y+16, 12, 2); fill(BLACK, x+18, y+18, 2, 2); fill(RED, x+20, y+18, 10, 2); fill(BLACK, x+30, y+18, 2, 2); fill(BLACK, x+20, y+20, 10, 2); } /* * Wing down. */ void draw_wing1(int x, int y) { fill(BLACK, x, y+14, 2, 6); fill(BLACK, x+2, y+20, 8, 2); fill(BLACK, x+2, y+12, 10, 2); fill(BLACK, x+12, y+14, 2, 2); fill(BLACK, x+10, y+16, 2, 2); fill(WHITE, x+2, y+14, 8, 6); fill(BLACK, x+8, y+18, 2, 2); fill(WHITE, x+10, y+14, 2, 2); } /* * Wing middle. */ void draw_wing2(int x, int y) { fill(BLACK, x+2, y+10, 10, 2); fill(BLACK, x+2, y+16, 10, 2); fill(BLACK, x, y+12, 2, 4); fill(BLACK, x+12, y+12, 2, 4); fill(WHITE, x+2, y+12, 10, 4); } /* * Wing up. */ void draw_wing3(int x, int y) { fill(BLACK, x+2, y+6, 8, 2); fill(BLACK, x, y+8, 2, 6); fill(BLACK, x+10, y+8, 2, 2); fill(BLACK, x+12, y+10, 2, 4); fill(BLACK, x+10, y+14, 2, 2); fill(BLACK, x+2, y+14, 2, 2); fill(BLACK, x+4, y+16, 6, 2); fill(WHITE, x+2, y+8, 8, 6); fill(WHITE, x+4, y+14, 6, 2); fill(WHITE, x+10, y+10, 2, 4); } time_t millis() { struct timeval tv; gettimeofday(&tv, 0); return (tv.tv_sec * 1000) + (tv.tv_usec / 1000); } void start_game() { fx = 50; fy = 125; fall_rate = -1; pillar_pos = 320; gap_pos = 60; crashed = 0; score = 0; gpanel_clear(BLUE, 0, 0); gpanel_text(&font_lucidasans28, WHITE, BLUE, 10, 10, "Flappy Bird"); gpanel_text(&font_lucidasans15, WHITE, BLUE, 50, 180, "(Press Space to start)"); char score_line[80]; sprintf(score_line, "High Score: %u", high_score); gpanel_text(&font_lucidasans28, GREEN, BLUE, 10, 60, score_line); /* Draw ground. */ int tx, ty = 230; for (tx = 0; tx <= 300; tx += 20) { gpanel_fill_triangle(GREEN, tx, ty, tx+9, ty, tx, ty+9); gpanel_fill_triangle(YELLOW, tx+9, ty+9, tx+9, ty, tx, ty+9); gpanel_fill_triangle(YELLOW, tx+10, ty, tx+19, ty, tx+10, ty+9); gpanel_fill_triangle(GREEN, tx+19, ty+9, tx+19, ty, tx+10, ty+9); } next_draw_time = millis() + DRAW_LOOP_INTERVAL; } void draw_loop() { /* Clear moving items. */ clear_pillar(pillar_pos, gap_pos); /* Move items. */ if (running) { clear_flappy(fx, fy); fy += fall_rate; fall_rate++; pillar_pos -= 5; if (pillar_pos == 0) { score++; } else if (pillar_pos < -50) { pillar_pos = 320; gap_pos = 20 + random() % 100; } } /* Draw moving items & animate. */ draw_flappy(fx, fy); draw_pillar(pillar_pos, gap_pos); switch (wing) { case 0: case 1: draw_wing1(fx, fy); break; case 2: case 3: draw_wing2(fx, fy); break; case 4: case 5: draw_wing3(fx, fy); break; } wing++; if (wing == 6) wing = 0; } /* * Write high score value to file. */ void save_score() { int fd, nbytes; char line[80]; fd = open(SCORE_FILENAME, O_WRONLY | O_CREAT, 0644); if (fd < 0) { perror(SCORE_FILENAME); return; } sprintf(line, "%u\n", high_score); nbytes = strlen(line); if (write(fd, line, nbytes) != nbytes) perror(SCORE_FILENAME); close(fd); } /* * Read high score value from file. */ void load_score() { int fd, nbytes; char line[80]; fd = open(SCORE_FILENAME, O_RDONLY); if (fd < 0) { /* No high score file yet. */ return; } nbytes = read(fd, line, sizeof(line)); if (nbytes <= 0) { if (nbytes < 0) perror(SCORE_FILENAME); return; } close(fd); high_score = strtol(line, 0, 0); } void check_collision() { /* Collision with ground. */ if (fy > 206) crashed = 1; /* Collision with pillar. */ if (fx + 34 > pillar_pos && fx < pillar_pos + 50) if (fy < gap_pos || fy + 24 > gap_pos + 90) crashed = 1; if (crashed) { gpanel_text(&font_lucidasans28, RED, BLUE, 50, 50, "Game Over!"); char score_line[80]; sprintf(score_line, "Score: %u", score); gpanel_text(&font_lucidasans28, RED, BLUE, 50, 100, score_line); if (score > high_score) { high_score = score; gpanel_text(&font_lucidasans28, RED, BLUE, 50, 150, "NEW HIGH!"); save_score(); } /* Stop animation. */ running = 0; /* Delay to stop any last minute clicks from restarting immediately. */ sleep(1); } } #if 1 #ifndef SDL struct sgttyb origtty, newtty; #endif /* * Terminate the game when ^C pressed. */ void quit(int sig) { signal(SIGINT, SIG_IGN); #ifndef SDL if (newtty.sg_flags != 0) ioctl(0, TIOCSETP, &origtty); #endif gpanel_close(); exit(0); } /* * Return 1 when any key is pressed on console. */ int get_input() { #ifdef SDL extern int gpanel_input(void); return gpanel_input(); #else if (newtty.sg_flags == 0) { ioctl(0, TIOCGETP, &origtty); newtty = origtty; newtty.sg_flags &= ~(ECHO|XTABS); newtty.sg_flags |= CBREAK; ioctl(0, TIOCSETP, &newtty); } int nchars = 0; ioctl(0, FIONREAD, &nchars); if (nchars <= 0) return 0; char c; read(0, &c, 1); return 1; #endif } #endif int main() { char *devname = "/dev/tft0"; int xsize = 320, ysize = 240; signal(SIGINT, quit); if (gpanel_open(devname) < 0) { printf("Cannot open %s\n", devname); exit(-1); } gpanel_clear(BLUE, &xsize, &ysize); load_score(); start_game(); for (;;) { if (millis() > next_draw_time && !crashed) { draw_loop(); check_collision(); next_draw_time += DRAW_LOOP_INTERVAL; } usleep(10000); /* Get user input. */ int user_input = get_input(); /* Process "user input". */ if (user_input > 0 && !scr_press) { if (crashed) { /* Restart game. */ start_game(); } else if (!running) { /* Clear text & start scrolling. */ gpanel_fill(BLUE, 0, 0, 320-1, 100); gpanel_fill(BLUE, 0, 180, 320-1, 205); running = 1; } else { /* Fly up. */ fall_rate = -8; scr_press = 1; } } else if (user_input == 0 && scr_press) { /* Attempt to throttle presses. */ scr_press = 0; } } } ================================================ FILE: share/examples/gpanel/font.c ================================================ /* * Draw samples of various fonts. */ #include #include /* * Data from external font files. */ extern const struct gpanel_font_t font_lucidasans15; extern const struct gpanel_font_t font_lucidasans11; extern const struct gpanel_font_t font_lucidasans9; extern const struct gpanel_font_t font_lucidasans7; extern const struct gpanel_font_t font_verdana7; extern const struct gpanel_font_t font_6x9; extern const struct gpanel_font_t font_5x7; extern const struct gpanel_font_t font_digits32; extern const struct gpanel_font_t font_digits20; /* * Color constants. */ #define COLOR_RGB(r,g,b) ((r)<<11 | (g)<<5 | (b)) #define COLOR_BLACK 0 #define COLOR_WHITE COLOR_RGB(31, 63, 31) #define COLOR_YELLOW COLOR_RGB(31, 63, 0) #define COLOR_MAGENTA COLOR_RGB(31, 0, 31) #define COLOR_CYAN COLOR_RGB(0, 63, 31) #define COLOR_RED COLOR_RGB(31, 0, 0) #define COLOR_GREEN COLOR_RGB(0, 63, 0) #define COLOR_BLUE COLOR_RGB(0, 0, 31) /* * Screen size. */ int xsize, ysize; void show(const struct gpanel_font_t *font, const char *title, int digits_only) { char line[100]; int x = 0, y = 0, i, color; const char *phrase = digits_only ? "0123456789" : "The quick brown fox jumps over the lazy dog."; static const int colortab[] = { COLOR_YELLOW, COLOR_CYAN, COLOR_MAGENTA, COLOR_RED, COLOR_GREEN, COLOR_BLUE, 0, }; gpanel_clear(COLOR_BLACK, 0, 0); gpanel_text(&font_lucidasans15, COLOR_WHITE, COLOR_BLACK, x, y, title); y += font_lucidasans15.height * 2; for (i=0; yheight; } printf("Font %s: press Enter...", title); fflush(stdout); fgets(line, sizeof(line), stdin); } int main() { char *devname = "/dev/tft0"; int x, y, color; if (gpanel_open(devname) < 0) { printf("Cannot open %s\n", devname); exit(-1); } gpanel_clear(0, &xsize, &ysize); printf("Screen size %u x %u.\n", xsize, ysize); printf("Draw fonts.\n"); printf("Press ^C to stop.\n"); for (;;) { show(&font_lucidasans15, "Lucida Sans 15", 0); show(&font_lucidasans11, "Lucida Sans 11", 0); show(&font_lucidasans9, "Lucida Sans 9", 0); show(&font_lucidasans7, "Lucida Sans 7", 0); show(&font_verdana7, "Verdana 7", 0); show(&font_6x9, "Fixed 6x9", 0); show(&font_5x7, "Fixed 5x7", 0); show(&font_digits32, "Digits 32", 1); show(&font_digits20, "Digits 20", 1); } return 0; } ================================================ FILE: share/examples/gpanel/fonts/5x7.c ================================================ /* Generated by convbdf on Thu Oct 8 21:26:35 2015. */ #include /* Font information: name: 5x7 facename: -Misc-Fixed-Medium-R-Normal--7-70-75-75-C-50-ISO10646-1 w x h: 5x7 size: 1104 ascent: 6 descent: 1 first char: 0 (0x00) last char: 1103 (0x44f) default char: 0 (0x00) proportional: no Public domain font. Share and enjoy. */ /* Font character bitmap data. */ static const unsigned short _5x7_bits[] = { /* Character 0 (0x00): width 5 +-----+ | | |* * *| | | |* *| | | |* * *| | | +-----+ */ 0x0000, 0xa800, 0x0000, 0x8800, 0x0000, 0xa800, 0x0000, /* Character 32 (0x20): width 5 +-----+ | | | | | | | | | | | | | | +-----+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 33 (0x21): width 5 +-----+ | * | | * | | * | | * | | | | * | | | +-----+ */ 0x2000, 0x2000, 0x2000, 0x2000, 0x0000, 0x2000, 0x0000, /* Character 34 (0x22): width 5 +-----+ | * * | | * * | | * * | | | | | | | | | +-----+ */ 0x5000, 0x5000, 0x5000, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 35 (0x23): width 5 +-----+ | | | * * | |*****| | * * | |*****| | * * | | | +-----+ */ 0x0000, 0x5000, 0xf800, 0x5000, 0xf800, 0x5000, 0x0000, /* Character 36 (0x24): width 5 +-----+ | | | *** | |* * | | *** | | * *| | *** | | | +-----+ */ 0x0000, 0x7000, 0xa000, 0x7000, 0x2800, 0x7000, 0x0000, /* Character 37 (0x25): width 5 +-----+ |* | |* * | | * | | * | |* * | | * | | | +-----+ */ 0x8000, 0x9000, 0x2000, 0x4000, 0x9000, 0x1000, 0x0000, /* Character 38 (0x26): width 5 +-----+ | | | * | |* * | | * | |* * | | * * | | | +-----+ */ 0x0000, 0x4000, 0xa000, 0x4000, 0xa000, 0x5000, 0x0000, /* Character 39 (0x27): width 5 +-----+ | * | | * | | * | | | | | | | | | +-----+ */ 0x2000, 0x2000, 0x2000, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 40 (0x28): width 5 +-----+ | * | | * | | * | | * | | * | | * | | | +-----+ */ 0x2000, 0x4000, 0x4000, 0x4000, 0x4000, 0x2000, 0x0000, /* Character 41 (0x29): width 5 +-----+ | * | | * | | * | | * | | * | | * | | | +-----+ */ 0x4000, 0x2000, 0x2000, 0x2000, 0x2000, 0x4000, 0x0000, /* Character 42 (0x2a): width 5 +-----+ | | | * * | | * | | *** | | * | | * * | | | +-----+ */ 0x0000, 0x5000, 0x2000, 0x7000, 0x2000, 0x5000, 0x0000, /* Character 43 (0x2b): width 5 +-----+ | | | * | | * | |*****| | * | | * | | | +-----+ */ 0x0000, 0x2000, 0x2000, 0xf800, 0x2000, 0x2000, 0x0000, /* Character 44 (0x2c): width 5 +-----+ | | | | | | | | | ** | | * | | * | +-----+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x3000, 0x2000, 0x4000, /* Character 45 (0x2d): width 5 +-----+ | | | | | | |**** | | | | | | | +-----+ */ 0x0000, 0x0000, 0x0000, 0xf000, 0x0000, 0x0000, 0x0000, /* Character 46 (0x2e): width 5 +-----+ | | | | | | | | | ** | | ** | | | +-----+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x6000, 0x6000, 0x0000, /* Character 47 (0x2f): width 5 +-----+ | | | * | | * | | * | |* | | | | | +-----+ */ 0x0000, 0x1000, 0x2000, 0x4000, 0x8000, 0x0000, 0x0000, /* Character 48 (0x30): width 5 +-----+ | * | | * * | | * * | | * * | | * * | | * | | | +-----+ */ 0x2000, 0x5000, 0x5000, 0x5000, 0x5000, 0x2000, 0x0000, /* Character 49 (0x31): width 5 +-----+ | * | | ** | | * | | * | | * | | *** | | | +-----+ */ 0x2000, 0x6000, 0x2000, 0x2000, 0x2000, 0x7000, 0x0000, /* Character 50 (0x32): width 5 +-----+ | ** | |* * | | * | | * | | * | |**** | | | +-----+ */ 0x6000, 0x9000, 0x1000, 0x2000, 0x4000, 0xf000, 0x0000, /* Character 51 (0x33): width 5 +-----+ |**** | | * | | ** | | * | |* * | | ** | | | +-----+ */ 0xf000, 0x1000, 0x6000, 0x1000, 0x9000, 0x6000, 0x0000, /* Character 52 (0x34): width 5 +-----+ | * | | ** | |* * | |**** | | * | | * | | | +-----+ */ 0x2000, 0x6000, 0xa000, 0xf000, 0x2000, 0x2000, 0x0000, /* Character 53 (0x35): width 5 +-----+ |**** | |* | |*** | | * | |* * | | ** | | | +-----+ */ 0xf000, 0x8000, 0xe000, 0x1000, 0x9000, 0x6000, 0x0000, /* Character 54 (0x36): width 5 +-----+ | ** | |* | |*** | |* * | |* * | | ** | | | +-----+ */ 0x6000, 0x8000, 0xe000, 0x9000, 0x9000, 0x6000, 0x0000, /* Character 55 (0x37): width 5 +-----+ |**** | | * | | * | | * | | * | | * | | | +-----+ */ 0xf000, 0x1000, 0x2000, 0x2000, 0x4000, 0x4000, 0x0000, /* Character 56 (0x38): width 5 +-----+ | ** | |* * | | ** | |* * | |* * | | ** | | | +-----+ */ 0x6000, 0x9000, 0x6000, 0x9000, 0x9000, 0x6000, 0x0000, /* Character 57 (0x39): width 5 +-----+ | ** | |* * | |* * | | *** | | * | | ** | | | +-----+ */ 0x6000, 0x9000, 0x9000, 0x7000, 0x1000, 0x6000, 0x0000, /* Character 58 (0x3a): width 5 +-----+ | | | ** | | ** | | | | ** | | ** | | | +-----+ */ 0x0000, 0x6000, 0x6000, 0x0000, 0x6000, 0x6000, 0x0000, /* Character 59 (0x3b): width 5 +-----+ | | | ** | | ** | | | | ** | | * | |* | +-----+ */ 0x0000, 0x6000, 0x6000, 0x0000, 0x6000, 0x4000, 0x8000, /* Character 60 (0x3c): width 5 +-----+ | | | * | | * | | * | | * | | * | | | +-----+ */ 0x0000, 0x1000, 0x2000, 0x4000, 0x2000, 0x1000, 0x0000, /* Character 61 (0x3d): width 5 +-----+ | | | | |**** | | | |**** | | | | | +-----+ */ 0x0000, 0x0000, 0xf000, 0x0000, 0xf000, 0x0000, 0x0000, /* Character 62 (0x3e): width 5 +-----+ | | | * | | * | | * | | * | | * | | | +-----+ */ 0x0000, 0x4000, 0x2000, 0x1000, 0x2000, 0x4000, 0x0000, /* Character 63 (0x3f): width 5 +-----+ | * | | * * | | * | | * | | | | * | | | +-----+ */ 0x2000, 0x5000, 0x1000, 0x2000, 0x0000, 0x2000, 0x0000, /* Character 64 (0x40): width 5 +-----+ | ** | |* * | |* ** | |* ** | |* | | ** | | | +-----+ */ 0x6000, 0x9000, 0xb000, 0xb000, 0x8000, 0x6000, 0x0000, /* Character 65 (0x41): width 5 +-----+ | ** | |* * | |* * | |**** | |* * | |* * | | | +-----+ */ 0x6000, 0x9000, 0x9000, 0xf000, 0x9000, 0x9000, 0x0000, /* Character 66 (0x42): width 5 +-----+ |*** | |* * | |*** | |* * | |* * | |*** | | | +-----+ */ 0xe000, 0x9000, 0xe000, 0x9000, 0x9000, 0xe000, 0x0000, /* Character 67 (0x43): width 5 +-----+ | ** | |* * | |* | |* | |* * | | ** | | | +-----+ */ 0x6000, 0x9000, 0x8000, 0x8000, 0x9000, 0x6000, 0x0000, /* Character 68 (0x44): width 5 +-----+ |*** | |* * | |* * | |* * | |* * | |*** | | | +-----+ */ 0xe000, 0x9000, 0x9000, 0x9000, 0x9000, 0xe000, 0x0000, /* Character 69 (0x45): width 5 +-----+ |**** | |* | |*** | |* | |* | |**** | | | +-----+ */ 0xf000, 0x8000, 0xe000, 0x8000, 0x8000, 0xf000, 0x0000, /* Character 70 (0x46): width 5 +-----+ |**** | |* | |*** | |* | |* | |* | | | +-----+ */ 0xf000, 0x8000, 0xe000, 0x8000, 0x8000, 0x8000, 0x0000, /* Character 71 (0x47): width 5 +-----+ | ** | |* * | |* | |* ** | |* * | | *** | | | +-----+ */ 0x6000, 0x9000, 0x8000, 0xb000, 0x9000, 0x7000, 0x0000, /* Character 72 (0x48): width 5 +-----+ |* * | |* * | |**** | |* * | |* * | |* * | | | +-----+ */ 0x9000, 0x9000, 0xf000, 0x9000, 0x9000, 0x9000, 0x0000, /* Character 73 (0x49): width 5 +-----+ | *** | | * | | * | | * | | * | | *** | | | +-----+ */ 0x7000, 0x2000, 0x2000, 0x2000, 0x2000, 0x7000, 0x0000, /* Character 74 (0x4a): width 5 +-----+ | * | | * | | * | | * | |* * | | ** | | | +-----+ */ 0x1000, 0x1000, 0x1000, 0x1000, 0x9000, 0x6000, 0x0000, /* Character 75 (0x4b): width 5 +-----+ |* * | |* * | |** | |** | |* * | |* * | | | +-----+ */ 0x9000, 0xa000, 0xc000, 0xc000, 0xa000, 0x9000, 0x0000, /* Character 76 (0x4c): width 5 +-----+ |* | |* | |* | |* | |* | |**** | | | +-----+ */ 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0xf000, 0x0000, /* Character 77 (0x4d): width 5 +-----+ |* * | |**** | |**** | |* * | |* * | |* * | | | +-----+ */ 0x9000, 0xf000, 0xf000, 0x9000, 0x9000, 0x9000, 0x0000, /* Character 78 (0x4e): width 5 +-----+ |* * | |** * | |** * | |* ** | |* ** | |* * | | | +-----+ */ 0x9000, 0xd000, 0xd000, 0xb000, 0xb000, 0x9000, 0x0000, /* Character 79 (0x4f): width 5 +-----+ | ** | |* * | |* * | |* * | |* * | | ** | | | +-----+ */ 0x6000, 0x9000, 0x9000, 0x9000, 0x9000, 0x6000, 0x0000, /* Character 80 (0x50): width 5 +-----+ |*** | |* * | |* * | |*** | |* | |* | | | +-----+ */ 0xe000, 0x9000, 0x9000, 0xe000, 0x8000, 0x8000, 0x0000, /* Character 81 (0x51): width 5 +-----+ | ** | |* * | |* * | |* * | |** * | | ** | | * | +-----+ */ 0x6000, 0x9000, 0x9000, 0x9000, 0xd000, 0x6000, 0x1000, /* Character 82 (0x52): width 5 +-----+ |*** | |* * | |* * | |*** | |* * | |* * | | | +-----+ */ 0xe000, 0x9000, 0x9000, 0xe000, 0xa000, 0x9000, 0x0000, /* Character 83 (0x53): width 5 +-----+ | ** | |* * | | * | | * | |* * | | ** | | | +-----+ */ 0x6000, 0x9000, 0x4000, 0x2000, 0x9000, 0x6000, 0x0000, /* Character 84 (0x54): width 5 +-----+ | *** | | * | | * | | * | | * | | * | | | +-----+ */ 0x7000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x0000, /* Character 85 (0x55): width 5 +-----+ |* * | |* * | |* * | |* * | |* * | | ** | | | +-----+ */ 0x9000, 0x9000, 0x9000, 0x9000, 0x9000, 0x6000, 0x0000, /* Character 86 (0x56): width 5 +-----+ |* * | |* * | |* * | |* * | | ** | | ** | | | +-----+ */ 0x9000, 0x9000, 0x9000, 0x9000, 0x6000, 0x6000, 0x0000, /* Character 87 (0x57): width 5 +-----+ |* * | |* * | |* * | |**** | |**** | |* * | | | +-----+ */ 0x9000, 0x9000, 0x9000, 0xf000, 0xf000, 0x9000, 0x0000, /* Character 88 (0x58): width 5 +-----+ |* * | |* * | | ** | | ** | |* * | |* * | | | +-----+ */ 0x9000, 0x9000, 0x6000, 0x6000, 0x9000, 0x9000, 0x0000, /* Character 89 (0x59): width 5 +-----+ | * * | | * * | | * * | | * | | * | | * | | | +-----+ */ 0x5000, 0x5000, 0x5000, 0x2000, 0x2000, 0x2000, 0x0000, /* Character 90 (0x5a): width 5 +-----+ |**** | | * | | * | | * | |* | |**** | | | +-----+ */ 0xf000, 0x1000, 0x2000, 0x4000, 0x8000, 0xf000, 0x0000, /* Character 91 (0x5b): width 5 +-----+ | *** | | * | | * | | * | | * | | *** | | | +-----+ */ 0x7000, 0x4000, 0x4000, 0x4000, 0x4000, 0x7000, 0x0000, /* Character 92 (0x5c): width 5 +-----+ | | |* | | * | | * | | * | | | | | +-----+ */ 0x0000, 0x8000, 0x4000, 0x2000, 0x1000, 0x0000, 0x0000, /* Character 93 (0x5d): width 5 +-----+ | *** | | * | | * | | * | | * | | *** | | | +-----+ */ 0x7000, 0x1000, 0x1000, 0x1000, 0x1000, 0x7000, 0x0000, /* Character 94 (0x5e): width 5 +-----+ | * | | * * | | | | | | | | | | | +-----+ */ 0x2000, 0x5000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 95 (0x5f): width 5 +-----+ | | | | | | | | | | |**** | | | +-----+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xf000, 0x0000, /* Character 96 (0x60): width 5 +-----+ | * | | * | | | | | | | | | | | +-----+ */ 0x4000, 0x2000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 97 (0x61): width 5 +-----+ | | | | | *** | |* * | |* ** | | * * | | | +-----+ */ 0x0000, 0x0000, 0x7000, 0x9000, 0xb000, 0x5000, 0x0000, /* Character 98 (0x62): width 5 +-----+ |* | |* | |*** | |* * | |* * | |*** | | | +-----+ */ 0x8000, 0x8000, 0xe000, 0x9000, 0x9000, 0xe000, 0x0000, /* Character 99 (0x63): width 5 +-----+ | | | | | ** | |* | |* | | ** | | | +-----+ */ 0x0000, 0x0000, 0x6000, 0x8000, 0x8000, 0x6000, 0x0000, /* Character 100 (0x64): width 5 +-----+ | * | | * | | *** | |* * | |* * | | *** | | | +-----+ */ 0x1000, 0x1000, 0x7000, 0x9000, 0x9000, 0x7000, 0x0000, /* Character 101 (0x65): width 5 +-----+ | | | | | ** | |* ** | |** | | ** | | | +-----+ */ 0x0000, 0x0000, 0x6000, 0xb000, 0xc000, 0x6000, 0x0000, /* Character 102 (0x66): width 5 +-----+ | * | | * * | | * | |*** | | * | | * | | | +-----+ */ 0x2000, 0x5000, 0x4000, 0xe000, 0x4000, 0x4000, 0x0000, /* Character 103 (0x67): width 5 +-----+ | | | | | *** | |* * | | ** | |* | | *** | +-----+ */ 0x0000, 0x0000, 0x7000, 0x9000, 0x6000, 0x8000, 0x7000, /* Character 104 (0x68): width 5 +-----+ |* | |* | |*** | |* * | |* * | |* * | | | +-----+ */ 0x8000, 0x8000, 0xe000, 0x9000, 0x9000, 0x9000, 0x0000, /* Character 105 (0x69): width 5 +-----+ | * | | | | ** | | * | | * | | *** | | | +-----+ */ 0x2000, 0x0000, 0x6000, 0x2000, 0x2000, 0x7000, 0x0000, /* Character 106 (0x6a): width 5 +-----+ | * | | | | * | | * | | * | | * * | | * | +-----+ */ 0x1000, 0x0000, 0x1000, 0x1000, 0x1000, 0x5000, 0x2000, /* Character 107 (0x6b): width 5 +-----+ |* | |* | |* * | |** | |* * | |* * | | | +-----+ */ 0x8000, 0x8000, 0xa000, 0xc000, 0xa000, 0x9000, 0x0000, /* Character 108 (0x6c): width 5 +-----+ | ** | | * | | * | | * | | * | | *** | | | +-----+ */ 0x6000, 0x2000, 0x2000, 0x2000, 0x2000, 0x7000, 0x0000, /* Character 109 (0x6d): width 5 +-----+ | | | | |* * | |**** | |* * | |* * | | | +-----+ */ 0x0000, 0x0000, 0xa000, 0xf000, 0x9000, 0x9000, 0x0000, /* Character 110 (0x6e): width 5 +-----+ | | | | |*** | |* * | |* * | |* * | | | +-----+ */ 0x0000, 0x0000, 0xe000, 0x9000, 0x9000, 0x9000, 0x0000, /* Character 111 (0x6f): width 5 +-----+ | | | | | ** | |* * | |* * | | ** | | | +-----+ */ 0x0000, 0x0000, 0x6000, 0x9000, 0x9000, 0x6000, 0x0000, /* Character 112 (0x70): width 5 +-----+ | | | | |*** | |* * | |* * | |*** | |* | +-----+ */ 0x0000, 0x0000, 0xe000, 0x9000, 0x9000, 0xe000, 0x8000, /* Character 113 (0x71): width 5 +-----+ | | | | | *** | |* * | |* * | | *** | | * | +-----+ */ 0x0000, 0x0000, 0x7000, 0x9000, 0x9000, 0x7000, 0x1000, /* Character 114 (0x72): width 5 +-----+ | | | | |*** | |* * | |* | |* | | | +-----+ */ 0x0000, 0x0000, 0xe000, 0x9000, 0x8000, 0x8000, 0x0000, /* Character 115 (0x73): width 5 +-----+ | | | | | *** | |** | | ** | |*** | | | +-----+ */ 0x0000, 0x0000, 0x7000, 0xc000, 0x3000, 0xe000, 0x0000, /* Character 116 (0x74): width 5 +-----+ | * | | * | |*** | | * | | * | | ** | | | +-----+ */ 0x4000, 0x4000, 0xe000, 0x4000, 0x4000, 0x3000, 0x0000, /* Character 117 (0x75): width 5 +-----+ | | | | |* * | |* * | |* * | | *** | | | +-----+ */ 0x0000, 0x0000, 0x9000, 0x9000, 0x9000, 0x7000, 0x0000, /* Character 118 (0x76): width 5 +-----+ | | | | | * * | | * * | | * * | | * | | | +-----+ */ 0x0000, 0x0000, 0x5000, 0x5000, 0x5000, 0x2000, 0x0000, /* Character 119 (0x77): width 5 +-----+ | | | | |* * | |* * | |**** | |**** | | | +-----+ */ 0x0000, 0x0000, 0x9000, 0x9000, 0xf000, 0xf000, 0x0000, /* Character 120 (0x78): width 5 +-----+ | | | | |* * | | ** | | ** | |* * | | | +-----+ */ 0x0000, 0x0000, 0x9000, 0x6000, 0x6000, 0x9000, 0x0000, /* Character 121 (0x79): width 5 +-----+ | | | | |* * | |* * | | * * | | * | | * | +-----+ */ 0x0000, 0x0000, 0x9000, 0x9000, 0x5000, 0x2000, 0x4000, /* Character 122 (0x7a): width 5 +-----+ | | | | |**** | | * | | * | |**** | | | +-----+ */ 0x0000, 0x0000, 0xf000, 0x2000, 0x4000, 0xf000, 0x0000, /* Character 123 (0x7b): width 5 +-----+ | * | | * | | ** | | * | | * | | * | | | +-----+ */ 0x1000, 0x2000, 0x6000, 0x2000, 0x2000, 0x1000, 0x0000, /* Character 124 (0x7c): width 5 +-----+ | * | | * | | * | | * | | * | | * | | | +-----+ */ 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x0000, /* Character 125 (0x7d): width 5 +-----+ | * | | * | | ** | | * | | * | | * | | | +-----+ */ 0x4000, 0x2000, 0x3000, 0x2000, 0x2000, 0x4000, 0x0000, /* Character 126 (0x7e): width 5 +-----+ | * * | |* * | | | | | | | | | | | +-----+ */ 0x5000, 0xa000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 1040 (0x410): width 5 +-----+ | ** | |* * | |* * | |**** | |* * | |* * | | | +-----+ */ 0x6000, 0x9000, 0x9000, 0xf000, 0x9000, 0x9000, 0x0000, /* Character 1041 (0x411): width 5 +-----+ |*** | |* | |*** | |* * | |* * | |*** | | | +-----+ */ 0xe000, 0x8000, 0xe000, 0x9000, 0x9000, 0xe000, 0x0000, /* Character 1042 (0x412): width 5 +-----+ |*** | |* * | |*** | |* * | |* * | |*** | | | +-----+ */ 0xe000, 0x9000, 0xe000, 0x9000, 0x9000, 0xe000, 0x0000, /* Character 1043 (0x413): width 5 +-----+ |**** | |* | |* | |* | |* | |* | | | +-----+ */ 0xf000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x0000, /* Character 1044 (0x414): width 5 +-----+ | ** | | * * | | * * | | * * | | * * | |**** | |* * | +-----+ */ 0x3000, 0x5000, 0x5000, 0x5000, 0x5000, 0xf000, 0x9000, /* Character 1045 (0x415): width 5 +-----+ |**** | |* | |*** | |* | |* | |**** | | | +-----+ */ 0xf000, 0x8000, 0xe000, 0x8000, 0x8000, 0xf000, 0x0000, /* Character 1046 (0x416): width 5 +-----+ |* * *| |* * *| | *** | | *** | |* * *| |* * *| | | +-----+ */ 0xa800, 0xa800, 0x7000, 0x7000, 0xa800, 0xa800, 0x0000, /* Character 1047 (0x417): width 5 +-----+ |*** | | * | | ** | | * | |* * | | ** | | | +-----+ */ 0xe000, 0x1000, 0x6000, 0x1000, 0x9000, 0x6000, 0x0000, /* Character 1048 (0x418): width 5 +-----+ |* * | |* ** | |* ** | |** * | |** * | |* * | | | +-----+ */ 0x9000, 0xb000, 0xb000, 0xd000, 0xd000, 0x9000, 0x0000, /* Character 1049 (0x419): width 5 +-----+ |** * | |* ** | |* ** | |** * | |** * | |* * | | | +-----+ */ 0xd000, 0xb000, 0xb000, 0xd000, 0xd000, 0x9000, 0x0000, /* Character 1050 (0x41a): width 5 +-----+ |* * | |* * | |** | |** | |* * | |* * | | | +-----+ */ 0x9000, 0xa000, 0xc000, 0xc000, 0xa000, 0x9000, 0x0000, /* Character 1051 (0x41b): width 5 +-----+ | ** | | * * | | * * | | * * | | * * | |* * | | | +-----+ */ 0x3000, 0x5000, 0x5000, 0x5000, 0x5000, 0x9000, 0x0000, /* Character 1052 (0x41c): width 5 +-----+ |* * | |**** | |**** | |* * | |* * | |* * | | | +-----+ */ 0x9000, 0xf000, 0xf000, 0x9000, 0x9000, 0x9000, 0x0000, /* Character 1053 (0x41d): width 5 +-----+ |* * | |* * | |**** | |* * | |* * | |* * | | | +-----+ */ 0x9000, 0x9000, 0xf000, 0x9000, 0x9000, 0x9000, 0x0000, /* Character 1054 (0x41e): width 5 +-----+ | ** | |* * | |* * | |* * | |* * | | ** | | | +-----+ */ 0x6000, 0x9000, 0x9000, 0x9000, 0x9000, 0x6000, 0x0000, /* Character 1055 (0x41f): width 5 +-----+ |**** | |* * | |* * | |* * | |* * | |* * | | | +-----+ */ 0xf000, 0x9000, 0x9000, 0x9000, 0x9000, 0x9000, 0x0000, /* Character 1056 (0x420): width 5 +-----+ |*** | |* * | |* * | |*** | |* | |* | | | +-----+ */ 0xe000, 0x9000, 0x9000, 0xe000, 0x8000, 0x8000, 0x0000, /* Character 1057 (0x421): width 5 +-----+ | ** | |* * | |* | |* | |* * | | ** | | | +-----+ */ 0x6000, 0x9000, 0x8000, 0x8000, 0x9000, 0x6000, 0x0000, /* Character 1058 (0x422): width 5 +-----+ | *** | | * | | * | | * | | * | | * | | | +-----+ */ 0x7000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x0000, /* Character 1059 (0x423): width 5 +-----+ | * * | | * * | | * * | | * | | * | | * | | | +-----+ */ 0x5000, 0x5000, 0x5000, 0x2000, 0x2000, 0x4000, 0x0000, /* Character 1060 (0x424): width 5 +-----+ | * | | *** | | * * | | * * | | *** | | * | | | +-----+ */ 0x2000, 0x7000, 0x5000, 0x5000, 0x7000, 0x2000, 0x0000, /* Character 1061 (0x425): width 5 +-----+ |* * | |* * | | ** | | ** | |* * | |* * | | | +-----+ */ 0x9000, 0x9000, 0x6000, 0x6000, 0x9000, 0x9000, 0x0000, /* Character 1062 (0x426): width 5 +-----+ |* * | |* * | |* * | |* * | |* * | |**** | | * | +-----+ */ 0x9000, 0x9000, 0x9000, 0x9000, 0x9000, 0xf000, 0x1000, /* Character 1063 (0x427): width 5 +-----+ |* * | |* * | |* * | | *** | | * | | * | | | +-----+ */ 0x9000, 0x9000, 0x9000, 0x7000, 0x1000, 0x1000, 0x0000, /* Character 1064 (0x428): width 5 +-----+ |* * *| |* * *| |* * *| |* * *| |* * *| |*****| | | +-----+ */ 0xa800, 0xa800, 0xa800, 0xa800, 0xa800, 0xf800, 0x0000, /* Character 1065 (0x429): width 5 +-----+ |* * *| |* * *| |* * *| |* * *| |* * *| |*****| | *| +-----+ */ 0xa800, 0xa800, 0xa800, 0xa800, 0xa800, 0xf800, 0x0800, /* Character 1066 (0x42a): width 5 +-----+ |** | | * | | ** | | * * | | * * | | ** | | | +-----+ */ 0xc000, 0x4000, 0x6000, 0x5000, 0x5000, 0x6000, 0x0000, /* Character 1067 (0x42b): width 5 +-----+ |* * | |* * | |** * | |* ** | |* ** | |** * | | | +-----+ */ 0x9000, 0x9000, 0xd000, 0xb000, 0xb000, 0xd000, 0x0000, /* Character 1068 (0x42c): width 5 +-----+ |* | |* | |*** | |* * | |* * | |*** | | | +-----+ */ 0x8000, 0x8000, 0xe000, 0x9000, 0x9000, 0xe000, 0x0000, /* Character 1069 (0x42d): width 5 +-----+ | ** | |* * | | ** | | * | |* * | | ** | | | +-----+ */ 0x6000, 0x9000, 0x3000, 0x1000, 0x9000, 0x6000, 0x0000, /* Character 1070 (0x42e): width 5 +-----+ |* * | |** * | |** * | |** * | |** * | |* * | | | +-----+ */ 0xa000, 0xd000, 0xd000, 0xd000, 0xd000, 0xa000, 0x0000, /* Character 1071 (0x42f): width 5 +-----+ | *** | |* * | |* * | | *** | | * * | |* * | | | +-----+ */ 0x7000, 0x9000, 0x9000, 0x7000, 0x5000, 0x9000, 0x0000, /* Character 1072 (0x430): width 5 +-----+ | | | | | *** | |* * | |* ** | | * * | | | +-----+ */ 0x0000, 0x0000, 0x7000, 0x9000, 0xb000, 0x5000, 0x0000, /* Character 1073 (0x431): width 5 +-----+ | | | ** | |* | |*** | |* * | | ** | | | +-----+ */ 0x0000, 0x6000, 0x8000, 0xe000, 0x9000, 0x6000, 0x0000, /* Character 1074 (0x432): width 5 +-----+ | | | | |*** | |*** | |* * | |*** | | | +-----+ */ 0x0000, 0x0000, 0xe000, 0xe000, 0x9000, 0xe000, 0x0000, /* Character 1075 (0x433): width 5 +-----+ | | | | |**** | |* | |* | |* | | | +-----+ */ 0x0000, 0x0000, 0xf000, 0x8000, 0x8000, 0x8000, 0x0000, /* Character 1076 (0x434): width 5 +-----+ | | | | | ** | | * * | | * * | |**** | |* * | +-----+ */ 0x0000, 0x0000, 0x3000, 0x5000, 0x5000, 0xf000, 0x9000, /* Character 1077 (0x435): width 5 +-----+ | | | | | ** | |* ** | |** | | ** | | | +-----+ */ 0x0000, 0x0000, 0x6000, 0xb000, 0xc000, 0x6000, 0x0000, /* Character 1078 (0x436): width 5 +-----+ | | | | |* * *| | *** | | *** | |* * *| | | +-----+ */ 0x0000, 0x0000, 0xa800, 0x7000, 0x7000, 0xa800, 0x0000, /* Character 1079 (0x437): width 5 +-----+ | | | | |*** | | ** | | * | |** | | | +-----+ */ 0x0000, 0x0000, 0xe000, 0x6000, 0x2000, 0xc000, 0x0000, /* Character 1080 (0x438): width 5 +-----+ | | | | |* * | |* ** | |** * | |* * | | | +-----+ */ 0x0000, 0x0000, 0x9000, 0xb000, 0xd000, 0x9000, 0x0000, /* Character 1081 (0x439): width 5 +-----+ |* * | | ** | |* * | |* ** | |** * | |* * | | | +-----+ */ 0x9000, 0x6000, 0x9000, 0xb000, 0xd000, 0x9000, 0x0000, /* Character 1082 (0x43a): width 5 +-----+ | | | | |* * | |*** | |* * | |* * | | | +-----+ */ 0x0000, 0x0000, 0x9000, 0xe000, 0xa000, 0x9000, 0x0000, /* Character 1083 (0x43b): width 5 +-----+ | | | | | ** | | * * | | * * | |* * | | | +-----+ */ 0x0000, 0x0000, 0x3000, 0x5000, 0x5000, 0x9000, 0x0000, /* Character 1084 (0x43c): width 5 +-----+ | | | | |* *| |** **| |* * *| |* * *| | | +-----+ */ 0x0000, 0x0000, 0x8800, 0xd800, 0xa800, 0xa800, 0x0000, /* Character 1085 (0x43d): width 5 +-----+ | | | | |* * | |**** | |* * | |* * | | | +-----+ */ 0x0000, 0x0000, 0x9000, 0xf000, 0x9000, 0x9000, 0x0000, /* Character 1086 (0x43e): width 5 +-----+ | | | | | ** | |* * | |* * | | ** | | | +-----+ */ 0x0000, 0x0000, 0x6000, 0x9000, 0x9000, 0x6000, 0x0000, /* Character 1087 (0x43f): width 5 +-----+ | | | | |**** | |* * | |* * | |* * | | | +-----+ */ 0x0000, 0x0000, 0xf000, 0x9000, 0x9000, 0x9000, 0x0000, /* Character 1088 (0x440): width 5 +-----+ | | | | |*** | |* * | |* * | |*** | |* | +-----+ */ 0x0000, 0x0000, 0xe000, 0x9000, 0x9000, 0xe000, 0x8000, /* Character 1089 (0x441): width 5 +-----+ | | | | | ** | |* | |* | | ** | | | +-----+ */ 0x0000, 0x0000, 0x6000, 0x8000, 0x8000, 0x6000, 0x0000, /* Character 1090 (0x442): width 5 +-----+ | | | | |*** | | * | | * | | * | | | +-----+ */ 0x0000, 0x0000, 0xe000, 0x4000, 0x4000, 0x4000, 0x0000, /* Character 1091 (0x443): width 5 +-----+ | | | | |* * | |* * | | * * | | * | | * | +-----+ */ 0x0000, 0x0000, 0x9000, 0x9000, 0x5000, 0x2000, 0x4000, /* Character 1092 (0x444): width 5 +-----+ | ** | | * | | * | | *** | | * * | | *** | | * | +-----+ */ 0x6000, 0x2000, 0x2000, 0x7000, 0x5000, 0x7000, 0x2000, /* Character 1093 (0x445): width 5 +-----+ | | | | |* * | | ** | | ** | |* * | | | +-----+ */ 0x0000, 0x0000, 0x9000, 0x6000, 0x6000, 0x9000, 0x0000, /* Character 1094 (0x446): width 5 +-----+ | | | | |* * | |* * | |* * | |**** | | * | +-----+ */ 0x0000, 0x0000, 0x9000, 0x9000, 0x9000, 0xf000, 0x1000, /* Character 1095 (0x447): width 5 +-----+ | | | | |* * | |* * | | *** | | * | | | +-----+ */ 0x0000, 0x0000, 0x9000, 0x9000, 0x7000, 0x1000, 0x0000, /* Character 1096 (0x448): width 5 +-----+ | | | | |* * *| |* * *| |* * *| |*****| | | +-----+ */ 0x0000, 0x0000, 0xa800, 0xa800, 0xa800, 0xf800, 0x0000, /* Character 1097 (0x449): width 5 +-----+ | | | | |* * *| |* * *| |* * *| |*****| | *| +-----+ */ 0x0000, 0x0000, 0xa800, 0xa800, 0xa800, 0xf800, 0x0800, /* Character 1098 (0x44a): width 5 +-----+ | | | | |** | | ** | | * * | | ** | | | +-----+ */ 0x0000, 0x0000, 0xc000, 0x6000, 0x5000, 0x6000, 0x0000, /* Character 1099 (0x44b): width 5 +-----+ | | | | |* * | |** * | |* ** | |** * | | | +-----+ */ 0x0000, 0x0000, 0x9000, 0xd000, 0xb000, 0xd000, 0x0000, /* Character 1100 (0x44c): width 5 +-----+ | | | | |* | |*** | |* * | |*** | | | +-----+ */ 0x0000, 0x0000, 0x8000, 0xe000, 0x9000, 0xe000, 0x0000, /* Character 1101 (0x44d): width 5 +-----+ | | | | | ** | | ** | | * | | ** | | | +-----+ */ 0x0000, 0x0000, 0x6000, 0x3000, 0x1000, 0x6000, 0x0000, /* Character 1102 (0x44e): width 5 +-----+ | | | | |* * | |** * | |** * | |* * | | | +-----+ */ 0x0000, 0x0000, 0xa000, 0xd000, 0xd000, 0xa000, 0x0000, /* Character 1103 (0x44f): width 5 +-----+ | | | | | ** | |* * | | ** | |* * | | | +-----+ */ 0x0000, 0x0000, 0x6000, 0xa000, 0x6000, 0xa000, 0x0000, }; /* Character->glyph mapping. */ static const unsigned short _5x7_offset[] = { 0, /* (0x00) */ 0, /* (0x01) */ 0, /* (0x02) */ 0, /* (0x03) */ 0, /* (0x04) */ 0, /* (0x05) */ 0, /* (0x06) */ 0, /* (0x07) */ 0, /* (0x08) */ 0, /* (0x09) */ 0, /* (0x0a) */ 0, /* (0x0b) */ 0, /* (0x0c) */ 0, /* (0x0d) */ 0, /* (0x0e) */ 0, /* (0x0f) */ 0, /* (0x10) */ 0, /* (0x11) */ 0, /* (0x12) */ 0, /* (0x13) */ 0, /* (0x14) */ 0, /* (0x15) */ 0, /* (0x16) */ 0, /* (0x17) */ 0, /* (0x18) */ 0, /* (0x19) */ 0, /* (0x1a) */ 0, /* (0x1b) */ 0, /* (0x1c) */ 0, /* (0x1d) */ 0, /* (0x1e) */ 0, /* (0x1f) */ 7, /* (0x20) */ 14, /* (0x21) */ 21, /* (0x22) */ 28, /* (0x23) */ 35, /* (0x24) */ 42, /* (0x25) */ 49, /* (0x26) */ 56, /* (0x27) */ 63, /* (0x28) */ 70, /* (0x29) */ 77, /* (0x2a) */ 84, /* (0x2b) */ 91, /* (0x2c) */ 98, /* (0x2d) */ 105, /* (0x2e) */ 112, /* (0x2f) */ 119, /* (0x30) */ 126, /* (0x31) */ 133, /* (0x32) */ 140, /* (0x33) */ 147, /* (0x34) */ 154, /* (0x35) */ 161, /* (0x36) */ 168, /* (0x37) */ 175, /* (0x38) */ 182, /* (0x39) */ 189, /* (0x3a) */ 196, /* (0x3b) */ 203, /* (0x3c) */ 210, /* (0x3d) */ 217, /* (0x3e) */ 224, /* (0x3f) */ 231, /* (0x40) */ 238, /* (0x41) */ 245, /* (0x42) */ 252, /* (0x43) */ 259, /* (0x44) */ 266, /* (0x45) */ 273, /* (0x46) */ 280, /* (0x47) */ 287, /* (0x48) */ 294, /* (0x49) */ 301, /* (0x4a) */ 308, /* (0x4b) */ 315, /* (0x4c) */ 322, /* (0x4d) */ 329, /* (0x4e) */ 336, /* (0x4f) */ 343, /* (0x50) */ 350, /* (0x51) */ 357, /* (0x52) */ 364, /* (0x53) */ 371, /* (0x54) */ 378, /* (0x55) */ 385, /* (0x56) */ 392, /* (0x57) */ 399, /* (0x58) */ 406, /* (0x59) */ 413, /* (0x5a) */ 420, /* (0x5b) */ 427, /* (0x5c) */ 434, /* (0x5d) */ 441, /* (0x5e) */ 448, /* (0x5f) */ 455, /* (0x60) */ 462, /* (0x61) */ 469, /* (0x62) */ 476, /* (0x63) */ 483, /* (0x64) */ 490, /* (0x65) */ 497, /* (0x66) */ 504, /* (0x67) */ 511, /* (0x68) */ 518, /* (0x69) */ 525, /* (0x6a) */ 532, /* (0x6b) */ 539, /* (0x6c) */ 546, /* (0x6d) */ 553, /* (0x6e) */ 560, /* (0x6f) */ 567, /* (0x70) */ 574, /* (0x71) */ 581, /* (0x72) */ 588, /* (0x73) */ 595, /* (0x74) */ 602, /* (0x75) */ 609, /* (0x76) */ 616, /* (0x77) */ 623, /* (0x78) */ 630, /* (0x79) */ 637, /* (0x7a) */ 644, /* (0x7b) */ 651, /* (0x7c) */ 658, /* (0x7d) */ 665, /* (0x7e) */ 0, /* (0x7f) */ 0, /* (0x80) */ 0, /* (0x81) */ 0, /* (0x82) */ 0, /* (0x83) */ 0, /* (0x84) */ 0, /* (0x85) */ 0, /* (0x86) */ 0, /* (0x87) */ 0, /* (0x88) */ 0, /* (0x89) */ 0, /* (0x8a) */ 0, /* (0x8b) */ 0, /* (0x8c) */ 0, /* (0x8d) */ 0, /* (0x8e) */ 0, /* (0x8f) */ 0, /* (0x90) */ 0, /* (0x91) */ 0, /* (0x92) */ 0, /* (0x93) */ 0, /* (0x94) */ 0, /* (0x95) */ 0, /* (0x96) */ 0, /* (0x97) */ 0, /* (0x98) */ 0, /* (0x99) */ 0, /* (0x9a) */ 0, /* (0x9b) */ 0, /* (0x9c) */ 0, /* (0x9d) */ 0, /* (0x9e) */ 0, /* (0x9f) */ 0, /* (0xa0) */ 0, /* (0xa1) */ 0, /* (0xa2) */ 0, /* (0xa3) */ 0, /* (0xa4) */ 0, /* (0xa5) */ 0, /* (0xa6) */ 0, /* (0xa7) */ 0, /* (0xa8) */ 0, /* (0xa9) */ 0, /* (0xaa) */ 0, /* (0xab) */ 0, /* (0xac) */ 0, /* (0xad) */ 0, /* (0xae) */ 0, /* (0xaf) */ 0, /* (0xb0) */ 0, /* (0xb1) */ 0, /* (0xb2) */ 0, /* (0xb3) */ 0, /* (0xb4) */ 0, /* (0xb5) */ 0, /* (0xb6) */ 0, /* (0xb7) */ 0, /* (0xb8) */ 0, /* (0xb9) */ 0, /* (0xba) */ 0, /* (0xbb) */ 0, /* (0xbc) */ 0, /* (0xbd) */ 0, /* (0xbe) */ 0, /* (0xbf) */ 0, /* (0xc0) */ 0, /* (0xc1) */ 0, /* (0xc2) */ 0, /* (0xc3) */ 0, /* (0xc4) */ 0, /* (0xc5) */ 0, /* (0xc6) */ 0, /* (0xc7) */ 0, /* (0xc8) */ 0, /* (0xc9) */ 0, /* (0xca) */ 0, /* (0xcb) */ 0, /* (0xcc) */ 0, /* (0xcd) */ 0, /* (0xce) */ 0, /* (0xcf) */ 0, /* (0xd0) */ 0, /* (0xd1) */ 0, /* (0xd2) */ 0, /* (0xd3) */ 0, /* (0xd4) */ 0, /* (0xd5) */ 0, /* (0xd6) */ 0, /* (0xd7) */ 0, /* (0xd8) */ 0, /* (0xd9) */ 0, /* (0xda) */ 0, /* (0xdb) */ 0, /* (0xdc) */ 0, /* (0xdd) */ 0, /* (0xde) */ 0, /* (0xdf) */ 0, /* (0xe0) */ 0, /* (0xe1) */ 0, /* (0xe2) */ 0, /* (0xe3) */ 0, /* (0xe4) */ 0, /* (0xe5) */ 0, /* (0xe6) */ 0, /* (0xe7) */ 0, /* (0xe8) */ 0, /* (0xe9) */ 0, /* (0xea) */ 0, /* (0xeb) */ 0, /* (0xec) */ 0, /* (0xed) */ 0, /* (0xee) */ 0, /* (0xef) */ 0, /* (0xf0) */ 0, /* (0xf1) */ 0, /* (0xf2) */ 0, /* (0xf3) */ 0, /* (0xf4) */ 0, /* (0xf5) */ 0, /* (0xf6) */ 0, /* (0xf7) */ 0, /* (0xf8) */ 0, /* (0xf9) */ 0, /* (0xfa) */ 0, /* (0xfb) */ 0, /* (0xfc) */ 0, /* (0xfd) */ 0, /* (0xfe) */ 0, /* (0xff) */ 0, /* (0x100) */ 0, /* (0x101) */ 0, /* (0x102) */ 0, /* (0x103) */ 0, /* (0x104) */ 0, /* (0x105) */ 0, /* (0x106) */ 0, /* (0x107) */ 0, /* (0x108) */ 0, /* (0x109) */ 0, /* (0x10a) */ 0, /* (0x10b) */ 0, /* (0x10c) */ 0, /* (0x10d) */ 0, /* (0x10e) */ 0, /* (0x10f) */ 0, /* (0x110) */ 0, /* (0x111) */ 0, /* (0x112) */ 0, /* (0x113) */ 0, /* (0x114) */ 0, /* (0x115) */ 0, /* (0x116) */ 0, /* (0x117) */ 0, /* (0x118) */ 0, /* (0x119) */ 0, /* (0x11a) */ 0, /* (0x11b) */ 0, /* (0x11c) */ 0, /* (0x11d) */ 0, /* (0x11e) */ 0, /* (0x11f) */ 0, /* (0x120) */ 0, /* (0x121) */ 0, /* (0x122) */ 0, /* (0x123) */ 0, /* (0x124) */ 0, /* (0x125) */ 0, /* (0x126) */ 0, /* (0x127) */ 0, /* (0x128) */ 0, /* (0x129) */ 0, /* (0x12a) */ 0, /* (0x12b) */ 0, /* (0x12c) */ 0, /* (0x12d) */ 0, /* (0x12e) */ 0, /* (0x12f) */ 0, /* (0x130) */ 0, /* (0x131) */ 0, /* (0x132) */ 0, /* (0x133) */ 0, /* (0x134) */ 0, /* (0x135) */ 0, /* (0x136) */ 0, /* (0x137) */ 0, /* (0x138) */ 0, /* (0x139) */ 0, /* (0x13a) */ 0, /* (0x13b) */ 0, /* (0x13c) */ 0, /* (0x13d) */ 0, /* (0x13e) */ 0, /* (0x13f) */ 0, /* (0x140) */ 0, /* (0x141) */ 0, /* (0x142) */ 0, /* (0x143) */ 0, /* (0x144) */ 0, /* (0x145) */ 0, /* (0x146) */ 0, /* (0x147) */ 0, /* (0x148) */ 0, /* (0x149) */ 0, /* (0x14a) */ 0, /* (0x14b) */ 0, /* (0x14c) */ 0, /* (0x14d) */ 0, /* (0x14e) */ 0, /* (0x14f) */ 0, /* (0x150) */ 0, /* (0x151) */ 0, /* (0x152) */ 0, /* (0x153) */ 0, /* (0x154) */ 0, /* (0x155) */ 0, /* (0x156) */ 0, /* (0x157) */ 0, /* (0x158) */ 0, /* (0x159) */ 0, /* (0x15a) */ 0, /* (0x15b) */ 0, /* (0x15c) */ 0, /* (0x15d) */ 0, /* (0x15e) */ 0, /* (0x15f) */ 0, /* (0x160) */ 0, /* (0x161) */ 0, /* (0x162) */ 0, /* (0x163) */ 0, /* (0x164) */ 0, /* (0x165) */ 0, /* (0x166) */ 0, /* (0x167) */ 0, /* (0x168) */ 0, /* (0x169) */ 0, /* (0x16a) */ 0, /* (0x16b) */ 0, /* (0x16c) */ 0, /* (0x16d) */ 0, /* (0x16e) */ 0, /* (0x16f) */ 0, /* (0x170) */ 0, /* (0x171) */ 0, /* (0x172) */ 0, /* (0x173) */ 0, /* (0x174) */ 0, /* (0x175) */ 0, /* (0x176) */ 0, /* (0x177) */ 0, /* (0x178) */ 0, /* (0x179) */ 0, /* (0x17a) */ 0, /* (0x17b) */ 0, /* (0x17c) */ 0, /* (0x17d) */ 0, /* (0x17e) */ 0, /* (0x17f) */ 0, /* (0x180) */ 0, /* (0x181) */ 0, /* (0x182) */ 0, /* (0x183) */ 0, /* (0x184) */ 0, /* (0x185) */ 0, /* (0x186) */ 0, /* (0x187) */ 0, /* (0x188) */ 0, /* (0x189) */ 0, /* (0x18a) */ 0, /* (0x18b) */ 0, /* (0x18c) */ 0, /* (0x18d) */ 0, /* (0x18e) */ 0, /* (0x18f) */ 0, /* (0x190) */ 0, /* (0x191) */ 0, /* (0x192) */ 0, /* (0x193) */ 0, /* (0x194) */ 0, /* (0x195) */ 0, /* (0x196) */ 0, /* (0x197) */ 0, /* (0x198) */ 0, /* (0x199) */ 0, /* (0x19a) */ 0, /* (0x19b) */ 0, /* (0x19c) */ 0, /* (0x19d) */ 0, /* (0x19e) */ 0, /* (0x19f) */ 0, /* (0x1a0) */ 0, /* (0x1a1) */ 0, /* (0x1a2) */ 0, /* (0x1a3) */ 0, /* (0x1a4) */ 0, /* (0x1a5) */ 0, /* (0x1a6) */ 0, /* (0x1a7) */ 0, /* (0x1a8) */ 0, /* (0x1a9) */ 0, /* (0x1aa) */ 0, /* (0x1ab) */ 0, /* (0x1ac) */ 0, /* (0x1ad) */ 0, /* (0x1ae) */ 0, /* (0x1af) */ 0, /* (0x1b0) */ 0, /* (0x1b1) */ 0, /* (0x1b2) */ 0, /* (0x1b3) */ 0, /* (0x1b4) */ 0, /* (0x1b5) */ 0, /* (0x1b6) */ 0, /* (0x1b7) */ 0, /* (0x1b8) */ 0, /* (0x1b9) */ 0, /* (0x1ba) */ 0, /* (0x1bb) */ 0, /* (0x1bc) */ 0, /* (0x1bd) */ 0, /* (0x1be) */ 0, /* (0x1bf) */ 0, /* (0x1c0) */ 0, /* (0x1c1) */ 0, /* (0x1c2) */ 0, /* (0x1c3) */ 0, /* (0x1c4) */ 0, /* (0x1c5) */ 0, /* (0x1c6) */ 0, /* (0x1c7) */ 0, /* (0x1c8) */ 0, /* (0x1c9) */ 0, /* (0x1ca) */ 0, /* (0x1cb) */ 0, /* (0x1cc) */ 0, /* (0x1cd) */ 0, /* (0x1ce) */ 0, /* (0x1cf) */ 0, /* (0x1d0) */ 0, /* (0x1d1) */ 0, /* (0x1d2) */ 0, /* (0x1d3) */ 0, /* (0x1d4) */ 0, /* (0x1d5) */ 0, /* (0x1d6) */ 0, /* (0x1d7) */ 0, /* (0x1d8) */ 0, /* (0x1d9) */ 0, /* (0x1da) */ 0, /* (0x1db) */ 0, /* (0x1dc) */ 0, /* (0x1dd) */ 0, /* (0x1de) */ 0, /* (0x1df) */ 0, /* (0x1e0) */ 0, /* (0x1e1) */ 0, /* (0x1e2) */ 0, /* (0x1e3) */ 0, /* (0x1e4) */ 0, /* (0x1e5) */ 0, /* (0x1e6) */ 0, /* (0x1e7) */ 0, /* (0x1e8) */ 0, /* (0x1e9) */ 0, /* (0x1ea) */ 0, /* (0x1eb) */ 0, /* (0x1ec) */ 0, /* (0x1ed) */ 0, /* (0x1ee) */ 0, /* (0x1ef) */ 0, /* (0x1f0) */ 0, /* (0x1f1) */ 0, /* (0x1f2) */ 0, /* (0x1f3) */ 0, /* (0x1f4) */ 0, /* (0x1f5) */ 0, /* (0x1f6) */ 0, /* (0x1f7) */ 0, /* (0x1f8) */ 0, /* (0x1f9) */ 0, /* (0x1fa) */ 0, /* (0x1fb) */ 0, /* (0x1fc) */ 0, /* (0x1fd) */ 0, /* (0x1fe) */ 0, /* (0x1ff) */ 0, /* (0x200) */ 0, /* (0x201) */ 0, /* (0x202) */ 0, /* (0x203) */ 0, /* (0x204) */ 0, /* (0x205) */ 0, /* (0x206) */ 0, /* (0x207) */ 0, /* (0x208) */ 0, /* (0x209) */ 0, /* (0x20a) */ 0, /* (0x20b) */ 0, /* (0x20c) */ 0, /* (0x20d) */ 0, /* (0x20e) */ 0, /* (0x20f) */ 0, /* (0x210) */ 0, /* (0x211) */ 0, /* (0x212) */ 0, /* (0x213) */ 0, /* (0x214) */ 0, /* (0x215) */ 0, /* (0x216) */ 0, /* (0x217) */ 0, /* (0x218) */ 0, /* (0x219) */ 0, /* (0x21a) */ 0, /* (0x21b) */ 0, /* (0x21c) */ 0, /* (0x21d) */ 0, /* (0x21e) */ 0, /* (0x21f) */ 0, /* (0x220) */ 0, /* (0x221) */ 0, /* (0x222) */ 0, /* (0x223) */ 0, /* (0x224) */ 0, /* (0x225) */ 0, /* (0x226) */ 0, /* (0x227) */ 0, /* (0x228) */ 0, /* (0x229) */ 0, /* (0x22a) */ 0, /* (0x22b) */ 0, /* (0x22c) */ 0, /* (0x22d) */ 0, /* (0x22e) */ 0, /* (0x22f) */ 0, /* (0x230) */ 0, /* (0x231) */ 0, /* (0x232) */ 0, /* (0x233) */ 0, /* (0x234) */ 0, /* (0x235) */ 0, /* (0x236) */ 0, /* (0x237) */ 0, /* (0x238) */ 0, /* (0x239) */ 0, /* (0x23a) */ 0, /* (0x23b) */ 0, /* (0x23c) */ 0, /* (0x23d) */ 0, /* (0x23e) */ 0, /* (0x23f) */ 0, /* (0x240) */ 0, /* (0x241) */ 0, /* (0x242) */ 0, /* (0x243) */ 0, /* (0x244) */ 0, /* (0x245) */ 0, /* (0x246) */ 0, /* (0x247) */ 0, /* (0x248) */ 0, /* (0x249) */ 0, /* (0x24a) */ 0, /* (0x24b) */ 0, /* (0x24c) */ 0, /* (0x24d) */ 0, /* (0x24e) */ 0, /* (0x24f) */ 0, /* (0x250) */ 0, /* (0x251) */ 0, /* (0x252) */ 0, /* (0x253) */ 0, /* (0x254) */ 0, /* (0x255) */ 0, /* (0x256) */ 0, /* (0x257) */ 0, /* (0x258) */ 0, /* (0x259) */ 0, /* (0x25a) */ 0, /* (0x25b) */ 0, /* (0x25c) */ 0, /* (0x25d) */ 0, /* (0x25e) */ 0, /* (0x25f) */ 0, /* (0x260) */ 0, /* (0x261) */ 0, /* (0x262) */ 0, /* (0x263) */ 0, /* (0x264) */ 0, /* (0x265) */ 0, /* (0x266) */ 0, /* (0x267) */ 0, /* (0x268) */ 0, /* (0x269) */ 0, /* (0x26a) */ 0, /* (0x26b) */ 0, /* (0x26c) */ 0, /* (0x26d) */ 0, /* (0x26e) */ 0, /* (0x26f) */ 0, /* (0x270) */ 0, /* (0x271) */ 0, /* (0x272) */ 0, /* (0x273) */ 0, /* (0x274) */ 0, /* (0x275) */ 0, /* (0x276) */ 0, /* (0x277) */ 0, /* (0x278) */ 0, /* (0x279) */ 0, /* (0x27a) */ 0, /* (0x27b) */ 0, /* (0x27c) */ 0, /* (0x27d) */ 0, /* (0x27e) */ 0, /* (0x27f) */ 0, /* (0x280) */ 0, /* (0x281) */ 0, /* (0x282) */ 0, /* (0x283) */ 0, /* (0x284) */ 0, /* (0x285) */ 0, /* (0x286) */ 0, /* (0x287) */ 0, /* (0x288) */ 0, /* (0x289) */ 0, /* (0x28a) */ 0, /* (0x28b) */ 0, /* (0x28c) */ 0, /* (0x28d) */ 0, /* (0x28e) */ 0, /* (0x28f) */ 0, /* (0x290) */ 0, /* (0x291) */ 0, /* (0x292) */ 0, /* (0x293) */ 0, /* (0x294) */ 0, /* (0x295) */ 0, /* (0x296) */ 0, /* (0x297) */ 0, /* (0x298) */ 0, /* (0x299) */ 0, /* (0x29a) */ 0, /* (0x29b) */ 0, /* (0x29c) */ 0, /* (0x29d) */ 0, /* (0x29e) */ 0, /* (0x29f) */ 0, /* (0x2a0) */ 0, /* (0x2a1) */ 0, /* (0x2a2) */ 0, /* (0x2a3) */ 0, /* (0x2a4) */ 0, /* (0x2a5) */ 0, /* (0x2a6) */ 0, /* (0x2a7) */ 0, /* (0x2a8) */ 0, /* (0x2a9) */ 0, /* (0x2aa) */ 0, /* (0x2ab) */ 0, /* (0x2ac) */ 0, /* (0x2ad) */ 0, /* (0x2ae) */ 0, /* (0x2af) */ 0, /* (0x2b0) */ 0, /* (0x2b1) */ 0, /* (0x2b2) */ 0, /* (0x2b3) */ 0, /* (0x2b4) */ 0, /* (0x2b5) */ 0, /* (0x2b6) */ 0, /* (0x2b7) */ 0, /* (0x2b8) */ 0, /* (0x2b9) */ 0, /* (0x2ba) */ 0, /* (0x2bb) */ 0, /* (0x2bc) */ 0, /* (0x2bd) */ 0, /* (0x2be) */ 0, /* (0x2bf) */ 0, /* (0x2c0) */ 0, /* (0x2c1) */ 0, /* (0x2c2) */ 0, /* (0x2c3) */ 0, /* (0x2c4) */ 0, /* (0x2c5) */ 0, /* (0x2c6) */ 0, /* (0x2c7) */ 0, /* (0x2c8) */ 0, /* (0x2c9) */ 0, /* (0x2ca) */ 0, /* (0x2cb) */ 0, /* (0x2cc) */ 0, /* (0x2cd) */ 0, /* (0x2ce) */ 0, /* (0x2cf) */ 0, /* (0x2d0) */ 0, /* (0x2d1) */ 0, /* (0x2d2) */ 0, /* (0x2d3) */ 0, /* (0x2d4) */ 0, /* (0x2d5) */ 0, /* (0x2d6) */ 0, /* (0x2d7) */ 0, /* (0x2d8) */ 0, /* (0x2d9) */ 0, /* (0x2da) */ 0, /* (0x2db) */ 0, /* (0x2dc) */ 0, /* (0x2dd) */ 0, /* (0x2de) */ 0, /* (0x2df) */ 0, /* (0x2e0) */ 0, /* (0x2e1) */ 0, /* (0x2e2) */ 0, /* (0x2e3) */ 0, /* (0x2e4) */ 0, /* (0x2e5) */ 0, /* (0x2e6) */ 0, /* (0x2e7) */ 0, /* (0x2e8) */ 0, /* (0x2e9) */ 0, /* (0x2ea) */ 0, /* (0x2eb) */ 0, /* (0x2ec) */ 0, /* (0x2ed) */ 0, /* (0x2ee) */ 0, /* (0x2ef) */ 0, /* (0x2f0) */ 0, /* (0x2f1) */ 0, /* (0x2f2) */ 0, /* (0x2f3) */ 0, /* (0x2f4) */ 0, /* (0x2f5) */ 0, /* (0x2f6) */ 0, /* (0x2f7) */ 0, /* (0x2f8) */ 0, /* (0x2f9) */ 0, /* (0x2fa) */ 0, /* (0x2fb) */ 0, /* (0x2fc) */ 0, /* (0x2fd) */ 0, /* (0x2fe) */ 0, /* (0x2ff) */ 0, /* (0x300) */ 0, /* (0x301) */ 0, /* (0x302) */ 0, /* (0x303) */ 0, /* (0x304) */ 0, /* (0x305) */ 0, /* (0x306) */ 0, /* (0x307) */ 0, /* (0x308) */ 0, /* (0x309) */ 0, /* (0x30a) */ 0, /* (0x30b) */ 0, /* (0x30c) */ 0, /* (0x30d) */ 0, /* (0x30e) */ 0, /* (0x30f) */ 0, /* (0x310) */ 0, /* (0x311) */ 0, /* (0x312) */ 0, /* (0x313) */ 0, /* (0x314) */ 0, /* (0x315) */ 0, /* (0x316) */ 0, /* (0x317) */ 0, /* (0x318) */ 0, /* (0x319) */ 0, /* (0x31a) */ 0, /* (0x31b) */ 0, /* (0x31c) */ 0, /* (0x31d) */ 0, /* (0x31e) */ 0, /* (0x31f) */ 0, /* (0x320) */ 0, /* (0x321) */ 0, /* (0x322) */ 0, /* (0x323) */ 0, /* (0x324) */ 0, /* (0x325) */ 0, /* (0x326) */ 0, /* (0x327) */ 0, /* (0x328) */ 0, /* (0x329) */ 0, /* (0x32a) */ 0, /* (0x32b) */ 0, /* (0x32c) */ 0, /* (0x32d) */ 0, /* (0x32e) */ 0, /* (0x32f) */ 0, /* (0x330) */ 0, /* (0x331) */ 0, /* (0x332) */ 0, /* (0x333) */ 0, /* (0x334) */ 0, /* (0x335) */ 0, /* (0x336) */ 0, /* (0x337) */ 0, /* (0x338) */ 0, /* (0x339) */ 0, /* (0x33a) */ 0, /* (0x33b) */ 0, /* (0x33c) */ 0, /* (0x33d) */ 0, /* (0x33e) */ 0, /* (0x33f) */ 0, /* (0x340) */ 0, /* (0x341) */ 0, /* (0x342) */ 0, /* (0x343) */ 0, /* (0x344) */ 0, /* (0x345) */ 0, /* (0x346) */ 0, /* (0x347) */ 0, /* (0x348) */ 0, /* (0x349) */ 0, /* (0x34a) */ 0, /* (0x34b) */ 0, /* (0x34c) */ 0, /* (0x34d) */ 0, /* (0x34e) */ 0, /* (0x34f) */ 0, /* (0x350) */ 0, /* (0x351) */ 0, /* (0x352) */ 0, /* (0x353) */ 0, /* (0x354) */ 0, /* (0x355) */ 0, /* (0x356) */ 0, /* (0x357) */ 0, /* (0x358) */ 0, /* (0x359) */ 0, /* (0x35a) */ 0, /* (0x35b) */ 0, /* (0x35c) */ 0, /* (0x35d) */ 0, /* (0x35e) */ 0, /* (0x35f) */ 0, /* (0x360) */ 0, /* (0x361) */ 0, /* (0x362) */ 0, /* (0x363) */ 0, /* (0x364) */ 0, /* (0x365) */ 0, /* (0x366) */ 0, /* (0x367) */ 0, /* (0x368) */ 0, /* (0x369) */ 0, /* (0x36a) */ 0, /* (0x36b) */ 0, /* (0x36c) */ 0, /* (0x36d) */ 0, /* (0x36e) */ 0, /* (0x36f) */ 0, /* (0x370) */ 0, /* (0x371) */ 0, /* (0x372) */ 0, /* (0x373) */ 0, /* (0x374) */ 0, /* (0x375) */ 0, /* (0x376) */ 0, /* (0x377) */ 0, /* (0x378) */ 0, /* (0x379) */ 0, /* (0x37a) */ 0, /* (0x37b) */ 0, /* (0x37c) */ 0, /* (0x37d) */ 0, /* (0x37e) */ 0, /* (0x37f) */ 0, /* (0x380) */ 0, /* (0x381) */ 0, /* (0x382) */ 0, /* (0x383) */ 0, /* (0x384) */ 0, /* (0x385) */ 0, /* (0x386) */ 0, /* (0x387) */ 0, /* (0x388) */ 0, /* (0x389) */ 0, /* (0x38a) */ 0, /* (0x38b) */ 0, /* (0x38c) */ 0, /* (0x38d) */ 0, /* (0x38e) */ 0, /* (0x38f) */ 0, /* (0x390) */ 0, /* (0x391) */ 0, /* (0x392) */ 0, /* (0x393) */ 0, /* (0x394) */ 0, /* (0x395) */ 0, /* (0x396) */ 0, /* (0x397) */ 0, /* (0x398) */ 0, /* (0x399) */ 0, /* (0x39a) */ 0, /* (0x39b) */ 0, /* (0x39c) */ 0, /* (0x39d) */ 0, /* (0x39e) */ 0, /* (0x39f) */ 0, /* (0x3a0) */ 0, /* (0x3a1) */ 0, /* (0x3a2) */ 0, /* (0x3a3) */ 0, /* (0x3a4) */ 0, /* (0x3a5) */ 0, /* (0x3a6) */ 0, /* (0x3a7) */ 0, /* (0x3a8) */ 0, /* (0x3a9) */ 0, /* (0x3aa) */ 0, /* (0x3ab) */ 0, /* (0x3ac) */ 0, /* (0x3ad) */ 0, /* (0x3ae) */ 0, /* (0x3af) */ 0, /* (0x3b0) */ 0, /* (0x3b1) */ 0, /* (0x3b2) */ 0, /* (0x3b3) */ 0, /* (0x3b4) */ 0, /* (0x3b5) */ 0, /* (0x3b6) */ 0, /* (0x3b7) */ 0, /* (0x3b8) */ 0, /* (0x3b9) */ 0, /* (0x3ba) */ 0, /* (0x3bb) */ 0, /* (0x3bc) */ 0, /* (0x3bd) */ 0, /* (0x3be) */ 0, /* (0x3bf) */ 0, /* (0x3c0) */ 0, /* (0x3c1) */ 0, /* (0x3c2) */ 0, /* (0x3c3) */ 0, /* (0x3c4) */ 0, /* (0x3c5) */ 0, /* (0x3c6) */ 0, /* (0x3c7) */ 0, /* (0x3c8) */ 0, /* (0x3c9) */ 0, /* (0x3ca) */ 0, /* (0x3cb) */ 0, /* (0x3cc) */ 0, /* (0x3cd) */ 0, /* (0x3ce) */ 0, /* (0x3cf) */ 0, /* (0x3d0) */ 0, /* (0x3d1) */ 0, /* (0x3d2) */ 0, /* (0x3d3) */ 0, /* (0x3d4) */ 0, /* (0x3d5) */ 0, /* (0x3d6) */ 0, /* (0x3d7) */ 0, /* (0x3d8) */ 0, /* (0x3d9) */ 0, /* (0x3da) */ 0, /* (0x3db) */ 0, /* (0x3dc) */ 0, /* (0x3dd) */ 0, /* (0x3de) */ 0, /* (0x3df) */ 0, /* (0x3e0) */ 0, /* (0x3e1) */ 0, /* (0x3e2) */ 0, /* (0x3e3) */ 0, /* (0x3e4) */ 0, /* (0x3e5) */ 0, /* (0x3e6) */ 0, /* (0x3e7) */ 0, /* (0x3e8) */ 0, /* (0x3e9) */ 0, /* (0x3ea) */ 0, /* (0x3eb) */ 0, /* (0x3ec) */ 0, /* (0x3ed) */ 0, /* (0x3ee) */ 0, /* (0x3ef) */ 0, /* (0x3f0) */ 0, /* (0x3f1) */ 0, /* (0x3f2) */ 0, /* (0x3f3) */ 0, /* (0x3f4) */ 0, /* (0x3f5) */ 0, /* (0x3f6) */ 0, /* (0x3f7) */ 0, /* (0x3f8) */ 0, /* (0x3f9) */ 0, /* (0x3fa) */ 0, /* (0x3fb) */ 0, /* (0x3fc) */ 0, /* (0x3fd) */ 0, /* (0x3fe) */ 0, /* (0x3ff) */ 0, /* (0x400) */ 0, /* (0x401) */ 0, /* (0x402) */ 0, /* (0x403) */ 0, /* (0x404) */ 0, /* (0x405) */ 0, /* (0x406) */ 0, /* (0x407) */ 0, /* (0x408) */ 0, /* (0x409) */ 0, /* (0x40a) */ 0, /* (0x40b) */ 0, /* (0x40c) */ 0, /* (0x40d) */ 0, /* (0x40e) */ 0, /* (0x40f) */ 672, /* (0x410) */ 679, /* (0x411) */ 686, /* (0x412) */ 693, /* (0x413) */ 700, /* (0x414) */ 707, /* (0x415) */ 714, /* (0x416) */ 721, /* (0x417) */ 728, /* (0x418) */ 735, /* (0x419) */ 742, /* (0x41a) */ 749, /* (0x41b) */ 756, /* (0x41c) */ 763, /* (0x41d) */ 770, /* (0x41e) */ 777, /* (0x41f) */ 784, /* (0x420) */ 791, /* (0x421) */ 798, /* (0x422) */ 805, /* (0x423) */ 812, /* (0x424) */ 819, /* (0x425) */ 826, /* (0x426) */ 833, /* (0x427) */ 840, /* (0x428) */ 847, /* (0x429) */ 854, /* (0x42a) */ 861, /* (0x42b) */ 868, /* (0x42c) */ 875, /* (0x42d) */ 882, /* (0x42e) */ 889, /* (0x42f) */ 896, /* (0x430) */ 903, /* (0x431) */ 910, /* (0x432) */ 917, /* (0x433) */ 924, /* (0x434) */ 931, /* (0x435) */ 938, /* (0x436) */ 945, /* (0x437) */ 952, /* (0x438) */ 959, /* (0x439) */ 966, /* (0x43a) */ 973, /* (0x43b) */ 980, /* (0x43c) */ 987, /* (0x43d) */ 994, /* (0x43e) */ 1001, /* (0x43f) */ 1008, /* (0x440) */ 1015, /* (0x441) */ 1022, /* (0x442) */ 1029, /* (0x443) */ 1036, /* (0x444) */ 1043, /* (0x445) */ 1050, /* (0x446) */ 1057, /* (0x447) */ 1064, /* (0x448) */ 1071, /* (0x449) */ 1078, /* (0x44a) */ 1085, /* (0x44b) */ 1092, /* (0x44c) */ 1099, /* (0x44d) */ 1106, /* (0x44e) */ 1113, /* (0x44f) */ }; /* Exported structure definition. */ const struct gpanel_font_t font_5x7 = { "5x7", 5, 7, 6, 0, 1104, _5x7_bits, _5x7_offset, 0, /* fixed width*/ 0, sizeof(_5x7_bits) / sizeof(_5x7_bits[0]), }; ================================================ FILE: share/examples/gpanel/fonts/6x9.c ================================================ /* Generated by convbdf on Thu Oct 8 21:26:35 2015. */ #include /* Font information: name: 6x9 facename: -Misc-Fixed-Medium-R-Normal--9-90-75-75-C-60-ISO10646-1 w x h: 6x9 size: 1104 ascent: 7 descent: 2 first char: 0 (0x00) last char: 1103 (0x44f) default char: 0 (0x00) proportional: no Public domain font. Share and enjoy. */ /* Font character bitmap data. */ static const unsigned short _6x9_bits[] = { /* Character 0 (0x00): width 6 +------+ | | | * * | | * | | * | | * | | * | | * * | | | | | +------+ */ 0x0000, 0x2800, 0x4000, 0x0800, 0x4000, 0x0800, 0x5000, 0x0000, 0x0000, /* Character 32 (0x20): width 6 +------+ | | | | | | | | | | | | | | | | | | +------+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 33 (0x21): width 6 +------+ | | | * | | * | | * | | * | | | | * | | | | | +------+ */ 0x0000, 0x2000, 0x2000, 0x2000, 0x2000, 0x0000, 0x2000, 0x0000, 0x0000, /* Character 34 (0x22): width 6 +------+ | | | * * | | * * | | * * | | | | | | | | | | | +------+ */ 0x0000, 0x5000, 0x5000, 0x5000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 35 (0x23): width 6 +------+ | | | * * | | * * | |***** | | * * | |***** | | * * | | * * | | | +------+ */ 0x0000, 0x5000, 0x5000, 0xf800, 0x5000, 0xf800, 0x5000, 0x5000, 0x0000, /* Character 36 (0x24): width 6 +------+ | * | | *** | |* * * | |* * | | *** | | * * | |* * * | | *** | | * | +------+ */ 0x2000, 0x7000, 0xa800, 0xa000, 0x7000, 0x2800, 0xa800, 0x7000, 0x2000, /* Character 37 (0x25): width 6 +------+ | * | |* * * | | * * | | * | | * | | * * | | * * *| | * | | | +------+ */ 0x4000, 0xa800, 0x4800, 0x1000, 0x2000, 0x4800, 0x5400, 0x0800, 0x0000, /* Character 38 (0x26): width 6 +------+ | | | ** | |* * | |* * | | ** | |* ** | |* * | | ** * | | | +------+ */ 0x0000, 0x6000, 0x9000, 0x9000, 0x6000, 0x9800, 0x9000, 0x6800, 0x0000, /* Character 39 (0x27): width 6 +------+ | | | * | | * | | * | | | | | | | | | | | +------+ */ 0x0000, 0x2000, 0x2000, 0x2000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 40 (0x28): width 6 +------+ | | | * | | * | | * | | * | | * | | * | | * | | | +------+ */ 0x0000, 0x1000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x1000, 0x0000, /* Character 41 (0x29): width 6 +------+ | | | * | | * | | * | | * | | * | | * | | * | | | +------+ */ 0x0000, 0x2000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x2000, 0x0000, /* Character 42 (0x2a): width 6 +------+ | | | | |* * | | * * | |***** | | * * | |* * | | | | | +------+ */ 0x0000, 0x0000, 0x8800, 0x5000, 0xf800, 0x5000, 0x8800, 0x0000, 0x0000, /* Character 43 (0x2b): width 6 +------+ | | | | | * | | * | |***** | | * | | * | | | | | +------+ */ 0x0000, 0x0000, 0x2000, 0x2000, 0xf800, 0x2000, 0x2000, 0x0000, 0x0000, /* Character 44 (0x2c): width 6 +------+ | | | | | | | | | | | ** | | * | | * | | * | +------+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x3000, 0x1000, 0x1000, 0x2000, /* Character 45 (0x2d): width 6 +------+ | | | | | | | | |***** | | | | | | | | | +------+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0xf800, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 46 (0x2e): width 6 +------+ | | | | | | | | | | | ** | | ** | | | | | +------+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x3000, 0x3000, 0x0000, 0x0000, /* Character 47 (0x2f): width 6 +------+ | | | * | | * | | * | | * | | * | | * | | | | | +------+ */ 0x0000, 0x0800, 0x0800, 0x1000, 0x2000, 0x4000, 0x4000, 0x0000, 0x0000, /* Character 48 (0x30): width 6 +------+ | | | ** | | * * | | * * | | * * | | * * | | ** | | | | | +------+ */ 0x0000, 0x3000, 0x4800, 0x4800, 0x4800, 0x4800, 0x3000, 0x0000, 0x0000, /* Character 49 (0x31): width 6 +------+ | | | * | | ** | | * | | * | | * | | *** | | | | | +------+ */ 0x0000, 0x2000, 0x6000, 0x2000, 0x2000, 0x2000, 0x7000, 0x0000, 0x0000, /* Character 50 (0x32): width 6 +------+ | | | ** | | * * | | * | | * | | * | | **** | | | | | +------+ */ 0x0000, 0x3000, 0x4800, 0x0800, 0x1000, 0x2000, 0x7800, 0x0000, 0x0000, /* Character 51 (0x33): width 6 +------+ | | | **** | | * | | ** | | * | | * | | *** | | | | | +------+ */ 0x0000, 0x7800, 0x1000, 0x3000, 0x0800, 0x0800, 0x7000, 0x0000, 0x0000, /* Character 52 (0x34): width 6 +------+ | | | * | | ** | | * * | |* * | |***** | | * | | | | | +------+ */ 0x0000, 0x1000, 0x3000, 0x5000, 0x9000, 0xf800, 0x1000, 0x0000, 0x0000, /* Character 53 (0x35): width 6 +------+ | | | **** | | * | | *** | | * | | * | | *** | | | | | +------+ */ 0x0000, 0x7800, 0x4000, 0x7000, 0x0800, 0x0800, 0x7000, 0x0000, 0x0000, /* Character 54 (0x36): width 6 +------+ | | | ** | | * | | *** | | * * | | * * | | ** | | | | | +------+ */ 0x0000, 0x3000, 0x4000, 0x7000, 0x4800, 0x4800, 0x3000, 0x0000, 0x0000, /* Character 55 (0x37): width 6 +------+ | | | **** | | * | | * | | * | | * | | * | | | | | +------+ */ 0x0000, 0x7800, 0x0800, 0x0800, 0x1000, 0x2000, 0x2000, 0x0000, 0x0000, /* Character 56 (0x38): width 6 +------+ | | | ** | | * * | | ** | | * * | | * * | | ** | | | | | +------+ */ 0x0000, 0x3000, 0x4800, 0x3000, 0x4800, 0x4800, 0x3000, 0x0000, 0x0000, /* Character 57 (0x39): width 6 +------+ | | | ** | | * * | | * * | | *** | | * | | ** | | | | | +------+ */ 0x0000, 0x3000, 0x4800, 0x4800, 0x3800, 0x0800, 0x3000, 0x0000, 0x0000, /* Character 58 (0x3a): width 6 +------+ | | | | | ** | | ** | | | | ** | | ** | | | | | +------+ */ 0x0000, 0x0000, 0x3000, 0x3000, 0x0000, 0x3000, 0x3000, 0x0000, 0x0000, /* Character 59 (0x3b): width 6 +------+ | | | | | ** | | ** | | | | ** | | * | | * | | * | +------+ */ 0x0000, 0x0000, 0x3000, 0x3000, 0x0000, 0x3000, 0x1000, 0x1000, 0x2000, /* Character 60 (0x3c): width 6 +------+ | | | | | ** | | ** | |* | | ** | | ** | | | | | +------+ */ 0x0000, 0x0000, 0x1800, 0x6000, 0x8000, 0x6000, 0x1800, 0x0000, 0x0000, /* Character 61 (0x3d): width 6 +------+ | | | | | | |***** | | | |***** | | | | | | | +------+ */ 0x0000, 0x0000, 0x0000, 0xf800, 0x0000, 0xf800, 0x0000, 0x0000, 0x0000, /* Character 62 (0x3e): width 6 +------+ | | | | |** | | ** | | * | | ** | |** | | | | | +------+ */ 0x0000, 0x0000, 0xc000, 0x3000, 0x0800, 0x3000, 0xc000, 0x0000, 0x0000, /* Character 63 (0x3f): width 6 +------+ | ** | | * * | | * | | ** | | * | | | | * | | | | | +------+ */ 0x3000, 0x4800, 0x0800, 0x3000, 0x2000, 0x0000, 0x2000, 0x0000, 0x0000, /* Character 64 (0x40): width 6 +------+ | | | *** | |* * | |* * * | |* ** | |* | | *** | | | | | +------+ */ 0x0000, 0x7000, 0x9000, 0xa800, 0xb000, 0x8000, 0x7000, 0x0000, 0x0000, /* Character 65 (0x41): width 6 +------+ | | | * | | * * | |* * | |***** | |* * | |* * | | | | | +------+ */ 0x0000, 0x2000, 0x5000, 0x8800, 0xf800, 0x8800, 0x8800, 0x0000, 0x0000, /* Character 66 (0x42): width 6 +------+ | | |**** | |* * | |**** | |* * | |* * | |**** | | | | | +------+ */ 0x0000, 0xf000, 0x8800, 0xf000, 0x8800, 0x8800, 0xf000, 0x0000, 0x0000, /* Character 67 (0x43): width 6 +------+ | | | ** | | * * | | * | | * | | * * | | ** | | | | | +------+ */ 0x0000, 0x3000, 0x4800, 0x4000, 0x4000, 0x4800, 0x3000, 0x0000, 0x0000, /* Character 68 (0x44): width 6 +------+ | | | *** | | * * | | * * | | * * | | * * | | *** | | | | | +------+ */ 0x0000, 0x7000, 0x4800, 0x4800, 0x4800, 0x4800, 0x7000, 0x0000, 0x0000, /* Character 69 (0x45): width 6 +------+ | | | **** | | * | | *** | | * | | * | | **** | | | | | +------+ */ 0x0000, 0x7800, 0x4000, 0x7000, 0x4000, 0x4000, 0x7800, 0x0000, 0x0000, /* Character 70 (0x46): width 6 +------+ | | | **** | | * | | *** | | * | | * | | * | | | | | +------+ */ 0x0000, 0x7800, 0x4000, 0x7000, 0x4000, 0x4000, 0x4000, 0x0000, 0x0000, /* Character 71 (0x47): width 6 +------+ | | | ** | | * * | | * | | * ** | | * * | | ** | | | | | +------+ */ 0x0000, 0x3000, 0x4800, 0x4000, 0x5800, 0x4800, 0x3000, 0x0000, 0x0000, /* Character 72 (0x48): width 6 +------+ | | | * * | | * * | | **** | | * * | | * * | | * * | | | | | +------+ */ 0x0000, 0x4800, 0x4800, 0x7800, 0x4800, 0x4800, 0x4800, 0x0000, 0x0000, /* Character 73 (0x49): width 6 +------+ | | | *** | | * | | * | | * | | * | | *** | | | | | +------+ */ 0x0000, 0x7000, 0x2000, 0x2000, 0x2000, 0x2000, 0x7000, 0x0000, 0x0000, /* Character 74 (0x4a): width 6 +------+ | | | *** | | * | | * | | * | |* * | | ** | | | | | +------+ */ 0x0000, 0x3800, 0x1000, 0x1000, 0x1000, 0x9000, 0x6000, 0x0000, 0x0000, /* Character 75 (0x4b): width 6 +------+ | | | * * | | * * | | ** | | * * | | * * | | * * | | | | | +------+ */ 0x0000, 0x4800, 0x5000, 0x6000, 0x5000, 0x4800, 0x4800, 0x0000, 0x0000, /* Character 76 (0x4c): width 6 +------+ | | | * | | * | | * | | * | | * | | **** | | | | | +------+ */ 0x0000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x7800, 0x0000, 0x0000, /* Character 77 (0x4d): width 6 +------+ | | |* * | |** ** | |* * * | |* * * | |* * | |* * | | | | | +------+ */ 0x0000, 0x8800, 0xd800, 0xa800, 0xa800, 0x8800, 0x8800, 0x0000, 0x0000, /* Character 78 (0x4e): width 6 +------+ | | | * * | | ** * | | * ** | | * * | | * * | | * * | | | | | +------+ */ 0x0000, 0x4800, 0x6800, 0x5800, 0x4800, 0x4800, 0x4800, 0x0000, 0x0000, /* Character 79 (0x4f): width 6 +------+ | | | *** | |* * | |* * | |* * | |* * | | *** | | | | | +------+ */ 0x0000, 0x7000, 0x8800, 0x8800, 0x8800, 0x8800, 0x7000, 0x0000, 0x0000, /* Character 80 (0x50): width 6 +------+ | | | *** | | * * | | * * | | *** | | * | | * | | | | | +------+ */ 0x0000, 0x7000, 0x4800, 0x4800, 0x7000, 0x4000, 0x4000, 0x0000, 0x0000, /* Character 81 (0x51): width 6 +------+ | | | ** | | * * | | * * | | ** * | | * ** | | ** | | * | | | +------+ */ 0x0000, 0x3000, 0x4800, 0x4800, 0x6800, 0x5800, 0x3000, 0x0800, 0x0000, /* Character 82 (0x52): width 6 +------+ | | | *** | | * * | | * * | | *** | | * * | | * * | | | | | +------+ */ 0x0000, 0x7000, 0x4800, 0x4800, 0x7000, 0x4800, 0x4800, 0x0000, 0x0000, /* Character 83 (0x53): width 6 +------+ | | | ** | | * * | | * | | * | | * * | | ** | | | | | +------+ */ 0x0000, 0x3000, 0x4800, 0x2000, 0x1000, 0x4800, 0x3000, 0x0000, 0x0000, /* Character 84 (0x54): width 6 +------+ | | |***** | | * | | * | | * | | * | | * | | | | | +------+ */ 0x0000, 0xf800, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x0000, 0x0000, /* Character 85 (0x55): width 6 +------+ | | | * * | | * * | | * * | | * * | | * * | | ** | | | | | +------+ */ 0x0000, 0x4800, 0x4800, 0x4800, 0x4800, 0x4800, 0x3000, 0x0000, 0x0000, /* Character 86 (0x56): width 6 +------+ | | | * * | | * * | | * * | | **** | | ** | | ** | | | | | +------+ */ 0x0000, 0x4800, 0x4800, 0x4800, 0x7800, 0x3000, 0x3000, 0x0000, 0x0000, /* Character 87 (0x57): width 6 +------+ | | |* * | |* * | |* * * | |* * * | |** ** | |* * | | | | | +------+ */ 0x0000, 0x8800, 0x8800, 0xa800, 0xa800, 0xd800, 0x8800, 0x0000, 0x0000, /* Character 88 (0x58): width 6 +------+ | | |* * | | * * | | * | | * | | * * | |* * | | | | | +------+ */ 0x0000, 0x8800, 0x5000, 0x2000, 0x2000, 0x5000, 0x8800, 0x0000, 0x0000, /* Character 89 (0x59): width 6 +------+ | | |* * | |* * | | * * | | * | | * | | * | | | | | +------+ */ 0x0000, 0x8800, 0x8800, 0x5000, 0x2000, 0x2000, 0x2000, 0x0000, 0x0000, /* Character 90 (0x5a): width 6 +------+ | | | **** | | * | | * | | * | | * | | **** | | | | | +------+ */ 0x0000, 0x7800, 0x0800, 0x1000, 0x2000, 0x4000, 0x7800, 0x0000, 0x0000, /* Character 91 (0x5b): width 6 +------+ | | | *** | | * | | * | | * | | * | | *** | | | | | +------+ */ 0x0000, 0x7000, 0x4000, 0x4000, 0x4000, 0x4000, 0x7000, 0x0000, 0x0000, /* Character 92 (0x5c): width 6 +------+ | | | * | | * | | * | | * | | * | | * | | | | | +------+ */ 0x0000, 0x4000, 0x4000, 0x2000, 0x1000, 0x0800, 0x0800, 0x0000, 0x0000, /* Character 93 (0x5d): width 6 +------+ | | | *** | | * | | * | | * | | * | | *** | | | | | +------+ */ 0x0000, 0x7000, 0x1000, 0x1000, 0x1000, 0x1000, 0x7000, 0x0000, 0x0000, /* Character 94 (0x5e): width 6 +------+ | | | * | | * * | |* * | | | | | | | | | | | +------+ */ 0x0000, 0x2000, 0x5000, 0x8800, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 95 (0x5f): width 6 +------+ | | | | | | | | | | | | | | | | |***** | +------+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xf800, /* Character 96 (0x60): width 6 +------+ | | | * | | * | | | | | | | | | | | | | +------+ */ 0x0000, 0x2000, 0x1000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 97 (0x61): width 6 +------+ | | | | | | | *** | | * * | | * * | | *** | | | | | +------+ */ 0x0000, 0x0000, 0x0000, 0x3800, 0x4800, 0x4800, 0x3800, 0x0000, 0x0000, /* Character 98 (0x62): width 6 +------+ | | | * | | * | | *** | | * * | | * * | | *** | | | | | +------+ */ 0x0000, 0x4000, 0x4000, 0x7000, 0x4800, 0x4800, 0x7000, 0x0000, 0x0000, /* Character 99 (0x63): width 6 +------+ | | | | | | | *** | | * | | * | | *** | | | | | +------+ */ 0x0000, 0x0000, 0x0000, 0x3800, 0x4000, 0x4000, 0x3800, 0x0000, 0x0000, /* Character 100 (0x64): width 6 +------+ | | | * | | * | | *** | | * * | | * * | | *** | | | | | +------+ */ 0x0000, 0x0800, 0x0800, 0x3800, 0x4800, 0x4800, 0x3800, 0x0000, 0x0000, /* Character 101 (0x65): width 6 +------+ | | | | | | | ** | | * ** | | ** | | *** | | | | | +------+ */ 0x0000, 0x0000, 0x0000, 0x3000, 0x5800, 0x6000, 0x3800, 0x0000, 0x0000, /* Character 102 (0x66): width 6 +------+ | | | * | | * * | | * | | *** | | * | | * | | | | | +------+ */ 0x0000, 0x1000, 0x2800, 0x2000, 0x7000, 0x2000, 0x2000, 0x0000, 0x0000, /* Character 103 (0x67): width 6 +------+ | | | | | | | ** | | * * | | * * | | *** | | * | | ** | +------+ */ 0x0000, 0x0000, 0x0000, 0x3000, 0x4800, 0x4800, 0x3800, 0x0800, 0x3000, /* Character 104 (0x68): width 6 +------+ | | | * | | * | | *** | | * * | | * * | | * * | | | | | +------+ */ 0x0000, 0x4000, 0x4000, 0x7000, 0x4800, 0x4800, 0x4800, 0x0000, 0x0000, /* Character 105 (0x69): width 6 +------+ | | | * | | | | ** | | * | | * | | *** | | | | | +------+ */ 0x0000, 0x2000, 0x0000, 0x6000, 0x2000, 0x2000, 0x7000, 0x0000, 0x0000, /* Character 106 (0x6a): width 6 +------+ | | | * | | | | ** | | * | | * | | * | | * * | | * | +------+ */ 0x0000, 0x1000, 0x0000, 0x3000, 0x1000, 0x1000, 0x1000, 0x5000, 0x2000, /* Character 107 (0x6b): width 6 +------+ | | | * | | * | | * * | | ** | | * * | | * * | | | | | +------+ */ 0x0000, 0x4000, 0x4000, 0x5000, 0x6000, 0x5000, 0x4800, 0x0000, 0x0000, /* Character 108 (0x6c): width 6 +------+ | | | ** | | * | | * | | * | | * | | *** | | | | | +------+ */ 0x0000, 0x6000, 0x2000, 0x2000, 0x2000, 0x2000, 0x7000, 0x0000, 0x0000, /* Character 109 (0x6d): width 6 +------+ | | | | | | |** * | |* * * | |* * * | |* * | | | | | +------+ */ 0x0000, 0x0000, 0x0000, 0xd000, 0xa800, 0xa800, 0x8800, 0x0000, 0x0000, /* Character 110 (0x6e): width 6 +------+ | | | | | | | *** | | * * | | * * | | * * | | | | | +------+ */ 0x0000, 0x0000, 0x0000, 0x7000, 0x4800, 0x4800, 0x4800, 0x0000, 0x0000, /* Character 111 (0x6f): width 6 +------+ | | | | | | | ** | | * * | | * * | | ** | | | | | +------+ */ 0x0000, 0x0000, 0x0000, 0x3000, 0x4800, 0x4800, 0x3000, 0x0000, 0x0000, /* Character 112 (0x70): width 6 +------+ | | | | | | | *** | | * * | | * * | | *** | | * | | * | +------+ */ 0x0000, 0x0000, 0x0000, 0x7000, 0x4800, 0x4800, 0x7000, 0x4000, 0x4000, /* Character 113 (0x71): width 6 +------+ | | | | | | | *** | | * * | | * * | | *** | | * | | * | +------+ */ 0x0000, 0x0000, 0x0000, 0x3800, 0x4800, 0x4800, 0x3800, 0x0800, 0x0800, /* Character 114 (0x72): width 6 +------+ | | | | | | | * * | | ** * | | * | | * | | | | | +------+ */ 0x0000, 0x0000, 0x0000, 0x5000, 0x6800, 0x4000, 0x4000, 0x0000, 0x0000, /* Character 115 (0x73): width 6 +------+ | | | | | | | *** | | ** | | ** | | *** | | | | | +------+ */ 0x0000, 0x0000, 0x0000, 0x3800, 0x6000, 0x1800, 0x7000, 0x0000, 0x0000, /* Character 116 (0x74): width 6 +------+ | | | * | | * | | *** | | * | | * * | | * | | | | | +------+ */ 0x0000, 0x2000, 0x2000, 0x7000, 0x2000, 0x2800, 0x1000, 0x0000, 0x0000, /* Character 117 (0x75): width 6 +------+ | | | | | | | * * | | * * | | * * | | *** | | | | | +------+ */ 0x0000, 0x0000, 0x0000, 0x4800, 0x4800, 0x4800, 0x3800, 0x0000, 0x0000, /* Character 118 (0x76): width 6 +------+ | | | | | | | * * | | * * | | ** | | ** | | | | | +------+ */ 0x0000, 0x0000, 0x0000, 0x4800, 0x4800, 0x3000, 0x3000, 0x0000, 0x0000, /* Character 119 (0x77): width 6 +------+ | | | | | | |* * | |* * * | |* * * | | * * | | | | | +------+ */ 0x0000, 0x0000, 0x0000, 0x8800, 0xa800, 0xa800, 0x5000, 0x0000, 0x0000, /* Character 120 (0x78): width 6 +------+ | | | | | | | * * | | ** | | ** | | * * | | | | | +------+ */ 0x0000, 0x0000, 0x0000, 0x4800, 0x3000, 0x3000, 0x4800, 0x0000, 0x0000, /* Character 121 (0x79): width 6 +------+ | | | | | | | * * | | * * | | * * | | *** | | * * | | ** | +------+ */ 0x0000, 0x0000, 0x0000, 0x4800, 0x4800, 0x4800, 0x3800, 0x4800, 0x3000, /* Character 122 (0x7a): width 6 +------+ | | | | | | | **** | | * | | * | | **** | | | | | +------+ */ 0x0000, 0x0000, 0x0000, 0x7800, 0x1000, 0x2000, 0x7800, 0x0000, 0x0000, /* Character 123 (0x7b): width 6 +------+ | * | | * | | * | | * | | * | | * | | * | | | | | +------+ */ 0x1000, 0x2000, 0x2000, 0x4000, 0x2000, 0x2000, 0x1000, 0x0000, 0x0000, /* Character 124 (0x7c): width 6 +------+ | | | * | | * | | * | | * | | * | | * | | * | | | +------+ */ 0x0000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x0000, /* Character 125 (0x7d): width 6 +------+ | * | | * | | * | | * | | * | | * | | * | | | | | +------+ */ 0x4000, 0x2000, 0x2000, 0x1000, 0x2000, 0x2000, 0x4000, 0x0000, 0x0000, /* Character 126 (0x7e): width 6 +------+ | | | | | * * | | * * | | | | | | | | | | | +------+ */ 0x0000, 0x0000, 0x2800, 0x5000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 1040 (0x410): width 6 +------+ | | | * | | * * | |* * | |***** | |* * | |* * | | | | | +------+ */ 0x0000, 0x2000, 0x5000, 0x8800, 0xf800, 0x8800, 0x8800, 0x0000, 0x0000, /* Character 1041 (0x411): width 6 +------+ | | |**** | |* | |**** | |* * | |* * | |**** | | | | | +------+ */ 0x0000, 0xf000, 0x8000, 0xf000, 0x8800, 0x8800, 0xf000, 0x0000, 0x0000, /* Character 1042 (0x412): width 6 +------+ | | |**** | |* * | |**** | |* * | |* * | |**** | | | | | +------+ */ 0x0000, 0xf000, 0x8800, 0xf000, 0x8800, 0x8800, 0xf000, 0x0000, 0x0000, /* Character 1043 (0x413): width 6 +------+ | | | **** | | * | | * | | * | | * | | * | | | | | +------+ */ 0x0000, 0x7800, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x0000, 0x0000, /* Character 1044 (0x414): width 6 +------+ | | | ** | | * * | | * * | | * * | | * * | |***** | |* * | | | +------+ */ 0x0000, 0x3000, 0x5000, 0x5000, 0x5000, 0x5000, 0xf800, 0x8800, 0x0000, /* Character 1045 (0x415): width 6 +------+ | | | **** | | * | | *** | | * | | * | | **** | | | | | +------+ */ 0x0000, 0x7800, 0x4000, 0x7000, 0x4000, 0x4000, 0x7800, 0x0000, 0x0000, /* Character 1046 (0x416): width 6 +------+ | | |* * * | |* * * | | *** | |* * * | |* * * | |* * * | | | | | +------+ */ 0x0000, 0xa800, 0xa800, 0x7000, 0xa800, 0xa800, 0xa800, 0x0000, 0x0000, /* Character 1047 (0x417): width 6 +------+ | | | *** | |* * | | ** | | * | |* * | | *** | | | | | +------+ */ 0x0000, 0x7000, 0x8800, 0x3000, 0x0800, 0x8800, 0x7000, 0x0000, 0x0000, /* Character 1048 (0x418): width 6 +------+ | | | * * | | * ** | | ** * | | * * | | * * | | * * | | | | | +------+ */ 0x0000, 0x4800, 0x5800, 0x6800, 0x4800, 0x4800, 0x4800, 0x0000, 0x0000, /* Character 1049 (0x419): width 6 +------+ | * * | | ** | | * * | | * ** | | ** * | | * * | | * * | | | | | +------+ */ 0x4800, 0x3000, 0x4800, 0x5800, 0x6800, 0x4800, 0x4800, 0x0000, 0x0000, /* Character 1050 (0x41a): width 6 +------+ | | | * * | | * * | | ** | | * * | | * * | | * * | | | | | +------+ */ 0x0000, 0x4800, 0x5000, 0x6000, 0x5000, 0x4800, 0x4800, 0x0000, 0x0000, /* Character 1051 (0x41b): width 6 +------+ | | | *** | | * * | | * * | | * * | | * * | |* * | | | | | +------+ */ 0x0000, 0x3800, 0x4800, 0x4800, 0x4800, 0x4800, 0x8800, 0x0000, 0x0000, /* Character 1052 (0x41c): width 6 +------+ | | |* * | |** ** | |* * * | |* * * | |* * | |* * | | | | | +------+ */ 0x0000, 0x8800, 0xd800, 0xa800, 0xa800, 0x8800, 0x8800, 0x0000, 0x0000, /* Character 1053 (0x41d): width 6 +------+ | | | * * | | * * | | **** | | * * | | * * | | * * | | | | | +------+ */ 0x0000, 0x4800, 0x4800, 0x7800, 0x4800, 0x4800, 0x4800, 0x0000, 0x0000, /* Character 1054 (0x41e): width 6 +------+ | | | *** | |* * | |* * | |* * | |* * | | *** | | | | | +------+ */ 0x0000, 0x7000, 0x8800, 0x8800, 0x8800, 0x8800, 0x7000, 0x0000, 0x0000, /* Character 1055 (0x41f): width 6 +------+ | | |***** | |* * | |* * | |* * | |* * | |* * | | | | | +------+ */ 0x0000, 0xf800, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x0000, 0x0000, /* Character 1056 (0x420): width 6 +------+ | | | *** | | * * | | * * | | *** | | * | | * | | | | | +------+ */ 0x0000, 0x7000, 0x4800, 0x4800, 0x7000, 0x4000, 0x4000, 0x0000, 0x0000, /* Character 1057 (0x421): width 6 +------+ | | | ** | | * * | | * | | * | | * * | | ** | | | | | +------+ */ 0x0000, 0x3000, 0x4800, 0x4000, 0x4000, 0x4800, 0x3000, 0x0000, 0x0000, /* Character 1058 (0x422): width 6 +------+ | | |***** | | * | | * | | * | | * | | * | | | | | +------+ */ 0x0000, 0xf800, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x0000, 0x0000, /* Character 1059 (0x423): width 6 +------+ | | |* * | |* * | |* * | | **** | | * | | *** | | | | | +------+ */ 0x0000, 0x8800, 0x8800, 0x8800, 0x7800, 0x0800, 0x7000, 0x0000, 0x0000, /* Character 1060 (0x424): width 6 +------+ | | | * | | *** | |* * * | |* * * | | *** | | * | | | | | +------+ */ 0x0000, 0x2000, 0x7000, 0xa800, 0xa800, 0x7000, 0x2000, 0x0000, 0x0000, /* Character 1061 (0x425): width 6 +------+ | | |* * | | * * | | * | | * | | * * | |* * | | | | | +------+ */ 0x0000, 0x8800, 0x5000, 0x2000, 0x2000, 0x5000, 0x8800, 0x0000, 0x0000, /* Character 1062 (0x426): width 6 +------+ | | |* * | |* * | |* * | |* * | |* * | |***** | | * | | * | +------+ */ 0x0000, 0x9000, 0x9000, 0x9000, 0x9000, 0x9000, 0xf800, 0x0800, 0x1000, /* Character 1063 (0x427): width 6 +------+ | | |* * | |* * | |* * | | **** | | * | | * | | | | | +------+ */ 0x0000, 0x8800, 0x8800, 0x8800, 0x7800, 0x0800, 0x0800, 0x0000, 0x0000, /* Character 1064 (0x428): width 6 +------+ | | |* * * | |* * * | |* * * | |* * * | |* * * | |***** | | | | | +------+ */ 0x0000, 0xa800, 0xa800, 0xa800, 0xa800, 0xa800, 0xf800, 0x0000, 0x0000, /* Character 1065 (0x429): width 6 +------+ | | |* * * | |* * * | |* * * | |* * * | |* * * | |***** | | * | | * | +------+ */ 0x0000, 0xa800, 0xa800, 0xa800, 0xa800, 0xa800, 0xf800, 0x0800, 0x1000, /* Character 1066 (0x42a): width 6 +------+ | | |** | | * | | *** | | * * | | * * | | *** | | | | | +------+ */ 0x0000, 0xc000, 0x4000, 0x7000, 0x4800, 0x4800, 0x7000, 0x0000, 0x0000, /* Character 1067 (0x42b): width 6 +------+ | | |* * | |* * | |*** * | |* ** | |* ** | |*** * | | | | | +------+ */ 0x0000, 0x8800, 0x8800, 0xe800, 0x9800, 0x9800, 0xe800, 0x0000, 0x0000, /* Character 1068 (0x42c): width 6 +------+ | | | * | | * | | *** | | * * | | * * | | *** | | | | | +------+ */ 0x0000, 0x4000, 0x4000, 0x7000, 0x4800, 0x4800, 0x7000, 0x0000, 0x0000, /* Character 1069 (0x42d): width 6 +------+ | | | *** | |* * | | *** | | * | |* * | | *** | | | | | +------+ */ 0x0000, 0x7000, 0x8800, 0x3800, 0x0800, 0x8800, 0x7000, 0x0000, 0x0000, /* Character 1070 (0x42e): width 6 +------+ | | |* * | |* * * | |*** * | |*** * | |* * * | |* * | | | | | +------+ */ 0x0000, 0x9000, 0xa800, 0xe800, 0xe800, 0xa800, 0x9000, 0x0000, 0x0000, /* Character 1071 (0x42f): width 6 +------+ | | | *** | | * * | | * * | | *** | | * * | | * * | | | | | +------+ */ 0x0000, 0x3800, 0x4800, 0x4800, 0x3800, 0x4800, 0x4800, 0x0000, 0x0000, /* Character 1072 (0x430): width 6 +------+ | | | | | | | *** | |* * | |* * | | **** | | | | | +------+ */ 0x0000, 0x0000, 0x0000, 0x7000, 0x9000, 0x9000, 0x7800, 0x0000, 0x0000, /* Character 1073 (0x431): width 6 +------+ | * | | ** | | * | | *** | | * * | | * * | | ** | | | | | +------+ */ 0x0800, 0x3000, 0x4000, 0x7000, 0x4800, 0x4800, 0x3000, 0x0000, 0x0000, /* Character 1074 (0x432): width 6 +------+ | | | | | | | ** | | * * | | ** * | | *** | | | | | +------+ */ 0x0000, 0x0000, 0x0000, 0x6000, 0x5000, 0x6800, 0x7000, 0x0000, 0x0000, /* Character 1075 (0x433): width 6 +------+ | | | | | | | **** | | * | | * | | * | | | | | +------+ */ 0x0000, 0x0000, 0x0000, 0x7800, 0x4000, 0x4000, 0x4000, 0x0000, 0x0000, /* Character 1076 (0x434): width 6 +------+ | | | | | | | ** | | * * | | * * | |***** | |* * | | | +------+ */ 0x0000, 0x0000, 0x0000, 0x3000, 0x5000, 0x5000, 0xf800, 0x8800, 0x0000, /* Character 1077 (0x435): width 6 +------+ | | | | | | | ** | |* * | |*** | | *** | | | | | +------+ */ 0x0000, 0x0000, 0x0000, 0x6000, 0x9000, 0xe000, 0x7000, 0x0000, 0x0000, /* Character 1078 (0x436): width 6 +------+ | | | | | | |* * * | | *** | | *** | |* * * | | | | | +------+ */ 0x0000, 0x0000, 0x0000, 0xa800, 0x7000, 0x7000, 0xa800, 0x0000, 0x0000, /* Character 1079 (0x437): width 6 +------+ | | | | | | | ** | | * * | | ** | | *** | | | | | +------+ */ 0x0000, 0x0000, 0x0000, 0x3000, 0x2800, 0x1800, 0x7000, 0x0000, 0x0000, /* Character 1080 (0x438): width 6 +------+ | | | | | | |* * | |* ** | |* * * | |** * | | | | | +------+ */ 0x0000, 0x0000, 0x0000, 0x8800, 0x9800, 0xa800, 0xc800, 0x0000, 0x0000, /* Character 1081 (0x439): width 6 +------+ |* * | | *** | | | |* * | |* ** | |* * * | |** * | | | | | +------+ */ 0x8800, 0x7000, 0x0000, 0x8800, 0x9800, 0xa800, 0xc800, 0x0000, 0x0000, /* Character 1082 (0x43a): width 6 +------+ | | | | | | | * * | | * * | | *** | | * * | | | | | +------+ */ 0x0000, 0x0000, 0x0000, 0x4800, 0x5000, 0x7000, 0x4800, 0x0000, 0x0000, /* Character 1083 (0x43b): width 6 +------+ | | | | | | | *** | | * * | | * * | |* * | | | | | +------+ */ 0x0000, 0x0000, 0x0000, 0x3800, 0x4800, 0x4800, 0x8800, 0x0000, 0x0000, /* Character 1084 (0x43c): width 6 +------+ | | | | | | |* * | |** ** | |* * * | |* * | | | | | +------+ */ 0x0000, 0x0000, 0x0000, 0x8800, 0xd800, 0xa800, 0x8800, 0x0000, 0x0000, /* Character 1085 (0x43d): width 6 +------+ | | | | | | |* * | |***** | |* * | |* * | | | | | +------+ */ 0x0000, 0x0000, 0x0000, 0x8800, 0xf800, 0x8800, 0x8800, 0x0000, 0x0000, /* Character 1086 (0x43e): width 6 +------+ | | | | | | | *** | |* * | |* * | | *** | | | | | +------+ */ 0x0000, 0x0000, 0x0000, 0x7000, 0x8800, 0x8800, 0x7000, 0x0000, 0x0000, /* Character 1087 (0x43f): width 6 +------+ | | | | | | |***** | |* * | |* * | |* * | | | | | +------+ */ 0x0000, 0x0000, 0x0000, 0xf800, 0x8800, 0x8800, 0x8800, 0x0000, 0x0000, /* Character 1088 (0x440): width 6 +------+ | | | | | | |**** | |* * | |* * | |**** | |* | |* | +------+ */ 0x0000, 0x0000, 0x0000, 0xf000, 0x8800, 0x8800, 0xf000, 0x8000, 0x8000, /* Character 1089 (0x441): width 6 +------+ | | | | | | | *** | |* * | |* | | **** | | | | | +------+ */ 0x0000, 0x0000, 0x0000, 0x7000, 0x8800, 0x8000, 0x7800, 0x0000, 0x0000, /* Character 1090 (0x442): width 6 +------+ | | | | | | |***** | | * | | * | | * | | | | | +------+ */ 0x0000, 0x0000, 0x0000, 0xf800, 0x2000, 0x2000, 0x2000, 0x0000, 0x0000, /* Character 1091 (0x443): width 6 +------+ | | | | | | |* * | |* * | |* * | | **** | | * | | *** | +------+ */ 0x0000, 0x0000, 0x0000, 0x8800, 0x8800, 0x8800, 0x7800, 0x0800, 0x7000, /* Character 1092 (0x444): width 6 +------+ | | | * | | * | | *** | |* * * | |* * * | | *** | | * | | * | +------+ */ 0x0000, 0x2000, 0x2000, 0x7000, 0xa800, 0xa800, 0x7000, 0x2000, 0x2000, /* Character 1093 (0x445): width 6 +------+ | | | | | | | * * | | ** | | ** | | * * | | | | | +------+ */ 0x0000, 0x0000, 0x0000, 0x4800, 0x3000, 0x3000, 0x4800, 0x0000, 0x0000, /* Character 1094 (0x446): width 6 +------+ | | | | | | |* * | |* * | |* * | |***** | | * | | * | +------+ */ 0x0000, 0x0000, 0x0000, 0x9000, 0x9000, 0x9000, 0xf800, 0x0800, 0x1000, /* Character 1095 (0x447): width 6 +------+ | | | | | | |* * | |* * | | **** | | * | | | | | +------+ */ 0x0000, 0x0000, 0x0000, 0x8800, 0x8800, 0x7800, 0x0800, 0x0000, 0x0000, /* Character 1096 (0x448): width 6 +------+ | | | | | | |* * * | |* * * | |* * * | |***** | | | | | +------+ */ 0x0000, 0x0000, 0x0000, 0xa800, 0xa800, 0xa800, 0xf800, 0x0000, 0x0000, /* Character 1097 (0x449): width 6 +------+ | | | | | | |* * * | |* * * | |* * * | |***** | | * | | * | +------+ */ 0x0000, 0x0000, 0x0000, 0xa800, 0xa800, 0xa800, 0xf800, 0x0800, 0x1000, /* Character 1098 (0x44a): width 6 +------+ | | | | | | |** | | *** | | * * | | *** | | | | | +------+ */ 0x0000, 0x0000, 0x0000, 0xc000, 0x7000, 0x4800, 0x7000, 0x0000, 0x0000, /* Character 1099 (0x44b): width 6 +------+ | | | | | | |* * | |*** * | |* ** | |*** * | | | | | +------+ */ 0x0000, 0x0000, 0x0000, 0x8800, 0xe800, 0x9800, 0xe800, 0x0000, 0x0000, /* Character 1100 (0x44c): width 6 +------+ | | | | | | | * | | *** | | * * | | *** | | | | | +------+ */ 0x0000, 0x0000, 0x0000, 0x4000, 0x7000, 0x4800, 0x7000, 0x0000, 0x0000, /* Character 1101 (0x44d): width 6 +------+ | | | | | | |*** | | * * | | ** | |*** | | | | | +------+ */ 0x0000, 0x0000, 0x0000, 0xe000, 0x5000, 0x3000, 0xe000, 0x0000, 0x0000, /* Character 1102 (0x44e): width 6 +------+ | | | | | | |* * | |*** * | |*** * | |* * | | | | | +------+ */ 0x0000, 0x0000, 0x0000, 0x9000, 0xe800, 0xe800, 0x9000, 0x0000, 0x0000, /* Character 1103 (0x44f): width 6 +------+ | | | | | | | *** | |* * | | *** | |* * | | | | | +------+ */ 0x0000, 0x0000, 0x0000, 0x7000, 0x9000, 0x7000, 0x9000, 0x0000, 0x0000, }; /* Character->glyph mapping. */ static const unsigned short _6x9_offset[] = { 0, /* (0x00) */ 0, /* (0x01) */ 0, /* (0x02) */ 0, /* (0x03) */ 0, /* (0x04) */ 0, /* (0x05) */ 0, /* (0x06) */ 0, /* (0x07) */ 0, /* (0x08) */ 0, /* (0x09) */ 0, /* (0x0a) */ 0, /* (0x0b) */ 0, /* (0x0c) */ 0, /* (0x0d) */ 0, /* (0x0e) */ 0, /* (0x0f) */ 0, /* (0x10) */ 0, /* (0x11) */ 0, /* (0x12) */ 0, /* (0x13) */ 0, /* (0x14) */ 0, /* (0x15) */ 0, /* (0x16) */ 0, /* (0x17) */ 0, /* (0x18) */ 0, /* (0x19) */ 0, /* (0x1a) */ 0, /* (0x1b) */ 0, /* (0x1c) */ 0, /* (0x1d) */ 0, /* (0x1e) */ 0, /* (0x1f) */ 9, /* (0x20) */ 18, /* (0x21) */ 27, /* (0x22) */ 36, /* (0x23) */ 45, /* (0x24) */ 54, /* (0x25) */ 63, /* (0x26) */ 72, /* (0x27) */ 81, /* (0x28) */ 90, /* (0x29) */ 99, /* (0x2a) */ 108, /* (0x2b) */ 117, /* (0x2c) */ 126, /* (0x2d) */ 135, /* (0x2e) */ 144, /* (0x2f) */ 153, /* (0x30) */ 162, /* (0x31) */ 171, /* (0x32) */ 180, /* (0x33) */ 189, /* (0x34) */ 198, /* (0x35) */ 207, /* (0x36) */ 216, /* (0x37) */ 225, /* (0x38) */ 234, /* (0x39) */ 243, /* (0x3a) */ 252, /* (0x3b) */ 261, /* (0x3c) */ 270, /* (0x3d) */ 279, /* (0x3e) */ 288, /* (0x3f) */ 297, /* (0x40) */ 306, /* (0x41) */ 315, /* (0x42) */ 324, /* (0x43) */ 333, /* (0x44) */ 342, /* (0x45) */ 351, /* (0x46) */ 360, /* (0x47) */ 369, /* (0x48) */ 378, /* (0x49) */ 387, /* (0x4a) */ 396, /* (0x4b) */ 405, /* (0x4c) */ 414, /* (0x4d) */ 423, /* (0x4e) */ 432, /* (0x4f) */ 441, /* (0x50) */ 450, /* (0x51) */ 459, /* (0x52) */ 468, /* (0x53) */ 477, /* (0x54) */ 486, /* (0x55) */ 495, /* (0x56) */ 504, /* (0x57) */ 513, /* (0x58) */ 522, /* (0x59) */ 531, /* (0x5a) */ 540, /* (0x5b) */ 549, /* (0x5c) */ 558, /* (0x5d) */ 567, /* (0x5e) */ 576, /* (0x5f) */ 585, /* (0x60) */ 594, /* (0x61) */ 603, /* (0x62) */ 612, /* (0x63) */ 621, /* (0x64) */ 630, /* (0x65) */ 639, /* (0x66) */ 648, /* (0x67) */ 657, /* (0x68) */ 666, /* (0x69) */ 675, /* (0x6a) */ 684, /* (0x6b) */ 693, /* (0x6c) */ 702, /* (0x6d) */ 711, /* (0x6e) */ 720, /* (0x6f) */ 729, /* (0x70) */ 738, /* (0x71) */ 747, /* (0x72) */ 756, /* (0x73) */ 765, /* (0x74) */ 774, /* (0x75) */ 783, /* (0x76) */ 792, /* (0x77) */ 801, /* (0x78) */ 810, /* (0x79) */ 819, /* (0x7a) */ 828, /* (0x7b) */ 837, /* (0x7c) */ 846, /* (0x7d) */ 855, /* (0x7e) */ 0, /* (0x7f) */ 0, /* (0x80) */ 0, /* (0x81) */ 0, /* (0x82) */ 0, /* (0x83) */ 0, /* (0x84) */ 0, /* (0x85) */ 0, /* (0x86) */ 0, /* (0x87) */ 0, /* (0x88) */ 0, /* (0x89) */ 0, /* (0x8a) */ 0, /* (0x8b) */ 0, /* (0x8c) */ 0, /* (0x8d) */ 0, /* (0x8e) */ 0, /* (0x8f) */ 0, /* (0x90) */ 0, /* (0x91) */ 0, /* (0x92) */ 0, /* (0x93) */ 0, /* (0x94) */ 0, /* (0x95) */ 0, /* (0x96) */ 0, /* (0x97) */ 0, /* (0x98) */ 0, /* (0x99) */ 0, /* (0x9a) */ 0, /* (0x9b) */ 0, /* (0x9c) */ 0, /* (0x9d) */ 0, /* (0x9e) */ 0, /* (0x9f) */ 0, /* (0xa0) */ 0, /* (0xa1) */ 0, /* (0xa2) */ 0, /* (0xa3) */ 0, /* (0xa4) */ 0, /* (0xa5) */ 0, /* (0xa6) */ 0, /* (0xa7) */ 0, /* (0xa8) */ 0, /* (0xa9) */ 0, /* (0xaa) */ 0, /* (0xab) */ 0, /* (0xac) */ 0, /* (0xad) */ 0, /* (0xae) */ 0, /* (0xaf) */ 0, /* (0xb0) */ 0, /* (0xb1) */ 0, /* (0xb2) */ 0, /* (0xb3) */ 0, /* (0xb4) */ 0, /* (0xb5) */ 0, /* (0xb6) */ 0, /* (0xb7) */ 0, /* (0xb8) */ 0, /* (0xb9) */ 0, /* (0xba) */ 0, /* (0xbb) */ 0, /* (0xbc) */ 0, /* (0xbd) */ 0, /* (0xbe) */ 0, /* (0xbf) */ 0, /* (0xc0) */ 0, /* (0xc1) */ 0, /* (0xc2) */ 0, /* (0xc3) */ 0, /* (0xc4) */ 0, /* (0xc5) */ 0, /* (0xc6) */ 0, /* (0xc7) */ 0, /* (0xc8) */ 0, /* (0xc9) */ 0, /* (0xca) */ 0, /* (0xcb) */ 0, /* (0xcc) */ 0, /* (0xcd) */ 0, /* (0xce) */ 0, /* (0xcf) */ 0, /* (0xd0) */ 0, /* (0xd1) */ 0, /* (0xd2) */ 0, /* (0xd3) */ 0, /* (0xd4) */ 0, /* (0xd5) */ 0, /* (0xd6) */ 0, /* (0xd7) */ 0, /* (0xd8) */ 0, /* (0xd9) */ 0, /* (0xda) */ 0, /* (0xdb) */ 0, /* (0xdc) */ 0, /* (0xdd) */ 0, /* (0xde) */ 0, /* (0xdf) */ 0, /* (0xe0) */ 0, /* (0xe1) */ 0, /* (0xe2) */ 0, /* (0xe3) */ 0, /* (0xe4) */ 0, /* (0xe5) */ 0, /* (0xe6) */ 0, /* (0xe7) */ 0, /* (0xe8) */ 0, /* (0xe9) */ 0, /* (0xea) */ 0, /* (0xeb) */ 0, /* (0xec) */ 0, /* (0xed) */ 0, /* (0xee) */ 0, /* (0xef) */ 0, /* (0xf0) */ 0, /* (0xf1) */ 0, /* (0xf2) */ 0, /* (0xf3) */ 0, /* (0xf4) */ 0, /* (0xf5) */ 0, /* (0xf6) */ 0, /* (0xf7) */ 0, /* (0xf8) */ 0, /* (0xf9) */ 0, /* (0xfa) */ 0, /* (0xfb) */ 0, /* (0xfc) */ 0, /* (0xfd) */ 0, /* (0xfe) */ 0, /* (0xff) */ 0, /* (0x100) */ 0, /* (0x101) */ 0, /* (0x102) */ 0, /* (0x103) */ 0, /* (0x104) */ 0, /* (0x105) */ 0, /* (0x106) */ 0, /* (0x107) */ 0, /* (0x108) */ 0, /* (0x109) */ 0, /* (0x10a) */ 0, /* (0x10b) */ 0, /* (0x10c) */ 0, /* (0x10d) */ 0, /* (0x10e) */ 0, /* (0x10f) */ 0, /* (0x110) */ 0, /* (0x111) */ 0, /* (0x112) */ 0, /* (0x113) */ 0, /* (0x114) */ 0, /* (0x115) */ 0, /* (0x116) */ 0, /* (0x117) */ 0, /* (0x118) */ 0, /* (0x119) */ 0, /* (0x11a) */ 0, /* (0x11b) */ 0, /* (0x11c) */ 0, /* (0x11d) */ 0, /* (0x11e) */ 0, /* (0x11f) */ 0, /* (0x120) */ 0, /* (0x121) */ 0, /* (0x122) */ 0, /* (0x123) */ 0, /* (0x124) */ 0, /* (0x125) */ 0, /* (0x126) */ 0, /* (0x127) */ 0, /* (0x128) */ 0, /* (0x129) */ 0, /* (0x12a) */ 0, /* (0x12b) */ 0, /* (0x12c) */ 0, /* (0x12d) */ 0, /* (0x12e) */ 0, /* (0x12f) */ 0, /* (0x130) */ 0, /* (0x131) */ 0, /* (0x132) */ 0, /* (0x133) */ 0, /* (0x134) */ 0, /* (0x135) */ 0, /* (0x136) */ 0, /* (0x137) */ 0, /* (0x138) */ 0, /* (0x139) */ 0, /* (0x13a) */ 0, /* (0x13b) */ 0, /* (0x13c) */ 0, /* (0x13d) */ 0, /* (0x13e) */ 0, /* (0x13f) */ 0, /* (0x140) */ 0, /* (0x141) */ 0, /* (0x142) */ 0, /* (0x143) */ 0, /* (0x144) */ 0, /* (0x145) */ 0, /* (0x146) */ 0, /* (0x147) */ 0, /* (0x148) */ 0, /* (0x149) */ 0, /* (0x14a) */ 0, /* (0x14b) */ 0, /* (0x14c) */ 0, /* (0x14d) */ 0, /* (0x14e) */ 0, /* (0x14f) */ 0, /* (0x150) */ 0, /* (0x151) */ 0, /* (0x152) */ 0, /* (0x153) */ 0, /* (0x154) */ 0, /* (0x155) */ 0, /* (0x156) */ 0, /* (0x157) */ 0, /* (0x158) */ 0, /* (0x159) */ 0, /* (0x15a) */ 0, /* (0x15b) */ 0, /* (0x15c) */ 0, /* (0x15d) */ 0, /* (0x15e) */ 0, /* (0x15f) */ 0, /* (0x160) */ 0, /* (0x161) */ 0, /* (0x162) */ 0, /* (0x163) */ 0, /* (0x164) */ 0, /* (0x165) */ 0, /* (0x166) */ 0, /* (0x167) */ 0, /* (0x168) */ 0, /* (0x169) */ 0, /* (0x16a) */ 0, /* (0x16b) */ 0, /* (0x16c) */ 0, /* (0x16d) */ 0, /* (0x16e) */ 0, /* (0x16f) */ 0, /* (0x170) */ 0, /* (0x171) */ 0, /* (0x172) */ 0, /* (0x173) */ 0, /* (0x174) */ 0, /* (0x175) */ 0, /* (0x176) */ 0, /* (0x177) */ 0, /* (0x178) */ 0, /* (0x179) */ 0, /* (0x17a) */ 0, /* (0x17b) */ 0, /* (0x17c) */ 0, /* (0x17d) */ 0, /* (0x17e) */ 0, /* (0x17f) */ 0, /* (0x180) */ 0, /* (0x181) */ 0, /* (0x182) */ 0, /* (0x183) */ 0, /* (0x184) */ 0, /* (0x185) */ 0, /* (0x186) */ 0, /* (0x187) */ 0, /* (0x188) */ 0, /* (0x189) */ 0, /* (0x18a) */ 0, /* (0x18b) */ 0, /* (0x18c) */ 0, /* (0x18d) */ 0, /* (0x18e) */ 0, /* (0x18f) */ 0, /* (0x190) */ 0, /* (0x191) */ 0, /* (0x192) */ 0, /* (0x193) */ 0, /* (0x194) */ 0, /* (0x195) */ 0, /* (0x196) */ 0, /* (0x197) */ 0, /* (0x198) */ 0, /* (0x199) */ 0, /* (0x19a) */ 0, /* (0x19b) */ 0, /* (0x19c) */ 0, /* (0x19d) */ 0, /* (0x19e) */ 0, /* (0x19f) */ 0, /* (0x1a0) */ 0, /* (0x1a1) */ 0, /* (0x1a2) */ 0, /* (0x1a3) */ 0, /* (0x1a4) */ 0, /* (0x1a5) */ 0, /* (0x1a6) */ 0, /* (0x1a7) */ 0, /* (0x1a8) */ 0, /* (0x1a9) */ 0, /* (0x1aa) */ 0, /* (0x1ab) */ 0, /* (0x1ac) */ 0, /* (0x1ad) */ 0, /* (0x1ae) */ 0, /* (0x1af) */ 0, /* (0x1b0) */ 0, /* (0x1b1) */ 0, /* (0x1b2) */ 0, /* (0x1b3) */ 0, /* (0x1b4) */ 0, /* (0x1b5) */ 0, /* (0x1b6) */ 0, /* (0x1b7) */ 0, /* (0x1b8) */ 0, /* (0x1b9) */ 0, /* (0x1ba) */ 0, /* (0x1bb) */ 0, /* (0x1bc) */ 0, /* (0x1bd) */ 0, /* (0x1be) */ 0, /* (0x1bf) */ 0, /* (0x1c0) */ 0, /* (0x1c1) */ 0, /* (0x1c2) */ 0, /* (0x1c3) */ 0, /* (0x1c4) */ 0, /* (0x1c5) */ 0, /* (0x1c6) */ 0, /* (0x1c7) */ 0, /* (0x1c8) */ 0, /* (0x1c9) */ 0, /* (0x1ca) */ 0, /* (0x1cb) */ 0, /* (0x1cc) */ 0, /* (0x1cd) */ 0, /* (0x1ce) */ 0, /* (0x1cf) */ 0, /* (0x1d0) */ 0, /* (0x1d1) */ 0, /* (0x1d2) */ 0, /* (0x1d3) */ 0, /* (0x1d4) */ 0, /* (0x1d5) */ 0, /* (0x1d6) */ 0, /* (0x1d7) */ 0, /* (0x1d8) */ 0, /* (0x1d9) */ 0, /* (0x1da) */ 0, /* (0x1db) */ 0, /* (0x1dc) */ 0, /* (0x1dd) */ 0, /* (0x1de) */ 0, /* (0x1df) */ 0, /* (0x1e0) */ 0, /* (0x1e1) */ 0, /* (0x1e2) */ 0, /* (0x1e3) */ 0, /* (0x1e4) */ 0, /* (0x1e5) */ 0, /* (0x1e6) */ 0, /* (0x1e7) */ 0, /* (0x1e8) */ 0, /* (0x1e9) */ 0, /* (0x1ea) */ 0, /* (0x1eb) */ 0, /* (0x1ec) */ 0, /* (0x1ed) */ 0, /* (0x1ee) */ 0, /* (0x1ef) */ 0, /* (0x1f0) */ 0, /* (0x1f1) */ 0, /* (0x1f2) */ 0, /* (0x1f3) */ 0, /* (0x1f4) */ 0, /* (0x1f5) */ 0, /* (0x1f6) */ 0, /* (0x1f7) */ 0, /* (0x1f8) */ 0, /* (0x1f9) */ 0, /* (0x1fa) */ 0, /* (0x1fb) */ 0, /* (0x1fc) */ 0, /* (0x1fd) */ 0, /* (0x1fe) */ 0, /* (0x1ff) */ 0, /* (0x200) */ 0, /* (0x201) */ 0, /* (0x202) */ 0, /* (0x203) */ 0, /* (0x204) */ 0, /* (0x205) */ 0, /* (0x206) */ 0, /* (0x207) */ 0, /* (0x208) */ 0, /* (0x209) */ 0, /* (0x20a) */ 0, /* (0x20b) */ 0, /* (0x20c) */ 0, /* (0x20d) */ 0, /* (0x20e) */ 0, /* (0x20f) */ 0, /* (0x210) */ 0, /* (0x211) */ 0, /* (0x212) */ 0, /* (0x213) */ 0, /* (0x214) */ 0, /* (0x215) */ 0, /* (0x216) */ 0, /* (0x217) */ 0, /* (0x218) */ 0, /* (0x219) */ 0, /* (0x21a) */ 0, /* (0x21b) */ 0, /* (0x21c) */ 0, /* (0x21d) */ 0, /* (0x21e) */ 0, /* (0x21f) */ 0, /* (0x220) */ 0, /* (0x221) */ 0, /* (0x222) */ 0, /* (0x223) */ 0, /* (0x224) */ 0, /* (0x225) */ 0, /* (0x226) */ 0, /* (0x227) */ 0, /* (0x228) */ 0, /* (0x229) */ 0, /* (0x22a) */ 0, /* (0x22b) */ 0, /* (0x22c) */ 0, /* (0x22d) */ 0, /* (0x22e) */ 0, /* (0x22f) */ 0, /* (0x230) */ 0, /* (0x231) */ 0, /* (0x232) */ 0, /* (0x233) */ 0, /* (0x234) */ 0, /* (0x235) */ 0, /* (0x236) */ 0, /* (0x237) */ 0, /* (0x238) */ 0, /* (0x239) */ 0, /* (0x23a) */ 0, /* (0x23b) */ 0, /* (0x23c) */ 0, /* (0x23d) */ 0, /* (0x23e) */ 0, /* (0x23f) */ 0, /* (0x240) */ 0, /* (0x241) */ 0, /* (0x242) */ 0, /* (0x243) */ 0, /* (0x244) */ 0, /* (0x245) */ 0, /* (0x246) */ 0, /* (0x247) */ 0, /* (0x248) */ 0, /* (0x249) */ 0, /* (0x24a) */ 0, /* (0x24b) */ 0, /* (0x24c) */ 0, /* (0x24d) */ 0, /* (0x24e) */ 0, /* (0x24f) */ 0, /* (0x250) */ 0, /* (0x251) */ 0, /* (0x252) */ 0, /* (0x253) */ 0, /* (0x254) */ 0, /* (0x255) */ 0, /* (0x256) */ 0, /* (0x257) */ 0, /* (0x258) */ 0, /* (0x259) */ 0, /* (0x25a) */ 0, /* (0x25b) */ 0, /* (0x25c) */ 0, /* (0x25d) */ 0, /* (0x25e) */ 0, /* (0x25f) */ 0, /* (0x260) */ 0, /* (0x261) */ 0, /* (0x262) */ 0, /* (0x263) */ 0, /* (0x264) */ 0, /* (0x265) */ 0, /* (0x266) */ 0, /* (0x267) */ 0, /* (0x268) */ 0, /* (0x269) */ 0, /* (0x26a) */ 0, /* (0x26b) */ 0, /* (0x26c) */ 0, /* (0x26d) */ 0, /* (0x26e) */ 0, /* (0x26f) */ 0, /* (0x270) */ 0, /* (0x271) */ 0, /* (0x272) */ 0, /* (0x273) */ 0, /* (0x274) */ 0, /* (0x275) */ 0, /* (0x276) */ 0, /* (0x277) */ 0, /* (0x278) */ 0, /* (0x279) */ 0, /* (0x27a) */ 0, /* (0x27b) */ 0, /* (0x27c) */ 0, /* (0x27d) */ 0, /* (0x27e) */ 0, /* (0x27f) */ 0, /* (0x280) */ 0, /* (0x281) */ 0, /* (0x282) */ 0, /* (0x283) */ 0, /* (0x284) */ 0, /* (0x285) */ 0, /* (0x286) */ 0, /* (0x287) */ 0, /* (0x288) */ 0, /* (0x289) */ 0, /* (0x28a) */ 0, /* (0x28b) */ 0, /* (0x28c) */ 0, /* (0x28d) */ 0, /* (0x28e) */ 0, /* (0x28f) */ 0, /* (0x290) */ 0, /* (0x291) */ 0, /* (0x292) */ 0, /* (0x293) */ 0, /* (0x294) */ 0, /* (0x295) */ 0, /* (0x296) */ 0, /* (0x297) */ 0, /* (0x298) */ 0, /* (0x299) */ 0, /* (0x29a) */ 0, /* (0x29b) */ 0, /* (0x29c) */ 0, /* (0x29d) */ 0, /* (0x29e) */ 0, /* (0x29f) */ 0, /* (0x2a0) */ 0, /* (0x2a1) */ 0, /* (0x2a2) */ 0, /* (0x2a3) */ 0, /* (0x2a4) */ 0, /* (0x2a5) */ 0, /* (0x2a6) */ 0, /* (0x2a7) */ 0, /* (0x2a8) */ 0, /* (0x2a9) */ 0, /* (0x2aa) */ 0, /* (0x2ab) */ 0, /* (0x2ac) */ 0, /* (0x2ad) */ 0, /* (0x2ae) */ 0, /* (0x2af) */ 0, /* (0x2b0) */ 0, /* (0x2b1) */ 0, /* (0x2b2) */ 0, /* (0x2b3) */ 0, /* (0x2b4) */ 0, /* (0x2b5) */ 0, /* (0x2b6) */ 0, /* (0x2b7) */ 0, /* (0x2b8) */ 0, /* (0x2b9) */ 0, /* (0x2ba) */ 0, /* (0x2bb) */ 0, /* (0x2bc) */ 0, /* (0x2bd) */ 0, /* (0x2be) */ 0, /* (0x2bf) */ 0, /* (0x2c0) */ 0, /* (0x2c1) */ 0, /* (0x2c2) */ 0, /* (0x2c3) */ 0, /* (0x2c4) */ 0, /* (0x2c5) */ 0, /* (0x2c6) */ 0, /* (0x2c7) */ 0, /* (0x2c8) */ 0, /* (0x2c9) */ 0, /* (0x2ca) */ 0, /* (0x2cb) */ 0, /* (0x2cc) */ 0, /* (0x2cd) */ 0, /* (0x2ce) */ 0, /* (0x2cf) */ 0, /* (0x2d0) */ 0, /* (0x2d1) */ 0, /* (0x2d2) */ 0, /* (0x2d3) */ 0, /* (0x2d4) */ 0, /* (0x2d5) */ 0, /* (0x2d6) */ 0, /* (0x2d7) */ 0, /* (0x2d8) */ 0, /* (0x2d9) */ 0, /* (0x2da) */ 0, /* (0x2db) */ 0, /* (0x2dc) */ 0, /* (0x2dd) */ 0, /* (0x2de) */ 0, /* (0x2df) */ 0, /* (0x2e0) */ 0, /* (0x2e1) */ 0, /* (0x2e2) */ 0, /* (0x2e3) */ 0, /* (0x2e4) */ 0, /* (0x2e5) */ 0, /* (0x2e6) */ 0, /* (0x2e7) */ 0, /* (0x2e8) */ 0, /* (0x2e9) */ 0, /* (0x2ea) */ 0, /* (0x2eb) */ 0, /* (0x2ec) */ 0, /* (0x2ed) */ 0, /* (0x2ee) */ 0, /* (0x2ef) */ 0, /* (0x2f0) */ 0, /* (0x2f1) */ 0, /* (0x2f2) */ 0, /* (0x2f3) */ 0, /* (0x2f4) */ 0, /* (0x2f5) */ 0, /* (0x2f6) */ 0, /* (0x2f7) */ 0, /* (0x2f8) */ 0, /* (0x2f9) */ 0, /* (0x2fa) */ 0, /* (0x2fb) */ 0, /* (0x2fc) */ 0, /* (0x2fd) */ 0, /* (0x2fe) */ 0, /* (0x2ff) */ 0, /* (0x300) */ 0, /* (0x301) */ 0, /* (0x302) */ 0, /* (0x303) */ 0, /* (0x304) */ 0, /* (0x305) */ 0, /* (0x306) */ 0, /* (0x307) */ 0, /* (0x308) */ 0, /* (0x309) */ 0, /* (0x30a) */ 0, /* (0x30b) */ 0, /* (0x30c) */ 0, /* (0x30d) */ 0, /* (0x30e) */ 0, /* (0x30f) */ 0, /* (0x310) */ 0, /* (0x311) */ 0, /* (0x312) */ 0, /* (0x313) */ 0, /* (0x314) */ 0, /* (0x315) */ 0, /* (0x316) */ 0, /* (0x317) */ 0, /* (0x318) */ 0, /* (0x319) */ 0, /* (0x31a) */ 0, /* (0x31b) */ 0, /* (0x31c) */ 0, /* (0x31d) */ 0, /* (0x31e) */ 0, /* (0x31f) */ 0, /* (0x320) */ 0, /* (0x321) */ 0, /* (0x322) */ 0, /* (0x323) */ 0, /* (0x324) */ 0, /* (0x325) */ 0, /* (0x326) */ 0, /* (0x327) */ 0, /* (0x328) */ 0, /* (0x329) */ 0, /* (0x32a) */ 0, /* (0x32b) */ 0, /* (0x32c) */ 0, /* (0x32d) */ 0, /* (0x32e) */ 0, /* (0x32f) */ 0, /* (0x330) */ 0, /* (0x331) */ 0, /* (0x332) */ 0, /* (0x333) */ 0, /* (0x334) */ 0, /* (0x335) */ 0, /* (0x336) */ 0, /* (0x337) */ 0, /* (0x338) */ 0, /* (0x339) */ 0, /* (0x33a) */ 0, /* (0x33b) */ 0, /* (0x33c) */ 0, /* (0x33d) */ 0, /* (0x33e) */ 0, /* (0x33f) */ 0, /* (0x340) */ 0, /* (0x341) */ 0, /* (0x342) */ 0, /* (0x343) */ 0, /* (0x344) */ 0, /* (0x345) */ 0, /* (0x346) */ 0, /* (0x347) */ 0, /* (0x348) */ 0, /* (0x349) */ 0, /* (0x34a) */ 0, /* (0x34b) */ 0, /* (0x34c) */ 0, /* (0x34d) */ 0, /* (0x34e) */ 0, /* (0x34f) */ 0, /* (0x350) */ 0, /* (0x351) */ 0, /* (0x352) */ 0, /* (0x353) */ 0, /* (0x354) */ 0, /* (0x355) */ 0, /* (0x356) */ 0, /* (0x357) */ 0, /* (0x358) */ 0, /* (0x359) */ 0, /* (0x35a) */ 0, /* (0x35b) */ 0, /* (0x35c) */ 0, /* (0x35d) */ 0, /* (0x35e) */ 0, /* (0x35f) */ 0, /* (0x360) */ 0, /* (0x361) */ 0, /* (0x362) */ 0, /* (0x363) */ 0, /* (0x364) */ 0, /* (0x365) */ 0, /* (0x366) */ 0, /* (0x367) */ 0, /* (0x368) */ 0, /* (0x369) */ 0, /* (0x36a) */ 0, /* (0x36b) */ 0, /* (0x36c) */ 0, /* (0x36d) */ 0, /* (0x36e) */ 0, /* (0x36f) */ 0, /* (0x370) */ 0, /* (0x371) */ 0, /* (0x372) */ 0, /* (0x373) */ 0, /* (0x374) */ 0, /* (0x375) */ 0, /* (0x376) */ 0, /* (0x377) */ 0, /* (0x378) */ 0, /* (0x379) */ 0, /* (0x37a) */ 0, /* (0x37b) */ 0, /* (0x37c) */ 0, /* (0x37d) */ 0, /* (0x37e) */ 0, /* (0x37f) */ 0, /* (0x380) */ 0, /* (0x381) */ 0, /* (0x382) */ 0, /* (0x383) */ 0, /* (0x384) */ 0, /* (0x385) */ 0, /* (0x386) */ 0, /* (0x387) */ 0, /* (0x388) */ 0, /* (0x389) */ 0, /* (0x38a) */ 0, /* (0x38b) */ 0, /* (0x38c) */ 0, /* (0x38d) */ 0, /* (0x38e) */ 0, /* (0x38f) */ 0, /* (0x390) */ 0, /* (0x391) */ 0, /* (0x392) */ 0, /* (0x393) */ 0, /* (0x394) */ 0, /* (0x395) */ 0, /* (0x396) */ 0, /* (0x397) */ 0, /* (0x398) */ 0, /* (0x399) */ 0, /* (0x39a) */ 0, /* (0x39b) */ 0, /* (0x39c) */ 0, /* (0x39d) */ 0, /* (0x39e) */ 0, /* (0x39f) */ 0, /* (0x3a0) */ 0, /* (0x3a1) */ 0, /* (0x3a2) */ 0, /* (0x3a3) */ 0, /* (0x3a4) */ 0, /* (0x3a5) */ 0, /* (0x3a6) */ 0, /* (0x3a7) */ 0, /* (0x3a8) */ 0, /* (0x3a9) */ 0, /* (0x3aa) */ 0, /* (0x3ab) */ 0, /* (0x3ac) */ 0, /* (0x3ad) */ 0, /* (0x3ae) */ 0, /* (0x3af) */ 0, /* (0x3b0) */ 0, /* (0x3b1) */ 0, /* (0x3b2) */ 0, /* (0x3b3) */ 0, /* (0x3b4) */ 0, /* (0x3b5) */ 0, /* (0x3b6) */ 0, /* (0x3b7) */ 0, /* (0x3b8) */ 0, /* (0x3b9) */ 0, /* (0x3ba) */ 0, /* (0x3bb) */ 0, /* (0x3bc) */ 0, /* (0x3bd) */ 0, /* (0x3be) */ 0, /* (0x3bf) */ 0, /* (0x3c0) */ 0, /* (0x3c1) */ 0, /* (0x3c2) */ 0, /* (0x3c3) */ 0, /* (0x3c4) */ 0, /* (0x3c5) */ 0, /* (0x3c6) */ 0, /* (0x3c7) */ 0, /* (0x3c8) */ 0, /* (0x3c9) */ 0, /* (0x3ca) */ 0, /* (0x3cb) */ 0, /* (0x3cc) */ 0, /* (0x3cd) */ 0, /* (0x3ce) */ 0, /* (0x3cf) */ 0, /* (0x3d0) */ 0, /* (0x3d1) */ 0, /* (0x3d2) */ 0, /* (0x3d3) */ 0, /* (0x3d4) */ 0, /* (0x3d5) */ 0, /* (0x3d6) */ 0, /* (0x3d7) */ 0, /* (0x3d8) */ 0, /* (0x3d9) */ 0, /* (0x3da) */ 0, /* (0x3db) */ 0, /* (0x3dc) */ 0, /* (0x3dd) */ 0, /* (0x3de) */ 0, /* (0x3df) */ 0, /* (0x3e0) */ 0, /* (0x3e1) */ 0, /* (0x3e2) */ 0, /* (0x3e3) */ 0, /* (0x3e4) */ 0, /* (0x3e5) */ 0, /* (0x3e6) */ 0, /* (0x3e7) */ 0, /* (0x3e8) */ 0, /* (0x3e9) */ 0, /* (0x3ea) */ 0, /* (0x3eb) */ 0, /* (0x3ec) */ 0, /* (0x3ed) */ 0, /* (0x3ee) */ 0, /* (0x3ef) */ 0, /* (0x3f0) */ 0, /* (0x3f1) */ 0, /* (0x3f2) */ 0, /* (0x3f3) */ 0, /* (0x3f4) */ 0, /* (0x3f5) */ 0, /* (0x3f6) */ 0, /* (0x3f7) */ 0, /* (0x3f8) */ 0, /* (0x3f9) */ 0, /* (0x3fa) */ 0, /* (0x3fb) */ 0, /* (0x3fc) */ 0, /* (0x3fd) */ 0, /* (0x3fe) */ 0, /* (0x3ff) */ 0, /* (0x400) */ 0, /* (0x401) */ 0, /* (0x402) */ 0, /* (0x403) */ 0, /* (0x404) */ 0, /* (0x405) */ 0, /* (0x406) */ 0, /* (0x407) */ 0, /* (0x408) */ 0, /* (0x409) */ 0, /* (0x40a) */ 0, /* (0x40b) */ 0, /* (0x40c) */ 0, /* (0x40d) */ 0, /* (0x40e) */ 0, /* (0x40f) */ 864, /* (0x410) */ 873, /* (0x411) */ 882, /* (0x412) */ 891, /* (0x413) */ 900, /* (0x414) */ 909, /* (0x415) */ 918, /* (0x416) */ 927, /* (0x417) */ 936, /* (0x418) */ 945, /* (0x419) */ 954, /* (0x41a) */ 963, /* (0x41b) */ 972, /* (0x41c) */ 981, /* (0x41d) */ 990, /* (0x41e) */ 999, /* (0x41f) */ 1008, /* (0x420) */ 1017, /* (0x421) */ 1026, /* (0x422) */ 1035, /* (0x423) */ 1044, /* (0x424) */ 1053, /* (0x425) */ 1062, /* (0x426) */ 1071, /* (0x427) */ 1080, /* (0x428) */ 1089, /* (0x429) */ 1098, /* (0x42a) */ 1107, /* (0x42b) */ 1116, /* (0x42c) */ 1125, /* (0x42d) */ 1134, /* (0x42e) */ 1143, /* (0x42f) */ 1152, /* (0x430) */ 1161, /* (0x431) */ 1170, /* (0x432) */ 1179, /* (0x433) */ 1188, /* (0x434) */ 1197, /* (0x435) */ 1206, /* (0x436) */ 1215, /* (0x437) */ 1224, /* (0x438) */ 1233, /* (0x439) */ 1242, /* (0x43a) */ 1251, /* (0x43b) */ 1260, /* (0x43c) */ 1269, /* (0x43d) */ 1278, /* (0x43e) */ 1287, /* (0x43f) */ 1296, /* (0x440) */ 1305, /* (0x441) */ 1314, /* (0x442) */ 1323, /* (0x443) */ 1332, /* (0x444) */ 1341, /* (0x445) */ 1350, /* (0x446) */ 1359, /* (0x447) */ 1368, /* (0x448) */ 1377, /* (0x449) */ 1386, /* (0x44a) */ 1395, /* (0x44b) */ 1404, /* (0x44c) */ 1413, /* (0x44d) */ 1422, /* (0x44e) */ 1431, /* (0x44f) */ }; /* Exported structure definition. */ const struct gpanel_font_t font_6x9 = { "6x9", 6, 9, 7, 0, 1104, _6x9_bits, _6x9_offset, 0, /* fixed width*/ 0, sizeof(_6x9_bits) / sizeof(_6x9_bits[0]), }; ================================================ FILE: share/examples/gpanel/fonts/Makefile ================================================ CFLAGS = -Wall -O -g LDFLAGS = -L/opt/local/lib -lpng FONTS = digits32.c \ digits20.c \ lucidasans11.c \ lucidasans15.c \ lucidasans9.c \ lucidasans7.c \ verdana7.c \ 5x7.c \ 6x9.c # Latin CHARSET = 20_126 164 # Cyrillics: Ё, ё, А-я #CHARSET += 1025 1105 1040_1103 all: $(FONTS) compile: $(FONTS) $(CC) -c $(FONTS) size *.o # Get Lucida_Sans_Unicode.ttf from internet free font collection: # http://www.webpagepublicity.com/free-fonts/l/Lucida%20Sans%20Unicode.ttf # Use otf2bdf utility from ftp://crl.nmsu.edu/CLR/multiling/General/ # Under Ubuntu, install otf2bdf package. digits32.c: convbdf ttf/Lucida_Sans_Unicode.ttf -otf2bdf -p 32 -l "32 48_58" ttf/Lucida_Sans_Unicode.ttf > digits32.bdf ./convbdf -a12 -d15 digits32.bdf rm -f digits32.bdf digits20.c: convbdf ttf/Lucida_Sans_Unicode.ttf -otf2bdf -p 20 -l "32 48_58" ttf/Lucida_Sans_Unicode.ttf > digits20.bdf ./convbdf -a9 -d11 digits20.bdf rm -f digits20.bdf lucidasans11.c: convbdf ttf/Lucida_Sans_Unicode.ttf -otf2bdf -p 11 -l "$(CHARSET)" ttf/Lucida_Sans_Unicode.ttf > lucidasans11.bdf ./convbdf -u164 -a2 -d3 lucidasans11.bdf rm -f lucidasans11.bdf lucidasans15.c: convbdf ttf/Lucida_Sans_Unicode.ttf -otf2bdf -p 15 -l "$(CHARSET)" ttf/Lucida_Sans_Unicode.ttf > lucidasans15.bdf ./convbdf -u164 -a5 -d5 lucidasans15.bdf rm -f lucidasans15.bdf lucidasans28.c: convbdf ttf/Lucida_Sans_Unicode.ttf -otf2bdf -p 28 -l "$(CHARSET)" ttf/Lucida_Sans_Unicode.ttf > lucidasans28.bdf ./convbdf -u164 -a11 -d9 lucidasans28.bdf rm -f lucidasans28.bdf lucidasans9.c: convbdf ttf/Lucida_Sans_Unicode.ttf -otf2bdf -p 9 -l "$(CHARSET)" ttf/Lucida_Sans_Unicode.ttf > lucidasans9.bdf ./convbdf -u164 -a2 -d3 lucidasans9.bdf rm -f lucidasans9.bdf lucidasans7.c: convbdf ttf/Lucida_Sans_Unicode.ttf -otf2bdf -p 7 -l "$(CHARSET)" ttf/Lucida_Sans_Unicode.ttf > lucidasans7.bdf ./convbdf -u164 -a2 -d3 lucidasans7.bdf rm -f lucidasans7.bdf # Use /usr/share/fonts/truetype/msttcorefonts/Verdana.ttf verdana7.c: convbdf ttf/Verdana.ttf -otf2bdf -p 7 -l "$(CHARSET)" ttf/Verdana.ttf > verdana7.bdf ./convbdf -a2 verdana7.bdf rm -f verdana7.bdf 5x7.c: convbdf bdf/5x7.bdf ./convbdf -u0 -l0x44f -x0xa0-0x40f bdf/5x7.bdf 6x9.c: convbdf bdf/6x9.bdf ./convbdf -u0 -l0x44f -x0xa0-0x40f bdf/6x9.bdf clean: -rm -f *~ *.o convbdf clean-all: clean -rm -f $(FONTS) ================================================ FILE: share/examples/gpanel/fonts/bdf/5x7.bdf ================================================ STARTFONT 2.1 COMMENT "$Id: 5x7.bdf,v 1.38 2006-01-05 20:03:17+00 mgk25 Rel $" COMMENT "Send bug reports to Markus Kuhn " FONT -Misc-Fixed-Medium-R-Normal--7-70-75-75-C-50-ISO10646-1 SIZE 7 75 75 FONTBOUNDINGBOX 5 7 0 -1 STARTPROPERTIES 23 FONTNAME_REGISTRY "" FOUNDRY "Misc" FAMILY_NAME "Fixed" WEIGHT_NAME "Medium" SLANT "R" SETWIDTH_NAME "Normal" ADD_STYLE_NAME "" PIXEL_SIZE 7 POINT_SIZE 70 RESOLUTION_X 75 RESOLUTION_Y 75 SPACING "C" AVERAGE_WIDTH 50 CHARSET_REGISTRY "ISO10646" CHARSET_ENCODING "1" FONT_ASCENT 6 FONT_DESCENT 1 DESTINATION 1 DEFAULT_CHAR 0 COPYRIGHT "Public domain font. Share and enjoy." _XMBDFED_INFO "Edited with xmbdfed 4.5." CAP_HEIGHT 6 X_HEIGHT 4 ENDPROPERTIES CHARS 1848 STARTCHAR char0 ENCODING 0 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 A8 00 88 00 A8 00 ENDCHAR STARTCHAR space ENCODING 32 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 00 00 00 00 00 ENDCHAR STARTCHAR exclam ENCODING 33 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 20 20 20 00 20 00 ENDCHAR STARTCHAR quotedbl ENCODING 34 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 50 50 00 00 00 00 ENDCHAR STARTCHAR numbersign ENCODING 35 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 50 F8 50 F8 50 00 ENDCHAR STARTCHAR dollar ENCODING 36 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 70 A0 70 28 70 00 ENDCHAR STARTCHAR percent ENCODING 37 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 80 90 20 40 90 10 00 ENDCHAR STARTCHAR ampersand ENCODING 38 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 40 A0 40 A0 50 00 ENDCHAR STARTCHAR quotesingle ENCODING 39 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 20 20 00 00 00 00 ENDCHAR STARTCHAR parenleft ENCODING 40 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 40 40 40 40 20 00 ENDCHAR STARTCHAR parenright ENCODING 41 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 20 20 20 20 40 00 ENDCHAR STARTCHAR asterisk ENCODING 42 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 50 20 70 20 50 00 ENDCHAR STARTCHAR plus ENCODING 43 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 20 20 F8 20 20 00 ENDCHAR STARTCHAR comma ENCODING 44 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 00 00 30 20 40 ENDCHAR STARTCHAR hyphen ENCODING 45 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 00 F0 00 00 00 ENDCHAR STARTCHAR period ENCODING 46 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 00 00 60 60 00 ENDCHAR STARTCHAR slash ENCODING 47 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 10 20 40 80 00 00 ENDCHAR STARTCHAR zero ENCODING 48 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 50 50 50 50 20 00 ENDCHAR STARTCHAR one ENCODING 49 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 60 20 20 20 70 00 ENDCHAR STARTCHAR two ENCODING 50 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 90 10 20 40 F0 00 ENDCHAR STARTCHAR three ENCODING 51 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP F0 10 60 10 90 60 00 ENDCHAR STARTCHAR four ENCODING 52 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 60 A0 F0 20 20 00 ENDCHAR STARTCHAR five ENCODING 53 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP F0 80 E0 10 90 60 00 ENDCHAR STARTCHAR six ENCODING 54 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 80 E0 90 90 60 00 ENDCHAR STARTCHAR seven ENCODING 55 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP F0 10 20 20 40 40 00 ENDCHAR STARTCHAR eight ENCODING 56 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 90 60 90 90 60 00 ENDCHAR STARTCHAR nine ENCODING 57 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 90 90 70 10 60 00 ENDCHAR STARTCHAR colon ENCODING 58 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 60 60 00 60 60 00 ENDCHAR STARTCHAR semicolon ENCODING 59 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 60 60 00 60 40 80 ENDCHAR STARTCHAR less ENCODING 60 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 10 20 40 20 10 00 ENDCHAR STARTCHAR equal ENCODING 61 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 F0 00 F0 00 00 ENDCHAR STARTCHAR greater ENCODING 62 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 40 20 10 20 40 00 ENDCHAR STARTCHAR question ENCODING 63 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 50 10 20 00 20 00 ENDCHAR STARTCHAR at ENCODING 64 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 90 B0 B0 80 60 00 ENDCHAR STARTCHAR A ENCODING 65 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 90 90 F0 90 90 00 ENDCHAR STARTCHAR B ENCODING 66 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP E0 90 E0 90 90 E0 00 ENDCHAR STARTCHAR C ENCODING 67 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 90 80 80 90 60 00 ENDCHAR STARTCHAR D ENCODING 68 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP E0 90 90 90 90 E0 00 ENDCHAR STARTCHAR E ENCODING 69 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP F0 80 E0 80 80 F0 00 ENDCHAR STARTCHAR F ENCODING 70 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP F0 80 E0 80 80 80 00 ENDCHAR STARTCHAR G ENCODING 71 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 90 80 B0 90 70 00 ENDCHAR STARTCHAR H ENCODING 72 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 90 90 F0 90 90 90 00 ENDCHAR STARTCHAR I ENCODING 73 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 70 20 20 20 20 70 00 ENDCHAR STARTCHAR J ENCODING 74 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 10 10 10 90 60 00 ENDCHAR STARTCHAR K ENCODING 75 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 90 A0 C0 C0 A0 90 00 ENDCHAR STARTCHAR L ENCODING 76 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 80 80 80 80 80 F0 00 ENDCHAR STARTCHAR M ENCODING 77 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 90 F0 F0 90 90 90 00 ENDCHAR STARTCHAR N ENCODING 78 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 90 D0 D0 B0 B0 90 00 ENDCHAR STARTCHAR O ENCODING 79 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 90 90 90 90 60 00 ENDCHAR STARTCHAR P ENCODING 80 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP E0 90 90 E0 80 80 00 ENDCHAR STARTCHAR Q ENCODING 81 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 90 90 90 D0 60 10 ENDCHAR STARTCHAR R ENCODING 82 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP E0 90 90 E0 A0 90 00 ENDCHAR STARTCHAR S ENCODING 83 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 90 40 20 90 60 00 ENDCHAR STARTCHAR T ENCODING 84 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 70 20 20 20 20 20 00 ENDCHAR STARTCHAR U ENCODING 85 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 90 90 90 90 90 60 00 ENDCHAR STARTCHAR V ENCODING 86 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 90 90 90 90 60 60 00 ENDCHAR STARTCHAR W ENCODING 87 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 90 90 90 F0 F0 90 00 ENDCHAR STARTCHAR X ENCODING 88 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 90 90 60 60 90 90 00 ENDCHAR STARTCHAR Y ENCODING 89 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 50 50 20 20 20 00 ENDCHAR STARTCHAR Z ENCODING 90 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP F0 10 20 40 80 F0 00 ENDCHAR STARTCHAR bracketleft ENCODING 91 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 70 40 40 40 40 70 00 ENDCHAR STARTCHAR backslash ENCODING 92 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 80 40 20 10 00 00 ENDCHAR STARTCHAR bracketright ENCODING 93 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 70 10 10 10 10 70 00 ENDCHAR STARTCHAR asciicircum ENCODING 94 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 50 00 00 00 00 00 ENDCHAR STARTCHAR underscore ENCODING 95 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 00 00 00 F0 00 ENDCHAR STARTCHAR grave ENCODING 96 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 20 00 00 00 00 00 ENDCHAR STARTCHAR a ENCODING 97 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 70 90 B0 50 00 ENDCHAR STARTCHAR b ENCODING 98 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 80 80 E0 90 90 E0 00 ENDCHAR STARTCHAR c ENCODING 99 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 60 80 80 60 00 ENDCHAR STARTCHAR d ENCODING 100 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 10 70 90 90 70 00 ENDCHAR STARTCHAR e ENCODING 101 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 60 B0 C0 60 00 ENDCHAR STARTCHAR f ENCODING 102 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 50 40 E0 40 40 00 ENDCHAR STARTCHAR g ENCODING 103 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 70 90 60 80 70 ENDCHAR STARTCHAR h ENCODING 104 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 80 80 E0 90 90 90 00 ENDCHAR STARTCHAR i ENCODING 105 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 00 60 20 20 70 00 ENDCHAR STARTCHAR j ENCODING 106 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 00 10 10 10 50 20 ENDCHAR STARTCHAR k ENCODING 107 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 80 80 A0 C0 A0 90 00 ENDCHAR STARTCHAR l ENCODING 108 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 20 20 20 20 70 00 ENDCHAR STARTCHAR m ENCODING 109 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 A0 F0 90 90 00 ENDCHAR STARTCHAR n ENCODING 110 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 E0 90 90 90 00 ENDCHAR STARTCHAR o ENCODING 111 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 60 90 90 60 00 ENDCHAR STARTCHAR p ENCODING 112 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 E0 90 90 E0 80 ENDCHAR STARTCHAR q ENCODING 113 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 70 90 90 70 10 ENDCHAR STARTCHAR r ENCODING 114 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 E0 90 80 80 00 ENDCHAR STARTCHAR s ENCODING 115 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 70 C0 30 E0 00 ENDCHAR STARTCHAR t ENCODING 116 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 40 E0 40 40 30 00 ENDCHAR STARTCHAR u ENCODING 117 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 90 90 90 70 00 ENDCHAR STARTCHAR v ENCODING 118 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 50 50 50 20 00 ENDCHAR STARTCHAR w ENCODING 119 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 90 90 F0 F0 00 ENDCHAR STARTCHAR x ENCODING 120 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 90 60 60 90 00 ENDCHAR STARTCHAR y ENCODING 121 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 90 90 50 20 40 ENDCHAR STARTCHAR z ENCODING 122 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 F0 20 40 F0 00 ENDCHAR STARTCHAR braceleft ENCODING 123 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 20 60 20 20 10 00 ENDCHAR STARTCHAR bar ENCODING 124 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 20 20 20 20 20 00 ENDCHAR STARTCHAR braceright ENCODING 125 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 20 30 20 20 40 00 ENDCHAR STARTCHAR asciitilde ENCODING 126 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 A0 00 00 00 00 00 ENDCHAR STARTCHAR space ENCODING 160 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 00 00 00 00 00 ENDCHAR STARTCHAR exclamdown ENCODING 161 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 00 20 20 20 20 00 ENDCHAR STARTCHAR cent ENCODING 162 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 20 70 A0 A0 70 20 ENDCHAR STARTCHAR sterling ENCODING 163 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 30 40 E0 40 B0 00 ENDCHAR STARTCHAR currency ENCODING 164 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 88 70 50 70 88 00 ENDCHAR STARTCHAR yen ENCODING 165 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 50 20 70 20 20 00 ENDCHAR STARTCHAR brokenbar ENCODING 166 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 20 20 00 20 20 00 ENDCHAR STARTCHAR section ENCODING 167 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 30 40 60 50 30 10 60 ENDCHAR STARTCHAR dieresis ENCODING 168 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 00 00 00 00 00 00 ENDCHAR STARTCHAR copyright ENCODING 169 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 70 88 A8 C8 A8 88 70 ENDCHAR STARTCHAR ordfeminine ENCODING 170 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 A0 60 00 00 00 00 ENDCHAR STARTCHAR guillemotleft ENCODING 171 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 48 90 48 00 00 ENDCHAR STARTCHAR logicalnot ENCODING 172 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 00 F0 10 00 00 ENDCHAR STARTCHAR hyphen ENCODING 173 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 00 70 00 00 00 ENDCHAR STARTCHAR registered ENCODING 174 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 70 88 E8 C8 C8 88 70 ENDCHAR STARTCHAR macron ENCODING 175 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP F0 00 00 00 00 00 00 ENDCHAR STARTCHAR degree ENCODING 176 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 50 20 00 00 00 00 ENDCHAR STARTCHAR plusminus ENCODING 177 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 20 F8 20 20 F8 00 ENDCHAR STARTCHAR twosuperior ENCODING 178 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 20 40 60 00 00 00 ENDCHAR STARTCHAR threesuperior ENCODING 179 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 60 20 60 00 00 00 ENDCHAR STARTCHAR acute ENCODING 180 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 40 00 00 00 00 00 ENDCHAR STARTCHAR mu ENCODING 181 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 90 90 90 E0 80 ENDCHAR STARTCHAR paragraph ENCODING 182 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 70 D0 D0 50 50 50 00 ENDCHAR STARTCHAR periodcentered ENCODING 183 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 60 60 00 00 00 ENDCHAR STARTCHAR cedilla ENCODING 184 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 00 00 00 20 40 ENDCHAR STARTCHAR onesuperior ENCODING 185 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 60 20 70 00 00 00 ENDCHAR STARTCHAR ordmasculine ENCODING 186 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 A0 40 00 00 00 00 ENDCHAR STARTCHAR guillemotright ENCODING 187 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 90 48 90 00 00 ENDCHAR STARTCHAR onequarter ENCODING 188 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 80 80 80 90 30 70 10 ENDCHAR STARTCHAR onehalf ENCODING 189 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 80 80 80 B0 10 20 30 ENDCHAR STARTCHAR threequarters ENCODING 190 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP C0 C0 40 D0 30 70 10 ENDCHAR STARTCHAR questiondown ENCODING 191 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 00 20 40 50 20 00 ENDCHAR STARTCHAR Agrave ENCODING 192 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 90 90 F0 90 90 00 ENDCHAR STARTCHAR Aacute ENCODING 193 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 90 90 F0 90 90 00 ENDCHAR STARTCHAR Acircumflex ENCODING 194 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 90 90 F0 90 90 00 ENDCHAR STARTCHAR Atilde ENCODING 195 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 90 90 F0 90 90 00 ENDCHAR STARTCHAR Adieresis ENCODING 196 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 90 60 90 F0 90 90 00 ENDCHAR STARTCHAR Aring ENCODING 197 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 60 90 F0 90 90 00 ENDCHAR STARTCHAR AE ENCODING 198 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 70 A0 B0 E0 A0 B0 00 ENDCHAR STARTCHAR Ccedilla ENCODING 199 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 90 80 80 90 60 40 ENDCHAR STARTCHAR Egrave ENCODING 200 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP F0 80 E0 80 80 F0 00 ENDCHAR STARTCHAR Eacute ENCODING 201 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP F0 80 E0 80 80 F0 00 ENDCHAR STARTCHAR Ecircumflex ENCODING 202 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP F0 80 E0 80 80 F0 00 ENDCHAR STARTCHAR Edieresis ENCODING 203 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP F0 80 E0 80 80 F0 00 ENDCHAR STARTCHAR Igrave ENCODING 204 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 70 20 20 20 20 70 00 ENDCHAR STARTCHAR Iacute ENCODING 205 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 70 20 20 20 20 70 00 ENDCHAR STARTCHAR Icircumflex ENCODING 206 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 70 20 20 20 20 70 00 ENDCHAR STARTCHAR Idieresis ENCODING 207 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 70 20 20 20 20 70 00 ENDCHAR STARTCHAR Eth ENCODING 208 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP E0 50 D0 50 50 E0 00 ENDCHAR STARTCHAR Ntilde ENCODING 209 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP B0 90 D0 B0 B0 90 00 ENDCHAR STARTCHAR Ograve ENCODING 210 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 90 90 90 90 60 00 ENDCHAR STARTCHAR Oacute ENCODING 211 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 90 90 90 90 60 00 ENDCHAR STARTCHAR Ocircumflex ENCODING 212 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 90 90 90 90 60 00 ENDCHAR STARTCHAR Otilde ENCODING 213 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 90 90 90 90 60 00 ENDCHAR STARTCHAR Odieresis ENCODING 214 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 90 60 90 90 90 60 00 ENDCHAR STARTCHAR multiply ENCODING 215 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 90 60 60 90 00 ENDCHAR STARTCHAR Oslash ENCODING 216 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 70 B0 B0 D0 D0 E0 00 ENDCHAR STARTCHAR Ugrave ENCODING 217 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 90 90 90 90 90 60 00 ENDCHAR STARTCHAR Uacute ENCODING 218 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 90 90 90 90 90 60 00 ENDCHAR STARTCHAR Ucircumflex ENCODING 219 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 90 90 90 90 90 60 00 ENDCHAR STARTCHAR Udieresis ENCODING 220 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 90 00 90 90 90 60 00 ENDCHAR STARTCHAR Yacute ENCODING 221 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 50 50 20 20 20 00 ENDCHAR STARTCHAR Thorn ENCODING 222 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 80 E0 90 E0 80 80 00 ENDCHAR STARTCHAR germandbls ENCODING 223 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 90 A0 90 90 A0 00 ENDCHAR STARTCHAR agrave ENCODING 224 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 20 70 90 B0 50 00 ENDCHAR STARTCHAR aacute ENCODING 225 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 40 70 90 B0 50 00 ENDCHAR STARTCHAR acircumflex ENCODING 226 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 50 70 90 B0 50 00 ENDCHAR STARTCHAR atilde ENCODING 227 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 A0 70 90 B0 50 00 ENDCHAR STARTCHAR adieresis ENCODING 228 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 00 70 90 B0 50 00 ENDCHAR STARTCHAR aring ENCODING 229 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 60 70 90 B0 50 00 ENDCHAR STARTCHAR ae ENCODING 230 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 70 B0 A0 70 00 ENDCHAR STARTCHAR ccedilla ENCODING 231 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 30 40 40 30 20 ENDCHAR STARTCHAR egrave ENCODING 232 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 20 60 B0 C0 60 00 ENDCHAR STARTCHAR eacute ENCODING 233 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 40 60 B0 C0 60 00 ENDCHAR STARTCHAR ecircumflex ENCODING 234 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 A0 60 B0 C0 60 00 ENDCHAR STARTCHAR edieresis ENCODING 235 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP A0 00 60 B0 C0 60 00 ENDCHAR STARTCHAR igrave ENCODING 236 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 20 60 20 20 70 00 ENDCHAR STARTCHAR iacute ENCODING 237 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 40 60 20 20 70 00 ENDCHAR STARTCHAR icircumflex ENCODING 238 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 50 60 20 20 70 00 ENDCHAR STARTCHAR idieresis ENCODING 239 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 00 60 20 20 70 00 ENDCHAR STARTCHAR eth ENCODING 240 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 30 60 90 90 60 00 ENDCHAR STARTCHAR ntilde ENCODING 241 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 A0 E0 90 90 90 00 ENDCHAR STARTCHAR ograve ENCODING 242 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 20 60 90 90 60 00 ENDCHAR STARTCHAR oacute ENCODING 243 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 40 60 90 90 60 00 ENDCHAR STARTCHAR ocircumflex ENCODING 244 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 00 60 90 90 60 00 ENDCHAR STARTCHAR otilde ENCODING 245 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 A0 60 90 90 60 00 ENDCHAR STARTCHAR odieresis ENCODING 246 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 00 60 90 90 60 00 ENDCHAR STARTCHAR divide ENCODING 247 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 60 00 F0 00 60 00 ENDCHAR STARTCHAR oslash ENCODING 248 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 70 B0 D0 E0 00 ENDCHAR STARTCHAR ugrave ENCODING 249 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 20 90 90 90 70 00 ENDCHAR STARTCHAR uacute ENCODING 250 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 40 90 90 90 70 00 ENDCHAR STARTCHAR ucircumflex ENCODING 251 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 00 90 90 90 70 00 ENDCHAR STARTCHAR udieresis ENCODING 252 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 00 90 90 90 70 00 ENDCHAR STARTCHAR yacute ENCODING 253 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 40 90 90 50 20 40 ENDCHAR STARTCHAR thorn ENCODING 254 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 80 E0 90 90 E0 80 ENDCHAR STARTCHAR ydieresis ENCODING 255 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 00 90 90 50 20 40 ENDCHAR STARTCHAR Amacron ENCODING 256 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 90 90 F0 90 90 00 ENDCHAR STARTCHAR amacron ENCODING 257 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 70 00 70 90 B0 50 00 ENDCHAR STARTCHAR Abreve ENCODING 258 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 90 90 F0 90 90 00 ENDCHAR STARTCHAR abreve ENCODING 259 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 90 60 70 90 B0 50 00 ENDCHAR STARTCHAR Aogonek ENCODING 260 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 90 90 F0 90 90 10 ENDCHAR STARTCHAR aogonek ENCODING 261 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 70 90 B0 50 08 ENDCHAR STARTCHAR Cacute ENCODING 262 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 90 80 80 90 60 00 ENDCHAR STARTCHAR cacute ENCODING 263 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 20 30 40 40 30 00 ENDCHAR STARTCHAR Ccircumflex ENCODING 264 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 90 80 80 90 60 00 ENDCHAR STARTCHAR ccircumflex ENCODING 265 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 00 60 80 80 60 00 ENDCHAR STARTCHAR Cdotaccent ENCODING 266 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 90 80 80 90 60 00 ENDCHAR STARTCHAR cdotaccent ENCODING 267 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 00 60 80 80 60 00 ENDCHAR STARTCHAR Ccaron ENCODING 268 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 90 80 80 90 60 00 ENDCHAR STARTCHAR ccaron ENCODING 269 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP A0 40 60 80 80 60 00 ENDCHAR STARTCHAR Dcaron ENCODING 270 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP E0 90 90 90 90 E0 00 ENDCHAR STARTCHAR dcaron ENCODING 271 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP A0 50 10 70 90 70 00 ENDCHAR STARTCHAR Dcroat ENCODING 272 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP E0 90 D0 90 90 E0 00 ENDCHAR STARTCHAR dcroat ENCODING 273 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 38 10 70 90 70 00 ENDCHAR STARTCHAR Emacron ENCODING 274 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP F0 80 E0 80 80 F0 00 ENDCHAR STARTCHAR emacron ENCODING 275 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP E0 00 60 B0 C0 60 00 ENDCHAR STARTCHAR Ebreve ENCODING 276 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP F0 80 E0 80 80 F0 00 ENDCHAR STARTCHAR ebreve ENCODING 277 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 90 60 60 B0 C0 60 00 ENDCHAR STARTCHAR Edotaccent ENCODING 278 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP F0 80 E0 80 80 F0 00 ENDCHAR STARTCHAR edotaccent ENCODING 279 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 00 60 B0 C0 60 00 ENDCHAR STARTCHAR Eogonek ENCODING 280 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP F0 80 E0 80 80 F0 40 ENDCHAR STARTCHAR eogonek ENCODING 281 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 60 B0 C0 60 40 ENDCHAR STARTCHAR Ecaron ENCODING 282 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP F0 80 E0 80 80 F0 00 ENDCHAR STARTCHAR ecaron ENCODING 283 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP A0 40 60 B0 C0 60 00 ENDCHAR STARTCHAR Gcircumflex ENCODING 284 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 90 80 B0 90 70 00 ENDCHAR STARTCHAR gcircumflex ENCODING 285 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 00 70 90 60 80 70 ENDCHAR STARTCHAR Gbreve ENCODING 286 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 90 80 B0 90 70 00 ENDCHAR STARTCHAR gbreve ENCODING 287 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 20 70 90 60 80 70 ENDCHAR STARTCHAR Gdotaccent ENCODING 288 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 90 80 B0 90 70 00 ENDCHAR STARTCHAR gdotaccent ENCODING 289 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 00 70 90 60 80 70 ENDCHAR STARTCHAR Gcommaaccent ENCODING 290 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 90 80 B0 90 70 40 ENDCHAR STARTCHAR gcommaaccent ENCODING 291 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 20 70 90 60 80 70 ENDCHAR STARTCHAR Hcircumflex ENCODING 292 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 90 90 F0 90 90 90 00 ENDCHAR STARTCHAR hcircumflex ENCODING 293 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 A0 80 E0 90 90 00 ENDCHAR STARTCHAR Hbar ENCODING 294 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 90 F8 90 F0 90 90 00 ENDCHAR STARTCHAR hbar ENCODING 295 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 80 C0 80 E0 90 90 00 ENDCHAR STARTCHAR Itilde ENCODING 296 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 70 20 20 20 20 70 00 ENDCHAR STARTCHAR itilde ENCODING 297 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 A0 60 20 20 70 00 ENDCHAR STARTCHAR Imacron ENCODING 298 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 70 20 20 20 20 70 00 ENDCHAR STARTCHAR imacron ENCODING 299 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 70 00 60 20 20 70 00 ENDCHAR STARTCHAR Ibreve ENCODING 300 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 70 20 20 20 20 70 00 ENDCHAR STARTCHAR ibreve ENCODING 301 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 90 60 60 20 20 70 00 ENDCHAR STARTCHAR Iogonek ENCODING 302 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 70 20 20 20 20 70 40 ENDCHAR STARTCHAR iogonek ENCODING 303 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 00 60 20 20 70 40 ENDCHAR STARTCHAR Idotaccent ENCODING 304 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 70 20 20 20 20 70 00 ENDCHAR STARTCHAR dotlessi ENCODING 305 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 60 20 20 70 00 ENDCHAR STARTCHAR IJ ENCODING 306 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 90 90 90 90 D0 A0 00 ENDCHAR STARTCHAR ij ENCODING 307 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 90 00 90 90 90 D0 20 ENDCHAR STARTCHAR Jcircumflex ENCODING 308 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 10 10 10 90 60 00 ENDCHAR STARTCHAR jcircumflex ENCODING 309 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 50 00 20 20 A0 40 ENDCHAR STARTCHAR Kcommaaccent ENCODING 310 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 90 A0 C0 C0 A0 90 80 ENDCHAR STARTCHAR kcommaaccent ENCODING 311 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 80 80 A0 C0 A0 90 80 ENDCHAR STARTCHAR kgreenlandic ENCODING 312 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 90 E0 90 90 00 ENDCHAR STARTCHAR Lacute ENCODING 313 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 90 A0 80 80 80 F0 00 ENDCHAR STARTCHAR lacute ENCODING 314 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP C8 50 40 40 40 E0 00 ENDCHAR STARTCHAR Lcommaaccent ENCODING 315 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 80 80 80 80 80 F0 80 ENDCHAR STARTCHAR lcommaaccent ENCODING 316 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 20 20 20 20 70 40 ENDCHAR STARTCHAR Lcaron ENCODING 317 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP A8 90 80 80 80 F0 00 ENDCHAR STARTCHAR lcaron ENCODING 318 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP A8 90 80 80 80 40 00 ENDCHAR STARTCHAR Ldot ENCODING 319 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 80 80 A0 80 80 F0 00 ENDCHAR STARTCHAR ldot ENCODING 320 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP C0 40 50 40 40 E0 00 ENDCHAR STARTCHAR Lslash ENCODING 321 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 80 80 C0 80 80 F0 00 ENDCHAR STARTCHAR lslash ENCODING 322 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 20 30 60 20 70 00 ENDCHAR STARTCHAR Nacute ENCODING 323 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 90 D0 D0 B0 B0 90 00 ENDCHAR STARTCHAR nacute ENCODING 324 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 40 E0 90 90 90 00 ENDCHAR STARTCHAR Ncommaaccent ENCODING 325 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 90 D0 D0 B0 B0 90 80 ENDCHAR STARTCHAR ncommaaccent ENCODING 326 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 E0 90 90 90 80 ENDCHAR STARTCHAR Ncaron ENCODING 327 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 90 D0 D0 B0 B0 90 00 ENDCHAR STARTCHAR ncaron ENCODING 328 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP A0 40 E0 90 90 90 00 ENDCHAR STARTCHAR napostrophe ENCODING 329 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 80 00 E0 90 90 90 00 ENDCHAR STARTCHAR Eng ENCODING 330 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 90 D0 D0 B0 B0 90 20 ENDCHAR STARTCHAR eng ENCODING 331 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 E0 90 90 90 20 ENDCHAR STARTCHAR Omacron ENCODING 332 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 90 90 90 90 60 00 ENDCHAR STARTCHAR omacron ENCODING 333 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP F0 00 60 90 90 60 00 ENDCHAR STARTCHAR Obreve ENCODING 334 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 90 90 90 90 60 00 ENDCHAR STARTCHAR obreve ENCODING 335 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 90 60 60 90 90 60 00 ENDCHAR STARTCHAR Ohungarumlaut ENCODING 336 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 90 90 90 90 60 00 ENDCHAR STARTCHAR ohungarumlaut ENCODING 337 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 48 90 60 90 90 60 00 ENDCHAR STARTCHAR OE ENCODING 338 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 70 A0 B0 A0 A0 70 00 ENDCHAR STARTCHAR oe ENCODING 339 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 70 B0 A0 70 00 ENDCHAR STARTCHAR Racute ENCODING 340 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP E0 90 90 E0 A0 90 00 ENDCHAR STARTCHAR racute ENCODING 341 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 40 E0 90 80 80 00 ENDCHAR STARTCHAR Rcommaaccent ENCODING 342 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP E0 90 90 E0 A0 90 80 ENDCHAR STARTCHAR rcommaaccent ENCODING 343 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 E0 90 80 80 40 ENDCHAR STARTCHAR Rcaron ENCODING 344 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP E0 90 90 E0 A0 90 00 ENDCHAR STARTCHAR rcaron ENCODING 345 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP A0 40 E0 90 80 80 00 ENDCHAR STARTCHAR Sacute ENCODING 346 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 90 40 20 90 60 00 ENDCHAR STARTCHAR sacute ENCODING 347 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 40 70 C0 30 E0 00 ENDCHAR STARTCHAR Scircumflex ENCODING 348 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 90 40 20 90 60 00 ENDCHAR STARTCHAR scircumflex ENCODING 349 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 00 70 C0 30 E0 00 ENDCHAR STARTCHAR Scedilla ENCODING 350 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 90 40 20 90 60 40 ENDCHAR STARTCHAR scedilla ENCODING 351 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 70 C0 30 E0 40 ENDCHAR STARTCHAR Scaron ENCODING 352 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 90 40 20 90 60 00 ENDCHAR STARTCHAR scaron ENCODING 353 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 20 70 C0 30 E0 00 ENDCHAR STARTCHAR Tcommaaccent ENCODING 354 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 70 20 20 20 20 20 40 ENDCHAR STARTCHAR tcommaaccent ENCODING 355 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 40 E0 40 40 30 40 ENDCHAR STARTCHAR Tcaron ENCODING 356 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP E0 40 40 40 40 40 00 ENDCHAR STARTCHAR tcaron ENCODING 357 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 20 40 E0 40 30 00 ENDCHAR STARTCHAR Tbar ENCODING 358 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP E0 40 E0 40 40 40 00 ENDCHAR STARTCHAR tbar ENCODING 359 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 E0 40 E0 40 30 00 ENDCHAR STARTCHAR Utilde ENCODING 360 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 90 90 90 90 90 60 00 ENDCHAR STARTCHAR utilde ENCODING 361 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 A0 90 90 90 70 00 ENDCHAR STARTCHAR Umacron ENCODING 362 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 90 90 90 90 90 60 00 ENDCHAR STARTCHAR umacron ENCODING 363 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP F0 00 90 90 90 70 00 ENDCHAR STARTCHAR Ubreve ENCODING 364 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 90 90 90 90 90 60 00 ENDCHAR STARTCHAR ubreve ENCODING 365 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 90 60 00 90 90 70 00 ENDCHAR STARTCHAR Uring ENCODING 366 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 90 90 90 90 90 60 00 ENDCHAR STARTCHAR uring ENCODING 367 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 60 00 90 90 70 00 ENDCHAR STARTCHAR Uhungarumlaut ENCODING 368 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 90 90 90 90 90 60 00 ENDCHAR STARTCHAR uhungarumlaut ENCODING 369 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 48 90 00 90 90 70 00 ENDCHAR STARTCHAR Uogonek ENCODING 370 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 90 90 90 90 90 60 40 ENDCHAR STARTCHAR uogonek ENCODING 371 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 90 90 90 70 20 ENDCHAR STARTCHAR Wcircumflex ENCODING 372 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 90 90 90 F0 F0 90 00 ENDCHAR STARTCHAR wcircumflex ENCODING 373 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 50 00 90 F0 F0 00 ENDCHAR STARTCHAR Ycircumflex ENCODING 374 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP A0 A0 A0 40 40 40 00 ENDCHAR STARTCHAR ycircumflex ENCODING 375 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 50 00 90 50 20 40 ENDCHAR STARTCHAR Ydieresis ENCODING 376 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP A0 A0 A0 40 40 40 00 ENDCHAR STARTCHAR Zacute ENCODING 377 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP F0 10 20 40 80 F0 00 ENDCHAR STARTCHAR zacute ENCODING 378 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 40 F0 20 40 F0 00 ENDCHAR STARTCHAR Zdotaccent ENCODING 379 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP F0 10 20 40 80 F0 00 ENDCHAR STARTCHAR zdotaccent ENCODING 380 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 00 F0 20 40 F0 00 ENDCHAR STARTCHAR Zcaron ENCODING 381 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP F0 10 20 40 80 F0 00 ENDCHAR STARTCHAR zcaron ENCODING 382 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 20 F0 20 40 F0 00 ENDCHAR STARTCHAR longs ENCODING 383 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 20 60 20 20 20 00 ENDCHAR STARTCHAR uni0180 ENCODING 384 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 E0 40 60 50 60 00 ENDCHAR STARTCHAR uni0181 ENCODING 385 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP E0 50 60 50 50 60 00 ENDCHAR STARTCHAR uni0182 ENCODING 386 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP E0 80 E0 90 90 E0 00 ENDCHAR STARTCHAR uni0183 ENCODING 387 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 40 60 50 50 60 00 ENDCHAR STARTCHAR uni0184 ENCODING 388 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 C0 F0 48 48 70 00 ENDCHAR STARTCHAR uni0185 ENCODING 389 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 C0 60 50 50 60 00 ENDCHAR STARTCHAR uni0186 ENCODING 390 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 90 10 10 90 60 00 ENDCHAR STARTCHAR uni0187 ENCODING 391 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 68 90 80 80 90 60 00 ENDCHAR STARTCHAR uni0188 ENCODING 392 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 10 60 80 80 60 00 ENDCHAR STARTCHAR uni0189 ENCODING 393 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP E0 50 D0 50 50 E0 00 ENDCHAR STARTCHAR uni018A ENCODING 394 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP E0 50 50 50 50 60 00 ENDCHAR STARTCHAR uni018B ENCODING 395 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 70 10 70 90 90 70 00 ENDCHAR STARTCHAR uni018C ENCODING 396 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 30 10 30 50 50 30 00 ENDCHAR STARTCHAR uni018D ENCODING 397 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 60 90 60 10 60 ENDCHAR STARTCHAR uni018E ENCODING 398 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP F0 10 70 10 10 F0 00 ENDCHAR STARTCHAR uni018F ENCODING 399 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 90 10 F0 90 60 00 ENDCHAR STARTCHAR uni0190 ENCODING 400 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 90 40 80 90 60 00 ENDCHAR STARTCHAR uni0191 ENCODING 401 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 70 40 60 40 40 40 80 ENDCHAR STARTCHAR florin ENCODING 402 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 50 40 E0 40 40 80 ENDCHAR STARTCHAR uni0193 ENCODING 403 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 70 90 80 B0 90 70 00 ENDCHAR STARTCHAR uni0194 ENCODING 404 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 90 90 60 90 60 00 ENDCHAR STARTCHAR uni0195 ENCODING 405 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 80 80 C8 A8 A8 90 00 ENDCHAR STARTCHAR uni0196 ENCODING 406 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 20 20 20 20 10 00 ENDCHAR STARTCHAR uni0197 ENCODING 407 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 70 20 70 20 20 70 00 ENDCHAR STARTCHAR uni0198 ENCODING 408 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP A0 D0 80 C0 A0 90 00 ENDCHAR STARTCHAR uni0199 ENCODING 409 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 80 A0 C0 A0 90 00 ENDCHAR STARTCHAR uni019A ENCODING 410 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 20 70 20 20 70 00 ENDCHAR STARTCHAR uni019B ENCODING 411 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 30 60 20 50 50 00 ENDCHAR STARTCHAR uni019C ENCODING 412 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 90 90 90 90 F0 50 00 ENDCHAR STARTCHAR uni019D ENCODING 413 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 48 68 68 58 58 48 80 ENDCHAR STARTCHAR uni019E ENCODING 414 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 E0 90 90 90 10 ENDCHAR STARTCHAR uni019F ENCODING 415 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 90 F0 90 90 60 00 ENDCHAR STARTCHAR Ohorn ENCODING 416 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 68 90 90 90 90 60 00 ENDCHAR STARTCHAR ohorn ENCODING 417 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 08 70 90 90 60 00 ENDCHAR STARTCHAR uni01A2 ENCODING 418 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 70 A8 A8 A8 A8 40 00 ENDCHAR STARTCHAR uni01A3 ENCODING 419 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 70 A8 A8 48 00 ENDCHAR STARTCHAR uni01A4 ENCODING 420 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP E0 50 50 60 40 40 00 ENDCHAR STARTCHAR uni01A5 ENCODING 421 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 80 E0 90 90 E0 80 ENDCHAR STARTCHAR uni01A6 ENCODING 422 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 80 E0 90 E0 C0 A0 10 ENDCHAR STARTCHAR uni01A7 ENCODING 423 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 90 20 40 90 60 00 ENDCHAR STARTCHAR uni01A8 ENCODING 424 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 E0 30 C0 70 00 ENDCHAR STARTCHAR uni01A9 ENCODING 425 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP F0 80 40 40 80 F0 00 ENDCHAR STARTCHAR uni01AA ENCODING 426 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 A0 70 20 20 20 10 ENDCHAR STARTCHAR uni01AB ENCODING 427 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 40 E0 40 70 10 20 ENDCHAR STARTCHAR uni01AC ENCODING 428 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 70 A0 A0 20 20 20 00 ENDCHAR STARTCHAR uni01AD ENCODING 429 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 30 40 E0 40 40 30 00 ENDCHAR STARTCHAR uni01AE ENCODING 430 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP E0 40 40 40 40 40 30 ENDCHAR STARTCHAR Uhorn ENCODING 431 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 98 90 90 90 90 60 00 ENDCHAR STARTCHAR uhorn ENCODING 432 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 08 90 90 90 70 00 ENDCHAR STARTCHAR uni01B1 ENCODING 433 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 88 88 88 88 70 00 ENDCHAR STARTCHAR uni01B2 ENCODING 434 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP A0 90 90 90 90 60 00 ENDCHAR STARTCHAR uni01B3 ENCODING 435 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 90 50 50 20 20 20 00 ENDCHAR STARTCHAR uni01B4 ENCODING 436 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 90 A0 A0 40 80 ENDCHAR STARTCHAR uni01B5 ENCODING 437 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP F0 10 F0 40 80 F0 00 ENDCHAR STARTCHAR uni01B6 ENCODING 438 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 F0 70 40 F0 00 ENDCHAR STARTCHAR uni01B7 ENCODING 439 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP F0 20 60 10 10 E0 00 ENDCHAR STARTCHAR uni01B8 ENCODING 440 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP F0 40 60 80 80 70 00 ENDCHAR STARTCHAR uni01B9 ENCODING 441 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 F0 40 60 80 70 ENDCHAR STARTCHAR uni01BA ENCODING 442 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 F0 20 60 30 F8 ENDCHAR STARTCHAR uni01BB ENCODING 443 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 90 10 F0 40 F0 00 ENDCHAR STARTCHAR uni01BC ENCODING 444 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP F0 80 E0 90 10 E0 00 ENDCHAR STARTCHAR uni01BD ENCODING 445 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 70 60 10 60 00 ENDCHAR STARTCHAR uni01BE ENCODING 446 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 20 70 20 10 60 00 ENDCHAR STARTCHAR uni01BF ENCODING 447 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 E0 90 A0 C0 80 ENDCHAR STARTCHAR uni01C0 ENCODING 448 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 20 20 20 20 20 00 ENDCHAR STARTCHAR uni01C1 ENCODING 449 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 50 50 50 50 50 00 ENDCHAR STARTCHAR uni01C2 ENCODING 450 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 20 70 20 70 20 00 ENDCHAR STARTCHAR uni01C3 ENCODING 451 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 20 20 20 00 20 00 ENDCHAR STARTCHAR uni01C4 ENCODING 452 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 18 D8 A8 A8 B0 D8 00 ENDCHAR STARTCHAR uni01C5 ENCODING 453 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP D8 A0 B8 A8 B0 D8 00 ENDCHAR STARTCHAR uni01C6 ENCODING 454 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 38 20 78 A8 B0 78 00 ENDCHAR STARTCHAR uni01C7 ENCODING 455 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 88 88 88 88 A8 D0 00 ENDCHAR STARTCHAR uni01C8 ENCODING 456 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 88 80 88 88 88 E8 10 ENDCHAR STARTCHAR uni01C9 ENCODING 457 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP C8 40 48 48 48 E8 10 ENDCHAR STARTCHAR uni01CA ENCODING 458 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP C8 A8 A8 A8 A8 B0 00 ENDCHAR STARTCHAR uni01CB ENCODING 459 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP C8 A0 A8 A8 A8 A8 10 ENDCHAR STARTCHAR uni01CC ENCODING 460 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 08 00 C8 A8 A8 A8 10 ENDCHAR STARTCHAR uni01CD ENCODING 461 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 90 90 F0 90 90 00 ENDCHAR STARTCHAR uni01CE ENCODING 462 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 20 70 90 B0 50 00 ENDCHAR STARTCHAR uni01CF ENCODING 463 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 70 20 20 20 20 70 00 ENDCHAR STARTCHAR uni01D0 ENCODING 464 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 20 60 20 20 70 00 ENDCHAR STARTCHAR uni01D1 ENCODING 465 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 90 90 90 90 60 00 ENDCHAR STARTCHAR uni01D2 ENCODING 466 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP A0 40 60 90 90 60 00 ENDCHAR STARTCHAR uni01D3 ENCODING 467 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 90 90 90 90 90 60 00 ENDCHAR STARTCHAR uni01D4 ENCODING 468 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 20 90 90 90 70 00 ENDCHAR STARTCHAR uni01D5 ENCODING 469 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 90 90 90 90 90 60 00 ENDCHAR STARTCHAR uni01D6 ENCODING 470 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 70 50 00 90 90 70 00 ENDCHAR STARTCHAR uni01D7 ENCODING 471 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 90 90 90 90 90 60 00 ENDCHAR STARTCHAR uni01D8 ENCODING 472 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 70 00 90 90 70 00 ENDCHAR STARTCHAR uni01D9 ENCODING 473 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 90 90 90 90 90 60 00 ENDCHAR STARTCHAR uni01DA ENCODING 474 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 70 00 90 90 70 00 ENDCHAR STARTCHAR uni01DB ENCODING 475 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 90 90 90 90 90 60 00 ENDCHAR STARTCHAR uni01DC ENCODING 476 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 70 00 90 90 70 00 ENDCHAR STARTCHAR uni01DD ENCODING 477 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 60 30 D0 60 00 ENDCHAR STARTCHAR uni01DE ENCODING 478 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 90 90 F0 90 90 00 ENDCHAR STARTCHAR uni01DF ENCODING 479 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 70 50 70 90 B0 50 00 ENDCHAR STARTCHAR uni01E0 ENCODING 480 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 90 90 F0 90 90 00 ENDCHAR STARTCHAR uni01E1 ENCODING 481 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 70 20 70 90 B0 50 00 ENDCHAR STARTCHAR uni01E2 ENCODING 482 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP F0 70 A0 F0 A0 B0 00 ENDCHAR STARTCHAR uni01E3 ENCODING 483 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP F0 00 70 B0 A0 70 00 ENDCHAR STARTCHAR uni01E4 ENCODING 484 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 90 80 B0 B8 70 00 ENDCHAR STARTCHAR uni01E5 ENCODING 485 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 70 90 60 B8 70 ENDCHAR STARTCHAR Gcaron ENCODING 486 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 90 80 B0 90 70 00 ENDCHAR STARTCHAR gcaron ENCODING 487 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 20 70 90 60 80 70 ENDCHAR STARTCHAR uni01E8 ENCODING 488 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 90 A0 C0 C0 A0 90 00 ENDCHAR STARTCHAR uni01E9 ENCODING 489 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP D0 A0 80 A0 C0 A0 00 ENDCHAR STARTCHAR uni01EA ENCODING 490 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 90 90 90 90 60 40 ENDCHAR STARTCHAR uni01EB ENCODING 491 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 60 90 90 60 40 ENDCHAR STARTCHAR uni01EC ENCODING 492 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 90 90 90 90 60 40 ENDCHAR STARTCHAR uni01ED ENCODING 493 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP F0 00 60 90 90 60 40 ENDCHAR STARTCHAR uni01EE ENCODING 494 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP F0 20 60 10 10 E0 00 ENDCHAR STARTCHAR uni01EF ENCODING 495 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 20 F0 20 60 10 E0 ENDCHAR STARTCHAR uni01F0 ENCODING 496 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 20 00 20 20 A0 40 ENDCHAR STARTCHAR uni01F1 ENCODING 497 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP D8 A8 A8 B0 B0 D8 00 ENDCHAR STARTCHAR uni01F2 ENCODING 498 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP C0 A0 B8 A8 B0 D8 00 ENDCHAR STARTCHAR uni01F3 ENCODING 499 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 20 78 A8 B0 78 00 ENDCHAR STARTCHAR uni01F4 ENCODING 500 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 90 80 B0 90 70 00 ENDCHAR STARTCHAR uni01F5 ENCODING 501 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 20 70 90 60 80 70 ENDCHAR STARTCHAR uni01F6 ENCODING 502 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP A0 A0 E8 A8 A8 90 00 ENDCHAR STARTCHAR uni01F7 ENCODING 503 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP E0 90 A0 C0 80 80 00 ENDCHAR STARTCHAR uni01F8 ENCODING 504 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 90 D0 D0 B0 B0 90 00 ENDCHAR STARTCHAR uni01F9 ENCODING 505 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 20 E0 90 90 90 00 ENDCHAR STARTCHAR Aringacute ENCODING 506 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 90 90 F0 90 90 00 ENDCHAR STARTCHAR aringacute ENCODING 507 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 40 60 60 90 70 00 ENDCHAR STARTCHAR AEacute ENCODING 508 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 70 A0 B0 E0 A0 B0 00 ENDCHAR STARTCHAR aeacute ENCODING 509 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 20 70 B0 A0 70 00 ENDCHAR STARTCHAR Oslashacute ENCODING 510 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 70 B0 B0 D0 D0 E0 00 ENDCHAR STARTCHAR oslashacute ENCODING 511 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 20 70 B0 D0 E0 00 ENDCHAR STARTCHAR uni0200 ENCODING 512 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 90 90 F0 90 90 00 ENDCHAR STARTCHAR uni0201 ENCODING 513 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP A0 50 70 90 B0 50 00 ENDCHAR STARTCHAR uni0202 ENCODING 514 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 90 90 F0 90 90 00 ENDCHAR STARTCHAR uni0203 ENCODING 515 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 90 70 90 B0 50 00 ENDCHAR STARTCHAR uni0204 ENCODING 516 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP F0 80 E0 80 80 F0 00 ENDCHAR STARTCHAR uni0205 ENCODING 517 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP A0 50 60 B0 C0 60 00 ENDCHAR STARTCHAR uni0206 ENCODING 518 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP F0 80 E0 80 80 F0 00 ENDCHAR STARTCHAR uni0207 ENCODING 519 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 90 60 B0 C0 60 00 ENDCHAR STARTCHAR uni0208 ENCODING 520 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 70 20 20 20 20 70 00 ENDCHAR STARTCHAR uni0209 ENCODING 521 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP A0 50 60 20 20 70 00 ENDCHAR STARTCHAR uni020A ENCODING 522 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 70 20 20 20 20 70 00 ENDCHAR STARTCHAR uni020B ENCODING 523 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 90 60 20 20 70 00 ENDCHAR STARTCHAR uni020C ENCODING 524 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 90 90 90 90 60 00 ENDCHAR STARTCHAR uni020D ENCODING 525 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP A0 50 60 90 90 60 00 ENDCHAR STARTCHAR uni020E ENCODING 526 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 90 90 90 90 60 00 ENDCHAR STARTCHAR uni020F ENCODING 527 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 90 60 90 90 60 00 ENDCHAR STARTCHAR uni0210 ENCODING 528 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP E0 90 90 E0 A0 90 00 ENDCHAR STARTCHAR uni0211 ENCODING 529 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP A0 50 E0 90 80 80 00 ENDCHAR STARTCHAR uni0212 ENCODING 530 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP E0 90 90 E0 A0 90 00 ENDCHAR STARTCHAR uni0213 ENCODING 531 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 90 E0 90 80 80 00 ENDCHAR STARTCHAR uni0214 ENCODING 532 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 90 90 90 90 90 60 00 ENDCHAR STARTCHAR uni0215 ENCODING 533 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP A0 50 90 90 90 70 00 ENDCHAR STARTCHAR uni0216 ENCODING 534 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 90 90 90 90 90 60 00 ENDCHAR STARTCHAR uni0217 ENCODING 535 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 90 90 90 90 70 00 ENDCHAR STARTCHAR Scommaaccent ENCODING 536 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 90 40 20 90 60 C0 ENDCHAR STARTCHAR scommaaccent ENCODING 537 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 70 C0 30 E0 C0 ENDCHAR STARTCHAR Tcommaaccent ENCODING 538 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 70 20 20 20 20 20 40 ENDCHAR STARTCHAR tcommaaccent ENCODING 539 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 40 E0 40 40 30 40 ENDCHAR STARTCHAR uni021C ENCODING 540 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 90 10 20 10 E0 00 ENDCHAR STARTCHAR uni021D ENCODING 541 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 60 B0 50 20 C0 ENDCHAR STARTCHAR uni021E ENCODING 542 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 90 90 F0 90 90 90 00 ENDCHAR STARTCHAR uni021F ENCODING 543 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 A0 80 E0 90 90 00 ENDCHAR STARTCHAR uni0250 ENCODING 592 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 A0 D0 90 E0 00 ENDCHAR STARTCHAR uni0251 ENCODING 593 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 70 90 90 70 00 ENDCHAR STARTCHAR uni0252 ENCODING 594 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 E0 90 90 E0 00 ENDCHAR STARTCHAR uni0253 ENCODING 595 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 80 E0 90 90 E0 00 ENDCHAR STARTCHAR uni0254 ENCODING 596 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 60 10 10 60 00 ENDCHAR STARTCHAR uni0255 ENCODING 597 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 60 80 B0 60 80 ENDCHAR STARTCHAR uni0256 ENCODING 598 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 10 70 90 90 70 18 ENDCHAR STARTCHAR uni0257 ENCODING 599 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 18 10 70 90 90 70 00 ENDCHAR STARTCHAR uni0258 ENCODING 600 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 60 D0 30 60 00 ENDCHAR STARTCHAR uni0259 ENCODING 601 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 60 30 D0 60 00 ENDCHAR STARTCHAR uni025A ENCODING 602 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 60 38 D0 60 00 ENDCHAR STARTCHAR uni025B ENCODING 603 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 30 20 40 30 00 ENDCHAR STARTCHAR uni025C ENCODING 604 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 60 20 10 60 00 ENDCHAR STARTCHAR uni025D ENCODING 605 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 F0 40 20 C0 00 ENDCHAR STARTCHAR uni025E ENCODING 606 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 60 A0 90 60 00 ENDCHAR STARTCHAR uni025F ENCODING 607 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 20 20 70 20 A0 40 ENDCHAR STARTCHAR uni0260 ENCODING 608 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 08 70 90 70 10 60 ENDCHAR STARTCHAR uni0261 ENCODING 609 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 70 90 70 10 60 ENDCHAR STARTCHAR uni0262 ENCODING 610 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 70 80 90 70 00 ENDCHAR STARTCHAR uni0263 ENCODING 611 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 50 50 20 50 20 ENDCHAR STARTCHAR uni0264 ENCODING 612 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 50 20 50 20 00 ENDCHAR STARTCHAR uni0265 ENCODING 613 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 90 90 90 70 10 ENDCHAR STARTCHAR uni0266 ENCODING 614 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 80 E0 90 90 90 00 ENDCHAR STARTCHAR uni0267 ENCODING 615 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 80 E0 90 90 90 20 ENDCHAR STARTCHAR uni0268 ENCODING 616 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 00 20 70 20 70 00 ENDCHAR STARTCHAR uni0269 ENCODING 617 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 40 40 40 20 00 ENDCHAR STARTCHAR uni026A ENCODING 618 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 E0 40 40 E0 00 ENDCHAR STARTCHAR uni026B ENCODING 619 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 20 68 B0 20 70 00 ENDCHAR STARTCHAR uni026C ENCODING 620 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 20 60 70 20 70 00 ENDCHAR STARTCHAR uni026D ENCODING 621 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 20 20 20 20 20 10 ENDCHAR STARTCHAR uni026E ENCODING 622 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 80 80 E0 90 90 A0 60 ENDCHAR STARTCHAR uni026F ENCODING 623 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 90 90 F0 50 00 ENDCHAR STARTCHAR uni0270 ENCODING 624 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 90 90 F0 50 10 ENDCHAR STARTCHAR uni0271 ENCODING 625 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 A0 F0 90 90 20 ENDCHAR STARTCHAR uni0272 ENCODING 626 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 60 50 50 50 80 ENDCHAR STARTCHAR uni0273 ENCODING 627 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 C0 A0 A0 A0 10 ENDCHAR STARTCHAR uni0274 ENCODING 628 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 90 D0 B0 90 00 ENDCHAR STARTCHAR uni0275 ENCODING 629 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 60 90 F0 90 60 00 ENDCHAR STARTCHAR uni0276 ENCODING 630 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 70 B0 A0 70 00 ENDCHAR STARTCHAR uni0277 ENCODING 631 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 60 90 F0 F0 00 ENDCHAR STARTCHAR uni0278 ENCODING 632 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 20 70 A8 70 20 00 ENDCHAR STARTCHAR uni0279 ENCODING 633 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 10 10 90 70 00 ENDCHAR STARTCHAR uni027A ENCODING 634 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 10 10 10 90 70 00 ENDCHAR STARTCHAR uni027B ENCODING 635 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 20 A0 60 30 00 ENDCHAR STARTCHAR uni027C ENCODING 636 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 E0 90 80 80 80 80 ENDCHAR STARTCHAR uni027D ENCODING 637 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 E0 90 80 80 80 40 ENDCHAR STARTCHAR uni027E ENCODING 638 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 60 90 80 80 00 ENDCHAR STARTCHAR uni027F ENCODING 639 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 60 90 10 10 00 ENDCHAR STARTCHAR uni0280 ENCODING 640 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 E0 90 E0 90 00 ENDCHAR STARTCHAR uni0281 ENCODING 641 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 90 E0 90 E0 00 ENDCHAR STARTCHAR uni0282 ENCODING 642 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 70 C0 30 E0 80 ENDCHAR STARTCHAR uni0283 ENCODING 643 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 20 20 20 20 20 40 ENDCHAR STARTCHAR uni0284 ENCODING 644 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 20 20 20 70 20 40 ENDCHAR STARTCHAR uni0285 ENCODING 645 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 40 20 20 10 00 ENDCHAR STARTCHAR uni0286 ENCODING 646 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 20 20 20 70 A0 40 ENDCHAR STARTCHAR uni0287 ENCODING 647 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 C0 20 20 70 20 20 ENDCHAR STARTCHAR uni0288 ENCODING 648 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 40 E0 40 40 40 30 ENDCHAR STARTCHAR uni0289 ENCODING 649 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 90 F0 90 70 00 ENDCHAR STARTCHAR uni028A ENCODING 650 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 90 90 90 60 00 ENDCHAR STARTCHAR uni028B ENCODING 651 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 A0 90 90 60 00 ENDCHAR STARTCHAR uni028C ENCODING 652 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 20 50 50 50 00 ENDCHAR STARTCHAR uni028D ENCODING 653 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 F0 F0 90 90 00 ENDCHAR STARTCHAR uni028E ENCODING 654 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 20 40 A0 90 90 00 ENDCHAR STARTCHAR uni028F ENCODING 655 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 A0 40 40 40 00 ENDCHAR STARTCHAR uni0290 ENCODING 656 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 F0 20 40 F0 10 ENDCHAR STARTCHAR uni0291 ENCODING 657 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 F0 20 50 F0 40 ENDCHAR STARTCHAR uni0292 ENCODING 658 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 F0 20 60 10 E0 ENDCHAR STARTCHAR uni0293 ENCODING 659 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 F0 20 60 50 78 ENDCHAR STARTCHAR uni0294 ENCODING 660 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 60 10 30 20 20 00 ENDCHAR STARTCHAR uni0295 ENCODING 661 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 30 40 60 20 20 00 ENDCHAR STARTCHAR uni0296 ENCODING 662 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 20 20 30 10 60 00 ENDCHAR STARTCHAR uni0297 ENCODING 663 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 20 50 40 40 50 20 ENDCHAR STARTCHAR uni0298 ENCODING 664 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 70 88 A8 88 70 00 ENDCHAR STARTCHAR uni0299 ENCODING 665 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 E0 E0 90 E0 00 ENDCHAR STARTCHAR uni029A ENCODING 666 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 60 50 90 60 00 ENDCHAR STARTCHAR uni029B ENCODING 667 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 18 70 80 90 70 00 ENDCHAR STARTCHAR uni029C ENCODING 668 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 90 F0 90 90 00 ENDCHAR STARTCHAR uni029D ENCODING 669 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 00 20 20 70 A0 40 ENDCHAR STARTCHAR uni029E ENCODING 670 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 90 50 30 50 10 ENDCHAR STARTCHAR uni029F ENCODING 671 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 80 80 80 F0 00 ENDCHAR STARTCHAR uni02A0 ENCODING 672 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 18 70 90 90 70 10 ENDCHAR STARTCHAR uni02A1 ENCODING 673 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 60 10 20 70 20 00 ENDCHAR STARTCHAR uni02A2 ENCODING 674 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 30 40 20 70 20 00 ENDCHAR STARTCHAR uni02A3 ENCODING 675 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 20 78 A8 B0 78 00 ENDCHAR STARTCHAR uni02A4 ENCODING 676 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 20 78 A8 B0 68 10 ENDCHAR STARTCHAR uni02A5 ENCODING 677 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 20 78 A8 B8 78 00 ENDCHAR STARTCHAR uni02A6 ENCODING 678 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 40 E8 50 48 30 00 ENDCHAR STARTCHAR uni02A7 ENCODING 679 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 48 50 F0 50 50 30 20 ENDCHAR STARTCHAR uni02A8 ENCODING 680 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 40 E8 50 50 38 10 ENDCHAR STARTCHAR uni02B6 ENCODING 694 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP A0 C0 A0 C0 00 00 00 ENDCHAR STARTCHAR uni02B8 ENCODING 696 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 80 00 00 00 00 00 ENDCHAR STARTCHAR uni02B9 ENCODING 697 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 A0 00 00 00 00 00 ENDCHAR STARTCHAR afii57929 ENCODING 700 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 30 20 40 00 00 00 00 ENDCHAR STARTCHAR afii64937 ENCODING 701 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 20 10 00 00 00 00 ENDCHAR STARTCHAR circumflex ENCODING 710 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 50 00 00 00 00 00 ENDCHAR STARTCHAR caron ENCODING 711 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 20 00 00 00 00 00 ENDCHAR STARTCHAR uni02C8 ENCODING 712 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 20 00 00 00 00 00 ENDCHAR STARTCHAR macron ENCODING 713 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 70 00 00 00 00 00 00 ENDCHAR STARTCHAR uni02CC ENCODING 716 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 00 00 00 20 20 ENDCHAR STARTCHAR uni02D0 ENCODING 720 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 70 20 00 20 70 00 ENDCHAR STARTCHAR uni02D6 ENCODING 726 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 20 70 20 00 00 ENDCHAR STARTCHAR breve ENCODING 728 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 90 60 00 00 00 00 00 ENDCHAR STARTCHAR dotaccent ENCODING 729 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 00 00 00 00 00 00 ENDCHAR STARTCHAR ring ENCODING 730 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 50 20 00 00 00 00 ENDCHAR STARTCHAR ogonek ENCODING 731 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 00 00 00 20 30 ENDCHAR STARTCHAR tilde ENCODING 732 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 A0 00 00 00 00 00 ENDCHAR STARTCHAR hungarumlaut ENCODING 733 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 48 90 00 00 00 00 00 ENDCHAR STARTCHAR gravecomb ENCODING 768 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 20 00 00 00 00 00 ENDCHAR STARTCHAR acutecomb ENCODING 769 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 40 00 00 00 00 00 ENDCHAR STARTCHAR uni0302 ENCODING 770 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 00 00 00 00 00 00 ENDCHAR STARTCHAR tildecomb ENCODING 771 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 A0 00 00 00 00 00 ENDCHAR STARTCHAR uni0304 ENCODING 772 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 70 00 00 00 00 00 00 ENDCHAR STARTCHAR uni0305 ENCODING 773 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP F8 00 00 00 00 00 00 ENDCHAR STARTCHAR uni0306 ENCODING 774 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 90 60 00 00 00 00 00 ENDCHAR STARTCHAR uni0307 ENCODING 775 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 00 00 00 00 00 00 ENDCHAR STARTCHAR uni0308 ENCODING 776 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 00 00 00 00 00 00 ENDCHAR STARTCHAR hookabovecomb ENCODING 777 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 20 00 00 00 00 00 ENDCHAR STARTCHAR uni030A ENCODING 778 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 60 00 00 00 00 00 ENDCHAR STARTCHAR uni030B ENCODING 779 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 48 90 00 00 00 00 00 ENDCHAR STARTCHAR uni030C ENCODING 780 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 20 00 00 00 00 00 ENDCHAR STARTCHAR uni030D ENCODING 781 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 20 00 00 00 00 00 ENDCHAR STARTCHAR uni030E ENCODING 782 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 50 00 00 00 00 00 ENDCHAR STARTCHAR uni030F ENCODING 783 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 90 48 00 00 00 00 00 ENDCHAR STARTCHAR uni0310 ENCODING 784 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP A8 70 00 00 00 00 00 ENDCHAR STARTCHAR uni0311 ENCODING 785 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 90 00 00 00 00 00 ENDCHAR STARTCHAR dotbelowcomb ENCODING 803 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 00 00 00 00 20 ENDCHAR STARTCHAR uni0324 ENCODING 804 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 00 00 00 00 50 ENDCHAR STARTCHAR uni0338 ENCODING 824 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 20 20 40 40 80 00 ENDCHAR STARTCHAR uni0340 ENCODING 832 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 20 00 00 00 00 00 ENDCHAR STARTCHAR uni0341 ENCODING 833 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 40 00 00 00 00 00 ENDCHAR STARTCHAR uni0374 ENCODING 884 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 40 00 00 00 00 00 ENDCHAR STARTCHAR uni0375 ENCODING 885 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 00 00 00 20 40 ENDCHAR STARTCHAR uni037A ENCODING 890 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 00 00 00 00 40 ENDCHAR STARTCHAR uni037E ENCODING 894 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 60 60 00 60 40 80 ENDCHAR STARTCHAR tonos ENCODING 900 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 40 00 00 00 00 00 ENDCHAR STARTCHAR dieresistonos ENCODING 901 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP B0 40 00 00 00 00 00 ENDCHAR STARTCHAR Alphatonos ENCODING 902 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP A0 D0 50 70 50 50 00 ENDCHAR STARTCHAR anoteleia ENCODING 903 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 60 60 00 00 00 ENDCHAR STARTCHAR Epsilontonos ENCODING 904 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP F0 C0 60 40 40 70 00 ENDCHAR STARTCHAR Etatonos ENCODING 905 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP D0 D0 70 50 50 50 00 ENDCHAR STARTCHAR Iotatonos ENCODING 906 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP F0 A0 20 20 20 70 00 ENDCHAR STARTCHAR Omicrontonos ENCODING 908 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP A0 D0 50 50 50 20 00 ENDCHAR STARTCHAR Upsilontonos ENCODING 910 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP D0 D0 50 20 20 20 00 ENDCHAR STARTCHAR Omegatonos ENCODING 911 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP A0 D0 50 50 20 50 00 ENDCHAR STARTCHAR iotadieresistonos ENCODING 912 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP B0 40 00 40 40 20 00 ENDCHAR STARTCHAR Alpha ENCODING 913 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 90 90 F0 90 90 00 ENDCHAR STARTCHAR Beta ENCODING 914 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP E0 90 E0 90 90 E0 00 ENDCHAR STARTCHAR Gamma ENCODING 915 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP F0 80 80 80 80 80 00 ENDCHAR STARTCHAR Delta ENCODING 916 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 60 90 90 90 F0 00 ENDCHAR STARTCHAR Epsilon ENCODING 917 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP F0 80 E0 80 80 F0 00 ENDCHAR STARTCHAR Zeta ENCODING 918 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP F0 10 20 40 80 F0 00 ENDCHAR STARTCHAR Eta ENCODING 919 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 90 90 F0 90 90 90 00 ENDCHAR STARTCHAR Theta ENCODING 920 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 90 F0 90 90 60 00 ENDCHAR STARTCHAR Iota ENCODING 921 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 70 20 20 20 20 70 00 ENDCHAR STARTCHAR Kappa ENCODING 922 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 90 A0 C0 C0 A0 90 00 ENDCHAR STARTCHAR Lambda ENCODING 923 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 60 60 90 90 90 00 ENDCHAR STARTCHAR Mu ENCODING 924 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 90 F0 F0 90 90 90 00 ENDCHAR STARTCHAR Nu ENCODING 925 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 90 D0 D0 B0 B0 90 00 ENDCHAR STARTCHAR Xi ENCODING 926 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP F0 00 60 00 00 F0 00 ENDCHAR STARTCHAR Omicron ENCODING 927 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 90 90 90 90 60 00 ENDCHAR STARTCHAR Pi ENCODING 928 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP F0 90 90 90 90 90 00 ENDCHAR STARTCHAR Rho ENCODING 929 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP E0 90 90 E0 80 80 00 ENDCHAR STARTCHAR Sigma ENCODING 931 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP F0 80 40 40 80 F0 00 ENDCHAR STARTCHAR Tau ENCODING 932 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 70 20 20 20 20 20 00 ENDCHAR STARTCHAR Upsilon ENCODING 933 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 50 50 20 20 20 00 ENDCHAR STARTCHAR Phi ENCODING 934 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 70 50 50 70 20 00 ENDCHAR STARTCHAR Chi ENCODING 935 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 90 90 60 60 90 90 00 ENDCHAR STARTCHAR Psi ENCODING 936 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 70 70 70 20 20 00 ENDCHAR STARTCHAR Omega ENCODING 937 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 50 50 50 20 50 00 ENDCHAR STARTCHAR Iotadieresis ENCODING 938 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 00 70 20 20 70 00 ENDCHAR STARTCHAR Upsilondieresis ENCODING 939 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP A0 00 A0 A0 40 40 00 ENDCHAR STARTCHAR alphatonos ENCODING 940 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 20 70 90 B0 50 00 ENDCHAR STARTCHAR epsilontonos ENCODING 941 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 20 70 20 40 30 00 ENDCHAR STARTCHAR etatonos ENCODING 942 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 40 E0 90 90 90 10 ENDCHAR STARTCHAR iotatonos ENCODING 943 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 40 00 40 40 20 00 ENDCHAR STARTCHAR upsilondieresistonos ENCODING 944 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP B0 40 90 90 90 60 00 ENDCHAR STARTCHAR alpha ENCODING 945 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 70 90 B0 50 00 ENDCHAR STARTCHAR beta ENCODING 946 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 90 E0 90 90 E0 80 ENDCHAR STARTCHAR gamma ENCODING 947 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 50 50 20 20 20 ENDCHAR STARTCHAR delta ENCODING 948 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 70 80 60 90 90 60 00 ENDCHAR STARTCHAR epsilon ENCODING 949 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 70 20 40 30 00 ENDCHAR STARTCHAR zeta ENCODING 950 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP F0 40 80 80 80 70 10 ENDCHAR STARTCHAR eta ENCODING 951 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 E0 90 90 90 10 ENDCHAR STARTCHAR theta ENCODING 952 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 50 70 50 50 20 00 ENDCHAR STARTCHAR iota ENCODING 953 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 40 40 40 20 00 ENDCHAR STARTCHAR kappa ENCODING 954 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 90 A0 E0 90 00 ENDCHAR STARTCHAR lambda ENCODING 955 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP E0 10 50 B0 90 90 00 ENDCHAR STARTCHAR mu ENCODING 956 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 90 90 90 F0 80 ENDCHAR STARTCHAR nu ENCODING 957 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 50 50 50 20 00 ENDCHAR STARTCHAR xi ENCODING 958 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP F0 40 80 60 80 70 10 ENDCHAR STARTCHAR omicron ENCODING 959 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 60 90 90 60 00 ENDCHAR STARTCHAR pi ENCODING 960 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 70 50 50 50 00 ENDCHAR STARTCHAR rho ENCODING 961 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 60 90 90 E0 80 ENDCHAR STARTCHAR sigma1 ENCODING 962 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 70 C0 30 60 00 ENDCHAR STARTCHAR sigma ENCODING 963 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 70 A0 90 60 00 ENDCHAR STARTCHAR tau ENCODING 964 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 F0 40 40 20 00 ENDCHAR STARTCHAR upsilon ENCODING 965 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 90 90 90 60 00 ENDCHAR STARTCHAR phi ENCODING 966 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 20 70 50 70 20 ENDCHAR STARTCHAR chi ENCODING 967 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 90 60 60 90 90 ENDCHAR STARTCHAR psi ENCODING 968 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 50 70 70 20 20 ENDCHAR STARTCHAR omega ENCODING 969 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 90 90 F0 F0 00 ENDCHAR STARTCHAR iotadieresis ENCODING 970 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP A0 00 40 40 40 20 00 ENDCHAR STARTCHAR upsilondieresis ENCODING 971 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 90 00 90 90 90 60 00 ENDCHAR STARTCHAR omicrontonos ENCODING 972 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 40 60 90 90 60 00 ENDCHAR STARTCHAR upsilontonos ENCODING 973 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 40 90 90 90 60 00 ENDCHAR STARTCHAR omegatonos ENCODING 974 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 40 90 90 F0 F0 00 ENDCHAR STARTCHAR uni03D0 ENCODING 976 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 90 A0 D0 90 60 00 ENDCHAR STARTCHAR theta1 ENCODING 977 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 90 70 10 90 60 00 ENDCHAR STARTCHAR Upsilon1 ENCODING 978 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 50 50 20 20 20 00 ENDCHAR STARTCHAR uni03D3 ENCODING 979 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP D0 D0 50 20 20 20 00 ENDCHAR STARTCHAR uni03D4 ENCODING 980 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 00 50 50 20 20 00 ENDCHAR STARTCHAR phi1 ENCODING 981 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 20 70 50 70 20 ENDCHAR STARTCHAR omega1 ENCODING 982 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 F0 90 F0 F0 00 ENDCHAR STARTCHAR uni03D7 ENCODING 983 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 20 90 60 60 90 30 ENDCHAR STARTCHAR uni03DA ENCODING 986 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 50 80 80 60 10 20 ENDCHAR STARTCHAR uni03DB ENCODING 987 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 70 C0 30 60 00 ENDCHAR STARTCHAR uni03DC ENCODING 988 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP F0 80 E0 80 80 80 00 ENDCHAR STARTCHAR uni03DD ENCODING 989 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 70 40 60 40 40 ENDCHAR STARTCHAR uni03DE ENCODING 990 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 80 90 B0 D0 90 10 00 ENDCHAR STARTCHAR uni03DF ENCODING 991 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 40 80 F0 10 20 20 ENDCHAR STARTCHAR uni03E0 ENCODING 992 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 60 60 90 B0 B0 00 ENDCHAR STARTCHAR uni03E1 ENCODING 993 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP C0 20 50 B0 50 10 10 ENDCHAR STARTCHAR uni03F0 ENCODING 1008 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 90 60 60 B0 00 ENDCHAR STARTCHAR uni03F1 ENCODING 1009 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 60 90 E0 80 60 ENDCHAR STARTCHAR uni03F2 ENCODING 1010 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 30 40 40 30 00 ENDCHAR STARTCHAR uni03F3 ENCODING 1011 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 00 10 10 10 50 20 ENDCHAR STARTCHAR uni03F4 ENCODING 1012 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 90 F0 90 90 60 00 ENDCHAR STARTCHAR uni03F5 ENCODING 1013 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 30 60 40 30 00 ENDCHAR STARTCHAR afii10023 ENCODING 1025 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP F0 80 E0 80 80 F0 00 ENDCHAR STARTCHAR afii10051 ENCODING 1026 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP E0 40 60 50 50 10 20 ENDCHAR STARTCHAR afii10052 ENCODING 1027 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP F0 80 80 80 80 80 00 ENDCHAR STARTCHAR afii10053 ENCODING 1028 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 90 C0 80 90 60 00 ENDCHAR STARTCHAR afii10054 ENCODING 1029 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 90 40 20 90 60 00 ENDCHAR STARTCHAR afii10055 ENCODING 1030 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 70 20 20 20 20 70 00 ENDCHAR STARTCHAR afii10056 ENCODING 1031 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 70 20 20 20 20 70 00 ENDCHAR STARTCHAR afii10057 ENCODING 1032 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 10 10 10 90 60 00 ENDCHAR STARTCHAR afii10058 ENCODING 1033 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 A0 B0 A8 A8 B0 00 ENDCHAR STARTCHAR afii10059 ENCODING 1034 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP A0 A0 F0 A8 A8 B0 00 ENDCHAR STARTCHAR afii10060 ENCODING 1035 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP E0 40 60 50 50 50 00 ENDCHAR STARTCHAR afii10061 ENCODING 1036 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 90 A0 C0 C0 A0 90 00 ENDCHAR STARTCHAR afii10062 ENCODING 1038 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 50 50 20 20 40 00 ENDCHAR STARTCHAR afii10145 ENCODING 1039 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 50 50 50 50 70 20 ENDCHAR STARTCHAR afii10017 ENCODING 1040 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 90 90 F0 90 90 00 ENDCHAR STARTCHAR afii10018 ENCODING 1041 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP E0 80 E0 90 90 E0 00 ENDCHAR STARTCHAR afii10019 ENCODING 1042 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP E0 90 E0 90 90 E0 00 ENDCHAR STARTCHAR afii10020 ENCODING 1043 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP F0 80 80 80 80 80 00 ENDCHAR STARTCHAR afii10021 ENCODING 1044 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 30 50 50 50 50 F0 90 ENDCHAR STARTCHAR afii10022 ENCODING 1045 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP F0 80 E0 80 80 F0 00 ENDCHAR STARTCHAR afii10024 ENCODING 1046 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP A8 A8 70 70 A8 A8 00 ENDCHAR STARTCHAR afii10025 ENCODING 1047 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP E0 10 60 10 90 60 00 ENDCHAR STARTCHAR afii10026 ENCODING 1048 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 90 B0 B0 D0 D0 90 00 ENDCHAR STARTCHAR afii10027 ENCODING 1049 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP D0 B0 B0 D0 D0 90 00 ENDCHAR STARTCHAR afii10028 ENCODING 1050 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 90 A0 C0 C0 A0 90 00 ENDCHAR STARTCHAR afii10029 ENCODING 1051 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 30 50 50 50 50 90 00 ENDCHAR STARTCHAR afii10030 ENCODING 1052 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 90 F0 F0 90 90 90 00 ENDCHAR STARTCHAR afii10031 ENCODING 1053 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 90 90 F0 90 90 90 00 ENDCHAR STARTCHAR afii10032 ENCODING 1054 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 90 90 90 90 60 00 ENDCHAR STARTCHAR afii10033 ENCODING 1055 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP F0 90 90 90 90 90 00 ENDCHAR STARTCHAR afii10034 ENCODING 1056 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP E0 90 90 E0 80 80 00 ENDCHAR STARTCHAR afii10035 ENCODING 1057 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 90 80 80 90 60 00 ENDCHAR STARTCHAR afii10036 ENCODING 1058 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 70 20 20 20 20 20 00 ENDCHAR STARTCHAR afii10037 ENCODING 1059 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 50 50 20 20 40 00 ENDCHAR STARTCHAR afii10038 ENCODING 1060 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 70 50 50 70 20 00 ENDCHAR STARTCHAR afii10039 ENCODING 1061 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 90 90 60 60 90 90 00 ENDCHAR STARTCHAR afii10040 ENCODING 1062 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 90 90 90 90 90 F0 10 ENDCHAR STARTCHAR afii10041 ENCODING 1063 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 90 90 90 70 10 10 00 ENDCHAR STARTCHAR afii10042 ENCODING 1064 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP A8 A8 A8 A8 A8 F8 00 ENDCHAR STARTCHAR afii10043 ENCODING 1065 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP A8 A8 A8 A8 A8 F8 08 ENDCHAR STARTCHAR afii10044 ENCODING 1066 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP C0 40 60 50 50 60 00 ENDCHAR STARTCHAR afii10045 ENCODING 1067 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 90 90 D0 B0 B0 D0 00 ENDCHAR STARTCHAR afii10046 ENCODING 1068 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 80 80 E0 90 90 E0 00 ENDCHAR STARTCHAR afii10047 ENCODING 1069 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 90 30 10 90 60 00 ENDCHAR STARTCHAR afii10048 ENCODING 1070 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP A0 D0 D0 D0 D0 A0 00 ENDCHAR STARTCHAR afii10049 ENCODING 1071 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 70 90 90 70 50 90 00 ENDCHAR STARTCHAR afii10065 ENCODING 1072 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 70 90 B0 50 00 ENDCHAR STARTCHAR afii10066 ENCODING 1073 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 60 80 E0 90 60 00 ENDCHAR STARTCHAR afii10067 ENCODING 1074 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 E0 E0 90 E0 00 ENDCHAR STARTCHAR afii10068 ENCODING 1075 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 F0 80 80 80 00 ENDCHAR STARTCHAR afii10069 ENCODING 1076 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 30 50 50 F0 90 ENDCHAR STARTCHAR afii10070 ENCODING 1077 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 60 B0 C0 60 00 ENDCHAR STARTCHAR afii10072 ENCODING 1078 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 A8 70 70 A8 00 ENDCHAR STARTCHAR afii10073 ENCODING 1079 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 E0 60 20 C0 00 ENDCHAR STARTCHAR afii10074 ENCODING 1080 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 90 B0 D0 90 00 ENDCHAR STARTCHAR afii10075 ENCODING 1081 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 90 60 90 B0 D0 90 00 ENDCHAR STARTCHAR afii10076 ENCODING 1082 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 90 E0 A0 90 00 ENDCHAR STARTCHAR afii10077 ENCODING 1083 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 30 50 50 90 00 ENDCHAR STARTCHAR afii10078 ENCODING 1084 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 88 D8 A8 A8 00 ENDCHAR STARTCHAR afii10079 ENCODING 1085 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 90 F0 90 90 00 ENDCHAR STARTCHAR afii10080 ENCODING 1086 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 60 90 90 60 00 ENDCHAR STARTCHAR afii10081 ENCODING 1087 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 F0 90 90 90 00 ENDCHAR STARTCHAR afii10082 ENCODING 1088 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 E0 90 90 E0 80 ENDCHAR STARTCHAR afii10083 ENCODING 1089 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 60 80 80 60 00 ENDCHAR STARTCHAR afii10084 ENCODING 1090 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 E0 40 40 40 00 ENDCHAR STARTCHAR afii10085 ENCODING 1091 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 90 90 50 20 40 ENDCHAR STARTCHAR afii10086 ENCODING 1092 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 20 20 70 50 70 20 ENDCHAR STARTCHAR afii10087 ENCODING 1093 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 90 60 60 90 00 ENDCHAR STARTCHAR afii10088 ENCODING 1094 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 90 90 90 F0 10 ENDCHAR STARTCHAR afii10089 ENCODING 1095 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 90 90 70 10 00 ENDCHAR STARTCHAR afii10090 ENCODING 1096 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 A8 A8 A8 F8 00 ENDCHAR STARTCHAR afii10091 ENCODING 1097 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 A8 A8 A8 F8 08 ENDCHAR STARTCHAR afii10092 ENCODING 1098 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 C0 60 50 60 00 ENDCHAR STARTCHAR afii10093 ENCODING 1099 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 90 D0 B0 D0 00 ENDCHAR STARTCHAR afii10094 ENCODING 1100 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 80 E0 90 E0 00 ENDCHAR STARTCHAR afii10095 ENCODING 1101 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 60 30 10 60 00 ENDCHAR STARTCHAR afii10096 ENCODING 1102 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 A0 D0 D0 A0 00 ENDCHAR STARTCHAR afii10097 ENCODING 1103 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 60 A0 60 A0 00 ENDCHAR STARTCHAR afii10071 ENCODING 1105 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP A0 00 60 B0 C0 60 00 ENDCHAR STARTCHAR afii10099 ENCODING 1106 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 E0 40 60 50 10 20 ENDCHAR STARTCHAR afii10100 ENCODING 1107 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 40 F0 80 80 80 00 ENDCHAR STARTCHAR afii10101 ENCODING 1108 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 30 60 40 30 00 ENDCHAR STARTCHAR afii10102 ENCODING 1109 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 70 C0 30 E0 00 ENDCHAR STARTCHAR afii10103 ENCODING 1110 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 00 60 20 20 70 00 ENDCHAR STARTCHAR afii10104 ENCODING 1111 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 00 60 20 20 70 00 ENDCHAR STARTCHAR afii10105 ENCODING 1112 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 00 10 10 10 50 20 ENDCHAR STARTCHAR afii10106 ENCODING 1113 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 60 B8 A8 B0 00 ENDCHAR STARTCHAR afii10107 ENCODING 1114 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 A0 F0 A8 B0 00 ENDCHAR STARTCHAR afii10108 ENCODING 1115 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 E0 40 70 48 48 00 ENDCHAR STARTCHAR afii10109 ENCODING 1116 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 40 90 E0 A0 90 00 ENDCHAR STARTCHAR afii10110 ENCODING 1118 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 90 60 00 90 50 20 40 ENDCHAR STARTCHAR afii10193 ENCODING 1119 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 50 50 50 70 20 ENDCHAR STARTCHAR afii10050 ENCODING 1168 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 F0 80 80 80 80 00 ENDCHAR STARTCHAR afii10098 ENCODING 1169 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 10 F0 80 80 80 00 ENDCHAR STARTCHAR uni0492 ENCODING 1170 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 70 40 E0 40 40 00 ENDCHAR STARTCHAR uni0493 ENCODING 1171 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 70 40 E0 40 00 ENDCHAR STARTCHAR uni0496 ENCODING 1174 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP A8 A8 70 70 A8 A8 08 ENDCHAR STARTCHAR uni0497 ENCODING 1175 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 A8 70 70 A8 08 ENDCHAR STARTCHAR uni049A ENCODING 1178 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 90 A0 C0 C0 A0 90 08 ENDCHAR STARTCHAR uni049B ENCODING 1179 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 90 E0 A0 90 08 ENDCHAR STARTCHAR uni04AE ENCODING 1198 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 50 50 20 20 20 00 ENDCHAR STARTCHAR uni04AF ENCODING 1199 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 50 50 20 20 20 ENDCHAR STARTCHAR uni04B0 ENCODING 1200 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 50 20 70 20 20 00 ENDCHAR STARTCHAR uni04B1 ENCODING 1201 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 50 20 70 20 20 ENDCHAR STARTCHAR uni04B2 ENCODING 1202 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 90 90 60 60 90 90 08 ENDCHAR STARTCHAR uni04B3 ENCODING 1203 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 90 60 60 90 08 ENDCHAR STARTCHAR uni04BA ENCODING 1210 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 80 80 E0 90 90 90 00 ENDCHAR STARTCHAR uni04BB ENCODING 1211 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 40 60 50 50 50 00 ENDCHAR STARTCHAR uni04D8 ENCODING 1240 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 90 10 F0 90 60 00 ENDCHAR STARTCHAR afii10846 ENCODING 1241 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 60 30 D0 60 00 ENDCHAR STARTCHAR uni04E2 ENCODING 1250 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 70 20 20 20 20 70 00 ENDCHAR STARTCHAR uni04E3 ENCODING 1251 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 70 00 60 20 20 70 00 ENDCHAR STARTCHAR uni04E8 ENCODING 1256 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 90 F0 90 90 60 00 ENDCHAR STARTCHAR uni04E9 ENCODING 1257 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 60 F0 90 60 00 ENDCHAR STARTCHAR uni04EE ENCODING 1262 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 90 90 90 90 90 60 00 ENDCHAR STARTCHAR uni04EF ENCODING 1263 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP F0 00 90 90 90 70 00 ENDCHAR STARTCHAR afii57664 ENCODING 1488 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 90 50 A0 90 00 ENDCHAR STARTCHAR afii57665 ENCODING 1489 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 E0 20 20 F0 00 ENDCHAR STARTCHAR afii57666 ENCODING 1490 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 40 20 20 20 D0 00 ENDCHAR STARTCHAR afii57667 ENCODING 1491 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 F0 20 20 20 00 ENDCHAR STARTCHAR afii57668 ENCODING 1492 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 F0 10 90 90 00 ENDCHAR STARTCHAR afii57669 ENCODING 1493 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 40 20 20 20 20 00 ENDCHAR STARTCHAR afii57670 ENCODING 1494 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 70 20 20 20 00 ENDCHAR STARTCHAR afii57671 ENCODING 1495 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 F0 50 50 50 00 ENDCHAR STARTCHAR afii57672 ENCODING 1496 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 90 90 90 F0 00 ENDCHAR STARTCHAR afii57673 ENCODING 1497 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 40 20 00 00 00 00 ENDCHAR STARTCHAR afii57674 ENCODING 1498 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 F0 10 20 20 00 ENDCHAR STARTCHAR afii57675 ENCODING 1499 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 80 70 10 10 E0 00 ENDCHAR STARTCHAR afii57676 ENCODING 1500 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 80 70 10 20 40 00 ENDCHAR STARTCHAR afii57677 ENCODING 1501 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 80 70 90 90 F0 00 ENDCHAR STARTCHAR afii57678 ENCODING 1502 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 80 70 90 90 B0 00 ENDCHAR STARTCHAR afii57679 ENCODING 1503 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 40 20 40 40 40 00 ENDCHAR STARTCHAR afii57680 ENCODING 1504 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 40 20 20 20 60 00 ENDCHAR STARTCHAR afii57681 ENCODING 1505 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 80 78 48 48 30 00 ENDCHAR STARTCHAR afii57682 ENCODING 1506 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 90 50 50 F0 00 ENDCHAR STARTCHAR afii57683 ENCODING 1507 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 70 90 10 10 00 ENDCHAR STARTCHAR afii57684 ENCODING 1508 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 F0 90 10 F0 00 ENDCHAR STARTCHAR afii57685 ENCODING 1509 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 50 60 40 40 00 ENDCHAR STARTCHAR afii57686 ENCODING 1510 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 90 60 20 F0 00 ENDCHAR STARTCHAR afii57687 ENCODING 1511 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 E0 10 A0 80 00 ENDCHAR STARTCHAR afii57688 ENCODING 1512 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 F0 10 10 10 00 ENDCHAR STARTCHAR afii57689 ENCODING 1513 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 A8 C8 88 F0 00 ENDCHAR STARTCHAR afii57690 ENCODING 1514 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 F0 50 50 D0 00 ENDCHAR STARTCHAR uni16A0 ENCODING 5792 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 60 50 60 40 40 00 ENDCHAR STARTCHAR uni16A2 ENCODING 5794 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 50 50 50 50 50 00 ENDCHAR STARTCHAR uni16A3 ENCODING 5795 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 50 50 70 70 70 00 ENDCHAR STARTCHAR uni16A6 ENCODING 5798 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 60 50 50 60 40 00 ENDCHAR STARTCHAR uni16A9 ENCODING 5801 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP D0 A0 80 80 80 80 00 ENDCHAR STARTCHAR uni16AA ENCODING 5802 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP D0 A0 80 C0 A0 80 00 ENDCHAR STARTCHAR uni16AB ENCODING 5803 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 50 60 50 40 40 00 ENDCHAR STARTCHAR uni16B1 ENCODING 5809 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP E0 90 A0 C0 A0 80 00 ENDCHAR STARTCHAR uni16B3 ENCODING 5811 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 40 60 50 50 50 00 ENDCHAR STARTCHAR uni16B7 ENCODING 5815 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 50 20 20 50 50 00 ENDCHAR STARTCHAR uni16B8 ENCODING 5816 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 70 A8 A8 70 50 00 ENDCHAR STARTCHAR uni16B9 ENCODING 5817 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 50 50 60 40 40 00 ENDCHAR STARTCHAR uni16BB ENCODING 5819 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 90 90 D0 B0 D0 B0 00 ENDCHAR STARTCHAR uni16BE ENCODING 5822 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 20 60 30 20 20 00 ENDCHAR STARTCHAR uni16C0 ENCODING 5824 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 20 20 20 20 20 00 ENDCHAR STARTCHAR uni16C4 ENCODING 5828 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 70 A8 A8 70 20 00 ENDCHAR STARTCHAR uni16C7 ENCODING 5831 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 30 28 A0 60 20 00 ENDCHAR STARTCHAR uni16C8 ENCODING 5832 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP D0 A0 80 80 A0 D0 00 ENDCHAR STARTCHAR uni16C9 ENCODING 5833 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP A8 A8 A8 70 20 20 00 ENDCHAR STARTCHAR uni16CB ENCODING 5835 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 80 90 B0 D0 90 10 00 ENDCHAR STARTCHAR uni16CF ENCODING 5839 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 70 A8 20 20 20 00 ENDCHAR STARTCHAR uni16D2 ENCODING 5842 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP E0 90 E0 E0 90 E0 00 ENDCHAR STARTCHAR uni16D6 ENCODING 5846 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 88 D8 A8 88 88 88 00 ENDCHAR STARTCHAR uni16D7 ENCODING 5847 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 88 D8 A8 D8 88 88 00 ENDCHAR STARTCHAR uni16DA ENCODING 5850 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 60 50 40 40 40 00 ENDCHAR STARTCHAR uni16DD ENCODING 5853 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 20 50 50 20 50 00 ENDCHAR STARTCHAR uni16DE ENCODING 5854 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 88 88 D8 A8 D8 88 00 ENDCHAR STARTCHAR uni16DF ENCODING 5855 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 50 50 20 50 50 00 ENDCHAR STARTCHAR uni16E0 ENCODING 5856 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP A8 70 20 20 20 20 00 ENDCHAR STARTCHAR uni16E1 ENCODING 5857 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP A8 70 70 A8 20 20 00 ENDCHAR STARTCHAR uni16E2 ENCODING 5858 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 28 30 20 20 60 A0 00 ENDCHAR STARTCHAR uni16E3 ENCODING 5859 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 20 20 70 A8 A8 00 ENDCHAR STARTCHAR uni16E4 ENCODING 5860 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 90 F0 90 90 F0 90 00 ENDCHAR STARTCHAR uni16EB ENCODING 5867 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 00 20 00 00 00 ENDCHAR STARTCHAR uni16EC ENCODING 5868 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 20 00 20 00 00 ENDCHAR STARTCHAR uni16ED ENCODING 5869 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 50 20 50 00 00 ENDCHAR STARTCHAR uni1E02 ENCODING 7682 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP E0 90 E0 90 90 E0 00 ENDCHAR STARTCHAR uni1E03 ENCODING 7683 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 80 80 E0 90 E0 00 ENDCHAR STARTCHAR uni1E0A ENCODING 7690 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP E0 90 90 90 90 E0 00 ENDCHAR STARTCHAR uni1E0B ENCODING 7691 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 10 10 70 90 70 00 ENDCHAR STARTCHAR uni1E1E ENCODING 7710 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP F0 80 E0 80 80 80 00 ENDCHAR STARTCHAR uni1E1F ENCODING 7711 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 80 20 40 E0 40 40 00 ENDCHAR STARTCHAR uni1E40 ENCODING 7744 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 90 F0 F0 90 90 90 00 ENDCHAR STARTCHAR uni1E41 ENCODING 7745 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 00 A0 F0 90 90 00 ENDCHAR STARTCHAR uni1E56 ENCODING 7766 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP E0 90 90 E0 80 80 00 ENDCHAR STARTCHAR uni1E57 ENCODING 7767 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 00 E0 90 90 E0 80 ENDCHAR STARTCHAR uni1E60 ENCODING 7776 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 90 40 20 90 60 00 ENDCHAR STARTCHAR uni1E61 ENCODING 7777 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 00 70 C0 30 E0 00 ENDCHAR STARTCHAR uni1E6A ENCODING 7786 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 70 20 20 20 20 20 00 ENDCHAR STARTCHAR uni1E6B ENCODING 7787 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 80 20 70 20 20 10 00 ENDCHAR STARTCHAR Wgrave ENCODING 7808 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 90 90 90 F0 F0 90 00 ENDCHAR STARTCHAR wgrave ENCODING 7809 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 20 00 90 F0 F0 00 ENDCHAR STARTCHAR Wacute ENCODING 7810 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 90 90 90 F0 F0 90 00 ENDCHAR STARTCHAR wacute ENCODING 7811 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 40 00 90 F0 F0 00 ENDCHAR STARTCHAR Wdieresis ENCODING 7812 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 90 90 90 F0 F0 90 00 ENDCHAR STARTCHAR wdieresis ENCODING 7813 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 A0 00 90 F0 F0 00 ENDCHAR STARTCHAR Ygrave ENCODING 7922 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 50 50 20 20 20 00 ENDCHAR STARTCHAR ygrave ENCODING 7923 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 20 00 90 50 20 40 ENDCHAR STARTCHAR uni1F00 ENCODING 7936 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 20 70 90 B0 50 00 ENDCHAR STARTCHAR uni1F01 ENCODING 7937 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 40 70 90 B0 50 00 ENDCHAR STARTCHAR uni1F02 ENCODING 7938 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP E0 50 70 90 B0 50 00 ENDCHAR STARTCHAR uni1F03 ENCODING 7939 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP E0 90 70 90 B0 50 00 ENDCHAR STARTCHAR uni1F04 ENCODING 7940 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP D0 60 70 90 B0 50 00 ENDCHAR STARTCHAR uni1F05 ENCODING 7941 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP D0 A0 70 90 B0 50 00 ENDCHAR STARTCHAR uni1F06 ENCODING 7942 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 70 20 70 90 B0 50 00 ENDCHAR STARTCHAR uni1F07 ENCODING 7943 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 70 20 70 90 B0 50 00 ENDCHAR STARTCHAR uni1F08 ENCODING 7944 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP A0 D0 50 70 50 50 00 ENDCHAR STARTCHAR uni1F09 ENCODING 7945 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP A0 D0 50 70 50 50 00 ENDCHAR STARTCHAR uni1F0A ENCODING 7946 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP A0 D0 50 70 50 50 00 ENDCHAR STARTCHAR uni1F0B ENCODING 7947 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP A0 D0 50 70 50 50 00 ENDCHAR STARTCHAR uni1F0C ENCODING 7948 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP A0 D0 50 70 50 50 00 ENDCHAR STARTCHAR uni1F0D ENCODING 7949 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP A0 D0 50 70 50 50 00 ENDCHAR STARTCHAR uni1F0E ENCODING 7950 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP A0 D0 50 70 50 50 00 ENDCHAR STARTCHAR uni1F0F ENCODING 7951 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP A0 D0 50 70 50 50 00 ENDCHAR STARTCHAR uni1F10 ENCODING 7952 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 30 10 70 20 40 30 00 ENDCHAR STARTCHAR uni1F11 ENCODING 7953 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 30 20 70 20 40 30 00 ENDCHAR STARTCHAR uni1F12 ENCODING 7954 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP E0 50 E0 40 80 60 00 ENDCHAR STARTCHAR uni1F13 ENCODING 7955 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP E0 90 E0 40 80 60 00 ENDCHAR STARTCHAR uni1F14 ENCODING 7956 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP D0 60 E0 40 80 60 00 ENDCHAR STARTCHAR uni1F15 ENCODING 7957 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP D0 A0 E0 40 80 60 00 ENDCHAR STARTCHAR uni1F18 ENCODING 7960 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP F0 C0 60 40 40 70 00 ENDCHAR STARTCHAR uni1F19 ENCODING 7961 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP F0 C0 60 40 40 70 00 ENDCHAR STARTCHAR uni1F1A ENCODING 7962 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP F0 C0 60 40 40 70 00 ENDCHAR STARTCHAR uni1F1B ENCODING 7963 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP F0 C0 60 40 40 70 00 ENDCHAR STARTCHAR uni1F1C ENCODING 7964 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP F0 C0 60 40 40 70 00 ENDCHAR STARTCHAR uni1F1D ENCODING 7965 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP F0 C0 60 40 40 70 00 ENDCHAR STARTCHAR uni1F20 ENCODING 7968 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 20 E0 90 90 90 10 ENDCHAR STARTCHAR uni1F21 ENCODING 7969 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 40 E0 90 90 90 10 ENDCHAR STARTCHAR uni1F22 ENCODING 7970 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP E0 50 E0 90 90 90 10 ENDCHAR STARTCHAR uni1F23 ENCODING 7971 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP E0 90 E0 90 90 90 10 ENDCHAR STARTCHAR uni1F24 ENCODING 7972 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP D0 60 E0 90 90 90 10 ENDCHAR STARTCHAR uni1F25 ENCODING 7973 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP D0 A0 E0 90 90 90 10 ENDCHAR STARTCHAR uni1F26 ENCODING 7974 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 70 20 E0 90 90 90 10 ENDCHAR STARTCHAR uni1F27 ENCODING 7975 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 70 20 E0 90 90 90 10 ENDCHAR STARTCHAR uni1F28 ENCODING 7976 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP D0 D0 70 50 50 50 00 ENDCHAR STARTCHAR uni1F29 ENCODING 7977 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP D0 D0 70 50 50 50 00 ENDCHAR STARTCHAR uni1F2A ENCODING 7978 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP D0 D0 70 50 50 50 00 ENDCHAR STARTCHAR uni1F2B ENCODING 7979 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP D0 D0 70 50 50 50 00 ENDCHAR STARTCHAR uni1F2C ENCODING 7980 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP D0 D0 70 50 50 50 00 ENDCHAR STARTCHAR uni1F2D ENCODING 7981 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP D0 D0 70 50 50 50 00 ENDCHAR STARTCHAR uni1F2E ENCODING 7982 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP D0 D0 70 50 50 50 00 ENDCHAR STARTCHAR uni1F2F ENCODING 7983 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP D0 D0 70 50 50 50 00 ENDCHAR STARTCHAR uni1F30 ENCODING 7984 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 20 00 40 40 20 00 ENDCHAR STARTCHAR uni1F31 ENCODING 7985 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 40 00 40 40 20 00 ENDCHAR STARTCHAR uni1F32 ENCODING 7986 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP E0 50 00 40 40 20 00 ENDCHAR STARTCHAR uni1F33 ENCODING 7987 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP E0 90 00 40 40 20 00 ENDCHAR STARTCHAR uni1F34 ENCODING 7988 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP D0 60 00 40 40 20 00 ENDCHAR STARTCHAR uni1F35 ENCODING 7989 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP D0 A0 00 40 40 20 00 ENDCHAR STARTCHAR uni1F36 ENCODING 7990 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP E0 40 00 40 40 20 00 ENDCHAR STARTCHAR uni1F37 ENCODING 7991 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP E0 40 00 40 40 20 00 ENDCHAR STARTCHAR uni1F38 ENCODING 7992 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP F0 A0 20 20 20 70 00 ENDCHAR STARTCHAR uni1F39 ENCODING 7993 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP F0 A0 20 20 20 70 00 ENDCHAR STARTCHAR uni1F3A ENCODING 7994 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP F0 A0 20 20 20 70 00 ENDCHAR STARTCHAR uni1F3B ENCODING 7995 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP F0 A0 20 20 20 70 00 ENDCHAR STARTCHAR uni1F3C ENCODING 7996 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP F0 A0 20 20 20 70 00 ENDCHAR STARTCHAR uni1F3D ENCODING 7997 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP F0 A0 20 20 20 70 00 ENDCHAR STARTCHAR uni1F3E ENCODING 7998 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP F0 A0 20 20 20 70 00 ENDCHAR STARTCHAR uni1F3F ENCODING 7999 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP F0 A0 20 20 20 70 00 ENDCHAR STARTCHAR uni1F40 ENCODING 8000 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 20 60 90 90 60 00 ENDCHAR STARTCHAR uni1F41 ENCODING 8001 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 40 60 90 90 60 00 ENDCHAR STARTCHAR uni1F42 ENCODING 8002 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP E0 50 60 90 90 60 00 ENDCHAR STARTCHAR uni1F43 ENCODING 8003 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP E0 90 60 90 90 60 00 ENDCHAR STARTCHAR uni1F44 ENCODING 8004 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP D0 60 60 90 90 60 00 ENDCHAR STARTCHAR uni1F45 ENCODING 8005 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP D0 A0 60 90 90 60 00 ENDCHAR STARTCHAR uni1F48 ENCODING 8008 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP A0 D0 50 50 50 20 00 ENDCHAR STARTCHAR uni1F49 ENCODING 8009 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP A0 D0 50 50 50 20 00 ENDCHAR STARTCHAR uni1F4A ENCODING 8010 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP A0 D0 50 50 50 20 00 ENDCHAR STARTCHAR uni1F4B ENCODING 8011 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP A0 D0 50 50 50 20 00 ENDCHAR STARTCHAR uni1F4C ENCODING 8012 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP A0 D0 50 50 50 20 00 ENDCHAR STARTCHAR uni1F4D ENCODING 8013 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP A0 D0 50 50 50 20 00 ENDCHAR STARTCHAR uni1F50 ENCODING 8016 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 20 90 90 90 60 00 ENDCHAR STARTCHAR uni1F51 ENCODING 8017 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 40 90 90 90 60 00 ENDCHAR STARTCHAR uni1F52 ENCODING 8018 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP E0 50 90 90 90 60 00 ENDCHAR STARTCHAR uni1F53 ENCODING 8019 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP E0 90 90 90 90 60 00 ENDCHAR STARTCHAR uni1F54 ENCODING 8020 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP D0 60 90 90 90 60 00 ENDCHAR STARTCHAR uni1F55 ENCODING 8021 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP D0 A0 90 90 90 60 00 ENDCHAR STARTCHAR uni1F56 ENCODING 8022 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 70 20 90 90 90 60 00 ENDCHAR STARTCHAR uni1F57 ENCODING 8023 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 70 20 90 90 90 60 00 ENDCHAR STARTCHAR uni1F59 ENCODING 8025 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP D0 D0 50 20 20 20 00 ENDCHAR STARTCHAR uni1F5B ENCODING 8027 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP D0 D0 50 20 20 20 00 ENDCHAR STARTCHAR uni1F5D ENCODING 8029 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP D0 D0 50 20 20 20 00 ENDCHAR STARTCHAR uni1F5F ENCODING 8031 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP D0 D0 50 20 20 20 00 ENDCHAR STARTCHAR uni1F60 ENCODING 8032 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 20 90 90 F0 F0 00 ENDCHAR STARTCHAR uni1F61 ENCODING 8033 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 40 90 90 F0 F0 00 ENDCHAR STARTCHAR uni1F62 ENCODING 8034 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP E0 50 90 90 F0 F0 00 ENDCHAR STARTCHAR uni1F63 ENCODING 8035 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP E0 90 90 90 F0 F0 00 ENDCHAR STARTCHAR uni1F64 ENCODING 8036 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP D0 60 90 90 F0 F0 00 ENDCHAR STARTCHAR uni1F65 ENCODING 8037 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP D0 A0 90 90 F0 F0 00 ENDCHAR STARTCHAR uni1F66 ENCODING 8038 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 70 20 90 90 F0 F0 00 ENDCHAR STARTCHAR uni1F67 ENCODING 8039 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 70 20 90 90 F0 F0 00 ENDCHAR STARTCHAR uni1F68 ENCODING 8040 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP A0 D0 50 50 20 50 00 ENDCHAR STARTCHAR uni1F69 ENCODING 8041 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP A0 D0 50 50 20 50 00 ENDCHAR STARTCHAR uni1F6A ENCODING 8042 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP A0 D0 50 50 20 50 00 ENDCHAR STARTCHAR uni1F6B ENCODING 8043 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP A0 D0 50 50 20 50 00 ENDCHAR STARTCHAR uni1F6C ENCODING 8044 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP A0 D0 50 50 20 50 00 ENDCHAR STARTCHAR uni1F6D ENCODING 8045 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP A0 D0 50 50 20 50 00 ENDCHAR STARTCHAR uni1F6E ENCODING 8046 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP A0 D0 50 50 20 50 00 ENDCHAR STARTCHAR uni1F6F ENCODING 8047 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP A0 D0 50 50 20 50 00 ENDCHAR STARTCHAR uni1F70 ENCODING 8048 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 20 70 90 B0 50 00 ENDCHAR STARTCHAR uni1F71 ENCODING 8049 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 20 70 90 B0 50 00 ENDCHAR STARTCHAR uni1F72 ENCODING 8050 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 20 70 20 40 30 00 ENDCHAR STARTCHAR uni1F73 ENCODING 8051 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 20 70 20 40 30 00 ENDCHAR STARTCHAR uni1F74 ENCODING 8052 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 80 40 E0 90 90 90 10 ENDCHAR STARTCHAR uni1F75 ENCODING 8053 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 40 E0 90 90 90 10 ENDCHAR STARTCHAR uni1F76 ENCODING 8054 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 80 40 00 40 40 20 00 ENDCHAR STARTCHAR uni1F77 ENCODING 8055 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 40 00 40 40 20 00 ENDCHAR STARTCHAR uni1F78 ENCODING 8056 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 80 40 60 90 90 60 00 ENDCHAR STARTCHAR uni1F79 ENCODING 8057 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 40 60 90 90 60 00 ENDCHAR STARTCHAR uni1F7A ENCODING 8058 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 20 90 90 90 60 00 ENDCHAR STARTCHAR uni1F7B ENCODING 8059 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 40 90 90 90 60 00 ENDCHAR STARTCHAR uni1F7C ENCODING 8060 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 20 90 90 F0 F0 00 ENDCHAR STARTCHAR uni1F7D ENCODING 8061 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 40 90 90 F0 F0 00 ENDCHAR STARTCHAR uni1F80 ENCODING 8064 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 20 70 90 B0 50 40 ENDCHAR STARTCHAR uni1F81 ENCODING 8065 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 40 70 90 B0 50 40 ENDCHAR STARTCHAR uni1F82 ENCODING 8066 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP E0 50 70 90 B0 50 40 ENDCHAR STARTCHAR uni1F83 ENCODING 8067 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP E0 90 70 90 B0 50 40 ENDCHAR STARTCHAR uni1F84 ENCODING 8068 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP D0 60 70 90 B0 50 40 ENDCHAR STARTCHAR uni1F85 ENCODING 8069 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP D0 A0 70 90 B0 50 40 ENDCHAR STARTCHAR uni1F86 ENCODING 8070 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 70 20 70 90 B0 50 40 ENDCHAR STARTCHAR uni1F87 ENCODING 8071 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 70 20 70 90 B0 50 40 ENDCHAR STARTCHAR uni1F88 ENCODING 8072 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP A0 D0 50 70 50 50 20 ENDCHAR STARTCHAR uni1F89 ENCODING 8073 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP A0 D0 50 70 50 50 20 ENDCHAR STARTCHAR uni1F8A ENCODING 8074 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP A0 D0 50 70 50 50 20 ENDCHAR STARTCHAR uni1F8B ENCODING 8075 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP A0 D0 50 70 50 50 20 ENDCHAR STARTCHAR uni1F8C ENCODING 8076 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP A0 D0 50 70 50 50 20 ENDCHAR STARTCHAR uni1F8D ENCODING 8077 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP A0 D0 50 70 50 50 20 ENDCHAR STARTCHAR uni1F8E ENCODING 8078 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP A0 D0 50 70 50 50 20 ENDCHAR STARTCHAR uni1F8F ENCODING 8079 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP A0 D0 50 70 50 50 20 ENDCHAR STARTCHAR uni1F90 ENCODING 8080 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 20 E0 90 90 10 90 ENDCHAR STARTCHAR uni1F91 ENCODING 8081 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 40 E0 90 90 10 90 ENDCHAR STARTCHAR uni1F92 ENCODING 8082 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP E0 50 E0 90 90 10 90 ENDCHAR STARTCHAR uni1F93 ENCODING 8083 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP E0 90 E0 90 90 10 90 ENDCHAR STARTCHAR uni1F94 ENCODING 8084 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP D0 60 E0 90 90 10 90 ENDCHAR STARTCHAR uni1F95 ENCODING 8085 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP D0 A0 E0 90 90 10 90 ENDCHAR STARTCHAR uni1F96 ENCODING 8086 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 70 20 E0 90 90 10 90 ENDCHAR STARTCHAR uni1F97 ENCODING 8087 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 70 20 E0 90 90 10 90 ENDCHAR STARTCHAR uni1F98 ENCODING 8088 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP D0 D0 70 50 50 50 20 ENDCHAR STARTCHAR uni1F99 ENCODING 8089 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP D0 D0 70 50 50 50 20 ENDCHAR STARTCHAR uni1F9A ENCODING 8090 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP D0 D0 70 50 50 50 20 ENDCHAR STARTCHAR uni1F9B ENCODING 8091 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP D0 D0 70 50 50 50 20 ENDCHAR STARTCHAR uni1F9C ENCODING 8092 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP D0 D0 70 50 50 50 20 ENDCHAR STARTCHAR uni1F9D ENCODING 8093 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP D0 D0 70 50 50 50 20 ENDCHAR STARTCHAR uni1F9E ENCODING 8094 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP D0 D0 70 50 50 50 20 ENDCHAR STARTCHAR uni1F9F ENCODING 8095 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP D0 D0 70 50 50 50 20 ENDCHAR STARTCHAR uni1FA0 ENCODING 8096 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 20 90 90 F0 F0 40 ENDCHAR STARTCHAR uni1FA1 ENCODING 8097 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 40 90 90 F0 F0 40 ENDCHAR STARTCHAR uni1FA2 ENCODING 8098 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP E0 50 90 90 F0 F0 40 ENDCHAR STARTCHAR uni1FA3 ENCODING 8099 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP E0 90 90 90 F0 F0 40 ENDCHAR STARTCHAR uni1FA4 ENCODING 8100 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP D0 60 90 90 F0 F0 40 ENDCHAR STARTCHAR uni1FA5 ENCODING 8101 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP D0 A0 90 90 F0 F0 40 ENDCHAR STARTCHAR uni1FA6 ENCODING 8102 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 70 20 90 90 F0 F0 40 ENDCHAR STARTCHAR uni1FA7 ENCODING 8103 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 70 20 90 90 F0 F0 40 ENDCHAR STARTCHAR uni1FA8 ENCODING 8104 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP A0 D0 50 50 20 50 20 ENDCHAR STARTCHAR uni1FA9 ENCODING 8105 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP A0 D0 50 50 20 50 20 ENDCHAR STARTCHAR uni1FAA ENCODING 8106 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP A0 D0 50 50 20 50 20 ENDCHAR STARTCHAR uni1FAB ENCODING 8107 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP A0 D0 50 50 20 50 20 ENDCHAR STARTCHAR uni1FAC ENCODING 8108 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP A0 D0 50 50 20 50 20 ENDCHAR STARTCHAR uni1FAD ENCODING 8109 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP A0 D0 50 50 20 50 20 ENDCHAR STARTCHAR uni1FAE ENCODING 8110 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP A0 D0 50 50 20 50 20 ENDCHAR STARTCHAR uni1FAF ENCODING 8111 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP A0 D0 50 50 20 50 20 ENDCHAR STARTCHAR uni1FB0 ENCODING 8112 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 90 60 70 90 B0 50 00 ENDCHAR STARTCHAR uni1FB1 ENCODING 8113 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP F0 00 70 90 B0 50 00 ENDCHAR STARTCHAR uni1FB2 ENCODING 8114 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 20 70 90 B0 50 40 ENDCHAR STARTCHAR uni1FB3 ENCODING 8115 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 70 90 B0 50 40 ENDCHAR STARTCHAR uni1FB4 ENCODING 8116 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 20 70 90 B0 50 40 ENDCHAR STARTCHAR uni1FB6 ENCODING 8118 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 70 00 70 90 B0 50 00 ENDCHAR STARTCHAR uni1FB7 ENCODING 8119 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 70 00 70 90 B0 50 40 ENDCHAR STARTCHAR uni1FB8 ENCODING 8120 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 90 60 60 90 F0 90 00 ENDCHAR STARTCHAR uni1FB9 ENCODING 8121 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP F0 00 60 90 F0 90 00 ENDCHAR STARTCHAR uni1FBA ENCODING 8122 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP A0 D0 50 70 50 50 00 ENDCHAR STARTCHAR uni1FBB ENCODING 8123 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP A0 D0 50 70 50 50 00 ENDCHAR STARTCHAR uni1FBC ENCODING 8124 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 90 90 F0 90 90 40 ENDCHAR STARTCHAR uni1FBD ENCODING 8125 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 20 00 00 00 00 00 ENDCHAR STARTCHAR uni1FBE ENCODING 8126 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 00 40 40 20 00 ENDCHAR STARTCHAR uni1FBF ENCODING 8127 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 20 00 00 00 00 00 ENDCHAR STARTCHAR uni1FC0 ENCODING 8128 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP E0 00 00 00 00 00 00 ENDCHAR STARTCHAR uni1FC1 ENCODING 8129 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP E0 A0 00 00 00 00 00 ENDCHAR STARTCHAR uni1FC2 ENCODING 8130 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 80 40 E0 90 90 10 90 ENDCHAR STARTCHAR uni1FC3 ENCODING 8131 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 E0 90 90 10 90 ENDCHAR STARTCHAR uni1FC4 ENCODING 8132 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 40 E0 90 90 10 90 ENDCHAR STARTCHAR uni1FC6 ENCODING 8134 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 70 00 E0 90 90 90 10 ENDCHAR STARTCHAR uni1FC7 ENCODING 8135 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 70 00 E0 90 90 10 90 ENDCHAR STARTCHAR uni1FC8 ENCODING 8136 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP F0 C0 60 40 40 70 00 ENDCHAR STARTCHAR uni1FC9 ENCODING 8137 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP F0 C0 60 40 40 70 00 ENDCHAR STARTCHAR uni1FCA ENCODING 8138 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP D0 D0 70 50 50 50 00 ENDCHAR STARTCHAR uni1FCB ENCODING 8139 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP D0 D0 70 50 50 50 00 ENDCHAR STARTCHAR uni1FCC ENCODING 8140 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 90 90 F0 90 90 90 40 ENDCHAR STARTCHAR uni1FCD ENCODING 8141 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP E0 50 00 00 00 00 00 ENDCHAR STARTCHAR uni1FCE ENCODING 8142 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP D0 60 00 00 00 00 00 ENDCHAR STARTCHAR uni1FCF ENCODING 8143 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP E0 40 00 00 00 00 00 ENDCHAR STARTCHAR uni1FD0 ENCODING 8144 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 90 60 40 40 40 20 00 ENDCHAR STARTCHAR uni1FD1 ENCODING 8145 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP F0 00 40 40 40 20 00 ENDCHAR STARTCHAR uni1FD2 ENCODING 8146 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP D0 20 00 20 20 10 00 ENDCHAR STARTCHAR uni1FD3 ENCODING 8147 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP B0 40 00 40 40 20 00 ENDCHAR STARTCHAR uni1FD6 ENCODING 8150 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP E0 00 40 40 40 20 00 ENDCHAR STARTCHAR uni1FD7 ENCODING 8151 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP E0 A0 00 40 40 20 00 ENDCHAR STARTCHAR uni1FD8 ENCODING 8152 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 90 60 70 20 20 70 00 ENDCHAR STARTCHAR uni1FD9 ENCODING 8153 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 70 00 70 20 20 70 00 ENDCHAR STARTCHAR uni1FDA ENCODING 8154 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP F0 A0 20 20 20 70 00 ENDCHAR STARTCHAR uni1FDB ENCODING 8155 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP F0 A0 20 20 20 70 00 ENDCHAR STARTCHAR uni1FDD ENCODING 8157 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP E0 90 00 00 00 00 00 ENDCHAR STARTCHAR uni1FDE ENCODING 8158 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP D0 A0 00 00 00 00 00 ENDCHAR STARTCHAR uni1FDF ENCODING 8159 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP E0 40 00 00 00 00 00 ENDCHAR STARTCHAR uni1FE0 ENCODING 8160 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 90 60 90 90 90 60 00 ENDCHAR STARTCHAR uni1FE1 ENCODING 8161 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP F0 00 90 90 90 60 00 ENDCHAR STARTCHAR uni1FE2 ENCODING 8162 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP D0 20 90 90 90 60 00 ENDCHAR STARTCHAR uni1FE3 ENCODING 8163 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP B0 40 90 90 90 60 00 ENDCHAR STARTCHAR uni1FE4 ENCODING 8164 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 20 60 90 90 E0 80 ENDCHAR STARTCHAR uni1FE5 ENCODING 8165 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 40 60 90 90 E0 80 ENDCHAR STARTCHAR uni1FE6 ENCODING 8166 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 70 00 90 90 90 60 00 ENDCHAR STARTCHAR uni1FE7 ENCODING 8167 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP F0 90 00 90 90 60 00 ENDCHAR STARTCHAR uni1FE8 ENCODING 8168 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 90 60 A0 A0 40 40 00 ENDCHAR STARTCHAR uni1FE9 ENCODING 8169 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP F0 00 A0 A0 40 40 00 ENDCHAR STARTCHAR uni1FEA ENCODING 8170 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP D0 D0 50 20 20 20 00 ENDCHAR STARTCHAR uni1FEB ENCODING 8171 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP D0 D0 50 20 20 20 00 ENDCHAR STARTCHAR uni1FEC ENCODING 8172 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP E0 D0 50 60 40 40 00 ENDCHAR STARTCHAR uni1FED ENCODING 8173 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP D0 20 00 00 00 00 00 ENDCHAR STARTCHAR uni1FEE ENCODING 8174 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP B0 40 00 00 00 00 00 ENDCHAR STARTCHAR uni1FEF ENCODING 8175 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 20 00 00 00 00 00 ENDCHAR STARTCHAR uni1FF2 ENCODING 8178 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 20 90 90 F0 F0 40 ENDCHAR STARTCHAR uni1FF3 ENCODING 8179 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 90 90 F0 F0 40 ENDCHAR STARTCHAR uni1FF4 ENCODING 8180 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 40 90 90 F0 F0 40 ENDCHAR STARTCHAR uni1FF6 ENCODING 8182 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 70 00 90 90 F0 F0 00 ENDCHAR STARTCHAR uni1FF7 ENCODING 8183 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 70 00 90 90 F0 F0 40 ENDCHAR STARTCHAR uni1FF8 ENCODING 8184 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP A0 D0 50 50 50 20 00 ENDCHAR STARTCHAR uni1FF9 ENCODING 8185 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP A0 D0 50 50 50 20 00 ENDCHAR STARTCHAR uni1FFA ENCODING 8186 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP A0 D0 50 50 20 50 00 ENDCHAR STARTCHAR uni1FFB ENCODING 8187 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP A0 D0 50 50 20 50 00 ENDCHAR STARTCHAR uni1FFC ENCODING 8188 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 50 50 50 20 50 20 ENDCHAR STARTCHAR uni1FFD ENCODING 8189 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 40 00 00 00 00 00 ENDCHAR STARTCHAR uni1FFE ENCODING 8190 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 40 00 00 00 00 00 ENDCHAR STARTCHAR uni2010 ENCODING 8208 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 00 70 00 00 00 ENDCHAR STARTCHAR uni2011 ENCODING 8209 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 00 70 00 00 00 ENDCHAR STARTCHAR figuredash ENCODING 8210 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 00 F0 00 00 00 ENDCHAR STARTCHAR endash ENCODING 8211 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 00 F0 00 00 00 ENDCHAR STARTCHAR emdash ENCODING 8212 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 00 F8 00 00 00 ENDCHAR STARTCHAR afii00208 ENCODING 8213 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 00 F8 00 00 00 ENDCHAR STARTCHAR uni2016 ENCODING 8214 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 50 50 50 50 50 00 ENDCHAR STARTCHAR underscoredbl ENCODING 8215 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 00 00 F0 00 F0 ENDCHAR STARTCHAR quoteleft ENCODING 8216 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 40 60 00 00 00 00 ENDCHAR STARTCHAR quoteright ENCODING 8217 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 20 40 00 00 00 00 ENDCHAR STARTCHAR quotesinglbase ENCODING 8218 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 00 00 60 20 40 ENDCHAR STARTCHAR quotereversed ENCODING 8219 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 40 20 00 00 00 00 ENDCHAR STARTCHAR quotedblleft ENCODING 8220 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 A0 A0 00 00 00 00 ENDCHAR STARTCHAR quotedblright ENCODING 8221 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 50 A0 00 00 00 00 ENDCHAR STARTCHAR quotedblbase ENCODING 8222 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 00 00 50 50 A0 ENDCHAR STARTCHAR uni201F ENCODING 8223 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP A0 A0 50 00 00 00 00 ENDCHAR STARTCHAR dagger ENCODING 8224 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 20 70 20 20 20 00 ENDCHAR STARTCHAR daggerdbl ENCODING 8225 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 20 70 20 70 20 00 ENDCHAR STARTCHAR bullet ENCODING 8226 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 60 F0 F0 60 00 ENDCHAR STARTCHAR uni2023 ENCODING 8227 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 40 60 70 60 40 00 ENDCHAR STARTCHAR onedotenleader ENCODING 8228 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 00 00 00 20 00 ENDCHAR STARTCHAR twodotenleader ENCODING 8229 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 00 00 00 50 00 ENDCHAR STARTCHAR ellipsis ENCODING 8230 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 00 00 00 A8 00 ENDCHAR STARTCHAR uni2027 ENCODING 8231 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 00 60 00 00 00 ENDCHAR STARTCHAR perthousand ENCODING 8240 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 80 90 20 40 A8 28 00 ENDCHAR STARTCHAR minute ENCODING 8242 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 20 40 00 00 00 00 ENDCHAR STARTCHAR second ENCODING 8243 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 50 A0 00 00 00 00 ENDCHAR STARTCHAR uni2034 ENCODING 8244 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 70 70 E0 00 00 00 00 ENDCHAR STARTCHAR uni2035 ENCODING 8245 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 40 20 00 00 00 00 ENDCHAR STARTCHAR uni2036 ENCODING 8246 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP A0 A0 50 00 00 00 00 ENDCHAR STARTCHAR uni2037 ENCODING 8247 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP E0 E0 70 00 00 00 00 ENDCHAR STARTCHAR guilsinglleft ENCODING 8249 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 20 40 20 00 00 ENDCHAR STARTCHAR guilsinglright ENCODING 8250 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 40 20 40 00 00 ENDCHAR STARTCHAR exclamdbl ENCODING 8252 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 50 50 50 00 50 00 ENDCHAR STARTCHAR uni203E ENCODING 8254 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP F8 00 00 00 00 00 00 ENDCHAR STARTCHAR fraction ENCODING 8260 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 10 20 40 80 00 00 ENDCHAR STARTCHAR zerosuperior ENCODING 8304 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 50 50 20 00 00 00 ENDCHAR STARTCHAR uni2071 ENCODING 8305 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 00 20 20 00 00 00 ENDCHAR STARTCHAR foursuperior ENCODING 8308 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 60 70 20 00 00 00 ENDCHAR STARTCHAR fivesuperior ENCODING 8309 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 70 60 10 60 00 00 00 ENDCHAR STARTCHAR sixsuperior ENCODING 8310 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 30 60 50 20 00 00 00 ENDCHAR STARTCHAR sevensuperior ENCODING 8311 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 70 10 20 20 00 00 00 ENDCHAR STARTCHAR eightsuperior ENCODING 8312 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 50 20 50 20 00 00 ENDCHAR STARTCHAR ninesuperior ENCODING 8313 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 50 30 60 00 00 00 ENDCHAR STARTCHAR uni207A ENCODING 8314 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 20 70 20 00 00 00 ENDCHAR STARTCHAR uni207B ENCODING 8315 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 70 00 00 00 00 ENDCHAR STARTCHAR uni207C ENCODING 8316 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 70 00 70 00 00 00 ENDCHAR STARTCHAR parenleftsuperior ENCODING 8317 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 40 40 20 00 00 00 ENDCHAR STARTCHAR parenrightsuperior ENCODING 8318 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 10 10 20 00 00 00 ENDCHAR STARTCHAR nsuperior ENCODING 8319 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 60 50 50 00 00 00 ENDCHAR STARTCHAR zeroinferior ENCODING 8320 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 00 20 50 50 20 ENDCHAR STARTCHAR oneinferior ENCODING 8321 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 00 20 60 20 70 ENDCHAR STARTCHAR twoinferior ENCODING 8322 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 00 60 20 40 60 ENDCHAR STARTCHAR threeinferior ENCODING 8323 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 00 60 60 20 60 ENDCHAR STARTCHAR fourinferior ENCODING 8324 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 00 20 60 70 20 ENDCHAR STARTCHAR fiveinferior ENCODING 8325 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 00 70 60 10 60 ENDCHAR STARTCHAR sixinferior ENCODING 8326 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 00 30 60 50 20 ENDCHAR STARTCHAR seveninferior ENCODING 8327 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 00 70 10 20 20 ENDCHAR STARTCHAR eightinferior ENCODING 8328 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 20 50 20 50 20 ENDCHAR STARTCHAR nineinferior ENCODING 8329 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 00 20 50 30 60 ENDCHAR STARTCHAR uni208A ENCODING 8330 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 00 00 20 70 20 ENDCHAR STARTCHAR uni208B ENCODING 8331 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 00 00 00 70 00 ENDCHAR STARTCHAR uni208C ENCODING 8332 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 00 00 70 00 70 ENDCHAR STARTCHAR parenleftinferior ENCODING 8333 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 00 20 40 40 20 ENDCHAR STARTCHAR parenrightinferior ENCODING 8334 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 00 20 10 10 20 ENDCHAR STARTCHAR franc ENCODING 8355 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP F0 80 D8 A0 A0 A0 00 ENDCHAR STARTCHAR lira ENCODING 8356 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 30 40 E0 E0 40 B0 00 ENDCHAR STARTCHAR peseta ENCODING 8359 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 50 F8 70 40 40 00 ENDCHAR STARTCHAR dong ENCODING 8363 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 38 70 90 90 70 F0 ENDCHAR STARTCHAR Euro ENCODING 8364 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 30 40 E0 E0 40 30 00 ENDCHAR STARTCHAR uni20AF ENCODING 8367 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 60 D0 50 D0 E0 00 ENDCHAR STARTCHAR uni20D0 ENCODING 8400 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 F8 00 00 00 00 00 ENDCHAR STARTCHAR uni20D1 ENCODING 8401 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 F8 00 00 00 00 00 ENDCHAR STARTCHAR uni20D2 ENCODING 8402 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 20 20 20 20 20 20 ENDCHAR STARTCHAR uni20D3 ENCODING 8403 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 20 20 20 20 20 20 ENDCHAR STARTCHAR uni20D4 ENCODING 8404 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP A0 D0 D0 00 00 00 00 ENDCHAR STARTCHAR uni20D5 ENCODING 8405 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 B0 B0 00 00 00 00 ENDCHAR STARTCHAR uni20D6 ENCODING 8406 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 F8 40 00 00 00 00 ENDCHAR STARTCHAR uni20D7 ENCODING 8407 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 F8 10 00 00 00 00 ENDCHAR STARTCHAR uni2102 ENCODING 8450 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 D0 C0 C0 D0 60 00 ENDCHAR STARTCHAR afii61248 ENCODING 8453 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 80 70 60 A0 50 20 ENDCHAR STARTCHAR afii61289 ENCODING 8467 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 30 30 30 20 20 50 00 ENDCHAR STARTCHAR uni2115 ENCODING 8469 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP C8 C8 E8 D8 C8 C8 00 ENDCHAR STARTCHAR afii61352 ENCODING 8470 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP C0 A0 A0 B0 A8 B0 00 ENDCHAR STARTCHAR uni211A ENCODING 8474 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 D0 D0 D0 F0 70 10 ENDCHAR STARTCHAR uni211D ENCODING 8477 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP E0 D0 D0 F0 E0 D0 00 ENDCHAR STARTCHAR trademark ENCODING 8482 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 70 20 20 00 F8 A8 A8 ENDCHAR STARTCHAR uni2124 ENCODING 8484 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP F0 30 60 60 C0 F0 00 ENDCHAR STARTCHAR Omega ENCODING 8486 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 50 50 50 20 70 00 ENDCHAR STARTCHAR uni2127 ENCODING 8487 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 70 20 50 50 50 20 00 ENDCHAR STARTCHAR estimated ENCODING 8494 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 70 D8 E0 70 00 ENDCHAR STARTCHAR oneeighth ENCODING 8539 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 80 80 80 B0 30 30 30 ENDCHAR STARTCHAR threeeighths ENCODING 8540 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP C0 C0 40 F0 30 30 30 ENDCHAR STARTCHAR fiveeighths ENCODING 8541 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP C0 80 40 B0 30 30 30 ENDCHAR STARTCHAR seveneighths ENCODING 8542 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP C0 40 80 B0 30 30 30 ENDCHAR STARTCHAR arrowleft ENCODING 8592 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 40 F0 40 00 00 ENDCHAR STARTCHAR arrowup ENCODING 8593 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 70 20 20 20 20 00 ENDCHAR STARTCHAR arrowright ENCODING 8594 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 20 F0 20 00 00 ENDCHAR STARTCHAR arrowdown ENCODING 8595 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 20 20 20 70 20 00 ENDCHAR STARTCHAR arrowboth ENCODING 8596 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 50 F8 50 00 00 ENDCHAR STARTCHAR arrowupdn ENCODING 8597 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 70 20 20 70 20 00 ENDCHAR STARTCHAR uni21A4 ENCODING 8612 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 50 F0 50 00 00 ENDCHAR STARTCHAR uni21A5 ENCODING 8613 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 70 20 20 20 70 00 ENDCHAR STARTCHAR uni21A6 ENCODING 8614 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 A0 F0 A0 00 00 ENDCHAR STARTCHAR uni21A7 ENCODING 8615 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 70 20 20 20 70 20 00 ENDCHAR STARTCHAR arrowupdnbse ENCODING 8616 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 70 20 20 70 20 70 ENDCHAR STARTCHAR uni21C4 ENCODING 8644 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 F8 10 40 F8 40 00 ENDCHAR STARTCHAR uni21C6 ENCODING 8646 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 F8 40 10 F8 10 00 ENDCHAR STARTCHAR uni21CB ENCODING 8651 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 40 F0 00 F0 20 00 ENDCHAR STARTCHAR uni21CC ENCODING 8652 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 20 F0 00 F0 40 00 ENDCHAR STARTCHAR arrowdblleft ENCODING 8656 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 20 78 80 78 20 10 ENDCHAR STARTCHAR arrowdblup ENCODING 8657 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 50 D8 50 50 50 00 ENDCHAR STARTCHAR arrowdblright ENCODING 8658 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 20 F0 08 F0 20 40 ENDCHAR STARTCHAR arrowdbldown ENCODING 8659 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 50 50 D8 50 20 00 ENDCHAR STARTCHAR arrowdblboth ENCODING 8660 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 20 70 88 70 20 00 ENDCHAR STARTCHAR uni21D5 ENCODING 8661 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 50 D8 50 D8 50 20 ENDCHAR STARTCHAR universal ENCODING 8704 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 90 90 F0 90 90 60 00 ENDCHAR STARTCHAR uni2201 ENCODING 8705 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 50 40 40 50 20 00 ENDCHAR STARTCHAR partialdiff ENCODING 8706 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 10 30 50 50 20 00 ENDCHAR STARTCHAR existential ENCODING 8707 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP F0 10 70 10 10 F0 00 ENDCHAR STARTCHAR uni2204 ENCODING 8708 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 F0 50 70 50 F0 40 ENDCHAR STARTCHAR emptyset ENCODING 8709 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 70 B0 D0 D0 E0 80 ENDCHAR STARTCHAR Delta ENCODING 8710 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 20 50 50 88 F8 00 ENDCHAR STARTCHAR gradient ENCODING 8711 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP F8 88 50 50 20 20 00 ENDCHAR STARTCHAR element ENCODING 8712 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 70 80 F0 80 70 00 ENDCHAR STARTCHAR notelement ENCODING 8713 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 70 A0 F0 A0 70 40 ENDCHAR STARTCHAR uni220A ENCODING 8714 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 30 40 70 40 30 00 ENDCHAR STARTCHAR suchthat ENCODING 8715 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 E0 10 F0 10 E0 00 ENDCHAR STARTCHAR uni220C ENCODING 8716 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 E0 50 F0 50 E0 80 ENDCHAR STARTCHAR uni220D ENCODING 8717 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 60 10 70 10 60 00 ENDCHAR STARTCHAR uni220E ENCODING 8718 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 F0 F0 F0 F0 F0 00 ENDCHAR STARTCHAR product ENCODING 8719 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP F8 50 50 50 50 D8 00 ENDCHAR STARTCHAR uni2210 ENCODING 8720 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP D8 50 50 50 50 F8 00 ENDCHAR STARTCHAR summation ENCODING 8721 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP F0 40 20 40 80 F0 00 ENDCHAR STARTCHAR minus ENCODING 8722 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 00 F8 00 00 00 ENDCHAR STARTCHAR uni2213 ENCODING 8723 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP F8 20 20 F8 20 20 00 ENDCHAR STARTCHAR uni2214 ENCODING 8724 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 00 20 20 F8 20 20 ENDCHAR STARTCHAR fraction ENCODING 8725 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 10 20 40 80 80 00 ENDCHAR STARTCHAR uni2216 ENCODING 8726 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 80 40 20 10 00 ENDCHAR STARTCHAR asteriskmath ENCODING 8727 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 20 A8 70 A8 20 00 ENDCHAR STARTCHAR uni2218 ENCODING 8728 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 20 50 20 00 00 ENDCHAR STARTCHAR periodcentered ENCODING 8729 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 20 70 20 00 00 ENDCHAR STARTCHAR radical ENCODING 8730 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 08 10 10 20 A0 40 00 ENDCHAR STARTCHAR uni221B ENCODING 8731 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 88 D0 90 20 A0 40 00 ENDCHAR STARTCHAR uni221C ENCODING 8732 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 88 D0 50 20 A0 40 00 ENDCHAR STARTCHAR proportional ENCODING 8733 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 50 A0 A0 50 00 ENDCHAR STARTCHAR infinity ENCODING 8734 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 50 A8 A8 50 00 ENDCHAR STARTCHAR orthogonal ENCODING 8735 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 80 80 80 F0 00 ENDCHAR STARTCHAR angle ENCODING 8736 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 10 20 40 F0 00 ENDCHAR STARTCHAR uni2221 ENCODING 8737 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 10 A0 40 F0 20 ENDCHAR STARTCHAR uni2222 ENCODING 8738 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 50 60 A0 60 50 00 ENDCHAR STARTCHAR uni2223 ENCODING 8739 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 20 20 20 20 20 00 ENDCHAR STARTCHAR uni2224 ENCODING 8740 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 20 30 60 20 20 00 ENDCHAR STARTCHAR uni2225 ENCODING 8741 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 50 50 50 50 50 00 ENDCHAR STARTCHAR uni2226 ENCODING 8742 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 58 70 70 D0 50 00 ENDCHAR STARTCHAR logicaland ENCODING 8743 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 20 20 50 50 00 ENDCHAR STARTCHAR logicalor ENCODING 8744 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 50 50 20 20 00 ENDCHAR STARTCHAR intersection ENCODING 8745 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 60 90 90 90 00 ENDCHAR STARTCHAR union ENCODING 8746 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 90 90 90 60 00 ENDCHAR STARTCHAR integral ENCODING 8747 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 28 20 20 20 A0 40 ENDCHAR STARTCHAR uni222C ENCODING 8748 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 28 50 50 50 50 50 A0 ENDCHAR STARTCHAR uni222D ENCODING 8749 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 38 70 70 70 70 70 E0 ENDCHAR STARTCHAR uni222E ENCODING 8750 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 28 70 A8 70 A0 40 ENDCHAR STARTCHAR uni222F ENCODING 8751 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 28 50 70 D8 70 50 A0 ENDCHAR STARTCHAR uni2230 ENCODING 8752 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 38 70 70 F8 70 70 E0 ENDCHAR STARTCHAR therefore ENCODING 8756 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 20 00 50 00 00 ENDCHAR STARTCHAR uni2235 ENCODING 8757 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 50 00 20 00 00 ENDCHAR STARTCHAR uni2236 ENCODING 8758 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 20 00 00 20 00 ENDCHAR STARTCHAR uni2237 ENCODING 8759 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 90 00 00 90 00 ENDCHAR STARTCHAR uni2238 ENCODING 8760 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 20 00 F8 00 00 ENDCHAR STARTCHAR uni2239 ENCODING 8761 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 10 C0 10 00 00 ENDCHAR STARTCHAR uni223A ENCODING 8762 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 90 00 F0 00 90 00 ENDCHAR STARTCHAR similar ENCODING 8764 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 00 50 A0 00 00 ENDCHAR STARTCHAR uni2243 ENCODING 8771 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 50 A0 00 F0 00 00 ENDCHAR STARTCHAR congruent ENCODING 8773 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 A0 00 F0 00 F0 00 ENDCHAR STARTCHAR approxequal ENCODING 8776 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 50 A0 00 50 A0 00 ENDCHAR STARTCHAR uni2249 ENCODING 8777 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 50 A0 20 50 A0 80 ENDCHAR STARTCHAR uni2259 ENCODING 8793 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 50 00 F0 00 F0 00 ENDCHAR STARTCHAR uni225A ENCODING 8794 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 20 00 F0 00 F0 00 ENDCHAR STARTCHAR uni225F ENCODING 8799 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 20 00 20 F0 00 F0 ENDCHAR STARTCHAR notequal ENCODING 8800 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 10 F0 20 F0 40 00 ENDCHAR STARTCHAR equivalence ENCODING 8801 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 F0 00 F0 00 F0 00 ENDCHAR STARTCHAR uni2262 ENCODING 8802 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 F0 20 F0 20 F0 40 ENDCHAR STARTCHAR uni2263 ENCODING 8803 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP F0 00 F0 00 F0 00 F0 ENDCHAR STARTCHAR lessequal ENCODING 8804 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 20 40 20 10 70 00 ENDCHAR STARTCHAR greaterequal ENCODING 8805 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 20 10 20 40 70 00 ENDCHAR STARTCHAR uni226A ENCODING 8810 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 28 50 A0 50 28 00 ENDCHAR STARTCHAR uni226B ENCODING 8811 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 A0 50 28 50 A0 00 ENDCHAR STARTCHAR propersubset ENCODING 8834 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 70 80 80 70 00 ENDCHAR STARTCHAR propersuperset ENCODING 8835 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 E0 10 10 E0 00 ENDCHAR STARTCHAR notsubset ENCODING 8836 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 20 70 A0 A0 70 20 ENDCHAR STARTCHAR uni2285 ENCODING 8837 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 40 E0 50 50 E0 40 ENDCHAR STARTCHAR reflexsubset ENCODING 8838 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 70 80 70 00 F0 00 ENDCHAR STARTCHAR reflexsuperset ENCODING 8839 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 E0 10 E0 00 F0 00 ENDCHAR STARTCHAR uni2288 ENCODING 8840 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 70 A0 70 20 F0 20 ENDCHAR STARTCHAR uni2289 ENCODING 8841 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 E0 50 E0 40 F0 40 ENDCHAR STARTCHAR uni228A ENCODING 8842 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 70 80 70 20 F0 20 ENDCHAR STARTCHAR uni228B ENCODING 8843 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 E0 10 E0 40 F0 40 ENDCHAR STARTCHAR circleplus ENCODING 8853 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 70 A8 F8 A8 70 00 ENDCHAR STARTCHAR uni2296 ENCODING 8854 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 70 88 F8 88 70 00 ENDCHAR STARTCHAR circlemultiply ENCODING 8855 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 70 D8 A8 D8 70 00 ENDCHAR STARTCHAR uni2298 ENCODING 8856 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 70 98 A8 C8 70 00 ENDCHAR STARTCHAR uni2299 ENCODING 8857 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 70 88 A8 88 70 00 ENDCHAR STARTCHAR uni22A2 ENCODING 8866 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 80 80 F0 80 80 00 ENDCHAR STARTCHAR uni22A3 ENCODING 8867 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 10 10 F0 10 10 00 ENDCHAR STARTCHAR uni22A4 ENCODING 8868 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 70 20 20 20 20 20 00 ENDCHAR STARTCHAR perpendicular ENCODING 8869 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 20 20 20 20 70 00 ENDCHAR STARTCHAR uni22A6 ENCODING 8870 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 40 40 70 40 40 00 ENDCHAR STARTCHAR uni22A7 ENCODING 8871 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 40 70 40 70 40 00 ENDCHAR STARTCHAR uni22A8 ENCODING 8872 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 80 F0 80 F0 80 00 ENDCHAR STARTCHAR uni22C2 ENCODING 8898 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 90 90 90 90 90 00 ENDCHAR STARTCHAR uni22C3 ENCODING 8899 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 90 90 90 90 90 60 00 ENDCHAR STARTCHAR dotmath ENCODING 8901 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 00 20 00 00 00 ENDCHAR STARTCHAR uni22EE ENCODING 8942 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 20 00 20 00 20 00 ENDCHAR STARTCHAR uni22EF ENCODING 8943 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 00 A8 00 00 00 ENDCHAR STARTCHAR uni22F0 ENCODING 8944 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 08 00 20 00 80 00 ENDCHAR STARTCHAR uni22F1 ENCODING 8945 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 80 00 20 00 08 00 ENDCHAR STARTCHAR uni2300 ENCODING 8960 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 78 98 A8 C8 F0 00 ENDCHAR STARTCHAR house ENCODING 8962 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 20 50 88 88 F8 00 ENDCHAR STARTCHAR uni2308 ENCODING 8968 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 70 40 40 40 40 40 00 ENDCHAR STARTCHAR uni2309 ENCODING 8969 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 70 10 10 10 10 10 00 ENDCHAR STARTCHAR uni230A ENCODING 8970 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 40 40 40 40 70 00 ENDCHAR STARTCHAR uni230B ENCODING 8971 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 10 10 10 10 70 00 ENDCHAR STARTCHAR revlogicalnot ENCODING 8976 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 00 F0 80 00 00 ENDCHAR STARTCHAR integraltp ENCODING 8992 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 28 20 20 20 20 20 ENDCHAR STARTCHAR integralbt ENCODING 8993 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 20 20 20 20 A0 40 ENDCHAR STARTCHAR uni23BA ENCODING 9146 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP F8 00 00 00 00 00 00 ENDCHAR STARTCHAR uni23BB ENCODING 9147 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 F8 00 00 00 00 00 ENDCHAR STARTCHAR uni23BC ENCODING 9148 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 00 00 00 F8 00 ENDCHAR STARTCHAR uni23BD ENCODING 9149 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 00 00 00 00 F8 ENDCHAR STARTCHAR uni2409 ENCODING 9225 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP A0 E0 A0 70 20 20 00 ENDCHAR STARTCHAR uni240A ENCODING 9226 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 80 80 F0 20 30 20 00 ENDCHAR STARTCHAR uni240B ENCODING 9227 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP A0 A0 78 50 10 10 00 ENDCHAR STARTCHAR uni240C ENCODING 9228 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP E0 80 F8 A0 30 20 00 ENDCHAR STARTCHAR uni240D ENCODING 9229 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 80 E0 50 60 50 00 ENDCHAR STARTCHAR uni2423 ENCODING 9251 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 00 00 90 F0 00 ENDCHAR STARTCHAR uni2424 ENCODING 9252 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP C0 A0 A0 A0 20 38 00 ENDCHAR STARTCHAR SF100000 ENCODING 9472 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 00 F8 00 00 00 ENDCHAR STARTCHAR uni2501 ENCODING 9473 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 F8 F8 00 00 00 ENDCHAR STARTCHAR SF110000 ENCODING 9474 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 20 20 20 20 20 20 ENDCHAR STARTCHAR uni2503 ENCODING 9475 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 30 30 30 30 30 30 30 ENDCHAR STARTCHAR uni2504 ENCODING 9476 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 00 A8 00 00 00 ENDCHAR STARTCHAR uni2505 ENCODING 9477 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 A8 A8 00 00 00 ENDCHAR STARTCHAR uni2506 ENCODING 9478 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 00 20 20 00 20 00 ENDCHAR STARTCHAR uni2507 ENCODING 9479 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 30 00 30 30 00 30 00 ENDCHAR STARTCHAR uni2508 ENCODING 9480 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 00 A8 00 00 00 ENDCHAR STARTCHAR uni2509 ENCODING 9481 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 A8 A8 00 00 00 ENDCHAR STARTCHAR uni250A ENCODING 9482 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 00 20 00 20 00 20 ENDCHAR STARTCHAR uni250B ENCODING 9483 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 30 00 30 00 30 00 30 ENDCHAR STARTCHAR SF010000 ENCODING 9484 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 00 38 20 20 20 ENDCHAR STARTCHAR uni250D ENCODING 9485 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 38 38 20 20 20 ENDCHAR STARTCHAR uni250E ENCODING 9486 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 00 38 30 30 30 ENDCHAR STARTCHAR uni250F ENCODING 9487 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 38 38 30 30 30 ENDCHAR STARTCHAR SF030000 ENCODING 9488 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 00 E0 20 20 20 ENDCHAR STARTCHAR uni2511 ENCODING 9489 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 E0 E0 20 20 20 ENDCHAR STARTCHAR uni2512 ENCODING 9490 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 00 F0 30 30 30 ENDCHAR STARTCHAR uni2513 ENCODING 9491 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 F0 F0 30 30 30 ENDCHAR STARTCHAR SF020000 ENCODING 9492 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 20 20 38 00 00 00 ENDCHAR STARTCHAR uni2515 ENCODING 9493 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 20 38 38 00 00 00 ENDCHAR STARTCHAR uni2516 ENCODING 9494 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 30 30 30 38 00 00 00 ENDCHAR STARTCHAR uni2517 ENCODING 9495 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 30 30 38 38 00 00 00 ENDCHAR STARTCHAR SF040000 ENCODING 9496 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 20 20 E0 00 00 00 ENDCHAR STARTCHAR uni2519 ENCODING 9497 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 20 E0 E0 00 00 00 ENDCHAR STARTCHAR uni251A ENCODING 9498 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 30 30 30 F0 00 00 00 ENDCHAR STARTCHAR uni251B ENCODING 9499 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 30 30 F0 F0 00 00 00 ENDCHAR STARTCHAR SF080000 ENCODING 9500 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 20 20 38 20 20 20 ENDCHAR STARTCHAR uni251D ENCODING 9501 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 20 38 38 20 20 20 ENDCHAR STARTCHAR uni251E ENCODING 9502 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 30 30 30 38 20 20 20 ENDCHAR STARTCHAR uni251F ENCODING 9503 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 20 20 38 30 30 30 ENDCHAR STARTCHAR uni2520 ENCODING 9504 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 30 30 30 38 30 30 30 ENDCHAR STARTCHAR uni2521 ENCODING 9505 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 30 30 38 38 20 20 20 ENDCHAR STARTCHAR uni2522 ENCODING 9506 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 20 38 38 30 30 30 ENDCHAR STARTCHAR uni2523 ENCODING 9507 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 30 30 38 38 30 30 30 ENDCHAR STARTCHAR SF090000 ENCODING 9508 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 20 20 E0 20 20 20 ENDCHAR STARTCHAR uni2525 ENCODING 9509 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 20 E0 E0 20 20 20 ENDCHAR STARTCHAR uni2526 ENCODING 9510 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 30 30 30 F0 20 20 20 ENDCHAR STARTCHAR uni2527 ENCODING 9511 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 20 20 F0 30 30 30 ENDCHAR STARTCHAR uni2528 ENCODING 9512 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 30 30 30 F0 30 30 30 ENDCHAR STARTCHAR uni2529 ENCODING 9513 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 30 30 F0 F0 20 20 20 ENDCHAR STARTCHAR uni252A ENCODING 9514 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 20 F0 F0 30 30 30 ENDCHAR STARTCHAR uni252B ENCODING 9515 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 30 30 F0 F0 30 30 30 ENDCHAR STARTCHAR SF060000 ENCODING 9516 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 00 F8 20 20 20 ENDCHAR STARTCHAR uni252D ENCODING 9517 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 E0 F8 20 20 20 ENDCHAR STARTCHAR uni252E ENCODING 9518 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 38 F8 20 20 20 ENDCHAR STARTCHAR uni252F ENCODING 9519 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 F8 F8 20 20 20 ENDCHAR STARTCHAR uni2530 ENCODING 9520 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 00 F8 30 30 30 ENDCHAR STARTCHAR uni2531 ENCODING 9521 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 E0 F8 30 30 30 ENDCHAR STARTCHAR uni2532 ENCODING 9522 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 18 F8 30 30 30 ENDCHAR STARTCHAR uni2533 ENCODING 9523 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 F8 F8 30 30 30 ENDCHAR STARTCHAR SF070000 ENCODING 9524 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 20 20 F8 00 00 00 ENDCHAR STARTCHAR uni2535 ENCODING 9525 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 20 E0 F8 00 00 00 ENDCHAR STARTCHAR uni2536 ENCODING 9526 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 20 38 F8 00 00 00 ENDCHAR STARTCHAR uni2537 ENCODING 9527 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 20 F8 F8 00 00 00 ENDCHAR STARTCHAR uni2538 ENCODING 9528 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 30 30 30 F8 00 00 00 ENDCHAR STARTCHAR uni2539 ENCODING 9529 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 30 30 F0 F8 00 00 00 ENDCHAR STARTCHAR uni253A ENCODING 9530 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 30 30 38 F8 00 00 00 ENDCHAR STARTCHAR uni253B ENCODING 9531 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 30 30 F8 F8 00 00 00 ENDCHAR STARTCHAR SF050000 ENCODING 9532 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 20 20 F8 20 20 20 ENDCHAR STARTCHAR uni253D ENCODING 9533 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 20 E0 F8 20 20 20 ENDCHAR STARTCHAR uni253E ENCODING 9534 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 20 38 F8 20 20 20 ENDCHAR STARTCHAR uni253F ENCODING 9535 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 20 F8 F8 20 20 20 ENDCHAR STARTCHAR uni2540 ENCODING 9536 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 30 30 30 F8 20 20 20 ENDCHAR STARTCHAR uni2541 ENCODING 9537 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 20 20 F8 30 30 30 ENDCHAR STARTCHAR uni2542 ENCODING 9538 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 30 30 30 F8 30 30 30 ENDCHAR STARTCHAR uni2543 ENCODING 9539 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 30 30 F0 F8 20 20 20 ENDCHAR STARTCHAR uni2544 ENCODING 9540 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 30 30 38 F8 20 20 20 ENDCHAR STARTCHAR uni2545 ENCODING 9541 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 20 E0 F8 30 30 30 ENDCHAR STARTCHAR uni2546 ENCODING 9542 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 20 38 F8 30 30 30 ENDCHAR STARTCHAR uni2547 ENCODING 9543 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 30 30 F8 F8 20 20 20 ENDCHAR STARTCHAR uni2548 ENCODING 9544 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 20 F8 F8 30 30 30 ENDCHAR STARTCHAR uni2549 ENCODING 9545 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 30 30 F0 F8 30 30 30 ENDCHAR STARTCHAR uni254A ENCODING 9546 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 30 30 38 F8 30 30 30 ENDCHAR STARTCHAR uni254B ENCODING 9547 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 30 30 F8 F8 30 30 30 ENDCHAR STARTCHAR uni254C ENCODING 9548 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 00 D0 00 00 00 ENDCHAR STARTCHAR uni254D ENCODING 9549 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 D0 D0 00 00 00 ENDCHAR STARTCHAR uni254E ENCODING 9550 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 20 20 00 20 20 00 ENDCHAR STARTCHAR uni254F ENCODING 9551 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 30 30 30 00 30 30 00 ENDCHAR STARTCHAR SF430000 ENCODING 9552 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 F8 00 F8 00 00 ENDCHAR STARTCHAR SF240000 ENCODING 9553 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 50 50 50 50 50 50 ENDCHAR STARTCHAR SF510000 ENCODING 9554 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 38 20 38 20 20 ENDCHAR STARTCHAR SF520000 ENCODING 9555 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 00 78 50 50 50 ENDCHAR STARTCHAR SF390000 ENCODING 9556 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 78 40 58 50 50 ENDCHAR STARTCHAR SF220000 ENCODING 9557 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 E0 20 E0 20 20 ENDCHAR STARTCHAR SF210000 ENCODING 9558 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 00 F0 50 50 50 ENDCHAR STARTCHAR SF250000 ENCODING 9559 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 F0 10 D0 50 50 ENDCHAR STARTCHAR SF500000 ENCODING 9560 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 20 38 20 38 00 00 ENDCHAR STARTCHAR SF490000 ENCODING 9561 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 50 50 78 00 00 00 ENDCHAR STARTCHAR SF380000 ENCODING 9562 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 50 58 40 78 00 00 ENDCHAR STARTCHAR SF280000 ENCODING 9563 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 20 E0 20 E0 00 00 ENDCHAR STARTCHAR SF270000 ENCODING 9564 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 50 50 F0 00 00 00 ENDCHAR STARTCHAR SF260000 ENCODING 9565 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 50 D0 10 F0 00 00 ENDCHAR STARTCHAR SF360000 ENCODING 9566 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 20 38 20 38 20 20 ENDCHAR STARTCHAR SF370000 ENCODING 9567 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 50 50 58 50 50 50 ENDCHAR STARTCHAR SF420000 ENCODING 9568 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 50 58 40 58 50 50 ENDCHAR STARTCHAR SF190000 ENCODING 9569 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 20 E0 20 E0 20 20 ENDCHAR STARTCHAR SF200000 ENCODING 9570 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 50 50 D0 50 50 50 ENDCHAR STARTCHAR SF230000 ENCODING 9571 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 50 D0 10 D0 50 50 ENDCHAR STARTCHAR SF470000 ENCODING 9572 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 F8 00 F8 20 20 ENDCHAR STARTCHAR SF480000 ENCODING 9573 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 00 F8 50 50 50 ENDCHAR STARTCHAR SF410000 ENCODING 9574 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 F8 00 D8 50 50 ENDCHAR STARTCHAR SF450000 ENCODING 9575 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 20 F8 00 F8 00 00 ENDCHAR STARTCHAR SF460000 ENCODING 9576 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 50 50 F8 00 00 00 ENDCHAR STARTCHAR SF400000 ENCODING 9577 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 50 D8 00 F8 00 00 ENDCHAR STARTCHAR SF540000 ENCODING 9578 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 20 F8 20 F8 20 20 ENDCHAR STARTCHAR SF530000 ENCODING 9579 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 50 50 F8 50 50 50 ENDCHAR STARTCHAR SF440000 ENCODING 9580 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 50 D8 00 D8 50 50 ENDCHAR STARTCHAR uni256D ENCODING 9581 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 00 18 20 20 20 ENDCHAR STARTCHAR uni256E ENCODING 9582 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 00 C0 20 20 20 ENDCHAR STARTCHAR uni256F ENCODING 9583 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 20 20 C0 00 00 00 ENDCHAR STARTCHAR uni2570 ENCODING 9584 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 20 20 18 00 00 00 ENDCHAR STARTCHAR uni2571 ENCODING 9585 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 08 10 10 20 40 40 80 ENDCHAR STARTCHAR uni2572 ENCODING 9586 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 80 40 40 20 10 10 08 ENDCHAR STARTCHAR uni2573 ENCODING 9587 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 88 50 50 20 50 50 88 ENDCHAR STARTCHAR uni2574 ENCODING 9588 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 00 E0 00 00 00 ENDCHAR STARTCHAR uni2575 ENCODING 9589 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 20 20 20 00 00 00 ENDCHAR STARTCHAR uni2576 ENCODING 9590 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 00 38 00 00 00 ENDCHAR STARTCHAR uni2577 ENCODING 9591 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 00 20 20 20 20 ENDCHAR STARTCHAR uni2578 ENCODING 9592 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 E0 E0 00 00 00 ENDCHAR STARTCHAR uni2579 ENCODING 9593 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 30 30 30 30 00 00 00 ENDCHAR STARTCHAR uni257A ENCODING 9594 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 38 38 00 00 00 ENDCHAR STARTCHAR uni257B ENCODING 9595 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 00 30 30 30 30 ENDCHAR STARTCHAR uni257C ENCODING 9596 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 38 F8 00 00 00 ENDCHAR STARTCHAR uni257D ENCODING 9597 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 20 20 30 30 30 30 ENDCHAR STARTCHAR uni257E ENCODING 9598 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 E0 F8 00 00 00 ENDCHAR STARTCHAR uni257F ENCODING 9599 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 30 30 30 30 20 20 20 ENDCHAR STARTCHAR upblock ENCODING 9600 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP F8 F8 F8 00 00 00 00 ENDCHAR STARTCHAR uni2581 ENCODING 9601 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 00 00 00 00 F8 ENDCHAR STARTCHAR uni2582 ENCODING 9602 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 00 00 00 F8 F8 ENDCHAR STARTCHAR uni2583 ENCODING 9603 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 00 00 F8 F8 F8 ENDCHAR STARTCHAR dnblock ENCODING 9604 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 00 F8 F8 F8 F8 ENDCHAR STARTCHAR uni2585 ENCODING 9605 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 00 F8 F8 F8 F8 ENDCHAR STARTCHAR uni2586 ENCODING 9606 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 F8 F8 F8 F8 F8 ENDCHAR STARTCHAR uni2587 ENCODING 9607 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 F8 F8 F8 F8 F8 F8 ENDCHAR STARTCHAR block ENCODING 9608 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP F8 F8 F8 F8 F8 F8 F8 ENDCHAR STARTCHAR uni2589 ENCODING 9609 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP F0 F0 F0 F0 F0 F0 F0 ENDCHAR STARTCHAR uni258A ENCODING 9610 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP F0 F0 F0 F0 F0 F0 F0 ENDCHAR STARTCHAR uni258B ENCODING 9611 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP E0 E0 E0 E0 E0 E0 E0 ENDCHAR STARTCHAR lfblock ENCODING 9612 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP E0 E0 E0 E0 E0 E0 E0 ENDCHAR STARTCHAR uni258D ENCODING 9613 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP C0 C0 C0 C0 C0 C0 C0 ENDCHAR STARTCHAR uni258E ENCODING 9614 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 80 80 80 80 80 80 80 ENDCHAR STARTCHAR uni258F ENCODING 9615 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 80 80 80 80 80 80 80 ENDCHAR STARTCHAR rtblock ENCODING 9616 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 18 18 18 18 18 18 18 ENDCHAR STARTCHAR ltshade ENCODING 9617 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 10 40 10 40 10 00 ENDCHAR STARTCHAR shade ENCODING 9618 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP A8 50 A8 50 A8 50 A8 ENDCHAR STARTCHAR dkshade ENCODING 9619 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP B8 E8 B8 E8 B8 E8 F8 ENDCHAR STARTCHAR uni2594 ENCODING 9620 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP F8 00 00 00 00 00 00 ENDCHAR STARTCHAR uni2595 ENCODING 9621 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 08 08 08 08 08 08 08 ENDCHAR STARTCHAR uni2596 ENCODING 9622 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 00 E0 E0 E0 E0 ENDCHAR STARTCHAR uni2597 ENCODING 9623 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 00 18 18 18 18 ENDCHAR STARTCHAR uni2598 ENCODING 9624 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP E0 E0 E0 00 00 00 00 ENDCHAR STARTCHAR uni2599 ENCODING 9625 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP E0 E0 E0 F8 F8 F8 F8 ENDCHAR STARTCHAR uni259A ENCODING 9626 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP E0 E0 E0 18 18 18 18 ENDCHAR STARTCHAR uni259B ENCODING 9627 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP F8 F8 F8 E0 E0 E0 E0 ENDCHAR STARTCHAR uni259C ENCODING 9628 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP F8 F8 F8 18 18 18 18 ENDCHAR STARTCHAR uni259D ENCODING 9629 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 18 18 18 00 00 00 00 ENDCHAR STARTCHAR uni259E ENCODING 9630 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 18 18 18 E0 E0 E0 E0 ENDCHAR STARTCHAR uni259F ENCODING 9631 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 18 18 18 F8 F8 F8 F8 ENDCHAR STARTCHAR filledbox ENCODING 9632 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 F0 F0 F0 F0 00 ENDCHAR STARTCHAR H22073 ENCODING 9633 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 F0 90 90 F0 00 ENDCHAR STARTCHAR H18543 ENCODING 9642 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 70 70 70 00 00 ENDCHAR STARTCHAR H18551 ENCODING 9643 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 70 50 70 00 00 ENDCHAR STARTCHAR filledrect ENCODING 9644 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 F8 F8 F8 00 00 ENDCHAR STARTCHAR uni25AD ENCODING 9645 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 F8 88 F8 00 00 ENDCHAR STARTCHAR uni25AE ENCODING 9646 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 70 70 70 70 70 00 ENDCHAR STARTCHAR triagup ENCODING 9650 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 20 70 70 F8 F8 00 ENDCHAR STARTCHAR uni25B3 ENCODING 9651 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 20 50 50 88 F8 00 ENDCHAR STARTCHAR uni25B6 ENCODING 9654 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 80 C0 E0 F0 E0 C0 80 ENDCHAR STARTCHAR uni25B7 ENCODING 9655 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 80 C0 A0 90 A0 C0 80 ENDCHAR STARTCHAR uni25B8 ENCODING 9656 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 40 60 70 60 40 00 ENDCHAR STARTCHAR uni25B9 ENCODING 9657 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 40 60 50 60 40 00 ENDCHAR STARTCHAR triagrt ENCODING 9658 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 80 E0 F8 E0 80 00 ENDCHAR STARTCHAR uni25BB ENCODING 9659 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 80 E0 98 E0 80 00 ENDCHAR STARTCHAR triagdn ENCODING 9660 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP F8 F8 70 70 20 20 00 ENDCHAR STARTCHAR uni25BD ENCODING 9661 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP F8 88 50 50 20 20 00 ENDCHAR STARTCHAR uni25C0 ENCODING 9664 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 30 70 F0 70 30 10 ENDCHAR STARTCHAR uni25C1 ENCODING 9665 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 30 50 90 50 30 10 ENDCHAR STARTCHAR uni25C2 ENCODING 9666 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 10 30 70 30 10 00 ENDCHAR STARTCHAR uni25C3 ENCODING 9667 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 10 30 50 30 10 00 ENDCHAR STARTCHAR triaglf ENCODING 9668 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 08 38 F8 38 08 00 ENDCHAR STARTCHAR uni25C5 ENCODING 9669 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 08 38 C8 38 08 00 ENDCHAR STARTCHAR uni25C6 ENCODING 9670 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 20 70 F8 70 20 00 ENDCHAR STARTCHAR lozenge ENCODING 9674 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 20 50 88 50 20 00 ENDCHAR STARTCHAR circle ENCODING 9675 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 70 88 88 88 70 00 ENDCHAR STARTCHAR H18533 ENCODING 9679 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 70 F8 F8 F8 70 00 ENDCHAR STARTCHAR invbullet ENCODING 9688 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP F8 F8 D8 88 D8 F8 F8 ENDCHAR STARTCHAR invcircle ENCODING 9689 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP F8 F8 D8 A8 D8 F8 F8 ENDCHAR STARTCHAR openbullet ENCODING 9702 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 60 90 90 60 00 ENDCHAR STARTCHAR uni2639 ENCODING 9785 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 50 00 20 50 00 00 ENDCHAR STARTCHAR smileface ENCODING 9786 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 50 00 50 20 00 00 ENDCHAR STARTCHAR invsmileface ENCODING 9787 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 70 A8 F8 A8 D8 70 00 ENDCHAR STARTCHAR sun ENCODING 9788 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 A8 70 D8 70 A8 20 ENDCHAR STARTCHAR female ENCODING 9792 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 20 50 20 70 20 00 ENDCHAR STARTCHAR uni2641 ENCODING 9793 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 20 70 20 50 20 00 ENDCHAR STARTCHAR male ENCODING 9794 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 38 18 68 A0 40 00 00 ENDCHAR STARTCHAR spade ENCODING 9824 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 70 F8 F8 20 70 00 ENDCHAR STARTCHAR club ENCODING 9827 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 70 70 A8 F8 A8 20 70 ENDCHAR STARTCHAR heart ENCODING 9829 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 F8 F8 70 70 20 00 ENDCHAR STARTCHAR diamond ENCODING 9830 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 70 F8 F8 70 20 00 ENDCHAR STARTCHAR uni2669 ENCODING 9833 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 10 10 30 70 20 00 ENDCHAR STARTCHAR musicalnote ENCODING 9834 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 30 28 60 E0 40 00 ENDCHAR STARTCHAR musicalnotedbl ENCODING 9835 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 60 58 48 C8 D8 18 00 ENDCHAR STARTCHAR uni266C ENCODING 9836 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 70 68 58 C8 D8 18 00 ENDCHAR STARTCHAR uni266D ENCODING 9837 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 40 70 50 50 60 00 ENDCHAR STARTCHAR uni266E ENCODING 9838 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 70 50 50 70 10 00 ENDCHAR STARTCHAR uni266F ENCODING 9839 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 58 70 D8 70 D0 40 ENDCHAR STARTCHAR uni27E8 ENCODING 10216 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 20 40 40 20 20 00 ENDCHAR STARTCHAR uni27E9 ENCODING 10217 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 40 20 20 40 40 00 ENDCHAR STARTCHAR uni2800 ENCODING 10240 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 00 00 00 00 00 ENDCHAR STARTCHAR uni2801 ENCODING 10241 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 00 00 00 00 00 00 ENDCHAR STARTCHAR uni2802 ENCODING 10242 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 40 00 00 00 00 ENDCHAR STARTCHAR uni2803 ENCODING 10243 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 00 40 00 00 00 00 ENDCHAR STARTCHAR uni2804 ENCODING 10244 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 00 00 40 00 00 ENDCHAR STARTCHAR uni2805 ENCODING 10245 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 00 00 00 40 00 00 ENDCHAR STARTCHAR uni2806 ENCODING 10246 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 40 00 40 00 00 ENDCHAR STARTCHAR uni2807 ENCODING 10247 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 00 40 00 40 00 00 ENDCHAR STARTCHAR uni2808 ENCODING 10248 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 00 00 00 00 00 00 ENDCHAR STARTCHAR uni2809 ENCODING 10249 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 00 00 00 00 00 00 ENDCHAR STARTCHAR uni280A ENCODING 10250 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 00 40 00 00 00 00 ENDCHAR STARTCHAR uni280B ENCODING 10251 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 00 40 00 00 00 00 ENDCHAR STARTCHAR uni280C ENCODING 10252 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 00 00 00 40 00 00 ENDCHAR STARTCHAR uni280D ENCODING 10253 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 00 00 00 40 00 00 ENDCHAR STARTCHAR uni280E ENCODING 10254 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 00 40 00 40 00 00 ENDCHAR STARTCHAR uni280F ENCODING 10255 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 00 40 00 40 00 00 ENDCHAR STARTCHAR uni2810 ENCODING 10256 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 10 00 00 00 00 ENDCHAR STARTCHAR uni2811 ENCODING 10257 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 00 10 00 00 00 00 ENDCHAR STARTCHAR uni2812 ENCODING 10258 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 50 00 00 00 00 ENDCHAR STARTCHAR uni2813 ENCODING 10259 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 00 50 00 00 00 00 ENDCHAR STARTCHAR uni2814 ENCODING 10260 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 10 00 40 00 00 ENDCHAR STARTCHAR uni2815 ENCODING 10261 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 00 10 00 40 00 00 ENDCHAR STARTCHAR uni2816 ENCODING 10262 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 50 00 40 00 00 ENDCHAR STARTCHAR uni2817 ENCODING 10263 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 00 50 00 40 00 00 ENDCHAR STARTCHAR uni2818 ENCODING 10264 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 00 10 00 00 00 00 ENDCHAR STARTCHAR uni2819 ENCODING 10265 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 00 10 00 00 00 00 ENDCHAR STARTCHAR uni281A ENCODING 10266 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 00 50 00 00 00 00 ENDCHAR STARTCHAR uni281B ENCODING 10267 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 00 50 00 00 00 00 ENDCHAR STARTCHAR uni281C ENCODING 10268 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 00 10 00 40 00 00 ENDCHAR STARTCHAR uni281D ENCODING 10269 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 00 10 00 40 00 00 ENDCHAR STARTCHAR uni281E ENCODING 10270 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 00 50 00 40 00 00 ENDCHAR STARTCHAR uni281F ENCODING 10271 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 00 50 00 40 00 00 ENDCHAR STARTCHAR uni2820 ENCODING 10272 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 00 00 10 00 00 ENDCHAR STARTCHAR uni2821 ENCODING 10273 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 00 00 00 10 00 00 ENDCHAR STARTCHAR uni2822 ENCODING 10274 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 40 00 10 00 00 ENDCHAR STARTCHAR uni2823 ENCODING 10275 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 00 40 00 10 00 00 ENDCHAR STARTCHAR uni2824 ENCODING 10276 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 00 00 50 00 00 ENDCHAR STARTCHAR uni2825 ENCODING 10277 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 00 00 00 50 00 00 ENDCHAR STARTCHAR uni2826 ENCODING 10278 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 40 00 50 00 00 ENDCHAR STARTCHAR uni2827 ENCODING 10279 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 00 40 00 50 00 00 ENDCHAR STARTCHAR uni2828 ENCODING 10280 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 00 00 00 10 00 00 ENDCHAR STARTCHAR uni2829 ENCODING 10281 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 00 00 00 10 00 00 ENDCHAR STARTCHAR uni282A ENCODING 10282 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 00 40 00 10 00 00 ENDCHAR STARTCHAR uni282B ENCODING 10283 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 00 40 00 10 00 00 ENDCHAR STARTCHAR uni282C ENCODING 10284 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 00 00 00 50 00 00 ENDCHAR STARTCHAR uni282D ENCODING 10285 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 00 00 00 50 00 00 ENDCHAR STARTCHAR uni282E ENCODING 10286 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 00 40 00 50 00 00 ENDCHAR STARTCHAR uni282F ENCODING 10287 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 00 40 00 50 00 00 ENDCHAR STARTCHAR uni2830 ENCODING 10288 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 10 00 10 00 00 ENDCHAR STARTCHAR uni2831 ENCODING 10289 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 00 10 00 10 00 00 ENDCHAR STARTCHAR uni2832 ENCODING 10290 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 50 00 10 00 00 ENDCHAR STARTCHAR uni2833 ENCODING 10291 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 00 50 00 10 00 00 ENDCHAR STARTCHAR uni2834 ENCODING 10292 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 10 00 50 00 00 ENDCHAR STARTCHAR uni2835 ENCODING 10293 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 00 10 00 50 00 00 ENDCHAR STARTCHAR uni2836 ENCODING 10294 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 50 00 50 00 00 ENDCHAR STARTCHAR uni2837 ENCODING 10295 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 00 50 00 50 00 00 ENDCHAR STARTCHAR uni2838 ENCODING 10296 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 00 10 00 10 00 00 ENDCHAR STARTCHAR uni2839 ENCODING 10297 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 00 10 00 10 00 00 ENDCHAR STARTCHAR uni283A ENCODING 10298 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 00 50 00 10 00 00 ENDCHAR STARTCHAR uni283B ENCODING 10299 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 00 50 00 10 00 00 ENDCHAR STARTCHAR uni283C ENCODING 10300 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 00 10 00 50 00 00 ENDCHAR STARTCHAR uni283D ENCODING 10301 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 00 10 00 50 00 00 ENDCHAR STARTCHAR uni283E ENCODING 10302 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 00 50 00 50 00 00 ENDCHAR STARTCHAR uni283F ENCODING 10303 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 00 50 00 50 00 00 ENDCHAR STARTCHAR uni2840 ENCODING 10304 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 00 00 00 00 40 ENDCHAR STARTCHAR uni2841 ENCODING 10305 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 00 00 00 00 00 40 ENDCHAR STARTCHAR uni2842 ENCODING 10306 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 40 00 00 00 40 ENDCHAR STARTCHAR uni2843 ENCODING 10307 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 00 40 00 00 00 40 ENDCHAR STARTCHAR uni2844 ENCODING 10308 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 00 00 40 00 40 ENDCHAR STARTCHAR uni2845 ENCODING 10309 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 00 00 00 40 00 40 ENDCHAR STARTCHAR uni2846 ENCODING 10310 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 40 00 40 00 40 ENDCHAR STARTCHAR uni2847 ENCODING 10311 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 00 40 00 40 00 40 ENDCHAR STARTCHAR uni2848 ENCODING 10312 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 00 00 00 00 00 40 ENDCHAR STARTCHAR uni2849 ENCODING 10313 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 00 00 00 00 00 40 ENDCHAR STARTCHAR uni284A ENCODING 10314 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 00 40 00 00 00 40 ENDCHAR STARTCHAR uni284B ENCODING 10315 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 00 40 00 00 00 40 ENDCHAR STARTCHAR uni284C ENCODING 10316 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 00 00 00 40 00 40 ENDCHAR STARTCHAR uni284D ENCODING 10317 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 00 00 00 40 00 40 ENDCHAR STARTCHAR uni284E ENCODING 10318 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 00 40 00 40 00 40 ENDCHAR STARTCHAR uni284F ENCODING 10319 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 00 40 00 40 00 40 ENDCHAR STARTCHAR uni2850 ENCODING 10320 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 10 00 00 00 40 ENDCHAR STARTCHAR uni2851 ENCODING 10321 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 00 10 00 00 00 40 ENDCHAR STARTCHAR uni2852 ENCODING 10322 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 50 00 00 00 40 ENDCHAR STARTCHAR uni2853 ENCODING 10323 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 00 50 00 00 00 40 ENDCHAR STARTCHAR uni2854 ENCODING 10324 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 10 00 40 00 40 ENDCHAR STARTCHAR uni2855 ENCODING 10325 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 00 10 00 40 00 40 ENDCHAR STARTCHAR uni2856 ENCODING 10326 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 50 00 40 00 40 ENDCHAR STARTCHAR uni2857 ENCODING 10327 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 00 50 00 40 00 40 ENDCHAR STARTCHAR uni2858 ENCODING 10328 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 00 10 00 00 00 40 ENDCHAR STARTCHAR uni2859 ENCODING 10329 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 00 10 00 00 00 40 ENDCHAR STARTCHAR uni285A ENCODING 10330 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 00 50 00 00 00 40 ENDCHAR STARTCHAR uni285B ENCODING 10331 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 00 50 00 00 00 40 ENDCHAR STARTCHAR uni285C ENCODING 10332 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 00 10 00 40 00 40 ENDCHAR STARTCHAR uni285D ENCODING 10333 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 00 10 00 40 00 40 ENDCHAR STARTCHAR uni285E ENCODING 10334 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 00 50 00 40 00 40 ENDCHAR STARTCHAR uni285F ENCODING 10335 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 00 50 00 40 00 40 ENDCHAR STARTCHAR uni2860 ENCODING 10336 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 00 00 10 00 40 ENDCHAR STARTCHAR uni2861 ENCODING 10337 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 00 00 00 10 00 40 ENDCHAR STARTCHAR uni2862 ENCODING 10338 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 40 00 10 00 40 ENDCHAR STARTCHAR uni2863 ENCODING 10339 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 00 40 00 10 00 40 ENDCHAR STARTCHAR uni2864 ENCODING 10340 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 00 00 50 00 40 ENDCHAR STARTCHAR uni2865 ENCODING 10341 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 00 00 00 50 00 40 ENDCHAR STARTCHAR uni2866 ENCODING 10342 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 40 00 50 00 40 ENDCHAR STARTCHAR uni2867 ENCODING 10343 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 00 40 00 50 00 40 ENDCHAR STARTCHAR uni2868 ENCODING 10344 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 00 00 00 10 00 40 ENDCHAR STARTCHAR uni2869 ENCODING 10345 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 00 00 00 10 00 40 ENDCHAR STARTCHAR uni286A ENCODING 10346 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 00 40 00 10 00 40 ENDCHAR STARTCHAR uni286B ENCODING 10347 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 00 40 00 10 00 40 ENDCHAR STARTCHAR uni286C ENCODING 10348 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 00 00 00 50 00 40 ENDCHAR STARTCHAR uni286D ENCODING 10349 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 00 00 00 50 00 40 ENDCHAR STARTCHAR uni286E ENCODING 10350 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 00 40 00 50 00 40 ENDCHAR STARTCHAR uni286F ENCODING 10351 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 00 40 00 50 00 40 ENDCHAR STARTCHAR uni2870 ENCODING 10352 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 10 00 10 00 40 ENDCHAR STARTCHAR uni2871 ENCODING 10353 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 00 10 00 10 00 40 ENDCHAR STARTCHAR uni2872 ENCODING 10354 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 50 00 10 00 40 ENDCHAR STARTCHAR uni2873 ENCODING 10355 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 00 50 00 10 00 40 ENDCHAR STARTCHAR uni2874 ENCODING 10356 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 10 00 50 00 40 ENDCHAR STARTCHAR uni2875 ENCODING 10357 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 00 10 00 50 00 40 ENDCHAR STARTCHAR uni2876 ENCODING 10358 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 50 00 50 00 40 ENDCHAR STARTCHAR uni2877 ENCODING 10359 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 00 50 00 50 00 40 ENDCHAR STARTCHAR uni2878 ENCODING 10360 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 00 10 00 10 00 40 ENDCHAR STARTCHAR uni2879 ENCODING 10361 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 00 10 00 10 00 40 ENDCHAR STARTCHAR uni287A ENCODING 10362 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 00 50 00 10 00 40 ENDCHAR STARTCHAR uni287B ENCODING 10363 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 00 50 00 10 00 40 ENDCHAR STARTCHAR uni287C ENCODING 10364 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 00 10 00 50 00 40 ENDCHAR STARTCHAR uni287D ENCODING 10365 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 00 10 00 50 00 40 ENDCHAR STARTCHAR uni287E ENCODING 10366 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 00 50 00 50 00 40 ENDCHAR STARTCHAR uni287F ENCODING 10367 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 00 50 00 50 00 40 ENDCHAR STARTCHAR uni2880 ENCODING 10368 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 00 00 00 00 10 ENDCHAR STARTCHAR uni2881 ENCODING 10369 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 00 00 00 00 00 10 ENDCHAR STARTCHAR uni2882 ENCODING 10370 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 40 00 00 00 10 ENDCHAR STARTCHAR uni2883 ENCODING 10371 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 00 40 00 00 00 10 ENDCHAR STARTCHAR uni2884 ENCODING 10372 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 00 00 40 00 10 ENDCHAR STARTCHAR uni2885 ENCODING 10373 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 00 00 00 40 00 10 ENDCHAR STARTCHAR uni2886 ENCODING 10374 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 40 00 40 00 10 ENDCHAR STARTCHAR uni2887 ENCODING 10375 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 00 40 00 40 00 10 ENDCHAR STARTCHAR uni2888 ENCODING 10376 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 00 00 00 00 00 10 ENDCHAR STARTCHAR uni2889 ENCODING 10377 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 00 00 00 00 00 10 ENDCHAR STARTCHAR uni288A ENCODING 10378 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 00 40 00 00 00 10 ENDCHAR STARTCHAR uni288B ENCODING 10379 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 00 40 00 00 00 10 ENDCHAR STARTCHAR uni288C ENCODING 10380 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 00 00 00 40 00 10 ENDCHAR STARTCHAR uni288D ENCODING 10381 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 00 00 00 40 00 10 ENDCHAR STARTCHAR uni288E ENCODING 10382 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 00 40 00 40 00 10 ENDCHAR STARTCHAR uni288F ENCODING 10383 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 00 40 00 40 00 10 ENDCHAR STARTCHAR uni2890 ENCODING 10384 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 10 00 00 00 10 ENDCHAR STARTCHAR uni2891 ENCODING 10385 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 00 10 00 00 00 10 ENDCHAR STARTCHAR uni2892 ENCODING 10386 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 50 00 00 00 10 ENDCHAR STARTCHAR uni2893 ENCODING 10387 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 00 50 00 00 00 10 ENDCHAR STARTCHAR uni2894 ENCODING 10388 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 10 00 40 00 10 ENDCHAR STARTCHAR uni2895 ENCODING 10389 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 00 10 00 40 00 10 ENDCHAR STARTCHAR uni2896 ENCODING 10390 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 50 00 40 00 10 ENDCHAR STARTCHAR uni2897 ENCODING 10391 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 00 50 00 40 00 10 ENDCHAR STARTCHAR uni2898 ENCODING 10392 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 00 10 00 00 00 10 ENDCHAR STARTCHAR uni2899 ENCODING 10393 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 00 10 00 00 00 10 ENDCHAR STARTCHAR uni289A ENCODING 10394 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 00 50 00 00 00 10 ENDCHAR STARTCHAR uni289B ENCODING 10395 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 00 50 00 00 00 10 ENDCHAR STARTCHAR uni289C ENCODING 10396 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 00 10 00 40 00 10 ENDCHAR STARTCHAR uni289D ENCODING 10397 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 00 10 00 40 00 10 ENDCHAR STARTCHAR uni289E ENCODING 10398 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 00 50 00 40 00 10 ENDCHAR STARTCHAR uni289F ENCODING 10399 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 00 50 00 40 00 10 ENDCHAR STARTCHAR uni28A0 ENCODING 10400 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 00 00 10 00 10 ENDCHAR STARTCHAR uni28A1 ENCODING 10401 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 00 00 00 10 00 10 ENDCHAR STARTCHAR uni28A2 ENCODING 10402 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 40 00 10 00 10 ENDCHAR STARTCHAR uni28A3 ENCODING 10403 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 00 40 00 10 00 10 ENDCHAR STARTCHAR uni28A4 ENCODING 10404 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 00 00 50 00 10 ENDCHAR STARTCHAR uni28A5 ENCODING 10405 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 00 00 00 50 00 10 ENDCHAR STARTCHAR uni28A6 ENCODING 10406 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 40 00 50 00 10 ENDCHAR STARTCHAR uni28A7 ENCODING 10407 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 00 40 00 50 00 10 ENDCHAR STARTCHAR uni28A8 ENCODING 10408 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 00 00 00 10 00 10 ENDCHAR STARTCHAR uni28A9 ENCODING 10409 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 00 00 00 10 00 10 ENDCHAR STARTCHAR uni28AA ENCODING 10410 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 00 40 00 10 00 10 ENDCHAR STARTCHAR uni28AB ENCODING 10411 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 00 40 00 10 00 10 ENDCHAR STARTCHAR uni28AC ENCODING 10412 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 00 00 00 50 00 10 ENDCHAR STARTCHAR uni28AD ENCODING 10413 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 00 00 00 50 00 10 ENDCHAR STARTCHAR uni28AE ENCODING 10414 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 00 40 00 50 00 10 ENDCHAR STARTCHAR uni28AF ENCODING 10415 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 00 40 00 50 00 10 ENDCHAR STARTCHAR uni28B0 ENCODING 10416 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 10 00 10 00 10 ENDCHAR STARTCHAR uni28B1 ENCODING 10417 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 00 10 00 10 00 10 ENDCHAR STARTCHAR uni28B2 ENCODING 10418 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 50 00 10 00 10 ENDCHAR STARTCHAR uni28B3 ENCODING 10419 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 00 50 00 10 00 10 ENDCHAR STARTCHAR uni28B4 ENCODING 10420 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 10 00 50 00 10 ENDCHAR STARTCHAR uni28B5 ENCODING 10421 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 00 10 00 50 00 10 ENDCHAR STARTCHAR uni28B6 ENCODING 10422 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 50 00 50 00 10 ENDCHAR STARTCHAR uni28B7 ENCODING 10423 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 00 50 00 50 00 10 ENDCHAR STARTCHAR uni28B8 ENCODING 10424 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 00 10 00 10 00 10 ENDCHAR STARTCHAR uni28B9 ENCODING 10425 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 00 10 00 10 00 10 ENDCHAR STARTCHAR uni28BA ENCODING 10426 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 00 50 00 10 00 10 ENDCHAR STARTCHAR uni28BB ENCODING 10427 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 00 50 00 10 00 10 ENDCHAR STARTCHAR uni28BC ENCODING 10428 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 00 10 00 50 00 10 ENDCHAR STARTCHAR uni28BD ENCODING 10429 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 00 10 00 50 00 10 ENDCHAR STARTCHAR uni28BE ENCODING 10430 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 00 50 00 50 00 10 ENDCHAR STARTCHAR uni28BF ENCODING 10431 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 00 50 00 50 00 10 ENDCHAR STARTCHAR uni28C0 ENCODING 10432 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 00 00 00 00 50 ENDCHAR STARTCHAR uni28C1 ENCODING 10433 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 00 00 00 00 00 50 ENDCHAR STARTCHAR uni28C2 ENCODING 10434 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 40 00 00 00 50 ENDCHAR STARTCHAR uni28C3 ENCODING 10435 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 00 40 00 00 00 50 ENDCHAR STARTCHAR uni28C4 ENCODING 10436 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 00 00 40 00 50 ENDCHAR STARTCHAR uni28C5 ENCODING 10437 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 00 00 00 40 00 50 ENDCHAR STARTCHAR uni28C6 ENCODING 10438 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 40 00 40 00 50 ENDCHAR STARTCHAR uni28C7 ENCODING 10439 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 00 40 00 40 00 50 ENDCHAR STARTCHAR uni28C8 ENCODING 10440 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 00 00 00 00 00 50 ENDCHAR STARTCHAR uni28C9 ENCODING 10441 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 00 00 00 00 00 50 ENDCHAR STARTCHAR uni28CA ENCODING 10442 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 00 40 00 00 00 50 ENDCHAR STARTCHAR uni28CB ENCODING 10443 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 00 40 00 00 00 50 ENDCHAR STARTCHAR uni28CC ENCODING 10444 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 00 00 00 40 00 50 ENDCHAR STARTCHAR uni28CD ENCODING 10445 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 00 00 00 40 00 50 ENDCHAR STARTCHAR uni28CE ENCODING 10446 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 00 40 00 40 00 50 ENDCHAR STARTCHAR uni28CF ENCODING 10447 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 00 40 00 40 00 50 ENDCHAR STARTCHAR uni28D0 ENCODING 10448 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 10 00 00 00 50 ENDCHAR STARTCHAR uni28D1 ENCODING 10449 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 00 10 00 00 00 50 ENDCHAR STARTCHAR uni28D2 ENCODING 10450 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 50 00 00 00 50 ENDCHAR STARTCHAR uni28D3 ENCODING 10451 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 00 50 00 00 00 50 ENDCHAR STARTCHAR uni28D4 ENCODING 10452 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 10 00 40 00 50 ENDCHAR STARTCHAR uni28D5 ENCODING 10453 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 00 10 00 40 00 50 ENDCHAR STARTCHAR uni28D6 ENCODING 10454 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 50 00 40 00 50 ENDCHAR STARTCHAR uni28D7 ENCODING 10455 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 00 50 00 40 00 50 ENDCHAR STARTCHAR uni28D8 ENCODING 10456 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 00 10 00 00 00 50 ENDCHAR STARTCHAR uni28D9 ENCODING 10457 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 00 10 00 00 00 50 ENDCHAR STARTCHAR uni28DA ENCODING 10458 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 00 50 00 00 00 50 ENDCHAR STARTCHAR uni28DB ENCODING 10459 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 00 50 00 00 00 50 ENDCHAR STARTCHAR uni28DC ENCODING 10460 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 00 10 00 40 00 50 ENDCHAR STARTCHAR uni28DD ENCODING 10461 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 00 10 00 40 00 50 ENDCHAR STARTCHAR uni28DE ENCODING 10462 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 00 50 00 40 00 50 ENDCHAR STARTCHAR uni28DF ENCODING 10463 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 00 50 00 40 00 50 ENDCHAR STARTCHAR uni28E0 ENCODING 10464 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 00 00 10 00 50 ENDCHAR STARTCHAR uni28E1 ENCODING 10465 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 00 00 00 10 00 50 ENDCHAR STARTCHAR uni28E2 ENCODING 10466 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 40 00 10 00 50 ENDCHAR STARTCHAR uni28E3 ENCODING 10467 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 00 40 00 10 00 50 ENDCHAR STARTCHAR uni28E4 ENCODING 10468 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 00 00 50 00 50 ENDCHAR STARTCHAR uni28E5 ENCODING 10469 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 00 00 00 50 00 50 ENDCHAR STARTCHAR uni28E6 ENCODING 10470 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 40 00 50 00 50 ENDCHAR STARTCHAR uni28E7 ENCODING 10471 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 00 40 00 50 00 50 ENDCHAR STARTCHAR uni28E8 ENCODING 10472 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 00 00 00 10 00 50 ENDCHAR STARTCHAR uni28E9 ENCODING 10473 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 00 00 00 10 00 50 ENDCHAR STARTCHAR uni28EA ENCODING 10474 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 00 40 00 10 00 50 ENDCHAR STARTCHAR uni28EB ENCODING 10475 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 00 40 00 10 00 50 ENDCHAR STARTCHAR uni28EC ENCODING 10476 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 00 00 00 50 00 50 ENDCHAR STARTCHAR uni28ED ENCODING 10477 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 00 00 00 50 00 50 ENDCHAR STARTCHAR uni28EE ENCODING 10478 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 00 40 00 50 00 50 ENDCHAR STARTCHAR uni28EF ENCODING 10479 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 00 40 00 50 00 50 ENDCHAR STARTCHAR uni28F0 ENCODING 10480 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 10 00 10 00 50 ENDCHAR STARTCHAR uni28F1 ENCODING 10481 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 00 10 00 10 00 50 ENDCHAR STARTCHAR uni28F2 ENCODING 10482 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 50 00 10 00 50 ENDCHAR STARTCHAR uni28F3 ENCODING 10483 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 00 50 00 10 00 50 ENDCHAR STARTCHAR uni28F4 ENCODING 10484 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 10 00 50 00 50 ENDCHAR STARTCHAR uni28F5 ENCODING 10485 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 00 10 00 50 00 50 ENDCHAR STARTCHAR uni28F6 ENCODING 10486 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 00 00 50 00 50 00 50 ENDCHAR STARTCHAR uni28F7 ENCODING 10487 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 40 00 50 00 50 00 50 ENDCHAR STARTCHAR uni28F8 ENCODING 10488 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 00 10 00 10 00 50 ENDCHAR STARTCHAR uni28F9 ENCODING 10489 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 00 10 00 10 00 50 ENDCHAR STARTCHAR uni28FA ENCODING 10490 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 00 50 00 10 00 50 ENDCHAR STARTCHAR uni28FB ENCODING 10491 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 00 50 00 10 00 50 ENDCHAR STARTCHAR uni28FC ENCODING 10492 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 00 10 00 50 00 50 ENDCHAR STARTCHAR uni28FD ENCODING 10493 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 00 10 00 50 00 50 ENDCHAR STARTCHAR uni28FE ENCODING 10494 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 10 00 50 00 50 00 50 ENDCHAR STARTCHAR uni28FF ENCODING 10495 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 00 50 00 50 00 50 ENDCHAR STARTCHAR fi ENCODING 64257 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 20 50 40 F0 50 50 00 ENDCHAR STARTCHAR fl ENCODING 64258 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 30 50 50 F0 50 50 00 ENDCHAR STARTCHAR uniFFFD ENCODING 65533 SWIDTH 685 0 DWIDTH 5 0 BBX 5 7 0 -1 BITMAP 50 A8 E8 D8 F8 D8 70 ENDCHAR ENDFONT ================================================ FILE: share/examples/gpanel/fonts/bdf/6x9.bdf ================================================ STARTFONT 2.1 COMMENT $Id: 6x9.bdf,v 1.28 2006-01-05 20:03:17+00 mgk25 Rel $ COMMENT Send bug reports to Markus Kuhn FONT -Misc-Fixed-Medium-R-Normal--9-90-75-75-C-60-ISO10646-1 SIZE 9 75 75 FONTBOUNDINGBOX 6 9 0 -2 STARTPROPERTIES 22 FONTNAME_REGISTRY "" FOUNDRY "Misc" FAMILY_NAME "Fixed" WEIGHT_NAME "Medium" SLANT "R" SETWIDTH_NAME "Normal" ADD_STYLE_NAME "" PIXEL_SIZE 9 POINT_SIZE 90 RESOLUTION_X 75 RESOLUTION_Y 75 SPACING "C" AVERAGE_WIDTH 60 CHARSET_REGISTRY "ISO10646" CHARSET_ENCODING "1" FONT_ASCENT 7 FONT_DESCENT 2 DEFAULT_CHAR 0 COPYRIGHT "Public domain font. Share and enjoy." _XMBDFED_INFO "Edited with xmbdfed 4.5." CAP_HEIGHT 6 X_HEIGHT 4 ENDPROPERTIES CHARS 1296 STARTCHAR char0 ENCODING 0 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 28 40 08 40 08 50 00 00 ENDCHAR STARTCHAR space ENCODING 32 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 00 00 00 00 00 00 ENDCHAR STARTCHAR exclam ENCODING 33 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 20 20 20 20 00 20 00 00 ENDCHAR STARTCHAR quotedbl ENCODING 34 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 50 50 50 00 00 00 00 00 ENDCHAR STARTCHAR numbersign ENCODING 35 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 50 50 F8 50 F8 50 50 00 ENDCHAR STARTCHAR dollar ENCODING 36 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 20 70 A8 A0 70 28 A8 70 20 ENDCHAR STARTCHAR percent ENCODING 37 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 40 A8 48 10 20 48 54 08 00 ENDCHAR STARTCHAR ampersand ENCODING 38 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 60 90 90 60 98 90 68 00 ENDCHAR STARTCHAR quotesingle ENCODING 39 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 20 20 20 00 00 00 00 00 ENDCHAR STARTCHAR parenleft ENCODING 40 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 10 20 20 20 20 20 10 00 ENDCHAR STARTCHAR parenright ENCODING 41 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 20 10 10 10 10 10 20 00 ENDCHAR STARTCHAR asterisk ENCODING 42 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 88 50 F8 50 88 00 00 ENDCHAR STARTCHAR plus ENCODING 43 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 20 20 F8 20 20 00 00 ENDCHAR STARTCHAR comma ENCODING 44 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 00 00 30 10 10 20 ENDCHAR STARTCHAR hyphen ENCODING 45 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 00 F8 00 00 00 00 ENDCHAR STARTCHAR period ENCODING 46 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 00 00 30 30 00 00 ENDCHAR STARTCHAR slash ENCODING 47 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 08 08 10 20 40 40 00 00 ENDCHAR STARTCHAR zero ENCODING 48 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 30 48 48 48 48 30 00 00 ENDCHAR STARTCHAR one ENCODING 49 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 20 60 20 20 20 70 00 00 ENDCHAR STARTCHAR two ENCODING 50 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 30 48 08 10 20 78 00 00 ENDCHAR STARTCHAR three ENCODING 51 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 78 10 30 08 08 70 00 00 ENDCHAR STARTCHAR four ENCODING 52 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 10 30 50 90 F8 10 00 00 ENDCHAR STARTCHAR five ENCODING 53 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 78 40 70 08 08 70 00 00 ENDCHAR STARTCHAR six ENCODING 54 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 30 40 70 48 48 30 00 00 ENDCHAR STARTCHAR seven ENCODING 55 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 78 08 08 10 20 20 00 00 ENDCHAR STARTCHAR eight ENCODING 56 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 30 48 30 48 48 30 00 00 ENDCHAR STARTCHAR nine ENCODING 57 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 30 48 48 38 08 30 00 00 ENDCHAR STARTCHAR colon ENCODING 58 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 30 30 00 30 30 00 00 ENDCHAR STARTCHAR semicolon ENCODING 59 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 30 30 00 30 10 10 20 ENDCHAR STARTCHAR less ENCODING 60 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 18 60 80 60 18 00 00 ENDCHAR STARTCHAR equal ENCODING 61 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 F8 00 F8 00 00 00 ENDCHAR STARTCHAR greater ENCODING 62 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 C0 30 08 30 C0 00 00 ENDCHAR STARTCHAR question ENCODING 63 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 30 48 08 30 20 00 20 00 00 ENDCHAR STARTCHAR at ENCODING 64 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 70 90 A8 B0 80 70 00 00 ENDCHAR STARTCHAR A ENCODING 65 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 20 50 88 F8 88 88 00 00 ENDCHAR STARTCHAR B ENCODING 66 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 F0 88 F0 88 88 F0 00 00 ENDCHAR STARTCHAR C ENCODING 67 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 30 48 40 40 48 30 00 00 ENDCHAR STARTCHAR D ENCODING 68 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 70 48 48 48 48 70 00 00 ENDCHAR STARTCHAR E ENCODING 69 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 78 40 70 40 40 78 00 00 ENDCHAR STARTCHAR F ENCODING 70 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 78 40 70 40 40 40 00 00 ENDCHAR STARTCHAR G ENCODING 71 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 30 48 40 58 48 30 00 00 ENDCHAR STARTCHAR H ENCODING 72 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 48 48 78 48 48 48 00 00 ENDCHAR STARTCHAR I ENCODING 73 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 70 20 20 20 20 70 00 00 ENDCHAR STARTCHAR J ENCODING 74 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 38 10 10 10 90 60 00 00 ENDCHAR STARTCHAR K ENCODING 75 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 48 50 60 50 48 48 00 00 ENDCHAR STARTCHAR L ENCODING 76 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 40 40 40 40 40 78 00 00 ENDCHAR STARTCHAR M ENCODING 77 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 88 D8 A8 A8 88 88 00 00 ENDCHAR STARTCHAR N ENCODING 78 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 48 68 58 48 48 48 00 00 ENDCHAR STARTCHAR O ENCODING 79 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 70 88 88 88 88 70 00 00 ENDCHAR STARTCHAR P ENCODING 80 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 70 48 48 70 40 40 00 00 ENDCHAR STARTCHAR Q ENCODING 81 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 30 48 48 68 58 30 08 00 ENDCHAR STARTCHAR R ENCODING 82 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 70 48 48 70 48 48 00 00 ENDCHAR STARTCHAR S ENCODING 83 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 30 48 20 10 48 30 00 00 ENDCHAR STARTCHAR T ENCODING 84 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 F8 20 20 20 20 20 00 00 ENDCHAR STARTCHAR U ENCODING 85 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 48 48 48 48 48 30 00 00 ENDCHAR STARTCHAR V ENCODING 86 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 48 48 48 78 30 30 00 00 ENDCHAR STARTCHAR W ENCODING 87 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 88 88 A8 A8 D8 88 00 00 ENDCHAR STARTCHAR X ENCODING 88 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 88 50 20 20 50 88 00 00 ENDCHAR STARTCHAR Y ENCODING 89 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 88 88 50 20 20 20 00 00 ENDCHAR STARTCHAR Z ENCODING 90 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 78 08 10 20 40 78 00 00 ENDCHAR STARTCHAR bracketleft ENCODING 91 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 70 40 40 40 40 70 00 00 ENDCHAR STARTCHAR backslash ENCODING 92 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 40 40 20 10 08 08 00 00 ENDCHAR STARTCHAR bracketright ENCODING 93 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 70 10 10 10 10 70 00 00 ENDCHAR STARTCHAR asciicircum ENCODING 94 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 20 50 88 00 00 00 00 00 ENDCHAR STARTCHAR underscore ENCODING 95 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 00 00 00 00 00 F8 ENDCHAR STARTCHAR grave ENCODING 96 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 20 10 00 00 00 00 00 00 ENDCHAR STARTCHAR a ENCODING 97 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 38 48 48 38 00 00 ENDCHAR STARTCHAR b ENCODING 98 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 40 40 70 48 48 70 00 00 ENDCHAR STARTCHAR c ENCODING 99 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 38 40 40 38 00 00 ENDCHAR STARTCHAR d ENCODING 100 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 08 08 38 48 48 38 00 00 ENDCHAR STARTCHAR e ENCODING 101 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 30 58 60 38 00 00 ENDCHAR STARTCHAR f ENCODING 102 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 10 28 20 70 20 20 00 00 ENDCHAR STARTCHAR g ENCODING 103 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 30 48 48 38 08 30 ENDCHAR STARTCHAR h ENCODING 104 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 40 40 70 48 48 48 00 00 ENDCHAR STARTCHAR i ENCODING 105 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 20 00 60 20 20 70 00 00 ENDCHAR STARTCHAR j ENCODING 106 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 10 00 30 10 10 10 50 20 ENDCHAR STARTCHAR k ENCODING 107 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 40 40 50 60 50 48 00 00 ENDCHAR STARTCHAR l ENCODING 108 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 60 20 20 20 20 70 00 00 ENDCHAR STARTCHAR m ENCODING 109 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 D0 A8 A8 88 00 00 ENDCHAR STARTCHAR n ENCODING 110 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 70 48 48 48 00 00 ENDCHAR STARTCHAR o ENCODING 111 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 30 48 48 30 00 00 ENDCHAR STARTCHAR p ENCODING 112 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 70 48 48 70 40 40 ENDCHAR STARTCHAR q ENCODING 113 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 38 48 48 38 08 08 ENDCHAR STARTCHAR r ENCODING 114 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 50 68 40 40 00 00 ENDCHAR STARTCHAR s ENCODING 115 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 38 60 18 70 00 00 ENDCHAR STARTCHAR t ENCODING 116 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 20 20 70 20 28 10 00 00 ENDCHAR STARTCHAR u ENCODING 117 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 48 48 48 38 00 00 ENDCHAR STARTCHAR v ENCODING 118 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 48 48 30 30 00 00 ENDCHAR STARTCHAR w ENCODING 119 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 88 A8 A8 50 00 00 ENDCHAR STARTCHAR x ENCODING 120 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 48 30 30 48 00 00 ENDCHAR STARTCHAR y ENCODING 121 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 48 48 48 38 48 30 ENDCHAR STARTCHAR z ENCODING 122 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 78 10 20 78 00 00 ENDCHAR STARTCHAR braceleft ENCODING 123 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 10 20 20 40 20 20 10 00 00 ENDCHAR STARTCHAR bar ENCODING 124 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 20 20 20 20 20 20 20 00 ENDCHAR STARTCHAR braceright ENCODING 125 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 40 20 20 10 20 20 40 00 00 ENDCHAR STARTCHAR asciitilde ENCODING 126 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 28 50 00 00 00 00 00 ENDCHAR STARTCHAR space ENCODING 160 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 00 00 00 00 00 00 ENDCHAR STARTCHAR exclamdown ENCODING 161 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 20 00 20 20 20 20 00 00 ENDCHAR STARTCHAR cent ENCODING 162 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 10 38 50 50 38 10 00 ENDCHAR STARTCHAR sterling ENCODING 163 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 30 48 40 F0 40 40 F8 00 ENDCHAR STARTCHAR currency ENCODING 164 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 A8 50 88 50 A8 00 00 ENDCHAR STARTCHAR yen ENCODING 165 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 88 50 F8 20 F8 20 00 00 ENDCHAR STARTCHAR brokenbar ENCODING 166 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 20 20 20 00 20 20 20 00 ENDCHAR STARTCHAR section ENCODING 167 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 38 40 30 48 30 08 70 00 ENDCHAR STARTCHAR dieresis ENCODING 168 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 50 00 00 00 00 00 00 00 ENDCHAR STARTCHAR copyright ENCODING 169 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 78 84 94 A4 94 84 78 00 00 ENDCHAR STARTCHAR ordfeminine ENCODING 170 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 30 50 30 00 70 00 00 00 ENDCHAR STARTCHAR guillemotleft ENCODING 171 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 28 50 A0 50 28 00 00 ENDCHAR STARTCHAR logicalnot ENCODING 172 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 00 78 08 08 00 00 ENDCHAR STARTCHAR hyphen ENCODING 173 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 00 78 00 00 00 00 ENDCHAR STARTCHAR registered ENCODING 174 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 78 84 B4 A4 A4 84 78 00 00 ENDCHAR STARTCHAR macron ENCODING 175 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 78 00 00 00 00 00 00 00 ENDCHAR STARTCHAR degree ENCODING 176 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 30 48 30 00 00 00 00 ENDCHAR STARTCHAR plusminus ENCODING 177 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 20 20 F8 20 20 00 F8 00 ENDCHAR STARTCHAR twosuperior ENCODING 178 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 20 50 10 20 70 00 00 00 ENDCHAR STARTCHAR threesuperior ENCODING 179 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 60 10 20 10 60 00 00 00 ENDCHAR STARTCHAR acute ENCODING 180 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 10 20 00 00 00 00 00 00 ENDCHAR STARTCHAR mu ENCODING 181 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 48 48 58 68 40 00 ENDCHAR STARTCHAR paragraph ENCODING 182 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 78 E8 E8 68 28 28 00 00 ENDCHAR STARTCHAR periodcentered ENCODING 183 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 00 20 00 00 00 00 ENDCHAR STARTCHAR cedilla ENCODING 184 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 00 00 00 00 10 20 ENDCHAR STARTCHAR onesuperior ENCODING 185 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 20 60 20 20 70 00 00 00 ENDCHAR STARTCHAR ordmasculine ENCODING 186 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 20 50 20 00 70 00 00 00 ENDCHAR STARTCHAR guillemotright ENCODING 187 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 A0 50 28 50 A0 00 00 ENDCHAR STARTCHAR onequarter ENCODING 188 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 40 C0 40 50 70 30 78 10 00 ENDCHAR STARTCHAR onehalf ENCODING 189 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 40 C0 40 50 68 08 10 38 00 ENDCHAR STARTCHAR threequarters ENCODING 190 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP C0 20 40 30 F0 30 78 10 00 ENDCHAR STARTCHAR questiondown ENCODING 191 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 10 00 10 30 40 48 30 00 00 ENDCHAR STARTCHAR Agrave ENCODING 192 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 40 20 20 50 70 88 88 00 00 ENDCHAR STARTCHAR Aacute ENCODING 193 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 10 20 20 50 70 88 88 00 00 ENDCHAR STARTCHAR Acircumflex ENCODING 194 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 20 50 20 50 70 88 88 00 00 ENDCHAR STARTCHAR Atilde ENCODING 195 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 28 50 20 50 70 88 88 00 00 ENDCHAR STARTCHAR Adieresis ENCODING 196 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 50 00 20 50 70 88 88 00 00 ENDCHAR STARTCHAR Aring ENCODING 197 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 20 50 20 50 70 88 88 00 00 ENDCHAR STARTCHAR AE ENCODING 198 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 78 A0 F0 A0 A0 B8 00 00 ENDCHAR STARTCHAR Ccedilla ENCODING 199 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 30 48 40 40 48 30 10 20 ENDCHAR STARTCHAR Egrave ENCODING 200 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 20 10 78 40 70 40 78 00 00 ENDCHAR STARTCHAR Eacute ENCODING 201 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 10 20 78 40 70 40 78 00 00 ENDCHAR STARTCHAR Ecircumflex ENCODING 202 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 10 28 78 40 70 40 78 00 00 ENDCHAR STARTCHAR Edieresis ENCODING 203 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 28 00 78 40 70 40 78 00 00 ENDCHAR STARTCHAR Igrave ENCODING 204 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 40 20 70 20 20 20 70 00 00 ENDCHAR STARTCHAR Iacute ENCODING 205 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 10 20 70 20 20 20 70 00 00 ENDCHAR STARTCHAR Icircumflex ENCODING 206 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 20 50 70 20 20 20 70 00 00 ENDCHAR STARTCHAR Idieresis ENCODING 207 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 50 00 70 20 20 20 70 00 00 ENDCHAR STARTCHAR Eth ENCODING 208 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 70 48 E8 48 48 70 00 00 ENDCHAR STARTCHAR Ntilde ENCODING 209 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 28 50 48 68 58 48 48 00 00 ENDCHAR STARTCHAR Ograve ENCODING 210 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 20 10 30 48 48 48 30 00 00 ENDCHAR STARTCHAR Oacute ENCODING 211 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 10 20 30 48 48 48 30 00 00 ENDCHAR STARTCHAR Ocircumflex ENCODING 212 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 10 28 30 48 48 48 30 00 00 ENDCHAR STARTCHAR Otilde ENCODING 213 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 28 50 30 48 48 48 30 00 00 ENDCHAR STARTCHAR Odieresis ENCODING 214 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 28 00 30 48 48 48 30 00 00 ENDCHAR STARTCHAR multiply ENCODING 215 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 88 50 20 50 88 00 00 ENDCHAR STARTCHAR Oslash ENCODING 216 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 08 38 58 58 68 68 70 40 00 ENDCHAR STARTCHAR Ugrave ENCODING 217 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 20 10 48 48 48 48 30 00 00 ENDCHAR STARTCHAR Uacute ENCODING 218 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 10 20 48 48 48 48 30 00 00 ENDCHAR STARTCHAR Ucircumflex ENCODING 219 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 10 28 48 48 48 48 30 00 00 ENDCHAR STARTCHAR Udieresis ENCODING 220 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 28 00 48 48 48 48 30 00 00 ENDCHAR STARTCHAR Yacute ENCODING 221 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 10 20 88 50 20 20 20 00 00 ENDCHAR STARTCHAR Thorn ENCODING 222 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 40 70 48 48 70 40 00 00 ENDCHAR STARTCHAR germandbls ENCODING 223 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 30 48 50 50 48 50 00 00 ENDCHAR STARTCHAR agrave ENCODING 224 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 20 10 00 38 48 48 38 00 00 ENDCHAR STARTCHAR aacute ENCODING 225 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 10 20 00 38 48 48 38 00 00 ENDCHAR STARTCHAR acircumflex ENCODING 226 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 10 28 00 38 48 48 38 00 00 ENDCHAR STARTCHAR atilde ENCODING 227 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 28 50 00 38 48 48 38 00 00 ENDCHAR STARTCHAR adieresis ENCODING 228 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 28 00 38 48 48 38 00 00 ENDCHAR STARTCHAR aring ENCODING 229 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 10 28 10 38 48 48 38 00 00 ENDCHAR STARTCHAR ae ENCODING 230 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 70 A8 B0 78 00 00 ENDCHAR STARTCHAR ccedilla ENCODING 231 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 38 40 40 38 10 20 ENDCHAR STARTCHAR egrave ENCODING 232 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 20 10 00 30 58 60 38 00 00 ENDCHAR STARTCHAR eacute ENCODING 233 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 10 20 00 30 58 60 38 00 00 ENDCHAR STARTCHAR ecircumflex ENCODING 234 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 10 28 00 30 58 60 38 00 00 ENDCHAR STARTCHAR edieresis ENCODING 235 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 28 00 30 58 60 38 00 00 ENDCHAR STARTCHAR igrave ENCODING 236 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 40 20 00 60 20 20 70 00 00 ENDCHAR STARTCHAR iacute ENCODING 237 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 10 20 00 60 20 20 70 00 00 ENDCHAR STARTCHAR icircumflex ENCODING 238 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 20 50 00 60 20 20 70 00 00 ENDCHAR STARTCHAR idieresis ENCODING 239 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 50 00 60 20 20 70 00 00 ENDCHAR STARTCHAR eth ENCODING 240 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 18 30 08 38 48 48 30 00 00 ENDCHAR STARTCHAR ntilde ENCODING 241 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 28 50 00 70 48 48 48 00 00 ENDCHAR STARTCHAR ograve ENCODING 242 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 20 10 00 30 48 48 30 00 00 ENDCHAR STARTCHAR oacute ENCODING 243 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 10 20 00 30 48 48 30 00 00 ENDCHAR STARTCHAR ocircumflex ENCODING 244 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 10 28 00 30 48 48 30 00 00 ENDCHAR STARTCHAR otilde ENCODING 245 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 28 50 00 30 48 48 30 00 00 ENDCHAR STARTCHAR odieresis ENCODING 246 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 28 00 30 48 48 30 00 00 ENDCHAR STARTCHAR divide ENCODING 247 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 20 00 F8 00 20 00 00 ENDCHAR STARTCHAR oslash ENCODING 248 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 38 58 68 70 00 00 ENDCHAR STARTCHAR ugrave ENCODING 249 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 20 10 00 48 48 48 38 00 00 ENDCHAR STARTCHAR uacute ENCODING 250 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 10 20 00 48 48 48 38 00 00 ENDCHAR STARTCHAR ucircumflex ENCODING 251 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 10 28 00 48 48 48 38 00 00 ENDCHAR STARTCHAR udieresis ENCODING 252 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 28 00 48 48 48 38 00 00 ENDCHAR STARTCHAR yacute ENCODING 253 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 10 20 00 48 48 48 38 48 30 ENDCHAR STARTCHAR thorn ENCODING 254 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 40 40 70 48 48 70 40 40 ENDCHAR STARTCHAR ydieresis ENCODING 255 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 28 00 48 48 48 38 48 30 ENDCHAR STARTCHAR Amacron ENCODING 256 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 70 00 20 50 70 88 88 00 00 ENDCHAR STARTCHAR amacron ENCODING 257 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 38 00 38 48 48 38 00 00 ENDCHAR STARTCHAR Abreve ENCODING 258 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 90 60 20 50 70 88 88 00 00 ENDCHAR STARTCHAR abreve ENCODING 259 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 48 30 00 38 48 48 38 00 00 ENDCHAR STARTCHAR Aogonek ENCODING 260 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 20 50 88 F8 88 88 10 08 ENDCHAR STARTCHAR aogonek ENCODING 261 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 38 48 48 38 10 08 ENDCHAR STARTCHAR Cacute ENCODING 262 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 10 20 30 48 40 48 30 00 00 ENDCHAR STARTCHAR cacute ENCODING 263 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 10 20 00 38 40 40 38 00 00 ENDCHAR STARTCHAR Ccircumflex ENCODING 264 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 10 28 30 48 40 48 30 00 00 ENDCHAR STARTCHAR ccircumflex ENCODING 265 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 10 28 00 38 40 40 38 00 00 ENDCHAR STARTCHAR Cdotaccent ENCODING 266 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 10 00 30 48 40 48 30 00 00 ENDCHAR STARTCHAR cdotaccent ENCODING 267 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 10 00 38 40 40 38 00 00 ENDCHAR STARTCHAR Ccaron ENCODING 268 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 28 10 30 48 40 48 30 00 00 ENDCHAR STARTCHAR ccaron ENCODING 269 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 28 10 00 38 40 40 38 00 00 ENDCHAR STARTCHAR Dcaron ENCODING 270 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 28 10 70 48 48 48 70 00 00 ENDCHAR STARTCHAR dcaron ENCODING 271 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 50 28 08 38 48 48 38 00 00 ENDCHAR STARTCHAR Dcroat ENCODING 272 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 70 48 E8 48 48 70 00 00 ENDCHAR STARTCHAR dcroat ENCODING 273 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 10 38 70 90 90 70 00 00 ENDCHAR STARTCHAR Emacron ENCODING 274 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 78 00 78 40 70 40 78 00 00 ENDCHAR STARTCHAR emacron ENCODING 275 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 78 00 30 58 60 38 00 00 ENDCHAR STARTCHAR Ebreve ENCODING 276 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 48 30 78 40 70 40 78 00 00 ENDCHAR STARTCHAR ebreve ENCODING 277 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 48 30 00 30 58 60 38 00 00 ENDCHAR STARTCHAR Edotaccent ENCODING 278 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 20 00 78 40 70 40 78 00 00 ENDCHAR STARTCHAR edotaccent ENCODING 279 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 20 00 30 58 60 38 00 00 ENDCHAR STARTCHAR Eogonek ENCODING 280 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 78 40 70 40 40 78 20 10 ENDCHAR STARTCHAR eogonek ENCODING 281 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 30 58 60 38 20 10 ENDCHAR STARTCHAR Ecaron ENCODING 282 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 28 10 78 40 70 40 78 00 00 ENDCHAR STARTCHAR ecaron ENCODING 283 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 28 10 00 30 58 60 38 00 00 ENDCHAR STARTCHAR Gcircumflex ENCODING 284 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 10 28 38 40 58 48 30 00 00 ENDCHAR STARTCHAR gcircumflex ENCODING 285 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 10 28 00 30 48 48 38 08 30 ENDCHAR STARTCHAR Gbreve ENCODING 286 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 48 30 38 40 58 48 30 00 00 ENDCHAR STARTCHAR gbreve ENCODING 287 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 48 30 00 30 48 48 38 08 30 ENDCHAR STARTCHAR Gdotaccent ENCODING 288 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 10 00 38 40 58 48 30 00 00 ENDCHAR STARTCHAR gdotaccent ENCODING 289 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 10 00 30 48 48 38 08 30 ENDCHAR STARTCHAR Gcommaaccent ENCODING 290 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 30 48 40 58 48 30 10 20 ENDCHAR STARTCHAR gcommaaccent ENCODING 291 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 10 20 30 48 48 38 08 30 ENDCHAR STARTCHAR Hcircumflex ENCODING 292 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 10 28 00 48 78 48 48 00 00 ENDCHAR STARTCHAR hcircumflex ENCODING 293 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 10 A8 80 E0 90 90 90 00 00 ENDCHAR STARTCHAR Hbar ENCODING 294 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 50 F8 50 70 50 50 00 00 ENDCHAR STARTCHAR hbar ENCODING 295 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 40 E0 70 48 48 48 00 00 ENDCHAR STARTCHAR Itilde ENCODING 296 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 28 50 38 10 10 10 38 00 00 ENDCHAR STARTCHAR itilde ENCODING 297 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 28 50 00 30 10 10 38 00 00 ENDCHAR STARTCHAR Imacron ENCODING 298 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 70 00 70 20 20 20 70 00 00 ENDCHAR STARTCHAR imacron ENCODING 299 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 70 00 60 20 20 70 00 00 ENDCHAR STARTCHAR Ibreve ENCODING 300 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 48 30 00 38 10 10 38 00 00 ENDCHAR STARTCHAR ibreve ENCODING 301 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 48 30 00 30 10 10 38 00 00 ENDCHAR STARTCHAR Iogonek ENCODING 302 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 70 20 20 20 20 70 20 10 ENDCHAR STARTCHAR iogonek ENCODING 303 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 20 00 60 20 20 70 20 10 ENDCHAR STARTCHAR Idotaccent ENCODING 304 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 20 00 70 20 20 20 70 00 00 ENDCHAR STARTCHAR dotlessi ENCODING 305 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 60 20 20 70 00 00 ENDCHAR STARTCHAR IJ ENCODING 306 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 B8 88 88 88 A8 90 00 00 ENDCHAR STARTCHAR ij ENCODING 307 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 88 00 98 88 88 88 28 10 ENDCHAR STARTCHAR Jcircumflex ENCODING 308 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 10 28 38 10 10 90 60 00 00 ENDCHAR STARTCHAR jcircumflex ENCODING 309 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 10 28 00 30 10 10 10 50 20 ENDCHAR STARTCHAR Kcommaaccent ENCODING 310 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 48 50 60 50 48 48 20 40 ENDCHAR STARTCHAR kcommaaccent ENCODING 311 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 40 40 50 60 50 48 20 40 ENDCHAR STARTCHAR kgreenlandic ENCODING 312 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 58 60 50 48 00 00 ENDCHAR STARTCHAR Lacute ENCODING 313 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 08 10 40 40 40 40 78 00 00 ENDCHAR STARTCHAR lacute ENCODING 314 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 20 40 60 20 20 20 70 00 00 ENDCHAR STARTCHAR Lcommaaccent ENCODING 315 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 40 40 40 40 40 78 10 20 ENDCHAR STARTCHAR lcommaaccent ENCODING 316 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 60 20 20 20 20 70 20 40 ENDCHAR STARTCHAR Lcaron ENCODING 317 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 28 10 40 40 40 40 78 00 00 ENDCHAR STARTCHAR lcaron ENCODING 318 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 50 20 60 20 20 20 70 00 00 ENDCHAR STARTCHAR Ldot ENCODING 319 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 40 40 50 40 40 78 00 00 ENDCHAR STARTCHAR ldot ENCODING 320 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 60 20 28 20 20 70 00 00 ENDCHAR STARTCHAR Lslash ENCODING 321 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 40 40 60 C0 40 78 00 00 ENDCHAR STARTCHAR lslash ENCODING 322 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 60 20 30 60 20 70 00 00 ENDCHAR STARTCHAR Nacute ENCODING 323 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 10 20 48 68 58 48 48 00 00 ENDCHAR STARTCHAR nacute ENCODING 324 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 10 20 00 70 48 48 48 00 00 ENDCHAR STARTCHAR Ncommaaccent ENCODING 325 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 48 68 58 48 48 48 20 40 ENDCHAR STARTCHAR ncommaaccent ENCODING 326 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 70 48 48 48 20 40 ENDCHAR STARTCHAR Ncaron ENCODING 327 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 28 10 48 68 58 48 48 00 00 ENDCHAR STARTCHAR ncaron ENCODING 328 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 50 20 00 70 48 48 48 00 00 ENDCHAR STARTCHAR napostrophe ENCODING 329 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 C0 40 B0 28 28 28 00 00 ENDCHAR STARTCHAR Eng ENCODING 330 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 48 68 58 48 48 48 08 10 ENDCHAR STARTCHAR eng ENCODING 331 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 70 48 48 48 08 10 ENDCHAR STARTCHAR Omacron ENCODING 332 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP F8 00 70 88 88 88 70 00 00 ENDCHAR STARTCHAR omacron ENCODING 333 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 78 00 30 48 48 30 00 00 ENDCHAR STARTCHAR Obreve ENCODING 334 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 88 70 70 88 88 88 70 00 00 ENDCHAR STARTCHAR obreve ENCODING 335 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 48 30 00 30 48 48 30 00 00 ENDCHAR STARTCHAR Ohungarumlaut ENCODING 336 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 48 90 70 88 88 88 70 00 00 ENDCHAR STARTCHAR ohungarumlaut ENCODING 337 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 48 90 00 60 90 90 60 00 00 ENDCHAR STARTCHAR OE ENCODING 338 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 78 A0 B0 A0 A0 78 00 00 ENDCHAR STARTCHAR oe ENCODING 339 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 50 A8 B0 58 00 00 ENDCHAR STARTCHAR Racute ENCODING 340 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 10 20 70 48 70 50 48 00 00 ENDCHAR STARTCHAR racute ENCODING 341 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 10 20 00 50 68 40 40 00 00 ENDCHAR STARTCHAR Rcommaaccent ENCODING 342 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 70 48 48 70 48 48 20 40 ENDCHAR STARTCHAR rcommaaccent ENCODING 343 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 50 68 40 40 20 40 ENDCHAR STARTCHAR Rcaron ENCODING 344 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 50 20 70 48 70 50 48 00 00 ENDCHAR STARTCHAR rcaron ENCODING 345 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 50 20 00 50 68 40 40 00 00 ENDCHAR STARTCHAR Sacute ENCODING 346 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 10 20 38 40 30 08 70 00 00 ENDCHAR STARTCHAR sacute ENCODING 347 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 10 20 00 38 60 18 70 00 00 ENDCHAR STARTCHAR Scircumflex ENCODING 348 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 10 28 38 40 30 08 70 00 00 ENDCHAR STARTCHAR scircumflex ENCODING 349 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 10 28 00 38 60 18 70 00 00 ENDCHAR STARTCHAR Scedilla ENCODING 350 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 30 48 20 10 48 30 10 20 ENDCHAR STARTCHAR scedilla ENCODING 351 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 38 60 18 70 10 20 ENDCHAR STARTCHAR Scaron ENCODING 352 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 28 10 38 40 30 08 70 00 00 ENDCHAR STARTCHAR scaron ENCODING 353 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 28 10 00 38 60 18 70 00 00 ENDCHAR STARTCHAR Tcommaaccent ENCODING 354 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 F8 20 20 20 20 20 10 20 ENDCHAR STARTCHAR tcommaaccent ENCODING 355 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 20 20 70 20 28 10 10 20 ENDCHAR STARTCHAR Tcaron ENCODING 356 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 50 20 F8 20 20 20 20 00 00 ENDCHAR STARTCHAR tcaron ENCODING 357 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 28 10 20 70 20 28 10 00 00 ENDCHAR STARTCHAR Tbar ENCODING 358 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 F8 20 20 70 20 20 00 00 ENDCHAR STARTCHAR tbar ENCODING 359 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 20 20 70 70 28 10 00 00 ENDCHAR STARTCHAR Utilde ENCODING 360 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 28 50 00 48 48 48 30 00 00 ENDCHAR STARTCHAR utilde ENCODING 361 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 28 50 00 48 48 48 38 00 00 ENDCHAR STARTCHAR Umacron ENCODING 362 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 78 00 48 48 48 48 30 00 00 ENDCHAR STARTCHAR umacron ENCODING 363 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 78 00 48 48 48 38 00 00 ENDCHAR STARTCHAR Ubreve ENCODING 364 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 48 30 00 48 48 48 30 00 00 ENDCHAR STARTCHAR ubreve ENCODING 365 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 48 30 00 48 48 48 38 00 00 ENDCHAR STARTCHAR Uring ENCODING 366 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 30 48 30 48 48 48 30 00 00 ENDCHAR STARTCHAR uring ENCODING 367 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 30 48 30 48 48 48 38 00 00 ENDCHAR STARTCHAR Uhungarumlaut ENCODING 368 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 48 90 00 90 90 90 60 00 00 ENDCHAR STARTCHAR uhungarumlaut ENCODING 369 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 48 90 00 90 90 90 70 00 00 ENDCHAR STARTCHAR Uogonek ENCODING 370 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 48 48 48 48 48 30 20 10 ENDCHAR STARTCHAR uogonek ENCODING 371 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 48 48 48 38 20 10 ENDCHAR STARTCHAR Wcircumflex ENCODING 372 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 20 50 00 88 A8 D8 88 00 00 ENDCHAR STARTCHAR wcircumflex ENCODING 373 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 20 50 00 88 A8 A8 50 00 00 ENDCHAR STARTCHAR Ycircumflex ENCODING 374 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 20 50 00 88 50 20 20 00 00 ENDCHAR STARTCHAR ycircumflex ENCODING 375 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 10 28 00 48 48 48 38 48 30 ENDCHAR STARTCHAR Ydieresis ENCODING 376 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 50 00 88 50 20 20 20 00 00 ENDCHAR STARTCHAR Zacute ENCODING 377 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 10 20 78 10 20 40 78 00 00 ENDCHAR STARTCHAR zacute ENCODING 378 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 10 20 00 78 10 20 78 00 00 ENDCHAR STARTCHAR Zdotaccent ENCODING 379 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 10 00 78 10 20 40 78 00 00 ENDCHAR STARTCHAR zdotaccent ENCODING 380 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 10 00 78 10 20 78 00 00 ENDCHAR STARTCHAR Zcaron ENCODING 381 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 28 10 78 10 20 40 78 00 00 ENDCHAR STARTCHAR zcaron ENCODING 382 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 28 10 00 78 10 20 78 00 00 ENDCHAR STARTCHAR longs ENCODING 383 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 10 28 60 20 20 20 00 00 ENDCHAR STARTCHAR uni018F ENCODING 399 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 30 48 08 78 48 30 00 00 ENDCHAR STARTCHAR florin ENCODING 402 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 10 28 20 70 20 20 20 40 ENDCHAR STARTCHAR Ohorn ENCODING 416 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 64 94 98 90 90 60 00 00 ENDCHAR STARTCHAR ohorn ENCODING 417 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 34 48 48 30 00 00 ENDCHAR STARTCHAR Uhorn ENCODING 431 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 54 54 58 50 50 20 00 00 ENDCHAR STARTCHAR uhorn ENCODING 432 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 54 58 50 30 00 00 ENDCHAR STARTCHAR uni01B5 ENCODING 437 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 78 08 78 20 40 78 00 00 ENDCHAR STARTCHAR uni01B6 ENCODING 438 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 78 78 20 78 00 00 ENDCHAR STARTCHAR uni01D1 ENCODING 465 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 28 10 30 48 48 48 30 00 00 ENDCHAR STARTCHAR uni01D2 ENCODING 466 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 28 10 00 30 48 48 30 00 00 ENDCHAR STARTCHAR Gcaron ENCODING 486 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 28 10 38 40 58 48 30 00 00 ENDCHAR STARTCHAR gcaron ENCODING 487 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 28 10 00 30 48 48 38 08 30 ENDCHAR STARTCHAR Aringacute ENCODING 506 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 10 20 50 20 50 70 50 00 00 ENDCHAR STARTCHAR aringacute ENCODING 507 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 08 10 28 38 48 48 38 00 00 ENDCHAR STARTCHAR AEacute ENCODING 508 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 10 20 78 A0 F0 A0 B8 00 00 ENDCHAR STARTCHAR aeacute ENCODING 509 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 10 20 00 70 A8 B0 78 00 00 ENDCHAR STARTCHAR Oslashacute ENCODING 510 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 08 10 38 58 68 68 70 00 00 ENDCHAR STARTCHAR oslashacute ENCODING 511 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 10 20 00 38 58 68 70 00 00 ENDCHAR STARTCHAR Scommaaccent ENCODING 536 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 30 48 20 10 48 30 10 20 ENDCHAR STARTCHAR scommaaccent ENCODING 537 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 38 60 18 70 10 20 ENDCHAR STARTCHAR Tcommaaccent ENCODING 538 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 F8 20 20 20 20 20 10 20 ENDCHAR STARTCHAR tcommaaccent ENCODING 539 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 20 20 70 20 28 10 10 20 ENDCHAR STARTCHAR uni0258 ENCODING 600 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 30 68 18 70 00 00 ENDCHAR STARTCHAR uni0259 ENCODING 601 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 70 18 68 30 00 00 ENDCHAR STARTCHAR uni02BB ENCODING 699 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 10 20 30 00 00 00 00 00 ENDCHAR STARTCHAR afii57929 ENCODING 700 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 30 10 20 00 00 00 00 00 ENDCHAR STARTCHAR afii64937 ENCODING 701 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 30 20 10 00 00 00 00 00 ENDCHAR STARTCHAR circumflex ENCODING 710 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 20 50 00 00 00 00 00 00 00 ENDCHAR STARTCHAR caron ENCODING 711 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 50 20 00 00 00 00 00 00 00 ENDCHAR STARTCHAR macron ENCODING 713 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 70 00 00 00 00 00 00 00 ENDCHAR STARTCHAR breve ENCODING 728 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 48 30 00 00 00 00 00 00 00 ENDCHAR STARTCHAR dotaccent ENCODING 729 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 20 00 00 00 00 00 00 00 ENDCHAR STARTCHAR ring ENCODING 730 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 20 50 20 00 00 00 00 00 00 ENDCHAR STARTCHAR ogonek ENCODING 731 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 00 00 00 00 20 10 ENDCHAR STARTCHAR tilde ENCODING 732 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 28 50 00 00 00 00 00 00 00 ENDCHAR STARTCHAR hungarumlaut ENCODING 733 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 48 90 00 00 00 00 00 00 00 ENDCHAR STARTCHAR gravecomb ENCODING 768 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 40 20 00 00 00 00 00 00 00 ENDCHAR STARTCHAR acutecomb ENCODING 769 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 10 20 00 00 00 00 00 00 00 ENDCHAR STARTCHAR uni0302 ENCODING 770 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 20 50 00 00 00 00 00 00 00 ENDCHAR STARTCHAR tildecomb ENCODING 771 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 28 50 00 00 00 00 00 00 00 ENDCHAR STARTCHAR uni0304 ENCODING 772 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 70 00 00 00 00 00 00 00 00 ENDCHAR STARTCHAR uni0305 ENCODING 773 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP F8 00 00 00 00 00 00 00 00 ENDCHAR STARTCHAR uni0306 ENCODING 774 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 88 70 00 00 00 00 00 00 00 ENDCHAR STARTCHAR uni0307 ENCODING 775 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 20 00 00 00 00 00 00 00 00 ENDCHAR STARTCHAR uni0308 ENCODING 776 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 50 00 00 00 00 00 00 00 00 ENDCHAR STARTCHAR hookabovecomb ENCODING 777 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 60 10 20 00 00 00 00 00 00 ENDCHAR STARTCHAR uni030A ENCODING 778 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 20 50 20 00 00 00 00 00 00 ENDCHAR STARTCHAR uni030B ENCODING 779 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 48 90 00 00 00 00 00 00 00 ENDCHAR STARTCHAR uni030C ENCODING 780 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 50 20 00 00 00 00 00 00 00 ENDCHAR STARTCHAR uni030D ENCODING 781 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 20 20 00 00 00 00 00 00 00 ENDCHAR STARTCHAR uni030E ENCODING 782 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 50 50 00 00 00 00 00 00 00 ENDCHAR STARTCHAR uni030F ENCODING 783 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 90 48 00 00 00 00 00 00 00 ENDCHAR STARTCHAR uni0310 ENCODING 784 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP A8 70 00 00 00 00 00 00 00 ENDCHAR STARTCHAR uni0311 ENCODING 785 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 70 88 00 00 00 00 00 00 00 ENDCHAR STARTCHAR uni0312 ENCODING 786 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 10 20 30 00 00 00 00 00 00 ENDCHAR STARTCHAR uni0313 ENCODING 787 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 30 10 20 00 00 00 00 00 00 ENDCHAR STARTCHAR uni0314 ENCODING 788 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 30 20 10 00 00 00 00 00 00 ENDCHAR STARTCHAR dotbelowcomb ENCODING 803 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 00 00 00 00 00 20 ENDCHAR STARTCHAR uni0324 ENCODING 804 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 00 00 00 00 00 50 ENDCHAR STARTCHAR uni0374 ENCODING 884 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 10 20 00 00 00 00 00 00 00 ENDCHAR STARTCHAR uni0375 ENCODING 885 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 00 00 00 00 10 20 ENDCHAR STARTCHAR uni037A ENCODING 890 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 00 00 00 00 20 30 ENDCHAR STARTCHAR uni037E ENCODING 894 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 30 30 00 30 10 10 20 ENDCHAR STARTCHAR tonos ENCODING 900 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 20 20 00 00 00 00 00 00 00 ENDCHAR STARTCHAR dieresistonos ENCODING 901 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 20 A8 00 00 00 00 00 00 00 ENDCHAR STARTCHAR Alphatonos ENCODING 902 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 80 B0 48 48 78 48 48 00 00 ENDCHAR STARTCHAR anoteleia ENCODING 903 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 00 20 00 00 00 00 ENDCHAR STARTCHAR Epsilontonos ENCODING 904 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 80 B8 20 30 20 20 38 00 00 ENDCHAR STARTCHAR Etatonos ENCODING 905 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 80 A8 28 38 28 28 28 00 00 ENDCHAR STARTCHAR Iotatonos ENCODING 906 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 80 B8 10 10 10 10 38 00 00 ENDCHAR STARTCHAR Omicrontonos ENCODING 908 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 80 B0 48 48 48 48 30 00 00 ENDCHAR STARTCHAR Upsilontonos ENCODING 910 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 80 A8 28 28 10 10 10 00 00 ENDCHAR STARTCHAR Omegatonos ENCODING 911 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 80 B0 48 48 48 30 78 00 00 ENDCHAR STARTCHAR iotadieresistonos ENCODING 912 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 20 A8 00 20 20 20 10 00 00 ENDCHAR STARTCHAR Alpha ENCODING 913 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 20 50 88 F8 88 88 00 00 ENDCHAR STARTCHAR Beta ENCODING 914 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 F0 88 F0 88 88 F0 00 00 ENDCHAR STARTCHAR Gamma ENCODING 915 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 78 40 40 40 40 40 00 00 ENDCHAR STARTCHAR Delta ENCODING 916 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 20 20 50 50 88 F8 00 00 ENDCHAR STARTCHAR Epsilon ENCODING 917 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 78 40 70 40 40 78 00 00 ENDCHAR STARTCHAR Zeta ENCODING 918 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 78 08 10 20 40 78 00 00 ENDCHAR STARTCHAR Eta ENCODING 919 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 48 48 78 48 48 48 00 00 ENDCHAR STARTCHAR Theta ENCODING 920 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 70 88 F8 88 88 70 00 00 ENDCHAR STARTCHAR Iota ENCODING 921 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 70 20 20 20 20 70 00 00 ENDCHAR STARTCHAR Kappa ENCODING 922 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 48 50 60 50 48 48 00 00 ENDCHAR STARTCHAR Lambda ENCODING 923 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 20 20 50 50 88 88 00 00 ENDCHAR STARTCHAR Mu ENCODING 924 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 88 D8 A8 A8 88 88 00 00 ENDCHAR STARTCHAR Nu ENCODING 925 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 48 68 58 48 48 48 00 00 ENDCHAR STARTCHAR Xi ENCODING 926 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 78 00 30 00 00 78 00 00 ENDCHAR STARTCHAR Omicron ENCODING 927 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 70 88 88 88 88 70 00 00 ENDCHAR STARTCHAR Pi ENCODING 928 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 78 48 48 48 48 48 00 00 ENDCHAR STARTCHAR Rho ENCODING 929 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 70 48 48 70 40 40 00 00 ENDCHAR STARTCHAR Sigma ENCODING 931 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 78 40 20 20 40 78 00 00 ENDCHAR STARTCHAR Tau ENCODING 932 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 F8 20 20 20 20 20 00 00 ENDCHAR STARTCHAR Upsilon ENCODING 933 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 88 88 50 20 20 20 00 00 ENDCHAR STARTCHAR Phi ENCODING 934 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 20 70 A8 A8 70 20 00 00 ENDCHAR STARTCHAR Chi ENCODING 935 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 88 50 20 20 50 88 00 00 ENDCHAR STARTCHAR Psi ENCODING 936 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 A8 A8 A8 70 20 20 00 00 ENDCHAR STARTCHAR Omega ENCODING 937 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 70 88 88 88 50 D8 00 00 ENDCHAR STARTCHAR Iotadieresis ENCODING 938 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 50 00 70 20 20 20 70 00 00 ENDCHAR STARTCHAR Upsilondieresis ENCODING 939 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 50 00 88 50 20 20 20 00 00 ENDCHAR STARTCHAR alphatonos ENCODING 940 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 08 10 00 38 48 48 38 00 00 ENDCHAR STARTCHAR epsilontonos ENCODING 941 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 08 10 00 30 58 60 38 00 00 ENDCHAR STARTCHAR etatonos ENCODING 942 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 10 20 00 B0 C8 88 88 08 08 ENDCHAR STARTCHAR iotatonos ENCODING 943 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 20 40 00 40 40 50 20 00 00 ENDCHAR STARTCHAR upsilondieresistonos ENCODING 944 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 20 A8 00 88 88 88 70 00 00 ENDCHAR STARTCHAR alpha ENCODING 945 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 38 48 48 38 00 00 ENDCHAR STARTCHAR beta ENCODING 946 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 30 48 70 48 48 70 40 40 ENDCHAR STARTCHAR gamma ENCODING 947 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 88 88 50 50 20 20 ENDCHAR STARTCHAR delta ENCODING 948 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 70 80 70 88 88 70 00 00 ENDCHAR STARTCHAR epsilon ENCODING 949 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 30 58 60 38 00 00 ENDCHAR STARTCHAR zeta ENCODING 950 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 F8 20 40 40 30 08 30 00 ENDCHAR STARTCHAR eta ENCODING 951 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 B0 C8 88 88 08 08 ENDCHAR STARTCHAR theta ENCODING 952 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 30 48 78 48 48 30 00 00 ENDCHAR STARTCHAR iota ENCODING 953 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 40 40 50 20 00 00 ENDCHAR STARTCHAR kappa ENCODING 954 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 48 50 60 58 00 00 ENDCHAR STARTCHAR lambda ENCODING 955 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 70 88 08 68 98 88 00 00 ENDCHAR STARTCHAR mu ENCODING 956 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 88 88 98 E8 80 80 ENDCHAR STARTCHAR nu ENCODING 957 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 88 88 50 20 00 00 ENDCHAR STARTCHAR xi ENCODING 958 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 F8 20 40 70 80 70 08 10 ENDCHAR STARTCHAR omicron ENCODING 959 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 30 48 48 30 00 00 ENDCHAR STARTCHAR pi ENCODING 960 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 F8 50 50 50 00 00 ENDCHAR STARTCHAR rho ENCODING 961 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 70 88 88 F0 80 80 ENDCHAR STARTCHAR sigma1 ENCODING 962 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 70 88 80 70 08 30 ENDCHAR STARTCHAR sigma ENCODING 963 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 78 90 88 70 00 00 ENDCHAR STARTCHAR tau ENCODING 964 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 78 20 28 10 00 00 ENDCHAR STARTCHAR upsilon ENCODING 965 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 88 88 88 70 00 00 ENDCHAR STARTCHAR phi ENCODING 966 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 90 A8 A8 70 20 20 ENDCHAR STARTCHAR chi ENCODING 967 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 88 50 20 50 88 88 ENDCHAR STARTCHAR psi ENCODING 968 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 A8 A8 A8 70 20 20 ENDCHAR STARTCHAR omega ENCODING 969 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 50 88 A8 50 00 00 ENDCHAR STARTCHAR iotadieresis ENCODING 970 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 50 00 20 20 28 10 00 00 ENDCHAR STARTCHAR upsilondieresis ENCODING 971 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 50 00 88 88 88 70 00 00 ENDCHAR STARTCHAR omicrontonos ENCODING 972 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 10 20 00 70 88 88 70 00 00 ENDCHAR STARTCHAR upsilontonos ENCODING 973 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 10 20 00 88 88 88 70 00 00 ENDCHAR STARTCHAR omegatonos ENCODING 974 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 10 20 00 50 88 A8 50 00 00 ENDCHAR STARTCHAR uni03D0 ENCODING 976 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 60 90 90 F0 88 70 00 00 ENDCHAR STARTCHAR theta1 ENCODING 977 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 20 50 38 D0 50 20 00 00 ENDCHAR STARTCHAR Upsilon1 ENCODING 978 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 90 A8 40 40 40 40 00 00 ENDCHAR STARTCHAR uni03D3 ENCODING 979 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 D0 28 60 A0 20 20 00 00 ENDCHAR STARTCHAR uni03D4 ENCODING 980 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP A0 00 90 A8 40 40 40 00 00 ENDCHAR STARTCHAR phi1 ENCODING 981 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 20 20 70 A8 A8 70 20 20 ENDCHAR STARTCHAR omega1 ENCODING 982 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 F8 88 A8 50 00 00 ENDCHAR STARTCHAR uni03D7 ENCODING 983 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 10 20 00 88 48 70 88 08 30 ENDCHAR STARTCHAR uni03DA ENCODING 986 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 30 48 80 80 80 70 08 10 ENDCHAR STARTCHAR uni03DB ENCODING 987 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 08 70 80 80 70 08 30 ENDCHAR STARTCHAR uni03DC ENCODING 988 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 F8 80 80 E0 80 80 00 00 ENDCHAR STARTCHAR uni03DD ENCODING 989 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 78 40 40 70 40 40 ENDCHAR STARTCHAR uni03DE ENCODING 990 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 80 88 98 A8 C8 08 00 00 ENDCHAR STARTCHAR uni03DF ENCODING 991 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 20 40 80 F8 08 10 20 20 ENDCHAR STARTCHAR uni03E0 ENCODING 992 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 20 50 50 98 A8 A8 00 00 ENDCHAR STARTCHAR uni03E1 ENCODING 993 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 E0 10 30 48 18 28 08 08 ENDCHAR STARTCHAR uni03E2 ENCODING 994 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 A8 A8 A8 A8 78 08 F0 00 ENDCHAR STARTCHAR uni03E3 ENCODING 995 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 A8 A8 78 08 F0 00 ENDCHAR STARTCHAR uni03E4 ENCODING 996 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 48 A8 88 78 08 08 00 00 ENDCHAR STARTCHAR uni03E5 ENCODING 997 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 28 48 38 08 00 00 ENDCHAR STARTCHAR uni03E6 ENCODING 998 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 80 80 B0 C8 88 08 F0 00 ENDCHAR STARTCHAR uni03E7 ENCODING 999 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 20 70 A8 48 08 F0 00 00 ENDCHAR STARTCHAR uni03E8 ENCODING 1000 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 70 88 08 70 80 78 00 00 ENDCHAR STARTCHAR uni03E9 ENCODING 1001 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 70 88 70 80 78 00 00 ENDCHAR STARTCHAR uni03EA ENCODING 1002 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 50 A8 20 50 88 F8 00 00 ENDCHAR STARTCHAR uni03EB ENCODING 1003 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 50 A8 20 50 70 00 00 ENDCHAR STARTCHAR uni03EC ENCODING 1004 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 08 70 80 F0 88 70 00 00 ENDCHAR STARTCHAR uni03ED ENCODING 1005 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 08 70 80 D8 70 00 00 ENDCHAR STARTCHAR uni03EE ENCODING 1006 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 70 20 F8 A8 20 70 00 00 ENDCHAR STARTCHAR uni03EF ENCODING 1007 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 20 30 20 F8 A0 20 60 20 ENDCHAR STARTCHAR uni03F0 ENCODING 1008 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 88 48 70 88 00 00 ENDCHAR STARTCHAR uni03F1 ENCODING 1009 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 70 88 88 F0 80 78 ENDCHAR STARTCHAR uni03F2 ENCODING 1010 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 70 88 80 78 00 00 ENDCHAR STARTCHAR uni03F3 ENCODING 1011 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 08 00 18 08 08 48 48 30 ENDCHAR STARTCHAR uni03F4 ENCODING 1012 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 70 88 F8 88 88 70 00 00 ENDCHAR STARTCHAR uni03F5 ENCODING 1013 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 38 70 40 38 00 00 ENDCHAR STARTCHAR uni0400 ENCODING 1024 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 20 10 78 40 70 40 78 00 00 ENDCHAR STARTCHAR afii10023 ENCODING 1025 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 28 00 78 40 70 40 78 00 00 ENDCHAR STARTCHAR afii10051 ENCODING 1026 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 F8 20 30 28 28 28 08 10 ENDCHAR STARTCHAR afii10052 ENCODING 1027 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 10 20 78 40 40 40 40 00 00 ENDCHAR STARTCHAR afii10053 ENCODING 1028 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 70 88 E0 80 88 70 00 00 ENDCHAR STARTCHAR afii10054 ENCODING 1029 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 30 48 20 10 48 30 00 00 ENDCHAR STARTCHAR afii10055 ENCODING 1030 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 70 20 20 20 20 70 00 00 ENDCHAR STARTCHAR afii10056 ENCODING 1031 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 50 00 70 20 20 20 70 00 00 ENDCHAR STARTCHAR afii10057 ENCODING 1032 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 38 10 10 10 90 60 00 00 ENDCHAR STARTCHAR afii10058 ENCODING 1033 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 60 A0 B0 A8 A8 B0 00 00 ENDCHAR STARTCHAR afii10059 ENCODING 1034 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 A0 A0 F0 A8 A8 B0 00 00 ENDCHAR STARTCHAR afii10060 ENCODING 1035 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 F8 20 30 28 28 28 00 00 ENDCHAR STARTCHAR afii10061 ENCODING 1036 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 08 10 48 50 60 50 48 00 00 ENDCHAR STARTCHAR uni040D ENCODING 1037 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 40 20 88 98 A8 C8 88 00 00 ENDCHAR STARTCHAR afii10062 ENCODING 1038 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 48 30 88 88 78 08 70 00 00 ENDCHAR STARTCHAR afii10145 ENCODING 1039 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 88 88 88 88 88 F8 20 20 ENDCHAR STARTCHAR afii10017 ENCODING 1040 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 20 50 88 F8 88 88 00 00 ENDCHAR STARTCHAR afii10018 ENCODING 1041 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 F0 80 F0 88 88 F0 00 00 ENDCHAR STARTCHAR afii10019 ENCODING 1042 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 F0 88 F0 88 88 F0 00 00 ENDCHAR STARTCHAR afii10020 ENCODING 1043 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 78 40 40 40 40 40 00 00 ENDCHAR STARTCHAR afii10021 ENCODING 1044 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 30 50 50 50 50 F8 88 00 ENDCHAR STARTCHAR afii10022 ENCODING 1045 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 78 40 70 40 40 78 00 00 ENDCHAR STARTCHAR afii10024 ENCODING 1046 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 A8 A8 70 A8 A8 A8 00 00 ENDCHAR STARTCHAR afii10025 ENCODING 1047 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 70 88 30 08 88 70 00 00 ENDCHAR STARTCHAR afii10026 ENCODING 1048 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 48 58 68 48 48 48 00 00 ENDCHAR STARTCHAR afii10027 ENCODING 1049 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 48 30 48 58 68 48 48 00 00 ENDCHAR STARTCHAR afii10028 ENCODING 1050 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 48 50 60 50 48 48 00 00 ENDCHAR STARTCHAR afii10029 ENCODING 1051 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 38 48 48 48 48 88 00 00 ENDCHAR STARTCHAR afii10030 ENCODING 1052 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 88 D8 A8 A8 88 88 00 00 ENDCHAR STARTCHAR afii10031 ENCODING 1053 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 48 48 78 48 48 48 00 00 ENDCHAR STARTCHAR afii10032 ENCODING 1054 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 70 88 88 88 88 70 00 00 ENDCHAR STARTCHAR afii10033 ENCODING 1055 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 F8 88 88 88 88 88 00 00 ENDCHAR STARTCHAR afii10034 ENCODING 1056 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 70 48 48 70 40 40 00 00 ENDCHAR STARTCHAR afii10035 ENCODING 1057 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 30 48 40 40 48 30 00 00 ENDCHAR STARTCHAR afii10036 ENCODING 1058 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 F8 20 20 20 20 20 00 00 ENDCHAR STARTCHAR afii10037 ENCODING 1059 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 88 88 88 78 08 70 00 00 ENDCHAR STARTCHAR afii10038 ENCODING 1060 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 20 70 A8 A8 70 20 00 00 ENDCHAR STARTCHAR afii10039 ENCODING 1061 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 88 50 20 20 50 88 00 00 ENDCHAR STARTCHAR afii10040 ENCODING 1062 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 90 90 90 90 90 F8 08 10 ENDCHAR STARTCHAR afii10041 ENCODING 1063 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 88 88 88 78 08 08 00 00 ENDCHAR STARTCHAR afii10042 ENCODING 1064 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 A8 A8 A8 A8 A8 F8 00 00 ENDCHAR STARTCHAR afii10043 ENCODING 1065 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 A8 A8 A8 A8 A8 F8 08 10 ENDCHAR STARTCHAR afii10044 ENCODING 1066 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 C0 40 70 48 48 70 00 00 ENDCHAR STARTCHAR afii10045 ENCODING 1067 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 88 88 E8 98 98 E8 00 00 ENDCHAR STARTCHAR afii10046 ENCODING 1068 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 40 40 70 48 48 70 00 00 ENDCHAR STARTCHAR afii10047 ENCODING 1069 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 70 88 38 08 88 70 00 00 ENDCHAR STARTCHAR afii10048 ENCODING 1070 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 90 A8 E8 E8 A8 90 00 00 ENDCHAR STARTCHAR afii10049 ENCODING 1071 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 38 48 48 38 48 48 00 00 ENDCHAR STARTCHAR afii10065 ENCODING 1072 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 70 90 90 78 00 00 ENDCHAR STARTCHAR afii10066 ENCODING 1073 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 08 30 40 70 48 48 30 00 00 ENDCHAR STARTCHAR afii10067 ENCODING 1074 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 60 50 68 70 00 00 ENDCHAR STARTCHAR afii10068 ENCODING 1075 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 78 40 40 40 00 00 ENDCHAR STARTCHAR afii10069 ENCODING 1076 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 30 50 50 F8 88 00 ENDCHAR STARTCHAR afii10070 ENCODING 1077 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 60 90 E0 70 00 00 ENDCHAR STARTCHAR afii10072 ENCODING 1078 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 A8 70 70 A8 00 00 ENDCHAR STARTCHAR afii10073 ENCODING 1079 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 30 28 18 70 00 00 ENDCHAR STARTCHAR afii10074 ENCODING 1080 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 88 98 A8 C8 00 00 ENDCHAR STARTCHAR afii10075 ENCODING 1081 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 88 70 00 88 98 A8 C8 00 00 ENDCHAR STARTCHAR afii10076 ENCODING 1082 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 48 50 70 48 00 00 ENDCHAR STARTCHAR afii10077 ENCODING 1083 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 38 48 48 88 00 00 ENDCHAR STARTCHAR afii10078 ENCODING 1084 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 88 D8 A8 88 00 00 ENDCHAR STARTCHAR afii10079 ENCODING 1085 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 88 F8 88 88 00 00 ENDCHAR STARTCHAR afii10080 ENCODING 1086 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 70 88 88 70 00 00 ENDCHAR STARTCHAR afii10081 ENCODING 1087 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 F8 88 88 88 00 00 ENDCHAR STARTCHAR afii10082 ENCODING 1088 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 F0 88 88 F0 80 80 ENDCHAR STARTCHAR afii10083 ENCODING 1089 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 70 88 80 78 00 00 ENDCHAR STARTCHAR afii10084 ENCODING 1090 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 F8 20 20 20 00 00 ENDCHAR STARTCHAR afii10085 ENCODING 1091 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 88 88 88 78 08 70 ENDCHAR STARTCHAR afii10086 ENCODING 1092 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 20 20 70 A8 A8 70 20 20 ENDCHAR STARTCHAR afii10087 ENCODING 1093 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 48 30 30 48 00 00 ENDCHAR STARTCHAR afii10088 ENCODING 1094 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 90 90 90 F8 08 10 ENDCHAR STARTCHAR afii10089 ENCODING 1095 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 88 88 78 08 00 00 ENDCHAR STARTCHAR afii10090 ENCODING 1096 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 A8 A8 A8 F8 00 00 ENDCHAR STARTCHAR afii10091 ENCODING 1097 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 A8 A8 A8 F8 08 10 ENDCHAR STARTCHAR afii10092 ENCODING 1098 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 C0 70 48 70 00 00 ENDCHAR STARTCHAR afii10093 ENCODING 1099 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 88 E8 98 E8 00 00 ENDCHAR STARTCHAR afii10094 ENCODING 1100 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 40 70 48 70 00 00 ENDCHAR STARTCHAR afii10095 ENCODING 1101 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 E0 50 30 E0 00 00 ENDCHAR STARTCHAR afii10096 ENCODING 1102 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 90 E8 E8 90 00 00 ENDCHAR STARTCHAR afii10097 ENCODING 1103 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 70 90 70 90 00 00 ENDCHAR STARTCHAR uni0450 ENCODING 1104 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 20 10 00 30 48 70 38 00 00 ENDCHAR STARTCHAR afii10071 ENCODING 1105 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 50 00 30 48 70 38 00 00 ENDCHAR STARTCHAR afii10099 ENCODING 1106 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 40 E0 40 70 48 48 08 10 ENDCHAR STARTCHAR afii10100 ENCODING 1107 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 10 20 00 78 40 40 40 00 00 ENDCHAR STARTCHAR afii10101 ENCODING 1108 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 38 50 60 38 00 00 ENDCHAR STARTCHAR afii10102 ENCODING 1109 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 38 60 18 70 00 00 ENDCHAR STARTCHAR afii10103 ENCODING 1110 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 20 00 60 20 20 70 00 00 ENDCHAR STARTCHAR afii10104 ENCODING 1111 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 50 00 60 20 20 70 00 00 ENDCHAR STARTCHAR afii10105 ENCODING 1112 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 08 00 18 08 08 08 48 30 ENDCHAR STARTCHAR afii10106 ENCODING 1113 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 60 B0 A8 B0 00 00 ENDCHAR STARTCHAR afii10107 ENCODING 1114 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 A0 F0 A8 B0 00 00 ENDCHAR STARTCHAR afii10108 ENCODING 1115 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 40 E0 40 70 48 48 00 00 ENDCHAR STARTCHAR afii10109 ENCODING 1116 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 10 20 00 48 50 70 48 00 00 ENDCHAR STARTCHAR uni045D ENCODING 1117 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 40 20 00 88 98 A8 C8 00 00 ENDCHAR STARTCHAR afii10110 ENCODING 1118 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 48 30 00 88 88 78 08 70 ENDCHAR STARTCHAR afii10193 ENCODING 1119 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 88 88 88 F8 20 20 ENDCHAR STARTCHAR afii10146 ENCODING 1122 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 40 E0 40 70 48 48 70 00 00 ENDCHAR STARTCHAR afii10194 ENCODING 1123 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 40 40 E0 70 48 70 00 00 ENDCHAR STARTCHAR uni0470 ENCODING 1136 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 A8 A8 A8 70 20 20 00 00 ENDCHAR STARTCHAR uni0471 ENCODING 1137 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 A8 A8 70 20 00 00 ENDCHAR STARTCHAR afii10147 ENCODING 1138 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 70 88 F8 88 88 70 00 00 ENDCHAR STARTCHAR afii10195 ENCODING 1139 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 70 A8 D8 70 00 00 ENDCHAR STARTCHAR afii10148 ENCODING 1140 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 40 48 58 70 20 20 00 00 ENDCHAR STARTCHAR afii10196 ENCODING 1141 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 40 58 30 20 00 00 ENDCHAR STARTCHAR afii10050 ENCODING 1168 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 08 78 40 40 40 40 40 00 00 ENDCHAR STARTCHAR afii10098 ENCODING 1169 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 08 78 40 40 40 00 00 ENDCHAR STARTCHAR uni0492 ENCODING 1170 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 78 40 F0 40 40 40 00 00 ENDCHAR STARTCHAR uni0493 ENCODING 1171 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 78 40 E0 40 00 00 ENDCHAR STARTCHAR uni0496 ENCODING 1174 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 A8 A8 70 A8 A8 AC 04 04 ENDCHAR STARTCHAR uni0497 ENCODING 1175 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 A8 70 70 A8 04 04 ENDCHAR STARTCHAR uni049A ENCODING 1178 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 48 50 60 50 48 48 04 04 ENDCHAR STARTCHAR uni049B ENCODING 1179 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 48 50 70 48 04 04 ENDCHAR STARTCHAR uni04AE ENCODING 1198 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 88 88 50 20 20 20 00 00 ENDCHAR STARTCHAR uni04AF ENCODING 1199 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 88 88 50 20 20 20 ENDCHAR STARTCHAR uni04B0 ENCODING 1200 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 88 88 50 F8 20 20 00 00 ENDCHAR STARTCHAR uni04B1 ENCODING 1201 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 88 88 50 F8 20 20 ENDCHAR STARTCHAR uni04B2 ENCODING 1202 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 88 50 20 20 50 88 04 04 ENDCHAR STARTCHAR uni04B3 ENCODING 1203 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 48 30 30 48 04 04 ENDCHAR STARTCHAR uni04BA ENCODING 1210 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 80 80 F0 88 88 88 00 00 ENDCHAR STARTCHAR uni04BB ENCODING 1211 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 40 40 70 48 48 48 00 00 ENDCHAR STARTCHAR uni04D8 ENCODING 1240 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 30 48 08 78 48 30 00 00 ENDCHAR STARTCHAR afii10846 ENCODING 1241 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 70 18 68 30 00 00 ENDCHAR STARTCHAR uni04E2 ENCODING 1250 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 70 00 70 20 20 20 70 00 00 ENDCHAR STARTCHAR uni04E3 ENCODING 1251 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 70 00 60 20 20 70 00 00 ENDCHAR STARTCHAR uni04E8 ENCODING 1256 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 70 88 F8 88 88 70 00 00 ENDCHAR STARTCHAR uni04E9 ENCODING 1257 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 30 78 48 30 00 00 ENDCHAR STARTCHAR uni04EE ENCODING 1262 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 78 00 48 48 48 48 30 00 00 ENDCHAR STARTCHAR uni04EF ENCODING 1263 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 78 00 48 48 48 38 00 00 ENDCHAR STARTCHAR afii57664 ENCODING 1488 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 90 48 B0 88 00 00 ENDCHAR STARTCHAR afii57665 ENCODING 1489 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 F0 10 10 F8 00 00 ENDCHAR STARTCHAR afii57666 ENCODING 1490 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 40 20 30 50 00 00 ENDCHAR STARTCHAR afii57667 ENCODING 1491 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 F8 10 10 10 00 00 ENDCHAR STARTCHAR afii57668 ENCODING 1492 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 F8 08 88 88 00 00 ENDCHAR STARTCHAR afii57669 ENCODING 1493 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 30 10 10 10 00 00 ENDCHAR STARTCHAR afii57670 ENCODING 1494 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 F8 20 10 10 00 00 ENDCHAR STARTCHAR afii57671 ENCODING 1495 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 F8 48 48 48 00 00 ENDCHAR STARTCHAR afii57672 ENCODING 1496 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 98 A8 88 F8 00 00 ENDCHAR STARTCHAR afii57673 ENCODING 1497 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 30 10 00 00 00 00 ENDCHAR STARTCHAR afii57674 ENCODING 1498 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 F8 08 08 08 08 08 ENDCHAR STARTCHAR afii57675 ENCODING 1499 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 F8 08 08 F0 00 00 ENDCHAR STARTCHAR afii57676 ENCODING 1500 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 80 80 F8 08 10 60 00 00 ENDCHAR STARTCHAR afii57677 ENCODING 1501 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 F8 48 48 78 00 00 ENDCHAR STARTCHAR afii57678 ENCODING 1502 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 90 A8 48 98 00 00 ENDCHAR STARTCHAR afii57679 ENCODING 1503 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 30 10 10 10 10 10 ENDCHAR STARTCHAR afii57680 ENCODING 1504 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 18 08 08 78 00 00 ENDCHAR STARTCHAR afii57681 ENCODING 1505 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 78 28 28 30 00 00 ENDCHAR STARTCHAR afii57682 ENCODING 1506 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 D8 48 50 E0 00 00 ENDCHAR STARTCHAR afii57683 ENCODING 1507 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 F8 48 48 08 08 08 ENDCHAR STARTCHAR afii57684 ENCODING 1508 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 F8 48 08 F0 00 00 ENDCHAR STARTCHAR afii57685 ENCODING 1509 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 90 48 50 60 40 40 ENDCHAR STARTCHAR afii57686 ENCODING 1510 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 90 48 30 F8 00 00 ENDCHAR STARTCHAR afii57687 ENCODING 1511 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 F8 08 88 B0 80 80 ENDCHAR STARTCHAR afii57688 ENCODING 1512 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 F0 08 08 08 00 00 ENDCHAR STARTCHAR afii57689 ENCODING 1513 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 A8 E8 88 F0 00 00 ENDCHAR STARTCHAR afii57690 ENCODING 1514 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 F8 48 48 C8 00 00 ENDCHAR STARTCHAR afii57716 ENCODING 1520 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 D8 48 48 48 00 00 ENDCHAR STARTCHAR afii57717 ENCODING 1521 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 D8 48 08 08 00 00 ENDCHAR STARTCHAR afii57718 ENCODING 1522 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 D8 48 00 00 00 00 ENDCHAR STARTCHAR uni05F3 ENCODING 1523 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 10 20 00 00 00 00 ENDCHAR STARTCHAR uni05F4 ENCODING 1524 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 48 90 00 00 00 00 ENDCHAR STARTCHAR uni1E02 ENCODING 7682 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 20 00 F0 88 F0 88 F0 00 00 ENDCHAR STARTCHAR uni1E03 ENCODING 7683 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 10 40 40 70 48 48 70 00 00 ENDCHAR STARTCHAR uni1E0A ENCODING 7690 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 20 00 70 48 48 48 70 00 00 ENDCHAR STARTCHAR uni1E0B ENCODING 7691 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 20 08 08 38 48 48 38 00 00 ENDCHAR STARTCHAR uni1E1E ENCODING 7710 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 20 00 78 40 70 40 40 00 00 ENDCHAR STARTCHAR uni1E1F ENCODING 7711 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 20 00 10 28 70 20 20 00 00 ENDCHAR STARTCHAR uni1E40 ENCODING 7744 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 20 88 D8 A8 A8 88 88 00 00 ENDCHAR STARTCHAR uni1E41 ENCODING 7745 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 20 00 D0 A8 A8 88 00 00 ENDCHAR STARTCHAR uni1E56 ENCODING 7766 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 20 00 70 48 70 40 40 00 00 ENDCHAR STARTCHAR uni1E57 ENCODING 7767 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 20 00 70 48 48 70 40 40 ENDCHAR STARTCHAR uni1E60 ENCODING 7776 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 10 00 38 40 30 08 70 00 00 ENDCHAR STARTCHAR uni1E61 ENCODING 7777 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 10 00 38 60 18 70 00 00 ENDCHAR STARTCHAR uni1E6A ENCODING 7786 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 20 00 F8 20 20 20 20 00 00 ENDCHAR STARTCHAR uni1E6B ENCODING 7787 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 20 00 20 70 20 28 10 00 00 ENDCHAR STARTCHAR Wgrave ENCODING 7808 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 40 20 88 88 A8 D8 88 00 00 ENDCHAR STARTCHAR wgrave ENCODING 7809 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 40 20 00 88 A8 A8 50 00 00 ENDCHAR STARTCHAR Wacute ENCODING 7810 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 10 20 88 88 A8 D8 88 00 00 ENDCHAR STARTCHAR wacute ENCODING 7811 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 10 20 00 88 A8 A8 50 00 00 ENDCHAR STARTCHAR Wdieresis ENCODING 7812 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 50 00 88 88 A8 D8 88 00 00 ENDCHAR STARTCHAR wdieresis ENCODING 7813 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 50 00 88 A8 A8 50 00 00 ENDCHAR STARTCHAR Ygrave ENCODING 7922 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 40 20 88 50 20 20 20 00 00 ENDCHAR STARTCHAR ygrave ENCODING 7923 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 20 10 00 48 48 48 38 48 30 ENDCHAR STARTCHAR uni2010 ENCODING 8208 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 00 78 00 00 00 00 ENDCHAR STARTCHAR uni2011 ENCODING 8209 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 00 78 00 00 00 00 ENDCHAR STARTCHAR figuredash ENCODING 8210 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 00 F8 00 00 00 00 ENDCHAR STARTCHAR endash ENCODING 8211 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 00 F8 00 00 00 00 ENDCHAR STARTCHAR emdash ENCODING 8212 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 00 FC 00 00 00 00 ENDCHAR STARTCHAR afii00208 ENCODING 8213 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 00 FC 00 00 00 00 ENDCHAR STARTCHAR uni2016 ENCODING 8214 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 50 50 50 50 50 50 00 00 ENDCHAR STARTCHAR underscoredbl ENCODING 8215 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 00 00 00 FC 00 FC ENDCHAR STARTCHAR quoteleft ENCODING 8216 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 10 20 30 00 00 00 00 00 ENDCHAR STARTCHAR quoteright ENCODING 8217 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 30 10 20 00 00 00 00 00 ENDCHAR STARTCHAR quotesinglbase ENCODING 8218 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 00 00 00 30 10 20 ENDCHAR STARTCHAR quotereversed ENCODING 8219 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 30 20 10 00 00 00 00 00 ENDCHAR STARTCHAR quotedblleft ENCODING 8220 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 48 90 D8 00 00 00 00 00 ENDCHAR STARTCHAR quotedblright ENCODING 8221 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 D8 48 90 00 00 00 00 00 ENDCHAR STARTCHAR quotedblbase ENCODING 8222 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 00 00 00 D8 48 90 ENDCHAR STARTCHAR uni201F ENCODING 8223 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 D8 90 48 00 00 00 00 00 ENDCHAR STARTCHAR dagger ENCODING 8224 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 20 20 F8 20 20 20 20 00 ENDCHAR STARTCHAR daggerdbl ENCODING 8225 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 20 20 F8 20 F8 20 20 00 ENDCHAR STARTCHAR bullet ENCODING 8226 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 30 78 78 30 00 00 00 ENDCHAR STARTCHAR uni2023 ENCODING 8227 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 40 60 70 60 40 00 00 ENDCHAR STARTCHAR onedotenleader ENCODING 8228 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 00 00 00 20 00 00 ENDCHAR STARTCHAR twodotenleader ENCODING 8229 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 00 00 00 50 00 00 ENDCHAR STARTCHAR ellipsis ENCODING 8230 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 00 00 00 A8 00 00 ENDCHAR STARTCHAR uni2027 ENCODING 8231 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 00 30 00 00 00 00 ENDCHAR STARTCHAR perthousand ENCODING 8240 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 40 A8 48 10 20 68 D4 28 00 ENDCHAR STARTCHAR minute ENCODING 8242 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 10 10 20 00 00 00 00 00 ENDCHAR STARTCHAR second ENCODING 8243 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 48 48 90 00 00 00 00 00 ENDCHAR STARTCHAR uni2034 ENCODING 8244 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 54 54 A8 00 00 00 00 00 ENDCHAR STARTCHAR uni2035 ENCODING 8245 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 20 20 10 00 00 00 00 00 ENDCHAR STARTCHAR uni2036 ENCODING 8246 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 90 90 48 00 00 00 00 00 ENDCHAR STARTCHAR uni2037 ENCODING 8247 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 A8 A8 54 00 00 00 00 00 ENDCHAR STARTCHAR guilsinglleft ENCODING 8249 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 10 20 40 20 10 00 00 ENDCHAR STARTCHAR guilsinglright ENCODING 8250 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 40 20 10 20 40 00 00 ENDCHAR STARTCHAR exclamdbl ENCODING 8252 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 50 50 50 50 00 50 00 00 ENDCHAR STARTCHAR uni203E ENCODING 8254 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 FC 00 00 00 00 00 00 00 ENDCHAR STARTCHAR fraction ENCODING 8260 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 08 08 10 20 40 40 00 00 ENDCHAR STARTCHAR zerosuperior ENCODING 8304 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 20 50 50 50 20 00 00 00 ENDCHAR STARTCHAR uni2071 ENCODING 8305 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 20 00 60 20 70 00 00 00 ENDCHAR STARTCHAR foursuperior ENCODING 8308 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 50 50 70 10 10 00 00 00 ENDCHAR STARTCHAR fivesuperior ENCODING 8309 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 70 40 60 10 60 00 00 00 ENDCHAR STARTCHAR sixsuperior ENCODING 8310 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 20 40 60 50 20 00 00 00 ENDCHAR STARTCHAR sevensuperior ENCODING 8311 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 70 10 20 20 20 00 00 00 ENDCHAR STARTCHAR eightsuperior ENCODING 8312 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 20 50 20 50 20 00 00 00 ENDCHAR STARTCHAR ninesuperior ENCODING 8313 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 20 50 30 10 20 00 00 00 ENDCHAR STARTCHAR uni207A ENCODING 8314 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 20 70 20 00 00 00 ENDCHAR STARTCHAR uni207B ENCODING 8315 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 00 70 00 00 00 00 ENDCHAR STARTCHAR uni207C ENCODING 8316 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 70 00 70 00 00 00 ENDCHAR STARTCHAR parenleftsuperior ENCODING 8317 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 20 40 40 40 20 00 00 00 ENDCHAR STARTCHAR parenrightsuperior ENCODING 8318 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 20 10 10 10 20 00 00 00 ENDCHAR STARTCHAR nsuperior ENCODING 8319 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 60 50 50 50 00 00 00 ENDCHAR STARTCHAR zeroinferior ENCODING 8320 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 00 20 50 50 50 20 ENDCHAR STARTCHAR oneinferior ENCODING 8321 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 00 20 60 20 20 70 ENDCHAR STARTCHAR twoinferior ENCODING 8322 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 00 20 50 10 20 70 ENDCHAR STARTCHAR threeinferior ENCODING 8323 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 00 60 10 20 10 60 ENDCHAR STARTCHAR fourinferior ENCODING 8324 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 00 50 50 70 10 10 ENDCHAR STARTCHAR fiveinferior ENCODING 8325 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 00 70 40 60 10 60 ENDCHAR STARTCHAR sixinferior ENCODING 8326 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 00 20 40 60 50 20 ENDCHAR STARTCHAR seveninferior ENCODING 8327 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 00 70 10 20 20 20 ENDCHAR STARTCHAR eightinferior ENCODING 8328 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 00 20 50 20 50 20 ENDCHAR STARTCHAR nineinferior ENCODING 8329 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 00 20 50 30 10 20 ENDCHAR STARTCHAR uni208A ENCODING 8330 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 00 00 00 20 70 20 ENDCHAR STARTCHAR uni208B ENCODING 8331 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 00 00 00 00 70 00 ENDCHAR STARTCHAR uni208C ENCODING 8332 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 00 00 00 70 00 70 ENDCHAR STARTCHAR parenleftinferior ENCODING 8333 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 00 20 40 40 40 20 ENDCHAR STARTCHAR parenrightinferior ENCODING 8334 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 00 20 10 10 10 20 ENDCHAR STARTCHAR franc ENCODING 8355 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 F8 80 E8 B0 A0 A0 00 00 ENDCHAR STARTCHAR lira ENCODING 8356 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 30 48 E0 40 E0 40 F8 00 ENDCHAR STARTCHAR peseta ENCODING 8359 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 60 50 F8 50 60 40 00 00 ENDCHAR STARTCHAR dong ENCODING 8363 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 08 1C 38 48 48 38 00 78 ENDCHAR STARTCHAR Euro ENCODING 8364 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 38 40 F0 F0 40 38 00 00 ENDCHAR STARTCHAR uni20AF ENCODING 8367 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 40 E0 50 48 48 E8 D0 00 00 ENDCHAR STARTCHAR uni20D0 ENCODING 8400 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 40 F8 00 00 00 00 00 00 00 ENDCHAR STARTCHAR uni20D1 ENCODING 8401 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 10 F8 00 00 00 00 00 00 00 ENDCHAR STARTCHAR uni20D2 ENCODING 8402 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 20 20 20 20 20 20 20 20 20 ENDCHAR STARTCHAR uni20D3 ENCODING 8403 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 20 20 20 20 20 20 00 ENDCHAR STARTCHAR uni20D4 ENCODING 8404 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP B0 C8 E0 00 00 00 00 00 00 ENDCHAR STARTCHAR uni20D5 ENCODING 8405 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 68 98 38 00 00 00 00 00 00 ENDCHAR STARTCHAR uni20D6 ENCODING 8406 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 40 F8 40 00 00 00 00 00 00 ENDCHAR STARTCHAR uni20D7 ENCODING 8407 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 10 F8 10 00 00 00 00 00 00 ENDCHAR STARTCHAR uni2102 ENCODING 8450 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 70 A8 A0 A0 A8 70 00 00 ENDCHAR STARTCHAR afii61248 ENCODING 8453 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 40 80 40 10 28 10 00 00 ENDCHAR STARTCHAR afii61289 ENCODING 8467 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 10 28 28 30 20 58 00 00 ENDCHAR STARTCHAR uni2115 ENCODING 8469 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 C8 E8 E8 D8 D8 C8 00 00 ENDCHAR STARTCHAR afii61352 ENCODING 8470 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 90 D0 D0 B8 B4 98 00 00 ENDCHAR STARTCHAR uni211A ENCODING 8474 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 70 A8 A8 A8 A8 70 18 00 ENDCHAR STARTCHAR uni211D ENCODING 8477 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 F0 A8 A8 B0 A8 A8 00 00 ENDCHAR STARTCHAR trademark ENCODING 8482 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 FC 5C 54 00 00 00 00 00 ENDCHAR STARTCHAR uni2124 ENCODING 8484 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 F8 28 50 50 A0 F8 00 00 ENDCHAR STARTCHAR Omega ENCODING 8486 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 70 88 88 88 50 D8 00 00 ENDCHAR STARTCHAR estimated ENCODING 8494 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 70 D8 F8 C0 70 00 00 ENDCHAR STARTCHAR oneeighth ENCODING 8539 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 40 C0 40 50 68 10 28 10 00 ENDCHAR STARTCHAR threeeighths ENCODING 8540 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP C0 20 40 30 E8 10 28 10 00 ENDCHAR STARTCHAR fiveeighths ENCODING 8541 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP E0 80 C0 30 E8 10 28 10 00 ENDCHAR STARTCHAR seveneighths ENCODING 8542 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP E0 20 40 50 68 10 28 10 00 ENDCHAR STARTCHAR arrowleft ENCODING 8592 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 20 40 F8 40 20 00 00 ENDCHAR STARTCHAR arrowup ENCODING 8593 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 20 70 A8 20 20 20 00 00 ENDCHAR STARTCHAR arrowright ENCODING 8594 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 20 10 F8 10 20 00 00 ENDCHAR STARTCHAR arrowdown ENCODING 8595 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 20 20 20 A8 70 20 00 00 ENDCHAR STARTCHAR arrowboth ENCODING 8596 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 48 FC 48 00 00 00 ENDCHAR STARTCHAR arrowupdn ENCODING 8597 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 20 70 A8 20 A8 70 20 00 ENDCHAR STARTCHAR uni21A4 ENCODING 8612 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 20 48 F8 48 20 00 00 ENDCHAR STARTCHAR uni21A5 ENCODING 8613 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 20 70 A8 20 20 70 00 00 ENDCHAR STARTCHAR uni21A6 ENCODING 8614 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 20 90 F8 90 20 00 00 ENDCHAR STARTCHAR uni21A7 ENCODING 8615 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 70 20 20 A8 70 20 00 00 ENDCHAR STARTCHAR arrowupdnbse ENCODING 8616 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 20 70 A8 20 A8 70 20 F8 00 ENDCHAR STARTCHAR arrowdblleft ENCODING 8656 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 20 78 80 78 20 00 00 ENDCHAR STARTCHAR arrowdblup ENCODING 8657 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 20 50 D8 50 50 50 00 00 ENDCHAR STARTCHAR arrowdblright ENCODING 8658 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 20 F0 08 F0 20 00 00 ENDCHAR STARTCHAR arrowdbldown ENCODING 8659 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 50 50 50 D8 70 20 00 00 ENDCHAR STARTCHAR arrowdblboth ENCODING 8660 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 30 78 84 78 30 00 00 ENDCHAR STARTCHAR uni21D5 ENCODING 8661 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 20 70 D8 50 D8 70 20 00 ENDCHAR STARTCHAR universal ENCODING 8704 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 88 88 F8 88 50 20 00 00 ENDCHAR STARTCHAR uni2201 ENCODING 8705 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 20 50 40 40 40 50 20 00 ENDCHAR STARTCHAR partialdiff ENCODING 8706 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 30 08 38 48 48 30 00 00 ENDCHAR STARTCHAR existential ENCODING 8707 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 78 08 38 08 08 78 00 00 ENDCHAR STARTCHAR uni2204 ENCODING 8708 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 20 78 28 38 28 28 78 20 00 ENDCHAR STARTCHAR emptyset ENCODING 8709 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 78 98 A8 A8 C8 F0 00 00 ENDCHAR STARTCHAR Delta ENCODING 8710 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 20 20 50 50 88 F8 00 00 ENDCHAR STARTCHAR gradient ENCODING 8711 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 F8 88 50 50 20 20 00 00 ENDCHAR STARTCHAR element ENCODING 8712 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 38 40 78 40 38 00 00 ENDCHAR STARTCHAR notelement ENCODING 8713 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 10 38 50 78 50 38 10 00 ENDCHAR STARTCHAR suchthat ENCODING 8715 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 70 08 78 08 70 00 00 ENDCHAR STARTCHAR uni220C ENCODING 8716 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 20 70 28 78 28 70 20 00 ENDCHAR STARTCHAR product ENCODING 8719 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP F8 50 50 50 50 50 50 50 00 ENDCHAR STARTCHAR uni2210 ENCODING 8720 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 50 50 50 50 50 50 50 F8 00 ENDCHAR STARTCHAR summation ENCODING 8721 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 F8 40 20 20 40 F8 00 00 ENDCHAR STARTCHAR minus ENCODING 8722 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 00 F8 00 00 00 00 ENDCHAR STARTCHAR uni2213 ENCODING 8723 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 F8 00 20 20 F8 20 20 00 ENDCHAR STARTCHAR fraction ENCODING 8725 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 08 08 10 20 40 40 00 00 ENDCHAR STARTCHAR uni2218 ENCODING 8728 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 20 50 20 00 00 00 ENDCHAR STARTCHAR periodcentered ENCODING 8729 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 20 70 20 00 00 00 ENDCHAR STARTCHAR radical ENCODING 8730 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 0C 08 08 08 10 D0 30 30 10 ENDCHAR STARTCHAR proportional ENCODING 8733 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 28 50 50 28 00 00 00 ENDCHAR STARTCHAR infinity ENCODING 8734 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 50 A8 A8 50 00 00 00 ENDCHAR STARTCHAR orthogonal ENCODING 8735 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 80 80 80 80 F8 00 00 ENDCHAR STARTCHAR uni2221 ENCODING 8737 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 50 20 50 90 F8 10 00 ENDCHAR STARTCHAR uni2224 ENCODING 8740 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 20 20 30 60 20 20 00 00 ENDCHAR STARTCHAR uni2225 ENCODING 8741 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 50 50 50 50 50 50 00 00 ENDCHAR STARTCHAR uni2226 ENCODING 8742 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 50 58 70 D0 50 50 00 00 ENDCHAR STARTCHAR logicaland ENCODING 8743 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 20 50 50 88 00 00 ENDCHAR STARTCHAR logicalor ENCODING 8744 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 88 50 50 20 00 00 ENDCHAR STARTCHAR intersection ENCODING 8745 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 70 88 88 88 00 00 ENDCHAR STARTCHAR union ENCODING 8746 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 88 88 88 70 00 00 ENDCHAR STARTCHAR integral ENCODING 8747 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 10 28 20 20 20 20 20 A0 40 ENDCHAR STARTCHAR uni222E ENCODING 8750 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 10 28 20 70 A8 70 20 A0 40 ENDCHAR STARTCHAR therefore ENCODING 8756 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 20 00 00 88 00 00 00 ENDCHAR STARTCHAR uni2235 ENCODING 8757 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 88 00 00 20 00 00 00 ENDCHAR STARTCHAR uni2236 ENCODING 8758 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 20 00 00 20 00 00 00 ENDCHAR STARTCHAR uni2237 ENCODING 8759 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 48 00 00 48 00 00 00 ENDCHAR STARTCHAR uni2238 ENCODING 8760 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 20 00 F8 00 00 00 00 ENDCHAR STARTCHAR uni2239 ENCODING 8761 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 08 00 E0 00 08 00 00 ENDCHAR STARTCHAR uni223A ENCODING 8762 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 88 00 F8 00 88 00 00 ENDCHAR STARTCHAR uni223B ENCODING 8763 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 10 00 28 50 00 20 00 ENDCHAR STARTCHAR similar ENCODING 8764 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 00 28 50 00 00 00 ENDCHAR STARTCHAR uni223D ENCODING 8765 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 00 50 28 00 00 00 ENDCHAR STARTCHAR uni2243 ENCODING 8771 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 28 50 00 78 00 00 ENDCHAR STARTCHAR congruent ENCODING 8773 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 28 50 00 78 00 78 00 ENDCHAR STARTCHAR approxequal ENCODING 8776 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 40 A8 50 A8 10 00 00 ENDCHAR STARTCHAR uni2249 ENCODING 8777 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 10 50 A8 70 A8 50 40 00 ENDCHAR STARTCHAR uni2259 ENCODING 8793 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 20 50 00 F8 00 F8 00 00 00 ENDCHAR STARTCHAR uni225F ENCODING 8799 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 60 10 20 00 20 00 F8 00 F8 ENDCHAR STARTCHAR notequal ENCODING 8800 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 10 F8 20 F8 40 00 00 ENDCHAR STARTCHAR equivalence ENCODING 8801 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 F8 00 F8 00 F8 00 00 ENDCHAR STARTCHAR uni2262 ENCODING 8802 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 10 F8 20 F8 20 F8 40 00 ENDCHAR STARTCHAR uni2263 ENCODING 8803 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 F8 00 F8 00 F8 00 F8 00 ENDCHAR STARTCHAR lessequal ENCODING 8804 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 18 60 80 60 98 60 18 00 ENDCHAR STARTCHAR greaterequal ENCODING 8805 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 C0 30 08 30 C8 30 C0 00 ENDCHAR STARTCHAR uni226A ENCODING 8810 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 28 50 A0 50 28 00 00 ENDCHAR STARTCHAR uni226B ENCODING 8811 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 A0 50 28 50 A0 00 00 ENDCHAR STARTCHAR propersubset ENCODING 8834 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 38 40 40 38 00 00 00 ENDCHAR STARTCHAR propersuperset ENCODING 8835 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 70 08 08 70 00 00 00 ENDCHAR STARTCHAR notsubset ENCODING 8836 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 10 38 50 50 38 10 00 00 ENDCHAR STARTCHAR uni2285 ENCODING 8837 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 20 70 28 28 70 20 00 00 ENDCHAR STARTCHAR reflexsubset ENCODING 8838 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 38 40 40 38 00 78 00 00 ENDCHAR STARTCHAR reflexsuperset ENCODING 8839 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 70 08 08 70 00 78 00 00 ENDCHAR STARTCHAR uni2288 ENCODING 8840 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 10 38 50 50 38 10 78 10 00 ENDCHAR STARTCHAR uni2289 ENCODING 8841 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 20 70 28 28 70 20 78 20 00 ENDCHAR STARTCHAR uni228A ENCODING 8842 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 38 40 40 38 10 78 20 00 ENDCHAR STARTCHAR uni228B ENCODING 8843 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 70 08 08 70 10 78 20 00 ENDCHAR STARTCHAR circleplus ENCODING 8853 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 70 A8 F8 A8 70 00 00 ENDCHAR STARTCHAR uni2296 ENCODING 8854 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 70 88 F8 88 70 00 00 ENDCHAR STARTCHAR circlemultiply ENCODING 8855 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 70 D8 A8 D8 70 00 00 ENDCHAR STARTCHAR uni2298 ENCODING 8856 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 70 98 A8 C8 70 00 00 ENDCHAR STARTCHAR uni2299 ENCODING 8857 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 70 88 A8 88 70 00 00 ENDCHAR STARTCHAR uni22A2 ENCODING 8866 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 80 80 F8 80 80 00 00 ENDCHAR STARTCHAR uni22A3 ENCODING 8867 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 08 08 F8 08 08 00 00 ENDCHAR STARTCHAR uni22A4 ENCODING 8868 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 F8 20 20 20 20 20 00 00 ENDCHAR STARTCHAR perpendicular ENCODING 8869 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 20 20 20 20 20 F8 00 00 ENDCHAR STARTCHAR uni22A6 ENCODING 8870 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 40 40 70 40 40 00 00 ENDCHAR STARTCHAR uni22A7 ENCODING 8871 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 40 70 40 70 40 00 00 ENDCHAR STARTCHAR uni22A8 ENCODING 8872 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 80 F8 80 F8 80 00 00 ENDCHAR STARTCHAR uni22C0 ENCODING 8896 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 20 20 50 50 50 88 88 88 00 ENDCHAR STARTCHAR uni22C1 ENCODING 8897 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 88 88 88 50 50 50 20 20 00 ENDCHAR STARTCHAR uni22C2 ENCODING 8898 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 70 88 88 88 88 88 88 88 00 ENDCHAR STARTCHAR uni22C3 ENCODING 8899 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 88 88 88 88 88 88 88 70 00 ENDCHAR STARTCHAR dotmath ENCODING 8901 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 00 20 00 00 00 00 ENDCHAR STARTCHAR uni22EE ENCODING 8942 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 20 00 00 20 00 00 20 00 ENDCHAR STARTCHAR uni22EF ENCODING 8943 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 00 A8 00 00 00 00 ENDCHAR STARTCHAR uni22F0 ENCODING 8944 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 08 00 00 20 00 00 80 00 ENDCHAR STARTCHAR uni22F1 ENCODING 8945 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 80 00 00 20 00 00 08 00 ENDCHAR STARTCHAR uni2300 ENCODING 8960 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 78 98 A8 C8 F0 00 00 ENDCHAR STARTCHAR house ENCODING 8962 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 20 50 88 88 88 F8 00 00 ENDCHAR STARTCHAR uni2308 ENCODING 8968 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 70 40 40 40 40 40 00 00 ENDCHAR STARTCHAR uni2309 ENCODING 8969 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 70 10 10 10 10 10 00 00 ENDCHAR STARTCHAR uni230A ENCODING 8970 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 40 40 40 40 40 70 00 00 ENDCHAR STARTCHAR uni230B ENCODING 8971 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 10 10 10 10 10 70 00 00 ENDCHAR STARTCHAR revlogicalnot ENCODING 8976 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 00 78 40 40 00 00 ENDCHAR STARTCHAR integraltp ENCODING 8992 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 08 14 10 10 10 10 10 10 ENDCHAR STARTCHAR integralbt ENCODING 8993 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 10 10 10 10 10 10 50 20 00 ENDCHAR STARTCHAR uni23BA ENCODING 9146 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP FC 00 00 00 00 00 00 00 00 ENDCHAR STARTCHAR uni23BB ENCODING 9147 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 FC 00 00 00 00 00 00 ENDCHAR STARTCHAR uni23BC ENCODING 9148 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 00 00 00 FC 00 00 ENDCHAR STARTCHAR uni23BD ENCODING 9149 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 00 00 00 00 00 FC ENDCHAR STARTCHAR uni2409 ENCODING 9225 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 A0 E0 A0 00 38 10 10 00 ENDCHAR STARTCHAR uni240A ENCODING 9226 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 80 80 80 C0 38 20 30 20 ENDCHAR STARTCHAR uni240B ENCODING 9227 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 A0 A0 40 40 38 10 10 10 ENDCHAR STARTCHAR uni240C ENCODING 9228 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 E0 80 C0 80 38 20 30 20 ENDCHAR STARTCHAR uni240D ENCODING 9229 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 60 80 60 00 30 28 30 28 ENDCHAR STARTCHAR uni2424 ENCODING 9252 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 90 D0 B0 90 20 20 20 38 ENDCHAR STARTCHAR SF100000 ENCODING 9472 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 00 FC 00 00 00 00 ENDCHAR STARTCHAR uni2501 ENCODING 9473 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 FC FC 00 00 00 00 ENDCHAR STARTCHAR SF110000 ENCODING 9474 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 10 10 10 10 10 10 10 10 10 ENDCHAR STARTCHAR uni2503 ENCODING 9475 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 30 30 30 30 30 30 30 30 30 ENDCHAR STARTCHAR SF010000 ENCODING 9484 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 00 1C 10 10 10 10 ENDCHAR STARTCHAR SF030000 ENCODING 9488 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 00 F0 10 10 10 10 ENDCHAR STARTCHAR SF020000 ENCODING 9492 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 10 10 10 10 1C 00 00 00 00 ENDCHAR STARTCHAR SF040000 ENCODING 9496 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 10 10 10 10 F0 00 00 00 00 ENDCHAR STARTCHAR SF080000 ENCODING 9500 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 10 10 10 10 1C 10 10 10 10 ENDCHAR STARTCHAR SF090000 ENCODING 9508 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 10 10 10 10 F0 10 10 10 10 ENDCHAR STARTCHAR SF060000 ENCODING 9516 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 00 FC 10 10 10 10 ENDCHAR STARTCHAR SF070000 ENCODING 9524 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 10 10 10 10 FC 00 00 00 00 ENDCHAR STARTCHAR SF050000 ENCODING 9532 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 10 10 10 10 FC 10 10 10 10 ENDCHAR STARTCHAR uni254C ENCODING 9548 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 00 D8 00 00 00 00 ENDCHAR STARTCHAR uni254D ENCODING 9549 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 D8 D8 00 00 00 00 ENDCHAR STARTCHAR uni254E ENCODING 9550 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 10 10 10 10 00 10 10 10 00 ENDCHAR STARTCHAR uni254F ENCODING 9551 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 30 30 30 30 00 30 30 30 00 ENDCHAR STARTCHAR SF430000 ENCODING 9552 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 FC 00 FC 00 00 00 ENDCHAR STARTCHAR SF240000 ENCODING 9553 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 28 28 28 28 28 28 28 28 28 ENDCHAR STARTCHAR SF510000 ENCODING 9554 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 1C 10 1C 10 10 10 ENDCHAR STARTCHAR SF520000 ENCODING 9555 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 00 3C 28 28 28 28 ENDCHAR STARTCHAR SF390000 ENCODING 9556 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 3C 20 2C 28 28 28 ENDCHAR STARTCHAR SF220000 ENCODING 9557 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 F0 10 F0 10 10 10 ENDCHAR STARTCHAR SF210000 ENCODING 9558 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 00 F8 28 28 28 28 ENDCHAR STARTCHAR SF250000 ENCODING 9559 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 F8 08 E8 28 28 28 ENDCHAR STARTCHAR SF500000 ENCODING 9560 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 10 10 10 1C 10 1C 00 00 00 ENDCHAR STARTCHAR SF490000 ENCODING 9561 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 28 28 28 28 3C 00 00 00 00 ENDCHAR STARTCHAR SF380000 ENCODING 9562 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 28 28 28 2C 20 3C 00 00 00 ENDCHAR STARTCHAR SF280000 ENCODING 9563 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 10 10 10 F0 10 F0 00 00 00 ENDCHAR STARTCHAR SF270000 ENCODING 9564 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 28 28 28 28 F8 00 00 00 00 ENDCHAR STARTCHAR SF260000 ENCODING 9565 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 28 28 28 E8 08 F8 00 00 00 ENDCHAR STARTCHAR SF360000 ENCODING 9566 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 10 10 10 1C 10 1C 10 10 10 ENDCHAR STARTCHAR SF370000 ENCODING 9567 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 28 28 28 28 2C 28 28 28 28 ENDCHAR STARTCHAR SF420000 ENCODING 9568 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 28 28 28 2C 20 2C 28 28 28 ENDCHAR STARTCHAR SF190000 ENCODING 9569 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 10 10 10 F0 10 F0 10 10 10 ENDCHAR STARTCHAR SF200000 ENCODING 9570 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 28 28 28 28 E8 28 28 28 28 ENDCHAR STARTCHAR SF230000 ENCODING 9571 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 28 28 28 E8 08 E8 28 28 28 ENDCHAR STARTCHAR SF470000 ENCODING 9572 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 FC 00 FC 10 10 10 ENDCHAR STARTCHAR SF480000 ENCODING 9573 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 00 FC 28 28 28 28 ENDCHAR STARTCHAR SF410000 ENCODING 9574 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 FC 00 EC 28 28 28 ENDCHAR STARTCHAR SF450000 ENCODING 9575 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 10 10 10 FC 00 FC 00 00 00 ENDCHAR STARTCHAR SF460000 ENCODING 9576 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 28 28 28 28 FC 00 00 00 00 ENDCHAR STARTCHAR SF400000 ENCODING 9577 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 28 28 28 EC 00 FC 00 00 00 ENDCHAR STARTCHAR SF540000 ENCODING 9578 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 10 10 10 FC 10 FC 10 10 10 ENDCHAR STARTCHAR SF530000 ENCODING 9579 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 28 28 28 28 FC 28 28 28 28 ENDCHAR STARTCHAR SF440000 ENCODING 9580 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 28 28 28 EC 00 EC 28 28 28 ENDCHAR STARTCHAR uni256D ENCODING 9581 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 00 04 08 10 10 10 ENDCHAR STARTCHAR uni256E ENCODING 9582 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 00 C0 20 10 10 10 ENDCHAR STARTCHAR uni256F ENCODING 9583 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 10 10 10 20 C0 00 00 00 00 ENDCHAR STARTCHAR uni2570 ENCODING 9584 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 10 10 10 08 04 00 00 00 00 ENDCHAR STARTCHAR uni2571 ENCODING 9585 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 04 04 08 10 10 20 40 40 80 ENDCHAR STARTCHAR uni2572 ENCODING 9586 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 80 80 40 20 20 10 08 08 04 ENDCHAR STARTCHAR uni2573 ENCODING 9587 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 84 84 48 30 30 30 48 48 84 ENDCHAR STARTCHAR upblock ENCODING 9600 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP FC FC FC FC 00 00 00 00 00 ENDCHAR STARTCHAR uni2581 ENCODING 9601 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 00 00 00 00 00 FC ENDCHAR STARTCHAR uni2582 ENCODING 9602 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 00 00 00 00 FC FC ENDCHAR STARTCHAR uni2583 ENCODING 9603 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 00 00 FC FC FC FC ENDCHAR STARTCHAR dnblock ENCODING 9604 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 00 FC FC FC FC FC ENDCHAR STARTCHAR uni2585 ENCODING 9605 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 FC FC FC FC FC FC ENDCHAR STARTCHAR uni2586 ENCODING 9606 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 FC FC FC FC FC FC FC ENDCHAR STARTCHAR uni2587 ENCODING 9607 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 FC FC FC FC FC FC FC FC ENDCHAR STARTCHAR block ENCODING 9608 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP FC FC FC FC FC FC FC FC FC ENDCHAR STARTCHAR uni2589 ENCODING 9609 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP F8 F8 F8 F8 F8 F8 F8 F8 F8 ENDCHAR STARTCHAR uni258A ENCODING 9610 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP F0 F0 F0 F0 F0 F0 F0 F0 F0 ENDCHAR STARTCHAR uni258B ENCODING 9611 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP F0 F0 F0 F0 F0 F0 F0 F0 F0 ENDCHAR STARTCHAR lfblock ENCODING 9612 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP E0 E0 E0 E0 E0 E0 E0 E0 E0 ENDCHAR STARTCHAR uni258D ENCODING 9613 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP C0 C0 C0 C0 C0 C0 C0 C0 C0 ENDCHAR STARTCHAR uni258E ENCODING 9614 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP C0 C0 C0 C0 C0 C0 C0 C0 C0 ENDCHAR STARTCHAR uni258F ENCODING 9615 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 80 80 80 80 80 80 80 80 80 ENDCHAR STARTCHAR rtblock ENCODING 9616 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 1C 1C 1C 1C 1C 1C 1C 1C 1C ENDCHAR STARTCHAR ltshade ENCODING 9617 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP A8 00 54 00 A8 00 54 00 A8 ENDCHAR STARTCHAR shade ENCODING 9618 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 54 A8 54 A8 54 A8 54 A8 54 ENDCHAR STARTCHAR dkshade ENCODING 9619 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP FC A8 FC 54 FC A8 FC 54 FC ENDCHAR STARTCHAR uni2594 ENCODING 9620 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP FC 00 00 00 00 00 00 00 00 ENDCHAR STARTCHAR uni2595 ENCODING 9621 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 04 04 04 04 04 04 04 04 04 ENDCHAR STARTCHAR uni2596 ENCODING 9622 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 00 E0 E0 E0 E0 E0 ENDCHAR STARTCHAR uni2597 ENCODING 9623 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 00 1C 1C 1C 1C 1C ENDCHAR STARTCHAR uni2598 ENCODING 9624 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP E0 E0 E0 E0 00 00 00 00 00 ENDCHAR STARTCHAR uni2599 ENCODING 9625 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP E0 E0 E0 E0 FC FC FC FC FC ENDCHAR STARTCHAR uni259A ENCODING 9626 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP E0 E0 E0 E0 1C 1C 1C 1C 1C ENDCHAR STARTCHAR uni259B ENCODING 9627 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP FC FC FC FC E0 E0 E0 E0 E0 ENDCHAR STARTCHAR uni259C ENCODING 9628 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP FC FC FC FC 1C 1C 1C 1C 1C ENDCHAR STARTCHAR uni259D ENCODING 9629 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 1C 1C 1C 1C 00 00 00 00 00 ENDCHAR STARTCHAR uni259E ENCODING 9630 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 1C 1C 1C 1C E0 E0 E0 E0 E0 ENDCHAR STARTCHAR uni259F ENCODING 9631 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 1C 1C 1C 1C FC FC FC FC FC ENDCHAR STARTCHAR filledbox ENCODING 9632 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 F8 F8 F8 F8 F8 00 00 ENDCHAR STARTCHAR H22073 ENCODING 9633 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 F8 88 88 88 F8 00 00 ENDCHAR STARTCHAR uni25A2 ENCODING 9634 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 70 88 88 88 70 00 00 ENDCHAR STARTCHAR uni25A3 ENCODING 9635 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 F8 88 A8 88 F8 00 00 ENDCHAR STARTCHAR H18543 ENCODING 9642 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 70 70 70 00 00 00 ENDCHAR STARTCHAR H18551 ENCODING 9643 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 70 50 70 00 00 00 ENDCHAR STARTCHAR filledrect ENCODING 9644 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 F8 F8 F8 00 00 00 ENDCHAR STARTCHAR uni25AD ENCODING 9645 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 F8 88 F8 00 00 00 ENDCHAR STARTCHAR uni25AE ENCODING 9646 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 78 78 78 78 78 78 00 00 ENDCHAR STARTCHAR uni25AF ENCODING 9647 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 78 48 48 48 48 78 00 00 ENDCHAR STARTCHAR uni25B0 ENCODING 9648 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 78 F8 F0 00 00 00 ENDCHAR STARTCHAR uni25B1 ENCODING 9649 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 78 88 F0 00 00 00 ENDCHAR STARTCHAR triagup ENCODING 9650 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 20 20 70 70 F8 F8 00 00 ENDCHAR STARTCHAR uni25B3 ENCODING 9651 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 20 20 50 50 88 F8 00 00 ENDCHAR STARTCHAR uni25B4 ENCODING 9652 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 20 20 70 70 00 00 00 ENDCHAR STARTCHAR uni25B5 ENCODING 9653 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 20 20 50 70 00 00 00 ENDCHAR STARTCHAR uni25B6 ENCODING 9654 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 C0 F0 F8 F0 C0 00 00 ENDCHAR STARTCHAR uni25B7 ENCODING 9655 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 C0 B0 88 B0 C0 00 00 ENDCHAR STARTCHAR uni25B8 ENCODING 9656 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 60 78 60 00 00 00 ENDCHAR STARTCHAR uni25B9 ENCODING 9657 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 60 58 60 00 00 00 ENDCHAR STARTCHAR triagrt ENCODING 9658 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 E0 F8 E0 00 00 00 ENDCHAR STARTCHAR uni25BB ENCODING 9659 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 E0 98 E0 00 00 00 ENDCHAR STARTCHAR triagdn ENCODING 9660 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 F8 F8 70 70 20 20 00 00 ENDCHAR STARTCHAR uni25BD ENCODING 9661 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 F8 88 50 50 20 20 00 00 ENDCHAR STARTCHAR uni25BE ENCODING 9662 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 70 70 20 20 00 00 00 ENDCHAR STARTCHAR uni25BF ENCODING 9663 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 70 50 20 20 00 00 00 ENDCHAR STARTCHAR uni25C0 ENCODING 9664 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 18 78 F8 78 18 00 00 ENDCHAR STARTCHAR uni25C1 ENCODING 9665 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 18 68 88 68 18 00 00 ENDCHAR STARTCHAR uni25C2 ENCODING 9666 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 18 78 18 00 00 00 ENDCHAR STARTCHAR uni25C3 ENCODING 9667 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 18 68 18 00 00 00 ENDCHAR STARTCHAR triaglf ENCODING 9668 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 38 F8 38 00 00 00 ENDCHAR STARTCHAR uni25C5 ENCODING 9669 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 38 C8 38 00 00 00 ENDCHAR STARTCHAR uni25C6 ENCODING 9670 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 30 78 FC 78 30 00 00 ENDCHAR STARTCHAR lozenge ENCODING 9674 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 20 50 50 88 50 50 20 00 ENDCHAR STARTCHAR circle ENCODING 9675 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 70 88 88 88 70 00 00 ENDCHAR STARTCHAR H18533 ENCODING 9679 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 70 F8 F8 F8 70 00 00 ENDCHAR STARTCHAR invbullet ENCODING 9688 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP FC FC CC 84 84 CC FC FC FC ENDCHAR STARTCHAR invcircle ENCODING 9689 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP FC FC CC B4 B4 CC FC FC FC ENDCHAR STARTCHAR openbullet ENCODING 9702 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 30 48 48 30 00 00 00 ENDCHAR STARTCHAR uni2600 ENCODING 9728 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 20 A8 70 F8 70 A8 20 00 ENDCHAR STARTCHAR uni2639 ENCODING 9785 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 78 84 CC 84 B4 CC 84 78 00 ENDCHAR STARTCHAR smileface ENCODING 9786 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 78 84 CC 84 CC B4 84 78 00 ENDCHAR STARTCHAR invsmileface ENCODING 9787 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 78 FC B4 FC B4 CC FC 78 00 ENDCHAR STARTCHAR sun ENCODING 9788 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 20 A8 70 D8 70 A8 20 00 ENDCHAR STARTCHAR uni263F ENCODING 9791 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 88 70 88 88 70 20 F8 20 00 ENDCHAR STARTCHAR female ENCODING 9792 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 70 88 88 70 20 F8 20 00 ENDCHAR STARTCHAR uni2641 ENCODING 9793 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 20 F8 20 70 88 88 70 00 ENDCHAR STARTCHAR male ENCODING 9794 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 1C 0C 14 70 88 88 70 00 ENDCHAR STARTCHAR spade ENCODING 9824 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 20 70 F8 F8 20 70 00 00 ENDCHAR STARTCHAR uni2661 ENCODING 9825 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 50 A8 88 88 50 20 00 00 ENDCHAR STARTCHAR uni2662 ENCODING 9826 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 20 50 88 50 20 00 00 ENDCHAR STARTCHAR club ENCODING 9827 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 20 70 A8 F8 A8 20 70 00 00 ENDCHAR STARTCHAR uni2664 ENCODING 9828 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 20 50 88 F8 20 70 00 00 ENDCHAR STARTCHAR heart ENCODING 9829 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 50 F8 F8 F8 70 20 00 00 ENDCHAR STARTCHAR diamond ENCODING 9830 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 20 70 F8 70 20 00 00 ENDCHAR STARTCHAR uni2669 ENCODING 9833 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 10 10 10 10 70 60 00 00 ENDCHAR STARTCHAR musicalnote ENCODING 9834 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 30 28 20 20 E0 C0 00 00 ENDCHAR STARTCHAR musicalnotedbl ENCODING 9835 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 60 58 48 C8 D8 18 00 00 ENDCHAR STARTCHAR uni27E8 ENCODING 10216 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 10 10 20 20 20 10 10 00 ENDCHAR STARTCHAR uni27E9 ENCODING 10217 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 20 20 10 10 10 20 20 00 ENDCHAR STARTCHAR uni2800 ENCODING 10240 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 00 00 00 00 00 00 ENDCHAR STARTCHAR uni2801 ENCODING 10241 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 40 00 00 00 00 00 00 00 ENDCHAR STARTCHAR uni2802 ENCODING 10242 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 40 00 00 00 00 00 ENDCHAR STARTCHAR uni2803 ENCODING 10243 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 40 00 40 00 00 00 00 00 ENDCHAR STARTCHAR uni2804 ENCODING 10244 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 00 00 40 00 00 00 ENDCHAR STARTCHAR uni2805 ENCODING 10245 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 40 00 00 00 40 00 00 00 ENDCHAR STARTCHAR uni2806 ENCODING 10246 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 40 00 40 00 00 00 ENDCHAR STARTCHAR uni2807 ENCODING 10247 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 40 00 40 00 40 00 00 00 ENDCHAR STARTCHAR uni2808 ENCODING 10248 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 10 00 00 00 00 00 00 00 ENDCHAR STARTCHAR uni2809 ENCODING 10249 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 50 00 00 00 00 00 00 00 ENDCHAR STARTCHAR uni280A ENCODING 10250 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 10 00 40 00 00 00 00 00 ENDCHAR STARTCHAR uni280B ENCODING 10251 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 50 00 40 00 00 00 00 00 ENDCHAR STARTCHAR uni280C ENCODING 10252 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 10 00 00 00 40 00 00 00 ENDCHAR STARTCHAR uni280D ENCODING 10253 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 50 00 00 00 40 00 00 00 ENDCHAR STARTCHAR uni280E ENCODING 10254 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 10 00 40 00 40 00 00 00 ENDCHAR STARTCHAR uni280F ENCODING 10255 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 50 00 40 00 40 00 00 00 ENDCHAR STARTCHAR uni2810 ENCODING 10256 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 10 00 00 00 00 00 ENDCHAR STARTCHAR uni2811 ENCODING 10257 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 40 00 10 00 00 00 00 00 ENDCHAR STARTCHAR uni2812 ENCODING 10258 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 50 00 00 00 00 00 ENDCHAR STARTCHAR uni2813 ENCODING 10259 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 40 00 50 00 00 00 00 00 ENDCHAR STARTCHAR uni2814 ENCODING 10260 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 10 00 40 00 00 00 ENDCHAR STARTCHAR uni2815 ENCODING 10261 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 40 00 10 00 40 00 00 00 ENDCHAR STARTCHAR uni2816 ENCODING 10262 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 50 00 40 00 00 00 ENDCHAR STARTCHAR uni2817 ENCODING 10263 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 40 00 50 00 40 00 00 00 ENDCHAR STARTCHAR uni2818 ENCODING 10264 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 10 00 10 00 00 00 00 00 ENDCHAR STARTCHAR uni2819 ENCODING 10265 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 50 00 10 00 00 00 00 00 ENDCHAR STARTCHAR uni281A ENCODING 10266 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 10 00 50 00 00 00 00 00 ENDCHAR STARTCHAR uni281B ENCODING 10267 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 50 00 50 00 00 00 00 00 ENDCHAR STARTCHAR uni281C ENCODING 10268 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 10 00 10 00 40 00 00 00 ENDCHAR STARTCHAR uni281D ENCODING 10269 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 50 00 10 00 40 00 00 00 ENDCHAR STARTCHAR uni281E ENCODING 10270 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 10 00 50 00 40 00 00 00 ENDCHAR STARTCHAR uni281F ENCODING 10271 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 50 00 50 00 40 00 00 00 ENDCHAR STARTCHAR uni2820 ENCODING 10272 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 00 00 10 00 00 00 ENDCHAR STARTCHAR uni2821 ENCODING 10273 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 40 00 00 00 10 00 00 00 ENDCHAR STARTCHAR uni2822 ENCODING 10274 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 40 00 10 00 00 00 ENDCHAR STARTCHAR uni2823 ENCODING 10275 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 40 00 40 00 10 00 00 00 ENDCHAR STARTCHAR uni2824 ENCODING 10276 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 00 00 50 00 00 00 ENDCHAR STARTCHAR uni2825 ENCODING 10277 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 40 00 00 00 50 00 00 00 ENDCHAR STARTCHAR uni2826 ENCODING 10278 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 40 00 50 00 00 00 ENDCHAR STARTCHAR uni2827 ENCODING 10279 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 40 00 40 00 50 00 00 00 ENDCHAR STARTCHAR uni2828 ENCODING 10280 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 10 00 00 00 10 00 00 00 ENDCHAR STARTCHAR uni2829 ENCODING 10281 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 50 00 00 00 10 00 00 00 ENDCHAR STARTCHAR uni282A ENCODING 10282 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 10 00 40 00 10 00 00 00 ENDCHAR STARTCHAR uni282B ENCODING 10283 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 50 00 40 00 10 00 00 00 ENDCHAR STARTCHAR uni282C ENCODING 10284 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 10 00 00 00 50 00 00 00 ENDCHAR STARTCHAR uni282D ENCODING 10285 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 50 00 00 00 50 00 00 00 ENDCHAR STARTCHAR uni282E ENCODING 10286 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 10 00 40 00 50 00 00 00 ENDCHAR STARTCHAR uni282F ENCODING 10287 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 50 00 40 00 50 00 00 00 ENDCHAR STARTCHAR uni2830 ENCODING 10288 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 10 00 10 00 00 00 ENDCHAR STARTCHAR uni2831 ENCODING 10289 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 40 00 10 00 10 00 00 00 ENDCHAR STARTCHAR uni2832 ENCODING 10290 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 50 00 10 00 00 00 ENDCHAR STARTCHAR uni2833 ENCODING 10291 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 40 00 50 00 10 00 00 00 ENDCHAR STARTCHAR uni2834 ENCODING 10292 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 10 00 50 00 00 00 ENDCHAR STARTCHAR uni2835 ENCODING 10293 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 40 00 10 00 50 00 00 00 ENDCHAR STARTCHAR uni2836 ENCODING 10294 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 50 00 50 00 00 00 ENDCHAR STARTCHAR uni2837 ENCODING 10295 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 40 00 50 00 50 00 00 00 ENDCHAR STARTCHAR uni2838 ENCODING 10296 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 10 00 10 00 10 00 00 00 ENDCHAR STARTCHAR uni2839 ENCODING 10297 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 50 00 10 00 10 00 00 00 ENDCHAR STARTCHAR uni283A ENCODING 10298 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 10 00 50 00 10 00 00 00 ENDCHAR STARTCHAR uni283B ENCODING 10299 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 50 00 50 00 10 00 00 00 ENDCHAR STARTCHAR uni283C ENCODING 10300 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 10 00 10 00 50 00 00 00 ENDCHAR STARTCHAR uni283D ENCODING 10301 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 50 00 10 00 50 00 00 00 ENDCHAR STARTCHAR uni283E ENCODING 10302 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 10 00 50 00 50 00 00 00 ENDCHAR STARTCHAR uni283F ENCODING 10303 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 50 00 50 00 50 00 00 00 ENDCHAR STARTCHAR uni2840 ENCODING 10304 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 00 00 00 00 40 00 ENDCHAR STARTCHAR uni2841 ENCODING 10305 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 40 00 00 00 00 00 40 00 ENDCHAR STARTCHAR uni2842 ENCODING 10306 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 40 00 00 00 40 00 ENDCHAR STARTCHAR uni2843 ENCODING 10307 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 40 00 40 00 00 00 40 00 ENDCHAR STARTCHAR uni2844 ENCODING 10308 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 00 00 40 00 40 00 ENDCHAR STARTCHAR uni2845 ENCODING 10309 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 40 00 00 00 40 00 40 00 ENDCHAR STARTCHAR uni2846 ENCODING 10310 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 40 00 40 00 40 00 ENDCHAR STARTCHAR uni2847 ENCODING 10311 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 40 00 40 00 40 00 40 00 ENDCHAR STARTCHAR uni2848 ENCODING 10312 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 10 00 00 00 00 00 40 00 ENDCHAR STARTCHAR uni2849 ENCODING 10313 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 50 00 00 00 00 00 40 00 ENDCHAR STARTCHAR uni284A ENCODING 10314 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 10 00 40 00 00 00 40 00 ENDCHAR STARTCHAR uni284B ENCODING 10315 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 50 00 40 00 00 00 40 00 ENDCHAR STARTCHAR uni284C ENCODING 10316 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 10 00 00 00 40 00 40 00 ENDCHAR STARTCHAR uni284D ENCODING 10317 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 50 00 00 00 40 00 40 00 ENDCHAR STARTCHAR uni284E ENCODING 10318 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 10 00 40 00 40 00 40 00 ENDCHAR STARTCHAR uni284F ENCODING 10319 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 50 00 40 00 40 00 40 00 ENDCHAR STARTCHAR uni2850 ENCODING 10320 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 10 00 00 00 40 00 ENDCHAR STARTCHAR uni2851 ENCODING 10321 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 40 00 10 00 00 00 40 00 ENDCHAR STARTCHAR uni2852 ENCODING 10322 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 50 00 00 00 40 00 ENDCHAR STARTCHAR uni2853 ENCODING 10323 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 40 00 50 00 00 00 40 00 ENDCHAR STARTCHAR uni2854 ENCODING 10324 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 10 00 40 00 40 00 ENDCHAR STARTCHAR uni2855 ENCODING 10325 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 40 00 10 00 40 00 40 00 ENDCHAR STARTCHAR uni2856 ENCODING 10326 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 50 00 40 00 40 00 ENDCHAR STARTCHAR uni2857 ENCODING 10327 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 40 00 50 00 40 00 40 00 ENDCHAR STARTCHAR uni2858 ENCODING 10328 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 10 00 10 00 00 00 40 00 ENDCHAR STARTCHAR uni2859 ENCODING 10329 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 50 00 10 00 00 00 40 00 ENDCHAR STARTCHAR uni285A ENCODING 10330 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 10 00 50 00 00 00 40 00 ENDCHAR STARTCHAR uni285B ENCODING 10331 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 50 00 50 00 00 00 40 00 ENDCHAR STARTCHAR uni285C ENCODING 10332 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 10 00 10 00 40 00 40 00 ENDCHAR STARTCHAR uni285D ENCODING 10333 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 50 00 10 00 40 00 40 00 ENDCHAR STARTCHAR uni285E ENCODING 10334 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 10 00 50 00 40 00 40 00 ENDCHAR STARTCHAR uni285F ENCODING 10335 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 50 00 50 00 40 00 40 00 ENDCHAR STARTCHAR uni2860 ENCODING 10336 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 00 00 10 00 40 00 ENDCHAR STARTCHAR uni2861 ENCODING 10337 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 40 00 00 00 10 00 40 00 ENDCHAR STARTCHAR uni2862 ENCODING 10338 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 40 00 10 00 40 00 ENDCHAR STARTCHAR uni2863 ENCODING 10339 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 40 00 40 00 10 00 40 00 ENDCHAR STARTCHAR uni2864 ENCODING 10340 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 00 00 50 00 40 00 ENDCHAR STARTCHAR uni2865 ENCODING 10341 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 40 00 00 00 50 00 40 00 ENDCHAR STARTCHAR uni2866 ENCODING 10342 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 40 00 50 00 40 00 ENDCHAR STARTCHAR uni2867 ENCODING 10343 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 40 00 40 00 50 00 40 00 ENDCHAR STARTCHAR uni2868 ENCODING 10344 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 10 00 00 00 10 00 40 00 ENDCHAR STARTCHAR uni2869 ENCODING 10345 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 50 00 00 00 10 00 40 00 ENDCHAR STARTCHAR uni286A ENCODING 10346 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 10 00 40 00 10 00 40 00 ENDCHAR STARTCHAR uni286B ENCODING 10347 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 50 00 40 00 10 00 40 00 ENDCHAR STARTCHAR uni286C ENCODING 10348 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 10 00 00 00 50 00 40 00 ENDCHAR STARTCHAR uni286D ENCODING 10349 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 50 00 00 00 50 00 40 00 ENDCHAR STARTCHAR uni286E ENCODING 10350 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 10 00 40 00 50 00 40 00 ENDCHAR STARTCHAR uni286F ENCODING 10351 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 50 00 40 00 50 00 40 00 ENDCHAR STARTCHAR uni2870 ENCODING 10352 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 10 00 10 00 40 00 ENDCHAR STARTCHAR uni2871 ENCODING 10353 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 40 00 10 00 10 00 40 00 ENDCHAR STARTCHAR uni2872 ENCODING 10354 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 50 00 10 00 40 00 ENDCHAR STARTCHAR uni2873 ENCODING 10355 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 40 00 50 00 10 00 40 00 ENDCHAR STARTCHAR uni2874 ENCODING 10356 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 10 00 50 00 40 00 ENDCHAR STARTCHAR uni2875 ENCODING 10357 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 40 00 10 00 50 00 40 00 ENDCHAR STARTCHAR uni2876 ENCODING 10358 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 50 00 50 00 40 00 ENDCHAR STARTCHAR uni2877 ENCODING 10359 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 40 00 50 00 50 00 40 00 ENDCHAR STARTCHAR uni2878 ENCODING 10360 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 10 00 10 00 10 00 40 00 ENDCHAR STARTCHAR uni2879 ENCODING 10361 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 50 00 10 00 10 00 40 00 ENDCHAR STARTCHAR uni287A ENCODING 10362 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 10 00 50 00 10 00 40 00 ENDCHAR STARTCHAR uni287B ENCODING 10363 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 50 00 50 00 10 00 40 00 ENDCHAR STARTCHAR uni287C ENCODING 10364 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 10 00 10 00 50 00 40 00 ENDCHAR STARTCHAR uni287D ENCODING 10365 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 50 00 10 00 50 00 40 00 ENDCHAR STARTCHAR uni287E ENCODING 10366 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 10 00 50 00 50 00 40 00 ENDCHAR STARTCHAR uni287F ENCODING 10367 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 50 00 50 00 50 00 40 00 ENDCHAR STARTCHAR uni2880 ENCODING 10368 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 00 00 00 00 10 00 ENDCHAR STARTCHAR uni2881 ENCODING 10369 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 40 00 00 00 00 00 10 00 ENDCHAR STARTCHAR uni2882 ENCODING 10370 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 40 00 00 00 10 00 ENDCHAR STARTCHAR uni2883 ENCODING 10371 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 40 00 40 00 00 00 10 00 ENDCHAR STARTCHAR uni2884 ENCODING 10372 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 00 00 40 00 10 00 ENDCHAR STARTCHAR uni2885 ENCODING 10373 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 40 00 00 00 40 00 10 00 ENDCHAR STARTCHAR uni2886 ENCODING 10374 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 40 00 40 00 10 00 ENDCHAR STARTCHAR uni2887 ENCODING 10375 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 40 00 40 00 40 00 10 00 ENDCHAR STARTCHAR uni2888 ENCODING 10376 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 10 00 00 00 00 00 10 00 ENDCHAR STARTCHAR uni2889 ENCODING 10377 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 50 00 00 00 00 00 10 00 ENDCHAR STARTCHAR uni288A ENCODING 10378 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 10 00 40 00 00 00 10 00 ENDCHAR STARTCHAR uni288B ENCODING 10379 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 50 00 40 00 00 00 10 00 ENDCHAR STARTCHAR uni288C ENCODING 10380 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 10 00 00 00 40 00 10 00 ENDCHAR STARTCHAR uni288D ENCODING 10381 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 50 00 00 00 40 00 10 00 ENDCHAR STARTCHAR uni288E ENCODING 10382 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 10 00 40 00 40 00 10 00 ENDCHAR STARTCHAR uni288F ENCODING 10383 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 50 00 40 00 40 00 10 00 ENDCHAR STARTCHAR uni2890 ENCODING 10384 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 10 00 00 00 10 00 ENDCHAR STARTCHAR uni2891 ENCODING 10385 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 40 00 10 00 00 00 10 00 ENDCHAR STARTCHAR uni2892 ENCODING 10386 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 50 00 00 00 10 00 ENDCHAR STARTCHAR uni2893 ENCODING 10387 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 40 00 50 00 00 00 10 00 ENDCHAR STARTCHAR uni2894 ENCODING 10388 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 10 00 40 00 10 00 ENDCHAR STARTCHAR uni2895 ENCODING 10389 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 40 00 10 00 40 00 10 00 ENDCHAR STARTCHAR uni2896 ENCODING 10390 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 50 00 40 00 10 00 ENDCHAR STARTCHAR uni2897 ENCODING 10391 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 40 00 50 00 40 00 10 00 ENDCHAR STARTCHAR uni2898 ENCODING 10392 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 10 00 10 00 00 00 10 00 ENDCHAR STARTCHAR uni2899 ENCODING 10393 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 50 00 10 00 00 00 10 00 ENDCHAR STARTCHAR uni289A ENCODING 10394 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 10 00 50 00 00 00 10 00 ENDCHAR STARTCHAR uni289B ENCODING 10395 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 50 00 50 00 00 00 10 00 ENDCHAR STARTCHAR uni289C ENCODING 10396 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 10 00 10 00 40 00 10 00 ENDCHAR STARTCHAR uni289D ENCODING 10397 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 50 00 10 00 40 00 10 00 ENDCHAR STARTCHAR uni289E ENCODING 10398 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 10 00 50 00 40 00 10 00 ENDCHAR STARTCHAR uni289F ENCODING 10399 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 50 00 50 00 40 00 10 00 ENDCHAR STARTCHAR uni28A0 ENCODING 10400 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 00 00 10 00 10 00 ENDCHAR STARTCHAR uni28A1 ENCODING 10401 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 40 00 00 00 10 00 10 00 ENDCHAR STARTCHAR uni28A2 ENCODING 10402 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 40 00 10 00 10 00 ENDCHAR STARTCHAR uni28A3 ENCODING 10403 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 40 00 40 00 10 00 10 00 ENDCHAR STARTCHAR uni28A4 ENCODING 10404 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 00 00 50 00 10 00 ENDCHAR STARTCHAR uni28A5 ENCODING 10405 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 40 00 00 00 50 00 10 00 ENDCHAR STARTCHAR uni28A6 ENCODING 10406 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 40 00 50 00 10 00 ENDCHAR STARTCHAR uni28A7 ENCODING 10407 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 40 00 40 00 50 00 10 00 ENDCHAR STARTCHAR uni28A8 ENCODING 10408 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 10 00 00 00 10 00 10 00 ENDCHAR STARTCHAR uni28A9 ENCODING 10409 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 50 00 00 00 10 00 10 00 ENDCHAR STARTCHAR uni28AA ENCODING 10410 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 10 00 40 00 10 00 10 00 ENDCHAR STARTCHAR uni28AB ENCODING 10411 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 50 00 40 00 10 00 10 00 ENDCHAR STARTCHAR uni28AC ENCODING 10412 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 10 00 00 00 50 00 10 00 ENDCHAR STARTCHAR uni28AD ENCODING 10413 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 50 00 00 00 50 00 10 00 ENDCHAR STARTCHAR uni28AE ENCODING 10414 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 10 00 40 00 50 00 10 00 ENDCHAR STARTCHAR uni28AF ENCODING 10415 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 50 00 40 00 50 00 10 00 ENDCHAR STARTCHAR uni28B0 ENCODING 10416 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 10 00 10 00 10 00 ENDCHAR STARTCHAR uni28B1 ENCODING 10417 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 40 00 10 00 10 00 10 00 ENDCHAR STARTCHAR uni28B2 ENCODING 10418 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 50 00 10 00 10 00 ENDCHAR STARTCHAR uni28B3 ENCODING 10419 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 40 00 50 00 10 00 10 00 ENDCHAR STARTCHAR uni28B4 ENCODING 10420 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 10 00 50 00 10 00 ENDCHAR STARTCHAR uni28B5 ENCODING 10421 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 40 00 10 00 50 00 10 00 ENDCHAR STARTCHAR uni28B6 ENCODING 10422 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 50 00 50 00 10 00 ENDCHAR STARTCHAR uni28B7 ENCODING 10423 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 40 00 50 00 50 00 10 00 ENDCHAR STARTCHAR uni28B8 ENCODING 10424 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 10 00 10 00 10 00 10 00 ENDCHAR STARTCHAR uni28B9 ENCODING 10425 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 50 00 10 00 10 00 10 00 ENDCHAR STARTCHAR uni28BA ENCODING 10426 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 10 00 50 00 10 00 10 00 ENDCHAR STARTCHAR uni28BB ENCODING 10427 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 50 00 50 00 10 00 10 00 ENDCHAR STARTCHAR uni28BC ENCODING 10428 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 10 00 10 00 50 00 10 00 ENDCHAR STARTCHAR uni28BD ENCODING 10429 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 50 00 10 00 50 00 10 00 ENDCHAR STARTCHAR uni28BE ENCODING 10430 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 10 00 50 00 50 00 10 00 ENDCHAR STARTCHAR uni28BF ENCODING 10431 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 50 00 50 00 50 00 10 00 ENDCHAR STARTCHAR uni28C0 ENCODING 10432 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 00 00 00 00 50 00 ENDCHAR STARTCHAR uni28C1 ENCODING 10433 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 40 00 00 00 00 00 50 00 ENDCHAR STARTCHAR uni28C2 ENCODING 10434 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 40 00 00 00 50 00 ENDCHAR STARTCHAR uni28C3 ENCODING 10435 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 40 00 40 00 00 00 50 00 ENDCHAR STARTCHAR uni28C4 ENCODING 10436 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 00 00 40 00 50 00 ENDCHAR STARTCHAR uni28C5 ENCODING 10437 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 40 00 00 00 40 00 50 00 ENDCHAR STARTCHAR uni28C6 ENCODING 10438 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 40 00 40 00 50 00 ENDCHAR STARTCHAR uni28C7 ENCODING 10439 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 40 00 40 00 40 00 50 00 ENDCHAR STARTCHAR uni28C8 ENCODING 10440 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 10 00 00 00 00 00 50 00 ENDCHAR STARTCHAR uni28C9 ENCODING 10441 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 50 00 00 00 00 00 50 00 ENDCHAR STARTCHAR uni28CA ENCODING 10442 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 10 00 40 00 00 00 50 00 ENDCHAR STARTCHAR uni28CB ENCODING 10443 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 50 00 40 00 00 00 50 00 ENDCHAR STARTCHAR uni28CC ENCODING 10444 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 10 00 00 00 40 00 50 00 ENDCHAR STARTCHAR uni28CD ENCODING 10445 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 50 00 00 00 40 00 50 00 ENDCHAR STARTCHAR uni28CE ENCODING 10446 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 10 00 40 00 40 00 50 00 ENDCHAR STARTCHAR uni28CF ENCODING 10447 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 50 00 40 00 40 00 50 00 ENDCHAR STARTCHAR uni28D0 ENCODING 10448 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 10 00 00 00 50 00 ENDCHAR STARTCHAR uni28D1 ENCODING 10449 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 40 00 10 00 00 00 50 00 ENDCHAR STARTCHAR uni28D2 ENCODING 10450 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 50 00 00 00 50 00 ENDCHAR STARTCHAR uni28D3 ENCODING 10451 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 40 00 50 00 00 00 50 00 ENDCHAR STARTCHAR uni28D4 ENCODING 10452 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 10 00 40 00 50 00 ENDCHAR STARTCHAR uni28D5 ENCODING 10453 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 40 00 10 00 40 00 50 00 ENDCHAR STARTCHAR uni28D6 ENCODING 10454 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 50 00 40 00 50 00 ENDCHAR STARTCHAR uni28D7 ENCODING 10455 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 40 00 50 00 40 00 50 00 ENDCHAR STARTCHAR uni28D8 ENCODING 10456 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 10 00 10 00 00 00 50 00 ENDCHAR STARTCHAR uni28D9 ENCODING 10457 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 50 00 10 00 00 00 50 00 ENDCHAR STARTCHAR uni28DA ENCODING 10458 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 10 00 50 00 00 00 50 00 ENDCHAR STARTCHAR uni28DB ENCODING 10459 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 50 00 50 00 00 00 50 00 ENDCHAR STARTCHAR uni28DC ENCODING 10460 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 10 00 10 00 40 00 50 00 ENDCHAR STARTCHAR uni28DD ENCODING 10461 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 50 00 10 00 40 00 50 00 ENDCHAR STARTCHAR uni28DE ENCODING 10462 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 10 00 50 00 40 00 50 00 ENDCHAR STARTCHAR uni28DF ENCODING 10463 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 50 00 50 00 40 00 50 00 ENDCHAR STARTCHAR uni28E0 ENCODING 10464 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 00 00 10 00 50 00 ENDCHAR STARTCHAR uni28E1 ENCODING 10465 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 40 00 00 00 10 00 50 00 ENDCHAR STARTCHAR uni28E2 ENCODING 10466 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 40 00 10 00 50 00 ENDCHAR STARTCHAR uni28E3 ENCODING 10467 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 40 00 40 00 10 00 50 00 ENDCHAR STARTCHAR uni28E4 ENCODING 10468 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 00 00 50 00 50 00 ENDCHAR STARTCHAR uni28E5 ENCODING 10469 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 40 00 00 00 50 00 50 00 ENDCHAR STARTCHAR uni28E6 ENCODING 10470 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 40 00 50 00 50 00 ENDCHAR STARTCHAR uni28E7 ENCODING 10471 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 40 00 40 00 50 00 50 00 ENDCHAR STARTCHAR uni28E8 ENCODING 10472 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 10 00 00 00 10 00 50 00 ENDCHAR STARTCHAR uni28E9 ENCODING 10473 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 50 00 00 00 10 00 50 00 ENDCHAR STARTCHAR uni28EA ENCODING 10474 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 10 00 40 00 10 00 50 00 ENDCHAR STARTCHAR uni28EB ENCODING 10475 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 50 00 40 00 10 00 50 00 ENDCHAR STARTCHAR uni28EC ENCODING 10476 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 10 00 00 00 50 00 50 00 ENDCHAR STARTCHAR uni28ED ENCODING 10477 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 50 00 00 00 50 00 50 00 ENDCHAR STARTCHAR uni28EE ENCODING 10478 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 10 00 40 00 50 00 50 00 ENDCHAR STARTCHAR uni28EF ENCODING 10479 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 50 00 40 00 50 00 50 00 ENDCHAR STARTCHAR uni28F0 ENCODING 10480 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 10 00 10 00 50 00 ENDCHAR STARTCHAR uni28F1 ENCODING 10481 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 40 00 10 00 10 00 50 00 ENDCHAR STARTCHAR uni28F2 ENCODING 10482 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 50 00 10 00 50 00 ENDCHAR STARTCHAR uni28F3 ENCODING 10483 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 40 00 50 00 10 00 50 00 ENDCHAR STARTCHAR uni28F4 ENCODING 10484 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 10 00 50 00 50 00 ENDCHAR STARTCHAR uni28F5 ENCODING 10485 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 40 00 10 00 50 00 50 00 ENDCHAR STARTCHAR uni28F6 ENCODING 10486 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 00 00 50 00 50 00 50 00 ENDCHAR STARTCHAR uni28F7 ENCODING 10487 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 40 00 50 00 50 00 50 00 ENDCHAR STARTCHAR uni28F8 ENCODING 10488 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 10 00 10 00 10 00 50 00 ENDCHAR STARTCHAR uni28F9 ENCODING 10489 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 50 00 10 00 10 00 50 00 ENDCHAR STARTCHAR uni28FA ENCODING 10490 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 10 00 50 00 10 00 50 00 ENDCHAR STARTCHAR uni28FB ENCODING 10491 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 50 00 50 00 10 00 50 00 ENDCHAR STARTCHAR uni28FC ENCODING 10492 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 10 00 10 00 50 00 50 00 ENDCHAR STARTCHAR uni28FD ENCODING 10493 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 50 00 10 00 50 00 50 00 ENDCHAR STARTCHAR uni28FE ENCODING 10494 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 10 00 50 00 50 00 50 00 ENDCHAR STARTCHAR uni28FF ENCODING 10495 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 50 00 50 00 50 00 50 00 ENDCHAR STARTCHAR fi ENCODING 64257 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 10 28 20 78 28 28 00 00 ENDCHAR STARTCHAR fl ENCODING 64258 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 00 18 28 28 78 28 28 00 00 ENDCHAR STARTCHAR uniFFFD ENCODING 65533 SWIDTH 640 0 DWIDTH 6 0 BBX 6 9 0 -2 BITMAP 70 D8 A8 E8 D8 D8 F8 D8 70 ENDCHAR ENDFONT ================================================ FILE: share/examples/gpanel/fonts/convbdf.c ================================================ /* * Convert BDF files to C source * * Copyright (c) 2002 by Greg Haerr * Copyright (c) 2008-2015 by Serge Vakulenko * * What fun it is converting font data... * * 09/17/02 Version 1.0 */ #include #include #include #include /* * Glyph image helper macros. */ #define BITS_PER_WORD (sizeof(unsigned short) * 8) #define NIBBLES_PER_WORD (BITS_PER_WORD/4) #define WORDS(bits) (((bits)+BITS_PER_WORD-1)/BITS_PER_WORD) #define BYTES(bits) (WORDS(bits) * sizeof(unsigned short)) #define TEST_HIGH_BIT(w) ((w) >> (BITS_PER_WORD - 1) & 1) /* * Builtin C-based proportional/fixed font structure. * Based on The Microwindows Project http://microwindows.org */ typedef struct { char * name; /* font name*/ int maxwidth; /* max width in pixels*/ int height; /* height in pixels*/ int ascent; /* ascent (baseline) height*/ int firstchar; /* first character in bitmap*/ int size; /* font size in glyphs*/ unsigned short *bits; /* 16-bit right-padded bitmap data*/ unsigned long *offset; /* offsets into bitmap data*/ unsigned char *width; /* character widths or NULL if fixed*/ int defaultchar; /* default char (not glyph index)*/ long bits_size; /* # words of bits[]*/ /* unused by runtime system, read in by convbdf*/ char * facename; /* facename of font*/ char * copyright; /* copyright info for loadable fonts*/ int pixel_size; int descent; int fbbw, fbbh, fbbx, fbby; } font_t; #define isprefix(buf,str) (!strncmp(buf, str, strlen(str))) #define strequal(s1,s2) (!strcmp(s1, s2)) #define EXTRA 300 /* # bytes extra allocation for buggy .bdf files*/ int gen_map = 1; int start_char = 0; int default_char = 0; int exclude_start = 0; int exclude_end = 0; int limit_char = 65535; int ascent_correction = 0; int descent_correction = 0; char outfile[256]; void usage(void); void getopts(int *pac, char ***pav); int convbdf(char *path); void free_font(font_t *pf); font_t * bdf_read_font(char *path); int bdf_read_header(FILE *fp, font_t *pf); int bdf_read_bitmaps(FILE *fp, font_t *pf); char * bdf_getline(FILE *fp, char *buf, int len); unsigned short bdf_hexval(unsigned char *buf, int ndx1, int ndx2); int gen_c_source(font_t *pf, char *path); void usage(void) { fprintf (stderr, "Usage: convbdf [options] [input-files]\n" "Options:\n" " -s N Start output at character encodings >= N\n" " -l N Limit output to character encodings <= N\n" " -x N-M Exclude character range N...M\n" " -u N Use code N as default char \n" " -a N Decrease ascent by N\n" " -d N Decrease descent by N\n" " -n Don't generate bitmaps as comments in .c file\n" ); } /* * parse command line options */ void getopts(int *pac, char ***pav) { char *p; char **av; int ac; ac = *pac; av = *pav; while (ac > 0 && av[0][0] == '-') { p = &av[0][1]; while( *p) switch(*p++) { case ' ': /* multiple -args on av[]*/ while( *p && *p == ' ') p++; if( *p++ != '-') /* next option must have dash*/ p = ""; break; /* proceed to next option*/ case 'n': /* don't gen bitmap comments*/ gen_map = 0; break; case 'l': /* set encoding limit */ if (*p) { limit_char = strtol (p, 0, 0); while (*p && *p != ' ') p++; } else { av++; ac--; if (ac > 0) limit_char = strtol (av[0], 0, 0); } break; case 'x': /* exclude encoding range */ if (*p) { char *e; exclude_start = strtol (p, &e, 0); if (*e != '-') { fprintf(stderr, "Invalud option ignored: %s\r\n", p); exclude_start = 0; break; } exclude_end = strtol (e+1, 0, 0); while (*p && *p != ' ') p++; } else { av++; ac--; if (ac > 0) { char *e; exclude_start = strtol (av[0], &e, 0); if (*e != '-') { fprintf(stderr, "Invalud option ignored: %s\r\n", av[0]); exclude_start = 0; break; } exclude_end = strtol (e+1, 0, 0); } } break; case 's': /* set encoding start */ if (*p) { start_char = strtol (p, 0, 0); while (*p && *p != ' ') p++; } else { av++; ac--; if (ac > 0) start_char = strtol (av[0], 0, 0); } break; case 'a': /* ascent correction */ if (*p) { ascent_correction = strtol (p, 0, 0); while (*p && *p != ' ') p++; } else { av++; ac--; if (ac > 0) ascent_correction = strtol (av[0], 0, 0); } break; case 'd': /* descent correction */ if (*p) { descent_correction = strtol (p, 0, 0); while (*p && *p != ' ') p++; } else { av++; ac--; if (ac > 0) descent_correction = strtol (av[0], 0, 0); } break; case 'u': /* unknown char */ if (*p) { default_char = strtol (p, 0, 0); while (*p && *p != ' ') p++; } else { av++; ac--; if (ac > 0) default_char = strtol (av[0], 0, 0); } break; default: fprintf(stderr, "Unknown option ignored: %c\r\n", *(p-1)); } ++av; --ac; } *pac = ac; *pav = av; } /* * remove directory prefix and file suffix from full path */ char * basename(char *path) { char *p, *b; static char base[256]; /* remove prepended path and extension*/ b = path; for (p=path; *p; ++p) { if (*p == '/') b = p + 1; } strcpy(base, b); for (p=base; *p; ++p) { if (*p == '.') { *p = 0; break; } } return base; } int convbdf(char *path) { font_t *pf; int ret = 0; pf = bdf_read_font(path); if (!pf) exit(1); strcpy(outfile, basename(path)); strcat(outfile, ".c"); ret |= gen_c_source(pf, outfile); free_font(pf); return ret; } int main(int ac, char **av) { int ret = 0; ++av; --ac; /* skip av[0] */ getopts(&ac, &av); /* read command line options */ if (ac < 1) { usage(); exit(1); } while (ac > 0) { ret |= convbdf(av[0]); ++av; --ac; } exit(ret); } /* * free font structure */ void free_font(font_t *pf) { if (!pf) return; if (pf->name) free(pf->name); if (pf->facename) free(pf->facename); if (pf->bits) free(pf->bits); if (pf->offset) free(pf->offset); if (pf->width) free(pf->width); free(pf); } /* * build incore structure from .bdf file */ font_t * bdf_read_font(char *path) { FILE *fp; font_t *pf; fp = fopen(path, "rb"); if (!fp) { fprintf(stderr, "Error opening file: %s\n", path); return NULL; } pf = (font_t *) calloc(1, sizeof(font_t)); if (!pf) goto errout; pf->name = strdup(basename(path)); if (!bdf_read_header(fp, pf)) { fprintf(stderr, "Error reading font header\n"); goto errout; } if (!bdf_read_bitmaps(fp, pf)) { fprintf(stderr, "Error reading font bitmaps\n"); goto errout; } fclose(fp); return pf; errout: fclose(fp); free_font(pf); return NULL; } /* * read bdf font header information, return 0 on error */ int bdf_read_header(FILE *fp, font_t *pf) { int encoding; int nchars, maxwidth = 0; int firstchar = 65535; int lastchar = -1; char buf[256]; char facename[256]; char copyright[256]; /* set certain values to errors for later error checking*/ pf->defaultchar = -1; pf->ascent = -1; pf->descent = -1; for (;;) { if (!bdf_getline(fp, buf, sizeof(buf))) { fprintf(stderr, "Error: EOF on file\n"); return 0; } if (isprefix(buf, "FONT ")) { /* not required*/ if (sscanf(buf, "FONT %[^\n]", facename) != 1) { fprintf(stderr, "Error: bad 'FONT'\n"); return 0; } pf->facename = strdup(facename); continue; } if (isprefix(buf, "COPYRIGHT ")) { /* not required*/ if (sscanf(buf, "COPYRIGHT \"%[^\"]", copyright) != 1) { fprintf(stderr, "Error: bad 'COPYRIGHT'\n"); return 0; } pf->copyright = strdup(copyright); continue; } if (isprefix(buf, "DEFAULT_CHAR ")) { /* not required*/ if (sscanf(buf, "DEFAULT_CHAR %d", &pf->defaultchar) != 1) { fprintf(stderr, "Error: bad 'DEFAULT_CHAR'\n"); return 0; } } if (isprefix(buf, "FONT_DESCENT ")) { if (sscanf(buf, "FONT_DESCENT %d", &pf->descent) != 1) { fprintf(stderr, "Error: bad 'FONT_DESCENT'\n"); return 0; } continue; } if (isprefix(buf, "FONT_ASCENT ")) { if (sscanf(buf, "FONT_ASCENT %d", &pf->ascent) != 1) { fprintf(stderr, "Error: bad 'FONT_ASCENT'\n"); return 0; } continue; } if (isprefix(buf, "FONTBOUNDINGBOX ")) { if (sscanf(buf, "FONTBOUNDINGBOX %d %d %d %d", &pf->fbbw, &pf->fbbh, &pf->fbbx, &pf->fbby) != 4) { fprintf(stderr, "Error: bad 'FONTBOUNDINGBOX'\n"); return 0; } continue; } if (isprefix(buf, "CHARS ")) { if (sscanf(buf, "CHARS %d", &nchars) != 1) { fprintf(stderr, "Error: bad 'CHARS'\n"); return 0; } continue; } /* * Reading ENCODING is necessary to get firstchar/lastchar * which is needed to pre-calculate our offset and widths * array sizes. */ if (isprefix(buf, "ENCODING ")) { if (sscanf(buf, "ENCODING %d", &encoding) != 1) { fprintf(stderr, "Error: bad 'ENCODING'\n"); return 0; } if (encoding > limit_char || encoding < start_char) continue; if (exclude_start && encoding >= exclude_start && encoding <= exclude_end) continue; if (firstchar > encoding) firstchar = encoding; if (lastchar < encoding) lastchar = encoding; continue; } if (isprefix(buf, "DWIDTH ")) { int width; if (sscanf(buf, "DWIDTH %d", &width) != 1) { fprintf(stderr, "Error: bad 'DWIDTH' for encoding %d\n", encoding); return 0; } if (maxwidth < width) maxwidth = width; continue; } if (strequal(buf, "ENDFONT")) break; } /* calc font height*/ if (pf->ascent < 0 || pf->descent < 0 || firstchar < 0) { fprintf(stderr, "Error: Invalid BDF file, requires FONT_ASCENT/FONT_DESCENT/ENCODING\n"); return 0; } pf->height = pf->ascent + pf->descent; /* calc default char*/ if (default_char) pf->defaultchar = default_char; if (pf->defaultchar < 0 || pf->defaultchar < firstchar || pf->defaultchar > limit_char) pf->defaultchar = firstchar; /* calc font size (offset/width entries)*/ pf->firstchar = firstchar; pf->size = lastchar - firstchar + 1; /* initially use font maxwidth * height for bits allocation*/ pf->bits_size = nchars * WORDS(maxwidth) * pf->height; /* allocate bits, offset, and width arrays*/ pf->bits = (unsigned short*) malloc(pf->bits_size * sizeof(unsigned short) + EXTRA); pf->offset = (unsigned long*) malloc(pf->size * sizeof(unsigned long)); pf->width = (unsigned char*) malloc(pf->size * sizeof(unsigned char)); if (!pf->bits || !pf->offset || !pf->width) { fprintf(stderr, "Error: no memory for font load\n"); return 0; } return 1; } /* * read bdf font bitmaps, return 0 on error */ int bdf_read_bitmaps(FILE *fp, font_t *pf) { long ofs = 0; int maxwidth = 0; int i, k, encoding, width; int bbw, bbh, bbx, bby; int proportional = 0; int encodetable = 0; long l; char buf[256]; /* reset file pointer*/ fseek(fp, 0L, SEEK_SET); /* initially mark offsets as not used*/ for (i=0; isize; ++i) pf->offset[i] = -1; for (;;) { if (!bdf_getline(fp, buf, sizeof(buf))) { fprintf(stderr, "Error: EOF on file\n"); return 0; } if (isprefix(buf, "STARTCHAR")) { encoding = width = bbw = bbh = bbx = bby = -1; continue; } if (isprefix(buf, "ENCODING ")) { if (sscanf(buf, "ENCODING %d", &encoding) != 1) { fprintf(stderr, "Error: bad 'ENCODING'\n"); return 0; } if (encoding < start_char || encoding > limit_char) encoding = -1; if (exclude_start && encoding >= exclude_start && encoding <= exclude_end) encoding = -1; continue; } if (isprefix(buf, "DWIDTH ")) { if (sscanf(buf, "DWIDTH %d", &width) != 1) { fprintf(stderr, "Error: bad 'DWIDTH'\n"); return 0; } /* use font boundingbox width if DWIDTH <= 0*/ if (width <= 0) width = pf->fbbw - pf->fbbx; continue; } if (isprefix(buf, "BBX ")) { if (sscanf(buf, "BBX %d %d %d %d", &bbw, &bbh, &bbx, &bby) != 4) { fprintf(stderr, "Error: bad 'BBX'\n"); return 0; } continue; } if (strequal(buf, "BITMAP")) { unsigned short *ch_bitmap = pf->bits + ofs; int ch_words; if (encoding < 0) continue; /* set bits offset in encode map*/ if (pf->offset[encoding-pf->firstchar] != (unsigned long)-1) { fprintf(stderr, "Error: duplicate encoding for character %d (0x%02x), ignoring duplicate\n", encoding, encoding); continue; } pf->offset[encoding-pf->firstchar] = ofs; /* calc char width*/ if (bbx < 0) { width -= bbx; /*if (width > maxwidth) width = maxwidth;*/ bbx = 0; } if (width > maxwidth) maxwidth = width; pf->width[encoding-pf->firstchar] = width; /* clear bitmap*/ memset(ch_bitmap, 0, BYTES(width) * pf->height); ch_words = WORDS(width); #define BM(row,col) (*(ch_bitmap + ((row)*ch_words) + (col))) /* read bitmaps*/ for (i=0; ; ++i) { int hexnibbles; if (!bdf_getline(fp, buf, sizeof(buf))) { fprintf(stderr, "Error: EOF reading BITMAP data\n"); return 0; } if (isprefix(buf, "ENDCHAR")) break; hexnibbles = strlen(buf); for (k=0; k= NIBBLES_PER_WORD) padnibbles = 0; value = bdf_hexval((unsigned char *)buf, ndx, ndx+NIBBLES_PER_WORD-1-padnibbles); value <<= padnibbles * NIBBLES_PER_WORD; BM(pf->height - pf->descent - bby - bbh + i, k) |= value >> bbx; /* handle overflow into next image word*/ if (bbx) { BM(pf->height - pf->descent - bby - bbh + i, k+1) = value << (BITS_PER_WORD - bbx); } } } ofs += WORDS(width) * pf->height; continue; } if (strequal(buf, "ENDFONT")) break; } /* set max width*/ pf->maxwidth = maxwidth; /* change unused offset/width values to default char values*/ for (i=0; isize; ++i) { int defchar = pf->defaultchar - pf->firstchar; if (pf->offset[i] == (unsigned long)-1) { pf->offset[i] = pf->offset[defchar]; pf->width[i] = pf->width[defchar]; } } /* determine whether font doesn't require encode table*/ l = 0; for (i=0; isize; ++i) { if (pf->offset[i] != l) { encodetable = 1; break; } l += WORDS(pf->width[i]) * pf->height; } if (!encodetable) { free(pf->offset); pf->offset = NULL; } /* determine whether font is fixed-width*/ for (i=0; isize; ++i) { if (pf->width[i] != maxwidth) { proportional = 1; break; } } if (!proportional) { free(pf->width); pf->width = NULL; } /* reallocate bits array to actual bits used*/ if (ofs < pf->bits_size) { pf->bits = realloc(pf->bits, ofs * sizeof(unsigned short)); pf->bits_size = ofs; } else if (ofs > pf->bits_size) { fprintf(stderr, "Warning: DWIDTH spec > max FONTBOUNDINGBOX\n"); if (ofs > pf->bits_size+EXTRA) { fprintf(stderr, "Error: Not enough bits initially allocated\n"); return 0; } pf->bits_size = ofs; } return 1; } /* * read the next non-comment line, returns buf or NULL if EOF */ char * bdf_getline(FILE *fp, char *buf, int len) { int c; char *b; for (;;) { b = buf; while ((c = getc(fp)) != EOF) { if (c == '\r') continue; if (c == '\n') break; if (b - buf >= (len - 1)) break; *b++ = c; } *b = '\0'; if (c == EOF && b == buf) return NULL; if (b != buf && !isprefix(buf, "COMMENT")) break; } return buf; } /* * return hex value of portion of buffer */ unsigned short bdf_hexval(unsigned char *buf, int ndx1, int ndx2) { unsigned short val = 0; int i, c; for (i=ndx1; i<=ndx2; ++i) { c = buf[i]; if (c >= '0' && c <= '9') c -= '0'; else if (c >= 'A' && c <= 'F') c = c - 'A' + 10; else if (c >= 'a' && c <= 'f') c = c - 'a' + 10; else c = 0; val = (val << 4) | c; } return val; } /* * generate C source from in-core font */ int gen_c_source(font_t *pf, char *path) { FILE *ofp; int i; int did_defaultchar = 0; time_t t = time(0); char buf[256]; char obuf[256]; char hdr1[] = { "/* Generated by convbdf on %s. */\n" "#include \n" "\n" "/* Font information:\n" " name: %s\n" " facename: %s\n" " w x h: %dx%d\n" " size: %d\n" " ascent: %d\n" " descent: %d\n" " first char: %d (0x%02x)\n" " last char: %d (0x%02x)\n" " default char: %d (0x%02x)\n" " proportional: %s\n" " %s\n" "*/\n" "\n" "/* Font character bitmap data. */\n" "static const unsigned short _%s_bits[] = {\n" }; ofp = fopen(path, "w"); if (!ofp) { fprintf(stderr, "Can't create %s\n", path); return 1; } fprintf(stderr, "Generating %s\n", path); strcpy(buf, ctime(&t)); buf[strlen(buf)-1] = 0; fprintf(ofp, hdr1, buf, pf->name, pf->facename? pf->facename: "", pf->maxwidth, pf->height - ascent_correction - descent_correction, pf->size, pf->ascent - ascent_correction, pf->descent - descent_correction, pf->firstchar, pf->firstchar, pf->firstchar+pf->size-1, pf->firstchar+pf->size-1, pf->defaultchar, pf->defaultchar, pf->width? "yes": "no", pf->copyright? pf->copyright: "", pf->name); /* generate bitmaps*/ for (i=0; isize; ++i) { int x; int bitcount = 0; int width = pf->width ? pf->width[i] : pf->maxwidth; int height = pf->height - ascent_correction - descent_correction; unsigned short *bits = pf->bits + (pf->offset? pf->offset[i]: (pf->height * i)); unsigned short bitvalue = 0; /* * Generate bitmap bits only if not this index isn't * the default character in encode map, or the default * character hasn't been generated yet. */ if (pf->offset && (pf->offset[i] == pf->offset[pf->defaultchar-pf->firstchar])) { if (did_defaultchar) continue; did_defaultchar = 1; } fprintf(ofp, "\n/* Character %d (0x%02x):\n width %d", i+pf->firstchar, i+pf->firstchar, width); bits += WORDS(width) * ascent_correction; if (gen_map) { fprintf(ofp, "\n +"); for (x=0; x 0) { if (x == 0) fprintf(ofp, " |"); if (bitcount <= 0) { bitcount = BITS_PER_WORD; bitvalue = *bits++; } fprintf(ofp, TEST_HIGH_BIT(bitvalue)? "*": " "); bitvalue <<= 1; --bitcount; if (++x == width) { fprintf(ofp, "|\n"); --height; x = 0; bitcount = 0; } } fprintf(ofp, " +"); for (x=0; xbits + (pf->offset? pf->offset[i]: (pf->height * i)); bits += WORDS(width) * ascent_correction; height = pf->height - ascent_correction - descent_correction; for (; height>0; --height) { for (x=WORDS(width); x>0; --x) { fprintf(ofp, "0x%04x,", *bits++); } fprintf(ofp, "\n"); } } fprintf(ofp, "};\n\n"); if (pf->offset) { long offset, default_offset; /* output offset table*/ fprintf(ofp, "/* Character->glyph mapping. */\n" "static const unsigned short _%s_offset[] = {\n", pf->name); offset = 0; did_defaultchar = 0; default_offset = 0; for (i=0; isize; ++i) { int width = pf->width ? pf->width[i] : pf->maxwidth; if (pf->offset && (pf->offset[i] == pf->offset[pf->defaultchar-pf->firstchar])) { if (did_defaultchar) { fprintf(ofp, " %ld,\t/* (0x%02x) */\n", default_offset, i + pf->firstchar); continue; } did_defaultchar = 1; default_offset = offset; } fprintf(ofp, " %ld,\t/* (0x%02x) */\n", offset, i + pf->firstchar); offset += WORDS(width) * (pf->height - ascent_correction - descent_correction); } fprintf(ofp, "};\n\n"); } /* output width table for proportional fonts*/ if (pf->width) { fprintf(ofp, "/* Character width data. */\n" "static const unsigned char _%s_width[] = {\n", pf->name); for (i=0; isize; ++i) fprintf(ofp, " %d,\t/* (0x%02x) */\n", pf->width[i], i+pf->firstchar); fprintf(ofp, "};\n\n"); } /* output font_t struct*/ if (pf->offset) sprintf(obuf, "_%s_offset,", pf->name); else sprintf(obuf, "0, /* no encode table*/"); if (pf->width) sprintf(buf, "_%s_width,", pf->name); else sprintf(buf, "0, /* fixed width*/"); fprintf(ofp, "/* Exported structure definition. */\n" "const struct gpanel_font_t font_%s = {\n" " \"%s\",\n" " %d,\n" " %d,\n" " %d,\n" " %d,\n" " %d,\n" " _%s_bits,\n" " %s\n" " %s\n" " %d,\n" " sizeof(_%s_bits) / sizeof(_%s_bits[0]),\n" "};\n", pf->name, pf->name, pf->maxwidth, pf->height - ascent_correction - descent_correction, pf->ascent - ascent_correction, pf->firstchar, pf->size, pf->name, obuf, buf, pf->defaultchar, pf->name, pf->name); return 0; } ================================================ FILE: share/examples/gpanel/fonts/digits20.c ================================================ /* Generated by convbdf on Thu Oct 8 21:26:34 2015. */ #include /* Font information: name: digits20 facename: -FreeType-Lucida Sans Unicode-Medium-R-Normal--28-200-100-100-P-111-ISO10646-1 w x h: 18x22 size: 27 ascent: 21 descent: 1 first char: 32 (0x20) last char: 58 (0x3a) default char: 32 (0x20) proportional: yes Copyright 1993 Bigelow & Holmes Inc. All rights reserved. Pat. Des. 289,420. Pats. Pend. */ /* Font character bitmap data. */ static const unsigned short _digits20_bits[] = { /* Character 32 (0x20): width 9 +---------+ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | +---------+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 48 (0x30): width 18 +------------------+ | | | **** | | ******** | | *** *** | | *** *** | | *** *** | | ** ** | | *** *** | | *** *** | | *** *** | | *** *** | | *** *** | | *** *** | | *** *** | | *** *** | | ** ** | | *** *** | | *** *** | | *** *** | | ******** | | **** | | | +------------------+ */ 0x0000,0x0000, 0x01e0,0x0000, 0x07f8,0x0000, 0x0e1c,0x0000, 0x1c0e,0x0000, 0x1c0e,0x0000, 0x1806,0x0000, 0x3807,0x0000, 0x3807,0x0000, 0x3807,0x0000, 0x3807,0x0000, 0x3807,0x0000, 0x3807,0x0000, 0x3807,0x0000, 0x3807,0x0000, 0x1806,0x0000, 0x1c0e,0x0000, 0x1c0e,0x0000, 0x0e1c,0x0000, 0x07f8,0x0000, 0x01e0,0x0000, 0x0000,0x0000, /* Character 49 (0x31): width 18 +------------------+ | | | *** | | ****** | | ****** | | *** | | *** | | *** | | *** | | *** | | *** | | *** | | *** | | *** | | *** | | *** | | *** | | *** | | *** | | *** | | *** | | *** | | | +------------------+ */ 0x0000,0x0000, 0x01c0,0x0000, 0x0fc0,0x0000, 0x0fc0,0x0000, 0x01c0,0x0000, 0x01c0,0x0000, 0x01c0,0x0000, 0x01c0,0x0000, 0x01c0,0x0000, 0x01c0,0x0000, 0x01c0,0x0000, 0x01c0,0x0000, 0x01c0,0x0000, 0x01c0,0x0000, 0x01c0,0x0000, 0x01c0,0x0000, 0x01c0,0x0000, 0x01c0,0x0000, 0x01c0,0x0000, 0x01c0,0x0000, 0x01c0,0x0000, 0x0000,0x0000, /* Character 50 (0x32): width 18 +------------------+ | | | ******* | | ********* | | * **** | | *** | | *** | | *** | | *** | | *** | | *** | | *** | | *** | | *** | | *** | | *** | | *** | | *** | | *** | | *** | | ************ | | ************ | | | +------------------+ */ 0x0000,0x0000, 0x0fe0,0x0000, 0x1ff0,0x0000, 0x1078,0x0000, 0x001c,0x0000, 0x001c,0x0000, 0x001c,0x0000, 0x001c,0x0000, 0x001c,0x0000, 0x0038,0x0000, 0x0070,0x0000, 0x00e0,0x0000, 0x01c0,0x0000, 0x0380,0x0000, 0x0700,0x0000, 0x0e00,0x0000, 0x1c00,0x0000, 0x1c00,0x0000, 0x3800,0x0000, 0x3ffc,0x0000, 0x3ffc,0x0000, 0x0000,0x0000, /* Character 51 (0x33): width 18 +------------------+ | | | ******* | | ********** | | * *** | | *** | | *** | | *** | | *** | | *** | | *** | | ****** | | ******* | | **** | | **** | | *** | | *** | | *** | | **** | | ** **** | | ********** | | ****** | | | +------------------+ */ 0x0000,0x0000, 0x0fe0,0x0000, 0x1ff8,0x0000, 0x1038,0x0000, 0x001c,0x0000, 0x001c,0x0000, 0x001c,0x0000, 0x001c,0x0000, 0x0038,0x0000, 0x0070,0x0000, 0x07e0,0x0000, 0x07f0,0x0000, 0x003c,0x0000, 0x001e,0x0000, 0x000e,0x0000, 0x000e,0x0000, 0x000e,0x0000, 0x001e,0x0000, 0x183c,0x0000, 0x1ff8,0x0000, 0x07e0,0x0000, 0x0000,0x0000, /* Character 52 (0x34): width 18 +------------------+ | | | *** | | **** | | ***** | | ****** | | ** *** | | ** *** | | *** *** | | *** *** | | ** *** | | ** *** | | *** *** | | *** *** | | *************** | | *************** | | *** | | *** | | *** | | *** | | *** | | *** | | | +------------------+ */ 0x0000,0x0000, 0x0038,0x0000, 0x0078,0x0000, 0x00f8,0x0000, 0x01f8,0x0000, 0x01b8,0x0000, 0x0338,0x0000, 0x0738,0x0000, 0x0e38,0x0000, 0x0c38,0x0000, 0x1838,0x0000, 0x3838,0x0000, 0x7038,0x0000, 0x7fff,0x0000, 0x7fff,0x0000, 0x0038,0x0000, 0x0038,0x0000, 0x0038,0x0000, 0x0038,0x0000, 0x0038,0x0000, 0x0038,0x0000, 0x0000,0x0000, /* Character 53 (0x35): width 18 +------------------+ | | | *********** | | *********** | | *** | | *** | | *** | | *** | | *** | | ****** | | ******** | | ***** | | *** | | *** | | *** | | *** | | *** | | *** | | *** | | **** | | ********* | | ******* | | | +------------------+ */ 0x0000,0x0000, 0x1ffc,0x0000, 0x1ffc,0x0000, 0x1c00,0x0000, 0x1c00,0x0000, 0x1c00,0x0000, 0x1c00,0x0000, 0x1c00,0x0000, 0x1f80,0x0000, 0x1fe0,0x0000, 0x00f8,0x0000, 0x0038,0x0000, 0x001c,0x0000, 0x001c,0x0000, 0x001c,0x0000, 0x001c,0x0000, 0x001c,0x0000, 0x0038,0x0000, 0x0078,0x0000, 0x1ff0,0x0000, 0x1fc0,0x0000, 0x0000,0x0000, /* Character 54 (0x36): width 18 +------------------+ | | | ****** | | ********** | | **** ** | | *** | | *** | | *** | | *** | | *** ***** | | *** ******** | | ***** **** | | **** *** | | *** *** | | *** *** | | *** *** | | *** *** | | *** *** | | *** *** | | *** **** | | ********* | | ***** | | | +------------------+ */ 0x0000,0x0000, 0x01f8,0x0000, 0x07fe,0x0000, 0x0f06,0x0000, 0x0e00,0x0000, 0x1c00,0x0000, 0x1c00,0x0000, 0x3800,0x0000, 0x39f0,0x0000, 0x3bfc,0x0000, 0x3e1e,0x0000, 0x3c0e,0x0000, 0x3807,0x0000, 0x3807,0x0000, 0x3807,0x0000, 0x3807,0x0000, 0x1c07,0x0000, 0x1c0e,0x0000, 0x0e1e,0x0000, 0x07fc,0x0000, 0x01f0,0x0000, 0x0000,0x0000, /* Character 55 (0x37): width 18 +------------------+ | | | ************* | | ************* | | *** | | *** | | *** | | *** | | *** | | ** | | *** | | ** | | *** | | *** | | *** | | *** | | *** | | *** | | *** | | *** | | *** | | *** | | | +------------------+ */ 0x0000,0x0000, 0x1fff,0x0000, 0x1fff,0x0000, 0x0007,0x0000, 0x000e,0x0000, 0x001c,0x0000, 0x001c,0x0000, 0x0038,0x0000, 0x0030,0x0000, 0x0070,0x0000, 0x0060,0x0000, 0x00e0,0x0000, 0x01c0,0x0000, 0x01c0,0x0000, 0x0380,0x0000, 0x0380,0x0000, 0x0700,0x0000, 0x0700,0x0000, 0x0700,0x0000, 0x0e00,0x0000, 0x0e00,0x0000, 0x0000,0x0000, /* Character 56 (0x38): width 18 +------------------+ | | | ****** | | ********* | | *** **** | | *** *** | | *** *** | | *** *** | | **** *** | | **** *** | | ******* | | ******* | | *** ****** | | *** ***** | | ** *** | | *** *** | | *** *** | | *** *** | | **** *** | | **** **** | | ********** | | ****** | | | +------------------+ */ 0x0000,0x0000, 0x03f0,0x0000, 0x07fc,0x0000, 0x0e1e,0x0000, 0x1c0e,0x0000, 0x1c0e,0x0000, 0x1c0e,0x0000, 0x1e1c,0x0000, 0x0f1c,0x0000, 0x07f0,0x0000, 0x07f0,0x0000, 0x0efc,0x0000, 0x1c3e,0x0000, 0x180e,0x0000, 0x3807,0x0000, 0x3807,0x0000, 0x3807,0x0000, 0x3c07,0x0000, 0x1e1e,0x0000, 0x0ffc,0x0000, 0x03f0,0x0000, 0x0000,0x0000, /* Character 57 (0x39): width 18 +------------------+ | | | ***** | | ********* | | **** *** | | *** *** | | *** *** | | *** *** | | *** *** | | *** *** | | *** *** | | *** **** | | **** ***** | | ******** *** | | ***** *** | | ** | | *** | | *** | | *** | | ** *** | | ********* | | ****** | | | +------------------+ */ 0x0000,0x0000, 0x03e0,0x0000, 0x0ff8,0x0000, 0x1e1c,0x0000, 0x1c0e,0x0000, 0x380e,0x0000, 0x3807,0x0000, 0x3807,0x0000, 0x3807,0x0000, 0x3807,0x0000, 0x1c0f,0x0000, 0x1e1f,0x0000, 0x0ff7,0x0000, 0x03e7,0x0000, 0x0006,0x0000, 0x000e,0x0000, 0x000e,0x0000, 0x001c,0x0000, 0x1838,0x0000, 0x1ff0,0x0000, 0x0fc0,0x0000, 0x0000,0x0000, /* Character 58 (0x3a): width 9 +---------+ | | | | | | | | | | | | | *** | | *** | | *** | | | | | | | | | | | | | | | | | | | | *** | | *** | | *** | | | +---------+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x1c00, 0x1c00, 0x1c00, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x1c00, 0x1c00, 0x1c00, 0x0000, }; /* Character->glyph mapping. */ static const unsigned short _digits20_offset[] = { 0, /* (0x20) */ 0, /* (0x21) */ 0, /* (0x22) */ 0, /* (0x23) */ 0, /* (0x24) */ 0, /* (0x25) */ 0, /* (0x26) */ 0, /* (0x27) */ 0, /* (0x28) */ 0, /* (0x29) */ 0, /* (0x2a) */ 0, /* (0x2b) */ 0, /* (0x2c) */ 0, /* (0x2d) */ 0, /* (0x2e) */ 0, /* (0x2f) */ 22, /* (0x30) */ 66, /* (0x31) */ 110, /* (0x32) */ 154, /* (0x33) */ 198, /* (0x34) */ 242, /* (0x35) */ 286, /* (0x36) */ 330, /* (0x37) */ 374, /* (0x38) */ 418, /* (0x39) */ 462, /* (0x3a) */ }; /* Character width data. */ static const unsigned char _digits20_width[] = { 9, /* (0x20) */ 9, /* (0x21) */ 9, /* (0x22) */ 9, /* (0x23) */ 9, /* (0x24) */ 9, /* (0x25) */ 9, /* (0x26) */ 9, /* (0x27) */ 9, /* (0x28) */ 9, /* (0x29) */ 9, /* (0x2a) */ 9, /* (0x2b) */ 9, /* (0x2c) */ 9, /* (0x2d) */ 9, /* (0x2e) */ 9, /* (0x2f) */ 18, /* (0x30) */ 18, /* (0x31) */ 18, /* (0x32) */ 18, /* (0x33) */ 18, /* (0x34) */ 18, /* (0x35) */ 18, /* (0x36) */ 18, /* (0x37) */ 18, /* (0x38) */ 18, /* (0x39) */ 9, /* (0x3a) */ }; /* Exported structure definition. */ const struct gpanel_font_t font_digits20 = { "digits20", 18, 22, 21, 32, 27, _digits20_bits, _digits20_offset, _digits20_width, 32, sizeof(_digits20_bits) / sizeof(_digits20_bits[0]), }; ================================================ FILE: share/examples/gpanel/fonts/digits32.c ================================================ /* Generated by convbdf on Thu Oct 8 21:26:34 2015. */ #include /* Font information: name: digits32 facename: -FreeType-Lucida Sans Unicode-Medium-R-Normal--44-320-100-100-P-170-ISO10646-1 w x h: 28x40 size: 27 ascent: 36 descent: 4 first char: 32 (0x20) last char: 58 (0x3a) default char: 32 (0x20) proportional: yes Copyright 1993 Bigelow & Holmes Inc. All rights reserved. Pat. Des. 289,420. Pats. Pend. */ /* Font character bitmap data. */ static const unsigned short _digits32_bits[] = { /* Character 32 (0x20): width 14 +--------------+ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | +--------------+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 48 (0x30): width 28 +----------------------------+ | | | | | | | ****** | | ********** | | ************ | | ***** ***** | | ***** ***** | | ***** **** | | **** ***** | | **** **** | | ***** ***** | | ***** ***** | | **** **** | | ***** ***** | | ***** ***** | | ***** ***** | | ***** ***** | | ***** ***** | | ***** ***** | | ***** ***** | | ***** ***** | | ***** ***** | | ***** ***** | | ***** ***** | | ***** ***** | | **** **** | | ***** ***** | | ***** ***** | | **** **** | | **** ***** | | ***** **** | | ***** ***** | | ***** ***** | | ************ | | ********** | | ****** | | | | | | | +----------------------------+ */ 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x001f,0x8000, 0x007f,0xe000, 0x00ff,0xf000, 0x01f0,0xf800, 0x03e0,0x7c00, 0x07c0,0x3c00, 0x0780,0x3e00, 0x0780,0x1e00, 0x0f80,0x1f00, 0x0f80,0x1f00, 0x0f00,0x0f00, 0x1f00,0x0f80, 0x1f00,0x0f80, 0x1f00,0x0f80, 0x1f00,0x0f80, 0x1f00,0x0f80, 0x1f00,0x0f80, 0x1f00,0x0f80, 0x1f00,0x0f80, 0x1f00,0x0f80, 0x1f00,0x0f80, 0x1f00,0x0f80, 0x1f00,0x0f80, 0x0f00,0x0f00, 0x0f80,0x1f00, 0x0f80,0x1f00, 0x0780,0x1e00, 0x0780,0x3e00, 0x07c0,0x3c00, 0x03e0,0x7c00, 0x01f0,0xf800, 0x00ff,0xf000, 0x007f,0xe000, 0x001f,0x8000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, /* Character 49 (0x31): width 28 +----------------------------+ | | | | | | | | | ***** | | ********* | | ********* | | ********* | | ***** | | ***** | | ***** | | ***** | | ***** | | ***** | | ***** | | ***** | | ***** | | ***** | | ***** | | ***** | | ***** | | ***** | | ***** | | ***** | | ***** | | ***** | | ***** | | ***** | | ***** | | ***** | | ***** | | ***** | | ***** | | ***** | | ***** | | ***** | | | | | | | | | +----------------------------+ */ 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x000f,0x8000, 0x00ff,0x8000, 0x00ff,0x8000, 0x00ff,0x8000, 0x000f,0x8000, 0x000f,0x8000, 0x000f,0x8000, 0x000f,0x8000, 0x000f,0x8000, 0x000f,0x8000, 0x000f,0x8000, 0x000f,0x8000, 0x000f,0x8000, 0x000f,0x8000, 0x000f,0x8000, 0x000f,0x8000, 0x000f,0x8000, 0x000f,0x8000, 0x000f,0x8000, 0x000f,0x8000, 0x000f,0x8000, 0x000f,0x8000, 0x000f,0x8000, 0x000f,0x8000, 0x000f,0x8000, 0x000f,0x8000, 0x000f,0x8000, 0x000f,0x8000, 0x000f,0x8000, 0x000f,0x8000, 0x000f,0x8000, 0x000f,0x8000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, /* Character 50 (0x32): width 28 +----------------------------+ | | | | | | | ******** | | ************* | | *************** | | ***** ****** | | ** ****** | | * ***** | | ***** | | ***** | | ***** | | ***** | | ***** | | ***** | | ***** | | ***** | | ***** | | ****** | | ****** | | ****** | | ****** | | ***** | | ***** | | ***** | | ***** | | ***** | | **** | | ***** | | ***** | | **** | | ***** | | ******************* | | ******************* | | ******************* | | ******************* | | | | | | | | | +----------------------------+ */ 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x007f,0x8000, 0x03ff,0xe000, 0x07ff,0xf000, 0x07c1,0xf800, 0x0600,0xfc00, 0x0400,0x7c00, 0x0000,0x3e00, 0x0000,0x3e00, 0x0000,0x3e00, 0x0000,0x3e00, 0x0000,0x3e00, 0x0000,0x3e00, 0x0000,0x7c00, 0x0000,0x7c00, 0x0000,0xf800, 0x0001,0xf800, 0x0003,0xf000, 0x0007,0xe000, 0x000f,0xc000, 0x001f,0x0000, 0x003e,0x0000, 0x007c,0x0000, 0x00f8,0x0000, 0x01f0,0x0000, 0x01e0,0x0000, 0x03e0,0x0000, 0x07c0,0x0000, 0x0780,0x0000, 0x0f80,0x0000, 0x0fff,0xfe00, 0x0fff,0xfe00, 0x0fff,0xfe00, 0x0fff,0xfe00, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, /* Character 51 (0x33): width 28 +----------------------------+ | | | | | | | ********** | | *************** | | **************** | | **** ******* | | * ***** | | ****** | | ***** | | ***** | | ***** | | ***** | | ***** | | ***** | | ***** | | ***** | | ****** | | ********** | | ********* | | ************ | | ******* | | ****** | | ***** | | ***** | | ***** | | ***** | | ***** | | ***** | | ***** | | ****** | | ***** | | * ****** | | **** ******* | | **************** | | ************** | | ********* | | | | | | | +----------------------------+ */ 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x03ff,0x0000, 0x0fff,0xe000, 0x0fff,0xf000, 0x0f03,0xf800, 0x0800,0xf800, 0x0000,0xfc00, 0x0000,0x7c00, 0x0000,0x7c00, 0x0000,0x7c00, 0x0000,0x7c00, 0x0000,0x7c00, 0x0000,0xf800, 0x0000,0xf800, 0x0001,0xf000, 0x000f,0xc000, 0x01ff,0x8000, 0x01ff,0x0000, 0x01ff,0xe000, 0x0007,0xf000, 0x0001,0xf800, 0x0000,0x7c00, 0x0000,0x7c00, 0x0000,0x3e00, 0x0000,0x3e00, 0x0000,0x3e00, 0x0000,0x3e00, 0x0000,0x3e00, 0x0000,0x7e00, 0x0000,0x7c00, 0x0800,0xfc00, 0x0f03,0xf800, 0x0fff,0xf000, 0x0fff,0xc000, 0x01ff,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, /* Character 52 (0x34): width 28 +----------------------------+ | | | | | | | | | **** | | ***** | | ****** | | ****** | | ******* | | ******** | | **** **** | | *** **** | | **** **** | | **** **** | | *** **** | | **** **** | | **** **** | | *** **** | | **** **** | | **** **** | | **** **** | | *** **** | | **** **** | | **** **** | | ********************** | | ********************** | | ********************** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | | | | | | | | +----------------------------+ */ 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0xf000, 0x0001,0xf000, 0x0003,0xf000, 0x0003,0xf000, 0x0007,0xf000, 0x000f,0xf000, 0x001e,0xf000, 0x001c,0xf000, 0x003c,0xf000, 0x0078,0xf000, 0x0070,0xf000, 0x00f0,0xf000, 0x01e0,0xf000, 0x01c0,0xf000, 0x03c0,0xf000, 0x0780,0xf000, 0x0f00,0xf000, 0x0e00,0xf000, 0x1e00,0xf000, 0x3c00,0xf000, 0x3fff,0xff00, 0x3fff,0xff00, 0x3fff,0xff00, 0x0000,0xf000, 0x0000,0xf000, 0x0000,0xf000, 0x0000,0xf000, 0x0000,0xf000, 0x0000,0xf000, 0x0000,0xf000, 0x0000,0xf000, 0x0000,0xf000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, /* Character 53 (0x35): width 28 +----------------------------+ | | | | | | | | | *************** | | *************** | | *************** | | *************** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | ******** | | *********** | | ************ | | ******* | | ****** | | ****** | | ***** | | ****** | | ***** | | ***** | | ***** | | ***** | | ***** | | ***** | | ***** | | ***** | | * ***** | | *** ******* | | ************** | | ************ | | ******** | | | | | | | +----------------------------+ */ 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x03ff,0xf800, 0x03ff,0xf800, 0x03ff,0xf800, 0x03ff,0xf800, 0x03c0,0x0000, 0x03c0,0x0000, 0x03c0,0x0000, 0x03c0,0x0000, 0x03c0,0x0000, 0x03c0,0x0000, 0x03c0,0x0000, 0x03c0,0x0000, 0x03fc,0x0000, 0x03ff,0x8000, 0x03ff,0xc000, 0x000f,0xe000, 0x0003,0xf000, 0x0001,0xf800, 0x0000,0xf800, 0x0000,0xfc00, 0x0000,0x7c00, 0x0000,0x7c00, 0x0000,0x7c00, 0x0000,0x7c00, 0x0000,0x7c00, 0x0000,0x7c00, 0x0000,0xf800, 0x0000,0xf800, 0x0401,0xf000, 0x0707,0xf000, 0x07ff,0xe000, 0x07ff,0x8000, 0x01fe,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, /* Character 54 (0x36): width 28 +----------------------------+ | | | | | | | ********* | | ************* | | *************** | | ****** **** | | ***** * | | **** | | ***** | | **** | | ***** | | ***** | | **** | | **** | | ***** ****** | | ***** ********** | | ***** ************* | | ********* ******* | | ******* ****** | | ****** ***** | | ****** ***** | | ***** ***** | | ***** ***** | | ***** ***** | | ***** ***** | | **** ***** | | **** ***** | | **** ***** | | ***** **** | | **** ***** | | ***** ***** | | ***** ***** | | ***** ***** | | ************* | | *********** | | ******* | | | | | | | +----------------------------+ */ 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x000f,0xf800, 0x003f,0xfe00, 0x00ff,0xfe00, 0x01f8,0x1e00, 0x03e0,0x0200, 0x03c0,0x0000, 0x07c0,0x0000, 0x0780,0x0000, 0x0f80,0x0000, 0x0f80,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x1f07,0xe000, 0x1f1f,0xf800, 0x1f7f,0xfc00, 0x1ff0,0xfe00, 0x1fc0,0x3f00, 0x1f80,0x1f00, 0x1f80,0x1f00, 0x1f00,0x0f80, 0x1f00,0x0f80, 0x1f00,0x0f80, 0x1f00,0x0f80, 0x0f00,0x0f80, 0x0f00,0x0f80, 0x0f00,0x0f80, 0x0f80,0x0f00, 0x0780,0x1f00, 0x07c0,0x1f00, 0x03e0,0x3e00, 0x01f0,0x7c00, 0x00ff,0xf800, 0x007f,0xf000, 0x001f,0xc000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, /* Character 55 (0x37): width 28 +----------------------------+ | | | | | | | | | ******************** | | ******************** | | ******************** | | ******************** | | ***** | | ***** | | **** | | ***** | | ***** | | ***** | | ***** | | **** | | ***** | | **** | | ***** | | **** | | ***** | | **** | | ***** | | ***** | | ***** | | ***** | | ***** | | ***** | | ***** | | ***** | | ***** | | ***** | | ***** | | ***** | | ***** | | ***** | | | | | | | | | +----------------------------+ */ 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x07ff,0xff80, 0x07ff,0xff80, 0x07ff,0xff80, 0x07ff,0xff80, 0x0000,0x0f80, 0x0000,0x1f00, 0x0000,0x1e00, 0x0000,0x3e00, 0x0000,0x7c00, 0x0000,0x7c00, 0x0000,0xf800, 0x0000,0xf000, 0x0001,0xf000, 0x0001,0xe000, 0x0003,0xe000, 0x0003,0xc000, 0x0007,0xc000, 0x0007,0x8000, 0x000f,0x8000, 0x001f,0x0000, 0x001f,0x0000, 0x003e,0x0000, 0x003e,0x0000, 0x007c,0x0000, 0x007c,0x0000, 0x007c,0x0000, 0x00f8,0x0000, 0x00f8,0x0000, 0x00f8,0x0000, 0x01f0,0x0000, 0x01f0,0x0000, 0x01f0,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, /* Character 56 (0x38): width 28 +----------------------------+ | | | | | | | ******* | | *********** | | ************** | | ****** ****** | | **** ***** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | ***** **** | | ***** **** | | ****** **** | | ******* **** | | *********** | | ******** | | *********** | | ************* | | ***** ******* | | ***** ******* | | ***** ****** | | ***** ***** | | ***** ***** | | ***** **** | | ***** **** | | ***** **** | | ***** **** | | ***** **** | | ***** **** | | ****** ***** | | ****** ***** | | *************** | | ************* | | ******* | | | | | | | +----------------------------+ */ 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x000f,0xe000, 0x003f,0xf800, 0x00ff,0xfc00, 0x01f8,0x7e00, 0x01e0,0x1f00, 0x03c0,0x0f00, 0x03c0,0x0f00, 0x03c0,0x0f00, 0x03c0,0x0f00, 0x03c0,0x0f00, 0x03e0,0x1e00, 0x01f0,0x1e00, 0x01f8,0x3c00, 0x00fe,0x7800, 0x007f,0xf000, 0x003f,0xc000, 0x007f,0xf000, 0x00ff,0xf800, 0x01f1,0xfc00, 0x03e0,0xfe00, 0x07c0,0x3f00, 0x07c0,0x1f00, 0x0f80,0x0f80, 0x0f80,0x0780, 0x0f80,0x0780, 0x0f80,0x0780, 0x0f80,0x0780, 0x0f80,0x0780, 0x07c0,0x0f00, 0x07e0,0x1f00, 0x03f0,0x3e00, 0x01ff,0xfc00, 0x00ff,0xf800, 0x001f,0xc000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, /* Character 57 (0x39): width 28 +----------------------------+ | | | | | | | ******* | | *********** | | ************* | | ***** ***** | | ***** ***** | | ***** ***** | | ***** **** | | **** ***** | | ***** **** | | ***** **** | | ***** **** | | ***** ***** | | ***** ***** | | ***** ***** | | ***** ***** | | ***** ****** | | ***** ****** | | ***** ******* | | ******* ********* | | ************* ***** | | ********* ***** | | ***** **** | | **** | | ***** | | ***** | | **** | | ***** | | **** | | ***** | | * ***** | | **** ****** | | ************** | | ************* | | ******** | | | | | | | +----------------------------+ */ 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x003f,0x8000, 0x00ff,0xe000, 0x01ff,0xf000, 0x03e0,0xf800, 0x07c0,0x7c00, 0x0f80,0x3e00, 0x0f80,0x1e00, 0x0f00,0x1f00, 0x1f00,0x0f00, 0x1f00,0x0f00, 0x1f00,0x0f00, 0x1f00,0x0f80, 0x1f00,0x0f80, 0x1f00,0x0f80, 0x1f00,0x0f80, 0x0f80,0x1f80, 0x0f80,0x1f80, 0x07c0,0x3f80, 0x07f0,0xff80, 0x03ff,0xef80, 0x00ff,0x8f80, 0x003e,0x0f00, 0x0000,0x0f00, 0x0000,0x1f00, 0x0000,0x1f00, 0x0000,0x1e00, 0x0000,0x3e00, 0x0000,0x3c00, 0x0000,0x7c00, 0x0400,0xf800, 0x0783,0xf000, 0x07ff,0xe000, 0x07ff,0xc000, 0x01fe,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, /* Character 58 (0x3a): width 14 +--------------+ | | | | | | | | | | | | | | | | | | | | | | | | | | | ***** | | ***** | | ***** | | ***** | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ***** | | ***** | | ***** | | ***** | | | | | | | | | +--------------+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x07c0, 0x07c0, 0x07c0, 0x07c0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x07c0, 0x07c0, 0x07c0, 0x07c0, 0x0000, 0x0000, 0x0000, 0x0000, }; /* Character->glyph mapping. */ static const unsigned short _digits32_offset[] = { 0, /* (0x20) */ 0, /* (0x21) */ 0, /* (0x22) */ 0, /* (0x23) */ 0, /* (0x24) */ 0, /* (0x25) */ 0, /* (0x26) */ 0, /* (0x27) */ 0, /* (0x28) */ 0, /* (0x29) */ 0, /* (0x2a) */ 0, /* (0x2b) */ 0, /* (0x2c) */ 0, /* (0x2d) */ 0, /* (0x2e) */ 0, /* (0x2f) */ 40, /* (0x30) */ 120, /* (0x31) */ 200, /* (0x32) */ 280, /* (0x33) */ 360, /* (0x34) */ 440, /* (0x35) */ 520, /* (0x36) */ 600, /* (0x37) */ 680, /* (0x38) */ 760, /* (0x39) */ 840, /* (0x3a) */ }; /* Character width data. */ static const unsigned char _digits32_width[] = { 14, /* (0x20) */ 14, /* (0x21) */ 14, /* (0x22) */ 14, /* (0x23) */ 14, /* (0x24) */ 14, /* (0x25) */ 14, /* (0x26) */ 14, /* (0x27) */ 14, /* (0x28) */ 14, /* (0x29) */ 14, /* (0x2a) */ 14, /* (0x2b) */ 14, /* (0x2c) */ 14, /* (0x2d) */ 14, /* (0x2e) */ 14, /* (0x2f) */ 28, /* (0x30) */ 28, /* (0x31) */ 28, /* (0x32) */ 28, /* (0x33) */ 28, /* (0x34) */ 28, /* (0x35) */ 28, /* (0x36) */ 28, /* (0x37) */ 28, /* (0x38) */ 28, /* (0x39) */ 14, /* (0x3a) */ }; /* Exported structure definition. */ const struct gpanel_font_t font_digits32 = { "digits32", 28, 40, 36, 32, 27, _digits32_bits, _digits32_offset, _digits32_width, 32, sizeof(_digits32_bits) / sizeof(_digits32_bits[0]), }; ================================================ FILE: share/examples/gpanel/fonts/lucidasans11.c ================================================ /* Generated by convbdf on Thu Oct 8 21:26:34 2015. */ #include /* Font information: name: lucidasans11 facename: -FreeType-Lucida Sans Unicode-Medium-R-Normal--15-110-100-100-P-71-ISO10646-1 w x h: 14x17 size: 133 ascent: 14 descent: 3 first char: 32 (0x20) last char: 164 (0xa4) default char: 164 (0xa4) proportional: yes Copyright 1993 Bigelow & Holmes Inc. All rights reserved. Pat. Des. 289,420. Pats. Pend. */ /* Font character bitmap data. */ static const unsigned short _lucidasans11_bits[] = { /* Character 32 (0x20): width 5 +-----+ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | +-----+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 33 (0x21): width 5 +-----+ | | | | | | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | | | ** | | | | | | | +-----+ */ 0x0000, 0x0000, 0x0000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x0000, 0x3000, 0x0000, 0x0000, 0x0000, /* Character 34 (0x22): width 6 +------+ | | | | | ** **| | ** **| | ** **| | ** **| | | | | | | | | | | | | | | | | | | | | | | +------+ */ 0x0000, 0x0000, 0x6c00, 0x6c00, 0x6c00, 0x6c00, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 35 (0x23): width 9 +---------+ | | | | | | | * * | | * * | | * * | | ********| | * * | | ** ** | | * * | |******** | | * * | | * * | | * * | | | | | | | +---------+ */ 0x0000, 0x0000, 0x0000, 0x0900, 0x0900, 0x1200, 0x7f80, 0x1200, 0x3600, 0x2400, 0xff00, 0x2400, 0x4800, 0x4800, 0x0000, 0x0000, 0x0000, /* Character 36 (0x24): width 9 +---------+ | | | | | * | | ***** | | ** * * | | ** * | | ** * | | *** | | ** | | * * | | * ** | | * ** | | * * ** | | **** | | * | | | | | +---------+ */ 0x0000, 0x0000, 0x0800, 0x3e00, 0x6900, 0x6800, 0x6800, 0x3800, 0x0c00, 0x0a00, 0x0b00, 0x0b00, 0x4b00, 0x3c00, 0x0800, 0x0000, 0x0000, /* Character 37 (0x25): width 10 +----------+ | | | | | | | *** *| |* * * | |* * * | |* * * | | *** * | | * | | * *** | | * * *| | * * *| | * * *| |* *** | | | | | | | +----------+ */ 0x0000, 0x0000, 0x0000, 0x7040, 0x8880, 0x8900, 0x8a00, 0x7400, 0x0800, 0x0b80, 0x1440, 0x2440, 0x4440, 0x8380, 0x0000, 0x0000, 0x0000, /* Character 38 (0x26): width 10 +----------+ | | | | | | | *** | | ** ** | | ** ** | | ** ** | | *** | | **** **| | ** ** **| | ** * **| | ** *** | | ** ** | | **** **| | | | | | | +----------+ */ 0x0000, 0x0000, 0x0000, 0x0e00, 0x1b00, 0x1b00, 0x1b00, 0x0e00, 0x3cc0, 0x66c0, 0x62c0, 0x6380, 0x3180, 0x1ec0, 0x0000, 0x0000, 0x0000, /* Character 39 (0x27): width 3 +---+ | | | | | **| | **| | **| | **| | | | | | | | | | | | | | | | | | | | | | | +---+ */ 0x0000, 0x0000, 0x6000, 0x6000, 0x6000, 0x6000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 40 (0x28): width 5 +-----+ | | | | | * | | * | | * | | * | | ** | | ** | | ** | | ** | | ** | | ** | | * | | * | | * | | * | | | +-----+ */ 0x0000, 0x0000, 0x1000, 0x1000, 0x2000, 0x2000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x2000, 0x2000, 0x1000, 0x1000, 0x0000, /* Character 41 (0x29): width 5 +-----+ | | | | | * | | * | | * | | * | | ** | | ** | | ** | | ** | | ** | | ** | | * | | * | | * | | * | | | +-----+ */ 0x0000, 0x0000, 0x4000, 0x4000, 0x2000, 0x2000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x2000, 0x2000, 0x4000, 0x4000, 0x0000, /* Character 42 (0x2a): width 7 +-------+ | | | | | | | * | | * * * | | * * | | * * | | * * | | | | | | | | | | | | | | | | | | | +-------+ */ 0x0000, 0x0000, 0x0000, 0x1000, 0x5400, 0x2800, 0x2800, 0x2800, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 43 (0x2b): width 12 +------------+ | | | | | | | | | | | * | | * | | * | | * | | ********* | | * | | * | | * | | * | | | | | | | +------------+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0200, 0x0200, 0x0200, 0x0200, 0x3fe0, 0x0200, 0x0200, 0x0200, 0x0200, 0x0000, 0x0000, 0x0000, /* Character 44 (0x2c): width 5 +-----+ | | | | | | | | | | | | | | | | | | | | | | | | | ** | | ** | | * | | * | | | +-----+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x6000, 0x6000, 0x2000, 0x4000, 0x0000, /* Character 45 (0x2d): width 9 +---------+ | | | | | | | | | | | | | | | | | | | ******* | | | | | | | | | | | | | | | +---------+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x7f00, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 46 (0x2e): width 5 +-----+ | | | | | | | | | | | | | | | | | | | | | | | | | ** | | ** | | | | | | | +-----+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x6000, 0x6000, 0x0000, 0x0000, 0x0000, /* Character 47 (0x2f): width 8 +--------+ | | | | | | | * | | * | | * | | * | | * | | * | | * | | * | | * | | * | | * | | * | | * | | | +--------+ */ 0x0000, 0x0000, 0x0000, 0x0200, 0x0200, 0x0400, 0x0400, 0x0400, 0x0800, 0x0800, 0x0800, 0x1000, 0x1000, 0x1000, 0x2000, 0x2000, 0x0000, /* Character 48 (0x30): width 9 +---------+ | | | | | | | **** | | ** ** | | * * | | ** **| | ** **| | ** **| | ** **| | ** **| | * * | | ** ** | | **** | | | | | | | +---------+ */ 0x0000, 0x0000, 0x0000, 0x1e00, 0x3300, 0x2100, 0x6180, 0x6180, 0x6180, 0x6180, 0x6180, 0x2100, 0x3300, 0x1e00, 0x0000, 0x0000, 0x0000, /* Character 49 (0x31): width 9 +---------+ | | | | | | | *** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | | | | | | +---------+ */ 0x0000, 0x0000, 0x0000, 0x1c00, 0x0c00, 0x0c00, 0x0c00, 0x0c00, 0x0c00, 0x0c00, 0x0c00, 0x0c00, 0x0c00, 0x0c00, 0x0000, 0x0000, 0x0000, /* Character 50 (0x32): width 9 +---------+ | | | | | | | ***** | | * ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ******* | | | | | | | +---------+ */ 0x0000, 0x0000, 0x0000, 0x3e00, 0x4300, 0x0300, 0x0300, 0x0300, 0x0600, 0x0c00, 0x1800, 0x3000, 0x6000, 0x7f00, 0x0000, 0x0000, 0x0000, /* Character 51 (0x33): width 9 +---------+ | | | | | | | **** | | * ** | | ** | | ** | | ** | | *** | | ** | | ** | | ** | | * ** | | **** | | | | | | | +---------+ */ 0x0000, 0x0000, 0x0000, 0x1e00, 0x2300, 0x0300, 0x0300, 0x0600, 0x1c00, 0x0600, 0x0300, 0x0300, 0x2300, 0x1e00, 0x0000, 0x0000, 0x0000, /* Character 52 (0x34): width 9 +---------+ | | | | | | | ** | | *** | | *** | | * ** | | * ** | | * ** | | * ** | | ******* | | ** | | ** | | ** | | | | | | | +---------+ */ 0x0000, 0x0000, 0x0000, 0x0600, 0x0e00, 0x0e00, 0x1600, 0x2600, 0x2600, 0x4600, 0x7f00, 0x0600, 0x0600, 0x0600, 0x0000, 0x0000, 0x0000, /* Character 53 (0x35): width 9 +---------+ | | | | | | | ****** | | ** | | ** | | ** | | **** | | ** | | ** | | ** | | ** | | ** | | **** | | | | | | | +---------+ */ 0x0000, 0x0000, 0x0000, 0x3f00, 0x3000, 0x3000, 0x3000, 0x3c00, 0x0600, 0x0300, 0x0300, 0x0300, 0x0600, 0x3c00, 0x0000, 0x0000, 0x0000, /* Character 54 (0x36): width 9 +---------+ | | | | | | | **** | | ** | | * | | ** | | ** ** | | *** ** | | ** ** | | ** ** | | ** ** | | ** ** | | *** | | | | | | | +---------+ */ 0x0000, 0x0000, 0x0000, 0x1e00, 0x3000, 0x2000, 0x6000, 0x6c00, 0x7600, 0x6300, 0x6300, 0x6300, 0x3600, 0x1c00, 0x0000, 0x0000, 0x0000, /* Character 55 (0x37): width 9 +---------+ | | | | | | | *******| | *| | * | | ** | | * | | ** | | * | | ** | | ** | | ** | | ** | | | | | | | +---------+ */ 0x0000, 0x0000, 0x0000, 0x3f80, 0x0080, 0x0100, 0x0300, 0x0200, 0x0600, 0x0400, 0x0c00, 0x0c00, 0x1800, 0x1800, 0x0000, 0x0000, 0x0000, /* Character 56 (0x38): width 9 +---------+ | | | | | | | **** | | ** ** | | ** ** | | ** ** | | ** * | | ***** | | ** *** | | ** ** | | ** ** | | ** ** | | ***** | | | | | | | +---------+ */ 0x0000, 0x0000, 0x0000, 0x1e00, 0x3300, 0x3300, 0x3300, 0x1a00, 0x3e00, 0x6700, 0x6300, 0x6300, 0x6300, 0x3e00, 0x0000, 0x0000, 0x0000, /* Character 57 (0x39): width 9 +---------+ | | | | | | | *** | | ** ** | | ** ** | | ** ** | | ** ** | | ** *** | | ** ** | | ** | | * | | ** | | **** | | | | | | | +---------+ */ 0x0000, 0x0000, 0x0000, 0x1c00, 0x3600, 0x6300, 0x6300, 0x6300, 0x3700, 0x1b00, 0x0300, 0x0200, 0x0600, 0x3c00, 0x0000, 0x0000, 0x0000, /* Character 58 (0x3a): width 5 +-----+ | | | | | | | | | | | | | ** | | | | | | | | | | | | | | ** | | | | | | | +-----+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x3000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x3000, 0x0000, 0x0000, 0x0000, /* Character 59 (0x3b): width 5 +-----+ | | | | | | | | | | | | | ** | | | | | | | | | | | | | | ** | | * | | * | | | +-----+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x3000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x3000, 0x1000, 0x2000, 0x0000, /* Character 60 (0x3c): width 12 +------------+ | | | | | | | | | | | * | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | * | | | | | | | +------------+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0020, 0x00c0, 0x0300, 0x0c00, 0x3000, 0x0c00, 0x0300, 0x00c0, 0x0020, 0x0000, 0x0000, 0x0000, /* Character 61 (0x3d): width 12 +------------+ | | | | | | | | | | | | | | | | | ******** | | | | ******** | | | | | | | | | | | | | +------------+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x3fc0, 0x0000, 0x3fc0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 62 (0x3e): width 12 +------------+ | | | | | | | | | | | * | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | * | | | | | | | +------------+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x2000, 0x1800, 0x0600, 0x0180, 0x0060, 0x0180, 0x0600, 0x1800, 0x2000, 0x0000, 0x0000, 0x0000, /* Character 63 (0x3f): width 6 +------+ | | | | | | |***** | | **| | **| | **| | ** | | ** | | * | | ** | | ** | | | | ** | | | | | | | +------+ */ 0x0000, 0x0000, 0x0000, 0xf800, 0x0c00, 0x0c00, 0x0c00, 0x1800, 0x3000, 0x2000, 0x6000, 0x6000, 0x0000, 0x6000, 0x0000, 0x0000, 0x0000, /* Character 64 (0x40): width 13 +-------------+ | | | | | | | ***** | | ** * | | ** *** * | | * * * * | | * * * * | | * * * * | | * * * * | | * * ** * | | ** *** ** | | ** | | ***** | | | | | | | +-------------+ */ 0x0000, 0x0000, 0x0000, 0x07c0, 0x1820, 0x3390, 0x2490, 0x4490, 0x4890, 0x4890, 0x49a0, 0x6ec0, 0x3000, 0x1f00, 0x0000, 0x0000, 0x0000, /* Character 65 (0x41): width 10 +----------+ | | | | | | | ** | | ** | | * ** | | * ** | | * ** | | * ** | | * ** | | ******** | | * ** | | * ** | |* **| | | | | | | +----------+ */ 0x0000, 0x0000, 0x0000, 0x0c00, 0x0c00, 0x1600, 0x1600, 0x1600, 0x2300, 0x2300, 0x7f80, 0x4180, 0x4180, 0x80c0, 0x0000, 0x0000, 0x0000, /* Character 66 (0x42): width 9 +---------+ | | | | | | | ****** | | ** ** | | ** ** | | ** ** | | ** ** | | ***** | | ** ** | | ** ** | | ** ** | | ** ** | | ****** | | | | | | | +---------+ */ 0x0000, 0x0000, 0x0000, 0x7e00, 0x6300, 0x6300, 0x6300, 0x6600, 0x7c00, 0x6600, 0x6300, 0x6300, 0x6300, 0x7e00, 0x0000, 0x0000, 0x0000, /* Character 67 (0x43): width 11 +-----------+ | | | | | | | ***** | | *** * | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | *** * | | ***** | | | | | | | +-----------+ */ 0x0000, 0x0000, 0x0000, 0x0f80, 0x3840, 0x3000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x3000, 0x3840, 0x0f80, 0x0000, 0x0000, 0x0000, /* Character 68 (0x44): width 11 +-----------+ | | | | | | | ****** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ****** | | | | | | | +-----------+ */ 0x0000, 0x0000, 0x0000, 0x7e00, 0x6180, 0x6180, 0x60c0, 0x60c0, 0x60c0, 0x60c0, 0x60c0, 0x6180, 0x6180, 0x7e00, 0x0000, 0x0000, 0x0000, /* Character 69 (0x45): width 8 +--------+ | | | | | | | ****** | | ** | | ** | | ** | | ** | | ***** | | ** | | ** | | ** | | ** | | ****** | | | | | | | +--------+ */ 0x0000, 0x0000, 0x0000, 0x7e00, 0x6000, 0x6000, 0x6000, 0x6000, 0x7c00, 0x6000, 0x6000, 0x6000, 0x6000, 0x7e00, 0x0000, 0x0000, 0x0000, /* Character 70 (0x46): width 8 +--------+ | | | | | | | ****** | | ** | | ** | | ** | | ** | | ***** | | ** | | ** | | ** | | ** | | ** | | | | | | | +--------+ */ 0x0000, 0x0000, 0x0000, 0x7e00, 0x6000, 0x6000, 0x6000, 0x6000, 0x7c00, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x0000, 0x0000, 0x0000, /* Character 71 (0x47): width 11 +-----------+ | | | | | | | ****** | | *** | | ** | | ** | | ** | | ** | | ** ** | | ** ** | | ** ** | | *** ** | | ****** | | | | | | | +-----------+ */ 0x0000, 0x0000, 0x0000, 0x0fc0, 0x3800, 0x3000, 0x6000, 0x6000, 0x6000, 0x60c0, 0x60c0, 0x30c0, 0x38c0, 0x0fc0, 0x0000, 0x0000, 0x0000, /* Character 72 (0x48): width 11 +-----------+ | | | | | | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ********* | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | | | | | | +-----------+ */ 0x0000, 0x0000, 0x0000, 0x60c0, 0x60c0, 0x60c0, 0x60c0, 0x60c0, 0x7fc0, 0x60c0, 0x60c0, 0x60c0, 0x60c0, 0x60c0, 0x0000, 0x0000, 0x0000, /* Character 73 (0x49): width 4 +----+ | | | | | | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | | | | | | +----+ */ 0x0000, 0x0000, 0x0000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x0000, 0x0000, 0x0000, /* Character 74 (0x4a): width 6 +------+ | | | | | | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | |**** | | | +------+ */ 0x0000, 0x0000, 0x0000, 0x1800, 0x1800, 0x1800, 0x1800, 0x1800, 0x1800, 0x1800, 0x1800, 0x1800, 0x1800, 0x1800, 0x1800, 0xf000, 0x0000, /* Character 75 (0x4b): width 10 +----------+ | | | | | | | ** * | | ** * | | ** * | | ** * | | *** | | **** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | | | | | | +----------+ */ 0x0000, 0x0000, 0x0000, 0x6100, 0x6200, 0x6400, 0x6800, 0x7000, 0x7800, 0x6c00, 0x6600, 0x6600, 0x6300, 0x6180, 0x0000, 0x0000, 0x0000, /* Character 76 (0x4c): width 8 +--------+ | | | | | | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ****** | | | | | | | +--------+ */ 0x0000, 0x0000, 0x0000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x7e00, 0x0000, 0x0000, 0x0000, /* Character 77 (0x4d): width 13 +-------------+ | | | | | | | ** ** | | *** *** | | *** *** | | *** *** | | * ** * ** | | * ** * ** | | * ** * ** | | * ** * ** | | * *** ** | | * ** ** | | * ** | | | | | | | +-------------+ */ 0x0000, 0x0000, 0x0000, 0x6060, 0x70e0, 0x70e0, 0x70e0, 0x5960, 0x5960, 0x5960, 0x4d60, 0x4e60, 0x4660, 0x4060, 0x0000, 0x0000, 0x0000, /* Character 78 (0x4e): width 11 +-----------+ | | | | | | | ** * | | ** * | | *** * | | * ** * | | * ** * | | * ** * | | * ** * | | * ** * | | * *** | | * ** | | * ** | | | | | | | +-----------+ */ 0x0000, 0x0000, 0x0000, 0x6080, 0x6080, 0x7080, 0x5880, 0x5880, 0x4c80, 0x4680, 0x4680, 0x4380, 0x4180, 0x4180, 0x0000, 0x0000, 0x0000, /* Character 79 (0x4f): width 12 +------------+ | | | | | | | **** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | **** | | | | | | | +------------+ */ 0x0000, 0x0000, 0x0000, 0x0f00, 0x30c0, 0x30c0, 0x6060, 0x6060, 0x6060, 0x6060, 0x6060, 0x30c0, 0x30c0, 0x0f00, 0x0000, 0x0000, 0x0000, /* Character 80 (0x50): width 9 +---------+ | | | | | | | ****** | | ** *** | | ** ** | | ** ** | | ** ** | | ** ** | | ***** | | ** | | ** | | ** | | ** | | | | | | | +---------+ */ 0x0000, 0x0000, 0x0000, 0x7e00, 0x6700, 0x6300, 0x6300, 0x6300, 0x6600, 0x7c00, 0x6000, 0x6000, 0x6000, 0x6000, 0x0000, 0x0000, 0x0000, /* Character 81 (0x51): width 12 +------------+ | | | | | | | **** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | **** | | ** | | **| | | +------------+ */ 0x0000, 0x0000, 0x0000, 0x0f00, 0x30c0, 0x30c0, 0x6060, 0x6060, 0x6060, 0x6060, 0x6060, 0x30c0, 0x30c0, 0x0f00, 0x00c0, 0x0030, 0x0000, /* Character 82 (0x52): width 9 +---------+ | | | | | | | ****** | | ** ** | | ** ** | | ** ** | | ** ** | | ***** | | ** ** | | ** ** | | ** ** | | ** ** | | ** **| | | | | | | +---------+ */ 0x0000, 0x0000, 0x0000, 0x7e00, 0x6300, 0x6300, 0x6300, 0x6600, 0x7c00, 0x6600, 0x6600, 0x6300, 0x6300, 0x6180, 0x0000, 0x0000, 0x0000, /* Character 83 (0x53): width 8 +--------+ | | | | | | | ***** | |** | |** | |** | | *** | | **** | | *** | | ** | | ** | | ** | |***** | | | | | | | +--------+ */ 0x0000, 0x0000, 0x0000, 0x7c00, 0xc000, 0xc000, 0xc000, 0x7000, 0x3c00, 0x0e00, 0x0600, 0x0600, 0x0c00, 0xf800, 0x0000, 0x0000, 0x0000, /* Character 84 (0x54): width 10 +----------+ | | | | | | |**********| | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | | | | | | +----------+ */ 0x0000, 0x0000, 0x0000, 0xffc0, 0x0c00, 0x0c00, 0x0c00, 0x0c00, 0x0c00, 0x0c00, 0x0c00, 0x0c00, 0x0c00, 0x0c00, 0x0000, 0x0000, 0x0000, /* Character 85 (0x55): width 10 +----------+ | | | | | | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | **** | | | | | | | +----------+ */ 0x0000, 0x0000, 0x0000, 0x6180, 0x6180, 0x6180, 0x6180, 0x6180, 0x6180, 0x6180, 0x6180, 0x6180, 0x3300, 0x1e00, 0x0000, 0x0000, 0x0000, /* Character 86 (0x56): width 10 +----------+ | | | | | | |** * | | ** * | | ** * | | ** * | | ** * | | ** * | | ** * | | *** | | *** | | *** | | * | | | | | | | +----------+ */ 0x0000, 0x0000, 0x0000, 0xc080, 0x6100, 0x6100, 0x6100, 0x3200, 0x3200, 0x3200, 0x1c00, 0x1c00, 0x1c00, 0x0800, 0x0000, 0x0000, 0x0000, /* Character 87 (0x57): width 13 +-------------+ | | | | | | |** ** *| |** ** *| | ** ** * | | ** * ** * | | ** * ** * | | *** * ** ** | | ** * ** * | | ** * ** * | | *** *** | | ** ** | | ** ** | | | | | | | +-------------+ */ 0x0000, 0x0000, 0x0000, 0xc308, 0xc308, 0x6310, 0x6590, 0x6590, 0x75b0, 0x35a0, 0x35a0, 0x38e0, 0x18c0, 0x18c0, 0x0000, 0x0000, 0x0000, /* Character 88 (0x58): width 9 +---------+ | | | | | | |*** *| | ** * | | ** * | | ** * | | *** | | *** | | *** | | * ** | | * *** | | * ** | |* ***| | | | | | | +---------+ */ 0x0000, 0x0000, 0x0000, 0xe080, 0x6100, 0x3200, 0x3200, 0x1c00, 0x1c00, 0x1c00, 0x2600, 0x2700, 0x4300, 0x8380, 0x0000, 0x0000, 0x0000, /* Character 89 (0x59): width 9 +---------+ | | | | | | |** | | ** *| | ** * | | ** * | | ** * | | ** * | | ** | | ** | | ** | | ** | | ** | | | | | | | +---------+ */ 0x0000, 0x0000, 0x0000, 0xc040, 0x6080, 0x3100, 0x3100, 0x1a00, 0x1a00, 0x0c00, 0x0c00, 0x0c00, 0x0c00, 0x0c00, 0x0000, 0x0000, 0x0000, /* Character 90 (0x5a): width 9 +---------+ | | | | | | |******** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | |** | |******** | | | | | | | +---------+ */ 0x0000, 0x0000, 0x0000, 0xff00, 0x0300, 0x0600, 0x0c00, 0x0c00, 0x1800, 0x3000, 0x3000, 0x6000, 0xc000, 0xff00, 0x0000, 0x0000, 0x0000, /* Character 91 (0x5b): width 5 +-----+ | | | | | *** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | *** | | | +-----+ */ 0x0000, 0x0000, 0x7000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x7000, 0x0000, /* Character 92 (0x5c): width 8 +--------+ | | | | | | | * | | * | | * | | * | | * | | * | | * | | * | | * | | * | | * | | * | | * | | | +--------+ */ 0x0000, 0x0000, 0x0000, 0x2000, 0x2000, 0x1000, 0x1000, 0x1000, 0x0800, 0x0800, 0x0800, 0x0400, 0x0400, 0x0400, 0x0200, 0x0200, 0x0000, /* Character 93 (0x5d): width 5 +-----+ | | | | | *** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | *** | | | +-----+ */ 0x0000, 0x0000, 0x7000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x7000, 0x0000, /* Character 94 (0x5e): width 9 +---------+ | | | | | | | * | | * | | * * | | * * | | * * | | * * | | * * | | * * | | | | | | | | | | | | | +---------+ */ 0x0000, 0x0000, 0x0000, 0x0800, 0x0800, 0x1400, 0x1400, 0x2400, 0x2200, 0x2200, 0x4100, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 95 (0x5f): width 8 +--------+ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ****** | | | | | +--------+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x7e00, 0x0000, 0x0000, /* Character 96 (0x60): width 9 +---------+ | | | | | | | ** | | ** | | | | | | | | | | | | | | | | | | | | | | | | | +---------+ */ 0x0000, 0x0000, 0x0000, 0x1800, 0x0c00, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 97 (0x61): width 8 +--------+ | | | | | | | | | | | | | *** | | * ** | | ** | | ***** | | ** ** | | ** ** | | ** ** | | *** **| | | | | | | +--------+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x1c00, 0x2600, 0x0600, 0x3e00, 0x6600, 0x6600, 0x6600, 0x3b00, 0x0000, 0x0000, 0x0000, /* Character 98 (0x62): width 10 +----------+ | | | | | ** | | ** | | ** | | ** | | ** *** | | *** ** | | ** ** | | ** ** | | ** ** | | ** ** | | *** ** | | ** *** | | | | | | | +----------+ */ 0x0000, 0x0000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6e00, 0x7300, 0x6180, 0x6180, 0x6180, 0x6180, 0x7300, 0x6e00, 0x0000, 0x0000, 0x0000, /* Character 99 (0x63): width 8 +--------+ | | | | | | | | | | | | | **** | | ** | | ** | | ** | | ** | | ** | | ** | | **** | | | | | | | +--------+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x1e00, 0x3000, 0x6000, 0x6000, 0x6000, 0x6000, 0x3000, 0x1e00, 0x0000, 0x0000, 0x0000, /* Character 100 (0x64): width 10 +----------+ | | | | | ** | | ** | | ** | | ** | | *** ** | | ** *** | | ** ** | | ** ** | | ** ** | | ** ** | | ** *** | | *** ** | | | | | | | +----------+ */ 0x0000, 0x0000, 0x0180, 0x0180, 0x0180, 0x0180, 0x1d80, 0x3380, 0x6180, 0x6180, 0x6180, 0x6180, 0x3380, 0x1d80, 0x0000, 0x0000, 0x0000, /* Character 101 (0x65): width 9 +---------+ | | | | | | | | | | | | | **** | | ** ** | | ** ** | | ******* | | ** | | ** | | ** | | ***** | | | | | | | +---------+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x1e00, 0x3300, 0x6300, 0x7f00, 0x6000, 0x6000, 0x3000, 0x1f00, 0x0000, 0x0000, 0x0000, /* Character 102 (0x66): width 6 +------+ | | | | | ***| | ** | | ** | | ** | | **** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | | | | | | +------+ */ 0x0000, 0x0000, 0x1c00, 0x3000, 0x3000, 0x3000, 0x7800, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x0000, 0x0000, 0x0000, /* Character 103 (0x67): width 10 +----------+ | | | | | | | | | | | | | *** ** | | ** *** | | ** ** | | ** ** | | ** ** | | ** ** | | ** *** | | *** ** | | ** | | ** | | ***** | +----------+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x1d80, 0x3380, 0x6180, 0x6180, 0x6180, 0x6180, 0x3380, 0x1d80, 0x0180, 0x0300, 0x3e00, /* Character 104 (0x68): width 9 +---------+ | | | | | ** | | ** | | ** | | ** | | ** *** | | *** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | | | | | | +---------+ */ 0x0000, 0x0000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6e00, 0x7300, 0x6300, 0x6300, 0x6300, 0x6300, 0x6300, 0x6300, 0x0000, 0x0000, 0x0000, /* Character 105 (0x69): width 4 +----+ | | | | | | | ** | | | | | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | | | | | | +----+ */ 0x0000, 0x0000, 0x0000, 0x6000, 0x0000, 0x0000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x0000, 0x0000, 0x0000, /* Character 106 (0x6a): width 5 +-----+ | | | | | | | ** | | | | | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | |*** | +-----+ */ 0x0000, 0x0000, 0x0000, 0x3000, 0x0000, 0x0000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0xe000, /* Character 107 (0x6b): width 9 +---------+ | | | | | ** | | ** | | ** | | ** | | ** * | | ** * | | ** * | | *** | | **** | | ** ** | | ** ** | | ** ** | | | | | | | +---------+ */ 0x0000, 0x0000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6200, 0x6400, 0x6800, 0x7000, 0x7800, 0x6c00, 0x6600, 0x6300, 0x0000, 0x0000, 0x0000, /* Character 108 (0x6c): width 4 +----+ | | | | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | | | | | | +----+ */ 0x0000, 0x0000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x0000, 0x0000, 0x0000, /* Character 109 (0x6d): width 14 +--------------+ | | | | | | | | | | | | | ** *** *** | | *** *** ** | | ** ** ** | | ** ** ** | | ** ** ** | | ** ** ** | | ** ** ** | | ** ** ** | | | | | | | +--------------+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x6e70, 0x7398, 0x6318, 0x6318, 0x6318, 0x6318, 0x6318, 0x6318, 0x0000, 0x0000, 0x0000, /* Character 110 (0x6e): width 9 +---------+ | | | | | | | | | | | | | ** *** | | *** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | | | | | | +---------+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x6e00, 0x7300, 0x6300, 0x6300, 0x6300, 0x6300, 0x6300, 0x6300, 0x0000, 0x0000, 0x0000, /* Character 111 (0x6f): width 10 +----------+ | | | | | | | | | | | | | **** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | **** | | | | | | | +----------+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x1e00, 0x3300, 0x6180, 0x6180, 0x6180, 0x6180, 0x3300, 0x1e00, 0x0000, 0x0000, 0x0000, /* Character 112 (0x70): width 10 +----------+ | | | | | | | | | | | | | ** *** | | *** ** | | ** ** | | ** ** | | ** ** | | ** ** | | *** ** | | ** *** | | ** | | ** | | ** | +----------+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x6e00, 0x7300, 0x6180, 0x6180, 0x6180, 0x6180, 0x7300, 0x6e00, 0x6000, 0x6000, 0x6000, /* Character 113 (0x71): width 10 +----------+ | | | | | | | | | | | | | *** ** | | ** *** | | ** ** | | ** ** | | ** ** | | ** ** | | ** *** | | *** ** | | ** | | ** | | ** | +----------+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x1d80, 0x3380, 0x6180, 0x6180, 0x6180, 0x6180, 0x3380, 0x1d80, 0x0180, 0x0180, 0x0180, /* Character 114 (0x72): width 6 +------+ | | | | | | | | | | | | | ** **| | *** | | ** | | ** | | ** | | ** | | ** | | ** | | | | | | | +------+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x6c00, 0x7000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x0000, 0x0000, 0x0000, /* Character 115 (0x73): width 7 +-------+ | | | | | | | | | | | | | *** | | ** | | ** | | ** | | ** | | ** | | ** | | **** | | | | | | | +-------+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x3800, 0x6000, 0x6000, 0x3000, 0x1800, 0x0c00, 0x0c00, 0x7800, 0x0000, 0x0000, 0x0000, /* Character 116 (0x74): width 6 +------+ | | | | | | | | | ** | | ** | |***** | | ** | | ** | | ** | | ** | | ** | | ** | | *** | | | | | | | +------+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x6000, 0x6000, 0xf800, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x3800, 0x0000, 0x0000, 0x0000, /* Character 117 (0x75): width 9 +---------+ | | | | | | | | | | | | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** *** | | *** ** | | | | | | | +---------+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x6300, 0x6300, 0x6300, 0x6300, 0x6300, 0x6300, 0x6700, 0x3b00, 0x0000, 0x0000, 0x0000, /* Character 118 (0x76): width 8 +--------+ | | | | | | | | | | | | |** *| | ** * | | ** * | | ** * | | ** * | | ** * | | ** | | ** | | | | | | | +--------+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xc100, 0x6200, 0x6200, 0x6200, 0x3400, 0x3400, 0x1800, 0x1800, 0x0000, 0x0000, 0x0000, /* Character 119 (0x77): width 12 +------------+ | | | | | | | | | | | | | ** * * | | ** ** * | | ** *** * | | ** *** * | | ** * * * | | *** *** | | ** ** | | ** ** | | | | | | | +------------+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x6220, 0x6620, 0x3740, 0x3740, 0x3540, 0x39c0, 0x1980, 0x1980, 0x0000, 0x0000, 0x0000, /* Character 120 (0x78): width 10 +----------+ | | | | | | | | | | | | | *** * | | ** * | | ** * | | *** | | *** | | * ** | | * ** | | * *** | | | | | | | +----------+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x7080, 0x3100, 0x1a00, 0x1c00, 0x0e00, 0x1600, 0x2300, 0x4380, 0x0000, 0x0000, 0x0000, /* Character 121 (0x79): width 8 +--------+ | | | | | | | | | | | | |** *| | ** * | | ** * | | ** * | | ** * | | ** * | | ** | | ** | | * | | * | | ** | +--------+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xc100, 0x6200, 0x6200, 0x6200, 0x3400, 0x3400, 0x1800, 0x1800, 0x1000, 0x1000, 0x3000, /* Character 122 (0x7a): width 9 +---------+ | | | | | | | | | | | | | ******* | | ** | | ** | | ** | | ** | | ** | | ** | | ******* | | | | | | | +---------+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x7f00, 0x0300, 0x0600, 0x0c00, 0x1800, 0x3000, 0x6000, 0x7f00, 0x0000, 0x0000, 0x0000, /* Character 123 (0x7b): width 5 +-----+ | | | | | * | | * | | * | | * | | * | | * | | * | |* | | * | | * | | * | | * | | * | | * | | | +-----+ */ 0x0000, 0x0000, 0x2000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x8000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x2000, 0x0000, /* Character 124 (0x7c): width 6 +------+ | | | | | * | | * | | * | | * | | * | | * | | * | | * | | * | | * | | * | | * | | * | | * | | | +------+ */ 0x0000, 0x0000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x0000, /* Character 125 (0x7d): width 5 +-----+ | | | | | * | | * | | * | | * | | * | | * | | * | | *| | * | | * | | * | | * | | * | | * | | | +-----+ */ 0x0000, 0x0000, 0x2000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x0800, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x2000, 0x0000, /* Character 126 (0x7e): width 9 +---------+ | | | | | | | | | | | | | | | | | ** * | |* ** * | |* ** | | | | | | | | | | | | | +---------+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x6100, 0x9900, 0x8600, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 127 (0x7f): width 10 +----------+ | | | | | | | | |* * | | * *** * | | * * | | * * | | * * | | * * | | * * | | * *** * | |* * | | | | | | | | | +----------+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x8080, 0x5d00, 0x2200, 0x4100, 0x4100, 0x4100, 0x2200, 0x5d00, 0x8080, 0x0000, 0x0000, 0x0000, 0x0000, }; /* Character->glyph mapping. */ static const unsigned short _lucidasans11_offset[] = { 0, /* (0x20) */ 17, /* (0x21) */ 34, /* (0x22) */ 51, /* (0x23) */ 68, /* (0x24) */ 85, /* (0x25) */ 102, /* (0x26) */ 119, /* (0x27) */ 136, /* (0x28) */ 153, /* (0x29) */ 170, /* (0x2a) */ 187, /* (0x2b) */ 204, /* (0x2c) */ 221, /* (0x2d) */ 238, /* (0x2e) */ 255, /* (0x2f) */ 272, /* (0x30) */ 289, /* (0x31) */ 306, /* (0x32) */ 323, /* (0x33) */ 340, /* (0x34) */ 357, /* (0x35) */ 374, /* (0x36) */ 391, /* (0x37) */ 408, /* (0x38) */ 425, /* (0x39) */ 442, /* (0x3a) */ 459, /* (0x3b) */ 476, /* (0x3c) */ 493, /* (0x3d) */ 510, /* (0x3e) */ 527, /* (0x3f) */ 544, /* (0x40) */ 561, /* (0x41) */ 578, /* (0x42) */ 595, /* (0x43) */ 612, /* (0x44) */ 629, /* (0x45) */ 646, /* (0x46) */ 663, /* (0x47) */ 680, /* (0x48) */ 697, /* (0x49) */ 714, /* (0x4a) */ 731, /* (0x4b) */ 748, /* (0x4c) */ 765, /* (0x4d) */ 782, /* (0x4e) */ 799, /* (0x4f) */ 816, /* (0x50) */ 833, /* (0x51) */ 850, /* (0x52) */ 867, /* (0x53) */ 884, /* (0x54) */ 901, /* (0x55) */ 918, /* (0x56) */ 935, /* (0x57) */ 952, /* (0x58) */ 969, /* (0x59) */ 986, /* (0x5a) */ 1003, /* (0x5b) */ 1020, /* (0x5c) */ 1037, /* (0x5d) */ 1054, /* (0x5e) */ 1071, /* (0x5f) */ 1088, /* (0x60) */ 1105, /* (0x61) */ 1122, /* (0x62) */ 1139, /* (0x63) */ 1156, /* (0x64) */ 1173, /* (0x65) */ 1190, /* (0x66) */ 1207, /* (0x67) */ 1224, /* (0x68) */ 1241, /* (0x69) */ 1258, /* (0x6a) */ 1275, /* (0x6b) */ 1292, /* (0x6c) */ 1309, /* (0x6d) */ 1326, /* (0x6e) */ 1343, /* (0x6f) */ 1360, /* (0x70) */ 1377, /* (0x71) */ 1394, /* (0x72) */ 1411, /* (0x73) */ 1428, /* (0x74) */ 1445, /* (0x75) */ 1462, /* (0x76) */ 1479, /* (0x77) */ 1496, /* (0x78) */ 1513, /* (0x79) */ 1530, /* (0x7a) */ 1547, /* (0x7b) */ 1564, /* (0x7c) */ 1581, /* (0x7d) */ 1598, /* (0x7e) */ 1615, /* (0x7f) */ 1615, /* (0x80) */ 1615, /* (0x81) */ 1615, /* (0x82) */ 1615, /* (0x83) */ 1615, /* (0x84) */ 1615, /* (0x85) */ 1615, /* (0x86) */ 1615, /* (0x87) */ 1615, /* (0x88) */ 1615, /* (0x89) */ 1615, /* (0x8a) */ 1615, /* (0x8b) */ 1615, /* (0x8c) */ 1615, /* (0x8d) */ 1615, /* (0x8e) */ 1615, /* (0x8f) */ 1615, /* (0x90) */ 1615, /* (0x91) */ 1615, /* (0x92) */ 1615, /* (0x93) */ 1615, /* (0x94) */ 1615, /* (0x95) */ 1615, /* (0x96) */ 1615, /* (0x97) */ 1615, /* (0x98) */ 1615, /* (0x99) */ 1615, /* (0x9a) */ 1615, /* (0x9b) */ 1615, /* (0x9c) */ 1615, /* (0x9d) */ 1615, /* (0x9e) */ 1615, /* (0x9f) */ 1615, /* (0xa0) */ 1615, /* (0xa1) */ 1615, /* (0xa2) */ 1615, /* (0xa3) */ 1615, /* (0xa4) */ }; /* Character width data. */ static const unsigned char _lucidasans11_width[] = { 5, /* (0x20) */ 5, /* (0x21) */ 6, /* (0x22) */ 9, /* (0x23) */ 9, /* (0x24) */ 10, /* (0x25) */ 10, /* (0x26) */ 3, /* (0x27) */ 5, /* (0x28) */ 5, /* (0x29) */ 7, /* (0x2a) */ 12, /* (0x2b) */ 5, /* (0x2c) */ 9, /* (0x2d) */ 5, /* (0x2e) */ 8, /* (0x2f) */ 9, /* (0x30) */ 9, /* (0x31) */ 9, /* (0x32) */ 9, /* (0x33) */ 9, /* (0x34) */ 9, /* (0x35) */ 9, /* (0x36) */ 9, /* (0x37) */ 9, /* (0x38) */ 9, /* (0x39) */ 5, /* (0x3a) */ 5, /* (0x3b) */ 12, /* (0x3c) */ 12, /* (0x3d) */ 12, /* (0x3e) */ 6, /* (0x3f) */ 13, /* (0x40) */ 10, /* (0x41) */ 9, /* (0x42) */ 11, /* (0x43) */ 11, /* (0x44) */ 8, /* (0x45) */ 8, /* (0x46) */ 11, /* (0x47) */ 11, /* (0x48) */ 4, /* (0x49) */ 6, /* (0x4a) */ 10, /* (0x4b) */ 8, /* (0x4c) */ 13, /* (0x4d) */ 11, /* (0x4e) */ 12, /* (0x4f) */ 9, /* (0x50) */ 12, /* (0x51) */ 9, /* (0x52) */ 8, /* (0x53) */ 10, /* (0x54) */ 10, /* (0x55) */ 10, /* (0x56) */ 13, /* (0x57) */ 9, /* (0x58) */ 9, /* (0x59) */ 9, /* (0x5a) */ 5, /* (0x5b) */ 8, /* (0x5c) */ 5, /* (0x5d) */ 9, /* (0x5e) */ 8, /* (0x5f) */ 9, /* (0x60) */ 8, /* (0x61) */ 10, /* (0x62) */ 8, /* (0x63) */ 10, /* (0x64) */ 9, /* (0x65) */ 6, /* (0x66) */ 10, /* (0x67) */ 9, /* (0x68) */ 4, /* (0x69) */ 5, /* (0x6a) */ 9, /* (0x6b) */ 4, /* (0x6c) */ 14, /* (0x6d) */ 9, /* (0x6e) */ 10, /* (0x6f) */ 10, /* (0x70) */ 10, /* (0x71) */ 6, /* (0x72) */ 7, /* (0x73) */ 6, /* (0x74) */ 9, /* (0x75) */ 8, /* (0x76) */ 12, /* (0x77) */ 10, /* (0x78) */ 8, /* (0x79) */ 9, /* (0x7a) */ 5, /* (0x7b) */ 6, /* (0x7c) */ 5, /* (0x7d) */ 9, /* (0x7e) */ 10, /* (0x7f) */ 10, /* (0x80) */ 10, /* (0x81) */ 10, /* (0x82) */ 10, /* (0x83) */ 10, /* (0x84) */ 10, /* (0x85) */ 10, /* (0x86) */ 10, /* (0x87) */ 10, /* (0x88) */ 10, /* (0x89) */ 10, /* (0x8a) */ 10, /* (0x8b) */ 10, /* (0x8c) */ 10, /* (0x8d) */ 10, /* (0x8e) */ 10, /* (0x8f) */ 10, /* (0x90) */ 10, /* (0x91) */ 10, /* (0x92) */ 10, /* (0x93) */ 10, /* (0x94) */ 10, /* (0x95) */ 10, /* (0x96) */ 10, /* (0x97) */ 10, /* (0x98) */ 10, /* (0x99) */ 10, /* (0x9a) */ 10, /* (0x9b) */ 10, /* (0x9c) */ 10, /* (0x9d) */ 10, /* (0x9e) */ 10, /* (0x9f) */ 10, /* (0xa0) */ 10, /* (0xa1) */ 10, /* (0xa2) */ 10, /* (0xa3) */ 10, /* (0xa4) */ }; /* Exported structure definition. */ const struct gpanel_font_t font_lucidasans11 = { "lucidasans11", 14, 17, 14, 32, 133, _lucidasans11_bits, _lucidasans11_offset, _lucidasans11_width, 164, sizeof(_lucidasans11_bits) / sizeof(_lucidasans11_bits[0]), }; ================================================ FILE: share/examples/gpanel/fonts/lucidasans15.c ================================================ /* Generated by convbdf on Thu Oct 8 21:26:34 2015. */ #include /* Font information: name: lucidasans15 facename: -FreeType-Lucida Sans Unicode-Medium-R-Normal--21-150-100-100-P-95-ISO10646-1 w x h: 20x22 size: 133 ascent: 18 descent: 4 first char: 32 (0x20) last char: 164 (0xa4) default char: 164 (0xa4) proportional: yes Copyright 1993 Bigelow & Holmes Inc. All rights reserved. Pat. Des. 289,420. Pats. Pend. */ /* Font character bitmap data. */ static const unsigned short _lucidasans15_bits[] = { /* Character 32 (0x20): width 7 +-------+ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | +-------+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 33 (0x21): width 7 +-------+ | | | | | | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | | | | | ** | | | | | | | | | +-------+ */ 0x0000, 0x0000, 0x0000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x0000, 0x0000, 0x3000, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 34 (0x22): width 8 +--------+ | | | | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | +--------+ */ 0x0000, 0x0000, 0x6600, 0x6600, 0x6600, 0x6600, 0x6600, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 35 (0x23): width 13 +-------------+ | | | | | | | * * | | ** ** | | * * | | * * | | * * | | ************| | * * | | * * | | * * | |************ | | * * | | * * | | * * | | ** ** | | * * | | | | | | | | | +-------------+ */ 0x0000, 0x0000, 0x0000, 0x0220, 0x0660, 0x0440, 0x0440, 0x0440, 0x7ff8, 0x0880, 0x0880, 0x0880, 0xfff0, 0x1100, 0x1100, 0x1100, 0x3300, 0x2200, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 36 (0x24): width 13 +-------------+ | | | | | * | | ****** | | ** * * | | ** * | | ** * | | ** * | | ** * | | *** | | *** | | **** | | * *** | | * ** | | * ** | | * ** | | * * ** | | ****** | | * | | | | | | | +-------------+ */ 0x0000, 0x0000, 0x0200, 0x0fc0, 0x1a20, 0x3200, 0x3200, 0x3200, 0x1a00, 0x0e00, 0x0700, 0x03c0, 0x02e0, 0x0260, 0x0260, 0x0260, 0x22c0, 0x1f80, 0x0200, 0x0000, 0x0000, 0x0000, /* Character 37 (0x25): width 14 +--------------+ | | | | | * | | **** ** | | * * ** | |** ** * | |** ** * | |** ** ** | |** ** ** | | * * * | | **** * **** | | ** * * | | ** ** **| | * ** **| | * ** **| | ** ** **| | ** * * | | * **** | | | | | | | | | +--------------+ */ 0x0000, 0x0000, 0x0008, 0x7818, 0x4830, 0xcc20, 0xcc40, 0xccc0, 0xcd80, 0x4900, 0x7a78, 0x0648, 0x0ccc, 0x08cc, 0x10cc, 0x30cc, 0x6048, 0x4078, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 38 (0x26): width 15 +---------------+ | | | | | | | **** | | ** ** | | ** ** | | ** ** | | ** ** | | ***** | | **** | | *** ** ** | | *** ** ** | | ** *** ** | | ** ** * | | ** **** | | ** *** | | *** **** | | ***** *** | | | | | | | | | +---------------+ */ 0x0000, 0x0000, 0x0000, 0x03c0, 0x0c60, 0x0c60, 0x0c60, 0x0cc0, 0x07c0, 0x0f00, 0x3b0c, 0x718c, 0x61cc, 0x60c8, 0x6078, 0x3070, 0x3878, 0x0f9c, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 39 (0x27): width 5 +-----+ | | | | | *** | | *** | | *** | | * | | * | | * | | | | | | | | | | | | | | | | | | | | | | | | | | | | | +-----+ */ 0x0000, 0x0000, 0x7000, 0x7000, 0x7000, 0x2000, 0x2000, 0x2000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 40 (0x28): width 7 +-------+ | | | | | * | | ** | | ** | | * | | ** | | * | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | * | | ** | | * | | ** | | ** | | * | | | +-------+ */ 0x0000, 0x0000, 0x0400, 0x0c00, 0x1800, 0x1000, 0x3000, 0x2000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x2000, 0x3000, 0x1000, 0x1800, 0x0c00, 0x0400, 0x0000, /* Character 41 (0x29): width 7 +-------+ | | | | | * | | ** | | ** | | * | | ** | | * | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | * | | ** | | * | | ** | | ** | | * | | | +-------+ */ 0x0000, 0x0000, 0x4000, 0x6000, 0x3000, 0x1000, 0x1800, 0x0800, 0x0c00, 0x0c00, 0x0c00, 0x0c00, 0x0c00, 0x0c00, 0x0c00, 0x0800, 0x1800, 0x1000, 0x3000, 0x6000, 0x4000, 0x0000, /* Character 42 (0x2a): width 10 +----------+ | | | | | | | ** | | ** | | ** ** ** | | *** *** | | | | **** | | ** ** | | * * | | | | | | | | | | | | | | | | | | | | | | | +----------+ */ 0x0000, 0x0000, 0x0000, 0x0c00, 0x0c00, 0x6d80, 0x7380, 0x0000, 0x1e00, 0x3300, 0x1200, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 43 (0x2b): width 17 +-----------------+ | | | | | | | | | | | * | | * | | * | | * | | * | | * | | ************* | | * | | * | | * | | * | | * | | * | | | | | | | | | +-----------------+ */ 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0080,0x0000, 0x0080,0x0000, 0x0080,0x0000, 0x0080,0x0000, 0x0080,0x0000, 0x0080,0x0000, 0x3ffe,0x0000, 0x0080,0x0000, 0x0080,0x0000, 0x0080,0x0000, 0x0080,0x0000, 0x0080,0x0000, 0x0080,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, /* Character 44 (0x2c): width 7 +-------+ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | *** | | *** | | *** | | ** | | ** | | ** | | | +-------+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x3800, 0x3800, 0x3800, 0x1800, 0x1800, 0x3000, 0x0000, /* Character 45 (0x2d): width 12 +------------+ | | | | | | | | | | | | | | | | | | | | | | | ********* | | | | | | | | | | | | | | | | | | | | | +------------+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x3fe0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 46 (0x2e): width 7 +-------+ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | *** | | *** | | *** | | | | | | | | | +-------+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x3800, 0x3800, 0x3800, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 47 (0x2f): width 11 +-----------+ | | | | | | | * | | * | | * | | * | | * | | * | | * | | * | | * | | * | | * | | * | | * | | * | | * | | * | | * | | * | | | +-----------+ */ 0x0000, 0x0000, 0x0000, 0x0080, 0x0080, 0x0100, 0x0100, 0x0100, 0x0200, 0x0200, 0x0200, 0x0200, 0x0400, 0x0400, 0x0400, 0x0400, 0x0800, 0x0800, 0x0800, 0x1000, 0x1000, 0x0000, /* Character 48 (0x30): width 13 +-------------+ | | | | | | | ***** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ***** | | | | | | | | | +-------------+ */ 0x0000, 0x0000, 0x0000, 0x0f80, 0x18c0, 0x3060, 0x3060, 0x6030, 0x6030, 0x6030, 0x6030, 0x6030, 0x6030, 0x6030, 0x3060, 0x3060, 0x18c0, 0x0f80, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 49 (0x31): width 13 +-------------+ | | | | | | | **** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | | | | | | | | +-------------+ */ 0x0000, 0x0000, 0x0000, 0x0f00, 0x0300, 0x0300, 0x0300, 0x0300, 0x0300, 0x0300, 0x0300, 0x0300, 0x0300, 0x0300, 0x0300, 0x0300, 0x0300, 0x0300, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 50 (0x32): width 13 +-------------+ | | | | | | | ****** | | * ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ********* | | | | | | | | | +-------------+ */ 0x0000, 0x0000, 0x0000, 0x1f80, 0x20c0, 0x0060, 0x0060, 0x0060, 0x0060, 0x00c0, 0x0180, 0x0300, 0x0600, 0x0c00, 0x1800, 0x1800, 0x3000, 0x3fe0, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 51 (0x33): width 13 +-------------+ | | | | | | | ***** | | * ** | | ** | | ** | | ** | | ** | | ***** | | *** | | ** | | ** | | ** | | ** | | ** | | * *** | | ***** | | | | | | | | | +-------------+ */ 0x0000, 0x0000, 0x0000, 0x1f00, 0x2180, 0x00c0, 0x00c0, 0x00c0, 0x0180, 0x1f00, 0x01c0, 0x00c0, 0x0060, 0x0060, 0x0060, 0x00c0, 0x21c0, 0x1f00, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 52 (0x34): width 13 +-------------+ | | | | | | | ** | | *** | | * ** | | * ** | | * ** | | * ** | | * ** | | * ** | | * ** | | * ** | | *********** | | ** | | ** | | ** | | ** | | | | | | | | | +-------------+ */ 0x0000, 0x0000, 0x0000, 0x00c0, 0x01c0, 0x02c0, 0x02c0, 0x04c0, 0x08c0, 0x10c0, 0x10c0, 0x20c0, 0x40c0, 0x7ff0, 0x00c0, 0x00c0, 0x00c0, 0x00c0, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 53 (0x35): width 13 +-------------+ | | | | | | | ******** | | ** | | ** | | ** | | ** | | ** | | ***** | | *** | | ** | | ** | | ** | | ** | | ** | | *** | | ***** | | | | | | | | | +-------------+ */ 0x0000, 0x0000, 0x0000, 0x1fe0, 0x1800, 0x1800, 0x1800, 0x1800, 0x1800, 0x1f00, 0x01c0, 0x00c0, 0x0060, 0x0060, 0x0060, 0x00c0, 0x01c0, 0x1f00, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 54 (0x36): width 13 +-------------+ | | | | | | | ***** | | ** * | | ** | | ** | | ** | | ** **** | | ** * ** | | *** ** | | ** ** | | ** ** | | ** ** | | * ** | | ** ** | | ** ** | | **** | | | | | | | | | +-------------+ */ 0x0000, 0x0000, 0x0000, 0x0f80, 0x1840, 0x3000, 0x3000, 0x6000, 0x6780, 0x68c0, 0x7060, 0x6060, 0x6060, 0x6060, 0x2060, 0x30c0, 0x18c0, 0x0f00, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 55 (0x37): width 13 +-------------+ | | | | | | | ********** | | ** | | ** | | * | | ** | | ** | | * | | ** | | * | | ** | | ** | | ** | | ** | | ** | | ** | | | | | | | | | +-------------+ */ 0x0000, 0x0000, 0x0000, 0x3ff0, 0x0030, 0x0060, 0x0040, 0x00c0, 0x0180, 0x0100, 0x0300, 0x0200, 0x0600, 0x0c00, 0x0c00, 0x0c00, 0x1800, 0x1800, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 56 (0x38): width 13 +-------------+ | | | | | | | **** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | **** | | ****** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ****** | | | | | | | | | +-------------+ */ 0x0000, 0x0000, 0x0000, 0x0780, 0x0cc0, 0x1860, 0x1860, 0x1860, 0x0cc0, 0x0780, 0x0fc0, 0x1860, 0x3030, 0x3030, 0x3030, 0x3030, 0x1860, 0x0fc0, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 57 (0x39): width 13 +-------------+ | | | | | | | **** | | ** ** | | ** ** | | ** * | | ** ** | | ** ** | | ** ** | | ** *** | | ** * ** | | **** ** | | ** | | ** | | ** | | ** | | ****** | | | | | | | | | +-------------+ */ 0x0000, 0x0000, 0x0000, 0x0780, 0x18c0, 0x1860, 0x3020, 0x3030, 0x3030, 0x3030, 0x3070, 0x18b0, 0x0f30, 0x0030, 0x0060, 0x0060, 0x00c0, 0x1f80, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 58 (0x3a): width 7 +-------+ | | | | | | | | | | | | | | | ** | | | | | | | | | | | | | | | | | | | | ** | | | | | | | | | +-------+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x3000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x3000, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 59 (0x3b): width 7 +-------+ | | | | | | | | | | | | | | | ** | | | | | | | | | | | | | | | | | | | | ** | | * | | * | | * | | | +-------+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x3000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x3000, 0x1000, 0x1000, 0x2000, 0x0000, /* Character 60 (0x3c): width 17 +-----------------+ | | | | | | | | | | | * | | ** | | *** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | *** | | ** | | * | | | | | | | | | +-----------------+ */ 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0004,0x0000, 0x0018,0x0000, 0x0070,0x0000, 0x00c0,0x0000, 0x0300,0x0000, 0x0c00,0x0000, 0x3000,0x0000, 0x0c00,0x0000, 0x0300,0x0000, 0x00c0,0x0000, 0x0070,0x0000, 0x0018,0x0000, 0x0004,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, /* Character 61 (0x3d): width 17 +-----------------+ | | | | | | | | | | | | | | | | | | | | | ************ | | | | | | ************ | | | | | | | | | | | | | | | | | +-----------------+ */ 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x3ffc,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x3ffc,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, /* Character 62 (0x3e): width 17 +-----------------+ | | | | | | | | | | | * | | ** | | *** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | *** | | ** | | * | | | | | | | | | +-----------------+ */ 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x2000,0x0000, 0x1800,0x0000, 0x0e00,0x0000, 0x0300,0x0000, 0x00c0,0x0000, 0x0030,0x0000, 0x000c,0x0000, 0x0030,0x0000, 0x00c0,0x0000, 0x0300,0x0000, 0x0e00,0x0000, 0x1800,0x0000, 0x2000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, /* Character 63 (0x3f): width 9 +---------+ | | | | | | | ***** | |* ** | | ** | | ** | | ** | | ** | | *** | | *** | | ** | | ** | | ** | | ** | | | | | | ** | | | | | | | | | +---------+ */ 0x0000, 0x0000, 0x0000, 0x7c00, 0x8600, 0x0300, 0x0300, 0x0300, 0x0600, 0x0e00, 0x1c00, 0x1800, 0x3000, 0x3000, 0x3000, 0x0000, 0x0000, 0x3000, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 64 (0x40): width 18 +------------------+ | | | | | | | ****** | | ** ** | | ** ** | | * **** * | | ** * * * | | * ** * * | | * * * * | | * ** ** * | | * ** ** * | | * ** *** * | | * ** * ** * | | ** ** **** | | * | | ** * | | ***** | | | | | | | | | +------------------+ */ 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x01f8,0x0000, 0x0606,0x0000, 0x0c03,0x0000, 0x10f1,0x0000, 0x3110,0x8000, 0x2310,0x8000, 0x4210,0x8000, 0x4630,0x8000, 0x4630,0x8000, 0x4671,0x0000, 0x46b2,0x0000, 0x633c,0x0000, 0x2000,0x0000, 0x1820,0x0000, 0x07c0,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, /* Character 65 (0x41): width 14 +--------------+ | | | | | | | ** | | *** | | * ** | | * ** | | * ** | | * ** | | * ** | | * ** | | * ** | | ********** | | * ** | | * ** | | * ** | | * ** | |* **| | | | | | | | | +--------------+ */ 0x0000, 0x0000, 0x0000, 0x0300, 0x0380, 0x0580, 0x0580, 0x08c0, 0x08c0, 0x0860, 0x1060, 0x1060, 0x3ff0, 0x2030, 0x4018, 0x4018, 0x4018, 0x800c, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 66 (0x42): width 12 +------------+ | | | | | | | ****** | | ** ** | | ** ** | | ** ** | | ** ** | | ** * | | ** ** | | ****** | | ** *** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ******* | | | | | | | | | +------------+ */ 0x0000, 0x0000, 0x0000, 0x3f00, 0x3180, 0x30c0, 0x30c0, 0x30c0, 0x3080, 0x3180, 0x3f00, 0x31c0, 0x30c0, 0x3060, 0x3060, 0x3060, 0x30c0, 0x3f80, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 67 (0x43): width 15 +---------------+ | | | | | | | ****** | | ** ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** * | | ******* | | | | | | | | | +---------------+ */ 0x0000, 0x0000, 0x0000, 0x07e0, 0x0c18, 0x1800, 0x3000, 0x3000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x3000, 0x3000, 0x1800, 0x0c08, 0x07f0, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 68 (0x44): width 16 +----------------+ | | | | | | | ********* | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ******** | | | | | | | | | +----------------+ */ 0x0000, 0x0000, 0x0000, 0x3fe0, 0x3030, 0x3018, 0x300c, 0x300c, 0x3006, 0x3006, 0x3006, 0x3006, 0x3006, 0x300c, 0x300c, 0x3018, 0x3030, 0x3fc0, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 69 (0x45): width 11 +-----------+ | | | | | | | *********| | ** | | ** | | ** | | ** | | ** | | ******** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | *********| | | | | | | | | +-----------+ */ 0x0000, 0x0000, 0x0000, 0x3fe0, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3fc0, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3fe0, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 70 (0x46): width 11 +-----------+ | | | | | | | ******** | | ** | | ** | | ** | | ** | | ** | | ** | | ******* | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | | | | | | | | +-----------+ */ 0x0000, 0x0000, 0x0000, 0x3fc0, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3f80, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 71 (0x47): width 15 +---------------+ | | | | | | | ****** | | *** ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** ** | | ** ** | | ** ** | | ** ** | | *** ** | | *** ** | | ******* | | | | | | | | | +---------------+ */ 0x0000, 0x0000, 0x0000, 0x07e0, 0x1c18, 0x3000, 0x3000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6018, 0x6018, 0x6018, 0x3018, 0x3818, 0x1c18, 0x07f0, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 72 (0x48): width 15 +---------------+ | | | | | | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ************ | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | | | | | | | | +---------------+ */ 0x0000, 0x0000, 0x0000, 0x300c, 0x300c, 0x300c, 0x300c, 0x300c, 0x300c, 0x3ffc, 0x300c, 0x300c, 0x300c, 0x300c, 0x300c, 0x300c, 0x300c, 0x300c, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 73 (0x49): width 6 +------+ | | | | | | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | | | | | | | | +------+ */ 0x0000, 0x0000, 0x0000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 74 (0x4a): width 9 +---------+ | | | | | | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | |***** | | | +---------+ */ 0x0000, 0x0000, 0x0000, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0c00, 0xf800, 0x0000, /* Character 75 (0x4b): width 14 +--------------+ | | | | | | | ** * | | ** * | | ** * | | ** * | | ** * | | ** * | | ** * | | **** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | | | | | | | | +--------------+ */ 0x0000, 0x0000, 0x0000, 0x3020, 0x3040, 0x3080, 0x3100, 0x3200, 0x3200, 0x3400, 0x3c00, 0x3600, 0x3300, 0x3180, 0x30c0, 0x3060, 0x3030, 0x3018, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 76 (0x4c): width 11 +-----------+ | | | | | | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | *********| | | | | | | | | +-----------+ */ 0x0000, 0x0000, 0x0000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3fe0, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 77 (0x4d): width 18 +------------------+ | | | | | | | ** *** | | *** *** | | *** * ** | | * ** * ** | | * ** * ** | | * ** * ** | | * ** * ** | | * ** * ** | | * ** * ** | | * ** * ** | | * ** * ** | | * *** ** | | * *** ** | | * *** ** | | * ** | | | | | | | | | +------------------+ */ 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x3007,0x0000, 0x3807,0x0000, 0x380b,0x0000, 0x2c0b,0x0000, 0x2c0b,0x0000, 0x2c13,0x0000, 0x2613,0x0000, 0x2613,0x0000, 0x2623,0x0000, 0x2323,0x0000, 0x2323,0x0000, 0x21c3,0x0000, 0x21c3,0x0000, 0x21c3,0x0000, 0x2003,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, /* Character 78 (0x4e): width 16 +----------------+ | | | | | | | ** * | | *** * | | **** * | | * ** * | | * ** * | | * *** * | | * *** * | | * ** * | | * *** * | | * *** * | | * ** * | | * ** * | | * **** | | * *** | | * ** | | | | | | | | | +----------------+ */ 0x0000, 0x0000, 0x0000, 0x3004, 0x3804, 0x3c04, 0x2c04, 0x2604, 0x2704, 0x2384, 0x2184, 0x21c4, 0x20e4, 0x2064, 0x2034, 0x203c, 0x201c, 0x200c, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 79 (0x4f): width 16 +----------------+ | | | | | | | ****** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ****** | | | | | | | | | +----------------+ */ 0x0000, 0x0000, 0x0000, 0x07e0, 0x0c30, 0x1818, 0x300c, 0x300c, 0x6006, 0x6006, 0x6006, 0x6006, 0x6006, 0x300c, 0x300c, 0x1818, 0x0c30, 0x07e0, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 80 (0x50): width 12 +------------+ | | | | | | | ******* | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** *** | | ****** | | ** | | ** | | ** | | ** | | ** | | ** | | | | | | | | | +------------+ */ 0x0000, 0x0000, 0x0000, 0x3f80, 0x30c0, 0x3060, 0x3060, 0x3060, 0x3060, 0x30c0, 0x31c0, 0x3f00, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 81 (0x51): width 16 +----------------+ | | | | | | | ****** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ****** | | *** | | *** | | **| | | +----------------+ */ 0x0000, 0x0000, 0x0000, 0x07e0, 0x0c30, 0x1818, 0x300c, 0x300c, 0x6006, 0x6006, 0x6006, 0x6006, 0x6006, 0x300c, 0x300c, 0x1818, 0x0c30, 0x07e0, 0x0038, 0x000e, 0x0003, 0x0000, /* Character 82 (0x52): width 13 +-------------+ | | | | | | | ******* | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ****** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** **| | | | | | | | | +-------------+ */ 0x0000, 0x0000, 0x0000, 0x3f80, 0x30c0, 0x3060, 0x3060, 0x3060, 0x30c0, 0x3180, 0x3f00, 0x3300, 0x3180, 0x30c0, 0x3060, 0x3060, 0x3030, 0x3018, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 83 (0x53): width 11 +-----------+ | | | | | | | ***** | | ** * | | ** | | ** | | ** | | **** | | **** | | **** | | *** | | *** | | ** | | ** | | ** | | * ** | | ****** | | | | | | | | | +-----------+ */ 0x0000, 0x0000, 0x0000, 0x1f00, 0x3080, 0x6000, 0x6000, 0x6000, 0x7800, 0x3c00, 0x0f00, 0x0380, 0x01c0, 0x00c0, 0x00c0, 0x00c0, 0x4180, 0x3f00, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 84 (0x54): width 13 +-------------+ | | | | | | | ************| | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | | | | | | | | +-------------+ */ 0x0000, 0x0000, 0x0000, 0x7ff8, 0x0300, 0x0300, 0x0300, 0x0300, 0x0300, 0x0300, 0x0300, 0x0300, 0x0300, 0x0300, 0x0300, 0x0300, 0x0300, 0x0300, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 85 (0x55): width 15 +---------------+ | | | | | | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** *** | | ***** | | | | | | | | | +---------------+ */ 0x0000, 0x0000, 0x0000, 0x3018, 0x3018, 0x3018, 0x3018, 0x3018, 0x3018, 0x3018, 0x3018, 0x3018, 0x3018, 0x3018, 0x3018, 0x1830, 0x1870, 0x07c0, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 86 (0x56): width 14 +--------------+ | | | | | | |** * | | ** * | | ** * | | ** * | | ** * | | ** * | | ** * | | ** * | | ** * | | ** * | | ** * | | ** * | | *** | | *** | | ** | | | | | | | | | +--------------+ */ 0x0000, 0x0000, 0x0000, 0xc008, 0x6010, 0x6010, 0x6010, 0x3020, 0x3020, 0x1820, 0x1840, 0x1840, 0x0c40, 0x0c80, 0x0c80, 0x0700, 0x0700, 0x0300, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 87 (0x57): width 18 +------------------+ | | | | | | |** ** *| |** ** *| | ** * ** * | | ** * ** * | | ** * ** * | | *** * ** ** | | ** * ** * | | ** * ** * | | ** * ** * | | ** * ** * | | ** * ** * | | ** * ** * | | *** ** * | | ** ** | | ** ** | | | | | | | | | +------------------+ */ 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0xc0c0,0x4000, 0xc0c0,0x4000, 0x6160,0x8000, 0x6160,0x8000, 0x6160,0x8000, 0x7161,0x8000, 0x3131,0x0000, 0x3231,0x0000, 0x3231,0x0000, 0x1a1a,0x0000, 0x1a1a,0x0000, 0x1a1a,0x0000, 0x1c1a,0x0000, 0x0c0c,0x0000, 0x0c0c,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, /* Character 88 (0x58): width 13 +-------------+ | | | | | | |*** * | | ** * | | ** * | | *** * | | ** * | | ** * | | *** | | ** | | *** | | * ** | | * ** | | * *** | | * ** | | * ** | |* *** | | | | | | | | | +-------------+ */ 0x0000, 0x0000, 0x0000, 0xe010, 0x6020, 0x3040, 0x3840, 0x1880, 0x0d00, 0x0e00, 0x0600, 0x0700, 0x0b00, 0x1180, 0x21c0, 0x20c0, 0x4060, 0x8070, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 89 (0x59): width 13 +-------------+ | | | | | | |** * | | ** * | | ** * | | ** * | | ** * | | ** * | | ** * | | ** * | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | | | | | | | | +-------------+ */ 0x0000, 0x0000, 0x0000, 0xc010, 0x6020, 0x6020, 0x3040, 0x1880, 0x1880, 0x0d00, 0x0d00, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0600, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 90 (0x5a): width 13 +-------------+ | | | | | | | ********** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | *********** | | | | | | | | | +-------------+ */ 0x0000, 0x0000, 0x0000, 0x3ff0, 0x0030, 0x0060, 0x00c0, 0x00c0, 0x0180, 0x0300, 0x0600, 0x0600, 0x0c00, 0x1800, 0x1800, 0x3000, 0x6000, 0x7ff0, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 91 (0x5b): width 7 +-------+ | | | | | **** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | **** | | | +-------+ */ 0x0000, 0x0000, 0x3c00, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3c00, 0x0000, /* Character 92 (0x5c): width 11 +-----------+ | | | | | | | * | | * | | * | | * | | * | | * | | * | | * | | * | | * | | * | | * | | * | | * | | * | | * | | * | | * | | | +-----------+ */ 0x0000, 0x0000, 0x0000, 0x1000, 0x1000, 0x0800, 0x0800, 0x0800, 0x0400, 0x0400, 0x0400, 0x0400, 0x0200, 0x0200, 0x0200, 0x0200, 0x0100, 0x0100, 0x0100, 0x0080, 0x0080, 0x0000, /* Character 93 (0x5d): width 7 +-------+ | | | | | **** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | **** | | | +-------+ */ 0x0000, 0x0000, 0x7800, 0x1800, 0x1800, 0x1800, 0x1800, 0x1800, 0x1800, 0x1800, 0x1800, 0x1800, 0x1800, 0x1800, 0x1800, 0x1800, 0x1800, 0x1800, 0x1800, 0x1800, 0x7800, 0x0000, /* Character 94 (0x5e): width 13 +-------------+ | | | | | | | * | | * | | *** | | * * | | ** ** | | * * | | ** ** | | * * | | ** ** | | * * | | ** ** | | | | | | | | | | | | | | | | | +-------------+ */ 0x0000, 0x0000, 0x0000, 0x0200, 0x0200, 0x0700, 0x0500, 0x0d80, 0x0880, 0x18c0, 0x1040, 0x3060, 0x2020, 0x6030, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 95 (0x5f): width 11 +-----------+ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ********* | | | | | | | +-----------+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x7fc0, 0x0000, 0x0000, 0x0000, /* Character 96 (0x60): width 13 +-------------+ | | | | | *** | | *** | | *** | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | +-------------+ */ 0x0000, 0x0000, 0x0e00, 0x0700, 0x0380, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 97 (0x61): width 12 +------------+ | | | | | | | | | | | | | | | **** | | * ** | | ** | | ** | | ** | | ****** | | ** ** | | ** ** | | ** ** | | ** *** | | **** *** | | | | | | | | | +------------+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x1e00, 0x2300, 0x0180, 0x0180, 0x0180, 0x1f80, 0x3180, 0x6180, 0x6180, 0x6380, 0x3ce0, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 98 (0x62): width 13 +-------------+ | | | | | ** | | ** | | ** | | ** | | ** | | ** **** | | ** * ** | | *** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | *** ** | | ** **** | | | | | | | | | +-------------+ */ 0x0000, 0x0000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x33c0, 0x3460, 0x3830, 0x3030, 0x3030, 0x3030, 0x3030, 0x3030, 0x3060, 0x3860, 0x3780, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 99 (0x63): width 11 +-----------+ | | | | | | | | | | | | | | | ****** | | *** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | *** * | | ***** | | | | | | | | | +-----------+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0fc0, 0x3800, 0x3000, 0x6000, 0x6000, 0x6000, 0x6000, 0x6000, 0x3000, 0x3840, 0x0f80, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 100 (0x64): width 13 +-------------+ | | | | | ** | | ** | | ** | | ** | | ** | | **** ** | | ** *** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** *** | | ** * ** | | **** ** | | | | | | | | | +-------------+ */ 0x0000, 0x0000, 0x0060, 0x0060, 0x0060, 0x0060, 0x0060, 0x0f60, 0x30e0, 0x3060, 0x6060, 0x6060, 0x6060, 0x6060, 0x6060, 0x60e0, 0x3160, 0x1e60, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 101 (0x65): width 12 +------------+ | | | | | | | | | | | | | | | ***** | | ** ** | | ** ** | | ** ** | | ********** | | ** | | ** | | ** | | ** | | *** * | | ****** | | | | | | | | | +------------+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0f80, 0x30c0, 0x3060, 0x6060, 0x7fe0, 0x6000, 0x6000, 0x6000, 0x3000, 0x3820, 0x0fc0, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 102 (0x66): width 8 +--------+ | | | | | *****| | ** | | ** | | ** | | ** | |******* | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | | | | | | | | +--------+ */ 0x0000, 0x0000, 0x1f00, 0x3000, 0x3000, 0x3000, 0x3000, 0xfe00, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 103 (0x67): width 13 +-------------+ | | | | | | | | | | | | | | | **** ** | | ** *** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** *** | | ** * ** | | **** ** | | ** | | * | | * ** | | ***** | +-------------+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0f60, 0x30e0, 0x3060, 0x6060, 0x6060, 0x6060, 0x6060, 0x6060, 0x60e0, 0x3160, 0x1e60, 0x0060, 0x0040, 0x20c0, 0x1f00, /* Character 104 (0x68): width 13 +-------------+ | | | | | ** | | ** | | ** | | ** | | ** | | ** **** | | ** * ** | | *** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | | | | | | | | +-------------+ */ 0x0000, 0x0000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x33c0, 0x3460, 0x3860, 0x3060, 0x3060, 0x3060, 0x3060, 0x3060, 0x3060, 0x3060, 0x3060, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 105 (0x69): width 6 +------+ | | | | | | | ** | | | | | | | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | | | | | | | | +------+ */ 0x0000, 0x0000, 0x0000, 0x3000, 0x0000, 0x0000, 0x0000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 106 (0x6a): width 8 +--------+ | | | | | | | ** | | | | | | | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | |* * | | *** | +--------+ */ 0x0000, 0x0000, 0x0000, 0x0c00, 0x0000, 0x0000, 0x0000, 0x0c00, 0x0c00, 0x0c00, 0x0c00, 0x0c00, 0x0c00, 0x0c00, 0x0c00, 0x0c00, 0x0c00, 0x0c00, 0x0c00, 0x0c00, 0x8800, 0x7000, /* Character 107 (0x6b): width 12 +------------+ | | | | | ** | | ** | | ** | | ** | | ** | | ** * | | ** * | | ** * | | ** * | | ** * | | **** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | | | | | | | | +------------+ */ 0x0000, 0x0000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3040, 0x3080, 0x3100, 0x3200, 0x3400, 0x3c00, 0x3600, 0x3300, 0x3180, 0x30c0, 0x3060, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 108 (0x6c): width 6 +------+ | | | | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | | | | | | | | +------+ */ 0x0000, 0x0000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 109 (0x6d): width 20 +--------------------+ | | | | | | | | | | | | | | | ** **** **** | | ** * ** * ** | | *** *** ** | | ** ** ** | | ** ** ** | | ** ** ** | | ** ** ** | | ** ** ** | | ** ** ** | | ** ** ** | | ** ** ** | | | | | | | | | +--------------------+ */ 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x33c7,0x8000, 0x3468,0xc000, 0x3870,0xc000, 0x3060,0xc000, 0x3060,0xc000, 0x3060,0xc000, 0x3060,0xc000, 0x3060,0xc000, 0x3060,0xc000, 0x3060,0xc000, 0x3060,0xc000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, /* Character 110 (0x6e): width 13 +-------------+ | | | | | | | | | | | | | | | ** **** | | ** * ** | | *** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | | | | | | | | +-------------+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x33c0, 0x3460, 0x3860, 0x3060, 0x3060, 0x3060, 0x3060, 0x3060, 0x3060, 0x3060, 0x3060, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 111 (0x6f): width 13 +-------------+ | | | | | | | | | | | | | | | ***** | | *** *** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | *** *** | | ***** | | | | | | | | | +-------------+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0f80, 0x38e0, 0x3060, 0x6030, 0x6030, 0x6030, 0x6030, 0x6030, 0x3060, 0x38e0, 0x0f80, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 112 (0x70): width 13 +-------------+ | | | | | | | | | | | | | | | ** **** | | ** * ** | | *** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | *** ** | | ** **** | | ** | | ** | | ** | | ** | +-------------+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x33c0, 0x3460, 0x3830, 0x3030, 0x3030, 0x3030, 0x3030, 0x3030, 0x3060, 0x3860, 0x3780, 0x3000, 0x3000, 0x3000, 0x3000, /* Character 113 (0x71): width 13 +-------------+ | | | | | | | | | | | | | | | **** ** | | ** *** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** *** | | ** * ** | | **** ** | | ** | | ** | | ** | | ** | +-------------+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0f60, 0x30e0, 0x3060, 0x6060, 0x6060, 0x6060, 0x6060, 0x6060, 0x60e0, 0x3160, 0x1e60, 0x0060, 0x0060, 0x0060, 0x0060, /* Character 114 (0x72): width 9 +---------+ | | | | | | | | | | | | | | | ** ** | | ** * | | *** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | | | | | | | | +---------+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x3300, 0x3400, 0x3800, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 115 (0x73): width 11 +-----------+ | | | | | | | | | | | | | | | ***** | | ** | | ** | | ** | | **** | | **** | | *** | | ** | | ** | | * ** | | **** | | | | | | | | | +-----------+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x1f00, 0x3000, 0x3000, 0x3000, 0x3c00, 0x0f00, 0x0380, 0x0180, 0x0180, 0x2300, 0x1e00, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 116 (0x74): width 8 +--------+ | | | | | | | | | | | ** | | ** | | ****** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | **** | | | | | | | | | +--------+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x3000, 0x3000, 0x7e00, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x1e00, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 117 (0x75): width 13 +-------------+ | | | | | | | | | | | | | | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** *** | | ** * ** | | **** ** | | | | | | | | | +-------------+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x3060, 0x3060, 0x3060, 0x3060, 0x3060, 0x3060, 0x3060, 0x3060, 0x30e0, 0x3160, 0x1e60, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 118 (0x76): width 11 +-----------+ | | | | | | | | | | | | | | |** *| | ** * | | ** * | | ** * | | ** * | | ** * | | ** * | | ** * | | ** * | | *** | | *** | | | | | | | | | +-----------+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xc020, 0x6040, 0x6040, 0x6040, 0x3080, 0x3080, 0x1900, 0x1900, 0x1a00, 0x0e00, 0x0e00, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 119 (0x77): width 16 +----------------+ | | | | | | | | | | | | | | |** ** *| |** ** * | | ** ** * | | ** * ** * | | ** * ** * | | *** * * * | | ** * ** * | | ** * ** * | | ** * ** * | | ** *** | | ** ** | | | | | | | | | +----------------+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xc181, 0xc182, 0x6182, 0x62c2, 0x62c4, 0x7244, 0x3464, 0x3468, 0x3468, 0x1838, 0x1830, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 120 (0x78): width 13 +-------------+ | | | | | | | | | | | | | | | *** * | | *** * | | ** * | | ** * | | *** | | *** | | *** | | * ** | | * ** | | * *** | | * *** | | | | | | | | | +-------------+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x7010, 0x3820, 0x1840, 0x0c80, 0x0700, 0x0700, 0x0700, 0x0980, 0x10c0, 0x20e0, 0x4070, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 121 (0x79): width 11 +-----------+ | | | | | | | | | | | | | | |** *| | ** * | | ** * | | ** * | | ** * | | ** * | | ** * | | ** * | | ** * | | *** | | *** | | * | | * | | * | | * | +-----------+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xc020, 0x6040, 0x6040, 0x6040, 0x3080, 0x3080, 0x1900, 0x1900, 0x1a00, 0x0e00, 0x0e00, 0x0400, 0x0400, 0x0800, 0x0800, /* Character 122 (0x7a): width 12 +------------+ | | | | | | | | | | | | | | | ********** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ********** | | | | | | | | | +------------+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x7fe0, 0x0060, 0x00c0, 0x0180, 0x0300, 0x0600, 0x0c00, 0x1800, 0x3000, 0x6000, 0x7fe0, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 123 (0x7b): width 7 +-------+ | | | | | ** | | * | | ** | | ** | | *** | | ** | | ** | | ** | | * | |** | | * | | ** | | ** | | ** | | *** | | ** | | ** | | * | | ** | | | +-------+ */ 0x0000, 0x0000, 0x1800, 0x2000, 0x6000, 0x6000, 0x7000, 0x3000, 0x3000, 0x3000, 0x2000, 0xc000, 0x2000, 0x3000, 0x3000, 0x3000, 0x7000, 0x6000, 0x6000, 0x2000, 0x1800, 0x0000, /* Character 124 (0x7c): width 8 +--------+ | | | | | * | | * | | * | | * | | * | | * | | * | | * | | * | | * | | * | | * | | * | | * | | * | | * | | * | | * | | * | | | +--------+ */ 0x0000, 0x0000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x0000, /* Character 125 (0x7d): width 7 +-------+ | | | | | ** | | * | | ** | | ** | | *** | | ** | | ** | | ** | | * | | **| | * | | ** | | ** | | ** | | *** | | ** | | ** | | * | | ** | | | +-------+ */ 0x0000, 0x0000, 0x3000, 0x0800, 0x0c00, 0x0c00, 0x1c00, 0x1800, 0x1800, 0x1800, 0x0800, 0x0600, 0x0800, 0x1800, 0x1800, 0x1800, 0x1c00, 0x0c00, 0x0c00, 0x0800, 0x3000, 0x0000, /* Character 126 (0x7e): width 13 +-------------+ | | | | | | | | | | | | | | | | | | | | | *** ** | | ** * ** | | ** ** ** | | ** *** | | | | | | | | | | | | | | | | | +-------------+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x3830, 0x6430, 0x6330, 0x60e0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 127 (0x7f): width 13 +-------------+ | | | | | | | | | | | * * | | * ***** * | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | ** ** | | * ***** * | | * * | | | | | | | | | | | | | +-------------+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x4010, 0x2fa0, 0x18c0, 0x3060, 0x3060, 0x3060, 0x3060, 0x3060, 0x18c0, 0x2fa0, 0x4010, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, }; /* Character->glyph mapping. */ static const unsigned short _lucidasans15_offset[] = { 0, /* (0x20) */ 22, /* (0x21) */ 44, /* (0x22) */ 66, /* (0x23) */ 88, /* (0x24) */ 110, /* (0x25) */ 132, /* (0x26) */ 154, /* (0x27) */ 176, /* (0x28) */ 198, /* (0x29) */ 220, /* (0x2a) */ 242, /* (0x2b) */ 286, /* (0x2c) */ 308, /* (0x2d) */ 330, /* (0x2e) */ 352, /* (0x2f) */ 374, /* (0x30) */ 396, /* (0x31) */ 418, /* (0x32) */ 440, /* (0x33) */ 462, /* (0x34) */ 484, /* (0x35) */ 506, /* (0x36) */ 528, /* (0x37) */ 550, /* (0x38) */ 572, /* (0x39) */ 594, /* (0x3a) */ 616, /* (0x3b) */ 638, /* (0x3c) */ 682, /* (0x3d) */ 726, /* (0x3e) */ 770, /* (0x3f) */ 792, /* (0x40) */ 836, /* (0x41) */ 858, /* (0x42) */ 880, /* (0x43) */ 902, /* (0x44) */ 924, /* (0x45) */ 946, /* (0x46) */ 968, /* (0x47) */ 990, /* (0x48) */ 1012, /* (0x49) */ 1034, /* (0x4a) */ 1056, /* (0x4b) */ 1078, /* (0x4c) */ 1100, /* (0x4d) */ 1144, /* (0x4e) */ 1166, /* (0x4f) */ 1188, /* (0x50) */ 1210, /* (0x51) */ 1232, /* (0x52) */ 1254, /* (0x53) */ 1276, /* (0x54) */ 1298, /* (0x55) */ 1320, /* (0x56) */ 1342, /* (0x57) */ 1386, /* (0x58) */ 1408, /* (0x59) */ 1430, /* (0x5a) */ 1452, /* (0x5b) */ 1474, /* (0x5c) */ 1496, /* (0x5d) */ 1518, /* (0x5e) */ 1540, /* (0x5f) */ 1562, /* (0x60) */ 1584, /* (0x61) */ 1606, /* (0x62) */ 1628, /* (0x63) */ 1650, /* (0x64) */ 1672, /* (0x65) */ 1694, /* (0x66) */ 1716, /* (0x67) */ 1738, /* (0x68) */ 1760, /* (0x69) */ 1782, /* (0x6a) */ 1804, /* (0x6b) */ 1826, /* (0x6c) */ 1848, /* (0x6d) */ 1892, /* (0x6e) */ 1914, /* (0x6f) */ 1936, /* (0x70) */ 1958, /* (0x71) */ 1980, /* (0x72) */ 2002, /* (0x73) */ 2024, /* (0x74) */ 2046, /* (0x75) */ 2068, /* (0x76) */ 2090, /* (0x77) */ 2112, /* (0x78) */ 2134, /* (0x79) */ 2156, /* (0x7a) */ 2178, /* (0x7b) */ 2200, /* (0x7c) */ 2222, /* (0x7d) */ 2244, /* (0x7e) */ 2266, /* (0x7f) */ 2266, /* (0x80) */ 2266, /* (0x81) */ 2266, /* (0x82) */ 2266, /* (0x83) */ 2266, /* (0x84) */ 2266, /* (0x85) */ 2266, /* (0x86) */ 2266, /* (0x87) */ 2266, /* (0x88) */ 2266, /* (0x89) */ 2266, /* (0x8a) */ 2266, /* (0x8b) */ 2266, /* (0x8c) */ 2266, /* (0x8d) */ 2266, /* (0x8e) */ 2266, /* (0x8f) */ 2266, /* (0x90) */ 2266, /* (0x91) */ 2266, /* (0x92) */ 2266, /* (0x93) */ 2266, /* (0x94) */ 2266, /* (0x95) */ 2266, /* (0x96) */ 2266, /* (0x97) */ 2266, /* (0x98) */ 2266, /* (0x99) */ 2266, /* (0x9a) */ 2266, /* (0x9b) */ 2266, /* (0x9c) */ 2266, /* (0x9d) */ 2266, /* (0x9e) */ 2266, /* (0x9f) */ 2266, /* (0xa0) */ 2266, /* (0xa1) */ 2266, /* (0xa2) */ 2266, /* (0xa3) */ 2266, /* (0xa4) */ }; /* Character width data. */ static const unsigned char _lucidasans15_width[] = { 7, /* (0x20) */ 7, /* (0x21) */ 8, /* (0x22) */ 13, /* (0x23) */ 13, /* (0x24) */ 14, /* (0x25) */ 15, /* (0x26) */ 5, /* (0x27) */ 7, /* (0x28) */ 7, /* (0x29) */ 10, /* (0x2a) */ 17, /* (0x2b) */ 7, /* (0x2c) */ 12, /* (0x2d) */ 7, /* (0x2e) */ 11, /* (0x2f) */ 13, /* (0x30) */ 13, /* (0x31) */ 13, /* (0x32) */ 13, /* (0x33) */ 13, /* (0x34) */ 13, /* (0x35) */ 13, /* (0x36) */ 13, /* (0x37) */ 13, /* (0x38) */ 13, /* (0x39) */ 7, /* (0x3a) */ 7, /* (0x3b) */ 17, /* (0x3c) */ 17, /* (0x3d) */ 17, /* (0x3e) */ 9, /* (0x3f) */ 18, /* (0x40) */ 14, /* (0x41) */ 12, /* (0x42) */ 15, /* (0x43) */ 16, /* (0x44) */ 11, /* (0x45) */ 11, /* (0x46) */ 15, /* (0x47) */ 15, /* (0x48) */ 6, /* (0x49) */ 9, /* (0x4a) */ 14, /* (0x4b) */ 11, /* (0x4c) */ 18, /* (0x4d) */ 16, /* (0x4e) */ 16, /* (0x4f) */ 12, /* (0x50) */ 16, /* (0x51) */ 13, /* (0x52) */ 11, /* (0x53) */ 13, /* (0x54) */ 15, /* (0x55) */ 14, /* (0x56) */ 18, /* (0x57) */ 13, /* (0x58) */ 13, /* (0x59) */ 13, /* (0x5a) */ 7, /* (0x5b) */ 11, /* (0x5c) */ 7, /* (0x5d) */ 13, /* (0x5e) */ 11, /* (0x5f) */ 13, /* (0x60) */ 12, /* (0x61) */ 13, /* (0x62) */ 11, /* (0x63) */ 13, /* (0x64) */ 12, /* (0x65) */ 8, /* (0x66) */ 13, /* (0x67) */ 13, /* (0x68) */ 6, /* (0x69) */ 8, /* (0x6a) */ 12, /* (0x6b) */ 6, /* (0x6c) */ 20, /* (0x6d) */ 13, /* (0x6e) */ 13, /* (0x6f) */ 13, /* (0x70) */ 13, /* (0x71) */ 9, /* (0x72) */ 11, /* (0x73) */ 8, /* (0x74) */ 13, /* (0x75) */ 11, /* (0x76) */ 16, /* (0x77) */ 13, /* (0x78) */ 11, /* (0x79) */ 12, /* (0x7a) */ 7, /* (0x7b) */ 8, /* (0x7c) */ 7, /* (0x7d) */ 13, /* (0x7e) */ 13, /* (0x7f) */ 13, /* (0x80) */ 13, /* (0x81) */ 13, /* (0x82) */ 13, /* (0x83) */ 13, /* (0x84) */ 13, /* (0x85) */ 13, /* (0x86) */ 13, /* (0x87) */ 13, /* (0x88) */ 13, /* (0x89) */ 13, /* (0x8a) */ 13, /* (0x8b) */ 13, /* (0x8c) */ 13, /* (0x8d) */ 13, /* (0x8e) */ 13, /* (0x8f) */ 13, /* (0x90) */ 13, /* (0x91) */ 13, /* (0x92) */ 13, /* (0x93) */ 13, /* (0x94) */ 13, /* (0x95) */ 13, /* (0x96) */ 13, /* (0x97) */ 13, /* (0x98) */ 13, /* (0x99) */ 13, /* (0x9a) */ 13, /* (0x9b) */ 13, /* (0x9c) */ 13, /* (0x9d) */ 13, /* (0x9e) */ 13, /* (0x9f) */ 13, /* (0xa0) */ 13, /* (0xa1) */ 13, /* (0xa2) */ 13, /* (0xa3) */ 13, /* (0xa4) */ }; /* Exported structure definition. */ const struct gpanel_font_t font_lucidasans15 = { "lucidasans15", 20, 22, 18, 32, 133, _lucidasans15_bits, _lucidasans15_offset, _lucidasans15_width, 164, sizeof(_lucidasans15_bits) / sizeof(_lucidasans15_bits[0]), }; ================================================ FILE: share/examples/gpanel/fonts/lucidasans28.c ================================================ /* Generated by convbdf on Sun Nov 22 13:48:53 2015. */ #include /* Font information: name: lucidasans28 facename: -FreeType-Lucida Sans Unicode-Medium-R-Normal--39-280-100-100-P-174-ISO10646-1 w x h: 36x39 size: 133 ascent: 31 descent: 8 first char: 32 (0x20) last char: 164 (0xa4) default char: 164 (0xa4) proportional: yes Copyright 1993 Bigelow & Holmes Inc. All rights reserved. Pat. Des. 289,420. Pats. Pend. */ /* Font character bitmap data. */ static const unsigned short _lucidasans28_bits[] = { /* Character 32 (0x20): width 12 +------------+ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | +------------+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 33 (0x21): width 12 +------------+ | | | | | | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | | | | | | | | | **** | | **** | | **** | | **** | | | | | | | | | | | | | | | | | +------------+ */ 0x0000, 0x0000, 0x0000, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0000, 0x0000, 0x0000, 0x0000, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 34 (0x22): width 15 +---------------+ | | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | +---------------+ */ 0x0000, 0x3c78, 0x3c78, 0x3c78, 0x3c78, 0x3c78, 0x3c78, 0x3c78, 0x3c78, 0x3c78, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 35 (0x23): width 25 +-------------------------+ | | | | | | | ** ** | | *** *** | | ** ** | | ** ** | | ** ** | | *** *** | | *** *** | | ** ** | | ** ** | | ********************** | | ********************** | | ** ** | | ** ** | | ** ** | | *** *** | | ** ** | | ** ** | | ** ** | |********************** | |********************** | | ** ** | | ** ** | | *** *** | | ** ** | | ** ** | | ** ** | | *** *** | | ** ** | | | | | | | | | | | | | | | | | +-------------------------+ */ 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0018,0x3000, 0x0038,0x7000, 0x0030,0x6000, 0x0030,0x6000, 0x0030,0x6000, 0x0070,0xe000, 0x0070,0xe000, 0x0060,0xc000, 0x0060,0xc000, 0x3fff,0xff00, 0x3fff,0xff00, 0x00c1,0x8000, 0x00c1,0x8000, 0x00c1,0x8000, 0x01c3,0x8000, 0x0183,0x0000, 0x0183,0x0000, 0x0183,0x0000, 0xffff,0xfc00, 0xffff,0xfc00, 0x0306,0x0000, 0x0306,0x0000, 0x070e,0x0000, 0x060c,0x0000, 0x060c,0x0000, 0x060c,0x0000, 0x0e1c,0x0000, 0x0c18,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, /* Character 36 (0x24): width 25 +-------------------------+ | | | ** | | ** | | ******** | | ************ | | ************** | | ***** ** ** | | **** ** | | *** ** | | *** ** | | *** ** | | *** ** | | *** ** | | ***** ** | | ******* | | ****** | | ****** | | ****** | | ****** | | ******* | | ** *** | | ** **** | | ** *** | | ** *** | | ** *** | | ** *** | | * ** *** | | **** ** **** | | ************** | | ************ | | ******** | | ** | | ** | | | | | | | | | | | | | +-------------------------+ */ 0x0000,0x0000, 0x000c,0x0000, 0x000c,0x0000, 0x003f,0xc000, 0x00ff,0xf000, 0x03ff,0xf000, 0x03ec,0x3000, 0x078c,0x0000, 0x070c,0x0000, 0x070c,0x0000, 0x070c,0x0000, 0x070c,0x0000, 0x038c,0x0000, 0x03ec,0x0000, 0x01fc,0x0000, 0x00fc,0x0000, 0x007e,0x0000, 0x001f,0x8000, 0x000f,0xc000, 0x000f,0xe000, 0x000c,0xe000, 0x000c,0xf000, 0x000c,0x7000, 0x000c,0x7000, 0x000c,0x7000, 0x000c,0x7000, 0x080c,0xe000, 0x0f0d,0xe000, 0x0fff,0xc000, 0x07ff,0x8000, 0x00ff,0x0000, 0x000c,0x0000, 0x000c,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, /* Character 37 (0x25): width 26 +--------------------------+ | | | | | *** | | ***** *** | | ******** *** | | **** **** *** | | *** *** *** | |*** *** *** | |*** *** *** | |*** *** *** | |*** *** *** | |*** *** *** | |*** *** *** | | *** *** *** | | **** **** *** | | ******** *** | | ****** *** | | *** ***** | | *** ******** | | *** **** **** | | *** *** *** | | *** *** ***| | *** *** ***| | *** *** ***| | *** *** ***| | *** *** ***| | *** *** ***| | *** *** *** | | *** **** **** | | *** ******** | | *** ****** | | *** | | | | | | | | | | | | | | | +--------------------------+ */ 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0380, 0x1f00,0x0380, 0x3fc0,0x0700, 0x79e0,0x0e00, 0x70e0,0x1c00, 0xe070,0x1c00, 0xe070,0x3800, 0xe070,0x7000, 0xe070,0xe000, 0xe070,0xe000, 0xe071,0xc000, 0x70e3,0x8000, 0x79e7,0x0000, 0x3fc7,0x0000, 0x1f8e,0x0000, 0x001c,0x7c00, 0x0038,0xff00, 0x0039,0xe780, 0x0071,0xc380, 0x00e3,0x81c0, 0x01c3,0x81c0, 0x01c3,0x81c0, 0x0383,0x81c0, 0x0703,0x81c0, 0x0e03,0x81c0, 0x0e01,0xc380, 0x1c01,0xe780, 0x3800,0xff00, 0x7000,0x7e00, 0x7000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, /* Character 38 (0x26): width 27 +---------------------------+ | | | | | | | ***** | | ********* | | *********** | | ***** ***** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | ******** | | ******** | | ******** | | ***** ***** **** | | **** **** **** | | **** **** **** | | **** ***** **** | | **** **** *** | | **** **** *** | | **** ***** **** | | **** ***** *** | | ***** ******** | | **** ****** | | ***** **** | | ****** ******* | | ******************* | | ************ ***** | | ******** ****** | | | | | | | | | | | | | | | | | +---------------------------+ */ 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x003e,0x0000, 0x00ff,0x8000, 0x01ff,0xc000, 0x03e3,0xe000, 0x03c1,0xe000, 0x03c1,0xe000, 0x03c1,0xe000, 0x03c1,0xe000, 0x01e3,0xc000, 0x01e7,0x8000, 0x00ff,0x0000, 0x01fe,0x0000, 0x07f8,0x0000, 0x1f7c,0x0780, 0x1e3c,0x0780, 0x3c1e,0x0780, 0x781f,0x0780, 0x780f,0x0700, 0x7807,0x8700, 0x7807,0xcf00, 0x7803,0xee00, 0x7c01,0xfe00, 0x3c00,0xfc00, 0x3e00,0x7800, 0x1f81,0xfc00, 0x0fff,0xfe00, 0x07ff,0x9f00, 0x01fe,0x1f80, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, /* Character 39 (0x27): width 9 +---------+ | | | ***** | | ***** | | ***** | | ***** | | ***** | | *** | | *** | | *** | | *** | | *** | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | +---------+ */ 0x0000, 0x3e00, 0x3e00, 0x3e00, 0x3e00, 0x3e00, 0x1c00, 0x1c00, 0x1c00, 0x1c00, 0x1c00, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 40 (0x28): width 13 +-------------+ | | | * | | ** | | *** | | **** | | **** | | *** | | *** | | **** | | *** | | *** | | **** | | **** | | *** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | *** | | **** | | **** | | *** | | *** | | **** | | *** | | *** | | **** | | **** | | *** | | ** | | * | | | | | +-------------+ */ 0x0000, 0x0020, 0x0060, 0x00e0, 0x01e0, 0x03c0, 0x0380, 0x0700, 0x0f00, 0x0e00, 0x0e00, 0x1e00, 0x1e00, 0x1c00, 0x3c00, 0x3c00, 0x3c00, 0x3c00, 0x3c00, 0x3c00, 0x3c00, 0x3c00, 0x3c00, 0x3c00, 0x1c00, 0x1e00, 0x1e00, 0x0e00, 0x0e00, 0x0f00, 0x0700, 0x0380, 0x03c0, 0x01e0, 0x00e0, 0x0060, 0x0020, 0x0000, 0x0000, /* Character 41 (0x29): width 13 +-------------+ | | | * | | ** | | *** | | **** | | **** | | *** | | *** | | *** | | **** | | *** | | **** | | **** | | *** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | *** | | **** | | **** | | *** | | **** | | *** | | *** | | *** | | **** | | **** | | *** | | ** | | * | | | | | +-------------+ */ 0x0000, 0x4000, 0x6000, 0x7000, 0x7800, 0x3c00, 0x1c00, 0x0e00, 0x0e00, 0x0f00, 0x0700, 0x0780, 0x0780, 0x0380, 0x03c0, 0x03c0, 0x03c0, 0x03c0, 0x03c0, 0x03c0, 0x03c0, 0x03c0, 0x03c0, 0x03c0, 0x0380, 0x0780, 0x0780, 0x0700, 0x0f00, 0x0e00, 0x0e00, 0x1c00, 0x3c00, 0x7800, 0x7000, 0x6000, 0x4000, 0x0000, 0x0000, /* Character 42 (0x2a): width 19 +-------------------+ | | | | | | | *** | | *** | | *** | | *** | | * *** * | | **** * **** | | ****** ****** | | ** ** | | | | ** ** | | ** ** | | *** *** | | *** *** | | * * | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | +-------------------+ */ 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x00e0,0x0000, 0x00e0,0x0000, 0x00e0,0x0000, 0x00e0,0x0000, 0x10e1,0x0000, 0x3c47,0x8000, 0x3f1f,0x8000, 0x0318,0x0000, 0x0000,0x0000, 0x01b0,0x0000, 0x0318,0x0000, 0x071c,0x0000, 0x0e0e,0x0000, 0x0208,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, /* Character 43 (0x2b): width 31 +-------------------------------+ | | | | | | | | | | | | | | | | | | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ********************** | | ********************** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | | | | | | | | | | | | | | | | +-------------------------------+ */ 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0003,0x0000, 0x0003,0x0000, 0x0003,0x0000, 0x0003,0x0000, 0x0003,0x0000, 0x0003,0x0000, 0x0003,0x0000, 0x0003,0x0000, 0x0003,0x0000, 0x0003,0x0000, 0x0fff,0xffc0, 0x0fff,0xffc0, 0x0003,0x0000, 0x0003,0x0000, 0x0003,0x0000, 0x0003,0x0000, 0x0003,0x0000, 0x0003,0x0000, 0x0003,0x0000, 0x0003,0x0000, 0x0003,0x0000, 0x0003,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, /* Character 44 (0x2c): width 12 +------------+ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ***** | | ***** | | ***** | | ***** | | ***** | | *** | | *** | | *** | | ** | | ** | | ** | | | | | +------------+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0f80, 0x0f80, 0x0f80, 0x0f80, 0x0f80, 0x0380, 0x0380, 0x0380, 0x0300, 0x0600, 0x0c00, 0x0000, 0x0000, /* Character 45 (0x2d): width 23 +-----------------------+ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ***************** | | ***************** | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | +-----------------------+ */ 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x1fff,0xf000, 0x1fff,0xf000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, /* Character 46 (0x2e): width 12 +------------+ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ***** | | ***** | | ***** | | ***** | | ***** | | | | | | | | | | | | | | | | | +------------+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0f80, 0x0f80, 0x0f80, 0x0f80, 0x0f80, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 47 (0x2f): width 20 +--------------------+ | | | | | | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | *** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | *** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | | | | +--------------------+ */ 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0003,0x0000, 0x0003,0x0000, 0x0006,0x0000, 0x0006,0x0000, 0x0006,0x0000, 0x000c,0x0000, 0x000c,0x0000, 0x000c,0x0000, 0x001c,0x0000, 0x0018,0x0000, 0x0018,0x0000, 0x0018,0x0000, 0x0030,0x0000, 0x0030,0x0000, 0x0030,0x0000, 0x0060,0x0000, 0x0060,0x0000, 0x0060,0x0000, 0x0060,0x0000, 0x00c0,0x0000, 0x00c0,0x0000, 0x00c0,0x0000, 0x0180,0x0000, 0x0180,0x0000, 0x0180,0x0000, 0x0380,0x0000, 0x0300,0x0000, 0x0300,0x0000, 0x0300,0x0000, 0x0600,0x0000, 0x0600,0x0000, 0x0600,0x0000, 0x0c00,0x0000, 0x0c00,0x0000, 0x0000,0x0000, 0x0000,0x0000, /* Character 48 (0x30): width 25 +-------------------------+ | | | | | | | ****** | | ********** | | ************ | | ***** ***** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | *** **** | | **** **** | | **** **** | | **** **** | | **** **** | | ***** ***** | | ************ | | ********** | | ****** | | | | | | | | | | | | | | | | | +-------------------------+ */ 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x007e,0x0000, 0x01ff,0x8000, 0x03ff,0xc000, 0x07c3,0xe000, 0x0f00,0xf000, 0x0f00,0xf000, 0x1e00,0x7800, 0x1e00,0x7800, 0x1e00,0x7800, 0x3c00,0x3c00, 0x3c00,0x3c00, 0x3c00,0x3c00, 0x3c00,0x3c00, 0x3c00,0x3c00, 0x3c00,0x3c00, 0x3c00,0x3c00, 0x3c00,0x3c00, 0x3c00,0x3c00, 0x3c00,0x3c00, 0x1c00,0x7800, 0x1e00,0x7800, 0x1e00,0x7800, 0x0f00,0xf000, 0x0f00,0xf000, 0x07c3,0xe000, 0x03ff,0xc000, 0x01ff,0x8000, 0x007e,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, /* Character 49 (0x31): width 25 +-------------------------+ | | | | | | | **** | | ******** | | ******** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | | | | | | | | | | | | | | | | +-------------------------+ */ 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x003c,0x0000, 0x03fc,0x0000, 0x03fc,0x0000, 0x003c,0x0000, 0x003c,0x0000, 0x003c,0x0000, 0x003c,0x0000, 0x003c,0x0000, 0x003c,0x0000, 0x003c,0x0000, 0x003c,0x0000, 0x003c,0x0000, 0x003c,0x0000, 0x003c,0x0000, 0x003c,0x0000, 0x003c,0x0000, 0x003c,0x0000, 0x003c,0x0000, 0x003c,0x0000, 0x003c,0x0000, 0x003c,0x0000, 0x003c,0x0000, 0x003c,0x0000, 0x003c,0x0000, 0x003c,0x0000, 0x003c,0x0000, 0x003c,0x0000, 0x003c,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, /* Character 50 (0x32): width 25 +-------------------------+ | | | | | | | ******* | | ************ | | ************** | | **** ****** | | * **** | | **** | | **** | | **** | | **** | | **** | | ***** | | **** | | **** | | ***** | | ***** | | ***** | | ***** | | **** | | **** | | **** | | **** | | ***** | | ***** | | **** | | ***** | | ***************** | | ***************** | | ***************** | | | | | | | | | | | | | | | | | +-------------------------+ */ 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x00fe,0x0000, 0x07ff,0x8000, 0x0fff,0xc000, 0x0f07,0xe000, 0x0801,0xe000, 0x0000,0xf000, 0x0000,0xf000, 0x0000,0xf000, 0x0000,0xf000, 0x0000,0xf000, 0x0001,0xf000, 0x0001,0xe000, 0x0003,0xc000, 0x0007,0xc000, 0x000f,0x8000, 0x001f,0x0000, 0x003e,0x0000, 0x0078,0x0000, 0x00f0,0x0000, 0x01e0,0x0000, 0x03c0,0x0000, 0x07c0,0x0000, 0x0f80,0x0000, 0x0f00,0x0000, 0x1f00,0x0000, 0x1fff,0xf000, 0x1fff,0xf000, 0x1fff,0xf000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, /* Character 51 (0x33): width 25 +-------------------------+ | | | | | | | ******** | | ************* | | ************** | | ** ***** | | ***** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | ******** | | ******** | | ********** | | ****** | | ***** | | ***** | | **** | | **** | | **** | | **** | | ***** | | * **** | | *** ****** | | ************** | | ************* | | ******** | | | | | | | | | | | | | | | | | +-------------------------+ */ 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x03fc,0x0000, 0x0fff,0x8000, 0x0fff,0xc000, 0x0c07,0xc000, 0x0003,0xe000, 0x0001,0xe000, 0x0001,0xe000, 0x0001,0xe000, 0x0001,0xe000, 0x0003,0xc000, 0x0003,0xc000, 0x000f,0x0000, 0x01fe,0x0000, 0x01fe,0x0000, 0x01ff,0x8000, 0x000f,0xc000, 0x0003,0xe000, 0x0001,0xf000, 0x0000,0xf000, 0x0000,0xf000, 0x0000,0xf000, 0x0000,0xf000, 0x0001,0xf000, 0x0801,0xe000, 0x0e07,0xe000, 0x0fff,0xc000, 0x0fff,0x8000, 0x03fc,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, /* Character 52 (0x34): width 25 +-------------------------+ | | | | | | | **** | | ***** | | ****** | | ****** | | ******* | | ******** | | **** **** | | *** **** | | **** **** | | **** **** | | *** **** | | **** **** | | **** **** | | **** **** | | *** **** | | **** **** | | **** **** | | ******************** | | ******************** | | ******************** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | | | | | | | | | | | | | | | | +-------------------------+ */ 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0003,0xc000, 0x0007,0xc000, 0x000f,0xc000, 0x000f,0xc000, 0x001f,0xc000, 0x003f,0xc000, 0x007b,0xc000, 0x0073,0xc000, 0x00f3,0xc000, 0x01e3,0xc000, 0x01c3,0xc000, 0x03c3,0xc000, 0x0783,0xc000, 0x0f03,0xc000, 0x0e03,0xc000, 0x1e03,0xc000, 0x3c03,0xc000, 0x3fff,0xfc00, 0x3fff,0xfc00, 0x3fff,0xfc00, 0x0003,0xc000, 0x0003,0xc000, 0x0003,0xc000, 0x0003,0xc000, 0x0003,0xc000, 0x0003,0xc000, 0x0003,0xc000, 0x0003,0xc000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, /* Character 53 (0x35): width 25 +-------------------------+ | | | | | | | ************** | | ************** | | ************** | | *** | | *** | | *** | | *** | | *** | | *** | | *** | | ******* | | ********** | | ************ | | ******* | | ***** | | **** | | ***** | | **** | | **** | | **** | | **** | | **** | | **** | | ***** | | ** ***** | | ************* | | *********** | | ******* | | | | | | | | | | | | | | | | | +-------------------------+ */ 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x07ff,0xe000, 0x07ff,0xe000, 0x07ff,0xe000, 0x0700,0x0000, 0x0700,0x0000, 0x0700,0x0000, 0x0700,0x0000, 0x0700,0x0000, 0x0700,0x0000, 0x0700,0x0000, 0x07f0,0x0000, 0x07fe,0x0000, 0x07ff,0x8000, 0x001f,0xc000, 0x0003,0xe000, 0x0001,0xe000, 0x0001,0xf000, 0x0000,0xf000, 0x0000,0xf000, 0x0000,0xf000, 0x0000,0xf000, 0x0000,0xf000, 0x0001,0xe000, 0x0003,0xe000, 0x0607,0xc000, 0x07ff,0xc000, 0x07ff,0x0000, 0x01fc,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, /* Character 54 (0x36): width 25 +-------------------------+ | | | | | | | ******** | | ************ | | ************** | | ****** ** | | **** | | **** | | **** | | **** | | **** | | **** | | **** ****** | | **** ********** | | **** ************ | | ******* ****** | | ****** ***** | | ***** ***** | | **** **** | | **** **** | | **** **** | | **** **** | | *** **** | | **** **** | | **** **** | | **** **** | | **** ***** | | ************* | | ********** | | ****** | | | | | | | | | | | | | | | | | +-------------------------+ */ 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x001f,0xe000, 0x007f,0xf800, 0x01ff,0xf800, 0x03f0,0x1800, 0x03c0,0x0000, 0x0780,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x1e00,0x0000, 0x1e1f,0x8000, 0x1e7f,0xe000, 0x1eff,0xf000, 0x1fc1,0xf800, 0x1f80,0xf800, 0x1f00,0x7c00, 0x1e00,0x3c00, 0x1e00,0x3c00, 0x1e00,0x3c00, 0x1e00,0x3c00, 0x0e00,0x3c00, 0x0f00,0x3c00, 0x0f00,0x7800, 0x0780,0x7800, 0x03c1,0xf000, 0x03ff,0xe000, 0x00ff,0xc000, 0x003f,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, /* Character 55 (0x37): width 25 +-------------------------+ | | | | | | | ****************** | | ****************** | | ****************** | | ****************** | | **** | | **** | | **** | | **** | | **** | | *** | | **** | | *** | | **** | | **** | | *** | | **** | | *** | | **** | | **** | | **** | | **** | | **** | | ***** | | **** | | **** | | ***** | | **** | | **** | | | | | | | | | | | | | | | | | +-------------------------+ */ 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0fff,0xfc00, 0x0fff,0xfc00, 0x0fff,0xfc00, 0x0fff,0xfc00, 0x0000,0x3c00, 0x0000,0x7800, 0x0000,0xf000, 0x0000,0xf000, 0x0001,0xe000, 0x0001,0xc000, 0x0003,0xc000, 0x0003,0x8000, 0x0007,0x8000, 0x000f,0x0000, 0x000e,0x0000, 0x001e,0x0000, 0x001c,0x0000, 0x003c,0x0000, 0x0078,0x0000, 0x0078,0x0000, 0x00f0,0x0000, 0x00f0,0x0000, 0x01f0,0x0000, 0x01e0,0x0000, 0x01e0,0x0000, 0x03e0,0x0000, 0x03c0,0x0000, 0x03c0,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, /* Character 56 (0x38): width 25 +-------------------------+ | | | | | | | ******* | | ************ | | ************** | | ***** ***** | | ***** ***** | | **** **** | | **** **** | | **** **** | | ***** *** | | ***** **** | | ****** **** | | ******* **** | | ******** | | ********** | | **** ******* | | **** ******* | | **** ****** | | *** ***** | | **** ***** | | **** **** | | **** **** | | **** **** | | ***** **** | | **** **** | | ****** ****** | | *************** | | ************ | | ******* | | | | | | | | | | | | | | | | | +-------------------------+ */ 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x007f,0x0000, 0x01ff,0xe000, 0x03ff,0xf000, 0x07c1,0xf000, 0x0f80,0xf800, 0x0f00,0x7800, 0x0f00,0x7800, 0x0f00,0x7800, 0x0f80,0x7000, 0x07c0,0xf000, 0x07e1,0xe000, 0x03fb,0xc000, 0x00ff,0x0000, 0x01ff,0x8000, 0x03df,0xc000, 0x0787,0xf000, 0x0f01,0xf800, 0x0e00,0xf800, 0x1e00,0x7c00, 0x1e00,0x3c00, 0x1e00,0x3c00, 0x1e00,0x3c00, 0x1f00,0x3c00, 0x0f00,0x7800, 0x0fc1,0xf800, 0x07ff,0xf000, 0x03ff,0xc000, 0x007f,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, /* Character 57 (0x39): width 25 +-------------------------+ | | | | | | | ****** | | ********** | | ************ | | ***** **** | | **** **** | | **** **** | | **** **** | | **** *** | | **** **** | | **** **** | | **** **** | | **** **** | | **** ***** | | ***** ****** | | ***** ******* | | ************ **** | | ********* **** | | ***** **** | | *** | | **** | | **** | | **** | | **** | | **** | | ** ***** | | ************* | | ************ | | ******* | | | | | | | | | | | | | | | | | +-------------------------+ */ 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x007e,0x0000, 0x01ff,0x8000, 0x03ff,0xc000, 0x07c1,0xe000, 0x0f00,0xf000, 0x0f00,0x7800, 0x1e00,0x7800, 0x1e00,0x3800, 0x1e00,0x3c00, 0x1e00,0x3c00, 0x1e00,0x3c00, 0x1e00,0x3c00, 0x0f00,0x7c00, 0x0f80,0xfc00, 0x07c1,0xfc00, 0x07ff,0xbc00, 0x01ff,0x3c00, 0x007c,0x3c00, 0x0000,0x3800, 0x0000,0x7800, 0x0000,0x7800, 0x0000,0xf000, 0x0000,0xf000, 0x0001,0xe000, 0x0c07,0xc000, 0x0fff,0x8000, 0x0fff,0x0000, 0x03f8,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, /* Character 58 (0x3a): width 12 +------------+ | | | | | | | | | | | | | | | | | | | | | **** | | **** | | **** | | **** | | | | | | | | | | | | | | | | | | | | | | | | | | | | **** | | **** | | **** | | **** | | | | | | | | | | | | | | | | | +------------+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 59 (0x3b): width 12 +------------+ | | | | | | | | | | | | | | | | | | | | | **** | | **** | | **** | | **** | | | | | | | | | | | | | | | | | | | | | | | | | | | | **** | | **** | | **** | | **** | | ** | | ** | | ** | | ** | | ** | | * | | | | | +------------+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0300, 0x0300, 0x0300, 0x0600, 0x0600, 0x0800, 0x0000, 0x0000, /* Character 60 (0x3c): width 31 +-------------------------------+ | | | | | | | | | | | | | | | | | * | | *** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | *** | | * | | | | | | | | | | | | | | | | | +-------------------------------+ */ 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0020, 0x0000,0x00e0, 0x0000,0x03c0, 0x0000,0x0f00, 0x0000,0x3c00, 0x0000,0xf000, 0x0003,0xc000, 0x000f,0x0000, 0x003c,0x0000, 0x00f0,0x0000, 0x03c0,0x0000, 0x0f00,0x0000, 0x03c0,0x0000, 0x00f0,0x0000, 0x003c,0x0000, 0x000f,0x0000, 0x0003,0xc000, 0x0000,0xf000, 0x0000,0x3c00, 0x0000,0x0f00, 0x0000,0x03c0, 0x0000,0x00e0, 0x0000,0x0020, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, /* Character 61 (0x3d): width 31 +-------------------------------+ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | *********************** | | *********************** | | | | | | | | | | | | *********************** | | *********************** | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | +-------------------------------+ */ 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0fff,0xffe0, 0x0fff,0xffe0, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0fff,0xffe0, 0x0fff,0xffe0, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, /* Character 62 (0x3e): width 31 +-------------------------------+ | | | | | | | | | | | | | | | | | * | | *** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | *** | | * | | | | | | | | | | | | | | | | | +-------------------------------+ */ 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0800,0x0000, 0x0e00,0x0000, 0x0780,0x0000, 0x01e0,0x0000, 0x0078,0x0000, 0x001e,0x0000, 0x0007,0x8000, 0x0001,0xe000, 0x0000,0x7800, 0x0000,0x1e00, 0x0000,0x0780, 0x0000,0x01e0, 0x0000,0x0780, 0x0000,0x1e00, 0x0000,0x7800, 0x0001,0xe000, 0x0007,0x8000, 0x001e,0x0000, 0x0078,0x0000, 0x01e0,0x0000, 0x0780,0x0000, 0x0e00,0x0000, 0x0800,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, /* Character 63 (0x3f): width 16 +----------------+ | | | | | | | ******** | | ************* | | ************** | | ** ***** | | *****| | ****| | ****| | ****| | **** | | **** | | **** | | **** | | **** | | **** | | **** | | *** | | **** | | **** | | **** | | **** | | | | | | | | | | **** | | **** | | **** | | **** | | | | | | | | | | | | | | | | | +----------------+ */ 0x0000, 0x0000, 0x0000, 0x1fe0, 0x7ffc, 0x7ffe, 0x603e, 0x001f, 0x000f, 0x000f, 0x000f, 0x001e, 0x001e, 0x003c, 0x0078, 0x00f0, 0x01e0, 0x03c0, 0x0380, 0x0780, 0x0780, 0x0780, 0x0780, 0x0000, 0x0000, 0x0000, 0x0000, 0x0780, 0x0780, 0x0780, 0x0780, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 64 (0x40): width 33 +---------------------------------+ | | | | | | | ******* | | ************* | | ***** ***** | | **** **** | | *** *** | | *** ** | | *** ******** *** | | *** ********** ** | | *** *** *** *** | | ** *** *** ** | | *** *** *** ** | | ** ** ** ** | | ** *** ** ** | | ** *** *** ** | | ** ** **** ** | | ** *** *** ** | | ** *** **** ** | | ** *** ** ** ** | | ** *** ** ** *** | | ** **** *** *** **** | | ** ******* ******** | | ** **** ***** | | *** | | *** | | *** | | ***** ** | | ************* | | ******** | | | | | | | | | | | | | | | | | +---------------------------------+ */ 0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000, 0x0000,0xfe00,0x0000, 0x0007,0xffc0,0x0000, 0x001f,0x01f0,0x0000, 0x0078,0x0078,0x0000, 0x00e0,0x001c,0x0000, 0x01c0,0x000c,0x0000, 0x0380,0xff0e,0x0000, 0x0703,0xff06,0x0000, 0x0e07,0x0707,0x0000, 0x0c0e,0x0703,0x0000, 0x1c1c,0x0703,0x0000, 0x1818,0x0603,0x0000, 0x1838,0x0603,0x0000, 0x3038,0x0e03,0x0000, 0x3030,0x1e03,0x0000, 0x3070,0x1c06,0x0000, 0x3070,0x3c06,0x0000, 0x3070,0x6c0c,0x0000, 0x3070,0xcc1c,0x0000, 0x3079,0xdc78,0x0000, 0x183f,0x9fe0,0x0000, 0x181e,0x0f80,0x0000, 0x1c00,0x0000,0x0000, 0x0e00,0x0000,0x0000, 0x0700,0x0000,0x0000, 0x03e0,0x1800,0x0000, 0x00ff,0xf800,0x0000, 0x003f,0xc000,0x0000, 0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000, /* Character 65 (0x41): width 27 +---------------------------+ | | | | | | | **** | | ***** | | ****** | | ****** | | ******** | | *** **** | | *** ***** | | *** **** | | *** **** | | **** ***** | | *** **** | | *** ***** | | *** **** | | *** **** | | **** ***** | | *** **** | | *** ***** | | ****************** | | ****************** | | ******************** | | *** **** | | *** **** | | *** **** | | *** **** | | **** ***** | | *** **** | | *** **** | |*** ***** | | | | | | | | | | | | | | | | | +---------------------------+ */ 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x001e,0x0000, 0x001f,0x0000, 0x003f,0x0000, 0x003f,0x0000, 0x007f,0x8000, 0x0077,0x8000, 0x0077,0xc000, 0x00e3,0xc000, 0x00e3,0xc000, 0x01e3,0xe000, 0x01c1,0xe000, 0x01c1,0xf000, 0x0380,0xf000, 0x0380,0xf000, 0x0780,0xf800, 0x0700,0x7800, 0x0700,0x7c00, 0x0fff,0xfc00, 0x0fff,0xfc00, 0x1fff,0xfe00, 0x1c00,0x1e00, 0x1c00,0x1e00, 0x3800,0x0f00, 0x3800,0x0f00, 0x7800,0x0f80, 0x7000,0x0780, 0x7000,0x0780, 0xe000,0x07c0, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, /* Character 66 (0x42): width 22 +----------------------+ | | | | | | | *********** | | ************** | | *************** | | **** ****** | | **** ***** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | ************ | | *********** | | ************* | | **** ****** | | **** **** | | **** **** | | **** ***** | | **** **** | | **** **** | | **** **** | | **** **** | | **** ***** | | **** ****** | | *************** | | ************** | | ************ | | | | | | | | | | | | | | | | | +----------------------+ */ 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0ffe,0x0000, 0x0fff,0xc000, 0x0fff,0xe000, 0x0f07,0xe000, 0x0f01,0xf000, 0x0f00,0xf000, 0x0f00,0xf000, 0x0f00,0xf000, 0x0f00,0xf000, 0x0f01,0xe000, 0x0f03,0xc000, 0x0f07,0x8000, 0x0fff,0x0000, 0x0ffe,0x0000, 0x0fff,0x8000, 0x0f0f,0xc000, 0x0f01,0xe000, 0x0f00,0xf000, 0x0f00,0xf800, 0x0f00,0x7800, 0x0f00,0x7800, 0x0f00,0x7800, 0x0f00,0x7800, 0x0f00,0xf800, 0x0f03,0xf000, 0x0fff,0xe000, 0x0fff,0xc000, 0x0fff,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, /* Character 67 (0x43): width 27 +---------------------------+ | | | | | | | ********** | | **************** | | ****************** | | ****** ***** | | ***** ** | | ***** | | **** | | **** | | **** | | ***** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | ***** | | **** | | ***** | | **** | | ***** | | ***** * | | ******* ***** | | ****************** | | *************** | | ********** | | | | | | | | | | | | | | | | | +---------------------------+ */ 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x000f,0xfc00, 0x007f,0xff80, 0x01ff,0xff80, 0x03f0,0x0f80, 0x07c0,0x0180, 0x0f80,0x0000, 0x0f00,0x0000, 0x1e00,0x0000, 0x1e00,0x0000, 0x3e00,0x0000, 0x3c00,0x0000, 0x3c00,0x0000, 0x3c00,0x0000, 0x3c00,0x0000, 0x3c00,0x0000, 0x3c00,0x0000, 0x3c00,0x0000, 0x3c00,0x0000, 0x3e00,0x0000, 0x1e00,0x0000, 0x1f00,0x0000, 0x0f00,0x0000, 0x0f80,0x0000, 0x07c0,0x0080, 0x03f8,0x0f80, 0x01ff,0xff80, 0x007f,0xff00, 0x001f,0xf800, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, /* Character 68 (0x44): width 29 +-----------------------------+ | | | | | | | *************** | | ****************** | | ******************* | | **** ******* | | **** ***** | | **** ***** | | **** ***** | | **** **** | | **** **** | | **** ***** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** ***** | | **** **** | | **** **** | | **** ***** | | **** ******* | | ******************* | | ***************** | | ************** | | | | | | | | | | | | | | | | | +-----------------------------+ */ 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0fff,0xe000, 0x0fff,0xfc00, 0x0fff,0xfe00, 0x0f00,0x7f00, 0x0f00,0x0f80, 0x0f00,0x07c0, 0x0f00,0x03e0, 0x0f00,0x01e0, 0x0f00,0x01e0, 0x0f00,0x01f0, 0x0f00,0x00f0, 0x0f00,0x00f0, 0x0f00,0x00f0, 0x0f00,0x00f0, 0x0f00,0x00f0, 0x0f00,0x00f0, 0x0f00,0x00f0, 0x0f00,0x00f0, 0x0f00,0x01e0, 0x0f00,0x01e0, 0x0f00,0x03e0, 0x0f00,0x03c0, 0x0f00,0x0780, 0x0f00,0x0f80, 0x0f00,0x7f00, 0x0fff,0xfe00, 0x0fff,0xf800, 0x0fff,0xc000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, /* Character 69 (0x45): width 21 +---------------------+ | | | | | | | **************** | | **************** | | **************** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | ************** | | ************** | | ************** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | *****************| | *****************| | *****************| | | | | | | | | | | | | | | | | +---------------------+ */ 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0fff,0xf000, 0x0fff,0xf000, 0x0fff,0xf000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0fff,0xc000, 0x0fff,0xc000, 0x0fff,0xc000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0fff,0xf800, 0x0fff,0xf800, 0x0fff,0xf800, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, /* Character 70 (0x46): width 21 +---------------------+ | | | | | | | **************** | | **************** | | **************** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | ************** | | ************** | | ************** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | | | | | | | | | | | | | | | | +---------------------+ */ 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0fff,0xf000, 0x0fff,0xf000, 0x0fff,0xf000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0fff,0xc000, 0x0fff,0xc000, 0x0fff,0xc000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, /* Character 71 (0x47): width 28 +----------------------------+ | | | | | | | ********** | | **************** | | ****************** | | ****** ***** | | ***** ** | | ***** | | **** | | **** | | **** | | ***** | | **** | | **** | | **** | | **** | | **** | | **** | | **** **** | | **** **** | | ***** **** | | **** **** | | ***** **** | | ***** **** | | ***** **** | | ***** **** | | ******* ***** | | ****************** | | **************** | | ********** | | | | | | | | | | | | | | | | | +----------------------------+ */ 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x000f,0xfc00, 0x007f,0xff80, 0x01ff,0xff80, 0x03f0,0x0f80, 0x07c0,0x0180, 0x0f80,0x0000, 0x0f00,0x0000, 0x1e00,0x0000, 0x1e00,0x0000, 0x3e00,0x0000, 0x3c00,0x0000, 0x3c00,0x0000, 0x3c00,0x0000, 0x3c00,0x0000, 0x3c00,0x0000, 0x3c00,0x0000, 0x3c00,0x0780, 0x3c00,0x0780, 0x3e00,0x0780, 0x1e00,0x0780, 0x1f00,0x0780, 0x1f00,0x0780, 0x0f80,0x0780, 0x07c0,0x0780, 0x03f8,0x0f80, 0x01ff,0xff80, 0x007f,0xff80, 0x001f,0xf800, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, /* Character 72 (0x48): width 29 +-----------------------------+ | | | | | | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | ********************* | | ********************* | | ********************* | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | | | | | | | | | | | | | | | | +-----------------------------+ */ 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0f00,0x0780, 0x0f00,0x0780, 0x0f00,0x0780, 0x0f00,0x0780, 0x0f00,0x0780, 0x0f00,0x0780, 0x0f00,0x0780, 0x0f00,0x0780, 0x0f00,0x0780, 0x0f00,0x0780, 0x0f00,0x0780, 0x0f00,0x0780, 0x0fff,0xff80, 0x0fff,0xff80, 0x0fff,0xff80, 0x0f00,0x0780, 0x0f00,0x0780, 0x0f00,0x0780, 0x0f00,0x0780, 0x0f00,0x0780, 0x0f00,0x0780, 0x0f00,0x0780, 0x0f00,0x0780, 0x0f00,0x0780, 0x0f00,0x0780, 0x0f00,0x0780, 0x0f00,0x0780, 0x0f00,0x0780, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, /* Character 73 (0x49): width 11 +-----------+ | | | | | | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | | | | | | | | | | | | | | | | +-----------+ */ 0x0000, 0x0000, 0x0000, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 74 (0x4a): width 15 +---------------+ | | | | | | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | |* ***** | |********** | |********* | |******* | | | | | +---------------+ */ 0x0000, 0x0000, 0x0000, 0x00f0, 0x00f0, 0x00f0, 0x00f0, 0x00f0, 0x00f0, 0x00f0, 0x00f0, 0x00f0, 0x00f0, 0x00f0, 0x00f0, 0x00f0, 0x00f0, 0x00f0, 0x00f0, 0x00f0, 0x00f0, 0x00f0, 0x00f0, 0x00f0, 0x00f0, 0x00f0, 0x00f0, 0x00f0, 0x00f0, 0x00f0, 0x00f0, 0x00f0, 0x01e0, 0x83e0, 0xffc0, 0xff80, 0xfe00, 0x0000, 0x0000, /* Character 75 (0x4b): width 25 +-------------------------+ | | | | | | | **** *** | | **** **** | | **** **** | | **** **** | | **** **** | | **** *** | | **** **** | | **** **** | | **** **** | | **** **** | | **** *** | | **** **** | | **** **** | | ********* | | **** ***** | | **** ***** | | **** ***** | | **** ***** | | **** ***** | | **** ***** | | **** ***** | | **** ***** | | **** ***** | | **** ***** | | **** ***** | | **** ***** | | **** ***** | | **** *****| | | | | | | | | | | | | | | | | +-------------------------+ */ 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0f00,0x1c00, 0x0f00,0x3c00, 0x0f00,0x7800, 0x0f00,0xf000, 0x0f01,0xe000, 0x0f01,0xc000, 0x0f03,0xc000, 0x0f07,0x8000, 0x0f0f,0x0000, 0x0f1e,0x0000, 0x0f1c,0x0000, 0x0f3c,0x0000, 0x0f78,0x0000, 0x0ff8,0x0000, 0x0f7c,0x0000, 0x0f7c,0x0000, 0x0f3e,0x0000, 0x0f1f,0x0000, 0x0f0f,0x8000, 0x0f07,0xc000, 0x0f03,0xe000, 0x0f01,0xf000, 0x0f01,0xf000, 0x0f00,0xf800, 0x0f00,0x7c00, 0x0f00,0x3e00, 0x0f00,0x1f00, 0x0f00,0x0f80, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, /* Character 76 (0x4c): width 21 +---------------------+ | | | | | | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | *****************| | *****************| | *****************| | | | | | | | | | | | | | | | | +---------------------+ */ 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0fff,0xf800, 0x0fff,0xf800, 0x0fff,0xf800, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, /* Character 77 (0x4d): width 34 +----------------------------------+ | | | | | | | ***** ***** | | ****** ****** | | ****** ****** | | ****** ****** | | ******* ******* | | ******* ******* | | ******* ******** | | *** **** *** **** | | *** **** *** **** | | *** ***** **** **** | | *** **** *** **** | | *** **** *** **** | | *** ***** **** **** | | *** **** *** **** | | *** **** *** **** | | *** **** *** **** | | *** **** *** **** | | *** ***** **** **** | | *** **** *** **** | | *** **** *** **** | | *** ********* **** | | *** ******* **** | | *** ******* **** | | *** ****** **** | | *** ***** **** | | *** ***** **** | | *** **** | | *** **** | | | | | | | | | | | | | | | | | +----------------------------------+ */ 0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000, 0x0f80,0x007c,0x0000, 0x0fc0,0x00fc,0x0000, 0x0fc0,0x00fc,0x0000, 0x0fc0,0x00fc,0x0000, 0x0fe0,0x01fc,0x0000, 0x0fe0,0x01fc,0x0000, 0x0fe0,0x03fc,0x0000, 0x0ef0,0x03bc,0x0000, 0x0ef0,0x03bc,0x0000, 0x0ef8,0x07bc,0x0000, 0x0e78,0x073c,0x0000, 0x0e78,0x073c,0x0000, 0x0e7c,0x0f3c,0x0000, 0x0e3c,0x0e3c,0x0000, 0x0e3c,0x0e3c,0x0000, 0x0e1e,0x1c3c,0x0000, 0x0e1e,0x1c3c,0x0000, 0x0e1f,0x3c3c,0x0000, 0x0e0f,0x383c,0x0000, 0x0e0f,0x383c,0x0000, 0x0e0f,0xf83c,0x0000, 0x0e07,0xf03c,0x0000, 0x0e07,0xf03c,0x0000, 0x0e03,0xf03c,0x0000, 0x0e03,0xe03c,0x0000, 0x0e03,0xe03c,0x0000, 0x0e00,0x003c,0x0000, 0x0e00,0x003c,0x0000, 0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000, /* Character 78 (0x4e): width 29 +-----------------------------+ | | | | | | | **** *** | | ***** *** | | ****** *** | | ****** *** | | ******* *** | | ******** *** | | *** **** *** | | *** ***** *** | | *** ***** *** | | *** **** *** | | *** ***** *** | | *** ***** *** | | *** **** *** | | *** ***** *** | | *** ***** *** | | *** **** *** | | *** ***** *** | | *** ***** *** | | *** **** *** | | *** ***** *** | | *** ***** *** | | *** **** *** | | *** ******** | | *** ******* | | *** ****** | | *** ****** | | *** ***** | | *** **** | | | | | | | | | | | | | | | | | +-----------------------------+ */ 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0f00,0x01c0, 0x0f80,0x01c0, 0x0fc0,0x01c0, 0x0fc0,0x01c0, 0x0fe0,0x01c0, 0x0ff0,0x01c0, 0x0ef0,0x01c0, 0x0ef8,0x01c0, 0x0e7c,0x01c0, 0x0e3c,0x01c0, 0x0e3e,0x01c0, 0x0e1f,0x01c0, 0x0e0f,0x01c0, 0x0e0f,0x81c0, 0x0e07,0xc1c0, 0x0e03,0xc1c0, 0x0e03,0xe1c0, 0x0e01,0xf1c0, 0x0e00,0xf1c0, 0x0e00,0xf9c0, 0x0e00,0x7dc0, 0x0e00,0x3dc0, 0x0e00,0x3fc0, 0x0e00,0x1fc0, 0x0e00,0x0fc0, 0x0e00,0x0fc0, 0x0e00,0x07c0, 0x0e00,0x03c0, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, /* Character 79 (0x4f): width 30 +------------------------------+ | | | | | | | ******** | | ************* | | **************** | | ****** ****** | | ***** ***** | | ***** ***** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | ***** ***** | | ***** ***** | | ****** ****** | | **************** | | ************* | | ******** | | | | | | | | | | | | | | | | | +------------------------------+ */ 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x001f,0xe000, 0x00ff,0xf800, 0x01ff,0xfe00, 0x03f0,0x3f00, 0x07c0,0x0f80, 0x0f80,0x07c0, 0x0f00,0x03c0, 0x1e00,0x01e0, 0x1e00,0x01e0, 0x1e00,0x01e0, 0x3c00,0x00f0, 0x3c00,0x00f0, 0x3c00,0x00f0, 0x3c00,0x00f0, 0x3c00,0x00f0, 0x3c00,0x00f0, 0x3c00,0x00f0, 0x3c00,0x00f0, 0x1e00,0x01e0, 0x1e00,0x01e0, 0x1e00,0x01e0, 0x0f00,0x03c0, 0x0f80,0x07c0, 0x07c0,0x0f80, 0x03f0,0x3f00, 0x01ff,0xfe00, 0x00ff,0xf800, 0x001f,0xe000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, /* Character 80 (0x50): width 22 +----------------------+ | | | | | | | ************ | | ************** | | **************** | | **** ****** | | **** ***** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** ***** | | **** **** | | **** ***** | | **** ****** | | ************** | | ************* | | ********** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | | | | | | | | | | | | | | | | +----------------------+ */ 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0fff,0x0000, 0x0fff,0xc000, 0x0fff,0xf000, 0x0f03,0xf000, 0x0f00,0xf800, 0x0f00,0x7800, 0x0f00,0x7800, 0x0f00,0x7800, 0x0f00,0x7800, 0x0f00,0x7800, 0x0f00,0xf800, 0x0f00,0xf000, 0x0f01,0xf000, 0x0f07,0xe000, 0x0fff,0xc000, 0x0fff,0x8000, 0x0ffc,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, /* Character 81 (0x51): width 30 +------------------------------+ | | | | | | | ******** | | ************* | | **************** | | ****** ****** | | ***** ***** | | ***** ***** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** ***** | | **** **** | | **** **** | | **** **** | | ***** ***** | | ***** ***** | | ****** ****** | | **************** | | ************* | | *********** | | ******* | | ********* | | ********| | ******| | ** | | | | | | | +------------------------------+ */ 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x001f,0xe000, 0x00ff,0xf800, 0x01ff,0xfe00, 0x03f0,0x3f00, 0x07c0,0x0f80, 0x0f80,0x07c0, 0x0f00,0x03c0, 0x1e00,0x01e0, 0x1e00,0x01e0, 0x1e00,0x01e0, 0x3c00,0x00f0, 0x3c00,0x00f0, 0x3c00,0x00f0, 0x3c00,0x00f0, 0x3c00,0x00f0, 0x3c00,0x00f0, 0x3c00,0x00f0, 0x3c00,0x00f0, 0x1e00,0x01f0, 0x1e00,0x01e0, 0x1e00,0x01e0, 0x0f00,0x03c0, 0x0f80,0x07c0, 0x07c0,0x0f80, 0x03f0,0x3f00, 0x01ff,0xfe00, 0x00ff,0xf800, 0x001f,0xfc00, 0x0000,0x3f80, 0x0000,0x0ff8, 0x0000,0x03fe, 0x0000,0x00fc, 0x0000,0x0018, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, /* Character 82 (0x52): width 25 +-------------------------+ | | | | | | | ************ | | ************** | | **************** | | **** ****** | | **** ***** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** ***** | | **** ****** | | ************** | | ************ | | ************ | | **** ***** | | **** **** | | **** ***** | | **** ***** | | **** ***** | | **** **** | | **** ***** | | **** ***** | | **** **** | | **** ***** | | **** ***** | | **** *****| | | | | | | | | | | | | | | | | +-------------------------+ */ 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0fff,0x0000, 0x0fff,0xc000, 0x0fff,0xf000, 0x0f03,0xf000, 0x0f00,0xf800, 0x0f00,0x7800, 0x0f00,0x7800, 0x0f00,0x7800, 0x0f00,0x7800, 0x0f00,0x7800, 0x0f00,0xf000, 0x0f01,0xf000, 0x0f07,0xe000, 0x0fff,0xc000, 0x0fff,0x0000, 0x0fff,0x0000, 0x0f0f,0x8000, 0x0f07,0x8000, 0x0f07,0xc000, 0x0f03,0xe000, 0x0f01,0xf000, 0x0f00,0xf000, 0x0f00,0xf800, 0x0f00,0x7c00, 0x0f00,0x3c00, 0x0f00,0x3e00, 0x0f00,0x1f00, 0x0f00,0x0f80, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, /* Character 83 (0x53): width 21 +---------------------+ | | | | | | | ******** | | ************ | | ************* | | ***** **** | | ***** * | | **** | | **** | | **** | | ***** | | ****** | | ****** | | ******* | | ******** | | ******** | | ******** | | ******* | | ****** | | ***** | | ***** | | **** | | **** | | **** | | **** | | * **** | | **** ****** | | *************** | | ************* | | ********* | | | | | | | | | | | | | | | | | +---------------------+ */ 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x01fe,0x0000, 0x07ff,0x8000, 0x0fff,0x8000, 0x1f07,0x8000, 0x3e00,0x8000, 0x3c00,0x0000, 0x3c00,0x0000, 0x3c00,0x0000, 0x3e00,0x0000, 0x3f00,0x0000, 0x1f80,0x0000, 0x0fe0,0x0000, 0x07f8,0x0000, 0x03fc,0x0000, 0x00ff,0x0000, 0x003f,0x8000, 0x000f,0xc000, 0x0007,0xc000, 0x0003,0xe000, 0x0001,0xe000, 0x0001,0xe000, 0x0001,0xe000, 0x0001,0xe000, 0x2003,0xc000, 0x3c0f,0xc000, 0x3fff,0x8000, 0x3ffe,0x0000, 0x0ff8,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, /* Character 84 (0x54): width 25 +-------------------------+ | | | | | | |************************ | |************************ | |************************ | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | | | | | | | | | | | | | | | | +-------------------------+ */ 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0xffff,0xff00, 0xffff,0xff00, 0xffff,0xff00, 0x003c,0x0000, 0x003c,0x0000, 0x003c,0x0000, 0x003c,0x0000, 0x003c,0x0000, 0x003c,0x0000, 0x003c,0x0000, 0x003c,0x0000, 0x003c,0x0000, 0x003c,0x0000, 0x003c,0x0000, 0x003c,0x0000, 0x003c,0x0000, 0x003c,0x0000, 0x003c,0x0000, 0x003c,0x0000, 0x003c,0x0000, 0x003c,0x0000, 0x003c,0x0000, 0x003c,0x0000, 0x003c,0x0000, 0x003c,0x0000, 0x003c,0x0000, 0x003c,0x0000, 0x003c,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, /* Character 85 (0x55): width 27 +---------------------------+ | | | | | | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | ***** ***** | | **** **** | | ***** ***** | | ***** ***** | | ************** | | ************ | | ******** | | | | | | | | | | | | | | | | | +---------------------------+ */ 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x1e00,0x1e00, 0x1e00,0x1e00, 0x1e00,0x1e00, 0x1e00,0x1e00, 0x1e00,0x1e00, 0x1e00,0x1e00, 0x1e00,0x1e00, 0x1e00,0x1e00, 0x1e00,0x1e00, 0x1e00,0x1e00, 0x1e00,0x1e00, 0x1e00,0x1e00, 0x1e00,0x1e00, 0x1e00,0x1e00, 0x1e00,0x1e00, 0x1e00,0x1e00, 0x1e00,0x1e00, 0x1e00,0x1e00, 0x1e00,0x1e00, 0x1e00,0x1e00, 0x1e00,0x1e00, 0x1f00,0x3e00, 0x0f00,0x3c00, 0x0f80,0x7c00, 0x07c0,0xf800, 0x03ff,0xf000, 0x01ff,0xe000, 0x007f,0x8000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, /* Character 86 (0x56): width 26 +--------------------------+ | | | | | | | **** ***| | **** *** | | **** *** | | ***** **** | | **** *** | | **** *** | | **** **** | | **** *** | | ***** *** | | **** *** | | **** *** | | ***** **** | | **** *** | | **** *** | | **** **** | | **** *** | | ***** *** | | **** **** | | **** *** | | **** *** | | **** *** | | ***** *** | | ******** | | ******* | | ******* | | ****** | | ***** | | **** | | | | | | | | | | | | | | | | | +--------------------------+ */ 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x7800,0x01c0, 0x3c00,0x0380, 0x3c00,0x0380, 0x3e00,0x0780, 0x1e00,0x0700, 0x1e00,0x0700, 0x0f00,0x0f00, 0x0f00,0x0e00, 0x0f80,0x0e00, 0x0780,0x1c00, 0x0780,0x1c00, 0x07c0,0x3c00, 0x03c0,0x3800, 0x03c0,0x3800, 0x01e0,0x7800, 0x01e0,0x7000, 0x01f0,0x7000, 0x00f0,0xf000, 0x00f0,0xe000, 0x0078,0xe000, 0x0079,0xc000, 0x007d,0xc000, 0x003f,0xc000, 0x003f,0x8000, 0x003f,0x8000, 0x001f,0x8000, 0x001f,0x0000, 0x000f,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, /* Character 87 (0x57): width 33 +---------------------------------+ | | | | | | |**** **** ***| |**** **** ****| | **** ****** *** | | **** ****** *** | | **** ****** *** | | **** ****** *** | | **** ******* *** | | **** *** **** *** | | **** *** **** **** | | ***** *** **** *** | | **** *** **** *** | | **** *** **** *** | | **** *** **** *** | | ***** *** **** *** | | **** *** **** *** | | **** *** **** **** | | **** *** ***** *** | | ***** **** **** *** | | **** *** **** *** | | **** *** **** *** | | **** *** **** *** | | ******** ******* | | ****** ******* | | ****** ****** | | ****** ****** | | ****** ****** | | **** **** | | **** **** | | | | | | | | | | | | | | | | | +---------------------------------+ */ 0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000, 0xf001,0xe003,0x8000, 0xf001,0xe007,0x8000, 0x7803,0xf007,0x0000, 0x7803,0xf007,0x0000, 0x7803,0xf007,0x0000, 0x7803,0xf00e,0x0000, 0x3c07,0xf00e,0x0000, 0x3c07,0x780e,0x0000, 0x3c07,0x781e,0x0000, 0x3e07,0x781c,0x0000, 0x1e0e,0x781c,0x0000, 0x1e0e,0x781c,0x0000, 0x1e0e,0x3c38,0x0000, 0x1f0e,0x3c38,0x0000, 0x0f1c,0x3c38,0x0000, 0x0f1c,0x3c78,0x0000, 0x0f1c,0x3e70,0x0000, 0x0fbc,0x1e70,0x0000, 0x07b8,0x1e70,0x0000, 0x07b8,0x1ee0,0x0000, 0x07b8,0x1ee0,0x0000, 0x07f8,0x0fe0,0x0000, 0x03f0,0x0fe0,0x0000, 0x03f0,0x0fc0,0x0000, 0x03f0,0x0fc0,0x0000, 0x03f0,0x0fc0,0x0000, 0x01e0,0x0780,0x0000, 0x01e0,0x0780,0x0000, 0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000, /* Character 88 (0x58): width 24 +------------------------+ | | | | | | |***** **** | | ***** **** | | **** *** | | ***** **** | | ***** **** | | **** *** | | ***** **** | | ***** **** | | **** *** | | ***** **** | | ********* | | ******** | | ******* | | ***** | | ***** | | ******* | | ******** | | ********* | | **** ***** | | *** **** | | **** ***** | | **** ***** | | *** **** | | **** ***** | | **** ***** | | *** **** | | **** ***** | |**** ***** | | | | | | | | | | | | | | | | | +------------------------+ */ 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0xf800,0x1e00, 0x7c00,0x3c00, 0x3c00,0x3800, 0x3e00,0x7800, 0x1f00,0xf000, 0x0f00,0xe000, 0x0f81,0xe000, 0x07c3,0xc000, 0x03c3,0x8000, 0x03e7,0x8000, 0x01ff,0x0000, 0x01fe,0x0000, 0x00fe,0x0000, 0x007c,0x0000, 0x007c,0x0000, 0x00fe,0x0000, 0x00ff,0x0000, 0x01ff,0x0000, 0x03cf,0x8000, 0x0387,0x8000, 0x0787,0xc000, 0x0f03,0xe000, 0x0e01,0xe000, 0x1e01,0xf000, 0x3c00,0xf800, 0x3800,0x7800, 0x7800,0x7c00, 0xf000,0x3e00, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, /* Character 89 (0x59): width 24 +------------------------+ | | | | | | |***** **** | | **** *** | | ***** *** | | ***** **** | | ***** *** | | ***** **** | | **** **** | | ***** *** | | **** **** | | ***** *** | | **** **** | | ***** **** | | **** *** | | ******** | | ****** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | | | | | | | | | | | | | | | | +------------------------+ */ 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0xf800,0x1e00, 0x7800,0x1c00, 0x7c00,0x3800, 0x3e00,0x7800, 0x3e00,0x7000, 0x1f00,0xf000, 0x0f01,0xe000, 0x0f81,0xc000, 0x0783,0xc000, 0x07c3,0x8000, 0x03c7,0x8000, 0x03ef,0x0000, 0x01ee,0x0000, 0x01fe,0x0000, 0x00fc,0x0000, 0x0078,0x0000, 0x0078,0x0000, 0x0078,0x0000, 0x0078,0x0000, 0x0078,0x0000, 0x0078,0x0000, 0x0078,0x0000, 0x0078,0x0000, 0x0078,0x0000, 0x0078,0x0000, 0x0078,0x0000, 0x0078,0x0000, 0x0078,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, /* Character 90 (0x5a): width 24 +------------------------+ | | | | | | | ******************* | | ******************* | | ******************* | | ***** | | ***** | | ***** | | ***** | | ***** | | ***** | | ***** | | ***** | | ***** | | **** | | ***** | | ***** | | **** | | ***** | | ***** | | ***** | | ***** | | ***** | | ***** | | ***** | | ***** | | ***** | | ******************** | | ******************** | | ******************** | | | | | | | | | | | | | | | | | +------------------------+ */ 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x1fff,0xfc00, 0x1fff,0xfc00, 0x1fff,0xfc00, 0x0000,0x7c00, 0x0000,0xf800, 0x0001,0xf000, 0x0001,0xf000, 0x0003,0xe000, 0x0007,0xc000, 0x0007,0xc000, 0x000f,0x8000, 0x001f,0x0000, 0x001e,0x0000, 0x003e,0x0000, 0x007c,0x0000, 0x0078,0x0000, 0x00f8,0x0000, 0x01f0,0x0000, 0x03e0,0x0000, 0x03e0,0x0000, 0x07c0,0x0000, 0x0f80,0x0000, 0x0f80,0x0000, 0x1f00,0x0000, 0x3e00,0x0000, 0x3fff,0xfc00, 0x3fff,0xfc00, 0x3fff,0xfc00, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, /* Character 91 (0x5b): width 13 +-------------+ | | | ******** | | ******** | | ******** | | *** | | *** | | *** | | *** | | *** | | *** | | *** | | *** | | *** | | *** | | *** | | *** | | *** | | *** | | *** | | *** | | *** | | *** | | *** | | *** | | *** | | *** | | *** | | *** | | *** | | *** | | *** | | *** | | *** | | *** | | ******** | | ******** | | ******** | | | | | +-------------+ */ 0x0000, 0x0ff0, 0x0ff0, 0x0ff0, 0x0e00, 0x0e00, 0x0e00, 0x0e00, 0x0e00, 0x0e00, 0x0e00, 0x0e00, 0x0e00, 0x0e00, 0x0e00, 0x0e00, 0x0e00, 0x0e00, 0x0e00, 0x0e00, 0x0e00, 0x0e00, 0x0e00, 0x0e00, 0x0e00, 0x0e00, 0x0e00, 0x0e00, 0x0e00, 0x0e00, 0x0e00, 0x0e00, 0x0e00, 0x0e00, 0x0ff0, 0x0ff0, 0x0ff0, 0x0000, 0x0000, /* Character 92 (0x5c): width 20 +--------------------+ | | | | | | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | * | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | * | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | | | | +--------------------+ */ 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0c00,0x0000, 0x0c00,0x0000, 0x0600,0x0000, 0x0600,0x0000, 0x0600,0x0000, 0x0300,0x0000, 0x0300,0x0000, 0x0300,0x0000, 0x0100,0x0000, 0x0180,0x0000, 0x0180,0x0000, 0x0180,0x0000, 0x00c0,0x0000, 0x00c0,0x0000, 0x00c0,0x0000, 0x0060,0x0000, 0x0060,0x0000, 0x0060,0x0000, 0x0060,0x0000, 0x0030,0x0000, 0x0030,0x0000, 0x0030,0x0000, 0x0018,0x0000, 0x0018,0x0000, 0x0018,0x0000, 0x0008,0x0000, 0x000c,0x0000, 0x000c,0x0000, 0x000c,0x0000, 0x0006,0x0000, 0x0006,0x0000, 0x0006,0x0000, 0x0003,0x0000, 0x0003,0x0000, 0x0000,0x0000, 0x0000,0x0000, /* Character 93 (0x5d): width 13 +-------------+ | | | ******** | | ******** | | ******** | | *** | | *** | | *** | | *** | | *** | | *** | | *** | | *** | | *** | | *** | | *** | | *** | | *** | | *** | | *** | | *** | | *** | | *** | | *** | | *** | | *** | | *** | | *** | | *** | | *** | | *** | | *** | | *** | | *** | | *** | | ******** | | ******** | | ******** | | | | | +-------------+ */ 0x0000, 0x7f80, 0x7f80, 0x7f80, 0x0380, 0x0380, 0x0380, 0x0380, 0x0380, 0x0380, 0x0380, 0x0380, 0x0380, 0x0380, 0x0380, 0x0380, 0x0380, 0x0380, 0x0380, 0x0380, 0x0380, 0x0380, 0x0380, 0x0380, 0x0380, 0x0380, 0x0380, 0x0380, 0x0380, 0x0380, 0x0380, 0x0380, 0x0380, 0x0380, 0x7f80, 0x7f80, 0x7f80, 0x0000, 0x0000, /* Character 94 (0x5e): width 25 +-------------------------+ | | | | | | | * | | * | | *** | | *** | | ***** | | ***** | | *** *** | | *** *** | | *** *** | | *** *** | | *** *** | | *** *** | | *** *** | | *** *** | | *** *** | | *** *** | | *** *** | | *** *** | | *** *** | | *** *** | | *** *** | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | +-------------------------+ */ 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0008,0x0000, 0x0008,0x0000, 0x001c,0x0000, 0x001c,0x0000, 0x003e,0x0000, 0x003e,0x0000, 0x0077,0x0000, 0x0077,0x0000, 0x00e3,0x8000, 0x00e3,0x8000, 0x01c1,0xc000, 0x01c1,0xc000, 0x0380,0xe000, 0x0380,0xe000, 0x0700,0x7000, 0x0700,0x7000, 0x0e00,0x3800, 0x0e00,0x3800, 0x1c00,0x1c00, 0x1c00,0x1c00, 0x3800,0x0e00, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, /* Character 95 (0x5f): width 20 +--------------------+ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | **************** | | **************** | | **************** | | | | | | | | | | | +--------------------+ */ 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x3fff,0xc000, 0x3fff,0xc000, 0x3fff,0xc000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, /* Character 96 (0x60): width 24 +------------------------+ | | | ***** | | ***** | | **** | | **** | | **** | | **** | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | +------------------------+ */ 0x0000,0x0000, 0x00f8,0x0000, 0x007c,0x0000, 0x003c,0x0000, 0x001e,0x0000, 0x000f,0x0000, 0x0007,0x8000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, /* Character 97 (0x61): width 22 +----------------------+ | | | | | | | | | | | | | | | | | | | | | ******* | | *********** | | ************* | | *** ****** | | * **** | | **** | | **** | | **** | | **** | | ********** | | ************* | | ***** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** ***** | | ***** ******* | | *********** ****** | | ********* ****** | | ****** ***** | | | | | | | | | | | | | | | | | +----------------------+ */ 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x00fe,0x0000, 0x07ff,0x0000, 0x0fff,0x8000, 0x0e0f,0xc000, 0x0803,0xc000, 0x0003,0xc000, 0x0003,0xc000, 0x0003,0xc000, 0x0003,0xc000, 0x00ff,0xc000, 0x07ff,0xc000, 0x0f83,0xc000, 0x1e03,0xc000, 0x3c03,0xc000, 0x3c03,0xc000, 0x3c03,0xc000, 0x3c07,0xc000, 0x3e0f,0xe000, 0x1ffd,0xf800, 0x0ff9,0xf800, 0x07e0,0xf800, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, /* Character 98 (0x62): width 25 +-------------------------+ | | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** ****** | | **** ********** | | **** ************ | | ******** ***** | | ****** **** | | ***** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | ***** ***** | | ******* ***** | | **************** | | **** ********** | | **** ****** | | | | | | | | | | | | | | | | | +-------------------------+ */ 0x0000,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0f0f,0xc000, 0x0f3f,0xf000, 0x0f7f,0xf800, 0x0ff0,0xf800, 0x0fc0,0x3c00, 0x0f80,0x3c00, 0x0f00,0x1e00, 0x0f00,0x1e00, 0x0f00,0x1e00, 0x0f00,0x1e00, 0x0f00,0x1e00, 0x0f00,0x1e00, 0x0f00,0x1e00, 0x0f00,0x1e00, 0x0f00,0x3c00, 0x0f00,0x3c00, 0x0f80,0x7c00, 0x0fe0,0xf800, 0x0fff,0xf000, 0x0f7f,0xe000, 0x0f1f,0x8000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, /* Character 99 (0x63): width 20 +--------------------+ | | | | | | | | | | | | | | | | | | | | | ******* | | ************ | | ************* | | ****** ** | | ***** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | ****** ** | | ************* | | ************ | | ******* | | | | | | | | | | | | | | | | | +--------------------+ */ 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x007f,0x0000, 0x03ff,0xc000, 0x07ff,0xc000, 0x0fc0,0xc000, 0x1f00,0x0000, 0x1e00,0x0000, 0x1e00,0x0000, 0x3c00,0x0000, 0x3c00,0x0000, 0x3c00,0x0000, 0x3c00,0x0000, 0x3c00,0x0000, 0x3c00,0x0000, 0x3c00,0x0000, 0x1e00,0x0000, 0x1e00,0x0000, 0x0f00,0x0000, 0x0fc0,0xc000, 0x07ff,0xc000, 0x03ff,0xc000, 0x007f,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, /* Character 100 (0x64): width 25 +-------------------------+ | | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | ****** **** | | ********** **** | | **************** | | ***** ******* | | ***** ***** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** ***** | | **** ****** | | ***** ******** | | ************ **** | | ********** **** | | ****** **** | | | | | | | | | | | | | | | | | +-------------------------+ */ 0x0000,0x0000, 0x0000,0x7800, 0x0000,0x7800, 0x0000,0x7800, 0x0000,0x7800, 0x0000,0x7800, 0x0000,0x7800, 0x0000,0x7800, 0x0000,0x7800, 0x0000,0x7800, 0x00fc,0x7800, 0x03ff,0x7800, 0x07ff,0xf800, 0x0f83,0xf800, 0x1f00,0xf800, 0x1e00,0x7800, 0x1e00,0x7800, 0x3c00,0x7800, 0x3c00,0x7800, 0x3c00,0x7800, 0x3c00,0x7800, 0x3c00,0x7800, 0x3c00,0x7800, 0x3c00,0x7800, 0x3c00,0x7800, 0x1e00,0xf800, 0x1e01,0xf800, 0x0f87,0xf800, 0x0fff,0x7800, 0x07fe,0x7800, 0x01f8,0x7800, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, /* Character 101 (0x65): width 22 +----------------------+ | | | | | | | | | | | | | | | | | | | | | ****** | | ********** | | ************ | | **** ***** | | **** **** | | **** *** | | *** **** | | **** **** | | ***************** | | ***************** | | ***************** | | **** | | **** | | ***** | | **** | | ***** | | **** | | ****** ** | | ************** | | ************ | | ******** | | | | | | | | | | | | | | | | | +----------------------+ */ 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x00fc,0x0000, 0x03ff,0x0000, 0x07ff,0x8000, 0x0f07,0xc000, 0x1e03,0xc000, 0x1e01,0xc000, 0x1c01,0xe000, 0x3c01,0xe000, 0x3fff,0xe000, 0x3fff,0xe000, 0x3fff,0xe000, 0x3c00,0x0000, 0x3c00,0x0000, 0x3e00,0x0000, 0x1e00,0x0000, 0x1f00,0x0000, 0x0f00,0x0000, 0x0fc0,0x6000, 0x07ff,0xe000, 0x01ff,0xe000, 0x007f,0x8000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, /* Character 102 (0x66): width 14 +--------------+ | | | ******| | ********| | *********| | ***** | | **** | | **** | | **** | | **** | | **** | | ************ | | ************ | | ************ | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | | | | | | | | | | | | | | | | +--------------+ */ 0x0000, 0x00fc, 0x03fe, 0x07fe, 0x0f82, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x7ff8, 0x7ff8, 0x7ff8, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 103 (0x67): width 24 +------------------------+ | | | | | | | | | | | | | | | | | | | | | ****** **** | | ********* **** | | **************** | | ***** ******* | | ***** ***** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** ***** | | **** ****** | | ***** ******** | | ************ **** | | ********** **** | | ****** **** | | **** | | *** | | **** | | ***** | | ** ***** | | ************** | | ************* | | ********* | +------------------------+ */ 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x00fc,0x7800, 0x03fe,0x7800, 0x07ff,0xf800, 0x0f83,0xf800, 0x1f00,0xf800, 0x1e00,0x7800, 0x1e00,0x7800, 0x3c00,0x7800, 0x3c00,0x7800, 0x3c00,0x7800, 0x3c00,0x7800, 0x3c00,0x7800, 0x3c00,0x7800, 0x3c00,0x7800, 0x3c00,0x7800, 0x1e00,0xf800, 0x1e01,0xf800, 0x0f87,0xf800, 0x0fff,0x7800, 0x07fe,0x7800, 0x01f8,0x7800, 0x0000,0x7800, 0x0000,0x7000, 0x0000,0xf000, 0x0001,0xf000, 0x0c03,0xe000, 0x0fff,0xc000, 0x0fff,0x8000, 0x03fe,0x0000, /* Character 104 (0x68): width 24 +------------------------+ | | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** ***** | | **** ******** | | **** *********** | | **** *** ***** | | ******* **** | | ****** **** | | ***** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | | | | | | | | | | | | | | | | +------------------------+ */ 0x0000,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0f07,0xc000, 0x0f1f,0xe000, 0x0f7f,0xf000, 0x0f70,0xf800, 0x0fe0,0x7800, 0x0fc0,0x7800, 0x0f80,0x7800, 0x0f00,0x7800, 0x0f00,0x7800, 0x0f00,0x7800, 0x0f00,0x7800, 0x0f00,0x7800, 0x0f00,0x7800, 0x0f00,0x7800, 0x0f00,0x7800, 0x0f00,0x7800, 0x0f00,0x7800, 0x0f00,0x7800, 0x0f00,0x7800, 0x0f00,0x7800, 0x0f00,0x7800, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, /* Character 105 (0x69): width 11 +-----------+ | | | | | | | **** | | **** | | **** | | **** | | | | | | | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | | | | | | | | | | | | | | | | +-----------+ */ 0x0000, 0x0000, 0x0000, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0000, 0x0000, 0x0000, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 106 (0x6a): width 15 +---------------+ | | | | | | | **** | | **** | | **** | | **** | | | | | | | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | |* **** | |********** | |********* | | ****** | +---------------+ */ 0x0000, 0x0000, 0x0000, 0x01e0, 0x01e0, 0x01e0, 0x01e0, 0x0000, 0x0000, 0x0000, 0x01e0, 0x01e0, 0x01e0, 0x01e0, 0x01e0, 0x01e0, 0x01e0, 0x01e0, 0x01e0, 0x01e0, 0x01e0, 0x01e0, 0x01e0, 0x01e0, 0x01e0, 0x01e0, 0x01e0, 0x01e0, 0x01e0, 0x01e0, 0x01e0, 0x01e0, 0x01e0, 0x01e0, 0x01e0, 0x83c0, 0xffc0, 0xff80, 0x7e00, /* Character 107 (0x6b): width 23 +-----------------------+ | | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** *** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | ********* | | **** ***** | | **** ***** | | **** ***** | | **** ***** | | **** ****** | | **** ***** | | **** ***** | | **** ***** | | **** ***** | | **** ***** | | | | | | | | | | | | | | | | | +-----------------------+ */ 0x0000,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0f00,0xe000, 0x0f01,0xe000, 0x0f03,0xc000, 0x0f07,0x8000, 0x0f0f,0x0000, 0x0f0f,0x0000, 0x0f1e,0x0000, 0x0f3c,0x0000, 0x0f78,0x0000, 0x0f78,0x0000, 0x0ff8,0x0000, 0x0f7c,0x0000, 0x0f3e,0x0000, 0x0f1f,0x0000, 0x0f0f,0x8000, 0x0f0f,0xc000, 0x0f07,0xc000, 0x0f03,0xe000, 0x0f01,0xf000, 0x0f00,0xf800, 0x0f00,0x7c00, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, /* Character 108 (0x6c): width 11 +-----------+ | | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | | | | | | | | | | | | | | | | +-----------+ */ 0x0000, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 109 (0x6d): width 36 +------------------------------------+ | | | | | | | | | | | | | | | | | | | | | **** ****** ****** | | **** ******** ******** | | **** *********** *********** | | **** *** ***** *** ***** | | ******* ******* **** | | ***** ***** **** | | ***** ***** **** | | **** **** **** | | **** **** **** | | **** **** **** | | **** **** **** | | **** **** **** | | **** **** **** | | **** **** **** | | **** **** **** | | **** **** **** | | **** **** **** | | **** **** **** | | **** **** **** | | **** **** **** | | **** **** **** | | | | | | | | | | | | | | | | | +------------------------------------+ */ 0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000, 0x0f0f,0xc07e,0x0000, 0x0f1f,0xe0ff,0x0000, 0x0f7f,0xf3ff,0x8000, 0x0f70,0xfb87,0xc000, 0x0fe0,0x7f03,0xc000, 0x0f80,0x7c03,0xc000, 0x0f80,0x7c03,0xc000, 0x0f00,0x7803,0xc000, 0x0f00,0x7803,0xc000, 0x0f00,0x7803,0xc000, 0x0f00,0x7803,0xc000, 0x0f00,0x7803,0xc000, 0x0f00,0x7803,0xc000, 0x0f00,0x7803,0xc000, 0x0f00,0x7803,0xc000, 0x0f00,0x7803,0xc000, 0x0f00,0x7803,0xc000, 0x0f00,0x7803,0xc000, 0x0f00,0x7803,0xc000, 0x0f00,0x7803,0xc000, 0x0f00,0x7803,0xc000, 0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000, /* Character 110 (0x6e): width 24 +------------------------+ | | | | | | | | | | | | | | | | | | | | | **** ***** | | **** ******** | | **** *********** | | **** *** ***** | | ******* **** | | ****** **** | | ***** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | | | | | | | | | | | | | | | | +------------------------+ */ 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0f07,0xc000, 0x0f1f,0xe000, 0x0f7f,0xf000, 0x0f70,0xf800, 0x0fe0,0x7800, 0x0fc0,0x7800, 0x0f80,0x7800, 0x0f00,0x7800, 0x0f00,0x7800, 0x0f00,0x7800, 0x0f00,0x7800, 0x0f00,0x7800, 0x0f00,0x7800, 0x0f00,0x7800, 0x0f00,0x7800, 0x0f00,0x7800, 0x0f00,0x7800, 0x0f00,0x7800, 0x0f00,0x7800, 0x0f00,0x7800, 0x0f00,0x7800, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, /* Character 111 (0x6f): width 24 +------------------------+ | | | | | | | | | | | | | | | | | | | | | ****** | | ************ | | ************** | | ***** ***** | | ***** ***** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | ***** ***** | | ***** ***** | | ************** | | ************ | | ****** | | | | | | | | | | | | | | | | | +------------------------+ */ 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x007e,0x0000, 0x03ff,0xc000, 0x07ff,0xe000, 0x0f81,0xf000, 0x1f00,0xf800, 0x1e00,0x7800, 0x1e00,0x7800, 0x3c00,0x3c00, 0x3c00,0x3c00, 0x3c00,0x3c00, 0x3c00,0x3c00, 0x3c00,0x3c00, 0x3c00,0x3c00, 0x3c00,0x3c00, 0x1e00,0x7800, 0x1e00,0x7800, 0x1f00,0xf800, 0x0f81,0xf000, 0x07ff,0xe000, 0x03ff,0xc000, 0x007e,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, /* Character 112 (0x70): width 25 +-------------------------+ | | | | | | | | | | | | | | | | | | | | | **** ****** | | **** ********** | | **** ************ | | ******** ***** | | ****** **** | | ***** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | ***** ***** | | ******* ***** | | **************** | | **** ********** | | **** ****** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | +-------------------------+ */ 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0f0f,0xc000, 0x0f3f,0xf000, 0x0f7f,0xf800, 0x0ff0,0xf800, 0x0fc0,0x3c00, 0x0f80,0x3c00, 0x0f00,0x1e00, 0x0f00,0x1e00, 0x0f00,0x1e00, 0x0f00,0x1e00, 0x0f00,0x1e00, 0x0f00,0x1e00, 0x0f00,0x1e00, 0x0f00,0x1e00, 0x0f00,0x3c00, 0x0f00,0x3c00, 0x0f80,0x7c00, 0x0fe0,0xf800, 0x0fff,0xf000, 0x0f7f,0xe000, 0x0f1f,0x8000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, 0x0f00,0x0000, /* Character 113 (0x71): width 25 +-------------------------+ | | | | | | | | | | | | | | | | | | | | | ****** **** | | ********** **** | | **************** | | ***** ******* | | ***** ***** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** ***** | | **** ****** | | ***** ******** | | ************ **** | | ********** **** | | ****** **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | +-------------------------+ */ 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x00fc,0x7800, 0x03ff,0x7800, 0x07ff,0xf800, 0x0f83,0xf800, 0x1f00,0xf800, 0x1e00,0x7800, 0x1e00,0x7800, 0x3c00,0x7800, 0x3c00,0x7800, 0x3c00,0x7800, 0x3c00,0x7800, 0x3c00,0x7800, 0x3c00,0x7800, 0x3c00,0x7800, 0x3c00,0x7800, 0x1e00,0xf800, 0x1e01,0xf800, 0x0f87,0xf800, 0x0fff,0x7800, 0x07fe,0x7800, 0x01f8,0x7800, 0x0000,0x7800, 0x0000,0x7800, 0x0000,0x7800, 0x0000,0x7800, 0x0000,0x7800, 0x0000,0x7800, 0x0000,0x7800, 0x0000,0x7800, /* Character 114 (0x72): width 16 +----------------+ | | | | | | | | | | | | | | | | | | | | | **** *** | | **** ***** | | **** ****** | | ******* | | ****** | | ***** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | | | | | | | | | | | | | | | | +----------------+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0f0e, 0x0f3e, 0x0f7e, 0x0fe0, 0x0fc0, 0x0f80, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 115 (0x73): width 20 +--------------------+ | | | | | | | | | | | | | | | | | | | | | ****** | | ********** | | *********** | | ***** ** | | **** | | **** | | **** | | ****** | | ******* | | ******** | | ********* | | ******** | | ***** | | ***** | | **** | | **** | | **** | | ** ***** | | ************* | | ************ | | ******** | | | | | | | | | | | | | | | | | +--------------------+ */ 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x01f8,0x0000, 0x07fe,0x0000, 0x0ffe,0x0000, 0x1f06,0x0000, 0x1e00,0x0000, 0x1e00,0x0000, 0x1e00,0x0000, 0x1f80,0x0000, 0x0fe0,0x0000, 0x07f8,0x0000, 0x03fe,0x0000, 0x00ff,0x0000, 0x001f,0x0000, 0x000f,0x8000, 0x0007,0x8000, 0x0007,0x8000, 0x0007,0x8000, 0x181f,0x0000, 0x1fff,0x0000, 0x1ffe,0x0000, 0x07f8,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, /* Character 116 (0x74): width 15 +---------------+ | | | | | | | | | | | | | **** | | **** | | **** | | **** | | ************ | | ************ | | ************ | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | **** | | ***** | | ******** | | ******* | | ****** | | | | | | | | | | | | | | | | | +---------------+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x7ff8, 0x7ff8, 0x7ff8, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f00, 0x0f80, 0x07f8, 0x03f8, 0x01f8, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 117 (0x75): width 24 +------------------------+ | | | | | | | | | | | | | | | | | | | | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** **** | | **** ***** | | **** ****** | | **** ******* | | ***** *** **** | | *********** **** | | ******** **** | | ****** **** | | | | | | | | | | | | | | | | | +------------------------+ */ 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0f00,0x7800, 0x0f00,0x7800, 0x0f00,0x7800, 0x0f00,0x7800, 0x0f00,0x7800, 0x0f00,0x7800, 0x0f00,0x7800, 0x0f00,0x7800, 0x0f00,0x7800, 0x0f00,0x7800, 0x0f00,0x7800, 0x0f00,0x7800, 0x0f00,0x7800, 0x0f00,0x7800, 0x0f00,0xf800, 0x0f01,0xf800, 0x0f03,0xf800, 0x0f87,0x7800, 0x07ff,0x7800, 0x03fc,0x7800, 0x01f8,0x7800, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, /* Character 118 (0x76): width 20 +--------------------+ | | | | | | | | | | | | | | | | | | | | |**** ***| | **** *** | | **** *** | | ***** **** | | **** *** | | **** *** | | ***** *** | | **** *** | | **** **** | | **** *** | | **** *** | | ***** *** | | **** *** | | **** **** | | ***** *** | | **** *** | | ******* | | ****** | | ****** | | ***** | | **** | | | | | | | | | | | | | | | | | +--------------------+ */ 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0xf000,0x7000, 0x7800,0xe000, 0x7800,0xe000, 0x7c01,0xe000, 0x3c01,0xc000, 0x3c01,0xc000, 0x3e03,0x8000, 0x1e03,0x8000, 0x1e07,0x8000, 0x0f07,0x0000, 0x0f07,0x0000, 0x0f8e,0x0000, 0x078e,0x0000, 0x079e,0x0000, 0x07dc,0x0000, 0x03dc,0x0000, 0x03f8,0x0000, 0x01f8,0x0000, 0x01f8,0x0000, 0x01f0,0x0000, 0x00f0,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, /* Character 119 (0x77): width 30 +------------------------------+ | | | | | | | | | | | | | | | | | | | | |**** **** ***| |***** ***** ****| | **** ****** *** | | **** ****** *** | | **** ******* **** | | **** ******* *** | | **** ******** *** | | **** **** **** **** | | ***** *** **** *** | | **** *** **** *** | | **** **** ***** **** | | **** *** **** *** | | **** *** **** *** | | **** **** **** **** | | **** *** **** *** | | ******** ******* | | ******* ******* | | ****** ****** | | ****** ****** | | ***** ***** | | **** **** | | | | | | | | | | | | | | | | | +------------------------------+ */ 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0xf003,0xc01c, 0xf807,0xc03c, 0x7807,0xe038, 0x7807,0xe038, 0x780f,0xe078, 0x3c0f,0xe070, 0x3c0f,0xf070, 0x3c1e,0xf0f0, 0x3e1c,0xf0e0, 0x1e1c,0xf0e0, 0x1e3c,0xf9e0, 0x1e38,0x79c0, 0x0f38,0x79c0, 0x0f78,0x7bc0, 0x0f70,0x7b80, 0x0ff0,0x3f80, 0x07f0,0x3f80, 0x07e0,0x3f00, 0x07e0,0x3f00, 0x03e0,0x1f00, 0x03c0,0x1e00, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, /* Character 120 (0x78): width 24 +------------------------+ | | | | | | | | | | | | | | | | | | | | | ***** **** | | ***** **** | | ***** *** | | **** **** | | ***** **** | | ***** **** | | ***** **** | | ***** *** | | ******** | | ****** | | ***** | | ******* | | ******** | | **** ***** | | **** ***** | | **** ***** | | **** ***** | | **** **** | | **** ***** | | **** ***** | | **** ***** | | | | | | | | | | | | | | | | | +------------------------+ */ 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x3e00,0x7800, 0x1f00,0xf000, 0x0f80,0xe000, 0x0781,0xe000, 0x07c3,0xc000, 0x03e3,0xc000, 0x01f7,0x8000, 0x01f7,0x0000, 0x00ff,0x0000, 0x007e,0x0000, 0x007c,0x0000, 0x00fe,0x0000, 0x00ff,0x0000, 0x01ef,0x8000, 0x03cf,0x8000, 0x03c7,0xc000, 0x0783,0xe000, 0x0f01,0xe000, 0x0f01,0xf000, 0x1e00,0xf800, 0x3c00,0x7c00, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, /* Character 121 (0x79): width 20 +--------------------+ | | | | | | | | | | | | | | | | | | | | |**** ***| | **** *** | | **** *** | | ***** **** | | **** *** | | **** *** | | ***** *** | | **** *** | | ***** **** | | **** *** | | **** *** | | ***** *** | | **** *** | | **** **** | | **** *** | | **** *** | | ******** | | ****** | | ****** | | ***** | | **** | | **** | | *** | | **** | | *** | | *** | | **** | | *** | | **** | +--------------------+ */ 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0xf000,0x7000, 0x7800,0xe000, 0x7800,0xe000, 0x7c01,0xe000, 0x3c01,0xc000, 0x3c01,0xc000, 0x3e03,0x8000, 0x1e03,0x8000, 0x1f07,0x8000, 0x0f07,0x0000, 0x0f07,0x0000, 0x0f8e,0x0000, 0x078e,0x0000, 0x079e,0x0000, 0x03dc,0x0000, 0x03dc,0x0000, 0x03fc,0x0000, 0x01f8,0x0000, 0x01f8,0x0000, 0x01f0,0x0000, 0x00f0,0x0000, 0x00f0,0x0000, 0x00e0,0x0000, 0x01e0,0x0000, 0x01c0,0x0000, 0x01c0,0x0000, 0x03c0,0x0000, 0x0380,0x0000, 0x0780,0x0000, /* Character 122 (0x7a): width 22 +----------------------+ | | | | | | | | | | | | | | | | | | | | | ***************** | | ***************** | | ***************** | | ****** | | ****** | | ***** | | ***** | | ***** | | ***** | | ****** | | ****** | | ****** | | ***** | | ***** | | ***** | | ***** | | ****** | | ****** | | ****************** | | ****************** | | ****************** | | | | | | | | | | | | | | | | | +----------------------+ */ 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x1fff,0xf000, 0x1fff,0xf000, 0x1fff,0xf000, 0x0003,0xf000, 0x0007,0xe000, 0x0007,0xc000, 0x000f,0x8000, 0x001f,0x0000, 0x003e,0x0000, 0x007e,0x0000, 0x00fc,0x0000, 0x01f8,0x0000, 0x01f0,0x0000, 0x03e0,0x0000, 0x07c0,0x0000, 0x0f80,0x0000, 0x1f80,0x0000, 0x3f00,0x0000, 0x3fff,0xf000, 0x3fff,0xf000, 0x3fff,0xf000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, /* Character 123 (0x7b): width 13 +-------------+ | | | *** | | ***** | | ****** | | **** | | *** | | *** | | *** | | *** | | **** | | *** | | *** | | *** | | *** | | *** | | ** | | *** | |***** | |**** | |***** | | *** | | ** | | *** | | *** | | *** | | *** | | *** | | **** | | **** | | *** | | *** | | *** | | *** | | *** | | ****** | | ***** | | *** | | | | | +-------------+ */ 0x0000, 0x01c0, 0x07c0, 0x0fc0, 0x1e00, 0x1c00, 0x1c00, 0x1c00, 0x1c00, 0x1e00, 0x0e00, 0x0e00, 0x0e00, 0x0e00, 0x0e00, 0x0c00, 0x1c00, 0xf800, 0xf000, 0xf800, 0x1c00, 0x0c00, 0x0e00, 0x0e00, 0x0e00, 0x0e00, 0x0e00, 0x1e00, 0x1e00, 0x1c00, 0x1c00, 0x1c00, 0x1c00, 0x0e00, 0x0fc0, 0x07c0, 0x01c0, 0x0000, 0x0000, /* Character 124 (0x7c): width 15 +---------------+ | | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | ** | | | | | +---------------+ */ 0x0000, 0x0300, 0x0300, 0x0300, 0x0300, 0x0300, 0x0300, 0x0300, 0x0300, 0x0300, 0x0300, 0x0300, 0x0300, 0x0300, 0x0300, 0x0300, 0x0300, 0x0300, 0x0300, 0x0300, 0x0300, 0x0300, 0x0300, 0x0300, 0x0300, 0x0300, 0x0300, 0x0300, 0x0300, 0x0300, 0x0300, 0x0300, 0x0300, 0x0300, 0x0300, 0x0300, 0x0300, 0x0000, 0x0000, /* Character 125 (0x7d): width 13 +-------------+ | | | *** | | ***** | | ****** | | **** | | *** | | *** | | *** | | *** | | **** | | **** | | *** | | *** | | *** | | *** | | *** | | *** | | ***** | | **** | | ***** | | *** | | ** | | *** | | *** | | *** | | *** | | *** | | **** | | **** | | *** | | *** | | *** | | *** | | *** | | ****** | | ***** | | *** | | | | | +-------------+ */ 0x0000, 0x3800, 0x3e00, 0x3f00, 0x0780, 0x0380, 0x0380, 0x0380, 0x0380, 0x0780, 0x0780, 0x0700, 0x0700, 0x0700, 0x0700, 0x0700, 0x0380, 0x01f0, 0x00f0, 0x01f0, 0x0380, 0x0300, 0x0700, 0x0700, 0x0700, 0x0700, 0x0700, 0x0780, 0x0780, 0x0380, 0x0380, 0x0380, 0x0380, 0x0700, 0x3f00, 0x3e00, 0x3800, 0x0000, 0x0000, /* Character 126 (0x7e): width 25 +-------------------------+ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ***** | | ******** *** | | *********** *** | | **** ******* **** | | *** *********** | | *** ******** | | ***** | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | +-------------------------+ */ 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x07c0,0x0000, 0x0ff0,0x0e00, 0x1ffc,0x0e00, 0x3c7f,0x1e00, 0x381f,0xfc00, 0x3807,0xf800, 0x0001,0xf000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, /* Character 127 (0x7f): width 25 +-------------------------+ | | | | | | | | | | | | | * * | | *** *** | | *** ***** *** | | *** ********* *** | | *************** | | **** **** | | **** **** | | *** *** | | *** *** | | *** *** | | *** *** | | *** *** | | *** *** | | *** *** | | **** **** | | **** **** | | *************** | | *** ********* *** | | *** ***** *** | | *** *** | | * * | | | | | | | | | | | | | | | | | | | | | | | | | +-------------------------+ */ 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x1000,0x0400, 0x3800,0x0e00, 0x1c3e,0x1c00, 0x0eff,0xb800, 0x07ff,0xf000, 0x03c1,0xe000, 0x0780,0xf000, 0x0700,0x7000, 0x0e00,0x3800, 0x0e00,0x3800, 0x0e00,0x3800, 0x0e00,0x3800, 0x0e00,0x3800, 0x0700,0x7000, 0x0780,0xf000, 0x03c1,0xe000, 0x07ff,0xf000, 0x0eff,0xb800, 0x1c3e,0x1c00, 0x3800,0x0e00, 0x1000,0x0400, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, 0x0000,0x0000, }; /* Character->glyph mapping. */ static const unsigned short _lucidasans28_offset[] = { 0, /* (0x20) */ 39, /* (0x21) */ 78, /* (0x22) */ 117, /* (0x23) */ 195, /* (0x24) */ 273, /* (0x25) */ 351, /* (0x26) */ 429, /* (0x27) */ 468, /* (0x28) */ 507, /* (0x29) */ 546, /* (0x2a) */ 624, /* (0x2b) */ 702, /* (0x2c) */ 741, /* (0x2d) */ 819, /* (0x2e) */ 858, /* (0x2f) */ 936, /* (0x30) */ 1014, /* (0x31) */ 1092, /* (0x32) */ 1170, /* (0x33) */ 1248, /* (0x34) */ 1326, /* (0x35) */ 1404, /* (0x36) */ 1482, /* (0x37) */ 1560, /* (0x38) */ 1638, /* (0x39) */ 1716, /* (0x3a) */ 1755, /* (0x3b) */ 1794, /* (0x3c) */ 1872, /* (0x3d) */ 1950, /* (0x3e) */ 2028, /* (0x3f) */ 2067, /* (0x40) */ 2184, /* (0x41) */ 2262, /* (0x42) */ 2340, /* (0x43) */ 2418, /* (0x44) */ 2496, /* (0x45) */ 2574, /* (0x46) */ 2652, /* (0x47) */ 2730, /* (0x48) */ 2808, /* (0x49) */ 2847, /* (0x4a) */ 2886, /* (0x4b) */ 2964, /* (0x4c) */ 3042, /* (0x4d) */ 3159, /* (0x4e) */ 3237, /* (0x4f) */ 3315, /* (0x50) */ 3393, /* (0x51) */ 3471, /* (0x52) */ 3549, /* (0x53) */ 3627, /* (0x54) */ 3705, /* (0x55) */ 3783, /* (0x56) */ 3861, /* (0x57) */ 3978, /* (0x58) */ 4056, /* (0x59) */ 4134, /* (0x5a) */ 4212, /* (0x5b) */ 4251, /* (0x5c) */ 4329, /* (0x5d) */ 4368, /* (0x5e) */ 4446, /* (0x5f) */ 4524, /* (0x60) */ 4602, /* (0x61) */ 4680, /* (0x62) */ 4758, /* (0x63) */ 4836, /* (0x64) */ 4914, /* (0x65) */ 4992, /* (0x66) */ 5031, /* (0x67) */ 5109, /* (0x68) */ 5187, /* (0x69) */ 5226, /* (0x6a) */ 5265, /* (0x6b) */ 5343, /* (0x6c) */ 5382, /* (0x6d) */ 5499, /* (0x6e) */ 5577, /* (0x6f) */ 5655, /* (0x70) */ 5733, /* (0x71) */ 5811, /* (0x72) */ 5850, /* (0x73) */ 5928, /* (0x74) */ 5967, /* (0x75) */ 6045, /* (0x76) */ 6123, /* (0x77) */ 6201, /* (0x78) */ 6279, /* (0x79) */ 6357, /* (0x7a) */ 6435, /* (0x7b) */ 6474, /* (0x7c) */ 6513, /* (0x7d) */ 6552, /* (0x7e) */ 6630, /* (0x7f) */ 6630, /* (0x80) */ 6630, /* (0x81) */ 6630, /* (0x82) */ 6630, /* (0x83) */ 6630, /* (0x84) */ 6630, /* (0x85) */ 6630, /* (0x86) */ 6630, /* (0x87) */ 6630, /* (0x88) */ 6630, /* (0x89) */ 6630, /* (0x8a) */ 6630, /* (0x8b) */ 6630, /* (0x8c) */ 6630, /* (0x8d) */ 6630, /* (0x8e) */ 6630, /* (0x8f) */ 6630, /* (0x90) */ 6630, /* (0x91) */ 6630, /* (0x92) */ 6630, /* (0x93) */ 6630, /* (0x94) */ 6630, /* (0x95) */ 6630, /* (0x96) */ 6630, /* (0x97) */ 6630, /* (0x98) */ 6630, /* (0x99) */ 6630, /* (0x9a) */ 6630, /* (0x9b) */ 6630, /* (0x9c) */ 6630, /* (0x9d) */ 6630, /* (0x9e) */ 6630, /* (0x9f) */ 6630, /* (0xa0) */ 6630, /* (0xa1) */ 6630, /* (0xa2) */ 6630, /* (0xa3) */ 6630, /* (0xa4) */ }; /* Character width data. */ static const unsigned char _lucidasans28_width[] = { 12, /* (0x20) */ 12, /* (0x21) */ 15, /* (0x22) */ 25, /* (0x23) */ 25, /* (0x24) */ 26, /* (0x25) */ 27, /* (0x26) */ 9, /* (0x27) */ 13, /* (0x28) */ 13, /* (0x29) */ 19, /* (0x2a) */ 31, /* (0x2b) */ 12, /* (0x2c) */ 23, /* (0x2d) */ 12, /* (0x2e) */ 20, /* (0x2f) */ 25, /* (0x30) */ 25, /* (0x31) */ 25, /* (0x32) */ 25, /* (0x33) */ 25, /* (0x34) */ 25, /* (0x35) */ 25, /* (0x36) */ 25, /* (0x37) */ 25, /* (0x38) */ 25, /* (0x39) */ 12, /* (0x3a) */ 12, /* (0x3b) */ 31, /* (0x3c) */ 31, /* (0x3d) */ 31, /* (0x3e) */ 16, /* (0x3f) */ 33, /* (0x40) */ 27, /* (0x41) */ 22, /* (0x42) */ 27, /* (0x43) */ 29, /* (0x44) */ 21, /* (0x45) */ 21, /* (0x46) */ 28, /* (0x47) */ 29, /* (0x48) */ 11, /* (0x49) */ 15, /* (0x4a) */ 25, /* (0x4b) */ 21, /* (0x4c) */ 34, /* (0x4d) */ 29, /* (0x4e) */ 30, /* (0x4f) */ 22, /* (0x50) */ 30, /* (0x51) */ 25, /* (0x52) */ 21, /* (0x53) */ 25, /* (0x54) */ 27, /* (0x55) */ 26, /* (0x56) */ 33, /* (0x57) */ 24, /* (0x58) */ 24, /* (0x59) */ 24, /* (0x5a) */ 13, /* (0x5b) */ 20, /* (0x5c) */ 13, /* (0x5d) */ 25, /* (0x5e) */ 20, /* (0x5f) */ 24, /* (0x60) */ 22, /* (0x61) */ 25, /* (0x62) */ 20, /* (0x63) */ 25, /* (0x64) */ 22, /* (0x65) */ 14, /* (0x66) */ 24, /* (0x67) */ 24, /* (0x68) */ 11, /* (0x69) */ 15, /* (0x6a) */ 23, /* (0x6b) */ 11, /* (0x6c) */ 36, /* (0x6d) */ 24, /* (0x6e) */ 24, /* (0x6f) */ 25, /* (0x70) */ 25, /* (0x71) */ 16, /* (0x72) */ 20, /* (0x73) */ 15, /* (0x74) */ 24, /* (0x75) */ 20, /* (0x76) */ 30, /* (0x77) */ 24, /* (0x78) */ 20, /* (0x79) */ 22, /* (0x7a) */ 13, /* (0x7b) */ 15, /* (0x7c) */ 13, /* (0x7d) */ 25, /* (0x7e) */ 25, /* (0x7f) */ 25, /* (0x80) */ 25, /* (0x81) */ 25, /* (0x82) */ 25, /* (0x83) */ 25, /* (0x84) */ 25, /* (0x85) */ 25, /* (0x86) */ 25, /* (0x87) */ 25, /* (0x88) */ 25, /* (0x89) */ 25, /* (0x8a) */ 25, /* (0x8b) */ 25, /* (0x8c) */ 25, /* (0x8d) */ 25, /* (0x8e) */ 25, /* (0x8f) */ 25, /* (0x90) */ 25, /* (0x91) */ 25, /* (0x92) */ 25, /* (0x93) */ 25, /* (0x94) */ 25, /* (0x95) */ 25, /* (0x96) */ 25, /* (0x97) */ 25, /* (0x98) */ 25, /* (0x99) */ 25, /* (0x9a) */ 25, /* (0x9b) */ 25, /* (0x9c) */ 25, /* (0x9d) */ 25, /* (0x9e) */ 25, /* (0x9f) */ 25, /* (0xa0) */ 25, /* (0xa1) */ 25, /* (0xa2) */ 25, /* (0xa3) */ 25, /* (0xa4) */ }; /* Exported structure definition. */ const struct gpanel_font_t font_lucidasans28 = { "lucidasans28", 36, 39, 31, 32, 133, _lucidasans28_bits, _lucidasans28_offset, _lucidasans28_width, 164, sizeof(_lucidasans28_bits) / sizeof(_lucidasans28_bits[0]), }; ================================================ FILE: share/examples/gpanel/fonts/lucidasans7.c ================================================ /* Generated by convbdf on Thu Oct 8 21:26:35 2015. */ #include /* Font information: name: lucidasans7 facename: -FreeType-Lucida Sans Unicode-Medium-R-Normal--10-70-100-100-P-48-ISO10646-1 w x h: 9x9 size: 133 ascent: 8 descent: 1 first char: 32 (0x20) last char: 164 (0xa4) default char: 164 (0xa4) proportional: yes Copyright 1993 Bigelow & Holmes Inc. All rights reserved. Pat. Des. 289,420. Pats. Pend. */ /* Font character bitmap data. */ static const unsigned short _lucidasans7_bits[] = { /* Character 32 (0x20): width 3 +---+ | | | | | | | | | | | | | | | | | | +---+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 33 (0x21): width 3 +---+ | | | * | | * | | * | | * | | * | | | | * | | | +---+ */ 0x0000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x0000, 0x4000, 0x0000, /* Character 34 (0x22): width 4 +----+ | * *| | * *| | * *| | | | | | | | | | | | | +----+ */ 0x5000, 0x5000, 0x5000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 35 (0x23): width 6 +------+ | | | * * | | * * | |******| | * * | |******| | * * | | * * | | | +------+ */ 0x0000, 0x2800, 0x2800, 0xfc00, 0x5000, 0xfc00, 0x5000, 0x5000, 0x0000, /* Character 36 (0x24): width 6 +------+ | * | | **** | |* * | |* * | | *** | | * * | | * * | |**** | | * | +------+ */ 0x2000, 0x7800, 0xa000, 0xa000, 0x7000, 0x2800, 0x2800, 0xf000, 0x2000, /* Character 37 (0x25): width 7 +-------+ | | | * *| |* * * | |* * * | | * * * | | * * *| | * * *| |* * | | | +-------+ */ 0x0000, 0x4200, 0xa400, 0xa800, 0x5400, 0x2a00, 0x4a00, 0x8400, 0x0000, /* Character 38 (0x26): width 7 +-------+ | | | * | | * * | | * * | | ** * | |* * * | |* * | | *** * | | | +-------+ */ 0x0000, 0x2000, 0x5000, 0x5000, 0x6400, 0x9400, 0x8800, 0x7400, 0x0000, /* Character 39 (0x27): width 2 +--+ |* | |* | |* | | | | | | | | | | | | | +--+ */ 0x8000, 0x8000, 0x8000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 40 (0x28): width 3 +---+ | *| | *| | * | | * | | * | | * | | * | | *| | *| +---+ */ 0x2000, 0x2000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x2000, 0x2000, /* Character 41 (0x29): width 3 +---+ |* | |* | | * | | * | | * | | * | | * | |* | |* | +---+ */ 0x8000, 0x8000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x8000, 0x8000, /* Character 42 (0x2a): width 5 +-----+ | | | * * | | * | | * * | | | | | | | | | | | +-----+ */ 0x0000, 0x5000, 0x2000, 0x5000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 43 (0x2b): width 8 +--------+ | | | * | | * | | * | |******* | | * | | * | | * | | | +--------+ */ 0x0000, 0x1000, 0x1000, 0x1000, 0xfe00, 0x1000, 0x1000, 0x1000, 0x0000, /* Character 44 (0x2c): width 3 +---+ | | | | | | | | | | | | | | | * | |* | +---+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x4000, 0x8000, /* Character 45 (0x2d): width 6 +------+ | | | | | | | | | **** | | | | | | | | | +------+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x7800, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 46 (0x2e): width 3 +---+ | | | | | | | | | | | | | | | * | | | +---+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x4000, 0x0000, /* Character 47 (0x2f): width 5 +-----+ | | | * | | * | | * | | * | | * | | * | | * | | * | +-----+ */ 0x0000, 0x1000, 0x1000, 0x2000, 0x2000, 0x2000, 0x4000, 0x4000, 0x4000, /* Character 48 (0x30): width 6 +------+ | | | *** | |* * | |* * | |* * | |* * | |* * | | *** | | | +------+ */ 0x0000, 0x7000, 0x8800, 0x8800, 0x8800, 0x8800, 0x8800, 0x7000, 0x0000, /* Character 49 (0x31): width 6 +------+ | | | ** | | * | | * | | * | | * | | * | | * | | | +------+ */ 0x0000, 0x6000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x0000, /* Character 50 (0x32): width 6 +------+ | | | ** | | * * | | * | | * | | * | | * | | **** | | | +------+ */ 0x0000, 0x3000, 0x4800, 0x0800, 0x1000, 0x2000, 0x4000, 0x7800, 0x0000, /* Character 51 (0x33): width 6 +------+ | | | ** | | * * | | * | | ** | | * | | * * | | ** | | | +------+ */ 0x0000, 0x3000, 0x4800, 0x0800, 0x3000, 0x0800, 0x4800, 0x3000, 0x0000, /* Character 52 (0x34): width 6 +------+ | | | * | | ** | | * * | |* * | |***** | | * | | * | | | +------+ */ 0x0000, 0x1000, 0x3000, 0x5000, 0x9000, 0xf800, 0x1000, 0x1000, 0x0000, /* Character 53 (0x35): width 6 +------+ | | | **** | | * | | * | | *** | | * | | * | | *** | | | +------+ */ 0x0000, 0x7800, 0x4000, 0x4000, 0x7000, 0x0800, 0x0800, 0x7000, 0x0000, /* Character 54 (0x36): width 6 +------+ | | | **** | |* | |* | |**** | |* * | |* * | | *** | | | +------+ */ 0x0000, 0x7800, 0x8000, 0x8000, 0xf000, 0x8800, 0x8800, 0x7000, 0x0000, /* Character 55 (0x37): width 6 +------+ | | |***** | | * | | * | | * | | * | | * | | * | | | +------+ */ 0x0000, 0xf800, 0x0800, 0x1000, 0x2000, 0x2000, 0x4000, 0x4000, 0x0000, /* Character 56 (0x38): width 6 +------+ | | | *** | |* * | |* * | | *** | |* * | |* * | | *** | | | +------+ */ 0x0000, 0x7000, 0x8800, 0x8800, 0x7000, 0x8800, 0x8800, 0x7000, 0x0000, /* Character 57 (0x39): width 6 +------+ | | | *** | |* * | |* * | | **** | | * | | * | |**** | | | +------+ */ 0x0000, 0x7000, 0x8800, 0x8800, 0x7800, 0x0800, 0x0800, 0xf000, 0x0000, /* Character 58 (0x3a): width 3 +---+ | | | | | | | * | | | | | | | | * | | | +---+ */ 0x0000, 0x0000, 0x0000, 0x4000, 0x0000, 0x0000, 0x0000, 0x4000, 0x0000, /* Character 59 (0x3b): width 3 +---+ | | | | | | | * | | | | | | | | * | |* | +---+ */ 0x0000, 0x0000, 0x0000, 0x4000, 0x0000, 0x0000, 0x0000, 0x4000, 0x8000, /* Character 60 (0x3c): width 8 +--------+ | | | | | | | * | | *** | | ** | | **** | | * | | | +--------+ */ 0x0000, 0x0000, 0x0000, 0x0200, 0x1c00, 0x6000, 0x3c00, 0x0200, 0x0000, /* Character 61 (0x3d): width 8 +--------+ | | | | | | | ****** | | | | ****** | | | | | | | +--------+ */ 0x0000, 0x0000, 0x0000, 0x7e00, 0x0000, 0x7e00, 0x0000, 0x0000, 0x0000, /* Character 62 (0x3e): width 8 +--------+ | | | | | | | * | | *** | | ** | | **** | | * | | | +--------+ */ 0x0000, 0x0000, 0x0000, 0x4000, 0x3800, 0x0600, 0x3c00, 0x4000, 0x0000, /* Character 63 (0x3f): width 4 +----+ | | |*** | | *| | *| | * | | * | | | | * | | | +----+ */ 0x0000, 0xe000, 0x1000, 0x1000, 0x2000, 0x4000, 0x0000, 0x4000, 0x0000, /* Character 64 (0x40): width 9 +---------+ | | | **** | | ** * | |* ** * | |* * * * | |* ***** | |* | | **** | | | +---------+ */ 0x0000, 0x1e00, 0x6100, 0x9900, 0xa900, 0xbe00, 0x8000, 0x7800, 0x0000, /* Character 65 (0x41): width 7 +-------+ | | | * | | * * | | * * | | * * | | ***** | | * * | |* *| | | +-------+ */ 0x0000, 0x1000, 0x2800, 0x2800, 0x4400, 0x7c00, 0x4400, 0x8200, 0x0000, /* Character 66 (0x42): width 6 +------+ | | | *** | | * * | | * * | | *** | | * * | | * * | | *** | | | +------+ */ 0x0000, 0x7000, 0x4800, 0x4800, 0x7000, 0x4800, 0x4800, 0x7000, 0x0000, /* Character 67 (0x43): width 7 +-------+ | | | *** | | * * | |* | |* | |* | | * * | | *** | | | +-------+ */ 0x0000, 0x3800, 0x4400, 0x8000, 0x8000, 0x8000, 0x4400, 0x3800, 0x0000, /* Character 68 (0x44): width 7 +-------+ | | | *** | | * * | | * * | | * * | | * * | | * * | | *** | | | +-------+ */ 0x0000, 0x7000, 0x4800, 0x4400, 0x4400, 0x4400, 0x4800, 0x7000, 0x0000, /* Character 69 (0x45): width 5 +-----+ | | | ****| | * | | * | | *** | | * | | * | | ****| | | +-----+ */ 0x0000, 0x7800, 0x4000, 0x4000, 0x7000, 0x4000, 0x4000, 0x7800, 0x0000, /* Character 70 (0x46): width 5 +-----+ | | | ****| | * | | * | | *** | | * | | * | | * | | | +-----+ */ 0x0000, 0x7800, 0x4000, 0x4000, 0x7000, 0x4000, 0x4000, 0x4000, 0x0000, /* Character 71 (0x47): width 7 +-------+ | | | *** | | * | | * | | * | | * * | | * * | | *** | | | +-------+ */ 0x0000, 0x1c00, 0x2000, 0x4000, 0x4000, 0x4400, 0x2400, 0x1c00, 0x0000, /* Character 72 (0x48): width 7 +-------+ | | | * * | | * * | | * * | | ***** | | * * | | * * | | * * | | | +-------+ */ 0x0000, 0x4400, 0x4400, 0x4400, 0x7c00, 0x4400, 0x4400, 0x4400, 0x0000, /* Character 73 (0x49): width 3 +---+ | | | * | | * | | * | | * | | * | | * | | * | | | +---+ */ 0x0000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x0000, /* Character 74 (0x4a): width 4 +----+ | | | * | | * | | * | | * | | * | | * | | * | |** | +----+ */ 0x0000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0xc000, /* Character 75 (0x4b): width 7 +-------+ | | | * * | | * * | | * * | | ** | | * * | | * * | | * * | | | +-------+ */ 0x0000, 0x4400, 0x4800, 0x5000, 0x6000, 0x5000, 0x4800, 0x4400, 0x0000, /* Character 76 (0x4c): width 5 +-----+ | | | * | | * | | * | | * | | * | | * | | ****| | | +-----+ */ 0x0000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x7800, 0x0000, /* Character 77 (0x4d): width 9 +---------+ | | | * * | | ** ** | | ** ** | | * * * * | | * * * * | | * * * * | | * * * | | | +---------+ */ 0x0000, 0x4100, 0x6300, 0x6300, 0x5500, 0x5500, 0x5500, 0x4900, 0x0000, /* Character 78 (0x4e): width 7 +-------+ | | |* * | |** * | |* * * | |* ** * | |* * * | |* ** | |* * | | | +-------+ */ 0x0000, 0x8400, 0xc400, 0xa400, 0xb400, 0x9400, 0x8c00, 0x8400, 0x0000, /* Character 79 (0x4f): width 8 +--------+ | | | ** | | * * | | * * | | * * | | * * | | * * | | ** | | | +--------+ */ 0x0000, 0x1800, 0x2400, 0x4200, 0x4200, 0x4200, 0x2400, 0x1800, 0x0000, /* Character 80 (0x50): width 6 +------+ | | | *** | | * * | | * * | | *** | | * | | * | | * | | | +------+ */ 0x0000, 0x7000, 0x4800, 0x4800, 0x7000, 0x4000, 0x4000, 0x4000, 0x0000, /* Character 81 (0x51): width 8 +--------+ | | | ** | | * * | | * * | | * * | | * * | | * * | | *** | | **| +--------+ */ 0x0000, 0x1800, 0x2400, 0x4200, 0x4200, 0x4200, 0x2400, 0x1c00, 0x0300, /* Character 82 (0x52): width 6 +------+ | | | *** | | * * | | * * | | *** | | * * | | * * | | * *| | | +------+ */ 0x0000, 0x7000, 0x4800, 0x4800, 0x7000, 0x5000, 0x4800, 0x4400, 0x0000, /* Character 83 (0x53): width 5 +-----+ | | | *** | |* | |* | | ** | | * | | * | |*** | | | +-----+ */ 0x0000, 0x7000, 0x8000, 0x8000, 0x6000, 0x1000, 0x1000, 0xe000, 0x0000, /* Character 84 (0x54): width 6 +------+ | | |***** | | * | | * | | * | | * | | * | | * | | | +------+ */ 0x0000, 0xf800, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x0000, /* Character 85 (0x55): width 7 +-------+ | | | * * | | * * | | * * | | * * | | * * | | * * | | *** | | | +-------+ */ 0x0000, 0x4400, 0x4400, 0x4400, 0x4400, 0x4400, 0x4400, 0x3800, 0x0000, /* Character 86 (0x56): width 7 +-------+ | | |* *| | * * | | * * | | * * | | * * | | * * | | * | | | +-------+ */ 0x0000, 0x8200, 0x4400, 0x4400, 0x2800, 0x2800, 0x2800, 0x1000, 0x0000, /* Character 87 (0x57): width 9 +---------+ | | |* * *| |* * *| | * * * * | | * * * * | | * * * * | | * * | | * * | | | +---------+ */ 0x0000, 0x8880, 0x8880, 0x5500, 0x5500, 0x5500, 0x2200, 0x2200, 0x0000, /* Character 88 (0x58): width 6 +------+ | | |* *| | * * | | ** | | ** | | ** | | * * | |* *| | | +------+ */ 0x0000, 0x8400, 0x4800, 0x3000, 0x3000, 0x3000, 0x4800, 0x8400, 0x0000, /* Character 89 (0x59): width 6 +------+ | | | * *| | * * | | * * | | * | | * | | * | | * | | | +------+ */ 0x0000, 0x4400, 0x2800, 0x2800, 0x1000, 0x1000, 0x1000, 0x1000, 0x0000, /* Character 90 (0x5a): width 6 +------+ | | |***** | | * | | * | | * | | * | |* | |***** | | | +------+ */ 0x0000, 0xf800, 0x0800, 0x1000, 0x2000, 0x4000, 0x8000, 0xf800, 0x0000, /* Character 91 (0x5b): width 3 +---+ | **| | * | | * | | * | | * | | * | | * | | * | | **| +---+ */ 0x6000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x6000, /* Character 92 (0x5c): width 5 +-----+ | | | * | | * | | * | | * | | * | | * | | * | | * | +-----+ */ 0x0000, 0x4000, 0x4000, 0x4000, 0x2000, 0x2000, 0x2000, 0x1000, 0x1000, /* Character 93 (0x5d): width 3 +---+ |** | | * | | * | | * | | * | | * | | * | | * | |** | +---+ */ 0xc000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0xc000, /* Character 94 (0x5e): width 6 +------+ | | | * | | * | | * * | | * * | | * *| | | | | | | +------+ */ 0x0000, 0x1000, 0x1000, 0x2800, 0x2800, 0x4400, 0x0000, 0x0000, 0x0000, /* Character 95 (0x5f): width 5 +-----+ | | | | | | | | | | | | | | | | |*****| +-----+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xf800, /* Character 96 (0x60): width 6 +------+ | * | | * | | | | | | | | | | | | | | | +------+ */ 0x2000, 0x1000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 97 (0x61): width 6 +------+ | | | | | | |*** | | * | | *** | |* * | | **** | | | +------+ */ 0x0000, 0x0000, 0x0000, 0xe000, 0x1000, 0x7000, 0x9000, 0x7800, 0x0000, /* Character 98 (0x62): width 6 +------+ |* | |* | |* | |**** | |* * | |* * | |* * | |**** | | | +------+ */ 0x8000, 0x8000, 0x8000, 0xf000, 0x8800, 0x8800, 0x8800, 0xf000, 0x0000, /* Character 99 (0x63): width 5 +-----+ | | | | | | | *** | |* | |* | |* | | *** | | | +-----+ */ 0x0000, 0x0000, 0x0000, 0x7000, 0x8000, 0x8000, 0x8000, 0x7000, 0x0000, /* Character 100 (0x64): width 6 +------+ | * | | * | | * | | **** | |* * | |* * | |* * | | **** | | | +------+ */ 0x0800, 0x0800, 0x0800, 0x7800, 0x8800, 0x8800, 0x8800, 0x7800, 0x0000, /* Character 101 (0x65): width 5 +-----+ | | | | | | | ** | |* * | |**** | |* | | *** | | | +-----+ */ 0x0000, 0x0000, 0x0000, 0x6000, 0x9000, 0xf000, 0x8000, 0x7000, 0x0000, /* Character 102 (0x66): width 4 +----+ | **| | * | | * | |*** | | * | | * | | * | | * | | | +----+ */ 0x3000, 0x4000, 0x4000, 0xe000, 0x4000, 0x4000, 0x4000, 0x4000, 0x0000, /* Character 103 (0x67): width 6 +------+ | | | | | | | **** | |* * | |* * | |* * | | **** | | * | +------+ */ 0x0000, 0x0000, 0x0000, 0x7800, 0x8800, 0x8800, 0x8800, 0x7800, 0x0800, /* Character 104 (0x68): width 6 +------+ |* | |* | |* | |* ** | |** * | |* * | |* * | |* * | | | +------+ */ 0x8000, 0x8000, 0x8000, 0xb000, 0xc800, 0x8800, 0x8800, 0x8800, 0x0000, /* Character 105 (0x69): width 3 +---+ | | | * | | | | * | | * | | * | | * | | * | | | +---+ */ 0x0000, 0x4000, 0x0000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x0000, /* Character 106 (0x6a): width 4 +----+ | | | * | | | | * | | * | | * | | * | | * | | * | +----+ */ 0x0000, 0x2000, 0x0000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, /* Character 107 (0x6b): width 6 +------+ | * | | * | | * | | * * | | * * | | ** | | * * | | * * | | | +------+ */ 0x4000, 0x4000, 0x4000, 0x4800, 0x5000, 0x6000, 0x5000, 0x4800, 0x0000, /* Character 108 (0x6c): width 3 +---+ | * | | * | | * | | * | | * | | * | | * | | * | | | +---+ */ 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x0000, /* Character 109 (0x6d): width 8 +--------+ | | | | | | |*** ** | |* * * | |* * * | |* * * | |* * * | | | +--------+ */ 0x0000, 0x0000, 0x0000, 0xec00, 0x9200, 0x9200, 0x9200, 0x9200, 0x0000, /* Character 110 (0x6e): width 6 +------+ | | | | | | |* ** | |** * | |* * | |* * | |* * | | | +------+ */ 0x0000, 0x0000, 0x0000, 0xb000, 0xc800, 0x8800, 0x8800, 0x8800, 0x0000, /* Character 111 (0x6f): width 6 +------+ | | | | | | | *** | |* * | |* * | |* * | | *** | | | +------+ */ 0x0000, 0x0000, 0x0000, 0x7000, 0x8800, 0x8800, 0x8800, 0x7000, 0x0000, /* Character 112 (0x70): width 6 +------+ | | | | | | |**** | |* * | |* * | |* * | |**** | |* | +------+ */ 0x0000, 0x0000, 0x0000, 0xf000, 0x8800, 0x8800, 0x8800, 0xf000, 0x8000, /* Character 113 (0x71): width 6 +------+ | | | | | | | **** | |* * | |* * | |* * | | **** | | * | +------+ */ 0x0000, 0x0000, 0x0000, 0x7800, 0x8800, 0x8800, 0x8800, 0x7800, 0x0800, /* Character 114 (0x72): width 5 +-----+ | | | | | | | * * | | ** | | * | | * | | * | | | +-----+ */ 0x0000, 0x0000, 0x0000, 0x5000, 0x6000, 0x4000, 0x4000, 0x4000, 0x0000, /* Character 115 (0x73): width 5 +-----+ | | | | | | |**** | |* | | ** | | * | |**** | | | +-----+ */ 0x0000, 0x0000, 0x0000, 0xf000, 0x8000, 0x6000, 0x1000, 0xf000, 0x0000, /* Character 116 (0x74): width 4 +----+ | | | | | * | |*** | | * | | * | | * | | ** | | | +----+ */ 0x0000, 0x0000, 0x4000, 0xe000, 0x4000, 0x4000, 0x4000, 0x6000, 0x0000, /* Character 117 (0x75): width 6 +------+ | | | | | | |* * | |* * | |* * | |* ** | | ** * | | | +------+ */ 0x0000, 0x0000, 0x0000, 0x8800, 0x8800, 0x8800, 0x9800, 0x6800, 0x0000, /* Character 118 (0x76): width 6 +------+ | | | | | | |* * | | * * | | * * | | * * | | * | | | +------+ */ 0x0000, 0x0000, 0x0000, 0x8800, 0x5000, 0x5000, 0x5000, 0x2000, 0x0000, /* Character 119 (0x77): width 8 +--------+ | | | | | | |* * * | |* * * * | |* * * * | | * * | | * * | | | +--------+ */ 0x0000, 0x0000, 0x0000, 0x9200, 0xaa00, 0xaa00, 0x4400, 0x4400, 0x0000, /* Character 120 (0x78): width 6 +------+ | | | | | | |* * | | * * | | * | | * * | |* * | | | +------+ */ 0x0000, 0x0000, 0x0000, 0x8800, 0x5000, 0x2000, 0x5000, 0x8800, 0x0000, /* Character 121 (0x79): width 6 +------+ | | | | | | |* * | | * * | | * * | | * * | | * | | * | +------+ */ 0x0000, 0x0000, 0x0000, 0x8800, 0x5000, 0x5000, 0x5000, 0x2000, 0x2000, /* Character 122 (0x7a): width 6 +------+ | | | | | | |***** | | * | | * | | * | |***** | | | +------+ */ 0x0000, 0x0000, 0x0000, 0xf800, 0x1000, 0x2000, 0x4000, 0xf800, 0x0000, /* Character 123 (0x7b): width 3 +---+ | **| | * | | * | | * | |* | | * | | * | | * | | **| +---+ */ 0x6000, 0x4000, 0x4000, 0x4000, 0x8000, 0x4000, 0x4000, 0x4000, 0x6000, /* Character 124 (0x7c): width 4 +----+ | * | | * | | * | | * | | * | | * | | * | | * | | * | +----+ */ 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, /* Character 125 (0x7d): width 3 +---+ |** | | * | | * | | * | | *| | * | | * | | * | |** | +---+ */ 0xc000, 0x4000, 0x4000, 0x4000, 0x2000, 0x4000, 0x4000, 0x4000, 0xc000, /* Character 126 (0x7e): width 6 +------+ | | | | | | | | |** * | |* *** | | | | | | | +------+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0xc800, 0xb800, 0x0000, 0x0000, 0x0000, /* Character 127 (0x7f): width 6 +------+ | | |* *| | **** | | * * | | * * | | **** | |* *| | | | | +------+ */ 0x0000, 0x8400, 0x7800, 0x4800, 0x4800, 0x7800, 0x8400, 0x0000, 0x0000, }; /* Character->glyph mapping. */ static const unsigned short _lucidasans7_offset[] = { 0, /* (0x20) */ 9, /* (0x21) */ 18, /* (0x22) */ 27, /* (0x23) */ 36, /* (0x24) */ 45, /* (0x25) */ 54, /* (0x26) */ 63, /* (0x27) */ 72, /* (0x28) */ 81, /* (0x29) */ 90, /* (0x2a) */ 99, /* (0x2b) */ 108, /* (0x2c) */ 117, /* (0x2d) */ 126, /* (0x2e) */ 135, /* (0x2f) */ 144, /* (0x30) */ 153, /* (0x31) */ 162, /* (0x32) */ 171, /* (0x33) */ 180, /* (0x34) */ 189, /* (0x35) */ 198, /* (0x36) */ 207, /* (0x37) */ 216, /* (0x38) */ 225, /* (0x39) */ 234, /* (0x3a) */ 243, /* (0x3b) */ 252, /* (0x3c) */ 261, /* (0x3d) */ 270, /* (0x3e) */ 279, /* (0x3f) */ 288, /* (0x40) */ 297, /* (0x41) */ 306, /* (0x42) */ 315, /* (0x43) */ 324, /* (0x44) */ 333, /* (0x45) */ 342, /* (0x46) */ 351, /* (0x47) */ 360, /* (0x48) */ 369, /* (0x49) */ 378, /* (0x4a) */ 387, /* (0x4b) */ 396, /* (0x4c) */ 405, /* (0x4d) */ 414, /* (0x4e) */ 423, /* (0x4f) */ 432, /* (0x50) */ 441, /* (0x51) */ 450, /* (0x52) */ 459, /* (0x53) */ 468, /* (0x54) */ 477, /* (0x55) */ 486, /* (0x56) */ 495, /* (0x57) */ 504, /* (0x58) */ 513, /* (0x59) */ 522, /* (0x5a) */ 531, /* (0x5b) */ 540, /* (0x5c) */ 549, /* (0x5d) */ 558, /* (0x5e) */ 567, /* (0x5f) */ 576, /* (0x60) */ 585, /* (0x61) */ 594, /* (0x62) */ 603, /* (0x63) */ 612, /* (0x64) */ 621, /* (0x65) */ 630, /* (0x66) */ 639, /* (0x67) */ 648, /* (0x68) */ 657, /* (0x69) */ 666, /* (0x6a) */ 675, /* (0x6b) */ 684, /* (0x6c) */ 693, /* (0x6d) */ 702, /* (0x6e) */ 711, /* (0x6f) */ 720, /* (0x70) */ 729, /* (0x71) */ 738, /* (0x72) */ 747, /* (0x73) */ 756, /* (0x74) */ 765, /* (0x75) */ 774, /* (0x76) */ 783, /* (0x77) */ 792, /* (0x78) */ 801, /* (0x79) */ 810, /* (0x7a) */ 819, /* (0x7b) */ 828, /* (0x7c) */ 837, /* (0x7d) */ 846, /* (0x7e) */ 855, /* (0x7f) */ 855, /* (0x80) */ 855, /* (0x81) */ 855, /* (0x82) */ 855, /* (0x83) */ 855, /* (0x84) */ 855, /* (0x85) */ 855, /* (0x86) */ 855, /* (0x87) */ 855, /* (0x88) */ 855, /* (0x89) */ 855, /* (0x8a) */ 855, /* (0x8b) */ 855, /* (0x8c) */ 855, /* (0x8d) */ 855, /* (0x8e) */ 855, /* (0x8f) */ 855, /* (0x90) */ 855, /* (0x91) */ 855, /* (0x92) */ 855, /* (0x93) */ 855, /* (0x94) */ 855, /* (0x95) */ 855, /* (0x96) */ 855, /* (0x97) */ 855, /* (0x98) */ 855, /* (0x99) */ 855, /* (0x9a) */ 855, /* (0x9b) */ 855, /* (0x9c) */ 855, /* (0x9d) */ 855, /* (0x9e) */ 855, /* (0x9f) */ 855, /* (0xa0) */ 855, /* (0xa1) */ 855, /* (0xa2) */ 855, /* (0xa3) */ 855, /* (0xa4) */ }; /* Character width data. */ static const unsigned char _lucidasans7_width[] = { 3, /* (0x20) */ 3, /* (0x21) */ 4, /* (0x22) */ 6, /* (0x23) */ 6, /* (0x24) */ 7, /* (0x25) */ 7, /* (0x26) */ 2, /* (0x27) */ 3, /* (0x28) */ 3, /* (0x29) */ 5, /* (0x2a) */ 8, /* (0x2b) */ 3, /* (0x2c) */ 6, /* (0x2d) */ 3, /* (0x2e) */ 5, /* (0x2f) */ 6, /* (0x30) */ 6, /* (0x31) */ 6, /* (0x32) */ 6, /* (0x33) */ 6, /* (0x34) */ 6, /* (0x35) */ 6, /* (0x36) */ 6, /* (0x37) */ 6, /* (0x38) */ 6, /* (0x39) */ 3, /* (0x3a) */ 3, /* (0x3b) */ 8, /* (0x3c) */ 8, /* (0x3d) */ 8, /* (0x3e) */ 4, /* (0x3f) */ 9, /* (0x40) */ 7, /* (0x41) */ 6, /* (0x42) */ 7, /* (0x43) */ 7, /* (0x44) */ 5, /* (0x45) */ 5, /* (0x46) */ 7, /* (0x47) */ 7, /* (0x48) */ 3, /* (0x49) */ 4, /* (0x4a) */ 7, /* (0x4b) */ 5, /* (0x4c) */ 9, /* (0x4d) */ 7, /* (0x4e) */ 8, /* (0x4f) */ 6, /* (0x50) */ 8, /* (0x51) */ 6, /* (0x52) */ 5, /* (0x53) */ 6, /* (0x54) */ 7, /* (0x55) */ 7, /* (0x56) */ 9, /* (0x57) */ 6, /* (0x58) */ 6, /* (0x59) */ 6, /* (0x5a) */ 3, /* (0x5b) */ 5, /* (0x5c) */ 3, /* (0x5d) */ 6, /* (0x5e) */ 5, /* (0x5f) */ 6, /* (0x60) */ 6, /* (0x61) */ 6, /* (0x62) */ 5, /* (0x63) */ 6, /* (0x64) */ 5, /* (0x65) */ 4, /* (0x66) */ 6, /* (0x67) */ 6, /* (0x68) */ 3, /* (0x69) */ 4, /* (0x6a) */ 6, /* (0x6b) */ 3, /* (0x6c) */ 8, /* (0x6d) */ 6, /* (0x6e) */ 6, /* (0x6f) */ 6, /* (0x70) */ 6, /* (0x71) */ 5, /* (0x72) */ 5, /* (0x73) */ 4, /* (0x74) */ 6, /* (0x75) */ 6, /* (0x76) */ 8, /* (0x77) */ 6, /* (0x78) */ 6, /* (0x79) */ 6, /* (0x7a) */ 3, /* (0x7b) */ 4, /* (0x7c) */ 3, /* (0x7d) */ 6, /* (0x7e) */ 6, /* (0x7f) */ 6, /* (0x80) */ 6, /* (0x81) */ 6, /* (0x82) */ 6, /* (0x83) */ 6, /* (0x84) */ 6, /* (0x85) */ 6, /* (0x86) */ 6, /* (0x87) */ 6, /* (0x88) */ 6, /* (0x89) */ 6, /* (0x8a) */ 6, /* (0x8b) */ 6, /* (0x8c) */ 6, /* (0x8d) */ 6, /* (0x8e) */ 6, /* (0x8f) */ 6, /* (0x90) */ 6, /* (0x91) */ 6, /* (0x92) */ 6, /* (0x93) */ 6, /* (0x94) */ 6, /* (0x95) */ 6, /* (0x96) */ 6, /* (0x97) */ 6, /* (0x98) */ 6, /* (0x99) */ 6, /* (0x9a) */ 6, /* (0x9b) */ 6, /* (0x9c) */ 6, /* (0x9d) */ 6, /* (0x9e) */ 6, /* (0x9f) */ 6, /* (0xa0) */ 6, /* (0xa1) */ 6, /* (0xa2) */ 6, /* (0xa3) */ 6, /* (0xa4) */ }; /* Exported structure definition. */ const struct gpanel_font_t font_lucidasans7 = { "lucidasans7", 9, 9, 8, 32, 133, _lucidasans7_bits, _lucidasans7_offset, _lucidasans7_width, 164, sizeof(_lucidasans7_bits) / sizeof(_lucidasans7_bits[0]), }; ================================================ FILE: share/examples/gpanel/fonts/lucidasans9.c ================================================ /* Generated by convbdf on Thu Oct 8 21:26:35 2015. */ #include /* Font information: name: lucidasans9 facename: -FreeType-Lucida Sans Unicode-Medium-R-Normal--12-90-100-100-P-60-ISO10646-1 w x h: 12x14 size: 133 ascent: 12 descent: 2 first char: 32 (0x20) last char: 164 (0xa4) default char: 164 (0xa4) proportional: yes Copyright 1993 Bigelow & Holmes Inc. All rights reserved. Pat. Des. 289,420. Pats. Pend. */ /* Font character bitmap data. */ static const unsigned short _lucidasans9_bits[] = { /* Character 32 (0x20): width 4 +----+ | | | | | | | | | | | | | | | | | | | | | | | | | | | | +----+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 33 (0x21): width 4 +----+ | | | | | | | * | | * | | * | | * | | * | | * | | * | | | | * | | | | | +----+ */ 0x0000, 0x0000, 0x0000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x0000, 0x4000, 0x0000, 0x0000, /* Character 34 (0x22): width 5 +-----+ | | | | | * * | | * * | | * * | | | | | | | | | | | | | | | | | | | +-----+ */ 0x0000, 0x0000, 0x5000, 0x5000, 0x5000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 35 (0x23): width 8 +--------+ | | | | | | | * * | | * * | | *******| | * * | | * * | |******* | | * * | | * * | | * * | | | | | +--------+ */ 0x0000, 0x0000, 0x0000, 0x1200, 0x2400, 0x7f00, 0x2400, 0x2400, 0xfe00, 0x4800, 0x4800, 0x4800, 0x0000, 0x0000, /* Character 36 (0x24): width 8 +--------+ | | | | | * | | **** | | * * | | * * | | ** | | ** | | * * | | * * | | * * * | | *** | | * | | | +--------+ */ 0x0000, 0x0000, 0x1000, 0x3c00, 0x5000, 0x5000, 0x3000, 0x1800, 0x1400, 0x1400, 0x5400, 0x3800, 0x1000, 0x0000, /* Character 37 (0x25): width 9 +---------+ | | | | | *| | ** * | |* * * | |* * * | |* ** | | ** * ** | | * * *| | * * *| | * * *| |* ** | | | | | +---------+ */ 0x0000, 0x0000, 0x0080, 0x6100, 0x9200, 0x9400, 0x9800, 0x6b00, 0x1480, 0x2480, 0x4480, 0x8300, 0x0000, 0x0000, /* Character 38 (0x26): width 9 +---------+ | | | | | | | ** | | * * | | * * | | ** | | ** * | | * * * | | * * * | | ** ** | | *** ** | | | | | +---------+ */ 0x0000, 0x0000, 0x0000, 0x1800, 0x2400, 0x2400, 0x1800, 0x3100, 0x4900, 0x4500, 0x6600, 0x3b00, 0x0000, 0x0000, /* Character 39 (0x27): width 3 +---+ | | | | | * | | * | | * | | | | | | | | | | | | | | | | | | | +---+ */ 0x0000, 0x0000, 0x4000, 0x4000, 0x4000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 40 (0x28): width 4 +----+ | | | | | *| | * | | * | | * | | * | | * | | * | | * | | * | | * | | * | | *| +----+ */ 0x0000, 0x0000, 0x1000, 0x2000, 0x2000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x2000, 0x2000, 0x1000, /* Character 41 (0x29): width 4 +----+ | | | | |* | | * | | * | | * | | * | | * | | * | | * | | * | | * | | * | |* | +----+ */ 0x0000, 0x0000, 0x8000, 0x4000, 0x4000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x4000, 0x4000, 0x8000, /* Character 42 (0x2a): width 6 +------+ | | | | | | | * | |* * * | | * * | | * * | | * * | | | | | | | | | | | | | +------+ */ 0x0000, 0x0000, 0x0000, 0x2000, 0xa800, 0x5000, 0x5000, 0x5000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 43 (0x2b): width 10 +----------+ | | | | | | | | | | | * | | * | | * | | ******* | | * | | * | | * | | | | | +----------+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0800, 0x0800, 0x0800, 0x7f00, 0x0800, 0x0800, 0x0800, 0x0000, 0x0000, /* Character 44 (0x2c): width 4 +----+ | | | | | | | | | | | | | | | | | | | | | ** | | ** | | * | | * | +----+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x6000, 0x6000, 0x2000, 0x4000, /* Character 45 (0x2d): width 8 +--------+ | | | | | | | | | | | | | | | | | ****** | | | | | | | | | | | +--------+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x7e00, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 46 (0x2e): width 4 +----+ | | | | | | | | | | | | | | | | | | | | | ** | | ** | | | | | +----+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x6000, 0x6000, 0x0000, 0x0000, /* Character 47 (0x2f): width 7 +-------+ | | | | | | | * | | * | | * | | * | | * | | * | | * | | * | | * | | * | | * | +-------+ */ 0x0000, 0x0000, 0x0000, 0x0800, 0x0800, 0x1000, 0x1000, 0x1000, 0x2000, 0x2000, 0x2000, 0x4000, 0x4000, 0x4000, /* Character 48 (0x30): width 8 +--------+ | | | | | | | *** | | * * | |* * | |* * | |* * | |* * | |* * | | * * | | *** | | | | | +--------+ */ 0x0000, 0x0000, 0x0000, 0x3800, 0x4400, 0x8200, 0x8200, 0x8200, 0x8200, 0x8200, 0x4400, 0x3800, 0x0000, 0x0000, /* Character 49 (0x31): width 8 +--------+ | | | | | | | *** | | * | | * | | * | | * | | * | | * | | * | | * | | | | | +--------+ */ 0x0000, 0x0000, 0x0000, 0x7000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x0000, 0x0000, /* Character 50 (0x32): width 8 +--------+ | | | | | | | **** | | * * | | * | | * | | * | | ** | | * | | * | | ****** | | | | | +--------+ */ 0x0000, 0x0000, 0x0000, 0x3c00, 0x4200, 0x0200, 0x0200, 0x0400, 0x1800, 0x2000, 0x4000, 0x7e00, 0x0000, 0x0000, /* Character 51 (0x33): width 8 +--------+ | | | | | | | *** | | * * | | * | | * | | *** | | * | | * | | * * | | *** | | | | | +--------+ */ 0x0000, 0x0000, 0x0000, 0x3800, 0x4400, 0x0400, 0x0800, 0x3800, 0x0400, 0x0400, 0x4400, 0x3800, 0x0000, 0x0000, /* Character 52 (0x34): width 8 +--------+ | | | | | | | * | | ** | | * * | | * * | | * * | | ****** | | * | | * | | * | | | | | +--------+ */ 0x0000, 0x0000, 0x0000, 0x0400, 0x0c00, 0x1400, 0x2400, 0x4400, 0x7e00, 0x0400, 0x0400, 0x0400, 0x0000, 0x0000, /* Character 53 (0x35): width 8 +--------+ | | | | | | | ***** | | * | | * | | *** | | * | | * | | * | | * | | **** | | | | | +--------+ */ 0x0000, 0x0000, 0x0000, 0x7c00, 0x4000, 0x4000, 0x7000, 0x0800, 0x0400, 0x0400, 0x0400, 0x7800, 0x0000, 0x0000, /* Character 54 (0x36): width 8 +--------+ | | | | | | | **** | | * | | * | | * ** | | ** * | | * * | | * * | | * * | | ** | | | | | +--------+ */ 0x0000, 0x0000, 0x0000, 0x1e00, 0x2000, 0x4000, 0x5800, 0x6400, 0x4200, 0x4200, 0x2400, 0x1800, 0x0000, 0x0000, /* Character 55 (0x37): width 8 +--------+ | | | | | | | ****** | | * | | * | | * | | * | | * | | * | | * | | * | | | | | +--------+ */ 0x0000, 0x0000, 0x0000, 0x7e00, 0x0200, 0x0400, 0x0800, 0x0800, 0x1000, 0x1000, 0x2000, 0x2000, 0x0000, 0x0000, /* Character 56 (0x38): width 8 +--------+ | | | | | | | **** | | * * | | * * | | * * | | **** | | * * | | * * | | * * | | **** | | | | | +--------+ */ 0x0000, 0x0000, 0x0000, 0x3c00, 0x4200, 0x4200, 0x2400, 0x3c00, 0x4200, 0x4200, 0x4200, 0x3c00, 0x0000, 0x0000, /* Character 57 (0x39): width 8 +--------+ | | | | | | | ** | | * * | | * * | | * * | | * ** | | ** * | | * | | * | | **** | | | | | +--------+ */ 0x0000, 0x0000, 0x0000, 0x1800, 0x2400, 0x4200, 0x4200, 0x2600, 0x1a00, 0x0200, 0x0400, 0x7800, 0x0000, 0x0000, /* Character 58 (0x3a): width 4 +----+ | | | | | | | | | | | * | | | | | | | | | | | | * | | | | | +----+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x4000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x4000, 0x0000, 0x0000, /* Character 59 (0x3b): width 4 +----+ | | | | | | | | | | | * | | | | | | | | | | | | * | | * | |* | +----+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x4000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x4000, 0x4000, 0x8000, /* Character 60 (0x3c): width 10 +----------+ | | | | | | | | | | | * | | *** | | ** | | ** | | *** | | *** | | * | | | | | +----------+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0080, 0x0700, 0x1800, 0x6000, 0x3800, 0x0700, 0x0080, 0x0000, 0x0000, /* Character 61 (0x3d): width 10 +----------+ | | | | | | | | | | | | | ******** | | | | | | ******** | | | | | | | | | +----------+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x7f80, 0x0000, 0x0000, 0x7f80, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 62 (0x3e): width 10 +----------+ | | | | | | | | | | | * | | *** | | ** | | ** | | *** | | *** | | * | | | | | +----------+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x4000, 0x3800, 0x0600, 0x0180, 0x0700, 0x3800, 0x4000, 0x0000, 0x0000, /* Character 63 (0x3f): width 5 +-----+ | | | | | | |**** | | *| | *| | * | | * | | * | | * | | | | * | | | | | +-----+ */ 0x0000, 0x0000, 0x0000, 0xf000, 0x0800, 0x0800, 0x1000, 0x2000, 0x4000, 0x4000, 0x0000, 0x4000, 0x0000, 0x0000, /* Character 64 (0x40): width 11 +-----------+ | | | | | | | **** | | ** * | | * *** * | |* * * * | |* * * * | |* * ** * | |* ** *** | | * | | **** | | | | | +-----------+ */ 0x0000, 0x0000, 0x0000, 0x0f00, 0x3080, 0x4e40, 0x9240, 0xa440, 0xac80, 0xb700, 0x4000, 0x3c00, 0x0000, 0x0000, /* Character 65 (0x41): width 9 +---------+ | | | | | | | * | | * * | | * * | | * * | | * * | | * * | | ******* | | * * | |* *| | | | | +---------+ */ 0x0000, 0x0000, 0x0000, 0x0800, 0x1400, 0x1400, 0x2200, 0x2200, 0x4100, 0x7f00, 0x4100, 0x8080, 0x0000, 0x0000, /* Character 66 (0x42): width 7 +-------+ | | | | | | | **** | | * * | | * * | | * * | | *** | | * * | | * * | | * * | | **** | | | | | +-------+ */ 0x0000, 0x0000, 0x0000, 0x7800, 0x4400, 0x4400, 0x4800, 0x7000, 0x4800, 0x4400, 0x4400, 0x7800, 0x0000, 0x0000, /* Character 67 (0x43): width 9 +---------+ | | | | | | | ***** | | * * | |* | |* | |* | |* | |* | | * * | | ***** | | | | | +---------+ */ 0x0000, 0x0000, 0x0000, 0x3e00, 0x4100, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x4100, 0x3e00, 0x0000, 0x0000, /* Character 68 (0x44): width 10 +----------+ | | | | | | | ****** | | * * | | * * | | * * | | * * | | * * | | * * | | * * | | ****** | | | | | +----------+ */ 0x0000, 0x0000, 0x0000, 0x7e00, 0x4100, 0x4080, 0x4080, 0x4080, 0x4080, 0x4080, 0x4100, 0x7e00, 0x0000, 0x0000, /* Character 69 (0x45): width 7 +-------+ | | | | | | | ******| | * | | * | | * | | ***** | | * | | * | | * | | ******| | | | | +-------+ */ 0x0000, 0x0000, 0x0000, 0x7e00, 0x4000, 0x4000, 0x4000, 0x7c00, 0x4000, 0x4000, 0x4000, 0x7e00, 0x0000, 0x0000, /* Character 70 (0x46): width 7 +-------+ | | | | | | | ***** | | * | | * | | * | | **** | | * | | * | | * | | * | | | | | +-------+ */ 0x0000, 0x0000, 0x0000, 0x7c00, 0x4000, 0x4000, 0x4000, 0x7800, 0x4000, 0x4000, 0x4000, 0x4000, 0x0000, 0x0000, /* Character 71 (0x47): width 9 +---------+ | | | | | | | ***** | | * | | * | | * | | * | | * * | | * * | | * * | | ***** | | | | | +---------+ */ 0x0000, 0x0000, 0x0000, 0x1f00, 0x2000, 0x4000, 0x4000, 0x4000, 0x4100, 0x4100, 0x2100, 0x1f00, 0x0000, 0x0000, /* Character 72 (0x48): width 10 +----------+ | | | | | | | * * | | * * | | * * | | * * | | ******* | | * * | | * * | | * * | | * * | | | | | +----------+ */ 0x0000, 0x0000, 0x0000, 0x4100, 0x4100, 0x4100, 0x4100, 0x7f00, 0x4100, 0x4100, 0x4100, 0x4100, 0x0000, 0x0000, /* Character 73 (0x49): width 4 +----+ | | | | | | | * | | * | | * | | * | | * | | * | | * | | * | | * | | | | | +----+ */ 0x0000, 0x0000, 0x0000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x0000, 0x0000, /* Character 74 (0x4a): width 5 +-----+ | | | | | | | * | | * | | * | | * | | * | | * | | * | | * | | * | | * | |*** | +-----+ */ 0x0000, 0x0000, 0x0000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0xe000, /* Character 75 (0x4b): width 8 +--------+ | | | | | | | * * | | * * | | * * | | * * | | ** | | * * | | * * | | * * | | * * | | | | | +--------+ */ 0x0000, 0x0000, 0x0000, 0x4200, 0x4400, 0x4800, 0x5000, 0x6000, 0x5000, 0x4800, 0x4400, 0x4200, 0x0000, 0x0000, /* Character 76 (0x4c): width 7 +-------+ | | | | | | | * | | * | | * | | * | | * | | * | | * | | * | | ******| | | | | +-------+ */ 0x0000, 0x0000, 0x0000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x7e00, 0x0000, 0x0000, /* Character 77 (0x4d): width 11 +-----------+ | | | | | | | ** ** | | ** ** | | * * * * | | * * * * | | * * * * | | * * * * | | * * * * | | * * * | | * * | | | | | +-----------+ */ 0x0000, 0x0000, 0x0000, 0x60c0, 0x60c0, 0x5140, 0x5140, 0x5140, 0x4a40, 0x4a40, 0x4440, 0x4040, 0x0000, 0x0000, /* Character 78 (0x4e): width 10 +----------+ | | | | | | | ** * | | ** * | | * * * | | * * * | | * * * | | * * * | | * * * | | * ** | | * ** | | | | | +----------+ */ 0x0000, 0x0000, 0x0000, 0x6100, 0x6100, 0x5100, 0x5100, 0x4900, 0x4500, 0x4500, 0x4300, 0x4300, 0x0000, 0x0000, /* Character 79 (0x4f): width 10 +----------+ | | | | | | | ***** | | * * | |* * | |* * | |* * | |* * | |* * | | * * | | ***** | | | | | +----------+ */ 0x0000, 0x0000, 0x0000, 0x3e00, 0x4100, 0x8080, 0x8080, 0x8080, 0x8080, 0x8080, 0x4100, 0x3e00, 0x0000, 0x0000, /* Character 80 (0x50): width 7 +-------+ | | | | | | | ***** | | * *| | * *| | * *| | ***** | | * | | * | | * | | * | | | | | +-------+ */ 0x0000, 0x0000, 0x0000, 0x7c00, 0x4200, 0x4200, 0x4200, 0x7c00, 0x4000, 0x4000, 0x4000, 0x4000, 0x0000, 0x0000, /* Character 81 (0x51): width 10 +----------+ | | | | | | | ***** | | * * | |* * | |* * | |* * | |* * | |* * | | * * | | ***** | | ** | | **| +----------+ */ 0x0000, 0x0000, 0x0000, 0x3e00, 0x4100, 0x8080, 0x8080, 0x8080, 0x8080, 0x8080, 0x4100, 0x3e00, 0x0300, 0x00c0, /* Character 82 (0x52): width 8 +--------+ | | | | | | | ***** | | * * | | * * | | * * | | **** | | * * | | * * | | * * | | * *| | | | | +--------+ */ 0x0000, 0x0000, 0x0000, 0x7c00, 0x4200, 0x4200, 0x4400, 0x7800, 0x4800, 0x4400, 0x4200, 0x4100, 0x0000, 0x0000, /* Character 83 (0x53): width 7 +-------+ | | | | | | | **** | |* | |* | | * | | ** | | * | | * | | * | |***** | | | | | +-------+ */ 0x0000, 0x0000, 0x0000, 0x7800, 0x8000, 0x8000, 0x4000, 0x3000, 0x0800, 0x0400, 0x0400, 0xf800, 0x0000, 0x0000, /* Character 84 (0x54): width 8 +--------+ | | | | | | |******* | | * | | * | | * | | * | | * | | * | | * | | * | | | | | +--------+ */ 0x0000, 0x0000, 0x0000, 0xfe00, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x0000, 0x0000, /* Character 85 (0x55): width 9 +---------+ | | | | | | | * * | | * * | | * * | | * * | | * * | | * * | | * * | | * * | | ***** | | | | | +---------+ */ 0x0000, 0x0000, 0x0000, 0x4100, 0x4100, 0x4100, 0x4100, 0x4100, 0x4100, 0x4100, 0x4100, 0x3e00, 0x0000, 0x0000, /* Character 86 (0x56): width 9 +---------+ | | | | | | |* * | | * * | | * * | | * * | | * * | | * * | | * * | | ** | | ** | | | | | +---------+ */ 0x0000, 0x0000, 0x0000, 0x8100, 0x4200, 0x4200, 0x4200, 0x2400, 0x2400, 0x2400, 0x1800, 0x1800, 0x0000, 0x0000, /* Character 87 (0x57): width 11 +-----------+ | | | | | | |* * *| |* * *| | * * * * | | * * * * | | * ** * * | | * * * * | | * * * * | | ** ** | | * * | | | | | +-----------+ */ 0x0000, 0x0000, 0x0000, 0x8420, 0x8420, 0x4a40, 0x4a40, 0x5a40, 0x5140, 0x5140, 0x3180, 0x2080, 0x0000, 0x0000, /* Character 88 (0x58): width 8 +--------+ | | | | | | |* *| | * * | | * * | | * * | | ** | | * * | | * * | | * * | |* *| | | | | +--------+ */ 0x0000, 0x0000, 0x0000, 0x8100, 0x4200, 0x2400, 0x2400, 0x1800, 0x2400, 0x2400, 0x4200, 0x8100, 0x0000, 0x0000, /* Character 89 (0x59): width 8 +--------+ | | | | | | |* * | | * * | | * * | | * * | | * | | * | | * | | * | | * | | | | | +--------+ */ 0x0000, 0x0000, 0x0000, 0x8200, 0x4400, 0x4400, 0x2800, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x0000, 0x0000, /* Character 90 (0x5a): width 8 +--------+ | | | | | | |******* | | * | | * | | * | | * | | * | | * | |* | |******* | | | | | +--------+ */ 0x0000, 0x0000, 0x0000, 0xfe00, 0x0200, 0x0400, 0x0800, 0x1000, 0x2000, 0x4000, 0x8000, 0xfe00, 0x0000, 0x0000, /* Character 91 (0x5b): width 4 +----+ | | | | | ***| | * | | * | | * | | * | | * | | * | | * | | * | | * | | * | | ***| +----+ */ 0x0000, 0x0000, 0x7000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x7000, /* Character 92 (0x5c): width 7 +-------+ | | | | | | | * | | * | | * | | * | | * | | * | | * | | * | | * | | * | | * | +-------+ */ 0x0000, 0x0000, 0x0000, 0x4000, 0x4000, 0x4000, 0x2000, 0x2000, 0x2000, 0x1000, 0x1000, 0x1000, 0x0800, 0x0800, /* Character 93 (0x5d): width 4 +----+ | | | | |*** | | * | | * | | * | | * | | * | | * | | * | | * | | * | | * | |*** | +----+ */ 0x0000, 0x0000, 0xe000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0xe000, /* Character 94 (0x5e): width 8 +--------+ | | | | | | | * | | * | | * * | | * * | | * * | | * * | |* * | | | | | | | | | +--------+ */ 0x0000, 0x0000, 0x0000, 0x1000, 0x1000, 0x2800, 0x2800, 0x4400, 0x4400, 0x8200, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 95 (0x5f): width 7 +-------+ | | | | | | | | | | | | | | | | | | | | | | | | | ***** | | | +-------+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x7c00, 0x0000, /* Character 96 (0x60): width 8 +--------+ | | | | | ** | | ** | | | | | | | | | | | | | | | | | | | | | +--------+ */ 0x0000, 0x0000, 0x1800, 0x0c00, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 97 (0x61): width 7 +-------+ | | | | | | | | | | | ** | | * * | | * | | **** | | * * | | * * | | *****| | | | | +-------+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x1800, 0x2400, 0x0400, 0x3c00, 0x4400, 0x4400, 0x3e00, 0x0000, 0x0000, /* Character 98 (0x62): width 8 +--------+ | | | | | * | | * | | * | | * *** | | ** * | | * * | | * * | | * * | | * * | | ***** | | | | | +--------+ */ 0x0000, 0x0000, 0x4000, 0x4000, 0x4000, 0x5c00, 0x6200, 0x4200, 0x4200, 0x4200, 0x4200, 0x7c00, 0x0000, 0x0000, /* Character 99 (0x63): width 7 +-------+ | | | | | | | | | | | **** | | * | | * | | * | | * | | * | | **** | | | | | +-------+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x3c00, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x3c00, 0x0000, 0x0000, /* Character 100 (0x64): width 8 +--------+ | | | | | * | | * | | * | | ***** | | * * | | * * | | * * | | * * | | * ** | | *** * | | | | | +--------+ */ 0x0000, 0x0000, 0x0200, 0x0200, 0x0200, 0x3e00, 0x4200, 0x4200, 0x4200, 0x4200, 0x4600, 0x3a00, 0x0000, 0x0000, /* Character 101 (0x65): width 7 +-------+ | | | | | | | | | | | *** | | * * | | * * | | ***** | | * | | * | | **** | | | | | +-------+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x3800, 0x4400, 0x4400, 0x7c00, 0x4000, 0x4000, 0x3c00, 0x0000, 0x0000, /* Character 102 (0x66): width 5 +-----+ | | | | | **| | * | | * | | ****| | * | | * | | * | | * | | * | | * | | | | | +-----+ */ 0x0000, 0x0000, 0x1c00, 0x2000, 0x2000, 0x7800, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x0000, 0x0000, /* Character 103 (0x67): width 8 +--------+ | | | | | | | | | | | ***** | | * * | | * * | | * * | | * * | | * ** | | *** * | | * | | * | +--------+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x3e00, 0x4200, 0x4200, 0x4200, 0x4200, 0x4600, 0x3a00, 0x0200, 0x0400, /* Character 104 (0x68): width 8 +--------+ | | | | | * | | * | | * | | * *** | | ** * | | * * | | * * | | * * | | * * | | * * | | | | | +--------+ */ 0x0000, 0x0000, 0x4000, 0x4000, 0x4000, 0x5c00, 0x6200, 0x4200, 0x4200, 0x4200, 0x4200, 0x4200, 0x0000, 0x0000, /* Character 105 (0x69): width 4 +----+ | | | | | | | * | | | | * | | * | | * | | * | | * | | * | | * | | | | | +----+ */ 0x0000, 0x0000, 0x0000, 0x4000, 0x0000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x0000, 0x0000, /* Character 106 (0x6a): width 5 +-----+ | | | | | | | * | | | | * | | * | | * | | * | | * | | * | | * | | * | | * | +-----+ */ 0x0000, 0x0000, 0x0000, 0x1000, 0x0000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, /* Character 107 (0x6b): width 8 +--------+ | | | | | * | | * | | * | | * * | | * * | | * * | | ** | | * * | | * * | | * * | | | | | +--------+ */ 0x0000, 0x0000, 0x4000, 0x4000, 0x4000, 0x4400, 0x4800, 0x5000, 0x6000, 0x5000, 0x4800, 0x4400, 0x0000, 0x0000, /* Character 108 (0x6c): width 4 +----+ | | | | | * | | * | | * | | * | | * | | * | | * | | * | | * | | * | | | | | +----+ */ 0x0000, 0x0000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x0000, 0x0000, /* Character 109 (0x6d): width 12 +------------+ | | | | | | | | | | | * ** ** | | ** ** * | | * * * | | * * * | | * * * | | * * * | | * * * | | | | | +------------+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x5980, 0x6640, 0x4440, 0x4440, 0x4440, 0x4440, 0x4440, 0x0000, 0x0000, /* Character 110 (0x6e): width 8 +--------+ | | | | | | | | | | | * *** | | ** * | | * * | | * * | | * * | | * * | | * * | | | | | +--------+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x5c00, 0x6200, 0x4200, 0x4200, 0x4200, 0x4200, 0x4200, 0x0000, 0x0000, /* Character 111 (0x6f): width 8 +--------+ | | | | | | | | | | | **** | | * * | | * * | | * * | | * * | | * * | | **** | | | | | +--------+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x3c00, 0x4200, 0x4200, 0x4200, 0x4200, 0x4200, 0x3c00, 0x0000, 0x0000, /* Character 112 (0x70): width 8 +--------+ | | | | | | | | | | | * *** | | ** * | | * * | | * * | | * * | | * * | | ***** | | * | | * | +--------+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x5c00, 0x6200, 0x4200, 0x4200, 0x4200, 0x4200, 0x7c00, 0x4000, 0x4000, /* Character 113 (0x71): width 8 +--------+ | | | | | | | | | | | ***** | | * * | | * * | | * * | | * * | | * ** | | *** * | | * | | * | +--------+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x3e00, 0x4200, 0x4200, 0x4200, 0x4200, 0x4600, 0x3a00, 0x0200, 0x0200, /* Character 114 (0x72): width 5 +-----+ | | | | | | | | | | | * **| | ** | | * | | * | | * | | * | | * | | | | | +-----+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x5800, 0x6000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x0000, 0x0000, /* Character 115 (0x73): width 7 +-------+ | | | | | | | | | | | *** | | * | | * | | *** | | * | | * | | **** | | | | | +-------+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x3800, 0x4000, 0x4000, 0x3800, 0x0400, 0x0400, 0x7800, 0x0000, 0x0000, /* Character 116 (0x74): width 5 +-----+ | | | | | | | | | * | |**** | | * | | * | | * | | * | | * | | ** | | | | | +-----+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x4000, 0xf000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x3000, 0x0000, 0x0000, /* Character 117 (0x75): width 8 +--------+ | | | | | | | | | | | * * | | * * | | * * | | * * | | * * | | * ** | | *** * | | | | | +--------+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x4200, 0x4200, 0x4200, 0x4200, 0x4200, 0x4600, 0x3a00, 0x0000, 0x0000, /* Character 118 (0x76): width 7 +-------+ | | | | | | | | | | |* *| | * * | | * * | | * * | | * * | | * * | | * | | | | | +-------+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x8200, 0x4400, 0x4400, 0x4400, 0x2800, 0x2800, 0x1000, 0x0000, 0x0000, /* Character 119 (0x77): width 10 +----------+ | | | | | | | | | | |* * * | |* * * | | * * * * | | * * * * | | * * * * | | * * | | * * | | | | | +----------+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x8880, 0x8880, 0x5500, 0x5500, 0x5500, 0x2200, 0x2200, 0x0000, 0x0000, /* Character 120 (0x78): width 8 +--------+ | | | | | | | | | | | * * | | * * | | ** | | ** | | ** | | * * | | * * | | | | | +--------+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x4200, 0x2400, 0x1800, 0x1800, 0x1800, 0x2400, 0x4200, 0x0000, 0x0000, /* Character 121 (0x79): width 7 +-------+ | | | | | | | | | | |* *| | * * | | * * | | * * | | * * | | * * | | * | | * | | * | +-------+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x8200, 0x4400, 0x4400, 0x4400, 0x2800, 0x2800, 0x1000, 0x1000, 0x1000, /* Character 122 (0x7a): width 7 +-------+ | | | | | | | | | | | ******| | * | | * | | * | | * | | * | | ******| | | | | +-------+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x7e00, 0x0400, 0x0800, 0x1000, 0x2000, 0x4000, 0x7e00, 0x0000, 0x0000, /* Character 123 (0x7b): width 4 +----+ | | | | | * | | * | | * | | * | | * | |* | | * | | * | | * | | * | | * | | * | +----+ */ 0x0000, 0x0000, 0x2000, 0x4000, 0x4000, 0x4000, 0x4000, 0x8000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x2000, /* Character 124 (0x7c): width 5 +-----+ | | | | | * | | * | | * | | * | | * | | * | | * | | * | | * | | * | | * | | * | +-----+ */ 0x0000, 0x0000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, /* Character 125 (0x7d): width 4 +----+ | | | | | * | | * | | * | | * | | * | | *| | * | | * | | * | | * | | * | | * | +----+ */ 0x0000, 0x0000, 0x4000, 0x2000, 0x2000, 0x2000, 0x2000, 0x1000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x4000, /* Character 126 (0x7e): width 8 +--------+ | | | | | | | | | | | | | | | *** * | | * *** | | | | | | | | | | | +--------+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x7200, 0x4e00, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 127 (0x7f): width 8 +--------+ | | | | | | | | | * ** * | | * * | | * * | | * * | | * * | | * ** * | | | | | | | | | +--------+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x5a00, 0x2400, 0x4200, 0x4200, 0x2400, 0x5a00, 0x0000, 0x0000, 0x0000, 0x0000, }; /* Character->glyph mapping. */ static const unsigned short _lucidasans9_offset[] = { 0, /* (0x20) */ 14, /* (0x21) */ 28, /* (0x22) */ 42, /* (0x23) */ 56, /* (0x24) */ 70, /* (0x25) */ 84, /* (0x26) */ 98, /* (0x27) */ 112, /* (0x28) */ 126, /* (0x29) */ 140, /* (0x2a) */ 154, /* (0x2b) */ 168, /* (0x2c) */ 182, /* (0x2d) */ 196, /* (0x2e) */ 210, /* (0x2f) */ 224, /* (0x30) */ 238, /* (0x31) */ 252, /* (0x32) */ 266, /* (0x33) */ 280, /* (0x34) */ 294, /* (0x35) */ 308, /* (0x36) */ 322, /* (0x37) */ 336, /* (0x38) */ 350, /* (0x39) */ 364, /* (0x3a) */ 378, /* (0x3b) */ 392, /* (0x3c) */ 406, /* (0x3d) */ 420, /* (0x3e) */ 434, /* (0x3f) */ 448, /* (0x40) */ 462, /* (0x41) */ 476, /* (0x42) */ 490, /* (0x43) */ 504, /* (0x44) */ 518, /* (0x45) */ 532, /* (0x46) */ 546, /* (0x47) */ 560, /* (0x48) */ 574, /* (0x49) */ 588, /* (0x4a) */ 602, /* (0x4b) */ 616, /* (0x4c) */ 630, /* (0x4d) */ 644, /* (0x4e) */ 658, /* (0x4f) */ 672, /* (0x50) */ 686, /* (0x51) */ 700, /* (0x52) */ 714, /* (0x53) */ 728, /* (0x54) */ 742, /* (0x55) */ 756, /* (0x56) */ 770, /* (0x57) */ 784, /* (0x58) */ 798, /* (0x59) */ 812, /* (0x5a) */ 826, /* (0x5b) */ 840, /* (0x5c) */ 854, /* (0x5d) */ 868, /* (0x5e) */ 882, /* (0x5f) */ 896, /* (0x60) */ 910, /* (0x61) */ 924, /* (0x62) */ 938, /* (0x63) */ 952, /* (0x64) */ 966, /* (0x65) */ 980, /* (0x66) */ 994, /* (0x67) */ 1008, /* (0x68) */ 1022, /* (0x69) */ 1036, /* (0x6a) */ 1050, /* (0x6b) */ 1064, /* (0x6c) */ 1078, /* (0x6d) */ 1092, /* (0x6e) */ 1106, /* (0x6f) */ 1120, /* (0x70) */ 1134, /* (0x71) */ 1148, /* (0x72) */ 1162, /* (0x73) */ 1176, /* (0x74) */ 1190, /* (0x75) */ 1204, /* (0x76) */ 1218, /* (0x77) */ 1232, /* (0x78) */ 1246, /* (0x79) */ 1260, /* (0x7a) */ 1274, /* (0x7b) */ 1288, /* (0x7c) */ 1302, /* (0x7d) */ 1316, /* (0x7e) */ 1330, /* (0x7f) */ 1330, /* (0x80) */ 1330, /* (0x81) */ 1330, /* (0x82) */ 1330, /* (0x83) */ 1330, /* (0x84) */ 1330, /* (0x85) */ 1330, /* (0x86) */ 1330, /* (0x87) */ 1330, /* (0x88) */ 1330, /* (0x89) */ 1330, /* (0x8a) */ 1330, /* (0x8b) */ 1330, /* (0x8c) */ 1330, /* (0x8d) */ 1330, /* (0x8e) */ 1330, /* (0x8f) */ 1330, /* (0x90) */ 1330, /* (0x91) */ 1330, /* (0x92) */ 1330, /* (0x93) */ 1330, /* (0x94) */ 1330, /* (0x95) */ 1330, /* (0x96) */ 1330, /* (0x97) */ 1330, /* (0x98) */ 1330, /* (0x99) */ 1330, /* (0x9a) */ 1330, /* (0x9b) */ 1330, /* (0x9c) */ 1330, /* (0x9d) */ 1330, /* (0x9e) */ 1330, /* (0x9f) */ 1330, /* (0xa0) */ 1330, /* (0xa1) */ 1330, /* (0xa2) */ 1330, /* (0xa3) */ 1330, /* (0xa4) */ }; /* Character width data. */ static const unsigned char _lucidasans9_width[] = { 4, /* (0x20) */ 4, /* (0x21) */ 5, /* (0x22) */ 8, /* (0x23) */ 8, /* (0x24) */ 9, /* (0x25) */ 9, /* (0x26) */ 3, /* (0x27) */ 4, /* (0x28) */ 4, /* (0x29) */ 6, /* (0x2a) */ 10, /* (0x2b) */ 4, /* (0x2c) */ 8, /* (0x2d) */ 4, /* (0x2e) */ 7, /* (0x2f) */ 8, /* (0x30) */ 8, /* (0x31) */ 8, /* (0x32) */ 8, /* (0x33) */ 8, /* (0x34) */ 8, /* (0x35) */ 8, /* (0x36) */ 8, /* (0x37) */ 8, /* (0x38) */ 8, /* (0x39) */ 4, /* (0x3a) */ 4, /* (0x3b) */ 10, /* (0x3c) */ 10, /* (0x3d) */ 10, /* (0x3e) */ 5, /* (0x3f) */ 11, /* (0x40) */ 9, /* (0x41) */ 7, /* (0x42) */ 9, /* (0x43) */ 10, /* (0x44) */ 7, /* (0x45) */ 7, /* (0x46) */ 9, /* (0x47) */ 10, /* (0x48) */ 4, /* (0x49) */ 5, /* (0x4a) */ 8, /* (0x4b) */ 7, /* (0x4c) */ 11, /* (0x4d) */ 10, /* (0x4e) */ 10, /* (0x4f) */ 7, /* (0x50) */ 10, /* (0x51) */ 8, /* (0x52) */ 7, /* (0x53) */ 8, /* (0x54) */ 9, /* (0x55) */ 9, /* (0x56) */ 11, /* (0x57) */ 8, /* (0x58) */ 8, /* (0x59) */ 8, /* (0x5a) */ 4, /* (0x5b) */ 7, /* (0x5c) */ 4, /* (0x5d) */ 8, /* (0x5e) */ 7, /* (0x5f) */ 8, /* (0x60) */ 7, /* (0x61) */ 8, /* (0x62) */ 7, /* (0x63) */ 8, /* (0x64) */ 7, /* (0x65) */ 5, /* (0x66) */ 8, /* (0x67) */ 8, /* (0x68) */ 4, /* (0x69) */ 5, /* (0x6a) */ 8, /* (0x6b) */ 4, /* (0x6c) */ 12, /* (0x6d) */ 8, /* (0x6e) */ 8, /* (0x6f) */ 8, /* (0x70) */ 8, /* (0x71) */ 5, /* (0x72) */ 7, /* (0x73) */ 5, /* (0x74) */ 8, /* (0x75) */ 7, /* (0x76) */ 10, /* (0x77) */ 8, /* (0x78) */ 7, /* (0x79) */ 7, /* (0x7a) */ 4, /* (0x7b) */ 5, /* (0x7c) */ 4, /* (0x7d) */ 8, /* (0x7e) */ 8, /* (0x7f) */ 8, /* (0x80) */ 8, /* (0x81) */ 8, /* (0x82) */ 8, /* (0x83) */ 8, /* (0x84) */ 8, /* (0x85) */ 8, /* (0x86) */ 8, /* (0x87) */ 8, /* (0x88) */ 8, /* (0x89) */ 8, /* (0x8a) */ 8, /* (0x8b) */ 8, /* (0x8c) */ 8, /* (0x8d) */ 8, /* (0x8e) */ 8, /* (0x8f) */ 8, /* (0x90) */ 8, /* (0x91) */ 8, /* (0x92) */ 8, /* (0x93) */ 8, /* (0x94) */ 8, /* (0x95) */ 8, /* (0x96) */ 8, /* (0x97) */ 8, /* (0x98) */ 8, /* (0x99) */ 8, /* (0x9a) */ 8, /* (0x9b) */ 8, /* (0x9c) */ 8, /* (0x9d) */ 8, /* (0x9e) */ 8, /* (0x9f) */ 8, /* (0xa0) */ 8, /* (0xa1) */ 8, /* (0xa2) */ 8, /* (0xa3) */ 8, /* (0xa4) */ }; /* Exported structure definition. */ const struct gpanel_font_t font_lucidasans9 = { "lucidasans9", 12, 14, 12, 32, 133, _lucidasans9_bits, _lucidasans9_offset, _lucidasans9_width, 164, sizeof(_lucidasans9_bits) / sizeof(_lucidasans9_bits[0]), }; ================================================ FILE: share/examples/gpanel/fonts/verdana7.c ================================================ /* Generated by convbdf on Thu Oct 8 21:26:35 2015. */ #include /* Font information: name: verdana7 facename: -FreeType-Verdana-Medium-R-Normal--10-70-100-100-P-52-ISO10646-1 w x h: 11x10 size: 133 ascent: 8 descent: 2 first char: 32 (0x20) last char: 164 (0xa4) default char: 32 (0x20) proportional: yes Typeface and data 1996 Microsoft Corporation. All Rights Reserved */ /* Font character bitmap data. */ static const unsigned short _verdana7_bits[] = { /* Character 32 (0x20): width 4 +----+ | | | | | | | | | | | | | | | | | | | | +----+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 33 (0x21): width 4 +----+ | | | * | | * | | * | | * | | * | | | | * | | | | | +----+ */ 0x0000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x0000, 0x2000, 0x0000, 0x0000, /* Character 34 (0x22): width 5 +-----+ | * * | | * * | | * * | | | | | | | | | | | | | | | +-----+ */ 0x5000, 0x5000, 0x5000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 35 (0x23): width 8 +--------+ | | | * * | | * * | | ***** | | * * | | ***** | | * * | | * * | | | | | +--------+ */ 0x0000, 0x1400, 0x1400, 0x3e00, 0x2400, 0x7c00, 0x2800, 0x2800, 0x0000, 0x0000, /* Character 36 (0x24): width 7 +-------+ | * | | * | | **** | | * * | | ** | | ** | | * * | | **** | | * | | * | +-------+ */ 0x1000, 0x1000, 0x3c00, 0x5000, 0x3000, 0x1800, 0x1400, 0x7800, 0x1000, 0x1000, /* Character 37 (0x25): width 11 +-----------+ | | | ** * | | * * * | | * * * | | ** * ** | | * * * | | * * * | | * ** | | | | | +-----------+ */ 0x0000, 0x3100, 0x4a00, 0x4a00, 0x3580, 0x0a40, 0x0a40, 0x1180, 0x0000, 0x0000, /* Character 38 (0x26): width 7 +-------+ | | | ** | | * * | | * * | | ** *| | * * *| | * * | | *** *| | | | | +-------+ */ 0x0000, 0x3000, 0x4800, 0x4800, 0x3200, 0x4a00, 0x4400, 0x3a00, 0x0000, 0x0000, /* Character 39 (0x27): width 3 +---+ | * | | * | | * | | | | | | | | | | | | | | | +---+ */ 0x4000, 0x4000, 0x4000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 40 (0x28): width 5 +-----+ | * | | * | | * | | * | | * | | * | | * | | * | | * | | * | +-----+ */ 0x1000, 0x2000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x2000, 0x1000, /* Character 41 (0x29): width 5 +-----+ | * | | * | | * | | * | | * | | * | | * | | * | | * | | * | +-----+ */ 0x4000, 0x2000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x2000, 0x4000, /* Character 42 (0x2a): width 7 +-------+ | * | | * * * | | *** | | * * * | | * | | | | | | | | | | | +-------+ */ 0x1000, 0x5400, 0x3800, 0x5400, 0x1000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 43 (0x2b): width 8 +--------+ | | | * | | * | | * | | *******| | * | | * | | * | | | | | +--------+ */ 0x0000, 0x0800, 0x0800, 0x0800, 0x7f00, 0x0800, 0x0800, 0x0800, 0x0000, 0x0000, /* Character 44 (0x2c): width 4 +----+ | | | | | | | | | | | | | * | | * | | * | | | +----+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x2000, 0x2000, 0x4000, 0x0000, /* Character 45 (0x2d): width 5 +-----+ | | | | | | | | | *** | | | | | | | | | | | +-----+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x7000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 46 (0x2e): width 4 +----+ | | | | | | | | | | | | | * | | * | | | | | +----+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x4000, 0x4000, 0x0000, 0x0000, /* Character 47 (0x2f): width 5 +-----+ | * | | * | | * | | * | | * | | * | | * | |* | |* | | | +-----+ */ 0x1000, 0x1000, 0x2000, 0x2000, 0x4000, 0x4000, 0x4000, 0x8000, 0x8000, 0x0000, /* Character 48 (0x30): width 7 +-------+ | | | *** | | * * | | * * | | * * | | * * | | * * | | *** | | | | | +-------+ */ 0x0000, 0x3800, 0x4400, 0x4400, 0x4400, 0x4400, 0x4400, 0x3800, 0x0000, 0x0000, /* Character 49 (0x31): width 7 +-------+ | | | * | | *** | | * | | * | | * | | * | | ***** | | | | | +-------+ */ 0x0000, 0x1000, 0x7000, 0x1000, 0x1000, 0x1000, 0x1000, 0x7c00, 0x0000, 0x0000, /* Character 50 (0x32): width 7 +-------+ | | | *** | | * * | | * | | * | | * | | * | | ***** | | | | | +-------+ */ 0x0000, 0x3800, 0x4400, 0x0400, 0x0800, 0x1000, 0x2000, 0x7c00, 0x0000, 0x0000, /* Character 51 (0x33): width 7 +-------+ | | | *** | | * * | | * | | ** | | * | | * * | | *** | | | | | +-------+ */ 0x0000, 0x3800, 0x4400, 0x0400, 0x1800, 0x0400, 0x4400, 0x3800, 0x0000, 0x0000, /* Character 52 (0x34): width 7 +-------+ | | | * | | ** | | * * | | * * | | ***** | | * | | * | | | | | +-------+ */ 0x0000, 0x0800, 0x1800, 0x2800, 0x4800, 0x7c00, 0x0800, 0x0800, 0x0000, 0x0000, /* Character 53 (0x35): width 7 +-------+ | | | ***** | | * | | **** | | * | | * | | * * | | *** | | | | | +-------+ */ 0x0000, 0x7c00, 0x4000, 0x7800, 0x0400, 0x0400, 0x4400, 0x3800, 0x0000, 0x0000, /* Character 54 (0x36): width 7 +-------+ | | | ** | | * | | * | | **** | | * * | | * * | | *** | | | | | +-------+ */ 0x0000, 0x1800, 0x2000, 0x4000, 0x7800, 0x4400, 0x4400, 0x3800, 0x0000, 0x0000, /* Character 55 (0x37): width 7 +-------+ | | | ***** | | * | | * | | * | | * | | * | | * | | | | | +-------+ */ 0x0000, 0x7c00, 0x0400, 0x0800, 0x0800, 0x1000, 0x1000, 0x2000, 0x0000, 0x0000, /* Character 56 (0x38): width 7 +-------+ | | | *** | | * * | | * * | | *** | | * * | | * * | | *** | | | | | +-------+ */ 0x0000, 0x3800, 0x4400, 0x4400, 0x3800, 0x4400, 0x4400, 0x3800, 0x0000, 0x0000, /* Character 57 (0x39): width 7 +-------+ | | | *** | | * * | | * * | | **** | | * | | * | | ** | | | | | +-------+ */ 0x0000, 0x3800, 0x4400, 0x4400, 0x3c00, 0x0400, 0x0800, 0x3000, 0x0000, 0x0000, /* Character 58 (0x3a): width 5 +-----+ | | | | | | | * | | * | | | | * | | * | | | | | +-----+ */ 0x0000, 0x0000, 0x0000, 0x2000, 0x2000, 0x0000, 0x2000, 0x2000, 0x0000, 0x0000, /* Character 59 (0x3b): width 5 +-----+ | | | | | | | * | | * | | | | * | | * | | * | | | +-----+ */ 0x0000, 0x0000, 0x0000, 0x2000, 0x2000, 0x0000, 0x2000, 0x2000, 0x4000, 0x0000, /* Character 60 (0x3c): width 8 +--------+ | | | | | ** | | ** | | ** | | ** | | ** | | | | | | | +--------+ */ 0x0000, 0x0000, 0x0600, 0x1800, 0x6000, 0x1800, 0x0600, 0x0000, 0x0000, 0x0000, /* Character 61 (0x3d): width 8 +--------+ | | | | | | | ****** | | | | ****** | | | | | | | | | +--------+ */ 0x0000, 0x0000, 0x0000, 0x7e00, 0x0000, 0x7e00, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 62 (0x3e): width 8 +--------+ | | | | | ** | | ** | | ** | | ** | | ** | | | | | | | +--------+ */ 0x0000, 0x0000, 0x6000, 0x1800, 0x0600, 0x1800, 0x6000, 0x0000, 0x0000, 0x0000, /* Character 63 (0x3f): width 6 +------+ | | | *** | | * | | * | | * | | * | | | | * | | | | | +------+ */ 0x0000, 0x7000, 0x0800, 0x0800, 0x1000, 0x2000, 0x0000, 0x2000, 0x0000, 0x0000, /* Character 64 (0x40): width 10 +----------+ | | | ***** | | * * | | * *** * | | * * * * | | * * * * | | * * * * | | * ** * | | * | | **** | +----------+ */ 0x0000, 0x1f00, 0x2080, 0x4e80, 0x5280, 0x5280, 0x5280, 0x4d00, 0x2000, 0x1e00, /* Character 65 (0x41): width 7 +-------+ | | | * | | * * | | * * | | * * | | ***** | | * * | |* *| | | | | +-------+ */ 0x0000, 0x1000, 0x2800, 0x2800, 0x4400, 0x7c00, 0x4400, 0x8200, 0x0000, 0x0000, /* Character 66 (0x42): width 7 +-------+ | | | *** | | * * | | * * | | **** | | * * | | * * | | **** | | | | | +-------+ */ 0x0000, 0x7000, 0x4800, 0x4800, 0x7800, 0x4400, 0x4400, 0x7800, 0x0000, 0x0000, /* Character 67 (0x43): width 8 +--------+ | | | *** | | * * | | * | | * | | * | | * * | | *** | | | | | +--------+ */ 0x0000, 0x1c00, 0x2200, 0x4000, 0x4000, 0x4000, 0x2200, 0x1c00, 0x0000, 0x0000, /* Character 68 (0x44): width 8 +--------+ | | | **** | | * * | | * * | | * * | | * * | | * * | | **** | | | | | +--------+ */ 0x0000, 0x7800, 0x4400, 0x4200, 0x4200, 0x4200, 0x4400, 0x7800, 0x0000, 0x0000, /* Character 69 (0x45): width 6 +------+ | | | **** | | * | | * | | **** | | * | | * | | **** | | | | | +------+ */ 0x0000, 0x7800, 0x4000, 0x4000, 0x7800, 0x4000, 0x4000, 0x7800, 0x0000, 0x0000, /* Character 70 (0x46): width 6 +------+ | | | *****| | * | | * | | **** | | * | | * | | * | | | | | +------+ */ 0x0000, 0x7c00, 0x4000, 0x4000, 0x7800, 0x4000, 0x4000, 0x4000, 0x0000, 0x0000, /* Character 71 (0x47): width 8 +--------+ | | | *** | | ** * | | * | | * *** | | * * | | * * | | **** | | | | | +--------+ */ 0x0000, 0x1c00, 0x6200, 0x4000, 0x4e00, 0x4200, 0x2200, 0x1e00, 0x0000, 0x0000, /* Character 72 (0x48): width 8 +--------+ | | | * * | | * * | | * * | | ****** | | * * | | * * | | * * | | | | | +--------+ */ 0x0000, 0x4200, 0x4200, 0x4200, 0x7e00, 0x4200, 0x4200, 0x4200, 0x0000, 0x0000, /* Character 73 (0x49): width 5 +-----+ | | | *** | | * | | * | | * | | * | | * | | *** | | | | | +-----+ */ 0x0000, 0x7000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x7000, 0x0000, 0x0000, /* Character 74 (0x4a): width 5 +-----+ | | | ** | | * | | * | | * | | * | | * | |*** | | | | | +-----+ */ 0x0000, 0x3000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0xe000, 0x0000, 0x0000, /* Character 75 (0x4b): width 7 +-------+ | | | * * | | * * | | * * | | *** | | * * | | * * | | * *| | | | | +-------+ */ 0x0000, 0x4400, 0x4800, 0x5000, 0x7000, 0x4800, 0x4400, 0x4200, 0x0000, 0x0000, /* Character 76 (0x4c): width 6 +------+ | | | * | | * | | * | | * | | * | | * | | *****| | | | | +------+ */ 0x0000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x7c00, 0x0000, 0x0000, /* Character 77 (0x4d): width 9 +---------+ | | | ** ** | | ** ** | | * * * * | | * * * * | | * * * | | * * * | | * * | | | | | +---------+ */ 0x0000, 0x6300, 0x6300, 0x5500, 0x5500, 0x4900, 0x4900, 0x4100, 0x0000, 0x0000, /* Character 78 (0x4e): width 7 +-------+ | | | * * | | ** * | | * * * | | * * * | | * ** | | * * | | * * | | | | | +-------+ */ 0x0000, 0x4400, 0x6400, 0x5400, 0x5400, 0x4c00, 0x4400, 0x4400, 0x0000, 0x0000, /* Character 79 (0x4f): width 9 +---------+ | | | *** | | * * | | * * | | * * | | * * | | * * | | *** | | | | | +---------+ */ 0x0000, 0x1c00, 0x2200, 0x4100, 0x4100, 0x4100, 0x2200, 0x1c00, 0x0000, 0x0000, /* Character 80 (0x50): width 7 +-------+ | | | **** | | * * | | * * | | * * | | **** | | * | | * | | | | | +-------+ */ 0x0000, 0x7800, 0x4400, 0x4400, 0x4400, 0x7800, 0x4000, 0x4000, 0x0000, 0x0000, /* Character 81 (0x51): width 9 +---------+ | | | *** | | * * | | * * | | * * | | * * | | * * | | *** | | * | | ** | +---------+ */ 0x0000, 0x1c00, 0x2200, 0x4100, 0x4100, 0x4100, 0x2200, 0x1c00, 0x0400, 0x0300, /* Character 82 (0x52): width 8 +--------+ | | | **** | | * * | | * * | | **** | | * * | | * * | | * * | | | | | +--------+ */ 0x0000, 0x7800, 0x4400, 0x4400, 0x7800, 0x4800, 0x4400, 0x4200, 0x0000, 0x0000, /* Character 83 (0x53): width 7 +-------+ | | | *** | | * * | | * | | *** | | * | | * * | | *** | | | | | +-------+ */ 0x0000, 0x3800, 0x4400, 0x4000, 0x3800, 0x0400, 0x4400, 0x3800, 0x0000, 0x0000, /* Character 84 (0x54): width 7 +-------+ | | |*******| | * | | * | | * | | * | | * | | * | | | | | +-------+ */ 0x0000, 0xfe00, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x0000, 0x0000, /* Character 85 (0x55): width 8 +--------+ | | | * * | | * * | | * * | | * * | | * * | | * * | | **** | | | | | +--------+ */ 0x0000, 0x4200, 0x4200, 0x4200, 0x4200, 0x4200, 0x4200, 0x3c00, 0x0000, 0x0000, /* Character 86 (0x56): width 7 +-------+ | | |* *| | * * | | * * | | * * | | * * | | * * | | * | | | | | +-------+ */ 0x0000, 0x8200, 0x4400, 0x4400, 0x4400, 0x2800, 0x2800, 0x1000, 0x0000, 0x0000, /* Character 87 (0x57): width 11 +-----------+ | | | * * * | | * * * | | * * * * | | * * * * | | * * * * | | * * | | * * | | | | | +-----------+ */ 0x0000, 0x4440, 0x4440, 0x2a80, 0x2a80, 0x2a80, 0x1100, 0x1100, 0x0000, 0x0000, /* Character 88 (0x58): width 7 +-------+ | | | * * | | * * | | * * | | * | | * * | | * * | | * * | | | | | +-------+ */ 0x0000, 0x4400, 0x4400, 0x2800, 0x1000, 0x2800, 0x4400, 0x4400, 0x0000, 0x0000, /* Character 89 (0x59): width 7 +-------+ | | |* *| | * * | | * * | | * | | * | | * | | * | | | | | +-------+ */ 0x0000, 0x8200, 0x4400, 0x2800, 0x1000, 0x1000, 0x1000, 0x1000, 0x0000, 0x0000, /* Character 90 (0x5a): width 7 +-------+ | | | ***** | | * | | * | | * | | * | | * | | ***** | | | | | +-------+ */ 0x0000, 0x7c00, 0x0400, 0x0800, 0x1000, 0x2000, 0x4000, 0x7c00, 0x0000, 0x0000, /* Character 91 (0x5b): width 5 +-----+ | *** | | * | | * | | * | | * | | * | | * | | * | | * | | *** | +-----+ */ 0x7000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x7000, /* Character 92 (0x5c): width 5 +-----+ |* | |* | | * | | * | | * | | * | | * | | * | | * | | | +-----+ */ 0x8000, 0x8000, 0x4000, 0x4000, 0x2000, 0x2000, 0x2000, 0x1000, 0x1000, 0x0000, /* Character 93 (0x5d): width 5 +-----+ | *** | | * | | * | | * | | * | | * | | * | | * | | * | | *** | +-----+ */ 0x7000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x7000, /* Character 94 (0x5e): width 8 +--------+ | | | ** | | * * | | * * | | | | | | | | | | | | | +--------+ */ 0x0000, 0x1800, 0x2400, 0x4200, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 95 (0x5f): width 6 +------+ | | | | | | | | | | | | | | | | | | |******| +------+ */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xfc00, /* Character 96 (0x60): width 6 +------+ | * | | * | | | | | | | | | | | | | | | | | +------+ */ 0x2000, 0x1000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 97 (0x61): width 7 +-------+ | | | | | | | *** | | * | | **** | | * * | | **** | | | | | +-------+ */ 0x0000, 0x0000, 0x0000, 0x3800, 0x0400, 0x3c00, 0x4400, 0x3c00, 0x0000, 0x0000, /* Character 98 (0x62): width 7 +-------+ | * | | * | | * | | **** | | * * | | * * | | * * | | **** | | | | | +-------+ */ 0x4000, 0x4000, 0x4000, 0x7800, 0x4400, 0x4400, 0x4400, 0x7800, 0x0000, 0x0000, /* Character 99 (0x63): width 5 +-----+ | | | | | | | ***| | * | | * | | * | | ***| | | | | +-----+ */ 0x0000, 0x0000, 0x0000, 0x3800, 0x4000, 0x4000, 0x4000, 0x3800, 0x0000, 0x0000, /* Character 100 (0x64): width 7 +-------+ | * | | * | | * | | **** | | * * | | * * | | * * | | **** | | | | | +-------+ */ 0x0400, 0x0400, 0x0400, 0x3c00, 0x4400, 0x4400, 0x4400, 0x3c00, 0x0000, 0x0000, /* Character 101 (0x65): width 7 +-------+ | | | | | | | *** | | * * | | ***** | | * | | **** | | | | | +-------+ */ 0x0000, 0x0000, 0x0000, 0x3800, 0x4400, 0x7c00, 0x4000, 0x3c00, 0x0000, 0x0000, /* Character 102 (0x66): width 4 +----+ | **| | * | | * | |****| | * | | * | | * | | * | | | | | +----+ */ 0x3000, 0x4000, 0x4000, 0xf000, 0x4000, 0x4000, 0x4000, 0x4000, 0x0000, 0x0000, /* Character 103 (0x67): width 7 +-------+ | | | | | | | **** | | * * | | * * | | * * | | **** | | * | | *** | +-------+ */ 0x0000, 0x0000, 0x0000, 0x3c00, 0x4400, 0x4400, 0x4400, 0x3c00, 0x0400, 0x3800, /* Character 104 (0x68): width 7 +-------+ | * | | * | | * | | **** | | * * | | * * | | * * | | * * | | | | | +-------+ */ 0x4000, 0x4000, 0x4000, 0x7800, 0x4400, 0x4400, 0x4400, 0x4400, 0x0000, 0x0000, /* Character 105 (0x69): width 3 +---+ | | | * | | | | * | | * | | * | | * | | * | | | | | +---+ */ 0x0000, 0x4000, 0x0000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x0000, 0x0000, /* Character 106 (0x6a): width 4 +----+ | | | * | | | | ** | | * | | * | | * | | * | | * | |** | +----+ */ 0x0000, 0x2000, 0x0000, 0x6000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0xc000, /* Character 107 (0x6b): width 7 +-------+ | * | | * | | * | | * * | | * * | | *** | | * * | | * * | | | | | +-------+ */ 0x4000, 0x4000, 0x4000, 0x4800, 0x5000, 0x7000, 0x4800, 0x4400, 0x0000, 0x0000, /* Character 108 (0x6c): width 3 +---+ | * | | * | | * | | * | | * | | * | | * | | * | | | | | +---+ */ 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x0000, 0x0000, /* Character 109 (0x6d): width 11 +-----------+ | | | | | | | **** *** | | * * * | | * * * | | * * * | | * * * | | | | | +-----------+ */ 0x0000, 0x0000, 0x0000, 0x7b80, 0x4440, 0x4440, 0x4440, 0x4440, 0x0000, 0x0000, /* Character 110 (0x6e): width 7 +-------+ | | | | | | | **** | | * * | | * * | | * * | | * * | | | | | +-------+ */ 0x0000, 0x0000, 0x0000, 0x7800, 0x4400, 0x4400, 0x4400, 0x4400, 0x0000, 0x0000, /* Character 111 (0x6f): width 7 +-------+ | | | | | | | *** | | * * | | * * | | * * | | *** | | | | | +-------+ */ 0x0000, 0x0000, 0x0000, 0x3800, 0x4400, 0x4400, 0x4400, 0x3800, 0x0000, 0x0000, /* Character 112 (0x70): width 7 +-------+ | | | | | | | **** | | * * | | * * | | * * | | **** | | * | | * | +-------+ */ 0x0000, 0x0000, 0x0000, 0x7800, 0x4400, 0x4400, 0x4400, 0x7800, 0x4000, 0x4000, /* Character 113 (0x71): width 7 +-------+ | | | | | | | **** | | * * | | * * | | * * | | **** | | * | | * | +-------+ */ 0x0000, 0x0000, 0x0000, 0x3c00, 0x4400, 0x4400, 0x4400, 0x3c00, 0x0400, 0x0400, /* Character 114 (0x72): width 4 +----+ | | | | | | | * *| | ** | | * | | * | | * | | | | | +----+ */ 0x0000, 0x0000, 0x0000, 0x5000, 0x6000, 0x4000, 0x4000, 0x4000, 0x0000, 0x0000, /* Character 115 (0x73): width 6 +------+ | | | | | | | *** | | * | | ** | | * | | *** | | | | | +------+ */ 0x0000, 0x0000, 0x0000, 0x3800, 0x4000, 0x3000, 0x0800, 0x7000, 0x0000, 0x0000, /* Character 116 (0x74): width 4 +----+ | | | * | | * | |****| | * | | * | | * | | **| | | | | +----+ */ 0x0000, 0x4000, 0x4000, 0xf000, 0x4000, 0x4000, 0x4000, 0x3000, 0x0000, 0x0000, /* Character 117 (0x75): width 7 +-------+ | | | | | | | * * | | * * | | * * | | * * | | **** | | | | | +-------+ */ 0x0000, 0x0000, 0x0000, 0x4400, 0x4400, 0x4400, 0x4400, 0x3c00, 0x0000, 0x0000, /* Character 118 (0x76): width 6 +------+ | | | | | | | * * | | * * | | * * | | ** | | ** | | | | | +------+ */ 0x0000, 0x0000, 0x0000, 0x4800, 0x4800, 0x4800, 0x3000, 0x3000, 0x0000, 0x0000, /* Character 119 (0x77): width 7 +-------+ | | | | | | | * * | | * * * | | * * * | | * * | | * * | | | | | +-------+ */ 0x0000, 0x0000, 0x0000, 0x4400, 0x5400, 0x5400, 0x2800, 0x2800, 0x0000, 0x0000, /* Character 120 (0x78): width 7 +-------+ | | | | | | | * * | | * * | | * | | * * | | * * | | | | | +-------+ */ 0x0000, 0x0000, 0x0000, 0x4400, 0x2800, 0x1000, 0x2800, 0x4400, 0x0000, 0x0000, /* Character 121 (0x79): width 6 +------+ | | | | | | | * * | | * * | | * * | | ** | | * | | * | | * | +------+ */ 0x0000, 0x0000, 0x0000, 0x4800, 0x4800, 0x4800, 0x3000, 0x1000, 0x2000, 0x2000, /* Character 122 (0x7a): width 6 +------+ | | | | | | | **** | | * | | * | | * | | **** | | | | | +------+ */ 0x0000, 0x0000, 0x0000, 0x7800, 0x1000, 0x2000, 0x4000, 0x7800, 0x0000, 0x0000, /* Character 123 (0x7b): width 6 +------+ | **| | * | | * | | * | | * | | ** | | * | | * | | * | | **| +------+ */ 0x0c00, 0x1000, 0x1000, 0x1000, 0x1000, 0x6000, 0x1000, 0x1000, 0x1000, 0x0c00, /* Character 124 (0x7c): width 5 +-----+ | * | | * | | * | | * | | * | | * | | * | | * | | * | | * | +-----+ */ 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, /* Character 125 (0x7d): width 6 +------+ |** | | * | | * | | * | | * | | ** | | * | | * | | * | |** | +------+ */ 0xc000, 0x2000, 0x2000, 0x2000, 0x2000, 0x1800, 0x2000, 0x2000, 0x2000, 0xc000, /* Character 126 (0x7e): width 8 +--------+ | | | | | | | * * | | * ** * | | * ** | | | | | | | | | +--------+ */ 0x0000, 0x0000, 0x0000, 0x2200, 0x5a00, 0x4c00, 0x0000, 0x0000, 0x0000, 0x0000, /* Character 164 (0xa4): width 7 +-------+ | | | | | * * | | *** | | * * | | *** | | * * | | | | | | | +-------+ */ 0x0000, 0x0000, 0x4400, 0x3800, 0x2800, 0x3800, 0x4400, 0x0000, 0x0000, 0x0000, }; /* Character->glyph mapping. */ static const unsigned short _verdana7_offset[] = { 0, /* (0x20) */ 10, /* (0x21) */ 20, /* (0x22) */ 30, /* (0x23) */ 40, /* (0x24) */ 50, /* (0x25) */ 60, /* (0x26) */ 70, /* (0x27) */ 80, /* (0x28) */ 90, /* (0x29) */ 100, /* (0x2a) */ 110, /* (0x2b) */ 120, /* (0x2c) */ 130, /* (0x2d) */ 140, /* (0x2e) */ 150, /* (0x2f) */ 160, /* (0x30) */ 170, /* (0x31) */ 180, /* (0x32) */ 190, /* (0x33) */ 200, /* (0x34) */ 210, /* (0x35) */ 220, /* (0x36) */ 230, /* (0x37) */ 240, /* (0x38) */ 250, /* (0x39) */ 260, /* (0x3a) */ 270, /* (0x3b) */ 280, /* (0x3c) */ 290, /* (0x3d) */ 300, /* (0x3e) */ 310, /* (0x3f) */ 320, /* (0x40) */ 330, /* (0x41) */ 340, /* (0x42) */ 350, /* (0x43) */ 360, /* (0x44) */ 370, /* (0x45) */ 380, /* (0x46) */ 390, /* (0x47) */ 400, /* (0x48) */ 410, /* (0x49) */ 420, /* (0x4a) */ 430, /* (0x4b) */ 440, /* (0x4c) */ 450, /* (0x4d) */ 460, /* (0x4e) */ 470, /* (0x4f) */ 480, /* (0x50) */ 490, /* (0x51) */ 500, /* (0x52) */ 510, /* (0x53) */ 520, /* (0x54) */ 530, /* (0x55) */ 540, /* (0x56) */ 550, /* (0x57) */ 560, /* (0x58) */ 570, /* (0x59) */ 580, /* (0x5a) */ 590, /* (0x5b) */ 600, /* (0x5c) */ 610, /* (0x5d) */ 620, /* (0x5e) */ 630, /* (0x5f) */ 640, /* (0x60) */ 650, /* (0x61) */ 660, /* (0x62) */ 670, /* (0x63) */ 680, /* (0x64) */ 690, /* (0x65) */ 700, /* (0x66) */ 710, /* (0x67) */ 720, /* (0x68) */ 730, /* (0x69) */ 740, /* (0x6a) */ 750, /* (0x6b) */ 760, /* (0x6c) */ 770, /* (0x6d) */ 780, /* (0x6e) */ 790, /* (0x6f) */ 800, /* (0x70) */ 810, /* (0x71) */ 820, /* (0x72) */ 830, /* (0x73) */ 840, /* (0x74) */ 850, /* (0x75) */ 860, /* (0x76) */ 870, /* (0x77) */ 880, /* (0x78) */ 890, /* (0x79) */ 900, /* (0x7a) */ 910, /* (0x7b) */ 920, /* (0x7c) */ 930, /* (0x7d) */ 940, /* (0x7e) */ 0, /* (0x7f) */ 0, /* (0x80) */ 0, /* (0x81) */ 0, /* (0x82) */ 0, /* (0x83) */ 0, /* (0x84) */ 0, /* (0x85) */ 0, /* (0x86) */ 0, /* (0x87) */ 0, /* (0x88) */ 0, /* (0x89) */ 0, /* (0x8a) */ 0, /* (0x8b) */ 0, /* (0x8c) */ 0, /* (0x8d) */ 0, /* (0x8e) */ 0, /* (0x8f) */ 0, /* (0x90) */ 0, /* (0x91) */ 0, /* (0x92) */ 0, /* (0x93) */ 0, /* (0x94) */ 0, /* (0x95) */ 0, /* (0x96) */ 0, /* (0x97) */ 0, /* (0x98) */ 0, /* (0x99) */ 0, /* (0x9a) */ 0, /* (0x9b) */ 0, /* (0x9c) */ 0, /* (0x9d) */ 0, /* (0x9e) */ 0, /* (0x9f) */ 0, /* (0xa0) */ 0, /* (0xa1) */ 0, /* (0xa2) */ 0, /* (0xa3) */ 950, /* (0xa4) */ }; /* Character width data. */ static const unsigned char _verdana7_width[] = { 4, /* (0x20) */ 4, /* (0x21) */ 5, /* (0x22) */ 8, /* (0x23) */ 7, /* (0x24) */ 11, /* (0x25) */ 7, /* (0x26) */ 3, /* (0x27) */ 5, /* (0x28) */ 5, /* (0x29) */ 7, /* (0x2a) */ 8, /* (0x2b) */ 4, /* (0x2c) */ 5, /* (0x2d) */ 4, /* (0x2e) */ 5, /* (0x2f) */ 7, /* (0x30) */ 7, /* (0x31) */ 7, /* (0x32) */ 7, /* (0x33) */ 7, /* (0x34) */ 7, /* (0x35) */ 7, /* (0x36) */ 7, /* (0x37) */ 7, /* (0x38) */ 7, /* (0x39) */ 5, /* (0x3a) */ 5, /* (0x3b) */ 8, /* (0x3c) */ 8, /* (0x3d) */ 8, /* (0x3e) */ 6, /* (0x3f) */ 10, /* (0x40) */ 7, /* (0x41) */ 7, /* (0x42) */ 8, /* (0x43) */ 8, /* (0x44) */ 6, /* (0x45) */ 6, /* (0x46) */ 8, /* (0x47) */ 8, /* (0x48) */ 5, /* (0x49) */ 5, /* (0x4a) */ 7, /* (0x4b) */ 6, /* (0x4c) */ 9, /* (0x4d) */ 7, /* (0x4e) */ 9, /* (0x4f) */ 7, /* (0x50) */ 9, /* (0x51) */ 8, /* (0x52) */ 7, /* (0x53) */ 7, /* (0x54) */ 8, /* (0x55) */ 7, /* (0x56) */ 11, /* (0x57) */ 7, /* (0x58) */ 7, /* (0x59) */ 7, /* (0x5a) */ 5, /* (0x5b) */ 5, /* (0x5c) */ 5, /* (0x5d) */ 8, /* (0x5e) */ 6, /* (0x5f) */ 6, /* (0x60) */ 7, /* (0x61) */ 7, /* (0x62) */ 5, /* (0x63) */ 7, /* (0x64) */ 7, /* (0x65) */ 4, /* (0x66) */ 7, /* (0x67) */ 7, /* (0x68) */ 3, /* (0x69) */ 4, /* (0x6a) */ 7, /* (0x6b) */ 3, /* (0x6c) */ 11, /* (0x6d) */ 7, /* (0x6e) */ 7, /* (0x6f) */ 7, /* (0x70) */ 7, /* (0x71) */ 4, /* (0x72) */ 6, /* (0x73) */ 4, /* (0x74) */ 7, /* (0x75) */ 6, /* (0x76) */ 7, /* (0x77) */ 7, /* (0x78) */ 6, /* (0x79) */ 6, /* (0x7a) */ 6, /* (0x7b) */ 5, /* (0x7c) */ 6, /* (0x7d) */ 8, /* (0x7e) */ 4, /* (0x7f) */ 4, /* (0x80) */ 4, /* (0x81) */ 4, /* (0x82) */ 4, /* (0x83) */ 4, /* (0x84) */ 4, /* (0x85) */ 4, /* (0x86) */ 4, /* (0x87) */ 4, /* (0x88) */ 4, /* (0x89) */ 4, /* (0x8a) */ 4, /* (0x8b) */ 4, /* (0x8c) */ 4, /* (0x8d) */ 4, /* (0x8e) */ 4, /* (0x8f) */ 4, /* (0x90) */ 4, /* (0x91) */ 4, /* (0x92) */ 4, /* (0x93) */ 4, /* (0x94) */ 4, /* (0x95) */ 4, /* (0x96) */ 4, /* (0x97) */ 4, /* (0x98) */ 4, /* (0x99) */ 4, /* (0x9a) */ 4, /* (0x9b) */ 4, /* (0x9c) */ 4, /* (0x9d) */ 4, /* (0x9e) */ 4, /* (0x9f) */ 4, /* (0xa0) */ 4, /* (0xa1) */ 4, /* (0xa2) */ 4, /* (0xa3) */ 7, /* (0xa4) */ }; /* Exported structure definition. */ const struct gpanel_font_t font_verdana7 = { "verdana7", 11, 10, 8, 32, 133, _verdana7_bits, _verdana7_offset, _verdana7_width, 32, sizeof(_verdana7_bits) / sizeof(_verdana7_bits[0]), }; ================================================ FILE: share/examples/gpanel/line.c ================================================ /* * Draw random lines. */ #include #include int xsize, ysize; int main() { char *devname = "/dev/tft0"; int x0, y0, x1, y1, color; if (gpanel_open(devname) < 0) { printf("Cannot open %s\n", devname); exit(-1); } gpanel_clear(0, &xsize, &ysize); printf("Screen size %u x %u.\n", xsize, ysize); srand(time(0)); printf("Draw random lines.\n"); printf("Press ^C to stop.\n"); for (;;) { x0 = rand() % xsize; y0 = rand() % ysize; x1 = rand() % xsize; y1 = rand() % ysize; color = rand() << 1; gpanel_line(color, x0, y0, x1, y1); } return 0; } ================================================ FILE: share/examples/gpanel/pixel.c ================================================ /* * Draw random pixels. */ #include #include int xsize, ysize; int main() { char *devname = "/dev/tft0"; int x, y, color; if (gpanel_open(devname) < 0) { printf("Cannot open %s\n", devname); exit(-1); } gpanel_clear(0, &xsize, &ysize); printf("Screen size %u x %u.\n", xsize, ysize); srand(time(0)); printf("Draw random pixels.\n"); printf("Press ^C to stop.\n"); for (;;) { x = rand() % xsize; y = rand() % ysize; color = rand() << 1; gpanel_pixel(color, x, y); } return 0; } ================================================ FILE: share/examples/gpanel/rect.c ================================================ /* * Draw random rectangles. */ #include #include int xsize, ysize; int main() { char *devname = "/dev/tft0"; int x0, y0, x1, y1, color; if (gpanel_open(devname) < 0) { printf("Cannot open %s\n", devname); exit(-1); } gpanel_clear(0, &xsize, &ysize); printf("Screen size %u x %u.\n", xsize, ysize); srand(time(0)); printf("Draw random rectangles.\n"); printf("Press ^C to stop.\n"); for (;;) { x0 = rand() % xsize; y0 = rand() % ysize; x1 = rand() % xsize; y1 = rand() % ysize; color = rand() << 1; gpanel_rect(color, x0, y0, x1, y1); } return 0; } ================================================ FILE: share/examples/gpanel/speed.c ================================================ /* * Test the gpanel functions for speed. */ #include #include #include #define NPIXELS 100000 #define NLINES 3000 #define NRECT 1000 #define NCIRCLES 1000 #define NCHARS 10000 extern const struct gpanel_font_t font_lucidasans15; int xsize, ysize; /* * Get current time in milliseconds. */ unsigned current_msec() { struct timeval t; gettimeofday(&t, 0); return t.tv_sec * 1000 + t.tv_usec / 1000; } /* * Compute elapsed time in milliseconds. */ unsigned elapsed_msec(unsigned t0) { struct timeval t1; unsigned msec; gettimeofday (&t1, 0); msec = t1.tv_sec * 1000 + t1.tv_usec / 1000; msec -= t0; if (msec < 1) msec = 1; return msec; } int main() { char *devname = "/dev/tft0"; int x, y, x1, y1, color, i, r, sym; unsigned t0, msec; if (gpanel_open(devname) < 0) { printf("Cannot open %s\n", devname); exit(-1); } gpanel_clear(0, &xsize, &ysize); printf("Screen size %u x %u.\n", xsize, ysize); /* Use fixed seed, for repeatability. */ srand(1); printf("Graphics speed:\n"); sync(); usleep(500000); /* * Pixels. */ t0 = current_msec(); for (i=0; i #include #include #include #include #include #include #define BLACK 0x0000 #define RED 0xF800 #define GREEN 0x07E0 #define BLUE 0x001F #define WHITE 0xFFFF int fd = -1; void pixel(unsigned x, unsigned y, unsigned color) { struct gpanel_pixel_t param; param.color = color; param.x = x; param.y = y; ioctl(fd, GPANEL_PIXEL, ¶m); } void lineh(unsigned x, unsigned y, unsigned length, unsigned color) { struct gpanel_line_t param; param.color = color; param.x0 = x; param.y0 = y; param.x1 = x + length - 1; param.y1 = y; ioctl(fd, GPANEL_LINE, ¶m); } void linev(unsigned x, unsigned y, unsigned length, unsigned color) { struct gpanel_line_t param; param.color = color; param.x0 = x; param.y0 = y; param.x1 = x; param.y1 = y + length - 1; ioctl(fd, GPANEL_LINE, ¶m); } void box(unsigned x, unsigned y, unsigned width, unsigned height, unsigned color, int solid) { if (solid) { struct gpanel_rect_t param; param.color = color; param.x0 = x; param.y0 = y; param.x1 = x + width - 1; param.y1 = y + height - 1; ioctl(fd, GPANEL_FILL, ¶m); } else { lineh(x, y, width, color); lineh(x, y + height - 1, width, color); linev(x, y, height, color); linev(x + width - 1, y, height, color); } } void line(int x1, int y1, int x2, int y2, unsigned short color) { int sx, sy, dx1, dy1, dx2, dy2, x, y, m, n, k, cnt; sx = x2 - x1; sy = y2 - y1; if (sy < 0 || sy == 0 && sx < 0) { k = x1; x1 = x2; x2 = k; k = y1; y1 = y2; y2 = k; sx = -sx; sy = -sy; } if (sx > 0) dx1 = 1; else if (sx < 0) dx1 = -1; else dy1 = 0; if (sy > 0) dy1 = 1; else if (sy < 0) dy1 = -1; else dy1 = 0; m = (sx >= 0) ? sx : -sx; n = (sy >= 0) ? sy : -sy; dx2 = dx1; dy2 = 0; if (m < n) { m = (sy >= 0) ? sy : -sy; n = (sx >= 0) ? sx : -sx; dx2 = 0; dy2 = dy1; } x = x1; y = y1; cnt = m + 1; k = n / 2; while (cnt--) { if (x >= 0 && x < 480 && y >= 0 && y < 320) pixel(x, y, color); k += n; if (k < m) { x += dx2; y += dy2; } else { k -= m; x += dx1; y += dy1; } } } int main(int argc, char* argv[]) { if ((fd = open ("/dev/tft0", O_RDWR)) < 0) { perror("/dev/tft0"); return 1; } if (argc > 1) { if (!strcmp(argv[1], "-blank")) { box(0, 0, 480, 320, BLACK, 1); return 0; } } for (int y = 0; y < 320; y++) for (int x = 0; x < 480; x++) pixel(x, y, (x<<3) ^ (y<<3)); sleep(2); box(0, 0*100, 480, 100, RED, 1); box(0, 1*100, 480, 100, GREEN, 1); box(0, 2*100, 480, 100, BLUE, 1); box(0, 0, 480, 320, WHITE, 0); line(0, 0, 479, 319, RED | GREEN); line(479, 0, 0, 319, GREEN | BLUE); sleep(2); // for (;;) line(rand() & 511, rand() & 511, rand() & 511, rand() & 511, rand()); #if 01 time_t t1 = time(NULL), t2; int fps = 0; do { t2 = time(NULL); box(0, 0, 480, 320, rand(), 1); fps++; } while (t2 < t1 + 10); printf("%d fps\n", fps / 10); #endif sleep(2); box(0, 0, 480, 320, BLACK, 1); return 0; } ================================================ FILE: share/examples/gpanel/tftetris.c ================================================ /* Arduino/RetroBSD Tetris Copyright (C) 2015 João André Esteves Vilaça https://github.com/vilaca/Handheld-Color-Console Adapted for RetroBSD by Alexey Frunze. Required Hardware: - PICadillo-35T board - Funduino joystick shield v1.a This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include #include #include #include #include volatile int quit = 0; volatile int jx = 0, jy = 0; #include #include #include #include int fd = -1; int fdx = -1; int fdy = -1; struct timeval start_time; unsigned long millis(void) { static int init; struct timeval t; unsigned long ms; if (!init) { gettimeofday(&start_time, 0); init = 1; return 0; } gettimeofday(&t, 0); ms = (t.tv_sec - start_time.tv_sec) * 1000UL; ms += t.tv_usec / 1000; ms -= start_time.tv_usec / 1000; return ms; } void delay(unsigned long ms) { usleep(ms * 1000); } void lineh(unsigned x, unsigned y, unsigned length, unsigned color) { struct gpanel_line_t param; param.color = color; param.x0 = x; param.y0 = y; param.x1 = x + length - 1; param.y1 = y; ioctl(fd, GPANEL_LINE, ¶m); } void linev(unsigned x, unsigned y, unsigned length, unsigned color) { struct gpanel_line_t param; param.color = color; param.x0 = x; param.y0 = y; param.x1 = x; param.y1 = y + length - 1; ioctl(fd, GPANEL_LINE, ¶m); } void box(unsigned x, unsigned y, unsigned width, unsigned height, unsigned color, int solid) { if (solid) { struct gpanel_rect_t param; param.color = color; param.x0 = x; param.y0 = y; param.x1 = x + width - 1; param.y1 = y + height - 1; ioctl(fd, GPANEL_FILL, ¶m); } else { lineh(x, y, width, color); lineh(x, y + height - 1, width, color); linev(x, y, height, color); linev(x + width - 1, y, height, color); } } void beep(int frq, int d) { (void)frq; // TBD??? delay(d); } void boxb(unsigned x, unsigned y, unsigned w, unsigned h, unsigned short c) { box(x, y, w, h - 1, c, 1); box(x, y + h - 1, 1, 1, c, 1); } int Joystick_fire(void) { return 0; // TBD??? } int Joystick_getX(void) { char buf[21] = { 0 }; jx = 512; if (read(fdx, buf, sizeof buf - 1) > 0) jx = strtol(buf, 0, 0); jx -= 512; jx = -jx; if (-128 < jx && jx < 128) jx = 0; return jx; } int Joystick_getY(void) { char buf[21] = { 0 }; jy = 512; if (read(fdy, buf, sizeof buf - 1) > 0) jy = strtol(buf, 0, 0); jy -= 512; jy = -jy; if (-128 < jy && jy < 128) jy = 0; return jy; } void Joystick_waitForRelease(int howLong) { int c = 0; do { delay(10); c += 10; } while ((Joystick_fire() || Joystick_getY() || Joystick_getX()) && c < howLong); } void randomizer(void); void score(void); void scoreBoard(void); void draw(void); void moveDown(void); void userInput(unsigned long now); void chooseNewShape(void); int touches(int xi, int yi, int roti); //TFT resolution 480x320 #define LCD_WIDTH 480//320//480 #define LCD_HEIGHT 320//200//320 #define MIN(X, Y) (((X) < (Y)) ? (X) : (Y)) #define FONT_SPACE 6 #define FONT_X 8 extern unsigned char simpleFont[][8]; enum { BOARD_WIDTH = 11, BOARD_HEIGHT = 20, BLOCK_SIZE = MIN(LCD_WIDTH / BOARD_WIDTH - 1, LCD_HEIGHT / BOARD_HEIGHT - 1), BOARD_LEFT = (LCD_WIDTH - BOARD_WIDTH * BLOCK_SIZE) / 4 * 3, BOARD_RIGHT = BOARD_LEFT + BLOCK_SIZE * BOARD_WIDTH, BOARD_TOP = (LCD_HEIGHT - BOARD_HEIGHT * BLOCK_SIZE) / 2, BOARD_BOTTOM = BOARD_TOP + BOARD_HEIGHT * BLOCK_SIZE }; //Basic Colors #define BLACK 0x0000 #define BLUE 0x001f #define CYAN 0x07ff #define DARKCYAN 0x03EF /* 0, 128, 128 */ #define DARKGREEN 0x03E0 #define DARKGREY 0x7BEF /* 128, 128, 128 */ #define GRAY1 0x8410 #define GRAY2 0x4208 #define GRAY3 0x2104 #define GREEN 0x07e0 #define LIGHTGREEN 0xAFE5 /* 173, 255, 47 */ #define LIGHTGREY 0xC618 /* 192, 192, 192 */ #define MAGENTA 0xF81F /* 255, 0, 255 */ #define MAROON 0x7800 /* 128, 0, 0 */ #define NAVY 0x000F /* 0, 0, 128 */ #define OLIVE 0x7BE0 /* 128, 128, 0 */ #define ORANGE 0xFD20 /* 255, 165, 0 */ #define PURPLE 0x780F /* 128, 0, 128 */ #define RED 0xf800 #define WHITE 0xffff #define YELLOW 0xffe0 #define PIT_COLOR CYAN #define BG_COLOR BLACK typedef unsigned char byte; // used to clear the position from the screen typedef struct { byte x, y, rot; } Backup; #define DROP_WAIT_INIT 1100 #define INPUT_WAIT_ROT 200 #define INPUT_WAIT_MOVE 100 #define INPUT_WAIT_NEW_SHAPE 400 // shapes definitions byte l_shape[4][4][2] = { { {0, 0}, {0, 1}, {0, 2}, {1, 2} }, { {0, 1}, {1, 1}, {2, 0}, {2, 1} }, { {0, 0}, {1, 0}, {1, 1}, {1, 2} }, { {0, 0}, {0, 1}, {1, 0}, {2, 0} }, }; byte j_shape[4][4][2] = { { {1, 0}, {1, 1}, {0, 2}, {1, 2} }, { {0, 0}, {1, 0}, {2, 0}, {2, 1} }, { {0, 0}, {1, 0}, {0, 1}, {0, 2} }, { {0, 0}, {0, 1}, {1, 1}, {2, 1} }, }; byte o_shape[1][4][2] = { { {0, 0}, {0, 1}, {1, 0}, {1, 1} } }; byte s_shape[2][4][2] = { { {0, 1}, {1, 0}, {1, 1}, {2, 0} }, { {0, 0}, {0, 1}, {1, 1}, {1, 2} } }; byte z_shape[2][4][2] = { { {0, 0}, {1, 0}, {1, 1}, {2, 1} }, { {1, 0}, {0, 1}, {1, 1}, {0, 2} } }; byte t_shape[4][4][2] = { { {0, 0}, {1, 0}, {2, 0}, {1, 1} }, { {0, 0}, {0, 1}, {1, 1}, {0, 2} }, { {1, 0}, {0, 1}, {1, 1}, {2, 1} }, { {1, 0}, {0, 1}, {1, 1}, {1, 2} } }; byte i_shape[2][4][2] = { { {0, 0}, {1, 0}, {2, 0}, {3, 0} }, { {0, 0}, {0, 1}, {0, 2}, {0, 3} } // TBD??? rotate at the center }; // All game shapes and their colors byte* all_shapes[7] = { l_shape[0][0], j_shape[0][0], o_shape[0][0], s_shape[0][0], z_shape[0][0], t_shape[0][0], i_shape[0][0] }; unsigned short colors[7] = { ORANGE, BLUE, YELLOW, GREEN, RED, MAGENTA, CYAN }; // how many rotated variations each shape has byte shapes[7] = { 4, 4, 1, 2, 2, 4, 2 }; // game progress int lines, level; // current shapes byte current; // tetris guidelines have all 7 shapes // selected in sequence to avoid // long runs without a shape byte next[7]; byte next_c; unsigned long lastInput, lastDrop; byte board[BOARD_HEIGHT][BOARD_WIDTH]; byte x, y, rot; Backup old; int newShape; unsigned long dropWait; void drawChar(byte ascii, unsigned poX, unsigned poY, unsigned size, unsigned short fgcolor) { if ((ascii < 32) || (ascii > 127)) ascii = '?' - 32; for (int i = 0; i < FONT_X; i++) { byte temp = simpleFont[ascii - 32][i]; for (byte f = 0; f < 8; f++) if ((temp >> f) & 1) box(poX + i * size, poY + f * size, size, size, fgcolor, 1); } } void drawString(char* string, unsigned poX, unsigned poY, unsigned size, unsigned short fgcolor) { while (*string) { drawChar(*string++, poX, poY, size, fgcolor); poX += FONT_SPACE * size; } } void drawCenteredString(char* string, unsigned poY, unsigned size, unsigned short fgcolor) { unsigned len = strlen(string) * FONT_SPACE * size; unsigned left = (LCD_WIDTH - len) / 2; drawString(string, left, poY, size, fgcolor); } void drawNumber(long long_num, unsigned poX, unsigned poY, unsigned size, unsigned short fgcolor) { char buf[12], *p = buf + sizeof buf; int neg = long_num < 0; unsigned long n = neg ? -(unsigned long)long_num : (unsigned long)long_num; *--p = '\0'; do { *--p = '0' + n % 10; n /= 10; } while (n); if (neg) *--p = '-'; drawString(p, poX, poY, size, fgcolor); } void bcackground(void) { // draw black-blue gradient background for (int i = 0; i < LCD_HEIGHT; i++) { int c = 31 - i * 31 / (LCD_HEIGHT - 1); if (i < BOARD_BOTTOM) { lineh(0, i, BOARD_LEFT - 1, c); lineh(BOARD_RIGHT, i, LCD_WIDTH - BOARD_RIGHT, c); } else { lineh(0, i, LCD_WIDTH, c); } } // draw the board left limit linev(BOARD_LEFT - 1, BOARD_TOP, BOARD_BOTTOM - BOARD_TOP, PIT_COLOR); // draw the board right limit linev(BOARD_RIGHT - 1, BOARD_TOP, BOARD_BOTTOM - BOARD_TOP, PIT_COLOR); // draw the board bottom limit lineh(BOARD_LEFT - 1, BOARD_BOTTOM - 1, BOARD_RIGHT - BOARD_LEFT + 1, PIT_COLOR); // draw the grid for (int i = BOARD_LEFT + BLOCK_SIZE - 1; i < BOARD_RIGHT - 1; i += BLOCK_SIZE) linev(i, BOARD_TOP, BOARD_BOTTOM - BOARD_TOP - 1, GRAY2); for (int i = BOARD_TOP + BLOCK_SIZE - 1; i < BOARD_BOTTOM - 1; i += BLOCK_SIZE) lineh(BOARD_LEFT, i, BOARD_RIGHT - BOARD_LEFT - 1, GRAY2); } void scoreBoard(void) { box(6, 3, 128, 50, BLACK, 1); drawString("Level", 8, 8, 2, YELLOW); drawString("Lines", 8, 32, 2, 0x3f); drawNumber(level, 74, 8, 2, YELLOW); drawNumber(lines, 74, 32, 2, 0x3f); box(5, 2, 130, 52, WHITE, 0); } void hint(void) { // draw next shape hint box box(30, 100, BLOCK_SIZE * 6, BLOCK_SIZE * 5, BLACK, 1); box(29, 99, BLOCK_SIZE * 6 + 1, BLOCK_SIZE * 5 + 1, WHITE, 0); byte* shape = all_shapes[next[next_c]]; for (int i = 0; i < 4; i++) { byte* block = shape + i * 2; boxb(30 + BLOCK_SIZE + block[0] * BLOCK_SIZE, 100 + BLOCK_SIZE + block[1] * BLOCK_SIZE, BLOCK_SIZE - 1, BLOCK_SIZE - 1, colors[next[next_c]]); } } void gameLoop(void) { box(0, 0, LCD_WIDTH, LCD_HEIGHT, BG_COLOR, 1); // initialize game logic newShape = 1; lines = 0; lastInput = 0; lastDrop = 0; dropWait = DROP_WAIT_INIT; level = 1; // clean board for (int i = 0; i < BOARD_WIDTH; i++) for (int j = 0; j < BOARD_HEIGHT; j++) board[j][i] = 0; // next shape randomizer(); bcackground(); scoreBoard(); do { // get clock unsigned long now = millis(); // display new shape if (newShape) { Joystick_waitForRelease(INPUT_WAIT_NEW_SHAPE); newShape = 0; // a new shape enters the game chooseNewShape(); // draw next shape hint box hint(); // check if new shape is placed over other shape(s) // on the board if (touches(0, 0, 0)) { // draw shape to screen draw(); // game over return; } // draw shape to screen draw(); } else { // check if enough time has passed since last time the shape // was moved down the board if (now - lastDrop > dropWait || Joystick_getY() > 0) { // update clock lastDrop = now; moveDown(); } } if (!newShape && now - lastInput > INPUT_WAIT_MOVE) { userInput(now); } } while (!quit); } void chooseNewShape(void) { current = next[next_c]; next_c++; if (next_c == 7) randomizer(); // new shape must be postioned at the middle of // the top of the board // with zero rotation rot = 0; y = 0; x = BOARD_WIDTH / 2 - 1; old.rot = rot; old.y = y; old.x = x; } void userInput(unsigned long now) { int jx = Joystick_getX(); if (jx < 0 && x > 0 && !touches(-1, 0, 0)) { x--; } else if (jx > 0 && x < BOARD_WIDTH && !touches(1, 0, 0)) { x++; } else if (Joystick_fire()) { while (!touches(0, 1, 0)) y++; } else if (now - lastInput > INPUT_WAIT_ROT) { if (Joystick_getY() < 0 && !touches(0, 0, 1)) { rot++; rot %= shapes[current]; } } else { return; } lastInput = now; draw(); } void moveDown(void) { // prepare to move down // check if board is clear bellow if (touches(0, 1, 0)) { // moving down touches another shape newShape = 1; // this shape wont move again // add it to the board byte* shape = all_shapes[current]; for (int i = 0; i < 4; i++) { byte* block = shape + (rot * 4 + i) * 2; board[block[1] + y][block[0] + x] = current + 1; } // check if lines were made score(); beep(1500, 25); } else { // move shape down y++; draw(); } } void draw(void) { byte* shape = all_shapes[current]; for (int i = 0; i < 4; i++) { byte* block = shape + (rot * 4 + i) * 2; boxb(BOARD_LEFT + block[0] * BLOCK_SIZE + BLOCK_SIZE * x, BOARD_TOP + block[1] * BLOCK_SIZE + BLOCK_SIZE * y, BLOCK_SIZE - 1, BLOCK_SIZE - 1, colors[current]); board[block[1] + y][block[0] + x] = 255; } // erase old for (int i = 0; i < 4; i++) { byte* block = shape + (old.rot * 4 + i) * 2; if (board[block[1] + old.y][block[0] + old.x] == 255) continue; boxb(BOARD_LEFT + block[0] * BLOCK_SIZE + BLOCK_SIZE * old.x, BOARD_TOP + block[1] * BLOCK_SIZE + BLOCK_SIZE * old.y, BLOCK_SIZE - 1, BLOCK_SIZE - 1, BG_COLOR); } for (int i = 0; i < 4; i++) { byte* block = shape + (rot * 4 + i) * 2; board[block[1] + y][block[0] + x] = 0; } old.x = x; old.y = y; old.rot = rot; } int touches(int xi, int yi, int roti) { byte* shape = all_shapes[current]; for (int i = 0; i < 4; i++) { byte* block = shape + (((rot + roti) % shapes[current]) * 4 + i) * 2; int x2 = x + block[0] + xi; int y2 = y + block[1] + yi; if (y2 == BOARD_HEIGHT || x2 == BOARD_WIDTH || board[y2][x2]) return 1; } return 0; } void score(void) { // we scan a max of 4 lines int ll = y + 3; // BUG!!! was uninitialized if (y + 3 >= BOARD_HEIGHT) ll = BOARD_HEIGHT - 1; // scan board from current position for (int l = y; l <= ll; l++) { // check if there's a complete line on the board int line = 1; for (int c = 0; c < BOARD_WIDTH; c++) { if (board[l][c] == 0) { line = 0; break; } } if (!line) { // move to next line continue; } beep(3000, 50); lines++; if (lines % 10 == 0) { level++; dropWait /= 2; } scoreBoard(); // move board down for (int row = l; row > 0; row --) { for (int c = 0; c < BOARD_WIDTH; c++) { byte v = board[row - 1][c]; board[row][c] = v; boxb(BOARD_LEFT + BLOCK_SIZE * c, BOARD_TOP + BLOCK_SIZE * row, BLOCK_SIZE - 1, BLOCK_SIZE - 1, v == 0 ? BLACK : colors[v - 1]); } } // clear top line for (int c = 0; c < BOARD_WIDTH; c++) board[0][c] = 0; box(BOARD_LEFT, 0, BOARD_RIGHT - BOARD_LEFT, BLOCK_SIZE, BLACK, 1); } delay(350); } // create a sequence of 7 random shapes void randomizer(void) { // randomize 7 shapes for (byte i = 0; i < 7; i ++) { int retry; byte shape; do { shape = rand() % 7; // check if already in sequence retry = 0; for (int j = 0; j < i; j++) { if (shape == next[j]) { retry = 1; break; } } } while (retry); next[i] = shape; } next_c = 0; } void drawPreGameScreen(void) { box(0, 0, LCD_WIDTH, LCD_HEIGHT, WHITE, 1); drawCenteredString("Tetris", 40, 8, BLUE); drawCenteredString("Move joystick to start", 110, 2, BLACK); drawCenteredString("http://vilaca.eu", 220, 2, PURPLE); } void gameOver(void) { box(32, LCD_HEIGHT / 2 - 24, LCD_WIDTH - 64, 48, BLACK, 1); drawCenteredString("Game Over", LCD_HEIGHT / 2 - 16, 4, WHITE); box(32, LCD_HEIGHT / 2 - 24, LCD_WIDTH - 64, 48, RED, 0); beep(600, 200); delay(300); beep(600, 200); delay(300); beep(200, 600); delay(1500); } unsigned char simpleFont[][8] = { {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, {0x00,0x00,0x5F,0x00,0x00,0x00,0x00,0x00}, {0x00,0x00,0x07,0x00,0x07,0x00,0x00,0x00}, {0x00,0x14,0x7F,0x14,0x7F,0x14,0x00,0x00}, {0x00,0x24,0x2A,0x7F,0x2A,0x12,0x00,0x00}, {0x00,0x23,0x13,0x08,0x64,0x62,0x00,0x00}, {0x00,0x36,0x49,0x55,0x22,0x50,0x00,0x00}, {0x00,0x00,0x05,0x03,0x00,0x00,0x00,0x00}, {0x00,0x1C,0x22,0x41,0x00,0x00,0x00,0x00}, {0x00,0x41,0x22,0x1C,0x00,0x00,0x00,0x00}, {0x00,0x08,0x2A,0x1C,0x2A,0x08,0x00,0x00}, {0x00,0x08,0x08,0x3E,0x08,0x08,0x00,0x00}, {0x00,0xA0,0x60,0x00,0x00,0x00,0x00,0x00}, {0x00,0x08,0x08,0x08,0x08,0x08,0x00,0x00}, {0x00,0x60,0x60,0x00,0x00,0x00,0x00,0x00}, {0x00,0x20,0x10,0x08,0x04,0x02,0x00,0x00}, {0x00,0x3E,0x51,0x49,0x45,0x3E,0x00,0x00}, {0x00,0x00,0x42,0x7F,0x40,0x00,0x00,0x00}, {0x00,0x62,0x51,0x49,0x49,0x46,0x00,0x00}, {0x00,0x22,0x41,0x49,0x49,0x36,0x00,0x00}, {0x00,0x18,0x14,0x12,0x7F,0x10,0x00,0x00}, {0x00,0x27,0x45,0x45,0x45,0x39,0x00,0x00}, {0x00,0x3C,0x4A,0x49,0x49,0x30,0x00,0x00}, {0x00,0x01,0x71,0x09,0x05,0x03,0x00,0x00}, {0x00,0x36,0x49,0x49,0x49,0x36,0x00,0x00}, {0x00,0x06,0x49,0x49,0x29,0x1E,0x00,0x00}, {0x00,0x00,0x36,0x36,0x00,0x00,0x00,0x00}, {0x00,0x00,0xAC,0x6C,0x00,0x00,0x00,0x00}, {0x00,0x08,0x14,0x22,0x41,0x00,0x00,0x00}, {0x00,0x14,0x14,0x14,0x14,0x14,0x00,0x00}, {0x00,0x41,0x22,0x14,0x08,0x00,0x00,0x00}, {0x00,0x02,0x01,0x51,0x09,0x06,0x00,0x00}, {0x00,0x32,0x49,0x79,0x41,0x3E,0x00,0x00}, {0x00,0x7E,0x09,0x09,0x09,0x7E,0x00,0x00}, {0x00,0x7F,0x49,0x49,0x49,0x36,0x00,0x00}, {0x00,0x3E,0x41,0x41,0x41,0x22,0x00,0x00}, {0x00,0x7F,0x41,0x41,0x22,0x1C,0x00,0x00}, {0x00,0x7F,0x49,0x49,0x49,0x41,0x00,0x00}, {0x00,0x7F,0x09,0x09,0x09,0x01,0x00,0x00}, {0x00,0x3E,0x41,0x41,0x51,0x72,0x00,0x00}, {0x00,0x7F,0x08,0x08,0x08,0x7F,0x00,0x00}, {0x00,0x41,0x7F,0x41,0x00,0x00,0x00,0x00}, {0x00,0x20,0x40,0x41,0x3F,0x01,0x00,0x00}, {0x00,0x7F,0x08,0x14,0x22,0x41,0x00,0x00}, {0x00,0x7F,0x40,0x40,0x40,0x40,0x00,0x00}, {0x00,0x7F,0x02,0x0C,0x02,0x7F,0x00,0x00}, {0x00,0x7F,0x04,0x08,0x10,0x7F,0x00,0x00}, {0x00,0x3E,0x41,0x41,0x41,0x3E,0x00,0x00}, {0x00,0x7F,0x09,0x09,0x09,0x06,0x00,0x00}, {0x00,0x3E,0x41,0x51,0x21,0x5E,0x00,0x00}, {0x00,0x7F,0x09,0x19,0x29,0x46,0x00,0x00}, {0x00,0x26,0x49,0x49,0x49,0x32,0x00,0x00}, {0x00,0x01,0x01,0x7F,0x01,0x01,0x00,0x00}, {0x00,0x3F,0x40,0x40,0x40,0x3F,0x00,0x00}, {0x00,0x1F,0x20,0x40,0x20,0x1F,0x00,0x00}, {0x00,0x3F,0x40,0x38,0x40,0x3F,0x00,0x00}, {0x00,0x63,0x14,0x08,0x14,0x63,0x00,0x00}, {0x00,0x03,0x04,0x78,0x04,0x03,0x00,0x00}, {0x00,0x61,0x51,0x49,0x45,0x43,0x00,0x00}, {0x00,0x7F,0x41,0x41,0x00,0x00,0x00,0x00}, {0x00,0x02,0x04,0x08,0x10,0x20,0x00,0x00}, {0x00,0x41,0x41,0x7F,0x00,0x00,0x00,0x00}, {0x00,0x04,0x02,0x01,0x02,0x04,0x00,0x00}, {0x00,0x80,0x80,0x80,0x80,0x80,0x00,0x00}, {0x00,0x01,0x02,0x04,0x00,0x00,0x00,0x00}, {0x00,0x20,0x54,0x54,0x54,0x78,0x00,0x00}, {0x00,0x7F,0x48,0x44,0x44,0x38,0x00,0x00}, {0x00,0x38,0x44,0x44,0x28,0x00,0x00,0x00}, {0x00,0x38,0x44,0x44,0x48,0x7F,0x00,0x00}, {0x00,0x38,0x54,0x54,0x54,0x18,0x00,0x00}, {0x00,0x08,0x7E,0x09,0x02,0x00,0x00,0x00}, {0x00,0x18,0xA4,0xA4,0xA4,0x7C,0x00,0x00}, {0x00,0x7F,0x08,0x04,0x04,0x78,0x00,0x00}, {0x00,0x00,0x7D,0x00,0x00,0x00,0x00,0x00}, {0x00,0x80,0x84,0x7D,0x00,0x00,0x00,0x00}, {0x00,0x7F,0x10,0x28,0x44,0x00,0x00,0x00}, {0x00,0x41,0x7F,0x40,0x00,0x00,0x00,0x00}, {0x00,0x7C,0x04,0x18,0x04,0x78,0x00,0x00}, {0x00,0x7C,0x08,0x04,0x7C,0x00,0x00,0x00}, {0x00,0x38,0x44,0x44,0x38,0x00,0x00,0x00}, {0x00,0xFC,0x24,0x24,0x18,0x00,0x00,0x00}, {0x00,0x18,0x24,0x24,0xFC,0x00,0x00,0x00}, {0x00,0x00,0x7C,0x08,0x04,0x00,0x00,0x00}, {0x00,0x48,0x54,0x54,0x24,0x00,0x00,0x00}, {0x00,0x04,0x7F,0x44,0x00,0x00,0x00,0x00}, {0x00,0x3C,0x40,0x40,0x7C,0x00,0x00,0x00}, {0x00,0x1C,0x20,0x40,0x20,0x1C,0x00,0x00}, {0x00,0x3C,0x40,0x30,0x40,0x3C,0x00,0x00}, {0x00,0x44,0x28,0x10,0x28,0x44,0x00,0x00}, {0x00,0x1C,0xA0,0xA0,0x7C,0x00,0x00,0x00}, {0x00,0x44,0x64,0x54,0x4C,0x44,0x00,0x00}, {0x00,0x08,0x36,0x41,0x00,0x00,0x00,0x00}, {0x00,0x00,0x7F,0x00,0x00,0x00,0x00,0x00}, {0x00,0x41,0x36,0x08,0x00,0x00,0x00,0x00}, {0x00,0x02,0x01,0x01,0x02,0x01,0x00,0x00}, {0x00,0x02,0x05,0x05,0x02,0x00,0x00,0x00} }; int main(void) { // get TFT display handle if ((fd = open("/dev/tft0", O_RDWR)) < 0) { perror("/dev/tft0"); return 1; } // get joystick's x ADC handle if ((fdx = open("/dev/adc0", O_RDWR)) < 0) { perror("/dev/adc0"); return 1; } // get joystick's y ADC handle if ((fdy = open("/dev/adc1", O_RDWR)) < 0) { perror("/dev/adc1"); return 1; } srand(time(NULL)); drawPreGameScreen(); while (!Joystick_fire() && !Joystick_getY() && !Joystick_getX()); gameLoop(); gameOver(); while (!Joystick_fire() && !Joystick_getY() && !Joystick_getX()); box(0, 0, LCD_WIDTH, LCD_HEIGHT, BLACK, 1); } ================================================ FILE: share/examples/lex/Makefile ================================================ # Lex examples from the source tree: # awk, lex manpage example, cpp, and ccom. LEX= lex LFLAGS= -v # These files require at least 96Kbytes of User RAM. SRCS= awk.lx.l example.l scanner.l # These files require at least 120Kbytes of User RAM. #SRCS= scan.l all: -@for src in ${SRCS} ; do \ echo "Generating from: $$src" ; \ ${LEX} ${LFLAGS} $$src ; \ done clean: rm -f a.out [Ee]rrs *.core y.tab.[ch] lex.yy.c ================================================ FILE: share/examples/lex/awk.lx.l ================================================ /* awk.lx.l 4.3 84/12/08 */ %Start A str chc sc reg comment %{ #include "awk.h" #include "awk.def.h" #define YY_NO_INPUT /* defeat lex */ extern int yylval; extern int mustfld; int lineno = 1; #define CADD cbuf[clen++]=yytext[0]; if(clen>=CBUFLEN-1) {yyerror("string too long", cbuf); BEGIN A;} #define CBUFLEN 150 char cbuf[CBUFLEN]; int clen, cflag; %} A [a-zA-Z_] B [a-zA-Z0-9_] D [0-9] WS [ \t] %% /* witchcraft */ /* switch (yybgin-yysvec-1) { case 0: BEGIN A; break; case sc: BEGIN A; return('}'); } */ ^\n lineno++; ^{WS}*#.*\n lineno++; /* strip comment lines */ {WS} ; "\\"\n lineno++; "||" return(BOR); BEGIN return(XBEGIN); END return(XEND); PROGEND return(EOF); "&&" return(AND); "!" return(NOT); "!=" { yylval = NE; return(RELOP); } "~" { yylval = MATCH; return(MATCHOP); } "!~" { yylval = NOTMATCH; return(MATCHOP); } "<" { yylval = LT; return(RELOP); } "<=" { yylval = LE; return(RELOP); } "==" { yylval = EQ; return(RELOP); } ">=" { yylval = GE; return(RELOP); } ">" { yylval = GT; return(RELOP); } ">>" { yylval = APPEND; return(RELOP); } "++" { yylval = INCR; return(INCR); } "--" { yylval = DECR; return(DECR); } "+=" { yylval = ADDEQ; return(ASGNOP); } "-=" { yylval = SUBEQ; return(ASGNOP); } "*=" { yylval = MULTEQ; return(ASGNOP); } "/=" { yylval = DIVEQ; return(ASGNOP); } "%=" { yylval = MODEQ; return(ASGNOP); } "=" { yylval = ASSIGN; return(ASGNOP); } "$"{D}+ { if (atoi(yytext+1)==0) { yylval = (hack)lookup("$record", symtab, 0); return(STRING); } else { yylval = fieldadr(atoi(yytext+1)); return(FIELD); } } "$"{WS}* { return(INDIRECT); } NF { mustfld=1; yylval = (hack)setsymtab(yytext, EMPTY, 0.0, NUM, symtab); return(VAR); } ({D}+("."?){D}*|"."{D}+)((e|E)("+"|-)?{D}+)? { yylval = (hack)setsymtab(yytext, EMPTY, atof(yytext), CON|NUM, symtab); return(NUMBER); } "}"{WS}*\n { BEGIN sc; lineno++; return(';'); } "}" { BEGIN sc; return(';'); } ;\n { lineno++; return(';'); } \n { lineno++; return(NL); } while return(WHILE); for return(FOR); if return(IF); else return(ELSE); next return(NEXT); exit return(EXIT); break return(BREAK); continue return(CONTINUE); print { yylval = PRINT; return(PRINT); } printf { yylval = PRINTF; return(PRINTF); } sprintf { yylval = SPRINTF; return(SPRINTF); } split { yylval = SPLIT; return(SPLIT); } substr return(SUBSTR); index return(INDEX); in return(IN); getline return(GETLINE); length { yylval = FLENGTH; return(FNCN); } log { yylval = FLOG; return(FNCN); } int { yylval = FINT; return(FNCN); } exp { yylval = FEXP; return(FNCN); } sqrt { yylval = FSQRT; return(FNCN); } {A}{B}* { yylval = (hack)setsymtab(yytext, tostring(""), 0.0, STR|NUM, symtab); return(VAR); } \" { BEGIN str; clen=0; } # { BEGIN comment; } \n { BEGIN A; lineno++; return(NL); } . ; . { yylval = yytext[0]; return(yytext[0]); } "[" { BEGIN chc; clen=0; cflag=0; } "[^" { BEGIN chc; clen=0; cflag=1; } "?" return(QUEST); "+" return(PLUS); "*" return(STAR); "|" return(OR); "." return(DOT); "(" return('('); ")" return(')'); "^" return('^'); "$" return('$'); \\{D}{D}{D} { sscanf(yytext+1, "%o", &yylval); return(CHAR); } \\. { if (yytext[1]=='n') yylval = '\n'; else if (yytext[1] == 't') yylval = '\t'; else yylval = yytext[1]; return(CHAR); } "/" { BEGIN A; unput('/'); } \n { yyerror("newline in regular expression"); lineno++; BEGIN A; } . { yylval = yytext[0]; return(CHAR); } \" { char *s; BEGIN A; cbuf[clen]=0; s = tostring(cbuf); cbuf[clen] = ' '; cbuf[++clen] = 0; yylval = (hack)setsymtab(cbuf, s, 0.0, CON|STR, symtab); return(STRING); } \n { yyerror("newline in string"); lineno++; BEGIN A; } "\\\"" { cbuf[clen++]='"'; } "\\"n { cbuf[clen++]='\n'; } "\\"t { cbuf[clen++]='\t'; } "\\\\" { cbuf[clen++]='\\'; } . { CADD; } "\\""]" { cbuf[clen++]=']'; } "]" { BEGIN reg; cbuf[clen]=0; yylval = (hack)tostring(cbuf); if (cflag==0) { return(CCL); } else { return(NCCL); } } \n { yyerror("newline in character class"); lineno++; BEGIN A; } . { CADD; } %% input() { register c; extern char *lexprog; if (yyin == NULL) c = *lexprog++; else c = getc(yyin); if (c == '\n') yylineno++; else if (c == EOF) c = 0; return(c); } startreg() { BEGIN reg; } ================================================ FILE: share/examples/lex/example.l ================================================ %% [A-Z] putchar(yytext[0]+'a'-'A'); [ ]+$ ; [ ]+ putchar(' '); ================================================ FILE: share/examples/lex/scan.l ================================================ %{ /* * Copyright (c) 2002 Anders Magnusson. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifdef CROSS # include # include #else # include # include #endif #include #include #include #include "pass1.h" #include "cgram.h" %} D [0-9] L [a-zA-Z_] H [a-fA-F0-9] E [Ee][+-]?{D}+ P [Pp][+-]?{D}+ FS (f|F|l|L)?i? IS (u|U|l|L)* UL ({L}|\\u{H}{H}{H}{H}|\\U{H}{H}{H}{H}{H}{H}{H}{H}) %{ static NODE *cvtdig(int radix); static NODE *charcon(void); static NODE *wcharcon(void); static void control(int); static void pragma(void); int notype, parbal, inattr, parlvl; static int resw(TWORD, int); #define CPP_IDENT 2 #define CPP_LINE 3 #define CPP_HASH 4 #ifdef STABS # define STABS_LINE(x) if (gflag && cftnsp) stabs_line(x) #else # define STABS_LINE(x) #endif #if defined(FLEX_SCANNER) && YY_FLEX_SUBMINOR_VERSION == 31 /* Hack to avoid unnecessary warnings */ FILE *yyget_in (void); FILE *yyget_out (void); int yyget_leng (void); char *yyget_text (void); void yyset_in (FILE *); void yyset_out (FILE *); int yyget_debug (void); void yyset_debug (int); int yylex_destroy (void); extern int yyget_lineno (void); extern void yyset_lineno (int); #endif %} %% "__func__" { if (cftnsp == NULL) uerror("__func__ outside function"); yylval.strp = cftnsp->sname; /* XXX - not C99 */ return(C_STRING); } "asm" { return(C_ASM); } "auto" { return resw(AUTO, C_CLASS); } "_Bool" { return resw(BOOL, C_TYPE); } "break" { return(C_BREAK); } "case" { return(C_CASE); } "char" { return resw(CHAR, C_TYPE); } "_Complex" { return resw(COMPLEX, C_TYPE); } "const" { return resw(CON, C_QUALIFIER); } "continue" { return(C_CONTINUE); } "default" { return(C_DEFAULT); } "do" { return(C_DO); } "double" { return resw(DOUBLE, C_TYPE); } "else" { return(C_ELSE); } "enum" { notype=1; return(C_ENUM); } "extern" { return resw(EXTERN, C_CLASS); } "float" { return resw(FLOAT, C_TYPE); } "for" { return(C_FOR); } "goto" { notype=1; return(C_GOTO); } "if" { return(C_IF); } "_Imaginary" { return resw(IMAG, C_TYPE); } "inline" { return(C_FUNSPEC); } "int" { return resw(INT, C_TYPE); } "long" { return resw(LONG, C_TYPE); } "register" { return resw(REGISTER, C_CLASS); } "restrict" { ; /* just ignore */ } "return" { return(C_RETURN); } "short" { return resw(SHORT, C_TYPE); } "signed" { return resw(SIGNED, C_TYPE); } "sizeof" { return(C_SIZEOF); } "static" { return resw(STATIC, C_CLASS); } "struct" { yylval.intval = STNAME; notype=1; return(C_STRUCT); } "switch" { return(C_SWITCH); } "typedef" { return resw(TYPEDEF, C_CLASS); } "union" { yylval.intval = UNAME; notype=1; return(C_STRUCT); } "unsigned" { return resw(UNSIGNED, C_TYPE); } "void" { return resw(VOID, C_TYPE); } "volatile" { return resw(VOL, C_QUALIFIER); } "while" { return(C_WHILE); } {UL}({UL}|{D})* { struct symtab *s; int i = 0; yylval.strp = addname(yytext); #ifdef GCC_COMPAT if ((i = gcc_keyword(yylval.strp, &yylval.nodep)) > 0) return i; #endif if (i == 0) { if (notype) return(C_NAME); s = lookup(yylval.strp, SNOCREAT); return s && s->sclass == TYPEDEF ? notype=1, C_TYPENAME : C_NAME; } } 0[xX]{H}+{IS}? { yylval.nodep = cvtdig(16); return(C_ICON); } 0{D}+{IS}? { yylval.nodep = cvtdig(8); return(C_ICON); } {D}+{IS}? { yylval.nodep = cvtdig(10); return(C_ICON); } L'(\\.|[^\\'])+' { yylval.nodep = wcharcon(); return(C_ICON); } '(\\.|[^\\'])+' { yylval.nodep = charcon(); return(C_ICON); } {D}+{E}{FS}? { yylval.nodep = floatcon(yytext); return(C_FCON); } {D}*"."{D}+({E})?{FS}? { yylval.nodep = floatcon(yytext); return(C_FCON); } {D}+"."{D}*({E})?{FS}? { yylval.nodep = floatcon(yytext); return(C_FCON); } 0[xX]{H}*"."{H}+{P}{FS}? { yylval.nodep = fhexcon(yytext); return(C_FCON); } 0[xX]{H}+"."{P}{FS}? { yylval.nodep = fhexcon(yytext); return(C_FCON); } 0[xX]{H}+{P}{FS}? { yylval.nodep = fhexcon(yytext); return(C_FCON); } L?\"(\\.|[^\\"])*\" { yylval.strp = yytext; return C_STRING; } "..." { return(C_ELLIPSIS); } ">>=" { yylval.intval = RSEQ; return(C_ASOP); } "<<=" { yylval.intval = LSEQ; return(C_ASOP); } "+=" { yylval.intval = PLUSEQ; return(C_ASOP); } "-=" { yylval.intval = MINUSEQ; return(C_ASOP); } "*=" { yylval.intval = MULEQ; return(C_ASOP); } "/=" { yylval.intval = DIVEQ; return(C_ASOP); } "%=" { yylval.intval = MODEQ; return(C_ASOP); } "&=" { yylval.intval = ANDEQ; return(C_ASOP); } "^=" { yylval.intval = EREQ; return(C_ASOP); } "|=" { yylval.intval = OREQ; return(C_ASOP); } ">>" { yylval.intval = RS; return(C_SHIFTOP); } "<<" { yylval.intval = LS; return(C_SHIFTOP); } "++" { yylval.intval = INCR; return(C_INCOP); } "--" { yylval.intval = DECR; return(C_INCOP); } "->" { yylval.intval = STREF; return(C_STROP); } "&&" { yylval.intval = ANDAND; return(C_ANDAND); } "||" { yylval.intval = OROR; return(C_OROR); } "<=" { yylval.intval = LE; return(C_RELOP); } ">=" { yylval.intval = GE; return(C_RELOP); } "==" { yylval.intval = EQ; return(C_EQUOP); } "!=" { yylval.intval = NE; return(C_EQUOP); } ";" { notype = 0; return(';'); } ("{"|"<%") { notype = 0; return('{'); } ("}"|"%>") { if (rpole) notype = 1; return('}'); } "," { if (parbal) notype = 0; return(','); } ":" { return(':'); } "=" { return('='); } "(" { parbal++; notype = 0; return('('); } ")" { parbal--; if (parbal==0) { notype = 0; } if (inattr && parlvl == parbal) inattr = 0; return(')'); } ("["|"<:") { return('['); } ("]"|":>") { return(']'); } "." { yylval.intval = DOT; return(C_STROP); } "&" { return('&'); } "!" { yylval.intval = NOT; return(C_UNOP); } "~" { yylval.intval = COMPL; return(C_UNOP); } "-" { return('-'); } "+" { return('+'); } "*" { if (parbal && notype == 0) notype = 1; return('*'); } "/" { yylval.intval = DIV; return(C_DIVOP); } "%" { yylval.intval = MOD; return(C_DIVOP); } "<" { yylval.intval = LT; return(C_RELOP); } ">" { yylval.intval = GT; return(C_RELOP); } "^" { return('^'); } "|" { return('|'); } "?" { return('?'); } ^#pragma[ \t].* { pragma(); } ^#ident[ \t].* { control(CPP_IDENT); } ^#line[ \t].* { control(CPP_LINE); } ^#.* { control(CPP_HASH); } [ \t\v\f] { } "\n" { ++lineno; STABS_LINE(lineno); } . { /* ignore bad characters */ } %% int lineno; char *ftitle = ""; int yywrap(void) { if (0) unput(0); /* quiet gcc */ return(1); } int resw(TWORD t, int rv) { if (inattr) { yylval.strp = addname(yytext); return C_NAME; } switch (rv) { case C_CLASS: yylval.nodep = block(CLASS, NIL, NIL, t, 0, 0); return rv; case C_QUALIFIER: yylval.nodep = block(QUALIFIER, NIL, NIL, 0, 0, 0); yylval.nodep->n_qual = t; return rv; case C_TYPE: yylval.nodep = mkty(t, 0, MKAP(t)); notype=1; return(rv); default: cerror("resw"); } return 0; } #ifndef SOFTFLOAT /* * XXX floatcon() and fhexcon() should be in support libraries for * the target floating point. */ static NODE * f2(char *str) { TWORD tw; NODE *p; long double dc; char *eptr; int imag = 0; #ifdef HAVE_STRTOLD dc = strtold(str, &eptr); /* XXX - avoid strtod() */ #else dc = strtod(str, &eptr); /* XXX - avoid strtod() */ #endif tw = DOUBLE; for (; *eptr; eptr++) { switch (*eptr) { case 'f': case 'F': tw = FLOAT; dc = (float)dc; break; case 'l': case 'L': tw = LDOUBLE; break; case 'i': case 'I': imag = 1; break; } } if (tw == DOUBLE) dc = (double)dc; #ifndef NO_COMPLEX if (imag) tw += (FIMAG-FLOAT); #endif p = block(FCON, NIL, NIL, tw, 0, MKAP(tw)); p->n_dcon = dc; return p; } NODE * floatcon(char *s) { return f2(s); } static int h2n(int ch) { if (ch >= '0' && ch <= '9') return ch - '0'; if (ch >= 'a' && ch <= 'f') return ch - 'a' + 10; return ch - 'A' + 10; } NODE * fhexcon(char *c) { char buf[500]; unsigned long long num1, num2; /* XXX - convert it to a decimal float number and use strtod */ c+= 2; /* skip 0x */ for (num1 = 0; *c != '.' && *c != 'p' && *c != 'P'; c++) num1 = (num1 << 4) | h2n(*c); if (*c != '.' && *c != 'p' && *c != 'P') cerror("fhexcon"); num2 = 0; if (*c == '.') { c++; for (; *c != 'p' && *c != 'P'; c++) num2 = (num2 << 4) | h2n(*c); } if (*c != 'P' && *c != 'p') cerror("fhexcon2"); c++; snprintf(buf, sizeof(buf), "%llu.%lluE%s", num1, num2, c); return f2(buf); } #endif unsigned int esccon(char **sptr) { char *wr = *sptr; char *owr; char c; unsigned int val; int wsz = 4, esccon_warn = 1; switch (*wr++) { case 'a': val = '\a'; break; case 'b': val = '\b'; break; case 'f': val = '\f'; break; case 'n': val = '\n'; break; case 'r': val = '\r'; break; case 't': val = '\t'; break; case 'v': val = '\v'; break; case '\"': val = '\"'; break; case 'x': val = strtoul(wr, &wr, 16); break; /* ISO/IEC 9099:1999 (E) 6.4.3 */ case 'U'|(char)0x80: esccon_warn = 0; /* FALLTHROUGH */ case 'U': wsz = 8; /* FALLTHROUGH */ case 'u': owr = wr; while (wr < (owr + wsz)) if (*wr == '\0') break; else ++wr; if (wr != (owr + wsz)) { /* incomplete */ val = strtoul(owr, &wr, 16); } else { c = owr[wsz]; owr[wsz] = '\0'; /* prevent it from reading too much */ val = strtoul(owr, &wr, 16); owr[wsz] = c; } if (wr != (owr + wsz)) werror("incomplete universal character name"); if (wsz == 4) val &= 0xFFFF; if (esccon_warn && ((val >= 0xD800 && val <= 0xDFFF) || (val < 0xA0 && val != 0x24 && val != 0x40 && val != 0x60))) werror("invalid universal character name %04X", val); break; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': val = wr[-1] - '0'; if (*wr >= '0' && *wr <= '7') { val = (val << 3) + (*wr++ - '0'); if (*wr >= '0' && *wr <= '7') val = (val << 3) + (*wr++ - '0'); } break; default: val = wr[-1]; } *sptr = wr; return val; } NODE * cvtdig(int radix) { NODE *p; TWORD ntype; unsigned long long v; char *ch = yytext; int n, numl, numu; if (radix == 16) ch += 2; /* Skip 0x */ v = 0; while ((*ch >= '0' && *ch <= '9') || (*ch >= 'a' && *ch <= 'f') || (*ch >= 'A' && *ch <= 'F')) { v *= radix; n = *ch; n = (n <= '9' ? n - '0' : (n > 'F' ? n - 'a' : n - 'A') + 10); ch++; v += n; } /* Parse trailing chars */ ntype = INT; numl = numu = 0; for (n = 0; n < 3; n++) { if (*ch == 0) break; if ((*ch == 'l' || *ch == 'L') && numl < 2) ntype+=2, numl++; else if ((*ch == 'u' || *ch == 'U') && numu < 1) ntype = ENUNSIGN(ntype), numu++; else break; ch++; } if (*ch) uerror("constant has too many '%c'", *ch); if (ntype == INT) { /* v contains a number. Get type correct */ if (v > MAX_LONGLONG && radix != 10) ntype = ULONGLONG; else if (v > MAX_ULONG) ntype = LONGLONG; else if (v > MAX_LONG && radix != 10) ntype = ULONG; else if (v > MAX_UNSIGNED) ntype = LONG; else if (v > MAX_INT && radix != 10) ntype = UNSIGNED; } ntype = ctype(ntype); p = xbcon(v, NULL, ntype); ASGLVAL(p->n_slval, v); return p; } /* * Convert a character constant to an integer. */ NODE * charcon(void) { int lastcon = 0; int val, i = 0; char *pp = yytext; if (*pp == 'L') pp++; pp++; while (*pp != '\'') { if (*pp++ == '\\') { val = esccon(&pp); } else val = pp[-1]; makecc(val, i); i++; } if (i == 0) uerror("empty character constant"); if (i > (SZINT/SZCHAR) || (i>1)) werror("too many characters in character constant"); return bcon(lastcon); } NODE * wcharcon(void) { unsigned int lastcon = 0; unsigned int val, i = 0; char *pp = yytext; if (*pp == 'L') pp++; pp++; while (*pp != '\'') { if (*pp++ == '\\') { val = esccon(&pp); } else val = pp[-1]; #if WCHAR_SIZE == 2 lastcon = (lastcon << 16) | (val & 0xFFFF); #else lastcon = val; #endif i++; } if (i == 0) uerror("empty wide character constant"); if (i > 1) werror("too many characters in wide character constant"); return xbcon(lastcon, NULL, ctype(UNSIGNED)); } void control(int t) { char *wr = yytext; char *eptr; int val; wr++; /* Skip initial '#' */ switch (t) { case CPP_IDENT: return; /* Just skip these for now. */ case CPP_LINE: wr += 4; /* FALLTHROUGH */ case CPP_HASH: val = strtol(wr, &eptr, 10); if (wr == eptr) /* Illegal string */ goto bad; wr = eptr; lineno = val - 1; while (*wr && *wr != '\"') wr++; if (*wr == 0) return; if (*wr++ != '\"') goto bad; eptr = wr; while (*wr && *wr != '\"') wr++; if (*wr != '\"') goto bad; *wr = 0; ftitle = addstring(eptr); #ifdef STABS if (gflag) stabs_file(ftitle); #endif } return; bad: werror("%s: illegal control", yytext); } /* * split a pragma string in parts. */ static char ** splitup(char *str) { char *s, **ary; int i; /* count ws. at least needed array size, add 2 to terminate */ for (i = 2, s = str; *s; s++) if (*s == ' ' || *s == '\t' || *s == '(' || *s == ')' || *s == ',') i++; ary = tmpalloc(sizeof(char *)*i); for (i = 0, s = strtok(str, " \t(,)"); s; s = strtok(NULL, " \t(,)")) ary[i++] = s; ary[i] = NULL; return ary; } int pragma_allpacked; int pragma_packed, pragma_aligned; char *pragma_renamed; /* * got a full pragma line. Split it up here. */ static void pragma() { char **ary; ary = splitup(yytext); if (ary[1] == NULL) goto bad; if (strcmp(ary[1], "pack") == 0) { pragma_allpacked = ary[2] ? atoi(ary[2]) : 0; } else if (strcmp(ary[1], "packed") == 0) { pragma_packed = ary[2] ? atoi(ary[2]) : 1; } else if (strcmp(ary[1], "aligned") == 0) { pragma_aligned = ary[2] ? atoi(ary[2]) : 1; } else if (strcmp(ary[1], "rename") == 0) { pragma_renamed = newstring(ary[2], strlen(ary[2])); } else if (strcmp(ary[1], "GCC") == 0) { /* pragma_gcc(); Ignored for now */ } else if (strcmp(ary[1], "weak") == 0) { struct symtab *sp = lookup(addname(ary[2]), SNORMAL); sp->sap = attr_add(sp->sap, gcc_attr_parse(bdty(NAME, "weak"))); if (ary[3]) uerror("too many arguments to #pragma weak"); } else if (mypragma(ary)) { return; } else { bad: if (Wunknown_pragmas) werror("unknown pragma"); } } void cunput(char c) { unput(c); } ================================================ FILE: share/examples/lex/scanner.l ================================================ %{ /* $Id: scanner.l,v 1.49 2009/02/14 09:23:55 ragge Exp $ */ /* * Copyright (c) 2004 Anders Magnusson. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "config.h" #include #include #include #ifdef HAVE_UNISTD_H #include #endif #include #include #include "compat.h" #include "cpp.h" #include "y.tab.h" %} %{ static void cvtdig(int rad); static int charcon(usch *); static void elsestmt(void); static void ifdefstmt(void); static void ifndefstmt(void); static void endifstmt(void); static void ifstmt(void); static void cpperror(void); static void pragmastmt(void); static void undefstmt(void); static void cpperror(void); static void elifstmt(void); static void storepb(void); static void badop(const char *); void include(void); void define(void); extern int yyget_lineno (void); extern void yyset_lineno (int); static int inch(void); static int scale, gotdef, contr; int inif; #ifdef FLEX_SCANNER /* should be set by autoconf instead */ static int yyinput(char *b, int m) { int c, i; for (i = 0; i < m; i++) { if ((c = inch()) < 0) break; *b++ = c; if (c == '\n') { i++; break; } } return i; } #undef YY_INPUT #undef YY_BUF_SIZE #define YY_BUF_SIZE (8*65536) #define YY_INPUT(b,r,m) (r = yyinput(b, m)) #ifdef HAVE_CPP_VARARG_MACRO_GCC #define fprintf(x, ...) error(__VA_ARGS__) #endif #define ECHO putstr((usch *)yytext) #undef fileno #define fileno(x) 0 #if YY_FLEX_SUBMINOR_VERSION >= 31 /* Hack to avoid unnecessary warnings */ FILE *yyget_in (void); FILE *yyget_out (void); int yyget_leng (void); char *yyget_text (void); void yyset_in (FILE * in_str ); void yyset_out (FILE * out_str ); int yyget_debug (void); void yyset_debug (int bdebug ); int yylex_destroy (void); #endif #else /* Assume lex here */ #undef input #undef unput #define input() inch() #define unput(ch) unch(ch) #endif #define PRTOUT(x) if (YYSTATE || slow) return x; if (!flslvl) putstr((usch *)yytext); /* protection against recursion in #include */ #define MAX_INCLEVEL 100 static int inclevel; %} D [0-9] L [a-zA-Z_] H [a-fA-F0-9] E [Ee][+-]?{D}+ FS (f|F|l|L) IS (u|U|l|L)* WS [\t ] %s IFR CONTR DEF COMMENT %% "\n" { int os = YYSTATE; if (os != IFR) BEGIN 0; ifiles->lineno++; if (flslvl == 0) { if (ifiles->lineno == 1) prtline(); else putch('\n'); } if ((os != 0 || slow) && !contr) return '\n'; contr = 0; } "\r" { ; /* Ignore CR's */ } "++" { badop("++"); } "--" { badop("--"); } "==" { return EQ; } "!=" { return NE; } "<=" { return LE; } "<<" { return LS; } ">>" { return RS; } ">=" { return GE; } "||" { return OROR; } "&&" { return ANDAND; } "defined" { int p, c; gotdef = 1; if ((p = c = yylex()) == '(') c = yylex(); if (c != IDENT || (p != IDENT && p != '(')) error("syntax error"); if (p == '(' && yylex() != ')') error("syntax error"); return NUMBER; } {WS}+ { ; } {L}({L}|{D})* { yylval.node.op = NUMBER; if (gotdef) { yylval.node.nd_val = lookup((usch *)yytext, FIND) != 0; gotdef = 0; return IDENT; } yylval.node.nd_val = 0; return NUMBER; } [0-9][0-9]* { if (slow && !YYSTATE) return IDENT; scale = yytext[0] == '0' ? 8 : 10; goto num; } 0[xX]{H}+{IS}? { scale = 16; num: if (YYSTATE == IFR) cvtdig(scale); PRTOUT(NUMBER); } 0{D}+{IS}? { scale = 8; goto num; } {D}+{IS}? { scale = 10; goto num; } '(\\.|[^\\'])+' { if (YYSTATE || slow) { yylval.node.op = NUMBER; yylval.node.nd_val = charcon((usch *)yytext); return (NUMBER); } if (tflag) yyless(1); if (!flslvl) putstr((usch *)yytext); } . { return yytext[0]; } {D}+{E}{FS}? { PRTOUT(FPOINT); } {D}*"."{D}+({E})?{FS}? { PRTOUT(FPOINT); } {D}+"."{D}*({E})?{FS}? { PRTOUT(FPOINT); } ^{WS}*#{WS}* { extern int inmac; if (inmac) error("preprocessor directive found " "while expanding macro"); contr = 1; BEGIN CONTR; } {WS}+ { PRTOUT(WSPACE); } "ifndef" { contr = 0; ifndefstmt(); } "ifdef" { contr = 0; ifdefstmt(); } "if" { contr = 0; storepb(); BEGIN IFR; ifstmt(); BEGIN 0; } "include" { contr = 0; BEGIN 0; include(); prtline(); } "else" { contr = 0; elsestmt(); } "endif" { contr = 0; endifstmt(); } "error" { contr = 0; if (slow) return IDENT; cpperror(); BEGIN 0; } "define" { contr = 0; BEGIN DEF; define(); BEGIN 0; } "undef" { contr = 0; if (slow) return IDENT; undefstmt(); } "line" { contr = 0; storepb(); BEGIN 0; line(); } "pragma" { contr = 0; pragmastmt(); BEGIN 0; } "elif" { contr = 0; storepb(); BEGIN IFR; elifstmt(); BEGIN 0; } "//".*$ { /* if (tflag) yyless(..) */ if (Cflag && !flslvl && !slow) putstr((usch *)yytext); else if (!flslvl) putch(' '); } "/*" { int c, wrn; int prtcm = Cflag && !flslvl && !slow; extern int readmac; if (Cflag && !flslvl && readmac) return CMNT; if (prtcm) putstr((usch *)yytext); wrn = 0; more: while ((c = input()) && c != '*') { if (c == '\n') putch(c), ifiles->lineno++; else if (c == 1) /* WARN */ wrn = 1; else if (prtcm) putch(c); } if (c == 0) return 0; if (prtcm) putch(c); if ((c = input()) && c != '/') { unput(c); goto more; } if (prtcm) putch(c); if (c == 0) return 0; if (!tflag && !Cflag && !flslvl) unput(' '); if (wrn) unput(1); } "##" { return CONCAT; } "#" { return MKSTR; } "..." { return ELLIPS; } "__VA_ARGS__" { return VA_ARGS; } L?\"(\\.|[^\\"])*\" { PRTOUT(STRING); } [a-zA-Z_0-9]+ { /* {L}({L}|{D})* */ struct symtab *nl; if (slow) return IDENT; if (YYSTATE == CONTR) { if (flslvl == 0) { /*error("undefined control");*/ while (input() != '\n') ; unput('\n'); BEGIN 0; goto xx; } else { BEGIN 0; /* do nothing */ } } if (flslvl) { ; /* do nothing */ } else if (isdigit((int)yytext[0]) == 0 && (nl = lookup((usch *)yytext, FIND)) != 0) { usch *op = stringbuf; putstr(gotident(nl)); stringbuf = op; } else putstr((usch *)yytext); xx: ; } . { if (contr) { while (input() != '\n') ; unput('\n'); BEGIN 0; contr = 0; goto yy; } if (YYSTATE || slow) return yytext[0]; if (yytext[0] == 6) { /* PRAGS */ usch *obp = stringbuf; extern usch *prtprag(usch *); *stringbuf++ = yytext[0]; do { *stringbuf = input(); } while (*stringbuf++ != 14); prtprag(obp); stringbuf = obp; } else { PRTOUT(yytext[0]); } yy:; } %% usch *yyp, yybuf[CPPBUF]; int yylex(void); int yywrap(void); static int inpch(void) { int len; if (ifiles->curptr < ifiles->maxread) return *ifiles->curptr++; if ((len = read(ifiles->infil, ifiles->buffer, CPPBUF)) < 0) error("read error on file %s", ifiles->orgfn); if (len == 0) return -1; ifiles->curptr = ifiles->buffer; ifiles->maxread = ifiles->buffer + len; return inpch(); } #define unch(c) *--ifiles->curptr = c static int inch(void) { int c; again: switch (c = inpch()) { case '\\': /* continued lines */ msdos: if ((c = inpch()) == '\n') { ifiles->lineno++; putch('\n'); goto again; } else if (c == '\r') goto msdos; unch(c); return '\\'; case '?': /* trigraphs */ if ((c = inpch()) != '?') { unch(c); return '?'; } switch (c = inpch()) { case '=': c = '#'; break; case '(': c = '['; break; case ')': c = ']'; break; case '<': c = '{'; break; case '>': c = '}'; break; case '/': c = '\\'; break; case '\'': c = '^'; break; case '!': c = '|'; break; case '-': c = '~'; break; default: unch(c); unch('?'); return '?'; } unch(c); goto again; default: return c; } } /* * Let the command-line args be faked defines at beginning of file. */ static void prinit(struct initar *it, struct includ *ic) { char *a, *pre, *post; if (it->next) prinit(it->next, ic); pre = post = NULL; /* XXX gcc */ switch (it->type) { case 'D': pre = "#define "; if ((a = strchr(it->str, '=')) != NULL) { *a = ' '; post = "\n"; } else post = " 1\n"; break; case 'U': pre = "#undef "; post = "\n"; break; case 'i': pre = "#include \""; post = "\"\n"; break; default: error("prinit"); } strlcat((char *)ic->buffer, pre, CPPBUF+1); strlcat((char *)ic->buffer, it->str, CPPBUF+1); if (strlcat((char *)ic->buffer, post, CPPBUF+1) >= CPPBUF+1) error("line exceeds buffer size"); ic->lineno--; while (*ic->maxread) ic->maxread++; } /* * A new file included. * If ifiles == NULL, this is the first file and already opened (stdin). * Return 0 on success, -1 if file to be included is not found. */ int pushfile(usch *file) { extern struct initar *initar; struct includ ibuf; struct includ *ic; int c, otrulvl; ic = &ibuf; ic->next = ifiles; slow = 0; if (file != NULL) { if ((ic->infil = open((char *)file, O_RDONLY)) < 0) return -1; ic->orgfn = ic->fname = file; if (++inclevel > MAX_INCLEVEL) error("Limit for nested includes exceeded"); } else { ic->infil = 0; ic->orgfn = ic->fname = (usch *)""; } ic->buffer = ic->bbuf+NAMEMAX; ic->curptr = ic->buffer; ifiles = ic; ic->lineno = 1; ic->maxread = ic->curptr; prtline(); if (initar) { *ic->maxread = 0; prinit(initar, ic); if (dMflag) write(ofd, ic->buffer, strlen((char *)ic->buffer)); initar = NULL; } otrulvl = trulvl; if ((c = yylex()) != 0) error("yylex returned %d", c); if (otrulvl != trulvl || flslvl) error("unterminated conditional"); ifiles = ic->next; close(ic->infil); inclevel--; return 0; } /* * Print current position to output file. */ void prtline() { usch *s, *os = stringbuf; if (Mflag) { if (dMflag) return; /* no output */ if (ifiles->lineno == 1) { s = sheap("%s: %s\n", Mfile, ifiles->fname); write(ofd, s, strlen((char *)s)); } } else if (!Pflag) putstr(sheap("# %d \"%s\"\n", ifiles->lineno, ifiles->fname)); stringbuf = os; } void cunput(int c) { #ifdef CPP_DEBUG extern int dflag; if (dflag)printf(": '%c'(%d)", c > 31 ? c : ' ', c); #endif unput(c); } int yywrap(void) { return 1; } static int dig2num(int c) { if (c >= 'a') c = c - 'a' + 10; else if (c >= 'A') c = c - 'A' + 10; else c = c - '0'; return c; } /* * Convert string numbers to unsigned long long and check overflow. */ static void cvtdig(int rad) { unsigned long long rv = 0; unsigned long long rv2 = 0; char *y = yytext; int c; c = *y++; if (rad == 16) y++; while (isxdigit(c)) { rv = rv * rad + dig2num(c); /* check overflow */ if (rv / rad < rv2) error("Constant \"%s\" is out of range", yytext); rv2 = rv; c = *y++; } y--; while (*y == 'l' || *y == 'L') y++; yylval.node.op = *y == 'u' || *y == 'U' ? UNUMBER : NUMBER; yylval.node.nd_uval = rv; if ((rad == 8 || rad == 16) && yylval.node.nd_val < 0) yylval.node.op = UNUMBER; if (yylval.node.op == NUMBER && yylval.node.nd_val < 0) /* too large for signed */ error("Constant \"%s\" is out of range", yytext); } static int charcon(usch *p) { int val, c; p++; /* skip first ' */ val = 0; if (*p++ == '\\') { switch (*p++) { case 'a': val = '\a'; break; case 'b': val = '\b'; break; case 'f': val = '\f'; break; case 'n': val = '\n'; break; case 'r': val = '\r'; break; case 't': val = '\t'; break; case 'v': val = '\v'; break; case '\"': val = '\"'; break; case '\'': val = '\''; break; case '\\': val = '\\'; break; case 'x': while (isxdigit(c = *p)) { val = val * 16 + dig2num(c); p++; } break; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': p--; while (isdigit(c = *p)) { val = val * 8 + (c - '0'); p++; } break; default: val = p[-1]; } } else val = p[-1]; return val; } static void chknl(int ignore) { int t; slow = 1; while ((t = yylex()) == WSPACE) ; if (t != '\n') { if (ignore) { warning("newline expected, got \"%s\"", yytext); /* ignore rest of line */ while ((t = yylex()) && t != '\n') ; } else error("newline expected, got \"%s\"", yytext); } slow = 0; } static void elsestmt(void) { if (flslvl) { if (elflvl > trulvl) ; else if (--flslvl!=0) { flslvl++; } else { trulvl++; prtline(); } } else if (trulvl) { flslvl++; trulvl--; } else error("If-less else"); if (elslvl==trulvl+flslvl) error("Too many else"); elslvl=trulvl+flslvl; chknl(1); } static void ifdefstmt(void) { int t; if (flslvl) { /* just ignore the rest of the line */ while (input() != '\n') ; unput('\n'); yylex(); flslvl++; return; } slow = 1; do t = yylex(); while (t == WSPACE); if (t != IDENT) error("bad ifdef"); slow = 0; if (flslvl == 0 && lookup((usch *)yytext, FIND) != 0) trulvl++; else flslvl++; chknl(0); } static void ifndefstmt(void) { int t; slow = 1; do t = yylex(); while (t == WSPACE); if (t != IDENT) error("bad ifndef"); slow = 0; if (flslvl == 0 && lookup((usch *)yytext, FIND) == 0) trulvl++; else flslvl++; chknl(0); } static void endifstmt(void) { if (flslvl) { flslvl--; if (flslvl == 0) prtline(); } else if (trulvl) trulvl--; else error("If-less endif"); if (flslvl == 0) elflvl = 0; elslvl = 0; chknl(1); } /* * Note! Ugly! * Walk over the string s and search for defined, and replace it with * spaces and a 1 or 0. */ static void fixdefined(usch *s) { usch *bc, oc; for (; *s; s++) { if (*s != 'd') continue; if (memcmp(s, "defined", 7)) continue; /* Ok, got defined, can scratch it now */ memset(s, ' ', 7); s += 7; #define WSARG(x) (x == ' ' || x == '\t') if (*s != '(' && !WSARG(*s)) continue; while (WSARG(*s)) s++; if (*s == '(') s++; while (WSARG(*s)) s++; #define IDARG(x) ((x>= 'A' && x <= 'Z') || (x >= 'a' && x <= 'z') || (x == '_')) #define NUMARG(x) (x >= '0' && x <= '9') if (!IDARG(*s)) error("bad defined arg"); bc = s; while (IDARG(*s) || NUMARG(*s)) s++; oc = *s; *s = 0; *bc = (lookup(bc, FIND) != 0) + '0'; memset(bc+1, ' ', s-bc-1); *s = oc; } } /* * get the full line of identifiers after an #if, pushback a WARN and * the line and prepare for expmac() to expand. * This is done before switching state. When expmac is finished, * pushback the expanded line, change state and call yyparse. */ static void storepb(void) { usch *opb = stringbuf; int c; while ((c = input()) != '\n') { if (c == '/') { if ((c = input()) == '*') { /* ignore comments here whatsoever */ usch *g = stringbuf; getcmnt(); stringbuf = g; continue; } else if (c == '/') { while ((c = input()) && c != '\n') ; break; } unput(c); c = '/'; } savch(c); } cunput('\n'); savch(0); fixdefined(opb); /* XXX can fail if #line? */ cunput(1); /* WARN XXX */ unpstr(opb); stringbuf = opb; slow = 1; expmac(NULL); slow = 0; /* line now expanded */ while (stringbuf > opb) cunput(*--stringbuf); } static void ifstmt(void) { if (flslvl == 0) { slow = 1; if (yyparse()) ++trulvl; else ++flslvl; slow = 0; } else ++flslvl; } static void elifstmt(void) { if (flslvl == 0) elflvl = trulvl; if (flslvl) { if (elflvl > trulvl) ; else if (--flslvl!=0) ++flslvl; else { slow = 1; if (yyparse()) { ++trulvl; prtline(); } else ++flslvl; slow = 0; } } else if (trulvl) { ++flslvl; --trulvl; } else error("If-less elif"); } static usch * svinp(void) { int c; usch *cp = stringbuf; while ((c = input()) && c != '\n') savch(c); savch('\n'); savch(0); BEGIN 0; return cp; } static void cpperror(void) { usch *cp; int c; if (flslvl) return; c = yylex(); if (c != WSPACE && c != '\n') error("bad error"); cp = svinp(); if (flslvl) stringbuf = cp; else error("%s", cp); } static void undefstmt(void) { struct symtab *np; slow = 1; if (yylex() != WSPACE || yylex() != IDENT) error("bad undef"); if (flslvl == 0 && (np = lookup((usch *)yytext, FIND))) np->value = 0; slow = 0; chknl(0); } static void pragmastmt(void) { int c; slow = 1; if (yylex() != WSPACE) error("bad pragma"); if (!flslvl) putstr((usch *)"#pragma "); do { c = input(); if (!flslvl) putch(c); /* Do arg expansion instead? */ } while (c && c != '\n'); ifiles->lineno++; prtline(); slow = 0; } static void badop(const char *op) { error("invalid operator in preprocessor expression: %s", op); } int cinput() { return input(); } ================================================ FILE: share/examples/scheme/prime.scm ================================================ (define (square n) (* n n)) (define (divides? a b) (= (remainder b a) 0)) (define (find-divisor n test-divisor) (cond ((> (square test-divisor) n) n) ((divides? test-divisor n) test-divisor) (else (find-divisor n (+ test-divisor 1))))) (define (smallest-divisor n) (find-divisor n 2)) (define (prime? n) (= n (smallest-divisor n))) (define (t n) (display n) (if (prime? n) (display '-prime) (display '-compound)) (newline)) (t 2) (t 20) (t 23) (t 65) (t 67) (t 2011) ================================================ FILE: share/examples/sensors/Makefile ================================================ PROG = led2 led3 led7 relay buzzer laser pbuzz irled joystick all: $(PROG) relay: relay.c cc $? -o $@ buzzer: buzzer.c cc $? -o $@ pbuzz: pbuzz.c cc $? -o $@ laser: laser.c cc $? -o $@ led2: led2.c cc $? -o $@ led3: led3.c cc $? -o $@ led7: led7.c cc $? -o $@ irled: irled.c cc $? -o $@ joystick: joystick.c cc $? -o $@ clean: rm -f *.o *~ $(PROG) ================================================ FILE: share/examples/sensors/README.txt ================================================ Examples for 37-in-1 sensor kit. For details, see: https://github.com/sergev/RetroBSD-and-37-Sensor-Kit/wiki ================================================ FILE: share/examples/sensors/buzzer.c ================================================ /* * Example for RetroBSD on Olimex Duinomite board. * Active buzzer is connected to D0 pin of Duinomite board. * Use ioctl() calls to poll the user button, and control the buzzer. */ #include #include #include /* * Pin D0 is connected to signal RE0 on pic32 chip. * User button is connected to signal RD8 on pic32 chip. */ #define MASK_D0 (1 << 0) /* signal RE0 */ #define MASK_BUTTON (1 << 8) /* signal RD8 */ int main() { int fd, portb; char *devname = "/dev/porta"; /* Open GPIO driver. */ fd = open(devname, 1); if (fd < 0) { perror(devname); return -1; } /* Configure pins. */ ioctl(fd, GPIO_PORTD | GPIO_CONFIN, MASK_BUTTON); ioctl(fd, GPIO_PORTE | GPIO_CONFOUT, MASK_D0); ioctl(fd, GPIO_PORTE | GPIO_CLEAR, MASK_D0); for (;;) { /* Poll button at RD8 every 20 msec (active low). */ usleep(20000); portb = ioctl(fd, GPIO_PORTD | GPIO_POLL, 0); if (~portb & MASK_BUTTON) { /* Enable buzzer at D0. */ ioctl(fd, GPIO_PORTE | GPIO_SET, MASK_D0); } else { /* Disable buzzer at D0. */ ioctl(fd, GPIO_PORTE | GPIO_CLEAR, MASK_D0); } } return 0; } ================================================ FILE: share/examples/sensors/buzzer.sh ================================================ #!/bin/sh # Set signal RD8 as input, RE0 as output. echo -------i-------- > /dev/confd echo ---------------o > /dev/confe echo ---------------0 > /dev/porte while : do # Poll button (active low) read portd < /dev/portd case $portd in ???????0????????) # Switch buzzer on echo ---------------1 > /dev/porte ;; ???????1????????) # Switch buzzer off echo ---------------0 > /dev/porte ;; esac done ================================================ FILE: share/examples/sensors/irled.c ================================================ /* * Example for RetroBSD on Olimex Duinomite board. * Infrared LED is connected to D0 pin of Duinomite board. * Use ioctl() calls to poll the user button, and control the buzzer. */ #include #include #include /* * Pin D0 is connected to signal RE0 on pic32 chip. * User button is connected to signal RD8 on pic32 chip. */ #define MASK_D0 (1 << 0) /* signal RE0 */ #define MASK_BUTTON (1 << 8) /* signal RD8 */ int main() { int fd, portb; char *devname = "/dev/porta"; /* Open GPIO driver. */ fd = open(devname, 1); if (fd < 0) { perror(devname); return -1; } /* Configure pins. */ ioctl(fd, GPIO_PORTD | GPIO_CONFIN, MASK_BUTTON); ioctl(fd, GPIO_PORTE | GPIO_CONFOUT, MASK_D0); ioctl(fd, GPIO_PORTE | GPIO_CLEAR, MASK_D0); for (;;) { /* Poll button at RD8 (active low). */ portb = ioctl(fd, GPIO_PORTD | GPIO_POLL, 0); if (~portb & MASK_BUTTON) { /* Transmit a series of three pulses 50 msec each, * repeat every second. */ ioctl(fd, GPIO_PORTE | GPIO_SET, MASK_D0); usleep(50000); ioctl(fd, GPIO_PORTE | GPIO_CLEAR, MASK_D0); usleep(50000); ioctl(fd, GPIO_PORTE | GPIO_SET, MASK_D0); usleep(50000); ioctl(fd, GPIO_PORTE | GPIO_CLEAR, MASK_D0); usleep(50000); ioctl(fd, GPIO_PORTE | GPIO_SET, MASK_D0); usleep(50000); ioctl(fd, GPIO_PORTE | GPIO_CLEAR, MASK_D0); usleep(750000); } } return 0; } ================================================ FILE: share/examples/sensors/joystick.c ================================================ /* * Example for RetroBSD on Olimex Duinomite board. * Joystick is connected to A0, A1 and D7 pin of Duinomite board. */ #include #include #include /* * Pin D7 is connected to signal RE7 on pic32 chip. */ #define MASK_BUTTON (1 << 7) /* signal RE7 */ /* * Read value from analog-to-digital converter. * Scale to given max value. */ int readadc(int fd, int max) { char buf[16]; int val; if (read(fd, buf, sizeof(buf)) <= 0) { perror("adc"); exit(-1); } val = strtol(buf, 0, 10); return val * max / 1024; } int main() { int gpio, adc3, adc4, porte, x, y; /* Open GPIO driver. */ gpio = open("/dev/porta", 1); if (gpio < 0) { perror("/dev/porta"); return -1; } /* Open ADC driver. */ adc3 = open("/dev/adc3", 0); if (adc3 < 0) { perror("/dev/adc3"); return -1; } adc4 = open("/dev/adc4", 0); if (adc4 < 0) { perror("/dev/adc4"); return -1; } /* Configure D7 pin is input, active low. */ ioctl(gpio, GPIO_PORTE | GPIO_CONFIN, MASK_BUTTON); /* Clear screen. */ printf("\33[2J"); for (;;) { /* Poll joystick every 20 msec. */ usleep(20000); porte = ioctl(gpio, GPIO_PORTE | GPIO_POLL, 0); x = readadc(adc3, 50); y = readadc(adc4, 25); if (~porte & MASK_BUTTON) { /* When button pressed - clear screen. */ printf("\33[2J"); } printf("\33[H%u, %u ", x, y); printf("\33[%u;%uHX", y, 78 - x); fflush(stdout); } return 0; } ================================================ FILE: share/examples/sensors/laser.c ================================================ /* * Example for RetroBSD on Olimex Duinomite board. * Laser is connected to D0 pin of Duinomite board. * Use ioctl() calls to poll the user button, and control the laser. */ #include #include #include /* * Pin D0 is connected to signal RE0 on pic32 chip. * User button is connected to signal RD8 on pic32 chip. */ #define MASK_D0 (1 << 0) /* signal RE0 */ #define MASK_BUTTON (1 << 8) /* signal RD8 */ int main() { int fd, portb; char *devname = "/dev/porta"; /* Open GPIO driver. */ fd = open(devname, 1); if (fd < 0) { perror(devname); return -1; } /* Configure pins. */ ioctl(fd, GPIO_PORTD | GPIO_CONFIN, MASK_BUTTON); ioctl(fd, GPIO_PORTE | GPIO_CONFOUT, MASK_D0); ioctl(fd, GPIO_PORTE | GPIO_CLEAR, MASK_D0); for (;;) { /* Poll button at RD8 every 20 msec (active low). */ usleep(20000); portb = ioctl(fd, GPIO_PORTD | GPIO_POLL, 0); if (~portb & MASK_BUTTON) { /* Enable laser at D0. */ ioctl(fd, GPIO_PORTE | GPIO_SET, MASK_D0); } else { /* Disable laser at D0. */ ioctl(fd, GPIO_PORTE | GPIO_CLEAR, MASK_D0); } } return 0; } ================================================ FILE: share/examples/sensors/laser.sh ================================================ #!/bin/sh # Set signal RD8 as input, RE0 as output. echo -------i-------- > /dev/confd echo ---------------o > /dev/confe echo ---------------0 > /dev/porte while : do # Poll button (active low) read portd < /dev/portd case $portd in ???????0????????) # Switch relay on echo ---------------1 > /dev/porte ;; ???????1????????) # Switch relay off echo ---------------0 > /dev/porte ;; esac done ================================================ FILE: share/examples/sensors/led2-portio.sh ================================================ #!/bin/sh # # Example for RetroBSD on Olimex Duinomite board. # RGB LED is connected to D1 and D0 pins of Duinomite board. # Use /dev/porte device to control LED. # # Pins D0 and D1 are connected to signals RE0 and RE1 of pic32 chip. # Set up them as output. portio -o e0 e1 portio -c e0 e1 while : do portio -c e0 -s e1 portio -c e1 -s e0 done ================================================ FILE: share/examples/sensors/led2.c ================================================ /* * Example for RetroBSD on Olimex Duinomite board. * RGB LED is connected to D1 and D0 pins of Duinomite board. * Use ioctl() calls to control LED. */ #include #include #include /* * Pins D0 and D1 are connected to signals RE0 and RE1 of pic32 chip. */ #define MASK_D0 (1 << 0) /* signal RE0 */ #define MASK_D1 (1 << 1) /* signal RE1 */ int main() { int fd; char *devname = "/dev/porta"; /* Open GPIO driver. */ fd = open(devname, 1); if (fd < 0) { perror(devname); return -1; } /* Configure pins as output. */ ioctl(fd, GPIO_PORTE | GPIO_CONFOUT, MASK_D0 | MASK_D1); ioctl(fd, GPIO_PORTE | GPIO_CLEAR, MASK_D0 | MASK_D1); for (;;) { /* Clear D0, set D1. */ ioctl(fd, GPIO_PORTE | GPIO_CLEAR, MASK_D0); ioctl(fd, GPIO_PORTE | GPIO_SET, MASK_D1); usleep(250000); /* Clear D1, set D0. */ ioctl(fd, GPIO_PORTE | GPIO_CLEAR, MASK_D1); ioctl(fd, GPIO_PORTE | GPIO_SET, MASK_D0); usleep(250000); } return 0; } ================================================ FILE: share/examples/sensors/led2.sh ================================================ #!/bin/sh # # Example for RetroBSD on Olimex Duinomite board. # RGB LED is connected to D1 and D0 pins of Duinomite board. # Use /dev/porte device to control LED. # # Pins D0 and D1 are connected to signals RE0 and RE1 of pic32 chip. # Set up them as output. echo --------------oo > /dev/confe echo --------------00 > /dev/porte while : do echo --------------10 > /dev/porte sleep 1 echo --------------01 > /dev/porte sleep 1 done ================================================ FILE: share/examples/sensors/led3-portio.sh ================================================ #!/bin/sh # # Example for RetroBSD on Olimex Duinomite board. # RGB LED is connected to D7, D6 and D5 pins of Duinomite board. # Use portio utility to control LED. # # Pins D5, D6 and D7 are connected to signals RE5, RE6 and RE7 of pic32 chip. # Set up them as output. portio -o e5-7 portio -c e5-7 while : do portio -c e5 -s e7 portio -c e7 -s e6 portio -c e6 -s e5 done ================================================ FILE: share/examples/sensors/led3.c ================================================ /* * Example for RetroBSD on Olimex Duinomite board. * RGB LED is connected to D7, D6 and D5 pins of Duinomite board. * Use ioctl() calls to control LED. */ #include #include #include /* * Pins D5, D6 and D7 are connected to signals RE5, RE6 and RE7 of pic32 chip. */ #define MASK_D5 (1 << 5) /* signal RE5 */ #define MASK_D6 (1 << 6) /* signal RE6 */ #define MASK_D7 (1 << 7) /* signal RE7 */ int main() { int fd; char *devname = "/dev/porta"; /* Open GPIO driver. */ fd = open(devname, 1); if (fd < 0) { perror(devname); return -1; } /* Configure pins as output. */ ioctl(fd, GPIO_PORTE | GPIO_CONFOUT, MASK_D5 | MASK_D6 | MASK_D7); ioctl(fd, GPIO_PORTE | GPIO_CLEAR, MASK_D5 | MASK_D6 | MASK_D7); for (;;) { /* Clear D5, set D7. */ ioctl(fd, GPIO_PORTE | GPIO_CLEAR, MASK_D5); ioctl(fd, GPIO_PORTE | GPIO_SET, MASK_D7); usleep(100000); /* Clear D7, set D6. */ ioctl(fd, GPIO_PORTE | GPIO_CLEAR, MASK_D7); ioctl(fd, GPIO_PORTE | GPIO_SET, MASK_D6); usleep(100000); /* Clear D6, set D5. */ ioctl(fd, GPIO_PORTE | GPIO_CLEAR, MASK_D6); ioctl(fd, GPIO_PORTE | GPIO_SET, MASK_D5); usleep(100000); } return 0; } ================================================ FILE: share/examples/sensors/led3.sh ================================================ #!/bin/sh # # Example for RetroBSD on Olimex Duinomite board. # RGB LED is connected to D7, D6 and D5 pins of Duinomite board. # Use /dev/porte device to control LED. # # Pins D5, D6 and D7 are connected to signals RE5, RE6 and RE7 of pic32 chip. # Set up them as output. echo --------ooo----- > /dev/confe echo --------000----- > /dev/porte while : do echo --------100----- > /dev/porte sleep 1 echo --------010----- > /dev/porte sleep 1 echo --------001----- > /dev/porte sleep 1 done ================================================ FILE: share/examples/sensors/led7.c ================================================ /* * Example for RetroBSD on Olimex Duinomite board. * RGB LED is connected to D7, D6 and D5 pins of Duinomite board. * Use ioctl() calls to control LED. */ #include #include #include /* * Pin D2 is connected to signal RE2 on pic32 chip. */ #define MASK_D2 (1 << 2) /* signal RE2 */ int main() { int fd; char *devname = "/dev/porta"; /* Open GPIO driver. */ fd = open(devname, 1); if (fd < 0) { perror(devname); return -1; } /* Configure pin as output. */ ioctl(fd, GPIO_PORTE | GPIO_CONFOUT, MASK_D2); ioctl(fd, GPIO_PORTE | GPIO_CLEAR, MASK_D2); for (;;) { /* Set D2. */ ioctl(fd, GPIO_PORTE | GPIO_SET, MASK_D2); sleep(15); /* Clear D2. */ ioctl(fd, GPIO_PORTE | GPIO_CLEAR, MASK_D2); sleep(3); } return 0; } ================================================ FILE: share/examples/sensors/pbuzz.c ================================================ /* * Example for RetroBSD on Olimex Duinomite board. * Passive buzzer is connected to D0 pin of Duinomite board. * Use ioctl() calls to poll the user button, and control the buzzer. */ #include #include #include /* * Pin D0 is connected to signal RE0 on pic32 chip. * User button is connected to signal RD8 on pic32 chip. */ #define MASK_D0 (1 << 0) /* signal RE0 */ #define MASK_BUTTON (1 << 8) /* signal RD8 */ int main() { int fd, portb; char *devname = "/dev/porta"; /* Open GPIO driver. */ fd = open(devname, 1); if (fd < 0) { perror(devname); return -1; } /* Configure pins. */ ioctl(fd, GPIO_PORTD | GPIO_CONFIN, MASK_BUTTON); ioctl(fd, GPIO_PORTE | GPIO_CONFOUT, MASK_D0); ioctl(fd, GPIO_PORTE | GPIO_CLEAR, MASK_D0); for (;;) { /* Poll button at RD8 (active low). */ portb = ioctl(fd, GPIO_PORTD | GPIO_POLL, 0); if (~portb & MASK_BUTTON) { /* Toggle buzzer at D0. */ ioctl(fd, GPIO_PORTE | GPIO_INVERT, MASK_D0); usleep(5000); } else { /* Disable buzzer at D0. */ ioctl(fd, GPIO_PORTE | GPIO_CLEAR, MASK_D0); } } return 0; } ================================================ FILE: share/examples/sensors/relay.c ================================================ /* * Example for RetroBSD on Olimex Duinomite board. * Relay is connected to D0 pin of Duinomite board. * Use ioctl() calls to poll the user button, and control the relay. */ #include #include #include /* * Pin D0 is connected to signal RE0 on pic32 chip. * User button is connected to signal RD8 on pic32 chip. */ #define MASK_D0 (1 << 0) /* signal RE0 */ #define MASK_BUTTON (1 << 8) /* signal RD8 */ int main() { int fd, portb; char *devname = "/dev/porta"; /* Open GPIO driver. */ fd = open(devname, 1); if (fd < 0) { perror(devname); return -1; } /* Configure pins. */ ioctl(fd, GPIO_PORTD | GPIO_CONFIN, MASK_BUTTON); ioctl(fd, GPIO_PORTE | GPIO_CONFOUT, MASK_D0); ioctl(fd, GPIO_PORTE | GPIO_CLEAR, MASK_D0); for (;;) { /* Poll button at RD8 every 20 msec (active low). */ usleep(20000); portb = ioctl(fd, GPIO_PORTD | GPIO_POLL, 0); if (~portb & MASK_BUTTON) { /* Enable relay at D0. */ ioctl(fd, GPIO_PORTE | GPIO_SET, MASK_D0); } else { /* Disable relay at D0. */ ioctl(fd, GPIO_PORTE | GPIO_CLEAR, MASK_D0); } } return 0; } ================================================ FILE: share/examples/sensors/relay.sh ================================================ #!/bin/sh # Set signal RD8 as input, RE0 as output. echo -------i-------- > /dev/confd echo ---------------o > /dev/confe echo ---------------0 > /dev/porte while : do # Poll button (active low) read portd < /dev/portd case $portd in ???????0????????) # Switch relay on echo ---------------1 > /dev/porte ;; ???????1????????) # Switch relay off echo ---------------0 > /dev/porte ;; esac done ================================================ FILE: share/examples/smallc/Makefile ================================================ CC = scc PROG = hello primelist primesum test1 test2 test3 gpio adc rain \ webserver q8 all: $(PROG) hello: hello.c $(CC) $(CFLAGS) -o $@ $(LDFLAGS) hello.c primelist: primelist.c $(CC) $(CFLAGS) -o $@ $(LDFLAGS) primelist.c primesum: primesum.c $(CC) $(CFLAGS) -o $@ $(LDFLAGS) primesum.c webserver: webserver.c $(CC) $(CFLAGS) -o $@ $(LDFLAGS) webserver.c -lwiznet gpio: gpio.c $(CC) $(CFLAGS) -o $@ $(LDFLAGS) gpio.c adc: adc.c $(CC) $(CFLAGS) -o $@ $(LDFLAGS) adc.c rain: rain.c $(CC) $(CFLAGS) -o $@ $(LDFLAGS) rain.c q8: q8.c $(CC) $(CFLAGS) -o $@ $(LDFLAGS) q8.c test1: test1.c $(CC) $(CFLAGS) -o $@ $(LDFLAGS) test1.c test2: test2.c $(CC) $(CFLAGS) -o $@ $(LDFLAGS) test2.c test3: test3.c $(CC) $(CFLAGS) -o $@ $(LDFLAGS) test3.c clean: rm -f *.o $(PROG) ================================================ FILE: share/examples/smallc/adc.c ================================================ /* * Example of reading ADC data. */ #include char buf[100]; main() { int i, fd, value; for (i=0; i<16; i++) { sprintf(buf, "/dev/adc%d", i); fd = open(buf, O_RDWR); if (fd < 0) { printf("Error: unable to open %s\n", buf); } else { if (read(fd, buf, 20) > 0) { value = strtol (buf, 0, 0); printf("adc%-2d = %d\n", i, value); } close(fd); } } return 0; } ================================================ FILE: share/examples/smallc/gpio.c ================================================ /* * Example of polling general purpose i/o pins. */ #include #include main () { int fd, pnum, value; fd = open ("/dev/porta", O_RDWR); if (fd < 0) { perror ("/dev/porta"); return -1; } for (pnum=0; pnum<7; pnum++) { value = ioctl (fd, GPIO_POLL | GPIO_PORT (pnum), 0); if (value < 0) perror ("GPIO_POLL"); printf ("port%c = 0x%04x\n", pnum + 'A', value); } return 0; } ================================================ FILE: share/examples/smallc/hello.c ================================================ main() { printf ("Hello, SmallC World!\n"); } ================================================ FILE: share/examples/smallc/primelist.c ================================================ /* * Print the list of prime numbers up to 100. */ main() { int n; for (n=2; n<100; ++n) { if (isprime(n)) { printf("%d ", n); } } printf("\n"); } isprime(n) int n; { int j; if (n == 2) return 1; if (n % 2 == 0) return 0; for (j=3; j*j<=n; j+=2) if (n % j == 0) return 0; return 1; } ================================================ FILE: share/examples/smallc/primesum.c ================================================ /* * Compute the sum of prime numbers up to 10000. */ main() { int sum, n; sum = 0; for (n=2; n<10000; ++n) { if (isprime(n)) { sum += n; } } printf("Sum of primes less than 10000: %d\n", sum); } isprime(n) int n; { int j; if (n == 2) return 1; if (n % 2 == 0) return 0; for (j=3; j*j<=n; j+=2) if (n % j == 0) return 0; return 1; } ================================================ FILE: share/examples/smallc/q8.c ================================================ /* * Eight Queens puzzle * * (C) 2010 by Mark Sproul * Open source as per standard Arduino code * Modified by Pito 12/2012 for SmallC */ #define TRUE 1 #define FALSE 0 unsigned int gChessBoard[8]; unsigned int gLoopCounter; int gValidCount; CheckCurrentBoard() { int ii; int jj; int theRow; int theLongRow; int theLongColumns; int bitCount; //* we know we have 1 in each row, //* Check for 1 in each column theRow = 0; for (ii=0; ii<8; ii++) { theRow |= gChessBoard[ii]; } if (theRow != 0x0ff) { return FALSE; } //* we have 1 in each column, now check the diagonals theLongColumns = 0; for (ii=0; ii<8; ii++) { theLongRow = gChessBoard[ii] & 0x0ff; theLongRow = theLongRow << ii; theLongColumns |= theLongRow; } //* now count the bits bitCount = 0; for (ii=0; ii<16; ii++) { if ((theLongColumns & 0x01) == 0x01) { bitCount++; } theLongColumns = theLongColumns >> 1; } if (bitCount != 8) { return FALSE; } //* we now have to check the other diagonal theLongColumns = 0; for (ii=0; ii<8; ii++) { theLongRow = gChessBoard[ii] & 0x0ff; theLongRow = theLongRow << 8; theLongRow = theLongRow >> ii; theLongColumns |= theLongRow; } //* now count the bits bitCount = 0; for (ii=0; ii<16; ii++) { if ((theLongColumns & 0x01) == 0x01) { bitCount++; } theLongColumns = theLongColumns >> 1; } if (bitCount != 8) { return FALSE; } return TRUE; } CheckForDone() { int ii; int weAreDone; int theRow; weAreDone = FALSE; //* we know we have 1 in each row, //* Check for 1 in each column theRow = 0; for (ii=0; ii<8; ii++) { theRow |= gChessBoard[ii]; } if (theRow == 0x01) { weAreDone = TRUE; } return weAreDone; } RotateQueens() { int ii; int keepGoing; int theRow; ii = 0; keepGoing = TRUE; while (keepGoing && (ii < 8)) { theRow = gChessBoard[ii] & 0x0ff; theRow = (theRow >> 1) & 0x0ff; if (theRow != 0) { gChessBoard[ii] = theRow; keepGoing = FALSE; } else { gChessBoard[ii] = 0x080; } ii++; } } PrintChessBoard() { int ii; int jj; int theRow; char textString[32]; printf("\nLoop= %d\n", gLoopCounter); printf("Solution count= %d\n", gValidCount); printf("+----------------+\n"); for (ii=0; ii<8; ii++) { theRow = gChessBoard[ii]; printf("|"); for (jj=0; jj<8; jj++) { if (theRow & 0x080) { printf("Q "); } else { printf(". "); } theRow = theRow << 1; } printf("|\n"); } printf("+----------------+\n"); } main() { int ii; printf("\nEight Queens brute force"); printf("\n************************\n"); //* put the 8 queens on the board, 1 in each row for (ii=0; ii<8; ii++) { gChessBoard[ii] = 0x080; } PrintChessBoard(); gLoopCounter = 0; gValidCount = 0; while (1) { gLoopCounter++; if (CheckCurrentBoard()) { gValidCount++; PrintChessBoard(); } else if ((gLoopCounter % 1000) == 0) { //PrintChessBoard(); } RotateQueens(); if (CheckForDone()) { //int elapsedSeconds; //int elapsedMinutes; //int elapsedHours; //elapsedSeconds = millis() / 1000; //elapsedMinutes = elapsedSeconds / 60; //elapsedHours = elapsedMinutes / 60; printf("----------------------------------\n"); printf("All done\n"); PrintChessBoard(); printf("----------------------------------\n"); //Serial.print("total seconds="); //Serial.println(elapsedSeconds); //Serial.print("hours="); //Serial.println(elapsedHours); //Serial.print("minutes="); //Serial.println(elapsedMinutes % 60); //Serial.print("seconds="); //Serial.println(elapsedSeconds % 60); return (1); } } } ================================================ FILE: share/examples/smallc/rain.c ================================================ /* * Example of using termcap library for SmallC. * 11/3/1980 EPS/CITHEP * * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include #include #define CO 80 /* number of columns */ #define LI 24 /* number of lines */ #define CL "\33[H\33[J" /* clear the screen */ #define CM "\33[%u;%uH" /* move the cursor to row, column */ #define BC "\b" /* move cursor left */ #define DN "\33[B" /* move cursor down */ #define ND " " /* move cursor right */ int xpos[5], ypos[5]; char outbuf[BUFSIZ]; moveto(col, row) int col, row; { printf(CM, row, col); } onsig(n) int n; { moveto(0, LI - 1); fflush(stdout); _exit(0); } main() { int x, y, j; setbuf(stdout, outbuf); for (j = SIGHUP; j <= SIGTERM; j++) if (signal(j, SIG_IGN) != SIG_IGN) signal(j, onsig); fputs(CL, stdout); fflush(stdout); for (j = 5; --j >= 0; ) { xpos[j] = 2 + rand() % (CO - 4); ypos[j] = 2 + rand() % (LI - 4); } for (j = 0; ; ) { x = 2 + rand() % (CO - 4); y = 2 + rand() % (LI - 4); moveto(x, y); putchar('.'); moveto(xpos[j], ypos[j]); putchar('o'); if (j == 0) j = 4; else --j; moveto(xpos[j], ypos[j]); putchar('O'); if (j == 0) j = 4; else --j; moveto(xpos[j], ypos[j]-1); putchar('-'); fputs(DN, stdout); fputs(BC, stdout); fputs(BC, stdout); fputs("|.|", stdout); fputs(DN, stdout); fputs(BC, stdout); fputs(BC, stdout); putchar('-'); if (j == 0) j = 4; else --j; moveto(xpos[j], ypos[j]-2); putchar('-'); fputs(DN, stdout); fputs(BC, stdout); fputs(BC, stdout); fputs("/ \\", stdout); moveto(xpos[j]-2, ypos[j]); fputs("| O |", stdout); moveto(xpos[j]-1, ypos[j]+1); fputs("\\ /", stdout); fputs(DN, stdout); fputs(BC, stdout); fputs(BC, stdout); putchar('-'); if (j == 0) j = 4; else --j; moveto(xpos[j], ypos[j]-2); putchar(' '); fputs(DN, stdout); fputs(BC, stdout); fputs(BC, stdout); putchar(' '); fputs(ND, stdout); putchar(' '); moveto(xpos[j]-2, ypos[j]); putchar(' '); fputs(ND, stdout); putchar(' '); fputs(ND, stdout); putchar(' '); moveto(xpos[j]-1, ypos[j]+1); putchar(' '); fputs(ND, stdout); putchar(' '); fputs(DN, stdout); fputs(BC, stdout); fputs(BC, stdout); putchar(' '); xpos[j] = x; ypos[j] = y; fflush(stdout); usleep(100000); } } ================================================ FILE: share/examples/smallc/test1.c ================================================ int ga[5]; main() { int a, b, c, d; int arr[5]; int *pi; char arrc[5]; char *pic; int s1, s2; int z; int t; int *pip; int *picp; int e1, e2; ga[0] = 10; ga[1] = 20; ga[2] = 30; ga[3] = 40; ga[4] = 50; a = 21; b = 31; c = 71; d = 82; arr[0] = 10; arr[1] = 20; arr[2] = 30; arr[3] = 40; arr[4] = 50; pi = &arr[0]; arrc[0] = 13; arrc[1] = 23; arrc[2] = 33; arrc[3] = 43; arrc[4] = 53; pic = &arrc[0]; printf(" 21 + 31 = %d (52)\n", a + b); printf(" 21 - 31 = %d (-10)\n", a - b); printf(" 21 & 71 = %d (5)\n", a & c); printf(" 21 | 82 = %d (87)\n", a | d); printf(" 21 ^ 82 = %d (71)\n", a ^ d); printf(" 21 * 82 = %d (1722)\n", a * d); printf(" 82 % 21 = %d (19)\n", d % a); printf(" 82 / 21 = %d (3)\n", d / a); printf(" *pi = %d (10)\n", *pi); printf(" *pi + 1 = %d (11)\n", *pi + 1); printf(" *(pi + 1) = %d (20)\n", *(pi + 1)); printf("&arr[3] - &arr[0] = %d (3)\n", &arr[3] - &arr[0]); printf(" arr[3]-arr[0] = %d (30)\n", arr[3] - arr[0]); printf(" arr[3]+arr[0] = %d (50)\n", arr[3] + arr[0]); printf(" &ga[3] - &ga[0] = %d (3)\n", &ga[3] - &ga[0]); printf(" ga[3]-ga[0] = %d (30)\n", ga[3] - ga[0]); printf(" ga[3]+ga[0] = %d (50)\n", ga[3] + ga[0]); printf("\n"); printf(" *pic = %d (13)\n", *pic); printf(" *pic + 1 = %d (14)\n", *pic+1); printf(" *(pic + 1) = %d (23)\n", *(pic+1)); printf("&arrc[3] - &arrc[0] = %d (3)\n", &arrc[3]-&arrc[0]); printf("\n"); s1 = 3; s2 = -200; printf(" 82 << 3 = %d (656)\n", d << s1); printf(" 82 >> 3 = %d (10)\n", d >> s1); printf("-200 >> 3 = %d (-25)\n", s2 >> s1); printf("-200 << 3 = %d (-1600)\n", s2 << s1); printf("\n"); printf("-s1 = %d (-3)\n", -s1); printf("-s2 = %d (200)\n", -s2); printf("\n"); printf("~82 = %d (-83)\n", ~d); printf("\n"); z = 0; printf("!82 = %d (0)\n", !d); printf(" !0 = %d (1)\n", !z); printf("\n"); printf(" 0 && 0 = %d (0)\n", z && z); printf(" 0 && 21 = %d (0)\n", z && a); printf(" 3 && 21 = %d (1)\n", s1 && a); printf("21 && 3 = %d (1)\n", a && s1); printf("\n"); printf(" 0 || 0 = %d (0)\n", z || z); printf(" 0 || 21 = %d (1)\n", z || a); printf(" 3 || 21 = %d (1)\n", s1 || a); printf("21 || 3 = %d (1)\n", a || s1); printf("\n"); pi = 4; printf("pi++ = %d (4)\n", pi++); printf(" pi = %d (8)\n", pi); printf("++pi = %d (12)\n", ++pi); printf("pi-- = %d (12)\n", pi--); printf(" pi = %d (8)\n", pi); printf("--pi = %d (4)\n", --pi); printf("\n"); pic = 4; printf("pic++ = %d (4)\n", pic++); printf(" pic = %d (5)\n", pic); printf("++pic = %d (6)\n", ++pic); printf("pic-- = %d (6)\n", pic--); printf(" pic = %d (5)\n", pic); printf("--pic = %d (4)\n", --pic); printf("\n"); t = 4; printf("t++ = %d (4)\n", t++); printf(" t = %d (5)\n", t); printf("++t = %d (6)\n", ++t); printf("t-- = %d (6)\n", t--); printf(" t = %d (5)\n", t); printf("--t = %d (4)\n", --t); printf("\n"); t = 4; printf(" t==4 = %d (1)\n", t == 4); printf(" t==3 = %d (0)\n", t == 3); printf(" t==5 = %d (0)\n", t == 5); t = -4; printf("t==-4 = %d (1)\n", t == -4); printf("t==-3 = %d (0)\n", t == -3); printf("t==-5 = %d (0)\n", t == -5); printf(" t==4 = %d (0)\n", t == 4); printf(" t==3 = %d (0)\n", t == 3); printf(" t==5 = %d (0)\n", t == 5); printf("\n"); t = 4; printf(" t!=4 = %d (0)\n", t != 4); printf(" t!=3 = %d (1)\n", t != 3); printf(" t!=5 = %d (1)\n", t != 5); t = -4; printf("t!=-4 = %d (0)\n", t != -4); printf("t!=-3 = %d (1)\n", t != -3); printf("t!=-5 = %d (1)\n", t != -5); printf(" t!=4 = %d (1)\n", t != 4); printf(" t!=3 = %d (1)\n", t != 3); printf(" t!=5 = %d (1)\n", t != 5); printf("\n"); t = 4; printf(" t<4 = %d (0)\n", t < 4); printf(" t<3 = %d (0)\n", t < 3); printf(" t<5 = %d (1)\n", t < 5); printf("t<-1 = %d (0)\n", t < -1); printf("\n"); printf(" t<=4 = %d (1)\n", t <= 4); printf(" t<=3 = %d (0)\n", t <= 3); printf(" t<=5 = %d (1)\n", t <= 5); printf("t<=-1 = %d (0)\n", t <= -1); printf("\n"); t = 4; printf(" t>4 = %d (0)\n", t > 4); printf(" t>3 = %d (1)\n", t > 3); printf(" t>5 = %d (0)\n", t > 5); printf("t>-1 = %d (1)\n", t > -1); printf("\n"); printf(" t>=4 = %d (1)\n", t >= 4); printf(" t>=3 = %d (1)\n", t >= 3); printf(" t>=5 = %d (0)\n", t >= 5); printf("t>=-1 = %d (1)\n", t >= -1); printf("\n"); pi = -100; printf(" pi<4 = %d (0)\n", pi < 4); printf(" pi<3 = %d (0)\n", pi < 3); printf("pi<-100 = %d (0)\n", pi < -100); printf(" pi<-1 = %d (1)\n", pi < -1); printf("\n"); printf(" pi<=4 = %d (0)\n", pi <= 4); printf(" pi<=3 = %d (0)\n", pi <= 3); printf("pi<=-100 = %d (1)\n", pi <= -100); printf(" pi<=-1 = %d (1)\n", pi <= -1); printf("\n"); pi = -100; printf(" pi>4 = %d (1)\n", pi > 4); printf(" pi>3 = %d (1)\n", pi > 3); printf("pi>-100 = %d (0)\n", pi > -100); printf(" pi>-1 = %d (0)\n", pi > -1); printf("\n"); printf(" pi>=4 = %d (1)\n", pi >= 4); printf(" pi>=3 = %d (1)\n", pi >= 3); printf("pi>=-100 = %d (1)\n", pi >= -100); printf(" pi>=-1 = %d (0)\n", pi >= -1); printf("\n"); pi = &arr[0]; pip = &arr[3]; printf(" *pip - *pi: %d 30\n", *pip - *pi); printf(" pip - pi: %d 3\n", pip - pi); printf(" *pip: %d 40\n", *pip); printf(" *(pip - 3): %d 10\n", *(pip - 3)); printf(" *&arr[3]: %d 40\n", *&arr[3]); printf("*(&arr[3] - 3): %d 10\n", *(&arr[3]-3)); } printt (t, str) int t; char *str; { printf("bool test on value %d %s\n", t, str); } ================================================ FILE: share/examples/smallc/test2.c ================================================ #include int aaa; int bbb; int ccc; char gc; char gbuffer[3]; int gibuffer[4]; extern errno; main() { char b; int la; unsigned int u1, u2; int s1, s2; unsigned char uc1, uc2; char sc1, sc2; int fd; char buffer[6]; int ibuffer[7]; printf(" sizeof(uc1): %d 1\n", sizeof(uc1)); printf(" sizeof(sc1): %d 1\n", sizeof(sc1)); printf(" sizeof(u1): %d 4\n", sizeof(u1)); printf(" sizeof(s1): %d 4\n", sizeof(s1)); printf(" sizeof(aaa): %d 4\n", sizeof(aaa)); printf(" sizeof(bbb): %d 4\n", sizeof(bbb)); printf(" sizeof(gc): %d 1\n", sizeof(gc)); printf(" sizeof(buffer): %d 6\n", sizeof(buffer)); printf(" sizeof(ibuffer): %d 28\n", sizeof(ibuffer)); printf(" sizeof(char): %d 1\n", sizeof(char)); printf(" sizeof(int): %d 4\n", sizeof(int)); printf(" sizeof(gbuffer): %d 3\n", sizeof(gbuffer)); printf(" sizeof(gibuffer): %d 16\n", sizeof(gibuffer)); // sizeof(ibuffer[0]) is not supported, so the following can be used... printf("sizeof(ibuffer)/sizeof(int): %d 7\n", sizeof(ibuffer)/sizeof(int)); aaa = 1; bbb = 2; la = 4; printf("%d 1\n", aaa); printf("%d 2\n", bbb); printf("%d 4\n", la); uc1 = 0x80; sc1 = 0x80; s1 = uc1; s2 = sc1; printf("unsigned char (0x80) -> int: %d 128\n", s1); printf(" signed char (0x80) -> int: %d -128\n", s2); u1 = uc1; u2 = sc1; printf("unsigned char (0x80) -> unsigned: %d 128\n", u1); printf(" signed char (0x80) -> unsigned: %d -128\n", u2); la = errno; printf("errno: %d 0\n", la); write(1, "abcd ", 5); la = errno; printf("errno after good write call: %d 0\n", la); write(10, "abcde", 5); la = errno; printf("errno after bad write call: %d 9\n", la); write(1, "abcd ", 5); la = errno; printf("good write after failed should not overwrite errno: %d 9\n", la); errno = 0; write(1, "abcd ", 5); la = errno; printf("good write after errno set to zero: %d 0\n", la); la = write(1, "abcd ", 5); printf("write() return: %d 5\n", la); la = write(10, "abcd ", 5); printf("write(bad fd) return: %d -1\n", la); fd = open("/a.txt", O_WRONLY | O_CREAT, 0666); if (fd != -1) { printf("open success\n"); la = write(fd, "abcd\n", 5); if (la == 5) printf("write success\n"); else printf("write failed\n"); la = close(fd); if (la != -1) printf("close success\n"); else printf("close failed\n"); } else { printf("open failed\n"); } buffer[0] = 0; buffer[1] = 0; buffer[2] = 0; buffer[3] = 0; buffer[4] = 0; buffer[5] = 0; fd = open("/a.txt", O_RDONLY, 0666); if (fd != -1) { printf("open success\n"); la = read(fd, buffer, 5); printf(buffer); if (la == 5) printf("read success\n"); else printf("read failed\n"); la = close(fd); if (la != -1) printf("close success\n"); else printf("close failed\n"); } else { printf("open failed\n"); } if (buffer[0] != 'a') printf("data0 readback from file MISMATCH\n"); if (buffer[1] != 'b') printf("data1 readback from file MISMATCH\n"); if (buffer[2] != 'c') printf("data2 readback from file MISMATCH\n"); if (buffer[3] != 'd') printf("data3 readback from file MISMATCH\n"); if (buffer[4] != '\n') printf("data4 readback from file MISMATCH\n"); if (buffer[0] != 'a' || buffer[1] != 'b' || buffer[2] != 'c' || buffer[3] != 'd' || buffer[4] != '\n') { printf("data readback from file MISMATCH\n"); } else { printf("data readback from file OK\n"); } } ================================================ FILE: share/examples/smallc/test3.c ================================================ main() { int t; t = 0; if (t) printt(t, "failure"); else printt(t, "success"); t = 1; if (t) printt(t, "success"); else printt(t, "failure"); t = 8; if (t) printt(t, "success"); else printt(t, "failure"); t = -2; if (t) printt(t, "success"); else printt(t, "failure"); printf("\n"); t = 4; printf("switch test: "); switch (t) { case 3: printf("failure"); break; case 4: printf("success"); break; case 5: printf("failure"); break; } printf("\n"); printf("switch fallthrough test: "); switch (t) { case 3: printf("failure"); break; case 4: printf("OKSOFAR: "); case 5: printf("success if oksofar printed before this in caps"); break; } printf("\n"); } printt (t, str) int t; char *str; { printf("bool test on value %d %s\n", t, str); } ================================================ FILE: share/examples/smallc/webserver.c ================================================ /* * Web server, written in SmallC. * * A simple web server that shows the value of the analog input pins. * using an Arduino Wiznet Ethernet shield. * * 18 Dec 2009 created by David A. Mellis * 4 Sep 2010 modified by Tom Igoe * 16 Apr 2012 ported to RetroBSD by Serge Vakulenko */ #include #include #include #include int client [CLIENT_SIZE]; char buf [80]; main() { /* Initialize the Ethernet server library * with the IP address and port you want to use * (port 80 is default for HTTP). */ ethernet_init (); server_init (80); for (;;) { /* Listen for incoming clients. */ if (server_available (client)) { process_request(); } } } process_request() { int current_line_is_blank; int c, fd, pnum, value; /* An http request ends with a blank line. */ current_line_is_blank = 1; /* Parse the http request. */ while (client_connected (client)) { if (client_available (client)) { c = client_getc (client); /* If you've gotten to the end of the line (received * a newline character) and the line is blank, the http * request has ended, so you can send a reply. */ if (c == '\n' && current_line_is_blank) break; if (c == '\n') { /* You're starting a new line. */ current_line_is_blank = 1; } else if (c != '\r') { /* You've gotten a character on the current line. */ current_line_is_blank = 0; } } } /* Send a standard http response header. */ client_puts (client, "HTTP/1.1 200 OK\n"); client_puts (client, "Content-Type: text/html\n\n"); /* Output the value of each digital pin. */ fd = open ("/dev/porta", O_RDONLY); if (fd < 0) { client_puts (client, "Failed to open /dev/porta\n"); } else { for (pnum = 0; pnum < 6; pnum++) { value = ioctl (fd, GPIO_POLL | GPIO_PORT (pnum), 0); sprintf (buf, "PORT%c = 0x%04x
\n", pnum+'A', value); client_puts (client, buf); } close (fd); } /* Give the web browser time to receive the data. */ usleep (1000); /* Close the connection. */ client_stop (client); } ================================================ FILE: share/examples/yacc/Makefile ================================================ all: config.c cpy.c egrep.c expr.c gram.c grammar.c parser.c %.c: %.y yacc $< mv y.tab.c $@ clean: rm -f *.c yacc.acts yacc.tmp y.output y.tab.[ch] ================================================ FILE: share/examples/yacc/config.y ================================================ %union { char *str; int val; struct file_list *file; struct idlst *lst; } %token AND %token ANY %token ARCHITECTURE %token AT %token BOARD %token COMMA %token CONFIG %token CONTROLLER %token CPU %token CSR %token DEVICE %token DRIVE %token DST %token DUMPS %token EQUALS %token FLAGS %token HZ %token INVERT %token LDSCRIPT %token MAJOR %token MAXUSERS %token MINOR %token MINUS %token ON %token OPTIONS %token MAKEOPTIONS %token PINS %token PRIORITY %token SERVICE %token SIGNAL %token ROOT %token SEMICOLON %token SEQUENTIAL %token SIZE %token SWAP %token TIMEZONE %token TRACE %token VECTOR %token ID %token NUMBER %token FPNUMBER %token PIN %type Save_id %type Opt_value %type Dev %type Id_list %type optional_size %type optional_sflag %type optional_invert %type device_name %type major_minor %type root_device_spec %type dump_device_spec %type swap_device_spec %{ /* * Copyright (c) 1988, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)config.y 8.1 (Berkeley) 6/6/93 */ #include "config.h" #include #include struct device cur; struct device *curp = 0; char *temp_id; char *val_id; int yylex(void); void yyerror(char *s); void newdev(struct device *dp); void mkconf(char *sysname); struct file_list *newflist(u_char ftype); void mkswap(struct file_list *system, struct file_list *fl, int size, int flag); struct device *connect(char *dev, int num); struct device *huhcon(char *dev); void check_nexus(struct device *dev, int num); void check_tz(void); void checksystemspec(struct file_list *fl); void verifysystemspecs(void); dev_t *verifyswap(struct file_list *fl, dev_t checked[], dev_t *pchecked); int alreadychecked(dev_t dev, dev_t list[], dev_t *last); void deverror(char *systemname, char *devtype); int finddev(dev_t dev); %} %% Configuration: Many_specs { verifysystemspecs(); } ; Many_specs: Many_specs Spec | /* lambda */ ; Spec: Device_spec SEMICOLON { newdev(&cur); } | Config_spec SEMICOLON | TRACE SEMICOLON { do_trace = !do_trace; } | SEMICOLON | error SEMICOLON ; Config_spec: ARCHITECTURE Save_id { if (strcmp($2, "pic32") == 0) { arch = ARCH_PIC32; archname = "pic32"; } else if (strcmp($2, "stm32") == 0) { arch = ARCH_STM32; archname = "stm32"; } else yyerror("Unknown architecture"); } | CPU Save_id { struct cputype *cp = (struct cputype *)malloc(sizeof (struct cputype)); cp->cpu_name = strdup($2); cp->cpu_next = cputype; cputype = cp; free(temp_id); } | OPTIONS Opt_list | MAKEOPTIONS Mkopt_list | BOARD ID { board = strdup($2); } | LDSCRIPT ID { ldscript = strdup($2); } | SIGNAL ID PINS PIN optional_invert { struct signal *s = (struct signal*) malloc(sizeof(struct signal)); s->sig_name = strdup($2); s->sig_next = siglist; s->sig_pin = $4; s->sig_invert = $5; siglist = s; } | System_spec | TIMEZONE NUMBER { zone = 60 * $2; check_tz(); } | TIMEZONE NUMBER DST NUMBER { zone = 60 * $2; dst = $4; check_tz(); } | TIMEZONE NUMBER DST { zone = 60 * $2; dst = 1; check_tz(); } | TIMEZONE FPNUMBER { zone = $2; check_tz(); } | TIMEZONE FPNUMBER DST NUMBER { zone = $2; dst = $4; check_tz(); } | TIMEZONE FPNUMBER DST { zone = $2; dst = 1; check_tz(); } | TIMEZONE MINUS NUMBER { zone = -60 * $3; check_tz(); } | TIMEZONE MINUS NUMBER DST NUMBER { zone = -60 * $3; dst = $5; check_tz(); } | TIMEZONE MINUS NUMBER DST { zone = -60 * $3; dst = 1; check_tz(); } | TIMEZONE MINUS FPNUMBER { zone = -$3; check_tz(); } | TIMEZONE MINUS FPNUMBER DST NUMBER { zone = -$3; dst = $5; check_tz(); } | TIMEZONE MINUS FPNUMBER DST { zone = -$3; dst = 1; check_tz(); } | MAXUSERS NUMBER { maxusers = $2; } ; System_spec: System_id System_parameter_list { checksystemspec(*confp); } ; System_id: CONFIG Save_id { mkconf($2); } ; System_parameter_list: System_parameter_list System_parameter | System_parameter ; System_parameter: swap_spec | root_spec | dump_spec ; swap_spec: SWAP optional_on swap_device_list ; swap_device_list: swap_device_list AND swap_device | swap_device ; swap_device: swap_device_spec optional_size optional_sflag { mkswap(*confp, $1, $2, $3); } ; swap_device_spec: device_name { struct file_list *fl = newflist(SWAPSPEC); if (eq($1, "generic")) fl->f_fn = $1; else { fl->f_swapdev = nametodev($1, 0); fl->f_fn = devtoname(fl->f_swapdev); } $$ = fl; } | major_minor { struct file_list *fl = newflist(SWAPSPEC); fl->f_swapdev = $1; fl->f_fn = devtoname($1); $$ = fl; } ; root_spec: ROOT optional_on root_device_spec { struct file_list *fl = *confp; if (fl && fl->f_rootdev != NODEV) yyerror("extraneous root device specification"); else fl->f_rootdev = $3; } ; root_device_spec: device_name { $$ = nametodev($1, 0); } | major_minor ; dump_spec: DUMPS optional_on dump_device_spec { struct file_list *fl = *confp; if (fl && fl->f_dumpdev != NODEV) yyerror("extraneous dump device specification"); else fl->f_dumpdev = $3; } ; dump_device_spec: device_name { $$ = nametodev($1, 0); } | major_minor ; major_minor: MAJOR NUMBER MINOR NUMBER { $$ = makedev($2, $4); } ; optional_on: ON | /* empty */ ; optional_size: SIZE NUMBER { $$ = $2; } | /* empty */ { $$ = 0; } ; optional_sflag: SEQUENTIAL { $$ = 2; } | /* empty */ { $$ = 0; } ; optional_invert: INVERT { $$ = 1; } | /* empty */ { $$ = 0; } ; device_name: Save_id { $$ = $1; } | Save_id NUMBER { char buf[80]; (void) sprintf(buf, "%s%d", $1, $2); $$ = strdup(buf); free($1); } | Save_id NUMBER ID { char buf[80]; (void) sprintf(buf, "%s%d%s", $1, $2, $3); $$ = strdup(buf); free($1); } ; Opt_list: Opt_list COMMA Option | Option ; Option: Save_id { struct opt *op = (struct opt *)malloc(sizeof (struct opt)); op->op_name = strdup($1); op->op_next = opt; op->op_value = 0; opt = op; free(temp_id); } | Save_id EQUALS Opt_value { struct opt *op = (struct opt *)malloc(sizeof (struct opt)); op->op_name = strdup($1); op->op_next = opt; op->op_value = strdup($3); opt = op; free(temp_id); free(val_id); } ; Opt_value: ID { $$ = val_id = strdup($1); } | NUMBER { char nb[16]; (void) sprintf(nb, "%d", $1); $$ = val_id = strdup(nb); } ; Save_id: ID { $$ = temp_id = strdup($1); } ; Mkopt_list: Mkopt_list COMMA Mkoption | Mkoption ; Mkoption: Save_id EQUALS Opt_value { struct opt *op = (struct opt *)malloc(sizeof (struct opt)); op->op_name = strdup($1); op->op_next = mkopt; op->op_value = strdup($3); mkopt = op; free(temp_id); free(val_id); } ; Dev: ID { $$ = strdup($1); } ; Device_spec: DEVICE Dev_name Dev_info Int_spec { cur.d_type = DEVICE; } | CONTROLLER Dev_name Dev_info Int_spec { cur.d_type = CONTROLLER; } | SERVICE Init_dev Dev { cur.d_name = $3; cur.d_type = SERVICE; } | SERVICE Init_dev Dev NUMBER { cur.d_name = $3; cur.d_type = SERVICE; cur.d_slave = $4; } ; Dev_name: Init_dev Dev NUMBER { cur.d_name = $2; cur.d_unit = $3; } | Init_dev Dev { cur.d_name = $2; } ; Init_dev: /* lambda */ { init_dev(&cur); } ; Dev_info: Con_info Info_list | Info_list | /* lambda */ ; Con_info: AT Dev NUMBER { cur.d_conn = connect($2, $3); } ; Info_list: Info_list Info | /* lambda */ ; Info: CSR NUMBER { cur.d_addr = $2; } | DRIVE NUMBER { cur.d_drive = $2; } | FLAGS NUMBER { cur.d_flags = $2; } | PINS Pin_list ; Int_spec: VECTOR Id_list { cur.d_vec = $2; } | PRIORITY NUMBER { cur.d_pri = $2; } | /* lambda */ ; Id_list: Save_id { struct idlst *a = (struct idlst *)malloc(sizeof(struct idlst)); a->id = $1; a->id_next = 0; $$ = a; } | Save_id Id_list { struct idlst *a = (struct idlst *)malloc(sizeof(struct idlst)); a->id = $1; a->id_next = $2; $$ = a; } ; Pin_list: PIN { cur.d_pins[cur.d_npins++] = $1; } | PIN COMMA Pin_list { cur.d_pins[cur.d_npins++] = $1; } ; %% void yyerror(char *s) { fprintf(stderr, "config: line %d: %s\n", yyline + 1, s); } /* * add a device to the list of devices */ void newdev(struct device *dp) { register struct device *np; np = (struct device *) malloc(sizeof *np); *np = *dp; np->d_next = 0; if (curp == 0) dtab = np; else curp->d_next = np; curp = np; } /* * note that a configuration should be made */ void mkconf(char *sysname) { register struct file_list *fl, **flp; fl = (struct file_list *) malloc(sizeof *fl); fl->f_type = SYSTEMSPEC; fl->f_needs = sysname; fl->f_rootdev = NODEV; fl->f_dumpdev = NODEV; fl->f_fn = 0; fl->f_next = 0; for (flp = confp; *flp; flp = &(*flp)->f_next) ; *flp = fl; confp = flp; } struct file_list * newflist(u_char ftype) { struct file_list *fl = (struct file_list *)malloc(sizeof (*fl)); fl->f_type = ftype; fl->f_next = 0; fl->f_swapdev = NODEV; fl->f_swapsize = 0; fl->f_needs = 0; fl->f_fn = 0; return (fl); } /* * Add a swap device to the system's configuration */ void mkswap(struct file_list *system, struct file_list *fl, int size, int flag) { register struct file_list **flp; if (system == 0 || system->f_type != SYSTEMSPEC) { yyerror("\"swap\" spec precedes \"config\" specification"); return; } if (size < 0) { yyerror("illegal swap partition size"); return; } /* * Append swap description to the end of the list. */ flp = &system->f_next; for (; *flp && (*flp)->f_type == SWAPSPEC; flp = &(*flp)->f_next) ; fl->f_next = *flp; *flp = fl; fl->f_swapsize = size; fl->f_swapflag = flag; /* * If first swap device for this system, * set up f_fn field to insure swap * files are created with unique names. */ if (system->f_fn) return; if (eq(fl->f_fn, "generic")) system->f_fn = strdup(fl->f_fn); else system->f_fn = strdup(system->f_needs); } /* * find the pointer to connect to the given device and number. * returns 0 if no such device and prints an error message */ struct device * connect(char *dev, int num) { register struct device *dp; if (num == QUES) return (huhcon(dev)); for (dp = dtab; dp != 0; dp = dp->d_next) { if ((num != dp->d_unit) || !eq(dev, dp->d_name)) continue; if (dp->d_type != CONTROLLER) { (void) sprintf(errbuf, "%s connected to non-controller", dev); yyerror(errbuf); return (0); } return (dp); } (void) sprintf(errbuf, "%s %d not defined", dev, num); yyerror(errbuf); return (0); } /* * connect to an unspecific thing */ struct device * huhcon(char *dev) { register struct device *dp, *dcp; struct device rdev; int oldtype; /* * First make certain that there are some of these to wildcard on */ for (dp = dtab; dp != 0; dp = dp->d_next) if (eq(dp->d_name, dev)) break; if (dp == 0) { (void) sprintf(errbuf, "no %s's to wildcard", dev); yyerror(errbuf); return (0); } oldtype = dp->d_type; dcp = dp->d_conn; /* * Now see if there is already a wildcard entry for this device * (e.g. Search for a "uba ?") */ for (; dp != 0; dp = dp->d_next) if (eq(dev, dp->d_name) && dp->d_unit == -1) break; /* * If there isn't, make one because everything needs to be connected * to something. */ if (dp == 0) { dp = &rdev; init_dev(dp); dp->d_unit = QUES; dp->d_name = strdup(dev); dp->d_type = oldtype; newdev(dp); dp = curp; /* * Connect it to the same thing that other similar things are * connected to, but make sure it is a wildcard unit * (e.g. up connected to sc ?, here we make connect sc? to a * uba?). If other things like this * aren't connected to anything, then make the same * connection, else call ourself to connect to another * unspecific device. */ if (dcp == 0) dp->d_conn = dcp; else dp->d_conn = connect(dcp->d_name, QUES); } return (dp); } void init_dev(struct device *dp) { dp->d_name = "OHNO!!!"; dp->d_type = DEVICE; dp->d_conn = 0; dp->d_vec = 0; dp->d_addr = dp->d_flags; dp->d_pri = -1; dp->d_slave = dp->d_drive = dp->d_unit = UNKNOWN; dp->d_port = (char *)0; dp->d_irq = -1; dp->d_drq = -1; dp->d_maddr = 0; dp->d_msize = 0; dp->d_npins = 0; dp->d_flags = 0; dp->d_mask = "null"; } /* * make certain that this is a reasonable type of thing to connect to a nexus */ void check_nexus(struct device *dev, int num) { switch (arch) { case ARCH_PIC32: break; case ARCH_STM32: break; } } /* * Check the timezone to make certain it is sensible */ void check_tz(void) { if (abs(zone) > 12 * 60) yyerror("timezone is unreasonable"); else hadtz = 1; } /* * Check system specification and apply defaulting * rules on root, argument, dump, and swap devices. */ void checksystemspec(struct file_list *fl) { char buf[BUFSIZ]; register struct file_list *swap; int generic; if (fl == 0 || fl->f_type != SYSTEMSPEC) { yyerror("internal error, bad system specification"); exit(1); } swap = fl->f_next; generic = swap && swap->f_type == SWAPSPEC && eq(swap->f_fn, "generic"); if (fl->f_rootdev == NODEV && !generic) { yyerror("no root device specified"); exit(1); } /* * Default swap area to be in 'b' partition of root's * device. If root specified to be other than on 'a' * partition, give warning, something probably amiss. */ if (swap == 0 || swap->f_type != SWAPSPEC) { dev_t dev; swap = newflist(SWAPSPEC); dev = fl->f_rootdev; if (minor(dev) & 07) { sprintf(buf, "Warning, swap defaulted to 'b' partition with root on '%c' partition", (minor(dev) & 07) + 'a' - 1); yyerror(buf); } swap->f_swapdev = makedev(major(dev), (minor(dev) &~ 07) | ('b' - 'a' + 1)); swap->f_fn = devtoname(swap->f_swapdev); mkswap(fl, swap, 0, 0); } /* * Make sure a generic swap isn't specified, along with * other stuff (user must really be confused). */ if (generic) { if (fl->f_rootdev != NODEV) yyerror("root device specified with generic swap"); if (fl->f_dumpdev != NODEV) yyerror("dump device specified with generic swap"); return; } /* * Default dump device and warn if place is not a * swap area. */ if (fl->f_dumpdev == NODEV) fl->f_dumpdev = swap->f_swapdev; if (fl->f_dumpdev != swap->f_swapdev) { struct file_list *p = swap->f_next; for (; p && p->f_type == SWAPSPEC; p = p->f_next) if (fl->f_dumpdev == p->f_swapdev) return; (void) sprintf(buf, "Warning: dump device is not a swap partition"); yyerror(buf); } } /* * Verify all devices specified in the system specification * are present in the device specifications. */ void verifysystemspecs(void) { register struct file_list *fl; dev_t checked[50]; register dev_t *pchecked = checked; for (fl = conf_list; fl; fl = fl->f_next) { if (fl->f_type != SYSTEMSPEC) continue; if (!finddev(fl->f_rootdev)) deverror(fl->f_needs, "root"); *pchecked++ = fl->f_rootdev; pchecked = verifyswap(fl->f_next, checked, pchecked); #define samedev(dev1, dev2) \ ((minor(dev1) &~ 07) != (minor(dev2) &~ 07)) if (!alreadychecked(fl->f_dumpdev, checked, pchecked)) { if (!finddev(fl->f_dumpdev)) deverror(fl->f_needs, "dump"); *pchecked++ = fl->f_dumpdev; } } } /* * Do as above, but for swap devices. */ dev_t * verifyswap(struct file_list *fl, dev_t checked[], dev_t *pchecked) { for (;fl && fl->f_type == SWAPSPEC; fl = fl->f_next) { if (eq(fl->f_fn, "generic")) continue; if (alreadychecked(fl->f_swapdev, checked, pchecked)) continue; if (!finddev(fl->f_swapdev)) fprintf(stderr, "config: swap device %s not configured", fl->f_fn); *pchecked++ = fl->f_swapdev; } return (pchecked); } /* * Has a device already been checked * for it's existence in the configuration? */ int alreadychecked(dev_t dev, dev_t *list, dev_t *last) { register dev_t *p; for (p = list; p < last; p++) if (samedev(*p, dev)) return (1); return (0); } void deverror(char *systemname, char *devtype) { fprintf(stderr, "config: %s: %s device not configured\n", systemname, devtype); } /* * Look for the device in the list of * configured hardware devices. Must * take into account stuff wildcarded. */ /*ARGSUSED*/ int finddev(dev_t dev) { /* punt on this right now */ return (1); } ================================================ FILE: share/examples/yacc/cpy.y ================================================ /* $Id: cpy.y,v 1.18 2010/02/25 15:49:00 ragge Exp $ */ /* * Copyright (c) 2004 Anders Magnusson (ragge@ludd.luth.se). * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * Copyright(C) Caldera International Inc. 2001-2002. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * Redistributions of source code and documentation must retain the above * copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed or owned by Caldera * International, Inc. * Neither the name of Caldera International, Inc. nor the names of other * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA * INTERNATIONAL, INC. AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL CALDERA INTERNATIONAL, INC. BE LIABLE * FOR ANY DIRECT, INDIRECT INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OFLIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ %{ #include "cpp.h" void yyerror(const char *); int yylex(void); int setd(int l, int r); #define EVALUNARY(tok, l, r) l.nd_val = tok r.nd_val; l.op = r.op #define EVALBIN(tok, d, l, r) \ d.op = setd(l.op, r.op); d.nd_val = l.nd_val tok r.nd_val #define EVALUBIN(tok, d, l, r, t) \ d.op = setd(l.op, r.op); \ if (d.op == NUMBER) d.nd_val = l.nd_val tok r.nd_val; \ else d.nd_uval = l.nd_uval tok r.nd_uval; \ if (t && d.op) d.op = NUMBER #define XEVALUBIN(tok, d, l, r) \ if (r.nd_val) { EVALUBIN(tok, d, l, r, 0); } else d.op = 0 %} %token stop %token EQ NE LE GE LS RS %token ANDAND OROR IDENT NUMBER UNUMBER DEFINED /* * The following terminals are not used in the yacc code. */ %token STRING WSPACE CMNT %left ',' %right '?' ':' %left OROR %left ANDAND %left '|' '^' %left '&' %nonassoc EQ NE %nonassoc '<' '>' LE GE %left LS RS %left '+' '-' %left '*' '/' '%' %right '!' '~' UMINUS %left '(' %union { struct nd node; } %type term e NUMBER UNUMBER %% S: e '\n' { if ($1.op == 0) error("division by zero"); return $1.nd_val; } e: e '*' e { EVALUBIN(*, $$, $1, $3, 0); } | e '/' e { XEVALUBIN(/, $$, $1, $3); } | e '%' e { XEVALUBIN(%, $$, $1, $3); } | e '+' e { EVALBIN(+, $$, $1, $3); } | e '-' e { EVALBIN(-, $$, $1, $3); } | e LS e { EVALBIN(<<, $$, $1, $3); } | e RS e { EVALUBIN(>>, $$, $1, $3, 0); } | e '<' e { EVALUBIN(<, $$, $1, $3, 1); } | e '>' e { EVALUBIN(>, $$, $1, $3, 1); } | e LE e { EVALUBIN(<=, $$, $1, $3, 1); } | e GE e { EVALUBIN(>=, $$, $1, $3, 1); } | e EQ e { EVALUBIN(==, $$, $1, $3, 1); } | e NE e { EVALUBIN(!=, $$, $1, $3, 1); } | e '&' e { EVALBIN(&, $$, $1, $3); } | e '^' e { EVALBIN(^, $$, $1, $3); } | e '|' e { EVALBIN(|, $$, $1, $3); } | e ANDAND e { $$ = $1; if ($1.nd_val) { $$.op = setd($1.op, $3.op); $$.nd_val = ($3.nd_val != 0); } if ($$.op == UNUMBER) $$.op = NUMBER; } | e OROR e { if ($1.nd_val != 0) { $$.nd_val = ($1.nd_val != 0); $$.op = $1.op; } else { $$.nd_val = ($3.nd_val != 0); $$.op = setd($1.op, $3.op); } if ($$.op == UNUMBER) $$.op = NUMBER; } | e '?' e ':' e { if ($1.op == 0) $$ = $1; else if ($1.nd_val) $$ = $3; else $$ = $5; } | e ',' e { $$.op = setd($1.op, $3.op); $$.nd_val = $3.nd_val; if ($$.op) $$.op = $3.op; } | term {$$ = $1;} term: '-' term %prec UMINUS { EVALUNARY(-, $$, $2); } | '+' term %prec UMINUS {$$ = $2;} | '!' term { $$.nd_val = ! $2.nd_val; $$.op = $2.op ? NUMBER : 0; } | '~' term { EVALUNARY(~, $$, $2); } | '(' e ')' {$$ = $2;} | DEFINED '(' NUMBER ')' {$$= $3;} | DEFINED NUMBER {$$ = $2;} | NUMBER {$$ = $1;} %% void yyerror(const char *err) { error(err); } /* * Set return type of an expression. */ int setd(int l, int r) { if (!l || !r) return 0; /* div by zero involved */ if (l == UNUMBER || r == UNUMBER) return UNUMBER; return NUMBER; } ================================================ FILE: share/examples/yacc/egrep.y ================================================ /* * egrep -- print lines containing (or not containing) a regular expression * * status returns: * 0 - ok, and some matches * 1 - ok, but no matches * 2 - some error */ %token CHAR DOT CCL NCCL OR CAT STAR PLUS QUEST %left OR %left CHAR DOT CCL NCCL '(' %left CAT %left STAR PLUS QUEST %{ #include #include #include #include #include #include #define BLKSIZE 8192 #define MAXLIN 350 #define MAXPOS 4000 #define NCHARS 128 #define NSTATES 128 #define FINAL -1 void yyerror(); int yylex(); int nextch(); void synerror(); int enter(); int cclenter(); int node(); int unary(); void overflo(); void cfoll(); void cgotofn(); int cstate(); int member(); int notin(); void add(); void follow(); void execute(); char gotofn[NSTATES][NCHARS]; int state[NSTATES]; char out[NSTATES]; int line = 1; int name[MAXLIN]; int left[MAXLIN]; int right[MAXLIN]; int parent[MAXLIN]; int foll[MAXLIN]; int positions[MAXPOS]; char chars[MAXLIN]; int nxtpos; int nxtchar = 0; int tmpstat[MAXLIN]; int initstat[MAXLIN]; int xstate; int count; int icount; char *input; FILE *exprfile; long lnum; int bflag; int cflag; int fflag; int lflag; int nflag; int hflag = 1; int sflag; int vflag; int retcode = 0; int nfile; long blkno; long tln; int nsucc; int f; char *fname; %} %% s: t { unary(FINAL, $1); line--; } ; t: b r { $$ = node(CAT, $1, $2); } | OR b r OR { $$ = node(CAT, $2, $3); } | OR b r { $$ = node(CAT, $2, $3); } | b r OR { $$ = node(CAT, $1, $2); } ; b: { $$ = enter(DOT); $$ = unary(STAR, $$); } ; r: CHAR { $$ = enter($1); } | DOT { $$ = enter(DOT); } | CCL { $$ = cclenter(CCL); } | NCCL { $$ = cclenter(NCCL); } ; r: r OR r { $$ = node(OR, $1, $3); } | r r %prec CAT { $$ = node(CAT, $1, $2); } | r STAR { $$ = unary(STAR, $1); } | r PLUS { $$ = unary(PLUS, $1); } | r QUEST { $$ = unary(QUEST, $1); } | '(' r ')' { $$ = $2; } | error ; %% void yyerror(s) int s; { fprintf(stderr, "egrep: %s\n", s); exit(2); } int yylex() { extern int yylval; int cclcnt, x; register char c, d; switch(c = nextch()) { case '$': case '^': c = '\n'; goto defchar; case '|': return (OR); case '*': return (STAR); case '+': return (PLUS); case '?': return (QUEST); case '(': return (c); case ')': return (c); case '.': return (DOT); case '\0': return (0); case '\n': return (OR); case '[': x = CCL; cclcnt = 0; count = nxtchar++; if ((c = nextch()) == '^') { x = NCCL; c = nextch(); } do { if (c == '\0') synerror(); if (c == '-' && cclcnt > 0 && chars[nxtchar-1] != 0) { if ((d = nextch()) != 0) { c = chars[nxtchar-1]; while (c < d) { if (nxtchar >= MAXLIN) overflo(); chars[nxtchar++] = ++c; cclcnt++; } continue; } } if (nxtchar >= MAXLIN) overflo(); chars[nxtchar++] = c; cclcnt++; } while ((c = nextch()) != ']'); chars[count] = cclcnt; return (x); case '\\': if ((c = nextch()) == '\0') synerror(); defchar: default: yylval = c; return (CHAR); } } int nextch() { register char c; if (fflag) { if ((c = getc(exprfile)) == EOF) { fclose(exprfile); return(0); } } else c = *input++; return(c); } void synerror() { fprintf(stderr, "egrep: syntax error\n"); exit(2); } int enter(x) int x; { if(line >= MAXLIN) overflo(); name[line] = x; left[line] = 0; right[line] = 0; return(line++); } int cclenter(x) int x; { register int linno; linno = enter(x); right[linno] = count; return (linno); } int node(x, l, r) int x, l, r; { if(line >= MAXLIN) overflo(); name[line] = x; left[line] = l; right[line] = r; parent[l] = line; parent[r] = line; return(line++); } int unary(x, d) int x, d; { if(line >= MAXLIN) overflo(); name[line] = x; left[line] = d; right[line] = 0; parent[d] = line; return(line++); } void overflo() { fprintf(stderr, "egrep: regular expression too long\n"); exit(2); } void cfoll(v) int v; { register int i; if (left[v] == 0) { count = 0; for (i=1; i<=line; i++) tmpstat[i] = 0; follow(v); add(foll, v); } else if (right[v] == 0) cfoll(left[v]); else { cfoll(left[v]); cfoll(right[v]); } } void cgotofn() { register int c, i, k; int n, s; char symbol[NCHARS]; int j, nc, pc, pos; int curpos, num; int number, newpos; count = 0; for (n=3; n<=line; n++) tmpstat[n] = 0; if (cstate(line-1)==0) { tmpstat[line] = 1; count++; out[0] = 1; } for (n=3; n<=line; n++) initstat[n] = tmpstat[n]; count--; /*leave out position 1 */ icount = count; tmpstat[1] = 0; add(state, 0); n = 0; for (s=0; s<=n; s++) { if (out[s] == 1) continue; for (i=0; i= 0) { if (c < NCHARS) symbol[c] = 1; else if (c == DOT) { for (k=0; k= 0) if ( (k == c) | (k == DOT) | (k == CCL && member(c, right[curpos], 1)) | (k == NCCL && member(c, right[curpos], 0)) ) { number = positions[foll[curpos]]; newpos = foll[curpos] + 1; for (k=0; k= NSTATES) overflo(); add(state, ++n); if (tmpstat[line] == 1) out[n] = 1; gotofn[s][c] = n; } else { gotofn[s][c] = xstate; } } } } } int cstate(v) int v; { register int b; if (left[v] == 0) { if (tmpstat[v] != 1) { tmpstat[v] = 1; count++; } return(1); } else if (right[v] == 0) { if (cstate(left[v]) == 0) return (0); else if (name[v] == PLUS) return (1); else return (0); } else if (name[v] == CAT) { if (cstate(left[v]) == 0 && cstate(right[v]) == 0) return (0); else return (1); } else { /* name[v] == OR */ b = cstate(right[v]); if (cstate(left[v]) == 0 || b == 0) return (0); else return (1); } } int member(symb, set, torf) int symb, set, torf; { register int i, num, pos; num = chars[set]; pos = set + 1; for (i=0; i MAXPOS) overflo(); array[n] = nxtpos; positions[nxtpos++] = count; for (i=3; i <= line; i++) { if (tmpstat[i] == 1) { positions[nxtpos++] = i; } } } void follow(v) int v; { int p; if (v == line) return; p = parent[v]; switch(name[p]) { case STAR: case PLUS: cstate(v); follow(p); return; case OR: case QUEST: follow(p); return; case CAT: if (v == left[p]) { if (cstate(right[p]) == 0) { follow(p); return; } } else follow(p); return; case FINAL: if (tmpstat[line] != 1) { tmpstat[line] = 1; count++; } return; } } int main(argc, argv) int argc; char **argv; { while (--argc > 0 && (++argv)[0][0]=='-') switch (argv[0][1]) { case 's': sflag++; continue; case 'h': hflag = 0; continue; case 'b': bflag++; continue; case 'c': cflag++; continue; case 'e': argc--; argv++; goto out; case 'f': fflag++; continue; case 'l': lflag++; continue; case 'n': nflag++; continue; case 'v': vflag++; continue; default: fprintf(stderr, "egrep: unknown flag\n"); continue; } out: if (argc<=0) exit(2); if (fflag) { fname = *argv; exprfile = fopen(fname, "r"); if (exprfile == (FILE *)NULL) { fprintf(stderr, "egrep: can't open %s\n", fname); exit(2); } } else input = *argv; argc--; argv++; yyparse(); cfoll(line-1); cgotofn(); nfile = argc; if (argc<=0) { if (lflag) exit(1); execute(0); } else while (--argc >= 0) { execute(*argv); argv++; } exit(retcode != 0 ? retcode : nsucc == 0); } void execute(file) char *file; { register char *p; register int cstat; register int ccount; static char *buf; static int blksize; struct stat stb; char *nlp; int istat; if (file) { if ((f = open(file, 0)) < 0) { fprintf(stderr, "egrep: can't open %s\n", file); retcode = 2; return; } } else f = 0; if (buf == NULL) { if (fstat(f, &stb) > 0 && stb.st_blksize > 0) blksize = stb.st_blksize; else blksize = BLKSIZE; buf = (char *)malloc(2*blksize); if (buf == NULL) { fprintf(stderr, "egrep: no memory for %s\n", file); retcode = 2; return; } } ccount = 0; lnum = 1; tln = 0; blkno = 0; p = buf; nlp = p; if ((ccount = read(f,p,blksize))<=0) goto done; istat = cstat = gotofn[0]['\n']; if (out[cstat]) goto found; for (;;) { cstat = gotofn[cstat][*p&0377]; /* all input chars made positive */ if (out[cstat]) { found: for(;;) { if (*p++ == '\n') { if (vflag == 0) { succeed: nsucc = 1; if (cflag) tln++; else if (sflag) ; /* ugh */ else if (lflag) { printf("%s\n", file); close(f); return; } else { if (nfile > 1 && hflag) printf("%s:", file); if (bflag) printf("%ld:", blkno); if (nflag) printf("%ld:", lnum); if (p <= nlp) { while (nlp < &buf[2*blksize]) putchar(*nlp++); nlp = buf; } while (nlp < p) putchar(*nlp++); } } lnum++; nlp = p; if ((out[(cstat=istat)]) == 0) goto brk2; } cfound: if (--ccount <= 0) { if (p <= &buf[blksize]) { if ((ccount = read(f, p, blksize)) <= 0) goto done; } else if (p == &buf[2*blksize]) { p = buf; if ((ccount = read(f, p, blksize)) <= 0) goto done; } else { if ((ccount = read(f, p, &buf[2*blksize]-p)) <= 0) goto done; } blkno += ccount / 512; } } } if (*p++ == '\n') { if (vflag) goto succeed; else { lnum++; nlp = p; if (out[(cstat=istat)]) goto cfound; } } brk2: if (--ccount <= 0) { if (p <= &buf[blksize]) { if ((ccount = read(f, p, blksize)) <= 0) break; } else if (p == &buf[2*blksize]) { p = buf; if ((ccount = read(f, p, blksize)) <= 0) break; } else { if ((ccount = read(f, p, &buf[2*blksize] - p)) <= 0) break; } blkno += ccount / 512; } } done: close(f); if (cflag) { if (nfile > 1) printf("%s:", file); printf("%ld\n", tln); } } ================================================ FILE: share/examples/yacc/expr.y ================================================ /* Yacc productions for "expr" command: */ %token OR AND ADD SUBT MULT DIV REM EQ GT GEQ LT LEQ NEQ %token A_STRING SUBSTR LENGTH INDEX NOARG MATCH /* operators listed below in increasing precedence: */ %left OR %left AND %left EQ LT GT GEQ LEQ NEQ %left ADD SUBT %left MULT DIV REM %left MCH %left MATCH %left SUBSTR %left LENGTH INDEX %% /* a single `expression' is evaluated and printed: */ expression: expr NOARG { printf("%s\n", $1); exit((! strcmp((char*) $1, "0") || ! strcmp((char*) $1, "\0")) ? 1 : 0); } ; expr: '(' expr ')' { $$ = (int) $2; } | expr OR expr { $$ = (int) conju(OR, $1, $3); } | expr AND expr { $$ = (int) conju(AND, $1, $3); } | expr EQ expr { $$ = (int) rel(EQ, $1, $3); } | expr GT expr { $$ = (int) rel(GT, $1, $3); } | expr GEQ expr { $$ = (int) rel(GEQ, $1, $3); } | expr LT expr { $$ = (int) rel(LT, $1, $3); } | expr LEQ expr { $$ = (int) rel(LEQ, $1, $3); } | expr NEQ expr { $$ = (int) rel(NEQ, $1, $3); } | expr ADD expr { $$ = (int) arith(ADD, $1, $3); } | expr SUBT expr { $$ = (int) arith(SUBT, $1, $3); } | expr MULT expr { $$ = (int) arith(MULT, $1, $3); } | expr DIV expr { $$ = (int) arith(DIV, $1, $3); } | expr REM expr { $$ = (int) arith(REM, $1, $3); } | expr MCH expr { $$ = (int) match($1, $3); } | MATCH expr expr { $$ = (int) match($2, $3); } | SUBSTR expr expr expr { $$ = (int) substr($2, $3, $4); } | LENGTH expr { $$ = (int) length($2); } | INDEX expr expr { $$ = (int) cindex($2, $3); } | A_STRING ; %% /* expression command */ #include #include #include #define ESIZE 256 #define error(c) errxx(c) #define EQL(x,y) !strcmp(x,y) int yylex(); char *rel(); char *arith(); char *conju(); char *substr(); char *length(); char *cindex(); char *match(); int ematch(); void errxx(); char *compile(); int step(); int advance(); void getrnge(); int ecmp(); void yyerror(); char **Av; int Ac; int Argi; char Mstring[1][128]; extern int nbra; int main(argc, argv) int argc; char **argv; { Ac = argc; Argi = 1; Av = argv; yyparse(); } char *operators[] = { "|", "&", "+", "-", "*", "/", "%", ":", "=", "==", "<", "<=", ">", ">=", "!=", "match", "substr", "length", "index", "\0" }; int op[] = { OR, AND, ADD, SUBT, MULT, DIV, REM, MCH, EQ, EQ, LT, LEQ, GT, GEQ, NEQ, MATCH, SUBSTR, LENGTH, INDEX }; int yylex() { register char *p; register int i; if(Argi >= Ac) return NOARG; p = Av[Argi++]; if(*p == '(' || *p == ')') return (int)*p; for(i = 0; *operators[i]; ++i) if(EQL(operators[i], p)) return op[i]; yylval = (int) p; return A_STRING; } char * rel(op, r1, r2) int op; register char *r1, *r2; { register long i; if(ematch(r1, "-*[0-9]*$") && ematch(r2, "[0-9]*$")) i = atol(r1) - atol(r2); else i = strcmp(r1, r2); switch(op) { case EQ: i = i==0; break; case GT: i = i>0; break; case GEQ: i = i>=0; break; case LT: i = i<0; break; case LEQ: i = i<=0; break; case NEQ: i = i!=0; break; } return i? "1": "0"; } char * arith(op, r1, r2) int op; char *r1, *r2; { long i1, i2; register char *rv; if(!(ematch(r1, "[0-9]*$") && ematch(r2, "[0-9]*$"))) yyerror("non-numeric argument"); i1 = atol(r1); i2 = atol(r2); switch(op) { case ADD: i1 = i1 + i2; break; case SUBT: i1 = i1 - i2; break; case MULT: i1 = i1 * i2; break; case DIV: i1 = i1 / i2; break; case REM: i1 = i1 % i2; break; } rv = malloc(16); sprintf(rv, "%D", i1); return rv; } char * conju(op, r1, r2) int op; char *r1, *r2; { register char *rv; switch(op) { case OR: if(EQL(r1, "0") || EQL(r1, "")) if(EQL(r2, "0") || EQL(r2, "")) rv = "0"; else rv = r2; else rv = r1; break; case AND: if(EQL(r1, "0") || EQL(r1, "")) rv = "0"; else if(EQL(r2, "0") || EQL(r2, "")) rv = "0"; else rv = r1; break; } return rv; } char *substr(v, s, w) char *v, *s, *w; { register int si, wi; register char *res; si = atol(s); wi = atol(w); while(--si) if(*v) ++v; res = v; while(wi--) if(*v) ++v; *v = '\0'; return res; } char *length(s) register char *s; { register int i = 0; register char *rv; while(*s++) ++i; rv = malloc(8); sprintf(rv, "%d", i); return rv; } char *cindex(s, t) char *s, *t; { register int i, j; register char *rv; for(i = 0; s[i] ; ++i) for(j = 0; t[j] ; ++j) if(s[i]==t[j]) { sprintf(rv = malloc(8), "%d", ++i); return rv; } return "0"; } char * match(s, p) char *s; char *p; { register char *rv; sprintf(rv = malloc(8), "%d", ematch(s, p)); if(nbra) { rv = malloc(strlen(Mstring[0])+1); strcpy(rv, Mstring[0]); } return rv; } #define INIT register char *sp = instring; #define GETC() (*sp++) #define PEEKC() (*sp) #define UNGETC(c) (--sp) #define RETURN(c) return(c) #define ERROR(c) errxx(c) int ematch(s, p) char *s; register char *p; { static char expbuf[ESIZE]; char *compile(); register int num; extern char *braslist[], *braelist[], *loc2; compile(p, expbuf, &expbuf[ESIZE], 0); if(nbra > 1) yyerror("Too many '\\('s"); if(advance(s, expbuf)) { if(nbra == 1) { p = braslist[0]; num = braelist[0] - p; strncpy(Mstring[0], p, num); Mstring[0][num] = '\0'; } return(loc2-s); } return(0); } void errxx(c) int c; { yyerror("RE error"); } #define CBRA 2 #define CCHR 4 #define CDOT 8 #define CCL 12 #define CDOL 20 #define CEOF 22 #define CKET 24 #define CBACK 36 #define STAR 01 #define RNGE 03 #define NBRA 9 #define PLACE(c) ep[c >> 3] |= bittab[c & 07] #define ISTHERE(c) (ep[c >> 3] & bittab[c & 07]) char *braslist[NBRA]; char *braelist[NBRA]; int nbra; char *loc1, *loc2, *locs; int sed; int circf; int low; int size; char bittab[] = { 1, 2, 4, 8, 16, 32, 64, 128 }; char * compile(instring, ep, endbuf, seof) register char *ep; char *instring, *endbuf; int seof; { INIT /* Dependent declarations and initializations */ register int c; register int eof = seof; char *lastep = instring; int cclcnt; char bracket[NBRA], *bracketp; int closed; char neg; int lc; int i, cflg; lastep = 0; if((c = GETC()) == eof) { if(*ep == 0 && !sed) ERROR(41); RETURN(ep); } bracketp = bracket; circf = closed = nbra = 0; if (c == '^') circf++; else UNGETC(c); for (;;) { if (ep >= endbuf) ERROR(50); if((c = GETC()) != '*' && ((c != '\\') || (PEEKC() != '{'))) lastep = ep; if (c == eof) { *ep++ = CEOF; RETURN(ep); } switch (c) { case '.': *ep++ = CDOT; continue; case '\n': ERROR(36); case '*': if (lastep==0 || *lastep==CBRA || *lastep==CKET) goto defchar; *lastep |= STAR; continue; case '$': if(PEEKC() != eof) goto defchar; *ep++ = CDOL; continue; case '[': if(&ep[17] >= endbuf) ERROR(50); *ep++ = CCL; lc = 0; for(i = 0; i < 16; i++) ep[i] = 0; neg = 0; if((c = GETC()) == '^') { neg = 1; c = GETC(); } do { if(c == '\0' || c == '\n') ERROR(49); if(c == '-' && lc != 0) { if ((c = GETC()) == ']') { PLACE('-'); break; } while(lc < c) { PLACE(lc); lc++; } } lc = c; PLACE(c); } while((c = GETC()) != ']'); if(neg) { for(cclcnt = 0; cclcnt < 16; cclcnt++) ep[cclcnt] ^= -1; ep[0] &= 0376; } ep += 16; continue; case '\\': switch(c = GETC()) { case '(': if(nbra >= NBRA) ERROR(43); *bracketp++ = nbra; *ep++ = CBRA; *ep++ = nbra++; continue; case ')': if(bracketp <= bracket) ERROR(42); *ep++ = CKET; *ep++ = *--bracketp; closed++; continue; case '{': if(lastep == (char *) (0)) goto defchar; *lastep |= RNGE; cflg = 0; nlim: c = GETC(); i = 0; do { if ('0' <= c && c <= '9') i = 10 * i + c - '0'; else ERROR(16); } while(((c = GETC()) != '\\') && (c != ',')); if (i > 255) ERROR(11); *ep++ = i; if (c == ',') { if(cflg++) ERROR(44); if((c = GETC()) == '\\') *ep++ = 255; else { UNGETC(c); goto nlim; /* get 2'nd number */ } } if(GETC() != '}') ERROR(45); if(!cflg) /* one number */ *ep++ = i; else if((ep[-1] & 0377) < (ep[-2] & 0377)) ERROR(46); continue; case '\n': ERROR(36); case 'n': c = '\n'; goto defchar; default: if(c >= '1' && c <= '9') { if((c -= '1') >= closed) ERROR(25); *ep++ = CBACK; *ep++ = c; continue; } } /* Drop through to default to use \ to turn off special chars */ defchar: default: lastep = ep; *ep++ = CCHR; *ep++ = c; } } } int step(p1, p2) register char *p1, *p2; { register int c; if (circf) { loc1 = p1; return(advance(p1, p2)); } /* fast check for first character */ if (*p2==CCHR) { c = p2[1]; do { if (*p1 != c) continue; if (advance(p1, p2)) { loc1 = p1; return(1); } } while (*p1++); return(0); } /* regular algorithm */ do { if (advance(p1, p2)) { loc1 = p1; return(1); } } while (*p1++); return(0); } int advance(lp, ep) register char *lp, *ep; { register char *curlp; char c; char *bbeg; int ct; for (;;) switch (*ep++) { case CCHR: if (*ep++ == *lp++) continue; return(0); case CDOT: if (*lp++) continue; return(0); case CDOL: if (*lp==0) continue; return(0); case CEOF: loc2 = lp; return(1); case CCL: c = *lp++ & 0177; if(ISTHERE(c)) { ep += 16; continue; } return(0); case CBRA: braslist[*ep++] = lp; continue; case CKET: braelist[*ep++] = lp; continue; case CCHR|RNGE: c = *ep++; getrnge(ep); while(low--) if(*lp++ != c) return(0); curlp = lp; while(size--) if(*lp++ != c) break; if(size < 0) lp++; ep += 2; goto star; case CDOT|RNGE: getrnge(ep); while(low--) if(*lp++ == '\0') return(0); curlp = lp; while(size--) if(*lp++ == '\0') break; if(size < 0) lp++; ep += 2; goto star; case CCL|RNGE: getrnge(ep + 16); while(low--) { c = *lp++ & 0177; if(!ISTHERE(c)) return(0); } curlp = lp; while(size--) { c = *lp++ & 0177; if(!ISTHERE(c)) break; } if(size < 0) lp++; ep += 18; /* 16 + 2 */ goto star; case CBACK: bbeg = braslist[*ep]; ct = braelist[*ep++] - bbeg; if(ecmp(bbeg, lp, ct)) { lp += ct; continue; } return(0); case CBACK|STAR: bbeg = braslist[*ep]; ct = braelist[*ep++] - bbeg; curlp = lp; while(ecmp(bbeg, lp, ct)) lp += ct; while(lp >= curlp) { if(advance(lp, ep)) return(1); lp -= ct; } return(0); case CDOT|STAR: curlp = lp; while (*lp++); goto star; case CCHR|STAR: curlp = lp; while (*lp++ == *ep); ep++; goto star; case CCL|STAR: curlp = lp; do { c = *lp++ & 0177; } while(ISTHERE(c)); ep += 16; goto star; star: do { if(--lp == locs) break; if (advance(lp, ep)) return(1); } while (lp > curlp); return(0); } } void getrnge(str) register char *str; { low = *str++ & 0377; size = *str == 255 ? 20000 : (*str &0377) - low; } int ecmp(a, b, count) register char *a, *b; register int count; { if(a == b) /* should have been caught in compile() */ error(51); while(count--) if(*a++ != *b++) return(0); return(1); } void yyerror(s) char *s; { fprintf(stderr, "%s\n", s); exit(2); } ================================================ FILE: share/examples/yacc/gram.y ================================================ %{ #include "defs.h" struct depblock *pp; FSTATIC struct shblock *prevshp; FSTATIC struct nameblock *lefts[NLEFTS]; struct nameblock *leftp; FSTATIC int nlefts; struct lineblock *lp, *lpp; FSTATIC struct depblock *prevdep; FSTATIC int sepc; %} %token NAME SHELLINE START MACRODEF COLON DOUBLECOLON GREATER %union { struct shblock *yshblock; struct depblock *ydepblock; struct nameblock *ynameblock; } %type SHELLINE shlist shellist %type NAME namelist %type deplist dlist %% file: | file comline ; comline: START | MACRODEF | START namelist deplist shellist { while ( --nlefts >= 0) { leftp = lefts[nlefts]; if (leftp->septype == 0) leftp->septype = sepc; else if (leftp->septype != sepc) fprintf(stderr, "Inconsistent rules lines for `%s'\n", leftp->namep); else if (sepc==ALLDEPS && *(leftp->namep)!='.' && $4!=0) { for (lp=leftp->linep; lp->nxtlineblock!=0; lp=lp->nxtlineblock) if (lp->shp) fprintf(stderr, "Multiple rules lines for `%s'\n", leftp->namep); } lp = ALLOC(lineblock); lp->nxtlineblock = NULL; lp->depp = $3; lp->shp = $4; if (! unequal(leftp->namep, ".SUFFIXES") && $3==0) leftp->linep = 0; else if(leftp->linep == 0) leftp->linep = lp; else { for (lpp = leftp->linep; lpp->nxtlineblock; lpp = lpp->nxtlineblock) ; if (sepc==ALLDEPS && leftp->namep[0]=='.') lpp->shp = 0; lpp->nxtlineblock = lp; } } } | error ; namelist: NAME { lefts[0] = $1; nlefts = 1; } | namelist NAME { lefts[nlefts++] = $2; if (nlefts>=NLEFTS) fatal("Too many lefts"); } ; deplist: { char junk[10]; sprintf(junk, "%d", yylineno); fatal1("Must be a separator on rules line %s", junk); } | dlist ; dlist: sepchar { prevdep = 0; $$ = 0; } | dlist NAME { pp = ALLOC(depblock); pp->nxtdepblock = NULL; pp->depname = $2; if(prevdep == 0) $$ = pp; else prevdep->nxtdepblock = pp; prevdep = pp; } ; sepchar: COLON { sepc = ALLDEPS; } | DOUBLECOLON { sepc = SOMEDEPS; } ; shellist: { $$ = 0; } | shlist { $$ = $1; } ; shlist: SHELLINE { $$ = $1; prevshp = $1; } | shlist SHELLINE { $$ = $1; prevshp->nxtshblock = $2; prevshp = $2; } ; %% char *zznextc; /* zero if need another line; otherwise points to next char */ int yylineno; extern FILE * fin; int retsh(q) char *q; { register char *p; struct shblock *sp; char *copys(); for(p=q+1 ; *p==' '||*p=='\t' ; ++p) ; sp = ALLOC(shblock); sp->nxtshblock = NULL; sp->shbp = (fin == NULL) ? p : copys(p); yylval.yshblock = sp; zznextc = 0; return(SHELLINE); } int nextlin() { static char yytext[INMAX]; static char *yytextl = yytext+INMAX; char *text, templin[INMAX]; register char c; register char *p, *t; char lastch, *lastchp; int incom; int kc; again: incom = NO; zznextc = 0; if (fin == NULL) { text = *linesptr++; if (text == 0) return(0); ++yylineno; } else { for (p = text = yytext; p') { ++zznextc; return(GREATER); } if (*zznextc == ';') return retsh(zznextc); p = zznextc; q = word; while (! (funny[(int)*p] & TERMINAL)) *q++ = *p++; if (p != zznextc) { *q = '\0'; if((yylval.ynameblock=srchname(word))==0) yylval.ynameblock = makename(word); zznextc = p; return(NAME); } else { fprintf(stderr,"Bad character %c (octal %o), line %d", *zznextc,*zznextc,yylineno); fatal( (char *) NULL ); } return(0); /* never executed */ } ================================================ FILE: share/examples/yacc/grammar.y ================================================ /* * Copyright (c) 1987 by Ed James, UC Berkeley. All rights reserved. * * Copy permission is hereby granted provided that this notice is * retained on all partial or complete copies. * * For more info on this and all of my stuff, mail edjames@berkeley.edu. */ %token HeightOp %token WidthOp %token UpdateOp %token NewplaneOp %token DirOp %token ConstOp %token LineOp %token AirportOp %token BeaconOp %token ExitOp %union { int ival; char cval; } %{ #include "include.h" int errors = 0; int line = 1; int yylex(void); int yyerror(char *s); %} %% file: bunch_of_defs { if (checkdefs() < 0) return (errors); } bunch_of_lines { if (sp->num_exits + sp->num_airports < 2) yyerror("Need at least 2 airports and/or exits."); return (errors); } ; bunch_of_defs: def bunch_of_defs | def ; def: udef | ndef | wdef | hdef ; udef: UpdateOp '=' ConstOp ';' { if (sp->update_secs != 0) return (yyerror("Redefinition of 'update'.")); else if ($3 < 1) return (yyerror("'update' is too small.")); else sp->update_secs = $3; } ; ndef: NewplaneOp '=' ConstOp ';' { if (sp->newplane_time != 0) return (yyerror("Redefinition of 'newplane'.")); else if ($3 < 1) return (yyerror("'newplane' is too small.")); else sp->newplane_time = $3; } ; hdef: HeightOp '=' ConstOp ';' { if (sp->height != 0) return (yyerror("Redefinition of 'height'.")); else if ($3 < 3) return (yyerror("'height' is too small.")); else sp->height = $3; } ; wdef: WidthOp '=' ConstOp ';' { if (sp->height != 0) return (yyerror("Redefinition of 'width'.")); else if ($3 < 3) return (yyerror("'width' is too small.")); else sp->width = $3; } ; bunch_of_lines: line bunch_of_lines {} | line {} ; line: BeaconOp ':' Bpoint_list ';' {} | ExitOp ':' Epoint_list ';' {} | LineOp ':' Lline_list ';' {} | AirportOp ':' Apoint_list ';' {} ; Bpoint_list: Bpoint Bpoint_list {} | Bpoint {} ; Bpoint: '(' ConstOp ConstOp ')' { if (sp->num_beacons % REALLOC == 0) { if (sp->beacon == NULL) sp->beacon = (BEACON *) malloc((sp->num_beacons + REALLOC) * sizeof (BEACON)); else sp->beacon = (BEACON *) realloc(sp->beacon, (sp->num_beacons + REALLOC) * sizeof (BEACON)); if (sp->beacon == NULL) return (yyerror("No memory available.")); } sp->beacon[sp->num_beacons].x = $2; sp->beacon[sp->num_beacons].y = $3; check_point($2, $3); sp->num_beacons++; } ; Epoint_list: Epoint Epoint_list {} | Epoint {} ; Epoint: '(' ConstOp ConstOp DirOp ')' { int dir; if (sp->num_exits % REALLOC == 0) { if (sp->exit == NULL) sp->exit = (EXIT *) malloc((sp->num_exits + REALLOC) * sizeof (EXIT)); else sp->exit = (EXIT *) realloc(sp->exit, (sp->num_exits + REALLOC) * sizeof (EXIT)); if (sp->exit == NULL) return (yyerror("No memory available.")); } dir = dir_no($4); sp->exit[sp->num_exits].x = $2; sp->exit[sp->num_exits].y = $3; sp->exit[sp->num_exits].dir = dir; check_edge($2, $3); check_edir($2, $3, dir); sp->num_exits++; } ; Apoint_list: Apoint Apoint_list {} | Apoint {} ; Apoint: '(' ConstOp ConstOp DirOp ')' { int dir; if (sp->num_airports % REALLOC == 0) { if (sp->airport == NULL) sp->airport=(AIRPORT *)malloc((sp->num_airports + REALLOC) * sizeof(AIRPORT)); else sp->airport = (AIRPORT *) realloc(sp->airport, (sp->num_airports + REALLOC) * sizeof(AIRPORT)); if (sp->airport == NULL) return (yyerror("No memory available.")); } dir = dir_no($4); sp->airport[sp->num_airports].x = $2; sp->airport[sp->num_airports].y = $3; sp->airport[sp->num_airports].dir = dir; check_point($2, $3); check_adir($2, $3, dir); sp->num_airports++; } ; Lline_list: Lline Lline_list {} | Lline {} ; Lline: '[' '(' ConstOp ConstOp ')' '(' ConstOp ConstOp ')' ']' { if (sp->num_lines % REALLOC == 0) { if (sp->line == NULL) sp->line = (LINE *) malloc((sp->num_lines + REALLOC) * sizeof (LINE)); else sp->line = (LINE *) realloc(sp->line, (sp->num_lines + REALLOC) * sizeof (LINE)); if (sp->line == NULL) return (yyerror("No memory available.")); } sp->line[sp->num_lines].p1.x = $3; sp->line[sp->num_lines].p1.y = $4; sp->line[sp->num_lines].p2.x = $7; sp->line[sp->num_lines].p2.y = $8; check_line($3, $4, $7, $8); sp->num_lines++; } ; %% void check_edge(x, y) { if (!(x == 0) && !(x == sp->width - 1) && !(y == 0) && !(y == sp->height - 1)) yyerror("edge value not on edge."); } void check_point(x, y) { if (x < 1 || x >= sp->width - 1) yyerror("X value out of range."); if (y < 1 || y >= sp->height - 1) yyerror("Y value out of range."); } void check_linepoint(x, y) { if (x < 0 || x >= sp->width) yyerror("X value out of range."); if (y < 0 || y >= sp->height) yyerror("Y value out of range."); } void check_line(x1, y1, x2, y2) { int d1, d2; check_linepoint(x1, y1); check_linepoint(x2, y2); d1 = ABS(x2 - x1); d2 = ABS(y2 - y1); if (!(d1 == d2) && !(d1 == 0) && !(d2 == 0)) yyerror("Bad line endpoints."); } int yyerror(char *s) { fprintf(stderr, "\"%s\": line %d: %s\n", file, line, s); errors++; return (errors); } void check_edir(x, y, dir) { int bad = 0; if (x == sp->width - 1) x = 2; else if (x != 0) x = 1; if (y == sp->height - 1) y = 2; else if (y != 0) y = 1; switch (x * 10 + y) { case 00: if (dir != 3) bad++; break; case 01: if (dir < 1 || dir > 3) bad++; break; case 02: if (dir != 1) bad++; break; case 10: if (dir < 3 || dir > 5) bad++; break; case 11: break; case 12: if (dir > 1 && dir < 7) bad++; break; case 20: if (dir != 5) bad++; break; case 21: if (dir < 5) bad++; break; case 22: if (dir != 7) bad++; break; default: yyerror("Unknown value in checkdir! Get help!"); break; } if (bad) yyerror("Bad direction for entrance at exit."); } void check_adir(x, y, dir) { } int checkdefs() { int err = 0; if (sp->width == 0) { yyerror("'width' undefined."); err++; } if (sp->height == 0) { yyerror("'height' undefined."); err++; } if (sp->update_secs == 0) { yyerror("'update' undefined."); err++; } if (sp->newplane_time == 0) { yyerror("'newplane' undefined."); err++; } if (err) return (-1); else return (0); } ================================================ FILE: share/examples/yacc/parser.y ================================================ %token CHAR CCL NCCL STR DELIM SCON ITER NEWE NULLS %left SCON '/' NEWE %left '|' %left '$' '^' %left CHAR CCL NCCL '(' '.' STR NULLS %left ITER %left CAT %left '*' '+' '?' %{ # include "ldefs.h" int i; int j,k; int g; uchar *p; #define YYSTYPE union _yystype_ union _yystype_ { int i; uchar *cp; }; %} %% acc : lexinput { # ifdef DEBUG if(debug) sect2dump(); # endif } ; lexinput: defns delim prods end | defns delim end { if(!funcflag)phead2(); funcflag = TRUE; } | error { # ifdef DEBUG if(debug) { sect1dump(); sect2dump(); } # endif } ; end: delim | ; defns: defns STR STR { strcpy((char*)dp,(char*)$2.cp); def[dptr] = dp; dp += strlen((char*)$2.cp) + 1; strcpy((char*)dp,(char*)$3.cp); subs[dptr++] = dp; if(dptr >= DEFSIZE) error("Too many definitions"); dp += strlen((char*)$3.cp) + 1; if(dp >= dchar+DEFCHAR) error("Definitions too long"); subs[dptr]=def[dptr]=0; /* for lookup - require ending null */ } | ; delim: DELIM { # ifdef DEBUG if(sect == DEFSECTION && debug) sect1dump(); # endif sect++; } ; prods: prods pr { $$.i = mn2(RNEWE,$1.i,$2.i); } | pr { $$.i = $1.i;} ; pr: r NEWE { if(divflg == TRUE) i = mn1(S1FINAL,casecount); else i = mn1(FINAL,casecount); $$.i = mn2(RCAT,$1.i,i); divflg = FALSE; casecount++; } | error NEWE { # ifdef DEBUG if(debug) sect2dump(); # endif } r: CHAR { $$.i = mn0($1.i); } | STR { p = $1.cp; i = mn0(*p++); while(*p) i = mn2(RSTR,i,*p++); $$.i = i; } | '.' { symbol['\n'] = 0; if(psave == FALSE){ p = ccptr; psave = ccptr; for(i=1;i<'\n';i++){ symbol[i] = 1; *ccptr++ = i; } for(i='\n'+1;i ccl+CCLSIZE) error("Too many large character classes"); } else p = psave; $$.i = mnp(RCCL, p); cclinter(1); } | CCL { $$.i = mnp(RCCL,$1.cp); } | NCCL { $$.i = mnp(RNCCL,$1.cp); } | r '*' { $$.i = mn1(STAR,$1.i); } | r '+' { $$.i = mn1(PLUS,$1.i); } | r '?' { $$.i = mn1(QUEST,$1.i); } | r '|' r { $$.i = mn2(BAR,$1.i,$3.i); } | r r %prec CAT { $$.i = mn2(RCAT,$1.i,$2.i); } | r '/' r { if(!divflg){ j = mn1(S2FINAL,-casecount); i = mn2(RCAT,$1.i,j); $$.i = mn2(DIV,i,$3.i); } else { $$.i = mn2(RCAT,$1.i,$3.i); warning("Extra slash removed"); } divflg = TRUE; } | r ITER ',' ITER '}' { if($2.i > $4.i){ i = $2.i; $2.i = $4.i; $4.i = i; } if($4.i <= 0) warning("Iteration range must be positive"); else { j = $1.i; for(k = 2; k<=$2.i;k++) j = mn2(RCAT,j,dupl($1.i)); for(i = $2.i+1; i<=$4.i; i++){ g = dupl($1.i); for(k=2;k<=i;k++) g = mn2(RCAT,g,dupl($1.i)); j = mn2(BAR,j,g); } $$.i = j; } } | r ITER '}' { if($2.i < 0)warning("Can't have negative iteration"); else if($2.i == 0) $$.i = mn0(RNULLS); else { j = $1.i; for(k=2;k<=$2.i;k++) j = mn2(RCAT,j,dupl($1.i)); $$.i = j; } } | r ITER ',' '}' { /* from n to infinity */ if($2.i < 0)warning("Can't have negative iteration"); else if($2.i == 0) $$.i = mn1(STAR,$1.i); else if($2.i == 1)$$.i = mn1(PLUS,$1.i); else { /* >= 2 iterations minimum */ j = $1.i; for(k=2;k<$2.i;k++) j = mn2(RCAT,j,dupl($1.i)); k = mn1(PLUS,dupl($1.i)); $$.i = mn2(RCAT,j,k); } } | SCON r { $$.i = mn2(RSCON,$2.i,(uintptr)$1.cp); } | '^' r { $$.i = mn1(CARAT,$2.i); } | r '$' { i = mn0('\n'); if(!divflg){ j = mn1(S2FINAL,-casecount); k = mn2(RCAT,$1.i,j); $$.i = mn2(DIV,k,i); } else $$.i = mn2(RCAT,$1.i,i); divflg = TRUE; } | '(' r ')' { $$.i = $2.i; } | NULLS { $$.i = mn0(RNULLS); } ; %% int yylex(void) { uchar *p; int c, i; uchar *t, *xp; int n, j, k, x; static int sectbegin; static uchar token[TOKENSIZE]; static int iter; # ifdef DEBUG yylval.i = 0; yylval.cp = 0; # endif if(sect == DEFSECTION) { /* definitions section */ while(!eof) { if(prev == '\n'){ /* next char is at beginning of line */ getl(p=buf); switch(*p){ case '%': switch(*(p+1)){ case '%': lgate(); fprintf(fout,"#define YYNEWLINE %d\n",'\n'); fprintf(fout,"int\nyylex(void){\nint nstr; extern int yyprevious;\n"); sectbegin = TRUE; i = treesize*(sizeof(*name)+sizeof(*left)+ sizeof(*right)+sizeof(*nullstr)+sizeof(*parent))+ALITTLEEXTRA; p = myalloc(i,1); if(p == 0) error("Too little core for parse tree"); free(p); name = myalloc(treesize,sizeof(*name)); left = myalloc(treesize,sizeof(*left)); right = myalloc(treesize,sizeof(*right)); nullstr = myalloc(treesize,sizeof(*nullstr)); parent = myalloc(treesize,sizeof(*parent)); ptr = myalloc(treesize,sizeof(*ptr)); if(name == 0 || left == 0 || right == 0 || parent == 0 || nullstr == 0 || ptr == 0) error("Too little core for parse tree"); return(freturn(DELIM)); case 'p': case 'P': /* has overridden number of positions */ while(*p && !isdigit(*p))p++; maxpos = atol((char*)p); # ifdef DEBUG if (debug) printf("positions (%%p) now %d\n",maxpos); # endif if(report == 2)report = 1; continue; case 'n': case 'N': /* has overridden number of states */ while(*p && !isdigit(*p))p++; nstates = atol((char*)p); # ifdef DEBUG if(debug)printf( " no. states (%%n) now %d\n",nstates); # endif if(report == 2)report = 1; continue; case 'e': case 'E': /* has overridden number of tree nodes */ while(*p && !isdigit(*p))p++; treesize = atol((char*)p); # ifdef DEBUG if (debug) printf("treesize (%%e) now %d\n",treesize); # endif if(report == 2)report = 1; continue; case 'o': case 'O': while (*p && !isdigit(*p))p++; outsize = atol((char*)p); if (report ==2) report=1; continue; case 'a': case 'A': /* has overridden number of transitions */ while(*p && !isdigit(*p))p++; if(report == 2)report = 1; ntrans = atol((char*)p); # ifdef DEBUG if (debug)printf("N. trans (%%a) now %d\n",ntrans); # endif continue; case 'k': case 'K': /* overriden packed char classes */ while (*p && !isdigit(*p))p++; if (report==2) report=1; free(pchar); pchlen = atol((char*)p); # ifdef DEBUG if (debug) printf( "Size classes (%%k) now %d\n",pchlen); # endif pchar=pcptr=myalloc(pchlen, sizeof(*pchar)); continue; case '{': lgate(); while(getl(p) && strcmp((char*)p,"%}") != 0) fprintf(fout, "%s\n",(char*)p); if(p[0] == '%') continue; error("Premature eof"); case 's': case 'S': /* start conditions */ lgate(); while(*p && strchr(" \t,", *p) == 0) p++; n = TRUE; while(n){ while(*p && strchr(" \t,", *p)) p++; t = p; while(*p && strchr(" \t,", *p) == 0)p++; if(!*p) n = FALSE; *p++ = 0; if (*t == 0) continue; i = sptr*2; fprintf(fout,"#define %s %d\n",(char*)t,i); strcpy((char*)sp, (char*)t); sname[sptr++] = sp; sname[sptr] = 0; /* required by lookup */ if(sptr >= STARTSIZE) error("Too many start conditions"); sp += strlen((char*)sp) + 1; if(sp >= stchar+STARTCHAR) error("Start conditions too long"); } continue; default: warning("Invalid request %s",p); continue; } /* end of switch after seeing '%' */ case ' ': case '\t': /* must be code */ lgate(); fprintf(fout, "%s\n",(char*)p); continue; default: /* definition */ while(*p && !isspace(*p)) p++; if(*p == 0) continue; prev = *p; *p = 0; bptr = p+1; yylval.cp = buf; if(isdigit(buf[0])) warning("Substitution strings may not begin with digits"); return(freturn(STR)); } } /* still sect 1, but prev != '\n' */ else { p = bptr; while(*p && isspace(*p)) p++; if(*p == 0) warning("No translation given - null string assumed"); strcpy((char*)token, (char*)p); yylval.cp = token; prev = '\n'; return(freturn(STR)); } } /* end of section one processing */ } else if(sect == RULESECTION){ /* rules and actions */ while(!eof){ switch(c=gch()){ case '\0': return(freturn(0)); case '\n': if(prev == '\n') continue; x = NEWE; break; case ' ': case '\t': if(sectbegin == TRUE){ cpyact(); while((c=gch()) && c != '\n'); continue; } if(!funcflag)phead2(); funcflag = TRUE; fprintf(fout,"case %d:\n",casecount); if(cpyact()) fprintf(fout,"break;\n"); while((c=gch()) && c != '\n'); if(peek == ' ' || peek == '\t' || sectbegin == TRUE){ warning("Executable statements should occur right after %%"); continue; } x = NEWE; break; case '%': if(prev != '\n') goto character; if(peek == '{'){ /* included code */ getl(buf); while(!eof && getl(buf) && strcmp("%}",(char*)buf) != 0) fprintf(fout,"%s\n",(char*)buf); continue; } if(peek == '%'){ gch(); gch(); x = DELIM; break; } goto character; case '|': if(peek == ' ' || peek == '\t' || peek == '\n'){ /* XXX Plan 9 uses this line instead ?? fprintf(fout,"%d\n",30000+casecount++); XXX */ fprintf(fout,"case %d:\n",casecount++); continue; } x = '|'; break; case '$': if(peek == '\n' || peek == ' ' || peek == '\t' || peek == '|' || peek == '/'){ x = c; break; } goto character; case '^': if(prev != '\n' && scon != TRUE) goto character; /* valid only at line begin */ x = c; break; case '?': case '+': case '.': case '*': case '(': case ')': case ',': case '/': x = c; break; case '}': iter = FALSE; x = c; break; case '{': /* either iteration or definition */ if(isdigit(c=gch())){ /* iteration */ iter = TRUE; ieval: i = 0; while(isdigit(c)){ token[i++] = c; c = gch(); } token[i] = 0; yylval.i = atol((char*)token); munputc(c); x = ITER; break; } else { /* definition */ i = 0; while(c && c!='}'){ token[i++] = c; c = gch(); } token[i] = 0; i = lookup(token,def); if(i < 0) warning("Definition %s not found",token); else munputs(subs[i]); continue; } case '<': /* start condition ? */ if(prev != '\n') /* not at line begin, not start */ goto character; t = slptr; do { i = 0; c = gch(); while(c != ',' && c && c != '>'){ token[i++] = c; c = gch(); } token[i] = 0; if(i == 0) goto character; i = lookup(token,sname); if(i < 0) { warning("Undefined start condition %s",token); continue; } *slptr++ = i+1; } while(c && c != '>'); *slptr++ = 0; /* check if previous value re-usable */ for (xp=slist; xp slist+STARTSIZE) /* note not packed ! */ error("Too many start conditions used"); yylval.cp = t; x = SCON; break; case '"': i = 0; while((c=gch()) && c != '"' && c != '\n'){ if(c == '\\') c = usescape(gch()); token[i++] = c; if(i > TOKENSIZE){ warning("String too long"); i = TOKENSIZE-1; break; } } if(c == '\n') { yyline--; warning("Non-terminated string"); yyline++; } token[i] = 0; if(i == 0)x = NULLS; else if(i == 1){ yylval.i = token[0]; x = CHAR; } else { yylval.cp = token; x = STR; } break; case '[': for(i=1;i k) { n = j; j = k; k = n; } if(!(('A' <= j && k <= 'Z') || ('a' <= j && k <= 'z') || ('0' <= j && k <= '9'))) warning("Non-portable Character Class"); for(n=j+1;n<=k;n++) symbol[n] = 1; /* implementation dependent */ c = gch(); } } /* try to pack ccl's */ i = 0; for(j=0;j= ccl+CCLSIZE) error("Too many large character classes"); } cclinter(x==CCL); break; case '\\': c = usescape(gch()); default: character: if(iter){ /* second part of an iteration */ iter = FALSE; if('0' <= c && c <= '9') goto ieval; } if(isalpha(peek)){ i = 0; yylval.cp = token; token[i++] = c; while(isalpha(peek)) token[i++] = gch(); if(peek == '?' || peek == '*' || peek == '+') munputc(token[--i]); token[i] = 0; if(i == 1){ yylval.i = token[0]; x = CHAR; } else x = STR; } else { yylval.i = c; x = CHAR; } } scon = FALSE; if(x == SCON)scon = TRUE; sectbegin = FALSE; return(freturn(x)); } } /* section three */ ptail(); # ifdef DEBUG if(debug) fprintf(fout,"\n/*this comes from section three - debug */\n"); # endif while(getl(buf) && !eof) fprintf(fout,"%s\n",(char*)buf); return(freturn(0)); } /* end of yylex */ # ifdef DEBUG int freturn(int i) { if(yydebug) { printf("now return "); if(i < NCH) allprint(i); else printf("%d",i); printf(" yylval = "); switch(i){ case STR: case CCL: case NCCL: strpt(yylval.cp); break; case CHAR: allprint(yylval.i); break; default: printf("%d",yylval.i); break; } putchar('\n'); } return(i); } # endif ================================================ FILE: share/man/.gitignore ================================================ whatis.db ================================================ FILE: share/man/Makefile ================================================ # # Copyright (c) 1987 Regents of the University of California. # All rights reserved. # # Redistribution and use in source and binary forms are permitted # provided that the above copyright notice and this paragraph are # duplicated in all such forms and that any documentation, # advertising materials, and other materials related to such # distribution and use acknowledge that the software was developed # by the University of California, Berkeley. The name of the # University may not be used to endorse or promote products derived # from this software without specific prior written permission. # THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED # WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. # # @(#)Makefile 5.3 (Berkeley) 7/9/88 # TOPSRC!=cd ../..; pwd include ${TOPSRC}/share/mk/sys.mk DIRS= man1 man2 man3 man4 man5 man6 man7 man8 man9 CDIRS= cat1 cat2 cat3 cat4 cat5 cat6 cat7 cat8 cat9 LCDIRS= cat1 cat2 cat3 cat4 cat5 cat6 cat7 cat8 cat9 all: for i in ${DIRS}; do \ ${MAKE} -C $$i; \ done whatis.db: cp /dev/null whatis_tmp for dirext in ${DESTDIR}/usr/share/man/cat* ; do \ echo $$dirext; \ for file in `find $$dirext -type f -name '*.0' -print`; do \ sed -n -f makewhatis.sed $$file; \ done >> whatis_tmp; \ done sort -u whatis_tmp > whatis.db -rm -f whatis_tmp install: FRC for i in ${DIRS}; do \ ${MAKE} -C $$i install; \ done ${MAKE} whatis.db cp whatis.db ${DESTDIR}/usr/share/man/whatis cp man.template ${DESTDIR}/usr/share/man/man.template # cp makewhatis.sed ${DESTDIR}/usr/share/man/makewhatis.sed # ${INSTALL} -c -m 755 manroff ${DESTDIR}/usr/share/man/manroff clean: FRC for i in ${DIRS}; do \ ${MAKE} -C $$i clean; \ done rm -f whatis_tmp whatis.db depend: lint: tags: FRC: ================================================ FILE: share/man/makewhatis.sed ================================================ #!/bin/sh - # # Copyright (c) 1988 Regents of the University of California. # All rights reserved. # # Redistribution and use in source and binary forms are permitted # provided that the above copyright notice and this paragraph are # duplicated in all such forms and that any documentation, # advertising materials, and other materials related to such # distribution and use acknowledge that the software was developed # by the University of California, Berkeley. The name of the # University may not be used to endorse or promote products derived # from this software without specific prior written permission. # THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED # WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. # # @(#)makewhatis.sed 5.3 (Berkeley) 7/9/88 # /(\([a-zA-Z0-9]*\).* Manual/ { s;.*(\([a-zA-Z0-9]*\).* Manual.*;\1; h d } /^NNAAMMEE/!d :name s;.*;; N s;\n;; # some twits underline the command name s;_;;g /^[^ ]/b print H b name :print x s;\n;;g s;^ *;; /-/!d s;\([a-z][A-Z]\)-[ ][ ]*;\1; s;\([a-zA-Z0-9,]\)[ ][ ]*;\1 ;g s;[^a-zA-Z0-9]*\([a-zA-Z0-9]*\)[^a-zA-Z0-9]*\(.*\) - \(.*\);\2 (\1) - \3; p d ================================================ FILE: share/man/man.template ================================================ .TH NAME SECTION local .SH NAME .SH SYNOPSIS .SH DESCRIPTION .SH FILES .SH SEE ALSO .SH DIAGNOSTICS .SH BUGS ================================================ FILE: share/man/man0/Makefile ================================================ # # Copyright (c) 1986 Regents of the University of California. # All rights reserved. The Berkeley software License Agreement # specifies the terms and conditions for redistribution. # # @(#)Makefile 6.2 (Berkeley) 5/15/86 # TOCS= toc1 toc2 toc3 toc3f toc4 toc5 toc6 toc7 toc8 \ tocx1 tocx2 tocx3 tocx3f tocx4 tocx5 tocx6 tocx7 tocx8 MACROS= -msU PRINTER=Pdp TROFF= ditroff -${PRINTER} all: title.urm.${PRINTER} preface.${PRINTER} intro.${PRINTER} \ toc.${PRINTER} ptx.${PRINTER} title.prm.${PRINTER} lpr -${PRINTER} -n title.urm.${PRINTER} lpr -${PRINTER} -n preface.${PRINTER} lpr -${PRINTER} -n intro.${PRINTER} lpr -${PRINTER} -n toc.${PRINTER} lpr -${PRINTER} -n ptx.${PRINTER} lpr -${PRINTER} -n title.prm.${PRINTER} title.urm.${PRINTER}: title.urm ${TROFF} -t title.urm >title.urm.${PRINTER} preface.${PRINTER}: preface.ms ${TROFF} ${MACROS} -t preface.ms >preface.${PRINTER} intro.${PRINTER}: intro.ms ${TROFF} ${MACROS} -t intro.ms >intro.${PRINTER} toc.${PRINTER}: toc.in ptxx ${TROFF} -t toc.in >toc.${PRINTER} ptx.${PRINTER}: ptx.in ptxx ${TROFF} -t ptx.in >ptx.${PRINTER} title.prm.${PRINTER}: title.prm ptxx ${TROFF} -t title.prm >title.prm.${PRINTER} ptxx: tocrc all tocrc t clean: rm -f title.urm.[PT]* preface.[PT]* intro.[PT]* toc.[PT]* ptx.[PT]* \ title.prm.[PT]* ${TOCS} ptxx *.spell errs Errs make.out ================================================ FILE: share/man/man0/break ================================================  ; : . , ================================================ FILE: share/man/man0/cshcmd ================================================ csh(1) alias: shell macros. csh(1) bg: place job in background. csh(1) break: exit while/foreach loop. csh(1) breaksw: exit from switch. csh(1) case: selector in switch. csh(1) cd: change directory. csh(1) chdir: change directory. csh(1) continue: cycle in loop. csh(1) default: catchall clause in switch. csh(1) echo: echo arguments. csh(1) else: alternative commands. csh(1) end: terminate loop. csh(1) endif: terminate conditional. csh(1) endsw: terminate switch. csh(1) eval: re-evaluate shell data. csh(1) exec: overlay shell with specified command. csh(1) exit: leave shell. csh(1) fg: bring job into foreground. csh(1) foreach: loop over list of names. csh(1) glob: filename expand argument list. csh(1) goto: command transfer. csh(1) hashstat: print command hashing statistics. csh(1) history: print history event list. csh(1) if: conditional statement. csh(1) jobs: print current job list. csh(1) kill: kill jobs and processes. csh(1) limit: alter per-process resource limitations. csh(1) login: login new user. csh(1) logout: end session. csh(1) nice: run low priority process. csh(1) nohup: run command immune to hangups. csh(1) notify: request immediate notification. csh(1) onintr: process interrupts in command scripts. csh(1) popd: pop shell directory stack. csh(1) pushd: push shell directory stack. csh(1) rehash: recompute command hash table. csh(1) repeat: execute command repeatedly. csh(1) set: change value of shell variable. csh(1) setenv: set variable in environment. csh(1) shift: manipulate argument list. csh(1) source: read commands from file. csh(1) stop: halt a job or process. csh(1) suspend: suspend a shell, resuming its superior. csh(1) switch: multi-way command branch. csh(1) time: time command. csh(1) umask: change or display file creation mask. csh(1) unalias: remove aliases. csh(1) unhash: discard command hash table. csh(1) unlimit: remove resource limitiations. csh(1) unsetenv: remove environment variables. csh(1) unset: discard shell variables. csh(1) wait: wait for background processes to complete. csh(1) while: repeat commands conditionally. csh(1) @: arithmetic on shell variables. ================================================ FILE: share/man/man0/ignore ================================================ - \- 10 11 16 144 2 201 3 4014 6 7 77 a about across after al al all allow am among an and and/or any another are B back be been between bits by dialect do et extreme facts feeds fitting for from general get has head in integer integers interval into intro is it its knowledge large last later local long low map o of off on or other out package part periodically pieces prejudice problem service simple special system tac that the them they this to toe turn two until way with yet you your ================================================ FILE: share/man/man0/intro.ms ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)intro.ms 6.3 (Berkeley) 5/14/86 .\" .de IR \fI\\$1\^\fR\\$2 .. .de RI \fR\\$1\fI\\$2\^\fR\\$3 .. .TL INTRODUCTION TO USER'S REFERENCE MANUAL .OH 'Introduction''- % -' .EH '- % -''Introduction' .af % i .pn 6 .LP The documentation has been reorganized for 4.3BSD in a format similar to the one used for the Usenix 4.2BSD manuals. It is divided into three sets; each set consists of one or more volumes. The abbreviations for the volume names are listed in square brackets; the abbreviations for the manual sections are listed in parenthesis. .DS I. User's Documents User's Reference Manual [URM] Commands (1) Games (6) Macro packages and language conventions (7) User's Supplementary Documents [USD] Getting Started Basic Utilities Communicating with the World Text Editing Document Preparation Amusements II. Programmer's Documents Programmer's Reference Manual [PRM] System calls (2) Subroutines (3) Special files (4) File formats and conventions (5) Programmer's Supplementary Documents, Volume 1 [PS1] Languages in common use General Reference Programming Tools Programming Libraries Programmer's Supplementary Documents, Volume 2 [PS2] Documents of Historic Interest Other Languages Database Management III. System Manager's Manual [SMM] Maintenance commands (8) System Installation and Administration Supporting Documentation .DE .LP References to individual documents are given as ``volume:document'', thus USD:1 refers to the first document in the ``User's Supplementary Documents''. References to manual pages are given as ``\fIname\fP(section)'' thus .IR sh (1) refers to the shell manual entry in section 1. .LP The manual pages give descriptions of the publicly available features of the .UX \s-2/32V\s0 system, as extended to provide a virtual memory environment and other enhancements at the University of California. They do not attempt to provide perspective or tutorial information about the .UX operating system, its facilities, or its implementation. Various documents on those topics are contained in the ``UNIX User's Supplementary Documents'' (USD), the ``UNIX Programmer's Supplementary Documents'' (PS1 and PS2), and ``UNIX System Manager's Manual'' (SMM). In particular, for an overview see ``The UNIX Time-Sharing System'' (PS2:1) by Ritchie and Thompson; for a tutorial see ``\s8UNIX\s10 for Beginners'' (USD:1) by Kernighan, and for an guide to the new features of this virtual version, see ``Berkeley Software Architecture Manual (4.3 Edition)'' (PS1:6). .LP Within the area it surveys, this volume attempts to be timely, complete and concise. Where the latter two objectives conflict, the obvious is often left unsaid in favor of brevity. It is intended that each program be described as it is, not as it should be. Inevitably, this means that various sections will soon be out of date. .LP Commands are programs intended to be invoked directly by the user, in contrast to subroutines, that are intended to be called by the user's programs. User commands are described in URM section 1. Commands generally reside in directory .I /bin (for .IR bin \|ary programs). Some programs also reside in .I /\|usr/\|bin, .R .I /\|usr/\|ucb, .R or .I /\|usr/\|new, .R to save space in .I /\|bin. These directories are searched automatically by the command interpreters. .LP Games have been relegated to URM section 6 and .I /\|usr/\|games, .R to keep them from contaminating the more staid information of URM section 1. .LP Miscellaneous collection of information necessary for writing in various specialized languages such as character codes, macro packages for typesetting, etc is contained in URM section 7. .LP System calls are entries into the .UX supervisor. The system call interface is identical to a C language procedure call; the equivalent C procedures are described in PRM section 2. .LP An assortment of subroutines is available; they are described in PRM section 3. The primary libraries in which they are kept are described in .IR intro (3). The functions are described in terms of C; those that will work with Fortran are described in .IR intro (3f). .LP PRM section 4 discusses the characteristics of each system ``file'' that refers to an I/O device. The names in this section refer to the DEC device names for the hardware, instead of the names of the special files themselves. .LP The file formats and conventions (PRM section 5) documents the structure of particular kinds of files; for example, the form of the output of the loader and assembler is given. Excluded are files used by only one command, for example the assembler's intermediate files. .LP Commands and procedures intended for use primarily by the system administrator are described in SMM section 8. The commands and files described here are almost all kept in the directory .I /\|etc. .LP Each section consists of independent entries of a page or so each. The name of the entry is in the upper corners of its pages, together with the section number, and sometimes a letter characteristic of a subcategory, e.g. graphics is 1G, and the math library is 3M. Entries within each section are alphabetized. except for PRM section 3f which appears after the rest of PRM section 3. The page numbers of each entry start at 1; it is infeasible to number consecutively the pages of a document like this that is republished in many variant forms. .LP All entries are based on a common format; not all subsections always appear. .RS .LP The .I name subsection lists the exact names of the commands and subroutines covered under the entry and gives a short description of their purpose. .LP The .IR synopsis "" summarizes the use of the program being described. A few conventions are used, particularly in the Commands subsection: .LP .RS .B Boldface words are considered literals, and are typed just as they appear. .LP Square brackets [ ] around an argument show that the argument is optional. When an argument is given as ``name'', it always refers to a file name. .LP Ellipses ``.\|.\|.'' are used to show that the previous argument-prototype may be repeated. .LP A final convention is used by the commands themselves. An argument beginning with a minus sign ``\-'' usually means that it is an option-specifying argument, even if it appears in a position where a file name could appear. Therefore, it is unwise to have files whose names begin with ``\-''. .LP .RE The .IR description "" subsection discusses in detail the subject at hand. .LP The .IR files "" subsection gives the names of files that are built into the program. .LP A .I see also .R subsection gives pointers to related information. .LP A .I diagnostics subsection discusses the diagnostic indications that may be produced. Messages that are intended to be self-explanatory are not listed. .LP The .IR bugs "" subsection gives known bugs and sometimes deficiencies. Occasionally the suggested fix is also described. .LP .RE At the beginning of URM is a table of contents, organized by section and alphabetically within each section. There is also a permuted index derived from the table of contents. Within each index entry, the title of the writeup to which it refers is followed by the appropriate section number in parentheses. This fact is important because there is considerable name duplication among the sections, arising principally from commands that exist only to exercise a particular system call. .SH HOW TO GET STARTED .LP This section sketches the basic information you need to get started on UNIX; how to log in and log out, how to communicate through your terminal, and how to run a program. See ``\c .UX for Beginners'' in (USD:1) for a more complete introduction to the system. .LP .I Logging in.\ \ .R Almost any ASCII terminal capable of full duplex operation and generating the entire character set can be used. You must have a valid user name, which may be obtained from the system administration. If you will be accessing UNIX remotely, you will also need to obtain the telephone number for the system that you will be using. .LP After a data connection is established, the login procedure depends on what type of terminal you are using and local system conventions. If your terminal is directly connected to the computer, it generally runs at 9600 or 19200 baud. If you are using a modem running over a phone line, the terminal must be set at the speed appropriate for the modem you are using, typically 300, 1200, or 2400 baud. The half/full duplex switch should always be set at full-duplex. (This switch will often have to be changed since many other systems require half-duplex). .LP When a connection is established, the system types ``login:''; you type your user name, followed by the ``return'' key. If you have a password, the system asks for it and suppresses echo to the terminal so the password will not appear. After you have logged in, the ``return'', ``new line'', or ``linefeed'' keys will give exactly the same results. A message-of-the-day usually greets you before your first prompt. .LP If the system types out a few garbage characters after you have established a data connection (the ``login:'' message at the wrong speed), depress the ``break'' (or ``interrupt'') key. This is a speed-independent signal to .UX that a different speed terminal is in use. The system then will type ``login:,'' this time at another speed. Continue depressing the break key until ``login:'' appears clearly, then respond with your user name. .LP For all these terminals, it is important that you type your name in lower-case if possible; if you type upper-case letters, .UX will assume that your terminal cannot generate lower-case letters and will translate all subsequent lower-case letters to upper case. .LP The evidence that you have successfully logged in is that a shell program will type a prompt (``$'' or ``%'') to you. (The shells are described below under ``How to run a program.'') .LP For more information, consult .IR tset (1), and .IR stty (1), which tell how to adjust terminal behavior; .IR getty (8) discusses the login sequence in more detail, and .IR tty (4) discusses terminal I/O. .LP .I Logging out.\ \ .R There are three ways to log out: .IP By typing ``logout'' or an end-of-file indication (EOT character, control-D) to the shell. The shell will terminate and the ``login:'' message will appear again. .IP You can log in directly as another user by giving a .IR login (1) command. .IP If worse comes to worse, you can simply hang up the phone; but beware \- some machines may lack the necessary hardware to detect that the phone has been hung up. Ask your system administrator if this is a problem on your machine. .LP .I How to communicate through your terminal.\ \ .R When you type characters, a gnome deep in the system gathers your characters and saves them in a secret place. The characters will not be given to a program until you type a return (or newline), as described above in .I Logging in. .R .LP .UX terminal I/O is full-duplex. It has full read-ahead, which means that you can type at any time, even while a program is typing at you. Of course, if you type during output, the printed output will have the input characters interspersed. However, whatever you type will be saved up and interpreted in correct sequence. There is a limit to the amount of read-ahead, but it is generous and not likely to be exceeded unless the system is in trouble. When the read-ahead limit is exceeded, the system throws away all the saved characters (or beeps, if your prompt was a ``%''). .LP The delete (DEL) character in typed input kills all the preceding characters in the line, so typing mistakes can be repaired on a single line. Also, the backspace character (control-H) erases the last character typed. .IR Tset (1) or .IR stty (1) can be used to change these defaults. Successive uses of backspace erases characters back to, but not beyond, the beginning of the line. DEL and backspace can be transmitted to a program by preceding them with ``\e''. (So, to erase ``\e'', you need two backspaces). .LP An .I interrupt signal .R is sent to a program by typing control-C or the ``break'' key which is not passed to programs. This signal generally causes whatever program you are running to terminate. It is typically used to stop a long printout that you do not want. However, programs can arrange either to ignore this signal altogether, or to be notified when it happens (instead of being terminated). The editor, for example, catches interrupts and stops what it is doing, instead of terminating, so that an interrupt can be used to halt an editor printout without losing the file being edited. The interrupt character can also be changed with .IR tset (1) or .IR stty (1). .LP It is also possible to suspend output temporarily using ^S (control-S) and later resume output with ^Q (control-Q). Output can be thrown away without interrupting the program by typing ^O (control-O); see .IR tty (4). .LP The .IR quit "" signal is generated by typing the \s8ASCII\s10 FS character. (FS appears many places on different terminals, most commonly as control-\e or control-\^|\^.) It not only causes a running program to terminate but also generates a file with the core image of the terminated process. Quit is useful for debugging. .LP Besides adapting to the speed of the terminal, .UX tries to be intelligent about whether you have a terminal with the newline function or whether it must be simulated with carriage-return and line-feed. In the latter case, all input carriage returns are turned to newline characters (the standard line delimiter) and both a carriage return and a line feed are echoed to the terminal. If you get into the wrong mode, the .IR reset (1) command will rescue you. If the terminal does not appear to be echoing anything that you type, it may be stuck in ``no-echo'' or ``raw'' mode. Try typing ``(control-J)reset(control-J)'' to recover. .LP Tab characters are used freely in .UX source programs. If your terminal does not have the tab function, you can arrange to have them turned into spaces during output, and echoed as spaces during input. The system assumes that tabs are set every eight columns. Again, the .IR tset (1) or .IR stty (1) command can be used to change these defaults. .IR Tset (1) can be used to set the tab stops automatically when necessary. .LP .I How to run a program; the shells.\ \ .R When you have successfully logged in, a program called a shell is listening to your terminal. The shell reads typed-in lines, splits them up into a command name and arguments, and executes the command. A command is simply an executable program. The shell looks in several system directories to find the command. You can also place commands in your own directory and have the shell find them there. There is nothing special about system-provided commands except that they are kept in a directory where the shell can find them. .LP The command name is always the first word on an input line; it and its arguments are separated from one another by spaces. .LP When a program terminates, the shell will ordinarily regain control and type a prompt at you to show that it is ready for another command. .LP The shells have many other capabilities, that are described in detail in sections .IR sh (1) and .IR csh (1). If the shell prompts you with ``$'', then it is an instance of .IR sh (1) the standard shell provided by Bell Labs. If it prompts with ``%'' then it is an instance of .IR csh (1), a shell written at Berkeley. The shells are different for all but the most simple terminal usage. Most users at Berkeley choose .IR csh (1) because of the .I history mechanism and the .I alias feature, that greatly enhance its power when used interactively. .I Csh also supports the job-control facilities; see .IR csh (1) or the Csh introduction in USD:4 for details. .LP You can change from one shell to the other by using the .I chsh (1) command, which takes effect at your next login. .LP .I The current directory.\ \ .R .UX has a file system arranged as a hierarchy of directories. When the system administrator gave you a user name, they also created a directory for you (ordinarily with the same name as your user name). When you log in, any file name you type is by default in this directory. Since you are the owner of this directory, you have full permission to read, write, alter, or destroy its contents. Permissions to have your will with other directories and files will have been granted or denied to you by their owners. As a matter of observed fact, few .UX users protect their files from perusal by other users. .LP To change the current directory (but not the set of permissions you were endowed with at login) use .IR cd (1). .LP .I Path names.\ \ .R To refer to files not in the current directory, you must use a path name. Full path names begin with ``/\|'', the name of the root directory of the whole file system. After the slash comes the name of each directory containing the next sub-directory (followed by a ``/\|'') until finally the file name is reached. For example, .I /\^usr/\^tmp/\^filex .R refers to the file .I filex .R in the directory .I tmp; tmp .R is itself a subdirectory of .I usr; usr .R springs directly from the root directory. .LP If your current directory has subdirectories, the path names of files therein begin with the name of the subdirectory with no prefixed ``/\|''. .LP A path name may be used anywhere a file name is required. .LP Important commands that modify the contents of files are .IR cp (1), .IR mv (1), and .IR rm (1), which respectively copy, move (i.e. rename) and remove files. To find out the status of files or directories, use .IR ls (1). See .IR mkdir (1) for making directories and .IR rmdir (1) for destroying them. .LP For a fuller discussion of the file system, see ``A Fast File System for UNIX'' (SMM:14) by McKusick, Joy, Leffler, and Fabry. It may also be useful to glance through PRM section 2, that discusses system calls, even if you do not intend to deal with the system at that level. .LP .I Writing a program.\ \ .R To enter the text of a source program into a .UX file, use the editor .IR ex (1) or its display editing alias .IR vi (1). (The old standard editor .IR ed (1) is also available.) The principal languages in .UX are provided by the C compiler .IR cc (1), the Fortran compiler .IR f77 (1), and its derivatives .IR efl (1) and .IR ratfor (1), the Pascal compiler .IR pc (1), and interpreter .IR pi (1), and the Lisp system .IR lisp (1). User contributed software in the latest release of the system supports APL, B, the Functional Programming language, and Icon. Refer to .IR apl (1), .IR b (1), .IR fp (1), and .IR icon (1), respectively for more information about each. After the program text has been entered through the editor and written to a file, you can give the file to the appropriate language processor as an argument. The output of the language processor will be left on a file in the current directory named ``a.out''. If the output is precious, use .IR mv (1) to move it to a less exposed name after successful compilation. .LP When you have finally gone through this entire process without provoking any diagnostics, the resulting program can be run by giving its name to the shell in response to the shell (``$'' or ``%'') prompt. .LP Your programs can receive arguments from the command line just as system programs do, see ``UNIX Programming - Second Edition'' (PS2:3), or for a more terse description .IR execve (2). .LP .I Text processing.\ \ .R Almost all text is entered through the editor .IR ex (1) (often entered via .IR vi (1)). The commands most often used to write text on a terminal are: .IR cat (1), .IR more (1), and .IR nroff (1). .LP The .IR cat (1) command simply dumps \s8ASCII\s10 text on the terminal, with no processing at all. .IR More (1) is useful for preventing the output of a command from scrolling off the top of your screen. It is also well suited to perusing files. .IR Nroff (1) is an elaborate text formatting program. Used naked, it requires careful forethought, but for ordinary documents it has been tamed; see .IR me (7) and .IR ms (7). .LP .IR Troff (1) prepares documents for a Graphics Systems phototypesetter or a Versatec Plotter; it is similar to .IR nroff (1), and often works from exactly the same source text. It was used to produce this manual. .LP .IR Script (1) lets you keep a record of your session in a file, which can then be printed, mailed, etc. It provides the advantages of a hard-copy terminal even when using a display terminal. .LP .I Status inquiries.\ \ .R Various commands exist to provide you with useful information. .IR w (1) prints a list of users currently logged in, and what they are doing. .IR date (1) prints the current time and date. .IR ls (1) will list the files in your directory or give summary information about particular files. .LP .I Surprises.\ \ .R Certain commands provide inter-user communication. Even if you do not plan to use them, it would be well to learn something about them, because someone else may aim them at you. .LP To communicate with another user currently logged in, .IR write (1) or .IR talk (1) is used; .IR mail (1) will leave a message whose presence will be announced to another user when they next log in. The write-ups in the manual also suggest how to respond to the these commands if you are a target. .LP If you use .IR csh (1) the key ^Z (control-Z) will cause jobs to ``stop''. If this happens before you learn about it, you can simply continue by saying ``fg'' (for foreground) to bring the job back. .SH CONVERTING FROM 4.2BSD SYSTEMS .LP A detailed list of changes from the 4.2BSD to the 4.3BSD distributions is contained in ``Bug Fixes and Changes in 4.3BSD'' (SMM:12), and ``Changes to the Kernel in 4.3BSD'' (SMM:13). Detailed conversion procedures are described in ``Installing and Operating 4.3BSD on the VAX'' (SMM:1); it also discusses changes from pre-4.2BSD systems. ================================================ FILE: share/man/man0/preface.ms ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)preface.ms 6.3 (Berkeley) 5/13/86 .\" .nr PS 9 .nr VS 11 .vs 11p .ps 9p .TL PREFACE .OH 'Preface''- % -' .EH '- % -''Preface' .af % i .LP This update to the 4.2 distribution of August 1983 provides substantially improved performance, reliability, and security, the addition of Xerox Network System (NS) to the set of networking domains, and partial support for the VAX 8600 and MICROVAXII. .LP We were greatly assisted by the DEC UNIX Engineering group who provided two full time employees, Miriam Amos and Kevin Dunlap, to work at Berkeley. They were responsible for developing and debugging the distributed domain based name server and integrating it into the mail system. Mt Xinu provided the bug list distribution service as well as donating their MICROVAXII port to 4.3BSD. Drivers for the MICROVAXII were done by Rick Macklem at the University of Guelph. Sam Leffler provided valuable assistance and advice with many projects. Keith Sklower coordinated with William Nesheim and J. Q. Johnson at Cornell, and Chris Torek and James O'Toole at the University of Maryland to do the Xerox Network Systems implementation. Robert Elz at the University of Melbourne contributed greatly to the performance work in the kernel. Donn Seeley and Jay Lepreau at the University of Utah relentlessly dealt with a miriad of details; Donn completed the unfinished performance work on Fortran 77 and fixed numerous C compiler bugs. Ralph Campbell handled innumerable questions and problem reports and had time left to write rdist. George Goble was invaluable in shaking out the bugs on his production systems long before we were confident enough to inflict it on our users. Bill Shannon at Sun Microsystems has been helpful in providing us with bug fixes and improvements. Tom Ferrin, in his capacity as Board Member of Usenix Association, handled the logistics of large-scale reproduction of the 4.2BSD and 4.3BSD manuals. Mark Seiden helped with the typesetting and indexing of the 4.3BSD manuals. Special mention goes to Bob Henry for keeping ucbvax running in spite of new and improved software and an ever increasing mail, news, and uucp load. .LP Numerous others contributed their time and energy in creating the user contributed software for the release. As always, we are grateful to the UNIX user community for encouragement and support. .LP Once again, the financial support of the Defense Advanced Research Projects Agency is gratefully acknowledged. .sp 1 .in 4i .nf M. K. McKusick M. J. Karels J. M. Bloom .fi .in 0 .sp 2 .ne 1i .ce \fIPreface to the 4.2 Berkeley distribution\fP .sp 1 This update to the 4.1 distribution of June 1981 provides support for the VAX 11/730, full networking and interprocess communication support, an entirely new file system, and many other new features. It is certainly the most ambitious release of software ever prepared here and represents many man-years of work. Bill Shannon (both at DEC and at Sun Microsystems) and Robert Elz of the University of Melbourne contributed greatly to this distribution through new device drivers and painful debugging episodes. Rob Gurwitz of BBN wrote the initial version of the code upon which the current networking support is based. Eric Allman of Britton-Lee donated countless hours to the mail system. Bill Croft (both at SRI and Sun Microsystems) aided in the debugging and development of the networking facilities. Dennis Ritchie of Bell Laboratories also contributed greatly to this distribution, providing valuable advise and guidance. Helge Skrivervik worked on the device drivers which enabled the distribution to be delivered with a TU58 console cassette and RX01 console flopppy disk, and rewrote major portions of the standalone i/o system to support formatting of non-DEC peripherals. .LP Numerous others contributed their time and energy in organizing the user software for release, while many groups of people on campus suffered patiently through the low spots of development. As always, we are grateful to the UNIX user community for encouragement and support. .LP Once again, the financial support of the Defense Advanced Research Projects Agency is gratefully acknowledged. .sp 1 .in 4i .nf S. J. Leffler W. N. Joy M. K. McKusick .fi .in 0 .sp 2 .ne 1i .ce \fIPreface to the 4.1 Berkeley distribution\fP .sp 1 This update to the fourth distribution of November 1980 provides support for the VAX 11/750 and for the full interconnect architecture of the VAX 11/780. Robert Elz of the University of Melbourne contributed greatly to this distribution especially in the boot-time system configuration code; Bill Shannon of DEC supplied us with the implementation of DEC standard bad block handling. The research group at Bell Laboratories and DEC Merrimack provided us with access to 11/750's in order to debug its support. .LP Other individuals too numerous to mention provided us with bug reports, fixes and other enhancements which are reflected in the system. We are grateful to the UNIX user community for encouragement and support. .LP The financial support of the Defence Advanced Research Projects Agency in support of this work is gratefully acknowledged. .sp 1 .in 4i .nf W. N. Joy R. S. Fabry K. Sklower .fi .in 0 .sp 2 .ne 1i .ce \fIPreface to the Fourth Berkeley distribution\fP .sp 1 This manual reflects the Berkeley system mid-October, 1980. A large amount of tuning has been done in the system since the last release; we hope this provides as noticeable an improvement for you as it did for us. This release finds the system in transition; a number of facilities have been added in experimental versions (job control, resource limits) and the implementation of others is imminent (shared-segments, higher performance from the file system, etc.). Applications which use facilities that are in transition should be aware that some of the system calls and library routines will change in the near future. We have tried to be conscientious and make it very clear where this is likely. .LP A new group has been formed at Berkeley, to assume responsibility for the future development and support of a version of UNIX on the VAX. The group has received funding from the Defense Advanced Research Projects Agency (DARPA) to supply a standard version of the system to DARPA contractors. The same version of the system will be made available to other licensees of UNIX on the VAX for a duplication charge. We gratefully acknowledge the support of this contract. .LP We wish to acknowledge the contribution of a number of individuals to the the system. .LP We would especially like to thank Jim Kulp of IIASA, Laxenburg Austria and his colleagues, who first put job control facilities into UNIX; Eric Allman, Robert Henry, Peter Kessler and Kirk McKusick, who contributed major new pieces of software; Mark Horton, who contributed to the improvement of facilities and substantially improved the quality of our bit-mapped fonts, our hardware support staff: Bob Kridle, Anita Hirsch, Len Edmondson and Fred Archibald, who helped us to debug a number of new peripherals; Ken Arnold who did much of the leg-work in getting this version of the manual prepared, and did the final editing of sections 2-6, some special individuals within Bell Laboratories: Greg Chesson, Stuart Feldman, Dick Haight, Howard Katseff, Brian Kernighan, Tom London, John Reiser, Dennis Ritchie, Ken Thompson, and Peter Weinberger who helped out by answering questions; our excellent local DEC field service people, Kevin Althaus and Frank Chargois who kept our machine running virtually all the time, and fixed it quickly when things broke; and, Mike Accetta of Carnegie-Mellon University, Robert Elz of the University of Melbourne, George Goble of Purdue University, and David Kashtan of the Stanford Research Institute for their technical advice and support. .LP Special thanks to Bill Munson of DEC who helped by augmenting our computing facility and to Eric Allman for carefully proofreading the ``last'' draft of the manual and finding the bugs which we knew were there but couldn't see. .LP We dedicate this to the memory of David Sakrison, late chairman of our department, who gave his support to the establishment of our VAX computing facility, and to our department as a whole. .sp 1 .in 4i .nf W. N. Joy \v'-3p'\h'2p'\*:\v'3p'\h'-2p'O. Babao\*~glu R. S. Fabry K. Sklower .fi .in 0 .sp 2 .ne 1i .ce \fIPreface to the Third Berkeley distribution\fP .sp 1 This manual reflects the state of the Berkeley system, December 1979. We would like to thank all the people at Berkeley who have contributed to the system, and particularly thank Prof. Richard Fateman for creating and administrating a hospitable environment, Mark Horton who helped prepare this manual, and Eric Allman, Bob Kridle, Juan Porcar and Richard Tuck for their contributions to the kernel. .LP The cooperation of Bell Laboratories in providing us with an early version of \s-2UNIX\s0/32V is greatly appreciated. We would especially like to thank Dr. Charles Roberts of Bell Laboratories for helping us obtain this release, and acknowledge T. B. London, J. F. Reiser, K. Thompson, D. M. Ritchie, G. Chesson and H. P. Katseff for their advice and support. .sp 1 .in 4i W. N. Joy .br \v'-3p'\h'2p'\*:\v'3p'\h'-2p'O. Babao\*~glu .in 0 .sp 2 .ne 1i .ce \fIPreface to the UNIX/32V distribution\fP .sp 1 The .UX operating system for the VAX*-11 .FS *VAX and PDP are Trademarks of Digital Equipment Corporation. .FE provides substantially the same facilities as the \s-2UNIX\s0 system for the PDP*-11. .LP We acknowledge the work of many who came before us, and particularly thank G. K. Swanson, W. M. Cardoza, D. K. Sharma, and J. F. Jarvis for assistance with the implementation for the VAX-11/780. .sp 1 .in 4i T. B. London .br J. F. Reiser .in 0 .sp 2 .ne 1i .ce \fIPreface to the Seventh Edition\fP .sp 1 .LP Although this Seventh Edition no longer bears their byline, Ken Thompson and Dennis Ritchie remain the fathers and preceptors of the \s-2UNIX\s0 time-sharing system. Many of the improvements here described bear their mark. Among many, many other people who have contributed to the further flowering of \s-2UNIX\s0, we wish especially to acknowledge the contributions of A. V. Aho, S. R. Bourne, L. L. Cherry, G. L. Chesson, S. I. Feldman, C. B. Haley, R. C. Haight, S. C. Johnson, M. E. Lesk, T. L. Lyon, L. E. McMahon, R. Morris, R. Muha, D. A. Nowitz, L. Wehr, and P. J. Weinberger. We appreciate also the effective advice and criticism of T. A. Dolotta, A. G. Fraser, J. F. Maranzano, and J. R. Mashey; and we remember the important work of the late Joseph F. Ossanna. .sp 1 .in 4i B. W. Kernighan .br M. D. McIlroy .in 0 ================================================ FILE: share/man/man0/ptx.in ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)ptx.in 6.2 (Berkeley) 5/12/86 .\" .af % i .if t .pn 25\"PERMUTED INDEX .if n .pn 29 .tr ~ .ll 6.5i .lt 6.7i .po .75i .ds ET\" .de HD .po 0 .lt 7.4i .tl '''' .lt .po 'sp 18p .if o .tl '\\*(ET''- % -' .if e .tl '- % -''\\*(ET' 'sp 18p .ns .. .de FO 'sp 18p .if e .tl '\s9\\*(Dt''\\*(Ed\s0' .if o .tl '\s9\\*(Ed''\\*(Dt\s0' 'bp .. .wh 0 HD .wh -60p FO .if \n(nl .bp .br .ds ET \s9\f2Permuted \|Index\fP\s0 .ds Ed 4.3BSD .ds Dt April \|1986 .ce \f3PERMUTED \|INDEX\fP .sp 1v .ps 8 .vs 9p .nf .cs 3 36 .\" backup from slotput 1, slot, 2 .de xx .ds s1\" .if \w\\$2 .ds s1 ~~\" .ds s2 ~~~\" .ds s3\" .if \w\\$4 .ds s3 ~~\" .ds s4 ~~\" .ds s5 ~~\" .ds y \\*(s4\f3\fP\\*(s5 .ta 6i-\w\\*(s5u \h"3i-\w\\$1\\*(s1\\$2\\*(s2u"\\$1\\*(s1\\$2\\*(s2\\$3\\*(s3\\$4\\*y\\$5 .. .so ptxx .cs 3 .if n .ta 8n 16n 24n 32n 40n 48n 56n 64n 72n 80n .if t .ta .5i 1i 1.5i 2i 2.5i 3i 3.5i 4i 4.5i 5i 5.5i 6i 6.5i ================================================ FILE: share/man/man0/ptxx ================================================ .xx "" "" "@: arithmetic on shell variables." "" csh(1) .xx "" "imp:" "1822 network interface." "" imp(4) .xx "" "ddn: DDN Standard Mode X." "25 IMP interface." "" ddn(4) .xx "" "lib2648: subroutines for the HP" "2648 graphics terminal." "" lib2648(3X) .xx "" "mset: retrieve ASCII to IBM" "3270 keyboard map." "" mset(1) .xx "" "database for mapping ascii keystrokes into IBM" "3270 keys." "map3270:" map3270(5) .xx "" "ec:" "3Com 10 Mb/s Ethernet interface." "" ec(4) .xx "" "diff3:" "3-way differential file comparison." "" diff3(1) .xx "" "openpl et al.: f77 library interface to \fIplot\fR" "(3X) libraries.." "plot:" plot(3F) .xx "" "sendbug: mail a system bug report to" "4bsd-bugs." "" sendbug(1) .xx "" "crl: VAX" "8600 console RL02 interface." "" crl(4) .xx "" "" "aardvark: yet another exploration game." "" aardvark(6) .xx "" "abort:" "abnormal termination." "" abort(3F) .xx "" "" "abort: abnormal termination." "" abort(3F) .xx "" "" "abort: generate a fault." "" abort(3) .xx "" "" "abs: integer absolute value." "" abs(3) .xx "" "abs: integer" "absolute value." "" abs(3) .xx "" "hypot, cabs: Euclidean distance, complex" "absolute value." "" hypot(3M) .xx "round-to-nearest/" "fabs, floor, ceil, rint:" "absolute value, floor, ceiling, and" "" floor(3M) .xx "" "" "ac: login accounting." "" ac(8) .xx "" "" "acc: ACC LH/DH IMP interface." "" acc(4) .xx "" "hdh:" "ACC IF-11/HDH IMP interface." "" hdh(4) .xx "" "acc:" "ACC LH/DH IMP interface." "" acc(4) .xx "" "accept:" "accept a connection on a socket." "" accept(2) .xx "" "" "accept: accept a connection on a socket." "" accept(2) .xx "" "" "access: determine accessability of a file." "" access(3F) .xx "" "" "access: determine accessibility of file." "" access(2) .xx "" "getgroups: get group" "access list." "" getgroups(2) .xx "" "initgroups: initialize group" "access list." "" initgroups(3) .xx "" "setgroups: set group" "access list." "" setgroups(2) .xx "" "access: determine" "accessability of a file." "" access(3F) .xx "" "access: determine" "accessibility of file." "" access(2) .xx "" "ac: login" "accounting." "" ac(8) .xx "" "sa, accton: system" "accounting." "" sa(8) .xx "" "acct: execution" "accounting file." "" acct(5) .xx "" "pac: printer/plotter" "accounting information." "" pac(8) .xx "" "acct: turn" "accounting on or off." "" acct(2) .xx "" "" "acct: execution accounting file." "" acct(5) .xx "" "" "acct: turn accounting on or off." "" acct(2) .xx "" "sa," "accton: system accounting." "" sa(8) .xx "their inverses." "sin, cos, tan, asin," "acos, atan, atan2: trigonometric functions and" "" sin(3M) .xx "" "asinh," "acosh, atanh: inverse hyperbolic functions." "" asinh(3M) .xx "" "signal: change the" "action for a signal." "" signal(3F) .xx "" "ad: Data Translation" "A/D converter." "" ad(4) .xx "" "" "ad: Data Translation A/D converter." "" ad(4) .xx "" "fortune: print a random, hopefully interesting," "adage." "" fortune(6) .xx "" "" "adb: debugger." "" adb(1) .xx "" "swapon:" "add a swap device for interleaved paging/swapping." "" swapon(2) .xx "" "" "addbib: create or extend bibliographic database." "" addbib(1) .xx "" "adduser: procedure for" "adding new users." "" adduser(8) .xx "" "swapon: specify" "additional device for paging and swapping." "" swapon(8) .xx "" "ns_addr, ns_ntoa: Xerox NS(tm)" "address conversion routines." "" ns(3N) .xx "" "inet_makeaddr, inet_lnaof, inet_netof: Internet" "address manipulation routines." "/inet_ntoa," inet(3N) .xx "" "loc: return the" "address of an object." "" loc(3F) .xx "" "arp:" "address resolution display and control." "" arp(8C) .xx "" "arp:" "Address Resolution Protocol." "" arp(4P) .xx "" "mailaddr: mail" "addressing description." "" mailaddr(7) .xx "" "" "adduser: procedure for adding new users." "" adduser(8) .xx "of the system clock." "" "adjtime: correct the time to allow synchronization" "" adjtime(2) .xx "" "" "adventure: an exploration game." "" adventure(6) .xx "" "battlestar: a tropical" "adventure game." "" battlestar(6) .xx "" "flock: apply or remove an" "advisory lock on an open file." "" flock(2) .xx "" "yes: be repetitively" "affirmative." "" yes(1) .xx "" "basename: strip filename" "affixes." "" basename(1) .xx "" "learn: computer" "aided instruction about UNIX." "" learn(1) .xx "" "" "alarm: execute a subroutine after a specified time." "" alarm(3F) .xx "" "" "alarm: schedule signal after specified time." "" alarm(3C) .xx "" "L.aliases: UUCP hostname" "alias file." "" L.aliases(5) .xx "" "" "alias: shell macros." "" csh(1) .xx "" "unalias: remove" "aliases." "" csh(1) .xx "" "" "aliases: aliases file for sendmail." "" aliases(5) .xx "" "which: locate a program file including" "aliases and paths (\fIcsh\fR only)." "" which(1) .xx "" "newaliases: rebuild the data base for the mail" "aliases file." "" newaliases(1) .xx "" "aliases:" "aliases file for sendmail." "" aliases(5) .xx "" "L." "aliases: UUCP hostname alias file." "" L.aliases(5) .xx "" "valloc:" "aligned memory allocator." "" valloc(3C) .xx "" "malloc, free, realloc, calloc," "alloca: memory allocator." "" malloc(3) .xx "" "malloc, free, realloc, calloc, alloca: memory" "allocator." "" malloc(3) .xx "" "malloc, free, falloc: memory" "allocator." "" malloc(3F) .xx "" "valloc: aligned memory" "allocator." "" valloc(3C) .xx "" "scandir," "alphasort: scan a directory." "" scandir(3) .xx "" "limit:" "alter per-process resource limitations." "" csh(1) .xx "" "renice:" "alter priority of running processes." "" renice(8) .xx "" "else:" "alternative commands." "" csh(1) .xx "" "lex: generator of lexical" "analysis programs." "" lex(1) .xx "" "error:" "analyze and disperse compiler error messages." "" error(1) .xx "" "style:" "analyze surface characteristics of a document." "" style(1) .xx "" "worms:" "animate worms on a display terminal." "" worms(6) .xx "" "rain:" "animated raindrops display." "" rain(6) .xx "" "bcd: convert to" "antique media." "" bcd(6) .xx "" "sticky: persistent text and" "append-only directories." "" sticky(8) .xx "" "apply:" "apply a command to a set of arguments." "" apply(1) .xx "" "" "apply: apply a command to a set of arguments." "" apply(1) .xx "" "flock:" "apply or remove an advisory lock on an open file." "" flock(2) .xx "" "patch: a program for" "applying a diff file to an original." "" patch(1) .xx "" "" "apropos: locate commands by keyword lookup." "" apropos(1) .xx "" "" "ar: archive and library maintainer." "" ar(1) .xx "" "" "ar: archive (library) file format." "" ar(5) .xx "" "number: convert" "Arabic numerals to English." "" number(6) .xx "" "bc:" "arbitrary-precision arithmetic language." "" bc(1) .xx "graphics/" "plot: openpl, erase, label, line, circle," "arc, move, cont, point, linemod, space, closepl:" "" plot(3X) .xx "" "tp: manipulate tape" "archive." "" tp(1) .xx "" "ar:" "archive and library maintainer." "" ar(1) .xx "" "tar: tape" "archive file format." "" tar(5) .xx "" "ar:" "archive (library) file format." "" ar(5) .xx "" "tar: tape" "archiver." "" tar(1) .xx "" "arff, flcopy:" "archiver and copier for floppy." "" arff(8V) .xx "" "ranlib: convert" "archives to random libraries." "" ranlib(1) .xx "" "" "arff, flcopy: archiver and copier for floppy." "" arff(8V) .xx "" "glob: filename expand" "argument list." "" csh(1) .xx "" "shift: manipulate" "argument list." "" csh(1) .xx "" "varargs: variable" "argument list." "" varargs(3) .xx "" "apply: apply a command to a set of" "arguments." "" apply(1) .xx "" "echo: echo" "arguments." "" csh(1) .xx "" "echo: echo" "arguments." "" echo(1) .xx "" "getarg, iargc: return command line" "arguments." "" getarg(3F) .xx "" "expr: evaluate" "arguments as an expression." "" expr(1) .xx "" "getopt: get option letter from" "argv." "" getopt(3) .xx "" "m_out, sdiv, itom: multiple precision integer" "arithmetic." "/omin, fmin, m_in, mout, omout, fmout," mp(3X) .xx "" "traper: trap" "arithmetic errors." "" traper(3F) .xx "" "bc: arbitrary-precision" "arithmetic language." "" bc(1) .xx "" "@:" "arithmetic on shell variables." "" csh(1) .xx "" "" "arithmetic: provide drill in number facts." "" arithmetic(6) .xx "" "" "arp: address resolution display and control." "" arp(8C) .xx "" "" "arp: Address Resolution Protocol." "" arp(4P) .xx "" "ftp:" "ARPANET file transfer program." "" ftp(1C) .xx "" "biff: be notified if mail" "arrives and who it is from." "" biff(1) .xx "" "readnews: read news" "articles." "" readnews(1) .xx "" "vnews: read news" "articles." "" vnews(1) .xx "" "expr: evaluate arguments" "as an expression." "" expr(1) .xx "" "slattach: attach serial lines" "as network interfaces." "" slattach(8C) .xx "" "" "as: VAX-11 assembler." "" as(1) .xx "" "gmtime, asctime, timezone: convert date and time to" "ASCII." "ctime, localtime," ctime(3) .xx "" "ascii: map of" "ASCII character set." "" ascii(7) .xx "" "od: octal, decimal, hex," "ascii dump." "" od(1) .xx "" "map3270: database for mapping" "ascii keystrokes into IBM 3270 keys." "" map3270(5) .xx "" "" "ascii: map of ASCII character set." "" ascii(7) .xx "" "fdate: return date and time in an" "ASCII string." "" fdate(3F) .xx "" "mset: retrieve" "ASCII to IBM 3270 keyboard map." "" mset(1) .xx "" "atof, atoi, atol: convert" "ASCII to numbers." "" atof(3) .xx "" "ctime, localtime, gmtime," "asctime, timezone: convert date and time to ASCII." "" ctime(3) .xx "and their inverses." "sin, cos, tan," "asin, acos, atan, atan2: trigonometric functions" "" sin(3M) .xx "" "" "asinh, acosh, atanh: inverse hyperbolic functions." "" asinh(3M) .xx "" "as: VAX-11" "assembler." "" as(1) .xx "" "a.out:" "assembler and link editor output." "" a.out(5) .xx "" "" "assert: program verification." "" assert(3) .xx "" "setbuf, setbuffer, setlinebuf:" "assign buffering to a stream." "" setbuf(3S) .xx "" "atrm: remove jobs spooled by" "at." "" atrm(1) .xx "" "shutdown: close down the system" "at a given time." "" shutdown(8) .xx "" "at: execute commands" "at a later time." "" at(1) .xx "" "" "at: execute commands at a later time." "" at(1) .xx "" "nice, nohup: run a command" "at low priority (\fIsh\fR only)." "" nice(1) .xx "inverses." "sin, cos, tan, asin, acos," "atan, atan2: trigonometric functions and their" "" sin(3M) .xx "" "sin, cos, tan, asin, acos, atan," "atan2: trigonometric functions and their inverses." "" sin(3M) .xx "" "asinh, acosh," "atanh: inverse hyperbolic functions." "" asinh(3M) .xx "" "" "atof, atoi, atol: convert ASCII to numbers." "" atof(3) .xx "" "atof," "atoi, atol: convert ASCII to numbers." "" atof(3) .xx "" "atof, atoi," "atol: convert ASCII to numbers." "" atof(3) .xx "interrupt." "sigpause:" "atomically release blocked signals and wait for" "" sigpause(2) .xx "" "" "atq: print the queue of jobs waiting to be run." "" atq(1) .xx "" "" "atrm: remove jobs spooled by at." "" atrm(1) .xx "" "slattach:" "attach serial lines as network interfaces." "" slattach(8C) .xx "" "dn: DN-11" "autocall unit interface." "" dn(4) .xx "code." "" "autoconf: diagnostics from the autoconfiguration" "" autoconf(4) .xx "" "autoconf: diagnostics from the" "autoconfiguration code." "" autoconf(4) .xx "" "bugfiler: file bug reports in folders" "automatically." "" bugfiler(8) .xx "" "rc: command script for" "auto-reboot and daemons." "" rc(8) .xx "" "notes," "autoseq, readnotes: a news system." "" notes(1) .xx "" "wait:" "await completion of process." "" wait(1) .xx "" "" "awk: pattern scanning and processing language." "" awk(1) .xx "" "" "backgammon: the game." "" backgammon(6) .xx "" "bg: place job in" "background." "" csh(1) .xx "" "wait: wait for" "background processes to complete." "" csh(1) .xx "" "bad144: read/write dec standard 144" "bad sector information." "" bad144(8) .xx "" "badsect: create files to contain" "bad sectors." "" badsect(8) .xx "information." "" "bad144: read/write dec standard 144 bad sector" "" bad144(8) .xx "" "" "badsect: create files to contain bad sectors." "" badsect(8) .xx "" "banner: print large" "banner on printer." "" banner(6) .xx "" "" "banner: print large banner on printer." "" banner(6) .xx "" "gettytab: terminal configuration data" "base." "" gettytab(5) .xx "" "hosts: host name data" "base." "" hosts(5) .xx "" "networks: network name data" "base." "" networks(5) .xx "" "phones: remote host phone number data" "base." "" phones(5) .xx "" "printcap: printer capability data" "base." "" printcap(5) .xx "" "protocols: protocol name data" "base." "" protocols(5) .xx "" "services: service name data" "base." "" services(5) .xx "" "termcap: terminal capability data" "base." "" termcap(5) .xx "" "vgrindefs: vgrind's language definition data" "base." "" vgrindefs(5) .xx "" "newaliases: rebuild the data" "base for the mail aliases file." "" newaliases(1) .xx "" "fetch, store, delete, firstkey, nextkey: data" "base subroutines." "dbminit," dbm(3X) .xx "" "dbm_nextkey, dbm_error, dbm_clearerr: data" "base subroutines." "/dbm_delete, dbm_firstkey," ndbm(3) .xx "" "vi: screen oriented (visual) display editor" "based on ex." "" vi(1) .xx "" "" "basename: strip filename affixes." "" basename(1) .xx "" "" "battlestar: a tropical adventure game." "" battlestar(6) .xx "" "" "bc: arbitrary-precision arithmetic language." "" bc(1) .xx "" "" "bcd: convert to antique media." "" bcd(6) .xx "" "bcopy," "bcmp, bzero, ffs: bit and byte string operations." "" bstring(3) .xx "operations." "" "bcopy, bcmp, bzero, ffs: bit and byte string" "" bstring(3) .xx "" "cb: C program" "beautifier." "" cb(1) .xx "" "va:" "Benson-Varian interface." "" va(4) .xx "" "vfont: font formats for the" "Benson-Varian or Versatec." "" vfont(5) .xx "" "j0, j1, jn, y0, y1, yn:" "bessel functions." "" j0(3M) .xx "" "" "bessel functions: of two kinds for integer orders." "" bessel(3F) .xx "" "random, drandm, irandm:" "better random number generator." "" random(3F) .xx "changing/" "random, srandom, initstate, setstate:" "better random number generator; routines for" "" random(3) .xx "" "" "bg: place job in background." "" csh(1) .xx "bibliographic reference items." "" "bib, listrefs: bibliographic formatter; list" "" bib(1) .xx "" "addbib: create or extend" "bibliographic database." "" addbib(1) .xx "" "roffbib: run off" "bibliographic database." "" roffbib(1) .xx "" "sortbib: sort" "bibliographic database." "" sortbib(1) .xx "reference items." "bib, listrefs:" "bibliographic formatter; list bibliographic" "" bib(1) .xx "" "bib, listrefs: bibliographic formatter; list" "bibliographic reference items." "" bib(1) .xx "" "index for a bibliography, find references in a" "bibliography." "indxbib, lookbib: build inverted" lookbib(1) .xx "" "indxbib, lookbib: build inverted index for a" "bibliography, find references in a bibliography." "" lookbib(1) .xx "from." "" "biff: be notified if mail arrives and who it is" "" biff(1) .xx "" "comsat:" "biff server." "" comsat(8C) .xx "" "install: install" "binaries." "" install(1) .xx "" "whereis: locate source," "binary, and or manual for program." "" whereis(1) .xx "" "find the printable strings in a object, or other" "binary, file." "strings:" strings(1) .xx "" "uuencode, uudecode: encode/decode a" "binary file for transmission via mail." "" uuencode(1C) .xx "" "fread, fwrite: buffered" "binary input/output." "" fread(3S) .xx "" "bind:" "bind a name to a socket." "" bind(2) .xx "" "" "bind: bind a name to a socket." "" bind(2) .xx "" "" "binmail: send or receive mail among users." "" binmail(1) .xx "" "bcopy, bcmp, bzero, ffs:" "bit and byte string operations." "" bstring(3) .xx "functions." "" "bit: and, or, xor, not, rshift, lshift bitwise" "" bit(3F) .xx "" "bit: and, or, xor, not, rshift, lshift" "bitwise functions." "" bit(3F) .xx "communication (obsolete)." "" "bk: line discipline for machine-machine" "" bk(4) .xx "" "sync: update the super" "block." "" sync(8) .xx "" "update: periodically update the super" "block." "" update(8) .xx "" "sigblock:" "block signals." "" sigblock(2) .xx "" "sigpause: atomically release" "blocked signals and wait for interrupt." "" sigpause(2) .xx "" "sum: sum and count" "blocks in a file." "" sum(1) .xx "" "boggle: play the game of" "boggle." "" boggle(6) .xx "" "" "boggle: play the game of boggle." "" boggle(6) .xx "" "ching: the" "book of changes and other cookies." "" ching(6) .xx "" "reboot: UNIX" "bootstrapping procedures." "" reboot(8) .xx "" "mille: play Mille" "Bournes." "" mille(6) .xx "" "switch: multi-way command" "branch." "" csh(1) .xx "login,/" "sh, for, case, if, while, \fB:\fP, \fB.\fP," "break, continue, cd, eval, exec, exit, export," "" sh(1) .xx "" "" "break: exit while/foreach loop." "" csh(1) .xx "" "" "breaksw: exit from switch." "" csh(1) .xx "" "fg:" "bring job into foreground." "" csh(1) .xx "" "" "brk, sbrk: change data segment size." "" brk(2) .xx "" "ik: Ikonas frame" "buffer, graphics device interface." "" ik(4) .xx "" "fread, fwrite:" "buffered binary input/output." "" fread(3S) .xx "" "stdio: standard" "buffered input/output package." "" stdio(3S) .xx "" "setbuf, setbuffer, setlinebuf: assign" "buffering to a stream." "" setbuf(3S) .xx "" "generate a dump of the operating system's profile" "buffers." "kgmon:" kgmon(8) .xx "" "sendbug: mail a system" "bug report to 4bsd-bugs." "" sendbug(1) .xx "" "bugfiler: file" "bug reports in folders automatically." "" bugfiler(8) .xx "automatically." "" "bugfiler: file bug reports in folders" "" bugfiler(8) .xx "references in a bibliography." "indxbib, lookbib:" "build inverted index for a bibliography, find" "" lookbib(1) .xx "" "mknod:" "build special file." "" mknod(8) .xx "" "config:" "build system configuration files." "" config(8) .xx "" "ntohs: convert values between host and network" "byte order." "htonl, htons, ntohl," byteorder(3N) .xx "" "bcopy, bcmp, bzero, ffs: bit and" "byte string operations." "" bstring(3) .xx "" "swab: swap" "bytes." "" swab(3) .xx "" "bcopy, bcmp," "bzero, ffs: bit and byte string operations." "" bstring(3) .xx "" "cc:" "C compiler." "" cc(1) .xx "" "intro: introduction to" "C library functions." "" intro(3) .xx "" "cb:" "C program beautifier." "" cb(1) .xx "" "indent: indent and format" "C program source." "" indent(1) .xx "" "lint: a" "C program verifier." "" lint(1) .xx "" "xstr: extract strings from" "C programs to implement shared strings." "" xstr(1) .xx "" "mkstr: create an error message file by massaging" "C source." "" mkstr(1) .xx "" "hypot," "cabs: Euclidean distance, complex absolute value." "" hypot(3M) .xx "" "" "cal: print calendar." "" cal(1) .xx "" "diskpart:" "calculate default disk partition sizes." "" diskpart(8) .xx "" "dc: desk" "calculator." "" dc(1) .xx "" "cal: print" "calendar." "" cal(1) .xx "" "" "calendar: reminder service." "" calendar(1) .xx "" "syscall: indirect system" "call." "" syscall(2) .xx "" "gprof: display" "call graph profile data." "" gprof(1) .xx "" "getuid, getgid: get user or group ID of the" "caller." "" getuid(3F) .xx "" "malloc, free, realloc," "calloc, alloca: memory allocator." "" malloc(3) .xx "" "siginterrupt: allow signals to interrupt system" "calls." "" siginterrupt(3) .xx "" "intro: introduction to system" "calls and error numbers." "" intro(2) .xx "" "canfield, cfscores: the solitaire card game" "canfield." "" canfield(6) .xx "canfield." "" "canfield, cfscores: the solitaire card game" "" canfield(6) .xx "" "printcap: printer" "capability data base." "" printcap(5) .xx "" "termcap: terminal" "capability data base." "" termcap(5) .xx "" "canfield, cfscores: the solitaire" "card game canfield." "" canfield(6) .xx "" "cribbage: the" "card game cribbage." "" cribbage(6) .xx "cd, eval, exec, exit, export, login,/" "sh, for," "case, if, while, \fB:\fP, \fB.\fP, break, continue," "" sh(1) .xx "" "" "case: selector in switch." "" csh(1) .xx "" "tu: VAX-11/730 and VAX-11/750 TU58 console" "cassette interface." "" tu(4) .xx "" "uu: TU58/DECtape II UNIBUS" "cassette interface." "" uu(4) .xx "" "" "cat: catenate and print." "" cat(1) .xx "" "catman: create the" "cat files for the manual." "" catman(8) .xx "" "default:" "catchall clause in switch." "" csh(1) .xx "" "cat:" "catenate and print." "" cat(1) .xx "" "" "catman: create the cat files for the manual." "" catman(8) .xx "" "" "cb: C program beautifier." "" cb(1) .xx "" "" "cbrt, sqrt: cube root, square root." "" sqrt(3M) .xx "" "" "cc: C compiler." "" cc(1) .xx "" "" "cd: change directory." "" csh(1) .xx "" "" "cd: change working directory." "" cd(1) .xx "" "case, if, while, \fB:\fP, \fB.\fP, break, continue," "cd, eval, exec, exit, export, login, read,/" "/for," sh(1) .xx "round-to-nearest functions." "fabs, floor," "ceil, rint: absolute value, floor, ceiling, and" "" floor(3M) .xx "" "fabs, floor, ceil, rint: absolute value, floor," "ceiling, and round-to-nearest functions." "" floor(3M) .xx "" "canfield," "cfscores: the solitaire card game canfield." "" canfield(6) .xx "" "chdir:" "change current working directory." "" chdir(2) .xx "" "brk, sbrk:" "change data segment size." "" brk(2) .xx "" "chdir:" "change default directory." "" chdir(3F) .xx "" "cd:" "change directory." "" csh(1) .xx "" "chdir:" "change directory." "" csh(1) .xx "" "ioinit:" "change f77 I/O initialization." "" ioinit(3F) .xx "" "chgrp:" "change group." "" chgrp(1) .xx "" "chmod:" "change mode." "" chmod(1) .xx "" "chmod:" "change mode of a file." "" chmod(3F) .xx "" "chmod:" "change mode of file." "" chmod(2) .xx "" "umask:" "change or display file creation mask." "" csh(1) .xx "" "chown:" "change owner." "" chown(8) .xx "" "chown:" "change owner and group of a file." "" chown(2) .xx "" "chfn, chsh, passwd:" "change password file information." "" chfn(1) .xx "" "chfn, chsh, passwd:" "change password file information." "" chsh(1) .xx "" "chfn, chsh, passwd:" "change password file information." "" passwd(1) .xx "" "chroot:" "change root directory." "" chroot(2) .xx "" "signal:" "change the action for a signal." "" signal(3F) .xx "" "rename:" "change the name of a file." "" rename(2) .xx "" "set:" "change value of shell variable." "" csh(1) .xx "" "cd:" "change working directory." "" cd(1) .xx "" "ching: the book of" "changes and other cookies." "" ching(6) .xx "" "better random number generator; routines for" "changing generators." "/srandom, initstate, setstate:" random(3) .xx "" "pipe: create an interprocess communication" "channel." "" pipe(2) .xx "" "ungetc: push" "character back into input stream." "" ungetc(3S) .xx "" "iscntrl, isascii, toupper, tolower, toascii:" "character classification macros." "/isprint, isgraph," ctype(3) .xx "" "eqnchar: special" "character definitions for eqn." "" eqnchar(7) .xx "" "getc, fgetc: get a" "character from a logical unit." "" getc(3F) .xx "" "index, rindex, lnblnk, len: tell about" "character objects." "" index(3F) .xx "" "getc, getchar, fgetc, getw: get" "character or word from stream." "" getc(3S) .xx "" "putc, putchar, fputc, putw: put" "character or word on a stream." "" putc(3S) .xx "" "ascii: map of ASCII" "character set." "" ascii(7) .xx "" "putc, fputc: write a" "character to a fortran logical unit." "" putc(3F) .xx "" "style: analyze surface" "characteristics of a document." "" style(1) .xx "" "tr: translate" "characters." "" tr(1) .xx "" "snake, snscore: display" "chase game." "" snake(6) .xx "" "" "chdir: change current working directory." "" chdir(2) .xx "" "" "chdir: change default directory." "" chdir(3F) .xx "" "" "chdir: change directory." "" csh(1) .xx "" "dcheck: file system directory consistency" "check." "" dcheck(8) .xx "" "icheck: file system storage consistency" "check." "" icheck(8) .xx "" "fsck: file system consistency" "check and interactive repair." "" fsck(8) .xx "" "checknr:" "check nroff/troff files." "" checknr(1) .xx "" "eqn, neqn," "checkeq: typeset mathematics." "" eqn(1) .xx "" "quotacheck: file system quota consistency" "checker." "" quotacheck(8) .xx "" "fastboot, fasthalt: reboot/halt the system without" "checking the disks." "" fastboot(8) .xx "" "" "checknr: check nroff/troff files." "" checknr(1) .xx "" "chess: the game of" "chess." "" chess(6) .xx "" "" "chess: the game of chess." "" chess(6) .xx "information." "" "chfn, chsh, passwd: change password file" "" chfn(1) .xx "information." "" "chfn, chsh, passwd: change password file" "" chsh(1) .xx "information." "" "chfn, chsh, passwd: change password file" "" passwd(1) .xx "" "" "chgrp: change group." "" chgrp(1) .xx "" "" "ching: the book of changes and other cookies." "" ching(6) .xx "" "" "chmod: change mode." "" chmod(1) .xx "" "" "chmod: change mode of a file." "" chmod(3F) .xx "" "" "chmod: change mode of file." "" chmod(2) .xx "" "" "chown: change owner." "" chown(8) .xx "" "" "chown: change owner and group of a file." "" chown(2) .xx "" "" "chroot: change root directory." "" chroot(2) .xx "" "chfn," "chsh, passwd: change password file information." "" chfn(1) .xx "" "chfn," "chsh, passwd: change password file information." "" chsh(1) .xx "" "chfn," "chsh, passwd: change password file information." "" passwd(1) .xx "closepl:/" "plot: openpl, erase, label, line," "circle, arc, move, cont, point, linemod, space," "" plot(3X) .xx "" "isascii, toupper, tolower, toascii: character" "classification macros." "/isprint, isgraph, iscntrl," ctype(3) .xx "" "default: catchall" "clause in switch." "" csh(1) .xx "" "uuclean: uucp spool directory" "clean-up." "" uuclean(8C) .xx "" "" "clear: clear terminal screen." "" clear(1) .xx "" "clri:" "clear i-node." "" clri(8) .xx "" "clear:" "clear terminal screen." "" clear(1) .xx "" "ferror, feof," "clearerr, fileno: stream status inquiries." "" ferror(3S) .xx "" "csh: a shell (command interpreter) with" "C-like syntax." "" csh(1) .xx "" "the time to allow synchronization of the system" "clock." "adjtime: correct" adjtime(2) .xx "" "kg: KL-11/DL-11W line" "clock." "" kg(4) .xx "" "cron:" "clock daemon." "" cron(8) .xx "" "" "close: delete a descriptor." "" close(2) .xx "" "shutdown:" "close down the system at a given time." "" shutdown(8) .xx "" "fclose, fflush:" "close or flush a stream." "" fclose(3S) .xx "" "opendir, readdir, telldir, seekdir, rewinddir," "closedir: directory operations." "" directory(3) .xx "" "syslog, openlog," "closelog, setlogmask: control system log." "" syslog(3) .xx "" "circle, arc, move, cont, point, linemod, space," "closepl: graphics interface." "/erase, label, line," plot(3X) .xx "" "" "clri: clear i-node." "" clri(8) .xx "" "L." "cmds: UUCP remote command permissions file." "" L.cmds(5) .xx "" "" "cmp: compare two files." "" cmp(1) .xx "" "autoconf: diagnostics from the autoconfiguration" "code." "" autoconf(4) .xx "" "pi: Pascal interpreter" "code translator." "" pi(1) .xx "" "" "col: filter reverse line feeds." "" col(1) .xx "" "" "colcrt: filter nroff output for CRT previewing." "" colcrt(1) .xx "log." "dmesg:" "collect system diagnostic messages to form error" "" dmesg(8) .xx "" "" "colrm: remove columns from a file." "" colrm(1) .xx "" "colrm: remove" "columns from a file." "" colrm(1) .xx "files." "" "comm: select or reject lines common to two sorted" "" comm(1) .xx "" "exec: overlay shell with specified" "command." "" csh(1) .xx "" "time: time" "command." "" csh(1) .xx "" "routines for returning a stream to a remote" "command." "rcmd, rresvport, ruserok:" rcmd(3) .xx "" "rexec: return stream to a remote" "command." "" rexec(3) .xx "" "system: issue a shell" "command." "" system(3) .xx "" "system: execute a UNIX" "command." "" system(3F) .xx "" "test: condition" "command." "" test(1) .xx "" "time: time a" "command." "" time(1) .xx "" "nice, nohup: run a" "command at low priority (\fIsh\fR only)." "" nice(1) .xx "" "switch: multi-way" "command branch." "" csh(1) .xx "" "uux: unix to unix" "command execution." "" uux(1C) .xx "" "rehash: recompute" "command hash table." "" csh(1) .xx "" "unhash: discard" "command hash table." "" csh(1) .xx "" "hashstat: print" "command hashing statistics." "" csh(1) .xx "" "nohup: run" "command immune to hangups." "" csh(1) .xx "" "csh: a shell" "(command interpreter) with C-like syntax." "" csh(1) .xx "" "whatis: describe what a" "command is." "" whatis(1) .xx "" "readonly, set, shift, times, trap, umask, wait:" "command language." "/exec, exit, export, login, read," sh(1) .xx "" "getarg, iargc: return" "command line arguments." "" getarg(3F) .xx "" "L.cmds: UUCP remote" "command permissions file." "" L.cmds(5) .xx "" "repeat: execute" "command repeatedly." "" csh(1) .xx "" "rc:" "command script for auto-reboot and daemons." "" rc(8) .xx "" "onintr: process interrupts in" "command scripts." "" csh(1) .xx "" "apply: apply a" "command to a set of arguments." "" apply(1) .xx "" "goto:" "command transfer." "" csh(1) .xx "" "else: alternative" "commands." "" csh(1) .xx "" "intro: introduction to" "commands." "" intro(1) .xx "" "introduction to system maintenance and operation" "commands." "intro:" intro(8) .xx "" "rcsintro: introduction to RCS" "commands." "" rcsintro(1) .xx "" "at: execute" "commands at a later time." "" at(1) .xx "" "apropos: locate" "commands by keyword lookup." "" apropos(1) .xx "" "while: repeat" "commands conditionally." "" csh(1) .xx "" "lastcomm: show last" "commands executed in reverse order." "" lastcomm(1) .xx "" "source: read" "commands from file." "" csh(1) .xx "" "comm: select or reject lines" "common to two sorted files." "" comm(1) .xx "" "socket: create an endpoint for" "communication." "" socket(2) .xx "" "pipe: create an interprocess" "communication channel." "" pipe(2) .xx "" "bk: line discipline for machine-machine" "communication (obsolete)." "" bk(4) .xx "" "talkd: remote user" "communication server." "" talkd(8C) .xx "" "dmc: DEC DMC-11/DMR-11 point-to-point" "communications device." "" dmc(4) .xx "" "dh: DH-11/DM-11" "communications multiplexer." "" dh(4) .xx "" "dhu: DHU-11" "communications multiplexer." "" dhu(4) .xx "" "dz: DZ-11" "communications multiplexer." "" dz(4) .xx "" "users:" "compact list of users who are on the system." "" users(1) .xx "" "diff: differential file and directory" "comparator." "" diff(1) .xx "" "cmp:" "compare two files." "" cmp(1) .xx "" "diff3: 3-way differential file" "comparison." "" diff3(1) .xx "" "liszt:" "compile a Franz Lisp program." "" liszt(1) .xx "" "cc: C" "compiler." "" cc(1) .xx "" "f77: Fortran 77" "compiler." "" f77(1) .xx "" "pc: Pascal" "compiler." "" pc(1) .xx "" "error: analyze and disperse" "compiler error messages." "" error(1) .xx "" "yacc: yet another" "compiler-compiler." "" yacc(1) .xx "" "fp: Functional Programming language" "compiler/interpreter." "" fp(1) .xx "" "wait: wait for background processes to" "complete." "" csh(1) .xx "" "wait: await" "completion of process." "" wait(1) .xx "" "hypot, cabs: Euclidean distance," "complex absolute value." "" hypot(3M) .xx "" "compress, uncompress, zcat:" "compress and expand data." "" compress(1) .xx "data." "" "compress, uncompress, zcat: compress and expand" "" compress(1) .xx "" "learn:" "computer aided instruction about UNIX." "" learn(1) .xx "" "hangman:" "Computer version of the game hangman." "" hangman(6) .xx "" "" "comsat: biff server." "" comsat(8C) .xx "" "test:" "condition command." "" test(1) .xx "" "endif: terminate" "conditional." "" csh(1) .xx "" "if:" "conditional statement." "" csh(1) .xx "" "while: repeat commands" "conditionally." "" csh(1) .xx "" "" "config: build system configuration files." "" config(8) .xx "" "gettytab: terminal" "configuration data base." "" gettytab(5) .xx "" "resolver" "configuration file." "" resolver(5) .xx "" "config: build system" "configuration files." "" config(8) .xx "" "ifconfig:" "configure network interface parameters." "" ifconfig(8C) .xx "" "" "connect: initiate a connection on a socket." "" connect(2) .xx "" "tip, cu:" "connect to a remote system." "" tip(1C) .xx "" "getpeername: get name of" "connected peer." "" getpeername(2) .xx "" "socketpair: create a pair of" "connected sockets." "" socketpair(2) .xx "" "shutdown: shut down part of a full-duplex" "connection." "" shutdown(2) .xx "" "accept: accept a" "connection on a socket." "" accept(2) .xx "" "connect: initiate a" "connection on a socket." "" connect(2) .xx "" "listen: listen for" "connections on a socket." "" listen(2) .xx "" "" "cons: VAX-11 console interface." "" cons(4) .xx "" "dcheck: file system directory" "consistency check." "" dcheck(8) .xx "" "icheck: file system storage" "consistency check." "" icheck(8) .xx "" "fsck: file system" "consistency check and interactive repair." "" fsck(8) .xx "" "quotacheck: file system quota" "consistency checker." "" quotacheck(8) .xx "" "tu: VAX-11/730 and VAX-11/750 TU58" "console cassette interface." "" tu(4) .xx "" "fl:" "console floppy interface." "" fl(4) .xx "" "cons: VAX-11" "console interface." "" cons(4) .xx "" "crl: VAX 8600" "console RL02 interface." "" crl(4) .xx "" "show what versions of object modules were used to" "construct a file." "what:" what(1) .xx "" "mkfs:" "construct a file system." "" mkfs(8) .xx "" "newfs:" "construct a new file system." "" newfs(8) .xx "" "mkproto:" "construct a prototype file system." "" mkproto(8) .xx "" "deroff: remove nroff, troff, tbl and eqn" "constructs." "" deroff(1) .xx "" "setrlimit: control maximum system resource" "consumption." "getrlimit," getrlimit(2) .xx "" "vlimit: control maximum system resource" "consumption." "" vlimit(3C) .xx "" "/openpl, erase, label, line, circle, arc, move," "cont, point, linemod, space, closepl: graphics/" "" plot(3X) .xx "" "badsect: create files to" "contain bad sectors." "" badsect(8) .xx "" "ls: list" "contents of directory." "" ls(1) .xx "" "sigstack: set and/or get signal stack" "context." "" sigstack(2) .xx "" "sh, for, case, if, while, \fB:\fP, \fB.\fP, break," "continue, cd, eval, exec, exit, export, login,/" "" sh(1) .xx "" "" "continue: cycle in loop." "" csh(1) .xx "" "arp: address resolution display and" "control." "" arp(8C) .xx "" "fcntl: file" "control." "" fcntl(2) .xx "" "ioctl:" "control device." "" ioctl(2) .xx "" "init: process" "control initialization." "" init(8) .xx "" "getrlimit, setrlimit:" "control maximum system resource consumption." "" getrlimit(2) .xx "" "vlimit:" "control maximum system resource consumption." "" vlimit(3C) .xx "" "icmp: Internet" "Control Message Protocol." "" icmp(4P) .xx "" "lpc: line printer" "control program." "" lpc(8) .xx "" "timedc: timed" "control program." "" timedc(8) .xx "" "tcp: Internet Transmission" "Control Protocol." "" tcp(4P) .xx "" "syslog, openlog, closelog, setlogmask:" "control system log." "" syslog(3) .xx "" "vhangup: virtually ``hangup'' the current" "control terminal." "" vhangup(2) .xx "" "uda: UDA-50 disk" "controller interface." "" uda(4) .xx "" "up: unibus storage module" "controller/drives." "" up(4) .xx "" "term:" "conventional names for terminals." "" term(7) .xx "" "ecvt, fcvt, gcvt: output" "conversion." "" ecvt(3) .xx "" "long, short: integer object" "conversion." "" long(3F) .xx "" "printf, fprintf, sprintf: formatted output" "conversion." "" printf(3S) .xx "" "scanf, fscanf, sscanf: formatted input" "conversion." "" scanf(3S) .xx "" "units:" "conversion program." "" units(1) .xx "" "ns_addr, ns_ntoa: Xerox NS(tm) address" "conversion routines." "" ns(3N) .xx "" "dd:" "convert and copy a file." "" dd(1) .xx "" "number:" "convert Arabic numerals to English." "" number(6) .xx "" "ranlib:" "convert archives to random libraries." "" ranlib(1) .xx "" "atof, atoi, atol:" "convert ASCII to numbers." "" atof(3) .xx "" "ctime, localtime, gmtime, asctime, timezone:" "convert date and time to ASCII." "" ctime(3) .xx "" "htable:" "convert NIC standard format host tables." "" htable(8) .xx "" "bcd:" "convert to antique media." "" bcd(6) .xx "" "htonl, htons, ntohl, ntohs:" "convert values between host and network byte order." "" byteorder(3N) .xx "" "ad: Data Translation A/D" "converter." "" ad(4) .xx "" "ching: the book of changes and other" "cookies." "" ching(6) .xx "" "arff, flcopy: archiver and" "copier for floppy." "" arff(8V) .xx "" "cp:" "copy." "" cp(1) .xx "" "rcp: remote file" "copy." "" rcp(1C) .xx "" "uucp: unix to unix" "copy." "" uucp(1C) .xx "" "dd: convert and" "copy a file." "" dd(1) .xx "" "tcopy:" "copy a mag tape." "" tcopy(1) .xx "" "fork: create a" "copy of this process." "" fork(3F) .xx "remainder, exponent manipulations." "" "copysign, drem, finite, logb, scalb: copysign," "" ieee(3M) .xx "" "copysign, drem, finite, logb, scalb:" "copysign, remainder, exponent manipulations." "" ieee(3M) .xx "" "savecore: save a" "core dump of the operating system." "" savecore(8) .xx "" "" "core: format of memory image file." "" core(5) .xx "" "gcore: get" "core images of running processes." "" gcore(1) .xx "system clock." "adjtime:" "correct the time to allow synchronization of the" "" adjtime(2) .xx "functions and their inverses." "sin," "cos, tan, asin, acos, atan, atan2: trigonometric" "" sin(3M) .xx "" "sinh," "cosh, tanh: hyperbolic functions." "" sinh(3M) .xx "" "wc: word" "count." "" wc(1) .xx "" "sum: sum and" "count blocks in a file." "" sum(1) .xx "" "" "cp: copy." "" cp(1) .xx "" "" "crash: what happens when the system crashes." "" crash(8V) .xx "" "crash: what happens when the system" "crashes." "" crash(8V) .xx "" "" "creat: create a new file." "" creat(2) .xx "" "fork:" "create a copy of this process." "" fork(3F) .xx "" "creat:" "create a new file." "" creat(2) .xx "" "open: open a file for reading or writing, or" "create a new file." "" open(2) .xx "" "fork:" "create a new process." "" fork(2) .xx "" "socketpair:" "create a pair of connected sockets." "" socketpair(2) .xx "" "ctags:" "create a tags file." "" ctags(1) .xx "" "socket:" "create an endpoint for communication." "" socket(2) .xx "" "mkstr:" "create an error message file by massaging C source." "" mkstr(1) .xx "" "pipe:" "create an interprocess communication channel." "" pipe(2) .xx "" "badsect:" "create files to contain bad sectors." "" badsect(8) .xx "" "addbib:" "create or extend bibliographic database." "" addbib(1) .xx "" "catman:" "create the cat files for the manual." "" catman(8) .xx "" "umask: change or display file" "creation mask." "" csh(1) .xx "" "umask: set file" "creation mode mask." "" umask(2) .xx "" "cribbage: the card game" "cribbage." "" cribbage(6) .xx "" "" "cribbage: the card game cribbage." "" cribbage(6) .xx "" "" "crl: VAX 8600 console RL02 interface." "" crl(4) .xx "" "" "cron: clock daemon." "" cron(8) .xx "" "lxref: lisp" "cross reference program." "" lxref(1) .xx "" "pxref: Pascal" "cross-reference program." "" pxref(1) .xx "" "systat: display system statistics on a" "crt." "" systat(1) .xx "" "colcrt: filter nroff output for" "CRT previewing." "" colcrt(1) .xx "" "more, page: file perusal filter for" "crt viewing." "" more(1) .xx "" "" "crypt: encode/decode." "" crypt(1) .xx "" "" "crypt, setkey, encrypt: DES encryption." "" crypt(3) .xx "syntax." "" "csh: a shell (command interpreter) with C-like" "" csh(1) .xx "" "" "css: DEC IMP-11A LH/DH IMP interface." "" css(4) .xx "" "pcl: DEC" "CSS PCL-11 B Network Interface." "" pcl(4) .xx "" "" "ct: phototypesetter interface." "" ct(4) .xx "" "" "ctags: create a tags file." "" ctags(1) .xx "convert date and time to ASCII." "" "ctime, localtime, gmtime, asctime, timezone:" "" ctime(3) .xx "" "time," "ctime, ltime, gmtime: return system time." "" time(3F) .xx "" "tip," "cu: connect to a remote system." "" tip(1C) .xx "" "cbrt, sqrt:" "cube root, square root." "" sqrt(3M) .xx "" "vhangup: virtually ``hangup'' the" "current control terminal." "" vhangup(2) .xx "" "gethostid, sethostid: get/set unique identifier of" "current host." "" gethostid(2) .xx "" "gethostname, sethostname: get/set name of" "current host." "" gethostname(2) .xx "" "hostnm: get name of" "current host." "" hostnm(3F) .xx "" "hostid: set or print identifier of" "current host system." "" hostid(1) .xx "" "hostname: set or print name of" "current host system." "" hostname(1) .xx "" "jobs: print" "current job list." "" csh(1) .xx "" "sigsetmask: set" "current signal mask." "" sigsetmask(2) .xx "" "whoami: print effective" "current user id." "" whoami(1) .xx "" "chdir: change" "current working directory." "" chdir(2) .xx "" "getcwd: get pathname of" "current working directory." "" getcwd(3F) .xx "" "getwd: get" "current working directory pathname." "" getwd(3) .xx "motion." "" "curses: screen functions with ``optimal'' cursor" "" curses(3X) .xx "" "curses: screen functions with ``optimal''" "cursor motion." "" curses(3X) .xx "" "spline: interpolate smooth" "curve." "" spline(1G) .xx "" "continue:" "cycle in loop." "" csh(1) .xx "" "cron: clock" "daemon." "" cron(8) .xx "" "lpd: line printer" "daemon." "" lpd(8) .xx "" "routed: network routing" "daemon." "" routed(8C) .xx "" "timed: time server" "daemon." "" timed(8) .xx "" "XNSrouted: NS Routing Information Protocol" "daemon." "" XNSrouted(8C) .xx "" "rc: command script for auto-reboot and" "daemons." "" rc(8) .xx "" "ftpd:" "DARPA Internet File Transfer Protocol server." "" ftpd(8C) .xx "" "whois:" "DARPA Internet user name directory service." "" whois(1) .xx "" "telnetd:" "DARPA TELNET protocol server." "" telnetd(8C) .xx "" "tftpd:" "DARPA Trivial File Transfer Protocol server." "" tftpd(8C) .xx "" "compress, uncompress, zcat: compress and expand" "data." "" compress(1) .xx "" "eval: re-evaluate shell" "data." "" csh(1) .xx "" "gprof: display call graph profile" "data." "" gprof(1) .xx "" "prof: display profile" "data." "" prof(1) .xx "" "ttys: terminal initialization" "data." "" ttys(5) .xx "" "gettytab: terminal configuration" "data base." "" gettytab(5) .xx "" "hosts: host name" "data base." "" hosts(5) .xx "" "networks: network name" "data base." "" networks(5) .xx "" "phones: remote host phone number" "data base." "" phones(5) .xx "" "printcap: printer capability" "data base." "" printcap(5) .xx "" "protocols: protocol name" "data base." "" protocols(5) .xx "" "services: service name" "data base." "" services(5) .xx "" "termcap: terminal capability" "data base." "" termcap(5) .xx "" "vgrindefs: vgrind's language definition" "data base." "" vgrindefs(5) .xx "" "newaliases: rebuild the" "data base for the mail aliases file." "" newaliases(1) .xx "" "dbminit, fetch, store, delete, firstkey, nextkey:" "data base subroutines." "" dbm(3X) .xx "" "dbm_firstkey, dbm_nextkey, dbm_error, dbm_clearerr:" "data base subroutines." "/dbm_store, dbm_delete," ndbm(3) .xx "" "brk, sbrk: change" "data segment size." "" brk(2) .xx "" "null:" "data sink." "" null(4) .xx "" "ad:" "Data Translation A/D converter." "" ad(4) .xx "" "types: primitive system" "data types." "" types(5) .xx "" "addbib: create or extend bibliographic" "database." "" addbib(1) .xx "" "roffbib: run off bibliographic" "database." "" roffbib(1) .xx "" "sortbib: sort bibliographic" "database." "" sortbib(1) .xx "keys." "map3270:" "database for mapping ascii keystrokes into IBM 3270" "" map3270(5) .xx "" "join: relational" "database operator." "" join(1) .xx "" "idp: Xerox Internet" "Datagram Protocol." "" idp(4P) .xx "" "udp: Internet User" "Datagram Protocol." "" udp(4P) .xx "" "date: print and set the" "date." "" date(1) .xx "" "gettimeofday, settimeofday: get/set" "date and time." "" gettimeofday(2) .xx "" "time, ftime: get" "date and time." "" time(3C) .xx "" "fdate: return" "date and time in an ASCII string." "" fdate(3F) .xx "" "localtime, gmtime, asctime, timezone: convert" "date and time to ASCII." "ctime," ctime(3) .xx "" "touch: update" "date last modified of a file." "" touch(1) .xx "" "idate, itime: return" "date or time in numerical form." "" idate(3F) .xx "" "" "date: print and set the date." "" date(1) .xx "" "dbm_delete, dbm_firstkey, dbm_nextkey, dbm_error," "dbm_clearerr: data base subroutines." "/dbm_store," ndbm(3) .xx "dbm_firstkey, dbm_nextkey, dbm_error,/" "dbm_open," "dbm_close, dbm_fetch, dbm_store, dbm_delete," "" ndbm(3) .xx "" "dbm_open, dbm_close, dbm_fetch, dbm_store," "dbm_delete, dbm_firstkey, dbm_nextkey, dbm_error,/" "" ndbm(3) .xx "" "/dbm_store, dbm_delete, dbm_firstkey, dbm_nextkey," "dbm_error, dbm_clearerr: data base subroutines." "" ndbm(3) .xx "dbm_nextkey, dbm_error,/" "dbm_open, dbm_close," "dbm_fetch, dbm_store, dbm_delete, dbm_firstkey," "" ndbm(3) .xx "data/" "/dbm_close, dbm_fetch, dbm_store, dbm_delete," "dbm_firstkey, dbm_nextkey, dbm_error, dbm_clearerr:" "" ndbm(3) .xx "data base subroutines." "" "dbminit, fetch, store, delete, firstkey, nextkey:" "" dbm(3X) .xx "" "/dbm_fetch, dbm_store, dbm_delete, dbm_firstkey," "dbm_nextkey, dbm_error, dbm_clearerr: data base/" "" ndbm(3) .xx "dbm_delete, dbm_firstkey, dbm_nextkey, dbm_error,/" "" "dbm_open, dbm_close, dbm_fetch, dbm_store," "" ndbm(3) .xx "dbm_error,/" "dbm_open, dbm_close, dbm_fetch," "dbm_store, dbm_delete, dbm_firstkey, dbm_nextkey," "" ndbm(3) .xx "" "" "dbx: dbx symbol table information." "" dbx(5) .xx "" "" "dbx: debugger." "" dbx(1) .xx "" "dbx:" "dbx symbol table information." "" dbx(5) .xx "" "" "dc: desk calculator." "" dc(1) .xx "" "" "dcheck: file system directory consistency check." "" dcheck(8) .xx "" "" "dd: convert and copy a file." "" dd(1) .xx "" "" "ddn: DDN Standard Mode X.25 IMP interface." "" ddn(4) .xx "" "ddn:" "DDN Standard Mode X.25 IMP interface." "" ddn(4) .xx "" "" "de: DEC DEUNA 10 Mb/s Ethernet interface." "" de(4) .xx "" "adb:" "debugger." "" adb(1) .xx "" "dbx:" "debugger." "" dbx(1) .xx "" "pdx: pascal" "debugger." "" pdx(1) .xx "" "pcl:" "DEC CSS PCL-11 B Network Interface." "" pcl(4) .xx "" "qe:" "DEC DEQNA Q-bus 10 Mb/s Ethernet interface." "" qe(4) .xx "" "de:" "DEC DEUNA 10 Mb/s Ethernet interface." "" de(4) .xx "device." "dmc:" "DEC DMC-11/DMR-11 point-to-point communications" "" dmc(4) .xx "" "css:" "DEC IMP-11A LH/DH IMP interface." "" css(4) .xx "" "rx:" "DEC RX02 floppy disk interface." "" rx(4) .xx "" "bad144: read/write" "dec standard 144 bad sector information." "" bad144(8) .xx "" "tmscp:" "DEC TMSCP magtape interface." "" tmscp(4) .xx "" "od: octal," "decimal, hex, ascii dump." "" od(1) .xx "" "tp:" "DEC/mag tape formats." "" tp(5) .xx "" "" "default: catchall clause in switch." "" csh(1) .xx "" "chdir: change" "default directory." "" chdir(3F) .xx "" "diskpart: calculate" "default disk partition sizes." "" diskpart(8) .xx "" "vgrindefs: vgrind's language" "definition data base." "" vgrindefs(5) .xx "" "eqnchar: special character" "definitions for eqn." "" eqnchar(7) .xx "" "stty, gtty: set and get terminal state" "(defunct)." "" stty(3C) .xx "" "close:" "delete a descriptor." "" close(2) .xx "" "dbminit, fetch, store," "delete, firstkey, nextkey: data base subroutines." "" dbm(3X) .xx "" "tail:" "deliver the last part of a file." "" tail(1) .xx "" "mesg: permit or" "deny messages." "" mesg(1) .xx "" "tset: terminal" "dependent initialization." "" tset(1) .xx "" "qe: DEC" "DEQNA Q-bus 10 Mb/s Ethernet interface." "" qe(4) .xx "constructs." "" "deroff: remove nroff, troff, tbl and eqn" "" deroff(1) .xx "" "crypt, setkey, encrypt:" "DES encryption." "" crypt(3) .xx "" "whatis:" "describe what a command is." "" whatis(1) .xx "" "mailaddr: mail addressing" "description." "" mailaddr(7) .xx "" "getdiskbyname: get disk" "description by its name." "" getdisk(3) .xx "" "disktab: disk" "description file." "" disktab(5) .xx "" "L-devices: UUCP device" "description file." "" L-devices(5) .xx "" "L.sys: UUCP remote host" "description file." "" L.sys(5) .xx "" "remote: remote host" "description file." "" remote(5) .xx "" "close: delete a" "descriptor." "" close(2) .xx "" "dup, dup2: duplicate a" "descriptor." "" dup(2) .xx "" "getfstype, setfsent, endfsent: get file system" "descriptor file entry." "/getfsspec, getfsfile," getfsent(3) .xx "" "getdtablesize: get" "descriptor table size." "" getdtablesize(2) .xx "" "dc:" "desk calculator." "" dc(1) .xx "" "access:" "determine accessability of a file." "" access(3F) .xx "" "access:" "determine accessibility of file." "" access(2) .xx "" "file:" "determine file type." "" file(1) .xx "" "de: DEC" "DEUNA 10 Mb/s Ethernet interface." "" de(4) .xx "" "DEC DMC-11/DMR-11 point-to-point communications" "device." "dmc:" dmc(4) .xx "" "drum: paging" "device." "" drum(4) .xx "" "fold: fold long lines for finite width output" "device." "" fold(1) .xx "" "ioctl: control" "device." "" ioctl(2) .xx "" "L-devices: UUCP" "device description file." "" L-devices(5) .xx "" "swapon: add a swap" "device for interleaved paging/swapping." "" swapon(2) .xx "" "swapon: specify additional" "device for paging and swapping." "" swapon(8) .xx "" "ik: Ikonas frame buffer, graphics" "device interface." "" ik(4) .xx "" "ps: Evans and Sutherland Picture System 2 graphics" "device interface." "" ps(4) .xx "" "tb: line discipline for digitizing" "devices." "" tb(4) .xx "" "" "df: disk free." "" df(1) .xx "" "flmin, flmax, ffrac, dflmin, dflmax," "dffrac, inmax: return extreme values." "" flmin(3F) .xx "" "flmin, flmax, ffrac, dflmin," "dflmax, dffrac, inmax: return extreme values." "" flmin(3F) .xx "values." "flmin, flmax, ffrac," "dflmin, dflmax, dffrac, inmax: return extreme" "" flmin(3F) .xx "" "" "dh: DH-11/DM-11 communications multiplexer." "" dh(4) .xx "" "dh:" "DH-11/DM-11 communications multiplexer." "" dh(4) .xx "" "" "dhu: DHU-11 communications multiplexer." "" dhu(4) .xx "" "dhu:" "DHU-11 communications multiplexer." "" dhu(4) .xx "" "dmesg: collect system" "diagnostic messages to form error log." "" dmesg(8) .xx "" "autoconf:" "diagnostics from the autoconfiguration code." "" autoconf(4) .xx "" "explain: print wordy sentences; thesaurus for" "diction." "diction," diction(1) .xx "for diction." "" "diction, explain: print wordy sentences; thesaurus" "" diction(1) .xx "" "" "diff: differential file and directory comparator." "" diff(1) .xx "" "patch: a program for applying a" "diff file to an original." "" patch(1) .xx "" "" "diff3: 3-way differential file comparison." "" diff3(1) .xx "" "diff:" "differential file and directory comparator." "" diff(1) .xx "" "diff3: 3-way" "differential file comparison." "" diff3(1) .xx "" "tb: line discipline for" "digitizing devices." "" tb(4) .xx "" "" "dir: format of directories." "" dir(5) .xx "" "dir: format of" "directories." "" dir(5) .xx "" "rm, rmdir: remove (unlink) files or" "directories." "" rm(1) .xx "" "sticky: persistent text and append-only" "directories." "" sticky(8) .xx "" "rmdir, rm: remove (unlink)" "directories or files." "" rmdir(1) .xx "" "cd: change working" "directory." "" cd(1) .xx "" "chdir: change current working" "directory." "" chdir(2) .xx "" "chdir: change default" "directory." "" chdir(3F) .xx "" "chroot: change root" "directory." "" chroot(2) .xx "" "cd: change" "directory." "" csh(1) .xx "" "chdir: change" "directory." "" csh(1) .xx "" "getcwd: get pathname of current working" "directory." "" getcwd(3F) .xx "" "ls: list contents of" "directory." "" ls(1) .xx "" "mkdir: make a" "directory." "" mkdir(1) .xx "" "scandir, alphasort: scan a" "directory." "" scandir(3) .xx "" "uuclean: uucp spool" "directory clean-up." "" uuclean(8C) .xx "" "diff: differential file and" "directory comparator." "" diff(1) .xx "" "dcheck: file system" "directory consistency check." "" dcheck(8) .xx "" "unlink: remove" "directory entry." "" unlink(2) .xx "" "unlink: remove a" "directory entry." "" unlink(3F) .xx "" "mkdir: make a" "directory file." "" mkdir(2) .xx "" "rmdir: remove a" "directory file." "" rmdir(2) .xx "" "mklost+found: make a lost+found" "directory for fsck." "" mklost+found(8) .xx "" "pwd: working" "directory name." "" pwd(1) .xx "" "readdir, telldir, seekdir, rewinddir, closedir:" "directory operations." "opendir," directory(3) .xx "" "getwd: get current working" "directory pathname." "" getwd(3) .xx "" "whois: DARPA Internet user name" "directory service." "" whois(1) .xx "" "popd: pop shell" "directory stack." "" csh(1) .xx "" "pushd: push shell" "directory stack." "" csh(1) .xx "" "quota: display" "disc usage and limits." "" quota(1) .xx "" "unhash:" "discard command hash table." "" csh(1) .xx "" "unset:" "discard shell variables." "" csh(1) .xx "" "tb: line" "discipline for digitizing devices." "" tb(4) .xx "(obsolete)." "bk: line" "discipline for machine-machine communication" "" bk(4) .xx "" "synchronize a file's in-core state with that on" "disk." "fsync:" fsync(2) .xx "" "hk: RK6-11/RK06 and RK07 moving head" "disk." "" hk(4) .xx "" "uda: UDA-50" "disk controller interface." "" uda(4) .xx "" "getdiskbyname: get" "disk description by its name." "" getdisk(3) .xx "" "disktab:" "disk description file." "" disktab(5) .xx "" "df:" "disk free." "" df(1) .xx "" "hp: MASSBUS" "disk interface." "" hp(4) .xx "" "rx: DEC RX02 floppy" "disk interface." "" rx(4) .xx "" "format: how to format" "disk packs." "" format(8V) .xx "" "diskpart: calculate default" "disk partition sizes." "" diskpart(8) .xx "" "quota: manipulate" "disk quotas." "" quota(2) .xx "" "drtest: standalone" "disk test program." "" drtest(8) .xx "" "du: summarize" "disk usage." "" du(1) .xx "" "" "diskpart: calculate default disk partition sizes." "" diskpart(8) .xx "" "reboot/halt the system without checking the" "disks." "fastboot, fasthalt:" fastboot(8) .xx "" "rxformat: format floppy" "disks." "" rxformat(8V) .xx "" "" "disktab: disk description file." "" disktab(5) .xx "" "mount, umount: mount and" "dismount file system." "" mount(8) .xx "" "error: analyze and" "disperse compiler error messages." "" error(1) .xx "" "rain: animated raindrops" "display." "" rain(6) .xx "" "arp: address resolution" "display and control." "" arp(8C) .xx "" "gprof:" "display call graph profile data." "" gprof(1) .xx "" "snake, snscore:" "display chase game." "" snake(6) .xx "" "quota:" "display disc usage and limits." "" quota(1) .xx "" "vi: screen oriented (visual)" "display editor based on ex." "" vi(1) .xx "" "umask: change or" "display file creation mask." "" csh(1) .xx "" "prof:" "display profile data." "" prof(1) .xx "" "systat:" "display system statistics on a crt." "" systat(1) .xx "" "sysline:" "display system status on status line of a terminal." "" sysline(1) .xx "" "worms: animate worms on a" "display terminal." "" worms(6) .xx "" "uulog:" "display UUCP log files." "" uulog(1C) .xx "" "jove: an interactive" "display-oriented text editor." "" jove(1) .xx "" "hypot, cabs: Euclidean" "distance, complex absolute value." "" hypot(3M) .xx "" "rdist: remote file" "distribution program." "" rdist(1) .xx "communications device." "" "dmc: DEC DMC-11/DMR-11 point-to-point" "" dmc(4) .xx "" "dmc: DEC" "DMC-11/DMR-11 point-to-point communications device." "" dmc(4) .xx "error log." "" "dmesg: collect system diagnostic messages to form" "" dmesg(8) .xx "" "" "dmf: DMF-32, terminal multiplexor." "" dmf(4) .xx "" "dmf:" "DMF-32, terminal multiplexor." "" dmf(4) .xx "" "" "dmz: DMZ-32 terminal multiplexor." "" dmz(4) .xx "" "dmz:" "DMZ-32 terminal multiplexor." "" dmz(4) .xx "" "" "dn: DN-11 autocall unit interface." "" dn(4) .xx "" "dn:" "DN-11 autocall unit interface." "" dn(4) .xx "" "res_mkquery, res_send, res_init," "dn_comp, dn_expand: resolver routines." "" resolver(3) .xx "" "res_mkquery, res_send, res_init, dn_comp," "dn_expand: resolver routines." "" resolver(3) .xx "" "" "doctor: interact with a psychoanalyst." "" doctor(6) .xx "" "style: analyze surface characteristics of a" "document." "" style(1) .xx "" "refer: find and insert literature references in" "documents." "" refer(1) .xx "" "w: who is on and what they are" "doing." "" w(1) .xx "" "named: Internet" "domain name server." "" named(8) .xx "" "rogue: Exploring The Dungeons of" "Doom." "" rogue(6) .xx "" "shutdown: shut" "down part of a full-duplex connection." "" shutdown(2) .xx "" "shutdown: close" "down the system at a given time." "" shutdown(8) .xx "" "rand," "drand, irand: return random values." "" rand(3F) .xx "" "random," "drandm, irandm: better random number generator." "" random(3F) .xx "" "graph:" "draw a graph." "" graph(1G) .xx "exponent manipulations." "copysign," "drem, finite, logb, scalb: copysign, remainder," "" ieee(3M) .xx "" "arithmetic: provide" "drill in number facts." "" arithmetic(6) .xx "" "ut: UNIBUS TU45 tri-density tape" "drive interface." "" ut(4) .xx "" "pty: pseudo terminal" "driver." "" pty(4) .xx "" "" "drtest: standalone disk test program." "" drtest(8) .xx "" "" "drum: paging device." "" drum(4) .xx "" "etime," "dtime: return elapsed execution time." "" etime(3F) .xx "" "" "du: summarize disk usage." "" du(1) .xx "" "dump: incremental file system" "dump." "" dump(8) .xx "" "od: octal, decimal, hex, ascii" "dump." "" od(1) .xx "" "rdump: file system" "dump across the network." "" rdump(8C) .xx "" "rrestore: restore a file system" "dump across the network." "" rrestore(8C) .xx "" "" "dump, dumpdates: incremental dump format." "" dump(5) .xx "" "dumpfs:" "dump file system information." "" dumpfs(8) .xx "" "dump, dumpdates: incremental" "dump format." "" dump(5) .xx "" "" "dump: incremental file system dump." "" dump(8) .xx "" "savecore: save a core" "dump of the operating system." "" savecore(8) .xx "" "kgmon: generate a" "dump of the operating system's profile buffers." "" kgmon(8) .xx "" "dump," "dumpdates: incremental dump format." "" dump(5) .xx "" "" "dumpfs: dump file system information." "" dumpfs(8) .xx "" "zork: the game of" "dungeon." "" zork(6) .xx "" "rogue: Exploring The" "Dungeons of Doom." "" rogue(6) .xx "" "" "dup, dup2: duplicate a descriptor." "" dup(2) .xx "" "dup," "dup2: duplicate a descriptor." "" dup(2) .xx "" "dup, dup2:" "duplicate a descriptor." "" dup(2) .xx "" "" "dz: DZ-11 communications multiplexer." "" dz(4) .xx "" "dz:" "DZ-11 communications multiplexer." "" dz(4) .xx "" "" "ec: 3Com 10 Mb/s Ethernet interface." "" ec(4) .xx "" "echo:" "echo arguments." "" csh(1) .xx "" "echo:" "echo arguments." "" echo(1) .xx "" "" "echo: echo arguments." "" csh(1) .xx "" "" "echo: echo arguments." "" echo(1) .xx "" "ping: send ICMP" "ECHO_REQUEST packets to network hosts." "" ping(8) .xx "" "" "ecvt, fcvt, gcvt: output conversion." "" ecvt(3) .xx "" "" "ed: text editor." "" ed(1) .xx "" "end, etext," "edata: last locations in program." "" end(3) .xx "" "ex," "edit: text editor." "" ex(1) .xx "" "vipw:" "edit the password file." "" vipw(8) .xx "" "edquota:" "edit user quotas." "" edquota(8) .xx "" "ed: text" "editor." "" ed(1) .xx "" "ex, edit: text" "editor." "" ex(1) .xx "" "jove: an interactive display-oriented text" "editor." "" jove(1) .xx "" "ld: link" "editor." "" ld(1) .xx "" "sed: stream" "editor." "" sed(1) .xx "" "vi: screen oriented (visual) display" "editor based on ex." "" vi(1) .xx "" "a.out: assembler and link" "editor output." "" a.out(5) .xx "" "" "edquota: edit user quotas." "" edquota(8) .xx "" "whoami: print" "effective current user id." "" whoami(1) .xx "" "setregid: set real and" "effective group ID." "" setregid(2) .xx "" "setreuid: set real and" "effective user ID's." "" setreuid(2) .xx "" "vfork: spawn new process in a virtual memory" "efficient way." "" vfork(2) .xx "" "" "efl: Extended Fortran Language." "" efl(1) .xx "" "grep," "egrep, fgrep: search a file for a pattern." "" grep(1) .xx "" "etime, dtime: return" "elapsed execution time." "" etime(3F) .xx "" "insque, remque: insert/remove" "element from a queue." "" insque(3) .xx "" "soelim:" "eliminate \&.so's from nroff input." "" soelim(1) .xx "" "" "else: alternative commands." "" csh(1) .xx "" "" "en: Xerox 3 Mb/s Ethernet interface." "" en(4) .xx "" "setquota:" "enable/disable quotas on a file system." "" setquota(2) .xx "" "nsip: software network interface" "encapsulating ns packets in ip packets.." "" nsip(4) .xx "" "uuencode: format of an" "encoded uuencode file." "" uuencode(5) .xx "" "crypt:" "encode/decode." "" crypt(1) .xx "mail." "uuencode, uudecode:" "encode/decode a binary file for transmission via" "" uuencode(1C) .xx "" "crypt, setkey," "encrypt: DES encryption." "" crypt(3) .xx "" "crypt, setkey, encrypt: DES" "encryption." "" crypt(3) .xx "" "makekey: generate" "encryption key." "" makekey(8) .xx "" "" "end, etext, edata: last locations in program." "" end(3) .xx "" "sccs: front" "end for the SCCS subsystem." "" sccs(1) .xx "" "logout:" "end session." "" csh(1) .xx "" "" "end: terminate loop." "" csh(1) .xx "" "/getfsspec, getfsfile, getfstype, setfsent," "endfsent: get file system descriptor file entry." "" getfsent(3) .xx "" "getgrent, getgrgid, getgrnam, setgrent," "endgrent: get group file entry." "" getgrent(3) .xx "" "gethostbyaddr, gethostent, sethostent," "endhostent: get network host entry." "gethostbyname," gethostbyname(3N) .xx "" "" "endif: terminate conditional." "" csh(1) .xx "" "getnetent, getnetbyaddr, getnetbyname, setnetent," "endnetent: get network entry." "" getnetent(3N) .xx "" "socket: create an" "endpoint for communication." "" socket(2) .xx "" "getprotobynumber, getprotobyname, setprotoent," "endprotoent: get protocol entry." "getprotoent," getprotoent(3N) .xx "" "getpwent, getpwuid, getpwnam, setpwent," "endpwent, setpwfile: get password file entry." "" getpwent(3) .xx "" "getservbyport, getservbyname, setservent," "endservent: get service entry." "getservent," getservent(3N) .xx "" "" "endsw: terminate switch." "" csh(1) .xx "" "getttyent, getttynam, setttyent," "endttyent: get ttys file entry." "" getttyent(3) .xx "" "getusershell, setusershell," "endusershell: get legal user shells." "" getusershell(3) .xx "" "number: convert Arabic numerals to" "English." "" number(6) .xx "" "xsend, xget," "enroll: secret mail." "" xsend(1) .xx "" "nlist: get" "entries from name list." "" nlist(3) .xx "" "logger: make" "entries in the system log." "" logger(1) .xx "" "setfsent, endfsent: get file system descriptor file" "entry." "getfsent, getfsspec, getfsfile, getfstype," getfsent(3) .xx "" "getgrnam, setgrent, endgrent: get group file" "entry." "getgrent, getgrgid," getgrent(3) .xx "" "sethostent, endhostent: get network host" "entry." "gethostbyname, gethostbyaddr, gethostent," gethostbyname(3N) .xx "" "getnetbyname, setnetent, endnetent: get network" "entry." "getnetent, getnetbyaddr," getnetent(3N) .xx "" "setprotoent, endprotoent: get protocol" "entry." "/getprotobynumber, getprotobyname," getprotoent(3N) .xx "" "setpwent, endpwent, setpwfile: get password file" "entry." "getpwent, getpwuid, getpwnam," getpwent(3) .xx "" "getservbyname, setservent, endservent: get service" "entry." "getservent, getservbyport," getservent(3N) .xx "" "getttynam, setttyent, endttyent: get ttys file" "entry." "getttyent," getttyent(3) .xx "" "unlink: remove directory" "entry." "" unlink(2) .xx "" "unlink: remove a directory" "entry." "" unlink(3F) .xx "" "execv, execle, execlp, execvp, exec, execve, exect," "environ: execute a file." "execl," execl(3) .xx "" "" "environ: user environment." "" environ(7) .xx "" "setenv: set variable in" "environment." "" csh(1) .xx "" "environ: user" "environment." "" environ(7) .xx "" "printenv: print out the" "environment." "" printenv(1) .xx "" "window: window" "environment." "" window(1) .xx "" "getenv: value for" "environment name." "" getenv(3) .xx "" "unsetenv: remove" "environment variables." "" csh(1) .xx "" "getenv: get value of" "environment variables." "" getenv(3F) .xx "" "eqnchar: special character definitions for" "eqn." "" eqnchar(7) .xx "" "deroff: remove nroff, troff, tbl and" "eqn constructs." "" deroff(1) .xx "" "" "eqn, neqn, checkeq: typeset mathematics." "" eqn(1) .xx "" "" "eqnchar: special character definitions for eqn." "" eqnchar(7) .xx "linemod, space, closepl: graphics/" "plot: openpl," "erase, label, line, circle, arc, move, cont, point," "" plot(3X) .xx "" "" "erf, erfc: error functions." "" erf(3M) .xx "" "erf," "erfc: error functions." "" erf(3M) .xx "messages." "" "error: analyze and disperse compiler error" "" error(1) .xx "" "erf, erfc:" "error functions." "" erf(3M) .xx "" "dmesg: collect system diagnostic messages to form" "error log." "" dmesg(8) .xx "" "mkstr: create an" "error message file by massaging C source." "" mkstr(1) .xx "" "error: analyze and disperse compiler" "error messages." "" error(1) .xx "" "perror, sys_errlist, sys_nerr: system" "error messages." "" perror(3) .xx "" "perror, gerror, ierrno: get system" "error messages." "" perror(3F) .xx "" "intro: introduction to system calls and" "error numbers." "" intro(2) .xx "" "spell, spellin, spellout: find spelling" "errors." "" spell(1) .xx "" "traper: trap arithmetic" "errors." "" traper(3F) .xx "" "end," "etext, edata: last locations in program." "" end(3) .xx "" "de: DEC DEUNA 10 Mb/s" "Ethernet interface." "" de(4) .xx "" "ec: 3Com 10 Mb/s" "Ethernet interface." "" ec(4) .xx "" "en: Xerox 3 Mb/s" "Ethernet interface." "" en(4) .xx "" "ex: Excelan 10 Mb/s" "Ethernet interface." "" ex(4) .xx "" "il: Interlan NI1010 10 Mb/s" "Ethernet interface." "" il(4) .xx "" "ix: Interlan Np100 10 Mb/s" "Ethernet interface." "" ix(4) .xx "" "np: Interlan Np100 10 Mb/s" "Ethernet interface." "" np(4) .xx "" "qe: DEC DEQNA Q-bus 10 Mb/s" "Ethernet interface." "" qe(4) .xx "" "" "etime, dtime: return elapsed execution time." "" etime(3F) .xx "" "hypot, cabs:" "Euclidean distance, complex absolute value." "" hypot(3M) .xx "" "/if, while, \fB:\fP, \fB.\fP, break, continue, cd," "eval, exec, exit, export, login, read, readonly,/" "" sh(1) .xx "" "" "eval: re-evaluate shell data." "" csh(1) .xx "" "expr:" "evaluate arguments as an expression." "" expr(1) .xx "device interface." "ps:" "Evans and Sutherland Picture System 2 graphics" "" ps(4) .xx "" "history: print history" "event list." "" csh(1) .xx "" "screen oriented (visual) display editor based on" "ex." "vi:" vi(1) .xx "" "" "ex, edit: text editor." "" ex(1) .xx "" "" "ex: Excelan 10 Mb/s Ethernet interface." "" ex(4) .xx "" "lpq: spool queue" "examination program." "" lpq(1) .xx "" "uuq:" "examine or manipulate the uucp queue." "" uuq(1C) .xx "" "ex:" "Excelan 10 Mb/s Ethernet interface." "" ex(4) .xx "" "execl, execv, execle, execlp, execvp," "exec, execve, exect, environ: execute a file." "" execl(3) .xx "" "/while, \fB:\fP, \fB.\fP, break, continue, cd, eval," "exec, exit, export, login, read, readonly, set,/" "" sh(1) .xx "" "" "exec: overlay shell with specified command." "" csh(1) .xx "exect, environ: execute a file." "" "execl, execv, execle, execlp, execvp, exec, execve," "" execl(3) .xx "environ: execute a file." "execl, execv," "execle, execlp, execvp, exec, execve, exect," "" execl(3) .xx "execute a file." "execl, execv, execle," "execlp, execvp, exec, execve, exect, environ:" "" execl(3) .xx "" "execl, execv, execle, execlp, execvp, exec, execve," "exect, environ: execute a file." "" execl(3) .xx "" "execlp, execvp, exec, execve, exect, environ:" "execute a file." "execl, execv, execle," execl(3) .xx "" "execve:" "execute a file." "" execve(2) .xx "" "alarm:" "execute a subroutine after a specified time." "" alarm(3F) .xx "" "system:" "execute a UNIX command." "" system(3F) .xx "" "repeat:" "execute command repeatedly." "" csh(1) .xx "" "at:" "execute commands at a later time." "" at(1) .xx "" "lastcomm: show last commands" "executed in reverse order." "" lastcomm(1) .xx "" "uux: unix to unix command" "execution." "" uux(1C) .xx "" "acct:" "execution accounting file." "" acct(5) .xx "" "uuxqt: UUCP" "execution file interpreter." "" uuxqt(8C) .xx "" "sleep: suspend" "execution for an interval." "" sleep(1) .xx "" "sleep: suspend" "execution for an interval." "" sleep(3F) .xx "" "sleep: suspend" "execution for interval." "" sleep(3) .xx "" "usleep: suspend" "execution for interval." "" usleep(3) .xx "" "monitor, monstartup, moncontrol: prepare" "execution profile." "" monitor(3) .xx "" "pxp: Pascal" "execution profiler." "" pxp(1) .xx "" "rexecd: remote" "execution server." "" rexecd(8C) .xx "" "etime, dtime: return elapsed" "execution time." "" etime(3F) .xx "" "profil:" "execution time profile." "" profil(2) .xx "" "pix: Pascal interpreter and" "executor." "" pix(1) .xx "environ: execute a file." "execl," "execv, execle, execlp, execvp, exec, execve, exect," "" execl(3) .xx "" "execl, execv, execle, execlp, execvp, exec," "execve, exect, environ: execute a file." "" execl(3) .xx "" "" "execve: execute a file." "" execve(2) .xx "file." "execl, execv, execle, execlp," "execvp, exec, execve, exect, environ: execute a" "" execl(3) .xx "" "link: make a link to an" "existing file." "" link(3F) .xx "" "tunefs: tune up an" "existing file system." "" tunefs(8) .xx "" "/\fB:\fP, \fB.\fP, break, continue, cd, eval, exec," "exit, export, login, read, readonly, set, shift,/" "" sh(1) .xx "" "breaksw:" "exit from switch." "" csh(1) .xx "" "" "exit: leave shell." "" csh(1) .xx "" "" "_exit: terminate a process." "" exit(2) .xx "pending output." "" "exit: terminate a process after flushing any" "" exit(3) .xx "" "" "exit: terminate process with status." "" exit(3F) .xx "" "break:" "exit while/foreach loop." "" csh(1) .xx "logarithm, power." "" "exp, expm1, log, log10, log1p, pow: exponential," "" exp(3M) .xx "" "glob: filename" "expand argument list." "" csh(1) .xx "" "compress, uncompress, zcat: compress and" "expand data." "" compress(1) .xx "" "expand, unexpand:" "expand tabs to spaces, and vice versa." "" expand(1) .xx "versa." "" "expand, unexpand: expand tabs to spaces, and vice" "" expand(1) .xx "diction." "diction," "explain: print wordy sentences; thesaurus for" "" diction(1) .xx "" "aardvark: yet another" "exploration game." "" aardvark(6) .xx "" "adventure: an" "exploration game." "" adventure(6) .xx "" "rogue:" "Exploring The Dungeons of Doom." "" rogue(6) .xx "logarithm, power." "exp," "expm1, log, log10, log1p, pow: exponential," "" exp(3M) .xx "" "frexp, ldexp, modf: split into mantissa and" "exponent." "" frexp(3) .xx "" "drem, finite, logb, scalb: copysign, remainder," "exponent manipulations." "copysign," ieee(3M) .xx "" "exp, expm1, log, log10, log1p, pow:" "exponential, logarithm, power." "" exp(3M) .xx "" "/\fB.\fP, break, continue, cd, eval, exec, exit," "export, login, read, readonly, set, shift, times,/" "" sh(1) .xx "" "" "expr: evaluate arguments as an expression." "" expr(1) .xx "" "expr: evaluate arguments as an" "expression." "" expr(1) .xx "" "re_comp, re_exec: regular" "expression handler." "" regex(3) .xx "" "addbib: create or" "extend bibliographic database." "" addbib(1) .xx "" "efl:" "Extended Fortran Language." "" efl(1) .xx "strings." "xstr:" "extract strings from C programs to implement shared" "" xstr(1) .xx "" "" "f77: Fortran 77 compiler." "" f77(1) .xx "" "ioinit: change" "f77 I/O initialization." "" ioinit(3F) .xx "libraries.." "plot: openpl et al.:" "f77 library interface to \fIplot\fR (3X)" "" plot(3F) .xx "" "tclose, tread, twrite, trewin, tskipf, tstate:" "f77 tape I/O." "topen," topen(3F) .xx "ceiling, and round-to-nearest functions." "" "fabs, floor, ceil, rint: absolute value, floor," "" floor(3M) .xx "" "networking: introduction to networking" "facilities." "" intro(4N) .xx "" "signal: simplified software signal" "facilities." "" signal(3C) .xx "" "sigvec: software signal" "facilities." "" sigvec(2) .xx "" "malloc, free," "falloc: memory allocator." "" malloc(3F) .xx "" "true," "false: provide truth values." "" true(1) .xx "" "" "false, true: provide truth values." "" false(1) .xx "" "inet: Internet protocol" "family." "" inet(4F) .xx "" "ns: Xerox Network Systems(tm) protocol" "family." "" ns(4F) .xx "checking the disks." "" "fastboot, fasthalt: reboot/halt the system without" "" fastboot(8) .xx "the disks." "fastboot," "fasthalt: reboot/halt the system without checking" "" fastboot(8) .xx "" "abort: generate a" "fault." "" abort(3) .xx "" "trpfpe, fpecnt: trap and repair floating point" "faults." "" trpfpe(3F) .xx "export, login,/" "sh, for, case, if, while, \fB:\fP," "\fB.\fP, break, continue, cd, eval, exec, exit," "" sh(1) .xx "exit, export, login,/" "sh, for, case, if, while," "\fB:\fP, \fB.\fP, break, continue, cd, eval, exec," "" sh(1) .xx "" "" "fclose, fflush: close or flush a stream." "" fclose(3S) .xx "" "" "fcntl: file control." "" fcntl(2) .xx "" "ecvt," "fcvt, gcvt: output conversion." "" ecvt(3) .xx "" "" "fdate: return date and time in an ASCII string." "" fdate(3F) .xx "" "fopen, freopen," "fdopen: open a stream." "" fopen(3S) .xx "" "ferror," "feof, clearerr, fileno: stream status inquiries." "" ferror(3S) .xx "inquiries." "" "ferror, feof, clearerr, fileno: stream status" "" ferror(3S) .xx "subroutines." "dbminit," "fetch, store, delete, firstkey, nextkey: data base" "" dbm(3X) .xx "" "head: give first" "few lines." "" head(1) .xx "" "fclose," "fflush: close or flush a stream." "" fclose(3S) .xx "extreme values." "flmin, flmax," "ffrac, dflmin, dflmax, dffrac, inmax: return" "" flmin(3F) .xx "" "bcopy, bcmp, bzero," "ffs: bit and byte string operations." "" bstring(3) .xx "" "" "fg: bring job into foreground." "" csh(1) .xx "" "getc," "fgetc: get a character from a logical unit." "" getc(3F) .xx "" "getc, getchar," "fgetc, getw: get character or word from stream." "" getc(3S) .xx "" "gets," "fgets: get a string from a stream." "" gets(3S) .xx "" "grep, egrep," "fgrep: search a file for a pattern." "" grep(1) .xx "" "locate a program file including aliases and paths" "(\fIcsh\fR only)." "which:" which(1) .xx "" "robots:" "fight off villainous robots." "" robots(6) .xx "" "access: determine accessibility of" "file." "" access(2) .xx "" "access: determine accessability of a" "file." "" access(3F) .xx "" "acct: execution accounting" "file." "" acct(5) .xx "" "chmod: change mode of" "file." "" chmod(2) .xx "" "chmod: change mode of a" "file." "" chmod(3F) .xx "" "chown: change owner and group of a" "file." "" chown(2) .xx "" "colrm: remove columns from a" "file." "" colrm(1) .xx "" "core: format of memory image" "file." "" core(5) .xx "" "creat: create a new" "file." "" creat(2) .xx "" "source: read commands from" "file." "" csh(1) .xx "" "ctags: create a tags" "file." "" ctags(1) .xx "" "dd: convert and copy a" "file." "" dd(1) .xx "" "disktab: disk description" "file." "" disktab(5) .xx "" "execvp, exec, execve, exect, environ: execute a" "file." "execl, execv, execle, execlp," execl(3) .xx "" "execve: execute a" "file." "" execve(2) .xx "" "flock: apply or remove an advisory lock on an open" "file." "" flock(2) .xx "" "fpr: print Fortran" "file." "" fpr(1) .xx "" "group: group" "file." "" group(5) .xx "" "L.aliases: UUCP hostname alias" "file." "" L.aliases(5) .xx "" "L.cmds: UUCP remote command permissions" "file." "" L.cmds(5) .xx "" "L-devices: UUCP device description" "file." "" L-devices(5) .xx "" "L-dialcodes: UUCP phone number index" "file." "" L-dialcodes(5) .xx "" "link: make a hard link to a" "file." "" link(2) .xx "" "link: make a link to an existing" "file." "" link(3F) .xx "" "L.sys: UUCP remote host description" "file." "" L.sys(5) .xx "" "mkdir: make a directory" "file." "" mkdir(2) .xx "" "mknod: make a special" "file." "" mknod(2) .xx "" "mknod: build special" "file." "" mknod(8) .xx "" "rebuild the data base for the mail aliases" "file." "newaliases:" newaliases(1) .xx "" "open a file for reading or writing, or create a new" "file." "open:" open(2) .xx "" "passwd: password" "file." "" passwd(5) .xx "" "pr: print" "file." "" pr(1) .xx "" "remote: remote host description" "file." "" remote(5) .xx "" "rename: change the name of a" "file." "" rename(2) .xx "" "rename: rename a" "file." "" rename(3F) .xx "" "resolver configuration" "file." "" resolver(5) .xx "" "rev: reverse lines of a" "file." "" rev(1) .xx "" "rmdir: remove a directory" "file." "" rmdir(2) .xx "" "size: size of an object" "file." "" size(1) .xx "" "the printable strings in a object, or other binary," "file." "strings: find" strings(1) .xx "" "sum: sum and count blocks in a" "file." "" sum(1) .xx "" "symlink: make symbolic link to a" "file." "" symlink(2) .xx "" "tail: deliver the last part of a" "file." "" tail(1) .xx "" "touch: update date last modified of a" "file." "" touch(1) .xx "" "uniq: report repeated lines in a" "file." "" uniq(1) .xx "" "USERFILE: UUCP pathname permissions" "file." "" USERFILE(5) .xx "" "uuencode: format of an encoded uuencode" "file." "" uuencode(5) .xx "" "vipw: edit the password" "file." "" vipw(8) .xx "" "versions of object modules were used to construct a" "file." "what: show what" what(1) .xx "" "diff: differential" "file and directory comparator." "" diff(1) .xx "" "bugfiler:" "file bug reports in folders automatically." "" bugfiler(8) .xx "" "mkstr: create an error message" "file by massaging C source." "" mkstr(1) .xx "" "diff3: 3-way differential" "file comparison." "" diff3(1) .xx "" "fcntl:" "file control." "" fcntl(2) .xx "" "rcp: remote" "file copy." "" rcp(1C) .xx "" "umask: change or display" "file creation mask." "" csh(1) .xx "" "umask: set" "file creation mode mask." "" umask(2) .xx "" "" "file: determine file type." "" file(1) .xx "" "rdist: remote" "file distribution program." "" rdist(1) .xx "" "setfsent, endfsent: get file system descriptor" "file entry." "/getfsspec, getfsfile, getfstype," getfsent(3) .xx "" "getgrgid, getgrnam, setgrent, endgrent: get group" "file entry." "getgrent," getgrent(3) .xx "" "setpwent, endpwent, setpwfile: get password" "file entry." "getpwent, getpwuid, getpwnam," getpwent(3) .xx "" "getttynam, setttyent, endttyent: get ttys" "file entry." "getttyent," getttyent(3) .xx "" "grep, egrep, fgrep: search a" "file for a pattern." "" grep(1) .xx "" "open: open a" "file for reading or writing, or create a new file." "" open(2) .xx "" "aliases: aliases" "file for sendmail." "" aliases(5) .xx "" "uuencode, uudecode: encode/decode a binary" "file for transmission via mail." "" uuencode(1C) .xx "" "ar: archive (library)" "file format." "" ar(5) .xx "" "tar: tape archive" "file format." "" tar(5) .xx "" "which: locate a program" "file including aliases and paths (\fIcsh\fR only)." "" which(1) .xx "" "chfn, chsh, passwd: change password" "file information." "" chfn(1) .xx "" "chfn, chsh, passwd: change password" "file information." "" chsh(1) .xx "" "chfn, chsh, passwd: change password" "file information." "" passwd(1) .xx "" "uuxqt: UUCP execution" "file interpreter." "" uuxqt(8C) .xx "" "fsplit: split a multi-routine Fortran" "file into individual files." "" fsplit(1) .xx "" "split: split a" "file into pieces." "" split(1) .xx "" "pmerge: pascal" "file merger." "" pmerge(1) .xx "" "mktemp: make a unique" "file name." "" mktemp(3) .xx "" "fseek, ftell: reposition a" "file on a logical unit." "" fseek(3F) .xx "" "more, page:" "file perusal filter for crt viewing." "" more(1) .xx "" "stat, lstat, fstat: get" "file status." "" stat(2) .xx "" "stat, lstat, fstat: get" "file status." "" stat(3F) .xx "" "mkfs: construct a" "file system." "" mkfs(8) .xx "" "mkproto: construct a prototype" "file system." "" mkproto(8) .xx "" "mount, umount: mount or remove" "file system." "" mount(2) .xx "" "mount, umount: mount and dismount" "file system." "" mount(8) .xx "" "newfs: construct a new" "file system." "" newfs(8) .xx "" "repquota: summarize quotas for a" "file system." "" repquota(8) .xx "" "setquota: enable/disable quotas on a" "file system." "" setquota(2) .xx "" "tunefs: tune up an existing" "file system." "" tunefs(8) .xx "repair." "fsck:" "file system consistency check and interactive" "" fsck(8) .xx "" "getfsfile, getfstype, setfsent, endfsent: get" "file system descriptor file entry." "/getfsspec," getfsent(3) .xx "" "dcheck:" "file system directory consistency check." "" dcheck(8) .xx "" "dump: incremental" "file system dump." "" dump(8) .xx "" "rdump:" "file system dump across the network." "" rdump(8C) .xx "" "rrestore: restore a" "file system dump across the network." "" rrestore(8C) .xx "" "hier:" "file system hierarchy." "" hier(7) .xx "" "dumpfs: dump" "file system information." "" dumpfs(8) .xx "" "quot: summarize" "file system ownership." "" quot(8) .xx "" "quotacheck:" "file system quota consistency checker." "" quotacheck(8) .xx "" "quotaon, quotaoff: turn" "file system quotas on and off." "" quotaon(8) .xx "" "restore: incremental" "file system restore." "" restore(8) .xx "" "icheck:" "file system storage consistency check." "" icheck(8) .xx "" "mtab: mounted" "file system table." "" mtab(5) .xx "" "fs, inode: format of" "file system volume." "" fs(5) .xx "" "utime: set" "file times." "" utime(3C) .xx "" "utimes: set" "file times." "" utimes(2) .xx "" "uusend: send a" "file to a remote host." "" uusend(1C) .xx "" "truncate: truncate a" "file to a specified length." "" truncate(2) .xx "" "patch: a program for applying a diff" "file to an original." "" patch(1) .xx "" "ftp: ARPANET" "file transfer program." "" ftp(1C) .xx "" "tftp: trivial" "file transfer program." "" tftp(1C) .xx "" "ftpd: DARPA Internet" "File Transfer Protocol server." "" ftpd(8C) .xx "" "tftpd: DARPA Trivial" "File Transfer Protocol server." "" tftpd(8C) .xx "" "file: determine" "file type." "" file(1) .xx "" "basename: strip" "filename affixes." "" basename(1) .xx "" "glob:" "filename expand argument list." "" csh(1) .xx "" "ferror, feof, clearerr," "fileno: stream status inquiries." "" ferror(3S) .xx "" "checknr: check nroff/troff" "files." "" checknr(1) .xx "" "cmp: compare two" "files." "" cmp(1) .xx "" "comm: select or reject lines common to two sorted" "files." "" comm(1) .xx "" "config: build system configuration" "files." "" config(8) .xx "" "find: find" "files." "" find(1) .xx "" "split a multi-routine Fortran file into individual" "files." "fsplit:" fsplit(1) .xx "" "makedev: make system special" "files." "" makedev(8) .xx "" "mv: move or rename" "files." "" mv(1) .xx "" "rmdir, rm: remove (unlink) directories or" "files." "" rmdir(1) .xx "" "sort: sort or merge" "files." "" sort(1) .xx "" "uulog: display UUCP log" "files." "" uulog(1C) .xx "" "intro: introduction to special" "files and hardware support." "" intro(4) .xx "" "catman: create the cat" "files for the manual." "" catman(8) .xx "" "fsync: synchronize a" "file's in-core state with that on disk." "" fsync(2) .xx "" "rm, rmdir: remove (unlink)" "files or directories." "" rm(1) .xx "" "uucico, uucpd: transfer" "files queued by uucp or uux." "" uucico(8C) .xx "" "badsect: create" "files to contain bad sectors." "" badsect(8) .xx "" "fstab: static information about the" "filesystems." "" fstab(5) .xx "" "more, page: file perusal" "filter for crt viewing." "" more(1) .xx "" "colcrt:" "filter nroff output for CRT previewing." "" colcrt(1) .xx "" "col:" "filter reverse line feeds." "" col(1) .xx "" "plot: graphics" "filters." "" plot(1G) .xx "" "refer:" "find and insert literature references in documents." "" refer(1) .xx "" "find:" "find files." "" find(1) .xx "" "" "find: find files." "" find(1) .xx "" "look:" "find lines in a sorted list." "" look(1) .xx "manual." "man:" "find manual information by keywords; print out the" "" man(1) .xx "" "ttyname, isatty, ttyslot:" "find name of a terminal." "" ttyname(3) .xx "" "ttynam, isatty:" "find name of a terminal port." "" ttynam(3F) .xx "" "lorder:" "find ordering relation for an object library." "" lorder(1) .xx "" "lookbib: build inverted index for a bibliography," "find references in a bibliography." "indxbib," lookbib(1) .xx "" "spell, spellin, spellout:" "find spelling errors." "" spell(1) .xx "binary, file." "strings:" "find the printable strings in a object, or other" "" strings(1) .xx "" "" "finger: user information lookup program." "" finger(1) .xx "" "" "fingerd: remote user information server." "" fingerd(8C) .xx "manipulations." "copysign, drem," "finite, logb, scalb: copysign, remainder, exponent" "" ieee(3M) .xx "" "fold: fold long lines for" "finite width output device." "" fold(1) .xx "" "plot: openpl et al.: f77 library interface to" "\fIplot\fR (3X) libraries.." "" plot(3F) .xx "" "head: give" "first few lines." "" head(1) .xx "" "dbminit, fetch, store, delete," "firstkey, nextkey: data base subroutines." "" dbm(3X) .xx "" "fish: play ``Go" "Fish''." "" fish(6) .xx "" "" "fish: play ``Go Fish''." "" fish(6) .xx "" "nice, nohup: run a command at low priority" "(\fIsh\fR only)." "" nice(1) .xx "" "" "fl: console floppy interface." "" fl(4) .xx "" "arff," "flcopy: archiver and copier for floppy." "" arff(8V) .xx "extreme values." "flmin," "flmax, ffrac, dflmin, dflmax, dffrac, inmax: return" "" flmin(3F) .xx "return extreme values." "" "flmin, flmax, ffrac, dflmin, dflmax, dffrac, inmax:" "" flmin(3F) .xx "" "trpfpe, fpecnt: trap and repair" "floating point faults." "" trpfpe(3F) .xx "" "trapov: trap and repair" "floating point overflow." "" trapov(3F) .xx "" "infnan: signals invalid" "floating-point operations on a VAX (temporary)." "" infnan(3M) .xx "file." "" "flock: apply or remove an advisory lock on an open" "" flock(2) .xx "and round-to-nearest functions." "fabs," "floor, ceil, rint: absolute value, floor, ceiling," "" floor(3M) .xx "" "fabs, floor, ceil, rint: absolute value," "floor, ceiling, and round-to-nearest functions." "" floor(3M) .xx "" "arff, flcopy: archiver and copier for" "floppy." "" arff(8V) .xx "" "rx: DEC RX02" "floppy disk interface." "" rx(4) .xx "" "rxformat: format" "floppy disks." "" rxformat(8V) .xx "" "fl: console" "floppy interface." "" fl(4) .xx "" "fclose, fflush: close or" "flush a stream." "" fclose(3S) .xx "" "" "flush: flush output to a logical unit." "" flush(3F) .xx "" "flush:" "flush output to a logical unit." "" flush(3F) .xx "" "exit: terminate a process after" "flushing any pending output." "" exit(3) .xx "" "/gcd, invert, rpow, msqrt, mcmp, move, min, omin," "fmin, m_in, mout, omout, fmout, m_out, sdiv, itom:/" "" mp(3X) .xx "" "/mcmp, move, min, omin, fmin, m_in, mout, omout," "fmout, m_out, sdiv, itom: multiple precision/" "" mp(3X) .xx "" "" "fmt: simple text formatter." "" fmt(1) .xx "device." "" "fold: fold long lines for finite width output" "" fold(1) .xx "" "fold:" "fold long lines for finite width output device." "" fold(1) .xx "" "bugfiler: file bug reports in" "folders automatically." "" bugfiler(8) .xx "" "vwidth: make troff width table for a" "font." "" vwidth(1) .xx "" "vfont:" "font formats for the Benson-Varian or Versatec." "" vfont(5) .xx "" "" "fopen, freopen, fdopen: open a stream." "" fopen(3S) .xx "" "" "foreach: loop over list of names." "" csh(1) .xx "" "fg: bring job into" "foreground." "" csh(1) .xx "" "" "fork: create a copy of this process." "" fork(3F) .xx "" "" "fork: create a new process." "" fork(2) .xx "" "idate, itime: return date or time in numerical" "form." "" idate(3F) .xx "" "dmesg: collect system diagnostic messages to" "form error log." "" dmesg(8) .xx "" "ar: archive (library) file" "format." "" ar(5) .xx "" "dump, dumpdates: incremental dump" "format." "" dump(5) .xx "" "tar: tape archive file" "format." "" tar(5) .xx "" "indent: indent and" "format C program source." "" indent(1) .xx "" "format: how to" "format disk packs." "" format(8V) .xx "" "rxformat:" "format floppy disks." "" rxformat(8V) .xx "" "htable: convert NIC standard" "format host tables." "" htable(8) .xx "" "gettable: get NIC" "format host tables from a host." "" gettable(8C) .xx "" "" "format: how to format disk packs." "" format(8V) .xx "vtroff, or troff." "vlp:" "Format Lisp programs to be printed with nroff," "" vlp(1) .xx "" "uuencode:" "format of an encoded uuencode file." "" uuencode(5) .xx "" "dir:" "format of directories." "" dir(5) .xx "" "fs, inode:" "format of file system volume." "" fs(5) .xx "" "core:" "format of memory image file." "" core(5) .xx "" "tbl:" "format tables for nroff or troff." "" tbl(1) .xx "" "tp: DEC/mag tape" "formats." "" tp(5) .xx "" "vfont: font" "formats for the Benson-Varian or Versatec." "" vfont(5) .xx "" "scanf, fscanf, sscanf:" "formatted input conversion." "" scanf(3S) .xx "" "printf, fprintf, sprintf:" "formatted output conversion." "" printf(3S) .xx "" "fmt: simple text" "formatter." "" fmt(1) .xx "" "bib, listrefs: bibliographic" "formatter; list bibliographic reference items." "" bib(1) .xx "" "nroff: text" "formatting." "" nroff(1) .xx "" "troff, nroff: text" "formatting and typesetting." "" troff(1) .xx "" "ms: text" "formatting macros." "" ms(7) .xx "" "me: macros for" "formatting papers." "" me(7) .xx "" "f77:" "Fortran 77 compiler." "" f77(1) .xx "" "ratfor: rational" "Fortran dialect." "" ratfor(1) .xx "" "fpr: print" "Fortran file." "" fpr(1) .xx "" "fsplit: split a multi-routine" "Fortran file into individual files." "" fsplit(1) .xx "" "efl: Extended" "Fortran Language." "" efl(1) .xx "" "intro: introduction to" "FORTRAN library functions." "" intro(3F) .xx "" "putc, fputc: write a character to a" "fortran logical unit." "" putc(3F) .xx "" "struct: structure" "Fortran programs." "" struct(1) .xx "adage." "" "fortune: print a random, hopefully interesting," "" fortune(6) .xx "login,/" "sh, for, case, if, while, \fB:\fP, \fB." "\fP, break, continue, cd, eval, exec, exit, export," "" sh(1) .xx "exit, export,/" "sh, for, case, if, while, \fB:" "\fP, \fB.\fP, break, continue, cd, eval, exec," "" sh(1) .xx "compiler/interpreter." "" "fp: Functional Programming language" "" fp(1) .xx "" "trpfpe," "fpecnt: trap and repair floating point faults." "" trpfpe(3F) .xx "" "" "fpr: print Fortran file." "" fpr(1) .xx "" "printf," "fprintf, sprintf: formatted output conversion." "" printf(3S) .xx "" "putc, putchar," "fputc, putw: put character or word on a stream." "" putc(3S) .xx "" "putc," "fputc: write a character to a fortran logical unit." "" putc(3F) .xx "" "puts," "fputs: put a string on a stream." "" puts(3S) .xx "" "ik: Ikonas" "frame buffer, graphics device interface." "" ik(4) .xx "" "liszt: compile a" "Franz Lisp program." "" liszt(1) .xx "" "" "fread, fwrite: buffered binary input/output." "" fread(3S) .xx "" "df: disk" "free." "" df(1) .xx "" "malloc," "free, falloc: memory allocator." "" malloc(3F) .xx "" "malloc," "free, realloc, calloc, alloca: memory allocator." "" malloc(3) .xx "" "fopen," "freopen, fdopen: open a stream." "" fopen(3S) .xx "exponent." "" "frexp, ldexp, modf: split into mantissa and" "" frexp(3) .xx "" "from: who is my mail" "from?." "" from(1) .xx "" "sccs:" "front end for the SCCS subsystem." "" sccs(1) .xx "" "" "fs, inode: format of file system volume." "" fs(5) .xx "" "scanf," "fscanf, sscanf: formatted input conversion." "" scanf(3S) .xx "" "mklost+found: make a lost+found directory for" "fsck." "" mklost+found(8) .xx "repair." "" "fsck: file system consistency check and interactive" "" fsck(8) .xx "" "" "fseek, ftell: reposition a file on a logical unit." "" fseek(3F) .xx "" "" "fseek, ftell, rewind: reposition a stream." "" fseek(3S) .xx "individual files." "" "fsplit: split a multi-routine Fortran file into" "" fsplit(1) .xx "" "" "fstab: static information about the filesystems." "" fstab(5) .xx "" "stat, lstat," "fstat: get file status." "" stat(2) .xx "" "stat, lstat," "fstat: get file status." "" stat(3F) .xx "on disk." "" "fsync: synchronize a file's in-core state with that" "" fsync(2) .xx "" "fseek," "ftell: reposition a file on a logical unit." "" fseek(3F) .xx "" "fseek," "ftell, rewind: reposition a stream." "" fseek(3S) .xx "" "time," "ftime: get date and time." "" time(3C) .xx "" "" "ftp: ARPANET file transfer program." "" ftp(1C) .xx "" "" "ftpd: DARPA Internet File Transfer Protocol server." "" ftpd(8C) .xx "" "shutdown: shut down part of a" "full-duplex connection." "" shutdown(2) .xx "" "tn3270:" "full-screen remote login to IBM VM/CMS." "" tn3270(1) .xx "" "lgamma: log gamma" "function." "" lgamma(3M) .xx "compiler/interpreter." "fp:" "Functional Programming language" "" fp(1) .xx "" "asinh, acosh, atanh: inverse hyperbolic" "functions." "" asinh(3M) .xx "" "bit: and, or, xor, not, rshift, lshift bitwise" "functions." "" bit(3F) .xx "" "erf, erfc: error" "functions." "" erf(3M) .xx "" "value, floor, ceiling, and round-to-nearest" "functions." "fabs, floor, ceil, rint: absolute" floor(3M) .xx "" "intro: introduction to C library" "functions." "" intro(3) .xx "" "intro: introduction to FORTRAN library" "functions." "" intro(3F) .xx "" "j0, j1, jn, y0, y1, yn: bessel" "functions." "" j0(3M) .xx "" "math: introduction to mathematical library" "functions." "" math(3M) .xx "" "sinh, cosh, tanh: hyperbolic" "functions." "" sinh(3M) .xx "" "cos, tan, asin, acos, atan, atan2: trigonometric" "functions and their inverses." "sin," sin(3M) .xx "" "bessel" "functions: of two kinds for integer orders." "" bessel(3F) .xx "" "curses: screen" "functions with ``optimal'' cursor motion." "" curses(3X) .xx "" "fread," "fwrite: buffered binary input/output." "" fread(3S) .xx "" "aardvark: yet another exploration" "game." "" aardvark(6) .xx "" "adventure: an exploration" "game." "" adventure(6) .xx "" "backgammon: the" "game." "" backgammon(6) .xx "" "battlestar: a tropical adventure" "game." "" battlestar(6) .xx "" "hunt: a multi-player multi-terminal" "game." "" hunt(6) .xx "" "monop: Monopoly" "game." "" monop(6) .xx "" "snake, snscore: display chase" "game." "" snake(6) .xx "" "trek: trekkie" "game." "" trek(6) .xx "" "worm: Play the growing worm" "game." "" worm(6) .xx "" "canfield, cfscores: the solitaire card" "game canfield." "" canfield(6) .xx "" "cribbage: the card" "game cribbage." "" cribbage(6) .xx "" "hangman: Computer version of the" "game hangman." "" hangman(6) .xx "" "boggle: play the" "game of boggle." "" boggle(6) .xx "" "chess: the" "game of chess." "" chess(6) .xx "" "zork: the" "game of dungeon." "" zork(6) .xx "" "wump: the" "game of hunt-the-wumpus." "" wump(6) .xx "" "lgamma: log" "gamma function." "" lgamma(3M) .xx "fmin, m_in, mout,/" "madd, msub, mult, mdiv, pow," "gcd, invert, rpow, msqrt, mcmp, move, min, omin," "" mp(3X) .xx "" "" "gcore: get core images of running processes." "" gcore(1) .xx "" "ecvt, fcvt," "gcvt: output conversion." "" ecvt(3) .xx "buffers." "kgmon:" "generate a dump of the operating system's profile" "" kgmon(8) .xx "" "abort:" "generate a fault." "" abort(3) .xx "" "makekey:" "generate encryption key." "" makekey(8) .xx "" "mkhosts:" "generate hashed host table." "" mkhosts(8) .xx "" "mkpasswd:" "generate hashed password table." "" mkpasswd(8) .xx "" "lptest:" "generate lineprinter ripple pattern." "" lptest(1) .xx "" "ncheck:" "generate names from i-numbers." "" ncheck(8) .xx "" "rand, srand: random number" "generator." "" rand(3C) .xx "" "random, drandm, irandm: better random number" "generator." "" random(3F) .xx "" "lex:" "generator of lexical analysis programs." "" lex(1) .xx "" "/srandom, initstate, setstate: better random number" "generator; routines for changing generators." "" random(3) .xx "" "random number generator; routines for changing" "generators." "/srandom, initstate, setstate: better" random(3) .xx "" "perror," "gerror, ierrno: get system error messages." "" perror(3F) .xx "" "" "getarg, iargc: return command line arguments." "" getarg(3F) .xx "" "" "getc, fgetc: get a character from a logical unit." "" getc(3F) .xx "from stream." "" "getc, getchar, fgetc, getw: get character or word" "" getc(3S) .xx "stream." "getc," "getchar, fgetc, getw: get character or word from" "" getc(3S) .xx "" "" "getcwd: get pathname of current working directory." "" getcwd(3F) .xx "" "" "getdiskbyname: get disk description by its name." "" getdisk(3) .xx "" "" "getdtablesize: get descriptor table size." "" getdtablesize(2) .xx "" "getgid," "getegid: get group identity." "" getgid(2) .xx "" "" "getenv: get value of environment variables." "" getenv(3F) .xx "" "" "getenv: value for environment name." "" getenv(3) .xx "" "getuid," "geteuid: get user identity." "" getuid(2) .xx "setfsent, endfsent: get file system descriptor/" "" "getfsent, getfsspec, getfsfile, getfstype," "" getfsent(3) .xx "system descriptor file entry." "getfsent, getfsspec," "getfsfile, getfstype, setfsent, endfsent: get file" "" getfsent(3) .xx "endfsent: get file system descriptor/" "getfsent," "getfsspec, getfsfile, getfstype, setfsent," "" getfsent(3) .xx "descriptor file/" "getfsent, getfsspec, getfsfile," "getfstype, setfsent, endfsent: get file system" "" getfsent(3) .xx "" "getuid," "getgid: get user or group ID of the caller." "" getuid(3F) .xx "" "" "getgid, getegid: get group identity." "" getgid(2) .xx "get group file entry." "" "getgrent, getgrgid, getgrnam, setgrent, endgrent:" "" getgrent(3) .xx "file entry." "getgrent," "getgrgid, getgrnam, setgrent, endgrent: get group" "" getgrent(3) .xx "" "getgrent, getgrgid," "getgrnam, setgrent, endgrent: get group file entry." "" getgrent(3) .xx "" "" "getgroups: get group access list." "" getgroups(2) .xx "get network host entry." "gethostbyname," "gethostbyaddr, gethostent, sethostent, endhostent:" "" gethostbyname(3N) .xx "sethostent, endhostent: get network host entry." "" "gethostbyname, gethostbyaddr, gethostent," "" gethostbyname(3N) .xx "host entry." "gethostbyname, gethostbyaddr," "gethostent, sethostent, endhostent: get network" "" gethostbyname(3N) .xx "current host." "" "gethostid, sethostid: get/set unique identifier of" "" gethostid(2) .xx "host." "" "gethostname, sethostname: get/set name of current" "" gethostname(2) .xx "timer." "" "getitimer, setitimer: get/set value of interval" "" getitimer(2) .xx "" "" "getlog: get user's login name." "" getlog(3F) .xx "" "" "getlogin: get login name." "" getlogin(3) .xx "get network entry." "getnetent," "getnetbyaddr, getnetbyname, setnetent, endnetent:" "" getnetent(3N) .xx "entry." "getnetent, getnetbyaddr," "getnetbyname, setnetent, endnetent: get network" "" getnetent(3N) .xx "endnetent: get network entry." "" "getnetent, getnetbyaddr, getnetbyname, setnetent," "" getnetent(3N) .xx "" "" "getopt: get option letter from argv." "" getopt(3) .xx "" "" "getpagesize: get system page size." "" getpagesize(2) .xx "" "" "getpass: read a password." "" getpass(3) .xx "" "" "getpeername: get name of connected peer." "" getpeername(2) .xx "" "" "getpgrp: get process group." "" getpgrp(2) .xx "" "" "getpid: get process id." "" getpid(3F) .xx "" "" "getpid, getppid: get process identification." "" getpid(2) .xx "" "getpid," "getppid: get process identification." "" getpid(2) .xx "scheduling priority." "" "getpriority, setpriority: get/set program" "" getpriority(2) .xx "protocol entry." "getprotoent, getprotobynumber," "getprotobyname, setprotoent, endprotoent: get" "" getprotoent(3N) .xx "endprotoent: get protocol entry." "getprotoent," "getprotobynumber, getprotobyname, setprotoent," "" getprotoent(3N) .xx "setprotoent, endprotoent: get protocol entry." "" "getprotoent, getprotobynumber, getprotobyname," "" getprotoent(3N) .xx "" "" "getpw: get name from uid." "" getpw(3C) .xx "setpwfile: get password file entry." "" "getpwent, getpwuid, getpwnam, setpwent, endpwent," "" getpwent(3) .xx "password file entry." "getpwent, getpwuid," "getpwnam, setpwent, endpwent, setpwfile: get" "" getpwent(3) .xx "get password file entry." "getpwent," "getpwuid, getpwnam, setpwent, endpwent, setpwfile:" "" getpwent(3) .xx "resource consumption." "" "getrlimit, setrlimit: control maximum system" "" getrlimit(2) .xx "utilization." "" "getrusage: get information about resource" "" getrusage(2) .xx "" "" "gets, fgets: get a string from a stream." "" gets(3S) .xx "entry." "getservent, getservbyport," "getservbyname, setservent, endservent: get service" "" getservent(3N) .xx "endservent: get service entry." "getservent," "getservbyport, getservbyname, setservent," "" getservent(3N) .xx "setservent, endservent: get service entry." "" "getservent, getservbyport, getservbyname," "" getservent(3N) .xx "" "gettimeofday, settimeofday:" "get/set date and time." "" gettimeofday(2) .xx "" "gethostname, sethostname:" "get/set name of current host." "" gethostname(2) .xx "" "getpriority, setpriority:" "get/set program scheduling priority." "" getpriority(2) .xx "" "gethostid, sethostid:" "get/set unique identifier of current host." "" gethostid(2) .xx "" "getitimer, setitimer:" "get/set value of interval timer." "" getitimer(2) .xx "" "" "getsockname: get socket name." "" getsockname(2) .xx "sockets." "" "getsockopt, setsockopt: get and set options on" "" getsockopt(2) .xx "" "" "gettable: get NIC format host tables from a host." "" gettable(8C) .xx "" "" "gettimeofday, settimeofday: get/set date and time." "" gettimeofday(2) .xx "ttys file entry." "" "getttyent, getttynam, setttyent, endttyent: get" "" getttyent(3) .xx "entry." "getttyent," "getttynam, setttyent, endttyent: get ttys file" "" getttyent(3) .xx "" "" "getty: set terminal mode." "" getty(8) .xx "" "" "gettytab: terminal configuration data base." "" gettytab(5) .xx "" "" "getuid, geteuid: get user identity." "" getuid(2) .xx "" "" "getuid, getgid: get user or group ID of the caller." "" getuid(3F) .xx "user shells." "" "getusershell, setusershell, endusershell: get legal" "" getusershell(3) .xx "" "getc, getchar, fgetc," "getw: get character or word from stream." "" getc(3S) .xx "" "" "getwd: get current working directory pathname." "" getwd(3) .xx "" "head:" "give first few lines." "" head(1) .xx "" "shutdown: close down the system at a" "given time." "" shutdown(8) .xx "" "" "glob: filename expand argument list." "" csh(1) .xx "ASCII." "ctime, localtime," "gmtime, asctime, timezone: convert date and time to" "" ctime(3) .xx "" "time, ctime, ltime," "gmtime: return system time." "" time(3F) .xx "" "fish: play" "``Go Fish''." "" fish(6) .xx "" "setjmp, longjmp: non-local" "goto." "" setjmp(3) .xx "" "" "goto: command transfer." "" csh(1) .xx "" "" "gprof: display call graph profile data." "" gprof(1) .xx "" "graph: draw a" "graph." "" graph(1G) .xx "" "" "graph: draw a graph." "" graph(1G) .xx "" "gprof: display call" "graph profile data." "" gprof(1) .xx "" "ik: Ikonas frame buffer," "graphics device interface." "" ik(4) .xx "" "ps: Evans and Sutherland Picture System 2" "graphics device interface." "" ps(4) .xx "" "plot:" "graphics filters." "" plot(1G) .xx "" "arc, move, cont, point, linemod, space, closepl:" "graphics interface." "/erase, label, line, circle," plot(3X) .xx "" "plot:" "graphics interface." "" plot(5) .xx "" "lib2648: subroutines for the HP 2648" "graphics terminal." "" lib2648(3X) .xx "" "" "grep, egrep, fgrep: search a file for a pattern." "" grep(1) .xx "" "vgrind:" "grind nice listings of programs." "" vgrind(1) .xx "" "chgrp: change" "group." "" chgrp(1) .xx "" "getpgrp: get process" "group." "" getpgrp(2) .xx "" "killpg: send signal to a process" "group." "" killpg(2) .xx "" "setpgrp: set process" "group." "" setpgrp(2) .xx "" "getgroups: get" "group access list." "" getgroups(2) .xx "" "initgroups: initialize" "group access list." "" initgroups(3) .xx "" "setgroups: set" "group access list." "" setgroups(2) .xx "" "group:" "group file." "" group(5) .xx "" "getgrgid, getgrnam, setgrent, endgrent: get" "group file entry." "getgrent," getgrent(3) .xx "" "" "group: group file." "" group(5) .xx "" "setregid: set real and effective" "group ID." "" setregid(2) .xx "" "setruid, setgid, setegid, setrgid: set user and" "group ID." "setuid, seteuid," setuid(3) .xx "" "getuid, getgid: get user or" "group ID of the caller." "" getuid(3F) .xx "" "getgid, getegid: get" "group identity." "" getgid(2) .xx "" "groups: show" "group memberships." "" groups(1) .xx "" "chown: change owner and" "group of a file." "" chown(2) .xx "" "make: maintain program" "groups." "" make(1) .xx "" "" "groups: show group memberships." "" groups(1) .xx "" "worm: Play the" "growing worm game." "" worm(6) .xx "" "stty," "gtty: set and get terminal state (defunct)." "" stty(3C) .xx "" "stop:" "halt a job or process." "" csh(1) .xx "" "reboot: reboot system or" "halt processor." "" reboot(2) .xx "" "" "halt: stop the processor." "" halt(8) .xx "" "rmail:" "handle remote mail received via uucp." "" rmail(1) .xx "" "mh: Message" "Handler." "" mh(1) .xx "" "re_comp, re_exec: regular expression" "handler." "" regex(3) .xx "" "hangman: Computer version of the game" "hangman." "" hangman(6) .xx "" "" "hangman: Computer version of the game hangman." "" hangman(6) .xx "" "vhangup: virtually" "``hangup'' the current control terminal." "" vhangup(2) .xx "" "nohup: run command immune to" "hangups." "" csh(1) .xx "" "crash: what" "happens when the system crashes." "" crash(8V) .xx "" "link: make a" "hard link to a file." "" link(2) .xx "" "intro: introduction to special files and" "hardware support." "" intro(4) .xx "" "rehash: recompute command" "hash table." "" csh(1) .xx "" "unhash: discard command" "hash table." "" csh(1) .xx "" "mkhosts: generate" "hashed host table." "" mkhosts(8) .xx "" "mkpasswd: generate" "hashed password table." "" mkpasswd(8) .xx "" "hashstat: print command" "hashing statistics." "" csh(1) .xx "" "" "hashstat: print command hashing statistics." "" csh(1) .xx "" "leave: remind you when you" "have to leave." "" leave(1) .xx "" "" "hdh: ACC IF-11/HDH IMP interface." "" hdh(4) .xx "" "od: octal, decimal," "hex, ascii dump." "" od(1) .xx "" "" "hier: file system hierarchy." "" hier(7) .xx "" "hier: file system" "hierarchy." "" hier(7) .xx "" "history: print" "history event list." "" csh(1) .xx "" "" "history: print history event list." "" csh(1) .xx "" "" "hk: RK6-11/RK06 and RK07 moving head disk." "" hk(4) .xx "" "fortune: print a random," "hopefully interesting, adage." "" fortune(6) .xx "" "sethostid: get/set unique identifier of current" "host." "gethostid," gethostid(2) .xx "" "gethostname, sethostname: get/set name of current" "host." "" gethostname(2) .xx "" "gettable: get NIC format host tables from a" "host." "" gettable(8C) .xx "" "hostnm: get name of current" "host." "" hostnm(3F) .xx "" "uusend: send a file to a remote" "host." "" uusend(1C) .xx "" "htonl, htons, ntohl, ntohs: convert values between" "host and network byte order." "" byteorder(3N) .xx "" "L.sys: UUCP remote" "host description file." "" L.sys(5) .xx "" "remote: remote" "host description file." "" remote(5) .xx "" "gethostent, sethostent, endhostent: get network" "host entry." "gethostbyname, gethostbyaddr," gethostbyname(3N) .xx "" "hosts:" "host name data base." "" hosts(5) .xx "" "phones: remote" "host phone number data base." "" phones(5) .xx "" "ruptime: show" "host status of local machines." "" ruptime(1C) .xx "" "hostid: set or print identifier of current" "host system." "" hostid(1) .xx "" "hostname: set or print name of current" "host system." "" hostname(1) .xx "" "mkhosts: generate hashed" "host table." "" mkhosts(8) .xx "" "htable: convert NIC standard format" "host tables." "" htable(8) .xx "" "gettable: get NIC format" "host tables from a host." "" gettable(8C) .xx "system." "" "hostid: set or print identifier of current host" "" hostid(1) .xx "" "L.aliases: UUCP" "hostname alias file." "" L.aliases(5) .xx "" "" "hostname: set or print name of current host system." "" hostname(1) .xx "" "" "hostnm: get name of current host." "" hostnm(3F) .xx "" "ping: send ICMP ECHO_REQUEST packets to network" "hosts." "" ping(8) .xx "" "uuname: list names of UUCP" "hosts." "" uuname(1C) .xx "" "" "hosts: host name data base." "" hosts(5) .xx "" "uptime: show" "how long system has been up." "" uptime(1) .xx "" "format:" "how to format disk packs." "" format(8V) .xx "" "lib2648: subroutines for the" "HP 2648 graphics terminal." "" lib2648(3X) .xx "" "" "hp: MASSBUS disk interface." "" hp(4) .xx "interface." "" "ht: TM-03/TE-16,TU-45,TU-77 MASSBUS magtape" "" ht(4) .xx "" "" "htable: convert NIC standard format host tables." "" htable(8) .xx "host and network byte order." "" "htonl, htons, ntohl, ntohs: convert values between" "" byteorder(3N) .xx "and network byte order." "htonl," "htons, ntohl, ntohs: convert values between host" "" byteorder(3N) .xx "" "" "hunt: a multi-player multi-terminal game." "" hunt(6) .xx "" "wump: the game of" "hunt-the-wumpus." "" wump(6) .xx "" "" "hy: Network Systems Hyperchannel interface." "" hy(4) .xx "" "asinh, acosh, atanh: inverse" "hyperbolic functions." "" asinh(3M) .xx "" "sinh, cosh, tanh:" "hyperbolic functions." "" sinh(3M) .xx "" "hy: Network Systems" "Hyperchannel interface." "" hy(4) .xx "value." "" "hypot, cabs: Euclidean distance, complex absolute" "" hypot(3M) .xx "" "vacation: return" "``I am on vacation'' indication." "" vacation(1) .xx "" "getarg," "iargc: return command line arguments." "" getarg(3F) .xx "" "mset: retrieve ASCII to" "IBM 3270 keyboard map." "" mset(1) .xx "" "map3270: database for mapping ascii keystrokes into" "IBM 3270 keys." "" map3270(5) .xx "" "tn3270: full-screen remote login to" "IBM VM/CMS." "" tn3270(1) .xx "" "" "icheck: file system storage consistency check." "" icheck(8) .xx "" "ping: send" "ICMP ECHO_REQUEST packets to network hosts." "" ping(8) .xx "" "" "icmp: Internet Control Message Protocol." "" icmp(4P) .xx "" "getpid: get process" "id." "" getpid(3F) .xx "" "setregid: set real and effective group" "ID." "" setregid(2) .xx "" "setgid, setegid, setrgid: set user and group" "ID." "setuid, seteuid, setruid," setuid(3) .xx "" "whoami: print effective current user" "id." "" whoami(1) .xx "" "getuid, getgid: get user or group" "ID of the caller." "" getuid(3F) .xx "" "su: substitute user" "id temporarily." "" su(1) .xx "form." "" "idate, itime: return date or time in numerical" "" idate(3F) .xx "" "getpid, getppid: get process" "identification." "" getpid(2) .xx "" "gethostid, sethostid: get/set unique" "identifier of current host." "" gethostid(2) .xx "" "hostid: set or print" "identifier of current host system." "" hostid(1) .xx "" "getgid, getegid: get group" "identity." "" getgid(2) .xx "" "getuid, geteuid: get user" "identity." "" getuid(2) .xx "" "" "idp: Xerox Internet Datagram Protocol." "" idp(4P) .xx "" "setreuid: set real and effective user" "ID's." "" setreuid(2) .xx "" "perror, gerror," "ierrno: get system error messages." "" perror(3F) .xx "" "" "if: conditional statement." "" csh(1) .xx "" "biff: be notified" "if mail arrives and who it is from." "" biff(1) .xx "eval, exec, exit, export, login,/" "sh, for, case," "if, while, \fB:\fP, \fB.\fP, break, continue, cd," "" sh(1) .xx "" "hdh: ACC" "IF-11/HDH IMP interface." "" hdh(4) .xx "" "" "ifconfig: configure network interface parameters." "" ifconfig(8C) .xx "" "unifdef: remove" "ifdef'ed lines." "" unifdef(1) .xx "" "uu: TU58/DECtape" "II UNIBUS cassette interface." "" uu(4) .xx "" "" "ik: Ikonas frame buffer, graphics device interface." "" ik(4) .xx "" "ik:" "Ikonas frame buffer, graphics device interface." "" ik(4) .xx "" "" "il: Interlan NI1010 10 Mb/s Ethernet interface." "" il(4) .xx "" "core: format of memory" "image file." "" core(5) .xx "" "gcore: get core" "images of running processes." "" gcore(1) .xx "" "notify: request" "immediate notification." "" csh(1) .xx "" "nohup: run command" "immune to hangups." "" csh(1) .xx "" "" "imp: 1822 network interface." "" imp(4) .xx "" "" "imp: IMP raw socket interface." "" imp(4P) .xx "" "acc: ACC LH/DH" "IMP interface." "" acc(4) .xx "" "css: DEC IMP-11A LH/DH" "IMP interface." "" css(4) .xx "" "ddn: DDN Standard Mode X.25" "IMP interface." "" ddn(4) .xx "" "hdh: ACC IF-11/HDH" "IMP interface." "" hdh(4) .xx "" "implog:" "IMP log interpreter." "" implog(8C) .xx "" "implogd:" "IMP logger process." "" implogd(8C) .xx "" "imp:" "IMP raw socket interface." "" imp(4P) .xx "" "css: DEC" "IMP-11A LH/DH IMP interface." "" css(4) .xx "" "xstr: extract strings from C programs to" "implement shared strings." "" xstr(1) .xx "" "" "implog: IMP log interpreter." "" implog(8C) .xx "" "" "implogd: IMP logger process." "" implogd(8C) .xx "" "which: locate a program file" "including aliases and paths (\fIcsh\fR only)." "" which(1) .xx "" "fsync: synchronize a file's" "in-core state with that on disk." "" fsync(2) .xx "" "dump, dumpdates:" "incremental dump format." "" dump(5) .xx "" "dump:" "incremental file system dump." "" dump(8) .xx "" "restore:" "incremental file system restore." "" restore(8) .xx "" "indent:" "indent and format C program source." "" indent(1) .xx "" "" "indent: indent and format C program source." "" indent(1) .xx "" "tgetnum, tgetflag, tgetstr, tgoto, tputs: terminal" "independent operation routines." "tgetent," termcap(3X) .xx "" "ptx: permuted" "index." "" ptx(1) .xx "" "L-dialcodes: UUCP phone number" "index file." "" L-dialcodes(5) .xx "bibliography." "indxbib, lookbib: build inverted" "index for a bibliography, find references in a" "" lookbib(1) .xx "objects." "" "index, rindex, lnblnk, len: tell about character" "" index(3F) .xx "" "strncat, strcmp, strncmp, strcpy, strncpy, strlen," "index, rindex: string operations." "strcat," string(3) .xx "" "last:" "indicate last logins of users and teletypes." "" last(1) .xx "" "vacation: return ``I am on vacation''" "indication." "" vacation(1) .xx "" "syscall:" "indirect system call." "" syscall(2) .xx "" "fsplit: split a multi-routine Fortran file into" "individual files." "" fsplit(1) .xx "bibliography, find references in a bibliography." "" "indxbib, lookbib: build inverted index for a" "" lookbib(1) .xx "" "" "inet: Internet protocol family." "" inet(4F) .xx "inet_lnaof, inet_netof: Internet address/" "" "inet_addr, inet_network, inet_ntoa, inet_makeaddr," "" inet(3N) .xx "" "" "inetd: internet ``super\-server''." "" inetd(8) .xx "" "inet_addr, inet_network, inet_ntoa, inet_makeaddr," "inet_lnaof, inet_netof: Internet address/" "" inet(3N) .xx "address/" "inet_addr, inet_network, inet_ntoa," "inet_makeaddr, inet_lnaof, inet_netof: Internet" "" inet(3N) .xx "" "/inet_network, inet_ntoa, inet_makeaddr, inet_lnaof," "inet_netof: Internet address manipulation routines." "" inet(3N) .xx "inet_netof: Internet address/" "inet_addr," "inet_network, inet_ntoa, inet_makeaddr, inet_lnaof," "" inet(3N) .xx "Internet address/" "inet_addr, inet_network," "inet_ntoa, inet_makeaddr, inet_lnaof, inet_netof:" "" inet(3N) .xx "on a VAX (temporary)." "" "infnan: signals invalid floating-point operations" "" infnan(3M) .xx "" "bad144: read/write dec standard 144 bad sector" "information." "" bad144(8) .xx "" "chfn, chsh, passwd: change password file" "information." "" chfn(1) .xx "" "chfn, chsh, passwd: change password file" "information." "" chsh(1) .xx "" "dbx: dbx symbol table" "information." "" dbx(5) .xx "" "dumpfs: dump file system" "information." "" dumpfs(8) .xx "" "pac: printer/plotter accounting" "information." "" pac(8) .xx "" "chfn, chsh, passwd: change password file" "information." "" passwd(1) .xx "" "getrusage: get" "information about resource utilization." "" getrusage(2) .xx "" "vtimes: get" "information about resource utilization." "" vtimes(3C) .xx "" "fstab: static" "information about the filesystems." "" fstab(5) .xx "" "man: find manual" "information by keywords; print out the manual." "" man(1) .xx "" "finger: user" "information lookup program." "" finger(1) .xx "" "miscellaneous: miscellaneous useful" "information pages." "" intro(7) .xx "" "XNSrouted: NS Routing" "Information Protocol daemon." "" XNSrouted(8C) .xx "" "fingerd: remote user" "information server." "" fingerd(8C) .xx "" "" "init: process control initialization." "" init(8) .xx "" "" "initgroups: initialize group access list." "" initgroups(3) .xx "" "init: process control" "initialization." "" init(8) .xx "" "ioinit: change f77 I/O" "initialization." "" ioinit(3F) .xx "" "tset: terminal dependent" "initialization." "" tset(1) .xx "" "ttys: terminal" "initialization data." "" ttys(5) .xx "" "initgroups:" "initialize group access list." "" initgroups(3) .xx "" "connect:" "initiate a connection on a socket." "" connect(2) .xx "" "popen, pclose:" "initiate I/O to/from a process." "" popen(3) .xx "generator; routines for changing/" "random, srandom," "initstate, setstate: better random number" "" random(3) .xx "" "flmin, flmax, ffrac, dflmin, dflmax, dffrac," "inmax: return extreme values." "" flmin(3F) .xx "" "clri: clear" "i-node." "" clri(8) .xx "" "fs," "inode: format of file system volume." "" fs(5) .xx "" "read, readv: read" "input." "" read(2) .xx "" "soelim: eliminate \&.so's from nroff" "input." "" soelim(1) .xx "" "scanf, fscanf, sscanf: formatted" "input conversion." "" scanf(3S) .xx "" "ungetc: push character back into" "input stream." "" ungetc(3S) .xx "" "fread, fwrite: buffered binary" "input/output." "" fread(3S) .xx "" "stdio: standard buffered" "input/output package." "" stdio(3S) .xx "" "ferror, feof, clearerr, fileno: stream status" "inquiries." "" ferror(3S) .xx "" "refer: find and" "insert literature references in documents." "" refer(1) .xx "" "insque, remque:" "insert/remove element from a queue." "" insque(3) .xx "" "" "insque, remque: insert/remove element from a queue." "" insque(3) .xx "" "install:" "install binaries." "" install(1) .xx "" "" "install: install binaries." "" install(1) .xx "" "learn: computer aided" "instruction about UNIX." "" learn(1) .xx "" "doctor:" "interact with a psychoanalyst." "" doctor(6) .xx "" "jove: an" "interactive display-oriented text editor." "" jove(1) .xx "" "fsck: file system consistency check and" "interactive repair." "" fsck(8) .xx "" "fortune: print a random, hopefully" "interesting, adage." "" fortune(6) .xx "" "acc: ACC LH/DH IMP" "interface." "" acc(4) .xx "" "cons: VAX-11 console" "interface." "" cons(4) .xx "" "crl: VAX 8600 console RL02" "interface." "" crl(4) .xx "" "css: DEC IMP-11A LH/DH IMP" "interface." "" css(4) .xx "" "ct: phototypesetter" "interface." "" ct(4) .xx "" "ddn: DDN Standard Mode X.25 IMP" "interface." "" ddn(4) .xx "" "de: DEC DEUNA 10 Mb/s Ethernet" "interface." "" de(4) .xx "" "dn: DN-11 autocall unit" "interface." "" dn(4) .xx "" "ec: 3Com 10 Mb/s Ethernet" "interface." "" ec(4) .xx "" "en: Xerox 3 Mb/s Ethernet" "interface." "" en(4) .xx "" "ex: Excelan 10 Mb/s Ethernet" "interface." "" ex(4) .xx "" "fl: console floppy" "interface." "" fl(4) .xx "" "hdh: ACC IF-11/HDH IMP" "interface." "" hdh(4) .xx "" "hp: MASSBUS disk" "interface." "" hp(4) .xx "" "ht: TM-03/TE-16,TU-45,TU-77 MASSBUS magtape" "interface." "" ht(4) .xx "" "hy: Network Systems Hyperchannel" "interface." "" hy(4) .xx "" "ik: Ikonas frame buffer, graphics device" "interface." "" ik(4) .xx "" "il: Interlan NI1010 10 Mb/s Ethernet" "interface." "" il(4) .xx "" "imp: 1822 network" "interface." "" imp(4) .xx "" "imp: IMP raw socket" "interface." "" imp(4P) .xx "" "ix: Interlan Np100 10 Mb/s Ethernet" "interface." "" ix(4) .xx "" "lo: software loopback network" "interface." "" lo(4) .xx "" "mt: TM78/TU-78 MASSBUS magtape" "interface." "" mt(4) .xx "" "mtio: UNIX magtape" "interface." "" mtio(4) .xx "" "np: Interlan Np100 10 Mb/s Ethernet" "interface." "" np(4) .xx "" "pcl: DEC CSS PCL-11 B Network" "Interface." "" pcl(4) .xx "" "cont, point, linemod, space, closepl: graphics" "interface." "/erase, label, line, circle, arc, move," plot(3X) .xx "" "plot: graphics" "interface." "" plot(5) .xx "" "and Sutherland Picture System 2 graphics device" "interface." "ps: Evans" ps(4) .xx "" "qe: DEC DEQNA Q-bus 10 Mb/s Ethernet" "interface." "" qe(4) .xx "" "rx: DEC RX02 floppy disk" "interface." "" rx(4) .xx "" "tm: TM-11/TE-10 magtape" "interface." "" tm(4) .xx "" "tmscp: DEC TMSCP magtape" "interface." "" tmscp(4) .xx "" "ts: TS-11 magtape" "interface." "" ts(4) .xx "" "tty: general terminal" "interface." "" tty(4) .xx "" "tu: VAX-11/730 and VAX-11/750 TU58 console cassette" "interface." "" tu(4) .xx "" "uda: UDA-50 disk controller" "interface." "" uda(4) .xx "" "ut: UNIBUS TU45 tri-density tape drive" "interface." "" ut(4) .xx "" "uu: TU58/DECtape II UNIBUS cassette" "interface." "" uu(4) .xx "" "va: Benson-Varian" "interface." "" va(4) .xx "" "vp: Versatec" "interface." "" vp(4) .xx "" "nsip: software network" "interface encapsulating ns packets in ip packets.." "" nsip(4) .xx "" "ifconfig: configure network" "interface parameters." "" ifconfig(8C) .xx "" "plot: openpl et al.: f77 library" "interface to \fIplot\fR (3X) libraries.." "" plot(3F) .xx "" "telnet: user" "interface to the TELNET protocol." "" telnet(1C) .xx "" "slattach: attach serial lines as network" "interfaces." "" slattach(8C) .xx "" "il:" "Interlan NI1010 10 Mb/s Ethernet interface." "" il(4) .xx "" "ix:" "Interlan Np100 10 Mb/s Ethernet interface." "" ix(4) .xx "" "np:" "Interlan Np100 10 Mb/s Ethernet interface." "" np(4) .xx "" "swapon: add a swap device for" "interleaved paging/swapping." "" swapon(2) .xx "" "sendmail: send mail over the" "internet." "" sendmail(8) .xx "" "/inet_ntoa, inet_makeaddr, inet_lnaof, inet_netof:" "Internet address manipulation routines." "" inet(3N) .xx "" "icmp:" "Internet Control Message Protocol." "" icmp(4P) .xx "" "idp: Xerox" "Internet Datagram Protocol." "" idp(4P) .xx "" "named:" "Internet domain name server." "" named(8) .xx "" "ftpd: DARPA" "Internet File Transfer Protocol server." "" ftpd(8C) .xx "" "ip:" "Internet Protocol." "" ip(4P) .xx "" "inet:" "Internet protocol family." "" inet(4F) .xx "" "inetd:" "internet ``super\-server''." "" inetd(8) .xx "" "tcp:" "Internet Transmission Control Protocol." "" tcp(4P) .xx "" "udp:" "Internet User Datagram Protocol." "" udp(4P) .xx "" "whois: DARPA" "Internet user name directory service." "" whois(1) .xx "" "spline:" "interpolate smooth curve." "" spline(1G) .xx "" "implog: IMP log" "interpreter." "" implog(8C) .xx "" "lisp: lisp" "interpreter." "" lisp(1) .xx "" "px: Pascal" "interpreter." "" px(1) .xx "" "uuxqt: UUCP execution file" "interpreter." "" uuxqt(8C) .xx "" "pix: Pascal" "interpreter and executor." "" pix(1) .xx "" "pi: Pascal" "interpreter code translator." "" pi(1) .xx "" "csh: a shell (command" "interpreter) with C-like syntax." "" csh(1) .xx "" "pipe: create an" "interprocess communication channel." "" pipe(2) .xx "" "atomically release blocked signals and wait for" "interrupt." "sigpause:" sigpause(2) .xx "" "siginterrupt: allow signals to" "interrupt system calls." "" siginterrupt(3) .xx "" "onintr: process" "interrupts in command scripts." "" csh(1) .xx "" "intro:" "introduction to C library functions." "" intro(3) .xx "" "intro:" "introduction to commands." "" intro(1) .xx "" "intro:" "introduction to FORTRAN library functions." "" intro(3F) .xx "" "math:" "introduction to mathematical library functions." "" math(3M) .xx "" "networking:" "introduction to networking facilities." "" intro(4N) .xx "" "rcsintro:" "introduction to RCS commands." "" rcsintro(1) .xx "" "intro:" "introduction to special files and hardware support." "" intro(4) .xx "" "intro:" "introduction to system calls and error numbers." "" intro(2) .xx "commands." "intro:" "introduction to system maintenance and operation" "" intro(8) .xx "" "ncheck: generate names from" "i-numbers." "" ncheck(8) .xx "(temporary)." "infnan: signals" "invalid floating-point operations on a VAX" "" infnan(3M) .xx "" "asinh, acosh, atanh:" "inverse hyperbolic functions." "" asinh(3M) .xx "" "atan, atan2: trigonometric functions and their" "inverses." "sin, cos, tan, asin, acos," sin(3M) .xx "m_in, mout,/" "madd, msub, mult, mdiv, pow, gcd," "invert, rpow, msqrt, mcmp, move, min, omin, fmin," "" mp(3X) .xx "in a bibliography." "indxbib, lookbib: build" "inverted index for a bibliography, find references" "" lookbib(1) .xx "" "tread, twrite, trewin, tskipf, tstate: f77 tape" "I/O." "topen, tclose," topen(3F) .xx "" "ioinit: change f77" "I/O initialization." "" ioinit(3F) .xx "" "select: synchronous" "I/O multiplexing." "" select(2) .xx "" "iostat: report" "I/O statistics." "" iostat(1) .xx "" "popen, pclose: initiate" "I/O to/from a process." "" popen(3) .xx "" "" "ioctl: control device." "" ioctl(2) .xx "" "" "ioinit: change f77 I/O initialization." "" ioinit(3F) .xx "" "" "iostat: report I/O statistics." "" iostat(1) .xx "" "" "ip: Internet Protocol." "" ip(4P) .xx "" "network interface encapsulating ns packets in" "ip packets.." "nsip: software" nsip(4) .xx "" "rand, drand," "irand: return random values." "" rand(3F) .xx "" "random, drandm," "irandm: better random number generator." "" random(3F) .xx "" "sail: multi-user wooden ships and" "iron men." "" sail(6) .xx "" "isalpha, isupper, islower, isdigit, isxdigit," "isalnum, isspace, ispunct, isprint, isgraph,/" "" ctype(3) .xx "isalnum, isspace, ispunct, isprint, isgraph,/" "" "isalpha, isupper, islower, isdigit, isxdigit," "" ctype(3) .xx "" "/isspace, ispunct, isprint, isgraph, iscntrl," "isascii, toupper, tolower, toascii: character/" "" ctype(3) .xx "" "ttynam," "isatty: find name of a terminal port." "" ttynam(3F) .xx "" "ttyname," "isatty, ttyslot: find name of a terminal." "" ttyname(3) .xx "" "/isalnum, isspace, ispunct, isprint, isgraph," "iscntrl, isascii, toupper, tolower, toascii:/" "" ctype(3) .xx "isprint, isgraph,/" "isalpha, isupper, islower," "isdigit, isxdigit, isalnum, isspace, ispunct," "" ctype(3) .xx "" "/isxdigit, isalnum, isspace, ispunct, isprint," "isgraph, iscntrl, isascii, toupper, tolower,/" "" ctype(3) .xx "ispunct, isprint, isgraph,/" "isalpha, isupper," "islower, isdigit, isxdigit, isalnum, isspace," "" ctype(3) .xx "" "/isdigit, isxdigit, isalnum, isspace, ispunct," "isprint, isgraph, iscntrl, isascii, toupper,/" "" ctype(3) .xx "" "/islower, isdigit, isxdigit, isalnum, isspace," "ispunct, isprint, isgraph, iscntrl, isascii,/" "" ctype(3) .xx "" "/isupper, islower, isdigit, isxdigit, isalnum," "isspace, ispunct, isprint, isgraph, iscntrl,/" "" ctype(3) .xx "" "system:" "issue a shell command." "" system(3) .xx "isspace, ispunct, isprint, isgraph,/" "isalpha," "isupper, islower, isdigit, isxdigit, isalnum," "" ctype(3) .xx "isgraph,/" "isalpha, isupper, islower, isdigit," "isxdigit, isalnum, isspace, ispunct, isprint," "" ctype(3) .xx "" "formatter; list bibliographic reference" "items." "bib, listrefs: bibliographic" bib(1) .xx "" "idate," "itime: return date or time in numerical form." "" idate(3F) .xx "" "omin, fmin, m_in, mout, omout, fmout, m_out, sdiv," "itom: multiple precision integer arithmetic." "/min," mp(3X) .xx "" "" "ix: Interlan Np100 10 Mb/s Ethernet interface." "" ix(4) .xx "" "" "j0, j1, jn, y0, y1, yn: bessel functions." "" j0(3M) .xx "" "j0," "j1, jn, y0, y1, yn: bessel functions." "" j0(3M) .xx "" "j0, j1," "jn, y0, y1, yn: bessel functions." "" j0(3M) .xx "" "bg: place" "job in background." "" csh(1) .xx "" "fg: bring" "job into foreground." "" csh(1) .xx "" "jobs: print current" "job list." "" csh(1) .xx "" "stop: halt a" "job or process." "" csh(1) .xx "" "kill: kill" "jobs and processes." "" csh(1) .xx "" "lprm: remove" "jobs from the line printer spooling queue." "" lprm(1) .xx "" "" "jobs: print current job list." "" csh(1) .xx "" "atrm: remove" "jobs spooled by at." "" atrm(1) .xx "" "atq: print the queue of" "jobs waiting to be run." "" atq(1) .xx "" "" "join: relational database operator." "" join(1) .xx "" "" "jove: an interactive display-oriented text editor." "" jove(1) .xx "" "msgs: system messages and" "junk mail program." "" msgs(1) .xx "" "makekey: generate encryption" "key." "" makekey(8) .xx "" "mset: retrieve ASCII to IBM 3270" "keyboard map." "" mset(1) .xx "" "database for mapping ascii keystrokes into IBM 3270" "keys." "map3270:" map3270(5) .xx "" "map3270: database for mapping ascii" "keystrokes into IBM 3270 keys." "" map3270(5) .xx "" "apropos: locate commands by" "keyword lookup." "" apropos(1) .xx "" "man: find manual information by" "keywords; print out the manual." "" man(1) .xx "" "" "kg: KL-11/DL-11W line clock." "" kg(4) .xx "profile buffers." "" "kgmon: generate a dump of the operating system's" "" kgmon(8) .xx "" "kill:" "kill jobs and processes." "" csh(1) .xx "" "" "kill: kill jobs and processes." "" csh(1) .xx "" "" "kill: send a signal to a process." "" kill(3F) .xx "" "" "kill: send signal to a process." "" kill(2) .xx "" "" "kill: terminate a process with extreme prejudice." "" kill(1) .xx "" "" "killpg: send signal to a process group." "" killpg(2) .xx "" "bessel functions: of two" "kinds for integer orders." "" bessel(3F) .xx "" "kg:" "KL-11/DL-11W line clock." "" kg(4) .xx "" "mem," "kmem: main memory." "" mem(4) .xx "linemod, space, closepl:/" "plot: openpl, erase," "label, line, circle, arc, move, cont, point," "" plot(3X) .xx "" "" "L.aliases: UUCP hostname alias file." "" L.aliases(5) .xx "" "awk: pattern scanning and processing" "language." "" awk(1) .xx "" "bc: arbitrary-precision arithmetic" "language." "" bc(1) .xx "" "efl: Extended Fortran" "Language." "" efl(1) .xx "" "set, shift, times, trap, umask, wait: command" "language." "/exit, export, login, read, readonly," sh(1) .xx "" "fp: Functional Programming" "language compiler/interpreter." "" fp(1) .xx "" "vgrindefs: vgrind's" "language definition data base." "" vgrindefs(5) .xx "order." "" "lastcomm: show last commands executed in reverse" "" lastcomm(1) .xx "" "" "L.cmds: UUCP remote command permissions file." "" L.cmds(5) .xx "" "" "ld: link editor." "" ld(1) .xx "" "" "L-devices: UUCP device description file." "" L-devices(5) .xx "" "frexp," "ldexp, modf: split into mantissa and exponent." "" frexp(3) .xx "" "" "L-dialcodes: UUCP phone number index file." "" L-dialcodes(5) .xx "" "" "learn: computer aided instruction about UNIX." "" learn(1) .xx "" "leave: remind you when you have to" "leave." "" leave(1) .xx "" "" "leave: remind you when you have to leave." "" leave(1) .xx "" "exit:" "leave shell." "" csh(1) .xx "" "getusershell, setusershell, endusershell: get" "legal user shells." "" getusershell(3) .xx "" "index, rindex, lnblnk," "len: tell about character objects." "" index(3F) .xx "" "truncate: truncate a file to a specified" "length." "" truncate(2) .xx "" "getopt: get option" "letter from argv." "" getopt(3) .xx "" "" "lex: generator of lexical analysis programs." "" lex(1) .xx "" "lex: generator of" "lexical analysis programs." "" lex(1) .xx "" "" "lgamma: log gamma function." "" lgamma(3M) .xx "" "acc: ACC" "LH/DH IMP interface." "" acc(4) .xx "" "css: DEC IMP-11A" "LH/DH IMP interface." "" css(4) .xx "terminal." "" "lib2648: subroutines for the HP 2648 graphics" "" lib2648(3X) .xx "" "et al.: f77 library interface to \fIplot\fR (3X)" "libraries.." "plot: openpl" plot(3F) .xx "" "ranlib: convert archives to random" "libraries." "" ranlib(1) .xx "" "lorder: find ordering relation for an object" "library." "" lorder(1) .xx "" "ar: archive" "(library) file format." "" ar(5) .xx "" "intro: introduction to C" "library functions." "" intro(3) .xx "" "intro: introduction to FORTRAN" "library functions." "" intro(3F) .xx "" "math: introduction to mathematical" "library functions." "" math(3M) .xx "" "plot: openpl et al.: f77" "library interface to \fIplot\fR (3X) libraries.." "" plot(3F) .xx "" "ar: archive and" "library maintainer." "" ar(1) .xx "" "" "limit: alter per-process resource limitations." "" csh(1) .xx "" "limit: alter per-process resource" "limitations." "" csh(1) .xx "" "unlimit: remove resource" "limitiations." "" csh(1) .xx "" "quota: display disc usage and" "limits." "" quota(1) .xx "" "getarg, iargc: return command" "line arguments." "" getarg(3F) .xx "space, closepl:/" "plot: openpl, erase, label," "line, circle, arc, move, cont, point, linemod," "" plot(3X) .xx "" "kg: KL-11/DL-11W" "line clock." "" kg(4) .xx "" "tb:" "line discipline for digitizing devices." "" tb(4) .xx "(obsolete)." "bk:" "line discipline for machine-machine communication" "" bk(4) .xx "" "col: filter reverse" "line feeds." "" col(1) .xx "" "sysline: display system status on status" "line of a terminal." "" sysline(1) .xx "" "lpr: off" "line print." "" lpr(1) .xx "" "lp:" "line printer." "" lp(4) .xx "" "lpc:" "line printer control program." "" lpc(8) .xx "" "lpd:" "line printer daemon." "" lpd(8) .xx "" "lprm: remove jobs from the" "line printer spooling queue." "" lprm(1) .xx "" "/erase, label, line, circle, arc, move, cont, point," "linemod, space, closepl: graphics interface." "" plot(3X) .xx "" "lptest: generate" "lineprinter ripple pattern." "" lptest(1) .xx "" "head: give first few" "lines." "" head(1) .xx "" "unifdef: remove ifdef'ed" "lines." "" unifdef(1) .xx "" "slattach: attach serial" "lines as network interfaces." "" slattach(8C) .xx "" "comm: select or reject" "lines common to two sorted files." "" comm(1) .xx "" "fold: fold long" "lines for finite width output device." "" fold(1) .xx "" "uniq: report repeated" "lines in a file." "" uniq(1) .xx "" "look: find" "lines in a sorted list." "" look(1) .xx "" "rev: reverse" "lines of a file." "" rev(1) .xx "" "readlink: read value of a symbolic" "link." "" readlink(2) .xx "" "ld:" "link editor." "" ld(1) .xx "" "a.out: assembler and" "link editor output." "" a.out(5) .xx "" "" "link: make a hard link to a file." "" link(2) .xx "" "" "link: make a link to an existing file." "" link(3F) .xx "" "link: make a hard" "link to a file." "" link(2) .xx "" "symlink: make symbolic" "link to a file." "" symlink(2) .xx "" "link: make a" "link to an existing file." "" link(3F) .xx "" "ln: make" "links." "" ln(1) .xx "" "" "lint: a C program verifier." "" lint(1) .xx "" "lxref:" "lisp cross reference program." "" lxref(1) .xx "" "lisp:" "lisp interpreter." "" lisp(1) .xx "" "" "lisp: lisp interpreter." "" lisp(1) .xx "" "liszt: compile a Franz" "Lisp program." "" liszt(1) .xx "troff." "vlp: Format" "Lisp programs to be printed with nroff, vtroff, or" "" vlp(1) .xx "" "glob: filename expand argument" "list." "" csh(1) .xx "" "history: print history event" "list." "" csh(1) .xx "" "jobs: print current job" "list." "" csh(1) .xx "" "shift: manipulate argument" "list." "" csh(1) .xx "" "getgroups: get group access" "list." "" getgroups(2) .xx "" "initgroups: initialize group access" "list." "" initgroups(3) .xx "" "look: find lines in a sorted" "list." "" look(1) .xx "" "nlist: get entries from name" "list." "" nlist(3) .xx "" "nm: print name" "list." "" nm(1) .xx "" "setgroups: set group access" "list." "" setgroups(2) .xx "" "symorder: rearrange name" "list." "" symorder(1) .xx "" "varargs: variable argument" "list." "" varargs(3) .xx "" "bib, listrefs: bibliographic formatter;" "list bibliographic reference items." "" bib(1) .xx "" "ls:" "list contents of directory." "" ls(1) .xx "" "uuname:" "list names of UUCP hosts." "" uuname(1C) .xx "" "foreach: loop over" "list of names." "" csh(1) .xx "" "users: compact" "list of users who are on the system." "" users(1) .xx "" "listen:" "listen for connections on a socket." "" listen(2) .xx "" "" "listen: listen for connections on a socket." "" listen(2) .xx "" "vgrind: grind nice" "listings of programs." "" vgrind(1) .xx "bibliographic reference items." "bib," "listrefs: bibliographic formatter; list" "" bib(1) .xx "" "" "liszt: compile a Franz Lisp program." "" liszt(1) .xx "" "refer: find and insert" "literature references in documents." "" refer(1) .xx "" "" "ln: make links." "" ln(1) .xx "" "index, rindex," "lnblnk, len: tell about character objects." "" index(3F) .xx "" "" "lo: software loopback network interface." "" lo(4) .xx "" "" "loc: return the address of an object." "" loc(3F) .xx "and time to ASCII." "ctime," "localtime, gmtime, asctime, timezone: convert date" "" ctime(3) .xx "(\fIcsh\fR only)." "which:" "locate a program file including aliases and paths" "" which(1) .xx "" "apropos:" "locate commands by keyword lookup." "" apropos(1) .xx "" "whereis:" "locate source, binary, and or manual for program." "" whereis(1) .xx "" "end, etext, edata: last" "locations in program." "" end(3) .xx "" "flock: apply or remove an advisory" "lock on an open file." "" flock(2) .xx "" "" "lock: reserve a terminal." "" lock(1) .xx "" "collect system diagnostic messages to form error" "log." "dmesg:" dmesg(8) .xx "" "logger: make entries in the system" "log." "" logger(1) .xx "" "openlog, closelog, setlogmask: control system" "log." "syslog," syslog(3) .xx "" "uulog: display UUCP" "log files." "" uulog(1C) .xx "" "lgamma:" "log gamma function." "" lgamma(3M) .xx "" "implog: IMP" "log interpreter." "" implog(8C) .xx "power." "exp, expm1," "log, log10, log1p, pow: exponential, logarithm," "" exp(3M) .xx "" "syslogd:" "log systems messages." "" syslogd(8) .xx "" "exp, expm1, log," "log10, log1p, pow: exponential, logarithm, power." "" exp(3M) .xx "" "exp, expm1, log, log10," "log1p, pow: exponential, logarithm, power." "" exp(3M) .xx "" "exp, expm1, log, log10, log1p, pow: exponential," "logarithm, power." "" exp(3M) .xx "manipulations." "copysign, drem, finite," "logb, scalb: copysign, remainder, exponent" "" ieee(3M) .xx "" "rwho: who's" "logged in on local machines." "" rwho(1C) .xx "" "" "logger: make entries in the system log." "" logger(1) .xx "" "implogd: IMP" "logger process." "" implogd(8C) .xx "" "flush: flush output to a" "logical unit." "" flush(3F) .xx "" "fseek, ftell: reposition a file on a" "logical unit." "" fseek(3F) .xx "" "getc, fgetc: get a character from a" "logical unit." "" getc(3F) .xx "" "putc, fputc: write a character to a fortran" "logical unit." "" putc(3F) .xx "" "rlogin: remote" "login." "" rlogin(1C) .xx "" "ac:" "login accounting." "" ac(8) .xx "" "" "login: login new user." "" csh(1) .xx "" "getlog: get user's" "login name." "" getlog(3F) .xx "" "getlogin: get" "login name." "" getlogin(3) .xx "" "login:" "login new user." "" csh(1) .xx "" "/break, continue, cd, eval, exec, exit, export," "login, read, readonly, set, shift, times, trap,/" "" sh(1) .xx "" "utmp, wtmp:" "login records." "" utmp(5) .xx "" "rlogind: remote" "login server." "" rlogind(8C) .xx "" "" "login: sign on." "" login(1) .xx "" "tn3270: full-screen remote" "login to IBM VM/CMS." "" tn3270(1) .xx "" "last: indicate last" "logins of users and teletypes." "" last(1) .xx "" "" "logout: end session." "" csh(1) .xx "" "setjmp," "longjmp: non-local goto." "" setjmp(3) .xx "" "" "look: find lines in a sorted list." "" look(1) .xx "find references in a bibliography." "indxbib," "lookbib: build inverted index for a bibliography," "" lookbib(1) .xx "" "apropos: locate commands by keyword" "lookup." "" apropos(1) .xx "" "finger: user information" "lookup program." "" finger(1) .xx "" "break: exit while/foreach" "loop." "" csh(1) .xx "" "continue: cycle in" "loop." "" csh(1) .xx "" "end: terminate" "loop." "" csh(1) .xx "" "foreach:" "loop over list of names." "" csh(1) .xx "" "lo: software" "loopback network interface." "" lo(4) .xx "library." "" "lorder: find ordering relation for an object" "" lorder(1) .xx "" "mklost+found: make a" "lost+found directory for fsck." "" mklost+found(8) .xx "" "" "lp: line printer." "" lp(4) .xx "" "" "lpc: line printer control program." "" lpc(8) .xx "" "" "lpd: line printer daemon." "" lpd(8) .xx "" "" "lpq: spool queue examination program." "" lpq(1) .xx "" "" "lpr: off line print." "" lpr(1) .xx "queue." "" "lprm: remove jobs from the line printer spooling" "" lprm(1) .xx "" "" "lptest: generate lineprinter ripple pattern." "" lptest(1) .xx "" "" "ls: list contents of directory." "" ls(1) .xx "" "" "lseek: move read/write pointer." "" lseek(2) .xx "" "bit: and, or, xor, not, rshift," "lshift bitwise functions." "" bit(3F) .xx "" "stat," "lstat, fstat: get file status." "" stat(2) .xx "" "stat," "lstat, fstat: get file status." "" stat(3F) .xx "" "" "L.sys: UUCP remote host description file." "" L.sys(5) .xx "" "time, ctime," "ltime, gmtime: return system time." "" time(3F) .xx "" "" "lxref: lisp cross reference program." "" lxref(1) .xx "" "" "m4: macro processor." "" m4(1) .xx "" "bk: line discipline for" "machine-machine communication (obsolete)." "" bk(4) .xx "" "ruptime: show host status of local" "machines." "" ruptime(1C) .xx "" "rwho: who's logged in on local" "machines." "" rwho(1C) .xx "" "m4:" "macro processor." "" m4(1) .xx "" "alias: shell" "macros." "" csh(1) .xx "" "toupper, tolower, toascii: character classification" "macros." "/isprint, isgraph, iscntrl, isascii," ctype(3) .xx "" "ms: text formatting" "macros." "" ms(7) .xx "" "me:" "macros for formatting papers." "" me(7) .xx "" "man:" "macros to typeset manual." "" man(7) .xx "msqrt, mcmp, move, min, omin, fmin, m_in, mout,/" "" "madd, msub, mult, mdiv, pow, gcd, invert, rpow," "" mp(3X) .xx "" "tcopy: copy a" "mag tape." "" tcopy(1) .xx "" "mt:" "magnetic tape manipulating program." "" mt(1) .xx "" "ht: TM-03/TE-16,TU-45,TU-77 MASSBUS" "magtape interface." "" ht(4) .xx "" "mt: TM78/TU-78 MASSBUS" "magtape interface." "" mt(4) .xx "" "mtio: UNIX" "magtape interface." "" mtio(4) .xx "" "tm: TM-11/TE-10" "magtape interface." "" tm(4) .xx "" "tmscp: DEC TMSCP" "magtape interface." "" tmscp(4) .xx "" "ts: TS-11" "magtape interface." "" ts(4) .xx "" "rmt: remote" "magtape protocol module." "" rmt(8C) .xx "" "mail: send and receive" "mail." "" mail(1) .xx "" "encode/decode a binary file for transmission via" "mail." "uuencode, uudecode:" uuencode(1C) .xx "" "xsend, xget, enroll: secret" "mail." "" xsend(1) .xx "" "sendbug:" "mail a system bug report to 4bsd-bugs." "" sendbug(1) .xx "" "mailaddr:" "mail addressing description." "" mailaddr(7) .xx "" "newaliases: rebuild the data base for the" "mail aliases file." "" newaliases(1) .xx "" "binmail: send or receive" "mail among users." "" binmail(1) .xx "" "biff: be notified if" "mail arrives and who it is from." "" biff(1) .xx "" "from: who is my" "mail from?." "" from(1) .xx "" "sendmail: send" "mail over the internet." "" sendmail(8) .xx "" "msgs: system messages and junk" "mail program." "" msgs(1) .xx "" "rmail: handle remote" "mail received via uucp." "" rmail(1) .xx "" "" "mail: send and receive mail." "" mail(1) .xx "" "" "mailaddr: mail addressing description." "" mailaddr(7) .xx "" "mem, kmem:" "main memory." "" mem(4) .xx "" "make:" "maintain program groups." "" make(1) .xx "" "ar: archive and library" "maintainer." "" ar(1) .xx "" "intro: introduction to system" "maintenance and operation commands." "" intro(8) .xx "" "mkdir:" "make a directory." "" mkdir(1) .xx "" "mkdir:" "make a directory file." "" mkdir(2) .xx "" "link:" "make a hard link to a file." "" link(2) .xx "" "link:" "make a link to an existing file." "" link(3F) .xx "" "mklost+found:" "make a lost+found directory for fsck." "" mklost+found(8) .xx "" "mknod:" "make a special file." "" mknod(2) .xx "" "mktemp:" "make a unique file name." "" mktemp(3) .xx "" "logger:" "make entries in the system log." "" logger(1) .xx "" "ln:" "make links." "" ln(1) .xx "" "" "make: maintain program groups." "" make(1) .xx "" "symlink:" "make symbolic link to a file." "" symlink(2) .xx "" "makedev:" "make system special files." "" makedev(8) .xx "" "vwidth:" "make troff width table for a font." "" vwidth(1) .xx "" "script:" "make typescript of terminal session." "" script(1) .xx "" "" "makedev: make system special files." "" makedev(8) .xx "" "" "makekey: generate encryption key." "" makekey(8) .xx "" "" "malloc, free, falloc: memory allocator." "" malloc(3F) .xx "allocator." "" "malloc, free, realloc, calloc, alloca: memory" "" malloc(3) .xx "the manual." "" "man: find manual information by keywords; print out" "" man(1) .xx "" "" "man: macros to typeset manual." "" man(7) .xx "" "shift:" "manipulate argument list." "" csh(1) .xx "" "quota:" "manipulate disk quotas." "" quota(2) .xx "" "tp:" "manipulate tape archive." "" tp(1) .xx "" "route: manually" "manipulate the routing tables." "" route(8C) .xx "" "uuq: examine or" "manipulate the uucp queue." "" uuq(1C) .xx "" "mt: magnetic tape" "manipulating program." "" mt(1) .xx "" "inet_lnaof, inet_netof: Internet address" "manipulation routines." "/inet_ntoa, inet_makeaddr," inet(3N) .xx "" "finite, logb, scalb: copysign, remainder, exponent" "manipulations." "copysign, drem," ieee(3M) .xx "" "frexp, ldexp, modf: split into" "mantissa and exponent." "" frexp(3) .xx "" "catman: create the cat files for the" "manual." "" catman(8) .xx "" "find manual information by keywords; print out the" "manual." "man:" man(1) .xx "" "man: macros to typeset" "manual." "" man(7) .xx "" "whereis: locate source, binary, and or" "manual for program." "" whereis(1) .xx "manual." "man: find" "manual information by keywords; print out the" "" man(1) .xx "" "route:" "manually manipulate the routing tables." "" route(8C) .xx "IBM 3270 keys." "" "map3270: database for mapping ascii keystrokes into" "" map3270(5) .xx "" "map3270: database for" "mapping ascii keystrokes into IBM 3270 keys." "" map3270(5) .xx "" "umask: change or display file creation" "mask." "" csh(1) .xx "" "sigsetmask: set current signal" "mask." "" sigsetmask(2) .xx "" "umask: set file creation mode" "mask." "" umask(2) .xx "" "mkstr: create an error message file by" "massaging C source." "" mkstr(1) .xx "" "hp:" "MASSBUS disk interface." "" hp(4) .xx "" "ht: TM-03/TE-16,TU-45,TU-77" "MASSBUS magtape interface." "" ht(4) .xx "" "mt: TM78/TU-78" "MASSBUS magtape interface." "" mt(4) .xx "functions." "" "math: introduction to mathematical library" "" math(3M) .xx "" "math: introduction to" "mathematical library functions." "" math(3M) .xx "" "eqn, neqn, checkeq: typeset" "mathematics." "" eqn(1) .xx "" "getrlimit, setrlimit: control" "maximum system resource consumption." "" getrlimit(2) .xx "" "vlimit: control" "maximum system resource consumption." "" vlimit(3C) .xx "" "de: DEC DEUNA 10" "Mb/s Ethernet interface." "" de(4) .xx "" "ec: 3Com 10" "Mb/s Ethernet interface." "" ec(4) .xx "" "en: Xerox 3" "Mb/s Ethernet interface." "" en(4) .xx "" "ex: Excelan 10" "Mb/s Ethernet interface." "" ex(4) .xx "" "il: Interlan NI1010 10" "Mb/s Ethernet interface." "" il(4) .xx "" "ix: Interlan Np100 10" "Mb/s Ethernet interface." "" ix(4) .xx "" "np: Interlan Np100 10" "Mb/s Ethernet interface." "" np(4) .xx "" "qe: DEC DEQNA Q-bus 10" "Mb/s Ethernet interface." "" qe(4) .xx "" "/msub, mult, mdiv, pow, gcd, invert, rpow, msqrt," "mcmp, move, min, omin, fmin, m_in, mout, omout,/" "" mp(3X) .xx "min, omin, fmin, m_in, mout,/" "madd, msub, mult," "mdiv, pow, gcd, invert, rpow, msqrt, mcmp, move," "" mp(3X) .xx "" "" "me: macros for formatting papers." "" me(7) .xx "" "bcd: convert to antique" "media." "" bcd(6) .xx "" "vv: Proteon proNET 10" "Megabit ring." "" vv(4) .xx "" "" "mem, kmem: main memory." "" mem(4) .xx "" "groups: show group" "memberships." "" groups(1) .xx "" "mem, kmem: main" "memory." "" mem(4) .xx "" "malloc, free, realloc, calloc, alloca:" "memory allocator." "" malloc(3) .xx "" "malloc, free, falloc:" "memory allocator." "" malloc(3F) .xx "" "valloc: aligned" "memory allocator." "" valloc(3C) .xx "" "vfork: spawn new process in a virtual" "memory efficient way." "" vfork(2) .xx "" "core: format of" "memory image file." "" core(5) .xx "" "vmstat: report virtual" "memory statistics." "" vmstat(1) .xx "" "sail: multi-user wooden ships and iron" "men." "" sail(6) .xx "" "sort: sort or" "merge files." "" sort(1) .xx "" "pmerge: pascal file" "merger." "" pmerge(1) .xx "" "" "mesg: permit or deny messages." "" mesg(1) .xx "" "mkstr: create an error" "message file by massaging C source." "" mkstr(1) .xx "" "recv, recvfrom, recvmsg: receive a" "message from a socket." "" recv(2) .xx "" "send, sendto, sendmsg: send a" "message from a socket." "" send(2) .xx "" "mh:" "Message Handler." "" mh(1) .xx "" "icmp: Internet Control" "Message Protocol." "" icmp(4P) .xx "" "error: analyze and disperse compiler error" "messages." "" error(1) .xx "" "mesg: permit or deny" "messages." "" mesg(1) .xx "" "perror, sys_errlist, sys_nerr: system error" "messages." "" perror(3) .xx "" "perror, gerror, ierrno: get system error" "messages." "" perror(3F) .xx "" "psignal, sys_siglist: system signal" "messages." "" psignal(3) .xx "" "syslogd: log systems" "messages." "" syslogd(8) .xx "" "msgs: system" "messages and junk mail program." "" msgs(1) .xx "" "dmesg: collect system diagnostic" "messages to form error log." "" dmesg(8) .xx "" "" "mh: Message Handler." "" mh(1) .xx "" "mille: play" "Mille Bournes." "" mille(6) .xx "" "" "mille: play Mille Bournes." "" mille(6) .xx "" "invert, rpow, msqrt, mcmp, move, min, omin, fmin," "m_in, mout, omout, fmout, m_out, sdiv, itom:/" "/gcd," mp(3X) .xx "" "/mdiv, pow, gcd, invert, rpow, msqrt, mcmp, move," "min, omin, fmin, m_in, mout, omout, fmout, m_out,/" "" mp(3X) .xx "pages." "" "miscellaneous: miscellaneous useful information" "" intro(7) .xx "" "miscellaneous:" "miscellaneous useful information pages." "" intro(7) .xx "" "" "mkdir: make a directory." "" mkdir(1) .xx "" "" "mkdir: make a directory file." "" mkdir(2) .xx "" "" "mkfs: construct a file system." "" mkfs(8) .xx "" "" "mkhosts: generate hashed host table." "" mkhosts(8) .xx "" "" "mklost+found: make a lost+found directory for fsck." "" mklost+found(8) .xx "" "" "mknod: build special file." "" mknod(8) .xx "" "" "mknod: make a special file." "" mknod(2) .xx "" "" "mkpasswd: generate hashed password table." "" mkpasswd(8) .xx "" "" "mkproto: construct a prototype file system." "" mkproto(8) .xx "source." "" "mkstr: create an error message file by massaging C" "" mkstr(1) .xx "" "" "mktemp: make a unique file name." "" mktemp(3) .xx "" "chmod: change" "mode." "" chmod(1) .xx "" "getty: set terminal" "mode." "" getty(8) .xx "" "umask: set file creation" "mode mask." "" umask(2) .xx "" "chmod: change" "mode of a file." "" chmod(3F) .xx "" "chmod: change" "mode of file." "" chmod(2) .xx "" "ddn: DDN Standard" "Mode X.25 IMP interface." "" ddn(4) .xx "" "frexp, ldexp," "modf: split into mantissa and exponent." "" frexp(3) .xx "" "touch: update date last" "modified of a file." "" touch(1) .xx "" "rmt: remote magtape protocol" "module." "" rmt(8C) .xx "" "up: unibus storage" "module controller/drives." "" up(4) .xx "" "what: show what versions of object" "modules were used to construct a file." "" what(1) .xx "" "monitor, monstartup," "moncontrol: prepare execution profile." "" monitor(3) .xx "profile." "" "monitor, monstartup, moncontrol: prepare execution" "" monitor(3) .xx "" "" "monop: Monopoly game." "" monop(6) .xx "" "monop:" "Monopoly game." "" monop(6) .xx "" "monitor," "monstartup, moncontrol: prepare execution profile." "" monitor(3) .xx "" "" "more, page: file perusal filter for crt viewing." "" more(1) .xx "" "curses: screen functions with ``optimal'' cursor" "motion." "" curses(3X) .xx "" "mount, umount:" "mount and dismount file system." "" mount(8) .xx "" "mount, umount:" "mount or remove file system." "" mount(2) .xx "" "" "mount, umount: mount and dismount file system." "" mount(8) .xx "" "" "mount, umount: mount or remove file system." "" mount(2) .xx "" "mtab:" "mounted file system table." "" mtab(5) .xx "" "/rpow, msqrt, mcmp, move, min, omin, fmin, m_in," "mout, omout, fmout, m_out, sdiv, itom: multiple/" "" mp(3X) .xx "" "/move, min, omin, fmin, m_in, mout, omout, fmout," "m_out, sdiv, itom: multiple precision integer/" "" mp(3X) .xx "" "plot: openpl, erase, label, line, circle, arc," "move, cont, point, linemod, space, closepl:/" "" plot(3X) .xx "" "/mult, mdiv, pow, gcd, invert, rpow, msqrt, mcmp," "move, min, omin, fmin, m_in, mout, omout, fmout,/" "" mp(3X) .xx "" "mv:" "move or rename files." "" mv(1) .xx "" "lseek:" "move read/write pointer." "" lseek(2) .xx "" "hk: RK6-11/RK06 and RK07" "moving head disk." "" hk(4) .xx "" "" "ms: text formatting macros." "" ms(7) .xx "" "" "mset: retrieve ASCII to IBM 3270 keyboard map." "" mset(1) .xx "" "" "msgs: system messages and junk mail program." "" msgs(1) .xx "" "madd, msub, mult, mdiv, pow, gcd, invert, rpow," "msqrt, mcmp, move, min, omin, fmin, m_in, mout,/" "" mp(3X) .xx "mcmp, move, min, omin, fmin, m_in, mout,/" "madd," "msub, mult, mdiv, pow, gcd, invert, rpow, msqrt," "" mp(3X) .xx "" "" "mt: magnetic tape manipulating program." "" mt(1) .xx "" "" "mt: TM78/TU-78 MASSBUS magtape interface." "" mt(4) .xx "" "" "mtab: mounted file system table." "" mtab(5) .xx "" "" "mtio: UNIX magtape interface." "" mtio(4) .xx "move, min, omin, fmin, m_in, mout,/" "madd, msub," "mult, mdiv, pow, gcd, invert, rpow, msqrt, mcmp," "" mp(3X) .xx "" "hunt: a" "multi-player multi-terminal game." "" hunt(6) .xx "" "fmin, m_in, mout, omout, fmout, m_out, sdiv, itom:" "multiple precision integer arithmetic." "/min, omin," mp(3X) .xx "" "dh: DH-11/DM-11 communications" "multiplexer." "" dh(4) .xx "" "dhu: DHU-11 communications" "multiplexer." "" dhu(4) .xx "" "dz: DZ-11 communications" "multiplexer." "" dz(4) .xx "" "select: synchronous I/O" "multiplexing." "" select(2) .xx "" "dmf: DMF-32, terminal" "multiplexor." "" dmf(4) .xx "" "dmz: DMZ-32 terminal" "multiplexor." "" dmz(4) .xx "" "fsplit: split a" "multi-routine Fortran file into individual files." "" fsplit(1) .xx "" "hunt: a multi-player" "multi-terminal game." "" hunt(6) .xx "" "sail:" "multi-user wooden ships and iron men." "" sail(6) .xx "" "switch:" "multi-way command branch." "" csh(1) .xx "" "" "mv: move or rename files." "" mv(1) .xx "" "from: who is" "my mail from?." "" from(1) .xx "" "getdiskbyname: get disk description by its" "name." "" getdisk(3) .xx "" "getenv: value for environment" "name." "" getenv(3) .xx "" "getlog: get user's login" "name." "" getlog(3F) .xx "" "getlogin: get login" "name." "" getlogin(3) .xx "" "getsockname: get socket" "name." "" getsockname(2) .xx "" "mktemp: make a unique file" "name." "" mktemp(3) .xx "" "pwd: working directory" "name." "" pwd(1) .xx "" "tty: get terminal" "name." "" tty(1) .xx "" "hosts: host" "name data base." "" hosts(5) .xx "" "networks: network" "name data base." "" networks(5) .xx "" "protocols: protocol" "name data base." "" protocols(5) .xx "" "services: service" "name data base." "" services(5) .xx "" "whois: DARPA Internet user" "name directory service." "" whois(1) .xx "" "getpw: get" "name from uid." "" getpw(3C) .xx "" "nlist: get entries from" "name list." "" nlist(3) .xx "" "nm: print" "name list." "" nm(1) .xx "" "symorder: rearrange" "name list." "" symorder(1) .xx "" "rename: change the" "name of a file." "" rename(2) .xx "" "ttyname, isatty, ttyslot: find" "name of a terminal." "" ttyname(3) .xx "" "ttynam, isatty: find" "name of a terminal port." "" ttynam(3F) .xx "" "getpeername: get" "name of connected peer." "" getpeername(2) .xx "" "gethostname, sethostname: get/set" "name of current host." "" gethostname(2) .xx "" "hostnm: get" "name of current host." "" hostnm(3F) .xx "" "hostname: set or print" "name of current host system." "" hostname(1) .xx "" "named: Internet domain" "name server." "" named(8) .xx "" "bind: bind a" "name to a socket." "" bind(2) .xx "" "" "named: Internet domain name server." "" named(8) .xx "" "foreach: loop over list of" "names." "" csh(1) .xx "" "term: conventional" "names for terminals." "" term(7) .xx "" "ncheck: generate" "names from i-numbers." "" ncheck(8) .xx "" "uuname: list" "names of UUCP hosts." "" uuname(1C) .xx "" "" "ncheck: generate names from i-numbers." "" ncheck(8) .xx "" "eqn," "neqn, checkeq: typeset mathematics." "" eqn(1) .xx "" "" "netstat: show network status." "" netstat(1) .xx "" "rdump: file system dump across the" "network." "" rdump(8C) .xx "" "rrestore: restore a file system dump across the" "network." "" rrestore(8C) .xx "" "ntohl, ntohs: convert values between host and" "network byte order." "htonl, htons," byteorder(3N) .xx "" "getnetbyname, setnetent, endnetent: get" "network entry." "getnetent, getnetbyaddr," getnetent(3N) .xx "" "gethostent, sethostent, endhostent: get" "network host entry." "gethostbyname, gethostbyaddr," gethostbyname(3N) .xx "" "ping: send ICMP ECHO_REQUEST packets to" "network hosts." "" ping(8) .xx "" "imp: 1822" "network interface." "" imp(4) .xx "" "lo: software loopback" "network interface." "" lo(4) .xx "" "pcl: DEC CSS PCL-11 B" "Network Interface." "" pcl(4) .xx "packets.." "nsip: software" "network interface encapsulating ns packets in ip" "" nsip(4) .xx "" "ifconfig: configure" "network interface parameters." "" ifconfig(8C) .xx "" "slattach: attach serial lines as" "network interfaces." "" slattach(8C) .xx "" "networks:" "network name data base." "" networks(5) .xx "" "routed:" "network routing daemon." "" routed(8C) .xx "" "netstat: show" "network status." "" netstat(1) .xx "" "hy:" "Network Systems Hyperchannel interface." "" hy(4) .xx "" "ns: Xerox" "Network Systems(tm) protocol family." "" ns(4F) .xx "" "networking: introduction to" "networking facilities." "" intro(4N) .xx "" "" "networking: introduction to networking facilities." "" intro(4N) .xx "" "" "networks: network name data base." "" networks(5) .xx "" "creat: create a" "new file." "" creat(2) .xx "" "open a file for reading or writing, or create a" "new file." "open:" open(2) .xx "" "newfs: construct a" "new file system." "" newfs(8) .xx "" "fork: create a" "new process." "" fork(2) .xx "" "vfork: spawn" "new process in a virtual memory efficient way." "" vfork(2) .xx "" "login: login" "new user." "" csh(1) .xx "" "adduser: procedure for adding" "new users." "" adduser(8) .xx "aliases file." "" "newaliases: rebuild the data base for the mail" "" newaliases(1) .xx "" "" "newfs: construct a new file system." "" newfs(8) .xx "" "readnews: read" "news articles." "" readnews(1) .xx "" "vnews: read" "news articles." "" vnews(1) .xx "" "notes, autoseq, readnotes: a" "news system." "" notes(1) .xx "" "dbminit, fetch, store, delete, firstkey," "nextkey: data base subroutines." "" dbm(3X) .xx "" "il: Interlan" "NI1010 10 Mb/s Ethernet interface." "" il(4) .xx "" "gettable: get" "NIC format host tables from a host." "" gettable(8C) .xx "" "htable: convert" "NIC standard format host tables." "" htable(8) .xx "" "vgrind: grind" "nice listings of programs." "" vgrind(1) .xx "(\fIsh\fR only)." "" "nice, nohup: run a command at low priority" "" nice(1) .xx "" "" "nice: run low priority process." "" csh(1) .xx "" "" "nice: set program priority." "" nice(3C) .xx "" "" "nlist: get entries from name list." "" nlist(3) .xx "" "" "nm: print name list." "" nm(1) .xx "only)." "nice," "nohup: run a command at low priority (\fIsh\fR" "" nice(1) .xx "" "" "nohup: run command immune to hangups." "" csh(1) .xx "" "setjmp, longjmp:" "non-local goto." "" setjmp(3) .xx "" "bit: and, or, xor," "not, rshift, lshift bitwise functions." "" bit(3F) .xx "" "" "notes, autoseq, readnotes: a news system." "" notes(1) .xx "" "notify: request immediate" "notification." "" csh(1) .xx "" "biff: be" "notified if mail arrives and who it is from." "" biff(1) .xx "" "" "notify: request immediate notification." "" csh(1) .xx "" "" "np: Interlan Np100 10 Mb/s Ethernet interface." "" np(4) .xx "" "ix: Interlan" "Np100 10 Mb/s Ethernet interface." "" ix(4) .xx "" "np: Interlan" "Np100 10 Mb/s Ethernet interface." "" np(4) .xx "" "soelim: eliminate \&.so's from" "nroff input." "" soelim(1) .xx "" "tbl: format tables for" "nroff or troff." "" tbl(1) .xx "" "colcrt: filter" "nroff output for CRT previewing." "" colcrt(1) .xx "" "" "nroff: text formatting." "" nroff(1) .xx "" "troff," "nroff: text formatting and typesetting." "" troff(1) .xx "" "deroff: remove" "nroff, troff, tbl and eqn constructs." "" deroff(1) .xx "" "vlp: Format Lisp programs to be printed with" "nroff, vtroff, or troff." "" vlp(1) .xx "" "checknr: check" "nroff/troff files." "" checknr(1) .xx "" "nsip: software network interface encapsulating" "ns packets in ip packets.." "" nsip(4) .xx "" "XNSrouted:" "NS Routing Information Protocol daemon." "" XNSrouted(8C) .xx "" "" "ns: Xerox Network Systems(tm) protocol family." "" ns(4F) .xx "routines." "" "ns_addr, ns_ntoa: Xerox NS(tm) address conversion" "" ns(3N) .xx "packets in ip packets.." "" "nsip: software network interface encapsulating ns" "" nsip(4) .xx "" "ns_addr," "ns_ntoa: Xerox NS(tm) address conversion routines." "" ns(3N) .xx "" "ns_addr, ns_ntoa: Xerox" "NS(tm) address conversion routines." "" ns(3N) .xx "network byte order." "htonl, htons," "ntohl, ntohs: convert values between host and" "" byteorder(3N) .xx "order." "htonl, htons, ntohl," "ntohs: convert values between host and network byte" "" byteorder(3N) .xx "" "" "null: data sink." "" null(4) .xx "" "" "number: convert Arabic numerals to English." "" number(6) .xx "" "phones: remote host phone" "number data base." "" phones(5) .xx "" "arithmetic: provide drill in" "number facts." "" arithmetic(6) .xx "" "rand, srand: random" "number generator." "" rand(3C) .xx "" "random, drandm, irandm: better random" "number generator." "" random(3F) .xx "" "random, srandom, initstate, setstate: better random" "number generator; routines for changing generators." "" random(3) .xx "" "L-dialcodes: UUCP phone" "number index file." "" L-dialcodes(5) .xx "" "atof, atoi, atol: convert ASCII to" "numbers." "" atof(3) .xx "" "intro: introduction to system calls and error" "numbers." "" intro(2) .xx "" "number: convert Arabic" "numerals to English." "" number(6) .xx "" "idate, itime: return date or time in" "numerical form." "" idate(3F) .xx "" "loc: return the address of an" "object." "" loc(3F) .xx "" "long, short: integer" "object conversion." "" long(3F) .xx "" "size: size of an" "object file." "" size(1) .xx "" "lorder: find ordering relation for an" "object library." "" lorder(1) .xx "" "what: show what versions of" "object modules were used to construct a file." "" what(1) .xx "" "strings: find the printable strings in a" "object, or other binary, file." "" strings(1) .xx "" "index, rindex, lnblnk, len: tell about character" "objects." "" index(3F) .xx "" "line discipline for machine-machine communication" "(obsolete)." "bk:" bk(4) .xx "" "od:" "octal, decimal, hex, ascii dump." "" od(1) .xx "" "" "od: octal, decimal, hex, ascii dump." "" od(1) .xx "" "/pow, gcd, invert, rpow, msqrt, mcmp, move, min," "omin, fmin, m_in, mout, omout, fmout, m_out, sdiv,/" "" mp(3X) .xx "" "/msqrt, mcmp, move, min, omin, fmin, m_in, mout," "omout, fmout, m_out, sdiv, itom: multiple precision/" "" mp(3X) .xx "" "" "onintr: process interrupts in command scripts." "" csh(1) .xx "" "nohup: run a command at low priority (\fIsh\fR" "only)." "nice," nice(1) .xx "" "program file including aliases and paths (\fIcsh\fR" "only)." "which: locate a" which(1) .xx "file." "open:" "open a file for reading or writing, or create a new" "" open(2) .xx "" "fopen, freopen, fdopen:" "open a stream." "" fopen(3S) .xx "" "flock: apply or remove an advisory lock on an" "open file." "" flock(2) .xx "a new file." "" "open: open a file for reading or writing, or create" "" open(2) .xx "closedir: directory operations." "" "opendir, readdir, telldir, seekdir, rewinddir," "" directory(3) .xx "" "syslog," "openlog, closelog, setlogmask: control system log." "" syslog(3) .xx "cont, point, linemod, space, closepl:/" "plot:" "openpl, erase, label, line, circle, arc, move," "" plot(3X) .xx "(3X) libraries.." "plot:" "openpl et al.: f77 library interface to \fIplot\fR" "" plot(3F) .xx "" "savecore: save a core dump of the" "operating system." "" savecore(8) .xx "" "kgmon: generate a dump of the" "operating system's profile buffers." "" kgmon(8) .xx "" "intro: introduction to system maintenance and" "operation commands." "" intro(8) .xx "" "tgetstr, tgoto, tputs: terminal independent" "operation routines." "tgetent, tgetnum, tgetflag," termcap(3X) .xx "" "bcopy, bcmp, bzero, ffs: bit and byte string" "operations." "" bstring(3) .xx "" "telldir, seekdir, rewinddir, closedir: directory" "operations." "opendir, readdir," directory(3) .xx "" "strcpy, strncpy, strlen, index, rindex: string" "operations." "strcat, strncat, strcmp, strncmp," string(3) .xx "" "infnan: signals invalid floating-point" "operations on a VAX (temporary)." "" infnan(3M) .xx "" "join: relational database" "operator." "" join(1) .xx "" "curses: screen functions with" "``optimal'' cursor motion." "" curses(3X) .xx "" "getopt: get" "option letter from argv." "" getopt(3) .xx "" "stty: set terminal" "options." "" stty(1) .xx "" "getsockopt, setsockopt: get and set" "options on sockets." "" getsockopt(2) .xx "" "ntohs: convert values between host and network byte" "order." "htonl, htons, ntohl," byteorder(3N) .xx "" "lastcomm: show last commands executed in reverse" "order." "" lastcomm(1) .xx "" "lorder: find" "ordering relation for an object library." "" lorder(1) .xx "" "bessel functions: of two kinds for integer" "orders." "" bessel(3F) .xx "" "vi: screen" "oriented (visual) display editor based on ex." "" vi(1) .xx "" "patch: a program for applying a diff file to an" "original." "" patch(1) .xx "" "a.out: assembler and link editor" "output." "" a.out(5) .xx "" "terminate a process after flushing any pending" "output." "exit:" exit(3) .xx "" "write, writev: write" "output." "" write(2) .xx "" "ecvt, fcvt, gcvt:" "output conversion." "" ecvt(3) .xx "" "printf, fprintf, sprintf: formatted" "output conversion." "" printf(3S) .xx "" "fold: fold long lines for finite width" "output device." "" fold(1) .xx "" "colcrt: filter nroff" "output for CRT previewing." "" colcrt(1) .xx "" "flush: flush" "output to a logical unit." "" flush(3F) .xx "" "foreach: loop" "over list of names." "" csh(1) .xx "" "sendmail: send mail" "over the internet." "" sendmail(8) .xx "" "trapov: trap and repair floating point" "overflow." "" trapov(3F) .xx "" "exec:" "overlay shell with specified command." "" csh(1) .xx "" "chown: change" "owner." "" chown(8) .xx "" "chown: change" "owner and group of a file." "" chown(2) .xx "" "quot: summarize file system" "ownership." "" quot(8) .xx "" "" "pac: printer/plotter accounting information." "" pac(8) .xx "" "spp: Xerox Sequenced" "Packet Protocol." "" spp(4P) .xx "" "trsp: transliterate sequenced" "packet protocol trace." "" trsp(8C) .xx "" "network interface encapsulating ns packets in ip" "packets.." "nsip: software" nsip(4) .xx "" "nsip: software network interface encapsulating ns" "packets in ip packets.." "" nsip(4) .xx "" "ping: send ICMP ECHO_REQUEST" "packets to network hosts." "" ping(8) .xx "" "format: how to format disk" "packs." "" format(8V) .xx "" "more," "page: file perusal filter for crt viewing." "" more(1) .xx "" "getpagesize: get system" "page size." "" getpagesize(2) .xx "" "pagesize: print system" "page size." "" pagesize(1) .xx "" "miscellaneous: miscellaneous useful information" "pages." "" intro(7) .xx "" "" "pagesize: print system page size." "" pagesize(1) .xx "" "tk:" "paginator for the Tektronix 4014." "" tk(1) .xx "" "swapon: specify additional device for" "paging and swapping." "" swapon(8) .xx "" "drum:" "paging device." "" drum(4) .xx "" "swapon: add a swap device for interleaved" "paging/swapping." "" swapon(2) .xx "" "socketpair: create a" "pair of connected sockets." "" socketpair(2) .xx "" "me: macros for formatting" "papers." "" me(7) .xx "" "ifconfig: configure network interface" "parameters." "" ifconfig(8C) .xx "" "diskpart: calculate default disk" "partition sizes." "" diskpart(8) .xx "" "pc:" "Pascal compiler." "" pc(1) .xx "" "pxref:" "Pascal cross-reference program." "" pxref(1) .xx "" "pdx:" "pascal debugger." "" pdx(1) .xx "" "pxp:" "Pascal execution profiler." "" pxp(1) .xx "" "pmerge:" "pascal file merger." "" pmerge(1) .xx "" "px:" "Pascal interpreter." "" px(1) .xx "" "pix:" "Pascal interpreter and executor." "" pix(1) .xx "" "pi:" "Pascal interpreter code translator." "" pi(1) .xx "" "chfn, chsh," "passwd: change password file information." "" chfn(1) .xx "" "chfn, chsh," "passwd: change password file information." "" chsh(1) .xx "" "chfn, chsh," "passwd: change password file information." "" passwd(1) .xx "" "" "passwd: password file." "" passwd(5) .xx "" "getpass: read a" "password." "" getpass(3) .xx "" "passwd:" "password file." "" passwd(5) .xx "" "vipw: edit the" "password file." "" vipw(8) .xx "" "getpwnam, setpwent, endpwent, setpwfile: get" "password file entry." "getpwent, getpwuid," getpwent(3) .xx "" "chfn, chsh, passwd: change" "password file information." "" chfn(1) .xx "" "chfn, chsh, passwd: change" "password file information." "" chsh(1) .xx "" "chfn, chsh, passwd: change" "password file information." "" passwd(1) .xx "" "mkpasswd: generate hashed" "password table." "" mkpasswd(8) .xx "original." "" "patch: a program for applying a diff file to an" "" patch(1) .xx "" "getwd: get current working directory" "pathname." "" getwd(3) .xx "" "getcwd: get" "pathname of current working directory." "" getcwd(3F) .xx "" "USERFILE: UUCP" "pathname permissions file." "" USERFILE(5) .xx "" "which: locate a program file including aliases and" "paths (\fIcsh\fR only)." "" which(1) .xx "" "grep, egrep, fgrep: search a file for a" "pattern." "" grep(1) .xx "" "lptest: generate lineprinter ripple" "pattern." "" lptest(1) .xx "" "awk:" "pattern scanning and processing language." "" awk(1) .xx "" "" "pause: stop until signal." "" pause(3C) .xx "" "" "pc: Pascal compiler." "" pc(1) .xx "" "" "pcl: DEC CSS PCL-11 B Network Interface." "" pcl(4) .xx "" "pcl: DEC CSS" "PCL-11 B Network Interface." "" pcl(4) .xx "" "popen," "pclose: initiate I/O to/from a process." "" popen(3) .xx "" "" "pdx: pascal debugger." "" pdx(1) .xx "" "getpeername: get name of connected" "peer." "" getpeername(2) .xx "" "exit: terminate a process after flushing any" "pending output." "" exit(3) .xx "" "L.cmds: UUCP remote command" "permissions file." "" L.cmds(5) .xx "" "USERFILE: UUCP pathname" "permissions file." "" USERFILE(5) .xx "" "mesg:" "permit or deny messages." "" mesg(1) .xx "" "ptx:" "permuted index." "" ptx(1) .xx "" "limit: alter" "per-process resource limitations." "" csh(1) .xx "" "" "perror, gerror, ierrno: get system error messages." "" perror(3F) .xx "messages." "" "perror, sys_errlist, sys_nerr: system error" "" perror(3) .xx "" "sticky:" "persistent text and append-only directories." "" sticky(8) .xx "" "more, page: file" "perusal filter for crt viewing." "" more(1) .xx "" "phones: remote host" "phone number data base." "" phones(5) .xx "" "L-dialcodes: UUCP" "phone number index file." "" L-dialcodes(5) .xx "" "" "phones: remote host phone number data base." "" phones(5) .xx "" "ct:" "phototypesetter interface." "" ct(4) .xx "" "tc:" "photoypesetter simulator." "" tc(1) .xx "" "" "pi: Pascal interpreter code translator." "" pi(1) .xx "" "ps: Evans and Sutherland" "Picture System 2 graphics device interface." "" ps(4) .xx "hosts." "" "ping: send ICMP ECHO_REQUEST packets to network" "" ping(8) .xx "" "" "pipe: create an interprocess communication channel." "" pipe(2) .xx "" "tee:" "pipe fitting." "" tee(1) .xx "" "" "pix: Pascal interpreter and executor." "" pix(1) .xx "" "bg:" "place job in background." "" csh(1) .xx "" "fish:" "play ``Go Fish''." "" fish(6) .xx "" "mille:" "play Mille Bournes." "" mille(6) .xx "" "boggle:" "play the game of boggle." "" boggle(6) .xx "" "worm:" "Play the growing worm game." "" worm(6) .xx "" "" "plot: graphics filters." "" plot(1G) .xx "" "" "plot: graphics interface." "" plot(5) .xx "move, cont, point, linemod, space, closepl:/" "" "plot: openpl, erase, label, line, circle, arc," "" plot(3X) .xx "\fIplot\fR (3X) libraries.." "" "plot: openpl et al.: f77 library interface to" "" plot(3F) .xx "" "" "pmerge: pascal file merger." "" pmerge(1) .xx "" "trpfpe, fpecnt: trap and repair floating" "point faults." "" trpfpe(3F) .xx "" "/erase, label, line, circle, arc, move, cont," "point, linemod, space, closepl: graphics interface." "" plot(3X) .xx "" "trapov: trap and repair floating" "point overflow." "" trapov(3F) .xx "" "lseek: move read/write" "pointer." "" lseek(2) .xx "" "dmc: DEC DMC-11/DMR-11" "point-to-point communications device." "" dmc(4) .xx "" "uupoll:" "poll a remote UUCP site." "" uupoll(8C) .xx "" "popd:" "pop shell directory stack." "" csh(1) .xx "" "" "popd: pop shell directory stack." "" csh(1) .xx "" "" "popen, pclose: initiate I/O to/from a process." "" popen(3) .xx "" "ttynam, isatty: find name of a terminal" "port." "" ttynam(3F) .xx "" "exp, expm1, log, log10, log1p," "pow: exponential, logarithm, power." "" exp(3M) .xx "omin, fmin, m_in, mout,/" "madd, msub, mult, mdiv," "pow, gcd, invert, rpow, msqrt, mcmp, move, min," "" mp(3X) .xx "" "log, log10, log1p, pow: exponential, logarithm," "power." "exp, expm1," exp(3M) .xx "" "" "pr: print file." "" pr(1) .xx "" "mout, omout, fmout, m_out, sdiv, itom: multiple" "precision integer arithmetic." "/omin, fmin, m_in," mp(3X) .xx "" "monitor, monstartup, moncontrol:" "prepare execution profile." "" monitor(3) .xx "" "colcrt: filter nroff output for CRT" "previewing." "" colcrt(1) .xx "" "types:" "primitive system data types." "" types(5) .xx "" "cat: catenate and" "print." "" cat(1) .xx "" "lpr: off line" "print." "" lpr(1) .xx "" "fortune:" "print a random, hopefully interesting, adage." "" fortune(6) .xx "" "date:" "print and set the date." "" date(1) .xx "" "cal:" "print calendar." "" cal(1) .xx "" "hashstat:" "print command hashing statistics." "" csh(1) .xx "" "jobs:" "print current job list." "" csh(1) .xx "" "whoami:" "print effective current user id." "" whoami(1) .xx "" "pr:" "print file." "" pr(1) .xx "" "fpr:" "print Fortran file." "" fpr(1) .xx "" "history:" "print history event list." "" csh(1) .xx "" "hostid: set or" "print identifier of current host system." "" hostid(1) .xx "" "banner:" "print large banner on printer." "" banner(6) .xx "" "nm:" "print name list." "" nm(1) .xx "" "hostname: set or" "print name of current host system." "" hostname(1) .xx "" "printenv:" "print out the environment." "" printenv(1) .xx "" "man: find manual information by keywords;" "print out the manual." "" man(1) .xx "" "pstat:" "print system facts." "" pstat(8) .xx "" "pagesize:" "print system page size." "" pagesize(1) .xx "" "atq:" "print the queue of jobs waiting to be run." "" atq(1) .xx "" "diction, explain:" "print wordy sentences; thesaurus for diction." "" diction(1) .xx "file." "strings: find the" "printable strings in a object, or other binary," "" strings(1) .xx "" "" "printcap: printer capability data base." "" printcap(5) .xx "" "vlp: Format Lisp programs to be" "printed with nroff, vtroff, or troff." "" vlp(1) .xx "" "" "printenv: print out the environment." "" printenv(1) .xx "" "banner: print large banner on" "printer." "" banner(6) .xx "" "lp: line" "printer." "" lp(4) .xx "" "printcap:" "printer capability data base." "" printcap(5) .xx "" "lpc: line" "printer control program." "" lpc(8) .xx "" "lpd: line" "printer daemon." "" lpd(8) .xx "" "lprm: remove jobs from the line" "printer spooling queue." "" lprm(1) .xx "" "pac:" "printer/plotter accounting information." "" pac(8) .xx "conversion." "" "printf, fprintf, sprintf: formatted output" "" printf(3S) .xx "" "setpriority: get/set program scheduling" "priority." "getpriority," getpriority(2) .xx "" "nice: set program" "priority." "" nice(3C) .xx "" "nice, nohup: run a command at low" "priority (\fIsh\fR only)." "" nice(1) .xx "" "renice: alter" "priority of running processes." "" renice(8) .xx "" "nice: run low" "priority process." "" csh(1) .xx "" "adduser:" "procedure for adding new users." "" adduser(8) .xx "" "reboot: UNIX bootstrapping" "procedures." "" reboot(8) .xx "" "nice: run low priority" "process." "" csh(1) .xx "" "stop: halt a job or" "process." "" csh(1) .xx "" "_exit: terminate a" "process." "" exit(2) .xx "" "fork: create a new" "process." "" fork(2) .xx "" "fork: create a copy of this" "process." "" fork(3F) .xx "" "implogd: IMP logger" "process." "" implogd(8C) .xx "" "kill: send signal to a" "process." "" kill(2) .xx "" "kill: send a signal to a" "process." "" kill(3F) .xx "" "popen, pclose: initiate I/O to/from a" "process." "" popen(3) .xx "" "wait: await completion of" "process." "" wait(1) .xx "" "exit: terminate a" "process after flushing any pending output." "" exit(3) .xx "" "init:" "process control initialization." "" init(8) .xx "" "getpgrp: get" "process group." "" getpgrp(2) .xx "" "killpg: send signal to a" "process group." "" killpg(2) .xx "" "setpgrp: set" "process group." "" setpgrp(2) .xx "" "getpid: get" "process id." "" getpid(3F) .xx "" "getpid, getppid: get" "process identification." "" getpid(2) .xx "" "vfork: spawn new" "process in a virtual memory efficient way." "" vfork(2) .xx "" "onintr:" "process interrupts in command scripts." "" csh(1) .xx "" "ps:" "process status." "" ps(1) .xx "" "times: get" "process times." "" times(3C) .xx "" "wait, wait3: wait for" "process to terminate." "" wait(2) .xx "" "wait: wait for a" "process to terminate." "" wait(3F) .xx "" "ptrace:" "process trace." "" ptrace(2) .xx "" "kill: terminate a" "process with extreme prejudice." "" kill(1) .xx "" "exit: terminate" "process with status." "" exit(3F) .xx "" "kill: kill jobs and" "processes." "" csh(1) .xx "" "gcore: get core images of running" "processes." "" gcore(1) .xx "" "renice: alter priority of running" "processes." "" renice(8) .xx "" "wait: wait for background" "processes to complete." "" csh(1) .xx "" "awk: pattern scanning and" "processing language." "" awk(1) .xx "" "halt: stop the" "processor." "" halt(8) .xx "" "m4: macro" "processor." "" m4(1) .xx "" "reboot: reboot system or halt" "processor." "" reboot(2) .xx "" "" "prof: display profile data." "" prof(1) .xx "" "" "profil: execution time profile." "" profil(2) .xx "" "monitor, monstartup, moncontrol: prepare execution" "profile." "" monitor(3) .xx "" "profil: execution time" "profile." "" profil(2) .xx "" "kgmon: generate a dump of the operating system's" "profile buffers." "" kgmon(8) .xx "" "gprof: display call graph" "profile data." "" gprof(1) .xx "" "prof: display" "profile data." "" prof(1) .xx "" "pxp: Pascal execution" "profiler." "" pxp(1) .xx "" "drtest: standalone disk test" "program." "" drtest(8) .xx "" "end, etext, edata: last locations in" "program." "" end(3) .xx "" "finger: user information lookup" "program." "" finger(1) .xx "" "ftp: ARPANET file transfer" "program." "" ftp(1C) .xx "" "liszt: compile a Franz Lisp" "program." "" liszt(1) .xx "" "lpc: line printer control" "program." "" lpc(8) .xx "" "lpq: spool queue examination" "program." "" lpq(1) .xx "" "lxref: lisp cross reference" "program." "" lxref(1) .xx "" "msgs: system messages and junk mail" "program." "" msgs(1) .xx "" "mt: magnetic tape manipulating" "program." "" mt(1) .xx "" "pxref: Pascal cross-reference" "program." "" pxref(1) .xx "" "rdist: remote file distribution" "program." "" rdist(1) .xx "" "tftp: trivial file transfer" "program." "" tftp(1C) .xx "" "timedc: timed control" "program." "" timedc(8) .xx "" "units: conversion" "program." "" units(1) .xx "" "whereis: locate source, binary, and or manual for" "program." "" whereis(1) .xx "" "cb: C" "program beautifier." "" cb(1) .xx "only)." "which: locate a" "program file including aliases and paths (\fIcsh\fR" "" which(1) .xx "" "patch: a" "program for applying a diff file to an original." "" patch(1) .xx "" "make: maintain" "program groups." "" make(1) .xx "" "nice: set" "program priority." "" nice(3C) .xx "" "getpriority, setpriority: get/set" "program scheduling priority." "" getpriority(2) .xx "" "indent: indent and format C" "program source." "" indent(1) .xx "" "assert:" "program verification." "" assert(3) .xx "" "lint: a C" "program verifier." "" lint(1) .xx "" "fp: Functional" "Programming language compiler/interpreter." "" fp(1) .xx "" "lex: generator of lexical analysis" "programs." "" lex(1) .xx "" "struct: structure Fortran" "programs." "" struct(1) .xx "" "vgrind: grind nice listings of" "programs." "" vgrind(1) .xx "troff." "vlp: Format Lisp" "programs to be printed with nroff, vtroff, or" "" vlp(1) .xx "" "xstr: extract strings from C" "programs to implement shared strings." "" xstr(1) .xx "" "vv: Proteon" "proNET 10 Megabit ring." "" vv(4) .xx "" "vv:" "Proteon proNET 10 Megabit ring." "" vv(4) .xx "" "arp: Address Resolution" "Protocol." "" arp(4P) .xx "" "icmp: Internet Control Message" "Protocol." "" icmp(4P) .xx "" "idp: Xerox Internet Datagram" "Protocol." "" idp(4P) .xx "" "ip: Internet" "Protocol." "" ip(4P) .xx "" "spp: Xerox Sequenced Packet" "Protocol." "" spp(4P) .xx "" "tcp: Internet Transmission Control" "Protocol." "" tcp(4P) .xx "" "telnet: user interface to the TELNET" "protocol." "" telnet(1C) .xx "" "udp: Internet User Datagram" "Protocol." "" udp(4P) .xx "" "XNSrouted: NS Routing Information" "Protocol daemon." "" XNSrouted(8C) .xx "" "getprotobyname, setprotoent, endprotoent: get" "protocol entry." "getprotoent, getprotobynumber," getprotoent(3N) .xx "" "inet: Internet" "protocol family." "" inet(4F) .xx "" "ns: Xerox Network Systems(tm)" "protocol family." "" ns(4F) .xx "" "rmt: remote magtape" "protocol module." "" rmt(8C) .xx "" "protocols:" "protocol name data base." "" protocols(5) .xx "" "ftpd: DARPA Internet File Transfer" "Protocol server." "" ftpd(8C) .xx "" "telnetd: DARPA TELNET" "protocol server." "" telnetd(8C) .xx "" "tftpd: DARPA Trivial File Transfer" "Protocol server." "" tftpd(8C) .xx "" "trpt: transliterate" "protocol trace." "" trpt(8C) .xx "" "trsp: transliterate sequenced packet" "protocol trace." "" trsp(8C) .xx "" "" "protocols: protocol name data base." "" protocols(5) .xx "" "mkproto: construct a" "prototype file system." "" mkproto(8) .xx "" "arithmetic:" "provide drill in number facts." "" arithmetic(6) .xx "" "false, true:" "provide truth values." "" false(1) .xx "" "true, false:" "provide truth values." "" true(1) .xx "device interface." "" "ps: Evans and Sutherland Picture System 2 graphics" "" ps(4) .xx "" "" "ps: process status." "" ps(1) .xx "" "pty:" "pseudo terminal driver." "" pty(4) .xx "" "" "psignal, sys_siglist: system signal messages." "" psignal(3) .xx "" "" "pstat: print system facts." "" pstat(8) .xx "" "doctor: interact with a" "psychoanalyst." "" doctor(6) .xx "" "" "ptrace: process trace." "" ptrace(2) .xx "" "" "ptx: permuted index." "" ptx(1) .xx "" "" "pty: pseudo terminal driver." "" pty(4) .xx "" "ungetc:" "push character back into input stream." "" ungetc(3S) .xx "" "pushd:" "push shell directory stack." "" csh(1) .xx "" "" "pushd: push shell directory stack." "" csh(1) .xx "" "puts, fputs:" "put a string on a stream." "" puts(3S) .xx "" "putc, putchar, fputc, putw:" "put character or word on a stream." "" putc(3S) .xx "unit." "" "putc, fputc: write a character to a fortran logical" "" putc(3F) .xx "on a stream." "" "putc, putchar, fputc, putw: put character or word" "" putc(3S) .xx "stream." "putc," "putchar, fputc, putw: put character or word on a" "" putc(3S) .xx "" "" "puts, fputs: put a string on a stream." "" puts(3S) .xx "" "putc, putchar, fputc," "putw: put character or word on a stream." "" putc(3S) .xx "" "" "pwd: working directory name." "" pwd(1) .xx "" "" "px: Pascal interpreter." "" px(1) .xx "" "" "pxp: Pascal execution profiler." "" pxp(1) .xx "" "" "pxref: Pascal cross-reference program." "" pxref(1) .xx "" "qe: DEC DEQNA" "Q-bus 10 Mb/s Ethernet interface." "" qe(4) .xx "" "" "qe: DEC DEQNA Q-bus 10 Mb/s Ethernet interface." "" qe(4) .xx "" "" "qsort: quick sort." "" qsort(3F) .xx "" "" "qsort: quicker sort." "" qsort(3) .xx "" "insque, remque: insert/remove element from a" "queue." "" insque(3) .xx "" "lprm: remove jobs from the line printer spooling" "queue." "" lprm(1) .xx "" "uuq: examine or manipulate the uucp" "queue." "" uuq(1C) .xx "" "lpq: spool" "queue examination program." "" lpq(1) .xx "" "atq: print the" "queue of jobs waiting to be run." "" atq(1) .xx "" "uucico, uucpd: transfer files" "queued by uucp or uux." "" uucico(8C) .xx "" "qsort:" "quick sort." "" qsort(3F) .xx "" "qsort:" "quicker sort." "" qsort(3) .xx "" "" "quiz: test your knowledge." "" quiz(6) .xx "" "" "quot: summarize file system ownership." "" quot(8) .xx "" "quotacheck: file system" "quota consistency checker." "" quotacheck(8) .xx "" "" "quota: display disc usage and limits." "" quota(1) .xx "" "" "quota: manipulate disk quotas." "" quota(2) .xx "" "" "quotacheck: file system quota consistency checker." "" quotacheck(8) .xx "" "quotaon," "quotaoff: turn file system quotas on and off." "" quotaon(8) .xx "off." "" "quotaon, quotaoff: turn file system quotas on and" "" quotaon(8) .xx "" "edquota: edit user" "quotas." "" edquota(8) .xx "" "quota: manipulate disk" "quotas." "" quota(2) .xx "" "repquota: summarize" "quotas for a file system." "" repquota(8) .xx "" "setquota: enable/disable" "quotas on a file system." "" setquota(2) .xx "" "quotaon, quotaoff: turn file system" "quotas on and off." "" quotaon(8) .xx "" "" "rain: animated raindrops display." "" rain(6) .xx "" "rain: animated" "raindrops display." "" rain(6) .xx "" "" "rand, drand, irand: return random values." "" rand(3F) .xx "" "" "rand, srand: random number generator." "" rand(3C) .xx "generator." "" "random, drandm, irandm: better random number" "" random(3F) .xx "" "fortune: print a" "random, hopefully interesting, adage." "" fortune(6) .xx "" "ranlib: convert archives to" "random libraries." "" ranlib(1) .xx "" "rand, srand:" "random number generator." "" rand(3C) .xx "" "random, drandm, irandm: better" "random number generator." "" random(3F) .xx "" "random, srandom, initstate, setstate: better" "random number generator; routines for changing/" "" random(3) .xx "number generator; routines for changing/" "" "random, srandom, initstate, setstate: better random" "" random(3) .xx "" "rand, drand, irand: return" "random values." "" rand(3F) .xx "" "" "ranlib: convert archives to random libraries." "" ranlib(1) .xx "" "" "ratfor: rational Fortran dialect." "" ratfor(1) .xx "" "ratfor:" "rational Fortran dialect." "" ratfor(1) .xx "" "imp: IMP" "raw socket interface." "" imp(4P) .xx "" "" "rc: command script for auto-reboot and daemons." "" rc(8) .xx "stream to a remote command." "" "rcmd, rresvport, ruserok: routines for returning a" "" rcmd(3) .xx "" "" "rcp: remote file copy." "" rcp(1C) .xx "" "rcsintro: introduction to" "RCS commands." "" rcsintro(1) .xx "" "" "rcsintro: introduction to RCS commands." "" rcsintro(1) .xx "" "" "rdist: remote file distribution program." "" rdist(1) .xx "" "" "rdump: file system dump across the network." "" rdump(8C) .xx "" "getpass:" "read a password." "" getpass(3) .xx "" "source:" "read commands from file." "" csh(1) .xx "" "read, readv:" "read input." "" read(2) .xx "" "readnews:" "read news articles." "" readnews(1) .xx "" "vnews:" "read news articles." "" vnews(1) .xx "" "/continue, cd, eval, exec, exit, export, login," "read, readonly, set, shift, times, trap, umask,/" "" sh(1) .xx "" "" "read, readv: read input." "" read(2) .xx "" "readlink:" "read value of a symbolic link." "" readlink(2) .xx "directory operations." "opendir," "readdir, telldir, seekdir, rewinddir, closedir:" "" directory(3) .xx "" "open: open a file for" "reading or writing, or create a new file." "" open(2) .xx "" "" "readlink: read value of a symbolic link." "" readlink(2) .xx "" "" "readnews: read news articles." "" readnews(1) .xx "" "notes, autoseq," "readnotes: a news system." "" notes(1) .xx "command/" "/cd, eval, exec, exit, export, login, read," "readonly, set, shift, times, trap, umask, wait:" "" sh(1) .xx "" "read," "readv: read input." "" read(2) .xx "" "bad144:" "read/write dec standard 144 bad sector information." "" bad144(8) .xx "" "lseek: move" "read/write pointer." "" lseek(2) .xx "" "setregid: set" "real and effective group ID." "" setregid(2) .xx "" "setreuid: set" "real and effective user ID's." "" setreuid(2) .xx "" "malloc, free," "realloc, calloc, alloca: memory allocator." "" malloc(3) .xx "" "symorder:" "rearrange name list." "" symorder(1) .xx "" "" "reboot: reboot system or halt processor." "" reboot(2) .xx "" "reboot:" "reboot system or halt processor." "" reboot(2) .xx "" "" "reboot: UNIX bootstrapping procedures." "" reboot(8) .xx "" "fastboot, fasthalt:" "reboot/halt the system without checking the disks." "" fastboot(8) .xx "" "newaliases:" "rebuild the data base for the mail aliases file." "" newaliases(1) .xx "" "recv, recvfrom, recvmsg:" "receive a message from a socket." "" recv(2) .xx "" "mail: send and" "receive mail." "" mail(1) .xx "" "binmail: send or" "receive mail among users." "" binmail(1) .xx "" "rmail: handle remote mail" "received via uucp." "" rmail(1) .xx "" "" "re_comp, re_exec: regular expression handler." "" regex(3) .xx "" "rehash:" "recompute command hash table." "" csh(1) .xx "" "utmp, wtmp: login" "records." "" utmp(5) .xx "socket." "" "recv, recvfrom, recvmsg: receive a message from a" "" recv(2) .xx "" "recv," "recvfrom, recvmsg: receive a message from a socket." "" recv(2) .xx "" "recv, recvfrom," "recvmsg: receive a message from a socket." "" recv(2) .xx "" "eval:" "re-evaluate shell data." "" csh(1) .xx "" "re_comp," "re_exec: regular expression handler." "" regex(3) .xx "documents." "" "refer: find and insert literature references in" "" refer(1) .xx "" "bibliographic formatter; list bibliographic" "reference items." "bib, listrefs:" bib(1) .xx "" "lxref: lisp cross" "reference program." "" lxref(1) .xx "" "build inverted index for a bibliography, find" "references in a bibliography." "indxbib, lookbib:" lookbib(1) .xx "" "refer: find and insert literature" "references in documents." "" refer(1) .xx "" "re_comp, re_exec:" "regular expression handler." "" regex(3) .xx "" "" "rehash: recompute command hash table." "" csh(1) .xx "" "comm: select or" "reject lines common to two sorted files." "" comm(1) .xx "" "lorder: find ordering" "relation for an object library." "" lorder(1) .xx "" "join:" "relational database operator." "" join(1) .xx "" "sigpause: atomically" "release blocked signals and wait for interrupt." "" sigpause(2) .xx "" "strip: remove symbols and" "relocation bits." "" strip(1) .xx "" "copysign, drem, finite, logb, scalb: copysign," "remainder, exponent manipulations." "" ieee(3M) .xx "" "leave:" "remind you when you have to leave." "" leave(1) .xx "" "calendar:" "reminder service." "" calendar(1) .xx "" "ruserok: routines for returning a stream to a" "remote command." "rcmd, rresvport," rcmd(3) .xx "" "rexec: return stream to a" "remote command." "" rexec(3) .xx "" "L.cmds: UUCP" "remote command permissions file." "" L.cmds(5) .xx "" "rexecd:" "remote execution server." "" rexecd(8C) .xx "" "rcp:" "remote file copy." "" rcp(1C) .xx "" "rdist:" "remote file distribution program." "" rdist(1) .xx "" "uusend: send a file to a" "remote host." "" uusend(1C) .xx "" "L.sys: UUCP" "remote host description file." "" L.sys(5) .xx "" "remote:" "remote host description file." "" remote(5) .xx "" "phones:" "remote host phone number data base." "" phones(5) .xx "" "rlogin:" "remote login." "" rlogin(1C) .xx "" "rlogind:" "remote login server." "" rlogind(8C) .xx "" "tn3270: full-screen" "remote login to IBM VM/CMS." "" tn3270(1) .xx "" "rmt:" "remote magtape protocol module." "" rmt(8C) .xx "" "rmail: handle" "remote mail received via uucp." "" rmail(1) .xx "" "" "remote: remote host description file." "" remote(5) .xx "" "rsh:" "remote shell." "" rsh(1C) .xx "" "rshd:" "remote shell server." "" rshd(8C) .xx "" "tip, cu: connect to a" "remote system." "" tip(1C) .xx "" "talkd:" "remote user communication server." "" talkd(8C) .xx "" "fingerd:" "remote user information server." "" fingerd(8C) .xx "" "uupoll: poll a" "remote UUCP site." "" uupoll(8C) .xx "" "unlink:" "remove a directory entry." "" unlink(3F) .xx "" "rmdir:" "remove a directory file." "" rmdir(2) .xx "" "unalias:" "remove aliases." "" csh(1) .xx "" "flock: apply or" "remove an advisory lock on an open file." "" flock(2) .xx "" "colrm:" "remove columns from a file." "" colrm(1) .xx "" "unlink:" "remove directory entry." "" unlink(2) .xx "" "unsetenv:" "remove environment variables." "" csh(1) .xx "" "mount, umount: mount or" "remove file system." "" mount(2) .xx "" "unifdef:" "remove ifdef'ed lines." "" unifdef(1) .xx "" "lprm:" "remove jobs from the line printer spooling queue." "" lprm(1) .xx "" "atrm:" "remove jobs spooled by at." "" atrm(1) .xx "" "deroff:" "remove nroff, troff, tbl and eqn constructs." "" deroff(1) .xx "" "unlimit:" "remove resource limitiations." "" csh(1) .xx "" "strip:" "remove symbols and relocation bits." "" strip(1) .xx "" "rmdir, rm:" "remove (unlink) directories or files." "" rmdir(1) .xx "" "rm, rmdir:" "remove (unlink) files or directories." "" rm(1) .xx "" "insque," "remque: insert/remove element from a queue." "" insque(3) .xx "" "rename:" "rename a file." "" rename(3F) .xx "" "" "rename: change the name of a file." "" rename(2) .xx "" "mv: move or" "rename files." "" mv(1) .xx "" "" "rename: rename a file." "" rename(3F) .xx "" "" "renice: alter priority of running processes." "" renice(8) .xx "" "fsck: file system consistency check and interactive" "repair." "" fsck(8) .xx "" "trpfpe, fpecnt: trap and" "repair floating point faults." "" trpfpe(3F) .xx "" "trapov: trap and" "repair floating point overflow." "" trapov(3F) .xx "" "while:" "repeat commands conditionally." "" csh(1) .xx "" "" "repeat: execute command repeatedly." "" csh(1) .xx "" "uniq: report" "repeated lines in a file." "" uniq(1) .xx "" "repeat: execute command" "repeatedly." "" csh(1) .xx "" "yes: be" "repetitively affirmative." "" yes(1) .xx "" "iostat:" "report I/O statistics." "" iostat(1) .xx "" "uniq:" "report repeated lines in a file." "" uniq(1) .xx "" "sendbug: mail a system bug" "report to 4bsd-bugs." "" sendbug(1) .xx "" "vmstat:" "report virtual memory statistics." "" vmstat(1) .xx "" "bugfiler: file bug" "reports in folders automatically." "" bugfiler(8) .xx "" "fseek, ftell:" "reposition a file on a logical unit." "" fseek(3F) .xx "" "fseek, ftell, rewind:" "reposition a stream." "" fseek(3S) .xx "" "" "repquota: summarize quotas for a file system." "" repquota(8) .xx "" "notify:" "request immediate notification." "" csh(1) .xx "" "lock:" "reserve a terminal." "" lock(1) .xx "" "res_mkquery, res_send," "res_init, dn_comp, dn_expand: resolver routines." "" resolver(3) .xx "dn_expand: resolver routines." "" "res_mkquery, res_send, res_init, dn_comp," "" resolver(3) .xx "" "arp: address" "resolution display and control." "" arp(8C) .xx "" "arp: Address" "Resolution Protocol." "" arp(4P) .xx "" "" "resolver configuration file." "" resolver(5) .xx "" "res_send, res_init, dn_comp, dn_expand:" "resolver routines." "res_mkquery," resolver(3) .xx "" "getrlimit, setrlimit: control maximum system" "resource consumption." "" getrlimit(2) .xx "" "vlimit: control maximum system" "resource consumption." "" vlimit(3C) .xx "" "limit: alter per-process" "resource limitations." "" csh(1) .xx "" "unlimit: remove" "resource limitiations." "" csh(1) .xx "" "getrusage: get information about" "resource utilization." "" getrusage(2) .xx "" "vtimes: get information about" "resource utilization." "" vtimes(3C) .xx "routines." "res_mkquery," "res_send, res_init, dn_comp, dn_expand: resolver" "" resolver(3) .xx "" "restore: incremental file system" "restore." "" restore(8) .xx "" "rrestore:" "restore a file system dump across the network." "" rrestore(8C) .xx "" "" "restore: incremental file system restore." "" restore(8) .xx "" "suspend: suspend a shell," "resuming its superior." "" csh(1) .xx "" "mset:" "retrieve ASCII to IBM 3270 keyboard map." "" mset(1) .xx "" "getarg, iargc:" "return command line arguments." "" getarg(3F) .xx "" "fdate:" "return date and time in an ASCII string." "" fdate(3F) .xx "" "idate, itime:" "return date or time in numerical form." "" idate(3F) .xx "" "etime, dtime:" "return elapsed execution time." "" etime(3F) .xx "" "flmin, flmax, ffrac, dflmin, dflmax, dffrac, inmax:" "return extreme values." "" flmin(3F) .xx "" "sigreturn:" "return from signal." "" sigreturn(2) .xx "" "vacation:" "return ``I am on vacation'' indication." "" vacation(1) .xx "" "rand, drand, irand:" "return random values." "" rand(3F) .xx "" "rexec:" "return stream to a remote command." "" rexec(3) .xx "" "time, ctime, ltime, gmtime:" "return system time." "" time(3F) .xx "" "loc:" "return the address of an object." "" loc(3F) .xx "" "rcmd, rresvport, ruserok: routines for" "returning a stream to a remote command." "" rcmd(3) .xx "" "" "rev: reverse lines of a file." "" rev(1) .xx "" "col: filter" "reverse line feeds." "" col(1) .xx "" "rev:" "reverse lines of a file." "" rev(1) .xx "" "lastcomm: show last commands executed in" "reverse order." "" lastcomm(1) .xx "" "fseek, ftell," "rewind: reposition a stream." "" fseek(3S) .xx "" "opendir, readdir, telldir, seekdir," "rewinddir, closedir: directory operations." "" directory(3) .xx "" "" "rexec: return stream to a remote command." "" rexec(3) .xx "" "" "rexecd: remote execution server." "" rexecd(8C) .xx "" "index," "rindex, lnblnk, len: tell about character objects." "" index(3F) .xx "" "strcmp, strncmp, strcpy, strncpy, strlen, index," "rindex: string operations." "strcat, strncat," string(3) .xx "" "vv: Proteon proNET 10 Megabit" "ring." "" vv(4) .xx "round-to-nearest functions." "fabs, floor, ceil," "rint: absolute value, floor, ceiling, and" "" floor(3M) .xx "" "lptest: generate lineprinter" "ripple pattern." "" lptest(1) .xx "" "hk: RK6-11/RK06 and" "RK07 moving head disk." "" hk(4) .xx "" "hk:" "RK6-11/RK06 and RK07 moving head disk." "" hk(4) .xx "" "crl: VAX 8600 console" "RL02 interface." "" crl(4) .xx "" "" "rlogin: remote login." "" rlogin(1C) .xx "" "" "rlogind: remote login server." "" rlogind(8C) .xx "" "rmdir," "rm: remove (unlink) directories or files." "" rmdir(1) .xx "" "" "rm, rmdir: remove (unlink) files or directories." "" rm(1) .xx "" "" "rmail: handle remote mail received via uucp." "" rmail(1) .xx "" "" "rmdir: remove a directory file." "" rmdir(2) .xx "" "rm," "rmdir: remove (unlink) files or directories." "" rm(1) .xx "" "" "rmdir, rm: remove (unlink) directories or files." "" rmdir(1) .xx "" "" "rmt: remote magtape protocol module." "" rmt(8C) .xx "" "robots: fight off villainous" "robots." "" robots(6) .xx "" "" "robots: fight off villainous robots." "" robots(6) .xx "" "" "roffbib: run off bibliographic database." "" roffbib(1) .xx "" "" "rogue: Exploring The Dungeons of Doom." "" rogue(6) .xx "" "cbrt, sqrt: cube root, square" "root." "" sqrt(3M) .xx "" "chroot: change" "root directory." "" chroot(2) .xx "" "cbrt, sqrt: cube" "root, square root." "" sqrt(3M) .xx "" "ceil, rint: absolute value, floor, ceiling, and" "round-to-nearest functions." "fabs, floor," floor(3M) .xx "" "" "route: manually manipulate the routing tables." "" route(8C) .xx "" "" "routed: network routing daemon." "" routed(8C) .xx "" "inet_netof: Internet address manipulation" "routines." "/inet_ntoa, inet_makeaddr, inet_lnaof," inet(3N) .xx "" "ns_addr, ns_ntoa: Xerox NS(tm) address conversion" "routines." "" ns(3N) .xx "" "res_send, res_init, dn_comp, dn_expand: resolver" "routines." "res_mkquery," resolver(3) .xx "" "tgoto, tputs: terminal independent operation" "routines." "tgetent, tgetnum, tgetflag, tgetstr," termcap(3X) .xx "" "setstate: better random number generator;" "routines for changing generators." "/initstate," random(3) .xx "command." "rcmd, rresvport, ruserok:" "routines for returning a stream to a remote" "" rcmd(3) .xx "" "routed: network" "routing daemon." "" routed(8C) .xx "" "XNSrouted: NS" "Routing Information Protocol daemon." "" XNSrouted(8C) .xx "" "route: manually manipulate the" "routing tables." "" route(8C) .xx "mout,/" "madd, msub, mult, mdiv, pow, gcd, invert," "rpow, msqrt, mcmp, move, min, omin, fmin, m_in," "" mp(3X) .xx "network." "" "rrestore: restore a file system dump across the" "" rrestore(8C) .xx "to a remote command." "rcmd," "rresvport, ruserok: routines for returning a stream" "" rcmd(3) .xx "" "" "rsh: remote shell." "" rsh(1C) .xx "" "" "rshd: remote shell server." "" rshd(8C) .xx "" "bit: and, or, xor, not," "rshift, lshift bitwise functions." "" bit(3F) .xx "" "atq: print the queue of jobs waiting to be" "run." "" atq(1) .xx "" "nice, nohup:" "run a command at low priority (\fIsh\fR only)." "" nice(1) .xx "" "nohup:" "run command immune to hangups." "" csh(1) .xx "" "nice:" "run low priority process." "" csh(1) .xx "" "roffbib:" "run off bibliographic database." "" roffbib(1) .xx "" "gcore: get core images of" "running processes." "" gcore(1) .xx "" "renice: alter priority of" "running processes." "" renice(8) .xx "" "" "ruptime: show host status of local machines." "" ruptime(1C) .xx "remote command." "rcmd, rresvport," "ruserok: routines for returning a stream to a" "" rcmd(3) .xx "" "" "rwho: who's logged in on local machines." "" rwho(1C) .xx "" "" "rwhod: system status server." "" rwhod(8C) .xx "" "" "rx: DEC RX02 floppy disk interface." "" rx(4) .xx "" "rx: DEC" "RX02 floppy disk interface." "" rx(4) .xx "" "" "rxformat: format floppy disks." "" rxformat(8V) .xx "" "" "sa, accton: system accounting." "" sa(8) .xx "" "" "sail: multi-user wooden ships and iron men." "" sail(6) .xx "" "savecore:" "save a core dump of the operating system." "" savecore(8) .xx "" "" "savecore: save a core dump of the operating system." "" savecore(8) .xx "" "brk," "sbrk: change data segment size." "" brk(2) .xx "" "copysign, drem, finite, logb," "scalb: copysign, remainder, exponent manipulations." "" ieee(3M) .xx "" "scandir, alphasort:" "scan a directory." "" scandir(3) .xx "" "" "scandir, alphasort: scan a directory." "" scandir(3) .xx "" "" "scanf, fscanf, sscanf: formatted input conversion." "" scanf(3S) .xx "" "awk: pattern" "scanning and processing language." "" awk(1) .xx "" "" "sccs: front end for the SCCS subsystem." "" sccs(1) .xx "" "sccs: front end for the" "SCCS subsystem." "" sccs(1) .xx "" "alarm:" "schedule signal after specified time." "" alarm(3C) .xx "" "ualarm:" "schedule signal after specified time." "" ualarm(3) .xx "" "getpriority, setpriority: get/set program" "scheduling priority." "" getpriority(2) .xx "" "clear: clear terminal" "screen." "" clear(1) .xx "" "curses:" "screen functions with ``optimal'' cursor motion." "" curses(3X) .xx "ex." "vi:" "screen oriented (visual) display editor based on" "" vi(1) .xx "" "rc: command" "script for auto-reboot and daemons." "" rc(8) .xx "" "" "script: make typescript of terminal session." "" script(1) .xx "" "onintr: process interrupts in command" "scripts." "" csh(1) .xx "" "/min, omin, fmin, m_in, mout, omout, fmout, m_out," "sdiv, itom: multiple precision integer arithmetic." "" mp(3X) .xx "" "grep, egrep, fgrep:" "search a file for a pattern." "" grep(1) .xx "" "xsend, xget, enroll:" "secret mail." "" xsend(1) .xx "" "bad144: read/write dec standard 144 bad" "sector information." "" bad144(8) .xx "" "badsect: create files to contain bad" "sectors." "" badsect(8) .xx "" "" "sed: stream editor." "" sed(1) .xx "" "opendir, readdir, telldir," "seekdir, rewinddir, closedir: directory operations." "" directory(3) .xx "" "brk, sbrk: change data" "segment size." "" brk(2) .xx "" "comm:" "select or reject lines common to two sorted files." "" comm(1) .xx "" "" "select: synchronous I/O multiplexing." "" select(2) .xx "" "case:" "selector in switch." "" csh(1) .xx "" "uusend:" "send a file to a remote host." "" uusend(1C) .xx "" "send, sendto, sendmsg:" "send a message from a socket." "" send(2) .xx "" "kill:" "send a signal to a process." "" kill(3F) .xx "" "mail:" "send and receive mail." "" mail(1) .xx "" "ping:" "send ICMP ECHO_REQUEST packets to network hosts." "" ping(8) .xx "" "sendmail:" "send mail over the internet." "" sendmail(8) .xx "" "binmail:" "send or receive mail among users." "" binmail(1) .xx "socket." "" "send, sendto, sendmsg: send a message from a" "" send(2) .xx "" "kill:" "send signal to a process." "" kill(2) .xx "" "killpg:" "send signal to a process group." "" killpg(2) .xx "" "" "sendbug: mail a system bug report to 4bsd-bugs." "" sendbug(1) .xx "" "aliases: aliases file for" "sendmail." "" aliases(5) .xx "" "" "sendmail: send mail over the internet." "" sendmail(8) .xx "" "send, sendto," "sendmsg: send a message from a socket." "" send(2) .xx "" "send," "sendto, sendmsg: send a message from a socket." "" send(2) .xx "" "diction, explain: print wordy" "sentences; thesaurus for diction." "" diction(1) .xx "" "spp: Xerox" "Sequenced Packet Protocol." "" spp(4P) .xx "" "trsp: transliterate" "sequenced packet protocol trace." "" trsp(8C) .xx "" "slattach: attach" "serial lines as network interfaces." "" slattach(8C) .xx "" "comsat: biff" "server." "" comsat(8C) .xx "" "fingerd: remote user information" "server." "" fingerd(8C) .xx "" "ftpd: DARPA Internet File Transfer Protocol" "server." "" ftpd(8C) .xx "" "named: Internet domain name" "server." "" named(8) .xx "" "rexecd: remote execution" "server." "" rexecd(8C) .xx "" "rlogind: remote login" "server." "" rlogind(8C) .xx "" "rshd: remote shell" "server." "" rshd(8C) .xx "" "rwhod: system status" "server." "" rwhod(8C) .xx "" "talkd: remote user communication" "server." "" talkd(8C) .xx "" "telnetd: DARPA TELNET protocol" "server." "" telnetd(8C) .xx "" "tftpd: DARPA Trivial File Transfer Protocol" "server." "" tftpd(8C) .xx "" "timed: time" "server daemon." "" timed(8) .xx "" "" "services: service name data base." "" services(5) .xx "" "logout: end" "session." "" csh(1) .xx "" "script: make typescript of terminal" "session." "" script(1) .xx "" "ascii: map of ASCII character" "set." "" ascii(7) .xx "" "stty, gtty:" "set and get terminal state (defunct)." "" stty(3C) .xx "" "sigstack:" "set and/or get signal stack context." "" sigstack(2) .xx "" "" "set: change value of shell variable." "" csh(1) .xx "" "sigsetmask:" "set current signal mask." "" sigsetmask(2) .xx "" "umask:" "set file creation mode mask." "" umask(2) .xx "" "utime:" "set file times." "" utime(3C) .xx "" "utimes:" "set file times." "" utimes(2) .xx "" "setgroups:" "set group access list." "" setgroups(2) .xx "" "apply: apply a command to a" "set of arguments." "" apply(1) .xx "" "getsockopt, setsockopt: get and" "set options on sockets." "" getsockopt(2) .xx "" "hostid:" "set or print identifier of current host system." "" hostid(1) .xx "" "hostname:" "set or print name of current host system." "" hostname(1) .xx "" "setpgrp:" "set process group." "" setpgrp(2) .xx "" "nice:" "set program priority." "" nice(3C) .xx "" "setregid:" "set real and effective group ID." "" setregid(2) .xx "" "setreuid:" "set real and effective user ID's." "" setreuid(2) .xx "" "eval, exec, exit, export, login, read, readonly," "set, shift, times, trap, umask, wait: command/" "/cd," sh(1) .xx "" "getty:" "set terminal mode." "" getty(8) .xx "" "stty:" "set terminal options." "" stty(1) .xx "" "tabs:" "set terminal tabs." "" tabs(1) .xx "" "date: print and" "set the date." "" date(1) .xx "" "setuid, seteuid, setruid, setgid, setegid, setrgid:" "set user and group ID." "" setuid(3) .xx "" "setenv:" "set variable in environment." "" csh(1) .xx "a stream." "" "setbuf, setbuffer, setlinebuf: assign buffering to" "" setbuf(3S) .xx "stream." "setbuf," "setbuffer, setlinebuf: assign buffering to a" "" setbuf(3S) .xx "" "setuid, seteuid, setruid, setgid," "setegid, setrgid: set user and group ID." "" setuid(3) .xx "" "" "setenv: set variable in environment." "" csh(1) .xx "user and group ID." "setuid," "seteuid, setruid, setgid, setegid, setrgid: set" "" setuid(3) .xx "entry." "getfsent, getfsspec, getfsfile, getfstype," "setfsent, endfsent: get file system descriptor file" "" getfsent(3) .xx "" "setuid, seteuid, setruid," "setgid, setegid, setrgid: set user and group ID." "" setuid(3) .xx "" "getgrent, getgrgid, getgrnam," "setgrent, endgrent: get group file entry." "" getgrent(3) .xx "" "" "setgroups: set group access list." "" setgroups(2) .xx "" "gethostbyname, gethostbyaddr, gethostent," "sethostent, endhostent: get network host entry." "" gethostbyname(3N) .xx "host." "gethostid," "sethostid: get/set unique identifier of current" "" gethostid(2) .xx "" "gethostname," "sethostname: get/set name of current host." "" gethostname(2) .xx "" "getitimer," "setitimer: get/set value of interval timer." "" getitimer(2) .xx "" "" "setjmp, longjmp: non-local goto." "" setjmp(3) .xx "" "crypt," "setkey, encrypt: DES encryption." "" crypt(3) .xx "" "setbuf, setbuffer," "setlinebuf: assign buffering to a stream." "" setbuf(3S) .xx "" "syslog, openlog, closelog," "setlogmask: control system log." "" syslog(3) .xx "" "getnetent, getnetbyaddr, getnetbyname," "setnetent, endnetent: get network entry." "" getnetent(3N) .xx "" "" "setpgrp: set process group." "" setpgrp(2) .xx "" "getpriority," "setpriority: get/set program scheduling priority." "" getpriority(2) .xx "" "getprotoent, getprotobynumber, getprotobyname," "setprotoent, endprotoent: get protocol entry." "" getprotoent(3N) .xx "entry." "getpwent, getpwuid, getpwnam," "setpwent, endpwent, setpwfile: get password file" "" getpwent(3) .xx "" "getpwent, getpwuid, getpwnam, setpwent, endpwent," "setpwfile: get password file entry." "" getpwent(3) .xx "" "" "setquota: enable/disable quotas on a file system." "" setquota(2) .xx "" "" "setregid: set real and effective group ID." "" setregid(2) .xx "" "" "setreuid: set real and effective user ID's." "" setreuid(2) .xx "" "setuid, seteuid, setruid, setgid, setegid," "setrgid: set user and group ID." "" setuid(3) .xx "consumption." "getrlimit," "setrlimit: control maximum system resource" "" getrlimit(2) .xx "group ID." "setuid, seteuid," "setruid, setgid, setegid, setrgid: set user and" "" setuid(3) .xx "" "getservent, getservbyport, getservbyname," "setservent, endservent: get service entry." "" getservent(3N) .xx "" "getsockopt," "setsockopt: get and set options on sockets." "" getsockopt(2) .xx "for changing/" "random, srandom, initstate," "setstate: better random number generator; routines" "" random(3) .xx "" "gettimeofday," "settimeofday: get/set date and time." "" gettimeofday(2) .xx "" "getttyent, getttynam," "setttyent, endttyent: get ttys file entry." "" getttyent(3) .xx "set user and group ID." "" "setuid, seteuid, setruid, setgid, setegid, setrgid:" "" setuid(3) .xx "" "getusershell," "setusershell, endusershell: get legal user shells." "" getusershell(3) .xx "continue, cd, eval, exec, exit, export, login,/" "" "sh, for, case, if, while, \fB:\fP, \fB.\fP, break," "" sh(1) .xx "" "xstr: extract strings from C programs to implement" "shared strings." "" xstr(1) .xx "" "exit: leave" "shell." "" csh(1) .xx "" "rsh: remote" "shell." "" rsh(1C) .xx "" "system: issue a" "shell command." "" system(3) .xx "" "csh: a" "shell (command interpreter) with C-like syntax." "" csh(1) .xx "" "eval: re-evaluate" "shell data." "" csh(1) .xx "" "popd: pop" "shell directory stack." "" csh(1) .xx "" "pushd: push" "shell directory stack." "" csh(1) .xx "" "alias:" "shell macros." "" csh(1) .xx "" "suspend: suspend a" "shell, resuming its superior." "" csh(1) .xx "" "rshd: remote" "shell server." "" rshd(8C) .xx "" "set: change value of" "shell variable." "" csh(1) .xx "" "@: arithmetic on" "shell variables." "" csh(1) .xx "" "unset: discard" "shell variables." "" csh(1) .xx "" "exec: overlay" "shell with specified command." "" csh(1) .xx "" "setusershell, endusershell: get legal user" "shells." "getusershell," getusershell(3) .xx "" "" "shift: manipulate argument list." "" csh(1) .xx "" "/exec, exit, export, login, read, readonly, set," "shift, times, trap, umask, wait: command language." "" sh(1) .xx "" "sail: multi-user wooden" "ships and iron men." "" sail(6) .xx "" "long," "short: integer object conversion." "" long(3F) .xx "" "groups:" "show group memberships." "" groups(1) .xx "" "ruptime:" "show host status of local machines." "" ruptime(1C) .xx "" "uptime:" "show how long system has been up." "" uptime(1) .xx "" "lastcomm:" "show last commands executed in reverse order." "" lastcomm(1) .xx "" "netstat:" "show network status." "" netstat(1) .xx "" "uusnap:" "show snapshot of the UUCP system." "" uusnap(8C) .xx "construct a file." "what:" "show what versions of object modules were used to" "" what(1) .xx "" "shutdown:" "shut down part of a full-duplex connection." "" shutdown(2) .xx "" "" "shutdown: close down the system at a given time." "" shutdown(8) .xx "connection." "" "shutdown: shut down part of a full-duplex" "" shutdown(2) .xx "" "" "sigblock: block signals." "" sigblock(2) .xx "calls." "" "siginterrupt: allow signals to interrupt system" "" siginterrupt(3) .xx "" "login:" "sign on." "" login(1) .xx "" "pause: stop until" "signal." "" pause(3C) .xx "" "signal: change the action for a" "signal." "" signal(3F) .xx "" "sigreturn: return from" "signal." "" sigreturn(2) .xx "" "alarm: schedule" "signal after specified time." "" alarm(3C) .xx "" "ualarm: schedule" "signal after specified time." "" ualarm(3) .xx "" "" "signal: change the action for a signal." "" signal(3F) .xx "" "signal: simplified software" "signal facilities." "" signal(3C) .xx "" "sigvec: software" "signal facilities." "" sigvec(2) .xx "" "sigsetmask: set current" "signal mask." "" sigsetmask(2) .xx "" "psignal, sys_siglist: system" "signal messages." "" psignal(3) .xx "" "" "signal: simplified software signal facilities." "" signal(3C) .xx "" "sigstack: set and/or get" "signal stack context." "" sigstack(2) .xx "" "kill: send" "signal to a process." "" kill(2) .xx "" "kill: send a" "signal to a process." "" kill(3F) .xx "" "killpg: send" "signal to a process group." "" killpg(2) .xx "" "sigblock: block" "signals." "" sigblock(2) .xx "" "sigpause: atomically release blocked" "signals and wait for interrupt." "" sigpause(2) .xx "(temporary)." "infnan:" "signals invalid floating-point operations on a VAX" "" infnan(3M) .xx "" "siginterrupt: allow" "signals to interrupt system calls." "" siginterrupt(3) .xx "wait for interrupt." "" "sigpause: atomically release blocked signals and" "" sigpause(2) .xx "" "" "sigreturn: return from signal." "" sigreturn(2) .xx "" "" "sigsetmask: set current signal mask." "" sigsetmask(2) .xx "" "" "sigstack: set and/or get signal stack context." "" sigstack(2) .xx "" "" "sigvec: software signal facilities." "" sigvec(2) .xx "" "signal:" "simplified software signal facilities." "" signal(3C) .xx "" "tc: photoypesetter" "simulator." "" tc(1) .xx "trigonometric functions and their inverses." "" "sin, cos, tan, asin, acos, atan, atan2:" "" sin(3M) .xx "" "" "sinh, cosh, tanh: hyperbolic functions." "" sinh(3M) .xx "" "null: data" "sink." "" null(4) .xx "" "uupoll: poll a remote UUCP" "site." "" uupoll(8C) .xx "" "brk, sbrk: change data segment" "size." "" brk(2) .xx "" "getdtablesize: get descriptor table" "size." "" getdtablesize(2) .xx "" "getpagesize: get system page" "size." "" getpagesize(2) .xx "" "pagesize: print system page" "size." "" pagesize(1) .xx "" "size:" "size of an object file." "" size(1) .xx "" "" "size: size of an object file." "" size(1) .xx "" "diskpart: calculate default disk partition" "sizes." "" diskpart(8) .xx "interfaces." "" "slattach: attach serial lines as network" "" slattach(8C) .xx "" "" "sleep: suspend execution for an interval." "" sleep(1) .xx "" "" "sleep: suspend execution for an interval." "" sleep(3F) .xx "" "" "sleep: suspend execution for interval." "" sleep(3) .xx "" "spline: interpolate" "smooth curve." "" spline(1G) .xx "" "" "snake, snscore: display chase game." "" snake(6) .xx "" "uusnap: show" "snapshot of the UUCP system." "" uusnap(8C) .xx "" "snake," "snscore: display chase game." "" snake(6) .xx "" "accept: accept a connection on a" "socket." "" accept(2) .xx "" "bind: bind a name to a" "socket." "" bind(2) .xx "" "connect: initiate a connection on a" "socket." "" connect(2) .xx "" "listen: listen for connections on a" "socket." "" listen(2) .xx "" "recv, recvfrom, recvmsg: receive a message from a" "socket." "" recv(2) .xx "" "send, sendto, sendmsg: send a message from a" "socket." "" send(2) .xx "" "" "socket: create an endpoint for communication." "" socket(2) .xx "" "imp: IMP raw" "socket interface." "" imp(4P) .xx "" "getsockname: get" "socket name." "" getsockname(2) .xx "" "" "socketpair: create a pair of connected sockets." "" socketpair(2) .xx "" "getsockopt, setsockopt: get and set options on" "sockets." "" getsockopt(2) .xx "" "socketpair: create a pair of connected" "sockets." "" socketpair(2) .xx "" "" "soelim: eliminate \&.so's from nroff input." "" soelim(1) .xx "" "lo:" "software loopback network interface." "" lo(4) .xx "in ip packets.." "nsip:" "software network interface encapsulating ns packets" "" nsip(4) .xx "" "signal: simplified" "software signal facilities." "" signal(3C) .xx "" "sigvec:" "software signal facilities." "" sigvec(2) .xx "" "canfield, cfscores: the" "solitaire card game canfield." "" canfield(6) .xx "" "qsort: quicker" "sort." "" qsort(3) .xx "" "qsort: quick" "sort." "" qsort(3F) .xx "" "tsort: topological" "sort." "" tsort(1) .xx "" "sortbib:" "sort bibliographic database." "" sortbib(1) .xx "" "sort:" "sort or merge files." "" sort(1) .xx "" "" "sort: sort or merge files." "" sort(1) .xx "" "" "sortbib: sort bibliographic database." "" sortbib(1) .xx "" "comm: select or reject lines common to two" "sorted files." "" comm(1) .xx "" "look: find lines in a" "sorted list." "" look(1) .xx "" "soelim: eliminate" "\&.so's from nroff input." "" soelim(1) .xx "" "soelim: eliminate \&." "so's from nroff input." "" soelim(1) .xx "" "indent: indent and format C program" "source." "" indent(1) .xx "" "mkstr: create an error message file by massaging C" "source." "" mkstr(1) .xx "" "whereis: locate" "source, binary, and or manual for program." "" whereis(1) .xx "" "" "source: read commands from file." "" csh(1) .xx "" "line, circle, arc, move, cont, point, linemod," "space, closepl: graphics interface." "/erase, label," plot(3X) .xx "" "expand, unexpand: expand tabs to" "spaces, and vice versa." "" expand(1) .xx "way." "vfork:" "spawn new process in a virtual memory efficient" "" vfork(2) .xx "" "exec: overlay shell with" "specified command." "" csh(1) .xx "" "truncate: truncate a file to a" "specified length." "" truncate(2) .xx "" "alarm: schedule signal after" "specified time." "" alarm(3C) .xx "" "alarm: execute a subroutine after a" "specified time." "" alarm(3F) .xx "" "ualarm: schedule signal after" "specified time." "" ualarm(3) .xx "" "swapon:" "specify additional device for paging and swapping." "" swapon(8) .xx "" "" "spell, spellin, spellout: find spelling errors." "" spell(1) .xx "" "spell," "spellin, spellout: find spelling errors." "" spell(1) .xx "" "spell, spellin, spellout: find" "spelling errors." "" spell(1) .xx "" "spell, spellin," "spellout: find spelling errors." "" spell(1) .xx "" "" "spline: interpolate smooth curve." "" spline(1G) .xx "" "split:" "split a file into pieces." "" split(1) .xx "files." "fsplit:" "split a multi-routine Fortran file into individual" "" fsplit(1) .xx "" "frexp, ldexp, modf:" "split into mantissa and exponent." "" frexp(3) .xx "" "" "split: split a file into pieces." "" split(1) .xx "" "uuclean: uucp" "spool directory clean-up." "" uuclean(8C) .xx "" "lpq:" "spool queue examination program." "" lpq(1) .xx "" "atrm: remove jobs" "spooled by at." "" atrm(1) .xx "" "lprm: remove jobs from the line printer" "spooling queue." "" lprm(1) .xx "" "" "spp: Xerox Sequenced Packet Protocol." "" spp(4P) .xx "" "printf, fprintf," "sprintf: formatted output conversion." "" printf(3S) .xx "" "cbrt," "sqrt: cube root, square root." "" sqrt(3M) .xx "" "cbrt, sqrt: cube root," "square root." "" sqrt(3M) .xx "" "rand," "srand: random number generator." "" rand(3C) .xx "generator; routines for changing/" "random," "srandom, initstate, setstate: better random number" "" random(3) .xx "" "scanf, fscanf," "sscanf: formatted input conversion." "" scanf(3S) .xx "" "" "stab: symbol table types." "" stab(5) .xx "" "popd: pop shell directory" "stack." "" csh(1) .xx "" "pushd: push shell directory" "stack." "" csh(1) .xx "" "sigstack: set and/or get signal" "stack context." "" sigstack(2) .xx "" "drtest:" "standalone disk test program." "" drtest(8) .xx "" "bad144: read/write dec" "standard 144 bad sector information." "" bad144(8) .xx "" "stdio:" "standard buffered input/output package." "" stdio(3S) .xx "" "htable: convert NIC" "standard format host tables." "" htable(8) .xx "" "ddn: DDN" "Standard Mode X.25 IMP interface." "" ddn(4) .xx "" "" "stat, lstat, fstat: get file status." "" stat(2) .xx "" "" "stat, lstat, fstat: get file status." "" stat(3F) .xx "" "stty, gtty: set and get terminal" "state (defunct)." "" stty(3C) .xx "" "fsync: synchronize a file's in-core" "state with that on disk." "" fsync(2) .xx "" "if: conditional" "statement." "" csh(1) .xx "" "fstab:" "static information about the filesystems." "" fstab(5) .xx "" "hashstat: print command hashing" "statistics." "" csh(1) .xx "" "iostat: report I/O" "statistics." "" iostat(1) .xx "" "vmstat: report virtual memory" "statistics." "" vmstat(1) .xx "" "systat: display system" "statistics on a crt." "" systat(1) .xx "" "exit: terminate process with" "status." "" exit(3F) .xx "" "netstat: show network" "status." "" netstat(1) .xx "" "ps: process" "status." "" ps(1) .xx "" "stat, lstat, fstat: get file" "status." "" stat(2) .xx "" "stat, lstat, fstat: get file" "status." "" stat(3F) .xx "" "ferror, feof, clearerr, fileno: stream" "status inquiries." "" ferror(3S) .xx "" "sysline: display system status on" "status line of a terminal." "" sysline(1) .xx "" "ruptime: show host" "status of local machines." "" ruptime(1C) .xx "" "sysline: display system" "status on status line of a terminal." "" sysline(1) .xx "" "rwhod: system" "status server." "" rwhod(8C) .xx "" "" "stdio: standard buffered input/output package." "" stdio(3S) .xx "directories." "" "sticky: persistent text and append-only" "" sticky(8) .xx "" "" "stop: halt a job or process." "" csh(1) .xx "" "halt:" "stop the processor." "" halt(8) .xx "" "pause:" "stop until signal." "" pause(3C) .xx "" "icheck: file system" "storage consistency check." "" icheck(8) .xx "" "up: unibus" "storage module controller/drives." "" up(4) .xx "subroutines." "dbminit, fetch," "store, delete, firstkey, nextkey: data base" "" dbm(3X) .xx "strlen, index, rindex: string operations." "" "strcat, strncat, strcmp, strncmp, strcpy, strncpy," "" string(3) .xx "rindex: string operations." "strcat, strncat," "strcmp, strncmp, strcpy, strncpy, strlen, index," "" string(3) .xx "operations." "strcat, strncat, strcmp, strncmp," "strcpy, strncpy, strlen, index, rindex: string" "" string(3) .xx "" "fclose, fflush: close or flush a" "stream." "" fclose(3S) .xx "" "fopen, freopen, fdopen: open a" "stream." "" fopen(3S) .xx "" "fseek, ftell, rewind: reposition a" "stream." "" fseek(3S) .xx "" "getchar, fgetc, getw: get character or word from" "stream." "getc," getc(3S) .xx "" "gets, fgets: get a string from a" "stream." "" gets(3S) .xx "" "putchar, fputc, putw: put character or word on a" "stream." "putc," putc(3S) .xx "" "puts, fputs: put a string on a" "stream." "" puts(3S) .xx "" "setbuffer, setlinebuf: assign buffering to a" "stream." "setbuf," setbuf(3S) .xx "" "ungetc: push character back into input" "stream." "" ungetc(3S) .xx "" "sed:" "stream editor." "" sed(1) .xx "" "ferror, feof, clearerr, fileno:" "stream status inquiries." "" ferror(3S) .xx "" "rcmd, rresvport, ruserok: routines for returning a" "stream to a remote command." "" rcmd(3) .xx "" "rexec: return" "stream to a remote command." "" rexec(3) .xx "" "fdate: return date and time in an ASCII" "string." "" fdate(3F) .xx "" "gets, fgets: get a" "string from a stream." "" gets(3S) .xx "" "puts, fputs: put a" "string on a stream." "" puts(3S) .xx "" "bcopy, bcmp, bzero, ffs: bit and byte" "string operations." "" bstring(3) .xx "" "strncmp, strcpy, strncpy, strlen, index, rindex:" "string operations." "strcat, strncat, strcmp," string(3) .xx "" "extract strings from C programs to implement shared" "strings." "xstr:" xstr(1) .xx "other binary, file." "" "strings: find the printable strings in a object, or" "" strings(1) .xx "strings." "xstr: extract" "strings from C programs to implement shared" "" xstr(1) .xx "" "strings: find the printable" "strings in a object, or other binary, file." "" strings(1) .xx "" "basename:" "strip filename affixes." "" basename(1) .xx "" "" "strip: remove symbols and relocation bits." "" strip(1) .xx "" "strcat, strncat, strcmp, strncmp, strcpy, strncpy," "strlen, index, rindex: string operations." "" string(3) .xx "index, rindex: string operations." "strcat," "strncat, strcmp, strncmp, strcpy, strncpy, strlen," "" string(3) .xx "string operations." "strcat, strncat, strcmp," "strncmp, strcpy, strncpy, strlen, index, rindex:" "" string(3) .xx "" "strcat, strncat, strcmp, strncmp, strcpy," "strncpy, strlen, index, rindex: string operations." "" string(3) .xx "" "" "struct: structure Fortran programs." "" struct(1) .xx "" "struct:" "structure Fortran programs." "" struct(1) .xx "" "" "stty, gtty: set and get terminal state (defunct)." "" stty(3C) .xx "" "" "stty: set terminal options." "" stty(1) .xx "document." "" "style: analyze surface characteristics of a" "" style(1) .xx "" "" "su: substitute user id temporarily." "" su(1) .xx "" "alarm: execute a" "subroutine after a specified time." "" alarm(3F) .xx "" "fetch, store, delete, firstkey, nextkey: data base" "subroutines." "dbminit," dbm(3X) .xx "" "dbm_nextkey, dbm_error, dbm_clearerr: data base" "subroutines." "/dbm_store, dbm_delete, dbm_firstkey," ndbm(3) .xx "" "lib2648:" "subroutines for the HP 2648 graphics terminal." "" lib2648(3X) .xx "" "su:" "substitute user id temporarily." "" su(1) .xx "" "sccs: front end for the SCCS" "subsystem." "" sccs(1) .xx "" "sum:" "sum and count blocks in a file." "" sum(1) .xx "" "" "sum: sum and count blocks in a file." "" sum(1) .xx "" "du:" "summarize disk usage." "" du(1) .xx "" "quot:" "summarize file system ownership." "" quot(8) .xx "" "repquota:" "summarize quotas for a file system." "" repquota(8) .xx "" "sync: update the" "super block." "" sync(8) .xx "" "update: periodically update the" "super block." "" update(8) .xx "" "sync: update" "super-block." "" sync(2) .xx "" "suspend: suspend a shell, resuming its" "superior." "" csh(1) .xx "" "inetd: internet" "``super\-server''." "" inetd(8) .xx "" "intro: introduction to special files and hardware" "support." "" intro(4) .xx "" "style: analyze" "surface characteristics of a document." "" style(1) .xx "" "suspend:" "suspend a shell, resuming its superior." "" csh(1) .xx "" "sleep:" "suspend execution for an interval." "" sleep(1) .xx "" "sleep:" "suspend execution for an interval." "" sleep(3F) .xx "" "sleep:" "suspend execution for interval." "" sleep(3) .xx "" "usleep:" "suspend execution for interval." "" usleep(3) .xx "" "" "suspend: suspend a shell, resuming its superior." "" csh(1) .xx "interface." "ps: Evans and" "Sutherland Picture System 2 graphics device" "" ps(4) .xx "" "" "swab: swap bytes." "" swab(3) .xx "" "swab:" "swap bytes." "" swab(3) .xx "" "swapon: add a" "swap device for interleaved paging/swapping." "" swapon(2) .xx "paging/swapping." "" "swapon: add a swap device for interleaved" "" swapon(2) .xx "swapping." "" "swapon: specify additional device for paging and" "" swapon(8) .xx "" "swapon: specify additional device for paging and" "swapping." "" swapon(8) .xx "" "breaksw: exit from" "switch." "" csh(1) .xx "" "case: selector in" "switch." "" csh(1) .xx "" "default: catchall clause in" "switch." "" csh(1) .xx "" "endsw: terminate" "switch." "" csh(1) .xx "" "" "switch: multi-way command branch." "" csh(1) .xx "" "dbx: dbx" "symbol table information." "" dbx(5) .xx "" "stab:" "symbol table types." "" stab(5) .xx "" "readlink: read value of a" "symbolic link." "" readlink(2) .xx "" "symlink: make" "symbolic link to a file." "" symlink(2) .xx "" "strip: remove" "symbols and relocation bits." "" strip(1) .xx "" "" "symlink: make symbolic link to a file." "" symlink(2) .xx "" "" "symorder: rearrange name list." "" symorder(1) .xx "" "" "sync: update super-block." "" sync(2) .xx "" "" "sync: update the super block." "" sync(8) .xx "" "adjtime: correct the time to allow" "synchronization of the system clock." "" adjtime(2) .xx "disk." "fsync:" "synchronize a file's in-core state with that on" "" fsync(2) .xx "" "select:" "synchronous I/O multiplexing." "" select(2) .xx "" "csh: a shell (command interpreter) with C-like" "syntax." "" csh(1) .xx "" "L." "sys: UUCP remote host description file." "" L.sys(5) .xx "" "" "syscall: indirect system call." "" syscall(2) .xx "" "perror," "sys_errlist, sys_nerr: system error messages." "" perror(3) .xx "terminal." "" "sysline: display system status on status line of a" "" sysline(1) .xx "system log." "" "syslog, openlog, closelog, setlogmask: control" "" syslog(3) .xx "" "" "syslogd: log systems messages." "" syslogd(8) .xx "" "perror, sys_errlist," "sys_nerr: system error messages." "" perror(3) .xx "" "psignal," "sys_siglist: system signal messages." "" psignal(3) .xx "" "" "systat: display system statistics on a crt." "" systat(1) .xx "" "hy: Network" "Systems Hyperchannel interface." "" hy(4) .xx "" "syslogd: log" "systems messages." "" syslogd(8) .xx "" "kgmon: generate a dump of the operating" "system's profile buffers." "" kgmon(8) .xx "" "ns: Xerox Network" "Systems(tm) protocol family." "" ns(4F) .xx "" "rehash: recompute command hash" "table." "" csh(1) .xx "" "unhash: discard command hash" "table." "" csh(1) .xx "" "mkhosts: generate hashed host" "table." "" mkhosts(8) .xx "" "mkpasswd: generate hashed password" "table." "" mkpasswd(8) .xx "" "mtab: mounted file system" "table." "" mtab(5) .xx "" "vwidth: make troff width" "table for a font." "" vwidth(1) .xx "" "dbx: dbx symbol" "table information." "" dbx(5) .xx "" "getdtablesize: get descriptor" "table size." "" getdtablesize(2) .xx "" "stab: symbol" "table types." "" stab(5) .xx "" "htable: convert NIC standard format host" "tables." "" htable(8) .xx "" "route: manually manipulate the routing" "tables." "" route(8C) .xx "" "tbl: format" "tables for nroff or troff." "" tbl(1) .xx "" "gettable: get NIC format host" "tables from a host." "" gettable(8C) .xx "" "tabs: set terminal" "tabs." "" tabs(1) .xx "" "" "tabs: set terminal tabs." "" tabs(1) .xx "" "expand, unexpand: expand" "tabs to spaces, and vice versa." "" expand(1) .xx "" "ctags: create a" "tags file." "" ctags(1) .xx "" "" "tail: deliver the last part of a file." "" tail(1) .xx "" "" "talk: talk to another user." "" talk(1) .xx "" "talk:" "talk to another user." "" talk(1) .xx "" "" "talkd: remote user communication server." "" talkd(8C) .xx "functions and their inverses." "sin, cos," "tan, asin, acos, atan, atan2: trigonometric" "" sin(3M) .xx "" "sinh, cosh," "tanh: hyperbolic functions." "" sinh(3M) .xx "" "tcopy: copy a mag" "tape." "" tcopy(1) .xx "" "tp: manipulate" "tape archive." "" tp(1) .xx "" "tar:" "tape archive file format." "" tar(5) .xx "" "tar:" "tape archiver." "" tar(1) .xx "" "ut: UNIBUS TU45 tri-density" "tape drive interface." "" ut(4) .xx "" "tp: DEC/mag" "tape formats." "" tp(5) .xx "" "tclose, tread, twrite, trewin, tskipf, tstate: f77" "tape I/O." "topen," topen(3F) .xx "" "mt: magnetic" "tape manipulating program." "" mt(1) .xx "" "" "tar: tape archive file format." "" tar(5) .xx "" "" "tar: tape archiver." "" tar(1) .xx "" "" "tb: line discipline for digitizing devices." "" tb(4) .xx "" "deroff: remove nroff, troff," "tbl and eqn constructs." "" deroff(1) .xx "" "" "tbl: format tables for nroff or troff." "" tbl(1) .xx "" "" "tc: photoypesetter simulator." "" tc(1) .xx "tape I/O." "topen," "tclose, tread, twrite, trewin, tskipf, tstate: f77" "" topen(3F) .xx "" "" "tcopy: copy a mag tape." "" tcopy(1) .xx "" "" "tcp: Internet Transmission Control Protocol." "" tcp(4P) .xx "" "" "tee: pipe fitting." "" tee(1) .xx "" "tk: paginator for the" "Tektronix 4014." "" tk(1) .xx "" "last: indicate last logins of users and" "teletypes." "" last(1) .xx "" "index, rindex, lnblnk, len:" "tell about character objects." "" index(3F) .xx "operations." "opendir, readdir," "telldir, seekdir, rewinddir, closedir: directory" "" directory(3) .xx "" "telnet: user interface to the" "TELNET protocol." "" telnet(1C) .xx "" "telnetd: DARPA" "TELNET protocol server." "" telnetd(8C) .xx "" "" "telnet: user interface to the TELNET protocol." "" telnet(1C) .xx "" "" "telnetd: DARPA TELNET protocol server." "" telnetd(8C) .xx "" "su: substitute user id" "temporarily." "" su(1) .xx "" "signals invalid floating-point operations on a VAX" "(temporary)." "infnan:" infnan(3M) .xx "" "" "term: conventional names for terminals." "" term(7) .xx "" "" "termcap: terminal capability data base." "" termcap(5) .xx "" "lib2648: subroutines for the HP 2648 graphics" "terminal." "" lib2648(3X) .xx "" "lock: reserve a" "terminal." "" lock(1) .xx "" "sysline: display system status on status line of a" "terminal." "" sysline(1) .xx "" "ttyname, isatty, ttyslot: find name of a" "terminal." "" ttyname(3) .xx "" "vhangup: virtually ``hangup'' the current control" "terminal." "" vhangup(2) .xx "" "worms: animate worms on a display" "terminal." "" worms(6) .xx "" "termcap:" "terminal capability data base." "" termcap(5) .xx "" "gettytab:" "terminal configuration data base." "" gettytab(5) .xx "" "tset:" "terminal dependent initialization." "" tset(1) .xx "" "pty: pseudo" "terminal driver." "" pty(4) .xx "" "tgetent, tgetnum, tgetflag, tgetstr, tgoto, tputs:" "terminal independent operation routines." "" termcap(3X) .xx "" "ttys:" "terminal initialization data." "" ttys(5) .xx "" "tty: general" "terminal interface." "" tty(4) .xx "" "getty: set" "terminal mode." "" getty(8) .xx "" "dmf: DMF-32," "terminal multiplexor." "" dmf(4) .xx "" "dmz: DMZ-32" "terminal multiplexor." "" dmz(4) .xx "" "tty: get" "terminal name." "" tty(1) .xx "" "stty: set" "terminal options." "" stty(1) .xx "" "ttynam, isatty: find name of a" "terminal port." "" ttynam(3F) .xx "" "clear: clear" "terminal screen." "" clear(1) .xx "" "script: make typescript of" "terminal session." "" script(1) .xx "" "stty, gtty: set and get" "terminal state (defunct)." "" stty(3C) .xx "" "tabs: set" "terminal tabs." "" tabs(1) .xx "" "term: conventional names for" "terminals." "" term(7) .xx "" "wait, wait3: wait for process to" "terminate." "" wait(2) .xx "" "wait: wait for a process to" "terminate." "" wait(3F) .xx "" "_exit:" "terminate a process." "" exit(2) .xx "output." "exit:" "terminate a process after flushing any pending" "" exit(3) .xx "" "kill:" "terminate a process with extreme prejudice." "" kill(1) .xx "" "endif:" "terminate conditional." "" csh(1) .xx "" "end:" "terminate loop." "" csh(1) .xx "" "exit:" "terminate process with status." "" exit(3F) .xx "" "endsw:" "terminate switch." "" csh(1) .xx "" "abort: abnormal" "termination." "" abort(3F) .xx "" "" "test: condition command." "" test(1) .xx "" "drtest: standalone disk" "test program." "" drtest(8) .xx "" "quiz:" "test your knowledge." "" quiz(6) .xx "" "sticky: persistent" "text and append-only directories." "" sticky(8) .xx "" "ed:" "text editor." "" ed(1) .xx "" "ex, edit:" "text editor." "" ex(1) .xx "" "jove: an interactive display-oriented" "text editor." "" jove(1) .xx "" "fmt: simple" "text formatter." "" fmt(1) .xx "" "nroff:" "text formatting." "" nroff(1) .xx "" "troff, nroff:" "text formatting and typesetting." "" troff(1) .xx "" "ms:" "text formatting macros." "" ms(7) .xx "" "" "tftp: trivial file transfer program." "" tftp(1C) .xx "" "" "tftpd: DARPA Trivial File Transfer Protocol server." "" tftpd(8C) .xx "terminal independent operation routines." "" "tgetent, tgetnum, tgetflag, tgetstr, tgoto, tputs:" "" termcap(3X) .xx "independent operation routines." "tgetent, tgetnum," "tgetflag, tgetstr, tgoto, tputs: terminal" "" termcap(3X) .xx "independent operation routines." "tgetent," "tgetnum, tgetflag, tgetstr, tgoto, tputs: terminal" "" termcap(3X) .xx "operation routines." "tgetent, tgetnum, tgetflag," "tgetstr, tgoto, tputs: terminal independent" "" termcap(3X) .xx "routines." "tgetent, tgetnum, tgetflag, tgetstr," "tgoto, tputs: terminal independent operation" "" termcap(3X) .xx "" "acos, atan, atan2: trigonometric functions and" "their inverses." "sin, cos, tan, asin," sin(3M) .xx "" "diction, explain: print wordy sentences;" "thesaurus for diction." "" diction(1) .xx "" "alarm: schedule signal after specified" "time." "" alarm(3C) .xx "" "alarm: execute a subroutine after a specified" "time." "" alarm(3F) .xx "" "at: execute commands at a later" "time." "" at(1) .xx "" "etime, dtime: return elapsed execution" "time." "" etime(3F) .xx "" "gettimeofday, settimeofday: get/set date and" "time." "" gettimeofday(2) .xx "" "shutdown: close down the system at a given" "time." "" shutdown(8) .xx "" "time, ftime: get date and" "time." "" time(3C) .xx "" "time, ctime, ltime, gmtime: return system" "time." "" time(3F) .xx "" "ualarm: schedule signal after specified" "time." "" ualarm(3) .xx "" "time:" "time a command." "" time(1) .xx "" "time:" "time command." "" csh(1) .xx "" "" "time, ctime, ltime, gmtime: return system time." "" time(3F) .xx "" "" "time, ftime: get date and time." "" time(3C) .xx "" "fdate: return date and" "time in an ASCII string." "" fdate(3F) .xx "" "idate, itime: return date or" "time in numerical form." "" idate(3F) .xx "" "profil: execution" "time profile." "" profil(2) .xx "" "timed:" "time server daemon." "" timed(8) .xx "" "" "time: time a command." "" time(1) .xx "" "" "time: time command." "" csh(1) .xx "" "adjtime: correct the" "time to allow synchronization of the system clock." "" adjtime(2) .xx "" "gmtime, asctime, timezone: convert date and" "time to ASCII." "ctime, localtime," ctime(3) .xx "" "timedc:" "timed control program." "" timedc(8) .xx "" "" "timed: time server daemon." "" timed(8) .xx "" "" "timedc: timed control program." "" timedc(8) .xx "" "getitimer, setitimer: get/set value of interval" "timer." "" getitimer(2) .xx "" "times: get process" "times." "" times(3C) .xx "" "utime: set file" "times." "" utime(3C) .xx "" "utimes: set file" "times." "" utimes(2) .xx "" "" "times: get process times." "" times(3C) .xx "" "exit, export, login, read, readonly, set, shift," "times, trap, umask, wait: command language." "/exec," sh(1) .xx "" "ctime, localtime, gmtime, asctime," "timezone: convert date and time to ASCII." "" ctime(3) .xx "" "" "tip, cu: connect to a remote system." "" tip(1C) .xx "" "" "tk: paginator for the Tektronix 4014." "" tk(1) .xx "" "" "tm: TM-11/TE-10 magtape interface." "" tm(4) .xx "" "ht:" "TM-03/TE-16,TU-45,TU-77 MASSBUS magtape interface." "" ht(4) .xx "" "tm:" "TM-11/TE-10 magtape interface." "" tm(4) .xx "" "mt:" "TM78/TU-78 MASSBUS magtape interface." "" mt(4) .xx "" "" "tmscp: DEC TMSCP magtape interface." "" tmscp(4) .xx "" "tmscp: DEC" "TMSCP magtape interface." "" tmscp(4) .xx "" "" "tn3270: full-screen remote login to IBM VM/CMS." "" tn3270(1) .xx "" "isgraph, iscntrl, isascii, toupper, tolower," "toascii: character classification macros." "/isprint," ctype(3) .xx "" "popen, pclose: initiate I/O" "to/from a process." "" popen(3) .xx "" "/isprint, isgraph, iscntrl, isascii, toupper," "tolower, toascii: character classification macros." "" ctype(3) .xx "tstate: f77 tape I/O." "" "topen, tclose, tread, twrite, trewin, tskipf," "" topen(3F) .xx "" "tsort:" "topological sort." "" tsort(1) .xx "" "" "touch: update date last modified of a file." "" touch(1) .xx "" "/ispunct, isprint, isgraph, iscntrl, isascii," "toupper, tolower, toascii: character classification/" "" ctype(3) .xx "" "" "tp: DEC/mag tape formats." "" tp(5) .xx "" "" "tp: manipulate tape archive." "" tp(1) .xx "" "tgetent, tgetnum, tgetflag, tgetstr, tgoto," "tputs: terminal independent operation routines." "" termcap(3X) .xx "" "" "tr: translate characters." "" tr(1) .xx "" "ptrace: process" "trace." "" ptrace(2) .xx "" "trpt: transliterate protocol" "trace." "" trpt(8C) .xx "" "trsp: transliterate sequenced packet protocol" "trace." "" trsp(8C) .xx "" "goto: command" "transfer." "" csh(1) .xx "" "uucico, uucpd:" "transfer files queued by uucp or uux." "" uucico(8C) .xx "" "ftp: ARPANET file" "transfer program." "" ftp(1C) .xx "" "tftp: trivial file" "transfer program." "" tftp(1C) .xx "" "ftpd: DARPA Internet File" "Transfer Protocol server." "" ftpd(8C) .xx "" "tftpd: DARPA Trivial File" "Transfer Protocol server." "" tftpd(8C) .xx "" "tr:" "translate characters." "" tr(1) .xx "" "ad: Data" "Translation A/D converter." "" ad(4) .xx "" "pi: Pascal interpreter code" "translator." "" pi(1) .xx "" "trpt:" "transliterate protocol trace." "" trpt(8C) .xx "" "trsp:" "transliterate sequenced packet protocol trace." "" trsp(8C) .xx "" "tcp: Internet" "Transmission Control Protocol." "" tcp(4P) .xx "" "uuencode, uudecode: encode/decode a binary file for" "transmission via mail." "" uuencode(1C) .xx "" "trpfpe, fpecnt:" "trap and repair floating point faults." "" trpfpe(3F) .xx "" "trapov:" "trap and repair floating point overflow." "" trapov(3F) .xx "" "traper:" "trap arithmetic errors." "" traper(3F) .xx "" "export, login, read, readonly, set, shift, times," "trap, umask, wait: command language." "/exec, exit," sh(1) .xx "" "" "traper: trap arithmetic errors." "" traper(3F) .xx "" "" "trapov: trap and repair floating point overflow." "" trapov(3F) .xx "I/O." "topen, tclose," "tread, twrite, trewin, tskipf, tstate: f77 tape" "" topen(3F) .xx "" "" "trek: trekkie game." "" trek(6) .xx "" "trek:" "trekkie game." "" trek(6) .xx "" "topen, tclose, tread, twrite," "trewin, tskipf, tstate: f77 tape I/O." "" topen(3F) .xx "" "ut: UNIBUS TU45" "tri-density tape drive interface." "" ut(4) .xx "" "sin, cos, tan, asin, acos, atan, atan2:" "trigonometric functions and their inverses." "" sin(3M) .xx "" "tftp:" "trivial file transfer program." "" tftp(1C) .xx "" "tftpd: DARPA" "Trivial File Transfer Protocol server." "" tftpd(8C) .xx "" "tbl: format tables for nroff or" "troff." "" tbl(1) .xx "" "Lisp programs to be printed with nroff, vtroff, or" "troff." "vlp: Format" vlp(1) .xx "" "" "troff, nroff: text formatting and typesetting." "" troff(1) .xx "" "deroff: remove nroff," "troff, tbl and eqn constructs." "" deroff(1) .xx "" "vwidth: make" "troff width table for a font." "" vwidth(1) .xx "" "battlestar: a" "tropical adventure game." "" battlestar(6) .xx "faults." "" "trpfpe, fpecnt: trap and repair floating point" "" trpfpe(3F) .xx "" "" "trpt: transliterate protocol trace." "" trpt(8C) .xx "trace." "" "trsp: transliterate sequenced packet protocol" "" trsp(8C) .xx "" "" "true, false: provide truth values." "" true(1) .xx "" "false," "true: provide truth values." "" false(1) .xx "" "truncate:" "truncate a file to a specified length." "" truncate(2) .xx "" "" "truncate: truncate a file to a specified length." "" truncate(2) .xx "" "false, true: provide" "truth values." "" false(1) .xx "" "true, false: provide" "truth values." "" true(1) .xx "" "" "ts: TS-11 magtape interface." "" ts(4) .xx "" "ts:" "TS-11 magtape interface." "" ts(4) .xx "" "" "tset: terminal dependent initialization." "" tset(1) .xx "" "topen, tclose, tread, twrite, trewin," "tskipf, tstate: f77 tape I/O." "" topen(3F) .xx "" "" "tsort: topological sort." "" tsort(1) .xx "" "topen, tclose, tread, twrite, trewin, tskipf," "tstate: f77 tape I/O." "" topen(3F) .xx "" "" "tty: general terminal interface." "" tty(4) .xx "" "" "tty: get terminal name." "" tty(1) .xx "" "" "ttynam, isatty: find name of a terminal port." "" ttynam(3F) .xx "" "" "ttyname, isatty, ttyslot: find name of a terminal." "" ttyname(3) .xx "" "getttyent, getttynam, setttyent, endttyent: get" "ttys file entry." "" getttyent(3) .xx "" "" "ttys: terminal initialization data." "" ttys(5) .xx "" "ttyname, isatty," "ttyslot: find name of a terminal." "" ttyname(3) .xx "interface." "" "tu: VAX-11/730 and VAX-11/750 TU58 console cassette" "" tu(4) .xx "" "ut: UNIBUS" "TU45 tri-density tape drive interface." "" ut(4) .xx "" "ht: TM-03/TE-16," "TU-45,TU-77 MASSBUS magtape interface." "" ht(4) .xx "" "tu: VAX-11/730 and VAX-11/750" "TU58 console cassette interface." "" tu(4) .xx "" "uu:" "TU58/DECtape II UNIBUS cassette interface." "" uu(4) .xx "" "ht: TM-03/TE-16,TU-45," "TU-77 MASSBUS magtape interface." "" ht(4) .xx "" "tunefs:" "tune up an existing file system." "" tunefs(8) .xx "" "" "tunefs: tune up an existing file system." "" tunefs(8) .xx "" "topen, tclose, tread," "twrite, trewin, tskipf, tstate: f77 tape I/O." "" topen(3F) .xx "" "file: determine file" "type." "" file(1) .xx "" "stab: symbol table" "types." "" stab(5) .xx "" "types: primitive system data" "types." "" types(5) .xx "" "" "types: primitive system data types." "" types(5) .xx "" "script: make" "typescript of terminal session." "" script(1) .xx "" "man: macros to" "typeset manual." "" man(7) .xx "" "eqn, neqn, checkeq:" "typeset mathematics." "" eqn(1) .xx "" "troff, nroff: text formatting and" "typesetting." "" troff(1) .xx "" "" "ualarm: schedule signal after specified time." "" ualarm(3) .xx "" "" "uda: UDA-50 disk controller interface." "" uda(4) .xx "" "uda:" "UDA-50 disk controller interface." "" uda(4) .xx "" "" "udp: Internet User Datagram Protocol." "" udp(4P) .xx "" "getpw: get name from" "uid." "" getpw(3C) .xx "" "" "ul: do underlining." "" ul(1) .xx "" "" "umask: change or display file creation mask." "" csh(1) .xx "" "" "umask: set file creation mode mask." "" umask(2) .xx "" "login, read, readonly, set, shift, times, trap," "umask, wait: command language." "/exec, exit, export," sh(1) .xx "" "mount," "umount: mount and dismount file system." "" mount(8) .xx "" "mount," "umount: mount or remove file system." "" mount(2) .xx "" "" "unalias: remove aliases." "" csh(1) .xx "" "compress," "uncompress, zcat: compress and expand data." "" compress(1) .xx "" "ul: do" "underlining." "" ul(1) .xx "" "expand," "unexpand: expand tabs to spaces, and vice versa." "" expand(1) .xx "" "" "ungetc: push character back into input stream." "" ungetc(3S) .xx "" "" "unhash: discard command hash table." "" csh(1) .xx "" "uu: TU58/DECtape II" "UNIBUS cassette interface." "" uu(4) .xx "" "up:" "unibus storage module controller/drives." "" up(4) .xx "" "ut:" "UNIBUS TU45 tri-density tape drive interface." "" ut(4) .xx "" "" "unifdef: remove ifdef'ed lines." "" unifdef(1) .xx "" "" "uniq: report repeated lines in a file." "" uniq(1) .xx "" "mktemp: make a" "unique file name." "" mktemp(3) .xx "" "gethostid, sethostid: get/set" "unique identifier of current host." "" gethostid(2) .xx "" "flush: flush output to a logical" "unit." "" flush(3F) .xx "" "fseek, ftell: reposition a file on a logical" "unit." "" fseek(3F) .xx "" "getc, fgetc: get a character from a logical" "unit." "" getc(3F) .xx "" "putc, fputc: write a character to a fortran logical" "unit." "" putc(3F) .xx "" "dn: DN-11 autocall" "unit interface." "" dn(4) .xx "" "" "units: conversion program." "" units(1) .xx "" "learn: computer aided instruction about" "UNIX." "" learn(1) .xx "" "reboot:" "UNIX bootstrapping procedures." "" reboot(8) .xx "" "system: execute a" "UNIX command." "" system(3F) .xx "" "uux: unix to" "unix command execution." "" uux(1C) .xx "" "uucp: unix to" "unix copy." "" uucp(1C) .xx "" "mtio:" "UNIX magtape interface." "" mtio(4) .xx "" "uux:" "unix to unix command execution." "" uux(1C) .xx "" "uucp:" "unix to unix copy." "" uucp(1C) .xx "" "" "unlimit: remove resource limitiations." "" csh(1) .xx "" "rmdir, rm: remove" "(unlink) directories or files." "" rmdir(1) .xx "" "rm, rmdir: remove" "(unlink) files or directories." "" rm(1) .xx "" "" "unlink: remove a directory entry." "" unlink(3F) .xx "" "" "unlink: remove directory entry." "" unlink(2) .xx "" "" "unset: discard shell variables." "" csh(1) .xx "" "" "unsetenv: remove environment variables." "" csh(1) .xx "" "uptime: show how long system has been" "up." "" uptime(1) .xx "" "tunefs: tune" "up an existing file system." "" tunefs(8) .xx "" "" "up: unibus storage module controller/drives." "" up(4) .xx "" "touch:" "update date last modified of a file." "" touch(1) .xx "" "" "update: periodically update the super block." "" update(8) .xx "" "sync:" "update super-block." "" sync(2) .xx "" "sync:" "update the super block." "" sync(8) .xx "" "update: periodically" "update the super block." "" update(8) .xx "" "" "uptime: show how long system has been up." "" uptime(1) .xx "" "du: summarize disk" "usage." "" du(1) .xx "" "quota: display disc" "usage and limits." "" quota(1) .xx "" "what: show what versions of object modules were" "used to construct a file." "" what(1) .xx "" "miscellaneous: miscellaneous" "useful information pages." "" intro(7) .xx "" "login: login new" "user." "" csh(1) .xx "" "talk: talk to another" "user." "" talk(1) .xx "" "write: write to another" "user." "" write(1) .xx "" "seteuid, setruid, setgid, setegid, setrgid: set" "user and group ID." "setuid," setuid(3) .xx "" "talkd: remote" "user communication server." "" talkd(8C) .xx "" "udp: Internet" "User Datagram Protocol." "" udp(4P) .xx "" "environ:" "user environment." "" environ(7) .xx "" "whoami: print effective current" "user id." "" whoami(1) .xx "" "su: substitute" "user id temporarily." "" su(1) .xx "" "getuid, geteuid: get" "user identity." "" getuid(2) .xx "" "setreuid: set real and effective" "user ID's." "" setreuid(2) .xx "" "finger:" "user information lookup program." "" finger(1) .xx "" "fingerd: remote" "user information server." "" fingerd(8C) .xx "" "telnet:" "user interface to the TELNET protocol." "" telnet(1C) .xx "" "whois: DARPA Internet" "user name directory service." "" whois(1) .xx "" "getuid, getgid: get" "user or group ID of the caller." "" getuid(3F) .xx "" "edquota: edit" "user quotas." "" edquota(8) .xx "" "getusershell, setusershell, endusershell: get legal" "user shells." "" getusershell(3) .xx "" "" "USERFILE: UUCP pathname permissions file." "" USERFILE(5) .xx "" "adduser: procedure for adding new" "users." "" adduser(8) .xx "" "binmail: send or receive mail among" "users." "" binmail(1) .xx "" "wall: write to all" "users." "" wall(1) .xx "" "last: indicate last logins of" "users and teletypes." "" last(1) .xx "" "" "users: compact list of users who are on the system." "" users(1) .xx "" "getlog: get" "user's login name." "" getlog(3F) .xx "" "users: compact list of" "users who are on the system." "" users(1) .xx "" "" "usleep: suspend execution for interval." "" usleep(3) .xx "" "" "ut: UNIBUS TU45 tri-density tape drive interface." "" ut(4) .xx "" "getrusage: get information about resource" "utilization." "" getrusage(2) .xx "" "vtimes: get information about resource" "utilization." "" vtimes(3C) .xx "" "" "utime: set file times." "" utime(3C) .xx "" "" "utimes: set file times." "" utimes(2) .xx "" "" "utmp, wtmp: login records." "" utmp(5) .xx "" "" "uu: TU58/DECtape II UNIBUS cassette interface." "" uu(4) .xx "uux." "" "uucico, uucpd: transfer files queued by uucp or" "" uucico(8C) .xx "" "" "uuclean: uucp spool directory clean-up." "" uuclean(8C) .xx "" "rmail: handle remote mail received via" "uucp." "" rmail(1) .xx "" "L-devices:" "UUCP device description file." "" L-devices(5) .xx "" "uuxqt:" "UUCP execution file interpreter." "" uuxqt(8C) .xx "" "L.aliases:" "UUCP hostname alias file." "" L.aliases(5) .xx "" "uuname: list names of" "UUCP hosts." "" uuname(1C) .xx "" "uulog: display" "UUCP log files." "" uulog(1C) .xx "" "uucico, uucpd: transfer files queued by" "uucp or uux." "" uucico(8C) .xx "" "USERFILE:" "UUCP pathname permissions file." "" USERFILE(5) .xx "" "L-dialcodes:" "UUCP phone number index file." "" L-dialcodes(5) .xx "" "uuq: examine or manipulate the" "uucp queue." "" uuq(1C) .xx "" "L.cmds:" "UUCP remote command permissions file." "" L.cmds(5) .xx "" "L.sys:" "UUCP remote host description file." "" L.sys(5) .xx "" "uupoll: poll a remote" "UUCP site." "" uupoll(8C) .xx "" "uuclean:" "uucp spool directory clean-up." "" uuclean(8C) .xx "" "uusnap: show snapshot of the" "UUCP system." "" uusnap(8C) .xx "" "" "uucp: unix to unix copy." "" uucp(1C) .xx "" "uucico," "uucpd: transfer files queued by uucp or uux." "" uucico(8C) .xx "transmission via mail." "uuencode," "uudecode: encode/decode a binary file for" "" uuencode(1C) .xx "" "uuencode: format of an encoded" "uuencode file." "" uuencode(5) .xx "" "" "uuencode: format of an encoded uuencode file." "" uuencode(5) .xx "transmission via mail." "" "uuencode, uudecode: encode/decode a binary file for" "" uuencode(1C) .xx "" "" "uulog: display UUCP log files." "" uulog(1C) .xx "" "" "uuname: list names of UUCP hosts." "" uuname(1C) .xx "" "" "uupoll: poll a remote UUCP site." "" uupoll(8C) .xx "" "" "uuq: examine or manipulate the uucp queue." "" uuq(1C) .xx "" "" "uusend: send a file to a remote host." "" uusend(1C) .xx "" "" "uusnap: show snapshot of the UUCP system." "" uusnap(8C) .xx "" "uucico, uucpd: transfer files queued by uucp or" "uux." "" uucico(8C) .xx "" "" "uux: unix to unix command execution." "" uux(1C) .xx "" "" "uuxqt: UUCP execution file interpreter." "" uuxqt(8C) .xx "" "" "va: Benson-Varian interface." "" va(4) .xx "" "vacation: return ``I am on" "vacation'' indication." "" vacation(1) .xx "" "" "vacation: return ``I am on vacation'' indication." "" vacation(1) .xx "" "" "valloc: aligned memory allocator." "" valloc(3C) .xx "" "abs: integer absolute" "value." "" abs(3) .xx "" "hypot, cabs: Euclidean distance, complex absolute" "value." "" hypot(3M) .xx "functions." "fabs, floor, ceil, rint: absolute" "value, floor, ceiling, and round-to-nearest" "" floor(3M) .xx "" "getenv:" "value for environment name." "" getenv(3) .xx "" "readlink: read" "value of a symbolic link." "" readlink(2) .xx "" "getenv: get" "value of environment variables." "" getenv(3F) .xx "" "getitimer, setitimer: get/set" "value of interval timer." "" getitimer(2) .xx "" "set: change" "value of shell variable." "" csh(1) .xx "" "false, true: provide truth" "values." "" false(1) .xx "" "dflmin, dflmax, dffrac, inmax: return extreme" "values." "flmin, flmax, ffrac," flmin(3F) .xx "" "rand, drand, irand: return random" "values." "" rand(3F) .xx "" "true, false: provide truth" "values." "" true(1) .xx "" "htonl, htons, ntohl, ntohs: convert" "values between host and network byte order." "" byteorder(3N) .xx "" "" "varargs: variable argument list." "" varargs(3) .xx "" "set: change value of shell" "variable." "" csh(1) .xx "" "varargs:" "variable argument list." "" varargs(3) .xx "" "setenv: set" "variable in environment." "" csh(1) .xx "" "@: arithmetic on shell" "variables." "" csh(1) .xx "" "unset: discard shell" "variables." "" csh(1) .xx "" "unsetenv: remove environment" "variables." "" csh(1) .xx "" "getenv: get value of environment" "variables." "" getenv(3F) .xx "" "crl:" "VAX 8600 console RL02 interface." "" crl(4) .xx "" "signals invalid floating-point operations on a" "VAX (temporary)." "infnan:" infnan(3M) .xx "" "as:" "VAX-11 assembler." "" as(1) .xx "" "cons:" "VAX-11 console interface." "" cons(4) .xx "interface." "tu:" "VAX-11/730 and VAX-11/750 TU58 console cassette" "" tu(4) .xx "" "tu: VAX-11/730 and" "VAX-11/750 TU58 console cassette interface." "" tu(4) .xx "" "assert: program" "verification." "" assert(3) .xx "" "lint: a C program" "verifier." "" lint(1) .xx "" "expand, unexpand: expand tabs to spaces, and vice" "versa." "" expand(1) .xx "" "vfont: font formats for the Benson-Varian or" "Versatec." "" vfont(5) .xx "" "vp:" "Versatec interface." "" vp(4) .xx "" "hangman: Computer" "version of the game hangman." "" hangman(6) .xx "file." "what: show what" "versions of object modules were used to construct a" "" what(1) .xx "Versatec." "" "vfont: font formats for the Benson-Varian or" "" vfont(5) .xx "efficient way." "" "vfork: spawn new process in a virtual memory" "" vfork(2) .xx "" "" "vgrind: grind nice listings of programs." "" vgrind(1) .xx "" "" "vgrindefs: vgrind's language definition data base." "" vgrindefs(5) .xx "" "vgrindefs:" "vgrind's language definition data base." "" vgrindefs(5) .xx "terminal." "" "vhangup: virtually ``hangup'' the current control" "" vhangup(2) .xx "on ex." "" "vi: screen oriented (visual) display editor based" "" vi(1) .xx "" "encode/decode a binary file for transmission" "via mail." "uuencode, uudecode:" uuencode(1C) .xx "" "rmail: handle remote mail received" "via uucp." "" rmail(1) .xx "" "expand, unexpand: expand tabs to spaces, and" "vice versa." "" expand(1) .xx "" "more, page: file perusal filter for crt" "viewing." "" more(1) .xx "" "robots: fight off" "villainous robots." "" robots(6) .xx "" "" "vipw: edit the password file." "" vipw(8) .xx "" "vfork: spawn new process in a" "virtual memory efficient way." "" vfork(2) .xx "" "vmstat: report" "virtual memory statistics." "" vmstat(1) .xx "" "vhangup:" "virtually ``hangup'' the current control terminal." "" vhangup(2) .xx "" "vi: screen oriented" "(visual) display editor based on ex." "" vi(1) .xx "consumption." "" "vlimit: control maximum system resource" "" vlimit(3C) .xx "vtroff, or troff." "" "vlp: Format Lisp programs to be printed with nroff," "" vlp(1) .xx "" "tn3270: full-screen remote login to IBM" "VM/CMS." "" tn3270(1) .xx "" "" "vmstat: report virtual memory statistics." "" vmstat(1) .xx "" "" "vnews: read news articles." "" vnews(1) .xx "" "fs, inode: format of file system" "volume." "" fs(5) .xx "" "" "vp: Versatec interface." "" vp(4) .xx "" "" "vtimes: get information about resource utilization." "" vtimes(3C) .xx "" "vlp: Format Lisp programs to be printed with nroff," "vtroff, or troff." "" vlp(1) .xx "" "" "vv: Proteon proNET 10 Megabit ring." "" vv(4) .xx "" "" "vwidth: make troff width table for a font." "" vwidth(1) .xx "" "" "w: who is on and what they are doing." "" w(1) .xx "" "" "wait: await completion of process." "" wait(1) .xx "" "read, readonly, set, shift, times, trap, umask," "wait: command language." "/exec, exit, export, login," sh(1) .xx "" "wait:" "wait for a process to terminate." "" wait(3F) .xx "" "wait:" "wait for background processes to complete." "" csh(1) .xx "" "sigpause: atomically release blocked signals and" "wait for interrupt." "" sigpause(2) .xx "" "wait, wait3:" "wait for process to terminate." "" wait(2) .xx "" "" "wait: wait for a process to terminate." "" wait(3F) .xx "" "" "wait: wait for background processes to complete." "" csh(1) .xx "" "" "wait, wait3: wait for process to terminate." "" wait(2) .xx "" "wait," "wait3: wait for process to terminate." "" wait(2) .xx "" "atq: print the queue of jobs" "waiting to be run." "" atq(1) .xx "" "" "wall: write to all users." "" wall(1) .xx "" "" "wc: word count." "" wc(1) .xx "" "what: show what versions of object modules" "were used to construct a file." "" what(1) .xx "" "whatis: describe" "what a command is." "" whatis(1) .xx "" "crash:" "what happens when the system crashes." "" crash(8V) .xx "used to construct a file." "" "what: show what versions of object modules were" "" what(1) .xx "" "w: who is on and" "what they are doing." "" w(1) .xx "construct a file." "what: show" "what versions of object modules were used to" "" what(1) .xx "" "" "whatis: describe what a command is." "" whatis(1) .xx "" "crash: what happens" "when the system crashes." "" crash(8V) .xx "" "leave: remind you" "when you have to leave." "" leave(1) .xx "program." "" "whereis: locate source, binary, and or manual for" "" whereis(1) .xx "paths (\fIcsh\fR only)." "" "which: locate a program file including aliases and" "" which(1) .xx "exec, exit, export, login,/" "sh, for, case, if," "while, \fB:\fP, \fB.\fP, break, continue, cd, eval," "" sh(1) .xx "" "" "while: repeat commands conditionally." "" csh(1) .xx "" "break: exit" "while/foreach loop." "" csh(1) .xx "" "users: compact list of users" "who are on the system." "" users(1) .xx "" "from:" "who is my mail from?." "" from(1) .xx "" "w:" "who is on and what they are doing." "" w(1) .xx "" "who:" "who is on the system." "" who(1) .xx "" "biff: be notified if mail arrives and" "who it is from." "" biff(1) .xx "" "" "who: who is on the system." "" who(1) .xx "" "" "whoami: print effective current user id." "" whoami(1) .xx "" "" "whois: DARPA Internet user name directory service." "" whois(1) .xx "" "rwho:" "who's logged in on local machines." "" rwho(1C) .xx "" "fold: fold long lines for finite" "width output device." "" fold(1) .xx "" "vwidth: make troff" "width table for a font." "" vwidth(1) .xx "" "window:" "window environment." "" window(1) .xx "" "" "window: window environment." "" window(1) .xx "" "fastboot, fasthalt: reboot/halt the system" "without checking the disks." "" fastboot(8) .xx "" "sail: multi-user" "wooden ships and iron men." "" sail(6) .xx "" "wc:" "word count." "" wc(1) .xx "" "getc, getchar, fgetc, getw: get character or" "word from stream." "" getc(3S) .xx "" "putc, putchar, fputc, putw: put character or" "word on a stream." "" putc(3S) .xx "" "diction, explain: print" "wordy sentences; thesaurus for diction." "" diction(1) .xx "" "cd: change" "working directory." "" cd(1) .xx "" "chdir: change current" "working directory." "" chdir(2) .xx "" "getcwd: get pathname of current" "working directory." "" getcwd(3F) .xx "" "pwd:" "working directory name." "" pwd(1) .xx "" "getwd: get current" "working directory pathname." "" getwd(3) .xx "" "worm: Play the growing" "worm game." "" worm(6) .xx "" "" "worm: Play the growing worm game." "" worm(6) .xx "" "" "worms: animate worms on a display terminal." "" worms(6) .xx "" "worms: animate" "worms on a display terminal." "" worms(6) .xx "" "putc, fputc:" "write a character to a fortran logical unit." "" putc(3F) .xx "" "write, writev:" "write output." "" write(2) .xx "" "wall:" "write to all users." "" wall(1) .xx "" "write:" "write to another user." "" write(1) .xx "" "" "write: write to another user." "" write(1) .xx "" "" "write, writev: write output." "" write(2) .xx "" "write," "writev: write output." "" write(2) .xx "" "open: open a file for reading or" "writing, or create a new file." "" open(2) .xx "" "utmp," "wtmp: login records." "" utmp(5) .xx "" "" "wump: the game of hunt-the-wumpus." "" wump(6) .xx "" "ddn: DDN Standard Mode" "X.25 IMP interface." "" ddn(4) .xx "" "en:" "Xerox 3 Mb/s Ethernet interface." "" en(4) .xx "" "idp:" "Xerox Internet Datagram Protocol." "" idp(4P) .xx "" "ns:" "Xerox Network Systems(tm) protocol family." "" ns(4F) .xx "" "ns_addr, ns_ntoa:" "Xerox NS(tm) address conversion routines." "" ns(3N) .xx "" "spp:" "Xerox Sequenced Packet Protocol." "" spp(4P) .xx "" "xsend," "xget, enroll: secret mail." "" xsend(1) .xx "" "" "XNSrouted: NS Routing Information Protocol daemon." "" XNSrouted(8C) .xx "" "bit: and, or," "xor, not, rshift, lshift bitwise functions." "" bit(3F) .xx "" "" "xsend, xget, enroll: secret mail." "" xsend(1) .xx "shared strings." "" "xstr: extract strings from C programs to implement" "" xstr(1) .xx "" "j0, j1, jn," "y0, y1, yn: bessel functions." "" j0(3M) .xx "" "j0, j1, jn, y0," "y1, yn: bessel functions." "" j0(3M) .xx "" "" "yacc: yet another compiler-compiler." "" yacc(1) .xx "" "" "yes: be repetitively affirmative." "" yes(1) .xx "" "j0, j1, jn, y0, y1," "yn: bessel functions." "" j0(3M) .xx "" "compress, uncompress," "zcat: compress and expand data." "" compress(1) .xx "" "" "zork: the game of dungeon." "" zork(6) ================================================ FILE: share/man/man0/title.prm ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)title.prm 6.2 (Berkeley) 5/15/86 .\" .ps 18 .vs 22 .sp 2.75i .ft B .ce 2 UNIX Programmer's Reference Manual (PRM) .ps 14 .vs 16 .sp |4i .ce 2 4.3 Berkeley Software Distribution Virtual VAX\-11 Version .sp |5.75i .ft R .pt 12 .vs 16 .ce April, 1986 .sp |8.2i .ce 5 Computer Systems Research Group Computer Science Division Department of Electrical Engineering and Computer Science University of California Berkeley, California 94720 .bp .ll 5.3i .in 1.25i .hy 0 .ps 10 .vs 12p .sp |3.35i Copyright 1979, 1980, 1983, 1986 Regents of the University of California. Permission to copy these documents or any portion thereof as necessary for licensed use of the software is granted to licensees of this software, provided this copyright notice and statement of permission are included. .sp 2 Copyright 1979, AT&T Bell Laboratories, Incorporated. Holders of \x'-1p'UNIX\v'-4p'\s-3TM\s0\v'4p'/32V, System III, or System V software licenses are permitted to copy these documents, or any portion of them, as necessary for licensed use of the software, provided this copyright notice and statement of permission are included. .sp 2 This manual reflects system enhancements made at Berkeley and sponsored in part by the Defense Advanced Research Projects Agency (DoD), Arpa Order No. 4871 monitored by the Naval Electronics Systems Command under contract No. N00039-84-C-0089. The views and conclusions contained in these documents are those of the authors and should not be interpreted as representing official policies, either expressed or implied, of the Defense Research Projects Agency or of the US Government. .br .ll 6.5i .lt 6.5i .po .75i .in 0i .af % i .ds ET\" .de HD .po 0 .lt 7.4i .tl '''' .lt .po 'sp 18p .if o .tl '\\*(ET''- % -' .if e .tl '- % -''\\*(ET' 'sp 18p .ns .. .de FO 'sp 18p .if e .tl '\s9\\*(Dt''\\*(Ed\s0' .if o .tl '\s9\\*(Ed''\\*(Dt\s0' 'bp .. .wh 0 HD .wh -60p FO .ds ET \s9\f2Table \|of \|Contents\fP\s0 .ds Ed 4.3BSD .ds Dt April \|1986 .bp 1 .ce \f3TABLE \|OF \|CONTENTS\fP .nr x .5i .in +\nxu .nf .ta \n(.lu-\nxuR .de xx \\$1\f3 \a \fP\\$2 .. .de t .sp 1v .ne .5i .cs 3 .ti -.5i .ss 18 \f3\s9\\$2. \\$3\s0\fP .ss 12 .if t .sp .5v .cs 3 36 .so \\$1 .. .t /usr/man/man0/toc2 2 "System Calls" .t /usr/man/man0/toc3 3 "C Library Subroutines" .t /usr/man/man0/toc3f 3F "Fortran Library" .t /usr/man/man0/toc4 4 "Special Files" .t /usr/man/man0/toc5 5 "File Formats" .in -.5i .cs 3 .if n .ta 8n 16n 24n 32n 40n 48n 56n 64n 72n 80n .if t .ta .5i 1i 1.5i 2i 2.5i 3i 3.5i 4i 4.5i 5i 5.5i 6i 6.5i ================================================ FILE: share/man/man0/title.urm ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)title.urm 6.2 (Berkeley) 5/15/86 .\" .ps 18 .vs 22 .sp 2.75i .ft B .ce 2 UNIX User's Reference Manual (URM) .ps 14 .vs 16 .sp |4i .ce 2 4.3 Berkeley Software Distribution Virtual VAX\-11 Version .sp |5.75i .ft R .pt 12 .vs 16 .ce April, 1986 .sp |8.2i .ce 5 Computer Systems Research Group Computer Science Division Department of Electrical Engineering and Computer Science University of California Berkeley, California 94720 .bp .ll 5.3i .in 1.25i .hy 0 .ps 10 .vs 12p .sp |3.35i Copyright 1979, 1980, 1983, 1986 Regents of the University of California. Permission to copy these documents or any portion thereof as necessary for licensed use of the software is granted to licensees of this software, provided this copyright notice and statement of permission are included. .sp 2 Copyright 1979, AT&T Bell Laboratories, Incorporated. Holders of \x'-1p'UNIX\v'-4p'\s-3TM\s0\v'4p'/32V, System III, or System V software licenses are permitted to copy these documents, or any portion of them, as necessary for licensed use of the software, provided this copyright notice and statement of permission are included. .sp 2 This manual reflects system enhancements made at Berkeley and sponsored in part by the Defense Advanced Research Projects Agency (DoD), Arpa Order No. 4871 monitored by the Naval Electronics Systems Command under contract No. N00039-84-C-0089. The views and conclusions contained in these documents are those of the authors and should not be interpreted as representing official policies, either expressed or implied, of the Defense Research Projects Agency or of the US Government. ================================================ FILE: share/man/man0/toc.in ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)toc.in 6.2 (Berkeley) 5/12/86 .\" .af % i .if t .pn 11\"TABLE OF CONTENTS .if n .pn 15 .tr ~ .ll 6.5i .lt 6.5i .po .75i .ds ET\" .de HD .po 0 .lt 7.4i .tl '''' .lt .po 'sp 18p .if o .tl '\\*(ET''- % -' .if e .tl '- % -''\\*(ET' 'sp 18p .ns .. .de FO 'sp 18p .if e .tl '\s9\\*(Dt''\\*(Ed\s0' .if o .tl '\s9\\*(Ed''\\*(Dt\s0' 'bp .. .wh 0 HD .wh -60p FO .if \n(nl .bp .br .ds ET \s9\f2Table \|of \|Contents\fP\s0 .ds Ed 4.3BSD .ds Dt April \|1986 .ce \f3TABLE \|OF \|CONTENTS\fP .nr x .5i .in +\nxu .nf .ta \n(.lu-\nxuR .de xx \\$1\f3 \a \fP\\$2 .. .de t .sp 1v .ne .5i .cs 3 .ti -.5i .ss 18 \f3\s9\\$2. \\$3\s0\fP .ss 12 .if t .sp .5v .cs 3 36 .so \\$1 .. .t toc1 1 "Commands and Application Programs" .t toc2 2 "System Calls" .t toc3 3 "C Library Subroutines" .t toc3f 3F "Fortran Library" .t toc4 4 "Special Files" .t toc5 5 "File Formats" .t toc6 6 "Games" .t toc7 7 "Miscellaneous" .t toc8 8 "System Maintenance" .in -.5i .cs 3 .if n .ta 8n 16n 24n 32n 40n 48n 56n 64n 72n 80n .if t .ta .5i 1i 1.5i 2i 2.5i 3i 3.5i 4i 4.5i 5i 5.5i 6i 6.5i ================================================ FILE: share/man/man0/toc1 ================================================ .xx "intro" "introduction to commands" .xx "adb" "debugger" .xx "addbib" "create or extend bibliographic database" .xx "apply" "apply a command to a set of arguments" .xx "apropos" "locate commands by keyword lookup" .xx "ar" "archive and library maintainer" .xx "as" "VAX-11 assembler" .xx "at" "execute commands at a later time" .xx "atq" "print the queue of jobs waiting to be run" .xx "atrm" "remove jobs spooled by at" .xx "awk" "pattern scanning and processing language" .xx "basename" "strip filename affixes" .xx "bc" "arbitrary-precision arithmetic language" .xx "bib" "bibliographic formatter; list bibliographic reference items" .xx "biff" "be notified if mail arrives and who it is from" .xx "binmail" "send or receive mail among users" .xx "cal" "print calendar" .xx "calendar" "reminder service" .xx "cat" "catenate and print" .xx "cb" "C program beautifier" .xx "cc" "C compiler" .xx "cd" "change working directory" .xx "checknr" "check nroff/troff files" .xx "chfn" "change password file information" .xx "chgrp" "change group" .xx "chmod" "change mode" .xx "chsh" "change password file information" .xx "clear" "clear terminal screen" .xx "cmp" "compare two files" .xx "col" "filter reverse line feeds" .xx "colcrt" "filter nroff output for CRT previewing" .xx "colrm" "remove columns from a file" .xx "comm" "select or reject lines common to two sorted files" .xx "compress" "compress and expand data" .xx "cp" "copy" .xx "crypt" "encode/decode" .xx "csh" "a shell (command interpreter) with C-like syntax" .xx "ctags" "create a tags file" .xx "date" "print and set the date" .xx "dbx" "debugger" .xx "dc" "desk calculator" .xx "dd" "convert and copy a file" .xx "deroff" "remove nroff, troff, tbl and eqn constructs" .xx "df" "disk free" .xx "diction" "print wordy sentences; thesaurus for diction" .xx "diff" "differential file and directory comparator" .xx "diff3" "3-way differential file comparison" .xx "du" "summarize disk usage" .xx "echo" "echo arguments" .xx "ed" "text editor" .xx "efl" "Extended Fortran Language" .xx "eqn" "typeset mathematics" .xx "error" "analyze and disperse compiler error messages" .xx "ex" "text editor" .xx "expand" "expand tabs to spaces, and vice versa" .xx "expr" "evaluate arguments as an expression" .xx "f77" "Fortran 77 compiler" .xx "false" "provide truth values" .xx "file" "determine file type" .xx "find" "find files" .xx "finger" "user information lookup program" .xx "fmt" "simple text formatter" .xx "fold" "fold long lines for finite width output device" .xx "fp" "Functional Programming language compiler/interpreter" .xx "fpr" "print Fortran file" .xx "from" "who is my mail from?" .xx "fsplit" "split a multi-routine Fortran file into individual files" .xx "ftp" "ARPANET file transfer program" .xx "gcore" "get core images of running processes" .xx "gprof" "display call graph profile data" .xx "graph" "draw a graph" .xx "grep" "search a file for a pattern" .xx "groups" "show group memberships" .xx "head" "give first few lines" .xx "hostid" "set or print identifier of current host system" .xx "hostname" "set or print name of current host system" .xx "indent" "indent and format C program source" .xx "install" "install binaries" .xx "iostat" "report I/O statistics" .xx "join" "relational database operator" .xx "jove" "an interactive display-oriented text editor" .xx "kill" "terminate a process with extreme prejudice" .xx "last" "indicate last logins of users and teletypes" .xx "lastcomm" "show last commands executed in reverse order" .xx "ld" "link editor" .xx "learn" "computer aided instruction about UNIX" .xx "leave" "remind you when you have to leave" .xx "lex" "generator of lexical analysis programs" .xx "lint" "a C program verifier" .xx "lisp" "lisp interpreter" .xx "liszt" "compile a Franz Lisp program" .xx "ln" "make links" .xx "lock" "reserve a terminal" .xx "logger" "make entries in the system log" .xx "login" "sign on" .xx "look" "find lines in a sorted list" .xx "lookbib" "build inverted index for a bibliography, find references in a bibliography" .xx "lorder" "find ordering relation for an object library" .xx "lpq" "spool queue examination program" .xx "lpr" "off line print" .xx "lprm" "remove jobs from the line printer spooling queue" .xx "lptest" "generate lineprinter ripple pattern" .xx "ls" "list contents of directory" .xx "lxref" "lisp cross reference program" .xx "m4" "macro processor" .xx "mail" "send and receive mail" .xx "make" "maintain program groups" .xx "man" "find manual information by keywords; print out the manual" .xx "mesg" "permit or deny messages" .xx "mh" "Message Handler" .xx "mkdir" "make a directory" .xx "mkstr" "create an error message file by massaging C source" .xx "more" "file perusal filter for crt viewing" .xx "mset" "retrieve ASCII to IBM 3270 keyboard map" .xx "msgs" "system messages and junk mail program" .xx "mt" "magnetic tape manipulating program" .xx "mv" "move or rename files" .xx "netstat" "show network status" .xx "newaliases" "rebuild the data base for the mail aliases file" .xx "nice" "run a command at low priority (\fIsh\fR only)" .xx "nm" "print name list" .xx "notes" "a news system" .xx "nroff" "text formatting" .xx "od" "octal, decimal, hex, ascii dump" .xx "pagesize" "print system page size" .xx "passwd" "change password file information" .xx "patch" "a program for applying a diff file to an original" .xx "pc" "Pascal compiler" .xx "pdx" "pascal debugger" .xx "pi" "Pascal interpreter code translator" .xx "pix" "Pascal interpreter and executor" .xx "plot" "graphics filters" .xx "pmerge" "pascal file merger" .xx "pr" "print file" .xx "printenv" "print out the environment" .xx "prof" "display profile data" .xx "ps" "process status" .xx "ptx" "permuted index" .xx "pwd" "working directory name" .xx "px" "Pascal interpreter" .xx "pxp" "Pascal execution profiler" .xx "pxref" "Pascal cross-reference program" .xx "quota" "display disc usage and limits" .xx "ranlib" "convert archives to random libraries" .xx "ratfor" "rational Fortran dialect" .xx "rcp" "remote file copy" .xx "rcsintro" "introduction to RCS commands" .xx "rdist" "remote file distribution program" .xx "readnews" "read news articles" .xx "refer" "find and insert literature references in documents" .xx "rev" "reverse lines of a file" .xx "rlogin" "remote login" .xx "rm" "remove (unlink) files or directories" .xx "rmail" "handle remote mail received via uucp" .xx "rmdir" "remove (unlink) directories or files" .xx "roffbib" "run off bibliographic database" .xx "rsh" "remote shell" .xx "ruptime" "show host status of local machines" .xx "rwho" "who's logged in on local machines" .xx "sccs" "front end for the SCCS subsystem" .xx "script" "make typescript of terminal session" .xx "sed" "stream editor" .xx "sendbug" "mail a system bug report to 4bsd-bugs" .xx "sh" "command language" .xx "size" "size of an object file" .xx "sleep" "suspend execution for an interval" .xx "soelim" "eliminate \&.so's from nroff input" .xx "sort" "sort or merge files" .xx "sortbib" "sort bibliographic database" .xx "spell" "find spelling errors" .xx "spline" "interpolate smooth curve" .xx "split" "split a file into pieces" .xx "strings" "find the printable strings in a object, or other binary, file" .xx "strip" "remove symbols and relocation bits" .xx "struct" "structure Fortran programs" .xx "stty" "set terminal options" .xx "style" "analyze surface characteristics of a document" .xx "su" "substitute user id temporarily" .xx "sum" "sum and count blocks in a file" .xx "symorder" "rearrange name list" .xx "sysline" "display system status on status line of a terminal" .xx "systat" "display system statistics on a crt" .xx "tabs" "set terminal tabs" .xx "tail" "deliver the last part of a file" .xx "talk" "talk to another user" .xx "tar" "tape archiver" .xx "tbl" "format tables for nroff or troff" .xx "tc" "photoypesetter simulator" .xx "tcopy" "copy a mag tape" .xx "tee" "pipe fitting" .xx "telnet" "user interface to the TELNET protocol" .xx "test" "condition command" .xx "tftp" "trivial file transfer program" .xx "time" "time a command" .xx "tip" "connect to a remote system" .xx "tk" "paginator for the Tektronix 4014" .xx "tn3270" "full-screen remote login to IBM VM/CMS" .xx "touch" "update date last modified of a file" .xx "tp" "manipulate tape archive" .xx "tr" "translate characters" .xx "troff" "text formatting and typesetting" .xx "true" "provide truth values" .xx "tset" "terminal dependent initialization" .xx "tsort" "topological sort" .xx "tty" "get terminal name" .xx "ul" "do underlining" .xx "unifdef" "remove ifdef'ed lines" .xx "uniq" "report repeated lines in a file" .xx "units" "conversion program" .xx "uptime" "show how long system has been up" .xx "users" "compact list of users who are on the system" .xx "uucp" "unix to unix copy" .xx "uuencode" "encode/decode a binary file for transmission via mail" .xx "uulog" "display UUCP log files" .xx "uuname" "list names of UUCP hosts" .xx "uuq" "examine or manipulate the uucp queue" .xx "uusend" "send a file to a remote host" .xx "uux" "unix to unix command execution" .xx "vacation" "return ``I am on vacation'' indication" .xx "vgrind" "grind nice listings of programs" .xx "vi" "screen oriented (visual) display editor based on ex" .xx "vlp" "Format Lisp programs to be printed with nroff, vtroff, or troff" .xx "vmstat" "report virtual memory statistics" .xx "vnews" "read news articles" .xx "vwidth" "make troff width table for a font" .xx "w" "who is on and what they are doing" .xx "wait" "await completion of process" .xx "wall" "write to all users" .xx "wc" "word count" .xx "what" "show what versions of object modules were used to construct a file" .xx "whatis" "describe what a command is" .xx "whereis" "locate source, binary, and or manual for program" .xx "which" "locate a program file including aliases and paths (\fIcsh\fR only)" .xx "who" "who is on the system" .xx "whoami" "print effective current user id" .xx "whois" "DARPA Internet user name directory service" .xx "window" "window environment" .xx "write" "write to another user" .xx "xsend" "secret mail" .xx "xstr" "extract strings from C programs to implement shared strings" .xx "yacc" "yet another compiler-compiler" .xx "yes" "be repetitively affirmative" ================================================ FILE: share/man/man0/toc2 ================================================ .xx "intro" "introduction to system calls and error numbers" .xx "accept" "accept a connection on a socket" .xx "access" "determine accessibility of file" .xx "acct" "turn accounting on or off" .xx "adjtime" "correct the time to allow synchronization of the system clock" .xx "bind" "bind a name to a socket" .xx "brk" "change data segment size" .xx "chdir" "change current working directory" .xx "chmod" "change mode of file" .xx "chown" "change owner and group of a file" .xx "chroot" "change root directory" .xx "close" "delete a descriptor" .xx "connect" "initiate a connection on a socket" .xx "creat" "create a new file" .xx "dup" "duplicate a descriptor" .xx "execve" "execute a file" .xx "exit" "terminate a process" .xx "fcntl" "file control" .xx "flock" "apply or remove an advisory lock on an open file" .xx "fork" "create a new process" .xx "fsync" "synchronize a file's in-core state with that on disk" .xx "getdtablesize" "get descriptor table size" .xx "getgid" "get group identity" .xx "getgroups" "get group access list" .xx "gethostid" "get/set unique identifier of current host" .xx "gethostname" "get/set name of current host" .xx "getitimer" "get/set value of interval timer" .xx "getpagesize" "get system page size" .xx "getpeername" "get name of connected peer" .xx "getpgrp" "get process group" .xx "getpid" "get process identification" .xx "getpriority" "get/set program scheduling priority" .xx "getrlimit" "control maximum system resource consumption" .xx "getrusage" "get information about resource utilization" .xx "getsockname" "get socket name" .xx "getsockopt" "get and set options on sockets" .xx "gettimeofday" "get/set date and time" .xx "getuid" "get user identity" .xx "ioctl" "control device" .xx "kill" "send signal to a process" .xx "killpg" "send signal to a process group" .xx "link" "make a hard link to a file" .xx "listen" "listen for connections on a socket" .xx "lseek" "move read/write pointer" .xx "mkdir" "make a directory file" .xx "mknod" "make a special file" .xx "mount" "mount or remove file system" .xx "open" "open a file for reading or writing, or create a new file" .xx "pipe" "create an interprocess communication channel" .xx "profil" "execution time profile" .xx "ptrace" "process trace" .xx "quota" "manipulate disk quotas" .xx "read" "read input" .xx "readlink" "read value of a symbolic link" .xx "reboot" "reboot system or halt processor" .xx "recv" "receive a message from a socket" .xx "rename" "change the name of a file" .xx "rmdir" "remove a directory file" .xx "select" "synchronous I/O multiplexing" .xx "send" "send a message from a socket" .xx "setgroups" "set group access list" .xx "setpgrp" "set process group" .xx "setquota" "enable/disable quotas on a file system" .xx "setregid" "set real and effective group ID" .xx "setreuid" "set real and effective user ID's" .xx "shutdown" "shut down part of a full-duplex connection" .xx "sigblock" "block signals" .xx "sigpause" "atomically release blocked signals and wait for interrupt" .xx "sigreturn" "return from signal" .xx "sigsetmask" "set current signal mask" .xx "sigstack" "set and/or get signal stack context" .xx "sigvec" "software signal facilities" .xx "socket" "create an endpoint for communication" .xx "socketpair" "create a pair of connected sockets" .xx "stat" "get file status" .xx "swapon" "add a swap device for interleaved paging/swapping" .xx "symlink" "make symbolic link to a file" .xx "sync" "update super-block" .xx "syscall" "indirect system call" .xx "truncate" "truncate a file to a specified length" .xx "umask" "set file creation mode mask" .xx "unlink" "remove directory entry" .xx "utimes" "set file times" .xx "vfork" "spawn new process in a virtual memory efficient way" .xx "vhangup" "virtually ``hangup'' the current control terminal" .xx "wait" "wait for process to terminate" .xx "write" "write output" ================================================ FILE: share/man/man0/toc3 ================================================ .xx "intro" "introduction to C library functions" .xx "abort" "generate a fault" .xx "abs" "integer absolute value" .xx "alarm" "schedule signal after specified time" .xx "asinh" "inverse hyperbolic functions" .xx "assert" "program verification" .xx "atof" "convert ASCII to numbers" .xx "bstring" "bit and byte string operations" .xx "byteorder" "convert values between host and network byte order" .xx "crypt" "DES encryption" .xx "ctime" "convert date and time to ASCII" .xx "ctype" "character classification macros" .xx "curses" "screen functions with ``optimal'' cursor motion" .xx "dbm" "data base subroutines" .xx "directory" "directory operations" .xx "ecvt" "output conversion" .xx "end" "last locations in program" .xx "erf" "error functions" .xx "execl" "execute a file" .xx "exit" "terminate a process after flushing any pending output" .xx "exp" "exponential, logarithm, power" .xx "fclose" "close or flush a stream" .xx "ferror" "stream status inquiries" .xx "floor" "absolute value, floor, ceiling, and round-to-nearest functions" .xx "fopen" "open a stream" .xx "fread" "buffered binary input/output" .xx "frexp" "split into mantissa and exponent" .xx "fseek" "reposition a stream" .xx "getc" "get character or word from stream" .xx "getdisk" "get disk description by its name" .xx "getenv" "value for environment name" .xx "getfsent" "get file system descriptor file entry" .xx "getgrent" "get group file entry" .xx "gethostbyname" "get network host entry" .xx "getlogin" "get login name" .xx "getnetent" "get network entry" .xx "getopt" "get option letter from argv" .xx "getpass" "read a password" .xx "getprotoent" "get protocol entry" .xx "getpw" "get name from uid" .xx "getpwent" "get password file entry" .xx "gets" "get a string from a stream" .xx "getservent" "get service entry" .xx "getttyent" "get ttys file entry" .xx "getusershell" "get legal user shells" .xx "getwd" "get current working directory pathname" .xx "hypot" "Euclidean distance, complex absolute value" .xx "ieee" "copysign, remainder, exponent manipulations" .xx "inet" "Internet address manipulation routines" .xx "infnan" "signals invalid floating-point operations on a VAX (temporary)" .xx "initgroups" "initialize group access list" .xx "insque" "insert/remove element from a queue" .xx "j0" "bessel functions" .xx "lgamma" "log gamma function" .xx "lib2648" "subroutines for the HP 2648 graphics terminal" .xx "malloc" "memory allocator" .xx "math" "introduction to mathematical library functions" .xx "mktemp" "make a unique file name" .xx "monitor" "prepare execution profile" .xx "mp" "multiple precision integer arithmetic" .xx "ndbm" "data base subroutines" .xx "nice" "set program priority" .xx "nlist" "get entries from name list" .xx "ns" "Xerox NS(tm) address conversion routines" .xx "pause" "stop until signal" .xx "perror" "system error messages" .xx "plot" "graphics interface" .xx "popen" "initiate I/O to/from a process" .xx "printf" "formatted output conversion" .xx "psignal" "system signal messages" .xx "putc" "put character or word on a stream" .xx "puts" "put a string on a stream" .xx "qsort" "quicker sort" .xx "rand" "random number generator" .xx "random" "better random number generator; routines for changing generators" .xx "rcmd" "routines for returning a stream to a remote command" .xx "regex" "regular expression handler" .xx "resolver" "resolver routines" .xx "rexec" "return stream to a remote command" .xx "scandir" "scan a directory" .xx "scanf" "formatted input conversion" .xx "setbuf" "assign buffering to a stream" .xx "setjmp" "non-local goto" .xx "setuid" "set user and group ID" .xx "siginterrupt" "allow signals to interrupt system calls" .xx "signal" "simplified software signal facilities" .xx "sin" "trigonometric functions and their inverses" .xx "sinh" "hyperbolic functions" .xx "sleep" "suspend execution for interval" .xx "sqrt" "cube root, square root" .xx "stdio" "standard buffered input/output package" .xx "string" "string operations" .xx "stty" "set and get terminal state (defunct)" .xx "swab" "swap bytes" .xx "syslog" "control system log" .xx "system" "issue a shell command" .xx "termcap" "terminal independent operation routines" .xx "time" "get date and time" .xx "times" "get process times" .xx "ttyname" "find name of a terminal" .xx "ualarm" "schedule signal after specified time" .xx "ungetc" "push character back into input stream" .xx "usleep" "suspend execution for interval" .xx "utime" "set file times" .xx "valloc" "aligned memory allocator" .xx "varargs" "variable argument list" .xx "vlimit" "control maximum system resource consumption" .xx "vtimes" "get information about resource utilization" ================================================ FILE: share/man/man0/toc3f ================================================ .xx "intro" "introduction to FORTRAN library functions" .xx "abort" "abnormal termination" .xx "access" "determine accessability of a file" .xx "alarm" "execute a subroutine after a specified time" .xx "bessel" "of two kinds for integer orders" .xx "bit" "and, or, xor, not, rshift, lshift bitwise functions" .xx "chdir" "change default directory" .xx "chmod" "change mode of a file" .xx "etime" "return elapsed execution time" .xx "exit" "terminate process with status" .xx "fdate" "return date and time in an ASCII string" .xx "flmin" "return extreme values" .xx "flush" "flush output to a logical unit" .xx "fork" "create a copy of this process" .xx "fseek" "reposition a file on a logical unit" .xx "getarg" "return command line arguments" .xx "getc" "get a character from a logical unit" .xx "getcwd" "get pathname of current working directory" .xx "getenv" "get value of environment variables" .xx "getlog" "get user's login name" .xx "getpid" "get process id" .xx "getuid" "get user or group ID of the caller" .xx "hostnm" "get name of current host" .xx "idate" "return date or time in numerical form" .xx "index" "tell about character objects" .xx "ioinit" "change f77 I/O initialization" .xx "kill" "send a signal to a process" .xx "link" "make a link to an existing file" .xx "loc" "return the address of an object" .xx "long" "integer object conversion" .xx "malloc" "memory allocator" .xx "perror" "get system error messages" .xx "plot" "f77 library interface to \fIplot\fR (3X) libraries." .xx "putc" "write a character to a fortran logical unit" .xx "qsort" "quick sort" .xx "rand" "return random values" .xx "random" "better random number generator" .xx "rename" "rename a file" .xx "signal" "change the action for a signal" .xx "sleep" "suspend execution for an interval" .xx "stat" "get file status" .xx "system" "execute a UNIX command" .xx "time" "return system time" .xx "topen" "f77 tape I/O" .xx "traper" "trap arithmetic errors" .xx "trapov" "trap and repair floating point overflow" .xx "trpfpe" "trap and repair floating point faults" .xx "ttynam" "find name of a terminal port" .xx "unlink" "remove a directory entry" .xx "wait" "wait for a process to terminate" ================================================ FILE: share/man/man0/toc4 ================================================ .xx "intro" "introduction to special files and hardware support" .xx "acc" "ACC LH/DH IMP interface" .xx "ad" "Data Translation A/D converter" .xx "arp" "Address Resolution Protocol" .xx "autoconf" "diagnostics from the autoconfiguration code" .xx "bk" "line discipline for machine-machine communication (obsolete)" .xx "cons" "VAX-11 console interface" .xx "crl" "VAX 8600 console RL02 interface" .xx "css" "DEC IMP-11A LH/DH IMP interface" .xx "ct" "phototypesetter interface" .xx "ddn" "DDN Standard Mode X.25 IMP interface" .xx "de" "DEC DEUNA 10 Mb/s Ethernet interface" .xx "dh" "DH-11/DM-11 communications multiplexer" .xx "dhu" "DHU-11 communications multiplexer" .xx "dmc" "DEC DMC-11/DMR-11 point-to-point communications device" .xx "dmf" "DMF-32, terminal multiplexor" .xx "dmz" "DMZ-32 terminal multiplexor" .xx "dn" "DN-11 autocall unit interface" .xx "drum" "paging device" .xx "dz" "DZ-11 communications multiplexer" .xx "ec" "3Com 10 Mb/s Ethernet interface" .xx "en" "Xerox 3 Mb/s Ethernet interface" .xx "ex" "Excelan 10 Mb/s Ethernet interface" .xx "fl" "console floppy interface" .xx "hdh" "ACC IF-11/HDH IMP interface" .xx "hk" "RK6-11/RK06 and RK07 moving head disk" .xx "hp" "MASSBUS disk interface" .xx "ht" "TM-03/TE-16,TU-45,TU-77 MASSBUS magtape interface" .xx "hy" "Network Systems Hyperchannel interface" .xx "icmp" "Internet Control Message Protocol" .xx "idp" "Xerox Internet Datagram Protocol" .xx "ik" "Ikonas frame buffer, graphics device interface" .xx "il" "Interlan NI1010 10 Mb/s Ethernet interface" .xx "imp" "1822 network interface" .xx "imp" "IMP raw socket interface" .xx "inet" "Internet protocol family" .xx "ip" "Internet Protocol" .xx "ix" "Interlan Np100 10 Mb/s Ethernet interface" .xx "kg" "KL-11/DL-11W line clock" .xx "lo" "software loopback network interface" .xx "lp" "line printer" .xx "mem" "main memory" .xx "mt" "TM78/TU-78 MASSBUS magtape interface" .xx "mtio" "UNIX magtape interface" .xx "np" "Interlan Np100 10 Mb/s Ethernet interface" .xx "ns" "Xerox Network Systems(tm) protocol family" .xx "nsip" "software network interface encapsulating ns packets in ip packets." .xx "null" "data sink" .xx "pcl" "DEC CSS PCL-11 B Network Interface" .xx "ps" "Evans and Sutherland Picture System 2 graphics device interface" .xx "pty" "pseudo terminal driver" .xx "qe" "DEC DEQNA Q-bus 10 Mb/s Ethernet interface" .xx "rx" "DEC RX02 floppy disk interface" .xx "spp" "Xerox Sequenced Packet Protocol" .xx "tb" "line discipline for digitizing devices" .xx "tcp" "Internet Transmission Control Protocol" .xx "tm" "TM-11/TE-10 magtape interface" .xx "tmscp" "DEC TMSCP magtape interface" .xx "ts" "TS-11 magtape interface" .xx "tty" "general terminal interface" .xx "tu" "VAX-11/730 and VAX-11/750 TU58 console cassette interface" .xx "uda" "UDA-50 disk controller interface" .xx "udp" "Internet User Datagram Protocol" .xx "up" "unibus storage module controller/drives" .xx "ut" "UNIBUS TU45 tri-density tape drive interface" .xx "uu" "TU58/DECtape II UNIBUS cassette interface" .xx "va" "Benson-Varian interface" .xx "vp" "Versatec interface" .xx "vv" "Proteon proNET 10 Megabit ring" ================================================ FILE: share/man/man0/toc5 ================================================ .xx "L-devices" "UUCP device description file" .xx "L-dialcodes" "UUCP phone number index file" .xx "L.aliases" "UUCP hostname alias file" .xx "L.cmds" "UUCP remote command permissions file" .xx "L.sys" "UUCP remote host description file" .xx "USERFILE" "UUCP pathname permissions file" .xx "a.out" "assembler and link editor output" .xx "acct" "execution accounting file" .xx "aliases" "aliases file for sendmail" .xx "ar" "archive (library) file format" .xx "core" "format of memory image file" .xx "dbx" "dbx symbol table information" .xx "dir" "format of directories" .xx "disktab" "disk description file" .xx "dump" "incremental dump format" .xx "fs" "format of file system volume" .xx "fstab" "static information about the filesystems" .xx "gettytab" "terminal configuration data base" .xx "group" "group file" .xx "hosts" "host name data base" .xx "map3270" "database for mapping ascii keystrokes into IBM 3270 keys" .xx "mtab" "mounted file system table" .xx "networks" "network name data base" .xx "passwd" "password file" .xx "phones" "remote host phone number data base" .xx "plot" "graphics interface" .xx "printcap" "printer capability data base" .xx "protocols" "protocol name data base" .xx "remote" "remote host description file" .xx "resolver" "resolver configuration file" .xx "services" "service name data base" .xx "stab" "symbol table types" .xx "tar" "tape archive file format" .xx "termcap" "terminal capability data base" .xx "tp" "DEC/mag tape formats" .xx "ttys" "terminal initialization data" .xx "types" "primitive system data types" .xx "utmp" "login records" .xx "uuencode" "format of an encoded uuencode file" .xx "vfont" "font formats for the Benson-Varian or Versatec" .xx "vgrindefs" "vgrind's language definition data base" ================================================ FILE: share/man/man0/toc6 ================================================ .xx "aardvark" "yet another exploration game" .xx "adventure" "an exploration game" .xx "arithmetic" "provide drill in number facts" .xx "backgammon" "the game" .xx "banner" "print large banner on printer" .xx "battlestar" "a tropical adventure game" .xx "bcd" "convert to antique media" .xx "boggle" "play the game of boggle" .xx "canfield" "the solitaire card game canfield" .xx "chess" "the game of chess" .xx "ching" "the book of changes and other cookies" .xx "cribbage" "the card game cribbage" .xx "doctor" "interact with a psychoanalyst" .xx "fish" "play ``Go Fish''" .xx "fortune" "print a random, hopefully interesting, adage" .xx "hangman" "Computer version of the game hangman" .xx "hunt" "a multi-player multi-terminal game" .xx "mille" "play Mille Bournes" .xx "monop" "Monopoly game" .xx "number" "convert Arabic numerals to English" .xx "quiz" "test your knowledge" .xx "rain" "animated raindrops display" .xx "robots" "fight off villainous robots" .xx "rogue" "Exploring The Dungeons of Doom" .xx "sail" "multi-user wooden ships and iron men" .xx "snake" "display chase game" .xx "trek" "trekkie game" .xx "worm" "Play the growing worm game" .xx "worms" "animate worms on a display terminal" .xx "wump" "the game of hunt-the-wumpus" .xx "zork" "the game of dungeon" ================================================ FILE: share/man/man0/toc7 ================================================ .xx "intro" "miscellaneous useful information pages" .xx "ascii" "map of ASCII character set" .xx "environ" "user environment" .xx "eqnchar" "special character definitions for eqn" .xx "hier" "file system hierarchy" .xx "mailaddr" "mail addressing description" .xx "man" "macros to typeset manual" .xx "me" "macros for formatting papers" .xx "ms" "text formatting macros" .xx "term" "conventional names for terminals" ================================================ FILE: share/man/man0/toc8 ================================================ .xx "intro" "introduction to system maintenance and operation commands" .xx "XNSrouted" "NS Routing Information Protocol daemon" .xx "ac" "login accounting" .xx "adduser" "procedure for adding new users" .xx "arff" "archiver and copier for floppy" .xx "arp" "address resolution display and control" .xx "bad144" "read/write dec standard 144 bad sector information" .xx "badsect" "create files to contain bad sectors" .xx "bugfiler" "file bug reports in folders automatically" .xx "catman" "create the cat files for the manual" .xx "chown" "change owner" .xx "clri" "clear i-node" .xx "comsat" "biff server" .xx "config" "build system configuration files" .xx "crash" "what happens when the system crashes" .xx "cron" "clock daemon" .xx "dcheck" "file system directory consistency check" .xx "diskpart" "calculate default disk partition sizes" .xx "dmesg" "collect system diagnostic messages to form error log" .xx "drtest" "standalone disk test program" .xx "dump" "incremental file system dump" .xx "dumpfs" "dump file system information" .xx "edquota" "edit user quotas" .xx "fastboot" "reboot/halt the system without checking the disks" .xx "fingerd" "remote user information server" .xx "format" "how to format disk packs" .xx "fsck" "file system consistency check and interactive repair" .xx "ftpd" "DARPA Internet File Transfer Protocol server" .xx "gettable" "get NIC format host tables from a host" .xx "getty" "set terminal mode" .xx "halt" "stop the processor" .xx "htable" "convert NIC standard format host tables" .xx "icheck" "file system storage consistency check" .xx "ifconfig" "configure network interface parameters" .xx "implog" "IMP log interpreter" .xx "implogd" "IMP logger process" .xx "inetd" "internet ``super\-server''" .xx "init" "process control initialization" .xx "kgmon" "generate a dump of the operating system's profile buffers" .xx "lpc" "line printer control program" .xx "lpd" "line printer daemon" .xx "makedev" "make system special files" .xx "makekey" "generate encryption key" .xx "mkfs" "construct a file system" .xx "mkhosts" "generate hashed host table" .xx "mklost+found" "make a lost+found directory for fsck" .xx "mknod" "build special file" .xx "mkpasswd" "generate hashed password table" .xx "mkproto" "construct a prototype file system" .xx "mount" "mount and dismount file system" .xx "named" "Internet domain name server" .xx "ncheck" "generate names from i-numbers" .xx "newfs" "construct a new file system" .xx "pac" "printer/plotter accounting information" .xx "ping" "send ICMP ECHO_REQUEST packets to network hosts" .xx "pstat" "print system facts" .xx "quot" "summarize file system ownership" .xx "quotacheck" "file system quota consistency checker" .xx "quotaon" "turn file system quotas on and off" .xx "rc" "command script for auto-reboot and daemons" .xx "rdump" "file system dump across the network" .xx "reboot" "UNIX bootstrapping procedures" .xx "renice" "alter priority of running processes" .xx "repquota" "summarize quotas for a file system" .xx "restore" "incremental file system restore" .xx "rexecd" "remote execution server" .xx "rlogind" "remote login server" .xx "rmt" "remote magtape protocol module" .xx "route" "manually manipulate the routing tables" .xx "routed" "network routing daemon" .xx "rrestore" "restore a file system dump across the network" .xx "rshd" "remote shell server" .xx "rwhod" "system status server" .xx "rxformat" "format floppy disks" .xx "sa" "system accounting" .xx "savecore" "save a core dump of the operating system" .xx "sendmail" "send mail over the internet" .xx "shutdown" "close down the system at a given time" .xx "slattach" "attach serial lines as network interfaces" .xx "sticky" "persistent text and append-only directories" .xx "swapon" "specify additional device for paging and swapping" .xx "sync" "update the super block" .xx "syslogd" "log systems messages" .xx "talkd" "remote user communication server" .xx "telnetd" "DARPA TELNET protocol server" .xx "tftpd" "DARPA Trivial File Transfer Protocol server" .xx "timed" "time server daemon" .xx "timedc" "timed control program" .xx "trpt" "transliterate protocol trace" .xx "trsp" "transliterate sequenced packet protocol trace" .xx "tunefs" "tune up an existing file system" .xx "update" "periodically update the super block" .xx "uucico" "transfer files queued by uucp or uux" .xx "uuclean" "uucp spool directory clean-up" .xx "uupoll" "poll a remote UUCP site" .xx "uusnap" "show snapshot of the UUCP system" .xx "uuxqt" "UUCP execution file interpreter" .xx "vipw" "edit the password file" ================================================ FILE: share/man/man0/tocrc ================================================ #!/bin/sh - # # Copyright (c) 1980 Regents of the University of California. # All rights reserved. The Berkeley software License Agreement # specifies the terms and conditions for redistribution. # # @(#)tocrc 6.2.1 (2.11BSD) 1996/10/25 # tmp=/tmp/toc$$ trap "rm $tmp ; exit" 2 3 15 if [ $# -eq 2 -a $1 = "3" ] then : create toc input files for section 3 only (cd ../man3 ; /usr/libexec/getNAME -t `ls *.3 *.3[mnsxc] | sort` | sed \ -e 's/.s-2//g' \ -e 's/.s-1//g' \ -e 's/.s0//g' \ -e 's/.s+1//g' \ -e 's/ *.- */: /' \ -e 's/ *$/./' \ -e 's/.TH.* //' \ > ../man0/tocx3 ; /usr/libexec/getNAME -t *.3f | sed \ -e 's/.s-2//g' \ -e 's/.s-1//g' \ -e 's/.s0//g' \ -e 's/.s+1//g' \ -e 's/ *.- */: /' \ -e 's/ *$/./' \ -e 's/.TH.* //' \ > ../man0/tocx3f ) elif [ $# -eq 2 ] then : create toc input file for one section only ( cd ../man$1 ; /usr/libexec/getNAME -t *.* | sed \ -e 's/.s-2//g' \ -e 's/.s-1//g' \ -e 's/.s0//g' \ -e 's/.s+1//g' \ -e 's/ *.- */: /' \ -e 's/ *$/./' \ -e 's/.TH.* //' \ > ../man0/tocx$1 ) else case $1 in all ) : tocx files for all sections and everything else for x in 1 2 3 4 5 6 7 8 do ./$0 $x $x done ./$0 t ;; t ) : permuted index and toc files if [ ! -f tocx1 ] then echo "tocx* files missing; must run tocrc all first" exit fi sed \ -e 's/(1c)/(1C)/' \ -e 's/(1g)/(1G)/' \ -e 's/(3c)/(3C)/' \ -e 's/(3m)/(3M)/' \ -e 's/(3n)/(3N)/' \ -e 's/(3s)/(3S)/' \ -e 's/(3x)/(3X)/' \ -e 's/(3f)/(3F)/' \ -e 's/(4f)/(4F)/' \ -e 's/(4n)/(4N)/' \ -e 's/(4p)/(4P)/' \ -e 's/(8c)/(8C)/' \ -e 's/(8v)/(8V)/' \ -e '/"\."/d' \ tocx* cshcmd \ > /tmp/cattoc ptx -r -t -b break -f -w 108 -i ignore \ /tmp/cattoc ptxx for x in 1 2 3 3f 4 5 6 7 8 do < tocx$x grep '^intro' >$tmp sed \ -e '2,${' \ -e '/^intro/d' \ -e '}' \ -e 's/ .*://' \ -e 's/.$//' \ -e 's/([^)]*) /" "/' \ -e 's/.*/.xx "&"/' \ -e '/""/d' \ $tmp tocx$x \ >toc$x done ;; * ) ./$0 $1 $1 ;; esac fi exit ================================================ FILE: share/man/man0/tocx1 ================================================ adb(1) adb: debugger. addbib(1) addbib: create or extend bibliographic database. apply(1) apply: apply a command to a set of arguments. apropos(1) apropos: locate commands by keyword lookup. ar(1) ar: archive and library maintainer. as(1) as: VAX-11 assembler. at(1) at: execute commands at a later time. atq(1) atq: print the queue of jobs waiting to be run. atrm(1) atrm: remove jobs spooled by at. awk(1) awk: pattern scanning and processing language. basename(1) basename: strip filename affixes. bc(1) bc: arbitrary-precision arithmetic language. bib(1) bib, listrefs: bibliographic formatter; list bibliographic reference items. biff(1) biff: be notified if mail arrives and who it is from. binmail(1) binmail: send or receive mail among users. cal(1) cal: print calendar. calendar(1) calendar: reminder service. cat(1) cat: catenate and print. cb(1) cb: C program beautifier. cc(1) cc: C compiler. cd(1) cd: change working directory. checknr(1) checknr: check nroff/troff files. chfn(1) chfn, chsh, passwd: change password file information. chgrp(1) chgrp: change group. chmod(1) chmod: change mode. chsh(1) chfn, chsh, passwd: change password file information. clear(1) clear: clear terminal screen. cmp(1) cmp: compare two files. col(1) col: filter reverse line feeds. colcrt(1) colcrt: filter nroff output for CRT previewing. colrm(1) colrm: remove columns from a file. comm(1) comm: select or reject lines common to two sorted files. compress(1) compress, uncompress, zcat: compress and expand data. cp(1) cp: copy. crypt(1) crypt: encode/decode. csh(1) csh: a shell (command interpreter) with C-like syntax. ctags(1) ctags: create a tags file. date(1) date: print and set the date. dbx(1) dbx: debugger. dc(1) dc: desk calculator. dd(1) dd: convert and copy a file. deroff(1) deroff: remove nroff, troff, tbl and eqn constructs. df(1) df: disk free. diction(1) diction, explain: print wordy sentences; thesaurus for diction. diff(1) diff: differential file and directory comparator. diff3(1) diff3: 3-way differential file comparison. du(1) du: summarize disk usage. echo(1) echo: echo arguments. ed(1) ed: text editor. efl(1) efl: Extended Fortran Language. eqn(1) eqn, neqn, checkeq: typeset mathematics. error(1) error: analyze and disperse compiler error messages. ex(1) ex, edit: text editor. expand(1) expand, unexpand: expand tabs to spaces, and vice versa. expr(1) expr: evaluate arguments as an expression. f77(1) f77: Fortran 77 compiler. false(1) false, true: provide truth values. file(1) file: determine file type. find(1) find: find files. finger(1) finger: user information lookup program. fmt(1) fmt: simple text formatter. fold(1) fold: fold long lines for finite width output device. fp(1) fp: Functional Programming language compiler/interpreter. fpr(1) fpr: print Fortran file. from(1) from: who is my mail from?. fsplit(1) fsplit: split a multi-routine Fortran file into individual files. ftp(1c) ftp: ARPANET file transfer program. gcore(1) gcore: get core images of running processes. gprof(1) gprof: display call graph profile data. graph(1g) graph: draw a graph. grep(1) grep, egrep, fgrep: search a file for a pattern. groups(1) groups: show group memberships. head(1) head: give first few lines. hostid(1) hostid: set or print identifier of current host system. hostname(1) hostname: set or print name of current host system. indent(1) indent: indent and format C program source. install(1) install: install binaries. intro(1) intro: introduction to commands. iostat(1) iostat: report I/O statistics. join(1) join: relational database operator. jove(1) jove: an interactive display-oriented text editor. kill(1) kill: terminate a process with extreme prejudice. last(1) last: indicate last logins of users and teletypes. lastcomm(1) lastcomm: show last commands executed in reverse order. ld(1) ld: link editor. learn(1) learn: computer aided instruction about UNIX. leave(1) leave: remind you when you have to leave. lex(1) lex: generator of lexical analysis programs. lint(1) lint: a C program verifier. lisp(1) lisp: lisp interpreter. liszt(1) liszt: compile a Franz Lisp program. ln(1) ln: make links. lock(1) lock: reserve a terminal. logger(1) logger: make entries in the system log. login(1) login: sign on. look(1) look: find lines in a sorted list. lookbib(1) indxbib, lookbib: build inverted index for a bibliography, find references in a bibliography. lorder(1) lorder: find ordering relation for an object library. lpq(1) lpq: spool queue examination program. lpr(1) lpr: off line print. lprm(1) lprm: remove jobs from the line printer spooling queue. lptest(1) lptest: generate lineprinter ripple pattern. ls(1) ls: list contents of directory. lxref(1) lxref: lisp cross reference program. m4(1) m4: macro processor. mail(1) mail: send and receive mail. make(1) make: maintain program groups. man(1) man: find manual information by keywords; print out the manual. mesg(1) mesg: permit or deny messages. mh(1) mh: Message Handler. mkdir(1) mkdir: make a directory. mkstr(1) mkstr: create an error message file by massaging C source. more(1) more, page: file perusal filter for crt viewing. mset(1) mset: retrieve ASCII to IBM 3270 keyboard map. msgs(1) msgs: system messages and junk mail program. mt(1) mt: magnetic tape manipulating program. mv(1) mv: move or rename files. netstat(1) netstat: show network status. newaliases(1) newaliases: rebuild the data base for the mail aliases file. nice(1) nice, nohup: run a command at low priority (\fIsh\fR only). nm(1) nm: print name list. notes(1) notes, autoseq, readnotes: a news system. nroff(1) nroff: text formatting. od(1) od: octal, decimal, hex, ascii dump. pagesize(1) pagesize: print system page size. passwd(1) chfn, chsh, passwd: change password file information. patch(1) patch: a program for applying a diff file to an original. pc(1) pc: Pascal compiler. pdx(1) pdx: pascal debugger. pi(1) pi: Pascal interpreter code translator. pix(1) pix: Pascal interpreter and executor. plot(1g) plot: graphics filters. pmerge(1) pmerge: pascal file merger. pr(1) pr: print file. printenv(1) printenv: print out the environment. prof(1) prof: display profile data. ps(1) ps: process status. ptx(1) ptx: permuted index. pwd(1) pwd: working directory name. px(1) px: Pascal interpreter. pxp(1) pxp: Pascal execution profiler. pxref(1) pxref: Pascal cross-reference program. quota(1) quota: display disc usage and limits. ranlib(1) ranlib: convert archives to random libraries. ratfor(1) ratfor: rational Fortran dialect. rcp(1c) rcp: remote file copy. rcsintro(1) rcsintro: introduction to RCS commands. rdist(1) rdist: remote file distribution program. readnews(1) readnews: read news articles. refer(1) refer: find and insert literature references in documents. rev(1) rev: reverse lines of a file. rlogin(1c) rlogin: remote login. rm(1) rm, rmdir: remove (unlink) files or directories. rmail(1) rmail: handle remote mail received via uucp. rmdir(1) rmdir, rm: remove (unlink) directories or files. roffbib(1) roffbib: run off bibliographic database. rsh(1c) rsh: remote shell. ruptime(1c) ruptime: show host status of local machines. rwho(1c) rwho: who's logged in on local machines. sccs(1) sccs: front end for the SCCS subsystem. script(1) script: make typescript of terminal session. sed(1) sed: stream editor. sendbug(1) sendbug: mail a system bug report to 4bsd-bugs. sh(1) sh, for, case, if, while, \fB:\fP, \fB.\fP, break, continue, cd, eval, exec, exit, export, login, read, readonly, set, shift, times, trap, umask, wait: command language. size(1) size: size of an object file. sleep(1) sleep: suspend execution for an interval. soelim(1) soelim: eliminate \&.so's from nroff input. sort(1) sort: sort or merge files. sortbib(1) sortbib: sort bibliographic database. spell(1) spell, spellin, spellout: find spelling errors. spline(1g) spline: interpolate smooth curve. split(1) split: split a file into pieces. strings(1) strings: find the printable strings in a object, or other binary, file. strip(1) strip: remove symbols and relocation bits. struct(1) struct: structure Fortran programs. stty(1) stty: set terminal options. style(1) style: analyze surface characteristics of a document. su(1) su: substitute user id temporarily. sum(1) sum: sum and count blocks in a file. symorder(1) symorder: rearrange name list. sysline(1) sysline: display system status on status line of a terminal. systat(1) systat: display system statistics on a crt. tabs(1) tabs: set terminal tabs. tail(1) tail: deliver the last part of a file. talk(1) talk: talk to another user. tar(1) tar: tape archiver. tbl(1) tbl: format tables for nroff or troff. tc(1) tc: photoypesetter simulator. tcopy(1) tcopy: copy a mag tape. tee(1) tee: pipe fitting. telnet(1c) telnet: user interface to the TELNET protocol. test(1) test: condition command. tftp(1c) tftp: trivial file transfer program. time(1) time: time a command. tip(1c) tip, cu: connect to a remote system. tk(1) tk: paginator for the Tektronix 4014. tn3270(1) tn3270: full-screen remote login to IBM VM/CMS. touch(1) touch: update date last modified of a file. tp(1) tp: manipulate tape archive. tr(1) tr: translate characters. troff(1) troff, nroff: text formatting and typesetting. true(1) true, false: provide truth values. tset(1) tset: terminal dependent initialization. tsort(1) tsort: topological sort. tty(1) tty: get terminal name. ul(1) ul: do underlining. unifdef(1) unifdef: remove ifdef'ed lines. uniq(1) uniq: report repeated lines in a file. units(1) units: conversion program. uptime(1) uptime: show how long system has been up. users(1) users: compact list of users who are on the system. uucp(1c) uucp: unix to unix copy. uuencode(1c) uuencode, uudecode: encode/decode a binary file for transmission via mail. uulog(1c) uulog: display UUCP log files. uuname(1c) uuname: list names of UUCP hosts. uuq(1c) uuq: examine or manipulate the uucp queue. uusend(1c) uusend: send a file to a remote host. uux(1c) uux: unix to unix command execution. vacation(1) vacation: return ``I am on vacation'' indication. vgrind(1) vgrind: grind nice listings of programs. vi(1) vi: screen oriented (visual) display editor based on ex. vlp(1) vlp: Format Lisp programs to be printed with nroff, vtroff, or troff. vmstat(1) vmstat: report virtual memory statistics. vnews(1) vnews: read news articles. vwidth(1) vwidth: make troff width table for a font. w(1) w: who is on and what they are doing. wait(1) wait: await completion of process. wall(1) wall: write to all users. wc(1) wc: word count. what(1) what: show what versions of object modules were used to construct a file. whatis(1) whatis: describe what a command is. whereis(1) whereis: locate source, binary, and or manual for program. which(1) which: locate a program file including aliases and paths (\fIcsh\fR only). who(1) who: who is on the system. whoami(1) whoami: print effective current user id. whois(1) whois: DARPA Internet user name directory service. window(1) window: window environment. write(1) write: write to another user. xsend(1) xsend, xget, enroll: secret mail. xstr(1) xstr: extract strings from C programs to implement shared strings. yacc(1) yacc: yet another compiler-compiler. yes(1) yes: be repetitively affirmative. ================================================ FILE: share/man/man0/tocx2 ================================================ accept(2) accept: accept a connection on a socket. access(2) access: determine accessibility of file. acct(2) acct: turn accounting on or off. adjtime(2) adjtime: correct the time to allow synchronization of the system clock. bind(2) bind: bind a name to a socket. brk(2) brk, sbrk: change data segment size. chdir(2) chdir: change current working directory. chmod(2) chmod: change mode of file. chown(2) chown: change owner and group of a file. chroot(2) chroot: change root directory. close(2) close: delete a descriptor. connect(2) connect: initiate a connection on a socket. creat(2) creat: create a new file. dup(2) dup, dup2: duplicate a descriptor. execve(2) execve: execute a file. exit(2) _exit: terminate a process. fcntl(2) fcntl: file control. flock(2) flock: apply or remove an advisory lock on an open file. fork(2) fork: create a new process. fsync(2) fsync: synchronize a file's in-core state with that on disk. getdtablesize(2) getdtablesize: get descriptor table size. getgid(2) getgid, getegid: get group identity. getgroups(2) getgroups: get group access list. gethostid(2) gethostid, sethostid: get/set unique identifier of current host. gethostname(2) gethostname, sethostname: get/set name of current host. getitimer(2) getitimer, setitimer: get/set value of interval timer. getpagesize(2) getpagesize: get system page size. getpeername(2) getpeername: get name of connected peer. getpgrp(2) getpgrp: get process group. getpid(2) getpid, getppid: get process identification. getpriority(2) getpriority, setpriority: get/set program scheduling priority. getrlimit(2) getrlimit, setrlimit: control maximum system resource consumption. getrusage(2) getrusage: get information about resource utilization. getsockname(2) getsockname: get socket name. getsockopt(2) getsockopt, setsockopt: get and set options on sockets. gettimeofday(2) gettimeofday, settimeofday: get/set date and time. getuid(2) getuid, geteuid: get user identity. intro(2) intro: introduction to system calls and error numbers. ioctl(2) ioctl: control device. kill(2) kill: send signal to a process. killpg(2) killpg: send signal to a process group. link(2) link: make a hard link to a file. listen(2) listen: listen for connections on a socket. lseek(2) lseek: move read/write pointer. mkdir(2) mkdir: make a directory file. mknod(2) mknod: make a special file. mount(2) mount, umount: mount or remove file system. open(2) open: open a file for reading or writing, or create a new file. pipe(2) pipe: create an interprocess communication channel. profil(2) profil: execution time profile. ptrace(2) ptrace: process trace. quota(2) quota: manipulate disk quotas. read(2) read, readv: read input. readlink(2) readlink: read value of a symbolic link. reboot(2) reboot: reboot system or halt processor. recv(2) recv, recvfrom, recvmsg: receive a message from a socket. rename(2) rename: change the name of a file. rmdir(2) rmdir: remove a directory file. select(2) select: synchronous I/O multiplexing. send(2) send, sendto, sendmsg: send a message from a socket. setgroups(2) setgroups: set group access list. setpgrp(2) setpgrp: set process group. setquota(2) setquota: enable/disable quotas on a file system. setregid(2) setregid: set real and effective group ID. setreuid(2) setreuid: set real and effective user ID's. shutdown(2) shutdown: shut down part of a full-duplex connection. sigblock(2) sigblock: block signals. sigpause(2) sigpause: atomically release blocked signals and wait for interrupt. sigreturn(2) sigreturn: return from signal. sigsetmask(2) sigsetmask: set current signal mask. sigstack(2) sigstack: set and/or get signal stack context. sigvec(2) sigvec: software signal facilities. socket(2) socket: create an endpoint for communication. socketpair(2) socketpair: create a pair of connected sockets. stat(2) stat, lstat, fstat: get file status. swapon(2) swapon: add a swap device for interleaved paging/swapping. symlink(2) symlink: make symbolic link to a file. sync(2) sync: update super-block. syscall(2) syscall: indirect system call. truncate(2) truncate: truncate a file to a specified length. umask(2) umask: set file creation mode mask. unlink(2) unlink: remove directory entry. utimes(2) utimes: set file times. vfork(2) vfork: spawn new process in a virtual memory efficient way. vhangup(2) vhangup: virtually ``hangup'' the current control terminal. wait(2) wait, wait3: wait for process to terminate. write(2) write, writev: write output. ================================================ FILE: share/man/man0/tocx3 ================================================ abort(3) abort: generate a fault. abs(3) abs: integer absolute value. alarm(3c) alarm: schedule signal after specified time. asinh(3m) asinh, acosh, atanh: inverse hyperbolic functions. assert(3) assert: program verification. atof(3) atof, atoi, atol: convert ASCII to numbers. bstring(3) bcopy, bcmp, bzero, ffs: bit and byte string operations. byteorder(3n) htonl, htons, ntohl, ntohs: convert values between host and network byte order. crypt(3) crypt, setkey, encrypt: DES encryption. ctime(3) ctime, localtime, gmtime, asctime, timezone: convert date and time to ASCII. ctype(3) isalpha, isupper, islower, isdigit, isxdigit, isalnum, isspace, ispunct, isprint, isgraph, iscntrl, isascii, toupper, tolower, toascii: character classification macros. curses(3x) curses: screen functions with ``optimal'' cursor motion. dbm(3x) dbminit, fetch, store, delete, firstkey, nextkey: data base subroutines. directory(3) opendir, readdir, telldir, seekdir, rewinddir, closedir: directory operations. ecvt(3) ecvt, fcvt, gcvt: output conversion. end(3) end, etext, edata: last locations in program. erf(3m) erf, erfc: error functions. execl(3) execl, execv, execle, execlp, execvp, exec, execve, exect, environ: execute a file. exit(3) exit: terminate a process after flushing any pending output. exp(3m) exp, expm1, log, log10, log1p, pow: exponential, logarithm, power. fclose(3s) fclose, fflush: close or flush a stream. ferror(3s) ferror, feof, clearerr, fileno: stream status inquiries. floor(3m) fabs, floor, ceil, rint: absolute value, floor, ceiling, and round-to-nearest functions. fopen(3s) fopen, freopen, fdopen: open a stream. fread(3s) fread, fwrite: buffered binary input/output. frexp(3) frexp, ldexp, modf: split into mantissa and exponent. fseek(3s) fseek, ftell, rewind: reposition a stream. getc(3s) getc, getchar, fgetc, getw: get character or word from stream. getdisk(3) getdiskbyname: get disk description by its name. getenv(3) getenv: value for environment name. getfsent(3) getfsent, getfsspec, getfsfile, getfstype, setfsent, endfsent: get file system descriptor file entry. getgrent(3) getgrent, getgrgid, getgrnam, setgrent, endgrent: get group file entry. gethostbyname(3n) gethostbyname, gethostbyaddr, gethostent, sethostent, endhostent: get network host entry. getlogin(3) getlogin: get login name. getnetent(3n) getnetent, getnetbyaddr, getnetbyname, setnetent, endnetent: get network entry. getopt(3) getopt: get option letter from argv. getpass(3) getpass: read a password. getprotoent(3n) getprotoent, getprotobynumber, getprotobyname, setprotoent, endprotoent: get protocol entry. getpw(3c) getpw: get name from uid. getpwent(3) getpwent, getpwuid, getpwnam, setpwent, endpwent, setpwfile: get password file entry. gets(3s) gets, fgets: get a string from a stream. getservent(3n) getservent, getservbyport, getservbyname, setservent, endservent: get service entry. getttyent(3) getttyent, getttynam, setttyent, endttyent: get ttys file entry. getusershell(3) getusershell, setusershell, endusershell: get legal user shells. getwd(3) getwd: get current working directory pathname. hypot(3m) hypot, cabs: Euclidean distance, complex absolute value. ieee(3m) copysign, drem, finite, logb, scalb: copysign, remainder, exponent manipulations. inet(3n) inet_addr, inet_network, inet_ntoa, inet_makeaddr, inet_lnaof, inet_netof: Internet address manipulation routines. infnan(3m) infnan: signals invalid floating-point operations on a VAX (temporary). initgroups(3) initgroups: initialize group access list. insque(3) insque, remque: insert/remove element from a queue. intro(3) intro: introduction to C library functions. j0(3m) j0, j1, jn, y0, y1, yn: bessel functions. lgamma(3m) lgamma: log gamma function. lib2648(3x) lib2648: subroutines for the HP 2648 graphics terminal. malloc(3) malloc, free, realloc, calloc, alloca: memory allocator. math(3m) math: introduction to mathematical library functions. mktemp(3) mktemp: make a unique file name. monitor(3) monitor, monstartup, moncontrol: prepare execution profile. mp(3x) madd, msub, mult, mdiv, pow, gcd, invert, rpow, msqrt, mcmp, move, min, omin, fmin, m_in, mout, omout, fmout, m_out, sdiv, itom: multiple precision integer arithmetic. ndbm(3) dbm_open, dbm_close, dbm_fetch, dbm_store, dbm_delete, dbm_firstkey, dbm_nextkey, dbm_error, dbm_clearerr: data base subroutines. nice(3c) nice: set program priority. nlist(3) nlist: get entries from name list. ns(3n) ns_addr, ns_ntoa: Xerox NS(tm) address conversion routines. pause(3c) pause: stop until signal. perror(3) perror, sys_errlist, sys_nerr: system error messages. plot(3x) plot: openpl, erase, label, line, circle, arc, move, cont, point, linemod, space, closepl: graphics interface. popen(3) popen, pclose: initiate I/O to/from a process. printf(3s) printf, fprintf, sprintf: formatted output conversion. psignal(3) psignal, sys_siglist: system signal messages. putc(3s) putc, putchar, fputc, putw: put character or word on a stream. puts(3s) puts, fputs: put a string on a stream. qsort(3) qsort: quicker sort. rand(3c) rand, srand: random number generator. random(3) random, srandom, initstate, setstate: better random number generator; routines for changing generators. rcmd(3) rcmd, rresvport, ruserok: routines for returning a stream to a remote command. regex(3) re_comp, re_exec: regular expression handler. resolver(3) res_mkquery, res_send, res_init, dn_comp, dn_expand: resolver routines. rexec(3) rexec: return stream to a remote command. scandir(3) scandir, alphasort: scan a directory. scanf(3s) scanf, fscanf, sscanf: formatted input conversion. setbuf(3s) setbuf, setbuffer, setlinebuf: assign buffering to a stream. setjmp(3) setjmp, longjmp: non-local goto. setuid(3) setuid, seteuid, setruid, setgid, setegid, setrgid: set user and group ID. siginterrupt(3) siginterrupt: allow signals to interrupt system calls. signal(3c) signal: simplified software signal facilities. sin(3m) sin, cos, tan, asin, acos, atan, atan2: trigonometric functions and their inverses. sinh(3m) sinh, cosh, tanh: hyperbolic functions. sleep(3) sleep: suspend execution for interval. sqrt(3m) cbrt, sqrt: cube root, square root. stdio(3s) stdio: standard buffered input/output package. string(3) strcat, strncat, strcmp, strncmp, strcpy, strncpy, strlen, index, rindex: string operations. stty(3c) stty, gtty: set and get terminal state (defunct). swab(3) swab: swap bytes. syslog(3) syslog, openlog, closelog, setlogmask: control system log. system(3) system: issue a shell command. termcap(3x) tgetent, tgetnum, tgetflag, tgetstr, tgoto, tputs: terminal independent operation routines. time(3c) time, ftime: get date and time. times(3c) times: get process times. ttyname(3) ttyname, isatty, ttyslot: find name of a terminal. ualarm(3) ualarm: schedule signal after specified time. ungetc(3s) ungetc: push character back into input stream. usleep(3) usleep: suspend execution for interval. utime(3c) utime: set file times. valloc(3c) valloc: aligned memory allocator. varargs(3) varargs: variable argument list. vlimit(3c) vlimit: control maximum system resource consumption. vtimes(3c) vtimes: get information about resource utilization. ================================================ FILE: share/man/man0/tocx3f ================================================ abort(3f) abort: abnormal termination. access(3f) access: determine accessability of a file. alarm(3f) alarm: execute a subroutine after a specified time. bessel(3f) bessel functions: of two kinds for integer orders. bit(3f) bit: and, or, xor, not, rshift, lshift bitwise functions. chdir(3f) chdir: change default directory. chmod(3f) chmod: change mode of a file. etime(3f) etime, dtime: return elapsed execution time. exit(3f) exit: terminate process with status. fdate(3f) fdate: return date and time in an ASCII string. flmin(3f) flmin, flmax, ffrac, dflmin, dflmax, dffrac, inmax: return extreme values. flush(3f) flush: flush output to a logical unit. fork(3f) fork: create a copy of this process. fseek(3f) fseek, ftell: reposition a file on a logical unit. getarg(3f) getarg, iargc: return command line arguments. getc(3f) getc, fgetc: get a character from a logical unit. getcwd(3f) getcwd: get pathname of current working directory. getenv(3f) getenv: get value of environment variables. getlog(3f) getlog: get user's login name. getpid(3f) getpid: get process id. getuid(3f) getuid, getgid: get user or group ID of the caller. hostnm(3f) hostnm: get name of current host. idate(3f) idate, itime: return date or time in numerical form. index(3f) index, rindex, lnblnk, len: tell about character objects. intro(3f) intro: introduction to FORTRAN library functions. ioinit(3f) ioinit: change f77 I/O initialization. kill(3f) kill: send a signal to a process. link(3f) link: make a link to an existing file. loc(3f) loc: return the address of an object. long(3f) long, short: integer object conversion. malloc(3f) malloc, free, falloc: memory allocator. perror(3f) perror, gerror, ierrno: get system error messages. plot(3f) plot: openpl et al.: f77 library interface to \fIplot\fR (3X) libraries.. putc(3f) putc, fputc: write a character to a fortran logical unit. qsort(3f) qsort: quick sort. rand(3f) rand, drand, irand: return random values. random(3f) random, drandm, irandm: better random number generator. rename(3f) rename: rename a file. signal(3f) signal: change the action for a signal. sleep(3f) sleep: suspend execution for an interval. stat(3f) stat, lstat, fstat: get file status. system(3f) system: execute a UNIX command. time(3f) time, ctime, ltime, gmtime: return system time. topen(3f) topen, tclose, tread, twrite, trewin, tskipf, tstate: f77 tape I/O. traper(3f) traper: trap arithmetic errors. trapov(3f) trapov: trap and repair floating point overflow. trpfpe(3f) trpfpe, fpecnt: trap and repair floating point faults. ttynam(3f) ttynam, isatty: find name of a terminal port. unlink(3f) unlink: remove a directory entry. wait(3f) wait: wait for a process to terminate. ================================================ FILE: share/man/man0/tocx4 ================================================ acc(4) acc: ACC LH/DH IMP interface. ad(4) ad: Data Translation A/D converter. arp(4p) arp: Address Resolution Protocol. autoconf(4) autoconf: diagnostics from the autoconfiguration code. bk(4) bk: line discipline for machine-machine communication (obsolete). cons(4) cons: VAX-11 console interface. crl(4) crl: VAX 8600 console RL02 interface. css(4) css: DEC IMP-11A LH/DH IMP interface. ct(4) ct: phototypesetter interface. ddn(4) ddn: DDN Standard Mode X.25 IMP interface. de(4) de: DEC DEUNA 10 Mb/s Ethernet interface. dh(4) dh: DH-11/DM-11 communications multiplexer. dhu(4) dhu: DHU-11 communications multiplexer. dmc(4) dmc: DEC DMC-11/DMR-11 point-to-point communications device. dmf(4) dmf: DMF-32, terminal multiplexor. dmz(4) dmz: DMZ-32 terminal multiplexor. dn(4) dn: DN-11 autocall unit interface. drum(4) drum: paging device. dz(4) dz: DZ-11 communications multiplexer. ec(4) ec: 3Com 10 Mb/s Ethernet interface. en(4) en: Xerox 3 Mb/s Ethernet interface. ex(4) ex: Excelan 10 Mb/s Ethernet interface. fl(4) fl: console floppy interface. hdh(4) hdh: ACC IF-11/HDH IMP interface. hk(4) hk: RK6-11/RK06 and RK07 moving head disk. hp(4) hp: MASSBUS disk interface. ht(4) ht: TM-03/TE-16,TU-45,TU-77 MASSBUS magtape interface. hy(4) hy: Network Systems Hyperchannel interface. icmp(4p) icmp: Internet Control Message Protocol. idp(4p) idp: Xerox Internet Datagram Protocol. ik(4) ik: Ikonas frame buffer, graphics device interface. il(4) il: Interlan NI1010 10 Mb/s Ethernet interface. imp(4) imp: 1822 network interface. imp(4p) imp: IMP raw socket interface. inet(4f) inet: Internet protocol family. intro(4) intro: introduction to special files and hardware support. intro(4n) networking: introduction to networking facilities. ip(4p) ip: Internet Protocol. ix(4) ix: Interlan Np100 10 Mb/s Ethernet interface. kg(4) kg: KL-11/DL-11W line clock. lo(4) lo: software loopback network interface. lp(4) lp: line printer. mem(4) mem, kmem: main memory. mt(4) mt: TM78/TU-78 MASSBUS magtape interface. mtio(4) mtio: UNIX magtape interface. np(4) np: Interlan Np100 10 Mb/s Ethernet interface. ns(4f) ns: Xerox Network Systems(tm) protocol family. nsip(4) nsip: software network interface encapsulating ns packets in ip packets.. null(4) null: data sink. pcl(4) pcl: DEC CSS PCL-11 B Network Interface. ps(4) ps: Evans and Sutherland Picture System 2 graphics device interface. pty(4) pty: pseudo terminal driver. qe(4) qe: DEC DEQNA Q-bus 10 Mb/s Ethernet interface. rx(4) rx: DEC RX02 floppy disk interface. spp(4p) spp: Xerox Sequenced Packet Protocol. tb(4) tb: line discipline for digitizing devices. tcp(4p) tcp: Internet Transmission Control Protocol. tm(4) tm: TM-11/TE-10 magtape interface. tmscp(4) tmscp: DEC TMSCP magtape interface. ts(4) ts: TS-11 magtape interface. tty(4) tty: general terminal interface. tu(4) tu: VAX-11/730 and VAX-11/750 TU58 console cassette interface. uda(4) uda: UDA-50 disk controller interface. udp(4p) udp: Internet User Datagram Protocol. up(4) up: unibus storage module controller/drives. ut(4) ut: UNIBUS TU45 tri-density tape drive interface. uu(4) uu: TU58/DECtape II UNIBUS cassette interface. va(4) va: Benson-Varian interface. vp(4) vp: Versatec interface. vv(4) vv: Proteon proNET 10 Megabit ring. ================================================ FILE: share/man/man0/tocx5 ================================================ L-devices(5) L-devices: UUCP device description file. L-dialcodes(5) L-dialcodes: UUCP phone number index file. L.aliases(5) L.aliases: UUCP hostname alias file. L.cmds(5) L.cmds: UUCP remote command permissions file. L.sys(5) L.sys: UUCP remote host description file. USERFILE(5) USERFILE: UUCP pathname permissions file. a.out(5) a.out: assembler and link editor output. acct(5) acct: execution accounting file. aliases(5) aliases: aliases file for sendmail. ar(5) ar: archive (library) file format. core(5) core: format of memory image file. dbx(5) dbx: dbx symbol table information. dir(5) dir: format of directories. disktab(5) disktab: disk description file. dump(5) dump, dumpdates: incremental dump format. fs(5) fs, inode: format of file system volume. fstab(5) fstab: static information about the filesystems. gettytab(5) gettytab: terminal configuration data base. group(5) group: group file. hosts(5) hosts: host name data base. map3270(5) map3270: database for mapping ascii keystrokes into IBM 3270 keys. mtab(5) mtab: mounted file system table. networks(5) networks: network name data base. passwd(5) passwd: password file. phones(5) phones: remote host phone number data base. plot(5) plot: graphics interface. printcap(5) printcap: printer capability data base. protocols(5) protocols: protocol name data base. remote(5) remote: remote host description file. resolver(5) resolver configuration file. services(5) services: service name data base. stab(5) stab: symbol table types. tar(5) tar: tape archive file format. termcap(5) termcap: terminal capability data base. tp(5) tp: DEC/mag tape formats. ttys(5) ttys: terminal initialization data. types(5) types: primitive system data types. utmp(5) utmp, wtmp: login records. uuencode(5) uuencode: format of an encoded uuencode file. vfont(5) vfont: font formats for the Benson-Varian or Versatec. vgrindefs(5) vgrindefs: vgrind's language definition data base. ================================================ FILE: share/man/man0/tocx6 ================================================ aardvark(6) aardvark: yet another exploration game. adventure(6) adventure: an exploration game. arithmetic(6) arithmetic: provide drill in number facts. backgammon(6) backgammon: the game. banner(6) banner: print large banner on printer. battlestar(6) battlestar: a tropical adventure game. bcd(6) bcd: convert to antique media. boggle(6) boggle: play the game of boggle. canfield(6) canfield, cfscores: the solitaire card game canfield. chess(6) chess: the game of chess. ching(6) ching: the book of changes and other cookies. cribbage(6) cribbage: the card game cribbage. doctor(6) doctor: interact with a psychoanalyst. fish(6) fish: play ``Go Fish''. fortune(6) fortune: print a random, hopefully interesting, adage. hangman(6) hangman: Computer version of the game hangman. hunt(6) hunt: a multi-player multi-terminal game. mille(6) mille: play Mille Bournes. monop(6) monop: Monopoly game. number(6) number: convert Arabic numerals to English. quiz(6) quiz: test your knowledge. rain(6) rain: animated raindrops display. robots(6) robots: fight off villainous robots. rogue(6) rogue: Exploring The Dungeons of Doom. sail(6) sail: multi-user wooden ships and iron men. snake(6) snake, snscore: display chase game. trek(6) trek: trekkie game. worm(6) worm: Play the growing worm game. worms(6) worms: animate worms on a display terminal. wump(6) wump: the game of hunt-the-wumpus. zork(6) zork: the game of dungeon. ================================================ FILE: share/man/man0/tocx7 ================================================ ascii(7) ascii: map of ASCII character set. environ(7) environ: user environment. eqnchar(7) eqnchar: special character definitions for eqn. hier(7) hier: file system hierarchy. intro(7) miscellaneous: miscellaneous useful information pages. mailaddr(7) mailaddr: mail addressing description. man(7) man: macros to typeset manual. me(7) me: macros for formatting papers. ms(7) ms: text formatting macros. term(7) term: conventional names for terminals. ================================================ FILE: share/man/man0/tocx8 ================================================ XNSrouted(8c) XNSrouted: NS Routing Information Protocol daemon. ac(8) ac: login accounting. adduser(8) adduser: procedure for adding new users. arff(8v) arff, flcopy: archiver and copier for floppy. arp(8c) arp: address resolution display and control. bad144(8) bad144: read/write dec standard 144 bad sector information. badsect(8) badsect: create files to contain bad sectors. bugfiler(8) bugfiler: file bug reports in folders automatically. catman(8) catman: create the cat files for the manual. chown(8) chown: change owner. clri(8) clri: clear i-node. comsat(8c) comsat: biff server. config(8) config: build system configuration files. crash(8v) crash: what happens when the system crashes. cron(8) cron: clock daemon. dcheck(8) dcheck: file system directory consistency check. diskpart(8) diskpart: calculate default disk partition sizes. dmesg(8) dmesg: collect system diagnostic messages to form error log. drtest(8) drtest: standalone disk test program. dump(8) dump: incremental file system dump. dumpfs(8) dumpfs: dump file system information. edquota(8) edquota: edit user quotas. fastboot(8) fastboot, fasthalt: reboot/halt the system without checking the disks. fingerd(8c) fingerd: remote user information server. format(8v) format: how to format disk packs. fsck(8) fsck: file system consistency check and interactive repair. ftpd(8c) ftpd: DARPA Internet File Transfer Protocol server. gettable(8c) gettable: get NIC format host tables from a host. getty(8) getty: set terminal mode. halt(8) halt: stop the processor. htable(8) htable: convert NIC standard format host tables. icheck(8) icheck: file system storage consistency check. ifconfig(8c) ifconfig: configure network interface parameters. implog(8c) implog: IMP log interpreter. implogd(8c) implogd: IMP logger process. inetd(8) inetd: internet ``super\-server''. init(8) init: process control initialization. intro(8) intro: introduction to system maintenance and operation commands. kgmon(8) kgmon: generate a dump of the operating system's profile buffers. lpc(8) lpc: line printer control program. lpd(8) lpd: line printer daemon. makedev(8) makedev: make system special files. makekey(8) makekey: generate encryption key. mkfs(8) mkfs: construct a file system. mkhosts(8) mkhosts: generate hashed host table. mklost+found(8) mklost+found: make a lost+found directory for fsck. mknod(8) mknod: build special file. mkpasswd(8) mkpasswd: generate hashed password table. mkproto(8) mkproto: construct a prototype file system. mount(8) mount, umount: mount and dismount file system. named(8) named: Internet domain name server. ncheck(8) ncheck: generate names from i-numbers. newfs(8) newfs: construct a new file system. pac(8) pac: printer/plotter accounting information. ping(8) ping: send ICMP ECHO_REQUEST packets to network hosts. pstat(8) pstat: print system facts. quot(8) quot: summarize file system ownership. quotacheck(8) quotacheck: file system quota consistency checker. quotaon(8) quotaon, quotaoff: turn file system quotas on and off. rc(8) rc: command script for auto-reboot and daemons. rdump(8c) rdump: file system dump across the network. reboot(8) reboot: UNIX bootstrapping procedures. renice(8) renice: alter priority of running processes. repquota(8) repquota: summarize quotas for a file system. restore(8) restore: incremental file system restore. rexecd(8c) rexecd: remote execution server. rlogind(8c) rlogind: remote login server. rmt(8c) rmt: remote magtape protocol module. route(8c) route: manually manipulate the routing tables. routed(8c) routed: network routing daemon. rrestore(8c) rrestore: restore a file system dump across the network. rshd(8c) rshd: remote shell server. rwhod(8c) rwhod: system status server. rxformat(8v) rxformat: format floppy disks. sa(8) sa, accton: system accounting. savecore(8) savecore: save a core dump of the operating system. sendmail(8) sendmail: send mail over the internet. shutdown(8) shutdown: close down the system at a given time. slattach(8c) slattach: attach serial lines as network interfaces. sticky(8) sticky: persistent text and append-only directories. swapon(8) swapon: specify additional device for paging and swapping. sync(8) sync: update the super block. syslogd(8) syslogd: log systems messages. talkd(8c) talkd: remote user communication server. telnetd(8c) telnetd: DARPA TELNET protocol server. tftpd(8c) tftpd: DARPA Trivial File Transfer Protocol server. timed(8) timed: time server daemon. timedc(8) timedc: timed control program. trpt(8c) trpt: transliterate protocol trace. trsp(8c) trsp: transliterate sequenced packet protocol trace. tunefs(8) tunefs: tune up an existing file system. update(8) update: periodically update the super block. uucico(8c) uucico, uucpd: transfer files queued by uucp or uux. uuclean(8c) uuclean: uucp spool directory clean-up. uupoll(8c) uupoll: poll a remote UUCP site. uusnap(8c) uusnap: show snapshot of the UUCP system. uuxqt(8c) uuxqt: UUCP execution file interpreter. vipw(8) vipw: edit the password file. ================================================ FILE: share/man/man1/Makefile ================================================ # # Copyright (c) 1987 Regents of the University of California. # All rights reserved. # # Redistribution and use in source and binary forms are permitted # provided that the above copyright notice and this paragraph are # duplicated in all such forms and that any documentation, # advertising materials, and other materials related to such # distribution and use acknowledge that the software was developed # by the University of California, Berkeley. The name of the # University may not be used to endorse or promote products derived # from this software without specific prior written permission. # THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED # WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. # # @(#)Makefile 1.9 (2.11BSD) 1998/1/24 # TOPSRC!=cd ../../..; pwd include ${TOPSRC}/share/mk/sys.mk MDIR= /usr/share/man/cat1 SRCS= adb.1 addbib.1 apply.1 apropos.1 as.1 at.1 atq.1 atrm.1 \ awk.1 basename.1 biff.1 binmail.1 cal.1 calendar.1 cat.1 \ cb.1 cc.1 cd.1 checknr.1 chgrp.1 chmod.1 clear.1 cmp.1 col.1 \ colcrt.1 colrm.1 comm.1 compress.1 cp.1 csh.1 ctags.1 date.1 \ dd.1 deroff.1 df.1 diction.1 diff.1 diff3.1 du.1 echo.1 ed.1 \ efl.1 eqn.1 error.1 ex.1 expand.1 expr.1 f77.1 false.1 file.1 \ find.1 fmt.1 fold.1 fpr.1 from.1 fsplit.1 gcore.1 \ graph.1 grep.1 head.1 hostid.1 indent.1 \ intro.1 join.1 kill.1 last.1 lastcomm.1 \ learn.1 leave.1 lex.1 lint.1 lisp.1 ln.1 logger.1 login.1 \ look.1 lookbib.1 lorder.1 lpq.1 lpr.1 lprm.1 lptest.1 ls.1 \ lxref.1 m4.1 mail.1 make.1 man.1 mesg.1 mkdep.1 mkdir.1 mkstr.1 \ more.1 mset.1 msgs.1 mt.1 mv.1 netstat.1 newaliases.1 nice.1 nm.1 SRCS1= nroff.1 nslookup.1 od.1 pagesize.1 pdx.1 pi.1 pix.1 \ plot.1 pmerge.1 pr.1 printenv.1 prof.1 ps.1 ptx.1 pwd.1 px.1 pxp.1 \ pxref.1 quota.1 ratfor.1 rcp.1 rdist.1 refer.1 rev.1 \ rlogin.1 rm.1 rmail.1 rmdir.1 roffbib.1 rsh.1 ruptime.1 rwho.1 \ sccs.1 script.1 sed.1 sendbug.1 sh.1 size.1 sleep.1 soelim.1 \ sort.1 sortbib.1 spell.1 spline.1 split.1 strcompact.1 strings.1 \ strip.1 style.1 su.1 sum.1 symcompact.1 symorder.1 \ tabs.1 tail.1 talk.1 \ tar.1 tbl.1 tc.1 tcopy.1 tee.1 telnet.1 time.1 \ tip.1 tk.1 tn3270.1 touch.1 tp.1 tr.1 troff.1 true.1 \ tsort.1 tty.1 ul.1 unifdef.1 uniq.1 units.1 uptime.1 users.1 \ uucp.1 uuencode.1 uulog.1 uuname.1 uuq.1 uusend.1 uux.1 \ vacation.1 vgrind.1 vi.1 vmstat.1 vwidth.1 w.1 wait.1 wall.1 wc.1 \ what.1 whatis.1 which.1 who.1 whois.1 window.1 \ write.1 xstr.1 yacc.1 yes.1 OBJS1= adb.0 addbib.0 apply.0 apropos.0 as.0 at.0 atq.0 atrm.0 \ awk.0 basename.0 biff.0 binmail.0 cal.0 calendar.0 cat.0 \ cb.0 cc.0 cd.0 checknr.0 chgrp.0 chmod.0 clear.0 cmp.0 col.0 \ colcrt.0 colrm.0 comm.0 compress.0 cp.0 csh.0 ctags.0 date.0 \ dd.0 deroff.0 df.0 diction.0 diff.0 diff3.0 du.0 echo.0 ed.0 \ efl.0 eqn.0 error.0 ex.0 expand.0 expr.0 f77.0 false.0 file.0 \ find.0 fmt.0 fold.0 fpr.0 from.0 fsplit.0 gcore.0 \ graph.0 grep.0 head.0 hostid.0 indent.0 \ intro.0 join.0 kill.0 last.0 lastcomm.0 \ learn.0 leave.0 lex.0 lint.0 lisp.0 ln.0 logger.0 login.0 \ look.0 lookbib.0 lorder.0 lpq.0 lpr.0 lprm.0 lptest.0 ls.0 \ lxref.0 m4.0 mail.0 make.0 man.0 mesg.0 mkdep.0 mkdir.0 mkstr.0 \ more.0 mset.0 msgs.0 mt.0 mv.0 netstat.0 newaliases.0 nice.0 nm.0 OBJS2= nroff.0 nslookup.0 od.0 pagesize.0 pdx.0 pi.0 pix.0 \ plot.0 pmerge.0 pr.0 printenv.0 prof.0 ps.0 ptx.0 pwd.0 px.0 pxp.0 \ pxref.0 quota.0 ratfor.0 rcp.0 rdist.0 refer.0 rev.0 \ rlogin.0 rm.0 rmail.0 rmdir.0 roffbib.0 rsh.0 ruptime.0 rwho.0 \ sccs.0 script.0 sed.0 sendbug.0 sh.0 size.0 sleep.0 soelim.0 \ sort.0 sortbib.0 spell.0 spline.0 split.0 strcompact.0 strings.0 \ strip.0 style.0 su.0 sum.0 symcompact.0 symorder.0 \ tabs.0 tail.0 talk.0 \ tar.0 tbl.0 tc.0 tcopy.0 tee.0 telnet.0 time.0 \ tip.0 tk.0 tn3270.0 touch.0 tp.0 tr.0 troff.0 true.0 \ tsort.0 tty.0 ul.0 unifdef.0 uniq.0 units.0 uptime.0 users.0 \ uucp.0 uuencode.0 uulog.0 uuname.0 uuq.0 uusend.0 uux.0 \ vacation.0 vgrind.0 vi.0 vmstat.0 vwidth.0 w.0 wait.0 wall.0 wc.0 \ what.0 whatis.0 which.0 who.0 whois.0 window.0 \ write.0 xstr.0 yacc.0 yes.0 .SUFFIXES: .1 .0 .1.0: ${MANROFF} $*.1 > $*.0 all: _make_01 _make_02 _make_01: ${OBJS1} _make_02: ${OBJS2} # mandoc accepts and processes the eqn language, # and gives cleaner output than "eqn | nroff" #eqn.0: # eqn eqn.1 | ${MANROFF} > $@ clean: FRC rm -f ${OBJS1} rm -f ${OBJS2} install: _make_01 _make_02 cp ${OBJS1} ${DESTDIR}${MDIR} cp ${OBJS2} ${DESTDIR}${MDIR} ln -f ${DESTDIR}/${MDIR}/sh.0 ${DESTDIR}${MDIR}/case.0 ln -f ${DESTDIR}/${MDIR}/eqn.0 ${DESTDIR}${MDIR}/checkeq.0 ln -f ${DESTDIR}${MDIR}/tip.0 ${DESTDIR}${MDIR}/cu.0 ln -f ${DESTDIR}${MDIR}/diff.0 ${DESTDIR}${MDIR}/diffh.0 ln -f ${DESTDIR}${MDIR}/ex.0 ${DESTDIR}${MDIR}/edit.0 ln -f ${DESTDIR}${MDIR}/grep.0 ${DESTDIR}${MDIR}/egrep.0 ln -f ${DESTDIR}${MDIR}/diction.0 ${DESTDIR}${MDIR}/explain.0 ln -f ${DESTDIR}${MDIR}/grep.0 ${DESTDIR}${MDIR}/fgrep.0 ln -f ${DESTDIR}${MDIR}/sh.0 ${DESTDIR}${MDIR}/for.0 ln -f ${DESTDIR}${MDIR}/sh.0 ${DESTDIR}${MDIR}/if.0 ln -f ${DESTDIR}${MDIR}/lookbib.0 ${DESTDIR}${MDIR}/indxbib.0 ln -f ${DESTDIR}${MDIR}/eqn.0 ${DESTDIR}${MDIR}/neqn.0 ln -f ${DESTDIR}${MDIR}/nice.0 ${DESTDIR}${MDIR}/nohup.0 ln -f ${DESTDIR}${MDIR}/more.0 ${DESTDIR}${MDIR}/page.0 ln -f ${DESTDIR}${MDIR}/spell.0 ${DESTDIR}${MDIR}/spellin.0 ln -f ${DESTDIR}${MDIR}/spell.0 ${DESTDIR}${MDIR}/spellout.0 ln -f ${DESTDIR}${MDIR}/compress.0 ${DESTDIR}${MDIR}/uncompress.0 ln -f ${DESTDIR}${MDIR}/expand.0 ${DESTDIR}${MDIR}/unexpand.0 ln -f ${DESTDIR}${MDIR}/uuencode.0 ${DESTDIR}${MDIR}/uudecode.0 ln -f ${DESTDIR}${MDIR}/sh.0 ${DESTDIR}${MDIR}/while.0 ln -f ${DESTDIR}${MDIR}/compress.0 ${DESTDIR}${MDIR}/zcat.0 FRC: ================================================ FILE: share/man/man1/adb.1 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)adb.1 6.1.1 (2.11BSD) 1996/10/21 .\" .TH ADB 1 "October 21, 1996" .UC 2 .SH NAME adb \- debugger (2BSD) .SH SYNOPSIS .B adb [\fB\-w\fR] [ \fB\-k\fR ] [ \fB-I\fRdir ] [ objfil [ corfil ] ] .ds TW \v'.25m'\s+2~\s-2\v'-.25m' .ds ST * .ds IM \v'.1m'=\v'-.1m'\s-2\h'-.1m'>\h'.1m'\s+2 .ds LE \(<= .ds LT \s-2<\s+2 .ds GT \s-2>\s+2 .SH DESCRIPTION .I Adb is a general purpose debugging program. It may be used to examine files and to provide a controlled environment for the execution of UNIX programs. .PP .I Objfil is normally an executable program file, preferably containing a symbol table; if not then the symbolic features of .I adb cannot be used although the file can still be examined. The default for .I objfil is .B a.out. .I Corfil is assumed to be a core image file produced after executing .IR objfil ; the default for .I corfil is .B core. .PP Requests to .I adb are read from the standard input and responses are to the standard output. If the .B \-w flag is present then both .I objfil and .I corfil are created if necessary and opened for reading and writing so that files can be modified using .IR adb . .PP The \fB\-k\fP option makes \fIadb\fP do UNIX kernel memory mapping; it should be used when \fIcore\fP is a UNIX crash dump or \fI/dev/mem\fP. .PP The \fB\-I\fP option specifies a directory where files to be read with $< or $<< (see below) will be sought; the default is .IR /usr/share/adb . .PP .I Adb ignores QUIT; INTERRUPT causes return to the next .I adb command. .PP In general requests to .I adb are of the form .PP .if n .ti 16 .if t .ti 1.6i [\|\fIaddress\fR\|] [\|, .IR count \|] [\|\fIcommand\fR\|] [\|;\|] .PP If .I address is present then .I dot is set to .IR address . Initially .I dot is set to 0. For most commands .I count specifies how many times the command will be executed. The default .I count is 1. .I Address and .I count are expressions. .PP The interpretation of an address depends on the context it is used in. If a subprocess is being debugged then addresses are interpreted in the usual way in the address space of the subprocess. For further details of address mapping see .SM ADDRESSES. .SH EXPRESSIONS .TP 7.2n .B . The value of .IR dot . .TP 7.2n + The value of .I dot incremented by the current increment. .TP 7.2n ^ The value of .I dot decremented by the current increment. .TP 7.2n " The last .I address typed. .TP 7.2n .I integer An octal number if .I integer begins with a 0; a hexadecimal number if preceded by .BR # ; otherwise a decimal number. This default interpretation of integers may be changed via the $o and $d commands. .TP 7.2n .IB integer . fraction A 32 bit floating point number. .TP 7.2n .I \'cccc\|\' The ASCII value of up to 4 characters. \e may be used to escape a \'. .TP 7.2n .I \*(LT name The value of .IR name , which is either a variable name or a register name. .I Adb maintains a number of variables (see .SM VARIABLES\*S) named by single letters or digits. If .I name is a register name then the value of the register is obtained from the system header in .IR corfil . The register names are those printed by the $r command. .TP 7.2n .I symbol A .I symbol is a sequence of upper or lower case letters, underscores or digits, not starting with a digit. The backslash character .B \e may be used to escape other characters. The value of the .I symbol is taken from the symbol table in .IR objfil . An initial \_ or \*(TW will be prepended to .I symbol if needed. If the symbol is a text symbol and .I objfil is an overlay type, the default is .IR \*(TWsymbol , which is the subroutine itself, not the entry interface in the base segment. .TP .I _ symbol In C, the `true name' of an external symbol begins with _. It may be necessary to utter this name to distinguish it from internal or hidden variables of a program. For a subroutine in an overlay, .I \*(TWsymbol is the actual subroutine, and .I _symbol is the entry point in the base segment (the "thunk"). Note that to explicitly specify the local name, the \*(TW must be preceeded by a backslash, since \*(TW is the bitwise complement operator: .I \e\*(TWsymbol must be typed. .TP 7.2n .IB routine . name The address of the variable .I name in the specified C routine. Both .I routine and .I name are .IR symbols . If .I name is omitted the value is the address of the most recently activated C stack frame corresponding to .IR routine . .TP 7.2n .RI ( exp \|) The value of the expression .IR exp . .LP .SM .B "Monadic\ operators" .TP 7.2n .RI \*(ST exp The contents of the location addressed by .I exp in .IR corfil . .TP 7.2n .RI @ exp The contents of the location addressed by .I exp in .IR objfil . .TP 7.2n .RI \- exp Integer negation. .TP 7.2n .RI \*(TW exp Bitwise complement. .LP .tr '' .B "Dyadic\ operators" are left associative and are less binding than monadic operators. .TP 7.2n .IR e1 + e2 Integer addition. .TP 7.2n .IR e1 \- e2 Integer subtraction. .TP 7.2n .IR e1 \*(ST e2 Integer multiplication. .TP 7.2n .IR e1 % e2 Integer division. .TP 7.2n .IR e1 & e2 Bitwise conjunction. .TP 7.2n .IR e1 \(bv e2 Bitwise disjunction. .TP 7.2n .IR e1 # e2 .I E1 rounded up to the next multiple of .IR e2 . .DT .SH COMMANDS Most commands consist of a verb followed by a modifier or list of modifiers. The following verbs are available. (The commands `?' and `/' may be followed by `\*(ST'; see .SM ADDRESSES for further details.) .TP .5i .RI ? f Locations starting at .I address in .I objfil are printed according to the format .IR f . .I dot is incremented by the sum of the increments for each format letter (q.v.). .TP .RI / f Locations starting at .I address in .I corfil are printed according to the format .I f and .I dot is incremented as for `?'. .TP .RI = f The value of .I address itself is printed in the styles indicated by the format .IR f . (For .B i format `?' is printed for the parts of the instruction that reference subsequent words.) .PP A .I format consists of one or more characters that specify a style of printing. Each format character may be preceded by a decimal integer that is a repeat count for the format character. While stepping through a format .I dot is incremented temporarily by the amount given for each format letter. If no format is given then the last format is used. The format letters available are as follows. .ta 2.5n .5i .RS .TP .BR o " 2" Print 2 bytes in octal. All octal numbers output by .I adb are preceded by 0. .br .ns .TP .BR O " 4" Print 4 bytes in octal. .br .ns .TP .BR q " 2" Print in signed octal. .br .ns .TP .BR Q " 4" Print long signed octal. .br .ns .TP .BR d " 2" Print in decimal. .br .ns .TP .BR D " 4" Print long decimal. .br .ns .TP .BR x " 2" Print 2 bytes in hexadecimal. .br .ns .TP .BR X " 4" Print 4 bytes in hexadecimal. .br .ns .TP .BR u " 2" Print as an unsigned decimal number. .br .ns .TP .BR U " 4" Print long unsigned decimal. .br .ns .TP .BR f " 4" Print the 32 bit value as a floating point number. .br .ns .TP .BR F " 8" Print double floating point. .br .ns .TP .BR b " 1" Print the addressed byte in octal. .br .ns .TP .BR c " 1" Print the addressed character. .br .ns .TP .BR C " 1" Print the addressed character using the following escape convention. the standard escape convention where control characters are printed as ^X and the delete character is printed as ^?. .br .ns .TP .BI s " n" Print the addressed characters until a zero character is reached. .br .ns .TP .BI S " n" Print a string using the ^\fIX\fR escape convention (see \fBC\fR above). .I n is the length of the string including its zero terminator. .br .ns .TP .BR Y " 4" Print 4 bytes in date format (see .IR ctime (3)). .br .ns .TP .BR i " n" Print as machine instructions. .I n is the number of bytes occupied by the instruction. This style of printing causes variables 1 and 2 to be set to the offset parts of the source and destination respectively. .br .ns .TP .BR a " 0" Print the value of .I dot in symbolic form. Symbols are checked to ensure that they have an appropriate type as indicated below. .LP / local or global data symbol .br ? local or global text symbol .br = local or global absolute symbol .TP .BR p " 2" Print the addressed value in symbolic form using the same rules for symbol lookup as .BR a . .br .tr '' .ns .TP .BR t " 0" When preceded by an integer tabs to the next appropriate tab stop. For example, .B 8t moves to the next 8-space tab stop. .br .ns .TP .BR r " 0" Print a space. .br .ns .TP .BR n " 0" Print a newline. .br .ns .tr '" .TP .BR '...' " 0" Print the enclosed string. .br .tr '' .br .ns .TP .B ^ .I Dot is decremented by the current increment. Nothing is printed. .br .ns .TP + .I Dot is incremented by 1. Nothing is printed. .br .ns .TP \- .I Dot is decremented by 1. Nothing is printed. .RE .TP newline If the previous command temporarily incremented .IR dot , make the increment permanent. Repeat the previous command with a .I count of 1. .TP .RB [ ?/ ] l "\fI value mask\fR" Words starting at .I dot are masked with .I mask and compared with .I value until a match is found. If .B L is used then the match is for 4 bytes at a time instead of 2. If no match is found then .I dot is unchanged; otherwise .I dot is set to the matched location. If .I mask is omitted then \-1 is used. .TP .RB [ ?/ ] w "\fI value ...\fR" Write the 2-byte .I value into the addressed location. If the command is .BR W , write 4 bytes. Odd addresses are not allowed when writing to the subprocess address space. .TP [\fB?/\fR]\fBm\fI b1 e1 f1\fR[\fB?/\fR] .br New values for .RI ( b1,\ e1,\ f1 ) are recorded. If less than three expressions are given then the remaining map parameters are left unchanged. If the `?' or `/' is followed by `\*(ST' then the last segment (\fIb2\fR\|,\|\fIe2\fR\|,\|\fIf2\fR) of the mapping is changed. If the list is terminated by `?' or `/' then the file (\fIobjfil\fR or .I corfil respectively) is used for subsequent requests. (So that, for example, `/m?' will cause `/' to refer to .IR objfil .) .TP .BI \*(GT name .I Dot is assigned to the variable or register named. .TP .B ! A shell (/bin/sh) is called to read the rest of the line following `!'. .TP .RI $ modifier Miscellaneous commands. The available .I modifiers are: .RS .TP .BI < f Read commands from the file .IR f . If this command is executed in a file, further commands in the file are not seen. If .I f is omitted, the current input stream is terminated. If a .I count is given, and is zero, the command will be ignored. The value of the count will be placed in variable .I 9 before the first command in .I f is executed. .br .ns .TP .BI << f Similar to .B < except it can be used in a file of commands without causing the file to be closed. Variable .I 9 is saved during the execution of this command, and restored when it completes. There is a (small) finite limit to the number of .B << files that can be open at once. .br .ns .TP .BI > f Append output to the file .IR f , which is created if it does not exist. If .I f is omitted, output is returned to the terminal. .br .ns .TP .B ? Print process id, the signal which caused stoppage or termination, as well as the registers as \fB$r\fR. This is the default if \fImodifier\fR is omitted. .br .ns .TP .B r Print the general registers and the instruction addressed by .BR pc . .I Dot is set to \fBpc\fR. .br .ns .TP .B f Print the floating registers in single or double length. If the floating point status of .B ps is set to double (0200 bit) then double length is used anyway. .br .ns .TP .B b Print all breakpoints and their associated counts and commands. .br .ns .TP .B a ALGOL 68 stack backtrace. If .I address is given then it is taken to be the address of the current frame (instead of .BR r4 ). If .I count is given then only the first .I count frames are printed. .br .ns .TP .B c C stack backtrace. If .I address is given then it is taken as the address of the current frame instead of the contents of the frame\-pointer register. If .B C is used then the names and (16 bit) values of all automatic and static variables are printed for each active function. If .I count is given then only the first .I count frames are printed. .br .ns .TP .B e The names and values of external variables are printed. .br .ns .TP .B w Set the page width for output to .I address (default 80). .br .ns .TP .B s Set the limit for symbol matches to .I address (default 255). .br .ns .TP .B o All integers input are regarded as octal. .br .ns .TP .B d Reset integer input as described in .SM EXPRESSIONS. .br .ns .TP .B q Exit from .IR adb . .br .ns .TP .B v Print all non zero variables in octal. .br .ns .TP .B m Print the address map. .RE .TP .BI : modifier Manage a subprocess. Available modifiers are: .RS .TP .BI b c Set breakpoint at .IR address . If .I objfil is overlaid and .I address is in the overlay region, the breakpoint is set in the overlay of the symbol mentioned if .I address was given symbolically, otherwise it is set in the current overlay (that in variable c). The breakpoint is executed .IR count \-1 times before causing a stop. Each time the breakpoint is encountered the command .I c is executed. If this command is omitted or sets .I dot to zero then the breakpoint causes a stop. .TP .B d Delete breakpoint at .IR address . .TP .B r Run .I objfil as a subprocess. If .I address is given explicitly then the program is entered at this point; otherwise the program is entered at its standard entry point. .I count specifies how many breakpoints are to be ignored before stopping. Arguments to the subprocess may be supplied on the same line as the command. An argument starting with < or > causes the standard input or output to be established for the command. .TP .BI c s The subprocess is continued with signal .I s, see .IR sigvec (2). If .I address is given then the subprocess is continued at this address. If no signal is specified then the signal that caused the subprocess to stop is sent. Breakpoint skipping is the same as for .BR r . .TP .BI s s As for .B c except that the subprocess is single stepped .I count times. If there is no current subprocess then .I objfil is run as a subprocess as for .BR r . In this case no signal can be sent; the remainder of the line is treated as arguments to the subprocess. .TP .B k The current subprocess, if any, is terminated. .RE .SH VARIABLES .I Adb provides a number of variables. Named variables are set initially by .I adb but are not used subsequently (except for c). Numbered variables are reserved for communication as follows. .TP 0 The last value printed. .br .ns .TP 1 The last offset part of an instruction source. .br .ns .TP 2 The previous value of variable 1. .br .ns .TP 9 The count on the last $< or $<< command. .PP On entry the following are set from the system header in the .IR corfil . If .I corfil does not appear to be a .B core file then these values are set from .IR objfil . .TP b The base address of the data segment. .br .ns .TP c The current overlay. This is set from .IR corfil , and in turn sets the overlay map. This variable and the map may be changed by referring to other overlays symbolically (e.g. by examining text in subroutines in other overlays), using the $r command (which resets c from the core file), or explicitly (with the command >c). .br .ns .TP d The data segment size. .br .ns .TP e The entry point. .br .ns .TP m The `magic' number (0405, 0407, 0410, 0411, 0430 or 0431). The object is overlaid if m is 0430 or 0431. .br .ns .TP o The sum of the overlay segment sizes (if overlaid). .br .ns .TP s The stack segment size. .br .ns .TP t The text segment size. .SH ADDRESSES The address in a file associated with a written address is determined by a mapping associated with that file. Each mapping is represented by two or three triples .RI ( "b1, e1, f1" ), .RI ( "bo, eo, fo" ) for overlaid object files, and .RI ( "b2, e2, f2" ) and the .I file address corresponding to a written .I address is calculated as follows. .PP .if t .ti 1.5i .if n .ti 8 .IR b1 \*(LE address < e1 \*(IM .IR "file address" = address + f1\-b1, otherwise, .PP if overlaid, .if t .ti 1.5i .if n .ti 8 .IR bo \*(LE address < eo \*(IM .IR "file address" = address + fo\-bo, otherwise, .PP .if t .ti 1.5i .if n .ti 8 .IR b2 \*(LE address < e2 \*(IM .IR "file address" = address + f2\-b2, .PP otherwise, the requested .I address is not legal. In some cases (e.g. for programs with separated I and D space) the two segments for a file may overlap. If a .B ? or .B / is followed by an .B \*(ST then only the last triple is used. .PP The initial setting of both mappings is suitable for normal .B a.out and .B core files. If the object file is not of the kind expected then, for both files, .I b1 is set to 0, .I e1 is set to the maximum file size and .I f1 is set to 0; in this way the whole file can be examined with no address translation. .PP So that .I adb may be used on large files all appropriate values are kept as signed 32 bit integers. .SH FILES a.out .br core .SH SEE\ ALSO cc(1), ptrace(2), a.out(5), core(5) .br \fIADB - A Tutorial\fR, S. R. Bourne .SH DIAGNOSTICS `Adb' when there is no current command or format. Comments about inaccessible files, syntax errors, abnormal termination of commands, etc. Exit status is 0, unless last command failed or returned nonzero status. .SH BUGS When single stepping, system calls do not count as an executed instruction. .br Local variables whose names are the same as an external variable may foul up the accessing of the external. .br Local variables cannot be accessed in routines that are in overlays. .br Since no shell is invoked to interpret the arguments of the .B :r command, the customary wild-card and variable expansions cannot occur. ================================================ FILE: share/man/man1/addbib.1 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)addbib.1 6.1 (Berkeley) 4/29/85 .\" .TH ADDBIB 1 "April 29, 1985" .UC 5 .SH NAME addbib \- create or extend bibliographic database .SH SYNOPSIS \fBaddbib\fP [ \fB\-p\fP promptfile ] [ \fB\-a\fP ] database .SH DESCRIPTION When this program starts up, answering ``y'' to the initial ``Instructions?'' prompt yields directions; typing ``n'' or \s-2RETURN\s0 skips them. .I Addbib then prompts for various bibliographic fields, reads responses from the terminal, and sends output records to a .I database. A null response (just \s-2RETURN\s0) means to leave out that field. A minus sign (\-) means to go back to the previous field. A trailing backslash allows a field to be continued on the next line. The repeating ``Continue?'' prompt allows the user either to resume by typing ``y'' or \s-2RETURN\s0, to quit the current session by typing ``n'' or ``q'', or to edit the .I database with any system editor \fI(vi, ex, edit, ed).\fP .PP The .B \-a option suppresses prompting for an abstract; asking for an abstract is the default. Abstracts are ended with a \s-2CTRL\s0-d. The .B \-p option causes .I addbib to use a new prompting skeleton, defined in .I promptfile. This file should contain prompt strings, a tab, and the key-letters to be written to the .I database. .PP The most common key-letters and their meanings are given below. .I Addbib insulates you from these key-letters, since it gives you prompts in English, but if you edit the bibliography file later on, you will need to know this information. .sp .nf %A Author's name %B Book containing article referenced %C City (place of publication) %D Date of publication %E Editor of book containing article referenced %F Footnote number or label (supplied by \fIrefer\fP\|) %G Government order number %H Header commentary, printed before reference %I Issuer (publisher) %J Journal containing article %K Keywords to use in locating reference %L Label field used by \fB\-k\fP option of \fIrefer\fP %M Bell Labs Memorandum (undefined) %N Number within volume %O Other commentary, printed at end of reference %P Page number(s) %Q Corporate or Foreign Author (unreversed) %R Report, paper, or thesis (unpublished) %S Series title %T Title of article or book %V Volume number %X Abstract \(em used by \fIroffbib\fP, not by \fIrefer\fP %Y,Z ignored by \fIrefer\fP .fi .sp Except for `A', each field should be given just once. Only relevant fields should be supplied. An example is: .sp .nf %A Bill Tuthill %T Refer \(em A Bibliography System %I Computing Services %C Berkeley %D 1982 %O \s-1UNX\s0 4.3.5. .fi .sp .SH FILES .DT promptfile optional file to define prompting .SH SEE ALSO refer(1), sortbib(1), roffbib(1), indxbib(1), lookbib(1) .SH AUTHORS Al Stangenberger, Bill Tuthill ================================================ FILE: share/man/man1/apply.1 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)apply.1 6.1 (Berkeley) 4/29/85 .\" .TH APPLY 1 "April 29, 1985" .UC 5 .SH NAME apply \- apply a command to a set of arguments .SH SYNOPSIS .B apply [ .B \-a\fIc\fP ] [ .B \-\fIn\fP ] command args ... .SH DESCRIPTION .I Apply runs the named .I command on each argument .I arg in turn. Normally arguments are chosen singly; the optional number .I n specifies the number of arguments to be passed to .I command. If .I n is zero, .I command is run without arguments once for each .I arg. Character sequences of the form %\fId\fP in .I command, where .I d is a digit from 1 to 9, are replaced by the \fId\fP'th following unused .I arg. If any such sequences occur, .I n is ignored, and the number of arguments passed to .I command is the maximum value of .I d in .I command. The character `%' may be changed by the .B \-a option. .PP Examples: .RS apply echo * .RE is similar to ls(1); .RS apply \-2 cmp a1 b1 a2 b2 ... .RE compares the `a' files to the `b' files; .RS apply \-0 who 1 2 3 4 5 .RE runs who(1) 5 times; and .RS apply \(aaln %1 /usr/joe\(aa * .RE links all files in the current directory to the directory /usr/joe. .SH "SEE ALSO" sh(1) .SH AUTHOR Rob Pike .SH BUGS Shell metacharacters in .I command may have bizarre effects; it is best to enclose complicated commands in single quotes \(aa\ \(aa. .sp There is no way to pass a literal `%2' if `%' is the argument expansion character. ================================================ FILE: share/man/man1/apropos.1 ================================================ .\" @(#)apropos.1 6.4 (Berkeley) 6/5/86 .\" .TH APROPOS 1 "June 5, 1986" .AT 3 .SH NAME apropos \- locate commands by keyword lookup .SH SYNOPSIS .B apropos keyword ... .SH DESCRIPTION .I Apropos shows which manual sections contain instances of any of the given keywords in their title. Each word is considered separately and case of letters is ignored. Words which are part of other words are considered; thus, when looking for compile, \fIapropos\fP will find all instances of `compiler' also. Try .IP apropos password .PP and .IP apropos editor .PP If the line starts `name(section) ...' you can do `man section name' to get the documentation for it. Try `apropos format' and then `man 3s printf' to get the manual on the subroutine .I printf. .PP .I Apropos is actually just the .B \-k option to the .IR man (1) command. .SH FILES .DT /usr/man/whatis data base .SH "SEE ALSO" man(1), whatis(1), catman(8) .SH AUTHOR William Joy ================================================ FILE: share/man/man1/as.1 ================================================ .TH AS 1 "March 12, 1994" .UC .SH NAME as \- assembler .SH SYNOPSIS .B as [ .B \-u ] [ .B \-V ] [ .B \-o objfile ] file ... .SH DESCRIPTION .I As assembles the concatenation of the named files. The options are: .TP .B \-u Treat all undefined symbols in the assembly as external globals. .TP .B \-\^V Produce an object suitable for loading into an automatic text overlaid program. .TP .B \-\^o Use .I objfil for the name of the resultant object. If this is omitted, .I a.out is used. If no errors occurred during the assembly and if there were no unresolved external references, it is made executable. .P The special file name .B \-\- serves two purposes. It signals the end of all options and causes .I stdin to be read for input. Thus it is now possible to pipe data to the assembler: .br .sp /lib/cpp -E foo.s | sed -e ';^#;/;' | as -o foo.o -- .br .sp The file name .B \-\- may be placed between normal files, when EOF is detected on .I stdin the next file in the argument list is opened and read. .br .sp If no input files are specified then .I stdin is read. .SH FILES /tmp/atm1 temporary .br a.out object .SH "SEE ALSO" adb(1), ld(1), nm(1), a.out(5) .br .I "UNIX Assembler Manual" by D. M. Ritchie .SH DIAGNOSTICS When an input file cannot be read, its name followed by a question mark is typed and assembly ceases. When syntactic or semantic errors occur, a single-character diagnostic is typed out together with the line number and the file name in which it occurred. Errors in pass 1 cause cancellation of pass 2. The possible errors are: .PP .ta 3 ) Parentheses error .br ] Parentheses error .br < String not terminated properly .br * Indirection used illegally .br .li \fB.\fP Illegal assignment to `\fB.\fP' .br a Error in address .br b Branch instruction is odd or too remote .br e Error in expression .br f Error in local (`f' or `b') type symbol .br g Garbage (unknown) character .br i End of file inside an if .br m Multiply defined symbol as label .br o Word quantity assembled at odd address .br p `\fB.\fP' different in pass 1 and 2 .br r Relocation error .br u Undefined symbol .br x Syntax error .br .SH BUGS Syntax errors can cause incorrect line numbers in following diagnostics. ================================================ FILE: share/man/man1/at.1 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)at.1 6.2.1 (2.11BSD) 1996/10/21 .\" .TH AT 1 "October 21, 1996" .UC 4 .SH NAME at \- execute commands at a later time .SH SYNOPSIS .B "at [ -c ] [ -s ] [ -m ]" time [ day ] [ file ] .SH DESCRIPTION .I At spools away a copy of the named .I file to be used as input to .IR sh (1) or .IR csh (1). If the .B \-c flag (for .IR (csh (1))) or the .B \-s flag (for .IR (sh (1))) is specified, then that shell will be used to execute the job; if no shell is specified, the current environment shell is used. If no file name is specified, .I at prompts for commands from standard input until a ^D is typed. .PP If the .B \-m flag is specified, mail will be sent to the user after the job has been run. If errors occur during execution of the job, then a copy of the error diagnostics will be sent to the user. If no errors occur, then a short message is sent informing the user that no errors occurred. .PP The format of the spool file is as follows: A four line header that includes the owner of the job, the name of the job, the shell used to run the job, and whether mail will be set after the job is executed. The header is followed by a .I cd command to the current directory and a .I umask command to set the modes on any files created by the job. Then .I at copies all relevant environment variables to the spool file. When the script is run, it uses the user and group ID of the creator of the spool file. .PP The .I time is 1 to 4 digits, with an optional following `A', `P', `N' or `M' for AM, PM, noon or midnight. One and two digit numbers are taken to be hours, three and four digits to be hours and minutes. If no letters follow the digits, a 24 hour clock time is understood. .PP The optional .I day is either (1) a month name followed by a day number, or (2) a day of the week; if the word `week' follows, invocation is moved seven days further off. Names of months and days may be recognizably truncated. Examples of legitimate commands are .IP at 8am jan 24 .br at -c -m 1530 fr week .br at -s -m 1200n week .PP .I At programs are executed by periodic execution of the command .IR /usr/libexec/atrun from .IR cron (8). The granularity of .I at depends upon the how often atrun is executed. .PP Error output is lost unless redirected or the .I \-m flag is requested, in which case a copy of the errors is sent to the user via .IR mail (1). .SH FILES .nf /usr/spool/at spooling area /usr/spool/at/yy.ddd.hhhh.* job file /usr/spool/at/past directory where jobs are executed from /usr/spool/at/lasttimedone last time atrun was run /usr/libexec/atrun executor (run by cron(8)) .fi .SH "SEE ALSO" atq(1), atrm(1), calendar(1), sleep(1), cron(8) .SH DIAGNOSTICS Complains about various syntax errors and times out of range. .SH BUGS Due to the granularity of the execution of .IR /usr/libexec/atrun, there may be bugs in scheduling things almost exactly 24 hours into the future. If the system crashes, mail is not sent to the user informing them that the job was not completed. Sometimes old spool files are not removed from the directory /usr/spool/at/past. This is usually due to a system crash, and requires that they be removed by hand. ================================================ FILE: share/man/man1/atq.1 ================================================ .\" Copyright (c) 1985 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)atq.1 6.2 (Berkeley) 5/10/86 .\" .TH ATQ 1 "May 10, 1986" .UC 6 .SH NAME atq \- print the queue of jobs waiting to be run .SH SYNOPSIS .B atq [ -c ] [ -n ] [ name ... ] .SH DESCRIPTION .I Atq prints the queue of jobs that are waiting to be run at a later date. These jobs were created with the .IR at (1) command. With no flags, the queue is sorted in the order that the jobs will be executed. .PP If the .B \-c flag is used, the queue is sorted by the time that the .I at command was given. .PP The .B \-n flag prints only the total number of files that are currently in the queue. .PP If a name(s) is provided, only those files belonging to that user(s) are displayed. .SH FILES /usr/spool/at spool area .SH "SEE ALSO" at(1), atrm(1), cron(8) ================================================ FILE: share/man/man1/atrm.1 ================================================ .\" Copyright (c) 1985 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)atrm.1 6.2 (Berkeley) 5/10/86 .\" .TH ATRM 1 "May 10, 1986" .UC 6 .SH NAME atrm \- remove jobs spooled by at .SH SYNOPSIS .B atrm [ -f ] [ -i ] [-] [[ job #] [ name ]... ] .SH DESCRIPTION .I Atrm removes jobs that were created with the .IR at (1) command. With the .B \- flag, all jobs belonging to the person invoking .I atrm are removed. If a job number(s) is specified, .I atrm attempts to remove only that job number(s). .PP If the .B \-f flag is used, all information regarding the removal of the specified jobs is suppressed. If the .B \-i flag is used, .I atrm asks if a job should be removed; a response of 'y' causes the job to be removed. .PP If a user(s) name is specified, all jobs belonging to that user(s) are removed. This form of invoking .I atrm is useful only to the super-user. .SH FILES /usr/spool/at spool area .SH "SEE ALSO" at(1), atq(1), cron(8) ================================================ FILE: share/man/man1/awk.1 ================================================ .\" @(#)awk.1 6.1 (Berkeley) 4/29/85 .\" .TH AWK 1 "April 29, 1985" .AT 3 .SH NAME awk \- pattern scanning and processing language .SH SYNOPSIS .B awk [ .BI \-F c ] [ prog ] [ file ] ... .SH DESCRIPTION .I Awk scans each input .I file for lines that match any of a set of patterns specified in .IR prog . With each pattern in .I prog there can be an associated action that will be performed when a line of a .I file matches the pattern. The set of patterns may appear literally as .I prog, or in a file specified as .B \-f .IR file . .PP Files are read in order; if there are no files, the standard input is read. The file name `\-' means the standard input. Each line is matched against the pattern portion of every pattern-action statement; the associated action is performed for each matched pattern. .PP An input line is made up of fields separated by white space. (This default can be changed by using FS, .IR "vide infra" ".)" The fields are denoted $1, $2, ... ; $0 refers to the entire line. .PP .PP A pattern-action statement has the form .PP pattern { action } .PP A missing { action } means print the line; a missing pattern always matches. .PP An action is a sequence of statements. A statement can be one of the following: .PP .nf if ( conditional ) statement [ else statement ] while ( conditional ) statement for ( expression ; conditional ; expression ) statement break continue { [ statement ] ... } variable = expression print [ expression-list ] [ >expression ] printf format [ , expression-list ] [ >expression ] next # skip remaining patterns on this input line exit # skip the rest of the input .fi .PP Statements are terminated by semicolons, newlines or right braces. An empty expression-list stands for the whole line. Expressions take on string or numeric values as appropriate, and are built using the operators +, \-, *, /, %, and concatenation (indicated by a blank). The C operators ++, \-\-, +=, \-=, *=, /=, and %= are also available in expressions. Variables may be scalars, array elements (denoted x[i]) or fields. Variables are initialized to the null string. Array subscripts may be any string, not necessarily numeric; this allows for a form of associative memory. String constants are quoted "...". .PP The .I print statement prints its arguments on the standard output (or on a file if .I >file is present), separated by the current output field separator, and terminated by the output record separator. The .I printf statement formats its expression list according to the format (see .IR printf (3S)). .PP The built-in function .I length returns the length of its argument taken as a string, or of the whole line if no argument. There are also built-in functions .I exp, .I log, .I sqrt, and .IR int . The last truncates its argument to an integer. .IR substr(s,\ m,\ n) returns the .IR n -character substring of .I s that begins at position .IR m . The function .IR sprintf(fmt,\ expr,\ expr,\ ...) formats the expressions according to the .IR printf (3S) format given by .I fmt and returns the resulting string. .PP Patterns are arbitrary Boolean combinations (!, \(or\(or, &&, and parentheses) of regular expressions and relational expressions. Regular expressions must be surrounded by slashes and are as in .IR egrep . Isolated regular expressions in a pattern apply to the entire line. Regular expressions may also occur in relational expressions. .PP A pattern may consist of two patterns separated by a comma; in this case, the action is performed for all lines between an occurrence of the first pattern and the next occurrence of the second. .PP .nf A relational expression is one of the following: .PP .nf expression matchop regular-expression expression relop expression .PP .fi where a relop is any of the six relational operators in C, and a matchop is either ~ (for contains) or !~ (for does not contain). A conditional is an arithmetic expression, a relational expression, or a Boolean combination of these. .PP The special patterns BEGIN and END may be used to capture control before the first input line is read and after the last. BEGIN must be the first pattern, END the last. .PP A single character .I c may be used to separate the fields by starting the program with .PP BEGIN { FS = "c" } .PP or by using the .BI \-F c option. .PP Other variable names with special meanings include NF, the number of fields in the current record; NR, the ordinal number of the current record; FILENAME, the name of the current input file; OFS, the output field separator (default blank); ORS, the output record separator (default newline); and OFMT, the output format for numbers (default "%.6g"). .PP .SH EXAMPLES .PP Print lines longer than 72 characters: .PP .nf length > 72 .fi .PP Print first two fields in opposite order: .PP .nf { print $2, $1 } .fi .PP Add up first column, print sum and average: .PP .nf { s += $1 } END { print "sum is", s, " average is", s/NR } .fi .PP Print fields in reverse order: .PP .nf { for (i = NF; i > 0; \-\-i) print $i } .fi .PP Print all lines between start/stop pairs: .PP .nf /start/, /stop/ .fi .PP Print all lines whose first field is different from previous one: .PP .nf $1 != prev { print; prev = $1 } .fi .SH SEE ALSO .PP lex(1), sed(1) .br A. V. Aho, B. W. Kernighan, P. J. Weinberger, .I Awk \- a pattern scanning and processing language .SH BUGS There are no explicit conversions between numbers and strings. To force an expression to be treated as a number add 0 to it; to force it to be treated as a string concatenate "" to it. ================================================ FILE: share/man/man1/basename.1 ================================================ .\" @(#)basename.1 6.1 (Berkeley) 4/29/85 .\" .TH BASENAME 1 "April 29, 1985" .AT 3 .SH NAME basename \- strip filename affixes .SH SYNOPSIS .B basename string [ suffix ] .SH DESCRIPTION .I Basename deletes any prefix ending in `/' and the .I suffix, if present in .I string, from .I string, and prints the result on the standard output. It is normally used inside substitution marks \`\ \` in shell procedures. .PP This shell procedure invoked with the argument .I /usr/src/bin/cat.c compiles the named file and moves the output to .I cat in the current directory: .IP "" 15n cc $1 .br mv a.out \`basename $1 .c\` .SH "SEE ALSO" sh(1) ================================================ FILE: share/man/man1/biff.1 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)biff.1 6.1 (Berkeley) 4/29/85 .\" .TH BIFF 1 "April 29, 1985" .UC 4 .SH NAME biff \- be notified if mail arrives and who it is from .SH SYNOPSIS .B biff [ .B yn ] .SH DESCRIPTION .I Biff informs the system whether you want to be notified when mail arrives during the current terminal session. The command .IP .B "biff y" .LP enables notification; the command .IP .B "biff n" .LP disables it. When mail notification is enabled, the header and first few lines of the message will be printed on your screen whenever mail arrives. A ``biff y'' command is often included in the file .I \&.login or .I \&.profile to be executed at each login. .PP .I Biff operates asynchronously. For synchronous notification use the MAIL variable of .IR sh (1) or the .I mail variable of .IR csh (1). .SH SEE ALSO csh(1), sh(1), mail(1), comsat(8C) ================================================ FILE: share/man/man1/binmail.1 ================================================ .\" @(#)binmail.1 6.1 (Berkeley) 4/29/85 .\" .TH BINMAIL 1 "April 29, 1985" .AT 3 .SH NAME binmail \- send or receive mail among users .SH SYNOPSIS .B /bin/mail [ .B + ] [ .B \-i ] [ person ] ... .br .B /bin/mail .B "[ + ]" [ .B \-i ] .B \-f file .LP .SH DESCRIPTION Note: This is the old version 7 UNIX system mail program. The default .I mail command is described in .IR Mail (1), and its binary is in the directory .IR /usr/ucb . .PP .I mail with no argument prints a user's mail, message-by-message, in last-in, first-out order; the optional argument .B + displays the mail messages in first-in, first-out order. For each message, it reads a line from the standard input to direct disposition of the message. .TP newline Go on to next message. .TP d Delete message and go on to the next. .TP p Print message again. .TP \- Go back to previous message. .TP .RI "s [" " file " "] ..." Save the message in the named .I files (`mbox' default). .TP .RI "w [" " file " "] ..." Save the message, without a header, in the named .I files (`mbox' default). .TP .RI "m [" " person " "] ..." Mail the message to the named .I persons (yourself is default). .TP EOT (control-D) Put unexamined mail back in the mailbox and stop. .TP q Same as EOT. .TP .RI ! command Escape to the Shell to do .IR command . .TP * Print a command summary. .PP An interrupt normally terminates the .I mail command; the mail file is unchanged. The optional argument .B \(mii tells .I mail to continue after interrupts. .PP When .I persons are named, .I mail takes the standard input up to an end-of-file (or a line with just `.') and adds it to each .I person's `mail' file. The message is preceded by the sender's name and a postmark. Lines that look like postmarks are prepended with `>'. A .I person is usually a user name recognized by .IR login (1). To denote a recipient on a remote system, prefix .I person by the system name and exclamation mark (see .IR uucp (1C)). .PP The .B \-f option causes the named file, for example, `mbox', to be printed as if it were the mail file. .PP When a user logs in he is informed of the presence of mail. .SH FILES .ta \w'/usr/spool/mail/*.lock 'u /etc/passwd to identify sender and locate persons .br .li /usr/spool/mail/* incoming mail for user * .br mbox saved mail .br /tmp/ma* temp file .br /usr/spool/mail/*.lock lock for mail directory .br dead.letter unmailable text .br .SH "SEE ALSO" Mail(1), write(1), uucp(1C), uux(1C), xsend(1), sendmail(8) .SH BUGS Race conditions sometimes result in a failure to remove a lock file. .PP Normally anybody can read your mail, unless it is sent by .IR xsend (1). An installation can overcome this by making .I mail a set-user-id command that owns the mail directory. ================================================ FILE: share/man/man1/cal.1 ================================================ .\" @(#)cal.1 6.1 (Berkeley) 4/29/85 .\" .TH CAL 1 "April 29, 1985" .AT 3 .SH NAME cal \- print calendar .SH SYNOPSIS .B cal [ month ] year .SH DESCRIPTION .I Cal prints a calendar for the specified year. If a month is also specified, a calendar just for that month is printed. .I Year can be between 1 and 9999. The .I month is a number between 1 and 12. The calendar produced is that for England and her colonies. .PP Try September 1752. .SH BUGS The year is always considered to start in January even though this is historically naive. .br Beware that `cal 78' refers to the early Christian era, not the 20th century. ================================================ FILE: share/man/man1/calendar.1 ================================================ .\" @(#)calendar.1 6.1.1 (2.11BSD) 1996/10/21 .\" .TH CALENDAR 1 "October 21, 1996" .AT 3 .SH NAME calendar \- reminder service .SH SYNOPSIS .B calendar [ \- ] .SH DESCRIPTION .I Calendar consults the file `calendar' in the current directory and prints out lines that contain today's or tomorrow's date anywhere in the line. Most reasonable month-day dates such as `Dec. 7,' `december 7,' `12/7,' etc., are recognized, but not `7 December' or `7/12'. If you give the month as ``*'' with a date, i.e. ``* 1'', that day in any month will do. On weekends `tomorrow' extends through Monday. .PP When an argument is present, .I calendar does its job for every user who has a file `calendar' in his login directory and sends him any positive results by .IR mail (1). Normally this is done daily in the wee hours under control of .IR cron (8). .PP The file `calendar' is first run through the ``C'' preprocessor, .IR /lib/cpp , to include any other calendar files specified with the usual ``#include'' syntax. Included calendars will usually be shared by all users, maintained and documented by the local administration. .SH FILES calendar .br /usr/libexec/calendar to figure out today's and tomorrow's dates .br /etc/passwd .br /tmp/cal* .br /lib/cpp, egrep, sed, mail as subprocesses .SH "SEE ALSO" at(1), cron(8), mail(1) .SH BUGS .I Calendar's extended idea of `tomorrow' doesn't account for holidays. ================================================ FILE: share/man/man1/cat.1 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)cat.1 6.2 (Berkeley) 5/5/86 .\" .TH CAT 1 "May 5, 1986" .UC 4 .SH NAME cat \- catenate and print .SH SYNOPSIS .B cat [ .B \-u ] [ .B \-n ] [ .B \-s ] [ .B \-v ] file ... .br .SH DESCRIPTION .I Cat reads each .I file in sequence and displays it on the standard output. Thus .PP .ti +15n cat file .PP displays the file on the standard output, and .PP .ti +15n cat file1 file2 >file3 .PP concatenates the first two files and places the result on the third. .PP If no input file is given, or if the argument `\-' is encountered, .I cat reads from the standard input file. Output is buffered in the block size recommended by \fIstat\fP(2) unless the standard output is a terminal, when it is line buffered. The .B \-u option makes the output completely unbuffered. .PP The .B \-n option displays the output lines preceded by lines numbers, numbered sequentially from 1. Specifying the .B \-b option with the .B \-n option omits the line numbers from blank lines. .PP The .B \-s option crushes out multiple adjacent empty lines so that the output is displayed single spaced. .PP The .B \-v option displays non-printing characters so that they are visible. Control characters print like ^X for control-x; the delete character (octal 0177) prints as ^?. Non-ascii characters (with the high bit set) are printed as M- (for meta) followed by the character of the low 7 bits. A .B \-e option may be given with the .B \-v option, which displays a `$' character at the end of each line. Specifying the .B \-t option with the .B \-v option displays tab characters as ^I. .PP .SH "SEE ALSO" cp(1), ex(1), more(1), pr(1), tail(1) .SH BUGS Beware of `cat a b >a' and `cat a b >b', which destroy the input files before reading them. ================================================ FILE: share/man/man1/cb.1 ================================================ .\" @(#)cb.1 6.1 (Berkeley) 4/29/85 .\" .TH CB 1 "April 29, 1985" .AT 3 .SH NAME cb \- C program beautifier .SH SYNOPSIS .B cb .SH DESCRIPTION .I Cb places a copy of the C program from the standard input on the standard output with spacing and indentation that displays the structure of the program. ================================================ FILE: share/man/man1/cc.1 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)cc.1 6.2 (Berkeley) 6/7/85 .\" .TH CC 1 "June 7, 1985" .UC 2 .SH NAME cc \- C compiler (2BSD) .SH SYNOPSIS .B cc [ option ] ... file ... .SH DESCRIPTION .I Cc is the UNIX C compiler. .I Cc accepts several types of arguments: .PP Arguments whose names end with `.c' are taken to be C source programs; they are compiled, and each object program is left on the file whose name is that of the source with `.o' substituted for `.c'. The `.o' file is normally deleted, however, if a single C program is compiled and loaded all at one go. .PP In the same way, arguments whose names end with `.s' are taken to be assembly source programs and are assembled, producing a `.o' file. .PP The following options are interpreted by .IR cc . See .IR ld (1) for load-time options. .TP 8 .B \-c Suppress the loading phase of the compilation, and force an object file to be produced even if only one program is compiled. .TP .B \-w Suppress warning diagnostics. .TP .B \-p Arrange for the compiler to produce code which counts the number of times each routine is called. If loading takes place, replace the standard startup routine by one which automatically calls .IR monitor (3) at the start and arranges to write out a .I mon.out file at normal termination of execution of the object program. An execution profile can then be generated by use of .IR prof (1). .TP .SM .B \-O Invoke an object-code improver. .TP .SM .B \-S Compile the named C programs, and leave the assembler-language output on corresponding files suffixed `.s'. .TP .SM .B \-M Run only the macro preprocessor on the named C programs, requesting it to generate Makefile dependencies and send the result to the standard output. .TP .SM .B \-E Run only the macro preprocessor on the named C programs, and send the result to the standard output. .TP .SM .B \-C prevent the macro preprocessor from eliding comments. .TP .BI \-o " output" Name the final output file .IR output . If this option is used the file `a.out' will be left undisturbed. .TP .SM .BI \-D name=def .br .ns .TP .SM .BI \-D \*Sname Define the .I name to the preprocessor, as if by `#define'. If no definition is given, the name is defined as "1". .TP .SM .BI \-U \*Sname Remove any initial definition of .IR name . .TP .SM .BI \-I \*Sdir `#include' files whose names do not begin with `/' are always sought first in the directory of the .I file argument, then in directories named in .B \-I options, then in directories on a standard list. .TP .SM .BI \-L \*Sdir Library archives are sought first in directories named in .B \-L options, then in directories on a standard list. .TP .SM .BI \-B \*Sstring Find substitute compiler passes in the files named .I string with the suffixes cpp, c0, c1 and c2. If .I string is empty, use a standard backup version. .TP .BR \-t [ p012 ] Find only the designated compiler passes in the files whose names are constructed by a .B \-B option. In the absence of a .B \-B option, the .I string is taken to be `/usr/c/'. .PP Other arguments are taken to be either loader option arguments, or C-compatible object programs, typically produced by an earlier .I cc run, or perhaps libraries of C-compatible routines. These programs, together with the results of any compilations specified, are loaded (in the order given) to produce an executable program with name .B a.out. .SH FILES .ta \w'/usr/c/c[01] 'u file.c input file .br file.o object file .br a.out loaded output .br /tmp/ctm? temporary .br /lib/cpp preprocessor .br /lib/c[01] compiler .br /lib/c2 optional optimizer .br /lib/crt0.o runtime startoff .br /lib/mcrt0.o startoff for profiling .br /lib/libc.a standard library, see .IR intro (3) .br /usr/lib/libc_p.a profiling library, see .IR intro (3) .br /usr/include standard directory for `#include' files .br mon.out file produced for analysis by .IR prof (1) .SH "SEE ALSO" B. W. Kernighan and D. M. Ritchie, .I The C Programming Language, Prentice-Hall, 1978 .br B. W. Kernighan, .I Programming in C\(ema tutorial .br D. M. Ritchie, .I C Reference Manual .br monitor(3), prof(1), adb(1), ld(1), as(1) .SH DIAGNOSTICS The diagnostics produced by C itself are intended to be self-explanatory. Occasional messages may be produced by the assembler or loader. .SH BUGS The compiler currently ignores advice to put \fBchar\fR, \fBunsigned char\fR, \fBlong\fR, \fBfloat\fR, or \fBdouble\fR variables in registers. ================================================ FILE: share/man/man1/cd.1 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)cd.1 6.1 (Berkeley) 4/29/85 .\" .TH CD 1 "April 29, 1985" .UC 4 .SH NAME cd \- change working directory .SH SYNOPSIS .B cd directory .SH DESCRIPTION .I Directory becomes the new working directory. The process must have execute (search) permission in .IR directory . .PP Because a new process is created to execute each command, .I cd would be ineffective if it were written as a normal command. It is therefore recognized and executed by the shells. In .IR csh (1) you may specify a list of directories in which .I directory is to be sought as a subdirectory if it is not a subdirectory of the current directory; see the description of the .I cdpath variable in .IR csh (1). .SH "SEE ALSO" csh(1), sh(1), pwd(1), chdir(2) ================================================ FILE: share/man/man1/checknr.1 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)checknr.1 6.2 (Berkeley) 5/7/86 .\" .TH CHECKNR 1 "May 7, 1986" .UC 4 .SH NAME checknr \- check nroff/troff files .SH SYNOPSIS .B checknr [ .B \-s ] [ .B \-f ] [ .BR \-a ".x1.y1.x2.y2. ... .xn.yn" ] [ .BR \-c ".x1.x2.x3 ... .xn" ] [ \fIfile\fP ... ] .SH DESCRIPTION .I Checknr checks a list of .IR nroff (1) or .IR troff (1) input files for certain kinds of errors involving mismatched opening and closing delimiters and unknown commands. If no files are specified, .I checknr checks the standard input. Delimeters checked are: .IP (1) Font changes using \efx ... \efP. .IP (2) Size changes using \esx ... \es0. .IP (3) Macros that come in open ... close forms, for example, the .TS and .TE macros which must always come in pairs. .PP .I Checknr knows about the .IR ms (7) and .IR me (7) macro packages. .PP Additional pairs of macros can be added to the list using the .B \-a option. This must be followed by groups of six characters, each group defining a pair of macros. The six characters are a period, the first macro name, another period, and the second macro name. For example, to define a pair .BS and .ES, use \-\fBa\fP.BS.ES .PP The .B \-c option defines commands which would otherwise be complained about as undefined. .PP The .B \-f option requests .I checknr to ignore \ef font changes. .PP The .B \-s option requests .I checknr to ignore \es size changes. .PP .I Checknr is intended to be used on documents that are prepared with .I checknr in mind, much the same as .I lint. It expects a certain document writing style for \ef and \es commands, in that each \efx must be terminated with \efP and each \esx must be terminated with \es0. While it will work to directly go into the next font or explicitly specify the original font or point size, and many existing documents actually do this, such a practice will produce complaints from .I checknr. Since it is probably better to use the \efP and \es0 forms anyway, you should think of this as a contribution to your document preparation style. .SH SEE\ ALSO nroff(1), troff(1), checkeq(1), ms(7), me(7) .SH DIAGNOSTICS Complaints about unmatched delimiters. .br Complaints about unrecognized commands. .br Various complaints about the syntax of commands. .SH BUGS There is no way to define a 1 character macro name using .BR \-a . .br Does not correctly recognize certain reasonable constructs, such as conditionals. ================================================ FILE: share/man/man1/chgrp.1 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)chgrp.1 6.2 (Berkeley) 5/22/86 .\" .TH CHGRP 1 "May 22, 1986" .UC 5 .SH NAME chgrp \- change group .SH SYNOPSIS .B chgrp [ -f -R ] group file ... .SH DESCRIPTION .I Chgrp changes the group-ID of the .I files to .IR group . The group may be either a decimal GID or a group name found in the group-ID file. .PP The user invoking .I chgrp must belong to the specified group and be the owner of the file, or be the super-user. .PP No errors are reported when the .B \-f (force) option is given. .PP When the .B \-R option is given, .I chgrp recursively descends its directory arguments setting the specified group-ID. When symbolic links are encountered, their group is changed, but they are not traversed. .SH FILES /etc/group .SH "SEE ALSO" chown(2), passwd(5), group(5) ================================================ FILE: share/man/man1/chmod.1 ================================================ .\" @(#)chmod.1 6.3 (Berkeley) 5/22/86 .\" .TH CHMOD 1 "May 22, 1986" .AT 3 .SH NAME chmod \- change mode .SH SYNOPSIS \fBchmod\fP [ .B \-Rf ] mode file ... .SH DESCRIPTION The mode of each named file is changed according to \fImode\fP, which may be absolute or symbolic. An absolute \fImode\fP is an octal number constructed from the OR of the following modes: .TP 10 4000 set user ID on execution .br .ns .TP 10 2000 set group ID on execution .br .ns .TP 10 1000 sticky bit, see .IR chmod (2) .br .ns .TP 10 0400 read by owner .br .ns .TP 10 0200 write by owner .br .ns .TP 10 0100 execute (search in directory) by owner .br .ns .TP 10 0070 read, write, execute (search) by group .br .ns .TP 10 0007 read, write, execute (search) by others .LP A symbolic \fImode\fP has the form: .IP .RI [ who ] \fIop permission\fP .RI [ "op permission" "] ..." .LP The \fIwho\fP part is a combination of the letters \fBu\fP (for user's permissions), \fBg\fP (group) and \fBo\fP (other). The letter \fBa\fP stands for all, or \fBugo.\fP If \fIwho\fP is omitted, the default is \fIa\fP but the setting of the file creation mask (see umask(2)) is taken into account. .LP \fIOp\fP can be \fB+\fP to add \fIpermission\fP to the file's mode, \fB\-\fP to take away \fIpermission\fP and \fB=\fP to assign \fIpermission\fP absolutely (all other bits will be reset). .LP \fIPermission\fP is any combination of the letters \fBr\fP (read), \fBw\fP (write), \fBx\fP (execute), \fBX\fP (set execute only if file is a directory or some other execute bit is set), \fBs\fP (set owner or group id) and \fBt\fP (save text \- sticky). Letters \fBu\fP, \fBg\fP, or \fBo\fP indicate that \fIpermission\fP is to be taken from the current mode. Omitting \fIpermission\fP is only useful with \fB=\fP to take away all permissions. .PP When the .B \-R option is given, .I chmod recursively descends its directory arguments setting the mode for each file as described above. When symbolic links are encountered, their mode is not changed and they are not traversed. .PP If the .B \-f option is given, .I chmod will not complain if it fails to change the mode on a file. .SH EXAMPLES .LP The first example denies write permission to others, the second makes a file executable by all if it is executable by anyone: .IP chmod o\-w file .br chmod +X file .LP Multiple symbolic modes separated by commas may be given. Operations are performed in the order specified. The letter \fBs\fP is only useful with \fBu\fP or \fBg.\fP .LP Only the owner of a file (or the super-user) may change its mode. .SH "SEE ALSO" ls(1), chmod(2), stat(2), umask(2), chown(8) ================================================ FILE: share/man/man1/clear.1 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)clear.1 6.1 (Berkeley) 4/29/85 .\" .TH CLEAR 1 "April 29, 1985" .UC .SH NAME clear \- clear terminal screen .SH SYNOPSIS .B clear .SH DESCRIPTION .I Clear clears your screen if this is possible. It looks in the environment for the terminal type and then in .I /etc/termcap to figure out how to clear the screen. .SH FILES /etc/termcap terminal capability data base ================================================ FILE: share/man/man1/cmp.1 ================================================ .\" @(#)cmp.1 6.1 (Berkeley) 4/29/85 .\" .TH CMP 1 "April 29, 1985" .AT 3 .SH NAME cmp \- compare two files .SH SYNOPSIS .B cmp [ .B \-l ] [ .B \-s ] file1 file2 .SH DESCRIPTION The two files are compared. (If .I file1 is `\-', the standard input is used.) Under default options, .I cmp makes no comment if the files are the same; if they differ, it announces the byte and line number at which the difference occurred. If one file is an initial subsequence of the other, that fact is noted. .PP Options: .TP 6 .B \-l Print the byte number (decimal) and the differing bytes (octal) for each difference. .TP 6 .B \-s Print nothing for differing files; return codes only. .SH "SEE ALSO" .DT diff(1), comm(1) .SH DIAGNOSTICS Exit code 0 is returned for identical files, 1 for different files, and 2 for an inaccessible or missing argument. ================================================ FILE: share/man/man1/col.1 ================================================ .\" @(#)col.1 6.2 (Berkeley) 5/16/86 .\" .TH COL 1 "May 16, 1986" .AT 3 .SH NAME col \- filter reverse line feeds .SH SYNOPSIS .B col [ .B \-bfh ] .SH DESCRIPTION .I Col reads the standard input and writes the standard output. It performs the line overlays implied by reverse line feeds (ESC-7 in ASCII) and by forward and reverse half line feeds (ESC-9 and ESC-8). .I Col is particularly useful for filtering multicolumn output made with the `.rt' command of .I nroff and output resulting from use of the .IR tbl (1) preprocessor. .PP Although .I col accepts half line motions in its input, it normally does not emit them on output. Instead, text that would appear between lines is moved to the next lower full line boundary. This treatment can be suppressed by the .B \-f (fine) option; in this case the output from .I col may contain forward half line feeds (ESC-9), but will still never contain either kind of reverse line motion. .PP If the .B \-b option is given, .I col assumes that the output device in use is not capable of backspacing. In this case, if several characters are to appear in the same place, only the last one read will be taken. .PP The control characters SO (ASCII code 017), and SI (016) are assumed to start and end text in an alternate character set. The character set (primary or alternate) associated with each printing character read is remembered; on output, SO and SI characters are generated where necessary to maintain the correct treatment of each character. .PP If the .B \-h option is given, .I col converts white space to tabs to shorten printing time. .PP All control characters are removed from the input except space, backspace, tab, return, newline, ESC (033) followed by one of 7, 8, 9, SI, SO, and VT (013). This last character is an alternate form of full reverse line feed, for compatibility with some other hardware conventions. All other non-printing characters are ignored. .SH "SEE ALSO" troff(1), tbl(1) .SH BUGS Can't back up more than 128 lines. .br No more than 800 characters, including backspaces, on a line. ================================================ FILE: share/man/man1/colcrt.1 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)colcrt.1 6.2 (Berkeley) 5/7/86 .\" .TH COLCRT 1 "May 7, 1986" .UC .SH NAME colcrt \- filter nroff output for CRT previewing .SH SYNOPSIS .B colcrt [ .B \- ] [ .B \-2 ] [ file ... ] .SH DESCRIPTION .I Colcrt provides virtual half-line and reverse line feed sequences for terminals without such capability, and on which overstriking is destructive. Half-line characters and underlining (changed to dashing `\-') are placed on new lines in between the normal output lines. .PP The optional .B \- suppresses all underlining. It is especially useful for previewing .I allboxed tables from .IR tbl (1). .PP The option .B \-2 causes all half-lines to be printed, effectively double spacing the output. Normally, a minimal space output format is used which will suppress empty lines. The program never suppresses two consecutive empty lines, however. The .B \-2 option is useful for sending output to the line printer when the output contains superscripts and subscripts which would otherwise be invisible. .PP A typical use of .I colcrt would be .PP .DT tbl exum2.n | nroff \-ms | colcrt \- | more .SH "SEE ALSO" nroff/troff(1), col(1), more(1), ul(1) .SH BUGS Should fold underlines onto blanks even with the `\fB\-\fR' option so that a true underline character would show; if we did this, however, .I colcrt wouldn't get rid of .I cu'd underlining completely. .PP Can't back up more than 102 lines. .PP General overstriking is lost; as a special case `|' overstruck with `\-' or underline becomes `+'. .PP Lines are trimmed to 132 characters. .PP Some provision should be made for processing superscripts and subscripts in documents which are already double-spaced. ================================================ FILE: share/man/man1/colrm.1 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)colrm.1 6.2 (Berkeley) 5/7/86 .\" .TH COLRM 1 "May 7, 1986" .UC 4 .SH NAME colrm \- remove columns from a file .SH SYNOPSIS .B colrm [ startcol [ endcol ] ] .SH DESCRIPTION .I Colrm removes selected columns from a file. Input is taken from standard input. Output is sent to standard output. .PP If called with one parameter the columns of each line will be removed starting with the specified column. If called with two parameters the columns from the first column to the last column will be removed. .PP Column numbering starts with column 1. .SH "SEE ALSO" expand(1) ================================================ FILE: share/man/man1/comm.1 ================================================ .\" @(#)comm.1 6.1 (Berkeley) 4/29/85 .\" .TH COMM 1 "April 29, 1985" .AT 3 .SH NAME comm \- select or reject lines common to two sorted files .SH SYNOPSIS .B comm [ .B \- [ .B 123 ] ] file1 file2 .SH DESCRIPTION .I Comm reads .I file1 and .I file2, which should be ordered in ASCII collating sequence, and produces a three column output: lines only in .I file1; lines only in .I file2; and lines in both files. The filename `\-' means the standard input. .PP Flags 1, 2, or 3 suppress printing of the corresponding column. Thus .B comm .B \-12 prints only the lines common to the two files; .B comm .B \-23 prints only lines in the first file but not in the second; .B comm .B \-123 is a no-op. .PP .SH "SEE ALSO" cmp(1), diff(1), uniq(1) ================================================ FILE: share/man/man1/compress.1 ================================================ .\" @(#)compress.1 6.5 (Berkeley) 5/11/86 .\" .TH COMPRESS 1 "May 11, 1986" .UC 6 .SH NAME compress, uncompress, zcat \- compress and expand data .SH SYNOPSIS .PU .ll +8 .B compress [ .B \-f ] [ .B \-v ] [ .B \-c ] [ .B \-b .I bits ] [ .I "name \&..." ] .ll -8 .br .B uncompress [ .B \-f ] [ .B \-v ] [ .B \-c ] [ .I "name \&..." ] .br .B zcat [ .I "name \&..." ] .SH DESCRIPTION .I Compress reduces the size of the named files using adaptive Lempel-Ziv coding. Whenever possible, each file is replaced by one with the extension .B "\&.Z," while keeping the same ownership modes, access and modification times. If no files are specified, the standard input is compressed to the standard output. Compressed files can be restored to their original form using .I uncompress or .I zcat. .PP The .B \-f option will force compression of .IR name , even if it does not actually shrink or the corresponding .IR name .Z file already exists. Except when run in the background under .IR /bin/sh , if .B \-f is not given the user is prompted as to whether an existing .IR name .Z file should be overwritten. .PP The .B \-c (``cat'') option makes .I compress/uncompress write to the standard output; no files are changed. The nondestructive behavior of .I zcat is identical to that of .I uncompress .B \-c. .PP .I Compress uses the modified Lempel-Ziv algorithm popularized in "A Technique for High Performance Data Compression", Terry A. Welch, .I "IEEE Computer," vol. 17, no. 6 (June 1984), pp. 8-19. Common substrings in the file are first replaced by 9-bit codes 257 and up. When code 512 is reached, the algorithm switches to 10-bit codes and continues to use more bits until the limit specified by the .B \-b flag is reached (default 16). .I Bits must be between 9 and 16. The default can be changed in the source to allow .I compress to be run on a smaller machine. .PP After the .I bits limit is attained, .I compress periodically checks the compression ratio. If it is increasing, .I compress continues to use the existing code dictionary. However, if the compression ratio decreases, .I compress discards the table of substrings and rebuilds it from scratch. This allows the algorithm to adapt to the next "block" of the file. .PP Note that the .B \-b flag is omitted for .I uncompress, since the .I bits parameter specified during compression is encoded within the output, along with a magic number to ensure that neither decompression of random data nor recompression of compressed data is attempted. .PP .ne 8 The amount of compression obtained depends on the size of the input, the number of .I bits per code, and the distribution of common substrings. Typically, text such as source code or English is reduced by 50\-60%. Compression is generally much better than that achieved by Huffman coding (as used in .IR pack ), or adaptive Huffman coding .RI ( compact ), and takes less time to compute. .PP The .B \-v option causes the printing of the percentage reduction of each file. .PP If an error occurs, exit status is 1, else if the last file was not compressed because it became larger, the status is 2; else the status is 0. .SH "DIAGNOSTICS" Usage: compress [\-fvc] [\-b maxbits] [file ...] .in +8 Invalid options were specified on the command line. .in -8 Missing maxbits .in +8 Maxbits must follow .BR \-b \. .in -8 .IR file : not in compressed format .in +8 The file specified to .I uncompress has not been compressed. .in -8 .IR file : compressed with .I xx bits, can only handle .I yy bits .in +8 .I File was compressed by a program that could deal with more .I bits than the compress code on this machine. Recompress the file with smaller .IR bits \. .in -8 .IR file : already has .Z suffix -- no change .in +8 The file is assumed to be already compressed. Rename the file and try again. .in -8 .IR file : filename too long to tack on .Z .in +8 The file cannot be compressed because its name is longer than 12 characters. Rename and try again. This message does not occur on BSD systems. .in -8 .I file already exists; do you wish to overwrite (y or n)? .in +8 Respond "y" if you want the output file to be replaced; "n" if not. .in -8 uncompress: corrupt input .in +8 A SIGSEGV violation was detected which usually means that the input file is corrupted. .in -8 Compression: .I "xx.xx%" .in +8 Percentage of the input saved by compression. (Relevant only for .BR \-v \.) .in -8 -- not a regular file: unchanged .in +8 When the input file is not a regular file, (e.g. a directory), it is left unaltered. .in -8 -- has .I xx other links: unchanged .in +8 The input file has links; it is left unchanged. See .IR ln "(1)" for more information. .in -8 -- file unchanged .in +8 No savings is achieved by compression. The input remains virgin. .in -8 .SH "BUGS" Although compressed files are compatible between machines with large memory, .BR \-b \12 should be used for file transfer to architectures with a small process data space (64KB or less, as exhibited by the DEC PDP series, the Intel 80286, etc.) .PP .I compress should be more flexible about the existence of the `.Z' suffix. ================================================ FILE: share/man/man1/cp.1 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)cp.1 6.2 (Berkeley) 6/8/85 .\" .TH CP 1 "June 8, 1985" .UC 4 .SH NAME cp \- copy .SH SYNOPSIS .B cp [ .B \-ip ] file1 file2 .PP .B cp [ .B \-ipr ] file ... directory .SH DESCRIPTION .I File1 is copied onto .IR file2 . By default, the mode and owner of .I file2 are preserved if it already existed; otherwise the mode of the source file modified by the current .IR umask (2) is used. The .B \-p option causes .I cp to attempt to preserve (duplicate) in its copies the modification times and modes of the source files, ignoring the present .IR umask . .PP In the second form, one or more .I files are copied into the .I directory with their original file-names. .PP .I Cp refuses to copy a file onto itself. .PP If the .B \-i option is specified, .I cp will prompt the user with the name of the file whenever the copy will cause an old file to be overwritten. An answer of 'y' will cause .I cp to continue. Any other answer will prevent it from overwriting the file. .PP If the .B \-r option is specified and any of the source files are directories, .I cp copies each subtree rooted at that name; in this case the destination must be a directory. .SH "SEE ALSO" cat(1), mv(1), rcp(1C) ================================================ FILE: share/man/man1/csh.1 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)csh.1 6.8.1 (2.11BSD) 1996/11/27 .\" .TH CSH 1 "November 27, 1996" .UC 4 .de sh .br .ne 5 .PP \fB\\$1\fR .PP .. .if n .ds ua ^ .if t .ds ua \(ua .if n .ds aa ' .if t .ds aa \(aa .if n .ds ga ` .if t .ds ga \(ga .if t .tr *\(** .SH NAME csh \- a shell (command interpreter) with C-like syntax .SH SYNOPSIS .B csh [ .B \-cef\^instvVxX ] [ arg ... ] .SH DESCRIPTION .I Csh is a first implementation of a command language interpreter incorporating a history mechanism (see \fBHistory Substitutions\fP), job control facilities (see \fBJobs\fP), interactive file name and user name completion (see \fBFile Name Completion\fP), and a C-like syntax. So as to be able to use its job control facilities, users of .I csh must (and automatically) use the new tty driver fully described in .IR tty (4). This new tty driver allows generation of interrupt characters from the keyboard to tell jobs to stop. See .IR stty (1) for details on setting options in the new tty driver. .PP An instance of .I csh begins by executing commands from the file `.cshrc' in the .I home directory of the invoker. If this is a login shell then it also executes commands from the file `.login' there. It is typical for users on crt's to put the command ``stty crt'' in their .I \&.login file, and to also invoke .IR tset (1) there. .PP In the normal case, the shell will then begin reading commands from the terminal, prompting with `% '. Processing of arguments and the use of the shell to process files containing command scripts will be described later. .PP The shell then repeatedly performs the following actions: a line of command input is read and broken into .IR words . This sequence of words is placed on the command history list and then parsed. Finally each command in the current line is executed. .PP When a login shell terminates it executes commands from the file `.logout' in the users home directory. .sh "Lexical structure" The shell splits input lines into words at blanks and tabs with the following exceptions. The characters `&' `|' `;' `<' `>' `(' `)' form separate words. If doubled in `&&', `|\|\||', `<<' or `>>' these pairs form single words. These parser metacharacters may be made part of other words, or prevented their special meaning, by preceding them with `\e'. A newline preceded by a `\e' is equivalent to a blank. .PP In addition strings enclosed in matched pairs of quotations, `\*(aa', `\*(ga' or `"', form parts of a word; metacharacters in these strings, including blanks and tabs, do not form separate words. These quotations have semantics to be described subsequently. Within pairs of `\'' or `"' characters a newline preceded by a `\e' gives a true newline character. .PP When the shell's input is not a terminal, the character `#' introduces a comment which continues to the end of the input line. It is prevented this special meaning when preceded by `\e' and in quotations using `\`', `\'', and `"'. .sh "Commands" A simple command is a sequence of words, the first of which specifies the command to be executed. A simple command or a sequence of simple commands separated by `|' characters forms a pipeline. The output of each command in a pipeline is connected to the input of the next. Sequences of pipelines may be separated by `;', and are then executed sequentially. A sequence of pipelines may be executed without immediately waiting for it to terminate by following it with an `&'. .PP Any of the above may be placed in `(' `)' to form a simple command (which may be a component of a pipeline, etc.) It is also possible to separate pipelines with `|\|\||' or `&&' indicating, as in the C language, that the second is to be executed only if the first fails or succeeds respectively. (See .I Expressions.) .sh "Jobs" The shell associates a \fIjob\fR with each pipeline. It keeps a table of current jobs, printed by the \fIjobs\fR command, and assigns them small integer numbers. When a job is started asynchronously with `&', the shell prints a line which looks like: .PP .DT [1] 1234 .PP indicating that the job which was started asynchronously was job number 1 and had one (top-level) process, whose process id was 1234. .PP If you are running a job and wish to do something else you may hit the key \fB^Z\fR (control-Z) which sends a STOP signal to the current job. The shell will then normally indicate that the job has been `Stopped', and print another prompt. You can then manipulate the state of this job, putting it in the background with the \fIbg\fR command, or run some other commands and then eventually bring the job back into the foreground with the foreground command \fIfg\fR. A \fB^Z\fR takes effect immediately and is like an interrupt in that pending output and unread input are discarded when it is typed. There is another special key \fB^Y\fR which does not generate a STOP signal until a program attempts to .IR read (2) it. This can usefully be typed ahead when you have prepared some commands for a job which you wish to stop after it has read them. .PP A job being run in the background will stop if it tries to read from the terminal. Background jobs are normally allowed to produce output, but this can be disabled by giving the command ``stty tostop''. If you set this tty option, then background jobs will stop when they try to produce output like they do when they try to read input. .PP There are several ways to refer to jobs in the shell. The character `%' introduces a job name. If you wish to refer to job number 1, you can name it as `%1'. Just naming a job brings it to the foreground; thus `%1' is a synonym for `fg %1', bringing job 1 back into the foreground. Similarly saying `%1 &' resumes job 1 in the background. Jobs can also be named by prefixes of the string typed in to start them, if these prefixes are unambiguous, thus `%ex' would normally restart a suspended .IR ex (1) job, if there were only one suspended job whose name began with the string `ex'. It is also possible to say `%?string' which specifies a job whose text contains .I string, if there is only one such job. .PP The shell maintains a notion of the current and previous jobs. In output pertaining to jobs, the current job is marked with a `+' and the previous job with a `\-'. The abbreviation `%+' refers to the current job and `%\-' refers to the previous job. For close analogy with the syntax of the .I history mechanism (described below), `%%' is also a synonym for the current job. .sh "Status reporting" This shell learns immediately whenever a process changes state. It normally informs you whenever a job becomes blocked so that no further progress is possible, but only just before it prints a prompt. This is done so that it does not otherwise disturb your work. If, however, you set the shell variable .I notify, the shell will notify you immediately of changes of status in background jobs. There is also a shell command .I notify which marks a single process so that its status changes will be immediately reported. By default .I notify marks the current process; simply say `notify' after starting a background job to mark it. .PP When you try to leave the shell while jobs are stopped, you will be warned that `You have stopped jobs.' You may use the \fIjobs\fR command to see what they are. If you do this or immediately try to exit again, the shell will not warn you a second time, and the suspended jobs will be terminated. .sh "File Name Completion" When the file name completion feature is enabled by setting the shell variable \fIfilec\fP (see \fBset\fP), \fIcsh\fP will interactively complete file names and user names from unique prefixes, when they are input from the terminal followed by the escape character (the escape key, or control-[). For example, if the current directory looks like .ta 1i 2i 3i 4i 5i 6i .nf DSC.OLD bin cmd lib xmpl.c DSC.NEW chaosnet cmtest mail xmpl.o bench class dev mbox xmpl.out .fi and the input is .br % vi ch .br \fIcsh\fP will complete the prefix ``ch'' to the only matching file name ``chaosnet'', changing the input line to .br % vi chaosnet .br However, given .br % vi D .br \fIcsh\fP will only expand the input to .br % vi DSC. .br and will sound the terminal bell to indicate that the expansion is incomplete, since there are two file names matching the prefix ``D''. .PP If a partial file name is followed by the end-of-file character (usually control-D), then, instead of completing the name, \fIcsh\fP will list all file names matching the prefix. For example, the input .br % vi D .br causes all files beginning with ``D'' to be listed: .br DSC.NEW DSC.OLD .br while the input line remains unchanged. .PP The same system of escape and end-of-file can also be used to expand partial user names, if the word to be completed (or listed) begins with the character ``~''. For example, typing .br cd ~ro .br may produce the expansion .br cd ~root .PP The use of the terminal bell to signal errors or multiple matches can be inhibited by setting the variable \fInobeep\fP. .PP Normally, all files in the particular directory are candidates for name completion. Files with certain suffixes can be excluded from consideration by setting the variable \fIfignore\fP to the list of suffixes to be ignored. Thus, if \fIfignore\fP is set by the command .br % set fignore = (.o .out) .br then typing .br % vi x .br would result in the completion to .br % vi xmpl.c .br ignoring the files "xmpl.o" and "xmpl.out". However, if the only completion possible requires not ignoring these suffixes, then they are not ignored. In addition, \fIfignore\fP does not affect the listing of file names by control-D. All files are listed regardless of their suffixes. .sh Substitutions We now describe the various transformations the shell performs on the input in the order in which they occur. .sh "History substitutions" History substitutions place words from previous command input as portions of new commands, making it easy to repeat commands, repeat arguments of a previous command in the current command, or fix spelling mistakes in the previous command with little typing and a high degree of confidence. History substitutions begin with the character `!' and may begin .B anywhere in the input stream (with the proviso that they .B "do not" nest.) This `!' may be preceded by an `\e' to prevent its special meaning; for convenience, a `!' is passed unchanged when it is followed by a blank, tab, newline, `=' or `('. (History substitutions also occur when an input line begins with `\*(ua'. This special abbreviation will be described later.) Any input line which contains history substitution is echoed on the terminal before it is executed as it could have been typed without history substitution. .PP Commands input from the terminal which consist of one or more words are saved on the history list. The history substitutions reintroduce sequences of words from these saved commands into the input stream. The size of which is controlled by the .I history variable; the previous command is always retained, regardless of its value. Commands are numbered sequentially from 1. .PP For definiteness, consider the following output from the .I history command: .PP .DT .br \09 write michael .br 10 ex write.c .br 11 cat oldwrite.c .br 12 diff *write.c .PP The commands are shown with their event numbers. It is not usually necessary to use event numbers, but the current event number can be made part of the .I prompt by placing an `!' in the prompt string. .PP With the current event 13 we can refer to previous events by event number `!11', relatively as in `!\-2' (referring to the same event), by a prefix of a command word as in `!d' for event 12 or `!wri' for event 9, or by a string contained in a word in the command as in `!?mic?' also referring to event 9. These forms, without further modification, simply reintroduce the words of the specified events, each separated by a single blank. As a special case `!!' refers to the previous command; thus `!!' alone is essentially a .I redo. .PP To select words from an event we can follow the event specification by a `:' and a designator for the desired words. The words of an input line are numbered from 0, the first (usually command) word being 0, the second word (first argument) being 1, etc. The basic word designators are: .PP .DT .nf 0 first (command) word \fIn\fR \fIn\fR\|'th argument \*(ua first argument, i.e. `1' $ last argument % word matched by (immediately preceding) ?\fIs\fR\|? search \fIx\fR\|\-\fIy\fR range of words \-\fIy\fR abbreviates `0\-\fIy\fR\|' * abbreviates `\*(ua\-$', or nothing if only 1 word in event \fIx\fR\|* abbreviates `\fIx\fR\|\-$' \fIx\fR\|\- like `\fIx\fR\|*' but omitting word `$' .fi .PP The `:' separating the event specification from the word designator can be omitted if the argument selector begins with a `\*(ua', `$', `*' `\-' or `%'. After the optional word designator can be placed a sequence of modifiers, each preceded by a `:'. The following modifiers are defined: .ta .5i 1.2i .PP .nf h Remove a trailing pathname component, leaving the head. r Remove a trailing `.xxx' component, leaving the root name. e Remove all but the extension `.xxx' part. s/\fIl\fR\|/\fIr\fR\|/ Substitute \fIl\fR for \fIr\fR t Remove all leading pathname components, leaving the tail. & Repeat the previous substitution. g Apply the change globally, prefixing the above, e.g. `g&'. p Print the new command but do not execute it. q Quote the substituted words, preventing further substitutions. x Like q, but break into words at blanks, tabs and newlines. .fi .PP Unless preceded by a `g' the modification is applied only to the first modifiable word. With substitutions, it is an error for no word to be applicable. .PP The left hand side of substitutions are not regular expressions in the sense of the editors, but rather strings. Any character may be used as the delimiter in place of `/'; a `\e' quotes the delimiter into the .IR l "" and .IR r "" strings. The character `&' in the right hand side is replaced by the text from the left. A `\e' quotes `&' also. A null .IR l "" uses the previous string either from a .IR l "" or from a contextual scan string .IR s "" in `!?\fIs\fR\|?'. The trailing delimiter in the substitution may be omitted if a newline follows immediately as may the trailing `?' in a contextual scan. .PP A history reference may be given without an event specification, e.g. `!$'. In this case the reference is to the previous command unless a previous history reference occurred on the same line in which case this form repeats the previous reference. Thus `!?foo?\*(ua !$' gives the first and last arguments from the command matching `?foo?'. .PP A special abbreviation of a history reference occurs when the first non-blank character of an input line is a `\*(ua'. This is equivalent to `!:s\*(ua' providing a convenient shorthand for substitutions on the text of the previous line. Thus `\*(ualb\*(ualib' fixes the spelling of `lib' in the previous command. Finally, a history substitution may be surrounded with `{' and `}' if necessary to insulate it from the characters which follow. Thus, after `ls \-ld ~paul' we might do `!{l}a' to do `ls \-ld ~paula', while `!la' would look for a command starting `la'. .PP .if n .ul \fBQuotations\ with\ \'\ and\ "\fR .PP The quotation of strings by `\'' and `"' can be used to prevent all or some of the remaining substitutions. Strings enclosed in `\'' are prevented any further interpretation. Strings enclosed in `"' may be expanded as described below. .PP In both cases the resulting text becomes (all or part of) a single word; only in one special case (see .I "Command Substitition" below) does a `"' quoted string yield parts of more than one word; `\'' quoted strings never do. .sh "Alias substitution" The shell maintains a list of aliases which can be established, displayed and modified by the .I alias and .I unalias commands. After a command line is scanned, it is parsed into distinct commands and the first word of each command, left-to-right, is checked to see if it has an alias. If it does, then the text which is the alias for that command is reread with the history mechanism available as though that command were the previous input line. The resulting words replace the command and argument list. If no reference is made to the history list, then the argument list is left unchanged. .PP Thus if the alias for `ls' is `ls \-l' the command `ls /usr' would map to `ls \-l /usr', the argument list here being undisturbed. Similarly if the alias for `lookup' was `grep !\*(ua /etc/passwd' then `lookup bill' would map to `grep bill /etc/passwd'. .PP If an alias is found, the word transformation of the input text is performed and the aliasing process begins again on the reformed input line. Looping is prevented if the first word of the new text is the same as the old by flagging it to prevent further aliasing. Other loops are detected and cause an error. .PP Note that the mechanism allows aliases to introduce parser metasyntax. Thus we can `alias print \'pr \e!* \||\| lpr\'' to make a command which .I pr's its arguments to the line printer. .sh "Variable substitution" The shell maintains a set of variables, each of which has as value a list of zero or more words. Some of these variables are set by the shell or referred to by it. For instance, the .I argv variable is an image of the shell's argument list, and words of this variable's value are referred to in special ways. .PP The values of variables may be displayed and changed by using the .I set and .I unset commands. Of the variables referred to by the shell a number are toggles; the shell does not care what their value is, only whether they are set or not. For instance, the .I verbose variable is a toggle which causes command input to be echoed. The setting of this variable results from the .B \-v command line option. .PP Other operations treat variables numerically. The `@' command permits numeric calculations to be performed and the result assigned to a variable. Variable values are, however, always represented as (zero or more) strings. For the purposes of numeric operations, the null string is considered to be zero, and the second and subsequent words of multiword values are ignored. .PP After the input line is aliased and parsed, and before each command is executed, variable substitution is performed keyed by `$' characters. This expansion can be prevented by preceding the `$' with a `\e' except within `"'s where it .B always occurs, and within `\''s where it .B never occurs. Strings quoted by `\*(ga' are interpreted later (see .I "Command substitution" below) so `$' substitution does not occur there until later, if at all. A `$' is passed unchanged if followed by a blank, tab, or end-of-line. .PP Input/output redirections are recognized before variable expansion, and are variable expanded separately. Otherwise, the command name and entire argument list are expanded together. It is thus possible for the first (command) word to this point to generate more than one word, the first of which becomes the command name, and the rest of which become arguments. .PP Unless enclosed in `"' or given the `:q' modifier the results of variable substitution may eventually be command and filename substituted. Within `"', a variable whose value consists of multiple words expands to a (portion of) a single word, with the words of the variables value separated by blanks. When the `:q' modifier is applied to a substitution the variable will expand to multiple words with each word separated by a blank and quoted to prevent later command or filename substitution. .PP The following metasequences are provided for introducing variable values into the shell input. Except as noted, it is an error to reference a variable which is not set. .HP 5 $name .br .ns .HP 5 ${name} .br Are replaced by the words of the value of variable .I name, each separated by a blank. Braces insulate .I name from following characters which would otherwise be part of it. Shell variables have names consisting of up to 20 letters and digits starting with a letter. The underscore character is considered a letter. .br If .I name is not a shell variable, but is set in the environment, then that value is returned (but \fB:\fR modifiers and the other forms given below are not available in this case). .HP 5 $name[selector] .br .ns .HP 5 ${name[selector]} .br May be used to select only some of the words from the value of .I name. The selector is subjected to `$' substitution and may consist of a single number or two numbers separated by a `\-'. The first word of a variables value is numbered `1'. If the first number of a range is omitted it defaults to `1'. If the last member of a range is omitted it defaults to `$#name'. The selector `*' selects all words. It is not an error for a range to be empty if the second argument is omitted or in range. .HP 5 $#name .br .ns .HP 5 ${#name} .br Gives the number of words in the variable. This is useful for later use in a `[selector]'. .HP 5 $0 .br Substitutes the name of the file from which command input is being read. An error occurs if the name is not known. .HP 5 $number .br .ns .HP 5 ${number} .br Equivalent to `$argv[number]'. .HP 5 $* .br Equivalent to `$argv[*]'. .PP The modifiers `:h', `:t', `:r', `:q' and `:x' may be applied to the substitutions above as may `:gh', `:gt' and `:gr'. If braces `{' '}' appear in the command form then the modifiers must appear within the braces. .B "The current implementation allows only one `:' modifier on each `$' expansion." .PP The following substitutions may not be modified with `:' modifiers. .HP 5 $?name .br .ns .HP 5 ${?name} .br Substitutes the string `1' if name is set, `0' if it is not. .HP 5 $?0 .br Substitutes `1' if the current input filename is known, `0' if it is not. .HP 5 $$ .br Substitute the (decimal) process number of the (parent) shell. .HP 5 $< .br Substitutes a line from the standard input, with no further interpretation thereafter. It can be used to read from the keyboard in a shell script. .sh "Command and filename substitution" The remaining substitutions, command and filename substitution, are applied selectively to the arguments of builtin commands. This means that portions of expressions which are not evaluated are not subjected to these expansions. For commands which are not internal to the shell, the command name is substituted separately from the argument list. This occurs very late, after input-output redirection is performed, and in a child of the main shell. .sh "Command substitution" Command substitution is indicated by a command enclosed in `\*(ga'. The output from such a command is normally broken into separate words at blanks, tabs and newlines, with null words being discarded, this text then replacing the original string. Within `"'s, only newlines force new words; blanks and tabs are preserved. .PP In any case, the single final newline does not force a new word. Note that it is thus possible for a command substitution to yield only part of a word, even if the command outputs a complete line. .sh "Filename substitution" If a word contains any of the characters `*', `?', `[' or `{' or begins with the character `~', then that word is a candidate for filename substitution, also known as `globbing'. This word is then regarded as a pattern, and replaced with an alphabetically sorted list of file names which match the pattern. In a list of words specifying filename substitution it is an error for no pattern to match an existing file name, but it is not required for each pattern to match. Only the metacharacters `*', `?' and `[' imply pattern matching, the characters `~' and `{' being more akin to abbreviations. .PP In matching filenames, the character `.' at the beginning of a filename or immediately following a `/', as well as the character `/' must be matched explicitly. The character `*' matches any string of characters, including the null string. The character `?' matches any single character. The sequence `[...]' matches any one of the characters enclosed. Within `[...]', a pair of characters separated by `\-' matches any character lexically between the two. .PP The character `~' at the beginning of a filename is used to refer to home directories. Standing alone, i.e. `~' it expands to the invokers home directory as reflected in the value of the variable .I home. When followed by a name consisting of letters, digits and `\-' characters the shell searches for a user with that name and substitutes their home directory; thus `~ken' might expand to `/usr/ken' and `~ken/chmach' to `/usr/ken/chmach'. If the character `~' is followed by a character other than a letter or `/' or appears not at the beginning of a word, it is left undisturbed. .PP The metanotation `a{b,c,d}e' is a shorthand for `abe ace ade'. Left to right order is preserved, with results of matches being sorted separately at a low level to preserve this order. This construct may be nested. Thus `~source/s1/{oldls,ls}.c' expands to `/usr/source/s1/oldls.c /usr/source/s1/ls.c' whether or not these files exist without any chance of error if the home directory for `source' is `/usr/source'. Similarly `../{memo,*box}' might expand to `../memo ../box ../mbox'. (Note that `memo' was not sorted with the results of matching `*box'.) As a special case `{', `}' and `{}' are passed undisturbed. .sh Input/output The standard input and standard output of a command may be redirected with the following syntax: .HP 5 < name .br Open file .I name (which is first variable, command and filename expanded) as the standard input. .HP 5 << word .br Read the shell input up to a line which is identical to .I word. .I Word is not subjected to variable, filename or command substitution, and each input line is compared to .I word before any substitutions are done on this input line. Unless a quoting `\e', `"', `\*(aa' or `\*(ga' appears in .I word variable and command substitution is performed on the intervening lines, allowing `\e' to quote `$', `\e' and `\*(ga'. Commands which are substituted have all blanks, tabs, and newlines preserved, except for the final newline which is dropped. The resultant text is placed in an anonymous temporary file which is given to the command as standard input. .HP 5 > name .br .ns .HP 5 >! name .br .ns .HP 5 >& name .br .ns .HP 5 >&! name .br The file .I name is used as standard output. If the file does not exist then it is created; if the file exists, its is truncated, its previous contents being lost. .IP If the variable .I noclobber is set, then the file must not exist or be a character special file (e.g. a terminal or `/dev/null') or an error results. This helps prevent accidental destruction of files. In this case the `!' forms can be used and suppress this check. .IP The forms involving `&' route the diagnostic output into the specified file as well as the standard output. .I Name is expanded in the same way as `<' input filenames are. .HP 5 >> name .br .ns .HP 5 >>& name .br .ns .HP 5 >>! name .br .ns .HP 5 >>&! name .br Uses file .I name as standard output like `>' but places output at the end of the file. If the variable .I noclobber is set, then it is an error for the file not to exist unless one of the `!' forms is given. Otherwise similar to `>'. .PP A command receives the environment in which the shell was invoked as modified by the input-output parameters and the presence of the command in a pipeline. Thus, unlike some previous shells, commands run from a file of shell commands have no access to the text of the commands by default; rather they receive the original standard input of the shell. The `<<' mechanism should be used to present inline data. This permits shell command scripts to function as components of pipelines and allows the shell to block read its input. Note that the default standard input for a command run detached is .B not modified to be the empty file `/dev/null'; rather the standard input remains as the original standard input of the shell. If this is a terminal and if the process attempts to read from the terminal, then the process will block and the user will be notified (see .B Jobs above). .PP Diagnostic output may be directed through a pipe with the standard output. Simply use the form `|\|&' rather than just `|'. .sh Expressions A number of the builtin commands (to be described subsequently) take expressions, in which the operators are similar to those of C, with the same precedence. These expressions appear in the .I @, .I exit, .I if, and .I while commands. The following operators are available: .DT .PP |\|\|| && | \*(ua & == != =~ !~ <= >= < > << >> + \- * / % ! ~ ( ) .PP Here the precedence increases to the right, `==' `!=' `=~' and `!~', `<=' `>=' `<' and `>', `<<' and `>>', `+' and `\-', `*' `/' and `%' being, in groups, at the same level. The `==' `!=' `=~' and `!~' operators compare their arguments as strings; all others operate on numbers. The operators `=~' and `!~' are like `!=' and `==' except that the right hand side is a .I pattern (containing, e.g. `*'s, `?'s and instances of `[...]') against which the left hand operand is matched. This reduces the need for use of the .I switch statement in shell scripts when all that is really needed is pattern matching. .PP Strings which begin with `0' are considered octal numbers. Null or missing arguments are considered `0'. The result of all expressions are strings, which represent decimal numbers. It is important to note that no two components of an expression can appear in the same word; except when adjacent to components of expressions which are syntactically significant to the parser (`&' `|' `<' `>' `(' `)') they should be surrounded by spaces. .PP Also available in expressions as primitive operands are command executions enclosed in `{' and `}' and file enquiries of the form `\-\fIl\fR name' where .I l is one of: .PP .DT .nf r read access w write access x execute access e existence o ownership z zero size f plain file d directory .fi .PP The specified name is command and filename expanded and then tested to see if it has the specified relationship to the real user. If the file does not exist or is inaccessible then all enquiries return false, i.e. `0'. Command executions succeed, returning true, i.e. `1', if the command exits with status 0, otherwise they fail, returning false, i.e. `0'. If more detailed status information is required then the command should be executed outside of an expression and the variable .I status examined. .sh "Control flow" The shell contains a number of commands which can be used to regulate the flow of control in command files (shell scripts) and (in limited but useful ways) from terminal input. These commands all operate by forcing the shell to reread or skip in its input and, due to the implementation, restrict the placement of some of the commands. .PP The .I foreach, .I switch, and .I while statements, as well as the .I if\-then\-else form of the .I if statement require that the major keywords appear in a single simple command on an input line as shown below. .PP If the shell's input is not seekable, the shell buffers up input whenever a loop is being read and performs seeks in this internal buffer to accomplish the rereading implied by the loop. (To the extent that this allows, backward goto's will succeed on non-seekable inputs.) .sh "Builtin commands" Builtin commands are executed within the shell. If a builtin command occurs as any component of a pipeline except the last then it is executed in a subshell. .HP 5 .B alias .br .ns .HP 5 .BR alias " name" .br .ns .HP 5 .BR alias " name wordlist" .br The first form prints all aliases. The second form prints the alias for name. The final form assigns the specified .I wordlist as the alias of .I name; .I wordlist is command and filename substituted. .I Name is not allowed to be .I alias or .I unalias. .HP 5 .B alloc .br Shows the amount of dynamic memory acquired, broken down into used and free memory. With an argument shows the number of free and used blocks in each size category. The categories start at size 8 and double at each step. This command's output may vary across system types, since systems other than the VAX may use a different memory allocator. .HP 5 .B bg .br .ns .HP 5 \fBbg\ %\fRjob\ ... .br Puts the current or specified jobs into the background, continuing them if they were stopped. .HP 5 .B break .br Causes execution to resume after the .I end of the nearest enclosing .I foreach or .I while. The remaining commands on the current line are executed. Multi-level breaks are thus possible by writing them all on one line. .HP 5 .B breaksw .br Causes a break from a .I switch, resuming after the .I endsw. .HP 5 .BR case " label:" .br A label in a .I switch statement as discussed below. .HP 5 .B cd .br .ns .HP 5 .BR cd " name" .br .ns .HP 5 .B chdir .br .ns .HP 5 .BR chdir " name" .br Change the shell's working directory to directory .I name. If no argument is given then change to the home directory of the user. .br If .I name is not found as a subdirectory of the current directory (and does not begin with `/', `./' or `../'), then each component of the variable .I cdpath is checked to see if it has a subdirectory .I name. Finally, if all else fails but .I name is a shell variable whose value begins with `/', then this is tried to see if it is a directory. .HP 5 .B continue .br Continue execution of the nearest enclosing .I while or .I foreach. The rest of the commands on the current line are executed. .HP 5 .B default: .br Labels the default case in a .I switch statement. The default should come after all .I case labels. .HP 5 .BR "dirs" .br Prints the directory stack; the top of the stack is at the left, the first directory in the stack being the current directory. .HP 5 .BR echo " wordlist" .br .ns .HP 5 .BR "echo \-n" " wordlist" .br The specified words are written to the shells standard output, separated by spaces, and terminated with a newline unless the .B \-n option is specified. .HP 5 .B else .br .ns .HP 5 .B end .br .ns .HP 5 .B endif .br .ns .HP 5 .B endsw .br See the description of the .I foreach, .I if, .I switch, and .I while statements below. .HP 5 .BR eval " arg ..." .br (As in .IR sh (1).) The arguments are read as input to the shell and the resulting command(s) executed in the context of the current shell. This is usually used to execute commands generated as the result of command or variable substitution, since parsing occurs before these substitutions. See .IR tset (1) for an example of using .IR eval . .HP 5 .BR exec " command" .br The specified command is executed in place of the current shell. .HP 5 .B exit .br .ns .HP 5 .BR exit (expr) .br The shell exits either with the value of the .I status variable (first form) or with the value of the specified .I expr (second form). .HP 5 .B fg .br .ns .HP 5 \fBfg\ %\fRjob\ ... .br Brings the current or specified jobs into the foreground, continuing them if they were stopped. .HP 5 .BR foreach " name (wordlist)" .br .ns .HP 5 \ ... .br .ns .HP 5 .B end .br The variable .I name is successively set to each member of .I wordlist and the sequence of commands between this command and the matching .I end are executed. (Both .I foreach and .I end must appear alone on separate lines.) .IP The builtin command .I continue may be used to continue the loop prematurely and the builtin command .I break to terminate it prematurely. When this command is read from the terminal, the loop is read up once prompting with `?' before any statements in the loop are executed. If you make a mistake typing in a loop at the terminal you can rub it out. .HP 5 .BR glob " wordlist" .br Like .I echo but no `\e' escapes are recognized and words are delimited by null characters in the output. Useful for programs which wish to use the shell to filename expand a list of words. .HP 5 .BR goto " word" .br The specified .I word is filename and command expanded to yield a string of the form `label'. The shell rewinds its input as much as possible and searches for a line of the form `label:' possibly preceded by blanks or tabs. Execution continues after the specified line. .HP 5 .BR hashstat .br Print a statistics line indicating how effective the internal hash table has been at locating commands (and avoiding .IR exec 's). An .I exec is attempted for each component of the .I path where the hash function indicates a possible hit, and in each component which does not begin with a `/'. .HP 5 .B history .br .ns .HP 5 .BI history " n" .br .ns .HP 5 .BI "history \-r" " n" .br .ns .HP 5 .BI "history \-h" " n" .br Displays the history event list; if \fIn\fR is given only the .I n most recent events are printed. The .B \-r option reverses the order of printout to be most recent first rather than oldest first. The .B \-h option causes the history list to be printed without leading numbers. This is used to produce files suitable for sourceing using the \-h option to .IR source . .HP 5 .BR if " (expr) command" .br If the specified expression evaluates true, then the single .I command with arguments is executed. Variable substitution on .IR command "" happens early, at the same time it does for the rest of the .I if command. .I Command must be a simple command, not a pipeline, a command list, or a parenthesized command list. Input/output redirection occurs even if .I expr is false, when command is .B not executed (this is a bug). .HP 5 .BR if " (expr) " "then" .br .ns .HP 5 \ ... .br .ns .HP 5 .BR else " " "if\fR (expr2) \fBthen" .br .ns .HP 5 \ ... .br .ns .HP 5 .B else .br .ns .HP 5 \ ... .br .ns .HP 5 .B endif .br If the specified .IR expr "" is true then the commands to the first .I else are executed; otherwise if .IR expr2 "" is true then the commands to the second \fIelse\fR are executed, etc. Any number of .I else-if pairs are possible; only one .I endif is needed. The .I else part is likewise optional. (The words .I else and .I endif must appear at the beginning of input lines; the .I if must appear alone on its input line or after an .I else.) .HP 5 .B jobs .br .ns .HP 5 .B "jobs \-l" .br Lists the active jobs; given the .B \-l options lists process id's in addition to the normal information. .HP 5 \fBkill %\fRjob .br .ns .HP 5 \fBkill\ \-\fRsig\ \fB%\fRjob\ ... .br .ns .HP 5 \fBkill\fR\ pid .br .ns .HP 5 \fBkill\ \-\fRsig\ pid\ ... .br .ns .HP 5 \fBkill\ \-l\fR .br Sends either the TERM (terminate) signal or the specified signal to the specified jobs or processes. Signals are either given by number or by names (as given in .I /usr/include/signal.h, stripped of the prefix ``SIG''). The signal names are listed by ``kill \-l''. There is no default, saying just `kill' does not send a signal to the current job. If the signal being sent is TERM (terminate) or HUP (hangup), then the job or process will be sent a CONT (continue) signal as well. .HP \fBlimit\fR .br .ns .HP 5 \fBlimit\fR \fIresource\fR .br .ns .HP 5 \fBlimit\fR \fIresource\fR \fImaximum-use\fR .br .ns .HP 5 \fBlimit\ \-h\fR .br .ns .HP 5 \fBlimit\ \-h\fR \fIresource\fR .br .ns .HP 5 \fBlimit\ \-h\fR \fIresource\fR \fImaximum-use\fR .br Limits the consumption by the current process and each process it creates to not individually exceed \fImaximum-use\fR on the specified \fIresource\fR. If no \fImaximum-use\fR is given, then the current limit is printed; if no \fIresource\fR is given, then all limitations are given. If the \fB\-h\fR flag is given, the hard limits are used instead of the current limits. The hard limits impose a ceiling on the values of the current limits. Only the super-user may raise the hard limits, but a user may lower or raise the current limits within the legal range. .IP Resources controllable currently include \fIcputime\fR (the maximum number of cpu-seconds to be used by each process), \fIfilesize\fR (the largest single file which can be created), \fIdatasize\fR (the maximum growth of the data+stack region via .IR sbrk (2) beyond the end of the program text), \fIstacksize\fR (the maximum size of the automatically-extended stack region), and \fIcoredumpsize\fR (the size of the largest core dump that will be created). .IP The \fImaximum-use\fR may be given as a (floating point or integer) number followed by a scale factor. For all limits other than \fIcputime\fR the default scale is `k' or `kilobytes' (1024 bytes); a scale factor of `m' or `megabytes' may also be used. For .I cputime the default scaling is `seconds', while `m' for minutes or `h' for hours, or a time of the form `mm:ss' giving minutes and seconds may be used. .IP For both \fIresource\fR names and scale factors, unambiguous prefixes of the names suffice. .HP 5 .B login .br Terminate a login shell, replacing it with an instance of .B /bin/login. This is one way to log off, included for compatibility with .IR sh (1). .HP 5 .B logout .br Terminate a login shell. Especially useful if .I ignoreeof is set. .HP 5 .B nice .br .ns .HP 5 .BR nice " +number" .br .ns .HP 5 .BR nice " command" .br .ns .HP 5 .BR nice " +number command" .br The first form sets the scheduling priority for this shell to 4. The second form sets the priority to the given number. The final two forms run command at priority 4 and .I number respectively. The greater the number, the less cpu the process will get. The super-user may specify negative priority by using `nice \-number ...'. Command is always executed in a sub-shell, and the restrictions placed on commands in simple .I if statements apply. .HP 5 .B nohup .br .ns .HP 5 .BR "nohup" " command" .br The first form can be used in shell scripts to cause hangups to be ignored for the remainder of the script. The second form causes the specified command to be run with hangups ignored. All processes detached with `&' are effectively .I nohup'ed. .HP 5 .B notify .br .ns .HP 5 \fBnotify\ %\fRjob\ ... .br Causes the shell to notify the user asynchronously when the status of the current or specified jobs changes; normally notification is presented before a prompt. This is automatic if the shell variable .I notify is set. .HP 5 .B onintr .br .ns .HP 5 .BR onintr " \-" .br .ns .HP 5 .BR onintr " label" .br Control the action of the shell on interrupts. The first form restores the default action of the shell on interrupts which is to terminate shell scripts or to return to the terminal command input level. The second form `onintr \-' causes all interrupts to be ignored. The final form causes the shell to execute a `goto label' when an interrupt is received or a child process terminates because it was interrupted. .IP In any case, if the shell is running detached and interrupts are being ignored, all forms of .I onintr have no meaning and interrupts continue to be ignored by the shell and all invoked commands. .HP 5 .BR "popd" .br .ns .HP 5 .BR "popd" " +n" .br Pops the directory stack, returning to the new top directory. With an argument `+\fIn\fR' discards the \fIn\fR\|th entry in the stack. The elements of the directory stack are numbered from 0 starting at the top. .HP 5 .BR "pushd" .br .ns .HP 5 .BR "pushd" " name" .br .ns .HP 5 .BR "pushd" " +n" .br With no arguments, .I pushd exchanges the top two elements of the directory stack. Given a .I name argument, .I pushd changes to the new directory (ala .I cd) and pushes the old current working directory (as in .I csw) onto the directory stack. With a numeric argument, rotates the \fIn\fR\|th argument of the directory stack around to be the top element and changes to it. The members of the directory stack are numbered from the top starting at 0. .HP 5 .BR rehash .br Causes the internal hash table of the contents of the directories in the .I path variable to be recomputed. This is needed if new commands are added to directories in the .I path while you are logged in. This should only be necessary if you add commands to one of your own directories, or if a systems programmer changes the contents of one of the system directories. .HP 5 .BR repeat " count command" .br The specified .I command which is subject to the same restrictions as the .I command in the one line .I if statement above, is executed .I count times. I/O redirections occur exactly once, even if .I count is 0. .HP 5 .B set .br .ns .HP 5 .BR set " name" .br .ns .HP 5 .BR set " name=word" .br .ns .HP 5 .BR set " name[index]=word" .br .ns .HP 5 .BR set " name=(wordlist)" .br The first form of the command shows the value of all shell variables. Variables which have other than a single word as value print as a parenthesized word list. The second form sets .I name to the null string. The third form sets .I name to the single .I word. The fourth form sets the .I index'th component of name to word; this component must already exist. The final form sets .I name to the list of words in .I wordlist. In all cases the value is command and filename expanded. .IP These arguments may be repeated to set multiple values in a single set command. Note however, that variable expansion happens for all arguments before any setting occurs. .HP 5 .BR setenv .br .ns .HP 5 .BR setenv " name value" .br .ns .HP 5 .BR setenv " name" .br The first form lists all current environment variables. The last form sets the value of environment variable .I name to be .I value, a single string. The second form sets .I name to an empty string. The most commonly used environment variable USER, TERM, and PATH are automatically imported to and exported from the .I csh variables .I user, .I term, and .I path; there is no need to use .I setenv for these. .HP 5 .B shift .br .ns .HP 5 .BR shift " variable" .br The members of .I argv are shifted to the left, discarding .I argv[1]. It is an error for .I argv not to be set or to have less than one word as value. The second form performs the same function on the specified variable. .HP 5 .BR source " name" .br .ns .HP 5 .BR "source \-h" " name" .br The shell reads commands from .I name. .I Source commands may be nested; if they are nested too deeply the shell may run out of file descriptors. An error in a .I source at any level terminates all nested .I source commands. Normally input during .I source commands is not placed on the history list; the \-h option causes the commands to be placed in the history list without being executed. .HP 5 .B stop .br .ns .HP 5 \fBstop\ %\fRjob\ ... .br Stops the current or specified job which is executing in the background. .HP 5 .B suspend .br .ns Causes the shell to stop in its tracks, much as if it had been sent a stop signal with \fB^Z\fR. This is most often used to stop shells started by .IR su (1). .HP 5 .BR switch " (string)" .br .ns .HP 5 .BR case " str1:" .br .ns .HP 5 \ ... .br .ns .HP 5 \ .B breaksw .br .ns .HP 5 \&... .br .ns .HP 5 .B default: .br .ns .HP 5 \ ... .br .ns .HP 5 \ .B breaksw .br .ns .HP 5 .B endsw .br Each case label is successively matched, against the specified .I string which is first command and filename expanded. The file metacharacters `*', `?' and `[...]' may be used in the case labels, which are variable expanded. If none of the labels match before a `default' label is found, then the execution begins after the default label. Each case label and the default label must appear at the beginning of a line. The command .I breaksw causes execution to continue after the .I endsw. Otherwise control may fall through case labels and default labels as in C. If no label matches and there is no default, execution continues after the .I endsw. .HP 5 .B time .br .ns .HP 5 .BR time " command" .br With no argument, a summary of time used by this shell and its children is printed. If arguments are given the specified simple command is timed and a time summary as described under the .I time variable is printed. If necessary, an extra shell is created to print the time statistic when the command completes. .HP 5 .B umask .br .ns .HP 5 .BR umask " value" .br The file creation mask is displayed (first form) or set to the specified value (second form). The mask is given in octal. Common values for the mask are 002 giving all access to the group and read and execute access to others or 022 giving all access except no write access for users in the group or others. .HP 5 .BR unalias " pattern" .br All aliases whose names match the specified pattern are discarded. Thus all aliases are removed by `unalias *'. It is not an error for nothing to be .I unaliased. .HP 5 .BR unhash .br Use of the internal hash table to speed location of executed programs is disabled. .HP 5 \fBunlimit\fR .br .ns .HP 5 \fBunlimit\fR \fIresource\fR .br .ns .HP 5 \fBunlimit\ \-h\fR .br .ns .HP 5 \fBunlimit\ \-h\fR \fIresource\fR .br Removes the limitation on \fIresource\fR. If no \fIresource\fR is specified, then all \fIresource\fR limitations are removed. If \fB\-h\fR is given, the corresponding hard limits are removed. Only the super-user may do this. .HP 5 .BR unset " pattern" .br All variables whose names match the specified pattern are removed. Thus all variables are removed by `unset *'; this has noticeably distasteful side-effects. It is not an error for nothing to be .I unset. .HP 5 .BR unsetenv " pattern" .br Removes all variables whose name match the specified pattern from the environment. See also the .I setenv command above and .IR printenv (1). .HP 5 .B wait .br All background jobs are waited for. It the shell is interactive, then an interrupt can disrupt the wait, at which time the shell prints names and job numbers of all jobs known to be outstanding. .HP 5 .BR while " (expr)" .br .ns .HP 5 \ ... .br .ns .HP 5 .B end .br While the specified expression evaluates non-zero, the commands between the .I while and the matching end are evaluated. .I Break and .I continue may be used to terminate or continue the loop prematurely. (The .I while and .I end must appear alone on their input lines.) Prompting occurs here the first time through the loop as for the .I foreach statement if the input is a terminal. .HP 5 \fB%\fRjob .br Brings the specified job into the foreground. .HP 5 \fB%\fRjob \fB&\fR .br Continues the specified job in the background. .HP 5 .B "@" .br .ns .HP 5 .BR "@" " name = expr" .br .ns .HP 5 .BR "@" " name[index] = expr" .br The first form prints the values of all the shell variables. The second form sets the specified .I name to the value of .I expr. If the expression contains `<', `>', `&' or `|' then at least this part of the expression must be placed within `(' `)'. The third form assigns the value of .I expr to the .I index'th argument of .I name. Both .I name and its .I index'th component must already exist. .IP The operators `*=', `+=', etc are available as in C. The space separating the name from the assignment operator is optional. Spaces are, however, mandatory in separating components of .I expr which would otherwise be single words. .IP Special postfix `++' and `\-\|\-' operators increment and decrement .I name respectively, i.e. `@ i++'. .sh "Pre-defined and environment variables" The following variables have special meaning to the shell. Of these, .I argv, .I cwd, .I home, .I path, .I prompt, .I shell and .I status are always set by the shell. Except for .I cwd and .I status this setting occurs only at initialization; these variables will not then be modified unless this is done explicitly by the user. .PP This shell copies the environment variable USER into the variable .I user, TERM into .I term, and HOME into .I home, and copies these back into the environment whenever the normal shell variables are reset. The environment variable PATH is likewise handled; it is not necessary to worry about its setting other than in the file .I \&.cshrc as inferior .I csh processes will import the definition of .I path from the environment, and re-export it if you then change it. .TP 15 .B argv \c Set to the arguments to the shell, it is from this variable that positional parameters are substituted, i.e. `$1' is replaced by `$argv[1]', etc. .TP 15 .B cdpath \c Gives a list of alternate directories searched to find subdirectories in .I chdir commands. .TP 15 .B cwd The full pathname of the current directory. .TP 15 .B echo \c Set when the .B \-x command line option is given. Causes each command and its arguments to be echoed just before it is executed. For non-builtin commands all expansions occur before echoing. Builtin commands are echoed before command and filename substitution, since these substitutions are then done selectively. .TP 15 .B filec Enable file name completion. \c .TP 15 .B histchars \c Can be given a string value to change the characters used in history substitution. The first character of its value is used as the history substitution character, replacing the default character !. The second character of its value replaces the character \(ua in quick substitutions. .TP 15 .B history \c Can be given a numeric value to control the size of the history list. Any command which has been referenced in this many events will not be discarded. Too large values of .I history may run the shell out of memory. The last executed command is always saved on the history list. .TP 15 .B home \c The home directory of the invoker, initialized from the environment. The filename expansion of `\fB~\fR' refers to this variable. .TP 15 .B ignoreeof \c If set the shell ignores end-of-file from input devices which are terminals. This prevents shells from accidentally being killed by control-D's. .TP 15 .B mail \c The files where the shell checks for mail. This is done after each command completion which will result in a prompt, if a specified interval has elapsed. The shell says `You have new mail.' if the file exists with an access time not greater than its modify time. .IP If the first word of the value of .I mail is numeric it specifies a different mail checking interval, in seconds, than the default, which is 10 minutes. .IP If multiple mail files are specified, then the shell says `New mail in .IR name ' when there is mail in the file .I name. .TP 15 .B noclobber \c As described in the section on .I Input/output, restrictions are placed on output redirection to insure that files are not accidentally destroyed, and that `>>' redirections refer to existing files. .TP 15 .B noglob \c If set, filename expansion is inhibited. This is most useful in shell scripts which are not dealing with filenames, or after a list of filenames has been obtained and further expansions are not desirable. .TP 15 .B nonomatch \c If set, it is not an error for a filename expansion to not match any existing files; rather the primitive pattern is returned. It is still an error for the primitive pattern to be malformed, i.e. `echo [' still gives an error. .TP 15 .B notify \c If set, the shell notifies asynchronously of job completions. The default is to rather present job completions just before printing a prompt. .TP 15 .B path \c Each word of the path variable specifies a directory in which commands are to be sought for execution. A null word specifies the current directory. If there is no .I path variable then only full path names will execute. The usual search path is `.', `/bin' and `/usr/bin', but this may vary from system to system. For the super-user the default search path is `/bin', `/sbin', `/usr/sbin', and `/usr/bin'. A shell which is given neither the .B \-c nor the .B \-t option will normally hash the contents of the directories in the .I path variable after reading .I \&.cshrc, and each time the .I path variable is reset. If new commands are added to these directories while the shell is active, it may be necessary to give the .I rehash or the commands may not be found. .TP 15 .B prompt \c The string which is printed before each command is read from an interactive terminal input. If a `!' appears in the string it will be replaced by the current event number unless a preceding `\e' is given. Default is `% ', or `# ' for the super-user. .TP 15 .B savehist \c is given a numeric value to control the number of entries of the history list that are saved in ~/.history when the user logs out. Any command which has been referenced in this many events will be saved. During start up the shell sources ~/.history into the history list enabling history to be saved across logins. Too large values of .I savehist will slow down the shell during start up. .TP 15 .B shell \c The file in which the shell resides. This is used in forking shells to interpret files which have execute bits set, but which are not executable by the system. (See the description of .I "Non-builtin Command Execution" below.) Initialized to the (system-dependent) home of the shell. .TP 15 .B status \c The status returned by the last command. If it terminated abnormally, then 0200 is added to the status. Builtin commands which fail return exit status `1', all other builtin commands set status `0'. .TP 15 .B time \c Controls automatic timing of commands. If set, then any command which takes more than this many cpu seconds will cause a line giving user, system, and real times and a utilization percentage which is the ratio of user plus system times to real time to be printed when it terminates. .TP 15 .B verbose \c Set by the .B \-v command line option, causes the words of each command to be printed after history substitution. .sh "Non-builtin command execution" When a command to be executed is found to not be a builtin command the shell attempts to execute the command via .IR execve (2). Each word in the variable .I path names a directory from which the shell will attempt to execute the command. If it is given neither a .B \-c nor a .B \-t option, the shell will hash the names in these directories into an internal table so that it will only try an .I exec in a directory if there is a possibility that the command resides there. This greatly speeds command location when a large number of directories are present in the search path. If this mechanism has been turned off (via .IR unhash ), or if the shell was given a .B \-c or .B \-t argument, and in any case for each directory component of .I path which does not begin with a `/', the shell concatenates with the given command name to form a path name of a file which it then attempts to execute. .PP Parenthesized commands are always executed in a subshell. Thus `(cd ; pwd) ; pwd' prints the .I home directory; leaving you where you were (printing this after the home directory), while `cd ; pwd' leaves you in the .I home directory. Parenthesized commands are most often used to prevent .I chdir from affecting the current shell. .PP If the file has execute permissions but is not an executable binary to the system, then it is assumed to be a file containing shell commands and a new shell is spawned to read it. .PP If there is an .I alias for .I shell then the words of the alias will be prepended to the argument list to form the shell command. The first word of the .I alias should be the full path name of the shell (e.g. `$shell'). Note that this is a special, late occurring, case of .I alias substitution, and only allows words to be prepended to the argument list without modification. .sh "Argument list processing" If argument 0 to the shell is `\-' then this is a login shell. The flag arguments are interpreted as follows: .TP 5 .B \-b \c This flag forces a ``break'' from option processing, causing any further shell arguments to be treated as non-option arguments. The remaining arguments will not be interpreted as shell options. This may be used to pass options to a shell script without confusion or possible subterfuge. The shell will not run a set-user ID script without this option. .TP 5 .B \-c \c Commands are read from the (single) following argument which must be present. Any remaining arguments are placed in .I argv. .TP 5 .B \-e \c The shell exits if any invoked command terminates abnormally or yields a non-zero exit status. .TP 5 .B \-f \c The shell will start faster, because it will neither search for nor execute commands from the file `\&.cshrc' in the invoker's home directory. .TP 5 .B \-i \c The shell is interactive and prompts for its top-level input, even if it appears to not be a terminal. Shells are interactive without this option if their inputs and outputs are terminals. .TP 5 .B \-n \c Commands are parsed, but not executed. This aids in syntactic checking of shell scripts. .TP 5 .B \-s \c Command input is taken from the standard input. .TP 5 .B \-t \c A single line of input is read and executed. A `\e' may be used to escape the newline at the end of this line and continue onto another line. .TP 5 .B \-v \c Causes the .I verbose variable to be set, with the effect that command input is echoed after history substitution. .TP 5 .B \-x \c Causes the .I echo variable to be set, so that commands are echoed immediately before execution. .TP 5 .B \-V \c Causes the .I verbose variable to be set even before `\&.cshrc' is executed. .TP 5 .B \-X \c Is to .B \-x as .B \-V is to .B \-v. .PP After processing of flag arguments, if arguments remain but none of the .B \-c, .B \-i, .B \-s, or .B \-t options was given, the first argument is taken as the name of a file of commands to be executed. The shell opens this file, and saves its name for possible resubstitution by `$0'. Since many systems use either the standard version 6 or version 7 shells whose shell scripts are not compatible with this shell, the shell will execute such a `standard' shell if the first character of a script is not a `#', i.e. if the script does not start with a comment. Remaining arguments initialize the variable .I argv. .sh "Signal handling" The shell normally ignores .I quit signals. Jobs running detached (either by `&' or the \fIbg\fR or \fB%... &\fR commands) are immune to signals generated from the keyboard, including hangups. Other signals have the values which the shell inherited from its parent. The shells handling of interrupts and terminate signals in shell scripts can be controlled by .I onintr. Login shells catch the .I terminate signal; otherwise this signal is passed on to children from the state in the shell's parent. In no case are interrupts allowed when a login shell is reading the file `\&.logout'. .SH AUTHOR William Joy. Job control and directory stack features first implemented by J.E. Kulp of I.I.A.S.A, Laxenburg, Austria, with different syntax than that used now. File name completion code written by Ken Greer, HP Labs. .SH FILES .ta 1.75i .nf ~/.cshrc Read at beginning of execution by each shell. ~/.login Read by login shell, after `.cshrc' at login. ~/.logout Read by login shell, at logout. /bin/sh Standard shell, for shell scripts not starting with a `#'. /tmp/sh* Temporary file for `<<'. /etc/passwd Source of home directories for `~name'. .fi .SH LIMITATIONS Words can be no longer than 1024 characters. The system limits argument lists to 10240 characters. The number of arguments to a command which involves filename expansion is limited to 1/6'th the number of characters allowed in an argument list. Command substitutions may substitute no more characters than are allowed in an argument list. To detect looping, the shell restricts the number of .I alias substitutions on a single line to 20. .SH "SEE ALSO" sh(1), access(2), execve(2), fork(2), killpg(2), pipe(2), sigvec(2), umask(2), setrlimit(2), wait(2), tty(4), a.out(5), environ(7), `An introduction to the C shell' .SH BUGS When a command is restarted from a stop, the shell prints the directory it started in if this is different from the current directory; this can be misleading (i.e. wrong) as the job may have changed directories internally. .PP Shell builtin functions are not stoppable/restartable. Command sequences of the form `a ; b ; c' are also not handled gracefully when stopping is attempted. If you suspend `b', the shell will then immediately execute `c'. This is especially noticeable if this expansion results from an .I alias. It suffices to place the sequence of commands in ()'s to force it to a subshell, i.e. `( a ; b ; c )'. .PP Control over tty output after processes are started is primitive; perhaps this will inspire someone to work on a good virtual terminal interface. In a virtual terminal interface much more interesting things could be done with output control. .PP Alias substitution is most often used to clumsily simulate shell procedures; shell procedures should be provided rather than aliases. .PP Commands within loops, prompted for by `?', are not placed in the .I history list. Control structure should be parsed rather than being recognized as built-in commands. This would allow control commands to be placed anywhere, to be combined with `|', and to be used with `&' and `;' metasyntax. .PP It should be possible to use the `:' modifiers on the output of command substitutions. All and more than one `:' modifier should be allowed on `$' substitutions. .PP The way the .B filec facility is implemented is ugly and expensive. ================================================ FILE: share/man/man1/ctags.1 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)ctags.1 6.2 (Berkeley) 5/30/85 .\" .TH CTAGS 1 "May 30, 1985" .UC 4 .SH NAME ctags \- create a tags file .SH SYNOPSIS .B ctags [ .B \-BFatuwvx ] [ .B \-f .I tagsfile ] name ... .SH DESCRIPTION .I Ctags makes a tags file for .IR ex (1) from the specified C, Pascal, Fortran, YACC, lex, and lisp sources. A tags file gives the locations of specified objects (in this case functions and typedefs) in a group of files. Each line of the tags file contains the object name, the file in which it is defined, and an address specification for the object definition. Functions are searched with a pattern, typedefs with a line number. Specifiers are given in separate fields on the line, separated by blanks or tabs. Using the .I tags file, .I ex can quickly find these objects definitions. .PP If the .B \-x flag is given, .I ctags produces a list of object names, the line number and file name on which each is defined, as well as the text of that line and prints this on the standard output. This is a simple index which can be printed out as an off-line readable function index. .PP If the .B \-v flag is given, an index of the form expected by .IR vgrind (1) is produced on the standard output. This listing contains the function name, file name, and page number (assuming 64 line pages). Since the output will be sorted into lexicographic order, it may be desired to run the output through .BR "sort \-f" . Sample use: .nf ctags \-v files | sort \-f > index vgrind \-x index .fi .PP Normally .I ctags places the tag descriptions in a file called .IR tags ; this may be overridden with the .B \-f option. .PP Files whose names end in .B \.c or .B \.h are assumed to be C source files and are searched for C routine and macro definitions. Files whose names end in .B \.y are assumed to be YACC source files. Files whose names end in .B \.l are assumed to be either lisp files if their first non-blank character is `;', `(', or `[', or lex files otherwise. Other files are first examined to see if they contain any Pascal or Fortran routine definitions; if not, they are processed again looking for C definitions. .PP Other options are: .TP 5 .B \-F use forward searching patterns (/.../) (default). .TP 5 .B \-B use backward searching patterns (?...?). .TP 5 .B \-a append to tags file. .TP 5 .B \-t create tags for typedefs. .TP 5 .B \-w suppressing warning diagnostics. .TP 5 .B \-u causing the specified files to be .I updated in tags, that is, all references to them are deleted, and the new values are appended to the file. (Beware: this option is implemented in a way which is rather slow; it is usually faster to simply rebuild the .I tags file.) .PP The tag .I main is treated specially in C programs. The tag formed is created by prepending .I M to the name of the file, with a trailing .c removed, if any, and leading pathname components also removed. This makes use of .I ctags practical in directories with more than one program. .SH FILES .DT tags output tags file .SH SEE ALSO ex(1), vi(1) .SH AUTHOR Ken Arnold; FORTRAN added by Jim Kleckner; Bill Joy added Pascal and .B \-x, replacing .I cxref; C typedefs added by Ed Pelegri-Llopart. .SH BUGS Recognition of \fBfunctions\fR, \fBsubroutines\fR and \fBprocedures\fR for FORTRAN and Pascal is done is a very simpleminded way. No attempt is made to deal with block structure; if you have two Pascal procedures in different blocks with the same name you lose. .PP The method of deciding whether to look for C or Pascal and FORTRAN functions is a hack. .PP Does not know about #ifdefs. .PP Should know about Pascal types. Relies on the input being well formed to detect typedefs. Use of -tx shows only the last line of typedefs. ================================================ FILE: share/man/man1/date.1 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)date.1 6.5 (Berkeley) 3/24/87 .\" .TH DATE 1 "March 24, 1987" .UC 4 .SH NAME date \- print and set the date .SH SYNOPSIS .B date .RB "[-nu] [-d dst] [-t timezone] [yymmddhhmm [" . "ss] ]" .SH DESCRIPTION If no arguments are given, the current date and time are printed. Providing an argument will set the desired date; only the superuser can set the date. The \fI-d\fP and \fI-t\fP flags set the kernel's values for daylight savings time and minutes west of GMT. If \fIdst\fP is non-zero, future calls to \fIgettimeofday\fP(2) will return a non-zero \fItz_dsttime\fP. \fITimezone\fP provides the number of minutes returned by future calls to \fIgettimeofday\fP(2) in \fItz_minuteswest\fP. The \fI-u\fP flag is used to display or set the date in GMT (universal) time. .I yy represents the last two digits of the year; the first .I mm is the month number; .I dd is the day number; .I hh is the hour number (24 hour system); the second .I mm is the minute number; .BI . ss is optional and represents the seconds. For example: .IP date 8506131627 .PP sets the date to June 13 1985, 4:27 PM. The year, month and day may be omitted; the default values will be the current ones. The system operates in GMT. \fIDate\fP takes care of the conversion to and from local standard and daylight-saving time. .PP If .I timed(8) is running to synchronize the clocks of machines in a local area network, \fIdate\fP sets the time globally on all those machines unless the .B \-n option is given. .SH FILES /usr/adm/wtmp to record time-setting. In /usr/adm/messages, \fIdate\fP records the name of the user setting the time. .SH SEE ALSO gettimeofday(2), utmp(5), timed(8), .br \fITSP: The Time Synchronization Protocol for UNIX 4.3BSD\fP, R. Gusella and S. Zatti .SH DIAGNOSTICS Exit status is 0 on success, 1 on complete failure to set the date, and 2 on successfully setting the local date but failing globally. .PP Occasionally, when \fItimed\fP synchronizes the time on many hosts, the setting of a new time value may require more than a few seconds. On these occasions, \fIdate\fP prints: `Network time being set'. The message `Communication error with timed' occurs when the communication between \fIdate\fP and \fItimed\fP fails. .SH BUGS The system attempts to keep the date in a format closely compatible with VMS. VMS, however, uses local time (rather than GMT) and does not understand daylight-saving time. Thus, if you use both UNIX and VMS, VMS will be running on GMT. ================================================ FILE: share/man/man1/dd.1 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)dd.1 6.1 (Berkeley) 4/29/85 .\" .TH DD 1 "April 29, 1985" .UC 4 .SH NAME dd \- convert and copy a file .SH SYNOPSIS .B dd [option=value] ... .SH DESCRIPTION .I Dd copies the specified input file to the specified output with possible conversions. The standard input and output are used by default. The input and output block size may be specified to take advantage of raw physical I/O. .PP .br .ns .TP 15 .I option .I values .br .ns .TP if= input file name; standard input is default .br .ns .TP of= output file name; standard output is default .br .ns .TP .RI ibs= n input block size .I n bytes (default 512) .br .ns .TP .RI obs= n output block size (default 512) .br .ns .TP .RI bs= n set both input and output block size, superseding .I ibs and .I obs; also, if no conversion is specified, it is particularly efficient since no copy need be done .br .ns .TP .RI cbs= n conversion buffer size .br .ns .TP .RI skip= n skip .IR n "" input records before starting copy .br .ns .TP .RI files= n copy .I n input files before terminating (makes sense only where input is a magtape or similar device). .br .ns .TP .RI seek= n seek .I n records from beginning of output file before copying .br .ns .TP count=\fIn\fR copy only .IR n "" input records .br .ns .TP conv=ascii .ds h \h'\w'conv='u' convert EBCDIC to ASCII .br .ns .IP \*hebcdic convert ASCII to EBCDIC .br .ns .IP \*hibm slightly different map of ASCII to EBCDIC .br .ns .IP \*hblock convert variable length records to fixed length .br .ns .IP \*hunblock convert fixed length records to variable length .br .ns .IP \*hlcase map alphabetics to lower case .br .ns .IP \*hucase map alphabetics to upper case .br .ns .IP \*hswab swap every pair of bytes .br .ns .IP \*hnoerror do not stop processing on an error .br .ns .IP \*hsync pad every input record to .I ibs .br .ns .IP "\*h... , ..." several comma-separated conversions .PP .fi Where sizes are specified, a number of bytes is expected. A number may end with .B "k, b" or .B w to specify multiplication by 1024, 512, or 2 respectively; a pair of numbers may be separated by .B x to indicate a product. .PP .I Cbs is used only if .I ascii, .I unblock, .I ebcdic, .I ibm, or .I block conversion is specified. In the first two cases, .I cbs characters are placed into the conversion buffer, any specified character mapping is done, trailing blanks trimmed and new-line added before sending the line to the output. In the latter three cases, characters are read into the conversion buffer, and blanks added to make up an output record of size .IR cbs . .PP After completion, .I dd reports the number of whole and partial input and output blocks. .PP For example, to read an EBCDIC tape blocked ten 80-byte EBCDIC card images per record into the ASCII file .I x: .IP .nf dd if=/dev/rmt0 of=x ibs=800 cbs=80 conv=ascii,lcase .fi .PP Note the use of raw magtape. .I Dd is especially suited to I/O on the raw physical devices because it allows reading and writing in arbitrary record sizes. .SH "SEE ALSO" cp(1), tr(1) .SH DIAGNOSTICS f+p records in(out): numbers of full and partial records read(written) .SH BUGS The ASCII/EBCDIC conversion tables are taken from the 256 character standard in the CACM Nov, 1968. The `ibm' conversion, while less blessed as a standard, corresponds better to certain IBM print train conventions. There is no universal solution. .br One must specify ``conv=noerror,sync'' when copying raw disks with bad sectors to insure .I dd stays synchronized. .PP Certain combinations of arguments to .I conv= are permitted. However, the .I block or .I unblock option cannot be combined with .IR ascii , .IR ebcdic "" or .IR ibm . Invalid combinations .I "silently ignore" all but the last mutually-exclusive keyword. ================================================ FILE: share/man/man1/deroff.1 ================================================ .\" @(#)deroff.1 6.1 (Berkeley) 4/29/85 .\" .TH DEROFF 1 "April 29, 1985" .AT 3 .SH NAME deroff \- remove nroff, troff, tbl and eqn constructs .SH SYNOPSIS .B deroff [ .B \-w ] file ... .SH DESCRIPTION .I Deroff reads each file in sequence and removes all .I nroff and .I troff command lines, backslash constructions, macro definitions, .I eqn constructs (between `.EQ' and `.EN' lines or between delimiters), and table descriptions and writes the remainder on the standard output. .I Deroff follows chains of included files (`.so' and `.nx' commands); if a file has already been included, a `.so' is ignored and a `.nx' terminates execution. If no input file is given, .I deroff reads from the standard input file. .PP If the .B \-w flag is given, the output is a word list, one `word' (string of letters, digits, and apostrophes, beginning with a letter; apostrophes are removed) per line, and all other characters ignored. Otherwise, the output follows the original, with the deletions mentioned above. .SH "SEE ALSO" troff(1), eqn(1), tbl(1) .SH BUGS .I Deroff is not a complete .I troff interpreter, so it can be confused by subtle constructs. Most errors result in too much rather than too little output. ================================================ FILE: share/man/man1/df.1 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)df.1 6.1 (Berkeley) 4/29/85 .\" .TH DF 1 "April 29, 1985" .UC 4 .SH NAME df \- disk free .SH SYNOPSIS .B df [ .B \-i ] [ filesystem ... ] [ file ... ] .SH DESCRIPTION .I Df prints out the amount of free disk space available on the specified .I filesystem, e.g. ``/dev/rp0a'', or on the filesystem in which the specified .I file, e.g. ``$HOME'', is contained. If no file system is specified, the free space on all of the normally mounted file systems is printed. The reported numbers are in kilobytes. .PP Other options are: .TP .B \-i Report also the number of inodes which are used and free. .SH FILES /etc/fstab list of normally mounted filesystems .SH "SEE ALSO" fstab(5), icheck(8), quot(8) ================================================ FILE: share/man/man1/diction.1 ================================================ .\" @(#)diction.1 6.2 (Berkeley) 5/10/86 .\" .TH DICTION 1 "May 10, 1986" .AT 3 .SH NAME diction, explain \- print wordy sentences; thesaurus for diction .SH SYNOPSIS .B diction [ .B \-ml ] [ .B \-mm ] [ .B \-n ] [ .B \-f pfile ] file ... .br .B explain .LP .SH DESCRIPTION .I Diction finds all sentences in a document that contain phrases from a data base of bad or wordy diction. Each phrase is bracketed with [ ]. Because .I diction runs .I deroff before looking at the text, formatting header files should be included as part of the input. The default macro package .B \-ms may be overridden with the flag .B \-mm. The flag .B \-ml which causes .B deroff to skip lists, should be used if the document contains many lists of non-sentences. The user may supply her/his own pattern file to be used in addition to the default file with .B \-f .I pfile. If the flag .B \-n is also supplied the default file will be suppressed. .PP .I Explain is an interactive thesaurus for the phrases found by diction. .SH "SEE ALSO" deroff(1) .SH BUGS Use of non-standard formatting macros may cause incorrect sentence breaks. In particular, .I diction doesn't grok .B \-me. ================================================ FILE: share/man/man1/diff.1 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)diff.1 6.4.1 (2.11BSD) 1996/10/21 .\" .TH DIFF 1 "October 21, 1996" .UC 4 .SH NAME diff \- differential file and directory comparator .SH SYNOPSIS .B diff [ .B \-l ] [ .B \-r ] [ .B \-s ] [ \fB\-cefhn\fR ] [ .B \-biwt ] dir1 dir2 .br .B diff [ \fB\-cefhn ] [ \fB\-biwt\fR ] file1 file2 .br .B diff [ .BI \-D string ] [ .B \-biw ] file1 file2 .SH DESCRIPTION If both arguments are directories, .I diff sorts the contents of the directories by name, and then runs the regular file .I diff algorithm (described below) on text files which are different. Binary files which differ, common subdirectories, and files which appear in only one directory are listed. Options when comparing directories are: .TP .B \-l long output format; each text file .I diff is piped through .IR pr (1) to paginate it, other differences are remembered and summarized after all text file differences are reported. .TP .B \-r causes application of .I diff recursively to common subdirectories encountered. .TP .B \-s causes .I diff to report files which are the same, which are otherwise not mentioned. .TP .B \-Sname starts a directory .I diff in the middle beginning with file .I name. .PP When run on regular files, and when comparing text files which differ during directory comparison, .I diff tells what lines must be changed in the files to bring them into agreement. Except in rare circumstances, .I diff finds a smallest sufficient set of file differences. If neither .I file1 nor .I file2 is a directory, then either may be given as `\-', in which case the standard input is used. If .I file1 is a directory, then a file in that directory whose file-name is the same as the file-name of .I file2 is used (and vice versa). .PP There are several options for output format; the default output format contains lines of these forms: .IP "" 5 .I n1 a .I n3,n4 .br .I n1,n2 d .I n3 .br .I n1,n2 c .I n3,n4 .PP These lines resemble .I ed commands to convert .I file1 into .IR file2 . The numbers after the letters pertain to .IR file2 . In fact, by exchanging `a' for `d' and reading backward one may ascertain equally how to convert .I file2 into .IR file1 . As in .I ed, identical pairs where .I n1 = .I n2 or .I n3 = .I n4 are abbreviated as a single number. .PP Following each of these lines come all the lines that are affected in the first file flagged by `<', then all the lines that are affected in the second file flagged by `>'. .PP Except for \fB\-b, -w, -i\fP or \fB-t\fP which may be given with any of the others, the following options are mutually exclusive: .TP 9 .B \-e produces a script of .I "a, c" and .I d commands for the editor .I ed, which will recreate .I file2 from .IR file1 . In connection with .BR \-e , the following shell program may help maintain multiple versions of a file. Only an ancestral file ($1) and a chain of version-to-version .I ed scripts ($2,$3,...) made by .I diff need be on hand. A `latest version' appears on the standard output. .IP \ \ \ \ \ \ \ \ (shift; cat $*; echo \'1,$p\') \(bv ed \- $1 .IP Extra commands are added to the output when comparing directories with .B \-e, so that the result is a .IR sh (1) script for converting text files which are common to the two directories from their state in .I dir1 to their state in .I dir2. .TP 9 .B \-f produces a script similar to that of .B \-e, not useful with .I ed, and in the opposite order. .TP 9 .B \-n produces a script similar to that of .B \-e, but in the opposite order and with a count of changed lines on each insert or delete command. This is the form used by .IR rcsdiff (1). .TP 9 .B \-c produces a diff with lines of context. The default is to present 3 lines of context and may be changed, e.g to 10, by .BR \-c10 \&. With .B \-c the output format is modified slightly: the output beginning with identification of the files involved and their creation dates and then each change is separated by a line with a dozen *'s. The lines removed from .I file1 are marked with `\(mi '; those added to .I file2 are marked `+ '. Lines which are changed from one file to the other are marked in both files with with `! '. Changes which lie within lines of each other are grouped together on output. (This is a change from the previous ``diff -c'' but the resulting output is usually much easier to interpret.) .TP 9 .B \-h does a fast, half-hearted job. It works only when changed stretches are short and well separated, but does work on files of unlimited length. .TP .B \-Dstring causes .I diff to create a merged version of .I file1 and .I file2 on the standard output, with C preprocessor controls included so that a compilation of the result without defining \fIstring\fR is equivalent to compiling .I file1, while defining .I string will yield .I file2. .TP 9 .B \-b causes trailing blanks (spaces and tabs) to be ignored, and other strings of blanks to compare equal. .TP 9 .B \-w is similar to .B \-b but causes whitespace (blanks and tabs) to be totally ignored. E.g., ``if\ (\ a\ ==\ b\ )'' will compare equal to ``if(a==b)''. .TP 9 .B \-i ignores the case of letters. E.g., ``A'' will compare equal to ``a''. .TP 9 .B \-t will expand tabs in output lines. Normal or .B \-c output adds character(s) to the front of each line which may screw up the indentation of the original source lines and make the output listing difficult to interpret. This option will preserve the original source's indentation. .SH FILES /tmp/d????? .br /usr/libexec/diffh for .B \-h .br /bin/diff for directory diffs .br /bin/pr .SH "SEE ALSO" cmp(1), cc(1), comm(1), ed(1), diff3(1) .SH DIAGNOSTICS Exit status is 0 for no differences, 1 for some, 2 for trouble. .SH BUGS Editing scripts produced under the .BR \-e " or" .BR \-f " option are naive about" creating lines consisting of a single `\fB.\fR'. .PP When comparing directories with the \fB\-b, -w\fP or \fB-i\fP options specified, .I diff first compares the files ala .I cmp, and then decides to run the .I diff algorithm if they are not equal. This may cause a small amount of spurious output if the files then turn out to be identical because the only differences are insignificant blank string or case differences. ================================================ FILE: share/man/man1/diff3.1 ================================================ .\" @(#)diff3.1 6.2.1 (2.11BSD) 1996/10/21 .\" .TH DIFF3 1 "October 21, 1996" .AT 3 .SH NAME diff3 \- 3-way differential file comparison .SH SYNOPSIS .B diff3 [ .B \-exEX3 ] file1 file2 file3 .SH DESCRIPTION .I Diff3 compares three versions of a file, and publishes disagreeing ranges of text flagged with these codes: .TP 16 ==== all three files differ .TP 16 ====1 .IR file1 " is different" .TP 16 ====2 .IR file2 " is different" .TP 16 ====3 .IR file3 " is different" .PP The type of change suffered in converting a given range of a given file to some other is indicated in one of these ways: .TP 16 .IB f " : " n1 " a" Text is to be appended after line number .I n1 in file .I f, where .I f = 1, 2, or 3. .TP 16 .IB f " : " n1 " , " n2 " c" Text is to be changed in the range line .I n1 to line .IR n2 . If .I n1 = .I n2, the range may be abbreviated to .IR n1 . .PP The original contents of the range follows immediately after a .B c indication. When the contents of two files are identical, the contents of the lower-numbered file is suppressed. .PP Under the .B \-e option, .I diff3 publishes a script for the editor .I ed that will incorporate into .I file1 all changes between .I file2 and .I file3, .IR i.e . the changes that normally would be flagged ==== and ====3. Option .B \-x (\fB\-3\fR) produces a script to incorporate only changes flagged ==== (====3). The following command will apply the resulting script to `file1'. .PP .ti 16n (cat script; echo \'1,$p\') \(bv ed \- file1 .PP The .B \-E and .B \-X are similar to .B \-e and .BR \-x , respectively, but treat overlapping changes (i.e., changes that would be flagged with ==== in the normal listing) differently. The overlapping lines from both files will be inserted by the edit script, bracketed by "<<<<<<" and ">>>>>>" lines. .PP For example, suppose lines 7-8 are changed in both file1 and file2. Applying the edit script generated by the command .ce "diff3 -E file1 file2 file3" .br to file1 results in the file: .RS .nf lines 1-6 of file1 <<<<<<< file1 lines 7-8 of file1 ======= lines 7-8 of file3 >>>>>>> file3 rest of file1 .fi .RE .PP The .B \-E option is used by RCS .IR merge (1) to insure that overlapping changes in the merged files are preserved and brought to someone's attention. .SH FILES /tmp/d3????? .br /usr/libexec/diff3 .SH "SEE ALSO" diff(1) .SH BUGS Text lines that consist of a single `.' will defeat .B \-e. ================================================ FILE: share/man/man1/du.1 ================================================ .\" @(#)du.1 6.1 (Berkeley) 4/29/85 .\" .TH DU 1 "April 29, 1985" .AT 3 .SH NAME du \- summarize disk usage .SH SYNOPSIS .B du [ .B \-s ] [ .B \-a ] [ name ... ] .SH DESCRIPTION .I Du gives the number of kilobytes contained in all files and, recursively, directories within each specified directory or file .IR name . If .I name is missing, `\fB.\fR' is used. .PP The argument .B \-s causes only the grand total to be given. The argument .B \-a causes an entry to be generated for each file. Absence of either causes an entry to be generated for each directory only. .PP A file which has two links to it is only counted once. .SH "SEE ALSO" df(1), quot(8) .SH BUGS Non-directories given as arguments (not under .B \-a option) are not listed. .br If there are too many distinct linked files, .I du counts the excess files multiply. ================================================ FILE: share/man/man1/echo.1 ================================================ .\" @(#)echo.1 6.1 (Berkeley) 4/29/85 .\" .TH ECHO 1 "April 29, 1985" .AT 3 .SH NAME echo \- echo arguments .SH SYNOPSIS .B echo [ .B \-n ] [ arg ] ... .SH DESCRIPTION .I Echo writes its arguments separated by blanks and terminated by a newline on the standard output. If the flag .B \-n is used, no newline is added to the output. .PP .I Echo is useful for producing diagnostics in shell programs and for writing constant data on pipes. To send diagnostics to the standard error file, do `echo ... 1>&2'. ================================================ FILE: share/man/man1/ed.1 ================================================ .\" @(#)ed.1 6.1.1.1 (Berkeley) 8/12/86 .\" .TH ED 1 "August 12, 1986" .AT 3 .if t .ds q \(aa .if n .ds q ' .SH NAME ed \- text editor .SH SYNOPSIS .B ed [ .B \- ] [ name ] .SH DESCRIPTION .I Ed is the standard text editor. .PP If a .I name argument is given, .I ed simulates an .I e command (see below)\| on the named file; that is to say, the file is read into .I ed's buffer so that it can be edited. The optional .B \- suppresses the printing of explanatory output and should be used when the standard input is an editor script. .PP .I Ed operates on a copy of any file it is editing; changes made in the copy have no effect on the file until a .IR w "" (write)\| command is given. The copy of the text being edited resides in a temporary file called the .IR buffer . .PP Commands to .I ed have a simple and regular structure: zero or more .I addresses followed by a single character .I command, possibly followed by parameters to the command. These addresses specify one or more lines in the buffer. Missing addresses are supplied by default. .PP In general, only one command may appear on a line. Certain commands allow the addition of text to the buffer. While .I ed is accepting text, it is said to be in .I "input mode." In this mode, no commands are recognized; all input is merely collected. Input mode is left by typing a period `\fB.\fR' alone at the beginning of a line. .PP .I Ed supports a limited form of .I "regular expression" notation. A regular expression specifies a set of strings of characters. A member of this set of strings is said to be .I matched by the regular expression. In the following specification for regular expressions the word `character' means any character but newline. .IP 1. Any character except a special character matches itself. Special characters are the regular expression delimiter plus .RB \e\|[\| . and sometimes ^\|*\|$. .IP 2. A .B . matches any character. .IP 3. A \e followed by any character except a digit or (\|) matches that character. .IP 4. A nonempty string .I s bracketed .RI [ \|s\| ] (or .RI [^ s\| ]) matches any character in (or not in) .I s. In .I s, \e has no special meaning, and ] may only appear as the first letter. A substring .I a\-b, with .I a and .I b in ascending ASCII order, stands for the inclusive range of ASCII characters. .IP 5. A regular expression of form 1-4 followed by * matches a sequence of 0 or more matches of the regular expression. .IP 6. A regular expression, .I x, of form 1-8, bracketed .RI \e( \|x\| \e) matches what .I x matches. .IP 7. A \e followed by a digit .I n matches a copy of the string that the bracketed regular expression beginning with the .IR n th \e( matched. .IP 8. A regular expression of form 1-8, .I x, followed by a regular expression of form 1-7, .I y matches a match for .I x followed by a match for .I y, with the .I x match being as long as possible while still permitting a .I y match. .IP 9. A regular expression of form 1-8 preceded by ^ (or followed by $), is constrained to matches that begin at the left (or end at the right) end of a line. .IP 10. A regular expression of form 1-9 picks out the longest among the leftmost matches in a line. .IP 11. An empty regular expression stands for a copy of the last regular expression encountered. .PP Regular expressions are used in addresses to specify lines and in one command (see .I s below)\| to specify a portion of a line which is to be replaced. If it is desired to use one of the regular expression metacharacters as an ordinary character, that character may be preceded by `\e'. This also applies to the character bounding the regular expression (often `/')\| and to `\e' itself. .PP To understand addressing in .I ed it is necessary to know that at any time there is a .I "current line." Generally speaking, the current line is the last line affected by a command; however, the exact effect on the current line is discussed under the description of the command. Addresses are constructed as follows. .TP 1. The character `\fB.\fR' addresses the current line. .TP 2. The character `$' addresses the last line of the buffer. .TP 3. A decimal number .I n addresses the .IR n -th line of the buffer. .TP 4. `\(fm\fIx\fR' addresses the line marked with the name .IR x , which must be a lower-case letter. Lines are marked with the .I k command described below. .TP 5. A regular expression enclosed in slashes `/' addresses the line found by searching forward from the current line and stopping at the first line containing a string that matches the regular expression. If necessary the search wraps around to the beginning of the buffer. .TP 6. A regular expression enclosed in queries `?' addresses the line found by searching backward from the current line and stopping at the first line containing a string that matches the regular expression. If necessary the search wraps around to the end of the buffer. .TP 7. An address followed by a plus sign `+' or a minus sign `\-' followed by a decimal number specifies that address plus (resp. minus)\| the indicated number of lines. The plus sign may be omitted. .TP 8. If an address begins with `+' or `\-' the addition or subtraction is taken with respect to the current line; e.g. `\-5' is understood to mean `\fB.\fR\-5'. .TP 9. If an address ends with `+' or `\-', then 1 is added (resp. subtracted). As a consequence of this rule and rule 8, the address `\-' refers to the line before the current line. Moreover, trailing `+' and `\-' characters have cumulative effect, so `\-\-' refers to the current line less 2. .TP 10. To maintain compatibility with earlier versions of the editor, the character `^' in addresses is equivalent to `\-'. .PP Commands may require zero, one, or two addresses. Commands which require no addresses regard the presence of an address as an error. Commands which accept one or two addresses assume default addresses when insufficient are given. If more addresses are given than such a command requires, the last one or two (depending on what is accepted)\| are used. .PP Addresses are separated from each other typically by a comma `\fB,\fR'. They may also be separated by a semicolon `\fB;\fR'. In this case the current line `\fB.\fR' is set to the previous address before the next address is interpreted. This feature can be used to determine the starting line for forward and backward searches (`/', `?')\|. The second address of any two-address sequence must correspond to a line following the line corresponding to the first address. The special form `%' is an abbreviation for the address pair `1,$'. .PP In the following list of .I ed commands, the default addresses are shown in parentheses. The parentheses are not part of the address, but are used to show that the given addresses are the default. .PP As mentioned, it is generally illegal for more than one command to appear on a line. However, most commands may be suffixed by `p' or by `l', in which case the current line is either printed or listed respectively in the way discussed below. Commands may also be suffixed by `n', meaning the output of the command is to be line numbered. These suffixes may be combined in any order. .TP 5 .RB (\| .\| )\|a .br .ns .TP 5 .br .ns .TP 5 .B . .br The append command reads the given text and appends it after the addressed line. `\fB.\fR' is left on the last line input, if there were any, otherwise at the addressed line. Address `0' is legal for this command; text is placed at the beginning of the buffer. .TP 5 .RB (\| .\| ,\ .\| )\|c .br .ns .TP 5 .br .ns .TP 5 .B . .br The change command deletes the addressed lines, then accepts input text which replaces these lines. `\fB.\fR' is left at the last line input; if there were none, it is left at the line preceding the deleted lines. .TP 5 .RB (\| .\| ,\ .\| )\|d The delete command deletes the addressed lines from the buffer. The line originally after the last line deleted becomes the current line; if the lines deleted were originally at the end, the new last line becomes the current line. .TP 5 e filename The edit command causes the entire contents of the buffer to be deleted, and then the named file to be read in. `\fB.\fR' is set to the last line of the buffer. The number of characters read is typed. `filename' is remembered for possible use as a default file name in a subsequent .I r or .I w command. If `filename' is missing, the remembered name is used. .TP 5 E filename This command is the same as .I e, except that no diagnostic results when no .I w has been given since the last buffer alteration. .TP 5 f filename The filename command prints the currently remembered file name. If `filename' is given, the currently remembered file name is changed to `filename'. .TP 5 (1,$)\|g/regular expression/command list In the global command, the first step is to mark every line which matches the given regular expression. Then for every such line, the given command list is executed with `\fB.\fR' initially set to that line. A single command or the first of multiple commands appears on the same line with the global command. All lines of a multi-line list except the last line must be ended with `\e'. .I A, .I i, and .I c commands and associated input are permitted; the `\fB.\fR' terminating input mode may be omitted if it would be on the last line of the command list. The commands .I g and .I v are not permitted in the command list. .TP 5 .RB (\| .\| )\|i .ns .TP 5 .br .ns .TP 5 .B . .br This command inserts the given text before the addressed line. `\fB.\fR' is left at the last line input, or, if there were none, at the line before the addressed line. This command differs from the .I a command only in the placement of the text. .TP 5 .RB (\| .\| ,\ . +1)\|j This command joins the addressed lines into a single line; intermediate newlines simply disappear. `\fB.\fR' is left at the resulting line. .TP 5 ( \fB. \fR)\|k\fIx\fR The mark command marks the addressed line with name .I x, which must be a lower-case letter. The address form `\(fm\fIx\fR' then addresses this line. .ne 2.5 .TP 5 .RB (\| .\| ,\ .\| )\|l The list command prints the addressed lines in an unambiguous way: non-graphic characters are printed in two-digit octal, and long lines are folded. The .I l command may be placed on the same line after any non-i/o command. .TP 5 .RB (\| .\| ,\ .\| )\|m\fIa The move command repositions the addressed lines after the line addressed by .IR a . The last of the moved lines becomes the current line. .TP 5 .RB (\| .\| ,\ .\| )\|p The print command prints the addressed lines. `\fB.\fR' is left at the last line printed. The .I p command may be placed on the same line after any non-i/o command. .TP .RB (\| .\| ,\ .\| )\|P This command is a synonym for .I p. .TP 5 q The quit command causes .I ed to exit. No automatic write of a file is done. .TP 5 Q This command is the same as .I q, except that no diagnostic results when no .I w has been given since the last buffer alteration. .TP 5 ($)\|r filename The read command reads in the given file after the addressed line. If no file name is given, the remembered file name, if any, is used (see .I e and .I f commands)\|. The file name is remembered if there was no remembered file name already. Address `0' is legal for .I r and causes the file to be read at the beginning of the buffer. If the read is successful, the number of characters read is typed. `\fB.\fR' is left at the last line read in from the file. .TP 5 (\| \fB.\fR\|, \fB.\fR\|)\|s/regular expression/replacement/ or, .br .ns .TP 5 (\| \fB.\fR\|, \fB.\fR\|)\|s/regular expression/replacement/g The substitute command searches each addressed line for an occurrence of the specified regular expression. On each line in which a match is found, all matched strings are replaced by the replacement specified, if the global replacement indicator `g' appears after the command. If the global indicator does not appear, only the first occurrence of the matched string is replaced. It is an error for the substitution to fail on all addressed lines. Any punctuation character may be used instead of `/' to delimit the regular expression and the replacement. `\fB.\fR' is left at the last line substituted. .IP An ampersand `&' appearing in the replacement is replaced by the string matching the regular expression. The special meaning of `&' in this context may be suppressed by preceding it by `\e'. The characters .I `\|\en' where .I n is a digit, are replaced by the text matched by the .IR n -th regular subexpression enclosed between `\e(' and `\e)'. When nested, parenthesized subexpressions are present, .I n is determined by counting occurrences of `\e(' starting from the left. .IP Lines may be split by substituting new-line characters into them. The new-line in the replacement string must be escaped by preceding it by `\e'. .IP One or two trailing delimiters may be omitted, implying the `p' suffix. The special form `s' followed by .I no delimiters repeats the most recent substitute command on the addressed lines. The `s' may be followed by the letters .B r (use the most recent regular expression for the left hand side, instead of the most recent left hand side of a substitute command), .B p (complement the setting of the .I p suffix from the previous substitution), or .B g (complement the setting of the .I g suffix). These letters may be combined in any order. .TP 5 .RB (\| .\| ,\ .\| )\|t\|\fIa This command acts just like the .I m command, except that a copy of the addressed lines is placed after address .I a (which may be 0). `\fB.\fR' is left on the last line of the copy. .TP 5 .RB (\| .\| ,\ .\| )\|u The undo command restores the buffer to it's state before the most recent buffer modifying command. The current line is also restored. Buffer modifying commands are .I a, c, d, g, i, k, m, r, s, t, and .I v. For purposes of undo, .I g and .I v are considered to be a single buffer modifying command. Undo is its own inverse. .IP When .I ed runs out of memory (at about 8000 lines on any 16 bit mini-computer such as the PDP-11) This full undo is not possible, and .I u can only undo the effect of the most recent substitute on the current line. This restricted undo also applies to editor scripts when .I ed is invoked with the .B - option. .TP 5 (1, $)\|v/regular expression/command list This command is the same as the global command .I g except that the command list is executed .I g with `\fB.\fR' initially set to every line .I except those matching the regular expression. .TP 5 (1, $)\|w filename .br The write command writes the addressed lines onto the given file. If the file does not exist, it is created. The file name is remembered if there was no remembered file name already. If no file name is given, the remembered file name, if any, is used (see .I e and .I f commands)\|. `\fB.\fR' is unchanged. If the command is successful, the number of characters written is printed. .TP (1, $)\|W filename This command is the same as .I w, except that the addressed lines are appended to the file. .TP 5 (1, $)\|wq filename This command is the same as .I w except that afterwards a .I q command is done, exiting the editor after the file is written. .TP 5 .RB (\| .\| +1)\|z or, .br .ns .TP 5 .RB (\| .\| +1)\|z\fIn This command scrolls through the buffer starting at the addressed line. 22 (or .I n, if given) lines are printed. The last line printed becomes the current line. The value .I n is sticky, in that it becomes the default for future .I z commands. .TP 5 ($)\|= The line number of the addressed line is typed. `\fB.\fR' is unchanged by this command. .TP 5 ! The remainder of the line after the `!' is sent to .IR sh (1) to be interpreted as a command. .RB ` . ' is unchanged. .TP 5 .RB (\| . +1,\| . +1)\| An address alone on a line causes the addressed line to be printed. A blank line alone is equivalent to `.+1p'; it is useful for stepping through text. If two addresses are present with no intervening semicolon, .I ed prints the range of lines. If they are separated by a semicolon, the second line is printed. .PP If an interrupt signal (ASCII DEL)\| is sent, .I ed prints `?interrupted' and returns to its command level. .PP Some size limitations: 512 characters per line, 256 characters per global command list, 64 characters per file name, and, on mini computers, 128K characters in the temporary file. The limit on the number of lines depends on the amount of core: each line takes 2 words. .PP When reading a file, .I ed discards ASCII NUL characters and all characters after the last newline. It refuses to read files containing non-ASCII characters. .SH FILES /tmp/e* .br edhup: work is saved here if terminal hangs up .SH "SEE ALSO" B. W. Kernighan, .I A Tutorial Introduction to the ED Text Editor .br B. W. Kernighan, .I Advanced editing on UNIX .br ex(1), sed(1), crypt(1) .SH DIAGNOSTICS `?name' for inaccessible file; `?self-explanatory message' for other errors. .PP To protect against throwing away valuable work, a .I q or .I e command is considered to be in error, unless a .I w has occurred since the last buffer change. A second .I q or .I e will be obeyed regardless. .SH BUGS The .I l command mishandles DEL. .br The .I undo command causes marks to be lost on affected lines. ================================================ FILE: share/man/man1/efl.1 ================================================ .\" @(#)efl.1 6.1 (Berkeley) 4/29/85 .\" .TH EFL 1 "April 29, 1985" .AT 3 .SH NAME efl \- Extended Fortran Language .SH SYNOPSIS .B efl [ option ... ] [ filename ... ] .SH DESCRIPTION .I Efl compiles a program written in the EFL language into clean Fortran. .I Efl provides the same control flow constructs as does .IR ratfor (1), which are essentially identical to those in C: .TP statement grouping with braces; decision-making with if, if-else, and switch-case; while, for, Fortran do, repeat, and repeat...until loops; multi-level break and next. In addition, EFL has C-like data structures, and more uniform and convenient input/output syntax, generic functions. EFL also provides some syntactic sugar to make programs easier to read and write: .TP free form input: multiple statements/line; automatic continuation statement label names (not just numbers), .TP comments: # this is a comment .TP translation of relationals: >, >=, etc., become .GT., .GE., etc. .TP return (expression) returns expression to caller from function .TP define: define name replacement .TP include: include filename .PP .fi The Efl command option .B \-w suppresses warning messages. The option .B \-C causes comments to be copied through to the Fortran output (default); .B \-# prevents comments from being copied through. If a command argument contains an embedded equal sign, that argument is treated as if it had appeared in an .B option statement at the beginning of the program. .I Efl is best used with .IR f77 (1). .SH "SEE ALSO" f77(1), ratfor(1). .br S. I. Feldman, .IR "The Programming Language EFL", Bell Labs Computing Science Technical Report #78. ================================================ FILE: share/man/man1/eqn.1 ================================================ .\" @(#)eqn.1 6.2 (Berkeley) 5/9/86 .\" .TH EQN 1 "May 9, 1986" .AT 3 .EQ delim $$ .EN .SH NAME eqn, neqn, checkeq \- typeset mathematics .SH SYNOPSIS .B eqn [ .BR \-d xy ] [ .BR \-p n ] [ .BR \-s n ] [ .BR \-f n ] [ file ] ... .br .B checkeq [ file ] ... .SH DESCRIPTION .I Eqn is a troff(1) preprocessor for typesetting mathematics on a Graphic Systems phototypesetter, .I neqn on terminals. Usage is almost always .PP eqn file ... | troff .br neqn file ... | nroff .PP If no files are specified, these programs read from the standard input. A line beginning with `.EQ' marks the start of an equation; the end of an equation is marked by a line beginning with `.EN'. Neither of these lines is altered, so they may be defined in macro packages to get centering, numbering, etc. It is also possible to set two characters as `delimiters'; subsequent text between delimiters is also treated as .ul eqn input. Delimiters may be set to characters .I x and .I y with the command-line argument .BI \-d xy or (more commonly) with `delim .IR xy ' between .EQ and .EN. The left and right delimiters may be identical. Delimiters are turned off by `delim off'. All text that is neither between delimiters nor between .EQ and .EN is passed through untouched. .PP The program .I checkeq reports missing or unbalanced delimiters and .EQ/.EN pairs. .PP Tokens within .I eqn are separated by spaces, tabs, newlines, braces, double quotes, tildes or circumflexes. Braces {} are used for grouping; generally speaking, anywhere a single character like .I x could appear, a complicated construction enclosed in braces may be used instead. Tilde ~ represents a full space in the output, circumflex ^ half as much. .PP .vs 13p Subscripts and superscripts are produced with the keywords .B sub and .B sup. Thus .I "x sub i" makes $x sub i$, .I "a sub i sup 2" produces $a sub i sup 2$, and .I "e sup {x sup 2 + y sup 2}" gives $e sup {x sup 2 + y sup 2}$. .PP Fractions are made with .BR over : .I "a over b" yields $a over b$. .PP .B sqrt makes square roots: .I "1 over sqrt {ax sup 2 +bx+c}" results in $1 over sqrt {ax sup 2 +bx+c}$ . .PP The keywords .B from and .B to introduce lower and upper limits on arbitrary things: $lim from {n-> inf} sum from 0 to n x sub i$ is made with .I "lim from {n\-> inf } sum from 0 to n x sub i." .PP Left and right brackets, braces, etc., of the right height are made with .B left and .B right: .I "left [ x sup 2 + y sup 2 over alpha right ] ~=~1" produces $left [ x sup 2 + y sup 2 over alpha right ] ~=~1$. The .B right clause is optional. Legal characters after .B left and .B right are braces, brackets, bars, .B c and .B f for ceiling and floor, and "" for nothing at all (useful for a right-side-only bracket). .PP Vertical piles of things are made with .BR pile , .BR lpile , .BR cpile , and .BR rpile : .I "pile {a above b above c}" produces $pile {a above b above c}$. There can be an arbitrary number of elements in a pile. .B lpile left-justifies, .B pile and .B cpile center, with different vertical spacing, and .B rpile right justifies. .PP Matrices are made with .BR matrix : .I "matrix { lcol { x sub i above y sub 2 } ccol { 1 above 2 } }" produces $matrix { lcol { x sub i above y sub 2 } ccol { 1 above 2 } }$. In addition, there is .B rcol for a right-justified column. .PP .vs 12p Diacritical marks are made with .BR dot , .BR dotdot , .BR hat , .BR tilde , .BR bar , .BR vec , .BR dyad , and .BR under : .I "x dot = f(t) bar" is $x dot = f(t) bar$, .I "y dotdot bar ~=~ n under" is $y dotdot bar ~=~ n under$, and .I "x vec ~=~ y dyad" is $x vec ~=~ y dyad$. .PP Sizes and font can be changed with .B size .I n or .B size .BI \(+- n, .BR roman , .BR italic , .BR bold , and .BR font .I n. Size and fonts can be changed globally in a document by .B gsize .I n and .B gfont .IR n , or by the command-line arguments .BI \-s n and .BI \-f n. .PP Normally subscripts and superscripts are reduced by 3 point sizes from the previous size; this may be changed by the command-line argument .BI \-p n. .PP Successive display arguments can be lined up. Place .B mark before the desired lineup point in the first equation; place .B lineup at the place that is to line up vertically in subsequent equations. .PP Shorthands may be defined or existing keywords redefined with .BI define : .I "define thing % replacement %" defines a new token called .I thing which will be replaced by .I replacement whenever it appears thereafter. The .I % may be any character that does not occur in .I replacement. .PP Keywords like .I sum .EQ ( sum ) .EN .I int .EQ ( int ) .EN .I inf .EQ ( inf ) .EN and shorthands like >= .EQ (>=) .EN \-> .EQ (->), .EN and != .EQ ( != ) .EN are recognized. Greek letters are spelled out in the desired case, as in .I alpha or .I GAMMA. Mathematical words like sin, cos, log are made Roman automatically. .IR Troff (1) four-character escapes like \e(bs (\(bs) can be used anywhere. Strings enclosed in double quotes "..." are passed through untouched; this permits keywords to be entered as text, and can be used to communicate with .I troff when all else fails. .SH "SEE ALSO" .PP troff(1), tbl(1), ms(7), eqnchar(7) .br B. W. Kernighan and L. L. Cherry, .ul Typesetting Mathematics\(emUser's Guide .br J. F. Ossanna, .ul NROFF/TROFF User's Manual .SH BUGS .PP To embolden digits, parens, etc., it is necessary to quote them, as in `bold "12.3"'. ================================================ FILE: share/man/man1/error.1 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)error.1 6.2.1 (2.11BSD) 1996/10/21 .\" .TH ERROR 1 "October 21, 1996" .UC 4 .SH NAME error \- analyze and disperse compiler error messages .SH SYNOPSIS .B error [ .B \-n ] [ .B \-s ] [ .B \-q ] [ .B \-v ] [ .B \-t suffixlist ] [ .B \-I ignorefile ] [ name ] .SH DESCRIPTION .I Error analyzes and optionally disperses the diagnostic error messages produced by a number of compilers and language processors to the source file and line where the errors occurred. It can replace the painful, traditional methods of scribbling abbreviations of errors on paper, and permits error messages and source code to be viewed simultaneously without machinations of multiple windows in a screen editor. .PP .I Error looks at the error messages, either from the specified file \fIname\fR or from the standard input, and attempts to determine which language processor produced each error message, determines the source file and line number to which the error message refers, determines if the error message is to be ignored or not, and inserts the (possibly slightly modified) error message into the source file as a comment on the line preceding to which the line the error message refers. Error messages which can't be categorized by language processor or content are not inserted into any file, but are sent to the standard output. .I Error touches source files only after all input has been read. By specifying the .B \-q query option, the user is asked to confirm any potentially dangerous (such as touching a file) or verbose action. Otherwise .I error proceeds on its merry business. If the .B \-t touch option and associated suffix list is given, .I error will restrict itself to touch only those files with suffices in the suffix list. Error also can be asked (by specifying .B \-v) to invoke .IR vi (1) on the files in which error messages were inserted; this obviates the need to remember the names of the files with errors. .PP .I Error is intended to be run with its standard input connected via a pipe to the error message source. Some language processors put error messages on their standard error file; others put their messages on the standard output. Hence, both error sources should be piped together into .I error. For example, when using the \fIcsh\fP syntax, .IP make \-s lint |\|& error \-q \-v .LP will analyze all the error messages produced by whatever programs .I make runs when making lint. .PP .I Error knows about the error messages produced by: .I make, .I cc, .I cpp, .I ccom, .I as, .I ld, .I lint, .I pi, .I pc, .I f77, and .I DEC Western Research Modula-2. .I Error knows a standard format for error messages produced by the language processors, so is sensitive to changes in these formats. For all languages except .I Pascal, error messages are restricted to be on one line. Some error messages refer to more than one line in more than one files; .I error will duplicate the error message and insert it at all of the places referenced. .PP .I Error will do one of six things with error messages. .TP 10 .I synchronize Some language processors produce short errors describing which file it is processing. .I Error uses these to determine the file name for languages that don't include the file name in each error message. These synchronization messages are consumed entirely by .I error. .TP 10 .I discard Error messages from .I lint that refer to one of the two .I lint libraries, .I /usr/share/lint/llib-lc and .I /usr/share/lint/llib-port are discarded, to prevent accidently touching these libraries. Again, these error messages are consumed entirely by .I error. .TP 10 .I nullify Error messages from .I lint can be nullified if they refer to a specific function, which is known to generate diagnostics which are not interesting. Nullified error messages are not inserted into the source file, but are written to the standard output. The names of functions to ignore are taken from either the file named .I .errorrc in the users's home directory, or from the file named by the .B \-I option. If the file does not exist, no error messages are nullified. If the file does exist, there must be one function name per line. .TP 10 .I not file specific Error messages that can't be intuited are grouped together, and written to the standard output before any files are touched. They will not be inserted into any source file. .TP 10 .I file specific Error message that refer to a specific file, but to no specific line, are written to the standard output when that file is touched. .TP 10 .I true errors Error messages that can be intuited are candidates for insertion into the file to which they refer. .PP Only true error messages are candidates for inserting into the file they refer to. Other error messages are consumed entirely by .I error or are written to the standard output. .I Error inserts the error messages into the source file on the line preceding the line the language processor found in error. Each error message is turned into a one line comment for the language, and is internally flagged with the string ``###'' at the beginning of the error, and ``%%%'' at the end of the error. This makes pattern searching for errors easier with an editor, and allows the messages to be easily removed. In addition, each error message contains the source line number for the line the message refers to. A reasonably formatted source program can be recompiled with the error messages still in it, without having the error messages themselves cause future errors. For poorly formatted source programs in free format languages, such as C or Pascal, it is possible to insert a comment into another comment, which can wreak havoc with a future compilation. To avoid this, programs with comments and source on the same line should be formatted so that language statements appear before comments. .PP Options available with .I error are: .TP 5 .B \-n Do .I not touch any files; all error messages are sent to the standard output. .TP 5 .B \-q The user is .I queried whether s/he wants to touch the file. A ``y'' or ``n'' to the question is necessary to continue. Absence of the .B \-q option implies that all referenced files (except those referring to discarded error messages) are to be touched. .TP 5 .B \-v After all files have been touched, overlay the visual editor .I vi with it set up to edit all files touched, and positioned in the first touched file at the first error. If .I vi can't be found, try .I ex or .I ed from standard places. .TP 5 .B \-t Take the following argument as a suffix list. Files whose suffixes do not appear in the suffix list are not touched. The suffix list is dot separated, and ``*'' wildcards work. Thus the suffix list: .IP \& ".c.y.foo*.h" .IP allows .I error to touch files ending with ``.c'', ``.y'', ``.foo*'' and ``.y''. .TP 5 .B \-s Print out .I statistics regarding the error categorization. Not too useful. .PP .I Error catches interrupt and terminate signals, and if in the insertion phase, will orderly terminate what it is doing. .SH AUTHOR Robert Henry .SH FILES .ta 2i ~/.errorrc function names to ignore for \fIlint\fP error messages .br /dev/tty user's teletype .SH BUGS .PP Opens the teletype directly to do user querying. .PP Source files with links make a new copy of the file with only one link to it. .PP Changing a language processor's format of error messages may cause .I error to not understand the error message. .PP .I Error, since it is purely mechanical, will not filter out subsequent errors caused by `floodgating' initiated by one syntactically trivial error. Humans are still much better at discarding these related errors. .PP Pascal error messages belong after the lines affected (error puts them before). The alignment of the `\||\|' marking the point of error is also disturbed by .I error. .PP .I Error was designed for work on CRT's at reasonably high speed. It is less pleasant on slow speed terminals, and has never been used on hardcopy terminals. ================================================ FILE: share/man/man1/ex.1 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)ex.1 6.4.1 (2.11BSD) 1996/10/21 .\" .TH EX 1 "October 21, 1996" .UC 4 .SH NAME ex, edit \- text editor .SH SYNOPSIS .B ex [ .B \- ] [ .B \-v ] [ .B \-t tag ] [ .B \-r ] [ \fB+\fIcommand\fR ] [ .B \-l ] name ... .br .B edit [ ex options ] .SH DESCRIPTION .I Ex is the root of a family of editors: .I edit, .I ex and .I vi. .I Ex is a superset of .I ed, with the most notable extension being a display editing facility. Display based editing is the focus of .I vi. .PP If you have not used .I ed, or are a casual user, you will find that the editor .I edit is convenient for you. It avoids some of the complexities of .I ex used mostly by systems programmers and persons very familiar with .I ed. .PP If you have a \s-2CRT\s0 terminal, you may wish to use a display based editor; in this case see .IR vi (1), which is a command which focuses on the display editing portion of .I ex. .SH DOCUMENTATION The document .I "Edit: A tutorial" (USD:14) provides a comprehensive introduction to .I edit assuming no previous knowledge of computers or the \s-2UNIX\s0 system. .PP The .I "Ex Reference Manual \- Version 3.7" (USD:16) is a comprehensive and complete manual for the command mode features of .I ex, but you cannot learn to use the editor by reading it. For an introduction to more advanced forms of editing using the command mode of .I ex see the editing documents written by Brian Kernighan for the editor .I ed; the material in the introductory and advanced documents works also with .I ex. .PP .I "An Introduction to Display Editing with Vi" (USD:15) introduces the display editor .I vi and provides reference material on .I vi. In addition, the .I "Vi Quick Reference" card summarizes the commands of .I vi in a useful, functional way, and is useful with the .I Introduction. .SH FILES .DT /usr/share/misc/exstrings error messages .br /usr/libexec/exrecover recover command .br /usr/sbin/expreserve preserve command .br /etc/termcap describes capabilities of terminals .br ~/.exrc editor startup file .br /tmp/Ex\fInnnnn\fR editor temporary .br /tmp/Rx\fInnnnn\fR named buffer temporary .br /usr/preserve preservation directory .SH SEE ALSO awk(1), ed(1), grep(1), sed(1), grep(1), vi(1), termcap(5), environ(7) .SH AUTHOR Originally written by William Joy .br Mark Horton has maintained the editor since version 2.7, adding macros, support for many unusual terminals, and other features such as word abbreviation mode. .SH BUGS The .I undo command causes all marks to be lost on lines changed and then restored if the marked lines were changed. .PP .I Undo never clears the buffer modified condition. .PP The .I z command prints a number of logical rather than physical lines. More than a screen full of output may result if long lines are present. .PP File input/output errors don't print a name if the command line \fB`\-'\fR option is used. .PP There is no easy way to do a single scan ignoring case. .PP The editor does not warn if text is placed in named buffers and not used before exiting the editor. .PP Null characters are discarded in input files, and cannot appear in resultant files. ================================================ FILE: share/man/man1/expand.1 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)expand.1 6.2 (Berkeley) 5/9/86 .\" .TH EXPAND 1 "May 9, 1986" .UC 4 .SH NAME expand, unexpand \- expand tabs to spaces, and vice versa .SH SYNOPSIS .B expand [ \-tabstop ] [ \-tab1,tab2,...,tabn ] [ file ... ] .br .B unexpand [ .B \-a ] [ file ... ] .SH DESCRIPTION .I Expand processes the named files or the standard input writing the standard output with tabs changed into blanks. Backspace characters are preserved into the output and decrement the column count for tab calculations. .I Expand is useful for pre-processing character files (before sorting, looking at specific columns, etc.) that contain tabs. .PP If a single .I tabstop argument is given, then tabs are set .I tabstop spaces apart instead of the default 8. If multiple tabstops are given then the tabs are set at those specific columns. .PP .I Unexpand puts tabs back into the data from the standard input or the named files and writes the result on the standard output. By default, only leading blanks and tabs are reconverted to maximal strings of tabs. If the .B \-a option is given, then tabs are inserted whenever they would compress the resultant file by replacing two or more characters. ================================================ FILE: share/man/man1/expr.1 ================================================ .\" @(#)expr.1 6.1 (Berkeley) 4/29/85 .\" .TH EXPR 1 "April 29, 1985" .AT 3 .SH NAME expr \- evaluate arguments as an expression .SH SYNOPSIS .B expr arg .B .\|.\|. .SH DESCRIPTION The arguments are taken as an expression. After evaluation, the result is written on the standard output. Each token of the expression is a separate argument. .PP The operators and keywords are listed below. The list is in order of increasing precedence, with equal precedence operators grouped. .TP .I expr | expr yields the first .I expr if it is neither null nor `0', otherwise yields the second .I expr. .TP .I expr & expr yields the first .I expr if neither .I expr is null or `0', otherwise yields `0'. .TP .I expr relop expr where .I relop is one of < <= = != >= >, yields `1' if the indicated comparison is true, `0' if false. The comparison is numeric if both .I expr are integers, otherwise lexicographic. .TP .IR expr " + " expr .br .ns .TP .IR expr " \- " expr .br addition or subtraction of the arguments. .TP .IR expr " * " expr .br .ns .TP .IR expr " / " expr .br .ns .TP .IR expr " % " expr .br multiplication, division, or remainder of the arguments. .TP .IR expr " : " expr The matching operator compares the string first argument with the regular expression second argument; regular expression syntax is the same as that of .IR ed (1). The \fB\\(\|.\|.\|.\|\\)\fP pattern symbols can be used to select a portion of the first argument. Otherwise, the matching operator yields the number of characters matched (`0' on failure). .TP .RI ( " expr " ) parentheses for grouping. .PP Examples: .PP To add 1 to the Shell variable .IR a : .IP a=\`expr $a + 1\` .PP To find the filename part (least significant part) of the pathname stored in variable .I a, which may or may not contain `/': .IP expr $a : \'.*/\e(\^.*\e)\' \'\^|\' $a .LP Note the quoted Shell metacharacters. .SH "SEE ALSO" sh(1), test(1) .SH DIAGNOSTICS .I Expr returns the following exit codes: .PP 0 if the expression is neither null nor `0', .br 1 if the expression is null or `0', .br 2 for invalid expressions. ================================================ FILE: share/man/man1/f77.1 ================================================ .TH F77 1 "October 22, 1996" .UC .SH NAME f77 \- Fortran77 compiler .SH SYNTAX .B f77 [ option ] ... file ... .SH DESCRIPTION .I F77 is the UNIX Fortran77 compiler. It accepts several types of arguments: .PP Arguments whose names end with `.f' are taken to be Fortran77 source programs; they are compiled, and each object program is left on the file in the current directory whose name is that of the source with `.o' substituted for '.f'. .PP Arguments whose names end with `.r' or `.e' are taken to be Ratfor or EFL source programs, respectively; these are first transformed by the appropriate preprocessor, then compiled by f77. .PP In the same way, arguments whose names end with `.c' or `.s' are taken to be C or assembly source programs and are compiled or assembled, producing a `.o' file. .PP The following options have the same meaning as in \fIcc\fP\|(1). See \fIld\fP\|(1) for load-time options. .TP .B \-\^c Suppress loading and produce `.o' files for each source file. .TP .B \-\^p Prepare object files for profiling, see \fIprof\fP\|(1) .TP .SM .B \-\^O Invoke an object-code optimizer. .TP .SM .B \-\^S Compile the named programs, and leave the assembler-language output on corresponding files suffixed `.s'. (No `.o' is created.). .TP .B \-\^f Use a floating point interpreter (for PDP11's that lack 11/70-style floating point). .TP .BR \-\^o " output" Name the final output file .I output instead of `a.out'. .PP The following options are peculiar to .IR f77 : .TP .SM .BR \-\^onetrip Compile DO loops that are performed at least once if reached. (Fortran77 DO loops are not performed at all if the upper limit is smaller than the lower limit.) .TP .BR \-\^u Make the default type of a variable `undefined' rather than using the default Fortran rules. .TP .BR \-\^C Compile code to check that subscripts are within declared array bounds. .TP .BR \-\^w Suppress all warning messages. If the option is `\-w66', only Fortran 66 compatibility warnings are suppressed. .TP .BR \-\^F Apply EFL and Ratfor preprocessor to relevant files, put the result in the file with the suffix changed to `.f', but do not compile. .TP .BR \-\^m Apply the M4 preprocessor to each `.r' or `.e' file before transforming it with the Ratfor or EFL preprocessor. .TP .TP .BI \-\^E x Use the string .I x as an EFL option in processing `.e' files. .TP .BI \-\^R x Use the string .I x as a Ratfor option in processing `.r' files. .TP .BR \-\^U Do not convert upper case letters to lower case. .TP .BR \-\^I 2 Make default integer size 16 bit. .TP .BR \-\^I 4 Make default integer size 32 bit (default). .TP .BR \-\^v Verbose. Print information showing what compiler is doing. .TP .BR \-\^d Debug prints out intermediate information, leaves temporary files in \fI/tmp\fP and often produces a core file. .PP Other arguments are taken to be either loader option arguments, or F77-compatible object programs, typically produced by an earlier run, or perhaps libraries of F77-compatible routines. These programs, together with the results of any compilations specified, are loaded (in the order given) to produce an executable program with name `a.out'. .SH FILES .nf .ta 2i file.[fresc] input file file.o object file a.out loaded output ./fort[pid].? temporary /usr/libexec/f77pass1 compiler pass 1 /lib/c1 compiler pass 2 /lib/c2 optional optimizer /usr/lib/libF77.a intrinsic function library /usr/lib/libI77.a Fortran I/O library /usr/lib/libU77.a Fortran system call library /lib/libc.a C library, see section 3 /temp/fortPID.[xsad SopzA] temporary files .fi .PP Different versions of the compiler tools may be used with the following flags followed immediately (no space) by the path name of the desired module: .PP .ta \w'\-TM1234567 'u +\w'macro pack12345 'u .nf \-T1 pass1 /lib/f77pass1 \-T2 pass2 /lib/c1 \-Ta assembler /bin/as \-Tl loader /bin/ld \-TF footname /lib/crt0.o \-TM macro pack m4 .fi .SH "SEE ALSO" S. I. Feldman, P. J. Weinberger, .I A Portable Fortran77 Compiler .br cc(1), ld(1), prof(1) .SH DIAGNOSTICS The diagnostics produced by .I f77 itself are intended to be self-explanatory. Occasional messages may be produced by the loader. .TP \-d causes the intermediate files to be saves in \fI/tmp\fP and causes the compiler to print out what it is doing. .PP Run-time diagnostics for the input/output library are as follows: .sp .nf /* 100 */ "error in format" See error message output for the location of the error in the format. Can be caused by more than 10 levels of nested (), or an extremely long format statement. .bp /* 101 */ "illegal unit number" It is illegal to close logical unit 0. Negative unit numbers are not allowed. The upper limit is system dependent. /* 102 */ "formatted io not allowed" The logical unit was opened for unformatted I/O. /* 103 */ "unformatted io not allowed" The logical unit was opened for formatted I/O. /* 104 */ "direct io not allowed" The logical unit was opened for sequential access, or the logical record length was specified as 0. /* 105 */ "sequential io not allowed" The logical unit was opened for direct access I/O. /* 106 */ "can't backspace file" The file associated with the logical unit can't seek. May be a device or a pipe. /* 107 */ "off beginning of record" The format specified a left tab off the beginning of the record. /* 108 */ "can't stat file" The system can't return status information about the file. Perhaps the directory is unreadable. /* 109 */ "no * after repeat count" Repeat counts in list-directed I/O must be followed by an * with no blank spaces. .DE .DS /* 110 */ "off end of record" A formatted write tried to go beyond the logical end-of-record. An unformatted read or write will also cause this. /* 111 */ "truncation failed" The truncation of external sequential files on 'close', 'backspace', or 'rewind' tries to do a copy. It failed. Perhaps the temp file couldn't be created. /* 112 */ "incomprehensible list input" List input has to be just right. /* 113 */ "out of free space" The library dynamically creates buffers for internal use. You ran out of memory for this. Your program is too big! /* 114 */ "unit not connected" The logical unit was not open. /* 115 */ "read unexpected character" Certain format conversions can't tolerate non-numeric data. Logical data must be T or F. /* 116 */ "blank logical input field" /* 117 */ "'new' file exists" You tried to open an existing file with "status='new'". /* 118 */ "can't find 'old' file" You tried to open a nonexistent file with "status='old'". /* 119 */ "unknown system error" Shouldn't happen, but ..... (Send me a documented example.) /* 120 */ "requires seek ability" Direct access requires seek ability. Sequential unformatted I/O requires seek ability on the file due to the special data structure required. Tabbing left also requires seek ability. /* 121 */ "illegal argument" Certain arguments to 'open', etc. will be checked for legitimacy. Often only non- default forms are looked for. /* 122 */ "negative repeat count" /* 123 */ "illegal operation for channel or device" .fi .SH BUGS The Fortran66 subset of the language has been exercised extensively; the newer features have not. .PP Fortran style read/write routines take up 23 Kbytes of addressing space. .PP The compiler is not intelligent enough to know when to split up assemblies and loads. Occasionally this causes the loader \fIld\fP\|(1) to produce the informative \fBlocal symbol botch\fP error message when local symbols like argument names are defined with different types. Thus one must split up such offensive modules into separate compilations. .PP All mathematics for reals is done in double precision. .br Integer*4 byte alignment is unlike DEC and everyone else's. .br There is no symbolic debugger. .PP The optimizer should be used with caution. It is known to occasionally produce incorrect code. .SH EXAMPLES .TP \fBf77 \-O \-c myprog.f\fP creates myprog.o using C optimizer .TP \fBf77 \-i \-O myprog.f another.f anon.o \-lplot\fP compiles .f files, loads all files using separate i&d space and linking in routines in the plot library. .TP \fBf77 myprog.f mine.c >&errors\fP Compiles and loads both files putting error output into file called errors. This is the C shell (\fBcsh\fP) version. The Bourne shell (\fBsh\fP) version is: .LP \fBf77 myprog.f mine.c 2>errors 1>errors\fP ================================================ FILE: share/man/man1/false.1 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)false.1 6.1 (Berkeley) 4/29/85 .\" .TH FALSE 1 "April 29, 1985" .UC 5 .SH NAME false, true \- provide truth values .SH SYNOPSIS .B true .PP .B false .SH DESCRIPTION .I True and .I false are usually used in a Bourne shell script. They test for the appropriate status "true" or "false" before running (or failing to run) a list of commands. .SH EXAMPLE .IP .nf while false do command list done .SH "SEE ALSO" csh(1), sh(1), true(1) .SH DIAGNOSTICS .I False has exit status nonzero. ================================================ FILE: share/man/man1/file.1 ================================================ .\" @(#)file.1 6.1 (Berkeley) 4/29/85 .\" .TH FILE 1 "April 29, 1985" .AT 3 .SH NAME file \- determine file type .SH SYNOPSIS .B file file ... .SH DESCRIPTION .I File performs a series of tests on each argument in an attempt to classify it. If an argument appears to be ascii, .I file examines the first 512 bytes and tries to guess its language. .SH BUGS It often makes mistakes. In particular it often suggests that command files are C programs. .PP Does not recognize Pascal or LISP. ================================================ FILE: share/man/man1/find.1 ================================================ .\" Copyright (c) 1985 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)find.1 6.3.1 (2.11BSD) 1996/10/22 .\" .TH FIND 1 "October 11, 1996" .AT 3 .SH NAME find \- find files .SH SYNOPSIS .B find pathname-list expression .br .B find pattern .SH DESCRIPTION In the first form above, .I find recursively descends the directory hierarchy for each pathname in the .I pathname-list (i.e., one or more pathnames) seeking files that match a boolean .I expression written in the primaries given below. In the descriptions, the argument .I n is used as a decimal integer where .I +n means more than .I n, .I \-n means less than .I n and .I n means exactly .IR n . .PP The second form rapidly searches a database for all pathnames which match .IR pattern . Usually the database is recomputed weekly and contains the pathnames of all files which are publicly accessible. If escaped, normal shell \*(lqglobbing\*(rq characters (`*', `?', `[', and ']') may be used in .IR pattern , but the matching differs in that no characters .RI ( e.g. " `/')" have to be matched explicitly. As a special case, a simple .I pattern containing no globbing characters is matched as though it were .IR *pattern* ; if any globbing character appears there are no implicit globbing characters. .TP 10n .BR \-name " filename" True if the .I filename argument matches the current file name. Normal shell argument syntax may be used if escaped (watch out for `[', `?' and `*'). .TP .BR \-perm " onum" True if the file permission flags exactly match the octal number .I onum (see .IR chmod (1)). If .I onum is prefixed by a minus sign, more flag bits (017777, see .IR stat (2)) become significant and the flags are compared: .IR (flags&onum)==onum . .TP .BR \-type " c" True if the type of the file is .I c, where .I c is .B "b, c, d, f, l" or .B s for block special file, character special file, directory, plain file, symbolic link, or socket. .TP .BR \-links " n" True if the file has .I n links. .TP .BR \-user " uname" True if the file belongs to the user .I uname (login name or numeric user ID). .TP .B \-nouser True if the file belongs to a user .I not in the /etc/passwd database. .TP .BR \-group " gname" True if the file belongs to group .I gname (group name or numeric group ID). .TP .B \-nogroup True if the file belongs to a group .I not in the /etc/group database. .TP .BR \-size " n" True if the file is .I n blocks long (512 bytes per block). .TP .BR \-inum " n" True if the file has inode number .I n. .TP .BR \-atime " n" True if the file has been accessed in .I n days. .TP .BR \-mtime " n" True if the file has been modified in .I n days. .TP .BR \-exec " command" True if the executed command returns a zero value as exit status. The end of the command must be punctuated by an escaped semicolon. A command argument `{}' is replaced by the current pathname. .TP .BR \-ok " command" Like .B \-exec except that the generated command is written on the standard output, then the standard input is read and the command executed only upon response .BR y . .TP .B \-print Always true; causes the current pathname to be printed. .TP .B \-ls Always true; causes current pathname to be printed together with its associated statistics. These include (respectively) inode number, size in kilobytes (1024 bytes), protection mode, number of hard links, user, group, size in bytes, and modification time. If the file is a special file the size field will instead contain the major and minor device numbers. If the file is a symbolic link the pathname of the linked-to file is printed preceded by ``->''. The format is identical to that of ``ls -gilds'' (note however that formatting is done internally, without executing the ls program). .TP .BR \-newer " file" True if the current file has been modified more recently than the argument .I file. .TP .BR \-cpio " file" Write the current file on the argument .I file in .I cpio format. .TP .B \-xdev Always true; causes find .I not to traverse down into a file system different from the one on which current .I argument pathname resides. .PP The primaries may be combined using the following operators (in order of decreasing precedence): .TP 4 1) A parenthesized group of primaries and operators (parentheses are special to the Shell and must be escaped). .TP 4 2) The negation of a primary (`!' is the unary .I not operator). .TP 4 3) Concatenation of primaries (the .I and operation is implied by the juxtaposition of two primaries). .TP 4 4) Alternation of primaries .RB "(`" \-o "' is the" .I or operator). .SH EXAMPLES .PP To find all accessible files whose pathname contains `find': .IP find find .PP To typeset all variants of manual pages for `ls': .IP vtroff -man `find '*man*/ls.?'` .PP To remove all files named `a.out' or `*.o' that have not been accessed for a week: .IP "" .2i find / \e( \-name a.out \-o \-name '*.o' \e) \-atime +7 \-exec rm {} \e\; .SH FILES .nf .ta \w'/var/db/find.codes 'u /etc/passwd /etc/group /var/db/find.codes coded pathnames database .fi .SH "SEE ALSO" sh(1), test(1), fs(5) .br Relevant paper in February, 1983 issue of .I ;login:. .SH BUGS The first form's syntax is painful, and the second form's exact semantics is confusing and can vary from site to site. .PP More than one `-newer' option does not work properly. ================================================ FILE: share/man/man1/fmt.1 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)fmt.1 6.1 (Berkeley) 4/29/85 .\" .TH FMT 1 "April 29, 1985" .UC .SH NAME fmt \- simple text formatter .SH SYNOPSIS .B fmt [ name ... ] .SH DESCRIPTION .I Fmt is a simple text formatter which reads the concatenation of input files (or standard input if none are given) and produces on standard output a version of its input with lines as close to 72 characters long as possible. The spacing at the beginning of the input lines is preserved in the output, as are blank lines and interword spacing. .PP .I Fmt is meant to format mail messages prior to sending, but may also be useful for other simple tasks. For instance, within visual mode of the .I ex editor (e.g. .IR vi ) the command .br !}fmt .br will reformat a paragraph, evening the lines. .SH "SEE ALSO" nroff(1), mail(1) .SH AUTHOR Kurt Shoens .SH BUGS The program was designed to be simple and fast \- for more complex operations, the standard text processors are likely to be more appropriate. ================================================ FILE: share/man/man1/fold.1 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)fold.1 6.1 (Berkeley) 4/29/85 .\" .TH FOLD 1 "April 29, 1985" .UC .SH NAME fold \- fold long lines for finite width output device .SH SYNOPSIS .B fold [ \-width ] [ file ... ] .SH DESCRIPTION .I Fold is a filter which will fold the contents of the specified files, or the standard input if no files are specified, breaking the lines to have maximum width .I width. The default for .I width is 80. .I Width should be a multiple of 8 if tabs are present, or the tabs should be expanded using .IR expand (1) before coming to .I fold. .SH SEE\ ALSO expand(1) .SH BUGS If underlining is present it may be messed up by folding. ================================================ FILE: share/man/man1/fpr.1 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)fpr.1 6.2 (Berkeley) 5/7/86 .\" .TH FPR 1 "May 7, 1986" .UC 5 .ds f. fpr.tbl .SH NAME fpr \- print Fortran file .SH SYNOPSIS .B fpr .SH DESCRIPTION .I Fpr is a filter that transforms files formatted according to Fortran's carriage control conventions into files formatted according to UNIX line printer conventions. .PP .I Fpr copies its input onto its output, replacing the carriage control characters with characters that will produce the intended effects when printed using .IR lpr (1). The first character of each line determines the vertical spacing as follows: .if t \{\ .\" tbl input for vertical spacing table .\" .TS .\" center box; .\" c | l. .\" Character Vertical Space Before Printing .\" _ .\" Blank One line .\" 0 Two lines .\" 1 To first line of next page .\" + No advance .\" .TE .\" end of tbl input for vertical spacing table .\" tbl output for vertical spacing table .TS .if \n+(b.=1 .nr d. \n(.c-\n(c.-1 .de 35 .ps \n(.s .vs \n(.vu .in \n(.iu .if \n(.u .fi .if \n(.j .ad .if \n(.j=0 .na .. .nf .nr #~ 0 .if n .nr #~ 0.6n .ds #d .d .if \(ts\n(.z\(ts\(ts .ds #d nl .fc .nr 33 \n(.s .rm 80 81 .nr 80 0 .nr 38 \wCharacter .if \n(80<\n(38 .nr 80 \n(38 .nr 38 \wBlank .if \n(80<\n(38 .nr 80 \n(38 .nr 38 \w0 .if \n(80<\n(38 .nr 80 \n(38 .nr 38 \w1 .if \n(80<\n(38 .nr 80 \n(38 .nr 38 \w+ .if \n(80<\n(38 .nr 80 \n(38 .80 .rm 80 .nr 81 0 .nr 38 \wVertical Space Before Printing .if \n(81<\n(38 .nr 81 \n(38 .nr 38 \wOne line .if \n(81<\n(38 .nr 81 \n(38 .nr 38 \wTwo lines .if \n(81<\n(38 .nr 81 \n(38 .nr 38 \wTo first line of next page .if \n(81<\n(38 .nr 81 \n(38 .nr 38 \wNo advance .if \n(81<\n(38 .nr 81 \n(38 .81 .rm 81 .nr 38 1n .nr 79 0 .nr 40 \n(79+(1*\n(38) .nr 80 +\n(40 .nr 41 \n(80+(3*\n(38) .nr 81 +\n(41 .nr TW \n(81 .nr TW +1*\n(38 .if t .if (\n(TW+\n(.o)>7.65i .tm Table at line 45 file fpr.tbl is too wide - \n(TW units .ne 5v+2p .nr #I \n(.i .in +(\n(.lu-\n(TWu-\n(.iu)/2u .fc   .nr #T 0-1 .nr #a 0-1 .nr #a 0-1 .eo .de T# .ds #d .d .if \(ts\n(.z\(ts\(ts .ds #d nl .mk ## .nr ## -1v .ls 1 .if \n(#T>=0 .nr #a \n(#T .if \n(T. .vs \n(.vu-\n(.sp .if \n(T. \h'|0'\s\n(33\l'|\n(TWu\(ul'\s0 .if \n(T. .vs .if \n(#a>=0 .sp -1 .if \n(#a>=0 \h'|0'\s\n(33\h'-\n(#~u'\L'|\n(#au-1v'\s0\v'\n(\*(#du-\n(#au+1v'\h'|\n(TWu' .if \n(#a>=0 .sp -1 .if \n(#a>=0 \h'(|\n(41u+|\n(80u)/2u'\s\n(33\h'-\n(#~u'\L'|\n(#au-1v'\s0\v'\n(\*(#du-\n(#au+1v'\h'|\n(TWu' .if \n(#a>=0 .sp -1 .if \n(#a>=0 \h'|\n(TWu'\s\n(33\h'-\n(#~u'\L'|\n(#au-1v'\s0\v'\n(\*(#du-\n(#au+1v' .ls .. .ec .nr 36 \n(.v .vs \n(.vu-\n(.sp \h'|0'\s\n(33\l'|\n(TWu\(ul'\s0 .vs \n(36u .mk #a .ta \n(80u \n(81u .nr 31 \n(.f .nr 35 1m \&\h'|\n(40u'Character\h'|\n(41u'Vertical Space Before Printing .nr 36 \n(.v .vs \n(.vu-\n(.sp \h'|0'\s\n(33\l'|\n(TWu\(ul'\s0 .vs \n(36u .ta \n(80u \n(81u .nr 31 \n(.f .nr 35 1m \&\h'|\n(40u'Blank\h'|\n(41u'One line .ta \n(80u \n(81u .nr 31 \n(.f .nr 35 1m \&\h'|\n(40u'0\h'|\n(41u'Two lines .ta \n(80u \n(81u .nr 31 \n(.f .nr 35 1m \&\h'|\n(40u'1\h'|\n(41u'To first line of next page .ta \n(80u \n(81u .nr 31 \n(.f .nr 35 1m \&\h'|\n(40u'+\h'|\n(41u'No advance .fc .nr T. 1 .T# 1 .in \n(#Iu .35 .nr #a 0 .TE .if \n-(b.=0 .nr c. \n(.c-\n(d.-9 .\" end of tbl output for vertical spacing table .\} .if n \{\ .nf +---------------+--------------------------------+ | Character | Vertical Space Before Printing | |---------------+--------------------------------| | Blank | One line | | 0 | Two lines | | 1 | To first line of next page | | + | No advance | +---------------+--------------------------------+ .fi .\} .PP A blank line is treated as if its first character is a blank. A blank that appears as a carriage control character is deleted. A zero is changed to a newline. A one is changed to a form feed. The effects of a "+" are simulated using backspaces. .SH EXAMPLES a.out | fpr | lpr .PP fpr < f77.output | lpr .SH BUGS Results are undefined for input lines longer than 170 characters. ================================================ FILE: share/man/man1/from.1 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)from.1 6.2 (Berkeley) 4/20/86 .\" .TH FROM 1 "April 20, 1986" .UC 4 .SH NAME from \- who is my mail from? .SH SYNOPSIS .B from [ .B \-s sender ] [ user ] .SH DESCRIPTION .I From prints out the mail header lines in your mailbox file to show you who your mail is from. If .I user is specified, then \fIuser\fP's mailbox is examined instead of your own. If the -s option is given, then only headers for mail sent by .I sender are printed. .SH FILES /usr/spool/mail/* .SH "SEE ALSO" biff(1), mail(1) ================================================ FILE: share/man/man1/fsplit.1 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)fsplit.1 6.1 (Berkeley) 4/29/85 .\" .TH FSPLIT 1 "April 29, 1985" .UC 5 .SH NAME fsplit \- split a multi-routine Fortran file into individual files .SH SYNOPSIS .B fsplit [ .B -e efile] ... [ file ] .SH DESCRIPTION .B Fsplit takes as input either a file or standard input containing Fortran source code. It attempts to split the input into separate routine files of the form .I name.f, where .I name is the name of the program unit (e.g. function, subroutine, block data or program). The name for unnamed block data subprograms has the form .I blkdtaNNN.f where NNN is three digits and a file of this name does not already exist. For unnamed main programs the name has the form .I mainNNN.f. If there is an error in classifying a program unit, or if .I name.f already exists, the program unit will be put in a file of the form .I zzzNNN.f where .I zzzNNN.f does not already exist. .PP Normally each subprogram unit is split into a separate file. When the .I -e option is used, only the specified subprogram units are split into separate files. E.g.: .nf fsplit -e readit -e doit prog.f .fi will split readit and doit into separate files. .SH DIAGNOSTICS If names specified via the .I -e option are not found, a diagnostic is written to .I standard .I error. .SH AUTHOR Asa Romberger and Jerry Berkman .SH BUGS .I Fsplit assumes the subprogram name is on the first noncomment line of the subprogram unit. Nonstandard source formats may confuse .I fsplit. .PP It is hard to use .I -e for unnamed main programs and block data subprograms since you must predict the created file name. ================================================ FILE: share/man/man1/gcore.1 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)gcore.1 1.1 (2.11BSD GTE) 4/15/94 .\" .TH GCORE 1 "April 15, 1994" .UC 5 .SH NAME gcore \- get core image of running process .SH SYNOPSIS .B gcore [\fB-s\fP][\fB-c core\fP] \fIpid\fP .SH DESCRIPTION .I gcore creates a core image of each specified process, suitable for use with .IR adb (1). By default the core image is written to the file \fI.core\fP. .PP The options are: .TP \fB-c\fP Write the core file to the specified file instead of \fI.core\fP. .TP \fB-s\fP Stop the process while creating the core image and resume it when done. This makes sure that the core dump will be in a consistent state. The process is resumed even if it was already stopped. Of course, you can obtain the same result by manually stopping the process with kill(1). .PP The core image name was changed from \fIcore.\fP to \fI.core\fP to prevent matching names like \fIcore.h\fP and \fIcore.c\fP when using programs such as \fIfind(1)\fP. .SH FILES .core The core image. .SH BUGS If \fBgcore\fP encounters an error while creating the core image and the \fB-s\fP option was used the process will remain stopped. .PP Swapped out processes and system processes (the swapper) may not be gcore'd. ================================================ FILE: share/man/man1/graph.1 ================================================ .\" @(#)graph.1g 6.1 (Berkeley) 4/29/85 .\" .TH GRAPH 1G "April 29, 1985" .AT 3 .SH NAME graph \- draw a graph .SH SYNOPSIS .B graph [ option ] ... .SH DESCRIPTION .I Graph with no options takes pairs of numbers from the standard input as abscissas and ordinates of a graph. Successive points are connected by straight lines. The graph is encoded on the standard output for display by the .IR plot (1G) filters. .PP If the coordinates of a point are followed by a nonnumeric string, that string is printed as a label beginning on the point. Labels may be surrounded with quotes "...", in which case they may be empty or contain blanks and numbers; labels never contain newlines. .PP The following options are recognized, each as a separate argument. .TP .B \-a Supply abscissas automatically (they are missing from the input); spacing is given by the next argument (default 1). A second optional argument is the starting point for automatic abscissas (default 0 or lower limit given by .BR \-x ). .TP .B \-b Break (disconnect) the graph after each label in the input. .TP .B \-c Character string given by next argument is default label for each point. .TP .B \-g Next argument is grid style, 0 no grid, 1 frame with ticks, 2 full grid (default). .TP .B \-l Next argument is label for graph. .TP .B \-m Next argument is mode (style) of connecting lines: 0 disconnected, 1 connected (default). Some devices give distinguishable line styles for other small integers. .TP .B \-s Save screen, don't erase before plotting. .TP \fB\-x\fR [ \fBl\fR ] If .B l is present, x axis is logarithmic. Next 1 (or 2) arguments are lower (and upper) .IR x "" limits. Third argument, if present, is grid spacing on .I x axis. Normally these quantities are determined automatically. .TP \fB\-y\fR [ \fBl\fR ] Similarly for .IR y . .TP .B \-h Next argument is fraction of space for height. .TP .B \-w Similarly for width. .TP .B \-r Next argument is fraction of space to move right before plotting. .TP .B \-u Similarly to move up before plotting. .TP .B \-t Transpose horizontal and vertical axes. (Option .B \-x now applies to the vertical axis.) .PP A legend indicating grid range is produced with a grid unless the .B \-s option is present. .PP If a specified lower limit exceeds the upper limit, the axis is reversed. .SH "SEE ALSO" spline(1G), plot(1G) .SH BUGS .I Graph stores all points internally and drops those for which there isn't room. .br Segments that run out of bounds are dropped, not windowed. .br Logarithmic axes may not be reversed. ================================================ FILE: share/man/man1/grep.1 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)grep.1 6.1 (Berkeley) 4/29/85 .\" .TH GREP 1 "April 29, 1985" .UC 4 .SH NAME grep, egrep, fgrep \- search a file for a pattern .SH SYNOPSIS .B grep [ option ] ... expression [ file ] ... .LP .B egrep [ option ] ... [ expression ] [ file ] ... .LP .B fgrep [ option ] ... [ strings ] [ file ] .SH DESCRIPTION Commands of the .I grep family search the input .I files (standard input default) for lines matching a pattern. Normally, each line found is copied to the standard output. .I Grep patterns are limited regular expressions in the style of .IR ex (1); it uses a compact nondeterministic algorithm. .I Egrep patterns are full regular expressions; it uses a fast deterministic algorithm that sometimes needs exponential space. .I Fgrep patterns are fixed strings; it is fast and compact. The following options are recognized. .TP .B \-v All lines but those matching are printed. .TP .B \-x (Exact) only lines matched in their entirety are printed .RI ( fgrep only). .TP .B \-c Only a count of matching lines is printed. .TP .B \-l The names of files with matching lines are listed (once) separated by newlines. .TP .B \-n Each line is preceded by its relative line number in the file. .TP .B \-b Each line is preceded by the block number on which it was found. This is sometimes useful in locating disk block numbers by context. .TP .B \-i The case of letters is ignored in making comparisons \(em that is, upper and lower case are considered identical. This applies to \fIgrep\fR\| and \fIfgrep\fR only. .TP .B \-s Silent mode. Nothing is printed (except error messages). This is useful for checking the error status. .TP .B \-w The expression is searched for as a word (as if surrounded by `\e<' and `\e>', see .IR ex (1).) (\fIgrep\fR\| only) .TP .BI \-e " expression" Same as a simple .I expression argument, but useful when the .I expression begins with a \-. .TP .BI \-f " file" The regular expression .RI ( egrep ) or string list .RI ( fgrep ) is taken from the .I file. .LP In all cases the file name is shown if there is more than one input file. Care should be taken when using the characters $ * [ ^ | ( ) and \\ in the .I expression as they are also meaningful to the Shell. It is safest to enclose the entire .I expression argument in single quotes \' \'. .LP .I Fgrep searches for lines that contain one of the (newline-separated) .I strings. .LP .I Egrep accepts extended regular expressions. In the following description `character' excludes newline: .IP A \e followed by a single character other than newline matches that character. .IP The character ^ matches the beginning of a line. .IP The character $ matches the end of a line. .IP A .B . (period) matches any character. .IP A single character not otherwise endowed with special meaning matches that character. .IP A string enclosed in brackets [\|] matches any single character from the string. Ranges of ASCII character codes may be abbreviated as in `a\-z0\-9'. A ] may occur only as the first character of the string. A literal \- must be placed where it can't be mistaken as a range indicator. .IP A regular expression followed by an * (asterisk) matches a sequence of 0 or more matches of the regular expression. A regular expression followed by a + (plus) matches a sequence of 1 or more matches of the regular expression. A regular expression followed by a ? (question mark) matches a sequence of 0 or 1 matches of the regular expression. .IP Two regular expressions concatenated match a match of the first followed by a match of the second. .IP Two regular expressions separated by | or newline match either a match for the first or a match for the second. .IP A regular expression enclosed in parentheses matches a match for the regular expression. .LP The order of precedence of operators at the same parenthesis level is [\|] then *+? then concatenation then | and newline. .LP Ideally there should be only one .I grep, but we don't know a single algorithm that spans a wide enough range of space-time tradeoffs. .SH "SEE ALSO" ex(1), sed(1), sh(1) .SH DIAGNOSTICS Exit status is 0 if any matches are found, 1 if none, 2 for syntax errors or inaccessible files. .SH BUGS Lines are limited to 256 characters; longer lines are truncated. ================================================ FILE: share/man/man1/head.1 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)head.1 6.1 (Berkeley) 4/29/85 .\" .TH HEAD 1 "April 29, 1985" .UC .SH NAME head \- give first few lines .SH SYNOPSIS .B head [ .BR \- count ] [ file ... ] .SH DESCRIPTION This filter gives the first .I count lines of each of the specified files, or of the standard input. If .I count is omitted it defaults to 10. .SH SEE\ ALSO tail(1) ================================================ FILE: share/man/man1/hostid.1 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)hostid.1 6.2 (Berkeley) 5/5/86 .\" .TH HOSTID 1 "May 5, 1986" .UC 5 .SH NAME hostid \- set or print identifier of current host system .SH SYNOPSIS .B hostid [ identifier ] .SH DESCRIPTION The .I hostid command prints the identifier of the current host in hexadecimal. This numeric value is expected to be unique across all hosts and is commonly set to the host's Internet address. The super-user can set the hostid by giving a hexadecimal argument or the hostname; this is usually done in the startup script /etc/rc.local. .SH SEE ALSO gethostid(2), sethostid(2) ================================================ FILE: share/man/man1/indent.1 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)indent.1 6.4 (Berkeley) 9/10/85 .\" .TH INDENT 1 "September 10, 1985" .UC 5 .SH NAME indent \- indent and format C program source .SH SYNOPSIS .in +\w'\fBindent \fR'u .ti -\w'\fBindent \fR'u \fBindent \fR [ \fIinput-file\fR [ \fIoutput-file\fR ] ] [\ \fB\-bad\fR\ |\ \fB\-nbad\fR\ ] [\ \fB\-bap\fR\ |\ \fB\-nbap\fR\ ] [\ \fB\-bbb\fR\ |\ \fB\-nbbb\fR\ ] [\ \fB\-bc\fR\ |\ \fB\-nbc\fR\ ] [\ \fB\-bl\fR\ |\ \fB\-br\fR\ ] [\ \fB\-c\fIn\fR\ ] [\ \fB\-cd\fIn\fR\ ] [\ \fB\-cdb\fR\ |\ \fB\-ncdb\fR\ ] [\ \fB\-ce\fR\ |\ \fB\-nce\fR\ ] [\ \fB\-ci\fIn\fR\ ] [\ \fB\-cli\fIn\fR\ ] [\ \fB\-d\fIn\fR\ ] [\ \fB\-di\fIn\fR\ ] [\ \fB\-dj\fR\ |\ \fB\-ndj\fR\ ] [\ \fB\-ei\fR\ |\ \fB\-nei\fR\ ] [\ \fB\-fc1\fR\ |\ \fB\-nfc1\fR\ ] [\ \fB\-i\fIn\fR\ ] [\ \fB\-ip\fR\ |\ \fB\-nip\fR\ ] [\ \fB\-l\fIn\fR\ ] [\ \fB\-lc\fIn\fR\ ] [\ \fB\-lp\fR\ |\ \fB\-nlp\fR\ ] [\ \fB\-npro\fR\ ] [\ \fB\-pcs\fR\ |\ \fB\-npcs\fR\ ] [\ \fB\-ps\fR\ |\ \fB\-nps\fR\ ] [\ \fB\-psl\fR\ |\ \fB\-npsl\fR\ ] [\ \fB\-sc\fR\ |\ \fB\-nsc\fR\ ] [\ \fB\-sob\fR\ |\ \fB\-nsob\fR\ ] [\ \fB\-st\fR\ ] [\ \fB\-troff\fR\ ] [\ \fB\-v\fR\ |\ \fB\-nv\fR\ ] .SH DESCRIPTION .IX indent "" "\fLindent\fP \(em format C source" .IX "programming tools" "indent" "" "\fLindent\fP \(em format C source" .IX "languages" "indent" "" "\fLindent\fP \(em format C source" .IX "C programming language" "indent" "" "\fLindent\fP \(em format C source" .IX "pretty printer" "indent" "" "\fLindent\fP \(em format C source" .IX "format C programs" "" "format C programs \(em \fLindent\fP" .IX "code formatter" "indent" "" "\fLindent\fP \(em format C source" .IX "cb" "indent" "\fLcb\fP" "try \fLindent\fP \(em format C source" .I Indent is a \fBC\fR program formatter. It reformats the \fBC\fR program in the \fIinput-file\fR according to the switches. The switches which can be specified are described below. They may appear before or after the file names. .LP \fBNOTE\fP: If you only specify an \fIinput-file\fR, the formatting is done `in-place', that is, the formatted file is written back into .I input-file and a backup copy of .I input-file is written in the current directory. If .I input-file is named `/blah/blah/file', the backup file is named .RI file .BAK. .LP If .I output-file is specified, .I indent checks to make sure it is different from .IR input-file . .SH OPTIONS .LP The options listed below control the formatting style imposed by .IR indent . .TP 15 .BR \-bad , \-nbad If .B \-bad is specified, a blank line is forced after every block of declarations. Default: .BR \-nbad . .TP 15 .BR \-bap , \-nbap If .B \-bap is specified, a blank line is forced after every procedure body. Default: .B \-nbap. .TP 15 .BR \-bbb , \-nbbb If .B \-bbb is specified, a blank line is forced before every block comment. Default: .B \-nbbb. .TP 15 .BR \-bc , \-nbc If .B \-bc is specified, then a newline is forced after each comma in a declaration. .B \-nbc turns off this option. The default is .BR \-nbc . .TP 15 .BR \-br , \-bl Specifying .B \-bl lines up compound statements like this: .ne 4 .nf .ft L if (...) { code } .ft R .fi Specifying .B \-br (the default) makes them look like this: .ne 3 .nf .ft L if (...) { code } .ft R .fi .LP .TP 15 .BI \-c n The column in which comments on code start. The default is 33. .TP 15 .BI \-cd n The column in which comments on declarations start. The default is for these comments to start in the same column as those on code. .TP 15 .BI \-cdb , \-ncdb Enables (disables) the placement of comment delimiters on blank lines. With this option enabled, comments look like this: .nf .ft L .ne 3 /* * this is a comment */ .ft R .fi Rather than like this: .nf .ft L /* this is a comment */ .ft R .fi This only affects block comments, not comments to the right of code. The default is .BR \-cdb . .TP 15 .BI \-ce , \-nce Enables (disables) forcing `else's to cuddle up to the immediately preceding `}'. The default is .BR \-ce . .TP 15 .BI \-ci n Sets the continuation indent to be \fIn\fR. Continuation lines will be indented that far from the beginning of the first line of the statement. Parenthesized expressions have extra indentation added to indicate the nesting, unless \fB\-lp\fR is in effect. \fB\-ci\fR defaults to the same value as \fB\-i\fR. .TP 15 .BI \-cli n Causes case labels to be indented .I n tab stops to the right of the containing \fBswitch\fR statement. \fB\-cli0.5\fR causes case labels to be indented half a tab stop. The default is .BR \-cli0 . (This is the only option that takes a fractional argument.) .TP 15 .BI \-d n Controls the placement of comments which are not to the right of code. Specifying .B \-d1 means that such comments are placed one indentation level to the left of code. The default .B \-d0 lines up these comments with the code. See the section on comment indentation below. .TP 15 .BI \-di n Specifies the indentation, in character positions, from a declaration keyword to the following identifier. The default is .BR \-di16 . .TP 15 .BR \-dj , \-ndj .B \-dj left justifies declarations. .B \-ndj indents declarations the same as code. The default is .BR \-ndj . .TP 15 .BI \-ei , \-nei Enables (disables) special .B else-if processing. If enabled, .BR if "s" following .BR else "s" will have the same indentation as the preceding .B if statement. The default is .BR \-ei . .TP 15 .BI \-fc1 , \-nfc1 Enables (disables) the formatting of comments that start in column 1. Often, comments whose leading `/' is in column 1 have been carefully hand formatted by the programmer. In such cases, \fB\-nfc1\fR should be used. The default is \fB\-fc1\fR. .TP 15 .BI \-i n The number of spaces for one indentation level. The default is 8. .TP 15 .BI \-ip , \-nip Enables (disables) the indentation of parameter declarations from the left margin. The default is .BR \-ip . .TP 15 .BI \-l n Maximum length of an output line. The default is 78. .TP 15 .BI \-lp , \-nlp Lines up code surrounded by parenthesis in continuation lines. If a line has a left paren which is not closed on that line, then continuation lines will be lined up to start at the character position just after the left paren. For example, here is how a piece of continued code looks with \fB\-nlp\fR in effect: .ne 2 .nf .ft L p1 = first_procedure(second_procedure(p2, p3), third_procedure(p4, p5)); .ft R .fi .ne 5 With \fB\-lp\fR in effect (the default) the code looks somewhat clearer: .nf .ft L .ta \w' p1 = first_procedure('u p1 = first_procedure(second_procedure(p2, p3), third_procedure(p4, p5)); .ft R .fi .ne 5 Inserting two more newlines we get: .nf .ft L .ta \w' p1 = first_procedure('u +\w'second_procedure('u p1 = first_procedure(second_procedure(p2, p3), .ta \w' p1 = first_procedure('u +\w'third_procedure('u third_procedure(p4, p5)); .ft R .fi .TP 15 .B \-npro Causes the profile files, `./.indent.pro' and `~/.indent.pro', to be ignored. .TP 15 .BR \-pcs , \-npcs If true (\fB\-pcs\fR) all procedure calls will have a space inserted between the name and the `('. The default is .BR \-npcs . .TP 15 .BR \-ps , \-nps If true (\fB\-ps\fR) the pointer following operator `\->' will be surrounded by spaces on either side. The default is .BR \-nps . .TP 15 .BR \-psl , \-npsl If true (\fB\-psl\fR) the names of procedures being defined are placed in column 1 \- their types, if any, will be left on the previous lines. The default is .BR \-psl . .TP 15 .BR \-sc , \-nsc Enables (disables) the placement of asterisks (`*'s) at the left edge of all comments. The default is .BR \-sc . .TP 15 .BR \-sob , \-nsob If .B \-sob is specified, indent will swallow optional blank lines. You can use this to get rid of blank lines after declarations. Default: .BR \-nsob . .TP 15 .B \-st Causes .B indent to take its input from stdin, and put its output to stdout. .TP 15 .BI \-T typename Adds .I typename to the list of type keywords. Names accumulate: .B \-T can be specified more than once. You need to specify all the typenames that appear in your program that are defined by \fBtypedef\fRs \- nothing will be harmed if you miss a few, but the program won't be formatted as nicely as it should. This sounds like a painful thing to have to do, but it's really a symptom of a problem in C: \fBtypedef\fR causes a syntactic change in the language and \fIindent\fR can't find all \fBtypedef\fRs. .TP 15 .B \-troff Causes .B indent to format the program for processing by troff. It will produce a fancy listing in much the same spirit as .BR vgrind . If the output file is not specified, the default is standard output, rather than formatting in place. .TP 15 .BR \-v , \-nv .B \-v turns on `verbose' mode; .B \-nv turns it off. When in verbose mode, .I indent reports when it splits one line of input into two or more lines of output, and gives some size statistics at completion. The default is .BR \-nv . .SH "FURTHER DESCRIPTION" .LP You may set up your own `profile' of defaults to .I indent by creating a file called .BI . indent . pro in either your login directory and/or the current directory and including whatever switches you like. Switches in `.indent.pro' in the current directory override those in your login directory (with the exception of .B -T type definitions, which just accumulate). If .I indent is run and a profile file exists, then it is read to set up the program's defaults. The switches should be separated by spaces, tabs or newlines. Switches on the command line, however, override profile switches. .LP .B Comments .LP .IR "`Box' comments" . .I Indent assumes that any comment with a dash or star immediately after the start of comment (that is, `/*\-' or `/**') is a comment surrounded by a box of stars. Each line of such a comment is left unchanged, except that its indentation may be adjusted to account for the change in indentation of the first line of the comment. .LP .IR "Straight text" . All other comments are treated as straight text. .I Indent fits as many words (separated by blanks, tabs, or newlines) on a line as possible. Blank lines break paragraphs. .LP .B Comment indentation .LP If a comment is on a line with code it is started in the `comment column', which is set by the .BI \-c n command line parameter. Otherwise, the comment is started at .I n indentation levels less than where code is currently being placed, where .I n is specified by the .BI \-d n command line parameter. If the code on a line extends past the comment column, the comment starts further to the right, and the right margin may be automatically extended in extreme cases. .LP .B Preprocessor lines .LP In general, \fIindent\fR leaves preprocessor lines alone. The only reformatting that it will do is to straighten up trailing comments. It leaves embedded comments alone. Conditional compilation (\fB#ifdef...#endif\fR) is recognized and \fIindent\fR attempts to correctly compensate for the syntactic peculiarities introduced. .LP .B C syntax .LP \fIIndent\fR understands a substantial amount about the syntax of C, but it has a `forgiving' parser. It attempts to cope with the usual sorts of incomplete and misformed syntax. In particular, the use of macros like: .nf .ft L #define forever for(;;) .ft R .fi is handled properly. .SH FILES .DT .br \&./.indent.pro profile file .br ~/.indent.pro profile file .SH BUGS .I Indent has even more switches than \fIls\fR. .sp .ne 5 A common mistake that often causes grief is typing: .nf .ft L indent *.c .ft R .fi to the shell in an attempt to indent all the \fBC\fR programs in a directory. This is probably a bug, not a feature. ================================================ FILE: share/man/man1/intro.1 ================================================ .\" @(#)intro.1 6.1 (Berkeley) 4/29/85 .\" .TH INTRO 1 "April 29, 1985" .AT 3 .SH NAME intro \- introduction to commands .SH DESCRIPTION This section describes publicly accessible commands in alphabetic order. Certain distinctions of purpose are made in the headings: .TP (1) Commands of general utility. .TP (1C) Commands for communication with other systems. .TP (1G) Commands used primarily for graphics and computer-aided design. .PP N.B.: Commands related to system maintenance used to appear in section 1 manual pages and were distinguished by (1M) at the top of the page. These manual pages now appear in section 8. .SH SEE ALSO Section (6) for computer games. .PP .I How to get started, in the Introduction. .SH DIAGNOSTICS Upon termination each command returns two bytes of status, one supplied by the system giving the cause for termination, and (in the case of `normal' termination) one supplied by the program, see .I wait and .IR exit (2). The former byte is 0 for normal termination, the latter is customarily 0 for successful execution, nonzero to indicate troubles such as erroneous parameters, bad or inaccessible data, or other inability to cope with the task at hand. It is called variously `exit code', `exit status' or `return code', and is described only where special conventions are involved. ================================================ FILE: share/man/man1/join.1 ================================================ .\" @(#)join.1 6.1 (Berkeley) 4/29/85 .\" .TH JOIN 1 "April 29, 1985" .AT 3 .SH NAME join \- relational database operator .SH SYNOPSIS .B join [ options ] file1 file2 .SH DESCRIPTION .I Join forms, on the standard output, a join of the two relations specified by the lines of .I file1 and .IR file2 . If .I file1 is `\-', the standard input is used. .PP .I File1 and .I file2 must be sorted in increasing ASCII collating sequence on the fields on which they are to be joined, normally the first in each line. .PP There is one line in the output for each pair of lines in .I file1 and .I file2 that have identical join fields. The output line normally consists of the common field, then the rest of the line from .IR file1 , then the rest of the line from .IR file2 . .PP Fields are normally separated by blank, tab or newline. In this case, multiple separators count as one, and leading separators are discarded. .PP These options are recognized: .TP .BI \-a n In addition to the normal output, produce a line for each unpairable line in file .IR n , where .I n is 1 or 2. .TP .BI \-e \ s Replace empty output fields by string .IR s . .TP .BI \-j n\ m Join on the .IR m th field of file .IR n . If .I n is missing, use the .IR m th field in each file. .TP .BI \-o \ list Each output line comprises the fields specified in .IR list , each element of which has the form .IR n . m , where .I n is a file number and .I m is a field number. .PP .TP .BI \-t c Use character .I c as a separator (tab character). Every appearance of .I c in a line is significant. .SH "SEE ALSO" sort(1), comm(1), awk(1) .SH BUGS With default field separation, the collating sequence is that of .IR sort\ \-b ; with .BR \-t , the sequence is that of a plain sort. .PP The conventions of .I join, sort, comm, uniq, look and .IR awk (1) are wildly incongruous. ================================================ FILE: share/man/man1/kill.1 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)kill.1 6.2 (Berkeley) 4/20/86 .\" .TH KILL 1 "April 20, 1986" .UC 4 .SH NAME kill \- terminate a process with extreme prejudice .SH SYNOPSIS .B kill [ .BR \- sig ] processid ... .br .B kill .B \-l .SH DESCRIPTION .I Kill sends the TERM (terminate, 15) signal to the specified processes. If a signal name or number preceded by `\-' is given as first argument, that signal is sent instead of terminate (see .IR sigvec (2)). The signal names are listed by `kill \-l', and are as given in .I /usr/include/signal.h, stripped of the common SIG prefix. .PP The terminate signal will kill processes that do not catch the signal; `kill \-9 ...' is a sure kill, as the KILL (9) signal cannot be caught. By convention, if process number 0 is specified, all members in the process group (i.e. processes resulting from the current login) are signaled (but beware: this works only if you use .IR sh (1); not if you use .IR csh (1).) Negative process numbers also have special meanings; see .IR kill (2) for details. .PP The killed processes must belong to the current user unless he is the super-user. .PP The process number of an asynchronous process started with `&' is reported by the shell. Process numbers can also be found by using .IR ps (1). .I Kill is a built-in to .IR csh (1); it allows job specifiers of the form ``%...'' as arguments so process id's are not as often used as .I kill arguments. See .IR csh (1) for details. .SH "SEE ALSO" csh(1), ps(1), kill(2), sigvec(2) .SH BUGS A replacement for ``kill 0'' for .IR csh (1) users should be provided. ================================================ FILE: share/man/man1/last.1 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)last.1 6.1 (Berkeley) 4/29/85 .\" .TH LAST 1 "April 29, 1985" .UC 4 .SH NAME last \- indicate last logins of users and teletypes .SH SYNOPSIS .B last [ \-f filename ] [ \-N ] [ name ... ] [ tty ... ] .SH DESCRIPTION .I Last will look back in the .I wtmp file which records all logins and logouts for information about a user, a teletype or any group of users and teletypes. Arguments specify names of users or teletypes of interest. Names of teletypes may be given fully or abbreviated. For example `last 0' is the same as `last tty0'. If multiple arguments are given, the information which applies to any of the arguments is printed. For example `last root console' would list all of "root's" sessions as well as all sessions on the console terminal. .I Last will print the sessions of the specified users and teletypes, most recent first, indicating the times at which the session began, the duration of the session, and the teletype which the session took place on. If the session is still continuing or was cut short by a reboot, .I last so indicates. .PP The pseudo-user .B reboot logs in at reboots of the system, thus .DT .PP last reboot .PP will give an indication of mean time between reboot. .PP .I Last with no arguments prints a record of all logins and logouts, in reverse order. The .B \-f filename option allows the user to examine an alternate .I wtmp file. The .B \-N option limits the report to N lines. .PP If .I last is interrupted, it indicates how far the search has progressed in .I wtmp. If interrupted with a quit signal (generated by a control-\e) .I last indicates how far the search has progressed so far, and the search continues. .SH FILES /usr/adm/wtmp login data base .br /usr/adm/shutdownlog which records shutdowns and reasons for same .SH SEE\ ALSO wtmp(5), ac(8), lastcomm(1) .SH AUTHOR Howard Katseff ================================================ FILE: share/man/man1/lastcomm.1 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)lastcomm.1 6.2.1 (2.11BSD) 2/3/05 .\" .TH LASTCOMM 1 "February 3, 1995" .UC 4 .SH NAME lastcomm \- show last commands executed in reverse order .SH SYNOPSIS .B lastcomm [ -f file ] [ command name ] ... [user name] ... [terminal name] ... .SH DESCRIPTION .I Lastcomm gives information on previously executed commands. .sp Option: .sp .TP 10 \-f \fIfile\fP Read from \fIfile\fP rather than the default accounting file. .PP With no arguments, .I lastcomm prints information about all the commands recorded during the current accounting file's lifetime. If called with arguments, only accounting entries with a matching command name, user name, or terminal name are printed. So, for example, .sp .ti +0.5i lastcomm a.out root ttyd0 .sp would produce a listing of all the executions of commands named .I a.out by user .I root on the terminal .IR ttyd0 . .PP For each process entry, the following are printed. .sp .in +0.5i The name of the user who ran the process. .br Flags, as accumulated by the accounting facilities in the system. .br The command name under which the process was called. .br The amount of cpu time used by the process (in seconds). .br The time the process exited. .in -0.5i .PP The flags are encoded as follows: ``S'' indicates the command was executed by the super-user, ``F'' indicates the command ran after a fork, but without a following .IR exec , ``C'' indicates the command was run in PDP-11 compatibility mode (VAX only), ``D'' indicates the command terminated with the generation of a .I core file, and ``X'' indicates the command was terminated with a signal. .SH FILES .TP 20 /usr/adm/acct Default accounting file. .SH "SEE ALSO" last(1), sigvec(2), acct(8), core(5) ================================================ FILE: share/man/man1/learn.1 ================================================ .\" @(#)learn.1 6.2.1 (2.11BSD) 1996/10/22 .\" .TH LEARN 1 "October 22, 1996" .AT 3 .SH NAME learn \- computer aided instruction about UNIX .SH SYNOPSIS .B learn [ .BR \- directory ] [ subject [ lesson ] ] .SH DESCRIPTION .I Learn gives Computer Aided Instruction courses and practice in the use of UNIX, the C Shell, and the Berkeley text editors. To get started simply type .BR learn . If you had used .I learn before and left your last session without completing a subject, the program will use information in $HOME/.learnrc to start you up in the same place you left off. Your first time through, .I learn will ask questions to find out what you want to do. Some questions may be bypassed by naming a .IR subject , and more yet by naming a .IR lesson . You may enter the .I lesson as a number that .I learn gave you in a previous session. If you do not know the lesson number, you may enter the .I lesson as a word, and .I learn will look for the first lesson containing it. If the .I lesson is `\fB\-\fP', .I learn prompts for each lesson; this is useful for debugging. .PP The .IR subject \|'s presently handled are .if n .sp 1v .if t .sp .5v .nf .in +0.5i files editor vi morefiles macros eqn C .in -0.5i .fi .PP There are a few special commands. The command `bye' terminates a .I learn session and `where' tells you of your progress, with `where\0m' telling you more. The command `again' re-displays the text of the lesson and `again\0\fIlesson\fP' lets you review .IR lesson . There is no way for .I learn to tell you the answers it expects in English, however, the command `hint' prints the last part of the lesson script used to evaluate a response, while `hint m' prints the whole lesson script. This is useful for debugging lessons and might possibly give you an idea about what it expects. .PP The .BI \- directory option allows one to exercise a script in a nonstandard place. .SH FILES /usr/share/learn subtree for all dependent directories and files .br /usr/tmp/pl\(** playpen directories .br $HOME/.learnrc startup information .SH SEE ALSO csh(1), ex(1) .br B. W. Kernighan and M. E. Lesk, \fILEARN \- Computer-Aided Instruction on UNIX\fR .SH BUGS The main strength of .I learn, that it asks the student to use the real UNIX, also makes possible baffling mistakes. It is helpful, especially for nonprogrammers, to have a UNIX initiate near at hand during the first sessions. .PP Occasionally lessons are incorrect, sometimes because the local version of a command operates in a non-standard way. Occasionally a lesson script does not recognize all the different correct responses, in which case the `hint' command may be useful. Such lessons may be skipped with the `skip' command, but it takes some sophistication to recognize the situation. .PP To find a .I lesson given as a word, .I learn does a simple .IR fgrep (1) through the lessons. It is unclear whether this sort of subject indexing is better than none. .PP Spawning a new shell is required for each of many user and internal functions. .PP The `vi' lessons are provided separately from the others. To use them see your system administrator. ================================================ FILE: share/man/man1/leave.1 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)leave.1 6.2 (Berkeley) 5/7/86 .\" .TH LEAVE 1 "May 7, 1986" .UC .SH NAME leave \- remind you when you have to leave .SH SYNOPSIS .B leave [ [+]hhmm ] .SH DESCRIPTION .I Leave waits until the specified time, then reminds you that you have to leave. You are reminded 5 minutes and 1 minute before the actual time, at the time, and every minute thereafter. When you log off, .I leave exits just before it would have printed the next message. .PP The time of day is in the form hhmm where hh is a time in hours (on a 12 or 24 hour clock). All times are converted to a 12 hour clock, and assumed to be in the next 12 hours. .PP If the time is preceeded by `+', the alarm will go off in hours and minutes from the current time. .PP If no argument is given, .I leave prompts with "When do you have to leave?". A reply of newline causes .I leave to exit, otherwise the reply is assumed to be a time. This form is suitable for inclusion in a .I .login or .I .profile. .PP Leave ignores interrupts, quits, and terminates. To get rid of it you should either log off or use ``kill \-9'' giving its process id. .SH SEE ALSO calendar(1) ================================================ FILE: share/man/man1/lex.1 ================================================ .\" @(#)lex.1 6.2 (Berkeley) 4/14/86 .\" .TH LEX 1 "April 14, 1986" .AT 3 .SH NAME lex \- generator of lexical analysis programs .SH SYNOPSIS .B lex [ .B \-tvfn ] [ file ] ... .SH DESCRIPTION .I Lex generates programs to be used in simple lexical analyis of text. The input .I files (standard input default) contain regular expressions to be searched for, and actions written in C to be executed when expressions are found. .PP A C source program, 'lex.yy.c' is generated, to be compiled thus: .IP cc lex.yy.c \-ll .LP This program, when run, copies unrecognized portions of the input to the output, and executes the associated C action for each regular expression that is recognized. .PP The options have the following meanings. .TP .B \-t Place the result on the standard output instead of in file "lex.yy.c". .TP .B \-v Print a one-line summary of statistics of the generated analyzer. .TP .B \-n Opposite of .BR \-v ; .B \-n is default. .TP .B \-f "Faster" compilation: don't bother to pack the resulting tables; limited to small programs. .SH EXAMPLE .IP lex lexcommands .PP would draw .I lex instructions from the file .I lexcommands, and place the output in .I lex.yy.c .IP "" .nf .ta \w'[A\-Z] 'u %% [A\-Z] putchar(yytext[0]+\'a\'\-\'A\'); [ ]+$ ; [ ]+ putchar(\' \'); .fi .PP is an example of a .I lex program that would be put into a .I lex command file. This program converts upper case to lower, removes blanks at the end of lines, and replaces multiple blanks by single blanks. .SH "SEE ALSO" yacc(1), sed(1) .br M. E. Lesk and E. Schmidt, .I LEX \- Lexical Analyzer Generator ================================================ FILE: share/man/man1/lint.1 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)lint.1 6.2.1 (2.11BSD) 1996/10/22 .\" .TH LINT 1 "October 22, 1996" .UC 4 .SH NAME lint \- a C program verifier .SH SYNOPSIS .B lint [ .B \-abchnpuvx ] file ... .SH DESCRIPTION .I Lint attempts to detect features of the C program .I files which are likely to be bugs, or non-portable, or wasteful. It also checks the type usage of the program more strictly than the compilers. Among the things which are currently found are unreachable statements, loops not entered at the top, automatic variables declared and not used, and logical expressions whose value is constant. Moreover, the usage of functions is checked to find functions which return values in some places and not in others, functions called with varying numbers of arguments, and functions whose values are not used. .PP By default, it is assumed that all the .I files are to be loaded together; they are checked for mutual compatibility. Function definitions for certain libraries are available to .IR lint ; these libraries are referred to by a conventional name, such as `\-lm', in the style of .IR ld (1). Arguments ending in .I .ln are also treated as library files. To create lint libraries, use the .B \-C option: .IP lint \-Cfoo files . . . .PP where .I files are the C sources of library .I foo. The result is a file .I llib-lfoo.ln in the correct library format suitable for linting programs using .I foo. .PP Any number of the options in the following list may be used. The .SM .BR \-D "\*S," .SM .BR \-U "\*S," and .SM .B \-I options of .IR cc (1) are also recognized as separate arguments. .TP .B p Attempt to check portability to the .I IBM and .I GCOS dialects of C. .TP .B h Apply a number of heuristic tests to attempt to intuit bugs, improve style, and reduce waste. .TP .B b Report .I break statements that cannot be reached. (This is not the default because, unfortunately, most .I lex and many .I yacc outputs produce dozens of such comments.) .TP .B v Suppress complaints about unused arguments in functions. .TP .B x Report variables referred to by extern declarations, but never used. .TP .B a Report assignments of long values to int variables. .TP .B c Complain about casts which have questionable portability. .TP .B u Do not complain about functions and variables used and not defined, or defined and not used (this is suitable for running .I lint on a subset of files out of a larger program). .TP .B n Do not check compatibility against the standard library. .TP .B z Do not complain about structures that are never defined (e.g. using a structure pointer without knowing its contents.). .PP .IR Exit (2) and other functions which do not return are not understood; this causes various lies. .PP Certain conventional comments in the C source will change the behavior of .IR lint : .TP /*NOTREACHED*/ at appropriate points stops comments about unreachable code. .TP .RI /*VARARGS n */ suppresses the usual checking for variable numbers of arguments in the following function declaration. The data types of the first .I n arguments are checked; a missing .I n is taken to be 0. .TP /*NOSTRICT*/ shuts off strict type checking in the next expression. .TP /*ARGSUSED*/ turns on the .B \-v option for the next function. .TP /*LINTLIBRARY*/ at the beginning of a file shuts off complaints about unused functions in this file. .SH AUTHOR S.C. Johnson. Lint library construction implemented by Edward Wang. .SH FILES .ta \w'/usr/share/lint/llib-port.ln 'u /usr/libexec/lint/lint[12] programs .br /usr/share/lint/llib-lc.ln declarations for standard functions .br /usr/share/lint/llib-lc human readable version of above .br /usr/share/lint/llib-port.ln declarations for portable functions .br /usr/share/lint/llib-port human readable . . . .br llib-l*.ln library created with .B \-C .SH SEE ALSO cc(1) .br S. C. Johnson, .I Lint, a C Program Checker .SH BUGS There are some things you just .B can't get lint to shut up about. .PP /*NOSTRICT*/ is not implemented in the current version (alas). ================================================ FILE: share/man/man1/lisp.1 ================================================ .de lt .ta 1.2i 2.4i 3.6i 4.8i 6.0i .. .TH LISP 1 "February 19, 1987" .UC .SH NAME lisp \- lisp interpreter .SH SYNOPSIS .B lisp .SH DESCRIPTION .PP .I Lisp is a provisional lisp interpreter. It only runs in eval mode. Built in functions are named in lower case, and case is distinguished. It is being transmuted from a subset of lisp as provided by the Harvard \s-2UNIX\s0 lisp in use at \s-2UCB\s0, to a subset of \s-2MIT\s0's \s-2MACLISP\s0. .PP The following functions are provided as machine code: .LP Lambda functions: .if n .ta 13n 26n 39n 52n 65n .if t .lt .sp .nf atom dptr load putd rplacd bcdp drain null putprop set car eq numberp ratom terpr cdr equal outfile read close eval patom readc concat get pntlen retbrk cons getd portp return cont infile print rplaca .fi .LP Nlambda functions (possibly simulating ones which are normally lambdas): .if n .ta 13n 26n 39n 52n 65n .if t .lt .sp .nf add1 difference onep quotient zerop and exit or reset break go plus setq cond minus product sub1 cond mod prog sum def not quote times .fi .PP The following functions are provided as lisp code (and at the moment must be read in by saying (load 'auxfns): .if n .ta 13n 26n 39n 52n 65n .if t .lt .sp .nf add copy length numbp append defevq linelength pp_etc apply* defprop member reverse charcnt defprop memcar terpri chrct diff memcdr conc last nconc .fi .PP All of the above functions are documented in the ``Harvard Lisp Manual.'' .PP The following functions are provided as in \s-2MIT\s0's \s-2MACLISP\s0. .if n .ta 13n 26n 39n 52n 65n .if t .lt .sp .nf alphalessp do mapc setsyntax apply explodec mapcar throw ascii exploden prog2 tyi catch funcall progn tyipeek defun implode progv tyo .fi .PP ``Hairy control structure'' is provided by the Nlambda (process\ \fIcommand\ inport\ outport\fP) where .I command is an atom whose print name is some command that you would wish typed at the terminal, e.g. ``neqn\ |\ nroff\ \-ms''; where .I inport and .I outport are atoms which will be bound to port descriptors for use in communication with the subprocess. .I Inport is a port to a pipe which will be read by the subprocess as its standard input. If .I Inport is \fInil\fP (or not present), the subprocess inherits the standard input, and lisp waits for the subprocess to die. If .I Inport is the atom .I t lisp continues without waiting. .SH AUTHORS Originally written by Jeff Levinsky, Mike Curry, and John Breedlove. Keith Sklower made it work and is maintaining the current version. The garbage collector was implemented by Bill Rowan. .SH SEE ALSO Harvard \s-2UNIX\s0 Lisp Manual .br MACLISP Manual .br UCB Franz Lisp Manual .SH "BUGS" The status bits for .I setsyntax are not the same as for \s-2MACLISP\s0. .PP Closing down a pipe doesn't always seem to work correctly. .PP Arrays are not implemented in version 1. ================================================ FILE: share/man/man1/ln.1 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)ln.1 6.2 (Berkeley) 4/10/86 .\" .TH LN 1 "April 10, 1986" .UC 4 .SH NAME ln \- make links .SH SYNOPSIS .B ln [ .B \-s ] sourcename [ targetname ] .br .B ln [ .B \-s ] sourcename1 sourcename2 [ sourcename3 ... ] targetdirectory .SH DESCRIPTION A link is a directory entry referring to a file; the same file (together with its size, all its protection information, etc.) may have several links to it. There are two kinds of links: hard links and symbolic links. .PP By default .I ln makes hard links. A hard link to a file is indistinguishable from the original directory entry; any changes to a file are effective independent of the name used to reference the file. Hard links may not span file systems and may not refer to directories. .PP The .B \-s option causes .I ln to create symbolic links. A symbolic link contains the name of the file to which it is linked. The referenced file is used when an .IR open (2) operation is performed on the link. A .IR stat (2) on a symbolic link will return the linked-to file; an .IR lstat (2) must be done to obtain information about the link. The .IR readlink (2) call may be used to read the contents of a symbolic link. Symbolic links may span file systems and may refer to directories. .PP Given one or two arguments, .I ln creates a link to an existing file .IR sourcename . If .I targetname is given, the link has that name; .I targetname may also be a directory in which to place the link; otherwise it is placed in the current directory. If only the directory is specified, the link will be made to the last component of .IR sourcename . .PP Given more than two arguments, .I ln makes links in .I targetdirectory to all the named source files. The links made will have the same name as the files being linked to. .SH "SEE ALSO" rm(1), cp(1), mv(1), link(2), readlink(2), stat(2), symlink(2) ================================================ FILE: share/man/man1/logger.1 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)logger.1 6.1 (Berkeley) 9/17/85 .\" .TH LOGGER 1 "September 17, 1985" .UC 6 .SH NAME logger \- make entries in the system log .SH SYNOPSIS .B logger [ .B \-t tag ] [ .B \-p pri ] [ .B \-i ] [ .B \-f file ] [ message ... ] .SH ARGUMENTS .TP 12n .BI \-t \ tag Mark every line in the log with the specified .IR tag . .TP .BI \-p \ pri Enter the message with the specified priority. The priority may be specified numerically or as a ``facility.level'' pair. For example, ``\-p local3.info'' logs the message(s) as .IR info rmational level in the .I local3 facility. The default is ``user.notice.'' .TP .B \-i Log the process id of the logger process with each line. .TP .BI \-f \ file Log the specified file. .TP message The message to log; if not specified, the .B \-f file or standard input is logged. .SH DESCRIPTION .I Logger provides a program interface to the .IR syslog (3) system log module. .PP A message can be given on the command line, which is logged immediately, or a file is read and each line is logged. .SH EXAMPLES logger System rebooted .PP logger \-p local0.notice \-t HOSTIDM \-f /dev/idmc .SH SEE ALSO syslog(3), syslogd(8) ================================================ FILE: share/man/man1/login.1 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)login.1 6.2.1 (2.11BSD) 1996/11/27 .\" .TH LOGIN 1 "November 27, 1996" .UC 4 .SH NAME login \- sign on .SH SYNOPSIS .B login [ \-p ] [ username ] .SH DESCRIPTION The .I login command is used when a user initially signs on, or it may be used at any time to change from one user to another. The latter case is the one summarized above and described here. See \*(lqHow to Get Started\*(rq for how to dial up initially. .PP If .I login is invoked without an argument, it asks for a user name, and, if appropriate, a password. Echoing is turned off (if possible) during the typing of the password, so it will not appear on the written record of the session. .PP After a successful login, accounting files are updated and the user is informed of the existence of mail. The message of the day is printed, as is the time of his last login. Both are suppressed if he has a \*(lq.hushlogin\*(rq file in his home directory; this is mostly used to make life easier for non-human users, such as .IR uucp . .PP .I Login initializes the user and group IDs and the working directory, then executes a command interpreter (usually .IR csh (1)) according to specifications found in a password file. Argument 0 of the command interpreter is the name of the command interpreter with a leading dash (\*(lq\-\*(rq). .PP Login also modifies the environment .IR environ (7) with information specifying home directory, command interpreter, terminal type (if available) and user name. The `\-p' argument causes the remainder of the environment to be preserved, otherwise any previous environment is discarded. .PP If the file /etc/nologin exists, .I login prints its contents on the user's terminal and exits. This is used by .IR shutdown (8) to stop users logging in when the system is about to go down. .PP Login is recognized by .IR sh (1) and .IR csh (1) and executed directly (without forking). .SH FILES .ta \w'/usr/spool/mail/*\ \ 'u /var/run/utmp accounting .br /usr/adm/wtmp accounting .br /usr/spool/mail/* mail .br /etc/motd message-of-the-day .br /etc/passwd password file .br /etc/nologin stops logins .br \&.hushlogin makes login quieter .SH "SEE ALSO" init(8), getty(8), mail(1), passwd(1), passwd(5), environ(7), shutdown(8), rlogin(1c) .SH DIAGNOSTICS \*(lqLogin incorrect,\*(rq if the name or the password is bad. .br \*(lqNo Shell\*(rq, \*(lqcannot open password file\*(rq, \*(lqno directory\*(rq: consult a programming counselor. .SH BUGS An undocumented option, .B \-r is used by the remote login server, .IR rlogind (8C) to force .I login to enter into an initial connection protocol. .B \-h is used by .IR telnetd (8C) and other servers to list the host from which the connection was received. ================================================ FILE: share/man/man1/look.1 ================================================ .\" @(#)look.1 6.1 (Berkeley) 4/29/85 .\" .TH LOOK 1 "April 29, 1985" .AT 3 .SH NAME look \- find lines in a sorted list .SH SYNOPSIS .B look [ .B \-df ] string [ file ] .SH DESCRIPTION .I Look consults a sorted .I file and prints all lines that begin with .IR string . It uses binary search. .PP The options .B d and .B f affect comparisons as in .IR sort (1): .TP 4 .B d `Dictionary' order: only letters, digits, tabs and blanks participate in comparisons. .TP 4 .B f Fold. Upper case letters compare equal to lower case. .PP If no .I file is specified, .I /usr/dict/words is assumed with collating sequence .B \-df. .SH FILES /usr/dict/words .SH "SEE ALSO" sort(1), grep(1) ================================================ FILE: share/man/man1/lookbib.1 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)lookbib.1 6.1.1 (2.11BSD) 1996/10/22 .\" .TH LOOKBIB 1 "October 22, 1996" .UC 5 .SH NAME indxbib, lookbib \- build inverted index for a bibliography, find references in a bibliography .SH SYNOPSIS .B indxbib database ... .br .B lookbib [ .B \-n ] database .SH DESCRIPTION .I Indxbib makes an inverted index to the named .I databases (or files) for use by .IR lookbib (1) and .IR refer (1). These files contain bibliographic references (or other kinds of information) separated by blank lines. .PP A bibliographic reference is a set of lines, constituting fields of bibliographic information. Each field starts on a line beginning with a ``%'', followed by a key-letter, then a blank, and finally the contents of the field, which may continue until the next line starting with ``%''. .PP .I Indxbib is a shell script that calls /usr/libexec/refer/mkey and /usr/libexec/refer/inv. The first program, .I mkey, truncates words to 6 characters, and maps upper case to lower case. It also discards words shorter than 3 characters, words among the 100 most common English words, and numbers (dates) < 1900 or > 2000. These parameters can be changed; see page 4 of the .I Refer document by Mike Lesk. The second program, .I inv, creates an entry file (.ia), a posting file (.ib), and a tag file (.ic), all in the working directory. .PP .I Lookbib uses an inverted index made by .I indxbib to find sets of bibliographic references. It reads keywords typed after the ``>'' prompt on the terminal, and retrieves records containing all these keywords. If nothing matches, nothing is returned except another ``>'' prompt. .PP .I Lookbib will ask if you need instructions, and will print some brief information if you reply ``y''. The ``\-n'' flag turns off the prompt for instructions. .PP It is possible to search multiple databases, as long as they have a common index made by .I indxbib. In that case, only the first argument given to .I indxbib is specified to .I lookbib. .PP If .I lookbib does not find the index files (the .i[abc] files), it looks for a reference file with the same name as the argument, without the suffixes. It creates a file with a '.ig' suffix, suitable for use with .I fgrep. It then uses this fgrep file to find references. This method is simpler to use, but the .ig file is slower to use than the .i[abc] files, and does not allow the use of multiple reference files. .SH FILES .IR x .ia, .IR x .ib, .IR x .ic, where .I x is the first argument, or if these are not present, then .IR x .ig, .IR x .SH SEE ALSO refer(1), addbib(1), sortbib(1), roffbib(1), lookbib(1) .SH BUGS Probably all dates should be indexed, since many disciplines refer to literature written in the 1800s or earlier. ================================================ FILE: share/man/man1/lorder.1 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)lorder.1 6.1 (Berkeley) 4/29/85 .\" .TH LORDER 1 "April 29, 1985" .UC 4 .SH NAME lorder \- find ordering relation for an object library .SH SYNOPSIS .B lorder file ... .SH DESCRIPTION The input is one or more object or library archive (see .IR ar (1)) .I files. The standard output is a list of pairs of object file names, meaning that the first file of the pair refers to external identifiers defined in the second. The output may be processed by .IR tsort (1) to find an ordering of a library suitable for one-pass access by .IR ld (1). .PP This brash one-liner intends to build a new library from existing `.o' files. .IP ar cr library \`\|lorder *.o | tsort\` .PP The need for lorder may be vitiated by use of .IR ranlib (1), which converts an ordered archive into a randomly accessed library. .SH FILES *symref, *symdef .br nm(1), sed(1), sort(1), join(1) .SH "SEE ALSO" tsort(1), ld(1), ar(1), ranlib(1) .SH BUGS The names of object files, in and out of libraries, must end with `.o'; nonsense results otherwise. ================================================ FILE: share/man/man1/lpq.1 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)lpq.1 6.2 (Berkeley) 6/5/86 .\" .TH LPQ 1 "June 5, 1986" .UC 5 .SH NAME lpq \- spool queue examination program .SH SYNOPSIS .B lpq [ +[ n ] ] [ -l ] [ \-Pprinter ] [ job # ... ] [ user ... ] .SH DESCRIPTION .I lpq examines the spooling area used by .IR lpd (8) for printing files on the line printer, and reports the status of the specified jobs or all jobs associated with a user. .I lpq invoked without any arguments reports on any jobs currently in the queue. A .B \-P flag may be used to specify a particular printer, otherwise the default line printer is used (or the value of the PRINTER variable in the environment). If a .B \(pl argument is supplied, .I lpq displays the spool queue until it empties. Supplying a number immediately after the .B \(pl sign indicates that .I lpq should sleep \fIn\fR seconds in between scans of the queue. All other arguments supplied are interpreted as user names or job numbers to filter out only those jobs of interest. .PP For each job submitted (i.e. invocation of .IR lpr (1)) .I lpq reports the user's name, current rank in the queue, the names of files comprising the job, the job identifier (a number which may be supplied to .IR lprm (1) for removing a specific job), and the total size in bytes. The .B \-l option causes information about each of the files comprising the job to be printed. Normally, only as much information as will fit on one line is displayed. Job ordering is dependent on the algorithm used to scan the spooling directory and is supposed to be FIFO (First in First Out). File names comprising a job may be unavailable (when .IR lpr (1) is used as a sink in a pipeline) in which case the file is indicated as ``(standard input)". .PP If .I lpq warns that there is no daemon present (i.e. due to some malfunction), the .IR lpc (8) command can be used to restart the printer daemon. .SH FILES .nf .ta \w'/etc/termcap 'u /etc/termcap for manipulating the screen for repeated display /etc/printcap to determine printer characteristics /usr/spool/* the spooling directory, as determined from printcap /usr/spool/*/cf* control files specifying jobs /usr/spool/*/lock the lock file to obtain the currently active job .fi .SH "SEE ALSO" lpr(1), lprm(1), lpc(8), lpd(8) .SH BUGS Due to the dynamic nature of the information in the spooling directory lpq may report unreliably. Output formatting is sensitive to the line length of the terminal; this can results in widely spaced columns. .SH DIAGNOSTICS Unable to open various files. The lock file being malformed. Garbage files when there is no daemon active, but files in the spooling directory. ================================================ FILE: share/man/man1/lpr.1 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)lpr.1 6.1.1 (2.11BSD) 1996/10/22 .\" .TH LPR 1 "October 22, 1996" .UC 4 .SH NAME lpr \- off line print .SH SYNOPSIS .B lpr [ .BI \-P printer ] [ .BI \-# num ] [ .B \-C .I class ] [ .B \-J .I job ] [ .B \-T .I title ] [ .B \-i [ .I numcols ]] [ .B \-1234 .I font ] [ .BI \-w num ] [ .B \-pltndgvcfrmhs ] [ name ... ] .SH DESCRIPTION .B Lpr uses a spooling daemon to print the named files when facilities become available. If no names appear, the standard input is assumed. The .B \-P option may be used to force output to a specific printer. Normally, the default printer is used (site dependent), or the value of the environment variable PRINTER is used. .PP The following single letter options are used to notify the line printer spooler that the files are not standard text files. The spooling daemon will use the appropriate filters to print the data accordingly. .IP \fB\-p\fP 5 Use .IR pr (1) to format the files (equivalent to .IR print ). .IP \fB\-l\fP 5 Use a filter which allows control characters to be printed and suppresses page breaks. .IP \fB\-t\fP 5 The files are assumed to contain data from .IR troff (1) (cat phototypesetter commands). .IP \fB\-n\fP 5 The files are assumed to contain data from .I ditroff (device independent troff). .IP \fB\-d\fP 5 The files are assumed to contain data from .IR tex (l) (DVI format from Stanford). .IP \fB\-g\fP 5 The files are assumed to contain standard plot data as produced by the .IR plot (3X) routines (see also .IR plot (1G) for the filters used by the printer spooler). .IP \fB\-v\fP 5 The files are assumed to contain a raster image for devices like the Benson Varian. .IP \fB\-c\fP 5 The files are assumed to contain data produced by .IR cifplot (l). .IP \fB\-f\fP 5 Use a filter which interprets the first character of each line as a standard FORTRAN carriage control character. .PP The remaining single letter options have the following meaning. .IP \fB\-r\fP 5 Remove the file upon completion of spooling or upon completion of printing (with the \fB\-s\fP option). .IP \fB\-m\fP 5 Send mail upon completion. .IP \fB\-h\fP 5 Suppress the printing of the burst page. .IP \fB\-s\fP 5 Use symbolic links. Usually files are copied to the spool directory. .PP The .B \-C option takes the following argument as a job classification for use on the burst page. For example, .PP .ti +0.5i lpr \-C EECS foo.c .PP causes the system name (the name returned by .IR hostname (1)) to be replaced on the burst page by EECS, and the file foo.c to be printed. .PP The .B \-J option takes the following argument as the job name to print on the burst page. Normally, the first file's name is used. .PP The .B \-T option uses the next argument as the title used by .IR pr (1) instead of the file name. .PP To get multiple copies of output, use the .BI \-# num option, where .I num is the number of copies desired of each file named. For example, .PP .ti +0.5i lpr \-#3 foo.c bar.c more.c .PP would result in 3 copies of the file foo.c, followed by 3 copies of the file bar.c, etc. On the other hand, .PP .ti +0.5i cat foo.c bar.c more.c | lpr \-#3 .PP will give three copies of the concatenation of the files. .PP The .B \-i option causes the output to be indented. If the next argument is numeric, it is used as the number of blanks to be printed before each line; otherwise, 8 characters are printed. .PP The .B \-w option takes the immediately following number to be the page width for .IR pr . .PP The .B \-s option will use .IR symlink (2) to link data files rather than trying to copy them so large files can be printed. This means the files should not be modified or removed until they have been printed. .PP The option .B \-1234 Specifies a font to be mounted on font position \fIi\fR. The daemon will construct a \fI.railmag\fR file referencing \fI/usr/share/vfont/name.size\fR. .SH FILES .nf .ta \w'/usr/spool/*/cf* 'u /etc/passwd personal identification /etc/printcap printer capabilities data base /usr/sbin/lpd line printer daemon /usr/spool/* directories used for spooling /usr/spool/*/cf* daemon control files /usr/spool/*/df* data files specified in "cf" files /usr/spool/*/tf* temporary copies of "cf" files .fi .SH "SEE ALSO" lpq(1), lprm(1), pr(1), symlink(2), printcap(5), lpc(8), lpd(8) .SH DIAGNOSTICS If you try to spool too large a file, it will be truncated. .I Lpr will object to printing binary files. If a user other than root prints a file and spooling is disabled, .I lpr will print a message saying so and will not put jobs in the queue. If a connection to .I lpd on the local machine cannot be made, .I lpr will say that the daemon cannot be started. Diagnostics may be printed in the daemon's log file regarding missing spool files by .IR lpd . .SH BUGS Fonts for .I troff and .I tex reside on the host with the printer. It is currently not possible to use local font libraries. ================================================ FILE: share/man/man1/lprm.1 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)lprm.1 6.1.1 (2.11BSD) 1996/10/22 .\" .TH LPRM 1 "October 22, 1996" .UC 5 .SH NAME lprm \- remove jobs from the line printer spooling queue .SH SYNOPSIS .B lprm [ .BI \-P printer ] [ .B \- ] [ job # ... ] [ user ... ] .SH DESCRIPTION .I Lprm will remove a job, or jobs, from a printer's spool queue. Since the spooling directory is protected from users, using .I lprm is normally the only method by which a user may remove a job. .PP .I Lprm without any arguments will delete the currently active job if it is owned by the user who invoked .IR lprm . .PP If the .B \- flag is specified, .I lprm will remove all jobs which a user owns. If the super-user employs this flag, the spool queue will be emptied entirely. The owner is determined by the user's login name and host name on the machine where the .I lpr command was invoked. .PP Specifying a user's name, or list of user names, will cause .I lprm to attempt to remove any jobs queued belonging to that user (or users). This form of invoking .I lprm is useful only to the super-user. .PP A user may dequeue an individual job by specifying its job number. This number may be obtained from the .IR lpq (1) program, e.g. .PP .nf .in +0.5i .ta \w'k0-k9 'u +\w'Type 'u +\w'"/usr/sbin/lpd" 'u .ta \w'1st: 'u +\w'(standard input) 'u % lpq \-l 1st: ken [job #013ucbarpa] (standard input) 100 bytes % lprm 13 .in -0.5i .fi .PP .I Lprm will announce the names of any files it removes and is silent if there are no jobs in the queue which match the request list. .PP .I Lprm will kill off an active daemon, if necessary, before removing any spooling files. If a daemon is killed, a new one is automatically restarted upon completion of file removals. .PP The .B \-P option may be usd to specify the queue associated with a specific printer (otherwise the default printer, or the value of the PRINTER variable in the environment is used). .SH FILES .nf .ta \w'/usr/spool/*/lock 'u /etc/printcap printer characteristics file /usr/spool/* spooling directories /usr/spool/*/lock lock file used to obtain the pid of the current daemon and the job number of the currently active job .fi .SH "SEE ALSO" lpr(1), lpq(1), lpd(8) .SH DIAGNOSTICS ``Permission denied" if the user tries to remove files other than his own. .SH BUGS Since there are race conditions possible in the update of the lock file, the currently active job may be incorrectly identified. ================================================ FILE: share/man/man1/lptest.1 ================================================ .\" Copyright (c) 1985 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)lptest.1 6.1 (Berkeley) 4/29/85 .\" .TH LPTEST 1 "April 29, 1985" .UC 6 .SH NAME lptest \- generate lineprinter ripple pattern .SH SYNOPSIS .B lptest [ .B length [ .B count ] ] .br .SH DESCRIPTION .I Lptest writes the traditional "ripple test" pattern on standard output. In 96 lines, this pattern will print all 96 printable ASCII characters in each position. While originally created to test printers, it is quite useful for testing terminals, driving terminal ports for debugging purposes, or any other task where a quick supply of random data is needed. .PP The .I length argument specifies the output line length if the the default length of 79 is inappropriate. .PP The .I count argument specifies the number of output lines to be generated if the default count of 200 is inappropriate. Note that if .I count is to be specified, .I length must be also be specified. .SH "SEE ALSO" .SH BUGS ================================================ FILE: share/man/man1/ls.1 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)ls.1 6.4.2 (2.11BSD GTE) 1996/12/23 .\" .TH LS 1 "December 20, 1994" .UC .SH NAME ls \- list contents of directory .SH SYNOPSIS .B ls [ .B \-acdfgiloqrstu1ACLFR ] name ... .br .SH DESCRIPTION For each directory argument, .I ls lists the contents of the directory; for each file argument, .I ls repeats its name and any other information requested. By default, the output is sorted alphabetically. When no argument is given, the current directory is listed. When several arguments are given, the arguments are first sorted appropriately, but file arguments are processed before directories and their contents. .PP There are a large number of options: .TP .B \-l List in long format, giving mode, number of links, owner, size in bytes, and time of last modification for each file. (See below.) If the file is a special file the size field will instead contain the major and minor device numbers. If the file is a symbolic link the pathname of the linked-to file is printed preceded by ``\->''. .TP .B \-o Include the file flags in a long (\-l) output. .TP .B \-g Include the group ownership of the file in a long output. .TP .B \-t Sort by time modified (latest first) instead of by name. .TP .B \-a List all entries; in the absence of this option, entries whose names begin with a period .RB ( . ) are .I not listed. .TP .B \-s Give size in kilobytes of each file. .TP .B \-d If argument is a directory, list only its name; often used with \fB\-l\fR to get the status of a directory. .TP .B \-L If argument is a symbolic link, list the file or directory the link references rather than the link itself. .TP .B \-r Reverse the order of sort to get reverse alphabetic or oldest first as appropriate. .TP .B \-u Use time of last access instead of last modification for sorting (with the \fB\-t\fP option) and/or printing (with the \fB\-l\fP option). .TP .B \-c Use time of file creation for sorting or printing. .TP .B \-i For each file, print the i-number in the first column of the report. .TP .B \-f Output is not sorted. .TP .B \-F cause directories to be marked with a trailing `/', sockets with a trailing `=', symbolic links with a trailing `@', and executable files with a trailing `*'. .TP .B \-R recursively list subdirectories encountered. .TP .B \-1 force one entry per line output format; this is the default when output is not to a terminal. .TP .B \-C force multi-column output; this is the default when output is to a terminal. .TP .B \-q force printing of non-graphic characters in file names as the character `?'; this is the default when output is to a terminal. .PP The mode printed under the .B \-l option contains 11 characters which are interpreted as follows: the first character is .TP 3 .B d if the entry is a directory; .br .ns .TP 3 .B b if the entry is a block-type special file; .br .ns .TP 3 .B c if the entry is a character-type special file; .br .ns .TP 3 .B l if the entry is a symbolic link; .br .ns .TP .B s if the entry is a socket, or .br .ns .TP 3 .B \- if the entry is a plain file. .PP The next 9 characters are interpreted as three sets of three bits each. The first set refers to owner permissions; the next refers to permissions to others in the same user-group; and the last to all others. Within each set the three characters indicate permission respectively to read, to write, or to execute the file as a program. For a directory, `execute' permission is interpreted to mean permission to search the directory. The permissions are indicated as follows: .TP 3 .B r if the file is readable; .br .ns .TP 3 .B w if the file is writable; .br .ns .TP 3 .B x if the file is executable; .br .ns .TP 3 .B \- if the indicated permission is not granted. .PP The group-execute permission character is given as .B s if the file has the set-group-id bit set; likewise the user-execute permission character is given as .B s if the file has the set-user-id bit set. .PP The last character of the mode (normally `x' or `\-') is .B t if the 1000 bit of the mode is on. See .IR chmod (1) for the meaning of this mode. .PP When the sizes of the files in a directory are listed, a total count of blocks, including indirect blocks is printed. .SH FILES /etc/passwd to get user id's for `ls \-l'. .br /etc/group to get group id's for `ls \-g'. .SH BUGS Newline and tab are considered printing characters in file names. .PP The output device is assumed to be 80 columns wide. .PP The option setting based on whether the output is a teletype is undesirable as ``ls\ \-s'' is much different than ``ls\ \-s\ |\ lpr''. On the other hand, not doing this setting would make old shell scripts which used .I ls almost certain losers. ================================================ FILE: share/man/man1/lxref.1 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)lxref.1 6.1 (Berkeley) 4/29/85 .\" .TH LXREF 1 "April 29, 1985" .UC 4 .SH NAME lxref \- lisp cross reference program .SH SYNOPSIS .B lxref [ .B \-N ] xref-file ... [ .B \-a source-file ... ] .SH DESCRIPTION .I Lxref reads cross reference file(s) written by the lisp compiler .I liszt and prints a cross reference listing on the standard output. .I Liszt will create a cross reference file during compilation when it is given the .B \-x switch. Cross reference files usually end in `.x' and consequently .I lxref will append a `.x' to the file names given if necessary. The first option to .I lxref is a decimal integer, N, which sets the .I ignorelevel. If a function is called more than .I ignorelevel times, the cross reference listing will just print the number of calls instead of listing each one of them. The default for .I ignorelevel is 50. .PP The .B \-a option causes .I lxref to put limited cross reference information in the sources named. .I lxref will scan the source and when it comes across a definition of a function (that is a line beginning with .I "`(def'" it will preceed that line with a list of the functions which call this function, written as a comment preceeded by .I "`;.. '". All existing lines beginning with .I "`;.. '" will be removed from the file. If the source file contains a line beginning .I "`;.-'" then this will disable this annotation process from this point on until a .I "`;.+'" is seen (however, lines beginning with .I "`;.. '" will continue to be deleted). After the annoation is done, the original file .I "`foo.l'" is renamed to .I `#.foo.l'" and the new file with annotation is named .I "`foo.l'" .SH AUTHOR John Foderaro .SH SEE ALSO lisp(1), liszt(1) .SH BUGS ================================================ FILE: share/man/man1/m4.1 ================================================ .\" @(#)m4.1 1.0 (2.11BSD GTE) 4/14/94 .\" .TH M4 1 "April 14, 1994" .UC 2 .SH NAME m4 \- macro processor .SH SYNOPSIS m4 [ -D\fBname\fP[\fB=value\fP]] [-U\fBname\fP] [files ...] .SH DESCRIPTION .I m4 is a macro processor intended as a front end for any language (e.g., C, ratfor, fortran, lex, and yacc). \fIm4\fP reads from the standard input and writes the processed text to the standard output. Each of the optional argument files is processed in order. .PP Macro calls have the form .PP name(arg1,arg2, . . . , argn) .br .PP The `(' must immediately follow the name of the macro. If a defined macro name is not followed by a `(', it is deemed to have no arguments. Leading unquoted blanks, tabs, and newlines are ignored while collecting arguments. Potential macro names consist of alphabetic letters, digits, and underscore `\_', where the first character is not a digit. .PP Left and right single quotes (\`\|\') are used to quote strings. The value of a quoted string is the string stripped of the quotes. .PP When a macro name is recognized, its arguments are collected by searching for a matching right parenthesis. Macro evaluation proceeds normally during the collection of the arguments, and any commas or right parentheses which happen to turn up within the value of a nested call are as effective as those in the original input text. After argument collection, the value of the macro is pushed back onto the input stream and rescanned. .TP 10 -D\fBname\fP[\fB=value\fP] Define the symbol \fBname\fP to have some value (or NULL). .TP 10 -U\fBname\fP Undefine the symbol \fBname\fP. .PP .I m4 makes available the following built-in macros. They may be redefined, but once this is done the original meaning is lost. Their values are null unless otherwise stated. .TP 10 .B define The second argument is installed as the value of the macro whose name is the first argument. Each occurrence of $\fIn\fR in the replacement text, where .I n is a digit, is replaced by the .IR n -th argument. Argument 0 is the name of the macro; missing arguments are replaced by the null string. .TP .B undefine removes the definition of the macro named in its argument. .TP .B ifdef If the first argument is defined, the value is the second argument, otherwise the third. If there is no third argument, the value is null. .TP .B changecom Change the start and end comment sequences. The default is the pound sign '#' and the newline character. With no arguments comments are turned off. The maximum legnth for a comment marker is five characters. .TP .B changequote Change quote characters to the first and second arguments. .I Changequote without arguments restores the original values (i.e., \`\|\'). .TP .B decr Decrements the argument by 1. The argument must be a valid numeric string. .TP .B divert .I m4 maintains 10 output streams, numbered 0-9. The final output is the concatenation of the streams in numerical order; initially stream 0 is the current stream. The .I divert macro changes the current output stream to its (digit-string) argument. Output diverted to a stream other than 0 through 9 is discarded. .TP .B undivert causes immediate output of text from diversions named as arguments, or all diversions if no argument. Text may be undiverted into another diversion. Undiverting discards the diverted text. .TP .B defn Returns the quoted definition for each argument. This can be used to rename macro definitions (even for builtin macros). .TP .B divnum returns the value of the current output stream. .TP .B dnl reads and discards characters up to and including the next newline. .TP .B expr This is an alias for eval. .TP .B ifelse has three or more arguments. If the first argument is the same string as the second, then the value is the third argument. If not, and if there are more than four arguments, the process is repeated with arguments 4, 5, 6 and 7. Otherwise, the value is either the fourth string, or, if it is not present, null. .TP .B incr returns the value of its argument incremented by 1. The value of the argument is calculated by interpreting an initial digit-string as a decimal number. .TP .B eval evaluates its argument as an arithmetic expression, using 32-bit arithmetic. Operators include +, \-, \(**, /, %, ^ (exponentiation); relationals; parentheses. .TP .B len returns the number of characters in its argument. .TP .B m4exit Immediately exits with the return value specified by the first argument, 0 if none. .TP .B m4wrap Allows you to define what happens at the final EOF, usually for cleanup purposes. (e.g., m4wrap("cleanup(tempfile)") causes the macro cleanup to be invoked after all processing is done.) .TP .B index returns the position in its first argument where the second argument begins (zero origin), or \-1 if the second argument does not occur. .TP .B substr returns a substring of its first argument. The second argument is a zero origin number selecting the first character; the third argument indicates the length of the substring. A missing third argument is taken to be large enough to extend to the end of the first string. .TP .B translit transliterates the characters in its first argument from the set given by the second argument to the set given by the third. No abbreviations are permitted. .TP .B include returns the contents of the file named in the argument. .TP .B sinclude is identical to .I include, except that it says nothing if the file is inaccessible. .TP .B syscmd executes the UNIX command given in the first argument. No value is returned. .TP .B maketemp fills in a string of XXXXX in its argument with the current process id. .TP .B paste Includes the contents of the file specified by the first argument without any macro processing. Aborts with an error message if the file cannot be included. .TP .B popdef Restores the pushdef'd definition for each argument. .TP .B pushdef Takes the same arguments as define, but it saves the definition on a stack for later retrieval by popdef. .TP .B shift Returns all but the first argument, the remaining arguments are quoted and pushed back with commas in between. The quoting nullifies the effect of the extra scan that will subsequently be performed. .TP .B spaste Similar to paste, except it ignores any errors. .TP .B syscal Returns the return value from the last syscmd. .TP .B errprint prints its argument on the diagnostic output file. .TP .B dumpdef prints current names and definitions, for the named items, or for all if no arguments are given. .TP .B unix A pre-defined macro for testing the OS platform. .SH "SEE ALSO" .DT B. W. Kernighan and D. M. Ritchie, .I The m4 Macro Processor .SH HISTORY An m4 command appeared in Version 6 AT&T UNIX. .SH AUTHOR Ozan Yigit ================================================ FILE: share/man/man1/mail.1 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)mail.1 6.6.1 (2.11BSD) 1996/10/22 .\" .TH MAIL 1 "October 22, 1996" .UC 4 .SH NAME mail \- send and receive mail .SH SYNOPSIS .B mail [ .B \-v ] [ .B \-i ] [ .B \-n ] [ .B \-s subject ] [ user ... ] .br .B mail [ .B \-v ] [ .B \-i ] [ .B \-n ] .B \-f [ name ] .br .B mail [ .B \-v ] [ .B \-i ] [ .B \-n ] .B \-u user .SH INTRODUCTION .I Mail is a intelligent mail processing system, which has a command syntax reminiscent of .I ed with lines replaced by messages. .PP The .B \-v flag puts mail into verbose mode; the details of delivery are displayed on the users terminal. The .B \-i flag causes tty interrupt signals to be ignored. This is particularly useful when using .I mail on noisy phone lines. The .B \-n flag inhibits the reading of /etc/Mail.rc. .PP .I "Sending mail.\ " To send a message to one or more people, .I mail can be invoked with arguments which are the names of people to whom the mail will be sent. You are then expected to type in your message, followed by an \s-2EOT\s0 (control\-D) at the beginning of a line. A subject may be specified on the command line by using the .B \-s flag. (Only the first argument after the .B \-s flag is used as a subject; be careful to quote subjects containing spaces.) The section below, labeled .I "Replying to or originating mail," describes some features of .I mail available to help you compose your letter. .PP .I "Reading mail.\ " In normal usage .I mail is given no arguments and checks your mail out of the post office, then prints out a one line header of each message there. The current message is initially the first message (numbered 1) and can be printed using the .B print command (which can be abbreviated \fBp\fR). You can move among the messages much as you move between lines in .IR ed , with the commands `+' and `\-' moving backwards and forwards, and simple numbers. .PP .I "Disposing of mail.\ " After examining a message you can .B delete (\fBd\fR) the message or .B reply (\fBr\fR) to it. Deletion causes the .I mail program to forget about the message. This is not irreversible; the message can be .B undeleted (\fBu\fR) by giving its number, or the .I mail session can be aborted by giving the .B exit (\fBx\fR) command. Deleted messages will, however, usually disappear never to be seen again. .PP .I "Specifying messages.\ " Commands such as .B print and .B delete can be given a list of message numbers as arguments to apply to a number of messages at once. Thus ``delete 1 2'' deletes messages 1 and 2, while ``delete 1\-5'' deletes messages 1 through 5. The special name ``*'' addresses all messages, and ``$'' addresses the last message; thus the command .B top which prints the first few lines of a message could be used in ``top *'' to print the first few lines of all messages. .PP .I "Replying to or originating mail.\ " You can use the .B reply command to set up a response to a message, sending it back to the person who it was from. Text you then type in, up to an end-of-file, defines the contents of the message. While you are composing a message, .I mail treats lines beginning with the character `~' specially. For instance, typing ``~m'' (alone on a line) will place a copy of the current message into the response right shifting it by a tabstop. Other escapes will set up subject fields, add and delete recipients to the message and allow you to escape to an editor to revise the message or to a shell to run some commands. (These options are given in the summary below.) .PP .I "Ending a mail processing session.\ " You can end a .I mail session with the .B quit (\fBq\fR) command. Messages which have been examined go to your .I mbox file unless they have been deleted in which case they are discarded. Unexamined messages go back to the post office. The .B \-f option causes .I mail to read in the contents of your .I mbox (or the specified file) for processing; when you .BR quit , .I mail writes undeleted messages back to this file. The .B \-u flag is a short way of doing "mail .B \-f /usr/spool/mail/user". .PP .I "Personal and systemwide distribution lists.\ " It is also possible to create a personal distribution lists so that, for instance, you can send mail to ``cohorts'' and have it go to a group of people. Such lists can be defined by placing a line like .IP alias cohorts bill ozalp jkf mark kridle@ucbcory .PP in the file \&.mailrc in your home directory. The current list of such aliases can be displayed with the .B alias .B (a) command in .IR mail . System wide distribution lists can be created by editing /etc/aliases, see .IR aliases (5) and .IR sendmail (8); these are kept in a different syntax. In mail you send, personal aliases will be expanded in mail sent to others so that they will be able to \fBreply\fR to the recipients. System wide \fIaliases\fR are not expanded when the mail is sent, but any reply returned to the machine will have the system wide alias expanded as all mail goes through .IR sendmail . .PP .I "Network mail (ARPA, UUCP, Berknet)\ " See .IR mailaddr(7) for a description of network addresses. .PP .I Mail has a number of options which can be set in the .I \&.mailrc file to alter its behavior; thus ``set askcc'' enables the ``askcc'' feature. (These options are summarized below.) .SH SUMMARY (Adapted from the `Mail Reference Manual') .PP Each command is typed on a line by itself, and may take arguments following the command word. The command need not be typed in its entirety \- the first command which matches the typed prefix is used. For commands which take message lists as arguments, if no message list is given, then the next message forward which satisfies the command's requirements is used. If there are no messages forward of the current message, the search proceeds backwards, and if there are no good messages at all, .I mail types ``No applicable messages'' and aborts the command. .TP 12n .B \- Goes to the previous message and prints it out. If given a numeric argument .IR n , goes to the .IR n -th previous message and prints it. .TP .B ? Prints a brief summary of commands. .TP .B ! Executes the \s-2UNIX\s0 shell command which follows. .TP .B Print (\fBP\fR) Like .B print but also prints out ignored header fields. See also .B print , .B ignore and .B retain. .TP .B Reply (\fBR\fR) Reply to originator. Does not reply to other recipients of the original message. .TP .B Type (\fBT\fR) Identical to the .B Print command. .TP .B alias (\fBa\fR) With no arguments, prints out all currently-defined aliases. With one argument, prints out that alias. With more than one argument, creates an new or changes an on old alias. .TP .B alternates (\fBalt\fR) The .B alternates command is useful if you have accounts on several machines. It can be used to inform .I mail that the listed addresses are really you. When you .B reply to messages, .I mail will not send a copy of the message to any of the addresses listed on the .I alternates list. If the .B alternates command is given with no argument, the current set of alternate names is displayed. .TP .B chdir (\fBc\fR) Changes the user's working directory to that specified, if given. If no directory is given, then changes to the user's login directory. .TP .B copy (\fBco\fR) The .B copy command does the same thing that .B save does, except that it does not mark the messages it is used on for deletion when you quit. .TP .B delete (\fBd\fR) Takes a list of messages as argument and marks them all as deleted. Deleted messages will not be saved in .IR mbox , nor will they be available for most other commands. .TP .B dp (also \fBdt\fR) Deletes the current message and prints the next message. If there is no next message, .I mail says ``at EOF.'' .TP .B edit (\fBe\fR) Takes a list of messages and points the text editor at each one in turn. On return from the editor, the message is read back in. .TP .B exit (\fBex\fR or \fBx\fR) Effects an immediate return to the Shell without modifying the user's system mailbox, his .I mbox file, or his edit file in .BR \-f . .TP .B file (\fBfi\fR) The same as .BR folder . .TP .B folders List the names of the folders in your folder directory. .TP .B folder (\fBfo\fR) The .B folder command switches to a new mail file or folder. With no arguments, it tells you which file you are currently reading. If you give it an argument, it will write out changes (such as deletions) you have made in the current file and read in the new file. Some special conventions are recognized for the name. # means the previous file, % means your system mailbox, %user means user's system mailbox, & means your \~/mbox file, and +folder means a file in your folder directory. .TP .B from (\fBf\fR) Takes a list of messages and prints their message headers. .TP .B headers (\fBh\fR) Lists the current range of headers, which is an 18 message group. If a ``+'' argument is given, then the next 18 message group is printed, and if a ``\-'' argument is given, the previous 18 message group is printed. .TP .B help A synonym for ? .TP .B hold (\fBho\fR, also \fBpreserve\fR) Takes a message list and marks each message therein to be saved in the user's system mailbox instead of in .IR mbox . Does not override the .B delete command. .TP .B ignore .B N.B.: .I Ignore has been superseded by .I retain. .br Add the list of header fields named to the .IR "ignored list" . Header fields in the ignore list are not printed on your terminal when you print a message. This command is very handy for suppression of certain machine-generated header fields. The .B Type and .B Print commands can be used to print a message in its entirety, including ignored fields. If .B ignore is executed with no arguments, it lists the current set of ignored fields. .TP .B mail (\fBm\fR) Takes as argument login names and distribution group names and sends mail to those people. .TP .B mbox Indicate that a list of messages be sent to .I mbox in your home directory when you quit. This is the default action for messages if you do .I not have the .I hold option set. .TP .B next (\fBn\fR like \fB+\fR or CR) Goes to the next message in sequence and types it. With an argument list, types the next matching message. .TP .B preserve (\fBpre\fR) A synonym for .BR hold . .TP .B print (\fBp\fR) Takes a message list and types out each message on the user's terminal. .TP .B quit (\fBq\fR) Terminates the session, saving all undeleted, unsaved messages in the user's .I mbox file in his login directory, preserving all messages marked with .B hold or .B preserve or never referenced in his system mailbox, and removing all other messages from his system mailbox. If new mail has arrived during the session, the message ``You have new mail'' is given. If given while editing a mailbox file with the .B \-f flag, then the edit file is rewritten. A return to the Shell is effected, unless the rewrite of edit file fails, in which case the user can escape with the .B exit command. .TP .B reply (\fBr\fR) Takes a message list and sends mail to the sender and all recipients of the specified message. The default message must not be deleted. .TP .B respond A synonym for .BR reply . .TP .B retain Add the list of header fields named to the .IR "retained list" . Only the header fields in the retain list are shown on your terminal when you print a message. All other header fields are suppressed. The .B Type and .B Print commands can be used to print a message in its entirety. If .B retain is executed with no arguments, it lists the current set of retained fields. .TP .B save (\fBs\fR) Takes a message list and a filename and appends each message in turn to the end of the file. The filename in quotes, followed by the line count and character count is echoed on the user's terminal. .TP .B set (\fBse\fR) With no arguments, prints all variable values. Otherwise, sets option. Arguments are of the form ``option=value'' (no space before or after =) or ``option.'' .TP .B shell (\fBsh\fR) Invokes an interactive version of the shell. .TP .B size Takes a message list and prints out the size in characters of each message. .TP .B source (\fBso\fR) The .B source command reads .I mail commands from a file. .TP .B top Takes a message list and prints the top few lines of each. The number of lines printed is controlled by the variable .B toplines and defaults to five. .TP .B type (\fBt\fR) A synonym for .BR print . .TP .B unalias Takes a list of names defined by .B alias commands and discards the remembered groups of users. The group names no longer have any significance. .TP .B undelete (\fBu\fR) Takes a message list and marks each message as .I not being deleted. .TP .B unread (\fBU\fR) Takes a message list and marks each message as .I not having been read. .TP .B unset Takes a list of option names and discards their remembered values; the inverse of .BR set . .TP .B visual (\fBv\fR) Takes a message list and invokes the display editor on each message. .TP .B write (\fBw\fR) Similar to .BR save , except that .I only the message body (\fIwithout\fP the header) is saved. Extremely useful for such tasks as sending and receiving source program text over the message system. .TP .B xit (\fBx\fR) A synonym for .BR exit . .TP .B z .I Mail presents message headers in windowfuls as described under the .B headers command. You can move .IR mail 's attention forward to the next window with the .B z command. Also, you can move to the previous window by using .BR z\- . .PP Here is a summary of the tilde escapes, which are used when composing messages to perform special functions. Tilde escapes are only recognized at the beginning of lines. The name ``tilde\ escape'' is somewhat of a misnomer since the actual escape character can be set by the option .B escape. .TP 12n .BR ~! command Execute the indicated shell command, then return to the message. .TP \fB~b\fR name ... Add the given names to the list of carbon copy recipients but do not make the names visible in the Cc: line ("blind" carbon copy). .TP \fB~c\fR name ... Add the given names to the list of carbon copy recipients. .TP .B ~d Read the file ``dead.letter'' from your home directory into the message. .TP .B ~e Invoke the text editor on the message collected so far. After the editing session is finished, you may continue appending text to the message. .TP \fB~f\fR messages Read the named messages into the message being sent. If no messages are specified, read in the current message. .TP .B ~h Edit the message header fields by typing each one in turn and allowing the user to append text to the end or modify the field by using the current terminal erase and kill characters. .TP \fB~m\fR messages Read the named messages into the message being sent, shifted right one tab. If no messages are specified, read the current message. .TP .B ~p Print out the message collected so far, prefaced by the message header fields. .TP .B ~q Abort the message being sent, copying the message to ``dead.letter'' in your home directory if .B save is set. .TP \fB~r\fR filename Read the named file into the message. .TP \fB~s\fR string Cause the named string to become the current subject field. .TP \fB~t\fR name ... Add the given names to the direct recipient list. .TP .B ~v Invoke an alternate editor (defined by the VISUAL option) on the message collected so far. Usually, the alternate editor will be a screen editor. After you quit the editor, you may resume appending text to the end of your message. .TP \fB~w\fR filename Write the message onto the named file. .TP \fB~\||\|\fRcommand Pipe the message through the command as a filter. If the command gives no output or terminates abnormally, retain the original text of the message. The command .IR fmt (1) is often used as .I command to rejustify the message. .TP .BR ~~ string Insert the string of text in the message prefaced by a single ~. If you have changed the escape character, then you should double that character in order to send it. .PP Options are controlled via the .B set and .B unset commands. Options may be either binary, in which case it is only significant to see whether they are set or not; or string, in which case the actual value is of interest. The binary options include the following: .TP 15n .B append Causes messages saved in .I mbox to be appended to the end rather than prepended. (This is set in /etc/Mail.rc on 2.11BSD systems.) .TP .B ask Causes .I mail to prompt you for the subject of each message you send. If you respond with simply a newline, no subject field will be sent. .TP .B askcc Causes you to be prompted for additional carbon copy recipients at the end of each message. Responding with a newline indicates your satisfaction with the current list. .TP .B autoprint Causes the .B delete command to behave like .B dp \- thus, after deleting a message, the next one will be typed automatically. .TP .B debug Setting the binary option .I debug is the same as specifying .B \-d on the command line and causes .I mail to output all sorts of information useful for debugging .IR mail . .TP .B dot The binary option .I dot causes .I mail to interpret a period alone on a line as the terminator of a message you are sending. .TP .B hold This option is used to hold messages in the system mailbox by default. .TP .B ignore Causes interrupt signals from your terminal to be ignored and echoed as @'s. .TP .B ignoreeof An option related to .I dot is .I ignoreeof which makes .I mail refuse to accept a control-d as the end of a message. .I Ignoreeof also applies to .I mail command mode. .TP .B metoo Usually, when a group is expanded that contains the sender, the sender is removed from the expansion. Setting this option causes the sender to be included in the group. .TP .B nosave Normally, when you abort a message with two \s-2RUBOUT\s0, .I mail copies the partial letter to the file ``dead.letter'' in your home directory. Setting the binary option .I nosave prevents this. .TP .B Replyall Reverses the sense of .I reply and .I Reply commands. .TP .B quiet Suppresses the printing of the version when first invoked. .TP .B verbose Setting the option .I verbose is the same as using the .B \-v flag on the command line. When mail runs in verbose mode, the actual delivery of messages is displayed on he users terminal. .PP The following options have string values: .TP 15n EDITOR Pathname of the text editor to use in the .B edit command and ~e escape. If not defined, then a default editor is used. .TP PAGER Pathname of the program to use in the .B more command or when .I crt variable is set. A default paginator is used if this option is not defined. .TP SHELL Pathname of the shell to use in the .B ! command and the ~! escape. A default shell is used if this option is not defined. .TP VISUAL Pathname of the text editor to use in the .B visual command and ~v escape. .TP .B crt The valued option .I crt is used as a threshold to determine how long a message must be before .B PAGER is used to read it. .TP .B escape If defined, the first character of this option gives the character to use in the place of ~ to denote escapes. .TP .B folder The name of the directory to use for storing folders of messages. If this name begins with a `/', .I mail considers it to be an absolute pathname; otherwise, the folder directory is found relative to your home directory. .TP .B record If defined, gives the pathname of the file used to record all outgoing mail. If not defined, then outgoing mail is not so saved. .TP .B toplines If defined, gives the number of lines of a message to be printed out with the .B top command; normally, the first five lines are printed. .SH FILES .if n .ta 2.5i .if t .ta 1.8i /usr/spool/mail/* post office .br ~/mbox your old mail .br ~/.mailrc file giving initial mail commands .br /tmp/R# temporary for editor escape .br /usr/share/misc/Mail.help* help files .br /etc/Mail.rc system initialization file .br Message* temporary for editing messages .SH "SEE ALSO" binmail(1), fmt(1), newaliases(1), aliases(5), .br mailaddr(7), sendmail(8) .br `The Mail Reference Manual' .SH BUGS There are many flags that are not documented here. Most are not useful to the general user. .br Usually, .I mail is just a link to .IR Mail , which can be confusing. .SH AUTHOR Kurt Shoens ================================================ FILE: share/man/man1/make.1 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)make.1 6.4 (Berkeley) 8/15/87 .\" .TH MAKE 1 "August 15, 1987" .UC 4 .SH NAME make \- maintain program groups .SH SYNOPSIS .B make [ .B \-f makefile ] [ option ] ... file ... .SH DESCRIPTION .I Make executes commands in .I makefile to update one or more target .IR names . .I Name is typically a program. If no .B \-f option is present, `makefile' and `Makefile' are tried in order. If .I makefile is `\-', the standard input is taken. More than one .B \-f option may appear. .PP .I Make updates a target if it depends on prerequisite files that have been modified since the target was last modified, or if the target does not exist. .PP .I Makefile contains a sequence of entries that specify dependencies. The first line of an entry is a blank-separated list of targets, then a colon, then a list of prerequisite files. Text following a semicolon, and all following lines that begin with a tab, are shell commands to be executed to update the target. If a name appears on the left of more than one `colon' line, then it depends on all of the names on the right of the colon on those lines, but only one command sequence may be specified for it. If a name appears on a line with a double colon .B "::" then the command sequence following that line is performed only if the name is out of date with respect to the names to the right of the double colon, and is not affected by other double colon lines on which that name may appear. .PP The special form of the name: .IR a ( b ) means the file named .I b stored in the archive named .I a. .PP Sharp and newline surround comments. .PP The following makefile says that `pgm' depends on two files `a.o' and `b.o', and that they in turn depend on `.c' files and a common file `incl'. .RS .HP .PD 0 .nf pgm: a.o b.o cc a.o b.o \-lm \-o pgm .HP a.o: incl a.c cc \-c a.c .HP b.o: incl b.c cc \-c b.c .fi .RE .PD .PP .I Makefile entries of the form .PP .IP string1 = string2 .PP are macro definitions. Subsequent appearances of .RI $( string1 ) or .RI ${ string1 } are replaced by .IR string2 . If .I string1 is a single character, the parentheses or braces are optional. .PP All environment variables are assumed to be macro definitions and processed as such. The environment variables are processed before any .I makefile macro definitions; thus, macro assignments in a makefile override environmental variables. The .B \-e option causes the environment to override the macro assignments in a makefile. Finally, command line options of the form .I string1=string2 override both environment and makefile macro definitions. .PP .I Make infers prerequisites for files for which .I makefile gives no construction commands. For example, a `.c' file may be inferred as prerequisite for a `.o' file and be compiled to produce the `.o' file. Thus the preceding example can be done more briefly: .RS .HP .PD 0 .nf pgm: a.o b.o cc a.o b.o \-lm \-o pgm .HP a.o b.o: incl .fi .RE .PD .PP Prerequisites are inferred according to selected suffixes listed as the `prerequisites' for the special name `.SUFFIXES'; multiple lists accumulate; an empty list clears what came before. Order is significant; the first possible name for which both a file and a rule as described in the next paragraph exist is inferred. The default list is .IP \&.SUFFIXES: .out .o .c .e .r .f .y .l .s .p .PP The rule to create a file with suffix .I s2 that depends on a similarly named file with suffix .I s1 is specified as an entry for the `target' .IR s1s2 . In such an entry, the special macro $* stands for the target name with suffix deleted, $@ for the full target name, $< for the complete list of prerequisites, and $? for the list of prerequisites that are out of date. For example, a rule for making optimized `.o' files from `.c' files is .IP \&.c.o: ; cc \-c \-O \-o $@ $*.c .PP Certain macros are used by the default inference rules to communicate optional arguments to any resulting compilations. In particular, `CFLAGS' is used for .IR cc (1) options, `FFLAGS' for .IR f77 (1) options, `PFLAGS' for .IR pc (1) options, and `LFLAGS' and `YFLAGS' for .I lex and .IR yacc (1) options. In addition, the macro `MFLAGS' is filled in with the initial command line options supplied to .IR make . This simplifies maintaining a hierarchy of makefiles as one may then invoke .I make on makefiles in subdirectories and pass along useful options such as .BR \-k . .PP Another special macro is `VPATH'. The `VPATH' macro should be set to a list of directories separated by colons. When .I make searches for a file as a result of a dependency relation, it will first search the current directory and then each of the directories on the `VPATH' list. If the file is found, the actual path to the file will be used, rather than just the filename. If `VPATH' is not defined, then only the current directory is searched. .PP One use for `VPATH' is when one has several programs that compile from the same source. The source can be kept in one directory and each set of object files (along with a separate .IR makefile ) would be in a separate subdirectory. The `VPATH' macro would point to the source directory in this case. .PP Command lines are executed one at a time, each by its own shell. A line is printed when it is executed unless the special target `.SILENT' is in .I makefile, or the first character of the command is `@'. .PP Commands returning nonzero status (see .IR intro (1)) cause .I make to terminate unless the special target `.IGNORE' is in .I makefile or the command begins with . .PP Interrupt and quit cause the target to be deleted unless the target is a directory or depends on the special name `.PRECIOUS'. .PP Other options: .TP .B \-e Environmental variables override assignments within makefiles. .TP .B \-i Equivalent to the special entry `.IGNORE:'. .TP .B \-k When a command returns nonzero status, abandon work on the current entry, but continue on branches that do not depend on the current entry. .TP .B \-n Trace and print, but do not execute the commands needed to update the targets. .TP .B \-t Touch, i.e. update the modified date of targets, without executing any commands. .TP .B \-r Equivalent to an initial special entry `.SUFFIXES:' with no list. .TP .B \-s Equivalent to the special entry `.SILENT:'. .SH FILES makefile, Makefile .br .SH "SEE ALSO" sh(1), touch(1), f77(1), pc(1), getenv(3) .br S. I. Feldman .I Make \- A Program for Maintaining Computer Programs .SH BUGS Some commands return nonzero status inappropriately. Use .B \-i to overcome the difficulty. .br Commands that are directly executed by the shell, notably .IR cd (1), are ineffectual across newlines in .I make. .PP `VPATH' is intended to act like the System V `VPATH' support, but there is no guarantee that it functions identically. ================================================ FILE: share/man/man1/man.1 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)man.1 6.7 (Berkeley) 4/19/88 .\" .TH MAN 1 "April 19, 1988" .UC 4 .SH NAME man \- print out the manual .SH SYNOPSIS .br .B man [ .B \- ] [ .B -a ] [ .B \-M .I path ] [ section ] title ... .SH DESCRIPTION \fIMan\fP is the program which provides on-line access to the UNIX manual. If a \fIsection\fP specifier is given, \fIman\fP looks in that section of the manual for the given \fItitle\fP(s). \fISection\fP is either an Arabic section number (``3'' for example), or one of the words ``local'', ``new,'' or ``old''. (The abbreviations ``l'', ``n'', and ``o'' are also allowed.) If \fIsection\fP is omitted, \fIman\fP searches all sections of the manual, giving preference to commands over library subroutines, and displays the first manual page it finds, if any. If the \fI-a\fP option is supplied, \fIman\fP displays all applicable manual pages. .PP Normally \fIman\fP checks in standard locations (/usr/man and /usr/local/man) for manual information. This can be changed by supplying a search path (a la the Bourne shell) with the \fB-M\fP flag. The search path is a colon (``:'') separated list of directories in which \fIman\fP expects to find the standard manual subdirectories. This search path can also be set with the environmental variable \fIMANPATH\fP. .PP Since some manual pages are intended for use only on certain machines, \fIman\fP only searches those directories applicable to the current machine. \fIMan\fP's determination of the current machine type can be overridden by setting the environmental variable \fIMACHINE\fP. .PP If the standard output is a teletype, and the \fB-\fP flag is not provided, \fIman\fP uses \fImore\fP(1), or the pager provided by the environmental variable \fIPAGER\fP, to display the manual page. .PP The FORTRAN version of section 3 of the manual may be specified by supplying \fIman\fP with the \fIsection\fP ``3f''. Also, a specific section of the local manual may be specified by appending a number to the \fIsection\fP, i.e. ``l5'' would indicate section 5 of the local manual. .SH FILES .nf .ta \w'/usr/local/man/man?/* 'u /usr/man standard manual area /usr/man/cat?/* directories containing standard manual pages /usr/local/man/cat?/* directories containing local manual pages /usr/src/man directories containing unformatted manual pages .fi .SH SEE\ ALSO apropos(1), more(1), whatis(1), whereis(1) .SH BUGS The manual is supposed to be reproducible either on the phototypesetter or on a typewriter, however, on a typewriter, some information is necessarily lost. ================================================ FILE: share/man/man1/mesg.1 ================================================ .\" @(#)mesg.1 6.1 (Berkeley) 4/29/85 .\" .TH MESG 1 "April 29, 1985" .AT 3 .SH NAME mesg \- permit or deny messages .SH SYNOPSIS .B mesg [ .B n ] [ .B y ] .SH DESCRIPTION .I Mesg with argument .B n forbids messages via .I write and .IR talk (1) by revoking non-user write permission on the user's terminal. .I Mesg with argument .B y reinstates permission. All by itself, .I mesg reports the current state without changing it. .SH FILES /dev/tty* .SH "SEE ALSO" write(1), talk(1) .SH DIAGNOSTICS Exit status is 0 if messages are receivable, 1 if not, 2 on error. ================================================ FILE: share/man/man1/mkdep.1 ================================================ .\" Copyright (c) 1987 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)mkdep.1 1.3 (Berkeley) 6/4/87 .\" .TH MKDEP 1 "June 4, 1987" .UC 5 .SH NAME mkdep \- construct Makefile dependency list .SH SYNOPSIS .B mkdep [ .B \-f makefile ] [ .B \-p ] flags file ... .SH DESCRIPTION \fIMkdep\fP takes a set of flags for the C compiler and a list of C source files as arguments and constructs a set of include file dependencies. It attaches this dependency list to the end of the file ``Makefile''. An example of its use in a makefile might be: .nf .RS CFLAGS= -O -I../include -I. SRCS= file1.c file2.c depend: mkdep ${CFLAGS} ${SRCS} .RE .PP where the macro SRCS is the list of C source files and the macro CFLAGS is the list of flags for the C compiler. The \fB-f\fP option provides \fImkdep\fP with a name other than ``Makefile'' to be edited. If the \fB-p\fP option is provided, \fImkdep\fP produces dependencies of the form ``program: program.c'' so that subsequent makes will produce \fIprogram\fP directly from its C module rather than using an intermediate \fI.o\fP module. This is useful in directories that contain many programs, each of whose source is contained in a single C module. .SH "SEE ALSO" cc(1), make(1) ================================================ FILE: share/man/man1/mkdir.1 ================================================ .\" Copyright (c) 1989, 1990 The Regents of the University of California. .\" All rights reserved. .\" .\" This code is derived from software contributed to Berkeley by .\" the Institute of Electrical and Electronics Engineers, Inc. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. All advertising materials mentioning features or use of this software .\" must display the following acknowledgement: .\" This product includes software developed by the University of .\" California, Berkeley and its contributors. .\" 4. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)mkdir.1 6.10 (Berkeley) 7/27/91 .\" .TH MKDIR 1 "August 16, 1993" .UC 2 .SH NAME mkdir \- make directories .SH SYNOPSIS mkdir [ \-p \fBdirectory_name\fP ... ] .SH DESCRIPTION Mkdir creates the directories named as operands, in the order specified, using mode \&0777 modified by the current umask(2). .PP The options are as follows: .TP \-p Create intermediate directories as required. If this option is not specified, the full path prefix of each operand must already exist. .TP The user must have write permission in the parent directory. .PP Mkdir exits 0 if successful, and >0 if an error occurred. .SH SEE ALSO rmdir(1) .SH STANDARDS Mkdir is POSIX 1003.2 compliant. This manual page is derived from the POSIX 1003.2 manual page. ================================================ FILE: share/man/man1/mkstr.1 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)mkstr.1 6.2.1 (2.11BSD) 1996/10/22 .\" .TH MKSTR 1 "October 22, 1996" .UC .SH NAME mkstr \- create an error message file by massaging C source .SH SYNOPSIS .B mkstr [ .B \- ] messagefile prefix file ... .SH DESCRIPTION .I Mkstr is used to create files of error messages. Its use can make programs with large numbers of error diagnostics much smaller, and reduce system overhead in running the program as the error messages do not have to be constantly swapped in and out. .PP .I Mkstr will process each of the specified .I files, placing a massaged version of the input file in a file whose name consists of the specified .I prefix and the original name. A typical usage of .I mkstr would be .DT .PP mkstr pistrings xx *.c .PP This command would cause all the error messages from the C source files in the current directory to be placed in the file .I pistrings and processed copies of the source for these files to be placed in files whose names are prefixed with .I xx. .PP To process the error messages in the source to the message file .I mkstr keys on the string \%`error("' in the input stream. Each time it occurs, the C string starting at the `"' is placed in the message file followed by a null character and a new-line character; the null character terminates the message so it can be easily used when retrieved, the new-line character makes it possible to sensibly .I cat the error message file to see its contents. The massaged copy of the input file then contains a .I lseek pointer into the file which can be used to retrieve the message, i.e.: .IP .DT .nf \fBchar\fR efilname[] = "/usr/share/pascal/pi_strings"; \fBint\fR efil = -1; .sp error(a1, a2, a3, a4) { \fBchar\fR buf[256]; \fBif\fR (efil < 0) { efil = open(efilname, 0); \fBif\fR (efil < 0) { oops: perror(efilname); exit(1); } } \fBif\fR (lseek(efil, (long) a1, 0) |\|| read(efil, buf, 256) <= 0) \fBgoto\fR oops; printf(buf, a2, a3, a4); } .fi .PP The optional .B \- causes the error messages to be placed at the end of the specified message file for recompiling part of a large .IR mkstr \|ed program. .SH SEE\ ALSO lseek(2), xstr(1) ================================================ FILE: share/man/man1/more.1 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)more.1 6.4.1 (2.11BSD) 1996/10/22 .\" .TH MORE 1 "October 22, 1996" .UC 4 .SH NAME more, page \- file perusal filter for crt viewing .SH SYNOPSIS .B more [ .B \-cdflsu ] [ .B \-\fIn\fP ] [ .B +\fIlinenumber\fP ] [ .B +/\fIpattern\fP ] [ name ... ] .LP .B page .I "more options" .SH DESCRIPTION .I More is a filter which allows examination of a continuous text one screenful at a time on a soft-copy terminal. It normally pauses after each screenful, printing --More-- at the bottom of the screen. If the user then types a carriage return, one more line is displayed. If the user hits a space, another screenful is displayed. Other possibilities are enumerated later. .PP The command line options are: .TP .I \-n An integer which is the size (in lines) of the window which .I more will use instead of the default. .TP .B \-c .I More will draw each page by beginning at the top of the screen and erasing each line just before it draws on it. This avoids scrolling the screen, making it easier to read while .I more is writing. This option will be ignored if the terminal does not have the ability to clear to the end of a line. .TP .B \-d .I More will prompt the user with the message "Press space to continue, \'q\' to quit." at the end of each screenful, and will respond to subsequent illegal user input by printing "Press \'h\' for instructions." instead of ringing the bell. This is useful if .I more is being used as a filter in some setting, such as a class, where many users may be unsophisticated. .TP .B \-f This causes .I more to count logical, rather than screen lines. That is, long lines are not folded. This option is recommended if .I nroff output is being piped through .I ul, since the latter may generate escape sequences. These escape sequences contain characters which would ordinarily occupy screen positions, but which do not print when they are sent to the terminal as part of an escape sequence. Thus .I more may think that lines are longer than they actually are, and fold lines erroneously. .TP .B \-l Do not treat ^\&L (form feed) specially. If this option is not given, .I more will pause after any line that contains a ^\&L, as if the end of a screenful had been reached. Also, if a file begins with a form feed, the screen will be cleared before the file is printed. .TP .B \-s Squeeze multiple blank lines from the output, producing only one blank line. Especially helpful when viewing .I nroff output, this option maximizes the useful information present on the screen. .TP .B \-u Normally, .I more will handle underlining such as produced by .I nroff in a manner appropriate to the particular terminal: if the terminal can perform underlining or has a stand-out mode, .I more will output appropriate escape sequences to enable underlining or stand-out mode for underlined information in the source file. The .I \-u option suppresses this processing. .TP .B +\fIlinenumber\fP Start up at \fIlinenumber\fP. .TP .B +/\fIpattern\fP Start up two lines before the line containing the regular expression \fIpattern\fP. .PP If the program is invoked as .I page, then the screen is cleared before each screenful is printed (but only if a full screenful is being printed), and .I k \- 1 rather than .I k \- 2 lines are printed in each screenful, where .I k is the number of lines the terminal can display. .PP .I More looks in the file .I /etc/termcap to determine terminal characteristics, and to determine the default window size. On a terminal capable of displaying 24 lines, the default window size is 22 lines. .PP .I More looks in the environment variable .I MORE to pre-set any flags desired. For example, if you prefer to view files using the .I \-c mode of operation, the .I csh command .I "setenv MORE -c" or the .I sh command sequence .I "MORE='-c' ; export MORE" would cause all invocations of .I more , including invocations by programs such as .I man and .I msgs , to use this mode. Normally, the user will place the command sequence which sets up the .I MORE environment variable in the .I .cshrc or .I .profile file. .PP If .I more is reading from a file, rather than a pipe, then a percentage is displayed along with the --More-- prompt. This gives the fraction of the file (in characters, not lines) that has been read so far. .PP Other sequences which may be typed when .I more pauses, and their effects, are as follows (\fIi\fP is an optional integer argument, defaulting to 1) : .PP .IP \fIi\|\fP display .I i more lines, (or another screenful if no argument is given) .PP .IP ^D display 11 more lines (a ``scroll''). If .I i is given, then the scroll size is set to \fIi\|\fP. .PP .IP d same as ^D (control-D) .PP .IP \fIi\|\fPz same as typing a space except that \fIi\|\fP, if present, becomes the new window size. .PP .IP \fIi\|\fPs skip \fIi\|\fP lines and print a screenful of lines .PP .IP \fIi\|\fPf skip \fIi\fP screenfuls and print a screenful of lines .PP .IP \fIi\|\fPb skip back \fIi\fP screenfuls and print a screenful of lines .PP .IP \fIi\|\fP^B same as b .PP .IP "q or Q" Exit from .I more. .PP .IP = Display the current line number. .PP .IP v Start up the editor .I vi at the current line. .PP .IP h Help command; give a description of all the .I more commands. .PP .IP \fIi\|\fP/expr search for the \fIi\|\fP-th occurrence of the regular expression \fIexpr.\fP If there are less than \fIi\fP occurrences of \fIexpr\|\fP, and the input is a file (rather than a pipe), then the position in the file remains unchanged. Otherwise, a screenful is displayed, starting two lines before the place where the expression was found. The user's erase and kill characters may be used to edit the regular expression. Erasing back past the first column cancels the search command. .PP .IP \fIi\|\fPn search for the \fIi\|\fP-th occurrence of the last regular expression entered. .PP .IP \' (single quote) Go to the point from which the last search started. If no search has been performed in the current file, this command goes back to the beginning of the file. .PP .IP !command invoke a shell with \fIcommand\|\fP. The characters `%' and `!' in "command" are replaced with the current file name and the previous shell command respectively. If there is no current file name, `%' is not expanded. The sequences "\\%" and "\\!" are replaced by "%" and "!" respectively. .PP .IP \fIi\|\fP:n skip to the \fIi\|\fP-th next file given in the command line (skips to last file if n doesn't make sense) .PP .IP \fIi\|\fP:p skip to the \fIi\|\fP-th previous file given in the command line. If this command is given in the middle of printing out a file, then .I more goes back to the beginning of the file. If \fIi\fP doesn't make sense, .I more skips back to the first file. If .I more is not reading from a file, the bell is rung and nothing else happens. .PP .IP :f display the current file name and line number. .PP .IP ":q or :Q" exit from .I more (same as q or Q). .PP .IP . (dot) repeat the previous command. .PP The commands take effect immediately, i.e., it is not necessary to type a carriage return. Up to the time when the command character itself is given, the user may hit the line kill character to cancel the numerical argument being formed. In addition, the user may hit the erase character to redisplay the --More--(xx%) message. .PP At any time when output is being sent to the terminal, the user can hit the quit key (normally control\-\\). .I More will stop sending output, and will display the usual --More-- prompt. The user may then enter one of the above commands in the normal manner. Unfortunately, some output is lost when this is done, due to the fact that any characters waiting in the terminal's output queue are flushed when the quit signal occurs. .PP The terminal is set to .I noecho mode by this program so that the output can be continuous. What you type will thus not show on your terminal, except for the / and ! commands. .PP If the standard output is not a teletype, then .I more acts just like .I cat, except that a header is printed before each file (if there is more than one). .PP .DT A sample usage of .I more in previewing .I nroff output would be .PP nroff \-ms +2 doc.n | more -s .SH FILES .DT /etc/termcap Terminal data base .br /usr/share/misc/more.help Help file .SH "SEE ALSO" csh(1), man(1), msgs(1), script(1), sh(1), environ(7) .SH BUGS Skipping backwards is too slow on large files. ================================================ FILE: share/man/man1/mset.1 ================================================ .\" Copyright (c) 1986 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)mset.1 1.3.1 (2.11BSD) 1996/11/16 .\" .TH MSET 1 "November 16, 1996" .UC 6 .SH NAME mset \- retrieve ASCII to IBM 3270 keyboard map .SH SYNOPSIS .B mset .SH DESCRIPTION .I Mset retrieves mapping information for the ASCII keyboard to IBM 3270 terminal special functions. Normally, these mappings are found in .I /usr/share/misc/map3270 (see .IR map3270 (5)). This information is used by the .I tn3270 command (see .IR tn3270 (1)). .PP .I Mset can be used store the mapping information in the process environment in order to avoid scanning .I /usr/share/misc/map3270 each time .I tn3270 is invoked. To do this, place the following command in your .I .login file: .ti 5n .sp set noglob; setenv \s-1MAP3270\s0 "\(gamset\(ga"; unset noglob .PP .I Mset first determines the user's terminal type from the environment variable .BR TERM . Normally .I mset then uses the file .I /usr/share/misc/map3270 to find the keyboard mapping for that terminal. However, if the environment variable .B MAP3270 exists and contains the entry for the specified terminal, then that definition is used. If the value of .B MAP3270 begins with a slash (`/') then it is assumed to be the full pathname of an alternate mapping file and that file is searched first. In any case, if the mapping for the terminal is not found in the environment, nor in an alternate map file, nor in the standard map file, then the same search is performed for an entry for a terminal type of .B unknown. If that search also fails, then a default mapping is used. .SH FILES /usr/share/misc/map3270 keyboard mapping for known terminals .SH SEE ALSO tn3270(1), map3270(5) .SH BUGS If the entry for the specific terminal exceeds 1024 bytes, \fIcsh\fR(1) will fail to set the environment variable. .I Mset should probably detect this case and output the path to the .I map3270 file instead of the terminal entry. ================================================ FILE: share/man/man1/msgs.1 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)msgs.1 6.3.1 (2.11BSD) 1996/10/22 .\" .TH MSGS 1 "October 22, 1996" .UC 4 .SH NAME msgs \- system messages and junk mail program .SH SYNOPSIS .B msgs [ .B \-fhlpq ] [ number ] [ \-number ] .LP .B msgs .B \-s .LP .B msgs .B \-c [ \-days ] .SH DESCRIPTION .I Msgs is used to read system messages. These messages are sent by mailing to the login `msgs' and should be short pieces of information which are suitable to be read once by most users of the system. .PP .I Msgs is normally invoked each time you login, by placing it in the file .I \&.login .I (\&.profile if you use .IR /bin/sh ). It will then prompt you with the source and subject of each new message. If there is no subject line, the first few non-blank lines of the message will be displayed. If there is more to the message, you will be told how long it is and asked whether you wish to see the rest of the message. The possible responses are: .TP 7 .B y type the rest of the message. .TP 7 RETURN synonym for y. .TP 7 .B n skip this message and go on to the next message. .TP 7 .B \- redisplay the last message. .TP 7 .B q drops you out of .I msgs; the next time you run the program it will pick up where you left off. .TP 7 .B s append the current message to the file ``Messages'' in the current directory; `s\-' will save the previously displayed message. A `s' or `s\-' may be followed by a space and a file name to receive the message replacing the default ``Messages''. .TP 7 .B m or `m\-' causes a copy of the specified message to be placed in a temporary mailbox and .IR mail (1) to be invoked on that mailbox. Both `m' and `s' accept a numeric argument in place of the `\-'. .PP .I Msgs keeps track of the next message you will see by a number in the file .I \&.msgsrc in your home directory. In the directory .I /usr/msgs it keeps a set of files whose names are the (sequential) numbers of the messages they represent. The file .I /usr/msgs/bounds shows the low and high number of the messages in the directory so that .I msgs can quickly determine if there are no messages for you. If the contents of .I bounds is incorrect it can be fixed by removing it; .I msgs will make a new .I bounds file the next time it is run. .PP The .B \-s option is used for setting up the posting of messages. The line .IP .DT msgs: "| /usr/ucb/msgs \-s" .PP should be include in .I /etc/aliases to enable posting of messages. .PP The .B \-c option is used for performing cleanup on .I /usr/msgs. An entry with the .B \-c option should be placed in .I /etc/crontab to run every night. This will remove all messages over 21 days old. A different expiration may be specified on the command line to override the default. .PP Options when reading messages include: .TP 7 .B \-f which causes it not to say ``No new messages.''. This is useful in your .I \&.login file since this is often the case here. .TP 7 .B \-q Queries whether there are messages, printing ``There are new messages.'' if there are. The command ``msgs \-q'' is often used in login scripts. .TP 7 .B \-h causes .I msgs to print the first part of messages only. .TP 7 .B \-l option causes only locally originated messages to be reported. .TP 7 \fInum\fR A message number can be given on the command line, causing .I msgs to start at the specified message rather than at the next message indicated by your .I \&.msgsrc file. Thus .IP "" 7 msgs \-h 1 .IP "" 7 prints the first part of all messages. .TP 7 .I "\-number" will cause .I msgs to start .I number messages back from the one indicated by your .I \&.msgsrc file, useful for reviews of recent messages. .TP 7 .B \-p causes long messages to be piped through .IR more (1). .PP Within .I msgs you can also go to any specific message by typing its number when .I msgs requests input as to what to do. .SH FILES .ta 2i /usr/msgs/* database .br ~/.msgsrc number of next message to be presented .SH AUTHORS William Joy .br David Wasley .SH SEE ALSO aliases(5), crontab(5), mail(1), more(1) .SH BUGS ================================================ FILE: share/man/man1/mt.1 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)mt.1 6.2.1 (2.11BSD) 1995/12/22 .\" .TH MT 1 "December 22, 1995" .UC 4 .SH NAME mt \- magnetic tape manipulating program .SH SYNOPSIS .B mt [ .B \-f .I tapename ] .I command [ .I count ] .SH DESCRIPTION .I Mt is used to give commands to a magnetic tape drive. If a tape name is not specified, the environment variable TAPE is used; if TAPE does not exist, .I mt uses the device .IR /dev/rmt12 . Note that .I tapename must reference a raw (not block) tape device. By default .I mt performs the requested operation once. Operations may be performed multiple times by specifying .IR count . .PP The available commands are listed below. Only as many characters as are required to uniquely identify a command need be specified. .TP .BR eof , " weof" Write .I count end-of-file marks at the current position on the tape. .TP .B fsf Forward space .I count files. .TP .B fsr Forward space .I count records. .TP .B bsf Back space .I count files. .TP .B bsr Back space .I count records. .TP .B rewind Rewind the tape .RI ( Count is ignored). .TP .BR offline , " rewoffl" Rewind the tape and place the tape unit off-line .RI ( Count is ignored). .TP .B status Print status information about the tape unit. .TP .B cacheon Enable the readahead/writebehind cache on the tape unit. .TP .B cacheoff Turn off the readahead/writebehind cache on the tape unit. .PP .I Mt returns a 0 exit status when the operation(s) were successful, 1 if the command was unrecognized, and 2 if an operation failed. .PP The .B cacheon and .B cacheoff commands currently only apply to the TMSCP driver and then only for certain drives such as the TU81+. No error is produced by the TMSCP driver if the cache commands are used. Other drivers will return an error code since they do not recognize the .B MTCACHE and .B MTNOCACHE functions codes. See .BR mtio (4). .SH FILES .DT /dev/rmt* Raw magnetic tape interface .SH "SEE ALSO" mtio(4), tmscp(4), dd(1), ioctl(2), environ(7) ================================================ FILE: share/man/man1/mv.1 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)mv.1 6.1 (Berkeley) 4/29/85 .\" .TH MV 1 "April 29, 1985" .UC 4 .SH NAME mv \- move or rename files .SH SYNOPSIS .B mv [ .B \-i ] [ .B \-f ] [ .B \- ] file1 file2 .PP .B mv [ .B \-i ] [ .B \-f ] [ .B \- ] file ... directory .SH DESCRIPTION .I Mv moves (changes the name of) .I file1 to .IR file2 . .PP If .I file2 already exists, it is removed before .I file1 is moved. If .I file2 has a mode which forbids writing, .I mv prints the mode (see .IR chmod (2)) and reads the standard input to obtain a line; if the line begins with .B y, the move takes place; if not, .I mv exits. .PP In the second form, one or more .I files (plain files or directories) are moved to the .I directory with their original file-names. .PP .I Mv refuses to move a file onto itself. .PP Options: .TP .B \-i stands for interactive mode. Whenever a move is to supercede an existing file, the user is prompted by the name of the file followed by a question mark. If he answers with a line starting with 'y', the move continues. Any other reply prevents the move from occurring. .TP .B \-f stands for force. This option overrides any mode restrictions or the \-i switch. .TP .B \- means interpret all the following arguments to .I mv as file names. This allows file names starting with minus. .SH "SEE ALSO" cp(1), ln(1) .SH BUGS If .I file1 and .I file2 lie on different file systems, .I mv must copy the file and delete the original. In this case the owner name becomes that of the copying process and any linking relationship with other files is lost. ================================================ FILE: share/man/man1/netstat.1 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)netstat.1 6.5 (Berkeley) 5/8/86 .\" .TH NETSTAT 1 "May 8, 1986" .UC 5 .SH NAME netstat \- show network status .SH SYNOPSIS .B netstat [ .B \-Aan ] [ .B \-f .I address_family ] [ .I system ] [ .I core ] .br .B netstat [ .B \-himnrs ] [ .B \-f .I address_family ] [ .I system ] [ .I core ] .br .B netstat [ .B \-n ] [ .B \-I .I interface ] .I interval [ .I system ] [ .I core ] .SH DESCRIPTION The .I netstat command symbolically displays the contents of various network-related data structures. There are a number of output formats, depending on the options for the information presented. The first form of the command displays a list of active sockets for each protocol. The second form presents the contents of one of the other network data structures according to the option selected. Using the third form, with an .I interval specified, .I netstat will continuously display the information regarding packet traffic on the configured network interfaces. .PP The options have the following meaning: .TP .B \-A With the default display, show the address of any protocol control blocks associated with sockets; used for debugging. .TP .B \-a With the default display, show the state of all sockets; normally sockets used by server processes are not shown. .TP .B \-h Show the state of the IMP host table. .TP .B \-i Show the state of interfaces which have been auto-configured (interfaces statically configured into a system, but not located at boot time are not shown). .TP .BI \-I " interface" Show information only about this interface; used with an .I interval as described below. .TP .B \-m Show statistics recorded by the memory management routines (the network manages a private pool of memory buffers). .TP .B \-n Show network addresses as numbers (normally .I netstat interprets addresses and attempts to display them symbolically). This option may be used with any of the display formats. .TP .B \-s Show per-protocol statistics. .TP .B \-r Show the routing tables. When .B \-s is also present, show routing statistics instead. .TP .BI \-f " address_family" Limit statistics or address control block reports to those of the specified .IR address\ family . The following address families are recognized: .IR inet , for .BR AF_INET , .IR ns , for .BR AF_NS , and .IR unix , for .BR AF_UNIX . .PP The arguments, .I system and .I core allow substitutes for the defaults ``/vmunix'' and ``/dev/kmem''. .PP The default display, for active sockets, shows the local and remote addresses, send and receive queue sizes (in bytes), protocol, and the internal state of the protocol. Address formats are of the form ``host.port'' or ``network.port'' if a socket's address specifies a network but no specific host address. When known the host and network addresses are displayed symbolically according to the data bases .I /etc/hosts and .IR /etc/networks , respectively. If a symbolic name for an address is unknown, or if the .B \-n option is specified, the address is printed numerically, according to the address family. For more information regarding the Internet ``dot format,'' refer to .IR inet (3N). Unspecified, or ``wildcard'', addresses and ports appear as ``*''. .PP The interface display provides a table of cumulative statistics regarding packets transferred, errors, and collisions. The network addresses of the interface and the maximum transmission unit (``mtu'') are also displayed. .PP The routing table display indicates the available routes and their status. Each route consists of a destination host or network and a gateway to use in forwarding packets. The flags field shows the state of the route (``U'' if ``up''), whether the route is to a gateway (``G''), and whether the route was created dynamically by a redirect (``D''). Direct routes are created for each interface attached to the local host; the gateway field for such entries shows the address of the outgoing interface. The refcnt field gives the current number of active uses of the route. Connection oriented protocols normally hold on to a single route for the duration of a connection while connectionless protocols obtain a route while sending to the same destination. The use field provides a count of the number of packets sent using that route. The interface entry indicates the network interface utilized for the route. .PP When .I netstat is invoked with an .I interval argument, it displays a running count of statistics related to network interfaces. This display consists of a column for the primary interface (the first interface found during autoconfiguration) and a column summarizing information for all interfaces. The primary interface may be replaced with another interface with the .I \-I option. The first line of each screen of information contains a summary since the system was last rebooted. Subsequent lines of output show values accumulated over the preceding interval. .SH SEE ALSO iostat(1), vmstat(1), hosts(5), networks(5), protocols(5), services(5), trpt(8C) .SH BUGS The notion of errors is ill-defined. Collisions mean something else for the IMP. ================================================ FILE: share/man/man1/newaliases.1 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)newaliases.1 6.2.1 (2.11BSD) 1996/10/22 .\" .TH NEWALIASES 1 "October 22, 1996" .UC 4 .SH NAME newaliases \- rebuild the data base for the mail aliases file .SH SYNOPSIS .B newaliases .SH DESCRIPTION .I Newaliases rebuilds the random access data base for the mail aliases file .IR /etc/aliases . It must be run each time .I /etc/aliases is changed in order for the change to take effect. .SH SEE ALSO aliases(5), sendmail(8) ================================================ FILE: share/man/man1/nice.1 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)nice.1 6.2 (Berkeley) 5/8/86 .\" .TH NICE 1 "May 8, 1986" .UC 4 .SH NAME nice, nohup \- run a command at low priority (\fIsh\fR only) .SH SYNOPSIS .B nice [ .BI \- number ] command [ arguments ] .PP .B nohup command [ arguments ] .SH DESCRIPTION .I Nice executes .I command with low scheduling priority. If the .I number argument is present, the priority is incremented (higher numbers mean lower priorities) by that amount up to a limit of 20. The default .I number is 10. .PP The super-user may run commands with priority higher than normal by using a negative priority, e.g. `\-\-10'. .PP .I Nohup executes .I command immune to hangup and terminate signals from the controlling terminal. The priority is incremented by 5. .I Nohup should be invoked from the shell with `&' in order to prevent it from responding to interrupts by or stealing the input from the next person who logs in on the same terminal. .SH FILES nohup.out standard output and standard error file under .I nohup .SH "SEE ALSO" csh(1), setpriority(2), renice(8) .SH DIAGNOSTICS .I Nice returns the exit status of the subject command. .SH BUGS .I Nice and .I nohup are particular to .IR sh (1). If you use .IR csh (1), then commands executed with ``&'' are automatically immune to hangup signals while in the background. There is a builtin command .I nohup which provides immunity from terminate, but it does not redirect output to .I nohup.out. .PP .I Nice is built into .IR csh (1) with a slightly different syntax than described here. The form ``nice +10'' nices to positive nice, and ``nice \-10'' can be used by the super-user to give a process more of the processor. ================================================ FILE: share/man/man1/nm.1 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)nm.1 6.1 (Berkeley) 4/29/85 .\" .TH NM 1 "April 29, 1985" .UC 2 .SH NAME nm \- print name list (2BSD) .SH SYNOPSIS .B nm [ .B \-gnopru ] [ file ... ] .SH DESCRIPTION .I Nm prints the name list (symbol table) of each object .I file in the argument list. If an argument is an archive, a listing for each object file in the archive will be produced. If no .I file is given, the symbols in "a.out" are listed. .PP Each symbol name is preceded by its value (blanks if undefined) and one of the letters .SM .B U (undefined), .SM .B A (absolute), .SM .B T (text segment symbol), .SM .B D (data segment symbol), .SM .B B (bss segment symbol), .SM .B C (common symbol), or .SM .B f file name. If the symbol is local (non-external) the type letter is in lower case. If the file is an overlaid executable, the overlay number is printed after the name. The number is printed if the symbol is in an overlay or if it is the entry point (in the base segment) for a subroutine in an overlay. The output is sorted alphabetically. .PP Options are: .TP .B \-g Print only global (external) symbols. .TP .B \-n Sort numerically rather than alphabetically. .TP .B \-o Prepend file or archive element name to each output line rather than only once. .TP .B \-p Don't sort; print in symbol-table order. .TP .B \-r Sort in reverse order. .TP .B \-u Print only undefined symbols. .SH SEE ALSO ar(1), ar(5), a.out(5), stab(5) ================================================ FILE: share/man/man1/nroff.1 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)nroff.1 6.1.1 (2.11BSD) 1996/10/22 .\" .TH NROFF 1 "October 22, 1996" .UC 5 .SH NAME nroff \- text formatting .SH SYNOPSIS .B nroff [ option ] ... [ file ] ... .SH DESCRIPTION .I Nroff formats text in the named .I files for typewriter-like devices. See also .I troff(1). The full capabilities of .I nroff are described in the .I Nroff/Troff User's Manual. .PP If no .I file argument is present, the standard input is read. An argument consisting of a single minus .RB ( \- ) is taken to be a file name corresponding to the standard input. .PP The options, which may appear in any order so long as they appear .I before the files, are: .TP "\w'\f3\-m\f1name 'u" .BI \-o list Print only pages whose page numbers appear in the comma-separated .I list of numbers and ranges. A range .IB N \- M means pages .I N through .IR M ; an initial .I \-N means from the beginning to page .IR N ; and a final .IR N \- means from .I N to the end. .TP .BI \-n N Number first generated page .IR N . .TP .BI \-s N Stop every .I N pages. .I Nroff will halt prior to every .I N pages (default .IR N =1) to allow paper loading or changing, and will resume upon receipt of a newline. .TP .BI \-m name Prepend the macro file .BI /usr/share/tmac/tmac. name to the input .IR files . .TP .BI \-r aN Set register .I a (one-character) to .IR N . .TP .B \-i Read standard input after the input files are exhausted. .TP .B \-q Invoke the simultaneous input-output mode of the .B rd request. .TP .BI \-T name Prepare output for specified terminal. Known .I names are .B 37 for the (default) Teletype Corporation Model 37 terminal, .B tn300 for the GE TermiNet\ 300 (or any terminal without half-line capability), .B 300S for the \s-1DASI\s+1-300S, .B 300 for the \s-1DASI\s+1-300, and .B 450 for the \s-1DASI\s+1-450 (Diablo Hyterm). .TP .B \-e Produce equally-spaced words in adjusted lines, using full terminal resolution. .TP .B \-h Use output tabs during horizontal spacing to speed output and reduce output character count. Tab settings are assumed to be every 8 nominal character widths. .SH FILES .ta \w'/usr/share/tmac/tmac.* 'u /tmp/ta* temporary file .br /usr/share/tmac/tmac.* standard macro files .br /usr/share/term/* terminal driving tables for .I nroff .br .SH "SEE ALSO" J. F. Ossanna, .I Nroff/Troff user's manual .br B. W. Kernighan, .I A TROFF Tutorial .br troff(1), eqn(1), tbl(1), ms(7), me(7), man(7), col(1) ================================================ FILE: share/man/man1/nslookup.1 ================================================ .\" Copyright (c) 1986 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)nslookup.1 1.2 (Berkeley) 11/21/87 .\" .TH NSLOOKUP 1 "November 21, 1987" .UC 6 .SH NAME nslookup \- query name servers interactively .SH SYNOPSIS .B nslookup [ .I host-to-find | \- [ .I server address | server name ]] .SH DESCRIPTION .IR Nslookup is a program to query DARPA Internet domain name servers. Nslookup has two modes: interactive and non-interactive. Interactive mode allows the user to query the name server for information about various hosts and domains or print a list of hosts in the domain. Non-interactive mode is used to print just the name and Internet address of a host or domain. .sp 1 .SH ARGUMENTS Interactive mode is entered in the following cases: .IP a) 4 when no arguments are given (the default name server will be used), and .IP b) 4 when the first argument is a hyphen (\-) and the second argument is the host name of a name server. .LP Non-interactive mode is used when the name of the host to be looked up is given as the first argument. The optional second argument specifies a name server. .sp 1 .SH "INTERACTIVE COMMANDS" Commands may be interrupted at any time by typing a control-C. To exit, type a control-D (EOF). The command line length must be less than 80 characters. \fBN.B.\fP an unrecognized command will be interpreted as a host name. .sp 1 .IP "host [server]" Look up information for \fIhost\fP using the current default server or using \fIserver\fP if it is specified. .sp 1 .IP "\fBserver\fP \fIdomain\fP" .ns .IP "\fBlserver\fP \fIdomain\fP" Change the default server to \fIdomain\fP. \fBLserver\fP uses the initial server to look up information about \fIdomain\fP while \fBserver\fP uses the current default server. If an authoritative answer can't be found, the names of servers that might have the answer are returned. .sp 1 .IP \fBroot\fP Changes the default server to the server for the root of the domain name space. Currently, the host sri-nic.arpa is used. (This command is a synonym for the \fBlserver sri-nic.arpa\fP.) The name of the root server can be changed with the \fBset root\fP command. .sp 1 .IP "\fBfinger\fP [\fIname\fP] [\fB>\fP \fIfilename\fP]" .ns .IP "\fBfinger\fP [\fIname\fP] [\fB>>\fP \fIfilename\fP]" Connects with the finger server on the current host. The current host is defined when a previous lookup for a host was successful and returned address information (see the \fBset querytype=A\fP command). \fIName\fP is optional. \fB>\fP and \fB>>\fP can be used to redirect output in the usual manner. .sp 1 .IP "\fBls\fP \fIdomain\fP [\fB>\fP \fIfilename\fP]" .ns .IP "\fBls\fP \fIdomain\fP [\fB>>\fP \fIfilename\fP]" .ns .IP "\fBls -a\fP \fIdomain\fP [\fB>\fP \fIfilename\fP]" .ns .IP "\fBls -a\fP \fIdomain\fP [\fB>>\fP \fIfilename\fP]" .ns .IP "\fBls -h\fP \fIdomain\fP [\fB>\fP \fIfilename\fP]" .ns .IP "\fBls -h\fP \fIdomain\fP [\fB>>\fP \fIfilename\fP]" .IP "\fBls -d\fP \fIdomain\fP [\fB>\fP \fIfilename\fP]" .ns List the information available for \fIdomain\fP. The default output contains host names and their Internet addresses. The \fB-a\fP option lists aliases of hosts in the domain. The \fB-h\fP option lists CPU and operating system information for the domain. The \fB-d\fP option lists all contents of a zone transfer. When output is directed to a file, hash marks are printed for every 50 records received from the server. .sp 1 .IP "\fBview\fP \fIfilename\fP" Sorts and lists the output of previous \fBls\fP command(s) with \fImore\fP(1). .sp 1 .IP "\fBhelp\fP" .ns .IP "\fB?\fP" Prints a brief summary of commands. .sp 1 .IP "\fBset\fP \fIkeyword\fP[=\fIvalue\fP]" This command is used to change state information that affects the lookups. Valid keywords are: .RS .IP "\fBall\fP" Prints the current values of the various options to \fBset\fP. Information about the current default server and host is also printed. .IP "\fB[no]debug\fP" Turn debugging mode on. A lot more information is printed about the packet sent to the server and the resulting answer. .br (Default = nodebug, abbreviation = [no]deb) .IP "\fB[no]d2\fP" Turn exhaustive debugging mode on. Essentially all fields of every packet are printed. .br (Default = nod2) .IP "\fB[no]defname\fP" Append the default domain name to every lookup. .br (Default = defname, abbreviation = [no]def) .IP "\fB[no]search\fP" With defname, search for each name in parent domains of the current domain. .br (Default = search) .IP "\fBdomain=\fIname\fR" Change the default domain name to \fIname\fP. The default domain name is appended to all lookup requests if the \fBdefname\fP option has been set. The search list is set to parents of the domain with at least two components in their names. .br (Default = value in hostname or /etc/resolv.conf, abbreviation = do) .IP "\fBquerytype=\fIvalue\fR" .IP "\fBtype=\fIvalue\fR" Change the type of information returned from a query to one of: .RS .IP A 10 the host's Internet address (the default). .IP CNAME 10 the canonical name for an alias. .IP HINFO 10 the host CPU and operating system type. .IP MD 10 the mail destination. .IP MX 10 the mail exchanger. .IP MG 10 the mail group member. .IP MINFO 10 the mailbox or mail list information. .IP MR 10 the mail rename domain name. .IP NS 10 nameserver for the named zone. .RE Other types specified in the RFC883 document are valid but aren't very useful. .br (Abbreviation = q) .IP "\fB[no]recurse\fP" Tell the name server to query other servers if it does not have the information. .br (Default = recurse, abbreviation = [no]rec) .IP \fBretry=\fInumber\fR Set the number of retries to \fInumber\fP. When a reply to a request is not received within a certain amount of time (changed with \fBset timeout\fP), the request is resent. The retry value controls how many times a request is resent before giving up. .br (Default = 2, abbreviation = ret) .IP \fBroot=\fIhost\fR Change the name of the root server to \fIhost\fP. This affects the \fBroot\fP command. .br (Default = sri-nic.arpa, abbreviation = ro) .IP \fBtimeout=\fInumber\fR Change the time-out interval for waiting for a reply to \fInumber\fP seconds. .br (Default = 10 seconds, abbreviation = t) .IP "\fB[no]vc\fP" Always use a virtual circuit when sending requests to the server. .br (Default = novc, abbreviation = [no]v) .RE .SH DIAGNOSTICS If the lookup request was not successful, an error message is printed. Possible errors are: .IP "Time-out" The server did not respond to a request after a certain amount of time (changed with \fBset timeout=\fIvalue\fR) and a certain number of retries (changed with \fBset retry=\fIvalue\fR). .IP "No information" Depending on the query type set with the \fBset querytype\fP command, no information about the host was available, though the host name is valid. .IP "Non-existent domain" The host or domain name does not exist. .IP "Connection refused" .ns .IP "Network is unreachable" The connection to the name or finger server could not be made at the current time. This error commonly occurs with \fBfinger\fP requests. .IP "Server failure" The name server found an internal inconsistency in its database and could not return a valid answer. .IP "Refused" The name server refused to service the request. .sp 1 .PP The following error should not occur and it indicates a bug in the program. .IP "Format error" The name server found that the request packet was not in the proper format. .sp 1 .SH FILES /etc/resolv.conf initial domain name and name server addresses. .SH SEE ALSO resolver(3), resolver(5), named(8), RFC882, RFC883 .SH AUTHOR Andrew Cherenson ================================================ FILE: share/man/man1/od.1 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)od.1 6.1 (Berkeley) 4/29/85 .\" .TH OD 1 "April 29, 1985" .UC 4 .SH NAME od \- octal, decimal, hex, ascii dump .SH SYNOPSIS .B od [ \-format ] [ file ] [ [\fB+\fP]offset[\fB.\fP][\fBb\fP] [label] ] .SH DESCRIPTION .I Od displays .IR file , or it's standard input, in one or more dump formats as selected by the first argument. If the first argument is missing, .B \-o is the default. Dumping continues until end-of-file. .PP The meanings of the format argument characters are: .TP 5 .B a Interpret bytes as characters and display them with their ACSII names. If the .B p character is given also, then bytes with even parity are underlined. The .B P character causes bytes with odd parity to be underlined. Otherwise the parity bit is ignored. .TP 5 .B b Interpret bytes as unsigned octal. .TP 5 .B c Interpret bytes as ASCII characters. Certain non-graphic characters appear as C escapes: null=\e0, backspace=\eb, formfeed=\ef, newline=\en, return=\er, tab=\et; others appear as 3-digit octal numbers. Bytes with the parity bit set are displayed in octal. .TP 5 .B d Interpret (short) words as unsigned decimal. .TP 5 .B f Interpret long words as floating point. .TP 5 .B h Interpret (short) words as unsigned hexadecimal. .TP 5 .B i Interpret (short) words as signed decimal. .TP 5 .B l Interpret long words as signed decimal. .TP 5 .B o Interpret (short) words as unsigned octal. .TP 5 .BR s [n] Look for strings of ascii graphic characters, terminated with a null byte. .I N specifies the minimum length string to be recognized. By default, the minimum length is 3 characters. .TP 5 .B v Show all data. By default, display lines that are identical to the last line shown are not output, but are indicated with an ``*'' in column 1. .TP 5 .BR w [n] Specifies the number of input bytes to be interpreted and displayed on each output line. If .B w is not specified, 16 bytes are read for each display line. If .I n is not specified, it defaults to 32. .TP 5 .B x Interpret (short) words as hexadecimal. .PP An upper case format character implies the long or double precision form of the object. .PP The .I offset argument specifies the byte offset into the file where dumping is to commence. By default this argument is interpreted in octal. A different radix can be specified; If ``\fB.\fR'' is appended to the argument, then .I offset is interpreted in decimal. If .I offset begins with ``\fBx\fP'' or ``\fB0x\fP'', it is interpreted in hexadecimal. If ``\fBb\fP'' (``\fBB\fP'') is appended, the offset is interpreted as a block count, where a block is 512 (1024) bytes. If the .I file argument is omitted, an .I offset argument must be preceded by .RB `` + ''. .PP The radix of the displayed address will be the same as the radix of the .IR offset , if specified; otherwise it will be octal. .PP .I Label will be interpreted as a pseudo-address for the first byte displayed. It will be shown in ``()'' following the file offset. It is intended to be used with core images to indicate the real memory address. The syntax for .I label is identical to that for .IR offset . .SH "SEE ALSO" adb(1) .SH BUGS A file name argument can't start with ``+''. A hexadecimal offset can't be a block count. Only one file name argument can be given. .PP It is an historical botch to require specification of object, radix, and sign representation in a single character argument. ================================================ FILE: share/man/man1/pagesize.1 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)pagesize.1 6.1 (Berkeley) 4/29/85 .\" .TH PAGESIZE 1 "April 29, 1985" .UC 5 .SH NAME pagesize \- print system page size .SH SYNOPSIS .B pagesize .SH DESCRIPTION .I Pagesize prints the size of a page of memory in bytes, as returned by .IR getpagesize (2). This program is useful in constructing portable shell scripts. .SH SEE ALSO getpagesize(2) ================================================ FILE: share/man/man1/pdx.1 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)pdx.1 6.1 (Berkeley) 4/29/85 .\" .TH PDX 1 "April 29, 1985" .UC 5 .SH NAME pdx \- pascal debugger .SH SYNOPSIS pdx [\fB\-r\fP] [\fIobjfile\fP] .SH DESCRIPTION \fIPdx\fP is a tool for source level debugging and execution of Pascal programs. The \fIobjfile\fP is an object file produced by the Pascal translator \fIpi\fP(1). If no \fIobjfile\fP is specified, \fIpdx\fP looks for a file named ``obj'' in the current directory. The object file contains a symbol table which includes the name of the all the source files translated by \fIpi\fP to create it. These files are available for perusal while using the debugger. .PP If the file ``.pdxinit'' exists in the current directory, then the debugger commands in it are executed. .PP The \fB\-r\fP option causes the \fIobjfile\fP to be executed immediately; if it terminates successfully \fIpdx\fP exits. Otherwise it reports the reason for termination and offers the user the option of entering the debugger or simply letting \fIpx\fP continue with a traceback. If \fB\-r\fP is not specified, \fIpdx\fP just prompts and waits for a command. .PP The commands are: .TP \fBrun\fP [\fIargs\fP] [\fB<\fP \fIfilename\fP] [\fB>\fP \fIfilename\fP] Start executing \fIobjfile\fP, passing \fIargs\fP as command line arguments; \fB<\fP or \fB>\fP can be used to redirect input or output in the usual manner. .TP \fBtrace\fP [\fBin\fP \fIprocedure/function\fP] [\fBif\fP \fIcondition\fP] .ns .TP \fBtrace\fP \fIsource-line-number\fP [\fBif\fP \fIcondition\fP] .ns .TP \fBtrace\fP \fIprocedure/function\fP [\fBin\fP \fIprocedure/function\fP] [\fBif\fP \fIcondition\fP] .ns .TP \fBtrace\fP \fIexpression\fP \fBat\fP \fIsource-line-number\fP [\fBif\fP \fIcondition\fP] .ns .TP \fBtrace\fP \fIvariable\fP [\fBin\fP \fIprocedure/function\fP] [\fBif\fP \fIcondition\fP] Have tracing information printed when the program is executed. A number is associated with the command that is used to turn the tracing off (see the \fBdelete\fP command). .sp 1 The first argument describes what is to be traced. If it is a \fIsource-line-number\fP, then the line is printed immediately prior to being executed. Source line numbers in a file other than the current one must be preceded by the name of the file and a colon, e.g. ``mumble.p:17''. .sp 1 If the argument is a procedure or function name then every time it is called, information is printed telling what routine called it, from what source line it was called, and what parameters were passed to it. In addition, its return is noted, and if it's a function then the value it is returning is also printed. .sp 1 If the argument is an \fIexpression\fP with an \fBat\fP clause then the value of the expression is printed whenever the identified source line is reached. .sp 1 If the argument is a variable then the name and value of the variable is printed whenever it changes. Execution is substantially slower during this form of tracing. .sp 1 If no argument is specified then all source lines are printed before they are executed. Execution is substantially slower during this form of tracing. .sp 1 The clause ``\fBin\fP \fIprocedure/function\fP'' restricts tracing information to be printed only while executing inside the given procedure or function. .sp 1 \fICondition\fP is a Pascal boolean expression and is evaluated prior to printing the tracing information; if it is false then the information is not printed. .sp 1 There is no restriction on the amount of information that can be traced. .br .ne 10 .IP "\fBstop\fP \fBif\fP \fIcondition\fP" .ns .IP "\fBstop\fP \fBat\fP \fIsource-line-number\fP [\fBif\fP \fIcondition\fP]" .ns .IP "\fBstop\fP \fBin\fP \fIprocedure/function\fP [\fBif\fP \fIcondition\fP]" .ns .IP "\fBstop\fP \fIvariable\fP [\fBif\fP \fIcondition\fP]" Stop execution when the given line is reached, procedure or function called, variable changed, or condition true. .IP "\fBdelete\fP \fIcommand-number\fP" The trace or stop corresponding to the given number is removed. The numbers associated with traces and stops are printed by the \fBstatus\fP command. .IP "\fBstatus\fP [\fB>\fP \fIfilename\fP]" Print out the currently active \fBtrace\fP and \fBstop\fP commands. .IP \fBcont\fP Continue execution from where it stopped. This can only be done when the program was stopped by an interrupt or through use of the \fBstop\fP command. .IP \fBstep\fP Execute one source line. .IP \fBnext\fP Execute up to the next source line. The difference between this and \fBstep\fP is that if the line contains a call to a procedure or function the \fBstep\fP command will stop at the beginning of that block, while the \fBnext\fP command will not. .IP "\fBprint\fP \fIexpression\fP [\fB,\fP \fIexpression\fP ...]" Print out the values of the Pascal expressions. Variables declared in an outer block but having the same identifier as one in the current block may be referenced as ``\fIblock-name\fP\ \fB.\fP\ \fIvariable\fP''. .IP "\fBwhatis\fP \fIidentifier\fP" Print the declaration of the given identifier. .IP "\fBwhich\fP \fIidentifier\fP" Print the full qualification of the given identifer, i.e. the outer blocks that the identifier is associated with. .IP "\fBassign\fP \fIvariable\fP \fIexpression\fP" Assign the value of the expression to the variable. .IP "\fBcall\fP \fIprocedure(parameters)\fP" Execute the object code associated with the named procedure or function. .IP \fBhelp\fP Print out a synopsis of \fIpdx\fP commands. .IP \fBgripe\fP Invokes a mail program to send a message to the person in charge of \fIpdx\fP. .IP \fBwhere\fP Print out a list of the active procedures and functions and the respective source line where they are called. .TP \fBsource\fP \fIfilename\fP Read \fIpdx\fP commands from the given \fIfilename\fP. Especially useful when the \fIfilename\fP has been created by redirecting a \fBstatus\fP command from an earlier debugging session. .IP "\fBdump\fP [\fB>\fP \fIfilename\fP]" Print the names and values of all active data. .IP "\fBlist\fP [\fIsource-line-number\fP [\fB,\fP \fIsource-line-number\fP]]" .ns .IP "\fBlist\fP \fIprocedure/function\fP" List the lines in the current source file from the first line number to the second inclusive. As in the editor ``$'' can be used to refer to the last line. If no lines are specified, the entire file is listed. If the name of a procedure or function is given lines \fIn-k\fP to \fIn+k\fP are listed where \fIn\fP is the first statement in the procedure or function and \fIk\fP is small. .IP "\fBfile\fP [\fIfilename\fP]" Change the current source file name to \fIfilename\fP. If none is specified then the current source file name is printed. .IP "\fBedit\fP [\fIfilename\fP]" .ns .IP "\fBedit\fP \fIprocedure/function-name\fP" Invoke an editor on \fIfilename\fP or the current source file if none is specified. If a \fIprocedure\fP or \fIfunction\fP name is specified, the editor is invoked on the file that contains it. Which editor is invoked by default depends on the installation. The default can be overridden by setting the environment variable EDITOR to the name of the desired editor. .IP \fBpi\fP Recompile the program and read in the new symbol table information. .IP "\fBsh\fP \fIcommand-line\fP" Pass the command line to the shell for execution. The SHELL environment variable determines which shell is used. .IP "\fBalias\fP \fInew-command-name\fP \fIold-command-name\fP" This command makes \fIpdx\fP respond to \fInew-command-name\fP the way it used to respond to \fIold-command-name\fP. .IP "\fBquit\fP" Exit \fIpdx\fP. .sp 4 .PP The following commands deal with the program at the \fIpx\fP instruction level rather than source level. They are not intended for general use. .TP \fBtracei\fP [\fIaddress\fP] [\fBif\fP \fIcond\fP] .ns .TP \fBtracei\fP [\fIvariable\fP] [\fBat\fP \fIaddress\fP] [\fBif\fP \fIcond\fP] .ns .TP \fBstopi\fP [\fIaddress\fP] [\fBif\fP \fIcond\fP] .ns .TP \fBstopi\fP [\fBat\fP] [\fIaddress\fP] [\fBif\fP \fIcond\fP] Turn on tracing or set a stop using a \fIpx\fP machine instruction addresses. .TP \fBxi\fP \fIaddress\fP [\fB,\fP \fIaddress\fP] Print the instructions starting at the first \fIaddress\fP. Instructions up to the second \fIaddress\fP are printed. .TP \fBxd\fP \fIaddress\fP [\fB,\fP \fIaddress\fP] Print in octal the specified data location(s). .SH FILES .nr In 25 .in +\n(Inn .ta \n(Inn .br .nr wg 1v .ie \n(.h=\n(vk .nr wg -\n(vhu .el .nr vh 0 .if \n(wg>0 \{\ .sp \n(wgu .nr vh +\n(wgu \} .nr vk \n(.h .ti -\n(Inn \&obj \c Pascal object file .br .nr wg 0v .ie \n(.h=\n(vk .nr wg -\n(vhu .el .nr vh 0 .if \n(wg>0 \{\ .sp \n(wgu .nr vh +\n(wgu \} .nr vk \n(.h .ti -\n(Inn \&\&.pdxinit \c \fIPdx\fP initialization file .in -\n(Inn .br .nr wg 1v .ie \n(.h=\n(vk .nr wg -\n(vhu .el .nr vh 0 .if \n(wg>0 \{\ .sp \n(wgu .nr vh +\n(wgu \} .nr vk \n(.h .SH SEE ALSO pi(1), px(1) .br \fIAn Introduction to Pdx\fP .SH BUGS \fIPdx\fP does not understand sets, and provides no information about files. .sp 1 The \fIwhatis\fP command doesn't quite work for variant records. .sp 1 Bad things will happen if a procedure invoked with the \fBcall\fP command does a non-local goto. .sp 1 The commands \fBstep\fP and \fBnext\fP should be able to take a \fIcount\fP that specifies how many lines to execute. .sp 1 There should be commands \fBstepi\fP and \fBnexti\fP that correspond to \fBstep\fP and \fBnext\fP but work at the instruction level. .sp 1 There should be a way to get an address associated with a line number, procedure or function, and variable. .sp 1 Most of the command names are too long. .sp 1 The alias facility is quite weak. .sp 1 A \fIcsh\fP-like history capability would improve the situation. ================================================ FILE: share/man/man1/pi.1 ================================================ .\" @(#)pi.1 1.1 (2.11BSD) 1996/10/22 .TH PI 1 "October 22, 1996" .UC .SH NAME pi \- Pascal interpreter code translator .SH SYNOPSIS .B pi [ .B \-blnpstuwz ] [ .B \-i name ... ] name.p .SH DESCRIPTION .I Pi translates the program in the file .I name.p leaving interpreter code in the file .I obj in the current directory. The interpreter code can be executed using .I px. .I Pix performs the functions of .I pi and .I px for `load and go' Pascal. .PP The following flags are interpreted by .I pi; the associated options can also be controlled in comments within the program as described in the .I "Berkeley Pascal User's Manual." .TP 6 .B \-\^b Block buffer the file .I output. .TP 6 .B \-\^i Enable the listing for any specified procedures and functions and while processing any specified .B include files. .TP 6 .B \-\^l Make a program listing during translation. .TP 6 .B \-\^n Begin each listed .B include file on a new page with a banner line. .TP 6 .B \-\^p Suppress the post-mortem control flow backtrace if an error occurs; suppress statement limit counting. .TP 6 .B \-\^s Accept standard Pascal only; non-standard constructs cause warning diagnostics. .TP 6 .B \-\^t Suppress runtime tests of subrange variables and treat .B assert statements as comments. .TP 6 .B \-\^u Card image mode; only the first 72 characters of input lines are used. .TP 6 .B \-\^w Suppress warning diagnostics. .TP 6 .B \-\^z Allow execution profiling with .I pxp by generating statement counters, and arranging for the creation of the profile data file .I pmon.out when the resulting object is executed. .SH FILES .DT .ta 2i file.p input file .br file.i \fBinclude\fP file(s) .br /usr/share/pascal/pi_strings text of the error messages .br .nf /usr/share/pascal/how_pi* basic usage explanation .fi obj interpreter code output .DT .SH "SEE ALSO" Berkeley Pascal User's Manual .br pcc(1), pix(1), px(1), pxp(1), pxref(1) .SH DIAGNOSTICS For a basic explanation do .IP .B pi .PP In the diagnostic output of the translator, lines containing syntax errors are listed with a flag indicating the point of error. Diagnostic messages indicate the action which the recovery mechanism took in order to be able to continue parsing. Some diagnostics indicate only that the input is `malformed.' This occurs if the recovery can find no simple correction to make the input syntactically valid. .PP Semantic error diagnostics indicate a line in the source text near the point of error. Some errors evoke more than one diagnostic to help pinpoint the error; the follow-up messages begin with an ellipsis `...'. .PP .ne 8 The first character of each error message indicates its class: .IP .ta 1c 2.i E Fatal error; no code will be generated. .br e Non-fatal error. .br w Warning \- a potential problem. .br s Non-standard Pascal construct warning. .PP If a severe error occurs which inhibits further processing, the translator will give a diagnostic and then `QUIT'. .SH AUTHORS Charles B. Haley, William N. Joy, and Ken Thompson .SH BUGS Formal parameters which are procedures and functions are not supported. .PP The keyword .B packed and the function .I dispose are recognized but have no effect. .PP For clarity, semantic errors should be flagged at an appropriate place in the source text, and multiple instances of the `same' semantic error should be summarized at the end of a .B procedure or .B function rather than evoking many diagnostics. .PP When .B include files are present, diagnostics relating to the last procedure in one file may appear after the beginning of the listing of the next. ================================================ FILE: share/man/man1/pix.1 ================================================ .\" @(#)pix.1 1.1 (2.11BSD) 1996/10/22 .TH PIX 1 "October 22, 1996" .UC .SH NAME pix \- Pascal interpreter and executor .SH SYNOPSIS .B pix [ .B \-blnpstuwz ] [ .B \-i name ... ] name.p [ argument ... ] .SH DESCRIPTION .I Pix is a `load and go' version of Pascal which combines the functions of the interpreter code translator .I pi and the executor .IR px . It uses .I pi to translate the program in the file .I name.p and, if there were no fatal errors during translation, causes the resulting interpreter code to be executed by .I px with the specified arguments. A temporary file is used for the object code; the file .I obj is neither created nor destroyed. .SH FILES .ta 2i /usr/bin/pi Pascal translator .br /usr/bin/px Pascal executor .br /tmp/pix????? temporary files .br /usr/share/pascal/how_pix basic explanation .SH SEE\ ALSO Berkeley Pascal User's Manual .br pi(1), px(1) .SH DIAGNOSTICS For a basic explanation do .PP .DT .B pix .SH AUTHOR Susan L. Graham and William N. Joy ================================================ FILE: share/man/man1/plot.1 ================================================ .\" @(#)plot.1g 6.3 (Berkeley) 9/21/85 .\" .TH PLOT 1G "September 21, 1985" .AT 3 .SH NAME plot \- graphics filters .SH SYNOPSIS .B plot [ .BR \-T terminal ] [ .BR \-r resolution ] [ files... ] .SH DESCRIPTION These commands read plotting instructions (see .IR plot (5)) from the standard input or the specified .IR files , and in general produce plotting instructions suitable for a particular .I terminal on the standard output. The .B \-r flag may be used to specify the device's output resolution (currently only the Imagen laser printer understands this option). .PP If no .I terminal type is specified, the environment parameter $TERM (see .IR environ (7)) is used. Known .I terminals are: .TP .B 4013 Tektronix 4013 storage scope. .TP .BR 4014\ or\ tek Tektronix 4014 or 4015 storage scope with Enhanced Graphics Module. (Use 4013 for Tektronix 4014 or 4015 without the Enhanced Graphics Module). .TP .B 450 DASI Hyterm 450 terminal (Diablo mechanism). .TP .B 300 DASI 300 or GSI terminal (Diablo mechanism). .TP .B 300S DASI 300S terminal (Diablo mechanism). .TP .B aed AED 512 color graphics terminal. .TP .BR bitgraph\ or\ bg BBN bitgraph graphics terminal. .TP .B imagen\ or\ ip Imagen laser printer (default 240 dots-per-inch resolution). .TP .B crt Any crt terminal capable of running .IR vi (1). .TP .B dumb Dumb terminals without cursor addressing or line printers. .TP .B vt125 DEC vt125 terminal. .TP .BR hp2648\ or\ hp\ or\ hp8 Hewlett Packard 2648 graphics terminal. .TP .B ver Versatec D1200A printer-plotter. .TP .B var Benson Varian printer-plotter. .IP These versions of .I plot use the .B \-g option of .IR lpr (1) to send the result directly to the plotter device rather than to the standard output. .SH FILES /usr/bin/t4013 .br /usr/bin/tek .br /usr/bin/t450 .br /usr/bin/t300 .br /usr/bin/t300s .br /usr/bin/aedplot .br /usr/bin/bgplot .br /usr/bin/crtplot .br /usr/bin/dumbplot .br /usr/bin/gigiplot .br /usr/bin/hpplot .br /usr/bin/implot .br /usr/ucb/lpr .SH "SEE ALSO" plot(3X), plot(3F), plot(5), lpr(1) ================================================ FILE: share/man/man1/pmerge.1 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)pmerge.1 6.1 (Berkeley) 4/29/85 .\" .TH PMERGE 1 "April 29, 1985" .UC 4 .SH NAME pmerge \- pascal file merger .SH SYNOPSIS .B pmerge name.p ... .SH DESCRIPTION .I Pmerge assembles the named Pascal files into a single standard Pascal program. The resulting program is listed on the standard output. It is intended to be used to merge a collection of separately compiled modules so that they can be run through .B pi , or exported to other sites. .SH FILES .ta 1.5i /usr/tmp/MG\(** default temporary files .br .SH "SEE ALSO" pc(1), pi(1), .br Auxiliary documentation .I Berkeley Pascal User's Manual. .SH AUTHOR M. Kirk McKusick .SH BUGS Very minimal error checking is done, so incorrect programs will produce unpredictable results. Block comments should be placed after the keyword to which they refer or they are likely to end up in bizarre places. ================================================ FILE: share/man/man1/pr.1 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)pr.1 6.1 (Berkeley) 4/29/85 .\" .TH PR 1 "April 29, 1985" .UC 4 .SH NAME pr \- print file .SH SYNOPSIS .B pr [ option ] ... [ file ] ... .SH DESCRIPTION .I Pr produces a printed listing of one or more .I files. The output is separated into pages headed by a date, the name of the file or a specified header, and the page number. If there are no file arguments, .I pr prints its standard input. .PP Options apply to all following files but may be reset between files: .TP .BI \- n Produce .IR n -column output. .TP .BI + n Begin printing with page .I n. .TP .B \-h Take the next argument as a page header. .TP .BI \-w n For purposes of multi-column output, take the width of the page to be .I n characters instead of the default 72. .TP .BI \-f Use formfeeds instead of newlines to separate pages. A formfeed is assumed to use up two blank lines at the top of a page. (Thus this option does not affect the effective page length.) .TP .BI \-l n Take the length of the page to be .I n lines instead of the default 66. .TP .B \-t Do not print the 5-line header or the 5-line trailer normally supplied for each page. .TP .BI \-s c Separate columns by the single character .I c instead of by the appropriate amount of white space. A missing .I c is taken to be a tab. .TP .B \-m Print all .I files simultaneously, each in one column, .PP Inter-terminal messages via .IR write (1) are forbidden during a .IR pr . .SH FILES /dev/tty? to suspend messages. .SH "SEE ALSO" cat(1) .SH DIAGNOSTICS There are no diagnostics when .I pr is printing on a terminal. ================================================ FILE: share/man/man1/printenv.1 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)printenv.1 6.1 (Berkeley) 4/29/85 .\" .TH PRINTENV 1 "April 29, 1985" .UC .SH NAME printenv \- print out the environment .SH SYNOPSIS .B printenv [ name ] .SH DESCRIPTION .I Printenv prints out the values of the variables in the environment. If a .I name is specified, only its value is printed. .PP If a .I name is specified and it is not defined in the environment, .I printenv returns exit status 1, else it returns status 0. .SH SEE ALSO sh(1), environ(7), csh(1) ================================================ FILE: share/man/man1/prof.1 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)prof.1 6.1 (Berkeley) 4/29/85 .\" .TH PROF 1 "April 29, 1985" .UC 4 .SH NAME prof \- display profile data .SH SYNOPSIS .B prof [ .B \-a ] [ .B \-l ] [ .B \-n ] [ .B \-z ] [ .B \-s ] [ .B \-v [ .BI \- "low\fR [ \fB\-\fIhigh\fR ]" ] ] [ a.out [ mon.out ... ] ] .SH DESCRIPTION .I Prof interprets the file produced by the .I monitor subroutine. Under default modes, the symbol table in the named object file .I (a.out default) is read and correlated with the profile file .I (mon.out default). For each external symbol, the percentage of time spent executing between that symbol and the next is printed (in decreasing order), together with the number of times that routine was called and the number of milliseconds per call. If more than one profile file is specified, the output represents the sum of the profiles. .PP In order for the number of calls to a routine to be tallied, the .B \-p option of .I cc, .I f77 or .I pc must have been given when the file containing the routine was compiled. This option also arranges for the profile file to be produced automatically. .PP Options are: .TP .B \-a all symbols are reported rather than just external symbols. .TP .B \-l the output is sorted by symbol value. .TP .B \-n the output is sorted by number of calls .TP .B \-s a summary profile file is produced in .I mon.sum. This is really only useful when more than one profile file is specified. .TP .B \-v all printing is suppressed and a graphic version of the profile is produced on the standard output for display by the .IR plot (1) filters. When plotting, the numbers .I low and .I high, by default 0 and 100, may be given to cause a selected percentage of the profile to be plotted with accordingly higher resolution. .TP .B \-z routines which have zero usage (as indicated by call counts and accumulated time) are nevertheless printed in the output. .SH FILES .ta \w'mon.out 'u mon.out for profile .br a.out for namelist .br mon.sum for summary profile .SH "SEE ALSO" monitor(3), profil(2), cc(1), plot(1G) .SH BUGS Beware of quantization errors. .PP Is confused by .I f77 which puts the entry points at the bottom of subroutines and functions. ================================================ FILE: share/man/man1/ps.1 ================================================ .TH PS 1 "November 17, 1996" .UC .SH NAME ps \- process status .SH SYNOPSIS .B ps [ .B acgklnrtuwxU# [ core [ swap [ system ] ] ] ] .SH DESCRIPTION .I Ps prints certain indicia about active processes. To get a complete printout on the console or lpr, use ``ps\ axlw'' For a quick snapshot of system activity, ``ps\ au'' is recommended. A hyphen may precede options with no effect. The following options may be specified. .TP .B a asks for information about all processes with terminals (ordinarily only one's own processes are displayed). .TP .B c causes only the .I comm field to be displayed instead of the arguments. (The comm field is the tail of the path name of the file the process last exec'ed.) This option speeds up .I ps somewhat and reduces the amount of output. It is also more reliable since the process can't scribble on top of it. .TP .B g asks for all processes. Without this option, .I ps only prints ``interesting'' processes. Processes are deemed to be uninteresting if they are process group leaders, or if their arguments begin with a `\-'. This normally eliminates shells and getty processes. .TP .B k causes the file .I /usr/sys/core is used in place of .IR /dev/kmem " and " /dev/mem. This is used for postmortem system debugging. .TP .B l asks for a long listing. The short listing contains the user name, process ID, tty, the cumulative execution time of the process and an approximation to the command line. .TP .B n asks for numeric rather than symbolic wchans. This flag implies the ``l'' flag. .TP .B r asks for ``raw'' output. A non-human readable sequence of structures is output on the standard output. There is one structure for each process, the format is defined by .TP .BI t ttyname restricts output to processes whose controlling tty is the specified ttyname (which should be specified as printed by .I ps, including .I t? for processes with no tty). This option must be the last one given. .TP .B u A user oriented output is produced. This includes the name of the owner of the process, process id, nice value, size, tty, cpu time used, and the command. .TP .B w tells .I ps you are on a wide terminal (132 columns). .I Ps normally assumes you are on an 80 column terminal. This information is used to decide how much of long commands to print. The .B w option may be repeated, e.g. .B ww, and the entire command, up to 128 characters, will be printed without regard to terminal width. .TP .B x asks even about processes with no terminal. .TP .B U causes ps to update a private database where is keeps system information. Thus ``ps \-U'' should be included in the /etc/rc file. .TP .B # A process number may be given, (indicated here by #), in which case the output is restricted to that process. This option must also be last. .PP A second argument tells .I ps where to look for .I core if the .I k option is given, instead of /usr/sys/core. A third argument is the name of a swap file to use instead of the default /dev/swap. If a fourth argument is given, it is taken to be the file containing the system's namelist. Otherwise, ``/unix'' is used. .PP The output is sorted by tty, then by process ID. .PP The long listing is columnar and contains .IP F Flags associated with the process. These are defined by #define lines in /usr/include/sys/proc.h. .IP S The state of the process. 0: nonexistent; S: sleeping; W: waiting; R: running; I: intermediate; Z: terminated; T: stopped. .IP UID The user id of the process owner. .IP PID The process ID of the process; as in certain cults it is possible to kill a process if you know its true name. .IP PPID The process ID of the parent process. .IP CPU Processor utilization for scheduling. .IP PRI The priority of the process; high numbers mean low priority. .IP NICE Used in priority computation. .IP ADDR The memory address of the process if resident, otherwise the disk address. .IP SZ The size in blocks (512 bytes) of the memory image of the process. .IP WCHAN The event for which the process is waiting or sleeping; if blank, the process is running. .IP TTY The controlling tty for the process. .IP TIME The cumulative execution time for the process. .IP COMMAND The command and its arguments. .DT .PP A process that has exited and has a parent, but has not yet been waited for by the parent is marked . .I Ps makes an educated guess as to the file name and arguments given when the process was created by examining memory or the swap area. The method is inherently somewhat unreliable and in any event a process is entitled to destroy this information, so the names cannot be counted on too much. .SH FILES .ta 2i /unix system namelist .br /dev/kmem kernel memory .br /dev/swap swap device .br /usr/sys/core core file .br /dev searched to find swap device and tty names .br /var/run/psdatabase system namelist and device information .SH "SEE ALSO" kill(1), w(1), pstat(8) .SH BUGS Things can change while .I ps is running; the picture it gives is only a close approximation to reality. ...br ..Some data printed for defunct processes is irrelevant. .PP Some processes, typically those in the background, are printed with null or garbaged arguments, even though the process has not swapped. (Sometimes ps even loses on its own arguments!) In these cases, the name of the command is printed in parentheses. .PP When automatic crash dumps are enabled, /usr/sys/core is not a sensible default core file name. ================================================ FILE: share/man/man1/ptx.1 ================================================ .\" @(#)ptx.1 6.1.1 (2.11BSD) 1996/10/22 .\" .TH PTX 1 "October 22, 1996" .AT 3 .SH NAME ptx \- permuted index .SH SYNOPSIS .B ptx [ option ] ... [ input [ output ] ] .SH DESCRIPTION .I Ptx generates a permuted index to file .I input on file .I output (standard input and output default). It has three phases: the first does the permutation, generating one line for each keyword in an input line. The keyword is rotated to the front. The permuted file is then sorted. Finally, the sorted lines are rotated so the keyword comes at the middle of the page. .I Ptx produces output in the form: .br .IP \&.xx "tail" "before keyword" "keyword and after" "head" .LP where .xx may be an .I nroff or .IR troff (1) macro for user-defined formatting. The .I before keyword and .I keyword and after fields incorporate as much of the line as will fit around the keyword when it is printed at the middle of the page. .I Tail and .I head, at least one of which is an empty string "", are wrapped-around pieces small enough to fit in the unused space at the opposite end of the line. When original text must be discarded, `/' marks the spot. .PP The following options can be applied: .TP .BR \-f Fold upper and lower case letters for sorting. .TP .BR \-t Prepare the output for the phototypesetter; the default line length is 100 characters. .TP .BI \-w " n" Use the next argument, .I n, as the width of the output line. The default line length is 72 characters. .TP .BI \-g " n" Use the next argument, .I n, as the number of characters to allow for each gap among the four parts of the line as finally printed. The default gap is 3 characters. .TP .BR \-o " only" Use as keywords only the words given in the \fIonly\fR file. .TP .BR \-i " ignore" Do not use as keywords any words given in the .I ignore file. If the \fB\-i\fR and \fB\-o\fR options are missing, use .I /usr/share/misc/eign as the .I ignore file. .TP .BR \-b " break" Use the characters in the .I break file to separate words. In any case, tab, newline, and space characters are always used as break characters. .TP .BR \-r Take any leading nonblank characters of each input line to be a reference identifier (as to a page or chapter) separate from the text of the line. Attach that identifier as a 5th field on each output line. .PP The index for this manual was generated using .I ptx. .SH FILES /usr/bin/sort .br /usr/share/misc/eign .SH BUGS Line length counts do not account for overstriking or proportional spacing. .br ================================================ FILE: share/man/man1/pwd.1 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)pwd.1 6.1 (Berkeley) 4/29/85 .\" .TH PWD 1 "April 29, 1985" .UC 4 .SH NAME pwd \- working directory name .SH SYNOPSIS .B pwd .SH DESCRIPTION .I Pwd prints the pathname of the working (current) directory. .SH "SEE ALSO" cd(1), csh(1), getwd(3) .SH BUGS In .IR csh (1) the command .I dirs is always faster (although it can give a different answer in the rare case that the current directory or a containing directory was moved after the shell descended into it). ================================================ FILE: share/man/man1/px.1 ================================================ .TH PX 1 "March 15, 1987" .UC .SH NAME px \- Pascal interpreter .SH SYNOPSIS .B px [ obj [ argument ... ] ] .SH DESCRIPTION .I Px interprets the abstract machine code generated by .I pi. The first argument is the file to be interpreted, and defaults to .IR obj \|; remaining arguments are available to the Pascal program using the built-ins .I argv and .I argc. .I Px is also invoked by .I pix when running `load and go'. .PP If the program terminates abnormally an error message and a control flow backtrace are printed. The number of statements executed and total execution time are printed after normal termination. The .B p option of .I pi suppresses all of this except the message indicating the cause of abnormal termination. .SH FILES .ta 2i obj default object file .br pmon.out profile data file .SH "SEE ALSO" Berkeley Pascal User's Manual .br pi(1), pix(1) .SH DIAGNOSTICS Most run-time error messages are self-explanatory. Some of the more unusual ones are: .HP 6 Reference to an inactive file .br A file other than .I input or .I output was used before a call to .I reset or .I rewrite. .HP 6 Statement count limit exceeded .br The limit of 500,000 executed statements (which prevents excessive looping or recursion) has been exceeded. .HP 6 Bad data found on integer read .br .ns .HP 6 Bad data found on real read .br Usually, non-numeric input was found for a number. For reals, Pascal requires digits before and after the decimal point so that numbers like `.1' or `21.' evoke the second diagnostic. .HP 6 panic: .I "Some message" .br Indicates a internal inconsistency detected in .I px probably due to a Pascal system bug. .sh AUTHORS Charles B. Haley, William N. Joy, and Ken Thompson .SH BUGS Calls to the procedures .I dispose and .I linelimit are ignored. .PP Post-mortem traceback is not limited; infinite recursion leads to almost infinite traceback. .PP Because interrupts sometimes find the system in the middle of a .B procedure or .B function entry or exit, the error backtrace on an interrupt is occasionally meaningless. The current line is, however, always correct; only the call backtrace and the name of the current routine may be lost. ================================================ FILE: share/man/man1/pxp.1 ================================================ .\" @(#)pxp.1 1.1 (2.11BSD) 1996/10/22 .TH PXP 1 "October 22, 1996" .UC .SH NAME pxp \- Pascal execution profiler .SH SYNOPSIS .B pxp [ .B \-acdefjnstuw_ ] [ .B \-23456789 ] [ .B \-z [ name ... ] ] name.p .SH DESCRIPTION .I Pxp can be used to obtain execution profiles of Pascal programs or as a pretty-printer. To produce an execution profile all that is necessary is to translate the program specifying the .B z option to .I pi or .I pix, to execute the program, and to then issue the command .DT .PP \fBpxp \-z\fP name.p .PP A reformatted listing is output if none of the .BR c , .BR t , or .B z options are specified; thus .PP \fBpxp\fP old.p > new.p .PP places a pretty-printed version of the program in `old.p' in the file `new.p'. .PP The use of the following options of .I pxp is discussed in sections 2.6, 5.4, 5.5 and 5.10 of the .IR "Berkeley Pascal User's Manual" "." .TP 6 .B \-\^a Print the bodies of all procedures and functions in the profile; even those which were never executed. .TP 6 .B \-\^c Extract profile data from the file .IR core . .TP 6 .B \-\^d Include declaration parts in a profile. .TP 6 .B \-\^e Eliminate .B include directives when reformatting a file; the .B include is replaced by the reformatted contents of the specified file. .TP 6 .B \-\^f Fully parenthesize expressions. .TP 6 .B \-\^j Left justify all procedures and functions. .TP 6 .B \-\^n Eject a new page as each file is included; in profiles, print a blank line at the top of the page. .TP 6 .B \-\^s Strip comments from the input text. .TP 6 .B \-\^t Print a table summarizing .B procedure and .B function call counts. .TP 6 .B \-\^u Card image mode; only the first 72 characters of input lines are used. .TP 6 .B \-\^w Suppress warning diagnostics. .TP 6 .B \-\^z Generate an execution profile. If no .IR name \|s, are given the profile is of the entire program. If a list of names is given, then only any specified .BR procedure s or .BR function s and the contents of any specified .B include files will appear in the profile. .TP 6 .B \-\^\_ Underline keywords. .TP 6 .BI \-\^ d With .I d a digit, 2 \(<= .IR d "" \(<= 9, causes .I pxp to use .IR d "" spaces as the basic indenting unit. The default is 4. .SH FILES .ta 2i name.p input file .br name.i include file(s) .br pmon.out profile data .br core profile data source with .B \-c .br /usr/share/pascal/how_pxp information on basic usage .br .ne 8 .SH "SEE ALSO" Berkeley Pascal User's Manual .br pi(1), px(1) .ne 5 .SH DIAGNOSTICS For a basic explanation do .IP .DT .B pxp .PP Error diagnostics include `No profile data in file' with the .B c option if the .B z option was not enabled to .I pi; `Not a Pascal system core file' if the core is not from a .I px execution; `Program and count data do not correspond' if the program was changed after compilation, before profiling; or if the wrong program is specified. .SH AUTHOR William N. Joy .SH BUGS Does not place multiple statements per line. ================================================ FILE: share/man/man1/pxref.1 ================================================ .TH PXREF 1 "March 15, 1987" .UC .SH NAME pxref \- Pascal cross-reference program .SH SYNOPSIS .B pxref [ .BR \- "" ] name .SH DESCRIPTION .I Pxref makes a line numbered listing and a cross-reference of identifier usage for the program in .I name. The optional `\fB\-\fP' argument suppresses the listing. The keywords .B goto and .B label are treated as identifiers for the purpose of the cross-reference. .B Include directives are not processed, but cause the placement of an entry indexed by `#include' in the cross-reference. .SH "SEE ALSO" Berkeley Pascal User's Manual .SH AUTHOR Niklaus Wirth .SH BUGS Identifiers are trimmed to 10 characters. ================================================ FILE: share/man/man1/quota.1 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)quota.1 6.1 (Berkeley) 4/29/85 .\" .TH QUOTA 1 "April 29, 1985" .UC 5 .SH NAME quota \- display disc usage and limits .SH SYNOPSIS .B quota [ .B \-qv ] [ user ] .SH DESCRIPTION .I Quota displays users' disc usage and limits. Only the super-user may use the optional .I user argument to view the limits of users other than himself. .PP The .B \-q flag prints a more terse message, containing only information on file systems where usage is over quota. .PP If a .B \-v flag is supplied, .I quota will also display user's quotas on file systems where no storage is allocated. .PP .I Quota reports only on file systems which have disc quotas. If .I quota exits with a non-zero status, one or more file systems are over quota. .SH "SEE ALSO" quota(2), quotaon(8) ================================================ FILE: share/man/man1/ratfor.1 ================================================ .\" @(#)ratfor.1 6.1 (Berkeley) 4/29/85 .\" .TH RATFOR 1 "April 29, 1985" .AT 3 .SH NAME ratfor \- rational Fortran dialect .SH SYNOPSIS .B ratfor [ option ... ] [ filename ... ] .SH DESCRIPTION .I Ratfor converts a rational dialect of Fortran into ordinary irrational Fortran. .I Ratfor provides control flow constructs essentially identical to those in C: .TP statement grouping: .nf { statement; statement; statement } .TP decision-making: if (condition) statement [ else statement ] .br switch (integer value) { case integer: statement ... [ default: ] statement } .TP loops: while (condition) statement for (expression; condition; expression) statement do limits statement repeat statement [ until (condition) ] break next .LP and some syntactic sugar to make programs easier to read and write: .TP free form input: multiple statements/line; automatic continuation .TP comments: # this is a comment .TP translation of relationals: >, >=, etc., become .GT., .GE., etc. .TP return (expression) returns expression to caller from function .TP define: define name replacement .TP include: include filename .PP .fi .I Ratfor is best used with .IR f77 (1). .SH "SEE ALSO" f77(1) .br B. W. Kernighan and P. J. Plauger, .IR "Software Tools" , Addison-Wesley, 1976. ================================================ FILE: share/man/man1/rcp.1 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)rcp.1c 6.4 (Berkeley) 5/12/86 .\" .TH RCP 1C "May 12, 1986" .UC 5 .SH NAME rcp \- remote file copy .SH SYNOPSIS .B rcp [ .B \-p ] file1 file2 .br .B rcp [ .B \-p ] [ .B \-r ] file ... directory .SH DESCRIPTION .I Rcp copies files between machines. Each .I file or .I directory argument is either a remote file name of the form ``rhost:path'', or a local file name (containing no `:' characters, or a `/' before any `:'s). .PP If the .B \-r option is specified and any of the source files are directories, .I rcp copies each subtree rooted at that name; in this case the destination must be a directory. .PP By default, the mode and owner of .I file2 are preserved if it already existed; otherwise the mode of the source file modified by the .IR umask (2) on the destination host is used. The .B \-p option causes .I rcp to attempt to preserve (duplicate) in its copies the modification times and modes of the source files, ignoring the .IR umask . .PP If .I path is not a full path name, it is interpreted relative to your login directory on .IR rhost . A .I path on a remote host may be quoted (using \e, ", or \(aa) so that the metacharacters are interpreted remotely. .PP .I Rcp does not prompt for passwords; your current local user name must exist on .I rhost and allow remote command execution via .IR rsh (1C). .PP .I Rcp handles third party copies, where neither source nor target files are on the current machine. Hostnames may also take the form ``rname@rhost'' to use .I rname rather than the current user name on the remote host. The destination hostname may also take the form ``rhost.rname'' to support destination machines that are running 4.2BSD versions of .I rcp. .SH SEE ALSO cp(1), ftp(1C), rsh(1C), rlogin(1C) .SH BUGS Doesn't detect all cases where the target of a copy might be a file in cases where only a directory should be legal. .br Is confused by any output generated by commands in a \&.login, \&.profile, or \&.cshrc file on the remote host. ================================================ FILE: share/man/man1/rdist.1 ================================================ .\" Copyright (c) 1985 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)rdist.1 6.6.1 (2.11BSD) 1996/10/22 .\" .TH RDIST 1 "October 22, 1996" .UC 6 .ad .SH NAME rdist \- remote file distribution program .SH SYNOPSIS .B rdist [ \-nqbRhivwy ] [ \-f distfile ] [ \-d var=value ] [ \-m host ] [ name ... ] .PP .B rdist [ \-nqbRhivwy ] -c name ... [login@]host[:dest] .SH DESCRIPTION .I Rdist is a program to maintain identical copies of files over multiple hosts. It preserves the owner, group, mode, and mtime of files if possible and can update programs that are executing. .I Rdist reads commands from .I distfile to direct the updating of files and/or directories. If .I distfile is `\-', the standard input is used. If no .B \-f option is present, the program looks first for `distfile', then `Distfile' to use as the input. If no names are specified on the command line, .I rdist will update all of the files and directories listed in .IR distfile . Otherwise, the argument is taken to be the name of a file to be updated or the label of a command to execute. If label and file names conflict, it is assumed to be a label. These may be used together to update specific files using specific commands. .PP The .B \-c option forces .I rdist to interpret the remaining arguments as a small .IR distfile . The equivalent distfile is as follows. .nf .ti +.5i ( \fIname\fP ... ) -> [\fIlogin\fP@]\fIhost\fP .ti +1i install [\fIdest\fP] ; .fi .PP Other options: .TP .B \-d Define .I var to have .IR value . The .B \-d option is used to define or override variable definitions in the .IR distfile . .I Value can be the empty string, one name, or a list of names surrounded by parentheses and separated by tabs and/or spaces. .TP .B \-m Limit which machines are to be updated. Multiple .B -m arguments can be given to limit updates to a subset of the hosts listed the .IR distfile . .TP .B \-n Print the commands without executing them. This option is useful for debugging .IR distfile . .TP .B \-q Quiet mode. Files that are being modified are normally printed on standard output. The .B \-q option suppresses this. .TP .B \-R Remove extraneous files. If a directory is being updated, any files that exist on the remote host that do not exist in the master directory are removed. This is useful for maintaining truely identical copies of directories. .TP .B \-h Follow symbolic links. Copy the file that the link points to rather than the link itself. .TP .B \-i Ignore unresolved links. .I Rdist will normally try to maintain the link structure of files being transfered and warn the user if all the links cannot be found. .TP .B \-v Verify that the files are up to date on all the hosts. Any files that are out of date will be displayed but no files will be changed nor any mail sent. .TP .B \-w Whole mode. The whole file name is appended to the destination directory name. Normally, only the last component of a name is used when renaming files. This will preserve the directory structure of the files being copied instead of flattening the directory structure. For example, renaming a list of files such as ( dir1/f1 dir2/f2 ) to dir3 would create files dir3/dir1/f1 and dir3/dir2/f2 instead of dir3/f1 and dir3/f2. .TP .B \-y Younger mode. Files are normally updated if their .I mtime and .I size (see .IR stat (2)) disagree. The .B \-y option causes .I rdist not to update files that are younger than the master copy. This can be used to prevent newer copies on other hosts from being replaced. A warning message is printed for files which are newer than the master copy. .TP .B \-b Binary comparison. Perform a binary comparison and update files if they differ rather than comparing dates and sizes. .PP .I Distfile contains a sequence of entries that specify the files to be copied, the destination hosts, and what operations to perform to do the updating. Each entry has one of the following formats. .nf .in +.5i `=' [ label: ] `\->' [ label: ] `::' .in .fi The first format is used for defining variables. The second format is used for distributing files to other hosts. The third format is used for making lists of files that have been changed since some given date. The \fIsource list\fP specifies a list of files and/or directories on the local host which are to be used as the master copy for distribution. The \fIdestination list\fP is the list of hosts to which these files are to be copied. Each file in the source list is added to a list of changes if the file is out of date on the host which is being updated (second format) or the file is newer than the time stamp file (third format). .PP Labels are optional. They are used to identify a command for partial updates. .PP Newlines, tabs, and blanks are only used as separators and are otherwise ignored. Comments begin with `#' and end with a newline. .PP Variables to be expanded begin with `$' followed by one character or a name enclosed in curly braces (see the examples at the end). .PP The source and destination lists have the following format: .nf .ti +.5i or .ti +.5i `(' `)' .fi The shell meta-characters `[', `]', `{', `}', `*', and `?' are recognized and expanded (on the local host only) in the same way as .IR csh (1). They can be escaped with a backslash. The `~' character is also expanded in the same way as .IR csh but is expanded separately on the local and destination hosts. When the .B \-w option is used with a file name that begins with `~', everything except the home directory is appended to the destination name. File names which do not begin with `/' or `~' use the destination user's home directory as the root directory for the rest of the file name. .PP The command list consists of zero or more commands of the following format. .nf .in +.5i .ta \w'install 'u +\w'name list 'u `install' opt_dest_name `;' `notify' `;' `except' `;' `except_pat' `;' `special' string `;' .in .fi .PP The .I install command is used to copy out of date files and/or directories. Each source file is copied to each host in the destination list. Directories are recursively copied in the same way. .I Opt_dest_name is an optional parameter to rename files. If no .I install command appears in the command list or the destination name is not specified, the source file name is used. Directories in the path name will be created if they do not exist on the remote host. To help prevent disasters, a non-empty directory on a target host will never be replaced with a regular file or a symbolic link. However, under the `\-R' option a non-empty directory will be removed if the corresponding filename is completely absent on the master host. The .I options are `\-R', `\-h', `\-i', `\-v', `\-w', `\-y', and `\-b' and have the same semantics as options on the command line except they only apply to the files in the source list. The login name used on the destination host is the same as the local host unless the destination name is of the format ``login@host". .PP The .I notify command is used to mail the list of files updated (and any errors that may have occured) to the listed names. If no `@' appears in the name, the destination host is appended to the name (e.g., name1@host, name2@host, ...). .PP The .I except command is used to update all of the files in the source list .B except for the files listed in \fIname list\fP. This is usually used to copy everything in a directory except certain files. .PP The .I except_pat command is like the .I except command except that \fIpattern list\fP is a list of regular expressions (see .IR ed (1) for details). If one of the patterns matches some string within a file name, that file will be ignored. Note that since `\e' is a quote character, it must be doubled to become part of the regular expression. Variables are expanded in \fIpattern list\fP but not shell file pattern matching characters. To include a `$', it must be escaped with `\e'. .PP The .I special command is used to specify .IR sh (1) commands that are to be executed on the remote host after the file in \fIname list\fP is updated or installed. If the \fIname list\fP is omitted then the shell commands will be executed for every file updated or installed. The shell variable `FILE' is set to the current filename before executing the commands in .IR string . .I String starts and ends with `"' and can cross multiple lines in .I distfile. Multiple commands to the shell should be separated by `;'. Commands are executed in the user's home directory on the host being updated. The .I special command can be used to rebuild private databases, etc. after a program has been updated. .PP The following is a small example. .nf .in +.5i HOSTS = ( matisse root@arpa) FILES = ( /bin /lib /usr/bin /usr/games /usr/include/{*.h,{stand,sys,vax*,pascal,machine}/*.h} /usr/lib /usr/man/man? /usr/ucb /usr/local/rdist ) EXLIB = ( Mail.rc aliases aliases.dir aliases.pag crontab dshrc sendmail.cf sendmail.fc sendmail.hf sendmail.st uucp vfont ) ${FILES} -> ${HOSTS} install -R ; except /usr/lib/${EXLIB} ; except /usr/games/lib ; special /usr/sbin/sendmail "/usr/sbin/sendmail -bz" ; srcs: /usr/src/bin -> arpa except_pat ( \e\e.o\e$ /SCCS\e$ ) ; IMAGEN = (ips dviimp catdvi) imagen: /usr/local/${IMAGEN} -> arpa install /usr/local/lib ; notify ralph ; ${FILES} :: stamp.cory notify root@cory ; .in .fi .SH FILES .nf .ta \w'/tmp/rdist* 'u distfile input command file /tmp/rdist* temporary file for update lists .fi .SH "SEE ALSO" sh(1), csh(1), stat(2) .SH DIAGNOSTICS A complaint about mismatch of rdist version numbers may really stem from some problem with starting your shell, e.g., you are in too many groups. .SH BUGS Source files must reside on the local host where rdist is executed. .PP There is no easy way to have a special command executed after all files in a directory have been updated. .PP Variable expansion only works for name lists; there should be a general macro facility. .PP .I Rdist aborts on files which have a negative mtime (before Jan 1, 1970). .PP There should be a `force' option to allow replacement of non-empty directories by regular files or symlinks. A means of updating file modes and owners of otherwise identical files is also needed. ================================================ FILE: share/man/man1/refer.1 ================================================ .\" @(#)refer.1 6.2.1 (2.11BSD) 1996/10/22 .\" .TH REFER 1 "October 22, 1996" .AT 3 .SH NAME refer \- find and insert literature references in documents .SH SYNOPSIS .B refer [ .B \-a ] [ .B \-b ] [ .B \-c ] [ .B \-e ] [ .BI \-f n ] [ .BI \-k x ] [ .BI \-l m,n ] [ .B \-n ] [ .B \-p bib ] [ .BI \-s keys ] [ .BI \-B l.m ] [ .B \-P ] [ .B \-S ] [ file ... ] .SH DESCRIPTION .I Refer is a preprocessor for .I nroff or .IR troff (1) that finds and formats references for footnotes or endnotes. It is also the base for a series of programs designed to index, search, sort, and print stand-alone bibliographies, or other data entered in the appropriate form. .PP Given an incomplete citation with sufficiently precise keywords, .I refer will search a bibliographic database for references containing these keywords anywhere in the title, author, journal, etc. The input file (or standard input) is copied to standard output, except for lines between .[ and .] delimiters, which are assumed to contain keywords, and are replaced by information from the bibliographic database. The user may also search different databases, override particular fields, or add new fields. The reference data, from whatever source, are assigned to a set of .I troff strings. Macro packages such as .IR ms (7) print the finished reference text from these strings. By default references are flagged by footnote numbers. .PP The following options are available: .TP 6 .BI \-a n Reverse the first .I n author names (Jones, J. A. instead of J. A. Jones). If .I n is omitted all author names are reversed. .ns .TP .B \-b Bare mode: do not put any flags in text (neither numbers nor labels). .ns .TP .BI \-c keys Capitalize (with C\s-2APS\s0 S\s-2MALL\s+2 C\s-2APS\s0) the fields whose key-letters are in .IR keys . .ns .TP .B \-e Instead of leaving the references where encountered, accumulate them until a sequence of the form .nf .[ $LIST$ .] .fi is encountered, and then write out all references collected so far. Collapse references to same source. .ns .TP .BI \-f n Set the footnote number to .I n instead of the default of 1 (one). With labels rather than numbers, this flag is a no-op. .ns .TP .BI \-k x Instead of numbering references, use labels as specified in a reference data line beginning .I %x; by default .I x is .B L. .ns .TP .BI \-l m , n Instead of numbering references, use labels made from the senior author's last name and the year of publication. Only the first .I m letters of the last name and the last .I n digits of the date are used. If either .I m or .I n is omitted the entire name or date respectively is used. .ns .TP .B \-n Do not search the default file /usr/dict/papers/Ind. If there is a REFER environment variable, the specified file will be searched instead of the default file; in this case the .B \-n flag has no effect. .ns .TP .BI \-p \0bib Take the next argument .I bib as a file of references to be searched. The default file is searched last. .ns .TP .BI \-s keys Sort references by fields whose key-letters are in the .I keys string; permute reference numbers in text accordingly. Implies .BR \-e . The key-letters in .I keys may be followed by a number to indicate how many such fields are used, with .B + taken as a very large number. The default is .B AD which sorts on the senior author and then date; to sort, for example, on all authors and then title, use .BR -sA+T . .ns .TP .BI \-B l.m Bibliography mode. Take a file composed of records separated by blank lines, and turn them into .I troff input. Label .I l will be turned into the macro .I .m with .I l defaulting to .B %X and .I .m defaulting to .B .AP (annotation paragraph). .ns .TP .B \-P Place punctuation marks .,:;?! after the reference signal, rather than before. (Periods and commas used to be done with strings.) .ns .TP .B \-S Produce references in the Natural or Social Science format. .PP To use your own references, put them in the format described below. They can be searched more rapidly by running .IR indxbib (1) on them before using .I refer; failure to index results in a linear search. When .I refer is used with the .I eqn, .I neqn or .I tbl preprocessors .I refer should be first, to minimize the volume of data passed through pipes. .PP The .I refer preprocessor and associated programs expect input from a file of references composed of records separated by blank lines. A record is a set of lines (fields), each containing one kind of information. Fields start on a line beginning with a ``%'', followed by a key-letter, then a blank, and finally the contents of the field, and continue until the next line starting with ``%''. The output ordering and formatting of fields is controlled by the macros specified for .I nroff/troff (for footnotes and endnotes) or .I roffbib (for stand-alone bibliographies). For a list of the most common key-letters and their corresponding fields, see .IR addbib (1). An example of a .I refer entry is given below. .SH EXAMPLE .PP .nf %A M. E. Lesk %T Some Applications of Inverted Indexes on the \s-1UNIX\s0 System %B \s-1UNIX\s0 Programmer's Manual %V 2b %I Bell Laboratories %C Murray Hill, NJ %D 1978 .fi .SH FILES .ta \w'/usr/dict/papers\0\0'u /usr/dict/papers directory of default publication lists .br /usr/libexec/refer directory of companion programs .SH SEE ALSO addbib(1), sortbib(1), roffbib(1), indxbib(1), lookbib(1) .SH AUTHOR Mike Lesk .SH BUGS Blank spaces at the end of lines in bibliography fields will cause the records to sort and reverse incorrectly. Sorting large numbers of references causes a core dump. ================================================ FILE: share/man/man1/rev.1 ================================================ .\" @(#)rev.1 6.1 (Berkeley) 4/29/85 .\" .TH REV 1 "April 29, 1985" .AT 3 .SH NAME rev \- reverse lines of a file .SH SYNOPSIS .B rev [ file ] ... .SH DESCRIPTION .I Rev copies the named files to the standard output, reversing the order of characters in every line. If no file is specified, the standard input is copied. ================================================ FILE: share/man/man1/rlogin.1 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)rlogin.1c 6.8 (Berkeley) 5/12/86 .\" .TH RLOGIN 1C "May 12, 1986" .UC 5 .SH NAME rlogin \- remote login .SH SYNOPSIS .B rlogin rhost [ \fB\-e\fR\fI\|c\fR ] [ .B \-8 ] [ .B \-L ] [ .B \-l username ] .br rhost [ \fB\-e\fR\fIc\fR ] [ .B \-8 ] [ .B \-L ] [ .B \-l username ] .SH DESCRIPTION .I Rlogin connects your terminal on the current local host system .I lhost to the remote host system .I rhost. .PP Each host has a file .I /etc/hosts.equiv which contains a list of \fIrhost\fR's with which it shares account names. (The host names must be the standard names as described in .IR rsh (1C).) When you .I rlogin as the same user on an equivalent host, you don't need to give a password. Each user may also have a private equivalence list in a file \&.rhosts in his login directory. Each line in this file should contain an \fIrhost\fP and a \fIusername\fP separated by a space, giving additional cases where logins without passwords are to be permitted. If the originating user is not equivalent to the remote user, then a login and password will be prompted for on the remote machine as in .IR login (1). To avoid some security problems, the \&.rhosts file must be owned by either the remote user or root. .PP The remote terminal type is the same as your local terminal type (as given in your environment TERM variable). The terminal or window size is also copied to the remote system if the server supports the option, and changes in size are reflected as well. All echoing takes place at the remote site, so that (except for delays) the rlogin is transparent. Flow control via ^S and ^Q and flushing of input and output on interrupts are handled properly. The optional argument .B \-8 allows an eight-bit input data path at all times; otherwise parity bits are stripped except when the remote side's stop and start characters are other than ^S/^Q. The argument .B \-L allows the rlogin session to be run in litout mode. A line of the form ``~.'' disconnects from the remote host, where ``~'' is the escape character. Similarly, the line ``~^Z'' (where ^Z, control-Z, is the suspend character) will suspend the rlogin session. Substitution of the delayed-suspend character (normally ^Y) for the suspend character suspends the send portion of the rlogin, but allows output from the remote system. A different escape character may be specified by the .B \-e option. There is no space separating this option flag and the argument character. .SH SEE ALSO rsh(1C) .SH FILES /usr/hosts/* for \fIrhost\fP version of the command .SH BUGS More of the environment should be propagated. ================================================ FILE: share/man/man1/rm.1 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)rm.1 6.1 (Berkeley) 4/29/85 .\" .TH RM 1 "April 29, 1985" .UC 4 .SH NAME rm, rmdir \- remove (unlink) files or directories .SH SYNOPSIS .B rm [ .B \-f ] [ .B \-r ] [ .B \-i ] [ .B \- ] file ... .PP .B rmdir dir ... .PP .SH DESCRIPTION .I Rm removes the entries for one or more files from a directory. If an entry was the last link to the file, the file is destroyed. Removal of a file requires write permission in its directory, but neither read nor write permission on the file itself. .PP If a file has no write permission and the standard input is a terminal, its permissions are printed and a line is read from the standard input. If that line begins with `y' the file is deleted, otherwise the file remains. No questions are asked and no errors are reported when the .B \-f (force) option is given. .PP If a designated file is a directory, an error comment is printed unless the optional argument .B \-r has been used. In that case, .I rm recursively deletes the entire contents of the specified directory, and the directory itself. .PP If the .B \-i (interactive) option is in effect, .I rm asks whether to delete each file, and, under .BR \-r , whether to examine each directory. .PP The null option .B \- indicates that all the arguments following it are to be treated as file names. This allows the specification of file names starting with a minus. .PP .I Rmdir removes entries for the named directories, which must be empty. .SH "SEE ALSO" rm(1), unlink(2), rmdir(2) ================================================ FILE: share/man/man1/rmail.1 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)rmail.1 6.1 (Berkeley) 4/29/85 .\" .TH RMAIL 1 "April 29, 1985" .UC 5 .SH NAME rmail \- handle remote mail received via uucp .SH SYNOPSIS .B rmail user ... .SH DESCRIPTION .I Rmail interprets incoming mail received via .IR uucp (1C), collapsing ``From'' lines in the form generated by .IR binmail (1) into a single line of the form ``return-path!sender'', and passing the processed mail on to .IR sendmail (8). .PP .I Rmail is explicitly designed for use with .I uucp and .IR sendmail . .SH "SEE ALSO" binmail(1), uucp(1C), sendmail(8) .SH BUGS .I Rmail should not reside in /bin. ================================================ FILE: share/man/man1/rmdir.1 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)rmdir.1 6.1 (Berkeley) 4/29/85 .\" .TH RMDIR 1 "April 29, 1985" .UC 5 .SH NAME rmdir, rm \- remove (unlink) directories or files .SH SYNOPSIS .B rmdir dir ... .PP .B rm [ .B \-f ] [ .B \-r ] [ .B \-i ] [ .B \- ] file ... .PP .SH DESCRIPTION .PP .I Rmdir removes entries for the named directories, which must be empty. .PP .I Rm removes the entries for one or more files from a directory. If an entry was the last link to the file, the file is destroyed. Removal of a file requires write permission in its directory, but neither read nor write permission on the file itself. .PP If a file has no write permission and the standard input is a terminal, its permissions are printed and a line is read from the standard input. If that line begins with `y' the file is deleted, otherwise the file remains. No questions are asked and no errors are reported when the .B \-f (force) option is given. .PP If a designated file is a directory, an error comment is printed unless the optional argument .B \-r has been used. In that case, .I rm recursively deletes the entire contents of the specified directory, and the directory itself. .PP If the .B \-i (interactive) option is in effect, .I rm asks whether to delete each file, and, under .BR \-r , whether to examine each directory. .PP The null option .B \- indicates that all the arguments following it are to be treated as file names. This allows the specification of file names starting with a minus. .SH "SEE ALSO" rm(1), unlink(2), rmdir(2) ================================================ FILE: share/man/man1/roffbib.1 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)roffbib.1 6.2.1 (2.11BSD) 1996/10/22 .\" .TH ROFFBIB 1 "October 22, 1996" .UC 5 .SH NAME roffbib \- run off bibliographic database .SH SYNOPSIS .B roffbib [ .B \-e ] [ .B \-h ] [ .B \-n ] [ .B \-o ] [ .B \-r ] [ .B \-s ] [ .BI \-T term ] [ .B \-x ] [ .B \-m .I mac ] [ .B \-V ] [ .B \-Q ] [ file ... ] .SH DESCRIPTION .I Roffbib prints out all records in a bibliographic database, in bibliography format rather than as footnotes or endnotes. Generally it is used in conjunction with .IR sortbib : .LP .RS sortbib database | roffbib .RE .LP .I Roffbib accepts most of the options understood by .IR nroff (1), most importantly the .B \-T flag to specify terminal type. .PP If abstracts or comments are entered following the %X field key, .I roffbib will format them into paragraphs for an annotated bibliography. Several %X fields may be given if several annotation paragraphs are desired. The .B \-x flag will suppress the printing of these abstracts. .PP A user-defined set of macros may be specified after the .B \-m option. There should be a space between the .B \-m and the macro filename. This set of macros will replace the ones defined in /usr/share/tmac/tmac.bib. The .B \-V flag will send output to the Versatec; the .B \-Q flag will queue output for the phototypesetter. .PP Four command-line registers control formatting style of the bibliography, much like the number registers of .IR ms (7). The command-line argument .BR \-r N1 will number the references starting at one (1). The flag .BR \-r V2 will double space the biblio\%graphy, while .BR \-r V1 will double space references but single space annotation paragraphs. The line length can be changed from the default 6.5 inches to 6 inches with the .BR \-r L6i argument, and the page offset can be set from the default of 0 to one inch by specifying .BR \-r O1i (capital O, not zero). Note: with the .B \-V and .B \-Q flags the default page offset is already one inch. .SH FILES .ta \w'/usr/share/tmac/tmac.bib\0\0'u .nf /usr/share/tmac/tmac.bib file of macros used by \fInroff/troff\fP .fi .SH SEE ALSO refer(1), addbib(1), sortbib(1), indxbib(1), lookbib(1) .SH BUGS Users have to rewrite macros to create customized formats. ================================================ FILE: share/man/man1/rsh.1 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)rsh.1c 6.1 (Berkeley) 4/29/85 .\" .TH RSH 1C "April 29, 1985" .UC 5 .SH NAME rsh \- remote shell .SH SYNOPSIS .B rsh host [ .B \-l username ] [ .B \-n ] command .br host [ .B \-l username ] [ .B \-n ] command .SH DESCRIPTION .I Rsh connects to the specified .I host, and executes the specified \fIcommand\fR. .I Rsh copies its standard input to the remote command, the standard output of the remote command to its standard output, and the standard error of the remote command to its standard error. Interrupt, quit and terminate signals are propagated to the remote command; \fIrsh\fP normally terminates when the remote command does. .PP The remote username used is the same as your local username, unless you specify a different remote name with the .B \-l option. This remote name must be equivalent (in the sense of .IR rlogin (1C)) to the originating account; no provision is made for specifying a password with a command. .PP If you omit .I command, then instead of executing a single command, you will be logged in on the remote host using .IR rlogin (1C). .PP Shell metacharacters which are not quoted are interpreted on local machine, while quoted metacharacters are interpreted on the remote machine. Thus the command .PP \ \ \ rsh otherhost cat remotefile >> localfile .PP appends the remote file .I remotefile to the localfile .I localfile, while .PP \ \ \ rsh otherhost cat remotefile ">>" otherremotefile .PP appends .I remotefile to .I otherremotefile. .PP Host names are given in the file /etc/hosts. Each host has one standard name (the first name given in the file), which is rather long and unambiguous, and optionally one or more nicknames. The host names for local machines are also commands in the directory /usr/hosts; if you put this directory in your search path then the .B rsh can be omitted. .SH FILES .ta 2i /etc/hosts .br /usr/hosts/* .DT .SH SEE ALSO rlogin(1C) .SH BUGS If you are using .IR csh (1) and put a .IR rsh (1C) in the background without redirecting its input away from the terminal, it will block even if no reads are posted by the remote command. If no input is desired you should redirect the input of .I rsh to /dev/null using the .B \-n option. .PP You cannot run an interactive command (like .IR rogue (6) or .IR vi (1)); use .IR rlogin (1C). .PP Stop signals stop the local \fIrsh\fP process only; this is arguably wrong, but currently hard to fix for reasons too complicated to explain here. ================================================ FILE: share/man/man1/ruptime.1 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)ruptime.1c 6.1 (Berkeley) 4/29/85 .\" .TH RUPTIME 1C "April 29, 1985" .UC 5 .SH NAME ruptime \- show host status of local machines .SH SYNOPSIS .B ruptime [ .B \-a ] [ .B \-r ] [ .B \-l ] [ .B \-t ] [ .B \-u ] .SH DESCRIPTION .I Ruptime gives a status line like .I uptime for each machine on the local network; these are formed from packets broadcast by each host on the network once a minute. .PP Machines for which no status report has been received for 11 minutes are shown as being down. .PP Users idle an hour or more are not counted unless the .B \-a flag is given. .PP Normally, the listing is sorted by host name. The .B \-l , .B \-t , and .B \-u flags specify sorting by load average, uptime, and number of users, respectively. The .B \-r flag reverses the sort order. .SH FILES .DT /usr/spool/rwho/whod.* data files .SH SEE ALSO rwho(1C) ================================================ FILE: share/man/man1/rwho.1 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)rwho.1c 6.1 (Berkeley) 4/29/85 .\" .TH RWHO 1C "April 29, 1985" .UC 5 .SH NAME rwho \- who's logged in on local machines .SH SYNOPSIS .B rwho [ .B \-a ] .SH DESCRIPTION The .I rwho command produces output similar to .I who, but for all machines on the local network. If no report has been received from a machine for 5 minutes then .I rwho assumes the machine is down, and does not report users last known to be logged into that machine. .PP If a users hasn't typed to the system for a minute or more, then .I rwho reports this idle time. If a user hasn't typed to the system for an hour or more, then the user will be omitted from the output of .I rwho unless the .B \-a flag is given. .SH FILES /usr/spool/rwho/whod.* information about other machines .SH SEE ALSO ruptime(1C), rwhod(8C) .SH BUGS This is unwieldy when the number of machines on the local net is large. ================================================ FILE: share/man/man1/sccs.1 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)sccs.1 2.5 (Berkeley) 5/12/86 .\" .TH SCCS 1 "May 12, 1986" .UC 5 .SH NAME sccs \- front end for the \s-1SCCS\s0 subsystem .SH SYNOPSIS .B sccs [ .B \-r ] [ .BI \-d path ] [ .BI \-p path ] command [ flags ] [ args ] .SH DESCRIPTION .I Sccs is a front end to the .SM SCCS programs that helps them mesh more cleanly with the rest of UNIX. It also includes the capability to run ``set user id'' to another user to provide additional protection. .PP Basically, .I sccs runs the .I command with the specified .I flags and .I args. Each argument is normally modified to be prepended with ``SCCS/s.''. .PP Flags to be interpreted by the .I sccs program must be before the .I command argument. Flags to be passed to the actual .SM SCCS program must come after the .I command argument. These flags are specific to the command and are discussed in the documentation for that command. .PP Besides the usual .SM SCCS commands, several ``pseudo-commands'' can be issued. These are: .IP edit 1i Equivalent to ``get \-e''. .IP delget Perform a delta on the named files and then get new versions. The new versions will have id keywords expanded, and will not be editable. The \-m, \-p, \-r, \-s, and \-y flags will be passed to delta, and the \-b, \-c, \-e, \-i, \-k, \-l, \-s, and \-x flags will be passed to get. .IP deledit Equivalent to ``delget'' except that the ``get'' phase includes the ``\-e'' flag. This option is useful for making a ``checkpoint'' of your current editing phase. The same flags will be passed to delta as described above, and all the flags listed for ``get'' above except \-e and \-k are passed to ``edit''. .IP create Creates an .SM SCCS file, taking the initial contents from the file of the same name. Any flags to ``admin'' are accepted. If the creation is successful, the files are renamed with a comma on the front. These should be removed when you are convinced that the .SM SCCS files have been created successfully. .IP fix Must be followed by a .B \-r flag. This command essentially removes the named delta, but leaves you with a copy of the delta with the changes that were in it. It is useful for fixing small compiler bugs, etc. Since it doesn't leave audit trails, it should be used carefully. .IP clean This routine removes everything from the current directory that can be recreated from SCCS files. It will not remove any files being edited. If the .B \-b flag is given, branches are ignored in the determination of whether they are being edited; this is dangerous if you are keeping the branches in the same directory. .IP unedit This is the opposite of an ``edit'' or a ``get \-e''. It should be used with extreme caution, since any changes you made since the get will be irretrievably lost. .IP info Gives a listing of all files being edited. If the .B \-b flag is given, branches (i.e., \s-1SID\s0's with two or fewer components) are ignored. If the .B \-u flag is given (with an optional argument) then only files being edited by you (or the named user) are listed. .IP check Like ``info'' except that nothing is printed if nothing is being edited, and a non-zero exit status is returned if anything is being edited. The intent is to have this included in an ``install'' entry in a makefile to insure that everything is included into the .SM SCCS file before a version is installed. .IP tell Gives a newline-separated list of the files being edited on the standard output. Takes the .B \-b and .B \-u flags like ``info'' and ``check''. .IP diffs Gives a ``diff'' listing between the current version of the program(s) you have out for editing and the versions in .SM SCCS format. The .B \-r, .B \-c, .B \-i, .B \-x, and .B \-t flags are passed to .I get\c ; the .B \-l, .B \-s, .B \-e, .B \-f, .B \-h, and .B \-b options are passed to .I diff. The .B \-C flag is passed to .I diff as .B \-c. .IP print This command prints out verbose information about the named files. .PP The .B \-r flag runs .I sccs as the real user rather than as whatever effective user .I sccs is ``set user id'' to. The .B \-d flag gives a root directory for the .SM SCCS files. The default is the current directory. The .B \-p flag defines the pathname of the directory in which the .SM SCCS files will be found; ``SCCS'' is the default. The .B \-p flag differs from the .B \-d flag in that the .B \-d argument is prepended to the entire pathname and the .B \-p argument is inserted before the final component of the pathname. For example, ``sccs \-d/x \-py get a/b'' will convert to ``get /x/a/y/s.b''. The intent here is to create aliases such as ``alias syssccs sccs -d/usr/src'' which will be used as ``syssccs get cmd/who.c''. Also, if the environment variable PROJECT is set, its value is used to determine the .B \-d flag. If it begins with a slash, it is taken directly; otherwise, the home directory of a user of that name is examined for a subdirectory ``src'' or ``source''. If such a directory is found, it is used. .PP Certain commands (such as .IR admin ) cannot be run ``set user id'' by all users, since this would allow anyone to change the authorizations. These commands are always run as the real user. .SH EXAMPLES .de BX .PP .nf .in +0.5i .. .de EX .fi .PP .. To get a file for editing, edit it, and produce a new delta: .BX sccs get \-e file.c ex file.c sccs delta file.c .EX To get a file from another directory: .BX sccs \-p/usr/src/sccs/s. get cc.c .EX or .BX sccs get /usr/src/sccs/s.cc.c .EX To make a delta of a large number of files in the current directory: .BX sccs delta *.c .EX To get a list of files being edited that are not on branches: .BX sccs info \-b .EX To delta everything being edited by you: .BX sccs delta \`sccs tell \-u\` .EX In a makefile, to get source files from an .SM SCCS file if it does not already exist: .BX SRCS = $(SRCS): sccs get $(REL) $@ .EX .SH "SEE ALSO" admin(SCCS), chghist(SCCS), comb(SCCS), delta(SCCS), get(SCCS), help(SCCS), prt(SCCS), rmdel(SCCS), sccsdiff(SCCS), what(SCCS) .br Eric Allman, .ul An Introduction to the Source Code Control System .SH BUGS It should be able to take directory arguments on pseudo-commands like the .SM SCCS commands do. ================================================ FILE: share/man/man1/script.1 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)script.1 6.1 (Berkeley) 4/29/85 .\" .TH SCRIPT 1 "April 29, 1985" .UC 4 .SH NAME script \- make typescript of terminal session .SH SYNOPSIS .B script [ .B \-a ] [ file ] .SH DESCRIPTION .I Script makes a typescript of everything printed on your terminal. The typescript is written to .IR file , or appended to .IR file if the .B \-a option is given. It can be sent to the line printer later with .IR lpr . If no file name is given, the typescript is saved in the file .IR typescript . .PP The script ends when the forked shell exits. .PP This program is useful when using a crt and a hard-copy record of the dialog is desired, as for a student handing in a program that was developed on a crt when hard-copy terminals are in short supply. .SH BUGS .I Script places .B everything in the log file. This is not what the naive user expects. ================================================ FILE: share/man/man1/sed.1 ================================================ .\" @(#)sed.1 6.1 (Berkeley) 4/29/85 .\" .TH SED 1 "April 29, 1985" .AT 3 .SH NAME sed \- stream editor .SH SYNOPSIS .B sed [ .B \-n ] [ .B \-e script ] [ .B \-f sfile ] [ file ] ... .SH DESCRIPTION .I Sed copies the named .I files (standard input default) to the standard output, edited according to a script of commands. The .B \-f option causes the script to be taken from file .IR sfile ; these options accumulate. If there is just one .B \-e option and no .BR \-f 's, the flag .B \-e may be omitted. The .B \-n option suppresses the default output. .PP A script consists of editing commands, one per line, of the following form: .IP [address [, address] ] function [arguments] .PP In normal operation .I sed cyclically copies a line of input into a .I pattern space (unless there is something left after a `D' command), applies in sequence all commands whose .I addresses select that pattern space, and at the end of the script copies the pattern space to the standard output (except under .BR \-n ) and deletes the pattern space. .PP An .I address is either a decimal number that counts input lines cumulatively across files, a `$' that addresses the last line of input, or a context address, `/regular expression/', in the style of .IR ed (1) modified thus: .IP The escape sequence `\en' matches a newline embedded in the pattern space. .PP A command line with no addresses selects every pattern space. .PP A command line with one address selects each pattern space that matches the address. .PP A command line with two addresses selects the inclusive range from the first pattern space that matches the first address through the next pattern space that matches the second. (If the second address is a number less than or equal to the line number first selected, only one line is selected.) Thereafter the process is repeated, looking again for the first address. .PP Editing commands can be applied only to non-selected pattern spaces by use of the negation function `!' (below). .PP In the following list of functions the maximum number of permissible addresses for each function is indicated in parentheses. .PP An argument denoted .I text consists of one or more lines, all but the last of which end with `\e' to hide the newline. Backslashes in text are treated like backslashes in the replacement string of an `s' command, and may be used to protect initial blanks and tabs against the stripping that is done on every script line. .PP An argument denoted .I rfile or .I wfile must terminate the command line and must be preceded by exactly one blank. Each .I wfile is created before processing begins. There can be at most 10 distinct .I wfile arguments. .TP (1)\|a\e .br .ns .TP .I text .br Append. Place .I text on the output before reading the next input line. .TP .RI (2)\|b " label" Branch to the `:' command bearing the .IR label . If .I label is empty, branch to the end of the script. .TP (2)\|c\e .br .ns .TP .I text .br Change. Delete the pattern space. With 0 or 1 address or at the end of a 2-address range, place .I text on the output. Start the next cycle. .TP (2)\|d Delete the pattern space. Start the next cycle. .TP (2)\|D Delete the initial segment of the pattern space through the first newline. Start the next cycle. .TP (2)\|g Replace the contents of the pattern space by the contents of the hold space. .TP (2)\|G Append the contents of the hold space to the pattern space. .TP (2)\|h Replace the contents of the hold space by the contents of the pattern space. .TP (2)\|H Append the contents of the pattern space to the hold space. .TP (1)\|i\e .br .ns .TP .I text .br Insert. Place .I text on the standard output. .TP (2)\|n Copy the pattern space to the standard output. Replace the pattern space with the next line of input. .TP (2)\|N Append the next line of input to the pattern space with an embedded newline. (The current line number changes.) .TP (2)\|p Print. Copy the pattern space to the standard output. .TP (2)\|P Copy the initial segment of the pattern space through the first newline to the standard output. .TP (1)\|q Quit. Branch to the end of the script. Do not start a new cycle. .TP .RI (2)\|r " rfile" Read the contents of .IR rfile . Place them on the output before reading the next input line. .TP .RI (2)\|s /regular\ expression/replacement/flags Substitute the .I replacement string for instances of the .I regular expression in the pattern space. Any character may be used instead of `/'. For a fuller description see .IR ed (1). .I Flags is zero or more of .RS .TP g Global. Substitute for all nonoverlapping instances of the .I regular expression rather than just the first one. .TP p Print the pattern space if a replacement was made. .TP .RI w " wfile" Write. Append the pattern space to .I wfile if a replacement was made. .RE .TP .RI (2)\|t " label" Test. Branch to the `:' command bearing the .I label if any substitutions have been made since the most recent reading of an input line or execution of a `t'. If .I label is empty, branch to the end of the script. .TP .RI (2)\|w " wfile" Write. Append the pattern space to .IR wfile . .TP .RI (2)\|x Exchange the contents of the pattern and hold spaces. .TP .RI (2)\|y /string1/string2/ Transform. Replace all occurrences of characters in .I string1 with the corresponding character in .I string2. The lengths of .I string1 and .I string2 must be equal. .TP .RI (2)! " function" Don't. Apply the .I function (or group, if .I function is `{') only to lines .I not selected by the address(es). .TP .RI (0)\|: " label" This command does nothing; it bears a .I label for `b' and `t' commands to branch to. .TP (1)\|= Place the current line number on the standard output as a line. .TP (2)\|{ Execute the following commands through a matching `}' only when the pattern space is selected. .TP (0)\| An empty command is ignored. .SH SEE ALSO ed(1), grep(1), awk(1), lex(1) ================================================ FILE: share/man/man1/sendbug.1 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)sendbug.1 6.2 (Berkeley) 5/5/86 .\" .TH SENDBUG 1 "May 5, 1986" .UC 5 .ad .SH NAME sendbug \- mail a system bug report to 4bsd-bugs .SH SYNOPSIS .B sendbug [ address ] .SH DESCRIPTION .PP Bug reports sent to `4bsd-bugs@Berkeley.EDU' are intercepted by a program which expects bug reports to conform to a standard format. .I Sendbug is a shell script to help the user compose and mail bug reports in the correct format. .I Sendbug works by invoking the editor specified by the environment variable .I EDITOR on a temporary copy of the bug report format outline. The user must fill in the appropriate fields and exit the editor. The default editor is .IR vi (1). .I Sendbug then mails the completed report to `4bsd-bugs@Berkeley.EDU' or the address specified on the command line. .SH FILES .nf .ta \w'/usr/ucb/bugformat 'u /usr/ucb/bugformat contains the bug report outline .fi .SH "SEE ALSO" vi(1), environ(7), sendmail(8) ================================================ FILE: share/man/man1/sh.1 ================================================ .\" @(#)sh.1 6.3 (Berkeley) 5/5/86 .\" .TH SH 1 "May 5, 1986" .AT 3 .SH NAME sh, for, case, if, while, \fB:\fP, \fB.\fP, break, continue, cd, eval, exec, exit, export, login, read, readonly, set, shift, times, trap, umask, wait \- command language .SH SYNOPSIS .B sh [ .B \-ceiknrstuvx ] [ arg ] ... .ds OK [\| .ds CK \|] .ds LT \s-2<\s0 .ds GT \s-2>\s0 .ds LE \s-2<\s0 .ds ST * .SH DESCRIPTION .I Sh is a command programming language that executes commands read from a terminal or a file. See .B invocation for the meaning of arguments to the shell. .PP .B Commands. .br A .I simple-command is a sequence of non blank .I words separated by blanks (a blank is a .B tab or a .BR space ). The first word specifies the name of the command to be executed. Except as specified below the remaining words are passed as arguments to the invoked command. The command name is passed as argument 0 (see .IR execve (2)). The .I value of a simple-command is its exit status if it terminates normally or 200+\fIstatus\fP if it terminates abnormally (see .IR sigvec (2) for a list of status values). .LP A .I pipeline is a sequence of one or more .I commands separated by .B \(or. The standard output of each command but the last is connected by a .IR pipe (2) to the standard input of the next command. Each command is run as a separate process; the shell waits for the last command to terminate. .LP A .I list is a sequence of one or more .I pipelines separated by .BR ; , .BR & , .B && or .B \(or\|\(or and optionally terminated by .B ; or .BR & . .B ; and .B & have equal precedence which is lower than that of .B && and .BR \(or\|\(or , .B && and .B \(or\|\(or also have equal precedence. A semicolon causes sequential execution; an ampersand causes the preceding .I pipeline to be executed without waiting for it to finish. The symbol .B && .RB ( \(or\|\(or ) causes the .I list following to be executed only if the preceding .I pipeline returns a zero (non zero) value. Newlines may appear in a .I list, instead of semicolons, to delimit commands. .LP A .I command is either a simple-command or one of the following. The value returned by a command is that of the last simple-command executed in the command. .TP \fBfor \fIname\fR \*(OK\fBin \fIword\fR ...\*(CK \fBdo \fIlist \fBdone\fR Each time a .B for command is executed .I name is set to the next word in the .B for word list. If .BI in \ word \&... is omitted, .B in "$@" is assumed. Execution ends when there are no more words in the list. .TP \fBcase \fIword \fBin\fR \*(OK\fIpattern \fR\*(OK \fB\(or \fIpattern \fR\*(CK ... \fB) \fIlist \fB;;\fR\*(CK ... \fBesac\fR A .B case command executes the .I list associated with the first pattern that matches .I word. The form of the patterns is the same as that used for file name generation. .TP \fBif \fIlist \fBthen \fIlist\fR \*(OK\fBelif \fIlist \fBthen \fIlist\fR\*(CK ... \*(OK\fBelse \fIlist\fR\*(CK \fBfi\fR The .I list following .B if is executed and if it returns zero the .I list following .B then is executed. Otherwise, the .I list following .B elif is executed and if its value is zero the .I list following .B then is executed. Failing that the .B else .I list is executed. .TP \fBwhile \fIlist\fR \*(OK\fBdo \fIlist\fR\*(CK \fBdone\fR A .B while command repeatedly executes the .B while .I list and if its value is zero executes the .B do .I list; otherwise the loop terminates. The value returned by a .B while command is that of the last executed command in the .B do .I list. .B until may be used in place of .B while to negate the loop termination test. .TP .BI ( " list " ) Execute .I list in a subshell. .TP .BI { " list " } .I list is simply executed. .LP The following words are only recognized as the first word of a command and when not quoted. .IP .B if then else elif fi case in esac for while until do done { } .PP .B Command substitution. .br The standard output from a command enclosed in a pair of back quotes .RB ( \`\|\` ) may be used as part or all of a word; trailing newlines are removed. .PP .B Parameter substitution. .br The character .B $ is used to introduce substitutable parameters. Positional parameters may be assigned values by .BR set . Variables may be set by writing .IP .IB name = value [ .IB name = value ] ... .TP $\fB\|{\fIparameter\fB\|}\fR A .I parameter is a sequence of letters, digits or underscores (a .IR name ), a digit, or any of the characters .B * @ # ? \- $ !\|. The value, if any, of the parameter is substituted. The braces are required only when .I parameter is followed by a letter, digit, or underscore that is not to be interpreted as part of its name. If .I parameter is a digit, it is a positional parameter. If .I parameter is .BR * " or" " @" then all the positional parameters, starting with .SM .BR $1 , are substituted separated by spaces. .SM .B $0 is set from argument zero when the shell is invoked. .TP $\fB\|{\fIparameter\|\-word\|\fB}\fR If .I parameter is set, substitute its value; otherwise substitute .I word. .TP $\fB\|{\fIparameter\|\(eq\|word\|\fB}\fR If .I parameter is not set, set it to .I word; the value of the parameter is then substituted. Positional parameters may not be assigned to in this way. .TP $\fB\|{\fIparameter\|?\|word\|\fB}\fR If .I parameter is set, substitute its value; otherwise, print .I word and exit from the shell. If .I word is omitted, a standard message is printed. .TP $\fB\|{\fIparameter\|\(plword\|\fB}\fR If .I parameter is set, substitute .I word; otherwise substitute nothing. .LP In the above .I word is not evaluated unless it is to be used as the substituted string. (So that, for example, echo ${d\-\'pwd\'} will only execute .I pwd if .I d is unset.) .LP The following .I parameters are automatically set by the shell. .RS .TP .B # The number of positional parameters in decimal. .PD 0 .TP .B \- Options supplied to the shell on invocation or by .BR set . .TP .B ? The value returned by the last executed command in decimal. .TP .B $ The process number of this shell. .TP .B ! The process number of the last background command invoked. .PD .RE .LP The following .I parameters are used but not set by the shell. .RS .TP .B .SM HOME The default argument (home directory) for the .B cd command. .PD 0 .TP .B .SM PATH The search path for commands (see .BR execution ). .TP .B .SM MAIL If this variable is set to the name of a mail file, the shell informs the user of the arrival of mail in the specified file. .SM .TP .B PS1 Primary prompt string, by default '$ '. .TP .SM .B PS2 Secondary prompt string, by default '> '. .TP .SM .B IFS Internal field separators, normally .BR space , .BR tab , and .BR newline . .B IFS is ignored if .I sh is running as root or if the effective user id differs from the real user id. .PD .RE .PP .B Blank interpretation. .br After parameter and command substitution, any results of substitution are scanned for internal field separator characters (those found in .SM .BR $IFS \*S) and split into distinct arguments where such characters are found. Explicit null arguments ("" or \'\') are retained. Implicit null arguments (those resulting from .I parameters that have no values) are removed. .PP .B File name generation. .br Following substitution, each command word is scanned for the characters .BR * , .B ? and .B \*(OK. If one of these characters appears, the word is regarded as a pattern. The word is replaced with alphabetically sorted file names that match the pattern. If no file name is found that matches the pattern, the word is left unchanged. The character .B . at the start of a file name or immediately following a .BR / , and the character .BR / , must be matched explicitly. .TP .B \*(ST Matches any string, including the null string. .PD 0 .TP .B ? Matches any single character. .TP .B \*(OK...\*(CK Matches any one of the characters enclosed. A pair of characters separated by .B \- matches any character lexically between the pair. .PD .PP .B Quoting. .br The following characters have a special meaning to the shell and cause termination of a word unless quoted. .LP \fB; & ( ) \(or \*(LT \*(GT newline space tab\fP .LP A character may be .I quoted by preceding it with a .B \\\|. .B \\\\newline is ignored. All characters enclosed between a pair of quote marks (\fB\'\|\'\fP), except a single quote, are quoted. Inside double quotes (\fB"\|"\fP) parameter and command substitution occurs and .B \\ quotes the characters .B \\ \' " and .BR $ \|. .LP .B "$*" is equivalent to .SM .B "$1 $2 ..." whereas .br .B "$@" is equivalent to .SM .B "$1" "$2" ... . .PP .B Prompting. .br When used interactively, the shell prompts with the value of .SM PS1 before reading a command. If at any time a newline is typed and further input is needed to complete a command, the secondary prompt .RB ( \s-2$PS2\s0 ) is issued. .PP .B Input output. .br Before a command is executed its input and output may be redirected using a special notation interpreted by the shell. The following may appear anywhere in a simple-command or may precede or follow a .I command and are not passed on to the invoked command. Substitution occurs before .I word or .I digit is used. .TP \*(LT\fI\|word\fP Use file .I word as standard input (file descriptor 0). .PD .TP \*(GT\fI\|word\fP Use file .I word as standard output (file descriptor 1). If the file does not exist, it is created; otherwise it is truncated to zero length. .TP \*(GT\*(GT\fI\|word\fP Use file .I word as standard output. If the file exists, output is appended (by seeking to the end); otherwise the file is created. .TP \*(LT\*(LT\fI\|word\fP The shell input is read up to a line the same as .IR word , or end of file. The resulting document becomes the standard input. If any character of .I word is quoted, no interpretation is placed upon the characters of the document; otherwise, parameter and command substitution occurs, .B \\newline is ignored, and .B \\ is used to quote the characters .B \\ $ \' and the first character of .I word. .TP \*(LT\|&\|\fIdigit\fP The standard input is duplicated from file descriptor .I digit; see .IR dup (2). Similarly for the standard output using \*(GT\|. .TP \*(LT\|&\|\- The standard input is closed. Similarly for the standard output using \*(GT\|. .PD .LP If one of the above is preceded by a digit, the file descriptor created is that specified by the digit (instead of the default 0 or 1). For example, .LP \&... 2\*(GT&1 .LP creates file descriptor 2 to be a duplicate of file descriptor 1. .LP If a command is followed by .B & then the default standard input for the command is the empty file (/dev/null). Otherwise, the environment for the execution of a command contains the file descriptors of the invoking shell as modified by input output specifications. .PP .B Environment. .br The environment is a list of name-value pairs that is passed to an executed program in the same way as a normal argument list; see .IR execve (2) and .IR environ (7). The shell interacts with the environment in several ways. On invocation, the shell scans the environment and creates a .I parameter for each name found, giving it the corresponding value. Executed commands inherit the same environment. If the user modifies the values of these .I parameters or creates new ones, none of these affects the environment unless the .B export command is used to bind the shell's .I parameter to the environment. The environment seen by any executed command is thus composed of any unmodified name-value pairs originally inherited by the shell, plus any modifications or additions, all of which must be noted in .B export commands. .LP The environment for any .I simple-command may be augmented by prefixing it with one or more assignments to .I parameters. Thus these two lines are equivalent .IP TERM=450 cmd args .br (export TERM; TERM=450; cmd args) .LP If the .B \-k flag is set, .I all keyword arguments are placed in the environment, even if the occur after the command name. The following prints 'a=b c' and 'c': .nf echo a=b c set \-k echo a=b c .fi .PP .B Signals. .br The INTERRUPT and QUIT signals for an invoked command are ignored if the command is followed by .BR & ; otherwise signals have the values inherited by the shell from its parent. (But see also .BR trap. ) .PP .B Execution. .br Each time a command is executed the above substitutions are carried out. Except for the 'special commands' listed below a new process is created and an attempt is made to execute the command via an .IR execve (2). .LP The shell parameter .B .SM $PATH defines the search path for the directory containing the command. Each alternative directory name is separated by a colon .RB ( : ). The default path is .BR :/bin:/usr/bin . If the command name contains a /, the search path is not used. Otherwise, each directory in the path is searched for an executable file. If the file has execute permission but is not an .I a.out file, it is assumed to be a file containing shell commands. A subshell (i.e., a separate process) is spawned to read it. A parenthesized command is also executed in a subshell. .PP .B Special commands. .br The following commands are executed in the shell process and except where specified no input output redirection is permitted for such commands. .TP .B # For non-interactive shells, everything following the .B # is treated as a comment, i.e. the rest of the line is ignored. For interactive shells, the .B # has no special effect. .TP .B : No effect; the command does nothing. .PD 0 .TP .BI . \ file Read and execute commands from .I file and return. The search path .B .SM $PATH is used to find the directory containing .IR file . .TP \fBbreak\fR \*(OK\fIn\fR\*(CK Exit from the enclosing .B for or .B while loop, if any. If .I n is specified, break .I n levels. .TP \fBcontinue\fR \*(OK\fIn\fR\*(CK Resume the next iteration of the enclosing .B for or .B while loop. If .I n is specified, resume at the .IR n -th enclosing loop. .TP \fBcd\fR \*(OK\fIarg\fR\*(CK Change the current directory to .I arg. The shell parameter .B .SM $HOME is the default .IR arg . .TP \fBeval\fR \*(OK\fIarg \fR...\*(CK The arguments are read as input to the shell and the resulting command(s) executed. .TP \fBexec\fR \*(OK\fIarg \fR...\*(CK The command specified by the arguments is executed in place of this shell without creating a new process. Input output arguments may appear and if no other arguments are given cause the shell input output to be modified. .TP \fBexit\fR \*(OK\fIn\fR\*(CK Causes a non interactive shell to exit with the exit status specified by .I n. If .I n is omitted, the exit status is that of the last command executed. (An end of file will also exit from the shell.) .TP \fBexport\fR \*(OK\fIname\fR ...\*(CK The given names are marked for automatic export to the .I environment of subsequently-executed commands. If no arguments are given, a list of exportable names is printed. .TP \fBlogin\fR \*(OK\fIarg\fR ...\*(CK Equivalent to 'exec login arg ...'. .TP .BI read \ name\ ... One line is read from the standard input; successive words of the input are assigned to the variables .I name in order, with leftover words to the last variable. The return code is 0 unless the end-of-file is encountered. .TP \fBreadonly\fR \*(OK\fIname \fR...\*(CK The given names are marked readonly and the values of the these names may not be changed by subsequent assignment. If no arguments are given, a list of all readonly names is printed. .TP \fBset\fR \*(OK\fB\-eknptuvx\fR \*(OK\fIarg \fR...\*(CK\*(CK .RS .PD 0 .TP 3m .B \-e If non interactive, exit immediately if a command fails. .TP .B \-k All keyword arguments are placed in the environment for a command, not just those that precede the command name. .TP .B \-n Read commands but do not execute them. .TP .B \-t Exit after reading and executing one command. .TP .B \-u Treat unset variables as an error when substituting. .TP .B \-v Print shell input lines as they are read. .TP .B \-x Print commands and their arguments as they are executed. .TP .B \- Turn off the .B \-x and .B \-v options. .PD .LP These flags can also be used upon invocation of the shell. The current set of flags may be found in .BR $\- . .LP Remaining arguments are positional parameters and are assigned, in order, to .SM .BR $1 , .SM .BR $2 , etc. If no arguments are given, the values of all names are printed. .RE .TP .B shift The positional parameters from .SM .BR $2 ... are renamed .SM .BR $1 ... .TP .B times Print the accumulated user and system times for processes run from the shell. .TP \fBtrap\fR \*(OK\fIarg\fR\*(CK \*(OK\fIn\fR\*(CK ... .I Arg is a command to be read and executed when the shell receives signal(s) .I n. (Note that .I arg is scanned once when the trap is set and once when the trap is taken.) Trap commands are executed in order of signal number. If .I arg is absent, all trap(s) .I n are reset to their original values. If .I arg is the null string, this signal is ignored by the shell and by invoked commands. If .I n is 0, the command .I arg is executed on exit from the shell, otherwise upon receipt of signal .I n as numbered in .IR sigvec (2). .I Trap with no arguments prints a list of commands associated with each signal number. .TP \fBumask \fR[ \fInnn\fR ] The user file creation mask is set to the octal value .I nnn (see .IR umask (2)). If .I nnn is omitted, the current value of the mask is printed. .TP \fBwait\fP \*(OK\fIn\fP\*(CK Wait for the specified process and report its termination status. If .I n is not given, all currently active child processes are waited for. The return code from this command is that of the process waited for. .PD .LP .PP .B Invocation. .br If the first character of argument zero is .BR \- , commands are read from .BR \s-2$HOME\s0/.\|profile , if such a file exists. Commands are then read as described below. The following flags are interpreted by the shell when it is invoked. .PD 0 .TP 11n .BI \-c \ string If the .B \-c flag is present, commands are read from .I string\|. .TP 11n .B \-s If the .B \-s flag is present or if no arguments remain then commands are read from the standard input. Shell output is written to file descriptor 2. .TP 11n .B \-i If the .B \-i flag is present or if the shell input and output are attached to a terminal (as told by .IR gtty ) then this shell is .I interactive. In this case the terminate signal SIGTERM (see .IR sigvec (2)) is ignored (so that 'kill 0' does not kill an interactive shell) and the interrupt signal SIGINT is caught and ignored (so that .B wait is interruptible). In all cases SIGQUIT is ignored by the shell. .PD .LP The remaining flags and arguments are described under the .B set command. .SH FILES .RB $HOME/ . \^profile .br /tmp/sh* .br /dev/null .SH SEE ALSO csh(1), test(1), execve(2), environ(7) .SH DIAGNOSTICS Errors detected by the shell, such as syntax errors cause the shell to return a non zero exit status. If the shell is being used non interactively then execution of the shell file is abandoned. Otherwise, the shell returns the exit status of the last command executed (see also .BR exit ). .SH BUGS If \*(LT\*(LT is used to provide standard input to an asynchronous process invoked by &, the shell gets mixed up about naming the input document. A garbage file /tmp/sh* is created, and the shell complains about not being able to find the file by another name. ================================================ FILE: share/man/man1/size.1 ================================================ .\" @(#)size.1 6.1 (Berkeley) 4/29/85 .\" .TH SIZE 1 "April 29, 1985" .AT 3 .SH NAME size \- size of an object file .SH SYNOPSIS .B size [ object ... ] .SH DESCRIPTION .I Size prints the (decimal) number of bytes required by the text, data, and bss portions, and their sum in hex and decimal, of each object-file argument. If no file is specified, .B a.out is used. .SH "SEE ALSO" a.out(5) ================================================ FILE: share/man/man1/sleep.1 ================================================ .\" @(#)sleep.1 6.1 (Berkeley) 4/29/85 .\" .TH SLEEP 1 "April 29, 1985" .AT 3 .SH NAME sleep \- suspend execution for an interval .SH SYNOPSIS .B sleep time .SH DESCRIPTION .I Sleep suspends execution for .I time seconds. It is used to execute a command after a certain amount of time as in: .PP (sleep 105; command)& .PP or to execute a command every so often, as in: .PP while true .br do .br command .br sleep 37 .br done .SH "SEE ALSO" setitimer(2), alarm(3C), sleep(3) .SH BUGS .I Time must be less than 2,147,483,647 seconds. ================================================ FILE: share/man/man1/soelim.1 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)soelim.1 6.2.1 (2.11BSD) 1996/10/22 .\" .TH SOELIM 1 "October 22, 1996" .UC .SH NAME soelim \- eliminate \&.so's from nroff input .SH SYNOPSIS .B soelim [ file ... ] .SH DESCRIPTION .I Soelim reads the specified files or the standard input and performs the textual inclusion implied by the .I nroff directives of the form .PP .DT \&.so somefile .PP when they appear at the beginning of input lines. This is useful since programs such as .I tbl do not normally do this; it allows the placement of individual tables in separate files to be run as a part of a large document. .PP An argument consisting of a single minus .RB ( \- ) is taken to be a file name corresponding to the standard input. .PP Note that inclusion can be suppressed by using `\'' instead of `\.', i.e. .PP .DT \'so /usr/share/tmac/tmac.s .PP A sample usage of .I soelim would be .PP soelim exum?.n | tbl | nroff \-ms | col | lpr .SH SEE\ ALSO colcrt(1), more(1) .SH BUGS The format of the source commands must involve no strangeness \- exactly one blank must precede and no blanks follow the file name. ================================================ FILE: share/man/man1/sort.1 ================================================ .\" @(#)sort.1 6.1 (Berkeley) 4/29/85 .\" .TH SORT 1 "April 29, 1985" .AT 3 .SH NAME sort \- sort or merge files .SH SYNOPSIS .B sort [ .if t \fB\-mubdf\&inrt\fIx\fR .if n -mubdfinrt_________x ] [ \fB+\fIpos1 \fR [ \fB\-\fIpos2 \fR] ] ... [ .B \-o name ] [ .B \-T directory ] [ name ] ... .SH DESCRIPTION .I Sort sorts lines of all the named files together and writes the result on the standard output. The name `\-' means the standard input. If no input files are named, the standard input is sorted. .LP The default sort key is an entire line. Default ordering is lexicographic by bytes in machine collating sequence. The ordering is affected globally by the following options, one or more of which may appear. .TP 5 .B b Ignore leading blanks (spaces and tabs) in field comparisons. .TP 5 .B d `Dictionary' order: only letters, digits and blanks are significant in comparisons. .TP 5 .B f Fold upper case letters onto lower case. .TP 5 .B i Ignore characters outside the ASCII range 040-0176 in nonnumeric comparisons. .TP 5 .B n An initial numeric string, consisting of optional blanks, optional minus sign, and zero or more digits with optional decimal point, is sorted by arithmetic value. Option .B n implies option .B b. .TP 5 .B r Reverse the sense of comparisons. .TP 5 .BI t x `Tab character' separating fields is .IR x . .LP The notation .BI + "pos1 " "\-\fIpos2" restricts a sort key to a field beginning at .I pos1 and ending just before .IR pos2 . .I Pos1 and .I pos2 each have the form .IB m . n\fR, optionally followed by one or more of the flags .B bdf\&inr, where .I m tells a number of fields to skip from the beginning of the line and .I n tells a number of characters to skip further. If any flags are present they override all the global ordering options for this key. If the .B b option is in effect .I n is counted from the first nonblank in the field; .B b is attached independently to .IR pos2 . A missing \&\fB.\fIn\fR means .0; a missing .BI \- pos2 means the end of the line. Under the .BI \-t x option, fields are strings separated by .IR x ; otherwise fields are nonempty nonblank strings separated by blanks. .LP When there are multiple sort keys, later keys are compared only after all earlier keys compare equal. Lines that otherwise compare equal are ordered with all bytes significant. .LP These option arguments are also understood: .TP 5 .B c Check that the input file is sorted according to the ordering rules; give no output unless the file is out of sort. .TP 5 .B m Merge only, the input files are already sorted. .TP 5 .B o The next argument is the name of an output file to use instead of the standard output. This file may be the same as one of the inputs. .TP 5 .B T The next argument is the name of a directory in which temporary files should be made. .TP 5 .B u Suppress all but one in each set of equal lines. Ignored bytes and bytes outside keys do not participate in this comparison. .SH EXAMPLES .LP Print in alphabetical order all the unique spellings in a list of words. Capitalized words differ from uncapitalized. .LP .ti +8 sort \-u +0f +0 list .LP Print the password file .RI ( passwd (5)) sorted by user id number (the 3rd colon-separated field). .LP .ti +8 sort \-t: +2n /etc/passwd .LP Print the first instance of each month in an already sorted file of (month day) entries. The options .B \-um with just one input file make the choice of a unique representative from a set of equal lines predictable. .LP .ti +8 sort \-um +0 \-1 dates .SH FILES /usr/tmp/stm*, /tmp/* first and second tries for temporary files .SH "SEE ALSO" uniq(1), comm(1), rev(1), join(1) .SH DIAGNOSTICS Comments and exits with nonzero status for various trouble conditions and for disorder discovered under option .BR \-c . .SH BUGS Very long lines are silently truncated. ================================================ FILE: share/man/man1/sortbib.1 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)sortbib.1 6.1 (Berkeley) 4/29/85 .\" .TH SORTBIB 1 "April 29, 1985" .UC 5 .SH NAME sortbib \- sort bibliographic database .SH SYNOPSIS .B sortbib [ .BR \-s KEYS ] database ... .SH DESCRIPTION .I Sortbib sorts files of records containing .I refer key-letters by user-specified keys. Records may be separated by blank lines, or by \&.[ and \&.] delimiters, but the two styles may not be mixed together. This program reads through each .I database and pulls out key fields, which are sorted separately. The sorted key fields contain the file pointer, byte offset, and length of corresponding records. These records are delivered using disk seeks and reads, so .I sortbib may not be used in a pipeline to read standard input. .PP By default, .I sortbib alphabetizes by the first %A and the %D fields, which contain the senior author and date. The .B \-s option is used to specify new .IR \s-1KEYS\s0 . For instance, .BR \-s ATD will sort by author, title, and date, while .BR \-s A+D will sort by all authors, and date. Sort keys past the fourth are not meaningful. No more than 16 databases may be sorted together at one time. Records longer than 4096 characters will be truncated. .PP .I Sortbib sorts on the last word on the %A line, which is assumed to be the author's last name. A word in the final position, such as ``jr.'' or ``ed.'', will be ignored if the name beforehand ends with a comma. Authors with two-word last names or unusual constructions can be sorted correctly by using the .I nroff convention ``\e0'' in place of a blank. A %Q field is considered to be the same as %A, except sorting begins with the first, not the last, word. .I Sortbib sorts on the last word of the %D line, usually the year. It also ignores leading articles (like ``A'' or ``The'') when sorting by titles in the %T or %J fields; it will ignore articles of any modern European language. If a sort-significant field is absent from a record, .I sortbib places that record before other records containing that field. .SH SEE ALSO refer(1), addbib(1), roffbib(1), indxbib(1), lookbib(1) .SH AUTHORS Greg Shenaut, Bill Tuthill .SH BUGS Records with missing author fields should probably be sorted by title. ================================================ FILE: share/man/man1/spell.1 ================================================ .\" @(#)spell.1 6.1.1 (2.11BSD) 1996/10/22 .\" .TH SPELL 1 "October 22, 1996" .AT 3 .SH NAME spell, spellin, spellout \- find spelling errors .SH SYNOPSIS .B spell [ .B \-v ] [ .B \-b ] [ .B \-x ] [ .B \-d hlist ] [ .B \-s hstop ] [ .B \-h spellhist ] [ file ] ... .PP .B spellin [ list ] .PP .B spellout [ .B \-d ] list .SH DESCRIPTION .I Spell collects words from the named documents, and looks them up in a spelling list. Words that neither occur among nor are derivable (by applying certain inflections, prefixes or suffixes) from words in the spelling list are printed on the standard output. If no files are named, words are collected from the standard input. .PP .I Spell ignores most .I troff, .I tbl and .IR eqn (1) constructions. .PP Under the .B \-v option, all words not literally in the spelling list are printed, and plausible derivations from spelling list words are indicated. .PP Under the .B \-b option, British spelling is checked. Besides preferring .ft I centre, colour, speciality, travelled, .ft R etc., this option insists upon .I -ise in words like .I standardise, Fowler and the OED to the contrary notwithstanding. .PP Under the .B \-x option, every plausible stem is printed with `=' for each word. .PP The spelling list is based on many sources. While it is more haphazard than an ordinary dictionary, it is also more effective with proper names and popular technical words. Coverage of the specialized vocabularies of biology, medicine and chemistry is light. .PP The auxiliary files used for the spelling list, stop list, and history file may be specified by arguments following the .BR \-d , .BR \-s , and .B \-h options. The default files are indicated below. Copies of all output may be accumulated in the history file. The stop list filters out misspellings (e.g. thier=thy\-y+ier) that would otherwise pass. .PP Two routines help maintain the hash lists used by .I spell. Both expect a set of words, one per line, from the standard input. .I Spellin combines the words from the standard input and the preexisting .I list file and places a new list on the standard output. If no .I list file is specified, the new list is created from scratch. .I Spellout looks up each word from the standard input and prints on the standard output those that are missing from (or present on, with option .BR \-d ) the hashed .I list file. For example, to verify that .I hookey is not on the default spelling list, add it to your own private list, and then use it with .IR spell , .PP .RS .nf echo hookey | spellout /usr/dict/hlista echo hookey | spellin /usr/dict/hlista > myhlist spell \-d myhlist huckfinn .RE .SH FILES /usr/dict/hlist[ab] hashed spelling lists, American & British, default for .B \-d .br /usr/dict/hstop hashed stop list, default for .B \-s .br /dev/null history file, default for .B \-h .br /tmp/spell.$$\(** temporary files .br /usr/libexec/spell .br .SH SEE ALSO deroff(1), sort(1), tee(1), sed(1) .SH BUGS The spelling list's coverage is uneven; new installations will probably wish to monitor the output for several months to gather local additions. .br British spelling was done by an American. ================================================ FILE: share/man/man1/spline.1 ================================================ .\" @(#)spline.1g 6.1 (Berkeley) 4/29/85 .\" .TH SPLINE 1G "April 29, 1985" .AT 3 .SH NAME spline \- interpolate smooth curve .SH SYNOPSIS .B spline [ option ] ... .SH DESCRIPTION .I Spline takes pairs of numbers from the standard input as abcissas and ordinates of a function. It produces a similar set, which is approximately equally spaced and includes the input set, on the standard output. The cubic spline output (R. W. Hamming, .ft I Numerical Methods for Scientists and Engineers, .ft R 2nd ed., 349ff) has two continuous derivatives, and sufficiently many points to look smooth when plotted, for example by .IR graph (1G). .PP The following options are recognized, each as a separate argument. .TP 5 .B \-a Supply abscissas automatically (they are missing from the input); spacing is given by the next argument, or is assumed to be 1 if next argument is not a number. .TP 5 .B \-k The constant .IR k "" used in the boundary value computation .IP .if n .ig .ti +1.5i .ds ' \h'-\w'\(fm\(fm'u' .EQ .nr 99 \n(.s .nr 98 \n(.f 'ps 10 .ft I .ds 11 "y\(fm\(fm .nr 11 \w'\*(11' .ds 12 "\*' .nr 12 \w'\*(12' 'ps 8 .ds 13 "\fR0\fP .nr 13 \w'\*(13' .as 12 \v'18u'\s8\*(13\|\s10\v'-18u' 'ps 10 .nr 12 \n(12+\n(13+\w'\s8\|' .as 11 "\*(12 .nr 11 \w'\*(11' .ds 12 "\|\| .nr 12 \w'\*(12' .as 11 "\*(12 .nr 11 \w'\*(11' .ds 12 "\|=\| .nr 12 \w'\*(12' .as 11 "\*(12 .nr 11 \w'\*(11' .ds 12 "\|\| .nr 12 \w'\*(12' .as 11 "\*(12 .nr 11 \w'\*(11' .ds 12 "ky\(fm\(fm .nr 12 \w'\*(12' .as 11 "\*(12 .nr 11 \w'\*(11' .ds 12 "\*' .nr 12 \w'\*(12' 'ps 8 .ds 13 "\fR1\fP .nr 13 \w'\*(13' .as 12 \v'18u'\s8\*(13\|\s10\v'-18u' 'ps 10 .nr 12 \n(12+\n(13+\w'\s8\|' .as 11 "\*(12 .nr 11 \w'\*(11' .ds 12 ", .nr 12 \w'\*(12' .as 11 "\*(12 .nr 11 \w'\*(11' .ds 12 "\|\| .nr 12 \w'\*(12' .as 11 "\*(12 .nr 11 \w'\*(11' .ds 12 "\|\| .nr 12 \w'\*(12' .as 11 "\*(12 .nr 11 \w'\*(11' .ds 12 "\|\| .nr 12 \w'\*(12' .as 11 "\*(12 .nr 11 \w'\*(11' .ds 12 "y\(fm\(fm .nr 12 \w'\*(12' .as 11 "\*(12 .nr 11 \w'\*(11' .ds 12 "\*' .nr 12 \w'\*(12' 'ps 8 .ds 13 "n .nr 13 \w'\*(13' .as 12 \v'18u'\s8\*(13\|\s10\v'-18u' 'ps 10 .nr 12 \n(12+\n(13+\w'\s8\|' .as 11 "\*(12 .nr 11 \w'\*(11' .ds 12 "\|\| .nr 12 \w'\*(12' .as 11 "\*(12 .nr 11 \w'\*(11' .ds 12 "\|=\| .nr 12 \w'\*(12' .as 11 "\*(12 .nr 11 \w'\*(11' .ds 12 "\|\| .nr 12 \w'\*(12' .as 11 "\*(12 .nr 11 \w'\*(11' .ds 12 "ky\(fm\(fm .nr 12 \w'\*(12' .as 11 "\*(12 .nr 11 \w'\*(11' .ds 12 "\*' .nr 12 \w'\*(12' 'ps 8 .ds 13 "n\|\(mi\|\fR1\fP .nr 13 \w'\*(13' .as 12 \v'18u'\s8\*(13\|\s10\v'-18u' 'ps 10 .nr 12 \n(12+\n(13+\w'\s8\|' .as 11 "\*(12 .nr 11 \w'\*(11' .ds 11 \x'0'\fI\*(11\s\n(99\f\n(98 .ne 78u \*(11 'ps \n(99 .ft \n(98 .EN .. .if t .ig .ce (2nd deriv. at end) = k*(2nd deriv. next to end) .. .IP .br is set by the next argument. By default .IR k "" = 0. .TP 5 .B \-n Space output points so that approximately .I n intervals occur between the lower and upper .I x limits. (Default .I n = 100.) .TP 5 .B \-p Make output periodic, i.e. match derivatives at ends. First and last input values should normally agree. .TP 5 .B \-x Next 1 (or 2) arguments are lower (and upper) .I x limits. Normally these limits are calculated from the data. Automatic abcissas start at lower limit (default 0). .SH "SEE ALSO" graph(1G), plot(1G) .SH DIAGNOSTICS When data is not strictly monotone in .I x, .I spline reproduces the input without interpolating extra points. .SH BUGS A limit of 1000 input points is enforced silently. ================================================ FILE: share/man/man1/split.1 ================================================ .\" @(#)split.1 6.1 (Berkeley) 4/29/85 .\" .TH SPLIT 1 "April 29, 1985" .AT 3 .SH NAME split \- split a file into pieces .SH SYNOPSIS .B split [ .B \-\fIn ] [ file [ name ] ] .SH DESCRIPTION .I Split reads .I file and writes it in .IR n -line pieces (default 1000), as many as necessary, onto a set of output files. The name of the first output file is .I name with .B aa appended, and so on lexicographically. If no output name is given, .B x is default. .PP If no input file is given, or if .B \- is given in its stead, then the standard input file is used. ================================================ FILE: share/man/man1/strcompact.1 ================================================ .\" Public domain 1994 - Steven Schultz .\" .\" @(#)strcompact.1 1.0 (2.11BSD GTE) 1/25/94 .\" .TH STRCOMPACT 1 "January 25, 1994" .UC 2 .SH NAME strcompact \- string compaction for object files .SH SYNOPSIS strcompact [ \fBobject_name\fP ... ] .SH DESCRIPTION strcompact scans the symbol and string tables of an object file looking for multiple references in the symbol table to the same string. The string offset of symbol table entries is updated to preserve only one copy of the string. .PP .B strcompact cut the size of the kernel string table by about 25%. .PP The user must have write permission to the object/executable file. .PP .B strcompact writes to \fIstderr\fP the number of shared strings found. .PP strcompact exits 0 if successful, and >0 if an error occurred. .SH SEE ALSO sort(1), symcompact(1), symorder(1), uniq(1) .SH BUGS Execution speed leaves much to be desired - on a 11/73 it takes about 4 minutes to process the string table of the kernel. Fortunately this is only done once when the kernel is created. .PP Although .B strcompact may be run on .o files as well as executables but this is probably not worth the trouble since the linker will not create shared strings in the final executable. ================================================ FILE: share/man/man1/strings.1 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)strings.1 6.2 (Berkeley) 5/12/86 .\" .TH STRINGS 1 "May 12, 1986" .UC .SH NAME strings \- find the printable strings in a object, or other binary, file .SH SYNOPSIS .B strings [ .B \- ] [ .B \-o ] [ \fB\-\fInumber\fR ] file ... .SH DESCRIPTION .I Strings looks for ascii strings in a binary file. A string is any sequence of 4 or more printing characters ending with a newline or a null. Unless the .B \- flag is given, .I strings only looks in the initialized data space of object files. If the .B \-o flag is given, then each string is preceded by its offset in the file (in octal). If the \fB\-\fInumber\fR flag is given then number is used as the minimum string length rather than 4. .PP .I Strings is useful for identifying random object files and many other things. .SH "SEE ALSO" od(1) .SH BUGS The algorithm for identifying strings is extremely primitive. ================================================ FILE: share/man/man1/strip.1 ================================================ .\" @(#)strip.1 6.1 (Berkeley) 4/29/85 .\" .TH STRIP 1 "April 29, 1985" .AT 3 .SH NAME strip \- remove symbols and relocation bits .SH SYNOPSIS .B strip name ... .SH DESCRIPTION .I Strip removes the symbol table and relocation bits ordinarily attached to the output of the assembler and loader. This is useful to save space after a program has been debugged. .PP The effect of .I strip is the same as use of the .B \-s option of .IR ld . .SH FILES /tmp/stm? temporary file .SH "SEE ALSO" ld(1) ================================================ FILE: share/man/man1/style.1 ================================================ .\" @(#)style.1 6.1 (Berkeley) 4/29/85 .\" .TH STYLE 1 "April 29, 1985" .AT 3 .SH NAME style \- analyze surface characteristics of a document .SH SYNOPSIS .B style [ .B \-ml ] [ .B \-mm ] [ .B \-a ] [ .B \-e ] [ .B \-l num ] [ .B \-r num ] [ .B \-p ] [ .B \-P ] file ... .LP .SH DESCRIPTION .I Style analyzes the surface characteristics of the writing style of a document. It reports on readability, sentence length and structure, word length and usage, verb type, and sentence openers. Because .I style runs .I deroff before looking at the text, formatting header files should be included as part of the input. The default macro package .B \-ms may be overridden with the flag .B \-mm. The flag .BR \-ml , which causes .B deroff to skip lists, should be used if the document contains many lists of non-sentences. The other options are used to locate sentences with certain characteristics. .TP .B \-a print all sentences with their length and readability index. .TP .B \-e print all sentences that begin with an expletive. .TP .B \-p print all sentences that contain a passive verb. .TP .BI \-l num print all sentences longer than .IR num . .TP .BI \-r num print all sentences whose readability index is greater than .IR num . .TP .B \-P print parts of speech of the words in the document. .SH "SEE ALSO" deroff(1), diction(1) .SH BUGS Use of non-standard formatting macros may cause incorrect sentence breaks. ================================================ FILE: share/man/man1/su.1 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)su.1 6.2 (Berkeley) 5/5/86 .\" .TH SU 1 "May 5, 1986" .UC .SH NAME su \- substitute user id temporarily .SH SYNOPSIS .B su [ \-f ] [ \- ] [ userid ] .SH DESCRIPTION .I Su demands the password of the specified .I userid, and if it is given, changes to that .I userid and invokes the Shell .IR sh (1) or .IR csh (1) without changing the current directory. The user environment is unchanged except for HOME and SHELL, which are taken from the password file for the user being substituted (see .IR environ (7)). The new user ID stays in force until the Shell exits. .PP If no .I userid is specified, ``root'' is assumed. Only users in the ``wheel'' group (group 0) can .I su to ``root'', even with the root password. To remind the super-user of his responsibilities, the Shell substitutes `#' for its usual prompt. .PP The .B \-f option prevents .IR csh (1) from executing the .cshrc file; thus making .I su start up faster. .PP The .B \- option simulates a full login. .SH "SEE ALSO" sh(1), csh(1) ================================================ FILE: share/man/man1/sum.1 ================================================ .\" @(#)sum.1 6.1 (Berkeley) 4/29/85 .\" .TH SUM 1 "April 29, 1985" .AT 3 .SH NAME sum \- sum and count blocks in a file .SH SYNOPSIS .B sum file .SH DESCRIPTION .I Sum calculates and prints a 16-bit checksum for the named file, and also prints the number of blocks in the file. It is typically used to look for bad spots, or to validate a file communicated over some transmission line. .SH "SEE ALSO" wc(1) .SH DIAGNOSTICS `Read error' is indistinguishable from end of file on most devices; check the block count. ================================================ FILE: share/man/man1/symcompact.1 ================================================ .\" Public domain 1994 - Steven Schultz .\" .\" @(#)symcompact.1 1.0 (2.11BSD GTE) 1/25/94 .\" .TH SYMCOMPACT 1 "January 25, 1994" .UC 2 .SH NAME symcompact \- string compaction for object files .SH SYNOPSIS symcompact [ \fBobject_name\fP ... ] .SH DESCRIPTION symcompact reduces the symbol table size of an executable file. This is done by removing unnecessary overlay transfer vectors (text symbols beginning with a tilde). In a nonoverlaid program there is no need for both the underscore (_foo) and tilde (~foo) text symbol and only the underscore form is kept. For overlaid programs if the symbol is in the base segment the tilde form is not needed and again only the underscore form is preserved. Running \fBsymcompact\fP typically reduces the kernel symbol table size by 250 or so symbols. .PP It is possible to run both \fBsymcompact\fP and \fBstrcompact\fP to achieve an even higher degree of symbol and string table compaction. The normal sequence is to run \fBsymcompact\fP first followed by \fBstrcompact\fP. If \fBsymcompact\fP runs out of memory it will be necessary to reverse the order and run \fBsymcompact\fP a second time - see the BUGS note below. .PP The user must have write permission to the object/executable file. .PP .B symcompact writes to \fIstderr\fP the count of symbols removed from the symbol table. .PP .B symcompact exits 0 if successful, and >0 if an error occurred. .SH SEE ALSO symcompact(1), symorder(1) .SH BUGS This program can partially negate the benefits of \fBstrcompact\fP because multiple references to identical strings cause additional strings to be placed in the string table. Running \fBstrcompact\fP again after running this program fixes this problem. .PP The \fIregister\fP local symbol type is removed from the executable/object file. Since the debugger really doesn't know how to deal with those symbols this is not much of a loss and saves quite a bit of space both in the symbol table and the string table. .PP .B symcompact should not be run on .o files that will be passed to the linker. The linker will need the tilde form of the symbol if an overlaid executable is being created. ================================================ FILE: share/man/man1/symorder.1 ================================================ .\" Copyright (c) 1980, 1990 The Regents of the University of California. .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. All advertising materials mentioning features or use of this software .\" must display the following acknowledgement: .\" This product includes software developed by the University of .\" California, Berkeley and its contributors. .\" 4. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)symorder.1 6.5.1 (2.11BSD GTE) 1/22/94 .\" .TH SYMORDER 1 "January 22, 1994" .UC 4 .SH NAME symorder \- rearrange name list .SH SYNOPSIS .B symorder symlist file .SH DESCRIPTION The file .IR symlist contains a list of symbols to be found in .IR file, one symbol per line. .PP The symbol table of .IR file is updated in place; symbols read from .IR symlist are relocated to the beginning of the table and in the order given. .PP This program was specifically designed to cut down on the overhead of getting symbols from the kernel name list. .SH DIAGNOSTICS The .IR symorder (1) utility exits 0 on success, non zero if an error occurs. .SH SEE ALSO nm(1), nlist(3), strip(1) .SH HISTORY The .B symorder command appeared in 3.0BSD. ================================================ FILE: share/man/man1/tabs.1 ================================================ .\" @(#)tabs.1 6.1 (Berkeley) 4/29/85 .\" .TH TABS 1 "April 29, 1985" .AT 3 .SH NAME tabs \- set terminal tabs .SH SYNOPSIS .B tabs [ .B \-n ] [ terminal ] .SH DESCRIPTION .I Tabs sets the tabs on a variety of terminals. Various terminal names given in .IR term (7) are recognized; the default is, however, suitable for most 300 baud terminals. If the .B \-n flag is present then the left margin is not indented as is normal. .SH SEE ALSO stty(1), term(7) .SH BUGS It's much better to use .IR tset (1). ================================================ FILE: share/man/man1/tail.1 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)tail.1 6.2 (Berkeley) 3/6/86 .\" .TH TAIL 1 "March 6, 1986" .UC 4 .SH NAME tail \- deliver the last part of a file .SH SYNOPSIS .B tail .if t [ \(+-number[\fBlbc\fR][\fBfr\fR] ] .if n +_number[l_b_c_][r_f_] [ file ] .SH DESCRIPTION .I Tail copies the named file to the standard output beginning at a designated place. If no file is named, the standard input is used. .PP Copying begins at distance .I +number from the beginning, or .I \-number from the end of the input. .I Number is counted in units of lines, blocks or characters, according to the appended option .B l, .B b or .B c. When no units are specified, counting is by lines. .PP Specifying .B r causes tail to print lines from the end of the file in reverse order. The default for .B r is to print the entire file this way. Specifying .B f causes .I tail to not quit at end of file, but rather wait and try to read repeatedly in hopes that the file will grow. .SH "SEE ALSO" dd(1) .SH BUGS Tails relative to the end of the file are treasured up in a buffer, and thus are limited in length. .PP Various kinds of anomalous behavior may happen with character special files. ================================================ FILE: share/man/man1/talk.1 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)talk.1 6.2.1 (2.11BSD) 1996/11/27 .\" .TH TALK 1 "November 27, 1996" .UC 5 .SH NAME talk \- talk to another user .SH SYNOPSIS .B talk person [ ttyname ] .SH DESCRIPTION .I Talk is a visual communication program which copies lines from your terminal to that of another user. .PP If you wish to talk to someone on you own machine, then .I person is just the person's login name. If you wish to talk to a user on another host, then .I person is of the form : .sp .in +2.0i .I host!user \ or .br .I host.user \ or .br .I host:user \ or .br .I user@host .br .in -2.0i .sp though .I host@user is perhaps preferred. .PP If you want to talk to a user who is logged in more than once, the .I ttyname argument may be used to indicate the appropriate terminal name. .PP When first called, it sends the message .PP Message from TalkDaemon@his_machine... talk: connection requested by your_name@your_machine. talk: respond with: talk your_name@your_machine .PP to the user you wish to talk to. At this point, the recipient of the message should reply by typing .PP talk \ your_name@your_machine .PP It doesn't matter from which machine the recipient replies, as long as his login-name is the same. Once communication is established, the two parties may type simultaneously, with their output appearing in separate windows. Typing control L will cause the screen to be reprinted, while your erase, kill, and word kill characters will work in talk as normal. To exit, just type your interrupt character; .I talk then moves the cursor to the bottom of the screen and restores the terminal. .PP Permission to talk may be denied or granted by use of the .I mesg command. At the outset talking is allowed. Certain commands, in particular .I nroff and .IR pr (1) disallow messages in order to prevent messy output. .PP .SH FILES /etc/hosts to find the recipient's machine .br /var/run/utmp to find the recipient's tty .SH "SEE ALSO" mesg(1), who(1), mail(1), write(1) .SH BUGS The version of .IR talk (1) released with 4.3BSD uses a protocol that is incompatible with the protocol used in the version released with 4.2BSD. ================================================ FILE: share/man/man1/tar.1 ================================================ .\" @(#)tar.1 6.5 (Berkeley) 5/12/86 .\" .TH TAR 1 "May 12, 1986" .AT 3 .SH NAME tar \- tape archiver .SH SYNOPSIS .B tar [ key ] [ name ... ] .SH DESCRIPTION .PP .I Tar saves and restores multiple files on a single file (usually a magnetic tape, but it can be any file). .IR Tar 's actions are controlled by the .I key argument. The .I key is a string of characters containing at most one function letter and possibly one or more function modifiers. Other arguments to .I tar are file or directory names specifying which files to dump or restore. In all cases, appearance of a directory name refers to the files and (recursively) subdirectories of that directory. .PP The function portion of the key is specified by one of the following letters: .TP 8 .B r The named files are written on the end of the tape. The .B c function implies this. .TP 8 .B x The named files are extracted from the tape. If the named file matches a directory whose contents had been written onto the tape, this directory is (recursively) extracted. The owner, modification time, and mode are restored (if possible). If no file argument is given, the entire content of the tape is extracted. Note that if multiple entries specifying the same file are on the tape, the last one overwrites all earlier. .TP 8 .B t The names of the specified files are listed each time they occur on the tape. If no file argument is given, all of the names on the tape are listed. .TP 8 .B u The named files are added to the tape if either they are not already there or have been modified since last put on the tape. .TP 8 .B c Create a new tape; writing begins on the beginning of the tape instead of after the last file. This command implies .BR r . .PP The following characters may be used in addition to the letter which selects the function desired. .TP 10 .B o On output, tar normally places information specifying owner and modes of directories in the archive. Former versions of tar, when encountering this information will give error message of the form .br "/: cannot create". .br This modifier will suppress the directory information. .TP 10 .B p This modifier says to restore files to their original modes, ignoring the present .IR umask (2). Setuid and sticky information will also be restored to the super-user. .TP 10 .B 0, ..., 9 This modifier selects an alternate drive on which the tape is mounted. The default is drive 0 at 1600 bpi, which is normally /dev/rmt8. .TP 10 .B v Normally .I tar does its work silently. The .B v (verbose) option makes .I tar print the name of each file it treats preceded by the function letter. With the .B t function, the verbose option gives more information about the tape entries than just their names. .TP 10 .B w .I Tar prints the action to be taken followed by file name, then wait for user confirmation. If a word beginning with `y' is given, the action is done. Any other input means don't do it. .TP 10 .B f .I Tar uses the next argument as the name of the archive instead of /dev/rmt?. If the name of the file is `\-', tar writes to standard output or reads from standard input, whichever is appropriate. Thus, .I tar can be used as the head or tail of a filter chain. .I Tar can also be used to move hierarchies with the command .ce 1 cd fromdir; tar cf - . | (cd todir; tar xf -) .TP 10 .B b .I Tar uses the next argument as the blocking factor for tape records. The default is 20 (the maximum). This option should only be used with raw magnetic tape archives (See .B f above). The block size is determined automatically when reading tapes (key letters `x' and `t'). .TP 10 .B l tells .I tar to complain if it cannot resolve all of the links to the files dumped. If this is not specified, no error messages are printed. .TP 10 .B m tells .I tar not to restore the modification times. The modification time will be the time of extraction. .TP 10 .B h Force .I tar to follow symbolic links as if they were normal files or directories. Normally, .I tar does not follow symbolic links. .TP 10 .B B Forces input and output blocking to 20 blocks per record. This option was added so that .I tar can work across a communications channel where the blocking may not be maintained. .TP 10 .B C If a file name is preceded by .BR \-C , then .I tar will perform a .IR chdir (2) to that file name. This allows multiple directories not related by a close common parent to be archived using short relative path names. For example, to archive files from /usr/include and from /etc, one might use .ti +0.5i tar c -C /usr include -C / etc .PP Previous restrictions dealing with .IR tar 's inability to properly handle blocked archives have been lifted. .PP .SH FILES /dev/rmt? .br /tmp/tar* .SH "SEE ALSO" tar(5) .SH DIAGNOSTICS Complaints about bad key characters and tape read/write errors. .br Complaints if enough memory is not available to hold the link tables. .SH BUGS There is no way to ask for the .IR n -th occurrence of a file. .br Tape errors are handled ungracefully. .br The .B u option can be slow. .br The current limit on file name length is 100 characters. .br There is no way selectively to follow symbolic links. .br When extracting tapes created with the .B r or .B u options, directory modification times may not be set correctly. ================================================ FILE: share/man/man1/tbl.1 ================================================ .\" @(#)tbl.1 6.1 (Berkeley) 4/29/85 .\" .TH TBL 1 "April 29, 1985" .AT 3 .SH NAME tbl \- format tables for nroff or troff .SH SYNOPSIS .B tbl [ files ] ... .SH DESCRIPTION .I Tbl is a preprocessor for formatting tables for .I nroff or .IR troff (1). The input files are copied to the standard output, except for lines between .TS and .TE command lines, which are assumed to describe tables and are reformatted. Details are given in the .IR tbl (1) reference manual. .SH EXAMPLE .PP As an example, letting \\t represent a tab (which should be typed as a genuine tab) the input .IP "" \&.TS .nf c s s c c s c c c l n n. Household Population Town\\tHouseholds \\tNumber\\tSize Bedminster\\t789\\t3.26 Bernards Twp.\\t3087\\t3.74 Bernardsville\\t2018\\t3.30 Bound Brook\\t3425\\t3.04 Branchburg\\t1644\\t3.49 Bridgewater\\t7897\\t3.81 Far Hills\\t240\\t3.19 \&.TE .LP .fi yields .ne 10 .IP " " .TS .nr 35 \n(.u .nf .nr 79 0n .nr 80 \n(79 .nr 40 \n(79 .nr 38 \n(79+\w!Town! .if \n(80<\n(38 .nr 80 \n(38 .nr 38 \n(79+\w!! .if \n(80<\n(38 .nr 80 \n(38 .nr 38 \n(79+\w!Bedminster! .if \n(80<\n(38 .nr 80 \n(38 .nr 38 \n(79+\w!Bernards Twp.! .if \n(80<\n(38 .nr 80 \n(38 .nr 38 \n(79+\w!Bernardsville! .if \n(80<\n(38 .nr 80 \n(38 .nr 38 \n(79+\w!Bound Brook! .if \n(80<\n(38 .nr 80 \n(38 .nr 38 \n(79+\w!Branchburg! .if \n(80<\n(38 .nr 80 \n(38 .nr 38 \n(79+\w!Bridgewater! .if \n(80<\n(38 .nr 80 \n(38 .nr 38 \n(79+\w!Far Hills! .if \n(80<\n(38 .nr 80 \n(38 .nr 81 \n(80 .nr 41 \n(80 .nr 38 \n(80+\w!Number! .if \n(81<\n(38 .nr 81 \n(38 .nr 31 0 .nr 32 0 .nr 38 \w!789! .if \n(31<\n(38 .nr 31 \n(38 .nr 38 \w!! .if \n(32<\n(38 .nr 32 \n(38 .nr 38 \w!3087! .if \n(31<\n(38 .nr 31 \n(38 .nr 38 \w!! .if \n(32<\n(38 .nr 32 \n(38 .nr 38 \w!2018! .if \n(31<\n(38 .nr 31 \n(38 .nr 38 \w!! .if \n(32<\n(38 .nr 32 \n(38 .nr 38 \w!3425! .if \n(31<\n(38 .nr 31 \n(38 .nr 38 \w!! .if \n(32<\n(38 .nr 32 \n(38 .nr 38 \w!1644! .if \n(31<\n(38 .nr 31 \n(38 .nr 38 \w!! .if \n(32<\n(38 .nr 32 \n(38 .nr 38 \w!7897! .if \n(31<\n(38 .nr 31 \n(38 .nr 38 \w!! .if \n(32<\n(38 .nr 32 \n(38 .nr 38 \w!240! .if \n(31<\n(38 .nr 31 \n(38 .nr 38 \w!! .if \n(32<\n(38 .nr 32 \n(38 .nr 61 \n(80+\n(31 .nr 38 \n(61+\n(32 .if \n(38>\n(81 .nr 81 \n(38 .if \n(38<\n(81 .nr 61 +(\n(81-\n(38)/2 .nr 82 \n(81 .nr 42 \n(81 .nr 38 \n(81+\w!Size! .if \n(82<\n(38 .nr 82 \n(38 .nr 31 0 .nr 32 0 .nr 38 \w!3! .if \n(31<\n(38 .nr 31 \n(38 .nr 38 \w!.26! .if \n(32<\n(38 .nr 32 \n(38 .nr 38 \w!3! .if \n(31<\n(38 .nr 31 \n(38 .nr 38 \w!.74! .if \n(32<\n(38 .nr 32 \n(38 .nr 38 \w!3! .if \n(31<\n(38 .nr 31 \n(38 .nr 38 \w!.30! .if \n(32<\n(38 .nr 32 \n(38 .nr 38 \w!3! .if \n(31<\n(38 .nr 31 \n(38 .nr 38 \w!.04! .if \n(32<\n(38 .nr 32 \n(38 .nr 38 \w!3! .if \n(31<\n(38 .nr 31 \n(38 .nr 38 \w!.49! .if \n(32<\n(38 .nr 32 \n(38 .nr 38 \w!3! .if \n(31<\n(38 .nr 31 \n(38 .nr 38 \w!.81! .if \n(32<\n(38 .nr 32 \n(38 .nr 38 \w!3! .if \n(31<\n(38 .nr 31 \n(38 .nr 38 \w!.19! .if \n(32<\n(38 .nr 32 \n(38 .nr 62 \n(81+\n(31 .nr 38 \n(62+\n(32 .if \n(38>\n(82 .nr 82 \n(38 .if \n(38<\n(82 .nr 62 +(\n(82-\n(38)/2 .nr 38 \n(79+\w!Household Population!-\n(82 .if \n(38>0 .nr 38 \n(38/2 .if \n(38<0 .nr 38 0 .nr 61 +1*\n(38 .nr 81 +1*\n(38 .nr 41 +1*\n(38 .nr 62 +2*\n(38 .nr 82 +2*\n(38 .nr 42 +2*\n(38 .nr 38 \n(80+\w!Households!-\n(82 .if \n(38>0 .nr 38 \n(38/1 .if \n(38<0 .nr 38 0 .nr 62 +1*\n(38 .nr 82 +1*\n(38 .nr 42 +1*\n(38 .nr 38 1n .nr 41 +3*\n(38 .nr 81 +3*\n(38 .nr 61 +3*\n(38 .if n .if \n(61%24>0 .nr 61 +12u .nr 42 +6*\n(38 .nr 82 +6*\n(38 .nr 62 +6*\n(38 .if n .if \n(62%24>0 .nr 62 +12u .nr TW \n(82 .fc ! : .ta \n(82u \&!:Household Population:! .ta \n(80u \n(82u \&\h'|\n(40u'!:Town:!\h'|\n(41u'!:Households:! .ta \n(80u \n(81u \n(82u \&\h'|\n(40u'!::!\h'|\n(41u'!:Number:!\h'|\n(42u'!:Size:! .ta \n(80u \n(61u \n(62u \n(82u \&\h'|\n(40u'!Bedminster:!\h'|\n(41u'!:789!\h'|\n(42u'!:3!!.26:! .ta \n(80u \n(61u \n(62u \n(82u \&\h'|\n(40u'!Bernards Twp.:!\h'|\n(41u'!:3087!\h'|\n(42u'!:3!!.74:! .ta \n(80u \n(61u \n(62u \n(82u \&\h'|\n(40u'!Bernardsville:!\h'|\n(41u'!:2018!\h'|\n(42u'!:3!!.30:! .ta \n(80u \n(61u \n(62u \n(82u \&\h'|\n(40u'!Bound Brook:!\h'|\n(41u'!:3425!\h'|\n(42u'!:3!!.04:! .ta \n(80u \n(61u \n(62u \n(82u \&\h'|\n(40u'!Branchburg:!\h'|\n(41u'!:1644!\h'|\n(42u'!:3!!.49:! .ta \n(80u \n(61u \n(62u \n(82u \&\h'|\n(40u'!Bridgewater:!\h'|\n(41u'!:7897!\h'|\n(42u'!:3!!.81:! .ta \n(80u \n(61u \n(62u \n(82u \&\h'|\n(40u'!Far Hills:!\h'|\n(41u'!:240!\h'|\n(42u'!:3!!.19:! .fc .mk ## .nr ## -1v .if \n(35>0 .fi .TE .fi .PP If no arguments are given, .I tbl reads the standard input, so it may be used as a filter. When .I tbl is used with .I eqn or .I neqn the .I tbl command should be first, to minimize the volume of data passed through pipes. .SH SEE ALSO troff(1), eqn(1) .br M. E. Lesk, .I TBL. ================================================ FILE: share/man/man1/tc.1 ================================================ .\" @(#)tc.1 6.1 (Berkeley) 4/29/85 .\" .TH TC 1 "April 29, 1985" .AT 3 .SH NAME tc \- photoypesetter simulator .SH SYNOPSIS .B tc [ .B \-t ] [ .B \-s\c N ] [ .B \-p\c L ] [ file ] .SH DESCRIPTION .I Tc interprets its input (standard input default) as device codes for a Graphic Systems phototypesetter (cat). The standard output of .I tc is intended for a Tektronix 4015 (a 4014 terminal with ASCII and APL character sets). The sixteen typesetter sizes are mapped into the 4014's four sizes; the entire TROFF character set is drawn using the 4014's character generator, using overstruck combinations where necessary. Typical usage: .IP "" 15 troff \-t file | tc .PP At the end of each page .I tc waits for a newline (empty line) from the keyboard before continuing on to the next page. In this wait state, the command .B e will suppress the screen erase before the next page; .B s\c N will cause the next N pages to be skipped; and .B !\c line will send line to the shell. .PP The command line options are: .TP .B \-t Don't wait between pages; for directing output into a file. .TP .BR \-s N Skip the first N pages. .TP .BR \-p L Set page length to L. L may include the scale factors .B p (points), .B i (inches), .B c (centimeters), and .B P (picas); default is picas. .TP .BI \(fm\- l\ w \(fm Multiply the default aspect ratio, 1.5, of a displayed page by .I l/w. .SH "SEE ALSO" troff(1), plot(1G) .SH BUGS Font distinctions are lost. .br .IR tc 's character set is limited to ASCII in just one size. .br The aspect ratio option is unbelievable. ================================================ FILE: share/man/man1/tcopy.1 ================================================ .\" Copyright (c) 1985 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)tcopy.1 6.1 (Berkeley) 12/11/85 .\" .TH TCOPY 1 "December 11, 1985" .UC 6 .SH NAME tcopy \- copy a mag tape .SH SYNOPSIS .B tcopy src [ .B dest ] .br .SH DESCRIPTION .I Tcopy is designed to copy magnetic tapes. The only assumption made about the tape is that there are two tape marks at the end. .I Tcopy with only a source tape specified will print information about the sizes of records and tape files. If a destination is specified, then, a copy will be made of the source tape. The blocking on the destination tape will be identical to that used on the source tape. Copying a tape will yield the same output as if just printing the sizes. .SH "SEE ALSO" mtio(4) ================================================ FILE: share/man/man1/tee.1 ================================================ .\" @(#)tee.1 6.1 (Berkeley) 4/29/85 .\" .TH TEE 1 "April 29, 1985" .AT 3 .SH NAME tee \- pipe fitting .SH SYNOPSIS .B tee [ .B \-i ] [ .B \-a ] [ file ] ... .SH DESCRIPTION .I Tee transcribes the standard input to the standard output and makes copies in the .I files. Option .B \-i ignores interrupts; option .B \-a causes the output to be appended to the .I files rather than overwriting them. ================================================ FILE: share/man/man1/telnet.1 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)telnet.1c 6.5 (Berkeley) 5/10/86 .\" .TH TELNET 1C "May 10, 1986" .UC 5 .SH NAME telnet \- user interface to the \s-1TELNET\s0 protocol .SH SYNOPSIS telnet [ host [ port ] ] .SH DESCRIPTION .I Telnet is used to communicate with another host using the .B TELNET protocol. If .I telnet is invoked without arguments, it enters command mode, indicated by its prompt (\*(lqtelnet>\*(rq). In this mode, it accepts and executes the commands listed below. If it is invoked with arguments, it performs an .B open command (see below) with those arguments. .PP Once a connection has been opened, .I telnet enters an input mode. The input mode entered will be either \*(lqcharacter at a time\*(rq or \*(lqline by line\*(rq depending on what the remote system supports. .PP In \*(lqcharacter at a time\*(rq mode, most text typed is immediately sent to the remote host for processing. .PP In \*(lqline by line\*(rq mode, all text is echoed locally, and (normally) only completed lines are sent to the remote host. The \*(lqlocal echo character\*(rq (initially \*(lq^E\*(rq) may be used to turn off and on the local echo (this would mostly be used to enter passwords without the password being echoed). .PP In either mode, if the .I localchars toggle is TRUE (the default in line mode; see below), the user's .IR quit , .IR intr , and .I flush characters are trapped locally, and sent as .B TELNET protocol sequences to the remote side. There are options (see .B toggle .I autoflush and .B toggle .I autosynch below) which cause this action to flush subsequent output to the terminal (until the remote host acknowledges the .B TELNET sequence) and flush previous terminal input (in the case of .I quit and .IR intr ). .PP While connected to a remote host, .I telnet command mode may be entered by typing the .I telnet \*(lqescape character\*(rq (initially \*(lq^]\*(rq). When in command mode, the normal terminal editing conventions are available. .PP .B COMMANDS .PP The following commands are available. Only enough of each command to uniquely identify it need be typed (this is also true for arguments to the .BR mode , .BR set , .BR toggle , and .B display commands). .PP .TP .B open \fIhost\fP \fR[\fP \fIport\fP \fR]\fP .br Open a connection to the named host. If no port number is specified, .I telnet will attempt to contact a .B TELNET server at the default port. The host specification may be either a host name (see .IR hosts (5)) or an Internet address specified in the \*(lqdot notation\*(rq (see .IR inet (3N)). .TP .B close .br Close a .B TELNET session and return to command mode. .TP .B quit .br Close any open .B TELNET session and exit .IR telnet . An end of file (in command mode) will also close a session and exit. .TP .B z .br Suspend .IR telnet . This command only works when the user is using the .IR csh (1). .TP .B mode \fItype\fP .br .I Type is either .I line (for \*(lqline by line\*(rq mode) or .I character (for \*(lqcharacter at a time\*(rq mode). The remote host is asked for permission to go into the requested mode. If the remote host is capable of entering that mode, the requested mode will be entered. .TP .B status .br Show the current status of .IR telnet . This includes the peer one is connected to, as well as the current mode. .TP .B display \fR[\fP \fIargument...\fP \fR]\fP .br Displays all, or some, of the .B set and .B toggle values (see below). .TP .B ? \fR[\fP \fIcommand\fP \fR]\fP .br Get help. With no arguments, .I telnet prints a help summary. If a command is specified, .I telnet will print the help information for just that command. .TP .B send \fIarguments\fP .br Sends one or more special character sequences to the remote host. The following are the arguments which may be specified (more than one argument may be specified at a time): .RS .TP .I escape .br Sends the current .I telnet escape character (initially \*(lq^]\*(rq). .TP .I synch .br Sends the .B TELNET SYNCH sequence. This sequence causes the remote system to discard all previously typed (but not yet read) input. This sequence is sent as TCP urgent data (and may not work if the remote system is a 4.2 BSD system -- if it doesn't work, a lower case \*(lqr\*(rq may be echoed on the terminal). .TP .I brk .br Sends the .B TELNET BRK (Break) sequence, which may have significance to the remote system. .TP .I ip .br Sends the .B TELNET IP (Interrupt Process) sequence, which should cause the remote system to abort the currently running process. .TP .I ao .br Sends the .B TELNET AO (Abort Output) sequence, which should cause the remote system to flush all output .B from the remote system .B to the user's terminal. .TP .I ayt .br Sends the .B TELNET AYT (Are You There) sequence, to which the remote system may or may not choose to respond. .TP .I ec .br Sends the .B TELNET EC (Erase Character) sequence, which should cause the remote system to erase the last character entered. .TP .I el .br Sends the .B TELNET EL (Erase Line) sequence, which should cause the remote system to erase the line currently being entered. .TP .I ga .br Sends the .B TELNET GA (Go Ahead) sequence, which likely has no significance to the remote system. .TP .I nop .br Sends the .B TELNET NOP (No OPeration) sequence. .TP .I ? .br Prints out help information for the .B send command. .RE .TP .B set \fIargument value\fP .br Set any one of a number of .I telnet variables to a specific value. The special value \*(lqoff\*(rq turns off the function associated with the variable. The values of variables may be interrogated with the .B display command. The variables which may be specified are: .RS .TP .I echo .br This is the value (initially \*(lq^E\*(rq) which, when in \*(lqline by line\*(rq mode, toggles between doing local echoing of entered characters (for normal processing), and suppressing echoing of entered characters (for entering, say, a password). .TP .I escape .br This is the .I telnet escape character (initially \*(lq^[\*(rq) which causes entry into .I telnet command mode (when connected to a remote system). .TP .I interrupt .br If .I telnet is in .I localchars mode (see .B toggle .I localchars below) and the .I interrupt character is typed, a .B TELNET IP sequence (see .B send .I ip above) is sent to the remote host. The initial value for the interrupt character is taken to be the terminal's .B intr character. .TP .I quit .br If .I telnet is in .I localchars mode (see .B toggle .I localchars below) and the .I quit character is typed, a .B TELNET BRK sequence (see .B send .I brk above) is sent to the remote host. The initial value for the quit character is taken to be the terminal's .B quit character. .TP .I flushoutput .br If .I telnet is in .I localchars mode (see .B toggle .I localchars below) and the .I flushoutput character is typed, a .B TELNET AO sequence (see .B send .I ao above) is sent to the remote host. The initial value for the flush character is taken to be the terminal's .B flush character. .TP .I erase .br If .I telnet is in .I localchars mode (see .B toggle .I localchars below), .B and if .I telnet is operating in \*(lqcharacter at a time\*(rq mode, then when this character is typed, a .B TELNET EC sequence (see .B send .I ec above) is sent to the remote system. The initial value for the erase character is taken to be the terminal's .B erase character. .TP .I kill .br If .I telnet is in .I localchars mode (see .B toggle .I localchars below), .B and if .I telnet is operating in \*(lqcharacter at a time\*(rq mode, then when this character is typed, a .B TELNET EL sequence (see .B send .I el above) is sent to the remote system. The initial value for the kill character is taken to be the terminal's .B kill character. .TP .I eof .br If .I telnet is operating in \*(lqline by line\*(rq mode, entering this character as the first character on a line will cause this character to be sent to the remote system. The initial value of the eof character is taken to be the terminal's .B eof character. .RE .TP .B toggle \fIarguments...\fP .br Toggle (between TRUE and FALSE) various flags that control how .I telnet responds to events. More than one argument may be specified. The state of these flags may be interrogated with the .B display command. Valid arguments are: .RS .TP .I localchars .br If this is TRUE, then the .IR flush , .IR interrupt , .IR quit , .IR erase , and .I kill characters (see .B set above) are recognized locally, and transformed into (hopefully) appropriate .B TELNET control sequences (respectively .IR ao , .IR ip , .IR brk , .IR ec , and .IR el ; see .B send above). The initial value for this toggle is TRUE in \*(lqline by line\*(rq mode, and FALSE in \*(lqcharacter at a time\*(rq mode. .TP .I autoflush .br If .I autoflush and .I localchars are both TRUE, then when the .IR ao , .IR intr , or .I quit characters are recognized (and transformed into .B TELNET sequences; see .B set above for details), .I telnet refuses to display any data on the user's terminal until the remote system acknowledges (via a .B TELNET .I Timing Mark option) that it has processed those .B TELNET sequences. The initial value for this toggle is TRUE if the terminal user had not done an "stty noflsh", otherwise FALSE (see .IR stty(1)). .TP .I autosynch If .I autosynch and .I localchars are both TRUE, then when either the .I intr or .I quit characters is typed (see .B set above for descriptions of the .I intr and .I quit characters), the resulting .B TELNET sequence sent is followed by the .B TELNET SYNCH sequence. This procedure .B should cause the remote system to begin throwing away all previously typed input until both of the .B TELNET sequences have been read and acted upon. The initial value of this toggle is FALSE. .TP .I crmod .br Toggle carriage return mode. When this mode is enabled, most carriage return characters received from the remote host will be mapped into a carriage return followed by a line feed. This mode does not affect those characters typed by the user, only those received from the remote host. This mode is not very useful unless the remote host only sends carriage return, but never line feed. The initial value for this toggle is FALSE. .TP .I debug .br Toggles socket level debugging (useful only to the .IR super user ). The initial value for this toggle is FALSE. .TP .I options .br Toggles the display of some internal .I telnet protocol processing (having to do with .B TELNET options). The initial value for this toggle is FALSE. .TP .I netdata .br Toggles the display of all network data (in hexadecimal format). The initial value for this toggle is FALSE. .TP .I ? .br Displays the legal .B toggle commands. .RE .SH BUGS .PP There is no adequate way for dealing with flow control. .PP On some remote systems, echo has to be turned off manually when in \*(lqline by line\*(rq mode. .PP There is enough settable state to justify a .RI . telnetrc file. .PP No capability for a .RI . telnetrc file is provided. .PP In \*(lqline by line\*(rq mode, the terminal's .I eof character is only recognized (and sent to the remote system) when it is the first character on a line. ================================================ FILE: share/man/man1/time.1 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)time.1 6.1 (Berkeley) 4/29/85 .\" .TH TIME 1 "April 29, 1985" .UC 4 .SH NAME time \- time a command .SH SYNOPSIS .B time command .SH DESCRIPTION The given command is executed; after it is complete, .I time prints the elapsed time during the command, the time spent in the system, and the time spent in execution of the command. Times are reported in seconds. .PP On a PDP-11, the execution time can depend on what kind of memory the program happens to land in; the user time in MOS is often half what it is in core. .PP The times are printed on the diagnostic output stream. .PP .I Time is built in to .IR csh (1), using a different output format. .SH BUGS Elapsed time is accurate to the second, while the CPU times are measured to the 100th second. Thus the sum of the CPU times can be up to a second larger than the elapsed time. .PP .I Time is a built-in command to .IR csh (1), with a much different syntax. This command is available as ``/bin/time'' to .I csh users. ================================================ FILE: share/man/man1/tip.1 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)tip.1c 6.3 (Berkeley) 5/5/86 .\" .TH TIP 1C "May 5, 1986" .UC 4 .SH NAME tip, cu \- connect to a remote system .SH SYNOPSIS .B tip [ .B \-v ] [ .BI \- speed ] system-name .br .B tip [ .B \-v ] [ .BI \- speed ] phone-number .br .B cu phone-number [ .B \-t ] [ .B \-s .I speed ] [ .B \ -a .I acu ] [ .B \-l .I line ] [ .B \-# ] .SH DESCRIPTION .I Tip and .I cu establish a full-duplex connection to another machine, giving the appearance of being logged in directly on the remote cpu. It goes without saying that you must have a login on the machine (or equivalent) to which you wish to connect. The preferred interface is .IR tip . The .I cu interface is included for those people attached to the ``call UNIX'' command of version 7. This manual page describes only .IR tip . .PP Typed characters are normally transmitted directly to the remote machine (which does the echoing as well). A tilde (`~') appearing as the first character of a line is an escape signal; the following are recognized: .TP 10 .B ~^D ~. Drop the connection and exit (you may still be logged in on the remote machine). .TP 10 \fB~c \fP [\fIname\fP] Change directory to name (no argument implies change to your home directory). .TP 10 .B ~! Escape to a shell (exiting the shell will return you to tip). .TP 10 .B ~> Copy file from local to remote. .I Tip prompts for the name of a local file to transmit. .TP 10 .B ~< Copy file from remote to local. .I Tip prompts first for the name of the file to be sent, then for a command to be executed on the remote machine. .TP 10 \fB~p\fP \fIfrom\fP [ \fIto\fP ] Send a file to a remote UNIX host. The put command causes the remote UNIX system to run the command string ``cat > 'to''', while .I tip sends it the ``from'' file. If the ``to'' file isn't specified the ``from'' file name is used. This command is actually a UNIX specific version of the ``~>'' command. .TP 10 \fB~t\fP \fIfrom\fP [ \fIto\fP ] Take a file from a remote UNIX host. As in the put command the ``to'' file defaults to the ``from'' file name if it isn't specified. The remote host executes the command string ``cat 'from';echo ^A'' to send the file to .IR tip . .TP 10 .B ~| Pipe the output from a remote command to a local UNIX process. The command string sent to the local UNIX system is processed by the shell. .TP 10 .B ~$ Pipe the output from a local UNIX process to the remote host. The command string sent to the local UNIX system is processed by the shell. .TP 10 .B ~# Send a BREAK to the remote system. For systems which don't support the necessary .I ioctl call the break is simulated by a sequence of line speed changes and DEL characters. .TP 10 .B ~s Set a variable (see the discussion below). .TP 10 .B ~^Z Stop .I tip (only available with job control). .TP 10 .B ~^Y Stop only the ``local side'' of .I tip (only available with job control); the ``remote side'' of .IR tip , the side that displays output from the remote host, is left running. .TP 10 .B ~? Get a summary of the tilde escapes .sp .PP .I Tip uses the file /etc/remote to find how to reach a particular system and to find out how it should operate while talking to the system; refer to .IR remote (5) for a full description. Each system has a default baud rate with which to establish a connection. If this value is not suitable, the baud rate to be used may be specified on the command line, e.g. ``tip -300 mds''. .PP When .I tip establishes a connection it sends out a connection message to the remote system; the default value, if any, is defined in /etc/remote. .PP When .I tip prompts for an argument (e.g. during setup of a file transfer) the line typed may be edited with the standard erase and kill characters. A null line in response to a prompt, or an interrupt, will abort the dialogue and return you to the remote machine. .PP .I Tip guards against multiple users connecting to a remote system by opening modems and terminal lines with exclusive access, and by honoring the locking protocol used by .IR uucp (1C). .PP During file transfers .I tip provides a running count of the number of lines transferred. When using the ~> and ~< commands, the ``eofread'' and ``eofwrite'' variables are used to recognize end-of-file when reading, and specify end-of-file when writing (see below). File transfers normally depend on tandem mode for flow control. If the remote system does not support tandem mode, ``echocheck'' may be set to indicate .I tip should synchronize with the remote system on the echo of each transmitted character. .PP When .I tip must dial a phone number to connect to a system it will print various messages indicating its actions. .I Tip supports the DEC DN-11 and Racal-Vadic 831 auto-call-units; the DEC DF02 and DF03, Ventel 212+, Racal-Vadic 3451, and Bizcomp 1031 and 1032 integral call unit/modems. .PP .SM .B VARIABLES .PP .I Tip maintains a set of .I variables which control its operation. Some of these variable are read-only to normal users (root is allowed to change anything of interest). Variables may be displayed and set through the ``s'' escape. The syntax for variables is patterned after .IR vi (1) and .IR Mail (1). Supplying ``all'' as an argument to the set command displays all variables readable by the user. Alternatively, the user may request display of a particular variable by attaching a `?' to the end. For example ``escape?'' displays the current escape character. .PP Variables are numeric, string, character, or boolean values. Boolean variables are set merely by specifying their name; they may be reset by prepending a `!' to the name. Other variable types are set by concatenating an `=' and the value. The entire assignment must not have any blanks in it. A single set command may be used to interrogate as well as set a number of variables. Variables may be initialized at run time by placing set commands (without the ``~s'' prefix in a file .I .tiprc in one's home directory). The .B \-v option causes .I tip to display the sets as they are made. Certain common variables have abbreviations. The following is a list of common variables, their abbreviations, and their default values. .TP .B beautify .br (bool) Discard unprintable characters when a session is being scripted; abbreviated .IR be . .TP .B baudrate .br (num) The baud rate at which the connection was established; abbreviated .IR ba . .TP .B dialtimeout .br (num) When dialing a phone number, the time (in seconds) to wait for a connection to be established; abbreviated .IR dial . .TP .B echocheck .br (bool) Synchronize with the remote host during file transfer by waiting for the echo of the last character transmitted; default is .IR off . .TP .B eofread .br (str) The set of characters which signify and end-of-tranmission during a ~< file transfer command; abbreviated .IR eofr . .TP .B eofwrite .br (str) The string sent to indicate end-of-transmission during a ~> file transfer command; abbreviated .IR eofw . .TP .B eol .br (str) The set of characters which indicate an end-of-line. .I Tip will recognize escape characters only after an end-of-line. .TP .B escape .br (char) The command prefix (escape) character; abbreviated .IR es ; default value is `~'. .TP .B exceptions .br (str) The set of characters which should not be discarded due to the beautification switch; abbreviated .IR ex ; default value is ``\et\en\ef\eb''. .TP .B force .br (char) The character used to force literal data transmission; abbreviated .IR fo ; default value is `^P'. .TP .B framesize .br (num) The amount of data (in bytes) to buffer between file system writes when receiving files; abbreviated .IR fr . .TP .B host .br (str) The name of the host to which you are connected; abbreviated .IR ho . .TP .B prompt .br (char) The character which indicates and end-of-line on the remote host; abbreviated .IR pr ; default value is `\en'. This value is used to synchronize during data transfers. The count of lines transferred during a file transfer command is based on recipt of this character. .TP .B raise .br (bool) Upper case mapping mode; abbreviated .IR ra ; default value is .IR off . When this mode is enabled, all lower case letters will be mapped to upper case by .I tip for transmission to the remote machine. .TP .B raisechar .br (char) The input character used to toggle upper case mapping mode; abbreviated .IR rc ; default value is `^A'. .TP .B record .br (str) The name of the file in which a session script is recorded; abbreviated .IR rec ; default value is ``tip.record''. .TP .B script .br (bool) Session scripting mode; abbreviated .IR sc ; default is .IR off . When .I script is .IR true , .I tip will record everything transmitted by the remote machine in the script record file specified in .IR record . If the .I beautify switch is on, only printable ASCII characters will be included in the script file (those characters betwee 040 and 0177). The variable .I exceptions is used to indicate characters which are an exception to the normal beautification rules. .TP .B tabexpand .br (bool) Expand tabs to spaces during file transfers; abbreviated .IR tab ; default value is .IR false . Each tab is expanded to 8 spaces. .TP .B verbose .br (bool) Verbose mode; abbreviated .IR verb ; default is .IR true . When verbose mode is enabled, .I tip prints messages while dialing, shows the current number of lines transferred during a file transfer operations, and more. .TP .B SHELL .br (str) The name of the shell to use for the ~! command; default value is ``/bin/sh'', or taken from the environment. .TP .B HOME .br (str) The home directory to use for the ~c command; default value is taken from the environment. .PP .SH FILES .ta \w'/usr/spool/uucp/LCK..* 'u .nf /etc/remote global system descriptions /etc/phones global phone number data base ${REMOTE} private system descriptions ${PHONES} private phone numbers ~/.tiprc initialization file. /usr/spool/uucp/LCK..* lock file to avoid conflicts with \fIuucp\fP .fi .SH DIAGNOSTICS Diagnostics are, hopefully, self explanatory. .SH "SEE ALSO" remote(5), phones(5) .SH BUGS The full set of variables is undocumented and should, probably, be paired down. ================================================ FILE: share/man/man1/tk.1 ================================================ .\" @(#)tk.1 6.1 (Berkeley) 4/29/85 .\" .TH TK 1 "April 29, 1985" .AT 3 .SH NAME tk \- paginator for the Tektronix 4014 .SH SYNOPSIS .B tk [ .B \-t ] [ .B \-\c .I N ] [ .B \-p\c .I L ] [ file ] .SH DESCRIPTION The output of .I tk is intended for a Tektronix 4014 terminal. .I Tk arranges for 66 lines to fit on the screen, divides the screen into .I N columns, and contributes an eight space page offset in the (default) single-column case. Tabs, spaces, and backspaces are collected and plotted when necessary. Teletype Model 37 half- and reverse-line sequences are interpreted and plotted. At the end of each page .I tk waits for a newline (empty line) from the keyboard before continuing on to the next page. In this wait state, the command .BI ! command will send the .I command to the shell. .PP The command line options are: .TP .B \-t Don't wait between pages; for directing output into a file. .PP .TP .BI \- N Divide the screen into \fIN\fR columns and wait after the last column. .TP .BI \-p L Set page length to \fIL\fR lines. .SH SEE ALSO pr(1) ================================================ FILE: share/man/man1/tn3270.1 ================================================ .\" Copyright (c) 1986 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)tn3270.1 1.3.1 (2.11BSD) 1996/11/27 .\" .TH TN3270 1 "November 27, 1996" .UC 6 .SH NAME tn3270 \- full-screen remote login to IBM VM/CMS .SH SYNOPSIS .B tn3270 sysname .SH DESCRIPTION .I Tn3270 permits a full-screen, full-duplex connection from a VAX UNIX machine to an IBM machine running VM/CMS giving the appearance of being logged in directly to the remote machine on an IBM 3270 terminal. Of course you must have an account on the machine to which you wish to connect in order to log in. .I Tn3270 looks to the user in many respects like the Yale ASCII Terminal Communication System II. .I Tn3270 is actually a modification of the Arpanet TELNET user interface (see .IR telnet (1)) that interprets and generates raw 3270 control streams. .PP Emulation of the 3270 terminal is done in the Unix process. This emulation involves mapping 3270-style commands from the host into appropriate sequences to control the user's terminal screen. .I Tn3270 uses .IR curses (3x) and the .I /etc/termcap file to do this. The emulation also involves simulating the special 3270 keyboard keys (program function keys, etc.) by mapping sequences of keystrokes from the ASCII keyboard into appropriate 3270 control strings. This mapping is terminal dependent and is specified in a description file, .IR /usr/share/misc/map3270 , (see .IR map3270 (5)) or in an environment variable .I MAP3270 (see .IR mset (1)). Any special function keys on the ASCII keyboard are used whenever possible. If an entry for the user's terminal is not found, .I tn3270 looks for an entry for the terminal type .B unknown. If this is not found, .I tn3270 uses a default keyboard mapping (see .IR map3270 (5)). .PP The first character of each special keyboard mapping sequence is either an ASCII escape (ESC), a control character, or an ASCII delete (DEL). If the user types an unrecognized function key sequence, .I tn3270 sends an ASCII bell (BEL), or a visual bell if defined in the user's termcap entry, to the user's terminal and nothing is sent to the IBM host. .PP If .I tn3270 is invoked without specifying a remote host system name, it enters local command mode, indicated by the prompt ``tn3270>''. In this mode, .I tn3270 accepts and executes the following commands: .sp .nf .ta 0.5i 1.5i open connect to a remote host close close the current connection quit exit tn3270 z suspend tn3270 status print connection status ? print help information .fi .sp Other common .I telnet commands are not available in .I tn3270. .I Tn3270 command mode may also be entered, after connecting to a host, by typing a special escape character (typically control-C). .PP While in command mode, any host login session is still alive but temporarily suspended. The host login session may be resumed by entering an empty line (press the RETURN key) in response to the command prompt. A session may be terminated by logging off the foreign host, or by typing ``quit'' or ``close'' while in local command mode. .SH FILES /etc/termcap .br /usr/share/misc/map3270 .SH AUTHOR Greg Minshall .SH SEE ALSO mset(1), telnet(1), termcap(3x), termcap(5), map3270(5), \fIYale ASCII Terminal Communication System II Program Description/Operator's Manual\fR (IBM SB30-1911) .SH BUGS Performance is slow and uses system resources prodigiously. .PP Not all 3270 functions are supported, nor all Yale enhancements. ================================================ FILE: share/man/man1/touch.1 ================================================ .\" @(#)touch.1 6.1 (Berkeley) 4/29/85 .\" .TH TOUCH 1 "April 29, 1985" .AT 3 .SH NAME touch \- update date last modified of a file .SH SYNOPSIS .B touch [ .B \-c ] [ .B \-f ] file ... .SH DESCRIPTION .I Touch attempts to set the modified date of each .IR file . If a .I file exists, this is done by reading a character from the file and writing it back. If a .I file does not exist, an attempt will be made to create it unless the .B \-c option is specified. The .B \-f option will attempt to force the touch in spite of read and write permissions on a .IR file . .SH SEE\ ALSO utimes(2) ================================================ FILE: share/man/man1/tp.1 ================================================ .\" @(#)tp.1 6.1 (Berkeley) 4/29/85 .\" .TH TP 1 "April 29, 1985" .AT 3 .SH NAME tp \- manipulate tape archive .SH SYNOPSIS .B tp [ key ] [ name ... ] .SH DESCRIPTION .PP .I Tp saves and restores files on DECtape or magtape. Its actions are controlled by the .I key argument. The key is a string of characters containing at most one function letter and possibly one or more function modifiers. Other arguments to the command are file or directory names specifying which files are to be dumped, restored, or listed. In all cases, appearance of a directory name refers to the files and (recursively) subdirectories of that directory. .PP The function portion of the key is specified by one of the following letters: .TP 8 .B r The named files are written on the tape. If files with the same names already exist, they are replaced. `Same' is determined by string comparison, so `./abc' can never be the same as `/usr/dmr/abc' even if `/usr/dmr' is the current directory. If no file argument is given, `\fB.\fR' is the default. .TP 8 .B u updates the tape. .B u is like .B r, but a file is replaced only if its modification date is later than the date stored on the tape; that is to say, if it has changed since it was dumped. .B u is the default command if none is given. .TP 8 .B d deletes the named files from the tape. At least one name argument must be given. This function is not permitted on magtapes. .TP 8 .B x extracts the named files from the tape to the file system. The owner and mode are restored. If no file argument is given, the entire contents of the tape are extracted. .TP 8 .B t lists the names of the specified files. If no file argument is given, the entire contents of the tape is listed. .PP The following characters may be used in addition to the letter which selects the function desired. .TP 10 .B m Specifies magtape as opposed to DECtape. .TP 10 .B 0,...,7 This modifier selects the drive on which the tape is mounted. For DECtape, .B x is default; for magtape `0' is the default. .TP 10 .B v Normally .I tp does its work silently. The .B v (verbose) option causes it to type the name of each file it treats preceded by the function letter. With the .B t function, .B v gives more information about the tape entries than just the name. .TP 10 .B c means a fresh dump is being created; the tape directory is cleared before beginning. Usable only with .B r and .B u. This option is assumed with magtape since it is impossible to selectively overwrite magtape. .TP 10 .B i Errors reading and writing the tape are noted, but no action is taken. Normally, errors cause a return to the command level. .TP 10 .B f Use the first named file, rather than a tape, as the archive. This option currently acts like .BR m ; .I i.e. .BR r implies .BR c , and neither .BR d nor .BR u are permitted. .TP 10 .B w causes .I tp to pause before treating each file, type the indicative letter and the file name (as with .BR v ) and await the user's response. Response .B y means `yes', so the file is treated. Null response means `no', and the file does not take part in whatever is being done. Response .B x means `exit'; the .I tp command terminates immediately. In the .B x function, files previously asked about have been extracted already. With .B "r, u," and .B d no change has been made to the tape. .PP .SH FILES /dev/tap? .br /dev/rmt? .SH SEE ALSO ar(1), tar(1) .SH DIAGNOSTICS Several; the non-obvious one is `Phase error', which means the file changed after it was selected for dumping but before it was dumped. .SH BUGS A single file with several links to it is treated like several files. .PP Binary-coded control information makes magnetic tapes written by .I tp difficult to carry to other machines; .IR tar (1) avoids the problem. ================================================ FILE: share/man/man1/tr.1 ================================================ .\" @(#)tr.1 6.1 (Berkeley) 4/29/85 .\" .TH TR 1 "April 29, 1985" .AT 3 .SH NAME tr \- translate characters .SH SYNOPSIS .B tr [ .B \-cds ] [ string1 [ string2 ] ] .SH DESCRIPTION .I Tr copies the standard input to the standard output with substitution or deletion of selected characters. Input characters found in .I string1 are mapped into the corresponding characters of .IR string2 . When .I string2 is short it is padded to the length of .I string1 by duplicating its last character. Any combination of the options .B \-cds may be used: .B \-c complements the set of characters in .I string1 with respect to the universe of characters whose ASCII codes are 01 through 0377 octal; .B \-d deletes all input characters in .I string1; .B \-s squeezes all strings of repeated output characters that are in .I string2 to single characters. .PP In either string the notation .IB a \- b means a range of characters from .I a to .I b in increasing ASCII order. The character `\e' followed by 1, 2 or 3 octal digits stands for the character whose ASCII code is given by those digits. A `\e' followed by any other character stands for that character. .PP The following example creates a list of all the words in `file1' one per line in `file2', where a word is taken to be a maximal string of alphabetics. The second string is quoted to protect `\e' from the Shell. 012 is the ASCII code for newline. .IP tr \-cs A\-Za\-z \'\e012\' file2 .SH "SEE ALSO" ed(1), ascii(7), expand(1) .SH BUGS Won't handle ASCII NUL in .I string1 or .I string2; always deletes NUL from input. ================================================ FILE: share/man/man1/troff.1 ================================================ .\" @(#)troff.1 6.1.1 (2.11BSD) 1996/10/22 .\" .TH TROFF 1 "October 22, 1996" .AT 3 .SH NAME troff, nroff \- text formatting and typesetting .SH SYNOPSIS .B troff [ option ] ... [ file ] ... .PP .B nroff [ option ] ... [ file ] ... .SH DESCRIPTION .I Troff formats text in the named .I files for printing on a Graphic Systems C/A/T phototypesetter; .I nroff is used for for typewriter-like devices. Their capabilities are described in the .I Nroff/Troff user's manual. .PP If no .I file argument is present, the standard input is read. An argument consisting of a single minus .RB ( \- ) is taken to be a file name corresponding to the standard input. The options, which may appear in any order so long as they appear before the files, are: .TP "\w'\f3\-m\f1name 'u" .BI \-o list Print only pages whose page numbers appear in the comma-separated .I list of numbers and ranges. A range .IB N \- M means pages .I N through .IR M ; an initial .I \-N means from the beginning to page .IR N ; and a final .IR N \- means from .I N to the end. .TP .BI \-n N Number first generated page .IR N . .TP .BI \-s N Stop every .I N pages. .I Nroff will halt prior to every .I N pages (default .IR N =1) to allow paper loading or changing, and will resume upon receipt of a newline. .I Troff will stop the phototypesetter every .I N pages, produce a trailer to allow changing cassettes, and resume when the typesetter's start button is pressed. .TP .BI \-m name Prepend the macro file .BI /usr/share/tmac/tmac. name to the input .IR files . .TP .BI \-r aN Set register .I a (one-character) to .IR N . .TP .B \-i Read standard input after the input files are exhausted. .TP .B \-q Invoke the simultaneous input-output mode of the .B rd request. .HP .bd I 3 .I Troff only .br .bd I .TP .B \-t Direct output to the standard output instead of the phototypesetter. .TP .B \-f Refrain from feeding out paper and stopping phototypesetter at the end of the run. .TP .B \-w Wait until phototypesetter is available, if currently busy. .TP .B \-b Report whether the phototypesetter is busy or available. No text processing is done. .TP .B \-a Send a printable ASCII approximation of the results to the standard output. .TP .BR \-p N Print all characters in point size .I N while retaining all prescribed spacings and motions, to reduce phototypesetter elapsed time. .TP .BI \-F fontdir The directory .I fontdir contains the font width tables instead of the default directory /usr/share/fonts. This option can be used to produce output for devices besides the phototypesetter. .PP If the file .I /usr/adm/tracct is writable, .I troff keeps phototypesetter accounting records there. The integrity of that file may be secured by making .I troff a 'set user-id' program. .SH FILES .ta \w'/usr/share/tmac/tmac.* 'u /tmp/ta* temporary file .br /usr/share/tmac/tmac.* standard macro files .br /usr/share/term/* terminal driving tables for .I nroff .br /usr/share/font/* font width tables for .I troff .br /dev/cat phototypesetter .br /usr/adm/tracct accounting statistics for /dev/cat .SH "SEE ALSO" J. F. Ossanna, .I Nroff/Troff user's manual .br B. W. Kernighan, .I A TROFF Tutorial .br eqn(1), tbl(1), ms(7), me(7), man(7), col(1) ================================================ FILE: share/man/man1/true.1 ================================================ .\" @(#)true.1 6.1 (Berkeley) 4/29/85 .\" .TH TRUE 1 "April 29, 1985" .AT 3 .SH NAME true, false \- provide truth values .SH SYNOPSIS .B true .PP .B false .SH DESCRIPTION .I True and .I false are usually used in a Bourne shell script. They test for the appropriate status "true" or "false" before running (or failing to run) a list of commands. .SH EXAMPLE .IP .nf while true do command list done .SH "SEE ALSO" csh(1), sh(1), false(1) .SH DIAGNOSTICS .I True has exit status zero. ================================================ FILE: share/man/man1/tsort.1 ================================================ .\" @(#)tsort.1 6.1 (Berkeley) 4/29/85 .\" .TH TSORT 1 "April 29, 1985" .AT 3 .SH NAME tsort \- topological sort .SH SYNOPSIS .B tsort [ file ] .SH DESCRIPTION .I Tsort produces on the standard output a totally ordered list of items consistent with a partial ordering of items mentioned in the input .IR file . If no .I file is specified, the standard input is understood. .PP The input consists of pairs of items (nonempty strings) separated by blanks. Pairs of different items indicate ordering. Pairs of identical items indicate presence, but not ordering. .SH "SEE ALSO" lorder(1) .SH DIAGNOSTICS Odd data: there is an odd number of fields in the input file. .SH BUGS Uses a quadratic algorithm; not worth fixing for the typical use of ordering a library archive file. ================================================ FILE: share/man/man1/tty.1 ================================================ .\" @(#)tty.1 6.1 (Berkeley) 4/29/85 .\" .TH TTY 1 "April 29, 1985" .AT 3 .SH NAME tty \- get terminal name .SH SYNOPSIS .B tty [ -s ] .SH DESCRIPTION .I Tty prints the pathname of the user's terminal unless the \-s (silent) is given. In either case, the exit value is zero if the standard input is a terminal and one if it is not. .SH DIAGNOSTICS `not a tty' if the standard input file is not a terminal. ================================================ FILE: share/man/man1/ul.1 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)ul.1 6.2 (Berkeley) 5/7/86 .\" .TH UL 1 "May 7, 1986" .UC 4 .SH NAME ul \- do underlining .SH SYNOPSIS .B ul [ .B \-i ] [ .B \-t .I terminal ] [ .I name \&... ] .SH DESCRIPTION .I Ul reads the named files (or standard input if none are given) and translates occurrences of underscores to the sequence which indicates underlining for the terminal in use, as specified by the environment variable TERM. The .B \-t option overrides the terminal kind specified in the environment. The file .I /etc/termcap is read to determine the appropriate sequences for underlining. If the terminal is incapable of underlining, but is capable of a standout mode then that is used instead. If the terminal can overstrike, or handles underlining automatically, .I ul degenerates to .IR cat (1). If the terminal cannot underline, underlining is ignored. .PP The .B \-i option causes .I ul to indicate underlining onto by a separate line containing appropriate dashes `\-'; this is useful when you want to look at the underlining which is present in an .I nroff output stream on a crt-terminal. .SH "SEE ALSO" man(1), nroff(1), colcrt(1) .SH BUGS .I Nroff usually outputs a series of backspaces and underlines intermixed with the text to indicate underlining. No attempt is made to optimize the backward motion. ================================================ FILE: share/man/man1/unifdef.1 ================================================ .\" Copyright (c) 1985 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)unifdef.1 6.1 (Berkeley) 4/29/85 .\" .TH UNIFDEF 1 "April 29, 1985" .UC 6 .SH NAME unifdef \- remove ifdef'ed lines .SH SYNOPSIS .B unifdef [ .B \-t .B \-l .B \-c .BI \-D sym .BI \-U sym .BI \-id sym .BI \-iu sym ] ... [ file ] .SH DESCRIPTION .I Unifdef is useful for removing ifdef'ed lines from a file while otherwise leaving the file alone. .I Unifdef is like a stripped-down C preprocessor: it is smart enough to deal with the nested ifdefs, comments, single and double quotes of C syntax so that it can do its job, but it doesn't do any including or interpretation of macros. Neither does it strip out comments, though it recognizes and ignores them. You specify which symbols you want defined .BI \-D sym or undefined .BI \-U sym and the lines inside those ifdefs will be copied to the output or removed as appropriate. The ifdef, ifndef, else, and endif lines associated with .I sym will also be removed. Ifdefs involving symbols you don't specify are untouched and copied out along with their associated ifdef, else, and endif lines. If an ifdef X occurs nested inside another ifdef X, then the inside ifdef is treated as if it were an unrecognized symbol. If the same symbol appears in more than one argument, only the first occurrence is significant. .PP The .B \-l option causes .I unifdef to replace removed lines with blank lines instead of deleting them. .PP If you use ifdefs to delimit non-C lines, such as comments or code which is under construction, then you must tell .I unifdef which symbols are used for that purpose so that it won't try to parse for quotes and comments in those ifdef'ed lines. You specify that you want the lines inside certain ifdefs to be ignored but copied out with .BI \-id sym and .BI \-iu sym similar to .BI \-D sym and .BI \-U sym above. .PP If you want to use .I unifdef for plain text (not C code), use the .B \-t option. This makes .I unifdef refrain from attempting to recognize comments and single and double quotes. .PP .I Unifdef copies its output to .I stdout and will take its input from .I stdin if no .I file argument is given. If the .B \-c argument is specified, then the operation of .I unifdef is complemented, i.e. the lines that would have been removed or blanked are retained and vice versa. .SH "SEE ALSO" diff(1) .SH DIAGNOSTICS Premature EOF, inappropriate else or endif. .PP Exit status is 0 if output is exact copy of input, 1 if not, 2 if trouble. .SH BUGS Does not know how to deal with \fIcpp\fP consructs such as .br .sp .nf #if defined(X) || defined(Y) .sp .fi .SH AUTHOR Dave Yost ================================================ FILE: share/man/man1/uniq.1 ================================================ .\" @(#)uniq.1 6.1 (Berkeley) 4/29/85 .\" .TH UNIQ 1 "April 29, 1985" .AT 3 .SH NAME uniq \- report repeated lines in a file .SH SYNOPSIS .B uniq [ .B \-udc [ .BR + n ] [ .BR \- n ] ] [ input [ output ] ] .SH DESCRIPTION .I Uniq reads the input file comparing adjacent lines. In the normal case, the second and succeeding copies of repeated lines are removed; the remainder is written on the output file. Note that repeated lines must be adjacent in order to be found; see .IR sort (1). If the .B \-u flag is used, just the lines that are not repeated in the original file are output. The .B \-d option specifies that one copy of just the repeated lines is to be written. The normal mode output is the union of the .B \-u and .B \-d mode outputs. .PP The .B \-c option supersedes .B \-u and .B \-d and generates an output report in default style but with each line preceded by a count of the number of times it occurred. .PP The .I n arguments specify skipping an initial portion of each line in the comparison: .TP 8 .BI \- n The first .IR n fields together with any blanks before each are ignored. A field is defined as a string of non-space, non-tab characters separated by tabs and spaces from its neighbors. .TP 8 .BI + n The first .IR n characters are ignored. Fields are skipped before characters. .PP .SH "SEE ALSO" sort(1), comm(1) ================================================ FILE: share/man/man1/units.1 ================================================ .\" @(#)units.1 6.1.1 (2.11BSD) 1996/10/22 .\" .TH UNITS 1 "October 22, 1996" .AT 3 .if n .ds / / .if t .ds / \z/\h'\w'*'u' .SH NAME units \- conversion program .SH SYNOPSIS .B units .SH DESCRIPTION .I Units converts quantities expressed in various standard scales to their equivalents in other scales. It works interactively in this fashion: .PP .I " You have:" inch .br .I " You want:" cm .br .I " * 2.54000e+00 .br .I " \*/ 3.93701e\-01 .PP A quantity is specified as a multiplicative combination of units optionally preceded by a numeric multiplier. Powers are indicated by suffixed positive integers, division by the usual sign: .PP .I " You have:" 15 pounds force/in2 .br .I " You want:" atm .br .I " * 1.02069e+00" .br .I " \*/ 9.79730e\-01" .PP .I Units only does multiplicative scale changes. Thus it can convert Kelvin to Rankine, but not Centigrade to Fahrenheit. Most familiar units, abbreviations, and metric prefixes are recognized, together with a generous leavening of exotica and a few constants of nature including: .PP .nf pi ratio of circumference to diameter c speed of light e charge on an electron g acceleration of gravity force same as g mole Avogadro's number water pressure head per unit height of water au astronomical unit .PP .fi `Pound' is a unit of mass. Compound names are run together, e.g. `lightyear'. British units that differ from their US counterparts are prefixed thus: `brgallon'. Currency is denoted `belgiumfranc', `britainpound', ... .PP For a complete list of units, `cat /usr/share/misc/units'. .SH FILES /usr/share/misc/units .SH BUGS Don't base your financial plans on the currency conversions. ================================================ FILE: share/man/man1/uptime.1 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)uptime.1 6.1 (Berkeley) 4/29/85 .\" .TH UPTIME 1 "April 29, 1985" .UC .SH NAME uptime \- show how long system has been up .SH SYNOPSIS .B uptime .SH DESCRIPTION Uptime prints the current time, the length of time the system has been up, and the average number of jobs in the run queue over the last 1, 5 and 15 minutes. It is, essentially, the first line of a .IR w (1) command. .SH FILES /vmunix system name list .SH SEE ALSO w(1) ================================================ FILE: share/man/man1/users.1 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)users.1 6.1.1 (2.11BSD) 1996/11/27 .\" .TH USERS 1 "November 27, 1996" .UC .SH NAME users \- compact list of users who are on the system .SH SYNOPSIS .B users .SH DESCRIPTION .I Users lists the login names of the users currently on the system in a compact, one-line format. .SH FILES /var/run/utmp .SH SEE ALSO who(1) ================================================ FILE: share/man/man1/uucp.1 ================================================ .\" @(#)uucp.1 6.3.1 (2.11BSD) 1996/10/22 .\" .TH UUCP 1 "April 24, 1986" .AT 3 .SH NAME uucp \- unix to unix copy .SH SYNOPSIS .B uucp [ .B \-acCdfmr ] [ .BI \-n user ] [ .BI \-g grade ] [ .BI \-s spool ] [ .BI \-x debug ] source-file.... destination-file .SH DESCRIPTION .I Uucp copies files named by the source-file arguments to the destination-file argument. A file name may be a pathname on your machine, or may have the form .IP system-name!pathname .LP where `system-name' is taken from a list of system names that .I uucp knows about. Shell metacharacters ?*[] appearing in the pathname part will be expanded on the appropriate system. .PP Pathnames may be one of: .IP (1) a full pathname; .IP (2) a pathname preceded by .BI ~ user; where .I user is a userid on the specified system and is replaced by that user's login directory; .IP (3) a pathname prefixed by .BR ~ , where .B ~ is expanded into the system's public directory (usually /usr/spool/uucppublic); .IP (4) a partial pathname, which is prefixed by the current directory. .PP If the result is an erroneous pathname for the remote system, the copy will fail. If the destination-file is a directory, the last part of the source-file name is used. .ig If a simple .I ~user destination is inaccessible to .IR uucp , data is copied to a spool directory and the user is notified by .IR mail (1). .. .PP .I Uucp preserves execute permissions across the transmission and gives 0666 read and write permissions (see .IR chmod (2)). .PP The following options are interpreted by .IR uucp . .TP .B \-a Avoid doing a .I getwd to find the current directory. (This is sometimes used for efficiency.) .TP .B \-c Use the source file when copying out rather than copying the file to the spool directory. (This is the default.) .TP .B \-C Copy the source file to the spool directory and transmit the copy. .TP .B \-d Make all necessary directories for the file copy. (This is the default.) .TP .B \-f Do not make intermediate directories for the file copy. .TP .BI \-g grade .I Grade is a single letter/number; lower ASCII sequence characters will cause a job to be transmitted earlier during a particular conversation. Default is `n'. By way of comparison, .IR uux (1C) defaults to `A'; mail is usually sent at `C'. .TP .B \-m Send mail to the requester when the copy is complete. .TP .BI \-n user Notify .I user on remote system (i.e., send .I user mail) that a file was sent. .TP .B \-r Do not start the transfer, just queue the job. .TP .BI \-s spool Use .I spool as the spool directory instead of the default. .TP .BI \-x debug Turn on the debugging at level .I debug. .SH FILES /usr/spool/uucp - spool directory .br /etc/uucp/* - data and configuration files .SH SEE ALSO uux(1C), mail(1) .PP D. A. Nowitz and M. E. Lesk, .IR "A Dial-Up Network of UNIX Systems" . .PP D. A. Nowitz, .IR "Uucp Implementation Description" . .SH WARNING The domain of remotely accessible files can (and for obvious security reasons, usually should) be severely restricted. You will very likely not be able to fetch files by pathname; ask a responsible person on the remote system to send them to you. For the same reasons you will probably not be able to send files to arbitrary pathnames. .SH BUGS .br All files received by .I uucp will be owned by the uucp administrator (usually UID 5). .PP The .B \-m option will only work sending files or receiving a single file. (Receiving multiple files specified by special shell characters ?*[] will not activate the .B \-m option.) .PP At present .I uucp cannot copy to a system several "hops" away, that is, a command of the form .PP .nf uucp myfile system1!system2!system3!yourfile .fi .PP is not permitted. Use .IR uusend (1C) instead. .PP When invoking .I uucp from .IR csh (1), the `!' character must be prefixed by the `\e' escape to inhibit .IR csh 's history mechanism. (Quotes are not sufficient.) .PP .I Uucp refuses to copy a file that does not give read access to ``other''; that is, the file must have at least 0444 modes. ================================================ FILE: share/man/man1/uuencode.1 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)uuencode.1c 6.2 (Berkeley) 4/24/86 .\" .TH UUENCODE 1C "April 24, 1986" .UC 4 .SH NAME uuencode, uudecode \- encode/decode a binary file for transmission via mail .SH SYNOPSIS .B uuencode [ source ] remotedest | .B mail sys1!sys2!..!decode .br .B uudecode [ file ] .SH DESCRIPTION .I Uuencode and .I uudecode are used to send a binary file via uucp (or other) mail. This combination can be used over indirect mail links even when .IR uusend (1C) is not available. .PP .I Uuencode takes the named source file (default standard input) and produces an encoded version on the standard output. The encoding uses only printing ASCII characters, and includes the mode of the file and the .I remotedest for recreation on the remote system. .PP .I Uudecode reads an encoded file, strips off any leading and trailing lines added by mailers, and recreates the original file with the specified mode and name. .PP The intent is that all mail to the user ``decode'' should be filtered through the .I uudecode program. This way the file is created automatically without human intervention. This is possible on the uucp network by either using .I sendmail or by making .I rmail be a link to .I Mail instead of .IR mail . In each case, an alias must be created in a master file to get the automatic invocation of .IR uudecode . .PP If these facilities are not available, the file can be sent to a user on the remote machine who can uudecode it manually. .PP The encode file has an ordinary text form and can be edited by any text editor to change the mode or remote name. .SH SEE ALSO atob(n), uusend(1C), uucp(1C), uux(1C), mail(1), uuencode(5) .SH BUGS The file is expanded by 35% (3 bytes become 4 plus control information) causing it to take longer to transmit. .PP The user on the remote system who is invoking .I uudecode (often .IR uucp ) must have write permission on the specified file. ================================================ FILE: share/man/man1/uulog.1 ================================================ .\" Copyright (c) 1986 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)uulog.1c 6.1 (Berkeley) 4/24/86 .\" .TH UULOG 1C "April 24, 1986" .UC 6 .SH NAME uulog \- display \s-1UUCP\s0 log files .SH SYNOPSIS .B uulog [ .B \-s .I sys ] [ .B \-u .I user ] .SH DESCRIPTION .I Uulog queries a log of .IR uucp (1C) and .IR uux (1C) transactions in the file .B /usr/spool/uucp/\s-1LOGFILE.\s0 .PP The options command .I uulog to print logging information: .TP 8 .BI \-s sys\^ Print information about work involving system .IR sys . .TP 8 .BI \-u user\^ Print information about work done for the specified .IR user . .SH FILES /usr/spool/uucp/\s-1LOGFILE\s0 .SH SEE ALSO uucp(1C), uux(1C). .SH NOTES Very early releases of \s-1UUCP\s0 used separate log files for each of the \s-1UUCP\s0 utilities; .I uulog was used to merge the individual logs into a master file. This capability has not been necessary for some time and is no longer supported. .SH BUGS \s-1UUCP\s0's recording of which user issued a request is unreliable. .PP .I Uulog is little more than an overspecialized version of .IR grep (1). ================================================ FILE: share/man/man1/uuname.1 ================================================ .\" Copyright (c) 1986 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)uuname.1c 6.1 (Berkeley) 4/24/86 .\" .TH UUNAME 1C "April 24, 1986" .UC 6 .SH NAME uuname \- list names of \s-1UUCP\s0 hosts .SH SYNOPSIS .B uuname [ .B \-l ] .SH DESCRIPTION .I Uuname lists the \s-1UUCP\s0 names of known systems. The .B \-l option returns the local system name; this may differ from the .IR hostname (1) for the system if the .I hostname is very long. .SH SEE ALSO uucp(1C), uux(1C). ================================================ FILE: share/man/man1/uuq.1 ================================================ .\" @(#)uuq.1c 6.2 (Berkeley) 4/24/86 .\" .TH UUQ 1C "April 24, 1986" .UC 6 .SH NAME uuq \- examine or manipulate the uucp queue .SH SYNOPSIS .B uuq [ .B -l ] [ .B -h ] [ .BI -s system ] [ .BI -u user ] [ .BI -d jobno ] [ .BI -r sdir ] [ .BI -b baud ] .SH DESCRIPTION .I Uuq is used to examine (and possibly delete) entries in the uucp queue. .PP When listing jobs, .I uuq uses a format reminiscent of .IR ls . For the long format, information for each job listed includes job number, number of files to transfer, user who spooled the job, number of bytes to send, type of command requested (S for sending files, R for receiving files, X for remote uucp), and file or command desired. .PP Several options are available: .TP 10 .B \-h Print only the summary lines for each system. Summary lines give system name, number of jobs for the system, and total number of bytes to send. .TP 10 .B \-l Specifies a long format listing. The default is to list only the job numbers sorted across the page. .TP 10 .BI \-s system Limit output to jobs for systems whose system names begin with \fIsystem\fP. .TP 10 .BI \-u user Limit output to jobs for users whose login names begin with \fIuser\fP. .TP 10 .BI \-d jobno Delete job number \fIjobno\fP (as obtained from a previous \fIuuq\fP command) from the uucp queue. Only the UUCP Administrator is permitted to delete jobs. .TP 10 .BI \-r sdir Look for files in the spooling directory \fIsdir\fP instead of the default directory. .TP 10 .BI \-b baud Use \fIbaud\fP to compute the transfer time instead of the default 1200 baud. .SH FILES .ta \w'/usr/spool/uucp/D.hostname/D.* 'u /usr/spool/uucp/ Default spool directory /usr/spool/uucp/C./C.* Control files .br /usr/spool/uucp/D\fIhostname\fP./D.* Outgoing data files /usr/spool/uucp/X./X.* Outgoing execution files .SH SEE ALSO uucp(1C), uux(1C), uulog(1C), uusnap(8C) .SH BUGS No information is available on work requested by the remote machine. .PP The user who requests a remote uucp command is unknown. .PP .B "Uuq -l" can be horrendously slow. .SH AUTHOR Lou Salkind, New York University ================================================ FILE: share/man/man1/uusend.1 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)uusend.1c 6.2 (Berkeley) 4/24/86 .\" .TH UUSEND 1C "April 24, 1986" .UC 4 .SH NAME uusend \- send a file to a remote host .SH SYNOPSIS .B uusend [ .B \-m mode ] sourcefile sys1!sys2!..!remotefile .SH DESCRIPTION .I Uusend sends a file to a given location on a remote system. The system need not be directly connected to the local system, but a chain of .IR uucp (1) links needs to connect the two systems. .PP If the .B \-m option is specified, the mode of the file on the remote end will be taken from the octal number given. Otherwise, the mode of the input file will be used. .PP The sourcefile can be ``\-'', meaning to use the standard input. Both of these options are primarily intended for internal use of .IR uusend . .PP The remotefile can include the ~userid syntax. .SH DIAGNOSTICS If anything goes wrong any further away than the first system down the line, you will never hear about it. .SH SEE\ ALSO uux(1), uucp(1), uuencode(1) .SH BUGS This command should not exist, since .I uucp should handle it. .PP All systems along the line must have the .I uusend command available and allow remote execution of it. .PP Some uucp systems have a bug where binary files cannot be the input to a .I uux command. If this bug exists in any system along the line, the file will show up severly munged. ================================================ FILE: share/man/man1/uux.1 ================================================ .\" @(#)uux.1 6.3.1 (2.11BSD) 1996/10/22 .\" .TH UUX 1 "October 22, 1996" .AT 3 .SH NAME uux \- unix to unix command execution .SH SYNOPSIS .B uux [ .B - ] [ .B -cClLnprz ] [ .BI -a name ] [ .BI -g grade ] [ .BI -x debug ] command-string .SH DESCRIPTION .I Uux\^ will gather zero or more files from various systems, execute a command on a specified system and then send standard output to a file on a specified system. .PP The .I command-string is made up of one or more arguments that look like a Shell command line, except that the command and file names may be prefixed by .IB system-name !\fR.\fP A null \fIsystem-name\fP is interpreted as the local system. .PP File names may be one of .IP (1) a full path name; .IP (2) a path name preceded by .BI ~ user where .I user is a login name on the specified system and is replaced by that user's login directory; .IP (3) a path name prefixed by .BR ~; where .B ~ is expanded to the system's public directory (usually /usr/spool/uucppublic); .IP (4) a partial pathname, which is prefixed by the current directory. .PP As an example, the command .IP uux "\^!diff usg!/usr/dan/file1 pwba!/a4/dan/file2 > !~/dan/file.diff\^" .PP will get the \fBfile1\fP and \fBfile2\fP files from the ``usg'' and ``pwba'' machines, execute a .IR diff (1) command and put the results in \fBfile.diff\fP in the local /usr/spool/uucppublic/dan/ directory. .PP Any special shell characters, such as \fB<>;|\fP, should be quoted either by quoting the entire \fIcommand-string\fP, or quoting the special characters as individual arguments. .PP .I Uux will attempt to get all files to the execution system. For files that are output files, the file name must be escaped using parentheses. For example, the command .IP uux a!wc b!/usr/file1 \\(c!/usr/file2 \\) .PP get \fB/usr/file1\fP from system ``b'' and send it to system ``a'', perform a \fIwc\fP command on that file and send the result of the .I wc command to system ``c''. .PP .I Uux\^ will notify you by mail if the requested command on the remote system was disallowed. This notification can be turned off by the \fB\-n\fP option. .PP The following \fIoptions\fP are interpreted by .IR uux : .TP .5i .B \- The standard input to .I uux is made the standard input to the .IR command-string . .TP .5i .BI \-a name Use .I name as the user identification replacing the initiator user-id. .TP .5i .B \-c Do not copy local file to the spool directory for transfer to the remote machine (this is the default). .TP .5i .B \-C Force the copy of local files to the spool directory for transfer. .TP .5i .BI \-g grade .I Grade is a single letter/number, from .B 0 to .BR 9 , .B A to .BR Z , or .B a to .BR z ; .B 0 is the highest, and .B z is the lowest grade. The default is .BR A ; by comparison .IR uucp (1) defaults to .B n and mail is usually sent at grade .BR C . Lower grades should be specified for high-volume jobs, such as news. .TP .5i .B \-l Try and make a link from the original file to the spool directory. If the link cannot be made, copy the file. .TP .5i .B \-n Do not notify the user when the command completes. .TP .5i .B \-p Same as \-: The standard input to .I uux is made the standard input to the .IR command-string . .TP .5i .B \-r Do not start the file transfer, just queue the job. .TP .5i .BI \-x debug Produce debugging output on stdout. The debug is a number between 0 and 9; higher numbers give more detailed information. Debugging is permitted only for privileged users (specifically, those with read access to .IR L.sys (5) . .TP .5i .B \-z Notify the user only if the command fails. .TP .5i .B \-L Start up .I uucico with the \fB-L\fP flag. This will force calls to be made to local sites only (see .IR uucico (8C)). .SH FILES .PD 0 .TP 22 /usr/spool/uucp spool directories .TP /etc/uucp/\(** UUCP configuration data. .PD .SH SEE ALSO uucp(1), uucico(8), uuxqt(8). .SH WARNING For security reasons, many installations will limit the list of commands executable on behalf of an incoming request from .IR uux . Many sites will permit little more than the receipt of mail (see .IR mail (1)) via .IR uux . .SH BUGS Only the first command of a shell pipeline may have a .IB system-name !\fR. All other commands are executed on the system of the first command. .PP The use of the shell metacharacter .B \(** will probably not do what you want it to do. .PP The shell tokens .B << and .B >> are not implemented. .PP When invoking .I uux from .IR csh (1), the `!' character must be prefixed by the `\\' escape to inhibit .IR csh 's history mechanism. (Quotes are not sufficient.) ================================================ FILE: share/man/man1/vacation.1 ================================================ .\" Copyright (c) 1985 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)vacation.1 6.2 (Berkeley) 6/16/85 .\" .TH VACATION 1 "June 16, 1985" .UC 6 .SH NAME vacation \- return ``I am on vacation'' indication .SH SYNOPSIS .B vacation .B \-I .br .B vacation user .SH DESCRIPTION .I Vacation returns a message to the sender of a message telling that you are on vacation. The intended use is in a .I \&.forward file. For example, your .I \&.forward file might have: .PP .ti +5 \eeric, "|vacation eric" .PP which would send messages to you (assuming your login name was eric) and send a message back to the sender. .PP .I Vacation expects a file .I \&.vacation.msg in your home directory containing a message to be sent back to each sender. It should be an entire message (including headers). For example, it might say: .PP .in +5 .nf From: eric@ucbmonet.Berkeley.EDU (Eric Allman) Subject: I am on vacation Delivered-By-The-Graces-Of: the Vacation program I am on vacation until July 22. If you have something urgent, please contact Joe Kalash . --eric .fi .in -5 .PP This message will only be sent once a week to each unique sender. The people who have sent you messages are kept in the files .I \&.vacation.pag and .I \&.vacation.dir in your home directory. The .B \-I option initializes these files, and should be executed before you modify your .I \&.forward file. .PP If the .B \-I flag is not specified, .I vacation reads the first line from the standard input for a \s-1UNIX\s0-style ``From'' line to determine the sender. If this is not present, a nasty diagnostic is produced. .IR Sendmail (8) includes the ``From'' line automatically. .PP No message is sent if the initial ``From'' line includes the string ``-REQUEST@'' or if a ``Precedence: bulk'' or ``Precedence: junk'' line is included in the header. .SH SEE\ ALSO sendmail(8) ================================================ FILE: share/man/man1/vgrind.1 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)vgrind.1 6.2.1 (2.11BSD) 1996/10/22 .\" .TH VGRIND 1 "October 22, 1996" .UC 4 .SH NAME vgrind \- grind nice listings of programs .SH SYNOPSIS .B vgrind [ .B \-f ] [ .B \- ] [ .B \-t ] [ .B \-n ] [ .B \-x ] [ .B \-W ] [ .B \-sn ] [ .B \-h header ] [ .B \-d file ] [ .BI \-l language ] name ... .SH DESCRIPTION .I Vgrind formats the program sources which are arguments in a nice style using .IR troff (1) Comments are placed in italics, keywords in bold face, and the name of the current function is listed down the margin of each page as it is encountered. .PP .I Vgrind runs in two basic modes, filter mode or regular mode. In filter mode .I vgrind acts as a filter in a manner similar to .IR tbl (1). The standard input is passed directly to the standard output except for lines bracketed by the .I troff-like macros: .IP .vS - starts processing .IP .vE - ends processing .LP These lines are formatted as described above. The output from this filter can be passed to .I troff for output. There need be no particular ordering with .IR eqn (1) or .IR tbl (1). .PP In regular mode .I vgrind accepts input files, processes them, and passes them to .IR troff (1) for output. .PP In both modes .I vgrind passes any lines beginning with a decimal point without conversion. .PP The options are: .IP \fB\-f\fP forces filter mode .IP \fB\-\fP forces input to be taken from standard input (default if .B \fB\-f\fP is specified ) .IP \fB\-t\fP similar to the same option in .I troff causing formatted text to go to the standard output .IP \fB\-n\fP forces no keyword bolding .IP \fB\-x\fP outputs the index file in a ``pretty'' format. The index file itself is produced whenever .I vgrind is run with a file called .I index in the current directory. The index of function definitions can then be run off by giving .I vgrind the .B \-x option and the file .I index as argument. .IP \fB\-W\fP forces output to the (wide) Versatec printer rather than the (narrow) Varian .IP \fB\-s\fP specifies a point size to use on output (exactly the same as the argument of a .ps) .IP \fB\-h\fP specifies a particular header to put on every output page (default is the file name) .IP \fB\-d\fP specifies an alternate language definitions file (default is /usr/share/misc/vgrindefs) .IP \fB\-l\fP specifies the language to use. Currently known are PASCAL .RB ( \-lp ), MODEL .RB ( \-lm ), C .RB ( \-lc or the default), CSH .RB ( \-lcsh ), SHELL .RB ( \-lsh ), RATFOR .RB ( \-lr ), MODULA2 .RB ( \-lmod2 ), YACC .RB ( \-lyacc ), ISP .RB ( \-lisp ), and ICON .RB ( \-lI ). .SH FILES .ta 2i index file where source for index is created .br /usr/share/tmac/tmac.vgrind macro package .br /usr/libexec/vfontedpr preprocessor .br /usr/share/misc/vgrindefs language descriptions .SH AUTHOR Dave Presotto & William Joy .SH SEE ALSO vlp(1), vtroff(1), vgrindefs(5) .SH BUGS Vfontedpr assumes that a certain programming style is followed: .PP For .B C \- function names can be preceded on a line only by spaces, tabs, or an asterisk. The parenthesized arguments must also be on the same line. .PP For .B PASCAL \- function names need to appear on the same line as the keywords .I function or .I procedure. .PP For .B MODEL \- function names need to appear on the same line as the keywords .I is .I beginproc. .PP If these conventions are not followed, the indexing and marginal function name comment mechanisms will fail. .sp More generally, arbitrary formatting styles for programs mostly look bad. The use of spaces to align source code fails miserably; if you plan to .I vgrind your program you should use tabs. This is somewhat inevitable since the font used by .I vgrind is variable width. .PP The mechanism of ctags in recognizing functions should be used here. .PP Filter mode does not work in documents using the \-me or \-ms macros. (So what use is it anyway?) ================================================ FILE: share/man/man1/vi.1 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)vi.1 6.1 (Berkeley) 4/29/85 .\" .TH VI 1 "April 29, 1985" .UC .SH NAME vi \- screen oriented (visual) display editor based on ex .SH SYNOPSIS .B vi [ .B \-t tag ] [ .B \-r ] [ \fB+\fR\fIcommand\fR ] [ .B \-l ] [ \fB\-w\fIn\fR ] name ... .SH DESCRIPTION .I Vi (visual) is a display oriented text editor based on .IR ex (1). .I Ex and .I vi run the same code; it is possible to get to the command mode of .I ex from within .I vi and vice-versa. .PP The .I "Vi Quick Reference" card and the .I "Introduction to Display Editing with Vi" provide full details on using .I vi. .SH FILES See .IR ex (1). .SH SEE ALSO ex (1), edit (1), ``Vi Quick Reference'' card, ``An Introduction to Display Editing with Vi''. .SH AUTHOR William Joy .br Mark Horton added macros to \fIvisual\fR mode and is maintaining version 3 .SH BUGS Software tabs using \fB^T\fR work only immediately after the .I autoindent. .PP Left and right shifts on intelligent terminals don't make use of insert and delete character operations in the terminal. .PP The .I wrapmargin option can be fooled since it looks at output columns when blanks are typed. If a long word passes through the margin and onto the next line without a break, then the line won't be broken. .PP Insert/delete within a line can be slow if tabs are present on intelligent terminals, since the terminals need help in doing this correctly. .PP Saving text on deletes in the named buffers is somewhat inefficient. .PP The .I source command does not work when executed as \fB:source\fR; there is no way to use the \fB:append\fR, \fB:change\fR, and \fB:insert\fR commands, since it is not possible to give more than one line of input to a \fB:\fR escape. To use these on a \fB:global\fR you must \fBQ\fR to \fIex\fR command mode, execute them, and then reenter the screen editor with .I vi or .I open. ================================================ FILE: share/man/man1/vmstat.1 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)vmstat.1 6.3 (Berkeley) 3/15/86 .\" .TH VMSTAT 1 "March 15, 1986" .UC 4 .de s1 .if n .sp .if t .sp .1i .. .de t1 .if n .ta 5n .if t .ta 1i .. .SH NAME vmstat \- report virtual memory statistics .SH SYNOPSIS .B vmstat [ .B \-fsi ] [ drives ] [ interval [ count ] ] .SH DESCRIPTION .I Vmstat delves into the system and normally reports certain statistics kept about process, virtual memory, disk, trap and cpu activity. If given a .B \-f argument, it instead reports on the number of .I forks and .I vforks since system startup and the number of pages of virtual memory involved in each kind of fork. If given a .B \-s argument, it instead prints the contents of the .I sum structure, giving the total number of several kinds of paging related events which have occurred since boot. If given a .B \-i argument, it instead reports on the number of .I interrupts taken by each device since system startup. .PP If none of these options are given, .I vmstat will report in the first line a summary of the virtual memory activity since the system has been booted. If .I interval is specified, then successive lines are summaries over the last .I interval seconds. ``vmstat 5'' will print what the system is doing every five seconds; this is a good choice of printing interval since this is how often some of the statistics are sampled in the system; others vary every second, running the output for a while will make it apparent which are recomputed every second. If a .I count is given, the statistics are repeated .I count times. The format fields are: .PP Procs: information about numbers of processes in various states. .s1 .t1 .nf r in run queue b blocked for resources (i/o, paging, etc.) w runnable or short sleeper (< 20 secs) but swapped .fi .s1 Memory: information about the usage of virtual and real memory. Virtual pages are considered active if they belong to processes which are running or have run in the last 20 seconds. A ``page'' here is 1024 bytes. .s1 .t1 .nf avm active virtual pages fre size of the free list .fi .s1 Page: information about page faults and paging activity. These are averaged each five seconds, and given in units per second. .s1 .t1 .nf re page reclaims (simulating reference bits) at pages attached (found in free list) pi pages paged in po pages paged out fr pages freed per second de anticipated short term memory shortfall sr pages scanned by clock algorithm, per-second .fi .s1 up/hp/rk/ra: Disk operations per second (this field is system dependent). Typically paging will be split across several of the available drives. The number under each of these is the unit number. .s1 Faults: trap/interrupt rate averages per second over last 5 seconds. .s1 .t1 .nf in (non clock) device interrupts per second sy system calls per second cs cpu context switch rate (switches/sec) .fi .s1 Cpu: breakdown of percentage usage of CPU time .s1 .nf us user time for normal and low priority processes sy system time id cpu idle .fi .PP If more than 4 disk drives are configured in the system, .I vmstat displays only the first 4 drives, with priority given to Massbus disk drives (i.e. if both Unibus and Massbus drives are present and the total number of drives exceeds 4, then some number of Unibus drives will not be displayed in favor of the Massbus drives). To force .I vmstat to display specific drives, their names may be supplied on the command line. .SH FILES /dev/kmem, /vmunix .SH SEE ALSO .IR systat (1), .IR iostat (1) .PP The sections starting with ``Interpreting system activity'' in .IR "Installing and Operating 4.2bsd" . ================================================ FILE: share/man/man1/vwidth.1 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)vwidth.1 6.1.1 (2.11BSD) 1996/10/22 .\" .TH VWIDTH 1 "October 22, 1996" .UC 5 .SH NAME vwidth \- make troff width table for a font .SH SYNOPSIS .B vwidth fontfile pointsize > ft\fIxx\fP.c .br .B cc -c ft\fIxx\fP.c mv ft\fIxx\fP.o /usr/share/font/ft\fIxx\fP .SH DESCRIPTION .I Vwidth translates from the width information stored in the vfont style format to the format expected by troff. Troff wants an object file in a.out(5) format. (This fact does not seem to be documented anywhere.) Troff should look directly in the font file but it doesn't. .PP Vwidth should be used after editing a font with .I fed(1). It is not necessary to use vwidth unless you have made a change that would affect the width tables. Such changes include numerically editing the width field, adding a new character, and moving or copying a character to a new position. It is .I not always necessary to use vwidth if the physical width of the glyph (e.g. the number of columns in the bit matrix) has changed, but if it has changed much the logical width should probably be changed and vwidth run. .PP Vwidth produces a C program on its standard output. This program should be run through the C compiler and the object (that is, the .o file) saved. The resulting file should be placed in /usr/share/font in the file .RI ft xx where .II xx is a one or two letter code that is the logical (internal to troff) font name. This name can be found by looking in the file .RI /usr/share/fontinfo/ fname * where .I fname is the external name of the font. .SH "SEE ALSO" fed(1), vfont(5), troff(1), vtroff(1) .SH BUGS Produces the C file using obsolete syntax that the portable C compiler complains about. ================================================ FILE: share/man/man1/w.1 ================================================ .TH W 1 "November 28, 1996" .UC .SH NAME w, uptime \- who is on and what they are doing; system time up .SH SYNOPSIS .B w [ .B \-hswu ] [ user ] .br .B uptime .SH DESCRIPTION .I W prints a summary of the current activity on the system, including what each user is doing. .PP The .I uptime invocation prints only the header line. .PP The heading line shows the current time of day, how long the system has been up, the number of users logged into the system, and the load averages. The load average numbers give the number of jobs in the run queue averaged over 1, 5 and 15 minutes. .PP The fields output are: the users login name, the name of the tty the user is on, the time of day the user logged on, the number of minutes since the user last typed anything, the CPU time used by all processes and their children on that terminal, the CPU time used by the currently active processes, the name and arguments of the current process. .PP The .B \-h flag suppresses the heading. The .B \-s flag asks for a short form of output. In the short form, the tty is abbreviated, the login time and cpu times are left off, as are the arguments to commands. .PP The .B \-w and .B \-u flags force the .I w and .I uptime actions respectively, regardless of the name the program is invoked as. .PP If a .I user name is included, the output will be restricted to that user. .SH FILES .ta 2i /var/run/utmp for login names .br /dev/swap secondary storage .SH "SEE ALSO" finger(1), ps(1), who(1) .SH AUTHOR Mark Horton .SH BUGS The notion of the ``current process'' is muddy. The current algorithm is ``the highest numbered process on the terminal that is not ignoring interrupts, or, if there is none, the highest numbered process on the terminal''. This fails, for example, in critical sections of programs like the shell and editor, or when faulty programs running in the background fork and fail to ignore interrupts. (In cases where no process can be found, .I w prints ``\-''.) .PP The CPU time is only an estimate, in particular, if someone leaves a background processs running after logging out, the person currently on that terminal is ``charged'' with the time. .PP Background processes are not shown, even though they account for much of the load on the system. .PP Sometimes processes, typically those in the background, are printed with null or garbaged arguments. In these cases, the name of the command is printed in parentheses. ================================================ FILE: share/man/man1/wait.1 ================================================ .\" @(#)wait.1 6.1 (Berkeley) 4/29/85 .\" .TH WAIT 1 "April 29, 1985" .AT 3 .SH NAME wait \- await completion of process .SH SYNOPSIS .B wait .SH DESCRIPTION Wait until all processes started with .B & have completed, and report on abnormal terminations. .PP Because the .IR wait (2) system call must be executed in the parent process, the Shell itself executes .I wait, without creating a new process. .SH "SEE ALSO" sh(1) .SH BUGS Not all the processes of a 3- or more-stage pipeline are children of the Shell, and thus can't be waited for. (This bug does not apply to .IR csh (1).) ================================================ FILE: share/man/man1/wall.1 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)wall.1 6.1.1 (2.11BSD) 1996/11/27 .\" .TH WALL 1 "November 27, 1996" .UC 4 .SH NAME wall \- write to all users .SH SYNOPSIS .B wall .SH DESCRIPTION .I Wall reads its standard input until an end-of-file. It then sends this message, preceded by `Broadcast Message ...', to all logged in users. .PP The sender should be super-user to override any protections the users may have invoked. .SH FILES /dev/tty? .br /var/run/utmp .SH "SEE ALSO" mesg(1), write(1) .SH DIAGNOSTICS `Cannot send to ...' when the open on a user's tty file fails. ================================================ FILE: share/man/man1/wc.1 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)wc.1 6.1 (Berkeley) 4/29/85 .\" .TH WC 1 "April 29, 1985" .UC 4 .SH NAME wc \- word count .SH SYNOPSIS .B wc [ .B \-lwc ] [ name ... ] .SH DESCRIPTION .PP .I Wc counts lines, words and characters in the named files, or in the standard input if no name appears. A word is a maximal string of characters delimited by spaces, tabs or newlines. .PP If an argument beginning with one of ``lwc'' is present, the specified counts (lines, words, or characters) are selected by the letters .BR l , .BR w , or .BR c . The default is .BR \-lwc . .SH BUGS ================================================ FILE: share/man/man1/what.1 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)what.1 6.1 (Berkeley) 4/29/85 .\" .TH WHAT 1 "April 29, 1985" .UC 4 .SH NAME what \- show what versions of object modules were used to construct a file .SH SYNOPSIS .B what name ... .SH DESCRIPTION .I What reads each file and searches for sequences of the form ``@(#)'' as inserted by the source code control system. It then prints the remainder of the string after this marker, up to a null character, newline, double quote, or ``>'' character. .SH BUGS As SCCS is not licensed with UNIX/32V, this is a rewrite of the .I what command which is part of SCCS, and may not behave exactly the same as that command does. ================================================ FILE: share/man/man1/whatis.1 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)whatis.1 6.3 (Berkeley) 5/7/86 .\" .TH WHATIS 1 "May 7, 1986" .UC 4 .SH NAME whatis \- describe what a command is .SH SYNOPSIS .B whatis command ... .SH DESCRIPTION .I Whatis looks up a given command and gives the header line from the manual section. You can then run the .IR man (1) command to get more information. If the line starts `name(section) ...' you can do `man section name' to get the documentation for it. Try `whatis ed' and then you should do `man 1 ed' to get the manual. .PP .I Whatis is actually just the .B \-f option to the .IR man (1) command. .SH FILES .DT /usr/man/whatis Data base .SH "SEE ALSO" man(1), catman(8) ================================================ FILE: share/man/man1/which.1 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)which.1 6.1 (Berkeley) 4/29/85 .\" .TH WHICH 1 "April 29, 1985" .UC .SH NAME which \- locate a program file including aliases and paths (\fIcsh\fR only) .SH SYNOPSIS .B which [ name ] ... .SH DESCRIPTION .I Which takes a list of names and looks for the files which would be executed had these names been given as commands. Each argument is expanded if it is aliased, and searched for along the user's path. Both aliases and path are taken from the user's \&.cshrc file. .SH FILES .ta 1i ~/\&.cshrc source of aliases and path values .SH DIAGNOSTICS A diagnostic is given for names which are aliased to more than a single word, or if an executable file with the argument name was not found in the path. .SH BUGS Must be executed by a csh, since only csh's know about aliases. ================================================ FILE: share/man/man1/who.1 ================================================ .\" @(#)who.1 6.1.1 (2.11BSD) 1996/11/27 .\" .TH WHO 1 "November 27, 1996" .AT 3 .SH NAME who \- who is on the system .SH SYNOPSIS .B who [ who-file ] [ .B "am I" ] .SH DESCRIPTION .I Who, without an argument, lists the login name, terminal name, and login time for each current UNIX user. .PP Without an argument, .I who examines the .I /var/run/utmp file to obtain its information. If a file is given, that file is examined. Typically the given file will be /usr/adm/wtmp, which contains a record of all the logins since it was created. Then .I who lists logins, logouts, and crashes since the creation of the wtmp file. Each login is listed with user name, terminal name (with `/dev/' suppressed), and date and time. When an argument is given, logouts produce a similar line without a user name. Reboots produce a line with `x' in the place of the device name, and a fossil time indicative of when the system went down. .PP With two arguments, as in `who am I' (and also `who are you'), .I who tells who you are logged in as. .SH FILES /var/run/utmp .SH "SEE ALSO" getuid(2), utmp(5) ================================================ FILE: share/man/man1/whois.1 ================================================ .\" Copyright (c) 1985 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)whois.1 6.2 (Berkeley) 6/6/85 .\" .TH WHOIS 1 "June 6, 1985" .UC 6 .SH NAME whois \- DARPA Internet user name directory service .SH SYNOPSIS .B whois name .SH DESCRIPTION .TP whois help Produces a helpful message similar to the following: .PP Please enter a name or a handle (``ident"), such as ``Smith" or ``SRI-NIC". Starting with a period forces a name-only search; starting with exclamation point forces handle-only. Examples: .nf Smith [looks for name or handle SMITH ] !SRI-NIC [looks for handle SRI-NIC only ] .Smith, John [looks for name JOHN SMITH only ] .fi Adding ``..." to the argument will match anything from that point, e.g. ``ZU..." will match ZUL, ZUM, etc. .PP To have the ENTIRE membership list of a group or organization, if you are asking about a group or org, shown with the record, use an asterisk character `*' directly preceding the given argument. [CAUTION: If there are a lot of members this will take a long time!] You may of course use exclamation point and asterisk, or a period and asterisk together. .SH SEE ALSO RFC 812: Nicname/Whois ================================================ FILE: share/man/man1/window.1 ================================================ .\" Copyright (c) 1985 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)window.1 6.5 (Berkeley) 5/12/86 .\" .TH WINDOW 1 "May 12, 1986" .UC 6 .SH NAME window \- window environment .SH SYNOPSIS .B window [ .B \-t ] [ .B \-f ] [ .B \-d ] [ .B \-e escape-char ] [ .B \-c command ] .SH DESCRIPTION \fIWindow\fP implements a window environment on ASCII terminals. .PP A window is a rectangular portion of the physical terminal screen associated with a set of processes. Its size and position can be changed by the user at any time. Processes communicate with their window in the same way they normally interact with a terminal--through their standard input, output, and diagnostic file descriptors. The window program handles the details of redirecting input an output to and from the windows. At any one time, only one window can receive input from the keyboard, but all windows can simultaneously send output to the display. .PP Windows can overlap and are framed as necessary. Each window is named by one of the digits ``1'' to ``9''. This one character identifier, as well as a user definable label string, are displayed with the window on the top edge of its frame. A window can be designated to be in the \fIforeground\fP, in which case it will always be on top of all normal, non-foreground windows, and can be covered only by other foreground windows. A window need not be completely within the edges of the terminal screen. Thus a large window (possibly larger than the screen) may be positioned to show only a portion of its full size. .PP Each window has a cursor and a set of control functions. Most intelligent terminal operations such as line and character deletion and insertion are supported. Display modes such as underlining and reverse video are available if they are supported by the terminal. In addition, similar to terminals with multiple pages of memory, each window has a text buffer which can have more lines than the window itself. .SH OPTIONS When \fIwindow\fP starts up, the commands (see long commands below) contained in the file \fI.windowrc\fP in the user's home directory are executed. If it does not exist, two equal sized windows spanning the terminal screen are created by default. .PP The command line options are .TP .B \-t Turn on terse mode (see \fIterse\fP command below). .TP .B \-f Fast. Don't perform any startup action. .TP .B \-d Ignore \fI.windowrc\fP and create the two default windows instead. .TP .B \-e escape-char Set the escape character to \fIescape-char\fP. \fIEscape-char\fP can be a single character, or in the form \fI^X\fP where \fIX\fP is any character, meaning control-\fIX\fP. .TP .B \-c command Execute the string \fIcommand\fP as a long command (see below) before doing anything else. .SH "PROCESS ENVIRONMENT" With each newly created window, a shell program is spawned with its process environment tailored to that window. Its standard input, output, and diagnostic file descriptors are bound to one end of either a pseudo-terminal (\fIpty\fP (4)) or a UNIX domain socket (\fIsocketpair\fP (4)). If a pseudo-terminal is used, then its special characters and modes (see \fIstty\fP (1)) are copied from the physical terminal. A \fItermcap\fP (5) entry tailored to this window is created and passed as environment (\fIenviron\fP (5)) variable \fITERMCAP\fP. The termcap entry contains the window's size and characteristics as well as information from the physical terminal, such as the existence of underline, reverse video, and other display modes, and the codes produced by the terminal's function keys, if any. In addition, the window size attributes of the pseudo-terminal are set to reflect the size of this window, and updated whenever it is changed by the user. In particular, the editor \fIvi\fP (1) uses this information to redraw its display. .SH OPERATION .PP During normal execution, \fIwindow\fP can be in one of two states: conversation mode and command mode. In conversation mode, the terminal's real cursor is placed at the cursor position of a particular window--called the current window--and input from the keyboard is sent to the process in that window. The current window is always on top of all other windows, except those in foreground. In addition, it is set apart by highlighting its identifier and label in reverse video. .PP Typing \fIwindow\fP's escape character (normally ^P) in conversation mode switches it into command mode. In command mode, the top line of the terminal screen becomes the command prompt window, and \fIwindow\fP interprets input from the keyboard as commands to manipulate windows. .PP There are two types of commands: short commands are usually one or two key strokes; long commands are strings either typed by the user in the command window (see the ``:'' command below), or read from a file (see \fIsource\fP below). .SH "SHORT COMMANDS" Below, \fI#\fP represents one of the digits ``1'' to ``9'' corresponding to the windows 1 to 9. \fI^X\fP means control-\fIX\fP, where \fPX\fP is any character. In particular, \fI^^\fP is control-^. \fIEscape\fP is the escape key, or \fI^[\fP. .TP .B # Select window \fI#\fP as the current window and return to conversation mode. .TP .B %# Select window \fI#\fP but stay in command mode. .TP .B ^^ Select the previous window and return to conversation mode. This is useful for toggling between two windows. .TP .B escape Return to conversation mode. .TP .B ^P Return to conversation mode and write ^P to the current window. Thus, typing two ^P's in conversation mode sends one to the current window. If the \fIwindow\fP escape is changed to some other character, that character takes the place of ^P here. .TP .B ? List a short summary of commands. .TP .B ^L Redraw the screen. .TP .B q Exit \fIwindow\fP. Confirmation is requested. .TP .B ^Z Suspend \fIwindow\fP. .TP .B w Create a new window. The user is prompted for the positions of the upper left and lower right corners of the window. The cursor is placed on the screen and the keys ``h'', ``j'', ``k'', and ``l'' move the cursor left, down, up, and right, respectively. The keys ``H'', ``J'', ``K'', and ``L'' move the cursor to the respective limits of the screen. Typing a number before the movement keys repeats the movement that number of times. Return enters the cursor position as the upper left corner of the window. The lower right corner is entered in the same manner. During this process, the placement of the new window is indicated by a rectangular box drawn on the screen, corresponding to where the new window will be framed. Typing escape at any point cancels this command. .IP This window becomes the current window, and is given the first available ID. The default buffer size is used (see \fInline\fP command below). .IP Only fully visible windows can be created this way. .TP .B c# Close window \fI#\fP. The process in the window is sent the hangup signal (see \fIkill\fP (1)). \fICsh\fP (1) should handle this signal correctly and cause no problems. .TP .B m# Move window \fI#\fP to another location. A box in the shape of the window is drawn on the screen to indicate the new position of the window, and the same keys as those for the \fIw\fP command are used to position the box. The window can be moved partially off-screen. .TP .B M# Move window \fI#\fP to its previous position. .TP .B s# Change the size of window \fI#\fP. The user is prompted to enter the new lower right corner of the window. A box is drawn to indicate the new window size. The same keys used in \fIw\fP and \fIm\fP are used to enter the position. .TP .B S# Change window \fI#\fP to its previous size. .TP .B ^Y Scroll the current window up by one line. .TP .B ^E Scroll the current window down by one line. .TP .B ^U Scroll the current window up by half the window size. .TP .B ^D Scroll the current window down by half the window size. .TP .B ^B Scroll the current window up by the full window size. .TP .B ^F Scroll the current window down by the full window size. .TP .B h Move the cursor of the current window left by one column. .TP .B j Move the cursor of the current window down by one line. .TP .B k Move the cursor of the current window up by one line. .TP .B l Move the cursor of the current window right by one column. .TP .B ^S Stop output in the current window. .TP .B ^Q Start output in the current window. .TP .B : Enter a line to be executed as long commands. Normal line editing characters (erase character, erase word, erase line) are supported. .SH "LONG COMMANDS" Long commands are a sequence of statements parsed much like a programming language, with a syntax similar to that of C. Numeric and string expressions and variables are supported, as well as conditional statements. .PP There are two data types: string and number. A string is a sequence of letters or digits beginning with a letter. ``_'' and ``.'' are considered letters. Alternately, non-alphanumeric characters can be included in strings by quoting them in ``"'' or escaping them with ``\\''. In addition, the ``\\'' sequences of C are supported, both inside and outside quotes (e.g., ``\\n'' is a new line, ``\\r'' a carriage return). For example, these are legal strings: abcde01234, "&#$^*&#", ab"$#"cd, ab\\$\\#cd, "/usr/ucb/window". .PP A number is an integer value in one of three forms: a decimal number, an octal number preceded by ``0'', or a hexadecimal number preceded by ``0x'' or ``0X''. The natural machine integer size is used (i.e., the signed integer type of the C compiler). As in C, a non-zero number represents a boolean true. .PP The character ``#'' begins a comment which terminates at the end of the line. .PP A statement is either a conditional or an expression. Expression statements are terminated with a new line or ``;''. To continue an expression on the next line, terminate the first line with ``\\''. .SH "CONDITIONAL STATEMENT" \fIWindow\fP has a single control structure: the fully bracketed if statement in the form .nf if then . . . elsif then . . . else . . . endif .fi The \fIelse\fP and \fIelsif\fP parts are optional, and the latter can be repeated any number of times. \fI\fP must be numeric. .SH EXPRESSIONS Expressions in \fIwindow\fP are similar to those in the C language, with most C operators supported on numeric operands. In addition, some are overloaded to operate on strings. .PP When an expression is used as a statement, its value is discarded after evaluation. Therefore, only expressions with side effects (assignments and function calls) are useful as statements. .PP Single valued (no arrays) variables are supported, of both numeric and string values. Some variables are predefined. They are listed below. .PP The operators in order of increasing precedence: .TP .B = Assignment. The variable of name \fI\fP, which must be string valued, is assigned the result of \fI\fP. Returns the value of \fI\fP. .TP .B ? : Returns the value of \fI\fP if \fI\fP evaluates true (non-zero numeric value); returns the value of \fI\fP otherwise. Only one of \fI\fP and \fI\fP is evaluated. \fI\fP must be numeric. .TP .B || Logical or. Numeric values only. Short circuit evaluation is supported (i.e., if \fI\fP evaluates true, then \fI\fP is not evaluated). .TP .B && Logical and with short circuit evaluation. Numeric values only. .TP .B | Bitwise or. Numeric values only. .TP .B ^ Bitwise exclusive or. Numeric values only. .TP .B & Bitwise and. Numeric values only. .TP .B == , != Comparison (equal and not equal, respectively). The boolean result (either 1 or 0) of the comparison is returned. The operands can be numeric or string valued. One string operand forces the other to be converted to a string in necessary. .TP .B < , > , <= , >= Less than, greater than, less than or equal to, greater than or equal to. Both numeric and string values, with automatic conversion as above. .TP .B << , >> If both operands are numbers, \fI\fP is bit shifted left (or right) by \fI\fP bits. If \fI\fP is a string, then its first (or last) \fI\fP characters are returns (if \fI\fP is also a string, then its length is used in place of its value). .TP .B + , - Addition and subtraction on numbers. For ``+'', if one argument is a string, then the other is converted to a string, and the result is the concatenation of the two strings. .TP .B * , / , % Multiplication, division, modulo. Numbers only. .TP .B -, ~, !, $, $? The first three are unary minus, bitwise complement and logical complement on numbers only. The operator, ``$'', takes \fI\fP and returns the value of the variable of that name. If \fI\fP is numeric with value \fIn\fP and it appears within an alias macro (see below), then it refers to the nth argument of the alias invocation. ``$?'' tests for the existence of the variable \fI\fP, and returns 1 if it exists or 0 otherwise. .TP .B () Function call. \fI\fP must be a string that is the unique prefix of the name of a builtin \fIwindow\fP function or the full name of a user defined alias macro. In the case of a builtin function, \fI\fP can be in one of two forms: .br , , . . . .br argname1 = , argname2 = , . . . .br The two forms can in fact be intermixed, but the result is unpredictable. Most arguments can be omitted; default values will be supplied for them. The \fIargnames\fP can be unique prefixes of the the argument names. The commas separating arguments are used only to disambiguate, and can usually be omitted. .IP Only the first argument form is valid for user defined aliases. Aliases are defined using the \fIalias\fP builtin function (see below). Arguments are accessed via a variant of the variable mechanism (see ``$'' operator above). .IP Most functions return value, but some are used for side effect only and so must be used as statements. When a function or an alias is used as a statement, the parenthesis surrounding the argument list may be omitted. Aliases return no value. .SH "BUILTIN FUNCTIONS" The arguments are listed by name in their natural order. Optional arguments are in square brackets (``[ ]''). Arguments that have no names are in angle brackets (``<>''). .TP .B alias([], []) If no argument is given, all currently defined alias macros are listed. Otherwise, \fI\fP is defined as an alias, with expansion \fI\fP. The previous definition of \fI\fP, if any, is returned. Default for \fI\fP is no change. .TP .B close() Close the windows specified in \fI\fP. If \fI\fP is the word \fIall\fP, than all windows are closed. No value is returned. .TP .B cursormodes([modes]) Set the window cursor to \fImodes\fP. \fIModes\fP is the bitwise or of the mode bits defined as the variables \fIm_ul\fP (underline), \fIm_rev\fP (reverse video), \fIm_blk\fP (blinking), and \fIm_grp\fP (graphics, terminal dependent). Return value is the previous modes. Default is no change. For example, cursor($m_rev|$m_blk) sets the window cursors to blinking reverse video. .TP .B echo([window], []) Write the list of strings, \fI\fP, to \fIwindow\fP, separated by spaces and terminated with a new line. The strings are only displayed in the window, the processes in the window are not involved (see \fIwrite\fP below). No value is returned. Default is the current window. .TP .B escape([escapec]) Set the escape character to \fIescape-char\fP. Returns the old escape character as a one character string. Default is no change. \fPEscapec\fP can be a string of a single character, or in the form \fI^X\fP, meaning control-\fIX\fP. .TP .B foreground([window], [flag]) Move \fIwindow\fP in or out of foreground. \fIFlag\fP can be one of \fIon\fP, \fIoff\fP, \fIyes\fP, \fIno\fP, \fItrue\fP, or \fIfalse\fP, with obvious meanings, or it can be a numeric expression, in which case a non-zero value is true. Returns the old foreground flag as a number. Default for \fIwindow\fP is the current window, default for \fIflag\fP is no change. .TP .B label([window], [label]) Set the label of \fIwindow\fP to \fIlabel\fP. Returns the old label as a string. Default for \fIwindow\fP is the current window, default for \fIlabel\fP is no change. To turn off a label, set it to an empty string (""). .TP .B list() No arguments. List the identifiers and labels of all windows. No value is returned. .TP .B nline([nline]) Set the default buffer size to \fInline\fP. Initially, it is 48 lines. Returns the old default buffer size. Default is no change. Using a very large buffer can slow the program down considerably. .TP .B select([window]) Make \fIwindow\fP the current window. The previous current window is returned. Default is no change. .TP .B shell([]) Set the default window shell program to \fI\fP. Returns the first string in the old shell setting. Default is no change. Initially, the default shell is taken from the environment variable \fISHELL\fP. .TP .B source(filename) Read and execute the long commands in \fIfilename\fP. Returns -1 if the file cannot be read, 0 otherwise. .TP .B terse([flag]) Set terse mode to \fIflag\fP. In terse mode, the command window stays hidden even in command mode, and errors are reported by sounding the terminal's bell. \fIFlag\fP can take on the same values as in \fIforeground\fP above. Returns the old terse flag. Default is no change. .TP .B unalias(alias) Undefine \fIalias\fP. Returns -1 if \fIalias\fP does not exist, 0 otherwise. .TP .B unset(variable) Undefine \fIvariable\fP. Returns -1 if \fIvariable\fP does not exist, 0 otherwise. .TP .B variables() No arguments. List all variables. No value is returned. .TP .B window([row], [column], [nrow], [ncol], [nline], [frame], .B [pty], [mapnl], [shell]) .br Open a window with upper left corner at \fIrow\fP, \fIcolumn\fP and size \fInrow\fP, \fIncol\fP. If \fInline\fP is specified, then that many lines are allocated for the text buffer. Otherwise, the default buffer size is used. Default values for \fIrow\fP, \fIcolumn\fP, \fInrow\fP, and \fIncol\fP are, respectively, the upper, left-most, lower, or right-most extremes of the screen. \fIFrame\fP, \fIpty\fP, and \fImapnl\fP are flag values interpreted in the same way as the argument to \fIforeground\fP (see above); they mean, respectively, put a frame around this window (default true), allocate pseudo-terminal for this window rather than socketpair (default true), and map new line characters in this window to carriage return and line feed (default true if socketpair is used, false otherwise). \fIShell\fP is a list of strings that will be used as the shell program to place in the window (default is the program specified by \fIshell\fP, see below). The created window's identifier is returned as a number. .TP .B write([window], []) Send the list of strings, \fI\fP, to \fIwindow\fP, separated by spaces but not terminated with a new line. The strings are actually given to the window as input. No value is returned. Default is the current window. .SH "PREDEFINED VARIABLES" These variables are for information only. Redefining them does not affect the internal operation of \fIwindow\fP. .TP .B baud The baud rate as a number between 50 and 38400. .TP .B modes The display modes (reverse video, underline, blinking, graphics) supported by the physical terminal. The value of \fImodes\fP is the bitwise or of some of the one bit values, \fIm_blk\fP, \fIm_grp\fP, \fIm_rev\fP, and \fIm_ul\fP (see below). These values are useful in setting the window cursors' modes (see \fIcursormodes\fP above). .TP .B m_blk The blinking mode bit. .TP .B m_grp The graphics mode bit (not very useful). .TP .B m_rev The reverse video mode bit. .TP .B m_ul The underline mode bit. .TP .B ncol The number of columns on the physical screen. .TP .B nrow The number of rows on the physical screen. .TP .B term The terminal type. The standard name, found in the second name field of the terminal's \fITERMCAP\fP entry, is used. .SH FILES .ta 15 ~/.windowrc startup command file. .br /dev/[pt]ty[pq]? pseudo-terminal devices. .SH DIAGNOSTICS Should be self explanatory. .SH BUGS ================================================ FILE: share/man/man1/write.1 ================================================ .\" @(#)write.1 6.2.1 (2.11BSD) 1996/11/27 .\" .TH WRITE 1 "November 27, 1996" .AT 3 .SH NAME write \- write to another user .SH SYNOPSIS .B write user [ ttyname ] .SH DESCRIPTION .I Write copies lines from your terminal to that of another user. When first called, it sends the message .PP Message from yourname@yoursystem on yourttyname at time... .PP The recipient of the message should write back at this point. Communication continues until an end of file is read from the terminal or an interrupt is sent. At that point .I write writes `EOT' on the other terminal and exits. .PP If you want to write to a user who is logged in more than once, the .I ttyname argument may be used to indicate the appropriate terminal name. .PP Permission to write may be denied or granted by use of the .I mesg command. At the outset writing is allowed. Certain commands, in particular .I nroff and .IR pr (1) disallow messages in order to prevent messy output. .PP If the character `!' is found at the beginning of a line, .I write calls the shell to execute the rest of the line as a command. .PP The following protocol is suggested for using .IR write : when you first write to another user, wait for him to write back before starting to send. Each party should end each message with a distinctive signal\(em\fB(o)\fR for `over' is conventional\(emthat the other may reply. .B (oo) for `over and out' is suggested when conversation is about to be terminated. .SH FILES /var/run/utmp to find user .br /bin/sh to execute `!' .SH "SEE ALSO" mesg(1), who(1), mail(1) ================================================ FILE: share/man/man1/xstr.1 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)xstr.1 6.2 (Berkeley) 5/7/86 .\" .TH XSTR 1 "May 7, 1986" .UC .SH NAME xstr \- extract strings from C programs to implement shared strings .SH SYNOPSIS .B xstr [ .B \-c ] [ .B \- ] [ file ] .SH DESCRIPTION .I Xstr maintains a file .I strings into which strings in component parts of a large program are hashed. These strings are replaced with references to this common area. This serves to implement shared constant strings, most useful if they are also read-only. .PP The command .PP .DT \fBxstr \-c\fR name .PP will extract the strings from the C source in name, replacing string references by expressions of the form (&xstr[number]) for some number. An appropriate declaration of .I xstr is prepended to the file. The resulting C text is placed in the file .I x.c, to then be compiled. The strings from this file are placed in the .I strings data base if they are not there already. Repeated strings and strings which are suffices of existing strings do not cause changes to the data base. .PP After all components of a large program have been compiled a file .I xs.c declaring the common .I xstr space can be created by a command of the form .PP .DT \fBxstr\fR .PP This .I xs.c file should then be compiled and loaded with the rest of the program. If possible, the array can be made read-only (shared) saving space and swap overhead. .PP .I Xstr can also be used on a single file. A command .PP .DT \fBxstr\fR name .PP creates files .I x.c and .I xs.c as before, without using or affecting any .I strings file in the same directory. .PP It may be useful to run .I xstr after the C preprocessor if any macro definitions yield strings or if there is conditional code which contains strings which may not, in fact, be needed. .I Xstr reads from its standard input when the argument `\-' is given. An appropriate command sequence for running .I xstr after the C preprocessor is: .PP .nf .DT \fBcc \-E\fR name.c | \fBxstr \-c\fR \- \fBcc \-c\fR x.c \fBmv\fR x.o name.o .fi .PP .I Xstr does not touch the file .I strings unless new items are added, thus .I make can avoid remaking .I xs.o unless truly necessary. .SH FILES .DT strings Data base of strings .br x.c Massaged C source .br xs.c C source for definition of array `xstr' .br /tmp/xs* Temp file when `xstr name' doesn't touch .I strings .SH "SEE ALSO" mkstr(1) .SH BUGS If a string is a suffix of another string in the data base, but the shorter string is seen first by .I xstr both strings will be placed in the data base, when just placing the longer one there will do. ================================================ FILE: share/man/man1/yacc.1 ================================================ .\" @(#)yacc.1 6.1.1 (2.11BSD) 1996/10/22 .\" .TH YACC 1 "October 22, 1996" .AT 3 .SH NAME yacc \- yet another compiler-compiler .SH SYNOPSIS .B yacc [ .B \-vd ] grammar .SH DESCRIPTION .I Yacc converts a context-free grammar into a set of tables for a simple automaton which executes an LR(1) parsing algorithm. The grammar may be ambiguous; specified precedence rules are used to break ambiguities. .PP The output file, .IR y.tab.c , must be compiled by the C compiler to produce a program .IR yyparse . This program must be loaded with the lexical analyzer program, .IR yylex , as well as .I main and .IR yyerror , an error handling routine. These routines must be supplied by the user; .IR Lex (1) is useful for creating lexical analyzers usable by .IR yacc . .PP If the .B \-v flag is given, the file .I y.output is prepared, which contains a description of the parsing tables and a report on conflicts generated by ambiguities in the grammar. .PP If the \-\fBd\fR flag is used, the file .I y.tab.h is generated with the .I define statements that associate the .I yacc\c -assigned `token codes' with the user-declared `token names'. This allows source files other than .I y.tab.c to access the token codes. .SH FILES .ta \w'yacc.tmp, yacc.acts 'u y.output .br y.tab.c .br y.tab.h defines for token names .br yacc.tmp, yacc.acts temporary files .br /usr/share/misc/yaccpar parser prototype for C programs .SH "SEE ALSO" .IR lex (1) .br .I "LR Parsing" by A. V. Aho and S. C. Johnson, Computing Surveys, June, 1974. .br .I "YACC \- Yet Another Compiler Compiler" by S. C. Johnson. .SH DIAGNOSTICS The number of reduce-reduce and shift-reduce conflicts is reported on the standard output; a more detailed report is found in the .I y.output file. Similarly, if some rules are not reachable from the start symbol, this is also reported. .SH BUGS Because file names are fixed, at most one .I yacc process can be active in a given directory at a time. ================================================ FILE: share/man/man1/yes.1 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)yes.1 6.1 (Berkeley) 4/29/85 .\" .TH YES 1 "April 29, 1985" .UC 4 .SH NAME yes \- be repetitively affirmative .SH SYNOPSIS .B yes [ .I expletive ] .SH DESCRIPTION .I Yes repeatedly outputs \*(lqy\*(rq, or if .I expletive is given, that is output repeatedly. Termination is by rubout. ================================================ FILE: share/man/man2/Makefile ================================================ # # Copyright (c) 1987 Regents of the University of California. # All rights reserved. # # Redistribution and use in source and binary forms are permitted # provided that the above copyright notice and this paragraph are # duplicated in all such forms and that any documentation, # advertising materials, and other materials related to such # distribution and use acknowledge that the software was developed # by the University of California, Berkeley. The name of the # University may not be used to endorse or promote products derived # from this software without specific prior written permission. # THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED # WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. # # @(#)Makefile 2.11 (2.11BSD) 2000/3/4 # TOPSRC!=cd ../../..; pwd include ${TOPSRC}/share/mk/sys.mk MDIR= /usr/share/man/cat2 SRCS= accept.2 access.2 acct.2 adjtime.2 bind.2 brk.2 chdir.2 chmod.2 \ chown.2 chroot.2 close.2 connect.2 creat.2 dup.2 execve.2 exit.2 \ chflags.2 \ fcntl.2 fetchi.2 flock.2 fork.2 fperr.2 fsync.2 getdtablesize.2 \ getgroups.2 gethostid.2 gethostname.2 getitimer.2 \ getpagesize.2 getpeername.2 getpgrp.2 getpid.2 getpriority.2 \ getrlimit.2 getrusage.2 getsockname.2 getsockopt.2 gettimeofday.2 \ getfsstat.2 getlogin.2 \ getuid.2 setreuid.2 setuid.2 getgid.2 setregid.2 \ intro.2 ioctl.2 kill.2 killpg.2 link.2 listen.2 \ lock.2 lseek.2 mkdir.2 mknod.2 mount.2 nostk.2 open.2 phys.2 \ pipe.2 profil.2 ptrace.2 quota.2 read.2 readlink.2 reboot.2 \ recv.2 rename.2 rmdir.2 select.2 send.2 setgroups.2 setpgrp.2 \ setquota.2 shutdown.2 sigblock.2 sigpause.2 \ sigaction.2 sigaltstack.2 sigpending.2 sigprocmask.2 sigsuspend.2 \ sigreturn.2 sigsetmask.2 sigstack.2 sigwait.2 sigvec.2 socket.2 \ socketpair.2 \ stat.2 statfs.2 swapon.2 symlink.2 sync.2 syscall.2 truncate.2 ucall.2 \ umask.2 unlink.2 utimes.2 vfork.2 vhangup.2 wait.2 write.2 OBJS= accept.0 access.0 acct.0 adjtime.0 bind.0 brk.0 chdir.0 chmod.0 \ chown.0 chroot.0 close.0 connect.0 creat.0 dup.0 execve.0 exit.0 \ chflags.0 \ fcntl.0 fetchi.0 flock.0 fork.0 fperr.0 fsync.0 getdtablesize.0 \ getgroups.0 gethostid.0 gethostname.0 getitimer.0 \ getpagesize.0 getpeername.0 getpgrp.0 getpid.0 getpriority.0 \ getrlimit.0 getrusage.0 getsockname.0 getsockopt.0 gettimeofday.0 \ getfsstat.0 getlogin.0 \ getuid.0 setreuid.0 setuid.0 getgid.0 setregid.0 \ intro.0 ioctl.0 kill.0 killpg.0 link.0 listen.0 \ lock.0 lseek.0 mkdir.0 mknod.0 mount.0 nostk.0 open.0 phys.0 \ pipe.0 profil.0 ptrace.0 quota.0 read.0 readlink.0 reboot.0 \ recv.0 rename.0 rmdir.0 select.0 send.0 setgroups.0 setpgrp.0 \ setquota.0 shutdown.0 sigblock.0 sigpause.0 \ sigaction.0 sigaltstack.0 sigpending.0 sigprocmask.0 sigsuspend.0 \ sigreturn.0 sigsetmask.0 sigstack.0 sigwait.0 sigvec.0 socket.0 \ socketpair.0 \ stat.0 statfs.0 swapon.0 symlink.0 sync.0 syscall.0 truncate.0 ucall.0 \ umask.0 unlink.0 utimes.0 vfork.0 vhangup.0 wait.0 write.0 .SUFFIXES: .2 .0 .2.0: ${MANROFF} $*.2 > $*.0 all: _make_01 _make_01: ${OBJS} clean: FRC rm -f ${OBJS} P=${DESTDIR}${MDIR} REM= sbrk.0 dup2.0 fstat.0 lstat.0 readv.0 recvfrom.0 sendmsg.0 recvmsg.0 \ sendto.0 fstatfs.0 wait3.0 wait4.0 waitpid.0 fchdir.0 fchflags.0 \ fchmod.0 fchown.0 umount.0 writev.0 getppid.0 ftruncate.0 \ pselect.0 \ sethostid.0 setitimer.0 setrlimit.0 setsockopt.0 sethostname.0 \ setpriority.0 settimeofday.0 setlogin.0 geteuid.0 setgid.0 \ seteuid.0 setegid.0 getegid.0 install: _make_01 cp ${OBJS} ${P} ln -f ${P}/dup.0 ${P}/dup2.0 ln -f ${P}/brk.0 ${P}/sbrk.0 ln -f ${P}/stat.0 ${P}/fstat.0 ln -f ${P}/stat.0 ${P}/lstat.0 ln -f ${P}/read.0 ${P}/readv.0 ln -f ${P}/recv.0 ${P}/recvfrom.0 ln -f ${P}/recv.0 ${P}/recvmsg.0 ln -f ${P}/send.0 ${P}/sendmsg.0 ln -f ${P}/send.0 ${P}/sendto.0 ln -f ${P}/statfs.0 ${P}/fstatfs.0 ln -f ${P}/wait.0 ${P}/wait3.0 ln -f ${P}/wait.0 ${P}/wait4.0 ln -f ${P}/wait.0 ${P}/waitpid.0 ln -f ${P}/chmod.0 ${P}/fchdir.0 ln -f ${P}/chflags.0 ${P}/fchflags.0 ln -f ${P}/chmod.0 ${P}/fchmod.0 ln -f ${P}/chown.0 ${P}/fchown.0 ln -f ${P}/mount.0 ${P}/umount.0 ln -f ${P}/select.0 ${P}/pselect.0 ln -f ${P}/write.0 ${P}/writev.0 ln -f ${P}/getpid.0 ${P}/getppid.0 ln -f ${P}/truncate.0 ${P}/ftruncate.0 ln -f ${P}/gethostid.0 ${P}/sethostid.0 ln -f ${P}/getitimer.0 ${P}/setitimer.0 ln -f ${P}/getrlimit.0 ${P}/setrlimit.0 ln -f ${P}/getsockopt.0 ${P}/setsockopt.0 ln -f ${P}/gethostname.0 ${P}/sethostname.0 ln -f ${P}/getpriority.0 ${P}/setpriority.0 ln -f ${P}/gettimeofday.0 ${P}/settimeofday.0 ln -f ${P}/getlogin.0 ${P}/setlogin.0 ln -f ${P}/getuid.0 ${P}/geteuid.0 ln -f ${P}/getgid.0 ${P}/getegid.0 ln -f ${P}/setuid.0 ${P}/setgid.0 ln -f ${P}/setuid.0 ${P}/seteuid.0 ln -f ${P}/setuid.0 ${P}/setegid.0 FRC: ================================================ FILE: share/man/man2/accept.2 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)accept.2 6.3 (Berkeley) 5/22/86 .\" .TH ACCEPT 2 "May 22, 1986" .UC 5 .SH NAME accept \- accept a connection on a socket .SH SYNOPSIS .ft B .nf #include #include .PP .ft B ns = accept(s, addr, addrlen) int ns, s; struct sockaddr *addr; int *addrlen; .fi .SH DESCRIPTION The argument .I s is a socket that has been created with .IR socket (2), bound to an address with .IR bind (2), and is listening for connections after a .IR listen (2). .I Accept extracts the first connection on the queue of pending connections, creates a new socket with the same properties of .I s and allocates a new file descriptor, .IR ns , for the socket. If no pending connections are present on the queue, and the socket is not marked as non-blocking, .I accept blocks the caller until a connection is present. If the socket is marked non-blocking and no pending connections are present on the queue, .I accept returns an error as described below. The accepted socket, .IR ns , may not be used to accept more connections. The original socket .I s remains open. .PP The argument .I addr is a result parameter that is filled in with the address of the connecting entity, as known to the communications layer. The exact format of the .I addr parameter is determined by the domain in which the communication is occurring. The .I addrlen is a value-result parameter; it should initially contain the amount of space pointed to by .IR addr ; on return it will contain the actual length (in bytes) of the address returned. This call is used with connection-based socket types, currently with SOCK_STREAM. .PP It is possible to .IR select (2) a socket for the purposes of doing an .I accept by selecting it for read. .SH "RETURN VALUE The call returns \-1 on error. If it succeeds, it returns a non-negative integer that is a descriptor for the accepted socket. .SH ERRORS The \fIaccept\fP will fail if: .TP 20 [EBADF] The descriptor is invalid. .TP 20 [ENOTSOCK] The descriptor references a file, not a socket. .TP 20 [EOPNOTSUPP] The referenced socket is not of type SOCK_STREAM. .TP 20 [EFAULT] The \fIaddr\fP parameter is not in a writable part of the user address space. .TP 20 [EWOULDBLOCK] The socket is marked non-blocking and no connections are present to be accepted. .SH SEE ALSO bind(2), connect(2), listen(2), select(2), socket(2) ================================================ FILE: share/man/man2/access.2 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)access.2 6.5 (Berkeley) 5/22/86 .\" .TH ACCESS 2 "May 22, 1986" .UC 4 .SH NAME access \- determine accessibility of file .SH SYNOPSIS .nf .ft B #include .PP .ft B .ta 1.25i 1.6i #define R_OK 4 /* test for read permission */ #define W_OK 2 /* test for write permission */ #define X_OK 1 /* test for execute (search) permission */ #define F_OK 0 /* test for presence of file */ .PP .ft B accessible = access(path, mode) int accessible; char *path; int mode; .ft R .fi .SH DESCRIPTION .I Access checks the given file .I path for accessibility according to .IR mode , which is an inclusive or of the bits R_OK, W_OK and X_OK. Specifying .I mode as F_OK (i.e., 0) tests whether the directories leading to the file can be searched and the file exists. .PP The real user ID and the group access list (including the real group ID) are used in verifying permission, so this call is useful to set-UID programs. .PP Notice that only access bits are checked. A directory may be indicated as writable by .IR access , but an attempt to open it for writing will fail (although files may be created there); a file may look executable, but .I execve will fail unless it is in proper format. .SH "RETURN VALUE If .I path cannot be found or if any of the desired access modes would not be granted, then a \-1 value is returned; otherwise a 0 value is returned. .SH "ERRORS Access to the file is denied if one or more of the following are true: .TP 15 [ENOTDIR] A component of the path prefix is not a directory. .TP 15 [EINVAL] The pathname contains a character with the high-order bit set. .TP 15 [ENAMETOOLONG] A component of a pathname exceeded 255 characters, or an entire path name exceeded 1023 characters. .TP 15 [ENOENT] The named file does not exist. .TP 15 [EACCES] Search permission is denied for a component of the path prefix. .TP 15 [ELOOP] Too many symbolic links were encountered in translating the pathname. .TP 15 [EROFS] Write access is requested for a file on a read-only file system. .TP 15 [ETXTBSY] Write access is requested for a pure procedure (shared text) file that is being executed. .TP 15 [EACCES] Permission bits of the file mode do not permit the requested access, or search permission is denied on a component of the path prefix. The owner of a file has permission checked with respect to the ``owner'' read, write, and execute mode bits, members of the file's group other than the owner have permission checked with respect to the ``group'' mode bits, and all others have permissions checked with respect to the ``other'' mode bits. .TP 15 [EFAULT] .I Path points outside the process's allocated address space. .TP 15 [EIO] An I/O error occurred while reading from or writing to the file system. .SH "SEE ALSO chmod(2), stat(2) ================================================ FILE: share/man/man2/acct.2 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)acct.2 6.4 (Berkeley) 5/22/86 .\" .TH ACCT 2 "May 22, 1986" .UC 4 .SH NAME acct \- turn accounting on or off .SH SYNOPSIS .nf .ft B acct(file) char *file; .ft R .fi .SH DESCRIPTION The system is prepared to write a record in an accounting .I file for each process as it terminates. This call, with a null-terminated string naming an existing file as argument, turns on accounting; records for each terminating process are appended to .IR file . An argument of 0 causes accounting to be turned off. .PP The accounting file format is given in .IR acct (5). .PP This call is permitted only to the super-user. .SH NOTES Accounting is automatically disabled when the file system the accounting file resides on runs out of space; it is enabled when space once again becomes available. .SH "RETURN VALUE On error \-1 is returned. The file must exist and the call may be exercised only by the super-user. It is erroneous to try to turn on accounting when it is already on. .SH ERRORS .I Acct will fail if one of the following is true: .TP 15 [EPERM] The caller is not the super-user. .TP 15 [ENOTDIR] A component of the path prefix is not a directory. .TP 15 [EINVAL] The pathname contains a character with the high-order bit set. .TP 15 [ENAMETOOLONG] A component of a pathname exceeded 255 characters, or an entire path name exceeded 1023 characters. .TP 15 [ENOENT] The named file does not exist. .TP 15 [EACCES] Search permission is denied for a component of the path prefix, or the path name is not a regular file. .TP 15 [ELOOP] Too many symbolic links were encountered in translating the pathname. .TP 15 [EROFS] The named file resides on a read-only file system. .TP 15 [EFAULT] .I File points outside the process's allocated address space. .TP 15 [EIO] An I/O error occurred while reading from or writing to the file system. .SH "SEE ALSO" acct(5), sa(8) .SH BUGS No accounting is produced for programs running when a crash occurs. In particular non-terminating programs are never accounted for. ================================================ FILE: share/man/man2/adjtime.2 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)adjtime.2 1.3 (Berkeley) 5/15/86 .\" .TH ADJTIME 2 "May 15, 1986" .UC 6 .SH NAME adjtime \- correct the time to allow synchronization of the system clock .SH SYNOPSIS .nf .ft B #include .PP .ft B adjtime(delta, olddelta) struct timeval *delta; struct timeval *olddelta; .fi .SH DESCRIPTION .I Adjtime makes small adjustments to the system time, as returned by .IR gettimeofday (2), advancing or retarding it by the time specified by the timeval \fIdelta\fP. If \fIdelta\fP is negative, the clock is slowed down by incrementing it more slowly than normal until the correction is complete. If \fIdelta\fP is positive, a larger increment than normal is used. The skew used to perform the correction is generally a fraction of one percent. Thus, the time is always a monotonically increasing function. A time correction from an earlier call to \fIadjtime\fP may not be finished when \fIadjtime\fP is called again. If \fIolddelta\fP is non-zero, then the structure pointed to will contain, upon return, the number of microseconds still to be corrected from the earlier call. .PP This call may be used by time servers that synchronize the clocks of computers in a local area network. Such time servers would slow down the clocks of some machines and speed up the clocks of others to bring them to the average network time. .PP The call .IR adjtime (2) is restricted to the super-user. .SH "RETURN VALUE A return value of 0 indicates that the call succeeded. A return value of \-1 indicates that an error occurred, and in this case an error code is stored in the global variable \fIerrno\fP. .SH "ERRORS The following error codes may be set in \fIerrno\fP: .TP 15 [EFAULT] An argument points outside the process's allocated address space. .TP 15 [EPERM] The process's effective user ID is not that of the super-user. .SH "SEE ALSO" date(1), gettimeofday(2), timed(8), timedc(8), .br \fITSP: The Time Synchronization Protocol for UNIX 4.3BSD\fP, R. Gusella and S. Zatti .SH "NOTES (PDP-11)" \fIAdjtime\fP(2) calls are executed immediately, not over a period of time, therefore, the \fIolddelta\fP return values for an \fIadjtime\fP(2) call will always be zero. ================================================ FILE: share/man/man2/bind.2 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)bind.2 6.6 (Berkeley) 5/22/86 .\" .TH BIND 2 "May 22, 1986" .UC 5 .SH NAME bind \- bind a name to a socket .SH SYNOPSIS .nf .ft B #include #include .PP .ft B bind(s, name, namelen) int s; struct sockaddr *name; int namelen; .fi .SH DESCRIPTION .I Bind assigns a name to an unnamed socket. When a socket is created with .IR socket (2) it exists in a name space (address family) but has no name assigned. .I Bind requests that .IR name be assigned to the socket. .SH NOTES Binding a name in the UNIX domain creates a socket in the file system that must be deleted by the caller when it is no longer needed (using .IR unlink (2)). .PP The rules used in name binding vary between communication domains. Consult the manual entries in section 4 for detailed information. .SH "RETURN VALUE If the bind is successful, a 0 value is returned. A return value of \-1 indicates an error, which is further specified in the global \fIerrno\fP. .SH ERRORS The \fIbind\fP call will fail if: .TP 20 [EBADF] \fIS\fP is not a valid descriptor. .TP 20 [ENOTSOCK] \fIS\fP is not a socket. .TP 20 [EADDRNOTAVAIL] The specified address is not available from the local machine. .TP 20 [EADDRINUSE] The specified address is already in use. .TP 20 [EINVAL] The socket is already bound to an address. .TP 20 [EACCES] The requested address is protected, and the current user has inadequate permission to access it. .TP 20 [EFAULT] The \fIname\fP parameter is not in a valid part of the user address space. .PP The following errors are specific to binding names in the UNIX domain. .TP 15 [ENOTDIR] A component of the path prefix is not a directory. .TP 15 [EINVAL] The pathname contains a character with the high-order bit set. .TP 15 [ENAMETOOLONG] A component of a pathname exceeded 255 characters, or an entire path name exceeded 1023 characters. .TP 15 [ENOENT] A prefix component of the path name does not exist. .TP 15 [ELOOP] Too many symbolic links were encountered in translating the pathname. .TP 15 [EIO] An I/O error occurred while making the directory entry or allocating the inode. .TP 15 [EROFS] The name would reside on a read-only file system. .TP 15 [EISDIR] A null pathname was specified. .SH SEE ALSO connect(2), listen(2), socket(2), getsockname(2) ================================================ FILE: share/man/man2/brk.2 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)brk.2 6.3 (Berkeley) 5/22/86 .\" .TH BRK 2 "May 22, 1986" .UC 4 .SH NAME brk, sbrk \- change data segment size .SH SYNOPSIS .nf #include .PP .ft B char *brk(addr) char *addr; .PP .ft B char *sbrk(incr) int incr; .fi .SH DESCRIPTION .I Brk sets the system's idea of the lowest data segment location not used by the program (called the break) to .I addr (rounded up to the next multiple of the system's page size). Locations greater than .I addr and below the stack pointer are not in the address space and will thus cause a memory violation if accessed. .PP In the alternate function .IR sbrk , .I incr more bytes are added to the program's data space and a pointer to the start of the new area is returned. .PP When a program begins execution via .I execve the break is set at the highest location defined by the program and data storage areas. Ordinarily, therefore, only programs with growing data areas need to use .IR sbrk . .PP The .IR getrlimit (2) system call may be used to determine the maximum permissible size of the .I data segment; it will not be possible to set the break beyond the .I rlim_max value returned from a call to .IR getrlimit , e.g. \*(lqetext + rlp\(->rlim_max.\*(rq (see .IR end (3) for the definition of .IR etext ). .SH "RETURN VALUE Zero is returned if the .I brk could be set; \-1 if the program requests more memory than the system limit. .I Sbrk returns \-1 if the break could not be set. .SH ERRORS .I Sbrk will fail and no additional memory will be allocated if one of the following are true: .TP 15 [ENOMEM] The limit, as set by .IR setrlimit (2), was exceeded. .TP 15 [ENOMEM] The maximum possible size of a data segment (compiled into the system) was exceeded. .TP 15 [ENOMEM] Insufficient space existed in the swap area to support the expansion. .SH "SEE ALSO" execve(2), getrlimit(2), malloc(3), end(3) .SH BUGS Setting the break may fail due to a temporary lack of swap space. It is not possible to distinguish this from a failure caused by exceeding the maximum size of the data segment without consulting .IR getrlimit . ================================================ FILE: share/man/man2/chdir.2 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)chdir.2 6.3.1 (2.11BSD GTE) 4/21/94 .\" .TH CHDIR 2 "April 21, 1994" .UC 4 .SH NAME chdir, fchdir \- change current working directory .SH SYNOPSIS .nf .ft B chdir(path) char *path; fchdir(fd) int fd; .ft R .fi .SH DESCRIPTION The .B path argument points to the pathname of a directory. The .B fd argument is a file descriptor which references a directory. The .I chdir function causes this directory to become the current working directory, the starting point for path names not beginning with ``/''. .PP The .I fchdir function causes the directory referenced by \fBfd\fP to become the current working directory, the starting point for path searches of pathnames not beginning with a slahs, '/'. .PP In order for a directory to become the current directory, a process must have execute (search) access to the directory. .SH "RETURN VALUE Upon successful completion, a value of 0 is returned. Otherwise, a value of \-1 is returned and \fIerrno\fP is set to indicate the error. .SH ERRORS .I Chdir will fail and the current working directory will be unchanged if one or more of the following are true: .TP 15 [ENOTDIR] A component of the path prefix is not a directory. .TP 15 [EINVAL] The pathname contains a character with the high-order bit set. .TP 15 [ENAMETOOLONG] A component of a pathname exceeded 63 characters, or an entire path name exceeded 255 characters. .TP 15 [ENOENT] The named directory does not exist. .TP 15 [ELOOP] Too many symbolic links were encountered in translating the pathname. .TP 15 [EACCES] Search permission is denied for any component of the path name. .TP 15 [EFAULT] .I Path points outside the process's allocated address space. .TP 15 [EIO] An I/O error occurred while reading from or writing to the file system. .PP .I Fchdir will fail and the current working directory will be unchanged if one or more of the following are true: .TP 15 [EACCES] Search permission is denied for the directory referenced by the file descriptor. .TP 15 [ENOTDIR] The file descriptor \fBfd\fP does not reference a directory. .TP 15 [EBADF] The argument \fBfd\fP is not a valid file descriptor. .SH "SEE ALSO" chroot(2) ================================================ FILE: share/man/man2/chflags.2 ================================================ .\" Copyright (c) 1989, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. All advertising materials mentioning features or use of this software .\" must display the following acknowledgement: .\" This product includes software developed by the University of .\" California, Berkeley and its contributors. .\" 4. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)chflags.2 8.1.1 (2.11BSD GTE) 11/28/94 .\" .TH CHFLAGS 2 "November 28, 1994" .UC 4 .SH NAME chflags, fchflags \- set file flags .SH SYNOPSIS .nf .ft B #include int chflags(path, flags) char *path; u_short flags; int fchflags(fd, flags) int fd; u_short flags; .ft R .fi .SH DESCRIPTION The file whose name is given by .B path or referenced by the descriptor .B fd has its flags changed to .B flags . .PP The flags specified are formed by or'ing the following values .PP .TP 15 UF_NODUMP Do not dump the file. .TP 15 UF_IMMUTABLE The file may not be changed. .TP 15 UF_APPEND The file may only be appended to. .TP 15 ARCHIVED File is archived. .TP 15 SF_IMMUTABLE The file may not be changed. .TP 15 SF_APPEND The file may only be appended to. .PP The .B UF_IMMUTABLE and .B UF_APPEND flags may be set or unset by either the owner of a file or the super-user. .PP The .B SF_IMMUTABLE and .B SF_APPEND flags may only be set or unset by the super-user. They may be set at any time, but normally may only be unset when the system is in single-user mode. (See .I init(8) for details.) .SH RETURN VALUES Upon successful completion, a value of 0 is returned. Otherwise, -1 is returned and the global variable .B errno is set to indicate the error. .SH ERRORS Chflags will fail if: .TP 15 ENOTDIR A component of the path prefix is not a directory. .TP 15 EINVAL The pathname contains a character with the high-order bit set. .TP 15 ENAMETOOLONG A component of a pathname exceeded 63 characters, or an entire path name exceeded 255 characters. .TP 15 ENOENT The named file does not exist. .TP 15 EACCES Search permission is denied for a component of the path prefix. .TP 15 ELOOP Too many symbolic links were encountered in translating the pathname. .TP 15 EPERM The effective user ID does not match the owner of the file and the effective user ID is not the super-user. .TP 15 EROFS The named file resides on a read-only file system. .TP 15 EFAULT .B path points outside the process's allocated address space. .TP 15 EIO An I/O error occurred while reading from or writing to the file system. .PP fchflags will fail if: .TP 15 EBADF The descriptor is not valid. .TP 15 EINVAL .B fd refers to a socket, not to a file. .TP 15 EPERM The effective user ID does not match the owner of the file and the effective user ID is not the super-user. .TP 15 EROFS The file resides on a read-only file system. .TP 15 EIO An I/O error occurred while reading from or writing to the file system. .SH SEE ALSO chflags(1), init(8) .SH HISTORY The .B chflags and .B fchflags functions first appeared in 4.4BSD. ================================================ FILE: share/man/man2/chmod.2 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)chmod.2 6.5 (Berkeley) 5/13/86 .\" .TH CHMOD 2 "May 13, 1986" .UC 4 .SH NAME chmod \- change mode of file .SH SYNOPSIS .nf .ft B chmod(path, mode) char *path; int mode; .PP .ft B fchmod(fd, mode) int fd, mode; .fi .SH DESCRIPTION The file whose name is given by \fIpath\fP or referenced by the descriptor .I fd has its mode changed to .IR mode . Modes are constructed by .IR or 'ing together some combination of the following, defined in .IR : .PP .RS .nf .ta \w'IWRITE\ \ 'u +\w'04000\ \ \ 'u ISUID 04000 set user ID on execution ISGID 02000 set group ID on execution ISVTX 01000 `sticky bit' (see below) IREAD 00400 read by owner IWRITE 00200 write by owner IEXEC 00100 execute (search on directory) by owner 00070 read, write, execute (search) by group 00007 read, write, execute (search) by others .fi .RE .PP If an executable file is set up for sharing (this is the default) then mode ISVTX (the `sticky bit') prevents the system from abandoning the swap-space image of the program-text portion of the file when its last user terminates. Ability to set this bit on executable files is restricted to the super-user. .PP If mode ISVTX (the `sticky bit') is set on a directory, an unprivileged user may not delete or rename files of other users in that directory. For more details of the properties of the sticky bit, see .IR sticky (8). .PP Only the owner of a file (or the super-user) may change the mode. .PP Writing or changing the owner of a file turns off the set-user-id and set-group-id bits unless the user is the super-user. This makes the system somewhat more secure by protecting set-user-id (set-group-id) files from remaining set-user-id (set-group-id) if they are modified, at the expense of a degree of compatibility. .SH "RETURN VALUE Upon successful completion, a value of 0 is returned. Otherwise, a value of \-1 is returned and .I errno is set to indicate the error. .SH "ERRORS .I Chmod will fail and the file mode will be unchanged if: .TP 15 [ENOTDIR] A component of the path prefix is not a directory. .TP 15 [EINVAL] The pathname contains a character with the high-order bit set. .TP 15 [ENAMETOOLONG] A component of a pathname exceeded 255 characters, or an entire path name exceeded 1023 characters. .TP 15 [ENOENT] The named file does not exist. .TP 15 [EACCES] Search permission is denied for a component of the path prefix. .TP 15 [ELOOP] Too many symbolic links were encountered in translating the pathname. .TP 15 [EPERM] The effective user ID does not match the owner of the file and the effective user ID is not the super-user. .TP 15 [EROFS] The named file resides on a read-only file system. .TP 15 [EFAULT] .I Path points outside the process's allocated address space. .TP 15 [EIO] An I/O error occurred while reading from or writing to the file system. .PP .I Fchmod will fail if: .TP 15 [EBADF] The descriptor is not valid. .TP 15 [EINVAL] .I Fd refers to a socket, not to a file. .TP 15 [EROFS] The file resides on a read-only file system. .TP 15 [EIO] An I/O error occurred while reading from or writing to the file system. .SH "SEE ALSO" chmod(1), open(2), chown(2), stat(2), sticky(8) ================================================ FILE: share/man/man2/chown.2 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)chown.2 6.6 (Berkeley) 5/22/86 .\" .TH CHOWN 2 "May 22, 1986" .UC 4 .SH NAME chown \- change owner and group of a file .SH SYNOPSIS .nf .ft B chown(path, owner, group) char *path; int owner, group; .PP .ft B fchown(fd, owner, group) int fd, owner, group; .fi .SH DESCRIPTION The file that is named by \fIpath\fP or referenced by \fIfd\fP has its .I owner and .I group changed as specified. Only the super-user may change the owner of the file, because if users were able to give files away, they could defeat the file-space accounting procedures. The owner of the file may change the group to a group of which he is a member. .PP On some systems, .I chown clears the set-user-id and set-group-id bits on the file to prevent accidental creation of set-user-id and set-group-id programs. .PP .I Fchown is particularly useful when used in conjunction with the file locking primitives (see .IR flock (2)). .PP One of the owner or group id's may be left unchanged by specifying it as \-1. .PP If the final component of .I path is a symbolic link, the ownership and group of the symbolic link is changed, not the ownership and group of the file or directory to which it points. .SH "RETURN VALUE Zero is returned if the operation was successful; \-1 is returned if an error occurs, with a more specific error code being placed in the global variable \fIerrno\fP. .SH "ERRORS .I Chown will fail and the file will be unchanged if: .TP 15 [ENOTDIR] A component of the path prefix is not a directory. .TP 15 [EINVAL] The pathname contains a character with the high-order bit set. .TP 15 [ENAMETOOLONG] A component of a pathname exceeded 255 characters, or an entire path name exceeded 1023 characters. .TP 15 [ENOENT] The named file does not exist. .TP 15 [EACCES] Search permission is denied for a component of the path prefix. .TP 15 [ELOOP] Too many symbolic links were encountered in translating the pathname. .TP 15 [EPERM] The effective user ID is not the super-user. .TP 15 [EROFS] The named file resides on a read-only file system. .TP 15 [EFAULT] .I Path points outside the process's allocated address space. .TP 15 [EIO] An I/O error occurred while reading from or writing to the file system. .PP .I Fchown will fail if: .TP 15 [EBADF] .I Fd does not refer to a valid descriptor. .TP 15 [EINVAL] .I Fd refers to a socket, not a file. .TP 15 [EPERM] The effective user ID is not the super-user. .TP 15 [EROFS] The named file resides on a read-only file system. .TP 15 [EIO] An I/O error occurred while reading from or writing to the file system. .SH "SEE ALSO" chown(8), chgrp(1), chmod(2), flock(2) ================================================ FILE: share/man/man2/chroot.2 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)chroot.2 6.3 (Berkeley) 8/26/85 .\" .TH CHROOT 2 "August 26, 1985" .UC 5 .SH NAME chroot \- change root directory .SH SYNOPSIS .nf .ft B chroot(dirname) char *dirname; .ft R .fi .SH DESCRIPTION .I Dirname is the address of the pathname of a directory, terminated by a null byte. .I Chroot causes this directory to become the root directory, the starting point for path names beginning with ``/''. .PP In order for a directory to become the root directory a process must have execute (search) access to the directory. .PP This call is restricted to the super-user. .SH "RETURN VALUE Upon successful completion, a value of 0 is returned. Otherwise, a value of \-1 is returned and \fIerrno\fP is set to indicate an error. .SH ERRORS .I Chroot will fail and the root directory will be unchanged if one or more of the following are true: .TP 15 [ENOTDIR] A component of the path name is not a directory. .TP 15 [EINVAL] The pathname contains a character with the high-order bit set. .TP 15 [ENAMETOOLONG] A component of a pathname exceeded 255 characters, or an entire path name exceeded 1023 characters. .TP 15 [ENOENT] The named directory does not exist. .TP 15 [EACCES] Search permission is denied for any component of the path name. .TP 15 [ELOOP] Too many symbolic links were encountered in translating the pathname. .TP 15 [EFAULT] .I Path points outside the process's allocated address space. .TP 15 [EIO] An I/O error occurred while reading from or writing to the file system. .SH "SEE ALSO" chdir(2) ================================================ FILE: share/man/man2/close.2 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)close.2 6.3 (Berkeley) 5/22/86 .\" .TH CLOSE 2 "May 22, 1986" .UC 4 .SH NAME close \- delete a descriptor .SH SYNOPSIS .B close(d) .br .B "int d;" .SH DESCRIPTION The \fIclose\fP call deletes a descriptor from the per-process object reference table. If this is the last reference to the underlying object, then it will be deactivated. For example, on the last close of a file the current \fIseek\fP pointer associated with the file is lost; on the last close of a .IR socket (2) associated naming information and queued data are discarded; on the last close of a file holding an advisory lock the lock is released (see further .IR flock (2)\fR). .PP A close of all of a process's descriptors is automatic on .IR exit , but since there is a limit on the number of active descriptors per process, .I close is necessary for programs that deal with many descriptors. .PP When a process forks (see .IR fork (2)), all descriptors for the new child process reference the same objects as they did in the parent before the fork. If a new process is then to be run using .IR execve (2), the process would normally inherit these descriptors. Most of the descriptors can be rearranged with .IR dup2 (2) or deleted with .I close before the .I execve is attempted, but if some of these descriptors will still be needed if the execve fails, it is necessary to arrange for them to be closed if the execve succeeds. For this reason, the call ``fcntl(d, F_SETFD, 1)'' is provided, which arranges that a descriptor will be closed after a successful execve; the call ``fcntl(d, F_SETFD, 0)'' restores the default, which is to not close the descriptor. .SH "RETURN VALUE Upon successful completion, a value of 0 is returned. Otherwise, a value of \-1 is returned and the global integer variable .I errno is set to indicate the error. .SH ERRORS .I Close will fail if: .TP 15 [EBADF] \fID\fP is not an active descriptor. .SH "SEE ALSO" accept(2), flock(2), open(2), pipe(2), socket(2), socketpair(2), execve(2), fcntl(2) ================================================ FILE: share/man/man2/connect.2 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)connect.2 6.6 (Berkeley) 5/22/86 .\" .TH CONNECT 2 "May 22, 1986" .UC 5 .SH NAME connect \- initiate a connection on a socket .SH SYNOPSIS .nf .ft B #include #include .PP .ft B connect(s, name, namelen) int s; struct sockaddr *name; int namelen; .fi .SH DESCRIPTION The parameter .I s is a socket. If it is of type SOCK_DGRAM, then this call specifies the peer with which the socket is to be associated; this address is that to which datagrams are to be sent, and the only address from which datagrams are to be received. If the socket is of type SOCK_STREAM, then this call attempts to make a connection to another socket. The other socket is specified by .I name, which is an address in the communications space of the socket. Each communications space interprets the .I name parameter in its own way. Generally, stream sockets may successfully .I connect only once; datagram sockets may use .I connect multiple times to change their association. Datagram sockets may dissolve the association by connecting to an invalid address, such as a null address. .SH "RETURN VALUE If the connection or binding succeeds, then 0 is returned. Otherwise a \-1 is returned, and a more specific error code is stored in \fIerrno\fP. .SH "ERRORS The call fails if: .TP 20 [EBADF] .I S is not a valid descriptor. .TP 20 [ENOTSOCK] .I S is a descriptor for a file, not a socket. .TP 20 [EADDRNOTAVAIL] The specified address is not available on this machine. .TP 20 [EAFNOSUPPORT] Addresses in the specified address family cannot be used with this socket. .TP 20 [EISCONN] The socket is already connected. .TP 20 [ETIMEDOUT] Connection establishment timed out without establishing a connection. .TP 20 [ECONNREFUSED] The attempt to connect was forcefully rejected. .TP 20 [ENETUNREACH] The network isn't reachable from this host. .TP 20 [EADDRINUSE] The address is already in use. .TP 20 [EFAULT] The \fIname\fP parameter specifies an area outside the process address space. .TP 20 [EINPROGRESS] The socket is non-blocking and the connection cannot be completed immediately. It is possible to .IR select (2) for completion by selecting the socket for writing. .TP 20 [EALREADY] The socket is non-blocking and a previous connection attempt has not yet been completed. .PP The following errors are specific to connecting names in the UNIX domain. These errors may not apply in future versions of the UNIX IPC domain. .TP 15 [ENOTDIR] A component of the path prefix is not a directory. .TP 15 [EINVAL] The pathname contains a character with the high-order bit set. .TP 15 [ENAMETOOLONG] A component of a pathname exceeded 255 characters, or an entire path name exceeded 1023 characters. .TP 15 [ENOENT] The named socket does not exist. .TP 15 [EACCES] Search permission is denied for a component of the path prefix. .TP 15 [EACCES] Write access to the named socket is denied. .TP 15 [ELOOP] Too many symbolic links were encountered in translating the pathname. .SH SEE ALSO accept(2), select(2), socket(2), getsockname(2) ================================================ FILE: share/man/man2/creat.2 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)creat.2 6.6 (Berkeley) 5/22/86 .\" .TH CREAT 2 "May 22, 1986" .UC 4 .SH NAME creat \- create a new file .SH SYNOPSIS .nf .B creat(name, mode) .B char *name; .fi .SH DESCRIPTION .B "This interface is made obsolete by open(2). .PP .I Creat creates a new file or prepares to rewrite an existing file called .IR name , given as the address of a null-terminated string. If the file did not exist, it is given mode .IR mode , as modified by the process's mode mask (see .IR umask (2)). Also see .IR chmod (2) for the construction of the .I mode argument. .PP If the file did exist, its mode and owner remain unchanged but it is truncated to 0 length. .PP The file is also opened for writing, and its file descriptor is returned. .SH NOTES The .I mode given is arbitrary; it need not allow writing. This feature has been used in the past by programs to construct a simple, exclusive locking mechanism. It is replaced by the O_EXCL open mode, or .IR flock (2) facility. .SH "RETURN VALUE The value \-1 is returned if an error occurs. Otherwise, the call returns a non-negative descriptor that only permits writing. .SH ERRORS .I Creat will fail and the file will not be created or truncated if one of the following occur: .TP 15 [ENOTDIR] A component of the path prefix is not a directory. .TP 15 [EINVAL] The pathname contains a character with the high-order bit set. .TP 15 [ENAMETOOLONG] A component of a pathname exceeded 255 characters, or an entire path name exceeded 1023 characters. .TP 15 [ENOENT] The named file does not exist. .TP 15 [ELOOP] Too many symbolic links were encountered in translating the pathname. .TP 15 [EACCES] Search permission is denied for a component of the path prefix. .TP 15 [EACCES] The file does not exist and the directory in which it is to be created is not writable. .TP 15 [EACCES] The file exists, but it is unwritable. .TP 15 [EISDIR] The file is a directory. .TP 15 [EMFILE] There are already too many files open. .TP 15 [ENFILE] The system file table is full. .TP 15 [ENOSPC] The directory in which the entry for the new file is being placed cannot be extended because there is no space left on the file system containing the directory. .TP 15 [ENOSPC] There are no free inodes on the file system on which the file is being created. .TP 15 [EDQUOT] The directory in which the entry for the new file is being placed cannot be extended because the user's quota of disk blocks on the file system containing the directory has been exhausted. .TP 15 [EDQUOT] The user's quota of inodes on the file system on which the file is being created has been exhausted. .TP 15 [EROFS] The named file resides on a read-only file system. .TP 15 [ENXIO] The file is a character special or block special file, and the associated device does not exist. .TP 15 [ETXTBSY] The file is a pure procedure (shared text) file that is being executed. .TP 15 [EIO] An I/O error occurred while making the directory entry or allocating the inode. .TP 15 [EFAULT] .I Name points outside the process's allocated address space. .TP 15 [EOPNOTSUPP] The file was a socket (not currently implemented). .SH "SEE ALSO" open(2), write(2), close(2), chmod(2), umask(2) ================================================ FILE: share/man/man2/dup.2 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)dup.2 6.3 (Berkeley) 5/13/86 .\" .TH DUP 2 "May 13, 1986" .UC 4 .SH NAME dup, dup2 \- duplicate a descriptor .SH SYNOPSIS .nf .ft B newd = dup(oldd) int newd, oldd; .PP .ft B dup2(oldd, newd) int oldd, newd; .fi .SH DESCRIPTION .I Dup duplicates an existing object descriptor. The argument \fIoldd\fP is a small non-negative integer index in the per-process descriptor table. The value must be less than the size of the table, which is returned by .IR getdtablesize (2). The new descriptor returned by the call, .I newd, is the lowest numbered descriptor that is not currently in use by the process. .PP The object referenced by the descriptor does not distinguish between references using \fIoldd\fP and \fInewd\fP in any way. Thus if \fInewd\fP and \fIoldd\fP are duplicate references to an open file, .IR read (2), .IR write (2) and .IR lseek (2) calls all move a single pointer into the file, and append mode, non-blocking I/O and asynchronous I/O options are shared between the references. If a separate pointer into the file is desired, a different object reference to the file must be obtained by issuing an additional .IR open (2) call. The close-on-exec flag on the new file descriptor is unset. .PP In the second form of the call, the value of .IR newd desired is specified. If this descriptor is already in use, the descriptor is first deallocated as if a .IR close (2) call had been done first. .SH "RETURN VALUE The value \-1 is returned if an error occurs in either call. The external variable .I errno indicates the cause of the error. .SH "ERRORS .I Dup and .I dup2 fail if: .TP 15 [EBADF] \fIOldd\fP or \fInewd\fP is not a valid active descriptor .TP 15 [EMFILE] Too many descriptors are active. .SH "SEE ALSO" accept(2), open(2), close(2), fcntl(2), pipe(2), socket(2), socketpair(2), getdtablesize(2) ================================================ FILE: share/man/man2/execve.2 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)execve.2 6.7 (Berkeley) 5/22/86 .\" .TH EXECVE 2 "May 22, 1986" .UC 4 .SH NAME execve \- execute a file .SH SYNOPSIS .ft B execve(name, argv, envp) .br char *name, *argv[], *envp[]; .fi .SH DESCRIPTION .I Execve transforms the calling process into a new process. The new process is constructed from an ordinary file called the \fInew process file\fP. This file is either an executable object file, or a file of data for an interpreter. An executable object file consists of an identifying header, followed by pages of data representing the initial program (text) and initialized data pages. Additional pages may be specified by the header to be initialized with zero data. See .IR a.out (5). .PP An interpreter file begins with a line of the form ``#! \fIinterpreter\fP''. When an interpreter file is .IR execve\| 'd, the system \fIexecve\fP\|'s the specified \fIinterpreter\fP, giving it the name of the originally exec'd file as an argument and shifting over the rest of the original arguments. .PP There can be no return from a successful \fIexecve\fP because the calling core image is lost. This is the mechanism whereby different process images become active. .PP The argument \fIargv\fP is a null-terminated array of character pointers to null-terminated character strings. These strings constitute the argument list to be made available to the new process. By convention, at least one argument must be present in this array, and the first element of this array should be the name of the executed program (i.e., the last component of \fIname\fP). .PP The argument \fIenvp\fP is also a null-terminated array of character pointers to null-terminated strings. These strings pass information to the new process that is not directly an argument to the command (see .IR environ (7)). .PP Descriptors open in the calling process remain open in the new process, except for those for which the close-on-exec flag is set (see .IR close (2)). Descriptors that remain open are unaffected by .IR execve . .PP Ignored signals remain ignored across an .IR execve , but signals that are caught are reset to their default values. Blocked signals remain blocked regardless of changes to the signal action. The signal stack is reset to be undefined (see .IR sigvec (2) for more information). .PP Each process has .I real user and group IDs and an .I effective user and group IDs. The .I real ID identifies the person using the system; the .I effective ID determines his access privileges. .I Execve changes the effective user and group ID to the owner of the executed file if the file has the \*(lqset-user-ID\*(rq or \*(lqset-group-ID\*(rq modes. The .I real user ID is not affected. .PP The new process also inherits the following attributes from the calling process: .PP .in +5n .nf .ta +2i process ID see \fIgetpid\fP\|(2) parent process ID see \fIgetppid\fP\|(2) process group ID see \fIgetpgrp\fP\|(2) access groups see \fIgetgroups\fP\|(2) working directory see \fIchdir\fP\|(2) root directory see \fIchroot\fP\|(2) control terminal see \fItty\fP\|(4) resource usages see \fIgetrusage\fP\|(2) interval timers see \fIgetitimer\fP\|(2) resource limits see \fIgetrlimit\fP\|(2) file mode mask see \fIumask\fP\|(2) signal mask see \fIsigvec\fP\|(2), \fIsigmask\fP\|(2) .in -5n .fi .PP When the executed program begins, it is called as follows: .PP .DT .nf main(argc, argv, envp) int argc; char **argv, **envp; .fi .PP where .I argc is the number of elements in \fIargv\fP (the ``arg count'') and .I argv is the array of character pointers to the arguments themselves. .PP .I Envp is a pointer to an array of strings that constitute the .I environment of the process. A pointer to this array is also stored in the global variable ``environ''. Each string consists of a name, an \*(lq=\*(rq, and a null-terminated value. The array of pointers is terminated by a null pointer. The shell .IR sh (1) passes an environment entry for each global shell variable defined when the program is called. See .IR environ (7) for some conventionally used names. .SH "RETURN VALUE If .I execve returns to the calling process an error has occurred; the return value will be \-1 and the global variable .I errno will contain an error code. .SH ERRORS .I Execve will fail and return to the calling process if one or more of the following are true: .TP 15 [ENOTDIR] A component of the path prefix is not a directory. .TP 15 [EINVAL] The pathname contains a character with the high-order bit set. .TP 15 [ENAMETOOLONG] A component of a pathname exceeded 255 characters, or an entire path name exceeded 1023 characters. .TP 15 [ENOENT] The new process file does not exist. .TP 15 [ELOOP] Too many symbolic links were encountered in translating the pathname. .TP 15 [EACCES] Search permission is denied for a component of the path prefix. .TP 15 [EACCES] The new process file is not an ordinary file. .TP 15 [EACCES] The new process file mode denies execute permission. .TP 15 [ENOEXEC] The new process file has the appropriate access permission, but has an invalid magic number in its header. .TP 15 [ETXTBSY] The new process file is a pure procedure (shared text) file that is currently open for writing or reading by some process. .TP 15 [ENOMEM] The new process requires more virtual memory than is allowed by the imposed maximum .RI ( getrlimit (2)). .TP 15 [E2BIG] The number of bytes in the new process's argument list is larger than the system-imposed limit. The limit in the system as released is 20480 bytes (NCARGS in .IR . .TP 15 [EFAULT] The new process file is not as long as indicated by the size values in its header. .TP 15 [EFAULT] \fIPath\fP\|, \fIargv\fP\|, or \fIenvp\fP point to an illegal address. .TP 15 [EIO] An I/O error occurred while reading from the file system. .SH CAVEATS If a program is .I setuid to a non-super-user, but is executed when the real \fIuid\fP is ``root'', then the program has some of the powers of a super-user as well. .SH "SEE ALSO" exit(2), fork(2), execl(3), environ(7) ================================================ FILE: share/man/man2/exit.2 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)exit.2 6.4 (Berkeley) 5/22/86 .\" .TH EXIT 2 "May 22, 1986" .UC 4 .SH NAME _exit \- terminate a process .SH SYNOPSIS .nf .ft B _exit(status) int status; .fi .SH DESCRIPTION .I _exit terminates a process with the following consequences: .in +5n .PP All of the descriptors open in the calling process are closed. This may entail delays, for example, waiting for output to drain; a process in this state may not be killed, as it is already dying. .PP If the parent process of the calling process is executing a .I wait or is interested in the SIGCHLD signal, then it is notified of the calling process's termination and the low-order eight bits of \fIstatus\fP are made available to it; see .IR wait (2). .PP The parent process ID of all of the calling process's existing child processes are also set to 1. This means that the initialization process (see .IR intro (2)) inherits each of these processes as well. Any stopped children are restarted with a hangup signal (SIGHUP). .in -5n .PP Most C programs call the library routine .IR exit (3), which performs cleanup actions in the standard I/O library before calling \fI_exit\fP\|. .SH "RETURN VALUE" This call never returns. .SH "SEE ALSO" fork(2), sigvec(2), wait(2), exit(3) ================================================ FILE: share/man/man2/fcntl.2 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)fcntl.2 6.4.1 (2.11BSD GTE) 11/30/94 .\" .TH FCNTL 2 "Nov 30, 1994" .UC 5 .SH NAME fcntl \- file control .SH SYNOPSIS .nf .ft B #include .PP .ft B res = fcntl(fd, cmd, arg) int res; int fd, cmd, arg; .ft R .SH DESCRIPTION .I Fcntl provides for control over descriptors. The argument .I fd is a descriptor to be operated on by .I cmd as follows: .TP 15 F_DUPFD Return a new descriptor as follows: .IP Lowest numbered available descriptor greater than or equal to .I arg. .IP Same object references as the original descriptor. .IP New descriptor shares the same file pointer if the object was a file. .IP Same access mode (read, write or read/write). .IP Same file status flags (i.e., both file descriptors share the same file status flags). .IP The close-on-exec flag associated with the new file descriptor is set to remain open across .IR execv (2) system calls. .TP 15 F_GETFD Get the close-on-exec flag associated with the file descriptor .IR fd . If the low-order bit is 0, the file will remain open across .IR exec , otherwise the file will be closed upon execution of .I exec. .TP 15 F_SETFD Set the close-on-exec flag associated with .I fd to the low order bit of .I arg (0 or 1 as above). .TP 15 F_GETFL Get descriptor status flags, as described below. .TP 15 F_SETFL Set descriptor status flags. .TP 15 F_GETOWN Get the process ID or process group currently receiving SIGIO and SIGURG signals; process groups are returned as negative values. .TP F_SETOWN Set the process or process group to receive SIGIO and SIGURG signals; process groups are specified by supplying .I arg as negative, otherwise .I arg is interpreted as a process ID. .LP The flags for the F_GETFL and F_SETFL flags are as follows: .TP 15 O_NONBLOCK Non-blocking I/O; if no data is available to a .I read call, or if a write operation would block, the call returns -1 with the error EWOULDBLOCK. .TP O_APPEND Force each write to append at the end of file; corresponds to the O_APPEND flag of .IR open (2). .TP O_ASYNC Enable the SIGIO signal to be sent to the process group when I/O is possible, e.g., upon availability of data to be read. .SH "RETURN VALUE Upon successful completion, the value returned depends on .I cmd as follows: .sp .5v .nf .ta .25i 1.25i F_DUPFD A new file descriptor. F_GETFD Value of flag (only the low-order bit is defined). F_GETFL Value of flags. F_GETOWN Value of file descriptor owner. other Value other than \-1. .fi .sp .5v Otherwise, a value of \-1 is returned and .I errno is set to indicate the error. .SH ERRORS .I Fcntl will fail if one or more of the following are true: .TP 15 [EBADF] .I Fildes is not a valid open file descriptor. .TP 15 [EMFILE] .I Cmd is F_DUPFD and the maximum allowed number of file descriptors are currently open. .TP 15 [EINVAL] .I Cmd is F_DUPFD and .I arg is negative or greater than the maximum allowable number (see .IR getdtablesize (2)). .TP 15 [ESRCH] .I Cmd is F_SETOWN and the process ID given as argument is not in use. .SH "SEE ALSO close(2), execve(2), getdtablesize(2), open(2), sigvec(2) .SH BUGS The asynchronous I/O facilities of O_NONBLOCK and O_ASYNC are currently available only for tty and socket operations. ================================================ FILE: share/man/man2/fetchi.2 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)fetchi.2 2.3 (Berkeley) 1/22/87 .\" .TH FETCHI 2 "January 22, 1987" .UC 2 .SH NAME fetchi \- fetch from user instruction space (2BSD) .SH SYNOPSIS .nf .ft B fetchi(addr) int *addr; .fi .ft R .SH DESCRIPTION .I Fetchi fetches the word at .I addr from the caller's instruction space. This system call is required on PDP-11's with separate instruction and data spaces because the .I mfpi instruction reads from D-space if the current and previous modes in the program status word are both user. .SH "RETURN VALUE Upon successful completion the contents of the caller's instruction space at .I addr are returned. Otherwise, a value of \-1 is returned. .SH "ERRORS .TP 15 [EINVAL] The kernel has not been compiled for a processor with separate I/D. .TP 15 [EFAULT] .I Addr points to an address not in the process's allocated instruction space. .SH BUGS The error indication, \-1, is a legitimate function value; .I errno, (see .IR intro (2)), can be used to disambiguate. .PP .I Fetchi is a kludge and exists only to circumvent an alleged security feature on some DEC PDP-11 processors. .PP .I Fetchi is unique to the PDP-11 and 2BSD; its use is discouraged. ================================================ FILE: share/man/man2/flock.2 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)flock.2 6.4 (Berkeley) 5/22/86 .\" .TH FLOCK 2 "May 22, 1986" .UC 5 .SH NAME flock \- apply or remove an advisory lock on an open file .SH SYNOPSIS .nf .ft B #include .PP .ft B .DT #define LOCK_SH 1 /* shared lock */ #define LOCK_EX 2 /* exclusive lock */ #define LOCK_NB 4 /* don't block when locking */ #define LOCK_UN 8 /* unlock */ .PP .ft B flock(fd, operation) int fd, operation; .fi .SH DESCRIPTION .I Flock applies or removes an .I advisory lock on the file associated with the file descriptor .IR fd . A lock is applied by specifying an .I operation parameter that is the inclusive or of LOCK_SH or LOCK_EX and, possibly, LOCK_NB. To unlock an existing lock .I operation should be LOCK_UN. .PP Advisory locks allow cooperating processes to perform consistent operations on files, but do not guarantee consistency (i.e., processes may still access files without using advisory locks possibly resulting in inconsistencies). .PP The locking mechanism allows two types of locks: .I shared locks and .I exclusive locks. At any time multiple shared locks may be applied to a file, but at no time are multiple exclusive, or both shared and exclusive, locks allowed simultaneously on a file. .PP A shared lock may be .I upgraded to an exclusive lock, and vice versa, simply by specifying the appropriate lock type; this results in the previous lock being released and the new lock applied (possibly after other processes have gained and released the lock). .PP Requesting a lock on an object that is already locked normally causes the caller to be blocked until the lock may be acquired. If LOCK_NB is included in .IR operation , then this will not happen; instead the call will fail and the error EWOULDBLOCK will be returned. .SH NOTES Locks are on files, not file descriptors. That is, file descriptors duplicated through .IR dup (2) or .IR fork (2) do not result in multiple instances of a lock, but rather multiple references to a single lock. If a process holding a lock on a file forks and the child explicitly unlocks the file, the parent will lose its lock. .PP Processes blocked awaiting a lock may be awakened by signals. .SH "RETURN VALUE Zero is returned if the operation was successful; on an error a \-1 is returned and an error code is left in the global location \fIerrno\fP. .SH "ERRORS The \fIflock\fP call fails if: .TP 20 [EWOULDBLOCK] The file is locked and the LOCK_NB option was specified. .TP 20 [EBADF] The argument \fIfd\fP is an invalid descriptor. .TP 20 [EINVAL] The argument \fIfd\fP refers to an object other than a file. .SH "SEE ALSO" open(2), close(2), dup(2), execve(2), fork(2) ================================================ FILE: share/man/man2/fork.2 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)fork.2 6.4 (Berkeley) 5/22/86 .\" .TH FORK 2 "May 22, 1986" .UC .SH NAME fork \- create a new process .SH SYNOPSIS .ft B pid = fork() .br int pid; .ft R .SH DESCRIPTION .I Fork causes creation of a new process. The new process (child process) is an exact copy of the calling process except for the following: .in +5n .sp The child process has a unique process ID. .sp The child process has a different parent process ID (i.e., the process ID of the parent process). .sp The child process has its own copy of the parent's descriptors. These descriptors reference the same underlying objects, so that, for instance, file pointers in file objects are shared between the child and the parent, so that an .IR lseek (2) on a descriptor in the child process can affect a subsequent .I read or .I write by the parent. This descriptor copying is also used by the shell to establish standard input and output for newly created processes as well as to set up pipes. .sp The child processes resource utilizations are set to 0; see .IR setrlimit (2). .SH "RETURN VALUE Upon successful completion, \fIfork\fP returns a value of 0 to the child process and returns the process ID of the child process to the parent process. Otherwise, a value of \-1 is returned to the parent process, no child process is created, and the global variable \fIerrno\fP is set to indicate the error. .SH ERRORS .I Fork will fail and no child process will be created if one or more of the following are true: .TP 15 [EAGAIN] The system-imposed limit on the total number of processes under execution would be exceeded. This limit is configuration-dependent. .TP 15 [EAGAIN] The system-imposed limit MAXUPRC (\fI) \fRon the total number of processes under execution by a single user would be exceeded. .TP 15 [ENOMEM] There is insufficient swap space for the new process. .SH "SEE ALSO" execve(2), wait(2) ================================================ FILE: share/man/man2/fperr.2 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)fperr.2 2.3 (Berkeley) 1/22/87 .\" .TH FPERR 2 "January 22, 1987" .UC 2 .SH NAME fperr \- get floating-point error registers (2BSD) .SH SYNOPSIS .nf .ft B #include struct fperr { short f_fec; caddr_t f_fea; }; fperr(fpe) struct fperr *fpe; .fi .ft R .SH DESCRIPTION .I Fperr returns the contents of the floating-point processor's error registers as they were following the last floating exception generated by the calling process. The registers are stored in the structure pointed to by .IR fpe . .PP This call is required because the error registers in the PDP-11 floating-point processor are read-only. Thus, they may be changed by some other process between the time that the current process generates an exception and the time that it reads the registers. Therefore, the system saves their state at the time of an exception. .PP The values returned are valid only after a floating-point exception. .SH ERRORS .TP 15 [EINVAL] The kernel has not been compiled for a processor with floating point. .SH "SEE ALSO Ed Gould, Jim Reeds, Vance Vaughan, .I UNIX Problems with Floating Point Processors .SH BUGS .I Fperr is unique to the PDP-11 and 2BSD; its use is discouraged. ================================================ FILE: share/man/man2/fsync.2 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)fsync.2 6.4 (Berkeley) 5/22/86 .\" .TH FSYNC 2 "May 22, 1986" .UC 5 .SH NAME fsync \- synchronize a file's in-core state with that on disk .SH SYNOPSIS .ft B fsync(fd) .br int fd; .ft R .SH DESCRIPTION .I Fsync causes all modified data and attributes of \fIfd\fP to be moved to a permanent storage device. This normally results in all in-core modified copies of buffers for the associated file to be written to a disk. .PP .I Fsync should be used by programs that require a file to be in a known state, for example, in building a simple transaction facility. .SH "RETURN VALUE A 0 value is returned on success. A \-1 value indicates an error. .SH "ERRORS The \fIfsync\fP fails if: .TP 15 [EBADF] \fIFd\fP is not a valid descriptor. .TP 15 [EINVAL] \fIFd\fP refers to a socket, not to a file. .TP 15 [EIO] An I/O error occurred while reading from or writing to the file system. .SH "SEE ALSO" sync(2), sync(8), update(8) ================================================ FILE: share/man/man2/getdtablesize.2 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)getdtablesize.2 6.2 (Berkeley) 6/28/85 .\" .TH GETDTABLESIZE 2 "June 28, 1985" .UC 5 .SH NAME getdtablesize \- get descriptor table size .SH SYNOPSIS .nf .ft B nfds = getdtablesize() int nfds; .fi .SH DESCRIPTION Each process has a fixed size descriptor table, which is guaranteed to have at least 20 slots. The entries in the descriptor table are numbered with small integers starting at 0. The call .I getdtablesize returns the size of this table. .SH "SEE ALSO" close(2), dup(2), open(2), select(2) ================================================ FILE: share/man/man2/getfsstat.2 ================================================ .\" Copyright (c) 1989, 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. All advertising materials mentioning features or use of this software .\" must display the following acknowledgement: .\" This product includes software developed by the University of .\" California, Berkeley and its contributors. .\" 4. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)getfsstat.2 8.1.1 (2.11BSD) 1995/12/24 .\" .TH GETFSSTAT 2 "December 24, 1995" .UC 7 .SH NAME \fBgetfsstat\fP \- get list of all mounted filesystems .SH SYNOPSIS .B #include .br .B #include .sp .I int .br \fBgetfsstat\fP(buf,bufsize,flags) .br .I struct statfs *buf; .br .I int bufsize; .br .I int flags; .br .SH DESCRIPTION .BR Getfsstat () returns information about all mounted filesystems. .I Buf is a pointer to .I statfs structures defined as follows: .sp .nf .cs R 20 #define MNAMELEN 90 /* length of buffer for returned name */ struct statfs { short f_type; /* type of filesystem (see below) */ short f_flags; /* copy of mount flags */ short f_bsize; /* fundamental file system block size */ short f_iosize; /* optimal transfer block size */ long f_blocks; /* total data blocks in file system */ long f_bfree; /* free blocks in fs */ long f_bavail; /* free blocks avail to non-superuser */ ino_t f_files; /* total file nodes in file system */ ino_t f_ffree; /* free file nodes in fs */ u_long f_fsid[2]; /* file system id */ long f_spare[4]; /* spare for later */ char f_mntonname[MNAMELEN]; /* mount point */ char f_mntfromname[MNAMELEN]; /* mounted filesystem */ }; /* * File system types. - Only UFS is supported so the other types are not * given. */ #define MOUNT_NONE 0 #define MOUNT_UFS 1 /* Fast Filesystem */ .br .fi .cs R .PP Fields that are undefined for a particular filesystem are set to -1. The buffer is filled with an array of .I fsstat structures, one for each mounted filesystem up to the size specified by .IR bufsize . .PP If .I buf is given as NULL, .BR getfsstat () returns just the number of mounted filesystems. .PP Normally .I flags is currently unused. In 4.4BSD systems the usage is specified as MNT_WAIT. If .I flags is set to MNT_NOWAIT, .BR getfsstat () will return the information it has available without requesting an update from each filesystem. Thus, some of the information will be out of date, but .BR getfsstat () will not block waiting for information from a filesystem that is unable to respond. .SH RETURN VALUES Upon successful completion, the number of .I fsstat structures is returned. Otherwise, -1 is returned and the global variable .I errno is set to indicate the error. .SH ERRORS .BR Getfsstat () fails if one or more of the following are true: .sp .TP 20 [EFAULT] .I Buf points to an invalid address. .TP 20 [EIO] An I/O error occurred while reading from or writing to the filesystem. .SH SEE ALSO statfs(2), fstab(5), mount(8) .SH HISTORY The .B getfsstat function first appeared in 4.4BSD. ================================================ FILE: share/man/man2/getgid.2 ================================================ .\" Copyright (c) 1983, 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. All advertising materials mentioning features or use of this software .\" must display the following acknowledgement: .\" This product includes software developed by the University of .\" California, Berkeley and its contributors. .\" 4. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)getgid.2 8.1.1 (2.11BSD) 1997/12/2 .\" .TH GETGID 2 "December 2, 1997" .UC 5 .SH NAME \fBgetgid\fP, \fBgetegid\fP \- get group process identification .SH SYNOPSIS .B #include .sp .nf \fIgid_t\fP \fBgetgid\fP() .sp \fIgid_t\fP \fBgetegid\fP() .fi .SH DESCRIPTION The .B getgid function returns the real group ID of the calling process, .B getegid returns the effective group ID of the calling process. .PP The real group ID is specified at login time. .PP The real group ID is the group of the user who invoked the program. As the effective group ID gives the process additional permissions during the execution of ``\fIset-group-ID\fP'' mode processes, .B getgid is used to determine the real-user-id of the calling process. .SH ERRORS The .B getgid and .B getegid functions are always successful, and no return value is reserved to indicate an error. .SH SEE ALSO getuid(2), setregid(2), setgid(3) .SH STANDARDS .B Getgid and .B getegid conform to IEEE Std 1003.1-1988 (``POSIX''). ================================================ FILE: share/man/man2/getgroups.2 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)getgroups.2 6.3 (Berkeley) 5/13/86 .\" .TH GETGROUPS 2 "May 13, 1986" .UC 5 .SH NAME getgroups \- get group access list .SH SYNOPSIS .nf .ft B #include .PP .ft B ngroups = getgroups(gidsetlen, gidset) int ngroups, gidsetlen, *gidset; .fi .SH DESCRIPTION .I Getgroups gets the current group access list of the user process and stores it in the array .IR gidset . The parameter .I gidsetlen indicates the number of entries that may be placed in .IR gidset. .I Getgroups returns the actual number of groups returned in .IR gidset . No more than NGROUPS, as defined in .RI < sys/param.h >, will ever be returned. .SH "RETURN VALUE A successful call returns the number of groups in the group set. A value of \-1 indicates that an error occurred, and the error code is stored in the global variable \fIerrno\fP\|. .SH "ERRORS The possible errors for \fIgetgroup\fP are: .TP 15 [EINVAL] The argument .I gidsetlen is smaller than the number of groups in the group set. .TP [EFAULT] The argument \fIgidset\fP specifies an invalid address. .SH "SEE ALSO setgroups(2), initgroups(3X) .SH BUGS The .I gidset array should be of type .BR gid_t , but remains integer for compatibility with earlier systems. ================================================ FILE: share/man/man2/gethostid.2 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)gethostid.2 6.3 (Berkeley) 11/28/85 .\" .TH GETHOSTID 2 "November 28, 1985" .UC 5 .SH NAME gethostid, sethostid \- get/set unique identifier of current host .SH SYNOPSIS .nf .ft B hostid = gethostid() long hostid; .PP .ft B sethostid(hostid) long hostid; .fi .SH DESCRIPTION .I Sethostid establishes a 32-bit identifier for the current processor that is intended to be unique among all UNIX systems in existence. This is normally a DARPA Internet address for the local machine. This call is allowed only to the super-user and is normally performed at boot time. .PP .I Gethostid returns the 32-bit identifier for the current processor. .SH SEE ALSO hostid(1), gethostname(2) .SH BUGS 32 bits for the identifier is too small. ================================================ FILE: share/man/man2/gethostname.2 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)gethostname.2 6.4 (Berkeley) 5/22/86 .\" .TH GETHOSTNAME 2 "May 22, 1986" .UC 5 .SH NAME gethostname, sethostname \- get/set name of current host .SH SYNOPSIS .nf .ft B gethostname(name, namelen) char *name; int namelen; .PP .ft B sethostname(name, namelen) char *name; int namelen; .fi .SH DESCRIPTION .I Gethostname returns the standard host name for the current processor, as previously set by .IR sethostname . The parameter .I namelen specifies the size of the .I name array. The returned name is null-terminated unless insufficient space is provided. .PP .I Sethostname sets the name of the host machine to be .IR name , which has length .IR namelen . This call is restricted to the super-user and is normally used only when the system is bootstrapped. .SH "RETURN VALUE If the call succeeds a value of 0 is returned. If the call fails, then a value of \-1 is returned and an error code is placed in the global location \fIerrno\fP. .SH "ERRORS The following errors may be returned by these calls: .TP 15 [EFAULT] The \fIname\fP or \fInamelen\fP parameter gave an invalid address. .TP 15 [EPERM] The caller tried to set the hostname and was not the super-user. .SH SEE ALSO gethostid(2) .SH BUGS Host names are limited to MAXHOSTNAMELEN (from .IR ) characters, currently 64. ================================================ FILE: share/man/man2/getitimer.2 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)getitimer.2 6.2 (Berkeley) 8/26/85 .\" .TH GETITIMER 2 "August 26, 1985" .UC 5 .SH NAME getitimer, setitimer \- get/set value of interval timer .SH SYNOPSIS .nf .ft B #include .PP .ft B #define ITIMER_REAL 0 /* real time intervals */ #define ITIMER_VIRTUAL 1 /* virtual time intervals */ #define ITIMER_PROF 2 /* user and system virtual time */ .sp .ft B getitimer(which, value) int which; struct itimerval *value; .PP .ft B setitimer(which, value, ovalue) int which; struct itimerval *value, *ovalue; .fi .SH DESCRIPTION The system provides each process with three interval timers, defined in .RI < sys/time.h >. The .I getitimer call returns the current value for the timer specified in .I which in the structure at .IR value . The .I setitimer call sets a timer to the specified .I value (returning the previous value of the timer if .I ovalue is nonzero). .PP A timer value is defined by the .I itimerval structure: .PP .nf .RS .DT struct itimerval { struct timeval it_interval; /* timer interval */ struct timeval it_value; /* current value */ }; .RE .fi .PP If .I it_value is non-zero, it indicates the time to the next timer expiration. If .I it_interval is non-zero, it specifies a value to be used in reloading .I it_value when the timer expires. Setting .I it_value to 0 disables a timer. Setting .I it_interval to 0 causes a timer to be disabled after its next expiration (assuming .I it_value is non-zero). .PP Time values smaller than the resolution of the system clock are rounded up to this resolution (on the VAX, 10 milliseconds). .PP The ITIMER_REAL timer decrements in real time. A SIGALRM signal is delivered when this timer expires. .PP The ITIMER_VIRTUAL timer decrements in process virtual time. It runs only when the process is executing. A SIGVTALRM signal is delivered when it expires. .PP The ITIMER_PROF timer decrements both in process virtual time and when the system is running on behalf of the process. It is designed to be used by interpreters in statistically profiling the execution of interpreted programs. Each time the ITIMER_PROF timer expires, the SIGPROF signal is delivered. Because this signal may interrupt in-progress system calls, programs using this timer must be prepared to restart interrupted system calls. .SH NOTES Three macros for manipulating time values are defined in .RI < sys/time.h >. .I Timerclear sets a time value to zero, .I timerisset tests if a time value is non-zero, and .I timercmp compares two time values (beware that >= and <= do not work with this macro). .SH "NOTES (PDP-11)" On the PDP-11, .I setitimer rounds timer values up to seconds resolution. (This saves some space and computation in the overburdened PDP-11 kernel.) .SH "RETURN VALUE If the calls succeed, a value of 0 is returned. If an error occurs, the value \-1 is returned, and a more precise error code is placed in the global variable \fIerrno\fP. .SH "ERRORS The possible errors are: .TP 15 [EFAULT] The \fIvalue\fP parameter specified a bad address. .TP 15 [EINVAL] A \fIvalue\fP parameter specified a time was too large to be handled. .SH "SEE ALSO" sigvec(2), gettimeofday(2) ================================================ FILE: share/man/man2/getlogin.2 ================================================ .\" Copyright (c) 1989, 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. All advertising materials mentioning features or use of this software .\" must display the following acknowledgement: .\" This product includes software developed by the University of .\" California, Berkeley and its contributors. .\" 4. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)getlogin.2 8.1.1 (2.11BSD) 1997/9/23 .\" .TH GETLOGIN 2 "September 23, 1997" .UC 5 .SH NAME \fBgetlogin\fP, \fBsetlogin\fP \- get/set login name .SH SYNOPSIS .B #include .sp .nf char * getlogin() .sp int setlogin(name) char *name; .fi .SH DESCRIPTION The .B getlogin routine returns the login name of the user associated with the current session, as previously set by .BR setlogin . The name is normally associated with a login shell at the time a session is created, and is inherited by all processes descended from the login shell. (This is true even if some of those processes assume another user ID, for example when \fBsu\fP(1) is used.) .PP .B Setlogin sets the login name of the user associated with the current session to .IR name . This call is restricted to the super-user, and is normally used only when a new session is being created on behalf of the named user (for example, at login time, or when a remote shell is invoked). .SH RETURN VALUES If a call to .B getlogin succeeds, it returns a pointer to a null-terminated string in a static buffer. If the name has not been set, it returns .IR NULL . If a call to .B setlogin succeeds, a value of 0 is returned. If .B setlogin fails, a value of -1 is returned and an error code is placed in the global location .IR errno . .SH ERRORS The following errors may be returned by these calls: .TP 15 EFAULT The .I name parameter gave an invalid address. .TP 15 EINVAL The .I name parameter pointed to a string that was too long. Login names are limited to .I MAXLOGNAME (from \fI\\fP) characters, currently 16. .TP 15 EPERM The caller tried to set the login name and was not the super-user. .SH SEE ALSO setsid(2) .SH BUGS Login names are limited in length by .BR setlogin . However, lower limits are placed on login names elsewhere in the system (UT_NAMESIZE in \fI\\fP). .PP In earlier versions of the system, .B getlogin failed unless the process was associated with a login terminal. The current implementation (using .BR setlogin ) allows getlogin to succeed even when the process has no controlling terminal. In earlier versions of the system, the value returned by .B getlogin could not be trusted without checking the user ID. Portable programs should probably still make this check. .SH HISTORY The .B setlogin function first appeared in 4.4BSD. The .B getlogin function was present in V7. ================================================ FILE: share/man/man2/getpagesize.2 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)getpagesize.2 6.1 (Berkeley) 5/15/85 .\" .TH GETPAGESIZE 2 "May 15, 1985" .UC 5 .SH NAME getpagesize \- get system page size .SH SYNOPSIS .nf .ft B pagesize = getpagesize() int pagesize; .ft R .fi .SH DESCRIPTION .I Getpagesize returns the number of bytes in a page. Page granularity is the granularity of many of the memory management calls. .PP The page size is a .I system page size and may not be the same as the underlying hardware page size. .SH SEE ALSO sbrk(2), pagesize(1) ================================================ FILE: share/man/man2/getpeername.2 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)getpeername.2 6.2 (Berkeley) 5/13/86 .\" .TH GETPEERNAME 2 "May 13, 1986" .UC 5 .SH NAME getpeername \- get name of connected peer .SH SYNOPSIS .nf .PP .ft B getpeername(s, name, namelen) int s; struct sockaddr *name; int *namelen; .fi .SH DESCRIPTION .I Getpeername returns the name of the peer connected to socket .IR s . The .I namelen parameter should be initialized to indicate the amount of space pointed to by .IR name . On return it contains the actual size of the name returned (in bytes). The name is truncated if the buffer provided is too small. .SH DIAGNOSTICS A 0 is returned if the call succeeds, \-1 if it fails. .SH ERRORS The call succeeds unless: .TP 15 [EBADF] The argument \fIs\fP is not a valid descriptor. .TP 15 [ENOTSOCK] The argument \fIs\fP is a file, not a socket. .TP 15 [ENOTCONN] The socket is not connected. .TP 15 [ENOBUFS] Insufficient resources were available in the system to perform the operation. .TP 15 [EFAULT] The .I name parameter points to memory not in a valid part of the process address space. .SH "SEE ALSO" accept(2), bind(2), socket(2), getsockname(2) ================================================ FILE: share/man/man2/getpgrp.2 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)getpgrp.2 6.3 (Berkeley) 8/26/85 .\" .TH GETPGRP 2 "August 26, 1985" .UC 5 .SH NAME getpgrp \- get process group .SH SYNOPSIS .ft B .nf pgrp = getpgrp(pid) int pgrp; int pid; .fi .ft R .SH DESCRIPTION The process group of the specified process is returned by .I getpgrp. If .I pid is zero, then the call applies to the current process. .PP Process groups are used for distribution of signals, and by terminals to arbitrate requests for their input: processes that have the same process group as the terminal are foreground and may read, while others will block with a signal if they attempt to read. .PP This call is thus used by programs such as .IR csh (1) to create process groups in implementing job control. The TIOCGPGRP and TIOCSPGRP calls described in .IR tty (4) are used to get/set the process group of the control terminal. .SH "SEE ALSO" setpgrp(2), getuid(2), tty(4) ================================================ FILE: share/man/man2/getpid.2 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)getpid.2 6.3 (Berkeley) 5/13/86 .\" .TH GETPID 2 "May 13, 1986" .UC 4 .SH NAME getpid, getppid \- get process identification .SH SYNOPSIS .ft B .nf pid = getpid() int pid; .sp ppid = getppid() int ppid; .fi .ft R .SH DESCRIPTION .I Getpid returns the process ID of the current process. Most often it is used to generate uniquely-named temporary files. .PP .I Getppid returns the process ID of the parent of the current process. .SH "SEE ALSO gethostid(2) ================================================ FILE: share/man/man2/getpriority.2 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)getpriority.2 6.5 (Berkeley) 5/22/86 .\" .TH GETPRIORITY 2 "May 22, 1986" .UC 4 .SH NAME getpriority, setpriority \- get/set program scheduling priority .SH SYNOPSIS .nf .ft B #include .PP .ft B prio = getpriority(which, who) int prio, which, who; .PP .ft B setpriority(which, who, prio) int which, who, prio; .fi .SH DESCRIPTION The scheduling priority of the process, process group, or user, as indicated by .I which and .I who is obtained with the .I getpriority call and set with the .I setpriority call. .I Which is one of PRIO_PROCESS, PRIO_PGRP, or PRIO_USER, and .I who is interpreted relative to .I which (a process identifier for PRIO_PROCESS, process group identifier for PRIO_PGRP, and a user ID for PRIO_USER). A zero value of .I who denotes the current process, process group, or user. .I Prio is a value in the range \-20 to 20. The default priority is 0; lower priorities cause more favorable scheduling. .PP The .I getpriority call returns the highest priority (lowest numerical value) enjoyed by any of the specified processes. The .I setpriority call sets the priorities of all of the specified processes to the specified value. Only the super-user may lower priorities. .SH "RETURN VALUE Since .I getpriority can legitimately return the value \-1, it is necessary to clear the external variable \fIerrno\fP prior to the call, then check it afterward to determine if a \-1 is an error or a legitimate value. The .I setpriority call returns 0 if there is no error, or \-1 if there is. .SH ERRORS .I Getpriority and .I setpriority may return one of the following errors: .TP 15 [ESRCH] No process was located using the .I which and .I who values specified. .TP 15 [EINVAL] .I Which was not one of PRIO_PROCESS, PRIO_PGRP, or PRIO_USER. .PP In addition to the errors indicated above, .I setpriority may fail with one of the following errors returned: .TP 15 [EPERM] A process was located, but neither its effective nor real user ID matched the effective user ID of the caller. .TP 15 [EACCES] A non super-user attempted to lower a process priority. .SH "SEE ALSO" nice(1), fork(2), renice(8) ================================================ FILE: share/man/man2/getrlimit.2 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)getrlimit.2 6.3 (Berkeley) 5/13/86 .\" .TH GETRLIMIT 2 "May 13, 1986" .UC 4 .SH NAME getrlimit, setrlimit \- control maximum system resource consumption .SH SYNOPSIS .ft B .nf #include #include .PP .ft B getrlimit(resource, rlp) int resource; struct rlimit *rlp; .PP .ft B setrlimit(resource, rlp) int resource; struct rlimit *rlp; .fi .ft R .SH DESCRIPTION Limits on the consumption of system resources by the current process and each process it creates may be obtained with the .I getrlimit call, and set with the .I setrlimit call. .PP The .I resource parameter is one of the following: .TP 17 RLIMIT_CPU the maximum amount of cpu time (in seconds) to be used by each process. .TP 17 RLIMIT_FSIZE the largest size, in bytes, of any single file that may be created. .TP 17 RLIMIT_DATA the maximum size, in bytes, of the data segment for a process; this defines how far a program may extend its break with the .IR sbrk (2) system call. .TP 17 RLIMIT_STACK the maximum size, in bytes, of the stack segment for a process; this defines how far a program's stack segment may be extended. Stack extension is performed automatically by the system. .TP 17 RLIMIT_CORE the largest size, in bytes, of a .I core file that may be created. .TP 17 RLIMIT_RSS the maximum size, in bytes, to which a process's resident set size may grow. This imposes a limit on the amount of physical memory to be given to a process; if memory is tight, the system will prefer to take memory from processes that are exceeding their declared resident set size. .PP A resource limit is specified as a soft limit and a hard limit. When a soft limit is exceeded a process may receive a signal (for example, if the cpu time is exceeded), but it will be allowed to continue execution until it reaches the hard limit (or modifies its resource limit). The .I rlimit structure is used to specify the hard and soft limits on a resource, .PP .nf .RS .DT struct rlimit { int rlim_cur; /* current (soft) limit */ int rlim_max; /* hard limit */ }; .RE .fi .PP Only the super-user may raise the maximum limits. Other users may only alter .I rlim_cur within the range from 0 to .I rlim_max or (irreversibly) lower .IR rlim_max . .PP An \*(lqinfinite\*(rq value for a limit is defined as RLIM_INFINITY (0x7\&f\&f\&f\&f\&f\&f\&f). .PP Because this information is stored in the per-process information, this system call must be executed directly by the shell if it is to affect all future processes created by the shell; .I limit is thus a built-in command to .IR csh (1). .PP The system refuses to extend the data or stack space when the limits would be exceeded in the normal way: a .I break call fails if the data space limit is reached. When the stack limit is reached, the process receives a segmentation fault (SIGSEGV); if this signal is not caught by a handler using the signal stack, this signal will kill the process. .PP A file I/O operation that would create a file that is too large will cause a signal SIGXFSZ to be generated; this normally terminates the process, but may be caught. When the soft cpu time limit is exceeded, a signal SIGXCPU is sent to the offending process. .SH "RETURN VALUE A 0 return value indicates that the call succeeded, changing or returning the resource limit. A return value of \-1 indicates that an error occurred, and an error code is stored in the global location \fIerrno\fP. .SH "ERRORS The possible errors are: .TP 15 [EFAULT] The address specified for \fIrlp\fP is invalid. .TP 15 [EPERM] The limit specified to \fIsetrlimit\fP would have raised the maximum limit value, and the caller is not the super-user. .SH SEE ALSO csh(1), quota(2), sigvec(2), sigstack(2) .SH BUGS There should be .I limit and .I unlimit commands in .IR sh (1) as well as in .IR csh. ================================================ FILE: share/man/man2/getrusage.2 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)getrusage.2 6.4 (Berkeley) 5/13/86 .\" .TH GETRUSAGE 2 "May 13, 1986" .UC 4 .SH NAME getrusage \- get information about resource utilization .SH SYNOPSIS .nf .ft B #include #include .PP .ft B .ta \w'#define 'u +\w'RUSAGE_CHILDREN 'u +\w'-1 'u #define RUSAGE_SELF 0 /* calling process */ #define RUSAGE_CHILDREN -1 /* terminated child processes */ .DT .PP .ft B getrusage(who, rusage) int who; struct rusage *rusage; .fi .SH DESCRIPTION .I Getrusage returns information describing the resources utilized by the current process, or all its terminated child processes. The .I who parameter is one of RUSAGE_SELF or RUSAGE_CHILDREN. The buffer to which .I rusage points will be filled in with the following structure: .PP .nf .RS .ta \w'struct 'u +\w'struct 'u +3u*\w'struct 'u struct rusage { struct timeval ru_utime; /* user time used */ struct timeval ru_stime; /* system time used */ long ru_maxrss; long ru_ixrss; /* integral shared text memory size */ long ru_idrss; /* integral unshared data size */ long ru_isrss; /* integral unshared stack size */ long ru_minflt; /* page reclaims */ long ru_majflt; /* page faults */ long ru_ovly; /* overlay changes */ long ru_nswap; /* swaps */ long ru_inblock; /* block input operations */ long ru_oublock; /* block output operations */ long ru_msgsnd; /* messages sent */ long ru_msgrcv; /* messages received */ long ru_nsignals; /* signals received */ long ru_nvcsw; /* voluntary context switches */ long ru_nivcsw; /* involuntary context switches */ }; .RE .DT .fi .PP The fields are interpreted as follows: .TP 15 ru_utime the total amount of time spent executing in user mode. .TP 15 ru_stime the total amount of time spent in the system executing on behalf of the process(es). .TP 15 ru_maxrss the maximum resident set size utilized (in kilobytes). .TP 15 ru_ixrss an \*(lqintegral\*(rq value indicating the amount of memory used by the text segment that was also shared among other processes. This value is expressed in units of kilobytes * seconds-of-execution and is calculated by summing the number of shared memory pages in use each time the internal system clock ticks and then averaging over 1 second intervals. .TP 15 ru_idrss an integral value of the amount of unshared memory residing in the data segment of a process (expressed in units of kilobytes * seconds-of-execution). .TP 15 ru_isrss an integral value of the amount of unshared memory residing in the stack segment of a process (expressed in units of kilobytes * seconds-of-execution). .TP 15 ru_minflt the number of page faults serviced without any I/O activity; here I/O activity is avoided by \*(lqreclaiming\*(rq a page frame from the list of pages awaiting reallocation. .TP 15 ru_majflt the number of page faults serviced that required I/O activity. .TP 15 the number of times a process requested a text overlay switch \- only available under 2_10BSD. .TP 15 ru_nswap the number of times a process was \*(lqswapped\*(rq out of main memory. .TP 15 ru_inblock the number of times the file system had to perform input. .TP 15 ru_outblock the number of times the file system had to perform output. .TP 15 ru_msgsnd the number of IPC messages sent. .TP 15 ru_msgrcv the number of IPC messages received. .TP 15 ru_nsignals the number of signals delivered. .TP 15 ru_nvcsw the number of times a context switch resulted due to a process voluntarily giving up the processor before its time slice was completed (usually to await availability of a resource). .TP 15 ru_nivcsw the number of times a context switch resulted due to a higher priority process becoming runnable or because the current process exceeded its time slice. .SH NOTES The numbers .I ru_inblock and .I ru_outblock account only for real I/O; data supplied by the caching mechanism is charged only to the first process to read or write the data. .SH ERRORS The possible errors for .I getrusage are: .TP 15 [EINVAL] The .I who parameter is not a valid value. .TP 15 [EFAULT] The address specified by the .I rusage parameter is not in a valid part of the process address space. .SH SEE ALSO gettimeofday(2), wait(2) .SH BUGS There is no way to obtain information about a child process that has not yet terminated. ================================================ FILE: share/man/man2/getsockname.2 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)getsockname.2 6.1 (Berkeley) 5/15/85 .\" .TH GETSOCKNAME 2 "May 15, 1985" .UC 5 .SH NAME getsockname \- get socket name .SH SYNOPSIS .nf .PP .ft B getsockname(s, name, namelen) int s; struct sockaddr *name; int *namelen; .fi .SH DESCRIPTION .I Getsockname returns the current .I name for the specified socket. The .I namelen parameter should be initialized to indicate the amount of space pointed to by .IR name . On return it contains the actual size of the name returned (in bytes). .SH DIAGNOSTICS A 0 is returned if the call succeeds, \-1 if it fails. .SH ERRORS The call succeeds unless: .TP 15 [EBADF] The argument \fIs\fP is not a valid descriptor. .TP 15 [ENOTSOCK] The argument \fIs\fP is a file, not a socket. .TP 15 [ENOBUFS] Insufficient resources were available in the system to perform the operation. .TP 15 [EFAULT] The .I name parameter points to memory not in a valid part of the process address space. .SH "SEE ALSO" bind(2), socket(2) .SH BUGS Names bound to sockets in the UNIX domain are inaccessible; .I getsockname returns a zero length name. ================================================ FILE: share/man/man2/getsockopt.2 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)getsockopt.2 6.4 (Berkeley) 5/23/86 .\" .TH GETSOCKOPT 2 "May 23, 1986" .UC 5 .SH NAME getsockopt, setsockopt \- get and set options on sockets .SH SYNOPSIS .nf .ft B #include #include .PP .ft B getsockopt(s, level, optname, optval, optlen) int s, level, optname; char *optval; int *optlen; .sp setsockopt(s, level, optname, optval, optlen) int s, level, optname; char *optval; int optlen; .fi .SH DESCRIPTION .I Getsockopt and .I setsockopt manipulate .I options associated with a socket. Options may exist at multiple protocol levels; they are always present at the uppermost ``socket'' level. .PP When manipulating socket options the level at which the option resides and the name of the option must be specified. To manipulate options at the ``socket'' level, .I level is specified as SOL_SOCKET. To manipulate options at any other level the protocol number of the appropriate protocol controlling the option is supplied. For example, to indicate that an option is to be interpreted by the TCP protocol, .I level should be set to the protocol number of TCP; see .IR getprotoent (3N). .PP The parameters .I optval and .I optlen are used to access option values for .IR setsockopt . For .I getsockopt they identify a buffer in which the value for the requested option(s) are to be returned. For .IR getsockopt , .I optlen is a value-result parameter, initially containing the size of the buffer pointed to by .IR optval , and modified on return to indicate the actual size of the value returned. If no option value is to be supplied or returned, .I optval may be supplied as 0. .PP .I Optname and any specified options are passed uninterpreted to the appropriate protocol module for interpretation. The include file .RI < sys/socket.h > contains definitions for ``socket'' level options, described below. Options at other protocol levels vary in format and name; consult the appropriate entries in section (4P). .PP Most socket-level options take an .I int parameter for .IR optval . For .IR setsockopt , the parameter should non-zero to enable a boolean option, or zero if the option is to be disabled. SO_LINGER uses a .I struct linger parameter, defined in .RI < sys/socket.h >, which specifies the desired state of the option and the linger interval (see below). .PP The following options are recognized at the socket level. Except as noted, each may be examined with .I getsockopt and set with .IR setsockopt . .PP .RS .ta \w'SO_BROADCAST\ \ \ \ 'u .nf SO_DEBUG toggle recording of debugging information SO_REUSEADDR toggle local address reuse SO_KEEPALIVE toggle keep connections alive SO_DONTROUTE toggle routing bypass for outgoing messages SO_LINGER linger on close if data present SO_BROADCAST toggle permission to transmit broadcast messages SO_OOBINLINE toggle reception of out-of-band data in band SO_SNDBUF set buffer size for output SO_RCVBUF set buffer size for input SO_TYPE get the type of the socket (get only) SO_ERROR get and clear error on the socket (get only) .fi .RE .PP SO_DEBUG enables debugging in the underlying protocol modules. SO_REUSEADDR indicates that the rules used in validating addresses supplied in a .IR bind (2) call should allow reuse of local addresses. SO_KEEPALIVE enables the periodic transmission of messages on a connected socket. Should the connected party fail to respond to these messages, the connection is considered broken and processes using the socket are notified via a SIGPIPE signal. SO_DONTROUTE indicates that outgoing messages should bypass the standard routing facilities. Instead, messages are directed to the appropriate network interface according to the network portion of the destination address. .PP SO_LINGER controls the action taken when unsent messags are queued on socket and a .IR close (2) is performed. If the socket promises reliable delivery of data and SO_LINGER is set, the system will block the process on the .I close attempt until it is able to transmit the data or until it decides it is unable to deliver the information (a timeout period, termed the linger interval, is specified in the .IR setsockopt call when SO_LINGER is requested). If SO_LINGER is disabled and a .I close is issued, the system will process the close in a manner that allows the process to continue as quickly as possible. .PP The option SO_BROADCAST requests permission to send broadcast datagrams on the socket. Broadcast was a privileged operation in earlier versions of the system. With protocols that support out-of-band data, the SO_OOBINLINE option requests that out-of-band data be placed in the normal data input queue as received; it will then be accessible with .I recv or .I read calls without the MSG_OOB flag. SO_SNDBUF and SO_RCVBUF are options to adjust the normal buffer sizes allocated for output and input buffers, respectively. The buffer size may be increased for high-volume connections, or may be decreased to limit the possible backlog of incoming data. The system places an absolute limit on these values. Finally, SO_TYPE and SO_ERROR are options used only with .IR setsockopt . SO_TYPE returns the type of the socket, such as SOCK_STREAM; it is useful for servers that inherit sockets on startup. SO_ERROR returns any pending error on the socket and clears the error status. It may be used to check for asynchronous errors on connected datagram sockets or for other asynchronous errors. .SH "RETURN VALUE" A 0 is returned if the call succeeds, \-1 if it fails. .SH ERRORS The call succeeds unless: .TP 20 [EBADF] The argument \fIs\fP is not a valid descriptor. .TP 20 [ENOTSOCK] The argument \fIs\fP is a file, not a socket. .TP 20 [ENOPROTOOPT] The option is unknown at the level indicated. .TP 20 [EFAULT] The address pointed to by .I optval is not in a valid part of the process address space. For .IR getsockopt , this error may also be returned if .I optlen is not in a valid part of the process address space. .SH "SEE ALSO" ioctl(2), socket(2), getprotoent(3N) .SH BUGS Several of the socket options should be handled at lower levels of the system. ================================================ FILE: share/man/man2/gettimeofday.2 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)gettimeofday.2 6.7 (Berkeley) 5/14/86 .\" .TH GETTIMEOFDAY 2 "May 14, 1986" .UC 4 .SH NAME gettimeofday, settimeofday \- get/set date and time .SH SYNOPSIS .nf .ft B #include .PP .ft B gettimeofday(tp, tzp) struct timeval *tp; struct timezone *tzp; .PP .ft B settimeofday(tp, tzp) struct timeval *tp; struct timezone *tzp; .fi .SH DESCRIPTION The system's notion of the current Greenwich time and the current time zone is obtained with the .I gettimeofday call, and set with the .I settimeofday call. The time is expressed in seconds and microseconds since midnight (0 hour), January 1, 1970. The resolution of the system clock is hardware dependent, and the time may be updated continuously or in ``ticks.'' If .I tzp is zero, the time zone information will not be returned or set. .PP The structures pointed to by .I tp and .I tzp are defined in .I as: .PP .nf .RS .DT struct timeval { long tv_sec; /* seconds since Jan. 1, 1970 */ long tv_usec; /* and microseconds */ }; .sp 1 struct timezone { int tz_minuteswest; /* of Greenwich */ int tz_dsttime; /* type of dst correction to apply */ }; .RE .fi .PP The .I timezone structure indicates the local time zone (measured in minutes of time westward from Greenwich), and a flag that, if nonzero, indicates that Daylight Saving time applies locally during the appropriate part of the year. .PP Only the super-user may set the time of day or time zone. .SH RETURN A 0 return value indicates that the call succeeded. A \-1 return value indicates an error occurred, and in this case an error code is stored into the global variable \fIerrno\fP. .SH "ERRORS The following error codes may be set in \fIerrno\fP: .TP 15 [EFAULT] An argument address referenced invalid memory. .TP 15 [EPERM] A user other than the super-user attempted to set the time. .SH "SEE ALSO" date(1), adjtime(2), ctime(3), timed(8) ================================================ FILE: share/man/man2/getuid.2 ================================================ .\" Copyright (c) 1980, 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. All advertising materials mentioning features or use of this software .\" must display the following acknowledgement: .\" This product includes software developed by the University of .\" California, Berkeley and its contributors. .\" 4. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)getuid.2 8.1.1 (2.11BSD) 1997/12/2 .\" .TH GETUID 2 "December 2, 1997" .UC 5 .SH NAME \fBgetuid\fP, \fBgeteuid\fP \- get user identification .SH SYNOPSIS .nf .B #include .B #include .sp \fIuid_t\fP \fBgetuid\fP() .sp \fIuid_t\fP \fBgeteuid\fP() .fi .SH DESCRIPTION The .B getuid function returns the real user ID of the calling process. The .B geteuid function returns the effective user ID of the calling process. .PP The real user ID is that of the user who has invoked the program. As the effective user ID gives the process additional permissions during execution of ``\fIset-user-ID\fP'' mode processes, .B getuid is used to determine the real-user-id of the calling process. .SH ERRORS The .B getuid and .B geteuid functions are always successful, and no return value is reserved to indicate an error. .SH SEE ALSO getgid(2), setreuid(2) .SH STANDARDS .B Geteuid and .B getuid conform to IEEE Std 1003.1-1988 (``POSIX''). ================================================ FILE: share/man/man2/intro.2 ================================================ .\" Copyright (c) 1980,1983,1986 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)intro.2 6.7 (Berkeley) 5/23/86 .\" .TH INTRO 2 "May 23, 1986" .UC 4 .de en .HP \\$1 \\$2 \\$3 .br .. .SH NAME intro \- introduction to system calls and error numbers .SH SYNOPSIS .B #include .SH DESCRIPTION This section describes all of the system calls. Most of these calls have one or more error returns. An error condition is indicated by an otherwise impossible return value. This is almost always \-1; the individual descriptions specify the details. Note that a number of system calls overload the meanings of these error numbers, and that the meanings must be interpreted according to the type and circumstances of the call. .PP As with normal arguments, all return codes and values from functions are of type integer unless otherwise noted. An error number is also made available in the external variable \fIerrno\fP, which is not cleared on successful calls. Thus \fIerrno\fP should be tested only after an error has occurred. .PP The following is a complete list of the errors and their names as given in .RI < sys/errno.h >. .en 0 \h'\w'EIO'u' "Error 0 Unused. .en 1 EPERM "Not owner Typically this error indicates an attempt to modify a file in some way forbidden except to its owner or super-user. It is also returned for attempts by ordinary users to do things allowed only to the super-user. .en 2 ENOENT "No such file or directory This error occurs when a file name is specified and the file should exist but doesn't, or when one of the directories in a path name does not exist. .en 3 ESRCH "No such process The process or process group whose number was given does not exist, or any such process is already dead. .en 4 EINTR "Interrupted system call An asynchronous signal (such as interrupt or quit) that the user has elected to catch occurred during a system call. If execution is resumed after processing the signal and the system call is not restarted, it will appear as if the interrupted system call returned this error condition. .en 5 EIO "I/O error Some physical I/O error occurred during a .I read or .IR write . This error may in some cases occur on a call following the one to which it actually applies. .en 6 ENXIO "No such device or address I/O on a special file refers to a subdevice that does not exist, or beyond the limits of the device. It may also occur when, for example, an illegal tape drive unit number is selected or a disk pack is not loaded on a drive. .en 7 E2BIG "Arg list too long An argument list longer than 20480 bytes (or the current limit, NCARGS in .IR ) is presented to .IR execve . .en 8 ENOEXEC "Exec format error A request is made to execute a file that, although it has the appropriate permissions, does not start with a valid magic number, (see .IR a.out (5)). .en 9 EBADF "Bad file number Either a file descriptor refers to no open file, or a read (resp. write) request is made to a file that is open only for writing (resp. reading). .en 10 ECHILD "No children .I Wait and the process has no living or unwaited-for children. .en 11 EAGAIN "No more processes In a .I fork, the system's process table is full or the user is not allowed to create any more processes. .en 12 ENOMEM "Not enough memory During an .I execve or .I break, a program asks for more core or swap space than the system is able to supply, or a process size limit would be exceeded. A lack of swap space is normally a temporary condition; however, a lack of core is not a temporary condition; the maximum size of the text, data, and stack segments is a system parameter. Soft limits may be increased to their corresponding hard limits. .en 13 EACCES "Permission denied An attempt was made to access a file in a way forbidden by the protection system. .en 14 EFAULT "Bad address The system encountered a hardware fault in attempting to access the arguments of a system call. .en 15 ENOTBLK "Block device required A plain file was mentioned where a block device was required, e.g., in .IR mount . .en 16 EBUSY "Device busy An attempt to mount a device that was already mounted or an attempt was made to dismount a device on which there is an active file (open file, current directory, mounted-on file, or active text segment). A request was made to an exclusive access device that was already in use. .en 17 EEXIST "File exists An existing file was mentioned in an inappropriate context, e.g., .IR link . .en 18 EXDEV "Cross-device link A hard link to a file on another device was attempted. .en 19 ENODEV "No such device An attempt was made to apply an inappropriate system call to a device, e.g., to read a write-only device, or the device is not configured by the system. .en 20 ENOTDIR "Not a directory A non-directory was specified where a directory is required, for example, in a path name or as an argument to .IR chdir . .en 21 EISDIR "Is a directory An attempt to write on a directory. .en 22 EINVAL "Invalid argument Some invalid argument: dismounting a non-mounted device, mentioning an unknown signal in .I signal, or some other argument inappropriate for the call. Also set by math functions, (see .IR math (3)). .en 23 ENFILE "File table overflow The system's table of open files is full, and temporarily no more .I opens can be accepted. .en 24 EMFILE "Too many open files As released, the limit on the number of open files per process is 64. .IR Getdtablesize (2) will obtain the current limit. Customary configuration limit on most other UNIX systems is 20 per process. .en 25 ENOTTY "Inappropriate ioctl for device The file mentioned in an .I ioctl is not a terminal or one of the devices to which this call applies. .en 26 ETXTBSY "Text file busy An attempt to execute a pure-procedure program that is currently open for writing. Also an attempt to open for writing a pure-procedure program that is being executed. .en 27 EFBIG "File too large The size of a file exceeded the maximum (about .if t 2\u\s-231\s+2\d .if n 2.1E9 bytes). .en 28 ENOSPC "No space left on device A .I write to an ordinary file, the creation of a directory or symbolic link, or the creation of a directory entry failed because no more disk blocks are available on the file system, or the allocation of an inode for a newly created file failed because no more inodes are available on the file system. .en 29 ESPIPE "Illegal seek An .I lseek was issued to a socket or pipe. This error may also be issued for other non-seekable devices. .en 30 EROFS "Read-only file system An attempt to modify a file or directory was made on a device mounted read-only. .en 31 EMLINK "Too many links An attempt to make more than 32767 hard links to a file. .en 32 EPIPE "Broken pipe A write on a pipe or socket for which there is no process to read the data. This condition normally generates a signal; the error is returned if the signal is caught or ignored. .en 33 EDOM "Argument too large The argument of a function in the math package (3M) is out of the domain of the function. .en 34 ERANGE "Result too large The value of a function in the math package (3M) is unrepresentable within machine precision. .en 35 EWOULDBLOCK "Operation would block" An operation that would cause a process to block was attempted on an object in non-blocking mode (see \fIfcntl\fP(2)). .en 36 EINPROGRESS "Operation now in progress" An operation that takes a long time to complete (such as a \fIconnect\fP(2)) was attempted on a non-blocking object (see \fIfcntl\fP(2)). .en 37 EALREADY "Operation already in progress" An operation was attempted on a non-blocking object that already had an operation in progress. .en 38 ENOTSOCK "Socket operation on non-socket" Self-explanatory. .en 39 EDESTADDRREQ "Destination address required" A required address was omitted from an operation on a socket. .en 40 EMSGSIZE "Message too long" A message sent on a socket was larger than the internal message buffer or some other network limit. .en 41 EPROTOTYPE "Protocol wrong type for socket" A protocol was specified that does not support the semantics of the socket type requested. For example, you cannot use the ARPA Internet UDP protocol with type SOCK_STREAM. .en 42 ENOPROTOOPT "Option not supported by protocol A bad option or level was specified in a .IR getsockopt (2) or .IR setsockopt (2) call. .en 43 EPROTONOSUPPORT "Protocol not supported" The protocol has not been configured into the system or no implementation for it exists. .en 44 ESOCKTNOSUPPORT "Socket type not supported" The support for the socket type has not been configured into the system or no implementation for it exists. .en 45 EOPNOTSUPP "Operation not supported on socket" For example, trying to \fIaccept\fP a connection on a datagram socket. .en 46 EPFNOSUPPORT "Protocol family not supported" The protocol family has not been configured into the system or no implementation for it exists. .en 47 EAFNOSUPPORT "Address family not supported by protocol family" An address incompatible with the requested protocol was used. For example, you shouldn't necessarily expect to be able to use NS addresses with ARPA Internet protocols. .en 48 EADDRINUSE "Address already in use" Only one usage of each address is normally permitted. .en 49 EADDRNOTAVAIL "Can't assign requested address" Normally results from an attempt to create a socket with an address not on this machine. .en 50 ENETDOWN "Network is down" A socket operation encountered a dead network. .en 51 ENETUNREACH "Network is unreachable" A socket operation was attempted to an unreachable network. .en 52 ENETRESET "Network dropped connection on reset" The host you were connected to crashed and rebooted. .en 53 ECONNABORTED "Software caused connection abort" A connection abort was caused internal to your host machine. .en 54 ECONNRESET "Connection reset by peer" A connection was forcibly closed by a peer. This normally results from a loss of the connection on the remote socket due to a timeout or a reboot. .en 55 ENOBUFS "No buffer space available" An operation on a socket or pipe was not performed because the system lacked sufficient buffer space or because a queue was full. .en 56 EISCONN "Socket is already connected" A .I connect request was made on an already connected socket; or, a .I sendto or .I sendmsg request on a connected socket specified a destination when already connected. .en 57 ENOTCONN "Socket is not connected" An request to send or receive data was disallowed because the socket is not connected and (when sending on a datagram socket) no address was supplied. .en 58 ESHUTDOWN "Can't send after socket shutdown" A request to send data was disallowed because the socket had already been shut down with a previous .IR shutdown (2) call. .en 59 \fIunused\fP .en 60 ETIMEDOUT "Connection timed out" A .I connect or .I send request failed because the connected party did not properly respond after a period of time. (The timeout period is dependent on the communication protocol.) .en 61 ECONNREFUSED "Connection refused" No connection could be made because the target machine actively refused it. This usually results from trying to connect to a service that is inactive on the foreign host. .en 62 ELOOP "Too many levels of symbolic links" A path name lookup involved more than 8 symbolic links. .en 63 ENAMETOOLONG "File name too long" A component of a path name exceeded 255 (MAXNAMELEN) characters, or an entire path name exceeded 1023 (MAXPATHLEN-1) characters. .en 64 EHOSTDOWN "Host is down" A socket operation failed because the destination host was down. .en 65 EHOSTUNREACH "Host is unreachable" A socket operation was attempted to an unreachable host. .en 66 ENOTEMPTY "Directory not empty" A directory with entries other than \*(lq.\*(rq and \*(lq..\*(rq was supplied to a remove directory or rename call. ...en 67 EPROCLIM "Too many processes" ...en 68 EUSERS "Too many users" .en 69 EDQUOT "Disc quota exceeded" A .I write to an ordinary file, the creation of a directory or symbolic link, or the creation of a directory entry failed because the user's quota of disk blocks was exhausted, or the allocation of an inode for a newly created file failed because the user's quota of inodes was exhausted. .SH DEFINITIONS .TP 5 Process ID .br Each active process in the system is uniquely identified by a positive integer called a process ID. The range of this ID is from 0 to 30000. .TP 5 Parent process ID .br A new process is created by a currently active process; (see .IR fork (2)). The parent process ID of a process is the process ID of its creator. .TP 5 Process Group ID .br Each active process is a member of a process group that is identified by a positive integer called the process group ID. This is the process ID of the group leader. This grouping permits the signaling of related processes (see .IR killpg (2)) and the job control mechanisms of .IR csh (1). .TP 5 Tty Group ID .br Each active process can be a member of a terminal group that is identified by a positive integer called the tty group ID. This grouping is used to arbitrate between multiple jobs contending for the same terminal; (see .IR csh (1) and .IR tty (4)). .TP 5 Real User ID and Real Group ID .br Each user on the system is identified by a positive integer termed the real user ID. .IP Each user is also a member of one or more groups. One of these groups is distinguished from others and used in implementing accounting facilities. The positive integer corresponding to this distinguished group is termed the real group ID. .IP All processes have a real user ID and real group ID. These are initialized from the equivalent attributes of the process that created it. .TP 5 Effective User Id, Effective Group Id, and Access Groups .br Access to system resources is governed by three values: the effective user ID, the effective group ID, and the group access list. .IP The effective user ID and effective group ID are initially the process's real user ID and real group ID respectively. Either may be modified through execution of a set-user-ID or set-group-ID file (possibly by one its ancestors) (see .IR execve (2)). .IP The group access list is an additional set of group ID's used only in determining resource accessibility. Access checks are performed as described below in ``File Access Permissions''. .TP 5 Super-user .br A process is recognized as a .I super-user process and is granted special privileges if its effective user ID is 0. .TP 5 Special Processes .br The processes with a process ID's of 0, 1, and 2 are special. Process 0 is the scheduler. Process 1 is the initialization process .IR init , and is the ancestor of every other process in the system. It is used to control the process structure. Process 2 is the paging daemon. .TP 5 Descriptor .br An integer assigned by the system when a file is referenced by .IR open (2) or .IR dup (2), or when a socket is created by .IR pipe (2), .IR socket (2) or .IR socketpair (2), which uniquely identifies an access path to that file or socket from a given process or any of its children. .TP 5 File Name .br Names consisting of up to 255 (MAXNAMELEN) characters may be used to name an ordinary file, special file, or directory. .IP These characters may be selected from the set of all ASCII character excluding 0 (null) and the ASCII code for / (slash). (The parity bit, bit 8, must be 0.) .IP Note that it is generally unwise to use *, ?, [ or ] as part of file names because of the special meaning attached to these characters by the shell. .TP 5 Path Name .br A path name is a null-terminated character string starting with an optional slash (/), followed by zero or more directory names separated by slashes, optionally followed by a file name. The total length of a path name must be less than 1024 (MAXPATHLEN) characters. .IP If a path name begins with a slash, the path search begins at the .I root directory. Otherwise, the search begins from the current working directory. A slash by itself names the root directory. A null pathname refers to the current directory. .TP 5 Directory .br A directory is a special type of file that contains entries that are references to other files. Directory entries are called links. By convention, a directory contains at least two links, . and .., referred to as .I dot and .I dot-dot respectively. Dot refers to the directory itself and dot-dot refers to its parent directory. .TP 5 Root Directory and Current Working Directory .br Each process has associated with it a concept of a root directory and a current working directory for the purpose of resolving path name searches. A process's root directory need not be the root directory of the root file system. .TP 5 File Access Permissions .br Every file in the file system has a set of access permissions. These permissions are used in determining whether a process may perform a requested operation on the file (such as opening a file for writing). Access permissions are established at the time a file is created. They may be changed at some later time through the .IR chmod (2) call. .IP File access is broken down according to whether a file may be: read, written, or executed. Directory files use the execute permission to control if the directory may be searched. .IP File access permissions are interpreted by the system as they apply to three different classes of users: the owner of the file, those users in the file's group, anyone else. Every file has an independent set of access permissions for each of these classes. When an access check is made, the system decides if permission should be granted by checking the access information applicable to the caller. .IP Read, write, and execute/search permissions on a file are granted to a process if: .IP The process's effective user ID is that of the super-user. .IP The process's effective user ID matches the user ID of the owner of the file and the owner permissions allow the access. .IP The process's effective user ID does not match the user ID of the owner of the file, and either the process's effective group ID matches the group ID of the file, or the group ID of the file is in the process's group access list, and the group permissions allow the access. .IP Neither the effective user ID nor effective group ID and group access list of the process match the corresponding user ID and group ID of the file, but the permissions for ``other users'' allow access. .IP Otherwise, permission is denied. .TP 5 Sockets and Address Families .IP A socket is an endpoint for communication between processes. Each socket has queues for sending and receiving data. .IP Sockets are typed according to their communications properties. These properties include whether messages sent and received at a socket require the name of the partner, whether communication is reliable, the format used in naming message recipients, etc. .IP Each instance of the system supports some collection of socket types; consult .IR socket (2) for more information about the types available and their properties. .IP Each instance of the system supports some number of sets of communications protocols. Each protocol set supports addresses of a certain format. An Address Family is the set of addresses for a specific group of protocols. Each socket has an address chosen from the address family in which the socket was created. .SH SEE ALSO intro(3), perror(3) ================================================ FILE: share/man/man2/ioctl.2 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)ioctl.2 6.3 (Berkeley) 3/4/86 .\" .TH IOCTL 2 "March 4, 1986" .UC 4 .SH NAME ioctl \- control device .SH SYNOPSIS .nf .ft B #include .PP .ft B ioctl(d, request, argp) int d; unsigned long request; char *argp; .fi .ft R .SH DESCRIPTION .I Ioctl performs a variety of functions on open descriptors. In particular, many operating characteristics of character special files (e.g. terminals) may be controlled with .I ioctl requests. The writeups of various devices in section 4 discuss how .I ioctl applies to them. .PP An ioctl .I request has encoded in it whether the argument is an \*(lqin\*(rq parameter or \*(lqout\*(rq parameter, and the size of the argument \fIargp\fP in bytes. Macros and defines used in specifying an ioctl .I request are located in the file .IR . .SH "RETURN VALUE If an error has occurred, a value of \-1 is returned and .I errno is set to indicate the error. .SH ERRORS .I Ioctl will fail if one or more of the following are true: .TP 15 [EBADF] \fID\fP is not a valid descriptor. .TP 15 [ENOTTY] \fID\fP is not associated with a character special device. .TP 15 [ENOTTY] The specified request does not apply to the kind of object that the descriptor \fId\fP references. .TP 15 [EINVAL] \fIRequest\fP or \fIargp\fP is not valid. .SH "SEE ALSO" execve(2), fcntl(2), mt(4), tty(4), intro(4N) ================================================ FILE: share/man/man2/kill.2 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)kill.2 6.5 (Berkeley) 5/14/86 .\" .TH KILL 2 "May 14, 1986" .UC 4 .SH NAME kill \- send signal to a process .SH SYNOPSIS .ft B kill(pid, sig) .br int pid, sig; .SH DESCRIPTION .I Kill sends the signal \fIsig\fP to a process, specified by the process number .IR pid . .I Sig may be one of the signals specified in .IR sigvec (2), or it may be 0, in which case error checking is performed but no signal is actually sent. This can be used to check the validity of .IR pid . .PP The sending and receiving processes must have the same effective user ID, otherwise this call is restricted to the super-user. A single exception is the signal SIGCONT, which may always be sent to any descendant of the current process. .PP If the process number is 0, the signal is sent to all processes in the sender's process group; this is a variant of .IR killpg (2). .PP If the process number is \-1 and the user is the super-user, the signal is broadcast universally except to system processes and the process sending the signal. If the process number is \-1 and the user is not the super-user, the signal is broadcast universally to all processes with the same uid as the user except the process sending the signal. No error is returned if any process could be signaled. .PP For compatibility with System V, if the process number is negative but not \-1, the signal is sent to all processes whose process group ID is equal to the absolute value of the process number. This is a variant of .IR killpg (2). .PP Processes may send signals to themselves. .SH "RETURN VALUE Upon successful completion, a value of 0 is returned. Otherwise, a value of \-1 is returned and .I errno is set to indicate the error. .SH "ERRORS .I Kill will fail and no signal will be sent if any of the following occur: .TP 15 [EINVAL] \fISig\fP is not a valid signal number. .TP 15 [ESRCH] No process can be found corresponding to that specified by \fIpid\fP. .TP 15 [ESRCH] The process id was given as 0 but the sending process does not have a process group. .TP 15 [EPERM] The sending process is not the super-user and its effective user id does not match the effective user-id of the receiving process. When signaling a process group, this error was returned if any members of the group could not be signaled. .SH "SEE ALSO" getpid(2), getpgrp(2), killpg(2), sigvec(2) ================================================ FILE: share/man/man2/killpg.2 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)killpg.2 6.3 (Berkeley) 5/14/86 .\" .TH KILLPG 2 "May 14, 1986" .UC 4 .SH NAME killpg \- send signal to a process group .SH SYNOPSIS .ft B killpg(pgrp, sig) .br int pgrp, sig; .ft R .SH DESCRIPTION .I Killpg sends the signal .I sig to the process group .IR pgrp . See .IR sigvec (2) for a list of signals. .PP The sending process and members of the process group must have the same effective user ID, or the sender must be the super-user. As a single special case the continue signal SIGCONT may be sent to any process that is a descendant of the current process. .SH "RETURN VALUE Upon successful completion, a value of 0 is returned. Otherwise, a value of \-1 is returned and the global variable \fIerrno\fP is set to indicate the error. .SH "ERRORS \fIKillpg\fP will fail and no signal will be sent if any of the following occur: .TP 15 [EINVAL] \fISig\fP is not a valid signal number. .TP 15 [ESRCH] No process can be found in the process group specified by \fIpgrp\fP. .TP 15 [ESRCH] The process group was given as 0 but the sending process does not have a process group. .TP 15 [EPERM] The sending process is not the super-user and one or more of the target processes has an effective user ID different from that of the sending process. .SH "SEE ALSO" kill(2), getpgrp(2), sigvec(2) ================================================ FILE: share/man/man2/link.2 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)link.2 6.3 (Berkeley) 8/26/85 .\" .TH LINK 2 "August 26, 1985" .UC 4 .SH NAME link \- make a hard link to a file .SH SYNOPSIS .nf .ft B link(name1, name2) char *name1, *name2; .fi .ft R .SH DESCRIPTION A hard link to .I name1 is created; the link has the name .IR name2 . .I Name1 must exist. .PP With hard links, both .I name1 and .I name2 must be in the same file system. Unless the caller is the super-user, .I name1 must not be a directory. Both the old and the new .I link share equal access and rights to the underlying object. .SH "RETURN VALUE Upon successful completion, a value of 0 is returned. Otherwise, a value of \-1 is returned and .I errno is set to indicate the error. .SH "ERRORS .I Link will fail and no link will be created if one or more of the following are true: .TP 15 [ENOTDIR] A component of either path prefix is not a directory. .TP 15 [EINVAL] Either pathname contains a character with the high-order bit set. .TP 15 [ENAMETOOLONG] A component of either pathname exceeded 255 characters, or entire length of either path name exceeded 1023 characters. .TP 15 [ENOENT] A component of either path prefix does not exist. .TP 15 [EACCES] A component of either path prefix denies search permission. .TP 15 [EACCES] The requested link requires writing in a directory with a mode that denies write permission. .TP 15 [ELOOP] Too many symbolic links were encountered in translating one of the pathnames. .TP 15 [ENOENT] The file named by \fIname1\fP does not exist. .TP 15 [EEXIST] The link named by \fIname2\fP does exist. .TP 15 [EPERM] The file named by \fIname1\fP is a directory and the effective user ID is not super-user. .TP 15 [EXDEV] The link named by \fIname2\fP and the file named by \fIname1\fP are on different file systems. .TP 15 [ENOSPC] The directory in which the entry for the new link is being placed cannot be extended because there is no space left on the file system containing the directory. .TP 15 [EDQUOT] The directory in which the entry for the new link is being placed cannot be extended because the user's quota of disk blocks on the file system containing the directory has been exhausted. .TP 15 [EIO] An I/O error occurred while reading from or writing to the file system to make the directory entry. .TP 15 [EROFS] The requested link requires writing in a directory on a read-only file system. .TP 15 [EFAULT] One of the pathnames specified is outside the process's allocated address space. .SH "SEE ALSO" symlink(2), unlink(2) ================================================ FILE: share/man/man2/listen.2 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)listen.2 6.2 (Berkeley) 5/14/86 .\" .TH LISTEN 2 "May 14, 1986" .UC 5 .SH NAME listen \- listen for connections on a socket .SH SYNOPSIS .nf .ft B listen(s, backlog) int s, backlog; .fi .SH DESCRIPTION To accept connections, a socket is first created with .IR socket (2), a willingness to accept incoming connections and a queue limit for incoming connections are specified with .IR listen (2), and then the connections are accepted with .IR accept (2). The .I listen call applies only to sockets of type SOCK_STREAM or SOCK_SEQPACKET. .PP The .I backlog parameter defines the maximum length the queue of pending connections may grow to. If a connection request arrives with the queue full the client may receive an error with an indication of ECONNREFUSED, or, if the underlying protocol supports retransmission, the request may be ignored so that retries may succeed. .SH "RETURN VALUE A 0 return value indicates success; \-1 indicates an error. .SH "ERRORS The call fails if: .TP 20 [EBADF] The argument \fIs\fP is not a valid descriptor. .TP 20 [ENOTSOCK] The argument \fIs\fP is not a socket. .TP 20 [EOPNOTSUPP] The socket is not of a type that supports the operation \fIlisten\fP. .SH "SEE ALSO" accept(2), connect(2), socket(2) .SH BUGS The .I backlog is currently limited (silently) to 5. ================================================ FILE: share/man/man2/lock.2 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)lock.2 2.3 (Berkeley) 1/22/87 .\" .TH LOCK 2 "January 22, 1987" .UC 2 .SH NAME lock \- lock a process in primary memory (2BSD) .SH SYNOPSIS .nf .ft B lock(flag) int flag .fi .ft R .SH DESCRIPTION If the .I flag argument is non-zero, the process executing this call will not be swapped unless it is required to grow. If the argument is zero, the process is .RI un lock ed. This call may only be executed by the super-user. .SH ERRORS .TP 15 [EPERM] The caller is not the super-user. .SH BUGS .IR Lock ed processes interfere with the compaction of primary memory and can cause deadlock. This system call is not considered a permanent part of the system. .PP .I Lock is unique to the PDP-11 and 2BSD; its use is discouraged. ================================================ FILE: share/man/man2/lseek.2 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)lseek.2 6.3 (Berkeley) 2/24/86 .\" .TH LSEEK 2 "February 24, 1986" .UC 4 .SH NAME lseek \- move read/write pointer .SH SYNOPSIS .nf .ft B #include .PP .nf .ft B .ta 1.25i 1.6i 1.8i #define L_SET 0 /* set the seek pointer */ #define L_INCR 1 /* increment the seek pointer */ #define L_XTND 2 /* extend the file size */ .PP .ft B pos = lseek(d, offset, whence) off_t pos; int d; off_t offset; int whence; .fi .ft R .SH DESCRIPTION The descriptor .I d refers to a file or device open for reading and/or writing. .I Lseek sets the file pointer of .I d as follows: .IP If .I whence is L_SET, the pointer is set to .I offset bytes. .IP If .I whence is L_INCR, the pointer is set to its current location plus .IR offset . .IP If .I whence is L_XTND, the pointer is set to the size of the file plus .IR offset . .PP Upon successful completion, the resulting pointer location as measured in bytes from beginning of the file is returned. Some devices are incapable of seeking. The value of the pointer associated with such a device is undefined. .SH NOTES Seeking far beyond the end of a file, then writing, creates a gap or \*(lqhole\*(rq, which occupies no physical space and reads as zeros. .SH "RETURN VALUE Upon successful completion, the current file pointer value is returned. Otherwise, a value of \-1 is returned and \fIerrno\fP is set to indicate the error. .SH "ERRORS .I Lseek will fail and the file pointer will remain unchanged if: .TP 15 [EBADF] .I Fildes is not an open file descriptor. .TP 15 [ESPIPE] .I Fildes is associated with a pipe or a socket. .TP 15 [EINVAL] .I Whence is not a proper value. .SH "SEE ALSO" dup(2), open(2) .SH BUGS This document's use of .I whence is incorrect English, but maintained for historical reasons. ================================================ FILE: share/man/man2/mkdir.2 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)mkdir.2 6.4 (Berkeley) 8/26/85 .\" .TH MKDIR 2 "August 26, 1985" .UC 5 .SH NAME mkdir \- make a directory file .SH SYNOPSIS .nf .ft B mkdir(path, mode) char *path; int mode; .fi .ft R .SH DESCRIPTION .I Mkdir creates a new directory file with name .IR path . The mode of the new file is initialized from .IR mode . (The protection part of the mode is modified by the process's mode mask; see .IR umask (2)). .PP The directory's owner ID is set to the process's effective user ID. The directory's group ID is set to that of the parent directory in which it is created. .PP The low-order 9 bits of mode are modified by the process's file mode creation mask: all bits set in the process's file mode creation mask are cleared. See .IR umask (2). .SH "RETURN VALUE A 0 return value indicates success. A \-1 return value indicates an error, and an error code is stored in .I errno. .SH "ERRORS .I Mkdir will fail and no directory will be created if: .TP 15 [ENOTDIR] A component of the path prefix is not a directory. .TP 15 [EINVAL] The pathname contains a character with the high-order bit set. .TP 15 [ENAMETOOLONG] A component of a pathname exceeded 255 characters, or an entire path name exceeded 1023 characters. .TP 15 [ENOENT] A component of the path prefix does not exist. .TP 15 [EACCES] Search permission is denied for a component of the path prefix. .TP 15 [ELOOP] Too many symbolic links were encountered in translating the pathname. .TP 15 [EPERM] The \fIpath\fP argument contains a byte with the high-order bit set. .TP 15 [EROFS] The named file resides on a read-only file system. .TP 15 [EEXIST] The named file exists. .TP 15 [ENOSPC] The directory in which the entry for the new directory is being placed cannot be extended because there is no space left on the file system containing the directory. .TP 15 [ENOSPC] The new directory cannot be created because there there is no space left on the file system that will contain the directory. .TP 15 [ENOSPC] There are no free inodes on the file system on which the directory is being created. .TP 15 [EDQUOT] The directory in which the entry for the new directory is being placed cannot be extended because the user's quota of disk blocks on the file system containing the directory has been exhausted. .TP 15 [EDQUOT] The new directory cannot be created because the user's quota of disk blocks on the file system that will contain the directory has been exhausted. .TP 15 [EDQUOT] The user's quota of inodes on the file system on which the directory is being created has been exhausted. .TP 15 [EIO] An I/O error occurred while making the directory entry or allocating the inode. .TP 15 [EIO] An I/O error occurred while reading from or writing to the file system. .TP 15 [EFAULT] .I Path points outside the process's allocated address space. .SH "SEE ALSO" chmod(2), stat(2), umask(2) ================================================ FILE: share/man/man2/mknod.2 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)mknod.2 6.4 (Berkeley) 5/23/86 .\" .TH MKNOD 2 "May 23, 1986" .UC 4 .SH NAME mknod \- make a special file .SH SYNOPSIS .nf .ft B mknod(path, mode, dev) char *path; int mode, dev; .fi .ft R .SH DESCRIPTION .I Mknod creates a new file whose name is .I path. The mode of the new file (including special file bits) is initialized from .IR mode . (The protection part of the mode is modified by the process's mode mask (see .IR umask (2))). The first block pointer of the i-node is initialized from .I dev and is used to specify which device the special file refers to. .PP If mode indicates a block or character special file, .I dev is a configuration dependent specification of a character or block I/O device. If .I mode does not indicate a block special or character special device, .I dev is ignored. .PP .I Mknod may be invoked only by the super-user. .SH "RETURN VALUE Upon successful completion a value of 0 is returned. Otherwise, a value of \-1 is returned and \fIerrno\fP is set to indicate the error. .SH ERRORS .I Mknod will fail and the file mode will be unchanged if: .TP 15 [ENOTDIR] A component of the path prefix is not a directory. .TP 15 [EINVAL] The pathname contains a character with the high-order bit set. .TP 15 [ENAMETOOLONG] A component of a pathname exceeded 255 characters, or an entire path name exceeded 1023 characters. .TP 15 [ENOENT] A component of the path prefix does not exist. .TP 15 [EACCES] Search permission is denied for a component of the path prefix. .TP 15 [ELOOP] Too many symbolic links were encountered in translating the pathname. .TP 15 [EPERM] The process's effective user ID is not super-user. .TP 15 [EPERM] The pathname contains a character with the high-order bit set. .TP 15 [EIO] An I/O error occurred while making the directory entry or allocating the inode. .TP 15 [ENOSPC] The directory in which the entry for the new node is being placed cannot be extended because there is no space left on the file system containing the directory. .TP 15 [ENOSPC] There are no free inodes on the file system on which the node is being created. .TP 15 [EDQUOT] The directory in which the entry for the new node is being placed cannot be extended because the user's quota of disk blocks on the file system containing the directory has been exhausted. .TP 15 [EDQUOT] The user's quota of inodes on the file system on which the node is being created has been exhausted. .TP 15 [EROFS] The named file resides on a read-only file system. .TP 15 [EEXIST] The named file exists. .TP 15 [EFAULT] .I Path points outside the process's allocated address space. .SH "SEE ALSO" chmod(2), stat(2), umask(2) ================================================ FILE: share/man/man2/mount.2 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)mount.2 6.3.1 (2.11BSD) 1996/1/25 .\" .TH MOUNT 2 "January 25, 1996" .UC 4 .SH NAME mount, umount \- mount or remove file system .SH SYNOPSIS .nf .ft B mount(special, name, flags) char *special, *name; int flags; .PP .ft B umount(special) char *special; .fi .SH DESCRIPTION .I Mount announces to the system that a removable file system has been mounted on the block-structured special file .I special; from now on, references to file .I name will refer to the root file on the newly mounted file system. .I Special and .I name are pointers to null-terminated strings containing the appropriate path names. .PP .I Name must exist already. .I Name must be a directory. Its old contents are inaccessible while the file system is mounted. .PP The following .I flags may be specified to suppress default semantics which affect filesystem access. .TP 20 MNT_RDONLY The filesystem should be treated as read-only; Even the super-user may not write on it. .TP 20 MNT_NOEXEC Do not allow files to be executed from the filesystem. .TP 20 MNT_NOSUID Do not honor setuid or setgid bits on files when executing them. .TP 20 MNT_NODEV Do not interpret special files on the filesystem. .TP 20 MNT_SYNCHRONOUS All I/O to the filesystem should be done synchronously. .PP .I Umount announces to the system that the .I special file is no longer to contain a removable file system. The associated file reverts to its ordinary interpretation. .SH "RETURN VALUE .I Mount returns 0 if the action occurred, \-1 if .I special is inaccessible or not an appropriate file, if .I name does not exist, if .I special is already mounted, if .I name is in use, or if there are already too many file systems mounted. .PP .I Umount returns 0 if the action occurred; \-1 if if the special file is inaccessible or does not have a mounted file system, or if there are active files in the mounted file system. .SH ERRORS .I Mount will fail when one of the following occurs: .TP 15 [ENAMETOOLONG] A component of either pathname exceeded 255 characters, or the entire length of either path name exceeded 1023 characters. .TP 15 [ELOOP] Too many symbolic links were encountered in translating either pathname. .TP 15 [EPERM] The caller is not the super-user. .TP 15 [ENOENT] A component of \fIname\fP does not exist. .TP 15 [ENODEV] A component of \fIspecial\fP does not exist. .TP 15 [ENOTBLK] .I Special is not a block device. .TP 15 [ENXIO] The major device number of .I special is out of range (this indicates no device driver exists for the associated hardware). .TP 15 [ENOTDIR] A component of \fIname\fP is not a directory, or a path prefix of \fIspecial\fP is not a directory. .TP 15 [EINVAL] Either pathname contains a character with the high-order bit set. .TP 15 [EINVAL] The super block for the file system had a bad magic number or an out of range block size. .TP 15 [EBUSY] Another process currently holds a reference to .IR name , or \fIspecial\fP is already mounted. .TP 15 [EMFILE] No space remains in the mount table. .TP 15 [ENOMEM] Not enough memory was available to read the cylinder group information for the file system. .TP 15 [EIO] An I/O error occurred while reading the super block or cylinder group information. .TP 15 [EFAULT] \fISpecial\fP or \fIname\fP points outside the process's allocated address space. .PP .I Umount may fail with one of the following errors: .TP 15 [ENOTDIR] A component of the path prefix is not a directory. .TP 15 [EINVAL] The pathname contains a character with the high-order bit set. .TP 15 [ENAMETOOLONG] A component of a pathname exceeded 255 characters, or an entire path name exceeded 1023 characters. .TP 15 [ELOOP] Too many symbolic links were encountered in translating the pathname. .TP 15 [EPERM] The caller is not the super-user. .TP 15 [ENODEV] .I Special does not exist. .TP 15 [ENOTBLK] .I Special is not a block device. .TP 15 [ENXIO] The major device number of .I special is out of range (this indicates no device driver exists for the associated hardware). .TP 15 [EINVAL] The requested device is not in the mount table. .TP 15 [EBUSY] A process is holding a reference to a file located on the file system. .TP 15 [EIO] An I/O error occurred while writing the super block or other cached file system information. .TP 15 [EFAULT] \fISpecial\fP points outside the process's allocated address space. .SH "SEE ALSO" mount(8), umount(8) .SH BUGS Some of the error codes need translation to more obvious messages. .PP Physically write-protected and magnetic tape file systems must be mounted read-only or errors will occur when access times are updated, whether or not any explicit write is attempted. .PP MNT_SYNCHRONOUS is not currently implemented in the kernel but may be specified because the kernel ignores it. ================================================ FILE: share/man/man2/nostk.2 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)nostk.2 2.3 (Berkeley) 6/24/87 .\" .TH NOSTK 2 "June 24, 1987" .UC 2 .SH NAME nostk \- allow process to manage its own stack (2BSD) .SH SYNOPSYS .B nostk(); .SH DESCRIPTION .I Nostk informs the system that the process wishes to manage its own stack. The system releases the stack segment(s) it has reserved, making them available for allocation (via .IR brk (2)) by the user. .PP C programs should use .I nostk only with great caution and understanding of the C language calling and stack conventions. It is most useful for assembler programs that want to use the entire available address space. .SH "SEE ALSO" stack(5) .SH BUGS .I Nostk is unique to the PDP-11 and 2BSD; its use is discouraged. ================================================ FILE: share/man/man2/open.2 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)open.2 6.4.1 (2.11BSD GTE) 11/30/94 .\" .TH OPEN 2 "Nov 30, 1994" .UC 4 .SH NAME open \- open a file for reading or writing, or create a new file .SH SYNOPSIS .nf .ft B #include .PP .ft B open(path, flags, mode) char *path; int flags, mode; .fi .SH DESCRIPTION .I Open opens the file .I path for reading and/or writing, as specified by the .I flags argument and returns a descriptor for that file. The .I flags argument may indicate the file is to be created if it does not already exist (by specifying the O_CREAT flag), in which case the file is created with mode .I mode as described in .IR chmod (2) and modified by the process' umask value (see .IR umask (2)). .PP .I Path is the address of a string of ASCII characters representing a path name, terminated by a null character. The flags specified are formed by .IR or 'ing the following values .PP .RS O_RDONLY open for reading only O_WRONLY open for writing only O_RDWR open for reading and writing O_NONBLOCK do not block on open O_APPEND append on each write O_CREAT create file if it does not exist O_TRUNC truncate size to 0 O_EXCL error if create and file exists O_NOCTTY do not acquire as controlling terminal O_SHLOCK atomically obtain a shared lock O_EXLOCK atomically obtain an exclusive lock .RE .PP Opening a file with O_APPEND set causes each write on the file to be appended to the end. If O_TRUNC is specified and the file exists, the file is truncated to zero length. If O_EXCL is set with O_CREAT, then if the file already exists, the open returns an error. This can be used to implement a simple exclusive access locking mechanism. If O_EXCL is set and the last component of the pathname is a symbolic link, the open will fail even if the symbolic link points to a non-existent name. If the O_NONBLOCK flag is specified and the open call would result in the process being blocked for some reason (e.g. waiting for carrier on a dialup line), the open returns immediately. The first time the process attempts to perform i/o on the open file it will block. .PP The flag O_NOCTTY indicates that even if the file is a terminal device, the call should not result in acquiring the terminal device as the controlling terminal of the caller. This flag is not the default and is currently unimplemented (it will be Real Soon Now). .PP When opening a file, a lock with .IR flock(2) semantics can be obtained by setting O_SHLOCK for a shared lock, or O_EXLOCK for an exclusive lock. If creating a file with O_CREAT, the request for the lock will never fail. .PP Upon successful completion a non-negative integer termed a file descriptor is returned. The file pointer used to mark the current position within the file is set to the beginning of the file. .PP The new descriptor is set to remain open across .IR execve system calls; see .IR close (2). .PP The system imposes a limit on the number of file descriptors open simultaneously by one process. .IR Getdtablesize (2) returns the current system limit. .SH "ERRORS The named file is opened unless one or more of the following are true: .TP 15 [ENOTDIR] A component of the path prefix is not a directory. .TP 15 [EINVAL] The pathname contains a character with the high-order bit set. .TP 15 [ENAMETOOLONG] A component of a pathname exceeded 255 characters, or an entire path name exceeded 1023 characters. .TP 15 [ENOENT] O_CREAT is not set and the named file does not exist. .TP 15 [ENOENT] A component of the path name that must exist does not exist. .TP 15 [EACCES] Search permission is denied for a component of the path prefix. .TP 15 [EACCES] The required permissions (for reading and/or writing) are denied for the named flag. .TP 15 [EACCES] O_CREAT is specified, the file does not exist, and the directory in which it is to be created does not permit writing. .TP 15 [ELOOP] Too many symbolic links were encountered in translating the pathname. .TP 15 [EISDIR] The named file is a directory, and the arguments specify it is to be opened for writting. .TP 15 [EROFS] The named file resides on a read-only file system, and the file is to be modified. .TP 15 [EMFILE] The system limit for open file descriptors per process has already been reached. .TP 15 [ENFILE] The system file table is full. .TP 15 [ENXIO] The named file is a character special or block special file, and the device associated with this special file does not exist. .TP 15 [ENOSPC] O_CREAT is specified, the file does not exist, and the directory in which the entry for the new file is being placed cannot be extended because there is no space left on the file system containing the directory. .TP 15 [ENOSPC] O_CREAT is specified, the file does not exist, and there are no free inodes on the file system on which the file is being created. .TP 15 [EDQUOT] O_CREAT is specified, the file does not exist, and the directory in which the entry for the new fie is being placed cannot be extended because the user's quota of disk blocks on the file system containing the directory has been exhausted. .TP 15 [EDQUOT] O_CREAT is specified, the file does not exist, and the user's quota of inodes on the file system on which the file is being created has been exhausted. .TP 15 [EIO] An I/O error occurred while making the directory entry or allocating the inode for O_CREAT. .TP 15 [ETXTBSY] The file is a pure procedure (shared text) file that is being executed and the \fIopen\fP call requests write access. .TP 15 [EFAULT] .I Path points outside the process's allocated address space. .TP 15 [EEXIST] O_CREAT and O_EXCL were specified and the file exists. .TP 15 [EOPNOTSUPP] An attempt was made to open a socket (not currently implemented). .SH "SEE ALSO" chmod(2), close(2), dup(2), getdtablesize(2), lseek(2), read(2), write(2), umask(2) ================================================ FILE: share/man/man2/phys.2 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)phys.2 2.3 (Berkeley) 1/22/87 .\" .TH PHYS 2 "January 22, 1987" .UC 2 .SH NAME phys \- allow a process to access physical addresses (2BSD) .SH SYNOPSIS .nf .ft B phys(segreg, size, physaddr) unsigned int segreg, size, physaddr; .fi .ft R .SH DESCRIPTION The argument .I segreg specifies a process virtual (data-space) address range of 8K bytes starting at virtual address .IR segreg \(mu8K bytes. This address range is mapped into physical address .IR physaddr \(mu64 bytes. Only the first .IR size \(mu64 bytes of this mapping is addressable. If .I size is zero, any previous mapping of this virtual address range is nullified. For example, the call .PP phys(7, 1, 0177775); .PP will map virtual addresses 0160000-0160077 into physical addresses 017777500-017777577. In particular, virtual address 0160060 is the PDP-11 console located at physical address 017777560. .PP This call may only be executed by the super-user. .SH ERRORS .TP 15 [EPERM] The process's effective user ID is not the super-user. .TP 15 [EINVAL] .I Segreg is less than 0 or greater than 7. .TP 15 [EINVAL] .I Size is less than 0 or greater than 128. .SH "SEE ALSO" PDP-11 segmentation hardware .SH BUGS .PP On systems with ENABLE/34(tm) memory mapping boards, \fIphys\fP cannot be used to map in the I/O page. .PP This system call is very dangerous. It is not considered a permanent part of the system. .PP .I Phys is unique to the PDP-11 and 2BSD; its use is discouraged. ================================================ FILE: share/man/man2/pipe.2 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)pipe.2 6.2 (Berkeley) 8/26/85 .\" .TH PIPE 2 "August 26, 1985" .UC 4 .SH NAME pipe \- create an interprocess communication channel .SH SYNOPSIS .nf .ft B pipe(fildes) int fildes[2]; .fi .ft R .SH DESCRIPTION The .I pipe system call creates an I/O mechanism called a pipe. The file descriptors returned can be used in read and write operations. When the pipe is written using the descriptor .IR fildes [1] up to 4096 bytes of data are buffered before the writing process is suspended. A read using the descriptor .IR fildes [0] will pick up the data. .PP It is assumed that after the pipe has been set up, two (or more) cooperating processes (created by subsequent .I fork calls) will pass data through the pipe with .I read and .I write calls. .PP The shell has a syntax to set up a linear array of processes connected by pipes. .PP Read calls on an empty pipe (no buffered data) with only one end (all write file descriptors closed) returns an end-of-file. .PP Pipes are really a special case of the .IR socketpair (2) call and, in fact, are implemented as such in the system. .PP A signal is generated if a write on a pipe with only one end is attempted. .SH "RETURN VALUE The function value zero is returned if the pipe was created; \-1 if an error occurred. .SH ERRORS The \fIpipe\fP call will fail if: .TP 15 [EMFILE] Too many descriptors are active. .TP 15 [ENFILE] The system file table is full. .TP 15 [EFAULT] The \fIfildes\fP buffer is in an invalid area of the process's address space. .SH "SEE ALSO" sh(1), read(2), write(2), fork(2), socketpair(2) .SH BUGS Should more than 4096 bytes be necessary in any pipe among a loop of processes, deadlock will occur. ================================================ FILE: share/man/man2/profil.2 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)profil.2 6.3 (Berkeley) 5/6/87 .\" .TH PROFIL 2 "May 6, 1987" .UC 2 .SH NAME profil \- execution time profile .SH SYNOPSIS .nf .B profil(buff, bufsiz, offset, scale) .B char *buff; .B int bufsiz, offset, scale; .fi .SH DESCRIPTION .I Buff points to an area of core whose length (in bytes) is given by .IR bufsiz . After this call, the user's program counter (pc) is examined each clock tick (VAX and TAHOE: 100 ticks/second = 10 milliseconds per tick; 60 ticks/second ~= 16 milliseconds per tick); .I offset is subtracted from it, and the result multiplied by .IR scale . If the resulting number corresponds to a word inside .I buff, that word is incremented. .PP The scale is interpreted as an unsigned, fixed-point fraction with 16 bits of fraction: 0xffff gives a 1-1 mapping of pc's to words in .I buff; 0x7fff maps each pair of instruction words together. .PP Profiling is turned off by giving a .I scale of 0 or 1. It is rendered ineffective by giving a .I bufsiz of 0. Profiling is turned off when an .I execve is executed, but remains on in child and parent both after a .IR fork . Profiling is turned off if an update in .I buff would cause a memory fault. .SH "RETURN VALUE A 0, indicating success, is always returned. .SH "SEE ALSO" gprof(1), prof(1), setitimer(2), monitor(3) ================================================ FILE: share/man/man2/ptrace.2 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)ptrace.2 6.4 (Berkeley) 5/23/86 .\" .TH PTRACE 2 "May 23, 1986" .UC 4 .SH NAME ptrace \- process trace .SH SYNOPSIS .nf .ft B #include #include .PP .ft B ptrace(request, pid, addr, data) int request, pid, *addr, data; .fi .SH DESCRIPTION .I Ptrace provides a means by which a parent process may control the execution of a child process, and examine and change its core image. Its primary use is for the implementation of breakpoint debugging. There are four arguments whose interpretation depends on a .I request argument. Generally, .I pid is the process ID of the traced process, which must be a child (no more distant descendant) of the tracing process. A process being traced behaves normally until it encounters some signal whether internally generated like \*(lqillegal instruction\*(rq or externally generated like \*(lqinterrupt\*(rq. See .IR sigvec (2) for the list. Then the traced process enters a stopped state and its parent is notified via .IR wait (2). When the child is in the stopped state, its core image can be examined and modified using .IR ptrace . If desired, another .I ptrace request can then cause the child either to terminate or to continue, possibly ignoring the signal. .PP The value of the .I request argument determines the precise action of the call: .TP 4 PT_TRACE_ME This request is the only one used by the child process; it declares that the process is to be traced by its parent. All the other arguments are ignored. Peculiar results will ensue if the parent does not expect to trace the child. .TP 4 PT_READ_I, PT_READ_D The word in the child process's address space at .I addr is returned. If I and D space are separated (e.g. historically on a pdp-11), request PT_READ_I indicates I space, PT_READ_D D space. .I Addr must be even on some machines. The child must be stopped. The input .I data is ignored. .TP 4 PT_READ_U The word of the system's per-process data area corresponding to .I addr is returned. .I Addr must be even on some machines and less than 512. This space contains the registers and other information about the process; its layout corresponds to the .I user structure in the system. .TP 4 PT_WRITE_I, PT_WRITE_D The given .I data is written at the word in the process's address space corresponding to .I addr, which must be even on some machines. No useful value is returned. If I and D space are separated, request PT_WRITE_I indicates I space, PT_WRITE_D D space. Attempts to write in pure procedure fail if another process is executing the same file. .TP 4 PT_WRITE_U The process's system data is written, as it is read with request PT_READ_U. Only a few locations can be written in this way: the general registers, the floating point status and registers, and certain bits of the processor status word. .TP 4 PT_CONTINUE The .I data argument is taken as a signal number and the child's execution continues at location .I addr as if it had incurred that signal. Normally the signal number will be either 0 to indicate that the signal that caused the stop should be ignored, or that value fetched out of the process's image indicating which signal caused the stop. If .I addr is (int *)1 then execution continues from where it stopped. .TP 4 PT_KILL The traced process terminates. .TP 4 PT_STEP Execution continues as in request PT_CONTINUE; however, as soon as possible after execution of at least one instruction, execution stops again. The signal number from the stop is SIGTRAP. (On the VAX-11 the T-bit is used and just one instruction is executed.) This is part of the mechanism for implementing breakpoints. .PP As indicated, these calls (except for request PT_TRACE_ME) can be used only when the subject process has stopped. The .I wait call is used to determine when a process stops; in such a case the \*(lqtermination\*(rq status returned by .I wait has the value 0177 to indicate stoppage rather than genuine termination. .PP To forestall possible fraud, .I ptrace inhibits the set-user-id and set-group-id facilities on subsequent .IR execve (2) calls. If a traced process calls .IR execve , it will stop before executing the first instruction of the new image showing signal SIGTRAP. .PP On a VAX-11, \*(lqword\*(rq also means a 32-bit integer, but the \*(lqeven\*(rq restriction does not apply. .SH "RETURN VALUE A 0 value is returned if the call succeeds. If the call fails then a \-1 is returned and the global variable \fIerrno\fP is set to indicate the error. .SH "ERRORS .TP 15 [EIO] The request code is invalid. .TP 15 [ESRCH] The specified process does not exist. .TP 15 [EIO] The given signal number is invalid. .TP 15 [EIO] The specified address is out of bounds. .TP 15 [EPERM] The specified process cannot be traced. .SH "SEE ALSO" wait(2), sigvec(2), adb(1) .SH "NOTES (PDP-11)" On the PDP-11 the PT_WRITE_U request may also write the child process's current overlay number in the system data area; the T-bit is used to single step the processor and just one instruction is executed for the PT_STEP request; a \*(lqword\*(rq means a 16-bit integer, and the \*(lqeven\*(rq restriction \fIdoes\fP apply. .SH BUGS .I Ptrace is unique and arcane; it should be replaced with a special file that can be opened and read and written. The control functions could then be implemented with .IR ioctl (2) calls on this file. This would be simpler to understand and have much higher performance. .PP The request PT_TRACE_ME call should be able to specify signals that are to be treated normally and not cause a stop. In this way, for example, programs with simulated floating point (which use \*(lqillegal instruction\*(rq signals at a very high rate) could be efficiently debugged. .PP The error indication, \-1, is a legitimate function value; .I errno, (see .IR intro (2)), can be used to disambiguate. .PP It should be possible to stop a process on occurrence of a system call; in this way a completely controlled environment could be provided. ================================================ FILE: share/man/man2/quota.2 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)quota.2 6.7 (Berkeley) 5/15/86 .\" .TH QUOTA 2 "May 15, 1986" .UC 5 .SH NAME quota \- manipulate disk quotas .SH SYNOPSIS .nf .B #include .PP .B quota(cmd, uid, arg, addr) .B int cmd, uid, arg; .B char *addr; .fi .SH DESCRIPTION The .I quota call manipulates disk quotas for file systems that have had quotas enabled with .IR setquota (2). The .I cmd parameter indicates a command to be applied to the user ID .IR uid . .I Arg is a command specific argument and .I addr is the address of an optional, command specific, data structure that is copied in or out of the system. The interpretation of .I arg and .I addr is given with each command below. .TP Q_SETDLIM Set disc quota limits and current usage for the user with ID .IR uid . .I Arg is a major-minor device indicating a particular file system. .I Addr is a pointer to a struct dqblk structure (defined in .RI < sys/quota.h >). This call is restricted to the super-user. .TP Q_GETDLIM Get disc quota limits and current usage for the user with ID .IR uid . The remaining parameters are as for Q_SETDLIM. .TP Q_SETDUSE Set disc usage limits for the user with ID .IR uid . .I Arg is a major-minor device indicating a particular file system. .I Addr is a pointer to a struct dqusage structure (defined in .RI < sys/quota.h >). This call is restricted to the super-user. .TP Q_SYNC Update the on-disc copy of quota usages. .I Arg is a major-minor device indicating the file system to be sync'ed. If the .I arg parameter is specified as NODEV, all file systems that have disc quotas will be sync'ed. The \fIuid\fP and \fIaddr\fP parameters are ignored. .TP Q_SETUID Change the calling process's quota limits to those of the user with ID .IR uid . The .I arg and .I addr parameters are ignored. This call is restricted to the super-user. .TP Q_SETWARN Alter the disc usage warning limits for the user with ID .IR uid . .I Arg is a major-minor device indicating a particular file system. .I Addr is a pointer to a struct dqwarn structure (defined in .RI < sys/quota.h >). This call is restricted to the super-user. .TP Q_DOWARN Warn the user with user ID .I uid about excessive disc usage. This call causes the system to check its current disc usage information and print a message on the terminal of the caller for each file system on which the user is over quota. If the user is under quota, his warning count is reset to MAX_*_WARN (defined in .RI < sys/quota.h >). If the .I arg parameter is specified as NODEV, all file systems that have disc quotas will be checked. Otherwise, .I arg indicates a specific major-minor device to be checked. This call is restricted to the super-user. .SH "RETURN VALUE" A successful call returns 0, otherwise the value \-1 is returned and the global variable .I errno indicates the reason for the failure. .SH ERRORS A \fIquota\fP call will fail when one of the following occurs: .TP 15 [EINVAL] The kernel has not been compiled with the QUOTA option. .TP 15 [EINVAL] .I Cmd is invalid. .TP 15 [ESRCH] No disc quota is found for the indicated user. .TP 15 [EPERM] The call is priviledged and the caller was not the super-user. .TP 15 [ENODEV] The .I arg parameter is being interpreted as a major-minor device and it indicates an unmounted file system. .TP 15 [EFAULT] An invalid .I addr is supplied; the associated structure could not be copied in or out of the kernel. .TP 15 [EUSERS] The quota table is full. .SH "SEE ALSO" setquota(2), quotaon(8), quotacheck(8) .SH BUGS There should be some way to integrate this call with the resource limit interface provided by .IR setrlimit (2) and .IR getrlimit (2). .PP The Australian spelling of .I disk is used throughout the quota facilities in honor of the implementors. ================================================ FILE: share/man/man2/read.2 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)read.2 6.6 (Berkeley) 8/1/87 .\" .TH READ 2 "August 1, 1987" .UC 4 .SH NAME read, readv \- read input .SH SYNOPSIS .nf .ft B cc = read(d, buf, nbytes) int cc, d; char *buf; unsigned short nbytes; .PP .ft B #include #include .PP .ft B cc = readv(d, iov, iovcnt) int cc, d; struct iovec *iov; int iovcnt; .fi .SH DESCRIPTION .I Read attempts to read .I nbytes of data from the object referenced by the descriptor .I d into the buffer pointed to by .IR buf . .I Readv performs the same action, but scatters the input data into the .I iovcnt buffers specified by the members of the .I iov array: iov[0], iov[1], ..., iov[iovcnt\|\-\|1]. .PP For .IR readv , the .I iovec structure is defined as .PP .nf .RS .DT struct iovec { caddr_t iov_base; u_short iov_len; }; .RE .fi .PP Each .I iovec entry specifies the base address and length of an area in memory where data should be placed. .I Readv will always fill an area completely before proceeding to the next. .PP On objects capable of seeking, the .I read starts at a position given by the pointer associated with .IR d (see .IR lseek (2)). Upon return from .IR read , the pointer is incremented by the number of bytes actually read. .PP Objects that are not capable of seeking always read from the current position. The value of the pointer associated with such an object is undefined. .PP Upon successful completion, .I read and .I readv return the number of bytes actually read and placed in the buffer. The system guarantees to read the number of bytes requested if the descriptor references a normal file that has that many bytes left before the end-of-file, but in no other case. .PP If the returned value is 0, then end-of-file has been reached. .SH "RETURN VALUE If successful, the number of bytes actually read is returned. Otherwise, a \-1 is returned and the global variable .I errno is set to indicate the error. .SH "ERRORS .I Read and .I readv will fail if one or more of the following are true: .TP 15 [EBADF] \fID\fP is not a valid file or socket descriptor open for reading. .TP 15 [EFAULT] \fIBuf\fP points outside the allocated address space. .TP 15 [EIO] An I/O error occurred while reading from the file system. .TP 15 [EINTR] A read from a slow device was interrupted before any data arrived by the delivery of a signal. .TP 15 [EINVAL] The pointer associated with .I d was negative. .TP 15 [EWOULDBLOCK] The file was marked for non-blocking I/O, and no data were ready to be read. .PP In addition, .I readv may return one of the following errors: .TP 15 [EINVAL] .I Iovcnt was less than or equal to 0, or greater than 16. .TP 15 [EINVAL] The sum of the .I iov_len values in the .I iov array overflowed a short. .TP 15 [EFAULT] Part of the \fIiov\fP points outside the process's allocated address space. .SH "SEE ALSO" dup(2), fcntl(2), open(2), pipe(2), select(2), socket(2), socketpair(2) ================================================ FILE: share/man/man2/readlink.2 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)readlink.2 6.4 (Berkeley) 8/26/85 .\" .TH READLINK 2 "August 26, 1985" .UC 5 .SH NAME readlink \- read value of a symbolic link .SH SYNOPSIS .nf .ft B cc = readlink(path, buf, bufsiz) int cc; char *path, *buf; int bufsiz; .fi .ft R .SH DESCRIPTION .I Readlink places the contents of the symbolic link .I name in the buffer .I buf, which has size .IR bufsiz . The contents of the link are not null terminated when returned. .SH "RETURN VALUE The call returns the count of characters placed in the buffer if it succeeds, or a \-1 if an error occurs, placing the error code in the global variable \fIerrno\fP. .SH "ERRORS .I Readlink will fail and the file mode will be unchanged if: .TP 15 [ENOTDIR] A component of the path prefix is not a directory. .TP 15 [EINVAL] The pathname contains a character with the high-order bit set. .TP 15 [ENAMETOOLONG] A component of a pathname exceeded 255 characters, or an entire path name exceeded 1023 characters. .TP 15 [ENOENT] The named file does not exist. .TP 15 [EACCES] Search permission is denied for a component of the path prefix. .TP 15 [ELOOP] Too many symbolic links were encountered in translating the pathname. .TP 15 [EINVAL] The named file is not a symbolic link. .TP 15 [EIO] An I/O error occurred while reading from the file system. .TP 15 [EFAULT] .I Buf extends outside the process's allocated address space. .SH SEE ALSO stat(2), lstat(2), symlink(2) ================================================ FILE: share/man/man2/reboot.2 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)reboot.2 6.1 (Berkeley) 5/9/85 .\" .TH REBOOT 2 "May 9, 1985" .UC 4 .SH NAME reboot \- reboot system or halt processor .SH SYNOPSIS .nf .B #include .PP .B reboot(howto) .B int howto; .fi .SH DESCRIPTION .I Reboot reboots the system, and is invoked automatically in the event of unrecoverable system failures. .I Howto is a mask of options passed to the bootstrap program. The system call interface permits only RB_HALT or RB_AUTOBOOT to be passed to the reboot program; the other flags are used in scripts stored on the console storage media, or used in manual bootstrap procedures. When none of these options (e.g. RB_AUTOBOOT) is given, the system is rebooted from file \*(lqvmunix\*(rq in the root file system of unit 0 of a disk chosen in a processor specific way. An automatic consistency check of the disks is then normally performed. .PP The bits of .I howto are: .TP RB_HALT the processor is simply halted; no reboot takes place. RB_HALT should be used with caution. .TP RB_ASKNAME Interpreted by the bootstrap program itself, causing it to inquire as to what file should be booted. Normally, the system is booted from the file \*(lqxx(0,0)vmunix\*(rq without asking. .TP RB_SINGLE Normally, the reboot procedure involves an automatic disk consistency check and then multi-user operations. RB_SINGLE prevents the consistency check, rather simply booting the system with a single-user shell on the console. RB_SINGLE is interpreted by the .IR init (8) program in the newly booted system. This switch is not available from the system call interface. .PP Only the super-user may .I reboot a machine. .SH "RETURN VALUES" If successful, this call never returns. Otherwise, a \-1 is returned and an error is returned in the global variable .IR errno . .SH ERRORS .TP 15 [EPERM] The caller is not the super-user. .SH "SEE ALSO" crash(8), halt(8), init(8), reboot(8) .SH BUGS The notion of ``console medium'', among other things, is specific to the VAX. ================================================ FILE: share/man/man2/recv.2 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)recv.2 6.3 (Berkeley) 5/23/86 .\" .TH RECV 2 "May 23, 1986" .UC 5 .SH NAME recv, recvfrom, recvmsg \- receive a message from a socket .SH SYNOPSIS .nf .ft B #include #include .PP .ft B cc = recv(s, buf, len, flags) int cc, s; char *buf; int len, flags; .PP .ft B cc = recvfrom(s, buf, len, flags, from, fromlen) int cc, s; char *buf; int len, flags; struct sockaddr *from; int *fromlen; .PP .ft B cc = recvmsg(s, msg, flags) int cc, s; struct msghdr msg[]; int flags; .ft R .SH DESCRIPTION .IR Recv , .IR recvfrom , and .IR recvmsg are used to receive messages from a socket. .PP The .I recv call is normally used only on a .I connected socket (see .IR connect (2)), while .I recvfrom and .I recvmsg may be used to receive data on a socket whether it is in a connected state or not. .PP If .I from is non-zero, the source address of the message is filled in. .I Fromlen is a value-result parameter, initialized to the size of the buffer associated with .IR from , and modified on return to indicate the actual size of the address stored there. The length of the message is returned in .IR cc . If a message is too long to fit in the supplied buffer, excess bytes may be discarded depending on the type of socket the message is received from (see .IR socket (2)). .PP If no messages are available at the socket, the receive call waits for a message to arrive, unless the socket is nonblocking (see .IR ioctl (2)) in which case a .I cc of \-1 is returned with the external variable errno set to EWOULDBLOCK. .PP The .IR select (2) call may be used to determine when more data arrives. .PP The .I flags argument to a recv call is formed by .IR or 'ing one or more of the values, .PP .nf .RS .ta \w'#define\ \ 'u +\w'MSG_DONTROUTE\ \ \ 'u +\w'0x\0\0\0\ \ 'u #define MSG_OOB 0x1 /* process out-of-band data */ #define MSG_PEEK 0x2 /* peek at incoming message */ .RE .fi .PP The .I recvmsg call uses a .I msghdr structure to minimize the number of directly supplied parameters. This structure has the following form, as defined in .IR : .PP .nf .RS .DT struct msghdr { caddr_t msg_name; /* optional address */ int msg_namelen; /* size of address */ struct iovec *msg_iov; /* scatter/gather array */ int msg_iovlen; /* # elements in msg_iov */ caddr_t msg_accrights; /* access rights sent/received */ int msg_accrightslen; }; .RE .fi .PP Here .I msg_name and .I msg_namelen specify the destination address if the socket is unconnected; .I msg_name may be given as a null pointer if no names are desired or required. The .I msg_iov and .I msg_iovlen describe the scatter gather locations, as described in .IR read (2). A buffer to receive any access rights sent along with the message is specified in .IR msg_accrights , which has length .IR msg_accrightslen . Access rights are currently limited to file descriptors, which each occupy the size of an .BR int . .SH "RETURN VALUE These calls return the number of bytes received, or \-1 if an error occurred. .SH ERRORS The calls fail if: .TP 20 [EBADF] The argument \fIs\fP is an invalid descriptor. .TP 20 [ENOTSOCK] The argument \fIs\fP is not a socket. .TP 20 [EWOULDBLOCK] The socket is marked non-blocking and the receive operation would block. .TP 20 [EINTR] The receive was interrupted by delivery of a signal before any data was available for the receive. .TP 20 [EFAULT] The data was specified to be received into a non-existent or protected part of the process address space. .SH SEE ALSO fcntl(2), read(2), send(2), select(2), getsockopt(2), socket(2) ================================================ FILE: share/man/man2/rename.2 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)rename.2 6.4 (Berkeley) 5/22/86 .\" .TH RENAME 2 "May 22, 1986" .UC 5 .SH NAME rename \- change the name of a file .SH SYNOPSIS .ft B .nf rename(from, to) char *from, *to; .fi .ft R .SH DESCRIPTION .I Rename causes the link named .I from to be renamed as .IR to . If .I to exists, then it is first removed. Both .I from and .I to must be of the same type (that is, both directories or both non-directories), and must reside on the same file system. .PP .I Rename guarantees that an instance of .I to will always exist, even if the system should crash in the middle of the operation. .PP If the final component of .I from is a symbolic link, the symbolic link is renamed, not the file or directory to which it points. .SH CAVEAT The system can deadlock if a loop in the file system graph is present. This loop takes the form of an entry in directory \*(lqa\*(rq, say \*(lqa/foo\*(rq, being a hard link to directory \*(lqb\*(rq, and an entry in directory \*(lqb\*(rq, say \*(lqb/bar\*(rq, being a hard link to directory \*(lqa\*(rq. When such a loop exists and two separate processes attempt to perform \*(lqrename a/foo b/bar\*(rq and \*(lqrename b/bar a/foo\*(rq, respectively, the system may deadlock attempting to lock both directories for modification. Hard links to directories should be replaced by symbolic links by the system administrator. .SH "RETURN VALUE" A 0 value is returned if the operation succeeds, otherwise .I rename returns \-1 and the global variable .I errno indicates the reason for the failure. .SH "ERRORS .I Rename will fail and neither of the argument files will be affected if any of the following are true: .TP 15 [EINVAL] Either pathname contains a character with the high-order bit set. .TP 15 [ENAMETOOLONG] A component of either pathname exceeded 255 characters, or the entire length of either path name exceeded 1023 characters. .TP 15 [ENOENT] A component of the \fIfrom\fP path does not exist, or a path prefix of \FIto\fP does not exist. .TP 15 [EACCES] A component of either path prefix denies search permission. .TP 15 [EACCES] The requested link requires writing in a directory with a mode that denies write permission. .TP 15 [EPERM] The directory containing \fIfrom\fP is marked sticky, and neither the containing directory nor \fIfrom\fP are owned by the effective user ID. .TP 15 [EPERM] The \fIto\fP file exists, the directory containing \fIto\fP is marked sticky, and neither the containing directory nor \fIto\fP are owned by the effective user ID. .TP 15 [ELOOP] Too many symbolic links were encountered in translating either pathname. .TP 15 [ENOTDIR] A component of either path prefix is not a directory. .TP 15 [ENOTDIR] .I From is a directory, but \fIto\fP is not a directory. .TP 15 [EISDIR] .I To is a directory, but \fIfrom\fP is not a directory. .TP 15 [EXDEV] The link named by \fIto\fP and the file named by \fIfrom\fP are on different logical devices (file systems). Note that this error code will not be returned if the implementation permits cross-device links. .TP 15 [ENOSPC] The directory in which the entry for the new name is being placed cannot be extended because there is no space left on the file system containing the directory. .TP 15 [EDQUOT] The directory in which the entry for the new name is being placed cannot be extended because the user's quota of disk blocks on the file system containing the directory has been exhausted. .TP 15 [EIO] An I/O error occurred while making or updating a directory entry. .TP 15 [EROFS] The requested link requires writing in a directory on a read-only file system. .TP 15 [EFAULT] .I Path points outside the process's allocated address space. .TP 15 [EINVAL] .I From is a parent directory of .IR to , or an attempt is made to rename ``.'' or ``..''. .TP 15 [ENOTEMPTY] .I To is a directory and is not empty. .SH "SEE ALSO" open(2) ================================================ FILE: share/man/man2/rmdir.2 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)rmdir.2 6.3 (Berkeley) 8/26/85 .\" .TH RMDIR 2 "August 26, 1985" .UC 5 .SH NAME rmdir \- remove a directory file .SH SYNOPSIS .nf .ft B rmdir(path) char *path; .fi .ft R .SH DESCRIPTION .I Rmdir removes a directory file whose name is given by .I path. The directory must not have any entries other than \*(lq.\*(rq and \*(lq..\*(rq. .SH "RETURN VALUE A 0 is returned if the remove succeeds; otherwise a \-1 is returned and an error code is stored in the global location \fIerrno\fP\|. .SH ERRORS The named file is removed unless one or more of the following are true: .TP 15 [ENOTDIR] A component of the path is not a directory. .TP 15 [EINVAL] The pathname contains a character with the high-order bit set. .TP 15 [ENAMETOOLONG] A component of a pathname exceeded 255 characters, or an entire path name exceeded 1023 characters. .TP 15 [ENOENT] The named directory does not exist. .TP 15 [ELOOP] Too many symbolic links were encountered in translating the pathname. .TP 15 [ENOTEMPTY] The named directory contains files other than ``.'' and ``..'' in it. .TP 15 [EACCES] Search permission is denied for a component of the path prefix. .TP 15 [EACCES] Write permission is denied on the directory containing the link to be removed. .TP 15 [EPERM] The directory containing the directory to be removed is marked sticky, and neither the containing directory nor the directory to be removed are owned by the effective user ID. .TP 15 [EBUSY] The directory to be removed is the mount point for a mounted file system. .TP 15 [EIO] An I/O error occurred while deleting the directory entry or deallocating the inode. .TP 15 [EROFS] The directory entry to be removed resides on a read-only file system. .TP 15 [EFAULT] .I Path points outside the process's allocated address space. .SH "SEE ALSO" mkdir(2), unlink(2) ================================================ FILE: share/man/man2/select.2 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)select.2 6.5.2 (2.11BSD) 2000/3/4 .\" .TH SELECT 2 "March 4, 2000" .UC 5 .SH NAME pselect, select \- synchronous I/O multiplexing .SH SYNOPSIS .nf .ft B #include #include #include #include .PP .ft B nfound = pselect(nfds, readfds, writefds, exceptfds, timeout, sigmask); int nfound, nfds; fd_set *readfds, *writefds, *exceptfds; struct timespec *timeout; sigset_t *sigmask; .PP .ft B nfound = select(nfds, readfds, writefds, exceptfds, timeout) int nfound, nfds; fd_set *readfds, *writefds, *exceptfds; struct timeval *timeout; .PP .ft B FD_SET(fd, &fdset) FD_CLR(fd, &fdset) FD_ISSET(fd, &fdset) FD_ZERO(&fdset) int fd; fd_set fdset; .fi .SH DESCRIPTION .I Pselect and .I select examine the I/O descriptor sets whose addresses are passed in .IR readfds , .IR writefds , and .I exceptfds to see if some of their descriptors are ready for reading, are ready for writing, or have an exceptional condition pending, respectively. The two functions are identical except for the type and format of the .I timeout value, and the additonal .I sigmask parameter supplied to the .IR pselect () call. .PP The first .I nfds descriptors are checked in each set; i.e. the descriptors from 0 through .IR nfds -1 in the descriptor sets are examined. On return, .I select replaces the given descriptor sets with subsets consisting of those descriptors that are ready for the requested operation. The total number of ready descriptors in all the sets is returned in .IR nfound . .PP The descriptor sets are stored as bit fields in arrays of integers. The following macros are provided for manipulating such descriptor sets: .I "FD_ZERO(&fdset)" initializes a descriptor set .I fdset to the null set. .I "FD_SET(fd, &fdset)" includes a particular descriptor .I fd in .IR fdset . .I "FD_CLR(fd, &fdset)" removes .I fd from .IR fdset . .I "FD_ISSET(fd, &fdset)" is nonzero if .I fd is a member of .IR fdset , zero otherwise. The behavior of these macros is undefined if a descriptor value is less than zero or greater than or equal to .IR FD_SETSIZE , which is normally at least equal to the maximum number of descriptors supported by the system. .PP If .I timeout is a non-zero pointer, it specifies a maximum interval to wait for the selection to complete. If .I timeout is a zero pointer, .I select blocks indefinitely. To affect a poll, the .I timeout argument should be non-zero, pointing to a zero-valued timeval structure. .PP If the .I sigmask parameter to .IR pselect () is not NULL, it points to a signal mask that replaces the previous signal mask for the process for the duration of the call, and the previous mask is restored upon return; see sigprocmask(3). This is normally used so that signals can be blocked while preparing for a call to .IR pselect () and then atomically unblocking the signals while selecting. .PP Any of .IR readfds , .IR writefds , and .I exceptfds may be given as zero pointers if no descriptors are of interest. .SH "RETURN VALUE .I Select returns the number of ready descriptors that are contained in the descriptor sets, or \-1 if an error occurred. If the time limit expires then .I select returns 0. If .I select returns with an error, including one due to an interrupted call, the descriptor sets will be unmodified. .SH "ERRORS An error return from \fIselect\fP indicates: .TP 15 [EBADF] One of the descriptor sets specified an invalid descriptor. .TP 15 [EINTR] A signal was delivered before the time limit expired and before any of the selected events occurred. .TP 15 [EINVAL] The specified time limit is invalid. One of its components is negative or too large. .SH SEE ALSO accept(2), connect(2), read(2), write(2), recv(2), send(2), getdtablesize(2) .SH BUGS Although the provision of .IR getdtablesize (2) was intended to allow user programs to be written independent of the kernel limit on the number of open files, the dimension of a sufficiently large bit field for select remains a problem. The default size FD_SETSIZE (currently 256) is somewhat larger than the current kernel limit to the number of open files. However, in order to accommodate programs which might potentially use a larger number of open files with select, it is possible to increase this size within a program by providing a larger definition of FD_SETSIZE before the inclusion of . .PP .I Select should probably return the time remaining from the original timeout, if any, by modifying the time value in place. This may be implemented in future versions of the system. Thus, it is unwise to assume that the timeout value will be unmodified by the .I select call. .PP In 2BSD the timeout is implemented in the kernel using the \fIcallout\fP table. Since a \fIcallout\fP structure only has a signed short to store the number of ticks till expiration the maximum value of a kernel timeout is 32767 ticks. In the US (60hz power) this gives a maximum timeout of approximately 9 minutes. In countries using 50hz power the maximum timeout is about 13 minutes. .PP .I struct timespec on a PDP\-11 is silly since the hardware has nowhere near microsecond much less nanosecond clock resolution. ================================================ FILE: share/man/man2/send.2 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)send.2 6.3 (Berkeley) 5/14/86 .\" .TH SEND 2 "May 14, 1986" .UC 5 .SH NAME send, sendto, sendmsg \- send a message from a socket .SH SYNOPSIS .nf .ft B #include #include .PP .ft B cc = send(s, msg, len, flags) int cc, s; char *msg; int len, flags; .PP .ft B cc = sendto(s, msg, len, flags, to, tolen) int cc, s; char *msg; int len, flags; struct sockaddr *to; int tolen; .PP .ft B cc = sendmsg(s, msg, flags) int cc, s; struct msghdr msg[]; int flags; .fi .SH DESCRIPTION .IR Send , .IR sendto , and .I sendmsg are used to transmit a message to another socket. .I Send may be used only when the socket is in a .I connected state, while .I sendto and .I sendmsg may be used at any time. .PP The address of the target is given by .I to with .I tolen specifying its size. The length of the message is given by .IR len . If the message is too long to pass atomically through the underlying protocol, then the error EMSGSIZE is returned, and the message is not transmitted. .PP No indication of failure to deliver is implicit in a .IR send . Return values of \-1 indicate some locally detected errors. .PP If no messages space is available at the socket to hold the message to be transmitted, then .I send normally blocks, unless the socket has been placed in non-blocking I/O mode. The .IR select (2) call may be used to determine when it is possible to send more data. .PP The .I flags parameter may include one or more of the following: .PP .nf .RS .ta \w'#define\ \ 'u +\w'MSG_DONTROUTE\ \ \ 'u +\w'0x\0\0\0\ \ 'u #define MSG_OOB 0x1 /* process out-of-band data */ #define MSG_DONTROUTE 0x4 /* bypass routing, use direct interface */ .RE .fi The flag MSG_OOB is used to send \*(lqout-of-band\*(rq data on sockets that support this notion (e.g. SOCK_STREAM); the underlying protocol must also support \*(lqout-of-band\*(rq data. MSG_DONTROUTE is usually used only by diagnostic or routing programs. .PP See .IR recv (2) for a description of the .I msghdr structure. .SH "RETURN VALUE The call returns the number of characters sent, or \-1 if an error occurred. .SH "ERRORS .TP 20 [EBADF] An invalid descriptor was specified. .TP 20 [ENOTSOCK] The argument \fIs\fP is not a socket. .TP 20 [EFAULT] An invalid user space address was specified for a parameter. .TP 20 [EMSGSIZE] The socket requires that message be sent atomically, and the size of the message to be sent made this impossible. .TP 20 [EWOULDBLOCK] The socket is marked non-blocking and the requested operation would block. .TP 20 [ENOBUFS] The system was unable to allocate an internal buffer. The operation may succeed when buffers become available. .TP 20 [ENOBUFS] The output queue for a network interface was full. This generally indicates that the interface has stopped sending, but may be caused by transient congestion. .SH SEE ALSO fcntl(2), recv(2), select(2), getsockopt(2), socket(2), write(2) ================================================ FILE: share/man/man2/setgroups.2 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)setgroups.2 6.3 (Berkeley) 5/13/86 .\" .TH SETGROUPS 2 "May 13, 1986" .UC 5 .SH NAME setgroups \- set group access list .SH SYNOPSIS .nf .ft B #include .PP .ft B setgroups(ngroups, gidset) int ngroups, *gidset; .fi .SH DESCRIPTION .I Setgroups sets the group access list of the current user process according to the array .IR gidset . The parameter .I ngroups indicates the number of entries in the array and must be no more than NGROUPS, as defined in .RI < sys/param.h >. .PP Only the super-user may set new groups. .SH "RETURN VALUE A 0 value is returned on success, \-1 on error, with a error code stored in \fIerrno\fP. .SH "ERRORS The \fIsetgroups\fP call will fail if: .TP 15 [EPERM] The caller is not the super-user. .TP 15 [EFAULT] The address specified for \fIgidset\fP is outside the process address space. .SH "SEE ALSO getgroups(2), initgroups(3X) .SH BUGS The .I gidset array should be of type .BR gid_t , but remains integer for compatibility with earlier systems. ================================================ FILE: share/man/man2/setpgrp.2 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)setpgrp.2 6.1 (Berkeley) 5/9/85 .\" .TH SETPGRP 2 "May 9, 1985" .UC 4 .SH NAME setpgrp \- set process group .SH SYNOPSIS .ft B setpgrp(pid, pgrp) .br int pid, pgrp; .ft R .SH DESCRIPTION .I Setpgrp sets the process group of the specified process .I pid to the specified .IR pgrp . If .I pid is zero, then the call applies to the current process. .PP If the invoker is not the super-user, then the affected process must have the same effective user-id as the invoker or be a descendant of the invoking process. .SH "RETURN VALUE .I Setpgrp returns when the operation was successful. If the request failed, \-1 is returned and the global variable .I errno indicates the reason. .SH ERRORS .I Setpgrp will fail and the process group will not be altered if one of the following occur: .TP 15 [ESRCH] The requested process does not exist. .TP 15 [EPERM] The effective user ID of the requested process is different from that of the caller and the process is not a descendent of the calling process. .SH "SEE ALSO" getpgrp(2) ================================================ FILE: share/man/man2/setquota.2 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)setquota.2 6.4 (Berkeley) 8/26/85 .\" .TH SETQUOTA 2 "August 26, 1985" .UC 5 .SH NAME setquota \- enable/disable quotas on a file system .SH SYNOPSIS .nf .B setquota(special, file) .B char *special, *file; .fi .SH DESCRIPTION Disc quotas are enabled or disabled with the .I setquota call. .I Special indicates a block special device on which a mounted file system exists. If .I file is nonzero, it specifies a file in that file system from which to take the quotas. If .I file is 0, then quotas are disabled on the file system. The quota file must exist; it is normally created with the .IR quotacheck (8) program. .PP Only the super-user may turn quotas on or off. .SH "SEE ALSO" quota(2), quotacheck(8), quotaon(8) .SH "RETURN VALUE" A 0 return value indicates a successful call. A value of \-1 is returned when an error occurs and .I errno is set to indicate the reason for failure. .SH ERRORS .I Setquota will fail when one of the following occurs: .TP 15 [ENOTDIR] A component of either path prefix is not a directory. .TP 15 [EINVAL] Either pathname contains a character with the high-order bit set. .TP 15 [EINVAL] The kernel has not been compiled with the QUOTA option. .TP 15 [ENAMETOOLONG] A component of either pathname exceeded 255 characters, or the entire length of either path name exceeded 1023 characters. .TP 15 [ENODEV] .I Special does not exist. .TP 15 [ENOENT] .I File does not exist. .TP 15 [ELOOP] Too many symbolic links were encountered in translating either pathname. .TP 15 [EPERM] The caller is not the super-user. .TP 15 [ENOTBLK] .I Special is not a block device. .TP 15 [ENXIO] The major device number of .I special is out of range (this indicates no device driver exists for the associated hardware). .TP 15 [EROFS] .I File resides on a read-only file system. .TP 15 [EACCES] Search permission is denied for a component of either path prefix. .TP 15 [EACCES] .I File resides on a file system different from .IR special . .TP 15 [EACCES] .I File is not a plain file. .TP 15 [EIO] An I/O error occurred while reading from or writing to the file containing the quotas. .TP 15 [EFAULT] .I Special or \fIpath\fP points outside the process's allocated address space. .SH BUGS The error codes are in a state of disarray; too many errors appear to the caller as one value. ================================================ FILE: share/man/man2/setregid.2 ================================================ .\" Copyright (c) 1980, 1991, 1993, 1994 .\" The Regents of the University of California. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. All advertising materials mentioning features or use of this software .\" must display the following acknowledgement: .\" This product includes software developed by the University of .\" California, Berkeley and its contributors. .\" 4. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)setregid.2 8.2.1 (2.11BSD) 1997/12/2 .\" .TH SETREGID 2 "December 2, 1997" .UC 5 .SH NAME \fBsetregid\fP \- set real and effective group ID .SH SYNOPSIS .B #include .sp .nf \fIint\fP \fBsetregid(rgid, egid)\fP \ \ \ \ \ gid_t rgid, egid .fi .SH DESCRIPTION The real and effective group ID's of the current process are set to the arguments. Unprivileged users may change the real group ID to the effective group ID and vice-versa; only the super-user may make other changes. .PP Supplying a value of -1 for either the real or effective group ID forces the system to substitute the current ID in place of the -1 parameter. .PP The .B setregid function was intended to allow swapping the real and effective group IDs in set-group-ID programs to temporarily relinquish the set-group-ID value. This function did not work correctly, and its purpose is now better served by the use of the .B setegid function (see setuid(2)). .PP When setting the real and effective group IDs to the same value, the standard .B setgid function is preferred. .SH RETURN VALUES Upon successful completion, a value of 0 is returned. Otherwise, a value of -1 is returned and .I errno is set to indicate the error. .SH ERRORS .TP 10 EPERM The current process is not the super-user and a change other than changing the effective group-id to the real group-id was specified. .SH SEE ALSO getgid(2), setegid(2), setgid(2), setuid(2) .SH HISTORY The .B setregid function call appeared in 4.2BSD and was dropped in 4.4BSD. ================================================ FILE: share/man/man2/setreuid.2 ================================================ .\" Copyright (c) 1980, 1991, 1993, 1994 .\" The Regents of the University of California. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. All advertising materials mentioning features or use of this software .\" must display the following acknowledgement: .\" This product includes software developed by the University of .\" California, Berkeley and its contributors. .\" 4. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)setreuid.2 8.2.1 (2.11BSD) 1997/12/3 .\" .TH SETREUID 2 "December 3, 1997" .UC 4 .SH NAME \fBsetreuid\fP \- set real and effective user ID's .SH SYNOPSIS .B #include .nf .sp \fIint\fP \fBsetreuid\fP(ruid, euid) \ \ \ \ uid_t ruid, euid .fi .SH DESCRIPTION The real and effective user IDs of the current process are set according to the arguments. If .I ruid or .I euid is -1, the current uid is filled in by the system. Unprivileged users may change the real user ID to the effective user ID and vice-versa; only the super-user may make other changes. .PP The .B setreuid function has been used to swap the real and effective user IDs in set-user-ID programs to temporarily relinquish the set-user-ID value. This purpose is now better served by the use of the .B seteuid function (see setuid(2)). .PP When setting the real and effective user IDs to the same value, the standard .B setuid function is preferred. .SH RETURN VALUES Upon successful completion, a value of 0 is returned. Otherwise, a value of -1 is returned and .I errno is set to indicate the error. .SH ERRORS .TP 10 EPERM The current process is not the super-user and a change other than changing the effective user-id to the real user-id was specified. .SH SEE ALSO getuid(2), seteuid(2), setuid(2) .SH HISTORY The .B setreuid function call appeared in 4.2BSD and was dropped in 4.4BSD. ================================================ FILE: share/man/man2/setuid.2 ================================================ .\" Copyright (c) 1983, 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. All advertising materials mentioning features or use of this software .\" must display the following acknowledgement: .\" This product includes software developed by the University of .\" California, Berkeley and its contributors. .\" 4. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)setuid.2 8.1.1 (2.11BSD) 1997/12/3 .\" .TH SETUID 2 "December 3, 1997" .UC 5 .SH NAME \fBsetuid\fP, \fBseteuid\fP,\fBsetgid\fP,\fBsetegid\fP \- set user and group ID .SH SYNOPSIS .nf .B #include .B #include .sp \fIint\fP \fBsetuid\fP(uid) \ \ \ \ uid_t uid .sp \fIint\fP \fBseteuid\fP(euid) \ \ \ \ uid_t euid .sp \fIint\fP \fBsetgid\fP(gid) \ \ \ \ gid_t gid .sp \fIint\fP \fBsetegid\fP(egid) \ \ \ \ gid_t egid .fi .SH DESCRIPTION The .B setuid function sets the real and effective user IDs and the saved set-user-ID of the current process to the specified value. The .B setuid function is permitted if the specified ID is equal to the real user ID of the process, or if the effective user ID is that of the super user. .PP The .B setgid function sets the real and effective group IDs and the saved set-group-ID of the current process to the specified value. The .B setgid function is permitted if the specified ID is equal to the real group ID of the process, or if the effective user ID is that of the super user. .PP The .B seteuid function (\fBsetegid\fP) sets the effective user ID (group ID) of the current process. The effective user ID may be set to the value of the real user ID or the saved set-user-ID (see intro(2) and execve(2); in this way, the effective user ID of a set-user-ID executable may be toggled by switching to the real user ID, then re-enabled by reverting to the set-user-ID value. Similarly, the effective group ID may be set to the value of the real group ID or the saved set-user-ID. .PP .SH RETURN VALUES Upon success, these functions return 0; otherwise \-1 is returned. .PP If the user is not the super user, or the uid specified is not the real, effective ID, or saved ID, these functions return \-1. .SH SEE ALSO getuid(2), getgid(2) .SH STANDARDS The .B setuid and .B setgid functions are compliant with the IEEE Std 1003.1-1988 (``POSIX'') specification with _POSIX_SAVED_IDS not defined. The .B seteuid and .B setegid functions are extensions based on the POSIX concept of _POSIX_SAVED_IDS , and have been proposed for a future revision of the standard. ================================================ FILE: share/man/man2/shutdown.2 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)shutdown.2 6.1 (Berkeley) 5/15/85 .\" .TH SHUTDOWN 2 "May 15, 1985" .UC 5 .SH NAME shutdown \- shut down part of a full-duplex connection .SH SYNOPSIS .nf .ft B shutdown(s, how) int s, how; .fi .SH DESCRIPTION The .I shutdown call causes all or part of a full-duplex connection on the socket associated with .I s to be shut down. If \fIhow\fP is 0, then further receives will be disallowed. If \fIhow\fP is 1, then further sends will be disallowed. If \fIhow\fP is 2, then further sends and receives will be disallowed. .SH DIAGNOSTICS A 0 is returned if the call succeeds, \-1 if it fails. .SH ERRORS The call succeeds unless: .TP 15 [EBADF] .I S is not a valid descriptor. .TP 15 [ENOTSOCK] .I S is a file, not a socket. .TP 15 [ENOTCONN] The specified socket is not connected. .SH "SEE ALSO" connect(2), socket(2) ================================================ FILE: share/man/man2/sigaction.2 ================================================ .\" Copyright (c) 1980, 1990, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. All advertising materials mentioning features or use of this software .\" must display the following acknowledgement: .\" This product includes software developed by the University of .\" California, Berkeley and its contributors. .\" 4. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)sigaction.2 8.2.1 (2.11BSD) 1997/9/3 .\" .TH SIGACTION 2 "September 3, 1997" .UC 7 .SH NAME \fBsigaction\fP \- software signal facilities .SH SYNOPSIS .B #include .sp .nf struct sigaction { int (*sa_handler)(); sigset_t sa_mask; int sa_flags; }; .fi .sp \fBsigaction\fP(sig, act, oact) .br .I int sig; .br .I struct sigaction *act; .br .I struct sigaction *oact; .SH DESCRIPTION The system defines a set of signals that may be delivered to a process. Signal delivery resembles the occurrence of a hardware interrupt: the signal is blocked from further occurrence, the current process context is saved, and a new one is built. A process may specify a .I handler to which a signal is delivered, or specify that a signal is to be .IR ignored . A process may also specify that a default action is to be taken by the system when a signal occurs. A signal may also be .IR blocked , in which case its delivery is postponed until it is .IR unblocked . The action to be taken on delivery is determined at the time of delivery. Normally, signal handlers execute on the current stack of the process. This may be changed, on a per-handler basis, so that signals are taken on a special .IR "signal stack" . .PP Signal routines execute with the signal that caused their invocation .IR blocked , but other signals may yet occur. A global .IR "signal mask" defines the set of signals currently blocked from delivery to a process. The signal mask for a process is initialized from that of its parent (normally empty). It may be changed with a .BR sigprocmask (2) call, or when a signal is delivered to the process. .PP When a signal condition arises for a process, the signal is added to a set of signals pending for the process. If the signal is not currently .I blocked by the process then it is delivered to the process. Signals may be delivered any time a process enters the operating system (e.g., during a system call, page fault or trap, or clock interrupt). If multiple signals are ready to be delivered at the same time, any signals that could be caused by traps are delivered first. Additional signals may be processed at the same time, with each appearing to interrupt the handlers for the previous signals before their first instructions. The set of pending signals is returned by the .BR sigpending (2) function. When a caught signal is delivered, the current state of the process is saved, a new signal mask is calculated (as described below), and the signal handler is invoked. The call to the handler is arranged so that if the signal handling routine returns normally the process will resume execution in the context from before the signal's delivery. If the process wishes to resume in a different context, then it must arrange to restore the previous context itself. .PP When a signal is delivered to a process a new signal mask is installed for the duration of the process' signal handler (or until a .B sigprocmask call is made). This mask is formed by taking the union of the current signal mask set, the signal to be delivered, and the signal mask associated with the handler to be invoked. .PP .B Sigaction assigns an action for a specific signal. If .I act is non-zero, it specifies an action (SIG_DFL, SIG_IGN, or a handler routine) and mask to be used when delivering the specified signal. If .I oact is non-zero, the previous handling information for the signal is returned to the user. .PP Once a signal handler is installed, it remains installed until another .B sigaction call is made, or an .BR execve (2) is performed. A signal-specific default action may be reset by setting .I sa_handler to SIG_DFL. The defaults are process termination, possibly with core dump; no action; stopping the process; or continuing the process. See the signal list below for each signal's default action. If .I sa_handler is SIG_DFL, the default action for the signal is to discard the signal, and if a signal is pending, the pending signal is discarded even if the signal is masked. If .I sa_handler is set to SIG_IGN current and pending instances of the signal are ignored and discarded. .PP Options may be specified by setting .IR sa_flags . If the SA_NOCLDSTOP bit is set when installing a catching function for the SIGCHLD signal, the SIGCHLD signal will be generated only when a child process exits, not when a child process stops. Further, if the SA_ONSTACK bit is set in .IR sa_flags , the system will deliver the signal to the process on a .IR "signal stack" , specified with .BR sigstack (2). .PP If a signal is caught during the system calls listed below, the call may be forced to terminate with the error EINTR, the call may return with a data transfer shorter than requested, or the call may be restarted. Restart of pending calls is requested by setting the SA_RESTART bit in .IR sa_flags . The affected system calls include .BR open (2), .BR read (2), .BR write (2), .BR sendto (2), .BR recvfrom (2), .BR sendmsg (2) and .BR recvmsg (2) on a communications channel or a slow device (such as a terminal, but not a regular file) and during a .BR wait (2) or .BR ioctl (2). However, calls that have already committed are not restarted, but instead return a partial success (for example, a short read count). .PP After a .BR fork (2) or .BR vfork (2) all signals, the signal mask, the signal stack, and the restart/interrupt flags are inherited by the child. .PP .BR Execve (2) reinstates the default action for all signals which were caught and resets all signals to be caught on the user stack. Ignored signals remain ignored; the signal mask remains the same; signals that restart pending system calls continue to do so. .PP The following is a list of all signals with names as in the include file .RI < signal.h >: .LP .in +0.5i .\" BE VERY VERY CAREFUL (and do not cut/paste in an xterm) below. There are .\" embedded tabs present. .ta \w'SIGVTALRMxx'u +\w'terminatexxx'u NAME Action Description .br SIGHUP terminate terminal line hangup .br SIGINT terminate interrupt program .br SIGQUIT core quit program .br SIGILL core illegal instruction .br SIGTRAP core trace trap .br SIGIOT core abort(2) call (same as SIGABRT) .br SIGEMT core emulate instruction executed .br SIGFPE core floating-point exception .br SIGKILL terminate kill program .br SIGBUS core bus error .br SIGSEGV core segmentation violation .br SIGSYS core system call given invalid argument .br SIGPIPE terminate write on a pipe with no reader .br SIGALRM terminate real-time timer expired .br SIGTERM terminate software termination signal .br SIGURG discard urgent condition present on socket .br SIGSTOP stop stop (cannot be caught or ignored) .br SIGTSTP stop stop generated from keyboard .br SIGCONT discard continue after stop .br SIGCHLD discard child status has changed .br SIGTTIN stop background read attempted on control terminal .br SIGTTOU stop background write attemped to control terminal .br SIGIO discard I/O is possible on a descriptor (see fcntl(2)) .br SIGXCPU terminate cpu time limit exceeded (see setrlimit(2)) .br SIGXFSZ terminate file size limit exceeded (see setrlimit(2)) .br SIGVTALRM terminate virtual time alarm (see setitimer(2)) .br SIGPROF terminate profiling timer alarm (see setitimer(2)) .br SIGWINCH discard Window size change .br SIGINFO discard status request from keyboard .br SIGUSR1 terminate User defined signal 1 .br SIGUSR2 terminate User defined signal 2 .br .in -0.5i .SH NOTE The mask specified in .I act is not allowed to block SIGKILL or SIGSTOP. This is done silently by the system. .SH RETURN VALUES A 0 value indicated that the call succeeded. A \-1 return value indicates an error occurred and .I errno is set to indicated the reason. .SH EXAMPLE The handler routine can be declared: .sp .nf int handler(sig, code, scp) int sig, code; struct sigcontext *scp; .fi .PP Here .I sig is the signal number, into which the hardware faults and traps are mapped. .I Code is a parameter that is either a constant or the code provided by the hardware. .I Scp is a pointer to the .I sigcontext structure (defined in .RI < signal.h >, used to restore the context from before the signal. .SH ERRORS .B Sigaction will fail and no new signal handler will be installed if one of the following occurs: .TP 20 EFAULT Either .I act or .I oact points to memory that is not a valid part of the process address space. .TP 20 EINVAL .I Sig is not a valid signal number. .TP 20 EINVAL An attempt is made to ignore or supply a handler for SIGKILL or SIGSTOP. .SH STANDARDS The .B sigaction function is defined by IEEE Std1003.1-1988 (``POSIX''). The SA_ONSTACK and SA_RESTART flags are Berkeley extensions, as are the signals, SIGTRAP, SIGEMT, SIGBUS, SIGSYS, SIGURG, SIGIO, SIGXCPU, SIGXFSZ, SIGVTALRM, SIGPROF, SIGWINCH, and SIGINFO. Those signals are available on most BSD\-derived systems. .SH BUGS The networking related syscalls are not properly restarted in 2.11BSD. The SIGINFO signal is not implemented in 2.11BSD. .SH SEE ALSO kill(1), fcntl(2), ptrace(2), kill(2), setitimer(2), setrlimit(2), sigaction(2), sigprocmask(2), sigsuspend(2), sigblock(2), sigsetmask(2), sigpause(2), sigstack(2), sigvec(2), setjmp(3), siginterrupt(3), sigsetops(3), tty(4) ================================================ FILE: share/man/man2/sigaltstack.2 ================================================ .\" Copyright (c) 1983, 1991, 1992, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. All advertising materials mentioning features or use of this software .\" must display the following acknowledgement: .\" This product includes software developed by the University of .\" California, Berkeley and its contributors. .\" 4. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)sigaltstack.2 8.2.1 (2.11BSD) 1997/9/3 .\" .TH SIGALTSTACK 2 "September 3, 1997" .UC 7 .SH NAME \fBsigaltstack\fP \- set and/or get signal stack context .SH SYNOPSIS .B #include .br .B #include .sp .nf struct sigaltstack { caddr_t ss_base; int ss_size; int ss_flags; }; .fi .sp .I int .br \fBsigaltstack\fP(ss, oss) .br .I struct sigaltstack *ss; .br .I struct sigaltstack *oss; .SH DESCRIPTION .B Sigaltstack allows users to define an alternate stack on which signals are to be processed. If .I ss is non-zero, it specifies a pointer to and the size of a .I "signal stack" on which to deliver signals, and tells the system if the process is currently executing on that stack. When a signal's action indicates its handler should execute on the signal stack (specified with a .BR sigaction (2) call), the system checks to see if the process is currently executing on that stack. If the process is not currently executing on the signal stack, the system arranges a switch to the signal stack for the duration of the signal handler's execution. .PP If SA_DISABLE is set in .IR ss_flags , .IR ss_base and .IR ss_size are ignored and the signal stack will be disabled. Trying to disable an active stack will cause .B sigaltstack to return -1 with .I errno set to EINVAL. A disabled stack will cause all signals to be taken on the regular user stack. If the stack is later re-enabled then all signals that were specified to be processed on an alternate stack will resume doing so. .PP If .I oss is non-zero, the current signal stack state is returned. The .I ss_flags field will contain the value SA_ONSTACK if the process is currently on a signal stack and SA_DISABLE if the signal stack is currently disabled. .SH NOTES The value SIGSTKSZ is defined to be the number of bytes/chars that would be used to cover the usual case when allocating an alternate stack area. The following code fragment is typically used to allocate an alternate stack. .sp .nf if ((sigstk.ss_base = malloc(SIGSTKSZ)) == NULL) /* error return */ sigstk.ss_size = SIGSTKSZ; sigstk.ss_flags = 0; if (sigaltstack(&sigstk,0) < 0) perror("sigaltstack"); .fi .sp An alternative approach is provided for programs with signal handlers that require a specific amount of stack space other than the default size. The value MINSIGSTKSZ is defined to be the number of bytes/chars that is required by the operating system to implement the alternate stack feature. In computing an alternate stack size, programs should add MINSIGSTKSZ to their stack requirements to allow for the operating system overhead. .PP Signal stacks are automatically adjusted for the direction of stack growth and alignment requirements. Signal stacks may or may not be protected by the hardware and are not ``grown'' automatically as is done for the normal stack. If the stack overflows and this space is not protected unpredictable results may occur. .SH RETURN VALUES Upon successful completion, a value of 0 is returned. Otherwise, a value of -1 is returned and .I errno is set to indicate the error. .SH ERRORS .B Sigaltstack will fail and the signal stack context will remain unchanged if one of the following occurs. .TP 20 EFAULT Either .I ss or .I oss points to memory that is not a valid part of the process address space. .TP 20 EINVAL An attempt was made to disable an active stack. .TP 20 ENOMEM Size of alternate stack area is less than or equal to MINSIGSTKSZ . .SH SEE ALSO sigaction(2), setjmp(3) .SH HISTORY The predecessor to .BR sigaltstack , the .B sigstack system call, appeared in 4.2BSD. ================================================ FILE: share/man/man2/sigblock.2 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)sigblock.2 6.3.1 (2.11BSD) 97/9/2 .\" .TH SIGBLOCK 2 "September 2, 1997" .UC 5 .SH NAME sigblock \- block signals .SH SYNOPSIS .nf .B #include \fIomask\fP = \fBsigblock\fP(\fImask\fP); long \fIomask, mask\fP; \fImask\fP = \fBsigmask\fP(\fIsignum\fP) long \fImask\fP; int \fIsignum\fP; .SH DESCRIPTION .B This interface is made obsolete by: sigprocmask(2). .PP .B Sigblock causes the signals specified in .I mask to be added to the set of signals currently being blocked from delivery. Signals are blocked if the corresponding bit in .I mask is a 1; the macro .B sigmask is provided to construct the mask for a given .IR signum . .PP It is not possible to block SIGKILL, SIGSTOP, or SIGCONT; this restriction is silently imposed by the system. .SH "RETURN VALUE The previous set of masked signals is returned. .SH "SEE ALSO" kill(2), sigprocmask(2), sigaction(2), sigsetmask(2), sigsetops(2) .SH "HISTORY" The \fBsigblock\fP function call appeared in 4.2BSD and has been deprecated. ================================================ FILE: share/man/man2/sigpause.2 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)sigpause.2 6.2.1 (2.11BSD) 97/9/2 .\" .TH SIGPAUSE 2 "September 2, 1997" .UC 4 .SH NAME sigpause \- atomically release blocked signals and wait for interrupt .SH SYNOPSIS \fBsigpause\fP(\fIsigmask\fP) .br long \fIsigmask\fP; .SH DESCRIPTION .B This interface is made obsolete by: sigsuspend(2). .PP .B Sigpause() assigns .I sigmask to the set of masked signals and then waits for a signal to arrive; on return the set of masked signals is restored. .I Sigmask is usually 0L to indicate that no signals are now to be blocked. .B Sigpause always terminates by being interrupted, returning \-1 with .I errno set to EINTR. .SH SEE ALSO sigsuspend(2), kill(2), sigaction(2), sigprocmask(2), sigblock(2), sigvec(2) .SH HISTORY The .B sigpause function call appeared in 4.2BSD and has been deprecated. ================================================ FILE: share/man/man2/sigpending.2 ================================================ .\" Copyright (c) 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" This code is derived from software contributed to Berkeley by .\" Berkeley Software Design, Inc. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. All advertising materials mentioning features or use of this software .\" must display the following acknowledgement: .\" This product includes software developed by the University of .\" California, Berkeley and its contributors. .\" 4. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)sigpending.2 8.3.1 (2.11BSD) 1997/9/3 .\" .TH SIGPENDING 2 "September 3, 1997" .UC 7 .SH NAME \fBsigpending\fP \- get pending signals .SH SYNOPSIS .B #include .sp .I int .br \fBsigpending\fP(set) .br .I sigset_t *set; .SH DESCRIPTION The .B sigpending function returns a mask of the signals pending for delivery to the calling process in the location indicated by .IR set . Signals may be pending because they are currently masked, or transiently before delivery (although the latter case is not normally detectable). .SH RETURN VALUES A 0 value indicated that the call succeeded. A \-1 return value indicates an error occurred and .I errno is set to indicated the reason. .SH ERRORS If .B sigpending fails then \fIerrno\fP will contain one of the following: .sp .TP 20 [EFAULT] .I set contains an invalid address. .SH SEE ALSO sigaction(2), sigprocmask(2) .SH STANDARDS The .B sigpending function is defined by IEEE Std1003.1-1988 (``POSIX''). ================================================ FILE: share/man/man2/sigprocmask.2 ================================================ .\" Copyright (c) 1983, 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. All advertising materials mentioning features or use of this software .\" must display the following acknowledgement: .\" This product includes software developed by the University of .\" California, Berkeley and its contributors. .\" 4. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)sigprocmask.2 8.1.1 (2.11BSD) 1997/9/3 .\" .TH SIGPROCMASK 2 "September 3, 1997" .UC 7 .SH NAME \fBsigprocmask\fP \- manipulate current signal mask .SH SYNOPSIS .B #include .sp .I int .br \fBsigprocmask\fP(how, set, oset) .br .I int how; .br .I sigset_t *set; .br .I sigset_t *oset; .sp .I sigset_t .br \fBsigmask\fP(signum) .br .I int signum; .SH DESCRIPTION The .B sigprocmask function examines and/or changes the current signal mask (those signals that are blocked from delivery). Signals are blocked if they are members of the current signal mask set. .PP If .I set is not null, the action of .B sigprocmask depends on the value of the parameter .IR how . The signal mask is changed as a function of the specified .I set and the current mask. The function is specified by .I how using one of the following values from .RI < signal.h >: .TP 20 SIG_BLOCK The new mask is the union of the current mask and the specified .IR set . .TP 20 SIG_UNBLOCK The new mask is the intersection of the current mask and the complement of the specified .IR set . .TP 20 SIG_SETMASK The current mask is replaced by the specified .IR set . .PP If .I oset is not null, it is set to the previous value of the signal mask. When .I set is null, the value of .I how is insignificant and the mask remains unset providing a way to examine the signal mask without modification. .PP The system quietly disallows SIGKILL or SIGSTOP to be blocked. .SH RETURN VALUES A 0 value indicated that the call succeeded. A -1 return value indicates an error occurred and .I errno is set to indicated the reason. .SH ERRORS The .B sigprocmask call will fail and the signal mask will be unchanged if one of the following occurs: .TP 20 EINVAL .I how has a value other than those listed here. .TP 20 EFAULT .I set or .I oset contain an invalid address. .SH SEE ALSO kill(2), sigaction(2), sigsetops(3), sigsuspend(2) .SH STANDARDS The .B sigprocmask function call is expected to conform to IEEE Std1003.1-1988 (``POSIX''). ================================================ FILE: share/man/man2/sigreturn.2 ================================================ .\" Copyright (c) 1985 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)sigreturn.2 6.2 (Berkeley) 6/30/85 .\" .TH SIGRETURN 2 "June 30, 1985" .UC 6 .SH NAME sigreturn \- return from signal .SH SYNOPSIS .nf .B #include .PP .B struct sigcontext { .B int sc_onstack; .B long sc_mask; .B int sc_sp; .B int sc_fp; .B int sc_ap; .B int sc_pc; .B int sc_ps; .B }; .PP .B sigreturn(scp); .B struct sigcontext *scp; .SH DESCRIPTION .I Sigreturn allows users to atomically unmask, switch stacks, and return from a signal context. The processes signal mask and stack status are restored from the context. The system call does not return; the users stack pointer, frame pointer, argument pointer, and processor status longword are restored from the context. Execution resumes at the specified pc. This system call is used by the trampoline code, and .IR longjmp (3) when returning from a signal to the previously executing program. .SH NOTES This system call is not available in 4.2BSD, hence it should not be used if backward compatibility is needed. .PP The definition of the .I sigcontext structure is machine dependent (the structure cited above is that for a VAX running 4.3BSD); no program should depend on its internal structure. .IR Setjmp (3) may be used to build sigcontext structures in a machine independent manner. .SH "RETURN VALUE If successful, the system call does not return. Otherwise, a value of \-1 is returned and .I errno is set to indicate the error. .SH ERRORS .I Sigreturn will fail and the process context will remain unchanged if one of the following occurs. .TP 15 [EFAULT] .I Scp points to memory that is not a valid part of the process address space. .TP [EINVAL] The process status longword is invalid or would improperly raise the privilege level of the process. .SH "SEE ALSO" sigvec(2), setjmp(3) .SH "NOTES (PDP-11)" On the PDP-11 the field \fIsc_ap\fP (argument pointer) does not exist and the field \fIsc_fp\fP (frame pointer) is the PDP-11 register \fIr5\fP. Additionally, three new fields \fIsc_r0\fP, \fIsc_r1\fP and \fIsc_ovno\fP are present on the PDP-11 which hold register values r0 and r1 and the text overlay number to restore (see \fIld\fP(1)). .nf .ta \w' struct 'u +\w'long 'u +\w'sc_onstack 'u .PP .B struct sigcontext { .B int sc_onstack; /* sigstack state to restore */ .B long sc_mask; /* signal mask to restore */ .B int sc_sp; /* sp to restore */ .B int sc_fp; /* fp to restore */ .B int sc_r1; /* r1 to restore */ .B int sc_r0; /* r0 to restore */ .B int sc_pc; /* pc to restore */ .B int sc_ps; /* psl to restore */ .B int sc_ovno /* overlay to restore */ .B }; ================================================ FILE: share/man/man2/sigsetmask.2 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)sigsetmask.2 6.3.1 (2.11BSD) 97/9/3 .\" .TH SIGSETMASK 2 "September 3, 1997" .UC 5 .SH NAME sigsetmask \- set current signal mask .SH SYNOPSIS .nf .B #include .B omask = sigsetmask(mask); .B long omask, mask; .B mask = sigmask(signum) .B long mask; .B int signum; .SH DESCRIPTION .B This interface is made obsolete by: .sigprocmask(2). .sp .I Sigsetmask sets the current signal mask (those signals that are blocked from delivery). Signals are blocked if the corresponding bit in .I mask is a 1; the macro .I sigmask is provided to construct the mask for a given .IR signum . .PP The system quietly disallows SIGKILL, SIGSTOP, or SIGCONT to be blocked. .SH "RETURN VALUE The previous set of masked signals is returned. .SH "SEE ALSO" kill(2), sigvec(2), sigblock(2), sigpause(2) .SH HISTORY The .B sigsetmask function call appeared in 4.2BSD and has been deprecated. ================================================ FILE: share/man/man2/sigstack.2 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)sigstack.2 6.2.1 (2.11BSD) 97/9/3 .\" .TH SIGSTACK 2 "September 3, 1997" .UC 5 .SH NAME sigstack \- set and/or get signal stack context .SH SYNOPSIS .nf .B #include .PP .B struct sigstack { .B caddr_t ss_sp; .B int ss_onstack; .B }; .PP .B sigstack(ss, oss); .B struct sigstack *ss, *oss; .SH DESCRIPTION .B This interface has been made obsolete by: sigaltstack(2). .sp .I Sigstack allows users to define an alternate stack on which signals are to be processed. If .I ss is non-zero, it specifies a .I "signal stack" on which to deliver signals and tells the system if the process is currently executing on that stack. When a signal's action indicates its handler should execute on the signal stack (specified with a .IR sigvec (2) call), the system checks to see if the process is currently executing on that stack. If the process is not currently executing on the signal stack, the system arranges a switch to the signal stack for the duration of the signal handler's execution. If .I oss is non-zero, the current signal stack state is returned. .SH NOTES Signal stacks are not ``grown'' automatically, as is done for the normal stack. If the stack overflows unpredictable results may occur. .SH "RETURN VALUE Upon successful completion, a value of 0 is returned. Otherwise, a value of \-1 is returned and .I errno is set to indicate the error. .SH ERRORS .I Sigstack will fail and the signal stack context will remain unchanged if one of the following occurs. .TP 15 [EFAULT] Either .I ss or .I oss points to memory that is not a valid part of the process address space. .SH "SEE ALSO" sigvec(2), setjmp(3) .SH HISTORY The .B sigstack function call appeared in 4.2BSD and has been deprecated. ================================================ FILE: share/man/man2/sigsuspend.2 ================================================ .\" Copyright (c) 1983, 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. All advertising materials mentioning features or use of this software .\" must display the following acknowledgement: .\" This product includes software developed by the University of .\" California, Berkeley and its contributors. .\" 4. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)sigsuspend.2 8.2.1 (2.11BSD) 1995/9/3 .\" .TH SIGSUSPEND 2 "September 3, 1997" .UC 7 .SH NAME \fBsigsuspend\fP \- atomically release blocked signals and wait for interrupt .SH SYNOPSIS .B #include .sp .I int .br \fBsigsuspend\fP(sigmask) .br .I sigset_t *sigmask .SH DESCRIPTION .BR Sigsuspend () temporarily changes the blocked signal mask to the set to which .I sigmask points, and then waits for a signal to arrive; on return the previous set of masked signals is restored. The signal mask set is usually empty to indicate that all signals are to be unblocked for the duration of the call. .PP In normal usage, a signal is blocked using .BR sigprocmask (2) to begin a critical section, variables modified on the occurrence of the signal are examined to determine that there is no work to be done, and the process pauses awaiting work by using .B sigsuspend with the previous mask returned by .BR sigprocmask . .SH RETURN VALUES The .B sigsuspend function always terminates by being interrupted, returning -1 with .I errno set to EINTR. If EFAULT is set in \fIerrno\fP then \fIset\fP contains an invalid address. .SH SEE ALSO sigprocmask(2), sigaction(2), sigsetops(3) .SH STANDARDS The .B sigsuspend function call conforms to IEEE Std1003.1-1988 (``POSIX''). ================================================ FILE: share/man/man2/sigvec.2 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)sigvec.2 6.3.1 (2.11BSD) 97/9/3 .\" .TH SIGVEC 2 "September 3, 1997" .UC 4 .ie t .ds d \(dg .el .ds d \z'|+' .ie t .ds b \(bu .el .ds b @ .SH NAME sigvec \- software signal facilities .SH SYNOPSIS .nf .B #include .PP .B struct sigvec { .B int (*sv_handler)(); .B long sv_mask; .B int sv_flags; .B }; .PP .B sigvec(sig, vec, ovec) .B int sig; .B struct sigvec *vec, *ovec; .fi .SH DESCRIPTION .B This interface has been made obsolete by: sigaction(2). .sp The system defines a set of signals that may be delivered to a process. Signal delivery resembles the occurence of a hardware interrupt: the signal is blocked from further occurrence, the current process context is saved, and a new one is built. A process may specify a .I handler to which a signal is delivered, or specify that a signal is to be .I blocked or .IR ignored . A process may also specify that a default action is to be taken by the system when a signal occurs. Normally, signal handlers execute on the current stack of the process. This may be changed, on a per-handler basis, so that signals are taken on a special .IR "signal stack" . .PP All signals have the same .IR priority . Signal routines execute with the signal that caused their invocation .IR blocked , but other signals may yet occur. A global .I "signal mask" defines the set of signals currently blocked from delivery to a process. The signal mask for a process is initialized from that of its parent (normally 0). It may be changed with a .IR sigblock (2) or .IR sigsetmask (2) call, or when a signal is delivered to the process. .PP When a signal condition arises for a process, the signal is added to a set of signals pending for the process. If the signal is not currently .I blocked by the process then it is delivered to the process. When a signal is delivered, the current state of the process is saved, a new signal mask is calculated (as described below), and the signal handler is invoked. The call to the handler is arranged so that if the signal handling routine returns normally the process will resume execution in the context from before the signal's delivery. If the process wishes to resume in a different context, then it must arrange to restore the previous context itself. .PP When a signal is delivered to a process a new signal mask is installed for the duration of the process' signal handler (or until a .I sigblock or .I sigsetmask call is made). This mask is formed by taking the current signal mask, adding the signal to be delivered, and .IR or 'ing in the signal mask associated with the handler to be invoked. .PP .I Sigvec assigns a handler for a specific signal. If .I vec is non-zero, it specifies a handler routine and mask to be used when delivering the specified signal. Further, if the SV_ONSTACK bit is set in .I sv_flags, the system will deliver the signal to the process on a .IR "signal stack" , specified with .IR sigstack (2). If .I ovec is non-zero, the previous handling information for the signal is returned to the user. .PP The following is a list of all signals with names as in the include file .RI < signal.h >: .LP .nf .ta \w'SIGVTALRM 'u +\w'15* 'u SIGHUP 1 hangup SIGINT 2 interrupt SIGQUIT 3* quit SIGILL 4* illegal instruction SIGTRAP 5* trace trap SIGIOT 6* IOT instruction SIGEMT 7* EMT instruction SIGFPE 8* floating point exception SIGKILL 9 kill (cannot be caught, blocked, or ignored) SIGBUS 10* bus error SIGSEGV 11* segmentation violation SIGSYS 12* bad argument to system call SIGPIPE 13 write on a pipe with no one to read it SIGALRM 14 alarm clock SIGTERM 15 software termination signal SIGURG 16\*b urgent condition present on socket SIGSTOP 17\*d stop (cannot be caught, blocked, or ignored) SIGTSTP 18\*d stop signal generated from keyboard SIGCONT 19\*b continue after stop (cannot be blocked) SIGCHLD 20\*b child status has changed SIGTTIN 21\*d background read attempted from control terminal SIGTTOU 22\*d background write attempted to control terminal SIGIO 23\*b i/o is possible on a descriptor (see \fIfcntl\fP(2)) SIGXCPU 24 cpu time limit exceeded (see \fIsetrlimit\fP(2)) SIGXFSZ 25 file size limit exceeded (see \fIsetrlimit\fP(2)) SIGVTALRM 26 virtual time alarm (see \fIsetitimer\fP(2)) SIGPROF 27 profiling timer alarm (see \fIsetitimer\fP(2)) SIGWINCH 28\*b window size change SIGUSR1 30 user defined signal 1 SIGUSR2 31 user defined signal 2 .fi .PP The starred signals in the list above cause a core image if not caught or ignored. .PP Once a signal handler is installed, it remains installed until another .I sigvec call is made, or an .IR execve (2) is performed. The default action for a signal may be reinstated by setting .I sv_handler to SIG_DFL; this default is termination (with a core image for starred signals) except for signals marked with \*b or \*d. Signals marked with \*b are discarded if the action is SIG_DFL; signals marked with \*d cause the process to stop. If .I sv_handler is SIG_IGN the signal is subsequently ignored, and pending instances of the signal are discarded. .PP If a caught signal occurs during certain system calls, the call is normally restarted. The call can be forced to terminate prematurely with an EINTR error return by setting the SV_INTERRUPT bit in .I sv_flags. The affected system calls are .IR read (2) or .IR write (2) on a slow device (such as a terminal; but not a file) and during a .IR wait (2). .PP After a .IR fork (2) or .IR vfork (2) the child inherits all signals, the signal mask, the signal stack, and the restart/interrupt flags. .PP .IR Execve (2) resets all caught signals to default action and resets all signals to be caught on the user stack. Ignored signals remain ignored; the signal mask remains the same; signals that interrupt system calls continue to do so. .SH NOTES The mask specified in .I vec is not allowed to block SIGKILL, SIGSTOP, or SIGCONT. This is done silently by the system. .PP The SV_INTERRUPT flag is not available in 4.2BSD, hence it should not be used if backward compatibility is needed. .SH "RETURN VALUE A 0 value indicated that the call succeeded. A \-1 return value indicates an error occurred and .I errno is set to indicated the reason. .SH ERRORS .I Sigvec will fail and no new signal handler will be installed if one of the following occurs: .TP 15 [EFAULT] Either .I vec or .I ovec points to memory that is not a valid part of the process address space. .TP 15 [EINVAL] .I Sig is not a valid signal number. .TP 15 [EINVAL] An attempt is made to ignore or supply a handler for SIGKILL or SIGSTOP. .TP 15 [EINVAL] An attempt is made to ignore SIGCONT (by default SIGCONT is ignored). .SH "SEE ALSO" kill(1), ptrace(2), kill(2), sigblock(2), sigsetmask(2), sigpause(2), sigstack(2), sigvec(2), setjmp(3), siginterrupt(3), tty(4) .SH "NOTES (VAX-11)" The handler routine can be declared: .PP handler(sig, code, scp) int sig, code; struct sigcontext *scp; .PP Here .I sig is the signal number, into which the hardware faults and traps are mapped as defined below. .I Code is a parameter that is either a constant as given below or, for compatibility mode faults, the code provided by the hardware (Compatibility mode faults are distinguished from the other SIGILL traps by having PSL_CM set in the psl). .I Scp is a pointer to the .I sigcontext structure (defined in .RI < signal.h >), used to restore the context from before the signal. .PP The following defines the mapping of hardware traps to signals and codes. All of these symbols are defined in .RI < signal.h >: .LP .ta \w' Floating/decimal divide by zero 'u +\w'15* 'u +8n .nf Hardware condition Signal Code Arithmetic traps: Integer overflow SIGFPE FPE_INTOVF_TRAP Integer division by zero SIGFPE FPE_INTDIV_TRAP Floating overflow trap SIGFPE FPE_FLTOVF_TRAP Floating/decimal division by zero SIGFPE FPE_FLTDIV_TRAP Floating underflow trap SIGFPE FPE_FLTUND_TRAP Decimal overflow trap SIGFPE FPE_DECOVF_TRAP Subscript-range SIGFPE FPE_SUBRNG_TRAP Floating overflow fault SIGFPE FPE_FLTOVF_FAULT Floating divide by zero fault SIGFPE FPE_FLTDIV_FAULT Floating underflow fault SIGFPE FPE_FLTUND_FAULT Length access control SIGSEGV Protection violation SIGBUS Reserved instruction SIGILL ILL_RESAD_FAULT Customer-reserved instr. SIGEMT Reserved operand SIGILL ILL_PRIVIN_FAULT Reserved addressing SIGILL ILL_RESOP_FAULT Trace pending SIGTRAP Bpt instruction SIGTRAP Compatibility-mode SIGILL hardware supplied code Chme SIGSEGV Chms SIGSEGV Chmu SIGSEGV .fi .SH "NOTES (PDP-11)" The handler routine can be declared: .PP handler(sig, code, scp) int sig, code; struct sigcontext *scp; .PP Here \fIsig\fP is the signal number, into which the hardware faults and traps are mapped as defined below. \fICode\fP is a parameter that is a constant as given below. \fIScp\fP is a pointer to the \fIsigcontext\fP structure (defined in <\fIsignal.h\fP>), used to restore the context from before the signal. .PP The following defines the mapping of hardware traps to signals and codes. All of these symbols are defined in <\fIsignal.h\fP>: .LP .ta \w' Floating/decimal divide by zero 'u +\w'15* 'u +8n .nf Hardware condition Signal Code Arithmetic traps: Floating overflow trap SIGFPE FPE_FLTOVF_TRAP Floating/decimal division by zero SIGFPE FPE_FLTDIV_TRAP Floating underflow trap SIGFPE FPE_FLTUND_TRAP Decimal overflow trap SIGFPE FPE_DECOVF_TRAP Illegal return code SIGFPE FPE_CRAZY Bad op code SIGFPE FPE_OPCODE_TRAP Bad operand SIGFPE FPE_OPERAND_TRAP Maintenance trap SIGFPE FPE_MAINT_TRAP Length access control SIGSEGV Protection violation (odd address) SIGBUS Reserved instruction SIGILL ILL_RESAD_FAULT Customer-reserved instr. SIGEMT Trace pending SIGTRAP Bpt instruction SIGTRAP .fi .DT .PP The handler routine must save any registers it uses and restore them before returning. On the PDP-11, the kernel saves \fIr0\fP and \fIr1\fP before calling the handler routine, but expect the handler to save any other registers it uses. The standard entry code generated by the C compiler for handler routines written in C automatically saves the remaining general registers, but floating point registers are \fInot\fP saved. As a result there is currently no [standard] method for a handler routine written in C to perform floating point operations without blowing the interrupted program out of the water. .SH BUGS This manual page is still confusing. ================================================ FILE: share/man/man2/sigwait.2 ================================================ .\" @(#)sigwait.2 1.0 (2.11BSD) 1999/9/10 .\" .TH SIGACTION 2 "September 10, 1999" .UC 7 .SH NAME \fBsigwait\fP \- wait for a signal .SH SYNOPSIS .B #include .sp int \fBsigwait\fP(set, sig) .br .I sigset_t *set; .br .I int *sig; .SH DESCRIPTION .B Sigwait checks for a pending signal in .IR set , clears it from the set of pending signals and returns the signal number in the location referenced by .IR sig . If more than one of the signals contained in .I set is pending then .B sigwait selects only one and acts upon it. If no signal contained in .I set is pending, then .B sigwait waits for a signal to arrive. All of the signals contained in .I set should be blocked or unpredictable results may occur. .SH RETURN VALUES The .B sigwait function returns 0 if successful and the signal number is stored in the location referenced by .IR sig . .SH ERRORS The .B sigwait function may return one of the following errors: .TP 20 EINVAL The .I set argument contains an invalid or unsupported signal number. .TP 20 EFAULT .I Sig points to memory that is not a valid part of the process address space. .SH SEE ALSO sigprocmask(2) .SH STANDARDS The .B sigwait function call conforms to IEEE Std1003.1-1998 (``POSIX''). ================================================ FILE: share/man/man2/socket.2 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)socket.2 6.5 (Berkeley) 5/23/86 .\" .TH SOCKET 2 "May 23, 1986" .UC 5 .SH NAME socket \- create an endpoint for communication .SH SYNOPSIS .nf .ft B #include #include .PP .ft B s = socket(domain, type, protocol) int s, domain, type, protocol; .fi .SH DESCRIPTION .I Socket creates an endpoint for communication and returns a descriptor. .PP The .I domain parameter specifies a communications domain within which communication will take place; this selects the protocol family which should be used. The protocol family generally is the same as the address family for the addresses supplied in later operations on the socket. These families are defined in the include file .IR . The currently understood formats are .PP .RS .nf .ta 1.25i 1.75i PF_UNIX (UNIX internal protocols), PF_INET (ARPA Internet protocols), PF_NS (Xerox Network Systems protocols), and PF_IMPLINK (IMP \*(lqhost at IMP\*(rq link layer). .fi .RE .PP The socket has the indicated .I type, which specifies the semantics of communication. Currently defined types are: .PP .RS .nf SOCK_STREAM SOCK_DGRAM SOCK_RAW SOCK_SEQPACKET SOCK_RDM .fi .RE .PP A SOCK_STREAM type provides sequenced, reliable, two-way connection based byte streams. An out-of-band data transmission mechanism may be supported. A SOCK_DGRAM socket supports datagrams (connectionless, unreliable messages of a fixed (typically small) maximum length). A SOCK_SEQPACKET socket may provide a sequenced, reliable, two-way connection-based data transmission path for datagrams of fixed maximum length; a consumer may be required to read an entire packet with each read system call. This facility is protocol specific, and presently implemented only for PF_NS. SOCK_RAW sockets provide access to internal network protocols and interfaces. The types SOCK_RAW, which is available only to the super-user, and SOCK_RDM, which is planned, but not yet implemented, are not described here. .PP The .I protocol specifies a particular protocol to be used with the socket. Normally only a single protocol exists to support a particular socket type within a given protocol family. However, it is possible that many protocols may exist, in which case a particular protocol must be specified in this manner. The protocol number to use is particular to the \*(lqcommunication domain\*(rq in which communication is to take place; see .IR protocols (3N). .PP Sockets of type SOCK_STREAM are full-duplex byte streams, similar to pipes. A stream socket must be in a .I connected state before any data may be sent or received on it. A connection to another socket is created with a .IR connect (2) call. Once connected, data may be transferred using .IR read (2) and .IR write (2) calls or some variant of the .IR send (2) and .IR recv (2) calls. When a session has been completed a .IR close (2) may be performed. Out-of-band data may also be transmitted as described in .IR send (2) and received as described in .IR recv (2). .PP The communications protocols used to implement a SOCK_STREAM insure that data is not lost or duplicated. If a piece of data for which the peer protocol has buffer space cannot be successfully transmitted within a reasonable length of time, then the connection is considered broken and calls will indicate an error with \-1 returns and with ETIMEDOUT as the specific code in the global variable errno. The protocols optionally keep sockets \*(lqwarm\*(rq by forcing transmissions roughly every minute in the absence of other activity. An error is then indicated if no response can be elicited on an otherwise idle connection for a extended period (e.g. 5 minutes). A SIGPIPE signal is raised if a process sends on a broken stream; this causes naive processes, which do not handle the signal, to exit. .PP SOCK_SEQPACKET sockets employ the same system calls as SOCK_STREAM sockets. The only difference is that .IR read (2) calls will return only the amount of data requested, and any remaining in the arriving packet will be discarded. .PP SOCK_DGRAM and SOCK_RAW sockets allow sending of datagrams to correspondents named in .IR send (2) calls. Datagrams are generally received with .IR recvfrom (2), which returns the next datagram with its return address. .PP An .IR fcntl (2) call can be used to specify a process group to receive a SIGURG signal when the out-of-band data arrives. It may also enable non-blocking I/O and asynchronous notification of I/O events via SIGIO. .PP The operation of sockets is controlled by socket level .IR options . These options are defined in the file .RI < sys/socket.h >. .IR Setsockopt (2) and .IR getsockopt (2) are used to set and get options, respectively. .SH "RETURN VALUE A \-1 is returned if an error occurs, otherwise the return value is a descriptor referencing the socket. .SH "ERRORS The \fIsocket\fP call fails if: .TP 20 [EPROTONOSUPPORT] The protocol type or the specified protocol is not supported within this domain. .TP 20 [EMFILE] The per-process descriptor table is full. .TP 20 [ENFILE] The system file table is full. .TP 20 [EACCESS] Permission to create a socket of the specified type and/or protocol is denied. .TP 20 [ENOBUFS] Insufficient buffer space is available. The socket cannot be created until sufficient resources are freed. .SH SEE ALSO accept(2), bind(2), connect(2), getsockname(2), getsockopt(2), ioctl(2), listen(2), read(2), recv(2), select(2), send(2), shutdown(2), socketpair(2), write(2) .br ``An Introductory 4.3BSD Interprocess Communication Tutorial.'' (reprinted in UNIX Programmer's Supplementary Documents Volume 1, PS1:7) ``An Advanced 4.3BSD Interprocess Communication Tutorial.'' (reprinted in UNIX Programmer's Supplementary Documents Volume 1, PS1:8) ================================================ FILE: share/man/man2/socketpair.2 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)socketpair.2 6.1 (Berkeley) 5/15/85 .\" .TH SOCKETPAIR 2 "May 15, 1985" .UC 5 .SH NAME socketpair \- create a pair of connected sockets .SH SYNOPSIS .nf .ft B #include #include .PP .ft B socketpair(d, type, protocol, sv) int d, type, protocol; int sv[2]; .fi .SH DESCRIPTION The .I socketpair call creates an unnamed pair of connected sockets in the specified domain .IR d , of the specified .IR type , and using the optionally specified .IR protocol . The descriptors used in referencing the new sockets are returned in .IR sv [0] and .IR sv [1]. The two sockets are indistinguishable. .SH DIAGNOSTICS A 0 is returned if the call succeeds, \-1 if it fails. .SH ERRORS The call succeeds unless: .TP 20 [EMFILE] Too many descriptors are in use by this process. .TP 20 [EAFNOSUPPORT] The specified address family is not supported on this machine. .TP 20 [EPROTONOSUPPORT] The specified protocol is not supported on this machine. .TP 20 [EOPNOSUPPORT] The specified protocol does not support creation of socket pairs. .TP 20 [EFAULT] The address \fIsv\fP does not specify a valid part of the process address space. .SH "SEE ALSO" read(2), write(2), pipe(2) .SH BUGS This call is currently implemented only for the UNIX domain. ================================================ FILE: share/man/man2/stat.2 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)stat.2 6.5 (Berkeley) 5/12/86 .\" .TH STAT 2 "May 12, 1986" .UC 4 .SH NAME stat, lstat, fstat \- get file status .SH SYNOPSIS .nf .ft B #include #include .PP .ft B stat(path, buf) char *path; struct stat *buf; .PP .ft B lstat(path, buf) char *path; struct stat *buf; .PP .ft B fstat(fd, buf) int fd; struct stat *buf; .fi .ft R .SH DESCRIPTION .I Stat obtains information about the file .IR path . Read, write or execute permission of the named file is not required, but all directories listed in the path name leading to the file must be reachable. .PP .I Lstat is like \fIstat\fP except in the case where the named file is a symbolic link, in which case .I lstat returns information about the link, while .I stat returns information about the file the link references. .PP .I Fstat obtains the same information about an open file referenced by the argument descriptor, such as would be obtained by an \fIopen\fP call. .PP .I Buf is a pointer to a .I stat structure into which information is placed concerning the file. The contents of the structure pointed to by .I buf .PP .nf .ta 1i 1.7i 2.5i struct stat { dev_t st_dev; /* device inode resides on */ ino_t st_ino; /* this inode's number */ u_short st_mode; /* protection */ short st_nlink; /* number or hard links to the file */ short st_uid; /* user-id of owner */ short st_gid; /* group-id of owner */ dev_t st_rdev; /* the device type, for inode that is device */ off_t st_size; /* total size of file */ time_t st_atime; /* file last access time */ int st_spare1; time_t st_mtime; /* file last modify time */ int st_spare2; time_t st_ctime; /* file last status change time */ int st_spare3; long st_blksize; /* optimal blocksize for file system i/o ops */ long st_blocks; /* actual number of blocks allocated */ long st_spare4[2]; }; .fi .DT .PP .TP 12 st_atime Time when file data was last read or modified. Changed by the following system calls: .IR mknod (2), .IR utimes (2), .IR read (2), and .IR write (2). For reasons of efficiency, st_atime is not set when a directory is searched, although this would be more logical. .TP 12 st_mtime Time when data was last modified. It is not set by changes of owner, group, link count, or mode. Changed by the following system calls: .IR mknod (2), .IR utimes (2), .IR write (2). .TP 12 st_ctime Time when file status was last changed. It is set both both by writing and changing the i-node. Changed by the following system calls: .IR chmod (2) .IR chown (2), .IR link (2), .IR mknod (2), .IR rename (2), .IR unlink (2), .IR utimes (2), .IR write (2). .PP The status information word \fIst_mode\fP has bits: .nf .in +5n .ta 1.6i 2.5i 3i #define S_IFMT 0170000 /* type of file */ #define\ \ \ \ S_IFDIR 0040000 /* directory */ #define\ \ \ \ S_IFCHR 0020000 /* character special */ #define\ \ \ \ S_IFBLK 0060000 /* block special */ #define\ \ \ \ S_IFREG 0100000 /* regular */ #define\ \ \ \ S_IFLNK 0120000 /* symbolic link */ #define\ \ \ \ S_IFSOCK 0140000 /* socket */ #define S_ISUID 0004000 /* set user id on execution */ #define S_ISGID 0002000 /* set group id on execution */ #define S_ISVTX 0001000 /* save swapped text even after use */ #define S_IREAD 0000400 /* read permission, owner */ #define S_IWRITE 0000200 /* write permission, owner */ #define S_IEXEC 0000100 /* execute/search permission, owner */ .fi .in -5n .PP The mode bits 0000070 and 0000007 encode group and others permissions (see .IR chmod (2)). .SH "RETURN VALUE Upon successful completion a value of 0 is returned. Otherwise, a value of \-1 is returned and .I errno is set to indicate the error. .SH "ERRORS .I Stat and .I lstat will fail if one or more of the following are true: .TP 15 [ENOTDIR] A component of the path prefix is not a directory. .TP 15 [EINVAL] The pathname contains a character with the high-order bit set. .TP 15 [ENAMETOOLONG] A component of a pathname exceeded 255 characters, or an entire path name exceeded 1023 characters. .TP 15 [ENOENT] The named file does not exist. .TP 15 [EACCES] Search permission is denied for a component of the path prefix. .TP 15 [ELOOP] Too many symbolic links were encountered in translating the pathname. .TP 15 [EFAULT] .I Buf or .I name points to an invalid address. .TP 15 [EIO] An I/O error occurred while reading from or writing to the file system. .PP .I Fstat will fail if one or both of the following are true: .TP 15 [EBADF] .I Fildes is not a valid open file descriptor. .TP 15 [EFAULT] .I Buf points to an invalid address. .TP 15 [EIO] An I/O error occurred while reading from or writing to the file system. .SH CAVEAT The fields in the stat structure currently marked .IR st_spare1 , .IR st_spare2 , and .I st_spare3 are present in preparation for inode time stamps expanding to 64 bits. This, however, can break certain programs that depend on the time stamps being contiguous (in calls to .IR utimes (2)). .SH "SEE ALSO" chmod(2), chown(2), utimes(2) .SH BUGS Applying .I fstat to a socket (and thus to a pipe) returns a zero'd buffer, except for the blocksize field, and a unique device and inode number. ================================================ FILE: share/man/man2/statfs.2 ================================================ .\" Copyright (c) 1989, 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. All advertising materials mentioning features or use of this software .\" must display the following acknowledgement: .\" This product includes software developed by the University of .\" California, Berkeley and its contributors. .\" 4. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)statfs.2 8.3.2 (2.11BSD) 1995/12/26 .\" .TH STATFS 2 "December 26, 1995" .UC 7 .SH NAME \fBstatfs\fP, \fBfstatfs\fP \- get file system statistics .SH SYNOPSIS .B #include .br .B #include .sp .I int .br \fBstatfs\fP(path,buf) .br .I char *path; .br .I struct statfs *buf; .sp .I int .br \fBfstatfs\fP(fd,buf) .br .I int fd; .br .I struct statfs *buf; .SH DESCRIPTION .BR Statfs () returns information about a mounted file system. .I Path is the path name of any file within the mounted filesystem. .I Buf is a pointer to a .I statfs structure defined as follows: .sp .nf .cs R 20 #define MNAMELEN 90 /* length of buffer for returned name */ struct statfs { short f_type; /* type of filesystem (see below) */ short f_flags; /* copy of mount flags */ short f_bsize; /* fundamental file system block size */ short f_iosize; /* optimal transfer block size */ long f_blocks; /* total data blocks in file system */ long f_bfree; /* free blocks in fs */ long f_bavail; /* free blocks avail to non-superuser */ ino_t f_files; /* total file nodes in file system */ ino_t f_ffree; /* free file nodes in fs */ u_long f_fsid[2]; /* file system id */ long f_spare[4]; /* spare for later */ char f_mntonname[MNAMELEN]; /* mount point */ char f_mntfromname[MNAMELEN]; /* mounted filesystem */ }; /* * File system types. - Only UFS is supported so the other types are not * given. */ #define MOUNT_UFS 1 /* Fast Filesystem */ .br .fi .cs R .PP Fields that are undefined for a particular file system are set to -1. .BR Fstatfs () returns the same information about an open file referenced by descriptor .IR fd . .SH RETURN VALUES Upon successful completion, a value of 0 is returned. Otherwise, -1 is returned and the global variable .I errno is set to indicate the error. .SH ERRORS .BR Statfs () fails if one or more of the following are true: .sp .TP 20 [ENOTDIR] A component of the path prefix of .I Path is not a directory. .TP 20 [EINVAL] .I path contains a character with the high-order bit set. .TP 20 [ENAMETOOLONG] The length of a component of .I path exceeds 63 characters, or the length of .I path exceeds 255 characters. .TP 20 [ENOENT] The file referred to by .I path does not exist. .TP 20 [EACCES] Search permission is denied for a component of the path prefix of .IR path . .TP 20 [ELOOP] Too many symbolic links were encountered in translating .IR path . .TP 20 [EFAULT] .I Buf or .I path points to an invalid address. .TP 20 [EIO] An I/O error occurred while reading from or writing to the file system. .PP .BR Fstatfs () fails if one or more of the following are true: .sp .TP 20 [EBADF] .I Fd is not a valid open file descriptor. .TP 20 [EFAULT] .I Buf points to an invalid address. .TP 20 [EIO] An I/O error occurred while reading from or writing to the file system. .SH HISTORY The .B statfs function first appeared in 4.4BSD. ================================================ FILE: share/man/man2/swapon.2 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)swapon.2 6.4 (Berkeley) 3/9/86 .\" .TH SWAPON 2 "March 9, 1986" .UC 4 .SH NAME swapon \- add a swap device for interleaved paging/swapping .SH SYNOPSIS .nf .B swapon(special) .B char *special; .fi .SH DESCRIPTION .I Swapon makes the block device .I special available to the system for allocation for paging and swapping. The names of potentially available devices are known to the system and defined at system configuration time. The size of the swap area on .I special is calculated at the time the device is first made available for swapping. .SH "RETURN VALUE If an error has occurred, a value of \-1 is returned and .I errno is set to indicate the error. .SH ERRORS .I Swapon succeeds unless: .TP 15 [ENOTDIR] A component of the path prefix is not a directory. .TP 15 [EINVAL] The pathname contains a character with the high-order bit set. .TP 15 [ENAMETOOLONG] A component of a pathname exceeded 255 characters, or an entire path name exceeded 1023 characters. .TP 15 [ENOENT] The named device does not exist. .TP 15 [EACCES] Search permission is denied for a component of the path prefix. .TP 15 [ELOOP] Too many symbolic links were encountered in translating the pathname. .TP 15 [EPERM] The caller is not the super-user. .TP 15 [ENOTBLK] .I Special is not a block device. .TP 15 [EBUSY] The device specified by \fIspecial\fP has already been made available for swapping .TP 15 [EINVAL] The device configured by \fIspecial\fP was not configured into the system as a swap device. .TP 15 [ENXIO] The major device number of .I special is out of range (this indicates no device driver exists for the associated hardware). .TP 15 [EIO] An I/O error occurred while opening the swap device. .TP 15 [EFAULT] .I Special points outside the process's allocated address space. .SH "SEE ALSO" swapon(8), config(8) .SH BUGS There is no way to stop swapping on a disk so that the pack may be dismounted. .PP This call will be upgraded in future versions of the system. ================================================ FILE: share/man/man2/symlink.2 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)symlink.2 6.3 (Berkeley) 8/26/85 .\" .TH SYMLINK 2 "August 26, 1985" .UC 5 .SH NAME symlink \- make symbolic link to a file .SH SYNOPSIS .nf .ft B symlink(name1, name2) char *name1, *name2; .fi .ft R .SH DESCRIPTION A symbolic link .I name2 is created to .IR name1 (\fIname2\fP is the name of the file created, \fIname1\fP is the string used in creating the symbolic link). Either name may be an arbitrary path name; the files need not be on the same file system. .SH "RETURN VALUE Upon successful completion, a zero value is returned. If an error occurs, the error code is stored in \fIerrno\fP and a \-1 value is returned. .SH "ERRORS The symbolic link is made unless on or more of the following are true: .TP 15 [ENOTDIR] A component of the \fIname2\fP prefix is not a directory. .TP 15 [EINVAL] Either \fIname1\fP or \fIname2\fP contains a character with the high-order bit set. .TP 15 [ENAMETOOLONG] A component of either pathname exceeded 255 characters, or the entire length of either path name exceeded 1023 characters. .TP 15 [ENOENT] The named file does not exist. .TP 15 [EACCES] A component of the \fIname2\fP path prefix denies search permission. .TP 15 [ELOOP] Too many symbolic links were encountered in translating the pathname. .TP 15 [EEXIST] \fIName2\fP already exists. .TP 15 [EIO] An I/O error occurred while making the directory entry for \fIname2\fP, or allocating the inode for \fIname2\fP, or writing out the link contents of \fIname2\fP. .TP 15 [EROFS] The file \fIname2\fP would reside on a read-only file system. .TP 15 [ENOSPC] The directory in which the entry for the new symbolic link is being placed cannot be extended because there is no space left on the file system containing the directory. .TP 15 [ENOSPC] The new symbolic link cannot be created because there there is no space left on the file system that will contain the symbolic link. .TP 15 [ENOSPC] There are no free inodes on the file system on which the symbolic link is being created. .TP 15 [EDQUOT] The directory in which the entry for the new symbolic link is being placed cannot be extended because the user's quota of disk blocks on the file system containing the directory has been exhausted. .TP 15 [EDQUOT] The new symbolic link cannot be created because the user's quota of disk blocks on the file system that will contain the symbolic link has been exhausted. .TP 15 [EDQUOT] The user's quota of inodes on the file system on which the symbolic link is being created has been exhausted. .TP 15 [EIO] An I/O error occurred while making the directory entry or allocating the inode. .TP 15 [EFAULT] .I Name1 or .I name2 points outside the process's allocated address space. .SH "SEE ALSO" link(2), ln(1), unlink(2) ================================================ FILE: share/man/man2/sync.2 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)sync.2 6.2 (Berkeley) 6/30/85 .\" .TH SYNC 2 "June 30, 1985" .UC 4 .SH NAME sync \- update super-block .SH SYNOPSIS .B sync() .SH DESCRIPTION .I Sync causes all information in core memory that should be on disk to be written out. This includes modified super blocks, modified i-nodes, and delayed block I/O. .PP .I Sync should be used by programs that examine a file system, for example .I "fsck, df," etc. .I Sync is mandatory before a boot. .SH "SEE ALSO" fsync(2), sync(8), update(8) .SH BUGS The writing, although scheduled, is not necessarily complete upon return from .IR sync . ================================================ FILE: share/man/man2/syscall.2 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)syscall.2 6.2 (Berkeley) 4/16/86 .\" .TH SYSCALL 2 "April 16, 1986" .UC 4 .SH NAME syscall \- indirect system call .SH SYNOPSIS .nf .ft B #include .PP .BR "syscall(number, arg, ...)" \ \ (VAX-11) .fi .SH DESCRIPTION .I Syscall performs the system call whose assembly language interface has the specified .I number, register arguments .I r0 and .I r1 and further arguments .IR arg . Symbolic constants for system calls can be found in the header file .I . .PP The r0 value of the system call is returned. .SH DIAGNOSTICS When the C-bit is set, .I syscall returns \-1 and sets the external variable .I errno (see .IR intro (2)). .SH BUGS There is no way to simulate system calls such as .IR pipe (2), which return values in register r1. ================================================ FILE: share/man/man2/truncate.2 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)truncate.2 6.6 (Berkeley) 3/29/86 .\" .TH TRUNCATE 2 "March 29, 1986" .UC 5 .SH NAME truncate \- truncate a file to a specified length .SH SYNOPSIS .nf .ft B truncate(path, length) char *path; off_t length; .PP .ft B ftruncate(fd, length) int fd; off_t length; .fi .SH DESCRIPTION .I Truncate causes the file named by .I path or referenced by .I fd to be truncated to at most .I length bytes in size. If the file previously was larger than this size, the extra data is lost. With .IR ftruncate , the file must be open for writing. .SH "RETURN VALUES A value of 0 is returned if the call succeeds. If the call fails a \-1 is returned, and the global variable \fIerrno\fP specifies the error. .SH "ERRORS .I Truncate succeeds unless: .TP 15 [ENOTDIR] A component of the path prefix is not a directory. .TP 15 [EINVAL] The pathname contains a character with the high-order bit set. .TP 15 [ENAMETOOLONG] A component of a pathname exceeded 255 characters, or an entire path name exceeded 1023 characters. .TP 15 [ENOENT] The named file does not exist. .TP 15 [EACCES] Search permission is denied for a component of the path prefix. .TP 15 [EACCES] The named file is not writable by the user. .TP 15 [ELOOP] Too many symbolic links were encountered in translating the pathname. .TP 15 [EISDIR] The named file is a directory. .TP 15 [EROFS] The named file resides on a read-only file system. .TP 15 [ETXTBSY] The file is a pure procedure (shared text) file that is being executed. .TP 15 [EIO] An I/O error occurred updating the inode. .TP 15 [EFAULT] .I Path points outside the process's allocated address space. .PP .I Ftruncate succeeds unless: .TP 15 [EBADF] The .I fd is not a valid descriptor. .TP 15 [EINVAL] The .I fd references a socket, not a file. .TP 15 [EINVAL] The .I fd is not open for writing. .SH "SEE ALSO" open(2) .SH BUGS These calls should be generalized to allow ranges of bytes in a file to be discarded. ================================================ FILE: share/man/man2/ucall.2 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)ucall.2 2.3 (Berkeley) 1/22/87 .\" .TH UCALL 2 "January 22, 1987" .UC 2 .SH NAME ucall \- call a kernel subroutine from user mode (2BSD) .SH SYNOPSIS .nf .ft B #include #include ucall(priority, function, arg0, arg1) int priority, arg0, arg1; caddr_t function; .fi .ft R .SH DESCRIPTION .I Ucall causes the processor priority to be set to .I priority and the specified kernel .I function to be called with arguments .IR arg0 " and " arg1 . .I Priority is one of PSL_BR0, \&..., PSL_BR7. Processor priority is reset to PSL_BR0 when .I function returns. .PP .I Ucall is allowed only if the user is the superuser. It is obviously extremely dangerous if misused. It's only current use is at system boot time to configure system devices by calling device drivers \&... .SH ERRORS .TP 15 [EPERM] The caller is not the super-user. .SH SEE ALSO autoconfig(8) .SH BUGS No address validations are attempted. .PP .I Ucall is unique to the PDP-11 and 2BSD; its use is discouraged. ================================================ FILE: share/man/man2/umask.2 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)umask.2 6.1 (Berkeley) 5/9/85 .\" .TH UMASK 2 "May 9, 1985" .UC 4 .SH NAME umask \- set file creation mode mask .SH SYNOPSIS .ft B oumask = umask(numask) .br int oumask, numask; .ft R .SH DESCRIPTION .I Umask sets the process's file mode creation mask to \fInumask\fP and returns the previous value of the mask. The low-order 9 bits of \fInumask\fP are used whenever a file is created, clearing corresponding bits in the file mode (see .IR chmod (2)). This clearing allows each user to restrict the default access to his files. .PP The value is initially 022 (write access for owner only). The mask is inherited by child processes. .SH "RETURN VALUE The previous value of the file mode mask is returned by the call. .SH SEE ALSO chmod(2), mknod(2), open(2) ================================================ FILE: share/man/man2/unlink.2 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)unlink.2 6.2 (Berkeley) 5/22/85 .\" .TH UNLINK 2 "May 22, 1985" .UC 4 .SH NAME unlink \- remove directory entry .SH SYNOPSIS .nf .ft B unlink(path) char *path; .fi .ft R .SH DESCRIPTION .I Unlink removes the entry for the file .I path from its directory. If this entry was the last link to the file, and no process has the file open, then all resources associated with the file are reclaimed. If, however, the file was open in any process, the actual resource reclamation is delayed until it is closed, even though the directory entry has disappeared. .SH "RETURN VALUE Upon successful completion, a value of 0 is returned. Otherwise, a value of \-1 is returned and .I errno is set to indicate the error. .SH "ERRORS The \fIunlink\fP succeeds unless: .TP 15 [ENOTDIR] A component of the path prefix is not a directory. .TP 15 [EINVAL] The pathname contains a character with the high-order bit set. .TP 15 [ENAMETOOLONG] A component of a pathname exceeded 255 characters, or an entire path name exceeded 1023 characters. .TP 15 [ENOENT] The named file does not exist. .TP 15 [EACCES] Search permission is denied for a component of the path prefix. .TP 15 [EACCES] Write permission is denied on the directory containing the link to be removed. .TP 15 [ELOOP] Too many symbolic links were encountered in translating the pathname. .TP 15 [EPERM] The named file is a directory and the effective user ID of the process is not the super-user. .TP 15 [EPERM] The directory containing the file is marked sticky, and neither the containing directory nor the file to be removed are owned by the effective user ID. .TP 15 [EBUSY] The entry to be unlinked is the mount point for a mounted file system. .TP 15 [EIO] An I/O error occurred while deleting the directory entry or deallocating the inode. .TP 15 [EROFS] The named file resides on a read-only file system. .TP 15 [EFAULT] .I Path points outside the process's allocated address space. .SH "SEE ALSO" close(2), link(2), rmdir(2) ================================================ FILE: share/man/man2/utimes.2 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)utimes.2 6.4 (Berkeley) 8/26/85 .\" .TH UTIMES 2 "August 26, 1985" .UC 4 .SH NAME utimes \- set file times .SH SYNOPSIS .nf .ft B #include .PP .ft B utimes(file, tvp) char *file; struct timeval tvp[2]; .fi .SH DESCRIPTION The .I utimes call uses the \*(lqaccessed\*(rq and \*(lqupdated\*(rq times in that order from the .I tvp vector to set the corresponding recorded times for .I file. .PP The caller must be the owner of the file or the super-user. The \*(lqinode-changed\*(rq time of the file is set to the current time. .SH "RETURN VALUE Upon successful completion, a value of 0 is returned. Otherwise, a value of \-1 is returned and .I errno is set to indicate the error. .SH "ERRORS .I Utime will fail if one or more of the following are true: .TP 15 [ENOTDIR] A component of the path prefix is not a directory. .TP 15 [EINVAL] The pathname contains a character with the high-order bit set. .TP 15 [ENAMETOOLONG] A component of a pathname exceeded 255 characters, or an entire path name exceeded 1023 characters. .TP 15 [ENOENT] The named file does not exist. .TP 15 [ELOOP] Too many symbolic links were encountered in translating the pathname. .TP 15 [EPERM] The process is not super-user and not the owner of the file. .TP 15 [EACCES] Search permission is denied for a component of the path prefix. .TP 15 [EROFS] The file system containing the file is mounted read-only. .TP 15 [EFAULT] .I File or \fItvp\fP points outside the process's allocated address space. .TP 15 [EIO] An I/O error occurred while reading or writing the affected inode. .SH SEE ALSO stat(2) ================================================ FILE: share/man/man2/vfork.2 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)vfork.2 6.2 (Berkeley) 6/30/85 .\" .TH VFORK 2 "June 30, 1985" .UC 4 .SH NAME vfork \- spawn new process in a virtual memory efficient way .SH SYNOPSIS .B pid = vfork() .br .B int pid; .SH DESCRIPTION .I Vfork can be used to create new processes without fully copying the address space of the old process, which is horrendously inefficient in a paged environment. It is useful when the purpose of .IR fork (2) would have been to create a new system context for an .IR execve . .I Vfork differs from .I fork in that the child borrows the parent's memory and thread of control until a call to .IR execve (2) or an exit (either by a call to .IR exit (2) or abnormally.) The parent process is suspended while the child is using its resources. .PP .I Vfork returns 0 in the child's context and (later) the pid of the child in the parent's context. .PP .I Vfork can normally be used just like .I fork. It does not work, however, to return while running in the childs context from the procedure that called .I vfork since the eventual return from .I vfork would then return to a no longer existent stack frame. Be careful, also, to call .I _exit rather than .I exit if you can't .IR execve , since .I exit will flush and close standard I/O channels, and thereby mess up the parent processes standard I/O data structures. (Even with .I fork it is wrong to call .I exit since buffered data would then be flushed twice.) .SH SEE ALSO fork(2), execve(2), sigvec(2), wait(2), .SH DIAGNOSTICS Same as for .IR fork . .SH BUGS This system call will be eliminated when proper system sharing mechanisms are implemented. Users should not depend on the memory sharing semantics of .I vfork as it will, in that case, be made synonymous to .IR fork . .PP To avoid a possible deadlock situation, processes that are children in the middle of a .I vfork are never sent SIGTTOU or SIGTTIN signals; rather, output or .IR ioctl s are allowed and input attempts result in an end-of-file indication. ================================================ FILE: share/man/man2/vhangup.2 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)vhangup.2 6.2 (Berkeley) 6/30/85 .\" .TH VHANGUP 2 "June 30, 1985" .UC 4 .SH NAME vhangup \- virtually ``hangup'' the current control terminal .SH SYNOPSIS .B vhangup() .SH DESCRIPTION .I Vhangup is used by the initialization process .IR init (8) (among others) to arrange that users are given \*(lqclean\*(rq' terminals at login, by revoking access of the previous users' processes to the terminal. To effect this, .I vhangup searches the system tables for references to the control terminal of the invoking process, revoking access permissions on each instance of the terminal that it finds. Further attempts to access the terminal by the affected processes will yield i/o errors (EBADF). Finally, a hangup signal (SIGHUP) is sent to the process group of the control terminal. .SH SEE ALSO init (8) .SH BUGS Access to the control terminal via .B /dev/tty is still possible. .PP This call should be replaced by an automatic mechanism that takes place on process exit. ================================================ FILE: share/man/man2/wait.2 ================================================ .\" Copyright (c) 1980, 1991 Regents of the University of California. .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. All advertising materials mentioning features or use of this software .\" must display the following acknowledgement: .\" This product includes software developed by the University of .\" California, Berkeley and its contributors. .\" 4. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)wait.2 6.5 (Berkeley) 3/10/91 .\" .TH WAIT 2 "March 12, 1993" .UC 4 .SH NAME wait, waitpid, wait4, wait3 \- wait for process terminatation .SH SYNOPSIS .ft B .nf #include #include .PP .ft B pid = wait(status) int pid; union wait *status; .PP .ft B #include #include .PP .ft B pid = waitpid(wpid, status, options); int pid; int wpid; union wait *status; int options; .PP .ft B pid = wait3(status, options, rusage); int pid; union wait *status; int options; struct rusage *rusage; .PP .ft B pid = wait4(wpid, status, options, rusage); int pid; int wpid; union wait *status; int options; struct rusage *rusage; .SH DESCRIPTION The .I wait function suspends execution of its calling process until .B status information is available for a terminated child process, or a signal is received. On return from a successful .I wait call, the .B status area contains termination information about the process that exited as defined below. .PP The .I wait4 call provides a more general interface for programs that need to wait for certain child processes, that need resource utilization statistics accummulated by child processes, or that require options. The other wait functions are implemented using .I wait4 . .PP The .B wpid parameter specifies the set of child processes for which to wait. If .B wpid is -1, the call waits for any child process. If .B wpid is 0, the call waits for any child process in the process group of the caller. If .B wpid is greater than zero, the call waits for the process with process id .B wpid . If .B wpid is less than -1, the call waits for any process whose process group id equals the absolute value of .B wpid . .PP The .B status parameter is defined below. The .B options parameter contains the bitwise OR of any of the following options. The .B WNOHANG option is used to indicate that the call should not block if there are no processes that wish to report status. If the .B WUNTRACED option is set, children of the current process that are stopped due to a .B SIGTTIN , SIGTTOU , SIGTSTP , or .B SIGSTOP signal also have their status reported. .PP If .B rusage is non-zero, a summary of the resources used by the terminated process and all its children is returned (this information is currently not available for stopped processes). .PP When the .B WNOHANG option is specified and no processes wish to report status, .I wait4 returns a process id of 0. .PP The .I waitpid call is identical to .I wait4 with an .B rusage value of zero. The older .I wait3 call is the same as .I wait4 with a .B wpid value of -1. .PP The following macros may be used to test the manner of exit of the process. One of the first three macros will evaluate to a non-zero (true) value: .sp .I WIFEXITED(status) \- True if the process terminated normally by a call to .I _exit(2) or .I exit(2) . .sp .I WIFSIGNALED(status) \- True if the process terminated due to receipt of a signal. .sp .I WIFSTOPPED(status) \- True if the process has not terminated, but has stopped and can be restarted. This macro can be true only if the wait call specified the .B WUNTRACED option or if the child process is being traced (see \fIptrace(2)\fP). .PP Depending on the values of those macros, the following macros produce the remaining status information about the child process: .sp .I WEXITSTATUS(status) \- If \fIWIFEXITED(status)\fP is true, evaluates to the low-order 8 bits of the argument passed to \fI_exit(2)\fP or \fIexit(2)\fP by the child. .sp .I WTERMSIG(status) \- If \fIWIFSIGNALED(status)\fP is true, evaluates to the number of the signal that caused the termination of the process. .sp .I WCOREDUMP(status) If \fIWIFSIGNALED(status)\fP is true, evaluates as true if the termination of the process was accompanied by the creation of a core file containing an image of the process when the signal was received. .sp .I WSTOPSIG(status)\fP If \fIWIFSTOPPED(status)\fP is true, evaluates to the number of the signal that caused the process to stop. .SH NOTES See .I sigvec(2) for a list of termination signals. A status of 0 indicates normal termination. .PP If a parent process terminates without waiting for all of its child processes to terminate, the remaining child processes are assigned the parent process 1 ID (the init process ID). .PP If a signal is caught while any of the .I wait calls is pending, the call may be interrupted or restarted when the signal-catching routine returns, depending on the options in effect for the signal; see \fIintro(2)\fP, System call restart. .SH RETURN VALUES If .I wait() returns due to a stopped or terminated child process, the process ID of the child is returned to the calling process. Otherwise, a value of -1 is returned and .I errno is set to indicate the error. .PP If .I wait4(), wait3() or waitpid() returns due to a stopped or terminated child process, the process ID of the child is returned to the calling process. If there are no children not previously awaited, -1 is returned with .I errno set to .B [ECHILD]. Otherwise, if .B WNOHANG is specified and there are no stopped or exited children, 0 is returned. If an error is detected or a caught signal aborts the call, a value of -1 is returned and .I errno is set to indicate the error. .SH ERRORS .I Wait() will fail and return immediately if: .TP 15 [ECHILD] The calling process has no existing unwaited-for child processes. .TP 15 [EFAULT] The \fIstatus\fP or \fIrusage\fP arguments point to an illegal address. (May not be detected before exit of a child process.) .TP 15 [EINTR] The call was interrupted by a caught signal, or the signal had the .I SV_INTERRUPT flag set. .SH STANDARDS The .I wait and .I waitpid functions are defined by POSIX; .I wait4 and .I wait3 are not specified by POSIX. The .I WCOREDUMP macro and the ability to restart a pending .I wait call are extensions to the POSIX interface. .SH SEE ALSO .I exit(2) , .I sigvec(2) .Sh HISTORY A .I wait function call appeared in Version 6 AT&T UNIX. ================================================ FILE: share/man/man2/write.2 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)write.2 6.5 (Berkeley) 8/1/87 .\" .TH WRITE 2 "August 1, 1987" .UC 4 .SH NAME write, writev \- write output .SH SYNOPSIS .nf .ft B cc = write(d, buf, nbytes) int cc, d; char *buf; unsigned short nbytes; .PP .ft B #include #include .PP .ft B cc = writev(d, iov, iovcnt) int cc, d; struct iovec *iov; int iovcnt; .fi .SH DESCRIPTION .I Write attempts to write .I nbytes of data to the object referenced by the descriptor .I d from the buffer pointed to by .IR buf . .I Writev performs the same action, but gathers the output data from the .I iovcnt buffers specified by the members of the .I iov array: iov[0], iov[1], ..., iov[iovcnt\|\-\|1]. .PP For .IR writev , the .I iovec structure is defined as .PP .nf .RS .DT struct iovec { caddr_t iov_base; u_short iov_len; }; .RE .fi .PP Each .I iovec entry specifies the base address and length of an area in memory from which data should be written. .I Writev will always write a complete area before proceeding to the next. .PP On objects capable of seeking, the \fIwrite\fP starts at a position given by the pointer associated with .IR d , see .IR lseek (2). Upon return from .IR write , the pointer is incremented by the number of bytes actually written. .PP Objects that are not capable of seeking always write from the current position. The value of the pointer associated with such an object is undefined. .PP If the real user is not the super-user, then .I write clears the set-user-id bit on a file. This prevents penetration of system security by a user who \*(lqcaptures\*(rq a writable set-user-id file owned by the super-user. .PP When using non-blocking I/O on objects such as sockets that are subject to flow control, .I write and .I writev may write fewer bytes than requested; the return value must be noted, and the remainder of the operation should be retried when possible. .SH "RETURN VALUE Upon successful completion the number of bytes actually written is returned. Otherwise a \-1 is returned and the global variable .I errno is set to indicate the error. .SH ERRORS .I Write and .I writev will fail and the file pointer will remain unchanged if one or more of the following are true: .TP 15 [EBADF] \fID\fP is not a valid descriptor open for writing. .TP 15 [EPIPE] An attempt is made to write to a pipe that is not open for reading by any process. .TP 15 [EPIPE] An attempt is made to write to a socket of type SOCK_STREAM that is not connected to a peer socket. .TP 15 [EFBIG] An attempt was made to write a file that exceeds the process's file size limit or the maximum file size. .TP 15 [EFAULT] Part of \fIiov\fP or data to be written to the file points outside the process's allocated address space. .TP 15 [EINVAL] The pointer associated with .I d was negative. .TP 15 [ENOSPC] There is no free space remaining on the file system containing the file. .TP 15 [EDQUOT] The user's quota of disk blocks on the file system containing the file has been exhausted. .TP 15 [EIO] An I/O error occurred while reading from or writing to the file system. .TP 15 [EWOULDBLOCK] The file was marked for non-blocking I/O, and no data could be written immediately. .PP In addition, .I writev may return one of the following errors: .TP 15 [EINVAL] .I Iovcnt was less than or equal to 0, or greater than 16. .TP 15 [EINVAL] The sum of the .I iov_len values in the .I iov array overflowed a short. .SH "SEE ALSO" fcntl(2), lseek(2), open(2), pipe(2), select(2) ================================================ FILE: share/man/man3/Makefile ================================================ # # Copyright (c) 1987 Regents of the University of California. # All rights reserved. # # Redistribution and use in source and binary forms are permitted # provided that the above copyright notice and this paragraph are # duplicated in all such forms and that any documentation, # advertising materials, and other materials related to such # distribution and use acknowledge that the software was developed # by the University of California, Berkeley. The name of the # University may not be used to endorse or promote products derived # from this software without specific prior written permission. # THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED # WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. # # @(#)Makefile 5.4.15 (2.11BSD) 1997/12/8 # TOPSRC!=cd ../../..; pwd include ${TOPSRC}/share/mk/sys.mk MDIR= /usr/share/man/cat3 SRCS1= abort.3 abs.3 alarm.3 asinh.3 assert.3 atof.3 \ basename.3 bstring.3 byteorder.3 \ compat-sys5.3 crypt.3 ctime.3 ctype.3 curses.3 dbm.3 daemon.3 \ devname.3 directory.3 dirname.3 \ ecvt.3 end.3 erf.3 err.3 execl.3 exit.3 \ exp.3 fclose.3 ferror.3 floor.3 \ fopen.3 fread.3 frexp.3 fseek.3 getc.3 getdisk.3 getenv.3 getfsent.3 \ getgrent.3 gethostbyname.3 getnetent.3 getopt.3 getpass.3 \ getgrouplist.3 getloadavg.3 getmntinfo.3 getsubopt.3 \ getprotoent.3 getpwent.3 gets.3 getservent.3 getttyent.3 \ getusershell.3 getwd.3 hypot.3 ieee.3 inet.3 infnan.3 initgroups.3 SRCS2= insque.3 intro.3 j0.3 l3tol.3 ldfps.3 lgamma.3 lib2648.3 \ malloc.3 math.3 mktemp.3 monitor.3 mp.3 ndbm.3 nice.3 nlist.3 ns.3 \ pause.3 perror.3 plot.3 popen.3 printf.3 psignal.3 putc.3 puts.3 \ qsort.3 rand.3 random.3 rcmd.3 regex.3 resolver.3 rexec.3 scandir.3 \ scanf.3 setbuf.3 setjmp.3 siginterrupt.3 signal.3 sin.3 \ sinh.3 sleep.3 sqrt.3 stdio.3 strftime.3 string.3 strtok.3 stty.3 \ setmode.3 setruid.3 sigsetops.3 \ strcspn.3 strlcpy.3 strpbrk.3 \ strsep.3 strspn.3 strtol.3 strtoul.3 strstr.3 \ swab.3 sysctl.3 syslog.3 \ system.3 termcap.3 time.3 times.3 ttyname.3 ualarm.3 uname.3 ungetc.3 \ syserrlst.3 \ utime.3 valloc.3 varargs.3 OBJS1= abort.0 abs.0 alarm.0 asinh.0 assert.0 atof.0 \ basename.0 bstring.0 byteorder.0 \ compat-sys5.0 crypt.0 ctime.0 ctype.0 curses.0 dbm.0 daemon.0 \ devname.0 directory.0 dirname.0 \ ecvt.0 end.0 erf.0 err.0 execl.0 exit.0 \ exp.0 fclose.0 ferror.0 floor.0 \ fopen.0 fread.0 frexp.0 fseek.0 getc.0 getdisk.0 getenv.0 getfsent.0 \ getgrent.0 gethostbyname.0 getnetent.0 getopt.0 getpass.0 \ getprotoent.0 getpwent.0 gets.0 getservent.0 getttyent.0 \ getgrouplist.0 getloadavg.0 getmntinfo.0 getsubopt.0 \ getusershell.0 getwd.0 hypot.0 ieee.0 inet.0 infnan.0 initgroups.0 OBJS2= insque.0 intro.0 j0.0 l3tol.0 ldfps.0 lgamma.0 lib2648.0 \ malloc.0 math.0 mktemp.0 monitor.0 mp.0 ndbm.0 nice.0 nlist.0 ns.0 \ pause.0 perror.0 plot.0 popen.0 printf.0 psignal.0 putc.0 puts.0 \ qsort.0 rand.0 random.0 rcmd.0 regex.0 resolver.0 rexec.0 scandir.0 \ scanf.0 setbuf.0 setjmp.0 siginterrupt.0 signal.0 sin.0 \ sinh.0 sleep.0 sqrt.0 stdio.0 strftime.0 string.0 strtok.0 stty.0 \ setmode.0 setruid.0 sigsetops.0 \ strcspn.0 strlcpy.0 strpbrk.0 \ strsep.0 strspn.0 strtol.0 strtoul.0 strstr.0 \ swab.0 sysctl.0 syslog.0 \ system.0 termcap.0 time.0 times.0 ttyname.0 ualarm.0 uname.0 ungetc.0 \ syserrlst.0 \ utime.0 valloc.0 varargs.0 REMO1= edata.0 etext.0 j1.0 jn.0 ns_addr.0 ns_ntoa.0 y0.0 y1.0 yn.0 acos.0 \ asin.0 atan.0 atan2.0 atoi.0 atol.0 cos.0 dbm_clearerr.0 dbm_close.0 \ dbm_delete.0 dbm_error.0 dbm_fetch.0 dbm_firstkey.0 dbm_nextkey.0 \ dbm_open.0 dbm_store.0 dbminit.0 delete.0 erfc.0 expm1.0 fcvt.0 \ fetch.0 firstkey.0 gcvt.0 log.0 log10.0 log1p.0 nextkey.0 pow.0 \ rresvport.0 ruserok.0 store.0 tan.0 addr.0 arc.0 asctime.0 cbrt.0 \ circle.0 comp.0 cont.0 copysign.0 cosh.0 drem.0 encrypt.0 environ.0 \ erase.0 execle.0 execlp.0 exect.0 execv.0 execve.0 execvp.0 fgetc.0 \ fgets.0 finite.0 fputc.0 fputs.0 ftime.0 getchar.0 getw.0 gmtime.0 \ gtty.0 inet_addr.0 inet_lnaof.0 inet_makeaddr.0 inet_netof.0 \ inet_network.0 inet_ntoa.0 isalnum.0 isalpha.0 isascii.0 iscntrl.0 \ isdigit.0 islower.0 isprint.0 ispunct.0 isspace.0 isupper.0 \ isxdigit.0 label.0 ldexp.0 line.0 linemod.0 localtime.0 logb.0 modf.0 \ move.0 network.0 ntoa.0 openpl.0 pclose.0 point.0 putchar.0 putw.0 REMO2= re_comp.0 re_exec.0 scalb.0 setkey.0 space.0 srand.0 tanh.0 \ timezone.0 toascii.0 tolower.0 toupper.0 ltol3.0 _longjmp.0 \ _setjmp.0 acosh.0 alloca.0 atanh.0 cabs.0 calloc.0 ceil.0 \ closelog.0 fabs.0 fdopen.0 free.0 freopen.0 fscanf.0 \ ftell.0 fwrite.0 index.0 initstate.0 longjmp.0 mkstemp.0 openlog.0 \ realloc.0 remque.0 rewind.0 rindex.0 rint.0 \ setlogmask.0 setstate.0 setrgid.0 srandom.0 \ sscanf.0 strcat.0 strcmp.0 strcpy.0 strlen.0 strncat.0 strncmp.0 \ strncpy.0 strcasecmp.0 strncasecmp.0 \ strerror.0 \ sprintf.0 vfprintf.0 vprintf.0 vsprintf.0 alphasort.0 bcmp.0 bcopy.0 \ bzero.0 clearerr.0 feof.0 fflush.0 ffs.0 fileno.0 fprintf.0 gamma.0 \ getdiskbyname.0 isatty.0 moncontrol.0 monstartup.0 setbuffer.0 \ setlinebuf.0 setvbuf.0 sys_siglist.0 ttyslot.0 endfsent.0 endgrent.0 \ endpwent.0 getfsfile.0 getfsspec.0 getfstype.0 getgrgid.0 REMO3= getgrnam.0 getpwnam.0 getpwuid.0 setfsent.0 setgrent.0 setpwent.0 \ setpwfile.0 tgetent.0 tgetflag.0 tgetnum.0 tgetstr.0 tgoto.0 tputs.0 \ closedir.0 endttyent.0 getttynam.0 opendir.0 readdir.0 rewinddir.0 \ seekdir.0 setttyent.0 telldir.0 endnetent.0 getnetbyaddr.0 \ getnetbyname.0 htonl.0 htons.0 ntohl.0 ntohs.0 setnetent.0 \ endservent.0 getservbyname.0 getservbyport.0 setservent.0 \ endprotoent.0 endusershell.0 getprotobyname.0 getprotobynumber.0 \ setprotoent.0 setusershell.0 endhostent.0 gethostbyaddr.0 gethostent.0 \ sethostent.0 sethostfile.0 memccpy.0 memchr.0 memcmp.0 memcpy.0 \ memset.0 strchr.0 strrchr.0 tmpnam.0 tmpfile.0 \ tempnam.0 getmode.0 usleep.0 setenv.0 unsetenv.0 REMO4= verr.0 errx.0 verrx.0 warn.0 warnx.0 vwarnx.0 REMO5 = sigaddset.0 sigdelset.0 sigemptyset.0 sigfillset.0 sigismember.0 .SUFFIXES: .3 .0 .3.0: ${MANROFF} $*.3 > $*.0 all: _make_01 _make_02 _make_01: ${OBJS1} _make_02: ${OBJS2} clean: FRC rm -f ${OBJS1} rm -f ${OBJS2} install: _make_01 _make_02 cp ${OBJS1} ${DESTDIR}${MDIR} cp ${OBJS2} ${DESTDIR}${MDIR} for i in ${REMO4}; do \ ln -f ${DESTDIR}/${MDIR}/err.0 ${DESTDIR}${MDIR}/$$i; \ done for i in ${REMO5}; do \ ln -f ${DESTDIR}/${MDIR}/sigsetops.0 ${DESTDIR}${MDIR}/$$i; \ done ln -f ${DESTDIR}${MDIR}/end.0 ${DESTDIR}${MDIR}/edata.0 ln -f ${DESTDIR}${MDIR}/end.0 ${DESTDIR}${MDIR}/etext.0 ln -f ${DESTDIR}${MDIR}/j0.0 ${DESTDIR}${MDIR}/j1.0 ln -f ${DESTDIR}${MDIR}/j0.0 ${DESTDIR}${MDIR}/jn.0 ln -f ${DESTDIR}${MDIR}/ns.0 ${DESTDIR}${MDIR}/ns_addr.0 ln -f ${DESTDIR}${MDIR}/ns.0 ${DESTDIR}${MDIR}/ns_ntoa.0 ln -f ${DESTDIR}${MDIR}/j0.0 ${DESTDIR}${MDIR}/y0.0 ln -f ${DESTDIR}${MDIR}/j0.0 ${DESTDIR}${MDIR}/y1.0 ln -f ${DESTDIR}${MDIR}/j0.0 ${DESTDIR}${MDIR}/yn.0 ln -f ${DESTDIR}${MDIR}/sin.0 ${DESTDIR}${MDIR}/acos.0 ln -f ${DESTDIR}${MDIR}/sin.0 ${DESTDIR}${MDIR}/asin.0 ln -f ${DESTDIR}${MDIR}/sin.0 ${DESTDIR}${MDIR}/atan.0 ln -f ${DESTDIR}${MDIR}/sin.0 ${DESTDIR}${MDIR}/atan2.0 ln -f ${DESTDIR}${MDIR}/atof.0 ${DESTDIR}${MDIR}/atoi.0 ln -f ${DESTDIR}${MDIR}/atof.0 ${DESTDIR}${MDIR}/atol.0 ln -f ${DESTDIR}${MDIR}/sin.0 ${DESTDIR}${MDIR}/cos.0 ln -f ${DESTDIR}${MDIR}/ndbm.0 ${DESTDIR}${MDIR}/dbm_clearerr.0 ln -f ${DESTDIR}${MDIR}/ndbm.0 ${DESTDIR}${MDIR}/dbm_close.0 ln -f ${DESTDIR}${MDIR}/ndbm.0 ${DESTDIR}${MDIR}/dbm_delete.0 ln -f ${DESTDIR}${MDIR}/ndbm.0 ${DESTDIR}${MDIR}/dbm_error.0 ln -f ${DESTDIR}${MDIR}/ndbm.0 ${DESTDIR}${MDIR}/dbm_fetch.0 ln -f ${DESTDIR}${MDIR}/ndbm.0 ${DESTDIR}${MDIR}/dbm_firstkey.0 ln -f ${DESTDIR}${MDIR}/ndbm.0 ${DESTDIR}${MDIR}/dbm_nextkey.0 ln -f ${DESTDIR}${MDIR}/ndbm.0 ${DESTDIR}${MDIR}/dbm_open.0 ln -f ${DESTDIR}${MDIR}/ndbm.0 ${DESTDIR}${MDIR}/dbm_store.0 ln -f ${DESTDIR}${MDIR}/dbm.0 ${DESTDIR}${MDIR}/dbminit.0 ln -f ${DESTDIR}${MDIR}/dbm.0 ${DESTDIR}${MDIR}/delete.0 ln -f ${DESTDIR}${MDIR}/erf.0 ${DESTDIR}${MDIR}/erfc.0 ln -f ${DESTDIR}${MDIR}/exp.0 ${DESTDIR}${MDIR}/expm1.0 ln -f ${DESTDIR}${MDIR}/ecvt.0 ${DESTDIR}${MDIR}/fcvt.0 ln -f ${DESTDIR}${MDIR}/dbm.0 ${DESTDIR}${MDIR}/fetch.0 ln -f ${DESTDIR}${MDIR}/dbm.0 ${DESTDIR}${MDIR}/firstkey.0 ln -f ${DESTDIR}${MDIR}/ecvt.0 ${DESTDIR}${MDIR}/gcvt.0 ln -f ${DESTDIR}${MDIR}/exp.0 ${DESTDIR}${MDIR}/log.0 ln -f ${DESTDIR}${MDIR}/exp.0 ${DESTDIR}${MDIR}/log10.0 ln -f ${DESTDIR}${MDIR}/exp.0 ${DESTDIR}${MDIR}/log1p.0 ln -f ${DESTDIR}${MDIR}/dbm.0 ${DESTDIR}${MDIR}/nextkey.0 ln -f ${DESTDIR}${MDIR}/exp.0 ${DESTDIR}${MDIR}/pow.0 ln -f ${DESTDIR}${MDIR}/rcmd.0 ${DESTDIR}${MDIR}/rresvport.0 ln -f ${DESTDIR}${MDIR}/rcmd.0 ${DESTDIR}${MDIR}/ruserok.0 ln -f ${DESTDIR}${MDIR}/dbm.0 ${DESTDIR}${MDIR}/store.0 ln -f ${DESTDIR}${MDIR}/sin.0 ${DESTDIR}${MDIR}/tan.0 ln -f ${DESTDIR}${MDIR}/inet.0 ${DESTDIR}${MDIR}/addr.0 ln -f ${DESTDIR}${MDIR}/plot.0 ${DESTDIR}${MDIR}/arc.0 ln -f ${DESTDIR}${MDIR}/ctime.0 ${DESTDIR}${MDIR}/asctime.0 ln -f ${DESTDIR}${MDIR}/sqrt.0 ${DESTDIR}${MDIR}/cbrt.0 ln -f ${DESTDIR}${MDIR}/plot.0 ${DESTDIR}${MDIR}/circle.0 ln -f ${DESTDIR}${MDIR}/regex.0 ${DESTDIR}${MDIR}/comp.0 ln -f ${DESTDIR}${MDIR}/plot.0 ${DESTDIR}${MDIR}/cont.0 ln -f ${DESTDIR}${MDIR}/ieee.0 ${DESTDIR}${MDIR}/copysign.0 ln -f ${DESTDIR}${MDIR}/sinh.0 ${DESTDIR}${MDIR}/cosh.0 ln -f ${DESTDIR}${MDIR}/ieee.0 ${DESTDIR}${MDIR}/drem.0 ln -f ${DESTDIR}${MDIR}/crypt.0 ${DESTDIR}${MDIR}/encrypt.0 ln -f ${DESTDIR}${MDIR}/execl.0 ${DESTDIR}${MDIR}/environ.0 ln -f ${DESTDIR}${MDIR}/plot.0 ${DESTDIR}${MDIR}/erase.0 ln -f ${DESTDIR}${MDIR}/execl.0 ${DESTDIR}${MDIR}/execle.0 ln -f ${DESTDIR}${MDIR}/execl.0 ${DESTDIR}${MDIR}/execlp.0 ln -f ${DESTDIR}${MDIR}/execl.0 ${DESTDIR}${MDIR}/exect.0 ln -f ${DESTDIR}${MDIR}/execl.0 ${DESTDIR}${MDIR}/execv.0 ln -f ${DESTDIR}${MDIR}/execl.0 ${DESTDIR}${MDIR}/execve.0 ln -f ${DESTDIR}${MDIR}/execl.0 ${DESTDIR}${MDIR}/execvp.0 ln -f ${DESTDIR}${MDIR}/getc.0 ${DESTDIR}${MDIR}/fgetc.0 ln -f ${DESTDIR}${MDIR}/gets.0 ${DESTDIR}${MDIR}/fgets.0 ln -f ${DESTDIR}${MDIR}/ieee.0 ${DESTDIR}${MDIR}/finite.0 ln -f ${DESTDIR}${MDIR}/putc.0 ${DESTDIR}${MDIR}/fputc.0 ln -f ${DESTDIR}${MDIR}/puts.0 ${DESTDIR}${MDIR}/fputs.0 ln -f ${DESTDIR}${MDIR}/time.0 ${DESTDIR}${MDIR}/ftime.0 ln -f ${DESTDIR}${MDIR}/getc.0 ${DESTDIR}${MDIR}/getchar.0 ln -f ${DESTDIR}${MDIR}/getc.0 ${DESTDIR}${MDIR}/getw.0 ln -f ${DESTDIR}${MDIR}/ctime.0 ${DESTDIR}${MDIR}/gmtime.0 ln -f ${DESTDIR}${MDIR}/stty.0 ${DESTDIR}${MDIR}/gtty.0 ln -f ${DESTDIR}${MDIR}/inet.0 ${DESTDIR}${MDIR}/inet_addr.0 ln -f ${DESTDIR}${MDIR}/inet.0 ${DESTDIR}${MDIR}/inet_lnaof.0 ln -f ${DESTDIR}${MDIR}/inet.0 ${DESTDIR}${MDIR}/inet_makeaddr.0 ln -f ${DESTDIR}${MDIR}/inet.0 ${DESTDIR}${MDIR}/inet_netof.0 ln -f ${DESTDIR}${MDIR}/inet.0 ${DESTDIR}${MDIR}/inet_network.0 ln -f ${DESTDIR}${MDIR}/inet.0 ${DESTDIR}${MDIR}/inet_ntoa.0 ln -f ${DESTDIR}${MDIR}/ctype.0 ${DESTDIR}${MDIR}/isalnum.0 ln -f ${DESTDIR}${MDIR}/ctype.0 ${DESTDIR}${MDIR}/isalpha.0 ln -f ${DESTDIR}${MDIR}/ctype.0 ${DESTDIR}${MDIR}/isascii.0 ln -f ${DESTDIR}${MDIR}/ctype.0 ${DESTDIR}${MDIR}/iscntrl.0 ln -f ${DESTDIR}${MDIR}/ctype.0 ${DESTDIR}${MDIR}/isdigit.0 ln -f ${DESTDIR}${MDIR}/ctype.0 ${DESTDIR}${MDIR}/islower.0 ln -f ${DESTDIR}${MDIR}/ctype.0 ${DESTDIR}${MDIR}/isprint.0 ln -f ${DESTDIR}${MDIR}/ctype.0 ${DESTDIR}${MDIR}/ispunct.0 ln -f ${DESTDIR}${MDIR}/ctype.0 ${DESTDIR}${MDIR}/isspace.0 ln -f ${DESTDIR}${MDIR}/ctype.0 ${DESTDIR}${MDIR}/isupper.0 ln -f ${DESTDIR}${MDIR}/ctype.0 ${DESTDIR}${MDIR}/isxdigit.0 ln -f ${DESTDIR}${MDIR}/plot.0 ${DESTDIR}${MDIR}/label.0 ln -f ${DESTDIR}${MDIR}/frexp.0 ${DESTDIR}${MDIR}/ldexp.0 ln -f ${DESTDIR}${MDIR}/plot.0 ${DESTDIR}${MDIR}/line.0 ln -f ${DESTDIR}${MDIR}/plot.0 ${DESTDIR}${MDIR}/linemod.0 ln -f ${DESTDIR}${MDIR}/ctime.0 ${DESTDIR}${MDIR}/localtime.0 ln -f ${DESTDIR}${MDIR}/ieee.0 ${DESTDIR}${MDIR}/logb.0 ln -f ${DESTDIR}${MDIR}/frexp.0 ${DESTDIR}${MDIR}/modf.0 ln -f ${DESTDIR}${MDIR}/plot.0 ${DESTDIR}${MDIR}/move.0 ln -f ${DESTDIR}${MDIR}/inet.0 ${DESTDIR}${MDIR}/network.0 ln -f ${DESTDIR}${MDIR}/inet.0 ${DESTDIR}${MDIR}/ntoa.0 ln -f ${DESTDIR}${MDIR}/plot.0 ${DESTDIR}${MDIR}/openpl.0 ln -f ${DESTDIR}${MDIR}/popen.0 ${DESTDIR}${MDIR}/pclose.0 ln -f ${DESTDIR}${MDIR}/plot.0 ${DESTDIR}${MDIR}/point.0 ln -f ${DESTDIR}${MDIR}/putc.0 ${DESTDIR}${MDIR}/putchar.0 ln -f ${DESTDIR}${MDIR}/putc.0 ${DESTDIR}${MDIR}/putw.0 ln -f ${DESTDIR}${MDIR}/regex.0 ${DESTDIR}${MDIR}/re_comp.0 ln -f ${DESTDIR}${MDIR}/regex.0 ${DESTDIR}${MDIR}/re_exec.0 ln -f ${DESTDIR}${MDIR}/ieee.0 ${DESTDIR}${MDIR}/scalb.0 ln -f ${DESTDIR}${MDIR}/crypt.0 ${DESTDIR}${MDIR}/setkey.0 ln -f ${DESTDIR}${MDIR}/plot.0 ${DESTDIR}${MDIR}/space.0 ln -f ${DESTDIR}${MDIR}/rand.0 ${DESTDIR}${MDIR}/srand.0 ln -f ${DESTDIR}${MDIR}/sinh.0 ${DESTDIR}${MDIR}/tanh.0 ln -f ${DESTDIR}${MDIR}/ctime.0 ${DESTDIR}${MDIR}/timezone.0 ln -f ${DESTDIR}${MDIR}/ctype.0 ${DESTDIR}${MDIR}/toascii.0 ln -f ${DESTDIR}${MDIR}/ctype.0 ${DESTDIR}${MDIR}/tolower.0 ln -f ${DESTDIR}${MDIR}/ctype.0 ${DESTDIR}${MDIR}/toupper.0 ln -f ${DESTDIR}${MDIR}/l3tol.0 ${DESTDIR}${MDIR}/ltol3.0 ln -f ${DESTDIR}${MDIR}/setjmp.0 ${DESTDIR}${MDIR}/_longjmp.0 ln -f ${DESTDIR}${MDIR}/setjmp.0 ${DESTDIR}${MDIR}/_setjmp.0 ln -f ${DESTDIR}${MDIR}/asinh.0 ${DESTDIR}${MDIR}/acosh.0 ln -f ${DESTDIR}${MDIR}/malloc.0 ${DESTDIR}${MDIR}/alloca.0 ln -f ${DESTDIR}${MDIR}/asinh.0 ${DESTDIR}${MDIR}/atanh.0 ln -f ${DESTDIR}${MDIR}/hypot.0 ${DESTDIR}${MDIR}/cabs.0 ln -f ${DESTDIR}${MDIR}/malloc.0 ${DESTDIR}${MDIR}/calloc.0 ln -f ${DESTDIR}${MDIR}/floor.0 ${DESTDIR}${MDIR}/ceil.0 ln -f ${DESTDIR}${MDIR}/syslog.0 ${DESTDIR}${MDIR}/closelog.0 ln -f ${DESTDIR}${MDIR}/perror.0 ${DESTDIR}${MDIR}/strerror.0 ln -f ${DESTDIR}${MDIR}/floor.0 ${DESTDIR}${MDIR}/fabs.0 ln -f ${DESTDIR}${MDIR}/fopen.0 ${DESTDIR}${MDIR}/fdopen.0 ln -f ${DESTDIR}${MDIR}/malloc.0 ${DESTDIR}${MDIR}/free.0 ln -f ${DESTDIR}${MDIR}/fopen.0 ${DESTDIR}${MDIR}/freopen.0 ln -f ${DESTDIR}${MDIR}/scanf.0 ${DESTDIR}${MDIR}/fscanf.0 ln -f ${DESTDIR}${MDIR}/fseek.0 ${DESTDIR}${MDIR}/ftell.0 ln -f ${DESTDIR}${MDIR}/fread.0 ${DESTDIR}${MDIR}/fwrite.0 ln -f ${DESTDIR}${MDIR}/string.0 ${DESTDIR}${MDIR}/index.0 ln -f ${DESTDIR}${MDIR}/random.0 ${DESTDIR}${MDIR}/initstate.0 ln -f ${DESTDIR}${MDIR}/setjmp.0 ${DESTDIR}${MDIR}/longjmp.0 ln -f ${DESTDIR}${MDIR}/mktemp.0 ${DESTDIR}${MDIR}/mkstemp.0 ln -f ${DESTDIR}${MDIR}/syslog.0 ${DESTDIR}${MDIR}/openlog.0 ln -f ${DESTDIR}${MDIR}/malloc.0 ${DESTDIR}${MDIR}/realloc.0 ln -f ${DESTDIR}${MDIR}/insque.0 ${DESTDIR}${MDIR}/remque.0 ln -f ${DESTDIR}${MDIR}/fseek.0 ${DESTDIR}${MDIR}/rewind.0 ln -f ${DESTDIR}${MDIR}/string.0 ${DESTDIR}${MDIR}/rindex.0 ln -f ${DESTDIR}${MDIR}/floor.0 ${DESTDIR}${MDIR}/rint.0 ln -f ${DESTDIR}${MDIR}/syslog.0 ${DESTDIR}${MDIR}/setlogmask.0 ln -f ${DESTDIR}${MDIR}/random.0 ${DESTDIR}${MDIR}/setstate.0 ln -f ${DESTDIR}${MDIR}/random.0 ${DESTDIR}${MDIR}/srandom.0 ln -f ${DESTDIR}${MDIR}/scanf.0 ${DESTDIR}${MDIR}/sscanf.0 ln -f ${DESTDIR}${MDIR}/string.0 ${DESTDIR}${MDIR}/strcat.0 ln -f ${DESTDIR}${MDIR}/string.0 ${DESTDIR}${MDIR}/strcmp.0 ln -f ${DESTDIR}${MDIR}/string.0 ${DESTDIR}${MDIR}/strcpy.0 ln -f ${DESTDIR}${MDIR}/string.0 ${DESTDIR}${MDIR}/strlen.0 ln -f ${DESTDIR}${MDIR}/string.0 ${DESTDIR}${MDIR}/strncat.0 ln -f ${DESTDIR}${MDIR}/string.0 ${DESTDIR}${MDIR}/strncmp.0 ln -f ${DESTDIR}${MDIR}/string.0 ${DESTDIR}${MDIR}/strncpy.0 ln -f ${DESTDIR}${MDIR}/string.0 ${DESTDIR}${MDIR}/strcasecmp.0 ln -f ${DESTDIR}${MDIR}/string.0 ${DESTDIR}${MDIR}/strncasecmp.0 ln -f ${DESTDIR}${MDIR}/strlcpy.0 ${DESTDIR}${MDIR}/strlcat.0 ln -f ${DESTDIR}${MDIR}/printf.0 ${DESTDIR}${MDIR}/sprintf.0 ln -f ${DESTDIR}${MDIR}/printf.0 ${DESTDIR}${MDIR}/vfprintf.0 ln -f ${DESTDIR}${MDIR}/printf.0 ${DESTDIR}${MDIR}/vprintf.0 ln -f ${DESTDIR}${MDIR}/printf.0 ${DESTDIR}${MDIR}/vsprintf.0 ln -f ${DESTDIR}${MDIR}/scandir.0 ${DESTDIR}${MDIR}/alphasort.0 ln -f ${DESTDIR}${MDIR}/bstring.0 ${DESTDIR}${MDIR}/bcmp.0 ln -f ${DESTDIR}${MDIR}/bstring.0 ${DESTDIR}${MDIR}/bcopy.0 ln -f ${DESTDIR}${MDIR}/bstring.0 ${DESTDIR}${MDIR}/bzero.0 ln -f ${DESTDIR}${MDIR}/ferror.0 ${DESTDIR}${MDIR}/clearerr.0 ln -f ${DESTDIR}${MDIR}/ferror.0 ${DESTDIR}${MDIR}/feof.0 ln -f ${DESTDIR}${MDIR}/fclose.0 ${DESTDIR}${MDIR}/fflush.0 ln -f ${DESTDIR}${MDIR}/bstring.0 ${DESTDIR}${MDIR}/ffs.0 ln -f ${DESTDIR}${MDIR}/ferror.0 ${DESTDIR}${MDIR}/fileno.0 ln -f ${DESTDIR}${MDIR}/printf.0 ${DESTDIR}${MDIR}/fprintf.0 ln -f ${DESTDIR}${MDIR}/lgamma.0 ${DESTDIR}${MDIR}/gamma.0 ln -f ${DESTDIR}${MDIR}/getdisk.0 ${DESTDIR}${MDIR}/getdiskbyname.0 ln -f ${DESTDIR}${MDIR}/ttyname.0 ${DESTDIR}${MDIR}/isatty.0 ln -f ${DESTDIR}${MDIR}/monitor.0 ${DESTDIR}${MDIR}/moncontrol.0 ln -f ${DESTDIR}${MDIR}/monitor.0 ${DESTDIR}${MDIR}/monstartup.0 ln -f ${DESTDIR}${MDIR}/setbuf.0 ${DESTDIR}${MDIR}/setbuffer.0 ln -f ${DESTDIR}${MDIR}/setbuf.0 ${DESTDIR}${MDIR}/setlinebuf.0 ln -f ${DESTDIR}${MDIR}/setbuf.0 ${DESTDIR}${MDIR}/setvbuf.0 ln -f ${DESTDIR}${MDIR}/psignal.0 ${DESTDIR}${MDIR}/sys_siglist.0 ln -f ${DESTDIR}${MDIR}/ttyname.0 ${DESTDIR}${MDIR}/ttyslot.0 ln -f ${DESTDIR}${MDIR}/getfsent.0 ${DESTDIR}${MDIR}/endfsent.0 ln -f ${DESTDIR}${MDIR}/getgrent.0 ${DESTDIR}${MDIR}/endgrent.0 ln -f ${DESTDIR}${MDIR}/getpwent.0 ${DESTDIR}${MDIR}/endpwent.0 ln -f ${DESTDIR}${MDIR}/getfsent.0 ${DESTDIR}${MDIR}/getfsfile.0 ln -f ${DESTDIR}${MDIR}/getfsent.0 ${DESTDIR}${MDIR}/getfsspec.0 ln -f ${DESTDIR}${MDIR}/getfsent.0 ${DESTDIR}${MDIR}/getfstype.0 ln -f ${DESTDIR}${MDIR}/getgrent.0 ${DESTDIR}${MDIR}/getgrgid.0 ln -f ${DESTDIR}${MDIR}/getgrent.0 ${DESTDIR}${MDIR}/getgrnam.0 ln -f ${DESTDIR}${MDIR}/getpwent.0 ${DESTDIR}${MDIR}/getpwnam.0 ln -f ${DESTDIR}${MDIR}/getpwent.0 ${DESTDIR}${MDIR}/getpwuid.0 ln -f ${DESTDIR}${MDIR}/getfsent.0 ${DESTDIR}${MDIR}/setfsent.0 ln -f ${DESTDIR}${MDIR}/getgrent.0 ${DESTDIR}${MDIR}/setgrent.0 ln -f ${DESTDIR}${MDIR}/getpwent.0 ${DESTDIR}${MDIR}/setpwent.0 ln -f ${DESTDIR}${MDIR}/getpwent.0 ${DESTDIR}${MDIR}/setpwfile.0 ln -f ${DESTDIR}${MDIR}/termcap.0 ${DESTDIR}${MDIR}/tgetent.0 ln -f ${DESTDIR}${MDIR}/termcap.0 ${DESTDIR}${MDIR}/tgetflag.0 ln -f ${DESTDIR}${MDIR}/termcap.0 ${DESTDIR}${MDIR}/tgetnum.0 ln -f ${DESTDIR}${MDIR}/termcap.0 ${DESTDIR}${MDIR}/tgetstr.0 ln -f ${DESTDIR}${MDIR}/termcap.0 ${DESTDIR}${MDIR}/tgoto.0 ln -f ${DESTDIR}${MDIR}/termcap.0 ${DESTDIR}${MDIR}/tputs.0 ln -f ${DESTDIR}${MDIR}/directory.0 ${DESTDIR}${MDIR}/closedir.0 ln -f ${DESTDIR}${MDIR}/getttyent.0 ${DESTDIR}${MDIR}/endttyent.0 ln -f ${DESTDIR}${MDIR}/getttyent.0 ${DESTDIR}${MDIR}/getttynam.0 ln -f ${DESTDIR}${MDIR}/directory.0 ${DESTDIR}${MDIR}/opendir.0 ln -f ${DESTDIR}${MDIR}/directory.0 ${DESTDIR}${MDIR}/readdir.0 ln -f ${DESTDIR}${MDIR}/directory.0 ${DESTDIR}${MDIR}/rewinddir.0 ln -f ${DESTDIR}${MDIR}/directory.0 ${DESTDIR}${MDIR}/seekdir.0 ln -f ${DESTDIR}${MDIR}/getttyent.0 ${DESTDIR}${MDIR}/setttyent.0 ln -f ${DESTDIR}${MDIR}/directory.0 ${DESTDIR}${MDIR}/telldir.0 ln -f ${DESTDIR}${MDIR}/getnetent.0 ${DESTDIR}${MDIR}/endnetent.0 ln -f ${DESTDIR}${MDIR}/getnetent.0 ${DESTDIR}${MDIR}/getnetbyaddr.0 ln -f ${DESTDIR}${MDIR}/getnetent.0 ${DESTDIR}${MDIR}/getnetbyname.0 ln -f ${DESTDIR}${MDIR}/byteorder.0 ${DESTDIR}${MDIR}/htonl.0 ln -f ${DESTDIR}${MDIR}/byteorder.0 ${DESTDIR}${MDIR}/htons.0 ln -f ${DESTDIR}${MDIR}/byteorder.0 ${DESTDIR}${MDIR}/ntohl.0 ln -f ${DESTDIR}${MDIR}/byteorder.0 ${DESTDIR}${MDIR}/ntohs.0 ln -f ${DESTDIR}${MDIR}/getnetent.0 ${DESTDIR}${MDIR}/setnetent.0 ln -f ${DESTDIR}${MDIR}/getservent.0 ${DESTDIR}${MDIR}/endservent.0 ln -f ${DESTDIR}${MDIR}/getservent.0 ${DESTDIR}${MDIR}/getservbyname.0 ln -f ${DESTDIR}${MDIR}/getservent.0 ${DESTDIR}${MDIR}/getservbyport.0 ln -f ${DESTDIR}${MDIR}/getservent.0 ${DESTDIR}${MDIR}/setservent.0 ln -f ${DESTDIR}${MDIR}/getprotoent.0 ${DESTDIR}${MDIR}/endprotoent.0 ln -f ${DESTDIR}${MDIR}/getusershell.0 ${DESTDIR}${MDIR}/endusershell.0 ln -f ${DESTDIR}${MDIR}/getprotoent.0 ${DESTDIR}${MDIR}/getprotobyname.0 ln -f ${DESTDIR}${MDIR}/getprotoent.0 ${DESTDIR}${MDIR}/getprotobynumber.0 ln -f ${DESTDIR}${MDIR}/getprotoent.0 ${DESTDIR}${MDIR}/setprotoent.0 ln -f ${DESTDIR}${MDIR}/getusershell.0 ${DESTDIR}${MDIR}/setusershell.0 ln -f ${DESTDIR}${MDIR}/gethostbyname.0 ${DESTDIR}${MDIR}/endhostent.0 ln -f ${DESTDIR}${MDIR}/gethostbyname.0 ${DESTDIR}${MDIR}/gethostbyaddr.0 ln -f ${DESTDIR}${MDIR}/gethostbyname.0 ${DESTDIR}${MDIR}/gethostent.0 ln -f ${DESTDIR}${MDIR}/gethostbyname.0 ${DESTDIR}${MDIR}/sethostent.0 ln -f ${DESTDIR}${MDIR}/gethostbyname.0 ${DESTDIR}${MDIR}/sethostfile.0 ln -f ${DESTDIR}${MDIR}/setmode.0 ${DESTDIR}${MDIR}/getmode.0 ln -f ${DESTDIR}${MDIR}/compat-sys5.0 ${DESTDIR}${MDIR}/memccpy.0 ln -f ${DESTDIR}${MDIR}/compat-sys5.0 ${DESTDIR}${MDIR}/memchr.0 ln -f ${DESTDIR}${MDIR}/compat-sys5.0 ${DESTDIR}${MDIR}/memcmp.0 ln -f ${DESTDIR}${MDIR}/compat-sys5.0 ${DESTDIR}${MDIR}/memcpy.0 ln -f ${DESTDIR}${MDIR}/compat-sys5.0 ${DESTDIR}${MDIR}/memset.0 ln -f ${DESTDIR}${MDIR}/compat-sys5.0 ${DESTDIR}${MDIR}/strchr.0 ln -f ${DESTDIR}${MDIR}/compat-sys5.0 ${DESTDIR}${MDIR}/strrchr.0 ln -f ${DESTDIR}${MDIR}/compat-sys5.0 ${DESTDIR}${MDIR}/tmpnam.0 ln -f ${DESTDIR}${MDIR}/compat-sys5.0 ${DESTDIR}${MDIR}/tmpfile.0 ln -f ${DESTDIR}${MDIR}/compat-sys5.0 ${DESTDIR}${MDIR}/tempnam.0 ln -f ${DESTDIR}${MDIR}/sleep.0 ${DESTDIR}${MDIR}/usleep.0 ln -f ${DESTDIR}${MDIR}/getenv.0 ${DESTDIR}${MDIR}/setenv.0 ln -f ${DESTDIR}${MDIR}/getenv.0 ${DESTDIR}${MDIR}/unsetenv.0 ln -f ${DESTDIR}${MDIR}/setruid.0 ${DESTDIR}${MDIR}/setrgid.0 FRC: ================================================ FILE: share/man/man3/abort.3 ================================================ .\" @(#)abort.3 6.3 (Berkeley) 5/27/86 .\" .TH ABORT 3 "May 27, 1986" .AT 3 .SH NAME abort \- generate a fault .SH DESCRIPTION .I Abort executes an instruction which is illegal in user mode. This causes a signal that normally terminates the process with a core dump, which may be used for debugging. .SH SEE ALSO adb(1), sigvec(2), exit(2) .SH DIAGNOSTICS Usually ``Illegal instruction \- core dumped'' from the shell. .SH BUGS The abort() function does not flush standard I/O buffers. Use \fIfflush\fP\|(3S). ================================================ FILE: share/man/man3/abs.3 ================================================ .\" @(#)abs.3 6.1 (Berkeley) 5/15/85 .\" .TH ABS 3 "May 15, 1985" .AT 3 .SH NAME abs \- integer absolute value .SH SYNOPSIS .nf .B abs(i) .B int i; .fi .SH DESCRIPTION .I Abs returns the absolute value of its integer operand. .SH SEE ALSO floor(3M) for .I fabs .SH BUGS Applying the \fIabs\fP function to the most negative integer generates a result which is the most negative integer. That is, .IP "abs(0x80000000)" .LP returns 0x80000000 as a result. ================================================ FILE: share/man/man3/alarm.3 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)alarm.3c 6.3 (Berkeley) 5/27/86 .\" .TH ALARM 3C "May 27, 1986" .UC 4 .SH NAME alarm \- schedule signal after specified time .SH SYNOPSIS .nf .B alarm(seconds) .B unsigned seconds; .fi .SH DESCRIPTION .ft B This interface is made obsolete by setitimer(2). .ft R .PP .I Alarm causes signal SIGALRM, see .IR sigvec (2), to be sent to the invoking process in a number of seconds given by the argument. Unless caught or ignored, the signal terminates the process. .PP Alarm requests are not stacked; successive calls reset the alarm clock. If the argument is 0, any alarm request is canceled. Because of scheduling delays, resumption of execution of when the signal is caught may be delayed an arbitrary amount. The longest specifiable delay time is 2147483647 seconds. .PP The return value is the amount of time previously remaining in the alarm clock. .SH "SEE ALSO" sigpause(2), sigvec(2), signal(3C), sleep(3), ualarm(3), usleep(3) ================================================ FILE: share/man/man3/asinh.3 ================================================ .\" Copyright (c) 1985 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)asinh.3m 6.2 (Berkeley) 5/12/86 .\" .TH ASINH 3M "May 12, 1986" .UC 6 .ds up \fIulp\fR .SH NAME asinh, acosh, atanh \- inverse hyperbolic functions .SH SYNOPSIS .nf .B #include .PP .B double asinh(x) .B double x; .PP .B double acosh(x) .B double x; .PP .B double atanh(x) .B double x; .fi .SH DESCRIPTION These functions compute the designated inverse hyperbolic functions for real arguments. .SH ERROR (due to Roundoff etc.) These functions inherit much of their error from log1p described in exp(3M). On a VAX, acosh is accurate to about 3 \*(ups, asinh and atanh to about 2 \*(ups. An \*(up is one \fIU\fRnit in the \fIL\fRast \fIP\fRlace carried. .SH DIAGNOSTICS Acosh returns the reserved operand on a VAX if the argument is less than 1. .PP Atanh returns the reserved operand on a VAX if the argument has absolute value bigger than or equal to 1. .SH SEE ALSO math(3M), exp(3M), infnan(3M) .SH AUTHOR W. Kahan, Kwok\-Choi Ng ================================================ FILE: share/man/man3/assert.3 ================================================ .\" @(#)assert.3 6.2 (Berkeley) 5/12/86 .\" .TH ASSERT 3 "May 12, 1986" .AT 3 .SH NAME assert \- program verification .SH SYNOPSIS .B #include .PP .B assert(expression) .SH DESCRIPTION .PP .I Assert is a macro that indicates .I expression is expected to be true at this point in the program. It causes an .IR exit (2) with a diagnostic comment on the standard output when .I expression is false (0). Compiling with the .IR cc (1) option .SM .B \-DNDEBUG effectively deletes .I assert from the program. .SH DIAGNOSTICS `Assertion failed: file .I f line .I n.' .I F is the source file and .I n the source line number of the .I assert statement. ================================================ FILE: share/man/man3/atof.3 ================================================ .\" @(#)atof.3 6.1 (Berkeley) 5/15/85 .\" .TH ATOF 3 "May 15, 1985" .AT 3 .SH NAME atof, atoi, atol \- convert ASCII to numbers .SH SYNOPSIS .nf .B double atof(nptr) .B char *nptr; .PP .B atoi(nptr) .B char *nptr; .PP .B long atol(nptr) .B char *nptr; .fi .SH DESCRIPTION These functions convert a string pointed to by .I nptr to floating, integer, and long integer representation respectively. The first unrecognized character ends the string. .PP .I Atof recognizes an optional string of spaces, then an optional sign, then a string of digits optionally containing a decimal point, then an optional `e' or `E' followed by an optionally signed integer. .PP .I Atoi and .I atol recognize an optional string of spaces, then an optional sign, then a string of digits. .SH SEE ALSO scanf(3S) .SH BUGS There are no provisions for overflow. ================================================ FILE: share/man/man3/basename.3 ================================================ .\" $OpenBSD: basename.3,v 1.25 2020/10/20 19:30:14 naddy Exp $ .\" .\" Copyright (c) 1997 Todd C. Miller .\" .\" Permission to use, copy, modify, and distribute this software for any .\" purpose with or without fee is hereby granted, provided that the above .\" copyright notice and this permission notice appear in all copies. .\" .\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES .\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF .\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR .\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES .\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" .Dd $Mdocdate: October 20 2020 $ .Dt BASENAME 3 .Os .Sh NAME .Nm basename .Nd extract the base portion of a pathname .Sh SYNOPSIS .In libgen.h .Ft char * .Fn basename "char *path" .Sh DESCRIPTION The .Fn basename function returns the last component from the pathname pointed to by .Ar path , deleting any trailing .Sq \&/ characters. If .Ar path consists entirely of .Sq \&/ characters, a pointer to the string .Qq \&/ is returned. If .Ar path is a null pointer or the empty string, a pointer to the string .Qq \&. is returned. .Sh RETURN VALUES On successful completion, .Fn basename returns a pointer to the last component of .Ar path . .Pp If .Fn basename fails, a null pointer is returned and the global variable .Va errno is set to indicate the error. .Sh ERRORS The following error codes may be set in .Va errno : .Bl -tag -width Er .It Bq Er ENAMETOOLONG The path component to be returned was larger than .Dv PATH_MAX . .El .Sh SEE ALSO .Xr basename 1 , .Xr dirname 1 , .Xr dirname 3 .Sh STANDARDS The .Fn basename function conforms to the X/Open System Interfaces option of the .St -p1003.1-2008 specification. .Sh HISTORY The .Fn basename function first appeared in .Ox 2.2 . .Sh AUTHORS .An Todd C. Miller .Sh CAVEATS .Fn basename returns a pointer to internal static storage space that will be overwritten by subsequent calls. .Pp Other vendor implementations of .Fn basename may modify the contents of the string passed to .Fn basename ; this should be taken into account when writing code which calls this function if portability is desired. ================================================ FILE: share/man/man3/bstring.3 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)bstring.3 6.1 (Berkeley) 5/15/85 .\" .TH BSTRING 3 "November 24, 2025" .UC 5 .SH NAME bcopy, bcmp, bzero, ffs \- bit and byte string operations .SH SYNOPSIS .nf .B bcopy(src, dst, length) .B char *src, *dst; .B int length; .PP .B bcmp(b1, b2, length) .B char *b1, *b2; .B int length; .PP .B bzero(b, length) .B void *b; .B size_t length; .PP .B ffs(i) .B long i; .fi .SH DESCRIPTION The functions .IR bcopy , .IR bcmp , and .I bzero operate on variable length strings of bytes. They do not check for null bytes as the routines in .IR string (3) do. .PP .I Bcopy copies .I length bytes from string .I src to the string .IR dst . .PP .I Bcmp compares byte string .I b1 against byte string .IR b2 , returning zero if they are identical, non-zero otherwise. Both strings are assumed to be .I length bytes long. .PP .I Bzero places .I length 0 bytes in the string .IR b . .PP .I Ffs find the first bit set in the argument passed it and returns the index of that bit. Bits are numbered starting at 1. A return value of 0 indicates the value passed is zero. .SH BUGS The .I bcopy routine take parameters backwards from .IR strcpy . ================================================ FILE: share/man/man3/byteorder.3 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)byteorder.3n 6.2 (Berkeley) 5/15/86 .\" .TH BYTEORDER 3N "May 15, 1986" .UC 5 .SH NAME htonl, htons, ntohl, ntohs \- convert values between host and network byte order .SH SYNOPSIS .nf .B #include .B #include .PP .B netlong = htonl(hostlong); .B u_long netlong, hostlong; .PP .B netshort = htons(hostshort); .B u_short netshort, hostshort; .PP .B hostlong = ntohl(netlong); .B u_long hostlong, netlong; .PP .B hostshort = ntohs(netshort); .B u_short hostshort, netshort; .fi .SH DESCRIPTION These routines convert 16 and 32 bit quantities between network byte order and host byte order. On machines such as the SUN these routines are defined as null macros in the include file .RI < netinet/in.h >. .PP These routines are most often used in conjunction with Internet addresses and ports as returned by .IR gethostbyname (3N) and .IR getservent (3N). .SH "SEE ALSO" gethostbyname(3N), getservent(3N) .SH BUGS The VAX handles bytes backwards from most everyone else in the world. This is not expected to be fixed in the near future. ================================================ FILE: share/man/man3/compat-sys5.3 ================================================ .\" Copyright (c) 1988 Regents of the University of California. .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms are permitted .\" provided that the above copyright notice and this paragraph are .\" duplicated in all such forms and that any documentation, .\" advertising materials, and other materials related to such .\" distribution and use acknowledge that the software was developed .\" by the University of California, Berkeley. The name of the .\" University may not be used to endorse or promote products derived .\" from this software without specific prior written permission. .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR .\" IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED .\" WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. .\" .\" @(#)compat-sys5.3 5.6.1 (2.11BSD) 1996/1/12 .\" .TH COMPATS5 3 "January 12, 1996" .UC 7 .SH NAME memccpy, memchr, memcmp, memcpy, memset, strchr, strrchr, tempnam, tmpfile, tmpnam \- System V compatibility routines .SH SYNOPSIS .nf .B char *memccpy(from, to, ch, count) .B char *from, *to; .B int ch, count; .PP .B char *memchr(str, ch, count) .B char *str; .B int ch, count; .PP .B int memcmp(str1, str2, count) .B char *str1, *str2; .B int count; .PP .B char *memcpy(from, to, count) .B char *from, to; .B int count; .PP .B char *memset(str, ch, count) .B char *str; .B int ch, count; .PP .B char *strchr(str, ch); .B char *str; .B int ch; .PP .B char *tempnam(tmpdir, prefix) .B char *tmpdir, *prefix; .PP .B char *tmpfile() .PP .B char *tmpnam(str) .B char *str; .PP .SH COMMENT The \fI#defines\fP \fIP_tmpdir\fP and \fIL_tmpnam\fP, used by the routines \fItempnam\fP, \fItmpfile\fP, and \fItmpnam\fP are not available in \fI\fP. If the code requires them, just use: .PP #include .br #define P_tmpdir "/usr/tmp" #define L_tmpnam MAXPATHLEN .PP Also, note that the caveat in the System V manual page that these functions can start recycling previously used names is untrue in this system. .SH DESCRIPTION The above routines are available and behave as in System V. .PP .BR strchr () and .BR strrchr () are simply an alternate entry points into .BR index () and .BR rindex () respectively. ================================================ FILE: share/man/man3/crypt.3 ================================================ .\" @(#)crypt.3 6.1.1.1 (Berkeley) 8/12/86 .\" .TH CRYPT 3 "August 12, 1986" .AT 3 .SH NAME crypt, setkey, encrypt \- DES encryption .SH SYNOPSIS .nf .B char *crypt(key, salt) .B char *key, *salt; .PP .B setkey(key) .B char *key; .PP .B encrypt(block, edflag) .B char *block; .fi .SH DESCRIPTION .I Crypt is the password encryption routine. It is based on the NBS Data Encryption Standard, with variations intended (among other things) to frustrate use of hardware implementations of the DES for key search. .PP The first argument to .I crypt is normally a user's typed password. The second is a 2-character string chosen from the set [a-zA-Z0-9./]. The .I salt string is used to perturb the DES algorithm in one of 4096 different ways, after which the password is used as the key to encrypt repeatedly a constant string. The returned value points to the encrypted password, in the same alphabet as the salt. The first two characters are the salt itself. .PP The other entries provide (rather primitive) access to the actual DES algorithm. The argument of .I setkey is a character array of length 64 containing only the characters with numerical value 0 and 1. If this string is divided into groups of 8, the low-order bit in each group is ignored, leading to a 56-bit key which is set into the machine. .PP The argument to the .I encrypt entry is likewise a character array of length 64 containing 0's and 1's. The argument array is modified in place to a similar array representing the bits of the argument after having been subjected to the DES algorithm using the key set by .I setkey. The .I edflag flag is ignored; the argument can only be encrypted. .SH "SEE ALSO" passwd(1), passwd(5), login(1), getpass(3) .SH BUGS The return value points to static data whose content is overwritten by each call. ================================================ FILE: share/man/man3/ctime.3 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)ctime.3 6.7.1 (2.11BSD) 1996/11/27 .\" .TH CTIME 3 "November 27, 1996" .UC 4 .SH NAME ctime, localtime, gmtime, asctime, timezone, tzset \- convert date and time to ASCII .SH SYNOPSIS .nf .B void tzset() .PP .B char *ctime(clock) .B time_t *clock; .PP .B #include .PP .B char *asctime(tm) .B struct tm *tm; .PP .B struct tm *localtime(clock) .B time_t *clock; .PP .B struct tm *gmtime(clock) .B time_t *clock; .PP .B char *timezone(zone, dst) .fi .fi .SH DESCRIPTION \fITzset\fP uses the value of the environment variable \fBTZ\fP to set up the time conversion information used by \fIlocaltime\fP. .PP If \fBTZ\fP does not appear in the environment, the \fBTZDEFAULT\fP file (as defined in \fItzfile.h\fP) is used by \fIlocaltime\fP. If this file fails for any reason, the GMT offset as provided by the kernel is used. In this case, DST is ignored, resulting in the time being incorrect by some amount if DST is currently in effect. If this fails for any reason, GMT is used. .PP If \fBTZ\fP appears in the environment but its value is a null string, Greenwich Mean Time is used; if \fBTZ\fP appears and begins with a slash, it is used as the absolute pathname of the \fItzfile\fP(5)-format file from which to read the time conversion information; if \fBTZ\fP appears and begins with a character other than a slash, it's used as a pathname relative to the system time conversion information directory, defined as \fBTZDIR\fP in the include file \fItzfile.h\fP. If this file fails for any reason, GMT is used. .PP Programs that always wish to use local wall clock time should explicitly remove the environmental variable \fBTZ\fP with \fIunsetenv\fP(3). .PP \fICtime\fP converts a long integer, pointed to by \fIclock\fP, such as returned by \fItime\fP(2) into ASCII and returns a pointer to a 26-character string in the following form. All the fields have constant width. .PP Sun Sep 16 01:03:52 1973\\n .PP .I Localtime and .I gmtime return pointers to structures containing the broken-down time. .I Localtime corrects for the time zone and possible daylight savings time; .I gmtime converts directly to GMT, which is the time UNIX uses. .I Asctime converts a broken-down time to ASCII and returns a pointer to a 26-character string. .PP The structure declaration from the include file is: .PP .RS .nf .nr .0 .8i+\w'int tm_isdst'u .ta .5i \n(.0u \n(.0u+\w'/* 0-000'u+1n struct tm { int tm_sec; /* 0-59 seconds */ int tm_min; /* 0-59 minutes */ int tm_hour; /* 0-23 hour */ int tm_mday; /* 1-31 day of month */ int tm_mon; /* 0-11 month */ int tm_year; /* 0- year \- 1900 */ int tm_wday; /* 0-6 day of week (Sunday = 0) */ int tm_yday; /* 0-365 day of year */ int tm_isdst; /* flag: daylight savings time in effect */ char **tm_zone; /* abbreviation of timezone name */ long tm_gmtoff; /* offset from GMT in seconds */ }; .fi .RE .PP \fITm_isdst\fP is non-zero if a time zone adjustment such as Daylight Savings time is in effect. .PP \fITm_gmtoff\fP is the offset (in seconds) of the time represented from GMT, with positive values indicating East of Greenwich. .PP \fITimezone\fP remains for compatibility reasons only; it's impossible to reliably map timezone's arguments (\fIzone\fP, a "minutes west of GMT" value and \fIdst\fP, a "daylight saving time in effect" flag) to a time zone abbreviation. .PP If the environmental string \fITZNAME\fP exists, \fItimezone\fP returns its value, unless it consists of two comma separated strings, in which case the second string is returned if \fIdst\fP is non-zero, else the first string. If \fITZNAME\fP doesn't exist, \fIzone\fP is checked for equality with a built-in table of values, in which case \fItimezone\fP returns the time zone or daylight time zone abbreviation associated with that value. If the requested \fIzone\fP does not appear in the table, the difference from GMT is returned; e.g. in Afghanistan, \fItimezone(-(60*4+30), 0)\fP is appropriate because it is 4:30 ahead of GMT, and the string \fBGMT+4:30\fP is returned. Programs that in the past used the \fItimezone\fP function should return the zone name as set by \fIlocaltime\fP to assure correctness. .SH FILES .ta \w'/usr/share/zoneinfo'u /usr/share/zoneinfo time zone information directory .br /etc/localtime local time zone file .SH SEE ALSO gettimeofday(2), getenv(3), time(3), tzfile(5), environ(7) .SH NOTE The return values point to static data whose content is overwritten by each call. The \fBtm_zone\fP field of a returned \fBstruct tm\fP points to a static array of characters, which will also be overwritten at the next call (and by calls to \fItzset\fP). ================================================ FILE: share/man/man3/ctype.3 ================================================ .\" @(#)ctype.3 6.4 (Berkeley) 5/12/86 .\" .TH CTYPE 3 "May 12, 1986" .AT 3 .SH NAME isalpha, isupper, islower, isdigit, isxdigit, isalnum, isspace, ispunct, isprint, isgraph, iscntrl, isascii, toupper, tolower, toascii \- character classification macros .SH SYNOPSIS .B #include .PP .B isalpha(c) .PP .B . . . .SH DESCRIPTION These macros classify ASCII-coded integer values by table lookup. Each is a predicate returning nonzero for true, zero for false. .I Isascii and .I toascii are defined on all integer values; the rest are defined only where .I isascii is true and on the single non-ASCII value EOF (see .IR stdio (3S)). .TP 15n .I isalpha .I c is a letter .TP .I isupper .I c is an upper case letter .TP .I islower .I c is a lower case letter .TP .I isdigit .I c is a digit .TP .I isxdigit .I c is a hex digit .TP .I isalnum .I c is an alphanumeric character .TP .I isspace .I c is a space, tab, carriage return, newline, vertical tab, or formfeed .TP .I ispunct .I c is a punctuation character (neither control nor alphanumeric) .TP .I isprint .I c is a printing character, code 040(8) (space) through 0176 (tilde) .TP .I isgraph .I c is a printing character, similar to .I isprint except false for space. .TP .I iscntrl .I c is a delete character (0177) or ordinary control character (less than 040). .TP .I isascii .I c is an ASCII character, code less than 0200 .TP .I tolower .I c is converted to lower case. Return value is undefined if not .I isupper(c). .TP .I toupper .I c is converted to upper case. Return value is undefined if not .I islower(c). .TP .I toascii .I c is converted to be a valid ascii character. .SH "SEE ALSO" ascii(7) ================================================ FILE: share/man/man3/curses.3 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)curses.3x 6.3 (Berkeley) 4/23/86 .\" .TH CURSES 3X "April 23, 1986" .UC 4 .SH NAME curses \- screen functions with ``optimal'' cursor motion .SH SYNOPSIS .B cc [ flags ] files .B \-lcurses \-ltermcap [ libraries ] .SH DESCRIPTION These routines give the user a method of updating screens with reasonable optimization. They keep an image of the current screen, and the user sets up an image of a new one. Then the .I refresh() tells the routines to make the current screen look like the new one. In order to initialize the routines, the routine .I initscr() must be called before any of the other routines that deal with windows and screens are used. The routine .I endwin() should be called before exiting. .SH SEE ALSO .I "Screen Updating and Cursor Movement Optimization: A Library Package," Ken Arnold, .br ioctl(2), getenv(3), tty(4), termcap(5) .SH AUTHOR Ken Arnold .SH FUNCTIONS .nf .ds w \fIwin\fP .ds s \fIstdscr\fP .ta 3i addch(ch) add a character to \*s addstr(str) add a string to \*s box(win,vert,hor) draw a box around a window cbreak() set cbreak mode clear() clear \*s clearok(scr,boolf) set clear flag for \fIscr\fP clrtobot() clear to bottom on \*s clrtoeol() clear to end of line on \*s delch() delete a character deleteln() delete a line delwin(win) delete \*w echo() set echo mode endwin() end window modes erase() erase \*s flusok(win,boolf) set flush-on-refresh flag for \fIwin\fP getch() get a char through \*s getcap(name) get terminal capability \fIname\fP getstr(str) get a string through \*s gettmode() get tty modes getyx(win,y,x) get (y,x) co-ordinates inch() get char at current (y,x) co-ordinates initscr() initialize screens insch(c) insert a char insertln() insert a line leaveok(win,boolf) set leave flag for \*w longname(termbuf,name) get long name from \fItermbuf\fP move(y,x) move to (y,x) on \*s mvcur(lasty,lastx,newy,newx) actually move cursor newwin(lines,cols,begin_y,begin_x)\ create a new window nl() set newline mapping nocbreak() unset cbreak mode noecho() unset echo mode nonl() unset newline mapping noraw() unset raw mode overlay(win1,win2) overlay win1 on win2 overwrite(win1,win2) overwrite win1 on top of win2 printw(fmt,arg1,arg2,...) printf on \*s raw() set raw mode refresh() make current screen look like \*s resetty() reset tty flags to stored value savetty() stored current tty flags scanw(fmt,arg1,arg2,...) scanf through \*s scroll(win) scroll \*w one line scrollok(win,boolf) set scroll flag setterm(name) set term variables for name standend() end standout mode standout() start standout mode subwin(win,lines,cols,begin_y,begin_x)\ create a subwindow touchline(win,y,sx,ex) mark line \fIy\fP \fIsx\fP through \fIsy\fP as changed touchoverlap(win1,win2) mark overlap of \fIwin1\fP on \fIwin2\fP as changed touchwin(win) \*(lqchange\*(rq all of \*w unctrl(ch) printable version of \fIch\fP waddch(win,ch) add char to \*w waddstr(win,str) add string to \*w wclear(win) clear \*w wclrtobot(win) clear to bottom of \*w wclrtoeol(win) clear to end of line on \*w wdelch(win,c) delete char from \*w wdeleteln(win) delete line from \*w werase(win) erase \*w wgetch(win) get a char through \*w wgetstr(win,str) get a string through \*w winch(win) get char at current (y,x) in \*w winsch(win,c) insert char into \*w winsertln(win) insert line into \*w wmove(win,y,x) set current (y,x) co-ordinates on \*w wprintw(win,fmt,arg1,arg2,...)\ printf on \*w wrefresh(win) make screen look like \*w wscanw(win,fmt,arg1,arg2,...)\ scanf through \*w wstandend(win) end standout mode on \*w wstandout(win) start standout mode on \*w .SH BUGS ================================================ FILE: share/man/man3/daemon.3 ================================================ .\" Copyright (c) 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. All advertising materials mentioning features or use of this software .\" must display the following acknowledgement: .\" This product includes software developed by the University of .\" California, Berkeley and its contributors. .\" 4. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)daemon.3 8.1.1 (2.11BSD GTE) 2/5/95 .TH DAEMON 3 "February 3, 1995" .UC 4 .SH NAME daemon \- run in the background .SH SYNOPSIS .nf .ft B int daemon(nochdir, noclose) int nochdir, noclose; .ft R .fi .SH DESCRIPTION .PP The .B daemon function is for programs wishing to detach themselves from the controlling terminal and run in the background as system daemons. .PP Unless the argument .I nochdir is non-zero, .B daemon changes the current working directory to the root (``/''). .PP Unless the argument .I noclose is non-zero, .B daemon will redirect standard input, standard output and standard error to ``/dev/null''. .SH ERRORS The function .B daemon may fail and set .I errno for any of the errors specified for the library functions .IR fork (2) . .SH SEE ALSO fork(2), ioctl(2). .SH HISTORY The .B daemon function first appeared in 4.4BSD. ================================================ FILE: share/man/man3/dbm.3 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)dbm.3x 6.3 (Berkeley) 5/12/86 .\" .TH DBM 3X "May 12, 1986" .UC 4 .SH NAME dbminit, fetch, store, delete, firstkey, nextkey \- data base subroutines .SH SYNOPSIS .nf .PP .B "#include " .PP .B typedef struct { .B " char *dptr;" .B " int dsize;" .B } datum; .PP .B dbminit(file) .B char *file; .PP .B datum fetch(key) .B datum key; .PP .B store(key, content) .B datum key, content; .PP .B delete(key) .B datum key; .PP .B datum firstkey() .PP .B datum nextkey(key) .B datum key; .SH DESCRIPTION .ft B Note: the dbm library has been superceded by ndbm(3), and is now implemented using ndbm. .ft R These functions maintain key/content pairs in a data base. The functions will handle very large (a billion blocks) databases and will access a keyed item in one or two file system accesses. The functions are obtained with the loader option .BR \-ldbm . .PP .IR Key s and .IR content s are described by the .I datum typedef. A .I datum specifies a string of .I dsize bytes pointed to by .I dptr. Arbitrary binary data, as well as normal ASCII strings, are allowed. The data base is stored in two files. One file is a directory containing a bit map and has `.dir' as its suffix. The second file contains all data and has `.pag' as its suffix. .PP Before a database can be accessed, it must be opened by .I dbminit. At the time of this call, the files .IB file .dir and .IB file .pag must exist. (An empty database is created by creating zero-length `.dir' and `.pag' files.) .PP Once open, the data stored under a key is accessed by .I fetch and data is placed under a key by .IR store . A key (and its associated contents) is deleted by .IR delete . A linear pass through all keys in a database may be made, in an (apparently) random order, by use of .I firstkey and .IR nextkey . .I Firstkey will return the first key in the database. With any key .I nextkey will return the next key in the database. This code will traverse the data base: .IP .B for (key = firstkey(); key.dptr != NULL; key = nextkey(key)) .SH DIAGNOSTICS All functions that return an .I int indicate errors with negative values. A zero return indicates ok. Routines that return a .I datum indicate errors with a null (0) .I dptr. .SH SEE ALSO ndbm(3) .SH BUGS The `.pag' file will contain holes so that its apparent size is about four times its actual content. Older UNIX systems may create real file blocks for these holes when touched. These files cannot be copied by normal means (cp, cat, tp, tar, ar) without filling in the holes. .PP .I Dptr pointers returned by these subroutines point into static storage that is changed by subsequent calls. .PP The sum of the sizes of a key/content pair must not exceed the internal block size (currently 1024 bytes). Moreover all key/content pairs that hash together must fit on a single block. .I Store will return an error in the event that a disk block fills with inseparable data. .PP .I Delete does not physically reclaim file space, although it does make it available for reuse. .PP The order of keys presented by .I firstkey and .I nextkey depends on a hashing function, not on anything interesting. ================================================ FILE: share/man/man3/devname.3 ================================================ .\" Copyright (c) 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. All advertising materials mentioning features or use of this software .\" must display the following acknowledgement: .\" This product includes software developed by the University of .\" California, Berkeley and its contributors. .\" 4. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)devname.3 8.1.1 (2.11BSD GTE) 2/3/95 .\" .TH DEVNAME 3 "February 3, 1995" .UC 4 .SH NAME devname \- get device name .SH SYNOPSIS .nf .ft B #include char * devname(dev, type) dev_t dev; mode_t type; .ft R .fi .SH DESCRIPTION The .B devname function returns a pointer to the name of the block or character device in .IR /dev with a device number of .I dev , and a file type matching the one encoded in .I type which must be one of S_IFBLK or S_IFCHR. If no device matches the specified values, or no information is available, the string .I ?? is returned. .SH SEE ALSO stat(2), dev_mkdb(8) .SH HISTORY The .B devname function call appeared in 4.4BSD. ================================================ FILE: share/man/man3/directory.3 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)directory.3 6.2 (Berkeley) 9/24/85 .\" .TH DIRECTORY 3 "September 24, 1985" .UC 5 .SH NAME opendir, readdir, telldir, seekdir, rewinddir, closedir \- directory operations .SH SYNOPSIS .B #include .br .B #include .PP .SM .B DIR .B *opendir(filename) .br .B char *filename; .PP .B struct direct .B *readdir(dirp) .br .SM .B DIR .B *dirp; .PP .B long .B telldir(dirp) .br .SM .B DIR .B *dirp; .PP .B seekdir(dirp, loc) .br .SM .B DIR .B *dirp; .br .B long loc; .PP .B rewinddir(dirp) .br .SM .B DIR .B *dirp; .PP .B closedir(dirp) .br .SM .B DIR .B *dirp; .SH DESCRIPTION .I Opendir opens the directory named by .I filename and associates a .I directory stream with it. .I Opendir returns a pointer to be used to identify the .I directory stream in subsequent operations. The pointer .SM .B NULL is returned if .I filename cannot be accessed, or if it cannot .IR malloc (3) enough memory to hold the whole thing. .PP .I Readdir returns a pointer to the next directory entry. It returns .B NULL upon reaching the end of the directory or detecting an invalid .I seekdir operation. .PP .I Telldir returns the current location associated with the named .I directory stream. .PP .I Seekdir sets the position of the next .I readdir operation on the .I directory stream. The new position reverts to the one associated with the .I directory stream when the .I telldir operation was performed. Values returned by .I telldir are good only for the lifetime of the DIR pointer from which they are derived. If the directory is closed and then reopened, the .I telldir value may be invalidated due to undetected directory compaction. It is safe to use a previous .I telldir value immediately after a call to .I opendir and before any calls to .I readdir. .PP .I Rewinddir resets the position of the named .I directory stream to the beginning of the directory. .PP .I Closedir closes the named .I directory stream and frees the structure associated with the DIR pointer. .PP Sample code which searchs a directory for entry ``name'' is: .PP .br len = strlen(name); .br dirp = opendir("."); .br for (dp = readdir(dirp); dp != NULL; dp = readdir(dirp)) .br if (dp->d_namlen == len && !strcmp(dp->d_name, name)) { .br closedir(dirp); .br return FOUND; .br } .br closedir(dirp); .br return NOT_FOUND; .SH "SEE ALSO" open(2), close(2), read(2), lseek(2), dir(5) ================================================ FILE: share/man/man3/dirname.3 ================================================ .\" $OpenBSD: dirname.3,v 1.24 2020/10/20 19:30:14 naddy Exp $ .\" .\" Copyright (c) 1997 Todd C. Miller .\" .\" Permission to use, copy, modify, and distribute this software for any .\" purpose with or without fee is hereby granted, provided that the above .\" copyright notice and this permission notice appear in all copies. .\" .\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES .\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF .\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR .\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES .\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" .Dd $Mdocdate: October 20 2020 $ .Dt DIRNAME 3 .Os .Sh NAME .Nm dirname .Nd extract the directory portion of a pathname .Sh SYNOPSIS .In libgen.h .Ft char * .Fn dirname "char *path" .Sh DESCRIPTION The .Fn dirname function is the converse of .Xr basename 3 ; it returns a pointer to the parent directory of the pathname pointed to by .Ar path . Any trailing .Sq \&/ characters are not counted as part of the directory name. If .Ar path is a null pointer, the empty string, or contains no .Sq \&/ characters, .Fn dirname returns a pointer to the string .Qq \&. , signifying the current directory. .Sh RETURN VALUES On successful completion, .Fn dirname returns a pointer to the parent directory of .Ar path . .Pp If .Fn dirname fails, a null pointer is returned and the global variable .Va errno is set to indicate the error. .Sh ERRORS The following error codes may be set in .Va errno : .Bl -tag -width Er .It Bq Er ENAMETOOLONG The path component to be returned was larger than .Dv PATH_MAX . .El .Sh SEE ALSO .Xr basename 1 , .Xr dirname 1 , .Xr basename 3 .Sh STANDARDS The .Fn dirname function conforms to the X/Open System Interfaces option of the .St -p1003.1-2008 specification. .Sh HISTORY The .Fn dirname function first appeared in .Ox 2.2 . .Sh AUTHORS .An Todd C. Miller .Sh CAVEATS .Fn dirname returns a pointer to internal static storage space that will be overwritten by subsequent calls. .Pp Other vendor implementations of .Fn dirname may modify the contents of the string passed to .Fn dirname ; this should be taken into account when writing code which calls this function if portability is desired. ================================================ FILE: share/man/man3/ecvt.3 ================================================ .\" @(#)ecvt.3 6.1 (Berkeley) 5/15/85 .\" .TH ECVT 3 "May 15, 1985" .AT 3 .SH NAME ecvt, fcvt, gcvt \- output conversion .SH SYNOPSIS .nf .B char *ecvt(value, ndigit, decpt, sign) .B double value; .B int ndigit, *decpt, *sign; .PP .B char *fcvt(value, ndigit, decpt, sign) .B double value; .B int ndigit, *decpt, *sign; .PP .B char *gcvt(value, ndigit, buf) .B double value; .B char *buf; .fi .SH DESCRIPTION .I Ecvt converts the .I value to a null-terminated string of .I ndigit ASCII digits and returns a pointer thereto. The position of the decimal point relative to the beginning of the string is stored indirectly through .IR decpt "" (negative means to the left of the returned digits). If the sign of the result is negative, the word pointed to by .IR sign "" is non-zero, otherwise it is zero. The low-order digit is rounded. .PP .IR Fcvt " is identical to " "ecvt\fR, except that the correct digit" has been rounded for Fortran F-format output of the number of digits specified by .IR ndigit . .PP .I Gcvt converts the .I value to a null-terminated ASCII string in .I buf and returns a pointer to .I buf. It attempts to produce .I ndigit significant digits in Fortran F format if possible, otherwise E format, ready for printing. Trailing zeros may be suppressed. .SH "SEE ALSO" printf(3) .SH BUGS The return values point to static data whose content is overwritten by each call. ================================================ FILE: share/man/man3/end.3 ================================================ .\" @(#)end.3 6.2 (Berkeley) 5/12/86 .\" .TH END 3 "May 12, 1986" .AT 3 .SH NAME end, etext, edata \- last locations in program .SH SYNOPSIS .nf .B extern end; .B extern etext; .B extern edata; .fi .SH DESCRIPTION These names refer neither to routines nor to locations with interesting contents. The address of .I etext is the first address above the program text, .I edata above the initialized data region, and .I end above the uninitialized data region. .PP When execution begins, the program break coincides with .I end, but it is reset by the routines .IR brk (2), .IR malloc (3), standard input/output .RI ( stdio (3S)), the profile .RB ( \-p ) option of .IR cc (1), etc. The current value of the program break is reliably returned by `sbrk(0)', see .IR brk (2). .SH "SEE ALSO" brk(2), malloc(3) ================================================ FILE: share/man/man3/erf.3 ================================================ .\" Copyright (c) 1985 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)erf.3m 6.2 (Berkeley) 5/12/86 .\" .TH ERF 3M "May 12, 1986" .UC 6 .SH NAME erf, erfc \- error functions .SH SYNOPSIS .nf .B #include .PP .B double erf(x) .B double x; .PP .B double erfc(x) .B double x; .fi .SH DESCRIPTION Erf\|(x) returns the error function of x; where .if n \{\ .PP erf(x) = 2/sqrt(pi)\(**\|integral from 0 to x of exp(\-t\(**t) dt. \} .if t \{\ erf\|(x) := (2/\(sr\(*p)\|\(is\d\s8\z0\s10\u\u\s8x\s10\d\|exp(\-t\u\s82\s10\d)\|dt. \} .PP Erfc\|(x) returns 1.0\-erf\|(x). .PP The entry for erfc is provided because of the extreme loss of relative accuracy if erf\|(x) is called for large x and the result subtracted from 1. (e.g. for x = 10, 12 places are lost). .SH SEE ALSO math(3M) ================================================ FILE: share/man/man3/err.3 ================================================ .\" Copyright (c) 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. All advertising materials mentioning features or use of this software .\" must display the following acknowledgement: .\" This product includes software developed by the University of .\" California, Berkeley and its contributors. .\" 4. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)err.3 8.1.1 (2.11BSD GTE) 2/3/95 .\" .TH ERR 3 "February 3, 1995" .UC 4 .SH NAME err, verr , errx , verrx , warn , vwarn , warnx , vwarnx \- formatted error messages .SH SYNOPSIS .nf .ft B void err(eval, fmt, ...) int eval; char *fmt; .PP void verr(eval, fmt, args) int eval; char *fmt; va_list args; .PP void errx(eval, fmt, ...) int eval; char *fmt; .PP void verrx(eval, fmt, args) int eval char *fmt; va_list args; .PP void warn(fmt, ...) char *fmt; .PP void vwarn(fmt, args) char *fmt; va_list args; .PP void warnx(fmt, ...) char *fmt; .PP void vwarnx(fmt, args) char *fmt; va_list args; .ft R .fi .SH DESCRIPTION The .B err and .B warn family of functions display a formatted error message on the standard error output. In all cases, the last component of the program name, a colon character, and a space are output. If the .I fmt argument is not NULL, the formatted error message, a colon character, and a space are output. In the case of the .BR err , .BR verr , .BR warn , and .BR vwarn functions, the error message string affiliated with the current value of the global variable .I errno is output. In all cases, the output is followed by a newline character. .PP The .BR err , .BR verr , .BR errx , and .BR verrx functions do not return, but exit with the value of the argument .IR eval . .SH EXAMPLES Display the current errno information string and exit: .sp .in +1.0i .nf if ((p = malloc(size)) == NULL) err(1, NULL); if ((fd = open(file_name, O_RDONLY, 0)) == -1) err(1, "%s", file_name); .in -1.0i .fi .PP Display an error message and exit: .sp .in +1.0i .nf if (tm.tm_hour < START_TIME) errx(1, "too early, wait until %s", start_time_string); .in -1.0i .fi .PP Warn of an error: .sp .in +1.0i .nf if ((fd = open(raw_device, O_RDONLY, 0)) == -1) warnx("%s: %s: trying the block device", raw_device, strerror(errno)); if ((fd = open(block_device, O_RDONLY, 0)) == -1) err(1, "%s", block_device); .in -1.0i .fi .SH SEE ALSO strerror(3) .SH HISTORY The .B err and .B warn functions first appeared in 4.4BSD. ================================================ FILE: share/man/man3/execl.3 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)execl.3 6.2 (Berkeley) 8/4/87 .\" .TH EXECL 3 "August 4, 1987" .UC 5 .SH NAME execl, execv, execle, execlp, execvp, exec, execve, exect, environ \- execute a file .SH SYNOPSIS .nf .B execl(name, arg0, arg1, ..., argn, 0) .B char *name, *arg0, *arg1, ..., *argn; .PP .B execv(name, argv) .B char *name, *argv[]; .PP .B "execle(name, arg0, arg1, ..., argn, 0, envp)" .B "char *name, *arg0, *arg1, ..., *argn, *envp[];" .PP .B "exect(name, argv, envp) .B "char *name, *argv[], *envp[]; .PP .B extern char **environ; .fi .SH DESCRIPTION These routines provide various interfaces to the .I execve system call. Refer to .IR execve (2) for a description of their properties; only brief descriptions are provided here. .PP .I Exec in all its forms overlays the calling process with the named file, then transfers to the entry point of the core image of the file. There can be no return from a successful exec; the calling core image is lost. .PP The .I name argument is a pointer to the name of the file to be executed. The pointers .IR arg [ 0 ], .IR arg [ 1 "] ..." address null-terminated strings. Conventionally .IR arg [ 0 ] is the name of the file. .PP Two interfaces are available. .I execl is useful when a known file with known arguments is being called; the arguments to .I execl are the character strings constituting the file and the arguments; the first argument is conventionally the same as the file name (or its last component). A 0 argument must end the argument list. .PP The .I execv version is useful when the number of arguments is unknown in advance; the arguments to .I execv are the name of the file to be executed and a vector of strings containing the arguments. The last argument string must be followed by a 0 pointer. .PP The .I exect version is used when the executed file is to be manipulated with .IR ptrace (2). The program is forced to single step a single instruction giving the parent an opportunity to manipulate its state. On the VAX-11 this is done by setting the trace bit in the process status longword. .I Exect is not available on the PDP-11. .PP When a C program is executed, it is called as follows: .PP .nf main(argc, argv, envp) int argc; char **argv, **envp; .fi .PP where .I argc is the argument count and .I argv is an array of character pointers to the arguments themselves. As indicated, .I argc is conventionally at least one and the first member of the array points to a string containing the name of the file. .PP .I Argv is directly usable in another .I execv because .IR argv [ argc ] is 0. .PP .I Envp is a pointer to an array of strings that constitute the .I environment of the process. Each string consists of a name, an \*(lq=\*(rq, and a null-terminated value. The array of pointers is terminated by a null pointer. The shell .IR sh (1) passes an environment entry for each global shell variable defined when the program is called. See .IR environ (7) for some conventionally used names. The C run-time start-off routine places a copy of .I envp in the global cell .IR environ , which is used by .I execv and .I execl to pass the environment to any subprograms executed by the current program. .PP .I Execlp and .I execvp are called with the same arguments as .I execl and .IR execv , but duplicate the shell's actions in searching for an executable file in a list of directories. The directory list is obtained from the environment. .SH FILES .ta \w'/bin/sh 'u /bin/sh shell, invoked if command file found by .I execlp or .I execvp .SH "SEE ALSO" execve(2), fork(2), environ(7), csh(1) .SH DIAGNOSTICS If the file cannot be found, if it is not executable, if it does not start with a valid magic number (see .IR a.out (5)), if maximum memory is exceeded, or if the arguments require too much space, a return constitutes the diagnostic; the return value is \-1. Even for the super-user, at least one of the execute-permission bits must be set for a file to be executed. .SH BUGS If .I execvp is called to execute a file that turns out to be a shell command file, and if it is impossible to execute the shell, the values of .I argv[0] and .I argv[\-1] will be modified before return. ================================================ FILE: share/man/man3/exit.3 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)exit.3 6.2 (Berkeley) 5/12/86 .\" .TH EXIT 3 "May 12, 1986" .UC 5 .SH NAME exit \- terminate a process after flushing any pending output .SH SYNOPSIS .nf .ft B exit(status) int status; .fi .SH DESCRIPTION .I Exit terminates a process after calling the Standard I/O library function .I _cleanup to flush any buffered output. .I Exit never returns. .SH "SEE ALSO" exit(2), intro(3) ================================================ FILE: share/man/man3/exp.3 ================================================ .\" Copyright (c) 1985 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)exp.3m 6.9 (Berkeley) 5/27/86 .\" .TH EXP 3M "May 27, 1986" .UC 4 .ds nn \fINaN\fR .ds up \fIulp\fR .SH NAME exp, expm1, log, log10, log1p, pow \- exponential, logarithm, power .SH SYNOPSIS .nf .B #include .PP .B double exp(x) .B double x; .PP .B double expm1(x) .B double x; .PP .B double log(x) .B double x; .PP .B double log10(x) .B double x; .PP .B double log1p(x) .B double x; .PP .B double pow(x,y) .B double x,y; .fi .SH DESCRIPTION .PP Exp returns the exponential function of x. .PP Expm1 returns exp(x)\-1 accurately even for tiny x. .PP Log returns the natural logarithm of x. .PP Log10 returns the logarithm of x to base 10. .PP Log1p returns log(1+x) accurately even for tiny x. .PP Pow(x,y) returns .if n \ x**y. .if t \ x\u\s8y\s10\d. .SH ERROR (due to Roundoff etc.) exp(x), log(x), expm1(x) and log1p(x) are accurate to within an \*(up, and log10(x) to within about 2 \*(ups; an \*(up is one \fIU\fRnit in the \fIL\fRast \fIP\fRlace. The error in pow(x,y) is below about 2 \*(ups when its magnitude is moderate, but increases as pow(x,y) approaches the over/underflow thresholds until almost as many bits could be lost as are occupied by the floating\-point format's exponent field; that is 8 bits for VAX D and 11 bits for IEEE 754 Double. No such drastic loss has been exposed by testing; the worst errors observed have been below 20 \*(ups for VAX D, 300 \*(ups for IEEE 754 Double. Moderate values of pow are accurate enough that pow(integer,integer) is exact until it is bigger than 2**56 on a VAX, 2**53 for IEEE 754. .SH DIAGNOSTICS Exp, expm1 and pow return the reserved operand on a VAX when the correct value would overflow, and they set \fIerrno\fR to ERANGE. Pow(x,y) returns the reserved operand on a VAX and sets \fIerrno\fR to EDOM when x < 0 and y is not an integer. .PP On a VAX, \fIerrno\fR is set to EDOM and the reserved operand is returned by log unless x > 0, by log1p unless x > \-1. .SH NOTES The functions exp(x)\-1 and log(1+x) are called expm1 and logp1 in BASIC on the Hewlett\-Packard HP\-71B and APPLE Macintosh, EXP1 and LN1 in Pascal, exp1 and log1 in C on APPLE Macintoshes, where they have been provided to make sure financial calculations of ((1+x)**n\-1)/x, namely expm1(n\(**log1p(x))/x, will be accurate when x is tiny. They also provide accurate inverse hyperbolic functions. .PP Pow(x,0) returns x**0 = 1 for all x including x = 0, .if n \ Infinity .if t \ \(if (not found on a VAX), and \*(nn (the reserved operand on a VAX). Previous implementations of pow may have defined x**0 to be undefined in some or all of these cases. Here are reasons for returning x**0 = 1 always: .IP (1) \w'\0\0\0\0'u Any program that already tests whether x is zero (or infinite or \*(nn) before computing x**0 cannot care whether 0**0 = 1 or not. Any program that depends upon 0**0 to be invalid is dubious anyway since that expression's meaning and, if invalid, its consequences vary from one computer system to another. .IP (2) \w'\0\0\0\0'u Some Algebra texts (e.g. Sigler's) define x**0 = 1 for all x, including x = 0. This is compatible with the convention that accepts a[0] as the value of polynomial .ce p(x) = a[0]\(**x**0 + a[1]\(**x**1 + a[2]\(**x**2 +...+ a[n]\(**x**n .IP at x = 0 rather than reject a[0]\(**0**0 as invalid. .IP (3) \w'\0\0\0\0'u Analysts will accept 0**0 = 1 despite that x**y can approach anything or nothing as x and y approach 0 independently. The reason for setting 0**0 = 1 anyway is this: .IP If x(z) and y(z) are \fIany\fR functions analytic (expandable in power series) in z around z = 0, and if there x(0) = y(0) = 0, then x(z)**y(z) \(-> 1 as z \(-> 0. .IP (4) \w'\0\0\0\0'u If 0**0 = 1, then .if n \ infinity**0 = 1/0**0 = 1 too; and .if t \ \(if**0 = 1/0**0 = 1 too; and then \*(nn**0 = 1 too because x**0 = 1 for all finite and infinite x, i.e., independently of x. .SH SEE ALSO math(3M), infnan(3M) .SH AUTHOR Kwok\-Choi Ng, W. Kahan ================================================ FILE: share/man/man3/fclose.3 ================================================ .\" @(#)fclose.3s 6.1 (Berkeley) 5/15/85 .\" .TH FCLOSE 3S "May 15, 1985" .AT 3 .SH NAME fclose, fflush \- close or flush a stream .SH SYNOPSIS .B #include .PP .B fclose(stream) .br .SM .B FILE .B *stream; .PP .B fflush(stream) .br .SM .B FILE .B *stream; .SH DESCRIPTION .I Fclose causes any buffers for the named .I stream to be emptied, and the file to be closed. Buffers allocated by the standard input/output system are freed. .PP .I Fclose is performed automatically upon calling .IR exit (3). .PP .I Fflush causes any buffered data for the named output .I stream to be written to that file. The stream remains open. .SH "SEE ALSO" close(2), fopen(3S), setbuf(3S) .SH DIAGNOSTICS These routines return .SM .B EOF if .I stream is not associated with an output file, or if buffered data cannot be transferred to that file. ================================================ FILE: share/man/man3/ferror.3 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)ferror.3s 6.3 (Berkeley) 5/14/86 .\" .TH FERROR 3S "May 14, 1986" .UC 4 .SH NAME ferror, feof, clearerr, fileno \- stream status inquiries .SH SYNOPSIS .B #include .PP .B feof(stream) .br .SM .B FILE .B *stream; .PP .B ferror(stream) .br .SM .B FILE .B *stream .PP .B clearerr(stream) .br .SM .B FILE .B *stream .PP .B fileno(stream) .br .SM .B FILE .B *stream; .SH DESCRIPTION .I Feof returns non-zero when end of file is read on the named input .IR stream , otherwise zero. Unless cleared by .IR clearerr , the end-of-file indication lasts until the stream is closed. .PP .I Ferror returns non-zero when an error has occurred reading or writing the named .IR stream , otherwise zero. Unless cleared by .IR clearerr , the error indication lasts until the stream is closed. .PP .I Clearerr resets the error and end-of-file indicators on the named .IR stream . .PP .I Fileno returns the integer file descriptor associated with the .IR stream , see .IR open (2). .PP Currently all of these functions are implemented as macros; they cannot be redeclared. .SH "SEE ALSO" fopen(3S), open(2) ================================================ FILE: share/man/man3/floor.3 ================================================ .\" Copyright (c) 1985 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)floor.3m 6.4 (Berkeley) 5/12/86 .\" .TH FLOOR 3M "May 12, 1986" .UC 4 .SH NAME fabs, floor, ceil, rint \- absolute value, floor, ceiling, and round-to-nearest functions .SH SYNOPSIS .nf .B #include .PP .B double floor(x) .B double x; .PP .B double ceil(x) .B double x; .PP .B double fabs(x) .B double x; .PP .B double rint(x) .B double x; .fi .SH DESCRIPTION Fabs returns the absolute value |\|x\||. .PP Floor returns the largest integer no greater than x. .PP Ceil returns the smallest integer no less than x. .PP Rint returns the integer (represented as a double precision number) nearest x in the direction of the prevailing rounding mode. .SH NOTES On a VAX, rint(x) is equivalent to adding half to the magnitude and then rounding towards zero. .PP In the default rounding mode, to nearest, on a machine that conforms to IEEE 754, rint(x) is the integer nearest x with the additional stipulation that if |rint(x)\-x|=1/2 then rint(x) is even. Other rounding modes can make rint act like floor, or like ceil, or round towards zero. .PP Another way to obtain an integer near x is to declare (in C) .RS double x;\0\0\0\0 int k;\0\0\0\0k\0=\0x; .RE Most C compilers round x towards 0 to get the integer k, but some do otherwise. If in doubt, use floor, ceil, or rint first, whichever you intend. Also note that, if x is larger than k can accommodate, the value of k and the presence or absence of an integer overflow are hard to predict. .SH SEE ALSO abs(3), ieee(3M), math(3M) ================================================ FILE: share/man/man3/fopen.3 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)fopen.3s 6.3 (Berkeley) 5/27/86 .\" .TH FOPEN 3S "May 27, 1986" .UC 4 .SH NAME fopen, freopen, fdopen \- open a stream .SH SYNOPSIS .B #include .PP .SM .B FILE .B *fopen(filename, type) .br .B char *filename, *type; .PP .SM .B FILE .B *freopen(filename, type, stream) .br .B char *filename, *type; .br .SM .B FILE .B *stream; .PP .SM .B FILE .B *fdopen(fildes, type) .br .B char *type; .SH DESCRIPTION .I Fopen opens the file named by .I filename and associates a stream with it. .I Fopen returns a pointer to be used to identify the stream in subsequent operations. .PP .I Type is a character string having one of the following values: .TP 5 "r" open for reading .ns .TP 5 "w" create for writing .ns .TP 5 "a" append: open for writing at end of file, or create for writing .PP In addition, each .I type may be followed by a "+" to have the file opened for reading and writing. "r+" positions the stream at the beginning of the file, "w+" creates or truncates it, and "a+" positions it at the end. Both reads and writes may be used on read/write streams, with the limitation that an .I fseek, rewind, or reading an end-of-file must be used between a read and a write or vice-versa. .PP .I Freopen substitutes the named file in place of the open .IR stream . It returns the original value of .IR stream . The original stream is closed. .PP .I Freopen is typically used to attach the preopened constant names, .B stdin, stdout, stderr, to specified files. .PP .I Fdopen associates a stream with a file descriptor obtained from .I open, dup, creat, or .IR pipe (2). The .I type of the stream must agree with the mode of the open file. .SH "SEE ALSO" open(2), fclose(3) .SH DIAGNOSTICS .I Fopen and .I freopen return the pointer .SM .B NULL if .I filename cannot be accessed, if too many files are already open, or if other resources needed cannot be allocated. .SH BUGS .I Fdopen is not portable to systems other than UNIX. .PP The read/write .I types do not exist on all systems. Those systems without read/write modes will probably treat the .I type as if the "+" was not present. These are unreliable in any event. .PP In order to support the same number of open files as does the system, .I fopen must allocate additional memory for data structures using .I calloc after 20 files have been opened. This confuses some programs which use their own memory allocators. An undocumented routine, .IR f_prealloc , may be called to force immediate allocation of all internal memory except for buffers. ================================================ FILE: share/man/man3/fread.3 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)fread.3s 6.1 (Berkeley) 5/15/85 .\" .TH FREAD 3S "May 15, 1985" .UC 4 .SH NAME fread, fwrite \- buffered binary input/output .SH SYNOPSIS .B #include .PP .B fread(ptr, sizeof(*ptr), nitems, stream) .br .SM .B FILE .B *stream; .PP .B fwrite(ptr, sizeof(*ptr), nitems, stream) .br .SM .B FILE .B *stream; .SH DESCRIPTION .I Fread reads, into a block beginning at .IR ptr , .I nitems of data of the type of .I *ptr from the named input .IR stream . It returns the number of items actually read. .PP If .I stream is .B stdin and the standard output is line buffered, then any partial output line will be flushed before any call to .IR read (2) to satisfy the .IR fread . .PP .I Fwrite appends at most .I nitems of data of the type of .I *ptr beginning at .I ptr to the named output .IR stream . It returns the number of items actually written. .SH "SEE ALSO" read(2), write(2), fopen(3S), getc(3S), putc(3S), gets(3S), puts(3S), printf(3S), scanf(3S) .SH DIAGNOSTICS .I Fread and .I fwrite return 0 upon end of file or error. ================================================ FILE: share/man/man3/frexp.3 ================================================ .\" @(#)frexp.3 6.1 (Berkeley) 5/15/85 .\" .TH FREXP 3 "May 15, 1985" .AT 3 .SH NAME frexp, ldexp, modf \- split into mantissa and exponent .SH SYNOPSIS .nf .B double frexp(value, eptr) .B double value; .B int *eptr; .PP .B double ldexp(value, exp) .B double value; .PP .B double modf(value, iptr) .B double value, *iptr; .SH DESCRIPTION .I Frexp returns the mantissa of a double .I value as a double quantity, .I x, of magnitude less than 1 and stores an integer .I n such that .I value = \fIx\fP\|\(**\|2\u\fIn\fP\d indirectly through .I eptr. .PP .I Ldexp returns the quantity \fIvalue\|\(**\|2\u\fIexp\fP\d. .PP .I Modf returns the positive fractional part of .I value and stores the integer part indirectly through .I iptr. ================================================ FILE: share/man/man3/fseek.3 ================================================ .\" @(#)fseek.3s 6.3 (Berkeley) 2/24/86 .\" .TH FSEEK 3S "February 24, 1986" .AT 3 .SH NAME fseek, ftell, rewind \- reposition a stream .SH SYNOPSIS .B #include .PP .B fseek(stream, offset, ptrname) .br .SM .B FILE .B *stream; .br .B long offset; .PP .B long ftell(stream) .br .SM .B FILE .B *stream; .PP .B rewind(stream) .SH DESCRIPTION .I Fseek sets the position of the next input or output operation on the .IR stream . The new position is at the signed distance .I offset bytes from the beginning, the current position, or the end of the file, according as .I ptrname has the value 0, 1, or 2. .PP .I Fseek undoes any effects of .IR ungetc (3S). .PP .I Ftell returns the current value of the offset relative to the beginning of the file associated with the named .IR stream . It is measured in bytes on UNIX; on some other systems it is a magic cookie, and the only foolproof way to obtain an .I offset for .IR fseek . .PP .IR Rewind ( stream ) is equivalent to .IR fseek ( stream , 0L, 0). .SH "SEE ALSO" lseek(2), fopen(3S) .SH DIAGNOSTICS .I Fseek returns \-1 for improper seeks, otherwise zero. ================================================ FILE: share/man/man3/getc.3 ================================================ .\" @(#)getc.3s 6.2 (Berkeley) 5/14/86 .\" .TH GETC 3S "May 14, 1986" .AT 3 .SH NAME getc, getchar, fgetc, getw \- get character or word from stream .SH SYNOPSIS .B #include .PP .B int getc(stream) .br .SM .B FILE .B *stream; .PP .B int getchar() .PP .B int fgetc(stream) .br .SM .B FILE .B *stream; .PP .B int getw(stream) .br .SM .B FILE .B *stream; .SH DESCRIPTION .I Getc returns the next character from the named input .IR stream . .PP .IR Getchar () is identical to .IR getc ( stdin ) . .PP .I Fgetc behaves like .IR getc , but is a genuine function, not a macro; it may be used to save object text. .PP .I Getw returns the next .B int (a 32-bit integer on a VAX-11) from the named input .IR stream . It returns the constant .SM .B EOF upon end of file or error, but since that is a good integer value, .I feof and .IR ferror (3S) should be used to check the success of .IR getw . .I Getw assumes no special alignment in the file. .SH "SEE ALSO" clearerr(3S), fopen(3S), putc(3S), gets(3S), scanf(3S), fread(3S), ungetc(3S) .SH DIAGNOSTICS These functions return the integer constant .SM .B EOF at end of file, upon read error, or if an attempt is made to read a file not opened by .IR fopen . The end-of-file condition is remembered, even on a terminal, and all subsequent attempts to read will return .B EOF until the condition is cleared with .IR clearerr (3S). .SH BUGS Because it is implemented as a macro, .I getc treats a .I stream argument with side effects incorrectly. In particular, `getc(*f++);' doesn't work sensibly. ================================================ FILE: share/man/man3/getdisk.3 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)getdisk.3 6.2.1 (2.11BSD) 1995/09/08 .\" .TH GETDISKBYNAME 3 "September 8, 1995" .UC 5 .SH NAME getdiskbyname \- get disk description by its name .SH SYNOPSIS .nf .B #include .B #include .PP .B struct disklabel * .B getdiskbyname(name) .B char *name; .fi .SH DESCRIPTION .I Getdiskbyname takes a disk name (e.g. rm03) and returns a structure describing its geometry information and the standard disk partition tables. Information obtained from the .IR disktab (5) file has the following form: .sp .cs R 24 .nf .so /usr/include/sys/disklabel.h .fi .cs R .SH "SEE ALSO" disktab(5), disklabel(8) .SH BUGS This routine is primarily used when the underlying disk driver does not support labels. The other use is for supplying default information to the .IR disklabel (8) program. ================================================ FILE: share/man/man3/getenv.3 ================================================ .\" @(#)getenv.3 6.4 (Berkeley) 3/20/87 .\" .TH GETENV 3 "March 20, 1987" .AT 3 .SH NAME getenv, setenv, unsetenv \- manipulate environmental variables .SH SYNOPSIS .nf .B char *getenv(name) .B char *name; .PP .B setenv(name, value, overwrite) .B char *name, value; .B int overwrite; .PP .B void unsetenv(name) .B char *name; .fi .SH DESCRIPTION \fIGetenv\fP searches the environment list (see \fIenviron\fP(7)) for a string of the form \fIname\fP\fB=\fP\fIvalue\fP and returns a pointer to the string \fIvalue\fP if such a string is present, and 0 (NULL) if it is not. .PP \fISetenv\fP searches the environment list as \fIgetenv\fP does; if the string \fIname\fP is not found, a string of the form \fIname\fP\fB=\fP\fIvalue\fP is added to the environment. If it is found, and \fIoverwrite\fP is non-zero, its value is changed to \fIvalue\fP. \fISetenv\fP returns 0 on success and -1 on failure, where failure is caused by an inability to allocate space for the environment. .PP \fIUnsetenv\fP removes all occurrences of the string \fIname\fP from the environment. There is no library provision for completely removing the current environment. It is suggested that the following code be used to do so. .PP .nf static char *envinit[1]; extern char **environ; environ = envinit; .fi .PP All of these routines permit, but do not require, a trailing equals (``='') sign on \fIname\fP or a leading equals sign on \fIvalue\fP. .SH SEE ALSO csh(1), sh(1), execve(2), environ(7) ================================================ FILE: share/man/man3/getfsent.3 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)getfsent.3 6.3 (Berkeley) 5/12/86 .\" .TH GETFSENT 3 "May 12, 1986" .UC 4 .SH NAME getfsent, getfsspec, getfsfile, getfstype, setfsent, endfsent \- get file system descriptor file entry .SH SYNOPSIS .nf .B #include .PP .B struct fstab *getfsent() .PP .B struct fstab *getfsspec(spec) .B char *spec; .PP .B struct fstab *getfsfile(file) .B char *file; .PP .B struct fstab *getfstype(type) .B char *type; .PP .B int setfsent() .PP .B int endfsent() .fi .SH DESCRIPTION .IR Getfsent , .IR getfsspec , .IR getfstype , and .I getfsfile each return a pointer to an object with the following structure containing the broken-out fields of a line in the file system description file, .IR < fstab.h >. .RS .PP .nf struct fstab { char *fs_spec; char *fs_file; char *fs_type; int fs_freq; int fs_passno; }; .ft R .ad .fi .RE .PP The fields have meanings described in .IR fstab (5). .PP .I Getfsent reads the next line of the file, opening the file if necessary. .PP .I Setfsent opens and rewinds the file. .PP .I Endfsent closes the file. .PP .I Getfsspec and .I getfsfile sequentially search from the beginning of the file until a matching special file name or file system file name is found, or until EOF is encountered. .I Getfstype does likewise, matching on the file system type field. .SH FILES /etc/fstab .SH "SEE ALSO" fstab(5) .SH DIAGNOSTICS Null pointer (0) returned on EOF or error. .SH BUGS All information is contained in a static area so it must be copied if it is to be saved. ================================================ FILE: share/man/man3/getgrent.3 ================================================ .\" @(#)getgrent.3 6.1 (Berkeley) 5/15/85 .\" .TH GETGRENT 3 "May 15, 1985" .AT 3 .SH NAME getgrent, getgrgid, getgrnam, setgrent, endgrent \- get group file entry .SH SYNOPSIS .nf .B #include .PP .B struct group *getgrent() .PP .B struct group *getgrgid(gid) .B int gid; .PP .B struct group *getgrnam(name) .B char *name; .PP .B setgrent() .PP .B endgrent() .fi .SH DESCRIPTION .I Getgrent, .I getgrgid and .I getgrnam each return pointers to an object with the following structure containing the broken-out fields of a line in the group file. .RS .PP .nf .so /usr/include/grp.h .fi .RE .PP The members of this structure are: .TP \w'gr_passwd'u+2n gr_name The name of the group. .br .ns .TP \w'gr_passwd'u+2n gr_passwd The encrypted password of the group. .br .ns .TP \w'gr_passwd'u+2n gr_gid The numerical group-ID. .br .ns .TP \w'gr_passwd'u+2n gr_mem Null-terminated vector of pointers to the individual member names. .PP .I Getgrent simply reads the next line while .I getgrgid and .I getgrnam search until a matching .I gid or .I name is found (or until EOF is encountered). Each routine picks up where the others leave off so successive calls may be used to search the entire file. .PP A call to .I setgrent has the effect of rewinding the group file to allow repeated searches. .I Endgrent may be called to close the group file when processing is complete. .SH FILES /etc/group .SH "SEE ALSO" getlogin(3), getpwent(3), group(5) .SH DIAGNOSTICS A null pointer (0) is returned on EOF or error. .SH BUGS All information is contained in a static area so it must be copied if it is to be saved. ================================================ FILE: share/man/man3/getgrouplist.3 ================================================ .\" Copyright (c) 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. All advertising materials mentioning features or use of this software .\" must display the following acknowledgement: .\" This product includes software developed by the University of .\" California, Berkeley and its contributors. .\" 4. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)getgrouplist.3 8.1.1 (2.11BSD) 1997/6/25 .\" .TH GETGROUPLIST 3 "June 25, 1997" .UC 4 .SH NAME getgrouplist \- calculate group access list .SH SYNOPSIS .nf .B #include .B int \fBgetgrouplist\fP(\fIname, basegid, groups, ngroups\fP) \ \ \ \ \ \ \ \ \ \ \ \ \ char\ *name; \ \ \ \ \ \ \ \ \ \ \ \ \ gid_t basegid; \ \ \ \ \ \ \ \ \ \ \ \ \ gid_t *groups; \ \ \ \ \ \ \ \ \ \ \ \ \ int\ \ \ *ngroups; .SH DESCRIPTION The .B getgrouplist function reads through the group file and calculates the group access list for the user specified in .IR name . The .I basegid is automatically included in the groups list. Typically this value is given as the group number from the password file. .PP The resulting group list is returned in the integer array pointed to by .IR groups . The caller specifies the size of the .IR groups array in the integer pointed to by .IR ngroups ; the actual number of groups found is returned in .IR ngroups . .SH RETURN VALUES The .B getgrouplist function returns \-1 if the size of the group list is too small to hold all the user's groups. Here, the group array will be filled with as many groups as will fit. .SH FILES .TP 12 /etc/group group membership list .SH SEE ALSO setgroups(2), initgroups(3) .SH HISTORY The .B getgrouplist function first appeared in 4.4BSD. .SH BUGS The .B getgrouplist function uses the routines based on getgrent(3). If the invoking program uses any of these routines, the group structure will be overwritten in the call to .BR getgrouplist . ================================================ FILE: share/man/man3/gethostbyname.3 ================================================ .\" Copyright (c) 1983,1987 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)gethostbyname.3 6.9.1 (2.11BSD) 1996/10/30 .\" .TH GETHOSTBYNAME 3 "October 30, 1996" .UC 5 .SH NAME gethostbyname, gethostbyaddr, gethostent, sethostent, endhostent, herror \- get network host entry .SH SYNOPSIS .B "#include .PP .B "extern int h_errno; .PP .B "struct hostent *gethostbyname(name) .br .B "char *name; .PP .B "struct hostent *gethostbyaddr(addr, len, type) .br .B "char *addr; int len, type; .PP .B "struct hostent *gethostent() .PP .B "sethostent(stayopen) .br .B "int stayopen; .PP .B "endhostent() .PP .B "herror(string) .br .B "char *string; .PP .SH DESCRIPTION .I Gethostbyname and .I gethostbyaddr each return a pointer to an object with the following structure describing an internet host referenced by name or by address, respectively. This structure contains either the information obtained from the name server, .IR named (8), or broken-out fields from a line in .IR /etc/hosts . If the local name server is not running these routines do a lookup in .IR /etc/hosts . .RS .PP .nf struct hostent { char *h_name; /* official name of host */ char **h_aliases; /* alias list */ int h_addrtype; /* host address type */ int h_length; /* length of address */ char **h_addr_list; /* list of addresses from name server */ }; #define h_addr h_addr_list[0] /* address, for backward compatibility */ .ft R .ad .fi .RE .PP The members of this structure are: .TP \w'h_addr_list'u+2n h_name Official name of the host. .TP \w'h_addr_list'u+2n h_aliases A zero terminated array of alternate names for the host. .TP \w'h_addr_list'u+2n h_addrtype The type of address being returned; currently always AF_INET. .TP \w'h_addr_list'u+2n h_length The length, in bytes, of the address. .TP \w'h_addr_list'u+2n h_addr_list A zero terminated array of network addresses for the host. Host addresses are returned in network byte order. .TP \w'h_addr_list'u+2n h_addr The first address in h_addr_list; this is for backward compatiblity. .PP When using the nameserver, .I gethostbyname will search for the named host in the current domain and its parents unless the name ends in a dot. If the name contains no dot, and if the environment variable ``HOSTALIASES'' contains the name of an alias file, the alias file will first be searched for an alias matching the input name. See .IR hostname (7) for the domain search procedure and the alias file format. .PP .I Sethostent may be used to request the use of a connected TCP socket for queries. If the .I stayopen flag is non-zero, this sets the option to send all queries to the name server using TCP and to retain the connection after each call to .I gethostbyname or .IR gethostbyaddr . Otherwise, queries are performed using UDP datagrams. .PP .I Endhostent closes the TCP connection. .SH DIAGNOSTICS .PP Error return status from .I gethostbyname and .I gethostbyaddr is indicated by return of a null pointer. The external integer .IR h_errno may then be checked to see whether this is a temporary failure or an invalid or unknown host. The routine .I herror can be used to print an error message describing the failure. If its argument .I string is non-NULL, it is printed, followed by a colon and a space. The error message is printed with a trailing newline. .PP .IR h_errno can have the following values: .RS .IP HOST_NOT_FOUND \w'HOST_NOT_FOUND'u+2n No such host is known. .IP TRY_AGAIN \w'HOST_NOT_FOUND'u+2n This is usually a temporary error and means that the local server did not receive a response from an authoritative server. A retry at some later time may succeed. .IP NO_RECOVERY \w'HOST_NOT_FOUND'u+2n Some unexpected server failure was encountered. This is a non-recoverable error. .IP NO_DATA \w'HOST_NOT_FOUND'u+2n The requested name is valid but does not have an IP address; this is not a temporary error. This means that the name is known to the name server but there is no address associated with this name. Another type of request to the name server using this domain name will result in an answer; for example, a mail-forwarder may be registered for this domain. .RE .SH FILES /etc/hosts .SH "SEE ALSO" resolver(3), hosts(5), hostname(7), named(8) .SH CAVEAT .PP .I Gethostent is defined, and .I sethostent and .I endhostent are redefined, when .IR libc is built to use only the routines to lookup in .IR /etc/hosts and not the name server. .PP .I Gethostent reads the next line of .IR /etc/hosts , opening the file if necessary. .PP .I Sethostent is redefined to open and rewind the file. If the .I stayopen argument is non-zero, the hosts data base will not be closed after each call to .I gethostbyname or .IR gethostbyaddr . .I Endhostent is redefined to close the file. .SH BUGS All information is contained in a static area so it must be copied if it is to be saved. Only the Internet address format is currently understood. ================================================ FILE: share/man/man3/getloadavg.3 ================================================ .\" Copyright (c) 1989, 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. All advertising materials mentioning features or use of this software .\" must display the following acknowledgement: .\" This product includes software developed by the University of .\" California, Berkeley and its contributors. .\" 4. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)getloadavg.3 8.1.1 (2.11BSD GTE) 1/15/95 .\" .TH GETLOADAVG 3 "January 15, 1995" .UC 4 .SH NAME getloadavg \- get system load averages .SH SYNOPSIS .nf .B getloadavg(loadavg, nelem) double loadavg[]; int nelem; .fi .SH DESCRIPTION The \fIgetloadavg\fP function returns the number of processes in the system run queue averaged over various periods of time. Up to \fInelem\fP samples are retrieved and assigned to successive elements of \fIloadavg\fP. The system imposes a maximum of 3 samples, representing averages over the last 1, 5, and 15 minutes, respectively. .SH DIAGNOSTICS If the load average was unobtainable, \-1 is returned; otherwise, the number of samples actually retrieved is returned. .SH SEE ALSO uptime(1), sysctl(3), sysctl(8). .SH HISTORY The .B getloadavg function appeared in \fB4.3BSD-Reno\fP. .PP This function replaces the 2.9BSD compatibility routine getla(). ================================================ FILE: share/man/man3/getmntinfo.3 ================================================ .\" Copyright (c) 1989, 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. All advertising materials mentioning features or use of this software .\" must display the following acknowledgement: .\" This product includes software developed by the University of .\" California, Berkeley and its contributors. .\" 4. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)getmntinfo.3 8.1.1 (2.11BSD) 1995/12/26 .\" .TH GETMNTINFO 3 "December 26, 1995" .UC 7 .SH NAME \fBgetmntinfo\fP \- get information about mounted file systems .SH SYNOPSIS .B #include .br .B #include .sp .I int .br \fBgetmntinfo\fP(mntbufp,flags) .br .I struct statfs **mntbufp; .br .I int flags .br .SH DESCRIPTION The .BR getmntinfo () function returns an array of .I statfs structures describing each currently mounted file system (see .BR statfs (2). .PP The .BR getmntinfo () function passes its .I flags parameter transparently to .BR getfsstat (2). .SH RETURN VALUES On successful completion, .BR getmntinfo () returns a count of the number of elements in the array. The pointer to the array is stored into .IR mntbufp . .PP If an error occurs, zero is returned and the external variable .I errno is set to indicate the error. Although the pointer .I mntbufp will be unmodified, any information previously returned by .BR getmntinfo () will be lost. .SH ERRORS The .BR getmntinfo () function may fail and set errno for any of the errors specified for the library routines .BR getfsstat (2) or .BR malloc (3). .SH SEE ALSO getfsstat(2), statfs(2), mount(2), mount(8) .SH HISTORY The .BR getmntinfo () function first appeared in 4.4BSD. .SH BUGS The .BR getmntinfo () function writes the array of structures to an internal static object and returns a pointer to that object. Subsequent calls to .BR getmntinfo () will modify the same object. .PP The memory allocated by .BR getmntinfo () cannot be .BR free (2)'d by the application. ================================================ FILE: share/man/man3/getnetent.3 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)getnetent.3n 6.3 (Berkeley) 5/19/86 .\" .TH GETNETENT 3N "May 19, 1986" .UC 5 .SH NAME getnetent, getnetbyaddr, getnetbyname, setnetent, endnetent \- get network entry .SH SYNOPSIS .nf .ft B #include .PP .ft B struct netent *getnetent() .PP .ft B struct netent *getnetbyname(name) char *name; .PP .ft B struct netent *getnetbyaddr(net, type) long net; int type; .PP .ft B setnetent(stayopen) int stayopen; .PP .ft B endnetent() .fi .SH DESCRIPTION .IR Getnetent , .IR getnetbyname , and .I getnetbyaddr each return a pointer to an object with the following structure containing the broken-out fields of a line in the network data base, .IR /etc/networks . .RS .PP .nf struct netent { char *n_name; /* official name of net */ char **n_aliases; /* alias list */ int n_addrtype; /* net number type */ unsigned long n_net; /* net number */ }; .ft R .ad .fi .RE .PP The members of this structure are: .TP \w'n_addrtype'u+2n n_name The official name of the network. .TP \w'n_addrtype'u+2n n_aliases A zero terminated list of alternate names for the network. .TP \w'n_addrtype'u+2n n_addrtype The type of the network number returned; currently only AF_INET. .TP \w'n_addrtype'u+2n n_net The network number. Network numbers are returned in machine byte order. .PP .I Getnetent reads the next line of the file, opening the file if necessary. .PP .I Setnetent opens and rewinds the file. If the .I stayopen flag is non-zero, the net data base will not be closed after each call to .I getnetbyname or .IR getnetbyaddr . .PP .I Endnetent closes the file. .PP .I Getnetbyname and .I getnetbyaddr sequentially search from the beginning of the file until a matching net name or net address and type is found, or until EOF is encountered. Network numbers are supplied in host order. .SH FILES /etc/networks .SH "SEE ALSO" networks(5) .SH DIAGNOSTICS Null pointer (0) returned on EOF or error. .SH BUGS All information is contained in a static area so it must be copied if it is to be saved. Only Internet network numbers are currently understood. Expecting network numbers to fit in no more than 32 bits is probably naive. ================================================ FILE: share/man/man3/getopt.3 ================================================ .\" Copyright (c) 1988, 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. All advertising materials mentioning features or use of this software .\" must display the following acknowledgement: .\" This product includes software developed by the University of .\" California, Berkeley and its contributors. .\" 4. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)getopt.3 8.4.1 (2.11BSD) 1996/1/12 .\" .TH GETOPT 3 "January 12, 1996" .UC 6 .SH NAME \fBgetopt\fP \- get option character from command line argument list .SH SYNOPSIS .B #include .sp .B extern char *optarg; .br .B extern int optind; .br .B extern int optopt; .br .B extern int opterr; .br .B extern int optreset; .sp .I int .br \fBgetopt\fP(argc, argv, optstring) .br .I int argc; .br .I char **argv; .br .I char *optstring; .SH DESCRIPTION The .BR getopt () function incrementally parses a command line argument list .I argv and returns the next .I known option character. An option character is .I known if it has been specified in the string of accepted option characters, .IR optstring . .PP The option string .I optstring may contain the following elements: individual characters, and characters followed by a colon to indicate an option argument is to follow. For example, an option string "\&""x"" recognizes an option ``\-\fBx\fP'', and an option string "\&""x:"" recognizes an option and argument ``\fB\-x\fP \fIargument\fP''. It does not matter to .BR getopt () if a following argument has leading white space. .PP On return from .BR getopt (), .I optarg points to an option argument, if it is anticipated, and the variable .I optind contains the index to the next .I argv argument for a subsequent call to .BR getopt (). The variable .I optopt saves the last .I known option character returned by .BR getopt (). .PP The variable .I opterr and .I optind are both initialized to 1. The .I optind variable may be set to another value before a set of calls to .BR getopt () in order to skip over more or less argv entries. .PP In order to use .BR getopt () to evaluate multiple sets of arguments, or to evaluate a single set of arguments multiple times, the variable .I optreset must be set to 1 before the second and each additional set of calls to .BR getopt (), and the variable .I optind must be reinitialized. .PP The .BR getopt () function returns an .B EOF when the argument list is exhausted, or a non-recognized option is encountered. The interpretation of options in the argument list may be cancelled by the option `\-\-' (double dash) which causes .BR getopt () to signal the end of argument processing and return an .BR EOF . When all options have been processed (i.e., up to the first non-option argument), .BR getopt () returns .BR EOF . .SH DIAGNOSTICS If the .BR getopt () function encounters a character not found in the string .I optarg or detects a missing option argument it writes an error message and returns `?' to the .IR stderr . Setting .I opterr to a zero will disable these error messages. If .I optstring has a leading `\&:' then a missing option argument causes a `\&:' to be returned in addition to suppressing any error messages. .PP Option arguments are allowed to begin with `\-'; this is reasonable but reduces the amount of error checking possible. .SH EXTENSIONS The .I optreset variable was added to make it possible to call the .BR getopt () function multiple times. This is an extension to the IEEE Std1003.2 (``POSIX'') specification. .SH EXAMPLE .nf .cs R 24 extern char *optarg; extern int optind; int bflag, ch, fd; bflag = 0; while ((ch = getopt(argc, argv, "bf:")) != EOF) switch(ch) { case 'b': bflag = 1; break; case 'f': if ((fd = open(optarg, O_RDONLY, 0)) < 0) { (void)fprintf(stderr, "myname: %s: %s\en", optarg, strerror(errno)); exit(1); } break; case '?': default: usage(); } argc -= optind; argv += optind; .br .cs R .fi .SH HISTORY The .BR getopt () function appeared 4.3BSD. .SH BUGS A single dash ``\-'' may be specified as an character in .I optstring , however it should .B never have an argument associated with it. This allows .BR getopt () to be used with programs that expect ``\-'' as an option flag. This practice is wrong, and should not be used in any current development. It is provided for backward compatibility .B only . By default, a single dash causes .BR getopt () to return .BR EOF . This is, we believe, compatible with System V. .PP It is also possible to handle digits as option letters. This allows .BR getopt () to be used with programs that expect a number (``-3'') as an option. This practice is wrong, and should not be used in any current development. It is provided for backward compatibility .BR only . The following code fragment works in most cases. .sp .nf .cs R 24 int length; char *p; while ((c = getopt(argc, argv, "0123456789")) != EOF) switch (c) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': p = argv[optind - 1]; if (p[0] == '-' && p[1] == ch && !p[2]) length = atoi(++p); else length = atoi(argv[optind] + 1); break; } } .cs R ================================================ FILE: share/man/man3/getpass.3 ================================================ .\" @(#)getpass.3 6.1 (Berkeley) 5/15/85 .\" .TH GETPASS 3 "May 15, 1985" .AT 3 .SH NAME getpass \- read a password .SH SYNOPSIS .nf .B char *getpass(prompt) .B char *prompt; .fi .SH DESCRIPTION .I Getpass reads a password from the file .IR /dev/tty , or if that cannot be opened, from the standard input, after prompting with the null-terminated string .I prompt and disabling echoing. A pointer is returned to a null-terminated string of at most 8 characters. .SH FILES /dev/tty .SH "SEE ALSO" crypt(3) .SH BUGS The return value points to static data whose content is overwritten by each call. ================================================ FILE: share/man/man3/getprotoent.3 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)getprotoent.3n 6.3 (Berkeley) 5/19/86 .\" .TH GETPROTOENT 3N "May 19, 1986" .UC 5 .SH NAME getprotoent, getprotobynumber, getprotobyname, setprotoent, endprotoent \- get protocol entry .SH SYNOPSIS .nf .ft B .B #include .PP .ft B struct protoent *getprotoent() .PP .ft B struct protoent *getprotobyname(name) char *name; .PP .ft B struct protoent *getprotobynumber(proto) int proto; .PP .ft B setprotoent(stayopen) int stayopen .PP .ft B endprotoent() .fi .SH DESCRIPTION .IR Getprotoent , .IR getprotobyname , and .I getprotobynumber each return a pointer to an object with the following structure containing the broken-out fields of a line in the network protocol data base, .IR /etc/protocols . .RS .PP .nf struct protoent { char *p_name; /* official name of protocol */ char **p_aliases; /* alias list */ int p_proto; /* protocol number */ }; .ft R .ad .fi .RE .PP The members of this structure are: .TP \w'p_aliases'u+2n p_name The official name of the protocol. .TP \w'p_aliases'u+2n p_aliases A zero terminated list of alternate names for the protocol. .TP \w'p_aliases'u+2n p_proto The protocol number. .PP .I Getprotoent reads the next line of the file, opening the file if necessary. .PP .I Setprotoent opens and rewinds the file. If the .I stayopen flag is non-zero, the net data base will not be closed after each call to .I getprotobyname or .IR getprotobynumber . .PP .I Endprotoent closes the file. .PP .I Getprotobyname and .I getprotobynumber sequentially search from the beginning of the file until a matching protocol name or protocol number is found, or until EOF is encountered. .SH FILES /etc/protocols .SH "SEE ALSO" protocols(5) .SH DIAGNOSTICS Null pointer (0) returned on EOF or error. .SH BUGS All information is contained in a static area so it must be copied if it is to be saved. Only the Internet protocols are currently understood. ================================================ FILE: share/man/man3/getpwent.3 ================================================ .\" Copyright (c) 1988 The Regents of the University of California. .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms are permitted .\" provided that the above copyright notice and this paragraph are .\" duplicated in all such forms and that any documentation, .\" advertising materials, and other materials related to such .\" distribution and use acknowledge that the software was developed .\" by the University of California, Berkeley. The name of the .\" University may not be used to endorse or promote products derived .\" from this software without specific prior written permission. .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR .\" IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED .\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. .\" .\" @(#)getpwent.3 6.5 (Berkeley) 2/23/89 .\" .TH GETPWENT 3 "February 23, 1989" .AT 3 .SH NAME getpwent, getpwnam, getpwuid, setpassent, setpwfile, setpwent, endpwent \- get password file entries .SH SYNOPSIS .nf .B #include .B #include .PP .B struct passwd *getpwent() .PP .B struct passwd *getpwnam(login) .B char *login; .PP .B struct passwd *getpwuid(uid) .B uid_t uid; .PP .B int setpassent(stayopen) .B int stayopen; .PP .B void setpwfile(file) .B char *file; .PP .B int setpwent() .PP .B void endpwent() .fi .SH DESCRIPTION .IR Getpwent , .IR getpwuid , and .I getpwnam each return a pointer to a structure containing the broken-out fields of a line in the password file. This structure is defined by the include file .IR < pwd.h > , and contains the following fields: .PP .RS .nf struct passwd { char *pw_name; /* user name */ char *pw_passwd; /* encrypted password */ uid_t pw_uid; /* user uid */ gid_t pw_gid; /* user gid */ time_t pw_change; /* password change time */ char *pw_class; /* user access class */ char *pw_gecos; /* Honeywell login info */ char *pw_dir; /* home directory */ char *pw_shell; /* default shell */ time_t pw_expire; /* account expiration */ }; .fi .RE .PP These fields are more completely described in .IR passwd (5). .PP .I Getpwnam and .I getpwuid search the password database for a matching user name or user uid, respectively, returning the first one encountered. Identical user names or user uids may result in undefined behavior. .PP .I Getpwent sequentially reads the password database and is intended for programs that wish to step through the complete list of users. .PP All three routines will open the password file for reading, if necessary. .PP .I Setpwfile changes the default password file to .IR file , thus allowing the use of alternate password files. .PP .I Setpassent opens the file or rewinds it if it is already open. If .I stayopen is non-zero, file descriptors are left open, significantly speeding up subsequent calls. This functionality is unnecessary for .I getpwent as it doesn't close its file descriptors by default. It should also be noted that it is dangerous for long-running programs to use this functionality as the password file may be updated by .IR chpass (1), .IR passwd (1), or .IR vipw (8). .PP .I Setpwent is identical to .I setpassent with an argument of zero. .PP .I Endpwent closes any open files. .PP These routines have been written to ``shadow'' the password file, e.g. allow only certain programs to have access to the encrypted password. This is done by using the .IR mkpasswd (8) program, which creates .IR ndbm (3) databases that correspond to the password file, with the single exception that, rather than storing the encrypted password in the database, it stores the offset in the password file where the encrypted password may be found. .IR Getpwent , .IR getpwnam , and .I getpwuid will use the .I ndbm files in preference to the ``real'' password files, only reading the password file itself, to obtain the encrypted password, if the process is running with an effective user id equivalent to super-user. If the password file itself is protected, and the .I ndbm files are not, this makes the password available only to programs running with super-user privileges. .SH FILES /etc/passwd .SH "SEE ALSO" getlogin(3), getgrent(3), ndbm(3), passwd(5) .SH DIAGNOSTICS The routines .IR getpwent , .IR getpwnam , and .IR getpwuid , return a null pointer on EOF or error. .I Setpassent and .I setpwent return 0 on failure and 1 on success. .I Endpwent and .I setpwfile have no return value. .SH BUGS All information is contained in a static buffer which is overwritten by each new call. It must be copied elsewhere to be retained. .PP Intermixing calls to .IR getpwent with calls to .I getpwnam or .IR getpwuid , or intermixing calls to .I getpwnam and .IR getpwuid , after using .I setpassent to require that file descriptors be left open, may result in undefined behavior. .PP The routines .IR getpwent , .IR endpwent , .IR setpassent , and .IR setpwent are fairly useless in a networked environment and should be avoided, if possible. ================================================ FILE: share/man/man3/gets.3 ================================================ .\" @(#)gets.3s 6.1 (Berkeley) 5/15/85 .\" .TH GETS 3S "May 15, 1985" .AT 3 .SH NAME gets, fgets \- get a string from a stream .SH SYNOPSIS .B #include .PP .B char *gets(s) .br .B char *s; .PP .B char *fgets(s, n, stream) .br .B char *s; .br .SM .B FILE .B *stream; .SH DESCRIPTION .I Gets reads a string into .I s from the standard input stream .BR stdin . The string is terminated by a newline character, which is replaced in .I s by a null character. .I Gets returns its argument. .PP .I Fgets reads .IR n \-1 characters, or up through a newline character, whichever comes first, from the .I stream into the string .IR s . The last character read into .I s is followed by a null character. .I Fgets returns its first argument. .SH "SEE ALSO" puts(3S), getc(3S), scanf(3S), fread(3S), ferror(3S) .SH DIAGNOSTICS .I Gets and .I fgets return the constant pointer .SM .B NULL upon end of file or error. .SH BUGS .I Gets deletes a newline, .I fgets keeps it, all in the name of backward compatibility. ================================================ FILE: share/man/man3/getservent.3 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)getservent.3n 6.3 (Berkeley) 5/19/86 .\" .TH GETSERVENT 3N "May 19, 1986" .UC 5 .SH NAME getservent, getservbyport, getservbyname, setservent, endservent \- get service entry .SH SYNOPSIS .nf .ft B #include .PP .ft B struct servent *getservent() .PP .ft B struct servent *getservbyname(name, proto) char *name, *proto; .PP .ft B struct servent *getservbyport(port, proto) int port; char *proto; .PP .ft B setservent(stayopen) int stayopen .PP .ft B endservent() .fi .SH DESCRIPTION .IR Getservent , .IR getservbyname , and .I getservbyport each return a pointer to an object with the following structure containing the broken-out fields of a line in the network services data base, .IR /etc/services . .RS .PP .nf struct servent { char *s_name; /* official name of service */ char **s_aliases; /* alias list */ int s_port; /* port service resides at */ char *s_proto; /* protocol to use */ }; .ft R .ad .fi .RE .PP The members of this structure are: .TP \w's_aliases'u+2n s_name The official name of the service. .TP \w's_aliases'u+2n s_aliases A zero terminated list of alternate names for the service. .TP \w's_aliases'u+2n s_port The port number at which the service resides. Port numbers are returned in network byte order. .TP \w's_aliases'u+2n s_proto The name of the protocol to use when contacting the service. .PP .I Getservent reads the next line of the file, opening the file if necessary. .PP .I Setservent opens and rewinds the file. If the .I stayopen flag is non-zero, the net data base will not be closed after each call to .I getservbyname or .IR getservbyport . .PP .I Endservent closes the file. .PP .I Getservbyname and .I getservbyport sequentially search from the beginning of the file until a matching protocol name or port number is found, or until EOF is encountered. If a protocol name is also supplied (non-NULL), searches must also match the protocol. .SH FILES /etc/services .SH "SEE ALSO" getprotoent(3N), services(5) .SH DIAGNOSTICS Null pointer (0) returned on EOF or error. .SH BUGS All information is contained in a static area so it must be copied if it is to be saved. Expecting port numbers to fit in a 32 bit quantity is probably naive. ================================================ FILE: share/man/man3/getsubopt.3 ================================================ .\" Copyright (c) 1990, 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. All advertising materials mentioning features or use of this software .\" must display the following acknowledgement: .\" This product includes software developed by the University of .\" California, Berkeley and its contributors. .\" 4. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)getsubopt.3 8.1.1 (2.11BSD) 1996/1/12 .\" .TH GETSUBOPT 3 "January 12, 1996" .UC 7 .SH NAME getsubopt \- get sub options from an argument .SH SYNOPSIS .ft B #include .sp extern char *suboptarg .sp int .br getsubopt(optionp, tokens, valuep) .br char **optionp; .br char **tokens; .br char **valuep; .br .ft .SH DESCRIPTION The .BR getsubopt () function parses a string containing tokens delimited by one or more tab, space or comma (`,') characters. It is intended for use in parsing groups of option arguments provided as part of a utility command line. .PP The argument .I optionp is a pointer to a pointer to the string. The argument .I tokens is a pointer to a \fBNULL\fP-terminated array of pointers to strings. .PP The .BR getsubopt () function returns the zero-based offset of the pointer in the .I tokens array referencing a string which matches the first token in the string, or, \-1 if the string contains no tokens or .I tokens does not contain a matching string. .PP If the token is of the form ``name=value'', the location referenced by .I valuep will be set to point to the start of the ``value'' portion of the token. .PP On return from .BR getsubopt (), .I optionp will be set to point to the start of the next token in the string, or the null at the end of the string if no more tokens are present. The external variable .I suboptarg will be set to point to the start of the current token, or .B NULL if no tokens were present. The argument .I valuep will be set to point to the ``value'' portion of the token, or .B NULL if no ``value'' portion was present. .SH EXAMPLE .nf .cs R 24 char *tokens[] = { #define ONE 0 "one", #define TWO 1 "two", NULL }; \&... extern char *optarg, *suboptarg; char *options, *value; while ((ch = getopt(argc, argv, "ab:")) != \-1) { switch(ch) { case 'a': /* process ``a'' option */ break; case 'b': options = optarg; while (*options) { switch(getsubopt(&options, tokens, &value)) { case ONE: /* process ``one'' sub option */ break; case TWO: /* process ``two'' sub option */ if (!value) error("no value for two"); i = atoi(value); break; case \-1: if (suboptarg) error("illegal sub option %s", suboptarg); else error("missing sub option"); break; } break; } .br .cs R .fi .SH SEE ALSO getopt(3), strsep(3) .SH HISTORY The .BR getsubopt () function first appeared in 4.4BSD. ================================================ FILE: share/man/man3/getttyent.3 ================================================ .\" Copyright (c) 1985 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)getttyent.3 6.4 (Berkeley) 5/20/86 .\" .TH GETTTYENT 3 "May 20, 1986" .UC 6 .SH NAME getttyent, getttynam, setttyent, endttyent \- get ttys file entry .SH SYNOPSIS .nf .B #include .PP .B struct ttyent *getttyent() .PP .B struct ttyent *getttynam(name) .B char *name; .PP .B setttyent() .PP .B endttyent() .fi .SH DESCRIPTION .I Getttyent, and .I getttynam each return a pointer to an object with the following structure containing the broken-out fields of a line from the tty description file. .RS .PP .nf .so /usr/include/ttyent.h .ft R .ad .fi .RE .PP .IP ty_name \w'ty_comment'u+3 is the name of the character-special file in the directory ``/dev". For various reasons, it must reside in the directory ``/dev". .IP ty_getty is the command (usually .IR getty (8)) which is invoked by .I init to initialize tty line characteristics. In fact, any arbitrary command can be used; a typical use is to initiate a terminal emulator in a window system. .IP ty_type is the name of the default terminal type connected to this tty line. This is typically a name from the .IR termcap (5) data base. The environment variable `TERM' is initialized with this name by .IR getty (8) or .IR login (1). .IP ty_status is a mask of bit fields which indicate various actions to be allowed on this tty line. The following is a description of each flag. .RS .IP TTY_ON \w'TTY_SECURE'u+3 Enables logins (i.e., .IR init (8) will start the specified ``getty" command on this entry). .IP TTY_SECURE Allows root to login on this terminal. Note that `TTY_ON' must be included for this to be useful. .RE .IP ty_window is the command to execute for a window system associated with the line. The window system will be started before the command specified in the .I ty_getty entry is executed. If none is specified, this will be null. .IP ty_comment is the trailing comment field, if any; a leading delimiter and white space will be removed. .PP .I Getttyent reads the next line from the ttys file, opening the file if necessary; .I setttyent rewinds the file; .I endttyent closes it. .PP .I Getttynam searches from the beginning of the file until a matching .I name is found (or until EOF is encountered). .SH FILES /etc/ttys .SH "SEE ALSO" login(1), ttyslot(3), ttys(5), gettytab(5), termcap(5), getty(8), init(8) .SH DIAGNOSTICS Null pointer (0) returned on EOF or error. .SH BUGS All information is contained in a static area so it must be copied if it is to be saved. ================================================ FILE: share/man/man3/getusershell.3 ================================================ .\" Copyright (c) 1985 The Regents of the University of California. .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms are permitted .\" provided that the above copyright notice and this paragraph are .\" duplicated in all such forms and that any documentation, .\" advertising materials, and other materials related to such .\" distribution and use acknowledge that the software was developed .\" by the University of California, Berkeley. The name of the .\" University may not be used to endorse or promote products derived .\" from this software without specific prior written permission. .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR .\" IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED .\" WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. .\" .\" @(#)getusershell.3 6.3 (Berkeley) 11/30/88 .\" .TH GETUSERSHELL 3 "November 30, 1988" .UC 6 .SH NAME getusershell, setusershell, endusershell \- get legal user shells .SH SYNOPSIS .nf .B char *getusershell() .PP .B setusershell() .PP .B endusershell() .fi .SH DESCRIPTION .I Getusershell returns a pointer to a legal user shell as defined by the system manager in the file .IR /etc/shells . If .I /etc/shells is unreadable or does not exist, .I getusershell behaves as if .I /bin/sh and .I /bin/csh were listed in the file. .PP .I Getusershell reads the next line (opening the file if necessary); .I setusershell rewinds the file; .I endusershell closes it. .SH FILES /etc/shells .SH "SEE ALSO" shells(5) .SH DIAGNOSTICS The routine .I getusershell returns a null pointer (0) on EOF. .SH BUGS All information is contained in a static area so it must be copied if it is to be saved. ================================================ FILE: share/man/man3/getwd.3 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)getwd.3 6.2 (Berkeley) 5/12/86 .\" .TH GETWD 3 "May 12, 1986" .UC 5 .SH NAME getwd \- get current working directory pathname .SH SYNOPSIS .nf .B char *getwd(pathname) .B char *pathname; .fi .SH DESCRIPTION .I Getwd copies the absolute pathname of the current working directory to .I pathname and returns a pointer to the result. .SH LIMITATIONS Maximum pathname length is MAXPATHLEN characters (1024), as defined in .I . .SH DIAGNOSTICS .I Getwd returns zero and places a message in .I pathname if an error occurs. ================================================ FILE: share/man/man3/hypot.3 ================================================ .\" Copyright (c) 1985 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)hypot.3m 6.5 (Berkeley) 5/12/86 .\" .TH HYPOT 3M "May 12, 1986" .UC 4 .ds up \fIulp\fR .ds nn \fINaN\fR .SH NAME hypot, cabs \- Euclidean distance, complex absolute value .SH SYNOPSIS .nf .B #include .PP .B double hypot(x,y) .B double x,y; .PP .B double cabs(z) .B struct {double x,y;} z; .fi .SH DESCRIPTION Hypot(x,y) and cabs(x,y) return sqrt(x\(**x+y\(**y) computed in such a way that underflow will not happen, and overflow occurs only if the final result deserves it. .PP .if n \ hypot(infinity,v) = hypot(v,infinity) = +infinity for all v, .if t \ hypot(\(if,v) = hypot(v,\(if) = +\(if for all v, including \*(nn. .SH ERROR (due to Roundoff, etc.) Below 0.97 \*(ups. Consequently hypot(5.0,12.0)\0=\013.0 exactly; in general, hypot and cabs return an integer whenever an integer might be expected. .PP The same cannot be said for the shorter and faster version of hypot and cabs that is provided in the comments in cabs.c; its error can exceed 1.2 \*(ups. .SH NOTES As might be expected, hypot(v,\*(nn) and hypot(\*(nn,v) are \*(nn for all \fIfinite\fR v; with "reserved operand" in place of "\*(nn", the same is true on a VAX. But programmers on machines other than a VAX (it has no .if n \ infinity) .if t \ \(if) might be surprised at first to discover that .if n \ hypot(\(+-infinity,\*(nn) = +infinity. .if t \ hypot(\(+-\(if,\*(nn) = +\(if. This is intentional; it happens because .if n \ hypot(infinity,v) = +infinity .if t \ hypot(\(if,v) = +\(if for \fIall\fR v, finite or infinite. Hence .if n \ hypot(infinity,v) .if t \ hypot(\(if,v) is independent of v. Unlike the reserved operand on a VAX, the IEEE \*(nn is designed to disappear when it turns out to be irrelevant, as it does in .if n \ hypot(infinity,\*(nn). .if t \ hypot(\(if,\*(nn). .SH SEE ALSO math(3M), sqrt(3M) .SH AUTHOR W. Kahan ================================================ FILE: share/man/man3/ieee.3 ================================================ .\" Copyright (c) 1985 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)ieee.3m 6.2 (Berkeley) 5/12/86 .\" .TH IEEE 3M "May 12, 1986" .UC 6 .ds nn \fINaN\fR .SH NAME copysign, drem, finite, logb, scalb \- copysign, remainder, exponent manipulations .SH SYNOPSIS .nf .B #include .PP .B double copysign(x,y) .B double x,y; .PP .B double drem(x,y) .B double x,y; .PP .B int finite(x) .B double x; .PP .B double logb(x) .B double x; .PP .B double scalb(x,n) .B double x; .B int n; .fi .SH DESCRIPTION These functions are required for, or recommended by the IEEE standard 754 for floating\-point arithmetic. .PP Copysign(x,y) returns x with its sign changed to y's. .PP Drem(x,y) returns the remainder r := x \- n\(**y where n is the integer nearest the exact value of x/y; moreover if |n\|\-\|x/y|\|=\|1/2 then n is even. Consequently the remainder is computed exactly and |r| \(<= |y|/2. But drem(x,0) is exceptional; see below under DIAGNOSTICS. .PP .nf .ta \w'Finite(x)'u+1n +\w'= 0 otherwise'u+1n .if n \ Finite(x) = 1 just when \-infinity < x < +infinity, .if t \ Finite(x) = 1 just when \-\(if < x < +\(if, .if n \ = 0 otherwise (when |x| = infinity or x is \*(nn or .if t \ = 0 otherwise (when |x| = \(if or x is \*(nn or \0x is the VAX's reserved operand.) .ta .fi .PP Logb(x) returns x's exponent n, a signed integer converted to double\-precision floating\-point and so chosen that 1\0\(<=\0|x|/2**n\0<\02 unless x = 0 or (only on machines that conform to IEEE 754) .if n \ |x| = infinity .if t \ |x| = \(if or x lies between 0 and the Underflow Threshold; see below under "BUGS". .PP Scalb(x,n) = x\(**(2**n) computed, for integer n, without first computing 2**n. .SH DIAGNOSTICS IEEE 754 defines drem(x,0) and .if n \ drem(infinity,y) .if t \ drem(\(if,y) to be invalid operations that produce a \*(nn. On a VAX, drem(x,0) returns the reserved operand. No .if n \ infinity .if t \ \(if exists on a VAX. .PP IEEE 754 defines .if n \ logb(\(+-infinity) = +infinity and logb(0) = \-infinity, .if t \ logb(\(+-\(if) = +\(if and logb(0) = \-\(if, and requires the latter to signal Division\-by\-Zero. But on a VAX, logb(0) = 1.0 \- 2.0**31 = \-2,147,483,647.0. And if the correct value of scalb(x,n) would overflow on a VAX, it returns the reserved operand and sets \fIerrno\fR to ERANGE. .SH SEE ALSO floor(3M), math(3M), infnan(3M) .SH AUTHOR Kwok\-Choi Ng .SH BUGS Should drem(x,0) and logb(0) on a VAX signal invalidity by setting \fIerrno\fR = EDOM? Should logb(0) return \-1.7e38? .PP IEEE 754 currently specifies that logb(denormalized no.) = logb(tiniest normalized no. > 0) but the consensus has changed to the specification in the new proposed IEEE standard p854, namely that logb(x) satisfy .RS 1 \(<= scalb(|x|,\-logb(x)) < Radix\0\0\0... = 2 for IEEE 754 .RE for every x except 0, .if n \ infinity .if t \ \(if and \*(nn. Almost every program that assumes 754's specification will work correctly if logb follows 854's specification instead. .PP IEEE 754 requires copysign(x,\*(nn) = \(+-x but says nothing else about the sign of a \*(nn. A \*(nn (\fIN\fRot \fIa\fR \fIN\fRumber) is similar in spirit to the VAX's reserved operand, but very different in important details. Since the sign bit of a reserved operand makes it look negative, .RS copysign(x,reserved operand) = \-x; .RE should this return the reserved operand instead? ================================================ FILE: share/man/man3/inet.3 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)inet.3n 6.4 (Berkeley) 5/27/86 .\" .TH INET 3N "May 27, 1986" .UC 5 .SH NAME inet_addr, inet_network, inet_ntoa, inet_makeaddr, inet_lnaof, inet_netof \- Internet address manipulation routines .SH SYNOPSIS .nf .B "#include .B "#include .B "#include .PP .B "unsigned long inet_addr(cp) .B "char *cp; .PP .B "unsigned long inet_network(cp) .B "char *cp; .PP .B "char *inet_ntoa(in) .B "struct in_addr in; .PP .B "struct in_addr inet_makeaddr(net, lna) .B "long net, lna;" .PP .B "long inet_lnaof(in) .B "struct in_addr in; .PP .B "long inet_netof(in) .B "struct in_addr in; .fi .SH DESCRIPTION The routines .I inet_addr and .I inet_network each interpret character strings representing numbers expressed in the Internet standard \*(lq.\*(rq notation, returning numbers suitable for use as Internet addresses and Internet network numbers, respectively. The routine .I inet_ntoa takes an Internet address and returns an ASCII string representing the address in \*(lq.\*(rq notation. The routine .I inet_makeaddr takes an Internet network number and a local network address and constructs an Internet address from it. The routines .I inet_netof and .I inet_lnaof break apart Internet host addresses, returning the network number and local network address part, respectively. .PP All Internet address are returned in network order (bytes ordered from left to right). All network numbers and local address parts are returned as machine format integer values. .SH "INTERNET ADDRESSES" Values specified using the \*(lq.\*(rq notation take one of the following forms: .RS .nf a.b.c.d a.b.c a.b a .RE .fi When four parts are specified, each is interpreted as a byte of data and assigned, from left to right, to the four bytes of an Internet address. Note that when an Internet address is viewed as a 32-bit integer quantity on the VAX the bytes referred to above appear as \*(lqd.c.b.a\*(rq. That is, VAX bytes are ordered from right to left. .PP When a three part address is specified, the last part is interpreted as a 16-bit quantity and placed in the right most two bytes of the network address. This makes the three part address format convenient for specifying Class B network addresses as \*(lq128.net.host\*(rq. .PP When a two part address is supplied, the last part is interpreted as a 24-bit quantity and placed in the right most three bytes of the network address. This makes the two part address format convenient for specifying Class A network addresses as \*(lqnet.host\*(rq. .PP When only one part is given, the value is stored directly in the network address without any byte rearrangement. .PP All numbers supplied as \*(lqparts\*(rq in a \*(lq.\*(rq notation may be decimal, octal, or hexadecimal, as specified in the C language (i.e., a leading 0x or 0X implies hexadecimal; otherwise, a leading 0 implies octal; otherwise, the number is interpreted as decimal). .SH "SEE ALSO" gethostbyname(3N), getnetent(3N), hosts(5), networks(5), .SH DIAGNOSTICS The value \-1 is returned by .I inet_addr and .I inet_network for malformed requests. .SH BUGS The problem of host byte ordering versus network byte ordering is confusing. A simple way to specify Class C network addresses in a manner similar to that for Class B and Class A is needed. The string returned by .I inet_ntoa resides in a static memory area. .br Inet_addr should return a struct in_addr. ================================================ FILE: share/man/man3/infnan.3 ================================================ .\" Copyright (c) 1985 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)infnan.3m 6.4 (Berkeley) 5/27/86 .\" .TH INFNAN 3M "May 27, 1986" .UC 6 .ds nn \fINaN\fR .SH NAME infnan \- signals invalid floating-point operations on a VAX (temporary) .SH SYNOPSIS .nf .B #include .PP .B double infnan(iarg) .B int iarg; .SH DESCRIPTION At some time in the future, some of the useful properties of the Infinities and \*(nns in the IEEE standard 754 for Binary Floating\-Point Arithmetic will be simulated in UNIX on the DEC VAX by using its Reserved Operands. Meanwhile, the Invalid, Overflow and Divide\-by\-Zero exceptions of the IEEE standard are being approximated on a VAX by calls to a procedure \fIinfnan\fR in appropriate places in \fIlibm\fR. When better exception\-handling is implemented in UNIX, only \fIinfnan\fR among the codes in \fIlibm\fR will have to be changed. And users of \fIlibm\fR can design their own \fIinfnan\fR now to insulate themselves from future changes. .PP Whenever an elementary function code in \fIlibm\fR has to simulate one of the aforementioned IEEE exceptions, it calls infnan(iarg) with an appropriate value of \fIiarg\fR. Then a reserved operand fault stops computation. But \fIinfnan\fR could be replaced by a function with the same name that returns some plausible value, assigns an apt value to the global variable \fIerrno\fR, and allows computation to resume. Alternatively, the Reserved Operand Fault Handler could be changed to respond by returning that plausible value, etc. instead of aborting. .PP In the table below, the first two columns show various exceptions signaled by the IEEE standard, and the default result it prescribes. The third column shows what value is given to \fIiarg\fR by functions in \fIlibm\fR when they invoke infnan(iarg) under analogous circumstances on a VAX. Currently \fIinfnan\fR stops computation under all those circumstances. The last two columns offer an alternative; they suggest a setting for \fIerrno\fR and a value for a revised \fIinfnan\fR to return. And a C program to implement that suggestion follows. .sp 0.5 .RS .nf .ta \w'Div\-by\-0'u+2n +\w'+Infinity'u+1n +\w'+ERANGE'u+1n +\w'ERANGE or EDOM'u+4n +\w'+HUGE'u+1n IEEE IEEE Signal Default \fIiarg\fR \fIerrno\fR \fIinfnan\fR .if t \{\ .sp -0.5 .ta \w'Div\-by\-0'u+2n+\w'+Infinity'u+1n+\w'+ERANGE'u+1n+\w'ERANGE or EDOM'u+4n+\w'+HUGE'u+1n .tc \(ru .ta \w'Div\-by\-0'u+2n +\w'+Infinity'u+1n +\w'+ERANGE'u+1n +\w'ERANGE or EDOM'u+4n +\w'+HUGE'u+1n .tc \} .if n \ \l'5i' Invalid \*(nn EDOM EDOM 0 .if n \{\ Overflow \(+-Infinity ERANGE ERANGE HUGE Div\-by\-0 \(+-Infinity \(+-ERANGE ERANGE or EDOM \(+-HUGE \} .if t \{\ Overflow \(+-\(if ERANGE ERANGE HUGE Div\-by\-0 \(+-\(if \(+-ERANGE ERANGE or EDOM \(+-HUGE \} .sp 0.5 (HUGE = 1.7e38 ... nearly 2.0**127) .ta .fi .RE .sp 0.5 .PP .nf .ta \w'\fBextern int\fR'u+1n +\w'\fBdefault:\fR'u+1n +\w'\fB\-ERANGE:\fR'u+1n +\w'\fBerrno = ERANGE;\fR'u+1n ALTERNATIVE \fIinfnan\fR:\fB .sp 0.5 #include #include extern int errno ; double infnan(iarg) int iarg ; { switch(iarg) { case \0ERANGE: errno = ERANGE; return(HUGE); case \-ERANGE: errno = EDOM; return(\-HUGE); default: errno = EDOM; return(0); } }\fR .ta .fi .SH SEE ALSO math(3M), intro(2), signal(3). .PP ERANGE and EDOM are defined in . See intro(2) for explanation of EDOM and ERANGE. ================================================ FILE: share/man/man3/initgroups.3 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)initgroups.3 6.2 (Berkeley) 5/12/86 .\" .TH INITGROUPS 3 "May 12, 1986" .UC 5 .SH NAME initgroups \- initialize group access list .SH SYNOPSIS .B initgroups(name, basegid) .br .B char *name; .br .B int basegid; .SH DESCRIPTION .I Initgroups reads through the group file and sets up, using the .IR setgroups (2) call, the group access list for the user specified in .IR name . The .I basegid is automatically included in the groups list. Typically this value is given as the group number from the password file. .SH FILES /etc/group .SH SEE ALSO setgroups(2) .SH DIAGNOSTICS .I Initgroups returns \-1 if it was not invoked by the super-user. .SH BUGS .I Initgroups uses the routines based on .IR getgrent (3). If the invoking program uses any of these routines, the group structure will be overwritten in the call to .IR initgroups . ================================================ FILE: share/man/man3/insque.3 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)insque.3 6.2 (Berkeley) 5/20/86 .\" .TH INSQUE 3 "May 20, 1986" .UC 5 .SH NAME insque, remque \- insert/remove element from a queue .SH SYNOPSIS .nf .DT .ft B struct qelem { struct qelem *q_forw; struct qelem *q_back; char q_data[]; }; .PP .ft B insque(elem, pred) struct qelem *elem, *pred; .PP .ft B remque(elem) struct qelem *elem; .ft R .SH DESCRIPTION .I Insque and .I remque manipulate queues built from doubly linked lists. Each element in the queue must in the form of ``struct qelem''. .I Insque inserts .I elem in a queue immediately after .IR pred ; .I remque removes an entry .I elem from a queue. .SH "SEE ALSO ``VAX Architecture Handbook'', pp. 228-235. ================================================ FILE: share/man/man3/intro.3 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)intro.3 6.8 (Berkeley) 5/27/86 .\" .TH INTRO 3 "May 27, 1986" .UC 4 .SH NAME intro \- introduction to C library functions .SH DESCRIPTION This section describes functions that may be found in various libraries. The library functions are those other than the functions which directly invoke UNIX system primitives, described in section 2. Most of these functions are accessible from the C library, .IR libc , which is automatically loaded by the C compiler .IR cc (1), and the Pascal compiler .IR pc (1). The link editor .IR ld (1) searches this library under the `\-lc' option. The C library also includes all the functions described in section 2. .PP A subset of these functions are available from Fortran; they are described separately in .IR intro (3F). .PP The functions described in this section are grouped into various sections: .TP (3) The straight ``3'' functions are the standard C library functions. .TP (3N) These functions constitute the internet network library. .TP (3S) These functions constitute the `standard I/O package', see .IR stdio (3S) for more details. Declarations for these functions may be obtained from the include file .RI < stdio.h >. .TP (3C) These routines are included for compatibility with other systems. In particular, a number of system call interfaces provided in previous releases of 4BSD have been included for source code compatibility. Use of these routines should, for the most part, be avoided. The manual page entry for each compatibility routine indicates the proper interface to use. .TP (3M) These functions constitute the math library, .IR libm . When functions in the math library (see .IR math (3M)) are passed values that are undefined or would generate answers that are out of range, they call the \fIinfnan\fP routine. By default this routine returns the VAX reserved floating point value which causes the process to get a floating point exception (see .IR sigvec (2)). Programs that wish to take other action should define their own version of \fIinfnan\fP (see .IR infnan (3M) for details). The math library is loaded as needed by the Pascal compiler .IR pc (1). C programs that wish to use this library need to specify the ``\-lm'' option. .TP (3X) These functions constitute minor libraries and other miscellaneous run-time facilities. Most are available only when programming in C. These functions include libraries that provide device independent plotting functions, terminal independent screen management routines for two dimensional non-bitmap display terminals, and functions for managing data bases with inverted indexes. These functions are located in separate libraries indicated in each manual entry. .SH FILES .nf /lib/libc.a the C library /usr/lib/libm.a the math library /usr/lib/libc_p.a the C library compiled for profiling /usr/lib/libm_p.a the math library compiled for profiling .fi .SH SEE ALSO stdio(3S), math(3M), intro(2), cc(1), ld(1), nm(1) .SH "LIST OF FUNCTIONS" .sp 2 .nf .ta \w'getprotobynumber'u+2n +\w'gethostbyname.3n'u+10n \fIName\fP \fIAppears on Page\fP \fIDescription\fP .ta \w'getprotobynumber'u+4n +\w'gethostbyname.3n'u+4n .sp 5p abort abort.3 generate a fault abs abs.3 integer absolute value acos sin.3m inverse trigonometric function acosh asinh.3m inverse hyperbolic function alarm alarm.3c schedule signal after specified time alloca malloc.3 memory allocator arc plot.3x graphics interface asctime ctime.3 convert date and time to ASCII asin sin.3m inverse trigonometric function asinh asinh.3m inverse hyperbolic function assert assert.3x program verification atan sin.3m inverse trigonometric function atanh asinh.3m inverse hyperbolic function atan2 sin.3m inverse trigonometric function atof atof.3 convert ASCII to numbers atoi atof.3 convert ASCII to numbers atol atof.3 convert ASCII to numbers bcmp bstring.3 bit and byte string operations bcopy bstring.3 bit and byte string operations bzero bstring.3 bit and byte string operations cabs hypot.3m complex absolute value calloc malloc.3 memory allocator cbrt sqrt.3m cube root ceil floor.3m integer no less than circle plot.3x graphics interface clearerr ferror.3s stream status inquiries closedir directory.3 directory operations closelog syslog.3 control system log closepl plot.3x graphics interface cont plot.3x graphics interface copysign ieee.3m copy sign bit cos sin.3m trigonometric function cosh sinh.3m hyperbolic function crypt crypt.3 DES encryption ctime ctime.3 convert date and time to ASCII curses curses.3x screen functions with ``optimal'' cursor motion dbminit dbm.3x data base subroutines delete dbm.3x data base subroutines drem ieee.3m remainder ecvt ecvt.3 output conversion edata end.3 last locations in program encrypt crypt.3 DES encryption end end.3 last locations in program endfsent getfsent.3x get file system descriptor file entry endgrent getgrent.3 get group file entry endhostent gethostbyname.3n get network host entry endnetent getnetent.3n get network entry endprotoent getprotoent.3n get protocol entry endpwent getpwent.3 get password file entry endservent getservent.3n get service entry environ execl.3 execute a file erase plot.3x graphics interface erf erf.3m error function erfc erf.3m complementary error function etext end.3 last locations in program exec execl.3 execute a file exece execl.3 execute a file execl execl.3 execute a file execle execl.3 execute a file execlp execl.3 execute a file exect execl.3 execute a file execv execl.3 execute a file execvp execl.3 execute a file exit exit.3 terminate a process after flushing any pending output exp exp.3m exponential expm1 exp.3m exp(x)\-1 fabs floor.3m absolute value fclose fclose.3s close or flush a stream fcvt ecvt.3 output conversion feof ferror.3s stream status inquiries ferror ferror.3s stream status inquiries fetch dbm.3x data base subroutines fflush fclose.3s close or flush a stream ffs bstring.3 bit and byte string operations fgetc getc.3s get character or word from stream fgets gets.3s get a string from a stream fileno ferror.3s stream status inquiries firstkey dbm.3x data base subroutines floor floor.3m integer no greater than fopen fopen.3s open a stream fprintf printf.3s formatted output conversion fputc putc.3s put character or word on a stream fputs puts.3s put a string on a stream fread fread.3s buffered binary input/output free malloc.3 memory allocator frexp frexp.3 split into mantissa and exponent fscanf scanf.3s formatted input conversion fseek fseek.3s reposition a stream ftell fseek.3s reposition a stream ftime time.3c get date and time fwrite fread.3s buffered binary input/output gcvt ecvt.3 output conversion getc getc.3s get character or word from stream getchar getc.3s get character or word from stream getdiskbyname getdisk.3x get disk description by its name getenv getenv.3 value for environment name getfsent getfsent.3x get file system descriptor file entry getfsfile getfsent.3x get file system descriptor file entry getfsspec getfsent.3x get file system descriptor file entry getfstype getfsent.3x get file system descriptor file entry getgrent getgrent.3 get group file entry getgrgid getgrent.3 get group file entry getgrnam getgrent.3 get group file entry gethostbyaddr gethostbyname.3n get network host entry gethostbyname gethostbyname.3n get network host entry gethostent gethostbyname.3n get network host entry getlogin getlogin.3 get login name getnetbyaddr getnetent.3n get network entry getnetbyname getnetent.3n get network entry getnetent getnetent.3n get network entry getpass getpass.3 read a password getprotobyname getprotoent.3n get protocol entry getprotobynumber getprotoent.3n get protocol entry getprotoent getprotoent.3n get protocol entry getpw getpw.3 get name from uid getpwent getpwent.3 get password file entry getpwnam getpwent.3 get password file entry getpwuid getpwent.3 get password file entry gets gets.3s get a string from a stream getservbyname getservent.3n get service entry getservbyport getservent.3n get service entry getservent getservent.3n get service entry getw getc.3s get character or word from stream getwd getwd.3 get current working directory pathname gmtime ctime.3 convert date and time to ASCII gtty stty.3c set and get terminal state (defunct) htonl byteorder.3n convert values between host and network byte order htons byteorder.3n convert values between host and network byte order hypot hypot.3m Euclidean distance index string.3 string operations inet_addr inet.3n Internet address manipulation routines inet_lnaof inet.3n Internet address manipulation routines inet_makeaddr inet.3n Internet address manipulation routines inet_netof inet.3n Internet address manipulation routines inet_network inet.3n Internet address manipulation routines infnan infnan.3m signals exceptions initgroups initgroups.3x initialize group access list initstate random.3 better random number generator insque insque.3 insert/remove element from a queue isalnum ctype.3 character classification macros isalpha ctype.3 character classification macros isascii ctype.3 character classification macros isatty ttyname.3 find name of a terminal iscntrl ctype.3 character classification macros isdigit ctype.3 character classification macros islower ctype.3 character classification macros isprint ctype.3 character classification macros ispunct ctype.3 character classification macros isspace ctype.3 character classification macros isupper ctype.3 character classification macros j0 j0.3m bessel function j1 j0.3m bessel function jn j0.3m bessel function label plot.3x graphics interface ldexp frexp.3 split into mantissa and exponent lgamma lgamma.3m log gamma function; (formerly gamma.3m) lib2648 lib2648.3x subroutines for the HP 2648 graphics terminal line plot.3x graphics interface linemod plot.3x graphics interface localtime ctime.3 convert date and time to ASCII log exp.3m natural logarithm logb ieee.3m exponent extraction log10 exp.3m logarithm to base 10 log1p exp.3m log(1+x) longjmp setjmp.3 non-local goto malloc malloc.3 memory allocator mktemp mktemp.3 make a unique file name modf frexp.3 split into mantissa and exponent moncontrol monitor.3 prepare execution profile monitor monitor.3 prepare execution profile monstartup monitor.3 prepare execution profile move plot.3x graphics interface nextkey dbm.3x data base subroutines nice nice.3c set program priority nlist nlist.3 get entries from name list ntohl byteorder.3n convert values between host and network byte order ntohs byteorder.3n convert values between host and network byte order opendir directory.3 directory operations openlog syslog.3 control system log openpl plot.3x graphics interface pause pause.3c stop until signal pclose popen.3 initiate I/O to/from a process perror perror.3 system error messages point plot.3x graphics interface popen popen.3 initiate I/O to/from a process pow exp.3m exponential x**y printf printf.3s formatted output conversion psignal psignal.3 system signal messages putc putc.3s put character or word on a stream putchar putc.3s put character or word on a stream puts puts.3s put a string on a stream putw putc.3s put character or word on a stream qsort qsort.3 quicker sort rand rand.3c random number generator random random.3 better random number generator rcmd rcmd.3x routines for returning a stream to a remote command re_comp regex.3 regular expression handler re_exec regex.3 regular expression handler readdir directory.3 directory operations realloc malloc.3 memory allocator remque insque.3 insert/remove element from a queue rewind fseek.3s reposition a stream rewinddir directory.3 directory operations rexec rexec.3x return stream to a remote command rindex string.3 string operations rint floor.3m round to nearest integer rresvport rcmd.3x routines for returning a stream to a remote command ruserok rcmd.3x routines for returning a stream to a remote command scalb ieee.3m exponent adjustment scandir scandir.3 scan a directory scanf scanf.3s formatted input conversion seekdir directory.3 directory operations setbuf setbuf.3s assign buffering to a stream setbuffer setbuf.3s assign buffering to a stream setegid setuid.3 set user and group ID seteuid setuid.3 set user and group ID setfsent getfsent.3x get file system descriptor file entry setgid setuid.3 set user and group ID setgrent getgrent.3 get group file entry sethostent gethostbyname.3n get network host entry setjmp setjmp.3 non-local goto setkey crypt.3 DES encryption setlinebuf setbuf.3s assign buffering to a stream setnetent getnetent.3n get network entry setprotoent getprotoent.3n get protocol entry setpwent getpwent.3 get password file entry setrgid setuid.3 set user and group ID setruid setuid.3 set user and group ID setservent getservent.3n get service entry setstate random.3 better random number generator setuid setuid.3 set user and group ID signal signal.3 simplified software signal facilities sin sin.3m trigonometric function sinh sinh.3m hyperbolic function sleep sleep.3 suspend execution for interval space plot.3x graphics interface sprintf printf.3s formatted output conversion sqrt sqrt.3m square root srand rand.3c random number generator srandom random.3 better random number generator sscanf scanf.3s formatted input conversion stdio intro.3s standard buffered input/output package store dbm.3x data base subroutines strcat string.3 string operations strcmp string.3 string operations strcpy string.3 string operations strlen string.3 string operations strncat string.3 string operations strncmp string.3 string operations strncpy string.3 string operations stty stty.3c set and get terminal state (defunct) swab swab.3 swap bytes sys_errlist perror.3 system error messages sys_nerr perror.3 system error messages sys_siglist psignal.3 system signal messages syslog syslog.3 control system log system system.3 issue a shell command tan sin.3m trigonometric function tanh sinh.3m hyperbolic function telldir directory.3 directory operations tgetent termcap.3x terminal independent operation routines tgetflag termcap.3x terminal independent operation routines tgetnum termcap.3x terminal independent operation routines tgetstr termcap.3x terminal independent operation routines tgoto termcap.3x terminal independent operation routines time time.3c get date and time times times.3c get process times timezone ctime.3 convert date and time to ASCII tputs termcap.3x terminal independent operation routines ttyname ttyname.3 find name of a terminal ttyslot ttyname.3 find name of a terminal ungetc ungetc.3s push character back into input stream utime utime.3c set file times valloc valloc.3 aligned memory allocator varargs varargs.3 variable argument list vlimit vlimit.3c control maximum system resource consumption vtimes vtimes.3c get information about resource utilization y0 j0.3m bessel function y1 j0.3m bessel function yn j0.3m bessel function .fi ================================================ FILE: share/man/man3/j0.3 ================================================ .\" Copyright (c) 1985 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)j0.3m 6.6 (Berkeley) 5/12/86 .\" .TH J0 3M "May 12, 1986" .UC 4 .SH NAME j0, j1, jn, y0, y1, yn \- bessel functions .SH SYNOPSIS .nf .B #include .PP .B double j0(x) .B double x; .PP .B double j1(x) .B double x; .PP .B double jn(n,x) .B int n; .B double x; .PP .B double y0(x) .B double x; .PP .B double y1(x) .B double x; .PP .B double yn(n,x) .B int n; .B double x; .fi .SH DESCRIPTION These functions calculate Bessel functions of the first and second kinds for real arguments and integer orders. .SH DIAGNOSTICS On a VAX, negative arguments cause y0, y1 and yn to return the reserved operand and set \fIerrno\fR to EDOM. .SH SEE ALSO math(3M), infnan(3M) ================================================ FILE: share/man/man3/l3tol.3 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)l3tol.3 2.3 (Berkeley) 1/22/87 .\" .TH L3TOL 3 "January 22, 1987" .UC 2 .SH NAME l3tol, ltol3 \- convert between 3-byte and long integers (2BSD) .SH SYNOPSIS .nf .ft B l3tol(lp, cp, n) long *lp; char *cp; ltol3(cp, lp, n) char *cp; long *lp; .fi .ft R .SH DESCRIPTION .I L3tol converts a list of .I n three-byte integers packed into a character string pointed to by .I cp into a list of long integers pointed to by .IR lp . .PP .I Ltol3 performs the inverse conversion from long integers .RI ( lp ) to three-byte integers .RI ( cp ). .PP These functions are useful for file-system maintenance under 2BSD where disk addresses within inodes are three bytes long. .SH SEE ALSO fs(5) .SH BUGS .IR l3tol " and " ltol3 are unique to the PDP-11 and 2BSD; their use is discouraged. ================================================ FILE: share/man/man3/ldfps.3 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)ldfps.3 1.1 (Berkeley) 8/10/88 .\" .TH LDFPS 3 "August 10, 1988" .UC 2 .SH NAME ldfps \- load floating point status register .SH SYNOPSIS .nf .ft B void ldfps(fps) unsigned int fps; .ft P .fi .SH DESCRIPTION .I Ldfps loads the hardware floating point status register with .IR fps . See the PDP-11 hardware handbook for a description of the meaning of the various bits in .IR fps . .SH BUGS .I Ldfps is unique to the PDP-11 and 2BSD; its use is discouraged. ================================================ FILE: share/man/man3/lgamma.3 ================================================ .\" Copyright (c) 1985 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)lgamma.3m 6.2 (Berkeley) 5/12/86 .\" .TH LGAMMA 3M "May 12, 1986" .UC 6 .SH NAME lgamma \- log gamma function .SH SYNOPSIS .nf .B #include .PP .B double lgamma(x) .B double x; .fi .SH DESCRIPTION .nf .ta \w'Lgamma returns ln\||\(*G(x)| where'u+1n +1.7i .if t \{\ Lgamma returns ln\||\(*G(x)| where \(*G(x) = \(is\d\s8\z0\s10\u\u\s8\(if\s10\d t\u\s8x\-1\s10\d e\u\s8\-t\s10\d dt for x > 0 and .br \(*G(x) = \(*p/(\(*G(1\-x)\|sin(\(*px)) for x < 1. \} .if n \ Lgamma returns ln\||\(*G(x)|. .ta .fi .PP The external integer signgam returns the sign of \(*G(x) . .SH IDIOSYNCRASIES Do \fBnot\fR use the expression signgam\(**exp(lgamma(x)) to compute g := \(*G(x). Instead use a program like this (in C): .RS lg = lgamma(x); g = signgam\(**exp(lg); .RE .PP Only after lgamma has returned can signgam be correct. Note too that \(*G(x) must overflow when x is large enough, underflow when \-x is large enough, and spawn a division by zero when x is a nonpositive integer. .PP Only in the UNIX math library for C was the name gamma ever attached to ln\(*G. Elsewhere, for instance in IBM's FORTRAN library, the name GAMMA belongs to \(*G and the name ALGAMA to ln\(*G in single precision; in double the names are DGAMMA and DLGAMA. Why should C be different? .PP Archaeological records suggest that C's gamma originally delivered ln(\(*G(|x|)). Later, the program gamma was changed to cope with negative arguments x in a more conventional way, but the documentation did not reflect that change correctly. The most recent change corrects inaccurate values when x is almost a negative integer, and lets \(*G(x) be computed without conditional expressions. Programmers should not assume that lgamma has settled down. .PP At some time in the future, the name \fIgamma\fR will be rehabilitated and used for the gamma function, just as is done in FORTRAN. The reason for this is not so much compatibility with FORTRAN as a desire to achieve greater speed for smaller values of |x| and greater accuracy for larger values. .PP Meanwhile, programmers who have to use the name \fIgamma\fR in its former sense, for what is now \fIlgamma\fR, have two choices: .IP 1) \w'1)\0'u Use the old math library, \fIlibom\fR. .IP 2) \w'1)\0'u Add the following program to your others: .RS .nf \fB#include double gamma(x) double x; { .RS \fBreturn (lgamma(x)); .RE }\fR .RE .fi .SH DIAGNOSTICS The reserved operand is returned on a VAX for negative integer arguments, \fIerrno\fR is set to ERANGE; for very large arguments over/underflows will occur inside the \fIlgamma\fP routine. .SH SEE ALSO math(3M), infnan(3M) ================================================ FILE: share/man/man3/lib2648.3 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)lib2648.3x 6.2 (Berkeley) 5/27/86 .\" .TH LIB2648 3X "May 27, 1986" .UC 5 .SH NAME lib2648 \- subroutines for the HP 2648 graphics terminal .SH SYNOPSIS .B #include .sp .B "typedef char" .RB * bitmat ; .br FILE *trace; .sp cc file.c .B \-l2648 .SH DESCRIPTION .I Lib2648 is a general purpose library of subroutines useful for interactive graphics on the Hewlett-Packard 2648 graphics terminal. To use it you must call the routine .IR ttyinit () at the beginning of execution, and .IR done () at the end of execution. All terminal input and output must go through the routines .IR rawchar , .IR readline , .IR outchar , and .IR outstr . .PP .I Lib2648 does the necessary ^E/^F handshaking if .I "getenv(``TERM'')" returns ``hp2648'', as it will if set by .IR tset (1). Any other value, including for example ``2648'', will disable handshaking. .PP Bit matrix routines are provided to model the graphics memory of the 2648. These routines are generally useful, but are specifically useful for the .I update function which efficiently changes what is on the screen to what is supposed to be on the screen. The primative bit matrix routines are .IR newmat , .IR mat , and .IR setmat . .PP The file .IR trace , if non-null, is expected to be a file descriptor as returned by .IR fopen . If so, .I lib2648 will trace the progress of the output by writing onto this file. It is provided to make debugging output feasible for graphics programs without messing up the screen or the escape sequences being sent. Typical use of trace will include: .nf \fBswitch\fP (argv[1][1]) { \fBcase\fP 'T': trace = fopen("trace", "w"); \fBbreak\fP; ... \fBif\fP (trace) fprintf(trace, "x is %d, y is %s\en", x, y); ... dumpmat("before update", xmat); .fi .SH ROUTINES .TP .B agoto(x, y) Move the alphanumeric cursor to position (x, y), measured from the upper left corner of the screen. .TP .B aoff() Turn the alphanumeric display off. .TP .B aon() Turn the alphanumeric display on. .TP .B areaclear(rmin, cmin, rmax, cmax) Clear the area on the graphics screen bordered by the four arguments. In normal mode the area is set to all black, in inverse video mode it is set to all white. .TP .B beep() Ring the bell on the terminal. .TP .B bitcopy(dest, src, rows, cols) bitmat dest, src; Copy a .I rows by .I cols bit matrix from .I src to (user provided) .I dest. .TP .B cleara() Clear the alphanumeric display. .TP .B clearg() Clear the graphics display. Note that the 2648 will only clear the part of the screen that is visible if zoomed in. .TP .B curoff() Turn the graphics cursor off. .TP .B curon() Turn the graphics cursor on. .TP .B dispmsg(str, x, y, maxlen) char *str; Display the message .I str in graphics text at position .I (x, y). The maximum message length is given by .IR maxlen , and is needed for dispmsg to know how big an area to clear before drawing the message. The lower left corner of the first character is at .I (x, y). .TP .B done() Should be called before the program exits. Restores the tty to normal, turns off graphics screen, turns on alphanumeric screen, flushes the standard output, etc. .TP .B draw(x, y) Draw a line from the pen location to .I (x, y). As with all graphics coordinates, .I (x, y) is measured from the bottom left corner of the screen. .I (x, y) coordinates represent the first quadrant of the usual Cartesian system. .TP .B drawbox(r, c, color, rows, cols) Draw a rectangular box on the graphics screen. The lower left corner is at location .I (r, c). The box is .I rows rows high and .I cols columns wide. The box is drawn if .I color is 1, erased if .I color is 0. .I (r, c) absolute coordinates represent row and column on the screen, with the origin at the lower left. They are equivalent to .I (x, y) except for being reversed in order. .TP .B "dumpmat(msg, m, rows, cols) char *msg; bitmat m;" If .I trace is non-null, write a readable ASCII representation of the matrix .I m on .I trace. .I Msg is a label to identify the output. .TP .B emptyrow(m, rows, cols, r) bitmat m; Returns 1 if row .I r of matrix .I m is all zero, else returns 0. This routine is provided because it can be implemented more efficiently with a knowledge of the internal representation than a series of calls to .I mat. .TP .B error(msg) char *msg; Default error handler. Calls .I message(msg) and returns. This is called by certain routines in .IR lib2648 . It is also suitable for calling by the user program. It is probably a good idea for a fancy graphics program to supply its own error procedure which uses .IR setjmp (3) to restart the program. .TP .B gdefault() Set the terminal to the default graphics modes. .TP .B goff() Turn the graphics display off. .TP .B gon() Turn the graphics display on. .TP .B koff() Turn the keypad off. .TP .B kon() Turn the keypad on. This means that most special keys on the terminal (such as the alphanumeric arrow keys) will transmit an escape sequence instead of doing their function locally. .TP .B line(x1, y1, x2, y2) Draw a line in the current mode from .I (x1, y1) to .I (x2, y2). This is equivalent to .I "move(x1, y1); draw(x2, y2);" except that a bug in the terminal involving repeated lines from the same point is compensated for. .TP .B lowleft() Move the alphanumeric cursor to the lower left (home down) position. .TP .B "mat(m, rows, cols, r, c) bitmat m;" Used to retrieve an element from a bit matrix. Returns 1 or 0 as the value of the .I [r, c] element of the .I rows by .I cols matrix .I m. Bit matrices are numbered .I (r, c) from the upper left corner of the matrix, beginning at (0, 0). .I R represents the row, and .I c represents the column. .TP .B message(str) char *str; Display the text message .I str at the bottom of the graphics screen. .TP .B "minmax(g, rows, cols, rmin, cmin, rmax, cmax) bitmat g;" .ti -.5i .B int *rmin, *cmin, *rmax, *cmax; .br Find the smallest rectangle that contains all the 1 (on) elements in the bit matrix g. The coordinates are returned in the variables pointed to by rmin, cmin, rmax, cmax. .TP .B move(x, y) Move the pen to location .I (x, y). Such motion is internal and will not cause output until a subsequent .I sync(). .TP .B movecurs(x, y) Move the graphics cursor to location .I (x, y). .TP .B bitmat newmat(rows, cols) Create (with .IR malloc (3)) a new bit matrix of size .I rows by .I cols. The value created (e.g. a pointer to the first location) is returned. A bit matrix can be freed directly with .IR free . .TP .B outchar(c) char c; Print the character .I c on the standard output. All output to the terminal should go through this routine or .IR outstr . .TP .B outstr(str) char *str; Print the string str on the standard output by repeated calls to .I outchar. .TP .B printg() Print the graphics display on the printer. The printer must be configured as device 6 (the default) on the HPIB. .TP .B char rawchar() Read one character from the terminal and return it. This routine or .I readline should be used to get all input, rather than .IR getchar (3). .TP .B rboff() Turn the rubber band line off. .TP .B rbon() Turn the rubber band line on. .TP .B char *rdchar(c) char c; Return a readable representation of the character .I c. If .I c is a printing character it returns itself, if a control character it is shown in the ^X notation, if negative an apostrophe is prepended. Space returns ^\`, rubout returns ^?. .IP .B NOTE: A pointer to a static place is returned. For this reason, it will not work to pass rdchar twice to the same .IR fprintf / sprintf call. You must instead save one of the values in your own buffer with strcpy. .TP .B readline(prompt, msg, maxlen) char *prompt, *msg; Display .I prompt on the bottom line of the graphics display and read one line of text from the user, terminated by a newline. The line is placed in the buffer .IR msg , which has size .I maxlen characters. Backspace processing is supported. .TP .B setclear() Set the display to draw lines in erase mode. (This is reversed by inverse video mode.) .TP .B "setmat(m, rows, cols, r, c, val) bitmat m;" The basic operation to store a value in an element of a bit matrix. The .I [r, c] element of .I m is set to .I val, which should be either 0 or 1. .TP .B setset() Set the display to draw lines in normal (solid) mode. (This is reversed by inverse video mode.) .TP .B setxor() Set the display to draw lines in exclusive or mode. .TP .B sync() Force all accumulated output to be displayed on the screen. This should be followed by fflush(stdout). The cursor is not affected by this function. Note that it is normally never necessary to call .IR sync , since .I rawchar and .I readline call .I sync() and .I fflush(stdout) automatically. .TP .B togvid() Toggle the state of video. If in normal mode, go into inverse video mode, and vice versa. The screen is reversed as well as the internal state of the library. .TP .B ttyinit() Set up the terminal for processing. This routine should be called at the beginning of execution. It places the terminal in CBREAK mode, turns off echo, sets the proper modes in the terminal, and initializes the library. .TP .B "update(mold, mnew, rows, cols, baser, basec) bitmat mold, mnew;" Make whatever changes are needed to make a window on the screen look like .IR mnew . .I Mold is what the window on the screen currently looks like. The window has size .I rows by .IR cols , and the lower left corner on the screen of the window is .I [baser, basec]. Note: .I update was not intended to be used for the entire screen. It would work but be very slow and take 64K bytes of memory just for mold and mnew. It was intended for 100 by 100 windows with objects in the center of them, and is quite fast for such windows. .TP .B vidinv() Set inverse video mode. .TP .B vidnorm() Set normal video mode. .TP .B zermat(m, rows, cols) bitmat m; Set the bit matrix .I m to all zeros. .TP .B zoomn(size) Set the hardware zoom to value .I size, which can range from 1 to 15. .TP .B zoomoff() Turn zoom off. This forces the screen to zoom level 1 without affecting the current internal zoom number. .TP .B zoomon() Turn zoom on. This restores the screen to the previously specified zoom size. .SH DIAGNOSTICS The routine .I error is called when an error is detected. The only error currently detected is overflow of the buffer provided to .IR readline . .PP Subscripts out of bounds to .I setmat return without setting anything. .SH FILES /usr/lib/lib2648.a .SH "SEE ALSO" fed(1) .SH AUTHOR Mark Horton .SH BUGS This library is not supported. It makes no attempt to use all of the features of the terminal, only those needed by fed. Contributions from users will be accepted for addition to the library. .PP The HP 2648 terminal is somewhat unreliable at speeds over 2400 baud, even with the ^E/^F handshaking. In an effort to improve reliability, handshaking is done every 32 characters. (The manual claims it is only necessary every 80 characters.) Nonetheless, I/O errors sometimes still occur. .PP There is no way to control the amount of debugging output generated on .I trace without modifying the source to the library. ================================================ FILE: share/man/man3/malloc.3 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)malloc.3 6.3 (Berkeley) 5/14/86 .\" .TH MALLOC 3 "May 14, 1986" .UC 4 .SH NAME malloc, free, realloc, calloc, alloca \- memory allocator .SH SYNOPSIS .nf .B char *malloc(size) .B unsigned size; .PP .B free(ptr) .B char *ptr; .PP .B char *realloc(ptr, size) .B char *ptr; .B unsigned size; .PP .B char *calloc(nelem, elsize) .B unsigned nelem, elsize; .PP .B char *alloca(size) .B int size; .fi .SH DESCRIPTION .I Malloc and .I free provide a general-purpose memory allocation package. .I Malloc returns a pointer to a block of at least .I size bytes beginning on a word boundary. .PP The argument to .I free is a pointer to a block previously allocated by .IR malloc ; this space is made available for further allocation, but its contents are left undisturbed. .PP Needless to say, grave disorder will result if the space assigned by .I malloc is overrun or if some random number is handed to .IR free . .PP .I Malloc maintains multiple lists of free blocks according to size, allocating space from the appropriate list. It calls .I sbrk (see .IR brk (2)) to get more memory from the system when there is no suitable space already free. .PP .I Realloc changes the size of the block pointed to by .I ptr to .I size bytes and returns a pointer to the (possibly moved) block. The contents will be unchanged up to the lesser of the new and old sizes. .PP In order to be compatible with older versions, .I realloc also works if .I ptr points to a block freed since the last call of .I malloc, realloc or .IR calloc ; sequences of .I free, malloc and .I realloc were previously used to attempt storage compaction. This procedure is no longer recommended. .PP .I Calloc allocates space for an array of .I nelem elements of size .I elsize. The space is initialized to zeros. .PP .I Alloca allocates .I size bytes of space in the stack frame of the caller. This temporary space is automatically freed on return. .PP Each of the allocation routines returns a pointer to space suitably aligned (after possible pointer coercion) for storage of any type of object. If the space is of .I pagesize or larger, the memory returned will be page-aligned. .SH SEE ALSO brk(2), pagesize(2) .SH DIAGNOSTICS .I Malloc, realloc and .I calloc return a null pointer (0) if there is no available memory or if the arena has been detectably corrupted by storing outside the bounds of a block. .I Malloc may be recompiled to check the arena very stringently on every transaction; those sites with a source code license may check the source code to see how this can be done. .SH BUGS When .I realloc returns 0, the block pointed to by .I ptr may be destroyed. .PP The current implementation of .I malloc does not always fail gracefully when system memory limits are approached. It may fail to allocate memory when larger free blocks could be broken up, or when limits are exceeded because the size is rounded up. It is optimized for sizes that are powers of two. .PP .I Alloca is machine dependent; its use is discouraged. ================================================ FILE: share/man/man3/math.3 ================================================ .\" Copyright (c) 1985 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)math.3m 6.8 (Berkeley) 5/27/86 .\" .TH MATH 3M "May 27, 1986" .UC 4 .ds up \fIulp\fR .ds nn \fINaN\fR .de If .if n \\ \\$1Infinity\\$2 .if t \\ \\$1\\(if\\$2 .. .SH NAME math \- introduction to mathematical library functions .SH DESCRIPTION These functions constitute the C math library, .I libm. The link editor searches this library under the \*(lq\-lm\*(rq option. Declarations for these functions may be obtained from the include file .RI < math.h >. The Fortran math library is described in ``man 3f intro''. .SH "LIST OF FUNCTIONS" .sp 2 .nf .ta \w'copysign'u+2n +\w'infnan.3m'u+10n +\w'inverse trigonometric func'u \fIName\fP \fIAppears on Page\fP \fIDescription\fP \fIError Bound (ULPs)\fP .ta \w'copysign'u+4n +\w'infnan.3m'u+4n +\w'inverse trigonometric function'u+6nC .sp 5p acos sin.3m inverse trigonometric function 3 acosh asinh.3m inverse hyperbolic function 3 asin sin.3m inverse trigonometric function 3 asinh asinh.3m inverse hyperbolic function 3 atan sin.3m inverse trigonometric function 1 atanh asinh.3m inverse hyperbolic function 3 atan2 sin.3m inverse trigonometric function 2 cabs hypot.3m complex absolute value 1 cbrt sqrt.3m cube root 1 ceil floor.3m integer no less than 0 copysign ieee.3m copy sign bit 0 cos sin.3m trigonometric function 1 cosh sinh.3m hyperbolic function 3 drem ieee.3m remainder 0 erf erf.3m error function ??? erfc erf.3m complementary error function ??? exp exp.3m exponential 1 expm1 exp.3m exp(x)\-1 1 fabs floor.3m absolute value 0 floor floor.3m integer no greater than 0 hypot hypot.3m Euclidean distance 1 infnan infnan.3m signals exceptions j0 j0.3m bessel function ??? j1 j0.3m bessel function ??? jn j0.3m bessel function ??? lgamma lgamma.3m log gamma function; (formerly gamma.3m) log exp.3m natural logarithm 1 logb ieee.3m exponent extraction 0 log10 exp.3m logarithm to base 10 3 log1p exp.3m log(1+x) 1 pow exp.3m exponential x**y 60\-500 rint floor.3m round to nearest integer 0 scalb ieee.3m exponent adjustment 0 sin sin.3m trigonometric function 1 sinh sinh.3m hyperbolic function 3 sqrt sqrt.3m square root 1 tan sin.3m trigonometric function 3 tanh sinh.3m hyperbolic function 3 y0 j0.3m bessel function ??? y1 j0.3m bessel function ??? yn j0.3m bessel function ??? .ta .fi .SH NOTES In 4.3 BSD, distributed from the University of California in late 1985, most of the foregoing functions come in two versions, one for the double\-precision "D" format in the DEC VAX\-11 family of computers, another for double\-precision arithmetic conforming to the IEEE Standard 754 for Binary Floating\-Point Arithmetic. The two versions behave very similarly, as should be expected from programs more accurate and robust than was the norm when UNIX was born. For instance, the programs are accurate to within the numbers of \*(ups tabulated above; an \*(up is one \fIU\fRnit in the \fIL\fRast \fIP\fRlace. And the programs have been cured of anomalies that afflicted the older math library \fIlibm\fR in which incidents like the following had been reported: .RS sqrt(\-1.0) = 0.0 and log(\-1.0) = \-1.7e38. .br cos(1.0e\-11) > cos(0.0) > 1.0. .br pow(x,1.0) .if n \ != .if t \ \(!= x when x = 2.0, 3.0, 4.0, ..., 9.0. .br pow(\-1.0,1.0e10) trapped on Integer Overflow. .br sqrt(1.0e30) and sqrt(1.0e\-30) were very slow. .RE However the two versions do differ in ways that have to be explained, to which end the following notes are provided. .PP \fBDEC VAX\-11 D_floating\-point:\fR .PP This is the format for which the original math library \fIlibm\fR was developed, and to which this manual is still principally dedicated. It is \fIthe\fR double\-precision format for the PDP\-11 and the earlier VAX\-11 machines; VAX\-11s after 1983 were provided with an optional "G" format closer to the IEEE double\-precision format. The earlier DEC MicroVAXs have no D format, only G double\-precision. (Why? Why not?) .PP Properties of D_floating\-point: .RS Wordsize: 64 bits, 8 bytes. Radix: Binary. .br Precision: 56 .if n \ sig. .if t \ significant bits, roughly like 17 .if n \ sig. .if t \ significant decimals. .RS If x and x' are consecutive positive D_floating\-point numbers (they differ by 1 \*(up), then .br 1.3e\-17 < 0.5**56 < (x'\-x)/x \(<= 0.5**55 < 2.8e\-17. .RE .nf .ta \w'Range:'u+1n +\w'Underflow threshold'u+1n +\w'= 2.0**127'u+1n Range: Overflow threshold = 2.0**127 = 1.7e38. Underflow threshold = 0.5**128 = 2.9e\-39. NOTE: THIS RANGE IS COMPARATIVELY NARROW. .ta .fi .RS Overflow customarily stops computation. .br Underflow is customarily flushed quietly to zero. .br CAUTION: .RS It is possible to have x .if n \ != .if t \ \(!= y and yet x\-y = 0 because of underflow. Similarly x > y > 0 cannot prevent either x\(**y = 0 or y/x = 0 from happening without warning. .RE .RE Zero is represented ambiguously. .RS Although 2**55 different representations of zero are accepted by the hardware, only the obvious representation is ever produced. There is no \-0 on a VAX. .RE .If is not part of the VAX architecture. .br Reserved operands: .RS of the 2**55 that the hardware recognizes, only one of them is ever produced. Any floating\-point operation upon a reserved operand, even a MOVF or MOVD, customarily stops computation, so they are not much used. .RE Exceptions: .RS Divisions by zero and operations that overflow are invalid operations that customarily stop computation or, in earlier machines, produce reserved operands that will stop computation. .RE Rounding: .RS Every rational operation (+, \-, \(**, /) on a VAX (but not necessarily on a PDP\-11), if not an over/underflow nor division by zero, is rounded to within half an \*(up, and when the rounding error is exactly half an \*(up then rounding is away from 0. .RE .RE .PP Except for its narrow range, D_floating\-point is one of the better computer arithmetics designed in the 1960's. Its properties are reflected fairly faithfully in the elementary functions for a VAX distributed in 4.3 BSD. They over/underflow only if their results have to lie out of range or very nearly so, and then they behave much as any rational arithmetic operation that over/underflowed would behave. Similarly, expressions like log(0) and atanh(1) behave like 1/0; and sqrt(\-3) and acos(3) behave like 0/0; they all produce reserved operands and/or stop computation! The situation is described in more detail in manual pages. .RS .ll -0.5i \fIThis response seems excessively punitive, so it is destined to be replaced at some time in the foreseeable future by a more flexible but still uniform scheme being developed to handle all floating\-point arithmetic exceptions neatly. See infnan(3M) for the present state of affairs.\fR .ll +0.5i .RE .PP How do the functions in 4.3 BSD's new \fIlibm\fR for UNIX compare with their counterparts in DEC's VAX/VMS library? Some of the VMS functions are a little faster, some are a little more accurate, some are more puritanical about exceptions (like pow(0.0,0.0) and atan2(0.0,0.0)), and most occupy much more memory than their counterparts in \fIlibm\fR. The VMS codes interpolate in large table to achieve speed and accuracy; the \fIlibm\fR codes use tricky formulas compact enough that all of them may some day fit into a ROM. .PP More important, DEC regards the VMS codes as proprietary and guards them zealously against unauthorized use. But the \fIlibm\fR codes in 4.3 BSD are intended for the public domain; they may be copied freely provided their provenance is always acknowledged, and provided users assist the authors in their researches by reporting experience with the codes. Therefore no user of UNIX on a machine whose arithmetic resembles VAX D_floating\-point need use anything worse than the new \fIlibm\fR. .PP \fBIEEE STANDARD 754 Floating\-Point Arithmetic:\fR .PP This standard is on its way to becoming more widely adopted than any other design for computer arithmetic. VLSI chips that conform to some version of that standard have been produced by a host of manufacturers, among them ... .nf .ta 0.5i +\w'Intel i8070, i80287'u+6n Intel i8087, i80287 National Semiconductor 32081 Motorola 68881 Weitek WTL-1032, ... , -1165 Zilog Z8070 Western Electric (AT&T) WE32106. .ta .fi Other implementations range from software, done thoroughly in the Apple Macintosh, through VLSI in the Hewlett\-Packard 9000 series, to the ELXSI 6400 running ECL at 3 Megaflops. Several other companies have adopted the formats of IEEE 754 without, alas, adhering to the standard's way of handling rounding and exceptions like over/underflow. The DEC VAX G_floating\-point format is very similar to the IEEE 754 Double format, so similar that the C programs for the IEEE versions of most of the elementary functions listed above could easily be converted to run on a MicroVAX, though nobody has volunteered to do that yet. .PP The codes in 4.3 BSD's \fIlibm\fR for machines that conform to IEEE 754 are intended primarily for the National Semi. 32081 and WTL 1164/65. To use these codes with the Intel or Zilog chips, or with the Apple Macintosh or ELXSI 6400, is to forego the use of better codes provided (perhaps freely) by those companies and designed by some of the authors of the codes above. Except for \fIatan\fR, \fIcabs\fR, \fIcbrt\fR, \fIerf\fR, \fIerfc\fR, \fIhypot\fR, \fIj0\-jn\fR, \fIlgamma\fR, \fIpow\fR and \fIy0\-yn\fR, the Motorola 68881 has all the functions in \fIlibm\fR on chip, and faster and more accurate; it, Apple, the i8087, Z8070 and WE32106 all use 64 .if n \ sig. .if t \ significant bits. The main virtue of 4.3 BSD's \fIlibm\fR codes is that they are intended for the public domain; they may be copied freely provided their provenance is always acknowledged, and provided users assist the authors in their researches by reporting experience with the codes. Therefore no user of UNIX on a machine that conforms to IEEE 754 need use anything worse than the new \fIlibm\fR. .PP Properties of IEEE 754 Double\-Precision: .RS Wordsize: 64 bits, 8 bytes. Radix: Binary. .br Precision: 53 .if n \ sig. .if t \ significant bits, roughly like 16 .if n \ sig. .if t \ significant decimals. .RS If x and x' are consecutive positive Double\-Precision numbers (they differ by 1 \*(up), then .br 1.1e\-16 < 0.5**53 < (x'\-x)/x \(<= 0.5**52 < 2.3e\-16. .RE .nf .ta \w'Range:'u+1n +\w'Underflow threshold'u+1n +\w'= 2.0**1024'u+1n Range: Overflow threshold = 2.0**1024 = 1.8e308 Underflow threshold = 0.5**1022 = 2.2e\-308 .ta .fi .RS Overflow goes by default to a signed .If "" . .br Underflow is \fIGradual,\fR rounding to the nearest integer multiple of 0.5**1074 = 4.9e\-324. .RE Zero is represented ambiguously as +0 or \-0. .RS Its sign transforms correctly through multiplication or division, and is preserved by addition of zeros with like signs; but x\-x yields +0 for every finite x. The only operations that reveal zero's sign are division by zero and copysign(x,\(+-0). In particular, comparison (x > y, x \(>= y, etc.) cannot be affected by the sign of zero; but if finite x = y then .If \&= 1/(x\-y) .if n \ != .if t \ \(!= \-1/(y\-x) = .If \- . .RE .If is signed. .RS it persists when added to itself or to any finite number. Its sign transforms correctly through multiplication and division, and .If (finite)/\(+- \0=\0\(+-0 (nonzero)/0 = .If \(+- . But .if n \ Infinity\-Infinity, Infinity\(**0 and Infinity/Infinity .if t \ \(if\-\(if, \(if\(**0 and \(if/\(if are, like 0/0 and sqrt(\-3), invalid operations that produce \*(nn. ... .RE Reserved operands: .RS there are 2**53\-2 of them, all called \*(nn (\fIN\fRot \fIa N\fRumber). Some, called Signaling \*(nns, trap any floating\-point operation performed upon them; they are used to mark missing or uninitialized values, or nonexistent elements of arrays. The rest are Quiet \*(nns; they are the default results of Invalid Operations, and propagate through subsequent arithmetic operations. If x .if n \ != .if t \ \(!= x then x is \*(nn; every other predicate (x > y, x = y, x < y, ...) is FALSE if \*(nn is involved. .br NOTE: Trichotomy is violated by \*(nn. .RS Besides being FALSE, predicates that entail ordered comparison, rather than mere (in)equality, signal Invalid Operation when \*(nn is involved. .RE .RE Rounding: .RS Every algebraic operation (+, \-, \(**, /, .if n \ sqrt) .if t \ \(sr) is rounded by default to within half an \*(up, and when the rounding error is exactly half an \*(up then the rounded value's least significant bit is zero. This kind of rounding is usually the best kind, sometimes provably so; for instance, for every x = 1.0, 2.0, 3.0, 4.0, ..., 2.0**52, we find (x/3.0)\(**3.0 == x and (x/10.0)\(**10.0 == x and ... despite that both the quotients and the products have been rounded. Only rounding like IEEE 754 can do that. But no single kind of rounding can be proved best for every circumstance, so IEEE 754 provides rounding towards zero or towards .If + or towards .If \- at the programmer's option. And the same kinds of rounding are specified for Binary\-Decimal Conversions, at least for magnitudes between roughly 1.0e\-10 and 1.0e37. .RE Exceptions: .RS IEEE 754 recognizes five kinds of floating\-point exceptions, listed below in declining order of probable importance. .RS .nf .ta \w'Invalid Operation'u+6n +\w'Gradual Underflow'u+2n Exception Default Result .tc \(ru .tc Invalid Operation \*(nn, or FALSE .if n \{\ Overflow \(+-Infinity Divide by Zero \(+-Infinity \} .if t \{\ Overflow \(+-\(if Divide by Zero \(+-\(if \} Underflow Gradual Underflow Inexact Rounded value .ta .fi .RE NOTE: An Exception is not an Error unless handled badly. What makes a class of exceptions exceptional is that no single default response can be satisfactory in every instance. On the other hand, if a default response will serve most instances satisfactorily, the unsatisfactory instances cannot justify aborting computation every time the exception occurs. .RE .PP For each kind of floating\-point exception, IEEE 754 provides a Flag that is raised each time its exception is signaled, and stays raised until the program resets it. Programs may also test, save and restore a flag. Thus, IEEE 754 provides three ways by which programs may cope with exceptions for which the default result might be unsatisfactory: .IP 1) \w'\0\0\0\0'u Test for a condition that might cause an exception later, and branch to avoid the exception. .IP 2) \w'\0\0\0\0'u Test a flag to see whether an exception has occurred since the program last reset its flag. .IP 3) \w'\0\0\0\0'u Test a result to see whether it is a value that only an exception could have produced. .RS CAUTION: The only reliable ways to discover whether Underflow has occurred are to test whether products or quotients lie closer to zero than the underflow threshold, or to test the Underflow flag. (Sums and differences cannot underflow in IEEE 754; if x .if n \ != .if t \ \(!= y then x\-y is correct to full precision and certainly nonzero regardless of how tiny it may be.) Products and quotients that underflow gradually can lose accuracy gradually without vanishing, so comparing them with zero (as one might on a VAX) will not reveal the loss. Fortunately, if a gradually underflowed value is destined to be added to something bigger than the underflow threshold, as is almost always the case, digits lost to gradual underflow will not be missed because they would have been rounded off anyway. So gradual underflows are usually \fIprovably\fR ignorable. The same cannot be said of underflows flushed to 0. .RE .PP At the option of an implementor conforming to IEEE 754, other ways to cope with exceptions may be provided: .IP 4) \w'\0\0\0\0'u ABORT. This mechanism classifies an exception in advance as an incident to be handled by means traditionally associated with error\-handling statements like "ON ERROR GO TO ...". Different languages offer different forms of this statement, but most share the following characteristics: .IP \(em \w'\0\0\0\0'u No means is provided to substitute a value for the offending operation's result and resume computation from what may be the middle of an expression. An exceptional result is abandoned. .IP \(em \w'\0\0\0\0'u In a subprogram that lacks an error\-handling statement, an exception causes the subprogram to abort within whatever program called it, and so on back up the chain of calling subprograms until an error\-handling statement is encountered or the whole task is aborted and memory is dumped. .IP 5) \w'\0\0\0\0'u STOP. This mechanism, requiring an interactive debugging environment, is more for the programmer than the program. It classifies an exception in advance as a symptom of a programmer's error; the exception suspends execution as near as it can to the offending operation so that the programmer can look around to see how it happened. Quite often the first several exceptions turn out to be quite unexceptionable, so the programmer ought ideally to be able to resume execution after each one as if execution had not been stopped. .IP 6) \w'\0\0\0\0'u \&... Other ways lie beyond the scope of this document. .RE .PP The crucial problem for exception handling is the problem of Scope, and the problem's solution is understood, but not enough manpower was available to implement it fully in time to be distributed in 4.3 BSD's \fIlibm\fR. Ideally, each elementary function should act as if it were indivisible, or atomic, in the sense that ... .IP i) \w'iii)'u+2n No exception should be signaled that is not deserved by the data supplied to that function. .IP ii) \w'iii)'u+2n Any exception signaled should be identified with that function rather than with one of its subroutines. .IP iii) \w'iii)'u+2n The internal behavior of an atomic function should not be disrupted when a calling program changes from one to another of the five or so ways of handling exceptions listed above, although the definition of the function may be correlated intentionally with exception handling. .PP Ideally, every programmer should be able \fIconveniently\fR to turn a debugged subprogram into one that appears atomic to its users. But simulating all three characteristics of an atomic function is still a tedious affair, entailing hosts of tests and saves\-restores; work is under way to ameliorate the inconvenience. .PP Meanwhile, the functions in \fIlibm\fR are only approximately atomic. They signal no inappropriate exception except possibly ... .RS Over/Underflow .RS when a result, if properly computed, might have lain barely within range, and .RE Inexact in \fIcabs\fR, \fIcbrt\fR, \fIhypot\fR, \fIlog10\fR and \fIpow\fR .RS when it happens to be exact, thanks to fortuitous cancellation of errors. .RE .RE Otherwise, ... .RS Invalid Operation is signaled only when .RS any result but \*(nn would probably be misleading. .RE Overflow is signaled only when .RS the exact result would be finite but beyond the overflow threshold. .RE Divide\-by\-Zero is signaled only when .RS a function takes exactly infinite values at finite operands. .RE Underflow is signaled only when .RS the exact result would be nonzero but tinier than the underflow threshold. .RE Inexact is signaled only when .RS greater range or precision would be needed to represent the exact result. .RE .RE .SH BUGS When signals are appropriate, they are emitted by certain operations within the codes, so a subroutine\-trace may be needed to identify the function with its signal in case method 5) above is in use. And the codes all take the IEEE 754 defaults for granted; this means that a decision to trap all divisions by zero could disrupt a code that would otherwise get correct results despite division by zero. .SH SEE ALSO An explanation of IEEE 754 and its proposed extension p854 was published in the IEEE magazine MICRO in August 1984 under the title "A Proposed Radix\- and Word\-length\-independent Standard for Floating\-point Arithmetic" by W. J. Cody et al. The manuals for Pascal, C and BASIC on the Apple Macintosh document the features of IEEE 754 pretty well. Articles in the IEEE magazine COMPUTER vol. 14 no. 3 (Mar. 1981), and in the ACM SIGNUM Newsletter Special Issue of Oct. 1979, may be helpful although they pertain to superseded drafts of the standard. .SH AUTHOR W. Kahan, with the help of Z\-S. Alex Liu, Stuart I. McDonald, Dr. Kwok\-Choi Ng, Peter Tang. ================================================ FILE: share/man/man3/mktemp.3 ================================================ .\" @(#)mktemp.3 6.3 (Berkeley) 4/10/87 .\" .TH MKTEMP 3 "April 10, 1987" .AT 3 .SH NAME mktemp \- make a unique file name .SH SYNOPSIS .nf .B char *mktemp(template) .B char *template; .sp .B mkstemp(template) .B char *template; .fi .SH DESCRIPTION \fIMktemp\fP creates a unique file name and returns the address of the template. The template should contain a file name with trailing \fIX\fP's, normally something like \fI/tmp/tempXXXXXX\fP. The \fIX\fP's are replaced by the current process number and/or a unique letter combination. \fIMkstemp\fP makes the same replacement to the template but opens the template file and returns a file descriptor open for reading and writing. \fIMkstemp\fP avoids the race between testing whether the file exists and opening it for use. The number of file name combinations \fImktemp\fP and \fImkstemp\fP will try depends on the number of \fIX\fP's placed on the end of the template; six \fIX\fP's will result in them trying roughly 26 ** 6 combinations. .SH "SEE ALSO" access(2), getpid(2), open(2) .SH DIAGNOSTICS \fIMktemp\fP returns NULL on failure, \fImkstemp\fP returns -1 if no suitable file could be created. ================================================ FILE: share/man/man3/monitor.3 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)monitor.3 6.1 (Berkeley) 5/15/85 .\" .TH MONITOR 3 "May 15, 1985" .UC 4 .SH NAME monitor, monstartup, moncontrol \- prepare execution profile .SH SYNOPSIS .nf .B monitor(lowpc, highpc, buffer, bufsize, nfunc) .B int (*lowpc)(), (*highpc)(); .B short buffer[]; .sp .B monstartup(lowpc, highpc) .B int (*lowpc)(), (*highpc)(); .sp .B moncontrol(mode) .fi .SH DESCRIPTION There are two different forms of monitoring available: An executable program created by: .IP " cc \-p . . ." .LP automatically includes calls for the .IR prof (1) monitor and includes an initial call to its start-up routine .I monstartup with default parameters; .I monitor need not be called explicitly except to gain fine control over profil buffer allocation. An executable program created by: .IP " cc \-pg . . ." .LP automatically includes calls for the .IR gprof (1) monitor. .PP .I Monstartup is a high level interface to .IR profil (2). .I Lowpc and .I highpc specify the address range that is to be sampled; the lowest address sampled is that of .I lowpc and the highest is just below .IR highpc . .I Monstartup allocates space using .IR sbrk (2) and passes it to .I monitor (see below) to record a histogram of periodically sampled values of the program counter, and of counts of calls of certain functions, in the buffer. Only calls of functions compiled with the profiling option .B \-p of .IR cc (1) are recorded. .PP To profile the entire program, it is sufficient to use .PP .nf extern etext(); . . . monstartup((int) 2, etext); .fi .PP .I Etext lies just above all the program text, see .IR end (3). .PP To stop execution monitoring and write the results on the file .I mon.out, use .PP monitor(0); .LP then .IR prof (1) can be used to examine the results. .PP .I Moncontrol is used to selectively control profiling within a program. This works with either .IR prof (1) or .IR gprof (1) type profiling. When the program starts, profiling begins. To stop the collection of histogram ticks and call counts use .IR moncontrol (0); to resume the collection of histogram ticks and call counts use .IR moncontrol (1). This allows the cost of particular operations to be measured. Note that an output file will be produced upon program exit irregardless of the state of .I moncontrol. .PP .I Monitor is a low level interface to .IR profil (2). .I Lowpc and .I highpc are the addresses of two functions; .I buffer is the address of a (user supplied) array of .I bufsize short integers. At most .I nfunc call counts can be kept. For the results to be significant, especially where there are small, heavily used routines, it is suggested that the buffer be no more than a few times smaller than the range of locations sampled. .I Monitor divides the buffer into space to record the histogram of program counter samples over the range .I lowpc to .IR highpc , and space to record call counts of functions compiled with the .B \-p option to .IR cc (1). .PP To profile the entire program, it is sufficient to use .PP .nf extern etext(); . . . monitor((int) 2, etext, buf, bufsize, nfunc); .fi .SH FILES mon.out .SH "SEE ALSO" cc(1), prof(1), gprof(1), profil(2), sbrk(2) ================================================ FILE: share/man/man3/mp.3 ================================================ .\" Copyright (c) 1986 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)mp.3x 6.4 (Berkeley) 6/4/86 .\" .TH MP 3X "June 4, 1986" .UC 6 .SH NAME madd, msub, mult, mdiv, pow, gcd, invert, rpow, msqrt, mcmp, move, min, omin, fmin, m_in, mout, omout, fmout, m_out, sdiv, itom \- multiple precision integer arithmetic .SH SYNOPSIS .nf .B #include .B #include .PP .B "typedef struct mint { int len; short *val; } MINT;" .PP .B madd(a, b, c) .B msub(a, b, c) .B mult(a, b, c) .B mdiv(a, b, q, r) .B pow(a, b, m, c) .B gcd(a, b, c) .B invert(a, b, c) .B rpow(a, n, c) .B msqrt(a, b, r) .B mcmp(a, b) .B move(a, b) .B min(a) .B omin(a) .B fmin(a, f) .B m_in(a, n, f) .B mout(a) .B omout(a) .B fmout(a, f) .B m_out(a, n, f) .B MINT *a, *b, *c, *m, "*q, *r;" .B FILE *f; .B int n; .PP .B sdiv(a, n, q, r) .B MINT *a, *q; .B short n; .B short *r; .PP .B MINT *itom(n) .SH DESCRIPTION These routines perform arithmetic on integers of arbitrary length. The integers are stored using the defined type .IR MINT . Pointers to a .I MINT can be initialized using the function .I itom which sets the initial value to .IR n . After that, space is managed automatically by the routines. .PP .IR madd , " msub " and " mult" assign to .I c the sum, difference and product, respectively, of .IR a " and " b . .I mdiv assigns to .IR q " and " r the quotient and remainder obtained from dividing .IR a " by " b. .I sdiv is like .I mdiv except that the divisor is a short integer .I n and the remainder is placed in a short whose address is given as .IR r . .I msqrt produces the integer square root of .IR a " in " b and places the remainder in .IR r . .I rpow calculates in .I c the value of .I a raised to the (``regular'' integral) power .IR n , while .I pow calculates this with a full multiple precision exponent .I b and the result is reduced modulo .IR m . .I gcd returns the greatest common denominator of .IR a " and " b " in " c , and .I invert computes .IR c " such that " a*c " mod " b " = 1," for .IR a " and " b relatively prime. .I mcmp returns a negative, zero or positive integer value when .I a is less than, equal to or greater than .IR b , respectively. .I move copies .IR a " to " b . .IR min " and " mout do decimal input and output while .IR omin " and " omout do octal input and output. More generally, .IR fmin " and " fmout do decimal input and output using file .IR f , and .IR m_in " and " m_out do I/O with arbitrary radix .IR n . On input, records should have the form of strings of digits terminated by a newline; output records have a similar form. .PP Programs which use the multiple-precision arithmetic library must be loaded using the loader flag .IR \-lmp . .SH FILES .ta 2i /usr/include/mp.h include file .br /usr/lib/libmp.a object code library .SH SEE ALSO dc(1), bc(1) .SH DIAGNOSTICS Illegal operations and running out of memory produce messages and core images. .SH BUGS Bases for input and output should be <= 10. .PP .IR dc (1) and .IR bc (1) don't use this library. .PP The input and output routines are a crock. .PP .I pow is also the name of a standard math library routine. ================================================ FILE: share/man/man3/ndbm.3 ================================================ .\" Copyright (c) 1985 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)ndbm.3 6.6 (Berkeley) 5/20/86 .\" .TH NDBM 3 "May 20, 1986" .UC 6 .SH NAME dbm_open, dbm_close, dbm_fetch, dbm_store, dbm_delete, dbm_firstkey, dbm_nextkey, dbm_error, dbm_clearerr \- data base subroutines .SH SYNOPSIS .nf .PP .ft B #include .PP .ft B typedef struct { char *dptr; int dsize; } datum; .PP .ft B DBM *dbm_open(file, flags, mode) char *file; int flags, mode; .PP .ft B void dbm_close(db) DBM *db; .PP .ft B datum dbm_fetch(db, key) DBM *db; datum key; .PP .ft B int dbm_store(db, key, content, flags) DBM *db; datum key, content; int flags; .PP .ft B int dbm_delete(db, key) DBM *db; datum key; .PP .ft B datum dbm_firstkey(db) DBM *db; .PP .ft B datum dbm_nextkey(db) DBM *db; .PP .ft B int dbm_error(db) DBM *db; .PP .ft B int dbm_clearerr(db) DBM *db; .SH DESCRIPTION These functions maintain key/content pairs in a data base. The functions will handle very large (a billion blocks) databases and will access a keyed item in one or two file system accesses. This package replaces the earlier .IR dbm (3x) library, which managed only a single database. .PP .IR Key s and .IR content s are described by the .I datum typedef. A .I datum specifies a string of .I dsize bytes pointed to by .I dptr. Arbitrary binary data, as well as normal ASCII strings, are allowed. The data base is stored in two files. One file is a directory containing a bit map and has `.dir' as its suffix. The second file contains all data and has `.pag' as its suffix. .PP Before a database can be accessed, it must be opened by .IR dbm_open . This will open and/or create the files .IB file .dir and .IB file .pag depending on the flags parameter (see .IR open (2)). .PP Once open, the data stored under a key is accessed by .I dbm_fetch and data is placed under a key by .IR dbm_store . The .I flags field can be either .B DBM_INSERT or .B DBM_REPLACE. .B DBM_INSERT will only insert new entries into the database and will not change an existing entry with the same key. .B DBM_REPLACE will replace an existing entry if it has the same key. A key (and its associated contents) is deleted by .IR dbm_delete . A linear pass through all keys in a database may be made, in an (apparently) random order, by use of .I dbm_firstkey and .IR dbm_nextkey . .I Dbm_firstkey will return the first key in the database. .I Dbm_nextkey will return the next key in the database. This code will traverse the data base: .IP .B for (key = dbm_firstkey(db); key.dptr != NULL; key = dbm_nextkey(db)) .PP .I Dbm_error returns non-zero when an error has occurred reading or writing the database. .I Dbm_clearerr resets the error condition on the named database. .SH DIAGNOSTICS All functions that return an .I int indicate errors with negative values. A zero return indicates ok. Routines that return a .I datum indicate errors with a null (0) .I dptr. If .IR dbm_store called with a .I flags value of .B DBM_INSERT finds an existing entry with the same key it returns 1. .SH BUGS The `.pag' file will contain holes so that its apparent size is about four times its actual content. Older UNIX systems may create real file blocks for these holes when touched. These files cannot be copied by normal means (cp, cat, tp, tar, ar) without filling in the holes. .PP .I Dptr pointers returned by these subroutines point into static storage that is changed by subsequent calls. .PP The sum of the sizes of a key/content pair must not exceed the internal block size (currently 4096 bytes). Moreover all key/content pairs that hash together must fit on a single block. .I Dbm_store will return an error in the event that a disk block fills with inseparable data. .PP .I Dbm_delete does not physically reclaim file space, although it does make it available for reuse. .PP The order of keys presented by .I dbm_firstkey and .I dbm_nextkey depends on a hashing function, not on anything interesting. .SH SEE ALSO dbm(3X) ================================================ FILE: share/man/man3/nice.3 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)nice.3c 6.1 (Berkeley) 5/9/85 .\" .TH NICE 3C "May 9, 1985" .UC 4 .SH NAME nice \- set program priority .SH SYNOPSIS .B nice(incr) .SH DESCRIPTION .ft B This interface is obsoleted by setpriority(2). .ft R .PP The scheduling priority of the process is augmented by .IR incr . Positive priorities get less service than normal. Priority 10 is recommended to users who wish to execute long-running programs without flak from the administration. .PP Negative increments are ignored except on behalf of the super-user. The priority is limited to the range \-20 (most urgent) to 20 (least). .PP The priority of a process is passed to a child process by .IR fork (2). For a privileged process to return to normal priority from an unknown state, .I nice should be called successively with arguments \-40 (goes to priority \-20 because of truncation), 20 (to get to 0), then 0 (to maintain compatibility with previous versions of this call). .SH "SEE ALSO" nice(1), setpriority(2), fork(2), renice(8) ================================================ FILE: share/man/man3/nlist.3 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)nlist.3 6.1 (Berkeley) 5/15/85 .\" .TH NLIST 3 "May 15, 1985" .UC 4 .SH NAME nlist \- get entries from name list .SH SYNOPSIS .nf .B #include .PP .B nlist(filename, nl) .B char *filename; .B struct nlist nl[]; .fi .SH DESCRIPTION .I Nlist examines the name list in the given executable output file and selectively extracts a list of values. The name list consists of an array of structures containing names, types and values. The list is terminated with a null name. Each name is looked up in the name list of the file. If the name is found, the type and value of the name are inserted in the next two fields. If the name is not found, both entries are set to 0. See .IR a.out (5) for the structure declaration. .PP This subroutine is useful for examining the system name list kept in the file .BR /vmunix . In this way programs can obtain system addresses that are up to date. .SH "SEE ALSO" a.out(5) .SH DIAGNOSTICS If the file cannot be found or if it is not a valid namelist \-1 is returned; otherwise, the number of unfound namelist entries is returned. .PP The type entry is set to 0 if the symbol is not found. ================================================ FILE: share/man/man3/ns.3 ================================================ .\" Copyright (c) 1986 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)ns.3n 6.2 (Berkeley) 5/12/86 .\" .TH NS 3N "May 12, 1986" .UC 6 .SH NAME ns_addr, ns_ntoa \- Xerox NS(tm) address conversion routines .SH SYNOPSIS .nf .B "#include .B "#include .PP .B "struct ns_addr ns_addr(cp) .B "char *cp; .PP .B "char *ns_ntoa(ns) .B "struct ns_addr ns; .fi .SH DESCRIPTION The routine .I ns_addr interprets character strings representing XNS addresses, returning binary information suitable for use in system calls. .I ns_ntoa takes XNS addresses and returns ASCII strings representing the address in a notation in common use in the Xerox Development Environment: .nf .. .fi Trailing zero fields are suppressed, and each number is printed in hexadecimal, in a format suitable for input to .IR ns_addr . Any fields lacking super-decimal digits will have a trailing ``H'' appended. .PP Unfortunately, no universal standard exists for representing XNS addresses. An effort has been made to insure that .I ns_addr be compatible with most formats in common use. It will first separate an address into 1 to 3 fields using a single delimiter chosen from period (``.''), colon (``:'') or pound-sign (``#''). Each field is then examined for byte separators (colon or period). If there are byte separators, each subfield separated is taken to be a small hexadecimal number, and the entirety is taken as a network-byte-ordered quantity to be zero extended in the high-network-order bytes. Next, the field is inspected for hyphens, in which case the field is assumed to be a number in decimal notation with hyphens separating the millenia. Next, the field is assumed to be a number: It is interpreted as hexadecimal if there is a leading ``0x'' (as in C), a trailing ``H'' (as in Mesa), or there are any super-decimal digits present. It is interpreted as octal is there is a leading ``0'' and there are no super-octal digits. Otherwise, it is converted as a decimal number. .SH "SEE ALSO" hosts(5), networks(5), .SH DIAGNOSTICS None (see BUGS). .SH BUGS The string returned by .I ns_ntoa resides in a static memory area. .br .I ns_addr should diagnose improperly formed input, and there should be an unambiguous way to recognize this. ================================================ FILE: share/man/man3/pause.3 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)pause.3c 6.1 (Berkeley) 5/9/85 .\" .TH PAUSE 3C "May 9, 1985" .UC 4 .SH NAME pause \- stop until signal .SH SYNOPSIS .B pause() .SH DESCRIPTION .I Pause never returns normally. It is used to give up control while waiting for a signal from .IR kill (2) or an interval timer, see .IR setitimer (2). Upon termination of a signal handler started during a .I pause, the .I pause call will return. .SH "RETURN VALUE Always returns \-1. .SH ERRORS .I Pause always returns: .TP 15 [EINTR] The call was interrupted. .SH "SEE ALSO kill(2), select(2), sigpause(2) ================================================ FILE: share/man/man3/perror.3 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)perror.3 6.1.1 (2.11BSD) 1996/3/21 .\" .TH PERROR 3 "March 21, 1996" .UC 4 .SH NAME perror, strerror \- system error messages .SH SYNOPSIS .nf .B perror(s) .B char *s; .sp .B #include .sp .I char * .B strerror(errnum) .B int errnum; .fi .SH DESCRIPTION The .B strerror() and .B perror() functions look up the error message string corresponding to an error number. .PP The .B strerror() function accepts an error number argument .I errnum and returns a pointer to the corresponding message string. .PP The .B perror() function finds the error message corresponding to the current value of the global variable .I errno (intro(2)) and writes it, followed by a newline, to the standard error file descriptor. If the argument .I string is non-NULL, it is prepended to the message string and separated from it by a colon and space (`: '). If .I string is NULL, only the error message string is printed. .PP If .I errnum is not a recognized error number, the error message string will contain ``Unknown error: '' followed by the error number in decimal. .PP The error messages are stored in a data file now rather than an in memory array. See .BR syserror (5). .SH "SEE ALSO" mkerrlst(1), intro(2), psignal(3), strerror(3), syserror(3), syserror(5) .SH BUGS The .BR strerror () function returns its result in a static buffer which may be overwritten by subsequent calls. .PP The array .B sys_errlist[] and the global .B sys_nerr are .B obsolete and should not be used. They have, for the time being, been placed in an object library .BR liberrlst.a . ================================================ FILE: share/man/man3/plot.3 ================================================ .\" @(#)plot.3x 6.2 (Berkeley) 5/15/86 .\" .TH PLOT 3X "May 15, 1986" .AT 3 .SH NAME plot: openpl, erase, label, line, circle, arc, move, cont, point, linemod, space, closepl \- graphics interface .SH SYNOPSIS .nf .B openpl() .PP .B erase() .PP .B label(s) .B char s[]; .PP .B line(x1, y1, x2, y2) .PP .B circle(x, y, r) .PP .B arc(x, y, x0, y0, x1, y1) .PP .B move(x, y) .PP .B cont(x, y) .PP .B point(x, y) .PP .B linemod(s) .B char s[]; .PP .B space(x0, y0, x1, y1) .PP .B closepl() .fi .PP .ft R .SH DESCRIPTION These subroutines generate graphic output in a relatively device-independent manner. See .IR plot (5) for a description of their effect. .I Openpl must be used before any of the others to open the device for writing. .I Closepl flushes the output. .PP String arguments to .I label and .I linemod are null-terminated, and do not contain newlines. .PP Various flavors of these functions exist for different output devices. They are obtained by the following .IR ld (1) options: .TP 8n .B \-lplot device-independent graphics stream on standard output for .IR plot (1) filters .br .ns .TP .B \-l300 GSI 300 terminal .br .ns .TP .B \-l300s GSI 300S terminal .br .ns .TP .B \-l450 GSI 450 terminal .br .ns .TP .B \-l4013 Tektronix 4013 terminal .br .ns .TP .B \-l4014 Tektronix 4014 and 4015 terminals with the Enhanced Graphics Module (Use .B \-l4013 for 4014's or 4015's without the Enhanced Graphics Module) .br .ns .TP .B \-lplotaed AED 512 color graphics terminal .br .ns .TP .B \-lplotbg BBN bitgraph graphics terminal .br .ns .TP .B \-lplotdumb Dumb terminals without cursor addressing or line printers .br .ns .TP .B \-lplot DEC Gigi terminals .br .ns .TP .B \-lvt0 DEC vt100 terminals .br .ns .TP .B \-lplot2648 Hewlett Packard 2648 graphics terminal .br .ns .TP .B \-lplot7221 Hewlett Packard 7221 graphics terminal .br .ns .TP .B \-lplotimagen Imagen laser printer (default 240 dots-per-inch resolution). .PP On many devices, it is necessary to pause after .IR erase (), otherwise plotting commands are lost. The pause is normally done by the tty driver if at login time, .I tset found a .I df field in the .IR termcap (5) entry for the terminal. If a pause is needed but not automatically being generated, add .RS .nf flush(stdout); sleep(1); .fi .RE after each .IR erase (). .SH "SEE ALSO" plot(5), plot(1G), plot(3F), graph(1G) ================================================ FILE: share/man/man3/popen.3 ================================================ .\" @(#)popen.3 6.1 (Berkeley) 5/15/85 .\" .TH POPEN 3 "May 15, 1985" .AT 3 .SH NAME popen, pclose \- initiate I/O to/from a process .SH SYNOPSIS .B #include .PP .SM .B FILE .B *popen(command, type) .br .B char *command, *type; .PP .B pclose(stream) .br .SM .B FILE .B *stream; .SH DESCRIPTION The arguments to .I popen are pointers to null-terminated strings containing respectively a shell command line and an I/O mode, either "r" for reading or "w" for writing. It creates a pipe between the calling process and the command to be executed. The value returned is a stream pointer that can be used (as appropriate) to write to the standard input of the command or read from its standard output. .PP A stream opened by .I popen should be closed by .IR pclose , which waits for the associated process to terminate and returns the exit status of the command. .PP Because open files are shared, a type "r" command may be used as an input filter, and a type "w" as an output filter. .SH "SEE ALSO" pipe(2), fopen(3S), fclose(3S), system(3), wait(2), sh(1) .SH DIAGNOSTICS .I Popen returns a null pointer if files or processes cannot be created, or the shell cannot be accessed. .PP .I Pclose returns \-1 if .I stream is not associated with a `popened' command. .SH BUGS Buffered reading before opening an input filter may leave the standard input of that filter mispositioned. Similar problems with an output filter may be forestalled by careful buffer flushing, for instance, with .I fflush, see .IR fclose (3S). .LP .I Popen always calls .IR sh , never calls .IR csh . ================================================ FILE: share/man/man3/printf.3 ================================================ .\" @(#)printf.3s 6.5.1 (2.11BSD) 1995/04/02 .\" .TH PRINTF 3S "August 10, 1988" .AT 3 .SH NAME printf, fprintf, sprintf, vfprintf, vsprintf \- formatted output conversion .SH SYNOPSIS .B #include .PP .B char *printf(format .RB [ , arg ] ... .B ) .br .B char *format; .PP .B char *fprintf(stream, format .RB [ , arg ] ... .B ) .br .SM .B FILE .B *stream; .br .B char *format; .PP .B int sprintf(s, format .RB [ , arg ] ... .B ) .br .B char *s, *format; .PP .B #include .br .B char *vprintf(format, args) .br .B char *format; .br .B va_list args; .PP .B char *vfprintf(stream, format, args) .br .B FILE *stream; .br .B char *format; .br .B va_list args; .PP .B int vsprintf(s, format, args) .br .B char *s, *format; .br .B va_list args; .SH DESCRIPTION .I Printf places output on the standard output stream .BR stdout . .I Fprintf places output on the named output .IR stream . .I Sprintf places `output' in the string .IR s , followed by the character `\\0'. Alternate forms, in which the arguments have already been captured using the variable-length argument facilities of .IR varargs (3), are available under the names .IR vprintf , .IR vfprintf , and .IR vsprintf . .PP Each of these functions converts, formats, and prints its arguments after the first under control of the first argument. The first argument is a character string which contains two types of objects: plain characters, which are simply copied to the output stream, and conversion specifications, each of which causes conversion and printing of the next successive .I arg .IR printf . .PP Each conversion specification is introduced by the character .BR % . The remainder of the conversion specification includes in the following order .TP .B \(bu a minus sign `\-' which specifies .I "left adjustment" of the converted value in the indicated field; .TP .B \(bu an optional digit string specifying a .I "field width;" if the converted value has fewer characters than the field width it will be blank-padded on the left (or right, if the left-adjustment indicator has been given) to make up the field width; if the field width begins with a zero, zero-padding will be done instead of blank-padding; .TP .B \(bu an optional period, followed by an optional digit string giving a .I precision which specifies the number of digits to appear after the decimal point, for e- and f-conversion, or the maximum number of characters to be printed from a string; .TP .B \(bu the character .B l specifying that a following .BR d , .BR o , .BR x , or .B u corresponds to a long integer .IR arg ; .TP .B \(bu a character which indicates the type of conversion to be applied. .PP A field width or precision may be `*' instead of a digit string. In this case an integer .I arg supplies the field width or precision. .PP The conversion characters and their meanings are .TP .B dox The integer .I arg is converted to signed decimal, unsigned octal, or unsigned hexadecimal notation respectively. .TP .B f The float or double .I arg is converted to decimal notation in the style `[\fB\-\fR]ddd.ddd' where the number of d's after the decimal point is equal to the precision specification for the argument. If the precision is missing, 6 digits are given; if the precision is explicitly 0, no digits and no decimal point are printed. .TP .B e The float or double .I arg is converted in the style `[\fB\-\fR]d\fB.\fRddd\fBe\fR\(+-dd' where there is one digit before the decimal point and the number after is equal to the precision specification for the argument; when the precision is missing, 6 digits are produced. .TP .B g The float or double .I arg is printed in style .BR d , in style .BR f , or in style .BR e , whichever gives full precision in minimum space. .TP .B c The character .I arg is printed. .TP .B s .I Arg is taken to be a string (character pointer) and characters from the string are printed until a null character or until the number of characters indicated by the precision specification is reached; however if the precision is 0 or missing all characters up to a null are printed. .TP .B u The unsigned integer .I arg is converted to decimal and printed (the result will be in the range 0 through MAXUINT, where MAXUINT equals 4294967295 on a VAX-11 and 65535 on a PDP-11). .TP .B % Print a `%'; no argument is converted. .PP In no case does a non-existent or small field width cause truncation of a field; padding takes place only if the specified field width exceeds the actual width. Characters generated by .I printf are printed as by .IR putc (3S). .PP .SH "RETURN VALUE" The functions all return the number of characters printed, or -1 if an error occurred. .SH EXAMPLES .br To print a date and time in the form `Sunday, July 3, 10:02', where .I weekday and .I month are pointers to null-terminated strings: .RS .HP .nh printf("%s, %s %d, %02d:%02d", weekday, month, day, hour, min); .RE .hy .PP To print .if n pi .if t \(*p to 5 decimals: .IP printf("pi = %.5f", 4*atan(1.0)); .SH "SEE ALSO" putc(3S), scanf(3S) .SH BUGS Very wide fields (>300 characters) fail. .LP Only \fIsprintf\fP and \fIvsprintf\fP return a count of characters transferred. .LP The functions still supports \fI%D\fP, \fI%O\fP, \fI%U\fP and \fI%X\fP. Do not use these formats, as they will be disappearing real soon now. ================================================ FILE: share/man/man3/psignal.3 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)psignal.3 6.1 (Berkeley) 5/15/85 .\" .TH PSIGNAL 3 "May 15, 1985" .UC 5 .SH NAME psignal, sys_siglist \- system signal messages .SH SYNOPSIS .nf .B psignal(sig, s) .B unsigned sig; .B char *s; .PP .B char *sys_siglist[]; .fi .SH DESCRIPTION .I Psignal produces a short message on the standard error file describing the indicated signal. First the argument string .I s is printed, then a colon, then the name of the signal and a new-line. Most usefully, the argument string is the name of the program which incurred the signal. The signal number should be from among those found in .IR . .PP To simplify variant formatting of signal names, the vector of message strings .I sys_siglist is provided; the signal number can be used as an index in this table to get the signal name without the newline. The define NSIG defined in .RI < signal.h > is the number of messages provided for in the table; it should be checked because new signals may be added to the system before they are added to the table. .SH "SEE ALSO" sigvec(2), perror(3) ================================================ FILE: share/man/man3/putc.3 ================================================ .\" @(#)putc.3s 6.2 (Berkeley) 11/6/85 .\" .TH PUTC 3S "November 6, 1985" .AT 3 .SH NAME putc, putchar, fputc, putw \- put character or word on a stream .SH SYNOPSIS .B #include .PP .B int putc(c, stream) .br .B char c; .br .SM .B FILE .B *stream; .PP .B int putchar(c) .PP .B int fputc(c, stream) .br .SM .B FILE .B *stream; .PP .B int putw(w, stream) .br .SM .B FILE .B *stream; .SH DESCRIPTION .I Putc appends the character .I c to the named output .IR stream . It returns the character written. .PP .IR Putchar ( c ) is defined as .IR putc ( c , .BR stdout ). .PP .I Fputc behaves like .IR putc , but is a genuine function rather than a macro. .PP .I Putw appends word (that is, .BR int ) .I w to the output .IR stream . It returns the word written. .I Putw neither assumes nor causes special alignment in the file. .SH "SEE ALSO" fopen(3S), fclose(3S), getc(3S), puts(3S), printf(3S), fread(3S) .SH DIAGNOSTICS These functions return the constant .SM .B EOF upon error. Since this is a good integer, .IR ferror (3S) should be used to detect .I putw errors. .SH BUGS Because it is implemented as a macro, .I putc treats a .I stream argument with side effects improperly. In particular .IP "putc(c, *f++);" .PP doesn't work sensibly. .PP Errors can occur long after the call to .IR putc . ================================================ FILE: share/man/man3/puts.3 ================================================ .\" @(#)puts.3s 6.1 (Berkeley) 5/15/85 .\" .TH PUTS 3S "May 15, 1985" .AT 3 .SH NAME puts, fputs \- put a string on a stream .SH SYNOPSIS .B #include .PP .B puts(s) .br .B char *s; .PP .B fputs(s, stream) .br .B char *s; .br .SM .B FILE .B *stream; .SH DESCRIPTION .I Puts copies the null-terminated string .I s to the standard output stream .B stdout and appends a newline character. .PP .I Fputs copies the null-terminated string .I s to the named output .IR stream . .PP Neither routine copies the terminal null character. .SH "SEE ALSO" fopen(3S), gets(3S), putc(3S), printf(3S), ferror(3S) .br fread(3S) for .I fwrite .SH BUGS .I Puts appends a newline, .I fputs does not, all in the name of backward compatibility. ================================================ FILE: share/man/man3/qsort.3 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)qsort.3 6.1 (Berkeley) 5/15/85 .\" .TH QSORT 3 "May 15, 1985" .UC 4 .SH NAME qsort \- quicker sort .SH SYNOPSIS .nf .B qsort(base, nel, width, compar) .B char *base; .B int (*compar)(); .fi .SH DESCRIPTION .I Qsort is an implementation of the quicker-sort algorithm. The first argument is a pointer to the base of the data; the second is the number of elements; the third is the width of an element in bytes; the last is the name of the comparison routine to be called with two arguments which are pointers to the elements being compared. The routine must return an integer less than, equal to, or greater than 0 according as the first argument is to be considered less than, equal to, or greater than the second. .SH "SEE ALSO" sort(1) ================================================ FILE: share/man/man3/rand.3 ================================================ .\" @(#)rand.3c 6.2 (Berkeley) 9/29/85 .\" .TH RAND 3C "September 29, 1985" .AT 3 .SH NAME rand, srand \- random number generator .SH SYNOPSIS .nf .B srand(seed) .B int seed; .PP .B rand() .fi .SH DESCRIPTION .ft B The newer random(3) should be used in new applications; rand remains for compatibilty. .ft R .PP .I Rand uses a multiplicative congruential random number generator with period .if t 2\u\s732\s0\d .if n 2**32 to return successive pseudo-random numbers in the range from 0 to .if t 2\u\s731\s10\d\(mi1. .if n (2**31)\(mi1 on the VAX, and .if t 2\u\s715\s10\d\(mi1. .if n (2**15)\(mi1 on the PDP-11. .PP The generator is reinitialized by calling .I srand with 1 as argument. It can be set to a random starting point by calling .I srand with whatever you like as argument. .SH "SEE ALSO" random(3) ================================================ FILE: share/man/man3/random.3 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)random.3 6.2 (Berkeley) 9/29/85 .\" .TH RANDOM 3 "September 29, 1985" .UC 5 .SH NAME random, srandom, initstate, setstate \- better random number generator; routines for changing generators .SH SYNOPSIS .nf .B long random() .PP .B srandom(seed) .B int seed; .PP .B char *initstate(seed, state, n) .B unsigned seed; .B char *state; .B int n; .PP .B char *setstate(state) .B char *state; .fi .SH DESCRIPTION .PP .I Random uses a non-linear additive feedback random number generator employing a default table of size 31 long integers to return successive pseudo-random numbers in the range from 0 to .if t 2\u\s731\s10\d\(mi1. .if n (2**31)\(mi1. The period of this random number generator is very large, approximately .if t 16\(mu(2\u\s731\s10\d\(mi1). .if n 16*((2**31)\(mi1). .PP .I Random/srandom have (almost) the same calling sequence and initialization properties as .I rand/srand. The difference is that .IR rand (3) produces a much less random sequence \(em in fact, the low dozen bits generated by rand go through a cyclic pattern. All the bits generated by .I random are usable. For example, ``random()&01'' will produce a random binary value. .PP Unlike .IR srand , .I srandom does not return the old seed; the reason for this is that the amount of state information used is much more than a single word. (Two other routines are provided to deal with restarting/changing random number generators). Like .IR rand (3), however, .I random will by default produce a sequence of numbers that can be duplicated by calling .I srandom with .I 1 as the seed. .PP The .I initstate routine allows a state array, passed in as an argument, to be initialized for future use. The size of the state array (in bytes) is used by .I initstate to decide how sophisticated a random number generator it should use -- the more state, the better the random numbers will be. (Current "optimal" values for the amount of state information are 8, 32, 64, 128, and 256 bytes; other amounts will be rounded down to the nearest known amount. Using less than 8 bytes will cause an error). The seed for the initialization (which specifies a starting point for the random number sequence, and provides for restarting at the same point) is also an argument. .I Initstate returns a pointer to the previous state information array. .PP Once a state has been initialized, the .I setstate routine provides for rapid switching between states. .I Setstate returns a pointer to the previous state array; its argument state array is used for further random number generation until the next call to .I initstate or .I setstate. .PP Once a state array has been initialized, it may be restarted at a different point either by calling .I initstate (with the desired seed, the state array, and its size) or by calling both .I setstate (with the state array) and .I srandom (with the desired seed). The advantage of calling both .I setstate and .I srandom is that the size of the state array does not have to be remembered after it is initialized. .PP With 256 bytes of state information, the period of the random number generator is greater than .if t 2\u\s769\s10\d, .if n 2**69 which should be sufficient for most purposes. .SH AUTHOR Earl T. Cohen .SH DIAGNOSTICS .PP If .I initstate is called with less than 8 bytes of state information, or if .I setstate detects that the state information has been garbled, error messages are printed on the standard error output. .SH "SEE ALSO" rand(3) .SH BUGS About 2/3 the speed of .IR rand (3C). ================================================ FILE: share/man/man3/rcmd.3 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)rcmd.3 6.7 (Berkeley) 5/14/86 .\" .TH RCMD 3 "May 14, 1986" .UC 5 .SH NAME rcmd, rresvport, ruserok \- routines for returning a stream to a remote command .SH SYNOPSIS .nf .PP .B "rem = rcmd(ahost, inport, locuser, remuser, cmd, fd2p);" .B char **ahost; .B int inport; .B "char *locuser, *remuser, *cmd;" .B int *fd2p; .PP .B s = rresvport(port); .B int *port; .PP .B "ruserok(rhost, superuser, ruser, luser);" .B char *rhost; .B int superuser; .B char *ruser, *luser; .fi .SH DESCRIPTION .I Rcmd is a routine used by the super-user to execute a command on a remote machine using an authentication scheme based on reserved port numbers. .I Rresvport is a routine which returns a descriptor to a socket with an address in the privileged port space. .I Ruserok is a routine used by servers to authenticate clients requesting service with .IR rcmd . All three functions are present in the same file and are used by the .IR rshd (8C) server (among others). .PP .I Rcmd looks up the host .I *ahost using .IR gethostbyname (3N), returning \-1 if the host does not exist. Otherwise .I *ahost is set to the standard name of the host and a connection is established to a server residing at the well-known Internet port .IR inport . .PP If the connection succeeds, a socket in the Internet domain of type SOCK_STREAM is returned to the caller, and given to the remote command as .B stdin and .BR stdout . If .I fd2p is non-zero, then an auxiliary channel to a control process will be set up, and a descriptor for it will be placed in .IR *fd2p . The control process will return diagnostic output from the command (unit 2) on this channel, and will also accept bytes on this channel as being UNIX signal numbers, to be forwarded to the process group of the command. If .I fd2p is 0, then the .B stderr (unit 2 of the remote command) will be made the same as the .B stdout and no provision is made for sending arbitrary signals to the remote process, although you may be able to get its attention by using out-of-band data. .PP The protocol is described in detail in .IR rshd (8C). .PP The .I rresvport routine is used to obtain a socket with a privileged address bound to it. This socket is suitable for use by .I rcmd and several other routines. Privileged Internet ports are those in the range 0 to 1023. Only the super-user is allowed to bind an address of this sort to a socket. .PP .I Ruserok takes a remote host's name, as returned by a .IR gethostbyaddr (3N) routine, two user names and a flag indicating whether the local user's name is that of the super-user. It then checks the files .I /etc/hosts.equiv and, possibly, .I .rhosts in the current working directory (normally the local user's home directory) to see if the request for service is allowed. A 0 is returned if the machine name is listed in the ``hosts.equiv'' file, or the host and remote user name are found in the ``.rhosts'' file; otherwise .I ruserok returns \-1. If the .I superuser flag is 1, the checking of the ``host.equiv'' file is bypassed. If the local domain (as obtained from \fIgethostname\fP\|(2)) is the same as the remote domain, only the machine name need be specified. .SH SEE ALSO rlogin(1C), rsh(1C), intro(2), rexec(3), rexecd(8C), rlogind(8C), rshd(8C) .SH DIAGNOSTICS .I Rcmd returns a valid socket descriptor on success. It returns -1 on error and prints a diagnostic message on the standard error. .PP .I Rresvport returns a valid, bound socket descriptor on success. It returns -1 on error with the global value .I errno set according to the reason for failure. The error code EAGAIN is overloaded to mean ``All network ports in use.'' ================================================ FILE: share/man/man3/regex.3 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)regex.3 6.1 (Berkeley) 5/15/85 .\" .TH REGEX 3 "May 15, 1985" .UC .SH NAME re_comp, re_exec \- regular expression handler .SH SYNOPSIS .B char *re_comp(s) .br .B char *s; .PP .B re_exec(s) .br .B char *s; .SH DESCRIPTION .I Re_comp compiles a string into an internal form suitable for pattern matching. .I Re_exec checks the argument string against the last string passed to .I re_comp. .PP .I Re_comp returns 0 if the string .I s was compiled successfully; otherwise a string containing an error message is returned. If .I re_comp is passed 0 or a null string, it returns without changing the currently compiled regular expression. .PP .I Re_exec returns 1 if the string .I s matches the last compiled regular expression, 0 if the string .I s failed to match the last compiled regular expression, and \-1 if the compiled regular expression was invalid (indicating an internal error). .PP The strings passed to both .I re_comp and .I re_exec may have trailing or embedded newline characters; they are terminated by nulls. The regular expressions recognized are described in the manual entry for .IR ed (1), given the above difference. .SH "SEE ALSO" ed(1), ex(1), egrep(1), fgrep(1), grep(1) .SH DIAGNOSTICS .I Re_exec returns \-1 for an internal error. .PP .I Re_comp returns one of the following strings if an error occurs: .PP .nf .in +0.5i \fINo previous regular expression, Regular expression too long, unmatched \e(, missing ], too many \e(\e) pairs, unmatched \e).\fP .in -0.5i .fi ================================================ FILE: share/man/man3/resolver.3 ================================================ .\" Copyright (c) 1985 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)resolver.3 6.1 (Berkeley) 11/21/87 .\" .TH RESOLVER 3 "November 21, 1987" .UC 4 .SH NAME res_mkquery, res_send, res_init, dn_comp, dn_expand \- resolver routines .SH SYNOPSIS .B #include .br .B #include .br .B #include .br .B #include .PP .B "res_mkquery(op, dname, class, type, data, datalen, newrr, buf, buflen)" .br .B int op; .br .B char *dname; .br .B int class, type; .br .B char *data; .br .B int datalen; .br .B struct rrec *newrr; .br .B char *buf; .br .B int buflen; .PP .B res_send(msg, msglen, answer, anslen) .br .B char *msg; .br .B int msglen; .br .B char *answer; .br .B int anslen; .PP .B res_init() .PP .B dn_comp(exp_dn, comp_dn, length, dnptrs, lastdnptr) .br .B char *exp_dn, *comp_dn; .br .B int length; .br .B char **dnptrs, **lastdnptr; .PP .B dn_expand(msg, eomorig, comp_dn, exp_dn, length) .br .B char *msg, *eomorig, *comp_dn, exp_dn; .br .B int length; .SH DESCRIPTION These routines are used for making, sending and interpreting packets for use with Internet domain name servers. Global information that is used by the resolver routines is kept in the variable .IR _res . Most of the values have reasonable defaults and can be ignored. Options stored in .I _res.options are defined in .I resolv.h and are as follows. Options are stored a simple bit mask containing the bitwise ``or'' of the options enabled. .IP RES_INIT True if the initial name server address and default domain name are initialized (i.e., .I res_init has been called). .IP RES_DEBUG Print debugging messages. .IP RES_AAONLY Accept authoritative answers only. With this option, .I res_send should continue until it finds an authoritative answer or finds an error. Currently this is not implemented. .IP RES_USEVC Use TCP connections for queries instead of UDP datagrams. .IP RES_STAYOPEN Used with RES_USEVC to keep the TCP connection open between queries. This is useful only in programs that regularly do many queries. UDP should be the normal mode used. .IP RES_IGNTC Unused currently (ignore truncation errors, i.e., don't retry with TCP). .IP RES_RECURSE Set the recursion-desired bit in queries. This is the default. ( .I res_send does not do iterative queries and expects the name server to handle recursion.) .IP RES_DEFNAMES If set, .I res_mkquery will append the default domain name to single-component names (those that do not contain a dot). This is the default. .IP RES_DNSRCH If this option is set, the standard host lookup routine .IR gethostbyname (3) will search for host names in the current domain and in parent domains; see .IR hostname (7). .PP .I Res_init .PP reads the initialization file to get the default domain name and the Internet address of the initial hosts running the name server. If this line does not exist, the host running the resolver is tried. .I Res_mkquery makes a standard query message and places it in .IR buf . .I Res_mkquery will return the size of the query or \-1 if the query is larger than .IR buflen . .I Op is usually QUERY but can be any of the query types defined in .IR nameser.h . .I Dname is the domain name. If .I dname consists of a single label and the RES_DEFNAMES flag is enabled (the default), the current domain name will be appended to .IR dname . The current domain name is defined by the hostname or is specified in a system file; it can be overridden by the environment variable LOCALDOMAIN. .I Newrr is currently unused but is intended for making update messages. .PP .I Res_send sends a query to name servers and returns an answer. It will call .I res_init if RES_INIT is not set, send the query to the local name server, and handle timeouts and retries. The length of the message is returned, or \-1 if there were errors. .PP .I Dn_expand expands the compressed domain name .I comp_dn to a full domain name. Expanded names are converted to upper case. .I Msg is a pointer to the beginning of the message, .I exp_dn is a pointer to a buffer of size .I length for the result. The size of compressed name is returned or -1 if there was an error. .PP .I Dn_comp compresses the domain name .I exp_dn and stores it in .IR comp_dn . The size of the compressed name is returned or -1 if there were errors. .I length is the size of the array pointed to by .IR comp_dn . .I Dnptrs is a list of pointers to previously compressed names in the current message. The first pointer points to to the beginning of the message and the list ends with NULL. .I lastdnptr is a pointer to the end of the array pointed to .IR dnptrs . A side effect is to update the list of pointers for labels inserted into the message by .I dn_comp as the name is compressed. If .I dnptr is NULL, names are not compressed. If .I lastdnptr is NULL, the list of labels is not updated. .SH FILES /etc/resolv.conf see resolver(5) .SH "SEE ALSO" gethostbyname(3), named(8), resolver(5), hostname(7), .br RFC882, RFC883, RFC973, RFC974, .br SMM:11 Name Server Operations Guide for BIND ================================================ FILE: share/man/man3/rexec.3 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)rexec.3 6.5 (Berkeley) 5/14/86 .\" .TH REXEC 3 "May 14, 1986" .UC 5 .SH NAME rexec \- return stream to a remote command .SH SYNOPSIS .nf .PP .B "rem = rexec(ahost, inport, user, passwd, cmd, fd2p);" .B char **ahost; .B int inport; .B "char *user, *passwd, *cmd;" .B int *fd2p; .fi .SH DESCRIPTION .I Rexec looks up the host .I *ahost using .IR gethostbyname (3N), returning \-1 if the host does not exist. Otherwise .I *ahost is set to the standard name of the host. If a username and password are both specified, then these are used to authenticate to the foreign host; otherwise the environment and then the user's .I .netrc file in his home directory are searched for appropriate information. If all this fails, the user is prompted for the information. .PP The port .I inport specifies which well-known DARPA Internet port to use for the connection; the call ``getservbyname("exec", "tcp")'' (see .IR getservent (3N)) will return a pointer to a structure, which contains the necessary port. The protocol for connection is described in detail in .IR rexecd (8C). .PP If the connection succeeds, a socket in the Internet domain of type SOCK_STREAM is returned to the caller, and given to the remote command as .B stdin and .BR stdout . If .I fd2p is non-zero, then an auxiliary channel to a control process will be setup, and a descriptor for it will be placed in .IR *fd2p . The control process will return diagnostic output from the command (unit 2) on this channel, and will also accept bytes on this channel as being UNIX signal numbers, to be forwarded to the process group of the command. The diagnostic information returned does not include remote authorization failure, as the secondary connection is set up after authorization has been verified. If .I fd2p is 0, then the .B stderr (unit 2 of the remote command) will be made the same as the .B stdout and no provision is made for sending arbitrary signals to the remote process, although you may be able to get its attention by using out-of-band data. .SH SEE ALSO rcmd(3), rexecd(8C) ================================================ FILE: share/man/man3/scandir.3 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)scandir.3 6.2 (Berkeley) 9/17/85 .\" .TH SCANDIR 3 "September 17, 1985" .UC 5 .SH NAME scandir, alphasort \- scan a directory .SH SYNOPSIS .nf .B #include .B #include .PP .B scandir(dirname, namelist, select, compar) .B char *dirname; .B struct direct *(*namelist[]); .B int (*select)(); .B int (*compar)(); .PP .B alphasort(d1, d2) .B struct direct **d1, **d2; .fi .SH DESCRIPTION .I Scandir reads the directory .I dirname and builds an array of pointers to directory entries using .IR malloc (3). It returns the number of entries in the array and a pointer to the array through .IR namelist . .PP The .I select parameter is a pointer to a user supplied subroutine which is called by .I scandir to select which entries are to be included in the array. The select routine is passed a pointer to a directory entry and should return a non-zero value if the directory entry is to be included in the array. If .I select is null, then all the directory entries will be included. .PP The .I compar parameter is a pointer to a user supplied subroutine which is passed to .IR qsort (3) to sort the completed array. If this pointer is null, the array is not sorted. .I Alphasort is a routine which can be used for the .I compar parameter to sort the array alphabetically. .PP The memory allocated for the array can be deallocated with .I free (see .IR malloc (3)) by freeing each pointer in the array and the array itself. .SH "SEE ALSO" directory(3), malloc(3), qsort(3), dir(5) .SH DIAGNOSTICS Returns \-1 if the directory cannot be opened for reading or if .IR malloc (3) cannot allocate enough memory to hold all the data structures. ================================================ FILE: share/man/man3/scanf.3 ================================================ .\" @(#)scanf.3s 6.1 (Berkeley) 5/15/85 .\" .TH SCANF 3S "May 15, 1985" .AT 3 .SH NAME scanf, fscanf, sscanf \- formatted input conversion .SH SYNOPSIS .B #include .PP .B scanf(format [ , pointer ] . . . .B ) .br .B char *format; .PP .B fscanf(stream, format [ , pointer ] . . . .B ) .br .SM .B FILE .B *stream; .br .B char *format; .PP .B sscanf(s, format [ , pointer ] . . . .B ) .br .B char *s, *format; .SH DESCRIPTION .I Scanf reads from the standard input stream .BR stdin . .I Fscanf reads from the named input .IR stream . .I Sscanf reads from the character string .IR s . Each function reads characters, interprets them according to a format, and stores the results in its arguments. Each expects as arguments a control string .IR format , described below, and a set of .I pointer arguments indicating where the converted input should be stored. .PP The control string usually contains conversion specifications, which are used to direct interpretation of input sequences. The control string may contain: .TP 4 1. Blanks, tabs or newlines, which match optional white space in the input. .TP 4 2. An ordinary character (not %) which must match the next character of the input stream. .TP 4 3. Conversion specifications, consisting of the character .BR % , an optional assignment suppressing character .BR * , an optional numerical maximum field width, and a conversion character. .PP A conversion specification directs the conversion of the next input field; the result is placed in the variable pointed to by the corresponding argument, unless assignment suppression was indicated by .BR * . An input field is defined as a string of non-space characters; it extends to the next inappropriate character or until the field width, if specified, is exhausted. .PP The conversion character indicates the interpretation of the input field; the corresponding pointer argument must usually be of a restricted type. The following conversion characters are legal: .TP 4 .B % a single `%' is expected in the input at this point; no assignment is done. .TP 4 .B d a decimal integer is expected; the corresponding argument should be an integer pointer. .TP 4 .B o an octal integer is expected; the corresponding argument should be a integer pointer. .TP 4 .B x a hexadecimal integer is expected; the corresponding argument should be an integer pointer. .ti -0.2i .TP 4 .B s a character string is expected; the corresponding argument should be a character pointer pointing to an array of characters large enough to accept the string and a terminating `\e0', which will be added. The input field is terminated by a space character or a newline. .TP 4 .B c a character is expected; the corresponding argument should be a character pointer. The normal skip over space characters is suppressed in this case; to read the next non-space character, try `%1s'. If a field width is given, the corresponding argument should refer to a character array, and the indicated number of characters is read. .TP 4 \z\fBe\v'1'f\v'-1'\fR a floating point number is expected; the next field is converted accordingly and stored through the corresponding argument, which should be a pointer to a .IR float . The input format for floating point numbers is an optionally signed string of digits possibly containing a decimal point, followed by an optional exponent field consisting of an E or e followed by an optionally signed integer. .TP 4 .B [ indicates a string not to be delimited by space characters. The left bracket is followed by a set of characters and a right bracket; the characters between the brackets define a set of characters making up the string. If the first character is not circumflex (\|^\|), the input field is all characters until the first character not in the set between the brackets; if the first character after the left bracket is ^, the input field is all characters until the first character which is in the remaining set of characters between the brackets. The corresponding argument must point to a character array. .PP The conversion characters .BR d , .B o and .B x may be capitalized or preceded by .B l to indicate that a pointer to .B long rather than to .B int is in the argument list. Similarly, the conversion characters .B e or .B f may be capitalized or preceded by .B l to indicate a pointer to .B double rather than to .BR float . The conversion characters .BR d , .B o and .B x may be preceded by .B h to indicate a pointer to .B short rather than to .BR int . .PP The .I scanf functions return the number of successfully matched and assigned input items. This can be used to decide how many input items were found. The constant .SM .B EOF is returned upon end of input; note that this is different from 0, which means that no conversion was done; if conversion was intended, it was frustrated by an inappropriate character in the input. .PP For example, the call .IP "" 10 int i; float x; char name[50]; .br scanf("%d%f%s", &i, &x, name); .PP with the input line .IP 25 54.32E\(mi1 thompson .PP will assign to .I i the value 25, .I x the value 5.432, and .I name will contain .IR `thompson\e0' . Or, .IP int i; float x; char name[50]; .br scanf("%2d%f%*d%[1234567890]", &i, &x, name); .PP with input .IP 56789 0123 56a72 .PP will assign 56 to .IR i , 789.0 to .IR x , skip `0123', and place the string `56\e0' in .IR name . The next call to .I getchar will return `a'. .SH "SEE ALSO" atof(3), getc(3S), printf(3S) .SH DIAGNOSTICS The .I scanf functions return .SM .B EOF on end of input, and a short count for missing or illegal data items. .SH BUGS The success of literal matches and suppressed assignments is not directly determinable. ================================================ FILE: share/man/man3/setbuf.3 ================================================ .\" Copyright (c) 1980, 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" This code is derived from software contributed to Berkeley by .\" the American National Standards Committee X3, on Information .\" Processing Systems. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. All advertising materials mentioning features or use of this software .\" must display the following acknowledgement: .\" This product includes software developed by the University of .\" California, Berkeley and its contributors. .\" 4. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)setbuf.3 8.1.1 (2.11BSD) 1997/7/28 .\" .TH SETBUF 3 "July 28, 1997" .UC 4 .SH NAME .BR setbuf , .BR setbuffer , .BR setlinebuf , .BR setvbuf \-stream buffering operations .SH SYNOPSIS .nf .B #include .B #include .sp .B void \fBsetbuf\fP(\fIstream\fP, \fIbuf\fP) .SM \ \ \ \ \ \ \ FILE\ *stream; \ \ \ \ \ \ \ char\ *buf; .sp .B void \fBsetbuffer\fP(\fIstream\fP, \fIbuf\fP, \fIsize\fP) .SM \ \ \ \ \ \ \ FILE\ *stream; \ \ \ \ \ \ \ char\ *buf; \ \ \ \ \ \ \ size_t\ size; .sp .B int \fBsetlinebuf\fP(\fIstream\fP) .SM \ \ \ \ \ \ \ FILE\ *stream; .sp .B int .br \fBsetvbuf\fP(\fIstream\fP, \fIbuf\fP, \fImode\fP, \fIsize\fP) .SM \ \ \ \ \ \ \ FILE\ *stream; \ \ \ \ \ \ \ char\ *buf; \ \ \ \ \ \ \ int\ mode; \ \ \ \ \ \ \ size_t\ size .fi .SH DESCRIPTION The three types of buffering available are unbuffered, block buffered, and line buffered. When an output stream is unbuffered, information appears on the destination file or terminal as soon as written; when it is block buffered many characters are saved up and written as a block; when it is line buffered characters are saved up until a newline is output or input is read from any stream attached to a terminal device (typically stdin). The function fflush(3) may be used to force the block out early. (See fclose(3).) .PP Normally all files are block buffered. When the first I/O operation occurs on a file, malloc(3) is called, and an optimally-sized buffer is obtained. If a stream refers to a terminal (as .I stdout normally does) it is line buffered. The standard error stream .I stderr is always unbuffered. .PP The .B setvbuf function may be used to alter the buffering behavior of a stream. The .I mode parameter must be one of the following three macros: .PP .nf .ta .5i 1.5i _IONBF unbuffered .sp _IOLBF line buffered .sp _IOFBF fully buffered .fi .PP The .I size parameter may be given as zero to obtain deferred optimal-size buffer allocation as usual. If it is not zero, then except for unbuffered files, the .I buf argument should point to a buffer at least .I size bytes long; this buffer will be used instead of the current buffer. (If the .I size argument is not zero but .I buf is NULL, a buffer of the given size will be allocated immediately, and released on close. This is an extension to ANSI C; portable code should use a size of 0 with any NULL buffer.) .PP The .B setvbuf function may be used at any time, but may have peculiar side effects (such as discarding input or flushing output) if the stream is ``active''. Portable applications should call it only once on any given stream, and before any I/O is performed. .PP The other three calls are, in effect, simply aliases for calls to .BR setvbuf . Except for the lack of a return value, the .B setbuf function is exactly equivalent to the call .PP .in +0.5i setvbuf(stream, buf, buf ? _IOFBF : _IONBF, BUFSIZ); .in -0.5i .PP The .B setbuffer function is the same, except that the size of the buffer is up to the caller, rather than being determined by the default BUFSIZ. The .B setlinebuf function is exactly equivalent to the call: .PP .in +0.5i setvbuf(stream, (char *)NULL, _IOLBF, 0); .in -0.5i .SH RETURN VALUES The .B setvbuf function returns 0 on success, or EOF if the request cannot be honored (note that the stream is still functional in this case). .PP The .B setlinebuf function returns what the equivalent .B setvbuf would have returned. .SH SEE ALSO fopen(3), fclose(3), fread(3), malloc(3), puts(3), printf(3) .SH STANDARDS The .B setbuf and .B setvbuf functions conform to ANSI C X3.159\-1989 (``ANSI C''). .SH BUGS The .B setbuffer and .B setlinebuf functions are not portable to versions of BSD before 4.2BSD. On 2BSD systems, .B setbuf always uses a 1kb buffer size. ================================================ FILE: share/man/man3/setjmp.3 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)setjmp.3 6.2 (Berkeley) 1/9/86 .\" .TH SETJMP 3 "January 9, 1986" .UC 4 .SH NAME setjmp, longjmp \- non-local goto .SH SYNOPSIS .nf .B #include .PP .B setjmp(env) .B jmp_buf env; .PP .B longjmp(env, val) .B jmp_buf env; .PP .B _setjmp(env) .B jmp_buf env; .PP .B _longjmp(env, val) .B jmp_buf env; .fi .SH DESCRIPTION These routines are useful for dealing with errors and interrupts encountered in a low-level subroutine of a program. .PP .I Setjmp saves its stack environment in .I env for later use by .I longjmp. It returns value 0. .PP .I Longjmp restores the environment saved by the last call of .IR setjmp . It then returns in such a way that execution continues as if the call of .I setjmp had just returned the value .I val to the function that invoked .I setjmp, which must not itself have returned in the interim. All accessible data have values as of the time .I longjmp was called. .PP .I Setjmp and .I longjmp save and restore the signal mask .IR sigmask (2), while .I _setjmp and .I _longjmp manipulate only the C stack and registers. .SH ERRORS .PP If the contents of the .B jmp_buf are corrupted, or correspond to an environment that has already returned, .I longjmp calls the routine .IR longjmperror . If .I longjmperror returns the program is aborted. The default version of .I longjmperror prints the message ``longjmp botch'' to standard error and returns. User programs wishing to exit more gracefully can write their own versions of .IR longjmperror . .SH "SEE ALSO" sigvec(2), sigstack(2), signal(3) .SH "NOTES (PDP-11)" On the PDP-11, \fIlongjmperror\fP is called as \fI_ljerr\fP. This difference stems from the limited name size of the PDP-11 that requires all external names to be unique within the first seven characters. However, <\fIsetjmp.h\fP> automatically translates \fIlongjmperror\fP to \fIljerror\fP and should be included before any definition \fIlongjmperror\fP. .PP The PDP-11 implementation also contains a subtle bug that occurs when a routine containing a \fIsetjmp\fP has \fIregister\fP variables. The bug sometimes causes those variables to be given invalid values when a longjmp is made back to the routine. \fIRegister\fP variables should therefore be avoided in routines containing \fIsetjmps\fP. .PP And finally, _longjmp may sometimes die fatally. Sorry. ================================================ FILE: share/man/man3/setmode.3 ================================================ .\" Copyright (c) 1989, 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. All advertising materials mentioning features or use of this software .\" must display the following acknowledgement: .\" This product includes software developed by the University of .\" California, Berkeley and its contributors. .\" 4. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)setmode.3 8.2.1 (2.11BSD) 1996/2/20 .\" .TH SETMODE 3 "February 20, 1996" .UC 7 .SH NAME \fBgetmode\fP, \fBsetmode\fP \- modify mode bits .SH SYNOPSIS .B #include .sp .B mode_t .br \fBgetmode\fP(set, mode) .br .I void *set; .br .I mode_t mode; .sp .B void * .br \fBsetmode\fP(mode_str) .br .I char *mode_str; .SH DESCRIPTION The .B getmode function returns a copy of the file permission bits .I mode as altered by the values pointed to by .IR set . While only the mode bits are altered, other parts of the file mode may be examined. .PP The .B setmode function takes an absolute (octal) or symbolic value, as described in chmod(1), as an argument and returns a pointer to mode values to be supplied to .BR getmode . Because some of the symbolic values are relative to the file creation mask, .B setmode may call umask(2). If this occurs, the file creation mask will be restored before .B setmode returns. If the calling program changes the value of its file creation mask after calling .BR setmode , .B setmode must be called again if .B getmode is to modify future file modes correctly. .PP If the mode passed to .B setmode is invalid, .B setmode returns .BR NULL . .SH ERRORS The .B setmode function may fail and set errno for any of the errors specified for the library routine malloc(3). .SH SEE ALSO chmod(1), stat(2), umask(2), malloc(3) .SH HISTORY The .B getmode and .B setmode functions first appeared in 4.4BSD. ================================================ FILE: share/man/man3/setruid.3 ================================================ .\" Copyright (c) 1983, 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. All advertising materials mentioning features or use of this software .\" must display the following acknowledgement: .\" This product includes software developed by the University of .\" California, Berkeley and its contributors. .\" 4. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)setruid.3 8.1.1 (2.11BSD) 1997/12/3 .\" .TH SETRUID 3 "December 3, 1997" .UC 4 .SH NAME \fBsetruid\fP, \fBsetrgid\fP \- set user and group ID .SH SYNOPSIS .B #include .nf \fIint\fP \fBsetruid\fP(ruid) \ \ \ \ uid_t ruid .sp \fIint\fP \fBsetrgid\fP(rgid) \ \ \ \ gid_t rgid .fi .SH DESCRIPTION The .B setruid function (\fBsetrgid\fP) sets the real user ID (group ID) of the current process. .SH RETURN VALUES Upon success, these functions return 0; otherwise \-1 is returned. .PP If the user is not the super user, or the uid specified is not the real or effective ID, these functions return \-1. .PP The use of these calls is not portable. Their use is discouraged; they will be removed in the future. .SH SEE ALSO setuid(2), setgid(2), seteuid(2), setegid(2), getuid(2), getgid(2) .SH HISTORY The .B setruid and .B setrgid syscalls appeared in 4.2BSD and were dropped in 4.4BSD. ================================================ FILE: share/man/man3/siginterrupt.3 ================================================ .\" Copyright (c) 1985 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)siginterrupt.3 6.1 (Berkeley) 5/15/85 .\" .TH SIGINTERRUPT 3 "May 15, 1985" .UC 6 .SH NAME siginterrupt \- allow signals to interrupt system calls .SH SYNOPSIS .nf .B siginterrupt(sig, flag); .B int sig, flag; .SH DESCRIPTION .I Siginterrupt is used to change the system call restart behavior when a system call is interrupted by the specified signal. If the flag is false (0), then system calls will be restarted if they are interrupted by the specified signal and no data has been transferred yet. System call restart is the default behavior on 4.2 BSD. .PP If the flag is true (1), then restarting of system calls is disabled. If a system call is interrupted by the specified signal and no data has been transferred, the system call will return -1 with errno set to EINTR. Interrupted system calls that have started transferring data will return the amount of data actually transferred. System call interrupt is the signal behavior found on 4.1 BSD and AT&T System V UNIX systems. .PP Note that the new 4.2 BSD signal handling semantics are not altered in any other way. Most notably, signal handlers always remain installed until explicitly changed by a subsequent .IR sigvec (2) call, and the signal mask operates as documented in .IR sigvec (2). Programs may switch between restartable and interruptible system call operation as often as desired in the execution of a program. .PP Issuing a .IR siginterrupt (3) call during the execution of a signal handler will cause the new action to take place on the next signal to be caught. .SH NOTES This library routine uses an extension of the .IR sigvec (2) system call that is not available in 4.2BSD, hence it should not be used if backward compatibility is needed. .SH "RETURN VALUE A 0 value indicates that the call succeeded. A -1 value indicates that an invalid signal number has been supplied. .SH "SEE ALSO" sigvec(2), sigblock(2), sigpause(2), sigsetmask(2). ================================================ FILE: share/man/man3/signal.3 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)signal.3c 6.4 (Berkeley) 5/20/86 .\" .TH SIGNAL 3C "May 20, 1986" .UC 4 .ie t .ds d \(dg .el .ds d \z'|+' .ie t .ds b \(bu .el .ds b @ .SH NAME signal \- simplified software signal facilities .SH SYNOPSIS .nf .B #include .PP .B (*signal(sig, func))() .B int (*func)(); .fi .SH DESCRIPTION .I Signal is a simplified interface to the more general .IR sigvec (2) facility. .PP A signal is generated by some abnormal event, initiated by a user at a terminal (quit, interrupt, stop), by a program error (bus error, etc.), by request of another program (kill), or when a process is stopped because it wishes to access its control terminal while in the background (see .IR tty (4)). Signals are optionally generated when a process resumes after being stopped, when the status of child processes changes, or when input is ready at the control terminal. Most signals cause termination of the receiving process if no action is taken; some signals instead cause the process receiving them to be stopped, or are simply discarded if the process has not requested otherwise. Except for the SIGKILL and SIGSTOP signals, the .I signal call allows signals either to be ignored or to cause an interrupt to a specified location. The following is a list of all signals with names as in the include file .RI < signal.h >: .LP .nf .ta \w'SIGVTALRM 'u +\w'15* 'u SIGHUP 1 hangup SIGINT 2 interrupt SIGQUIT 3* quit SIGILL 4* illegal instruction SIGTRAP 5* trace trap SIGIOT 6* IOT instruction SIGEMT 7* EMT instruction SIGFPE 8* floating point exception SIGKILL 9 kill (cannot be caught or ignored) SIGBUS 10* bus error SIGSEGV 11* segmentation violation SIGSYS 12* bad argument to system call SIGPIPE 13 write on a pipe with no one to read it SIGALRM 14 alarm clock SIGTERM 15 software termination signal SIGURG 16\*b urgent condition present on socket SIGSTOP 17\*d stop (cannot be caught or ignored) SIGTSTP 18\*d stop signal generated from keyboard SIGCONT 19\*b continue after stop SIGCHLD 20\*b child status has changed SIGTTIN 21\*d background read attempted from control terminal SIGTTOU 22\*d background write attempted to control terminal SIGIO 23\*b i/o is possible on a descriptor (see \fIfcntl\fP(2)) SIGXCPU 24 cpu time limit exceeded (see \fIsetrlimit\fP(2)) SIGXFSZ 25 file size limit exceeded (see \fIsetrlimit\fP(2)) SIGVTALRM 26 virtual time alarm (see \fIsetitimer\fP(2)) SIGPROF 27 profiling timer alarm (see \fIsetitimer\fP(2)) SIGWINCH 28\*b Window size change SIGUSR1 30 User defined signal 1 SIGUSR2 31 User defined signal 2 .fi .PP The starred signals in the list above cause a core image if not caught or ignored. .PP If .I func is SIG_DFL, the default action for signal .I sig is reinstated; this default is termination (with a core image for starred signals) except for signals marked with \*b or \*d. Signals marked with \*b are discarded if the action is SIG_DFL; signals marked with \*d cause the process to stop. If .I func is SIG_IGN the signal is subsequently ignored and pending instances of the signal are discarded. Otherwise, when the signal occurs further occurrences of the signal are automatically blocked and .I func is called. .PP A return from the function unblocks the handled signal and continues the process at the point it was interrupted. \fBUnlike previous signal facilities, the handler \fIfunc\fP remains installed after a signal has been delivered.\fP .PP If a caught signal occurs during certain system calls, causing the call to terminate prematurely, the call is automatically restarted. In particular this can occur during a .I read or .IR write (2) on a slow device (such as a terminal; but not a file) and during a .IR wait (2). .PP The value of .I signal is the previous (or initial) value of .I func for the particular signal. .PP After a .IR fork (2) or .IR vfork (2) the child inherits all signals. .IR Execve (2) resets all caught signals to the default action; ignored signals remain ignored. .SH "RETURN VALUE The previous action is returned on a successful call. Otherwise, \-1 is returned and .I errno is set to indicate the error. .SH ERRORS .I Signal will fail and no action will take place if one of the following occur: .TP 15 [EINVAL] .I Sig is not a valid signal number. .TP 15 [EINVAL] An attempt is made to ignore or supply a handler for SIGKILL or SIGSTOP. .TP 15 [EINVAL] An attempt is made to ignore SIGCONT (by default SIGCONT is ignored). .SH "SEE ALSO" kill(1), ptrace(2), kill(2), sigvec(2), sigblock(2), sigsetmask(2), sigpause(2), sigstack(2), setjmp(3), tty(4) .SH "NOTES (VAX-11)" The handler routine can be declared: .PP handler(sig, code, scp) .PP Here .I sig is the signal number, into which the hardware faults and traps are mapped as defined below. Code is a parameter which is either a constant as given below or, for compatibility mode faults, the code provided by the hardware. .I Scp is a pointer to the .I "struct sigcontext" used by the system to restore the process context from before the signal. Compatibility mode faults are distinguished from the other SIGILL traps by having PSL_CM set in the psl. .PP The following defines the mapping of hardware traps to signals and codes. All of these symbols are defined in .RI < signal.h >: .LP .ta \w' Floating/decimal divide by zero 'u +\w'15* 'u +8n .nf Hardware condition Signal Code Arithmetic traps: Integer overflow SIGFPE FPE_INTOVF_TRAP Integer division by zero SIGFPE FPE_INTDIV_TRAP Floating overflow trap SIGFPE FPE_FLTOVF_TRAP Floating/decimal division by zero SIGFPE FPE_FLTDIV_TRAP Floating underflow trap SIGFPE FPE_FLTUND_TRAP Decimal overflow trap SIGFPE FPE_DECOVF_TRAP Subscript-range SIGFPE FPE_SUBRNG_TRAP Floating overflow fault SIGFPE FPE_FLTOVF_FAULT Floating divide by zero fault SIGFPE FPE_FLTDIV_FAULT Floating underflow fault SIGFPE FPE_FLTUND_FAULT Length access control SIGSEGV Protection violation SIGBUS Reserved instruction SIGILL ILL_RESAD_FAULT Customer-reserved instr. SIGEMT Reserved operand SIGILL ILL_PRIVIN_FAULT Reserved addressing SIGILL ILL_RESOP_FAULT Trace pending SIGTRAP Bpt instruction SIGTRAP Compatibility-mode SIGILL hardware supplied code Chme SIGSEGV Chms SIGSEGV Chmu SIGSEGV .fi .SH "NOTES (PDP-11)" The handler routine can be declared: .PP handler(sig, code, scp) int sig, code; struct sigcontext *scp; .PP Here \fIsig\fP is the signal number, into which the hardware faults and traps are mapped as defined below. \fICode\fP is a parameter that is a constant as given below. \fIScp\fP is a pointer to the \fIsigcontext\fP structure (defined in <\fIsignal.h\fP>), used to restore the context from before the signal. .PP The following defines the mapping of hardware traps to signals and codes. All of these symbols are defined in <\fIsignal.h\fP>: .LP .ta \w' Floating/decimal divide by zero 'u +\w'15* 'u +8n .nf Hardware condition Signal Code Arithmetic traps: Floating overflow trap SIGFPE FPE_FLTOVF_TRAP Floating/decimal division by zero SIGFPE FPE_FLTDIV_TRAP Floating underflow trap SIGFPE FPE_FLTUND_TRAP Decimal overflow trap SIGFPE FPE_DECOVF_TRAP Illegal return code SIGFPE FPE_CRAZY Bad op code SIGFPE FPE_OPCODE_TRAP Bad operand SIGFPE FPE_OPERAND_TRAP Maintenance trap SIGFPE FPE_MAINT_TRAP Length access control SIGSEGV Protection violation (odd address) SIGBUS Reserved instruction SIGILL ILL_RESAD_FAULT Customer-reserved instr. SIGEMT Trace pending SIGTRAP Bpt instruction SIGTRAP .fi .DT .PP The handler routine must save any registers it uses and restore them before returning. On the PDP-11, the kernel saves \fIr0\fP and \fIr1\fP before calling the handler routine, but expect the handler to save any other registers it uses. The standard entry code generated by the C compiler for handler routines written in C automatically saves the remaining general registers, but floating point registers are \fInot\fP saved. As a result there is currently no [standard] method for a handler routine written in C to perform floating point operations without blowing the interrupted program out of the water. ================================================ FILE: share/man/man3/sigsetops.3 ================================================ .\" Copyright (c) 1983, 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. All advertising materials mentioning features or use of this software .\" must display the following acknowledgement: .\" This product includes software developed by the University of .\" California, Berkeley and its contributors. .\" 4. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)sigsetops.3 8.1.1 (2.11BSD) 1997/9/3 .\" .TH SIGSETOPS 3 "September 3, 1997" .UC 7 .SH NAME .BR sigemptyset , .BR sigfillset , .BR sigaddset , .BR sigdelset , .BR sigismember \- manipulate signal sets .SH SYNOPSIS .B #include .sp \fBsigemptyset\fP(set) .br .I sigset_t *set; .sp \fBsigfillset\fP(set) .br .I sigset_t *set; .sp \fBsigaddset\fP(set, signo) .br .I sigset_t *set; .br .I int signo; .sp \fBsigdelset\fP(set, signo) .br .I sigset_t *set; .br .I int signo; .sp \fBsigismember\fP(set, signo) .br .I sigset_t *set; .br .I int signo; .SH DESCRIPTION These functions manipulate signal sets stored in a .I sigset_t . Either .B sigemptyset or .B sigfillset must be called for every object of type .I sigset_t before any other use of the object. .PP The .B sigemptyset function initializes a signal set to be empty. .PP The .B sigfillset function initializes a signal set to contain all signals. .PP The .B sigaddset function adds the specified signal .I signo to the signal set. .PP The .B sigdelset function deletes the specified signal .I signo from the signal set. .PP The .B sigismember function returns whether a specified signal .I signo is contained in the signal set. .PP These functions are provided as macros in the include file .RI < signal.h >. Actual functions are available if their names are undefined (with #undef \fBname\fP). .SH RETURN VALUES The .B sigismember function returns 1 if the signal is a member of the set, 0 otherwise. The other functions return 0. .SH ERRORS Currently no errors are detected. .SH SEE ALSO kill(2), sigaction(2), sigsuspend(2) .SH STANDARDS These functions are defined by IEEE Std1003.1-1988 (``POSIX''). ================================================ FILE: share/man/man3/sin.3 ================================================ .\" Copyright (c) 1985 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)sin.3m 6.6 (Berkeley) 5/12/86 .\" .TH SIN 3M "May 12, 1986" .UC 4 .de Pi \" PI stuff sign .if n \\ \\$2pi\\$1 .if t \\ \\$2\\(*p\\$1 .. .ds up \fIulp\fR .SH NAME sin, cos, tan, asin, acos, atan, atan2 \- trigonometric functions and their inverses .SH SYNOPSIS .nf .B #include .PP .B double sin(x) .B double x; .PP .B double cos(x) .B double x; .PP .B double tan(x) .B double x; .PP .B double asin(x) .B double x; .PP .B double acos(x) .B double x; .PP .B double atan(x) .B double x; .PP .B double atan2(y,x) .B double y,x; .fi .SH DESCRIPTION Sin, cos and tan return trigonometric functions of radian arguments x. .PP Asin returns the arc sine in the range .Pi /2 \- to .Pi /2. .PP Acos returns the arc cosine in the range 0 to .Pi . .PP Atan returns the arc tangent in the range .Pi /2 \- to .Pi /2. .PP On a VAX, .nf .if n \{\ .ta \w'atan2(y,x) := 'u+2n +\w'sign(y)\(**(pi \- atan(|y/x|))'u+2n atan2(y,x) := atan(y/x) if x > 0, sign(y)\(**(pi \- atan(|y/x|)) if x < 0, 0 if x = y = 0, or sign(y)\(**pi/2 if x = 0 != y. \} .if t \{\ .ta \w'atan2(y,x) := 'u+2n +\w'sign(y)\(**(\(*p \- atan(|y/x|))'u+2n atan2(y,x) := atan(y/x) if x > 0, sign(y)\(**(\(*p \- atan(|y/x|)) if x < 0, 0 if x = y = 0, or sign(y)\(**\(*p/2 if x = 0 \(!= y. \} .ta .fi .SH DIAGNOSTICS On a VAX, if |x| > 1 then asin(x) and acos(x) will return reserved operands and \fIerrno\fR will be set to EDOM. .SH NOTES Atan2 defines atan2(0,0) = 0 on a VAX despite that previously atan2(0,0) may have generated an error message. The reasons for assigning a value to atan2(0,0) are these: .IP (1) \w'\0\0\0\0'u Programs that test arguments to avoid computing atan2(0,0) must be indifferent to its value. Programs that require it to be invalid are vulnerable to diverse reactions to that invalidity on diverse computer systems. .IP (2) \w'\0\0\0\0'u Atan2 is used mostly to convert from rectangular (x,y) to polar .if n\ (r,theta) .if t\ (r,\(*h) coordinates that must satisfy x = .if n\ r\(**cos theta .if t\ r\(**cos\(*h and y = .if n\ r\(**sin theta. .if t\ r\(**sin\(*h. These equations are satisfied when (x=0,y=0) is mapped to .if n \ (r=0,theta=0) .if t \ (r=0,\(*h=0) on a VAX. In general, conversions to polar coordinates should be computed thus: .nf .ta 1iR +1n +\w' := hypot(x,y);'u+0.5i .if n \{\ r := hypot(x,y); ... := sqrt(x\(**x+y\(**y) theta := atan2(y,x). .ta \} .if t \{\ r := hypot(x,y); ... := \(sr(x\u\s82\s10\d+y\u\s82\s10\d) \(*h := atan2(y,x). .ta \} .fi .IP (3) \w'\0\0\0\0'u The foregoing formulas need not be altered to cope in a reasonable way with signed zeros and infinities on a machine that conforms to IEEE 754; the versions of hypot and atan2 provided for such a machine are designed to handle all cases. That is why atan2(\(+-0,\-0) = .Pi , \(+- for instance. In general the formulas above are equivalent to these: .RS .nf .if n \ r := sqrt(x\(**x+y\(**y); if r = 0 then x := copysign(1,x); .if t \ r := \(sr(x\(**x+y\(**y);\0\0if r = 0 then x := copysign(1,x); .br .if n \ .ta 1i .if t \ .ta \w'if x > 0'u+2n +\w'then'u+2n .if n \ if x > 0 then theta := 2\(**atan(y/(r+x)) .if t \ if x > 0 then \(*h := 2\(**atan(y/(r+x)) .if n \ else theta := 2\(**atan((r\-x)/y); .if t \ else \(*h := 2\(**atan((r\-x)/y); .fi .RE except if r is infinite then atan2 will yield an appropriate multiple of .Pi /4 that would otherwise have to be obtained by taking limits. .SH ERROR (due to Roundoff etc.) Let P stand for the number stored in the computer in place of .Pi " = 3.14159 26535 89793 23846 26433 ... ." Let "trig" stand for one of "sin", "cos" or "tan". Then the expression "trig(x)" in a program actually produces an approximation to .Pi /P), trig(x\(** and "atrig(x)" approximates .Pi )\(**atrig(x). (P/ The approximations are close, within 0.9 \*(ups for sin, cos and atan, within 2.2 \*(ups for tan, asin, acos and atan2 on a VAX. Moreover, .Pi \& "P = " in the codes that run on a VAX. In the codes that run on other machines, P differs from .Pi by a fraction of an \*(up; the difference matters only if the argument x is huge, and even then the difference is likely to be swamped by the uncertainty in x. Besides, every trigonometric identity that does not involve .Pi explicitly is satisfied equally well regardless of whether .Pi . "P = " For instance, .if n \ sin(x)**2+cos(x)**2\0=\01 .if t \ sin\u\s62\s10\d(x)+cos\u\s62\s10\d(x)\0=\01 and sin(2x)\0=\02\|sin(x)cos(x) to within a few \*(ups no matter how big x may be. Therefore the difference between P and .Pi is most unlikely to affect scientific and engineering computations. .SH SEE ALSO math(3M), hypot(3M), sqrt(3M), infnan(3M) .SH AUTHOR Robert P. Corbett, W. Kahan, Stuart\0I.\0McDonald, Peter\0Tang and, for the codes for IEEE 754, Dr. Kwok\-Choi\0Ng. ================================================ FILE: share/man/man3/sinh.3 ================================================ .\" Copyright (c) 1985 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)sinh.3m 6.5 (Berkeley) 5/12/86 .\" .TH SINH 3M "May 12, 1986" .UC 4 .SH NAME sinh, cosh, tanh \- hyperbolic functions .SH SYNOPSIS .nf .B #include .PP .B double sinh(x) .B double x; .PP .B double cosh(x) .B double x; .PP .B double tanh(x) .B double x; .fi .SH DESCRIPTION These functions compute the designated hyperbolic functions for real arguments. .SH ERROR (due to Roundoff etc.) Below 2.4 \fIulp\fRs; an \fIulp\fR is one \fIU\fRnit in the \fIL\fRast \fIP\fRlace. .SH DIAGNOSTICS Sinh and cosh return the reserved operand on a VAX if the correct value would overflow. .SH SEE ALSO math(3M), infnan(3M) .SH AUTHOR W. Kahan, Kwok\-Choi Ng ================================================ FILE: share/man/man3/sleep.3 ================================================ .\" Copyright (c) 1986, 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. All advertising materials mentioning features or use of this software .\" must display the following acknowledgement: .\" This product includes software developed by the University of .\" California, Berkeley and its contributors. .\" 4. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)sleep.3 8.1.1 (2.11BSD) 1997/9/26 .\" .TH SLEEP 3 "September 26, 1997" .UC 3 .SH NAME \fBsleep\fP, usleep \- suspend process execution .SH SYNOPSIS .B #include .sp .nf unsigned int sleep(seconds) unsigned int seconds; .sp void usleep(microseconds) long microseconds; .fi .SH DESCRIPTION The .B sleep function suspends execution of the calling process for .I seconds of clock time, or until interrupted by a signal. .PP The .B usleep function suspends execution of the calling process for .I microseconds of clock time, or until interrupted by a signal. .PP System activity may lengthen the suspension. .SH RETURN VALUES The .B sleep function returns 0, or if interrupted before .IR seconds, the amount not slept (the requested time minus the time actually slept) in seconds. The .B usleep function does not return anything (meaningful). .SH SEE ALSO select(2) .SH COMPATIBILITY Previous implementations of .B sleep and .B usleep re-suspended the process if interrupted by a signal. This implementation has been changed to return in that case, to conform to POSIX 1003.1-88. .PP On the PDP-11 the previous version of \fBusleep\fP took a \fIu_int\fP as the input parameter. This has been changed to be \fIlong\fP so that \fBusleep\fP can be used for more than 65 milliseconds (a u_int could only count 65535 microseconds) of sleep. Thus it is now possible for \fBusleep\fP to handle longer sleep durations than \fBsleep\fP. .SH BUGS On the PDP-11 the clock resolution is limited to the line frequency (usually 60Hz in the U.S.A. and 50Hz elsewhere). .SH HISTORY A .B usleep function appeared in 4.3BSD. A .B sleep function appeared in V7. ================================================ FILE: share/man/man3/sqrt.3 ================================================ .\" Copyright (c) 1985 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)sqrt.3m 6.2 (Berkeley) 5/12/86 .\" .TH SQRT 3M "May 12, 1986" .UC 6 .ds up \fIulp\fR .SH NAME cbrt, sqrt \- cube root, square root .SH SYNOPSIS .nf .B #include .PP .B double cbrt(x) .B double x; .PP .B double sqrt(x) .B double x; .fi .SH DESCRIPTION Cbrt(x) returns the cube root of x. .PP Sqrt(x) returns the square root of x. .SH DIAGNOSTICS On a VAX, sqrt(negative) returns the reserved operand and sets \fIerrno\fR to EDOM . .SH ERROR (due to Roundoff etc.) Cbrt is accurate to within 0.7 \*(ups. .br Sqrt on a VAX is accurate to within 0.501 \*(ups. .br Sqrt on a machine that conforms to IEEE 754 is correctly rounded in accordance with the rounding mode in force; the error is less than half an \*(up in the default mode (round\-to\-nearest). An \*(up is one \fIU\fRnit in the \fIL\fRast \fIP\fRlace carried. .SH SEE ALSO math(3M), infnan(3M) .SH AUTHOR W. Kahan ================================================ FILE: share/man/man3/stdio.3 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)stdio.3s 6.2 (Berkeley) 5/13/86 .\" .TH STDIO 3S "May 13, 1986" .UC 4 .SH NAME stdio \- standard buffered input/output package .SH SYNOPSIS .B #include .PP .SM .B FILE .B *stdin; .br .SM .B FILE .B *stdout; .br .SM .B FILE .B *stderr; .SH DESCRIPTION The functions described in section 3S constitute a user-level buffering scheme. The in-line macros .I getc and .IR putc (3S) handle characters quickly. The higher level routines .IR gets , .IR fgets , .IR scanf , .IR fscanf , .IR fread , .IR puts , .IR fputs , .IR printf , .IR fprintf , .IR fwrite all use .I getc and .IR putc ; they can be freely intermixed. .PP A file with associated buffering is called a .IR stream , and is declared to be a pointer to a defined type .SM .BR FILE . .IR Fopen (3S) creates certain descriptive data for a stream and returns a pointer to designate the stream in all further transactions. There are three normally open streams with constant pointers declared in the include file and associated with the standard open files: .TP 10n .B stdin standard input file .br .ns .TP .B stdout standard output file .br .ns .TP .B stderr standard error file .PP A constant `pointer' .SM .B NULL (0) designates no stream at all. .PP An integer constant .SM .B EOF (\-1) is returned upon end of file or error by integer functions that deal with streams. .PP Any routine that uses the standard input/output package must include the header file .RI < stdio.h > of pertinent macro definitions. The functions and constants mentioned in sections labeled 3S are declared in the include file and need no further declaration. The constants, and the following `functions' are implemented as macros; redeclaration of these names is perilous: .IR getc , .IR getchar , .IR putc , .IR putchar , .IR feof , .IR ferror , .IR fileno . .SH "SEE ALSO" open(2), close(2), read(2), write(2), fread(3S), fseek(3S), f*(3S) .SH DIAGNOSTICS The value .SM .B EOF is returned uniformly to indicate that a .SM .B FILE pointer has not been initialized with .IR fopen , input (output) has been attempted on an output (input) stream, or a .SM .B FILE pointer designates corrupt or otherwise unintelligible .SM .B FILE data. .PP For purposes of efficiency, this implementation of the standard library has been changed to line buffer output to a terminal by default and attempts to do this transparently by flushing the output whenever a .IR read (2) from the standard input is necessary. This is almost always transparent, but may cause confusion or malfunctioning of programs which use standard i/o routines but use .IR read (2) themselves to read from the standard input. .PP In cases where a large amount of computation is done after printing part of a line on an output terminal, it is necessary to .IR fflush (3S) the standard output before going off and computing so that the output will appear. .SH BUGS The standard buffered functions do not interact well with certain other library and system functions, especially \fIvfork\fP and \fIabort\fP. .SH "LIST OF FUNCTIONS" .sp 2 .nf .ta \w'setlinebuf'u+2n +\w'setbuf.3s'u+10n \fIName\fP \fIAppears on Page\fP \fIDescription\fP .ta \w'setlinebuf'u+4n +\w'setbuf.3s'u+4n .sp 5p clearerr ferror.3s stream status inquiries fclose fclose.3s close or flush a stream fdopen fopen.3s open a stream feof ferror.3s stream status inquiries ferror ferror.3s stream status inquiries fflush fclose.3s close or flush a stream fgetc getc.3s get character or word from stream fgets gets.3s get a string from a stream fileno ferror.3s stream status inquiries fopen fopen.3s open a stream fprintf printf.3s formatted output conversion fputc putc.3s put character or word on a stream fputs puts.3s put a string on a stream fread fread.3s buffered binary input/output freopen fopen.3s open a stream fscanf scanf.3s formatted input conversion fseek fseek.3s reposition a stream ftell fseek.3s reposition a stream fwrite fread.3s buffered binary input/output getc getc.3s get character or word from stream getchar getc.3s get character or word from stream gets gets.3s get a string from a stream getw getc.3s get character or word from stream printf printf.3s formatted output conversion putc putc.3s put character or word on a stream putchar putc.3s put character or word on a stream puts puts.3s put a string on a stream putw putc.3s put character or word on a stream rewind fseek.3s reposition a stream scanf scanf.3s formatted input conversion setbuf setbuf.3s assign buffering to a stream setbuffer setbuf.3s assign buffering to a stream setlinebuf setbuf.3s assign buffering to a stream sprintf printf.3s formatted output conversion sscanf scanf.3s formatted input conversion ungetc ungetc.3s push character back into input stream .fi ================================================ FILE: share/man/man3/strcspn.3 ================================================ .\" Copyright (c) 1990, 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" This code is derived from software contributed to Berkeley by .\" Chris Torek and the American National Standards Committee X3, .\" on Information Processing Systems. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. All advertising materials mentioning features or use of this software .\" must display the following acknowledgement: .\" This product includes software developed by the University of .\" California, Berkeley and its contributors. .\" 4. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)strcspn.3 8.1.1 (2.11BSD) 1996/1/12 .\" .TH STRCSPN 3 "January 12, 1996" .UC 7 .SH NAME \fBstrcspn\fP \- span the complement of a string .SH SYNOPSIS .B #include .sp .B size_t .br \fBstrcspn\fP(s, charset) .br .I char *s; .br .I char *charset; .SH DESCRIPTION The .BR strcspn () function spans the initial part of the null-terminated string .I s as long as the characters from .I s do not occur in string .I charset (it spans the .I complement of .I charset ) . .SH RETURN VALUES The .BR strcspn () function returns the number of characters spanned. .SH SEE ALSO index(3), memchr(3), rindex(3), strchr(3), strpbrk(3), strrchr(3), strsep(3), strspn(3), strstr(3), strtok(3) .SH STANDARDS The .BR strcspn () function conforms to ANSI C X3.159-1989 (``ANSI C''). ================================================ FILE: share/man/man3/strftime.3 ================================================ .\" Copyright (c) 1989, 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" This code is derived from software contributed to Berkeley by .\" the American National Standards Committee X3, on Information .\" Processing Systems. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. All advertising materials mentioning features or use of this software .\" must display the following acknowledgement: .\" This product includes software developed by the University of .\" California, Berkeley and its contributors. .\" 4. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)strftime.3 8.1.1 (2.11BSD) 1995/04/01 .\" .TH STRFTIME 3 "April 1, 1995" .UC 5 .SH NAME strftime \- format date and time .SH SYNOPSIS .B #include .br .B #include .br .B #include .br .sp .B size_t strftime(buf, maxsize, format, timeptr) .br .B char *buf; .br .B size_t maxsize; .br .B char *format; .br .B struct tm *timeptr; .PP .SH DESCRIPTION The .B strftime() function formats the information from .I timeptr into the buffer .I buf according to the string pointed to by \fIformat\fP. .PP The .I format string consists of zero or more conversion specifications and ordinary characters. All ordinary characters are copied directly into the buffer. A conversion specification consists of a percent sign ``%'' and one other character. .PP No more than .I maxsize characters will be placed into the array. If the total number of resulting characters, including the terminating null character, is not more than .IR maxsize , .B strftime() returns the number of characters in the array, not counting the terminating null. Otherwise, zero is returned. .PP Each conversion specification is replaced by the characters as follows which are then copied into the buffer. .IP \&%A \w'xxxx'u+3 is replaced by the full weekday name. .IP %a \w'xxxx'u+3 is replaced by the abbreviated weekday name, where the abbreviation is the first three characters. .IP \&%B \w'xxxx'u+3 is replaced by the full month name. .IP "%b or %h" \w'xxxx'u+3 is replaced by the abbreviated month name, where the abbreviation is the first three characters. .IP \&%C \w'xxxx'u+3 is equivalent to ``%a %b %e %H:%M:%S %Y'' (the format produced by .IR asctime (3)). .IP %c \w'xxxx'u+3 is equivalent to ``%m/%d/%y''. .IP \&%D \w'xxxx'u+3 is replaced by the date in the format ``mm/dd/yy''. .IP %d \w'xxxx'u+3 is replaced by the day of the month as a decimal number (01-31). .IP %e \w'xxxx'u+3 is replaced by the day of month as a decimal number (1-31); single digits are preceded by a blank. .IP \&%H \w'xxxx'u+3 is replaced by the hour (24-hour clock) as a decimal number (00-23). .IP \&%I \w'xxxx'u+3 is replaced by the hour (12-hour clock) as a decimal number (01-12). .IP %j \w'xxxx'u+3 is replaced by the day of the year as a decimal number (001-366). .IP %k \w'xxxx'u+3 is replaced by the hour (24-hour clock) as a decimal number (0-23); single digits are preceded by a blank. .IP %l \w'xxxx'u+3 is replaced by the hour (12-hour clock) as a decimal number (1-12); single digits are preceded by a blank. .IP \&%M \w'xxxx'u+3 is replaced by the minute as a decimal number (00-59). .IP %m \w'xxxx'u+3 is replaced by the month as a decimal number (01-12). .IP %n \w'xxxx'u+3 is replaced by a newline. .IP %p \w'xxxx'u+3 is replaced by either ``AM'' or ``PM'' as appropriate. .IP \&%R \w'xxxx'u+3 is equivalent to ``%H:%M'' .IP %r \w'xxxx'u+3 is equivalent to ``%I:%M:%S %p'' . .IP %t \w'xxxx'u+3 is replaced by a tab. .IP \&%S \w'xxxx'u+3 is replaced by the second as a decimal number (00-60). .IP "\&%T or \&%X" \w'xxxx'u+3 is equivalent to "%H:%M:%S" . .IP \&%U \w'xxxx'u+3 is replaced by the week number of the year (Sunday as the first day of the week) as a decimal number (00-53). .IP \&%W \w'xxxx'u+3 is replaced by the week number of the year (Monday as the first day of the week) as a decimal number (00-53). .IP %w \w'xxxx'u+3 is replaced by the weekday (Sunday as the first day of the week) as a decimal number (0-6). .IP %x \w'xxxx'u+3 is equivalent to ``%m/%d/%y %H:%M:%S'' . .IP \&%Y \w'xxxx'u+3 is replaced by the year with century as a decimal number. .IP %y \w'xxxx'u+3 is replaced by the year without century as a decimal number (00-99). .IP \&%Z \w'xxxx'u+3 is replaced by the time zone name. .IP %% \w'xxxx'u+3 is replaced by `%' . .PP .SH SEE ALSO .IR date (1), .IR ctime (3), .IR printf (1), .IR printf (3) .SH STANDARDS The .B strftime() function conforms to ANSI X C3.159-1989(``ANSI C''). .SH BUGS There is no conversion specification for the phase of the moon. ================================================ FILE: share/man/man3/string.3 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)string.3 6.5 (Berkeley) 10/22/87 .\" .TH STRING 3 "October 22, 1987" .UC 4 .SH NAME strcat, strncat, strcmp, strncmp, strcasecmp, strncasecmp, strcpy, strncpy, strlen, index, rindex \- string operations .SH SYNOPSIS .nf .B #include .PP .B char *strcat(s, append) .B char *s, *append; .PP .B char *strncat(s, append, count) .B char *s, *append; .B int count; .PP .B strcmp(s1, s2) .B char *s1, *s2; .PP .B strncmp(s1, s2, count) .B char *s1, *s2; .B int count; .PP .B strcasecmp(s1, s2) .B char *s1, *s2; .PP .B strncasecmp(s1, s2, count) .B char *s1, *s2; .B int count; .PP .B char *strcpy(to, from) .B char *to, *from; .PP .B char *strncpy(to, from, count) .B char *to, *from; .B int count; .PP .B strlen(s) .B char *s; .PP .B char *index(s, c) .B char *s, c; .PP .B char *rindex(s, c) .B char *s, c; .fi .SH DESCRIPTION These functions operate on null-terminated strings. They do not check for overflow of any receiving string. .PP \fIStrcat\fP appends a copy of string \fIappend\fP to the end of string \fIs\fP. \fIStrncat\fP copies at most \fIcount\fP characters. Both return a pointer to the null-terminated result. .PP \fIStrcmp\fP compares its arguments and returns an integer greater than, equal to, or less than 0, according as \fIs1\fP is lexicographically greater than, equal to, or less than \fIs2\fP. \fIStrncmp\fP makes the same comparison but looks at at most \fIcount\fP characters. \fIStrcasecmp\fP and \fIstrncasecmp\fP are identical in function, but are case insensitive. The returned lexicographic difference reflects a conversion to lower-case. .PP \fIStrcpy\fP copies string \fIfrom\fP to \fIto\fP, stopping after the null character has been moved. \fIStrncpy\fP copies exactly \fIcount\fP characters, appending nulls if \fIfrom\fP is less than \fIcount\fP characters in length; the target may not be null-terminated if the length of \fIfrom\fP is \fIcount\fP or more. Both return \fIto\fP. .PP \fIStrlen\fP returns the number of non-null characters in \fIs\fP. .PP .I Index .RI ( rindex ) returns a pointer to the first (last) occurrence of character \fIc\fP in string \fIs\fP or zero if \fIc\fP does not occur in the string. Setting \fIc\fP to NULL works. ================================================ FILE: share/man/man3/strlcpy.3 ================================================ .\" $OpenBSD: strlcpy.3,v 1.27 2019/01/25 00:19:25 millert Exp $ .\" .\" Copyright (c) 1998, 2000 Todd C. Miller .\" .\" Permission to use, copy, modify, and distribute this software for any .\" purpose with or without fee is hereby granted, provided that the above .\" copyright notice and this permission notice appear in all copies. .\" .\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES .\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF .\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR .\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES .\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" .Dd $Mdocdate: January 25 2019 $ .Dt STRLCPY 3 .Os .Sh NAME .Nm strlcpy , .Nm strlcat .Nd size-bounded string copying and concatenation .Sh SYNOPSIS .In string.h .Ft size_t .Fn strlcpy "char *dst" "const char *src" "size_t dstsize" .Ft size_t .Fn strlcat "char *dst" "const char *src" "size_t dstsize" .Sh DESCRIPTION The .Fn strlcpy and .Fn strlcat functions copy and concatenate strings with the same input parameters and output result as .Xr snprintf 3 . They are designed to be safer, more consistent, and less error prone replacements for the easily misused functions .Xr strncpy 3 and .Xr strncat 3 . .Pp .Fn strlcpy and .Fn strlcat take the full size of the destination buffer and guarantee NUL-termination if there is room. Note that room for the NUL should be included in .Fa dstsize . .Pp .Fn strlcpy copies up to .Fa dstsize \- 1 characters from the string .Fa src to .Fa dst , NUL-terminating the result if .Fa dstsize is not 0. .Pp .Fn strlcat appends string .Fa src to the end of .Fa dst . It will append at most .Fa dstsize \- strlen(dst) \- 1 characters. It will then NUL-terminate, unless .Fa dstsize is 0 or the original .Fa dst string was longer than .Fa dstsize (in practice this should not happen as it means that either .Fa dstsize is incorrect or that .Fa dst is not a proper string). .Pp If the .Fa src and .Fa dst strings overlap, the behavior is undefined. .Sh RETURN VALUES Besides quibbles over the return type .Pf ( Va size_t versus .Va int ) and signal handler safety .Pf ( Xr snprintf 3 is not entirely safe on some systems), the following two are equivalent: .Bd -literal -offset indent n = strlcpy(dst, src, len); n = snprintf(dst, len, "%s", src); .Ed .Pp Like .Xr snprintf 3 , the .Fn strlcpy and .Fn strlcat functions return the total length of the string they tried to create. For .Fn strlcpy that means the length of .Fa src . For .Fn strlcat that means the initial length of .Fa dst plus the length of .Fa src . .Pp If the return value is .Cm >= .Va dstsize , the output string has been truncated. It is the caller's responsibility to handle this. .Sh EXAMPLES The following code fragment illustrates the simple case: .Bd -literal -offset indent char *s, *p, buf[BUFSIZ]; \&... (void)strlcpy(buf, s, sizeof(buf)); (void)strlcat(buf, p, sizeof(buf)); .Ed .Pp To detect truncation, perhaps while building a pathname, something like the following might be used: .Bd -literal -offset indent char *dir, *file, pname[PATH_MAX]; \&... if (strlcpy(pname, dir, sizeof(pname)) >= sizeof(pname)) goto toolong; if (strlcat(pname, file, sizeof(pname)) >= sizeof(pname)) goto toolong; .Ed .Pp Since it is known how many characters were copied the first time, things can be sped up a bit by using a copy instead of an append: .Bd -literal -offset indent char *dir, *file, pname[PATH_MAX]; size_t n; \&... n = strlcpy(pname, dir, sizeof(pname)); if (n >= sizeof(pname)) goto toolong; if (strlcpy(pname + n, file, sizeof(pname) - n) >= sizeof(pname) - n) goto toolong; .Ed .Pp However, one may question the validity of such optimizations, as they defeat the whole purpose of .Fn strlcpy and .Fn strlcat . As a matter of fact, the first version of this manual page got it wrong. .Sh SEE ALSO .Xr snprintf 3 , .Xr strncat 3 , .Xr strncpy 3 , .Xr wcslcpy 3 .Sh HISTORY .Fn strlcpy and .Fn strlcat first appeared in .Ox 2.4 . .Sh AUTHORS .Fn strlcpy and .Fn strlcat were created by .An Todd C. Miller Aq Mt millert@openbsd.org . ================================================ FILE: share/man/man3/strpbrk.3 ================================================ .\" Copyright (c) 1990, 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" This code is derived from software contributed to Berkeley by .\" Chris Torek and the American National Standards Committee X3, .\" on Information Processing Systems. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. All advertising materials mentioning features or use of this software .\" must display the following acknowledgement: .\" This product includes software developed by the University of .\" California, Berkeley and its contributors. .\" 4. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)strpbrk.3 8.1.1 (2.11BSD) 1996/1/12 .\" .TH STRPBRK 3 "January 12, 1996" .UC 7 .SH NAME \fBstrpbrk\fP \- locate multiple characters in string .SH SYNOPSIS .B #include .sp .B char * .br \fBstrpbrk\fP(s, charset) .br .I char *s; .br .I char *charset; .SH DESCRIPTION The .BR strpbrk () function locates in the null-terminated string .I s the first occurrence of any character in the string .I charset and returns a pointer to this character. If no characters from .I charset occur anywhere in .I s .BR strpbrk () returns NULL. .SH SEE ALSO index(3), memchr(3), rindex(3), strchr(3), strcspn(3), strrchr(3), strsep(3), strspn(3), strstr(3), strtok(3) .SH STANDARDS The .BR strpbrk () function conforms to ANSI C X3.159-1989 )``ANSI C''). ================================================ FILE: share/man/man3/strsep.3 ================================================ .\" Copyright (c) 1990, 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" This code is derived from software contributed to Berkeley by .\" Chris Torek. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. All advertising materials mentioning features or use of this software .\" must display the following acknowledgement: .\" This product includes software developed by the University of .\" California, Berkeley and its contributors. .\" 4. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)strsep.3 8.1.1 (2.11BSD) 1996/1/12 .\" .TH STRSEP 3 "January 12, 1996" .UC 7 .SH NAME \fBstrsep\fP \- separate strings .SH SYNOPSIS .B #include .sp .B char * .br \fBstrsep\fP(stringp, delim) .br .I char **stringp; .br .I char *delim; .SH DESCRIPTION The .BR strsep () function locates, in the string referenced by .I *stringp , the first occurrence of any character in the string .I delim (or the terminating `\e0' character) and replaces it with a `\e0'. The location of the next character after the delimiter character (or NULL, if the end of the string was reached) is stored in .I *stringp . The original value of .I *stringp is returned. .PP An ``empty'' field, i.e. one caused by two adjacent delimiter characters, can be detected by comparing the location referenced by the pointer returned in .I *stringp to `\e0'. .PP If .I *stringp is initially .BR NULL , .BR strsep () returns .BR NULL . .SH EXAMPLES The following uses .BR strsep () to parse a string, containing tokens delimited by white space, into an argument vector: .sp .nf .cs R 24 char **ap, *argv[10], *inputstring; for (ap = argv; (*ap = strsep(&inputstring, " \et")) != NULL;) if (**ap != '\e0') ++ap; .br .cs R .fi .SH HISTORY The .BR strsep () function is intended as a replacement for the .BR strtok () function. While the .BR strtok () function should be preferred for portability reasons (it conforms to ANSI C X3.159-1989 (``ANSI C'')) it is unable to handle empty fields, i.e. detect fields delimited by two adjacent delimiter characters, or to be used for more than a single string at a time. The .BR strsep () function first appeared in 4.4BSD. ================================================ FILE: share/man/man3/strspn.3 ================================================ .\" Copyright (c) 1990, 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" This code is derived from software contributed to Berkeley by .\" Chris Torek and the American National Standards Committee X3, .\" on Information Processing Systems. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. All advertising materials mentioning features or use of this software .\" must display the following acknowledgement: .\" This product includes software developed by the University of .\" California, Berkeley and its contributors. .\" 4. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)strspn.3 8.1.1 (2.11BSD) 1996/1/12 .\" .TH STRSPN 3 "January 12, 1996" .UC 7 .SH NAME \fBstrspn\fP \- span a string .SH SYNOPSIS .B #include .sp .B size_t .br \fBstrspn\fP(s, charset) .br .I char *s; .br .I char *charset; .SH DESCRIPTION The .BR strcspn () function spans the initial part of the null-terminated string .I s as long as the characters from .I s occur in string .I charset . .SH RETURN VALUES The .BR strspn () function returns the number of characters spanned. .SH SEE ALSO index(3), memchr(3), rindex(3), strchr(3), strcspn(3), strpbrk(3), strrchr(3), strsep(3), strstr(3), strtok(3) .SH STANDARDS The .BR strspn () function conforms to ANSI C X3.159-9189 (``ANSI C''). ================================================ FILE: share/man/man3/strstr.3 ================================================ .\" Copyright (c) 1990, 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" This code is derived from software contributed to Berkeley by .\" Chris Torek and the American National Standards Committee X3, .\" on Information Processing Systems. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. All advertising materials mentioning features or use of this software .\" must display the following acknowledgement: .\" This product includes software developed by the University of .\" California, Berkeley and its contributors. .\" 4. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)strstr.3 8.1.1 (2.11BSD) 1996/1/15 .\" .TH STRSTR 3 "January 15, 1996" .UC 7 .SH NAME \fBstrstr\fP \- locate a substring in a string .SH SYNOPSIS .B #include .sp .B char * .br .B strstr(big, little) .br .I char *big, *little; .br .SH DESCRIPTION The .BR strstr () function locates the first occurrence of the null-terminated string .I little in the null-terminated string .IR big . If .I little is the empty string, .BR strstr () returns .IR big ; if .I little occurs nowhere in .IR big , .BR strstr () returns NULL; otherwise .BR strstr () returns a pointer to the first character of the first occurrence of .IR little . .SH SEE ALSO index(3), memchr(3), rindex(3), strchr(3), strcspn(3), strpbrk(3), strrchr(3), strsep(3), strspn(3), strtok(3) .SH STANDARDS The .BR strstr () function conforms to ANSI C X3/159-1989 (``ANSI C''). ================================================ FILE: share/man/man3/strtok.3 ================================================ .\" Copyright (c) 1988, 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" This code is derived from software contributed to Berkeley by .\" the American National Standards Committee X3, on Information .\" Processing Systems. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. All advertising materials mentioning features or use of this software .\" must display the following acknowledgement: .\" This product includes software developed by the University of .\" California, Berkeley and its contributors. .\" 4. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)strtok.3 8.2.1 (2.11BSD) 1996/1/12 .\" .TH STRTOK 3 "January 12, 1996" .UC 7 .SH NAME \fBstrtok\fP \- string tokens .SH SYNOPSIS .B #include .sp .B char * .br \fBstrtok\fP(str, sep) .br .I char *str; .br .I char *sep; .SH DESCRIPTION .B This interface is obsoleted by strsep(3). .PP The .BR strtok () function is used to isolate sequential tokens in a null-terminated string, .I str . These tokens are separated in the string by at least one of the characters in .I sep . The first time that .BR strtok () is called, .I str should be specified; subsequent calls, wishing to obtain further tokens from the same string, should pass a null pointer instead. The separator string, .I sep , must be supplied each time, and may change between calls. .PP The .BR strtok () function returns a pointer to the beginning of each subsequent token in the string, after replacing the token itself with a .B NUL character. When no more tokens remain, a null pointer is returned. .SH SEE ALSO index(3), memchr(3), rindex(3), strchr(3), strcspn(3), strpbrk(3), strrchr(3), strsep(3), strspn(3), strstr(3 .SH STANDARDS The .BR strtok () function conforms to ANSI C X3.159-1989 (``ANSI C''). .SH BUGS There is no way to get tokens from multiple strings simultaneously. .PP The System V .BR strtok (), if handed a string containing only delimiter characters, will not alter the next starting point, so that a call to .BR strtok () with a different (or empty) delimiter string may return a non-\fBNULL\fP value. Since this implementation always alters the next starting point, such a sequence of calls would always return .BR NULL . ================================================ FILE: share/man/man3/strtol.3 ================================================ .\" Copyright (c) 1990, 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" This code is derived from software contributed to Berkeley by .\" Chris Torek and the American National Standards Committee X3, .\" on Information Processing Systems. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. All advertising materials mentioning features or use of this software .\" must display the following acknowledgement: .\" This product includes software developed by the University of .\" California, Berkeley and its contributors. .\" 4. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)strtol.3 8.1.1 (2.11BSD) 1996/1/12 .\" .TH STRTOL 3 "January 12, 1996" .UC 7 .SH NAME \fBstrtol\fP \- convert string value to a long .SH SYNOPSIS .B #include .br .B #include .sp .B long .br \fBstrtol\fP(nptr, endptr, base) .br .I char *nptr; .br .I char **endptr; .br .I int base; .SH DESCRIPTION The .BR strtol () function converts the string in .I nptr to a .I long value. The conversion is done according to the given .IR base , which must be between 2 and 36 inclusive, or be the special value 0. .PP The string may begin with an arbitrary amount of white space (as determined by isspace(3)) followed by a single optional `+' or `\-' sign. If .I base is zero or 16, the string may then include a `0x' prefix, and the number will be read in base 16; otherwise, a zero .I base is taken as 10 (decimal) unless the next character is `0', in which case it is taken as 8 (octal). .PP The remainder of the string is converted to a .I long value in the obvious manner, stopping at the first character which is not a valid digit in the given base. (In bases above 10, the letter `A' in either upper or lower case represents 10, `B' represents 11, and so forth, with `Z' representing 35.) .PP If .I endptr is non nil, .BR strtol () stores the address of the first invalid character in .I *endptr . If there were no digits at all, however, .BR strtol () stores the original value of .I nptr in .IR *endptr . (Thus, if .I *nptr is not `\e0' but .I **endptr is `\e0' on return, the entire string was valid.) .SH RETURN VALUES The .BR strtol () function returns the result of the conversion, unless the value would underflow or overflow. If an underflow occurs, .BR strtol () returns .BR LONG_MIN . If an overflow occurs, .BR strtol () returns .BR LONG_MAX . In both cases, .B errno is set to .B ERANGE . .SH ERRORS .TP 15 [ERANGE] The given string was out of range; the value converted has been clamped. .SH SEE ALSO atof(3), atoi(3), atol(3), strtoul(3) .SH STANDARDS The .BR strtol () function conforms to ANSI C X3.159-1989 (``ANSI C''). .SH BUGS Ignores the current locale. ================================================ FILE: share/man/man3/strtoul.3 ================================================ .\" Copyright (c) 1990, 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" This code is derived from software contributed to Berkeley by .\" Chris Torek and the American National Standards Committee X3, .\" on Information Processing Systems. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. All advertising materials mentioning features or use of this software .\" must display the following acknowledgement: .\" This product includes software developed by the University of .\" California, Berkeley and its contributors. .\" 4. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)strtoul.3 8.1.1 (2.11BSD) 1996/1/12 .\" .TH STRTOUL 3 "January 12, 1996" .UC 7 .SH NAME \fBstrtoul\fP \- convert a string to an unsigned long .SH SYNOPSIS .B #include .br .B #include .sp .B unsigned long .br \fBstrtoul\fP(nptr, endptr, base) .br .I char *nptr; .br .I char **endptr; .br .I int base; .SH DESCRIPTION The .BR strtoul () function converts the string in .I nptr to an .I unsigned long value. The conversion is done according to the given .IR base , which must be between 2 and 36 inclusive, or be the special value 0. .PP The string may begin with an arbitrary amount of white space (as determined by isspace(3)) followed by a single optional `+' or `\-' sign. If .I base is zero or 16, the string may then include a `0x' prefix, and the number will be read in base 16; otherwise, a zero .I base is taken as 10 (decimal) unless the next character is `0', in which case it is taken as 8 (octal). .PP The remainder of the string is converted to an .I unsigned long value in the obvious manner, stopping at the end of the string or at the first character that does not produce a valid digit in the given base. (In bases above 10, the letter `A' in either upper or lower case represents 10, `B' represents 11, and so forth, with `Z' representing 35.) .PP If .I endptr is non nil, .BR strtoul () stores the address of the first invalid character in .I *endptr . If there were no digits at all, however, .BR strtoul () stores the original value of .I nptr in .I *endptr . (Thus, if .I *nptr is not `\e0' but .I **endptr is `\e0' on return, the entire string was valid.) .SH RETURN VALUES The .BR strtoul () function returns either the result of the conversion or, if there was a leading minus sign, the negation of the result of the conversion, unless the original (non-negated) value would overflow; in the latter case, .BR strtoul () returns .B ULONG_MAX and sets the global variable .B errno to .B ERANGE . .SH ERRORS .TP 15 [ERANGE] The given string was out of range; the value converted has been clamped. .SH SEE ALSO strtol(3) .SH STANDARDS The .BR strtoul () function conforms to ANSI C X3.159-1989 (``ANSI C''). .SH BUGS Ignores the current locale. ================================================ FILE: share/man/man3/stty.3 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)stty.3c 6.1 (Berkeley) 5/15/85 .\" .TH STTY 3C "May 15, 1985" .UC 5 .SH NAME stty, gtty \- set and get terminal state (defunct) .SH SYNOPSIS .nf .B #include .sp .B stty(fd, buf) .B int fd; .B struct sgttyb *buf; .sp .B gtty(fd, buf) .B int fd; .B struct sgttyb *buf; .fi .SH DESCRIPTION .ft B This interface is obsoleted by ioctl(2). .ft R .PP .I Stty sets the state of the terminal associated with .IR fd . .I Gtty retrieves the state of the terminal associated with .IR fd . To set the state of a terminal the call must have write permission. .PP The .I stty call is actually ``ioctl(fd, TIOCSETP, buf)'', while the .I gtty call is ``ioctl(fd, TIOCGETP, buf)''. See .IR ioctl (2) and .IR tty (4) for an explanation. .SH DIAGNOSTICS If the call is successful 0 is returned, otherwise \-1 is returned and the global variable .I errno contains the reason for the failure. .SH SEE ALSO ioctl(2), tty(4) ================================================ FILE: share/man/man3/swab.3 ================================================ .\" @(#)swab.3 6.1 (Berkeley) 5/15/85 .\" .TH SWAB 3 "May 15, 1985" .AT 3 .nf .SH NAME swab \- swap bytes .SH SYNOPSIS .nf .B swab(from, to, nbytes) .B char *from, *to; .fi .SH DESCRIPTION .I Swab copies .I nbytes bytes pointed to by .I from to the position pointed to by .I to, exchanging adjacent even and odd bytes. It is useful for carrying binary data between PDP11's and other machines. .I Nbytes should be even. ================================================ FILE: share/man/man3/sysctl.3 ================================================ .\" Copyright (c) 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. All advertising materials mentioning features or use of this software .\" must display the following acknowledgement: .\" This product includes software developed by the University of .\" California, Berkeley and its contributors. .\" 4. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)sysctl.3 8.1.1 (2.11BSD GTE) 1/13/95 .\" .TH SYSCTL 3 "January 13, 1995" .UC 4 .SH NAME sysctl \- get or set system information .SH SYNOPSIS .nf .ft B #include int sysctl(name, namelen, oldp, *oldlenp, *newp, newlen) int *name; u_int namelen; void *oldp; size_t *oldlenp; void *newp; size_t newlen; .ft R .fi .SH DESCRIPTION The \fBsysctl\fP function retrieves system information and allows processes with appropriate privileges to set system information. The information available from \fBsysctl\fP consists of integers, strings, and tables. Information may be retrieved and set from the command interface using the \fIsysctl\fP(1) utility. .PP Unless explicitly noted below, \fBsysctl\fP returns a consistent snapshot of the data requested. Calls to \fBsysctl\fP are serialized to avoid deadlock. .PP The state is described using a ``Management Information Base'' (MIB) style name, listed in \fIname\fP, which is a \fInamelen\fP length array of integers. .PP The information is copied into the buffer specified by \fIoldp\fP. The size of the buffer is given by the location specified by \fIoldlenp\fP before the call, and that location gives the amount of data copied after a successful call. If the amount of data available is greater than the size of the buffer supplied, the call supplies as much data as fits in the buffer provided and returns with the error code ENOMEM. If the old value is not desired, \fIoldp\fP and \fIoldlenp\fP should be set to NULL. .PP The size of the available data can be determined by calling \fBsysctl\fP with a NULL parameter for \fIoldp\fP. The size of the available data will be returned in the location pointed to by \fIoldlenp\fP. For some operations, the amount of space may change often. For these operations, the system attempts to round up so that the returned size is large enough for a call to return the data shortly thereafter. .PP To set a new value, \fInewp\fP is set to point to a buffer of length \fInewlen\fP from which the requested value is to be taken. If a new value is not to be set, \fInewp\fP should be set to NULL and \fInewlen\fP set to 0. .PP The top level names are defined with a CTL_ prefix in \fI\fP, and are as follows. The next and subsequent levels down are found in the include files listed here, and described in separate sections below. .PP .nf .ta .25i 1.5i 3.75i 4.5i Name Next level names Description CTL\_DEBUG sys/sysctl.h Debugging CTL\_FS sys/sysctl.h File system CTL\_HW sys/sysctl.h Generic CPU, I/O CTL\_KERN sys/sysctl.h High kernel limits CTL\_MACHDEP sys/sysctl.h Machine dependent CTL\_NET sys/socket.h Networking CTL\_USER sys/sysctl.h User-level CTL\_VM vm/vm_param.h Virtual memory .fi .PP For example, the following retrieves the maximum number of processes allowed in the system: .sp .nf .in +.5i int mib[2], maxproc; size_t len; .sp mib[0] = CTL_KERN; mib[1] = KERN_MAXPROC; len = sizeof(maxproc); sysctl(mib, 2, &maxproc, &len, NULL, 0); .in -.5i .sp To retrieve the standard search path for the system utilities: .sp .nf .in +.5i int mib[2]; size_t len; char *p; mib[0] = CTL_USER; mib[1] = USER_CS_PATH; sysctl(mib, 2, NULL, &len, NULL, 0); p = malloc(len); sysctl(mib, 2, p, &len, NULL, 0); .in -.5i .fi .SH CTL_DEBUG The debugging variables vary from system to system. A debugging variable may be added or deleted without need to recompile \fBsysctl\fP to know about it. Each time it runs, \fBsysctl\fP gets the list of debugging variables from the kernel and displays their current values. The system defines twenty \fIstruct ctldebug\fP variables named \fIdebug0\fP through \fIdebug19\fP. They are declared as separate variables so that they can be individually initialized at the location of their associated variable. The loader prevents multiple use of the same variable by issuing errors if a variable is initialized in more than one place. For example, to export the variable \fIdospecialcheck\fP as a debugging variable, the following declaration would be used: .sp .nf .in +.5i int dospecialcheck = 1; struct ctldebug debug5 = { "dospecialcheck", &dospecialcheck }; .in -.5i .fi .SH CTL_FS There are currently no second level names for the file system. .SH CTL_HW The string and integer information available for the CTL_HW level is detailed below. The changeable column shows whether a process with appropriate privilege may change the value. .sp .nf .ta .25i 2.75i 3.75i Second level name Type Changeable HW\_MACHINE string no HW\_MODEL string no HW\_NCPU integer no HW\_BYTEORDER integer no HW\_PHYSMEM integer no HW\_USERMEM integer no HW\_PAGESIZE integer no .\".It HW\_DISKNAMES integer no .\".It HW\_DISKSTATS integer no HW\_MACHINE_ARCH string no .fi .PP .ta .5i HW_MACHINE .br The machine class. .sp HW_MODEL .br The machine model. .sp HW_NCPU .br The number of cpus. .sp HW_BYTEORDER .br The byteorder (3412, 4321, or 1234). .sp HW_PHYSMEM .br The bytes of physical memory. .sp HW_USERMEM .br The bytes of non-kernel memory. .sp HW_PAGESIZE .br The software page size. .sp .\".It Fa HW_DISKNAMES .\".It Fa HW_DISKSTATS HW_MACHINE_ARCH .br The machine architecture. .sp .SH CTL_KERN The string and integer information available for the CTL_KERN level is detailed below. The changeable column shows whether a process with appropriate privilege may change the value. The types of data currently available are process information, system inodes, the open file entries, routing table entries, virtual memory statistics, load average history, and clock rate information. .sp .nf .ta .25i 2.75i 4.5i Second level name Type Changeable KERN\_ARGMAX integer no KERN\_BOOTTIME struct timeval no KERN\_CHOWN\_RESTRICTED integer no KERN\_CLOCKRATE struct clockinfo no KERN\_FILE struct file no KERN\_HOSTID long yes KERN\_HOSTNAME string yes KERN\_JOB\_CONTROL integer no .\"KERN\_LINK\_MAX integer no KERN\_MAXFILES integer no KERN\_MAXPROC integer no KERN\_MAXINODES integer no KERN\_MAXTEXTS integer no .\"KERN\_MAX\_CANON integer no .\"KERN\_MAX\_INPUT integer no .\"KERN\_NAME\_MAX integer no KERN\_NGROUPS integer no .\"KERN\_NO\_TRUNC integer no KERN\_OSRELEASE string no KERN\_OSREV integer no KERN\_OSTYPE string no KERN\_OSVERSION string no .\"KERN\_PATH\_MAX integer no .\"KERN\_PIPE\_BUF integer no KERN\_POSIX1 integer no KERN\_PROC struct proc no KERN\_PROF node not applicable KERN\_SAVED\_IDS integer no KERN\_SECURELVL integer raise only KERN\_TEXT struct text no .\"KERN\_VDISABLE integer no KERN\_VERSION string no KERN\_INODE struct inode no .fi .PP KERN_ARGMAX .br .in +.5i The maximum bytes of argument to \fBexec(2)\fP. .sp .in -.5i KERN_BOOTTIME .br .in +.5i A \fIstruct timeval\fP structure is returned. This structure contains the time that the system was booted. .sp .in -.5i .\"KERN_CHOWN_RESTRICTED .\"Return 1 if appropriate privileges are required for the .\".Xr chown 2 .\"system call, otherwise 0. KERN_CLOCKRATE .br .in +.5i A \fIstruct clockinfo\fP structure is returned. This structure contains the clock, statistics clock and profiling clock frequencies, and the number of micro-seconds per hz tick. .sp .in -.5i KERN_FILE .br .in +.5i Return the entire file table as an array of extended \fIfile\fP structures. Each element of the array contains the kernel address of a file \fIstruct inode *\fP followed by the file itself \fIstruct file\fP. There can never be more than \fBKERN_MAXFILES\fP inodes returned. .sp .in -.5i KERN_HOSTID .br .in +.5i Get or set the host id. .sp .in -.5i KERN_HOSTNAME .br .in +.5i Get or set the hostname. .sp .in -.5i KERN_JOB_CONTROL .br .in +.5i Return 1 if job control is available on this system, otherwise 0. .sp .in -.5i .\"KERN_LINK_MAX .\"The maximum file link count. KERN_MAXFILES .br .in +.5i The maximum number of open files that may be open in the system. .sp .in -.5i KERN_MAXPROC .br .in +.5i The maximum number of simultaneous processes the system will allow. .sp .in -.5i KERN_MAXINODES .br .in +.5i The maximum number of inodes available on the system. .sp .in -.5i KERN_MAXTEXTS .br .in +.5i The maximum number of text structures available on the system. .sp .in -.5i .\"KERN_MAX_CANON .\"The maximum number of bytes in terminal canonical input line. .\"KERN_MAX_INPUT .\"The minimum maximum number of bytes for which space is available in .\"a terminal input queue. .\"KERN_NAME_MAX .\"The maximum number of bytes in a file name. KERN_NGROUPS .br .in +.5i The maximum number of supplemental groups. .sp .in -.5i .\"KERN_NO_TRUNC .\"Return 1 if file names longer than KERN_NAME_MAX are truncated. KERN_OSRELEASE .br .in +.5i The system release string. .sp .in -.5i KERN_OSREV .br .in +.5i The system revision number. .sp .in -.5i KERN_OSTYPE .br .in +.5i The system type string. .sp .in -.5i KERN_OSVERSION .br .in +.5i The kernel build version. .sp .in -.5i .\"KERN_PATH_MAX .\"The maximum number of bytes in a pathname. .\"KERN_PIPE_BUF .\"The maximum number of bytes which will be written atomically to a pipe. KERN_POSIX1 .br .in +.5i The version of ISO/IEC 9945 (POSIX 1003.1) with which the system attempts to comply. .sp .in -.5i KERN_PROC .br .in +.5i Return the entire process table, or a subset of it. An array of \fIstruct kinfo_proc\fP structures is returned, whose size depends on the current number of such objects in the system. .sp .in -.5i The third and fourth level names are as follows: .sp .nf .ta .25i 3.0i Third level name Fourth level is: KERN\_PROC\_ALL None KERN\_PROC\_PID A process ID KERN\_PROC\_PGRP A process group KERN\_PROC\_TTY A tty device KERN\_PROC\_UID A user ID KERN\_PROC\_RUID A real user ID KERN\_PROF Return kernel profiling information. .fi .sp .in +.5i If the kernel is not compiled for profiling, attempts to retrieve any of the KERN_PROF values will fail with EOPNOTSUPP. .sp .in -.5i The third level names for the string and integer profiling information is detailed below. The changeable column shows whether a process with appropriate privilege may change the value. .sp .in +.5i .nf .ta .25i 2.25i 4.25i Third level name Type Changeable GPROF\_STATE integer yes GPROF\_COUNT u_short[\|] yes GPROF\_FROMS u_short[\|] yes GPROF\_TOS struct tostruct yes GPROF\_GMONPARAM struct gmonparam no .fi .PP The variables are as follows: .sp GPROF_STATE .br .in +.5i Returns GMON_PROF_ON or GMON_PROF_OFF to show that profiling is running or stopped. .sp .in -.5i GPROF_COUNT .br .in +.5i Array of statistical program counter counts. .sp .in -.5i GPROF_FROMS .br .in +.5i Array indexed by program counter of call-from points. .sp .in -.5i GPROF_TOS .br .in +.5i Array of \fIstruct tostruct\fP describing destination of calls and their counts. .sp .in -.5i GPROF_GMONPARAM .br .in +.5i Structure giving the sizes of the above arrays. .in -.5i .sp KERN_SAVED_IDS .br .in +.5i Returns 1 if saved set-group and saved set-user ID is available. .sp .in -.5i .in -.5i KERN_SECURELVL .br .in +.5i The system security level. This level may be raised by processes with appropriate privilege. It may only be lowered by process 1. .sp .in -.5i .\"KERN_VDISABLE .\"Returns the terminal character disabling value. KERN_VERSION .br .in +.5i The system version string. .sp .in -.5i KERN_INODE .br .in +.5i Return the entire inode table. Note, the inode table is not necessarily a consistent snapshot of the system. The returned data consists of an array whose size depends on the current number of such objects in the system. Each element of the array contains the kernel address of a inode \fIstruct inode *\fP followed by the inode itself \fIstruct inode\fP. There can never be more than \fBKERN_MAXINODES\fP inodes returned. .sp .in -.5i KERN_TEXT .br .in +.5i Return the entire text table. The returned data consists of an array whose size depends on the current number of such objects active in the system. Each element of the array contains the kernel address of a text \fIstruct text *\fP followed by the text structure itself \fIstruct text\fP. There can never be more structures than returned by \fBKERN_MAXTEXTS\fP. .in -.5i .SH CTL_MACHDEP The set of variables defined is architecture dependent. Most architectures define at least the following variables. .nf .sp .ta .25i 2.75i 3.75i Second level name Type Changeable CPU_CONSDEV dev_t no .fi .SH CTL_NET The string and integer information available for the CTL_NET level is detailed below. The changeable column shows whether a process with appropriate privilege may change the value. .nf .sp .ta .25i 2.25i 4.0i Second level name Type Changeable PF\_ROUTE routing messages no PF\_INET internet values yes .fi .PP PF_ROUTE .br .in +.5i Return the entire routing table or a subset of it. The data is returned as a sequence of routing messages (see \fIroute(4)\fP for the header file, format and meaning). The length of each message is contained in the message header. .in -.5i .PP The third level name is a protocol number, which is currently always 0. The fourth level name is an address family, which may be set to 0 to select all address families. The fifth and sixth level names are as follows: .nf .sp .ta .25i 2.75i Fifth level name Sixth level is: NET\_RT\_FLAGS rtflags NET\_RT\_DUMP None NET\_RT\_IFLIST None .fi .sp PF_INET .br .in +.5i Get or set various global information about the internet protocols. The third level name is the protocol. The fourth level name is the variable name. The currently defined protocols and names are: .sp .in -.5i .nf .ta .25i 2.0i 3.75i 4.75i Protocol name Variable name Type Changeable ip forwarding integer yes ip redirect integer yes ip ttl integer yes icmp maskrepl integer yes udp checksum integer yes .fi .PP The variables are as follows: .sp ip.forwarding .br .in +.5i Returns 1 when IP forwarding is enabled for the host, meaning that the host is acting as a router. .sp .in -.5i ip.redirect .br .in +.5i Returns 1 when ICMP redirects may be sent by the host. This option is ignored unless the host is routing IP packets, and should normally be enabled on all systems. .sp .in -.5i ip.ttl .br .in +.5i The maximum time-to-live (hop count) value for an IP packet sourced by the system. This value applies to normal transport protocols, not to ICMP. .sp .in -.5i icmp.maskrepl .br .in +.5i Returns 1 if ICMP network mask requests are to be answered. .sp .in -.5i udp.checksum .br .in +.5i Returns 1 when UDP checksums are being computed and checked. Disabling UDP checksums is strongly discouraged. .sp .in -.5i .SH CTL_USER The string and integer information available for the CTL_USER level is detailed below. The changeable column shows whether a process with appropriate privilege may change the value. .sp .nf .ta .25i 3.0i 4.25i Second level name Type Changeable USER\_BC\_BASE\_MAX integer no USER\_BC\_DIM\_MAX integer no USER\_BC\_SCALE\_MAX integer no USER\_BC\_STRING\_MAX integer no USER\_COLL\_WEIGHTS\_MAX integer no USER\_CS\_PATH string no USER\_EXPR\_NEST\_MAX integer no USER\_LINE\_MAX integer no USER\_POSIX2\_CHAR\_TERM integer no USER\_POSIX2\_C\_BIND integer no USER\_POSIX2\_C\_DEV integer no USER\_POSIX2\_FORT\_DEV integer no USER\_POSIX2\_FORT\_RUN integer no USER\_POSIX2\_LOCALEDEF integer no USER\_POSIX2\_SW\_DEV integer no USER\_POSIX2\_UPE integer no USER\_POSIX2\_VERSION integer no USER\_RE\_DUP\_MAX integer no USER\_STREAM\_MAX integer no USER\_TZNAME\_MAX integer no .fi .PP USER_BC_BASE_MAX .br .in +.5i The maximum ibase/obase values in the \fIbc(1)\fP utility. .sp .in -.5i USER_BC_DIM_MAX .br .in +.5i The maximum array size in the \fIbc(1)\fP utility. .sp .in -.5i USER_BC_SCALE_MAX .br .in +.5i The maximum scale value in the \fIbc(1)\fP utility. .sp .in -.5i USER_BC_STRING_MAX .br .in +.5i The maximum string length in the \fIbc(1)\fP utility. .sp .in -.5i USER_COLL_WEIGHTS_MAX .br .in +.5i The maximum number of weights that can be assigned to any entry of the LC_COLLATE order keyword in the locale definition file. .sp .in -.5i USER_CS_PATH .br .in +.5i Return a value for the \fIPATH\fP environment variable that finds all the standard utilities. .sp .in -.5i USER_EXPR_NEST_MAX .br .in +.5i The maximum number of expressions that can be nested within parenthesis by the \fIexpr(1)\fP utility. .sp .in -.5i USER_LINE_MAX .br .in +.5i The maximum length in bytes of a text-processing utility's input line. .sp .in -.5i USER_POSIX2_CHAR_TERM .br .in +.5i Return 1 if the system supports at least one terminal type capable of all operations described in POSIX 1003.2, otherwise 0. .sp .in -.5i USER_POSIX2_C_BIND .br .in +.5i Return 1 if the system's C-language development facilities support the C-Language Bindings Option, otherwise 0. .sp .in -.5i USER_POSIX2_C_DEV .br .in +.5i Return 1 if the system supports the C-Language Development Utilities Option, otherwise 0. .sp .in -.5i USER_POSIX2_FORT_DEV .br .in +.5i Return 1 if the system supports the FORTRAN Development Utilities Option, otherwise 0. .sp .in -.5i USER_POSIX2_FORT_RUN .br .in +.5i Return 1 if the system supports the FORTRAN Runtime Utilities Option, otherwise 0. .sp .in -.5i USER_POSIX2_LOCALEDEF .br .in +.5i Return 1 if the system supports the creation of locales, otherwise 0. .sp .in -.5i USER_POSIX2_SW_DEV .br .in +.5i Return 1 if the system supports the Software Development Utilities Option, otherwise 0. .sp .in -.5i USER_POSIX2_UPE .br .in +.5i Return 1 if the system supports the User Portability Utilities Option, otherwise 0. .sp .in -.5i USER_POSIX2_VERSION .br .in +.5i The version of POSIX 1003.2 with which the system attempts to comply. .sp .in -.5i USER_RE_DUP_MAX .br .in +.5i The maximum number of repeated occurrences of a regular expression permitted when using interval notation. .sp .in -.5i USER_STREAM_MAX .br .in +.5i The minimum maximum number of streams that a process may have open at any one time. .sp .in -.5i USER_TZNAME_MAX .br .in +.5i The minimum maximum number of types supported for the name of a timezone. .br .in -.5i .SH CTL_VM The string and integer information available for the CTL_VM level is detailed below. The changeable column shows whether a process with appropriate privilege may change the value. .sp .nf .ta .25i 2.25i 4.0i Second level name Type Changeable VM\_LOADAVG struct loadavg no VM\_METER struct vmtotal no VM\_SWAPMAP struct map no VM\_COREMAP struct map no .fi .PP VM_LOADAVG .br .in +.5i Return the load average history. The returned data consists of a \fIstruct loadavg\fP. .sp .in -.5i VM_METER .br .in +.5i Return the system wide virtual memory statistics. The returned data consists of a \fIstruct vmtotal\fP. .br .in -.5i .sp VM_SWAPMAP .br .in +.5i Return the swapmap. The size of this structure is fixed and may be determined by specifying a \fBoldlenp\fP initialized to zero, the kernel will fill in the size of the swapmap. .in -.5i .sp VM_COREMAP .br .in +.5i Same as for swapmap above except that the core allocation map is returned. .in -.5i .SH RETURN VALUES If the call to \fBsysctl\fP is successful, 0 is returned. Otherwise \-1 is returned and \fIerrno\fP is set appropriately. .SH ERRORS The following errors may be reported: .TP 15 EFAULT The buffer \fIname\fP, \fIoldp\fP, \fInewp\fP, or length pointer \fIoldlenp\fP contains an invalid address. .TP 15 EINVAL The \fIname\fP array is less than two or greater than CTL_MAXNAME. .TP 15 EINVAL A non-null \fInewp\fP is given and its specified length in \fInewlen\fP is too large or too small. .TP 15 ENOMEM The length pointed to by \fIoldlenp\fP is too short to hold the requested value. .TP 15 ENOTDIR The \fIname\fP array specifies an intermediate rather than terminal name. .TP 15 EOPNOTSUPP The \fIname\fP array specifies a value that is unknown. .TP 15 EPERM An attempt is made to set a read-only value. .TP 15 EPERM A process without appropriate privilege attempts to set a value. .SH FILES .TP 15 definitions for top level identifiers, second level kernel and hardware identifiers, and user level identifiers .TP 15 definitions for second level network identifiers .TP 15 definitions for third level profiling identifiers .TP 15 definitions for second level virtual memory identifiers .TP 15 definitions for third level Internet identifiers and fourth level IP identifiers .TP 15 definitions for fourth level ICMP identifiers .TP 15 definitions for fourth level UDP identifiers .SH SEE ALSO .I sysctl(8) .SH HISTORY The .B sysctl function first appeared in 4.4BSD. .PP The KERN_TEXT, KERN_MAXTEXTS, VM_SWAPMAP, VM_COREMAP options are 2.11BSD specific extensions to the 4.4BSD \fIsysctl\fP implmentation. .PP Having KERN_FILE return the address of the file structure before the actual \fIstruct file\fP is a 2.11BSD enhancement. The \fIinode\fP (\fIvnode\fP under 4.4) table was handled this way. ================================================ FILE: share/man/man3/syserrlst.3 ================================================ .\" Public Domain, March 1996, Steven M. Schultz .\" .\" @(#)syserrlst.3 1.1 (2.11BSD) 1996/3/26 .\" .TH SYSERRLST 3 "March 26, 1996" .UC 2 .SH NAME syserrlst, __errlst \- read system error messages from file .SH SYNOPSIS .nf .B char * .B syserrlst(err) .B int err; .PP .B char * .B __errlst(err, path); .B int err; .B char *path; .fi .SH DESCRIPTION .BR Syserrlst (3) reads the error message string corresponding to \fIerr\fP from the file \fI/etc/syserrlst\fP. .PP .BR __errlst(3) reads the error message string corresponding to \fIerr\fP from the file \fIpath\fP. The file \fIpath\fP must be in the format described in .BR syserrlst (5). .PP .B NULL is returned if \fIerr\fP is out of bounds (negative or greater than the highest message number in \fI/etc/syserrlst\fP or \fIpath\fP) or if the error message file can not be opened. It is the responsibility of the caller (\fBstrerror\fP(3)) to check for and properly handle the \fINULL\fP return. .SH "RETURN VALUE" .B NULL if an error was encountered in opening the error message file, if the error was out of bounds, or if the file did not start with the correct magic number. Otherwise a .B "char *" is returned pointing to a static buffer containing the text of the error message. .SH ERRORS .BR syserrlst (3) and .BR __errlst (3) can return any of the errors for the .BR open (2), .BR lseek (2), or .BR read (2) system calls. .SH "SEE ALSO" perror(3), strerror(3), syserrlst(5) .SH HISTORY .BR syserrlst (3), and .BR __errlst (3) were created for 2.11BSD with the aim of saving 2kb of \fBData\fP space in programs which called .BR perror (3), or .BR strerror (3). .SH BUGS The information is stored in a static buffer. ================================================ FILE: share/man/man3/syslog.3 ================================================ .\" Copyright (c) 1985, 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. All advertising materials mentioning features or use of this software .\" must display the following acknowledgement: .\" This product includes software developed by the University of .\" California, Berkeley and its contributors. .\" 4. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)syslog.3 8.1.1 (2.11BSD) 1995/04/01 .\" .TH SYSLOG 3 "April 1, 1995" .UC 5 .SH NAME syslog , vsyslog , openlog , closelog , setlogmask \- control system log .SH SYNOPSIS .B #include .br .B #include .PP .B void syslog(priority, message, ...); .br .B int priority; .br .B char *message; .PP .B void vsyslog(priority, message, args); .br .B int priority; .br .B char *message; .br .B va_list args; .PP .B void openlog(ident, logopt, facility); .br .B char *ident; .br .B int logopt; .br .B int facility; .PP .B void closelog(); .PP .B int setlogmask(maskpri); .br .B int maskpri; .SH DESCRIPTION The .IR syslog () function writes .I message to the system message logger. The message is then written to the system console, log files, logged-in users, or forwarded to other machines as appropriate. (See .IR syslogd (8)). .PP The message is identical to a .IR printf (3) format string, except that .B %m is replaced by the current error message as denoted by the global variable \fIerrno\fP. See .IR strerror (3)). A trailing newline is added if none is present. .PP The .IR vsyslog () function is an alternate form in which the arguments have already been captured using the variable-length argument facilities of .IR varargs (3). .PP The message is tagged with .IR priority . Priorities are encoded as a .I facility and a .IR level . The facility describes the part of the system generating the message. The level is selected from the following .I ordered (high to low) list: .IP LOG_EMERG \w'LOG_AUTHORITY'u+3 A panic condition. This is normally broadcast to all users. .IP LOG_ALERT \w'LOG_AUTHORITY'u+3 A condition that should be corrected immediately, such as a corrupted system database. .IP LOG_CRIT \w'LOG_AUTHORITY'u+3 Critical conditions, e.g., hard device errors. .IP LOG_ERR \w'LOG_AUTHORITY'u+3 Errors. .IP LOG_WARNING \w'LOG_AUTHORITY'u+3 Warning messages. .IP LOG_NOTICE \w'LOG_AUTHORITY'u+3 Conditions that are not error conditions, but should possibly be handled specially. .IP LOG_INFO \w'LOG_AUTHORITY'u+3 Informational messages. .IP LOG_DEBUG \w'LOG_AUTHORITY'u+3 Messages that contain information normally of use only when debugging a program. .PP The .IR openlog () function provides for more specialized processing of the messages sent by .IR syslog () and .IR vsyslog (). The parameter .I ident is a string that will be prepended to every message. The .I logopt argument is a bit field specifying logging options, which is formed by .B OR'ing one or more of the following values: .IP LOG_CONS \w'LOG_AUTHPRIV'u+3 If .IR syslog cannot pass the message to .IR syslogd it will attempt to write the message to the console (\fB/dev/console\fP). .IP LOG_NDELAY \w'LOG_AUTHPRIV'u+3 Open the connection to .IR syslogd immediately. Normally the open is delayed until the first message is logged. Useful for programs that need to manage the order in which file descriptors are allocated. .IP LOG_PERROR \w'LOG_AUTHPRIV'u+3 Write the message to standard error output as well to the system log. .IP LOG_PID \w'LOG_AUTHPRIV'u+3 Log the process id with each message: useful for identifying instantiations of daemons. .PP The .IR facility parameter encodes a default facility to be assigned to all messages that do not have an explicit facility encoded: .IP LOG_AUTH \w'LOG_AUTHPRIV'u+3 The authorization system: .IR login (1), .IR su (1), .IR getty (8), etc. .IP LOG_AUTHPRIV \w'LOG_AUTHPRIV'u+3 The same as .B LOG_AUTH , but logged to a file readable only by selected individuals. .IP LOG_CRON \w'LOG_AUTHPRIV'u+3 The clock daemon. .IP LOG_DAEMON \w'LOG_AUTHPRIV'u+3 System daemons, such as .IR routed (8), that are not provided for explicitly by other facilities. .IP LOG_KERN \w'LOG_AUTHPRIV'u+3 Messages generated by the kernel. These cannot be generated by any user processes. .IP LOG_LPR \w'LOG_AUTHPRIV'u+3 The line printer spooling system: .IR lpr (1), .IR lpc (8), .IR lpd (8), etc. .IP LOG_MAIL \w'LOG_AUTHPRIV'u+3 The mail system. .IP LOG_NEWS \w'LOG_AUTHPRIV'u+3 The network news system. .IP LOG_SYSLOG \w'LOG_AUTHPRIV'u+3 Messages generated internally by .IR syslogd (8). .IP LOG_USER \w'LOG_AUTHPRIV'u+3 Messages generated by random user processes. This is the default facility identifier if none is specified. .IP LOG_UUCP \w'LOG_AUTHPRIV'u+3 The uucp system. .IP LOG_LOCAL0 \w'LOG_AUTHPRIV'u+3 Reserved for local use. Similarly for \fBLOG_LOCAL1\fP through \fBLOG_LOCAL7\fP. .PP The .IR closelog function can be used to close the log file. .PP The .IR setlogmask function sets the log priority mask to .I maskpri and returns the previous mask. Calls to .IR syslog with a priority not set in .I maskpri are rejected. The mask for an individual priority .I pri is calculated by the macro .IR LOG_MASK (pri). The mask for all priorities up to and including .I toppri is given by the macro .IR LOG_UPTO (toppri). The default allows all priorities to be logged. .PP .SH RETURN VALUES The routines .IR closelog (), .IR openlog (), .IR syslog () and .IR vsyslog () return no value. .PP The routine .IR setlogmask () always returns the previous log mask level. .PP .SH EXAMPLES .IP "" 8 syslog(LOG_ALERT, "who: internal error 23"); openlog("ftpd", LOG_PID, LOG_DAEMON); setlogmask(LOG_UPTO(LOG_ERR)); syslog(LOG_INFO, "Connection from host %d", CallingHost); syslog(LOG_INFO|LOG_LOCAL2, "foobar error: %m"); .PP .SH SEE ALSO .I logger(1), syslogd(8) .SH BUGS Under 2.11BSD the logfile \fB/usr/adm/messages\fP is used if a non networking kernel has been booted. That file must be publically writeable in this case. .SH HISTORY These functions appeared in 4.2BSD. ================================================ FILE: share/man/man3/system.3 ================================================ .\" @(#)system.3 6.1 (Berkeley) 5/15/85 .\" .TH SYSTEM 3 "May 15, 1985" .AT 3 .SH NAME system \- issue a shell command .SH SYNOPSIS .nf .B system(string) .B char *string; .fi .SH DESCRIPTION .I System causes the .I string to be given to .IR sh (1) as input as if the string had been typed as a command at a terminal. The current process waits until the shell has completed, then returns the exit status of the shell. .SH "SEE ALSO" popen(3S), execve(2), wait(2) .SH DIAGNOSTICS Exit status 127 indicates the shell couldn't be executed. ================================================ FILE: share/man/man3/termcap.3 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)termcap.3x 6.1 (Berkeley) 5/15/85 .\" .TH TERMCAP 3X "May 15, 1985" .UC 4 .SH NAME tgetent, tgetnum, tgetflag, tgetstr, tgoto, tputs \- terminal independent operation routines .SH SYNOPSIS .nf .B char PC; .B char *BC; .B char *UP; .B short ospeed; .PP .B tgetent(bp, name) .B char *bp, *name; .PP .B tgetnum(id) .B char *id; .PP .B tgetflag(id) .B char *id; .PP .B char * .B tgetstr(id, area) .B char *id, **area; .PP .B char * .B tgoto(cm, destcol, destline) .B char *cm; .PP .B tputs(cp, affcnt, outc) .B register char *cp; .B int affcnt; .B int (*outc)(); .fi .SH DESCRIPTION These functions extract and use capabilities from the terminal capability data base .IR termcap (5). These are low level routines; see .IR curses (3X) for a higher level package. .PP .I Tgetent extracts the entry for terminal .I name into the buffer at .I bp. .I Bp should be a character buffer of size 1024 and must be retained through all subsequent calls to .I tgetnum, .I tgetflag, and .I tgetstr. .I Tgetent returns \-1 if it cannot open the .I termcap file, 0 if the terminal name given does not have an entry, and 1 if all goes well. It will look in the environment for a TERMCAP variable. If found, and the value does not begin with a slash, and the terminal type .B name is the same as the environment string TERM, the TERMCAP string is used instead of reading the termcap file. If it does begin with a slash, the string is used as a path name rather than .I /etc/termcap. This can speed up entry into programs that call .IR tgetent , as well as to help debug new terminal descriptions or to make one for your terminal if you can't write the file .I /etc/termcap. .PP .I Tgetnum gets the numeric value of capability .I id, returning \-1 if is not given for the terminal. .I Tgetflag returns 1 if the specified capability is present in the terminal's entry, 0 if it is not. .I Tgetstr returns the string value of the capability .I id, places it in the buffer at .I area, and advances the .I area pointer. It decodes the abbreviations for this field described in .IR termcap (5), except for cursor addressing and padding information. .I Tgetstr returns NULL if the capability was not found. .PP .I Tgoto returns a cursor addressing string decoded from .I cm to go to column .I destcol in line .I destline. It uses the external variables .B UP (from the \fBup\fR capability) and .B BC (if \fBbc\fR is given rather than \fBbs\fR) if necessary to avoid placing \fB\en\fR, \fB^D\fR or \fB^@\fR in the returned string. (Programs which call tgoto should be sure to turn off the XTABS bit(s), since .I tgoto may now output a tab. Note that programs using termcap should in general turn off XTABS anyway since some terminals use control I for other functions, such as nondestructive space.) If a \fB%\fR sequence is given which is not understood, then .I tgoto returns \*(lqOOPS\*(rq. .PP .I Tputs decodes the leading padding information of the string .IR cp ; .I affcnt gives the number of lines affected by the operation, or 1 if this is not applicable, .I outc is a routine which is called with each character in turn. The external variable .I ospeed should contain the output speed of the terminal as encoded by .IR stty (3). The external variable .B PC should contain a pad character to be used (from the \fBpc\fR capability) if a null (\fB^@\fR) is inappropriate. .SH FILES .ta \w'/usr/lib/libtermcap.a 'u /usr/lib/libtermcap.a \-ltermcap library .br /etc/termcap data base .DT .SH SEE ALSO ex(1), curses(3X), termcap(5) .SH AUTHOR William Joy ================================================ FILE: share/man/man3/time.3 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)time.3c 6.1 (Berkeley) 5/9/85 .\" .TH TIME 3C "May 9, 1985" .UC 4 .SH NAME time, ftime \- get date and time .SH SYNOPSIS .nf .B long time(0) .PP .B long time(tloc) .B long *tloc; .PP .B #include .B #include .B ftime(tp) .B struct timeb *tp; .fi .SH DESCRIPTION .ft B These interfaces are obsoleted by gettimeofday(2). .ft R .PP .I Time returns the time since 00:00:00 GMT, Jan. 1, 1970, measured in seconds. .PP If .I tloc is nonnull, the return value is also stored in the place to which .I tloc points. .PP The .I ftime entry fills in a structure pointed to by its argument, as defined by .RI < sys/timeb.h >: .ta .5i +\w'unsigned 'u .nf .IP /* * Structure returned by ftime system call */ struct timeb { time_t time; unsigned short millitm; short timezone; short dstflag; }; .fi .PP The structure contains the time since the epoch in seconds, up to 1000 milliseconds of more-precise interval, the local time zone (measured in minutes of time westward from Greenwich), and a flag that, if nonzero, indicates that Daylight Saving time applies locally during the appropriate part of the year. .SH "SEE ALSO" date(1), gettimeofday(2), settimeofday(2), ctime(3) ================================================ FILE: share/man/man3/times.3 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)times.3c 6.1 (Berkeley) 5/9/85 .\" .TH TIMES 3C "May 9, 1985" .UC 4 .SH NAME times \- get process times .SH SYNOPSIS .nf .B "#include .B "#include .PP .B times(buffer) .B struct tms *buffer; .fi .SH DESCRIPTION .ft B This interface is obsoleted by getrusage(2). .ft R .PP .I Times returns time-accounting information for the current process and for the terminated child processes of the current process. All times are in 1/HZ seconds, where HZ is 60. .PP This is the structure returned by .IR times : .PP .nf .so /usr/include/sys/times.h .PP .fi The children times are the sum of the children's process times and their children's times. .SH "SEE ALSO" time(1), getrusage(2), wait3(2), time(3) ================================================ FILE: share/man/man3/ttyname.3 ================================================ .\" @(#)ttyname.3 6.1 (Berkeley) 5/15/85 .\" .TH TTYNAME 3 "May 15, 1985" .AT 3 .SH NAME ttyname, isatty, ttyslot \- find name of a terminal .SH SYNOPSIS .B char *ttyname(filedes) .PP .B isatty(filedes) .PP .B ttyslot() .SH DESCRIPTION .I Ttyname returns a pointer to the null-terminated path name of the terminal device associated with file descriptor .I filedes (this is a system file descriptor and has nothing to do with the standard I/O FILE typedef). .PP .I Isatty returns 1 if .I filedes is associated with a terminal device, 0 otherwise. .PP .I Ttyslot returns the number of the entry in the .IR ttys (5) file for the control terminal of the current process. .SH FILES /dev/\(** .br /etc/ttys .SH SEE ALSO ioctl(2), ttys(5) .SH DIAGNOSTICS .I Ttyname returns a null pointer (0) if .I filedes does not describe a terminal device in directory `/dev'. .PP .I Ttyslot returns 0 if `/etc/ttys' is inaccessible or if it cannot determine the control terminal. .SH BUGS The return value points to static data whose content is overwritten by each call. ================================================ FILE: share/man/man3/ualarm.3 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)@(#)ualarm.3 6.4 (Berkeley) 8/26/88 .\" .TH UALARM 3 "August 26, 1988" .UC 6 .SH NAME ualarm \- schedule signal after specified time .SH SYNOPSIS .nf .B unsigned ualarm(value, interval) .B unsigned value; .B unsigned interval; .fi .SH DESCRIPTION .ft B This is a simplified interface to setitimer(2). .ft R .PP .I Ualarm causes signal SIGALRM, see .IR signal (3C), to be sent to the invoking process in a number of microseconds given by the .I value argument. Unless caught or ignored, the signal terminates the process. .PP If the .I interval argument is non-zero, the SIGALRM signal will be sent to the process every .I interval microseconds after the timer expires (e.g. after .I value microseconds have passed). .PP Because of scheduling delays, resumption of execution of when the signal is caught may be delayed an arbitrary amount. The longest specifiable delay time (on the vax) is 2147483647 microseconds. .PP The return value is the amount of time previously remaining in the alarm clock. .SH "SEE ALSO" getitimer(2), setitimer(2), sigpause(2), sigvec(2), signal(3C), sleep(3), alarm(3), usleep(3) .SH "NOTES (PDP-11)" On the PDP-11, .IR setitimer (2) rounds the number of microseconds up to seconds resolution, therefore .I ualarm doesn't give you any more resolution than .IR alarm (3). ================================================ FILE: share/man/man3/uname.3 ================================================ .\" Copyright (c) 1994 .\" The Regents of the University of California. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. All advertising materials mentioning features or use of this software .\" must display the following acknowledgement: .\" This product includes software developed by the University of .\" California, Berkeley and its contributors. .\" 4. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)uname.3 8.1.1 (2.11BSD GTE) 2/4/95 .\" .TH UNAME 3 "February 4, 1995" .UC 4 .SH NAME uname \- get system identification .SH SYNOPSIS .nf .ft B #include int uname(struct utsname *name); .ft R .fi .SH DESCRIPTION The .B uname function stores nul-terminated strings of information identifying the current system into the structure referenced by .IR name . .PP The .I utsname structure is defined in the .I header file, and contains the following members: .TP 15 sysname Name of the operating system implementation. .TP 15 nodename Network name of this machine. .TP 15 release Release level of the operating system. .TP 15 version Version level of the operating system. .TP 15 machine Machine hardware platform. .SH RETURN VALUES If .B uname is successful, 0 is returned, otherwise, -1 is returned and .I errno is set appropriately. .SH ERRORS The .B uname function may fail and set .I errno for any of the errors specified for the library function sysctl(3). .SH SEE ALSO uname(1), sysctl(3) .SH STANDARDS The .B uname function conforms to IEEE Std1003.1-88 (``POSIX''). .SH HISTORY The .B uname function first appeared in 4.4BSD. ================================================ FILE: share/man/man3/ungetc.3 ================================================ .\" @(#)ungetc.3s 6.1 (Berkeley) 5/15/85 .\" .TH UNGETC 3S "May 15, 1985" .AT 3 .SH NAME ungetc \- push character back into input stream .SH SYNOPSIS .B #include .PP .B ungetc(c, stream) .br .SM .B FILE .B *stream; .SH DESCRIPTION .I Ungetc pushes the character .I c back on an input stream. That character will be returned by the next .I getc call on that stream. .I Ungetc returns .IR c . .PP One character of pushback is guaranteed provided something has been read from the stream and the stream is actually buffered. Attempts to push EOF are rejected. .PP .IR Fseek (3S) erases all memory of pushed back characters. .SH "SEE ALSO" getc(3S), setbuf(3S), fseek(3S) .SH DIAGNOSTICS .I Ungetc returns .SM .B EOF if it can't push a character back. ================================================ FILE: share/man/man3/utime.3 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)utime.3c 6.1 (Berkeley) 5/9/85 .\" .TH UTIME 3C "May 9, 1985" .UC 4 .SH NAME utime \- set file times .SH SYNOPSIS .nf .B #include .PP .B utime(file, timep) .B char *file; .B time_t timep[2]; .fi .SH DESCRIPTION .ft B This interface is obsoleted by utimes(2). .ft R .PP The .I utime call uses the `accessed' and `updated' times in that order from the .I timep vector to set the corresponding recorded times for .IR file . .PP The caller must be the owner of the file or the super-user. The `inode-changed' time of the file is set to the current time. .SH SEE ALSO utimes(2), stat(2) ================================================ FILE: share/man/man3/valloc.3 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)valloc.3c 6.2 (Berkeley) 5/12/86 .\" .TH VALLOC 3C "May 12, 1986" .UC 3 .SH NAME valloc \- aligned memory allocator .SH SYNOPSIS .nf .B char *valloc(size) .B unsigned size; .fi .SH DESCRIPTION .ft B Valloc is obsoleted by the current version of malloc, which aligns page-sized and larger allocations. .ft R .PP .I Valloc allocates .I size bytes aligned on a page boundary. It is implemented by calling .IR malloc (3) with a slightly larger request, saving the true beginning of the block allocated, and returning a properly aligned pointer. .SH DIAGNOSTICS .I Valloc returns a null pointer (0) if there is no available memory or if the arena has been detectably corrupted by storing outside the bounds of a block. .SH BUGS .I Vfree isn't implemented. ================================================ FILE: share/man/man3/varargs.3 ================================================ .\" @(#)varargs.3 6.3 (Berkeley) 5/15/86 .\" .TH VARARGS 3 "May 15, 1986" .AT 3 .SH NAME varargs \- variable argument list .SH SYNOPSIS .B "#include " .PP .I function\c .RB ( va_alist ) .br .B va_dcl .br .B va_list .IR pvar ; .br .B va_start\c .RI ( pvar ); .br f = .B va_arg\c .RI ( pvar , .IR type ); .br .B va_end\c .RI ( pvar ); .SH DESCRIPTION This set of macros provides a means of writing portable procedures that accept variable argument lists. Routines having variable argument lists (such as .IR printf (3)) that do not use varargs are inherently nonportable, since different machines use different argument passing conventions. .PP .B va_alist is used in a function header to declare a variable argument list. .PP .B va_dcl is a declaration for .BR va_alist . Note that there is no semicolon after .B va_dcl. .PP .B va_list is a type which can be used for the variable .IR pvar , which is used to traverse the list. One such variable must always be declared. .PP .B va_start\c .RI (pvar) is called to initialize .I pvar to the beginning of the list. .PP .B va_arg\c .RI ( pvar , .IR type ) will return the next argument in the list pointed to by .IR pvar . .I Type is the type to which the expected argument will be converted when passed as an argument. In standard C, arguments that are .B char or .B short should be accessed as .BR int , .B "unsigned char or .B "unsigned short are converted to .BR "unsigned int" , and .B float arguments are converted to .BR double . Different types can be mixed, but it is up to the routine to know what type of argument is expected, since it cannot be determined at runtime. .PP .B va_end\c .RI ( pvar ) is used to finish up. .PP Multiple traversals, each bracketed by .B va_start \&... .B va_end, are possible. .SH EXAMPLE .nf \fB#include\fP execl(\fBva_alist\fP) \fBva_dcl\fP { \fBva_list\fP ap; \fBchar\fP *file; \fBchar\fP *args[100]; \fBint\fP argno = 0; \fBva_start\fP(ap); file = \fBva_arg(ap, \fBchar\fP *); \fBwhile\fP (args[argno++] = \fBva_arg\fP(ap, \fBchar\fP *)) \fB;\fP \fBva_end\fP(ap); \fBreturn\fP execv(file, args); } .fi .SH BUGS It is up to the calling routine to determine how many arguments there are, since it is not possible to determine this from the stack frame. For example, .I execl passes a 0 to signal the end of the list. .I Printf can tell how many arguments are supposed to be there by the format. .PP The macros .I va_start and .I va_end may be arbitrarily complex; for example, .I va_start might contain an opening brace, which is closed by a matching brace in .IR va_end . Thus, they should only be used where they could be placed within a single complex statement. ================================================ FILE: share/man/man4/Makefile ================================================ # # Copyright (c) 1987 Regents of the University of California. # All rights reserved. # # Redistribution and use in source and binary forms are permitted # provided that the above copyright notice and this paragraph are # duplicated in all such forms and that any documentation, # advertising materials, and other materials related to such # distribution and use acknowledge that the software was developed # by the University of California, Berkeley. The name of the # University may not be used to endorse or promote products derived # from this software without specific prior written permission. # THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED # WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. # # @(#)Makefile 5.4.3 (2.11BSD) 1997/5/31 # TOPSRC!=cd ../../..; pwd include ${TOPSRC}/share/mk/sys.mk MDIR= ${DESTDIR}/usr/share/man/cat4 SRCS= acc.4 arp.4 bk.4 br.4 cons.4 css.4 de.4 dh.4 dhu.4 dhv.4 \ dmc.4 dr.4 dz.4 \ ec.4 en.4 fd.4 hk.4 ht.4 hy.4 icmp.4 idp.4 il.4 imp.4 impconf.4 inet.4 \ intro.4 ip.4 lo.4 lp.4 mem.4 mtio.4 networking.4 ns.4 nsip.4 \ null.4 pty.4 qe.4 ra.4 ram.4 rk.4 rl.4 rx.4 si.4 spp.4 sri.4 \ swap.4 tb.4 tcp.4 tm.4 tmscp.4 ts.4 tty.4 udp.4 vv.4 xp.4 OBJS= acc.0 arp.0 bk.0 br.0 cons.0 css.0 de.0 dh.0 dhu.0 dhv.0 \ dmc.0 dr.0 \ dz.0 ec.0 en.0 fd.0 hk.0 ht.0 hy.0 icmp.0 idp.0 il.0 imp.0 impconf.0 \ inet.0 intro.0 ip.0 lo.0 lp.0 mem.0 mtio.0 networking.0 ns.0 \ nsip.0 null.0 pty.0 qe.0 ra.0 ram.0 rk.0 rl.0 rx.0 si.0 spp.0 \ sri.0 swap.0 tb.0 tcp.0 tm.0 tmscp.0 ts.0 tty.0 udp.0 vv.0 xp.0 .SUFFIXES: .4 .0 .4.0: ${MANROFF} $*.4 > $*.0 all: ${OBJS} clean: FRC rm -f ${OBJS} install: all cp ${OBJS} ${MDIR} ln -f ${MDIR}/xp.0 ${MDIR}/dvhp.0 ln -f ${MDIR}/xp.0 ${MDIR}/hp.0 ln -f ${MDIR}/xp.0 ${MDIR}/rm.0 ln -f ${MDIR}/xp.0 ${MDIR}/rp.0 ln -f ${MDIR}/mem.0 ${MDIR}/kmem.0 ln -f ${MDIR}/fd.0 ${MDIR}/stdin.0 ln -f ${MDIR}/fd.0 ${MDIR}/stderr.0 ln -f ${MDIR}/fd.0 ${MDIR}/stdout.0 FRC: ================================================ FILE: share/man/man4/acc.4 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)acc.4 6.1 (Berkeley) 7/26/87 .\" .TH ACC 4 "July 26, 1987" .UC 2 .SH NAME acc \- ACC LH/DH IMP interface .SH SYNOPSIS .ft B .nf /sys/conf/SYSTEM: NACC 0 # ACC LH/DH ARPAnet IMP interface PLI YES # LH/DH is connected to a PLI .fi .ft R .SH DESCRIPTION The .I acc device provides a Local Host/Distant Host interface to an IMP. It is normally used when participating in the DARPA Internet. The controller itself is not accessible to users, but instead provides the hardware support to the IMP interface described in .IR imp (4). When configuring, the .IR imp ( NIMP ) pseudo-device must also be included. .SH DIAGNOSTICS .BR "acc%d: not alive" . The initialization routine was entered even though the device did not autoconfigure. This indicates a system problem. .PP .BR "acc%d: can't initialize" . Insufficient UNIBUS resources existed to initialize the device. This is likely to occur when the device is run on a buffered data path on an 11/750 and other network interfaces are also configured to use buffered data paths, or when it is configured to use buffered data paths on an 11/730 (which has none). .PP .BR "acc%d: imp doesn't respond, icsr=%b" . The driver attempted to initialize the device, but the IMP failed to respond after 500 tries. Check the cabling. .PP .BR "acc%d: stray xmit interrupt, csr=%b" . An interrupt occurred when no output had previously been started. .PP .BR "acc%d: output error, ocsr=%b, icsr=%b" . The device indicated a problem sending data on output. .PP .BR "acc%d: input error, csr=%b" . The device indicated a problem receiving data on input. .PP .BR "acc%d: bad length=%d" . An input operation resulted in a data transfer of less than 0 or more than 1008 bytes of data into memory (according to the word count register). This should never happen as the maximum size of a host-IMP message is 1008 bytes. ================================================ FILE: share/man/man4/arp.4 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)arp.4p 6.2 (Berkeley) 8/1/87 .\" .TH ARP 4P "August 1, 1987" .UC 2 .SH NAME arp \- Address Resolution Protocol .SH SYNOPSIS .ft B .nf /sys/conf/SYSTEM: NETHER \fI1\fP # ether pseudo-device .fi .ft R .SH DESCRIPTION ARP is a protocol used to dynamically map between DARPA Internet and 10Mb/s Ethernet addresses. It is used by all the 10Mb/s Ethernet interface drivers. It is not specific to Internet protocols or to 10Mb/s Ethernet, but this implementation currently supports only that combination. .PP ARP caches Internet-Ethernet address mappings. When an interface requests a mapping for an address not in the cache, ARP queues the message which requires the mapping and broadcasts a message on the associated network requesting the address mapping. If a response is provided, the new mapping is cached and any pending message is transmitted. ARP will queue at most one packet while waiting for a mapping request to be responded to; only the most recently ``transmitted'' packet is kept. .PP To facilitate communications with systems which do not use ARP, .IR ioctl \^s are provided to enter and delete entries in the Internet-to-Ethernet tables. Usage: .LP .nf .ft B #include #include #include struct arpreq arpreq; ioctl(s, SIOCSARP, (caddr_t)&arpreq); ioctl(s, SIOCGARP, (caddr_t)&arpreq); ioctl(s, SIOCDARP, (caddr_t)&arpreq); .fi .ft R Each ioctl takes the same structure as an argument. SIOCSARP sets an ARP entry, SIOCGARP gets an ARP entry, and SIOCDARP deletes an ARP entry. These ioctls may be applied to any socket descriptor .I s, but only by the super-user. The .I arpreq structure contains: .LP .RS .ta \w'#define\ \ 'u +\w'ATF_USETRAILERS\ \ 'u +\w'0x08\ \ \ \ 'u .nf /* * ARP ioctl request */ struct arpreq { struct sockaddr arp_pa; /* protocol address */ struct sockaddr arp_ha; /* hardware address */ int arp_flags; /* flags */ }; /* arp_flags field values */ #define ATF_COM 0x02 /* completed entry (arp_ha valid) */ #define ATF_PERM 0x04 /* permanent entry */ #define ATF_PUBL 0x08 /* publish (respond for other host) */ #define ATF_USETRAILERS 0x10 /* send trailer packets to host */ .fi .RE .LP The address family for the .I arp_pa sockaddr must be AF_INET; for the .I arp_ha sockaddr it must be AF_UNSPEC. The only flag bits which may be written are ATF_PERM, ATF_PUBL and ATF_USETRAILERS. ATF_PERM causes the entry to be permanent if the ioctl call succeeds. The peculiar nature of the ARP tables may cause the ioctl to fail if more than 8 (permanent) Internet host addresses hash to the same slot. ATF_PUBL specifies that the ARP code should respond to ARP requests for the indicated host coming from other machines. This allows a host to act as an ``ARP server,'' which may be useful in convincing an ARP-only machine to talk to a non-ARP machine. .PP ARP is also used to negotiate the use of trailer IP encapsulations; trailers are an alternate encapsulation used to allow efficient packet alignment for large packets despite variable-sized headers. Hosts which wish to receive trailer encapsulations so indicate by sending gratuitous ARP translation replies along with replies to IP requests; they are also sent in reply to IP translation replies. The negotiation is thus fully symmetrical, in that either or both hosts may request trailers. The ATF_USETRAILERS flag is used to record the receipt of such a reply, and enables the transmission of trailer packets to that host. .PP ARP watches passively for hosts impersonating the local host (i.e. a host which responds to an ARP mapping request for the local host's address). .SH DIAGNOSTICS .B "duplicate IP address!! sent from ethernet address: %x:%x:%x:%x:%x:%x." ARP has discovered another host on the local network which responds to mapping requests for its own Internet address. .SH SEE ALSO ec(4), de(4), il(4), inet(4F), arp(8C), ifconfig(8C) .br ``An Ethernet Address Resolution Protocol,'' RFC826, Dave Plummer, Network Information Center, SRI. .br ``Trailer Encapsulations,'' RFC893, S.J. Leffler and M.J. Karels, Network Information Center, SRI. .SH BUGS ARP packets on the Ethernet use only 42 bytes of data; however, the smallest legal Ethernet packet is 60 bytes (not including CRC). Some systems may not enforce the minimum packet size, others will. ================================================ FILE: share/man/man4/bk.4 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)bk.4 6.1.1 (2.11BSD) 1996/1/27 .\" .TH BK 4 "January 27, 1996" .UC 4 .SH NAME bk \- line discipline for machine-machine communication (obsolete) .SH SYNOPSIS .ft B .nf Not currently supported under 2.11BSD .fi .ft R .SH DESCRIPTION This line discipline provides a replacement for the old and new tty drivers described in .IR tty (4) when high speed output to and especially input from another machine is to be transmitted over a asynchronous communications line. The discipline was designed for use by the Berkeley network. It may be suitable for uploading of data from microprocessors into the system. If you are going to send data over asynchronous communications lines at high speed into the system, you must use this discipline, as the system otherwise may detect high input data rates on terminal lines and disables the lines; in any case the processing of such data when normal terminal mechanisms are involved saturates the system. .PP The line discipline is enabled by a sequence: .PP .nf .ft B #include int ldisc = NETLDISC, fildes; ... ioctl(fildes, TIOCSETD, &ldisc); .fi .ft R .PP A typical application program then reads a sequence of lines from the terminal port, checking header and sequencing information on each line and acknowledging receipt of each line to the sender, who then transmits another line of data. Typically several hundred bytes of data and a smaller amount of control information will be received on each handshake. .PP The old standard teletype discipline can be restored by doing: .PP .nf .ft B ldisc = OTTYDISC; ioctl(fildes, TIOCSETD, &ldisc); .fi .ft R .PP While in networked mode, normal teletype output functions take place. Thus, if an 8 bit output data path is desired, it is necessary to prepare the output line by putting it into RAW mode using .IR ioctl (2). This must be done .B before changing the discipline with TIOCSETD, as most .IR ioctl (2) calls are disabled while in network line-discipline mode. .PP When in network mode, input processing is very limited to reduce overhead. Currently the input path is only 7 bits wide, with newline the only recognized character, terminating an input record. Each input record must be read and acknowledged before the next input is read as the system refuses to accept any new data when there is a record in the buffer. The buffer is limited in length, but the system guarantees to always be willing to accept input resulting in 512 data characters and then the terminating newline. .PP User level programs should provide sequencing and checksums on the information to guarantee accurate data transfer. .SH "SEE ALSO" tty(4) .SH DIAGNOSTICS None. .SH BUGS The Purdue uploading line discipline, which provides 8 bits and uses timeout's to terminate uploading should be incorporated into the standard system, as it is much more suitable for microprocessor connections. ================================================ FILE: share/man/man4/br.4 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)br.4 6.2 (Berkeley) 8/29/87 .\" .TH BR 4 "August 20, 1988" .UC 2 .SH NAME br \- EATON BR1537/BR1711 1538[A,B,C,D] moving head disk .SH SYNOPSIS .ft B .nf /sys/conf/SYSTEM: NBR \fIbr_drives\fP # EATON 1537/1711, EATON 1538A, B, C, D /etc/dtab: .ta .5i +\w'#Name 'u +\w'Unit# 'u +\w'177777 'u +\w'Vector 'u +\w'Br 'u +\w'xxxxxxx 'u +\w'xxxxxxx 'u #Name Unit# Addr Vector Br Handler(s) # Comments \ br ? 176710 254 5 brintr # Eaton 1537/8 .DT major device number(s): raw: 20 block: 11 minor device encoding: bits 0007 specify partition of BR drive bits 0070 specify BR drive .fi .ft R .SH DESCRIPTION Files with minor device numbers 0 through 7 refer to various portions of drive 0; minor devices 8 through 15 refer to drive 1, etc. There are four drive types supported by the Eaton BR1537 and BR1711 controllers, these are the 1538A (50 Mb), 1538B (80 Mb), 1538C (200 Mb) and 1538D (300 Mb). Capacities are unformatted megabytes. The standard device names begin with ``br'' followed by the drive number and then a letter a-h for partitions 0-7 respectively. The character ? stands here for a drive number in the range 0-7. .PP The block files access the disk via the system's normal buffering mechanism and may be read and written without regard to physical disk records. There is also a `raw' interface which provides for direct transmission between the disk and the user's read or write buffer. A single read or write call results in exactly one I/O operation and therefore raw I/O is considerably more efficient when many words are transmitted. The names of the raw files conventionally begin with an extra `r.' .PP In raw I/O the buffer must begin on a word (even) boundary, and counts should be a multiple of 512 bytes (a disk sector). Likewise .I seek calls should specify a multiple of 512 bytes. .SH "DISK SUPPORT" The size (in sectors) of the pseudo-disks on each drive are as follows: .nf .ta .5i +\w'disk 'u +\w'000000 'u +\w'000000 'u +\w'000 - 000 'u .PP .ne 10 1538A partitions: disk length cyls comments br?a 18260 0 - 165 1538A has 22 sec/trk, 5 trk/cyl br?b 12210 166 - 276 br?c 59180 277 - 814 br?d unused br?e unused br?f unused br?g unused br?h 89650 0 - 814 .PP .ne 10 1538B partitions: disk length cyls comments br?a 18400 0 - 114 1538B has 32 sec/trk, 5 trk/cyl br?b 12320 115 - 190 br?c 99840 191 - 814 br?d unused br?e unused br?f unused br?g unused br?h 99840 0 - 814 .PP .ne 10 1538C partitions: disk length cyls comments br?a 18392 0 - 43 1538C has 22 sec/trk, 19 trk/cyl br?b 12122 44 - 72 br?c 231990 73 - 627 br?d 78166 628 - 814 br?e unused br?f unused br?g unused br?h 340670 0 - 814 .PP .ne 10 1538D partitions: disk length cyls comments br?a 18240 0 - 29 1538D has 32 sec/trk, 19 trk/cyl br?b 12160 30 - 49 br?c 232256 50 - 431 br?d 232256 432 - 813 br?e unused br?f unused br?g unused br?h 495520 0 - 814 .DT .fi .SH FILES .ta \w'/dev/MAKEDEV.local 'u /dev/br[0-7][a-h] block files .br /dev/rbr[0-7][a-h] raw files .br /dev/MAKEDEV script to create special files .br /dev/MAKEDEV.local script to localize special files .DT .SH "SEE ALSO" ra(4), ram(4), rk(4), rl(4), rx(4), si(4), xp(4), dtab(5), autoconfig(8) .SH DIAGNOSTICS \fBbr%d%c: hard error sn%d cs2=%b ds=%b er=%b\fR. An unrecoverable error occurred during transfer of the specified sector of the specified disk partition. The contents of the cs2, ds and er registers are printed in octal and symbolically with bits decoded. The error was either unrecoverable, or a large number of retry attempts (including offset positioning and drive recalibration) could not recover the error. .SH BUGS In raw I/O .I read and .IR write (2) truncate file offsets to 512-byte block boundaries, and .I write scribbles on the tail of incomplete blocks. Thus, in programs that are likely to access raw devices, .I read, write and .IR lseek (2) should always deal in 512-byte multiples. .PP DEC-standard error logging should be supported. .PP A program to analyze the logged error information (even in its present reduced form) is needed. .PP The partition tables for the file systems should be read off of each pack, as they are never quite what any single installation would prefer, and this would make packs more portable. .PP Only the 1538D (300Mb) disk has been used with this driver, the .IR disktab (5) file and .IR newfs (8) program only know about the 1538D. ================================================ FILE: share/man/man4/cons.4 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)cons.4 6.2 (Berkeley) 7/27/87 .\" .TH CONS 4 "July 27, 1987" .UC 4 .SH NAME cons \- PDP-11 console interface .SH DESCRIPTION The console is available to the processor through the console registers. It acts like a normal terminal, except that typing control-P on the consoles of some PDP-11's puts the console in local console mode with an ODT (console debugger mode) prompt. The operation of the console in this mode varies per-processor. See the PDP-11 Processor Handbook for your particular processor. .PP On an 11/44 the console can be put into local mode by typing a control-P. The ODT prompt is ``>>>''. The processor is not stopped by entering local console mode. The CPU may be halted with the ``halt'' command, which may be abbreviated to ``h.'' Conversational mode is re-entered by using the command ``c'' (continue). .PP On 11/73 the processor's front panel halt switch must be pressed to put the console into ODT mode. The ODT prompt is an ``@''. No characters typed on the console are special while UNIX is in control of the console. .SH FILES /dev/console .SH "SEE ALSO" tty(4), reboot(8) .br PDP-11 Hardware Handbook specific to hardware ================================================ FILE: share/man/man4/css.4 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)css.4 6.1 (Berkeley) 8/20/87 .\" .TH CSS 4 "August 20, 1987" .UC 2 .SH NAME css \- DEC IMP-11A LH/DH IMP interface .SH SYNOPSIS .ft B .nf /sys/conf/SYSTEM: NCSS \fIcss_controllers\fP # DEC/CSS IMP11-A ARPAnet IMP interface .fi .ft R .SH DESCRIPTION The .I css device provides a Local Host/Distant Host interface to an IMP. It is normally used when participating in the DARPA Internet. The controller itself is not accessible to users, but instead provides the hardware support to the IMP interface described in .IR imp (4). When configuring, the .IR imp ( NIMP ) pseudo-device is also included. .SH DIAGNOSTICS .BR "css%d: not alive" . The initialization routine was entered even though the device did not autoconfigure. This is indicates a system problem. .PP .BR "css%d: can't initialize" . Insufficient UNIBUS resources existed to initialize the device. This is likely to occur when the device is run on a buffered data path on an 11/750 and other network interfaces are also configured to use buffered data paths, or when it is configured to use buffered data paths on an 11/730 (which has none). .PP .BR "css%d: imp doesn't respond, icsr=%b" . The driver attempted to initialize the device, but the IMP failed to respond after 500 tries. Check the cabling. .PP .BR "css%d: stray output interrupt csr=%b" . An interrupt occurred when no output had previously been started. .PP .BR "css%d: output error, ocsr=%b icsr=%b" . The device indicated a problem sending data on output. .PP .BR "css%d: recv error, csr=%b" . The device indicated a problem receiving data on input. .PP .BR "css%d: bad length=%d" . An input operation resulted in a data transfer of less than 0 or more than 1008 bytes of data into memory (according to the word count register). This should never happen as the maximum size of a host-IMP message is 1008 bytes. ================================================ FILE: share/man/man4/de.4 ================================================ .\" Copyright (c) 1986 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)de.4 6.2 (Berkeley) 8/20/87 .\" .TH DE 4 "August 20, 1987" .UC 2 .SH NAME de \- DEC DEUNA 10 Mb/s Ethernet interface .SH SYNOPSIS .ft B .nf /sys/conf/SYSTEM: NDE \fIde_controllers\fP # DEUNA .fi .ft R .SH DESCRIPTION The .I de interface provides access to a 10 Mb/s Ethernet network through a Digital Equipment UNIBUS Network Adapter (DEUNA). .PP Each of the host's network addresses is specified at boot time with an SIOCSIFADDR ioctl. The .I de interface employs the address resolution protocol described in .IR arp (4P) to dynamically map between Internet and Ethernet addresses on the local network. .PP The interface normally tries to use a ``trailer'' encapsulation to minimize copying data on input and output. The use of trailers is negotiated with ARP. This negotiation may be disabled, on a per-interface basis, by setting the IFF_NOTRAILERS flag with an SIOCSIFFLAGS ioctl. .SH DIAGNOSTICS \fBde%d: hardware address %s\fP. This is a normal autoconfiguration message noting the 6 byte physical ethernet address of the adapter. .PP \fBde%d: oerror, flags=%b tdrerr=%b (len=%d)\fP. The hardware indicated an error in transmitting a packet to the cable. The status and error flags are reported. .PP \fBde%d: ierror, flags=%b lenerr=%b (len=%d)\fP. The hardware indicated an error in reading a packet from the cable. The status and error flags are reported. .PP \fBde%d: can't handle af%d\fP. The interface was handed a message with addresses formatted in an unsuitable address family; the packet was dropped. .PP \fBde%d: buffer unavailable\fP. The interface received more packets than it had buffers allocated to receive them. .PP \fBde%d: address change failed, csr0=%b csr1=%b\fP. The interface was unable to reprogram its physical ethernet address. This may happen with very early models of the interface. This facility is used only when the controller is not the first network interface configured for XNS. .PP The following messages indicate a probable hardware error performing the indicated operation during autoconfiguration or initialization. The two control and status registers should indicate the nature of the failure. See the hardware manual for details. .PP \fBde%d: reset failed, csr0=%b csr1=%b\fP. .PP \fBde%d: ppcb failed, csr0=%b csr1=%b\fP. .PP \fBde%d: read addr failed, csr0=%b csr1=%b\fP. .PP \fBde%d: wtring failed, csr0=%b csr1=%b\fP. .PP \fBde%d: wtmode failed, csr0=%b csr1=%b\fP. .SH SEE ALSO intro(4N), inet(4F), arp(4P) ================================================ FILE: share/man/man4/dh.4 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)dh.4 6.4 (2.11BSD) 1997/5/31 .\" .TH DH 4 "May 31, 1997" .UC 2 .SH NAME dh \- DH-11/DM-11 communications multiplexer .SH SYNOPSIS .ft B .nf /sys/conf/SYSTEM: NDH \fIdh_units\fP # DH11; NDH is in units of boards (16 each) NDM \fIdm_units\fP # DM11; NDM is in units of boards (16 each) /etc/dtab: .ta .5i +\w'#Name 'u +\w'Unit# 'u +\w'177777 'u +\w'Vector 'u +\w'Br 'u +\w'xxxxxxx 'u +\w'xxxxxxx 'u #Name Unit# Addr Vector Br Handler(s) # Comments dm ? 170500 310 4 dmintr # dm11 dh modem control dh ? 160020 320 5 dhrint dhxint # dh11 terminal mux .DT major device number(s): raw: 3 minor device encoding: bits 0017 specify line on DH unit bits 0060 specify DH unit bit 0100 specify RTS/CTS (``hardware'') flowcontrol bit 0200 specifies non-blocking open (``CD always on'') .fi .ft R .SH DESCRIPTION A dh-11 provides 16 communication lines; dm-11's may be optionally paired with dh-11's to provide modem control for the lines. If there are fewer dm-11's than dh-11's, the dm-11's are assumed to be paired with the first \fIdm_units\fP dh-11's. .PP Each line attached to the DH-11 communications multiplexer behaves as described in .IR tty (4). Input and output for each line may independently be set to run at any of 16 speeds; see .IR tty (4) for the encoding. .PP Bit .I 0200 of the minor device number for DH lines may be set to say that a line is not properly connected, and that the line should be treated as hard-wired with carrier always present. Thus creating the special character device node "3, 130" via .I "mknod /dev/ttyh2 c 3 130" would cause line ttyh2 to be treated in this way. Bit .I 0100 of the minor device number enables RTS/CTS (also called ``hardware'') flow control. It is enabled by adding 64 to the minor device number: .I "mknod /dev/ttyh2 c 3 194" .PP The .I dh driver monitors the rate of input on each board, and switches between the use of character-at-a-time interrupts and input silos. While the silo is enabled during periods of high-speed input, the driver polls for input 30 times per second. .SH FILES .ta \w'/dev/MAKEDEV.local 'u /dev/tty[h-k][0-9a-f] .br /dev/ttyd[0-9a-f] .br /dev/MAKEDEV script to create special files .br /dev/MAKEDEV.local script to localize special files .DT .SH "SEE ALSO" tty(4), dtab(5), autoconfig(8) .SH DIAGNOSTICS \fBdh%d NXM\fR. No response from UNIBUS on a dma transfer within a timeout period. This has never been observed on a PDP-11 and is a carryover from the VAX driver when it was ported. It is not serious. .PP \fBdh%d %d overruns\fR. The character input silo overflowed before it could be serviced. This message is only printed at line close time. It is not serious but does indicate that the system was not able to keep up with the data flow. ================================================ FILE: share/man/man4/dhu.4 ================================================ .\" Copyright (c) 1985 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)dhu.4 6.2.1 (2.11BSD) 1997/5/31 .\" .TH DHU 4 "May 31, 1997" .UC 2 .SH NAME dhu \- DHU-11 communications multiplexer .SH SYNOPSIS .ft B .nf /sys/conf/SYSTEM: NDHU \fIdhu_units\fP # DHU11 /etc/dtab: .ta .5i +\w'#Name 'u +\w'Unit# 'u +\w'177777 'u +\w'Vector 'u +\w'Br 'u +\w'xxxxxxx 'u +\w'xxxxxxx 'u #Name Unit# Addr Vector Br Handler(s) # Comments du ? 160020 310 5 dhurint dhuxint # dhu11 terminal mux .DT major device number(s): raw: 4 minor device encoding: bits 0017 specify line on DHU unit bits 0060 specify DHU unit bit 0100 specify RTS/CTS flow control bit 0200 specifies non-blocking open (``CD always on'') .fi .ft R .SH DESCRIPTION A DHU-11 provides 16 communication lines. .PP Each line attached to the DHU-11 communications multiplexer behaves as described in .IR tty (4). Input and output for each line may independently be set to run at any of 13 speeds (50, 200 and 38400 baud are not available); see .IR tty (4) for the encoding. .PP Bit .I 0200 of the minor device number for DHU lines may be set to say that a line is not properly connected, and that the line should be treated as hard-wired with carrier always present. Thus creating the special character device node "4, 130" via .I "mknod /dev/ttyS2 c 4 130" would cause line ttyS2 to be treated in this way. Turning on bit 6 (adding 64) to the minor device number via .I "mknod /dev/ttyS2 c 4 194" enables RTS/CTS flow control. .PP The DHU-11 driver normally uses input silos and delays receiver interrupts by 20 milliseconds rather than taking an interrupt on each input character. .SH FILES /dev/tty[S-Z][0-9a-f] .SH "SEE ALSO" tty(4) .SH DIAGNOSTICS \fBdhu(%d,%d) NXM\fR. No response from UNIBUS on a DMA transfer within a timeout period. This has never been observed on a PDP-11 and is believed to be a carryover from the VAX driver when it was ported. It is not serious. .PP \fBdhu%d %d overruns\fR. The character input silo overflowed before it could be serviced. This message is printed only at line close time rather than on each overrun error. Kernel printf's are not interrupt driven and caused more overruns by blocking interrupts for lengthy periods of time. .SH NOTES The driver currently does not make full use of the hardware capabilities of the DHU-11, for dealing with XON/XOFF flow-control or hard-wired lines for example. .PP The 4 40-way cables are a pain. ================================================ FILE: share/man/man4/dhv.4 ================================================ .\" .\" @(#)dhv.4 1.0 (2.11BSD) 1997/5/31 .\" .TH DHV 4 "May 31, 1997" .UC 2 .SH NAME dhv \- DHV-11 communications multiplexer .SH SYNOPSIS .ft B .nf /sys/conf/SYSTEM: NDHV \fIdhv_units\fP # DHV11 /etc/dtab: .ta .5i +\w'#Name 'u +\w'Unit# 'u +\w'177777 'u +\w'Vector 'u +\w'Br 'u +\w'xxxxxxx 'u +\w'xxxxxxx 'u #Name Unit# Addr Vector Br Handler(s) # Comments dhv ? 160440 310 5 dhvrint dhvxint # dhv terminal mux .DT major device number(s): raw: 24 minor device encoding: bits 0007 specify line on DHV unit bits 0070 specify DHV unit bit 0100 specifies RTS/CTS (``hardware'') flowcontrol bit 0200 specifies non-blocking open (``CD always on'') .fi .ft R .SH DESCRIPTION A DHV-11 provides 8 communication lines. .PP Each line attached to the DHV-11 communications multiplexer behaves as described in .IR tty (4). Input and output for each line may independently be set to run at any of 13 speeds (50 and 200 baud are not available). While 38400 is available the underlying hardware is not fast enough to handle it and there will be pauses/gaps between characters. .PP Bit .I 0200 of the minor device number for DHV lines may be set to say that a line is not properly connected, and that the line should be treated as hard-wired with carrier always present. Thus creating the special character device node "4, 130" via .I "mknod /dev/ttyS2 c 4 130" would cause line ttyS2 to be treated in this way. Turning on bit 6 in the minor device number via .I "mknod /dev/ttyS2 c 4 194" would enable RTS/CTS flow control. .PP The DHV-11 has an input silo but does \fBnot\fP have the programmable receiver delay that the DHU (and DHQ) have. Thus system services more interrupts (i.e. gets fewer characters per interrupt on average) with a DHV-11 than with a DHQ (in DHU mode). .SH FILES /dev/tty[S-Z][0-9a-f] .SH "SEE ALSO" tty(4) .SH DIAGNOSTICS \fBdhv%d,%d NXM\fR. No response from QBUS on a DMA transfer within a timeout period. This error has never been observed on a PDP-11 and is a carryover from the VAX driver when that was ported to 2BSD. .PP \fBdhv%d diag %o\fR. Diagnostic information from the DHV11. This has never been observed. The DHV-11 hardware manual will be required to decode the value printed out. .PP \fBdhv%d: %d overruns\fR. The character input silo overflowed before it could be serviced. This message is printed only when the line is closed. By only printing this when the line is closed further silo overruns are avoided (kernel printf statements are not interrupt driven). .SH NOTES The DHV lacks the receiver delay that the DHU (and DHQ) have. Thus it is extremely easy (indeed it's almost certain at higher data rates) for a DHV-11 to enter an interrupt per character mode and use 70-80% of the cpu. ================================================ FILE: share/man/man4/dmc.4 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)dmc.4 6.3.1 (2.11BSD) 1996/10/22 .\" .TH DMC 4 "October 22, 1996" .UC 2 .SH NAME dmc \- DEC DMC-11/DMR-11 point-to-point communications device .SH SYNOPSIS .ft B .nf /sys/conf/SYSTEM: NDMC \fIdmc_controllers\fP # DMC11 .fi .ft R .SH DESCRIPTION The .I dmc interface provides access to a point-to-point communications device which runs at either 1 Mb/s or 56 Kb/s. DMC-11's communicate using the DEC DDCMP link layer protocol. .PP The .I dmc interface driver also supports a DEC DMR-11 providing point-to-point communication running at data rates from 2.4 Kb/s to 1 Mb/s. DMR-11's are a more recent design and thus are preferred over DMC-11's. The NXMT and NRCV constants in the driver should be increased in this case, as the DMR can accept up to 64 transmit and receive buffers, as opposed to 7 for the DMC. .PP The configuration flags specify how to set up the device, .br 0 -- full duplex DDCMP (normal mode) .br 1 -- DDCMP Maintence mode (generally useless) .br 2 -- DDCMP Half Duplex, primary station .br 3 -- DDCMP Half Duplex, secondary station .ti .PP Several device error counters are available via "adb", for more information see the adb script /usr/share/adb/dmcstats, or the DMC11 technical manual. .PP The host's address must be specified with an SIOCSIFADDR ioctl, and the destination address specified with a SIOCSIFDSTADDR ioctl, before the interface will transmit or receive any packets. .SH ROUTING The driver places a HOST entry in the kernel routing tables for the address given in the SIOCSIFDSTADDR ioctl. To use the DMC as a link between local nets, the route to the remote net must be added manually with the .IR route (8) command, or by the use of the routing process .IR routed (8) on each end of the link. .SH DIAGNOSTICS .BR "dmc%d: bad control %o" . A bad parameter was passed to the .I dmcload routine. .PP .BR "dmc%d: unknown address type %d" . An input packet was received which contained a type of address unknown to the driver. .PP .BR "DMC fatal error 0%o" . A fatal error in DDMCP occurred, causing the device to be restarted. .PP .BR "DMC soft error 0%o" . A non-fatal error in DDMCP has occurred. .PP .BR "dmc%d: af%d not supported" . The interface was handed a message which has addresses formatted in an unsuitable address family. .SH SEE ALSO intro(4N), inet(4F) .SH BUGS The current version of the driver uses a link-level encapsulation so that multiple protocol types may be used. It is thus incompatible with earlier drivers, including the 4.2BSD version. ================================================ FILE: share/man/man4/dr.4 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)dr.4 6.2.1 (2.11BSD) 1996/1/27 .\" .TH DR 4 "January 27, 1996" .UC 2 .SH NAME dr \- DR11-W general purpose interface driver .SH SYNOPSIS .ft B .nf /sys/conf/SYSTEM: NDR \fIdr11-w_units\fP # DR11-W /etc/dtab: .ta .5i +\w'#Name 'u +\w'Unit# 'u +\w'177777 'u +\w'Vector 'u +\w'Br 'u +\w'xxxxxxx 'u +\w'xxxxxxx 'u #Name Unit# Addr Vector Br Handler(s) # Comments dr ? 172410 124 5 drintr # dr11-w (b-bus emulator) dr ? 172430 130 5 drintr # dr11-w (gc-bus emulator) dr ? 172450 134 5 drintr # dr11-w (em-2 interface) .DT major device number(s): raw: 12 minor device encoding: bits 0007 specify DR unit .fi .ft R .SH DESCRIPTION The .I "Digital Equipment 1981-82 Peripherals Handbook" states the following about the DR11-W: .RS .PP The The DR11-W is a general purpose, direct memory access (DMA) interface to the PDP-11 UNIBUS or VAX UNIBUS. The DR11-W moves data directly between memory and the UNIBUS to and from the user's peripheral. .PP It features: .IP \(bu Word or byte transfers. .IP \(bu Programmed or direct memory access (DMA) block transfers. .IP \(bu Burst data transfers. .IP \(bu User-controlled transfer rates up to memory speed. .PP The DR11-W is a 53-line direct memory access (DMA) interface to the PDP-11 UNIBUS or VAX UBA, which allows the user to control data transfers between the host processor and a peripheral. The DR11-W has 32 data lines (for transferring 16-bit parallel data) and 21 control lines (for transferring control and status information. .PP When used as an interprocessor buffer (IPB), the DR11-W allows data transfers between two processors. Interprocessor communication is accomplished by attaching one DR11-W to each processor UNIBUS or UBA and then cabling the two DR11-Ws together. .RE .PP There. Now you know as much about it as I do. .PP A number of \fIioctl\fP(2) calls apply to the dr devices, and have the form .RS .nf .ft B #include ioctl(fildes, code, arg) int *arg; .ft R .fi .RE The applicable codes are: .IP DRGTTY 18 Get DR11-W status. .IP DRSTTY 18 Set flags and function. .IP DRSFUN 18 Set function. .IP DRSFLAG 18 Set flags. .IP DRGCSR 18 Get CSR and WCR. .IP DRSSIG 18 Set signal for ATTN interrupt. .IP DRESET 18 Reset DR11-W interface. .IP DRSTIME 18 Set timeout. .IP DRCTIME 18 Set timeout inactive. .IP DROUTPUT 18 Put word in output data register. .IP DRINPUT 18 Get word from input data register. .IP DRITIME 18 Don't ignore errors on timeout. .SH FILES .ta \w'/dev/MAKEDEV.local 'u /dev/dr[0-7] device special files .br /dev/MAKEDEV script to create special files .br /dev/MAKEDEV.local script to localize special files .DT .SH "SEE ALSO" dtab(5), autoconfig(8) .SH DIAGNOSTICS \fBdr%d: error csr=%b, eir=%b\fR .PP \fBdr%d: timeout error\fR .SH BUGS This interface is only available under 2.9BSD and 2.11BSD. No documentation exists on how to use it. ================================================ FILE: share/man/man4/dz.4 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)dz.4 6.2 (Berkeley) 1/28/88 .\" .TH DZ 4 "January 28, 1988" .UC 2 .SH NAME dz \- DZ-11 communications multiplexer .SH SYNOPSIS .ft B .nf /sys/conf/SYSTEM: NDZ \fIdz_units\fP # DZ11; NDZ is in units of boards (8 each) /etc/dtab: .ta .5i +\w'#Name 'u +\w'Unit# 'u +\w'177777 'u +\w'Vector 'u +\w'Br 'u +\w'xxxxxxx 'u +\w'xxxxxxx 'u #Name Unit# Addr Vector Br Handler(s) # Comments dz ? 160100 310 5 dzrint dzdma # dz11 terminal mux .DT major device number: raw: 2 minor device encoding: bits 0007 specify line on DZ unit bits 0170 specify DZ unit bit 0200 specifies non-blocking open (``CD always on'') .SH DESCRIPTION A DZ11 provides 8 communication lines with partial modem control, adequate for UNIX dialup use. Each line attached to the DZ11 communications multiplexer behaves as described in .IR tty (4) and may be set to run at any of 16 speeds; see .IR tty (4) for the encoding. .PP Bit .I 0200 of the minor device number for DZ lines may be set to say that a line is not properly connected, and that the line should be treated as hard-wired with carrier always present. Thus creating the special character device node "2, 130" via .I "mknod /dev/tty02 c 2 130" would cause line tty02 to be treated in this way. .PP The .I dz driver monitors the rate of input on each board, and switches between the use of character-at-a-time interrupts and input silos. While the silo is enabled during periods of high-speed input, the driver polls for input 30 times per second. .SH FILES .ta \w'/dev/MAKEDEV.local 'u /dev/tty[0-9][0-9] .br /dev/ttyd[0-9a-f] dialups .br /dev/MAKEDEV script to create special files .br /dev/MAKEDEV.local script to localize special files .DT .SH "SEE ALSO" tty(4), dtab(5), autoconfig(8) .SH DIAGNOSTICS .PP \fBdz%d: silo overflow\fR. The 64 character input silo overflowed before it could be serviced. This can happen if a hard error occurs when the CPU is running with elevated priority, as the system will then print a message on the console with interrupts disabled. It is not serious. ================================================ FILE: share/man/man4/ec.4 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)ec.4 6.4 (Berkeley) 8/20/87 .\" .TH EC 4 "August 20, 1987" .UC 2 .SH NAME ec \- 3Com 10 Mb/s Ethernet interface .SH SYNOPSIS .ft B .nf /sys/conf/SYSTEM: NEC \fIec_controllers\fP # 3Com Ethernet .fi .ft R .SH DESCRIPTION The .I ec interface provides access to a 10 Mb/s Ethernet network through a 3com controller. .PP The hardware has 32 kilobytes of dual-ported memory on the UNIBUS. This memory is used for internal buffering by the board, and the interface code reads the buffer contents directly through the UNIBUS. The address of this memory is given in the \fIflags\fP field in the configuration file. The first interface normally has its memory at Unibus address 0. .PP Each of the host's network addresses is specified at boot time with an SIOCSIFADDR ioctl. The .I ec interface employs the address resolution protocol described in .IR arp (4P) to dynamically map between Internet and Ethernet addresses on the local network. .PP The interface normally tries to use a ``trailer'' encapsulation to minimize copying data on input and output. The use of trailers is negotiated with ARP. This negotiation may be disabled, on a per-interface basis, by setting the IFF_NOTRAILERS flag with an SIOCSIFFLAGS ioctl. .PP The interface software implements an exponential backoff algorithm when notified of a collision on the cable. This algorithm utilizes a 16-bit mask and the VAX-11's interval timer in calculating a series of random backoff values. The algorithm is as follows: .TP 5 1. Initialize the mask to be all 1's. .TP 5 2. If the mask is zero, 16 retries have been made and we give up. .TP 5 3. Shift the mask left one bit and formulate a backoff by masking the interval timer with the smaller of the complement of this mask and a 5-bit mask, resulting in a pseudo-random number between 0 and 31. This produces the number of slot times to delay, where a slot is 51 microseconds. .TP 5 4. Use the value calculated in step 3 to delay before retransmitting the packet. The delay is done in a software busy loop. .SH DIAGNOSTICS .BR "ec%d: send error" . After 16 retransmissions using the exponential backoff algorithm described above, the packet was dropped. .PP .BR "ec%d: input error (offset=%d)" . The hardware indicated an error in reading a packet off the cable or an illegally sized packet. The buffer offset value is printed for debugging purposes. .PP .BR "ec%d: can't handle af%d" . The interface was handed a message with addresses formatted in an unsuitable address family; the packet was dropped. .SH SEE ALSO intro(4N), inet(4F), arp(4P) .SH BUGS The hardware is not capable of talking to itself. The software implements local sending and broadcast by sending such packets to the loop interface. This is a kludge. .PP Backoff delays are done in a software busy loop. This can degrade the system if the network experiences frequent collisions. ================================================ FILE: share/man/man4/en.4 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)en.4 6.2 (Berkeley) 8/20/87 .\" .TH EN 4 "August 20, 1987" .UC 2 .SH NAME en \- Xerox 3 Mb/s Ethernet interface .SH SYNOPSIS .ft B .nf /sys/conf/SYSTEM: NEN \fIen_controllers\fP # Xerox prototype (3 Mb) Ethernet .fi .ft R .SH DESCRIPTION The .I en interface provides access to a 3 Mb/s Ethernet network. Due to limitations in the hardware, DMA transfers to and from the network must take place in the lower 64K bytes of the UNIBUS address space, and thus this must be among the first UNIBUS devices enabled after boot. .PP Each of the host's network addresses is specified at boot time with an SIOCSIFADDR ioctl. The station address is discovered by probing the on-board Ethernet address register, and is used to verify the protocol addresses. No packets will be sent or accepted until a network address is supplied. .PP The interface software implements an exponential backoff algorithm when notified of a collision on the cable. This algorithm utilizes a 16-bit mask and the VAX-11's interval timer in calculating a series of random backoff values. The algorithm is as follows: .TP 5 1. Initialize the mask to be all 1's. .TP 5 2. If the mask is zero, 16 retries have been made and we give up. .TP 5 3. Shift the mask left one bit and formulate a backoff by masking the interval timer with the mask (this is actually the two's complement of the value). .TP 5 4. Use the value calculated in step 3 to delay before retransmitting the packet. .PP The interface handles both Internet and NS protocol families. It normally tries to use a ``trailer'' encapsulation to minimize copying data on input and output. The use of trailers is negotiated with ARP. This negotiation may be disabled, on a per-interface basis, by setting the IFF_NOTRAILERS flag with an SIOCSIFFLAGS ioctl. .SH DIAGNOSTICS .BR "en%d: output error" . The hardware indicated an error on the previous transmission. .PP .BR "en%d: send error" . After 16 retransmissions using the exponential backoff algorithm described above, the packet was dropped. .PP .BR "en%d: input error" . The hardware indicated an error in reading a packet off the cable. .PP .BR "en%d: can't handle af%d" . The interface was handed a message with addresses formatted in an unsuitable address family; the packet was dropped. .SH SEE ALSO intro(4N), inet(4F) .SH BUGS The device has insufficient buffering to handle back to back packets. This makes use in a production environment painful. .PP The hardware does word at a time DMA without byte swapping. To compensate, byte swapping of user data must either be done by the user or by the system. A kludge to byte swap only IP packets is provided if the ENF_SWABIPS flag is defined in the driver and set at boot time with an SIOCSIFFLAGS ioctl. ================================================ FILE: share/man/man4/fd.4 ================================================ .\" Copyright (c) 1990, 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. All advertising materials mentioning features or use of this software .\" must display the following acknowledgement: .\" This product includes software developed by the University of .\" California, Berkeley and its contributors. .\" 4. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)fd.4 8.1.1 (2.11BSD) 1997/2/4 .\" .TH FD 4 "February 4, 1997" .UC 4 .SH NAME .BR fd , .BR stdin , .BR stdout , .BR stderr file descriptor files .SH DESCRIPTION The files .I /dev/fd/0 through .I /dev/fd/# refer to file descriptors which can be accessed through the file system. If the file descriptor is open and the mode the file is being opened with is a subset of the mode of the existing descriptor, the call: .sp .in +0.5i fd = open("/dev/fd/0", mode); .in -0.5i .PP and the call: .sp .in +0.5i fd = fcntl(0, F_DUPFD, 0); .in -0.5i .PP are equivalent. .PP Opening the files .IR /dev/stdin , .I /dev/stdout and .I /dev/stderr is equivalent to the following calls: .sp .in +0.5i fd = fcntl(STDIN_FILENO, F_DUPFD, 0); .br fd = fcntl(STDOUT_FILENO, F_DUPFD, 0); .br fd = fcntl(STDERR_FILENO, F_DUPFD, 0); .in -0.5i .PP Flags to the open(2) call other than O_RDONLY, O_WRONLY and O_RDWR are ignored. .SH FILES /dev/fd/# .br /dev/stdin .br /dev/stdout .br /dev/stderr .SH SEE ALSO tty(4) ================================================ FILE: share/man/man4/hk.4 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)hk.4 6.4 (2.11BSD GTE) 1997/12/28 .\" .TH HK 4 "December 28, 1997" .UC 2 .SH NAME hk \- RK6-11/RK06 and RK07 moving head disk .SH SYNOPSIS .ft B .nf /sys/conf/SYSTEM: NHK \fIhk_drives\fP # RK611, RK06/07 /etc/dtab: .ta .5i +\w'#Name 'u +\w'Unit# 'u +\w'177777 'u +\w'Vector 'u +\w'Br 'u +\w'xxxxxxx 'u +\w'xxxxxxx 'u #Name Unit# Addr Vector Br Handler(s) # Comments hk ? 177440 210 5 hkintr # rk611/711 rk06/07 .DT major device number(s): raw: 13 block: 4 minor device encoding: bits 0007 specify partition of HK drive bits 0070 specify HK drive .fi .ft R .SH DESCRIPTION Files with minor device numbers 0 through 7 refer to various portions of drive 0; minor devices 8 through 15 refer to drive 1, etc. The standard device names begin with ``hk'' followed by the drive number and then a letter a-h for partitions 0-7 respectively. The character ? stands here for a drive number in the range 0-7. .PP The block files access the disk via the system's normal buffering mechanism and may be read and written without regard to physical disk records. There is also a `raw' interface which provides for direct transmission between the disk and the user's read or write buffer. A single read or write call results in exactly one I/O operation and therefore raw I/O is considerably more efficient when many words are transmitted. The names of the raw files conventionally begin with an extra `r.' .PP In raw I/O the buffer must begin on a word (even) boundary, and counts should be a multiple of 512 bytes (a disk sector). Likewise .I seek calls should specify a multiple of 512 bytes. .SH "DISK SUPPORT" Disks must be labeled using either the standalone \fIdisklabel\fP program on the boot tape or with the \fIdisklabel\fP(8) program. There are no partition tables coded into the \fIhk\fP drivers, these must be placed on the drive with \fIdisklabel\fP. .PP Traditionally the \fIhk?a\fP partition is used for the root filesystem, the \fIb\fP partition as a swap area and the \fIc\fP partition for disk to disk copying (it spans the entire disk). .PP The kernel uses the \fIc\fP partition to access the bad block information stored at the end of some packs. Extreme care must be taken when creating file systems on this partition to avoid overwriting any bad block information present. User data should use the \fIh\fP partition which should be at least one track (one cylinder might be best) shorter than the \fIc\fP partition. .SH FILES .ta \w'/dev/MAKEDEV.local 'u /dev/hk[0-7][a-h] block files .br /dev/rhk[0-7][a-h] raw files .br /dev/MAKEDEV script to create special files .br /dev/MAKEDEV.local script to localize special files .DT .SH "SEE ALSO" ra(4) ram(4), rk(4), rl(4), rx(4), si(4), xp(4), dtab(5), autoconfig(8), disklabel(8) .SH DIAGNOSTICS \fBhk%d%c: hard error sn%d cs2=%b ds=%b er=%b\fR. An unrecoverable error occurred during transfer of the specified sector of the specified disk partition. The contents of the cs2, ds and er registers are printed in octal and symbolically with bits decoded. The error was either unrecoverable, or a large number of retry attempts (including offset positioning and drive recalibration) could not recover the error. .PP \fBhk%d: write locked\fP. The write protect switch was set on the drive when a write was attempted. The write operation is not recoverable. .PP \fBhk%d: not ready\fR. The drive was spun down or off line when it was accessed. The i/o operation is not recoverable. .PP \fBhk%d: not ready (came back!)\fR. The drive was not ready, but after printing the message about being not ready (which takes a fraction of a second) was ready. The operation is recovered if no further errors occur. .PP \fBhk%d%c: soft ecc sn%d\fP. A recoverable ECC error occurred on the specified sector of the specified disk partition. This happens normally a few times a week. If it happens more frequently than this the sectors where the errors are occuring should be checked to see if certain cylinders on the pack, spots on the carriage of the drive or heads are indicated. .SH BUGS In raw I/O .I read and .IR write (2) truncate file offsets to 512-byte block boundaries, and .I write scribbles on the tail of incomplete blocks. Thus, in programs that are likely to access raw devices, .I read, write and .IR lseek (2) should always deal in 512-byte multiples. .PP DEC-standard error logging should be supported. .PP A program to analyze the logged error information (even in its present reduced form) is needed. ================================================ FILE: share/man/man4/ht.4 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)ht.4 6.2 (Berkeley) 1/28/88 .\" .TH HT 4 "January 28, 1988" .UC 2 .SH NAME ht \- TM-03/TE-16,TU-45,TU-77 MASSBUS magtape interface .SH SYNOPSIS .ft B .nf /sys/conf/SYSTEM: NHT \fIht_drives\fP # TE16, TU45, TU77 /etc/dtab: .ta .5i +\w'#Name 'u +\w'Unit# 'u +\w'177777 'u +\w'Vector 'u +\w'Br 'u +\w'xxxxxxx 'u +\w'xxxxxxx 'u #Name Unit# Addr Vector Br Handler(s) # Comments ht ? 172440 224 5 htintr # tu 16 massbus tape .DT major device number(s): raw: 6 block: 0 minor device encoding: bits 0003 specify HT drive bit 0004 specifies no-rewind operation bit 0010 specifies 1600BPI recording density instead of 800BPI .fi .ft R .SH DESCRIPTION The tm-03/transport combination provides a standard tape drive interface as described in .IR mtio (4). All drives provide both 800 and 1600 bpi; the TE-16 runs at 45 ips, the TU-45 at 75 ips, while the TU-77 runs at 125 ips and autoloads tapes. .SH FILES .ta \w'/dev/MAKEDEV.local 'u /dev/MAKEDEV script to create special files .br /dev/MAKEDEV.local script to localize special files .DT .SH "SEE ALSO" mt(1), tar(1), tp(1), mtio(4), tm(4), ts(4), dtab(5), autoconfig(8) .SH DIAGNOSTICS \fBtu%d: no write ring\fR. An attempt was made to write on the tape drive when no write ring was present; this message is written on the terminal of the user who tried to access the tape. .PP \fBtu%d: not online\fR. An attempt was made to access the tape while it was offline; this message is written on the terminal of the user who tried to access the tape. .PP \fBtu%d: can't change density in mid-tape\fR. An attempt was made to write on a tape at a different density than is already recorded on the tape. This message is written on the terminal of the user who tried to switch the density. .PP \fBtu%d: hard error bn%d er=%b ds=%b\fR. A tape error occurred at block \fIbn\fR; the ht error register and drive status register are printed in octal with the bits symbolically decoded. Any error is fatal on non-raw tape; when possible the driver will have retried the operation which failed several times before reporting the error. .SH BUGS If any non-data error is encountered on non-raw tape, it refuses to do anything more until closed. .PP The system should remember which controlling terminal has the tape drive open and write error messages to that terminal rather than on the console. ================================================ FILE: share/man/man4/hy.4 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)hy.4 6.1 (Berkeley) 8/20/87 .\" .TH HY 4 "August 20, 1987" .UC 2 .SH NAME hy \- Network Systems Hyperchannel interface .SH SYNOPSIS .ft B .nf /sys/conf/SYSTEM: NHY \fihy_controllers\fP # Hyperchannel .fi .ft R .SH DESCRIPTION The .I hy interface provides access to a Network Systems Corporation Hyperchannel Adapter. .PP The network to which the interface is attached is specified at boot time with an SIOCSIFADDR ioctl. The host's address is discovered by reading the adapter status register. The interface will not transmit or receive packets until the network number is known. .SH DIAGNOSTICS \fBhy%d: unit number 0x%x port %d type %x microcode level 0x%x\fP. Identifies the device during autoconfiguration. .PP \fBhy%d: can't handle af%d\fP. The interface was handed a message with addresses formatted in an unsuitable address family; the packet was dropped. .PP \fBhy%d: can't initialize\fP. The interface was unable to allocate UNIBUS resources. This is usually due to having too many network devices on an 11/750 where there are only 3 buffered data paths. .PP \fBhy%d: NEX - Non Existent Memory\fP. Non existent memory error returned from hardware. .PP \fBhy%d: BAR overflow\fP. Bus address register overflow error returned from hardware. .PP \fBhy%d: Power Off bit set, trying to reset\fP. Adapter has lost power, driver will reset the bit and see if power is still out in the adapter. .PP \fBhy%d: Power Off Error, network shutdown\fP. Power was really off in the adapter, network connections are dropped. Software does not shut down the network unless power has been off for a while. .PP \fBhy%d: RECVD MP > MPSIZE (%d)\fP. A message proper was received that is too big. Probable a driver bug. Shouldn't happen. .PP \fBhy%d: xmit error \- len > hy_olen [%d > %d]\fP. Probable driver error. Shouldn't happen. .PP \fBhy%d: DRIVER BUG \- INVALID STATE %d\fP. The driver state machine reached a non-existent state. Definite driver bug. .PP \fBhy%d: watchdog timer expired\fP. A command in the adapter has taken too long to complete. Driver will abort and retry the command. .PP \fBhy%d: adapter power restored\fP. Software was able to reset the power off bit, indicating that the power has been restored. .SH SEE ALSO intro(4N), inet(4F) .SH BUGS If the adapter does not respond to the status command issued during autoconfigure, the adapter is assumed down. A reboot is required to recognize it. .PP The adapter power fail interrupt seems to occur sporadically when power has, in fact, not failed. The driver will believe that power has failed only if it can not reset the power fail latch after a ``reasonable'' time interval. These seem to appear about 2-4 times a day on some machines. There seems to be no correlation with adapter rev level, number of ports used etc. and whether a machine will get these ``bogus powerfails''. They don't seem to cause any real problems so they have been ignored. ================================================ FILE: share/man/man4/icmp.4 ================================================ .\" Copyright (c) 1986 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)icmp.4p 6.1 (Berkeley) 5/16/86 .\" .TH ICMP 4P "May 16, 1986" .UC 6 .SH NAME icmp \- Internet Control Message Protocol .SH SYNOPSIS .B #include .br .B #include .PP .B s = socket(AF_INET, SOCK_RAW, proto); .SH DESCRIPTION ICMP is the error and control message protocol used by IP and the Internet protocol family. It may be accessed through a \*(lqraw socket\*(rq for network monitoring and diagnostic functions. The .I proto parameter to the socket call to create an ICMP socket is obtained from .IR getprotobyname (3N). ICMP sockets are connectionless, and are normally used with the .I sendto and .I recvfrom calls, though the .IR connect (2) call may also be used to fix the destination for future packets (in which case the .IR read (2) or .IR recv (2) and .IR write (2) or .IR send (2) system calls may be used). .PP Outgoing packets automatically have an IP header prepended to them (based on the destination address). Incoming packets are received with the IP header and options intact. .SH DIAGNOSTICS A socket operation may fail with one of the following errors returned: .TP 15 [EISCONN] when trying to establish a connection on a socket which already has one, or when trying to send a datagram with the destination address specified and the socket is already connected; .TP 15 [ENOTCONN] when trying to send a datagram, but no destination address is specified, and the socket hasn't been connected; .TP 15 [ENOBUFS] when the system runs out of memory for an internal data structure; .TP 15 [EADDRNOTAVAIL] when an attempt is made to create a socket with a network address for which no network interface exists. .SH SEE ALSO send(2), recv(2), intro(4N), inet(4F), ip(4P) ================================================ FILE: share/man/man4/idp.4 ================================================ .\" Copyright (c) 1985 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)idp.4p 1.1 (Berkeley) 7/30/85 .\" .TH IDP 4P "July 30, 1985" .UC 6 .SH NAME idp \- Xerox Internet Datagram Protocol .SH SYNOPSIS .B #include .br .B #include .br .B #include .PP .B s = socket(AF_NS, SOCK_DGRAM, 0); .SH DESCRIPTION IDP is a simple, unreliable datagram protocol which is used to support the SOCK_DGRAM abstraction for the Internet protocol family. IDP sockets are connectionless, and are normally used with the .I sendto and .IR recvfrom calls, though the .IR connect (2) call may also be used to fix the destination for future packets (in which case the .IR recv (2) or .IR read (2) and .IR send (2) or .IR write(2) system calls may be used). .PP Xerox protocols are built vertically on top of IDP. Thus, IDP address formats are identical to those used by SPP. Note that the IDP port space is the same as the SPP port space (i.e. a IDP port may be \*(lqconnected\*(rq to a SPP port, with certain options enabled below). In addition broadcast packets may be sent (assuming the underlying network supports this) by using a reserved \*(lqbroadcast address\*(rq; this address is network interface dependent. .SH DIAGNOSTICS A socket operation may fail with one of the following errors returned: .TP 15 [EISCONN] when trying to establish a connection on a socket which already has one, or when trying to send a datagram with the destination address specified and the socket is already connected; .TP 15 [ENOTCONN] when trying to send a datagram, but no destination address is specified, and the socket hasn't been connected; .TP 15 [ENOBUFS] when the system runs out of memory for an internal data structure; .TP 15 [EADDRINUSE] when an attempt is made to create a socket with a port which has already been allocated; .TP 15 [EADDRNOTAVAIL] when an attempt is made to create a socket with a network address for which no network interface exists. .SH SOCKET OPTIONS .TP 15 [SO_HEADERS_ON_INPUT] When set, the first 30 bytes of any data returned from a read or recv from will be the initial 30 bytes of the IDP packet, as described by .nf struct idp { u_short idp_sum; u_short idp_len; u_char idp_tc; u_char idp_pt; struct ns_addr idp_dna; struct ns_addr idp_sna; }; .fi This allows the user to determine the packet type, and whether the packet was a multi-cast packet or directed specifically at the local host. When requested, gives the current state of the option, (NSP_RAWIN or 0). .TP 15 [SO_HEADERS_ON_OUTPUT] When set, the first 30 bytes of any data sent will be the initial 30 bytes of the IDP packet. This allows the user to determine the packet type, and whether the packet should be multi-cast packet or directed specifically at the local host. You can also misrepresent the sender of the packet. When requested, gives the current state of the option. (NSP_RAWOUT or 0). .TP 15 [SO_DEFAULT_HEADERS] The user provides the kernel an IDP header, from which it gleans the Packet Type. When requested, the kernel will provide an IDP header, showing the default packet type, and local and foreign addresses, if connected. .TP 15 [SO_ALL_PACKETS] When set, this option defeats automatic processing of Error packets, and Sequence Protocol packets. .TP 15 [SO_SEQNO] When requested, this returns a sequence number which is not likely to be repeated until the machine crashes or a very long time has passed. It is useful in constructing Packet Exchange Protocol packets. .SH SEE ALSO send(2), recv(2), intro(4N), ns(4F) ================================================ FILE: share/man/man4/il.4 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)il.4 6.4 (Berkeley) 8/20/87 .\" .TH IL 4 "August 20, 1987" .UC 2 .SH NAME il \- Interlan NI1010 10 Mb/s Ethernet interface .SH SYNOPSIS .ft B .nf /sys/conf/SYSTEM: NIL \fIil_controllers\fP # Interlan Ethernet .fi .ft R .SH DESCRIPTION The .I il interface provides access to a 10 Mb/s Ethernet network through an Interlan 1010 or 1010A controller. .PP Each of the host's network addresses is specified at boot time with an SIOCSIFADDR ioctl. The .I il interface employs the address resolution protocol described in .IR arp (4P) to dynamically map between Internet and Ethernet addresses on the local network. .PP The interface normally tries to use a ``trailer'' encapsulation to minimize copying data on input and output. The use of trailers is negotiated with ARP. This negotiation may be disabled, on a per-interface basis, by setting the IFF_NOTRAILERS flag with an SIOCSIFFLAGS ioctl. .SH DIAGNOSTICS \fBil%d: input error\fP. The hardware indicated an error in reading a packet off the cable or an illegally sized packet. .PP \fBil%d: can't handle af%d\fP. The interface was handed a message with addresses formatted in an unsuitable address family; the packet was dropped. .PP \fBil%d: setaddr didn't work\fP. The interface was unable to reprogram its physical ethernet address. This may happen with very early models of the interface. This facility is used only when the controller is not the first network interface configured for XNS. The oldest interface tested (2.7.1.0.1.45) has never failed in this way. .PP The following messages indicate a probable hardware error performing the indicated operation during autoconfiguration or initialization. The status field in the control and status register (the low-order four bits) should indicate the nature of the failure. See the hardware manual for details. .PP \fBil%d: reset failed, csr=%b\fP. .PP \fBil%d: status failed, csr=%b\fP. .PP \fBil%d: hardware diag failed, csr=%b\fP. .PP \fBil%d: verifying setaddr, csr=%b\fP. .PP \fBil%d: stray xmit interrupt, csr=%b\fP. .PP \fBil%d: can't initialize\fP. .SH SEE ALSO intro(4N), inet(4F), arp(4P) ================================================ FILE: share/man/man4/imp.4 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)imp.4p 6.2 (Berkeley) 5/16/86 .\" .TH IMP 4P "May 16, 1986" .UC 5 .SH NAME imp \- IMP raw socket interface .SH SYNOPSIS .B #include .br .B #include .br .B #include .PP .B s = socket(AF_IMPLINK, SOCK_RAW, proto); .SH DESCRIPTION The raw imp socket provides direct access to the .IR imp (4) network interface. Users send packets through the interface using the .IR send (2) calls, and receive packets with the .IR recv (2), calls. All outgoing packets must have an 1822 96-bit leader on the front. Likewise, packets received by the user will have this leader on the front. The 1822 leader and the legal values for the various fields are defined in the include file .RI < netimp/if_imp.h >. The raw imp interface automatically installs the length and destination address in the 1822 leader of all outgoing packets; these need not be filled in by the user. .PP If the protocol selected, .IR proto , is zero, the socket will receive all IMP messages except RFNM and incompletes which are not input data for a kernel protocol. If .I proto is non-zero, only messages for the specified link type will be received. .SH DIAGNOSTICS An operation on a socket may fail with one of the following errors: .TP 15 [EISCONN] when trying to establish a connection on a socket which already has one, or when trying to send a datagram with the destination address specified and the socket is already connected; .TP 15 [ENOTCONN] when trying to send a datagram, but no destination address is specified, and the socket hasn't been connected; .TP 15 [ENOBUFS] when the system runs out of memory for an internal data structure; .TP 15 [ENOBUFS] eight messages to the destination host are outstanding, and another eight are already queued for output; .TP 15 [EADDRNOTAVAIL] when an attempt is made to create a socket with a network address for which no network interface exists. .SH SEE ALSO intro(4N), inet(4F), imp(4) ================================================ FILE: share/man/man4/impconf.4 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)imp.4 6.2 (Berkeley) 8/2/87 .\" .TH IMP 4 "August 2, 1987" .UC 2 .SH NAME imp \- 1822 network interface .SH SYNOPSIS .ft B .nf /sys/conf/SYSTEM: NIMP \fIcount\fP # ARPAnet IMP 1822 interface .fi .ft R .SH DESCRIPTION The .I imp interface, as described in BBN Report 1822, provides access to an intelligent message processor normally used when participating in the Department of Defense ARPA network. The network interface communicates through a device controller, usually an ACC LH/DH or HDH or a DEC IMP-11A, with the IMP. The interface is \*(lqreliable\*(rq and \*(lqflow-controlled\*(rq by the host-IMP protocol. .PP To configure IMP support, at least one of .IR acc (4), .IR css (4) or .IR hdh (4) must be included. The .I count specifies the total number of IMP connections. The network number on which the interface resides is specified at boot time using the SIOCSIFADDR ioctl. The host number is discovered through receipt of NOOP messages from the IMP. .PP The network interface is always in one of four states: up, down, initializing, or going down. When the system is booted, the interface is marked down. If the hardware controller is successfully probed, the interface enters the initializing state and transmits three NOOP messages to the IMP. It then waits for the IMP to respond with two or more NOOP messages in reply. When it receives these messages it enters the up state. The ``going down'' state is entered only when notified by the IMP of an impending shutdown. Packets may be sent through the interface only while it is in the up state. Outgoing packets are dropped with the error ENETDOWN returned to the caller if the interface is in any other state. .SH DIAGNOSTICS \fBimp%d: not configured\fP. A hardware interface could not be attached during autoconfiguration because too few IMP pseudo-devices were configured. .PP \fBimp%d: leader error\fP. The IMP reported an error in a leader (1822 message header). This causes the interface to be reset and any packets queued up for transmission to be purged. .PP \fBimp%d: going down in 30 seconds\fP. .br \fBimp%d: going down for hardware PM\fP. .br \fBimp%d: going down for reload software\fP. .br \fBimp%d: going down for emergency reset\fP. The Network Control Center (NCC) is manipulating the IMP. By convention these messages are reported to all hosts on an IMP. .PP \fBimp?: host %x, lost %d rfnms\fP. The IMP had messages outstanding to the host listed, but no RFNM (Request for Next Message) messages were received from the IMP in 127 seconds. The software state for that host is reinitialized. .PP \fBimp%d: interface reset\fP. The host has received an interface reset message from the IMP. .PP \fBimp%d: address reset to x%x (%d/%d)\fP. The host has received a NOOP message which caused it to reset its notion of its current address. The Internet address is printed in hexadecimal, with the host and IMP numbers following. This indicates that the address originally set by .IR ifconfig (8) was incorrect, that the IMP has undergone an identity crisis, or that communication between the IMP and the host is being garbled. .PP \fBimp%d: data error\fP. The IMP noted an error in data transmitted. The host-IMP interface is reset and the host enters the init state (awaiting NOOP messages). .PP \fBimp%d: interface reset\fP. The reset process has been completed. .PP \fBimp%d: marked down\fP. After receiving a \*(lqgoing down in 30 seconds\*(rq message, and waiting 30 seconds, the host has marked the IMP unavailable. Before packets may be sent to the IMP again, the IMP must notify the host, through a series of NOOP messages, that it is back up. .PP \fBimp%d: can't handle af%d\fP. The interface was handed a message with addresses formatting in an unsuitable address family; the packet was dropped. .SH SEE ALSO intro(4N), inet(4F), acc(4), css(4), hdh(4), implog(8), implogd(8) ================================================ FILE: share/man/man4/inet.4 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)inet.4f 6.3 (Berkeley) 8/1/87 .\" .TH INET 4F "August 1, 1987" .UC 5 .SH NAME inet \- Internet protocol family .SH SYNOPSIS .B #include .br .B #include .SH DESCRIPTION .de _d .if t .ta .6i 2.1i 2.6i .\" 2.94 went to 2.6, 3.64 to 3.30 .if n .ta .84i 2.6i 3.30i .. .de _f .if t .ta .5i 1.25i 2.5i .\" 3.5i went to 3.8i .if n .ta .7i 1.75i 3.8i .. The Internet protocol family is a collection of protocols layered atop the .I Internet Protocol (IP) transport layer, and utilizing the Internet address format. The Internet family provides protocol support for the SOCK_STREAM, SOCK_DGRAM, and SOCK_RAW socket types; the SOCK_RAW interface provides access to the IP protocol. .SH ADDRESSING Internet addresses are four byte quantities, stored in network standard format: layed out as highest to lowest order bytes in memory or ``Big Endian'' (the VAX is word and byte reversed, or ``Little Endian''; the PDP-11 is byte reversed within each word, or ``Middle Endian''). The include file .RI < netinet/in.h > defines this address as a discriminated union. .PP Sockets bound to the Internet protocol family utilize the following addressing structure, .sp 1 .nf ._f struct sockaddr_in { short sin_family; u_short sin_port; struct in_addr sin_addr; char sin_zero[8]; }; .sp 1 .fi Sockets may be created with the local address INADDR_ANY to effect \*(lqwildcard\*(rq matching on incoming messages. The address in a .IR connect (2) or .IR sendto (2) call may be given as INADDR_ANY to mean ``this host.'' The distinguished address INADDR_BROADCAST is allowed as a shorthand for the broadcast address on the primary network if the first network configured supports broadcast. .SH PROTOCOLS The Internet protocol family is comprised of the IP transport protocol, Internet Control Message Protocol (ICMP), Transmission Control Protocol (TCP), and User Datagram Protocol (UDP). TCP is used to support the SOCK_STREAM abstraction while UDP is used to support the SOCK_DGRAM abstraction. A raw interface to IP is available by creating an Internet socket of type SOCK_RAW. The ICMP message protocol is accessible from a raw socket. .PP The 32-bit Internet address contains both network and host parts. It is frequency-encoded; the most-significant bit is clear in Class A addresses, in which the high-order 8 bits are the network number. Class B addresses use the high-order 16 bits as the network field, and Class C addresses have a 24-bit network part. Sites with a cluster of local networks and a connection to the DARPA Internet may chose to use a single network number for the cluster; this is done by using subnet addressing. The local (host) portion of the address is further subdivided into subnet and host parts. Within a subnet, each subnet appears to be an individual network; externally, the entire cluster appears to be a single, uniform network requiring only a single routing entry. Subnet addressing is enabled and examined by the following .IR ioctl (2) commands on a datagram socket in the Internet domain; they have the same form as the SIOCIFADDR command (see .IR intro (4N)). .PP .TP 20 SIOCSIFNETMASK Set interface network mask. The network mask defines the network part of the address; if it contains more of the address than the address type would indicate, then subnets are in use. .TP 20 SIOCGIFNETMASK Get interface network mask. .SH SEE ALSO ioctl(2), socket(2), intro(4N), tcp(4P), udp(4P), ip(4P), icmp(4P) .PP An Introductory 4.3BSD Interprocess Communication Tutorial (PS1:7). .PP An Advanced 4.3BSD Interprocess Communication Tutorial (PS1:8). .SH CAVEAT The Internet protocol support is subject to change as the Internet protocols develop. Users should not depend on details of the current implementation, but rather the services exported. ================================================ FILE: share/man/man4/intro.4 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)intro.4 6.3.1 (2.11BSD) 1996/1/27 .\" .TH INTRO 4 "January 27, 1996" .UC 4 .SH NAME intro \- introduction to special files and hardware support .SH DESCRIPTION This section describes the special files, related driver functions, and networking support available in the system. In this part of the manual, the SYNOPSIS section of each configurable device gives a sample specification for use in constructing a system description for the .IR /sys/conf/config script, the .IR autoconfig (8), program and descibes the major and minor device numbers and their encoding. The DIAGNOSTICS section lists messages which may appear on the console and/or in the system error log .I /usr/adm/messages due to errors in device operation. .PP This section contains both devices which may be configured into the system, ``4'' entries, and network related information, ``4N'', ``4P'', and ``4F'' entries; The networking support is introduced in .IR intro (4N). .SH "PDP DEVICE SUPPORT" This section describes the hardware supported on the DEC PDP-11. Software support for these devices comes in two forms. A hardware device may be supported with a character or block .IR "device driver" , or it may be used within the networking subsystem and have a .IR "network interface driver" . Block and character devices are accessed through files in the file system of a special type; c.f. .IR mknod (8). Network interfaces are indirectly accessed through the interprocess communication facilities provided by the system; see .IR socket (2). .PP A hardware device is identified to the system at configuration time and the appropriate device or network interface driver is then compiled into the system. When the resultant system is booted, the autoconfiguration facilities in the system probe for the device on either the UNIBUS (or Q-bus) or MASSBUS and, if found, enable the software support for it. If a device does not respond at autoconfiguration time it is not accessible at any time afterwards. To enable a device which did not autoconfigure, the system will have to be rebooted. .PP The autoconfiguration system is described in .IR autoconfig (8). A list of the supported devices is given below. .SH SEE ALSO intro(4), networking(4), config(8). .SH "LIST OF DEVICES" The devices listed below are supported in this incarnation of the system. Pseudo-devices are not listed. Listed also are devices which are in various stages of porting to 2.11BSD from 4.3BSD. .PP Devices are indicated by their functional interface. If second vendor products provide functionally identical interfaces they should be usable with the supplied software. (\fBBeware, however, that we promise the software works ONLY with the hardware indicated on the appropriate manual page.\fP) Occasionally, new devices of a similar type may be added simply by creating appropriate table entries in the driver. .sp .ta 1.0i .nf .ne 4 .B "The following are known to work:" acc ACC LH/DH IMP communications interface de DEC DEUNA 10Mb/s Ethernet controller dh DH-11 emulators, terminal multiplexor dhu DHU-11 terminal multiplexor dz DZ-11 terminal multiplexor ec 3Com 10Mb/s Ethernet controller hk RK6-11/RK06 and RK07 moving head disk ht TM03 MASSBUS tape drive interface (with TE-16, TU-45, TU-77) il Interlan 1010, 1010A, 2010A 10Mb/s Ethernet controller lp LP-11 parallel line printer interface qe DEC DEQNA Q-bus 10 Mb/s Ethernet interface ra DEC UDA-50, RQDX, KLESI disk controllers rk DEC RK05 disk controller rl DEC RL-11 disk controller rx DEC RX02 floppy interface si SI 9500 disk controller tm TM-11/TE-10 tape drive interface tmscp TMSCP-compatible tape controllers (e.g., TU81, TK50) ts TS-11 tape drive interface vv Proteon proNET 10Mb/s and 80Mb/s ring network interface xp General purpose SMD disk controller .ne 4 .B "The following should work:" dr DR-11W general purpose DMA UNIBUS interface .ne 4 .B "The following worked in the past but will probably require work:" css DEC IMP-11A communications interface dmc DEC DMC-11/DMR-11 point-to-point communications device en Xerox 3Mb/s Ethernet controller (obsolete) sri DR-11C IMP interface .ne 4 .B "It should be possible to port these from 4.3BSD:" ex Excelan 10Mb/s Ethernet controller ix Interlan NP-100 10Mb/s Ethernet controller np Interlan NP-100 10Mb/s Ethernet controller (intelligent mode) pcl DEC PCL-11 communications interface .ne 4 .B "No idea whether any of the following could be ported:" ad Data translation A/D interface ct C/A/T or APS phototypesetter ddn ACC ACP625 DDN Standard Mode X.25 IMP interface dmf DEC DMF-32 terminal multiplexor and parallel printer interface dmz DEC DMZ-32 terminal multiplexor dn DEC DN-11 autodialer interface hdh ACC IF-11/HDH IMP interface hp MASSBUS disk interface (with RP06, RM03, RM05, etc.) hy DR-11B or GI-13 interface to an NSC Hyperchannel kg KL-11/DL-11W line clock mt TM78 MASSBUS tape drive interface tu VAX-11/730 TU58 console cassette interface un DR-11W interface to Ungermann-Bass up Emulex SC-21V, SC-31 UNIBUS disk controller ut UNIBUS TU-45 tape drive interface uu TU58 dual cassette drive interface (DL11) va Benson-Varian printer/plotter interface vp Versatec printer/plotter interface ================================================ FILE: share/man/man4/ip.4 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)ip.4p 6.2 (Berkeley) 5/16/86 .\" .TH IP 4P "May 16, 1986" .UC 5 .SH NAME ip \- Internet Protocol .SH SYNOPSIS .B #include .br .B #include .PP .B s = socket(AF_INET, SOCK_RAW, proto); .SH DESCRIPTION IP is the transport layer protocol used by the Internet protocol family. Options may be set at the IP level when using higher-level protocols that are based on IP (such as TCP and UDP). It may also be accessed through a \*(lqraw socket\*(rq when developing new protocols, or special purpose applications. .PP A single generic option is supported at the IP level, IP_OPTIONS, that may be used to provide IP options to be transmitted in the IP header of each outgoing packet. Options are set with .IR setsockopt (2) and examined with .IR getsockopt (2). The format of IP options to be sent is that specified by the IP protocol specification, with one exception: the list of addresses for Source Route options must include the first-hop gateway at the beginning of the list of gateways. The first-hop gateway address will be extracted from the option list and the size adjusted accordingly before use. IP options may be used with any socket type in the Internet family. .PP Raw IP sockets are connectionless, and are normally used with the .I sendto and .I recvfrom calls, though the .IR connect (2) call may also be used to fix the destination for future packets (in which case the .IR read (2) or .IR recv (2) and .IR write (2) or .IR send (2) system calls may be used). .PP If .I proto is 0, the default protocol IPPROTO_RAW is used for outgoing packets, and only incoming packets destined for that protocol are received. If .I proto is non-zero, that protocol number will be used on outgoing packets and to filter incoming packets. .PP Outgoing packets automatically have an IP header prepended to them (based on the destination address and the protocol number the socket is created with). Incoming packets are received with IP header and options intact. .SH DIAGNOSTICS A socket operation may fail with one of the following errors returned: .TP 15 [EISCONN] when trying to establish a connection on a socket which already has one, or when trying to send a datagram with the destination address specified and the socket is already connected; .TP 15 [ENOTCONN] when trying to send a datagram, but no destination address is specified, and the socket hasn't been connected; .TP 15 [ENOBUFS] when the system runs out of memory for an internal data structure; .TP 15 [EADDRNOTAVAIL] when an attempt is made to create a socket with a network address for which no network interface exists. .PP The following errors specific to IP may occur when setting or getting IP options: .TP 15 [EINVAL] An unknown socket option name was given. .TP 15 [EINVAL] The IP option field was improperly formed; an option field was shorter than the minimum value or longer than the option buffer provided. .SH SEE ALSO getsockopt(2), send(2), recv(2), intro(4N), icmp(4P), inet(4F) ================================================ FILE: share/man/man4/lo.4 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)lo.4 6.3 (Berkeley) 8/1/87 .\" .TH LO 4 "August 1, 1987" .UC 2 .SH NAME lo \- software loopback network interface .SH SYNOPSIS .ft B .nf /sys/conf/SYSTEM: NLOOP \fI1\fP # loop-back pseudo-device .fi .ft R .SH DESCRIPTION The .I loop interface is a software loopback mechanism which may be used for performance analysis, software testing, and/or local communication. As with other network interfaces, the loopback interface must have network addresses assigned for each address family with which it is to be used. These addresses may be set or changed with the SIOCSIFADDR ioctl. The loopback interface should be the last interface configured, as protocols may use the order of configuration as an indication of priority. The loopback should \fBnever\fP be configured first unless no hardware interfaces exist. .SH DIAGNOSTICS \fBlo%d: can't handle af%d\fP. The interface was handed a message with addresses formatted in an unsuitable address family; the packet was dropped. .SH SEE ALSO intro(4N), inet(4F), ns(4F) .SH BUGS Previous versions of the system enabled the loopback interface automatically, using a nonstandard Internet address (127.1). Use of that address is now discouraged; a reserved host address for the local network should be used instead. ================================================ FILE: share/man/man4/lp.4 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)lp.4 6.1 (Berkeley) 1/28/88 .\" .TH LP 4 "January 28, 1988" .UC 2 .SH NAME lp \- line printer .SH SYNOPSIS .ft B .nf /sys/conf/SYSTEM: .ta .5i +\w'LP_MAXCOL 'u +\w'lp_printers 'u NLP \fIlp_printers\fP # Line Printer LP_MAXCOL \fI132\fP # Maximum number of columns on line printers .DT /etc/dtab: .ta .5i +\w'#Name 'u +\w'Unit# 'u +\w'177777 'u +\w'Vector 'u +\w'Br 'u +\w'xxxxxxx 'u +\w'xxxxxxx 'u #Name Unit# Addr Vector Br Handler(s) # Comments lp ? 177514 200 4 lpintr # lp-11 line printer .DT major device number(s): raw: 5 minor device encoding: bit 01 specifies 64-character set (instead of 96-character set) bits 06 are reserved bits 0370 specify line printer unit: * 8 .fi .ft R .SH DESCRIPTION .I Lp provides the interface to any of the standard DEC line printers on an LP-11 parallel interface. When it is opened or closed, a suitable number of page ejects is generated. Bytes written are printed. .PP The unit number of the printer is specified by the minor device after removing the low 3 bits, which act as per-device parameters. Currently only the lowest of the low three bits is interpreted: if it is set, the device is treated as having a 64-character set, rather than a full 96-character set. In the resulting half-ASCII mode, lower case letters are turned into upper case and certain characters are escaped according to the following table: .PP .br .ns .TP 10 { \o"-(" .br .ns .TP 10 } \o"-)" .br .ns .TP 10 \` \o"-\'" .br .ns .TP 10 | \o"\-!" .br .ns .TP 10 ~ \o"\-^" .. .PP The driver correctly interprets carriage returns, backspaces, tabs, and form feeds. Lines longer than the maximum page width are truncated. The page width is specified via the LP_MAXCOL definition, set to 132 in the GENERIC distribution. .SH FILES .ta \w'/dev/MAKEDEV.local 'u /dev/lp .br /dev/MAKEDEV script to create special files .br /dev/MAKEDEV.local script to localize special files .DT .SH "SEE ALSO" lpr(1), dtab(5), autoconfig(8) .SH DIAGNOSTICS None. .SH BUGS Although the driver supports multiple printers this has never been tried. ================================================ FILE: share/man/man4/mem.4 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)mem.4 6.2 (Berkeley) 1/28/88 .\" .TH MEM 4 "January 28, 1988" .UC 2 .SH NAME mem, kmem \- main memory .SH SYNOPSIS .ft B .nf major device number(s): raw: 1 minor device encoding: mem: 0; kmem: 1; null: 2 .fi .ft R .SH DESCRIPTION .I Mem is a special file that is an image of the main memory of the computer. It may be used, for example, to examine (and even to patch) the system. .PP Byte addresses in .I mem are interpreted as physical memory addresses. References to non-existent locations cause errors to be returned. .PP The file .I kmem is the same as .I mem except that kernel virtual memory rather than physical memory is accessed. Only kernel virtual addresses that are mapped to memory are allowed. Examining and patching device registers is likely to lead to unexpected results when read-only or write-only bits are present. .PP On PDP-11s, the I/O page begins at location 0160000 of .I kmem and the per-process data segment for the current process begins at 0140000 and is USIZE clicks (64 bytes each) long. .SH FILES .ta \w'/dev/MAKEDEV.local 'u /dev/mem .br /dev/kmem .br /dev/MAKEDEV script to create special files .br /dev/MAKEDEV.local script to localize special files .DT .SH BUGS .PP On PDP-11's, specifying an odd kernel or user address, or an odd transfer count is [generally] slower than using all even parameters. .PP On machines with ENABLE/34(tm) memory mapping boards the I/O page can be accessed only through \fIkmem\fP. ================================================ FILE: share/man/man4/mtio.4 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)mtio.4 6.3 (2.11BSD) 1995/12/22 .\" .TH MTIO 4 "December 22, 1995" .UC 2 .SH NAME mtio \- UNIX magtape interface .SH DESCRIPTION The files .I "mt0, ..., mt15" refer to the UNIX magtape drives, which may be on the MASSBUS using the TM03 formatter .IR ht (4), or on the UNIBUS using either the TM11 or TS11 formatters .IR tm (4) or .IR ts (4). The following description applies to any of the transport/controller pairs. The files .I "mt0, ..., mt7" are 800bpi (or the transport's lowest density), .I "mt8, ..., mt15" are 1600bpi (or the transport's second density), and .I "mt16, ..., mt23" are 6250bpi (or the transport's third density). (But note that only 1600 bpi is available with the TS11.) The files .IR "mt0, ..., mt3" , .IR "mt8, ..., mt11" , and .I "mt16, ..., mt19" are rewound when closed; the others are not. When a file open for writing is closed, two end-of-files are written. If the tape is not to be rewound it is positioned with the head between the two tapemarks. .PP A standard tape consists of a series of 1024 byte records terminated by an end-of-file. To the extent possible, the system makes it possible, if inefficient, to treat the tape like any other file. Seeks have their usual meaning and it is possible to read or write a byte at a time. Writing in very small units is inadvisable, however, because it uses most of the tape in record gaps. .PP The .I mt files discussed above are useful when it is desired to access the tape in a way compatible with ordinary files. When foreign tapes are to be dealt with, and especially when long records are to be read or written, the `raw' interface is appropriate. The associated files are named .I "rmt0, ..., rmt23," but the same minor-device considerations as for the regular files still apply. A number of other ioctl operations are available on raw magnetic tape. The following definitions are from .RI < sys/mtio.h >: .PP .nf /* * Structures and definitions for mag tape io control commands */ /* structure for MTIOCTOP - mag tape op command */ struct mtop { short mt_op; /* operations defined below */ daddr_t mt_count; /* how many of them */ }; /* operations */ #define MTWEOF 0 /* write an end-of-file record */ #define MTFSF 1 /* forward space file */ #define MTBSF 2 /* backward space file */ #define MTFSR 3 /* forward space record */ #define MTBSR 4 /* backward space record */ #define MTREW 5 /* rewind */ #define MTOFFL 6 /* rewind and put the drive offline */ #define MTNOP 7 /* no operation, sets status only */ #define MTCACHE 8 /* enable controller cache */ #define MTNOCACHE 9 /* disable controller cache */ /* structure for MTIOCGET - mag tape get status command */ struct mtget { short mt_type; /* type of magtape device */ /* the following two registers are grossly device dependent */ short mt_dsreg; /* ``drive status'' register */ short mt_erreg; /* ``error'' register */ /* end device-dependent registers */ short mt_resid; /* residual count */ /* the following two are not yet implemented */ daddr_t mt_fileno; /* file number of current position */ daddr_t mt_blkno; /* block number of current position */ /* end not yet implemented */ }; /* * Constants for mt_type byte. These are the same * for other controllers compatible with the types listed. */ #define MT_ISTS 0x01 /* TS-11 */ #define MT_ISHT 0x02 /* TM03 Massbus: TE16, TU45, TU77 */ #define MT_ISTM 0x03 /* TM11/TE10 Unibus */ #define MT_ISMT 0x04 /* TM78/TU78 Massbus */ #define MT_ISUT 0x05 /* SI TU-45 emulation on Unibus */ #define MT_ISCPC 0x06 /* SUN */ #define MT_ISAR 0x07 /* SUN */ #define MT_ISTMSCP 0x08 /* DEC TMSCP protocol (TU81, TK50) */ /* mag tape io control commands */ #define MTIOCTOP _IOW(m, 1, struct mtop) /* do a mag tape op */ #define MTIOCGET _IOR(m, 2, struct mtget) /* get tape status */ #define MTIOCIEOT _IO(m, 3) /* ignore EOT error */ #define MTIOCEEOT _IO(m, 4) /* enable EOT error */ #ifndef KERNEL #define DEFTAPE "/dev/rmt12" #endif .fi .ft R .PP Each .I read or .I write call reads or writes the next record on the tape. In the write case the record has the same length as the buffer given. During a read, the record size is passed back as the number of bytes read, provided it is no greater than the buffer size; if the record is long, an error is indicated. In raw tape I/O seeks are ignored. A zero byte count is returned when a tape mark is read, but another read will fetch the first record of the new tape file. .PP The MTCACHE and MTNOCACHE commands do not apply to all tape drivers. At present only the TMSCP driver supports those commands and then only for drives such as the TU81+. .SH FILES /dev/mt? .br /dev/rmt? .SH "SEE ALSO" mt(1), tar(1), tp(1), ht(4), tm(4), ts(4) .SH BUGS The status should be returned in a device independent format. .PP The special file naming should be redone in a more consistent and understandable manner. ================================================ FILE: share/man/man4/networking.4 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)intro.4n 6.3 (Berkeley) 8/1/87 .\" .TH INTRO 4N "August 1, 1987" .UC 5 .SH NAME networking \- introduction to networking facilities .SH SYNOPSIS .nf .ft B #include #include #include .fi R .fi .SH DESCRIPTION .de _d .if t .ta .6i 2.1i 2.6i .\" 2.94 went to 2.6, 3.64 to 3.30 .if n .ta .84i 2.6i 3.30i .. .de _f .if t .ta .5i 1.25i 2.5i .\" 3.5i went to 3.8i .if n .ta .7i 1.75i 3.8i .. This section briefly describes the networking facilities available in the system. Documentation in this part of section 4 is broken up into three areas: .I "protocol families (domains), .IR protocols , and .IR "network interfaces" . Entries describing a protocol family are marked ``4F,'' while entries describing protocol use are marked ``4P.'' Hardware support for network interfaces are found among the standard ``4'' entries. .PP All network protocols are associated with a specific .IR "protocol family" . A protocol family provides basic services to the protocol implementation to allow it to function within a specific network environment. These services may include packet fragmentation and reassembly, routing, addressing, and basic transport. A protocol family may support multiple methods of addressing, though the current protocol implementations do not. A protocol family is normally comprised of a number of protocols, one per .IR socket (2) type. It is not required that a protocol family support all socket types. A protocol family may contain multiple protocols supporting the same socket abstraction. .PP A protocol supports one of the socket abstractions detailed in .IR socket (2). A specific protocol may be accessed either by creating a socket of the appropriate type and protocol family, or by requesting the protocol explicitly when creating a socket. Protocols normally accept only one type of address format, usually determined by the addressing structure inherent in the design of the protocol family/network architecture. Certain semantics of the basic socket abstractions are protocol specific. All protocols are expected to support the basic model for their particular socket type, but may, in addition, provide non-standard facilities or extensions to a mechanism. For example, a protocol supporting the SOCK_STREAM abstraction may allow more than one byte of out-of-band data to be transmitted per out-of-band message. .PP A network interface is similar to a device interface. Network interfaces comprise the lowest layer of the networking subsystem, interacting with the actual transport hardware. An interface may support one or more protocol families and/or address formats. The SYNOPSIS section of each network interface entry gives a sample specification of the related drivers for use in providing a system description to the .IR /sys/conf/config script. The DIAGNOSTICS section lists messages which may appear on the console and/or in the system error log, .I /usr/adm/messages (see .IR syslogd (8)), due to errors in device operation. .SH PROTOCOLS The system currently supports the DARPA Internet protocols and the Xerox Network Systems(tm) protocols. Raw socket interfaces are provided to the IP protocol layer of the DARPA Internet, to the IMP link layer (1822), and to the IDP protocol of Xerox NS. Consult the appropriate manual pages in this section for more information regarding the support for each protocol family. .SH ADDRESSING Associated with each protocol family is an address format. The following address formats are used by the system (and additional formats are defined for possible future implementation): .sp 1 .nf ._d #define AF_UNIX 1 /* local to host (pipes, portals) */ #define AF_INET 2 /* internetwork: UDP, TCP, etc. */ #define AF_IMPLINK 3 /* arpanet imp addresses */ #define AF_PUP 4 /* pup protocols: e.g. BSP */ #define AF_NS 6 /* Xerox NS protocols */ #define AF_HYLINK 15 /* NSC Hyperchannel */ .fi .SH ROUTING The network facilities provided limited packet routing. A simple set of data structures comprise a ``routing table'' used in selecting the appropriate network interface when transmitting packets. This table contains a single entry for each route to a specific network or host. A user process, the routing daemon, maintains this data base with the aid of two socket-specific .IR ioctl (2) commands, SIOCADDRT and SIOCDELRT. The commands allow the addition and deletion of a single routing table entry, respectively. Routing table manipulations may only be carried out by super-user. .PP A routing table entry has the following form, as defined in .RI < net/route.h >; .sp 1 ._f .nf struct rtentry { u_long rt_hash; struct sockaddr rt_dst; struct sockaddr rt_gateway; short rt_flags; short rt_refcnt; u_long rt_use; struct ifnet *rt_ifp; }; .sp 1 .fi with .I rt_flags defined from, .sp 1 .nf ._d #define RTF_UP 0x1 /* route usable */ #define RTF_GATEWAY 0x2 /* destination is a gateway */ #define RTF_HOST 0x4 /* host entry (net otherwise) */ #define RTF_DYNAMIC 0x10 /* created dynamically (by redirect) */ .fi .PP Routing table entries come in three flavors: for a specific host, for all hosts on a specific network, for any destination not matched by entries of the first two types (a wildcard route). When the system is booted and addresses are assigned to the network interfaces, each protocol family installs a routing table entry for each interface when it is ready for traffic. Normally the protocol specifies the route through each interface as a ``direct'' connection to the destination host or network. If the route is direct, the transport layer of a protocol family usually requests the packet be sent to the same host specified in the packet. Otherwise, the interface is requested to address the packet to the gateway listed in the routing entry (i.e. the packet is forwarded). .PP Routing table entries installed by a user process may not specify the hash, reference count, use, or interface fields; these are filled in by the routing routines. If a route is in use when it is deleted .RI ( rt_refcnt is non-zero), the routing entry will be marked down and removed from the routing table, but the resources associated with it will not be reclaimed until all references to it are released. The routing code returns EEXIST if requested to duplicate an existing entry, ESRCH if requested to delete a non-existent entry, or ENOBUFS if insufficient resources were available to install a new route. User processes read the routing tables through the .I /dev/kmem device. The .I rt_use field contains the number of packets sent along the route. .PP When routing a packet, the kernel will first attempt to find a route to the destination host. Failing that, a search is made for a route to the network of the destination. Finally, any route to a default (``wildcard'') gateway is chosen. If multiple routes are present in the table, the first route found will be used. If no entry is found, the destination is declared to be unreachable. .PP A wildcard routing entry is specified with a zero destination address value. Wildcard routes are used only when the system fails to find a route to the destination host and network. The combination of wildcard routes and routing redirects can provide an economical mechanism for routing traffic. .SH INTERFACES Each network interface in a system corresponds to a path through which messages may be sent and received. A network interface usually has a hardware device associated with it, though certain interfaces such as the loopback interface, .IR lo (4), do not. .PP The following .I ioctl calls may be used to manipulate network interfaces. The .I ioctl is made on a socket (typically of type SOCK_DGRAM) in the desired domain. Unless specified otherwise, the request takes an .I ifrequest structure as its parameter. This structure has the form .PP .nf .DT struct ifreq { #define IFNAMSIZ 16 char ifr_name[IFNAMSIZ]; /* if name, e.g. "en0" */ union { struct sockaddr ifru_addr; struct sockaddr ifru_dstaddr; struct sockaddr ifru_broadaddr; short ifru_flags; int ifru_metric; caddr_t ifru_data; } ifr_ifru; #define ifr_addr ifr_ifru.ifru_addr /* address */ #define ifr_dstaddr ifr_ifru.ifru_dstaddr /* other end of p-to-p link */ #define ifr_broadaddr ifr_ifru.ifru_broadaddr /* broadcast address */ #define ifr_flags ifr_ifru.ifru_flags /* flags */ #define ifr_metric ifr_ifru.ifru_metric /* metric */ #define ifr_data ifr_ifru.ifru_data /* for use by interface */ }; .fi .TP SIOCSIFADDR Set interface address for protocol family. Following the address assignment, the ``initialization'' routine for the interface is called. .TP SIOCGIFADDR Get interface address for protocol family. .TP SIOCSIFDSTADDR Set point to point address for protocol family and interface. .TP SIOCGIFDSTADDR Get point to point address for protocol family and interface. .TP SIOCSIFBRDADDR Set broadcast address for protocol family and interface. .TP SIOCGIFBRDADDR Get broadcast address for protocol family and interface. .TP SIOCSIFFLAGS Set interface flags field. If the interface is marked down, any processes currently routing packets through the interface are notified; some interfaces may be reset so that incoming packets are no longer received. When marked up again, the interface is reinitialized. .TP SIOCGIFFLAGS Get interface flags. .TP SIOCSIFMETRIC Set interface routing metric. The metric is used only by user-level routers. .TP SIOCGIFMETRIC Get interface metric. .TP SIOCGIFCONF Get interface configuration list. This request takes an .I ifconf structure (see below) as a value-result parameter. The .I ifc_len field should be initially set to the size of the buffer pointed to by .IR ifc_buf . On return it will contain the length, in bytes, of the configuration list. .PP .nf .DT /* * Structure used in SIOCGIFCONF request. * Used to retrieve interface configuration * for machine (useful for programs which * must know all networks accessible). */ struct ifconf { int ifc_len; /* size of associated buffer */ union { caddr_t ifcu_buf; struct ifreq *ifcu_req; } ifc_ifcu; #define ifc_buf ifc_ifcu.ifcu_buf /* buffer address */ #define ifc_req ifc_ifcu.ifcu_req /* array of structures returned */ }; .fi .SH SEE ALSO socket(2), ioctl(2), intro(4), config(8), routed(8C) ================================================ FILE: share/man/man4/ns.4 ================================================ .\" Copyright (c) 1985 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)ns.4f 1.4 (2.11BSD) 1996/1/27 .\" .TH NS 4F "January 27, 1996" .UC 2 .SH NAME ns \- Xerox Network Systems(tm) protocol family .SH SYNOPSIS .ft B .nf Not currently supported under 2.11BSD .fi .ft R .SH DESCRIPTION .IX "ns device" "" "\fLns\fP \(em Xerox NS protocol family" The NS protocol family is a collection of protocols layered atop the .I Internet Datagram Protocol (IDP) transport layer, and using the Xerox NS address formats. The NS family provides protocol support for the SOCK_STREAM, SOCK_DGRAM, SOCK_SEQPACKET, and SOCK_RAW socket types; the SOCK_RAW interface is a debugging tool, allowing you to trace all packets entering, (or with toggling kernel variable, additionally leaving) the local host. .SH ADDRESSING NS addresses are 12 byte quantities, consisting of a 4 byte Network number, a 6 byte Host number and a 2 byte port number, all stored in network standard format. (on the VAX these are word and byte reversed; on the Sun they are not reversed). The include file .RI < netns/ns.h > defines the NS address as a structure containing unions (for quicker comparisons). .PP Sockets in the Internet protocol family use the following addressing structure: .nf struct sockaddr_ns { short sns_family; struct ns_addr sns_addr; char sns_zero[2]; }; where an ns_addr is composed as follows: union ns_host { u_char c_host[6]; u_short s_host[3]; }; union ns_net { u_char c_net[4]; u_short s_net[2]; }; struct ns_addr { union ns_net x_net; union ns_host x_host; u_short x_port; }; .fi Sockets may be created with an address of all zeroes to effect ``wildcard'' matching on incoming messages. The local port address specified in a .IR bind (2) call is restricted to be greater than NSPORT_RESERVED (=3000, in ) unless the creating process is running as the super-user, providing a space of protected port numbers. .SH PROTOCOLS The NS protocol family supported by the operating system is comprised of the Internet Datagram Protocol (IDP) .IR idp (4P), Error Protocol (available through IDP), and Sequenced Packet Protocol (SPP) .IR spp (4P). .LP SPP is used to support the SOCK_STREAM and SOCK_SEQPACKET abstraction, while IDP is used to support the SOCK_DGRAM abstraction. The Error protocol is responded to by the kernel to handle and report errors in protocol processing; it is, however, only accessible to user programs through heroic actions. .SH SEE ALSO intro(3), byteorder(3N), gethostbyname(3N), getnetent(3N), getprotoent(3N), getservent(3N), ns(3N), intro(4N), spp(4P), idp(4P), nsip(4) .br Internet Transport Protocols, Xerox Corporation document XSIS-028112 .br An Advanced 4.3BSD Interprocess Communication Tutorial ================================================ FILE: share/man/man4/nsip.4 ================================================ .\" Copyright (c) 1985 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)nsip.4 1.2 (2.11BSD) 1996/1/27 .\" .TH NSIP 4 "January 27, 1996" .UC 2 .SH NAME nsip \- software network interface encapsulating ns packets in ip packets. .SH SYNOPSIS .ft B .nf #include Not currently supported under 2.11BSD .fi .ft R .SH DESCRIPTION The .I nsip interface is a software mechanism which may be used to transmit Xerox NS(tm) packets through otherwise uncooperative networks. It functions by prepending an IP header, and resubmitting the packet through the unix IP machinery. .LP The super-user can advise the operating system of a willing partner by naming an IP address to be associated with an NS address. Presently, only specific hosts pairs are allowed, and for each host pair, an artificial point-to-point interface is constructed. At some future date, IP broadcast addresses or hosts may be paired with NS networks or hosts. .LP Specifically, a socket option of SO_NSIP_ROUTE is set on a socket of family AF_NS, type SOCK_DGRAM, passing the following structure: .nf struct nsip_req { struct sockaddr rq_ns; /* must be ns format destination */ struct sockaddr rq_ip; /* must be ip format gateway */ short rq_flags; }; .SH DIAGNOSTICS \fBnsip%d: can't handle af%d\fP. The interface was handed a message with addresses formatted in an unsuitable address family; the packet was dropped. .SH SEE ALSO intro(4N), ns(4F) .SH BUGS It is absurd to have a separate pseudo-device for each pt-to-pt link. There is no way to change the IP address for an NS host once the the encapsulation interface is set up. The request should honor flags of RTF_GATEWAY to indicate remote networks, and the absence of RTF_UP should be a clue to remove that partner. This was intended to postpone the necessity of rewriting reverse ARP for the .B en device, and to allow passing XNS packets through an Arpanet-Milnet gateway, to facilitate testing between some co-operating universities. ================================================ FILE: share/man/man4/null.4 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)null.4 6.1 (Berkeley) 1/28/88 .\" .TH NULL 4 "January 28, 1988" .UC 2 .SH NAME null \- data sink .SH SYNOPSIS .ft B .nf major device number(s): raw: 1 minor device encoding: mem: 0; kmem: 1; null: 2 .fi .ft R .SH DESCRIPTION Data written on a null special file is discarded. .PP Reads from a null special file always return 0 bytes. .SH FILES .ta \w'/dev/MAKEDEV.local 'u /dev/null .br /dev/MAKEDEV script to create special files .br /dev/MAKEDEV.local script to localize special files .DT .SH "SEE ALSO" mem(4) ================================================ FILE: share/man/man4/pty.4 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)pty.4 6.2 (Berkeley) 5/19/86 .\" .TH PTY 4 "May 19, 1986" .UC 5 .SH NAME pty \- pseudo terminal driver .SH SYNOPSIS .ft B .nf /sys/conf/SYSTEM: NPTY \fIptys\fP # pseudo-terminals, in groups of 8 .fi .ft R .SH DESCRIPTION The .I pty driver provides support for a device-pair termed a .IR "pseudo terminal" . A pseudo terminal is a pair of character devices, a .I master device and a .I slave device. The slave device provides processes an interface identical to that described in .IR tty (4). However, whereas all other devices which provide the interface described in .IR tty (4) have a hardware device of some sort behind them, the slave device has, instead, another process manipulating it through the master half of the pseudo terminal. That is, anything written on the master device is given to the slave device as input and anything written on the slave device is presented as input on the master device. .PP In configuring, .I ptys specifies the number of pseudo terminal pairs are configured. .PP The following .I ioctl calls apply only to pseudo terminals: .TP TIOCSTOP Stops output to a terminal (e.g. like typing ^S). Takes no parameter. .TP TIOCSTART Restarts output (stopped by TIOCSTOP or by typing ^S). Takes no parameter. .TP TIOCPKT Enable/disable .I packet mode. Packet mode is enabled by specifying (by reference) a nonzero parameter and disabled by specifying (by reference) a zero parameter. When applied to the master side of a pseudo terminal, each subsequent .I read from the terminal will return data written on the slave part of the pseudo terminal preceded by a zero byte (symbolically defined as TIOCPKT_DATA), or a single byte reflecting control status information. In the latter case, the byte is an inclusive-or of zero or more of the bits: .RS .TP TIOCPKT_FLUSHREAD whenever the read queue for the terminal is flushed. .TP TIOCPKT_FLUSHWRITE whenever the write queue for the terminal is flushed. .TP TIOCPKT_STOP whenever output to the terminal is stopped a la ^S. .TP TIOCPKT_START whenever output to the terminal is restarted. .TP TIOCPKT_DOSTOP whenever .I t_stopc is ^S and .I t_startc is ^Q. .TP TIOCPKT_NOSTOP whenever the start and stop characters are not ^S/^Q. .RE .IP While this mode is in use, the presence of control status information to be read from the master side may be detected by a .I select for exceptional conditions. .IP This mode is used by .IR rlogin (1C) and .IR rlogind (8C) to implement a remote-echoed, locally ^S/^Q flow-controlled remote login with proper back-flushing of output; it can be used by other similar programs. .TP TIOCUCNTL Enable/disable a mode that allows a small number of simple user .I ioctl commands to be passed through the pseudo-terminal, using a protocol similar to that of TIOCPKT. The TIOCUCNTL and TIOCPKT modes are mutually exclusive. This mode is enabled from the master side of a pseudo terminal by specifying (by reference) a nonzero parameter and disabled by specifying (by reference) a zero parameter. Each subsequent .I read from the master side will return data written on the slave part of the pseudo terminal preceded by a zero byte, or a single byte reflecting a user control operation on the slave side. A user control command consists of a special .I ioctl operation with no data; the command is given as UIOCCMD(\fIn\fP), where \fIn\fP is a number in the range 1-255. The operation value \fIn\fP will be received as a single byte on the next .I read from the master side. The \fIioctl\fP UIOCCMD(0) is a no-op that may be used to probe for the existence of this facility. As with TIOCPKT mode, command operations may be detected with a .I select for exceptional conditions. .TP TIOCREMOTE A mode for the master half of a pseudo terminal, independent of TIOCPKT. This mode causes input to the pseudo terminal to be flow controlled and not input edited (regardless of the terminal mode). Each write to the control terminal produces a record boundary for the process reading the terminal. In normal usage, a write of data is like the data typed as a line on the terminal; a write of 0 bytes is like typing an end-of-file character. TIOCREMOTE can be used when doing remote line editing in a window manager, or whenever flow controlled input is required. .SH FILES .DT /dev/pty[p-r][0-9a-f] master pseudo terminals .br /dev/tty[p-r][0-9a-f] slave pseudo terminals .SH DIAGNOSTICS None. ================================================ FILE: share/man/man4/qe.4 ================================================ .\" Copyright (c) 1986 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)qe.4 6.1 (Berkeley) 8/20/87 .\" .TH QE 4 "August 20, 1987" .UC 2 .SH NAME qe \- DEC DEQNA Q-bus 10 Mb/s Ethernet interface .SH SYNOPSIS .ft B .nf /sys/conf/SYSTEM: NQE \fIqe_controllers\fP # DEQNA .fi .ft R .SH DESCRIPTION The .B qe interface provides access to a 10 Mb/s Ethernet network through the DEC DEQNA Q-bus controller. .PP Each of the host's network addresses is specified at boot time with an SIOCSIFADDR ioctl. The .B qe interface employs the address resolution protocol described in arp(4P) to map dynamically between Internet and Ethernet addresses on the local network. .PP The interface normally tries to use a ``trailer'' encapsulation to minimize copying data on input and output. The use of trailers is negotiated with ARP. This negotiation may be disabled, on a per-interface basis, by setting the IFF_NOTRAILERS flag with an SIOCSIFFLAGS ioctl. .SH DIAGNOSTICS .SH SEE ALSO inet(4F), intro(4N), arp(4P) ================================================ FILE: share/man/man4/ra.4 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)ra.4 6.2.1 (2.11BSD) 1995/06/17 .\" .TH RA 4 "September 6, 1987" .UC 2 .SH NAME ra \- MSCP disk controller interface .SH SYNOPSIS .ft B .nf .ta .5i +\w'NRAC 'u +\w'ra_controllers 'u /sys/conf/SYSTEM: NRAC \fIra_controllers\fP # NRAD controllers NRAD \fIra_drives\fP # RX33/50, RC25, RD51/52/53/54, RA60/80/81/82 .DT /etc/dtab: .ta .5i +\w'#Name 'u +\w'Unit# 'u +\w'177777 'u +\w'Vector 'u +\w'Br 'u +\w'xxxxxxx 'u +\w'xxxxxxx 'u #Name Unit# Addr Vector Br Handler(s) # Comments ra ? 172150 154 5 raintr # uda50, rqdx1/2/3 .DT major device number(s): raw: 14 block: 5 minor device encoding: bits 0007 specify partition of RA drive bits 0070 specify RA drive bits 0300 specify RA controller .fi .ft R .SH DESCRIPTION This is a driver for the DEC UDA-50 disk controller and for other compatible controllers. The UDA-50 communicates with the host through a packet oriented protocol termed the Mass Storage Control Protocol (MSCP). Consult the file .RI < pdp/mscp.h > for a detailed description of this protocol. .PP Files with minor device numbers 0 through 7 refer to various portions of drive 0; minor devices 8 through 15 refer to drive 1, etc. The standard device names begin with ``ra'' followed by the drive number and then a letter a-h for partitions 0-7 respectively. The character ? stands here for a drive number in the range 0-7. .PP The block files access the disk via the system's normal buffering mechanism and may be read and written without regard to physical disk records. There is also a `raw' interface which provides for direct transmission between the disk and the user's read or write buffer. A single read or write call results in exactly one I/O operation and therefore raw I/O is considerably more efficient when many words are transmitted. The names of the raw files conventionally begin with an extra `r.' .PP In raw I/O the buffer must begin on a word (even) boundary, and counts should be a multiple of 512 bytes (a disk sector). Likewise .I seek calls should specify a multiple of 512 bytes. .SH "DISK SUPPORT" This driver configures the drive type of each drive when it is first opened. Partition information is read from the disklabel. If there is no label or the label is corrupt then the 'a' partition is used to span the entire drive. .PP The ra?a partition is normally used for the root file system, the ra?b partition as a swap area, and the ra?c partition for pack-pack copying (it maps the entire disk). .SH FILES .ta \w'/dev/MAKEDEV.local 'u /dev/ra[0-7][a-h] .br /dev/rra[0-7][a-h] .br /dev/MAKEDEV script to create special files .br .SH SEE ALSO hk(4), ram(4), rk(4), rl(4), rp(4), rx(4), si(4), xp(4), dtab(5), autoconfig(8), disklabel(8) .SH DIAGNOSTICS .BR "rasa %o, state %d" . (Additional status information given after a hard i/o error.) The values of the UDA-50 status register and the internal driver state are printed. .PP .BR "ra%d: interrupt in unknown state %d ignored" . An interrupt was received when the driver was in an unknown internal state. Indicates a hardware problem or a driver bug. .PP .BR "ra%d: fatal error (%o)" . The UDA-50 indicated a ``fatal error'' in the status returned to the host. The contents of the status register are displayed. .PP .BR "ra%d,%d: OFFLINE" . (Additional status information given after a hard i/o error.) A hard i/o error occurred because the drive was not on-line. The attached unit number and the MSCP unit numbers are printed. .PP .BR "status %o" . (Additional status information given after a hard i/o error.) The status information returned from the UDA-50 is tacked onto the end of the hard error message printed on the console. .PP .BR "ra: unknown packet opcode=0%o" . An MSCP packet of unknown type was received from the UDA-50. Check the cabling to the controller. .PP The following errors are interpretations of MSCP error messages returned by the UDA-50 to the host. .PP .BR "ra: %s error, controller error, event 0%o" . .PP .BR "ra: %s error, host memory access error, event 0%o, addr 0%o" . .PP .BR "ra: %s error, disk transfer error, unit %d, grp 0x%x, hdr 0x%x" . .PP .BR "ra: %s error, SDI error, unit %d, event 0%o, hdr 0x%x" . .PP .BR "ra: %s error, small disk error, unit %d, event 0%o, cyl %d" . .PP .BR "ra: %s error, unknown error, unit %d, format 0%o, event 0%o" . .SH BUGS In raw I/O .I read and .IR write (2) truncate file offsets to 512-byte block boundaries, and .I write scribbles on the tail of incomplete blocks. Thus, in programs that are likely to access raw devices, .I read, write and .IR lseek (2) should always deal in 512-byte multiples. ================================================ FILE: share/man/man4/ram.4 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)ram.4 1.2 (2.11BSD) 1996/1/27 .\" .TH RAM 4 "Januray 27, 1996" .UC 2 .SH NAME ram \- ram disk driver .SH SYNOPSIS .ft B .nf /sys/conf/SYSTEM: NRAM \fIram_size\fP # RAM disk size (512-byte blocks) major device number(s): block: 3 minor device encoding: must be zero (0) .fi .ft R .SH DESCRIPTION The .I ram pseudo-device provides a very fast extended memory store. It's use is intended for file systems like .I /tmp and applications which need to access a reasonably large amount of data quickly. .PP The amount of memory dedicated to the ram device is controlled by the NRAM definition in units of 512-byte blocks. This is also patchable in the system binary through the variable .IR ram_size (though a patched system would have to be rebooted before any change took effect; see .IR adb (1)). This makes it easy to test the effects of different ram disk sizes on system performance. It's important to note that any space given to the ram device is permanently allocated at system boot time. Dedicating too much memory can adversely affect system performance by forcing the system to swap heavily as in a memory poor environment. .PP The block file accesses the ram disk via the system's buffering mechanism through a buffer sharing arrangement with the buffer cache. It may be read and written without regard to physical disk records. There is no `raw' interface since no speed advantage is gained by such an interface with the ram disk. .SH "DISK SUPPORT" The .I ram driver does not support pseudo-disks (partitions). The special files refer to the entire `drive' as a single sequentially addressed file. .PP A typical use for the ram disk would be to mount .I /tmp on it. Note that if this arrangement is recorded in .I /etc/fstab then .I /etc/rc will have to be modified slightly to do a .IR mkfs (8) on the ram disk .B before the standard file system checks are done. .SH FILES .ta \w'/dev/MAKEDEV.local 'u /dev/ram block file .br /dev/MAKEDEV script to create special files .br /dev/MAKEDEV.local script to localize special files .DT .SH "SEE ALSO" hk(4), ra(4), rl(4), rk(4), rp(4), rx(4), si(4), xp(4) dtab(5), autoconfig(8) .SH DIAGNOSTICS \fBram: no space\fR. There is not enough memory to allocate the space needed by the ram disk. The ram disk is disabled. Any attempts to access it will return an error. .PP \fBram: not allocated\fR. No memory was allocated to the ram disk and an attempt was made to open it. Either not enough memory was available at boot time or the kernel variable .I ram_size was set to zero. .SH BUGS The .I ram driver is only available under 2.11BSD. ================================================ FILE: share/man/man4/rk.4 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)rk.4 6.2 (Berkeley) 8/20/87 .\" .TH RK 4 "August 20, 1987" .UC 2 .SH NAME rk \- RK-11/RK05 disk .SH SYNOPSIS .ft B .nf /sys/conf/SYSTEM: NRK \fIrk_drives\fP # RK05 /etc/dtab: .ta .5i +\w'#Name 'u +\w'Unit# 'u +\w'177777 'u +\w'Vector 'u +\w'Br 'u +\w'xxxxxxx 'u +\w'xxxxxxx 'u #Name Unit# Addr Vector Br Handler(s) # Comments rk ? 177400 220 5 rkintr # rk05 .DT major device number(s): raw: 15 block: 6 minor device encoding: specifies drive: .fi .ft R .SH DESCRIPTION Minor device numbers are drive numbers on one controller. The standard device names begin with ``rk'' followed by the drive number and then the letter "h". The character ? stands here for a drive number in the range 0-7. .PP The block files access the disk via the system's normal buffering mechanism and may be read and written without regard to physical disk records. There is also a `raw' interface which provides for direct transmission between the disk and the user's read or write buffer. A single read or write call results in exactly one I/O operation and therefore raw I/O is considerably more efficient when many words are transmitted. The names of the raw files conventionally begin with an extra `r.' .PP In raw I/O the buffer must begin on a word (even) boundary, and counts should be a multiple of 512 bytes (a disk sector). Likewise .I seek calls should specify a multiple of 512 bytes. .SH "DISK SUPPORT" The .I rk driver does not support pseudo-disks (partitions). Each file .I rk?h refers to the entire drive as a single sequentially addressed file. Each drive has 4872 512-byte blocks. .PP It's not clear what one would do with one of these drives if one had one ... .SH FILES .ta \w'/dev/MAKEDEV.local 'u /dev/rk[0-7]h block files .br /dev/rrk[0-7]h raw files .br /dev/MAKEDEV script to create special files .br /dev/MAKEDEV.local script to localize special files .DT .SH "SEE ALSO" hk(4), ra(4), ram(4), rl(4), rp(4), rx(4), si(4), xp(4), dtab(5), autoconfig(8) .SH DIAGNOSTICS \fBrk%d: hard error sn%d er=%b ds=%b\fR. An unrecoverable error occurred during transfer of the specified sector of the specified disk. The contents of the two error registers are also printed in octal and symbolically with bits decoded. The error was either unrecoverable, or a large number of retry attempts could not recover the error. .PP \fBrk%d: write locked\fR. The write protect switch was set on the drive when a write was attempted. The write operation is not recoverable. .SH BUGS In raw I/O .I read and .IR write (2) truncate file offsets to 512-byte block boundaries, and .I write scribbles on the tail of incomplete blocks. Thus, in programs that are likely to access raw devices, .I read, write and .IR lseek (2) should always deal in 512-byte multiples. .PP DEC-standard error logging should be supported. .PP A program to analyze the logged error information (even in its present reduced form) is needed. ================================================ FILE: share/man/man4/rl.4 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)rl.4 6.2.1 (2.11BSD) 1995/06/17 .\" .TH RL 4 "August 20, 1987" .UC 2 .SH NAME rl \- RL-11/RL01, RL02 moving-head disk .SH SYNOPSIS .ft B .nf /sys/conf/SYSTEM: NRL \fIrl_drives\fP # RL01/02 /etc/dtab: .ta .5i +\w'#Name 'u +\w'Unit# 'u +\w'177777 'u +\w'Vector 'u +\w'Br 'u +\w'xxxxxxx 'u +\w'xxxxxxx 'u #Name Unit# Addr Vector Br Handler(s) # Comments rl ? 174400 160 5 rlintr # rl-01/02 .DT major device number(s): raw: 16 block: 7 minor device encoding: bits 0007 specify partition of RL drive bits 0070 specify RL drive .fi .ft R .SH DESCRIPTION The block files access the disk via the system's normal buffering mechanism and may be read and written without regard to physical disk records. There is also a `raw' interface which provides for direct transmission between the disk and the user's read or write buffer. A single read or write call results in exactly one I/O operation and therefore raw I/O is considerably more efficient when many words are transmitted. The names of the raw files conventionally begin with an extra `r.' .PP In raw I/O the buffer must begin on a word (even) boundary, and counts should be a multiple of 512 bytes (a disk sector). Likewise .I seek calls should specify a multiple of 512 bytes. .SH "DISK SUPPORT" The RL01 drives are each 10240 blocks long and the RL02 drives are 20480 blocks long. .PP On a RL02 there is room for a full sized root ('a') partition and a reasonable sized swap ('b') partition. The RL01 can only (realistically) have a single 5mb partition. .SH FILES .ta \w'/dev/MAKEDEV.local 'u /dev/rl[0-3][a-h] block files .br /dev/rrl[0-3][a-h] raw files .br /dev/MAKEDEV script to create special files .br /dev/MAKEDEV.local script to localize special files .DT .SH "SEE ALSO" hk(4), ra(4), ram(4), rk(4), rp(4), rx(4), si(4), xp(4), dtab(5), autoconfig(8) .SH DIAGNOSTICS \fBrl%d: hard error sn%d cs=%b da=%b\fR. An unrecoverable error occurred during transfer of the specified sector of the specified disk. The contents of the two error registers are also printed in octal and symbolically with bits decoded. The error was either unrecoverable, or a large number of retry attempts could not recover the error. .PP \fBrl%d: hard error sn%d mp=%b da=%b\fR. An unrecoverable drive error occured during transfer of the specified sector of the specified disk. The contents of the two error registers are also printed in octal and symbolically with bits decoded. The error was either unrecoverable, or a large number of retry attempts could not recover the error. .PP \fBrl%d: write locked\fR. The write protect switch was set on the drive when a write was attempted. The write operation is not recoverable. .PP \fBrl%d: can't get status\fR. A ``get status'' command on the specified drive failed. The error is unrecoverable. .SH BUGS In raw I/O .I read and .IR write (2) truncate file offsets to 512-byte block boundaries, and .I write scribbles on the tail of incomplete blocks. Thus, in programs that are likely to access raw devices, .I read, write and .IR lseek (2) should always deal in 512-byte multiples. .PP DEC-standard error logging should be supported. .PP A program to analyze the logged error information (even in its present reduced form) is needed. ================================================ FILE: share/man/man4/rx.4 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)rx.4 6.2.1 (2.11BSD) 1996/1/27 .\" .TH RX 4 "January 27, 1996" .UC 2 .SH NAME rx \- DEC RX02 floppy disk .SH SYNOPSIS .ft B .nf /sys/conf/SYSTEM: NRX \fIrx_units\fP # RX02 /etc/dtab: .ta .5i +\w'#Name 'u +\w'Unit# 'u +\w'177777 'u +\w'Vector 'u +\w'Br 'u +\w'xxxxxxx 'u +\w'xxxxxxx 'u #Name Unit# Addr Vector Br Handler(s) # Comments rx ? 177170 264 5 rxintr # rx02 .DT major device number(s): raw: 17 block: 8 minor device encoding: bit 01 specifies drive: bit 02 specifies density: single: 0, double: 1 .fi .ft R .SH DESCRIPTION The .I rx device provides access to a DEC RX02 floppy disk unit with M8256 interface module (RX211 configuration). The RX02 uses 8-inch, single-sided, soft-sectored floppy disks (with pre-formatted industry-standard headers) in either single or double density. .PP Floppy disks handled by the RX02 contain 77 tracks, each with 26 sectors (for a total of 2,002 sectors). The sector size is 128 bytes for single density, 256 bytes for double density. Single density disks are compatible with the RX01 floppy disk unit and with IBM 3740 Series Diskette 1 systems. .PP Files with minor device numbers 0 and 1 refer to drives 0 and 1 in single density mode; minor devices 2 and 3 refer to drives 0 and 1 in double density mode. The standard device names begin with ``rx'' followed by the drive number and then a letter a-b for single and double density access to the drive respectively. The character ? stands here for a drive number in the range 0-1. .PP The block files access the disk via the system's normal buffering mechanism and may be read and written without regard to physical disk records. There is also a `raw' interface which provides for direct transmission between the disk and the user's read or write buffer. A single read or write call results in exactly one I/O operation and therefore raw I/O is considerably more efficient when many words are transmitted. The names of the raw files conventionally begin with an extra `r.' .PP In raw I/O the buffer must begin on a word (even) boundary, and counts should be a multiple of the disk's sector size (either 128 or 256 bytes depending on selected density.) Likewise .I seek calls should specify a multiple of the disk's sector size. .PP In addition to normal (`block' and `raw') i/o, the driver supports formatting of disks for either density. .SH "DISK SUPPORT" The .I rx driver does not support pseudo-disks (partitions). Each file .I rx?[ab] refers to the entire drive as a single sequentially addressed file. The physical disk sector size is 128 bytes for single density and 256 bytes for double density. The logical block size is 1024 bytes. Each diskette has 250 logical blocks in single density and 500 logical blocks in double density. .PP The size and density of the disks are specified as follows: .PP .nf .ta .5i +\w'rx00 'u +\w'minor device 'u +\w'unit 'u disk minor device unit density rx0a 0 0 single rx1a 1 1 single rx0b 2 0 double rx1b 3 1 double .DT .fi .PP Even though the storage capacity on a floppy disk is quite small, it is possible to make file systems on them. For example, the commands .nf .RS % rxformat /dev/rrx0a % newfs /dev/rrx0a .RE and .RS % rxformat /dev/rrx1b % newfs /dev/rrx1b .RE .fi format and make file systems on the single density disk in the left drive and the double density disk in the right drive with 241 and 486 kbytes available, respectively, for file storage. Using .IR tar (1) gives somewhat more efficient utilization of the available space for file storage. The RX02 disks are primarily useful for small archives and transfer of small systems or distributions. .PP An .IR ioctl (2) call is available is available to format RX02 disks: .RS .nf .ft B #include ioctl(fildes, RXIOC_FORMAT) .ft R .fi .RE The density is determined by the device opened. .SH FILES .ta \w'/dev/MAKEDEV.local 'u /dev/rx[01][ab] block files .br /dev/rrx[01][ab] raw files .br /dev/MAKEDEV script to create special files .br /dev/MAKEDEV.local script to localize special files .DT .SH "SEE ALSO" hk(4), ra(4), ram(4), rk(4), rl(4), rp(4), si(4), xp(4), dtab(5), autoconfig(8), rxformat(8V) .SH DIAGNOSTICS \fBrx2%d: hard error sn%d cs=%b er=%b\fR. An unrecoverable error occurred during transfer of the specified sector of the specified disk. The contents of the two error registers are also printed in octal and symbolically with bits decoded. The error was either unrecoverable, or a large number of retry attempts could not recover the error. .SH BUGS In raw I/O .I read and .IR write (2) truncate file offsets to disk sector size block boundaries (either 128 or 256 bytes depending on the selected density), and .I write scribbles on the tail of incomplete blocks. Thus, in programs that are likely to access raw devices, .I read, write and .IR lseek (2) should always deal in disk sector size multiples. .PP DEC-standard error logging should be supported. .PP A program to analyze the logged error information (even in its present reduced form) is needed. .PP The 4.3BSD rx driver which supports more capabilities should be ported to 2.11BSD. ================================================ FILE: share/man/man4/si.4 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)si.4 6.2 (Berkeley) 8/20/87 .\" .TH SI 4 "August 20, 1987" .UC 2 .SH NAME si \- SI 9500/CDC 9766 moving head disk .SH SYNOPSIS .ft B .nf /sys/conf/SYSTEM: NSI \fIsi_drives\fP # SI 9500 driver for CDC 9766 disks /etc/dtab: .ta .5i +\w'#Name 'u +\w'Unit# 'u +\w'177777 'u +\w'Vector 'u +\w'Br 'u +\w'xxxxxxx 'u +\w'xxxxxxx 'u #Name Unit# Addr Vector Br Handler(s) # Comments si ? 176700 170 5 siintr # si9500 .DT major device number(s): raw: 18 block: 9 minor device encoding: bits 0007 specify partition of SI drive bits 0070 specify SI drive .fi .ft R .SH DESCRIPTION Files with minor device numbers 0 through 7 refer to various portions of drive 0; minor devices 8 through 15 refer to drive 1, etc. The standard device names begin with ``si'' followed by the drive number and then a letter a-h for partitions 0-7 respectively. The character ? stands here for a drive number in the range 0-7. .PP The block files access the disk via the system's normal buffering mechanism and may be read and written without regard to physical disk records. There is also a `raw' interface which provides for direct transmission between the disk and the user's read or write buffer. A single read or write call results in exactly one I/O operation and therefore raw I/O is considerably more efficient when many words are transmitted. The names of the raw files conventionally begin with an extra `r.' .PP In raw I/O the buffer must begin on a word (even) boundary, and counts should be a multiple of 512 bytes (a disk sector). Likewise .I seek calls should specify a multiple of 512 bytes. .SH "DISK SUPPORT" The origin and size (in sectors) of the pseudo-disks on each drive are as follows: .PP .nf .ta .5i +\w'disk 'u +\w'000000 'u +\w'000000 'u +\w'000 - 000 'u .ne 10 SI 9500/CDC9766 partitions: disk start length cyls comments xp?a 0 9120 0 - 14 / xp?b 9120 9120 15 - 29 swap xp?c 18240 234080 30 - 414 xp?d 252320 247906 415 - 822* xp?e 18240 164160 30 - 299 /usr xp?f 182400 152000 300 - 549 xp?g 334400 165826 550 - 822* xp?h 0 500384 0 - 822 whole pack .PP .DT .fi .PP Those partitions marked with an asterisk (``*'') actually stop short of the indicated ending cylinder to protect any bad block forwarding information on the packs. The indicated lengths are correct. Partition ``h'' must be used to access the bad block forwarding area. .B N.B.: the .I si driver does not support bad block forwarding; the space is reserved in the event bad block forwarding is ever added to the driver. .SH FILES .ta \w'/dev/MAKEDEV.local 'u /dev/si[0-7][a-h] block files .br /dev/rsi[0-7][a-h] raw files .br /dev/MAKEDEV script to create special files .br /dev/MAKEDEV.local script to localize special files .SH SEE ALSO hk(4), ra(4), ram(4), rk(4), rl(4), rp(4), rx(4), xp(4), dtab(5), autoconfig(8) .SH DIAGNOSTICS \fBsi%d%c: hard error sn%d cnr=%b err=%b\fR. An unrecoverable error occurred during transfer of the specified sector of the specified disk partition. The contents of the two error registers are also printed in octal and symbolically with bits decoded. The error was either unrecoverable, or a large number of retry attempts (including offset positioning and drive recalibration) could not recover the error. .PP \fBsi%d%c: hard error sn%d ssr=%b err=%b\fR. An unrecoverable error occurred during transfer of the specified sector of the specified disk partition. The contents of the two error registers are also printed in octal and symbolically with bits decoded. The error was either unrecoverable, or a large number of retry attempts (including offset positioning and drive recalibration) could not recover the error. .SH BUGS In raw I/O .I read and .IR write (2) truncate file offsets to 512-byte block boundaries, and .I write scribbles on the tail of incomplete blocks. Thus, in programs that are likely to access raw devices, .I read, write and .IR lseek (2) should always deal in 512-byte multiples. .PP The partition tables for the file systems should be read off of each pack, as they are never quite what any single installation would prefer, and this would make packs more portable. ================================================ FILE: share/man/man4/spp.4 ================================================ .\" Copyright (c) 1985 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)spp.4p 1.2 (Berkeley) 9/17/85 .\" .TH SPP 4P "July 30, 1985" .UC 6 .SH NAME spp \- Xerox Sequenced Packet Protocol .SH SYNOPSIS .B #include .br .B #include .br .B s = socket(AF_NS, SOCK_STREAM, 0); .PP .B #include .br .B s = socket(AF_NS, SOCK_SEQPACKET, 0); .SH DESCRIPTION The SPP protocol provides reliable, flow-controlled, two-way transmission of data. It is a byte-stream protocol used to support the SOCK_STREAM abstraction. SPP uses the standard NS(tm) address formats. .PP Sockets utilizing the SPP protocol are either \*(lqactive\*(rq or \*(lqpassive\*(rq. Active sockets initiate connections to passive sockets. By default SPP sockets are created active; to create a passive socket the .IR listen (2) system call must be used after binding the socket with the .IR bind (2) system call. Only passive sockets may use the .IR accept (2) call to accept incoming connections. Only active sockets may use the .IR connect (2) call to initiate connections. .PP Passive sockets may \*(lqunderspecify\*(rq their location to match incoming connection requests from multiple networks. This technique, termed \*(lqwildcard addressing\*(rq, allows a single server to provide service to clients on multiple networks. To create a socket which listens on all networks, the NS address of all zeroes must be bound. The SPP port may still be specified at this time; if the port is not specified the system will assign one. Once a connection has been established the socket's address is fixed by the peer entity's location. The address assigned the socket is the address associated with the network interface through which packets are being transmitted and received. Normally this address corresponds to the peer entity's network. .LP If the SOCK_SEQPACKET socket type is specified, each packet received has the actual 12 byte sequenced packet header left for the user to inspect: .nf struct sphdr { u_char sp_cc; /* \fIconnection control\fP */ #define SP_EM 0x10 /* \fIend of message\fP */ u_char sp_dt; /* \fIdatastream type\fP */ u_short sp_sid; u_short sp_did; u_short sp_seq; u_short sp_ack; u_short sp_alo; }; .fi This facilitates the implementation of higher level Xerox protocols which make use of the data stream type field and the end of message bit. Conversely, the user is required to supply a 12 byte header, the only part of which inspected is the data stream type and end of message fields. .LP For either socket type, packets received with the Attention bit sent are interpreted as out of band data. Data sent with send(..., ..., ..., MSG_OOB) cause the attention bit to be set. .SH DIAGNOSTICS A socket operation may fail with one of the following errors returned: .TP 20 [EISCONN] when trying to establish a connection on a socket which already has one; .TP 20 [ENOBUFS] when the system runs out of memory for an internal data structure; .TP 20 [ETIMEDOUT] when a connection was dropped due to excessive retransmissions; .TP 20 [ECONNRESET] when the remote peer forces the connection to be closed; .TP 20 [ECONNREFUSED] when the remote peer actively refuses connection establishment (usually because no process is listening to the port); .TP 20 [EADDRINUSE] when an attempt is made to create a socket with a port which has already been allocated; .TP 20 [EADDRNOTAVAIL] when an attempt is made to create a socket with a network address for which no network interface exists. .SH SOCKET OPTIONS .TP 20 SO_DEFAULT_HEADERS when set, this determines the data stream type and whether the end of message bit is to be set on every ensuing packet. .TP 20 SO_MTU This specifies the maximum ammount of user data in a single packet. The default is 576 bytes - sizeof(struct spidp). This quantity affects windowing -- increasing it without increasing the amount of buffering in the socket will lower the number of unread packets accepted. Anything larger than the default will not be forwarded by a bona fide XEROX product internetwork router. The data argument for the setsockopt call must be an unsigned short. .SH SEE ALSO intro(4N), ns(4F) .SH BUGS There should be some way to reflect record boundaries in a stream. For stream mode, there should be an option to get the data stream type of the record the user process is about to receive. ================================================ FILE: share/man/man4/sri.4 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)sri.4 6.4 (Berkeley) 8/20/87 .\" .TH SRI 4 "August 20, 1987" .UC 2 .SH NAME sri \- DR11-C IMP interface .SH SYNOPSIS .ft B .nf /sys/conf/SYSTEM: NSRI \fIsri_controllers\fP # SRI DR11c ARPAnet IMP .fi .ft R .SH DESCRIPTION .SH DIAGNOSTICS .BR "sri%d: not alive" . The initialization routine was entered even though the device did not autoconfigure. This indicates a system problem. .PP .BR "sri%d: can't initialize" . Insufficient UNIBUS resources existed to initialize the device. This is likely to occur when the device is run on a buffered data path on an 11/750 and other network interfaces are also configured to use buffered data paths, or when it is configured to use buffered data paths on an 11/730 (which has none). .PP .BR "sri%d: imp doesn't respond, ibf=%b" . The driver attempted to initialize the device, but the IMP failed to respond after 5 tries. Check the cabling. .PP .BR "sri%d: stray xmit interrupt, csr=%b" . An interrupt occurred when no output had previously been started. .PP .BR "sri%d: output error, csr=%b" . The device indicated a problem sending data on output. .PP .BR "sri%d: input error, ibf=%b" . The device indicated a problem receiving data on input. .PP .BR "sri%d: bad length=%d" . An input operation resulted in a data transfer of less than 10 or more than 1008 bytes of data into memory (according to the word count register). This should never happen as the maximum size of a host-IMP message is 1018 bytes. ================================================ FILE: share/man/man4/swap.4 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)swap.4 6.2 (Berkeley) 1/28/88 .\" .TH SWAP 4 "January 28, 1988" .UC 2 .SH NAME swap \- swap device .SH DESCRIPTION This file refers to the swap device in use by the system. It should be linked to the special file for the disk or disk partition on which the system swaps. It is used by programs that wish to read from the swap device without knowing its real name. The script .I /dev/MAKEDEV.local normally is edited by the system builder to set .I /dev/swap up correctly. .SH FILES .ta \w'/dev/MAKEDEV.local 'u /dev/swap .br /dev/MAKEDEV script to create special files .br /dev/MAKEDEV.local script to localize special files .DT .SH "SEE ALSO" ps(1), w(1) ================================================ FILE: share/man/man4/tb.4 ================================================ .\" Copyright (c) 1986 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)tb.4 6.3 (Berkeley) 8/1/87 .\" .TH TB 4 "August 1, 1987" .UC 2 .SH NAME tb \- line discipline for digitizing devices .SH SYNOPSIS .ft B .nf /sys/conf/SYSTEM: NTB \fI1\fP # RS232 interface for Genisco/Hitachi tablets .fi .ft R .SH DESCRIPTION This line discipline provides a polled interface to many common digitizing devices which are connected to a host through a serial line. When these devices stream data at high speed, the use of the line discipline is critical in minimizing the number of samples that would otherwise be lost due to buffer exhaustion in the .IR tty (4) handler. .PP The line discipline is enabled by a sequence: .PP .nf .ft B #include int ldisc = TBLDISC, fildes; ... ioctl(fildes, TIOCSETD, &ldisc); .fi .ft R .PP A typical application program then polls the digitizing device by reading a binary data structure which contains: the current X and Y positions (in the device coordinate space), up-down status of the buttons or pen stylus, proximity information (when available), and a count of the number of samples received from the input device since it was opened. In addition, devices such as the GTCO append tilt and pressure information to the end of the aforementioned structure. For the Polhemus 3-D digitizer the structure read is completely different. Refer to the include file for a complete description. .PP While in tablet mode, normal teletype input and output functions take place. Thus, if an 8 bit output data path is desired, it is necessary to prepare the output line by putting it into RAW mode using .IR ioctl (2). This must be done .B before changing the discipline with TIOCSETD, as most .IR ioctl (2) calls are disabled while in tablet line-discipline mode. .PP The line discipline supports .IR ioctl (2) requests to get/set the operating mode, and to get/set the tablet type and operating mode by \fIor\fP-ing the two values together. .PP The line discipline supports digitizing devices which are compatible with Hitachi, GTCO, or Polhemus protocol formats. For Hitachi there are several formats with that used in the newer model HDG-1111B the most common. .SH "SEE ALSO" tty(4) .SH DIAGNOSTICS None. ================================================ FILE: share/man/man4/tcp.4 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)tcp.4p 6.2 (Berkeley) 5/16/86 .\" .TH TCP 4P "May 16, 1986" .UC 5 .SH NAME tcp \- Internet Transmission Control Protocol .SH SYNOPSIS .B #include .br .B #include .PP .B s = socket(AF_INET, SOCK_STREAM, 0); .SH DESCRIPTION The TCP protocol provides reliable, flow-controlled, two-way transmission of data. It is a byte-stream protocol used to support the SOCK_STREAM abstraction. TCP uses the standard Internet address format and, in addition, provides a per-host collection of \*(lqport addresses\*(rq. Thus, each address is composed of an Internet address specifying the host and network, with a specific TCP port on the host identifying the peer entity. .PP Sockets utilizing the tcp protocol are either \*(lqactive\*(rq or \*(lqpassive\*(rq. Active sockets initiate connections to passive sockets. By default TCP sockets are created active; to create a passive socket the .IR listen (2) system call must be used after binding the socket with the .IR bind (2) system call. Only passive sockets may use the .IR accept (2) call to accept incoming connections. Only active sockets may use the .IR connect (2) call to initiate connections. .PP Passive sockets may \*(lqunderspecify\*(rq their location to match incoming connection requests from multiple networks. This technique, termed \*(lqwildcard addressing\*(rq, allows a single server to provide service to clients on multiple networks. To create a socket which listens on all networks, the Internet address INADDR_ANY must be bound. The TCP port may still be specified at this time; if the port is not specified the system will assign one. Once a connection has been established the socket's address is fixed by the peer entity's location. The address assigned the socket is the address associated with the network interface through which packets are being transmitted and received. Normally this address corresponds to the peer entity's network. .PP TCP supports one socket option which is set with .IR setsockopt (2) and tested with .IR getsockopt (2). Under most circumstances, TCP sends data when it is presented; when outstanding data has not yet been acknowledged, it gathers small amounts of output to be sent in a single packet once an acknowledgement is received. For a small number of clients, such as window systems that send a stream of mouse events which receive no replies, this packetization may cause significant delays. Therefore, TCP provides a boolean option, TCP_NODELAY (from .IR , to defeat this algorithm. The option level for the .I setsockopt call is the protocol number for TCP, available from .IR getprotobyname (3N). .PP Options at the IP transport level may be used with TCP; see .IR ip (4P). Incoming connection requests that are source-routed are noted, and the reverse source route is used in responding. .SH DIAGNOSTICS A socket operation may fail with one of the following errors returned: .TP 20 [EISCONN] when trying to establish a connection on a socket which already has one; .TP 20 [ENOBUFS] when the system runs out of memory for an internal data structure; .TP 20 [ETIMEDOUT] when a connection was dropped due to excessive retransmissions; .TP 20 [ECONNRESET] when the remote peer forces the connection to be closed; .TP 20 [ECONNREFUSED] when the remote peer actively refuses connection establishment (usually because no process is listening to the port); .TP 20 [EADDRINUSE] when an attempt is made to create a socket with a port which has already been allocated; .TP 20 [EADDRNOTAVAIL] when an attempt is made to create a socket with a network address for which no network interface exists. .SH SEE ALSO getsockopt(2), socket(2), intro(4N), inet(4F), ip(4P) ================================================ FILE: share/man/man4/tm.4 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)tm.4 6.1 (Berkeley) 1/28/88 .\" .TH TM 4 "January 28, 1988" .UC 2 .SH NAME tm \- TM-11/TE-10 magtape interface .SH SYNOPSIS .ft B .nf /sys/conf/SYSTEM: .ta .5i +\w'AVIVTM 'u +\w'tm_drives 'u # Setting AVIVTM configures the TM driver for the AVIV 800/1600/6250 # controller. For more details, see /sys/pdpuba/tm.c. NTM \fItm_drives\fP # TM11 AVIVTM \fIYES\fP # AVIV 800/1600/6250 controller /etc/dtab: .ta .5i +\w'#Name 'u +\w'Unit# 'u +\w'177777 'u +\w'Vector 'u +\w'Br 'u +\w'xxxxxxx 'u +\w'xxxxxxx 'u #Name Unit# Addr Vector Br Handler(s) # Comments tm ? 172520 224 5 tmintr # tm11 driver .DT major device number(s): raw: 7 block: 1 minor device encoding: bits 0003 specify TS drive bit 0004 specifies no-rewind operation bits 0030 specify recording density: 0000: 800BPI 0010: 1600BPI (AVIVTM and some other controllers) 0020: 6250BPI (AVIVTM only) .fi .ft R .SH DESCRIPTION The tm-11/te-10 combination provides a standard tape drive interface as described in .IR mtio (4). The standard DEC tm-11 operates only at 800 bpi. Other controllers of this type may also allow operation at 1600 bpi, under software control or by switching manually. .SH FILES .ta \w'/dev/MAKEDEV.local 'u /dev/MAKEDEV script to create special files .br /dev/MAKEDEV.local script to localize special files .DT .SH "SEE ALSO" mt(1), tar(1), tp(1), mtio(4), ht(4), ts(4), mt(4), dtab(5), autoconfig(8) .SH DIAGNOSTICS \fBte%d: no write ring\fR. An attempt was made to write on the tape drive when no write ring was present; this message is written on the terminal of the user who tried to access the tape. .PP \fBte%d: not online\fR. An attempt was made to access the tape while it was offline; this message is written on the terminal of the user who tried to access the tape. .PP \fBte%d: can't change density in mid-tape\fR. An attempt was made to write on a tape at a different density than is already recorded on the tape. This message is written on the terminal of the user who tried to switch the density. .PP \fBte%d: hard error bn%d er=%b\fR. A tape error occurred at block \fIbn\fR; the tm error register is printed in octal with the bits symbolically decoded. Any error is fatal on non-raw tape; when possible the driver will have retried the operation which failed several times before reporting the error. .PP \fBte%d: lost interrupt\fR. A tape operation did not complete within a reasonable time, most likely because the tape was taken off-line during rewind or lost vacuum. The controller should, but does not, give an interrupt in these cases. The device will be made available again after this message, but any current open reference to the device will return an error as the operation in progress aborts. .SH BUGS If any non-data error is encountered on non-raw tape, it refuses to do anything more until closed. ================================================ FILE: share/man/man4/tmscp.4 ================================================ .\" Copyright (c) 1986 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)tmscp.4 1.2 (2.11BSD) 1995/12/22 .\" .TH TMSCP 4 "December 22, 1995" .UC 2 .SH NAME tmscp \- DEC TMSCP magtape interface .SH SYNOPSIS .ft B .nf /sys/conf/SYSTEM: NTMSCP 1 # TMSCP controllers NTMS 1 # TMSCP drives TMSCP_DEBUG NO # debugging code in in TMSCP drive (EXPENSIVE) /etc/dtab: .ta .5i +\w'#Name 'u +\w'Unit# 'u +\w'177777 'u +\w'Vector 'u +\w'Br 'u +\w'xxxxxxx 'u +\w'xxxxxxx 'u #Name Unit# Addr Vector Br Handler(s) # Comments tms ? 174500 260 5 tmsintr # tmscp driver tms ? 164334 0 5 tmsintr # alternate .DT major device number(s): raw: 23 block: 12 minor device encoding: bit: |7 | 6 | 5 | 4 | 3 | 2 | 1 | 0| ------------------------------- C C X D D N U U C = Controller # (max of 4 controllers) D = Density N = Norewind on close U = Unit (drive) number (max of 4 drives per controller) .fi .ft R .SH DESCRIPTION Tape controllers compatible with the DEC Tape Mass Storage Control Protocol (TMSCP) architecture such as the TU81 and the TK50 provide a standard tape drive interface as described in .IR mtio (4). The controller communicates with the host through a packet oriented protocol. Consult the file .IR < pdp/tmscp.h > for a detailed description of this protocol. .SH FILES .ta \w'/dev/MAKEDEV.local 'u /dev/MAKEDEV script to create special files .br /dev/MAKEDEV.local script to localize special files .DT .PP The vector specified in \fB/etc/dtab\fP may be given as an explicit value in which case \fIautoconfig(8)\fP will attempt to allocate the specified vector. The vector may also be (if the system is at revision level 100 or higher) given as \fB0\fP - in which case \fIautoconfig(8)\fP will request the kernel to allocate the next available vector (beginning at 01000 and proceeding downward) which \fIautoconfig(8)\fP will initialize. .PP Multiple drives on a single controller are supported. Multiple controllers are also supported. .PP Density selection is specified by bits 3 and 4 in the minor device number. A value of 0 requests the lowest density of a drive and a value of 3 the highest density. Values of 1 and 2 are essentially equivalent (because because TMSCP only defines values for three densities) and request the middle density (for tri-density tape drives). .SH DIAGNOSTICS .BR "tms: !drives" . Not enough drives were declared when the kernel was built. The NTMS parameter in the kernel config file needs to be increased by at least one. .PP .BR "tms%d stepN init failed: sa %x" . Step N of the 4 step initialization sequence has failed. .PP .BR "tms%d: random intr" . An unexpected interrupt was received. This is indicative of some other device using the same interrupt vector as the TMSCP controller. The interrupt is ignored. .PP .BR "tms%d Ver %d Mod %d" . The version and model number of the controller are displayed when the controller is initialized. This is an information message and not an error. .PP .BR "tms%d: state %d" . The controller state is not one of the 4 initialization states or the RUN state. This indicates a serious problem in the driver and possibly the hardware. .PP .BR "tms%d: fatal error %x" . The controller detected a ``fatal error'' in the status returned to the host. The contents of the status register are displayed. .PP .BR "tms%d init fail" . The controller failed to initialize. Indicative of a hardware problem. .PP .BR "tms%d,%d flush fail" . The cache failed to flush during a close operation. Data loss is possible in this case. .PP .BR "tms%d,%d: sa %x state %d" . A fatal error. The controller will be reset in an attempt to resume operation. .PP .BR "tms ioctl" . An invalid internal ioctl function call has been made. This is a driver bug. .PP .BR "tms%d,%d inv end" . An invalid end (completion) code has been detected. A drive has returned 0 as the opcode originally issued. This is a hardware problem. .PP .BR "tms%d,%d bad rsp: %x" . An unrecognized response has been received. This is a driver bug. .PP .BR "tms%d,%d cache lost" The cache on the drive has been lost. Data loss is likely. Usually due to a hardware problem. .PP The following error is produced when a TMSCP error log datagram is received: .sp .BR "tms%d,%d dgram fmt=%x evt=%x grp=%x flg=%x pos=%D" . .PP Earlier versions of the driver consumed a noticeable amount of kernel D-space decoding and pretty printing more detailed information. This has been removed in favor of a shorter message. In the future an error log daemon will be written and the datagrams from the MSCP and TMSCP drivers passed to it for analysis. .SH "SEE ALSO" mt(1), tar(1), tp(1), mtio(4), tm(4), ts(4), ut(4), dmesg(8), dtab(5), autoconfig(8) .SH BUGS If any non-data error is encountered on non-raw tape, it refuses to do anything more until closed. .PP On quad-density tape drives (the Kennedy 9662 for example) the middle density of 3200bpi is not host selectable (it can be manually selected from the drive's front panel) because TMSCP only defines 800, 1600 and 6250bpi. ================================================ FILE: share/man/man4/ts.4 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)ts.4 6.1 (Berkeley) 1/28/88 .\" .TH TS 4 "January 28, 1988" .UC 2 .SH NAME ts \- TS-11 magtape interface .SH SYNOPSIS .ft B .nf /sys/conf/SYSTEM: NTS \fIts_drives\fP # TS11 /etc/dtab: .ta .5i +\w'#Name 'u +\w'Unit# 'u +\w'177777 'u +\w'Vector 'u +\w'Br 'u +\w'xxxxxxx 'u +\w'xxxxxxx 'u #Name Unit# Addr Vector Br Handler(s) # Comments ts ? 172520 224 5 tsintr # ts11 driver .DT major device number(s): raw: 8 block: 2 minor device encoding: bits 0003 specify TS drive bit 0004 specifies no-rewind operation bit 0010 ignored .fi .ft R .SH DESCRIPTION The ts-11 combination provides a standard tape drive interface as described in .IR mtio (4). The ts-11 operates only at 1600 bpi, and only one transport is possible per controller. .SH FILES .ta \w'/dev/MAKEDEV.local 'u /dev/MAKEDEV script to create special files .br /dev/MAKEDEV.local script to localize special files .DT .SH "SEE ALSO" mt(1), tar(1), tp(1), mtio(4), ht(4), tm(4), dtab(5), autoconfig(8) .SH DIAGNOSTICS \fBts%d: no write ring\fR. An attempt was made to write on the tape drive when no write ring was present; this message is written on the terminal of the user who tried to access the tape. .PP \fBts%d: not online\fR. An attempt was made to access the tape while it was offline; this message is written on the terminal of the user who tried to access the tape. .PP \fBts%d: hard error bn%d xs0=%b xs1=%b xs2=%b xs3=%b\fR. A hard error occurred on the tape at block \fIbn\fR; status registers 0-3 are printed in octal and symbolically decoded as bits. .PP \fBts%d: addr mod 4 != 0\fR. The address of a TS-11 command packet was not on an even longword boundary. .SH BUGS If any non-data error is encountered on non-raw tape, it refuses to do anything more until closed. .PP The device lives at the same address as a tm-11 .IR tm (4). ================================================ FILE: share/man/man4/tty.4 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)tty.4 6.7.2 (2.11BSD GTE) 1997/4/10 .\" .TH TTY 4 "April 10, 1997" .UC 4 .SH NAME tty \- general terminal interface .SH SYNOPSIS .B #include .SH DESCRIPTION This section describes both a particular special file .B /dev/tty and the terminal drivers used for conversational computing. .LP .B Line disciplines. .PP The system provides different .I "line disciplines" for controlling communications lines. In this version of the system there are two disciplines available for use with terminals: .IP "old" 8 The old (Version 7) terminal driver. This is sometimes used when using the standard shell .IR sh (1). .IP "new" The standard Berkeley terminal driver, with features for job control; this must be used when using .IR csh (1). .LP Line discipline switching is accomplished with the TIOCSETD .IR ioctl : .IP .B "int ldisc = LDISC;" .br .B "ioctl(f, TIOCSETD, &ldisc);" .LP where LDISC is OTTYDISC for the standard tty driver and NTTYDISC for the ``new'' driver. The standard (currently old) tty driver is discipline 0 by convention. Other disciplines may exist for special purposes, such as use of communications lines for network connections. The current line discipline can be obtained with the TIOCGETD .IR ioctl . Pending input is discarded when the line discipline is changed. .PP All of the low-speed asynchronous communications ports can use any of the available line disciplines, no matter what hardware is involved. The remainder of this section discusses the \*(lqold\*(rq and \*(lqnew\*(rq disciplines. .LP .B "The control terminal." .LP When a terminal file is opened, it causes the process to wait until a connection is established. In practice, user programs seldom open these files; they are opened by .IR getty (8) or .IR rlogind (8C) and become a user's standard input and output file. .PP If a process which has no control terminal opens a terminal file, then that terminal file becomes the control terminal for that process. The control terminal is thereafter inherited by a child process during a .IR fork (2), even if the control terminal is closed. .LP The file .B /dev/tty is, in each process, a synonym for a .I "control terminal" associated with that process. It is useful for programs that wish to be sure of writing messages on the terminal no matter how output has been redirected. It can also be used for programs that demand a file name for output, when typed output is desired and it is tiresome to find out which terminal is currently in use. .LP A process can remove the association it has with its controlling terminal by opening the file .B /dev/tty and issuing an .IP .B "ioctl(f, TIOCNOTTY, 0);" .LP This is often desirable in server processes. .LP .B "Process groups." .LP Command processors such as .IR csh (1) can arbitrate the terminal between different .I jobs by placing related jobs in a single process group and associating this process group with the terminal. A terminal's associated process group may be set using the TIOCSPGRP .IR ioctl (2): .IP .B "ioctl(fildes, TIOCSPGRP, &pgrp);" .LP or examined using TIOCGPGRP, which returns the current process group in .IR pgrp . The new terminal driver aids in this arbitration by restricting access to the terminal by processes which are not in the current process group; see .B "Job access control" below. .LP .B "Modes." .PP The terminal drivers have three major modes, characterized by the amount of processing on the input and output characters: .IP cooked 10 The normal mode. In this mode lines of input are collected and input editing is done. The edited line is made available when it is completed by a newline, or when the \fIt_brkc\fP character (normally undefined) or \fIt_eofc\fP character (normally an EOT, control-D, hereafter ^D) is entered. A carriage return is usually made synonymous with newline in this mode, and replaced with a newline whenever it is typed. All driver functions (input editing, interrupt generation, output processing such as tab expansion, etc.) are available in this mode. .IP CBREAK 10 This mode eliminates the character, word, and line editing input facilities, making the input character available to the user program as it is typed. Flow control, literal-next and interrupt processing are still done in this mode. Output processing is done. .IP RAW 10 This mode eliminates all input processing and makes all input characters available as they are typed; no output processing is done either. .PP The style of input processing can also be very different when the terminal is put in non-blocking I/O mode; see the FNDELAY flag described in .IR fcntl (2). In this case a .IR read (2) from the control terminal will never block, but rather return an error indication (EWOULDBLOCK) if there is no input available. .PP A process may also request that a SIGIO signal be sent it whenever input is present and also whenever output queues fall below the low-water mark. To enable this mode the FASYNC flag should be set using .IR fcntl (2). .LP .B "Input editing." .LP A UNIX terminal ordinarily operates in full-duplex mode. Characters may be typed at any time, even while output is occurring, and are only lost when the system's character input buffers become completely choked, which is rare, or when the user has accumulated the maximum allowed number of input characters that have not yet been read by some program. Currently this limit is 256 characters. In RAW mode, the terminal driver throws away all input and output without notice when the limit is reached. In CBREAK or cooked mode it refuses to accept any further input and, if in the new line discipline, rings the terminal bell. .PP Input characters are normally accepted in either even or odd parity with the parity bit being stripped off before the character is given to the program. By clearing either the EVEN or ODD bit in the flags word it is possible to have input characters with that parity discarded (see the \fBSummary\fR below.) .PP In all of the line disciplines, it is possible to simulate terminal input using the TIOCSTI .IR ioctl , which takes, as its third argument, the address of a character. The system pretends that this character was typed on the argument terminal, which must be the control terminal except for the super-user (this call is not in standard version 7 UNIX). .PP Input characters are normally echoed by putting them in an output queue as they arrive. This may be disabled by clearing the ECHO bit in the flags word using the .IR stty (3C) call or the TIOCSETN or TIOCSETP .IR ioctl s (see the \fBSummary\fR below). .PP In cooked mode, terminal input is processed in units of lines. A program attempting to read will normally be suspended until an entire line has been received (but see the description of SIGTTIN in \fBJob access control\fR and of FIONREAD in \fBSummary\fR, both below.) No matter how many characters are requested in the read call, at most one line will be returned. It is not, however, necessary to read a whole line at once; any number of characters may be requested in a read, even one, without losing information. .PP During input, line editing is normally done, with the erase character .I sg_erase (by default, DELETE) logically erasing the last character typed and the .I sg_kill character (default, ^U: control-U) logically erasing the entire current input line. These characters never erase beyond the beginning of the current input line or an eof. .PP The drivers normally treat either a carriage return or a newline character as terminating an input line, replacing the return with a newline and echoing a return and a line feed. If the CRMOD bit is cleared in the local mode word then the processing for carriage return is disabled, and it is simply echoed as a return, and does not terminate cooked mode input. .PP In the new driver there is a literal-next character (normally ^V) which can be typed in both cooked and CBREAK mode preceding .I any character to prevent its special meaning to the terminal handler. .PP The new terminal driver also provides two other editing characters in normal mode. The word-erase character, normally ^W, erases the preceding word, but not any spaces before it. For the purposes of ^W, a word is defined as a sequence of non-blank characters, with tabs counted as blanks. Finally, the reprint character, normally ^R, retypes the pending input beginning on a new line. Retyping occurs automatically in cooked mode if characters which would normally be erased from the screen are fouled by program output. .LP .B "Input echoing and redisplay" .LP The terminal driver has several modes for handling the echoing of terminal input, controlled by bits in a local mode word. .LP .I "Hardcopy terminals." When a hardcopy terminal is in use, the LPRTERA bit is normally set in the local mode word. Characters which are logically erased are then printed out backwards preceded by `\e\|' and followed by `/' in this mode. .LP .I "CRT terminals." When a CRT terminal is in use, the LCRTBS bit is normally set in the local mode word. The terminal driver then echoes the proper number of erase characters when input is erased; in the normal case where the erase character is a ^H this causes the cursor of the terminal to back up to where it was before the logically erased character was typed. If the input has become fouled due to interspersed asynchronous output, the input is automatically retyped. .LP .I "Erasing characters from a CRT." When a CRT terminal is in use, the LCRTERA bit may be set to cause input to be erased from the screen with a \*(lqbackspace-space-backspace\*(rq sequence when character or word deleting sequences are used. A LCRTKIL bit may be set as well, causing the input to be erased in this manner on line kill sequences as well. .LP .I "Echoing of control characters." If the LCTLECH bit is set in the local state word, then non-printing (control) characters are normally echoed as ^X (for some X) rather than being echoed unmodified; delete is echoed as ^?. .LP The normal modes for use on CRT terminals are speed dependent. At speeds less than 1200 baud, the LCRTERA and LCRTKILL processing is painfully slow, and .IR stty (1) normally just sets LCRTBS and LCTLECH; at speeds of 1200 baud or greater all of these bits are normally set. .IR Stty (1) summarizes these option settings and the use of the new terminal driver as \*(lqnewcrt.\*(rq .LP .B "Output processing." .PP When one or more characters are written, they are actually transmitted to the terminal as soon as previously-written characters have finished typing. (As noted above, input characters are normally echoed by putting them in the output queue as they arrive.) When a process produces characters more rapidly than they can be typed, it will be suspended when its output queue exceeds some limit. When the queue has drained down to some threshold the program is resumed. Even parity is normally generated on output. The EOT character is not transmitted in cooked mode to prevent terminals that respond to it from hanging up; programs using RAW or CBREAK mode should be careful. .PP The terminal drivers provide necessary processing for cooked and CBREAK mode output including parity generation. The driver will also optionally expand tabs into spaces, where the tab stops are assumed to be set every eight columns, and optionally convert newlines to carriage returns followed by newline. These functions are controlled by bits in the tty flags word; see \fBSummary\fR below. .PP Finally, in the new terminal driver, there is a output flush character, normally ^O, which sets the LFLUSHO bit in the local mode word, causing subsequent output to be flushed until it is cleared by a program or more input is typed. This character has effect in both cooked and CBREAK modes and causes pending input to be retyped if there is any pending input. An .I ioctl to flush the characters in the input or output queues, TIOCFLUSH, is also available. .LP .B "Flow control." .PP There are two characters (the stop character, normally ^S, and the start character, normally ^Q) which cause output to be suspended and resumed respectively. Extra stop characters typed when output is already stopped have no effect, unless the start and stop characters are made the same, in which case output resumes. .PP A bit in the flags word may be set to put the terminal into TANDEM mode. In this mode the system produces a stop character (default ^S) when the input queue is in danger of overflowing, and a start character (default ^Q) when the input has drained sufficiently. This mode is useful when the terminal is actually another machine that obeys those conventions. .PP If software flow control is not sufficient (it begins failing above 4800 bits per second on slow systems) RTS/CTS flow control is now available. Hardware flow control causes RTS to be dropped when the remote system (modem) should cease sending and to be raised when additional data can be accepted. If the remote system drops CTS then the local host ceases sending data until the CTS is raised. Hardware flow control is enabled via the \fBTIOCLBIS\fP (or TIOCLBIC or TIOCLSET) function and the bit \fBLRTSCTS\fP. .LP .B "Line control and breaks." .LP There are several .I ioctl calls available to control the state of the terminal line. The TIOCSBRK .I ioctl will set the break bit in the hardware interface causing a break condition to exist; this can be cleared (usually after a delay with .IR sleep (3)) by TIOCCBRK. Break conditions in the input are reflected as a null character in RAW mode or as the interrupt character in cooked or CBREAK mode. The TIOCCDTR .I ioctl will clear the data terminal ready condition; it can be set again by TIOCSDTR. .PP When the carrier signal from the dataset drops (usually because the user has hung up his terminal) a SIGHUP hangup signal is sent to the processes in the distinguished process group of the terminal; this usually causes them to terminate. The SIGHUP can be suppressed by setting the LNOHANG bit in the local state word of the driver. Access to the terminal by other processes is then normally revoked, so any further reads will fail, and programs that read a terminal and test for end-of-file on their input will terminate appropriately. .PP It is possible to ask that the phone line be hung up on the last close with the TIOCHPCL .IR ioctl ; this is normally done on the outgoing lines and dialups. .LP .B "Interrupt characters." .PP There are several characters that generate interrupts in cooked and CBREAK mode; all are sent to the processes in the control group of the terminal, as if a TIOCGPGRP .I ioctl were done to get the process group and then a .IR killpg (2) system call were done, except that these characters also flush pending input and output when typed at a terminal (\fI\z'a\`'la\fR TIOCFLUSH). The characters shown here are the defaults; the field names in the structures (given below) are also shown. The characters may be changed. .IP ^C \fBt_intrc\fR (ETX) generates a SIGINT signal. This is the normal way to stop a process which is no longer interesting, or to regain control in an interactive program. .IP ^\e \fBt_quitc\fR (FS) generates a SIGQUIT signal. This is used to cause a program to terminate and produce a core image, if possible, in the file .B core in the current directory. .IP ^Z \fBt_suspc\fR (EM) generates a SIGTSTP signal, which is used to suspend the current process group. .IP ^Y \fBt_dsuspc\fR (SUB) generates a SIGTSTP signal as ^Z does, but the signal is sent when a program attempts to read the ^Y, rather than when it is typed. .LP .B "Job access control." .PP When using the new terminal driver, if a process which is not in the distinguished process group of its control terminal attempts to read from that terminal its process group is sent a SIGTTIN signal. This signal normally causes the members of that process group to stop. If, however, the process is ignoring SIGTTIN, has SIGTTIN blocked, or is in the middle of process creation using .IR vfork (2)), the read will return \-1 and set .I errno to EIO. .PP When using the new terminal driver with the LTOSTOP bit set in the local modes, a process is prohibited from writing on its control terminal if it is not in the distinguished process group for that terminal. Processes which are holding or ignoring SIGTTOU signals or which are in the middle of a .IR vfork (2) are excepted and allowed to produce output. .B "Terminal/window sizes." In order to accommodate terminals and workstations with variable-sized windows, the terminal driver provides a mechanism for obtaining and setting the current terminal size. The driver does not use this information internally, but only stores it and provides a uniform access mechanism. When the size is changed, a SIGWINCH signal is sent to the terminal's process group so that knowledgeable programs may detect size changes. This facility was added in 4.3BSD and is not available in earlier versions of the system. .LP .B "Summary of modes." .LP Unfortunately, due to the evolution of the terminal driver, there are 4 different structures which contain various portions of the driver data. The first of these (\fBsgttyb\fR) contains that part of the information largely common between version 6 and version 7 UNIX systems. The second contains additional control characters added in version 7. The third is a word of local state added in 4BSD, and the fourth is another structure of special characters added for the new driver. In the future a single structure may be made available to programs which need to access all this information; most programs need not concern themselves with all this state. .de Ul .ie t \\$1\l'|0\(ul' .el \fI\\$1\fP .. .LP .Ul "Basic modes: sgtty." .PP The basic .IR ioctl s use the structure defined in .IR : .PP .ta .5i 1i .nf .ft 3 struct sgttyb { char sg_ispeed; char sg_ospeed; char sg_erase; char sg_kill; short sg_flags; }; .ft R .fi .PP The .I sg_ispeed and .I sg_ospeed fields describe the input and output speeds of the device according to the following table, which corresponds to the DEC DH-11 interface. If other hardware is used, impossible speed changes are ignored. Symbolic values in the table are as defined in .IR . .PP .nf .ta \w'B9600 'u +5n B0 0 (hang up dataphone) B50 1 50 baud B75 2 75 baud B110 3 110 baud B134 4 134.5 baud B150 5 150 baud B200 6 200 baud B300 7 300 baud B600 8 600 baud B1200 9 1200 baud B1800 10 1800 baud B2400 11 2400 baud B4800 12 4800 baud B9600 13 9600 baud EXTA 14 External A EXTB 15 External B .fi .DT .PP Code conversion and line control required for IBM 2741's (134.5 baud) must be implemented by the user's program. The half-duplex line discipline required for the 202 dataset (1200 baud) is not supplied; full-duplex 212 datasets work fine. .PP The .I sg_erase and .I sg_kill fields of the argument structure specify the erase and kill characters respectively. (Defaults are DELETE and ^U.) .PP The .I sg_flags field of the argument structure contains several bits that determine the system's treatment of the terminal: .PP .ta \w'TANDEM 'u +\w'0100000 'u .nf XTABS 0004000 Expand tabs on output EVENP 0000200 Even parity allowed on input ODDP 0000100 Odd parity allowed on input RAW 0000040 Raw mode: wake up on all characters, 8-bit interface CRMOD 0000020 Map CR into LF; output LF as CR-LF ECHO 0000010 Echo (full duplex) CBREAK 0000002 Return each character as soon as typed TANDEM 0000001 Automatic inbound xon/xoff flow control .DT .fi .PP XTABS, causes tabs to be replaced by the appropriate number of spaces on output. .PP The flags for even and odd parity control parity checking on input and generation on output in cooked and CBREAK mode (unless LPASS8 is enabled, see below). Even parity is generated on output unless ODDP is set and EVENP is clear, in which case odd parity is generated. Input characters with the wrong parity, as determined by EVENP and ODDP, are ignored in cooked and CBREAK mode. .PP RAW disables all processing save output flushing with LFLUSHO; full 8 bits of input are given as soon as it is available; all 8 bits are passed on output. A break condition in the input is reported as a null character. If the input queue overflows in raw mode all data in the input and output queues are discarded; this applies to both new and old drivers. .PP CRMOD causes input carriage returns to be turned into new-lines, and output and echoed new-lines to be output as a carriage return followed by a line feed. .PP CBREAK is a sort of half-cooked (rare?) mode. Programs can read each character as soon as typed, instead of waiting for a full line; all processing is done except the input editing: character and word erase and line kill, input reprint, and the special treatment of \e and EOT are disabled. .PP TANDEM mode causes the system to produce a stop character (default ^S) whenever the input queue is in danger of overflowing, and a start character (default ^Q) when the input queue has drained sufficiently. It is useful for flow control when the `terminal' is really another computer which understands the conventions. .LP .B Note: The same ``stop'' and ``start'' characters are used for both directions of flow control; the .I t_stopc character is accepted on input as the character that stops output and is produced on output as the character to stop input, and the .I t_startc character is accepted on input as the character that restarts output and is produced on output as the character to restart input. .LP .Ul "Basic ioctls" .PP A large number of .IR ioctl (2) calls apply to terminals. Some have the general form: .PP .B #include .PP .B ioctl(fildes, code, arg) .br .B struct sgttyb *arg; .PP The applicable codes are: .IP TIOCGETP 15 Fetch the basic parameters associated with the terminal, and store in the pointed-to \fIsgttyb\fR structure. .IP TIOCSETP Set the parameters according to the pointed-to \fIsgttyb\fR structure. The interface delays until output is quiescent, then throws away any unread characters, before changing the modes. .IP TIOCSETN Set the parameters like TIOCSETP but do not delay or flush input. Input is not preserved, however, when changing to or from RAW. .PP With the following codes .I arg is ignored. .IP TIOCEXCL 15 Set \*(lqexclusive-use\*(rq mode: no further opens are permitted until the file has been closed. .IP TIOCNXCL Turn off \*(lqexclusive-use\*(rq mode. .IP TIOCHPCL When the file is closed for the last time, hang up the terminal. This is useful when the line is associated with an ACU used to place outgoing calls. .PP With the following codes .I arg is a pointer to an .BR int . .IP TIOCGETD 15 .I arg is a pointer to an .B int into which is placed the current line discipline number. .IP TIOCSETD .I arg is a pointer to an .B int whose value becomes the current line discipline number. .IP TIOCFLUSH If the .B int pointed to by .I arg has a zero value, all characters waiting in input or output queues are flushed. Otherwise, the value of the .B int is for the FREAD and FWRITE bits defined in .BR ; if the FREAD bit is set, all characters waiting in input queues are flushed, and if the FWRITE bit is set, all characters waiting in output queues are flushed. .LP The remaining calls are not available in vanilla version 7 UNIX. In cases where arguments are required, they are described; \fIarg\fR should otherwise be given as 0. .IP TIOCSTI 15 the argument points to a character which the system pretends had been typed on the terminal. .IP TIOCSBRK 15 the break bit is set in the terminal. .IP TIOCCBRK the break bit is cleared. .IP TIOCSDTR data terminal ready is set. .IP TIOCCDTR data terminal ready is cleared. .IP TIOCSTOP 15 output is stopped as if the ``stop'' character had been typed. .IP TIOCSTART output is restarted as if the ``start'' character had been typed. .IP TIOCGPGRP .I arg is a pointer to an .B int into which is placed the process group ID of the process group for which this terminal is the control terminal. .IP TIOCSPGRP .I arg is a pointer to an .B int which is the value to which the process group ID for this terminal will be set. .IP TIOCOUTQ returns in the .B int pointed to by .I arg the number of characters queued for output to the terminal. .IP FIONREAD returns in the .B long pointed to by .I arg the number of characters immediately readable from the argument descriptor. This works for files, pipes, and terminals. .PP .Ul Tchars .PP The second structure associated with each terminal specifies characters that are special in both the old and new terminal interfaces: The following structure is defined in .IR , which is automatically included in .IR : .PP .nf .ft 3 .ta .5i 1i 2i struct tchars { char t_intrc; /* interrupt */ char t_quitc; /* quit */ char t_startc; /* start output */ char t_stopc; /* stop output */ char t_eofc; /* end-of-file */ char t_brkc; /* input delimiter (like nl) */ }; .DT .fi .ft R .PP The default values for these characters are ^C, ^\e\|, ^Q, ^S, ^D, and \-1. A character value of \-1 eliminates the effect of that character. The .I t_brkc character, by default \-1, acts like a new-line in that it terminates a `line,' is echoed, and is passed to the program. The `stop' and `start' characters may be the same, to produce a toggle effect. It is probably counterproductive to make other special characters (including erase and kill) identical. The applicable .I ioctl calls are: .IP TIOCGETC 12 Get the special characters and put them in the specified structure. .IP TIOCSETC 12 Set the special characters to those given in the structure. .LP .Ul "Local mode" .PP The third structure associated with each terminal is a local mode word. The bits of the local mode word are: .sp .nf LCRTBS 000001 Backspace on erase rather than echoing erase LPRTERA 000002 Printing terminal erase mode LCRTERA 000004 Erase character echoes as backspace-space-backspace LMDMBUF 000020 Stop/start output when carrier drops LLITOUT 000040 Suppress output translations LTOSTOP 000100 Send SIGTTOU for background output LFLUSHO 000200 Output is being flushed LNOHANG 000400 Don't send hangup when carrier drops LRTSCTS 001000 RTS/CTS flow control LCRTKIL 002000 BS-space-BS erase entire line on line kill LPASS8 004000 Pass all 8 bits through on input, in any mode LCTLECH 010000 Echo input control chars as ^X, delete as ^? LPENDIN 020000 Retype pending input at next read or input character LDECCTQ 040000 Only ^Q restarts output after ^S, like DEC systems LNOFLSH 100000 Inhibit flushing of pending I/O when an interrupt character is typed. .fi .sp The applicable .I ioctl functions are: .IP TIOCLBIS 15 .I arg is a pointer to an .B int whose value is a mask containing the bits to be set in the local mode word. .IP TIOCLBIC .I arg is a pointer to an .B int whose value is a mask containing the bits to be cleared in the local mode word. .IP TIOCLSET .I arg is a pointer to an .B int whose value is stored in the local mode word. .IP TIOCLGET .I arg is a pointer to an .B int into which the current local mode word is placed. .LP .Ul "Local special chars" .PP The final control structure associated with each terminal is the .I ltchars structure which defines control characters for the new terminal driver. Its structure is: .nf .sp .ta .5i 1i 2i .ft B struct ltchars { char t_suspc; /* stop process signal */ char t_dsuspc; /* delayed stop process signal */ char t_rprntc; /* reprint line */ char t_flushc; /* flush output (toggles) */ char t_werasc; /* word erase */ char t_lnextc; /* literal next character */ }; .ft R .fi .sp The default values for these characters are ^Z, ^Y, ^R, ^O, ^W, and ^V. A value of \-1 disables the character. .PP The applicable \fIioctl\fR functions are: .IP TIOCSLTC 12 .I arg is a pointer to an .I ltchars structure which defines the new local special characters. .IP TIOCGLTC 12 .I arg is a pointer to an .I ltchars structure into which is placed the current set of local special characters. .LP .Ul "Window/terminal sizes" .PP Each terminal has provision for storage of the current terminal or window size in a .I winsize structure, with format: .nf .sp .ft B .ta .5i +\w'unsigned short\ \ \ \ 'u +\w'ws_ypixel;\ \ \ \ \ 'u struct winsize { unsigned short ws_row; /* rows, in characters */ unsigned short ws_col; /* columns, in characters */ unsigned short ws_xpixel; /* horizontal size, pixels */ unsigned short ws_ypixel; /* vertical size, pixels */ }; .ft R .fi .LP A value of 0 in any field is interpreted as ``undefined;'' the entire structure is zeroed on final close. .PP The applicable \fIioctl\fP functions are: .IP TIOCGWINSZ .I arg is a pointer to a .B "struct winsize" into which will be placed the current terminal or window size information. .IP TIOCSWINSZ .I arg is a pointer to a .B "struct winsize" which will be used to set the current terminal or window size information. If the new information is different than the old information, a SIGWINCH signal will be sent to the terminal's process group. .SH FILES /dev/tty .br /dev/tty* .br /dev/console .SH SEE ALSO csh(1), stty(1), tset(1), ioctl(2), sigvec(2), stty(3C), getty(8) ================================================ FILE: share/man/man4/udp.4 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)udp.4p 6.2 (Berkeley) 5/16/86 .\" .TH UDP 4P "May 16, 1986" .UC 5 .SH NAME udp \- Internet User Datagram Protocol .SH SYNOPSIS .B #include .br .B #include .PP .B s = socket(AF_INET, SOCK_DGRAM, 0); .SH DESCRIPTION UDP is a simple, unreliable datagram protocol which is used to support the SOCK_DGRAM abstraction for the Internet protocol family. UDP sockets are connectionless, and are normally used with the .I sendto and .IR recvfrom calls, though the .IR connect (2) call may also be used to fix the destination for future packets (in which case the .IR recv (2) or .IR read (2) and .IR send (2) or .IR write(2) system calls may be used). .PP UDP address formats are identical to those used by TCP. In particular UDP provides a port identifier in addition to the normal Internet address format. Note that the UDP port space is separate from the TCP port space (i.e. a UDP port may not be \*(lqconnected\*(rq to a TCP port). In addition broadcast packets may be sent (assuming the underlying network supports this) by using a reserved \*(lqbroadcast address\*(rq; this address is network interface dependent. .PP Options at the IP transport level may be used with UDP; see .IR ip (4P). .SH DIAGNOSTICS A socket operation may fail with one of the following errors returned: .TP 15 [EISCONN] when trying to establish a connection on a socket which already has one, or when trying to send a datagram with the destination address specified and the socket is already connected; .TP 15 [ENOTCONN] when trying to send a datagram, but no destination address is specified, and the socket hasn't been connected; .TP 15 [ENOBUFS] when the system runs out of memory for an internal data structure; .TP 15 [EADDRINUSE] when an attempt is made to create a socket with a port which has already been allocated; .TP 15 [EADDRNOTAVAIL] when an attempt is made to create a socket with a network address for which no network interface exists. .SH SEE ALSO getsockopt(2), recv(2), send(2), socket(2), intro(4N), inet(4F), ip(4P) ================================================ FILE: share/man/man4/vv.4 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)vv.4 6.2 (Berkeley) 8/20/87 .\" .TH VV 4 "August 20, 1987" .UC 2 .SH NAME vv \- Proteon proNET 10 Megabit ring .SH SYNOPSIS .ft B .nf /sys/conf/SYSTEM: NVV \fIvv_controllers\fP # V2LNI (Pronet) .fi .ft R .SH DESCRIPTION The .I vv interface provides access to a 10 Mb/s Proteon proNET ring network. .PP The network address of the interface must be specified with an an SIOCSIFADDR ioctl before data can be transmitted or received. It is only permissible to change the network address while the interface is marked "down". .PP The host's hardware address is discovered by putting the interface in digital loopback mode (not joining the ring) and sending a broadcast packet from which the hardware address is extracted. .PP Transmit timeouts are detected through use of a watchdog routine. Lost input interrupts are checked for when packets are sent out. .PP If the installation is running CTL boards which use the old broadcast address of 0 instead of the new address of 0xff, the define OLD_BROADCAST should be specified in the driver. .PP The driver can use ``trailer'' encapsulation to minimize copying data on input and output. This may be disabled, on a per-interface basis, by setting the IFF_NOTRAILERS flag with an SIOCSIFFLAGS ioctl. .SH DIAGNOSTICS .PP \fBvv%d: host %d\fP. The software announces the host address discovered during autoconfiguration. .PP \fBvv%d: can't initialize\fP. The software was unable to discover the address of this interface, so it deemed "dead" will not be enabled. .PP \fBvv%d: error vvocsr=%b\fP. The hardware indicated an error on the previous transmission. .PP \fBvv%d: output timeout\fP. The token timer has fired and the token will be recreated. .PP \fBvv%d: error vvicsr=%b\fP. The hardware indicated an error in reading a packet off the ring. .PP \fBen%d: can't handle af%d\fP. The interface was handed a message with addresses formatted in an unsuitable address family; the packet was dropped. .PP \fBvv%d: vs_olen=%d\fP. The ring output routine has been handed a message with a preposterous length. This results in an immediate .IR "panic: vs_olen" . .SH SEE ALSO intro(4N), inet(4F) .SH BUGS The encapsulation of trailer packets in the 4.2BSD version of this driver was incorrect (the packet type was in VAX byte order). As a result, the trailer encapsulation in this version is not compatible with the 4.2BSD VAX version. ================================================ FILE: share/man/man4/xp.4 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)xp.4 6.4 (2.11BSD GTE) 1995/08/14 .\" .TH XP 4 "August 14, 1995" .UC 2 .SH NAME xp \- generic SMD moving-head disk .SH SYNOPSIS .ft B .nf /sys/conf/SYSTEM: .ta .5i +\w'BADSECT 'u +\w'xp_controllers 'u NXPC \fIxp_controllers\fP # Number of controllers NXPD \fIxp_drives\fP # RM02/03/05, RP04/05/06, # CDC 9766, Fuji 160, etc. BADSECT \fINO\fP # Bad sector handling (see BUGS) .DT /etc/dtab: .ta .5i +\w'#Name 'u +\w'Unit# 'u +\w'177777 'u +\w'Vector 'u +\w'Br 'u +\w'xxxxxxx 'u +\w'xxxxxxx 'u #Name Unit# Addr Vector Br Handler(s) # Comments xp ? 176700 254 5 xpintr # xp driver .DT major device number(s): raw: 19 block: 10 minor device encoding: bits 0007 specify partition of XP drive bits 0370 specify XP drive .fi .ft R .SH DESCRIPTION The .I xp driver is a generic SMD storage module disk driver. It can be adapted to most SMD controllers although bootstrapping will not necessarily be directly possible. The drives are numbered from 0 to .I n on controller 0, from .IR n +1 to .I m on controller 1, etc. The drives may have different geometries. .PP The \fIxp\fP driver is unique amoungst 2BSD drivers in its numbering of drives. Other drivers (\fIra\fP for example) number drives 0 thru 7 on controller 1, 8 thru 15 on controller 2 and so on. \fIxp\fP on the other hand can have drives 0 and 1 on controller 1, drives 2, 3, 4 and 5 on controller 2 and drives 6, 7 and 8 on controller 3. This is different from \fBboot\fP's view of the world, so if you are booting from other than unit 0 you may have to experiment a bit. .PP Files with minor device numbers 0 through 7 refer to various portions of drive 0; minor devices 8 through 15 refer to drive 1, etc. The standard device names begin with ``xp'' followed by the drive number and then a letter a-h for partitions 0-7 respectively. The character ? stands here for a drive number in the range 0-7. .PP The block files access the disk via the system's normal buffering mechanism and may be read and written without regard to physical disk records. There is also a `raw' interface which provides for direct transmission between the disk and the user's read or write buffer. A single read or write call results in exactly one I/O operation and therefore raw I/O is considerably more efficient when many words are transmitted. The names of the raw files conventionally begin with an extra `r.' .PP In raw I/O the buffer must begin on a word (even) boundary, and counts should be a multiple of 512 bytes (a disk sector). Likewise .I lseek calls should specify a multiple of 512 bytes. .SH "DISK SUPPORT" Disks must be labeled using either the standalone \fIdisklabel\fP program on the boot tape or with the .IR disklabel (8) program. The kernel no longer attempts to determine the drive type and geometry, instead reading this information from the disklabel. There are no partition tables coded into the \fIxp\fP driver, these must be placed on the drive with \fIdisklabel\fP. .PP Special files should only be created for the partitions that are actually used, as the overlap in these addresses could lead to confusion otherwise. Traditionally the xp?a partition is normally used for the root file system, the xp?b partition as a swap area, and the xp?c partition for pack-pack copying (it maps the entire disk). .SH FILES .ta \w'/dev/MAKEDEV.local 'u /dev/xp[0-7][a-h] block files .br /dev/rxp[0-7][a-h] raw files .br /dev/MAKEDEV script to create special files .br /dev/MAKEDEV.local script to localize special files .SH SEE ALSO hk(4), ra(4), ram(4), rk(4), rl(4), rp(4), rx(4), si(4), dtab(5), autoconfig(8), newfs(8) .SH DIAGNOSTICS \fBxp%d%c: hard error sn%d cs2=%b er1=%b\fR. An unrecoverable error occurred during transfer of the specified sector of the specified disk partition. The contents of the two error registers are also printed in octal and symbolically with bits decoded. The error was either unrecoverable, or a large number of retry attempts (including offset positioning and drive recalibration) could not recover the error. .PP \fBxp%d: write locked\fR. The write protect switch was set on the drive when a write was attempted. The write operation is not recoverable. .PP \fBxp%d%c: soft ecc sn%d\fR. A recoverable ECC error occurred on the specified sector of the specified disk partition. This happens normally a few times a week. If it happens more frequently than this the sectors where the errors are occurring should be checked to see if certain cylinders on the pack, spots on the carriage of the drive or heads are indicated. .PP \fBxp%d: unknown device type 0%o\fR. The number in the drive's drive type register is unknown to the xp driver. .SH BUGS In raw I/O .I read and .IR write (2) truncate file offsets to 512-byte block boundaries, and .I write scribbles on the tail of incomplete blocks. Thus, in programs that are likely to access raw devices, .I read, write and .IR lseek (2) should always deal in 512-byte multiples. .PP DEC-standard error logging should be supported. .PP The kernel uses partition 'h' to access the badblock information. This should have been 'c' except that almost all of the /etc/disktab entries (and thus existing systems) use 'h' for this purpose. Unless you are very careful with \fIdisklabel\fP|(8) (to make certain that no data partition overlaps the badblock area) you should probably leave BADSECT undefined in the kernel config file. ================================================ FILE: share/man/man5/L-devices.5 ================================================ .\" Copyright (c) 1986 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)L-devices.5 6.1.1 (2.11BSD) 1996/10/22 .\" .TH L-DEVICES 5 "October 22, 1996" .UC 6 .SH NAME L-devices \- UUCP device description file .SH DESCRIPTION The L-devices file is consulted by the UUCP daemon .IR uucico (8) under the direction of .IR L.sys (5) for information on the devices that it may use. Each line describes exactly one device. .PP A line in .I L-devices has the form: .PP Caller Device Call_Unit Class Dialer [Expect Send].... .PP Each item can be separated by any number of blanks or tabs. Lines beginning with a `#' character are comments; long lines can be continued by appending a `\e' character to the end of the line. .PP .I Caller denotes the type of connection, and must be one of the following: .TP 8 .B ACU Automatic call unit, e.g., autodialing modems such as the Hayes Smartmodem 1200 or Novation ``Smart Cat''. .TP 8 .B DIR Direct connect; hardwired line (usually RS-232) to a remote system. .TP 8 .B DK AT&T Datakit. .TP 8 .B MICOM Micom Terminal switch. .TP 8 .B PAD X.25 PAD connection. .TP 8 .B PCP GTE Telenet PC Pursuit. .TP 8 .B SYTEK Sytek high-speed dedicated modem port connection. .TP 8 .B TCP Berkeley TCP/IP or 3Com UNET connection. These are mutually exclusive. Note that listing TCP connections in .I L-devices is superfluous; .I uucico does not even bother to look here since it has all the information it needs in .IR L.sys (5). .PP .I Device is a device file in /dev/ that is opened to use the device. The device file must be owned by UUCP, with access modes of 0600 or better. (See .IR chmod (2)). .PP .I Call_Unit is an optional second device file name. True automatic call units use a separate device file for data and for dialing; the .I Device field specifies the data port, while the .I Call_unit field specifies the dialing port. If the .I Call_unit field is unused, it must not be left empty. Insert a dummy entry as a placeholder, such as ``0'' or ``unused.'' .PP .I Class is an integer number that specifies the line baud (for dialers and direct lines) or the port number (for network connections). .PP The .I Class may be preceded by a non-numeric prefix. This is to differentiate among devices that have identical .I Caller and baud, but are distinctly different. For example, ``1200'' could refer to all Bell 212-compatible modems, ``V1200'' to Racal-Vadic modems, and ``C1200'' to CCITT modems, all at 1200 baud. Similarly, ``W1200'' could denote long distance lines, while ``L1200'' could refer to local phone lines. .PP .I Dialer applies only to ACU devices. This is the "brand" or type of the ACU or modem. .TP 8 .B DF02 DEC DF02 or DF03 modems. .TP 8 .B DF112 Dec DF112 modems. Use a .I Dialer field of .B DF112T to use tone dialing, or .B DF112P for pulse dialing. .TP 8 .B att AT&T 2224 2400 baud modem. .TP 8 .B cds224 Concord Data Systems 224 2400 baud modem. .TP 8 .B dn11 DEC DN11 Unibus dialer. .TP 8 .B hayes Hayes Smartmodem 1200 and compatible autodialing modems. Use a .I Dialer field of .B hayestone to use tone dialing, or .B hayespulse for pulse dialing. It is also permissible to include the letters `T' and `P' in the phone number (in .IR L.sys ) to change to tone or pulse midway through dialing. (Note that a leading `T' or `P' will be interpreted as a dialcode!) .TP 8 .B hayes2400 Hayes Smartmodem 2400 and compatible modems. Use a .I Dialer field of .B hayes2400tone to use tone dialing, or .B hayes2400pulse for pulse dialing. .TP 8 .B novation Novation ``Smart Cat'' autodialing modem. .TP 8 .B penril Penril Corp ``Hayes compatible'' modems (they really aren't or they would use the .B hayes entry.) .TP 8 .B rvmacs Racal-Vadic 820 dialer with 831 adapter in a MACS configuration. .TP 8 .B va212 Racal-Vadic 212 autodialing modem. .TP 8 .B va811s Racal-Vadic 811s dialer with 831 adapter. .TP 8 .B va820 Racal-Vadic 820 dialer with 831 adapter. .TP 8 .B vadic Racal-Vadic 3450 and 3451 series autodialing modems. .TP 8 .B ventel Ventel 212+ autodialing modem. .TP 8 .B vmacs Racal-Vadic 811 dialer with 831 adapter in a MACS configuration. .PP .I Expect/Send is an optional .I Expect/Send script for getting through a smart port selector, or for issuing special commands to the modem. The syntax is identical to that of the Expect/Send script of .IR L.sys . The difference is that the .I L-devices script is used .I before the connection is made, while the .I L.sys script is used .IR after . .SH FILES /etc/uucp/L-devices .br /etc/uucp/UUAIDS/L-devices L-devices example .SH SEE ALSO uucp(1), uux(1), L.sys(5), uucico(8) ================================================ FILE: share/man/man5/L-dialcodes.5 ================================================ .\" Copyright (c) 1986 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)L-dialcodes.5 6.1.1 (2.11BSD) 1996/10/22 .\" .TH L-DIALCODES 5 "October 22, 1996" .UC 6 .SH NAME L-dialcodes \- UUCP phone number index file .SH DESCRIPTION The .I L-dialcodes file defines the mapping of strings from the phone number field of .IR L.sys (5) to actual phone numbers. .PP Each line in L-dialcodes has the form: .PP .nf alpha_string phone_number .fi .PP The two items can be separated by any number of blanks or tabs. Lines beginning with a `#' character are comments. .PP A phone number in .I L.sys can be preceded by an arbitrary alphabetic character string; the string is matched against the list of .IR alpha_string s in .IR L-dialcodes . If a match is found, .I phone_number is substituted for it. If no match is found, the string is discarded. .PP .I L-dialcodes is commonly used either of two ways: .TP 4 (1) The alphabetic strings are used as prefixes to denote area codes, zones, and other commonly used sequences. For example, if .I L-dialcodes included the following lines: .PP .nf chi 1312 .br mv 1415 .fi .PP In .I L.sys you could enter: .PP .nf chivax Any ACU 1200 chi5551234 ogin:--ogin: nuucp .br mvpyr Any ACU 1200 mv5556001 ogin:--ogin: Uuucp instead of chivax Any ACU 1200 13125551234 ogin:--ogin: nuucp .br mvpyr Any ACU 1200 14155556001 ogin:--ogin: Uuucp .fi .TP 4 (2) All phone numbers are placed in .IR L-dialcodes , one for each remote site. .I L.sys then refers to these by name. For example, if .I L-dialcodes contains the following lines: .PP .nf chivax 13125551234 .br mvpyr 14155556601 .fi .PP then .I L.sys could have: .PP .nf chivax Any ACU 1200 chivax ogin:--ogin: nuucp .br mvpyr Any ACU 1200 mvpyr ogin:--ogin: Uuucp .fi .PP This scheme allows a site administrator to give users read access to the table of phone numbers, while still protecting the login/password sequences in .IR L.sys . .SH FILES .nf .ta \w'/etc/uucp/UUAIDS/L-dialcodes 'u /etc/uucp/L-dialcodes /etc/uucp/UUAIDS/L-dialcodes L-dialcodes example .fi .SH SEE ALSO uucp(1), uux(1), L.sys(5), uucico(8). ================================================ FILE: share/man/man5/L.aliases.5 ================================================ .\" Copyright (c) 1986 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)L.aliases.5 6.2.1 (2.11BSD) 1996/10/22 .\" .TH L.ALIASES 5 "October 22, 1996" .UC 6 .SH NAME L.aliases \- UUCP hostname alias file .SH DESCRIPTION The .I L.aliases file defines mapping (aliasing) of system names for uucp. This is intended for compensating for systems that have changed names, or do not provide their entire machine name (like most USG systems). It is also useful when a machine's name is not obvious or commonly misspelled. .PP Each line in .I L.aliases is of the form: .PP .nf real_name alias_name .fi .PP Any amount of whitespace may separate the two items. Lines beginning with a `#' character are comments. .PP All occurrences of .I alias_name are mapped to .I real_name by .IR uucico (8), .IR uucp (1), and .IR uux (1). The mapping occurs regardless of whether the name was typed in by a user or provided by a remote site. An exception is the .B -s option of .IR uucico ; only the site's real hostname (the name in .IR L.sys (5)) will be accepted there. .PP Aliased system names should not be placed in .IR L.sys ; they will not be used. .SH FILES .ta \w'/etc/uucp/UUAIDS/L.aliases 'u .nr /etc/uucp/L.aliases /etc/uucp/UUAIDS/L.aliases L.aliases example .fi .SH SEE ALSO uucp(1), uux(1), L.sys(5), uucico(8) ================================================ FILE: share/man/man5/L.cmds.5 ================================================ .\" Copyright (c) 1986 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)L.cmds.5 6.1.1 (2.11BSD) 1996/10/22 .\" .TH L.CMDS 5 "October 22, 1996" .UC 6 .SH NAME L.cmds \- UUCP remote command permissions file .SH DESCRIPTION The .I L.cmds file contains a list of commands, one per line, that are permitted for remote execution via .IR uux (1). .PP The default search path is /bin:/usr/bin:/usr/ucb. To change the path, include anywhere in the file a line of the form: .PP .nf PATH=/bin:/usr/bin:/usr/ucb .fi .PP Normally, an acknowledgment is mailed back to the requesting site after the command completes. If a command name is suffixed with .BR ,Error , then an acknowledgment will be mailed only if the command fails. If the command is suffixed with .BR ,No , then no acknowledgment will ever be sent. (These correspond with the .B \-z and .B \-n options of .IR uux , respectively.) .PP For most sites, .I L.cmds should only include the lines: .PP .nf rmail ruusend .fi .PP News sites should add: .PP .nf PATH=/bin:/usr/bin:/usr/ucb:/usr/new rnews,Error .fi .PP While file names supplied as arguments to .I uux commands will be checked against the list of accessible directory trees in .IR USERFILE (5), this check can be easily circumvented and should not be depended upon. In other words, it is unwise to include any commands in .I L.cmds that accept local file names. In particular, .IR sh (1) and .IR csh (1) are extreme risks. .PP It is common (but hazardous) to include .IR uucp (1) in .IR L.cmds ; see the NOTES section of .IR USERFILE . .SH FILES .ta \w'/etc/uucp/UUAIDS/L.cmds 'u .nf /etc/uucp/L.cmds /etc/uucp/UUAIDS/L.cmds L.cmds example. .fi .SH SEE ALSO uucp(1), uux(1), USERFILE(5), uucico(8), uuxqt(8) ================================================ FILE: share/man/man5/L.sys.5 ================================================ .\" Copyright (c) 1986 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)L.sys.5 6.1.1 (2.11BSD) 1996/10/22 .\" .TH L.SYS 5 "October 22, 1996" .UC 6 .SH NAME L.sys \- UUCP remote host description file .SH DESCRIPTION The .I L.sys file is consulted by the UUCP daemon .IR uucico (8) for information on remote systems. .I L.sys includes the system name, appropriate times to call, phone numbers, and a login and password for the remote system. .I L.sys is thus a privileged file, owned by the UUCP Administrator; it is accessible only to the Administrator and to the superuser. .PP Each line in .I L.sys describes one connection to one remote host, and has the form: .PP .nf System Times Caller Class Device/Phone_Number [Expect Send].... .fi .PP Fields can be separated by any number of blanks or tabs. Lines beginning with a `#' character are comments; long lines can be continued by appending a `\\' character to the end of the line. .PP The first five fields .RI ( System through .IR Device/Phone_Number ) specify the hardware mechanism that is necessary to make a connection to a remote host, such as a modem or network. .I Uucico searches from the top down through .I L.sys to find the desired .IR System ; it then opens the .IR L-devices (5) file and searches for the first available device with the same .IR Caller , .IR Class , and (possibly) .IR Device . (``Available'' means that the device is ready and not being used for something else.) .I Uucico attempts a connection using that device; if the connection cannot be made (for example, a dialer gets a busy signal), .I uucico tries the next available device. If this also fails, it returns to .I L.sys to look for another line for the same .IR System . If none is found, .I uucico gives up. .PP .I System is the hostname of the remote system. Every machine with which this system communicates via UUCP should be listed, regardless of who calls whom. Systems not listed in .I L.sys will not be permitted a connection. The local hostname should .B not appear here for security reasons. .PP .I Times is a comma-separated list of the times of the day and week that calls are permitted to this .IR System . .I Times is most commonly used to restrict long distance telephone calls to those times when rates are lower. List items are constructed as: .PP .nf \fIkeyword\fPhhmm\fB-\fPhhmm\fB/\fP\fIgrade\fP\fB;\fP\fIretry_time\fP .fi .PP .I Keyword is required, and must be one of: .TP 8 .B Any Any time, any day of the week. .TP 8 .B Wk Any weekday. In addition, .BR Mo , .BR Tu , .BR We , .BR Th , .BR Fr , .BR Sa , and .B Su can be used for Monday through Sunday, respectively. .TP 8 .B Evening When evening telephone rates are in effect, from 1700 to 0800 Monday through Friday, and all day Saturday and Sunday. .B Evening is the same as .BR Wk1700-0800,Sa,Su . .TP 8 .B Night When nighttime telephone rates are in effect, from 2300 to 0800 Monday through Friday, all day Saturday, and from 2300 to 1700 Sunday. .B Night is the same as .BR Any2300-0800,Sa,Su0800-1700 . .TP 8 .B NonPeak This is a slight modification of .BR Evening . It matches when the USA X.25 carriers have their lower rate period. This is 1800 to 0700 Monday through Friday, and all day Saturday and Sunday. .B NonPeak is the same as .BR Any1800-0700,Sa,Su . .TP 8 .B Never Never call; calling into this .I System is forbidden or impossible. This is intended for polled connections, where the remote system calls into the local machine periodically. This is necessary when one of the machines is lacking either dial-in or dial-out modems. .PP The optional .I hhmm-hhmm subfield provides a time range that modifies the keyword. .I hhmm refers to .I hours and .I minutes in 24-hour time (from 0000 to 2359). The time range is permitted to "wrap" around midnight, and will behave in the obvious way. It is invalid to follow the .BR Evening , .BR NonPeak , and .B Night keywords with a time range. .PP The .I grade subfield is optional; if present, it is composed of a `/' (slash) and single character denoting the .I grade of the connection, from .B 0 to .BR 9 , .B A to .BR Z , or .B a to .BR z . This specifies that only requests of grade .I grade or better will be transferred during this time. (The grade of a request or job is specified when it is queued by .I uucp or .IR uux .) By convention, mail is sent at grade .BR C , news is sent at grade .BR d , and uucp copies are sent at grade .BR n . Unfortunately, some sites do not follow these conventions, so it is not 100% reliable. .PP The .I retry_time subfield is optional; it must be preceded by a `;' (semicolon) and specifies the time, in minutes, before a failed connection may be tried again. (This restriction is in addition to any constraints imposed by the rest of the .I Time field.) By default, the retry time starts at 10 minutes and gradually increases at each failure, until after 26 tries .I uucico gives up completely (MAX RETRIES). If the retry time is too small, .I uucico may run into MAX RETRIES too soon. .PP .I Caller is the type of device used: .TP 8 .B ACU Automatic call unit or auto-dialing modem such as the Hayes Smartmodem 1200 or Novation ``Smart Cat''. See .I L-devices for a list of supported modems. .TP 8 .B DIR Direct connect; hardwired line (usually RS-232) to a remote system. .TP 8 .B MICOM Micom Terminal Switch. .TP 8 .B PAD X.25 PAD connection. .TP 8 .B PCP GTE Telenet PC Pursuit. See .I L-devices for configuration details. .TP 8 .B SYTEK Sytek high-speed dedicated modem port connection. .TP 8 .B TCP Berkeley TCP/IP or 3Com UNET connection. These are mutually exclusive. TCP ports do .B not need entries in .I L-devices since all the necessary information is contained in .IR L.sys . If several alternate ports or network connections should be tried, use multiple .I L.sys entries. .PP .I Class is usually the speed (baud) of the device, typically 300, 1200, or 2400 for ACU devices and 9600 for direct lines. Valid values are device dependent, and are specified in the .I L\-devices file. .PP On some devices, the baud may be preceded by a non-numeric prefix. This is used in .IR L\-devices to distinguish among devices that have identical .I Caller and baud, but yet are distinctly different. For example, 1200 could refer to all Bell 212-compatible modems, V1200 to Racal-Vadic modems, and C1200 to CCITT modems, all at 1200 baud. .PP On TCP connections, .I Class is the port number (an integer number) or a port name from .I /etc/services that is used to make the connection. For standard Berkeley TCP/IP, UUCP normally uses port number 540. .PP .I Device/Phone_Number varies based on the .I Caller field. For ACU devices, this is the phone number to dial. The number may include: digits .B 0 through .BR 9 ; .B # and .B * for dialing those symbols on tone telephone lines; .B - (hyphen) to pause for a moment, typically two to four seconds; .B = (equal sign) to wait for a second dial tone (implemented as a pause on many modems). Other characters are modem dependent; generally standard telephone punctuation characters (such as the slash and parentheses) are ignored, although .I uucico does not guarantee this. .PP The phone number can be preceded by an alphabetic string; the string is indexed and converted through the .IR "L\-dialcodes" (5) file. .PP For DIR devices, the .I Device/Phone_Number field contains the name of the device in .I /dev that is used to make the connection. There must be a corresponding line in .I L\-devices with identical .IR Caller , .IR Class , and .I Device fields. .PP For TCP and other network devices, .I Device/Phone_Number holds the true network name of the remote system, which may be different from its UUCP name (although one would hope not). .PP .I Expect and .I Send refer to an arbitrarily long set of strings that alternately specify what to .I expect and what to .I send to login to the remote system once a physical connection has been established. A complete set of expect/send strings is referred to as an .IR "expect/send script" . The same syntax is used in the .I L\-devices file to interact with the dialer prior to making a connection; there it is referred to as a .IR "chat script" . The complete format for one .I expect/send pair is: .PP .nf \fIexpect\fP\fB-\fP\fItimeout\fP\fB-\fP\fIsend\fP\fB-\fP\fI\ expect\fP\fB-\fP\fItimeout send\fP .fi .PP .I Expect and .I Send are character strings. .I Expect is compared against incoming text from the remote host; .I send is sent back when .I expect is matched. By default, the .I send is followed by a `\er' (carriage return). If the .I expect string is not matched within .I timeout seconds (default 45), then it is assumed that the match failed. The `\fIexpect\fP\fB-\fP\fIsend\fP\fB-\fP\fIexpect\fP' notation provides a limited loop mechanism; if the first .I expect string fails to match, then the .I send string between the hyphens is transmitted, and .I uucico waits for the second .I expect string. This can be repeated indefinitely. When the last .I expect string fails, .I uucico hangs up and logs that the connection failed. .PP The timeout can (optionally) be specified by appending the parameter `\fB~\fP\fInn\fP' to the expect string, when \fInn\fR is the timeout time in seconds. .PP Backslash escapes that may be imbedded in the .I expect or .I send strings include: .PP .ta .5i +.8i +.8i .nf \eb Generate a 3/10 second BREAK. \eb\fIn\fP Where \fIn\fP is a single-digit number; generate an \fIn\fP/10 second BREAK. \ec Suppress the \er at the end of a \fIsend\fP string. \ed Delay; pause for 1 second. (\fISend\fR only.) \er Carriage Return. \es Space. \en Newline. \exxx Where \fIxxx\fP is an octal constant; denotes the corresponding ASCII character. .fi .PP As a special case, an empty pair of double-quotes \fB""\fP in the .I expect string is interpreted as ``expect nothing''; that is, transmit the .I send string regardless of what is received. Empty double-quotes in the .I send string cause a lone `\er' (carriage return) to be sent. .PP One of the following keywords may be substituted for the .I send string: .PP .nf BREAK Generate a 3/10 second BREAK BREAK\fIn\fP Generate an \fIn\fP/10 second BREAK CR Send a Carriage Return (same as ""). EOT Send an End-Of-Transmission character, ASCII \e004. Note that this will cause most hosts to hang up. NL Send a Newline. PAUSE Pause for 3 seconds. PAUSE\fIn\fP Pause for \fIn\fR seconds. P_ODD Use odd parity on future send strings. P_ONE Use parity one on future send strings. P_EVEN Use even parity on future send strings. (Default) P_ZERO Use parity zero on future send strings. .fi .PP Finally, if the .I expect string consists of the keyword .BR ABORT , then the string following is used to arm an abort trap. If that string is subsequently received any time prior to the completion of the entire .I expect/send script, then .I uucico will abort, just as if the script had timed out. This is useful for trapping error messages from port selectors or front-end processors such as ``Host Unavailable'' or ``System is Down.'' .PP For example: .PP .nf "" "" ogin:--ogin: nuucp ssword: ufeedme .fi .PP This is executed as, ``When the remote system answers, .I expect nothing. .I Send a carriage return. .I Expect the remote to transmit the string `ogin:'. If it doesn't within 45 seconds, send another carriage return. When it finally does, .I send it the string `nuucp'. Then .I expect the string `ssword:'; when that is received, .I send `ufeedme'.'' .SH FILES /etc/uucp/L.sys .br /etc/uucp/UUAIDS/L.sys L.sys example .SH SEE ALSO uucp(1), uux(1), L-devices(5), services(5), uucico(8) .SH BUGS ``ABORT'' in the send/expect script is expressed ``backwards,'' that is, it should be written `` .I expect .BR ABORT '' but instead it is `` .B ABORT .IR expect ''. .PP Several of the backslash escapes in the send/expect strings are confusing and/or different from those used by AT&T and Honey-Danber UUCP. For example, `\eb' requests a BREAK, while practically everywhere else `\eb' means backspace. `\et' for tab and `\ef' for formfeed are not implemented. `\es' is a kludge; it would be more sensible to be able to delimit strings with quotation marks. ================================================ FILE: share/man/man5/Makefile ================================================ # # Copyright (c) 1987 Regents of the University of California. # All rights reserved. # # Redistribution and use in source and binary forms are permitted # provided that the above copyright notice and this paragraph are # duplicated in all such forms and that any documentation, # advertising materials, and other materials related to such # distribution and use acknowledge that the software was developed # by the University of California, Berkeley. The name of the # University may not be used to endorse or promote products derived # from this software without specific prior written permission. # THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED # WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. # # @(#)Makefile 5.4.3 (2.11BSD GTE) 1996/3/20 # TOPSRC!=cd ../../..; pwd include ${TOPSRC}/share/mk/sys.mk MDIR= /usr/share/man/cat5 SRCS= L-devices.5 L-dialcodes.5 L.aliases.5 L.cmds.5 L.sys.5 \ USERFILE.5 a.out.5 acct.5 aliases.5 core.5 dbx.5 \ dir.5 disktab.5 dtab.5 dump.5 fs.5 fstab.5 gettytab.5 \ group.5 hosts.5 intro.5 map3270.5 networks.5 passwd.5 \ phones.5 plot.5 printcap.5 protocols.5 remote.5 resolver.5 \ services.5 shells.5 stack.5 tar.5 termcap.5 tp.5 ttys.5 types.5 \ syserrlst.5 \ tzfile.5 utmp.5 uuencode.5 vfont.5 vgrindefs.5 OBJS= L-devices.0 L-dialcodes.0 L.aliases.0 L.cmds.0 L.sys.0 \ USERFILE.0 a.out.0 acct.0 aliases.0 core.0 dbx.0 \ dir.0 disktab.0 dtab.0 dump.0 fs.0 fstab.0 gettytab.0 \ group.0 hosts.0 intro.0 map3270.0 networks.0 passwd.0 \ phones.0 plot.0 printcap.0 protocols.0 remote.0 resolver.0 \ services.0 shells.0 stack.0 tar.0 termcap.0 tp.0 ttys.0 types.0 \ syserrlst.0 \ tzfile.0 utmp.0 uuencode.0 vfont.0 vgrindefs.0 .SUFFIXES: .5 .0 .5.0: ${MANROFF} $*.5 > $*.0 all: _make_01 _make_01: ${OBJS} clean: FRC rm -f ${OBJS} install: _make_01 cp ${OBJS} ${DESTDIR}${MDIR} ln -f ${DESTDIR}${MDIR}/fs.0 ${DESTDIR}${MDIR}/inode.0 ln -f ${DESTDIR}${MDIR}/dump.0 ${DESTDIR}${MDIR}/dumpdates.0 ln -f ${DESTDIR}${MDIR}/utmp.0 ${DESTDIR}${MDIR}/wtmp.0 FRC: ================================================ FILE: share/man/man5/USERFILE.5 ================================================ .\" Copyright (c) 1986 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)USERFILE.5 6.1.2 (2.11BSD) 1996/11/27 .\" .TH USERFILE 5 "November 27, 1996" .UC 6 .SH NAME USERFILE \- \s-1UUCP\s0 pathname permissions file .SH DESCRIPTION The .I USERFILE file specifies the file system directory trees that are accessible to local users and to remote systems via \s-1UUCP\s0. .PP Each line in .I USERFILE is of the form: .PP [\fIloginname\fP]\fB,\fP[\fIsystem\fP] [ \fBc\fP ] \fIpathname\fP \c [\fIpathname\fP] [\fIpathname\fP] .PP The first two items are separated by a comma; any number of spaces or tabs may separate the remaining items. Lines beginning with a `#' character are comments. A trailing `\e' indicates that the next line is a continuation of the current line. .PP .I Loginname is a login (from .IR /etc/passwd ) on the local machine. .PP .I System is the name of a remote machine, the same name used in .IR L.sys (5). .PP .I c denotes the optional .I callback field. If a \fBc\fP appears here, a remote machine that calls in will be told that callback is requested, and the conversation will be terminated. The local system will then immediately call the remote host back. .PP .I Pathname is a pathname prefix that is permissible for this .I login and/or .IR system . .PP When .IR uucico (8) runs in master role or .IR uucp (1) or .IR uux (1) are run by local users, the permitted pathnames are those on the first line with a .I loginname that matches the name of the user who executed the command. If no such line exists, then the first line with a null (missing) .I loginname field is used. (Beware: .I uucico is often run by the superuser or the \s-1UUCP\s0 administrator through .IR cron (8).) .PP When .I uucico runs in slave role, the permitted pathnames are those on the first line with a .I system field that matches the hostname of the remote machine. If no such line exists, then the first line with a null (missing) .I system field is used. .PP .IR Uuxqt (8) works differently; it knows neither a login name nor a hostname. It accepts the pathnames on the first line that has a null .I system field. (This is the same line that is used by .I uucico when it cannot match the remote machine's hostname.) .PP A line with both .I loginname and .I system null, for example .IP .B , /usr/spool/uucppublic .PP can be used to conveniently specify the paths for both "no match" cases if lines earlier in .I USERFILE did not define them. (This differs from older Berkeley and all USG versions, where each case must be individually specified. If neither case is defined earlier, a "null" line only defines the "unknown login" case.) .PP To correctly process .I loginname on systems that assign several logins per UID, the following strategy is used to determine the current .IR loginname : .TP 1) If the process is attached to a terminal, a login entry exists in .IR /var/run/utmp , and the UID for the .I utmp name matches the current real UID, then .IR loginname is set to the .I utmp name. .TP 2) If the .B USER environment variable is defined and the UID for this name matches the current real UID, then .IR loginname is set to the name in .BR USER . .TP 3) If both of the above fail, call .IR getpwuid (3) to fetch the first name in .I /etc/passwd that matches the real UID. .TP 4) If all of the above fail, the utility aborts. .SH FILES .ta \w'/etc/uucp/UUAIDS/USERFILE 'u .nf /etc/uucp/USERFILE /etc/uucp/UUAIDS/USERFILE USERFILE example .fi .SH SEE ALSO uucp(1), uux(1), L.cmds(5), L.sys(5), uucico(8), uuxqt(8) .SH NOTES The \s-1UUCP\s0 utilities .RI ( uucico , .IR uucp , .IR uux , and .IR uuxqt ) always have access to the \s-1UUCP\s0 spool files in .IR /usr/spool/uucp , regardless of pathnames in .IR USERFILE . .PP If .B uucp is listed in .IR L.cmds (5), then a remote system will execute .I uucp on the local system with the .I USERFILE privileges for its .IR login , not its hostname. .PP .I Uucico freely switches between master and slave roles during the course of a conversation, regardless of the role it was started with. This affects how .I USERFILE is interpreted. .SH WARNING .I USERFILE restricts access only on strings that the \s-1UUCP\s0 utilities identify as being pathnames. If the wrong holes are left in other \s-1UUCP\s0 control files (notably .IR L.cmds ), it can be easy for an intruder to open files anywhere in the file system. Arguments to .IR uucp (1) are safe, since it assumes all of its non-option arguments are files. .IR Uux (1) cannot make such assumptions; hence, it is more dangerous. .SH BUGS The .I "\s-1UUCP\s0 Implementation Description" explicitly states that all remote login names must be listed in .IR USERFILE . This requirement is not enforced by Berkeley \s-1UUCP\s0, although it is by USG \s-1UUCP\s0. .PP Early versions of 4.2BSD .IR uuxqt (8) erroneously check \s-1UUCP\s0 spool files against the .I USERFILE pathname permissions. Hence, on these systems it is necessary to specify .I /usr/spool/uucp as a valid path on the .I USERFILE line used by .IR uuxqt . Otherwise, all .IR uux (1) requests are rejected with a "PERMISSION DENIED" message. ================================================ FILE: share/man/man5/a.out.5 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)a.out.5 2.4 (2.11BSD GTE) 1/9/94 .\" .TH A.OUT 5 "January 9, 1994" .UC 2 .SH NAME a.out \- assembler and link editor output .SH SYNOPSIS .B #include .SH DESCRIPTION .I A.out is the output file of the assembler .IR as (1) and the link editor .IR ld (1). Both programs make .I a.out executable if there were no errors and no unresolved external references. Layout information as given in the include file for the PDP11 is: .PP .nf .ta \w'#define 'u +\w'unsigned int 'u +\w'ov_siz[NOVL] 'u /* * Header prepended to each a.out file. */ struct exec { int a_magic; /* magic number */ unsigned int a_text; /* size of text segment */ unsigned int a_data; /* size of initialized data */ unsigned int a_bss; /* size of uninitialized data */ unsigned int a_syms; /* size of symbol table */ unsigned int a_entry; /* entry point */ unsigned int a_unused; /* not used */ unsigned int a_flag; /* relocation info stripped */ }; #define NOVL 15 /* number of overlays */ struct ovlhdr { int max_ovl; /* maximum overlay size */ unsigned int ov_siz[NOVL]; /* size of i'th overlay */ }; struct xexec { struct exec e; struct ovlhdr o; }; #define A_MAGIC1 0407 /* normal */ #define A_MAGIC2 0410 /* read-only text */ #define A_MAGIC3 0411 /* separated I&D */ #define A_MAGIC4 0405 /* overlay */ #define A_MAGIC5 0430 /* auto-overlay (nonseparate) */ #define A_MAGIC6 0431 /* auto-overlay (separate) */ /* * Macros which take exec structures as arguments and tell whether * the file has a reasonable magic number or offset to text. */ #define N_BADMAG(x) \e (((x).a_magic)!=A_MAGIC1 && ((x).a_magic)!=A_MAGIC2 && \e ((x).a_magic)!=A_MAGIC3 && ((x).a_magic)!=A_MAGIC4 && \e ((x).a_magic)!=A_MAGIC5 && ((x).a_magic)!=A_MAGIC6) #define N_TXTOFF(x) \e ((x).a_magic==A_MAGIC5 || (x).a_magic==A_MAGIC6 ? \e sizeof(struct ovlhdr) + sizeof(struct exec) : sizeof(struct exec)) /* * The following were added as part of the new object file format. They * call functions because calculating the sums of overlay sizes was too * messy (and verbose) to do 'inline'. * * NOTE: if the magic number is that of an overlaid object the program * must pass an extended header ('xexec') as the argument. */ off_t n_stroff(), n_symoff(), n_datoff(), n_dreloc(), n_treloc(); #define N_STROFF(e) (n_stroff(&e)) #define N_SYMOFF(e) (n_symoff(&e)) #define N_DATOFF(e) (n_datoff(&e)) #define N_DRELOC(e) (n_dreloc(&e)) #define N_TRELOC(e) (n_treloc(&e)) .fi .PP The file has five sections: a header, the program text and data, relocation information, a symbol table and a strings table (in that order). The last three may be omitted if the program was loaded with the `\-s' option of .I ld or if the symbols and relocation have been removed by .IR strip (1). .PP In the header the sizes of each section are given in bytes, but are even. The size of the header is not included in any of the other sizes. .PP When an .I a.out file is executed, three or four logical segments are set up: the text segment, a possible text overlay segment, the data segment (with uninitialized data, which starts off as all 0, following initialized), and a stack. The text segment begins at 0 in the core image; the header is not loaded. .PP .IR "Non-overlaid objects" : If the magic number in the header is A_MAGIC1 (0407), it indicates that the text segment is not to be write-protected and shared, so the data segment is immediately contiguous with the text segment. This is the oldest kind of executable program and is the default; it should not be used for production binaries. If the magic number is A_MAGIC2 (0410), the data segment begins at the first 0 mod 8K byte boundary following the text segment, and the text segment is not writable by the program; if other processes are executing the same file, they will share the text segment. If the magic number is A_MAGIC3 (0411), the text segment is again pure, write-protected, and shared, and moreover instruction and data space are separated; the text and data segment both begin at location 0. This format is only runnable on processors which support separate instruction and data space but can provide significantly more data space than an A_MAGIC2 format of the same object. .PP .I "Text replacement objects" : If the magic number is A_MAGIC4 (0405), the text segment is overlaid on an existing non-overlaid pure (A_MAGIC2 or A_MAGIC3) or text replacement (A_MAGIC4) text segment and the existing data segment is preserved. The text segment of the previous memory image must be the same size as that of the text replacement object being loaded. There is, unfortunately, no loader support to help achieve this requirement. The text replacement format is useful for objects which need a large amount of data space on non-separate I&D processors. .PP .I "Overlaid objects" : If the magic number is A_MAGIC5 (0430), a base text segment is write-protected and shared and is followed by a text overlay segment. There are a maximum of NOVL overlays, all pure and shared. The base segment runs from 0 to txtsiz. The overlay region begins at the next 0 mod 8k byte boundary, which is as large as the largest overlay. When running, any one of the overlays can be mapped into this region. The data segment begins at the following 0 mod 8k byte boundary. If the magic number is A_MAGIC6 (0431), the situation is the same as for type A_MAGIC5 except that instruction and data spaces are separated and both begin at location 0. As with the A_MAGIC3 format, an .I a.out in A_MAGIC6 format can only be run on a processor which supports separate I&D, but again can provide significantly more data space than A_MAGIC5 format. Both A_MAGIC5 and A_MAGIC6 executable files have a second header between the normal a.out header and the start of the text image; it contains the maximum overlay size and the sizes of each of the overlays. The text images of the overlays follow the text in the object file. .PP The stack segment will occupy the highest possible locations in the core image: growing downwards from 0177776(8). The stack segment is automatically extended as required. The data segment is only extended as requested by .IR brk (2). .PP The include file \fBa.out.h\fP defines \fI_AOUT_INCLUDE_\fP, the include file \fBnlist.h\fP does not. This permits compile time initialization of the \fIn_name\fP field for programs that are not looking at the executable header. .sp The layout of a symbol table entry and the principal flag values that distinguish symbol types are given in the include file as follows: .PP .nf .ta \w'#define 'u +\w'unsigned int 'u +\w'n_name[8] 'u .PP struct nlist { #ifdef _AOUT_INCLUDE_ union { char *n_name; /* In memory address of symbol name */ off_t n_strx; /* String table offset (file) */ } n_un; #else char *n_name; /* symbol name (in memory) */ #endif u_char n_type; /* Type of symbol - see below */ char n_ovly; /* Overlay number */ u_int n_value; /* Symbol value */ }; /* * Simple values for n_type. */ #define N_UNDF 0x0 /* undefined */ #define N_ABS 0x1 /* absolute */ #define N_TEXT 0x2 /* text symbol */ #define N_DATA 0x3 /* data symbol */ #define N_BSS 0x4 /* bss symbol */ #define N_REG 0x14 /* register name */ #define N_FN 0x1f /* file name symbol */ #define N_EXT 0x20 /* external bit, or'ed in */ #define N_TYPE 0x1f /* mask for all the type bits */ /* * Format for namelist values. */ #define N_FORMAT "%06o" .fi .PP If a symbol's type is undefined external, and the value field is non-zero, the symbol is interpreted by the loader .I ld as the name of a common region whose size is indicated by the value of the symbol. .PP The value of a word in the text or data which is not a portion of a reference to an undefined external symbol is exactly that value which will appear in memory when the file is executed. If a word in the text or data involves a reference to an undefined external symbol, as indicated by the relocation information, then the value stored in the file is an offset from the associated external symbol. When the file is processed by the link editor and the external symbol becomes defined, the value of the symbol will be added into the word in the file. .PP If relocation information is present, it amounts to one word per word of program text or initialized data. There is no relocation information if the `relocation info stripped' flag in the header is on. Automatic-overlay (A_MAGIC5 and A_MAGIC6) files do not contain relocation information. .PP Bits 1-3 of a relocation word indicate the segment referred to by the text or data word associated with the relocation word: .TP 000 absolute number .br .ns .TP 002 reference to text segment .br .ns .TP 004 reference to initialized data .br .ns .TP 006 reference to uninitialized data (bss) .br .ns .TP 010 reference to undefined external symbol .PP Bit 0 of the relocation word indicates, if 1, that the reference is relative to the pc (e.g. `clr x'); if 0, that the reference is to the actual symbol (e.g., `clr *$x'). .PP The remainder of the relocation word (bits 15-4) contains a symbol number in the case of external references, and is unused otherwise. .PP The string table begins with a longword containing the length of the string table (including the longword itself). All strings are null terminated. .PP The first symbol is numbered 0, the second 1, etc. .SH "SEE ALSO" as(1), ld(1), nm(1), strip(1), nlist(3) .SH BUGS The current implementation places a maximum length of 32 characters for symbol names in .I a.out files. This is (relatively) easily raised with the caveat that the linker and other programs which look at symbol tables will slow down even more than they already have. .PP The .I 4BSD a.out format has been implemented. This involved modifying the first phase of the C compiler .RI ( /lib/c0 ), the assembler .RI ( /bin/as ), the debugger .RI adb (1), the linker .RI ld (1), and then simply porting the 4.3BSD/Net\-2 .IR ar (1), .IR nm (1), .IR ranlib (1), .IR strip "(1) and" .IR nlist (3). .PP As part of this effort the include file \fIshort_names.h\fP has gone away. ================================================ FILE: share/man/man5/acct.5 ================================================ .\" @(#)acct.5 6.2 (Berkeley) 5/19/86 .\" .TH ACCT 5 "May 19, 1986" .AT 3 .SH NAME acct \- execution accounting file .SH SYNOPSIS .B #include .SH DESCRIPTION The .IR acct (2) system call arranges for entries to be made in an accounting file for each process that terminates. The accounting file is a sequence of entries whose layout, as defined by the include file is: .PP .nf .ta \w'typedef 'u +\w'ACOMPAT 'u +\w'ac_comm[10]; 'u .so /usr/include/sys/acct.h .fi .PP If the process was created by an .IR execve (2), the first 10 characters of the filename appear in .I ac_comm. The accounting flag contains bits indicating whether .IR execve (2) was ever accomplished, and whether the process ever had super-user privileges. .SH SEE ALSO acct(2), execve(2), sa(8) ================================================ FILE: share/man/man5/aliases.5 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)aliases.5 6.1.1 (2.11BSD) 1996/10/22 .\" .TH ALIASES 5 "October 22, 1996" .UC 4 .SH NAME aliases \- aliases file for sendmail .SH SYNOPSIS .B /etc/aliases .SH DESCRIPTION This file describes user id aliases used by .I /usr/sbin/sendmail. It is formatted as a series of lines of the form .in +0.5i name: name_1, name2, name_3, . . . .in The .I name is the name to alias, and the .I name_n are the aliases for that name. Lines beginning with white space are continuation lines. Lines beginning with `\|#\|' are comments. .PP Aliasing occurs only on local names. Loops can not occur, since no message will be sent to any person more than once. .LP After aliasing has been done, local and valid recipients who have a ``.forward'' file in their home directory have messages forwarded to the list of users defined in that file. .PP This is only the raw data file; the actual aliasing information is placed into a binary format in the files .I /etc/aliases.dir and .I /etc/aliases.pag using the program .IR newaliases (1). A .I newaliases command should be executed each time the aliases file is changed for the change to take effect. .SH "SEE ALSO" newaliases(1), dbm(3X), sendmail(8) .br SENDMAIL Installation and Operation Guide. .br SENDMAIL An Internetwork Mail Router. .SH BUGS Because of restrictions in .IR dbm (3X) a single alias cannot contain more than about 1000 bytes of information. You can get longer aliases by ``chaining''; that is, make the last name in the alias be a dummy name which is a continuation alias. ================================================ FILE: share/man/man5/core.5 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)core.5 2.3 (Berkeley) 1/26/87 .\" .TH CORE 5 "January 26, 1987" .UC 2 .SH NAME core \- format of memory image file .SH SYNOPSIS .B #include .SH DESCRIPTION The UNIX System writes out a memory image of a terminated process when any of various errors occur. See .IR sigvec (2) for the list of reasons; the most common are memory violations, illegal instructions, bus errors, and user-generated quit signals. The memory image is called `core' and is written in the process's working directory (provided it can be; normal access controls apply). .PP The core file consists of the .I u. area, whose size (in 64 byte `clicks') is defined by the USIZE manifest in the .RI < sys/param.h > file. The .I u. area starts with a .I user structure as given in .RI < sys/user.h >. The rest of the .I u. area consists of the kernel stack for the terminated process which includes (among other things) the processor registers at the time of the fault; see the system listings for the format of this area. The remainder of the core file consists first of the data pages and then the stack pages of the process image. The amount of data space image in the core file is given (in clicks) by the variable .I u_dsize in the .I u. area. If the text segment was not write-only and and shared it is included as the first .I etext bytes of the data image where .I etext is taken from the symbol table of the object file which generated the memory image. The amount of stack image in the core file is given (in clicks) by the variable .I u_ssize in the .I u. area. .PP In general the debugger .IR adb (1) is sufficient to deal with core images. .SH "SEE ALSO" adb(1), sigvec(2), stack(5) ================================================ FILE: share/man/man5/dbx.5 ================================================ .\" Copyright (c) 1985 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)dbx.5 6.2 (Berkeley) 1/12/86 .\" .TH DBX 5 "January 12, 1986" .UC 6 .SH NAME dbx \- dbx symbol table information .SH DESCRIPTION The compiler symbol information generated for \fIdbx\fP(1) uses the same structure as described in \fIstab\fP(5), with additional type and scope information appended to a symbol's name. The assembler directive used to describe symbol information has the following format: .sp 1 .ti +8n \fBstabs\fR ``\fIstring\fP'',\fIkind\fP,0,\fIsize\fP,\fIvalue\fP .PP \fIString\fR contains the name, source language type, and scope of the symbol, \fIkind\fR specifies the memory class (e.g., external, static, parameter, local, register), and \fIsize\fR specifies the byte size of the object, if relevant. The third field (0 above) is unused. For a global variable or a type, \fIvalue\fR is unused; for a local variable or parameter, it is the offset from the frame pointer, for a register variable, it is the associated register number. .PP The different kinds of stab entries are interpreted by dbx as follows: .IP N_GSYM 10 The symbol is a global variable (e.g., .comm variable). The variable's address can be found from the corresponding ld(1) symbol entry, thus the value field for N_GSYM symbols is ignored. For example, a global variable ``x'' will have both an N_GSYM entry and an \fIld\fP(1) entry (e.g., N_BSS + N_EXT). See \fIa.out\fP(5) for details about these other entries. of .IP N_FUN The symbol is a procedure or function. The size field contains the line number of the entry point. The value field contains the address of the entry point (in the text segment). .IP N_STSYM The symbol is a statically allocated variable for which an initial value has been specified. The value field contains the address of the variable (in the data segment). .IP N_LCSYM The symbol is statically allocated, but not initialized. .IP N_RSYM The symbol is a register variable whose value is kept in the register denoted by the value field. .IP N_PSYM The symbol is a parameter whose value is pushed on the stack before the call. The value field contains the offset from the argument base pointer (on the VAX, the ap register). .IP N_LSYM The symbol is a local variable whose value is stored in the most recently defined procedure's stack frame. The value is the (often negative) offset from the frame pointer (on the VAX, the fp register). .IP "N_PC, N_MOD2" The symbol defines separate compilation information for pre-linking checking for Berkeley Pascal and DEC Modula-2 programs respectively. For Pascal, the value field contains the line number that the symbol is defined on. The value field is not used for Modula-2. .PP Most of the source level information about a symbol is stored in the string field of the stab entry. Since strings are kept in a separate string table in the a.out file, they can be arbitrarily long. Thus there are no restrictions on the kind or length of information in the string field, and it was not necessary to modify the assembler or loader when extending or modifying the format of this information. .sp .PP Below is a grammar describing the syntax of the symbol string. Except in the case of a constant whose value is a string, there are no blanks in a symbol string. .nf .ta 1i 2i 3i 4i 5i 6i 7i .sp 1 NAME: [a-zA-Z_][a-zA-Z_0-9]* INTEGER: [-][0-9][0-9]* REAL: [+-][0-9]*(\.[0-9][0-9]*|)([eE]([+-]|)[0-9][0-9]*|) STRING: ``.*'' BSTRING: .* String: NAME `:' Class `:' Class Class: `c' `=' Constant `;' Variable Procedure Parameter NamedType `X' ExportInfo -- export or import information (for N_MOD2 only) Constant: `i' INTEGER `r' REAL `c' OrdValue `b' OrdValue `s' STRING `e' TypeId `,' OrdValue `S' TypeId `,' NumElements `,' NumBits `,' BSTRING OrdValue: INTEGER NumElements: INTEGER NumBits: INTEGER Variable: TypeId -- local variable of type TypeId `r' TypeId -- register variable of type TypeId `S' TypeId -- module variable of type TypeId (static global in C) `V' TypeId -- own variable of type TypeId (static local in C) `G' TypeId -- global variable of type TypeId Procedure: Proc -- top level procedure Proc `,' NAME `,' NAME -- local to first NAME, -- second NAME is corresponding ld symbol .ne 8 Proc: `P' -- global procedure `Q' -- local procedure (static in C) `I' -- internal procedure (different calling sequence) `F' TypeId -- function returning type TypeId `f' TypeId -- local function `J' TypeId -- internal function Parameter: `p' TypeId -- value parameter of type TypeId `v' TypeId -- reference parameter of type TypeId NamedType: `t' TypeId -- type name for type TypeId `T' TypeId -- C structure tag name for struct TypeId TypeId: INTEGER -- Unique (per compilation) number of type INTEGER `=' TypeDef -- Definition of type number INTEGER `=' TypeAttrs TypeDef -- -- Type attributes are extra information associated with a type, -- such as alignment constraints or pointer checking semantics. -- Dbx interprets some of these, but will ignore rather than complain -- about any it does not recognize. Therefore this is a way to add -- extra information for pre-linking checking. -- TypeAttrs: `@' TypeAttrList `;' TypeAttrList: TypeAttrList `,' TypeAttr TypeAttr TypeAttr: `a' INTEGER -- align boundary `s' INTEGER -- size in bits `p' INTEGER -- pointer class (e.g., checking) BSTRING -- something else TypeDef: INTEGER Subrange Array Record `e' EnumList `;' -- enumeration `*' TypeId -- pointer to TypeId `S' TypeId -- set of TypeId `d' TypeId -- file of TypeId ProcedureType `i' NAME `:' NAME `;' -- imported type ModuleName:Name `o' NAME `;' -- opaque type `i' NAME `:' NAME `,' TypeId `;' `o' NAME `,' TypeId `;' Subrange: `r' TypeId `;' INTEGER `;' INTEGER Array: `a' TypeId `;' TypeId -- array [TypeId] of TypeId `A' TypeId -- open array of TypeId `D' INTEGER `,' TypeId -- N-dim. dynamic array `E' INTEGER `,' TypeId -- N-dim. subarray ProcedureType: `f' TypeId `;' -- C function type `f' TypeId `,' NumParams `;' TParamList `;' `p' NumParams `;' TParamList `;' NumParams: INTEGER Record: `s' ByteSize FieldList `;' -- structure/record `u' ByteSize FieldList `;' -- C union ByteSize: INTEGER FieldList : Field FieldList Field Field: NAME `:' TypeId `,' BitOffset `,' BitSize `;' BitSize: INTEGER BitOffset: INTEGER EnumList: Enum EnumList Enum Enum: NAME `:' OrdValue `,' ParamList: Param ParamList Param Param: NAME `:' TypeId `,' PassBy `;' PassBy: INTEGER TParam: TypeId `,' PassBy `;' TParamList : TParam TParamList TParam Export: INTEGER ExportInfo ExportInfo: `t' TypeId `f' TypeId `,' NumParams `;' ParamList `;' `p' NumParams `;' ParamList `;' `v' TypeId `c' `=' Constant .fi .PP A `?' indicates that the symbol information is continued in the next stab entry. This directive can only occur where a `;' would otherwise separate the fields of a record or constants in an enumeration. It is useful when the number of elements in one of these lists is large. .SH "SEE ALSO" dbx(1), stab(5), a.out(5) ================================================ FILE: share/man/man5/dir.5 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)dir.5 6.1 (Berkeley) 5/15/85 .\" .TH DIR 5 "May 15, 1985" .UC 5 .SH NAME dir \- format of directories .SH SYNOPSIS .B #include .br .B #include .SH DESCRIPTION A directory behaves exactly like an ordinary file, save that no user may write into a directory. The fact that a file is a directory is indicated by a bit in the flag word of its i-node entry; see .IR fs (5). The structure of a directory entry as given in the include file is: .RS .ta 8n +10n +10n .PP .nf /* * A directory consists of some number of blocks of DIRBLKSIZ * bytes, where DIRBLKSIZ is chosen such that it can be transferred * to disk in a single atomic operation (e.g. 512 bytes on most machines). * * Each DIRBLKSIZ byte block contains some number of directory entry * structures, which are of variable length. Each directory entry has * a struct direct at the front of it, containing its inode number, * the length of the entry, and the length of the name contained in * the entry. These are followed by the name padded to a 4 byte boundary * with null bytes. All names are guaranteed null terminated. * The maximum length of a name in a directory is MAXNAMLEN. * * The macro DIRSIZ(dp) gives the amount of space required to represent * a directory entry. Free space in a directory is represented by * entries which have dp->d_reclen > DIRSIZ(dp). All DIRBLKSIZ bytes * in a directory block are claimed by the directory entries. This * usually results in the last entry in a directory having a large * dp->d_reclen. When entries are deleted from a directory, the * space is returned to the previous entry in the same directory * block by increasing its dp->d_reclen. If the first entry of * a directory block is free, then its dp->d_ino is set to 0. * Entries other than the first in a directory do not normally have * dp->d_ino set to 0. */ #define DIRBLKSIZ 512 #define MAXNAMLEN 63 /* * The DIRSIZ macro gives the minimum record length which will hold * the directory entry. This requires the amount of space in struct direct * without the d_name field, plus enough space for the name with a terminating * null byte (dp->d_namlen+1), rounded up to a 4 byte boundary. */ #undef DIRSIZ #define DIRSIZ(dp) \e ((((sizeof (struct direct) - (MAXNAMLEN+1)) + (dp)->d_namlen+1) + 3) &~ 3) struct direct { ino_t d_ino; short d_reclen; short d_namlen; char d_name[MAXNAMLEN + 1]; /* typically shorter */ }; struct _dirdesc { int dd_fd; long dd_loc; long dd_size; char dd_buf[DIRBLKSIZ]; }; .fi .RE .PP By convention, the first two entries in each directory are for `.' and `..'. The first is an entry for the directory itself. The second is for the parent directory. The meaning of `..' is modified for the root directory of the master file system (\*(lq/\*(rq), where `..' has the same meaning as `.'. .SH "SEE ALSO" fs(5) .SH BUGS The 63 character MAXNAMLEN value is shorter than the 255 characters allowed by 4BSD. This could lead to file name portability problems in unusual circumstances. .PP The disk format of directories is only slightly different from the 4BSD directory format, the inode number is of type ino_t rather than u_long to reduce the amount of 32 bit arithmetic in the kernel. ================================================ FILE: share/man/man5/disktab.5 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)disktab.5 6.4 (Berkeley) 5/17/86 .\" .TH DISKTAB 5 "May 17, 1986" .UC 5 .SH NAME disktab \- disk description file .SH SYNOPSIS .B #include .SH DESCRIPTION .I Disktab is a simple date base which describes disk geometries and disk partition characteristics. The format is patterned after the .IR termcap (5) terminal data base. Entries in .I disktab consist of a number of `:' separated fields. The first entry for each disk gives the names which are known for the disk, separated by `|' characters. The last name given should be a long name fully identifying the disk. .PP The following list indicates the normal values stored for each disk entry. .nf .ta \w'Name 'u +\w'Type 'u \fBName Type Description\fP ns num Number of sectors per track nt num Number of tracks per cylinder nc num Total number of cylinders on the disk b0 str Filename of block zero primary bootstrap for device ba num Block size for partition `a' (bytes) bd num Block size for partition `d' (bytes) be num Block size for partition `e' (bytes) bf num Block size for partition `f' (bytes) bg num Block size for partition `g' (bytes) bh num Block size for partition `h' (bytes) fa num Fragment size for partition `a' (bytes) fd num Fragment size for partition `d' (bytes) fe num Fragment size for partition `e' (bytes) ff num Fragment size for partition `f' (bytes) fg num Fragment size for partition `g' (bytes) fh num Fragment size for partition `h' (bytes) pa num Size of partition `a' in sectors pb num Size of partition `b' in sectors pc num Size of partition `c' in sectors pd num Size of partition `d' in sectors pe num Size of partition `e' in sectors pf num Size of partition `f' in sectors pg num Size of partition `g' in sectors ph num Size of partition `h' in sectors se num Sector size in bytes (default 512) sf bool supports bad144-style bad sector forwarding so bool partition offsets in sectors ty str Type of disk (e.g. removable, winchester) .fi .PP .I Disktab entries may be automatically generated with the .I diskpart program. .SH FILES /etc/disktab .SH "SEE ALSO" newfs(8), diskpart(8), getdiskbyname(3) .SH BUGS This file shouldn't exist, the information should be stored on each disk pack. ================================================ FILE: share/man/man5/dtab.5 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)dtab.5 2.3 (Berkeley) 1/22/87 .\" .TH DTAB 5 "January 22, 1987" .UC 2 .SH NAME dtab \- automatic system configuration device table (2BSD) .SH DESCRIPTION The .I dtab file contains a list of the devices that the .IR autoconfig (8) program will attempt to attach to the system. .PP Each line describes one device which may be present on the system; additional devices of the same type require additional lines. The line contains at least six fields separated by white space. Blank lines and comments can appear anywhere in the file except between fields; comments are delimited by `#' and new line. The fields are (in order): .TP "\w'handler(s) 'u" dev The device name, usually two characters .TP unit Either a unit number or a `?' indicating automatic selection of unit numbers. .TP addr The address of the device's first register, as a 16-bit octal number. .TP vector The interrupt vector, in octal. .TP BR The priority at which the device interrupts. .TP handler(s) One or more routine names with which the interrupt vector is filled. .SH EXAMPLE .nf .sp .DT .ta .5i +\w'dm ? 'u +\w'160020 'u +\w'Vector 'u +\w'5 'u +\w'dhrint dhxint 'u # Device Configuration Table # Clock and console are pre-configured and should not be listed here # # Dev# Addr Vector Br Handler(s) # Comment lp ? 177514 200 4 lpio # lp-11 line printer ht 0 172440 224 5 htintr # tu 16 massbus tape xp ? 176700 254 5 xpio # xp driver dm ? 170500 310 4 dmin # dm11 dh modem control dh ? 160020 320 5 dhin dhou # dh11 terminal mux dz ? 160110 330 5 dzin dzdma # dz11 terminal mux .fi .SH FILES .ta 2i /etc/dtab device table .SH SEE ALSO autoconfig(8) .SH BUGS .I /Etc/dtab is unique to the PDP-11 and 2BSD. ================================================ FILE: share/man/man5/dump.5 ================================================ .TH DUMP 5 "February 26, 1987" .UC .SH NAME dump, ddate \- incremental dump format .SH SYNOPSIS .B #include .br .B #include .br .B #include .SH DESCRIPTION Tapes used by .I dump and .IR restor (8) contain: .nf .IP "" a header record two groups of bit map records a group of records describing directories a group of records describing files .fi .PP The format of the header record and of the first record of each description as given in the include file .I is: .PP .nf .ta .5i \w'#define\ TS_INODE\ 'u #if UCB_NKB == 1 #define NTREC 10 #endif #ifndef UCB_NKB #define NTREC 20 #endif #define MLEN 16 #define MSIZ 4096 #define TS_TAPE 1 #define TS_INODE 2 #define TS_BITS 3 #define TS_ADDR 4 #define TS_END 5 #define TS_CLRI 6 #define MAGIC (int)60011 #define CHECKSUM (int)84446 struct spcl { int c_type; time_t c_date; time_t c_ddate; int c_volume; daddr_t c_tapea; ino_t c_inumber; int c_magic; int c_checksum; struct dinode c_dinode; int c_count; char c_addr[BSIZE]; } spcl; struct idates { char id_name[16]; char id_incno; time_t id_ddate; }; .fi .PP .I NTREC is the number of BSIZE (sys/param.h) byte records in a physical tape block. .I MLEN is the number of bits in a bit map word. .I MSIZ is the number of bit map words. .PP The .I TS\_ entries are used in the .I c\_type field to indicate what sort of header this is. The types and their meanings are as follows: .TP \w'CHECKSUM\|'u TS\_TAPE Tape volume label .PD 0 .TP TS\_INODE A file or directory follows. The .I c\_dinode field is a copy of the disk inode and contains bits telling what sort of file this is. .TP TS\_BITS A bit map follows. This bit map has a one bit for each inode that was dumped. .TP TS\_ADDR A subrecord of a file description. See .I c\_addr below. .TP TS\_END End of tape record. .TP TS\_CLRI A bit map follows. This bit map contains a zero bit for all inodes that were empty on the file system when dumped. .TP MAGIC All header records have this number in .I c\_magic. .TP CHECKSUM Header records checksum to this value. .PD .PP The fields of the header structure are as follows: .TP \w'TS_INODE\ 'u c\_type The type of the header. .PD 0 .TP c\_date The date the dump was taken. .TP c\_ddate The date the file system was dumped from. .TP c\_volume The current volume number of the dump. .TP c\_tapea The current number of this (512-byte) record. .TP c\_inumber The number of the inode being dumped if this is of type .I TS\_INODE. .TP c\_magic This contains the value .I MAGIC above, truncated as needed. .TP c\_checksum This contains whatever value is needed to make the record sum to .I CHECKSUM. .TP c\_dinode This is a copy of the inode as it appears on the file system; see .IR filsys (5). .TP c\_count The count of characters in .I c\_addr. .TP c\_addr An array of characters describing the blocks of the dumped file. A character is zero if the block associated with that character was not present on the file system, otherwise the character is non-zero. If the block was not present on the file system, no block was dumped; the block will be restored as a hole in the file. If there is not sufficient space in this record to describe all of the blocks in a file, .I TS\_ADDR records will be scattered through the file, each one picking up where the last left off. .PD .PP Each volume except the last ends with a tapemark (read as an end of file). The last volume ends with a .I TS\_END record and then the tapemark. .PP The structure .I idates describes an entry of the file .I /etc/ddate where dump history is kept. The fields of the structure are: .TP \w'TS_INODE\ 'u id\_name The dumped file system is .RI `/dev/ id\_nam'. .PD 0 .TP id\_incno The level number of the dump tape; see .IR dump (8). .TP id\_ddate The date of the incremental dump in system format see .IR types (5). .PD .SH FILES /etc/ddate .SH "SEE ALSO" filsys(5), types(5), dump(8), dumpdir(8), restor(8) ================================================ FILE: share/man/man5/fs.5 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)fs.5 2.4 (2.11BSD) 1996/1/27 .\" .TH FS 5 "January 27, 1996" .UC 2 .SH NAME fs, inode \- format of file system volume (2BSD) .SH SYNOPSIS .B #include .br .B #include .br .B #include .SH DESCRIPTION Every file system storage volume (e.g. disk) has a common format for certain vital information. Every such volume is divided into a certain number of blocks. The block size is DEV_BSIZE bytes; specified in .RI < sys/param.h > \- currently 1024. .PP Each disk drive contains some number of file systems each laid out on a contiguous partition of the disk. A file system consists of a .IR "boot block" , followed by a .IR "super block" , followed by an .IR "inode area" , followed by a .I data block area which takes up the remainder of the disk partition. The layout of the super block as defined in .RI < sys/fs.h > is: .PP .nf .ta \w'struct 'u +\w'daddr_t 'u +\w'fs_fsmnt[MAXMNTLEN]; 'u #define MAXMNTLEN 12 /* * Structure of the super-block */ struct fs { u_short fs_isize; /* first block after i-list */ daddr_t fs_fsize; /* size in blocks of entire volume */ short fs_nfree; /* number of addresses in fs_free */ daddr_t fs_free[NICFREE]; /* free block list */ short fs_ninode; /* number of inodes in fs_inode */ ino_t fs_inode[NICINOD]; /* free inode list */ char fs_flock; /* lock during free list manipulation */ char fs_ilock; /* lock during i-list manipulation */ char fs_fmod; /* super block modified flag */ char fs_ronly; /* mounted read-only flag */ time_t fs_time; /* last super block update */ daddr_t fs_tfree; /* total free blocks */ ino_t fs_tinode; /* total free inodes */ short fs_step; /* optimal step in free list pattern */ short fs_cyl; /* number of blocks per pattern */ char fs_fsmnt[MAXMNTLEN]; /* ordinary file mounted on */ ino_t fs_lasti; /* start place for circular search */ ino_t fs_nbehind; /* est # free inodes before s_lasti */ u_short fs_flags; /* mount time flags */ }; .fi .PP .IR "File system" : A file system is described by its super-block. Block 0 of each file system partition is unused and is available to contain a bootstrap program, pack label, or other information. Block 1 (SUPERB) is the super block. The inode area starts immediately after the super-block, in block 2. .I Fs_isize is the address of the first block after the inode area. Thus the inode area is .IR fs_isize \-2 blocks long. .I Fs_fsize is the address of the first block not potentially available for allocation to a file. Thus the data block area is .I "fs_fsize \- fs_isize" blocks long. .PP .IR "Super block" : The path name on which the file system is mounted is maintained in .IR fs_fsmnt . .IR Fs_flock , .IR fs_ilock , .IR fs_fmod , .IR fs_ronly " and" .IR fs_flags are flags maintained in the in core copy of the super block while its file system is mounted and their values on disk are immaterial. .I Fs_fmod is used as a flag to indicate that the super-block has changed and should be copied to the disk during the next periodic update of file system information. .I Fs_ronly is a write-protection indicator. It is a copy of the mount flags .I fs_flags anded with .BR MNT_RDONLY (see \fI/sys/h/mount.h\fP). .PP .I Fs_time is the last time the super-block of the file system was changed. During a reboot, the .I fs_time of the super-block for the root file system is used to set the system's idea of the time. .PP .IR Inode : The inode is the focus of all file activity in the UNIX file system. There is a unique inode allocated for each active file, each current directory, each mounted-on file, text file, and the root. An inode is `named' by its device/i-number pair. .PP Inodes are 64 bytes long, so 16 of them fit into a block if DEV_BSIZE is 1024. The root inode is the root of the file system. Inode 0 can't be used for normal purposes and historically bad blocks were linked to inode 1, thus the root inode is 2 (inode 1 is no longer used for this purpose, however numerous dump tapes make this assumption, so we are stuck with it). No other i-number has a built-in meaning. .PP The format of an inode as given in .RI < sys/inode.h > is: .PP .nf .ta \w'struct 'u +\w'u_short 'u +\w'di_addr[40]; 'u /* * Inode structure as it appears on * a disk block. */ struct dinode { u_short di_mode; /* mode and type of file */ short di_nlink; /* number of links to file */ uid_t di_uid; /* owner's user id */ gid_t di_gid; /* owner's group id */ off_t di_size; /* number of bytes in file */ daddr_t di_addr[7]; /* 7 block addresses 4 bytes each */ u_short di_reserved[5]; /* pad of 10 to make total size 64 */ u_short di_flags; time_t di_atime; /* time last accessed */ time_t di_mtime; /* time last modified */ time_t di_ctime; /* time created */ }; /* * 28 of the di_addr address bytes are used; 7 addresses of 4 * bytes each: 4 direct (4Kb directly accessible) and 3 indirect. */ #define NADDR 7 /* modes */ .ta \w'#define 'u +\w'IWRITE 'u +\w'0170000 'u #define IFMT 0170000 /* type of file */ #define IFCHR 0020000 /* character special */ #define IFDIR 0040000 /* directory */ #define IFBLK 0060000 /* block special */ #define IFREG 0100000 /* regular */ #define IFLNK 0120000 /* symbolic link */ #define IFSOCK 0140000 /* socket */ #define ISUID 04000 /* set user id on execution */ #define ISGID 02000 /* set group id on execution */ #define ISVTX 01000 /* save swapped text even after use */ #define IREAD 0400 /* read, write, execute permissions */ #define IWRITE 0200 #define IEXEC 0100 .fi .PP .I Di_mode identifies the type of file the inode represents; it is encoded identically to the .IR st_mode " field of " stat (2). .I Di_nlink is the number of directory entries (links) that refer to this inode. .I Di_uid and .I di_gid are the owner's user and group IDs. .I Di_size is the number of bytes in the file. .I Di_atime and .I di_mtime are the times of last access and modification of the file contents (read, write or create); .I Di_ctime records the time of last modification to the inode or to the file, and is used to determine whether it should be dumped by .IR dump (8). .PP Special files are recognized by their modes. A block-type special file is one which can potentially be mounted as a file system; a character-type special file cannot, though it is not necessarily character-oriented. For special files, the first two bytes of the .I di_addr field are occupied by the device code .RI "(see " types (5)). The device codes of block and character special files overlap. .PP Disk addresses of plain files and directories are kept in the array .I di_addr. For a DEV_BSIZE of 1K bytes, 7 addresses are kept in .I di_addr using 28 of the 40 bytes. The first 4 addresses specify device blocks directly. The last 3 addresses are singly, doubly and triply indirect and point to blocks containing 256 further block pointers. There are 3 block addresses reserved as a pad to bring the total size of an inode to 64 bytes. All block addresses are of type .IR daddr_t " (see " types (5)). .PP For block .I b in a file to exist, it is not necessary that all blocks less than .I b exist. A zero block number indicates that the corresponding block has never been allocated. Such a missing block reads as if it contained all zero bytes. .PP .IR "Free block list" : The free data block list for each volume is maintained as follows. .I "Fs_free[1], ... , fs_free[fs_nfree\-1]," contain up to NICFREE free block numbers (NICFREE is a configuration constant defined in .RI < sys/param.h ">)." .I Fs_free[0] is the block address of the head of a chain of blocks constituting the free list. The layout of each block of the free chain as defined in .RI < sys/fs.h > is: .PP .nf .ta \w'struct 'u +\w'daddr_t 'u +\w'df_free[NICFREE]; 'u struct fblk { short df_nfree; /* number of addresses in df_free */ daddr_t df_free[NICFREE]; /* free block list */ }; .fi .PP The fields .I df_nfree and .I df_free in a free block are used exactly like .I fs_nfree and .I fs_free in the super block. .PP The algorithm used to allocate a block is: decrement .I fs_nfree, and the new block number is .I fs_free[fs_nfree]. If the new block address is 0, there are no blocks left, so give an error. If .I fs_nfree became 0, read the new block into .I fs_nfree and .I fs_free. .PP To free a block: check if .I fs_nfree is NICFREE; if so, copy .I fs_nfree and the .I fs_free array into the newly freed block, write it out, and set .I fs_nfree to 0. In any event set .I fs_free[fs_nfree] to the freed block's address and increment .I fs_nfree. .PP .IR Fs_isize " and " fs_fsize are used by the system to check for bad block addresses; if an `impossible' block address is allocated from or returned to the free list, a diagnostic is written on the console. Moreover, the free array is cleared, to prevent further allocation from a presumably corrupted free list. .PP .IR Fs_step " and " fs_cyl determine the block interleaving of files for fastest access; traditionally these were referred to as .IR s_m " and " s_n " respectively." .I Fs_step is the distance between successive blocks and .I fs_cyl is the number of blocks before the pattern repeats. A file system's interleaving factors are determined when it is first created by .IR mkfs (8). .I Mkfs lays out the initial free list with these parameters and .IR fsck (8) can be used to rebuild the free list optimally (and assign new interleaving factors if necessary). .PP .IR "Free inode list" : .I Fs_ninode is the number of free inode numbers in the .I fs_inode array. .PP To allocate an inode: if .I fs_ninode is greater than 0, decrement it and return .I fs_inode[fs_ninode]. If it was 0, read through the inode area and place the numbers of all free inodes (up to NICINOD) into the .I fs_inode array, then try again. If a search for free inodes is necessary, the search will start at the beginning of the inode area if .I fs_nbehind >= 4 \(mu NICINOD, otherwise starting at .I fs_lasti and continuing at the beginning of the inode area if NICINOD free inodes aren't found when the end of the inode area is reached. When a search completes the i-number of the first inode of the last block scanned in the search is left in .IR fs_lasti . .PP To free an inode, provided .I fs_ninode is less than NICINODE, place its number into .I fs_inode[fs_ninode] and increment .I fs_ninode. If .I fs_ninode is already NICINODE, don't bother to enter the freed inode into any table .RI ( fs_inode is only to speed up the allocation process; the information as to whether the inode is really free or not is maintained in the inode itself). If the i-number of the freed inode is less than .I fs_lasti increment .IR fs_nbehind . .SH "SEE ALSO" stat(2), dir(5), types(5), dcheck(8), fsck(8), icheck(8), mkfs(8), mount(8) .SH BUGS It isn't the .IR "4BSD fast file system" . The 2BSD file system is a direct descendent of the V7 file system and exists little changed from that ancestor. There are many performance holes in the file system. .PP Some changes from the original V7 file system have resulted in better performance: The larger block size (1Kb as opposed to the 512 byte block size of V7) cuts the average number of system calls necessary to access a file by a factor of two; the smaller (in core) inodes allowed by the smaller number of direct links kept in inodes saves valuable kernel data space allowing the kernel buffer cache to be made larger while sacrificing only 1Kb of direct file accessing; and starting free inode searches at the position the last search ended cuts the time to gather free inodes significantly. .PP However, the separation of inodes and data blocks into completely different areas of the disk, the handling of the free list, the lack of any file allocation layout policy encouraging locality such as that found in the 4BSD file system and the still too small block size often leads to extremely poor performance. .PP The separation of inodes and data blocks in the file system means that to access a file a seek will have to be made to the beginning of the disk partition containing the file system followed another to the the actual data blocks of the file (often quite distant from the inode area). .PP The free list which is laid out at file system creation for optimal file block allocation, becomes scrambled over time on an active file system. This process is slowed down by the kernel which always frees blocks from unlink'ed or truncated files in reverse order thereby maintaining strings of optimally laid out free blocks in the free list. Eventually, however, since both freed and allocated blocks use the head of the free list, it's possible (and quite probable) to have most of the free list laid out optimally with the first portion totally scrambled. As a trade off, a file system's free list may be rebuilt fairly frequently via .I icheck -s or .I fsck -s and most blocks allocated will be localized as close to the the inode area as possible. Because of this problem, files are sometimes scattered across a file system generating an unpleasant amount of disk arm movement. A nasty oscillation also occurs in the free block list when .I fs_nfree hovers around NICFREE and 0 causing the free array to be constantly written out and read back in as blocks are freed and allocated. .PP For a more in depth analysis of the 2BSD file system, its shortcomings, and a description of the changes made for the 4BSD file system see \*(lq\fBA Fast File System for UNIX\fR\*(rq by .IR "M. McKusick" ; .IR "W. Joy" ; .IR "S. Leffler" "; and" .IR "R. Fabry" . ================================================ FILE: share/man/man5/fstab.5 ================================================ .\" Copyright (c) 1980, 1989, 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. All advertising materials mentioning features or use of this software .\" must display the following acknowledgement: .\" This product includes software developed by the University of .\" California, Berkeley and its contributors. .\" 4. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)fstab.5 8.1.1 (2.11BSD) 1996/1/15 .\" .TH FSTAB 5 "January 15, 1996" .UC 7 .SH NAME \fBfstab\fP \- static information about the filesystems .SH SYNOPSIS .B #include .SH DESCRIPTION The file .B fstab contains descriptive information about the various file systems. .B fstab is only read by programs, and not written; it is the duty of the system administrator to properly create and maintain this file. Each filesystem is described on a separate line; fields on each line are separated by tabs or spaces. The order of records in .B fstab is important because fsck(8), mount(8), and umount(8) sequentially iterate through .B fstab doing their thing. .PP The first field, .IR fs_spec , describes the block special device or remote filesystem to be mounted. For filesystems of type .IR ufs , the special file name is the block special file name, and not the character special file name. If a program needs the character special file name, the program must create it by appending a ``r'' after the last ``/'' in the special file name. .PP The second field, .IR fs_file , describes the mount point for the filesystem. For swap partitions, this field should be specified as ``none''. .PP The third field, .IR fs_vfstype , describes the type of the filesystem. The system currently supports only two types of filesystems: .TP 15 .I ufs a local UNIX filesystem .TP 15 .I swap a disk partition to be used for swapping .PP The fourth field, .IR fs_mntops , describes the mount options associated with the filesystem. It is formatted as a comma separated list of options. It contains at least the type of mount (see .I fs_type below) plus any additional options appropriate to the filesystem type. .PP If the option ``quotas'' is specified, the filesystem is automatically processed by the quotacheck(8) command, and user disk quotas are enabled with quotaon(8). Filesystem quotas are maintained in the file named .I quotas located at the root of the associated filesystem. This restriction on the location of the quotas file is needlessly imposed by the kernel but may be lifted in the future. Thus, if the user quota file for .I /tmp is stored in .IR /var/quotas/tmp.user , this location can be specified as: .sp .in +.75i quotas=/var/quotas/tmp.user .br .in -0.75i .PP The type of the mount is extracted from the .I fs_mntops field and stored separately in the .I fs_type field (it is not deleted from the .I fs_mntops field). If .I fs_type is ``rw'' or ``ro'' then the filesystem whose name is given in the .I fs_file field is normally mounted read-write or read-only on the specified special file. If .I fs_type is ``sw'' then the special file is made available as a piece of swap space by the swapon(8) command at the end of the system reboot procedure. The fields other than .I fs_spec and .I fs_type are unused. If .I fs_type is specified as ``xx'' the entry is ignored. This is useful to show disk partitions which are currently unused. .PP The fifth field, .IR fs_freq , is used for these filesystems by the dump(8) command to determine which filesystems need to be dumped. If the fifth field is not present, a value of zero is returned and dump(8) will assume that the filesystem does not need to be dumped. .PP The sixth field, .IR fs_passno , is used by the fsck(8) program to determine the order in which filesystem checks are done at reboot time. The root filesystem should be specified with a .I fs_passno of 1, and other filesystems should have a .I fs_passno of 2. Filesystems within a drive will be checked sequentially, but filesystems on different drives will be checked at the same time to utilize parallelism available in the hardware. If the sixth field is not present or zero, a value of zero is returned and fsck(8) will assume that the filesystem does not need to be checked. .br .nf .cs R 24 #define FSTAB_RW "rw" /* read-write device */ #define FSTAB_RO "ro" /* read-only device */ #define FSTAB_SW "sw" /* swap device */ #define FSTAB_XX "xx" /* ignore totally */ struct fstab { char *fs_spec; /* block special device name */ char *fs_file; /* filesystem path prefix */ char *fs_vfstype; /* type of filesystem */ char *fs_mntops; /* comma separated mount options */ char *fs_type; /* rw, ro, sw, or xx */ int fs_freq; /* dump frequency, in days */ int fs_passno; /* pass number on parallel dump */ }; .fi .cs R .PP The proper way to read records from .I fstab is to use the routines getfsent(3), getfsspec(3), getfstype(3), and getfsfile(3). .SH FILES .TP 15 .I /etc/fstab The file .B fstab resides in .IR /etc . .SH SEE ALSO getfsent(3) .SH HISTORY The .B fstab file format appeared in 4.0BSD. ================================================ FILE: share/man/man5/gettytab.5 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)gettytab.5 6.3.1 (2.11BSD) 1997/3/28 .\" .TH GETTYTAB 5 "March 28, 1997" .UC 5 .SH NAME gettytab \- terminal configuration data base .SH SYNOPSIS /etc/gettytab .SH DESCRIPTION .I Gettytab is a simplified version of the .IR termcap (5) data base used to describe terminal lines. The initial terminal login process .IR getty (8) accesses the .I gettytab file each time it starts, allowing simpler reconfiguration of terminal characteristics. Each entry in the data base is used to describe one class of terminals. .PP There is a default terminal class, .IR default , that is used to set global defaults for all other classes. (That is, the .I default entry is read, then the entry for the class required is used to override particular settings.) .SH CAPABILITIES Refer to .IR termcap (5) for a description of the file layout. The .I default column below lists defaults obtained if there is no entry in the table obtained, nor one in the special .I default table. .nf .ta \w'k0-k9 'u +\w'Type 'u +\w'``/bin/login" 'u \fBName Type Default Description\fR ap bool false terminal uses any parity bk str 0377 alternate end of line character (input break) cb bool false use crt backspace mode ce bool false use crt erase algorithm ck bool false use crt kill algorithm cl str NULL screen clear sequence co bool false console - add \\n after login prompt ds str ^Y delayed suspend character dx bool false set DECCTLQ ec bool false leave echo \s-2OFF\s0 ep bool false terminal uses even parity er str ^? erase character et str ^D end of text (\s-2EOF\s0) character ev str NULL initial enviroment f0 num unused tty mode flags to write messages f1 num unused tty mode flags to read login name f2 num unused tty mode flags to leave terminal as fl str ^O output flush character hc bool false do \s-2NOT\s0 hangup line on last close he str NULL hostname editing string hf bool false enable hardware (rts/cts) flow control hn str hostname hostname ht bool false terminal has real tabs ig bool false ignore garbage characters in login name im str NULL initial (banner) message in str ^C interrupt character is num unused input speed kl str ^U kill character lc bool false terminal has lower case lm str login: login prompt ln str ^V ``literal next'' character lo str /bin/login program to exec when name obtained nl bool false terminal has (or might have) a newline character nx str default next table (for auto speed selection) op bool false terminal uses odd parity os num unused output speed pc str \\0 pad character pe bool false use printer (hard copy) erase algorithm pf num 0 delay between first prompt and following flush (seconds) ps bool false line connected to a MICOM port selector qu str ^\\ quit character rp str ^R line retype character rw bool false do \s-2NOT\s0 use raw for input, use cbreak sp num unused line speed (input and output) su str ^Z suspend character tc str none table continuation to num 0 timeout (seconds) tt str NULL terminal type (for enviroment) ub bool false do unbuffered output (of prompts etc) we str ^W word erase character xc bool false do \s-2NOT\s0 echo control chars as ^X xf str ^S XOFF (stop output) character xn str ^Q XON (start output) character .br .fi .PP If no line speed is specified, speed will not be altered from that which prevails when getty is entered. Specifying an input or output speed will override line speed for stated direction only. .PP Terminal modes to be used for the output of the message, for input of the login name, and to leave the terminal set as upon completion, are derived from the boolean flags specified. If the derivation should prove inadequate, any (or all) of these three may be overriden with one of the .BR f0 , .BR f1 ", or" .B f2 numeric specifications, which can be used to specify (usually in octal, with a leading '0') the exact values of the flags. Local (new tty) flags are set in the top 16 bits of this (32 bit) value. .PP Should .I getty receive a null character (presumed to indicate a line break) it will restart using the table indicated by the .B nx entry. If there is none, it will re-use its original table. .PP The .B cl screen clear string may be preceded by a (decimal) number of milliseconds of delay required (a la termcap). This delay is simulated by repeated use of the pad character .BR pc . .PP The initial message, and login message, .B im and .B lm may include the character sequence \fB%h\fP or \fB%t\fP to obtain the hostname or tty name respectively. (\fB%%\fP obtains a single '%' character.) The hostname is normally obtained from the system, but may be set by the .B hn table entry. In either case it may be edited with .BR he . The .B he string is a sequence of characters, each character that is neither '@' nor '#' is copied into the final hostname. A '@' in the .B he string, causes one character from the real hostname to be copied to the final hostname. A '#' in the .B he string, causes the next character of the real hostname to be skipped. Surplus '@' and '#' characters are ignored. .PP When getty execs the login process, given in the .B lo string (usually "/bin/login"), it will have set the enviroment to include the terminal type, as indicated by the .B tt string (if it exists). The .B ev string, can be used to enter additional data into the environment. It is a list of comma separated strings, each of which will presumably be of the form .IR name=value . .PP If a non-zero timeout is specified, with .BR to , then getty will exit within the indicated number of seconds, either having received a login name and passed control to .IR login , or having received an alarm signal, and exited. This may be useful to hangup dial in lines. .PP Output from .I getty is even parity unless .B op is specified. .B Op may be specified with .B ap to allow any parity on input, but generate odd parity output. Note: this only applies while getty is being run, terminal driver limitations prevent a more complete implementation. .I Getty does not check parity of input characters in .I RAW mode. .SH "SEE ALSO" login(1), termcap(5), getty(8). .SH BUGS The special characters (erase, kill, etc.) are reset to system defaults by .IR login (1). In .B all cases, '#' or '^H' typed in a login name will be treated as an erase character, and '@' will be treated as a kill character. .PP The delay stuff is a real crock. It has been removed from the system entirely. The .B he capability is stupid. .PP .I Termcap format is horrid, something more rational should have been chosen. ================================================ FILE: share/man/man5/group.5 ================================================ .\" @(#)group.5 6.1 (Berkeley) 5/15/85 .\" .TH GROUP 5 "May 15, 1985" .AT 3 .SH NAME group \- group file .SH DESCRIPTION .I Group contains for each group the following information: .HP 10 group name .br .ns .HP 10 encrypted password .br .ns .HP 10 numerical group ID .br .ns .HP 10 a comma separated list of all users allowed in the group .PP This is an ASCII file. The fields are separated by colons; Each group is separated from the next by a new-line. If the password field is null, no password is demanded. .PP This file resides in directory /etc. Because of the encrypted passwords, it can and does have general read permission and can be used, for example, to map numerical group ID's to names. .SH FILES /etc/group .SH "SEE ALSO" setgroups(2), initgroups(3X), crypt(3), passwd(1), passwd(5) .SH BUGS The .IR passwd (1) command won't change the passwords. ================================================ FILE: share/man/man5/hosts.5 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)hosts.5 6.3 (Berkeley) 5/14/86 .\" .TH HOSTS 5 "May 14, 1986" .UC 5 .SH NAME hosts \- host name data base .SH DESCRIPTION The .I hosts file contains information regarding the known hosts on the network. For each host a single line should be present with the following information: .HP 10 official host name .br .ns .HP 10 Internet address .br .ns .HP 10 aliases .PP Items are separated by any number of blanks and/or tab characters. A ``#'' indicates the beginning of a comment; characters up to the end of the line are not interpreted by routines which search the file. .PP When using the name server .IR named (8), this file provides a backup when the name server is not running. For the name server, it is suggested that only a few addresses be included in this file. These include address for the local interfaces that .IR ifconfig (8C) needs at boot time and a few machines on the local network. .PP This file may be created from the official host data base maintained at the Network Information Control Center (NIC), though local changes may be required to bring it up to date regarding unofficial aliases and/or unknown hosts. As the data base maintained at NIC is incomplete, use of the name server is recommend for sites on the DARPA Internet. .PP Network addresses are specified in the conventional ``.'' notation using the \fIinet_addr\fP() routine from the Internet address manipulation library, .IR inet (3N). Host names may contain any printable character other than a field delimiter, newline, or comment character. .SH FILES /etc/hosts .SH "SEE ALSO" gethostbyname(3N), ifconfig(8C), named(8) .br Name Server Operations Guide for BIND ================================================ FILE: share/man/man5/intro.5 ================================================ .\" $OpenBSD: intro.5,v 1.9 2018/09/30 13:24:32 schwarze Exp $ .\" .\" Copyright (c) 1999 Hugh Graham .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .Dd May 22, 2025 .Dt INTRO 5 .Os .Sh NAME .Nm intro .Nd introduction to file formats .Sh DESCRIPTION The manual pages in section 5 contain information related to file formats, including: .Pp .Bl -bullet -offset indent -compact .It ASCII configuration and resource files .It system binary file structures .It composition of database files .El .Sh HISTORY An .Nm manual for section 5 appeared in .Bx Disco 2.5. ================================================ FILE: share/man/man5/map3270.5 ================================================ .\" Copyright (c) 1986 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)map3270.5 1.3.1 (2.11BSD) 1996/11/27 .\" .TH MAP3270 5 "November 27, 1996" .UC 6 .SH NAME map3270 \- database for mapping ascii keystrokes into IBM 3270 keys .SH SYNOPSIS .B /usr/share/misc/map3270 .SH DESCRIPTION When emulating IBM-syle 3270 terminals under UNIX (see \fItn3270\fR(1)), a mapping must be performed between sequences of keys hit on a user's (ascii) keyboard, and the keys that are available on a 3270. For example, a 3270 has a key labeled .B EEOF which erases the contents of the current field from the location of the cursor to the end. In order to accomplish this function, the terminal user and a program emulating a 3270 must agree on what keys will be typed to invoke the .B EEOF function. .PP The requirements for these sequences are: .nf .ta 4n 9n .sp 1.) that the first character of the sequence be outside of the standard ascii printable characters; .sp 2.) that no one sequence \fIbe\fR an initial part of another (although sequences may \fIshare\fR initial parts). .sp .fi .SH FORMAT The file consists of entries for various terminals. The first part of an entry lists the names of the terminals which use that entry. These names should be the same as in .I /etc/termcap (see \fItermcap\fR(5)); note that often the terminals from various termcap entries will all use the same .I map3270 entry; for example, both 925 and 925vb (for 925 with visual bells) would probably use the same .I map3270 entry. After the names, separated by vertical bars (`|'), comes a left brace (`{'); the definitions; and, finally, a right brace (`}'). .PP The definitions consist of a reserved keyword (see list below) which identifies the 3270 function (extended as defined below), followed by an equal sign (`='), followed by the various ways to generate this particular function, followed by a semi-colon (`;'). Each way is a sequence of strings of .I printable ascii characters enclosed inside single quotes (`\(aa'); various ways (options) are separated by vertical bars (`|'). .PP Inside the single quotes, a few characters are special. A caret (`^') specifies that the next character is the ``control'' character of whatever the character is. So, `^a' represents control-a, ie: hexadecimal 1 (note that `^A' would generate the same code). To generate .B rubout, one enters `^?'. To represent a control character inside a file requires using the caret to represent a control sequence; simply typing control-A will not work. Note: the ctrl-caret sequence (to generate a hexadecimal 1E) is represented as `^^' (not `^\e^'). .PP In addition to the caret, a letter may be preceeded by a backslash (`\e'). Since this has little effect for most characters, its use is usually not recommended. For the case of a single quote (`\(aa'), the backslash prevents that single quote from terminating the string. To have the backslash be part of the string, it is necessary to place two backslashes ('\e\e') in the file. .PP In addition, the following characters are special: .sp .nf .in +0.5i `\eE' means an escape character; `\en' means newline; `\et' means tab; `\er' means carriage return. .in -0.5i .fi .sp It is not necessary for each character in a string to be enclosed within single quotes. `\eE\eE\eE' means three escape characters. .PP Comments, which may appear anywhere on a line, begin with a hash mark (`#'), and terminate at the end of that line. However, comments cannot begin inside a quoted string; a hash mark inside a quoted string has no special meaning. .PP .SH 3270 KEYS SUPPORTED The following is the list of 3270 key names that are supported in this file. Note that some of the keys don't really exist on a 3270. In particular, the developers of this file have relied extensively on the work at the Yale University Computer Center with their 3270 emulator which runs in an IBM Series/1 front end. The following list corresponds closely to the functions that the developers of the Yale code offer in their product. .sp .B In the following list, the .B starred ("*") .B functions are not supported by .IR tn3270 (1). An unsupported function will cause .IR tn3270(1) to send a bell sequence to the user's terminal. .sp .nf 3270 Key Name Functional description (*)LPRT local print DP dup character FM field mark character (*)CURSEL cursor select RESHOW redisplay the screen EINP erase input EEOF erase end of field DELETE delete character INSRT toggle insert mode TAB field tab BTAB field back tab COLTAB column tab COLBAK column back tab INDENT indent one tab stop UNDENT undent one tab stop NL new line HOME home the cursor UP up cursor DOWN down cursor RIGHT right cursor LEFT left cursor SETTAB set a column tab DELTAB delete a columntab SETMRG set left margin SETHOM set home position CLRTAB clear all column tabs (*)APLON apl on (*)APLOFF apl off (*)APLEND treat input as ascii (*)PCON xon/xoff on (*)PCOFF xon/xoff off DISC disconnect (suspend) (*)INIT new terminal type (*)ALTK alternate keyboard dvorak FLINP flush input ERASE erase last character WERASE erase last word FERASE erase field SYNCH we are in synch with the user RESET reset key-unlock keyboard MASTER_RESET reset, unlock and redisplay (*)XOFF please hold output (*)XON please give me output ESCAPE enter telnet command mode WORDTAB tab to beginning of next word WORDBACKTAB tab to beginning of current/last word WORDEND tab to end of current/next word FIELDEND tab to last non-blank of current/next unprotected (writable) field. PA1 program attention 1 PA2 program attention 2 PA3 program attention 3 CLEAR local clear of the 3270 screen TREQ test request ENTER enter key PFK1 program function key 1 PFK2 program function key 2 etc. etc. PFK36 program function key 36 .SH A SAMPLE ENTRY The following entry is used by tn3270(1) when unable to locate a reasonable version in the user's environment and in /usr/share/misc/map3270: .sp .nf name { # actual name comes from TERM variable clear = '^z'; flinp = '^x'; enter = '^m'; delete = '^d' | '^?'; # note that '^?' is delete (rubout) synch = '^r'; reshow = '^v'; eeof = '^e'; tab = '^i'; btab = '^b'; nl = '^n'; left = '^h'; right = '^l'; up = '^k'; down = '^j'; einp = '^w'; reset = '^t'; xoff = '^s'; xon = '^q'; escape = '^c'; ferase = '^u'; insrt = '\E '; # program attention keys pa1 = '^p1'; pa2 = '^p2'; pa3 = '^p3'; # program function keys pfk1 = '\eE1'; pfk2 = '\eE2'; pfk3 = '\eE3'; pfk4 = '\eE4'; pfk5 = '\eE5'; pfk6 = '\eE6'; pfk7 = '\eE7'; pfk8 = '\eE8'; pfk9 = '\eE9'; pfk10 = '\eE0'; pfk11 = '\eE-'; pfk12 = '\eE='; pfk13 = '\eE!'; pfk14 = '\eE@'; pfk15 = '\eE#'; pfk16 = '\eE$'; pfk17 = '\eE%'; pfk18 = '\eE'; pfk19 = '\eE&'; pfk20 = '\eE*'; pfk21 = '\eE('; pfk22 = '\eE)'; pfk23 = '\eE_'; pfk24 = '\eE+'; } .fi .SH "IBM 3270 KEY DEFINITONS FOR AN ABOVE DEFINITION" The charts below show the proper keys to emulate each 3270 function when using the default key mapping supplied with .IR tn3270 (1) and .IR mset (1). .sp .nf Command Keys IBM 3270 Key Default Key(s) Enter RETURN Clear control-z Cursor Movement Keys New Line control-n or Home Tab control-i Back Tab control-b Cursor Left control-h Cursor Right control-l Cursor Up control-k Cursor Down control-j or LINE FEED Edit Control Keys Delete Char control-d or RUB Erase EOF control-e Erase Input control-w Insert Mode ESC Space End Insert ESC Space Program Function Keys PF1 ESC 1 PF2 ESC 2 ... ... PF10 ESC 0 PF11 ESC - PF12 ESC = PF13 ESC ! PF14 ESC @ ... ... PF24 ESC + Program Attention Keys PA1 control-p 1 PA2 control-p 2 PA3 control-p 3 Local Control Keys Reset After Error control-r Purge Input Buffer control-x Keyboard Unlock control-t Redisplay Screen control-v Other Keys Erase current field control-u .fi .SH FILES /usr/share/misc/map3270 .SH SEE ALSO tn3270(1), mset(1), \fIYale ASCII Terminal Communication System II Program Description/Operator's Manual\fR (IBM SB30-1911) .SH AUTHOR Greg Minshall .SH BUGS .I Tn3270 doesn't yet understand how to process all the functions available in .I map3270; when such a function is requested .I tn3270 will beep at you. .PP The definition of "word" (for "word delete", "word tab") should be a run-time option. Currently it is defined as the kernel tty driver defines it (strings of non-blanks); more than one person would rather use the "vi" definition (strings of specials, strings of alphanumeric). ================================================ FILE: share/man/man5/networks.5 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)networks.5 6.2 (Berkeley) 5/6/86 .\" .TH NETWORKS 5 "May 6, 1986" .UC 5 .SH NAME networks \- network name data base .SH DESCRIPTION The .I networks file contains information regarding the known networks which comprise the DARPA Internet. For each network a single line should be present with the following information: .HP 10 official network name .br .ns .HP 10 network number .br .ns .HP 10 aliases .PP Items are separated by any number of blanks and/or tab characters. A ``#'' indicates the beginning of a comment; characters up to the end of the line are not interpreted by routines which search the file. This file is normally created from the official network data base maintained at the Network Information Control Center (NIC), though local changes may be required to bring it up to date regarding unofficial aliases and/or unknown networks. .PP Network number may be specified in the conventional ``.'' notation using the \fIinet_network\fP() routine from the Internet address manipulation library, .IR inet (3N). Network names may contain any printable character other than a field delimiter, newline, or comment character. .SH FILES /etc/networks .SH "SEE ALSO" getnetent(3N) .SH BUGS A name server should be used instead of a static file. ================================================ FILE: share/man/man5/passwd.5 ================================================ .\" Copyright (c) 1988 The Regents of the University of California. .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms are permitted .\" provided that the above copyright notice and this paragraph are .\" duplicated in all such forms and that any documentation, .\" advertising materials, and other materials related to such .\" distribution and use acknowledge that the software was developed .\" by the University of California, Berkeley. The name of the .\" University may not be used to endorse or promote products derived .\" from this software without specific prior written permission. .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR .\" IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED .\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. .\" .\" @(#)passwd.5 6.5 (Berkeley) 5/8/89 .\" .TH PASSWD 5 "May 8, 1989" .AT 3 .SH NAME passwd \- password files .SH DESCRIPTION .I Passwd files are files consisting of newline separated records, one per user, containing ten colon (``:'') separated fields. These fields are as follows: .PP .RS name user's login name password user's \fIencrypted\fP password uid user's id gid user's login group id class user's general classification (unused) change password change time expire account expiration time gecos general information about the user home_dir user's home directory shell user's login shell .RE .PP The .I name field is the login used to access the computer account, and the .I uid field is the number associated with it. They should both be unique across the system (and often across a group of systems) since they control file access. .PP While it is possible to have multiple entries with identical login names and/or identical user id's, it is usually a mistake to do so. Routines that manipulate these files will often return only one of the multiple entries, and that one by random selection. .PP The login name must never begin with a hyphen (``-''); also, it is strongly suggested that neither upper-case characters or dots (``.'') be part of the name, as this tends to confuse mailers. No field may contain a colon (``:'') as this has been used historically to separate the fields in the user database. .PP The password field is the .I encrypted form of the password. If the .I password field is empty, no password will be required to gain access to the machine. This is almost invariably a mistake. Because these files contain the encrypted user passwords, they should not be readable by anyone without appropriate privileges. .PP The group field is the group that the user will be placed in upon login. Since this system supports multiple groups (see .IR groups (1)) this field currently has little special meaning. .PP The .I class field is currently unused. In the near future it will be a key to a .IR termcap (5) style database of user attributes. .PP The .I change field is the number in seconds, GMT, from the epoch, until the password for the account must be changed. This field may be left empty to turn off the password aging feature. .PP The .I expire field is the number in seconds, GMT, from the epoch, until the account expires. This field may be left empty to turn off the account aging feature. .PP The .I gecos field normally contains comma (``,'') separated subfields as follows: .PP .RS name user's full name office user's office number wphone user's work phone number hphone user's home phone number .RE .PP This information is used by the .IR finger (1) program. .PP The user's home directory is the full UNIX path name where the user will be placed on login. .PP The shell field is the command interpreter the user prefers. If the .I shell field is empty, the Bourne shell (\fI/bin/sh\fP) is assumed. .SH "SEE ALSO" chpass(1), login(1), passwd(1), getpwent(3), mkpasswd(8), vipw(8) adduser(8) .SH BUGS User information should (and eventually will) be stored elsewhere. ================================================ FILE: share/man/man5/phones.5 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)phones.5 6.2 (Berkeley) 5/16/86 .\" .TH PHONES 5 "May 16, 1986" .UC 5 .SH NAME phones \- remote host phone number data base .SH DESCRIPTION The file /etc/phones contains the system-wide private phone numbers for the .IR tip (1C) program. This file is normally unreadable, and so may contain privileged information. The format of the file is a series of lines of the form: [\ \et]*. The system name is one of those defined in the .IR remote (5) file and the phone number is constructed from any sequence of characters terminated only by ``,'' or the end of the line. The ``='' and ``*'' characters are indicators to the auto call units to pause and wait for a second dial tone (when going through an exchange). The ``='' is required by the DF02-AC and the ``*'' is required by the BIZCOMP 1030. .PP Only one phone number per line is permitted. However, if more than one line in the file contains the same system name .IR tip (1C) will attempt to dial each one in turn, until it establishes a connection. .SH FILES /etc/phones .SH "SEE ALSO" tip(1C), remote(5) ================================================ FILE: share/man/man5/plot.5 ================================================ .\" @(#)plot.5 6.1 (Berkeley) 5/15/85 .\" .TH PLOT 5 "May 15, 1985" .AT 3 .SH NAME plot \- graphics interface .SH DESCRIPTION Files of this format are produced by routines described in .IR plot (3X) and .IR plot (3F), and are interpreted for various devices by commands described in .IR plot (1G). A graphics file is a stream of plotting instructions. Each instruction consists of an ASCII letter usually followed by bytes of binary information. The instructions are executed in order. A point is designated by four bytes representing the x and y values; each value is a signed integer. The last designated point in an .B "l, m, n, a," or .B p instruction becomes the `current point' for the next instruction. The .B a and .B c instructions change the current point in a manner dependent upon the specific device. .PP Each of the following descriptions begins with the name of the corresponding routine in .IR plot (3X). .TP 3 .B m move: The next four bytes give a new current point. .TP 3 .B n cont: Draw a line from the current point to the point given by the next four bytes. .TP 3 .B p point: Plot the point given by the next four bytes. .TP 3 .B l line: Draw a line from the point given by the next four bytes to the point given by the following four bytes. .TP 3 .B t label: Place the following ASCII string so that its first character falls on the current point. The string is terminated by a newline. .TP 3 .B a arc: The first four bytes give the center, the next four give the starting point, and the last four give the end point of a circular arc. The least significant coordinate of the end point is used only to determine the quadrant. The arc is drawn counter-clockwise. .TP 3 .B c circle: The first four bytes give the center of the circle, the next two the radius. .TP 3 .B e erase: Start another frame of output. .TP 3 .B f linemod: Take the following string, up to a newline, as the style for drawing further lines. The styles are `dotted,' `solid,' `longdashed,' `shortdashed,' and `dotdashed.' Effective only in .I plot 4014 and .I plot ver. .TP 3 .B s space: The next four bytes give the lower left corner of the plotting area; the following four give the upper right corner. The plot will be magnified or reduced to fit the device as closely as possible. .IP Space settings that exactly fill the plotting area with unity scaling appear below for devices supported by the filters of .IR plot (1G). The upper limit is just outside the plotting area. In every case the plotting area is taken to be square; points outside may be displayable on devices whose face isn't square. .RS .TP 10n 4013 space(0, 0, 780, 780); .br .ns .TP 10n 4014 space(0, 0, 3120, 3120); .br .ns .TP ver space(0, 0, 2048, 2048); .br .ns .TP 300, 300s space(0, 0, 4096, 4096); .br .ns .TP 450 space(0, 0, 4096, 4096); .RE .SH "SEE ALSO" plot(1G), plot(3X), plot(3F), graph(1G) ================================================ FILE: share/man/man5/printcap.5 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)printcap.5 6.4 (Berkeley) 5/14/86 .\" .TH PRINTCAP 5 "May 14, 1986" .UC 5 .ad .SH NAME printcap \- printer capability data base .SH SYNOPSIS /etc/printcap .SH DESCRIPTION .I Printcap is a simplified version of the .IR termcap (5) data base used to describe line printers. The spooling system accesses the .I printcap file every time it is used, allowing dynamic addition and deletion of printers. Each entry in the data base is used to describe one printer. This data base may not be substituted for, as is possible for .IR termcap , because it may allow accounting to be bypassed. .PP The default printer is normally .IR lp , though the environment variable PRINTER may be used to override this. Each spooling utility supports an option, .BI \-P printer, to allow explicit naming of a destination printer. .PP Refer to the .ul 4.3BSD Line Printer Spooler Manual for a complete discussion on how setup the database for a given printer. .SH CAPABILITIES Refer to .IR termcap (5) for a description of the file layout. .nf .ta \w'k0-k9 'u +\w'Type 'u +\w'``/usr/spool/lpd\'\' 'u \fBName Type Default Description\fR af str NULL name of accounting file br num none if lp is a tty, set the baud rate (ioctl call) cf str NULL cifplot data filter df str NULL tex data filter (DVI format) fc num 0 if lp is a tty, clear flag bits (sgtty.h) ff str ``\ef'' string to send for a form feed fo bool false print a form feed when device is opened fs num 0 like `fc' but set bits gf str NULL graph data filter (plot (3X) format) hl bool false print the burst header page last ic bool false driver supports (non standard) ioctl to indent printout if str NULL name of text filter which does accounting lf str ``/dev/console'' error logging file name lo str ``lock'' name of lock file lp str ``/dev/lp'' device name to open for output mx num 1000 maximum file size (in BUFSIZ blocks), zero = unlimited nd str NULL next directory for list of queues (unimplemented) nf str NULL ditroff data filter (device independent troff) of str NULL name of output filtering program pc num 200 price per foot or page in hundredths of cents pl num 66 page length (in lines) pw num 132 page width (in characters) px num 0 page width in pixels (horizontal) py num 0 page length in pixels (vertical) rf str NULL filter for printing FORTRAN style text files rg str NULL restricted group. Only members of group allowed access rm str NULL machine name for remote printer rp str ``lp'' remote printer name argument rs bool false restrict remote users to those with local accounts rw bool false open the printer device for reading and writing sb bool false short banner (one line only) sc bool false suppress multiple copies sd str ``/usr/spool/lpd'' spool directory sf bool false suppress form feeds sh bool false suppress printing of burst page header st str ``status'' status file name tf str NULL troff data filter (cat phototypesetter) tr str NULL trailer string to print when queue empties vf str NULL raster image filter xc num 0 if lp is a tty, clear local mode bits (tty (4)) xs num 0 like `xc' but set bits .fi .PP If the local line printer driver supports indentation, the daemon must understand how to invoke it. .SH FILTERS The .IR lpd (8) daemon creates a pipeline of .I filters to process files for various printer types. The filters selected depend on the flags passed to .IR lpr (1). The pipeline set up is: .RS .PP .nf .ta 0.5i +1i \-p pr | if regular text + \fIpr\fP(1) none if regular text \-c cf cifplot \-d df DVI (tex) \-g gf \fIplot\fP(3) \-n nf ditroff \-f rf Fortran \-t tf troff \-v vf raster image .fi .RE .PP The .B if filter is invoked with arguments: .PP \fIif\fP [ \fB\-c\fP ] \fB\-w\fPwidth \fB\-l\fPlength \fB\-i\fPindent \fB\-n\fP login \fB\-h\fP host acct-file .PP The .B \-c flag is passed only if the .B \-l flag (pass control characters literally) is specified to .IR lpr . .I Width and .I length specify the page width and length (from .B pw and .B pl respectively) in characters. The .B \-n and .B \-h parameters specify the login name and host name of the owner of the job respectively. .I Acct-file is passed from the .B af .I printcap entry. .PP If no .B if is specified, .B of is used instead, with the distinction that .B of is opened only once, while .B if is opened for every individual job. Thus, .B if is better suited to performing accounting. The .B of is only given the .I width and .I length flags. .PP All other filters are called as: .PP \fIfilter\fP \fB\-x\fPwidth \fB\-y\fPlength \fB\-n\fP login \fB\-h\fP host acct-file .PP where .I width and .I length are represented in pixels, specified by the .B px and .B py entries respectively. .PP All filters take .I stdin as the file, .I stdout as the printer, may log either to .I stderr or using .IR syslog (3), and must not ignore .SM SIGINT. .SH LOGGING Error messages generated by the line printer programs themselves (that is, the .IR lp * programs) are logged by .IR syslog (3) using the .I LPR facility. Messages printed on .I stderr of one of the filters are sent to the corresponding .B lf file. The filters may, of course, use .I syslog themselves. .PP Error messages sent to the console have a carriage return and a line feed appended to them, rather than just a line feed. .SH "SEE ALSO" termcap(5), lpc(8), lpd(8), pac(8), lpr(1), lpq(1), lprm(1) .br .ul 4.3BSD Line Printer Spooler Manual ================================================ FILE: share/man/man5/protocols.5 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)protocols.5 6.2 (Berkeley) 5/6/86 .\" .TH PROTOCOLS 5 "May 6, 1986" .UC 5 .SH NAME protocols \- protocol name data base .SH DESCRIPTION The .I protocols file contains information regarding the known protocols used in the DARPA Internet. For each protocol a single line should be present with the following information: .HP 10 official protocol name .br .ns .HP 10 protocol number .br .ns .HP 10 aliases .PP Items are separated by any number of blanks and/or tab characters. A ``#'' indicates the beginning of a comment; characters up to the end of the line are not interpreted by routines which search the file. .PP Protocol names may contain any printable character other than a field delimiter, newline, or comment character. .SH FILES /etc/protocols .SH "SEE ALSO" getprotoent(3N) .SH BUGS A name server should be used instead of a static file. ================================================ FILE: share/man/man5/remote.5 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)remote.5 6.1 (Berkeley) 5/15/85 .\" .TH REMOTE 5 "May 15, 1985" .UC 5 .SH NAME remote \- remote host description file .SH DESCRIPTION The systems known by .IR tip (1C) and their attributes are stored in an ASCII file which is structured somewhat like the .IR termcap (5) file. Each line in the file provides a description for a single .IR system . Fields are separated by a colon (``:''). Lines ending in a \e character with an immediately following newline are continued on the next line. .PP The first entry is the name(s) of the host system. If there is more than one name for a system, the names are separated by vertical bars. After the name of the system comes the fields of the description. A field name followed by an `=' sign indicates a string value follows. A field name followed by a `#' sign indicates a following numeric value. .PP Entries named ``tip*'' and ``cu*'' are used as default entries by .IR tip , and the .I cu interface to .IR tip , as follows. When .I tip is invoked with only a phone number, it looks for an entry of the form ``tip300'', where 300 is the baud rate with which the connection is to be made. When the .I cu interface is used, entries of the form ``cu300'' are used. .SH CAPABILITIES Capabilities are either strings (str), numbers (num), or boolean flags (bool). A string capability is specified by .IR capability = value ; e.g. ``dv=/dev/harris''. A numeric capability is specified by .IR capability # value ; e.g. ``xa#99''. A boolean capability is specified by simply listing the capability. .TP 0.5i .B at (str) Auto call unit type. .TP 0.5i .B br (num) The baud rate used in establishing a connection to the remote host. This is a decimal number. The default baud rate is 300 baud. .TP 0.5i .B cm (str) An initial connection message to be sent to the remote host. For example, if a host is reached through port selector, this might be set to the appropriate sequence required to switch to the host. .TP 0.5i .B cu (str) Call unit if making a phone call. Default is the same as the `dv' field. .TP 0.5i .B di (str) Disconnect message sent to the host when a disconnect is requested by the user. .TP 0.5i .B du (bool) This host is on a dial-up line. .TP 0.5i .B dv (str) UNIX device(s) to open to establish a connection. If this file refers to a terminal line, .IR tip (1C) attempts to perform an exclusive open on the device to insure only one user at a time has access to the port. .TP 0.5i .B el (str) Characters marking an end-of-line. The default is NULL. `~' escapes are only recognized by .I tip after one of the characters in `el', or after a carriage-return. .TP 0.5i .B fs (str) Frame size for transfers. The default frame size is equal to BUFSIZ. .TP 0.5i .B hd (bool) The host uses half-duplex communication, local echo should be performed. .TP 0.5i .B ie (str) Input end-of-file marks. The default is NULL. .TP 0.5i .B oe (str) Output end-of-file string. The default is NULL. When .I tip is transferring a file, this string is sent at end-of-file. .TP 0.5i .B pa (str) The type of parity to use when sending data to the host. This may be one of ``even'', ``odd'', ``none'', ``zero'' (always set bit 8 to zero), ``one'' (always set bit 8 to 1). The default is even parity. .TP 0.5i .B pn (str) Telephone number(s) for this host. If the telephone number field contains an @ sign, .I tip searches the file .I /etc/phones file for a list of telephone numbers; c.f. .IR phones (5). .TP 0.5i .B tc (str) Indicates that the list of capabilities is continued in the named description. This is used primarily to share common capability information. .PP Here is a short example showing the use of the capability continuation feature: .PP .nf .ta 0.5i UNIX-1200:\e :dv=/dev/cau0:el=^D^U^C^S^Q^O@:du:at=ventel:ie=#$%:oe=^D:br#1200: arpavax|ax:\e :pn=7654321%:tc=UNIX-1200 .fi .SH FILES /etc/remote .SH "SEE ALSO" tip(1C), phones(5) ================================================ FILE: share/man/man5/resolver.5 ================================================ .\" Copyright (c) 1986 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)resolver.5 1.6 (Berkeley) 9/14/87 .\" .TH RESOLVER 5 "September 14, 1987" .UC 4 .SH NAME resolver \- resolver configuration file .SH SYNOPSIS /etc/resolv.conf .SH DESCRIPTION .LP The resolver configuration file contains information that is read by the resolver routines the first time they are invoked by a process. The file is designed to be human readable and contains a list of name-value pairs that provide various types of resolver information. .LP On a normally configured system this file should not be necessary. The only name server to be queried will be on the local machine and the domain name is retrieved from the system. .LP The different configuration options are: .TP \fBnameserver\fP followed by the Internet address (in dot notation) of a name server that the resolver should query. At least one name server should be listed. Up to MAXNS (currently 3) name servers may be listed, in that case the resolver library queries tries them in the order listed. If no \fBnameserver\fP entries are present, the default is to use the name server on the local machine. (The algorithm used is to try a name server, and if the query times out, try the next, until out of name servers, then repeat trying all the name servers until a maximum number of retries are made). .TP \fBdomain\fP followed by a domain name, that is the default domain to append to names that do not have a dot in them. If no \fBdomain\fP entries are present, the domain returned by \fIgethostname\fP\|(2) is used (everything after the first `.'). Finally, if the host name does not contain a domain part, the root domain is assumed. .LP The name value pair must appear on a single line, and the keyword (e.g. \fBnameserver\fP) must start the line. The value follows the keyword, separated by white space. .SH FILES .I /etc/resolv.conf .SH SEE ALSO gethostbyname(3N), resolver(3), named(8) .br Name Server Operations Guide for BIND ================================================ FILE: share/man/man5/services.5 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)services.5 6.2 (Berkeley) 5/6/86 .\" .TH SERVICES 5 "May 6, 1986" .UC 5 .SH NAME services \- service name data base .SH DESCRIPTION The .I services file contains information regarding the known services available in the DARPA Internet. For each service a single line should be present with the following information: .HP 10 official service name .br .ns .HP 10 port number .br .ns .HP 10 protocol name .br .ns .HP 10 aliases .PP Items are separated by any number of blanks and/or tab characters. The port number and protocol name are considered a single .IR item ; a ``/'' is used to separate the port and protocol (e.g. ``512/tcp''). A ``#'' indicates the beginning of a comment; characters up to the end of the line are not interpreted by routines which search the file. .PP Service names may contain any printable character other than a field delimiter, newline, or comment character. .SH FILES /etc/services .SH "SEE ALSO" getservent(3N) .SH BUGS A name server should be used instead of a static file. ================================================ FILE: share/man/man5/shells.5 ================================================ .\" Copyright (c) 1986 The Regents of the University of California. .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms are permitted .\" provided that the above copyright notice and this paragraph are .\" duplicated in all such forms and that any documentation, .\" advertising materials, and other materials related to such .\" distribution and use acknowledge that the software was developed .\" by the University of California, Berkeley. The name of the .\" University may not be used to endorse or promote products derived .\" from this software without specific prior written permission. .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR .\" IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED .\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. .\" .\" @(#)shells.5 5.2 (Berkeley) 2/23/89 .\" .TH SHELLS 5 "February 23, 1989" .UC 5 .SH NAME shells \- shell database .SH DESCRIPTION The .I shells file contains a list of the shells on the system. For each shell a single line should be present, consisting of the shell's path, relative to root. .PP A hash mark (``#'') indicates the beginning of a comment; subsequent characters up to the end of the line are not interpreted by the routines which search the file. Blank lines are also ignored. .SH FILES /etc/shells .SH "SEE ALSO" getusershell(3) ================================================ FILE: share/man/man5/stack.5 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)stack.5 2.3 (Berkeley) 6/24/87 .\" .TH STACK 5 "June 24, 1987" .UC 2 .SH NAME stack \- 2.10BSD PDP-11 C stack frame conventions .SH DESCRIPTION The standard C stack frame layout: .RS .nf .ta 8 16 24 32 40 48 56 64 ------------------ |...nth argument | push arguments in reverse order ------------------ |second argument | ------------------ | first argument | ------------------ JSR PC,*$_FOO | return address | ------------------ JSR R5,CSV | old R5 value | <----- ------------------ | |previous overlay| | | number | | ------------------ | | r4 | | ------------------ | | r3 | | ------------------ | | r2 | | ------------------ | | first local var| | This is the top of the stack ------------------ | when the called routine ``starts'' | routine | | | allocates | | | storage | | SUB $n,SP | temporary | | ------------------ | | push arguments | | | of next routine| | ------------------ | JSR PC,*$_BAR | return address | | ------------------ | JSR R5,CSV | old R5 value---+------- ------------------ ^ |previous overlay| | | number | | ------------------ | | r4/43/r2/... | | ------------------ | and so on..... | .fi .RE .DT .PP The stack pushes downward through memory addresses. Overlay numbers saved in non-overlaid objects are always zero, but the simplification of not having to maintain two different stack frame formats more than outweighs the extra few micro seconds (less than four) necessary to save the zero ... .PP Functions returning integers leave their return value in R0; functions returning floating constants use FR0; functions returning longs leave return values in R1/R0 (R0 high word, R1 low); functions returning structures leave a pointer to bss storage (one chunk of which is allocated for each such routine) in R0, and the caller will copy from that bss storage to the local destination. .PP Local variables are allocated in such a way that they are referred to as ``-N(R5)'', arguments are referred to as ``+N(R5)''; arguments start at 4(R5), the first integer local declared will be at -10(R5). .PP The SP normally points at the first word available for parameter pushing. A function taking only single word as a parameter can be called simply by moving the parameter into (SP) and calling the function, without having to clean the parameter off the stack on return. Any parameters passed after the first (actually "Nth") must be pushed before the call and cleaned off afterwards. If the function has no local variables and calls no functions, it will allocate no stack and the word labelled ``first local var'' will be unused. .PP It is important to note that routines know how many arguments they pass to a function, and will adjust the stack accordingly after a function returns. .SH NOTE This stack frame format is the same as that used by overlaid objects in 2.9BSD. .SH AUTHOR John F. Woods, MIT Concouse Computer Center ================================================ FILE: share/man/man5/syserrlst.5 ================================================ .\" Public Domain, March 196, Steven M. Schultz .\" .\" @(#)syserrlst.5 1.0 (2.11BSD) 1996/3/7 .\" .TH SYSERRLST 5 "March 7, 1996" .UC 2 .SH NAME syserrlst \- error message file format .SH DESCRIPTION .IR mkerrlst (1), creates error message files in the format described below. .PP An ``error message file'' consists of a header, an array of structures specifying the offset and length of each message, and the array of message strings separated by newlines. .PP The message strings are separated by newlines but the newline characters are \fBnot\fP included in the size of the message. These newline characters serve only to make the file editable or printable (after stripping off the header). .PP The file format is: .PP .nf .cs R 20 /* * Definitions used by the 'mkerrlst' program which creates error message * files. * * The format of the file created is: * * struct ERRLSTHDR ehdr; * struct ERRLST emsg[num_of_messages]; * struct { * char msg[] = "error message string"; * char lf = '\n'; * } [num_of_messages]; * * Note: the newlines are NOT included in the message lengths, the newlines * are present to make it easy to 'cat' or 'vi' the file. */ struct ERRLSTHDR { short magic; short maxmsgnum; short maxmsglen; short pad[5]; /* Reserved */ }; struct ERRLST { off_t offmsg; short lenmsg; }; #define ERRMAGIC 012345 .fi .cs R .SH "SEE ALSO" mkerrlst(1), syserrlst(3) .SH BUGS Format of the file isn't necessarily portable between machines. .SH HISTORY This file format is new with 2.11BSD. ================================================ FILE: share/man/man5/tar.5 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)tar.5 6.2 (Berkeley) 11/7/85 .\" .TH TAR 5 "November 7, 1985" .UC 5 .SH NAME tar \- tape archive file format .SH DESCRIPTION .IR Tar , (the tape archive command) dumps several files into one, in a medium suitable for transportation. .PP A ``tar tape'' or file is a series of blocks. Each block is of size TBLOCK. A file on the tape is represented by a header block which describes the file, followed by zero or more blocks which give the contents of the file. At the end of the tape are two blocks filled with binary zeros, as an end-of-file indicator. .PP The blocks are grouped for physical I/O operations. Each group of .I n blocks (where .I n is set by the .B b keyletter on the .IR tar (1) command line \(em default is 20 blocks) is written with a single system call; on nine-track tapes, the result of this write is a single tape record. The last group is always written at the full size, so blocks after the two zero blocks contain random data. On reading, the specified or default group size is used for the first read, but if that read returns less than a full tape block, the reduced block size is used for further reads. .PP The header block looks like: .RS .PP .nf #define TBLOCK 512 #define NAMSIZ 100 union hblock { char dummy[TBLOCK]; struct header { char name[NAMSIZ]; char mode[8]; char uid[8]; char gid[8]; char size[12]; char mtime[12]; char chksum[8]; char linkflag; char linkname[NAMSIZ]; } dbuf; }; .ta \w'#define 'u +\w'SARMAG 'u .fi .RE .LP .IR Name is a null-terminated string. The other fields are zero-filled octal numbers in ASCII. Each field (of width w) contains w-2 digits, a space, and a null, except .IR size and .IR mtime , which do not contain the trailing null and .IR chksum which has a null followed by a space. .IR Name is the name of the file, as specified on the .I tar command line. Files dumped because they were in a directory which was named in the command line have the directory name as prefix and .I /filename as suffix. . \"Whatever format was used in the command line . \"will appear here, such as . \".I \&./yellow . \"or . \".IR \&../../brick/./road/.. . . \"To retrieve a file from a tar tape, an exact prefix match must be specified, . \"including all of the directory prefix information used on the command line . \"that dumped the file (if any). .IR Mode is the file mode, with the top bit masked off. .IR Uid and .IR gid are the user and group numbers which own the file. .IR Size is the size of the file in bytes. Links and symbolic links are dumped with this field specified as zero. .IR Mtime is the modification time of the file at the time it was dumped. .IR Chksum is an octal ASCII value which represents the sum of all the bytes in the header block. When calculating the checksum, the .IR chksum field is treated as if it were all blanks. .IR Linkflag is NULL if the file is ``normal'' or a special file, ASCII `1' if it is an hard link, and ASCII `2' if it is a symbolic link. The name linked-to, if any, is in .IR linkname, with a trailing null. Unused fields of the header are binary zeros (and are included in the checksum). .PP The first time a given i-node number is dumped, it is dumped as a regular file. The second and subsequent times, it is dumped as a link instead. Upon retrieval, if a link entry is retrieved, but not the file it was linked to, an error message is printed and the tape must be manually re-scanned to retrieve the linked-to file. .PP The encoding of the header is designed to be portable across machines. .SH "SEE ALSO" tar(1) .SH BUGS Names or linknames longer than NAMSIZ produce error reports and cannot be dumped. ================================================ FILE: share/man/man5/termcap.5 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)termcap.5 6.4 (Berkeley) 5/15/86 .\" .ie n \{\ . ds lq \&"\" . ds rq \&"\" .\} .el \{\ . ds rq '' . ds lq `` .\} .tr || .tr *\(** .hw trans-parently .TH TERMCAP 5 "May 5, 1986" .UC .SH NAME termcap \- terminal capability data base .SH SYNOPSIS /etc/termcap .SH DESCRIPTION .I Termcap\^ is a data base describing terminals, used, .IR e.g. , by .IR vi\^ (1) and .IR curses\^ (3X). Terminals are described in .I termcap\^ by giving a set of capabilities that they have and by describing how operations are performed. Padding requirements and initialization sequences are included in .IR termcap\^ . .PP Entries in .I termcap\^ consist of a number of `:'-separated fields. The first entry for each terminal gives the names that are known for the terminal, separated by `|' characters. The first name is always two characters long and is used by older systems which store the terminal type in a 16-bit word in a system-wide data base. The second name given is the most common abbreviation for the terminal, the last name given should be a long name fully identifying the terminal, and all others are understood as synonyms for the terminal name. All names but the first and last should be in lower case and contain no blanks; the last name may well contain upper case and blanks for readability. .PP Terminal names (except for the last, verbose entry) should be chosen using the following conventions. The particular piece of hardware making up the terminal should have a root name chosen, thus \*(lqhp2621\*(rq. This name should not contain hyphens. Modes that the hardware can be in or user preferences should be indicated by appending a hyphen and an indicator of the mode. Therefore, a \*(lqvt100\*(rq in 132-column mode would be \*(lqvt100-w\*(rq. The following suffixes should be used where possible: .sp .ta .ta \w'\fBSuffix\fP\ \ \ 'u +\w'With automatic margins (usually default)\ \ 'u .nf .if t \{\ .nr Xx \n(.lu-\n(.i-\w'\fBSuffix\fP\ \ \ With automatic margins (usually default)\ \ vt100-am'u .in +\n(Xxu/2u .\} \fBSuffix Meaning Example\fP -w Wide mode (more than 80 columns) vt100-w -am With automatic margins (usually default) vt100-am -nam Without automatic margins vt100-nam -\fIn\fP Number of lines on the screen aaa-60 -na No arrow keys (leave them in local) concept100-na -\fIn\^\fPp Number of pages of memory concept100-4p -rv Reverse video concept100-rv .fi .SH CAPABILITIES .PP The characters in the .I Notes field in the table have the following meanings (more than one may apply to a capability): .PP .ta .ta \w'N\ \ \ 'u .nf N indicates numeric parameter(s) P indicates that padding may be specified * indicates that padding may be based on the number of lines affected o indicates capability is obsolete .fi .PP \*(lqObsolete\*(rq capabilities have no .I terminfo\^ equivalents, since they were considered useless, or are subsumed by other capabilities. New software should not rely on them at all. .PP .nf .ta \w'\fBName \fP'u +\w'\fBType \fP'u +\w'\fBNotes \fP'u \fBName Type Notes Description\fP ae str (P) End alternate character set AL str (NP*) Add \fIn\^\fP new blank lines al str (P*) Add new blank line am bool Terminal has automatic margins as str (P) Start alternate character set bc str (o) Backspace if not \fB^H\fP bl str (P) Audible signal (bell) bs bool (o) Terminal can backspace with \fB^H\fP bt str (P) Back tab bw bool \fBle\fP (backspace) wraps from column 0 to last column CC str Terminal settable command character in prototype cd str (P*) Clear to end of display ce str (P) Clear to end of line ch str (NP) Set cursor column (horizontal position) cl str (P*) Clear screen and home cursor CM str (NP) Memory-relative cursor addressing cm str (NP) Screen-relative cursor motion co num Number of columns in a line (See BUGS section below) cr str (P) Carriage return cs str (NP) Change scrolling region (VT100) ct str (P) Clear all tab stops cv str (NP) Set cursor row (vertical position) da bool Display may be retained above the screen dB num (o) Milliseconds of \fBbs\fP delay needed (default 0) db bool Display may be retained below the screen DC str (NP*) Delete \fIn\^\fP characters dC num (o) Milliseconds of \fBcr\fP delay needed (default 0) dc str (P*) Delete character dF num (o) Milliseconds of \fBff\fP delay needed (default 0) DL str (NP*) Delete \fIn\^\fP lines dl str (P*) Delete line dm str Enter delete mode dN num (o) Milliseconds of \fBnl\fP delay needed (default 0) DO str (NP*) Move cursor down \fIn\^\fP lines do str Down one line ds str Disable status line dT num (o) Milliseconds of horizontal tab delay needed (default 0) dV num (o) Milliseconds of vertical tab delay needed (default 0) ec str (NP) Erase \fIn\^\fP characters ed str End delete mode ei str End insert mode eo bool Can erase overstrikes with a blank EP bool (o) Even parity es bool Escape can be used on the status line ff str (P*) Hardcopy terminal page eject fs str Return from status line gn bool Generic line type (\fIe.g.\fP dialup, switch) hc bool Hardcopy terminal HD bool (o) Half-duplex hd str Half-line down (forward 1/2 linefeed) ho str (P) Home cursor hs bool Has extra \*(lqstatus line\*(rq hu str Half-line up (reverse 1/2 linefeed) hz bool Cannot print ~s (Hazeltine) i1-i3 str Terminal initialization strings (\fIterminfo\^\fP only) IC str (NP*) Insert \fIn\^\fP blank characters ic str (P*) Insert character if str Name of file containing initialization string im str Enter insert mode in bool Insert mode distinguishes nulls iP str Pathname of program for initialization (\fIterminfo\^\fP only) ip str (P*) Insert pad after character inserted is str Terminal initialization string (\fItermcap\^\fP only) it num Tabs initially every \fIn\^\fP positions K1 str Sent by keypad upper left K2 str Sent by keypad upper right K3 str Sent by keypad center K4 str Sent by keypad lower left K5 str Sent by keypad lower right k0-k9 str Sent by function keys 0-9 kA str Sent by insert-line key ka str Sent by clear-all-tabs key kb str Sent by backspace key kC str Sent by clear-screen or erase key kD str Sent by delete-character key kd str Sent by down-arrow key kE str Sent by clear-to-end-of-line key ke str Out of \*(lqkeypad transmit\*(rq mode kF str Sent by scroll-forward/down key kH str Sent by home-down key kh str Sent by home key kI str Sent by insert-character or enter-insert-mode key kL str Sent by delete-line key kl str Sent by left-arrow key kM str Sent by insert key while in insert mode km bool Has a \*(lqmeta\*(rq key (shift, sets parity bit) kN str Sent by next-page key kn num (o) Number of function (\fBk0\fP\-\fBk9\fP) keys (default 0) ko str (o) Termcap entries for other non-function keys kP str Sent by previous-page key kR str Sent by scroll-backward/up key kr str Sent by right-arrow key kS str Sent by clear-to-end-of-screen key ks str Put terminal in \*(lqkeypad transmit\*(rq mode kT str Sent by set-tab key kt str Sent by clear-tab key ku str Sent by up-arrow key l0-l9 str Labels on function keys if not \*(lqf\fIn\^\fP\*(rq LC bool (o) Lower-case only LE str (NP) Move cursor left \fIn\^\fP positions le str (P) Move cursor left one position li num Number of lines on screen or page (See BUGS section below) ll str Last line, first column lm num Lines of memory if > \fBli\fP (0 means varies) ma str (o) Arrow key map (used by \fIvi\^\fP version 2 only) mb str Turn on blinking attribute md str Turn on bold (extra bright) attribute me str Turn off all attributes mh str Turn on half-bright attribute mi bool Safe to move while in insert mode mk str Turn on blank attribute (characters invisible) ml str (o) Memory lock on above cursor mm str Turn on \*(lqmeta mode\*(rq (8th bit) mo str Turn off \*(lqmeta mode\*(rq mp str Turn on protected attribute mr str Turn on reverse-video attibute ms bool Safe to move in standout modes mu str (o) Memory unlock (turn off memory lock) nc bool (o) No correctly-working \fBcr\fP (Datamedia 2500, Hazeltine 2000) nd str Non-destructive space (cursor right) NL bool (o) \fB\\n\fP is newline, not line feed nl str (o) Newline character if not \fB\\n\fP ns bool (o) Terminal is a \s-1CRT\s0 but doesn't scroll nw str (P) Newline (behaves like \fBcr\fP followed by \fBdo\fP) OP bool (o) Odd parity os bool Terminal overstrikes pb num Lowest baud where delays are required pc str Pad character (default \s-2NUL\s0) pf str Turn off the printer pk str Program function key \fIn\^\fP to type string \fIs\fP (\fIterminfo\^\fP only) pl str Program function key \fIn\^\fP to execute string \fIs\fP (\fIterminfo\^\fP only) pO str (N) Turn on the printer for \fIn\^\fP bytes po str Turn on the printer ps str Print contents of the screen pt bool (o) Has hardware tabs (may need to be set with \fBis\fP) px str Program function key \fIn\^\fP to transmit string \fIs\fP (\fIterminfo\^\fP only) r1-r3 str Reset terminal completely to sane modes (\fIterminfo\^\fP only) rc str (P) Restore cursor to position of last \fBsc\fP rf str Name of file containing reset codes RI str (NP) Move cursor right \fIn\^\fP positions rp str (NP*) Repeat character \fIc n\^\fP times rs str Reset terminal completely to sane modes (\fItermcap\^\fP only) sa str (NP) Define the video attributes sc str (P) Save cursor position se str End standout mode SF str (NP*) Scroll forward \fIn\^\fP lines sf str (P) Scroll text up sg num Number of garbage chars left by \fBso\fP or \fBse\fP (default 0) so str Begin standout mode SR str (NP*) Scroll backward \fIn\^\fP lines sr str (P) Scroll text down st str Set a tab in all rows, current column ta str (P) Tab to next 8-position hardware tab stop tc str Entry of similar terminal \- must be last te str String to end programs that use \fItermcap\fP ti str String to begin programs that use \fItermcap\fP ts str (N) Go to status line, column \fIn\^\fP UC bool (o) Upper-case only uc str Underscore one character and move past it ue str End underscore mode ug num Number of garbage chars left by \fBus\fP or \fBue\fP (default 0) ul bool Underline character overstrikes UP str (NP*) Move cursor up \fIn\^\fP lines up str Upline (cursor up) us str Start underscore mode vb str Visible bell (must not move cursor) ve str Make cursor appear normal (undo \fBvs\fP/\fBvi\fP) vi str Make cursor invisible vs str Make cursor very visible vt num Virtual terminal number (not supported on all systems) wi str (N) Set current window ws num Number of columns in status line xb bool Beehive (f1=\s-2ESC\s0, f2=^C) xn bool Newline ignored after 80 cols (Concept) xo bool Terminal uses xoff/xon (\s-2DC3\s0/\s-2DC1\s0) handshaking xr bool (o) Return acts like \fBce cr nl\fP (Delta Data) xs bool Standout not erased by overwriting (Hewlett-Packard) xt bool Tabs ruin, magic \fBso\fP char (Teleray 1061) xx bool (o) Tektronix 4025 insert-line .fi .ta 8n +8n .PP .B A Sample Entry .PP The following entry, which describes the Concept\-100, is among the more complex entries in the .I termcap\^ file as of this writing. .PP .nf ca\||\|concept100\||\|c100\||\|concept\||\|c104\||\|concept100-4p\||\|HDS Concept\-100:\e :al=3*\eE^R:am:bl=^G:cd=16*\eE^C:ce=16\eE^U:cl=2*^L:cm=\eEa%+ %+ :\e :co#80:.cr=9^M:db:dc=16\eE^A:dl=3*\eE^B:do=^J:ei=\eE\e200:eo:im=\eE^P:in:\e :ip=16*:is=\eEU\eEf\eE7\eE5\eE8\eEl\eENH\eEK\eE\e200\eEo&\e200\eEo\e47\eE:k1=\eE5:\e :k2=\eE6:k3=\eE7:kb=^h:kd=\eE<:ke=\eEx:kh=\eE?:kl=\eE>:kr=\eE=:ks=\eEX:\e :ku=\eE;:le=^H:li#24:mb=\eEC:me=\eEN\e200:mh=\eEE:mi:mk=\eEH:mp=\eEI:\e :mr=\eED:nd=\eE=:pb#9600:rp=0.2*\eEr%.%+ :se=\eEd\eEe:sf=^J:so=\eEE\eED:\e :.ta=8\et:te=\eEv \e200\e200\e200\e200\e200\e200\eEp\er\en:\e :ti=\eEU\eEv 8p\eEp\er:ue=\eEg:ul:up=\eE;:us=\eEG:\e :vb=\eEk\e200\e200\e200\e200\e200\e200\e200\e200\e200\e200\e200\e200\e200\e200\eEK:\e :ve=\eEw:vs=\eEW:vt#8:xn:\e :bs:cr=^M:dC#9:dT#8:nl=^J:ta=^I:pt: .fi .PP Entries may continue onto multiple lines by giving a \e as the last character of a line, and empty fields may be included for readability (here between the last field on a line and the first field on the next). Comments may be included on lines beginning with \*(lq#\*(rq. .br .ne 5 .PP .B Types of Capabilities .PP Capabilities in .I termcap\^ are of three types: Boolean capabilities, which indicate particular features that the terminal has; numeric capabilities, giving the size of the display or the size of other attributes; and string capabilities, which give character sequences that can be used to perform particular terminal operations. All capabilities have two-letter codes. For instance, the fact that the Concept has .I automatic margins .RI ( i.e. , an automatic return and linefeed when the end of a line is reached) is indicated by the Boolean capability .BR am . Hence the description of the Concept includes .BR am . .PP Numeric capabilities are followed by the character `#' then the value. In the example above .BR co , which indicates the number of columns the display has, gives the value `80' for the Concept. .PP Finally, string-valued capabilities, such as .B ce (clear-to-end-of-line sequence) are given by the two-letter code, an `=', then a string ending at the next following `:'. A delay in milliseconds may appear after the `=' in such a capability, which causes padding characters to be supplied by .I tputs\^ after the remainder of the string is sent to provide this delay. The delay can be either a number, .I e.g. `20', or a number followed by an `*', .IR i.e. , `3*'. An `*' indicates that the padding required is proportional to the number of lines affected by the operation, and the amount given is the per-affected-line padding required. (In the case of insert-character, the factor is still the number of .I lines\^ affected; this is always 1 unless the terminal has .B in and the software uses it.) When an `*' is specified, it is sometimes useful to give a delay of the form `3.5' to specify a delay per line to tenths of milliseconds. (Only one decimal place is allowed.) .PP A number of escape sequences are provided in the string-valued capabilities for easy encoding of control characters there. .B \eE maps to an \s-2ESC\s0 character, .B ^X maps to a control-X for any appropriate X, and the sequences .B \en .B \er .B \et .B \eb .B \ef map to linefeed, return, tab, backspace, and formfeed, respectively. Finally, characters may be given as three octal digits after a .BR \e , and the characters .B ^ and .B \e may be given as .B \e^ and .BR \e\e . If it is necessary to place a .B : in a capability it must be escaped in octal as .BR \e072 . If it is necessary to place a \s-2NUL\s0 character in a string capability it must be encoded as .BR \e200 . (The routines that deal with .I termcap\^ use C strings and strip the high bits of the output very late, so that a .B \e200 comes out as a .B \e000 would.) .PP Sometimes individual capabilities must be commented out. To do this, put a period before the capability name. For example, see the first .B cr and .B ta in the example above. .br .ne 5 .PP .B Preparing Descriptions .PP We now outline how to prepare descriptions of terminals. The most effective way to prepare a terminal description is by imitating the description of a similar terminal in .I termcap\^ and to build up a description gradually, using partial descriptions with .I vi\^ to check that they are correct. Be aware that a very unusual terminal may expose deficiencies in the ability of the .I termcap\^ file to describe it or bugs in .IR vi\^ . To easily test a new terminal description you can set the environment variable .B .SM TERMCAP to the absolute pathname of a file containing the description you are working on and programs will look there rather than in .IR /etc/termcap\^ . .B .SM TERMCAP can also be set to the .I termcap\^ entry itself to avoid reading the file when starting up a program. .PP To get the padding for insert-line right (if the terminal manufacturer did not document it), a severe test is to use .I vi\^ to edit .I /etc/passwd\^ at 9600 baud, delete roughly 16 lines from the middle of the screen, then hit the `u' key several times quickly. If the display messes up, more padding is usually needed. A similar test can be used for insert-character. .br .ne 5 .PP .B Basic Capabilities .PP The number of columns on each line of the display is given by the .B co numeric capability. If the display is a \s-1CRT\s0, then the number of lines on the screen is given by the .B li capability. If the display wraps around to the beginning of the next line when the cursor reaches the right margin, then it should have the .B am capability. If the terminal can clear its screen, the code to do this is given by the .B cl string capability. If the terminal overstrikes (rather than clearing the position when a character is overwritten), it should have the .B os capability. If the terminal is a printing terminal, with no soft copy unit, give it both .B hc and .BR os . .RB ( os applies to storage scope terminals, such as the Tektronix 4010 series, as well as to hard copy and .SM APL terminals.) If there is a code to move the cursor to the left edge of the current row, give this as .BR cr . (Normally this will be carriage-return, .BR ^M .) If there is a code to produce an audible signal (bell, beep, .IR etc.\^ ), give this as .BR bl . .PP If there is a code (such as backspace) to move the cursor one position to the left, that capability should be given as .BR le . Similarly, codes to move to the right, up, and down should be given as .BR nd , .BR up , and .BR do , respectively. These .I local cursor motions\^ should not alter the text they pass over; for example, you would not normally use \*(lqnd=\ \*(rq unless the terminal has the .B os capability, because the space would erase the character moved over. .PP A very important point here is that the local cursor motions encoded in .I termcap\^ have undefined behavior at the left and top edges of a .SM CRT display. Programs should never attempt to backspace around the left edge, unless .B bw is given, and never attempt to go up off the top using local cursor motions. .PP In order to scroll text up, a program goes to the bottom left corner of the screen and sends the .B sf (index) string. To scroll text down, a program goes to the top left corner of the screen and sends the .B sr (reverse index) string. The strings .B sf and .B sr have undefined behavior when not on their respective corners of the screen. Parameterized versions of the scrolling sequences are .B SF and .BR SR , which have the same semantics as .B sf and .B sr except that they take one parameter and scroll that many lines. They also have undefined behavior except at the appropriate corner of the screen. .PP The .B am capability tells whether the cursor sticks at the right edge of the screen when text is output there, but this does not necessarily apply to .B nd from the last column. Leftward local motion is defined from the left edge only when .B bw is given; then an .B le from the left edge will move to the right edge of the previous row. This is useful for drawing a box around the edge of the screen, for example. If the terminal has switch-selectable automatic margins, the .I termcap\^ description usually assumes that this feature is on, .IR i.e. , .BR am . If the terminal has a command that moves to the first column of the next line, that command can be given as .B nw (newline). It is permissible for this to clear the remainder of the current line, so if the terminal has no correctly-working \s-2CR\s0 and \s-2LF\s0 it may still be possible to craft a working .B nw out of one or both of them. .PP These capabilities suffice to describe hardcopy and \*(lqglass-tty\*(rq terminals. Thus the Teletype model 33 is described as .PP .nf T3\||\|tty33\||\|33\||\|tty\||\|Teletype model 33:\e :bl=^G:co#72:cr=^M:do=^J:hc:os: .fi .PP and the Lear Siegler \s-1ADM\s0\-3 is described as .PP .nf l3\||\|adm3\||\|3\||\|LSI \s-1ADM\s0-3:\e :am:bl=^G:cl=^Z:co#80:cr=^M:do=^J:le=^H:li#24:sf=^J: .fi .br .ne 5 .PP .B Parameterized Strings .PP Cursor addressing and other strings requiring parameters are described by a parameterized string capability, with .IR printf\^ (3S)-like escapes .B %x in it, while other characters are passed through unchanged. For example, to address the cursor the .B cm capability is given, using two parameters: the row and column to move to. (Rows and columns are numbered from zero and refer to the physical screen visible to the user, not to any unseen memory. If the terminal has memory-relative cursor addressing, that can be indicated by an analogous .B CM capability.) .PP The .B % encodings have the following meanings: .PP .DT .nf %% output `%' %d output value as in \fIprintf\^\fP %d %2 output value as in \fIprintf\^\fP %2d %3 output value as in \fIprintf\^\fP %3d %. output value as in \fIprintf\^\fP %c %+\fIx\fP add \fIx\^\fP to value, then do %. %>\fIxy\fP if value > \fIx\^\fP then add \fIy\^\fP, no output %r reverse order of two parameters, no output %i increment by one, no output %n exclusive-or all parameters with 0140 (Datamedia 2500) %B BCD (16*(value/10)) + (value%10), no output %D Reverse coding (value \- 2*(value%16)), no output (Delta Data) .fi .PP Consider the Hewlett-Packard 2645, which, to get to row 3 and column 12, needs to be sent \*(lq\eE&a12c03Y\*(rq padded for 6 milliseconds. Note that the order of the row and column coordinates is reversed here and that the row and column are sent as two-digit integers. Thus its .B cm capability is \*(lqcm=6\eE&%r%2c%2Y\*(rq. .PP The Microterm .SM ACT-IV needs the current row and column sent simply encoded in binary preceded by a .BR ^T , \*(lqcm=^T%.%.\*(rq. Terminals that use \*(lq%.\*(rq need to be able to backspace the cursor .RB ( le ) and to move the cursor up one line on the screen .RB ( up ). This is necessary because it is not always safe to transmit .BR \en , .BR ^D , and .BR \er , as the system may change or discard them. (Programs using .I termcap\^ must set terminal modes so that tabs are not expanded, so .B \et is safe to send. This turns out to be essential for the Ann Arbor 4080.) .PP A final example is the Lear Siegler \s-1ADM\s0\-3a, which offsets row and column by a blank character, thus \*(lqcm=\eE=%+ %+ \*(rq. .PP Row or column absolute cursor addressing can be given as single parameter capabilities .B ch (horizontal position absolute) and .B cv (vertical position absolute). Sometimes these are shorter than the more general two-parameter sequence (as with the Hewlett-Packard 2645) and can be used in preference to .BR cm . If there are parameterized local motions .RI ( e.g. , move .I n\^ positions to the right) these can be given as .BR DO , .BR LE , .BR RI , and .B UP with a single parameter indicating how many positions to move. These are primarily useful if the terminal does not have .BR cm , such as the Tektronix 4025. .br .ne 5 .PP .B Cursor Motions .PP If the terminal has a fast way to home the cursor (to the very upper left corner of the screen), this can be given as .BR ho . Similarly, a fast way of getting to the lower left-hand corner can be given as .BR ll ; this may involve going up with .B up from the home position, but a program should never do this itself (unless .B ll does), because it can make no assumption about the effect of moving up from the home position. Note that the home position is the same as cursor address (0,0): to the top left corner of the screen, not of memory. (Therefore, the \*(lq\eEH\*(rq sequence on Hewlett-Packard terminals cannot be used for .BR ho .) .br .ne 5 .PP .B Area Clears .PP If the terminal can clear from the current position to the end of the line, leaving the cursor where it is, this should be given as .BR ce . If the terminal can clear from the current position to the end of the display, this should be given as .BR cd . .B cd must only be invoked from the first column of a line. (Therefore, it can be simulated by a request to delete a large number of lines, if a true .B cd is not available.) .br .ne 5 .PP .B Insert/Delete Line .PP If the terminal can open a new blank line before the line containing the cursor, this should be given as .BR al ; this must be invoked only from the first position of a line. The cursor must then appear at the left of the newly blank line. If the terminal can delete the line that the cursor is on, this should be given as .BR dl ; this must only be used from the first position on the line to be deleted. Versions of .B al and .B dl which take a single parameter and insert or delete that many lines can be given as .B AL and .BR DL . If the terminal has a settable scrolling region (like the VT100), the command to set this can be described with the .B cs capability, which takes two parameters: the top and bottom lines of the scrolling region. The cursor position is, alas, undefined after using this command. It is possible to get the effect of insert or delete line using this command \(em the .B sc and .B rc (save and restore cursor) commands are also useful. Inserting lines at the top or bottom of the screen can also be done using .B sr or .B sf on many terminals without a true insert/delete line, and is often faster even on terminals with those features. .PP If the terminal has the ability to define a window as part of memory which all commands affect, it should be given as the parameterized string .BR wi . The four parameters are the starting and ending lines in memory and the starting and ending columns in memory, in that order. (This .I terminfo\^ capability is described for completeness. It is unlikely that any .IR termcap\^ -using program will support it.) .PP If the terminal can retain display memory above the screen, then the .B da capability should be given; if display memory can be retained below, then .B db should be given. These indicate that deleting a line or scrolling may bring non-blank lines up from below or that scrolling back with .B sr may bring down non-blank lines. .br .ne 5 .PP .B Insert/Delete Character .PP There are two basic kinds of intelligent terminals with respect to insert/delete character that can be described using .IR termcap\^ . The most common insert/delete character operations affect only the characters on the current line and shift characters off the end of the line rigidly. Other terminals, such as the Concept\-100 and the Perkin Elmer Owl, make a distinction between typed and untyped blanks on the screen, shifting upon an insert or delete only to an untyped blank on the screen which is either eliminated or expanded to two untyped blanks. You can determine the kind of terminal you have by clearing the screen then typing text separated by cursor motions. Type \*(lqabc\ \ \ \ def\*(rq using local cursor motions (not spaces) between the \*(lqabc\*(rq and the \*(lqdef\*(rq. Then position the cursor before the \*(lqabc\*(rq and put the terminal in insert mode. If typing characters causes the rest of the line to shift rigidly and characters to fall off the end, then your terminal does not distinguish between blanks and untyped positions. If the \*(lqabc\*(rq shifts over to the \*(lqdef\*(rq which then move together around the end of the current line and onto the next as you insert, then you have the second type of terminal and should give the capability \fBin\fP, which stands for \*(lqinsert null\*(rq. While these are two logically separate attributes (one line .I vs. multi-line insert mode, and special treatment of untyped spaces), we have seen no terminals whose insert mode cannot be described with the single attribute. .PP .I Termcap\^ can describe both terminals that have an insert mode and terminals that send a simple sequence to open a blank position on the current line. Give as .B im the sequence to get into insert mode. Give as .B ei the sequence to leave insert mode. Now give as .B ic any sequence that needs to be sent just before each character to be inserted. Most terminals with a true insert mode will not give .BR ic ; terminals that use a sequence to open a screen position should give it here. (If your terminal has both, insert mode is usually preferable to .BR ic . Do not give both unless the terminal actually requires both to be used in combination.) If post-insert padding is needed, give this as a number of milliseconds in .B ip (a string option). Any other sequence that may need to be sent after insertion of a single character can also be given in .BR ip . If your terminal needs to be placed into an `insert mode' and needs a special code preceding each inserted character, then both .BR im / ei and .B ic can be given, and both will be used. The .B IC capability, with one parameter .IR n\^ , will repeat the effects of .B ic .I n\^ times. .PP It is occasionally necessary to move around while in insert mode to delete characters on the same line .RI ( e.g. , if there is a tab after the insertion position). If your terminal allows motion while in insert mode, you can give the capability .B mi to speed up inserting in this case. Omitting .B mi will affect only speed. Some terminals (notably Datamedia's) must not have .B mi because of the way their insert mode works. .PP Finally, you can specify .B dc to delete a single character, .B DC with one parameter .I n\^ to delete .I n\^ characters, and delete mode by giving .B dm and .B ed to enter and exit delete mode (which is any mode the terminal needs to be placed in for .B dc to work). .br .ne 5 .PP .B Highlighting, Underlining, and Visible Bells .PP If your terminal has one or more kinds of display attributes, these can be represented in a number of different ways. You should choose one display form as .IR "standout mode" , representing a good high-contrast, easy-on-the-eyes format for highlighting error messages and other attention getters. (If you have a choice, reverse video plus half-bright is good, or reverse video alone.) The sequences to enter and exit standout mode are given as .B so and .BR se , respectively. If the code to change into or out of standout mode leaves one or even two blank spaces or garbage characters on the screen, as the TVI 912 and Teleray 1061 do, then .B sg should be given to tell how many characters are left. .PP Codes to begin underlining and end underlining can be given as .B us and .BR ue , respectively. Underline mode change garbage is specified by .BR ug , similar to .BR sg . If the terminal has a code to underline the current character and move the cursor one position to the right, such as the Microterm Mime, this can be given as .BR uc . .PP Other capabilities to enter various highlighting modes include .B mb (blinking), .B md (bold or extra bright), .B mh (dim or half-bright), .B mk (blanking or invisible text), .B mp (protected), .B mr (reverse video), .B me (turn off .I all attribute modes), .B as (enter alternate character set mode), and .B ae (exit alternate character set mode). Turning on any of these modes singly may or may not turn off other modes. .PP If there is a sequence to set arbitrary combinations of mode, this should be given as .B sa (set attributes), taking 9 parameters. Each parameter is either 0 or 1, as the corresponding attributes is on or off. The 9 parameters are, in order: standout, underline, reverse, blink, dim, bold, blank, protect, and alternate character set. Not all modes need be supported by .BR sa , only those for which corresponding attribute commands exist. (It is unlikely that a .IR termcap\^ -using program will support this capability, which is defined for compatibility with .IR terminfo\^ .) .PP Terminals with the \*(lqmagic cookie\*(rq glitches .RB ( sg and .BR ug ), rather than maintaining extra attribute bits for each character cell, instead deposit special \*(lqcookies\*(rq, or \*(lqgarbage characters\*(rq, when they receive mode-setting sequences, which affect the display algorithm. .PP Some terminals, such as the Hewlett-Packard 2621, automatically leave standout mode when they move to a new line or when the cursor is addressed. Programs using standout mode should exit standout mode on such terminals before moving the cursor or sending a newline. On terminals where this is not a problem, the .B ms capability should be present to say that this overhead is unnecessary. .PP If the terminal has a way of flashing the screen to indicate an error quietly (a bell replacement), this can be given as .BR vb ; it must not move the cursor. .PP If the cursor needs to be made more visible than normal when it is not on the bottom line (to change, for example, a non-blinking underline into an easier-to-find block or blinking underline), give this sequence as .BR vs . If there is a way to make the cursor completely invisible, give that as .BR vi . The capability .BR ve , which undoes the effects of both of these modes, should also be given. .PP If your terminal correctly displays underlined characters (with no special codes needed) even though it does not overstrike, then you should give the capability .BR ul . If overstrikes are erasable with a blank, this should be indicated by giving .BR eo . .br .ne 5 .PP .B Keypad .PP If the terminal has a keypad that transmits codes when the keys are pressed, this information can be given. Note that it is not possible to handle terminals where the keypad only works in local mode (this applies, for example, to the unshifted Hewlett-Packard 2621 keys). If the keypad can be set to transmit or not transmit, give these codes as .B ks and .BR ke . Otherwise the keypad is assumed to always transmit. The codes sent by the left-arrow, right-arrow, up-arrow, down-arrow, and home keys can be given as .BR kl , .BR kr , .BR ku , .BR kd , and .BR kh , respectively. If there are function keys such as f0, f1, ..., f9, the codes they send can be given as .BR k0 , .BR k1 , "" ..., .BR k9 . If these keys have labels other than the default f0 through f9, the labels can be given as .BR l0 , .BR l1 , "" ..., .BR l9 . The codes transmitted by certain other special keys can be given: .B kH (home down), .B kb (backspace), .B ka (clear all tabs), .B kt (clear the tab stop in this column), .B kC (clear screen or erase), .B kD (delete character), .B kL (delete line), .B kM (exit insert mode), .B kE (clear to end of line), .B kS (clear to end of screen), .B kI (insert character or enter insert mode), .B kA (insert line), .B kN (next page), .B kP (previous page), .B kF (scroll forward/down), .B kR (scroll backward/up), and .B kT (set a tab stop in this column). In addition, if the keypad has a 3 by 3 array of keys including the four arrow keys, then the other five keys can be given as .BR K1 , .BR K2 , .BR K3 , .BR K4 , and .BR K5 . These keys are useful when the effects of a 3 by 3 directional pad are needed. The obsolete .B ko capability formerly used to describe \*(lqother\*(rq function keys has been completely supplanted by the above capabilities. .PP The .B ma entry is also used to indicate arrow keys on terminals that have single-character arrow keys. It is obsolete but still in use in version 2 of .I vi\^ which must be run on some minicomputers due to memory limitations. This field is redundant with .BR kl , .BR kr , .BR ku , .BR kd , and .BR kh . It consists of groups of two characters. In each group, the first character is what an arrow key sends, and the second character is the corresponding .I vi\^ command. These commands are .B h for .BR kl , .B j for .BR kd , .B k for .BR ku , .B l for .BR kr , and .B H for .BR kh . For example, the Mime would have \*(lqma=^Hh^Kj^Zk^Xl\*(rq indicating arrow keys left (^H), down (^K), up (^Z), and right (^X). (There is no home key on the Mime.) .br .ne 5 .PP .B Tabs and Initialization .PP If the terminal needs to be in a special mode when running a program that uses these capabilities, the codes to enter and exit this mode can be given as .B ti and .BR te . This arises, for example, from terminals like the Concept with more than one page of memory. If the terminal has only memory-relative cursor addressing and not screen-relative cursor addressing, a screen-sized window must be fixed into the display for cursor addressing to work properly. This is also used for the Tektronix 4025, where .B ti sets the command character to be the one used by .IR termcap\^ . .PP Other capabilities include .BR is , an initialization string for the terminal, and .BR if , the name of a file containing long initialization strings. These strings are expected to set the terminal into modes consistent with the rest of the .I termcap\^ description. They are normally sent to the terminal by the .I tset\^ program each time the user logs in. They will be printed in the following order: .BR is ; setting tabs using .B ct and .BR st ; and finally .BR if . .RI ( Terminfo\^ uses .B i1-i2 instead of .B is and runs the program .B iP and prints .B i3 after the other initializations.) A pair of sequences that does a harder reset from a totally unknown state can be analogously given as .B rs and .BR if . These strings are output by the .I reset\^ program, which is used when the terminal gets into a wedged state. .RI ( Terminfo\^ uses .B r1-r3 instead of .BR rs .) Commands are normally placed in .B rs and .B rf only if they produce annoying effects on the screen and are not necessary when logging in. For example, the command to set the VT100 into 80-column mode would normally be part of .BR is , but it causes an annoying glitch of the screen and is not normally needed since the terminal is usually already in 80-column mode. .PP If the terminal has hardware tabs, the command to advance to the next tab stop can be given as .B ta (usually .BR ^I ). A \*(lqbacktab\*(rq command which moves leftward to the previous tab stop can be given as .BR bt . By convention, if the terminal driver modes indicate that tab stops are being expanded by the computer rather than being sent to the terminal, programs should not use .B ta or .B bt even if they are present, since the user may not have the tab stops properly set. If the terminal has hardware tabs that are initially set every .I n\^ positions when the terminal is powered up, then the numeric parameter .B it is given, showing the number of positions between tab stops. This is normally used by the .I tset\^ command to determine whether to set the driver mode for hardware tab expansion, and whether to set the tab stops. If the terminal has tab stops that can be saved in nonvolatile memory, the .I termcap\^ description can assume that they are properly set. .PP If there are commands to set and clear tab stops, they can be given as .B ct (clear all tab stops) and .B st (set a tab stop in the current column of every row). If a more complex sequence is needed to set the tabs than can be described by this, the sequence can be placed in .B is or .BR if . .br .ne 5 .PP .B Delays .PP Certain capabilities control padding in the terminal driver. These are primarily needed by hardcopy terminals and are used by the .I tset\^ program to set terminal driver modes appropriately. Delays embedded in the capabilities .BR cr , .BR sf , .BR le , .BR ff , and .B ta will cause the appropriate delay bits to be set in the terminal driver. If .B pb (padding baud rate) is given, these values can be ignored at baud rates below the value of .BR pb . For 4.2BSD .IR tset\^ , the delays are given as numeric capabilities .BR dC , .BR dN , .BR dB , .BR dF , and .BR dT instead. .br .ne 5 .PP .B Miscellaneous .PP If the terminal requires other than a \s-2NUL\s0 (zero) character as a pad, this can be given as .BR pc . Only the first character of the .B pc string is used. .PP If the terminal has commands to save and restore the position of the cursor, give them as .B sc and .BR rc . .PP If the terminal has an extra \*(lqstatus line\*(rq that is not normally used by software, this fact can be indicated. If the status line is viewed as an extra line below the bottom line, then the capability .B hs should be given. Special strings to go to a position in the status line and to return from the status line can be given as .B ts and .BR fs . .RB ( fs must leave the cursor position in the same place that it was before .BR ts . If necessary, the .B sc and .B rc strings can be included in .B ts and .B fs to get this effect.) The capability .B ts takes one parameter, which is the column number of the status line to which the cursor is to be moved. If escape sequences and other special commands such as tab work while in the status line, the flag .B es can be given. A string that turns off the status line (or otherwise erases its contents) should be given as .BR ds . The status line is normally assumed to be the same width as the rest of the screen, .IR i.e. , .BR co . If the status line is a different width (possibly because the terminal does not allow an entire line to be loaded), then its width in columns can be indicated with the numeric parameter .BR ws . .PP If the terminal can move up or down half a line, this can be indicated with .B hu (half-line up) and .B hd (half-line down). This is primarily useful for superscripts and subscripts on hardcopy terminals. If a hardcopy terminal can eject to the next page (form feed), give this as .B ff (usually .BR ^L ). .PP If there is a command to repeat a given character a given number of times (to save time transmitting a large number of identical characters), this can be indicated with the parameterized string .BR rp . The first parameter is the character to be repeated and the second is the number of times to repeat it. (This is a .I terminfo\^ feature that is unlikely to be supported by a program that uses .IR termcap\^ .) .PP If the terminal has a settable command character, such as the Tektronix 4025, this can be indicated with .BR CC . A prototype command character is chosen which is used in all capabilities. This character is given in the .B CC capability to identify it. The following convention is supported on some UNIX systems: The environment is to be searched for a .B .SM CC variable, and if found, all occurrences of the prototype character are replaced by the character in the environment variable. This use of the .B .SM CC environment variable is a very bad idea, as it conflicts with .IR make\^ (1). .PP Terminal descriptions that do not represent a specific kind of known terminal, such as .IR switch\^ , .IR dialup\^ , .IR patch\^ , and .IR network\^ , should include the .B gn (generic) capability so that programs can complain that they do not know how to talk to the terminal. (This capability does not apply to .I virtual\^ terminal descriptions for which the escape sequences are known.) .PP If the terminal uses xoff/xon (\s-2DC3\s0/\s-2DC1\s0) handshaking for flow control, give .BR xo . Padding information should still be included so that routines can make better decisions about costs, but actual pad characters will not be transmitted. .PP If the terminal has a \*(lqmeta key\*(rq which acts as a shift key, setting the 8th bit of any character transmitted, then this fact can be indicated with .BR km . Otherwise, software will assume that the 8th bit is parity and it will usually be cleared. If strings exist to turn this \*(lqmeta mode\*(rq on and off, they can be given as .B mm and .BR mo . .PP If the terminal has more lines of memory than will fit on the screen at once, the number of lines of memory can be indicated with .BR lm . An explicit value of 0 indicates that the number of lines is not fixed, but that there is still more memory than fits on the screen. .PP If the terminal is one of those supported by the UNIX system virtual terminal protocol, the terminal number can be given as .BR vt . .PP Media copy strings which control an auxiliary printer connected to the terminal can be given as .BR ps : print the contents of the screen; .BR pf : turn off the printer; and .BR po : turn on the printer. When the printer is on, all text sent to the terminal will be sent to the printer. It is undefined whether the text is also displayed on the terminal screen when the printer is on. A variation .B pO takes one parameter and leaves the printer on for as many characters as the value of the parameter, then turns the printer off. The parameter should not exceed 255. All text, including .BR pf , is transparently passed to the printer while .B pO is in effect. .PP Strings to program function keys can be given as .BR pk , .BR pl , and .BR px . Each of these strings takes two parameters: the function key number to program (from 0 to 9) and the string to program it with. Function key numbers out of this range may program undefined keys in a terminal-dependent manner. The differences among the capabilities are that .B pk causes pressing the given key to be the same as the user typing the given string; .B pl causes the string to be executed by the terminal in local mode; and .B px causes the string to be transmitted to the computer. Unfortunately, due to lack of a definition for string parameters in .IR termcap\^ , only .I terminfo\^ supports these capabilities. .br .ne 5 .PP .B Glitches and Braindamage .PP Hazeltine terminals, which do not allow `~' characters to be displayed, should indicate .BR hz . .PP The .B nc capability, now obsolete, formerly indicated Datamedia terminals, which echo .B \er \en for carriage return then ignore a following linefeed. .PP Terminals that ignore a linefeed immediately after an .B am wrap, such as the Concept, should indicate .BR xn . .PP If .B ce is required to get rid of standout (instead of merely writing normal text on top of it), .B xs should be given. .PP Teleray terminals, where tabs turn all characters moved over to blanks, should indicate .B xt (destructive tabs). This glitch is also taken to mean that it is not possible to position the cursor on top of a \*(lqmagic cookie\*(rq, and that to erase standout mode it is necessary to use delete and insert line. .PP The Beehive Superbee, which is unable to correctly transmit the \s-2ESC\s0 or ^C characters, has .BR xb , indicating that the \*(lqf1\*(rq key is used for \s-2ESC\s0 and \*(lqf2\*(rq for ^C. (Only certain Superbees have this problem, depending on the ROM.) .PP Other specific terminal problems may be corrected by adding more capabilities of the form \fBx\fIx\^\fP. .br .ne 5 .PP .B Similar Terminals .PP If there are two very similar terminals, one can be defined as being just like the other with certain exceptions. The string capability .B tc can be given with the name of the similar terminal. This capability must be .IR last\^ , and the combined length of the entries must not exceed 1024. The capabilities given before .B tc override those in the terminal type invoked by .BR tc . A capability can be canceled by placing .B xx@ to the left of the .B tc invocation, where .I xx\^ is the capability. For example, the entry .PP hn\||\|2621\-nl:ks@:ke@:tc=2621: .PP defines a \*(lq2621\-nl\*(rq that does not have the .B ks or .B ke capabilities, hence does not turn on the function key labels when in visual mode. This is useful for different modes for a terminal, or for different user preferences. .SH AUTHOR William Joy .br Mark Horton added underlining and keypad support .SH FILES .DT /etc/termcap file containing terminal descriptions .SH SEE ALSO ex(1), more(1), tset(1), ul(1), vi(1), curses(3X), printf(3S), term(7). .SH "CAVEATS AND BUGS" .B Note: .I termcap\^ was replaced by .I terminfo\^ in UNIX System V Release 2.0. The transition will be relatively painless if capabilities flagged as \*(lqobsolete\*(rq are avoided. .PP Lines and columns are now stored by the kernel as well as in the termcap entry. Most programs now use the kernel information primarily; the information in this file is used only if the kernel does not have any information. .PP .I Vi\^ allows only 256 characters for string capabilities, and the routines in .IR termlib\^ (3) do not check for overflow of this buffer. The total length of a single entry (excluding only escaped newlines) may not exceed 1024. .PP Not all programs support all entries. ================================================ FILE: share/man/man5/tp.5 ================================================ .\" @(#)tp.5 6.1 (Berkeley) 5/15/85 .\" .TH TP 5 "May 15, 1985" .AT 3 .SH NAME tp \- DEC/mag tape formats .SH DESCRIPTION .I Tp dumps files to and extracts files from DECtape and magtape. The formats of these tapes are the same except that magtapes have larger directories. .PP Block zero contains a copy of a stand-alone bootstrap program. See .IR reboot (8). .PP Blocks 1 through 24 for DECtape (1 through 62 for magtape) contain a directory of the tape. There are 192 (resp. 496) entries in the directory; 8 entries per block; 64 bytes per entry. Each entry has the following format: .nf .IP "" .ta 8n +\w'unsigned short 'u struct { char pathname[32]; unsigned short mode; char uid; char gid; char unused1; char size[3]; long modtime; unsigned short tapeaddr; char unused2[16]; unsigned short checksum; }; .fi .DT .PP The path name entry is the path name of the file when put on the tape. If the pathname starts with a zero word, the entry is empty. It is at most 32 bytes long and ends in a null byte. Mode, uid, gid, size and time modified are the same as described under i-nodes (see file system .IR fs (5)). The tape address is the tape block number of the start of the contents of the file. Every file starts on a block boundary. The file occupies (size+511)/512 blocks of continuous tape. The checksum entry has a value such that the sum of the 32 words of the directory entry is zero. .PP Blocks above 25 (resp. 63) are available for file storage. .PP A fake entry has a size of zero. .SH "SEE ALSO" fs(5), tp(1) .SH BUGS The .I pathname, uid, gid, and .I size fields are too small. ================================================ FILE: share/man/man5/ttys.5 ================================================ .\" @(#)ttys.5 6.4.1 (2.11BSD) 1996/11/16 .\" .TH TTYS 5 "November 16, 1996" .AT 3 .SH NAME ttys \- terminal initialization data .SH DESCRIPTION The .I ttys file contains information that is used by various routines to initialize and control the use of terminal special files. This information is read with the .IR getttyent (3) library routines. There is one line in the .I ttys file per special file. Fields are separated by tabs and/or spaces. Some fields may contain more than one word and should be enclosed in double quotes. Blank lines and comments can appear anywhere in the file; comments are delimited by `#' and new line. Unspecified fields default to null. The first field is the terminal's entry in the device directory, /dev. The second field of the file is the command to execute for the line, typically .IR getty (8), which performs such tasks as baud-rate recognition, reading the login name, and calling .IR login (1). It can be, however, any desired command, for example the start up for a window system terminal emulator or some other daemon process, and can contain multiple words if quoted. The third field is the type of terminal normally connected to that tty line, as found in the .IR termcap (5) data base file. The remaining fields set flags in the .I ty_status entry (see .IR getttyent (3)) or specify a window system process that .IR init (8) will maintain for the terminal line. As flag values, the strings `on' and `off' specify whether .I init should execute the command given in the second field, while `secure' in addition to `on' allows root to login on this line. These flag fields should not be quoted. The string `window=' is followed by a quoted command string which .I init will execute before starting .IR getty . If the line ends in a comment, the comment is included in the .I ty_comment field of the ttyent structure. .PP Some examples: .PP .nf .ta \w'console\ 'u +\w'"/usr/libexec/getty std.9600"\ \ \ 'u +\w'hp2621-nl\ \ \ \ 'u +.7i console "/usr/libexec/getty std.1200" vt100 on secure ttyd0 "/usr/libexec/getty d1200" dialup on # 555-1234 ttyh0 "/usr/libexec/getty std.9600" hp2621-nl on # 254MC ttyh1 "/usr/libexec/getty std.9600" plugboard on # John's office ttyp0 none network ttyp1 none network off ttyv0 "/usr/new/xterm -L :0" vs100 on window="/usr/new/Xvs100 0" .fi .PP The first example permits root login on the console at 1200 baud, the second allows dialup at 1200 baud without root login, the third and fourth allow login at 9600 baud with terminal types of "hp2621-nl" and "plugboard" respectively, the fifth and sixth line are examples of network pseudo ttys, which should not have .I getty enabled on them, and the last example shows a terminal emulator and window system startup entry. .SH FILES /etc/ttys .SH "SEE ALSO" login(1), getttyent(3), gettytab(5), init(8), getty(8) ================================================ FILE: share/man/man5/types.5 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)types.5 6.1 (Berkeley) 5/15/85 .\" .TH TYPES 5 "May 15, 1985" .UC 4 .SH NAME types \- primitive system data types .SH SYNOPSIS .B #include .SH DESCRIPTION The data types defined in the include file are used in UNIX system code; some data of these types are accessible to user code: .PP .nf .ta \w'typedef\ \ 'u +\w'minor(x)\ \ 'u +\w' short\ \ 'u .so /usr/include/sys/types.h .fi .PP The form .I daddr_t is used for disk addresses except in an i-node on disk, see .IR fs (5). Times are encoded in seconds since 00:00:00 GMT, January 1, 1970. The major and minor parts of a device code specify kind and unit number of a device and are installation-dependent. Offsets are measured in bytes from the beginning of a file. The .I label_t variables are used to save the processor state while another process is running. .SH SEE ALSO fs(5), time(3), lseek(2), adb(1) ================================================ FILE: share/man/man5/tzfile.5 ================================================ .\" @(#)tzfile.5 1.2 (Berkeley) 3/11/87 .\" .TH TZFILE 5 "March 11, 1987" .AT 5 .SH NAME tzfile \- time zone information .SH SYNOPSIS .B #include .SH DESCRIPTION The time zone information files used by .IR tzset (3) begin with bytes reserved for future use, followed by three four-byte values of type .BR long , written in a ``standard'' byte order (the high-order byte of the value is written first). These values are, in order: .TP .I tzh_timecnt The number of "transition times" for which data is stored in the file. .TP .I tzh_typecnt The number of "local time types" for which data is stored in the file (must not be zero). .TP .I tzh_charcnt The number of characters of "time zone abbreviation strings" stored in the file. .PP The above header is followed by .I tzh_timecnt four-byte values of type .BR long , sorted in ascending order. These values are written in ``standard'' byte order. Each is used as a transition time (as returned by .IR time (2)) at which the rules for computing local time change. Next come .I tzh_timecnt one-byte values of type .BR "unsigned char" ; each one tells which of the different types of ``local time'' types described in the file is associated with the same-indexed transition time. These values serve as indices into an array of .I ttinfo structures that appears next in the file; these structures are defined as follows: .in +.5i .sp .nf .ta .5i +\w'unsigned int\0\0'u struct ttinfo { long tt_gmtoff; int tt_isdst; unsigned int tt_abbrind; }; .in -.5i .fi .sp Each structure is written as a four-byte value for .I tt_gmtoff of type .BR long , in a standard byte order, followed by a one-byte value for .I tt_isdst and a one-byte value for .IR tt_abbrind . In each structure, .I tt_gmtoff gives the number of seconds to be added to GMT, .I tt_isdst tells whether .I tm_isdst should be set by .I localtime (3) and .I tt_abbrind serves as an index into the array of time zone abbreviation characters that follow the .I ttinfo structure(s) in the file. .PP .I Localtime uses the first standard-time .I ttinfo structure in the file (or simply the first .I ttinfo structure in the absence of a standard-time structure) if either .I tzh_timecnt is zero or the time argument is less than the first transition time recorded in the file. .SH SEE ALSO ctime(3) ================================================ FILE: share/man/man5/utmp.5 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)utmp.5 6.2.1 (2.11BSD) 1996/11/27 .\" .TH UTMP 5 "November 27, 1996" .UC 4 .SH NAME utmp, wtmp \- login records .SH SYNOPSIS .B #include .SH DESCRIPTION The .I utmp file records information about who is currently using the system. The file is a sequence of entries with the following structure declared in the include file: .RS .PP .nf .so /usr/include/utmp.h .fi .RE .PP This structure gives the name of the special file associated with the user's terminal, the user's login name, and the time of the login in the form of .IR time (3C). .PP The .I wtmp file records all logins and logouts. A null user name indicates a logout on the associated terminal. Furthermore, the terminal name `~' indicates that the system was rebooted at the indicated time; the adjacent pair of entries with terminal names `\^|\^' and `{' indicate the system-maintained time just before and just after a .I date command has changed the system's idea of the time. .PP .I Wtmp is maintained by .IR login (1) and .IR init (8). Neither of these programs creates the file, so if it is removed record-keeping is turned off. It is summarized by .IR ac (8). .SH FILES /var/run/utmp .br /usr/adm/wtmp .SH "SEE ALSO" login(1), init(8), who(1), ac(8) ================================================ FILE: share/man/man5/uuencode.5 ================================================ .\" @(#)uuencode.5 6.1 (Berkeley) 5/15/85 .\" .TH UUENCODE 5 "May 15, 1985" .AT 3 .SH NAME uuencode \- format of an encoded uuencode file .SH DESCRIPTION Files output by .I uuencode(1C) consist of a header line, followed by a number of body lines, and a trailer line. .I Uudecode(1C) will ignore any lines preceding the header or following the trailer. Lines preceding a header must not, of course, look like a header. .PP The header line is distinguished by having the first 6 characters \*(lqbegin\ \*(rq. The word .I begin is followed by a mode (in octal), and a string which names the remote file. A space separates the three items in the header line. .PP The body consists of a number of lines, each at most 62 characters long (including the trailing newline). These consist of a character count, followed by encoded characters, followed by a newline. The character count is a single printing character, and represents an integer, the number of bytes the rest of the line represents. Such integers are always in the range from 0 to 63 and can be determined by subtracting the character space (octal 40) from the character. .PP Groups of 3 bytes are stored in 4 characters, 6 bits per character. All are offset by a space to make the characters printing. The last line may be shorter than the normal 45 bytes. If the size is not a multiple of 3, this fact can be determined by the value of the count on the last line. Extra garbage will be included to make the character count a multiple of 4. The body is terminated by a line with a count of zero. This line consists of one ASCII space. .PP The trailer line consists of \*(lqend\*(rq on a line by itself. .SH "SEE ALSO" uuencode(1C), uudecode(1C), uusend(1C), uucp(1C), mail(1) ================================================ FILE: share/man/man5/vfont.5 ================================================ .\" @(#)vfont.5 6.2.1 (2.11BSD) 1996/10/22 .\" .TH VFONT 5 "October 22, 1996" .AT 3 .SH NAME vfont \- font formats for the Benson-Varian or Versatec .SH SYNOPSIS .B /usr/share/vfont/\(** .SH DESCRIPTION The fonts for the printer/plotters have the following format. Each file contains a header, an array of 256 character description structures, and then the bit maps for the characters themselves. The header has the following format: .in +5 .nf .sp .ta 8n +\w'unsigned short 'u struct header { short magic; unsigned short size; short maxx; short maxy; short xtnd; } header; .fi .in -5 .PP The .I magic number is 0436 (octal). The .I maxx, .I maxy, and .I xtnd fields are not used at the current time. .I Maxx and .I maxy are intended to be the maximum horizontal and vertical size of any glyph in the font, in raster lines. The .I size is the size of the bit maps for the characters in bytes. Before the maps for the characters is an array of 256 structures for each of the possible characters in the font. Each element of the array has the form: .in +5 .nf .sp .ta 8n +\w'unsigned short 'u struct dispatch { unsigned short addr; short nbytes; char up; char down; char left; char right; short width; }; .fi .in -5 .PP The .I nbytes field is nonzero for characters which actually exist. For such characters, the .I addr field is an offset into the rest of the file where the data for that character begins. There are .I up+down rows of data for each character, each of which has .I left+right bits, rounded up to a number of bytes. The .I width field is not used by vcat, although it is to make width tables for .IR troff . It represents the logical width of the glyph, in raster lines, and shows where the base point of the next glyph would be. .SH FILES /usr/share/vfont/\(** .SH SEE ALSO troff(1), pti(1), vfontinfo(1) ================================================ FILE: share/man/man5/vgrindefs.5 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)vgrindefs.5 6.1.1 (2.11BSD) 1996/10/22 .\" .tr || .TH VGRINDEFS 5 "October 22, 1996" .UC 5 .SH NAME vgrindefs \- vgrind's language definition data base .SH SYNOPSIS .B /usr/share/misc/vgrindefs .SH DESCRIPTION .I Vgrindefs contains all language definitions for vgrind. The data base is very similar to .IR termcap (5). .SH FIELDS The following table names and describes each field. .PP .nf .ta \w'k0-k9 'u +\w'Type 'u \fBName Type Description\fR pb str regular expression for start of a procedure bb str regular expression for start of a lexical block be str regular expression for the end of a lexical block cb str regular expression for the start of a comment ce str regular expression for the end of a comment sb str regular expression for the start of a string se str regular expression for the end of a string lb str regular expression for the start of a character constant le str regular expression for the end of a character constant tl bool present means procedures are only defined at the top lexical level oc bool present means upper and lower case are equivalent kw str a list of keywords separated by spaces .fi .PP .B Example .PP The following entry, which describes the C language, is typical of a language entry. .PP .nf C|c:\ :pb=^\ed?*?\ed?\ep\ed?\e(\ea?\e):bb={:be=}:cb=/*:ce=*/:sb=":se=\ee":\e :lb=':le=\ee':tl:\e :kw=asm auto break case char continue default do double else enum\e extern float for fortran goto if int long register return short\e sizeof static struct switch typedef union unsigned while #define\e #else #endif #if #ifdef #ifndef #include #undef # define else endif\e if ifdef ifndef include undef: .fi .PP Note that the first field is just the language name (and any variants of it). Thus the C language could be specified to .IR vgrind (1) as "c" or "C". .PP Entries may continue onto multiple lines by giving a \e as the last character of a line. Capabilities in .I vgrindefs are of two types: Boolean capabilities which indicate that the language has some particular feature and string capabilities which give a regular expression or keyword list. .PP .B REGULAR EXPRESSIONS .PP .I Vgrindefs uses regular expression which are very similar to those of .IR ex (1) and .IR lex (1). The characters `^', `$', `:' and `\e' are reserved characters and must be "quoted" with a preceding \e if they are to be included as normal characters. The metasymbols and their meanings are: .IP $ the end of a line .IP ^ the beginning of a line .IP \ed a delimiter (space, tab, newline, start of line) .IP \ea matches any string of symbols (like .* in lex) .IP \ep matches any alphanumeric name. In a procedure definition (pb) the string that matches this symbol is used as the procedure name. .IP () grouping .IP | alternation .IP ? last item is optional .IP \ee preceding any string means that the string will not match an input string if the input string is preceded by an escape character (\e). This is typically used for languages (like C) which can include the string delimiter in a string b escaping it. .PP Unlike other regular expressions in the system, these match words and not characters. Hence something like "(tramp|steamer)flies?" would match "tramp", "steamer", "trampflies", or "steamerflies". .PP .B KEYWORD LIST .PP The keyword list is just a list of keywords in the language separated by spaces. If the "oc" boolean is specified, indicating that upper and lower case are equivalent, then all the keywords should be specified in lower case. .SH FILES .DT /usr/share/misc/vgrindefs file containing terminal descriptions .SH SEE ALSO vgrind(1), troff(1) .SH AUTHOR Dave Presotto .SH BUGS ================================================ FILE: share/man/man6/Makefile ================================================ # # Copyright (c) 1987 Regents of the University of California. # All rights reserved. # # Redistribution and use in source and binary forms are permitted # provided that the above copyright notice and this paragraph are # duplicated in all such forms and that any documentation, # advertising materials, and other materials related to such # distribution and use acknowledge that the software was developed # by the University of California, Berkeley. The name of the # University may not be used to endorse or promote products derived # from this software without specific prior written permission. # THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED # WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. # # @(#)Makefile 5.4.1 (2.11BSD) 1996/01/26 # TOPSRC!=cd ../../..; pwd include ${TOPSRC}/share/mk/sys.mk MDIR= /usr/share/man/cat6 SRCS= intro.6 OBJS= intro.0 .SUFFIXES: .6 .0 .6.0: ${MANROFF} $*.6 > $*.0 all: _make_01 _make_01: ${OBJS} clean: FRC rm -f ${OBJS} install: _make_01 cp ${OBJS} ${DESTDIR}${MDIR} FRC: ================================================ FILE: share/man/man6/intro.6 ================================================ .\" $OpenBSD: intro.6,v 1.17 2018/09/30 13:24:33 schwarze Exp $ .\" .\" Copyright (c) 1999 Hugh Graham .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .Dd May 24, 2025 .Dt INTRO 6 .Os .Sh NAME .Nm intro .Nd introduction to the games .Sh SYNOPSIS Would you like to play a game? .Sh DESCRIPTION The manual pages in section 6 contain information about the various games and diversions optionally installed in .Pa /usr/games . Currently available games are: .Bl -ohang -offset indent .It aclock ASCII clock for UNIX console. .It Xr adventure 6 An exploration game. .It Xr arithmetic 6 Quiz on simple arithmetic. .It Xr atc 6 Air traffic controller game. .It Xr backgammon 6 The backgammon game. .It Xr banner 6 Print strings in large letters. .It Xr battlestar 6 A tropical adventure game. .It Xr bcd 6 Reformat input as punch cards. .It Xr boggle 6 Word search game. .It Xr caesar 6 Decrypt caesar cyphers. .It Xr canfield 6 A version of the solitaire card game. .It Xr cfscores 6 Print out the current status of a .Xr canfield 6 account. .It Xr cribbage 6 The card game cribbage. .It factor Factor a number. .It Xr fish 6 Play .Dq Go Fish! . .It Xr fortune 6 Print a random adage. .It Xr hangman 6 Play hangman. .It Xr mille 6 Play Mille Bornes. .It Xr monop 6 Play monopoly. .It morse Reformat input as morse code. .It Xr number 6 Convert Arabic numerals to English. .It Xr pig 6 .\" Do not fix the following gibberish and broken link. .\" According to jmc@, both are intentional exactly as they are. Eformatray inputway asway Igpay Atinlay. Eesay .Xr igpay 6 . .It Xr pom 6 Display the phase of the moon. .It Xr ppt 6 Reformat input as paper tape. .It primes Generate primes. .It Xr quiz 6 Random knowledge tests. .It Xr rain 6 Animated raindrops display. .It Xr robots 6 Fight off villainous robots. .It Xr rogue 6 Explore the Dungeons of Doom. .It Xr sail 6 Multi-user wooden ships and iron men. .It Xr snake 6 Display chase game. .It Xr snscore 6 See who wastes time playing .Xr snake 6 . .It teachgammon Backgammon rules and tutorial. See .Xr backgammon 6 . .It Xr trek 6 Trekkie game. .It Xr worm 6 Play the growing worm game. .It Xr worms 6 Animate worms on a display terminal. .It Xr wump 6 Hunt the wumpus in an underground cave. .El .Sh FILES .Bl -tag -width "/usr/games/libXXX" -compact .It Pa /usr/games Location of games. .It Pa /usr/games/lib Data files for games. .El .Sh SEE ALSO .Xr adventure 6 , .Xr arithmetic 6 , .Xr atc 6 , .Xr backgammon 6 , .Xr banner 6 , .Xr battlestar 6 , .Xr bcd 6 , .Xr boggle 6 , .Xr caesar 6 , .Xr canfield 6 , .Xr cfscores 6 , .Xr cribbage 6 , .Xr fish 6 , .Xr fortune 6 , .Xr hangman 6 , .Xr mille 6 , .Xr monop 6 , .Xr number 6 , .Xr pig 6 , .Xr pom 6 , .Xr ppt 6 , .Xr primes 6 , .Xr quiz 6 , .Xr rain 6 , .Xr robots 6 , .Xr rogue 6 , .Xr sail 6 , .Xr snake 6 , .Xr snscore 6 , .Xr trek 6 , .Xr worm 6 , .Xr worms 6 , .Xr wump 6 .Sh HISTORY An .Nm intro manual for section 6 appeared in .Bx Disco 2.5. ================================================ FILE: share/man/man7/Makefile ================================================ # # Copyright (c) 1987 Regents of the University of California. # All rights reserved. # # Redistribution and use in source and binary forms are permitted # provided that the above copyright notice and this paragraph are # duplicated in all such forms and that any documentation, # advertising materials, and other materials related to such # distribution and use acknowledge that the software was developed # by the University of California, Berkeley. The name of the # University may not be used to endorse or promote products derived # from this software without specific prior written permission. # THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED # WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. # # @(#)Makefile 5.4.1 (2.11BSD) 1996/01/26 # TOPSRC!=cd ../../..; pwd include ${TOPSRC}/share/mk/sys.mk MDIR= /usr/share/man/cat7 SRCS= ascii.7 environ.7 eqnchar.7 hier.7 hostname.7 intro.7 mailaddr.7 \ man.7 me.7 ms.7 term.7 OBJS= ascii.0 environ.0 eqnchar.0 hier.0 hostname.0 intro.0 mailaddr.0 \ man.0 me.0 ms.0 term.0 .SUFFIXES: .7 .0 .7.0: ${MANROFF} $*.7 > $*.0 all: _make_01 _make_01: ${OBJS} clean: FRC rm -f ${OBJS} install: _make_01 cp ${OBJS} ${DESTDIR}${MDIR} ln -f ${DESTDIR}${MDIR}/intro.0 ${DESTDIR}${MDIR}/miscellaneous.0 FRC: ================================================ FILE: share/man/man7/ascii.7 ================================================ .\" @(#)ascii.7 6.1 (Berkeley) 5/20/85 .\" .TH ASCII 7 "May 20, 1985" .AT 3 .SH NAME ascii \- map of ASCII character set .SH SYNOPSIS .B cat /usr/pub/ascii .SH DESCRIPTION .I Ascii is a map of the ASCII character set, to be printed as needed. It contains: .nf .cs R 20 |000 nul|001 soh|002 stx|003 etx|004 eot|005 enq|006 ack|007 bel| |010 bs |011 ht |012 nl |013 vt |014 np |015 cr |016 so |017 si | |020 dle|021 dc1|022 dc2|023 dc3|024 dc4|025 nak|026 syn|027 etb| |030 can|031 em |032 sub|033 esc|034 fs |035 gs |036 rs |037 us | |040 sp |041 ! |042 " |043 # |044 $ |045 % |046 & |047 \' | |050 ( |051 ) |052 * |053 + |054 , |055 \- |056 . |057 / | |060 0 |061 1 |062 2 |063 3 |064 4 |065 5 |066 6 |067 7 | |070 8 |071 9 |072 : |073 ; |074 < |075 = |076 > |077 ? | |100 @ |101 A |102 B |103 C |104 D |105 E |106 F |107 G | |110 H |111 I |112 J |113 K |114 L |115 M |116 N |117 O | |120 P |121 Q |122 R |123 S |124 T |125 U |126 V |127 W | |130 X |131 Y |132 Z |133 [ |134 \\ |135 ] |136 ^ |137 _ | |140 \` |141 a |142 b |143 c |144 d |145 e |146 f |147 g | |150 h |151 i |152 j |153 k |154 l |155 m |156 n |157 o | |160 p |161 q |162 r |163 s |164 t |165 u |166 v |167 w | |170 x |171 y |172 z |173 { |174 | |175 } |176 ~ |177 del| | 00 nul| 01 soh| 02 stx| 03 etx| 04 eot| 05 enq| 06 ack| 07 bel| | 08 bs | 09 ht | 0a nl | 0b vt | 0c np | 0d cr | 0e so | 0f si | | 10 dle| 11 dc1| 12 dc2| 13 dc3| 14 dc4| 15 nak| 16 syn| 17 etb| | 18 can| 19 em | 1a sub| 1b esc| 1c fs | 1d gs | 1e rs | 1f us | | 20 sp | 21 ! | 22 " | 23 # | 24 $ | 25 % | 26 & | 27 \' | | 28 ( | 29 ) | 2a * | 2b + | 2c , | 2d \- | 2e . | 2f / | | 30 0 | 31 1 | 32 2 | 33 3 | 34 4 | 35 5 | 36 6 | 37 7 | | 38 8 | 39 9 | 3a : | 3b ; | 3c < | 3d = | 3e > | 3f ? | | 40 @ | 41 A | 42 B | 43 C | 44 D | 45 E | 46 F | 47 G | | 48 H | 49 I | 4a J | 4b K | 4c L | 4d M | 4e N | 4f O | | 50 P | 51 Q | 52 R | 53 S | 54 T | 55 U | 56 V | 57 W | | 58 X | 59 Y | 5a Z | 5b [ | 5c \\ | 5d ] | 5e ^ | 5f _ | | 60 \` | 61 a | 62 b | 63 c | 64 d | 65 e | 66 f | 67 g | | 68 h | 69 i | 6a j | 6b k | 6c l | 6d m | 6e n | 6f o | | 70 p | 71 q | 72 r | 73 s | 74 t | 75 u | 76 v | 77 w | | 78 x | 79 y | 7a z | 7b { | 7c | | 7d } | 7e ~ | 7f del| .fi .cs R .SH FILES /usr/pub/ascii ================================================ FILE: share/man/man7/environ.7 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)environ.7 6.1 (Berkeley) 5/20/85 .\" .TH ENVIRON 7 "May 20, 1985" .UC 5 .SH NAME environ \- user environment .SH SYNOPSIS .B extern char **environ; .SH DESCRIPTION An array of strings called the `environment' is made available by .IR execve (2) when a process begins. By convention these strings have the form .RI ` name = value '. The following names are used by various commands: .TP "\w'TERMCAP 'u" PATH The sequence of directory prefixes that .I sh, time, .IR nice (1), etc., apply in searching for a file known by an incomplete path name. The prefixes are separated by `:'. .IR Login (1) sets PATH=:/usr/ucb:/bin:/usr/bin. .TP HOME A user's login directory, set by .IR login (1) from the password file .IR passwd (5). .TP TERM The kind of terminal for which output is to be prepared. This information is used by commands, such as .I nroff or .IR plot (1G), which may exploit special terminal capabilities. See .I /etc/termcap .RI ( termcap (5)) for a list of terminal types. .TP SHELL The file name of the users login shell. .TP TERMCAP The string describing the terminal in TERM, or the name of the termcap file, see .IR termcap (5), termcap (3X). .TP EXINIT A startup list of commands read by .IR ex (1), .IR edit (1), and .IR vi (1). .TP USER The login name of the user. .TP PRINTER The name of the default printer to be used by .IR lpr (1), .IR lpq (1), and .IR lprm (1). .PP Further names may be placed in the environment by the .I export command and `name=value' arguments in .IR sh (1), or by the .I setenv command if you use .IR csh (1). Arguments may also be placed in the environment at the point of an .IR execve (2). It is unwise to conflict with certain .IR sh (1) variables that are frequently exported by `.profile' files: MAIL, PS1, PS2, IFS. .SH SEE ALSO csh(1), ex(1), login(1), sh(1), execve(2), system(3), termcap(3X), termcap(5) ================================================ FILE: share/man/man7/eqnchar.7 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)eqnchar.7 6.1 (Berkeley) 5/20/85 .\" .TH EQNCHAR 7 "May 20, 1985" .UC 3 .EQ tdefine ciplus % "\o'\(pl\(ci'" % ndefine ciplus % O+ % tdefine citimes % "\o'\(mu\(ci'" % ndefine citimes % Ox % tdefine =wig % "\(eq\h'-\w'\(eq'u-\w'\s-2\(ap'u/2u'\v'-.4m'\s-2\z\(ap\(ap\s+2\v'.4m'\h'\w'\(eq'u-\w'\s-2\(ap'u/2u'" % ndefine =wig % ="~" % tdefine bigstar % "\o'\(pl\(mu'" % ndefine bigstar % X|- % tdefine =dot % "\z\(eq\v'-.6m'\h'.2m'\s+2.\s-2\v'.6m'\h'.1m'" % ndefine =dot % = dot % tdefine orsign % "\s-2\v'-.15m'\z\e\e\h'-.05m'\z\(sl\(sl\v'.15m'\s+2" % ndefine orsign % \e/ % tdefine andsign % "\s-2\v'-.15m'\z\(sl\(sl\h'-.05m'\z\e\e\v'.15m'\s+2" % ndefine andsign % /\e % tdefine =del % "\v'.3m'\z=\v'-.6m'\h'.3m'\s-1\(*D\s+1\v'.3m'" % ndefine =del % = to DELTA % tdefine oppA % "\s-2\v'-.15m'\z\e\e\h'-.05m'\z\(sl\(sl\v'-.15m'\h'-.75m'\z-\z-\h'.2m'\z-\z-\v'.3m'\h'.4m'\s+2" % ndefine oppA % V- % tdefine oppE %"\s-3\v'.2m'\z\(em\v'-.5m'\z\(em\v'-.5m'\z\(em\v'.55m'\h'.9m'\z\(br\z\(br\v'.25m'\s+3" % ndefine oppE % E/ % tdefine incl % "\s-1\z\(or\h'-.1m'\v'-.45m'\z\(em\v'.7m'\z\(em\v'.2m'\(em\v'-.45m'\s+1" % ndefine incl % C_ % tdefine nomem % "\o'\(mo\(sl'" % ndefine nomem % C-/ % tdefine angstrom % "\fR\zA\v'-.3m'\h'.2m'\(de\v'.3m'\fP\h'.2m'" % ndefine angstrom % A to o % tdefine star %{ roman "\v'.5m'\s+3*\s-3\v'-.5m'"}% ndefine star % * % tdefine || % \(or\(or % tdefine wig % "\z>\v'.4m'\(ap\v'-.4m'" % ndefine >wig %{ > from "~" }% tdefine langle % "\s-3\b'\(sl\e'\s0" % ndefine langle %<% tdefine rangle % "\s-3\b'\e\(sl'\s0" % ndefine rangle %>% tdefine hbar % "\zh\v'-.6m'\h'.05m'\(ru\v'.6m'" % ndefine hbar % h\u-\d % ndefine ppd % _| % tdefine ppd % "\o'\(ru\s-2\(or\s+2'" % tdefine <-> % "\o'\(<-\(->'" % ndefine <-> % "<-->" % tdefine <=> % "\s-2\z<\v'.05m'\h'.2m'\z=\h'.55m'=\h'-.6m'\v'-.05m'>\s+2" % ndefine <=> % "<=>" % tdefine |< % "\o'<\(or'" % ndefine |< % <| % tdefine |> % "\o'>\(or'" % ndefine |> % |> % tdefine ang % "\v'-.15m'\z\s-2\(sl\s+2\v'.15m'\(ru" % ndefine ang % /_ % tdefine rang % "\z\(or\h'.15m'\(ru" % ndefine rang % L % tdefine 3dot % "\v'-.8m'\z.\v'.5m'\z.\v'.5m'.\v'-.2m'" % ndefine 3dot % .\u.\u.\d\d % tdefine thf % ".\v'-.5m'.\v'.5m'." % ndefine thf % ..\u.\d % tdefine quarter % roman \(14 % ndefine quarter % 1/4 % tdefine 3quarter % roman \(34 % ndefine 3quarter % 3/4 % tdefine degree % \(de % ndefine degree % nothing sup o % tdefine square % \(sq % ndefine square % [] % tdefine circle % \(ci % ndefine circle % O % tdefine blot % "\fB\(sq\fP" % ndefine blot % HIX % tdefine bullet % \(bu % ndefine bullet % oxe % tdefine -wig % "\(~=" % ndefine -wig % - to "~" % tdefine wig % \(ap % ndefine wig % "~" % tdefine prop % \(pt % ndefine prop % oc % tdefine empty % \(es % ndefine empty % O/ % tdefine member % \(mo % ndefine member % C- % tdefine cup % \(cu % ndefine cup % U % define cap % \(ca % define subset % \(sb % define supset % \(sp % define !subset % \(ib % define !supset % \(ip % .EN .SH NAME eqnchar \- special character definitions for eqn .SH SYNOPSIS .B eqn /usr/pub/eqnchar [ files ] .B \(bv troff [ options ] .PP .B neqn /usr/pub/eqnchar [ files ] .B \(bv nroff [ options ] .SH DESCRIPTION .I Eqnchar contains .I troff and .I nroff character definitions for constructing characters that are not available on the Graphic Systems typesetter. These definitions are primarily intended for use with .I eqn and .IR neqn . It contains definitions for the following characters .PP .nf .ta \w'angstrom 'u \n(.lu/3u +\w'angstrom 'u \n(.lu*2u/3u +\w'angstrom 'u .EQ "ciplus" ciplus "|\||" || "square" square .EN .EQ "citimes" citimes "langle" langle "circle" circle .EN .EQ "wig" wig "rangle" rangle "blot" blot .EN .EQ "-wig" -wig "hbar" hbar "bullet" bullet .EN .EQ ">wig" >wig "ppd" ppd "prop" prop .EN .EQ "" <-> "empty" empty .EN .EQ "=wig" =wig "<=>" <=> "member" member .EN .EQ "star" star "|\|<" |< "nomem" nomem .EN .EQ "bigstar" bigstar "|\|>" |> "cup" cup .EN .EQ "=dot" =dot "ang" ang "cap" cap .EN .EQ "orsign" orsign "rang" rang "incl" incl .EN .EQ "andsign" andsign "3dot" 3dot "subset" subset .EN .EQ "=del" =del "thf" thf "supset" supset .EN .EQ "oppA" oppA "quarter" quarter "!subset" !subset .EN .EQ "oppE" oppE "3quarter" 3quarter "!supset" !supset .EN .EQ "angstrom" angstrom "degree" degree .EN .SH FILES /usr/pub/eqnchar .SH SEE ALSO troff(1), eqn(1) ================================================ FILE: share/man/man7/hier.7 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)hier.7 6.1 (Berkeley) 5/20/85 .\" .TH HIER 7 "May 20, 1985" .UC 4 .SH NAME hier \- file system hierarchy .SH DESCRIPTION The following outline gives a quick tour through a representative directory hierarchy. .na .nh .IP / root .PD 0 .IP /vmunix the kernel binary (UNIX itself) .IP /lost+found directory for connecting detached files for .IR fsck (8) .IP /dev/ devices (4) .RS .IP MAKEDEV shell script to create special files .IP MAKEDEV.local site specific part of MAKEDEV .IP console main console, .IR tty (4) .IP tty* terminals, .IR tty (4) .IP hp* disks, .IR hp (4) .IP rhp* raw disks, .IR hp (4) .IP up* UNIBUS disks .IR up (4) .IP ... .RE .IP /bin/ utility programs, cf /usr/bin/ (1) .RS .IP as assembler .IP cc C compiler executive, cf /lib/ccom, /lib/cpp, /lib/c2 .IP csh C shell .IP ... .RE .IP /lib/ object libraries and other stuff, cf /usr/lib/ .RS .IP libc.a system calls, standard I/O, etc. (2,3,3S) .IP ... .IP ccom C compiler proper .IP cpp C preprocessor .IP c2 C code improver .IP ... .RE .IP /etc/ essential data and maintenance utilities; sect (8) .RS .IP dump dump program .IR dump (8) .IP passwd password file, .IR passwd (5) .IP group group file, .IR group (5) .IP motd message of the day, .IR login (1) .IP termcap description of terminal capabilities, .IR termcap (5) .IP ttytype table of what kind of terminal is on each port, .IR ttytype (5) .IP mtab mounted file table, .IR mtab (5) .IP dumpdates dump history, .IR dump (8) .IP fstab file system configuration table .IR fstab (5) .IP disktab disk characteristics and partition tables, .IR disktab (5) .IP hosts host name to network address mapping file, .IR hosts (5) .IP networks network name to network number mapping file, .IR networks (5) .IP protocols protocol name to protocol number mapping file, .IR protocols (5) .IP services network services definition file, .IR services (5) .IP remote names and description of remote hosts for .IR tip (1C), .IR remote (5) .IP phones private phone numbers for remote hosts, as described in .IR phones (5) .IP ttys properties of terminals, .IR ttys (5) .IP getty part of .IR login , .IR getty (8) .IP init the parent of all processes, .IR init (8) .IP rc shell program to bring the system up .IP rc.local site dependent portion of .I rc .IP cron the clock daemon, .IR cron (8) .IP mount .IR mount (8) .IP ... .RE .IP /sys/ system source .RS .IP h/ header (include) files .RS .IP acct.h .IR acct (5) .IP stat.h .IR stat (2) .IP ... .RE .IP sys/ machine independent system source .RS .IP init_main.c .IP uipc_socket.c .IP ufs_syscalls.c .IP ... .RE .IP conf/ site configuration files .RS .IP GENERIC .IP ... .RE .IP net/ general network source .IP netinet/ DARPA Internet network source .IP netimp/ network code related to use of an IMP .RS .IP if_imp.c .IP if_imphost.c .IP if_imphost.h .IP ... .RE .IP vax/ source specific to the VAX .RS .IP locore.s .IP machdep.c .IP ... .RE .IP vaxuba/ device drivers for hardware which resides on the UNIBUS .RS .IP uba.c .IP dh.c .IP up.c .IP ... .RE .IP vaxmba/ device drivers for hardware which resides on the MASBUS .RS .IP mba.c .IP hp.c .IP ht.c .IP ... .RE .IP vaxif network interface drivers for the VAX .RS .IP if_en.c .IP if_ec.c .IP if_vv.c .IP ... .RE .RE .IP /tmp/ temporary files, usually on a fast device, cf /usr/tmp/ .RS .IP e* used by .IR ed (1) .IP ctm* used by .IR cc (1) .IP ... .RE .IP /usr/ general-pupose directory, usually a mounted file system .RS .IP adm/ administrative information .RS .IP wtmp login history, .IR utmp (5) .IP messages hardware error messages .IP tracct phototypesetter accounting, .IR troff (1) .IP lpacct line printer accounting .IR lpr (1) .IP "vaacct, vpacct" varian and versatec accounting .IR vpr (1), .IR vtroff (1), .IR pac (8) .RE .RE .IP /usr\t/bin .RS utility programs, to keep /bin/ small .IP tmp/ temporaries, to keep /tmp/ small .RS .IP stm* used by .IR sort (1) .IP raster used by .IR plot (1G) .RE .IP dict/ word lists, etc. .RS .IP words principal word list, used by .IR look (1) .IP spellhist history file for .IR spell (1) .RE .IP games/ .RS .IP hangman .IP lib/ library of stuff for the games .RS .IP quiz.k/ what .IR quiz (6) knows .RS .IP index category index .IP africa countries and capitals .IP ... .RE .IP ... .RE .IP ... .RE .IP include/ standard #include files .RS .IP a.out.h object file layout, .IR a.out (5) .IP stdio.h standard I/O, .IR intro (3S) .IP math.h (3M) .IP ... .IP sys/ system-defined layouts, cf /sys/h .IP net/ symbolic link to sys/net .IP machine/ symbolic link to sys/machine .IP ... .RE .IP lib/ object libraries and stuff, to keep /lib/ small .RS .IP atrun scheduler for .IR at (1) .IP lint/ utility files for lint .RS .IP lint[12] subprocesses for .IR lint (1) .IP llib-lc dummy declarations for /lib/libc.a, used by .IR lint (1) .IP llib-lm dummy declarations for /lib/libc.m .IP ... .RE .IP struct/ passes of .IR struct (1) .IP ... .IP tmac/ macros for .IR troff (1) .RS .IP tmac.an macros for .IR man (7) .IP tmac.s macros for .IR ms (7) .IP ... .RE .IP font/ fonts for .IR troff (1) .RS .IP ftR Times Roman .IP ftB Times Bold .IP ... .RE .IP uucp/ programs and data for .IR uucp (1C) .RS .IP L.sys remote system names and numbers .IP uucico the real copy program .IP ... .RE .IP units conversion tables for .IR units (1) .IP eign list of English words to be ignored by .IR ptx (1) .RE .RE .br .ne 5 .IP /usr/\tman/ .RS volume 1 of this manual, .IR man (1) .RS .IP man0/ general .RS .IP intro introduction to volume 1, .IR ms (7) format .IP xx template for manual page .RE .IP man1/ chapter 1 .RS .IP as.1 .IP mount.1m .IP ... .RE .IP ... .IP cat1/ preformatted pages for section 1 .IP ... .RE .IP msgs/ messages, cf .IR msgs (1) .RS .IP bounds highest and lowest message .RE .IP new/ binaries of new versions of programs .IP preserve/ editor temporaries preserved here after crashes/hangups .IP public/ binaries of user programs - write permission to everyone .IP spool/ delayed execution files .RS .IP at/ used by .IR at (1) .IP lpd/ used by .IR lpr (1) .RS .IP lock present when line printer is active .IP cf* copy of file to be printed, if necessary .IP df* daemon control file, .IR lpd (8) .IP tf* transient control file, while .I lpr is working .RE .IP uucp/ work files and staging area for .IR uucp (1C) .RS .IP LOGFILE summary log .IP LOG.* log file for one transaction .RE .IP mail/ mailboxes for .IR mail (1) .RS .TP .I name mail file for user .I name .TP .IR name .lock lock file while .I name is receiving mail .RE .IP secretmail/ like .IR mail / .IP uucp/ work files and staging area for .IR uucp (1C) .RS .IP LOGFILE summary log .IP LOG.* log file for one transaction .IP mqueue/ mail queue for .IR sendmail (8) .RE .RE .TP .I wd initial working directory of a user, typically .I wd is the user's login name .RS .TP .BR . profile set environment for .IR sh (1), .IR environ (7) .TP .BR . project what you are doing (used by ( .IR finger (1) ) .TP .BR . cshrc startup file for .IR csh (1) .TP .BR . exrc startup file for .IR ex (1) .TP .BR . plan what your short-term plans are (used by .IR finger (1) ) .TP .BR . netrc startup file for various network programs .TP .BR . msgsrc startup file for .IR msgs (1) .TP .BR . mailrc startup file for .IR mail (1) .IP calendar user's datebook for .IR calendar (1) .RE .IP doc/ papers, mostly in volume 2 of this manual, typically in .IR ms (7) format .RS .IP as/ assembler manual .IP c C manual .IP ... .RE .RE .RE .IP /usr/\tsrc/ .RS .IP source programs for utilities, etc. .RS .IP bin/ source of commands in /bin .RS .IP as/ assembler .IP ar.c source for .IR ar (1) .IP ... .RE .IP usr.bin/ source for commands in /usr/bin .RS .IP troff/ source for .I nroff and .IR troff (1) .RS .IP font/ source for font tables, /usr/lib/font/ .RS .IP ftR.c Roman .IP ... .RE .IP term/ terminal characteristics tables, /usr/lib/term/ .RS .IP tab300.c DASI 300 .IP ... .RE .IP ... .RE .RE .IP ucb source for programs in /usr/ucb .IP games/ source for /usr/games .IP lib/ source for programs and archives in /lib .RS .IP libc/ C runtime library .RS .IP csu/ startup and wrapup routines needed with every C program .RS .IP crt0.s regular startup .IP mcrt0.s modified startup for .I cc \-p .RE .IP sys/ system calls (2) .RS .IP access.s .IP brk.s .IP ... .RE .RE .IP stdio/ standard I/O functions (3S) .RS .IP fgets.c .IP fopen.c .IP ... .RE .IP gen/ other functions in (3) .RS .IP abs.c .IP ... .RE .IP net/ network functions in (3N) .RS .IP gethostbyname.c .IP ... .RE .RE .IP local/ source which isn't normally distributed .IP new/ source for new versions of commands and library routines .IP old/ source for old versions of commands and library routines .IP ucb/ binaries of programs developed at UCB .RS .IP ... .IP edit editor for beginners .IP ex command editor for experienced users .IP ... .IP mail mail reading/sending subsystem .IP man on line documentation .IP ... .IP pi Pascal translator .IP px Pascal interpreter .IP ... .IP vi visual editor .RE .RE .ad .SH SEE ALSO ls(1), apropos(1), whatis(1), whereis(1), finger(1), which(1), ncheck(8), find(1), grep(1) .SH BUGS The position of files is subject to change without notice. ================================================ FILE: share/man/man7/hostname.7 ================================================ .\" Copyright (c) 1987 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)hostname.7 6.1 (Berkeley) 11/21/87 .\" .TH HOSTNAME 7 "November 21, 1987" .UC 5 .SH NAME hostname \- host name resolution description .SH DESCRIPTION Hostnames are domains, where a domain is a hierarchical, dot-separated list of subdomains; for example, the machine monet, in the Berkeley subdomain of the EDU subdomain of the ARPANET would be represented as .br monet.Berkeley.EDU .br (with no trailing dot). .PP Hostnames are often used with network client and server programs, which must generally translate the name to an address for use. (This function is generally performed by the library routine .IR gethostbyname (3).) Hostnames are resolved by the internet name resolver in the following fashion. .PP If the name consists of a single component, i.e. contains no dot, and if the environment variable ``HOSTALIASES'' is set to the name of a file, that file is searched for an string matching the input hostname. The file should consist of lines made up of two white-space separated strings, the first of which is the hostname alias, and the second of which is the complete hostname to be substituted for that alias. If a case-sensitive match is found between the hostname to be resolved and the first field of a line in the file, the substituted name is looked up with no further processing. .PP If the input name ends with a trailing dot, the trailing dot is removed, and the remaining name is looked up with no further processing. .PP If the input name does not end with a trailing dot, it is looked up in the local domain and its parent domains until either a match is found or fewer than 2 components of the local domain remain. For example, in the domain CS.Berkeley.EDU, the name lithium.CChem will be checked first as lithium.CChem.CS.Berkeley.EDU and then as lithium.CChem.Berkeley.EDU. Lithium.CChem.EDU will not be tried, as the there is only one component remaining from the local domain. .SH SEE ALSO gethostbyname(3), resolver(5), mailaddr(7), named(8), RFC883 ================================================ FILE: share/man/man7/intro.7 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)intro.7 6.1 (Berkeley) 5/20/85 .\" .TH INTRO 7 "May 20, 1985" .UC 5 .SH NAME miscellaneous \- miscellaneous useful information pages .SH DESCRIPTION This section contains miscellaneous documentation, mostly in the area of text processing macro packages for .IR troff (1). .sp 2 .nf .ta 1.25i ascii map of ASCII character set environ user environment eqnchar special character definitions for eqn hier file system hierarchy mailaddr mail addressing description man macros to typeset manual pages me macros for formatting papers ms macros for formatting manuscripts term conventional names for terminals .fi ================================================ FILE: share/man/man7/mailaddr.7 ================================================ .\" Copyright (c) 1983, 1987 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)mailaddr.7 6.4 (Berkeley) 7/27/87 .\" .TH MAILADDR 7 "July 27, 1987" .UC 5 .SH NAME mailaddr \- mail addressing description .SH DESCRIPTION Mail addresses are based on the ARPANET protocol listed at the end of this manual page. These addresses are in the general format .PP user@domain .PP where a domain is a hierarchical dot separated list of subdomains. For example, the address .PP eric@monet.berkeley.edu .PP is normally interpreted from right to left: the message should go to the ARPA name tables (which do not correspond exactly to the physical ARPANET), then to the Berkeley gateway, after which it should go to the local host monet. When the message reaches monet it is delivered to the user ``eric''. .PP Unlike some other forms of addressing, this does not imply any routing. Thus, although this address is specified as an ARPA address, it might travel by an alternate route if that were more convenient or efficient. For example, at Berkeley, the associated message would probably go directly to monet over the Ethernet rather than going via the Berkeley ARPANET gateway. .SS Abbreviation. .PP Under certain circumstances it may not be necessary to type the entire domain name. In general, anything following the first dot may be omitted if it is the same as the domain from which you are sending the message. For example, a user on ``calder.berkeley.edu'' could send to ``eric@monet'' without adding the ``berkeley.edu'' since it is the same on both sending and receiving hosts. .PP Certain other abbreviations may be permitted as special cases. For example, at Berkeley, ARPANET hosts may be referenced without adding the ``berkeley.edu'' as long as their names do not conflict with a local host name. .SS Compatibility. .PP Certain old address formats are converted to the new format to provide compatibility with the previous mail system. In particular, .PP user@host.ARPA .PP is allowed and .PP host:user .PP is converted to .PP user@host .PP to be consistent with the \fIrcp\fP(1) command. .PP Also, the syntax .PP host!user .PP is converted to: .PP user@host.UUCP .PP This is normally converted back to the ``host!user'' form before being sent on for compatibility with older UUCP hosts. .PP The current implementation is not able to route messages automatically through the UUCP network. Until that time you must explicitly tell the mail system which hosts to send your message through to get to your final destination. .SS Case Distinctions. .PP Domain names (i.e., anything after the ``@'' sign) may be given in any mixture of upper and lower case with the exception of UUCP hostnames. Most hosts accept any combination of case in user names, with the notable exception of MULTICS sites. .SS Route-addrs. .PP Under some circumstances it may be necessary to route a message through several hosts to get it to the final destination. Normally this routing is done automatically, but sometimes it is desirable to route the message manually. Addresses which show these relays are termed ``route-addrs.'' These use the syntax: .PP <@hosta,@hostb:user@hostc> .PP This specifies that the message should be sent to hosta, from there to hostb, and finally to hostc. This path is forced even if there is a more efficient path to hostc. .PP Route-addrs occur frequently on return addresses, since these are generally augmented by the software at each host. It is generally possible to ignore all but the ``user@domain'' part of the address to determine the actual sender. .SS Postmaster. .PP Every site is required to have a user or user alias designated ``postmaster'' to which problems with the mail system may be addressed. .SS Other Networks. .PP Some other networks can be reached by giving the name of the network as the last component of the domain. \fIThis is not a standard feature\fP and may not be supported at all sites. For example, messages to CSNET or BITNET sites can often be sent to ``user@host.CSNET'' or ``user@host.BITNET'' respectively. .SH BUGS The RFC822 group syntax (``group:user1,user2,user3;'') is not supported except in the special case of ``group:;'' because of a conflict with old berknet-style addresses. .PP Route-Address syntax is grotty. .PP UUCP- and ARPANET-style addresses do not coexist politely. .SH SEE ALSO mail(1), sendmail(8); Crocker, D. H., .ul Standard for the Format of Arpa Internet Text Messages, RFC822. ================================================ FILE: share/man/man7/man.7 ================================================ .\" @(#)man.7 6.3.1 (2.11BSD) 1996/10/22 .\" .TH MAN 7 "October 22, 1996" .AT 3 .SH NAME man \- macros to typeset manual .SH SYNOPSIS .B nroff \-man\ file ... .PP .B troff \-man\ file ... .SH DESCRIPTION These macros are used to lay out pages of this manual. A skeleton page may be found in the file /usr/man/man.template. .PP Any text argument .I t may be zero to six words. Quotes may be used to include blanks in a `word'. If .I text is empty, special treatment is applied to the next input line with text to be printed. In this way .BR . I may be used to italicize a whole line, or .BR . SM may be followed by .BR . B to make small bold letters. .PP A prevailing indent distance is remembered between successive indented paragraphs, and is reset to default value upon reaching a non-indented paragraph. Default units for indents .I i are ens. .PP Type font and size are reset to default values before each paragraph, and after processing font and size setting macros. .PP These strings are predefined by .BR \-man : .IP \e*R .if t `\*R', `(Reg)' in .if t .I nroff. .if n `(Reg)', trademark symbol in .if n .I troff. .IP \e*S Change to default type size. .SH FILES /usr/share/tmac/tmac.an .br /usr/man/man.template .SH SEE ALSO troff(1), man(1) .SH BUGS Relative indents don't nest. .SH REQUESTS .ta \w'.TH n c x v m'u +\w'Cause 'u +\w'Argument\ 'u .di xx \ka .br .di .in \nau .ti 0 Request Cause If no Explanation .ti 0 Break Argument .ti 0 .tr ~. ~B \fIt\fR no \fIt\fR=n.t.l.* Text .I t is bold. .ti 0 ~BI \fIt\fR no \fIt\fR=n.t.l. Join words of .I t alternating bold and italic. .ti 0 ~BR \fIt\fR no \fIt\fR=n.t.l. Join words of .I t alternating bold and Roman. .ti 0 ~DT no .5i 1i... Restore default tabs. .ti 0 ~HP \fIi\fR yes \fIi\fR=p.i.* Set prevailing indent to .I i. Begin paragraph with hanging indent. .ti 0 ~I \fIt\fR no \fIt\fR=n.t.l. Text .I t is italic. .ti 0 ~IB \fIt\fR no \fIt\fR=n.t.l. Join words of .I t alternating italic and bold. .ti 0 ~IP \fIx i\fR yes \fIx\fR="" Same as .TP with tag .I x. .ti 0 ~IR \fIt\fR no \fIt\fR=n.t.l. Join words of .I t alternating italic and Roman. .ti 0 ~LP yes - Same as .PP. .ti 0 ~PD \fId\fR no \fId\fR=.4v Interparagraph distance is .I d. .ti 0 ~PP yes - Begin paragraph. Set prevailing indent to .5i. .ti 0 ~RE yes - End of relative indent. Set prevailing indent to amount of starting .RS. .ti 0 ~RB \fIt\fR no \fIt\fR=n.t.l. Join words of .I t alternating Roman and bold. .ti 0 ~RI \fIt\fR no \fIt\fR=n.t.l. Join words of .I t alternating Roman and italic. .ti 0 ~RS \fIi\fR yes \fIi\fR=p.i. Start relative indent, move left margin in distance .I i. Set prevailing indent to .5i for nested indents. .ti 0 ~SH \fIt\fR yes \fIt\fR=n.t.l. Subhead. .ti 0 ~SM \fIt\fR no \fIt\fR=n.t.l. Text .I t is small. .ti 0 ~TH \fIn c x v m\fR yes - Begin page named .I n of chapter .IR c; .I x is extra commentary, e.g. `local', for page foot center; .I v alters page foot left, e.g. `4th Berkeley Distribution'; .I m alters page head center, e.g. `Brand X Programmer's Manual'. Set prevailing indent and tabs to .5i. .ti 0 ~TP \fIi\fR yes \fIi\fR=p.i. Set prevailing indent to .I i. Begin indented paragraph with hanging tag given by next text line. If tag doesn't fit, place it on separate line. .PP .ti 0 * n.t.l. = next text line; p.i. = prevailing indent ================================================ FILE: share/man/man7/me.7 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)me.7 6.3.1 (2.11BSD) 1996/10/23 .\" .hc % .TH ME 7 "October 23, 1996" .UC 3 .SH NAME me \- macros for formatting papers .SH SYNOPSIS .B "nroff \-me" [ options ] file ... .br .B "troff \-me" [ options ] file ... .SH DESCRIPTION This package of .I nroff and .I troff macro definitions provides a canned formatting facility for tech%nical papers in various formats. When producing 2-column output on a terminal, filter the output through .IR col (1). .PP The macro requests are defined below. Many .I nroff and .I troff requests are unsafe in conjunction with this package, however, these requests may be used with impunity after the first .pp: .nf .IP .ta \w'.sz +n 'u \&.bp begin new page \&.br break output line here \&.sp n insert n spacing lines \&.ls n (line spacing) n=1 single, n=2 double space \&.na no alignment of right margin \&.ce n center next n lines \&.ul n underline next n lines \&.sz +n add n to point size .fi .PP Output of the .I eqn, .I neqn, .I refer, and .IR tbl (1) preprocessors for equations and tables is acceptable as input. .SH FILES /usr/share/tmac/tmac.e .br /usr/share/me/* .SH "SEE ALSO" eqn(1), troff(1), refer(1), tbl(1) .br \-me Reference Manual, Eric P. Allman .br Writing Papers with Nroff Using \-me .tr &. .SH REQUESTS In the following list, \*(lqinitialization\*(rq refers to the first .pp, .lp, .ip, .np, .sh, or .uh macro. This list is incomplete; see .I "The \-me Reference Manual" for interesting details. .PP .ta \w'.eh \'x\'y\'z\' 'u +\w'Initial 'u +\w'Cause 'u .br .di x \ka .br .di .in \nau .ti 0 Request Initial Cause Explanation .ti 0 Value Break .br .in \nau .ti 0 \&.(c - yes Begin centered block .ti 0 \&.(d - no Begin delayed text .ti 0 \&.(f - no Begin footnote .ti 0 \&.(l - yes Begin list .ti 0 \&.(q - yes Begin major quote .ti 0 \&.(x \fIx\fR - no Begin indexed item in index .I x .ti 0 \&.(z - no Begin floating keep .ti 0 \&.)c - yes End centered block .ti 0 \&.)d - yes End delayed text .ti 0 \&.)f - yes End footnote .ti 0 \&.)l - yes End list .ti 0 \&.)q - yes End major quote .ti 0 \&.)x - yes End index item .ti 0 \&.)z - yes End floating keep .ti 0 \&.++ \fIm H\fR - no Define paper section. .I m defines the part of the paper, and can be .B C (chapter), .B A (appendix), .B P (preliminary, e.g., abstract, table of contents, etc.), .B B (bibliography), .B RC (chapters renumbered from page one each chapter), or .B RA (appendix renumbered from page one). .ti 0 \&.+c \fIT\fR - yes Begin chapter (or appendix, etc., as set by .++). .I T is the chapter title. .ti 0 \&.1c 1 yes One column format on a new page. .ti 0 \&.2c 1 yes Two column format. .ti 0 \&.EN - yes Space after equation produced by .I eqn or .IR neqn . .ti 0 \&.EQ \fIx y\fR - yes Precede equation; break out and add space. Equation number is .IR y . The optional argument \fIx\fR may be .I I to indent equation (default), .I L to left-adjust the equation, or .I C to center the equation. .ti 0 \&.GE - yes End \fIgremlin\fP picture. .ti 0 \&.GS - yes Begin \fIgremlin\fP picture. .ti 0 \&.PE - yes End \fIpic\fP picture. .ti 0 \&.PS - yes Begin \fIpic\fP picture. .ti 0 \&.TE - yes End table. .ti 0 \&.TH - yes End heading section of table. .ti 0 \&.TS \fIx\fR - yes Begin table; if \fIx\fR is .I H table has repeated heading. .ti 0 \&.ac \fIA N\fR - no Set up for ACM style output. .I A is the Author's name(s), .I N is the total number of pages. Must be given before the first initialization. .ti 0 \&.b \fIx\fR no no Print .I x in boldface; if no argument switch to boldface. .ti 0 \&.ba \fI+n\fR 0 yes Augments the base indent by .I n. This indent is used to set the indent on regular text (like paragraphs). .ti 0 \&.bc no yes Begin new column .ti 0 \&.bi \fIx\fR no no Print .I x in bold italics (nofill only) .ti 0 \&.bu - yes Begin bulleted paragraph .ti 0 \&.bx \fIx\fR no no Print \fIx\fR in a box (nofill only). .ti 0 \&.ef \fI\'x\'y\'z\'\fR \'\'\'\' no Set even footer to x y z .ti 0 \&.eh \fI\'x\'y\'z\'\fR \'\'\'\' no Set even header to x y z .ti 0 \&.fo \fI\'x\'y\'z\'\fR \'\'\'\' no Set footer to x y z .ti 0 \&.hx - no Suppress headers and footers on next page. .ti 0 \&.he \fI\'x\'y\'z\'\fR \'\'\'\' no Set header to x y z .ti 0 \&.hl - yes Draw a horizontal line .ti 0 \&.i \fIx\fR no no Italicize .I x; if .I x missing, italic text follows. .ti 0 \&.ip \fIx y\fR no yes Start indented paragraph, with hanging tag .IR x . Indentation is .I y ens (default 5). .ti 0 \&.lp yes yes Start left-blocked paragraph. .ti 0 \&.lo - no Read in a file of local macros of the form .BI \&.* x. Must be given before initialization. .ti 0 \&.np 1 yes Start numbered paragraph. .ti 0 \&.of \fI\'x\'y\'z\'\fR \'\'\'\' no Set odd footer to x y z .ti 0 \&.oh \fI\'x\'y\'z\'\fR \'\'\'\' no Set odd header to x y z .ti 0 \&.pd - yes Print delayed text. .ti 0 \&.pp no yes Begin paragraph. First line indented. .ti 0 \&.r yes no Roman text follows. .ti 0 \&.re - no Reset tabs to default values. .ti 0 \&.sc no no Read in a file of special characters and diacritical marks. Must be given before initialization. .ti 0 \&.sh \fIn x\fR - yes Section head follows, font automatically bold. .I n is level of section, .I x is title of section. .ti 0 \&.sk no no Leave the next page blank. Only one page is remembered ahead. .ti 0 \&.sm \fIx\fR - no Set .I x in a smaller pointsize. .ti 0 \&.sz \fI+n\fR 10p no Augment the point size by .I n points. .ti 0 \&.th no no Produce the paper in thesis format. Must be given before initialization. .ti 0 \&.tp no yes Begin title page. .ti 0 \&.u \fIx\fR - no Underline argument (even in \fItroff\fR). (Nofill only). .ti 0 \&.uh - yes Like .sh but unnumbered. .ti 0 \&.xp \fIx\fR - no Print index .I x. ================================================ FILE: share/man/man7/ms.7 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)ms.7 6.1.1 (2.11BSD) 1996/10/23 .\" .TH MS 7 "October 23, 1996" .UC 4 .ds ]W UCB Computer Center .SH NAME ms \- text formatting macros .SH SYNOPSIS \fBnroff \-ms\fP [ options ] file ... .br \fBtroff \-ms\fP [ options ] file ... .SH DESCRIPTION This package of \fInroff\fP\| and \fItroff\fP\| macro definitions provides a formatting facility for various styles of articles, theses, and books. When producing 2-column output on a terminal or lineprinter, or when reverse line motions are needed, filter the output through \fIcol\fP\|(1). All external \-ms macros are defined below. Many \fInroff\fP\| and \fItroff\fP\| requests are unsafe in conjunction with this package. However, the first four requests below may be used with impunity after initialization, and the last two may be used even before initialization: .sp .2 .ta 5n 12n .nf .bp begin new page .br break output line .sp n insert n spacing lines .ce n center next n lines .ls n line spacing: n=1 single, n=2 double space .na no alignment of right margin .fi .sp .2 Font and point size changes with \ef and \es are also allowed; for example, ``\efIword\efR'' will italicize \fIword.\fP Output of the \fItbl, eqn,\fP and \fIrefer\fP\|(1) preprocessors for equations, tables, and references is acceptable as input. .SH FILES /usr/share/tmac/tmac.x .br /usr/share/ms/x.??? .SH "SEE ALSO" eqn(1), refer(1), tbl(1), troff(1) .SH REQUESTS .if n .in 0 .ds x \fIx\fP\| .ds y \fIy\fP\| .ds z \fI y\fP .ds Y \fIx y\fP .tr _. .ta \w'MacroNam'u +\w'InitialVal'u +\w'Break? 'u .sp .3 .nf Macro Initial Break? \0 Explanation Name Value Reset? .sp .3 _AB \*x \- y begin abstract; if \*x=no don't label abstract _AE \- y end abstract _AI \- y author's institution _AM \- n better accent mark definitions _AU \- y author's name _B \*x \- n embolden \*x; if no \*x, switch to boldface _B1 \- y begin text to be enclosed in a box _B2 \- y end boxed text and print it _BT date n bottom title, printed at foot of page _BX \*x \- n print word \*x in a box _CM if t n cut mark between pages _CT \- y,y chapter title: page number moved to CF (TM only) _DA \*x if n n force date \*x at bottom of page; today if no \*x _DE \- y end display (unfilled text) of any kind _DS \*Y I y begin display with keep; \*x=I,L,C,B; \*y=indent _ID\*z 8n,.5i y indented display with no keep; \*y=indent _LD \- y left display with no keep _CD \- y centered display with no keep _BD \- y block display; center entire block _EF \*x \- n even page footer \*x (3 part as for .tl) _EH \*x \- n even page header \*x (3 part as for .tl) _EN \- y end displayed equation produced by \fIeqn\fP _EQ \*Y \- y break out equation; \*x=L,I,C; \*y=equation number _FE \- n end footnote to be placed at bottom of page _FP \- n numbered footnote paragraph; may be redefined _FS \*x \- n start footnote; \*x is optional footnote label _HD undef n optional page header below header margin _I \*x \- n italicize \*x; if no \*x, switch to italics _IP \*Y \- y,y indented paragraph, with hanging tag \*x; \*y=indent _IX \*Y \- y index words \*x \*y and so on (up to 5 levels) _KE \- n end keep of any kind _KF \- n begin floating keep; text fills remainder of page _KS \- y begin keep; unit kept together on a single page _LG \- n larger; increase point size by 2 _LP \- y,y left (block) paragraph. _MC \*x \- y,y multiple columns; \*x=column width _ND \*x if t n no date in page footer; \*x is date on cover _NH \*Y \- y,y numbered header; \*x=level, \*x=0 resets, \*x=S sets to \*y _NL 10p n set point size back to normal _OF \*x \- n odd page footer \*x (3 part as for .tl) _OH \*x \- n odd page header \*x (3 part as for .tl) _P1 if TM n print header on 1st page _PP \- y,y paragraph with first line indented _PT - % - n page title, printed at head of page _PX \*x \- y print index (table of contents); \*x=no suppresses title _QP \- y,y quote paragraph (indented and shorter) _R on n return to Roman font _RE 5n y,y retreat: end level of relative indentation _RP \*x \- n released paper format; \*x=no stops title on 1st page _RS 5n y,y right shift: start level of relative indentation _SH \- y,y section header, in boldface _SM \- n smaller; decrease point size by 2 _TA 8n,5n n set tabs to 8n 16n ... (nroff) 5n 10n ... (troff) _TC \*x \- y print table of contents at end; \*x=no suppresses title _TE \- y end of table processed by \fItbl\fP _TH \- y end multi-page header of table _TL \- y title in boldface and two points larger _TM off n UC Berkeley thesis mode _TS \*x \- y,y begin table; if \*x=H table has multi-page header _UL \*x \- n underline \*x, even in \fItroff\fP _UX \*x \- n UNIX; trademark message first time; \*x appended _XA \*Y \- y another index entry; \*x=page or no for none; \*y=indent _XE \- y end index entry (or series of .IX entries) _XP \- y,y paragraph with first line exdented, others indented _XS \*Y \- y begin index entry; \*x=page or no for none; \*y=indent _1C on y,y one column format, on a new page _2C \- y,y begin two column format _]- \- n beginning of \fIrefer\fP\| reference _[0 \- n end of unclassifiable type of reference _[N \- n N= 1:journal-article, 2:book, 3:book-article, 4:report .fi .if t .bp .DT .SH REGISTERS Formatting distances can be controlled in \-ms by means of built-in number registers. For example, this sets the line length to 6.5 inches: .sp .3 .nr LL 6.5i .sp .3 Here is a table of number registers and their default values: .sp .3 .nf .ta .5i +\w'Name\0'u +\w'paragraph distance 'u +\w'Takes Effect 'u Name Register Controls Takes Effect Default .sp .3 PS point size paragraph 10 VS vertical spacing paragraph 12 LL line length paragraph 6i LT title length next page same as LL FL footnote length next .FS 5.5i PD paragraph distance paragraph 1v (if n), .3v (if t) DD display distance displays 1v (if n), .5v (if t) PI paragraph indent paragraph 5n QI quote indent next .QP 5n FI footnote indent next .FS 2n PO page offset next page 0 (if n), \(ap1i (if t) HM header margin next page 1i FM footer margin next page 1i FF footnote format next .FS 0 (1, 2, 3 available) .fi .sp .3 When resetting these values, make sure to specify the appropriate units. Setting the line length to 7, for example, will result in output with one character per line. Setting FF to 1 suppresses footnote superscripting; setting it to 2 also suppresses indentation of the first line; and setting it to 3 produces an .IP-like footnote paragraph. .PP Here is a list of string registers available in \-ms; they may be used anywhere in the text: .sp .3 .nf .ta .5i 1.1i Name String's Function .sp .3 \e*Q quote (" in \fInroff,\fP\| `` in \fItroff\fP ) \e*U unquote (" in \fInroff,\fP\| '' in \fItroff\fP ) \e*\- dash (-- in \fInroff,\fP \(em in \fItroff\fP ) \e*(MO month (month of the year) \e*(DY day (current date) \e** automatically numbered footnote \e*\' acute accent (before letter) \e*\` grave accent (before letter) \e*\d^ \ucircumflex (before letter) \e*, cedilla (before letter) \e*: umlaut (before letter) \e*\d~ \utilde (before letter) .fi .sp .3 When using the extended accent mark definitions available with .AM, these strings should come after, rather than before, the letter to be accented. .SH BUGS Floating keeps and regular keeps are diverted to the same space, so they cannot be mixed together with predictable results. ================================================ FILE: share/man/man7/term.7 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)term.7 6.1 (Berkeley) 5/20/85 .\" .TH TERM 7 "May 20, 1985" .UC 4 .SH NAME term \- conventional names for terminals .SH DESCRIPTION Certain commands use these terminal names. They are maintained as part of the shell environment (see .IR sh (1), environ (7)). .LP .nf .ta \w'450\-12\-8 'u adm3a Lear Seigler Adm-3a 2621 Hewlett-Packard HP262? series terminals hp Hewlett-Packard HP264? series terminals c100 Human Designed Systems Concept 100 h19 Heathkit H19 mime Microterm mime in enhanced ACT IV mode 1620 DIABLO 1620 (and others using HyType II) 300 DASI/DTC/GSI 300 (and others using HyType I) 33 TELETYPE\*R Model 33 37 TELETYPE Model 37 43 TELETYPE Model 43 735 Texas Instruments TI735 (and TI725) 745 Texas Instruments TI745 dumb terminals with no special features dialup a terminal on a phone line with no known characteristics network a terminal on a network connection with no known characteristics 4014 Tektronix 4014 vt52 Digital Equipment Corp. VT52 .fi .PP The list goes on and on. Consult /etc/termcap (see .IR termcap (5)) for an up-to-date and locally correct list. .PP Commands whose behavior may depend on the terminal either consult TERM in the environment, or accept arguments of the form .BR \-Tterm, where .I term is one of the names given above. .SH SEE ALSO stty(1), tabs(1), plot(1G), sh(1), environ(7) ex(1), clear(1), more(1), ul(1), tset(1), termcap(5), termcap(3X), ttytype(5) .br troff(1) for .I nroff .SH BUGS The programs that ought to adhere to this nomenclature do so only fitfully. ================================================ FILE: share/man/man8/Makefile ================================================ # # Copyright (c) 1987 Regents of the University of California. # All rights reserved. # # Redistribution and use in source and binary forms are permitted # provided that the above copyright notice and this paragraph are # duplicated in all such forms and that any documentation, # advertising materials, and other materials related to such # distribution and use acknowledge that the software was developed # by the University of California, Berkeley. The name of the # University may not be used to endorse or promote products derived # from this software without specific prior written permission. # THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED # WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. # # @(#)Makefile 5.4.7 (2.11BSD) 1997/1/10 # TOPSRC!=cd ../../..; pwd include ${TOPSRC}/share/mk/sys.mk MDIR= /usr/share/man/cat8 SRCS= XNSrouted.8 adduser.8 autoconfig.8 \ bugfiler.8 crash.8 \ boot.8 \ drtest.8 dump.8 dumpdir.8 \ format.8 fsck.8 \ getty.8 htable.8 \ intro.8 lpc.8 lpd.8 makedev.8 \ makekey.8 \ named.8 pac.8 \ rc.8 rdump.8 \ routed.8 rrestore.8 \ sendmail.8 \ sticky.8 sync.8 \ timed.8 timedc.8 uucico.8 \ uuclean.8 uupoll.8 uusnap.8 uuxqt.8 OBJS= XNSrouted.0 adduser.0 autoconfig.0 \ bugfiler.0 crash.0 \ boot.0 \ drtest.0 dump.0 dumpdir.0 \ format.0 fsck.0 \ getty.0 htable.0 \ intro.0 lpc.0 lpd.0 makedev.0 \ makekey.0 \ named.0 pac.0 \ rc.0 rdump.0 \ routed.0 rrestore.0 \ sendmail.0 \ sticky.0 sync.0 \ timed.0 timedc.0 uucico.0 \ uuclean.0 uupoll.0 uusnap.0 uuxqt.0 .SUFFIXES: .8 .0 .8.0: ${MANROFF} $*.8 > $*.0 all: _make_01 _make_01: ${OBJS} clean: FRC rm -f ${OBJS} install: _make_01 cp ${OBJS} ${DESTDIR}${MDIR} ln -f ${DESTDIR}${MDIR}/uucico.0 ${DESTDIR}${MDIR}/uucpd.0 FRC: ================================================ FILE: share/man/man8/XNSrouted.8 ================================================ .\" Copyright (c) 1986 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)XNSrouted.8 6.1.1 (2.11BSD) 1996/11/1 .\" .TH XNSROUTED 8 "November 1, 1996" .UC 6 .SH NAME XNSrouted \- NS Routing Information Protocol daemon .SH SYNOPSIS .B /sbin/XNSrouted [ .B \-s ] [ .B \-q ] [ .B \-t ] [ .I logfile ] .SH DESCRIPTION .I XNSrouted is invoked at boot time to manage the Xerox NS routing tables. The NS routing daemon uses the Xerox NS Routing Information Protocol in maintaining up to date kernel routing table entries. .PP In normal operation .I XNSrouted listens for routing information packets. If the host is connected to multiple NS networks, it periodically supplies copies of its routing tables to any directly connected hosts and networks. .PP When .I XNSrouted is started, it uses the SIOCGIFCONF .I ioctl to find those directly connected interfaces configured into the system and marked ``up'' (the software loopback interface is ignored). If multiple interfaces are present, it is assumed the host will forward packets between networks. .I XNSrouted then transmits a .I request packet on each interface (using a broadcast packet if the interface supports it) and enters a loop, listening for .I request and .I response packets from other hosts. .PP When a .I request packet is received, .I XNSrouted formulates a reply based on the information maintained in its internal tables. The .I response packet generated contains a list of known routes, each marked with a ``hop count'' metric (a count of 16, or greater, is considered ``infinite''). The metric associated with each route returned provides a metric .IR "relative to the sender" . .PP .I Response packets received by .I XNSrouted are used to update the routing tables if one of the following conditions is satisfied: .TP (1) No routing table entry exists for the destination network or host, and the metric indicates the destination is ``reachable'' (i.e. the hop count is not infinite). .TP (2) The source host of the packet is the same as the router in the existing routing table entry. That is, updated information is being received from the very internetwork router through which packets for the destination are being routed. .TP (3) The existing entry in the routing table has not been updated for some time (defined to be 90 seconds) and the route is at least as cost effective as the current route. .TP (4) The new route describes a shorter route to the destination than the one currently stored in the routing tables; the metric of the new route is compared against the one stored in the table to decide this. .PP When an update is applied, .I XNSrouted records the change in its internal tables and generates a .I response packet to all directly connected hosts and networks. .I Routed waits a short period of time (no more than 30 seconds) before modifying the kernel's routing tables to allow possible unstable situations to settle. .PP In addition to processing incoming packets, .I XNSrouted also periodically checks the routing table entries. If an entry has not been updated for 3 minutes, the entry's metric is set to infinity and marked for deletion. Deletions are delayed an additional 60 seconds to insure the invalidation is propagated to other routers. .PP Hosts acting as internetwork routers gratuitously supply their routing tables every 30 seconds to all directly connected hosts and networks. .PP Supplying the .B \-s option forces .I XNSrouted to supply routing information whether it is acting as an internetwork router or not. The .B \-q option is the opposite of the .B \-s option. If the .B \-t option is specified, all packets sent or received are printed on the standard output. In addition, .I XNSrouted will not divorce itself from the controlling terminal so that interrupts from the keyboard will kill the process. Any other argument supplied is interpreted as the name of file in which .IR XNSrouted 's actions should be logged. This log contains information about any changes to the routing tables and a history of recent messages sent and received which are related to the changed route. .SH "SEE ALSO" ``Internet Transport Protocols'', XSIS 028112, Xerox System Integration Standard. .br idp(4P) ================================================ FILE: share/man/man8/adduser.8 ================================================ .\" Copyright (c) 1980 The Regents of the University of California. .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms are permitted .\" provided that the above copyright notice and this paragraph are .\" duplicated in all such forms and that any documentation, .\" advertising materials, and other materials related to such .\" distribution and use acknowledge that the software was developed .\" by the University of California, Berkeley. The name of the .\" University may not be used to endorse or promote products derived .\" from this software without specific prior written permission. .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR .\" IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED .\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. .\" .\" @(#)adduser.8 6.6.1 (2.11BSD) 1996/10/23 .\" .TH ADDUSER 8 "October 23, 1996" .UC 4 .SH NAME adduser \- procedure for adding new users .SH DESCRIPTION A new user must choose a login name, which must not already appear in .IR /etc/passwd or .IR /etc/aliases . It must also not begin with the hyphen (``-'') character. It is strongly recommended that it be all lower-case, and not contain the dot (``.'') character, as that tends to confuse mailers. An account can be added by editing a line into the passwd file; this must be done with the password file locked e.g. by using .IR chpass (1) or .IR vipw (8). .PP A new user is given a group and user id. Login's and user id's should be unique across the system, and often across a group of systems, since they are used to control file access. Typically, users working on similar projects will be put in the same groups. At the University of California, Berkeley, we have groups for system staff, faculty, graduate students, and special groups for large projects. .PP A skeletal account for a new user \*(lqernie\*(rq might look like: .IP ernie::25:30::0:0:Ernie Kovacs,508 Evans Hall,x7925,642-8202:/a/users/ernie:/bin/csh .PP For a description of each of these fields, see .IR passwd (5). .PP It is useful to give new users some help in getting started, supplying them with a few skeletal files such as .I \&.profile if they use \*(lq/bin/sh\*(rq, or .I \&.cshrc and .I \&.login if they use \*(lq/bin/csh\*(rq. The directory \*(lq/usr/skel\*(rq contains skeletal definitions of such files. New users should be given copies of these files which, for instance, use .IR tset (1) automatically at each login. .SH FILES .ta 2i /etc/master.passwd user database .br /usr/skel skeletal login directory .SH SEE ALSO chpass(1), finger(1), passwd(1), aliases(5), passwd(5), mkpasswd(8), vipw(8) .SH BUGS User information should (and eventually will) be stored elsewhere. ================================================ FILE: share/man/man8/autoconfig.8 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)autoconfig.8 2.7 (2.11BSD GTE) 1996/5/24 .\" .TH AUTOCONFIG 8 "December 30, 1992" .UC 2 .SH NAME autoconfig \- configure the running system to the hardware .SH SYNOPSIS .B "autoconfig [\-i ifile] [\-n nfile] [\-k kfile] [\-v] [\-d] [\-c]" .SH DESCRIPTION .PP .I Autoconfig is called by .IR init (8) to configure the currently running system. Init checks the exit status of autoconfig to determine if the configuration was successful. .I Autoconfig reads the device table .I /etc/dtab for a list of devices which may be on the system. It first verifies that the kernel has an attach routine for each device (and therefore has a device handler) and that the kernel has a probe routine. It then checks each of these devices to see if it is present, and if it is, attempts to make it interrupt (if possible) to verify that the interrupt vector is correct. The interrupt vector is checked to see that it has not previously been used. An interrupt through any of the device's consecutive vectors is sufficient. .PP Devices which use programmable vectors (MSCP and TMSCP) are permitted to have a value of 0 in the dtab vector field. This special value tells autoconfig to call the kernel's get next available vector routine and assign that to the device. For programmable vector devices if the dtab vector field is non 0 then the value specified in the dtab file is used. In both cases the driver is called at its xxVec() routine with the vector being assigned to the device. .PP If the address and vector are correct, it then attaches the device by passing the address and unit number to the kernel's attach routine and setting up the interrupt vector according to the interrupt handlers and priority listed in the device table. If the unit number is given as a '?' in the device table, it will be assigned the next available unit number if the device exists. If the device is not present or the vector is incorrect, and if the unit number was specified (not a '?'), then the kernel is notified that that unit is not present, preventing accesses to a nonexistent device address. .PP There are only a few flags which are mostly useful for debugging but for completeness, here they are. .TP "\w'\fB\-k\fI kfile\fR 'u" \fB\-\^i\fI ifile\fR Use .I ifile instead of .I /etc/dtab as the device table. .TP \fB\-\^n\fI nfile\fR Use .I nfile instead of .I /unix for finding the namelist of the currently running kernel. .TP \fB\-\^k\fI kfile\fR The file .I kfile should be used instead of .I /dev/kmem to alter and read kernel memory. .TP \fB\-\^v\fR Verbose output, indicates reason for rejecting any device in the device table. Normally only attached devices are reported. .TP \fB\-\^c\fR Report error messages for devices skipped because of problems with their interrupt vectors. .TP \fB\-\^d\fR Turn on debugging mode. Shows many gory details of autoconfig's internal processing. .SH BUGS Devices of the same type must be listed with ascending unit numbers or with wildcards. .PP Disks that could be root devices must have their addresses and vectors initialized in the kernel; the kernel uses a root attach entry in the block device switch to allow disk drivers to do any probes necessary before autoconfiguration. .PP Must be run only by .IR init (8). There is a flag set in the kernel that autoconfig has already run, running autoconfig a second time results in the error: .TP "namelist doesn't match running kernel." Autoconfig attempts to open /dev/kmem for write. If the kernel is in securelevel 1 or higher the open of /dev/kmem will fail. .SH FILES .ta 2i /etc/dtab device table .br /unix .br /dev/kmem .SH SEE ALSO ucall(2), nlist(3), dtab(5) ================================================ FILE: share/man/man8/boot.8 ================================================ .\" Public domain. May 24, 1996. .\" .\" @(#)reboot.8 1.0 (2.11BSD) 1996/5/24 .\" .TH BOOT 8 "May 24, 1996" .UC 2 .SH NAME boot \- 2.11BSD bootstrap proceedure .SH DESCRIPTION .PP The 2.11BSD system is started by a two-stage process. The first is a primary bootstrap (limited to 512 bytes) which is able to read in relatively small stand-alone programs; the second (called .IR boot ) is used to read in the system itself. .PP The primary bootstrap must reside in block zero of the boot device (the disklabel resides in block one). It can be read in and started by standard ROM cold boot routines or, if necessary, by keying in a small startup routine. The primary bootstrap is capable of loading \fBonly\fP type 0407 executable files (impure (non-shared), non-separate I&D.) Copies of the block zero bootstraps are kept in the directory .IR /mdec . .IR Disklabel (8) is normally used to place a copy of the appropriate bootstrap in block zero of new file systems. .PP The primary bootstrap loads .I boot from the file system that starts at block 0 of the drive specified to the boot ROM. Normally the boot device is automatically used as the root filesystem. This action can be overriden by specifying the \fB\-R\fP command to \fIboot\fP. If .I boot is not found the system will hang as the primary boot spins in an endless loop trying to find \fIboot\fP. No diagnostic message results if the file cannot be found. .IP \(bu .BR "In an emergency" , the bootstrap methods described in the paper .I "Installing and Operating 2.11BSD" can be used to boot from a distribution tape. .PP The secondary boot program, called .IR boot , actually brings in the system. When read into location 0 and executed, .I boot sets up memory management, relocates itself into high memory, and types its name and a `:' on the console. If this is an automatic, unattended reboot, .I boot will use a default file specification for the installation, typing the file's name after the prompt. Otherwise, it reads a file specification from the console. Normal line editing characters can be used to make corrections while typing this (see below for file specification format). If only a carriage return is typed, a default name (/unix) will be used. .I Boot finds the [specified] file and loads it into memory location zero, sets up memory management as required, and calls the program by executing a `trap' instruction. .PP For the system to boot, .I /etc/init must exist and be executable; if it is not, the kernel will print a message to that effect and loop. Further, for a single user boot, the files .I /bin/sh and .I /dev/console must also exist and .I /bin/sh must be executable (if either of these is missing, .I init will attempt multi-user operation). For a multi-user boot the file .I /etc/ttys must exist (if missing, .I init will attempt single user operation). .PP .I Init runs the .IR autoconfig (8) program to probe for and initialize devices. .I Autoconfig only knows to look in \fI/unix\fP, thus if an alternate kernel name was specified none of the devices except \fI/dev/console\fP and the boot disk will be known. .PP If \fIautoconfig\fP problems are suspected (or if you are simply voyeuristic) the \fBdebug\fP flag can be turned on by specifying \fB\-D\fP to \fIboot\fP (see below). .PP When the system is running in single user mode, it starts a single user shell on the console which types a `#' prompt. After doing any file system checks and setting the date .RI ( date (1)) a multi-user system can be brought up by typing an EOT (control-d) in response to the `#' prompt. .PP .B "Boot file specification format:" The file specifications used with .I boot are of the form: .IP .I device(ctlr,unit,part)path [-aRrDs] .LP or .IP .I \-bootcommand .LP where .TP .I device is the type of the device to be searched; .TP .I ctlr is the controller number of the disk .TP .I unit is the unit number of the disk or tape; .TP .I part is the partition number of a filesystem on the specified disk or the tape file number if the device is a tape. The underlying device driver \fBmust\fP support disklabels and a valid disklabel must be present if \fIpart\fP is anything except 0. .TP .I path is the path name of a disk file to be loaded with all mount prefixes stripped off .RI ( path must be omitted for tape files.) Tape files are separated by single tape marks. .PP Flags to \fIboot\fP may be specified in either of two places. At the \fB:\fP prompt and after the \fIfile\fP name. The options are: .TP .B \-a Ask for a kernel name. This is present for symmetry only because in order to specify this option you already have to be at the \fB:\fP prompt. .TP .B \-D Turn on the .I autoconfig debug flag. .TP .B \-R force the kernel to use its compiled in root device rather than adapting to the boot device. .TP .B \-s tell .I init to enter single user state rather than bringing the system all the way up to multi-user mode. .B \-r mount the root filesystem read-only. This is not currently supported by the kernel mostly because pipes are implemented in the filesystem. .LP Commands (\fI\-bootcommand\fP) to \fIboot\fP are: .TP 20 .B \-bootflags N where N is a decimal number. .TP 20 .B \-bootflags flag where \fBflag\fP is from the list above. .TP 20 .B \-bootdebug N where N is a decimal number. This is a general purpose flag word used by \fIboot\fP and is not passed to the loaded program or kernel. .PP .I Device is one of the following .PP .nf .ne 10 xp RM02/03/05, RP04/05/06, DIVA, SI Eagle, CDC 9766, Fuji 160 rp RP03 rk RK05 hk RK06/7 rl RL01/2 si RM05, CDC 9766 ra RA60/80/81, RX50, RD51/52/53, RC25 ht TU/TE16 tm TU/TE10 ts TS-11 .fi .PP The stand alone tape drive unit number is specially encoded to specify both unit number and tape density (BPI). Most tape subsystems either automatically adjust to tape density or have switches on the drives to force the density to a particular setting, but for those which don't the following density select mechanisms may be necessary. The \fBts\fP only operates at 1600BPI, so there is no special unit density encoding. The \fBht\fP will operate at either 800BPI or 1600BPI. Units 0 through 3 correspond to 800BPI, and 4 through 7 to 1600BPI on drives 0 through 3 respectively. The standard DEC \fBtm\fP only supports 800BPI (and hence can't be used with the standard \*(2B distribution tape), but several widely used \fBtm\fP emulators support 1600BPI and even 6250BPI. Units 0 through 3 correspond to 800BPI, 4 through 7 to 1600BPI, and 8 through 11 to 6250BPI on drives 0 through 3 respectively. .PP For example, to boot a system from unit 0 on an RK07, type \*(lqhk(0,0)unix\*(rq to the boot prompt. The specification \*(lqra(1,0)unix\*(rq indicates an MSCP disk, unit 1. The specification \*(lqra(1,0,0)unix\*(rq indicates an MSCP disk, unit 0 but on controller 1. And finally the specification \*(lqts(0,3)\*(rq would cause the fourth file on a tape threaded on `ts' tape drive 0 to be loaded and executed. .PP .B "Cold boot loaders:" The following programs to load and execute the primary bootstrap may be installed in read-only memories or manually keyed into main memory. Each program is position-independent but should be placed well above location 0 so it will not be overwritten. Each reads a block from the beginning of a device into core location zero. The octal words constituting the program are listed on the left. .PP .nf .if n .ta 3 11 15 23 38 .if t .ta .3i 1i 1.4i 2i 3.5i .ne 10 RK (drive 0): 012700 mov $rkda,r0 177412 005040 clr \-(r0) / rkda cleared by start 010040 mov r0,\-(r0) 012740 mov $5,\-(r0) 000005 105710 1: tstb (r0) 002376 bge 1b 005007 clr pc .PP .ne 11 RP (drive 0) 012700 mov $rpmr,r0 176726 005040 clr \-(r0) 005040 clr \-(r0) 005040 clr \-(r0) 010040 mov r0,\-(r0) 012740 mov $5,\-(r0) 000005 105710 1: tstb (r0) 002376 bge 1b 005007 clr pc .PP .ne 7 TM (drive 0): 012700 mov $tmba,r0 172526 010040 mov r0,\-(r0) 012740 mov $60003,\-(r0) 060003 000777 br . .DT .SH FILES .ta \w'/mdec/xxuboot 'u /unix system code .br /boot system bootstrap .br /etc/init system process dispatcher .br /mdec/xxuboot sector 0 boot blocks, xx is disk type .SH "SEE ALSO" crash(8V), autoconfig(8), reboot(2), disklabel(8), fsck(8), init(8) ================================================ FILE: share/man/man8/bugfiler.8 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)bugfiler.8 6.2.1 (2.11BSD) 1996/10/23 .\" .TH BUGFILER 8 "October 23, 1996" .UC 5 .SH NAME bugfiler \- file bug reports in folders automatically .SH SYNOPSIS .B bugfiler [ mail directory ] .SH DESCRIPTION .I Bugfiler is a program to automatically intercept bug reports, summarize them and store them in the appropriate sub directories of the mail directory specified on the command line or the (system dependent) default. It is designed to be compatible with the Rand MH mail system. .I Bugfiler is normally invoked by the mail delivery program through .IR aliases (5) with a line such as the following in /etc/aliases. .PP .DT bugs:"|bugfiler /usr/bugs/mail" .PP It reads the message from the standard input or the named file, checks the format and returns mail acknowledging receipt or a message indicating the proper format. Valid reports are then summarized and filed in the appropriate folder; improperly formatted messages are filed in a folder named ``errors.'' Program maintainers can then log onto the system and check the summary file for bugs that pertain to them. Bug reports should be submitted in RFC822 format and aremust contain the following header lines to be properly indexed: .PP .DT Date: .br From: .br Subject: .br Index: / [Fix] .PP In addition, the body of the message must contain a line which begins with ``Description:'' followed by zero or more lines describing the problem in detail and a line beginning with ``Repeat-By:'' followed by zero or more lines describing how to repeat the problem. If the keyword `Fix' is specified in the `Index' line, then there must also be a line beginning with ``Fix:'' followed by a diff of the old and new source files or a description of what was done to fix the problem. .PP The `Index' line is the key to the filing mechanism. The source directory name must match one of the folder names in the mail directory. The message is then filed in this folder and a line appended to the summary file in the following format: .PP .DT / .br .PP The bug report may also be redistributed according to the index. If the file .IR maildir /.redist exists, it is examined for a line beginning with the index name followed with a tab. The remainder of this line contains a comma-separated list of mail addresses which should receive copies of bugs with this index. The list may be continued onto multiple lines by ending each but the last with a backslash (`\e'). .SH FILES .ta 2.5i /usr/sbin/sendmail mail delivery program .br /usr/libexec/unixtomh converts unix mail format to mh format .br maildir/.ack the message sent in acknowledgement .br maildir/.format the message sent when format errors are detected .br maildir/.redist the redistribution list .br maildir/summary the summary file .br maildir/Bf?????? temporary copy of the input message .br maildir/Rp?????? temporary file for the reply message. .SH "SEE ALSO" mh(1), newaliases(1), aliases(5) .SH BUGS .PP Since mail can be forwarded in a number of different ways, .I bugfiler does not recognize forwarded mail and will reply/complain to the forwarder instead of the original sender unless there is a `Reply-To' field in the header. .PP Duplicate messages should be discarded or recognized and put somewhere else. ================================================ FILE: share/man/man8/crash.8 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)crash.8v 6.2 (Berkeley) 5/20/86 .\" .TH CRASH 8V "July 11, 1987" .UC 2 .SH NAME crash \- what happens when the system crashes .SH DESCRIPTION This section explains what happens when the system crashes and (very briefly) how to analyze crash dumps. .PP When the system crashes voluntarily it prints a message of the form .IP panic: why i gave up the ghost .LP on the console, takes a dump on a mass storage peripheral, and then invokes an automatic reboot procedure as described in .IR reboot (8). Unless some unexpected inconsistency is encountered in the state of the file systems due to hardware or software failure, the system will then resume multi-user operations. If the automatic file system check fails, the file systems should be checked and repaired with .IR fsck (8) before continuing. .PP The system has a large number of internal consistency checks; if one of these fails, then it will panic with a very short message indicating which one failed. In many instances, this will be the name of the routine which detected the error, or a two-word description of the inconsistency. A full understanding of most panic messages requires perusal of the source code for the system. .PP The most common cause of system failures is hardware failure, which can reflect itself in different ways. Here are the messages which are most likely, with some hints as to causes. Left unstated in all cases is the possibility that hardware or software error produced the message in some unexpected way. .TP .B iinit This cryptic panic message results from a failure to mount the root filesystem during the bootstrap process. Either the root filesystem has been corrupted, or the system is attempting to use the wrong device as root filesystem. Usually, an alternate copy of the system binary or an alternate root filesystem can be used to bring up the system to investigate. .TP .B Can't exec /etc/init This is not a panic message, as reboots are likely to be futile. Late in the bootstrap procedure, the system was unable to locate and execute the initialization process, .IR init (8). The root filesystem is incorrect or has been corrupted, or the mode or type of /etc/init forbids execution. .TP .B hard IO err in swap The system encountered an error trying to write to the swap device or an error in reading critical information from a disk drive. The offending disk should be fixed if it is broken or unreliable. .TP .B timeout table overflow .ns This really shouldn't be a panic, but until the data structure involved is made to be extensible, running out of entries causes a crash. If this happens, make the timeout table bigger. (NCALL in param.c) .TP .B trap type %o An unexpected trap has occurred within the system; the trap types are: .PP .nf 0 bus error 1 illegal instruction trap 2 BPT/trace trap 3 IOT 4 power fail trap (if autoreboot fails) 5 EMT 6 recursive system call (TRAP instruction) 7 programmed interrupt request 11 protection fault (segmentation violation) 12 parity trap .fi .PP In some of these cases it is possible for octal 020 to be added into the trap type; this indicates that the processor was in user mode when the trap occurred. .PP In addition to the trap type, the system will have printed out three (or four) other numbers: .IR ka6 , which is the contents of the segmentation register for the area in which the system's stack is kept; .IR aps , which is the location where the hardware stored the program status word during the trap; .IR pc , which was the system's program counter when it faulted (already incremented to the next word); .IR __ovno , the overlay number of the currently loaded kernel overlay when the trap occurred. .PP The favorite trap types in system crashes are trap types 0 and 11, indicating a wild reference. The code is the referenced address, and the pc at the time of the fault is printed. These problems tend to be easy to track down if they are kernel bugs since the processor stops cold, but random flakiness seems to cause this sometimes. The debugger can be used to locate the instruction and subroutine corresponding to the PC value. If that is insufficient to suggest the nature of the problem, more detailed examination of the system status at the time of the trap usually can produce an explanation. .TP .B init died The system initialization process has exited. This is bad news, as no new users will then be able to log in. Rebooting is the only fix, so the system just does it right away. .TP .B out of mbufs: map full The network has exhausted its private page map for network buffers. This usually indicates that buffers are being lost, and rather than allow the system to slowly degrade, it reboots immediately. The map may be made larger if necessary. .TP out of swap space This really shouldn't be panics but there's no other satisfactory solution. The size of the swap area must be increased. The system attempts to avoid running out of swap by refusing to start new processes when short of swap space (resulting in ``No more proceses'' messages from the shell). .TP &remap_area > SEG5 .ns .TP _end > SEG5 The kernel detected at boot time that an unacceptable portion of its data space extended into the region controlled by KDSA5. In the case of the first message, the size of the kernel's data segment (excluding the file, proc, and text tables) must be decreased. In the latter case, there are two possibilities: if &remap_area is not greater than 0120000, the kernel must be recompiled without defining the option NOKA5. Otherwise, as above, the size of the kernel's data segment must be decreased. .PP That completes the list of panic types you are likely to see. There are many other panic messages which are less likely to occur; most of them detect logical inconsistencies within the kernel and thus ``cannot happen'' unless some part of the kernel has been modified. .PP If the system stops or hangs without a panic, it is possible to stop it and take a dump of memory before rebooting. A panic can be forced from the console, which will allow a dump, automatic reboot and file system check. This is accomplished by halting the CPU, putting the processor in kernel mode, loading the PC with 40, and continuing without a reset (use continue, not start). To put the processor in kernel mode, make sure the two high bits in the processor status word are zero. (you'll need to consult the procesor handbook describing your processor to determine how to access the PC and PS ...) The message ``panic: forced from console'' should print, and the automatic reboot will start. .PP If this fails a dump of memory can be made on magtape: mount a tape (with write ring!), halt the CPU, load address 044, and perform a start (which does a reset). This should write a copy of all of core on the tape with an EOF mark. Caution: Any error is taken to mean the end of core has been reached. This means that you must be sure the ring is in, the tape is ready, and the tape is clean and new. If the dump fails, you can try again, but some of the registers will be lost. After this completes, halt again and reboot. .PP After rebooting, or after an automatic file system check fails, check and fix the file systems with .IR fsck . If the system will not reboot, a runnable system must be obtained from a backup medium after verifying that the hardware is functioning normally. A damaged root file system should be patched while running with an alternate root if possible. .PP When the system crashes if crash dumping was enabled it writes (or at least attempts to write) an image of memory into the back end of the dump device, usually the same as the primary swap area. After the system is rebooted, the program .IR savecore (8) runs and preserves a copy of this core image and the current system in a specified directory for later perusal. See .IR savecore (8) for details. A magtape dump can be read onto disk with .IR dd (1). .PP To analyze a dump you should begin by running .IR adb (1) with the .B \-k flag on the system load image and core dump. If the core image is the result of a panic, the panic message is printed. Normally the command ``$c'' or ``$C'' will provide a stack trace from the point of the crash and this will provide a clue as to what went wrong. .IR ps (1) and .IR pstat (8) can also be used to print the process table at the time of the crash via: .I "ps\ \-alxk" and .IR "pstat\ \-p" . If the mapping or the stack frame are incorrect, the following magic locations may be examined in an attempt to find out what went wrong. The registers R0, R1, R2, R3, R4, R5, SP, and KDSA6 (or KISA6 for machines without separate instruction and data) are saved at location 04. If the core dump was taken on disk, these values also appear at 0300. The value of KDSA6 (KISA6) multiplied by 0100 (8) gives the address of the user structure and kernel stack for the running process. Relabel these addresses 0140000 through 0142000. R5 is C's frame or display pointer. Stored at (R5) is the old R5 pointing to the previous stack frame. At (R5)+2 is the saved PC of the calling procedure. Trace this calling chain to an R5 value of 0141756 (0141754 for overlaid kernels), which is where the user's R5 is stored. If the chain is broken, look for a plausible R5, PC pair and continue from there. In most cases this procedure will give an idea of what is wrong. .PP A more complete discussion of system debugging is impossible here. See, however, ``Using ADB to Debug the UNIX Kernel''. .SH "SEE ALSO" adb(1), ps(1), pstat(1), boot(8), fsck(8), reboot(8), savecore(8) .br .I "PDP-11 Processor Handbook" for various processors for more information about PDP-11 memory management and general architecture. .br .I "Using ADB to Debug the UNIX Kernel" ================================================ FILE: share/man/man8/drtest.8 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)drtest.8 6.2 (Berkeley) 5/19/86 .\" .TH DRTEST 8 "May 19, 1986" .UC 5 .SH NAME drtest \- standalone disk test program .SH DESCRIPTION .PP .I Drtest is a standalone program used to read a disk track by track. It was primarily intended as a test program for new standalone drivers, but has shown useful in other contexts as well, such as verifying disks and running speed tests. For example, when a disk has been formatted (by format(8)), you can check that hard errors has been taken care of by running .IR drtest . No hard errors should be found, but in many cases quite a few soft ECC errors will be reported. .PP While .I drtest is running, the cylinder number is printed on the console for every 10th cylinder read. .SH EXAMPLE A sample run of .I drtest is shown below. In this example (using a 750), .I drtest is loaded from the root file system; usually it will be loaded from the machine's console storage device. Boldface means user input. As usual, ``#'' and ``@'' may be used to edit input. .nf .in +5 .sp 1 >>>\fBB/3\fR %% loading hk(0,0)boot Boot : \fBhk(0,0)drtest\fR Test program for stand-alone up and hp driver .sp 1 Debugging level (1=bse, 2=ecc, 3=bse+ecc)? Enter disk name [type(adapter,unit), e.g. hp(1,3)]? \fBhp(0,0)\fR Device data: #cylinders=1024, #tracks=16, #sectors=32 Testing hp(0,0), chunk size is 16384 bytes. \fI(chunk size is the number of bytes read per disk access)\fP Start ...Make sure hp(0,0) is online ... \fI(errors are reported as they occur)\fP ... \fI(...program restarts to allow checking other disks)\fP \fI(...to abort halt machine with ^P)\fP .in -5 .fi .sp 1 .SH DIAGNOSTICS The diagnostics are intended to be self explanatory. Note, however, that the device number in the diagnostic messages is identified as \fItypeX\fR instead of \fItype(a,u)\fR where \fIX\fR = a*8+u, e.g., hp(1,3) becomes hp11. .SH SEE ALSO format(8V), bad144(8) .SH AUTHOR Helge Skrivervik ================================================ FILE: share/man/man8/dump.8 ================================================ .\" .\" @(#)dump.8 1.2 (2.11BSD GTE) 1996/11/17 .\" .TH DUMP 8 "November 17, 1996" .UC 4 .SH NAME dump \- incremental file system dump .SH SYNOPSIS .B dump [0123456789BchfusTdWwn [\fIargument\fP\& ...]] [filesystem] .SH DESCRIPTION .I Dump copies to magnetic tape all files changed after a certain date in the .I filesystem. .PP The following options are supported by dump: .TP 5 .B 0\-9 This number is the `dump level'. All files modified since the last date stored in the file .I /etc/dumpdates for the same filesystem at lesser levels will be dumped. If no date is determined by the level, the beginning of time is assumed; thus the option .B 0 causes the entire filesystem to be dumped. .TP 5 .B B records The number of dump records per volume. This option overrides the calculation of tape size based on length and density. .TP 5 .B c This option requires no further options. Used to specify that the tape is a \fIcartridge\fP drive rather than a 9\-track. .TP 5 .B h level Honor the user 'nodump' flags only for dumps at or above the given \fBlevel\fP. The default honor level is 1, so that incremental backups omit such files but full backups retain them. .TP 5 .B f Place the dump on the next .I argument file instead of the tape. If '-' is given then standard out (stdout) is written to. .TP 5 .B u If the dump completes successfully, write the date of the beginning of the dump on file .I /etc/dumpdates. This file records a separate date for each filesystem and each dump level. The format of .I /etc/dumpdates is readable by people, consisting of one free format record per line: filesystem name, increment level and .I ctime(3) format dump date. .I /etc/dumpdates may be edited to change any of the fields, if necessary. Note that .I /etc/dumpdates is in a format different from that which previous versions of .I dump maintained in .I /etc/ddate, although the information content is identical. .TP 5 .B s The size of the dump tape is specified in feet. The number of feet is taken from the next .I argument. When the specified size is reached, .I dump will wait for reels to be changed. The default tape size is 2300 feet. .TP 5 .B d The density of the tape, expressed in BPI, is taken from the next .I argument. This is used in calculating the amount of tape used per reel. The default is 1600. .TP 5 .B T date Use the specified date as the starting time for the dump instead of the time determined from looking in \fB/etc/dumpdates\fP. The format of \fBdate\fP is the same as that of \fIctime(3)\fP. This option is useful for automated dump scripts that wish to dump over a specific period of time. The \fBT\fP option is mutually exclusive with the \fBu\fP option. .TP 5 .B W .I Dump tells the operator what file systems need to be dumped. This information is gleaned from the files .I /etc/dumpdates and .I /etc/fstab. The .B W option causes .I dump to print out, for each file system in .I /etc/dumpdates the most recent dump date and level, and highlights those file systems that should be dumped. If the .B W option is set, all other options are ignored, and .I dump exits immediately. .TP 5 .B w Is like W, but prints only those filesystems which need to be dumped. .TP 5 .B n Whenever .I dump requires operator attention, notify by means similar to a .I wall(1) all of the operators in the group \*(lqoperator\*(rq. .PP If no arguments are given, the .I key is assumed to be .B 9u and a default file system is dumped to the default tape. .PP .I Dump requires operator intervention on these conditions: end of tape, end of dump, tape write error, tape open error or disk read error (if there are more than a threshold of 32). In addition to alerting all operators implied by the .B n key, .I dump interacts with the operator on .I dump's control terminal at times when .I dump can no longer proceed, or if something is grossly wrong. All questions .I dump poses .B must be answered by typing \*(lqyes\*(rq or \*(lqno\*(rq, appropriately. .PP Since making a dump involves a lot of time and effort for full dumps, .I dump checkpoints itself at the start of each tape volume. If writing that volume fails for some reason, .I dump will, with operator permission, restart itself from the checkpoint after the old tape has been rewound and removed, and a new tape has been mounted. .PP .I Dump tells the operator what is going on at periodic intervals, including usually low estimates of the number of blocks to write, the number of tapes it will take, the time to completion, and the time to the tape change. The output is verbose, so that others know that the terminal controlling .I dump is busy, and will be for some time. .PP Now a short suggestion on how to perform dumps. Start with a full level 0 dump .PP dump 0un .PP Next, dumps of active file systems are taken on a daily basis, using a modified Tower of Hanoi algorithm, with this sequence of dump levels: .ce 1 3 2 5 4 7 6 9 8 9 9 ... For the daily dumps, a set of 10 tapes per dumped file system is used on a cyclical basis. Each week, a level 1 dump is taken, and the daily Hanoi sequence repeats with 3. For weekly dumps, a set of 5 tapes per dumped file system is used, also on a cyclical basis. Each month, a level 0 dump is taken on a set of fresh tapes that is saved forever. .SH FILES .nf .ta \w'/etc/dumpdates\ \ 'u /dev/rxp0a default filesystem to dump from /dev/rmt0 default tape unit to dump to /etc/ddate old format dump date record (obsolete after \fB\-J\fR option) /etc/dumpdates new format dump date record /etc/fstab Dump table: file systems and frequency /etc/group to find group \fIoperator\fP .fi .DT .br .SH "SEE ALSO" restor(8), rdump(8), dump(5), fstab(5), dumpdir(8) .SH DIAGNOSTICS Many, and verbose. .SH BUGS .PP Sizes are based on 1600 BPI blocked tape; the raw magtape device has to be used to approach these densities. Fewer than 32 read errors on the filesystem are ignored. Each reel requires a new process, so parent processes for reels already written just hang around until the entire tape is written. .PP It would be nice if .I dump knew about the dump sequence, kept track of the tapes scribbled on, told the operator which tape to mount when, and provided more assistance for the operator running .I restor. ================================================ FILE: share/man/man8/dumpdir.8 ================================================ .TH DUMPDIR 8 "September 8, 1987" .UC .SH NAME dumpdir, 512dumpdir \- print the names of files on a dump tape .SH SYNOPSIS .I dumpdir [ .B f filename ] .br .I 512dumpdir [ .B f filename ] .SH DESCRIPTION .I Dumpdir is used to read magtapes dumped with the .I dump command and list the names and inode numbers of all the files and directories on the tape. .PP The .B f option causes .I filename as the name of the tape instead of the default. .PP .I 512dumpdir is a version of .I dumpdir that can read tapes written from 512-byte block file systems. .SH FILES .ta 2i /dev/rmt1 default file name .br rst* temporary files .SH "SEE ALSO" dump(8), restor(8) .SH DIAGNOSTICS If the dump extends over more than one tape, it may ask you to change tapes. Reply with a newline when the next tape has been mounted. .SH BUGS There is redundant information on the tape that could be used in case of tape reading problems. Unfortunately, .IR dumpdir " and " 512dumpdir don't use it. ================================================ FILE: share/man/man8/format.8 ================================================ .\" Copyright (c) 1980,1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)format.8v 6.4 (Berkeley) 5/22/86 .\" .TH FORMAT 8V "May 22, 1986" .UC 4 .SH NAME format \- how to format disk packs .SH DESCRIPTION .PP There are two ways to format disk packs. The simplest is to use the .I format program. The alternative is to use the DEC standard formatting software which operates under the DEC diagnostic supervisor. This manual page describes the operation of .IR format , then concludes with some remarks about using the DEC formatter. .PP .I Format is a standalone program used to format and check disks prior to constructing file systems. In addition to the formatting operation, .I format records any bad sectors encountered according to DEC standard 144. Formatting is performed one track at a time by writing the appropriate headers and a test pattern and then checking the sector by reading and verifying the pattern, using the controller's ECC for error detection. A sector is marked bad if an unrecoverable media error is detected, or if a correctable ECC error too many bits in length is detected (such errors are indicated as ``ECC'' in the summary printed upon completing the format operation). After the entire disk has been formatted and checked, the total number of errors are reported, any bad sectors and skip sectors are marked, and a bad sector forwarding table is written to the disk in the first five even numbered sectors of the last track. It is also possible to reformat sections of the disk in units of tracks. .I Format may be used on any UNIBUS or MASSBUS drive supported by the \fIup\fP and \fIhp\fP device drivers which uses 4-byte headers (everything except RP's). .PP The test pattern used during the media check may be selected from one of: 0xf00f (RH750 worst case), 0xec6d (media worst case), and 0xa5a5 (alternating 1's and 0's). Normally the media worst case pattern is used. .PP .I Format also has an option to perform an extended \*(lqsevere burn-in,\*(rq which makes a number of passes using different patterns. The number of passes can be selected at run time, up to a maximum of 48, with provision for additional passes or termination after the preselected number of passes. This test runs for many hours, depending on the disk and processor. .PP Each time .I format is run to format an entire disk, a completely new bad sector table is generated based on errors encountered while formatting. The device driver, however, will always attempt to read any existing bad sector table when the device is first opened. Thus, if a disk pack has never previously been formatted, or has been formatted with different sectoring, five error messages will be printed when the driver attempts to read the bad sector table; these diagnostics should be ignored. .PP Formatting a 400 megabyte disk on a MASSBUS disk controller usually takes about 20 minutes. Formatting on a UNIBUS disk controller takes significantly longer. For every hundredth cylinder formatted .I format prints a message indicating the current cylinder being formatted. (This message is just to reassure people that nothing is is amiss.) .PP .I Format uses the standard notation of the standalone I/O library in identifying a drive to be formatted. A drive is specified as .IR zz ( x , y ), where .I zz refers to the controller type (either .I hp or .IR up ), .I x is the unit number of the drive; 8 times the UNIBUS or MASSBUS adaptor number plus the MASSBUS drive number or UNIBUS drive unit number; and .I y is the file system partition on drive .I x (this should always be 0). For example, ``hp(1,0)'' indicates that drive 1 on MASSBUS adaptor 0 should be formatted; while ``up(10,0)'' indicates that UNIBUS drive 2 on UNIBUS adaptor 1 should be formatted. .PP Before each formatting attempt, .I format prompts the user in case debugging should be enabled in the appropriate device driver. A carriage return disables debugging information. .PP .I Format should be used prior to building file systems (with .IR newfs (8)) to insure that all sectors with uncorrectable media errors are remapped. If a drive develops uncorrectable defects after formatting, either .IR bad144 (8) or .IR badsect (8) should be able to avoid the bad sectors. .SH EXAMPLE A sample run of .I format is shown below. In this example (using a VAX-11/780), .I format is loaded from the console floppy; on an 11/750 .I format will be loaded from the root file system with .IR boot (8) following a \*(lqB/3\*(rq command. Boldface means user input. As usual, ``#'' and ``@'' may be used to edit input. .nf .in +0.5i .ta 1i .sp 1 >>>\fBL FORMAT\fP LOAD DONE, 00004400 BYTES LOADED >>>\fBS 2\fP Disk format/check utility .sp Enable debugging (0=none, 1=bse, 2=ecc, 3=bse+ecc)? \fB0\fP Device to format? \fBhp(8,0)\fP (\fIerror messages may occur as old bad sector table is read\fP) Formatting drive hp0 on adaptor 1: verify (yes/no)? \fByes\fP Device data: #cylinders=842, #tracks=20, #sectors=48 Starting cylinder (0): Starting track (0): Ending cylinder (841): Ending track (19): Available test patterns are: .in +1.0i 1 - (f00f) RH750 worst case 2 - (ec6d) media worst case 3 - (a5a5) alternating 1's and 0's 4 - (ffff) Severe burnin (up to 48 passes) .in -1.0i Pattern (one of the above, other to restart)? \fB2\fP Maximum number of bit errors to allow for soft ECC (3): Start formatting...make sure the drive is online ... (\fIsoft ecc's and other errors are reported as they occur\fP) ... (\fIif 4 write check errors were found, the program terminates like this...\fP) ... Errors: Bad sector: 0 Write check: 4 Hard ECC: 0 Other hard: 0 Marked bad: 0 Skipped: 0 Total of 4 hard errors revectored. Writing bad sector table at block 808272 (\fI808272 is the block # of the first block in the bad sector table\fP) Done (\fI...program restarts to allow formatting other disks\fP) (\fI...to abort halt machine with ^P\fP) .fi .sp 1 .SH DIAGNOSTICS The diagnostics are intended to be self explanatory. .SH "USING DEC SOFTWARE TO FORMAT" .PP .B "Warning: These instructions are for people with 11/780 CPU's." The steps needed for 11/750 or 11/730 cpu's are similar, but not covered in detail here. .I .PP The formatting procedures are different for each type of disk. Listed here are the formatting procedures for RK07's, RP0X, and RM0X disks. .PP You should shut down UNIX and halt the machine to do any disk formatting. Make certain you put in the pack you want formatted. It is also a good idea to spin down or write protect the disks you don't want to format, just in case. .PP .B "Formatting an RK07." Load the console floppy labeled, "RX11 VAX DSK LD DEV #1" in the console disk drive, and type the following commands: .RS .nf >>>BOOT DIAGNOSTIC SUPERVISOR. ZZ-ESSAA-X5.0-119 23-JAN-1980 12:44:40.03 DS>ATTACH DW780 SBI DW0 3 5 DS>ATTACH RK611 DMA DS>ATTACH RK07 DW0 DMA0 DS>SELECT DMA0 DS>LOAD EVRAC DS>START/SEC:PACKINIT .fi .RE .PP .B "Formatting an RP0X." Follow the above procedures except that the ATTACH and SELECT lines should read: .RS .nf DS>ATTACH RH780 SBI RH0 8 5 DS>ATTACH RP0X RH0 DBA0 (RP0X is, e.g. RP06) DS>SELECT DBA0 .fi .RE .PP This is for drive 0 on mba0; use 9 instead of 8 for mba1, etc. .PP .B "Formatting an RM0X." Follow the above procedures except that the ATTACH and SELECT lines should read: .RS .nf DS>ATTACH RH780 SBI RH0 8 5 DS>ATTACH RM0X RH0 DRA0 DS>SELECT DRA0 .fi .RE .PP Don't forget to put your UNIX console floppy back in the floppy disk drive. .SH SEE ALSO bad144(8), badsect(8), newfs(8) .SH BUGS An equivalent facility should be available which operates under a running UNIX system. .PP It should be possible to reformat or verify part or all of a disk, then update the existing bad sector table. ================================================ FILE: share/man/man8/fsck.8 ================================================ .de us \\$1\l'|0\(ul' .. .TH FSCK 8 "November 18, 1996" .UC .SH NAME fsck \- file system consistency check and interactive repair .SH SYNOPSIS .B fsck .BR \-p "[ # ]" [ filesystem ... ] .br .B fsck [ .B \-y ] [ .B \-n ] [ .BR \-s X ] [ .BR \-S X ] [ .B \-t filename ] [ filesystem ] ... .SH DESCRIPTION The first form of .I fsck preens a standard set of file systems or the specified file systems. It is normally used in the script .I /etc/rc during automatic reboot. In this case .I fsck reads the table .I /etc/fstab to determine which file systems to check. It uses the information there to inspect groups of disks in parallel taking maximum advantage of i/o overlap to check the file systems as quickly as possible. Normally, the root file system will be checked on pass 1, other ``root'' (``a'' partition) file systems on pass 2, other small file systems on separate passes (e.g. the ``d'' file systems on pass 3 and the ``e'' file systems on pass 4), and finally the large user file systems on the last pass, e.g. pass 5. Only one file system from each disk should be checked in each pass. A pass number of 0 in fstab causes a disk to not be checked; similarly partitions which are not shown as to be mounted ``rw'' or ``ro'' are not checked. A number or range of numbers may be given after the .B \-p to start or end the check at a specified pass number. A single number specifies the starting pass (e.g. \-p2 or \-p2\-); a range specifies the starting and endig passes (\-p2\-4). A missing start means to start with pass 1 (\-p\-2). These can be used to stop fsck to mount a temporary file system before continuing the check on larger file systems requiring scratch files. .PP The system normally takes care that only a restricted class of innocuous inconsistencies can happen unless hardware or software failures intervene. These are limited to the following: .IP Unreferenced inodes .ns .IP Link counts in inodes too large .ns .IP Missing blocks in the free list .ns .IP Blocks in the free list also in files .ns .IP Counts in the superblock wrong .ns .IP Allocated inodes in the free inode list .PP These are the only inconsistencies which .I fsck with the .B \-p option will correct; if it encounters other inconsistencies, it exits with an abnormal return status and an automatic reboot will then fail. For each corrected inconsistency one or more lines will be printed identifying the file system on which the correction will take place, and the nature of the correction. After successfully correcting a file system, .I fsck will print the number of files on that file system and the number of used and free blocks. .B Warning: kernel changes are required to limit the types of inconsistencies, and .B "fsck \-p" makes assumptions about the kernel's actions in repairing these. Vmunix, PDP-11 2.9BSD with the UCB_FSFIX option and PDP-11 2.10BSD Unix kernels have the appropriate modifications; the .B \-p option should not be used on other systems. .PP Without the .B \-p option, .I fsck audits and interactively repairs inconsistent conditions for file systems. If the file system is inconsistent the operator is prompted for concurrence before each correction is attempted. It should be noted that a number of the corrective actions which are not fixable under the .B \-p option will result in some loss of data. The amount and severity of data lost may be determined from the diagnostic output. The default action for each consistency correction is to wait for the operator to respond \fByes\fP or \fBno\fP. If the operator does not have write permission .I fsck will default to a .BR "\-n " action. .PP .I Fsck has more consistency checks than its predecessors .IR "check, dcheck, fcheck, " "and" " icheck" combined. .PP The following flags are interpreted by .I fsck. .TP 6 .B \-\^y Assume a yes response to all questions asked by .I fsck; this should be used with great caution as this is a free license to continue after essentially unlimited trouble has been encountered. .TP 6 .B \-\^n Assume a no response to all questions asked by .I fsck; do not open the file system for writing. .TP 6 .BR \-\^s \fIX Ignore the actual free list and (unconditionally) reconstruct a new one by rewriting the superblock of the file system. The file system should be unmounted while this is done; if this is not possible, care should be taken that the system is quiescent and that it is rebooted immediately afterwards. This precaution is necessary so that the old, bad, in-core copy of the superblock will not continue to be used, or written on the file system. .IP The .BR \-s \fIX option allows for creating an optimal free list organization. The following forms of .I X are supported for the following devices: .sp .nf \-s3 (RP03) \-s4 (RP04, RP05, RP06) \-sBlocks-per-cylinder\fB:\fPBlocks-to-skip (for anything else) .fi .IP "" 6 If .I X is not given, the values used when the file system was created are used. If these values were not specified, then the value .I 400:9 is used. .TP 6 .BR \-\^S \fIX Conditionally reconstruct the free list. This option is like .BR \-s \fIX above except that the free list is rebuilt only if there were no discrepancies discovered in the file system. Using .B \-S will force a no response to all questions asked by .I fsck. This option is useful for forcing free list reorganization on uncontaminated file systems. .TP 6 .B \-\^t If .I fsck cannot obtain enough memory to keep its tables, it uses a scratch file. If the \f3\-t\fP option is specified, the file named in the next argument is used as the scratch file, if needed. Without the .BR "\-t " flag, .I fsck will prompt the operator for the name of the scratch file. The file chosen should not be on the file system being checked, and if it is not a special file or did not already exist, it is removed when .I fsck completes. .PP If no file systems are given to .I fsck then a default list of file systems is read from the file .IR /etc/fstab . .PP .ne 10 Inconsistencies checked are as follows: .TP 6 1. Blocks claimed by more than one inode or the free list. .br .br .ns .TP 6 2. Blocks claimed by an inode or the free list outside the range of the file system. .br .br .ns .TP 6 3. Incorrect link counts. .br .br .ns .TP 6 4. Size checks: .br .ns .IP "" 12 Directory size not 16-byte aligned. .br .br .ns .TP 6 5. Bad inode format. .br .br .ns .TP 6 6. Blocks not accounted for anywhere. .br .br .ns .TP 6 7. Directory checks: .br .br .ns .IP "" 12 File pointing to unallocated inode. .br Inode number out of range. .br .br .ns .TP 6 8. Super Block checks: .br .br .ns .IP "" 12 More than 65536 inodes. .br More blocks for inodes than there are in the file system. .br .br .ns .TP 6 9. Bad free block list format. .br .br .ns .TP 6 10. Total free block and/or free inode count incorrect. .br .ns .TP 6 11. Allocated inodes on the free inode list in the superblock. .PP Orphaned files and directories (allocated but unreferenced) are, with the operator's concurrence, reconnected by placing them in the .I lost+found directory. The name assigned is the inode number. The only restriction is that the directory .I lost+found must preexist in the root of the file system being checked and must have empty slots in which entries can be made. This can be accomplished manually by making .IR lost+found , copying a number of files to the directory, and then removing them (before .I fsck is executed). .IR Mkfs (8) will automatically create a .I lost+found directory. .PP Checking the raw device is almost always faster. The root device should not be checked using the raw device, however, since it cannot be unmounted. .SH FILES .ta 2i /etc/fstab default list of file systems to check .SH DIAGNOSTICS The diagnostics produced by .I fsck are intended to be self-explanatory. The exit codes with the .B \-p option are 0 (no problems that weren't fixed), 4 (root file system was modified), 8 (problems that couldn't be fixed) and 12 .RI ( fsck was interrupted). .SH "SEE ALSO" filsys(5), fstab(5), crash(8), mkfs(8), mklost+found(8), reboot(8) .br T. J. Kowalski, .I "FSCK \- The UNIX File System Check Program" .SH BUGS Inode numbers for .BR . "" and .BR .. "" in each directory should be checked for validity. ================================================ FILE: share/man/man8/getty.8 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)getty.8 6.4.1 (2.11BSD) 1996/11/17 .\" .TH GETTY 8 "November 17, 1996" .UC 4 .SH NAME getty \- set terminal mode .SH SYNOPSIS .B getty [ type [ tty ] ] .SH DESCRIPTION .I Getty is usually invoked by .IR init (8) to open and initialize the tty line, read a login name, and invoke .IR login (1). .I getty attempts to adapt the system to the speed and type of terminal being used. .PP The argument .I tty is the special device file in /dev to open for the terminal (e.g., ``ttyh0''). If there is no argument or the argument is ``\-'', the tty line is assumed to be open as file descriptor 0. .PP The .I type argument can be used to make .I getty treat the terminal line specially. This argument is used as an index into the .IR gettytab (5) database, to determine the characteristics of the line. If there is no argument, or there is no such table, the .B default table is used. If there is no .B /etc/gettytab a set of system defaults is used. If indicated by the table located, .I getty will clear the terminal screen, print a banner heading, and prompt for a login name. Usually either the banner of the login prompt will include the system hostname. Then the user's name is read, a character at a time. If a null character is received, it is assumed to be the result of the user pushing the `break' (`interrupt') key. The speed is usually then changed and the `login:' is typed again; a second `break' changes the speed again and the `login:' is typed once more. Successive `break' characters cycle through the same standard set of speeds. .PP The user's name is terminated by a new-line or carriage-return character. The latter results in the system being set to treat carriage returns appropriately (see .IR tty (4)). .PP The user's name is scanned to see if it contains any lower-case alphabetic characters; if not, and if the name is nonempty, the system is told to map any future upper-case characters into the corresponding lower-case characters. .PP Finally, .I login is called with the user's name as an argument. .PP Most of the default actions of .I getty can be circumvented, or modified, by a suitable .I gettytab table. .PP .I Getty can be set to timeout after some interval, which will cause dial up lines to hang up if the login name is not entered reasonably quickly. .SH DIAGNOSTICS \fIttyxx\fR\|\fB: No such device or address\fR. \fIttyxx\fR\|\fB: No such file or address\fR. A terminal which is turned on in the \fIttys\fR file cannot be opened, likely because the requisite lines are either not configured into the system, the associated device was not attached during boot-time system configuration, or the special file in /dev does not exist. .SH FILES /etc/gettytab .SH "SEE ALSO" gettytab(5), init(8), login(1), ioctl(2), tty(4), ttys(5) ================================================ FILE: share/man/man8/htable.8 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)htable.8 6.3 (Berkeley) 5/22/86 .\" .TH HTABLE 8 "May 22, 1986" .UC 5 .SH NAME htable \- convert NIC standard format host tables .SH SYNOPSIS .B /etc/htable [ .B \-c .I connected-nets ] [ .B \-l .I local-nets ] .I file .SH DESCRIPTION .I Htable is used to convert host files in the format specified in Internet RFC 810 to the format used by the network library routines. Three files are created as a result of running .IR htable : .IR hosts , .IR networks , and .IR gateways . The .I hosts file may be used by the .IR gethostbyname (3N) routines in mapping host names to addresses if the nameserver, .IR named (8), is not used. The .I networks file is used by the .IR getnetent (3N) routines in mapping network names to numbers. The .I gateways file may be used by the routing daemon in identifying ``passive'' Internet gateways; see .IR routed (8C) for an explanation. .PP If any of the files .IR localhosts , .IR localnetworks , or .I localgateways are present in the current directory, the file's contents is prepended to the output file. Of these, only the gateways file is interpreted. This allows sites to maintain local aliases and entries which are not normally present in the master database. Only one gateway to each network will be placed in the gateways file; a gateway listed in the localgateways file will override any in the input file. .PP If the gateways file is to be used, a list of networks to which the host is directly connected is specified with the .B \-c flag. The networks, separated by commas, may be given by name or in Internet-standard dot notation, e.g. .B \-c arpanet,128.32,local-ether-net. .I Htable only includes gateways which are directly connected to one of the networks specified, or which can be reached from another gateway on a connected net. .PP If the .B \-l option is given with a list of networks (in the same format as for .BR \-c ), these networks will be treated as ``local,'' and information about hosts on local networks is taken only from the localhosts file. Entries for local hosts from the main database will be omitted. This allows the localhosts file to completely override any entries in the input file. .PP .I Htable is best used in conjunction with the .IR gettable (8C) program which retrieves the NIC database from a host. .SH "SEE ALSO" intro(3N), gettable(8C), named(8) .SH BUGS If the name-domain system provided network name mapping well as host name mapping, .I htable would no longer be needed. ================================================ FILE: share/man/man8/intro.8 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)intro.8 6.3 (Berkeley) 5/29/86 .\" .TH INTRO 8 "May 29, 1986" .UC 5 .SH NAME intro \- introduction to system maintenance and operation commands .SH DESCRIPTION This section contains information related to system operation and maintenance. It describes commands used to create new file systems, .IR newfs , verify the integrity of the file systems, .IR fsck , control disk usage, .IR edquota , maintain system backups, .IR dump , and recover files when disks die an untimely death, .IR restore . The section .I format should be consulted when formatting disk packs. Network related services are distinguished as 8C. The section .I crash should be consulted in understanding how to interpret system crash dumps. ================================================ FILE: share/man/man8/lpc.8 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)lpc.8 6.1.1 (2.11BSD) 1996/11/1 .\" .TH LPC 8 "November 1, 1996" .UC 5 .ad .SH NAME lpc \- line printer control program .SH SYNOPSIS .B /usr/sbin/lpc [ command [ argument ... ] ] .SH DESCRIPTION .I Lpc is used by the system administrator to control the operation of the line printer system. For each line printer configured in /etc/printcap, .I lpc may be used to: .IP \(bu disable or enable a printer, .IP \(bu disable or enable a printer's spooling queue, .IP \(bu rearrange the order of jobs in a spooling queue, .IP \(bu find the status of printers, and their associated spooling queues and printer dameons. .PP Without any arguments, .I lpc will prompt for commands from the standard input. If arguments are supplied, .IR lpc interprets the first argument as a command and the remaining arguments as parameters to the command. The standard input may be redirected causing .I lpc to read commands from file. Commands may be abreviated; the following is the list of recognized commands. .TP ? [ command ... ] .TP help [ command ... ] .br Print a short description of each command specified in the argument list, or, if no arguments are given, a list of the recognized commands. .TP abort { all | printer ... } .br Terminate an active spooling daemon on the local host immediately and then disable printing (preventing new daemons from being started by .IR lpr ) for the specified printers. .TP clean { all | printer ... } .br Remove any temporary files, data files, and control files that cannot be printed (i.e., do not form a complete printer job) from the specified printer queue(s) on the local machine. .TP disable { all | printer ... } .br Turn the specified printer queues off. This prevents new printer jobs from being entered into the queue by .IR lpr . .TP down { all | printer } message ... .br Turn the specified printer queue off, disable printing and put .I message in the printer status file. The message doesn't need to be quoted, the remaining arguments are treated like .IR echo (1). This is normally used to take a printer down and let others know why (lpq will indicate the printer is down and print the status message). .TP enable { all | printer ... } .br Enable spooling on the local queue for the listed printers. This will allow .I lpr to put new jobs in the spool queue. .TP exit .TP quit .br Exit from lpc. .TP restart { all | printer ... } .br Attempt to start a new printer daemon. This is useful when some abnormal condition causes the daemon to die unexpectedly leaving jobs in the queue. .I Lpq will report that there is no daemon present when this condition occurs. If the user is the super-user, try to abort the current daemon first (i.e., kill and restart a stuck daemon). .TP start { all | printer ... } .br Enable printing and start a spooling daemon for the listed printers. .TP status { all | printer ... } Display the status of daemons and queues on the local machine. .TP stop { all | printer ... } .br Stop a spooling daemon after the current job completes and disable printing. .TP topq printer [ jobnum ... ] [ user ... ] .br Place the jobs in the order listed at the top of the printer queue. .TP up { all | printer ... } .br Enable everything and start a new printer daemon. Undoes the effects of .IR down . .SH FILES .nf .ta \w'/etc/printcap 'u /etc/printcap printer description file /usr/spool/* spool directories /usr/spool/*/lock lock file for queue control .fi .SH "SEE ALSO" lpd(8), lpr(1), lpq(1), lprm(1), printcap(5) .SH DIAGNOSTICS .nf .ta \w'?Ambiguous command 'u ?Ambiguous command abreviation matches more than one command ?Invalid command no match was found ?Privileged command command can be executed by root only .fi ================================================ FILE: share/man/man8/lpd.8 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)lpd.8 6.3.1 (2.11BSD) 1996/10/23 .\" .TH LPD 8 "October 23, 1996" .UC 5 .ad .SH NAME lpd \- line printer daemon .SH SYNOPSIS .B /usr/sbin/lpd [ .B \-l ] [ port # ] .SH DESCRIPTION .I Lpd is the line printer daemon (spool area handler) and is normally invoked at boot time from the .IR rc (8) file. It makes a single pass through the .IR printcap (5) file to find out about the existing printers and prints any files left after a crash. It then uses the system calls .IR listen (2) and .IR accept (2) to receive requests to print files in the queue, transfer files to the spooling area, display the queue, or remove jobs from the queue. In each case, it forks a child to handle the request so the parent can continue to listen for more requests. The Internet port number used to rendezvous with other processes is normally obtained with .IR getservbyname (3) but can be changed with the .IR port # argument. The .B \-l flag causes .I lpd to log valid requests received from the network. This can be useful for debugging purposes. .PP Access control is provided by two means. First, All requests must come from one of the machines listed in the file .I /etc/hosts.equiv or .IR /etc/hosts.lpd . Second, if the ``rs'' capability is specified in the .I printcap entry for the printer being accessed, .I lpr requests will only be honored for those users with accounts on the machine with the printer. .PP The file .I minfree in each spool directory contains the number of disk blocks to leave free so that the line printer queue won't completely fill the disk. The .I minfree file can be edited with your favorite text editor. .PP The file .I lock in each spool directory is used to prevent multiple daemons from becoming active simultaneously, and to store information about the daemon process for .IR lpr (1), .IR lpq (1), and .IR lprm (1). After the daemon has successfully set the lock, it scans the directory for files beginning with .IR cf . Lines in each .I cf file specify files to be printed or non-printing actions to be performed. Each such line begins with a key character to specify what to do with the remainder of the line. .in +3 .IP J Job Name. String to be used for the job name on the burst page. .IP C Classification. String to be used for the classification line on the burst page. .IP L Literal. The line contains identification info from the password file and causes the banner page to be printed. .IP T Title. String to be used as the title for .IR pr (1). .IP H Host Name. Name of the machine where .I lpr was invoked. .IP P Person. Login name of the person who invoked .IR lpr . This is used to verify ownership by .IR lprm . .IP M Send mail to the specified user when the current print job completes. .IP f Formatted File. Name of a file to print which is already formatted. .IP l Like ``f'' but passes control characters and does not make page breaks. .IP p Name of a file to print using .IR pr (1) as a filter. .IP t Troff File. The file contains .IR troff (1) output (cat phototypesetter commands). .IP n Ditroff File. The file contains device independent troff output. .IP d DVI File. The file contains .IR Tex (l) output (DVI format from Standford). .IP g Graph File. The file contains data produced by .IR plot (3X). .IP c Cifplot File. The file contains data produced by .IR cifplot . .IP v The file contains a raster image. .IP r The file contains text data with FORTRAN carriage control characters. .IP 1 Troff Font R. Name of the font file to use instead of the default. .IP 2 Troff Font I. Name of the font file to use instead of the default. .IP 3 Troff Font B. Name of the font file to use instead of the default. .IP 4 Troff Font S. Name of the font file to use instead of the default. .IP W Width. Changes the page width (in characters) used by .IR pr (1) and the text filters. .IP I Indent. The number of characters to indent the output by (in ascii). .IP U Unlink. Name of file to remove upon completion of printing. .IP N File name. The name of the file which is being printed, or a blank for the standard input (when .I lpr is invoked in a pipeline). .in -5 .PP If a file can not be opened, a message will be logged via .IR syslog (3) using the .I LOG_LPR facility. .I Lpd will try up to 20 times to reopen a file it expects to be there, after which it will skip the file to be printed. .PP .I Lpd uses .IR flock (2) to provide exclusive access to the lock file and to prevent multiple deamons from becoming active simultaneously. If the daemon should be killed or die unexpectedly, the lock file need not be removed. The lock file is kept in a readable ASCII form and contains two lines. The first is the process id of the daemon and the second is the control file name of the current job being printed. The second line is updated to reflect the current status of .I lpd for the programs .IR lpq (1) and .IR lprm (1). .SH FILES .nf .ta \w'/etc/printcap 'u /etc/printcap printer description file /usr/spool/* spool directories /usr/spool/*/minfree minimum free space to leave /dev/lp* line printer devices /dev/printer socket for local requests /etc/hosts.equiv lists machine names allowed printer access /etc/hosts.lpd lists machine names allowed printer access, but not under same administrative control. .fi .SH "SEE ALSO" lpc(8), pac(1), lpr(1), lpq(1), lprm(1), syslog(3), printcap(5) .br .ul 4.2BSD Line Printer Spooler Manual ================================================ FILE: share/man/man8/makedev.8 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)makedev.8 6.2 (Berkeley) 5/19/86 .\" .TH MAKEDEV 8 "May 19, 1986" .UC 5 .SH NAME makedev \- make system special files .SH SYNOPSIS .B /dev/MAKEDEV .IR device ... .SH DESCRIPTION .I MAKEDEV is a shell script normally used to install special files. It resides in the .I /dev directory, as this is the normal location of special files. Arguments to .I MAKEDEV are usually of the form .IR device-name ? where .I device-name is one of the supported devices listed in section 4 of the manual and ``?'' is a logical unit number (0-9). A few special arguments create assorted collections of devices and are listed below. .TP .B std Create the .I standard devices for the system; e.g. /dev/console, /dev/tty. The VAX-11/780 console floppy device, /dev/floppy, and VAX-11/750 and VAX-11/730 console cassette device(s), /dev/tu?, are also created with this entry. .TP .B local Create those devices specific to the local site. This request causes the shell file .I /dev/MAKEDEV.local to be executed. Site specific commands, such as those used to setup dialup lines as ``ttyd?'' should be included in this file. .PP Since all devices are created using .IR mknod (8), this shell script is useful only to the super-user. .SH DIAGNOSTICS Either self-explanatory, or generated by one of the programs called from the script. Use ``sh -x MAKEDEV'' in case of trouble. .SH "SEE ALSO" intro(4), config(8), mknod(8) ================================================ FILE: share/man/man8/makekey.8 ================================================ .\" @(#)makekey.8 6.1.1 (2.11BSD) 1996/10/23 .\" .TH MAKEKEY 8 "October 23, 1996" .AT 3 .SH NAME makekey \- generate encryption key .SH SYNOPSIS .B /usr/sbin/makekey .SH DESCRIPTION .I Makekey improves the usefulness of encryption schemes depending on a key by increasing the amount of time required to search the key space. It reads 10 bytes from its standard input, and writes 13 bytes on its standard output. The output depends on the input in a way intended to be difficult to compute (that is, to require a substantial fraction of a second). .PP The first eight input bytes (the .IR "input key" ) can be arbitrary ASCII characters. The last two (the .IR salt ) are best chosen from the set of digits, upper- and lower-case letters, and `.' and `/'. The salt characters are repeated as the first two characters of the output. The remaining 11 output characters are chosen from the same set as the salt and constitute the .I "output key." .PP The transformation performed is essentially the following: the salt is used to select one of 4096 cryptographic machines all based on the National Bureau of Standards DES algorithm, but modified in 4096 different ways. Using the input key as key, a constant string is fed into the machine and recirculated a number of times. The 64 bits that come out are distributed into the 66 useful key bits in the result. .PP .I Makekey is intended for programs that perform encryption (for instance, .I ed and .IR crypt (1)). Usually makekey's input and output will be pipes. .SH SEE ALSO crypt(1), ed(1) ================================================ FILE: share/man/man8/named.8 ================================================ .\" Copyright (c) 1985 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)named.8 6.5 (Berkeley) 2/28/88 .\" .TH NAMED 8 "February 28, 1988" .UC 4 .SH NAME named \- Internet domain name server .SH SYNOPSIS .B named [ .B \-d .I debuglevel ] [ .B \-p .I port# ] [{\-b} .I bootfile ] .SH DESCRIPTION .I Named is the Internet domain name server. See RFC883 for more information on the Internet name-domain system. Without any arguments, .I named will read the default boot file .IR /etc/named.boot , read any initial data and listen for queries. .PP Options are: .TP .B \-d Print debugging information. A number after the ``d'' determines the level of messages printed. .TP .B \-p Use a different port number. The default is the standard port number as listed in /etc/services. .TP .B \-b Use an alternate boot file. This is optional and allows you to specify a file with a leading dash. .PP Any additional argument is taken as the name of the boot file. The boot file contains information about where the name server is to get its initial data. If multiple boot files are specified, only the last is used. Lines in the boot file cannot be continued on subsequent lines. The following is a small example: .in +2m .nf ; ; boot file for name server ; directory /usr/local/domain .ta \w'forwarders\ 'u +\w'6.32.128.IN-ADDR.ARPA\ 'u +\w'128.32.137.8 128.32.137.3\ 'u ; type domain source host/file backup file cache . root.cache primary Berkeley.EDU berkeley.edu.zone primary 32.128.IN-ADDR.ARPA ucbhosts.rev secondary CC.Berkeley.EDU 128.32.137.8 128.32.137.3 cc.zone.bak secondary 6.32.128.IN-ADDR.ARPA 128.32.137.8 128.32.137.3 cc.rev.bak primary 0.0.127.IN-ADDR.ARPA localhost.rev forwarders 10.0.0.78 10.2.0.78 ; slave .DT .fi .in The ``directory'' line causes the server to change its working directory to the directory specified. This can be important for the correct processing of $INCLUDE files in primary zone files. .LP The ``cache'' line specifies that data in ``root.cache'' is to be placed in the backup cache. Its main use is to specify data such as locations of root domain servers. This cache is not used during normal operation, but is used as ``hints'' to find the current root servers. The file ``root.cache'' is in the same format as ``berkeley.edu.zone''. There can be more than one ``cache'' file specified. .\"The first such file will be updated under certain conditions to snapshot the .\"cache (see SIGQUIT below). .\"The cache line can also have an optional interval argument after .\"the filename. .\"If an interval is listed, .\"it requests the nameserver to dump the cache contents .\"at that interval (in seconds). .\"The example above requests the nameserver to dump the cache content .\"every 3600 seconds (once an hour). .\"The use of automatic cache file updates is not currently recommended .\"because of the way the cache is currently managed by the server; .\"although the entire cache will be dumped for later reloading, .\"most of the cache contents will be ignored when reloaded. .\"The exact dump interval will vary .\"based on the minimum maintence interval time which is typically about .\"5 minutes. The cache files are processed in such a way as to preserve the time-to-live's of data dumped out. Data for the root nameservers is kept artificially valid if necessary. .LP The first ``primary'' line states that the file ``berkeley.edu.zone'' contains authoritative data for the ``Berkeley.EDU'' zone. The file ``berkeley.edu.zone'' contains data in the master file format described in RFC883. All domain names are relative to the origin, in this case, ``Berkeley.EDU'' (see below for a more detailed description). The second ``primary'' line states that the file ``ucbhosts.rev'' contains authoritative data for the domain ``32.128.IN-ADDR.ARPA,'' which is used to translate addresses in network 128.32 to hostnames. Each master file should begin with an SOA record for the zone (see below). .LP The first ``secondary'' line specifies that all authoritative data under ``CC.Berkeley.EDU'' is to be transferred from the name server at 128.32.137.8. If the transfer fails it will try 128.32.137.3 and continue trying the addresses, up to 10, listed on this line. The secondary copy is also authoritative for the specified domain. The first non-dotted-quad address on this line will be taken as a filename in which to backup the transfered zone. The name server will load the zone from this backup file if it exists when it boots, providing a complete copy even if the master servers are unreachable. Whenever a new copy of the domain is received by automatic zone transfer from one of the master servers, this file will be updated. The second ``secondary'' line states that the address-to-hostname mapping for the subnet 128.32.136 should be obtained from the same list of master servers as the previous zone. .LP The ``forwarders'' line specifies the addresses of sitewide servers that will accept recursive queries from other servers. If the boot file specifies one or more forwarders, then the server will send all queries for data not in the cache to the forwarders first. Each forwarder will be asked in turn until an answer is returned or the list is exhausted. If no answer is forthcoming from a forwarder, the server will continue as it would have without the forwarders line unless it is in ``slave'' mode. The forwarding facility is useful to cause a large sitewide cache to be generated on a master, and to reduce traffic over links to outside servers. It can also be used to allow servers to run that do not have access directly to the Internet, but wish to act as though they do. .LP The ``slave'' line (shown commented out) is used to put the server in slave mode. In this mode, the server will only make queries to forwarders. This option is normally used on machine that wish to run a server but for physical or administrative reasons cannot be given access to the Internet, but have access to a host that does have access. .LP The ``sortlist'' line can be used to indicate networks that are to be preferred over other, unlisted networks. Queries for host addresses from hosts on the same network as the server will receive responses with local network addresses listed first, then addresses on the sort list, then other addresses. This line is only acted on at initial startup. When reloading the nameserver with a SIGHUP, this line will be ignored. .PP The master file consists of control information and a list of resource records for objects in the zone of the forms: .RS .nf $INCLUDE $ORIGIN .fi .RE where .I domain is "." for root, "@" for the current origin, or a standard domain name. If .I domain is a standard domain name that does not end with ``.'', the current origin is appended to the domain. Domain names ending with ``.'' are unmodified. The .I opt_domain field is used to define an origin for the data in an included file. It is equivalent to placing a $ORIGIN statement before the first line of the included file. The field is optional. Neither the .I opt_domain field nor $ORIGIN statements in the included file modify the current origin for this file. The .I opt_ttl field is an optional integer number for the time-to-live field. It defaults to zero, meaning the minimum value specified in the SOA record for the zone. The .I opt_class field is the object address type; currently only one type is supported, .BR IN , for objects connected to the DARPA Internet. The .I type field contains one of the following tokens; the data expected in the .I resource_record_data field is in parentheses. .TP "\w'MINFO 'u" A a host address (dotted quad) .IP NS an authoritative name server (domain) .IP MX a mail exchanger (domain) .IP CNAME the canonical name for an alias (domain) .IP SOA marks the start of a zone of authority (domain of originating host, domain address of maintainer, a serial number and the following parameters in seconds: refresh, retry, expire and minimum TTL (see RFC883)) .IP MB a mailbox domain name (domain) .IP MG a mail group member (domain) .IP MR a mail rename domain name (domain) .IP NULL a null resource record (no format or data) .IP WKS a well know service description (not implemented yet) .IP PTR a domain name pointer (domain) .IP HINFO host information (cpu_type OS_type) .IP MINFO mailbox or mail list information (request_domain error_domain) .PP Resource records normally end at the end of a line, but may be continued across lines between opening and closing parentheses. Comments are introduced by semicolons and continue to the end of the line. .PP Each master zone file should begin with an SOA record for the zone. An example SOA record is as follows: .LP .nf @ IN SOA ucbvax.Berkeley.EDU. rwh.ucbvax.Berkeley.EDU. ( 2.89 ; serial 10800 ; refresh 3600 ; retry 3600000 ; expire 86400 ) ; minimum .fi .LP The SOA lists a serial number, which should be changed each time the master file is changed. Secondary servers check the serial number at intervals specified by the refresh time in seconds; if the serial number changes, a zone transfer will be done to load the new data. If a master server cannot be contacted when a refresh is due, the retry time specifies the interval at which refreshes should be attempted until successful. If a master server cannot be contacted within the interval given by the expire time, all data from the zone is discarded by secondary servers. The minimum value is the time-to-live used by records in the file with no explicit time-to-live value. .SH NOTES The boot file directives ``domain'' and ``suffixes'' have been obsoleted by a more useful resolver based implementation of suffixing for partially qualified domain names. The prior mechanisms could fail under a number of situations, especially when then local nameserver did not have complete information. .sp The following signals have the specified effect when sent to the server process using the .IR kill (1) command. .IP SIGHUP Causes server to read named.boot and reload database. .IP SIGINT Dumps current data base and cache to /usr/tmp/named_dump.db .\".IP SIGQUIT .\"Causes the server to checkpoint the cache into the first ``cache'' file. .IP SIGIOT Dumps statistics data into /usr/tmp/named.stats if the server is compiled -DSTATS. Statistics data is appended to the file. .IP SIGSYS Dumps the profiling data in /usr/tmp if the server is compiled with profiling (server forks, chdirs and exits). .IP SIGTERM Dumps the primary and secondary database files. Used to save modified data on shutdown if the server is compiled with dynamic updating enabled. .IP SIGUSR1 Turns on debugging; each SIGUSR1 increments debug level. (SIGEMT on older systems without SIGUSR1) .IP SIGUSR2 Turns off debugging completely. (SIGFPE on older systems without SIGUSR2) .SH FILES .nf .ta \w'/usr/tmp/named_dump.db 'u /etc/named.boot name server configuration boot file /var/run/named.pid the process id /usr/tmp/named.run debug output /usr/tmp/named_dump.db dump of the name server database /usr/tmp/named.stats nameserver statistics data .fi .SH "SEE ALSO" kill(1), gethostbyname(3), signal(3), resolver(3), resolver(5), hostname(7), RFC882, RFC883, RFC973, RFC974, \fIName Server Operations Guide for BIND\fR ================================================ FILE: share/man/man8/pac.8 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)pac.8 6.2.1 (2.11BSD) 1996/11/1 .\" .TH PAC 8 "November 1, 1996" .UC 5 .SH NAME pac \- printer/plotter accounting information .SH SYNOPSIS .B /usr/sbin/pac [ .B \-Pprinter ] [ .B \-pprice ] [ .B \-s ] [ .B \-r ] [ .B \-c ] [ .B \-m ] [ name ... ] .SH DESCRIPTION .I Pac reads the printer/plotter accounting files, accumulating the number of pages (the usual case) or feet (for raster devices) of paper consumed by each user, and printing out how much each user consumed in pages or feet and dollars. If any .I names are specified, then statistics are only printed for those users; usually, statistics are printed for every user who has used any paper. .PP The .B \-P flag causes accounting to be done for the named printer. Normally, accounting is done for the default printer (site dependent) or the value of the environment variable .B PRINTER is used. .PP The .B \-p flag causes the value .I price to be used for the cost in dollars instead of the default value of 0.02 or the price specified in .IR /etc/printcap. .PP The .B \-c flag causes the output to be sorted by cost; usually the output is sorted alphabetically by name. .PP The .B \-r flag reverses the sorting order. .PP The .B \-s flag causes the accounting information to be summarized on the summary accounting file; this summarization is necessary since on a busy system, the accounting file can grow by several lines per day. .PP The .B \-m flag causes the host name to be ignored in the accounting file. This allows for a user on multiple machines to have all of his printing charges grouped together. .SH FILES .ta 2i /usr/adm/?acct raw accounting files .br /usr/adm/?_sum summary accounting files .br /etc/printcap printer capability data base .SH SEE ALSO printcap(5) .SH BUGS The relationship between the computed price and reality is as yet unknown. ================================================ FILE: share/man/man8/rc.8 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)rc.8 6.1 (Berkeley) 4/27/85 .\" .TH RC 8 "April 27, 1985" .UC 4 .SH NAME rc \- command script for auto-reboot and daemons .SH SYNOPSIS .B /etc/rc .br .B /etc/rc.local .SH DESCRIPTION .I Rc is the command script which controls the automatic reboot and .I rc.local is the script holding commands which are pertinent only to a specific site. .PP When an automatic reboot is in progress, .I rc is invoked with the argument .I autoboot and runs a .I fsck with option .B \-p to ``preen'' all the disks of minor inconsistencies resulting from the last system shutdown and to check for serious inconsistencies caused by hardware or software failure. If this auto-check and repair succeeds, then the second part of .I rc is run. .PP The second part of .I rc, which is run after a auto-reboot succeeds and also if .I rc is invoked when a single user shell terminates (see .IR init (8)), starts all the daemons on the system, preserves editor files and clears the scratch directory .B /tmp. .I Rc.local is executed immediately before any other commands after a successful .IR fsck . Normally, the first commands placed in the .I rc.local file define the machine's name, using .IR hostname (1), and save any possible core image that might have been generated as a result of a system crash, .IR savecore (8). The latter command is included in the .I rc.local file because the directory in which core dumps are saved is usually site specific. .SH SEE ALSO init(8), reboot(8), savecore(8) .SH BUGS ================================================ FILE: share/man/man8/rdump.8 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)rdump.8 6.1.1 (2.11BSD) 1996/11/17 .\" .TH RDUMP 8 "November 17, 1996" .UC 5 .SH NAME rdump \- file system dump across the network .SH SYNOPSIS .B rdump [ key [ .I argument \&... ] filesystem ] .SH DESCRIPTION .I Rdump copies to magnetic tape all files changed after a certain date in the .I filesystem. The command is identical in operation to .IR dump (8) except the .I f key should be specified and the file supplied should be of the form .IR machine:device . .PP .I Rdump creates a remote server, .IR /usr/sbin/rmt , on the client machine to access the tape device. .SH "SEE ALSO" dump(8), rmt(8) .SH DIAGNOSTICS Same as .IR dump (8) with a few extra related to the network. ================================================ FILE: share/man/man8/routed.8 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)routed.8 6.2.1 (2.11BSD) 1996/11/17 .\" .TH ROUTED 8 "November 17, 1996" .UC 5 .SH NAME routed \- network routing daemon .SH SYNOPSIS .B routed [ .B \-d ] [ .B \-g ] [ .B \-s ] [ .B \-q ] [ .B \-t ] [ .I logfile ] .SH DESCRIPTION .I Routed is invoked at boot time to manage the network routing tables. The routing daemon uses a variant of the Xerox NS Routing Information Protocol in maintaining up to date kernel routing table entries. It used a generalized protocol capable of use with multiple address types, but is currently used only for Internet routing within a cluster of networks. .PP In normal operation .I routed listens on the .IR udp (4) socket for the .I route service (see .IR services (5)) for routing information packets. If the host is an internetwork router, it periodically supplies copies of its routing tables to any directly connected hosts and networks. .PP When .I routed is started, it uses the SIOCGIFCONF .I ioctl to find those directly connected interfaces configured into the system and marked ``up'' (the software loopback interface is ignored). If multiple interfaces are present, it is assumed that the host will forward packets between networks. .I Routed then transmits a .I request packet on each interface (using a broadcast packet if the interface supports it) and enters a loop, listening for .I request and .I response packets from other hosts. .PP When a .I request packet is received, .I routed formulates a reply based on the information maintained in its internal tables. The .I response packet generated contains a list of known routes, each marked with a ``hop count'' metric (a count of 16, or greater, is considered ``infinite''). The metric associated with each route returned provides a metric .IR "relative to the sender" . .PP .I Response packets received by .I routed are used to update the routing tables if one of the following conditions is satisfied: .TP (1) No routing table entry exists for the destination network or host, and the metric indicates the destination is ``reachable'' (i.e. the hop count is not infinite). .TP (2) The source host of the packet is the same as the router in the existing routing table entry. That is, updated information is being received from the very internetwork router through which packets for the destination are being routed. .TP (3) The existing entry in the routing table has not been updated for some time (defined to be 90 seconds) and the route is at least as cost effective as the current route. .TP (4) The new route describes a shorter route to the destination than the one currently stored in the routing tables; the metric of the new route is compared against the one stored in the table to decide this. .PP When an update is applied, .I routed records the change in its internal tables and updates the kernel routing table. The change is reflected in the next .I response packet sent. .PP In addition to processing incoming packets, .I routed also periodically checks the routing table entries. If an entry has not been updated for 3 minutes, the entry's metric is set to infinity and marked for deletion. Deletions are delayed an additional 60 seconds to insure the invalidation is propagated throughout the local internet. .PP Hosts acting as internetwork routers gratuitously supply their routing tables every 30 seconds to all directly connected hosts and networks. The response is sent to the broadcast address on nets capable of that function, to the destination address on point-to-point links, and to the router's own address on other networks. The normal routing tables are bypassed when sending gratuitous responses. The reception of responses on each network is used to determine that the network and interface are functioning correctly. If no response is received on an interface, another route may be chosen to route around the interface, or the route may be dropped if no alternative is available. .PP .I Routed supports several options: .TP .B \-d Enable additional debugging information to be logged, such as bad packets received. .TP .B \-g This flag is used on internetwork routers to offer a route to the ``default'' destination. This is typically used on a gateway to the Internet, or on a gateway that uses another routing protocol whose routes are not reported to other local routers. .TP .B \-s Supplying this option forces .I routed to supply routing information whether it is acting as an internetwork router or not. This is the default if multiple network interfaces are present, or if a point-to-point link is in use. .TP .B \-q This is the opposite of the .B \-s option. .TP .B \-t If the .B \-t option is specified, all packets sent or received are printed on the standard output. In addition, .I routed will not divorce itself from the controlling terminal so that interrupts from the keyboard will kill the process. .PP Any other argument supplied is interpreted as the name of file in which .IR routed 's actions should be logged. This log contains information about any changes to the routing tables and, if not tracing all packets, a history of recent messages sent and received which are related to the changed route. .PP In addition to the facilities described above, .I routed supports the notion of ``distant'' .I passive and .I active gateways. When .I routed is started up, it reads the file .I /etc/gateways to find gateways which may not be located using only information from the SIOGIFCONF .IR ioctl . Gateways specified in this manner should be marked passive if they are not expected to exchange routing information, while gateways marked active should be willing to exchange routing information (i.e. they should have a .I routed process running on the machine). Passive gateways are maintained in the routing tables forever and information regarding their existence is included in any routing information transmitted. Active gateways are treated equally to network interfaces. Routing information is distributed to the gateway and if no routing information is received for a period of the time, the associated route is deleted. External gateways are also passive, but are not placed in the kernel routing table nor are they included in routing updates. The function of external entries is to inform .I routed that another routing process will install such a route, and that alternate routes to that destination should not be installed. Such entries are only required when both routers may learn of routes to the same destination. .PP The .I /etc/gateways is comprised of a series of lines, each in the following format: .PP .nf < \fBnet\fP | \fBhost\fP > \fIname1\fP \fBgateway\fP \fIname2\fP \fBmetric\fP \fIvalue\fP < \fBpassive\fP | \fBactive\fP | \fBexternal\fP > .fi .PP The .B net or .B host keyword indicates if the route is to a network or specific host. .PP .I Name1 is the name of the destination network or host. This may be a symbolic name located in .I /etc/networks or .I /etc/hosts (or, if started after .IR named (8), known to the name server), or an Internet address specified in ``dot'' notation; see .IR inet (3). .PP .I Name2 is the name or address of the gateway to which messages should be forwarded. .PP .I Value is a metric indicating the hop count to the destination host or network. .PP One of the keywords .BR passive , .B active or .B external indicates if the gateway should be treated as .I passive or .I active (as described above), or whether the gateway is external to the scope of the .I routed protocol. .PP Internetwork routers that are directly attached to the Arpanet or Milnet should use the Exterior Gateway Protocol (EGP) to gather routing information rather then using a static routing table of passive gateways. EGP is required in order to provide routes for local networks to the rest of the Internet system. Sites needing assistance with such configurations should contact the Computer Systems Research Group at Berkeley. .SH FILES .DT /etc/gateways for distant gateways .SH "SEE ALSO" ``Internet Transport Protocols'', XSIS 028112, Xerox System Integration Standard. .br udp(4), XNSrouted(8), htable(8) .SH BUGS The kernel's routing tables may not correspond to those of .I routed when redirects change or add routes. The only remedy for this is to place the routing process in the kernel. .PP .I Routed should incorporate other routing protocols, such as Xerox NS .RI ( XNSrouted (8)) and EGP. Using separate processes for each requires configuration options to avoid redundant or competing routes. .PP .I Routed should listen to intelligent interfaces, such as an IMP, and to error protocols, such as ICMP, to gather more information. It does not always detect unidirectional failures in network interfaces (e.g., when the output side fails). ================================================ FILE: share/man/man8/rrestore.8 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)rrestore.8 6.2.1 (2.11BSD) 1996/11/17 .\" .TH RRESTORE 8 "November 17, 1996" .UC 5 .SH NAME rrestore \- restore a file system dump across the network .SH SYNOPSIS .B rrestore [ key [ name ... ] .SH DESCRIPTION .I Rrestore obtains from magnetic tape files saved by a previous .IR dump (8). The command is identical in operation to .IR restore (8) except the .I f key should be specified and the file supplied should be of the form .IR machine:device . .PP .I Rrestore creates a remote server, .IR rmt , on the client machine to access the tape device. .SH "SEE ALSO" restore(8), rmt(8) .SH DIAGNOSTICS Same as .IR restore (8) with a few extra related to the network. ================================================ FILE: share/man/man8/sendmail.8 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)sendmail.8 6.2.1 (2.11BSD) 1996/10/23 .\" .TH SENDMAIL 8 "October 23, 1996" .UC 4 .SH NAME sendmail \- send mail over the internet .SH SYNOPSIS .B /usr/sbin/sendmail [ flags ] [ address ... ] .PP .B newaliases .PP .B mailq [ .B \-v ] .SH DESCRIPTION .I Sendmail sends a message to one or more .IR recipients , routing the message over whatever networks are necessary. .I Sendmail does internetwork forwarding as necessary to deliver the message to the correct place. .PP .I Sendmail is not intended as a user interface routine; other programs provide user-friendly front ends; .I sendmail is used only to deliver pre-formatted messages. .PP With no flags, .I sendmail reads its standard input up to an end-of-file or a line consisting only of a single dot and sends a copy of the message found there to all of the addresses listed. It determines the network(s) to use based on the syntax and contents of the addresses. .PP Local addresses are looked up in a file and aliased appropriately. Aliasing can be prevented by preceding the address with a backslash. Normally the sender is not included in any alias expansions, e.g., if `john' sends to `group', and `group' includes `john' in the expansion, then the letter will not be delivered to `john'. .PP Flags are: .TP 1.2i .B \-ba Go into \s-1ARPANET\s0 mode. All input lines must end with a CR-LF, and all messages will be generated with a CR-LF at the end. Also, the ``From:'' and ``Sender:'' fields are examined for the name of the sender. .TP 1.2i .B \-bd Run as a daemon. This requires Berkeley IPC. .I Sendmail will fork and run in background listening on socket 25 for incoming SMTP connections. This is normally run from .IR /etc/rc . .TP 1.2i .B \-bi Initialize the alias database. .TP 1.2i .B \-bm Deliver mail in the usual way (default). .TP 1.2i .B \-bp Print a listing of the queue. .TP 1.2i .B \-bs Use the \s-2SMTP\s0 protocol as described in RFC821 on standard input and output. This flag implies all the operations of the .B \-ba flag that are compatible with \s-2SMTP\s0. .TP 1.2i .B \-bt Run in address test mode. This mode reads addresses and shows the steps in parsing; it is used for debugging configuration tables. .TP 1.2i .B \-bv Verify names only \- do not try to collect or deliver a message. Verify mode is normally used for validating users or mailing lists. .TP 1.2i .B \-bz Create the configuration freeze file. .TP 1.2i .BI \-C file Use alternate configuration file. .I Sendmail refuses to run as root if an alternate configuration file is specified. The frozen configuration file is bypassed. .TP 1.2i .BI \-d X Set debugging value to .I X. .TP 1.2i .BI \-F fullname Set the full name of the sender. .TP 1.2i .BI \-f name Sets the name of the ``from'' person (i.e., the sender of the mail). .B \-f can only be used by ``trusted'' users (normally .I root, .I daemon, and .I network) or if the person you are trying to become is the same as the person you are. .TP 1.2i .BI \-h N Set the hop count to .I N. The hop count is incremented every time the mail is processed. When it reaches a limit, the mail is returned with an error message, the victim of an aliasing loop. If not specified, ``Received:'' lines in the message are counted. .TP 1.2i .B \-n Don't do aliasing. .TP 1.2i .BI \-o x\|value Set option .I x to the specified .I value. Options are described below. .TP 1.2i .BI \-q[ time ] Processed saved messages in the queue at given intervals. If .I time is omitted, process the queue once. .I Time is given as a tagged number, with `s' being seconds, `m' being minutes, `h' being hours, `d' being days, and `w' being weeks. For example, ``\-q1h30m'' or ``\-q90m'' would both set the timeout to one hour thirty minutes. If .I time is specified, .I sendmail will run in background. This option can be used safely with .BR \-bd . .TP 1.2i .BI \-r name An alternate and obsolete form of the .B \-f flag. .TP 1.2i .B \-t Read message for recipients. To:, Cc:, and Bcc: lines will be scanned for recipient addresses. The Bcc: line will be deleted before transmission. Any addresses in the argument list will be suppressed, that is, they will .I not receive copies even if listed in the message header. .TP 1.2i .B \-v Go into verbose mode. Alias expansions will be announced, etc. .PP There are also a number of processing options that may be set. Normally these will only be used by a system administrator. Options may be set either on the command line using the .B \-o flag or in the configuration file. These are described in detail in the .ul Sendmail Installation and Operation Guide. The options are: .TP 1.2i .RI A file Use alternate alias file. .TP 1.2i c On mailers that are considered ``expensive'' to connect to, don't initiate immediate connection. This requires queueing. .TP 1.2i .RI d x Set the delivery mode to .I x. Delivery modes are `i' for interactive (synchronous) delivery, `b' for background (asynchronous) delivery, and `q' for queue only \- i.e., actual delivery is done the next time the queue is run. .TP 1.2i D Try to automatically rebuild the alias database if necessary. .TP 1.2i .RI e x Set error processing to mode .I x. Valid modes are `m' to mail back the error message, `w' to ``write'' back the error message (or mail it back if the sender is not logged in), `p' to print the errors on the terminal (default), `q' to throw away error messages (only exit status is returned), and `e' to do special processing for the BerkNet. If the text of the message is not mailed back by modes `m' or `w' and if the sender is local to this machine, a copy of the message is appended to the file ``dead.letter'' in the sender's home directory. .TP 1.2i .RI F mode The mode to use when creating temporary files. .TP 1.2i f Save UNIX-style From lines at the front of messages. .TP 1.2i .RI g N The default group id to use when calling mailers. .TP 1.2i .RI H file The SMTP help file. .TP 1.2i i Do not take dots on a line by themselves as a message terminator. .TP 1.2i .RI L n The log level. .TP 1.2i m Send to ``me'' (the sender) also if I am in an alias expansion. .TP 1.2i o If set, this message may have old style headers. If not set, this message is guaranteed to have new style headers (i.e., commas instead of spaces between addresses). If set, an adaptive algorithm is used that will correctly determine the header format in most cases. .TP 1.2i .RI Q queuedir Select the directory in which to queue messages. .TP 1.2i .RI r timeout The timeout on reads; if none is set, .I sendmail will wait forever for a mailer. This option violates the word (if not the intent) of the SMTP specification, show the timeout should probably be fairly large. .TP 1.2i .RI S file Save statistics in the named file. .TP 1.2i s Always instantiate the queue file, even under circumstances where it is not strictly necessary. This provides safety against system crashes during delivery. .TP 1.2i .RI T time Set the timeout on undelivered messages in the queue to the specified time. After delivery has failed (e.g., because of a host being down) for this amount of time, failed messages will be returned to the sender. The default is three days. .TP 1.2i .RI t stz,dtz Set the name of the time zone. .TP 1.2i .RI u N Set the default user id for mailers. .PP In aliases, the first character of a name may be a vertical bar to cause interpretation of the rest of the name as a command to pipe the mail to. It may be necessary to quote the name to keep .I sendmail from suppressing the blanks from between arguments. For example, a common alias is: .PP msgs: "|/usr/ucb/msgs -s" .PP Aliases may also have the syntax ``:include:\c .IR filename '' to ask .I sendmail to read the named file for a list of recipients. For example, an alias such as: .PP poets: ":include:/usr/local/lib/poets.list" .PP would read .I /usr/local/lib/poets.list for the list of addresses making up the group. .PP .I Sendmail returns an exit status describing what it did. The codes are defined in .RI < sysexits.h > .ta 3n +\w'EX_UNAVAILABLE'u+3n .de XX .ti \n(.iu .. .in +\w'EX_UNAVAILABLE'u+6n .XX EX_OK Successful completion on all addresses. .XX EX_NOUSER User name not recognized. .XX EX_UNAVAILABLE Catchall meaning necessary resources were not available. .XX EX_SYNTAX Syntax error in address. .XX EX_SOFTWARE Internal software error, including bad arguments. .XX EX_OSERR Temporary operating system error, such as \*(lqcannot fork\*(rq. .XX EX_NOHOST Host name not recognized. .XX EX_TEMPFAIL Message could not be sent immediately, but was queued. .PP If invoked as .I newaliases, .I sendmail will rebuild the alias database. If invoked as .I mailq, .I sendmail will print the contents of the mail queue. .SH FILES Except for /etc/sendmail.cf, these pathnames are all specified in /etc/sendmail.cf. Thus, these values are only approximations. .PP .if t .ta 2i .if n .ta 3i /etc/aliases raw data for alias names .br /etc/aliases.pag .br /etc/aliases.dir data base of alias names .br /etc/sendmail.cf configuration file .br /etc/sendmail.fc frozen configuration .br /usr/share/misc/sendmail.hf help file .br /var/log/sendmail.st collected statistics .br /usr/spool/mqueue/* temp files .SH SEE\ ALSO mail(1), rmail(1), syslog(3), aliases(5), sendmail.cf(5), mailaddr(7), rc(8); .br DARPA Internet Request For Comments RFC819, RFC821, RFC822; .br .ul Sendmail \- An Internetwork Mail Router (SMM:16); .br .ul Sendmail Installation and Operation Guide (SMM:7) ================================================ FILE: share/man/man8/sticky.8 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)sticky.8 6.3 (Berkeley) 5/26/86 .\" .TH STICKY 8 "May 26, 1986" .UC 4 .SH NAME sticky \- persistent text and append-only directories .SH DESCRIPTION The .I "sticky bit" (file mode bit 01000, see .IR chmod (2)) is used to indicate special treatment for certain executable files and directories. .SH "STICKY TEXT EXECUTABLE FILES" While the `sticky bit' is set on a sharable executable file, the text of that file will not be removed from the system swap area. Thus the file does not have to be fetched from the file system upon each execution. Shareable text segments are normally placed in a least-frequently-used cache after use, and thus the `sticky bit' has little effect on commonly-used text images. .PP Sharable executable files are made by the .B \-n and .B \-z options of .IR ld (1). .PP Only the super-user can set the sticky bit on a sharable executable file. .SH "STICKY DIRECTORIES" A directory whose `sticky bit' is set becomes an append-only directory, or, more accurately, a directory in which the deletion of files is restricted. A file in a sticky directory may only be removed or renamed by a user if the user has write permission for the directory and the user is the owner of the file, the owner of the directory, or the super-user. This feature is usefully applied to directories such as /tmp which must be publicly writable but should deny users the license to arbitrarily delete or rename each others' files. .PP Any user may create a sticky directory. See .IR chmod (1) for details about modifying file modes. .SH BUGS Since the text areas of sticky text executables are stashed in the swap area, abuse of the feature can cause a system to run out of swap. .PP Neither .IR open (2) nor .IR mkdir (2) will create a file with the sticky bit set. ================================================ FILE: share/man/man8/sync.8 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)sync.8 6.2.1 (2.11BSD) 1996/11/27 .\" .TH SYNC 8 "November 27, 1996" .UC 4 .SH NAME sync \- update the super block .SH SYNOPSIS .B sync .SH DESCRIPTION .I Sync executes the .I sync system primitive. .I Sync can be called to insure that all disk writes have been completed before the processor is halted in a way not suitably done by .IR reboot (8) or .IR halt (8). Generally, it is preferable to use .I reboot or .I halt to shut down the system, as they may perform additional actions such as resynchronizing the hardware clock and flushing internal caches before performing a final .IR sync . .PP See .IR sync (2) for details on the system primitive. .SH "SEE ALSO" sync(2), fsync(2), halt(8), reboot(8), update(8) ================================================ FILE: share/man/man8/timed.8 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)timed.8 6.1.1 (2.11BSD) 1996/11/17 .\" .TH TIMED 8 "November 17, 1996" .UC 6 .ad .SH NAME timed \- time server daemon .SH SYNOPSIS .B timed [ -t ] [ -M ] [ -n network ] [ -i network ] .SH DESCRIPTION .I Timed is the time server daemon and is normally invoked at boot time from the .IR rc (8) file. It synchronizes the host's time with the time of other machines in a local area network running .IR timed (8). These time servers will slow down the clocks of some machines and speed up the clocks of others to bring them to the average network time. The average network time is computed from measurements of clock differences using the ICMP timestamp request message. .PP The service provided by \fItimed\fP is based on a master-slave scheme. When .IR timed (8) is started on a machine, it asks the master for the network time and sets the host's clock to that time. After that, it accepts synchronization messages periodically sent by the master and calls .IR adjtime (2) to perform the needed corrections on the host's clock. .PP It also communicates with .IR date (1) in order to set the date globally, and with .IR timedc (8), a timed control program. If the machine running the master crashes, then the slaves will elect a new master from among slaves running with the .B \-M flag. A .IR timed running without the .B \-M flag will remain a slave. The .B \-t flag enables \fItimed\fP to trace the messages it receives in the file /usr/adm/timed.log. Tracing can be turned on or off by the program .IR timedc (8). .I Timed normally checks for a master time server on each network to which it is connected, except as modified by the options described below. It will request synchronization service from the first master server located. If permitted by the .B \-M flag, it will provide synchronization service on any attached networks on which no current master server was detected. Such a server propagates the time computed by the top-level master. The .B \-n flag, followed by the name of a network which the host is connected to (see .IR networks (5)), overrides the default choice of the network addresses made by the program. Each time the .B \-n flag appears, that network name is added to a list of valid networks. All other networks are ignored. The .B \-i flag, followed by the name of a network to which the host is connected (see .IR networks (5)), overrides the default choice of the network addresses made by the program. Each time the .B \-i flag appears, that network name is added to a list of networks to ignore. All other networks are used by the time daemon. The .B \-n and .B \-i flags are meaningless if used together. .SH FILES .nf .ta \w'/usr/adm/timed.masterlog 'u /usr/adm/timed.log tracing file for timed /usr/adm/timed.masterlog log file for master timed .fi .SH "SEE ALSO" date(1), adjtime(2), gettimeofday(2), icmp(4P), timedc(8), .br \fITSP: The Time Synchronization Protocol for UNIX 4.3BSD\fP, R. Gusella and S. Zatti ================================================ FILE: share/man/man8/timedc.8 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)timedc.8 6.1.1 (2.11BSD) 1996/11/17 .\" .TH TIMEDC 8 "November 17, 1996" .UC 6 .ad .SH NAME timedc \- timed control program .SH SYNOPSIS .B timedc [ command [ argument ... ] ] .SH DESCRIPTION .I Timedc is used to control the operation of the \fItimed\fP program. It may be used to: .IP \(bu measure the differences between machines' clocks, .IP \(bu find the location where the master time server is running, .IP \(bu enable or disable tracing of messages received by \fItimed\fP, and .IP \(bu perform various debugging actions. .PP Without any arguments, .I timedc will prompt for commands from the standard input. If arguments are supplied, .IR timedc interprets the first argument as a command and the remaining arguments as parameters to the command. The standard input may be redirected causing .I timedc to read commands from a file. Commands may be abbreviated; recognized commands are: .TP ? [ command ... ] .TP help [ command ... ] .br Print a short description of each command specified in the argument list, or, if no arguments are given, a list of the recognized commands. .TP clockdiff host ... .br Compute the differences between the clock of the host machine and the clocks of the machines given as arguments. .TP trace { on | off } .br Enable or disable the tracing of incoming messages to \fItimed\fP in the file /usr/adm/timed.log. .TP quit .br Exit from timedc. .PP Other commands may be included for use in testing and debugging .IR timed ; the help command and the program source may be consulted for details. .SH FILES .nf .ta \w'/usr/adm/masterlog 'u /usr/adm/timed.log tracing file for timed /usr/adm/timed.masterlog log file for master timed .fi .SH "SEE ALSO" date(1), adjtime(2), icmp(4P), timed(8), .br \fITSP: The Time Synchronization Protocol for UNIX 4.3BSD\fP, R. Gusella and S. Zatti .SH DIAGNOSTICS .nf .ta \w'?Ambiguous command 'u ?Ambiguous command abbreviation matches more than one command ?Invalid command no match found ?Privileged command command can be executed by root only .fi ================================================ FILE: share/man/man8/uucico.8 ================================================ .\" @(#)uucico.8 6.3.1 (2.11BSD) 1996/10/23 .\" .TH UUCICO 8 "October 23, 1996" .UC 6 .SH NAME uucico, uucpd \- transfer files queued by uucp or uux .SH SYNOPSIS .B /usr/sbin/uucico [ .BI \-d spooldir ] [ .BI \-g grade ] [ .BI \-r role ] [ .B \-R ] [ .BI \-s system ] [ .BI \-x debug ] [ .B \-L ] [ .BI \-t turnaround ] .PP .B /usr/libexec/uucpd .SH DESCRIPTION .I Uucico performs the actual work involved in transferring files between systems. .IR Uucp (1) and .IR uux (1) merely queue requests for data transfer which .I uucico processes. .PP The following options are available. .TP 8 .BI \-d spooldir Use .I spooldir as the spool directory. The default is /usr/spool/uucp. .TP 8 .BI \-g grade Only send jobs of grade .I grade or higher this transfer. The grade of a job is specified when the job is queued by .I uucp or .IR uux . .TP 8 .BI \-r role .I role is either 1 or 0; it indicates whether .I uucico is to start up in master or slave role, respectively. 1 is used when running .I uucico by hand or from .IR cron (8). 0 is used when another system calls the local system. Slave role is the default. .TP 8 .B \-R Reverse roles. When used with the .B \-r1 option, this tells the remote system to begin sending its jobs first, instead of waiting for the local machine to finish. .TP 8 .BI \-s system Call only system .IR system . If .B \-s is not specified, and \-r1 is specified, .I uucico will attempt to call all systems for which there is work. If .B \-s is specified, a call will be made even if there is no work for that system. This is useful for polling. .TP 8 .BI \-x debug Turn on debugging at level .IR debug . Level 5 is a good start when trying to find out why a call failed. Level 9 is very detailed. Level 99 is absurdly verbose. If .I role is 1 (master), output is normally written to the standard message output .IR stderr . If .I stderr is unavailable, output is written to .RI /usr/spool/uucp/AUDIT/ system. When .I role is 0 (slave), debugging output is always written to the AUDIT file. .TP 8 .B \-L Only call ``local'' sites. A site is considered local if the device-type field in .I L.sys is one of LOCAL, DIR or TCP. .TP 8 .BI \-t turnaround Use .I turnaround as the line turnaround time (in minutes) instead of the default 30. If .I turnaround is missing or 0, line turnaround will be disabled. After .I uucico has been running in slave role for .I turnaround minutes, it will attempt to run in master role by negotiating with the remote machine. In earlier versions of .IR uucico , a transfer of many large files in one direction would hold up mail going in the other direction. With the turnaround code working, the message flow will be more bidirectional in the short term. This option only works with newer .IR uucico 's and is ignored by older ones. .PP If .I uucico receives a .B SIGFPE (see .IR kill (1)), it will toggle the debugging on or off. .PP .I Uucpd is the server for supporting uucp connections over networks. .I Uucpd listens for service requests at the port indicated in the ``uucp'' service specification; see \fIservices\fP\|(5). The server provides login name and password authentication before starting up .I uucico for the rest of the transaction. .PP .I Uucico is commonly used either of two ways: as a daemon run periodically by .IR cron (8) to call out to remote systems, and as a ``shell'' for remote systems who call in. For calling out periodically, a typical line in .I crontab would be: .PP .nf 0 * * * * /usr/sbin/uucico -r1 .fi .PP This will run .I uucico every hour in master role. For each system that has transfer requests queued, .I uucico calls the system, logs in, and executes the transfers. The file .IR L.sys (5) is consulted for information about how to log in, while .IR L-devices (5) specifies available lines and modems for calling. .PP For remote systems to dial in, an entry in the .IR passwd (5) file must be created, with a login ``shell'' of .IR uucico . For example: .PP .nf nuucp:Password:6:1::/usr/spool/uucppublic:/usr/sbin/uucico .fi .PP The UID for UUCP remote logins is not critical, so long as it differs from the UUCP Administrative login. The latter owns the UUCP files, and assigning this UID to a remote login would be an extreme security hazard. .SH FILES .ta \w'/usr/spool/uucp/D.hostnameX/ 'u .nf /etc/uucp/ UUCP internal files /etc/uucp/L-devices Local device descriptions /etc/uucp/L-dialcodes Phone numbers and prefixes /etc/uucp/L.aliases Hostname aliases /etc/uucp/L.cmds Remote command permissions list /etc/uucp/L.sys Host connection specifications /etc/uucp/USERFILE Remote directory tree permissions list .PP /usr/spool/uucp/ Spool directory /usr/spool/uucp/AUDIT/* Debugging audit trails /usr/spool/uucp/C./ Control files directory /usr/spool/uucp/D./ Incoming data file directory /usr/spool/uucp/D.hostname/ Outgoing data file directory /usr/spool/uucp/D.hostnameX/ Outgoing execution file directory /usr/spool/uucp/CORRUPT/ Place for corrupted C. and D. files /usr/spool/uucp/ERRLOG UUCP internal error log /usr/spool/uucp/LOGFILE UUCP system activity log /usr/spool/uucp/LCK/LCK..* Device lock files /usr/spool/uucp/SYSLOG File transfer statistics log /usr/spool/uucp/STST/* System status files /usr/spool/uucp/TM./ File transfer temp directory /usr/spool/uucp/X./ Incoming execution file directory .PP /usr/spool/uucppublic Public access directory .fi .SH SEE ALSO uucp(1), uuq(1), uux(1), L-devices(5), L-dialcodes(5), L.aliases(5), L.cmds(5), L.sys(5), uuclean(8), uupoll(8), uusnap(8), uuxqt(8) .PP D. A. Nowitz and M. E. Lesk, .IR "A Dial-Up Network of UNIX Systems" . .PP D. A. Nowitz, .IR "Uucp Implementation Description" . ================================================ FILE: share/man/man8/uuclean.8 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)uuclean.8 6.3.1 (2.11BSD) 1996/10/23 .\" .TH UUCLEAN 8 "October 23, 1996" .UC 5 .SH NAME uuclean \- uucp spool directory clean-up .SH SYNOPSIS .B /etc/uucp/uuclean [ .B -m ] [ .BI -n time ] [ .BI -p pre ] .SH DESCRIPTION .I Uuclean will scan the spool directory for files with the specified prefix and delete all those which are older than the specified number of hours. .PP The following options are available. .TP 8 .BI \-p pre Scan for files with .I pre as the file prefix. Up to 10 .B \-p arguments may be specified. .TP .BI \-n time Files whose age is more than .I time hours will be deleted if the prefix test is satisfied. (default time is 72 hours) .TP 8 .B \-m Send mail to the owner of the file when it is deleted. .TP .BI \-d subdirectory Only the specified subdirectory will be cleaned. .PP This program will typically be run daily by .IR cron (8). .SH FILES .TP 22 /usr/spool/uucp Spool directory .SH SEE ALSO uucp(1), uux(1), uucico(8) ================================================ FILE: share/man/man8/uupoll.8 ================================================ .\" Copyright (c) 1986 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)uupoll.8 6.1.1 (2.11BSD) 1996/10/23 .\" .TH UUPOLL 8 "October 23, 1996" .UC 6 .SH NAME uupoll \- poll a remote \s-1UUCP\s+1 site .SH SYNOPSIS .B uupoll [ .BI \-g grade ] [ .B \-n ] .I system .SH DESCRIPTION .I Uupoll is used to force a poll of a remote system. It queues a null job for the remote system and then invokes .IR uucico (8). .PP The following options are available: .TP 8 .BI \-g grade Only send jobs of grade .I grade or higher on this call. .TP 8 .B \-n Queue the null job, but do not invoke .IR uucico . .PP .I Uupoll is usually run by .IR cron (5) or by a user who wants to hurry a job along. A typical entry in .I crontab could be: .PP .nf 0 0,8,16 * * * /usr/bin/uupoll ihnp4 0 4,12,20 * * * /usr/bin/uupoll ucbvax .fi This will poll .B ihnp4 at midnight, 0800, and 1600, and .B ucbvax at 0400, noon, and 2000. .PP If the local machine is already running .I uucico every hour and has a limited number of outgoing modems, a more elegant approach might be: .PP .nf 0 0,8,16 * * * /usr/bin/uupoll -n ihnp4 0 4,12,20 * * * /usr/bin/uupoll -n ucbvax 5 * * * * /usr/sbin/uucico -r1 .fi This will queue null jobs for the remote sites at the top of hour; they will be processed by .I uucico when it runs five minutes later. .SH FILES .ta \w'/usr/spool/uucp/ 'u .nf /etc/uucp/ UUCP internal files /usr/spool/uucp/ Spool directory .fi .SH SEE ALSO uucp(1), uux(1), uucico(8) ================================================ FILE: share/man/man8/uusnap.8 ================================================ .\" Copyright (c) 1983 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)uusnap.8c 6.2 (Berkeley) 4/24/86 .\" .TH UUSNAP 8C "April 24, 1986" .UC 5 .SH NAME uusnap \- show snapshot of the UUCP system .SH SYNOPSIS .B uusnap .SH DESCRIPTION .I Uusnap displays in tabular format a synopsis of the current UUCP situation. The format of each line is as follows: .PP .ti +10 site N Cmds N Data N Xqts Message .PP Where "site" is the name of the site with work, "N" is a count of each of the three possible types of work (command, data, or remote execute), and "Message" is the current status message for that site as found in the STST file. .PP Included in "Message" may be the time left before UUCP can re-try the call, and the count of the number of times that UUCP has tried (unsuccessfully) to reach the site. .SH SEE ALSO uucp(1C), uux(1C), uuq(1C), uucico(8C) .br .I "UUCP Implementation Guide" ================================================ FILE: share/man/man8/uuxqt.8 ================================================ .\" Copyright (c) 1980 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)uuxqt.8 6.1.1 (2.11BSD) 1996/10/23 .\" .TH UUXQT 8 "October 23, 1996" .UC 6 .SH NAME uuxqt \- \s-1UUCP\s+1 execution file interpreter .SH SYNOPSIS .B /usr/libexec/uuxqt [ .BI \-x debug ] .SH DESCRIPTION .I Uuxqt interprets .I "execution files" created on a remote system via .IR uux (1) and transferred to the local system via .IR uucico (8). When a user uses .I uux to request remote command execution, it is .I uuxqt that actually executes the command. Normally, .I uuxqt is forked from .I uucico to process queued execution files; for debugging, it may also be run manually by the \s-1UUCP\s+1 administrator. .PP .I Uuxqt runs in its own subdirectory, .IR /usr/spool/uucp/XTMP . It copies intermediate files to this directory when necessary. .SH FILES .ta \w'/usr/spool/uucp/LCK/LCK.XQT 'u .nf /etc/uucp/L.cmds Remote command permissions list /etc/uucp/USERFILE Remote directory tree permissions list /usr/spool/uucp/LOGFILE UUCP system activity log /usr/spool/uucp/LCK/LCK.XQT \fIUuxqt\fP lock file /usr/spool/uucp/X./ Incoming execution file directory /usr/spool/uucp/XTMP \fIUuxqt\fP running directory .fi .SH SEE ALSO uucp(1), uux(1), L.cmds(5), USERFILE(5), uucico(8) ================================================ FILE: share/man/man9/Makefile ================================================ # # Copyright (c) 1987 Regents of the University of California. # All rights reserved. # # Redistribution and use in source and binary forms are permitted # provided that the above copyright notice and this paragraph are # duplicated in all such forms and that any documentation, # advertising materials, and other materials related to such # distribution and use acknowledge that the software was developed # by the University of California, Berkeley. The name of the # University may not be used to endorse or promote products derived # from this software without specific prior written permission. # THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED # WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. # # @(#)Makefile 5.4.1 (2.11BSD) 1996/01/26 # TOPSRC!=cd ../../..; pwd include ${TOPSRC}/share/mk/sys.mk MDIR= /usr/share/man/cat9 SRCS= intro.9 style.9 OBJS= intro.0 style.0 .SUFFIXES: .9 .0 .9.0: ${MANROFF} $*.9 > $*.0 all: _make_01 _make_01: ${OBJS} clean: FRC rm -f ${OBJS} install: _make_01 cp ${OBJS} ${DESTDIR}${MDIR} FRC: ================================================ FILE: share/man/man9/intro.9 ================================================ .\" $OpenBSD: intro.9,v 1.14 2018/09/30 13:24:33 schwarze Exp $ .\" .\" Copyright (c) 1996 Michael Shalayeff .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .Dd April 22, 2025 .Dt INTRO 9 .Os .Sh NAME .Nm intro .Nd introduction to the kernel internals .Sh DESCRIPTION The manual pages in section 9 contain information related to the internal kernel data structures, variables and functions. .Sh CODE REFERENCES This section describes places within the .Bx Disco source tree where actual code implementing or using kernel internals can be found. All pathnames are relative to .Pa /usr/src . .Sh HISTORY An .Nm manual for section 9 appeared in .Bx Disco 2.5. ================================================ FILE: share/man/man9/style.9 ================================================ .\" Copyright (c) 1995 FreeBSD Inc. .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL [your name] OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" $OpenBSD: style.9,v 1.79 2022/09/11 06:38:11 jmc Exp $ .\" .Dd $Mdocdate: September 11 2022 $ .Dt STYLE 9 .Os .Sh NAME .Nm style .Nd Kernel source file style guide (KNF) .Sh DESCRIPTION This file specifies the preferred style for kernel source files in the .Ox source tree. It is also a guide for preferred userspace code style. These guidelines should be followed for all new code. In general, code can be considered .Dq new code when it makes up about 50% or more of the file(s) involved. This is enough to break precedents in the existing code and use the current style guidelines. .Bd -literal -offset indent /* * Style guide for the OpenBSD KNF (Kernel Normal Form). */ /* * VERY important single-line comments look like this. */ /* Most single-line comments look like this. */ /* * Multi-line comments look like this. Make them real sentences. * Fill them so they look like real paragraphs. */ .Ed .Pp Kernel include files (i.e., .In sys/*.h ) come first; normally, you'll need .In sys/types.h OR .In sys/param.h , but not both! .In sys/types.h includes .In sys/cdefs.h , and it's okay to depend on that. .Bd -literal -offset indent #include /* Non-local includes in brackets. */ .Ed .Pp If it's a network program, put the network include files next. .Bd -literal -offset indent #include #include #include #include .Ed .Pp Then there's a blank line, followed by the .Pa /usr/include files. The .Pa /usr/include files, for the most part, should be sorted. .Pp Global pathnames are defined in .Pa /usr/include/paths.h . Pathnames local to the program go in .Pa pathnames.h in the local directory. .Bd -literal -offset indent #include .Ed .Pp Then there's a blank line, and the user include files. .Bd -literal -offset indent #include "pathnames.h" /* Local includes in double quotes. */ .Ed .Pp All non-static functions are prototyped somewhere. .Pp Function prototypes for private functions (i.e., functions not used elsewhere) go at the top of the first source module. In the kernel, private functions do not require a prototype as long as they are defined before they are used. In userspace, functions local to one source module should be declared .Ql static . This should not be done in the kernel since it makes it impossible to use the kernel debugger. .Pp Functions used from other files are prototyped in the relevant include file. .Pp Functions that are used locally in more than one module go into a separate header file, e.g., .Pa extern.h . .Pp Prototypes should not have variable names associated with the types; i.e., .Bd -literal -offset indent void function(int); .Ed not: .Bd -literal -offset indent -compact void function(int a); .Ed .Pp Prototypes may have an extra space after a tab to enable function names to line up: .Bd -literal -offset indent static char *function(int, const char *); static void usage(void); .Ed .Pp There should be no space between the function name and the argument list. .Pp Use .Li __dead from .In sys/cdefs.h for functions that don't return, i.e., .Bd -literal -offset indent __dead void abort(void); .Ed .Pp In header files, put function prototypes within .Dv __BEGIN_DECLS / __END_DECLS matching pairs. This makes the header file usable from C++. .Pp Macros are capitalized and parenthesized, and should avoid side-effects. If they are an inline expansion of a function, the function is defined all in lowercase; the macro has the same name all in uppercase. If the macro needs more than a single line, use braces. Right-justify the backslashes, as the resulting definition is easier to read. If the macro encapsulates a compound statement, enclose it in a .Dq Li do loop, so that it can safely be used in .Dq Li if statements. Any final statement-terminating semicolon should be supplied by the macro invocation rather than the macro, to make parsing easier for pretty-printers and editors. .Bd -literal -offset indent #define MACRO(x, y) do { \e variable = (x) + (y); \e (y) += 2; \e } while (0) .Ed .Pp If a macro with arguments declares local variables, those variables should use identifiers beginning with two underscores. This is required for macros implementing C and POSIX interfaces and recommended for all macros for consistency. .Pp Enumeration values are all uppercase. .Bd -literal -offset indent enum enumtype { ONE, TWO } et; .Ed .Pp When defining unsigned integers, use .Dq "unsigned int" rather than just .Dq "unsigned" ; the latter has been a source of confusion in the past. .Pp When declaring variables in structures, declare them sorted by use, then by size (largest to smallest), then by alphabetical order. The first category normally doesn't apply, but there are exceptions. Each one gets its own line. Put a tab after the first word, i.e., use .Ql int^Ix; and .Ql struct^Ifoo *x; . .Pp Major structures should be declared at the top of the file in which they are used, or in separate header files if they are used in multiple source files. Use of the structures should be by separate declarations and should be .Dq Li extern if they are declared in a header file. .Bd -literal -offset indent struct foo { struct foo *next; /* List of active foo */ struct mumble amumble; /* Comment for mumble */ int bar; }; struct foo *foohead; /* Head of global foo list */ .Ed .Pp Use .Xr queue 3 macros rather than rolling your own lists, whenever possible. Thus, the previous example would be better written: .Bd -literal -offset indent #include struct foo { LIST_ENTRY(foo) link; /* Queue macro glue for foo lists */ struct mumble amumble; /* Comment for mumble */ int bar; }; LIST_HEAD(, foo) foohead; /* Head of global foo list */ .Ed .Pp Avoid using typedefs for structure types. This makes it impossible for applications to use pointers to such a structure opaquely, which is both possible and beneficial when using an ordinary struct tag. When convention requires a typedef, make its name match the struct tag. Avoid typedefs ending in .Dq Li \&_t , except as specified in Standard C or by POSIX. .Bd -literal -offset indent /* * All major routines should have a comment briefly describing what * they do. The comment before the "main" routine should describe * what the program does. */ int main(int argc, char *argv[]) { int aflag, bflag, ch, num; const char *errstr; .Ed .Pp For consistency, .Xr getopt 3 should be used to parse options. Options should be sorted in the .Xr getopt 3 call and the switch statement, unless parts of the switch cascade. Elements in a switch statement that cascade should have a FALLTHROUGH comment. Numerical arguments should be checked for accuracy. .Bd -literal -offset indent while ((ch = getopt(argc, argv, "abn:")) != -1) { switch (ch) { /* Indent the switch. */ case 'a': /* Don't indent the case. */ aflag = 1; /* FALLTHROUGH */ case 'b': bflag = 1; break; case 'n': num = strtonum(optarg, 0, INT_MAX, &errstr); if (errstr) { warnx("number is %s: %s", errstr, optarg); usage(); } break; default: usage(); } } argc -= optind; argv += optind; .Ed .Pp Use a space after keywords .Pf ( Li if , .Li while , .Li for , .Li return , .Li switch ) . No braces are used for control statements with zero or only a single statement unless that statement is more than a single line, in which case they are permitted. .Bd -literal -offset indent for (p = buf; *p != '\e0'; ++p) continue; for (;;) stmt; for (;;) { z = a + really + long + statement + that + needs + two + lines + gets + indented + four + spaces + on + the + second + and + subsequent + lines; } for (;;) { if (cond) stmt; } .Ed .Pp Parts of a for loop may be left empty. .Bd -literal -offset indent for (; cnt < 15; cnt++) { stmt1; stmt2; } .Ed .Pp Indentation is an 8 character tab. Second level indents are four spaces. All code should fit in 80 columns. .Bd -literal -offset indent while (cnt < 20) z = a + really + long + statement + that + needs + two + lines + gets + indented + four + spaces + on + the + second + and + subsequent + lines; .Ed .Pp Do not add whitespace at the end of a line, and only use tabs followed by spaces to form the indentation. Do not use more spaces than a tab will produce and do not use spaces in front of tabs. .Pp Closing and opening braces go on the same line as the else. Braces that aren't necessary may be left out, unless they cause a compiler warning. .Bd -literal -offset indent if (test) stmt; else if (bar) { stmt; stmt; } else stmt; .Ed .Pp Do not use spaces after function names. Commas have a space after them. Do not use spaces after .Sq \&( or .Sq \&[ or preceding .Sq \&] or .Sq \&) characters. .Bd -literal -offset indent if ((error = function(a1, a2))) exit(error); .Ed .Pp Unary operators don't require spaces; binary operators do. Don't use parentheses unless they're required for precedence, the statement is confusing without them, or the compiler generates a warning without them. Remember that other people may be confused more easily than you. Do YOU understand the following? .Bd -literal -offset indent a = b->c[0] + ~d == (e || f) || g && h ? i : j >> 1; k = !(l & FLAGS); .Ed .Pp Exits should be 0 on success, or non-zero for errors. .Bd -literal -offset indent /* * Avoid obvious comments such as * "Exit 0 on success." */ exit(0); .Ed .Pp The function type should be on a line by itself preceding the function. .Bd -literal -offset indent static char * function(int a1, int a2, float fl, int a4) { .Ed .Pp When declaring variables in functions, declare them sorted by size (largest to smallest), then in alphabetical order; multiple ones per line are okay. If a line overflows, reuse the type keyword. .Pp Be careful not to obfuscate the code by initializing variables in the declarations. Use this feature only thoughtfully. DO NOT use function calls in initializers! .Bd -literal -offset indent struct foo one, *two; double three; int *four, five; char *six, seven, eight, nine, ten, eleven, twelve; four = myfunction(); .Ed .Pp Do not declare functions inside other functions. .Pp Casts and .Fn sizeof calls are not followed by a space. Note that .Xr indent 1 does not understand this rule. .Pp Use of the .Dq register specifier is discouraged in new code. Optimizing compilers such as gcc can generally do a better job of choosing which variables to place in registers to improve code performance. The exception to this is in functions containing assembly code where the .Dq register specifier is required for proper code generation in the absence of compiler optimization. .Pp When using .Fn longjmp or .Fn vfork in a program, the .Fl W or .Fl Wall flag should be used to verify that the compiler does not generate warnings such as .Bd -literal -offset indent warning: variable `foo' might be clobbered by `longjmp' or `vfork'. .Ed .Pp If any warnings of this type occur, you must apply the .Dq volatile type-qualifier to the variable in question. Failure to do so may result in improper code generation when optimization is enabled. Note that for pointers, the location of .Dq volatile specifies if the type-qualifier applies to the pointer, or the thing being pointed to. A volatile pointer is declared with .Dq volatile to the right of the .Dq * . Example: .Bd -literal -offset indent char *volatile foo; .Ed .Pp says that .Dq foo is volatile, but .Dq *foo is not. To make .Dq *foo volatile use the syntax .Bd -literal -offset indent volatile char *foo; .Ed .Pp If both the pointer and the thing pointed to are volatile, use .Bd -literal -offset indent volatile char *volatile foo; .Ed .Pp .Dq const is also a type-qualifier and the same rules apply. The description of a read-only hardware register might look something like: .Bd -literal -offset indent const volatile char *reg; .Ed .Pp Global flags set inside signal handlers should be of type .Dq volatile sig_atomic_t if possible. This guarantees that the variable may be accessed as an atomic entity, even when a signal has been delivered. Global variables of other types (such as structures) are not guaranteed to have consistent values when accessed via a signal handler. .Pp .Dv NULL is the preferred null pointer constant. Use .Dv NULL instead of (type\ *)0 or (type\ *)NULL in all cases except for arguments to variadic functions where the compiler does not know the type. .Pp Don't use .Ql \&! for tests unless it's a boolean, i.e., use .Bd -literal -offset indent if (*p == '\e0') .Ed not .Bd -literal -offset indent -compact if (!*p) .Ed .Pp Routines returning .Vt void * should not have their return values cast to any pointer type. .Pp Use the .Xr err 3 and .Xr warn 3 family of functions. Don't roll your own! .Bd -literal -offset indent if ((four = malloc(sizeof(struct foo))) == NULL) err(1, NULL); if ((six = (int *)overflow()) == NULL) errx(1, "Number overflowed."); return eight; .Ed .Pp Always use ANSI function definitions. Long parameter lists are wrapped with a normal four space indent. .Pp Variable numbers of arguments should look like this: .Bd -literal -offset indent #include void vaf(const char *fmt, ...) { va_list ap; va_start(ap, fmt); STUFF; va_end(ap); /* No return needed for void functions. */ } static void usage(void) { .Ed .Pp Usage statements should take the same form as the synopsis in manual pages. Options without operands come first, in alphabetical order inside a single set of braces, followed by options with operands, in alphabetical order, each in braces, followed by required arguments in the order they are specified, followed by optional arguments in the order they are specified. .Pp A bar .Pq Sq \&| separates either-or options/arguments, and multiple options/arguments which are specified together are placed in a single set of braces. .Pp If numbers are used as options, they should be placed first, as shown in the example below. Uppercase letters take precedence over lowercase. .Bd -literal -offset indent "usage: f [-12aDde] [-b b_arg] [-m m_arg] req1 req2 [opt1 [opt2]]\en" "usage: f [-a | -b] [-c [-de] [-n number]]\en" .Ed .Pp The .Xr getprogname 3 function may be used instead of hard-coding the program name. .Bd -literal -offset indent fprintf(stderr, "usage: %s [-ab]\en", getprogname()); exit(1); .Ed .Pp New core kernel code should be reasonably compliant with the style guides. The guidelines for third-party maintained modules and device drivers are more relaxed but at a minimum should be internally consistent with their style. .Pp Whenever possible, code should be run through a code checker (e.g., .Dq Li gcc -Wall -W -Wpointer-arith -Wbad-function-cast ...\& or splint from the ports tree) and produce minimal warnings. Since lint has been removed, the only lint-style comment that should be used is FALLTHROUGH, as it's useful to humans. Other lint-style comments such as ARGSUSED, LINTED, and NOTREACHED may be deleted. .Pp Note that documentation follows its own style guide, as documented in .Xr mdoc 7 . .Sh FILES .Bl -tag -width "/usr/share/misc/license.template " -compact .It Pa /usr/share/misc/license.template Example license for new code. .El .Sh SEE ALSO .Xr indent 1 , .Xr err 3 , .Xr queue 3 , .Xr warn 3 , .Xr mdoc 7 .Sh HISTORY This man page is largely based on the src/admin/style/style file from the .Bx 4.4 Lite2 release, with updates to reflect the current practice and desire of the .Ox project. ================================================ FILE: share/man/manroff ================================================ #!/bin/sh - # # Copyright (c) 1988 Regents of the University of California. # All rights reserved. # # Redistribution and use in source and binary forms are permitted # provided that the above copyright notice and this paragraph are # duplicated in all such forms and that any documentation, # advertising materials, and other materials related to such # distribution and use acknowledge that the software was developed # by the University of California, Berkeley. The name of the # University may not be used to endorse or promote products derived # from this software without specific prior written permission. # THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED # WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. # # @(#)manroff 5.1 (Berkeley) 7/14/88 # nroff -man -h $* ================================================ FILE: share/misc/Makefile ================================================ # # Public domain - 1996/10/21 - sms # # Makefile for misc data files # TOPSRC!=cd ../..; pwd include ${TOPSRC}/share/mk/sys.mk SRCS = # eign Mail.help Mail.tildehelp units gprof.callg gprof.flat \ # vlpmacs mkproto.data all: ${SRCS} install: ${SRCS} -mkdir -p ${DESTDIR}/usr/share/misc -chmod a+r,a+x ${DESTDIR}/usr/share/misc # ${INSTALL} -c -m 444 ${SRCS} ${DESTDIR}/usr/share/misc clean: rm -f *~ ================================================ FILE: share/mk/sys.mk ================================================ # Override the default port with: # $ make MACHINE=pic32 MACHINE_ARCH=mips # MACHINE= stm32 MACHINE_ARCH= arm unix= We run DiscoBSD. OSMAJOR= 2 OSMINOR= 6 OSREV= ${OSMAJOR}.${OSMINOR} OSRev= ${OSMAJOR}_${OSMINOR} OSrev= ${OSMAJOR}${OSMINOR} DESTDIR?= ${TOPSRC}/distrib/obj/destdir.${MACHINE} RELEASE= ${OSREV} BUILD!= git rev-list HEAD --count VERSION= ${RELEASE}-${BUILD} TOOLDIR?= ${TOPSRC}/tools TOOLBINDIR?= ${TOOLDIR}/bin HOST_CC?= cc _HOST_OSNAME!= uname -s # libbsd-dev package on Linux in overlay mode. _LIBBSD_CFLAGS!=if [ x"${_HOST_OSNAME}" = x"Linux" ] ; then \ pkg-config libbsd-overlay --cflags ; \ else \ echo "" ; \ fi _LIBBSD_LIBS!= if [ x"${_HOST_OSNAME}" = x"Linux" ] ; then \ pkg-config libbsd-overlay --libs ; \ else \ echo "" ; \ fi GCCPREFIX!=if [ x"${MACHINE_ARCH}" = x"arm" ] ; then \ if [ x"${_HOST_OSNAME}" = x"OpenBSD" ] ; then \ echo "/usr/local/bin/arm-none-eabi" ; \ elif [ x"${_HOST_OSNAME}" = x"FreeBSD" ] ; then \ echo "/usr/local/gcc-arm-embedded/bin/arm-none-eabi" ; \ elif [ x"${_HOST_OSNAME}" = x"Linux" ] ; then \ echo "/usr/bin/arm-none-eabi" ; \ else \ echo "/does/not/exist" ; \ fi \ elif [ x"${MACHINE_ARCH}" = x"mips" ] ; then \ if [ x"${_HOST_OSNAME}" = x"OpenBSD" ] ; then \ echo "/usr/local/bin/mips-elf" ; \ elif [ x"${_HOST_OSNAME}" = x"FreeBSD" ] ; then \ echo "/usr/local/mips-elf/bin/mips-elf" ; \ elif [ x"${_HOST_OSNAME}" = x"Linux" ] ; then \ echo "/usr/local/mips-gcc-4.8.1/bin/mips-elf" ; \ else \ echo "/does/not/exist" ; \ fi \ else \ echo "/does/not/exist" ; \ fi CC!= if [ x"${MACHINE_ARCH}" = x"arm" ] ; then \ echo "${GCCPREFIX}-gcc -mcpu=cortex-m4 -mabi=aapcs -mlittle-endian -mthumb -mfloat-abi=soft -nostdinc -I${TOPSRC}/include ${INCLUDES}" ; \ elif [ x"${MACHINE_ARCH}" = x"mips" ] ; then \ echo "${GCCPREFIX}-gcc -mips32r2 -EL -msoft-float -nostdinc -I${TOPSRC}/include ${INCLUDES}" ; \ else \ echo "/does/not/exist" ; \ fi # Enable mips16e instruction set by default COPTS!=if [ x"${MACHINE_ARCH}" = x"arm" ] ; then \ echo "-Os -fcommon" ; \ elif [ x"${MACHINE_ARCH}" = x"mips" ] ; then \ echo "-Os -fcommon -mips16" ; \ else \ echo "" ; \ fi LDWARN!=if [ x"${MACHINE_ARCH}" = x"arm" ] ; then \ if [ x"${_HOST_OSNAME}" = x"FreeBSD" ] ; then \ echo "" ; \ else \ echo "-Wl,--no-warn-rwx-segments" ; \ fi \ else \ echo "-Wl,--no-warn-rwx-segments" ; \ fi CFLAGS= ${COPTS} AFLAGS= ${ASFLAGS} LDFLAGS=-N -nostartfiles -fno-dwarf2-cfi-asm \ ${LDWARN} \ -T${TOPSRC}/lib/elf32-${MACHINE_ARCH}.ld \ ${TOPSRC}/lib/crt0.o -L${TOPSRC}/lib LIBS= -lc LDLIBS= ${LIBS} OBJDUMP!=if [ x"${MACHINE_ARCH}" = x"arm" ] ; then \ echo "${GCCPREFIX}-objdump -marm -M force-thumb" ; \ elif [ x"${MACHINE_ARCH}" = x"mips" ] ; then \ echo "${GCCPREFIX}-objdump -mmips:isa32r2" ; \ else \ echo "/does/not/exist" ; \ fi YACC!= if [ x"${_HOST_OSNAME}" = x"Linux" ] ; then \ echo "byacc" ; \ else \ echo "yacc" ; \ fi YFLAGS= -d LD= ${GCCPREFIX}-ld AR= ${GCCPREFIX}-ar RANLIB= ${GCCPREFIX}-ranlib SIZE= ${GCCPREFIX}-size AS= ${CC} -x assembler-with-cpp -c LEX= flex INSTALL= ${TOOLBINDIR}/binstall -U TAGSFILE= tags #MANROFF= nroff -man -h -Tascii MANROFF= mandoc -Tascii -Ios="DiscoBSD ${OSREV}" ELF2AOUT= ${TOOLBINDIR}/elf2aout AOUT_AOUT= ${TOOLBINDIR}/aout AOUT_AR= ${TOOLBINDIR}/ar AOUT_AS= ${TOOLBINDIR}/as AOUT_LD= ${TOOLBINDIR}/ld AOUT_NM= ${TOOLBINDIR}/nm AOUT_RANLIB= ${TOOLBINDIR}/ranlib AOUT_SIZE= ${TOOLBINDIR}/size AOUT_STRIP= ${TOOLBINDIR}/strip ================================================ FILE: share/zoneinfo/.gitignore ================================================ zdump zic ================================================ FILE: share/zoneinfo/Makefile ================================================ # @(#)Makefile 1.6 Makefile 1997/12/28 TOPSRC!=cd ../..; pwd include ${TOPSRC}/share/mk/sys.mk # If you want something other than Western United States time used on your # system, change the line below (after finding the zone you want in the # time zone files, or adding it to a time zone file). # Alternately, if you discover you've got the wrong time zone, you can just # install -c -m 444 /usr/share/zoneinfo/right_zone /etc/localtime LOCALTIME= Canada/Mountain # If you want code inspired by certain emerging standards, add # -DSTD_INSPIRED # to the end of the "CFLAGS=" line. # # If you want to handle solar-time-based time zones, remove the # "#define NOSOLAR" from the include file usr/include/tzfile.h. # (and add solar87 to the DATA= line below). CFLAGS= -O LINTFLAGS= -phbaxc CC= ${HOST_CC} CFLAGS+= -Wall -idirafter ${TOPSRC}/include # libbsd-dev package on Linux in overlay mode. CFLAGS+= ${_LIBBSD_CFLAGS} LIBS+= ${_LIBBSD_LIBS} TZCSRCS= zic.c scheck.c ialloc.c TZCOBJS= zic.o scheck.o ialloc.o TZDSRCS= zdump.c ialloc.c TZDOBJS= zdump.o ialloc.o SOURCES= zic.c zdump.c scheck.c ialloc.c DATA= asia australasia europe etcetera northamerica \ pacificnew systemv ZICMAN= zic.0 ZICMANSRC= zic.8 ZDUMAN= zdump.0 ZDUMANSRC= zdump.8 MAN= $(ZICMAN) $(ZDUMAN) MANSRC= $(ZICMANSRC) $(ZDUMAN) SHARDIR= ${DESTDIR}/usr/share/zoneinfo MANDIR= ${DESTDIR}/usr/share/man/cat8 all: zdump zic ${ZICMAN} ${ZDUMAN} install: zic $(DATA) $(MAN) (umask 22; ./zic -v -d ${SHARDIR} $(DATA)) # ${INSTALL} -c ${ZICMAN} ${MANDIR}/${ZICMAN} # ${INSTALL} -c ${ZDUMAN} ${MANDIR}/${ZDUMAN} # ${INSTALL} -c -s zic ${DESTDIR}/usr/sbin/zic zdump.0: $(ZDUMANSRC) ${MANROFF} ${ZDUMANSRC} > ${ZDUMAN} zic.0: $(ZICMANSRC) ${MANROFF} ${ZICMANSRC} > ${ZICMAN} zdump: $(TZDOBJS) ${CC} ${CFLAGS} ${LFLAGS} ${TZDOBJS} -o $@ ${LIBS} zic: $(TZCOBJS) ${CC} ${CFLAGS} ${LFLAGS} ${TZCOBJS} -o $@ ${LIBS} lint: $(TZCSRCS) $(TZDSRCS) lint $(LINTFLAGS) $(CFLAGS) $(TZCSRCS) lint $(LINTFLAGS) $(CFLAGS) $(TZDSRCS) clean: rm -f *.o zdump zic $(ZICMAN) $(ZDUMAN) ================================================ FILE: share/zoneinfo/README ================================================ @(#)README 3.2 1996/11/29 Please send comments or information to seismo!elsie!tz for forwarding to folks interested in time zone matters. Be sure to read the comments in "Makefile" and make any changes needed to make things right for your system. This version of the time zone software uses a new format (based on the work of Guy Harris, a.k.a guy@sun.UUCP) for the time zone information files. They are stored in a directory named "/usr/share/zoneinfo". If you've already compiled programs with older time zone software, you may need to make a copy of /usr/share/zoneinfo to the old location. For better compatability with other versions of time conversion functions, the time zone abbreviation to be used with localtime's return value is now pointed to by one of the two elements of the (char *) array tzname, rather than by the (char *) tz_abbr. If you have code that uses tz_abbr, add a -DTZA_COMPAT to the end of the CFLAGS= line in "Makefile". To use the new functions, use a "-lz" option when compiling or linking. Historical local time information has been included here not because it is particularly useful, but rather to: * give an idea of the variety of local time rules that have existed in the past and thus an idea of the variety that may be expected in the future; * provide a test of the generality of the local time rule description system. The information in the time zone data files is by no means authoritative; if you know that the rules are different from those in a file, by all means feel free to change file (and please send the changed version to seismo!elsie!tz for use in the future). Europeans take note! ================================================ FILE: share/zoneinfo/Theory ================================================ @(#)Theory 3.2 1996/11/29 These time and date functions are much like the System V Release 2.0 (SVR2) time and date functions; there are a few additions and changes to extend the usefulness of the SVR2 functions: * In SVR2, time display in a process is controlled by the environment variable TZ, which "must be a three-letter time zone name, followed by a number representing the difference between local time and Greenwich Mean Time in hours, followed by an optional three-letter name for a daylight time zone;" when the optional daylight time zone is present, "standard U.S.A. Daylight Savings Time conversion is applied." This means that SVR2 can't deal with other (for example, Australian) daylight savings time rules, or situations where more than two time zone abbreviations are used in an area. * In SVR2, time conversion information is compiled into each program that does time conversion. This means that when time conversion rules change (as in the United States in 1987), all programs that do time conversion must be recompiled to ensure proper results. * In SVR2, time conversion fails for near-minimum or near-maximum time_t values when doing conversions for places that don't use GMT. * In SVR2, there's no tamper-proof way for a process to learn the system's best idea of local wall clock. (This is important for applications that an administrator wants used only at certain times-- without regard to whether the user has fiddled the "TZ" environment variable. While an administrator can "do everything in GMT" to get around the problem, doing so is inconvenient and precludes handling daylight savings time shifts--as might be required to limit phone calls to off-peak hours.) These are the changes that have been made to the SVR2 functions: * The "TZ" environment variable is used in generating the name of a file from which time zone information is read; "TZ" is no longer constrained to be a three-letter time zone name followed by a number of hours and an optional three-letter daylight time zone name. The daylight saving time rules to be used for a particular time zone are encoded in the time zone file; the format of the file allows U.S., Australian, and other rules to be encoded, and allows for situations where more than two time zone abbreviations are used. It was recognized that allowing the "TZ" environment variable to take on values such as "US/Eastern" might cause "old" programs (that expect "TZ" to have a certain form) to operate incorrectly; consideration was given to using some other environment variable (for example, "TIMEZONE") to hold the string used to generate the time zone information file name. In the end, however, it was decided to continue using "TZ": it is widely used for time zone purposes; separately maintaining both "TZ" and "TIMEZONE" seemed a nuisance; and systems where "new" forms of "TZ" might cause problems can simply give time zone files names such as "EST5EDT" which can be used both by "new" programs (as file names) and "old" programs (as zone names and offsets). * To handle places where more than two time zone abbreviations are used, the functions "localtime" and "gmtime" set tzname[tmp->tm_isdst] (where "tmp" is the value the function returns) to the time zone abbreviation to be used. This differs from SVR2, where the elements of tzname are only changed as a result of calls to tzset. * Since the "TZ" environment variable can now be used to control time conversion, the "daylight" and "timezone" variables are no longer needed or supported. (You can use a compile-time option to cause these variables to be defined and to be set by "tzset"; however, their values will not be used by "localtime.") * The "localtime" function has been set up to deliver correct results for near-minimum or near-maximum time_t values. (A comment in the source code tells how to get compatibly wrong results). * A function "tzsetwall" has been added to arrange for the system's best approximation to local wall clock time to be delivered by subsequent calls to "localtime." Source code for portable applications that "must" run on local wall clock time should call "tzsetwall();" if such code is moved to "old" systems that don't provide tzsetwall, you won't be able to generate an executable program. (These time zone functions also arrange for local wall clock time to be used if tzset is called--directly or indirectly--and there's no "TZ" environment variable; portable applications should not, however, rely on this behavior since it's not the way SVR2 systems behave.) Points of interest to folks with Version 7 or BSD systems: * The BSD "timezone" function is not present in this package; it's impossible to reliably map timezone's arguments (a "minutes west of GMT" value and a "daylight saving time in effect" flag) to a time zone abbreviation, and we refuse to guess. Programs that in the past used the timezone function may now examine tzname[localtime(&clock)->tm_isdst] to learn the correct time zone abbreviation to use. Alternatively, use localtime(&clock)->tm_zone if this has been enabled. * The BSD gettimeofday function is not used in this package; this lets users control the time zone used in doing time conversions. Users who don't try to control things (that is, users who do not set the environment variable TZ) get the time conversion specified in the file "/etc/localtime"; see the time zone compiler writeup for information on how to initialize this file. * The BSD "dysize" function is only included if the preprocessor symbol BSD_COMPAT is defined. For a year y, the BSD code returns the value ((y % 4) == 0) : 366 : 365 while this code returns the value (((y) % 4) == 0 && ((y) % 100) != 0 || ((y) % 400) == 0) ? 366 : 365 There's a comment in the code telling how to get the BSD value. The functions that are conditionally compiled if STD_INSPIRED is defined should, at this point, be looked on primarily as food for thought. They are not in any sense "standard compatible"--some are not, in fact, specified in *any* standard. They do, however, represent responses of various authors to standardization proposals. Other time conversion proposals, in particular the one developed by folks at Hewlett Packard, offer a wider selection of functions that provide capabilities beyond those provided here. The absence of such functions from this package is not meant to discourage the development, standardization, or use of such functions. Rather, their absence reflects the decision to make this package close to SVR2 (with the exceptions outlined above) to ensure its broad acceptability. If more powerful time conversion functions can be standardized, so much the better. It's probably not wise to standardize everything in this package. While the command nroff -man newctime.3 produces a document that describes this package, the command nroff -man -rX3J11 newctime.3 produces a document that describes the "standardizable" parts. ================================================ FILE: share/zoneinfo/asia ================================================ # @(#)asia 3.1 # Incorporates data for Singapore from Robert Elz' asia 1.1 # Zone NAME GMTOFF RULES/SAVE FORMAT [UNTIL] Zone Japan 9:00 - JST Zone Singapore 8:00 - SST ================================================ FILE: share/zoneinfo/australasia ================================================ # @(#)australasia 3.1 # Incorporates updates for Australia from Robert Elz' australia 1.1 # and further updates from the Australian consulate. # Australian Data (for states with DST), standard rules # Includes shift in 1987 to follow Vic/NSW rules for ending DST, # and shift in 1986 to start DST earlier. # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S Rule Oz 1971 1985 - Oct lastSun 2:00 1:00 - Rule Oz 1986 max - Oct Sun<=24 2:00 1:00 - Rule Oz 1972 only - Feb 27 3:00 0 - Rule Oz 1973 1986 - Mar Sun>=1 3:00 0 - Rule Oz 1987 max - Mar Sun<=21 3:00 0 - # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone Australia/Tasmania 10:00 Oz EST Zone Australia/Queensland 10:00 - EST # No DST here Zone Australia/North 9:30 - CST # No DST here Zone Australia/West 8:00 - WST # No DST here Zone Australia/South 9:30 Oz CST # Victoria and New South Wales made the jump to a later ending date for # DST in 1986 rather than 1987. New South Wales also had another variation # in 1983, but the details of that are unknown to the authors at this time. Zone Australia/Victoria 10:00 Oz EST 1985 Oct lastSun 2:00 10:00 1:00 EST 1986 Mar Sun<=21 3:00 10:00 Oz EST Link Australia/Victoria Australia/NSW # New Zealand, from Elz' asia 1.1 # Elz says "no guarantees" # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S Rule NZ 1974 max - Oct lastSun 2:00 1:00 D Rule NZ 1975 max - Mar Sun>=1 3:00 0 S # Zone NAME GMTOFF RULES/SAVE FORMAT [UNTIL] Zone NZ 12:00 NZ NZ%sT # New Zealand # # A footnote here: # # . . . # Date: Thu, j19 Feb 87 12:02:17 EST # From: Bradley White # . . . # I am including a description of Australian time zones. . . # this stuff is definitely accurate. # . . . # a) Australian Eastern Time: (EST = GMT+10:00, EDT = GMT+11:00) # . . . # Summer of 86/87 - present (current legislation): # third Sun Oct 02:00 EST -> third LSun Mar 02:00 EST # # If this turns out to be true, substitute Sun<=21 (third Sunday in October) # for Sun<=24 (next-to-last Sunday in October) above. . .some time before # October 1988, the first time it makes a difference. # ================================================ FILE: share/zoneinfo/etcetera ================================================ # @(#)etcetera 3.1 Zone GMT 0 - GMT # # Names for zones that might exist, just so people can set a timezone # that's right for their area, even if it doesn't have a name or dst rules # (half hour zones are too much to bother with -- when someone asks!) # Zone GMT-12 -12 - GMT-1200 Zone GMT-11 -11 - GMT-1100 Zone GMT-10 -10 - GMT-1000 Zone GMT-9 -9 - GMT-0900 Zone GMT-8 -8 - GMT-0800 Zone GMT-7 -7 - GMT-0700 Zone GMT-6 -6 - GMT-0600 Zone GMT-5 -5 - GMT-0500 Zone GMT-4 -4 - GMT-0400 Zone GMT-3 -3 - GMT-0300 Zone GMT-2 -2 - GMT-0200 Zone GMT-1 -1 - GMT-0100 Zone GMT+1 1 - GMT+0100 Zone GMT+2 2 - GMT+0200 Zone GMT+3 3 - GMT+0300 Zone GMT+4 4 - GMT+0400 Zone GMT+5 5 - GMT+0500 Zone GMT+6 6 - GMT+0600 Zone GMT+7 7 - GMT+0700 Zone GMT+8 8 - GMT+0800 Zone GMT+9 9 - GMT+0900 Zone GMT+10 10 - GMT+1000 Zone GMT+11 11 - GMT+1100 Zone GMT+12 12 - GMT+1200 Zone GMT+13 13 - GMT+1300 # GMT+12 with DST Link GMT UTC Link GMT UCT Link GMT Universal Link GMT Greenwich ================================================ FILE: share/zoneinfo/europe ================================================ # @(#)europe 3.1 # Europe, updated from 4.3BSD and various contributors # International country codes are used to identify countries' rules and # zones # # This data is by no means authoritative; if you think you know better, go # ahead and edit the file (and please send any changes to seismo!elsie!tz # for general use in the future). The use of 1986 as starting years below # is conservative. # # One source shows that Bulgaria, Cyprus, Finland, and Greece observe DST from # the last Sunday in March to the last Sunday in September in 1986. # The source shows Romania changing a day later than everybody else. # # According to Bernard Sieloff's source, Poland is in the MET time zone but # uses the WE DST rules. The Western USSR uses EET+1 and ME DST rules. # Bernard Sieloff's source claims Romania switches on the same day, but at # 00:00 standard time (i.e., 01:00 DST). It also claims that Turkey # switches on the same day, but switches on at 01:00 standard time # and off at 00:00 standard time (i.e., 01:00 DST) # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S Rule EU 1979 1995 - Sep lastSun 1:00s 0 - Rule EU 1981 max - Mar lastSun 1:00s 1:00 "S" Rule EU 1996 max - Oct lastSun 1:00s 0 - Rule C-Eur 1979 1995 - Sep lastSun 2:00s 0 - Rule C-Eur 1981 max - Mar lastSun 2:00s 1:00 "S" Rule C-Eur 1996 max - Oct lastSun 2:00s 0 - Rule Turkey 1986 max - Mar lastSun 1:00 1:00 " DST" Rule Turkey 1986 max - Sep lastSun 1:00 0 - Rule W-SU 1986 max - Mar lastSun 2:00s 1:00 " DST" Rule W-SU 1986 max - Sep lastSun 2:00s 0 - # Zone NAME GMTOFF RULES/SAVE FORMAT [UNTIL] Zone WET 0:00 EU WE%sT Zone CET 1:00 C-Eur CE%sT Zone EET 2:00 EU EE%sT Zone Turkey 3:00 Turkey EE%sT Zone W-SU 3:00 C-Eur ???? # # And now, letters on the subject. . . # ############################################################################### # # ... # Date: Wed, 28 Jan 87 16:56:27 -0100 # From: seismo!mcvax!cgcha!wtho (Tom Hofmann) # Message-Id: <8701281556.AA22174@cgcha.uucp> # ... # Subject: Time zone handling # ... # # ...the European time rules are...standardized since 1981, when # most European counrties started DST. Before that year, only # a few countries (UK, France, Italy) had DST, each according # to own national rules. In 1981, however, DST started on # 'Apr firstSun', and not on 'Mar lastSun' as in the following # years... # But also since 1981 there are some more national exceptions # than listed in 'europe': Switzerland, for example, joined DST # one year later, Denmark ended DST on 'Oct 1' instead of 'Sep # lastSun' in 1981---I don't know how they handle now. # # Finally, DST ist always from 'Apr 1' to 'Oct 1' in the # Soviet Union (as far as I know). # # Tom Hofmann, Scientific Computer Center, CIBA-GEIGY AG, # 4002 Basle, Switzerland # UUCP: ...!mcvax!cernvax!cgcha!wtho # ############################################################################### # # ... # Date: Wed, 4 Feb 87 22:35:22 +0100 # From: seismo!mcvax!cwi.nl!dik (Dik T. Winter) # Message-Id: <8702042135.AA23919@zuring.cwi.nl> # ... # Subject: timezones # ... # # The information from Tom Hofmann is (as far as I know) not entirely correct. # After a request from chongo at amdahl I tried to retrieve all information # about DST in Europe. I was able to find all from about 1969. # # ...standardization # on DST in Europe started in about 1977 with switches on first Sunday in # April and last Sunday in September. In UK it was from last but 1 Sunday # in march to last Sunday in October. In 1981 UK joined Europe insofar that # the starting day for both shifted to last Sunday in March. And from 1982 # the whole of Europe used DST, with switch dates April 1 and October 1 in # the Sovjet Union. In 1985 the SU reverted to standard Europen switch # dates. Note that currently in the UK the switch back date appears not # to be the last Sunday in October, but 4 weeks after the last Sunday in # September (withness 1982 and 1983 with terminating days October 24 and 23). # # It should also be remembered that time-zones are not constants; e.g. # Portugal switched in 1976 from MET (or CET) to WET with DST, and the UK # used MET throughout from 1967 to 1969, and WET with DST before and after # that time. Note also that though there were rules for switch dates not # all countries abided to these dates, and many individual deviations # occurred, though not since 1982 I believe. Another note: it is always # assumed that DST is 1 hour ahead of normal time, this need not be the # case; at least in the Netherlands there have been times when DST was 2 hours # in advance of normal time. # # ... # dik t. winter, cwi, amsterdam, nederland # INTERNET : dik@cwi.nl # BITNET/EARN: dik@mcvax ================================================ FILE: share/zoneinfo/ialloc.c ================================================ /* * @(#)ialloc.c 1.1 ialloc.c 3/4/87 */ #include #include #include #ifndef alloc_t #define alloc_t unsigned #endif /* !alloc_t */ #ifdef MAL #define NULLMAL(x) ((x) == NULL || (x) == MAL) #else /* !MAL */ #define NULLMAL(x) ((x) == NULL) #endif /* !MAL */ char * imalloc(int n) { #ifdef MAL register char * result; if (n == 0) n = 1; result = malloc((alloc_t) n); return (result == MAL) ? NULL : result; #else /* !MAL */ if (n == 0) n = 1; return malloc((alloc_t) n); #endif /* !MAL */ } char * icalloc(int nelem, int elsize) { if (nelem == 0 || elsize == 0) nelem = elsize = 1; return calloc((alloc_t) nelem, (alloc_t) elsize); } char * irealloc(char *pointer, int size) { if (NULLMAL(pointer)) return imalloc(size); if (size == 0) size = 1; return realloc(pointer, (alloc_t) size); } char * icatalloc(char *old, char *new) { register char * result; register int oldsize, newsize; oldsize = NULLMAL(old) ? 0 : strlen(old); newsize = NULLMAL(new) ? 0 : strlen(new); if ((result = irealloc(old, oldsize + newsize + 1)) != NULL) if (!NULLMAL(new)) (void)strlcpy(result + oldsize, new, newsize + 1); return result; } char * icpyalloc(char *string) { return icatalloc((char *) NULL, string); } void ifree(char *p) { if (!NULLMAL(p)) free(p); } ================================================ FILE: share/zoneinfo/northamerica ================================================ # @(#)northamerica 3.1 # Despite the performance of existing (4.[123]BSD, System V Release 2.0) code, # US Daylight Saving Time ended on the last Sunday of *October* in 1974. # See, for example, the front page of the Saturday, October 26, 1974 # and Sunday, October 27, 1974 editions of the Washington Post. # Note also this from seismo!munnari!kre: # "I recall also being told by someone once that Canada didn't have # the DST variations in 74/75 that the US did, but I am not nearly # sure enough of this to add anything." # The above has been confirmed by Bob Devine; we'll go with it here. # Before the Uniform Time Act of 1966 took effect in 1967, observance of # Daylight Saving Time in the US was by local option, except during wartime. # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S Rule US 1918 1919 - Mar lastSun 2:00 1:00 D Rule US 1918 1919 - Oct lastSun 2:00 0 S Rule US 1942 only - Feb 9 2:00 1:00 W # War Rule US 1945 only - Sep 30 2:00 0 S Rule US 1967 max - Oct lastSun 2:00 0 S Rule US 1967 1973 - Apr lastSun 2:00 1:00 D Rule US 1974 only - Jan 6 2:00 1:00 D Rule US 1975 only - Feb 23 2:00 1:00 D Rule US 1976 1986 - Apr lastSun 2:00 1:00 D Rule US 1987 max - Apr Sun>=1 2:00 1:00 D ############################################################################### # New names # Zone NAME GMTOFF RULES/SAVE FORMAT [UNTIL] Zone US/Eastern -5:00 US E%sT Zone US/Central -6:00 US C%sT Zone US/Mountain -7:00 US M%sT Zone US/Pacific -8:00 US P%sT Zone US/Yukon -9:00 US Y%sT # Mainland US areas that are always Standard as of 1986. Zone US/East-Indiana -5:00 US E%sT 1946 -5:00 - EST # Always EST as of 1986 Zone US/Arizona -7:00 US M%sT 1946 -7:00 - MST # Always MST as of 1986 # And then there's Hawaii. # DST was observed for one day in 1933; # Standard time was change by half an hour in 1947; # it's always standard as of 1986. Zone US/Hawaii -10:30 US H%sT 1933 Apr 30 2:00 -10:30 1:00 HDT 1933 May 1 2:00 -10:30 US H%sT 1947 Jun 8 2:00 -10:00 - HST # Old names, for S5 users # Link LINK-FROM LINK-TO Link US/Eastern EST5EDT Link US/Central CST6CDT Link US/Mountain MST7MDT Link US/Pacific PST8PDT Link US/East-Indiana EST Link US/Arizona MST Link US/Hawaii HST ################################################################################ # Canada is reportedly lots easier than the US--leastways since 1951. # I don't know what they did before then. # 4.3BSD claims that it's perfectly regular. # According to a posting in "comp.bugs.misc", "comp.unix.wizards", etc. # on February 8, 1987, by Dave Sherman of the Law Society of Upper Canada, # "...Canada (well, Ontario and at least some of the other provinces) are # adopting the new daylight savings time rules...". We assume all of # Canada is doing so. # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S Rule Canada 1969 max - Oct lastSun 2:00 0 S Rule Canada 1969 1986 - Apr lastSun 2:00 1:00 D Rule Canada 1987 max - Apr Sun>=1 2:00 1:00 D # Zone NAME GMTOFF RULES/SAVE FORMAT [UNTIL] # Bob Devine says that DST *is* observed in Newfoundland Zone Canada/Newfoundland -3:30 Canada N%sT Zone Canada/Atlantic -4:00 Canada A%sT Zone Canada/Eastern -5:00 Canada E%sT Zone Canada/Central -6:00 Canada C%sT Zone Canada/Mountain -7:00 Canada M%sT Zone Canada/Pacific -8:00 Canada P%sT Zone Canada/Yukon -9:00 Canada Y%sT ################################################################################ # ?Mexico? !Quien sabe! ================================================ FILE: share/zoneinfo/pacificnew ================================================ # @(#)pacificnew 3.1 # "Pacific Presidential Election Time" has been contemplated by the US Congress # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S Rule Twilite 1987 max - Apr Sun>=1 2:00 1:00 D Rule Twilite 1987 max uspres Oct lastSun 2:00 1:00 PE Rule Twilite 1987 max uspres Nov Sun>=7 2:00 0 S Rule Twilite 1987 max nonpres Oct lastSun 2:00 0 S # Zone NAME GMTOFF RULES/SAVE FORMAT [UNTIL] Zone US/Pacific-New -8:00 US P%sT 1987 -8:00 Twilite P%sT ================================================ FILE: share/zoneinfo/scheck.c ================================================ /* * @(#)scheck.c 1.1 scheck.c 3/4/87 */ #include #include #include #include extern char * imalloc(int); char * scheck(char *string, char *format) { register char * fbuf; register char * fp; register char * tp; register int c; register char * result; char dummy; result = ""; if (string == NULL || format == NULL) return result; fbuf = imalloc(2 * strlen(format) + 4); if (fbuf == NULL) return result; fp = format; tp = fbuf; while ((*tp++ = c = *fp++) != '\0') { if (c != '%') continue; if (*fp == '%') { *tp++ = *fp++; continue; } *tp++ = '*'; if (*fp == '*') ++fp; while (isascii(*fp) && isdigit(*fp)) *tp++ = *fp++; if (*fp == 'l' || *fp == 'h') *tp++ = *fp++; else if (*fp == '[') do *tp++ = *fp++; while (*fp != '\0' && *fp != ']'); if ((*tp++ = *fp++) == '\0') break; } *(tp - 1) = '%'; *tp++ = 'c'; *tp = '\0'; if (sscanf(string, fbuf, &dummy) != 1) result = format; free(fbuf); return result; } ================================================ FILE: share/zoneinfo/solar87 ================================================ # @(#)solar87 3.1 # So much for footnotes about Saudi Arabia. # Apparent noon times below are for Riyadh; your mileage will vary. # Times were computed using formulas in the U.S. Naval Observatory's # Almanac for Computers 1987; the formulas "will give EqT to an accuracy of # [plus or minus] two seconds during the current year." # # Rounding to the nearest five seconds results in fewer than # 256 different "time types"--a limit that's faced because time types are # stored on disk as unsigned chars. # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S Rule sol87 1987 only - Jan 1 12:03:20s -0:03:20 - Rule sol87 1987 only - Jan 2 12:03:50s -0:03:50 - Rule sol87 1987 only - Jan 3 12:04:15s -0:04:15 - Rule sol87 1987 only - Jan 4 12:04:45s -0:04:45 - Rule sol87 1987 only - Jan 5 12:05:10s -0:05:10 - Rule sol87 1987 only - Jan 6 12:05:40s -0:05:40 - Rule sol87 1987 only - Jan 7 12:06:05s -0:06:05 - Rule sol87 1987 only - Jan 8 12:06:30s -0:06:30 - Rule sol87 1987 only - Jan 9 12:06:55s -0:06:55 - Rule sol87 1987 only - Jan 10 12:07:20s -0:07:20 - Rule sol87 1987 only - Jan 11 12:07:45s -0:07:45 - Rule sol87 1987 only - Jan 12 12:08:10s -0:08:10 - Rule sol87 1987 only - Jan 13 12:08:30s -0:08:30 - Rule sol87 1987 only - Jan 14 12:08:55s -0:08:55 - Rule sol87 1987 only - Jan 15 12:09:15s -0:09:15 - Rule sol87 1987 only - Jan 16 12:09:35s -0:09:35 - Rule sol87 1987 only - Jan 17 12:09:55s -0:09:55 - Rule sol87 1987 only - Jan 18 12:10:15s -0:10:15 - Rule sol87 1987 only - Jan 19 12:10:35s -0:10:35 - Rule sol87 1987 only - Jan 20 12:10:55s -0:10:55 - Rule sol87 1987 only - Jan 21 12:11:10s -0:11:10 - Rule sol87 1987 only - Jan 22 12:11:30s -0:11:30 - Rule sol87 1987 only - Jan 23 12:11:45s -0:11:45 - Rule sol87 1987 only - Jan 24 12:12:00s -0:12:00 - Rule sol87 1987 only - Jan 25 12:12:15s -0:12:15 - Rule sol87 1987 only - Jan 26 12:12:30s -0:12:30 - Rule sol87 1987 only - Jan 27 12:12:40s -0:12:40 - Rule sol87 1987 only - Jan 28 12:12:55s -0:12:55 - Rule sol87 1987 only - Jan 29 12:13:05s -0:13:05 - Rule sol87 1987 only - Jan 30 12:13:15s -0:13:15 - Rule sol87 1987 only - Jan 31 12:13:25s -0:13:25 - Rule sol87 1987 only - Feb 1 12:13:35s -0:13:35 - Rule sol87 1987 only - Feb 2 12:13:40s -0:13:40 - Rule sol87 1987 only - Feb 3 12:13:50s -0:13:50 - Rule sol87 1987 only - Feb 4 12:13:55s -0:13:55 - Rule sol87 1987 only - Feb 5 12:14:00s -0:14:00 - Rule sol87 1987 only - Feb 6 12:14:05s -0:14:05 - Rule sol87 1987 only - Feb 7 12:14:10s -0:14:10 - Rule sol87 1987 only - Feb 8 12:14:10s -0:14:10 - Rule sol87 1987 only - Feb 9 12:14:15s -0:14:15 - Rule sol87 1987 only - Feb 10 12:14:15s -0:14:15 - Rule sol87 1987 only - Feb 11 12:14:15s -0:14:15 - Rule sol87 1987 only - Feb 12 12:14:15s -0:14:15 - Rule sol87 1987 only - Feb 13 12:14:15s -0:14:15 - Rule sol87 1987 only - Feb 14 12:14:15s -0:14:15 - Rule sol87 1987 only - Feb 15 12:14:10s -0:14:10 - Rule sol87 1987 only - Feb 16 12:14:10s -0:14:10 - Rule sol87 1987 only - Feb 17 12:14:05s -0:14:05 - Rule sol87 1987 only - Feb 18 12:14:00s -0:14:00 - Rule sol87 1987 only - Feb 19 12:13:55s -0:13:55 - Rule sol87 1987 only - Feb 20 12:13:50s -0:13:50 - Rule sol87 1987 only - Feb 21 12:13:45s -0:13:45 - Rule sol87 1987 only - Feb 22 12:13:35s -0:13:35 - Rule sol87 1987 only - Feb 23 12:13:30s -0:13:30 - Rule sol87 1987 only - Feb 24 12:13:20s -0:13:20 - Rule sol87 1987 only - Feb 25 12:13:10s -0:13:10 - Rule sol87 1987 only - Feb 26 12:13:00s -0:13:00 - Rule sol87 1987 only - Feb 27 12:12:50s -0:12:50 - Rule sol87 1987 only - Feb 28 12:12:40s -0:12:40 - Rule sol87 1987 only - Mar 1 12:12:30s -0:12:30 - Rule sol87 1987 only - Mar 2 12:12:20s -0:12:20 - Rule sol87 1987 only - Mar 3 12:12:05s -0:12:05 - Rule sol87 1987 only - Mar 4 12:11:55s -0:11:55 - Rule sol87 1987 only - Mar 5 12:11:40s -0:11:40 - Rule sol87 1987 only - Mar 6 12:11:25s -0:11:25 - Rule sol87 1987 only - Mar 7 12:11:15s -0:11:15 - Rule sol87 1987 only - Mar 8 12:11:00s -0:11:00 - Rule sol87 1987 only - Mar 9 12:10:45s -0:10:45 - Rule sol87 1987 only - Mar 10 12:10:30s -0:10:30 - Rule sol87 1987 only - Mar 11 12:10:15s -0:10:15 - Rule sol87 1987 only - Mar 12 12:09:55s -0:09:55 - Rule sol87 1987 only - Mar 13 12:09:40s -0:09:40 - Rule sol87 1987 only - Mar 14 12:09:25s -0:09:25 - Rule sol87 1987 only - Mar 15 12:09:10s -0:09:10 - Rule sol87 1987 only - Mar 16 12:08:50s -0:08:50 - Rule sol87 1987 only - Mar 17 12:08:35s -0:08:35 - Rule sol87 1987 only - Mar 18 12:08:15s -0:08:15 - Rule sol87 1987 only - Mar 19 12:08:00s -0:08:00 - Rule sol87 1987 only - Mar 20 12:07:40s -0:07:40 - Rule sol87 1987 only - Mar 21 12:07:25s -0:07:25 - Rule sol87 1987 only - Mar 22 12:07:05s -0:07:05 - Rule sol87 1987 only - Mar 23 12:06:50s -0:06:50 - Rule sol87 1987 only - Mar 24 12:06:30s -0:06:30 - Rule sol87 1987 only - Mar 25 12:06:10s -0:06:10 - Rule sol87 1987 only - Mar 26 12:05:55s -0:05:55 - Rule sol87 1987 only - Mar 27 12:05:35s -0:05:35 - Rule sol87 1987 only - Mar 28 12:05:15s -0:05:15 - Rule sol87 1987 only - Mar 29 12:05:00s -0:05:00 - Rule sol87 1987 only - Mar 30 12:04:40s -0:04:40 - Rule sol87 1987 only - Mar 31 12:04:25s -0:04:25 - Rule sol87 1987 only - Apr 1 12:04:05s -0:04:05 - Rule sol87 1987 only - Apr 2 12:03:45s -0:03:45 - Rule sol87 1987 only - Apr 3 12:03:30s -0:03:30 - Rule sol87 1987 only - Apr 4 12:03:10s -0:03:10 - Rule sol87 1987 only - Apr 5 12:02:55s -0:02:55 - Rule sol87 1987 only - Apr 6 12:02:35s -0:02:35 - Rule sol87 1987 only - Apr 7 12:02:20s -0:02:20 - Rule sol87 1987 only - Apr 8 12:02:05s -0:02:05 - Rule sol87 1987 only - Apr 9 12:01:45s -0:01:45 - Rule sol87 1987 only - Apr 10 12:01:30s -0:01:30 - Rule sol87 1987 only - Apr 11 12:01:15s -0:01:15 - Rule sol87 1987 only - Apr 12 12:00:55s -0:00:55 - Rule sol87 1987 only - Apr 13 12:00:40s -0:00:40 - Rule sol87 1987 only - Apr 14 12:00:25s -0:00:25 - Rule sol87 1987 only - Apr 15 12:00:10s -0:00:10 - Rule sol87 1987 only - Apr 16 11:59:55s 0:00:05 - Rule sol87 1987 only - Apr 17 11:59:45s 0:00:15 - Rule sol87 1987 only - Apr 18 11:59:30s 0:00:30 - Rule sol87 1987 only - Apr 19 11:59:15s 0:00:45 - Rule sol87 1987 only - Apr 20 11:59:05s 0:00:55 - Rule sol87 1987 only - Apr 21 11:58:50s 0:01:10 - Rule sol87 1987 only - Apr 22 11:58:40s 0:01:20 - Rule sol87 1987 only - Apr 23 11:58:25s 0:01:35 - Rule sol87 1987 only - Apr 24 11:58:15s 0:01:45 - Rule sol87 1987 only - Apr 25 11:58:05s 0:01:55 - Rule sol87 1987 only - Apr 26 11:57:55s 0:02:05 - Rule sol87 1987 only - Apr 27 11:57:45s 0:02:15 - Rule sol87 1987 only - Apr 28 11:57:35s 0:02:25 - Rule sol87 1987 only - Apr 29 11:57:25s 0:02:35 - Rule sol87 1987 only - Apr 30 11:57:15s 0:02:45 - Rule sol87 1987 only - May 1 11:57:10s 0:02:50 - Rule sol87 1987 only - May 2 11:57:00s 0:03:00 - Rule sol87 1987 only - May 3 11:56:55s 0:03:05 - Rule sol87 1987 only - May 4 11:56:50s 0:03:10 - Rule sol87 1987 only - May 5 11:56:45s 0:03:15 - Rule sol87 1987 only - May 6 11:56:40s 0:03:20 - Rule sol87 1987 only - May 7 11:56:35s 0:03:25 - Rule sol87 1987 only - May 8 11:56:30s 0:03:30 - Rule sol87 1987 only - May 9 11:56:25s 0:03:35 - Rule sol87 1987 only - May 10 11:56:25s 0:03:35 - Rule sol87 1987 only - May 11 11:56:20s 0:03:40 - Rule sol87 1987 only - May 12 11:56:20s 0:03:40 - Rule sol87 1987 only - May 13 11:56:20s 0:03:40 - Rule sol87 1987 only - May 14 11:56:20s 0:03:40 - Rule sol87 1987 only - May 15 11:56:20s 0:03:40 - Rule sol87 1987 only - May 16 11:56:20s 0:03:40 - Rule sol87 1987 only - May 17 11:56:20s 0:03:40 - Rule sol87 1987 only - May 18 11:56:20s 0:03:40 - Rule sol87 1987 only - May 19 11:56:25s 0:03:35 - Rule sol87 1987 only - May 20 11:56:25s 0:03:35 - Rule sol87 1987 only - May 21 11:56:30s 0:03:30 - Rule sol87 1987 only - May 22 11:56:35s 0:03:25 - Rule sol87 1987 only - May 23 11:56:40s 0:03:20 - Rule sol87 1987 only - May 24 11:56:45s 0:03:15 - Rule sol87 1987 only - May 25 11:56:50s 0:03:10 - Rule sol87 1987 only - May 26 11:56:55s 0:03:05 - Rule sol87 1987 only - May 27 11:57:00s 0:03:00 - Rule sol87 1987 only - May 28 11:57:10s 0:02:50 - Rule sol87 1987 only - May 29 11:57:15s 0:02:45 - Rule sol87 1987 only - May 30 11:57:25s 0:02:35 - Rule sol87 1987 only - May 31 11:57:30s 0:02:30 - Rule sol87 1987 only - Jun 1 11:57:40s 0:02:20 - Rule sol87 1987 only - Jun 2 11:57:50s 0:02:10 - Rule sol87 1987 only - Jun 3 11:58:00s 0:02:00 - Rule sol87 1987 only - Jun 4 11:58:10s 0:01:50 - Rule sol87 1987 only - Jun 5 11:58:20s 0:01:40 - Rule sol87 1987 only - Jun 6 11:58:30s 0:01:30 - Rule sol87 1987 only - Jun 7 11:58:40s 0:01:20 - Rule sol87 1987 only - Jun 8 11:58:50s 0:01:10 - Rule sol87 1987 only - Jun 9 11:59:05s 0:00:55 - Rule sol87 1987 only - Jun 10 11:59:15s 0:00:45 - Rule sol87 1987 only - Jun 11 11:59:30s 0:00:30 - Rule sol87 1987 only - Jun 12 11:59:40s 0:00:20 - Rule sol87 1987 only - Jun 13 11:59:50s 0:00:10 - Rule sol87 1987 only - Jun 14 12:00:05s -0:00:05 - Rule sol87 1987 only - Jun 15 12:00:15s -0:00:15 - Rule sol87 1987 only - Jun 16 12:00:30s -0:00:30 - Rule sol87 1987 only - Jun 17 12:00:45s -0:00:45 - Rule sol87 1987 only - Jun 18 12:00:55s -0:00:55 - Rule sol87 1987 only - Jun 19 12:01:10s -0:01:10 - Rule sol87 1987 only - Jun 20 12:01:20s -0:01:20 - Rule sol87 1987 only - Jun 21 12:01:35s -0:01:35 - Rule sol87 1987 only - Jun 22 12:01:50s -0:01:50 - Rule sol87 1987 only - Jun 23 12:02:00s -0:02:00 - Rule sol87 1987 only - Jun 24 12:02:15s -0:02:15 - Rule sol87 1987 only - Jun 25 12:02:25s -0:02:25 - Rule sol87 1987 only - Jun 26 12:02:40s -0:02:40 - Rule sol87 1987 only - Jun 27 12:02:50s -0:02:50 - Rule sol87 1987 only - Jun 28 12:03:05s -0:03:05 - Rule sol87 1987 only - Jun 29 12:03:15s -0:03:15 - Rule sol87 1987 only - Jun 30 12:03:30s -0:03:30 - Rule sol87 1987 only - Jul 1 12:03:40s -0:03:40 - Rule sol87 1987 only - Jul 2 12:03:50s -0:03:50 - Rule sol87 1987 only - Jul 3 12:04:05s -0:04:05 - Rule sol87 1987 only - Jul 4 12:04:15s -0:04:15 - Rule sol87 1987 only - Jul 5 12:04:25s -0:04:25 - Rule sol87 1987 only - Jul 6 12:04:35s -0:04:35 - Rule sol87 1987 only - Jul 7 12:04:45s -0:04:45 - Rule sol87 1987 only - Jul 8 12:04:55s -0:04:55 - Rule sol87 1987 only - Jul 9 12:05:05s -0:05:05 - Rule sol87 1987 only - Jul 10 12:05:15s -0:05:15 - Rule sol87 1987 only - Jul 11 12:05:20s -0:05:20 - Rule sol87 1987 only - Jul 12 12:05:30s -0:05:30 - Rule sol87 1987 only - Jul 13 12:05:40s -0:05:40 - Rule sol87 1987 only - Jul 14 12:05:45s -0:05:45 - Rule sol87 1987 only - Jul 15 12:05:50s -0:05:50 - Rule sol87 1987 only - Jul 16 12:06:00s -0:06:00 - Rule sol87 1987 only - Jul 17 12:06:05s -0:06:05 - Rule sol87 1987 only - Jul 18 12:06:10s -0:06:10 - Rule sol87 1987 only - Jul 19 12:06:15s -0:06:15 - Rule sol87 1987 only - Jul 20 12:06:15s -0:06:15 - Rule sol87 1987 only - Jul 21 12:06:20s -0:06:20 - Rule sol87 1987 only - Jul 22 12:06:25s -0:06:25 - Rule sol87 1987 only - Jul 23 12:06:25s -0:06:25 - Rule sol87 1987 only - Jul 24 12:06:25s -0:06:25 - Rule sol87 1987 only - Jul 25 12:06:30s -0:06:30 - Rule sol87 1987 only - Jul 26 12:06:30s -0:06:30 - Rule sol87 1987 only - Jul 27 12:06:30s -0:06:30 - Rule sol87 1987 only - Jul 28 12:06:30s -0:06:30 - Rule sol87 1987 only - Jul 29 12:06:25s -0:06:25 - Rule sol87 1987 only - Jul 30 12:06:25s -0:06:25 - Rule sol87 1987 only - Jul 31 12:06:25s -0:06:25 - Rule sol87 1987 only - Aug 1 12:06:20s -0:06:20 - Rule sol87 1987 only - Aug 2 12:06:15s -0:06:15 - Rule sol87 1987 only - Aug 3 12:06:10s -0:06:10 - Rule sol87 1987 only - Aug 4 12:06:05s -0:06:05 - Rule sol87 1987 only - Aug 5 12:06:00s -0:06:00 - Rule sol87 1987 only - Aug 6 12:05:55s -0:05:55 - Rule sol87 1987 only - Aug 7 12:05:50s -0:05:50 - Rule sol87 1987 only - Aug 8 12:05:40s -0:05:40 - Rule sol87 1987 only - Aug 9 12:05:35s -0:05:35 - Rule sol87 1987 only - Aug 10 12:05:25s -0:05:25 - Rule sol87 1987 only - Aug 11 12:05:15s -0:05:15 - Rule sol87 1987 only - Aug 12 12:05:05s -0:05:05 - Rule sol87 1987 only - Aug 13 12:04:55s -0:04:55 - Rule sol87 1987 only - Aug 14 12:04:45s -0:04:45 - Rule sol87 1987 only - Aug 15 12:04:35s -0:04:35 - Rule sol87 1987 only - Aug 16 12:04:25s -0:04:25 - Rule sol87 1987 only - Aug 17 12:04:10s -0:04:10 - Rule sol87 1987 only - Aug 18 12:04:00s -0:04:00 - Rule sol87 1987 only - Aug 19 12:03:45s -0:03:45 - Rule sol87 1987 only - Aug 20 12:03:30s -0:03:30 - Rule sol87 1987 only - Aug 21 12:03:15s -0:03:15 - Rule sol87 1987 only - Aug 22 12:03:00s -0:03:00 - Rule sol87 1987 only - Aug 23 12:02:45s -0:02:45 - Rule sol87 1987 only - Aug 24 12:02:30s -0:02:30 - Rule sol87 1987 only - Aug 25 12:02:15s -0:02:15 - Rule sol87 1987 only - Aug 26 12:02:00s -0:02:00 - Rule sol87 1987 only - Aug 27 12:01:40s -0:01:40 - Rule sol87 1987 only - Aug 28 12:01:25s -0:01:25 - Rule sol87 1987 only - Aug 29 12:01:05s -0:01:05 - Rule sol87 1987 only - Aug 30 12:00:50s -0:00:50 - Rule sol87 1987 only - Aug 31 12:00:30s -0:00:30 - Rule sol87 1987 only - Sep 1 12:00:10s -0:00:10 - Rule sol87 1987 only - Sep 2 11:59:50s 0:00:10 - Rule sol87 1987 only - Sep 3 11:59:35s 0:00:25 - Rule sol87 1987 only - Sep 4 11:59:15s 0:00:45 - Rule sol87 1987 only - Sep 5 11:58:55s 0:01:05 - Rule sol87 1987 only - Sep 6 11:58:35s 0:01:25 - Rule sol87 1987 only - Sep 7 11:58:15s 0:01:45 - Rule sol87 1987 only - Sep 8 11:57:55s 0:02:05 - Rule sol87 1987 only - Sep 9 11:57:30s 0:02:30 - Rule sol87 1987 only - Sep 10 11:57:10s 0:02:50 - Rule sol87 1987 only - Sep 11 11:56:50s 0:03:10 - Rule sol87 1987 only - Sep 12 11:56:30s 0:03:30 - Rule sol87 1987 only - Sep 13 11:56:10s 0:03:50 - Rule sol87 1987 only - Sep 14 11:55:45s 0:04:15 - Rule sol87 1987 only - Sep 15 11:55:25s 0:04:35 - Rule sol87 1987 only - Sep 16 11:55:05s 0:04:55 - Rule sol87 1987 only - Sep 17 11:54:45s 0:05:15 - Rule sol87 1987 only - Sep 18 11:54:20s 0:05:40 - Rule sol87 1987 only - Sep 19 11:54:00s 0:06:00 - Rule sol87 1987 only - Sep 20 11:53:40s 0:06:20 - Rule sol87 1987 only - Sep 21 11:53:15s 0:06:45 - Rule sol87 1987 only - Sep 22 11:52:55s 0:07:05 - Rule sol87 1987 only - Sep 23 11:52:35s 0:07:25 - Rule sol87 1987 only - Sep 24 11:52:15s 0:07:45 - Rule sol87 1987 only - Sep 25 11:51:55s 0:08:05 - Rule sol87 1987 only - Sep 26 11:51:35s 0:08:25 - Rule sol87 1987 only - Sep 27 11:51:10s 0:08:50 - Rule sol87 1987 only - Sep 28 11:50:50s 0:09:10 - Rule sol87 1987 only - Sep 29 11:50:30s 0:09:30 - Rule sol87 1987 only - Sep 30 11:50:10s 0:09:50 - Rule sol87 1987 only - Oct 1 11:49:50s 0:10:10 - Rule sol87 1987 only - Oct 2 11:49:35s 0:10:25 - Rule sol87 1987 only - Oct 3 11:49:15s 0:10:45 - Rule sol87 1987 only - Oct 4 11:48:55s 0:11:05 - Rule sol87 1987 only - Oct 5 11:48:35s 0:11:25 - Rule sol87 1987 only - Oct 6 11:48:20s 0:11:40 - Rule sol87 1987 only - Oct 7 11:48:00s 0:12:00 - Rule sol87 1987 only - Oct 8 11:47:45s 0:12:15 - Rule sol87 1987 only - Oct 9 11:47:25s 0:12:35 - Rule sol87 1987 only - Oct 10 11:47:10s 0:12:50 - Rule sol87 1987 only - Oct 11 11:46:55s 0:13:05 - Rule sol87 1987 only - Oct 12 11:46:40s 0:13:20 - Rule sol87 1987 only - Oct 13 11:46:25s 0:13:35 - Rule sol87 1987 only - Oct 14 11:46:10s 0:13:50 - Rule sol87 1987 only - Oct 15 11:45:55s 0:14:05 - Rule sol87 1987 only - Oct 16 11:45:45s 0:14:15 - Rule sol87 1987 only - Oct 17 11:45:30s 0:14:30 - Rule sol87 1987 only - Oct 18 11:45:20s 0:14:40 - Rule sol87 1987 only - Oct 19 11:45:05s 0:14:55 - Rule sol87 1987 only - Oct 20 11:44:55s 0:15:05 - Rule sol87 1987 only - Oct 21 11:44:45s 0:15:15 - Rule sol87 1987 only - Oct 22 11:44:35s 0:15:25 - Rule sol87 1987 only - Oct 23 11:44:25s 0:15:35 - Rule sol87 1987 only - Oct 24 11:44:20s 0:15:40 - Rule sol87 1987 only - Oct 25 11:44:10s 0:15:50 - Rule sol87 1987 only - Oct 26 11:44:05s 0:15:55 - Rule sol87 1987 only - Oct 27 11:43:55s 0:16:05 - Rule sol87 1987 only - Oct 28 11:43:50s 0:16:10 - Rule sol87 1987 only - Oct 29 11:43:45s 0:16:15 - Rule sol87 1987 only - Oct 30 11:43:45s 0:16:15 - Rule sol87 1987 only - Oct 31 11:43:40s 0:16:20 - Rule sol87 1987 only - Nov 1 11:43:40s 0:16:20 - Rule sol87 1987 only - Nov 2 11:43:35s 0:16:25 - Rule sol87 1987 only - Nov 3 11:43:35s 0:16:25 - Rule sol87 1987 only - Nov 4 11:43:35s 0:16:25 - Rule sol87 1987 only - Nov 5 11:43:35s 0:16:25 - Rule sol87 1987 only - Nov 6 11:43:40s 0:16:20 - Rule sol87 1987 only - Nov 7 11:43:40s 0:16:20 - Rule sol87 1987 only - Nov 8 11:43:45s 0:16:15 - Rule sol87 1987 only - Nov 9 11:43:50s 0:16:10 - Rule sol87 1987 only - Nov 10 11:43:55s 0:16:05 - Rule sol87 1987 only - Nov 11 11:44:00s 0:16:00 - Rule sol87 1987 only - Nov 12 11:44:05s 0:15:55 - Rule sol87 1987 only - Nov 13 11:44:15s 0:15:45 - Rule sol87 1987 only - Nov 14 11:44:20s 0:15:40 - Rule sol87 1987 only - Nov 15 11:44:30s 0:15:30 - Rule sol87 1987 only - Nov 16 11:44:40s 0:15:20 - Rule sol87 1987 only - Nov 17 11:44:50s 0:15:10 - Rule sol87 1987 only - Nov 18 11:45:05s 0:14:55 - Rule sol87 1987 only - Nov 19 11:45:15s 0:14:45 - Rule sol87 1987 only - Nov 20 11:45:30s 0:14:30 - Rule sol87 1987 only - Nov 21 11:45:45s 0:14:15 - Rule sol87 1987 only - Nov 22 11:46:00s 0:14:00 - Rule sol87 1987 only - Nov 23 11:46:15s 0:13:45 - Rule sol87 1987 only - Nov 24 11:46:30s 0:13:30 - Rule sol87 1987 only - Nov 25 11:46:50s 0:13:10 - Rule sol87 1987 only - Nov 26 11:47:10s 0:12:50 - Rule sol87 1987 only - Nov 27 11:47:25s 0:12:35 - Rule sol87 1987 only - Nov 28 11:47:45s 0:12:15 - Rule sol87 1987 only - Nov 29 11:48:05s 0:11:55 - Rule sol87 1987 only - Nov 30 11:48:30s 0:11:30 - Rule sol87 1987 only - Dec 1 11:48:50s 0:11:10 - Rule sol87 1987 only - Dec 2 11:49:10s 0:10:50 - Rule sol87 1987 only - Dec 3 11:49:35s 0:10:25 - Rule sol87 1987 only - Dec 4 11:50:00s 0:10:00 - Rule sol87 1987 only - Dec 5 11:50:25s 0:09:35 - Rule sol87 1987 only - Dec 6 11:50:50s 0:09:10 - Rule sol87 1987 only - Dec 7 11:51:15s 0:08:45 - Rule sol87 1987 only - Dec 8 11:51:40s 0:08:20 - Rule sol87 1987 only - Dec 9 11:52:05s 0:07:55 - Rule sol87 1987 only - Dec 10 11:52:30s 0:07:30 - Rule sol87 1987 only - Dec 11 11:53:00s 0:07:00 - Rule sol87 1987 only - Dec 12 11:53:25s 0:06:35 - Rule sol87 1987 only - Dec 13 11:53:55s 0:06:05 - Rule sol87 1987 only - Dec 14 11:54:25s 0:05:35 - Rule sol87 1987 only - Dec 15 11:54:50s 0:05:10 - Rule sol87 1987 only - Dec 16 11:55:20s 0:04:40 - Rule sol87 1987 only - Dec 17 11:55:50s 0:04:10 - Rule sol87 1987 only - Dec 18 11:56:20s 0:03:40 - Rule sol87 1987 only - Dec 19 11:56:50s 0:03:10 - Rule sol87 1987 only - Dec 20 11:57:20s 0:02:40 - Rule sol87 1987 only - Dec 21 11:57:50s 0:02:10 - Rule sol87 1987 only - Dec 22 11:58:20s 0:01:40 - Rule sol87 1987 only - Dec 23 11:58:50s 0:01:10 - Rule sol87 1987 only - Dec 24 11:59:20s 0:00:40 - Rule sol87 1987 only - Dec 25 11:59:50s 0:00:10 - Rule sol87 1987 only - Dec 26 12:00:20s -0:00:20 - Rule sol87 1987 only - Dec 27 12:00:45s -0:00:45 - Rule sol87 1987 only - Dec 28 12:01:15s -0:01:15 - Rule sol87 1987 only - Dec 29 12:01:45s -0:01:45 - Rule sol87 1987 only - Dec 30 12:02:15s -0:02:15 - Rule sol87 1987 only - Dec 31 12:02:45s -0:02:45 - # Riyadh is at about 46 degrees 46 minutes East: 3 hrs, 7 mins, 4 secs # Before and after 1987, we'll operate on local mean solar time. # Zone NAME GMTOFF RULES/SAVE FORMAT [UNTIL] Zone Mideast/Riyadh 3:07:04 - ?? 1987 3:07:04 sol87 ?? 1988 3:07:04 - ?? ================================================ FILE: share/zoneinfo/systemv ================================================ # @(#)systemv 3.1 # # Old rules, should the need arise. # No attempt is made to handle Newfoundland, since it cannot be expressed # using the System V "TZ" scheme (half-hour offset), or anything outside # North America (no support for non-standard DST start/end dates), nor # the change in the DST rules in the US in 1987 (can't split between # Canada, with no changes, and the US) # # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S Rule SystemV min 1973 - Apr lastSun 2:00 1:00 D Rule SystemV min 1973 - Oct lastSun 2:00 0 S Rule SystemV 1974 only - Jan 6 2:00 1:00 D Rule SystemV 1974 only - Nov lastSun 2:00 0 S Rule SystemV 1975 only - Feb 23 2:00 1:00 D Rule SystemV 1975 only - Oct lastSun 2:00 0 S Rule SystemV 1976 max - Apr lastSun 2:00 1:00 D Rule SystemV 1976 max - Oct lastSun 2:00 0 S # Zone NAME GMTOFF RULES/SAVE FORMAT [UNTIL] Zone SystemV/AST4ADT -4:00 SystemV A%sT Zone SystemV/EST5EDT -5:00 SystemV E%sT Zone SystemV/CST6CDT -6:00 SystemV C%sT Zone SystemV/MST7MDT -7:00 SystemV M%sT Zone SystemV/PST8PDT -8:00 SystemV P%sT Zone SystemV/YST9YDT -9:00 SystemV Y%sT Zone SystemV/AST4 -4:00 - AST Zone SystemV/EST5 -5:00 - EST Zone SystemV/CST6 -6:00 - CST Zone SystemV/MST7 -7:00 - MST Zone SystemV/PST8 -8:00 - PST Zone SystemV/YST9 -9:00 - YST Zone SystemV/HST10 -10:00 - HST ================================================ FILE: share/zoneinfo/zdump.8 ================================================ .TH ZDUMP 8 "November 30, 1996" .SH NAME zdump \- time zone dumper .SH SYNOPSIS .B zdump [ .B \-v ] [ .B \-c cutoffyear ] [ zonename ... ] .SH DESCRIPTION .I Zdump prints the current time in each .I zonename named on the command line. .PP These options are available: .TP .B \-v For each .I zonename on the command line, print the current time, the time at the lowest possible time value, the time one day after the lowest possible time value, the times both one second before and exactly at each time at which the rules for computing local time change, the time at the highest possible time value, and the time at one day less than the highest possible time value. Each line ends with .B isdst=1 if the given time is Daylight Saving Time or .B isdst=0 otherwise. .TP .BI "\-c " cutoffyear Cut off the verbose output near the start of the given year. .SH FILES /usr/share/zoneinfo standard zone information directory .SH "SEE ALSO" newctime(3), tzfile(5), zic(8) .. @(#)zdump.8 3.2 ================================================ FILE: share/zoneinfo/zdump.c ================================================ /* * @(#)zdump.c 1.1 zdump.c 3/4/87 */ #include #include #include #include #include #include #include "tzfile.h" #ifndef TRUE #define TRUE 1 #define FALSE 0 #endif extern char **environ; extern char *tzname[2]; extern char *imalloc(int); extern void tzset(void); static int longest; static void show(char *zone, time_t t, int v) { struct tm * tmp; (void) printf("%-*s ", longest, zone); if (v) (void) printf("%.24s GMT = ", asctime(gmtime(&t))); tmp = localtime(&t); (void) printf("%.24s", asctime(tmp)); if (*tzname[tmp->tm_isdst] != '\0') (void) printf(" %s", tzname[tmp->tm_isdst]); if (v) { (void) printf(" isdst=%d", tmp->tm_isdst); (void) printf(" gmtoff=%ld", tmp->tm_gmtoff); } (void) printf("\n"); } static void readerr(FILE *fp, char *progname, char *filename) { (void) fprintf(stderr, "%s: Error reading ", progname); if (ferror(fp)) perror(filename); else (void) fprintf(stderr, "%s: Premature EOF\n", filename); exit(1); } static long tzdecode(char *codep) { register int i; register long result; result = 0; for (i = 0; i < 4; ++i) result = (result << 8) | (codep[i] & 0xff); return result; } int main(int argc, char *argv[]) { register FILE * fp; register int i, j, c; register int vflag; register char * cutoff; register int cutyear = 0; register long cuttime; time_t now; time_t t; long timecnt; char buf[BUFSIZ]; vflag = 0; cutoff = NULL; while ((c = getopt(argc, argv, "c:v")) == 'c' || c == 'v') if (c == 'v') vflag = 1; else cutoff = optarg; if (c != EOF || (optind == argc - 1 && strcmp(argv[optind], "=") == 0)) { (void) fprintf(stderr, "%s: usage is %s [ -v ] zonename ...\n", argv[0], argv[0]); exit(1); } if (cutoff != NULL) cutyear = atoi(cutoff); /* ** VERY approximate. */ cuttime = (long) (cutyear - EPOCH_YEAR) * SECS_PER_HOUR * HOURS_PER_DAY * DAYS_PER_NYEAR; (void) time(&now); longest = 0; for (i = optind; i < argc; ++i) if (strlen(argv[i]) > longest) longest = strlen(argv[i]); for (i = optind; i < argc; ++i) { register char ** saveenv; char * tzequals; char * fakeenv[2]; tzequals = imalloc(strlen(argv[i]) + 4); if (tzequals == NULL) { (void) fprintf(stderr, "%s: can't allocate memory\n", argv[0]); exit(1); } (void)snprintf(tzequals, strlen(argv[i]) + 4, "TZ=%s", argv[i]); fakeenv[0] = tzequals; fakeenv[1] = NULL; saveenv = environ; environ = fakeenv; (void) tzset(); environ = saveenv; show(argv[i], now, FALSE); if (!vflag) continue; if (argv[i][0] == '/') fp = fopen(argv[i], "r"); else { j = strlen(TZDIR) + 1 + strlen(argv[i]) + 1; if (j > sizeof buf) { (void) fprintf(stderr, "%s: timezone name %s/%s is too long\n", argv[0], TZDIR, argv[i]); exit(1); } (void)snprintf(buf, sizeof(buf), "%s/%s", TZDIR, argv[i]); fp = fopen(buf, "r"); } if (fp == NULL) { (void) fprintf(stderr, "%s: Can't open ", argv[0]); perror(argv[i]); exit(1); } { char code[4]; (void) fseek(fp, (long) sizeof ((struct tzhead *) 0)->tzh_reserved, 0); if (fread((char *) code, sizeof code, 1, fp) != 1) readerr(fp, argv[0], argv[i]); timecnt = tzdecode(code); (void) fseek(fp, (long) (2 * sizeof code), 1); } t = 0x80000000; if (t > 0) /* time_t is unsigned */ t = 0; show(argv[i], t, TRUE); t += SECS_PER_HOUR * HOURS_PER_DAY; show(argv[i], t, TRUE); while (timecnt-- > 0) { char code[4]; if (fread((char *) code, sizeof code, 1, fp) != 1) readerr(fp, argv[0], argv[i]); t = tzdecode(code); if (cutoff != NULL && t > cuttime) break; show(argv[i], t - 1, TRUE); show(argv[i], t, TRUE); } if (fclose(fp)) { (void) fprintf(stderr, "%s: Error closing ", argv[0]); perror(argv[i]); exit(1); } t = 0xffffffff; if (t < 0) /* time_t is signed */ t = 0x7fffffff ; t -= SECS_PER_HOUR * HOURS_PER_DAY; show(argv[i], t, TRUE); t += SECS_PER_HOUR * HOURS_PER_DAY; show(argv[i], t, TRUE); free(tzequals); } if (fflush(stdout) || ferror(stdout)) { (void) fprintf(stderr, "%s: Error writing standard output ", argv[0]); perror("standard output"); exit(1); } return 0; } ================================================ FILE: share/zoneinfo/zic.8 ================================================ .TH ZIC 8 "November 30, 1996" .SH NAME zic \- time zone compiler .SH SYNOPSIS .B zic [ .B \-v ] [ .B \-d .I directory ] [ .B \-l .I localtime ] [ .I filename \&... ] .SH DESCRIPTION .I Zic reads text from the file(s) named on the command line and creates the time conversion information files specified in this input. If a .I filename is .BR \- , the standard input is read. .PP These options are available: .TP .BI "\-d " directory Create time conversion information files in the named directory rather than in the standard directory named below. .TP .BI "\-l " timezone Use the given time zone as local time. .I Zic will act as if the file contained a link line of the form .sp .ti +.5i Link \fItimezone\fP localtime .TP .B \-v Complain if a year that appears in a data file is outside the range of years representable by .IR time (2) values. .sp Input lines are made up of fields. Fields are separated from one another by any number of white space characters. Leading and trailing white space on input lines is ignored. An unquoted sharp character (#) in the input introduces a comment which extends to the end of the line the sharp character appears on. White space characters and sharp characters may be enclosed in double quotes (") if they're to be used as part of a field. Any line that is blank (after comment stripping) is ignored. Non-blank lines are expected to be of one of three types: rule lines, zone lines, and link lines. .PP A rule line has the form .nf .B .ti +.5i .ta \w'Rule\0\0'u +\w'NAME\0\0'u +\w'FROM\0\0'u +\w'1973\0\0'u +\w'TYPE\0\0'u +\w'Apr\0\0'u +\w'lastSun\0\0'u +\w'2:00\0\0'u +\w'SAVE\0\0'u .sp Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S .sp For example: .ti +.5i .sp Rule USA 1969 1973 \- Apr lastSun 2:00 1:00 D .sp .fi The fields that make up a rule line are: .TP "\w'LETTER/S'u" .B NAME Gives the (arbitrary) name of the set of rules this rule is part of. .TP .B FROM Gives the first year in which the rule applies. The word .B minimum (or an abbreviation) means the minimum year with a representable time value. The word .B maximum (or an abbreviation) means the maximum year with a representable time value. .TP .B TO Gives the final year in which the rule applies. In addition to .B minimum and .B maximum (as above), the word .B only (or an abbreviation) may be used to repeat the value of the .B FROM field. .TP .B TYPE Gives the type of year in which the year applies. If .B TYPE is .B \- then the rule applies in all years between .B FROM and .B TO inclusive; if .B TYPE is .BR uspres , the rule applies in U.S. Presidential election years; if .B TYPE is .BR nonpres , the rule applies in years other than U.S. Presidential election years. If .B TYPE is something else, then .I zic executes the command .ti +.5i \fByearistype\fP \fIyear\fP \fItype\fP .br to check the type of a year: an exit status of zero is taken to mean that the year is of the given type; an exit status of one is taken to mean that the year is not of the given type. .TP .B IN Names the month in which the rule takes effect. Month names may be abbreviated. .TP .B ON Gives the day on which the rule takes effect. Recognized forms include: .nf .in +.5i .sp .ta \w'Sun<=25\0\0'u 5 the fifth of the month lastSun the last Sunday in the month lastMon the last Monday in the month Sun>=8 first Sunday on or after the eighth Sun<=25 last Sunday on or before the 25th .fi .in -.5i .sp Names of days of the week may be abbreviated or spelled out in full. Note that there must be no spaces within the .B ON field. .TP .B AT Gives the time of day at which the rule takes affect. Recognized forms include: .nf .in +.5i .sp .ta \w'1:28:13\0\0'u 2 time in hours 2:00 time in hours and minutes 15:00 24-hour format time (for times after noon) 1:28:14 time in hours, minutes, and seconds .fi .in -.5i .sp Any of these forms may be followed by the letter .B w if the given time is local ``wall clock'' time or .B s if the given time is local ``standard'' time; in the absence of .B w or .BR s , wall clock time is assumed. .TP .B SAVE Gives the amount of time to be added to local standard time when the rule is in effect. This field has the same format as the .B AT field (although, of course, the .B w and .B s suffixes are not used). .TP .B LETTER/S Gives the ``variable part'' (for example, the ``S'' or ``D'' in ``EST'' or ``EDT'') of time zone abbreviations to be used when this rule is in effect. If this field is .BR \- , the variable part is null. .PP A zone line has the form .sp .nf .ti +.5i .ta \w'Zone\0\0'u +\w'Australia/South\-west\0\0'u +\w'GMTOFF\0\0'u +\w'RULES/SAVE\0\0'u +\w'FORMAT\0\0'u Zone NAME GMTOFF RULES/SAVE FORMAT [UNTIL] .sp For example: .sp .ti +.5i Zone Australia/South\-west 9:30 Aus CST 1987 Mar 15 2:00 .sp .fi The fields that make up a zone line are: .TP "\w'GMTOFF'u" .B NAME The name of the time zone. This is the name used in creating the time conversion information file for the zone. .TP .B GMTOFF The amount of time to add to GMT to get standard time in this zone. This field has the same format as the .B AT and .B SAVE fields of rule lines; begin the field with a minus sign if time must be subtracted from GMT. .TP .B RULES/SAVE The name of the rule(s) that apply in the time zone or, alternately, an amount of time to add to local standard time. If this field is .B \- then standard time always applies in the time zone. .TP .B FORMAT The format for time zone abbreviations in this time zone. The pair of characters .B %s is used to show where the ``variable part'' of the time zone abbreviation goes. .B UNTIL The time at which the GMT offset or the rule(s) change for a location. It is specified as a year, a month, a day, and a time of day. If this is specified, the time zone information is generated from the given GMT offset and rule change until the time specified. .IP The next line must be a ``continuation'' line; this has the same form as a zone line except that the string ``Zone'' and the name are omitted, as the continuation line will place information starting at the time specified as the .B UNTIL field in the previous line in the file used by the previous line. Continuation lines may contain an .B UNTIL field, just as zone lines do, indicating that the next line is a further continuation. .PP A link line has the form .sp .nf .ti +.5i .if t .ta \w'Link\0\0'u +\w'LINK-FROM\0\0'u .if n .ta \w'Link\0\0'u +\w'US/Eastern\0\0'u Link LINK-FROM LINK-TO .sp For example: .sp .ti +.5i Link US/Eastern EST5EDT .sp .fi The .B LINK-FROM field should appear as the .B NAME field in some zone line; the .B LINK-TO field is used as an alternate name for that zone. .PP Except for continuation lines, lines may appear in any order in the input. .SH NOTE For areas with more than two types of local time, you may need to use local standard time in the .B AT field of the earliest transition time's rule to ensure that the earliest transition time recorded in the compiled file is correct. .SH FILES /usr/share/zoneinfo standard directory used for created files .SH "SEE ALSO" newctime(3), tzfile(5), zdump(8) .. @(#)zic.8 3.2 ================================================ FILE: share/zoneinfo/zic.c ================================================ /* * @(#)zic.c 1.1 zic.c 3/4/87 */ #include #include #include #include #include #include #include #include #include #include #include "tzfile.h" #ifndef BUFSIZ #define BUFSIZ 1024 #endif #ifndef TRUE #define TRUE 1 #define FALSE 0 #endif /* Forward declaration. */ struct rule; struct zone; extern char * icpyalloc(char *string); extern char * imalloc(int n); extern char * irealloc(char *pointer, int size); extern char * scheck(char *string, char *format); static void addtt(time_t starttime, int type); static int addtype(long gmtoff, char *abbr, int isdst); static void associate(void); static int charcnt; static int ciequal(char *ap, char *bp); static long eitol(int i); static int errors; static char * filename; static char ** getfields(char *cp); static long gethms(char *string, char *errstring, int signable); static void infile(char *name); static void inlink(char **fields, int nfields); static void inrule(char **fields, int nfields); static int inzcont(char **fields, int nfields); static int inzone(char **fields, int nfields); static int inzsub(char **fields, int nfields, int iscont); static int linenum; static int lowerit(int a); static time_t max_time; static int max_year; static time_t min_time; static int min_year; static int mkdirs(char *name); static void newabbr(char *string); static int noise; static void nondunlink(char *name); static long oadd(long t1, long t2); static void outzone(struct zone *zpfirst, int zonecount); static char * progname; static char * rfilename; static int rlinenum; static time_t rpytime(struct rule *rp, int wantedy); static void rulesub(struct rule *rp, char *loyearp, char *hiyearp, char *typep, char *monthp, char *dayp, char *timep); static void setboundaries(void); static time_t tadd(time_t t1, long t2); static int timecnt; static int tt_signed; static int typecnt; static int yearistype(int year, char *type); /* ** Line codes. */ #define LC_RULE 0 #define LC_ZONE 1 #define LC_LINK 2 /* ** Which fields are which on a Zone line. */ #define ZF_NAME 1 #define ZF_GMTOFF 2 #define ZF_RULE 3 #define ZF_FORMAT 4 #define ZF_UNTILYEAR 5 #define ZF_UNTILMONTH 6 #define ZF_UNTILDAY 7 #define ZF_UNTILTIME 8 #define ZONE_MINFIELDS 5 #define ZONE_MAXFIELDS 9 /* ** Which fields are which on a Zone continuation line. */ #define ZFC_GMTOFF 0 #define ZFC_RULE 1 #define ZFC_FORMAT 2 #define ZFC_UNTILYEAR 3 #define ZFC_UNTILMONTH 4 #define ZFC_UNTILDAY 5 #define ZFC_UNTILTIME 6 #define ZONEC_MINFIELDS 3 #define ZONEC_MAXFIELDS 7 /* ** Which files are which on a Rule line. */ #define RF_NAME 1 #define RF_LOYEAR 2 #define RF_HIYEAR 3 #define RF_COMMAND 4 #define RF_MONTH 5 #define RF_DAY 6 #define RF_TOD 7 #define RF_STDOFF 8 #define RF_ABBRVAR 9 #define RULE_FIELDS 10 /* ** Which fields are which on a Link line. */ #define LF_FROM 1 #define LF_TO 2 #define LINK_FIELDS 3 struct rule { char * r_filename; int r_linenum; char * r_name; int r_loyear; /* for example, 1986 */ int r_hiyear; /* for example, 1986 */ char * r_yrtype; int r_month; /* 0..11 */ int r_dycode; /* see below */ int r_dayofmonth; int r_wday; long r_tod; /* time from midnight */ int r_todisstd; /* above is standard time if TRUE */ /* above is wall clock time if FALSE */ long r_stdoff; /* offset from standard time */ char * r_abbrvar; /* variable part of time zone abbreviation */ int r_todo; /* a rule to do (used in outzone) */ time_t r_temp; /* used in outzone */ }; /* ** r_dycode r_dayofmonth r_wday */ #define DC_DOM 0 /* 1..31 */ /* unused */ #define DC_DOWGEQ 1 /* 1..31 */ /* 0..6 (Sun..Sat) */ #define DC_DOWLEQ 2 /* 1..31 */ /* 0..6 (Sun..Sat) */ /* ** Year synonyms. */ #define YR_MINIMUM 0 #define YR_MAXIMUM 1 #define YR_ONLY 2 static struct rule * rules; static int nrules; /* number of rules */ struct zone { char * z_filename; int z_linenum; char * z_name; long z_gmtoff; char * z_rule; char * z_format; long z_stdoff; struct rule * z_rules; int z_nrules; struct rule z_untilrule; time_t z_untiltime; }; static struct zone * zones; static int nzones; /* number of zones */ struct link { char * l_filename; int l_linenum; char * l_from; char * l_to; }; static struct link * links; static int nlinks; struct lookup { char * l_word; int l_value; }; static struct lookup * byword(char *word, struct lookup *table); static struct lookup line_codes[] = { { "Rule", LC_RULE }, { "Zone", LC_ZONE }, { "Link", LC_LINK }, { NULL, 0 } }; static struct lookup mon_names[] = { { "January", TM_JANUARY }, { "February", TM_FEBRUARY }, { "March", TM_MARCH }, { "April", TM_APRIL }, { "May", TM_MAY }, { "June", TM_JUNE }, { "July", TM_JULY }, { "August", TM_AUGUST }, { "September", TM_SEPTEMBER }, { "October", TM_OCTOBER }, { "November", TM_NOVEMBER }, { "December", TM_DECEMBER }, { NULL, 0 } }; static struct lookup wday_names[] = { { "Sunday", TM_SUNDAY }, { "Monday", TM_MONDAY }, { "Tuesday", TM_TUESDAY }, { "Wednesday", TM_WEDNESDAY }, { "Thursday", TM_THURSDAY }, { "Friday", TM_FRIDAY }, { "Saturday", TM_SATURDAY }, { NULL, 0 } }; static struct lookup lasts[] = { { "last-Sunday", TM_SUNDAY }, { "last-Monday", TM_MONDAY }, { "last-Tuesday", TM_TUESDAY }, { "last-Wednesday", TM_WEDNESDAY }, { "last-Thursday", TM_THURSDAY }, { "last-Friday", TM_FRIDAY }, { "last-Saturday", TM_SATURDAY }, { NULL, 0 } }; static struct lookup begin_years[] = { { "minimum", YR_MINIMUM }, { "maximum", YR_MAXIMUM }, { NULL, 0 } }; static struct lookup end_years[] = { { "minimum", YR_MINIMUM }, { "maximum", YR_MAXIMUM }, { "only", YR_ONLY }, { NULL, 0 } }; static int len_months[2][MONS_PER_YEAR] = { { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }, { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 } }; static int len_years[2] = { DAYS_PER_NYEAR, DAYS_PER_LYEAR }; static time_t ats[TZ_MAX_TIMES]; static unsigned char types[TZ_MAX_TIMES]; static long gmtoffs[TZ_MAX_TYPES]; static char isdsts[TZ_MAX_TYPES]; static char abbrinds[TZ_MAX_TYPES]; static char chars[TZ_MAX_CHARS]; /* ** Memory allocation. */ static char * memcheck(char *ptr) { if (ptr == NULL) { perror(progname); exit(1); } return ptr; } #define emalloc(size) memcheck(imalloc(size)) #define erealloc(ptr, size) memcheck(irealloc(ptr, size)) #define ecpyalloc(ptr) memcheck(icpyalloc(ptr)) /* ** Error handling. */ static void eats(char *name, int num, char *rname, int rnum) { filename = name; linenum = num; rfilename = rname; rlinenum = rnum; } static void eat(char *name, int num) { eats(name, num, (char *) NULL, -1); } static void error(char *string) { /* ** Match the format of "cc" to allow sh users to ** zic ... 2>&1 | error -t "*" -v ** on BSD systems. */ (void) fprintf(stderr, "\"%s\", line %d: %s", filename, linenum, string); if (rfilename != NULL) (void) fprintf(stderr, " (rule from \"%s\", line %d)", rfilename, rlinenum); (void) fprintf(stderr, "\n"); ++errors; } static void usage(void) { (void) fprintf(stderr, "%s: usage is %s [ -v ] [ -l localtime ] [ -d directory ] [ filename ... ]\n", progname, progname); exit(1); } static char * lcltime = NULL; static char * directory = NULL; int main(int argc, char *argv[]) { register int i, j; register int c; #ifdef unix umask(umask(022) | 022); #endif progname = argv[0]; while ((c = getopt(argc, argv, "d:l:v")) != EOF) switch (c) { default: usage(); case 'd': if (directory == NULL) directory = optarg; else { (void) fprintf(stderr, "%s: More than one -d option specified\n", progname); exit(1); } break; case 'l': if (lcltime == NULL) lcltime = optarg; else { (void) fprintf(stderr, "%s: More than one -l option specified\n", progname); exit(1); } break; case 'v': noise = TRUE; break; } if (optind == argc - 1 && strcmp(argv[optind], "=") == 0) usage(); /* usage message by request */ if (directory == NULL) directory = TZDIR; setboundaries(); zones = (struct zone *) emalloc(0); rules = (struct rule *) emalloc(0); links = (struct link *) emalloc(0); for (i = optind; i < argc; ++i) infile(argv[i]); if (errors) exit(1); associate(); for (i = 0; i < nzones; i = j) { /* * Find the next non-continuation zone entry. */ for (j = i + 1; j < nzones && zones[j].z_name == NULL; ++j) ; outzone(&zones[i], j - i); } /* ** We'll take the easy way out on this last part. */ if (chdir(directory) != 0) { (void) fprintf(stderr, "%s: Can't chdir to ", progname); perror(directory); exit(1); } for (i = 0; i < nlinks; ++i) { nondunlink(links[i].l_to); if (link(links[i].l_from, links[i].l_to) != 0) { (void) fprintf(stderr, "%s: Can't link %s to ", progname, links[i].l_from); perror(links[i].l_to); exit(1); } } if (lcltime != NULL) { nondunlink(TZDEFAULT); if (link(lcltime, TZDEFAULT) != 0) { (void) fprintf(stderr, "%s: Can't link %s to ", progname, lcltime); perror(TZDEFAULT); exit(1); } } exit((errors == 0) ? 0 : 1); } static void setboundaries(void) { register time_t bit; struct tm zerotm = {0}; for (bit = 1; bit > 0; bit <<= 1) ; if (bit == 0) { /* time_t is an unsigned type */ tt_signed = FALSE; min_time = 0; max_time = ~(time_t) 0; } else { tt_signed = TRUE; for (;;) { min_time = mktime(&zerotm); if (min_time != -1) break; zerotm.tm_year++; } zerotm.tm_year = TZ_MAX_TIMES/2 - 2; for (;;) { max_time = mktime(&zerotm); if (max_time != -1) break; zerotm.tm_year--; } } min_year = TM_YEAR_BASE + gmtime(&min_time)->tm_year; max_year = TM_YEAR_BASE + gmtime(&max_time)->tm_year; } /* ** We get to be careful here since there's a fair chance of root running us. */ static void nondunlink(char *name) { struct stat s; if (stat(name, &s) != 0) return; if ((s.st_mode & S_IFMT) == S_IFDIR) return; (void) unlink(name); } /* ** Associate sets of rules with zones. */ /* ** Sort by rule name. */ static int rcomp(const void *cp1, const void *cp2) { return strcmp(((const struct rule *) cp1)->r_name, ((const struct rule *) cp2)->r_name); } static void associate(void) { register struct zone * zp; register struct rule * rp; register int base, out; register int i; if (nrules != 0) (void) qsort((char *) rules, nrules, sizeof *rules, rcomp); for (i = 0; i < nzones; ++i) { zp = &zones[i]; zp->z_rules = NULL; zp->z_nrules = 0; } for (base = 0; base < nrules; base = out) { rp = &rules[base]; for (out = base + 1; out < nrules; ++out) if (strcmp(rp->r_name, rules[out].r_name) != 0) break; for (i = 0; i < nzones; ++i) { zp = &zones[i]; if (strcmp(zp->z_rule, rp->r_name) != 0) continue; zp->z_rules = rp; zp->z_nrules = out - base; } } for (i = 0; i < nzones; ++i) { zp = &zones[i]; if (zp->z_nrules == 0) { /* ** Maybe we have a local standard time offset. */ eat(zp->z_filename, zp->z_linenum); zp->z_stdoff = gethms(zp->z_rule, "unruly zone", TRUE); /* ** Note, though, that if there's no rule, ** a '%s' in the format is a bad thing. */ if (index(zp->z_format, '%') != 0) error("%s in ruleless zone"); } } if (errors) exit(1); } static void infile(char *name) { register FILE * fp; register char ** fields; register char * cp; register struct lookup * lp; register int nfields; register int wantcont; register int num; char buf[BUFSIZ]; if (strcmp(name, "-") == 0) { name = "standard input"; fp = stdin; } else if ((fp = fopen(name, "r")) == NULL) { (void) fprintf(stderr, "%s: Can't open ", progname); perror(name); exit(1); } wantcont = FALSE; for (num = 1; ; ++num) { eat(name, num); if (fgets(buf, sizeof buf, fp) != buf) break; cp = index(buf, '\n'); if (cp == NULL) { error("line too long"); exit(1); } *cp = '\0'; fields = getfields(buf); nfields = 0; while (fields[nfields] != NULL) { if (ciequal(fields[nfields], "-")) fields[nfields] = ""; ++nfields; } if (nfields == 0) { /* nothing to do */ } else if (wantcont) { wantcont = inzcont(fields, nfields); } else { lp = byword(fields[0], line_codes); if (lp == NULL) error("input line of unknown type"); else switch ((int) (lp->l_value)) { case LC_RULE: inrule(fields, nfields); wantcont = FALSE; break; case LC_ZONE: wantcont = inzone(fields, nfields); break; case LC_LINK: inlink(fields, nfields); wantcont = FALSE; break; default: /* "cannot happen" */ (void) fprintf(stderr, "%s: panic: Invalid l_value %d\n", progname, lp->l_value); exit(1); } } free((char *) fields); } if (ferror(fp)) { (void) fprintf(stderr, "%s: Error reading ", progname); perror(filename); exit(1); } if (fp != stdin && fclose(fp)) { (void) fprintf(stderr, "%s: Error closing ", progname); perror(filename); exit(1); } if (wantcont) error("expected continuation line not found"); } /* ** Convert a string of one of the forms ** h -h hh:mm -hh:mm hh:mm:ss -hh:mm:ss ** into a number of seconds. ** A null string maps to zero. ** Call error with errstring and return zero on errors. */ static long gethms(char *string, char *errstring, int signable) { int hh, mm, ss, sign; if (string == NULL || *string == '\0') return 0; if (!signable) sign = 1; else if (*string == '-') { sign = -1; ++string; } else sign = 1; if (sscanf(string, scheck(string, "%d"), &hh) == 1) mm = ss = 0; else if (sscanf(string, scheck(string, "%d:%d"), &hh, &mm) == 2) ss = 0; else if (sscanf(string, scheck(string, "%d:%d:%d"), &hh, &mm, &ss) != 3) { error(errstring); return 0; } if (hh < 0 || hh >= HOURS_PER_DAY || mm < 0 || mm >= MINS_PER_HOUR || ss < 0 || ss >= SECS_PER_MIN) { error(errstring); return 0; } return eitol(sign) * (eitol(hh * MINS_PER_HOUR + mm) * eitol(SECS_PER_MIN) + eitol(ss)); } static void inrule(char **fields, int nfields) { struct rule r; if (nfields != RULE_FIELDS) { error("wrong number of fields on Rule line"); return; } if (*fields[RF_NAME] == '\0') { error("nameless rule"); return; } r.r_filename = filename; r.r_linenum = linenum; r.r_stdoff = gethms(fields[RF_STDOFF], "invalid saved time", TRUE); rulesub(&r, fields[RF_LOYEAR], fields[RF_HIYEAR], fields[RF_COMMAND], fields[RF_MONTH], fields[RF_DAY], fields[RF_TOD]); r.r_name = ecpyalloc(fields[RF_NAME]); r.r_abbrvar = ecpyalloc(fields[RF_ABBRVAR]); rules = (struct rule *) erealloc((char *) rules, (nrules + 1) * sizeof *rules); rules[nrules++] = r; } static int inzone(char **fields, int nfields) { register int i; char buf[132]; if (nfields < ZONE_MINFIELDS || nfields > ZONE_MAXFIELDS) { error("wrong number of fields on Zone line"); return FALSE; } if (strcmp(fields[ZF_NAME], TZDEFAULT) == 0 && lcltime != NULL) { (void)snprintf(buf, sizeof(buf), "\"Zone %s\" line and -l option are mutually exclusive", TZDEFAULT); error(buf); return FALSE; } for (i = 0; i < nzones; ++i) if (zones[i].z_name != NULL && strcmp(zones[i].z_name, fields[ZF_NAME]) == 0) { (void)snprintf(buf, sizeof(buf), "duplicate zone name %s (file \"%s\", line %d)", fields[ZF_NAME], zones[i].z_filename, zones[i].z_linenum); error(buf); return FALSE; } return inzsub(fields, nfields, FALSE); } static int inzcont(char **fields, int nfields) { if (nfields < ZONEC_MINFIELDS || nfields > ZONEC_MAXFIELDS) { error("wrong number of fields on Zone continuation line"); return FALSE; } return inzsub(fields, nfields, TRUE); } static int inzsub(char **fields, int nfields, int iscont) { register char * cp; struct zone z; register int i_gmtoff, i_rule, i_format; register int i_untilyear, i_untilmonth; register int i_untilday, i_untiltime; register int hasuntil; if (iscont) { i_gmtoff = ZFC_GMTOFF; i_rule = ZFC_RULE; i_format = ZFC_FORMAT; i_untilyear = ZFC_UNTILYEAR; i_untilmonth = ZFC_UNTILMONTH; i_untilday = ZFC_UNTILDAY; i_untiltime = ZFC_UNTILTIME; z.z_name = NULL; } else { i_gmtoff = ZF_GMTOFF; i_rule = ZF_RULE; i_format = ZF_FORMAT; i_untilyear = ZF_UNTILYEAR; i_untilmonth = ZF_UNTILMONTH; i_untilday = ZF_UNTILDAY; i_untiltime = ZF_UNTILTIME; z.z_name = ecpyalloc(fields[ZF_NAME]); } z.z_filename = filename; z.z_linenum = linenum; z.z_gmtoff = gethms(fields[i_gmtoff], "invalid GMT offset", TRUE); if ((cp = index(fields[i_format], '%')) != 0) { if (*++cp != 's' || index(cp, '%') != 0) { error("invalid abbreviation format"); return FALSE; } } z.z_rule = ecpyalloc(fields[i_rule]); z.z_format = ecpyalloc(fields[i_format]); hasuntil = nfields > i_untilyear; if (hasuntil) { z.z_untilrule.r_filename = filename; z.z_untilrule.r_linenum = linenum; rulesub(&z.z_untilrule, fields[i_untilyear], "only", "", (nfields > i_untilmonth) ? fields[i_untilmonth] : "Jan", (nfields > i_untilday) ? fields[i_untilday] : "1", (nfields > i_untiltime) ? fields[i_untiltime] : "0"); z.z_untiltime = rpytime(&z.z_untilrule, z.z_untilrule.r_loyear); if (iscont && nzones > 0 && z.z_untiltime < max_time && z.z_untiltime > min_time && zones[nzones - 1].z_untiltime >= z.z_untiltime) { error("Zone continuation line end time is not after end time of previous line"); return FALSE; } } zones = (struct zone *) erealloc((char *) zones, (nzones + 1) * sizeof *zones); zones[nzones++] = z; /* ** If there was an UNTIL field on this line, ** there's more information about the zone on the next line. */ return hasuntil; } static void inlink(char **fields, int nfields) { struct link l; if (nfields != LINK_FIELDS) { error("wrong number of fields on Link line"); return; } if (*fields[LF_FROM] == '\0') { error("blank FROM field on Link line"); return; } if (*fields[LF_TO] == '\0') { error("blank TO field on Link line"); return; } l.l_filename = filename; l.l_linenum = linenum; l.l_from = ecpyalloc(fields[LF_FROM]); l.l_to = ecpyalloc(fields[LF_TO]); links = (struct link *) erealloc((char *) links, (nlinks + 1) * sizeof *links); links[nlinks++] = l; } static void rulesub(struct rule *rp, char *loyearp, char *hiyearp, char *typep, char *monthp, char *dayp, char *timep) { register struct lookup * lp; register char * cp; if ((lp = byword(monthp, mon_names)) == NULL) { error("invalid month name"); return; } rp->r_month = lp->l_value; rp->r_todisstd = FALSE; cp = timep; if (*cp != '\0') { cp += strlen(cp) - 1; switch (lowerit(*cp)) { case 's': rp->r_todisstd = TRUE; *cp = '\0'; break; case 'w': rp->r_todisstd = FALSE; *cp = '\0'; break; } } rp->r_tod = gethms(timep, "invalid time of day", FALSE); /* ** Year work. */ cp = loyearp; if ((lp = byword(cp, begin_years)) != NULL) switch ((int) lp->l_value) { case YR_MINIMUM: rp->r_loyear = min_year; break; case YR_MAXIMUM: rp->r_loyear = max_year; break; default: /* "cannot happen" */ (void) fprintf(stderr, "%s: panic: Invalid l_value %d\n", progname, lp->l_value); exit(1); } else if (sscanf(cp, scheck(cp, "%d"), &rp->r_loyear) != 1 || rp->r_loyear < min_year || rp->r_loyear > max_year) { if (noise) error("invalid starting year"); if (rp->r_loyear > max_year) return; } cp = hiyearp; if ((lp = byword(cp, end_years)) != NULL) switch ((int) lp->l_value) { case YR_MINIMUM: rp->r_hiyear = min_year; break; case YR_MAXIMUM: rp->r_hiyear = max_year; break; case YR_ONLY: rp->r_hiyear = rp->r_loyear; break; default: /* "cannot happen" */ (void) fprintf(stderr, "%s: panic: Invalid l_value %d\n", progname, lp->l_value); exit(1); } else if (sscanf(cp, scheck(cp, "%d"), &rp->r_hiyear) != 1 || rp->r_hiyear < min_year || rp->r_hiyear > max_year) { if (noise) error("invalid ending year"); if (rp->r_hiyear < min_year) return; } if (rp->r_hiyear < min_year) return; if (rp->r_loyear < min_year) rp->r_loyear = min_year; if (rp->r_hiyear > max_year) rp->r_hiyear = max_year; if (rp->r_loyear > rp->r_hiyear) { error("starting year greater than ending year"); return; } if (*typep == '\0') rp->r_yrtype = NULL; else { if (rp->r_loyear == rp->r_hiyear) { error("typed single year"); return; } rp->r_yrtype = ecpyalloc(typep); } /* ** Day work. ** Accept things such as: ** 1 ** last-Sunday ** Sun<=20 ** Sun>=7 */ if ((lp = byword(dayp, lasts)) != NULL) { rp->r_dycode = DC_DOWLEQ; rp->r_wday = lp->l_value; rp->r_dayofmonth = len_months[1][rp->r_month]; } else { if ((cp = index(dayp, '<')) != 0) rp->r_dycode = DC_DOWLEQ; else if ((cp = index(dayp, '>')) != 0) rp->r_dycode = DC_DOWGEQ; else { cp = dayp; rp->r_dycode = DC_DOM; } if (rp->r_dycode != DC_DOM) { *cp++ = 0; if (*cp++ != '=') { error("invalid day of month"); return; } if ((lp = byword(dayp, wday_names)) == NULL) { error("invalid weekday name"); return; } rp->r_wday = lp->l_value; } if (sscanf(cp, scheck(cp, "%d"), &rp->r_dayofmonth) != 1 || rp->r_dayofmonth <= 0 || (rp->r_dayofmonth > len_months[1][rp->r_month])) { error("invalid day of month"); return; } } } static void puttzcode(long val, FILE *fp) { register int c; register int shift; for (shift = 24; shift >= 0; shift -= 8) { c = val >> shift; (void) putc(c, fp); } } static void writezone(char *name) { register FILE * fp; register int i; char fullname[BUFSIZ]; if (strlen(directory) + 1 + strlen(name) >= sizeof fullname) { (void) fprintf(stderr, "%s: File name %s/%s too long\n", progname, directory, name); exit(1); } (void)snprintf(fullname, sizeof(fullname), "%s/%s", directory, name); if ((fp = fopen(fullname, "w")) == NULL) { if (mkdirs(fullname) != 0) exit(1); if ((fp = fopen(fullname, "w")) == NULL) { (void) fprintf(stderr, "%s: Can't create ", progname); perror(fullname); exit(1); } } (void) fseek(fp, (long) sizeof ((struct tzhead *) 0)->tzh_reserved, 0); puttzcode(eitol(timecnt), fp); puttzcode(eitol(typecnt), fp); puttzcode(eitol(charcnt), fp); for (i = 0; i < timecnt; ++i) puttzcode((long) ats[i], fp); if (timecnt > 0) (void) fwrite((char *) types, sizeof types[0], (int) timecnt, fp); for (i = 0; i < typecnt; ++i) { puttzcode((long) gmtoffs[i], fp); (void) putc(isdsts[i], fp); (void) putc(abbrinds[i], fp); } if (charcnt != 0) (void) fwrite(chars, sizeof chars[0], (int) charcnt, fp); if (ferror(fp) || fclose(fp)) { (void) fprintf(stderr, "%s: Write error on ", progname); perror(fullname); exit(1); } } static void outzone(struct zone *zpfirst, int zonecount) { register struct zone * zp; register struct rule * rp; register int i, j; register int usestart, useuntil; register time_t starttime = 0, untiltime = 0; register long gmtoff; register long stdoff; register int year; register long startoff = 0; register int startisdst; register int type; char startbuf[BUFSIZ]; /* ** Now. . .finally. . .generate some useful data! */ timecnt = 0; typecnt = 0; charcnt = 0; /* ** Two guesses. . .the second may well be corrected later. */ gmtoff = zpfirst->z_gmtoff; stdoff = 0; for (i = 0; i < zonecount; ++i) { usestart = i > 0; useuntil = i < (zonecount - 1); zp = &zpfirst[i]; eat(zp->z_filename, zp->z_linenum); startisdst = -1; if (zp->z_nrules == 0) { type = addtype(oadd(zp->z_gmtoff, zp->z_stdoff), zp->z_format, zp->z_stdoff != 0); if (usestart) addtt(starttime, type); gmtoff = zp->z_gmtoff; stdoff = zp->z_stdoff; } else for (year = min_year; year <= max_year; ++year) { if (useuntil && year > zp->z_untilrule.r_hiyear) break; /* ** Mark which rules to do in the current year. ** For those to do, calculate rpytime(rp, year); */ for (j = 0; j < zp->z_nrules; ++j) { rp = &zp->z_rules[j]; eats(zp->z_filename, zp->z_linenum, rp->r_filename, rp->r_linenum); rp->r_todo = year >= rp->r_loyear && year <= rp->r_hiyear && yearistype(year, rp->r_yrtype); if (rp->r_todo) rp->r_temp = rpytime(rp, year); } for ( ; ; ) { register int k; register time_t jtime, ktime = 0; register long offset; char buf[BUFSIZ]; if (useuntil) { /* ** Turn untiltime into GMT ** assuming the current gmtoff and ** stdoff values. */ offset = gmtoff; if (!zp->z_untilrule.r_todisstd) offset = oadd(offset, stdoff); untiltime = tadd(zp->z_untiltime, -offset); } /* ** Find the rule (of those to do, if any) ** that takes effect earliest in the year. */ k = -1; for (j = 0; j < zp->z_nrules; ++j) { rp = &zp->z_rules[j]; if (!rp->r_todo) continue; eats(zp->z_filename, zp->z_linenum, rp->r_filename, rp->r_linenum); offset = gmtoff; if (!rp->r_todisstd) offset = oadd(offset, stdoff); jtime = rp->r_temp; if (jtime == min_time || jtime == max_time) continue; jtime = tadd(jtime, -offset); if (k < 0 || jtime < ktime) { k = j; ktime = jtime; } } if (k < 0) break; /* go on to next year */ rp = &zp->z_rules[k]; rp->r_todo = FALSE; if (useuntil && ktime >= untiltime) break; if (usestart) { if (ktime < starttime) { stdoff = rp->r_stdoff; startoff = oadd(zp->z_gmtoff, rp->r_stdoff); (void)snprintf(startbuf, sizeof(startbuf), zp->z_format, rp->r_abbrvar); startisdst = rp->r_stdoff != 0; continue; } if (ktime != starttime && startisdst >= 0) addtt(starttime, addtype(startoff, startbuf, startisdst)); usestart = FALSE; } eats(zp->z_filename, zp->z_linenum, rp->r_filename, rp->r_linenum); (void)snprintf(buf, sizeof(buf), zp->z_format, rp->r_abbrvar); offset = oadd(zp->z_gmtoff, rp->r_stdoff); type = addtype(offset, buf, rp->r_stdoff != 0); if (timecnt != 0 || rp->r_stdoff != 0) addtt(ktime, type); gmtoff = zp->z_gmtoff; stdoff = rp->r_stdoff; } } /* ** Now we may get to set starttime for the next zone line. */ if (useuntil) starttime = tadd(zp->z_untiltime, -gmtoffs[types[timecnt - 1]]); } writezone(zpfirst->z_name); } static void addtt(time_t starttime, int type) { if (timecnt != 0 && type == types[timecnt - 1]) return; /* easy enough! */ if (timecnt >= TZ_MAX_TIMES) { error("too many transitions?!"); exit(1); } ats[timecnt] = starttime; types[timecnt] = type; ++timecnt; } static int addtype(long gmtoff, char *abbr, int isdst) { register int i, j; /* ** See if there's already an entry for this zone type. ** If so, just return its index. */ for (i = 0; i < typecnt; ++i) { if (gmtoff == gmtoffs[i] && isdst == isdsts[i] && strcmp(abbr, &chars[(int)abbrinds[i]]) == 0) return i; } /* ** There isn't one; add a new one, unless there are already too ** many. */ if (typecnt >= TZ_MAX_TYPES) { error("too many local time types"); exit(1); } gmtoffs[i] = gmtoff; isdsts[i] = isdst; for (j = 0; j < charcnt; ++j) if (strcmp(&chars[j], abbr) == 0) break; if (j == charcnt) newabbr(abbr); abbrinds[i] = j; ++typecnt; return i; } static int yearistype(int year, char *type) { char buf[BUFSIZ]; int result; if (type == NULL || *type == '\0') return TRUE; if (strcmp(type, "uspres") == 0) return (year % 4) == 0; if (strcmp(type, "nonpres") == 0) return (year % 4) != 0; (void)snprintf(buf, sizeof(buf), "yearistype %d %s", year, type); result = system(buf); if (result == 0) return TRUE; if (result == 1 << 8) return FALSE; error("Wild result from command execution"); (void) fprintf(stderr, "%s: command was '%s', result was %d\n", progname, buf, result); for ( ; ; ) exit(1); } static int lowerit(int a) { return (isascii(a) && isupper(a)) ? tolower(a) : a; } static int ciequal(char *ap, char *bp) /* case-insensitive equality */ { while (lowerit(*ap) == lowerit(*bp++)) if (*ap++ == '\0') return TRUE; return FALSE; } static int isabbr(char *abbr, char *word) { if (lowerit(*abbr) != lowerit(*word)) return FALSE; ++word; while (*++abbr != '\0') do if (*word == '\0') return FALSE; while (lowerit(*word++) != lowerit(*abbr)); return TRUE; } static struct lookup * byword(char *word, struct lookup *table) { register struct lookup * foundlp; register struct lookup * lp; if (word == NULL || table == NULL) return NULL; /* ** Look for exact match. */ for (lp = table; lp->l_word != NULL; ++lp) if (ciequal(word, lp->l_word)) return lp; /* ** Look for inexact match. */ foundlp = NULL; for (lp = table; lp->l_word != NULL; ++lp) if (isabbr(word, lp->l_word)) { if (foundlp == NULL) foundlp = lp; else return NULL; /* multiple inexact matches */ } return foundlp; } static char ** getfields(char *cp) { register char * dp; register char ** array; register int nsubs; if (cp == NULL) return NULL; array = (char **) emalloc((strlen(cp) + 1) * sizeof *array); nsubs = 0; for ( ; ; ) { while (isascii(*cp) && isspace(*cp)) ++cp; if (*cp == '\0' || *cp == '#') break; array[nsubs++] = dp = cp; do { if ((*dp = *cp++) != '"') ++dp; else while ((*dp = *cp++) != '"') if (*dp != '\0') ++dp; else error("Odd number of quotation marks"); } while (*cp != '\0' && *cp != '#' && (!isascii(*cp) || !isspace(*cp))); if (isascii(*cp) && isspace(*cp)) ++cp; *dp = '\0'; } array[nsubs] = NULL; return array; } static long oadd(long t1, long t2) { register long t; t = t1 + t2; if ((t2 > 0 && t <= t1) || (t2 < 0 && t >= t1)) { error("time overflow"); exit(1); } return t; } static time_t tadd(time_t t1, long t2) { register time_t t; if (t1 == max_time && t2 > 0) return max_time; if (t1 == min_time && t2 < 0) return min_time; t = t1 + t2; if ((t2 > 0 && t <= t1) || (t2 < 0 && t >= t1)) { error("time overflow"); exit(1); } return t; } /* ** Given a rule, and a year, compute the date - in seconds since January 1, ** 1970, 00:00 LOCAL time - in that year that the rule refers to. */ static time_t rpytime(struct rule *rp, int wantedy) { register int y, m, i; register long dayoff; /* with a nod to Margaret O. */ register time_t t; dayoff = 0; m = TM_JANUARY; y = EPOCH_YEAR; while (wantedy != y) { if (wantedy > y) { i = len_years[isleap(y)]; ++y; } else { --y; i = -len_years[isleap(y)]; } dayoff = oadd(dayoff, eitol(i)); } while (m != rp->r_month) { i = len_months[isleap(y)][m]; dayoff = oadd(dayoff, eitol(i)); ++m; } i = rp->r_dayofmonth; if (m == TM_FEBRUARY && i == 29 && !isleap(y)) { if (rp->r_dycode == DC_DOWLEQ) --i; else { error("use of 2/29 in non leap-year"); exit(1); } } --i; dayoff = oadd(dayoff, eitol(i)); if (rp->r_dycode == DC_DOWGEQ || rp->r_dycode == DC_DOWLEQ) { register long wday; #define LDAYS_PER_WEEK ((long) DAYS_PER_WEEK) wday = eitol(EPOCH_WDAY); /* ** Don't trust mod of negative numbers. */ if (dayoff >= 0) wday = (wday + dayoff) % LDAYS_PER_WEEK; else { wday -= ((-dayoff) % LDAYS_PER_WEEK); if (wday < 0) wday += LDAYS_PER_WEEK; } while (wday != eitol(rp->r_wday)) if (rp->r_dycode == DC_DOWGEQ) { dayoff = oadd(dayoff, (long) 1); if (++wday >= LDAYS_PER_WEEK) wday = 0; ++i; } else { dayoff = oadd(dayoff, (long) -1); if (--wday < 0) wday = LDAYS_PER_WEEK; --i; } if (i < 0 || i >= len_months[isleap(y)][m]) { error("no day in month matches rule"); exit(1); } } if (dayoff < 0 && !tt_signed) { if (wantedy == rp->r_loyear) return min_time; error("time before zero"); exit(1); } t = (time_t) dayoff * SECS_PER_DAY; /* ** Cheap overflow check. */ if (t / SECS_PER_DAY != dayoff) { if (wantedy == rp->r_hiyear) return max_time; if (wantedy == rp->r_loyear) return min_time; error("time overflow"); exit(1); } return tadd(t, rp->r_tod); } static void newabbr(char *string) { register int i; i = strlen(string) + 1; if (charcnt + i >= TZ_MAX_CHARS) { error("too many, or too long, time zone abbreviations"); exit(1); } (void)strlcpy(&chars[charcnt], string, sizeof(chars) - charcnt); charcnt += eitol(i); } static int mkdirs(char *name) { register char * cp; if ((cp = name) == NULL || *cp == '\0') return 0; while ((cp = index(cp + 1,'/')) != 0) { *cp = '\0'; if (access(name,F_OK) && mkdir(name,0755)) { perror(name); return -1; } *cp = '/'; } return 0; } static long eitol(int i) { long l; l = i; if ((i < 0 && l >= 0) || (i == 0 && l != 0) || (i > 0 && l <= 0)) { (void) fprintf(stderr, "%s: %d did not sign extend correctly\n", progname, i); exit(1); } return l; } /* ** UNIX is a registered trademark of AT&T. */ ================================================ FILE: sys/arch/arm/include/cmsis_gcc.h ================================================ /**************************************************************************//** * @file cmsis_gcc.h * @brief CMSIS Cortex-M Core Function/Instruction Header File * @version V4.30 * @date 20. October 2015 ******************************************************************************/ /* Copyright (c) 2009 - 2015 ARM LIMITED All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - Neither the name of ARM nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ---------------------------------------------------------------------------*/ #ifndef __CMSIS_GCC_H #define __CMSIS_GCC_H /* ignore some GCC warnings */ #if defined ( __GNUC__ ) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wsign-conversion" #pragma GCC diagnostic ignored "-Wconversion" #pragma GCC diagnostic ignored "-Wunused-parameter" #endif /* ########################### Core Function Access ########################### */ /** \ingroup CMSIS_Core_FunctionInterface \defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions @{ */ /** \brief Enable IRQ Interrupts \details Enables IRQ interrupts by clearing the I-bit in the CPSR. Can only be executed in Privileged modes. */ __attribute__( ( always_inline ) ) __STATIC_INLINE void __enable_irq(void) { __ASM volatile ("cpsie i" : : : "memory"); } /** \brief Disable IRQ Interrupts \details Disables IRQ interrupts by setting the I-bit in the CPSR. Can only be executed in Privileged modes. */ __attribute__( ( always_inline ) ) __STATIC_INLINE void __disable_irq(void) { __ASM volatile ("cpsid i" : : : "memory"); } /** \brief Get Control Register \details Returns the content of the Control Register. \return Control Register value */ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_CONTROL(void) { uint32_t result; __ASM volatile ("MRS %0, control" : "=r" (result) ); return(result); } /** \brief Set Control Register \details Writes the given value to the Control Register. \param [in] control Control Register value to set */ __attribute__( ( always_inline ) ) __STATIC_INLINE void __set_CONTROL(uint32_t control) { __ASM volatile ("MSR control, %0" : : "r" (control) : "memory"); } /** \brief Get IPSR Register \details Returns the content of the IPSR Register. \return IPSR Register value */ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_IPSR(void) { uint32_t result; __ASM volatile ("MRS %0, ipsr" : "=r" (result) ); return(result); } /** \brief Get APSR Register \details Returns the content of the APSR Register. \return APSR Register value */ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_APSR(void) { uint32_t result; __ASM volatile ("MRS %0, apsr" : "=r" (result) ); return(result); } /** \brief Get xPSR Register \details Returns the content of the xPSR Register. \return xPSR Register value */ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_xPSR(void) { uint32_t result; __ASM volatile ("MRS %0, xpsr" : "=r" (result) ); return(result); } /** \brief Get Process Stack Pointer \details Returns the current value of the Process Stack Pointer (PSP). \return PSP Register value */ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_PSP(void) { register uint32_t result; __ASM volatile ("MRS %0, psp\n" : "=r" (result) ); return(result); } /** \brief Set Process Stack Pointer \details Assigns the given value to the Process Stack Pointer (PSP). \param [in] topOfProcStack Process Stack Pointer value to set */ __attribute__( ( always_inline ) ) __STATIC_INLINE void __set_PSP(uint32_t topOfProcStack) { __ASM volatile ("MSR psp, %0\n" : : "r" (topOfProcStack) : "sp"); } /** \brief Get Main Stack Pointer \details Returns the current value of the Main Stack Pointer (MSP). \return MSP Register value */ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_MSP(void) { register uint32_t result; __ASM volatile ("MRS %0, msp\n" : "=r" (result) ); return(result); } /** \brief Set Main Stack Pointer \details Assigns the given value to the Main Stack Pointer (MSP). \param [in] topOfMainStack Main Stack Pointer value to set */ __attribute__( ( always_inline ) ) __STATIC_INLINE void __set_MSP(uint32_t topOfMainStack) { __ASM volatile ("MSR msp, %0\n" : : "r" (topOfMainStack) : "sp"); } /** \brief Get Priority Mask \details Returns the current state of the priority mask bit from the Priority Mask Register. \return Priority Mask value */ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_PRIMASK(void) { uint32_t result; __ASM volatile ("MRS %0, primask" : "=r" (result) ); return(result); } /** \brief Set Priority Mask \details Assigns the given value to the Priority Mask Register. \param [in] priMask Priority Mask */ __attribute__( ( always_inline ) ) __STATIC_INLINE void __set_PRIMASK(uint32_t priMask) { __ASM volatile ("MSR primask, %0" : : "r" (priMask) : "memory"); } #if (__CORTEX_M >= 0x03U) /** \brief Enable FIQ \details Enables FIQ interrupts by clearing the F-bit in the CPSR. Can only be executed in Privileged modes. */ __attribute__( ( always_inline ) ) __STATIC_INLINE void __enable_fault_irq(void) { __ASM volatile ("cpsie f" : : : "memory"); } /** \brief Disable FIQ \details Disables FIQ interrupts by setting the F-bit in the CPSR. Can only be executed in Privileged modes. */ __attribute__( ( always_inline ) ) __STATIC_INLINE void __disable_fault_irq(void) { __ASM volatile ("cpsid f" : : : "memory"); } /** \brief Get Base Priority \details Returns the current value of the Base Priority register. \return Base Priority register value */ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_BASEPRI(void) { uint32_t result; __ASM volatile ("MRS %0, basepri" : "=r" (result) ); return(result); } /** \brief Set Base Priority \details Assigns the given value to the Base Priority register. \param [in] basePri Base Priority value to set */ __attribute__( ( always_inline ) ) __STATIC_INLINE void __set_BASEPRI(uint32_t value) { __ASM volatile ("MSR basepri, %0" : : "r" (value) : "memory"); } /** \brief Set Base Priority with condition \details Assigns the given value to the Base Priority register only if BASEPRI masking is disabled, or the new value increases the BASEPRI priority level. \param [in] basePri Base Priority value to set */ __attribute__( ( always_inline ) ) __STATIC_INLINE void __set_BASEPRI_MAX(uint32_t value) { __ASM volatile ("MSR basepri_max, %0" : : "r" (value) : "memory"); } /** \brief Get Fault Mask \details Returns the current value of the Fault Mask register. \return Fault Mask register value */ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_FAULTMASK(void) { uint32_t result; __ASM volatile ("MRS %0, faultmask" : "=r" (result) ); return(result); } /** \brief Set Fault Mask \details Assigns the given value to the Fault Mask register. \param [in] faultMask Fault Mask value to set */ __attribute__( ( always_inline ) ) __STATIC_INLINE void __set_FAULTMASK(uint32_t faultMask) { __ASM volatile ("MSR faultmask, %0" : : "r" (faultMask) : "memory"); } #endif /* (__CORTEX_M >= 0x03U) */ #if (__CORTEX_M == 0x04U) || (__CORTEX_M == 0x07U) /** \brief Get FPSCR \details Returns the current value of the Floating Point Status/Control register. \return Floating Point Status/Control register value */ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_FPSCR(void) { #if (__FPU_PRESENT == 1U) && (__FPU_USED == 1U) uint32_t result; /* Empty asm statement works as a scheduling barrier */ __ASM volatile (""); __ASM volatile ("VMRS %0, fpscr" : "=r" (result) ); __ASM volatile (""); return(result); #else return(0); #endif } /** \brief Set FPSCR \details Assigns the given value to the Floating Point Status/Control register. \param [in] fpscr Floating Point Status/Control value to set */ __attribute__( ( always_inline ) ) __STATIC_INLINE void __set_FPSCR(uint32_t fpscr) { #if (__FPU_PRESENT == 1U) && (__FPU_USED == 1U) /* Empty asm statement works as a scheduling barrier */ __ASM volatile (""); __ASM volatile ("VMSR fpscr, %0" : : "r" (fpscr) : "vfpcc"); __ASM volatile (""); #endif } #endif /* (__CORTEX_M == 0x04U) || (__CORTEX_M == 0x07U) */ /*@} end of CMSIS_Core_RegAccFunctions */ /* ########################## Core Instruction Access ######################### */ /** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface Access to dedicated instructions @{ */ /* Define macros for porting to both thumb1 and thumb2. * For thumb1, use low register (r0-r7), specified by constraint "l" * Otherwise, use general registers, specified by constraint "r" */ #if defined (__thumb__) && !defined (__thumb2__) #define __CMSIS_GCC_OUT_REG(r) "=l" (r) #define __CMSIS_GCC_USE_REG(r) "l" (r) #else #define __CMSIS_GCC_OUT_REG(r) "=r" (r) #define __CMSIS_GCC_USE_REG(r) "r" (r) #endif /** \brief No Operation \details No Operation does nothing. This instruction can be used for code alignment purposes. */ __attribute__((always_inline)) __STATIC_INLINE void __NOP(void) { __ASM volatile ("nop"); } /** \brief Wait For Interrupt \details Wait For Interrupt is a hint instruction that suspends execution until one of a number of events occurs. */ __attribute__((always_inline)) __STATIC_INLINE void __WFI(void) { __ASM volatile ("wfi"); } /** \brief Wait For Event \details Wait For Event is a hint instruction that permits the processor to enter a low-power state until one of a number of events occurs. */ __attribute__((always_inline)) __STATIC_INLINE void __WFE(void) { __ASM volatile ("wfe"); } /** \brief Send Event \details Send Event is a hint instruction. It causes an event to be signaled to the CPU. */ __attribute__((always_inline)) __STATIC_INLINE void __SEV(void) { __ASM volatile ("sev"); } /** \brief Instruction Synchronization Barrier \details Instruction Synchronization Barrier flushes the pipeline in the processor, so that all instructions following the ISB are fetched from cache or memory, after the instruction has been completed. */ __attribute__((always_inline)) __STATIC_INLINE void __ISB(void) { __ASM volatile ("isb 0xF":::"memory"); } /** \brief Data Synchronization Barrier \details Acts as a special kind of Data Memory Barrier. It completes when all explicit memory accesses before this instruction complete. */ __attribute__((always_inline)) __STATIC_INLINE void __DSB(void) { __ASM volatile ("dsb 0xF":::"memory"); } /** \brief Data Memory Barrier \details Ensures the apparent order of the explicit memory operations before and after the instruction, without ensuring their completion. */ __attribute__((always_inline)) __STATIC_INLINE void __DMB(void) { __ASM volatile ("dmb 0xF":::"memory"); } /** \brief Reverse byte order (32 bit) \details Reverses the byte order in integer value. \param [in] value Value to reverse \return Reversed value */ __attribute__((always_inline)) __STATIC_INLINE uint32_t __REV(uint32_t value) { #if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5) return __builtin_bswap32(value); #else uint32_t result; __ASM volatile ("rev %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) ); return(result); #endif } /** \brief Reverse byte order (16 bit) \details Reverses the byte order in two unsigned short values. \param [in] value Value to reverse \return Reversed value */ __attribute__((always_inline)) __STATIC_INLINE uint32_t __REV16(uint32_t value) { uint32_t result; __ASM volatile ("rev16 %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) ); return(result); } /** \brief Reverse byte order in signed short value \details Reverses the byte order in a signed short value with sign extension to integer. \param [in] value Value to reverse \return Reversed value */ __attribute__((always_inline)) __STATIC_INLINE int32_t __REVSH(int32_t value) { #if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8) return (short)__builtin_bswap16(value); #else int32_t result; __ASM volatile ("revsh %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) ); return(result); #endif } /** \brief Rotate Right in unsigned value (32 bit) \details Rotate Right (immediate) provides the value of the contents of a register rotated by a variable number of bits. \param [in] value Value to rotate \param [in] value Number of Bits to rotate \return Rotated value */ __attribute__((always_inline)) __STATIC_INLINE uint32_t __ROR(uint32_t op1, uint32_t op2) { return (op1 >> op2) | (op1 << (32U - op2)); } /** \brief Breakpoint \details Causes the processor to enter Debug state. Debug tools can use this to investigate system state when the instruction at a particular address is reached. \param [in] value is ignored by the processor. If required, a debugger can use it to store additional information about the breakpoint. */ #define __BKPT(value) __ASM volatile ("bkpt "#value) /** \brief Reverse bit order of value \details Reverses the bit order of the given value. \param [in] value Value to reverse \return Reversed value */ __attribute__((always_inline)) __STATIC_INLINE uint32_t __RBIT(uint32_t value) { uint32_t result; #if (__CORTEX_M >= 0x03U) || (__CORTEX_SC >= 300U) __ASM volatile ("rbit %0, %1" : "=r" (result) : "r" (value) ); #else int32_t s = 4 /*sizeof(v)*/ * 8 - 1; /* extra shift needed at end */ result = value; /* r will be reversed bits of v; first get LSB of v */ for (value >>= 1U; value; value >>= 1U) { result <<= 1U; result |= value & 1U; s--; } result <<= s; /* shift when v's highest bits are zero */ #endif return(result); } /** \brief Count leading zeros \details Counts the number of leading zeros of a data value. \param [in] value Value to count the leading zeros \return number of leading zeros in value */ #define __CLZ __builtin_clz #if (__CORTEX_M >= 0x03U) || (__CORTEX_SC >= 300U) /** \brief LDR Exclusive (8 bit) \details Executes a exclusive LDR instruction for 8 bit value. \param [in] ptr Pointer to data \return value of type uint8_t at (*ptr) */ __attribute__((always_inline)) __STATIC_INLINE uint8_t __LDREXB(volatile uint8_t *addr) { uint32_t result; #if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8) __ASM volatile ("ldrexb %0, %1" : "=r" (result) : "Q" (*addr) ); #else /* Prior to GCC 4.8, "Q" will be expanded to [rx, #0] which is not accepted by assembler. So has to use following less efficient pattern. */ __ASM volatile ("ldrexb %0, [%1]" : "=r" (result) : "r" (addr) : "memory" ); #endif return ((uint8_t) result); /* Add explicit type cast here */ } /** \brief LDR Exclusive (16 bit) \details Executes a exclusive LDR instruction for 16 bit values. \param [in] ptr Pointer to data \return value of type uint16_t at (*ptr) */ __attribute__((always_inline)) __STATIC_INLINE uint16_t __LDREXH(volatile uint16_t *addr) { uint32_t result; #if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8) __ASM volatile ("ldrexh %0, %1" : "=r" (result) : "Q" (*addr) ); #else /* Prior to GCC 4.8, "Q" will be expanded to [rx, #0] which is not accepted by assembler. So has to use following less efficient pattern. */ __ASM volatile ("ldrexh %0, [%1]" : "=r" (result) : "r" (addr) : "memory" ); #endif return ((uint16_t) result); /* Add explicit type cast here */ } /** \brief LDR Exclusive (32 bit) \details Executes a exclusive LDR instruction for 32 bit values. \param [in] ptr Pointer to data \return value of type uint32_t at (*ptr) */ __attribute__((always_inline)) __STATIC_INLINE uint32_t __LDREXW(volatile uint32_t *addr) { uint32_t result; __ASM volatile ("ldrex %0, %1" : "=r" (result) : "Q" (*addr) ); return(result); } /** \brief STR Exclusive (8 bit) \details Executes a exclusive STR instruction for 8 bit values. \param [in] value Value to store \param [in] ptr Pointer to location \return 0 Function succeeded \return 1 Function failed */ __attribute__((always_inline)) __STATIC_INLINE uint32_t __STREXB(uint8_t value, volatile uint8_t *addr) { uint32_t result; __ASM volatile ("strexb %0, %2, %1" : "=&r" (result), "=Q" (*addr) : "r" ((uint32_t)value) ); return(result); } /** \brief STR Exclusive (16 bit) \details Executes a exclusive STR instruction for 16 bit values. \param [in] value Value to store \param [in] ptr Pointer to location \return 0 Function succeeded \return 1 Function failed */ __attribute__((always_inline)) __STATIC_INLINE uint32_t __STREXH(uint16_t value, volatile uint16_t *addr) { uint32_t result; __ASM volatile ("strexh %0, %2, %1" : "=&r" (result), "=Q" (*addr) : "r" ((uint32_t)value) ); return(result); } /** \brief STR Exclusive (32 bit) \details Executes a exclusive STR instruction for 32 bit values. \param [in] value Value to store \param [in] ptr Pointer to location \return 0 Function succeeded \return 1 Function failed */ __attribute__((always_inline)) __STATIC_INLINE uint32_t __STREXW(uint32_t value, volatile uint32_t *addr) { uint32_t result; __ASM volatile ("strex %0, %2, %1" : "=&r" (result), "=Q" (*addr) : "r" (value) ); return(result); } /** \brief Remove the exclusive lock \details Removes the exclusive lock which is created by LDREX. */ __attribute__((always_inline)) __STATIC_INLINE void __CLREX(void) { __ASM volatile ("clrex" ::: "memory"); } /** \brief Signed Saturate \details Saturates a signed value. \param [in] value Value to be saturated \param [in] sat Bit position to saturate to (1..32) \return Saturated value */ #define __SSAT(ARG1,ARG2) \ ({ \ uint32_t __RES, __ARG1 = (ARG1); \ __ASM ("ssat %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \ __RES; \ }) /** \brief Unsigned Saturate \details Saturates an unsigned value. \param [in] value Value to be saturated \param [in] sat Bit position to saturate to (0..31) \return Saturated value */ #define __USAT(ARG1,ARG2) \ ({ \ uint32_t __RES, __ARG1 = (ARG1); \ __ASM ("usat %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \ __RES; \ }) /** \brief Rotate Right with Extend (32 bit) \details Moves each bit of a bitstring right by one bit. The carry input is shifted in at the left end of the bitstring. \param [in] value Value to rotate \return Rotated value */ __attribute__((always_inline)) __STATIC_INLINE uint32_t __RRX(uint32_t value) { uint32_t result; __ASM volatile ("rrx %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) ); return(result); } /** \brief LDRT Unprivileged (8 bit) \details Executes a Unprivileged LDRT instruction for 8 bit value. \param [in] ptr Pointer to data \return value of type uint8_t at (*ptr) */ __attribute__((always_inline)) __STATIC_INLINE uint8_t __LDRBT(volatile uint8_t *addr) { uint32_t result; #if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8) __ASM volatile ("ldrbt %0, %1" : "=r" (result) : "Q" (*addr) ); #else /* Prior to GCC 4.8, "Q" will be expanded to [rx, #0] which is not accepted by assembler. So has to use following less efficient pattern. */ __ASM volatile ("ldrbt %0, [%1]" : "=r" (result) : "r" (addr) : "memory" ); #endif return ((uint8_t) result); /* Add explicit type cast here */ } /** \brief LDRT Unprivileged (16 bit) \details Executes a Unprivileged LDRT instruction for 16 bit values. \param [in] ptr Pointer to data \return value of type uint16_t at (*ptr) */ __attribute__((always_inline)) __STATIC_INLINE uint16_t __LDRHT(volatile uint16_t *addr) { uint32_t result; #if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8) __ASM volatile ("ldrht %0, %1" : "=r" (result) : "Q" (*addr) ); #else /* Prior to GCC 4.8, "Q" will be expanded to [rx, #0] which is not accepted by assembler. So has to use following less efficient pattern. */ __ASM volatile ("ldrht %0, [%1]" : "=r" (result) : "r" (addr) : "memory" ); #endif return ((uint16_t) result); /* Add explicit type cast here */ } /** \brief LDRT Unprivileged (32 bit) \details Executes a Unprivileged LDRT instruction for 32 bit values. \param [in] ptr Pointer to data \return value of type uint32_t at (*ptr) */ __attribute__((always_inline)) __STATIC_INLINE uint32_t __LDRT(volatile uint32_t *addr) { uint32_t result; __ASM volatile ("ldrt %0, %1" : "=r" (result) : "Q" (*addr) ); return(result); } /** \brief STRT Unprivileged (8 bit) \details Executes a Unprivileged STRT instruction for 8 bit values. \param [in] value Value to store \param [in] ptr Pointer to location */ __attribute__((always_inline)) __STATIC_INLINE void __STRBT(uint8_t value, volatile uint8_t *addr) { __ASM volatile ("strbt %1, %0" : "=Q" (*addr) : "r" ((uint32_t)value) ); } /** \brief STRT Unprivileged (16 bit) \details Executes a Unprivileged STRT instruction for 16 bit values. \param [in] value Value to store \param [in] ptr Pointer to location */ __attribute__((always_inline)) __STATIC_INLINE void __STRHT(uint16_t value, volatile uint16_t *addr) { __ASM volatile ("strht %1, %0" : "=Q" (*addr) : "r" ((uint32_t)value) ); } /** \brief STRT Unprivileged (32 bit) \details Executes a Unprivileged STRT instruction for 32 bit values. \param [in] value Value to store \param [in] ptr Pointer to location */ __attribute__((always_inline)) __STATIC_INLINE void __STRT(uint32_t value, volatile uint32_t *addr) { __ASM volatile ("strt %1, %0" : "=Q" (*addr) : "r" (value) ); } #endif /* (__CORTEX_M >= 0x03U) || (__CORTEX_SC >= 300U) */ /*@}*/ /* end of group CMSIS_Core_InstructionInterface */ /* ################### Compiler specific Intrinsics ########################### */ /** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics Access to dedicated SIMD instructions @{ */ #if (__CORTEX_M >= 0x04U) /* only for Cortex-M4 and above */ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SADD8(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("sadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __QADD8(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("qadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SHADD8(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("shadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UADD8(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("uadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UQADD8(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("uqadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UHADD8(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("uhadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SSUB8(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("ssub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __QSUB8(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("qsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SHSUB8(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("shsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __USUB8(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("usub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UQSUB8(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("uqsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UHSUB8(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("uhsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SADD16(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("sadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __QADD16(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("qadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SHADD16(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("shadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UADD16(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("uadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UQADD16(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("uqadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UHADD16(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("uhadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SSUB16(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("ssub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __QSUB16(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("qsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SHSUB16(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("shsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __USUB16(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("usub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UQSUB16(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("uqsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UHSUB16(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("uhsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SASX(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("sasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __QASX(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("qasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SHASX(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("shasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UASX(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("uasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UQASX(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("uqasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UHASX(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("uhasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SSAX(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("ssax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __QSAX(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("qsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SHSAX(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("shsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __USAX(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("usax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UQSAX(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("uqsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UHSAX(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("uhsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __USAD8(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("usad8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __USADA8(uint32_t op1, uint32_t op2, uint32_t op3) { uint32_t result; __ASM volatile ("usada8 %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); return(result); } #define __SSAT16(ARG1,ARG2) \ ({ \ int32_t __RES, __ARG1 = (ARG1); \ __ASM ("ssat16 %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \ __RES; \ }) #define __USAT16(ARG1,ARG2) \ ({ \ uint32_t __RES, __ARG1 = (ARG1); \ __ASM ("usat16 %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \ __RES; \ }) __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UXTB16(uint32_t op1) { uint32_t result; __ASM volatile ("uxtb16 %0, %1" : "=r" (result) : "r" (op1)); return(result); } __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UXTAB16(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("uxtab16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SXTB16(uint32_t op1) { uint32_t result; __ASM volatile ("sxtb16 %0, %1" : "=r" (result) : "r" (op1)); return(result); } __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SXTAB16(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("sxtab16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SMUAD (uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("smuad %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SMUADX (uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("smuadx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SMLAD (uint32_t op1, uint32_t op2, uint32_t op3) { uint32_t result; __ASM volatile ("smlad %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); return(result); } __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SMLADX (uint32_t op1, uint32_t op2, uint32_t op3) { uint32_t result; __ASM volatile ("smladx %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); return(result); } __attribute__( ( always_inline ) ) __STATIC_INLINE uint64_t __SMLALD (uint32_t op1, uint32_t op2, uint64_t acc) { union llreg_u{ uint32_t w32[2]; uint64_t w64; } llr; llr.w64 = acc; #ifndef __ARMEB__ /* Little endian */ __ASM volatile ("smlald %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) ); #else /* Big endian */ __ASM volatile ("smlald %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) ); #endif return(llr.w64); } __attribute__( ( always_inline ) ) __STATIC_INLINE uint64_t __SMLALDX (uint32_t op1, uint32_t op2, uint64_t acc) { union llreg_u{ uint32_t w32[2]; uint64_t w64; } llr; llr.w64 = acc; #ifndef __ARMEB__ /* Little endian */ __ASM volatile ("smlaldx %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) ); #else /* Big endian */ __ASM volatile ("smlaldx %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) ); #endif return(llr.w64); } __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SMUSD (uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("smusd %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SMUSDX (uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("smusdx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SMLSD (uint32_t op1, uint32_t op2, uint32_t op3) { uint32_t result; __ASM volatile ("smlsd %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); return(result); } __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SMLSDX (uint32_t op1, uint32_t op2, uint32_t op3) { uint32_t result; __ASM volatile ("smlsdx %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); return(result); } __attribute__( ( always_inline ) ) __STATIC_INLINE uint64_t __SMLSLD (uint32_t op1, uint32_t op2, uint64_t acc) { union llreg_u{ uint32_t w32[2]; uint64_t w64; } llr; llr.w64 = acc; #ifndef __ARMEB__ /* Little endian */ __ASM volatile ("smlsld %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) ); #else /* Big endian */ __ASM volatile ("smlsld %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) ); #endif return(llr.w64); } __attribute__( ( always_inline ) ) __STATIC_INLINE uint64_t __SMLSLDX (uint32_t op1, uint32_t op2, uint64_t acc) { union llreg_u{ uint32_t w32[2]; uint64_t w64; } llr; llr.w64 = acc; #ifndef __ARMEB__ /* Little endian */ __ASM volatile ("smlsldx %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) ); #else /* Big endian */ __ASM volatile ("smlsldx %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) ); #endif return(llr.w64); } __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SEL (uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("sel %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __attribute__( ( always_inline ) ) __STATIC_INLINE int32_t __QADD( int32_t op1, int32_t op2) { int32_t result; __ASM volatile ("qadd %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __attribute__( ( always_inline ) ) __STATIC_INLINE int32_t __QSUB( int32_t op1, int32_t op2) { int32_t result; __ASM volatile ("qsub %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } #define __PKHBT(ARG1,ARG2,ARG3) \ ({ \ uint32_t __RES, __ARG1 = (ARG1), __ARG2 = (ARG2); \ __ASM ("pkhbt %0, %1, %2, lsl %3" : "=r" (__RES) : "r" (__ARG1), "r" (__ARG2), "I" (ARG3) ); \ __RES; \ }) #define __PKHTB(ARG1,ARG2,ARG3) \ ({ \ uint32_t __RES, __ARG1 = (ARG1), __ARG2 = (ARG2); \ if (ARG3 == 0) \ __ASM ("pkhtb %0, %1, %2" : "=r" (__RES) : "r" (__ARG1), "r" (__ARG2) ); \ else \ __ASM ("pkhtb %0, %1, %2, asr %3" : "=r" (__RES) : "r" (__ARG1), "r" (__ARG2), "I" (ARG3) ); \ __RES; \ }) __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SMMLA (int32_t op1, int32_t op2, int32_t op3) { int32_t result; __ASM volatile ("smmla %0, %1, %2, %3" : "=r" (result): "r" (op1), "r" (op2), "r" (op3) ); return(result); } #endif /* (__CORTEX_M >= 0x04) */ /*@} end of group CMSIS_SIMD_intrinsics */ #if defined ( __GNUC__ ) #pragma GCC diagnostic pop #endif #endif /* __CMSIS_GCC_H */ ================================================ FILE: sys/arch/arm/include/core_cm4.h ================================================ /**************************************************************************//** * @file core_cm4.h * @brief CMSIS Cortex-M4 Core Peripheral Access Layer Header File * @version V4.30 * @date 20. October 2015 ******************************************************************************/ /* Copyright (c) 2009 - 2015 ARM LIMITED All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - Neither the name of ARM nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ---------------------------------------------------------------------------*/ #if defined ( __ICCARM__ ) #pragma system_include /* treat file as system include file for MISRA check */ #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) #pragma clang system_header /* treat file as system include file */ #endif #ifndef __CORE_CM4_H_GENERIC #define __CORE_CM4_H_GENERIC #include #ifdef __cplusplus extern "C" { #endif /** \page CMSIS_MISRA_Exceptions MISRA-C:2004 Compliance Exceptions CMSIS violates the following MISRA-C:2004 rules: \li Required Rule 8.5, object/function definition in header file.
Function definitions in header files are used to allow 'inlining'. \li Required Rule 18.4, declaration of union type or object of union type: '{...}'.
Unions are used for effective representation of core registers. \li Advisory Rule 19.7, Function-like macro defined.
Function-like macros are used to allow more efficient code. */ /******************************************************************************* * CMSIS definitions ******************************************************************************/ /** \ingroup Cortex_M4 @{ */ /* CMSIS CM4 definitions */ #define __CM4_CMSIS_VERSION_MAIN (0x04U) /*!< [31:16] CMSIS HAL main version */ #define __CM4_CMSIS_VERSION_SUB (0x1EU) /*!< [15:0] CMSIS HAL sub version */ #define __CM4_CMSIS_VERSION ((__CM4_CMSIS_VERSION_MAIN << 16U) | \ __CM4_CMSIS_VERSION_SUB ) /*!< CMSIS HAL version number */ #define __CORTEX_M (0x04U) /*!< Cortex-M Core */ #if defined ( __CC_ARM ) #define __ASM __asm /*!< asm keyword for ARM Compiler */ #define __INLINE __inline /*!< inline keyword for ARM Compiler */ #define __STATIC_INLINE static __inline #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) #define __ASM __asm /*!< asm keyword for ARM Compiler */ #define __INLINE __inline /*!< inline keyword for ARM Compiler */ #define __STATIC_INLINE static __inline #elif defined ( __GNUC__ ) #define __ASM __asm /*!< asm keyword for GNU Compiler */ #define __INLINE inline /*!< inline keyword for GNU Compiler */ #define __STATIC_INLINE static inline #elif defined ( __ICCARM__ ) #define __ASM __asm /*!< asm keyword for IAR Compiler */ #define __INLINE inline /*!< inline keyword for IAR Compiler. Only available in High optimization mode! */ #define __STATIC_INLINE static inline #elif defined ( __TMS470__ ) #define __ASM __asm /*!< asm keyword for TI CCS Compiler */ #define __STATIC_INLINE static inline #elif defined ( __TASKING__ ) #define __ASM __asm /*!< asm keyword for TASKING Compiler */ #define __INLINE inline /*!< inline keyword for TASKING Compiler */ #define __STATIC_INLINE static inline #elif defined ( __CSMC__ ) #define __packed #define __ASM _asm /*!< asm keyword for COSMIC Compiler */ #define __INLINE inline /*!< inline keyword for COSMIC Compiler. Use -pc99 on compile line */ #define __STATIC_INLINE static inline #else #error Unknown compiler #endif /** __FPU_USED indicates whether an FPU is used or not. For this, __FPU_PRESENT has to be checked prior to making use of FPU specific registers and functions. */ #if defined ( __CC_ARM ) #if defined __TARGET_FPU_VFP #if (__FPU_PRESENT == 1U) #define __FPU_USED 1U #else #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" #define __FPU_USED 0U #endif #else #define __FPU_USED 0U #endif #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) #if defined __ARM_PCS_VFP #if (__FPU_PRESENT == 1) #define __FPU_USED 1U #else #warning "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" #define __FPU_USED 0U #endif #else #define __FPU_USED 0U #endif #elif defined ( __GNUC__ ) #if defined (__VFP_FP__) && !defined(__SOFTFP__) #if (__FPU_PRESENT == 1U) #define __FPU_USED 1U #else #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" #define __FPU_USED 0U #endif #else #define __FPU_USED 0U #endif #elif defined ( __ICCARM__ ) #if defined __ARMVFP__ #if (__FPU_PRESENT == 1U) #define __FPU_USED 1U #else #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" #define __FPU_USED 0U #endif #else #define __FPU_USED 0U #endif #elif defined ( __TMS470__ ) #if defined __TI_VFP_SUPPORT__ #if (__FPU_PRESENT == 1U) #define __FPU_USED 1U #else #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" #define __FPU_USED 0U #endif #else #define __FPU_USED 0U #endif #elif defined ( __TASKING__ ) #if defined __FPU_VFP__ #if (__FPU_PRESENT == 1U) #define __FPU_USED 1U #else #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" #define __FPU_USED 0U #endif #else #define __FPU_USED 0U #endif #elif defined ( __CSMC__ ) #if ( __CSMC__ & 0x400U) #if (__FPU_PRESENT == 1U) #define __FPU_USED 1U #else #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" #define __FPU_USED 0U #endif #else #define __FPU_USED 0U #endif #endif #include "core_cmInstr.h" /* Core Instruction Access */ #include "core_cmFunc.h" /* Core Function Access */ #include "core_cmSimd.h" /* Compiler specific SIMD Intrinsics */ #ifdef __cplusplus } #endif #endif /* __CORE_CM4_H_GENERIC */ #ifndef __CMSIS_GENERIC #ifndef __CORE_CM4_H_DEPENDANT #define __CORE_CM4_H_DEPENDANT #ifdef __cplusplus extern "C" { #endif /* check device defines and use defaults */ #if defined __CHECK_DEVICE_DEFINES #ifndef __CM4_REV #define __CM4_REV 0x0000U #warning "__CM4_REV not defined in device header file; using default!" #endif #ifndef __FPU_PRESENT #define __FPU_PRESENT 0U #warning "__FPU_PRESENT not defined in device header file; using default!" #endif #ifndef __MPU_PRESENT #define __MPU_PRESENT 0U #warning "__MPU_PRESENT not defined in device header file; using default!" #endif #ifndef __NVIC_PRIO_BITS #define __NVIC_PRIO_BITS 3U #warning "__NVIC_PRIO_BITS not defined in device header file; using default!" #endif #ifndef __Vendor_SysTickConfig #define __Vendor_SysTickConfig 0U #warning "__Vendor_SysTickConfig not defined in device header file; using default!" #endif #endif /* IO definitions (access restrictions to peripheral registers) */ /** \defgroup CMSIS_glob_defs CMSIS Global Defines IO Type Qualifiers are used \li to specify the access to peripheral variables. \li for automatic generation of peripheral register debug information. */ #ifdef __cplusplus #define __I volatile /*!< Defines 'read only' permissions */ #else #define __I volatile const /*!< Defines 'read only' permissions */ #endif #define __O volatile /*!< Defines 'write only' permissions */ #define __IO volatile /*!< Defines 'read / write' permissions */ /* following defines should be used for structure members */ #define __IM volatile const /*! Defines 'read only' structure member permissions */ #define __OM volatile /*! Defines 'write only' structure member permissions */ #define __IOM volatile /*! Defines 'read / write' structure member permissions */ /*@} end of group Cortex_M4 */ /******************************************************************************* * Register Abstraction Core Register contain: - Core Register - Core NVIC Register - Core SCB Register - Core SysTick Register - Core Debug Register - Core MPU Register - Core FPU Register ******************************************************************************/ /** \defgroup CMSIS_core_register Defines and Type Definitions \brief Type definitions and defines for Cortex-M processor based devices. */ /** \ingroup CMSIS_core_register \defgroup CMSIS_CORE Status and Control Registers \brief Core Register type definitions. @{ */ /** \brief Union type to access the Application Program Status Register (APSR). */ typedef union { struct { uint32_t _reserved0:16; /*!< bit: 0..15 Reserved */ uint32_t GE:4; /*!< bit: 16..19 Greater than or Equal flags */ uint32_t _reserved1:7; /*!< bit: 20..26 Reserved */ uint32_t Q:1; /*!< bit: 27 Saturation condition flag */ uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ uint32_t C:1; /*!< bit: 29 Carry condition code flag */ uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ uint32_t N:1; /*!< bit: 31 Negative condition code flag */ } b; /*!< Structure used for bit access */ uint32_t w; /*!< Type used for word access */ } APSR_Type; /* APSR Register Definitions */ #define APSR_N_Pos 31U /*!< APSR: N Position */ #define APSR_N_Msk (1UL << APSR_N_Pos) /*!< APSR: N Mask */ #define APSR_Z_Pos 30U /*!< APSR: Z Position */ #define APSR_Z_Msk (1UL << APSR_Z_Pos) /*!< APSR: Z Mask */ #define APSR_C_Pos 29U /*!< APSR: C Position */ #define APSR_C_Msk (1UL << APSR_C_Pos) /*!< APSR: C Mask */ #define APSR_V_Pos 28U /*!< APSR: V Position */ #define APSR_V_Msk (1UL << APSR_V_Pos) /*!< APSR: V Mask */ #define APSR_Q_Pos 27U /*!< APSR: Q Position */ #define APSR_Q_Msk (1UL << APSR_Q_Pos) /*!< APSR: Q Mask */ #define APSR_GE_Pos 16U /*!< APSR: GE Position */ #define APSR_GE_Msk (0xFUL << APSR_GE_Pos) /*!< APSR: GE Mask */ /** \brief Union type to access the Interrupt Program Status Register (IPSR). */ typedef union { struct { uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ uint32_t _reserved0:23; /*!< bit: 9..31 Reserved */ } b; /*!< Structure used for bit access */ uint32_t w; /*!< Type used for word access */ } IPSR_Type; /* IPSR Register Definitions */ #define IPSR_ISR_Pos 0U /*!< IPSR: ISR Position */ #define IPSR_ISR_Msk (0x1FFUL /*<< IPSR_ISR_Pos*/) /*!< IPSR: ISR Mask */ /** \brief Union type to access the Special-Purpose Program Status Registers (xPSR). */ typedef union { struct { uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ uint32_t _reserved0:7; /*!< bit: 9..15 Reserved */ uint32_t GE:4; /*!< bit: 16..19 Greater than or Equal flags */ uint32_t _reserved1:4; /*!< bit: 20..23 Reserved */ uint32_t T:1; /*!< bit: 24 Thumb bit (read 0) */ uint32_t IT:2; /*!< bit: 25..26 saved IT state (read 0) */ uint32_t Q:1; /*!< bit: 27 Saturation condition flag */ uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ uint32_t C:1; /*!< bit: 29 Carry condition code flag */ uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ uint32_t N:1; /*!< bit: 31 Negative condition code flag */ } b; /*!< Structure used for bit access */ uint32_t w; /*!< Type used for word access */ } xPSR_Type; /* xPSR Register Definitions */ #define xPSR_N_Pos 31U /*!< xPSR: N Position */ #define xPSR_N_Msk (1UL << xPSR_N_Pos) /*!< xPSR: N Mask */ #define xPSR_Z_Pos 30U /*!< xPSR: Z Position */ #define xPSR_Z_Msk (1UL << xPSR_Z_Pos) /*!< xPSR: Z Mask */ #define xPSR_C_Pos 29U /*!< xPSR: C Position */ #define xPSR_C_Msk (1UL << xPSR_C_Pos) /*!< xPSR: C Mask */ #define xPSR_V_Pos 28U /*!< xPSR: V Position */ #define xPSR_V_Msk (1UL << xPSR_V_Pos) /*!< xPSR: V Mask */ #define xPSR_Q_Pos 27U /*!< xPSR: Q Position */ #define xPSR_Q_Msk (1UL << xPSR_Q_Pos) /*!< xPSR: Q Mask */ #define xPSR_IT_Pos 25U /*!< xPSR: IT Position */ #define xPSR_IT_Msk (3UL << xPSR_IT_Pos) /*!< xPSR: IT Mask */ #define xPSR_T_Pos 24U /*!< xPSR: T Position */ #define xPSR_T_Msk (1UL << xPSR_T_Pos) /*!< xPSR: T Mask */ #define xPSR_GE_Pos 16U /*!< xPSR: GE Position */ #define xPSR_GE_Msk (0xFUL << xPSR_GE_Pos) /*!< xPSR: GE Mask */ #define xPSR_ISR_Pos 0U /*!< xPSR: ISR Position */ #define xPSR_ISR_Msk (0x1FFUL /*<< xPSR_ISR_Pos*/) /*!< xPSR: ISR Mask */ /** \brief Union type to access the Control Registers (CONTROL). */ typedef union { struct { uint32_t nPRIV:1; /*!< bit: 0 Execution privilege in Thread mode */ uint32_t SPSEL:1; /*!< bit: 1 Stack to be used */ uint32_t FPCA:1; /*!< bit: 2 FP extension active flag */ uint32_t _reserved0:29; /*!< bit: 3..31 Reserved */ } b; /*!< Structure used for bit access */ uint32_t w; /*!< Type used for word access */ } CONTROL_Type; /* CONTROL Register Definitions */ #define CONTROL_FPCA_Pos 2U /*!< CONTROL: FPCA Position */ #define CONTROL_FPCA_Msk (1UL << CONTROL_FPCA_Pos) /*!< CONTROL: FPCA Mask */ #define CONTROL_SPSEL_Pos 1U /*!< CONTROL: SPSEL Position */ #define CONTROL_SPSEL_Msk (1UL << CONTROL_SPSEL_Pos) /*!< CONTROL: SPSEL Mask */ #define CONTROL_nPRIV_Pos 0U /*!< CONTROL: nPRIV Position */ #define CONTROL_nPRIV_Msk (1UL /*<< CONTROL_nPRIV_Pos*/) /*!< CONTROL: nPRIV Mask */ /*@} end of group CMSIS_CORE */ /** \ingroup CMSIS_core_register \defgroup CMSIS_NVIC Nested Vectored Interrupt Controller (NVIC) \brief Type definitions for the NVIC Registers @{ */ /** \brief Structure type to access the Nested Vectored Interrupt Controller (NVIC). */ typedef struct { __IOM uint32_t ISER[8U]; /*!< Offset: 0x000 (R/W) Interrupt Set Enable Register */ uint32_t RESERVED0[24U]; __IOM uint32_t ICER[8U]; /*!< Offset: 0x080 (R/W) Interrupt Clear Enable Register */ uint32_t RSERVED1[24U]; __IOM uint32_t ISPR[8U]; /*!< Offset: 0x100 (R/W) Interrupt Set Pending Register */ uint32_t RESERVED2[24U]; __IOM uint32_t ICPR[8U]; /*!< Offset: 0x180 (R/W) Interrupt Clear Pending Register */ uint32_t RESERVED3[24U]; __IOM uint32_t IABR[8U]; /*!< Offset: 0x200 (R/W) Interrupt Active bit Register */ uint32_t RESERVED4[56U]; __IOM uint8_t IP[240U]; /*!< Offset: 0x300 (R/W) Interrupt Priority Register (8Bit wide) */ uint32_t RESERVED5[644U]; __OM uint32_t STIR; /*!< Offset: 0xE00 ( /W) Software Trigger Interrupt Register */ } NVIC_Type; /* Software Triggered Interrupt Register Definitions */ #define NVIC_STIR_INTID_Pos 0U /*!< STIR: INTLINESNUM Position */ #define NVIC_STIR_INTID_Msk (0x1FFUL /*<< NVIC_STIR_INTID_Pos*/) /*!< STIR: INTLINESNUM Mask */ /*@} end of group CMSIS_NVIC */ /** \ingroup CMSIS_core_register \defgroup CMSIS_SCB System Control Block (SCB) \brief Type definitions for the System Control Block Registers @{ */ /** \brief Structure type to access the System Control Block (SCB). */ typedef struct { __IM uint32_t CPUID; /*!< Offset: 0x000 (R/ ) CPUID Base Register */ __IOM uint32_t ICSR; /*!< Offset: 0x004 (R/W) Interrupt Control and State Register */ __IOM uint32_t VTOR; /*!< Offset: 0x008 (R/W) Vector Table Offset Register */ __IOM uint32_t AIRCR; /*!< Offset: 0x00C (R/W) Application Interrupt and Reset Control Register */ __IOM uint32_t SCR; /*!< Offset: 0x010 (R/W) System Control Register */ __IOM uint32_t CCR; /*!< Offset: 0x014 (R/W) Configuration Control Register */ __IOM uint8_t SHP[12U]; /*!< Offset: 0x018 (R/W) System Handlers Priority Registers (4-7, 8-11, 12-15) */ __IOM uint32_t SHCSR; /*!< Offset: 0x024 (R/W) System Handler Control and State Register */ __IOM uint32_t CFSR; /*!< Offset: 0x028 (R/W) Configurable Fault Status Register */ __IOM uint32_t HFSR; /*!< Offset: 0x02C (R/W) HardFault Status Register */ __IOM uint32_t DFSR; /*!< Offset: 0x030 (R/W) Debug Fault Status Register */ __IOM uint32_t MMFAR; /*!< Offset: 0x034 (R/W) MemManage Fault Address Register */ __IOM uint32_t BFAR; /*!< Offset: 0x038 (R/W) BusFault Address Register */ __IOM uint32_t AFSR; /*!< Offset: 0x03C (R/W) Auxiliary Fault Status Register */ __IM uint32_t PFR[2U]; /*!< Offset: 0x040 (R/ ) Processor Feature Register */ __IM uint32_t DFR; /*!< Offset: 0x048 (R/ ) Debug Feature Register */ __IM uint32_t ADR; /*!< Offset: 0x04C (R/ ) Auxiliary Feature Register */ __IM uint32_t MMFR[4U]; /*!< Offset: 0x050 (R/ ) Memory Model Feature Register */ __IM uint32_t ISAR[5U]; /*!< Offset: 0x060 (R/ ) Instruction Set Attributes Register */ uint32_t RESERVED0[5U]; __IOM uint32_t CPACR; /*!< Offset: 0x088 (R/W) Coprocessor Access Control Register */ } SCB_Type; /* SCB CPUID Register Definitions */ #define SCB_CPUID_IMPLEMENTER_Pos 24U /*!< SCB CPUID: IMPLEMENTER Position */ #define SCB_CPUID_IMPLEMENTER_Msk (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos) /*!< SCB CPUID: IMPLEMENTER Mask */ #define SCB_CPUID_VARIANT_Pos 20U /*!< SCB CPUID: VARIANT Position */ #define SCB_CPUID_VARIANT_Msk (0xFUL << SCB_CPUID_VARIANT_Pos) /*!< SCB CPUID: VARIANT Mask */ #define SCB_CPUID_ARCHITECTURE_Pos 16U /*!< SCB CPUID: ARCHITECTURE Position */ #define SCB_CPUID_ARCHITECTURE_Msk (0xFUL << SCB_CPUID_ARCHITECTURE_Pos) /*!< SCB CPUID: ARCHITECTURE Mask */ #define SCB_CPUID_PARTNO_Pos 4U /*!< SCB CPUID: PARTNO Position */ #define SCB_CPUID_PARTNO_Msk (0xFFFUL << SCB_CPUID_PARTNO_Pos) /*!< SCB CPUID: PARTNO Mask */ #define SCB_CPUID_REVISION_Pos 0U /*!< SCB CPUID: REVISION Position */ #define SCB_CPUID_REVISION_Msk (0xFUL /*<< SCB_CPUID_REVISION_Pos*/) /*!< SCB CPUID: REVISION Mask */ /* SCB Interrupt Control State Register Definitions */ #define SCB_ICSR_NMIPENDSET_Pos 31U /*!< SCB ICSR: NMIPENDSET Position */ #define SCB_ICSR_NMIPENDSET_Msk (1UL << SCB_ICSR_NMIPENDSET_Pos) /*!< SCB ICSR: NMIPENDSET Mask */ #define SCB_ICSR_PENDSVSET_Pos 28U /*!< SCB ICSR: PENDSVSET Position */ #define SCB_ICSR_PENDSVSET_Msk (1UL << SCB_ICSR_PENDSVSET_Pos) /*!< SCB ICSR: PENDSVSET Mask */ #define SCB_ICSR_PENDSVCLR_Pos 27U /*!< SCB ICSR: PENDSVCLR Position */ #define SCB_ICSR_PENDSVCLR_Msk (1UL << SCB_ICSR_PENDSVCLR_Pos) /*!< SCB ICSR: PENDSVCLR Mask */ #define SCB_ICSR_PENDSTSET_Pos 26U /*!< SCB ICSR: PENDSTSET Position */ #define SCB_ICSR_PENDSTSET_Msk (1UL << SCB_ICSR_PENDSTSET_Pos) /*!< SCB ICSR: PENDSTSET Mask */ #define SCB_ICSR_PENDSTCLR_Pos 25U /*!< SCB ICSR: PENDSTCLR Position */ #define SCB_ICSR_PENDSTCLR_Msk (1UL << SCB_ICSR_PENDSTCLR_Pos) /*!< SCB ICSR: PENDSTCLR Mask */ #define SCB_ICSR_ISRPREEMPT_Pos 23U /*!< SCB ICSR: ISRPREEMPT Position */ #define SCB_ICSR_ISRPREEMPT_Msk (1UL << SCB_ICSR_ISRPREEMPT_Pos) /*!< SCB ICSR: ISRPREEMPT Mask */ #define SCB_ICSR_ISRPENDING_Pos 22U /*!< SCB ICSR: ISRPENDING Position */ #define SCB_ICSR_ISRPENDING_Msk (1UL << SCB_ICSR_ISRPENDING_Pos) /*!< SCB ICSR: ISRPENDING Mask */ #define SCB_ICSR_VECTPENDING_Pos 12U /*!< SCB ICSR: VECTPENDING Position */ #define SCB_ICSR_VECTPENDING_Msk (0x1FFUL << SCB_ICSR_VECTPENDING_Pos) /*!< SCB ICSR: VECTPENDING Mask */ #define SCB_ICSR_RETTOBASE_Pos 11U /*!< SCB ICSR: RETTOBASE Position */ #define SCB_ICSR_RETTOBASE_Msk (1UL << SCB_ICSR_RETTOBASE_Pos) /*!< SCB ICSR: RETTOBASE Mask */ #define SCB_ICSR_VECTACTIVE_Pos 0U /*!< SCB ICSR: VECTACTIVE Position */ #define SCB_ICSR_VECTACTIVE_Msk (0x1FFUL /*<< SCB_ICSR_VECTACTIVE_Pos*/) /*!< SCB ICSR: VECTACTIVE Mask */ /* SCB Vector Table Offset Register Definitions */ #define SCB_VTOR_TBLOFF_Pos 7U /*!< SCB VTOR: TBLOFF Position */ #define SCB_VTOR_TBLOFF_Msk (0x1FFFFFFUL << SCB_VTOR_TBLOFF_Pos) /*!< SCB VTOR: TBLOFF Mask */ /* SCB Application Interrupt and Reset Control Register Definitions */ #define SCB_AIRCR_VECTKEY_Pos 16U /*!< SCB AIRCR: VECTKEY Position */ #define SCB_AIRCR_VECTKEY_Msk (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos) /*!< SCB AIRCR: VECTKEY Mask */ #define SCB_AIRCR_VECTKEYSTAT_Pos 16U /*!< SCB AIRCR: VECTKEYSTAT Position */ #define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos) /*!< SCB AIRCR: VECTKEYSTAT Mask */ #define SCB_AIRCR_ENDIANESS_Pos 15U /*!< SCB AIRCR: ENDIANESS Position */ #define SCB_AIRCR_ENDIANESS_Msk (1UL << SCB_AIRCR_ENDIANESS_Pos) /*!< SCB AIRCR: ENDIANESS Mask */ #define SCB_AIRCR_PRIGROUP_Pos 8U /*!< SCB AIRCR: PRIGROUP Position */ #define SCB_AIRCR_PRIGROUP_Msk (7UL << SCB_AIRCR_PRIGROUP_Pos) /*!< SCB AIRCR: PRIGROUP Mask */ #define SCB_AIRCR_SYSRESETREQ_Pos 2U /*!< SCB AIRCR: SYSRESETREQ Position */ #define SCB_AIRCR_SYSRESETREQ_Msk (1UL << SCB_AIRCR_SYSRESETREQ_Pos) /*!< SCB AIRCR: SYSRESETREQ Mask */ #define SCB_AIRCR_VECTCLRACTIVE_Pos 1U /*!< SCB AIRCR: VECTCLRACTIVE Position */ #define SCB_AIRCR_VECTCLRACTIVE_Msk (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos) /*!< SCB AIRCR: VECTCLRACTIVE Mask */ #define SCB_AIRCR_VECTRESET_Pos 0U /*!< SCB AIRCR: VECTRESET Position */ #define SCB_AIRCR_VECTRESET_Msk (1UL /*<< SCB_AIRCR_VECTRESET_Pos*/) /*!< SCB AIRCR: VECTRESET Mask */ /* SCB System Control Register Definitions */ #define SCB_SCR_SEVONPEND_Pos 4U /*!< SCB SCR: SEVONPEND Position */ #define SCB_SCR_SEVONPEND_Msk (1UL << SCB_SCR_SEVONPEND_Pos) /*!< SCB SCR: SEVONPEND Mask */ #define SCB_SCR_SLEEPDEEP_Pos 2U /*!< SCB SCR: SLEEPDEEP Position */ #define SCB_SCR_SLEEPDEEP_Msk (1UL << SCB_SCR_SLEEPDEEP_Pos) /*!< SCB SCR: SLEEPDEEP Mask */ #define SCB_SCR_SLEEPONEXIT_Pos 1U /*!< SCB SCR: SLEEPONEXIT Position */ #define SCB_SCR_SLEEPONEXIT_Msk (1UL << SCB_SCR_SLEEPONEXIT_Pos) /*!< SCB SCR: SLEEPONEXIT Mask */ /* SCB Configuration Control Register Definitions */ #define SCB_CCR_STKALIGN_Pos 9U /*!< SCB CCR: STKALIGN Position */ #define SCB_CCR_STKALIGN_Msk (1UL << SCB_CCR_STKALIGN_Pos) /*!< SCB CCR: STKALIGN Mask */ #define SCB_CCR_BFHFNMIGN_Pos 8U /*!< SCB CCR: BFHFNMIGN Position */ #define SCB_CCR_BFHFNMIGN_Msk (1UL << SCB_CCR_BFHFNMIGN_Pos) /*!< SCB CCR: BFHFNMIGN Mask */ #define SCB_CCR_DIV_0_TRP_Pos 4U /*!< SCB CCR: DIV_0_TRP Position */ #define SCB_CCR_DIV_0_TRP_Msk (1UL << SCB_CCR_DIV_0_TRP_Pos) /*!< SCB CCR: DIV_0_TRP Mask */ #define SCB_CCR_UNALIGN_TRP_Pos 3U /*!< SCB CCR: UNALIGN_TRP Position */ #define SCB_CCR_UNALIGN_TRP_Msk (1UL << SCB_CCR_UNALIGN_TRP_Pos) /*!< SCB CCR: UNALIGN_TRP Mask */ #define SCB_CCR_USERSETMPEND_Pos 1U /*!< SCB CCR: USERSETMPEND Position */ #define SCB_CCR_USERSETMPEND_Msk (1UL << SCB_CCR_USERSETMPEND_Pos) /*!< SCB CCR: USERSETMPEND Mask */ #define SCB_CCR_NONBASETHRDENA_Pos 0U /*!< SCB CCR: NONBASETHRDENA Position */ #define SCB_CCR_NONBASETHRDENA_Msk (1UL /*<< SCB_CCR_NONBASETHRDENA_Pos*/) /*!< SCB CCR: NONBASETHRDENA Mask */ /* SCB System Handler Control and State Register Definitions */ #define SCB_SHCSR_USGFAULTENA_Pos 18U /*!< SCB SHCSR: USGFAULTENA Position */ #define SCB_SHCSR_USGFAULTENA_Msk (1UL << SCB_SHCSR_USGFAULTENA_Pos) /*!< SCB SHCSR: USGFAULTENA Mask */ #define SCB_SHCSR_BUSFAULTENA_Pos 17U /*!< SCB SHCSR: BUSFAULTENA Position */ #define SCB_SHCSR_BUSFAULTENA_Msk (1UL << SCB_SHCSR_BUSFAULTENA_Pos) /*!< SCB SHCSR: BUSFAULTENA Mask */ #define SCB_SHCSR_MEMFAULTENA_Pos 16U /*!< SCB SHCSR: MEMFAULTENA Position */ #define SCB_SHCSR_MEMFAULTENA_Msk (1UL << SCB_SHCSR_MEMFAULTENA_Pos) /*!< SCB SHCSR: MEMFAULTENA Mask */ #define SCB_SHCSR_SVCALLPENDED_Pos 15U /*!< SCB SHCSR: SVCALLPENDED Position */ #define SCB_SHCSR_SVCALLPENDED_Msk (1UL << SCB_SHCSR_SVCALLPENDED_Pos) /*!< SCB SHCSR: SVCALLPENDED Mask */ #define SCB_SHCSR_BUSFAULTPENDED_Pos 14U /*!< SCB SHCSR: BUSFAULTPENDED Position */ #define SCB_SHCSR_BUSFAULTPENDED_Msk (1UL << SCB_SHCSR_BUSFAULTPENDED_Pos) /*!< SCB SHCSR: BUSFAULTPENDED Mask */ #define SCB_SHCSR_MEMFAULTPENDED_Pos 13U /*!< SCB SHCSR: MEMFAULTPENDED Position */ #define SCB_SHCSR_MEMFAULTPENDED_Msk (1UL << SCB_SHCSR_MEMFAULTPENDED_Pos) /*!< SCB SHCSR: MEMFAULTPENDED Mask */ #define SCB_SHCSR_USGFAULTPENDED_Pos 12U /*!< SCB SHCSR: USGFAULTPENDED Position */ #define SCB_SHCSR_USGFAULTPENDED_Msk (1UL << SCB_SHCSR_USGFAULTPENDED_Pos) /*!< SCB SHCSR: USGFAULTPENDED Mask */ #define SCB_SHCSR_SYSTICKACT_Pos 11U /*!< SCB SHCSR: SYSTICKACT Position */ #define SCB_SHCSR_SYSTICKACT_Msk (1UL << SCB_SHCSR_SYSTICKACT_Pos) /*!< SCB SHCSR: SYSTICKACT Mask */ #define SCB_SHCSR_PENDSVACT_Pos 10U /*!< SCB SHCSR: PENDSVACT Position */ #define SCB_SHCSR_PENDSVACT_Msk (1UL << SCB_SHCSR_PENDSVACT_Pos) /*!< SCB SHCSR: PENDSVACT Mask */ #define SCB_SHCSR_MONITORACT_Pos 8U /*!< SCB SHCSR: MONITORACT Position */ #define SCB_SHCSR_MONITORACT_Msk (1UL << SCB_SHCSR_MONITORACT_Pos) /*!< SCB SHCSR: MONITORACT Mask */ #define SCB_SHCSR_SVCALLACT_Pos 7U /*!< SCB SHCSR: SVCALLACT Position */ #define SCB_SHCSR_SVCALLACT_Msk (1UL << SCB_SHCSR_SVCALLACT_Pos) /*!< SCB SHCSR: SVCALLACT Mask */ #define SCB_SHCSR_USGFAULTACT_Pos 3U /*!< SCB SHCSR: USGFAULTACT Position */ #define SCB_SHCSR_USGFAULTACT_Msk (1UL << SCB_SHCSR_USGFAULTACT_Pos) /*!< SCB SHCSR: USGFAULTACT Mask */ #define SCB_SHCSR_BUSFAULTACT_Pos 1U /*!< SCB SHCSR: BUSFAULTACT Position */ #define SCB_SHCSR_BUSFAULTACT_Msk (1UL << SCB_SHCSR_BUSFAULTACT_Pos) /*!< SCB SHCSR: BUSFAULTACT Mask */ #define SCB_SHCSR_MEMFAULTACT_Pos 0U /*!< SCB SHCSR: MEMFAULTACT Position */ #define SCB_SHCSR_MEMFAULTACT_Msk (1UL /*<< SCB_SHCSR_MEMFAULTACT_Pos*/) /*!< SCB SHCSR: MEMFAULTACT Mask */ /* SCB Configurable Fault Status Register Definitions */ #define SCB_CFSR_USGFAULTSR_Pos 16U /*!< SCB CFSR: Usage Fault Status Register Position */ #define SCB_CFSR_USGFAULTSR_Msk (0xFFFFUL << SCB_CFSR_USGFAULTSR_Pos) /*!< SCB CFSR: Usage Fault Status Register Mask */ #define SCB_CFSR_BUSFAULTSR_Pos 8U /*!< SCB CFSR: Bus Fault Status Register Position */ #define SCB_CFSR_BUSFAULTSR_Msk (0xFFUL << SCB_CFSR_BUSFAULTSR_Pos) /*!< SCB CFSR: Bus Fault Status Register Mask */ #define SCB_CFSR_MEMFAULTSR_Pos 0U /*!< SCB CFSR: Memory Manage Fault Status Register Position */ #define SCB_CFSR_MEMFAULTSR_Msk (0xFFUL /*<< SCB_CFSR_MEMFAULTSR_Pos*/) /*!< SCB CFSR: Memory Manage Fault Status Register Mask */ /* SCB Hard Fault Status Register Definitions */ #define SCB_HFSR_DEBUGEVT_Pos 31U /*!< SCB HFSR: DEBUGEVT Position */ #define SCB_HFSR_DEBUGEVT_Msk (1UL << SCB_HFSR_DEBUGEVT_Pos) /*!< SCB HFSR: DEBUGEVT Mask */ #define SCB_HFSR_FORCED_Pos 30U /*!< SCB HFSR: FORCED Position */ #define SCB_HFSR_FORCED_Msk (1UL << SCB_HFSR_FORCED_Pos) /*!< SCB HFSR: FORCED Mask */ #define SCB_HFSR_VECTTBL_Pos 1U /*!< SCB HFSR: VECTTBL Position */ #define SCB_HFSR_VECTTBL_Msk (1UL << SCB_HFSR_VECTTBL_Pos) /*!< SCB HFSR: VECTTBL Mask */ /* SCB Debug Fault Status Register Definitions */ #define SCB_DFSR_EXTERNAL_Pos 4U /*!< SCB DFSR: EXTERNAL Position */ #define SCB_DFSR_EXTERNAL_Msk (1UL << SCB_DFSR_EXTERNAL_Pos) /*!< SCB DFSR: EXTERNAL Mask */ #define SCB_DFSR_VCATCH_Pos 3U /*!< SCB DFSR: VCATCH Position */ #define SCB_DFSR_VCATCH_Msk (1UL << SCB_DFSR_VCATCH_Pos) /*!< SCB DFSR: VCATCH Mask */ #define SCB_DFSR_DWTTRAP_Pos 2U /*!< SCB DFSR: DWTTRAP Position */ #define SCB_DFSR_DWTTRAP_Msk (1UL << SCB_DFSR_DWTTRAP_Pos) /*!< SCB DFSR: DWTTRAP Mask */ #define SCB_DFSR_BKPT_Pos 1U /*!< SCB DFSR: BKPT Position */ #define SCB_DFSR_BKPT_Msk (1UL << SCB_DFSR_BKPT_Pos) /*!< SCB DFSR: BKPT Mask */ #define SCB_DFSR_HALTED_Pos 0U /*!< SCB DFSR: HALTED Position */ #define SCB_DFSR_HALTED_Msk (1UL /*<< SCB_DFSR_HALTED_Pos*/) /*!< SCB DFSR: HALTED Mask */ /*@} end of group CMSIS_SCB */ /** \ingroup CMSIS_core_register \defgroup CMSIS_SCnSCB System Controls not in SCB (SCnSCB) \brief Type definitions for the System Control and ID Register not in the SCB @{ */ /** \brief Structure type to access the System Control and ID Register not in the SCB. */ typedef struct { uint32_t RESERVED0[1U]; __IM uint32_t ICTR; /*!< Offset: 0x004 (R/ ) Interrupt Controller Type Register */ __IOM uint32_t ACTLR; /*!< Offset: 0x008 (R/W) Auxiliary Control Register */ } SCnSCB_Type; /* Interrupt Controller Type Register Definitions */ #define SCnSCB_ICTR_INTLINESNUM_Pos 0U /*!< ICTR: INTLINESNUM Position */ #define SCnSCB_ICTR_INTLINESNUM_Msk (0xFUL /*<< SCnSCB_ICTR_INTLINESNUM_Pos*/) /*!< ICTR: INTLINESNUM Mask */ /* Auxiliary Control Register Definitions */ #define SCnSCB_ACTLR_DISOOFP_Pos 9U /*!< ACTLR: DISOOFP Position */ #define SCnSCB_ACTLR_DISOOFP_Msk (1UL << SCnSCB_ACTLR_DISOOFP_Pos) /*!< ACTLR: DISOOFP Mask */ #define SCnSCB_ACTLR_DISFPCA_Pos 8U /*!< ACTLR: DISFPCA Position */ #define SCnSCB_ACTLR_DISFPCA_Msk (1UL << SCnSCB_ACTLR_DISFPCA_Pos) /*!< ACTLR: DISFPCA Mask */ #define SCnSCB_ACTLR_DISFOLD_Pos 2U /*!< ACTLR: DISFOLD Position */ #define SCnSCB_ACTLR_DISFOLD_Msk (1UL << SCnSCB_ACTLR_DISFOLD_Pos) /*!< ACTLR: DISFOLD Mask */ #define SCnSCB_ACTLR_DISDEFWBUF_Pos 1U /*!< ACTLR: DISDEFWBUF Position */ #define SCnSCB_ACTLR_DISDEFWBUF_Msk (1UL << SCnSCB_ACTLR_DISDEFWBUF_Pos) /*!< ACTLR: DISDEFWBUF Mask */ #define SCnSCB_ACTLR_DISMCYCINT_Pos 0U /*!< ACTLR: DISMCYCINT Position */ #define SCnSCB_ACTLR_DISMCYCINT_Msk (1UL /*<< SCnSCB_ACTLR_DISMCYCINT_Pos*/) /*!< ACTLR: DISMCYCINT Mask */ /*@} end of group CMSIS_SCnotSCB */ /** \ingroup CMSIS_core_register \defgroup CMSIS_SysTick System Tick Timer (SysTick) \brief Type definitions for the System Timer Registers. @{ */ /** \brief Structure type to access the System Timer (SysTick). */ typedef struct { __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SysTick Control and Status Register */ __IOM uint32_t LOAD; /*!< Offset: 0x004 (R/W) SysTick Reload Value Register */ __IOM uint32_t VAL; /*!< Offset: 0x008 (R/W) SysTick Current Value Register */ __IM uint32_t CALIB; /*!< Offset: 0x00C (R/ ) SysTick Calibration Register */ } SysTick_Type; /* SysTick Control / Status Register Definitions */ #define SysTick_CTRL_COUNTFLAG_Pos 16U /*!< SysTick CTRL: COUNTFLAG Position */ #define SysTick_CTRL_COUNTFLAG_Msk (1UL << SysTick_CTRL_COUNTFLAG_Pos) /*!< SysTick CTRL: COUNTFLAG Mask */ #define SysTick_CTRL_CLKSOURCE_Pos 2U /*!< SysTick CTRL: CLKSOURCE Position */ #define SysTick_CTRL_CLKSOURCE_Msk (1UL << SysTick_CTRL_CLKSOURCE_Pos) /*!< SysTick CTRL: CLKSOURCE Mask */ #define SysTick_CTRL_TICKINT_Pos 1U /*!< SysTick CTRL: TICKINT Position */ #define SysTick_CTRL_TICKINT_Msk (1UL << SysTick_CTRL_TICKINT_Pos) /*!< SysTick CTRL: TICKINT Mask */ #define SysTick_CTRL_ENABLE_Pos 0U /*!< SysTick CTRL: ENABLE Position */ #define SysTick_CTRL_ENABLE_Msk (1UL /*<< SysTick_CTRL_ENABLE_Pos*/) /*!< SysTick CTRL: ENABLE Mask */ /* SysTick Reload Register Definitions */ #define SysTick_LOAD_RELOAD_Pos 0U /*!< SysTick LOAD: RELOAD Position */ #define SysTick_LOAD_RELOAD_Msk (0xFFFFFFUL /*<< SysTick_LOAD_RELOAD_Pos*/) /*!< SysTick LOAD: RELOAD Mask */ /* SysTick Current Register Definitions */ #define SysTick_VAL_CURRENT_Pos 0U /*!< SysTick VAL: CURRENT Position */ #define SysTick_VAL_CURRENT_Msk (0xFFFFFFUL /*<< SysTick_VAL_CURRENT_Pos*/) /*!< SysTick VAL: CURRENT Mask */ /* SysTick Calibration Register Definitions */ #define SysTick_CALIB_NOREF_Pos 31U /*!< SysTick CALIB: NOREF Position */ #define SysTick_CALIB_NOREF_Msk (1UL << SysTick_CALIB_NOREF_Pos) /*!< SysTick CALIB: NOREF Mask */ #define SysTick_CALIB_SKEW_Pos 30U /*!< SysTick CALIB: SKEW Position */ #define SysTick_CALIB_SKEW_Msk (1UL << SysTick_CALIB_SKEW_Pos) /*!< SysTick CALIB: SKEW Mask */ #define SysTick_CALIB_TENMS_Pos 0U /*!< SysTick CALIB: TENMS Position */ #define SysTick_CALIB_TENMS_Msk (0xFFFFFFUL /*<< SysTick_CALIB_TENMS_Pos*/) /*!< SysTick CALIB: TENMS Mask */ /*@} end of group CMSIS_SysTick */ /** \ingroup CMSIS_core_register \defgroup CMSIS_ITM Instrumentation Trace Macrocell (ITM) \brief Type definitions for the Instrumentation Trace Macrocell (ITM) @{ */ /** \brief Structure type to access the Instrumentation Trace Macrocell Register (ITM). */ typedef struct { __OM union { __OM uint8_t u8; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 8-bit */ __OM uint16_t u16; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 16-bit */ __OM uint32_t u32; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 32-bit */ } PORT [32U]; /*!< Offset: 0x000 ( /W) ITM Stimulus Port Registers */ uint32_t RESERVED0[864U]; __IOM uint32_t TER; /*!< Offset: 0xE00 (R/W) ITM Trace Enable Register */ uint32_t RESERVED1[15U]; __IOM uint32_t TPR; /*!< Offset: 0xE40 (R/W) ITM Trace Privilege Register */ uint32_t RESERVED2[15U]; __IOM uint32_t TCR; /*!< Offset: 0xE80 (R/W) ITM Trace Control Register */ uint32_t RESERVED3[29U]; __OM uint32_t IWR; /*!< Offset: 0xEF8 ( /W) ITM Integration Write Register */ __IM uint32_t IRR; /*!< Offset: 0xEFC (R/ ) ITM Integration Read Register */ __IOM uint32_t IMCR; /*!< Offset: 0xF00 (R/W) ITM Integration Mode Control Register */ uint32_t RESERVED4[43U]; __OM uint32_t LAR; /*!< Offset: 0xFB0 ( /W) ITM Lock Access Register */ __IM uint32_t LSR; /*!< Offset: 0xFB4 (R/ ) ITM Lock Status Register */ uint32_t RESERVED5[6U]; __IM uint32_t PID4; /*!< Offset: 0xFD0 (R/ ) ITM Peripheral Identification Register #4 */ __IM uint32_t PID5; /*!< Offset: 0xFD4 (R/ ) ITM Peripheral Identification Register #5 */ __IM uint32_t PID6; /*!< Offset: 0xFD8 (R/ ) ITM Peripheral Identification Register #6 */ __IM uint32_t PID7; /*!< Offset: 0xFDC (R/ ) ITM Peripheral Identification Register #7 */ __IM uint32_t PID0; /*!< Offset: 0xFE0 (R/ ) ITM Peripheral Identification Register #0 */ __IM uint32_t PID1; /*!< Offset: 0xFE4 (R/ ) ITM Peripheral Identification Register #1 */ __IM uint32_t PID2; /*!< Offset: 0xFE8 (R/ ) ITM Peripheral Identification Register #2 */ __IM uint32_t PID3; /*!< Offset: 0xFEC (R/ ) ITM Peripheral Identification Register #3 */ __IM uint32_t CID0; /*!< Offset: 0xFF0 (R/ ) ITM Component Identification Register #0 */ __IM uint32_t CID1; /*!< Offset: 0xFF4 (R/ ) ITM Component Identification Register #1 */ __IM uint32_t CID2; /*!< Offset: 0xFF8 (R/ ) ITM Component Identification Register #2 */ __IM uint32_t CID3; /*!< Offset: 0xFFC (R/ ) ITM Component Identification Register #3 */ } ITM_Type; /* ITM Trace Privilege Register Definitions */ #define ITM_TPR_PRIVMASK_Pos 0U /*!< ITM TPR: PRIVMASK Position */ #define ITM_TPR_PRIVMASK_Msk (0xFUL /*<< ITM_TPR_PRIVMASK_Pos*/) /*!< ITM TPR: PRIVMASK Mask */ /* ITM Trace Control Register Definitions */ #define ITM_TCR_BUSY_Pos 23U /*!< ITM TCR: BUSY Position */ #define ITM_TCR_BUSY_Msk (1UL << ITM_TCR_BUSY_Pos) /*!< ITM TCR: BUSY Mask */ #define ITM_TCR_TraceBusID_Pos 16U /*!< ITM TCR: ATBID Position */ #define ITM_TCR_TraceBusID_Msk (0x7FUL << ITM_TCR_TraceBusID_Pos) /*!< ITM TCR: ATBID Mask */ #define ITM_TCR_GTSFREQ_Pos 10U /*!< ITM TCR: Global timestamp frequency Position */ #define ITM_TCR_GTSFREQ_Msk (3UL << ITM_TCR_GTSFREQ_Pos) /*!< ITM TCR: Global timestamp frequency Mask */ #define ITM_TCR_TSPrescale_Pos 8U /*!< ITM TCR: TSPrescale Position */ #define ITM_TCR_TSPrescale_Msk (3UL << ITM_TCR_TSPrescale_Pos) /*!< ITM TCR: TSPrescale Mask */ #define ITM_TCR_SWOENA_Pos 4U /*!< ITM TCR: SWOENA Position */ #define ITM_TCR_SWOENA_Msk (1UL << ITM_TCR_SWOENA_Pos) /*!< ITM TCR: SWOENA Mask */ #define ITM_TCR_DWTENA_Pos 3U /*!< ITM TCR: DWTENA Position */ #define ITM_TCR_DWTENA_Msk (1UL << ITM_TCR_DWTENA_Pos) /*!< ITM TCR: DWTENA Mask */ #define ITM_TCR_SYNCENA_Pos 2U /*!< ITM TCR: SYNCENA Position */ #define ITM_TCR_SYNCENA_Msk (1UL << ITM_TCR_SYNCENA_Pos) /*!< ITM TCR: SYNCENA Mask */ #define ITM_TCR_TSENA_Pos 1U /*!< ITM TCR: TSENA Position */ #define ITM_TCR_TSENA_Msk (1UL << ITM_TCR_TSENA_Pos) /*!< ITM TCR: TSENA Mask */ #define ITM_TCR_ITMENA_Pos 0U /*!< ITM TCR: ITM Enable bit Position */ #define ITM_TCR_ITMENA_Msk (1UL /*<< ITM_TCR_ITMENA_Pos*/) /*!< ITM TCR: ITM Enable bit Mask */ /* ITM Integration Write Register Definitions */ #define ITM_IWR_ATVALIDM_Pos 0U /*!< ITM IWR: ATVALIDM Position */ #define ITM_IWR_ATVALIDM_Msk (1UL /*<< ITM_IWR_ATVALIDM_Pos*/) /*!< ITM IWR: ATVALIDM Mask */ /* ITM Integration Read Register Definitions */ #define ITM_IRR_ATREADYM_Pos 0U /*!< ITM IRR: ATREADYM Position */ #define ITM_IRR_ATREADYM_Msk (1UL /*<< ITM_IRR_ATREADYM_Pos*/) /*!< ITM IRR: ATREADYM Mask */ /* ITM Integration Mode Control Register Definitions */ #define ITM_IMCR_INTEGRATION_Pos 0U /*!< ITM IMCR: INTEGRATION Position */ #define ITM_IMCR_INTEGRATION_Msk (1UL /*<< ITM_IMCR_INTEGRATION_Pos*/) /*!< ITM IMCR: INTEGRATION Mask */ /* ITM Lock Status Register Definitions */ #define ITM_LSR_ByteAcc_Pos 2U /*!< ITM LSR: ByteAcc Position */ #define ITM_LSR_ByteAcc_Msk (1UL << ITM_LSR_ByteAcc_Pos) /*!< ITM LSR: ByteAcc Mask */ #define ITM_LSR_Access_Pos 1U /*!< ITM LSR: Access Position */ #define ITM_LSR_Access_Msk (1UL << ITM_LSR_Access_Pos) /*!< ITM LSR: Access Mask */ #define ITM_LSR_Present_Pos 0U /*!< ITM LSR: Present Position */ #define ITM_LSR_Present_Msk (1UL /*<< ITM_LSR_Present_Pos*/) /*!< ITM LSR: Present Mask */ /*@}*/ /* end of group CMSIS_ITM */ /** \ingroup CMSIS_core_register \defgroup CMSIS_DWT Data Watchpoint and Trace (DWT) \brief Type definitions for the Data Watchpoint and Trace (DWT) @{ */ /** \brief Structure type to access the Data Watchpoint and Trace Register (DWT). */ typedef struct { __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) Control Register */ __IOM uint32_t CYCCNT; /*!< Offset: 0x004 (R/W) Cycle Count Register */ __IOM uint32_t CPICNT; /*!< Offset: 0x008 (R/W) CPI Count Register */ __IOM uint32_t EXCCNT; /*!< Offset: 0x00C (R/W) Exception Overhead Count Register */ __IOM uint32_t SLEEPCNT; /*!< Offset: 0x010 (R/W) Sleep Count Register */ __IOM uint32_t LSUCNT; /*!< Offset: 0x014 (R/W) LSU Count Register */ __IOM uint32_t FOLDCNT; /*!< Offset: 0x018 (R/W) Folded-instruction Count Register */ __IM uint32_t PCSR; /*!< Offset: 0x01C (R/ ) Program Counter Sample Register */ __IOM uint32_t COMP0; /*!< Offset: 0x020 (R/W) Comparator Register 0 */ __IOM uint32_t MASK0; /*!< Offset: 0x024 (R/W) Mask Register 0 */ __IOM uint32_t FUNCTION0; /*!< Offset: 0x028 (R/W) Function Register 0 */ uint32_t RESERVED0[1U]; __IOM uint32_t COMP1; /*!< Offset: 0x030 (R/W) Comparator Register 1 */ __IOM uint32_t MASK1; /*!< Offset: 0x034 (R/W) Mask Register 1 */ __IOM uint32_t FUNCTION1; /*!< Offset: 0x038 (R/W) Function Register 1 */ uint32_t RESERVED1[1U]; __IOM uint32_t COMP2; /*!< Offset: 0x040 (R/W) Comparator Register 2 */ __IOM uint32_t MASK2; /*!< Offset: 0x044 (R/W) Mask Register 2 */ __IOM uint32_t FUNCTION2; /*!< Offset: 0x048 (R/W) Function Register 2 */ uint32_t RESERVED2[1U]; __IOM uint32_t COMP3; /*!< Offset: 0x050 (R/W) Comparator Register 3 */ __IOM uint32_t MASK3; /*!< Offset: 0x054 (R/W) Mask Register 3 */ __IOM uint32_t FUNCTION3; /*!< Offset: 0x058 (R/W) Function Register 3 */ } DWT_Type; /* DWT Control Register Definitions */ #define DWT_CTRL_NUMCOMP_Pos 28U /*!< DWT CTRL: NUMCOMP Position */ #define DWT_CTRL_NUMCOMP_Msk (0xFUL << DWT_CTRL_NUMCOMP_Pos) /*!< DWT CTRL: NUMCOMP Mask */ #define DWT_CTRL_NOTRCPKT_Pos 27U /*!< DWT CTRL: NOTRCPKT Position */ #define DWT_CTRL_NOTRCPKT_Msk (0x1UL << DWT_CTRL_NOTRCPKT_Pos) /*!< DWT CTRL: NOTRCPKT Mask */ #define DWT_CTRL_NOEXTTRIG_Pos 26U /*!< DWT CTRL: NOEXTTRIG Position */ #define DWT_CTRL_NOEXTTRIG_Msk (0x1UL << DWT_CTRL_NOEXTTRIG_Pos) /*!< DWT CTRL: NOEXTTRIG Mask */ #define DWT_CTRL_NOCYCCNT_Pos 25U /*!< DWT CTRL: NOCYCCNT Position */ #define DWT_CTRL_NOCYCCNT_Msk (0x1UL << DWT_CTRL_NOCYCCNT_Pos) /*!< DWT CTRL: NOCYCCNT Mask */ #define DWT_CTRL_NOPRFCNT_Pos 24U /*!< DWT CTRL: NOPRFCNT Position */ #define DWT_CTRL_NOPRFCNT_Msk (0x1UL << DWT_CTRL_NOPRFCNT_Pos) /*!< DWT CTRL: NOPRFCNT Mask */ #define DWT_CTRL_CYCEVTENA_Pos 22U /*!< DWT CTRL: CYCEVTENA Position */ #define DWT_CTRL_CYCEVTENA_Msk (0x1UL << DWT_CTRL_CYCEVTENA_Pos) /*!< DWT CTRL: CYCEVTENA Mask */ #define DWT_CTRL_FOLDEVTENA_Pos 21U /*!< DWT CTRL: FOLDEVTENA Position */ #define DWT_CTRL_FOLDEVTENA_Msk (0x1UL << DWT_CTRL_FOLDEVTENA_Pos) /*!< DWT CTRL: FOLDEVTENA Mask */ #define DWT_CTRL_LSUEVTENA_Pos 20U /*!< DWT CTRL: LSUEVTENA Position */ #define DWT_CTRL_LSUEVTENA_Msk (0x1UL << DWT_CTRL_LSUEVTENA_Pos) /*!< DWT CTRL: LSUEVTENA Mask */ #define DWT_CTRL_SLEEPEVTENA_Pos 19U /*!< DWT CTRL: SLEEPEVTENA Position */ #define DWT_CTRL_SLEEPEVTENA_Msk (0x1UL << DWT_CTRL_SLEEPEVTENA_Pos) /*!< DWT CTRL: SLEEPEVTENA Mask */ #define DWT_CTRL_EXCEVTENA_Pos 18U /*!< DWT CTRL: EXCEVTENA Position */ #define DWT_CTRL_EXCEVTENA_Msk (0x1UL << DWT_CTRL_EXCEVTENA_Pos) /*!< DWT CTRL: EXCEVTENA Mask */ #define DWT_CTRL_CPIEVTENA_Pos 17U /*!< DWT CTRL: CPIEVTENA Position */ #define DWT_CTRL_CPIEVTENA_Msk (0x1UL << DWT_CTRL_CPIEVTENA_Pos) /*!< DWT CTRL: CPIEVTENA Mask */ #define DWT_CTRL_EXCTRCENA_Pos 16U /*!< DWT CTRL: EXCTRCENA Position */ #define DWT_CTRL_EXCTRCENA_Msk (0x1UL << DWT_CTRL_EXCTRCENA_Pos) /*!< DWT CTRL: EXCTRCENA Mask */ #define DWT_CTRL_PCSAMPLENA_Pos 12U /*!< DWT CTRL: PCSAMPLENA Position */ #define DWT_CTRL_PCSAMPLENA_Msk (0x1UL << DWT_CTRL_PCSAMPLENA_Pos) /*!< DWT CTRL: PCSAMPLENA Mask */ #define DWT_CTRL_SYNCTAP_Pos 10U /*!< DWT CTRL: SYNCTAP Position */ #define DWT_CTRL_SYNCTAP_Msk (0x3UL << DWT_CTRL_SYNCTAP_Pos) /*!< DWT CTRL: SYNCTAP Mask */ #define DWT_CTRL_CYCTAP_Pos 9U /*!< DWT CTRL: CYCTAP Position */ #define DWT_CTRL_CYCTAP_Msk (0x1UL << DWT_CTRL_CYCTAP_Pos) /*!< DWT CTRL: CYCTAP Mask */ #define DWT_CTRL_POSTINIT_Pos 5U /*!< DWT CTRL: POSTINIT Position */ #define DWT_CTRL_POSTINIT_Msk (0xFUL << DWT_CTRL_POSTINIT_Pos) /*!< DWT CTRL: POSTINIT Mask */ #define DWT_CTRL_POSTPRESET_Pos 1U /*!< DWT CTRL: POSTPRESET Position */ #define DWT_CTRL_POSTPRESET_Msk (0xFUL << DWT_CTRL_POSTPRESET_Pos) /*!< DWT CTRL: POSTPRESET Mask */ #define DWT_CTRL_CYCCNTENA_Pos 0U /*!< DWT CTRL: CYCCNTENA Position */ #define DWT_CTRL_CYCCNTENA_Msk (0x1UL /*<< DWT_CTRL_CYCCNTENA_Pos*/) /*!< DWT CTRL: CYCCNTENA Mask */ /* DWT CPI Count Register Definitions */ #define DWT_CPICNT_CPICNT_Pos 0U /*!< DWT CPICNT: CPICNT Position */ #define DWT_CPICNT_CPICNT_Msk (0xFFUL /*<< DWT_CPICNT_CPICNT_Pos*/) /*!< DWT CPICNT: CPICNT Mask */ /* DWT Exception Overhead Count Register Definitions */ #define DWT_EXCCNT_EXCCNT_Pos 0U /*!< DWT EXCCNT: EXCCNT Position */ #define DWT_EXCCNT_EXCCNT_Msk (0xFFUL /*<< DWT_EXCCNT_EXCCNT_Pos*/) /*!< DWT EXCCNT: EXCCNT Mask */ /* DWT Sleep Count Register Definitions */ #define DWT_SLEEPCNT_SLEEPCNT_Pos 0U /*!< DWT SLEEPCNT: SLEEPCNT Position */ #define DWT_SLEEPCNT_SLEEPCNT_Msk (0xFFUL /*<< DWT_SLEEPCNT_SLEEPCNT_Pos*/) /*!< DWT SLEEPCNT: SLEEPCNT Mask */ /* DWT LSU Count Register Definitions */ #define DWT_LSUCNT_LSUCNT_Pos 0U /*!< DWT LSUCNT: LSUCNT Position */ #define DWT_LSUCNT_LSUCNT_Msk (0xFFUL /*<< DWT_LSUCNT_LSUCNT_Pos*/) /*!< DWT LSUCNT: LSUCNT Mask */ /* DWT Folded-instruction Count Register Definitions */ #define DWT_FOLDCNT_FOLDCNT_Pos 0U /*!< DWT FOLDCNT: FOLDCNT Position */ #define DWT_FOLDCNT_FOLDCNT_Msk (0xFFUL /*<< DWT_FOLDCNT_FOLDCNT_Pos*/) /*!< DWT FOLDCNT: FOLDCNT Mask */ /* DWT Comparator Mask Register Definitions */ #define DWT_MASK_MASK_Pos 0U /*!< DWT MASK: MASK Position */ #define DWT_MASK_MASK_Msk (0x1FUL /*<< DWT_MASK_MASK_Pos*/) /*!< DWT MASK: MASK Mask */ /* DWT Comparator Function Register Definitions */ #define DWT_FUNCTION_MATCHED_Pos 24U /*!< DWT FUNCTION: MATCHED Position */ #define DWT_FUNCTION_MATCHED_Msk (0x1UL << DWT_FUNCTION_MATCHED_Pos) /*!< DWT FUNCTION: MATCHED Mask */ #define DWT_FUNCTION_DATAVADDR1_Pos 16U /*!< DWT FUNCTION: DATAVADDR1 Position */ #define DWT_FUNCTION_DATAVADDR1_Msk (0xFUL << DWT_FUNCTION_DATAVADDR1_Pos) /*!< DWT FUNCTION: DATAVADDR1 Mask */ #define DWT_FUNCTION_DATAVADDR0_Pos 12U /*!< DWT FUNCTION: DATAVADDR0 Position */ #define DWT_FUNCTION_DATAVADDR0_Msk (0xFUL << DWT_FUNCTION_DATAVADDR0_Pos) /*!< DWT FUNCTION: DATAVADDR0 Mask */ #define DWT_FUNCTION_DATAVSIZE_Pos 10U /*!< DWT FUNCTION: DATAVSIZE Position */ #define DWT_FUNCTION_DATAVSIZE_Msk (0x3UL << DWT_FUNCTION_DATAVSIZE_Pos) /*!< DWT FUNCTION: DATAVSIZE Mask */ #define DWT_FUNCTION_LNK1ENA_Pos 9U /*!< DWT FUNCTION: LNK1ENA Position */ #define DWT_FUNCTION_LNK1ENA_Msk (0x1UL << DWT_FUNCTION_LNK1ENA_Pos) /*!< DWT FUNCTION: LNK1ENA Mask */ #define DWT_FUNCTION_DATAVMATCH_Pos 8U /*!< DWT FUNCTION: DATAVMATCH Position */ #define DWT_FUNCTION_DATAVMATCH_Msk (0x1UL << DWT_FUNCTION_DATAVMATCH_Pos) /*!< DWT FUNCTION: DATAVMATCH Mask */ #define DWT_FUNCTION_CYCMATCH_Pos 7U /*!< DWT FUNCTION: CYCMATCH Position */ #define DWT_FUNCTION_CYCMATCH_Msk (0x1UL << DWT_FUNCTION_CYCMATCH_Pos) /*!< DWT FUNCTION: CYCMATCH Mask */ #define DWT_FUNCTION_EMITRANGE_Pos 5U /*!< DWT FUNCTION: EMITRANGE Position */ #define DWT_FUNCTION_EMITRANGE_Msk (0x1UL << DWT_FUNCTION_EMITRANGE_Pos) /*!< DWT FUNCTION: EMITRANGE Mask */ #define DWT_FUNCTION_FUNCTION_Pos 0U /*!< DWT FUNCTION: FUNCTION Position */ #define DWT_FUNCTION_FUNCTION_Msk (0xFUL /*<< DWT_FUNCTION_FUNCTION_Pos*/) /*!< DWT FUNCTION: FUNCTION Mask */ /*@}*/ /* end of group CMSIS_DWT */ /** \ingroup CMSIS_core_register \defgroup CMSIS_TPI Trace Port Interface (TPI) \brief Type definitions for the Trace Port Interface (TPI) @{ */ /** \brief Structure type to access the Trace Port Interface Register (TPI). */ typedef struct { __IOM uint32_t SSPSR; /*!< Offset: 0x000 (R/ ) Supported Parallel Port Size Register */ __IOM uint32_t CSPSR; /*!< Offset: 0x004 (R/W) Current Parallel Port Size Register */ uint32_t RESERVED0[2U]; __IOM uint32_t ACPR; /*!< Offset: 0x010 (R/W) Asynchronous Clock Prescaler Register */ uint32_t RESERVED1[55U]; __IOM uint32_t SPPR; /*!< Offset: 0x0F0 (R/W) Selected Pin Protocol Register */ uint32_t RESERVED2[131U]; __IM uint32_t FFSR; /*!< Offset: 0x300 (R/ ) Formatter and Flush Status Register */ __IOM uint32_t FFCR; /*!< Offset: 0x304 (R/W) Formatter and Flush Control Register */ __IM uint32_t FSCR; /*!< Offset: 0x308 (R/ ) Formatter Synchronization Counter Register */ uint32_t RESERVED3[759U]; __IM uint32_t TRIGGER; /*!< Offset: 0xEE8 (R/ ) TRIGGER */ __IM uint32_t FIFO0; /*!< Offset: 0xEEC (R/ ) Integration ETM Data */ __IM uint32_t ITATBCTR2; /*!< Offset: 0xEF0 (R/ ) ITATBCTR2 */ uint32_t RESERVED4[1U]; __IM uint32_t ITATBCTR0; /*!< Offset: 0xEF8 (R/ ) ITATBCTR0 */ __IM uint32_t FIFO1; /*!< Offset: 0xEFC (R/ ) Integration ITM Data */ __IOM uint32_t ITCTRL; /*!< Offset: 0xF00 (R/W) Integration Mode Control */ uint32_t RESERVED5[39U]; __IOM uint32_t CLAIMSET; /*!< Offset: 0xFA0 (R/W) Claim tag set */ __IOM uint32_t CLAIMCLR; /*!< Offset: 0xFA4 (R/W) Claim tag clear */ uint32_t RESERVED7[8U]; __IM uint32_t DEVID; /*!< Offset: 0xFC8 (R/ ) TPIU_DEVID */ __IM uint32_t DEVTYPE; /*!< Offset: 0xFCC (R/ ) TPIU_DEVTYPE */ } TPI_Type; /* TPI Asynchronous Clock Prescaler Register Definitions */ #define TPI_ACPR_PRESCALER_Pos 0U /*!< TPI ACPR: PRESCALER Position */ #define TPI_ACPR_PRESCALER_Msk (0x1FFFUL /*<< TPI_ACPR_PRESCALER_Pos*/) /*!< TPI ACPR: PRESCALER Mask */ /* TPI Selected Pin Protocol Register Definitions */ #define TPI_SPPR_TXMODE_Pos 0U /*!< TPI SPPR: TXMODE Position */ #define TPI_SPPR_TXMODE_Msk (0x3UL /*<< TPI_SPPR_TXMODE_Pos*/) /*!< TPI SPPR: TXMODE Mask */ /* TPI Formatter and Flush Status Register Definitions */ #define TPI_FFSR_FtNonStop_Pos 3U /*!< TPI FFSR: FtNonStop Position */ #define TPI_FFSR_FtNonStop_Msk (0x1UL << TPI_FFSR_FtNonStop_Pos) /*!< TPI FFSR: FtNonStop Mask */ #define TPI_FFSR_TCPresent_Pos 2U /*!< TPI FFSR: TCPresent Position */ #define TPI_FFSR_TCPresent_Msk (0x1UL << TPI_FFSR_TCPresent_Pos) /*!< TPI FFSR: TCPresent Mask */ #define TPI_FFSR_FtStopped_Pos 1U /*!< TPI FFSR: FtStopped Position */ #define TPI_FFSR_FtStopped_Msk (0x1UL << TPI_FFSR_FtStopped_Pos) /*!< TPI FFSR: FtStopped Mask */ #define TPI_FFSR_FlInProg_Pos 0U /*!< TPI FFSR: FlInProg Position */ #define TPI_FFSR_FlInProg_Msk (0x1UL /*<< TPI_FFSR_FlInProg_Pos*/) /*!< TPI FFSR: FlInProg Mask */ /* TPI Formatter and Flush Control Register Definitions */ #define TPI_FFCR_TrigIn_Pos 8U /*!< TPI FFCR: TrigIn Position */ #define TPI_FFCR_TrigIn_Msk (0x1UL << TPI_FFCR_TrigIn_Pos) /*!< TPI FFCR: TrigIn Mask */ #define TPI_FFCR_EnFCont_Pos 1U /*!< TPI FFCR: EnFCont Position */ #define TPI_FFCR_EnFCont_Msk (0x1UL << TPI_FFCR_EnFCont_Pos) /*!< TPI FFCR: EnFCont Mask */ /* TPI TRIGGER Register Definitions */ #define TPI_TRIGGER_TRIGGER_Pos 0U /*!< TPI TRIGGER: TRIGGER Position */ #define TPI_TRIGGER_TRIGGER_Msk (0x1UL /*<< TPI_TRIGGER_TRIGGER_Pos*/) /*!< TPI TRIGGER: TRIGGER Mask */ /* TPI Integration ETM Data Register Definitions (FIFO0) */ #define TPI_FIFO0_ITM_ATVALID_Pos 29U /*!< TPI FIFO0: ITM_ATVALID Position */ #define TPI_FIFO0_ITM_ATVALID_Msk (0x3UL << TPI_FIFO0_ITM_ATVALID_Pos) /*!< TPI FIFO0: ITM_ATVALID Mask */ #define TPI_FIFO0_ITM_bytecount_Pos 27U /*!< TPI FIFO0: ITM_bytecount Position */ #define TPI_FIFO0_ITM_bytecount_Msk (0x3UL << TPI_FIFO0_ITM_bytecount_Pos) /*!< TPI FIFO0: ITM_bytecount Mask */ #define TPI_FIFO0_ETM_ATVALID_Pos 26U /*!< TPI FIFO0: ETM_ATVALID Position */ #define TPI_FIFO0_ETM_ATVALID_Msk (0x3UL << TPI_FIFO0_ETM_ATVALID_Pos) /*!< TPI FIFO0: ETM_ATVALID Mask */ #define TPI_FIFO0_ETM_bytecount_Pos 24U /*!< TPI FIFO0: ETM_bytecount Position */ #define TPI_FIFO0_ETM_bytecount_Msk (0x3UL << TPI_FIFO0_ETM_bytecount_Pos) /*!< TPI FIFO0: ETM_bytecount Mask */ #define TPI_FIFO0_ETM2_Pos 16U /*!< TPI FIFO0: ETM2 Position */ #define TPI_FIFO0_ETM2_Msk (0xFFUL << TPI_FIFO0_ETM2_Pos) /*!< TPI FIFO0: ETM2 Mask */ #define TPI_FIFO0_ETM1_Pos 8U /*!< TPI FIFO0: ETM1 Position */ #define TPI_FIFO0_ETM1_Msk (0xFFUL << TPI_FIFO0_ETM1_Pos) /*!< TPI FIFO0: ETM1 Mask */ #define TPI_FIFO0_ETM0_Pos 0U /*!< TPI FIFO0: ETM0 Position */ #define TPI_FIFO0_ETM0_Msk (0xFFUL /*<< TPI_FIFO0_ETM0_Pos*/) /*!< TPI FIFO0: ETM0 Mask */ /* TPI ITATBCTR2 Register Definitions */ #define TPI_ITATBCTR2_ATREADY_Pos 0U /*!< TPI ITATBCTR2: ATREADY Position */ #define TPI_ITATBCTR2_ATREADY_Msk (0x1UL /*<< TPI_ITATBCTR2_ATREADY_Pos*/) /*!< TPI ITATBCTR2: ATREADY Mask */ /* TPI Integration ITM Data Register Definitions (FIFO1) */ #define TPI_FIFO1_ITM_ATVALID_Pos 29U /*!< TPI FIFO1: ITM_ATVALID Position */ #define TPI_FIFO1_ITM_ATVALID_Msk (0x3UL << TPI_FIFO1_ITM_ATVALID_Pos) /*!< TPI FIFO1: ITM_ATVALID Mask */ #define TPI_FIFO1_ITM_bytecount_Pos 27U /*!< TPI FIFO1: ITM_bytecount Position */ #define TPI_FIFO1_ITM_bytecount_Msk (0x3UL << TPI_FIFO1_ITM_bytecount_Pos) /*!< TPI FIFO1: ITM_bytecount Mask */ #define TPI_FIFO1_ETM_ATVALID_Pos 26U /*!< TPI FIFO1: ETM_ATVALID Position */ #define TPI_FIFO1_ETM_ATVALID_Msk (0x3UL << TPI_FIFO1_ETM_ATVALID_Pos) /*!< TPI FIFO1: ETM_ATVALID Mask */ #define TPI_FIFO1_ETM_bytecount_Pos 24U /*!< TPI FIFO1: ETM_bytecount Position */ #define TPI_FIFO1_ETM_bytecount_Msk (0x3UL << TPI_FIFO1_ETM_bytecount_Pos) /*!< TPI FIFO1: ETM_bytecount Mask */ #define TPI_FIFO1_ITM2_Pos 16U /*!< TPI FIFO1: ITM2 Position */ #define TPI_FIFO1_ITM2_Msk (0xFFUL << TPI_FIFO1_ITM2_Pos) /*!< TPI FIFO1: ITM2 Mask */ #define TPI_FIFO1_ITM1_Pos 8U /*!< TPI FIFO1: ITM1 Position */ #define TPI_FIFO1_ITM1_Msk (0xFFUL << TPI_FIFO1_ITM1_Pos) /*!< TPI FIFO1: ITM1 Mask */ #define TPI_FIFO1_ITM0_Pos 0U /*!< TPI FIFO1: ITM0 Position */ #define TPI_FIFO1_ITM0_Msk (0xFFUL /*<< TPI_FIFO1_ITM0_Pos*/) /*!< TPI FIFO1: ITM0 Mask */ /* TPI ITATBCTR0 Register Definitions */ #define TPI_ITATBCTR0_ATREADY_Pos 0U /*!< TPI ITATBCTR0: ATREADY Position */ #define TPI_ITATBCTR0_ATREADY_Msk (0x1UL /*<< TPI_ITATBCTR0_ATREADY_Pos*/) /*!< TPI ITATBCTR0: ATREADY Mask */ /* TPI Integration Mode Control Register Definitions */ #define TPI_ITCTRL_Mode_Pos 0U /*!< TPI ITCTRL: Mode Position */ #define TPI_ITCTRL_Mode_Msk (0x1UL /*<< TPI_ITCTRL_Mode_Pos*/) /*!< TPI ITCTRL: Mode Mask */ /* TPI DEVID Register Definitions */ #define TPI_DEVID_NRZVALID_Pos 11U /*!< TPI DEVID: NRZVALID Position */ #define TPI_DEVID_NRZVALID_Msk (0x1UL << TPI_DEVID_NRZVALID_Pos) /*!< TPI DEVID: NRZVALID Mask */ #define TPI_DEVID_MANCVALID_Pos 10U /*!< TPI DEVID: MANCVALID Position */ #define TPI_DEVID_MANCVALID_Msk (0x1UL << TPI_DEVID_MANCVALID_Pos) /*!< TPI DEVID: MANCVALID Mask */ #define TPI_DEVID_PTINVALID_Pos 9U /*!< TPI DEVID: PTINVALID Position */ #define TPI_DEVID_PTINVALID_Msk (0x1UL << TPI_DEVID_PTINVALID_Pos) /*!< TPI DEVID: PTINVALID Mask */ #define TPI_DEVID_MinBufSz_Pos 6U /*!< TPI DEVID: MinBufSz Position */ #define TPI_DEVID_MinBufSz_Msk (0x7UL << TPI_DEVID_MinBufSz_Pos) /*!< TPI DEVID: MinBufSz Mask */ #define TPI_DEVID_AsynClkIn_Pos 5U /*!< TPI DEVID: AsynClkIn Position */ #define TPI_DEVID_AsynClkIn_Msk (0x1UL << TPI_DEVID_AsynClkIn_Pos) /*!< TPI DEVID: AsynClkIn Mask */ #define TPI_DEVID_NrTraceInput_Pos 0U /*!< TPI DEVID: NrTraceInput Position */ #define TPI_DEVID_NrTraceInput_Msk (0x1FUL /*<< TPI_DEVID_NrTraceInput_Pos*/) /*!< TPI DEVID: NrTraceInput Mask */ /* TPI DEVTYPE Register Definitions */ #define TPI_DEVTYPE_MajorType_Pos 4U /*!< TPI DEVTYPE: MajorType Position */ #define TPI_DEVTYPE_MajorType_Msk (0xFUL << TPI_DEVTYPE_MajorType_Pos) /*!< TPI DEVTYPE: MajorType Mask */ #define TPI_DEVTYPE_SubType_Pos 0U /*!< TPI DEVTYPE: SubType Position */ #define TPI_DEVTYPE_SubType_Msk (0xFUL /*<< TPI_DEVTYPE_SubType_Pos*/) /*!< TPI DEVTYPE: SubType Mask */ /*@}*/ /* end of group CMSIS_TPI */ #if (__MPU_PRESENT == 1U) /** \ingroup CMSIS_core_register \defgroup CMSIS_MPU Memory Protection Unit (MPU) \brief Type definitions for the Memory Protection Unit (MPU) @{ */ /** \brief Structure type to access the Memory Protection Unit (MPU). */ typedef struct { __IM uint32_t TYPE; /*!< Offset: 0x000 (R/ ) MPU Type Register */ __IOM uint32_t CTRL; /*!< Offset: 0x004 (R/W) MPU Control Register */ __IOM uint32_t RNR; /*!< Offset: 0x008 (R/W) MPU Region RNRber Register */ __IOM uint32_t RBAR; /*!< Offset: 0x00C (R/W) MPU Region Base Address Register */ __IOM uint32_t RASR; /*!< Offset: 0x010 (R/W) MPU Region Attribute and Size Register */ __IOM uint32_t RBAR_A1; /*!< Offset: 0x014 (R/W) MPU Alias 1 Region Base Address Register */ __IOM uint32_t RASR_A1; /*!< Offset: 0x018 (R/W) MPU Alias 1 Region Attribute and Size Register */ __IOM uint32_t RBAR_A2; /*!< Offset: 0x01C (R/W) MPU Alias 2 Region Base Address Register */ __IOM uint32_t RASR_A2; /*!< Offset: 0x020 (R/W) MPU Alias 2 Region Attribute and Size Register */ __IOM uint32_t RBAR_A3; /*!< Offset: 0x024 (R/W) MPU Alias 3 Region Base Address Register */ __IOM uint32_t RASR_A3; /*!< Offset: 0x028 (R/W) MPU Alias 3 Region Attribute and Size Register */ } MPU_Type; /* MPU Type Register Definitions */ #define MPU_TYPE_IREGION_Pos 16U /*!< MPU TYPE: IREGION Position */ #define MPU_TYPE_IREGION_Msk (0xFFUL << MPU_TYPE_IREGION_Pos) /*!< MPU TYPE: IREGION Mask */ #define MPU_TYPE_DREGION_Pos 8U /*!< MPU TYPE: DREGION Position */ #define MPU_TYPE_DREGION_Msk (0xFFUL << MPU_TYPE_DREGION_Pos) /*!< MPU TYPE: DREGION Mask */ #define MPU_TYPE_SEPARATE_Pos 0U /*!< MPU TYPE: SEPARATE Position */ #define MPU_TYPE_SEPARATE_Msk (1UL /*<< MPU_TYPE_SEPARATE_Pos*/) /*!< MPU TYPE: SEPARATE Mask */ /* MPU Control Register Definitions */ #define MPU_CTRL_PRIVDEFENA_Pos 2U /*!< MPU CTRL: PRIVDEFENA Position */ #define MPU_CTRL_PRIVDEFENA_Msk (1UL << MPU_CTRL_PRIVDEFENA_Pos) /*!< MPU CTRL: PRIVDEFENA Mask */ #define MPU_CTRL_HFNMIENA_Pos 1U /*!< MPU CTRL: HFNMIENA Position */ #define MPU_CTRL_HFNMIENA_Msk (1UL << MPU_CTRL_HFNMIENA_Pos) /*!< MPU CTRL: HFNMIENA Mask */ #define MPU_CTRL_ENABLE_Pos 0U /*!< MPU CTRL: ENABLE Position */ #define MPU_CTRL_ENABLE_Msk (1UL /*<< MPU_CTRL_ENABLE_Pos*/) /*!< MPU CTRL: ENABLE Mask */ /* MPU Region Number Register Definitions */ #define MPU_RNR_REGION_Pos 0U /*!< MPU RNR: REGION Position */ #define MPU_RNR_REGION_Msk (0xFFUL /*<< MPU_RNR_REGION_Pos*/) /*!< MPU RNR: REGION Mask */ /* MPU Region Base Address Register Definitions */ #define MPU_RBAR_ADDR_Pos 5U /*!< MPU RBAR: ADDR Position */ #define MPU_RBAR_ADDR_Msk (0x7FFFFFFUL << MPU_RBAR_ADDR_Pos) /*!< MPU RBAR: ADDR Mask */ #define MPU_RBAR_VALID_Pos 4U /*!< MPU RBAR: VALID Position */ #define MPU_RBAR_VALID_Msk (1UL << MPU_RBAR_VALID_Pos) /*!< MPU RBAR: VALID Mask */ #define MPU_RBAR_REGION_Pos 0U /*!< MPU RBAR: REGION Position */ #define MPU_RBAR_REGION_Msk (0xFUL /*<< MPU_RBAR_REGION_Pos*/) /*!< MPU RBAR: REGION Mask */ /* MPU Region Attribute and Size Register Definitions */ #define MPU_RASR_ATTRS_Pos 16U /*!< MPU RASR: MPU Region Attribute field Position */ #define MPU_RASR_ATTRS_Msk (0xFFFFUL << MPU_RASR_ATTRS_Pos) /*!< MPU RASR: MPU Region Attribute field Mask */ #define MPU_RASR_XN_Pos 28U /*!< MPU RASR: ATTRS.XN Position */ #define MPU_RASR_XN_Msk (1UL << MPU_RASR_XN_Pos) /*!< MPU RASR: ATTRS.XN Mask */ #define MPU_RASR_AP_Pos 24U /*!< MPU RASR: ATTRS.AP Position */ #define MPU_RASR_AP_Msk (0x7UL << MPU_RASR_AP_Pos) /*!< MPU RASR: ATTRS.AP Mask */ #define MPU_RASR_TEX_Pos 19U /*!< MPU RASR: ATTRS.TEX Position */ #define MPU_RASR_TEX_Msk (0x7UL << MPU_RASR_TEX_Pos) /*!< MPU RASR: ATTRS.TEX Mask */ #define MPU_RASR_S_Pos 18U /*!< MPU RASR: ATTRS.S Position */ #define MPU_RASR_S_Msk (1UL << MPU_RASR_S_Pos) /*!< MPU RASR: ATTRS.S Mask */ #define MPU_RASR_C_Pos 17U /*!< MPU RASR: ATTRS.C Position */ #define MPU_RASR_C_Msk (1UL << MPU_RASR_C_Pos) /*!< MPU RASR: ATTRS.C Mask */ #define MPU_RASR_B_Pos 16U /*!< MPU RASR: ATTRS.B Position */ #define MPU_RASR_B_Msk (1UL << MPU_RASR_B_Pos) /*!< MPU RASR: ATTRS.B Mask */ #define MPU_RASR_SRD_Pos 8U /*!< MPU RASR: Sub-Region Disable Position */ #define MPU_RASR_SRD_Msk (0xFFUL << MPU_RASR_SRD_Pos) /*!< MPU RASR: Sub-Region Disable Mask */ #define MPU_RASR_SIZE_Pos 1U /*!< MPU RASR: Region Size Field Position */ #define MPU_RASR_SIZE_Msk (0x1FUL << MPU_RASR_SIZE_Pos) /*!< MPU RASR: Region Size Field Mask */ #define MPU_RASR_ENABLE_Pos 0U /*!< MPU RASR: Region enable bit Position */ #define MPU_RASR_ENABLE_Msk (1UL /*<< MPU_RASR_ENABLE_Pos*/) /*!< MPU RASR: Region enable bit Disable Mask */ /*@} end of group CMSIS_MPU */ #endif #if (__FPU_PRESENT == 1U) /** \ingroup CMSIS_core_register \defgroup CMSIS_FPU Floating Point Unit (FPU) \brief Type definitions for the Floating Point Unit (FPU) @{ */ /** \brief Structure type to access the Floating Point Unit (FPU). */ typedef struct { uint32_t RESERVED0[1U]; __IOM uint32_t FPCCR; /*!< Offset: 0x004 (R/W) Floating-Point Context Control Register */ __IOM uint32_t FPCAR; /*!< Offset: 0x008 (R/W) Floating-Point Context Address Register */ __IOM uint32_t FPDSCR; /*!< Offset: 0x00C (R/W) Floating-Point Default Status Control Register */ __IM uint32_t MVFR0; /*!< Offset: 0x010 (R/ ) Media and FP Feature Register 0 */ __IM uint32_t MVFR1; /*!< Offset: 0x014 (R/ ) Media and FP Feature Register 1 */ } FPU_Type; /* Floating-Point Context Control Register Definitions */ #define FPU_FPCCR_ASPEN_Pos 31U /*!< FPCCR: ASPEN bit Position */ #define FPU_FPCCR_ASPEN_Msk (1UL << FPU_FPCCR_ASPEN_Pos) /*!< FPCCR: ASPEN bit Mask */ #define FPU_FPCCR_LSPEN_Pos 30U /*!< FPCCR: LSPEN Position */ #define FPU_FPCCR_LSPEN_Msk (1UL << FPU_FPCCR_LSPEN_Pos) /*!< FPCCR: LSPEN bit Mask */ #define FPU_FPCCR_MONRDY_Pos 8U /*!< FPCCR: MONRDY Position */ #define FPU_FPCCR_MONRDY_Msk (1UL << FPU_FPCCR_MONRDY_Pos) /*!< FPCCR: MONRDY bit Mask */ #define FPU_FPCCR_BFRDY_Pos 6U /*!< FPCCR: BFRDY Position */ #define FPU_FPCCR_BFRDY_Msk (1UL << FPU_FPCCR_BFRDY_Pos) /*!< FPCCR: BFRDY bit Mask */ #define FPU_FPCCR_MMRDY_Pos 5U /*!< FPCCR: MMRDY Position */ #define FPU_FPCCR_MMRDY_Msk (1UL << FPU_FPCCR_MMRDY_Pos) /*!< FPCCR: MMRDY bit Mask */ #define FPU_FPCCR_HFRDY_Pos 4U /*!< FPCCR: HFRDY Position */ #define FPU_FPCCR_HFRDY_Msk (1UL << FPU_FPCCR_HFRDY_Pos) /*!< FPCCR: HFRDY bit Mask */ #define FPU_FPCCR_THREAD_Pos 3U /*!< FPCCR: processor mode bit Position */ #define FPU_FPCCR_THREAD_Msk (1UL << FPU_FPCCR_THREAD_Pos) /*!< FPCCR: processor mode active bit Mask */ #define FPU_FPCCR_USER_Pos 1U /*!< FPCCR: privilege level bit Position */ #define FPU_FPCCR_USER_Msk (1UL << FPU_FPCCR_USER_Pos) /*!< FPCCR: privilege level bit Mask */ #define FPU_FPCCR_LSPACT_Pos 0U /*!< FPCCR: Lazy state preservation active bit Position */ #define FPU_FPCCR_LSPACT_Msk (1UL /*<< FPU_FPCCR_LSPACT_Pos*/) /*!< FPCCR: Lazy state preservation active bit Mask */ /* Floating-Point Context Address Register Definitions */ #define FPU_FPCAR_ADDRESS_Pos 3U /*!< FPCAR: ADDRESS bit Position */ #define FPU_FPCAR_ADDRESS_Msk (0x1FFFFFFFUL << FPU_FPCAR_ADDRESS_Pos) /*!< FPCAR: ADDRESS bit Mask */ /* Floating-Point Default Status Control Register Definitions */ #define FPU_FPDSCR_AHP_Pos 26U /*!< FPDSCR: AHP bit Position */ #define FPU_FPDSCR_AHP_Msk (1UL << FPU_FPDSCR_AHP_Pos) /*!< FPDSCR: AHP bit Mask */ #define FPU_FPDSCR_DN_Pos 25U /*!< FPDSCR: DN bit Position */ #define FPU_FPDSCR_DN_Msk (1UL << FPU_FPDSCR_DN_Pos) /*!< FPDSCR: DN bit Mask */ #define FPU_FPDSCR_FZ_Pos 24U /*!< FPDSCR: FZ bit Position */ #define FPU_FPDSCR_FZ_Msk (1UL << FPU_FPDSCR_FZ_Pos) /*!< FPDSCR: FZ bit Mask */ #define FPU_FPDSCR_RMode_Pos 22U /*!< FPDSCR: RMode bit Position */ #define FPU_FPDSCR_RMode_Msk (3UL << FPU_FPDSCR_RMode_Pos) /*!< FPDSCR: RMode bit Mask */ /* Media and FP Feature Register 0 Definitions */ #define FPU_MVFR0_FP_rounding_modes_Pos 28U /*!< MVFR0: FP rounding modes bits Position */ #define FPU_MVFR0_FP_rounding_modes_Msk (0xFUL << FPU_MVFR0_FP_rounding_modes_Pos) /*!< MVFR0: FP rounding modes bits Mask */ #define FPU_MVFR0_Short_vectors_Pos 24U /*!< MVFR0: Short vectors bits Position */ #define FPU_MVFR0_Short_vectors_Msk (0xFUL << FPU_MVFR0_Short_vectors_Pos) /*!< MVFR0: Short vectors bits Mask */ #define FPU_MVFR0_Square_root_Pos 20U /*!< MVFR0: Square root bits Position */ #define FPU_MVFR0_Square_root_Msk (0xFUL << FPU_MVFR0_Square_root_Pos) /*!< MVFR0: Square root bits Mask */ #define FPU_MVFR0_Divide_Pos 16U /*!< MVFR0: Divide bits Position */ #define FPU_MVFR0_Divide_Msk (0xFUL << FPU_MVFR0_Divide_Pos) /*!< MVFR0: Divide bits Mask */ #define FPU_MVFR0_FP_excep_trapping_Pos 12U /*!< MVFR0: FP exception trapping bits Position */ #define FPU_MVFR0_FP_excep_trapping_Msk (0xFUL << FPU_MVFR0_FP_excep_trapping_Pos) /*!< MVFR0: FP exception trapping bits Mask */ #define FPU_MVFR0_Double_precision_Pos 8U /*!< MVFR0: Double-precision bits Position */ #define FPU_MVFR0_Double_precision_Msk (0xFUL << FPU_MVFR0_Double_precision_Pos) /*!< MVFR0: Double-precision bits Mask */ #define FPU_MVFR0_Single_precision_Pos 4U /*!< MVFR0: Single-precision bits Position */ #define FPU_MVFR0_Single_precision_Msk (0xFUL << FPU_MVFR0_Single_precision_Pos) /*!< MVFR0: Single-precision bits Mask */ #define FPU_MVFR0_A_SIMD_registers_Pos 0U /*!< MVFR0: A_SIMD registers bits Position */ #define FPU_MVFR0_A_SIMD_registers_Msk (0xFUL /*<< FPU_MVFR0_A_SIMD_registers_Pos*/) /*!< MVFR0: A_SIMD registers bits Mask */ /* Media and FP Feature Register 1 Definitions */ #define FPU_MVFR1_FP_fused_MAC_Pos 28U /*!< MVFR1: FP fused MAC bits Position */ #define FPU_MVFR1_FP_fused_MAC_Msk (0xFUL << FPU_MVFR1_FP_fused_MAC_Pos) /*!< MVFR1: FP fused MAC bits Mask */ #define FPU_MVFR1_FP_HPFP_Pos 24U /*!< MVFR1: FP HPFP bits Position */ #define FPU_MVFR1_FP_HPFP_Msk (0xFUL << FPU_MVFR1_FP_HPFP_Pos) /*!< MVFR1: FP HPFP bits Mask */ #define FPU_MVFR1_D_NaN_mode_Pos 4U /*!< MVFR1: D_NaN mode bits Position */ #define FPU_MVFR1_D_NaN_mode_Msk (0xFUL << FPU_MVFR1_D_NaN_mode_Pos) /*!< MVFR1: D_NaN mode bits Mask */ #define FPU_MVFR1_FtZ_mode_Pos 0U /*!< MVFR1: FtZ mode bits Position */ #define FPU_MVFR1_FtZ_mode_Msk (0xFUL /*<< FPU_MVFR1_FtZ_mode_Pos*/) /*!< MVFR1: FtZ mode bits Mask */ /*@} end of group CMSIS_FPU */ #endif /** \ingroup CMSIS_core_register \defgroup CMSIS_CoreDebug Core Debug Registers (CoreDebug) \brief Type definitions for the Core Debug Registers @{ */ /** \brief Structure type to access the Core Debug Register (CoreDebug). */ typedef struct { __IOM uint32_t DHCSR; /*!< Offset: 0x000 (R/W) Debug Halting Control and Status Register */ __OM uint32_t DCRSR; /*!< Offset: 0x004 ( /W) Debug Core Register Selector Register */ __IOM uint32_t DCRDR; /*!< Offset: 0x008 (R/W) Debug Core Register Data Register */ __IOM uint32_t DEMCR; /*!< Offset: 0x00C (R/W) Debug Exception and Monitor Control Register */ } CoreDebug_Type; /* Debug Halting Control and Status Register Definitions */ #define CoreDebug_DHCSR_DBGKEY_Pos 16U /*!< CoreDebug DHCSR: DBGKEY Position */ #define CoreDebug_DHCSR_DBGKEY_Msk (0xFFFFUL << CoreDebug_DHCSR_DBGKEY_Pos) /*!< CoreDebug DHCSR: DBGKEY Mask */ #define CoreDebug_DHCSR_S_RESET_ST_Pos 25U /*!< CoreDebug DHCSR: S_RESET_ST Position */ #define CoreDebug_DHCSR_S_RESET_ST_Msk (1UL << CoreDebug_DHCSR_S_RESET_ST_Pos) /*!< CoreDebug DHCSR: S_RESET_ST Mask */ #define CoreDebug_DHCSR_S_RETIRE_ST_Pos 24U /*!< CoreDebug DHCSR: S_RETIRE_ST Position */ #define CoreDebug_DHCSR_S_RETIRE_ST_Msk (1UL << CoreDebug_DHCSR_S_RETIRE_ST_Pos) /*!< CoreDebug DHCSR: S_RETIRE_ST Mask */ #define CoreDebug_DHCSR_S_LOCKUP_Pos 19U /*!< CoreDebug DHCSR: S_LOCKUP Position */ #define CoreDebug_DHCSR_S_LOCKUP_Msk (1UL << CoreDebug_DHCSR_S_LOCKUP_Pos) /*!< CoreDebug DHCSR: S_LOCKUP Mask */ #define CoreDebug_DHCSR_S_SLEEP_Pos 18U /*!< CoreDebug DHCSR: S_SLEEP Position */ #define CoreDebug_DHCSR_S_SLEEP_Msk (1UL << CoreDebug_DHCSR_S_SLEEP_Pos) /*!< CoreDebug DHCSR: S_SLEEP Mask */ #define CoreDebug_DHCSR_S_HALT_Pos 17U /*!< CoreDebug DHCSR: S_HALT Position */ #define CoreDebug_DHCSR_S_HALT_Msk (1UL << CoreDebug_DHCSR_S_HALT_Pos) /*!< CoreDebug DHCSR: S_HALT Mask */ #define CoreDebug_DHCSR_S_REGRDY_Pos 16U /*!< CoreDebug DHCSR: S_REGRDY Position */ #define CoreDebug_DHCSR_S_REGRDY_Msk (1UL << CoreDebug_DHCSR_S_REGRDY_Pos) /*!< CoreDebug DHCSR: S_REGRDY Mask */ #define CoreDebug_DHCSR_C_SNAPSTALL_Pos 5U /*!< CoreDebug DHCSR: C_SNAPSTALL Position */ #define CoreDebug_DHCSR_C_SNAPSTALL_Msk (1UL << CoreDebug_DHCSR_C_SNAPSTALL_Pos) /*!< CoreDebug DHCSR: C_SNAPSTALL Mask */ #define CoreDebug_DHCSR_C_MASKINTS_Pos 3U /*!< CoreDebug DHCSR: C_MASKINTS Position */ #define CoreDebug_DHCSR_C_MASKINTS_Msk (1UL << CoreDebug_DHCSR_C_MASKINTS_Pos) /*!< CoreDebug DHCSR: C_MASKINTS Mask */ #define CoreDebug_DHCSR_C_STEP_Pos 2U /*!< CoreDebug DHCSR: C_STEP Position */ #define CoreDebug_DHCSR_C_STEP_Msk (1UL << CoreDebug_DHCSR_C_STEP_Pos) /*!< CoreDebug DHCSR: C_STEP Mask */ #define CoreDebug_DHCSR_C_HALT_Pos 1U /*!< CoreDebug DHCSR: C_HALT Position */ #define CoreDebug_DHCSR_C_HALT_Msk (1UL << CoreDebug_DHCSR_C_HALT_Pos) /*!< CoreDebug DHCSR: C_HALT Mask */ #define CoreDebug_DHCSR_C_DEBUGEN_Pos 0U /*!< CoreDebug DHCSR: C_DEBUGEN Position */ #define CoreDebug_DHCSR_C_DEBUGEN_Msk (1UL /*<< CoreDebug_DHCSR_C_DEBUGEN_Pos*/) /*!< CoreDebug DHCSR: C_DEBUGEN Mask */ /* Debug Core Register Selector Register Definitions */ #define CoreDebug_DCRSR_REGWnR_Pos 16U /*!< CoreDebug DCRSR: REGWnR Position */ #define CoreDebug_DCRSR_REGWnR_Msk (1UL << CoreDebug_DCRSR_REGWnR_Pos) /*!< CoreDebug DCRSR: REGWnR Mask */ #define CoreDebug_DCRSR_REGSEL_Pos 0U /*!< CoreDebug DCRSR: REGSEL Position */ #define CoreDebug_DCRSR_REGSEL_Msk (0x1FUL /*<< CoreDebug_DCRSR_REGSEL_Pos*/) /*!< CoreDebug DCRSR: REGSEL Mask */ /* Debug Exception and Monitor Control Register Definitions */ #define CoreDebug_DEMCR_TRCENA_Pos 24U /*!< CoreDebug DEMCR: TRCENA Position */ #define CoreDebug_DEMCR_TRCENA_Msk (1UL << CoreDebug_DEMCR_TRCENA_Pos) /*!< CoreDebug DEMCR: TRCENA Mask */ #define CoreDebug_DEMCR_MON_REQ_Pos 19U /*!< CoreDebug DEMCR: MON_REQ Position */ #define CoreDebug_DEMCR_MON_REQ_Msk (1UL << CoreDebug_DEMCR_MON_REQ_Pos) /*!< CoreDebug DEMCR: MON_REQ Mask */ #define CoreDebug_DEMCR_MON_STEP_Pos 18U /*!< CoreDebug DEMCR: MON_STEP Position */ #define CoreDebug_DEMCR_MON_STEP_Msk (1UL << CoreDebug_DEMCR_MON_STEP_Pos) /*!< CoreDebug DEMCR: MON_STEP Mask */ #define CoreDebug_DEMCR_MON_PEND_Pos 17U /*!< CoreDebug DEMCR: MON_PEND Position */ #define CoreDebug_DEMCR_MON_PEND_Msk (1UL << CoreDebug_DEMCR_MON_PEND_Pos) /*!< CoreDebug DEMCR: MON_PEND Mask */ #define CoreDebug_DEMCR_MON_EN_Pos 16U /*!< CoreDebug DEMCR: MON_EN Position */ #define CoreDebug_DEMCR_MON_EN_Msk (1UL << CoreDebug_DEMCR_MON_EN_Pos) /*!< CoreDebug DEMCR: MON_EN Mask */ #define CoreDebug_DEMCR_VC_HARDERR_Pos 10U /*!< CoreDebug DEMCR: VC_HARDERR Position */ #define CoreDebug_DEMCR_VC_HARDERR_Msk (1UL << CoreDebug_DEMCR_VC_HARDERR_Pos) /*!< CoreDebug DEMCR: VC_HARDERR Mask */ #define CoreDebug_DEMCR_VC_INTERR_Pos 9U /*!< CoreDebug DEMCR: VC_INTERR Position */ #define CoreDebug_DEMCR_VC_INTERR_Msk (1UL << CoreDebug_DEMCR_VC_INTERR_Pos) /*!< CoreDebug DEMCR: VC_INTERR Mask */ #define CoreDebug_DEMCR_VC_BUSERR_Pos 8U /*!< CoreDebug DEMCR: VC_BUSERR Position */ #define CoreDebug_DEMCR_VC_BUSERR_Msk (1UL << CoreDebug_DEMCR_VC_BUSERR_Pos) /*!< CoreDebug DEMCR: VC_BUSERR Mask */ #define CoreDebug_DEMCR_VC_STATERR_Pos 7U /*!< CoreDebug DEMCR: VC_STATERR Position */ #define CoreDebug_DEMCR_VC_STATERR_Msk (1UL << CoreDebug_DEMCR_VC_STATERR_Pos) /*!< CoreDebug DEMCR: VC_STATERR Mask */ #define CoreDebug_DEMCR_VC_CHKERR_Pos 6U /*!< CoreDebug DEMCR: VC_CHKERR Position */ #define CoreDebug_DEMCR_VC_CHKERR_Msk (1UL << CoreDebug_DEMCR_VC_CHKERR_Pos) /*!< CoreDebug DEMCR: VC_CHKERR Mask */ #define CoreDebug_DEMCR_VC_NOCPERR_Pos 5U /*!< CoreDebug DEMCR: VC_NOCPERR Position */ #define CoreDebug_DEMCR_VC_NOCPERR_Msk (1UL << CoreDebug_DEMCR_VC_NOCPERR_Pos) /*!< CoreDebug DEMCR: VC_NOCPERR Mask */ #define CoreDebug_DEMCR_VC_MMERR_Pos 4U /*!< CoreDebug DEMCR: VC_MMERR Position */ #define CoreDebug_DEMCR_VC_MMERR_Msk (1UL << CoreDebug_DEMCR_VC_MMERR_Pos) /*!< CoreDebug DEMCR: VC_MMERR Mask */ #define CoreDebug_DEMCR_VC_CORERESET_Pos 0U /*!< CoreDebug DEMCR: VC_CORERESET Position */ #define CoreDebug_DEMCR_VC_CORERESET_Msk (1UL /*<< CoreDebug_DEMCR_VC_CORERESET_Pos*/) /*!< CoreDebug DEMCR: VC_CORERESET Mask */ /*@} end of group CMSIS_CoreDebug */ /** \ingroup CMSIS_core_register \defgroup CMSIS_core_bitfield Core register bit field macros \brief Macros for use with bit field definitions (xxx_Pos, xxx_Msk). @{ */ /** \brief Mask and shift a bit field value for use in a register bit range. \param[in] field Name of the register bit field. \param[in] value Value of the bit field. \return Masked and shifted value. */ #define _VAL2FLD(field, value) ((value << field ## _Pos) & field ## _Msk) /** \brief Mask and shift a register value to extract a bit filed value. \param[in] field Name of the register bit field. \param[in] value Value of register. \return Masked and shifted bit field value. */ #define _FLD2VAL(field, value) ((value & field ## _Msk) >> field ## _Pos) /*@} end of group CMSIS_core_bitfield */ /** \ingroup CMSIS_core_register \defgroup CMSIS_core_base Core Definitions \brief Definitions for base addresses, unions, and structures. @{ */ /* Memory mapping of Cortex-M4 Hardware */ #define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */ #define ITM_BASE (0xE0000000UL) /*!< ITM Base Address */ #define DWT_BASE (0xE0001000UL) /*!< DWT Base Address */ #define TPI_BASE (0xE0040000UL) /*!< TPI Base Address */ #define CoreDebug_BASE (0xE000EDF0UL) /*!< Core Debug Base Address */ #define SysTick_BASE (SCS_BASE + 0x0010UL) /*!< SysTick Base Address */ #define NVIC_BASE (SCS_BASE + 0x0100UL) /*!< NVIC Base Address */ #define SCB_BASE (SCS_BASE + 0x0D00UL) /*!< System Control Block Base Address */ #define SCnSCB ((SCnSCB_Type *) SCS_BASE ) /*!< System control Register not in SCB */ #define SCB ((SCB_Type *) SCB_BASE ) /*!< SCB configuration struct */ #define SysTick ((SysTick_Type *) SysTick_BASE ) /*!< SysTick configuration struct */ #define NVIC ((NVIC_Type *) NVIC_BASE ) /*!< NVIC configuration struct */ #define ITM ((ITM_Type *) ITM_BASE ) /*!< ITM configuration struct */ #define DWT ((DWT_Type *) DWT_BASE ) /*!< DWT configuration struct */ #define TPI ((TPI_Type *) TPI_BASE ) /*!< TPI configuration struct */ #define CoreDebug ((CoreDebug_Type *) CoreDebug_BASE) /*!< Core Debug configuration struct */ #if (__MPU_PRESENT == 1U) #define MPU_BASE (SCS_BASE + 0x0D90UL) /*!< Memory Protection Unit */ #define MPU ((MPU_Type *) MPU_BASE ) /*!< Memory Protection Unit */ #endif #if (__FPU_PRESENT == 1U) #define FPU_BASE (SCS_BASE + 0x0F30UL) /*!< Floating Point Unit */ #define FPU ((FPU_Type *) FPU_BASE ) /*!< Floating Point Unit */ #endif /*@} */ /******************************************************************************* * Hardware Abstraction Layer Core Function Interface contains: - Core NVIC Functions - Core SysTick Functions - Core Debug Functions - Core Register Access Functions ******************************************************************************/ /** \defgroup CMSIS_Core_FunctionInterface Functions and Instructions Reference */ /* ########################## NVIC functions #################################### */ /** \ingroup CMSIS_Core_FunctionInterface \defgroup CMSIS_Core_NVICFunctions NVIC Functions \brief Functions that manage interrupts and exceptions via the NVIC. @{ */ /** \brief Set Priority Grouping \details Sets the priority grouping field using the required unlock sequence. The parameter PriorityGroup is assigned to the field SCB->AIRCR [10:8] PRIGROUP field. Only values from 0..7 are used. In case of a conflict between priority grouping and available priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. \param [in] PriorityGroup Priority grouping field. */ __STATIC_INLINE void NVIC_SetPriorityGrouping(uint32_t PriorityGroup) { uint32_t reg_value; uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ reg_value = SCB->AIRCR; /* read old register configuration */ reg_value &= ~((uint32_t)(SCB_AIRCR_VECTKEY_Msk | SCB_AIRCR_PRIGROUP_Msk)); /* clear bits to change */ reg_value = (reg_value | ((uint32_t)0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | (PriorityGroupTmp << 8U) ); /* Insert write key and priorty group */ SCB->AIRCR = reg_value; } /** \brief Get Priority Grouping \details Reads the priority grouping field from the NVIC Interrupt Controller. \return Priority grouping field (SCB->AIRCR [10:8] PRIGROUP field). */ __STATIC_INLINE uint32_t NVIC_GetPriorityGrouping(void) { return ((uint32_t)((SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) >> SCB_AIRCR_PRIGROUP_Pos)); } /** \brief Enable External Interrupt \details Enables a device-specific interrupt in the NVIC interrupt controller. \param [in] IRQn External interrupt number. Value cannot be negative. */ __STATIC_INLINE void NVIC_EnableIRQ(IRQn_Type IRQn) { NVIC->ISER[(((uint32_t)(int32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); } /** \brief Disable External Interrupt \details Disables a device-specific interrupt in the NVIC interrupt controller. \param [in] IRQn External interrupt number. Value cannot be negative. */ __STATIC_INLINE void NVIC_DisableIRQ(IRQn_Type IRQn) { NVIC->ICER[(((uint32_t)(int32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); } /** \brief Get Pending Interrupt \details Reads the pending register in the NVIC and returns the pending bit for the specified interrupt. \param [in] IRQn Interrupt number. \return 0 Interrupt status is not pending. \return 1 Interrupt status is pending. */ __STATIC_INLINE uint32_t NVIC_GetPendingIRQ(IRQn_Type IRQn) { return((uint32_t)(((NVIC->ISPR[(((uint32_t)(int32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); } /** \brief Set Pending Interrupt \details Sets the pending bit of an external interrupt. \param [in] IRQn Interrupt number. Value cannot be negative. */ __STATIC_INLINE void NVIC_SetPendingIRQ(IRQn_Type IRQn) { NVIC->ISPR[(((uint32_t)(int32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); } /** \brief Clear Pending Interrupt \details Clears the pending bit of an external interrupt. \param [in] IRQn External interrupt number. Value cannot be negative. */ __STATIC_INLINE void NVIC_ClearPendingIRQ(IRQn_Type IRQn) { NVIC->ICPR[(((uint32_t)(int32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); } /** \brief Get Active Interrupt \details Reads the active register in NVIC and returns the active bit. \param [in] IRQn Interrupt number. \return 0 Interrupt status is not active. \return 1 Interrupt status is active. */ __STATIC_INLINE uint32_t NVIC_GetActive(IRQn_Type IRQn) { return((uint32_t)(((NVIC->IABR[(((uint32_t)(int32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); } /** \brief Set Interrupt Priority \details Sets the priority of an interrupt. \note The priority cannot be set for every core interrupt. \param [in] IRQn Interrupt number. \param [in] priority Priority to set. */ __STATIC_INLINE void NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority) { if ((int32_t)(IRQn) < 0) { SCB->SHP[(((uint32_t)(int32_t)IRQn) & 0xFUL)-4UL] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); } else { NVIC->IP[((uint32_t)(int32_t)IRQn)] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); } } /** \brief Get Interrupt Priority \details Reads the priority of an interrupt. The interrupt number can be positive to specify an external (device specific) interrupt, or negative to specify an internal (core) interrupt. \param [in] IRQn Interrupt number. \return Interrupt Priority. Value is aligned automatically to the implemented priority bits of the microcontroller. */ __STATIC_INLINE uint32_t NVIC_GetPriority(IRQn_Type IRQn) { if ((int32_t)(IRQn) < 0) { return(((uint32_t)SCB->SHP[(((uint32_t)(int32_t)IRQn) & 0xFUL)-4UL] >> (8U - __NVIC_PRIO_BITS))); } else { return(((uint32_t)NVIC->IP[((uint32_t)(int32_t)IRQn)] >> (8U - __NVIC_PRIO_BITS))); } } /** \brief Encode Priority \details Encodes the priority for an interrupt with the given priority group, preemptive priority value, and subpriority value. In case of a conflict between priority grouping and available priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. \param [in] PriorityGroup Used priority group. \param [in] PreemptPriority Preemptive priority value (starting from 0). \param [in] SubPriority Subpriority value (starting from 0). \return Encoded priority. Value can be used in the function \ref NVIC_SetPriority(). */ __STATIC_INLINE uint32_t NVIC_EncodePriority (uint32_t PriorityGroup, uint32_t PreemptPriority, uint32_t SubPriority) { uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ uint32_t PreemptPriorityBits; uint32_t SubPriorityBits; PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); return ( ((PreemptPriority & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL)) << SubPriorityBits) | ((SubPriority & (uint32_t)((1UL << (SubPriorityBits )) - 1UL))) ); } /** \brief Decode Priority \details Decodes an interrupt priority value with a given priority group to preemptive priority value and subpriority value. In case of a conflict between priority grouping and available priority bits (__NVIC_PRIO_BITS) the smallest possible priority group is set. \param [in] Priority Priority value, which can be retrieved with the function \ref NVIC_GetPriority(). \param [in] PriorityGroup Used priority group. \param [out] pPreemptPriority Preemptive priority value (starting from 0). \param [out] pSubPriority Subpriority value (starting from 0). */ __STATIC_INLINE void NVIC_DecodePriority (uint32_t Priority, uint32_t PriorityGroup, uint32_t* const pPreemptPriority, uint32_t* const pSubPriority) { uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ uint32_t PreemptPriorityBits; uint32_t SubPriorityBits; PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); *pPreemptPriority = (Priority >> SubPriorityBits) & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL); *pSubPriority = (Priority ) & (uint32_t)((1UL << (SubPriorityBits )) - 1UL); } /** \brief System Reset \details Initiates a system reset request to reset the MCU. */ __STATIC_INLINE void NVIC_SystemReset(void) { __DSB(); /* Ensure all outstanding memory accesses included buffered write are completed before reset */ SCB->AIRCR = (uint32_t)((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | (SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) | SCB_AIRCR_SYSRESETREQ_Msk ); /* Keep priority group unchanged */ __DSB(); /* Ensure completion of memory access */ for(;;) /* wait until reset */ { __NOP(); } } /*@} end of CMSIS_Core_NVICFunctions */ /* ################################## SysTick function ############################################ */ /** \ingroup CMSIS_Core_FunctionInterface \defgroup CMSIS_Core_SysTickFunctions SysTick Functions \brief Functions that configure the System. @{ */ #if (__Vendor_SysTickConfig == 0U) /** \brief System Tick Configuration \details Initializes the System Timer and its interrupt, and starts the System Tick Timer. Counter is in free running mode to generate periodic interrupts. \param [in] ticks Number of ticks between two interrupts. \return 0 Function succeeded. \return 1 Function failed. \note When the variable __Vendor_SysTickConfig is set to 1, then the function SysTick_Config is not included. In this case, the file device.h must contain a vendor-specific implementation of this function. */ __STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks) { if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk) { return (1UL); /* Reload value impossible */ } SysTick->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ NVIC_SetPriority (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ SysTick->VAL = 0UL; /* Load the SysTick Counter Value */ SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | SysTick_CTRL_TICKINT_Msk | SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ return (0UL); /* Function successful */ } #endif /*@} end of CMSIS_Core_SysTickFunctions */ /* ##################################### Debug In/Output function ########################################### */ /** \ingroup CMSIS_Core_FunctionInterface \defgroup CMSIS_core_DebugFunctions ITM Functions \brief Functions that access the ITM debug interface. @{ */ extern volatile int32_t ITM_RxBuffer; /*!< External variable to receive characters. */ #define ITM_RXBUFFER_EMPTY 0x5AA55AA5U /*!< Value identifying \ref ITM_RxBuffer is ready for next character. */ /** \brief ITM Send Character \details Transmits a character via the ITM channel 0, and \li Just returns when no debugger is connected that has booked the output. \li Is blocking when a debugger is connected, but the previous character sent has not been transmitted. \param [in] ch Character to transmit. \returns Character to transmit. */ __STATIC_INLINE uint32_t ITM_SendChar (uint32_t ch) { if (((ITM->TCR & ITM_TCR_ITMENA_Msk) != 0UL) && /* ITM enabled */ ((ITM->TER & 1UL ) != 0UL) ) /* ITM Port #0 enabled */ { while (ITM->PORT[0U].u32 == 0UL) { __NOP(); } ITM->PORT[0U].u8 = (uint8_t)ch; } return (ch); } /** \brief ITM Receive Character \details Inputs a character via the external variable \ref ITM_RxBuffer. \return Received character. \return -1 No character pending. */ __STATIC_INLINE int32_t ITM_ReceiveChar (void) { int32_t ch = -1; /* no character available */ if (ITM_RxBuffer != ITM_RXBUFFER_EMPTY) { ch = ITM_RxBuffer; ITM_RxBuffer = ITM_RXBUFFER_EMPTY; /* ready for next character */ } return (ch); } /** \brief ITM Check Character \details Checks whether a character is pending for reading in the variable \ref ITM_RxBuffer. \return 0 No character available. \return 1 Character available. */ __STATIC_INLINE int32_t ITM_CheckChar (void) { if (ITM_RxBuffer == ITM_RXBUFFER_EMPTY) { return (0); /* no character available */ } else { return (1); /* character available */ } } /*@} end of CMSIS_core_DebugFunctions */ #ifdef __cplusplus } #endif #endif /* __CORE_CM4_H_DEPENDANT */ #endif /* __CMSIS_GENERIC */ ================================================ FILE: sys/arch/arm/include/core_cmFunc.h ================================================ /**************************************************************************//** * @file core_cmFunc.h * @brief CMSIS Cortex-M Core Function Access Header File * @version V4.30 * @date 20. October 2015 ******************************************************************************/ /* Copyright (c) 2009 - 2015 ARM LIMITED All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - Neither the name of ARM nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ---------------------------------------------------------------------------*/ #if defined ( __ICCARM__ ) #pragma system_include /* treat file as system include file for MISRA check */ #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) #pragma clang system_header /* treat file as system include file */ #endif #ifndef __CORE_CMFUNC_H #define __CORE_CMFUNC_H /* ########################### Core Function Access ########################### */ /** \ingroup CMSIS_Core_FunctionInterface \defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions @{ */ /*------------------ RealView Compiler -----------------*/ #if defined ( __CC_ARM ) #include "cmsis_armcc.h" /*------------------ ARM Compiler V6 -------------------*/ #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) #include "cmsis_armcc_V6.h" /*------------------ GNU Compiler ----------------------*/ #elif defined ( __GNUC__ ) #include "cmsis_gcc.h" /*------------------ ICC Compiler ----------------------*/ #elif defined ( __ICCARM__ ) #include /*------------------ TI CCS Compiler -------------------*/ #elif defined ( __TMS470__ ) #include /*------------------ TASKING Compiler ------------------*/ #elif defined ( __TASKING__ ) /* * The CMSIS functions have been implemented as intrinsics in the compiler. * Please use "carm -?i" to get an up to date list of all intrinsics, * Including the CMSIS ones. */ /*------------------ COSMIC Compiler -------------------*/ #elif defined ( __CSMC__ ) #include #endif /*@} end of CMSIS_Core_RegAccFunctions */ #endif /* __CORE_CMFUNC_H */ ================================================ FILE: sys/arch/arm/include/core_cmInstr.h ================================================ /**************************************************************************//** * @file core_cmInstr.h * @brief CMSIS Cortex-M Core Instruction Access Header File * @version V4.30 * @date 20. October 2015 ******************************************************************************/ /* Copyright (c) 2009 - 2015 ARM LIMITED All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - Neither the name of ARM nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ---------------------------------------------------------------------------*/ #if defined ( __ICCARM__ ) #pragma system_include /* treat file as system include file for MISRA check */ #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) #pragma clang system_header /* treat file as system include file */ #endif #ifndef __CORE_CMINSTR_H #define __CORE_CMINSTR_H /* ########################## Core Instruction Access ######################### */ /** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface Access to dedicated instructions @{ */ /*------------------ RealView Compiler -----------------*/ #if defined ( __CC_ARM ) #include "cmsis_armcc.h" /*------------------ ARM Compiler V6 -------------------*/ #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) #include "cmsis_armcc_V6.h" /*------------------ GNU Compiler ----------------------*/ #elif defined ( __GNUC__ ) #include "cmsis_gcc.h" /*------------------ ICC Compiler ----------------------*/ #elif defined ( __ICCARM__ ) #include /*------------------ TI CCS Compiler -------------------*/ #elif defined ( __TMS470__ ) #include /*------------------ TASKING Compiler ------------------*/ #elif defined ( __TASKING__ ) /* * The CMSIS functions have been implemented as intrinsics in the compiler. * Please use "carm -?i" to get an up to date list of all intrinsics, * Including the CMSIS ones. */ /*------------------ COSMIC Compiler -------------------*/ #elif defined ( __CSMC__ ) #include #endif /*@}*/ /* end of group CMSIS_Core_InstructionInterface */ #endif /* __CORE_CMINSTR_H */ ================================================ FILE: sys/arch/arm/include/core_cmSimd.h ================================================ /**************************************************************************//** * @file core_cmSimd.h * @brief CMSIS Cortex-M SIMD Header File * @version V4.30 * @date 20. October 2015 ******************************************************************************/ /* Copyright (c) 2009 - 2015 ARM LIMITED All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - Neither the name of ARM nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ---------------------------------------------------------------------------*/ #if defined ( __ICCARM__ ) #pragma system_include /* treat file as system include file for MISRA check */ #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) #pragma clang system_header /* treat file as system include file */ #endif #ifndef __CORE_CMSIMD_H #define __CORE_CMSIMD_H #ifdef __cplusplus extern "C" { #endif /* ################### Compiler specific Intrinsics ########################### */ /** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics Access to dedicated SIMD instructions @{ */ /*------------------ RealView Compiler -----------------*/ #if defined ( __CC_ARM ) #include "cmsis_armcc.h" /*------------------ ARM Compiler V6 -------------------*/ #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) #include "cmsis_armcc_V6.h" /*------------------ GNU Compiler ----------------------*/ #elif defined ( __GNUC__ ) #include "cmsis_gcc.h" /*------------------ ICC Compiler ----------------------*/ #elif defined ( __ICCARM__ ) #include /*------------------ TI CCS Compiler -------------------*/ #elif defined ( __TMS470__ ) #include /*------------------ TASKING Compiler ------------------*/ #elif defined ( __TASKING__ ) /* * The CMSIS functions have been implemented as intrinsics in the compiler. * Please use "carm -?i" to get an up to date list of all intrinsics, * Including the CMSIS ones. */ /*------------------ COSMIC Compiler -------------------*/ #elif defined ( __CSMC__ ) #include #endif /*@} end of group CMSIS_SIMD_intrinsics */ #ifdef __cplusplus } #endif #endif /* __CORE_CMSIMD_H */ ================================================ FILE: sys/arch/pic32/conf/BAREMETAL.ld ================================================ /* * Linker script for PIC32 firmware. */ OUTPUT_FORMAT("elf32-littlemips", "elf32-bigmips", "elf32-littlemips") OUTPUT_ARCH(mips) ENTRY(_reset_vector_) MEMORY { ram (rw!x): ORIGIN = 0x80000000, LENGTH = 26K u0area (rw!x): ORIGIN = 0x80006800, LENGTH = 3K uarea (rw!x): ORIGIN = 0x80007400, LENGTH = 3K devcfg (r) : ORIGIN = 0x9fc02ff0, LENGTH = 16 /* Required by Microchip C32 linker */ kseg0_program_mem (rx) : ORIGIN = 0x9D000000, LENGTH = 512K exception_mem (rx) : ORIGIN = 0x9D000000, LENGTH = 0x1000 kseg0_boot_mem (rx) : ORIGIN = 0x9FC00000, LENGTH = 12K-16 kseg1_boot_mem (rx) : ORIGIN = 0xBFC00000, LENGTH = 0x490 kseg1_data_mem (w!x) : ORIGIN = 0xA0000000, LENGTH = 0x20000 } /* higher address of the user mode stack */ u0 = ORIGIN(u0area); u = ORIGIN(uarea); u_end = ORIGIN(uarea) + LENGTH(uarea); SECTIONS { /* Read-only sections, merged into text segment: */ . = 0x0000; .interp : { *(.interp) } .hash : { *(.hash) } .dynsym : { *(.dynsym) } .dynstr : { *(.dynstr) } .gnu.version : { *(.gnu.version) } .gnu.version_d : { *(.gnu.version_d) } .gnu.version_r : { *(.gnu.version_r) } .rel.init : { *(.rel.init) } .rela.init : { *(.rela.init) } .rel.text : { *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*) } .rela.text : { *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*) } .rel.fini : { *(.rel.fini) } .rela.fini : { *(.rela.fini) } .rel.rodata : { *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*) } .rela.rodata : { *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*) } .rel.data : { *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*) } .rela.data : { *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*) } .rel.ctors : { *(.rel.ctors) } .rela.ctors : { *(.rela.ctors) } .rel.dtors : { *(.rel.dtors) } .rela.dtors : { *(.rela.dtors) } .rel.got : { *(.rel.got) } .rela.got : { *(.rela.got) } .rel.sdata : { *(.rel.sdata .rel.sdata.* .rel.gnu.linkonce.s.*) } .rela.sdata : { *(.rela.sdata .rela.sdata.* .rela.gnu.linkonce.s.*) } .rel.sbss : { *(.rel.sbss .rel.sbss.* .rel.gnu.linkonce.sb.*) } .rela.sbss : { *(.rela.sbss .rela.sbss.* .rela.gnu.linkonce.sb.*) } .rel.sdata2 : { *(.rel.sdata2 .rel.sdata2.* .rel.gnu.linkonce.s2.*) } .rela.sdata2 : { *(.rela.sdata2 .rela.sdata2.* .rela.gnu.linkonce.s2.*) } .rel.sbss2 : { *(.rel.sbss2 .rel.sbss2.* .rel.gnu.linkonce.sb2.*) } .rela.sbss2 : { *(.rela.sbss2 .rela.sbss2.* .rela.gnu.linkonce.sb2.*) } .rel.bss : { *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*) } .rela.bss : { *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) } .rel.plt : { *(.rel.plt) } .rela.plt : { *(.rela.plt) } .plt : { *(.plt) } .boot : { /* Execution starts here. */ *(.startup) } > kseg0_boot_mem .text : { /* Exception handlers. */ *(.exception) *(.text .stub .text.* .gnu.linkonce.t.*) /* .gnu.warning sections are handled specially by elf32.em. */ *(.gnu.warning) *(.glue_7t) *(.glue_7) __rodata_start = . ; *(.rodata .rodata.* .gnu.linkonce.r.* .rel.dyn) __abiflags = . ; *(.MIPS.abiflags) *(.dinit) /* Align here to ensure that the .text section ends on word boundary. */ . = ALIGN (32 / 8); _etext = .; } > kseg0_program_mem /* Start data (internal SRAM). */ .data : AT (ADDR (.text) + SIZEOF (.text)) { __data_start = . ; _gp = .; /* We have only 32k RAM on MC-24, so no need for 0x8000 offset. */ *(.data .data.* .gnu.linkonce.d.*) /* We want the small data sections together, so single-instruction offsets can access them all, and initialized data all before uninitialized, so we can shorten the on-disk segment size. */ *(.sdata .sdata.* .gnu.linkonce.s.*) *(.eh_frame) _edata = .; } > ram /* Device configuration. */ .config : { *(.config3) *(.config2) *(.config1) *(.config0) } > devcfg .bss ADDR (.data) + SIZEOF (.data) (NOLOAD) : { __bss_start = .; *(.dynbss) *(.sbss .sbss.*) *(.scommon) *(.bss .bss.* .gnu.linkonce.b.*) *(COMMON) /* Align here to ensure that the .bss section occupies space up to _end. Align after .bss to ensure correct alignment even if the .bss section disappears because there are no input sections. */ . = ALIGN (32 / 8); } > ram __bss_end = . ; _end = .; /* * RAM functions go at the end of our stack and heap allocation. * Alignment of 2K required by the boundary register (BMXDKPBA). */ /* .ramfunc : AT (LOADADDR (.data) + SIZEOF (.data)) { _ramfunc_begin = . ; *(.ramfunc .ramfunc.*) . = ALIGN(4) ; _ramfunc_end = . ; } >keram _ramfunc_image_begin = LOADADDR(.ramfunc) ; _ramfunc_length = SIZEOF(.ramfunc) ; */ /* Stabs debugging sections. */ .stab 0 : { *(.stab) } .stabstr 0 : { *(.stabstr) } .stab.excl 0 : { *(.stab.excl) } .stab.exclstr 0 : { *(.stab.exclstr) } .stab.index 0 : { *(.stab.index) } .stab.indexstr 0 : { *(.stab.indexstr) } .comment 0 : { *(.comment) } /* DWARF debug sections. Symbols in the DWARF debugging sections are relative to the beginning of the section so we begin them at 0. */ /* DWARF 1 */ .debug 0 : { *(.debug) } .line 0 : { *(.line) } /* GNU DWARF 1 extensions */ .debug_srcinfo 0 : { *(.debug_srcinfo) } .debug_sfnames 0 : { *(.debug_sfnames) } /* DWARF 1.1 and DWARF 2 */ .debug_aranges 0 : { *(.debug_aranges) } .debug_pubnames 0 : { *(.debug_pubnames) } /* DWARF 2 */ .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) } .debug_abbrev 0 : { *(.debug_abbrev) } .debug_line 0 : { *(.debug_line) } .debug_frame 0 : { *(.debug_frame) } .debug_str 0 : { *(.debug_str) } .debug_loc 0 : { *(.debug_loc) } .debug_macinfo 0 : { *(.debug_macinfo) } /* SGI/MIPS DWARF 2 extensions */ .debug_weaknames 0 : { *(.debug_weaknames) } .debug_funcnames 0 : { *(.debug_funcnames) } .debug_typenames 0 : { *(.debug_typenames) } .debug_varnames 0 : { *(.debug_varnames) } /DISCARD/ : { *(.MIPS.abiflags) } } ================================================ FILE: sys/arch/pic32/conf/Config.generic ================================================ # # Generic kernel configuration for PIC32 processor. # # This file contains all the devices and all the options available # for the pic32 platform. It's not expected to be buildable, as some # devices and options are mutually exclusive or incompatible. # It's intended to be used as a reference or as a starting point # when creating configuration for a new board. # # For details, see http://retrobsd.org/wiki/doku.php/doc/kconfig # architecture "pic32" cpu "PIC32MX7" # Processor variant board "MAX32" # Board type ldscript "MAX32.ld" # Linker script makeoptions DEBUG="-g" # Debug symbols # Need to set locally timezone 8 dst maxusers 2 # Standard system options options "HZ=100" # Rate of clock interrupt options "CPU_KHZ=80000" # Oscillator frequency of CPU core options "BUS_KHZ=80000" # Frequency of peripheral bus options "BUS_DIV=1" # Bus clock divisor 1/2/4/8 options "UCB_METER" # Collect kernel statistics options "NPROC=10" # Number of processes, default 25 options "NBUF=10" # Number of i/o buffers, default 10 options "NFILE=24" # Number of files, default 24 options "NINODE=24" # Number of i-nodes, default 24 options "NMOUNT=2" # Number of mounted filesystems, default 2 options "SMAPSIZ=NPROC" # Size of swap map, default NPROC options "HALTREBOOT" # Reboot the processor on halt() options "KERNEL_HIGHLIGHT" # Highlight kernel messages # LEDs signal "LED_DISK" pin RF0 invert # disk activity indicator signal "LED_SWAP" pin RA1 invert # swap activity indicator signal "LED_TTY" pin RA2 invert # tty activity indicator signal "LED_KERNEL" pin RA3 invert # kernel activity indicator # Root filesystem at /dev/sd0a, swap at /dev/sd0b config unix root on sd0a swap on sd0b dumps on sd0b # Serial UART ports device uart1 # Serial-to-USB converter device uart2 device uart3 device uart4 options "UART_BAUD=115200" # default speed signal "UART4_ENA" pin RB13 # power enable signal # USB UART ports device uartusb # USB device mode, CDC function options "UARTUSB_BAUD=115200" # default speed options "USB_AUTOBOOT=YES" # don't wait for on boot options "USB_MAX_EP_NUMBER=3" # parameters of USB device... options "USB_NUM_STRING_DESCRIPTORS=3" # ...specific for CDC function # Console options options "CONS_MAJOR=UART_MAJOR" # use UART device as console options "CONS_MINOR=0" # uart1 is /dev/tty0 # SPI ports controller spi2 # SD card # microSD card device sd0 at spi2 pin RC14 # select pin options "SD_MHZ=10" # speed 10 MHz signal "SD0_ENA" pin RA5 # SD card enable signal # General purpose I/O ports # Flags define a mask of available pins # For 64-pin devices: device gpio1 flags 0xffff # port B device gpio2 flags 0xf000 # port C device gpio3 flags 0x0fff # port D device gpio4 flags 0x00ff # port E device gpio5 flags 0x003b # port F device gpio6 flags 0x03cc # port G # For 100-pin devices: device gpio0 flags 0xc6ff # port A device gpio1 flags 0xffff # port B device gpio2 flags 0xf01e # port C device gpio3 flags 0xffff # port D device gpio4 flags 0x03ff # port E device gpio5 flags 0x313f # port F device gpio6 flags 0xf3cf # port G signal "GPIO_CLEAR" pin RA5 # clear on startup # ADC driver device adc # PWM driver device pwm # GLCD driver device glcd # HX8357 driver device hxtft # Skeleton driver device skel # Pseudo terminals service pty 4 # System log service log # Power control device power signal "POWER_LED" pin RA3 signal "POWER_SWITCH" pin RA4 signal "POWER_CONTROL" pin RA5 # picga controller spi1 # RAM disk: picga device picga0 at spi1 pin RA4 # chip select signal options "PICGA_BUS=SPI1CON" # TODO: delete this option signal "PICGA_CS" pin RA4 # TODO: delete # TFT display driver with 8-bit parallel interface. # Supported controllers: ST7781, ILI9341, NT35702 device gpanel signal "LCD_RST" pin RB10 signal "LCD_CS" pin RB0 signal "LCD_RD" pin RB2 signal "LCD_RS" pin RB8 signal "LCD_WR" pin RB4 signal "LCD_D0" pin RA14 signal "LCD_D1" pin RD3 signal "LCD_D2" pin RE8 signal "LCD_D3" pin RD0 signal "LCD_D4" pin RF0 signal "LCD_D5" pin RD1 signal "LCD_D6" pin RD2 signal "LCD_D7" pin RE9 #-------------------------------------------- # Custom RAM disk devices # # sdramp - SDRAM block device # The volume is divided into two partitions: A and B. # Size of partition B is specified as option SDR_SWAP_KBYTES. # The rest is partition A. device dr0 # SDRAM on external memory bus options "SDR_SWAP_KBYTES=2048" # size of partition B options "KERNEL_EXECUTABLE_RAM" # allow kernel code in RAM area # sramc - SRAM block device # The volume is divided into two partitions: A and B. # Size of partition B is specified as option SRAMC_SWAP_KBYTES. # The rest is partition A. device rc0 # SRAM via 4-wire CPLD interface signal "SRAMC_DATA" pin RE0 signal "SRAMC_LDA" pin RC13 signal "SRAMC_RD" pin RF1 signal "SRAMC_WR" pin RF0 options "SRAMC_SWAP_KBYTES=2048" # size of partition B # mrams - SPI block device controller spi1 # RAM disk: mrams device mr0 at spi1 pins RA4, RA2, RB14, RB12 # chip select signals options "MRAMS_CHIPS=4" # number of chips options "MRAMS_CHIPSIZE=512" # chip size in kbytes options "MRAMS_MHZ=10" # speed 10 MHz signal "MRAMS_LED0" pin RF0 # optional LED indicators signal "MRAMS_LED1" pin RF1 signal "MRAMS_LED2" pin RF2 signal "MRAMS_LED3" pin RF3 # spirams - SPI block device controller spi1 # RAM disk: spirams device sr0 at spi1 pins RF0, RF1, RF2, RF3, # chip select signals RF4, RF5, RF6, RF7, RF8, RF9, RF10, RF11, RF12, RF13, RF14, RF15 options "SPIRAMS_CHIPSIZE=128" # chip size in kbytes options "SPIRAMS_CHIPS=16" # number of chips options "SPIRAMS_MHZ=10" # speed 10 MHz signal "SPIRAMS_LED0" pin RG0 # optional LED indicators signal "SPIRAMS_LED1" pin RG1 signal "SPIRAMS_LED2" pin RG2 signal "SPIRAMS_LED3" pin RG3 signal "SPIRAMS_LED4" pin RG4 signal "SPIRAMS_LED5" pin RG5 signal "SPIRAMS_LED6" pin RG6 signal "SPIRAMS_LED7" pin RG7 signal "SPIRAMS_LED8" pin RG8 signal "SPIRAMS_LED9" pin RG9 signal "SPIRAMS_LED10" pin RG10 signal "SPIRAMS_LED11" pin RG11 signal "SPIRAMS_LED12" pin RG12 signal "SPIRAMS_LED13" pin RG13 signal "SPIRAMS_LED14" pin RG14 signal "SPIRAMS_LED15" pin RG15 ================================================ FILE: sys/arch/pic32/conf/MAX32.ld ================================================ /* * Linker script for PIC32 firmware using HID bootloader. * Flash area for user starts at 9d000000. * Start address for user program is 9d001000. */ OUTPUT_FORMAT("elf32-littlemips", "elf32-bigmips", "elf32-littlemips") OUTPUT_ARCH(mips) ENTRY(_reset_vector_) MEMORY { flash (rx) : ORIGIN = 0x9d000000, LENGTH = 512K ram (rw!x): ORIGIN = 0x80000000, LENGTH = 26K u0area (rw!x): ORIGIN = 0x80006800, LENGTH = 3K uarea (rw!x): ORIGIN = 0x80007400, LENGTH = 3K /* Required by Microchip C32 linker */ kseg0_program_mem (rx) : ORIGIN = 0x9D000000, LENGTH = 0x80000 kseg0_boot_mem : ORIGIN = 0x9FC00000, LENGTH = 0x1000 exception_mem : ORIGIN = 0x9FC01000, LENGTH = 0x1000 kseg1_boot_mem : ORIGIN = 0xBFC00000, LENGTH = 0 kseg1_data_mem (w!x) : ORIGIN = 0xA0000000, LENGTH = 0x20000 } /* higher address of the user mode stack */ u0 = ORIGIN(u0area); u = ORIGIN(uarea); u_end = ORIGIN(uarea) + LENGTH(uarea); SECTIONS { .text ORIGIN(flash) : { /* Exception handlers. */ *(.exception) . = 0x1000; /* Execution starts here. */ *(.startup) *(.text .stub .text.* .gnu.linkonce.t.*) /* .gnu.warning sections are handled specially by elf32.em. */ *(.gnu.warning) *(.glue_7t) *(.glue_7) __rodata_start = . ; *(.rodata .rodata.* .gnu.linkonce.r.* .rel.dyn) __abiflags = . ; *(.MIPS.abiflags) *(.dinit) /* Align here to ensure that the .text section ends on word boundary. */ . = ALIGN (32 / 8); _etext = .; } > flash /* Start data (internal SRAM). */ .data : AT (ADDR (.text) + SIZEOF (.text)) { __data_start = . ; _gp = .; /* We use only 32k RAM for kernel, so no need for 0x8000 offset. */ /* We want the small data sections together, so single-instruction offsets can access them all, and initialized data all before uninitialized, so we can shorten the on-disk segment size. */ *(.sdata .sdata.* .gnu.linkonce.s.*) *(.data .data.* .gnu.linkonce.d.*) *(.eh_frame) _edata = .; } > ram .bss ADDR (.data) + SIZEOF (.data) (NOLOAD) : { __bss_start = .; *(.dynbss) *(.sbss .sbss.*) *(.scommon) *(.bss .bss.* .gnu.linkonce.b.*) *(COMMON) /* Align here to ensure that the .bss section occupies space up to _end. Align after .bss to ensure correct alignment even if the .bss section disappears because there are no input sections. */ . = ALIGN (32 / 8); } > ram __bss_end = . ; _end = .; /* Stabs debugging sections. */ .stab 0 : { *(.stab) } .stabstr 0 : { *(.stabstr) } .stab.excl 0 : { *(.stab.excl) } .stab.exclstr 0 : { *(.stab.exclstr) } .stab.index 0 : { *(.stab.index) } .stab.indexstr 0 : { *(.stab.indexstr) } .comment 0 : { *(.comment) } /* DWARF debug sections. Symbols in the DWARF debugging sections are relative to the beginning of the section so we begin them at 0. */ /* DWARF 1 */ .debug 0 : { *(.debug) } .line 0 : { *(.line) } /* GNU DWARF 1 extensions */ .debug_srcinfo 0 : { *(.debug_srcinfo) } .debug_sfnames 0 : { *(.debug_sfnames) } /* DWARF 1.1 and DWARF 2 */ .debug_aranges 0 : { *(.debug_aranges) } .debug_pubnames 0 : { *(.debug_pubnames) } /* DWARF 2 */ .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) } .debug_abbrev 0 : { *(.debug_abbrev) } .debug_line 0 : { *(.debug_line) } .debug_frame 0 : { *(.debug_frame) } .debug_str 0 : { *(.debug_str) } .debug_loc 0 : { *(.debug_loc) } .debug_macinfo 0 : { *(.debug_macinfo) } /* SGI/MIPS DWARF 2 extensions */ .debug_weaknames 0 : { *(.debug_weaknames) } .debug_funcnames 0 : { *(.debug_funcnames) } .debug_typenames 0 : { *(.debug_typenames) } .debug_varnames 0 : { *(.debug_varnames) } .debug_pubtypes 0 : { *(.debug_pubtypes) } .debug_ranges 0 : { *(.debug_ranges) } .gnu.attributes 0 : { KEEP (*(.gnu.attributes)) } /DISCARD/ : { *(.MIPS.abiflags) } } ================================================ FILE: sys/arch/pic32/conf/MAXIMITE.ld ================================================ /* * Linker script for PIC32 firmware using HID bootloader. * Flash area for user starts at 9d003000. * Start address for user program is 9d004000. */ OUTPUT_FORMAT("elf32-littlemips", "elf32-bigmips", "elf32-littlemips") OUTPUT_ARCH(mips) ENTRY(_reset_vector_) MEMORY { flash (rx) : ORIGIN = 0x9d003000, LENGTH = 512K-12K ram (rw!x): ORIGIN = 0x80000000, LENGTH = 26K u0area (rw!x): ORIGIN = 0x80006800, LENGTH = 3K uarea (rw!x): ORIGIN = 0x80007400, LENGTH = 3K /* Required by Microchip C32 linker */ kseg0_program_mem (rx) : ORIGIN = 0x9D000000, LENGTH = 0x80000 kseg0_boot_mem : ORIGIN = 0x9FC00000, LENGTH = 0x1000 exception_mem : ORIGIN = 0x9FC04000, LENGTH = 0x1000 kseg1_boot_mem : ORIGIN = 0xBFC00000, LENGTH = 0 kseg1_data_mem (w!x) : ORIGIN = 0xA0000000, LENGTH = 0x20000 } /* higher address of the user mode stack */ u0 = ORIGIN(u0area); u = ORIGIN(uarea); u_end = ORIGIN(uarea) + LENGTH(uarea); SECTIONS { .text ORIGIN(flash) : { /* Exception handlers. */ *(.exception) . = 0x1000; /* Execution starts here. */ *(.startup) *(.text .stub .text.* .gnu.linkonce.t.*) /* .gnu.warning sections are handled specially by elf32.em. */ *(.gnu.warning) *(.glue_7t) *(.glue_7) __rodata_start = . ; *(.rodata .rodata.* .gnu.linkonce.r.* .rel.dyn) *(.dinit) /* Align here to ensure that the .text section ends on word boundary. */ . = ALIGN (32 / 8); _etext = .; } > flash /* Start data (internal SRAM). */ .data : AT (ADDR (.text) + SIZEOF (.text)) { __data_start = . ; _gp = .; /* We use only 32k RAM for kernel, so no need for 0x8000 offset. */ /* We want the small data sections together, so single-instruction offsets can access them all, and initialized data all before uninitialized, so we can shorten the on-disk segment size. */ *(.sdata .sdata.* .gnu.linkonce.s.*) *(.data .data.* .gnu.linkonce.d.*) *(.eh_frame) _edata = .; } > ram .bss ADDR (.data) + SIZEOF (.data) (NOLOAD) : { __bss_start = .; *(.dynbss) *(.sbss .sbss.*) *(.scommon) *(.bss .bss.* .gnu.linkonce.b.*) *(COMMON) /* Align here to ensure that the .bss section occupies space up to _end. Align after .bss to ensure correct alignment even if the .bss section disappears because there are no input sections. */ . = ALIGN (32 / 8); } > ram __bss_end = . ; _end = .; /* Stabs debugging sections. */ .stab 0 : { *(.stab) } .stabstr 0 : { *(.stabstr) } .stab.excl 0 : { *(.stab.excl) } .stab.exclstr 0 : { *(.stab.exclstr) } .stab.index 0 : { *(.stab.index) } .stab.indexstr 0 : { *(.stab.indexstr) } .comment 0 : { *(.comment) } /* DWARF debug sections. Symbols in the DWARF debugging sections are relative to the beginning of the section so we begin them at 0. */ /* DWARF 1 */ .debug 0 : { *(.debug) } .line 0 : { *(.line) } /* GNU DWARF 1 extensions */ .debug_srcinfo 0 : { *(.debug_srcinfo) } .debug_sfnames 0 : { *(.debug_sfnames) } /* DWARF 1.1 and DWARF 2 */ .debug_aranges 0 : { *(.debug_aranges) } .debug_pubnames 0 : { *(.debug_pubnames) } /* DWARF 2 */ .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) } .debug_abbrev 0 : { *(.debug_abbrev) } .debug_line 0 : { *(.debug_line) } .debug_frame 0 : { *(.debug_frame) } .debug_str 0 : { *(.debug_str) } .debug_loc 0 : { *(.debug_loc) } .debug_macinfo 0 : { *(.debug_macinfo) } /* SGI/MIPS DWARF 2 extensions */ .debug_weaknames 0 : { *(.debug_weaknames) } .debug_funcnames 0 : { *(.debug_funcnames) } .debug_typenames 0 : { *(.debug_typenames) } .debug_varnames 0 : { *(.debug_varnames) } .debug_pubtypes 0 : { *(.debug_pubtypes) } .debug_ranges 0 : { *(.debug_ranges) } .gnu.attributes 0 : { KEEP (*(.gnu.attributes)) } /DISCARD/ : { *(.MIPS.abiflags) } } ================================================ FILE: sys/arch/pic32/conf/MAXIMITE_COLOR.ld ================================================ /* * Linker script for PIC32 firmware using HID bootloader. * Flash area for user starts at 9d005000. * Start address for user program is 9d006000. */ OUTPUT_FORMAT("elf32-littlemips", "elf32-bigmips", "elf32-littlemips") OUTPUT_ARCH(mips) ENTRY(_reset_vector_) MEMORY { flash (rx) : ORIGIN = 0x9d005000, LENGTH = 512K-20K ram (rw!x): ORIGIN = 0x80000000, LENGTH = 26K u0area (rw!x): ORIGIN = 0x80006800, LENGTH = 3K uarea (rw!x): ORIGIN = 0x80007400, LENGTH = 3K /* Required by Microchip C32 linker */ kseg0_program_mem (rx) : ORIGIN = 0x9D000000, LENGTH = 0x80000 kseg0_boot_mem : ORIGIN = 0x9FC00000, LENGTH = 0x1000 exception_mem : ORIGIN = 0x9FC04000, LENGTH = 0x1000 kseg1_boot_mem : ORIGIN = 0xBFC00000, LENGTH = 0 kseg1_data_mem (w!x) : ORIGIN = 0xA0000000, LENGTH = 0x20000 } /* higher address of the user mode stack */ u0 = ORIGIN(u0area); u = ORIGIN(uarea); u_end = ORIGIN(uarea) + LENGTH(uarea); SECTIONS { .text ORIGIN(flash) : { /* Exception handlers. */ *(.exception) . = 0x1000; /* Execution starts here. */ *(.startup) *(.text .stub .text.* .gnu.linkonce.t.*) /* .gnu.warning sections are handled specially by elf32.em. */ *(.gnu.warning) *(.glue_7t) *(.glue_7) __rodata_start = . ; *(.rodata .rodata.* .gnu.linkonce.r.* .rel.dyn) __abiflags = . ; *(.MIPS.abiflags) *(.dinit) /* Align here to ensure that the .text section ends on word boundary. */ . = ALIGN (32 / 8); _etext = .; } > flash /* Start data (internal SRAM). */ .data : AT (ADDR (.text) + SIZEOF (.text)) { __data_start = . ; _gp = .; /* We use only 32k RAM for kernel, so no need for 0x8000 offset. */ /* We want the small data sections together, so single-instruction offsets can access them all, and initialized data all before uninitialized, so we can shorten the on-disk segment size. */ *(.sdata .sdata.* .gnu.linkonce.s.*) *(.data .data.* .gnu.linkonce.d.*) *(.eh_frame) _edata = .; } > ram .bss ADDR (.data) + SIZEOF (.data) (NOLOAD) : { __bss_start = .; *(.dynbss) *(.sbss .sbss.*) *(.scommon) *(.bss .bss.* .gnu.linkonce.b.*) *(COMMON) /* Align here to ensure that the .bss section occupies space up to _end. Align after .bss to ensure correct alignment even if the .bss section disappears because there are no input sections. */ . = ALIGN (32 / 8); } > ram __bss_end = . ; _end = .; /* Stabs debugging sections. */ .stab 0 : { *(.stab) } .stabstr 0 : { *(.stabstr) } .stab.excl 0 : { *(.stab.excl) } .stab.exclstr 0 : { *(.stab.exclstr) } .stab.index 0 : { *(.stab.index) } .stab.indexstr 0 : { *(.stab.indexstr) } .comment 0 : { *(.comment) } /* DWARF debug sections. Symbols in the DWARF debugging sections are relative to the beginning of the section so we begin them at 0. */ /* DWARF 1 */ .debug 0 : { *(.debug) } .line 0 : { *(.line) } /* GNU DWARF 1 extensions */ .debug_srcinfo 0 : { *(.debug_srcinfo) } .debug_sfnames 0 : { *(.debug_sfnames) } /* DWARF 1.1 and DWARF 2 */ .debug_aranges 0 : { *(.debug_aranges) } .debug_pubnames 0 : { *(.debug_pubnames) } /* DWARF 2 */ .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) } .debug_abbrev 0 : { *(.debug_abbrev) } .debug_line 0 : { *(.debug_line) } .debug_frame 0 : { *(.debug_frame) } .debug_str 0 : { *(.debug_str) } .debug_loc 0 : { *(.debug_loc) } .debug_macinfo 0 : { *(.debug_macinfo) } /* SGI/MIPS DWARF 2 extensions */ .debug_weaknames 0 : { *(.debug_weaknames) } .debug_funcnames 0 : { *(.debug_funcnames) } .debug_typenames 0 : { *(.debug_typenames) } .debug_varnames 0 : { *(.debug_varnames) } .debug_pubtypes 0 : { *(.debug_pubtypes) } .debug_ranges 0 : { *(.debug_ranges) } .gnu.attributes 0 : { KEEP (*(.gnu.attributes)) } /DISCARD/ : { *(.MIPS.abiflags) } } ================================================ FILE: sys/arch/pic32/conf/MMB_MX7.ld ================================================ /* * Linker script for PIC32 firmware using HID bootloader. * Flash area for user starts at 9d000000. * Start address for user program is 9d000000. */ OUTPUT_FORMAT("elf32-littlemips", "elf32-bigmips", "elf32-littlemips") OUTPUT_ARCH(mips) ENTRY(_reset_vector_) MEMORY { flash (rx) : ORIGIN = 0x9d000000, LENGTH = 512K ram (rw!x): ORIGIN = 0x80000000, LENGTH = 26K u0area (rw!x): ORIGIN = 0x80006800, LENGTH = 3K uarea (rw!x): ORIGIN = 0x80007400, LENGTH = 3K /* Required by Microchip C32 linker */ kseg0_program_mem (rx) : ORIGIN = 0x9D000000, LENGTH = 0x80000 kseg0_boot_mem : ORIGIN = 0x9FC00000, LENGTH = 0x1000 exception_mem : ORIGIN = 0x9FC00000, LENGTH = 0x1000 kseg1_boot_mem : ORIGIN = 0xBFC00000, LENGTH = 0 kseg1_data_mem (w!x) : ORIGIN = 0xA0000000, LENGTH = 0x20000 } /* higher address of the user mode stack */ u0 = ORIGIN(u0area); u = ORIGIN(uarea); u_end = ORIGIN(uarea) + LENGTH(uarea); SECTIONS { .text ORIGIN(flash) : { /* Exception handlers. */ *(.exception) /* Execution starts here. */ *(.startup) *(.text .stub .text.* .gnu.linkonce.t.*) /* .gnu.warning sections are handled specially by elf32.em. */ *(.gnu.warning) *(.glue_7t) *(.glue_7) __rodata_start = . ; *(.rodata .rodata.* .gnu.linkonce.r.* .rel.dyn) *(.dinit) /* Align here to ensure that the .text section ends on word boundary. */ . = ALIGN (32 / 8); _etext = .; } > flash /* Start data (internal SRAM). */ .data : AT (ADDR (.text) + SIZEOF (.text)) { __data_start = . ; _gp = .; /* We use only 32k RAM for kernel, so no need for 0x8000 offset. */ /* We want the small data sections together, so single-instruction offsets can access them all, and initialized data all before uninitialized, so we can shorten the on-disk segment size. */ *(.sdata .sdata.* .gnu.linkonce.s.*) *(.data .data.* .gnu.linkonce.d.*) *(.eh_frame) _edata = .; } > ram .bss ADDR (.data) + SIZEOF (.data) (NOLOAD) : { __bss_start = .; *(.dynbss) *(.sbss .sbss.*) *(.scommon) *(.bss .bss.* .gnu.linkonce.b.*) *(COMMON) /* Align here to ensure that the .bss section occupies space up to _end. Align after .bss to ensure correct alignment even if the .bss section disappears because there are no input sections. */ . = ALIGN (32 / 8); } > ram __bss_end = . ; _end = .; /* Stabs debugging sections. */ .stab 0 : { *(.stab) } .stabstr 0 : { *(.stabstr) } .stab.excl 0 : { *(.stab.excl) } .stab.exclstr 0 : { *(.stab.exclstr) } .stab.index 0 : { *(.stab.index) } .stab.indexstr 0 : { *(.stab.indexstr) } .comment 0 : { *(.comment) } /* DWARF debug sections. Symbols in the DWARF debugging sections are relative to the beginning of the section so we begin them at 0. */ /* DWARF 1 */ .debug 0 : { *(.debug) } .line 0 : { *(.line) } /* GNU DWARF 1 extensions */ .debug_srcinfo 0 : { *(.debug_srcinfo) } .debug_sfnames 0 : { *(.debug_sfnames) } /* DWARF 1.1 and DWARF 2 */ .debug_aranges 0 : { *(.debug_aranges) } .debug_pubnames 0 : { *(.debug_pubnames) } /* DWARF 2 */ .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) } .debug_abbrev 0 : { *(.debug_abbrev) } .debug_line 0 : { *(.debug_line) } .debug_frame 0 : { *(.debug_frame) } .debug_str 0 : { *(.debug_str) } .debug_loc 0 : { *(.debug_loc) } .debug_macinfo 0 : { *(.debug_macinfo) } /* SGI/MIPS DWARF 2 extensions */ .debug_weaknames 0 : { *(.debug_weaknames) } .debug_funcnames 0 : { *(.debug_funcnames) } .debug_typenames 0 : { *(.debug_typenames) } .debug_varnames 0 : { *(.debug_varnames) } .debug_pubtypes 0 : { *(.debug_pubtypes) } .debug_ranges 0 : { *(.debug_ranges) } .gnu.attributes 0 : { KEEP (*(.gnu.attributes)) } /DISCARD/ : { *(.MIPS.abiflags) } } ================================================ FILE: sys/arch/pic32/conf/Makefile.inc ================================================ BOARD?= PINGUINO_MICRO KERNDIR= ${TOPSRC}/sys/arch/pic32/compile/${BOARD} KERN= unix installflash: sudo pic32prog ${KERNDIR}/${KERN}.hex .PHONY: installflash ================================================ FILE: sys/arch/pic32/conf/Makefile.pic32 ================================================ # # Makefile for DiscoBSD/pic32 # # DEBUG is set to -g by config if debugging is requested (config -g). # # sources are located via $S relative to the compilation directory S= ../../../.. _mach?= pic32 _arch?= mips _machdir?= $S/arch/${_mach} _archdir?= $S/arch/${_arch} _confdir?= ${_machdir}/conf include ${_confdir}/compiler.mk INCLUDES= -nostdinc -I. -I$S -I$S/arch DEPFLAGS= -MT $@ -MP -MD -MF .deps/$*.dep DEFS= ${INCLUDES} ${PARAM} -DKERNEL ${DEPFLAGS} CWARNFLAGS= -Wall CMACHCPU= -march=mips32r2 -EL CMACHFLAGS= -ffreestanding -fno-builtin -fcommon CMACHFLAGS+= ${CMACHCPU} COPTS?= -O CFLAGS= ${DEBUG} ${CWARNFLAGS} ${CMACHFLAGS} ${COPTS} AFLAGS= -x assembler-with-cpp ${CWARNFLAGS} ${CMACHFLAGS} LDFLAGS= -T ${_confdir}/${LDSCRIPT} LDFLAGS+= -nostdlib -Map=$@.map LDADD= # compile rules: rules are named COMPILE_${SUFFIX} # SUFFIX is the file suffix, capitalized (e.g. C for a .c file). COMPILE_C= ${CC} ${CFLAGS} ${DEFS} -c $< COMPILE_S= ${AS} ${AFLAGS} ${DEFS} -c $< %OBJS %CFILES DEVCFG!=if [ -f devcfg.c ] ; then \ echo "devcfg.o" ; \ else \ echo "" ; \ fi # load lines for config "xxx" will be emitted as: # xxx: ${SYSTEM_DEP} swapxxx.o # ${SYSTEM_LD_HEAD} # ${SYSTEM_LD} swapxxx.o # ${SYSTEM_LD_TAIL} SYSTEM_OBJ= locore.o ${OBJS} ioconf.o ${DEVCFG} SYSTEM_DEP= Makefile ioconf.c machine sys .deps ${SYSTEM_OBJ} SYSTEM_LD_HEAD= sh $S/conf/newvers.sh > vers.c; ${CC} ${CFLAGS} -c vers.c; rm -f $@ SYSTEM_LD= -@echo ${LD} ${LDFLAGS} '$${SYSTEM_OBJ}' vers.o -o $@ ${LDADD}; \ ${LD} ${LDFLAGS} ${SYSTEM_OBJ} vers.o -o $@ ${LDADD} SYSTEM_LD_TAIL= ${SIZE} $@; cp $@ $@.elf; \ ${OBJCOPY} -O ihex --change-addresses=0x80000000 $@ $@.hex; \ ${OBJCOPY} -O binary -R .boot -R .config $@ $@.bin; \ ${OBJDUMP} -d -S $@ > $@.dis %LOAD clean: rm -rf .deps unix *.elf *.o *.map *.dis *.bin *.hex machine sys clean-all: clean rm -f *.h ioconf.c swap*.c vers.c reconfig ioconf.c: Config $S/../tools/bin/config $S/../tools/bin/config Config ${MAKE} clean machine: ln -s ${_machdir}/include $@ sys: ln -s $S/sys $@ .deps: mkdir .deps locore.o: ${_machdir}/${_mach}/locore.S ${COMPILE_S} ioconf.o: ioconf.c ${COMPILE_C} %RULES -include .deps/*.dep ================================================ FILE: sys/arch/pic32/conf/SDRAM32MX.ld ================================================ /* * Linker script for PIC32 firmware using HID bootloader. * Flash area for user starts at 9d005000. * Start address for user program is 9d006000. */ OUTPUT_FORMAT("elf32-littlemips", "elf32-bigmips", "elf32-littlemips") OUTPUT_ARCH(mips) ENTRY(_reset_vector_) MEMORY { flash (rx) : ORIGIN = 0x9d005000, LENGTH = 512K-20K ram (rw!x): ORIGIN = 0x80000000, LENGTH = 0x62C0 u0area (rw!x): ORIGIN = 0x800062C0, LENGTH = 3K uarea (rw!x): ORIGIN = 0x80006EC0, LENGTH = 3K keram (rwx) : ORIGIN = 0x80007AC0, LENGTH = 0x540 devcfg (r) : ORIGIN = 0x9fc02ff0, LENGTH = 16 /* Required by Microchip C32 linker */ kseg0_program_mem (rx) : ORIGIN = 0x9D000000, LENGTH = 0x80000 kseg0_boot_mem : ORIGIN = 0x9FC00000, LENGTH = 0x1000 exception_mem : ORIGIN = 0x9FC06000, LENGTH = 0x1000 kseg1_boot_mem : ORIGIN = 0xBFC00000, LENGTH = 0 kseg1_data_mem (w!x) : ORIGIN = 0xA0000000, LENGTH = 0x20000 } /* higher address of the user mode stack */ u0 = ORIGIN(u0area); u = ORIGIN(uarea); u_end = ORIGIN(uarea) + LENGTH(uarea); _keram_start = ORIGIN(keram); _keram_end = ORIGIN(keram) + LENGTH(keram); SECTIONS { .text ORIGIN(flash) : { /* Exception handlers. */ *(.exception) . = 0x1000; /* Execution starts here. */ *(.startup) *(.text .stub .text.* .gnu.linkonce.t.*) /* .gnu.warning sections are handled specially by elf32.em. */ *(.gnu.warning) *(.glue_7t) *(.glue_7) __rodata_start = . ; *(.rodata .rodata.* .gnu.linkonce.r.* .rel.dyn) __abiflags = . ; *(.MIPS.abiflags) *(.dinit) /* Align here to ensure that the .text section ends on word boundary. */ . = ALIGN (32 / 8); _etext = .; } > flash /* Start data (internal SRAM). */ .data : AT (ADDR (.text) + SIZEOF (.text)) { __data_start = . ; _gp = .; /* We use only 32k RAM for kernel, so no need for 0x8000 offset. */ /* We want the small data sections together, so single-instruction offsets can access them all, and initialized data all before uninitialized, so we can shorten the on-disk segment size. */ *(.sdata .sdata.* .gnu.linkonce.s.*) *(.data .data.* .gnu.linkonce.d.*) *(.eh_frame) _edata = .; } > ram /* Device configuration. */ .config : { *(.config3) *(.config2) *(.config1) *(.config0) } > devcfg .bss ADDR (.data) + SIZEOF (.data) (NOLOAD) : { __bss_start = .; *(.dynbss) *(.sbss .sbss.*) *(.scommon) *(.bss .bss.* .gnu.linkonce.b.*) *(COMMON) /* Align here to ensure that the .bss section occupies space up to _end. Align after .bss to ensure correct alignment even if the .bss section disappears because there are no input sections. */ . = ALIGN (32 / 8); } > ram __bss_end = . ; _end = .; /* * RAM functions go at the end of our stack and heap allocation. * Alignment of 2K required by the boundary register (BMXDKPBA). */ .ramfunc : AT (LOADADDR (.data) + SIZEOF (.data)) { _ramfunc_begin = . ; *(.ramfunc .ramfunc.*) . = ALIGN(4) ; _ramfunc_end = . ; } >keram _ramfunc_image_begin = LOADADDR(.ramfunc) ; _ramfunc_length = SIZEOF(.ramfunc) ; /* Stabs debugging sections. */ .stab 0 : { *(.stab) } .stabstr 0 : { *(.stabstr) } .stab.excl 0 : { *(.stab.excl) } .stab.exclstr 0 : { *(.stab.exclstr) } .stab.index 0 : { *(.stab.index) } .stab.indexstr 0 : { *(.stab.indexstr) } .comment 0 : { *(.comment) } /* DWARF debug sections. Symbols in the DWARF debugging sections are relative to the beginning of the section so we begin them at 0. */ /* DWARF 1 */ .debug 0 : { *(.debug) } .line 0 : { *(.line) } /* GNU DWARF 1 extensions */ .debug_srcinfo 0 : { *(.debug_srcinfo) } .debug_sfnames 0 : { *(.debug_sfnames) } /* DWARF 1.1 and DWARF 2 */ .debug_aranges 0 : { *(.debug_aranges) } .debug_pubnames 0 : { *(.debug_pubnames) } /* DWARF 2 */ .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) } .debug_abbrev 0 : { *(.debug_abbrev) } .debug_line 0 : { *(.debug_line) } .debug_frame 0 : { *(.debug_frame) } .debug_str 0 : { *(.debug_str) } .debug_loc 0 : { *(.debug_loc) } .debug_macinfo 0 : { *(.debug_macinfo) } /* SGI/MIPS DWARF 2 extensions */ .debug_weaknames 0 : { *(.debug_weaknames) } .debug_funcnames 0 : { *(.debug_funcnames) } .debug_typenames 0 : { *(.debug_typenames) } .debug_varnames 0 : { *(.debug_varnames) } .debug_pubtypes 0 : { *(.debug_pubtypes) } .debug_ranges 0 : { *(.debug_ranges) } .gnu.attributes 0 : { KEEP (*(.gnu.attributes)) } /DISCARD/ : { *(.MIPS.abiflags) } } ================================================ FILE: sys/arch/pic32/conf/UBW32.ld ================================================ /* * Linker script for PIC32 firmware using HID bootloader. * Flash area for user starts at 9d005000. * Start address for user program is 9d006000. */ OUTPUT_FORMAT("elf32-littlemips", "elf32-bigmips", "elf32-littlemips") OUTPUT_ARCH(mips) ENTRY(_reset_vector_) MEMORY { flash (rx) : ORIGIN = 0x9d005000, LENGTH = 512K-20K ram (rw!x): ORIGIN = 0x80000000, LENGTH = 26K u0area (rw!x): ORIGIN = 0x80006800, LENGTH = 3K uarea (rw!x): ORIGIN = 0x80007400, LENGTH = 3K /* Required by Microchip C32 linker */ kseg0_program_mem (rx) : ORIGIN = 0x9D000000, LENGTH = 0x80000 kseg0_boot_mem : ORIGIN = 0x9FC00000, LENGTH = 0x1000 exception_mem : ORIGIN = 0x9FC06000, LENGTH = 0x1000 kseg1_boot_mem : ORIGIN = 0xBFC00000, LENGTH = 0 kseg1_data_mem (w!x) : ORIGIN = 0xA0000000, LENGTH = 0x20000 } /* higher address of the user mode stack */ u0 = ORIGIN(u0area); u = ORIGIN(uarea); u_end = ORIGIN(uarea) + LENGTH(uarea); SECTIONS { .text ORIGIN(flash) : { /* Exception handlers. */ *(.exception) . = 0x1000; /* Execution starts here. */ *(.startup) *(.text .stub .text.* .gnu.linkonce.t.*) /* .gnu.warning sections are handled specially by elf32.em. */ *(.gnu.warning) *(.glue_7t) *(.glue_7) __rodata_start = . ; *(.rodata .rodata.* .gnu.linkonce.r.* .rel.dyn) __abiflags = . ; *(.MIPS.abiflags) *(.dinit) /* Align here to ensure that the .text section ends on word boundary. */ . = ALIGN (32 / 8); _etext = .; } > flash /* Start data (internal SRAM). */ .data : AT (ADDR (.text) + SIZEOF (.text)) { __data_start = . ; _gp = .; /* We use only 32k RAM for kernel, so no need for 0x8000 offset. */ /* We want the small data sections together, so single-instruction offsets can access them all, and initialized data all before uninitialized, so we can shorten the on-disk segment size. */ *(.sdata .sdata.* .gnu.linkonce.s.*) *(.data .data.* .gnu.linkonce.d.*) *(.eh_frame) _edata = .; } > ram .bss ADDR (.data) + SIZEOF (.data) (NOLOAD) : { __bss_start = .; *(.dynbss) *(.sbss .sbss.*) *(.scommon) *(.bss .bss.* .gnu.linkonce.b.*) *(COMMON) /* Align here to ensure that the .bss section occupies space up to _end. Align after .bss to ensure correct alignment even if the .bss section disappears because there are no input sections. */ . = ALIGN (32 / 8); } > ram __bss_end = . ; _end = .; /* Stabs debugging sections. */ .stab 0 : { *(.stab) } .stabstr 0 : { *(.stabstr) } .stab.excl 0 : { *(.stab.excl) } .stab.exclstr 0 : { *(.stab.exclstr) } .stab.index 0 : { *(.stab.index) } .stab.indexstr 0 : { *(.stab.indexstr) } .comment 0 : { *(.comment) } /* DWARF debug sections. Symbols in the DWARF debugging sections are relative to the beginning of the section so we begin them at 0. */ /* DWARF 1 */ .debug 0 : { *(.debug) } .line 0 : { *(.line) } /* GNU DWARF 1 extensions */ .debug_srcinfo 0 : { *(.debug_srcinfo) } .debug_sfnames 0 : { *(.debug_sfnames) } /* DWARF 1.1 and DWARF 2 */ .debug_aranges 0 : { *(.debug_aranges) } .debug_pubnames 0 : { *(.debug_pubnames) } /* DWARF 2 */ .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) } .debug_abbrev 0 : { *(.debug_abbrev) } .debug_line 0 : { *(.debug_line) } .debug_frame 0 : { *(.debug_frame) } .debug_str 0 : { *(.debug_str) } .debug_loc 0 : { *(.debug_loc) } .debug_macinfo 0 : { *(.debug_macinfo) } /* SGI/MIPS DWARF 2 extensions */ .debug_weaknames 0 : { *(.debug_weaknames) } .debug_funcnames 0 : { *(.debug_funcnames) } .debug_typenames 0 : { *(.debug_typenames) } .debug_varnames 0 : { *(.debug_varnames) } .debug_pubtypes 0 : { *(.debug_pubtypes) } .debug_ranges 0 : { *(.debug_ranges) } .gnu.attributes 0 : { KEEP (*(.gnu.attributes)) } /DISCARD/ : { *(.MIPS.abiflags) } } ================================================ FILE: sys/arch/pic32/conf/compiler.mk ================================================ # GCC mips-elf toolchain on OpenBSD, FreeBSD, and Linux # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Build the toolchain with the Ports Collection for OpenBSD, # as described in the file: tools/openbsd/README.md # # Build the toolchain from sources for FreeBSD and Linux, # as described on page: http://retrobsd.org/wiki/doku.php/doc/toolchain-mips _HOST_OSNAME!= uname -s MIPS_GCC_PREFIX!= if [ x"${_HOST_OSNAME}" = x"OpenBSD" ] ; then \ echo "/usr/local/bin/mips-elf" ; \ elif [ x"${_HOST_OSNAME}" = x"FreeBSD" ] ; then \ echo "/usr/local/mips-elf/bin/mips-elf" ; \ elif [ x"${_HOST_OSNAME}" = x"Linux" ] ; then \ echo "/usr/local/mips-gcc-4.8.1/bin/mips-elf" ; \ else \ echo "/does/not/exist" ; \ fi _AS= -gcc _CC= -gcc _CPP= -cpp _LD= -ld _SIZE= -size _OBJCOPY= -objcopy _OBJDUMP= -objdump AS= ${MIPS_GCC_PREFIX}${_AS} CC= ${MIPS_GCC_PREFIX}${_CC} CPP= ${MIPS_GCC_PREFIX}${_CPP} LD= ${MIPS_GCC_PREFIX}${_LD} SIZE= ${MIPS_GCC_PREFIX}${_SIZE} OBJCOPY= ${MIPS_GCC_PREFIX}${_OBJCOPY} OBJDUMP= ${MIPS_GCC_PREFIX}${_OBJDUMP} ================================================ FILE: sys/arch/pic32/conf/devices.pic32 ================================================ # # List of block devices and majors # sd 0 rc 1 # sramc - SRAM connected via CPLD dr 2 # sdramp - SDRAM at external memory bus mr 3 # mrams - MRAM at SPI port sr 5 # spirams - serial RAM at SPI port ================================================ FILE: sys/arch/pic32/conf/files.pic32 ================================================ # # Kernel sources, architecture-agnostic. # kern/exec_aout.c standard kern/exec_conf.c standard kern/exec_elf.c standard kern/exec_script.c standard kern/exec_subr.c standard kern/init_main.c standard kern/init_sysent.c standard kern/kern_clock.c standard kern/kern_descrip.c standard kern/kern_exec.c standard kern/kern_exit.c standard kern/kern_fork.c standard kern/kern_mman.c standard kern/kern_proc.c standard kern/kern_prot.c standard kern/kern_prot2.c standard kern/kern_resource.c standard kern/kern_sig.c standard kern/kern_sig2.c standard kern/kern_subr.c standard kern/kern_synch.c standard kern/kern_sysctl.c standard kern/kern_time.c standard kern/subr_log.c optional log kern/subr_prf.c standard kern/subr_rmap.c standard kern/sys_generic.c standard kern/sys_inode.c standard kern/sys_pipe.c standard kern/sys_process.c standard kern/syscalls.c standard kern/tty.c standard kern/tty_pty.c optional pty kern/tty_subr.c standard kern/tty_tty.c standard kern/ufs_alloc.c standard kern/ufs_bio.c standard kern/ufs_bmap.c standard kern/ufs_dsort.c standard kern/ufs_fio.c standard kern/ufs_inode.c standard kern/ufs_mount.c standard kern/ufs_namei.c standard kern/ufs_subr.c standard kern/ufs_syscalls.c standard kern/ufs_syscalls2.c standard kern/vfs_vnops.c standard kern/vm_sched.c standard kern/vm_swap.c standard kern/vm_swp.c standard # # Driver sources, architecture-agnostic. # dev/cons.c standard dev/mem.c standard dev/swap.c standard # # PIC32 platform. # arch/pic32/pic32/clock.c standard arch/pic32/pic32/conf.c standard arch/pic32/pic32/exception.c standard arch/pic32/pic32/machdep.c standard arch/pic32/pic32/sig_machdep.c standard arch/pic32/pic32/sysctl.c standard # # PIC32 hardware abstraction layer. # arch/pic32/hal/usb_device.c optional uartusb arch/pic32/hal/usb_function_cdc.c optional uartusb # # PIC32 drivers. # arch/pic32/dev/adc.c optional adc arch/pic32/dev/glcd.c optional glcd arch/pic32/dev/gpanel-ili9341.c optional gpanel arch/pic32/dev/gpanel-nt35702.c optional gpanel #arch/pic32/dev/gpanel-s6d04h0.c optional gpanel arch/pic32/dev/gpanel-spi-ili9341.c optional sgpanel arch/pic32/dev/gpanel-spi.c optional sgpanel arch/pic32/dev/gpanel-st7781.c optional gpanel arch/pic32/dev/gpanel.c optional gpanel arch/pic32/dev/gpio.c optional gpio arch/pic32/dev/hx8357.c optional hxtft arch/pic32/dev/mrams.c optional mr arch/pic32/dev/picga.c optional picga arch/pic32/dev/power_control.c optional power arch/pic32/dev/pwm.c optional pwm arch/pic32/dev/sd.c optional sd arch/pic32/dev/sdram.S optional dr arch/pic32/dev/sdramp.c optional dr arch/pic32/dev/skel.c optional skel arch/pic32/dev/spi.c optional spi arch/pic32/dev/spi_bus.c optional spi arch/pic32/dev/spirams.c optional sr arch/pic32/dev/sramc.c optional rc arch/pic32/dev/uart.c optional uart arch/pic32/dev/usb_uart.c optional uartusb ================================================ FILE: sys/arch/pic32/dev/adc.c ================================================ /* * ADC driver for PIC32. * * Copyright (C) 2012 Majenko Technologies * * Permission to use, copy, modify, and distribute this software * and its documentation for any purpose and without fee is hereby * granted, provided that the above copyright notice appear in all * copies and that both that the copyright notice and this * permission notice and warranty disclaimer appear in supporting * documentation, and that the name of the author not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * * The author disclaim all warranties with regard to this * software, including all implied warranties of merchantability * and fitness. In no event shall the author be liable for any * special, indirect or consequential damages or any damages * whatsoever resulting from loss of use, data or profits, whether * in an action of contract, negligence or other tortious action, * arising out of or in connection with the use or performance of * this software. */ #include #include #include #include #include #include #include #include #include extern int uwritec(struct uio *); unsigned short adcactive = 0; int adc_open(dev_t dev, int flag, int mode) { int channel; channel = minor(dev); if (channel > ADCMAX) return ENODEV; DEBUG1("adc%2: opened\n",channel); AD1PCFG &= ~(1< ADCMAX) return ENODEV; AD1PCFG |= (1< ADCMAX) return ENODEV; lr = *(&ADC1BUF0+(channel<<2)); c=0; if (lr >= 1000) { tv = lr/1000; temp[c++] = '0' + tv; lr = lr - (tv*1000); } if (lr >= 100 || c > 0) { tv = lr/100; temp[c++] = '0' + tv; lr = lr - (tv*100); } if (lr >= 10 || c>0) { tv = lr/10; temp[c++] = '0' + tv; lr = lr - (tv*10); } temp[c++] = '0' + lr; temp[c++] = '\n'; temp[c] = 0; uiomove(temp,strlen(temp), uio); return 0; } int adc_write(dev_t dev, struct uio *uio, int flag) { return EINVAL; } int adc_ioctl(dev_t dev, register u_int cmd, caddr_t addr, int flag) { switch (cmd) { default: return EINVAL; } return 0; } /* * Test to see if device is present. * Return true if found and initialized ok. */ static int adcprobe(config) struct conf_device *config; { printf("adc: %u channels\n", ADCMAX); return 1; } struct driver adcdriver = { "adc", adcprobe, }; ================================================ FILE: sys/arch/pic32/dev/adc.h ================================================ /* * Copyright (c) 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * * @(#)adc.h 1.4 (2.11BSD GTE) 1997/3/28 */ #ifndef _ADC_H #define _ADC_H #include #include #define ADCMAX 15 #ifdef KERNEL int adc_open (dev_t dev, int flag, int mode); int adc_close (dev_t dev, int flag, int mode); int adc_read (dev_t dev, struct uio *uio, int flag); int adc_write (dev_t dev, struct uio *uio, int flag); int adc_ioctl (dev_t dev, u_int cmd, caddr_t addr, int flag); #endif #endif ================================================ FILE: sys/arch/pic32/dev/glcd.c ================================================ /* * Graphical GLCD driver for PIC32. * * Copyright (C) 2012 Majenko Technologies * * Permission to use, copy, modify, and distribute this software * and its documentation for any purpose and without fee is hereby * granted, provided that the above copyright notice appear in all * copies and that both that the copyright notice and this * permission notice and warranty disclaimer appear in supporting * documentation, and that the name of the author not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * * The author disclaim all warranties with regard to this * software, including all implied warranties of merchantability * and fitness. In no event shall the author be liable for any * special, indirect or consequential damages or any damages * whatsoever resulting from loss of use, data or profits, whether * in an action of contract, negligence or other tortious action, * arising out of or in connection with the use or performance of * this software. */ #include #include #include #include #include #include #include #include #include #define _BC(R,B) (R &= ~(1< 0x02, 0x01, 0x51, 0x09, 0x06,// ? 0x32, 0x49, 0x79, 0x41, 0x3E,// @ 0x7E, 0x11, 0x11, 0x11, 0x7E,// A 0x7F, 0x49, 0x49, 0x49, 0x36,// B 0x3E, 0x41, 0x41, 0x41, 0x22,// C 0x7F, 0x41, 0x41, 0x22, 0x1C,// D 0x7F, 0x49, 0x49, 0x49, 0x41,// E 0x7F, 0x09, 0x09, 0x01, 0x01,// F 0x3E, 0x41, 0x41, 0x51, 0x32,// G 0x7F, 0x08, 0x08, 0x08, 0x7F,// H 0x00, 0x41, 0x7F, 0x41, 0x00,// I 0x20, 0x40, 0x41, 0x3F, 0x01,// J 0x7F, 0x08, 0x14, 0x22, 0x41,// K 0x7F, 0x40, 0x40, 0x40, 0x40,// L 0x7F, 0x02, 0x04, 0x02, 0x7F,// M 0x7F, 0x04, 0x08, 0x10, 0x7F,// N 0x3E, 0x41, 0x41, 0x41, 0x3E,// O 0x7F, 0x09, 0x09, 0x09, 0x06,// P 0x3E, 0x41, 0x51, 0x21, 0x5E,// Q 0x7F, 0x09, 0x19, 0x29, 0x46,// R 0x46, 0x49, 0x49, 0x49, 0x31,// S 0x01, 0x01, 0x7F, 0x01, 0x01,// T 0x3F, 0x40, 0x40, 0x40, 0x3F,// U 0x1F, 0x20, 0x40, 0x20, 0x1F,// V 0x7F, 0x20, 0x18, 0x20, 0x7F,// W 0x63, 0x14, 0x08, 0x14, 0x63,// X 0x03, 0x04, 0x78, 0x04, 0x03,// Y 0x61, 0x51, 0x49, 0x45, 0x43,// Z 0x00, 0x00, 0x7F, 0x41, 0x41,// [ 0x02, 0x04, 0x08, 0x10, 0x20,// "\" 0x41, 0x41, 0x7F, 0x00, 0x00,// ] 0x04, 0x02, 0x01, 0x02, 0x04,// ^ 0x40, 0x40, 0x40, 0x40, 0x40,// _ 0x00, 0x01, 0x02, 0x04, 0x00,// ` 0x20, 0x54, 0x54, 0x54, 0x78,// a 0x7F, 0x48, 0x44, 0x44, 0x38,// b 0x38, 0x44, 0x44, 0x44, 0x20,// c 0x38, 0x44, 0x44, 0x48, 0x7F,// d 0x38, 0x54, 0x54, 0x54, 0x18,// e 0x08, 0x7E, 0x09, 0x01, 0x02,// f 0x08, 0x14, 0x54, 0x54, 0x3C,// g 0x7F, 0x08, 0x04, 0x04, 0x78,// h 0x00, 0x44, 0x7D, 0x40, 0x00,// i 0x20, 0x40, 0x44, 0x3D, 0x00,// j 0x00, 0x7F, 0x10, 0x28, 0x44,// k 0x00, 0x41, 0x7F, 0x40, 0x00,// l 0x7C, 0x04, 0x18, 0x04, 0x78,// m 0x7C, 0x08, 0x04, 0x04, 0x78,// n 0x38, 0x44, 0x44, 0x44, 0x38,// o 0x7C, 0x14, 0x14, 0x14, 0x08,// p 0x08, 0x14, 0x14, 0x18, 0x7C,// q 0x7C, 0x08, 0x04, 0x04, 0x08,// r 0x48, 0x54, 0x54, 0x54, 0x20,// s 0x04, 0x3F, 0x44, 0x40, 0x20,// t 0x3C, 0x40, 0x40, 0x20, 0x7C,// u 0x1C, 0x20, 0x40, 0x20, 0x1C,// v 0x3C, 0x40, 0x30, 0x40, 0x3C,// w 0x44, 0x28, 0x10, 0x28, 0x44,// x 0x0C, 0x50, 0x50, 0x50, 0x3C,// y 0x44, 0x64, 0x54, 0x4C, 0x44,// z 0x00, 0x08, 0x36, 0x41, 0x00,// { 0x00, 0x00, 0x7F, 0x00, 0x00,// | 0x00, 0x41, 0x36, 0x08, 0x00,// } 0x08, 0x08, 0x2A, 0x1C, 0x08,// -> 0x08, 0x1C, 0x2A, 0x08, 0x08 // <- }; /* * Devices: * /dev/glcd * * Write to the device outputs to GLCD memory as data. Use ioctl() to send * comands: * * ioctl(fd, GLCD_RESET, 0) - reset the GLCD * ioctl(fd, GLCD_SET_PAGE, page) - set the page address * ioctl(fd, GLCD_SET_Y, y) - set the page offset * */ int abs(int x) { if(x>0) return x; return 0-x; } void glcd_delay() { unsigned long c; for(c=0; c<200; c++) asm("nop"); } void glcd_write_value(int chip, unsigned char data) { _BC(LAT_RW, PIN_RW); _BC(TRIS_DB0, PIN_DB0); _BC(TRIS_DB1, PIN_DB1); _BC(TRIS_DB2, PIN_DB2); _BC(TRIS_DB3, PIN_DB3); _BC(TRIS_DB4, PIN_DB4); _BC(TRIS_DB5, PIN_DB5); _BC(TRIS_DB6, PIN_DB6); _BC(TRIS_DB7, PIN_DB7); if(chip==0) _BS(LAT_CS1, PIN_CS1); if(chip==1) _BS(LAT_CS2, PIN_CS2); if(data & 0b00000001) _BS(LAT_DB0, PIN_DB0); else _BC(LAT_DB0, PIN_DB0); if(data & 0b00000010) _BS(LAT_DB1, PIN_DB1); else _BC(LAT_DB1, PIN_DB1); if(data & 0b00000100) _BS(LAT_DB2, PIN_DB2); else _BC(LAT_DB2, PIN_DB2); if(data & 0b00001000) _BS(LAT_DB3, PIN_DB3); else _BC(LAT_DB3, PIN_DB3); if(data & 0b00010000) _BS(LAT_DB4, PIN_DB4); else _BC(LAT_DB4, PIN_DB4); if(data & 0b00100000) _BS(LAT_DB5, PIN_DB5); else _BC(LAT_DB5, PIN_DB5); if(data & 0b01000000) _BS(LAT_DB6, PIN_DB6); else _BC(LAT_DB6, PIN_DB6); if(data & 0b10000000) _BS(LAT_DB7, PIN_DB7); else _BC(LAT_DB7, PIN_DB7); _BS(LAT_E, PIN_E); glcd_delay(); _BC(LAT_E, PIN_E); glcd_delay(); if(chip==0) _BC(LAT_CS1, PIN_CS1); if(chip==1) _BC(LAT_CS2, PIN_CS2); } void glcd_write_data(int chip, unsigned char value) { _BS(LAT_DI, PIN_DI); glcd_write_value(chip,value); } void glcd_write_command(int chip, unsigned char value) { _BC(LAT_DI, PIN_DI); glcd_write_value(chip,value); } void glcd_init() { _BC(TRIS_DI, PIN_DI); _BC(TRIS_RW, PIN_RW); _BC(TRIS_E, PIN_E); _BC(TRIS_DB0, PIN_DB0); _BC(TRIS_DB1, PIN_DB1); _BC(TRIS_DB2, PIN_DB2); _BC(TRIS_DB3, PIN_DB3); _BC(TRIS_DB4, PIN_DB4); _BC(TRIS_DB5, PIN_DB5); _BC(TRIS_DB6, PIN_DB6); _BC(TRIS_DB7, PIN_DB7); _BC(TRIS_CS1, PIN_CS1); _BC(TRIS_CS2, PIN_CS2); _BC(TRIS_RES, PIN_RES); _BC(LAT_E, PIN_E); _BC(LAT_CS1, PIN_CS1); _BC(LAT_CS2, PIN_CS2); _BS(LAT_RES, PIN_RES); glcd_write_command(0,GLCD_CMD_ON); glcd_write_command(1,GLCD_CMD_ON); glcd_write_command(0,GLCD_CMD_START); glcd_write_command(1,GLCD_CMD_START); } void glcd_reset() { _BC(LAT_RES, PIN_RES); glcd_delay(); _BS(LAT_RES, PIN_RES); glcd_init(); } void glcd_set_page(int chip, int page) { glcd_write_command(chip, GLCD_CMD_SET_PAGE | (page & 0x07)); } void glcd_set_y(int chip, int y) { glcd_write_command(chip, GLCD_CMD_SET_Y | (y & 0x63)); } void glcd_update() { unsigned char x,y; for(y=0; y<8; y++) { glcd_set_page(0,y); glcd_set_page(1,y); glcd_set_y(0,0); glcd_set_y(1,0); for(x=0; x<64; x++) { glcd_write_data(0,screen[y][x]); glcd_write_data(1,screen[y][x+64]); } } } void glcd_cls() { unsigned char x,y; for(y=0; y<8; y++) { for(x=0; x<128; x++) { screen[y][x] = 0; } } screen_x = 0; screen_y = 0; } void glcd_load_page() { screen_x = 0; screen_y = 0; mode = MODE_LOAD; } int glcd_open (dev, flag, mode) dev_t dev; { int unit = minor(dev); if (unit >= 2) return ENXIO; if (u.u_uid != 0) return EPERM; glcd_init(); mode = MODE_TEXT; DEBUG("glcd%d: Openend\n",unit); //screen_x = 0; //screen_y = 0; return 0; } int glcd_close (dev_t dev, int flag, int mode) { return 0; } int glcd_read (dev_t dev, struct uio *uio, int flag) { // TODO return ENODEV; } void glcd_scrollUp(void) { unsigned char x, y; for (y=0; y<9; y++) { for (x=0; x<128; x++) { screen[y][x] = screen[y][x]>>1; if (y < 8) screen[y][x] |= (screen[y+1][x]<<7); } } } void glcd_putc(char c) { unsigned int cpos; if (c=='\r') { screen_x = 0; return; } if (c=='\n') { screen_y++; screen_x = 0; if (screen_y>7) { screen_y--; for (cpos=0; cpos<8; cpos++) glcd_scrollUp(); } return; } if (c == 0x08) { if (screen_x > 0) { screen_x -= 6; } else { if (screen_y > 0) { screen_x = 127-7; screen_y--; } } return; } if (c == 0x07) { return; } if (c == 0x0C) { glcd_cls(); glcd_update(); return; } if (screen_x > 127-6) { screen_x = 0; screen_y++; if (screen_y > 7) { screen_y--; for (cpos=0; cpos<8; cpos++) glcd_scrollUp(); } } cpos = (c - ' ') * 5; screen[screen_y][screen_x++] = font[cpos++]; screen[screen_y][screen_x++] = font[cpos++]; screen[screen_y][screen_x++] = font[cpos++]; screen[screen_y][screen_x++] = font[cpos++]; screen[screen_y][screen_x++] = font[cpos++]; screen[screen_y][screen_x++] = 0; } void glcd_setPixel(int x, int y) { unsigned char row; unsigned char pixel; unsigned char mask; if (x > 127) return; if (y > 63) return; if (x < 0) return; if (y < 0) return; row = y>>3; pixel = y & 0x07; mask = 1 << pixel; screen[row][x] |= mask; } void glcd_clearPixel(int x, int y) { unsigned char row; unsigned char pixel; unsigned char mask; if (x > 127) return; if (y > 63) return; if (x < 0) return; if (y < 0) return; row = y>>3; pixel = y & 0x07; mask = 1 << pixel; screen[row][x] &= ~mask; } void glcd_drawLine(int x, int y, int x2, int y2, unsigned char ink) { int w, h; int dx1=0, dy1=0, dx2=0, dy2=0; int longest, shortest; int numerator; int i; w = x2 - x; h = y2 - y; if (w < 0) { dx1 = -1; dx2 = -1; } else if (w > 0) { dx1 = 1; dx2 = 1; } if (h < 0) dy1 = -1; else if (h > 0) dy1 = 1; longest = abs(w); shortest = abs(h); if (! (longest>shortest)) { longest = abs(h); shortest = abs(w); if (h < 0) dy2 = -1; else if (h > 0) dy2 = 1; dx2 = 0; } numerator = longest >> 1; for (i=0; i<=longest; i++) { if (ink == 1) glcd_setPixel(x, y); else glcd_clearPixel(x, y); numerator += shortest; if (! (numerator < longest)) { numerator -= longest; x += dx1; y += dy1; } else { x += dx2; y += dy2; } } } void glcd_set_pixel(struct glcd_command *c) { glcd_setPixel(c->x1, c->y1); } void glcd_clear_pixel(struct glcd_command *c) { glcd_clearPixel(c->x1, c->y1); } void glcd_draw_line(struct glcd_command *c) { glcd_drawLine(c->x1, c->y1, c->x2, c->y2, c->ink); } void glcd_draw_box(struct glcd_command *c) { glcd_drawLine(c->x1, c->y1, c->x1, c->y2, c->ink); glcd_drawLine(c->x1, c->y1, c->x2, c->y1, c->ink); glcd_drawLine(c->x2, c->y2, c->x1, c->y2, c->ink); glcd_drawLine(c->x2, c->y2, c->x2, c->y1, c->ink); } void glcd_draw_filled_box(struct glcd_command *c) { unsigned char y; int y1, y2; if (c->y1 > c->y2) { y1 = c->y2; y2 = c->y1; } else { y1 = c->y1; y2 = c->y2; } for (y=y1; y<=y2; y++) { glcd_drawLine(c->x1, y, c->x2, y, c->ink); } } void glcd_goto_xy(struct glcd_command *c) { screen_x = c->x1; screen_y = c->y1; } int glcd_write (dev_t dev, struct uio *uio, int flag) { struct iovec *iov; int i; iov = uio->uio_iov; switch (mode) { case MODE_LOAD: for (i=0; iiov_len; i++) { screen[screen_y][screen_x] = *(iov->iov_base+i); screen_x++; if (screen_x == 128) { screen_y++; if (screen_y == 8) { mode = MODE_TEXT; glcd_update(); } } } break; case MODE_TEXT: for (i=0; iiov_len; i++) { glcd_putc(*(iov->iov_base+i)); } glcd_update(); break; } return 0; } int glcd_ioctl (dev_t dev, register u_int cmd, caddr_t addr, int flag) { switch (cmd) { case GLCD_RESET: glcd_reset(); break; case GLCD_UPDATE: glcd_update(); break; case GLCD_CLS: glcd_cls(); break; case GLCD_LOAD_PAGE: glcd_load_page(); break; case GLCD_SET_PIXEL: glcd_set_pixel((struct glcd_command *)addr); break; case GLCD_CLEAR_PIXEL: glcd_clear_pixel((struct glcd_command *)addr); break; case GLCD_LINE: glcd_draw_line((struct glcd_command *)addr); break; case GLCD_BOX: glcd_draw_box((struct glcd_command *)addr); break; case GLCD_FILLED_BOX: glcd_draw_filled_box((struct glcd_command *)addr); break; case GLCD_GOTO_XY: glcd_goto_xy((struct glcd_command *)addr); break; } return 0; } /* * Test to see if device is present. * Return true if found and initialized ok. */ static int glcdprobe(config) struct conf_device *config; { int flags = config->dev_flags; printf("glcd0: flags %#x\n", flags); return 1; } struct driver glcddriver = { "glcd", glcdprobe, }; ================================================ FILE: sys/arch/pic32/dev/gpanel-ili9341.c ================================================ /* * Display driver for ILI9341 LCD controller. * * Copyright (C) 2015 Serge Vakulenko * * Permission to use, copy, modify, and distribute this software * and its documentation for any purpose and without fee is hereby * granted, provided that the above copyright notice appear in all * copies and that both that the copyright notice and this * permission notice and warranty disclaimer appear in supporting * documentation, and that the name of the author not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * * The author disclaim all warranties with regard to this * software, including all implied warranties of merchantability * and fitness. In no event shall the author be liable for any * special, indirect or consequential damages or any damages * whatsoever resulting from loss of use, data or profits, whether * in an action of contract, negligence or other tortious action, * arising out of or in connection with the use or performance of * this software. */ #include #include #include /* * Write a 8-bit value to the ILI9341 Command register. */ static void write_command(int cmd) { gpanel_rs_command(); gpanel_write_byte(cmd); } /* * Write a 8-bit value to the ILI9341 Data register. */ static void write_data(int cmd) { gpanel_rs_data(); gpanel_write_byte(cmd); } /* * Set address window. */ static void set_window(int x0, int y0, int x1, int y1) { write_command(ILI9341_Column_Address_Set); write_data(x0 >> 8); gpanel_write_byte(x0); gpanel_write_byte(x1 >> 8); gpanel_write_byte(x1); write_command(ILI9341_Page_Address_Set); write_data(y0 >> 8); gpanel_write_byte(y0); gpanel_write_byte(y1 >> 8); gpanel_write_byte(y1); write_command(ILI9341_Memory_Write); gpanel_rs_data(); } /* * Draw a pixel. */ void ili_set_pixel(int x, int y, int color) { if (x < 0 || x >= gpanel_width || y < 0 || y >= gpanel_height) return; gpanel_cs_active(); set_window(x, y, x, y); gpanel_write_byte(color >> 8); gpanel_write_byte(color); gpanel_cs_idle(); } /* * Fast block fill operation. * Requires set_window() has previously been called to set * the fill bounds. * 'npixels' is inclusive, MUST be >= 1. */ static void flood(int color, int npixels) { unsigned blocks, i; unsigned hi = color >> 8, lo = color; /* Write first pixel normally, decrement counter by 1. */ gpanel_write_byte(hi); gpanel_write_byte(lo); npixels--; /* 64 pixels/block. */ blocks = npixels >> 6; if (hi == lo) { /* High and low bytes are identical. Leave prior data * on the port(s) and just toggle the write strobe. */ while (blocks--) { /* 64 pixels/block / 4 pixels/pass. */ for (i = 16; i > 0; i--) { /* 2 bytes/pixel x 4 pixels. */ gpanel_wr_strobe(); gpanel_wr_strobe(); gpanel_wr_strobe(); gpanel_wr_strobe(); gpanel_wr_strobe(); gpanel_wr_strobe(); gpanel_wr_strobe(); gpanel_wr_strobe(); } } /* Fill any remaining pixels (1 to 64). */ for (i = npixels & 63; i > 0; i--) { gpanel_wr_strobe(); gpanel_wr_strobe(); } } else { while (blocks--) { /* 64 pixels/block / 4 pixels/pass. */ for (i = 16; i > 0; i--) { gpanel_write_byte(hi); gpanel_write_byte(lo); gpanel_write_byte(hi); gpanel_write_byte(lo); gpanel_write_byte(hi); gpanel_write_byte(lo); gpanel_write_byte(hi); gpanel_write_byte(lo); } } for (i = npixels & 63; i > 0; i--) { gpanel_write_byte(hi); gpanel_write_byte(lo); } } } /* * Switch the screen orientation. */ static void ili9341_set_rotation(int rotation) { write_command(ILI9341_Memory_Access_Control); switch (rotation & 3) { case 0: /* Portrait */ write_data(MADCTL_MX | MADCTL_BGR); gpanel_width = 240; gpanel_height = 320; break; case 1: /* Landscape */ write_data(MADCTL_MV | MADCTL_BGR); gpanel_width = 320; gpanel_height = 240; break; case 2: /* Upside down portrait */ write_data(MADCTL_MY | MADCTL_BGR); gpanel_width = 240; gpanel_height = 320; break; case 3: /* Upside down landscape */ write_data(MADCTL_MX | MADCTL_MY | MADCTL_MV | MADCTL_BGR); gpanel_width = 320; gpanel_height = 240; break; } } /* * Switch the screen orientation. */ static void ili9481_set_rotation(int rotation) { write_command(ILI9341_Memory_Access_Control); switch (rotation & 3) { case 0: /* Portrait */ write_data(MADCTL_MX | MADCTL_BGR); gpanel_width = 320; gpanel_height = 480; break; case 1: /* Landscape */ write_data(MADCTL_MV | MADCTL_BGR); gpanel_width = 480; gpanel_height = 320; break; case 2: /* Upside down portrait */ write_data(MADCTL_MY | MADCTL_BGR); gpanel_width = 320; gpanel_height = 480; break; case 3: /* Upside down landscape */ write_data(MADCTL_MX | MADCTL_MY | MADCTL_MV | MADCTL_BGR); gpanel_width = 480; gpanel_height = 320; break; } } static void ili9341_resize(struct gpanel_hw *h, int width, int height) { gpanel_cs_active(); /* Switch screen orientaation. */ if (width > height) ili9341_set_rotation(1); /* Landscape */ else if (width < height) ili9341_set_rotation(0); /* Portrait */ gpanel_cs_idle(); } static void ili9481_resize(struct gpanel_hw *h, int width, int height) { gpanel_cs_active(); /* Switch screen orientaation. */ if (width > height) ili9481_set_rotation(1); /* Landscape */ else if (width < height) ili9481_set_rotation(0); /* Portrait */ gpanel_cs_idle(); } /* * Fill a rectangle with specified color. */ void ili_fill_rectangle(int x0, int y0, int x1, int y1, int color) { if (x0 < 0) x0 = 0; if (y0 < 0) x0 = 0; if (x1 < 0) x1 = 0; if (y1 < 0) x1 = 0; if (x0 >= gpanel_width) x0 = gpanel_width-1; if (x1 >= gpanel_width) x1 = gpanel_width-1; if (y0 >= gpanel_height) y0 = gpanel_height-1; if (y1 >= gpanel_height) y1 = gpanel_height-1; if (x1 < x0) { int t = x0; x0 = x1; x1 = t; } if (y1 < y0) { int t = y0; y0 = y1; y1 = t; } gpanel_cs_active(); set_window(x0, y0, x1, y1); flood(color, (x1 - x0 + 1) * (y1 - y0 + 1)); gpanel_cs_idle(); } /* * Fill a rectangle with user data. */ void ili_draw_image(int x, int y, int width, int height, const unsigned short *data) { unsigned cnt = width * height; int color; gpanel_cs_active(); set_window(x, y, x + width - 1, y + height - 1); while (cnt--) { color = *data++; gpanel_write_byte(color >> 8); gpanel_write_byte(color); } gpanel_cs_idle(); } /* * Draw a glyph of one symbol. */ void ili_draw_glyph(const struct gpanel_font_t *font, int color, int background, int x, int y, int width, const unsigned short *bits) { int h, w, c; unsigned bitmask = 0; if (x + width > gpanel_width || y + font->height > gpanel_height) return; if (background >= 0) { /* * Clear background. */ gpanel_cs_active(); set_window(x, y, x + width - 1, y + font->height - 1); /* Loop on each glyph row. */ for (h=0; hheight; h++) { /* Loop on every pixel in the row (left to right). */ for (w=0; w> 8); gpanel_write_byte(c); } } gpanel_cs_idle(); } else { /* * Transparent background. */ /* Loop on each glyph row. */ for (h=0; hheight; h++) { /* Loop on every pixel in the row (left to right). */ for (w=0; wname = "Ilitek ILI9341"; h->resize = ili9341_resize; h->set_pixel = ili_set_pixel; h->fill_rectangle = ili_fill_rectangle; h->draw_image = ili_draw_image; h->draw_glyph = ili_draw_glyph; } /* * Initialize the LCD controller. * Fill the gpanel_hw descriptor. */ void ili9481_init_display(struct gpanel_hw *h) { /* Use a few NOPs to synchronize after the hard Reset. */ gpanel_cs_active(); write_command(ILI9341_No_Operation); write_command(ILI9341_No_Operation); write_command(ILI9341_No_Operation); write_command(ILI9341_No_Operation); write_command(ILI9341_Sleep_OUT); udelay(150000); write_command(ILI9341_NV_Memory_Write); write_data(0x07); write_data(0x42); write_data(0x18); write_command(ILI9341_NV_Memory_Protection_Key); write_data(0x00); write_data(0x07); write_data(0x10); write_command(ILI9341_NV_Memory_Status_Read); write_data(0x01); write_data(0x02); write_command(ILI9341_Power_Control_1); write_data(0x10); write_data(0x3B); write_data(0x00); write_data(0x02); write_data(0x11); write_command(ILI9341_VCOM_Control_1); write_data(0x03); write_command(ILI9341_Memory_Access_Control); write_data(0x0A); write_command(ILI9341_Pixel_Format_Set); write_data(0x55); write_command(ILI9341_Column_Address_Set); write_data(0x00); write_data(0x00); write_data(0x01); write_data(0x3F); write_command(ILI9341_Page_Address_Set); write_data(0x00); write_data(0x00); write_data(0x01); write_data(0xE0); write_command(ILI9341_Display_ON); ili9481_set_rotation(1); /* Landscape */ gpanel_cs_idle(); /* * Fill the gpanel_hw descriptor. */ h->name = "Ilitek ILI9341"; h->resize = ili9481_resize; h->set_pixel = ili_set_pixel; h->fill_rectangle = ili_fill_rectangle; h->draw_image = ili_draw_image; h->draw_glyph = ili_draw_glyph; } ================================================ FILE: sys/arch/pic32/dev/gpanel-nt35702.c ================================================ /* * Display driver for NT35702 LCD controller. * This controller is partially compatible with ILI9341 chip, * so we can reuse most of ili_xxx() routines. * * Copyright (C) 2015 Serge Vakulenko * * Permission to use, copy, modify, and distribute this software * and its documentation for any purpose and without fee is hereby * granted, provided that the above copyright notice appear in all * copies and that both that the copyright notice and this * permission notice and warranty disclaimer appear in supporting * documentation, and that the name of the author not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * * The author disclaim all warranties with regard to this * software, including all implied warranties of merchantability * and fitness. In no event shall the author be liable for any * special, indirect or consequential damages or any damages * whatsoever resulting from loss of use, data or profits, whether * in an action of contract, negligence or other tortious action, * arising out of or in connection with the use or performance of * this software. */ #include #include /* * NT35702 registers. */ #define NT35702_NOP 0x00 /* No Operation */ #define NT35702_SWRESET 0x01 /* Software reset */ #define NT35702_RDDID 0x04 /* Read Display ID */ #define NT35702_RDDST 0x09 /* Read Display Status */ #define NT35702_RDDPM 0x0A /* Read Display Power Mode */ #define NT35702_RDDMADCTR 0x0B /* Read Display MADCTR */ #define NT35702_RDDCOLMOD 0x0C /* Read Display Pixel Format */ #define NT35702_RDDIM 0x0D /* Read Display Image Mode */ #define NT35702_RDDSM 0x0E /* Read Display Signal Mode */ #define NT35702_RDDSDR 0x0F /* Read Display Self-diagnostic result */ #define NT35702_SLPIN 0x10 /* Sleep in & booster off */ #define NT35702_SLPOUT 0x11 /* Sleep out & booster on */ #define NT35702_PTLON 0x12 /* Partial mode on */ #define NT35702_NORON 0x13 /* Partial off (Normal) */ #define NT35702_DSBCTL 0x15 /* Deep Standby mode control */ #define NT35702_INVOFF 0x20 /* Inversion off (normal) */ #define NT35702_INVON 0x21 /* Inversion on */ #define NT35702_DISPOFF 0x28 /* Display off */ #define NT35702_DISPON 0x29 /* Display on */ #define NT35702_CASET 0x2A /* Column address set */ #define NT35702_RASET 0x2B /* Row address set */ #define NT35702_RAMWR 0x2C /* Memory write */ #define NT35702_PTLAR 0x30 /* Partial start/end address set */ #define NT35702_SCRLAR 0x33 /* Scroll area set */ #define NT35702_TEOFF 0x34 /* Tearing effect line off */ #define NT35702_TEON 0x35 /* Tearing effect mode set & on */ #define NT35702_MADCTL 0x36 /* Memory data access control */ #define NT35702_VSCSAD 0x37 /* Scroll start address of RAM */ #define NT35702_IDMOFF 0x38 /* Idle mode off */ #define NT35702_IDMON 0x39 /* Idle mode on */ #define NT35702_COLMOD 0x3A /* Interface pixel format */ #define NT35702_WRDISBV 0x51 /* Write Display Brightness */ #define NT35702_WRCTRLD 0x53 /* Write CTRL Display */ #define NT35702_WRCABC 0x55 /* Write Content Adaptive Brightness Control */ #define NT35702_WRCABCMB 0x5E /* Write CABC minimum brightness */ #define NT35702_RDPWM 0x6A /* Read CABC Brightness */ #define NT35702_WRPWMF 0x6B /* Write the PWM Frequency for CABC */ #define NT35702_CABC_FOR_CE 0x77 /* Force CABC PWM in Some Conditions */ #define NT35702_CABCDMT 0x79 /* Set Dimming Time Length for CABC */ #define NT35702_RDID1 0xDA /* Read IDB */ #define NT35702_RDID2 0xDB /* Read ID2 */ #define NT35702_RDID3 0xDC /* Read ID3 */ #define NT35702_INVCTR 0xB4 /* Display inversion control */ #define NT35702_DISSET5 0xB6 /* Display function setting */ #define NT35702_SDOCTR 0xB7 /* SD output direction control */ #define NT35702_GDOCTR 0xB8 /* GD output direction control */ #define NT35702_PWCTR1 0xC0 /* Power control setting * VRH: Set the GVDD */ #define NT35702_PWCTR2 0xC1 /* Power control setting */ #define NT35702_PWCTR3 0xC2 /* In normal mode (Full colors) * AP: adjust the operational amplifier * DC: adjust the booster circuit for normal mode */ #define NT35702_PWCTR4 0xC3 /* In Idle mode (8-colors) * AP: adjust the operational amplifier * DC: adjust the booster circuit for Idle mode */ #define NT35702_PWCTR5 0xC4 /* In partial mode + Full colors * AP: adjust the operational amplifier * DC: adjust the booster circuit for Idle mode */ #define NT35702_VMCTR1 0xC5 /* VMH: VCOMH voltage control * VML: VCOML voltage control */ #define NT35702_VMOFCTR 0xC7 /* VMF: VCOM offset control */ #define NT35702_RVMOFCTR 0xC8 /* Read the VMOF value form NV memory */ #define NT35702_WRID2 0xD1 /* LCM version code * Write ID2 value to NV memory */ #define NT35702_WRID3 0xD2 /* Customer Project code * Write ID3 value to NV memory */ #define NT35702_RDID4 0xD3 /* ID41: IC vendor code * ID42: IC part number code * ID43 & ID44: chip version code */ #define NT35702_MTP 0xD4 /* MTP access program enable */ #define NT35702_EPWRITE 0xD5 /* NV write command */ #define NT35702_MTPSUP 0xD7 /* MTP speed up */ #define NT35702_GAMCTRP1 0xE0 /* Gamma adjustment (+ polarity) */ #define NT35702_GAMCTRN1 0xE1 /* Gamma adjustment (- polarity) */ #define NT35702_FRMCTR 0xFA /* Frame rate control */ #define NT35702_AVDDCLP 0xFD /* AVDD Clamp Voltage */ /* * Memory Access Control register */ #define MADCTL_MY 0x80 /* Row address order */ #define MADCTL_MX 0x40 /* Column address order */ #define MADCTL_MV 0x20 /* Row/column exchange */ #define MADCTL_ML 0x10 /* Vertical refresh order */ #define MADCTL_BGR 0x08 /* Color filter selector: 0=RGB, 1=BGR */ #define MADCTL_MH 0x04 /* Horisontal refresh direction: 1=left-to-right */ /* * Reuse ILI9341 routines. */ extern void ili_set_pixel(int x, int y, int color); extern void ili_fill_rectangle(int x0, int y0, int x1, int y1, int color); extern void ili_draw_image(int x, int y, int width, int height, const unsigned short *data); extern void ili_draw_glyph(const struct gpanel_font_t *font, int color, int background, int x, int y, int width, const unsigned short *bits); /* * Write a 8-bit value to the NT35702 Command register. */ static void write_command(int cmd) { gpanel_rs_command(); gpanel_write_byte(cmd); } /* * Write a 8-bit value to the NT35702 Data register. */ static void write_data(int cmd) { gpanel_rs_data(); gpanel_write_byte(cmd); } /* * Switch the screen orientation. */ static void set_rotation(int rotation) { write_command(NT35702_MADCTL); switch (rotation & 3) { case 0: /* Portrait */ write_data(MADCTL_MX | MADCTL_MY | MADCTL_BGR); gpanel_width = 240; gpanel_height = 320; break; case 1: /* Landscape */ write_data(MADCTL_MY | MADCTL_MV | MADCTL_BGR); gpanel_width = 320; gpanel_height = 240; break; case 2: /* Upside down portrait */ write_data(MADCTL_BGR); gpanel_width = 240; gpanel_height = 320; break; case 3: /* Upside down landscape */ write_data(MADCTL_MX | MADCTL_MV | MADCTL_BGR); gpanel_width = 320; gpanel_height = 240; break; } } static void nt35702_resize(struct gpanel_hw *h, int width, int height) { gpanel_cs_active(); /* Switch screen orientaation. */ if (width > height) set_rotation(1); /* Landscape */ else if (width < height) set_rotation(0); /* Portrait */ gpanel_cs_idle(); } /* * Initialize the LCD controller. * Fill the gpanel_hw descriptor. */ void nt35702_init_display(struct gpanel_hw *h) { gpanel_cs_active(); write_command(NT35702_SWRESET); udelay(20000); write_command(NT35702_SLPOUT); udelay(120000); write_command(NT35702_PWCTR3); write_data(0x05); // APA2 APA1 APA0 Large write_data(0x00); // Step-up cycle in Booster circuit 1 // Step-up cycle in Booster circuit 2,3 write_command(NT35702_PWCTR4); write_data(0x05); // APA2 APA1 APA0 Large write_data(0x00); // Step-up cycle in Booster circuit 1 // Step-up cycle in Booster circuit 2,3 write_command(NT35702_PWCTR5); write_data(0x05); // APA2 APA1 APA0 Large write_data(0x00); // Step-up cycle in Booster circuit 1 // Step-up cycle in Booster circuit 2,3 write_command(NT35702_COLMOD); write_data(0x55); write_command(NT35702_MTPSUP); write_data(0x40); write_data(0xE0); write_command(NT35702_AVDDCLP); write_data(0x06); write_data(0x11); write_command(NT35702_FRMCTR); write_data(0x38); write_data(0x20); write_data(0x1C); write_data(0x10); write_data(0x37); write_data(0x12); write_data(0x22); write_data(0x1E); write_command(NT35702_PWCTR1); // Set GVDD write_data(0x05); write_command(NT35702_VMCTR1); // Set Vcom write_data(0x60); write_data(0x00); write_command(NT35702_VMOFCTR); // Set VCOM-OFFSET write_data(0xA9); // You can fine-tune to improve flicker set_rotation(1); /* Landscape */ write_command(NT35702_GAMCTRP1); write_data(0x22); write_data(0x23); write_data(0x25); write_data(0x08); write_data(0x10); write_data(0x14); write_data(0x40); write_data(0x7B); write_data(0x50); write_data(0x0B); write_data(0x1B); write_data(0x22); write_data(0x20); write_data(0x2F); write_data(0x37); write_command(NT35702_GAMCTRN1); write_data(0x0C); write_data(0x14); write_data(0x23); write_data(0x0E); write_data(0x14); write_data(0x15); write_data(0x36); write_data(0x59); write_data(0x46); write_data(0x0B); write_data(0x1F); write_data(0x27); write_data(0x1F); write_data(0x20); write_data(0x22); write_command(NT35702_DISPON); write_command(NT35702_RAMWR); gpanel_cs_idle(); /* * Fill the gpanel_hw descriptor. */ h->name = "Novatek NT35702"; h->resize = nt35702_resize; h->set_pixel = ili_set_pixel; h->fill_rectangle = ili_fill_rectangle; h->draw_image = ili_draw_image; h->draw_glyph = ili_draw_glyph; } ================================================ FILE: sys/arch/pic32/dev/gpanel-s6d04h0.c ================================================ /* * Display driver for Samsung S6D04H0 LCD controller. * * Copyright (C) 2015 Serge Vakulenko * * Permission to use, copy, modify, and distribute this software * and its documentation for any purpose and without fee is hereby * granted, provided that the above copyright notice appear in all * copies and that both that the copyright notice and this * permission notice and warranty disclaimer appear in supporting * documentation, and that the name of the author not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * * The author disclaim all warranties with regard to this * software, including all implied warranties of merchantability * and fitness. In no event shall the author be liable for any * special, indirect or consequential damages or any damages * whatsoever resulting from loss of use, data or profits, whether * in an action of contract, negligence or other tortious action, * arising out of or in connection with the use or performance of * this software. */ #include #include /* * Display size. */ static int _width, _height; /* * Level 1 Commands */ #define S6D04H0_No_Operation 0x00 /* C 0 */ #define S6D04H0_Software_Reset 0x01 /* C 0 */ #define S6D04H0_Read_Display_Identification_Information 0x04 /* R 4 */ #define S6D04H0_Read_Display_Status 0x09 /* R 5 */ #define S6D04H0_Read_Display_Power_Mode 0x0A /* R 2 */ #define S6D04H0_Read_Display_MADCTL 0x0B /* R 2 */ #define S6D04H0_Read_Display_Pixel_Format 0x0C /* R 2 */ #define S6D04H0_Read_Display_Image_Mode 0x0D /* R 2 */ #define S6D04H0_Read_Display_Signal_Mode 0x0E /* R 2 */ #define S6D04H0_Read_Display_Self_Diagnostic_Result 0x0F /* R 2 */ #define S6D04H0_Sleep_In 0x10 /* C 0 */ #define S6D04H0_Sleep_Out 0x11 /* C 0 */ #define S6D04H0_Partial_Mode_On 0x12 /* C 0 */ #define S6D04H0_Normal_Display_Mode_On 0x13 /* C 0 */ #define S6D04H0_Display_Inversion_Off 0x20 /* C 0 */ #define S6D04H0_Display_Inversion_On 0x21 /* C 0 */ #define S6D04H0_Gamma_Set 0x26 /* W 1 */ #define S6D04H0_Display_Off 0x28 /* C 0 */ #define S6D04H0_Display_On 0x29 /* C 0 */ #define S6D04H0_Column_Address_Set 0x2A /* W 4 */ #define S6D04H0_Page_Address_Set 0x2B /* W 4 */ #define S6D04H0_Memory_Write 0x2C /* W n */ #define S6D04H0_Memory_Read 0x2E /* R n */ #define S6D04H0_Partial_Area 0x30 /* W 4 */ #define S6D04H0_Vertical_Scrolling_Definition 0x33 /* W 6 */ #define S6D04H0_Tearing_Effect_Line_Off 0x34 /* C 0 */ #define S6D04H0_Tearing_Effect_Line_On 0x35 /* W 1 */ #define S6D04H0_Memory_Data_Access_Control 0x36 /* W 1 */ #define S6D04H0_Vertical_Scrolling_Start_Address 0x37 /* W 2 */ #define S6D04H0_Idle_Mode_Off 0x38 /* C 0 */ #define S6D04H0_Idle_Mode_On 0x39 /* C 0 */ #define S6D04H0_Interface_Pixel_Format 0x3A /* W 1 */ #define S6D04H0_Memory_Write_Continue 0x3C /* W n */ #define S6D04H0_Memory_Read_Continue 0x3E /* R n */ #define S6D04H0_Set_Tear_Scanline 0x44 /* W 2 */ #define S6D04H0_Get_Scanline 0x45 /* R 2 */ #define S6D04H0_Write_Manual_Brightness 0x51 /* W 1 */ #define S6D04H0_Read_Display_Brightness 0x52 /* R 2 */ #define S6D04H0_Write_BL_Control 0x53 /* W 1 */ #define S6D04H0_Read_BL_Control 0x54 /* R 2 */ #define S6D04H0_Write_MIE_Mode 0x55 /* W 1 */ #define S6D04H0_Read_MIE_Mode 0x56 /* R 2 */ #define S6D04H0_Write_Minimum_Brightness 0x5E /* W 1 */ #define S6D04H0_Read_Minimum_Brightness 0x5F /* R 2 */ #define S6D04H0_Read_DDB_Start 0xA1 /* R n */ #define S6D04H0_Read_DDB_Continue 0xA8 /* R n */ #define S6D04H0_Read_ID1 0xDA /* R 2 */ #define S6D04H0_Read_ID2 0xDB /* R 2 */ #define S6D04H0_Read_ID3 0xDC /* R 2 */ /* * Level 2 Commands */ #define S6D04H0_MIECTL 0xC0 /* W(3) MIE control */ #define S6D04H0_BCMODE 0xC1 /* W(1) MIE control */ #define S6D04H0_WRMIECTL 0xC2 /* W(9) MIE control */ #define S6D04H0_WRBLCTL 0xC3 /* W(2) MIE control */ #define S6D04H0_MTPCTL 0xD0 /* W(1) MTP control */ #define S6D04H0_MTPACCS 0xD2 /* W(2) MTP control */ #define S6D04H0_MTPRD 0xD3 /* R(8) MTP control */ #define S6D04H0_DSTB 0xDF /* W(1) Deep Standby */ #define S6D04H0_PASSWD1 0xF0 /* W(2) Test Key */ #define S6D04H0_PASSWD2 0xF1 /* W(2) Test Key */ #define S6D04H0_DISCTL 0xF2 /* W(17) Display control */ #define S6D04H0_MANPWRSEQ 0xF3 /* W(5) Power sequence control */ #define S6D04H0_PWRCTL 0xF4 /* W(20) Power control */ #define S6D04H0_VCMCTL 0xF5 /* W(12) VCOM control */ #define S6D04H0_SRCCTL 0xF6 /* W(9) Source control */ #define S6D04H0_IFCTL 0xF7 /* W(4) Interface control */ #define S6D04H0_PANELCTL 0xF8 /* W(3) Gate control */ #define S6D04H0_GAMMASEL 0xF9 /* W(1) Gamma selection */ #define S6D04H0_PGAMMACTL 0xFA /* W(12) Positive gamma control */ #define S6D04H0_NGAMMACTL 0xFB /* W(12) Negative gamma control */ /* * Memory Access Control register */ #define MADCTL_MY 0x80 #define MADCTL_MX 0x40 #define MADCTL_MV 0x20 #define MADCTL_ML 0x10 #define MADCTL_BGR 0x08 #define MADCTL_MH 0x04 #define MADCTL_RGB 0x00 /* * Write a 8-bit value to the S6D04H0 Command register. */ static void write_command(int cmd) { gpanel_cs_active(); gpanel_rs_command(); gpanel_write_byte(cmd); gpanel_cs_idle(); } /* * Write a 8-bit value to the S6D04H0 Data register. */ static void write_data(int cmd) { gpanel_cs_active(); gpanel_rs_data(); gpanel_write_byte(cmd); gpanel_cs_idle(); } /* * Set address window. */ static void set_window(int x0, int y0, int x1, int y1) { write_command(S6D04H0_Column_Address_Set); write_data(x0 >> 8); gpanel_write_byte(x0); gpanel_write_byte(x1 >> 8); gpanel_write_byte(x1); write_command(S6D04H0_Page_Address_Set); write_data(y0 >> 8); gpanel_write_byte(y0); gpanel_write_byte(y1 >> 8); gpanel_write_byte(y1); write_command(S6D04H0_Memory_Write); } /* * Draw a pixel. */ static void s6d04h0_set_pixel(int x, int y, int color) { if (x < 0 || x >= _width || y < 0 || y >= _height) return; set_window(x, y, x, y); write_data(color >> 8); write_data(color); } /* * Fast block fill operation. * Requires set_window() has previously been called to set * the fill bounds. * 'npixels' is inclusive, MUST be >= 1. */ static void flood(int color, int npixels) { unsigned blocks, i; unsigned hi = color >> 8, lo = color; /* Write first pixel normally, decrement counter by 1. */ gpanel_rs_data(); gpanel_write_byte(hi); gpanel_write_byte(lo); npixels--; /* 64 pixels/block. */ blocks = npixels >> 6; if (hi == lo) { /* High and low bytes are identical. Leave prior data * on the port(s) and just toggle the write strobe. */ while (blocks--) { /* 64 pixels/block / 4 pixels/pass. */ for (i = 16; i > 0; i--) { /* 2 bytes/pixel x 4 pixels. */ gpanel_wr_strobe(); gpanel_wr_strobe(); gpanel_wr_strobe(); gpanel_wr_strobe(); gpanel_wr_strobe(); gpanel_wr_strobe(); gpanel_wr_strobe(); gpanel_wr_strobe(); } } /* Fill any remaining pixels (1 to 64). */ for (i = npixels & 63; i > 0; i--) { gpanel_wr_strobe(); gpanel_wr_strobe(); } } else { while (blocks--) { /* 64 pixels/block / 4 pixels/pass. */ for (i = 16; i > 0; i--) { gpanel_write_byte(hi); gpanel_write_byte(lo); gpanel_write_byte(hi); gpanel_write_byte(lo); gpanel_write_byte(hi); gpanel_write_byte(lo); gpanel_write_byte(hi); gpanel_write_byte(lo); } } for (i = npixels & 63; i > 0; i--) { gpanel_write_byte(hi); gpanel_write_byte(lo); } } } /* * Switch the screen orientation. */ static void set_rotation(int rotation) { write_command(S6D04H0_Memory_Data_Access_Control); switch (rotation & 3) { case 0: /* Portrait */ write_data(MADCTL_MY | MADCTL_BGR); _width = 240; _height = 320; break; case 1: /* Landscape */ write_data(MADCTL_MX | MADCTL_MY | MADCTL_MV | MADCTL_BGR); _width = 320; _height = 240; break; case 2: /* Upside down portrait */ write_data(MADCTL_MX | MADCTL_BGR); _width = 240; _height = 320; break; case 3: /* Upside down landscape */ write_data(MADCTL_MV | MADCTL_BGR); _width = 320; _height = 240; break; } } static void s6d04h0_clear(struct gpanel_hw *h, int color, int width, int height) { /* Switch screen orientaation. */ if (width > height) set_rotation(1); /* Landscape */ else if (width < height) set_rotation(0); /* Portrait */ /* Fill the screen with a color. */ set_window(0, 0, _width-1, _height-1); flood(color, _width * _height); } /* * Fill a rectangle with specified color. */ static void s6d04h0_fill_rectangle(int x0, int y0, int x1, int y1, int color) { if (x0 < 0) x0 = 0; if (y0 < 0) x0 = 0; if (x1 < 0) x1 = 0; if (y1 < 0) x1 = 0; if (x0 >= _width) x0 = _width-1; if (x1 >= _width) x1 = _width-1; if (y0 >= _height) y0 = _height-1; if (y1 >= _height) y1 = _height-1; if (x1 < x0) { int t = x0; x0 = x1; x1 = t; } if (y1 < y0) { int t = y0; y0 = y1; y1 = t; } set_window(x0, y0, x1, y1); flood(color, (x1 - x0 + 1) * (y1 - y0 + 1)); } /* * Fill a rectangle with user data. */ static void s6d04h0_draw_image(int x, int y, int width, int height, const unsigned short *data) { unsigned cnt = width * height; int color; set_window(x, y, x + width - 1, y + height - 1); gpanel_rs_data(); while (cnt--) { color = *data++; gpanel_write_byte(color >> 8); gpanel_write_byte(color); } } /* * Draw a glyph of one symbol. */ static void s6d04h0_draw_glyph(const struct gpanel_font_t *font, int color, int background, int x, int y, int width, const unsigned short *bits) { int h, w, c; unsigned bitmask = 0; if (background >= 0) { /* * Clear background. */ set_window(x, y, x + width - 1, y + font->height - 1); gpanel_cs_active(); gpanel_rs_data(); /* Loop on each glyph row. */ for (h=0; hheight; h++) { /* Loop on every pixel in the row (left to right). */ for (w=0; w> 8); gpanel_write_byte(c); } } gpanel_cs_idle(); } else { /* * Transparent background. */ /* Loop on each glyph row. */ for (h=0; hheight; h++) { /* Loop on every pixel in the row (left to right). */ for (w=0; wname = "Samsung S6D04H0"; h->width = _width; h->height = _height; h->clear = s6d04h0_clear; h->set_pixel = s6d04h0_set_pixel; h->fill_rectangle = s6d04h0_fill_rectangle; h->draw_image = s6d04h0_draw_image; h->draw_glyph = s6d04h0_draw_glyph; } ================================================ FILE: sys/arch/pic32/dev/gpanel-spi-ili9341.c ================================================ /* * Display driver for ILI9341 LCD controller. * * Copyright (C) 2015 Serge Vakulenko * * Permission to use, copy, modify, and distribute this software * and its documentation for any purpose and without fee is hereby * granted, provided that the above copyright notice appear in all * copies and that both that the copyright notice and this * permission notice and warranty disclaimer appear in supporting * documentation, and that the name of the author not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * * The author disclaim all warranties with regard to this * software, including all implied warranties of merchantability * and fitness. In no event shall the author be liable for any * special, indirect or consequential damages or any damages * whatsoever resulting from loss of use, data or profits, whether * in an action of contract, negligence or other tortious action, * arising out of or in connection with the use or performance of * this software. */ #include #include #include /* * Set address window. */ static void set_window(int x0, int y0, int x1, int y1) { gpanel_send_command(ILI9341_Column_Address_Set); gpanel_send_data(x0 >> 8); gpanel_send_data(x0); gpanel_send_data(x1 >> 8); gpanel_send_data(x1); gpanel_send_command(ILI9341_Page_Address_Set); gpanel_send_data(y0 >> 8); gpanel_send_data(y0); gpanel_send_data(y1 >> 8); gpanel_send_data(y1); gpanel_send_command(ILI9341_Memory_Write); } /* * Draw a pixel. */ void ili9341_set_pixel(int x, int y, int color) { if (x < 0 || x >= gpanel_width || y < 0 || y >= gpanel_height) return; gpanel_cs_active(); set_window(x, y, x, y); gpanel_send_data(color >> 8); gpanel_send_data(color); gpanel_cs_idle(); } /* * Fast block fill operation. * Requires set_window() has previously been called to set * the fill bounds. * 'npixels' is inclusive, MUST be >= 1. */ static void flood(int color, int npixels) { unsigned i; unsigned hi = color >> 8, lo = color; for (i = npixels; i > 0; i--) { gpanel_send_data(hi); gpanel_send_data(lo); } } /* * Switch the screen orientation. */ static void set_rotation(int rotation) { gpanel_send_command(ILI9341_Memory_Access_Control); switch (rotation & 3) { case 0: /* Portrait */ gpanel_send_data(MADCTL_MX | MADCTL_BGR); gpanel_width = 240; gpanel_height = 320; break; case 1: /* Landscape */ gpanel_send_data(MADCTL_MV | MADCTL_BGR); gpanel_width = 320; gpanel_height = 240; break; case 2: /* Upside down portrait */ gpanel_send_data(MADCTL_MY | MADCTL_BGR); gpanel_width = 240; gpanel_height = 320; break; case 3: /* Upside down landscape */ gpanel_send_data(MADCTL_MX | MADCTL_MY | MADCTL_MV | MADCTL_BGR); gpanel_width = 320; gpanel_height = 240; break; } } static void ili9341_resize(struct gpanel_hw *h, int width, int height) { gpanel_cs_active(); /* Switch screen orientaation. */ if (width > height) set_rotation(1); /* Landscape */ else if (width < height) set_rotation(0); /* Portrait */ gpanel_cs_idle(); } /* * Fill a rectangle with specified color. */ void ili9341_fill_rectangle(int x0, int y0, int x1, int y1, int color) { if (x0 < 0) x0 = 0; if (y0 < 0) x0 = 0; if (x1 < 0) x1 = 0; if (y1 < 0) x1 = 0; if (x0 >= gpanel_width) x0 = gpanel_width-1; if (x1 >= gpanel_width) x1 = gpanel_width-1; if (y0 >= gpanel_height) y0 = gpanel_height-1; if (y1 >= gpanel_height) y1 = gpanel_height-1; if (x1 < x0) { int t = x0; x0 = x1; x1 = t; } if (y1 < y0) { int t = y0; y0 = y1; y1 = t; } gpanel_cs_active(); set_window(x0, y0, x1, y1); flood(color, (x1 - x0 + 1) * (y1 - y0 + 1)); gpanel_cs_idle(); } /* * Fill a rectangle with user data. */ void ili9341_draw_image(int x, int y, int width, int height, const unsigned short *data) { unsigned cnt = width * height; int color; gpanel_cs_active(); set_window(x, y, x + width - 1, y + height - 1); while (cnt--) { color = *data++; gpanel_send_data(color >> 8); gpanel_send_data(color); } gpanel_cs_idle(); } /* * Draw a glyph of one symbol. */ void ili9341_draw_glyph(const struct gpanel_font_t *font, int color, int background, int x, int y, int width, const unsigned short *bits) { int h, w, c; unsigned bitmask = 0; if (x + width > gpanel_width || y + font->height > gpanel_height) return; if (background >= 0) { /* * Clear background. */ gpanel_cs_active(); set_window(x, y, x + width - 1, y + font->height - 1); /* Loop on each glyph row. */ for (h=0; hheight; h++) { /* Loop on every pixel in the row (left to right). */ for (w=0; w> 8); gpanel_send_data(c); } } gpanel_cs_idle(); } else { /* * Transparent background. */ /* Loop on each glyph row. */ for (h=0; hheight; h++) { /* Loop on every pixel in the row (left to right). */ for (w=0; wname = "Ilitek ILI9341"; h->resize = ili9341_resize; h->set_pixel = ili9341_set_pixel; h->fill_rectangle = ili9341_fill_rectangle; h->draw_image = ili9341_draw_image; h->draw_glyph = ili9341_draw_glyph; } ================================================ FILE: sys/arch/pic32/dev/gpanel-spi.c ================================================ /* * Generic TFT LCD driver with SPI interface. * Supported chips: ILI9341. * * Copyright (C) 2015 Serge Vakulenko * * Permission to use, copy, modify, and distribute this software * and its documentation for any purpose and without fee is hereby * granted, provided that the above copyright notice appear in all * copies and that both that the copyright notice and this * permission notice and warranty disclaimer appear in supporting * documentation, and that the name of the author not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * * The author disclaim all warranties with regard to this * software, including all implied warranties of merchantability * and fitness. In no event shall the author be liable for any * special, indirect or consequential damages or any damages * whatsoever resulting from loss of use, data or profits, whether * in an action of contract, negligence or other tortious action, * arising out of or in connection with the use or performance of * this software. */ #include #include #include #include #include #include #include #include #include #include #define SGPANEL_KHZ 10000 /* clock 10 MHz */ /* * Descriptor for access to the hardware-level driver. */ static struct gpanel_hw hw; /* * Cursor position for text output. */ static int _col, _row; /* * ID of the LCD controller chip. */ static int _chip_id; /* * Data/command signal pin. */ static int _dc; static int _last_dc = -1; /* last DC value */ static struct spiio _spiio; /* * Display size. */ int gpanel_width, gpanel_height; /* * Control /CS signal. */ void gpanel_cs_active() { spi_select(&_spiio); } void gpanel_cs_idle() { spi_deselect(&_spiio); } /* * Send a command to the SPI bus. */ int gpanel_send_command(int value) { if (_last_dc != 0) { gpio_clr(_dc); _last_dc = 0; } return spi_transfer(&_spiio, value); } /* * Send data to the SPI bus. */ int gpanel_send_data(int value) { if (_last_dc != 1) { gpio_set(_dc); _last_dc = 1; } return spi_transfer(&_spiio, value); } /* * Draw a line. */ static void gpanel_draw_line(int x0, int y0, int x1, int y1, int color) { int dx, dy, stepx, stepy, fraction; if (x0 == x1 || y0 == y1) { hw.fill_rectangle(x0, y0, x1, y1, color); return; } /* Use Bresenham's line algorithm. */ dy = y1 - y0; if (dy < 0) { dy = -dy; stepy = -1; } else { stepy = 1; } dx = x1 - x0; if (dx < 0) { dx = -dx; stepx = -1; } else { stepx = 1; } dy <<= 1; /* dy is now 2*dy */ dx <<= 1; /* dx is now 2*dx */ hw.set_pixel(x0, y0, color); if (dx > dy) { fraction = dy - (dx >> 1); /* same as 2*dy - dx */ while (x0 != x1) { if (fraction >= 0) { y0 += stepy; fraction -= dx; /* same as fraction -= 2*dx */ } x0 += stepx; fraction += dy; /* same as fraction -= 2*dy */ hw.set_pixel(x0, y0, color); } } else { fraction = dx - (dy >> 1); while (y0 != y1) { if (fraction >= 0) { x0 += stepx; fraction -= dy; } y0 += stepy; fraction += dx; hw.set_pixel(x0, y0, color); } } } /* * Draw a rectangular frame. */ static void gpanel_draw_frame(int x0, int y0, int x1, int y1, int color) { hw.fill_rectangle(x0, y0, x1, y0, color); hw.fill_rectangle(x0, y1, x1, y1, color); hw.fill_rectangle(x0, y0, x0, y1, color); hw.fill_rectangle(x1, y0, x1, y1, color); } /* * Draw a circle. */ static void gpanel_draw_circle(int x0, int y0, int radius, int color) { int f = 1 - radius; int ddF_x = 0; int ddF_y = -2 * radius; int x = 0; int y = radius; hw.set_pixel(x0, y0 + radius, color); hw.set_pixel(x0, y0 - radius, color); hw.set_pixel(x0 + radius, y0, color); hw.set_pixel(x0 - radius, y0, color); while (x < y) { if (f >= 0) { y--; ddF_y += 2; f += ddF_y; } x++; ddF_x += 2; f += ddF_x + 1; hw.set_pixel(x0 + x, y0 + y, color); hw.set_pixel(x0 - x, y0 + y, color); hw.set_pixel(x0 + x, y0 - y, color); hw.set_pixel(x0 - x, y0 - y, color); hw.set_pixel(x0 + y, y0 + x, color); hw.set_pixel(x0 - y, y0 + x, color); hw.set_pixel(x0 + y, y0 - x, color); hw.set_pixel(x0 - y, y0 - x, color); } } /* * Draw a character from a specified font. */ static void gpanel_draw_char(const struct gpanel_font_t *font, int color, int background, int sym) { unsigned cindex, width; const unsigned short *bits; switch (sym) { case '\n': /* goto next line */ _row += font->height; _col = 0; if (_row > gpanel_height - font->height) _row = 0; return; case '\r': /* carriage return - go to begin of line */ _col = 0; return; case '\t': /* tab replaced by space */ sym = ' '; break; } if (sym < font->firstchar || sym >= font->firstchar + font->size) sym = font->defaultchar; cindex = sym - font->firstchar; /* Get font bitmap depending on fixed pitch or not. */ if (font->width) { /* Proportional font. */ width = font->width[cindex]; } else { /* Fixed width font. */ width = font->maxwidth; } if (font->offset) { bits = font->bits + font->offset[cindex]; } else { bits = font->bits + cindex * font->height; } /* Draw a character. */ hw.draw_glyph(font, color, background, _col, _row, width, bits); _col += width; } /* * Draw a string of characters. * TODO: Decode UTF-8. */ static void gpanel_draw_text(const struct gpanel_font_t *font, int color, int background, int x, int y, const char *text) { int sym; _col = x; _row = y; for (;;) { sym = *text++; if (! sym) break; gpanel_draw_char(font, color, background, sym); } } int gpanel_open(dev_t dev, int flag, int mode) { if (minor(dev) != 0) return ENODEV; return 0; } int gpanel_close(dev_t dev, int flag, int mode) { return 0; } int gpanel_read(dev_t dev, struct uio *uio, int flag) { return ENODEV; } int gpanel_write(dev_t dev, struct uio *uio, int flag) { return ENODEV; } /* * TODO: check whether user pointers are valid. */ int gpanel_ioctl(dev_t dev, register u_int cmd, caddr_t addr, int flag) { switch (cmd) { /* * Clear the whole screen with a given color. */ case GPANEL_CLEAR: { struct gpanel_clear_t *param = (struct gpanel_clear_t*) addr; if (hw.resize != 0) hw.resize(&hw, param->xsize, param->ysize); hw.fill_rectangle(0, 0, gpanel_width - 1, gpanel_height - 1, param->color); param->xsize = gpanel_width; param->ysize = gpanel_height; break; } /* * Draw a single pixel. */ case GPANEL_PIXEL: { struct gpanel_pixel_t *param = (struct gpanel_pixel_t*) addr; hw.set_pixel(param->x, param->y, param->color); break; } /* * Draw a line. */ case GPANEL_LINE: { struct gpanel_line_t *param = (struct gpanel_line_t*) addr; gpanel_draw_line(param->x0, param->y0, param->x1, param->y1, param->color); break; } /* * Draw a rectangle frame. */ case GPANEL_RECT: { struct gpanel_rect_t *param = (struct gpanel_rect_t*) addr; gpanel_draw_frame(param->x0, param->y0, param->x1, param->y1, param->color); break; } /* * Fill a rectangle with color. */ case GPANEL_FILL: { struct gpanel_rect_t *param = (struct gpanel_rect_t*) addr; hw.fill_rectangle(param->x0, param->y0, param->x1, param->y1, param->color); break; } /* * Draw a circle. */ case GPANEL_CIRCLE: { struct gpanel_circle_t *param = (struct gpanel_circle_t*) addr; gpanel_draw_circle(param->x, param->y, param->radius, param->color); break; } /* * Fill a rectangular area with the user-supplied data. */ case GPANEL_IMAGE: { struct gpanel_image_t *param = (struct gpanel_image_t*) addr; hw.draw_image(param->x, param->y, param->width, param->height, param->image); break; } /* * Draw a character. */ case GPANEL_CHAR: { struct gpanel_char_t *param = (struct gpanel_char_t*) addr; _col = param->x; _row = param->y; gpanel_draw_char(param->font, param->color, param->background, param->sym); break; } /* * Draw a string of characters. */ case GPANEL_TEXT: { struct gpanel_text_t *param = (struct gpanel_text_t*) addr; gpanel_draw_text(param->font, param->color, param->background, param->x, param->y, param->text); break; } } return 0; } /* * Draw a BSD logo on the screen. */ static void draw_logo() { #define K 7 #define COLOR_B 0xf81f #define COLOR_S 0x07ff #define COLOR_D 0xffe0 int x = gpanel_width/2 - 17*K; int y = gpanel_height/2 + 11*K; hw.fill_rectangle(0, 0, gpanel_width - 1, gpanel_height - 1, 0); /* B */ gpanel_draw_line( 0*K+x, y- 0*K, 0*K+x, y-11*K, COLOR_B); gpanel_draw_line( 0*K+x, y-11*K, 0*K+x, y-22*K, COLOR_B); gpanel_draw_line( 0*K+x, y-22*K, 10*K+x, y-19*K, COLOR_B); gpanel_draw_line(10*K+x, y-19*K, 0*K+x, y-11*K, COLOR_B); gpanel_draw_line( 0*K+x, y-11*K, 10*K+x, y- 8*K, COLOR_B); gpanel_draw_line(10*K+x, y- 8*K, 0*K+x, y- 0*K, COLOR_B); /* S */ gpanel_draw_line(22*K+x, y-22*K, 12*K+x, y-19*K, COLOR_S); gpanel_draw_line(12*K+x, y-19*K, 22*K+x, y- 8*K, COLOR_S); gpanel_draw_line(22*K+x, y- 8*K, 12*K+x, y- 0*K, COLOR_S); /* D */ gpanel_draw_line(24*K+x, y-22*K, 24*K+x, y- 0*K, COLOR_D); gpanel_draw_line(24*K+x, y-22*K, 34*K+x, y-19*K, COLOR_D); gpanel_draw_line(34*K+x, y-19*K, 34*K+x, y- 8*K, COLOR_D); gpanel_draw_line(34*K+x, y- 8*K, 24*K+x, y- 0*K, COLOR_D); } /* * Read the chip ID register. */ static int read_id() { int id; /* Read ID4 from register #D3. * Use undocumented command #D9 to get access to ID4. */ gpanel_cs_active(); gpanel_send_command(0xD9); gpanel_send_data(0x11); gpanel_send_command(0xD3); id = gpanel_send_data(0xff) << 16; gpanel_send_command(0xD9); gpanel_send_data(0x12); gpanel_send_command(0xD3); id |= gpanel_send_data(0xff) << 8; gpanel_send_command(0xD9); gpanel_send_data(0x13); gpanel_send_command(0xD3); id |= gpanel_send_data(0xff); gpanel_cs_idle(); return id; } /* * Detect the type of the LCD controller, and initialize it. * Return true if found and initialized ok. */ static int probe(config) struct conf_device *config; { int cs; struct spiio *io = &_spiio; /* Only one device is allowed. */ if (config->dev_unit > 0) return 0; cs = config->dev_pins[0]; _dc = config->dev_pins[1]; printf("sgpanel: port SPI%d, pins cs=R%c%d/dc=R%c%d\n", config->dev_ctlr, gpio_portname(cs), gpio_pinno(cs), gpio_portname(_dc), gpio_pinno(_dc)); if (spi_setup(io, config->dev_ctlr, cs) != 0) { printf("sgpanel: cannot open SPI%u port\n", config->dev_ctlr); return 0; } spi_brg(io, SGPANEL_KHZ); spi_set(io, PIC32_SPICON_CKE); gpio_set_output(_dc); /* Identify the LCD controller chip. */ _chip_id = read_id(); switch (_chip_id) { default: /* Disable outputs. */ gpio_set_input(_dc); gpio_set_input(cs); printf("gpanel0: Unknown chip ID = 0x%04x\n", _chip_id); return 0; case 0x009341: /* Ilitek ILI9341. */ ili9341_init_display(&hw); break; } printf("gpanel0: <%s> display %ux%u\n", hw.name, gpanel_width, gpanel_height); draw_logo(); return 1; } struct driver sgpaneldriver = { "sgpanel", probe, }; ================================================ FILE: sys/arch/pic32/dev/gpanel-st7781.c ================================================ /* * Display driver for ST7781 LCD controller. * * Based on code provided by Smoke And Wires * https://github.com/Smoke-And-Wires/TFT-Shield-Example-Code * * Copyright (C) 2015 Serge Vakulenko * * Permission to use, copy, modify, and distribute this software * and its documentation for any purpose and without fee is hereby * granted, provided that the above copyright notice appear in all * copies and that both that the copyright notice and this * permission notice and warranty disclaimer appear in supporting * documentation, and that the name of the author not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * * The author disclaim all warranties with regard to this * software, including all implied warranties of merchantability * and fitness. In no event shall the author be liable for any * special, indirect or consequential damages or any damages * whatsoever resulting from loss of use, data or profits, whether * in an action of contract, negligence or other tortious action, * arising out of or in connection with the use or performance of * this software. */ #include #include /* * Display orientation. */ typedef enum { PORTRAIT, LANDSCAPE, PORTRAIT_UPSIDE_DOWN, LANDSCAPE_UPSIDE_DOWN, } orient_t; static orient_t orientation; /* * ST7781 registers. */ #define ST7781_Driver_ID_Code_Read 0x00 #define ST7781_Driver_Output_Control 0x01 #define ST7781_LCD_Driving_Wave_Control 0x02 #define ST7781_Entry_Mode 0x03 #define ST7781_Resize_Control 0x04 #define ST7781_Display_Control_1 0x07 #define ST7781_Display_control_2 0x08 #define ST7781_Display_Control_3 0x09 #define ST7781_Display_Control_4 0x0A #define ST7781_Frame_Marker_Position 0x0D #define ST7781_Power_Control_1 0x10 #define ST7781_Power_Control_2 0x11 #define ST7781_Power_Control_3 0x12 #define ST7781_Power_Control_4 0x13 #define ST7781_DRAM_Horizontal_Address_Set 0x20 #define ST7781_DRAM_Vertical_Address_Set 0x21 #define ST7781_Write_Data_to_DRAM 0x22 #define ST7781_Read_Data_from_DRAM 0x22 #define ST7781_VCOMH_Control 0x29 #define ST7781_Frame_Rate_and_Color_Control 0x2B #define ST7781_Gamma_Control_1 0x30 #define ST7781_Gamma_Control_2 0x31 #define ST7781_Gamma_Control_3 0x32 #define ST7781_Gamma_Control_4 0x35 #define ST7781_Gamma_Control_5 0x36 #define ST7781_Gamma_Control_6 0x37 #define ST7781_Gamma_Control_7 0x38 #define ST7781_Gamma_Control_8 0x39 #define ST7781_Gamma_Control_9 0x3C #define ST7781_Gamma_Control_10 0x3D #define ST7781_Horizontal_Address_Start_Position 0x50 #define ST7781_Horizontal_Address_End_Position 0x51 #define ST7781_Vertical_Address_Start_Position 0x52 #define ST7781_Vertical_Address_End_Position 0x53 #define ST7781_Gate_Scan_Control_1 0x60 #define ST7781_Gate_Scan_Control_2 0x61 #define ST7781_Partial_Image_1_Display_Position 0x80 #define ST7781_Partial_Image_1_Start_Address 0x81 #define ST7781_Partial_Image_1_End_Address 0x82 #define ST7781_Partial_Image_2_Display_Position 0x83 #define ST7781_Partial_Image_2_Start_Address 0x84 #define ST7781_Partial_Image_2_End_Address 0x85 #define ST7781_Panel_Interface_Control_1 0x90 #define ST7781_Panel_Interface_Control_2 0x92 #define ST7781_EEPROM_ID_Code 0xD2 #define ST7781_EEPROM_Control_Status 0xD9 #define ST7781_EEPROM_Wite_Command 0xDF #define ST7781_EEPROM_Enable 0xFA #define ST7781_EEPROM_VCOM_Offset 0xFE #define ST7781_FAh_FEh_Enable 0xFF /* Swap values of two integer variables. */ #define swapi(x,y) { int _t = x; x = y; y = _t; } /* * Write a 16-bit value to the ST7781 register. */ static void write_reg(unsigned reg, unsigned value) { gpanel_rs_command(); gpanel_write_byte(reg >> 8); gpanel_write_byte(reg); gpanel_rs_data(); gpanel_write_byte(value >> 8); gpanel_write_byte(value); } static void set_window(int x0, int y0, int x1, int y1) { gpanel_cs_active(); /* Check rotation, move pixel around if necessary. */ switch (orientation) { case PORTRAIT: break; case LANDSCAPE: write_reg(ST7781_Entry_Mode, 0x1028); swapi(x0, y0); swapi(x1, y1); x0 = 240 - x0 - 1; x1 = 240 - x1 - 1; swapi(x0, x1); break; case PORTRAIT_UPSIDE_DOWN: write_reg(ST7781_Entry_Mode, 0x1000); x0 = 240 - x0 - 1; x1 = 240 - x1 - 1; swapi(x0, x1); y0 = 320 - y0 - 1; y1 = 320 - y1 - 1; swapi(y0, y1); break; case LANDSCAPE_UPSIDE_DOWN: write_reg(ST7781_Entry_Mode, 0x1018); swapi(x0, y0); swapi(x1, y1); y0 = 320 - y0 - 1; y1 = 320 - y1 - 1; swapi(y0, y1); break; } /* Set address window. */ write_reg(ST7781_Horizontal_Address_Start_Position, x0); write_reg(ST7781_Horizontal_Address_End_Position, x1); write_reg(ST7781_Vertical_Address_Start_Position, y0); write_reg(ST7781_Vertical_Address_End_Position, y1); /* Set address counter to top left. */ write_reg(ST7781_DRAM_Horizontal_Address_Set, x0); write_reg(ST7781_DRAM_Vertical_Address_Set, y0); gpanel_cs_idle(); } static void clear_window() { gpanel_cs_active(); write_reg(ST7781_Entry_Mode, 0x1030); write_reg(ST7781_Horizontal_Address_Start_Position, 0); write_reg(ST7781_Horizontal_Address_End_Position, 240-1); write_reg(ST7781_Vertical_Address_Start_Position, 0); write_reg(ST7781_Vertical_Address_End_Position, 320-1); gpanel_cs_idle(); } /* * Draw a pixel. */ static void st7781_set_pixel(int x, int y, int color) { if (x < 0 || x >= gpanel_width || y < 0 || y >= gpanel_height) return; /* Check rotation, move pixel around if necessary. */ switch (orientation) { case PORTRAIT: break; case LANDSCAPE: swapi(x, y); x = 240 - x - 1; break; case PORTRAIT_UPSIDE_DOWN: x = 240 - x - 1; y = 320 - y - 1; break; case LANDSCAPE_UPSIDE_DOWN: swapi(x, y); y = 320 - y - 1; break; } gpanel_cs_active(); write_reg(ST7781_DRAM_Horizontal_Address_Set, x); write_reg(ST7781_DRAM_Vertical_Address_Set, y); write_reg(ST7781_Write_Data_to_DRAM, color); gpanel_cs_idle(); } /* * Fast block fill operation. * Requires set_window() has previously been called to set * the fill bounds. * 'npixels' is inclusive, MUST be >= 1. */ static void flood(int color, int npixels) { unsigned blocks, i; unsigned hi = color >> 8, lo = color; gpanel_cs_active(); gpanel_rs_command(); gpanel_write_byte(0x00); /* High address byte */ gpanel_write_byte(ST7781_Write_Data_to_DRAM); /* Write first pixel normally, decrement counter by 1. */ gpanel_rs_data(); gpanel_write_byte(hi); gpanel_write_byte(lo); npixels--; /* 64 pixels/block. */ blocks = npixels >> 6; if (hi == lo) { /* High and low bytes are identical. Leave prior data * on the port(s) and just toggle the write strobe. */ while (blocks--) { /* 64 pixels/block / 4 pixels/pass. */ for (i = 16; i > 0; i--) { /* 2 bytes/pixel x 4 pixels. */ gpanel_wr_strobe(); gpanel_wr_strobe(); gpanel_wr_strobe(); gpanel_wr_strobe(); gpanel_wr_strobe(); gpanel_wr_strobe(); gpanel_wr_strobe(); gpanel_wr_strobe(); } } /* Fill any remaining pixels (1 to 64). */ for (i = npixels & 63; i > 0; i--) { gpanel_wr_strobe(); gpanel_wr_strobe(); } } else { while (blocks--) { /* 64 pixels/block / 4 pixels/pass. */ for (i = 16; i > 0; i--) { gpanel_write_byte(hi); gpanel_write_byte(lo); gpanel_write_byte(hi); gpanel_write_byte(lo); gpanel_write_byte(hi); gpanel_write_byte(lo); gpanel_write_byte(hi); gpanel_write_byte(lo); } } for (i = npixels & 63; i > 0; i--) { gpanel_write_byte(hi); gpanel_write_byte(lo); } } gpanel_cs_idle(); } /* * Fill a rectangle with specified color. */ static void st7781_fill_rectangle(int x0, int y0, int x1, int y1, int color) { if (x0 < 0) x0 = 0; if (y0 < 0) x0 = 0; if (x1 < 0) x1 = 0; if (y1 < 0) x1 = 0; if (x0 >= gpanel_width) x0 = gpanel_width-1; if (x1 >= gpanel_width) x1 = gpanel_width-1; if (y0 >= gpanel_height) y0 = gpanel_height-1; if (y1 >= gpanel_height) y1 = gpanel_height-1; if (x1 < x0) { int t = x0; x0 = x1; x1 = t; } if (y1 < y0) { int t = y0; y0 = y1; y1 = t; } set_window(x0, y0, x1, y1); flood(color, (x1 - x0 + 1) * (y1 - y0 + 1)); clear_window(); } /* * Fill a rectangle with user data. */ static void st7781_draw_image(int x, int y, int width, int height, const unsigned short *data) { unsigned cnt = width * height; int color; set_window(x, y, x + width - 1, y + height - 1); gpanel_cs_active(); gpanel_rs_command(); gpanel_write_byte(0x00); /* High address byte */ gpanel_write_byte(ST7781_Write_Data_to_DRAM); gpanel_rs_data(); while (cnt--) { color = *data++; gpanel_write_byte(color >> 8); gpanel_write_byte(color); } gpanel_cs_idle(); clear_window(); } /* * Draw a glyph of one symbol. */ static void st7781_draw_glyph(const struct gpanel_font_t *font, int color, int background, int x, int y, int width, const unsigned short *bits) { int h, w, c; unsigned bitmask = 0; if (x + width > gpanel_width || y + font->height > gpanel_height) return; if (background >= 0) { /* * Clear background. */ set_window(x, y, x + width - 1, y + font->height - 1); gpanel_cs_active(); gpanel_rs_command(); gpanel_write_byte(0x00); /* High address byte */ gpanel_write_byte(ST7781_Write_Data_to_DRAM); gpanel_rs_data(); /* Loop on each glyph row. */ for (h=0; hheight; h++) { /* Loop on every pixel in the row (left to right). */ for (w=0; w> 8); gpanel_write_byte(c); } } gpanel_cs_idle(); clear_window(); } else { /* * Transparent background. */ /* Loop on each glyph row. */ for (h=0; hheight; h++) { /* Loop on every pixel in the row (left to right). */ for (w=0; w height) set_rotation(LANDSCAPE); else if (width < height) set_rotation(PORTRAIT); gpanel_cs_idle(); } /* * Initialize the LCD controller. * Fill the gpanel_hw descriptor. */ void st7781_init_display(struct gpanel_hw *h) { /* Initialization of LCD controller. */ gpanel_cs_active(); write_reg(ST7781_Driver_Output_Control, 0x0100); write_reg(ST7781_LCD_Driving_Wave_Control, 0x0700); write_reg(ST7781_Display_control_2, 0x0302); write_reg(ST7781_Display_Control_3, 0x0000); write_reg(ST7781_Display_Control_4, 0x0008); /* Power control registers. */ write_reg(ST7781_Power_Control_1, 0x0790); write_reg(ST7781_Power_Control_2, 0x0005); write_reg(ST7781_Power_Control_3, 0x0000); write_reg(ST7781_Power_Control_4, 0x0000); /* Power supply startup 1 settings. */ write_reg(ST7781_Power_Control_1, 0x12B0); write_reg(ST7781_Power_Control_2, 0x0007); /* Power supply startup 2 settings. */ write_reg(ST7781_Power_Control_3, 0x008C); write_reg(ST7781_Power_Control_4, 0x1700); write_reg(ST7781_VCOMH_Control, 0x0022); /* Gamma cluster settings. */ write_reg(ST7781_Gamma_Control_1, 0x0000); write_reg(ST7781_Gamma_Control_2, 0x0505); write_reg(ST7781_Gamma_Control_3, 0x0205); write_reg(ST7781_Gamma_Control_4, 0x0206); write_reg(ST7781_Gamma_Control_5, 0x0408); write_reg(ST7781_Gamma_Control_6, 0x0000); write_reg(ST7781_Gamma_Control_7, 0x0504); write_reg(ST7781_Gamma_Control_8, 0x0206); write_reg(ST7781_Gamma_Control_9, 0x0206); write_reg(ST7781_Gamma_Control_10, 0x0408); /* Frame rate settings. */ write_reg(ST7781_Gate_Scan_Control_1, 0xA700); write_reg(ST7781_Gate_Scan_Control_2, 0x0001); write_reg(ST7781_Panel_Interface_Control_1, 0x0033); // RTNI setting /* Display on. */ write_reg(ST7781_Display_Control_1, 0x0133); clear_window(); /* Screen orientation. */ set_rotation(LANDSCAPE); /* Fill the gpanel_hw descriptor. */ h->name = "Sitronix ST7781"; h->resize = st7781_resize; h->set_pixel = st7781_set_pixel; h->fill_rectangle = st7781_fill_rectangle; h->draw_image = st7781_draw_image; h->draw_glyph = st7781_draw_glyph; } ================================================ FILE: sys/arch/pic32/dev/gpanel.c ================================================ /* * Generic TFT LCD driver for PIC32. * Supported chips: ST7781, NT35702, ILI9341. * * Copyright (C) 2015 Serge Vakulenko * * Permission to use, copy, modify, and distribute this software * and its documentation for any purpose and without fee is hereby * granted, provided that the above copyright notice appear in all * copies and that both that the copyright notice and this * permission notice and warranty disclaimer appear in supporting * documentation, and that the name of the author not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * * The author disclaim all warranties with regard to this * software, including all implied warranties of merchantability * and fitness. In no event shall the author be liable for any * special, indirect or consequential damages or any damages * whatsoever resulting from loss of use, data or profits, whether * in an action of contract, negligence or other tortious action, * arising out of or in connection with the use or performance of * this software. */ #include #include #include #include #include #include #include #include #include /* * Descriptor for access to the hardware-level driver. */ static struct gpanel_hw hw; /* * Cursor position for text output. */ static int _col, _row; /* * ID of the LCD controller chip. */ static int _chip_id; /* * Display size. */ int gpanel_width, gpanel_height; /* * Delay for 100 nanoseconds. * Needed to match the /WR and /RD timing requirements. */ #if CPU_KHZ <= 10000 # define delay100ns() /* empty */ #elif CPU_KHZ <= 20000 # define delay100ns() asm volatile("nop") #elif CPU_KHZ <= 30000 # define delay100ns() asm volatile("nop; nop") #elif CPU_KHZ <= 40000 # define delay100ns() asm volatile("nop; nop; nop") #elif CPU_KHZ <= 50000 # define delay100ns() asm volatile("nop; nop; nop; nop") #elif CPU_KHZ <= 60000 # define delay100ns() asm volatile("nop; nop; nop; nop; nop") #elif CPU_KHZ <= 70000 # define delay100ns() asm volatile("nop; nop; nop; nop; nop; nop") #else # define delay100ns() asm volatile("nop; nop; nop; nop; nop; nop; nop; nop") #endif /* * Signal mappings: * /RESET - reset and initialize the chip. * /CS - chip select when low. * /RD - read operation enable. * /WR - write operation enable. * RS - command or data mode selection. * D0-D7 - data bus, bidirectional. */ #define RST_IDLE() LAT_SET(LCD_RST_PORT) = 1<> 8); /* Need 2 bytes of address for ST7781 */ gpanel_write_byte(reg); gpanel_read_dir(); /* Switch data bus to input */ RS_DATA(); value = gpanel_read_byte() << 8; value |= gpanel_read_byte(); gpanel_write_dir(); /* Restore data bus as output */ CS_IDLE(); return value; } /* * Read a 32-bit value from the specified chip register. */ static int read_reg32(int reg) { unsigned value; CS_ACTIVE(); RS_COMMAND(); gpanel_write_byte(reg); gpanel_read_dir(); /* Switch data bus to input */ RS_DATA(); value = gpanel_read_byte() << 24; value |= gpanel_read_byte() << 16; value |= gpanel_read_byte() << 8; value |= gpanel_read_byte(); gpanel_write_dir(); /* Restore data bus as output */ CS_IDLE(); return value; } /* * Draw a line. */ static void gpanel_draw_line(int x0, int y0, int x1, int y1, int color) { int dx, dy, stepx, stepy, fraction; if (x0 == x1 || y0 == y1) { hw.fill_rectangle(x0, y0, x1, y1, color); return; } /* Use Bresenham's line algorithm. */ dy = y1 - y0; if (dy < 0) { dy = -dy; stepy = -1; } else { stepy = 1; } dx = x1 - x0; if (dx < 0) { dx = -dx; stepx = -1; } else { stepx = 1; } dy <<= 1; /* dy is now 2*dy */ dx <<= 1; /* dx is now 2*dx */ hw.set_pixel(x0, y0, color); if (dx > dy) { fraction = dy - (dx >> 1); /* same as 2*dy - dx */ while (x0 != x1) { if (fraction >= 0) { y0 += stepy; fraction -= dx; /* same as fraction -= 2*dx */ } x0 += stepx; fraction += dy; /* same as fraction -= 2*dy */ hw.set_pixel(x0, y0, color); } } else { fraction = dx - (dy >> 1); while (y0 != y1) { if (fraction >= 0) { x0 += stepx; fraction -= dy; } y0 += stepy; fraction += dx; hw.set_pixel(x0, y0, color); } } } /* * Draw a rectangular frame. */ static void gpanel_draw_frame(int x0, int y0, int x1, int y1, int color) { hw.fill_rectangle(x0, y0, x1, y0, color); hw.fill_rectangle(x0, y1, x1, y1, color); hw.fill_rectangle(x0, y0, x0, y1, color); hw.fill_rectangle(x1, y0, x1, y1, color); } /* * Draw a circle. */ static void gpanel_draw_circle(int x0, int y0, int radius, int color) { int f = 1 - radius; int ddF_x = 0; int ddF_y = -2 * radius; int x = 0; int y = radius; hw.set_pixel(x0, y0 + radius, color); hw.set_pixel(x0, y0 - radius, color); hw.set_pixel(x0 + radius, y0, color); hw.set_pixel(x0 - radius, y0, color); while (x < y) { if (f >= 0) { y--; ddF_y += 2; f += ddF_y; } x++; ddF_x += 2; f += ddF_x + 1; hw.set_pixel(x0 + x, y0 + y, color); hw.set_pixel(x0 - x, y0 + y, color); hw.set_pixel(x0 + x, y0 - y, color); hw.set_pixel(x0 - x, y0 - y, color); hw.set_pixel(x0 + y, y0 + x, color); hw.set_pixel(x0 - y, y0 + x, color); hw.set_pixel(x0 + y, y0 - x, color); hw.set_pixel(x0 - y, y0 - x, color); } } /* * Draw a character from a specified font. */ static void gpanel_draw_char(const struct gpanel_font_t *font, int color, int background, int sym) { unsigned cindex, width; const unsigned short *bits; switch (sym) { case '\n': /* goto next line */ _row += font->height; _col = 0; if (_row > gpanel_height - font->height) _row = 0; return; case '\r': /* carriage return - go to begin of line */ _col = 0; return; case '\t': /* tab replaced by space */ sym = ' '; break; } if (sym < font->firstchar || sym >= font->firstchar + font->size) sym = font->defaultchar; cindex = sym - font->firstchar; /* Get font bitmap depending on fixed pitch or not. */ if (font->width) { /* Proportional font. */ width = font->width[cindex]; } else { /* Fixed width font. */ width = font->maxwidth; } if (font->offset) { bits = font->bits + font->offset[cindex]; } else { bits = font->bits + cindex * font->height; } /* Draw a character. */ hw.draw_glyph(font, color, background, _col, _row, width, bits); _col += width; } /* * Draw a string of characters. * TODO: Decode UTF-8. */ static void gpanel_draw_text(const struct gpanel_font_t *font, int color, int background, int x, int y, const char *text) { int sym; _col = x; _row = y; for (;;) { sym = *text++; if (! sym) break; gpanel_draw_char(font, color, background, sym); } } int gpanel_open(dev_t dev, int flag, int mode) { if (minor(dev) != 0) return ENODEV; return 0; } int gpanel_close(dev_t dev, int flag, int mode) { return 0; } int gpanel_read(dev_t dev, struct uio *uio, int flag) { return ENODEV; } int gpanel_write(dev_t dev, struct uio *uio, int flag) { return ENODEV; } /* * TODO: check whether user pointers are valid. */ int gpanel_ioctl(dev_t dev, register u_int cmd, caddr_t addr, int flag) { switch (cmd) { /* * Clear the whole screen with a given color. */ case GPANEL_CLEAR: { struct gpanel_clear_t *param = (struct gpanel_clear_t*) addr; if (hw.resize != 0) hw.resize(&hw, param->xsize, param->ysize); hw.fill_rectangle(0, 0, gpanel_width - 1, gpanel_height - 1, param->color); param->xsize = gpanel_width; param->ysize = gpanel_height; break; } /* * Draw a single pixel. */ case GPANEL_PIXEL: { struct gpanel_pixel_t *param = (struct gpanel_pixel_t*) addr; hw.set_pixel(param->x, param->y, param->color); break; } /* * Draw a line. */ case GPANEL_LINE: { struct gpanel_line_t *param = (struct gpanel_line_t*) addr; gpanel_draw_line(param->x0, param->y0, param->x1, param->y1, param->color); break; } /* * Draw a rectangle frame. */ case GPANEL_RECT: { struct gpanel_rect_t *param = (struct gpanel_rect_t*) addr; gpanel_draw_frame(param->x0, param->y0, param->x1, param->y1, param->color); break; } /* * Fill a rectangle with color. */ case GPANEL_FILL: { struct gpanel_rect_t *param = (struct gpanel_rect_t*) addr; hw.fill_rectangle(param->x0, param->y0, param->x1, param->y1, param->color); break; } /* * Draw a circle. */ case GPANEL_CIRCLE: { struct gpanel_circle_t *param = (struct gpanel_circle_t*) addr; gpanel_draw_circle(param->x, param->y, param->radius, param->color); break; } /* * Fill a rectangular area with the user-supplied data. */ case GPANEL_IMAGE: { struct gpanel_image_t *param = (struct gpanel_image_t*) addr; hw.draw_image(param->x, param->y, param->width, param->height, param->image); break; } /* * Draw a character. */ case GPANEL_CHAR: { struct gpanel_char_t *param = (struct gpanel_char_t*) addr; _col = param->x; _row = param->y; gpanel_draw_char(param->font, param->color, param->background, param->sym); break; } /* * Draw a string of characters. */ case GPANEL_TEXT: { struct gpanel_text_t *param = (struct gpanel_text_t*) addr; gpanel_draw_text(param->font, param->color, param->background, param->x, param->y, param->text); break; } } return 0; } /* * Draw a BSD logo on the screen. */ static void draw_logo() { #define K 7 #define COLOR_B 0xf81f #define COLOR_S 0x07ff #define COLOR_D 0xffe0 int x = gpanel_width/2 - 17*K; int y = gpanel_height/2 + 11*K; hw.fill_rectangle(0, 0, gpanel_width - 1, gpanel_height - 1, 0); /* B */ gpanel_draw_line( 0*K+x, y- 0*K, 0*K+x, y-11*K, COLOR_B); gpanel_draw_line( 0*K+x, y-11*K, 0*K+x, y-22*K, COLOR_B); gpanel_draw_line( 0*K+x, y-22*K, 10*K+x, y-19*K, COLOR_B); gpanel_draw_line(10*K+x, y-19*K, 0*K+x, y-11*K, COLOR_B); gpanel_draw_line( 0*K+x, y-11*K, 10*K+x, y- 8*K, COLOR_B); gpanel_draw_line(10*K+x, y- 8*K, 0*K+x, y- 0*K, COLOR_B); /* S */ gpanel_draw_line(22*K+x, y-22*K, 12*K+x, y-19*K, COLOR_S); gpanel_draw_line(12*K+x, y-19*K, 22*K+x, y- 8*K, COLOR_S); gpanel_draw_line(22*K+x, y- 8*K, 12*K+x, y- 0*K, COLOR_S); /* D */ gpanel_draw_line(24*K+x, y-22*K, 24*K+x, y- 0*K, COLOR_D); gpanel_draw_line(24*K+x, y-22*K, 34*K+x, y-19*K, COLOR_D); gpanel_draw_line(34*K+x, y-19*K, 34*K+x, y- 8*K, COLOR_D); gpanel_draw_line(34*K+x, y- 8*K, 24*K+x, y- 0*K, COLOR_D); } /* * Read the the chip ID register. * Some controllers have a register #0 * programmed with unique chip ID. */ static int read_id() { int id, retry; /* Some controllers have a register #0 * programmed with unique chip ID. */ id = read_reg16(0); if (id != 0) return id; /* Try ID from register #4. */ id = read_reg32(4) & 0xffffff; if (id != 0) return id; /* Try ID from register #D3. * Might need to wait until the register becomes alive after Reset. */ for (retry=0; retry<5; retry++) { id = read_reg32(0xD3) & 0xffffff; if (id != 0) return id; udelay(50000); } return 0; } /* * Detect the type of the LCD controller, and initialize it. * Return true if found and initialized ok. */ static int probe(config) struct conf_device *config; { /* * Set all control bits to high (idle). * Signals are active low. */ CS_IDLE(); WR_IDLE(); RD_IDLE(); RST_IDLE(); /* Enable outputs. */ TRIS_CLR(LCD_CS_PORT) = 1 << LCD_CS_PIN; TRIS_CLR(LCD_RS_PORT) = 1 << LCD_RS_PIN; TRIS_CLR(LCD_WR_PORT) = 1 << LCD_WR_PIN; TRIS_CLR(LCD_RD_PORT) = 1 << LCD_RD_PIN; TRIS_CLR(LCD_RST_PORT) = 1 << LCD_RST_PIN; gpanel_write_dir(); /* Reset the chip. */ RST_ACTIVE(); udelay(1000); RST_IDLE(); udelay(1000); /* Read the the chip ID register. * Some controllers have a register #0 * programmed with unique chip ID. */ _chip_id = read_id(); switch (_chip_id) { default: printf("gpanel0: Unknown chip ID = 0x%04x\n", _chip_id); goto failed; case 0x7783: /* Sitronix ST7781. */ st7781_init_display(&hw); break; case 0x009341: /* Ilitek ILI9341. */ ili9341_init_display(&hw); break; case 0x012200: /* Ilitek ILI9481. */ ili9481_init_display(&hw); break; case 0x388000: /* Novatek NT35702. */ nt35702_init_display(&hw); break; } printf("gpanel0: <%s> display %ux%u\n", hw.name, gpanel_width, gpanel_height); draw_logo(); return 1; failed: /* Disable outputs. */ gpanel_read_dir(); TRIS_SET(LCD_CS_PORT) = 1 << LCD_CS_PIN; TRIS_SET(LCD_RS_PORT) = 1 << LCD_RS_PIN; TRIS_SET(LCD_WR_PORT) = 1 << LCD_WR_PIN; TRIS_SET(LCD_RD_PORT) = 1 << LCD_RD_PIN; TRIS_SET(LCD_RST_PORT) = 1 << LCD_RST_PIN; return 0; } struct driver gpaneldriver = { "gpanel", probe, }; ================================================ FILE: sys/arch/pic32/dev/gpio.c ================================================ /* * GPIO driver for PIC32. * * Copyright (C) 2012 Serge Vakulenko, * * Permission to use, copy, modify, and distribute this software * and its documentation for any purpose and without fee is hereby * granted, provided that the above copyright notice appear in all * copies and that both that the copyright notice and this * permission notice and warranty disclaimer appear in supporting * documentation, and that the name of the author not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * * The author disclaim all warranties with regard to this * software, including all implied warranties of merchantability * and fitness. In no event shall the author be liable for any * special, indirect or consequential damages or any damages * whatsoever resulting from loss of use, data or profits, whether * in an action of contract, negligence or other tortious action, * arising out of or in connection with the use or performance of * this software. */ #include #include #include #include #include #include #include #include /* * Devices: * /dev/porta ... /dev/portg * /dev/confa ... /dev/confg * * Example: * echo ....oiiid....iiii > /dev/confa * echo ....1...0........ > /dev/porta * * Write to /dev/confX: * 'i' - configure the corresponding port pin as an input; * 'o' - configure the corresponding port pin as an output; * 'd' - configure the corresponding port pin as an open-drain output; * 'x' - deconfigure the corresponding port pin; * '.' - no action. * * Write to /dev/portX: * '0' - set output pin low; * '1' - set output pin high; * '+' - invert the value of output pin; * '.' - no action. * * Use ioctl() on any of devices to control pins from the user program. * ioctl(fd, GPIO_PORTA | GPIO_CONFIN, mask) - configure as input * ioctl(fd, GPIO_PORTB | GPIO_CONFOUT,mask) - configure as output * ioctl(fd, GPIO_PORTC | GPIO_CONFOD, mask) - configure as open drain * ioctl(fd, GPIO_PORTD | GPIO_DECONF, mask) - deconfigure * ioctl(fd, GPIO_PORTE | GPIO_STORE, val) - set values of all pins * ioctl(fd, GPIO_PORTF | GPIO_SET, mask) - set to 1 by mask * ioctl(fd, GPIO_PORTG | GPIO_CLEAR, mask) - set to 0 by mask * ioctl(fd, GPIO_PORT(0)| GPIO_INVERT, mask) - invert by mask * val= ioctl(fd, GPIO_PORT(1)| GPIO_POLL, 0) - get input values * * Several operations can be combined in one call. * For example, to toggle pin A2 high thew low, and get value * of all PORTA pins: * val = ioctl(fd, GPIO_PORTA | GPIO_SET | GPIO_CLEAR | GPIO_POLL, 1<<3); */ #define NGPIO 7 /* Ports A, B, C, D, E, F, G */ #define NPINS 16 /* Number of pins per port */ #define MINOR_CONF 0x40 /* Minor mask: /dev/confX */ #define MINOR_UNIT 0x07 /* Minor mask: unit number */ /* * Some pins are actually not available in hardware. * Here are masks of real pins. */ #define MASK(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p) \ (a<<15 | b<<14 | c<<13 | d<<12 | e<<11 | f<<10 | g<<9 | h<<8 | \ i<<7 | j<<6 | k<<5 | l<<4 | m<<3 | n<<2 | o<<1 | p) /* * Mask of configured pins, default empty. */ u_int gpio_confmask [NGPIO]; /* * To enable debug output, comment out the first line, * and uncomment the second line. */ #define PRINTDBG(...) /*empty*/ //#define PRINTDBG printf static void gpio_print (dev, buf) dev_t dev; char *buf; { u_int unit = minor(dev) & MINOR_UNIT; register struct gpioreg *reg = unit + (struct gpioreg*) &TRISA; register u_int mask, conf, tris; register char c; conf = gpio_confmask[unit]; tris = reg->tris; if (minor(dev) & MINOR_CONF) { /* /dev/confX device: port configuration mask */ u_int odc = reg->odc; for (mask=1<<(NPINS-1); mask; mask>>=1) { if (! (conf & mask)) c = '-'; else if (tris & mask) c = 'i'; else c = (odc & mask) ? 'd' : 'o'; *buf++ = c; } } else { /* /dev/portX device: port value mask */ u_int lat = reg->lat; u_int port = reg->port; for (mask=1<<(NPINS-1); mask; mask>>=1) { if (! (conf & mask)) c = '-'; else if (tris & mask) c = (port & mask) ? '1' : '0'; else c = (lat & mask) ? '1' : '0'; *buf++ = c; } } *buf++ = '\n'; *buf = 0; } static void gpio_parse (dev, buf) dev_t dev; char *buf; { u_int unit = minor(dev) & MINOR_UNIT; register struct gpioreg *reg = unit + (struct gpioreg*) &TRISA; register u_int mask; register char c; if (minor(dev) & MINOR_CONF) { /* /dev/confX device: port configuration mask */ for (mask=1<<(NPINS-1); mask; mask>>=1) { c = *buf++; if (c <= ' ' || c > '~') break; if (c == 'x' || c == 'X') { gpio_confmask[unit] &= ~mask; reg->trisset = mask; } else if (c == 'i' || c == 'I') { gpio_confmask[unit] |= mask; reg->trisset = mask; } else if (c == 'o' || c == 'O') { gpio_confmask[unit] |= mask; reg->odcclr = mask; reg->trisclr = mask; } else if (c == 'd' || c == 'D') { gpio_confmask[unit] |= mask; reg->odcset = mask; reg->trisclr = mask; } } } else { /* /dev/portX device: port value mask */ u_int conf = gpio_confmask[unit]; u_int tris = reg->tris; for (mask=1<<(NPINS-1); mask; mask>>=1) { c = *buf++; if (c <= ' ' || c > '~') break; if (! (conf & mask) || (tris & mask)) continue; if (c == '0') reg->latclr = mask; else reg->latset = mask; } } } int gpioopen (dev, flag, mode) dev_t dev; int flag; int mode; { register u_int unit = minor(dev) & MINOR_UNIT; if (unit >= NGPIO) return ENXIO; if (u.u_uid != 0) return EPERM; return 0; } int gpioclose (dev, flag, mode) dev_t dev; int flag; int mode; { return 0; } int gpioread (dev, uio, flag) dev_t dev; struct uio *uio; int flag; { register struct iovec *iov; register u_int cnt = NPINS + 1; char buf [20]; /* I/o size should be large enough. */ iov = uio->uio_iov; if (iov->iov_len < cnt) return EIO; /* Read only cnt bytes. */ if (uio->uio_offset >= cnt) return 0; cnt -= uio->uio_offset; /* Print port status to buffer. */ gpio_print (dev, buf); //PRINTDBG ("gpioread -> %s", buf); bcopy (buf + uio->uio_offset, iov->iov_base, cnt); iov->iov_base += cnt; iov->iov_len -= cnt; uio->uio_resid -= cnt; uio->uio_offset += cnt; return 0; } int gpiowrite (dev, uio, flag) dev_t dev; struct uio *uio; int flag; { register struct iovec *iov = uio->uio_iov; register u_int cnt = NPINS; char buf [20]; /* I/o size should be large enough. */ if (iov->iov_len < cnt) return EIO; bcopy (iov->iov_base, buf, cnt); iov->iov_base += cnt; iov->iov_len -= cnt; uio->uio_resid -= cnt; uio->uio_offset += cnt; PRINTDBG ("gpiowrite ('%s')\n", buf); gpio_parse (dev, buf); return 0; } /* * Display a picture on LoL shield. * Duration in milliseconds is specified. */ static void gpio_lol (msec, data) u_int msec; const short *data; { /* Number of control pins for LoL Shield. */ #define LOL_NPINS 12 /* Number of rows on LoL Shield. */ #define LOL_NROW 9 /* Number of columns on LoL Shield. */ #define LOL_NCOL 14 /* Sequence of pins to set high during refresh cycle. */ static const unsigned high [LOL_NPINS] = { 1 << 10, /* PB10 - labeled D13 on board (connect to A5) */ 1 << 9, /* PB9 - D12 (connect to A4) */ 1 << 7, /* PB7 - D11 (connect to A3) */ 1 << 6, /* PB6 - D10 (connect to A2) */ 1 << 4, /* PB4 - D9 (connect to A1) */ 1 << 11, /* PB11 - D8 */ 0x10000 << 7, /* PE7 - D7 */ 0x10000 << 6, /* PE6 - D6 */ 0x10000 << 5, /* PE5 - D5 */ 0x10000 << 4, /* PE4 - D4 */ 0x10000 << 3, /* PE3 - D3 */ 0x10000 << 2, /* PE2 - D2 */ }; /* Remap pixels to pin indexes. */ static const unsigned char lol_map [LOL_NROW*LOL_NCOL*2] = { 0,8,0,7,0,6,0,5,0,4,0,3,0,2,0,1,0,9,9,0,0,10,10,0,0,11,11,0, 1,8,1,7,1,6,1,5,1,4,1,3,1,2,1,0,1,9,9,1,1,10,10,1,1,11,11,1, 2,8,2,7,2,6,2,5,2,4,2,3,2,1,2,0,2,9,9,2,2,10,10,2,2,11,11,2, 3,8,3,7,3,6,3,5,3,4,3,2,3,1,3,0,3,9,9,3,3,10,10,3,3,11,11,3, 4,8,4,7,4,6,4,5,4,3,4,2,4,1,4,0,4,9,9,4,4,10,10,4,4,11,11,4, 5,8,5,7,5,6,5,4,5,3,5,2,5,1,5,0,5,9,9,5,5,10,10,5,5,11,11,5, 6,8,6,7,6,5,6,4,6,3,6,2,6,1,6,0,6,9,9,6,6,10,10,6,6,11,11,6, 7,8,7,6,7,5,7,4,7,3,7,2,7,1,7,0,7,9,9,7,7,10,10,7,7,11,11,7, 8,7,8,6,8,5,8,4,8,3,8,2,8,1,8,0,8,9,9,8,8,10,10,8,8,11,11,8, }; unsigned row, mask, bmask, emask; const unsigned char *map; unsigned low [LOL_NPINS]; /* Clear pin masks. */ for (row = 0; row < LOL_NPINS; row++) low [row] = 0; /* Convert image to array of pin masks. */ for (row = 0; row < LOL_NROW; row++) { mask = *data++ & ((1 << LOL_NCOL) - 1); map = &lol_map [row * LOL_NCOL * 2]; while (mask != 0) { if (mask & 1) { low [map[0]] |= high [map[1]]; } map += 2; mask >>= 1; } } bmask = high[0] | high[1] | high[2] | high[3] | high[4] | high[5]; emask = (high[6] | high[7] | high[8] | high[9] | high[10] | high[11]) >> 16; /* Display the image. */ if (msec < 1) msec = 20; while (msec-- > 0) { for (row = 0; row < LOL_NPINS; row++) { /* Set all pins to tristate. */ TRISBSET = bmask; TRISESET = emask; /* Set one pin to high. */ mask = high [row]; if (row < 6) { TRISBCLR = mask; LATBSET = mask; } else { mask >>= 16; TRISECLR = mask; LATESET = mask; } /* Set other pins to low. */ mask = low [row]; TRISBCLR = mask; LATBCLR = mask; mask >>= 16; TRISECLR = mask; LATECLR = mask; /* Pause to make it visible. */ udelay (1000 / LOL_NPINS); } } /* Turn display off. */ TRISBSET = bmask; TRISESET = emask; } /* * Commands: * GPIO_CONFIN - configure as input * GPIO_CONFOUT - configure as output * GPIO_CONFOD - configure as open drain * GPIO_DECONF - deconfigure * GPIO_STORE - store all outputs * GPIO_SET - set to 1 by mask * GPIO_CLEAR - set to 0 by mask * GPIO_INVERT - invert by mask * GPIO_POLL - poll * * Use GPIO_PORT(n) to set port number. */ int gpioioctl (dev, cmd, addr, flag) dev_t dev; register u_int cmd; caddr_t addr; int flag; { register u_int unit, mask, value; register struct gpioreg *reg; PRINTDBG ("gpioioctl (cmd=%08x, addr=%08x, flag=%d)\n", cmd, addr, flag); unit = cmd & 0xff; cmd &= ~0xff; if (cmd == GPIO_LOL) { /* display 9x14 image on a lol shield */ if (baduaddr (addr) || baduaddr (addr + LOL_NROW*2 - 1)) return EFAULT; gpio_lol (unit, (const short*) addr); return 0; } if ((cmd & (IOC_INOUT | IOC_VOID)) != IOC_VOID || ((cmd >> 8) & 0xff) != 'g') return EINVAL; if (unit >= NGPIO) return ENXIO; reg = unit + (struct gpioreg*) &TRISA; mask = (u_int) addr & 0xffff; if (cmd & GPIO_COMMAND & (GPIO_CONFIN | GPIO_CONFOUT | GPIO_CONFOD)) mask = mask; else mask &= gpio_confmask[unit]; if (cmd & GPIO_COMMAND & GPIO_CONFIN) { /* configure as input */ PRINTDBG ("TRIS%cSET %p := %04x\n", unit+'A', ®->trisset, mask); reg->trisset = mask; gpio_confmask[unit] |= mask; /* skip output-only bits */ gpio_confmask[unit] ^= mask & ~reg->tris; } if (cmd & GPIO_COMMAND & (GPIO_CONFOUT | GPIO_CONFOD)) { if (cmd & GPIO_COMMAND & GPIO_CONFOUT) { /* configure as output */ PRINTDBG ("ODC%cCLR %p := %04x\n", unit+'A', ®->odcclr, mask); reg->odcclr = mask; } else { /* configure as open drain */ PRINTDBG ("ODC%cSET %p := %04x\n", unit+'A', ®->odcset, mask); reg->odcset = mask; } PRINTDBG ("TRIS%cCLR %p := %04x\n", unit+'A', ®->trisclr, mask); reg->trisclr = mask; gpio_confmask[unit] |= mask; /* skip input-only bits */ gpio_confmask[unit] ^= mask & reg->tris; } if (cmd & GPIO_COMMAND & GPIO_DECONF) { /* deconfigure */ gpio_confmask[unit] &= ~mask; } if (cmd & GPIO_COMMAND & GPIO_STORE) { /* store all outputs */ value = reg->lat; PRINTDBG ("LAT%c %p -> %04x\n", unit+'A', ®->lat, value); value &= ~gpio_confmask[unit]; value |= mask; PRINTDBG ("LAT%c %p := %04x\n", unit+'A', ®->lat, value); reg->lat = value; } if (cmd & GPIO_COMMAND & GPIO_SET) { /* set to 1 by mask */ PRINTDBG ("LAT%cSET %p := %04x\n", unit+'A', ®->latset, mask); reg->latset = mask; } if (cmd & GPIO_COMMAND & GPIO_CLEAR) { /* set to 0 by mask */ PRINTDBG ("LAT%cCLR %p := %04x\n", unit+'A', ®->latclr, mask); reg->latclr = mask; } if (cmd & GPIO_COMMAND & GPIO_INVERT) { /* invert by mask */ PRINTDBG ("LAT%cINV %p := %04x\n", unit+'A', ®->latinv, mask); reg->latinv = mask; } if (cmd & GPIO_COMMAND & GPIO_POLL) { /* send current pin values to user */ value = reg->port; PRINTDBG ("PORT%c %p -> %04x\n", unit+'A', ®->port, value); u.u_rval = value; } return 0; } /* * Test to see if device is present. * Return true if found and initialized ok. */ static int gpioprobe(config) struct conf_device *config; { int unit = config->dev_unit; int flags = config->dev_flags; char buf[20]; if (unit < 0 || unit >= NGPIO) return 0; gpio_confmask[unit] = flags; gpio_print(unit | MINOR_CONF, buf); printf("gpio%u: port%c, pins %s", unit, unit + 'A', buf); return 1; } struct driver gpiodriver = { "gpio", gpioprobe, }; ================================================ FILE: sys/arch/pic32/dev/hx8357.c ================================================ /* * HX8357 TFT driver for PIC32. * * Copyright (C) 2014 Majenko Technologies * Copyright (C) 2015 Serge Vakulenko * * Permission to use, copy, modify, and distribute this software * and its documentation for any purpose and without fee is hereby * granted, provided that the above copyright notice appear in all * copies and that both that the copyright notice and this * permission notice and warranty disclaimer appear in supporting * documentation, and that the name of the author not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * * The author disclaim all warranties with regard to this * software, including all implied warranties of merchantability * and fitness. In no event shall the author be liable for any * special, indirect or consequential damages or any damages * whatsoever resulting from loss of use, data or profits, whether * in an action of contract, negligence or other tortious action, * arising out of or in connection with the use or performance of * this software. */ #include #include #include #include #include #include #include #include #include #define HX8357_EXIT_SLEEP_MODE 0x11 #define HX8357_SET_DISPLAY_OFF 0x28 #define HX8357_SET_DISPLAY_ON 0x29 #define HX8357_SET_COLUMN_ADDRESS 0x2A #define HX8357_SET_PAGE_ADDRESS 0x2B #define HX8357_WRITE_MEMORY_START 0x2C #define HX8357_READ_MEMORY_START 0x2E #define HX8357_SET_TEAR_ON 0x35 #define HX8357_SET_ADDRESS_MODE 0x36 #define HX8357_SET_PIXEL_FORMAT 0x3A #define HX8357_WRITE_MEMORY_CONTINUE 0x3C #define HX8357_READ_MEMORY_CONTINUE 0x3E #define HX8357_SET_INTERNAL_OSCILLATOR 0xB0 #define HX8357_SET_POWER_CONTROL 0xB1 #define HX8357_SET_DISPLAY_MODE 0xB4 #define HX8357_SET_VCOM_VOLTAGE 0xB6 #define HX8357_ENABLE_EXTENSION_COMMAND 0xB9 #define HX8357_SET_PANEL_DRIVING 0xC0 // not documented! #define HX8357_SET_PANEL_CHARACTERISTIC 0xCC #define HX8357_SET_GAMMA_CURVE 0xE0 /* * Display size. */ static int _width, _height; /* * Cursor position for text output. */ static int _col, _row; static void writeCommand(int c) { while (PMMODE & PIC32_PMMODE_BUSY); PMADDR = 0x0000; PMDIN = c; } static void writeData(int c) { while (PMMODE & PIC32_PMMODE_BUSY); PMADDR = 0x0001; PMDIN = c; } static inline void initDisplay() { PMCONCLR = PIC32_PMCON_ON; udelay(1); PMCONSET = PIC32_PMCON_PTWREN | PIC32_PMCON_PTRDEN; PMCONCLR = PIC32_PMCON_CSF; PMAEN = 0x0001; // Enable PMA0 pin for RS pin and CS1 as CS PMMODE = PIC32_PMMODE_MODE16 | PIC32_PMMODE_MODE_MAST2; PMADDR = 0; PMCONSET = PIC32_PMCON_ON; writeCommand(HX8357_EXIT_SLEEP_MODE); //Sleep Out udelay(150000); writeCommand(HX8357_ENABLE_EXTENSION_COMMAND); writeData(0xFF); writeData(0x83); writeData(0x57); udelay(1000); writeCommand(HX8357_SET_POWER_CONTROL); writeData(0x00); writeData(0x12); writeData(0x12); writeData(0x12); writeData(0xC3); writeData(0x44); udelay(1000); writeCommand(HX8357_SET_DISPLAY_MODE); writeData(0x02); writeData(0x40); writeData(0x00); writeData(0x2A); writeData(0x2A); writeData(0x20); writeData(0x91); udelay(1000); writeCommand(HX8357_SET_VCOM_VOLTAGE); writeData(0x38); udelay(1000); writeCommand(HX8357_SET_INTERNAL_OSCILLATOR); writeData(0x68); writeCommand(0xE3); //Unknown Command writeData(0x2F); writeData(0x1F); writeCommand(0xB5); //Set BGP writeData(0x01); writeData(0x01); writeData(0x67); writeCommand(HX8357_SET_PANEL_DRIVING); writeData(0x70); writeData(0x70); writeData(0x01); writeData(0x3C); writeData(0xC8); writeData(0x08); udelay(1000); writeCommand(0xC2); // Set Gate EQ writeData(0x00); writeData(0x08); writeData(0x04); udelay(1000); writeCommand(HX8357_SET_PANEL_CHARACTERISTIC); writeData(0x09); udelay(1000); writeCommand(HX8357_SET_GAMMA_CURVE); writeData(0x01); writeData(0x02); writeData(0x03); writeData(0x05); writeData(0x0E); writeData(0x22); writeData(0x32); writeData(0x3B); writeData(0x5C); writeData(0x54); writeData(0x4C); writeData(0x41); writeData(0x3D); writeData(0x37); writeData(0x31); writeData(0x21); writeData(0x01); writeData(0x02); writeData(0x03); writeData(0x05); writeData(0x0E); writeData(0x22); writeData(0x32); writeData(0x3B); writeData(0x5C); writeData(0x54); writeData(0x4C); writeData(0x41); writeData(0x3D); writeData(0x37); writeData(0x31); writeData(0x21); writeData(0x00); writeData(0x01); udelay(1000); writeCommand(HX8357_SET_PIXEL_FORMAT); //COLMOD RGB888 writeData(0x55); writeCommand(HX8357_SET_ADDRESS_MODE); writeData(0x00); writeCommand(HX8357_SET_TEAR_ON); //TE ON writeData(0x00); udelay(10000); writeCommand(HX8357_SET_DISPLAY_ON); //Display On udelay(10000); writeCommand(HX8357_WRITE_MEMORY_START); //Write SRAM Data } static void setAddrWindow(int x0, int y0, int x1, int y1) { writeCommand(HX8357_SET_COLUMN_ADDRESS); // Column addr set writeData(x0 >> 8); writeData(x0); // XSTART writeData(x1 >> 8); writeData(x1); // XEND writeCommand(HX8357_SET_PAGE_ADDRESS); // Row addr set writeData(y0 >> 8); writeData(y0); // YSTART writeData(y1 >> 8); writeData(y1); // YEND writeCommand(HX8357_WRITE_MEMORY_START); //Write SRAM Data } static void setRotation(int rotation) { writeCommand(HX8357_SET_ADDRESS_MODE); switch (rotation & 3) { case 0: /* Portrait */ writeData(0x0000); _width = 320; _height = 480; break; case 1: /* Landscape */ writeData(0x0060); _width = 480; _height = 320; break; case 2: /* Upside down portrait */ writeData(0x00C0); _width = 320; _height = 480; break; case 3: /* Upside down landscape */ writeData(0x00A0); _width = 480; _height = 320; break; } } /* * Draw a pixel. */ static void setPixel(int x, int y, int color) { if (x < 0 || x >= _width || y < 0 || y >= _height) return; setAddrWindow(x, y, x+1, y+1); while (PMMODE & PIC32_PMMODE_BUSY); PMADDR = 0x0001; PMDIN = color; } /* * Fill a rectangle with specified color. */ static void fillRectangle(int x0, int y0, int x1, int y1, int color) { int x, y; if (x0 < 0) x0 = 0; if (y0 < 0) x0 = 0; if (x1 < 0) x1 = 0; if (y1 < 0) x1 = 0; if (x0 >= _width) x0 = _width-1; if (x1 >= _width) x1 = _width-1; if (y0 >= _height) y0 = _height-1; if (y1 >= _height) y1 = _height-1; if (x1 < x0) { int t = x0; x0 = x1; x1 = t; } if (y1 < y0) { int t = y0; y0 = y1; y1 = t; } setAddrWindow(x0, y0, x1, y1); while (PMMODE & PIC32_PMMODE_BUSY); PMADDR = 0x0001; for (y=y0; y<=y1; y++) { for (x=x0; x<=x1; x++) { while (PMMODE & PIC32_PMMODE_BUSY); PMDIN = color; } } } /* * Fill a rectangle with user data. */ static void drawImage(int x, int y, int width, int height, const unsigned short *data) { unsigned cnt = width * height; setAddrWindow(x, y, x + width - 1, y + height - 1); while (PMMODE & PIC32_PMMODE_BUSY); PMADDR = 0x0001; while (cnt--) { while (PMMODE & PIC32_PMMODE_BUSY); PMDIN = *data++; } } /* * Draw a line. */ static void drawLine(int x0, int y0, int x1, int y1, int color) { int dx, dy, stepx, stepy, fraction; if (x0 == x1 || y0 == y1) { fillRectangle(x0, y0, x1, y1, color); return; } /* Use Bresenham's line algorithm. */ dy = y1 - y0; if (dy < 0) { dy = -dy; stepy = -1; } else { stepy = 1; } dx = x1 - x0; if (dx < 0) { dx = -dx; stepx = -1; } else { stepx = 1; } dy <<= 1; /* dy is now 2*dy */ dx <<= 1; /* dx is now 2*dx */ setPixel(x0, y0, color); if (dx > dy) { fraction = dy - (dx >> 1); /* same as 2*dy - dx */ while (x0 != x1) { if (fraction >= 0) { y0 += stepy; fraction -= dx; /* same as fraction -= 2*dx */ } x0 += stepx; fraction += dy; /* same as fraction -= 2*dy */ setPixel(x0, y0, color); } } else { fraction = dx - (dy >> 1); while (y0 != y1) { if (fraction >= 0) { x0 += stepx; fraction -= dy; } y0 += stepy; fraction += dx; setPixel(x0, y0, color); } } } /* * Draw a rectangular frame. */ static void drawFrame(int x0, int y0, int x1, int y1, int color) { fillRectangle(x0, y0, x1, y0, color); fillRectangle(x0, y1, x1, y1, color); fillRectangle(x0, y0, x0, y1, color); fillRectangle(x1, y0, x1, y1, color); } /* * Draw a circle. */ static void drawCircle(int x0, int y0, int radius, int color) { int f = 1 - radius; int ddF_x = 0; int ddF_y = -2 * radius; int x = 0; int y = radius; setPixel(x0, y0 + radius, color); setPixel(x0, y0 - radius, color); setPixel(x0 + radius, y0, color); setPixel(x0 - radius, y0, color); while (x < y) { if (f >= 0) { y--; ddF_y += 2; f += ddF_y; } x++; ddF_x += 2; f += ddF_x + 1; setPixel(x0 + x, y0 + y, color); setPixel(x0 - x, y0 + y, color); setPixel(x0 + x, y0 - y, color); setPixel(x0 - x, y0 - y, color); setPixel(x0 + y, y0 + x, color); setPixel(x0 - y, y0 + x, color); setPixel(x0 + y, y0 - x, color); setPixel(x0 - y, y0 - x, color); } } /* * Start a new line: increase row. */ static void newLine(const struct gpanel_font_t *font) { _col = 0; _row += font->height; if (_row > _height - font->height) _row = 0; } /* * Draw a glyph of one symbol. */ void drawGlyph(const struct gpanel_font_t *font, int color, int background, int width, const unsigned short *bits) { int h, w; unsigned bitmask = 0; if (background >= 0) { /* * Clear background. */ setAddrWindow(_col, _row, _col + width - 1, _row + font->height - 1); while (PMMODE & PIC32_PMMODE_BUSY); PMADDR = 0x0001; /* Loop on each glyph row. */ for (h=0; hheight; h++) { /* Loop on every pixel in the row (left to right). */ for (w=0; wheight; h++) { /* Loop on every pixel in the row (left to right). */ for (w=0; wfirstchar || sym >= font->firstchar + font->size) sym = font->defaultchar; cindex = sym - font->firstchar; /* Get font bitmap depending on fixed pitch or not. */ if (font->width) { /* Proportional font. */ width = font->width[cindex]; } else { /* Fixed width font. */ width = font->maxwidth; } if (font->offset) { bits = font->bits + font->offset[cindex]; } else { bits = font->bits + cindex * font->height; } /* Scrolling. */ if (_col > _width - width) { newLine(font); } /* Draw a character. */ drawGlyph(font, color, background, width, bits); _col += width; } /* * Draw a string of characters. * TODO: Decode UTF-8. */ static void drawText(const struct gpanel_font_t *font, int color, int background, int x, int y, const char *text) { int sym; _col = x; _row = y; for (;;) { sym = *text++; if (! sym) break; drawChar(font, color, background, sym); } } int gpanel_open(dev_t dev, int flag, int mode) { if (minor(dev) != 0) return ENODEV; return 0; } int gpanel_close(dev_t dev, int flag, int mode) { return 0; } int gpanel_read(dev_t dev, struct uio *uio, int flag) { return ENODEV; } int gpanel_write(dev_t dev, struct uio *uio, int flag) { return ENODEV; } /* * TODO: check whether user pointers are valid. */ int gpanel_ioctl(dev_t dev, register u_int cmd, caddr_t addr, int flag) { switch (cmd) { /* * Clear the whole screen with a given color. */ case GPANEL_CLEAR: { struct gpanel_clear_t *param = (struct gpanel_clear_t*) addr; if (param->xsize != _width || param->ysize != _height) { /* Change the screen orientation. */ if (param->xsize > param->ysize) { /* Landscape */ setRotation(1); } else if (param->xsize < param->ysize) { /* Portrait */ setRotation(0); } } fillRectangle(0, 0, _width, _height, param->color); param->xsize = _width; param->ysize = _height; break; } /* * Draw a single pixel. */ case GPANEL_PIXEL: { struct gpanel_pixel_t *param = (struct gpanel_pixel_t*) addr; setPixel(param->x, param->y, param->color); break; } /* * Draw a line. */ case GPANEL_LINE: { struct gpanel_line_t *param = (struct gpanel_line_t*) addr; drawLine(param->x0, param->y0, param->x1, param->y1, param->color); break; } /* * Draw a rectangle frame. */ case GPANEL_RECT: { struct gpanel_rect_t *param = (struct gpanel_rect_t*) addr; drawFrame(param->x0, param->y0, param->x1, param->y1, param->color); break; } /* * Fill a rectangle with color. */ case GPANEL_FILL: { struct gpanel_rect_t *param = (struct gpanel_rect_t*) addr; fillRectangle(param->x0, param->y0, param->x1, param->y1, param->color); break; } /* * Draw a circle. */ case GPANEL_CIRCLE: { struct gpanel_circle_t *param = (struct gpanel_circle_t*) addr; drawCircle(param->x, param->y, param->radius, param->color); break; } /* * Fill a rectangular area with the user-supplied data. */ case GPANEL_IMAGE: { struct gpanel_image_t *param = (struct gpanel_image_t*) addr; drawImage(param->x, param->y, param->width, param->height, param->image); break; } /* * Draw a character. */ case GPANEL_CHAR: { struct gpanel_char_t *param = (struct gpanel_char_t*) addr; _col = param->x; _row = param->y; drawChar(param->font, param->color, param->background, param->sym); break; } /* * Draw a string of characters. */ case GPANEL_TEXT: { struct gpanel_text_t *param = (struct gpanel_text_t*) addr; drawText(param->font, param->color, param->background, param->x, param->y, param->text); break; } } return 0; } /* * Test to see if device is present. * Return true if found and initialized ok. */ static int hxtftprobe(config) struct conf_device *config; { initDisplay(); setRotation(1); printf("hxtft0: display %ux%u\n", _width, _height); return 1; } struct driver hxtftdriver = { "hxtft", hxtftprobe, }; ================================================ FILE: sys/arch/pic32/dev/ili9341.h ================================================ /* * ILI9341 registers. */ #define ILI9341_No_Operation 0x00 #define ILI9341_Software_Reset 0x01 #define ILI9341_Read_Display_Identification_Information 0x04 #define ILI9341_Read_Display_Status 0x09 #define ILI9341_Read_Display_Power_Mode 0x0A #define ILI9341_Read_Display_MADCTL 0x0B #define ILI9341_Read_Display_Pixel_Format 0x0C #define ILI9341_Read_Display_Image_Format 0x0D #define ILI9341_Read_Display_Signal_Mode 0x0E #define ILI9341_Read_Display_Self_Diagnostic_Result 0x0F #define ILI9341_Enter_Sleep_Mode 0x10 #define ILI9341_Sleep_OUT 0x11 #define ILI9341_Partial_Mode_ON 0x12 #define ILI9341_Normal_Display_Mode_ON 0x13 #define ILI9341_Display_Inversion_OFF 0x20 #define ILI9341_Display_Inversion_ON 0x21 #define ILI9341_Gamma_Set 0x26 #define ILI9341_Display_OFF 0x28 #define ILI9341_Display_ON 0x29 #define ILI9341_Column_Address_Set 0x2A #define ILI9341_Page_Address_Set 0x2B #define ILI9341_Memory_Write 0x2C #define ILI9341_Color_SET 0x2D #define ILI9341_Memory_Read 0x2E #define ILI9341_Partial_Area 0x30 #define ILI9341_Vertical_Scrolling_Definition 0x33 #define ILI9341_Tearing_Effect_Line_OFF 0x34 #define ILI9341_Tearing_Effect_Line_ON 0x35 #define ILI9341_Memory_Access_Control 0x36 #define ILI9341_Vertical_Scrolling_Start_Address 0x37 #define ILI9341_Idle_Mode_OFF 0x38 #define ILI9341_Idle_Mode_ON 0x39 #define ILI9341_Pixel_Format_Set 0x3A #define ILI9341_Write_Memory_Continue 0x3C #define ILI9341_Read_Memory_Continue 0x3E #define ILI9341_Set_Tear_Scanline 0x44 #define ILI9341_Get_Scanline 0x45 #define ILI9341_Write_Display_Brightness 0x51 #define ILI9341_Read_Display_Brightness 0x52 #define ILI9341_Write_CTRL_Display 0x53 #define ILI9341_Read_CTRL_Display 0x54 #define ILI9341_Write_Content_Adaptive_Brightness_Control 0x55 #define ILI9341_Read_Content_Adaptive_Brightness_Control 0x56 #define ILI9341_Write_CABC_Minimum_Brightness 0x5E #define ILI9341_Read_CABC_Minimum_Brightness 0x5F #define ILI9341_Read_ID1 0xDA #define ILI9341_Read_ID2 0xDB #define ILI9341_Read_ID3 0xDC #define ILI9341_RGB_Interface_Signal_Control 0xB0 #define ILI9341_Frame_Control_In_Normal_Mode 0xB1 #define ILI9341_Frame_Control_In_Idle_Mode 0xB2 #define ILI9341_Frame_Control_In_Partial_Mode 0xB3 #define ILI9341_Display_Inversion_Control 0xB4 #define ILI9341_Blanking_Porch_Control 0xB5 #define ILI9341_Display_Function_Control 0xB6 #define ILI9341_Entry_Mode_Set 0xB7 #define ILI9341_Backlight_Control_1 0xB8 #define ILI9341_Backlight_Control_2 0xB9 #define ILI9341_Backlight_Control_3 0xBA #define ILI9341_Backlight_Control_4 0xBB #define ILI9341_Backlight_Control_5 0xBC #define ILI9341_Backlight_Control_7 0xBE #define ILI9341_Backlight_Control_8 0xBF #define ILI9341_Power_Control_1 0xC0 #define ILI9341_Power_Control_2 0xC1 #define ILI9341_VCOM_Control_1 0xC5 #define ILI9341_VCOM_Control_2 0xC7 #define ILI9341_NV_Memory_Write 0xD0 #define ILI9341_NV_Memory_Protection_Key 0xD1 #define ILI9341_NV_Memory_Status_Read 0xD2 #define ILI9341_Read_ID4 0xD3 #define ILI9341_Positive_Gamma_Correction 0xE0 #define ILI9341_Negative_Gamma_Correction 0xE1 #define ILI9341_Digital_Gamma_Control_1 0xE2 #define ILI9341_Digital_Gamma_Control_2 0xE3 #define ILI9341_Interface_Control 0xF6 /* * Memory Access Control register */ #define MADCTL_MY 0x80 /* Row address order */ #define MADCTL_MX 0x40 /* Column address order */ #define MADCTL_MV 0x20 /* Row/column exchange */ #define MADCTL_ML 0x10 /* Vertical refresh order */ #define MADCTL_BGR 0x08 /* Color filter selector: 0=RGB, 1=BGR */ #define MADCTL_MH 0x04 /* Horisontal refresh direction: 1=left-to-right */ ================================================ FILE: sys/arch/pic32/dev/kbd.c ================================================ /* * * RetroBSD - PS2 keyboard driver for the Maximite PIC32 board * * Copyright (C) 2011 Rob Judd * All rights reserved. The three clause ("New" or "Modified") * Berkeley software License Agreement specifies the terms and * conditions for redistribution. * */ /* ../kbd.c: In function 'initKBD': ../kbd.c:155:8: error: request for member 'ON' in something not a structure or union ../kbd.c:156:8: error: request for member 'CNPUE15' in something not a structure or union ../kbd.c:157:8: error: request for member 'CNPUE16' in something not a structure or union ../kbd.c: In function 'readKBD': ../kbd.c:173:9: error: request for member 'RD7' in something not a structure or union ../kbd.c:174:9: error: request for member 'RD6' in something not a structure or union * * This driver uses a 20uS timer, probably too fast */ #include #include #include //#define TRACE printf #ifndef TRACE #define TRACE(...) #endif // I2C registers struct kbdreg { // }; #define USASCII 1 //#define RUSSIAN 1 #define true 1 #define false 0 #define PS2CLOCK 1//PORTD.RD6 #define PS2DATA 2//PORTD.RD7 #define QUEUE_SIZE 256 extern volatile char in_queue[QUEUE_SIZE]; extern volatile int in_queue_head, in_queue_tail; volatile int abort; #define POLL 20*(CPU_KHZ/1000) // # clock cycles for 20uS between keyboard reads #define TIMEOUT 500*(CPU_KHZ/1000) // # clock cycles for 500uS timeout enum {PS2START, PS2BIT, PS2PARITY, PS2STOP}; // Keyboard state machine and buffer int state; unsigned char key_buff; int key_state, key_count, key_parity, key_timer; // IBM keyboard scancode set 2 - Special Keys #define F1 0x0e #define F2 0x0f #define F3 0x10 #define F4 0x11 #define F5 0x12 #define F6 0x13 #define F7 0x14 // maps to F5 #define F8 0x15 #define F9 0x16 #define F10 0x17 #define F11 0x18 #define F12 0x19 #define NUM 0x00 #define BKSP 0x08 #define TAB 0x09 #define L_ALT 0x11 #define L_SHF 0x12 #define L_CTL 0x14 #define CAPS 0x58 #define R_SHF 0x59 #define ENTER 0x0d #define ESC 0x1b #define SCRL 0x7e #ifdef USASCII // // Map of standard keyboard, US ASCII layout // const char lowerKey[128]={ 0, F9, 0, F5, F3, F1, F2, F12, //00 0, F10, F8, F6, F4, TAB, '`', 0, //08 0, 0, L_SHF, 0, L_CTL, 'q', '1', 0, //10 0, 0, 'z', 's', 'a', 'w', '2', 0, //18 0, 'c', 'x', 'd', 'e', '4', '3', 0, //20 0, ' ', 'v', 'f', 't', 'r', '5', 0, //28 0, 'n', 'b', 'h', 'g', 'y', '6', 0, //30 0, 0, 'm', 'j', 'u', '7', '8', 0, //38 0, ',', 'k', 'i', 'o', '0', '9', 0, //40 0, '.', '/', 'l', ';', 'p', '-', 0, //48 0, 0, '\'', 0, '[', '=', 0, 0, //50 CAPS, R_SHF, ENTER, ']', 0, '\\', 0, 0, //58 0, 0, 0, 0, 0, 0, BKSP, 0, //60 0, '1', 0, '4', '7', 0, 0, 0, //68 '0', '.', '2', '5', '6', '8', ESC, NUM, //70 F11, '+', '3', '-', '*', '9', 0, 0 //78 }; const char upperKey[128] = { 0, F9, 0, F5, F3, F1, F2, F12, //00 0, F10, F8, F6, F4, TAB, '~', 0, //08 0, 0, L_SHF, 0, L_CTL, 'Q', '!', 0, //10 0, 0, 'Z', 'S', 'A', 'W', '@', 0, //18 0, 'C', 'X', 'D', 'E', '$', '#', 0, //20 0, ' ', 'V', 'F', 'T', 'R', '%', 0, //28 0, 'N', 'B', 'H', 'G', 'Y', '^', 0, //30 0, 0, 'M', 'J', 'U', '&', '*', 0, //38 0, '<', 'K', 'I', 'O', ')', '(', 0, //40 0, '>', '?', 'L', ':', 'P', '_', 0, //48 0, 0, '\"', 0, '{', '+', 0, 0, //50 CAPS, R_SHF, ENTER, '}', 0, '|', 0, 0, //58 0, 0, 0, 0, 0, 0, BKSP, 0, //60 0, '1', 0, '4', '7', 0, 0, 0, //68 '0', '.', '2', '5', '6', '8', ESC, NUM, //70 F11, '+', '3', '-', '*', '9', 0, 0 //78 }; #elif defined RUSSIAN // // Map of standard keyboard, Russian Windows layout // const char lowerKey[128]={ 0, F9, 0, F5, F3, F1, F2, F12, //00 0, F10, F8, F6, F4, TAB, 'ё', 0, //08 0, 0, L_SHF, 0, L_CTL, 'й', '1', 0, //10 0, 0, 'я', 'ы', 'ф', 'ц', '2', 0, //18 0, 'с', 'ч', 'в', 'у', '4', '3', 0, //20 0, ' ', 'м', 'а', 'е', 'к', '5', 0, //28 0, 'т', 'и', 'р', 'п', 'н', '6', 0, //30 0, 0, 'ь', 'о', 'г', '7', '8', 0, //38 0, 'б', 'л', 'ш', 'щ', '0', '9', 0, //40 0, 'ю', '.', 'д', 'ж', 'з', '-', 0, //48 0, 0, 'э', 0, 'х', '=', 0, 0, //50 CAPS, R_SHF, ENTER, 'ъ', 0, '\\', 0, 0, //58 0, 0, 0, 0, 0, 0, BKSP, 0, //60 0, '1', 0, '4', '7', 0, 0, 0, //68 '0', ',', '2', '5', '6', '8', ESC, NUM, //70 F11, '+', '3', '-', '*', '9', 0, 0 //78 }; const char upperKey[128] = { 0, F9, 0, F5, F3, F1, F2, F12, //00 0, F10, F8, F6, F4, TAB, 'Ё', 0, //08 0, 0, L_SHF, 0, L_CTL, 'Й', '!', 0, //10 0, 0, 'Я', 'Ы', 'Ф', 'Ц', '\"', 0, //18 0, 'С', 'Ч', 'В', 'У', ';', '№', 0, //20 0, ' ', 'М', 'А', 'Е', 'К', '%', 0, //28 0, 'Т', 'И', 'Р', 'П', 'Н', ':', 0, //30 0, 0, 'Ь', 'О', 'Г', '?', '*', 0, //38 0, 'Б', 'Л', 'Ш', 'Щ', ')', '(', 0, //40 0, 'Ю', ',', 'Д', 'Ж', 'З', '_', 0, //48 0, 0, 'Э', 0, 'Х', '+', 0, 0, //50 CAPS, R_SHF, ENTER, 'Ъ', 0, '/', 0, 0, //58 0, 0, 0, 0, 0, 0, BKSP, 0, //60 0, '1', 0, '4', '7', 0, 0, 0, //68 '0', ',', '2', '5', '6', '8', ESC, NUM, //70 F11, '+', '3', '-', '*', '9', 0, 0 //78 }; #endif /* Standard PC init sequence: Keyboard: AA Self-test passed ;Keyboard controller init Host: ED Set/Reset Status Indicators Keyboard: FA Acknowledge Host: 00 Turn off all LEDs Keyboard: FA Acknowledge Host: F2 Read ID Keyboard: FA Acknowledge Keyboard: AB First byte of ID Host: ED Set/Reset Status Indicators ;BIOS init Keyboard: FA Acknowledge Host: 02 Turn on Num Lock LED Keyboard: FA Acknowledge Host: F3 Set Typematic Rate/Delay ;Windows init Keyboard: FA Acknowledge Host: 20 500 ms / 30.0 reports/sec Keyboard: FA Acknowledge Host: F4 Enable Keyboard: FA Acknowledge Host: F3 Set Typematic Rate/delay Keyboard: FA Acknowledge Host: 00 250 ms / 30.0 reports/sec Keyboard: FA Acknowledge */ char init_kbd(void) { // enable pullups on the clock and data lines. // This stops them from floating and generating random chars when no keyboard is attached // CNCON.ON = 1; // turn on Change Notice for interrupt // CNPUE.CNPUE15 = 1; // turn on the pullup for pin D6 also called CN15 // CNPUE.CNPUE16 = 1; // turn on the pullup for pin D7 also called CN16 return false; } void read_kbd(void) { int data = PS2DATA; int clock = PS2CLOCK; static char key_up = false; static unsigned char code = 0; static unsigned then = 0; unsigned now = mips_read_c0_register (C0_COUNT, 0); // Is it time to poll the keyboard yet? if ((int) (now - then) < POLL) return; else then = now; if (key_state) { // if clock was high, key_state = 1 if (!clock) { // PS2CLOCK == 0, falling edge detected key_state = 0; // transition to state 0 key_timer = TIMEOUT; // restart the counter switch(state){ default: case PS2START: if(!data) { // PS2DATA == 0 key_count = 8; // init bit counter key_parity = 0; // init parity check code = 0; state = PS2BIT; } break; case PS2BIT: code >>= 1; // shift in data bit if(data) // PS2DATA == 1 code |= 0x80; key_parity ^= code; if (--key_count == 0) state = PS2PARITY; // all bits read break; case PS2PARITY: if(data) key_parity ^= 0x80; if(key_parity & 0x80) // parity odd, continue state = PS2STOP; else state = PS2START; break; case PS2STOP: if(data) { if(code == 0xf0) key_up = true; else { char chr; static char LShift = 0; static char RShift = 0; static char LCtrl = 0; static char LAlt = 0; static char CapsLock = 0; if(key_up) { // check for special key release key_up = false; switch(code) { case L_SHF: LShift = 0; case R_SHF: RShift = 0; case L_CTL: LCtrl = 0; case L_ALT: LAlt = 0; } goto exit; } else { // check for special key press switch(code) { case L_SHF: LShift = 1; case R_SHF: RShift = 1; case L_CTL: LCtrl = 1; case L_ALT: LAlt = 1; case CAPS: CapsLock = !CapsLock; default: break; goto exit; } } if(LShift || RShift) // get the ASCII code chr = lowerKey[code%128]; else chr = upperKey[code%128]; if(!chr) // it was an unmapped key break; if(CapsLock && chr >= 'a' && chr <= 'z') // check for altered keys chr -= 32; if(LCtrl) chr &= 0x1F; in_queue[in_queue_head] = chr; in_queue_head = (in_queue_head + 1) % QUEUE_SIZE; if(chr == 3) { // check for CTL-C in_queue_head = in_queue_tail = 0; abort = true; } // PrintSignonToUSB = false; // show that the keyboard is in use LAlt = LAlt; // not used yet } // if key_up exit: code = 0; } // if(data) state = PS2START; } // switch(state) } // if(!clock) } else // if(key_state) key_state = 1; // PS2CLOCK == 1, rising edge detected if ((key_timer -= POLL) <= 0) state = PS2START; // timeout, reset state machine return; } char write_kbd(u_char data) { // do something here return false; } ================================================ FILE: sys/arch/pic32/dev/kbd.h ================================================ /* * * RetroBSD - PS2 keyboard driver for the Maximite PIC32 board * * Copyright (C) 2011 Rob Judd * All rights reserved. The three clause ("New" or "Modified") * Berkeley software License Agreement specifies the terms and * conditions for redistribution. * */ #ifndef __KBD_H__ #define __KBD_H__ extern char init_kbd(void); extern void read_kbd(void); extern char write_kbd(u_char data); #endif // __KBD_H__ ================================================ FILE: sys/arch/pic32/dev/mrams.c ================================================ /* * Disk driver for serial MRAM chips connected via SPI port. */ #include #include #include #include #include #include #include #include #include #include #define MRAM_WREN 0x06 #define MRAM_WRDI 0x04 #define MRAM_RDSR 0x05 #define MRAM_WRSR 0x01 #define MRAM_READ 0x03 #define MRAM_WRITE 0x02 #define MRAM_SLEEP 0xB9 #define MRAM_WAKE 0xAB #ifndef MRAMS_MHZ #define MRAMS_MHZ 13 #endif struct spiio mrams_io[MRAMS_CHIPS]; int mrams_dkindex; /* disk index for statistics */ /* * Size of RAM disk. */ #define MRAMS_TOTAL_KBYTES (MRAMS_CHIPS * MRAMS_CHIPSIZE) #define MRBSIZE 1024 #define MRBLOG2 10 unsigned int mr_read_block(unsigned int chip, unsigned int address, unsigned int length, char *data) { register unsigned int cs = 0; struct spiio *io = &mrams_io[chip]; switch (chip) { case 0: #ifdef MRAMS_LED0_PORT TRIS_CLR(MRAMS_LED0_PORT) = 1<>16); spi_transfer(io, address>>8); spi_transfer(io, address); // If the length is a multiple of 32 bits, then do a 32 bit transfer #if 0 if ((length & 3) == 0) spi_bulk_read_32(io, length, data); else if ((length & 1) == 0) spi_bulk_read_16(io, length, data); else #endif spi_bulk_read(io, length, (unsigned char *)data); spi_deselect(io); switch (chip) { case 0: #ifdef MRAMS_LED0_PORT LAT_CLR(MRAMS_LED0_PORT) = 1< 0) { pass++; toread = bcount; if (toread > MRBSIZE) toread = MRBSIZE; chip = offset / MRAMS_CHIPSIZE; address = (offset<<10) - (chip * (MRAMS_CHIPSIZE*1024)); if (chip >= MRAMS_CHIPS) { printf("!!!EIO\n"); return EIO; } mr_read_block(chip, address, toread, data); bcount -= toread; offset += (toread>>MRBLOG2); data += toread; } return 1; } unsigned int mr_write_block(unsigned int chip, unsigned int address, unsigned int length, char *data) { struct spiio *io = &mrams_io[chip]; register unsigned int cs = 0; char blank __attribute__((unused)); switch (chip) { case 0: #ifdef MRAMS_LED0_PORT TRIS_CLR(MRAMS_LED0_PORT) = 1<>16); spi_transfer(io, address>>8); spi_transfer(io, address); #if 0 if ((length & 3) == 0) spi_bulk_write_32(io, length, data); else if ((length & 1) == 0) spi_bulk_write_16(io, length, data); else #endif spi_bulk_write(io, length, (unsigned char *)data); spi_deselect(io); switch (chip) { case 0: #ifdef MRAMS_LED0_PORT LAT_CLR(MRAMS_LED0_PORT) = 1< 0) { pass++; towrite = bcount; if (towrite > MRBSIZE) towrite = MRBSIZE; chip = offset / MRAMS_CHIPSIZE; address = (offset<<10) - (chip * (MRAMS_CHIPSIZE*MRBSIZE)); if (chip >= MRAMS_CHIPS) { printf("!!!EIO\n"); return EIO; } mr_write_block(chip, address, towrite, data); bcount -= towrite; offset += (towrite>>MRBLOG2); data += towrite; } return 1; } /* * Initialize hardware. */ static int mrams_init(int spi_port, int cs0, int cs1, int cs2, int cs3) { struct spiio *io = &mrams_io[0]; if (spi_setup(io, spi_port, cs0) != 0) { printf("mr0: cannot open SPI%u port\n", spi_port); return 0; } spi_brg(io, MRAMS_MHZ * 1000); spi_set(io, PIC32_SPICON_CKE); spi_select(io); spi_transfer(io, MRAM_WREN); spi_deselect(io); #if MRAMS_CHIPS >= 1 spi_setup(io+1, spi_port, cs1); spi_brg(io+1, MRAMS_MHZ * 1000); spi_set(io+1, PIC32_SPICON_CKE); spi_select(io+1); spi_transfer(io+1, MRAM_WREN); spi_deselect(io+1); #endif #if MRAMS_CHIPS >= 2 spi_setup(io+2, spi_port, cs2); spi_brg(io+2, MRAMS_MHZ * 1000); spi_set(io+2, PIC32_SPICON_CKE); spi_select(io+2); spi_transfer(io+2, MRAM_WREN); spi_deselect(io+2); #endif #if MRAMS_CHIPS >= 3 spi_setup(io+3, spi_port, cs3); spi_brg(io+3, MRAMS_MHZ * 1000); spi_set(io+3, PIC32_SPICON_CKE); spi_select(io+3); spi_transfer(io+3, MRAM_WREN); spi_deselect(io+3); #endif printf("mr0: size %dKB, speed %d Mbit/sec\n", MRAMS_CHIPS * MRAMS_CHIPSIZE, spi_get_brg(io) / 1000); return 1; } /* * Open the disk. */ int mrams_open(dev_t dev, int flag, int mode) { return 0; } int mrams_close(dev_t dev, int flag, int mode) { return 0; } /* * Return the size of the device in kbytes. */ daddr_t mrams_size(dev_t dev) { return MRAMS_TOTAL_KBYTES; } void mrams_strategy(struct buf *bp) { int offset = bp->b_blkno; long nblk = btod(bp->b_bcount); int s; /* * Determine the size of the transfer, and make sure it is * within the boundaries of the partition. */ if (bp->b_blkno + nblk > MRAMS_TOTAL_KBYTES) { /* if exactly at end of partition, return an EOF */ if (bp->b_blkno == MRAMS_TOTAL_KBYTES) { bp->b_resid = bp->b_bcount; biodone(bp); return; } /* or truncate if part of it fits */ nblk = MRAMS_TOTAL_KBYTES - bp->b_blkno; if (nblk <= 0) { bp->b_error = EINVAL; bp->b_flags |= B_ERROR; biodone(bp); return; } bp->b_bcount = nblk << DEV_BSHIFT; } led_control(LED_SWAP, 1); s = splbio(); #ifdef UCB_METER if (mrams_dkindex >= 0) { dk_busy |= 1 << mrams_dkindex; dk_xfer[mrams_dkindex]++; dk_bytes[mrams_dkindex] += bp->b_bcount; } #endif if (bp->b_flags & B_READ) { mrams_read(offset, bp->b_addr, bp->b_bcount); } else { mrams_write(offset, bp->b_addr, bp->b_bcount); } biodone(bp); led_control(LED_SWAP, 0); #ifdef UCB_METER if (mrams_dkindex >= 0) dk_busy &= ~(1 << mrams_dkindex); #endif splx(s); } int mrams_ioctl(dev_t dev, u_int cmd, caddr_t addr, int flag) { int error = 0; switch (cmd) { case DIOCGETMEDIASIZE: /* Get disk size in kbytes. */ *(int*) addr = MRAMS_TOTAL_KBYTES; break; default: error = EINVAL; break; } return error; } /* * Test to see if device is present. * Return true if found and initialized ok. */ static int mrams_probe(config) struct conf_device *config; { int cs0 = config->dev_pins[0]; int cs1 = config->dev_pins[1]; int cs2 = config->dev_pins[2]; int cs3 = config->dev_pins[3]; /* Only one device unit is supported. */ if (config->dev_unit != 0) return 0; printf("mr0: port SPI%d, pins cs0=R%c%d/cs1=R%c%d/cs2=R%c%d/cs3=R%c%d\n", config->dev_ctlr, gpio_portname(cs0), gpio_pinno(cs0), gpio_portname(cs1), gpio_pinno(cs1), gpio_portname(cs2), gpio_pinno(cs2), gpio_portname(cs3), gpio_pinno(cs3)); if (mrams_init(config->dev_ctlr, cs0, cs1, cs2, cs3) != 0) return 0; #ifdef UCB_METER dk_alloc(&mrams_dkindex, 1, "mr0"); #endif return 1; } struct driver mrdriver = { "mr", mrams_probe, }; ================================================ FILE: sys/arch/pic32/dev/mrams.h ================================================ #ifndef _MRAMS_H #define _MRAMS_H #ifdef KERNEL extern int mrams_open(dev_t dev, int flag, int mode); extern int mrams_close(dev_t dev, int flag, int mode); extern daddr_t mrams_size(dev_t dev); extern void mrams_strategy(struct buf *bp); extern int mrams_ioctl (dev_t dev, u_int cmd, caddr_t addr, int flag); #endif #endif ================================================ FILE: sys/arch/pic32/dev/picga.c ================================================ /* * PICGA driver for PIC32. * * Copyright (C) 2012 Majenko Technologies * * Permission to use, copy, modify, and distribute this software * and its documentation for any purpose and without fee is hereby * granted, provided that the above copyright notice appear in all * copies and that both that the copyright notice and this * permission notice and warranty disclaimer appear in supporting * documentation, and that the name of the author not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * * The author disclaim all warranties with regard to this * software, including all implied warranties of merchantability * and fitness. In no event shall the author be liable for any * special, indirect or consequential damages or any damages * whatsoever resulting from loss of use, data or profits, whether * in an action of contract, negligence or other tortious action, * arising out of or in connection with the use or performance of * this software. */ #include #include #include #include #include #include #include #include #include extern int uwritec(struct uio *); struct spiio picga_io; void blockdelay(u_int v) { for (; v > 0; v--) asm volatile("nop"); } void picga_command(u_char cmd, u_char len, void *data) { struct spiio *io = &picga_io; char *p = (char *)data; spi_select(io); blockdelay(3000); spi_transfer(io, cmd); blockdelay(3000); spi_transfer(io, len); blockdelay(3000); spi_transfer(io, 0); blockdelay(3000); while (len > 0) { spi_transfer(io, *p++); blockdelay(3000); len--; } blockdelay(3000); spi_deselect(io); blockdelay(3000); } int picga_open(dev_t dev, int flag, int mode) { int channel; struct spiio *io = &picga_io; struct intval i; struct coord2 j; channel = minor(dev); if (channel > 0) return ENODEV; if (spi_setup(io, PICGA_BUS, (u_int *)&PICGA_CS_PORT, PICGA_CS_PIN) != 0) return ENODEV; spi_brg(io, 500); i.value = 0x01; picga_command(SPI_FGCOLOR, sizeof(struct intval), &i); i.value = 0x00; picga_command(SPI_BGCOLOR, sizeof(struct intval), &i); i.value = FONT_TOPAZ; picga_command(SPI_FONT, sizeof(struct intval), &i); j.x = 0; j.y = 0; picga_command(SPI_CLUT, sizeof(struct coord2), &j); j.x = 1; j.y = 0xFFFF; picga_command(SPI_CLUT, sizeof(struct coord2), &j); return 0; } int picga_close(dev_t dev, int flag, int mode) { int channel; channel = minor(dev); if (channel > 0) return ENODEV; return 0; } /* Return the most recent ADC value. */ int picga_read(dev_t dev, struct uio *uio, int flag) { return EPERM; } /* Trigger an ADC conversion. */ int picga_write(dev_t dev, struct uio *uio, int flag) { int channel; char t[100]; int p = 0; char c; channel = minor(dev); if (channel > 0) return ENODEV; while (uio->uio_iov->iov_len > 0) { p = 0; while (p < 90 && uio->uio_iov->iov_len > 0) { c = uwritec(uio); t[p++] = c; t[p] = 0; if (c == '\n') break; } picga_command(SPI_PRINT, p, t); blockdelay(50000); } return 0; } int picga_ioctl(dev_t dev, u_int cmd, caddr_t addr, int flag) { printf("IOCTL %08X\n", cmd); switch (cmd) { case PICGA_CLS: printf("CLS command\n"); picga_command(SPI_CLS, 0, NULL); break; default: return EINVAL; } return 0; } ================================================ FILE: sys/arch/pic32/dev/power_control.c ================================================ #include #include #include #include #include #include volatile unsigned int psCounter; int countdown; #define COUNTDOWN 5 void power_off() { TRIS_CLR(POWER_CONTROL_PORT) = 1< 0) { LAT_SET(POWER_LED_PORT) = 1< * * Permission to use, copy, modify, and distribute this software * and its documentation for any purpose and without fee is hereby * granted, provided that the above copyright notice appear in all * copies and that both that the copyright notice and this * permission notice and warranty disclaimer appear in supporting * documentation, and that the name of the author not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * * The author disclaim all warranties with regard to this * software, including all implied warranties of merchantability * and fitness. In no event shall the author be liable for any * special, indirect or consequential damages or any damages * whatsoever resulting from loss of use, data or profits, whether * in an action of contract, negligence or other tortious action, * arising out of or in connection with the use or performance of * this software. */ #include #include #include #include #include #include #include #include #include #define _BC(R,B) (R &= ~(1<- 1:1 prescale _BC(T2CON,4); _BC(T2CON,3); // 16 bit timer _BC(T2CON,1); // Internal clock source PR2 = 0xFFFF; switch (unit) { case 0: _BS(OC1CON,15); // ON _BC(OC1CON,5); // 16 bit _BC(OC1CON,3); // TMR2 _BS(OC1CON,2); // _BS(OC1CON,1); // >- PWM Mode, no fault pin _BC(OC1CON,0); // state[0].mode = PWM_MODE_PWM; break; case 1: _BS(OC2CON,15); // ON _BC(OC2CON,5); // 16 bit _BC(OC2CON,3); // TMR2 _BS(OC2CON,2); // _BS(OC2CON,1); // >- PWM Mode, no fault pin _BC(OC2CON,0); // state[1].mode = PWM_MODE_PWM; break; case 2: _BS(OC3CON,15); // ON _BC(OC3CON,5); // 16 bit _BC(OC3CON,3); // TMR2 _BS(OC3CON,2); // _BS(OC3CON,1); // >- PWM Mode, no fault pin _BC(OC3CON,0); // state[2].mode = PWM_MODE_PWM; break; case 3: _BS(OC4CON,15); // ON _BC(OC4CON,5); // 16 bit _BC(OC4CON,3); // TMR2 _BS(OC4CON,2); // _BS(OC4CON,1); // >- PWM Mode, no fault pin _BC(OC4CON,0); // state[3].mode = PWM_MODE_PWM; break; case 4: _BS(OC5CON,15); // ON _BC(OC5CON,5); // 16 bit _BC(OC5CON,3); // TMR2 _BS(OC5CON,2); // _BS(OC5CON,1); // >- PWM Mode, no fault pin _BC(OC5CON,0); // state[4].mode = PWM_MODE_PWM; break; default: return EINVAL; } DEBUG("pwm%d: Mode set to PWM\n",unit); break; default: return EINVAL; } return 0; } int pwm_duty(int unit, unsigned int duty) { if (state[unit].mode != PWM_MODE_PWM) return EINVAL; switch (unit) { case 0: OC1RS = duty; break; case 1: OC2RS = duty; break; case 2: OC3RS = duty; break; case 3: OC4RS = duty; break; case 4: OC5RS = duty; break; default: return EINVAL; } DEBUG("pwm%d: Duty set to %d\n",unit,duty); return 0; } int pwm_open (dev, flag, mode) dev_t dev; int flag; int mode; { int unit = minor(dev); if (unit >= PWM_MAX_DEV) return ENXIO; if (u.u_uid != 0) return EPERM; DEBUG("pwm%d: Opened\n",unit); return 0; } int pwm_close (dev, flag, mode) dev_t dev; int flag; int mode; { return 0; } int pwm_read (dev, uio, flag) dev_t dev; struct uio *uio; int flag; { // TODO return ENODEV; } int pwm_write (dev_t dev, struct uio *uio, int flag) { return ENODEV; } int pwm_ioctl (dev, cmd, addr, flag) dev_t dev; register u_int cmd; caddr_t addr; int flag; { int unit; int *val; val = (int *)addr; unit = minor(dev); if (unit >= PWM_MAX_DEV) return ENODEV; if (cmd == PWM_SET_MODE) { return pwm_set_mode(unit, *val); } if (cmd == PWM_DUTY) { return pwm_duty(unit, (unsigned int) *val); } return 0; } /* * Test to see if device is present. * Return true if found and initialized ok. */ static int pwmprobe(config) struct conf_device *config; { printf("pwm: %u channels\n", PWM_MAX_DEV); return 1; } struct driver pwmdriver = { "pwm", pwmprobe, }; ================================================ FILE: sys/arch/pic32/dev/sd.c ================================================ /* * SD or SDHC card connected to SPI port. * * Up to two cards can be connected to the same SPI port. * PC-compatible partition table is supported. * The following device numbers are used: * * Major Minor Device Partition * ---------------------------------------------- * 0 0 sd0 Main SD card, whole volume * 0 1 sd0a 1-st partition, usually root FS * 0 2 sd0b 2-nd partition, usually swap * 0 3 sd0c 3-rd partition * 0 4 sd0d 4-th partition * 0 8 sd1 Second SD card, whole volume * 0 9 sd1a 1-st partition * 0 10 sd1b 2-nd partition * 0 11 sd1c 3-rd partition * 0 12 sd1d 4-th partition * * Copyright (C) 2010-2015 Serge Vakulenko, * * Permission to use, copy, modify, and distribute this software * and its documentation for any purpose and without fee is hereby * granted, provided that the above copyright notice appear in all * copies and that both that the copyright notice and this * permission notice and warranty disclaimer appear in supporting * documentation, and that the name of the author not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * * The author disclaim all warranties with regard to this * software, including all implied warranties of merchantability * and fitness. In no event shall the author be liable for any * special, indirect or consequential damages or any damages * whatsoever resulting from loss of use, data or profits, whether * in an action of contract, negligence or other tortious action, * arising out of or in connection with the use or performance of * this software. */ #include #include #include #include #include #include #include #include #include /* * Two SD/MMC disks on SPI. * Signals for SPI1: * D0 - SDO1 * D10 - SCK1 * C4 - SDI1 */ #define NSD 2 #define SECTSIZE 512 #define SPI_ENHANCED /* use SPI fifo */ #ifndef SD_MHZ #define SD_MHZ 12 /* set 12.5Mhz; really 13.33MHz */ #endif #ifndef SD_FAST_MHZ #define SD_FAST_MHZ 25 /* up to 25Mhz is allowed by the spec */ #endif #define TIMO_WAIT_WDONE 400000 #define TIMO_WAIT_WIDLE 300000 #define TIMO_WAIT_CMD 100000 #define TIMO_WAIT_WDATA 30000 #define TIMO_READ 90000 #define TIMO_SEND_OP 8000 #define TIMO_CMD 7000 #define TIMO_SEND_CSD 6000 #define TIMO_WAIT_WSTOP 5000 #define sdunit(dev) ((minor(dev) & 8) >> 3) #define sdpart(dev) ((minor(dev) & 7)) #define RAWPART 0 /* 'x' partition */ #define NPARTITIONS 4 /* * Driver's data per disk drive. */ struct disk { /* * Partition table. */ struct diskpart part[NPARTITIONS+1]; /* * Card type. */ int card_type; #define TYPE_UNKNOWN 0 #define TYPE_SD_LEGACY 1 #define TYPE_SD_II 2 #define TYPE_SDHC 3 struct spiio spiio; /* interface to SPI port */ int label_writable; /* is sector 0 writable? */ int dkindex; /* disk index for statistics */ u_int openpart; /* all partitions open on this drive */ u_char ocr[4]; /* operation condition register */ u_char csd[16]; /* card-specific data */ u_short group[6]; /* function group bitmasks */ int ma; /* power consumption */ }; struct disk sddrives[NSD]; /* Table of units */ int sd_timo_cmd; /* Max timeouts, for sysctl */ int sd_timo_send_op; int sd_timo_send_csd; int sd_timo_read; int sd_timo_wait_cmd; int sd_timo_wait_wdata; int sd_timo_wait_wdone; int sd_timo_wait_wstop; int sd_timo_wait_widle; /* * Definitions for MMC/SDC commands. */ #define CMD_GO_IDLE 0 /* CMD0 */ #define CMD_SEND_OP_MMC 1 /* CMD1 (MMC) */ #define CMD_SWITCH_FUNC 6 #define CMD_SEND_IF_COND 8 #define CMD_SEND_CSD 9 #define CMD_SEND_CID 10 #define CMD_STOP 12 #define CMD_SEND_STATUS 13 /* CMD13 */ #define CMD_SET_BLEN 16 #define CMD_READ_SINGLE 17 #define CMD_READ_MULTIPLE 18 #define CMD_SET_BCOUNT 23 /* (MMC) */ #define CMD_SET_WBECNT 23 /* ACMD23 (SDC) */ #define CMD_WRITE_SINGLE 24 #define CMD_WRITE_MULTIPLE 25 #define CMD_SEND_OP_SDC 41 /* ACMD41 (SDC) */ #define CMD_APP 55 /* CMD55 */ #define CMD_READ_OCR 58 #define DATA_START_BLOCK 0xFE /* start data for single block */ #define STOP_TRAN_TOKEN 0xFD /* stop token for write multiple */ #define WRITE_MULTIPLE_TOKEN 0xFC /* start data for write multiple */ /* * Release the card's /CS signal. * Add extra clocks after a deselect. */ static void card_release(struct spiio *io) { spi_deselect(io); spi_transfer(io, 0xFF); } /* * Wait while busy, up to 300 msec. */ static void card_wait_ready(int unit, int limit, int *maxcount) { int i; struct spiio *io = &sddrives[unit].spiio; spi_transfer(io, 0xFF); for (i=0; i> 24); spi_transfer(io, addr >> 16); spi_transfer(io, addr >> 8); spi_transfer(io, addr); /* Send cmd checksum for CMD_GO_IDLE. * For all other commands, CRC is ignored. */ if (cmd == CMD_GO_IDLE) spi_transfer(io, 0x95); else if (cmd == CMD_SEND_IF_COND) spi_transfer(io, 0x87); else spi_transfer(io, 0xFF); /* Wait for a response. */ for (i=0; icard_type = TYPE_UNKNOWN; do { /* Unselect the card. */ card_release(io); /* Send 80 clock cycles for start up. */ for (i=0; i<10; i++) spi_transfer(io, 0xFF); /* Select the card and send a single GO_IDLE command. */ spi_select(io); timeout--; reply = card_cmd(unit, CMD_GO_IDLE, 0); } while (reply != 1 && timeout != 0); card_release(io); if (reply != 1) { /* It must return Idle. */ return 0; } /* Check SD version. */ spi_select(io); reply = card_cmd(unit, CMD_SEND_IF_COND, 0x1AA); if (reply & 4) { /* Illegal command: card type 1. */ card_release(io); du->card_type = TYPE_SD_LEGACY; } else { u_char response[4]; response[0] = spi_transfer(io, 0xFF); response[1] = spi_transfer(io, 0xFF); response[2] = spi_transfer(io, 0xFF); response[3] = spi_transfer(io, 0xFF); card_release(io); if (response[3] != 0xAA) { printf("sd%d: cannot detect card type, response=%02x-%02x-%02x-%02x\n", unit, response[0], response[1], response[2], response[3]); return 0; } du->card_type = TYPE_SD_II; } /* Send repeatedly SEND_OP until Idle terminates. */ for (i=0; ; i++) { spi_select(io); card_cmd(unit, CMD_APP, 0); reply = card_cmd(unit, CMD_SEND_OP_SDC, (du->card_type == TYPE_SD_II) ? 0x40000000 : 0); spi_select(io); if (reply == 0) break; if (i >= TIMO_SEND_OP) { /* Init timed out. */ printf("card_init: SEND_OP timed out, reply = %d\n", reply); return 0; } } if (sd_timo_send_op < i) sd_timo_send_op = i; /* If SD2 read OCR register to check for SDHC card. */ if (du->card_type == TYPE_SD_II) { spi_select(io); reply = card_cmd(unit, CMD_READ_OCR, 0); if (reply != 0) { card_release(io); printf("sd%d: READ_OCR failed, reply=%02x\n", unit, reply); return 0; } du->ocr[0] = spi_transfer(io, 0xFF); du->ocr[1] = spi_transfer(io, 0xFF); du->ocr[2] = spi_transfer(io, 0xFF); du->ocr[3] = spi_transfer(io, 0xFF); card_release(io); if ((du->ocr[0] & 0xC0) == 0xC0) { du->card_type = TYPE_SDHC; } } /* Fast speed. */ spi_brg(io, SD_MHZ * 1000); return 1; } /* * Get disk size in 512-byte sectors. * Return nonzero if successful. */ static int card_size(int unit) { unsigned csize, n; int reply, i; int nsectors; struct spiio *io = &sddrives[unit].spiio; struct disk *du = &sddrives[unit]; spi_select(io); reply = card_cmd(unit, CMD_SEND_CSD, 0); if (reply != 0) { /* Command rejected. */ card_release(io); return 0; } /* Wait for a response. */ for (i=0; ; i++) { reply = spi_transfer(io, 0xFF); if (reply == DATA_START_BLOCK) break; if (i >= TIMO_SEND_CSD) { /* Command timed out. */ card_release(io); printf("sd%d: card_size: SEND_CSD timed out, reply = %d\n", unit, reply); return 0; } } if (sd_timo_send_csd < i) sd_timo_send_csd = i; /* Read data. */ for (i=0; i<16; i++) { du->csd[i] = spi_transfer(io, 0xFF); } /* Ignore CRC. */ spi_transfer(io, 0xFF); spi_transfer(io, 0xFF); /* Disable the card. */ card_release(io); /* CSD register has different structure * depending upon protocol version. */ switch (du->csd[0] >> 6) { case 1: /* SDC ver 2.00 */ csize = du->csd[9] + (du->csd[8] << 8) + 1; nsectors = csize << 10; break; case 0: /* SDC ver 1.XX or MMC. */ n = (du->csd[5] & 15) + ((du->csd[10] & 128) >> 7) + ((du->csd[9] & 3) << 1) + 2; csize = (du->csd[8] >> 6) + (du->csd[7] << 2) + ((du->csd[6] & 3) << 10) + 1; nsectors = csize << (n - 9); break; default: /* Unknown version. */ return 0; } return nsectors; } /* * Use CMD6 to enable high-speed mode. */ static void card_high_speed(int unit) { int reply, i; struct spiio *io = &sddrives[unit].spiio; struct disk *du = &sddrives[unit]; unsigned char status[64]; /* Here we set HighSpeed 50MHz. * We do not tackle the power and io driver strength yet. */ spi_select(io); reply = card_cmd(unit, CMD_SWITCH_FUNC, 0x80000001); if (reply != 0) { /* Command rejected. */ card_release(io); return; } /* Wait for a response. */ for (i=0; ; i++) { reply = spi_transfer(io, 0xFF); if (reply == DATA_START_BLOCK) break; if (i >= 5000) { /* Command timed out. */ card_release(io); printf("sd%d: card_size: SWITCH_FUNC timed out, reply = %d\n", unit, reply); return; } } /* Read 64-byte status. */ for (i=0; i<64; i++) status[i] = spi_transfer(io, 0xFF); card_release(io); if ((status[16] & 0xF) == 1) { /* The card has switched to high-speed mode. */ spi_brg(io, SD_FAST_MHZ * 1000); } /* Save function group information for later use. */ du->ma = status[0] << 8 | status[1]; du->group[0] = status[12] << 8 | status[13]; du->group[1] = status[10] << 8 | status[11]; du->group[2] = status[8] << 8 | status[9]; du->group[3] = status[6] << 8 | status[7]; du->group[4] = status[4] << 8 | status[5]; du->group[5] = status[2] << 8 | status[3]; printf("sd%d: function groups %x/%x/%x/%x/%x/%x", unit, du->group[0] & 0x7fff, du->group[1] & 0x7fff, du->group[2] & 0x7fff, du->group[3] & 0x7fff, du->group[4] & 0x7fff, du->group[5] & 0x7fff); if (du->ma > 0) printf(", max current %u mA", du->ma); printf("\n"); } /* * Read a block of data. * Return nonzero if successful. */ static int card_read(int unit, unsigned int offset, char *data, unsigned int bcount) { int reply, i; struct spiio *io = &sddrives[unit].spiio; struct disk *du = &sddrives[unit]; /* Send read-multiple command. */ spi_select(io); if (du->card_type != TYPE_SDHC) offset <<= 9; reply = card_cmd(unit, CMD_READ_MULTIPLE, offset<<1); if (reply != 0) { /* Command rejected. */ printf("sd%d: card_read: bad READ_MULTIPLE reply = %d, offset = %08x\n", unit, reply, offset<<1); card_release(io); return 0; } again: /* Wait for a response. */ for (i=0; ; i++) { int x = spl0(); reply = spi_transfer(io, 0xFF); splx(x); if (reply == DATA_START_BLOCK) break; if (i >= TIMO_READ) { /* Command timed out. */ printf("sd%d: card_read: READ_MULTIPLE timed out, reply = %d\n", unit, reply); card_release(io); return 0; } } if (sd_timo_read < i) sd_timo_read = i; /* Read data. */ if (bcount >= SECTSIZE) { spi_bulk_read_32_be(io, SECTSIZE, data); data += SECTSIZE; } else { spi_bulk_read(io, bcount, (unsigned char *)data); data += bcount; for (i=bcount; i SECTSIZE) { /* Next sector. */ bcount -= SECTSIZE; goto again; } /* Stop a read-multiple sequence. */ card_cmd(unit, CMD_STOP, 0); card_release(io); return 1; } /* * Write a block of data. * Return nonzero if successful. */ static int card_write(int unit, unsigned offset, char *data, unsigned bcount) { unsigned reply, i; struct spiio *io = &sddrives[unit].spiio; struct disk *du = &sddrives[unit]; /* Send pre-erase count. */ spi_select(io); card_cmd(unit, CMD_APP, 0); reply = card_cmd(unit, CMD_SET_WBECNT, (bcount + SECTSIZE - 1) / SECTSIZE); if (reply != 0) { /* Command rejected. */ card_release(io); printf("sd%d: card_write: bad SET_WBECNT reply = %02x, count = %u\n", unit, reply, (bcount + SECTSIZE - 1) / SECTSIZE); return 0; } /* Send write-multiple command. */ if (du->card_type != TYPE_SDHC) offset <<= 9; reply = card_cmd(unit, CMD_WRITE_MULTIPLE, offset<<1); if (reply != 0) { /* Command rejected. */ card_release(io); printf("sd%d: card_write: bad WRITE_MULTIPLE reply = %02x\n", unit, reply); return 0; } card_release(io); again: /* Select, wait while busy. */ spi_select(io); card_wait_ready(unit, TIMO_WAIT_WDATA, &sd_timo_wait_wdata); /* Send data. */ spi_transfer(io, WRITE_MULTIPLE_TOKEN); if (bcount >= SECTSIZE) { spi_bulk_write_32_be(io, SECTSIZE, data); data += SECTSIZE; } else { spi_bulk_write(io, bcount, (unsigned char *)data); data += bcount; for (i=bcount; i SECTSIZE) { /* Next sector. */ bcount -= SECTSIZE; goto again; } /* Stop a write-multiple sequence. */ spi_select(io); card_wait_ready(unit, TIMO_WAIT_WSTOP, &sd_timo_wait_wstop); spi_transfer(io, STOP_TRAN_TOKEN); card_wait_ready(unit, TIMO_WAIT_WIDLE, &sd_timo_wait_widle); card_release(io); return 1; } /* * Detect a card. */ static int sd_setup(int unit) { struct spiio *io = &sddrives[unit].spiio; struct disk *du = &sddrives[unit]; u_short buf[256]; #ifdef SD0_ENA_PORT /* On Duinomite Mega board, pin B13 set low * enables a +3.3V power to SD card. */ if (unit == 0) { LAT_CLR(SD0_ENA_PORT) = 1 << SD0_ENA_PIN; udelay(1000); } #endif #ifdef SD1_ENA_PORT /* On Duinomite Mega board, pin B13 set low * enables a +3.3V power to SD card. */ if (unit == 1) { LAT_CLR(SD1_ENA_PORT) = 1 << SD1_ENA_PIN; udelay(1000); } #endif if (! card_init(unit)) { printf("sd%d: no SD/MMC card detected\n", unit); return 0; } /* Get the size of raw partition. */ bzero(du->part, sizeof(du->part)); du->part[RAWPART].dp_offset = 0; du->part[RAWPART].dp_nsectors = card_size(unit); if (du->part[RAWPART].dp_nsectors == 0) { printf("sd%d: cannot get card size\n", unit); return 0; } /* Switch to the high speed mode, if possible. */ if (du->csd[4] & 0x40) { /* Class 10 card: switch to high-speed mode. * SPI interface of pic32 allows up to 25MHz clock rate. */ card_high_speed(unit); } printf("sd%d: type %s, size %u kbytes, speed %u Mbit/sec\n", unit, (du->card_type == TYPE_SDHC) ? "SDHC" : (du->card_type == TYPE_SD_II) ? "II" : "I", du->part[RAWPART].dp_nsectors / 2, spi_get_brg(io) / 1000); /* Read partition table. */ int s = splbio(); if (! card_read(unit, 0, (char*)buf, sizeof(buf))) { splx(s); printf("sd%d: cannot read partition table\n", unit); return 0; } splx(s); if (buf[255] == MBR_MAGIC) { bcopy(&buf[223], &du->part[1], 64); #if 1 int i; for (i=1; i<=NPARTITIONS; i++) { if (du->part[i].dp_type != 0) printf("sd%d%c: partition type %02x, sector %u, size %u kbytes\n", unit, i+'a'-1, du->part[i].dp_type, du->part[i].dp_offset, du->part[i].dp_nsectors / 2); } #endif } return 1; } /* * Disable power to the SD card. */ static void sd_release(int unit) { struct disk *du = &sddrives[unit]; /* Forget the partition table. */ du->part[RAWPART].dp_nsectors = 0; #ifdef SD0_ENA_PORT /* On Duinomite Mega board, pin B13 set low * enables a +3.3V power to SD card. */ if (unit == 0) { /* Enable SD0 phy - pin is assumed to be active low */ TRIS_CLR(SD0_ENA_PORT) = 1 << SD0_ENA_PIN; LAT_SET(SD0_ENA_PORT) = 1 << SD0_ENA_PIN; udelay(1000); } #endif #ifdef SD1_ENA_PORT /* On Duinomite Mega board, pin B13 set low * enables a +3.3V power to SD card. */ if (unit == 1) { /* Enable SD1 phy - pin is assumed to be active low */ TRIS_CLR(SD1_ENA_PORT) = 1 << SD1_ENA_PIN; LAT_SET(SD1_ENA_PORT) = 1 << SD1_ENA_PIN; udelay(1000); } #endif } int sdopen(dev_t dev, int flags, int mode) { int unit = sdunit(dev); int part = sdpart(dev); struct disk *du = &sddrives[unit]; unsigned mask, i; if (unit >= NSD || part > NPARTITIONS) return ENXIO; /* * Setup the SD card interface. */ if (du->part[RAWPART].dp_nsectors == 0) { if (! sd_setup(unit)) { return ENODEV; } } mask = 1 << part; /* * Warn if a partion is opened * that overlaps another partition which is open * unless one is the "raw" partition (whole disk). */ if (part != RAWPART && (du->openpart & mask) == 0) { unsigned start = du->part[part].dp_offset; unsigned end = start + du->part[part].dp_nsectors; /* Check for overlapped partitions. */ for (i=0; i<=NPARTITIONS; i++) { struct diskpart *pp = &du->part[i]; if (i == part || i == RAWPART) continue; if (pp->dp_offset + pp->dp_nsectors <= start || pp->dp_offset >= end) continue; if (du->openpart & (1 << i)) printf("sd%d%c: overlaps open partition (sd%d%c)\n", unit, part + 'a' - 1, unit, pp - du->part + 'a' - 1); } } du->openpart |= mask; return 0; } int sdclose(dev_t dev, int mode, int flag) { int unit = sdunit(dev); int part = sdpart(dev); struct disk *du = &sddrives[unit]; if (unit >= NSD || part > NPARTITIONS) return ENODEV; du->openpart &= ~(1 << part); if (du->openpart == 0) { /* All partitions closed. * Release the SD card. */ sd_release(unit); } return 0; } /* * Get disk size in kbytes. * Return nonzero if successful. */ daddr_t sdsize(dev_t dev) { int unit = sdunit(dev); int part = sdpart(dev); struct disk *du = &sddrives[unit]; if (unit >= NSD || part > NPARTITIONS || du->openpart == 0) return 0; return du->part[part].dp_nsectors >> 1; } void sdstrategy(struct buf *bp) { int unit = sdunit(bp->b_dev); struct disk *du = &sddrives[unit]; struct diskpart *p = &du->part[sdpart(bp->b_dev)]; int part_size = p->dp_nsectors >> 1; int offset = bp->b_blkno; long nblk = btod(bp->b_bcount); int s; /* * Determine the size of the transfer, and make sure it is * within the boundaries of the partition. */ offset += p->dp_offset >> 1; if (offset == 0 && ! (bp->b_flags & B_READ) && ! du->label_writable) { /* Write to partition table not allowed. */ bp->b_error = EROFS; bad: bp->b_flags |= B_ERROR; biodone(bp); return; } if (bp->b_blkno + nblk > part_size) { /* if exactly at end of partition, return an EOF */ if (bp->b_blkno == part_size) { bp->b_resid = bp->b_bcount; biodone(bp); return; } /* or truncate if part of it fits */ nblk = part_size - bp->b_blkno; if (nblk <= 0) { bp->b_error = EINVAL; goto bad; } bp->b_bcount = nblk << DEV_BSHIFT; } if (bp->b_dev == swapdev) { led_control(LED_SWAP, 1); } else { led_control(LED_DISK, 1); } s = splbio(); #ifdef UCB_METER if (du->dkindex >= 0) { dk_busy |= 1 << du->dkindex; dk_xfer[du->dkindex]++; dk_bytes[du->dkindex] += bp->b_bcount; } #endif if (bp->b_flags & B_READ) { card_read(unit, offset, bp->b_addr, bp->b_bcount); } else { card_write(unit, offset, bp->b_addr, bp->b_bcount); } biodone(bp); if (bp->b_dev == swapdev) { led_control(LED_SWAP, 0); } else { led_control(LED_DISK, 0); } #ifdef UCB_METER if (du->dkindex >= 0) dk_busy &= ~(1 << du->dkindex); #endif splx(s); } int sdioctl(dev_t dev, u_int cmd, caddr_t addr, int flag) { int unit = sdunit(dev); int part = sdpart(dev); struct diskpart *dp; int i, error = 0; switch (cmd) { case DIOCGETMEDIASIZE: /* Get disk size in kbytes. */ dp = &sddrives[unit].part[part]; *(int*) addr = dp->dp_nsectors >> 1; break; case DIOCREINIT: for (i=0; i<=NPARTITIONS; i++) bflush(makedev(major(dev), i)); sd_setup(unit); break; case DIOCGETPART: /* Get partition table entry. */ dp = &sddrives[unit].part[part]; *(struct diskpart*) addr = *dp; break; default: error = EINVAL; break; } return error; } /* * Test to see if device is present. * Return true if found and initialized ok. */ static int sd_probe(config) struct conf_device *config; { int unit = config->dev_unit; int cs = config->dev_pins[0]; struct spiio *io = &sddrives[unit].spiio; const char *ctlr_name = config->dev_cdriver->d_name; int ctlr_num = config->dev_ctlr; if (unit < 0 || unit >= NSD) return 0; printf("sd%u: port %s%d, pin cs=R%c%d\n", unit, ctlr_name, ctlr_num, gpio_portname(cs), gpio_pinno(cs)); if (spi_setup(io, ctlr_num, cs) != 0) { printf("sd%u: cannot open %s%u port\n", unit, ctlr_name, ctlr_num); return 0; } /* Disable power to the SD card. */ sd_release(unit); spi_brg(io, 250); spi_set(io, PIC32_SPICON_CKE); #ifdef UCB_METER dk_alloc(&sddrives[unit].dkindex, 1, (unit == 0) ? "sd0" : "sd1"); #endif return 1; } struct driver sddriver = { "sd", sd_probe, }; ================================================ FILE: sys/arch/pic32/dev/sd.h ================================================ #ifndef _SD_H #define _SD_H #ifdef KERNEL extern int sdopen(dev_t dev, int flag, int mode); extern int sdclose(dev_t dev, int flag, int mode); extern daddr_t sdsize(dev_t dev); extern void sdstrategy(struct buf *bp); extern int sdioctl (dev_t dev, u_int cmd, caddr_t addr, int flag); #endif #endif ================================================ FILE: sys/arch/pic32/dev/sdram.S ================================================ /* * SDRAM Access Routines for PIC32. * * Retromaster - 10.05.2010 * * This file is in the public domain. You can use, modify, and distribute the source code * and executable programs based on the source code. This file is provided "as is" and * without any express or implied warranties whatsoever. Use at your own risk! * * Changes by jmcgee for inclusion in the retrobsd project. */ /* SDRAM Used: HY57V281620 */ /* * See rd_sdramp_config.h for sdramp port/pin configuration */ #include /* Offsets (from TRISA) for the various port control registers */ #define TRIS_OFFSET 0x0 #define PORT_OFFSET (PORTA-TRISA) #define LAT_OFFSET (LATA-TRISA) #define ODCF_OFFSET (ODCA-TRISA) /* Offsets (from TRISA) for the various io port bit manipulator registers */ #define NOP_OP_OFFSET 0x0 #define CLR_OP_OFFSET (TRISACLR-TRISA) #define SET_OP_OFFSET (TRISASET-TRISA) #define INV_OP_OFFSET (TRISAINV-TRISA) /* Global Symbols */ .globl sdram_init .globl sdram_read .globl sdram_write .globl sdram_active .globl sdram_auto_refresh .globl sdram_precharge .globl sdram_precharge_all .globl sdram_sleep .globl sdram_wake .globl sdram_bank .type sdram_init, @function .type sdram_read, @function .type sdram_write, @function .type sdram_active, @function .type sdram_auto_refresh, @function .type sdram_precharge, @function .type sdram_precharge_all, @function .type sdram_sleep, @function .type sdram_wake, @function .type sdram_bank, @function /* * This code MUST execute from ram and the ram MUST be configured * for zero wait states. Interrupts MUST disabled before * calling any of these functions, and any DMA MUST also be * disabled. * * Also, the peripheral bus divisor must be set to 1. */ .section .ramfunc,"ax",@progbits /* No instruction reordering */ .set noreorder #define clock4 nop;nop;nop;nop #define clock3 nop;nop;nop #define clock2 nop;nop #define clock1 nop /* * The SDRAM clock is output from the output compare unit. * This macro synchronizes with that clock so that we are * sure to have at least two clock cycles to issue control * line changes and access the data bus before the rising * edge. */ #define sync_clock \ la $t8, TMR2; \ li $v0, 2; \ lw $v1, ($t8); \ bge $v1, $v0, 1f; \ nop; \ nop; \ nop; \ 1: \ nop; /* * Initializes the SDRAM. * Should be called once sometime after startup * C Prototype: * extern __attribute__((far)) void sdram_init(); * This should only be called from sdram_init_c, * which does all of the preliminary setup. */ sdram_init: /* Initialize address lines */ la $t0, TRISA /* base of io addresses */ /* Get ready for the commands we are about to issue. */ li $t4, (1< #include #include #include #include #include #include #include #include #include /* * See rd_sdramp_config.h for sdramp port/pin configuration */ #include int sdramp_dkindex = -1; /* Statistics slot number */ /* * physical specs of SDRAM chip */ #define RAM_COLS 512 #if SDR_ADDRESS_LINES == 13 #define RAM_ROWS (4096*2) #elif SDR_ADDRESS_LINES == 12 #define RAM_ROWS 4096 #elif SDR_ADDRESS_LINES == 11 #define RAM_ROWS 2048 #else #error Invalid Configuration - SDR_ADDRESS_LINES #endif #define RAM_BANKS 4 /* * RAM_BURST_COUNT MUST be match the number of bytes * read/written by each call to sdram_read/sdram_write */ #define RAM_BURST_COUNT 8 /* * CHUNK_SIZE number of bytes in each "chunk" */ #define CHUNK_SIZE 32 #define RAM_BURST_GROUP_COUNT 4 #define BLOCKS_PER_ROW (RAM_COLS / CHUNK_SIZE) /* * Size of the whole disk in kbytes. */ #define SDR_TOTAL_KBYTES ((1<partitions[n].type = t; \ m->partitions[n].lbastart = s; \ m->partitions[n].lbalength = l; // FIXME - FOLLOWING shared with gpio.c - needs to be made common struct ocreg { volatile unsigned con; /* ? */ volatile unsigned conclr; volatile unsigned conset; volatile unsigned coninv; volatile unsigned r; /* ? */ volatile unsigned rclr; volatile unsigned rset; volatile unsigned rinv; volatile unsigned rs; /* ? */ volatile unsigned rsclr; volatile unsigned rsset; volatile unsigned rsinv; }; static void sdram_bank_c(unsigned bank) { // In order to keep unnecessary noise from occuring on the // address lines, don't use the hardware set/clear functions. // Rather, read the latch value, change it, and write it back. struct gpioreg * bankport = (struct gpioreg *)&SDR_BANK_PORT; unsigned v = bankport->lat; v &= ~(BANK_BITMASK << SDR_BANK_0_BIT); v |= (bank & BANK_BITMASK) << SDR_BANK_0_BIT; bankport->lat = v; } static void sdram_upperlowerbyte(unsigned bit) { struct gpioreg * dqm_port = (struct gpioreg *)&SDR_DQM_PORT; #ifdef SDR_DQM_UDQM_BIT if (bit == 0) { dqm_port->latset = (1<latclr = (1<latset = (1<latclr = (1<latset = (1<latclr = (1<latclr = (1<latclr = (1<<13) | (1<<8); address_lb_port->trisclr = (1<<13) | (1<<8); address_lb_port->trisclr = ADDRESS_LB_MASK; address_port->trisclr = ADDRESS_MASK; /* AD1PCFGSET = 0xFFFF; */ bank_port->trisclr = BANK_ALL_MASK; #ifdef SDR_DQM_UDQM_BIT dqm_port->latset = (1<latclr = (1<trisclr = SDR_DQM_MASK; /* All address lines low */ address_lb_port->latclr = ADDRESS_LB_MASK; address_port->latclr = ADDRESS_MASK; bank_port->latclr = BANK_ALL_MASK; /* Initialize data lines */ data_port->trisset = 0xff; /* Initialize SDRAM control lines */ control_port->trisclr = CONTROL_ALL_MASK; /* Command Inhibit */ control_port->latset = CONTROL_ALL_MASK; /* Initialize CKE line */ cke_port->trisclr = (1<latclr = (1<latset = (1<trisclr = (1<con = 0; ocr_reg->rs = 1; ocr_reg->r = 3; ocr_reg->con = 0x8005; /* Clock output starts here */ /* SD-RAM initialization delay */ unsigned cc_start, cc_now; asm volatile("mfc0 %0, $9" : "=r" (cc_start)); do { asm volatile("mfc0 %0, $9" : "=r" (cc_now)); } while (cc_now - cc_start < 500); /* CKE high */ cke_port->latset = (1<lat = (address_lb_port->lat & ~ADDRESS_LB_MASK) | ((addr & 0x7) << SDR_ADDRESS_LB_A0_BIT); address_port->lat = (address_port->lat & ~ADDRESS_MASK) | ((addr & (ADDRESS_MASK<<(3-SDR_ADDRESS_A3_BIT))) >> (3-SDR_ADDRESS_A3_BIT)); } static void sdram_active_c(unsigned row_address) { sdram_output_addr(row_address); sdram_active(); } static void sdram_write_c(uint16_t coladdr, uint64_t val) { sdram_output_addr(coladdr); sdram_write(val); } static uint64_t sdram_read_c(uint16_t coladdr) { sdram_output_addr(coladdr); return sdram_read(); } static void read_chunk_from_sdram(uint64_t* dest, unsigned int blockNumber) { int startColumn = (blockNumber & (BLOCKS_PER_ROW - 1)) * CHUNK_SIZE; // / RAM_BURST_COUNT; int rowAndBank = blockNumber / BLOCKS_PER_ROW; int row = rowAndBank & (RAM_ROWS - 1); int bank = rowAndBank / RAM_ROWS; int sbank = bank / 4; bank = bank & 0b011; int col = startColumn; sdram_upperlowerbyte(sbank); while (col < startColumn + CHUNK_SIZE/*/RAM_BURST_COUNT*/) { int x = mips_intr_disable(); sdram_wake(); sdram_bank_c(bank); sdram_active_c(row); int i; for (i = 0; i < RAM_BURST_GROUP_COUNT; i++) { *dest++ = sdram_read_c(col); col += RAM_BURST_COUNT; } sdram_precharge(); sdram_precharge_all(); sdram_sleep(); mips_intr_restore (x); asm volatile ("nop"); } } static void write_chunk_to_sdram(uint64_t* src, unsigned int blockNumber) { int startColumn = (blockNumber & (BLOCKS_PER_ROW - 1)) * CHUNK_SIZE; /// RAM_BURST_COUNT; int rowAndBank = blockNumber / BLOCKS_PER_ROW; int row = rowAndBank & (RAM_ROWS - 1); int bank = rowAndBank / RAM_ROWS; int sbank = bank / 4; bank = bank & 0b011; sdram_upperlowerbyte(sbank); int col = startColumn; while (col < startColumn + CHUNK_SIZE /*/RAM_BURST_COUNT*/) { int x = mips_intr_disable(); sdram_wake(); sdram_bank_c(bank); sdram_active_c(row); int i; for (i = 0; i < RAM_BURST_GROUP_COUNT; i++) { sdram_write_c(col, *src++); col += RAM_BURST_COUNT; } sdram_precharge(); sdram_precharge_all(); sdram_sleep(); mips_intr_restore (x); asm volatile ("nop"); } } /* * Read a block of data. */ static int sdramp_read(unsigned blockno, char* data, unsigned nbytes) { blockno = blockno * (DEV_BSIZE/CHUNK_SIZE); while (nbytes >= CHUNK_SIZE) { read_chunk_from_sdram((uint64_t*) swaptemp, blockno); bcopy(swaptemp, data, CHUNK_SIZE); data += CHUNK_SIZE; blockno += 1; nbytes -= CHUNK_SIZE; } if (nbytes) { read_chunk_from_sdram((uint64_t*) swaptemp, blockno); bcopy(swaptemp, data, nbytes); } return 1; } /* * Write a block of data. */ static int sdramp_write (unsigned blockno, char *data, unsigned nbytes) { blockno = blockno * (DEV_BSIZE/CHUNK_SIZE); while (nbytes >= CHUNK_SIZE) { bcopy(data, swaptemp, CHUNK_SIZE); int x = mips_intr_disable(); write_chunk_to_sdram((uint64_t*) swaptemp, blockno); mips_intr_restore(x); data += CHUNK_SIZE; blockno += 1; nbytes -= CHUNK_SIZE; } if (nbytes) { read_chunk_from_sdram((uint64_t*) swaptemp, blockno); bcopy(data, swaptemp, nbytes); int x = mips_intr_disable(); write_chunk_to_sdram((uint64_t*) swaptemp, blockno); mips_intr_restore(x); } return 1; } int sdramp_open(dev_t dev, int flag, int mode) { return 0; } int sdramp_close(dev_t dev, int flag, int mode) { return 0; } /* * Return a size of partition in kbytes. * The memory is divided into two partitions: A and B. * Size of partition B is specified in the kernel config file * as option SDR_SWAP_KBYTES. */ daddr_t sdramp_size(dev_t dev) { switch (minor(dev)) { case 0: /* Whole disk. */ return SDR_TOTAL_KBYTES; case 1: /* Partition A: filesystem. */ return SDR_TOTAL_KBYTES - SDR_SWAP_KBYTES; case 2: default: /* Partition B: swap space. */ return SDR_SWAP_KBYTES; } } void sdramp_strategy(struct buf *bp) { int offset = bp->b_blkno; long nblk = btod(bp->b_bcount); int part_offset, part_size, s; /* Compute partition size and offset. */ part_size = sdramp_size(bp->b_dev); if (minor(bp->b_dev) < 2) { /* Partition A or a whole disk. */ part_offset = 0; } else { /* Partition B: swap space. */ part_offset = SDR_TOTAL_KBYTES - part_size; } /* * Determine the size of the transfer, and make sure it is * within the boundaries of the partition. */ offset += part_offset; if (bp->b_blkno + nblk > part_size) { /* if exactly at end of partition, return an EOF */ if (bp->b_blkno == part_size) { bp->b_resid = bp->b_bcount; biodone(bp); return; } /* or truncate if part of it fits */ nblk = part_size - bp->b_blkno; if (nblk <= 0) { bp->b_error = EINVAL; bp->b_flags |= B_ERROR; biodone(bp); return; } bp->b_bcount = nblk << DEV_BSHIFT; } if (bp->b_dev == swapdev) { led_control(LED_SWAP, 1); } else { led_control(LED_DISK, 1); } s = splbio(); #ifdef UCB_METER if (sdramp_dkindex >= 0) { dk_busy |= 1 << sdramp_dkindex; dk_xfer[sdramp_dkindex]++; dk_bytes[sdramp_dkindex] += bp->b_bcount; } #endif if (bp->b_flags & B_READ) { sdramp_read(offset, bp->b_addr, bp->b_bcount); } else { sdramp_write(offset, bp->b_addr, bp->b_bcount); } biodone(bp); if (bp->b_dev == swapdev) { led_control(LED_SWAP, 0); } else { led_control(LED_DISK, 0); } #ifdef UCB_METER if (sdramp_dkindex >= 0) dk_busy &= ~(1 << sdramp_dkindex); #endif splx(s); } int sdramp_ioctl(dev_t dev, u_int cmd, caddr_t addr, int flag) { int error = 0; switch (cmd) { case DIOCGETMEDIASIZE: /* Get disk size in kbytes. */ *(int*) addr = sdramp_size(dev); break; default: error = EINVAL; break; } return error; } /* * Test to see if device is present. * Return true if found and initialized ok. */ static int sdrampprobe(config) struct conf_device *config; { /* Only one device unit is supported. */ if (config->dev_unit != 0) return 0; printf("dr0: total %u kbytes, swap space %u kbytes\n", SDR_TOTAL_KBYTES, SDR_SWAP_KBYTES); int x = mips_intr_disable(); sdram_init_c(); mips_intr_restore(x); #ifdef UCB_METER dk_alloc(&sdramp_dkindex, 1, "dr0"); #endif return 1; } struct driver sdrampdriver = { "sdramp", sdrampprobe, }; ================================================ FILE: sys/arch/pic32/dev/sdramp.h ================================================ #ifndef _SDRAMP_H #define _SDRAMP_H #ifdef KERNEL extern int sdramp_open(dev_t dev, int flag, int mode); extern int sdramp_close(dev_t dev, int flag, int mode); extern daddr_t sdramp_size(dev_t dev); extern void sdramp_strategy(struct buf *bp); extern int sdramp_ioctl (dev_t dev, u_int cmd, caddr_t addr, int flag); #endif #endif ================================================ FILE: sys/arch/pic32/dev/sdramp_config.h ================================================ #ifndef RD_SDRAMP_CONFIG_H_ #include /* TODO: better support for different sized sdram chips, 16 bit support */ /* * Number of physical address lines on sdram chip * one of 11, 12, 13 */ #define SDR_ADDRESS_LINES 12 /* * Ram data width in bytes - 1 (8 bit) or 2 (16 bit) * * NOT USED YET */ #define SDR_DATA_BYTES 2 /* * Upper/Lower Byte selection */ #define SDR_DQM_PORT TRISA #if SDR_DATA_BYTES == 2 #define SDR_DQM_UDQM_BIT 6 #endif #define SDR_DQM_LDQM_BIT 7 /* * Bank Selection * BA0 is connected to SDR_BANK_0_BIT * BA1 is connected to SDR_BANK_0_BIT + 1 * * So, if SDR_BANK_0_BIT is 4, then bit 5 * must be connected to BA1. */ #define SDR_BANK_PORT TRISG #define SDR_BANK_0_BIT 0 /* * Clock Enable * * Connect to CKE on sdram */ #define SDR_CKE_PORT TRISD #define SDR_CKE_BIT 11 /* * Control Lines * * Connect to /WE, /CAS, /CS and /RAS pins on sdram */ #define SDR_CONTROL_PORT TRISG #define SDR_CONTROL_WE_BIT 15 #define SDR_CONTROL_CAS_BIT 13 #define SDR_CONTROL_CS_BIT 14 #define SDR_CONTROL_RAS_BIT 12 /* * Address Lines * * At present, the port can be changed, but * changing the address line bits is unsupported. */ #define SDR_ADDRESS_LB_PORT TRISF #define SDR_ADDRESS_PORT TRISD /***** WARNING - DO NOT CHANGE WITHOUT ALSO CHANGING CODE TO MATCH *****/ #define SDR_ADDRESS_LB_A0_BIT 0 #define SDR_ADDRESS_LB_A1_BIT 1 #define SDR_ADDRESS_LB_A2_BIT 2 #define SDR_ADDRESS_A3_BIT 1 #define SDR_ADDRESS_A4_BIT 2 #define SDR_ADDRESS_A5_BIT 3 #define SDR_ADDRESS_A6_BIT 4 #define SDR_ADDRESS_A7_BIT 5 #define SDR_ADDRESS_A8_BIT 6 #define SDR_ADDRESS_A9_BIT 7 #if SDR_ADDRESS_LINES >= 11 #define SDR_ADDRESS_A10_BIT 8 #endif #if SDR_ADDRESS_LINES >= 12 #define SDR_ADDRESS_A11_BIT 9 #endif #if SDR_ADDRESS_LINES >= 13 #define SDR_ADDRESS_A12_BIT 10 #endif /***** END WARNING *****/ /* * Data Lines * * The low 8 bits (bits 0-7) must be used * and connected to the data lines on the sdram. * The specific order in which the 8 pins are * connected to the data pins of the sdram is * not significant, unless you wish for a neat * and tidy design that is easy connect to a * logic analyzer for debugging purposes. */ #define SDR_DATA_PORT TRISE /* * Output Compare * * Currently supporting OC1CON or OC4CON * Timer2 is used in all cases. * The appropriate pin should be connected to CLK on the sdram. * OC1CON - RD0 * OC4CON - RD3 */ #define SDR_OCR OC1CON /* * Additional sdram connections * * Power and ground as appropriate. */ /***************************************************************/ /* * Anthing following should not normally need to be modified. * There are here in order to share definitions between C and ASM. */ #ifdef SDR_ADDRESS_A10_BIT #define SDR_ADDRESS_A10_BITMASK (1< #include #include #include #include #include #include #define NSKEL 5 /* Ports 1...5 */ /* * To enable debug output, uncomment the first line. */ #define PRINTDBG printf #ifndef PRINTDBG # define PRINTDBG(...) /*empty*/ #endif /* * Open /dev/skel# device. */ int skeldev_open(dev_t dev, int flag, int mode) { int unit = minor(dev); if (unit >= NSKEL) return ENXIO; if (u.u_uid != 0) return EPERM; // TODO: initialize the port. PRINTDBG("--- %s() unit=%u, flag=%d, mode=%d\n", __func__, unit, flag, mode); return 0; } /* * Close device. */ int skeldev_close(dev_t dev, int flag, int mode) { int unit = minor(dev); if (u.u_uid != 0) return EPERM; // TODO: disable the port. PRINTDBG("--- %s() unit=%u, flag=%d, mode=%d\n", __func__, unit, flag, mode); return 0; } /* * Read data from device. */ int skeldev_read(dev_t dev, struct uio *uio, int flag) { int unit = minor(dev); // TODO: read data from port to user program. PRINTDBG("--- %s() unit=%u, flag=%d\n", __func__, unit, flag); return 0; } /* * Write data to device. */ int skeldev_write(dev_t dev, struct uio *uio, int flag) { int unit = minor(dev); // TODO: write data from user program to port. PRINTDBG("--- %s() unit=%u, flag=%d\n", __func__, unit, flag); return 0; } /* * Control operations: * SKELCTL_SETMODE - set device mode * SKELCTL_IO(n) - perform R/W transaction of n bytes */ int skeldev_ioctl(dev_t dev, u_int cmd, caddr_t addr, int flag) { int unit = minor(dev); int nbytes; PRINTDBG("--- %s() unit=%u, cmd=0x%08x, addr=0x%08x, flag=%d\n", __func__, unit, cmd, addr, flag); switch (cmd & ~(IOCPARM_MASK << 16)) { default: return ENODEV; case SKELCTL_SETMODE: // TODO: set device mode. PRINTDBG("--- SETMODE 0x%x\n", (unsigned) addr); return 0; case SKELCTL_IO(0): /* transfer n bytes */ nbytes = (cmd >> 16) & IOCPARM_MASK; if (baduaddr(addr) || baduaddr(addr + nbytes - 1)) return EFAULT; // TODO: transfer nbytes from device to addr. PRINTDBG("--- Transfer nbytes=%u to addr=0x%08x\n", addr); break; } return 0; } ================================================ FILE: sys/arch/pic32/dev/spi.c ================================================ /* * Generic SPI driver for PIC32. * * Copyright (C) 2012 Serge Vakulenko, * * Permission to use, copy, modify, and distribute this software * and its documentation for any purpose and without fee is hereby * granted, provided that the above copyright notice appear in all * copies and that both that the copyright notice and this * permission notice and warranty disclaimer appear in supporting * documentation, and that the name of the author not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * * The author disclaim all warranties with regard to this * software, including all implied warranties of merchantability * and fitness. In no event shall the author be liable for any * special, indirect or consequential damages or any damages * whatsoever resulting from loss of use, data or profits, whether * in an action of contract, negligence or other tortious action, * arising out of or in connection with the use or performance of * this software. */ #include #include #include #include #include #include #include #include #define NSPI 4 /* Ports SPI1...SPI4 */ /* * To enable debug output, uncomment the first line. */ //#define PRINTDBG printf #ifndef PRINTDBG # define PRINTDBG(...) /*empty*/ #endif struct spiio spi_io[NSPI]; /* Data for SPI driver */ /* * Open /dev/spi# device. * Use default SPI parameters: * - rate 250 kHz; * - no sleect pin. */ int spidev_open(dev_t dev, int flag, int mode) { int channel = minor(dev); struct spiio *io = &spi_io[channel]; if (channel >= NSPI) return ENXIO; if (u.u_uid != 0) return EPERM; if (! io->bus) return ENODEV; return 0; } int spidev_close(dev_t dev, int flag, int mode) { int channel = minor(dev); if (channel >= NSPI) return ENXIO; if (u.u_uid != 0) return EPERM; return 0; } int spidev_read(dev_t dev, struct uio *uio, int flag) { return 0; } int spidev_write(dev_t dev, struct uio *uio, int flag) { return 0; } /* * SPI control operations: * - SPICTL_SETMODE - set clock polarity and phase * - SPICTL_SETRATE - set data rate in kHz * - SPICTL_SETSELPIN - set select pin * - SPICTL_IO8(n) - n*8 bit RW transaction * - SPICTL_IO16(n) - n*16 bit RW transaction * - SPICTL_IO32(n) - n*32 bit RW transaction * - SPICTL_IO8R(n) - n*8 bit R transaction * - SPICTL_IO16R(n) - n*16 bit R transaction * - SPICTL_IO32R(n) - n*32 bit R transaction * - SPICTL_IO8W(n) - n*8 bit W transaction * - SPICTL_IO16W(n) - n*16 bit W transaction * - SPICTL_IO32W(n) - n*32 bit W transaction * - SPICTL_IO32RB(n) - n*32 bit RB transaction (B - swaps byte's order) * - SPICTL_IO32WB(n) - n*32 bit WB transaction * - SPICTL_IO32B(n) - n*32 bit B transaction */ int spidev_ioctl(dev_t dev, u_int cmd, caddr_t addr, int flag) { int channel = minor(dev); struct spiio *io = &spi_io[channel]; unsigned char *cval = (unsigned char *)addr; int nelem; static unsigned volatile *const tris[8] = { 0, &TRISA,&TRISB,&TRISC,&TRISD,&TRISE,&TRISF,&TRISG, }; int portnum; //PRINTDBG("spi%d: ioctl(cmd=%08x, addr=%08x)\n", channel+1, cmd, addr); if (channel >= NSPI) return ENXIO; switch (cmd & ~(IOCPARM_MASK << 16)) { default: return ENODEV; case SPICTL_SETMODE: /* set SPI mode */ /* --- Clock ---- * Mode Polarity Phase * 0 0 0 * 1 0 1 * 2 1 0 * 3 1 1 */ if ((unsigned) addr & 1) spi_set(io, PIC32_SPICON_CKE); if ((unsigned) addr & 2) spi_set(io, PIC32_SPICON_CKP); return 0; case SPICTL_SETRATE: /* set clock rate, kHz */ spi_brg(io, (unsigned int) addr); return 0; case SPICTL_SETSELPIN: /* set select pin */ portnum = ((unsigned int) addr >> 8) & 7; if (! portnum) return 0; spi_set_cspin(io, (unsigned*) tris[portnum], (unsigned) addr & 15); return 0; case SPICTL_IO8(0): /* transfer n*8 bits */ spi_select(io); nelem = (cmd >> 16) & IOCPARM_MASK; if (baduaddr(addr) || baduaddr(addr + nelem - 1)) return EFAULT; spi_bulk_rw(io, nelem, cval); spi_deselect(io); break; case SPICTL_IO16(0): /* transfer n*16 bits */ spi_select(io); nelem = (cmd >> 16) & IOCPARM_MASK; if (((unsigned) addr & 1) || baduaddr(addr) || baduaddr(addr + nelem*2 - 1)) return EFAULT; spi_bulk_rw_16(io, nelem<<1, (char *)addr); spi_deselect(io); break; case SPICTL_IO32(0): /* transfer n*32 bits */ spi_select(io); nelem = (cmd >> 16) & IOCPARM_MASK; if (((unsigned) addr & 3) || baduaddr(addr) || baduaddr(addr + nelem*4 - 1)) return EFAULT; spi_bulk_rw_32(io, nelem<<2, (char *)addr); spi_deselect(io); break; // IM: added R and W and BE modes case SPICTL_IO8R(0): /* transfer n*8 bits */ spi_select(io); nelem = (cmd >> 16) & IOCPARM_MASK; if (baduaddr(addr) || baduaddr(addr + nelem - 1)) return EFAULT; spi_bulk_read(io, nelem, cval); spi_deselect(io); break; case SPICTL_IO16R(0): /* transfer n*16 bits */ spi_select(io); nelem = (cmd >> 16) & IOCPARM_MASK; if (((unsigned) addr & 1) || baduaddr(addr) || baduaddr(addr + nelem*2 - 1)) return EFAULT; spi_bulk_read_16(io, nelem<<1, (char *)addr); spi_deselect(io); break; case SPICTL_IO32R(0): /* transfer n*32 bits */ spi_select(io); nelem = (cmd >> 16) & IOCPARM_MASK; if (((unsigned) addr & 3) || baduaddr(addr) || baduaddr(addr + nelem*4 - 1)) return EFAULT; spi_bulk_read_32(io, nelem<<2, (char *)addr); spi_deselect(io); break; case SPICTL_IO8W(0): /* transfer n*8 bits */ spi_select(io); nelem = (cmd >> 16) & IOCPARM_MASK; if (baduaddr(addr) || baduaddr(addr + nelem - 1)) return EFAULT; spi_bulk_write(io, nelem, cval); spi_deselect(io); break; case SPICTL_IO16W(0): /* transfer n*16 bits */ spi_select(io); nelem = (cmd >> 16) & IOCPARM_MASK; if (((unsigned) addr & 1) || baduaddr(addr) || baduaddr(addr + nelem*2 - 1)) return EFAULT; spi_bulk_write_16(io, nelem<<1, (char *)addr); spi_deselect(io); break; case SPICTL_IO32W(0): /* transfer n*32 bits */ spi_select(io); nelem = (cmd >> 16) & IOCPARM_MASK; if (((unsigned) addr & 3) || baduaddr(addr) || baduaddr(addr + nelem*4 - 1)) return EFAULT; spi_bulk_write_32(io, nelem<<2, (char *)addr); spi_deselect(io); break; case SPICTL_IO32RB(0): /* transfer n*32 bits */ spi_select(io); nelem = (cmd >> 16) & IOCPARM_MASK; if (((unsigned) addr & 3) || baduaddr(addr) || baduaddr(addr + nelem*4 - 1)) return EFAULT; spi_bulk_read_32_be(io, nelem<<2, (char *)addr); spi_deselect(io); break; case SPICTL_IO32WB(0): /* transfer n*32 bits */ spi_select(io); nelem = (cmd >> 16) & IOCPARM_MASK; if (((unsigned) addr & 3) || baduaddr(addr) || baduaddr(addr + nelem*4 - 1)) return EFAULT; spi_bulk_write_32_be(io, nelem<<2, (char *)addr); spi_deselect(io); break; case SPICTL_IO32B(0): /* transfer n*32 bits */ spi_select(io); nelem = (cmd >> 16) & IOCPARM_MASK; if (((unsigned) addr & 3) || baduaddr(addr) || baduaddr(addr + nelem*4 - 1)) return EFAULT; spi_bulk_write_32_be(io, nelem<<2, (char *)addr); spi_deselect(io); break; } return 0; } /* * Test to see if device is present. * Return true if found and initialized ok. * SPI ports are always present, if configured. */ static int spiprobe(config) struct conf_ctlr *config; { int channel = config->ctlr_unit - 1; struct spiio *io = &spi_io[channel]; int sdi, sdo, sck; static const int sdi_tab[NSPI] = { GPIO_PIN('C',4), /* SDI1 */ GPIO_PIN('G',7), /* SDI2 */ GPIO_PIN('D',2), /* SDI3: 64pin - RD2, 100pin - RF2 */ GPIO_PIN('F',4), /* SDI4 */ }; static const int sdo_tab[NSPI] = { GPIO_PIN('D',0), /* SDO1 */ GPIO_PIN('G',8), /* SDO2 */ GPIO_PIN('D',3), /* SDO3: 64pin - RD3, 100pin - RF8 */ GPIO_PIN('F',5), /* SDO4 */ }; static const int sck_tab[NSPI] = { GPIO_PIN('D',10), /* SCK1 */ GPIO_PIN('G',6), /* SCK2 */ GPIO_PIN('D',1), /* SCK3: 64pin - RD1, 100pin - RD15 */ GPIO_PIN('D',10), /* SCK4 */ }; if (channel < 0 || channel >= NSPI) return 0; sdi = sdi_tab[channel]; sdo = sdo_tab[channel]; sck = sck_tab[channel]; if (channel+1 == 3 && cpu_pins > 64) { /* Port SPI3 has different pin assignment for 100-pin packages. */ sdi = GPIO_PIN('F',2); sdo = GPIO_PIN('F',8); sck = GPIO_PIN('D',15); } printf("spi%u: pins sdi=R%c%d/sdo=R%c%d/sck=R%c%d\n", channel+1, gpio_portname(sdi), gpio_pinno(sdi), gpio_portname(sdo), gpio_pinno(sdo), gpio_portname(sck), gpio_pinno(sck)); if (spi_setup(io, channel+1, 0) != 0) { printf("spi%u: setup failed\n", channel+1); return 0; } return 1; } struct driver spidriver = { "spi", spiprobe, }; ================================================ FILE: sys/arch/pic32/dev/spi_bus.c ================================================ #include #include #include #include #include #include #include #define NSPI 4 /* Ports SPI1...SPI4 */ static struct spireg *const spi_base[NSPI] = { (struct spireg*) &SPI1CON, (struct spireg*) &SPI2CON, (struct spireg*) &SPI3CON, (struct spireg*) &SPI4CON, }; // // Default SPI bus speed // #ifndef SPI_MHZ #define SPI_MHZ 10 #endif // // Open an SPI device in default mode. Use further function calls to // set baud rate, clock phase, etc. // Returns an integer for the number of the device (ala fd). // Returns -1 if no devices are available. // int spi_setup(struct spiio *io, int channel, int cs) { unsigned *tris = 0; int pin = 0; if (channel <= 0 || channel > NSPI) return ENXIO; if (cs != 0) { /* Compute the port address and pin index of the chip select signal. */ int port = (cs >> 4) - 1; tris = (unsigned*) (port + (struct gpioreg*) &TRISA); pin = cs & 15; } // Set up the device io->bus = spi_base[channel-1]; io->cs_tris = tris; io->cs_pin = pin; io->baud = (BUS_KHZ / SPI_MHZ / 1000 + 1) / 2 - 1; io->mode = PIC32_SPICON_MSTEN | PIC32_SPICON_ON; if (tris) { // Configure the CS pin LAT_SET(*tris) = 1<cs_tris) { // Configure the CS pin TRIS_SET(*io->cs_tris) = 1<cs_tris = tris; io->cs_pin = pin; if (tris) { // Configure the CS pin LAT_SET(*tris) = 1<cs_tris == NULL) return; io->bus->brg = io->baud; io->bus->con = io->mode; LAT_CLR(*io->cs_tris) = 1 << io->cs_pin; } // // Deassert the CS pin of a device. // void spi_deselect(struct spiio *io) { if (io->cs_tris == NULL) return; LAT_SET(*io->cs_tris) = 1 << io->cs_pin; } // // Set a mode setting or two - just updates the internal records, the // actual mode is changed next time the CS is asserted // void spi_set(struct spiio *io, unsigned int set) { io->mode |= set; } // // Clear a mode setting or two - just updates the internal records, the // actual mode is changed next time the CS is asserted // void spi_clr(struct spiio *io, unsigned int set) { io->mode &= ~set; } // // Return the current status of the SPI bus for the device in question // Just returns the ->stat entry in the register set. // unsigned int spi_status(struct spiio *io) { return io->bus->stat; } // // Transfer one word of data, and return the read word of // data. The actual number of bits sent depends on the // mode of the transfer. // This is blocking, and waits for the transfer to complete // before returning. Times out after a certain period. // unsigned char spi_transfer(struct spiio *io, unsigned char data) { struct spireg *reg = io->bus; unsigned int to = 100000; if (! reg) return 0xF1; reg->con = io->mode; reg->brg = io->baud; reg->buf = data; while ((--to > 0) && ! (reg->stat & PIC32_SPISTAT_SPIRBF)) asm volatile ("nop"); if (to == 0) return 0xF2; return reg->buf; } // // Write a huge chunk of data as fast and as efficiently as // possible. Switches in to 32-bit mode regardless, and uses // the enhanced buffer mode. // Data should be a multiple of 32 bits. // void spi_bulk_write_32_be(struct spiio *io, unsigned int len, char *data) { struct spireg *reg = io->bus; int *data32 = (int *)data; unsigned int words = len >> 2; unsigned int nread; unsigned int nwritten; if (! reg) return; nread = 0; nwritten = words; reg->conset = PIC32_SPICON_MODE32 | PIC32_SPICON_ENHBUF; while (nread < words) { if (nwritten > 0 && ! (reg->stat & PIC32_SPISTAT_SPITBF)) { reg->buf = mips_bswap(*data32++); nwritten--; } if (! (reg->stat & PIC32_SPISTAT_SPIRBE)) { (void) reg->buf; nread++; } } reg->con = io->mode; } void spi_bulk_write_32(struct spiio *io, unsigned int len, char *data) { struct spireg *reg = io->bus; int *data32 = (int *)data; unsigned int words = len >> 2; unsigned int nread; unsigned int nwritten; if (! reg) return; nread = 0; nwritten = words; reg->conset = PIC32_SPICON_MODE32 | PIC32_SPICON_ENHBUF; while (nread < words) { if (nwritten > 0 && ! (reg->stat & PIC32_SPISTAT_SPITBF)) { reg->buf = *data32++; nwritten--; } if (! (reg->stat & PIC32_SPISTAT_SPIRBE)) { (void) reg->buf; nread++; } } reg->con = io->mode; } void spi_bulk_write_16(struct spiio *io, unsigned int len, char *data) { struct spireg *reg = io->bus; short *data16 = (short *)data; unsigned int words = len >> 1; unsigned int nread; unsigned int nwritten; if (! reg) return; nread = 0; nwritten = words; reg->conset = PIC32_SPICON_MODE16 | PIC32_SPICON_ENHBUF; while (nread < words) { if (nwritten > 0 && ! (reg->stat & PIC32_SPISTAT_SPITBF)) { reg->buf = *data16++; nwritten--; } if (! (reg->stat & PIC32_SPISTAT_SPIRBE)) { (void) reg->buf; nread++; } } reg->con = io->mode; } void spi_bulk_write(struct spiio *io, unsigned int len, unsigned char *data) { unsigned char *data8 = data; unsigned int i; unsigned char out; for (i=0; ibus; int *data32 = (int *)data; unsigned int words = len >> 2; unsigned int nread; unsigned int nwritten; if (! reg) return; nread = 0; nwritten = words; reg->conset = PIC32_SPICON_MODE32 | PIC32_SPICON_ENHBUF; while (nread < words) { if (nwritten > 0 && ! (reg->stat & PIC32_SPISTAT_SPITBF)) { reg->buf = ~0; nwritten--; } if (! (reg->stat & PIC32_SPISTAT_SPIRBE)) { *data32++ = mips_bswap(reg->buf); nread++; } } reg->con = io->mode; } void spi_bulk_read_32(struct spiio *io, unsigned int len, char *data) { struct spireg *reg = io->bus; int *data32 = (int *)data; unsigned int words = len >> 2; unsigned int nread; unsigned int nwritten; if (! reg) return; nread = 0; nwritten = words; reg->conset = PIC32_SPICON_MODE32 | PIC32_SPICON_ENHBUF; while (nread < words) { if (nwritten > 0 && ! (reg->stat & PIC32_SPISTAT_SPITBF)) { reg->buf = ~0; nwritten--; } if (! (reg->stat & PIC32_SPISTAT_SPIRBE)) { *data32++ = reg->buf; nread++; } } reg->con = io->mode; } void spi_bulk_read_16(struct spiio *io, unsigned int len, char *data) { struct spireg *reg = io->bus; short *data16 = (short *)data; unsigned int words = len >> 1; unsigned int nread; unsigned int nwritten; if (! reg) return; nread = 0; nwritten = words; reg->conset = PIC32_SPICON_MODE16 | PIC32_SPICON_ENHBUF; while (nread < words) { if (nwritten > 0 && ! (reg->stat & PIC32_SPISTAT_SPITBF)) { reg->buf = ~0; nwritten--; } if (! (reg->stat & PIC32_SPISTAT_SPIRBE)) { *data16++ = mips_bswap(reg->buf); nread++; } } reg->con = io->mode; } void spi_bulk_read(struct spiio *io, unsigned int len, unsigned char *data) { unsigned char *data8 = data; unsigned int i; unsigned char in,out; for (i=0; ibus; int *read32 = (int *)data; int *write32 = (int *)data; unsigned int words = len >> 2; unsigned int nread; unsigned int nwritten; if (! reg) return; nread = 0; nwritten = words; reg->conset = PIC32_SPICON_MODE32 | PIC32_SPICON_ENHBUF; while (nread < words) { if (nwritten > 0 && ! (reg->stat & PIC32_SPISTAT_SPITBF)) { reg->buf = *write32++; nwritten--; } if (! (reg->stat & PIC32_SPISTAT_SPIRBE)) { *read32++ = mips_bswap(reg->buf); nread++; } } reg->con = io->mode; } void spi_bulk_rw_32(struct spiio *io, unsigned int len, char *data) { struct spireg *reg = io->bus; int *read32 = (int *)data; int *write32 = (int *)data; unsigned int words = len >> 2; unsigned int nread; unsigned int nwritten; if (! reg) return; nread = 0; nwritten = words; reg->conset = PIC32_SPICON_MODE32 | PIC32_SPICON_ENHBUF; while (nread < words) { if (nwritten > 0 && ! (reg->stat & PIC32_SPISTAT_SPITBF)) { reg->buf = *write32++; nwritten--; } if (! (reg->stat & PIC32_SPISTAT_SPIRBE)) { *read32++ = reg->buf; nread++; } } reg->con = io->mode; } void spi_bulk_rw_16(struct spiio *io, unsigned int len, char *data) { struct spireg *reg = io->bus; short *read16 = (short *)data; short *write16 = (short *)data; unsigned int words = len >> 1; unsigned int nread; unsigned int nwritten; if (! reg) return; nread = 0; nwritten = words; reg->conset = PIC32_SPICON_MODE16 | PIC32_SPICON_ENHBUF; while (nread < words) { if (nwritten > 0 && ! (reg->stat & PIC32_SPISTAT_SPITBF)) { reg->buf = *write16++; nwritten--; } if (! (reg->stat & PIC32_SPISTAT_SPIRBE)) { *read16++ = mips_bswap(reg->buf); nread++; } } reg->con = io->mode; } void spi_bulk_rw(struct spiio *io, unsigned int len, unsigned char *data) { unsigned char *data8 = data; unsigned int i; unsigned char in,out; for (i=0; ibaud = (BUS_KHZ / baud + 1) / 2 - 1; } // // Return the name of the SPI bus for a device // char *spi_name(struct spiio *io) { if (io->bus == spi_base[0]) return "SPI1"; if (io->bus == spi_base[1]) return "SPI2"; if (io->bus == spi_base[2]) return "SPI3"; if (io->bus == spi_base[3]) return "SPI4"; return "SPI?"; } // // Return the port name of the CS pin for a device // char spi_csname(struct spiio *io) { switch ((unsigned)io->cs_tris) { case (unsigned)&TRISA: return 'A'; case (unsigned)&TRISB: return 'B'; case (unsigned)&TRISC: return 'C'; case (unsigned)&TRISD: return 'D'; case (unsigned)&TRISE: return 'E'; case (unsigned)&TRISF: return 'F'; case (unsigned)&TRISG: return 'G'; } return '?'; } int spi_cspin(struct spiio *io) { return io->cs_pin; } unsigned int spi_get_brg(struct spiio *io) { return BUS_KHZ / (io->baud + 1) / 2; } ================================================ FILE: sys/arch/pic32/dev/spirams.c ================================================ /* * Disk driver for serial RAM chips connected via SPI port. */ #include #include #include #include #include #include #include #include #include #include #define SPIRAM_WREN 0x06 #define SPIRAM_WRDI 0x04 #define SPIRAM_RDSR 0x05 #define SPIRAM_WRSR 0x01 #define SPIRAM_READ 0x03 #define SPIRAM_WRITE 0x02 #define SPIRAM_SLEEP 0xB9 #define SPIRAM_WAKE 0xAB #ifndef SPIRAMS_MHZ #define SPIRAMS_MHZ 10 #endif struct spiio spirams_io[SPIRAMS_CHIPS]; int spirams_dkindex; /* disk index for statistics */ /* * Size of RAM disk. */ #define SPIRAMS_TOTAL_KBYTES (SPIRAMS_CHIPS * SPIRAMS_CHIPSIZE) #define MRBSIZE 1024 #define MRBLOG2 10 unsigned int spir_read_block(unsigned int chip, unsigned int address, unsigned int length, char *data) { struct spiio *io = &spirams_io[chip]; register unsigned int cs = 0; switch (chip) { case 0: #ifdef SPIRAMS_LED0_PORT TRIS_CLR(SPIRAMS_LED0_PORT) = 1<> 16); spi_transfer(io, address >> 8); spi_transfer(io, address); // If the length is a multiple of 32 bits, then do a 32 bit transfer #if 0 if ((length & 3) == 0) spi_bulk_read_32(io, length, data); else if ((length & 1) == 0) spi_bulk_read_16(io, length, data); else #endif spi_bulk_read(io, length, (unsigned char *)data); spi_deselect(io); switch (chip) { case 0: #ifdef SPIRAMS_LED0_PORT LAT_CLR(SPIRAMS_LED0_PORT) = 1< 0) { pass++; toread = bcount; if (toread > MRBSIZE) toread = MRBSIZE; chip = offset / SPIRAMS_CHIPSIZE; address = (offset<<10) - (chip * (SPIRAMS_CHIPSIZE*1024)); if (chip >= SPIRAMS_CHIPS) { printf("!!!EIO\n"); return EIO; } spir_read_block(chip, address, toread, data); bcount -= toread; offset += (toread>>MRBLOG2); data += toread; } return 1; } unsigned int spir_write_block(unsigned int chip, unsigned int address, unsigned int length, char *data) { struct spiio *io = &spirams_io[chip]; register unsigned int cs = 0; char blank __attribute__((unused)); switch (chip) { case 0: #ifdef SPIRAMS_LED0_PORT TRIS_CLR(SPIRAMS_LED0_PORT) = 1<> 16); spi_transfer(io, address >> 8); spi_transfer(io, address); #if 0 if ((length & 3) == 0) spi_bulk_write_32(io, length, data); else if ((length & 1) == 0) spi_bulk_write_16(io, length, data); else #endif spi_bulk_write(io, length, (unsigned char *)data); spi_deselect(io); switch (chip) { case 0: #ifdef SPIRAMS_LED0_PORT LAT_CLR(SPIRAMS_LED0_PORT) = 1< 0) { pass++; towrite = bcount; if (towrite > MRBSIZE) towrite = MRBSIZE; chip = offset / SPIRAMS_CHIPSIZE; address = (offset<<10) - (chip * (SPIRAMS_CHIPSIZE*MRBSIZE)); if (chip >= SPIRAMS_CHIPS) { printf("!!!EIO\n"); return EIO; } spir_write_block(chip, address, towrite, data); bcount -= towrite; offset += (towrite>>MRBLOG2); data += towrite; } return 1; } /* * Initialize hardware. */ static int spirams_init(int spi_port, char cs[]) { struct spiio *io = &spirams_io[0]; if (spi_setup(io, spi_port, cs[0]) != 0) { printf("sr0: cannot open SPI%u port\n", spi_port); return 0; } spi_brg(io, SPIRAMS_MHZ * 1000); spi_set(io, PIC32_SPICON_CKE); #if SPIRAMS_CHIPS >= 1 spi_setup(io+1, spi_port, cs[1]); spi_brg(io+1, SPIRAMS_MHZ * 1000); spi_set(io+1, PIC32_SPICON_CKE); #endif #if SPIRAMS_CHIPS >= 2 spi_setup(io+2, spi_port, cs[2]); spi_brg(io+2, SPIRAMS_MHZ * 1000); spi_set(io+2, PIC32_SPICON_CKE); #endif #if SPIRAMS_CHIPS >= 3 spi_setup(io+3, spi_port, cs[3]); spi_brg(io+3, SPIRAMS_MHZ * 1000); spi_set(io+3, PIC32_SPICON_CKE); #endif #if SPIRAMS_CHIPS >= 4 spi_setup(io+4, spi_port, cs[4]); spi_brg(io+4, SPIRAMS_MHZ * 1000); spi_set(io+4, PIC32_SPICON_CKE); #endif #if SPIRAMS_CHIPS >= 5 spi_setup(io+5, spi_port, cs[5]); spi_brg(io+5, SPIRAMS_MHZ * 1000); spi_set(io+5, PIC32_SPICON_CKE); #endif #if SPIRAMS_CHIPS >= 6 spi_setup(io+6, spi_port, cs[6]); spi_brg(io+6, SPIRAMS_MHZ * 1000); spi_set(io+6, PIC32_SPICON_CKE); #endif #if SPIRAMS_CHIPS >= 7 spi_setup(io+7, spi_port, cs[7]); spi_brg(io+7, SPIRAMS_MHZ * 1000); spi_set(io+7, PIC32_SPICON_CKE); #endif #if SPIRAMS_CHIPS >= 8 spi_setup(io+8, spi_port, cs[8]); spi_brg(io+8, SPIRAMS_MHZ * 1000); spi_set(io+8, PIC32_SPICON_CKE); #endif #if SPIRAMS_CHIPS >= 9 spi_setup(io+9, spi_port, cs[9]); spi_brg(io+9, SPIRAMS_MHZ * 1000); spi_set(io+9, PIC32_SPICON_CKE); #endif #if SPIRAMS_CHIPS >= 10 spi_setup(io+10, spi_port, cs[10]); spi_brg(io+10, SPIRAMS_MHZ * 1000); spi_set(io+10, PIC32_SPICON_CKE); #endif #if SPIRAMS_CHIPS >= 11 spi_setup(io+11, spi_port, cs[11]); spi_brg(io+11, SPIRAMS_MHZ * 1000); spi_set(io+11, PIC32_SPICON_CKE); #endif #if SPIRAMS_CHIPS >= 12 spi_setup(io+12, spi_port, cs[12]); spi_brg(io+12, SPIRAMS_MHZ * 1000); spi_set(io+12, PIC32_SPICON_CKE); #endif #if SPIRAMS_CHIPS >= 13 spi_setup(io+13, spi_port, cs[13]); spi_brg(io+13, SPIRAMS_MHZ * 1000); spi_set(io+13, PIC32_SPICON_CKE); #endif #if SPIRAMS_CHIPS >= 14 spi_setup(io+14, spi_port, cs[14]); spi_brg(io+14, SPIRAMS_MHZ * 1000); spi_set(io+14, PIC32_SPICON_CKE); #endif #if SPIRAMS_CHIPS >= 15 spi_setup(io+15, spi_port, cs[15]); spi_brg(io+15, SPIRAMS_MHZ * 1000); spi_set(io+15, PIC32_SPICON_CKE); #endif printf("spirams0: size %dKB, speed %d Mbit/sec\n", SPIRAMS_CHIPS * SPIRAMS_CHIPSIZE, spi_get_brg(io) / 1000); return 1; } /* * Open the disk. */ int spirams_open(dev_t dev, int flag, int mode) { return 0; } int spirams_close(dev_t dev, int flag, int mode) { return 0; } /* * Return the size of the device in kbytes. */ daddr_t spirams_size(dev_t dev) { return SPIRAMS_TOTAL_KBYTES; } void spirams_strategy(struct buf *bp) { int offset = bp->b_blkno; long nblk = btod(bp->b_bcount); int s; /* * Determine the size of the transfer, and make sure it is * within the boundaries of the partition. */ if (bp->b_blkno + nblk > SPIRAMS_TOTAL_KBYTES) { /* if exactly at end of partition, return an EOF */ if (bp->b_blkno == SPIRAMS_TOTAL_KBYTES) { bp->b_resid = bp->b_bcount; biodone(bp); return; } /* or truncate if part of it fits */ nblk = SPIRAMS_TOTAL_KBYTES - bp->b_blkno; if (nblk <= 0) { bp->b_error = EINVAL; bp->b_flags |= B_ERROR; biodone(bp); return; } bp->b_bcount = nblk << DEV_BSHIFT; } led_control(LED_SWAP, 1); s = splbio(); #ifdef UCB_METER if (spirams_dkindex >= 0) { dk_busy |= 1 << spirams_dkindex; dk_xfer[spirams_dkindex]++; dk_bytes[spirams_dkindex] += bp->b_bcount; } #endif if (bp->b_flags & B_READ) { spirams_read(offset, bp->b_addr, bp->b_bcount); } else { spirams_write(offset, bp->b_addr, bp->b_bcount); } biodone(bp); led_control(LED_SWAP, 0); #ifdef UCB_METER if (spirams_dkindex >= 0) dk_busy &= ~(1 << spirams_dkindex); #endif splx(s); } int spirams_ioctl(dev_t dev, u_int cmd, caddr_t addr, int flag) { int error = 0; switch (cmd) { case DIOCGETMEDIASIZE: /* Get disk size in kbytes. */ *(int*) addr = SPIRAMS_TOTAL_KBYTES; break; default: error = EINVAL; break; } return error; } /* * Test to see if device is present. * Return true if found and initialized ok. */ static int spirams_probe(config) struct conf_device *config; { int i; /* Only one device unit is supported. */ if (config->dev_unit != 0) return 0; printf("sr0: port SPI%d, pins ", config->dev_ctlr); for (i=0; idev_pins[i]; if (i > 0) printf("/"); if (i == 7) printf("\n "); printf("R%c%d", gpio_portname(cs), gpio_pinno(cs)); } printf("\n"); if (spirams_init(config->dev_ctlr, config->dev_pins) != 0) return 0; #ifdef UCB_METER dk_alloc(&spirams_dkindex, 1, "sr0"); #endif return 1; } struct driver srdriver = { "sr", spirams_probe, }; ================================================ FILE: sys/arch/pic32/dev/spirams.h ================================================ #ifndef _SPIRAMS_H #define _SPIRAMS_H #ifdef KERNEL extern int spirams_open(dev_t dev, int flag, int mode); extern int spirams_close(dev_t dev, int flag, int mode); extern daddr_t spirams_size(dev_t dev); extern void spirams_strategy(struct buf *bp); extern int spirams_ioctl (dev_t dev, u_int cmd, caddr_t addr, int flag); #endif #endif ================================================ FILE: sys/arch/pic32/dev/sramc.c ================================================ /* * Driver for external SRAM-CPLD based Swap and Filesystem devices * * This version is for 8MB RAMDISK v.1.1 and compatible * Pito 7.4.2014 - PIC32MX PMP bus version * Under by retrobsd.org used Licence * No warranties of any kind * * Interface: * PMD<7:0> - connected to PMP data bus * PMRD - fetch a byte from memory to data<7:0>, increment address, PMRD * PMWR - write a byte data[7:0] to memory, increment address, PMWR * PMA0 - HIGH - write Address from data<3:0> in 6 steps: high nibble ... low nibble * - LOW - write/read Data * * Signals PMRD, PMWR are active LOW and idle HIGH * Signal PMA0 is LOW when accessing RAM Data, and HIGH when accessing RAM Addresses */ #include #include #include #include #include #include #include #include #include #include int sramc_dkindex = -1; /* Statistics slot number */ /* * Size of RAM disk. */ #define SRAMC_TOTAL_KBYTES 8192 /* 4096 for 4MB ramdisk */ // Ramdisk v.1.1. wiring // PMP RAMDISK // =================== // PMD D0-D7 // PMRD /RD // PMWR /WR // PMA<0> /DATA // RD and WR pulses duration settings // Minimal recommended settings, increase them when unstable // No warranties of any kind // for 120MHz clock, 70ns PSRAM, Ramdisk v.1.1. #define ADR_PULSE 1 #define WR_PULSE 5 #define RD_PULSE 11 // for 80MHz clock, 70ns PSRAM, Ramdisk v.1.1. //#define ADR_PULSE 1 //#define WR_PULSE 3 //#define RD_PULSE 8 // for 120MHz clock, 55ns SRAM //#define ADR_PULSE 1 //#define WR_PULSE 3 //#define RD_PULSE 6 // for 80MHz clock, 55ns SRAM //#define ADR_PULSE 1 //#define WR_PULSE 2 //#define RD_PULSE 4 typedef union { unsigned value; struct { unsigned nib1 : 4; // lowest nibble unsigned nib2 : 4; unsigned nib3 : 4; unsigned nib4 : 4; unsigned nib5 : 4; unsigned nib6 : 4; unsigned nib7 : 4; unsigned nib8 : 4; // highest nibble }; } nybbles; /* * Load the 24 bit address to Ramdisk. * */ inline static void dev_load_address(addr) unsigned addr; { nybbles temp; temp.value = addr; while (PMMODE & 0x8000); // Poll - if busy, wait PMADDR = 1; // set ADR mode (1) to write the Address PMMODE = 0b10<<8 | (ADR_PULSE<<2); // full ADR speed PMDIN = temp.nib6; /* write 4 bits */ while (PMMODE & 0x8000); // Poll - if busy, wait PMDIN = temp.nib5; /* write 4 bits */ while (PMMODE & 0x8000); // Poll - if busy, wait PMDIN = temp.nib4; /* write 4 bits */ while (PMMODE & 0x8000); // Poll - if busy, wait PMDIN = temp.nib3; /* write 4 bits */ while (PMMODE & 0x8000); // Poll - if busy, wait PMDIN = temp.nib2; /* write 4 bits */ while (PMMODE & 0x8000); // Poll - if busy, wait PMDIN = temp.nib1; /* write 4 bits */ } /* * Return a size of partition in kbytes. * The memory is divided into two partitions: A and B. * Size of partition B is specified in the kernel config file * as option SRAMC_SWAP_KBYTES. */ daddr_t sramc_size(dev_t dev) { switch (minor(dev)) { case 0: /* Whole disk. */ return SRAMC_TOTAL_KBYTES; case 1: /* Partition A: filesystem. */ return SRAMC_TOTAL_KBYTES - SRAMC_SWAP_KBYTES; case 2: default: /* Partition B: swap space. */ return SRAMC_SWAP_KBYTES; } } /* * Read a block of data. */ static int sramc_read(unsigned int blockno, char *data, unsigned int nbytes) { int i; //DEBUG9("sramc%d: read block %u, length %u bytes, addr %p\n", major(dev), blockno, nbytes, data); dev_load_address(blockno * DEV_BSIZE); /* Read data. */ while (PMMODE & 0x8000); // Poll - if busy, wait PMADDR = 0; // set DATA mode (0) PMMODE = 0b10<<8 | (RD_PULSE<<2); // read slowly PMDIN; // Read the PMDIN to clear previous data and latch new data for (i=0; i, use A0 only PMADDR = 0; // start with DATA mode PMCONSET = 1<<15; // PMP enabled asm volatile ("nop"); // make a couple of dummy reads - it refreshes the cpld internals a little bit :) while (PMMODE & 0x8000); // Poll - if busy, wait before reading PMDIN; /* read a byte of data */ while (PMMODE & 0x8000); // Poll - if busy, wait before reading PMDIN; /* read a byte of data */ PMADDR = 1; // go with with ADDRESS mode now DEBUG3("sramc: init done\n"); } /* * Open the disk. */ int sramc_open(dev_t dev, int flag, int mode) { DEBUG3("sramc: open\n"); return 0; } int sramc_close(dev_t dev, int flag, int mode) { return 0; } void sramc_strategy(struct buf *bp) { int offset = bp->b_blkno; long nblk = btod(bp->b_bcount); int part_offset, part_size, s; /* Compute partition size and offset. */ part_size = sramc_size(bp->b_dev); if (minor(bp->b_dev) < 2) { /* Partition A or a whole disk. */ part_offset = 0; } else { /* Partition B: swap space. */ part_offset = SRAMC_TOTAL_KBYTES - part_size; } /* * Determine the size of the transfer, and make sure it is * within the boundaries of the partition. */ offset += part_offset; if (bp->b_blkno + nblk > part_size) { /* if exactly at end of partition, return an EOF */ if (bp->b_blkno == part_size) { bp->b_resid = bp->b_bcount; biodone(bp); return; } /* or truncate if part of it fits */ nblk = part_size - bp->b_blkno; if (nblk <= 0) { bp->b_error = EINVAL; bp->b_flags |= B_ERROR; biodone(bp); return; } bp->b_bcount = nblk << DEV_BSHIFT; } if (bp->b_dev == swapdev) { led_control(LED_SWAP, 1); } else { led_control(LED_DISK, 1); } s = splbio(); #ifdef UCB_METER if (sramc_dkindex >= 0) { dk_busy |= 1 << sramc_dkindex; dk_xfer[sramc_dkindex]++; dk_bytes[sramc_dkindex] += bp->b_bcount; } #endif if (bp->b_flags & B_READ) { sramc_read(offset, bp->b_addr, bp->b_bcount); } else { sramc_write(offset, bp->b_addr, bp->b_bcount); } biodone(bp); if (bp->b_dev == swapdev) { led_control(LED_SWAP, 0); } else { led_control(LED_DISK, 0); } #ifdef UCB_METER if (sramc_dkindex >= 0) dk_busy &= ~(1 << sramc_dkindex); #endif splx(s); } int sramc_ioctl(dev_t dev, u_int cmd, caddr_t addr, int flag) { int error = 0; switch (cmd) { case DIOCGETMEDIASIZE: /* Get disk size in kbytes. */ *(int*) addr = sramc_size(dev); break; default: error = EINVAL; break; } return error; } /* * Test to see if device is present. * Return true if found and initialized ok. */ static int sramcprobe(config) struct conf_device *config; { /* Only one device unit is supported. */ if (config->dev_unit != 0) return 0; printf("rc0: total %u kbytes, swap space %u kbytes\n", SRAMC_TOTAL_KBYTES, SRAMC_SWAP_KBYTES); sramc_init(); #ifdef UCB_METER dk_alloc(&sramc_dkindex, 1, "rc0"); #endif return 1; } struct driver rcdriver = { "sramc", sramcprobe, }; ================================================ FILE: sys/arch/pic32/dev/sramc.h ================================================ #ifndef _SRAMC_H #define _SRAMC_H #ifdef KERNEL extern int sramc_open(dev_t dev, int flag, int mode); extern int sramc_close(dev_t dev, int flag, int mode); extern daddr_t sramc_size(dev_t dev); extern void sramc_strategy(struct buf *bp); extern int sramc_ioctl (dev_t dev, u_int cmd, caddr_t addr, int flag); #endif #endif ================================================ FILE: sys/arch/pic32/dev/uart.c ================================================ /* * UART driver for PIC32. * * Copyright (c) 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * * @(#)cons.c 1.3 (2.11BSD GTE) 1997/4/25 */ #include #include #include #include #include #include #include #include #define CONCAT(x,y) x ## y #define BBAUD(x) CONCAT(B,x) #ifndef UART_BAUD #define UART_BAUD 115200 #endif /* * PIC32 UART registers. */ struct uartreg { volatile unsigned mode; /* Mode */ volatile unsigned modeclr; volatile unsigned modeset; volatile unsigned modeinv; volatile unsigned sta; /* Status and control */ volatile unsigned staclr; volatile unsigned staset; volatile unsigned stainv; volatile unsigned txreg; /* Transmit */ volatile unsigned unused1; volatile unsigned unused2; volatile unsigned unused3; volatile unsigned rxreg; /* Receive */ volatile unsigned unused4; volatile unsigned unused5; volatile unsigned unused6; volatile unsigned brg; /* Baud rate */ volatile unsigned brgclr; volatile unsigned brgset; volatile unsigned brginv; }; static struct uartreg *const uart[NUART] = { (struct uartreg*) &U1MODE, (struct uartreg*) &U2MODE, (struct uartreg*) &U3MODE, (struct uartreg*) &U4MODE, (struct uartreg*) &U5MODE, (struct uartreg*) &U6MODE }; /* * UART interrupt numbers. */ struct uart_irq { int er; int rx; int tx; }; static const struct uart_irq uirq[NUART] = { { PIC32_IRQ_U1E, PIC32_IRQ_U1RX, PIC32_IRQ_U1TX }, { PIC32_IRQ_U2E, PIC32_IRQ_U2RX, PIC32_IRQ_U2TX }, { PIC32_IRQ_U3E, PIC32_IRQ_U3RX, PIC32_IRQ_U3TX }, { PIC32_IRQ_U4E, PIC32_IRQ_U4RX, PIC32_IRQ_U4TX }, { PIC32_IRQ_U5E, PIC32_IRQ_U5RX, PIC32_IRQ_U5TX }, { PIC32_IRQ_U6E, PIC32_IRQ_U6RX, PIC32_IRQ_U6TX }, }; struct tty uartttys[NUART]; static unsigned speed_bps [NSPEEDS] = { 0, 50, 75, 150, 200, 300, 600, 1200, 1800, 2400, 4800, 9600, 19200, 38400, 57600, 115200, 230400, 460800, 500000, 576000, 921600, 1000000, 1152000, 1500000, 2000000, 2500000, 3000000, 3500000, 4000000 }; void cnstart (struct tty *tp); /* * Setup UART registers. * Compute the divisor for 115.2 kbaud. */ void uartinit(int unit) { register struct uartreg *reg; if (unit >= NUART) return; switch(unit) { case 0: #ifdef UART1_ENA_PORT /* Enable UART1 phy - pin is assumed to be active low */ TRIS_CLR(UART1_ENA_PORT) = 1 << UART1_ENA_PIN; LAT_CLR(UART1_ENA_PORT) = 1 << UART1_ENA_PIN; udelay(2500); #endif break; case 1: #ifdef UART2_ENA_PORT /* Enable UART2 phy - pin is assumed to be active low */ TRIS_CLR(UART2_ENA_PORT) = 1 << UART2_ENA_PIN; LAT_CLR(UART2_ENA_PORT) = 1 << UART2_ENA_PIN; udelay(2500); #endif break; case 2: #ifdef UART3_ENA_PORT /* Enable UART3 phy - pin is assumed to be active low */ TRIS_CLR(UART3_ENA_PORT) = 1 << UART3_ENA_PIN; LAT_CLR(UART3_ENA_PORT) = 1 << UART3_ENA_PIN; udelay(2500); #endif break; case 3: #ifdef UART4_ENA_PORT /* Enable UART4 phy - pin is assumed to be active low */ TRIS_CLR(UART4_ENA_PORT) = 1 << UART4_ENA_PIN; LAT_CLR(UART4_ENA_PORT) = 1 << UART4_ENA_PIN; udelay(2500); #endif break; case 4: #ifdef UART5_ENA_PORT /* Enable UART5 phy - pin is assumed to be active low */ TRIS_CLR(UART5_ENA_PORT) = 1 << UART5_ENA_PIN; LAT_CLR(UART5_ENA_PORT) = 1 << UART5_ENA_PIN; udelay(2500); #endif break; case 5: #ifdef UART6_ENA_PORT /* Enable UART6 phy - pin is assumed to be active low */ TRIS_CLR(UART6_ENA_PORT) = 1 << UART6_ENA_PIN; LAT_CLR(UART6_ENA_PORT) = 1 << UART6_ENA_PIN; udelay(2500); #endif break; } reg = uart[unit]; reg->brg = PIC32_BRG_BAUD (BUS_KHZ * 1000, UART_BAUD); reg->sta = 0; reg->mode = PIC32_UMODE_PDSEL_8NPAR | /* 8-bit data, no parity */ PIC32_UMODE_ON; /* UART Enable */ reg->staset = PIC32_USTA_URXEN | /* Receiver Enable */ PIC32_USTA_UTXEN; /* Transmit Enable */ } int uartopen(dev_t dev, int flag, int mode) { register struct uartreg *reg; register struct tty *tp; register int unit = minor(dev); if (unit >= NUART) return (ENXIO); tp = &uartttys[unit]; if (! tp->t_addr) return (ENXIO); reg = (struct uartreg*) tp->t_addr; tp->t_oproc = uartstart; if ((tp->t_state & TS_ISOPEN) == 0) { if (tp->t_ispeed == 0) { tp->t_ispeed = BBAUD(UART_BAUD); tp->t_ospeed = BBAUD(UART_BAUD); } ttychars(tp); tp->t_state = TS_ISOPEN | TS_CARR_ON; tp->t_flags = ECHO | XTABS | CRMOD | CRTBS | CRTERA | CTLECH | CRTKIL; } if ((tp->t_state & TS_XCLUDE) && u.u_uid != 0) return (EBUSY); reg->sta = 0; reg->brg = PIC32_BRG_BAUD (BUS_KHZ * 1000, speed_bps [tp->t_ospeed]); reg->mode = PIC32_UMODE_PDSEL_8NPAR | PIC32_UMODE_ON; reg->staset = PIC32_USTA_URXEN | PIC32_USTA_UTXEN; /* Enable receive interrupt. */ if (uirq[unit].rx < 32) { IECSET(0) = 1 << uirq[unit].rx; } else if (uirq[unit].rx < 64) { IECSET(1) = 1 << (uirq[unit].rx-32); } else { IECSET(2) = 1 << (uirq[unit].rx-64); } return ttyopen(dev, tp); } /*ARGSUSED*/ int uartclose (dev_t dev, int flag, int mode) { register int unit = minor(dev); register struct tty *tp = &uartttys[unit]; if (! tp->t_addr) return ENODEV; ttywflush(tp); ttyclose(tp); return(0); } /*ARGSUSED*/ int uartread (dev, uio, flag) dev_t dev; struct uio *uio; int flag; { register int unit = minor(dev); register struct tty *tp = &uartttys[unit]; if (! tp->t_addr) return ENODEV; return ttread(tp, uio, flag); } /*ARGSUSED*/ int uartwrite (dev, uio, flag) dev_t dev; struct uio *uio; int flag; { register int unit = minor(dev); register struct tty *tp = &uartttys[unit]; if (! tp->t_addr) return ENODEV; return ttwrite(tp, uio, flag); } int uartselect (dev, rw) register dev_t dev; int rw; { register int unit = minor(dev); register struct tty *tp = &uartttys[unit]; if (! tp->t_addr) return ENODEV; return (ttyselect (tp, rw)); } /*ARGSUSED*/ int uartioctl (dev, cmd, addr, flag) dev_t dev; register u_int cmd; caddr_t addr; int flag; { register int unit = minor(dev); register struct tty *tp = &uartttys[unit]; register int error; if (! tp->t_addr) return ENODEV; error = ttioctl(tp, cmd, addr, flag); if (error < 0) error = ENOTTY; return (error); } void uartintr (dev) dev_t dev; { register int c; register int unit = minor(dev); register struct tty *tp = &uartttys[unit]; register struct uartreg *reg = (struct uartreg *)tp->t_addr; if (! tp->t_addr) return; /* Receive */ while (reg->sta & PIC32_USTA_URXDA) { c = reg->rxreg; ttyinput(c, tp); } if (reg->sta & PIC32_USTA_OERR) reg->staclr = PIC32_USTA_OERR; if (uirq[unit].rx < 32) { IFSCLR(0) = (1 << uirq[unit].rx) | (1 << uirq[unit].er); } else if (uirq[unit].rx < 64) { IFSCLR(1) = (1 << (uirq[unit].rx-32)) | (1 << (uirq[unit].er-32)); } else { IFSCLR(2) = (1 << (uirq[unit].rx-64)) | (1 << (uirq[unit].er-64)); } /* Transmit */ if (reg->sta & PIC32_USTA_TRMT) { led_control (LED_TTY, 0); if (uirq[unit].tx < 32) { IECCLR(0) = 1 << uirq[unit].tx; IFSCLR(0) = 1 << uirq[unit].tx; } else if (uirq[unit].tx < 64) { IECCLR(1) = 1 << (uirq[unit].tx - 32); IFSCLR(1) = 1 << (uirq[unit].tx - 32); } else { IECCLR(2) = 1 << (uirq[unit].tx - 64); IFSCLR(2) = 1 << (uirq[unit].tx - 64); } if (tp->t_state & TS_BUSY) { tp->t_state &= ~TS_BUSY; ttstart(tp); } } } void uartstart (register struct tty *tp) { register struct uartreg *reg = (struct uartreg*) tp->t_addr; register int c, s; register int unit = minor(tp->t_dev); if (! tp->t_addr) return; s = spltty(); if (tp->t_state & (TS_TIMEOUT | TS_BUSY | TS_TTSTOP)) { out: /* Disable transmit_interrupt. */ led_control (LED_TTY, 0); splx (s); return; } ttyowake(tp); if (tp->t_outq.c_cc == 0) goto out; if (reg->sta & PIC32_USTA_TRMT) { c = getc(&tp->t_outq); reg->txreg = c & 0xff; tp->t_state |= TS_BUSY; } /* Enable transmit interrupt. */ if (uirq[unit].tx < 32) { IECSET(0) = 1 << uirq[unit].tx; } else if (uirq[unit].tx < 64) { IECSET(1) = 1 << (uirq[unit].tx - 32); } else { IECSET(2) = 1 << (uirq[unit].tx - 64); } led_control (LED_TTY, 1); splx (s); } void uartputc(dev_t dev, char c) { int unit = minor(dev); struct tty *tp = &uartttys[unit]; register struct uartreg *reg = uart[unit]; register int s, timo; s = spltty(); again: /* * Try waiting for the console tty to come ready, * otherwise give up after a reasonable time. */ timo = 30000; while ((reg->sta & PIC32_USTA_TRMT) == 0) if (--timo == 0) break; if (tp->t_state & TS_BUSY) { uartintr (dev); goto again; } led_control (LED_TTY, 1); reg->txreg = c; timo = 30000; while ((reg->sta & PIC32_USTA_TRMT) == 0) if (--timo == 0) break; /* Clear TX interrupt. */ if (uirq[unit].tx < 32) { IECCLR(0) = 1 << uirq[unit].tx; } else if (uirq[unit].tx < 64) { IECCLR(1) = 1 << (uirq[unit].tx - 32); } else { IECCLR(2) = 1 << (uirq[unit].tx - 64); } led_control(LED_TTY, 0); splx(s); } char uartgetc(dev_t dev) { int unit = minor(dev); register struct uartreg *reg = uart[unit]; int s, c; s = spltty(); for (;;) { /* Wait for key pressed. */ if (reg->sta & PIC32_USTA_URXDA) { c = reg->rxreg; break; } } if (uirq[unit].rx < 32) { IFSCLR(0) = (1 << uirq[unit].rx) | (1 << uirq[unit].er); } else if (uirq[unit].rx < 64) { IFSCLR(1) = (1 << (uirq[unit].rx-32)) | (1 << (uirq[unit].er-32)); } else { IFSCLR(2) = (1 << (uirq[unit].rx-64)) | (1 << (uirq[unit].er-64)); } splx(s); return (unsigned char) c; } /* * Test to see if device is present. * Return true if found and initialized ok. */ static int uartprobe(config) struct conf_device *config; { int unit = config->dev_unit - 1; int is_console = (CONS_MAJOR == UART_MAJOR && CONS_MINOR == unit); int rx, tx; static const int rx_tab[NUART] = { GPIO_PIN('D',2), /* U1RX: 64pin - RD2, 100pin - RF2 */ GPIO_PIN('F',4), /* U2RX */ GPIO_PIN('G',7), /* U3RX */ GPIO_PIN('D',9), /* U4RX: 64pin - RD9, 100pin - RD14 */ GPIO_PIN('B',8), /* U5RX: 64pin - RB8, 100pin - RF12 */ GPIO_PIN('G',9), /* U6RX */ }; static const int tx_tab[NUART] = { GPIO_PIN('D',3), /* U1TX: 64pin - RD3, 100pin - RF8 */ GPIO_PIN('F',5), /* U2TX */ GPIO_PIN('G',8), /* U3TX */ GPIO_PIN('D',1), /* U4TX: 64pin - RD1, 100pin - RD15 */ GPIO_PIN('B',14), /* U5TX: 64pin - RB14, 100pin - RF13 */ GPIO_PIN('G',6), /* U6TX */ }; if (unit < 0 || unit >= NUART) return 0; rx = rx_tab[unit]; tx = tx_tab[unit]; if (cpu_pins > 64) { /* Ports UART1, UART4 and UART5 have different pin assignments * for 100-pin packages. */ switch (unit + 1) { case 1: rx = GPIO_PIN('F',2); tx = GPIO_PIN('F',8); break; case 4: rx = GPIO_PIN('D',14); tx = GPIO_PIN('D',15); break; case 5: rx = GPIO_PIN('F',12); tx = GPIO_PIN('F',13); break; } } printf("uart%d: pins rx=R%c%d/tx=R%c%d, interrupts %u/%u/%u", unit+1, gpio_portname(rx), gpio_pinno(rx), gpio_portname(tx), gpio_pinno(tx), uirq[unit].er, uirq[unit].rx, uirq[unit].tx); if (is_console) printf(", console"); printf("\n"); /* Initialize the device. */ uartttys[unit].t_addr = (caddr_t) uart[unit]; if (! is_console) uartinit(unit); return 1; } struct driver uartdriver = { "uart", uartprobe, }; ================================================ FILE: sys/arch/pic32/dev/uart.h ================================================ #ifndef _UART_H #define _UART_H #define NUART 6 #ifdef KERNEL void uartinit(int unit); int uartopen(dev_t dev, int flag, int mode); int uartclose(dev_t dev, int flag, int mode); int uartread(dev_t dev, struct uio * uio, int flag); int uartwrite(dev_t dev, struct uio *uio, int flag); int uartselect(dev_t dev, int rw); int uartioctl(dev_t dev, u_int cmd, caddr_t addr, int flag); void uartintr(dev_t dev); void uartstart(struct tty *tp); void uartputc(dev_t dev, char c); char uartgetc(dev_t dev); extern struct tty uartttys[NUART]; #endif #endif ================================================ FILE: sys/arch/pic32/dev/usb_uart.c ================================================ /* * Console driver via USB. * * Copyright (C) 2011 Serge Vakulenko, * * Permission to use, copy, modify, and distribute this software * and its documentation for any purpose and without fee is hereby * granted, provided that the above copyright notice appear in all * copies and that both that the copyright notice and this * permission notice and warranty disclaimer appear in supporting * documentation, and that the name of the author not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * * The author disclaim all warranties with regard to this * software, including all implied warranties of merchantability * and fitness. In no event shall the author be liable for any * special, indirect or consequential damages or any damages * whatsoever resulting from loss of use, data or profits, whether * in an action of contract, negligence or other tortious action, * arising out of or in connection with the use or performance of * this software. */ #include #include #include #include #include #include #include #include #include #include #define CONCAT(x,y) x ## y #define BBAUD(x) CONCAT(B,x) #ifndef UARTUSB_BAUD #define UARTUSB_BAUD 115200 #endif static unsigned speed_bps [NSPEEDS] = { 0, 50, 75, 150, 200, 300, 600, 1200, 1800, 2400, 4800, 9600, 19200, 38400, 57600, 115200, 230400, 460800, 500000, 576000, 921600, 1000000, 1152000, 1500000, 2000000, 2500000, 3000000, 3500000, 4000000 }; struct tty usbttys [1]; void usbstart (struct tty *tp); int usbopen (dev_t dev, int flag, int mode); /* * Initialize USB module SFRs and firmware variables to known state. * Enable interrupts. */ void usbinit() { usb_device_init(); IECSET(1) = 1 << (PIC32_IRQ_USB - 32); #if !defined(USB_AUTOBOOT) /* Wait for any user input. */ while (! cdc_consume(0)) #endif usb_device_tasks(); } int usbopen (dev_t dev, int flag, int mode) { register struct tty *tp = &usbttys[0]; tp->t_oproc = usbstart; if ((tp->t_state & TS_ISOPEN) == 0) { tp->t_ispeed = BBAUD(UARTUSB_BAUD); tp->t_ospeed = BBAUD(UARTUSB_BAUD); ttychars(tp); tp->t_state = TS_ISOPEN | TS_CARR_ON; tp->t_flags = ECHO | XTABS | CRMOD | CRTBS | CRTERA | CTLECH | CRTKIL; } if ((tp->t_state & TS_XCLUDE) && u.u_uid != 0) return (EBUSY); if (tp->t_ispeed == 0) { tp->t_ispeed = BBAUD(UARTUSB_BAUD); tp->t_ospeed = BBAUD(UARTUSB_BAUD); } cdc_set_line_coding(speed_bps[tp->t_ospeed], NUM_STOP_BITS_1, PARITY_NONE, 8); return ttyopen (dev, tp); } int usbclose (dev, flag, mode) dev_t dev; int flag; int mode; { register struct tty *tp = &usbttys[0]; ttywflush(tp); ttyclose (tp); return 0; } int usbread (dev, uio, flag) dev_t dev; struct uio *uio; int flag; { register struct tty *tp = &usbttys[0]; return ttread (tp, uio, flag); } int usbwrite (dev, uio, flag) dev_t dev; struct uio *uio; int flag; { register struct tty *tp = &usbttys[0]; return ttwrite (tp, uio, flag); } int usbioctl (dev, cmd, addr, flag) dev_t dev; register u_int cmd; caddr_t addr; int flag; { register struct tty *tp = &usbttys[0]; register int error; error = ttioctl (tp, cmd, addr, flag); if (error < 0) error = ENOTTY; return error; } int usbselect (dev, rw) register dev_t dev; int rw; { register struct tty *tp = &usbttys[0]; return ttyselect (tp, rw); } void usbstart (tp) register struct tty *tp; { register int s; s = spltty(); if (tp->t_state & (TS_TIMEOUT | TS_BUSY | TS_TTSTOP)) { out: /* Disable transmit_interrupt. */ led_control (LED_TTY, 0); splx (s); return; } ttyowake(tp); if (tp->t_outq.c_cc == 0) goto out; if (cdc_is_tx_ready()) { while (tp->t_outq.c_cc != 0) { int c = getc (&tp->t_outq); if (cdc_putc (c) == 0) break; } cdc_tx_service(); tp->t_state |= TS_BUSY; } led_control (LED_TTY, 1); splx (s); } /* * Put a symbol on console terminal. */ void usbputc(dev_t dev, char c) { register int s; s = spltty(); while (! cdc_is_tx_ready()) { usb_device_tasks(); cdc_tx_service(); } led_control (LED_TTY, 1); cdc_putc (c); cdc_tx_service(); while (! cdc_is_tx_ready()) { cdc_tx_service(); usb_device_tasks(); } led_control (LED_TTY, 0); splx (s); } static int getc_data; /* * Receive a character for getc. */ static void store_char (int c) { getc_data = (unsigned char) c; } /* * Receive a symbol from console terminal. */ char usbgetc(dev_t dev) { register int s; s = spltty(); for (getc_data = -1; getc_data < 0; ) { usb_device_tasks(); cdc_consume (store_char); cdc_tx_service(); } splx (s); return getc_data; } /* * Receive a character from CDC. */ static void usb_rx (int c) { register struct tty *tp = &usbttys[0]; if ((tp->t_state & TS_ISOPEN) == 0) return; ttyinput (c, tp); } /* * Check bus status and service USB interrupts. */ void usbintr (int chan) { register struct tty *tp = &usbttys[0]; // Must call this function from interrupt or periodically. usb_device_tasks(); // Check that USB connection is established. if (usb_device_state < CONFIGURED_STATE || (U1PWRC & PIC32_U1PWRC_USUSPEND)) return; // Receive data from user. cdc_consume (usb_rx); if (cdc_is_tx_ready()) { // Transmitter empty. led_control (LED_TTY, 0); if (tp->t_state & TS_BUSY) { tp->t_state &= ~TS_BUSY; ttstart (tp); } } // Transmit data to user. cdc_tx_service(); } /* * Test to see if device is present. * Return true if found and initialized ok. */ static int usbprobe(config) struct conf_device *config; { int is_console = (CONS_MAJOR == UARTUSB_MAJOR); printf("uartusb: port USB, interrupt %u", PIC32_VECT_USB); if (is_console) printf(", console"); printf("\n"); return 1; } struct driver uartusbdriver = { "uartusb", usbprobe, }; /* * USB Callback Functions */ /* * This function is called when the device becomes initialized. * It should initialize the endpoints for the device's usage * according to the current configuration. */ void usbcb_init_ep() { cdc_init_ep(); } /* * Process device-specific SETUP requests. */ void usbcb_check_other_req() { cdc_check_request(); } #if 0 /* * Wake up a host PC. */ void usb_send_resume (void) { /* Start RESUME signaling. */ U1CON |= PIC32_U1CON_RESUME; /* Set RESUME line for 1-13 ms. */ udelay (5000); U1CON &= ~PIC32_U1CON_RESUME; } #endif #ifndef CONSOLE_VID # define CONSOLE_VID 0x04D8 // Vendor ID: Microchip #endif #ifndef CONSOLE_PID # define CONSOLE_PID 0x000A // Product ID: CDC RS-232 Emulation Demo #endif /* * Device Descriptor */ const USB_DEVICE_DESCRIPTOR usb_device = { sizeof(usb_device), // Size of this descriptor in bytes USB_DESCRIPTOR_DEVICE, // DEVICE descriptor type 0x0200, // USB Spec Release Number in BCD format CDC_DEVICE, // Class Code 0x00, // Subclass code 0x00, // Protocol code USB_EP0_BUFF_SIZE, // Max packet size for EP0, see usb_config.h CONSOLE_VID, // Vendor ID CONSOLE_PID, // Product ID 0x0100, // Device release number in BCD format 0x01, // Manufacturer string index 0x02, // Product string index 0x00, // Device serial number string index 0x01 // Number of possible configurations }; /* * Configuration 1 Descriptor */ const unsigned char usb_config1_descriptor[] = { /* Configuration Descriptor */ 9, // sizeof(USB_CFG_DSC) USB_DESCRIPTOR_CONFIGURATION, // CONFIGURATION descriptor type 67, 0, // Total length of data for this cfg 2, // Number of interfaces in this cfg 1, // Index value of this configuration 0, // Configuration string index _DEFAULT | _SELF, // Attributes, see usb_device.h 150, // Max power consumption (2X mA) /* Interface Descriptor */ 9, // sizeof(USB_INTF_DSC) USB_DESCRIPTOR_INTERFACE, // INTERFACE descriptor type 0, // Interface Number 0, // Alternate Setting Number 1, // Number of endpoints in this intf COMM_INTF, // Class code ABSTRACT_CONTROL_MODEL, // Subclass code V25TER, // Protocol code 0, // Interface string index /* CDC Class-Specific Descriptors */ sizeof(USB_CDC_HEADER_FN_DSC), CS_INTERFACE, DSC_FN_HEADER, 0x10,0x01, sizeof(USB_CDC_ACM_FN_DSC), CS_INTERFACE, DSC_FN_ACM, USB_CDC_ACM_FN_DSC_VAL, sizeof(USB_CDC_UNION_FN_DSC), CS_INTERFACE, DSC_FN_UNION, CDC_COMM_INTF_ID, CDC_DATA_INTF_ID, sizeof(USB_CDC_CALL_MGT_FN_DSC), CS_INTERFACE, DSC_FN_CALL_MGT, 0x00, CDC_DATA_INTF_ID, /* Endpoint Descriptor */ 7, // sizeof(USB_EP_DSC) USB_DESCRIPTOR_ENDPOINT, // Endpoint Descriptor _EP02_IN, // EndpointAddress _INTERRUPT, // Attributes 0x08, 0x00, // size 0x02, // Interval /* Interface Descriptor */ 9, // sizeof(USB_INTF_DSC) USB_DESCRIPTOR_INTERFACE, // INTERFACE descriptor type 1, // Interface Number 0, // Alternate Setting Number 2, // Number of endpoints in this intf DATA_INTF, // Class code 0, // Subclass code NO_PROTOCOL, // Protocol code 0, // Interface string index /* Endpoint Descriptor */ 7, // sizeof(USB_EP_DSC) USB_DESCRIPTOR_ENDPOINT, // Endpoint Descriptor _EP03_OUT, // EndpointAddress _BULK, // Attributes 0x40, 0x00, // size 0x00, // Interval /* Endpoint Descriptor */ 7, // sizeof(USB_EP_DSC) USB_DESCRIPTOR_ENDPOINT, // Endpoint Descriptor _EP03_IN, // EndpointAddress _BULK, // Attributes 0x40, 0x00, // size 0x00, // Interval }; /* * Language code string descriptor. */ static const USB_STRING_INIT(1) string0_descriptor = { sizeof(string0_descriptor), USB_DESCRIPTOR_STRING, { 0x0409 } /* US English */ }; /* * Manufacturer string descriptor */ static const USB_STRING_INIT(25) string1_descriptor = { sizeof(string1_descriptor), USB_DESCRIPTOR_STRING, { 'M','i','c','r','o','c','h','i','p',' ', 'T','e','c','h','n','o','l','o','g','y', ' ','I','n','c','.', }, }; /* * Product string descriptor */ static const USB_STRING_INIT(16) string2_descriptor = { sizeof(string2_descriptor), USB_DESCRIPTOR_STRING, { 'R','e','t','r','o','B','S','D',' ','C', 'o','n','s','o','l','e', }, }; /* * Array of configuration descriptors */ const unsigned char *const usb_config[] = { (const unsigned char *const) &usb_config1_descriptor, }; /* * Array of string descriptors */ const unsigned char *const usb_string[USB_NUM_STRING_DESCRIPTORS] = { (const unsigned char *const) &string0_descriptor, (const unsigned char *const) &string1_descriptor, (const unsigned char *const) &string2_descriptor, }; ================================================ FILE: sys/arch/pic32/dev/usb_uart.h ================================================ /* * Console driver via USB. * * Copyright (C) 2011 Serge Vakulenko, * * Permission to use, copy, modify, and distribute this software * and its documentation for any purpose and without fee is hereby * granted, provided that the above copyright notice appear in all * copies and that both that the copyright notice and this * permission notice and warranty disclaimer appear in supporting * documentation, and that the name of the author not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * * The author disclaim all warranties with regard to this * software, including all implied warranties of merchantability * and fitness. In no event shall the author be liable for any * special, indirect or consequential damages or any damages * whatsoever resulting from loss of use, data or profits, whether * in an action of contract, negligence or other tortious action, * arising out of or in connection with the use or performance of * this software. */ #ifndef _USB_UART_H #define _USB_UART_H #define USB_MAJOR 13 extern struct tty usbttys[1]; extern void usbinit(); extern int usbopen(dev_t dev, int flag, int mode); extern int usbclose(dev_t dev, int flag, int mode); extern int usbread(dev_t dev, struct uio *uio, int flag); extern int usbwrite(dev_t dev, struct uio *uio, int flag); extern int usbioctl(dev_t dev, register u_int cmd, caddr_t addr, int flag); extern int usbselect(dev_t dev, int rw); extern void usbstart (register struct tty *tp); extern void usbputc(dev_t dev, char c); extern char usbgetc(dev_t dev); extern void usbintr(int chan); #endif ================================================ FILE: sys/arch/pic32/hal/usb_ch9.h ================================================ /* * USB Chapter 9 Protocol (Header File) * * This file defines data structures, constants, and macros that are used to * to support the USB Device Framework protocol described in Chapter 9 of the * USB 2.0 specification. * * The software supplied herewith by Microchip Technology Incorporated * (the 'Company') for its PICmicro(R) Microcontroller is intended and * supplied to you, the Company's customer, for use solely and * exclusively on Microchip PICmicro Microcontroller products. The * software is owned by the Company and/or its supplier, and is * protected under applicable copyright laws. All rights are reserved. * Any use in violation of the foregoing restrictions may subject the * user to criminal sanctions under applicable laws, as well as to * civil liability for the breach of the terms and conditions of this * license. * * THIS SOFTWARE IS PROVIDED IN AN 'AS IS' CONDITION. NO WARRANTIES, * WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED * TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT, * IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. */ #ifndef _USB_CH9_H_ #define _USB_CH9_H_ // // Section: USB Descriptors // #define USB_DESCRIPTOR_DEVICE 0x01 // bDescriptorType for a Device Descriptor. #define USB_DESCRIPTOR_CONFIGURATION 0x02 // bDescriptorType for a Configuration Descriptor. #define USB_DESCRIPTOR_STRING 0x03 // bDescriptorType for a String Descriptor. #define USB_DESCRIPTOR_INTERFACE 0x04 // bDescriptorType for an Interface Descriptor. #define USB_DESCRIPTOR_ENDPOINT 0x05 // bDescriptorType for an Endpoint Descriptor. #define USB_DESCRIPTOR_DEVICE_QUALIFIER 0x06 // bDescriptorType for a Device Qualifier. #define USB_DESCRIPTOR_OTHER_SPEED 0x07 // bDescriptorType for a Other Speed Configuration. #define USB_DESCRIPTOR_INTERFACE_POWER 0x08 // bDescriptorType for Interface Power. #define USB_DESCRIPTOR_OTG 0x09 // bDescriptorType for an OTG Descriptor. /* * USB Device Descriptor Structure * * This struct defines the structure of a USB Device Descriptor. Note that this * structure may need to be packed, or even accessed as bytes, to properly access * the correct fields when used on some device architectures. */ typedef struct __attribute__ ((packed)) _USB_DEVICE_DESCRIPTOR { unsigned char bLength; // Length of this descriptor. unsigned char bDescriptorType; // DEVICE descriptor type (USB_DESCRIPTOR_DEVICE). unsigned short bcdUSB; // USB Spec Release Number (BCD). unsigned char bDeviceClass; // Class code (assigned by the USB-IF). 0xFF-Vendor specific. unsigned char bDeviceSubClass; // Subclass code (assigned by the USB-IF). unsigned char bDeviceProtocol; // Protocol code (assigned by the USB-IF). 0xFF-Vendor specific. unsigned char bMaxPacketSize0; // Maximum packet size for endpoint 0. unsigned short idVendor; // Vendor ID (assigned by the USB-IF). unsigned short idProduct; // Product ID (assigned by the manufacturer). unsigned short bcdDevice; // Device release number (BCD). unsigned char iManufacturer; // Index of String Descriptor describing the manufacturer. unsigned char iProduct; // Index of String Descriptor describing the product. unsigned char iSerialNumber; // Index of String Descriptor with the device's serial number. unsigned char bNumConfigurations; // Number of possible configurations. } USB_DEVICE_DESCRIPTOR; /* * USB Configuration Descriptor Structure * * This struct defines the structure of a USB Configuration Descriptor. Note that this * structure may need to be packed, or even accessed as bytes, to properly access * the correct fields when used on some device architectures. */ typedef struct __attribute__ ((packed)) _USB_CONFIGURATION_DESCRIPTOR { unsigned char bLength; // Length of this descriptor. unsigned char bDescriptorType; // CONFIGURATION descriptor type (USB_DESCRIPTOR_CONFIGURATION). unsigned short wTotalLength; // Total length of all descriptors for this configuration. unsigned char bNumInterfaces; // Number of interfaces in this configuration. unsigned char bConfigurationValue; // Value of this configuration (1 based). unsigned char iConfiguration; // Index of String Descriptor describing the configuration. unsigned char bmAttributes; // Configuration characteristics. unsigned char bMaxPower; // Maximum power consumed by this configuration. } USB_CONFIGURATION_DESCRIPTOR; // Attributes bits #define USB_CFG_DSC_REQUIRED 0x80 // Required attribute #define USB_CFG_DSC_SELF_PWR (0x40 | USB_CFG_DSC_REQUIRED) // Device is self powered. #define USB_CFG_DSC_REM_WAKE (0x20 | USB_CFG_DSC_REQUIRED) // Device can request remote wakup /* * USB Interface Descriptor Structure * * This struct defines the structure of a USB Interface Descriptor. Note that this * structure may need to be packed, or even accessed as bytes, to properly access * the correct fields when used on some device architectures. */ typedef struct __attribute__ ((packed)) _USB_INTERFACE_DESCRIPTOR { unsigned char bLength; // Length of this descriptor. unsigned char bDescriptorType; // INTERFACE descriptor type (USB_DESCRIPTOR_INTERFACE). unsigned char bInterfaceNumber; // Number of this interface (0 based). unsigned char bAlternateSetting; // Value of this alternate interface setting. unsigned char bNumEndpoints; // Number of endpoints in this interface. unsigned char bInterfaceClass; // Class code (assigned by the USB-IF). 0xFF-Vendor specific. unsigned char bInterfaceSubClass; // Subclass code (assigned by the USB-IF). unsigned char bInterfaceProtocol; // Protocol code (assigned by the USB-IF). 0xFF-Vendor specific. unsigned char iInterface; // Index of String Descriptor describing the interface. } USB_INTERFACE_DESCRIPTOR; // ***************************************************************************** /* USB Endpoint Descriptor Structure This struct defines the structure of a USB Endpoint Descriptor. Note that this structure may need to be packed, or even accessed as bytes, to properly access the correct fields when used on some device architectures. */ typedef struct __attribute__ ((packed)) _USB_ENDPOINT_DESCRIPTOR { unsigned char bLength; // Length of this descriptor. unsigned char bDescriptorType; // ENDPOINT descriptor type (USB_DESCRIPTOR_ENDPOINT). unsigned char bEndpointAddress; // Endpoint address. Bit 7 indicates direction (0=OUT, 1=IN). unsigned char bmAttributes; // Endpoint transfer type. unsigned short wMaxPacketSize; // Maximum packet size. unsigned char bInterval; // Polling interval in frames. } USB_ENDPOINT_DESCRIPTOR; // Endpoint Direction #define EP_DIR_IN 0x80 // Data flows from device to host #define EP_DIR_OUT 0x00 // Data flows from host to device // ****************************************************************** // USB Endpoint Attributes // ****************************************************************** // Section: Transfer Types #define EP_ATTR_CONTROL (0<<0) // Endoint used for control transfers #define EP_ATTR_ISOCH (1<<0) // Endpoint used for isochronous transfers #define EP_ATTR_BULK (2<<0) // Endpoint used for bulk transfers #define EP_ATTR_INTR (3<<0) // Endpoint used for interrupt transfers // Section: Synchronization Types (for isochronous enpoints) #define EP_ATTR_NO_SYNC (0<<2) // No Synchronization #define EP_ATTR_ASYNC (1<<2) // Asynchronous #define EP_ATTR_ADAPT (2<<2) // Adaptive synchronization #define EP_ATTR_SYNC (3<<2) // Synchronous // Section: Usage Types (for isochronous endpoints) #define EP_ATTR_DATA (0<<4) // Data Endpoint #define EP_ATTR_FEEDBACK (1<<4) // Feedback endpoint #define EP_ATTR_IMP_FB (2<<4) // Implicit Feedback data EP // Section: Max Packet Sizes #define EP_MAX_PKT_INTR_LS 8 // Max low-speed interrupt packet #define EP_MAX_PKT_INTR_FS 64 // Max full-speed interrupt packet #define EP_MAX_PKT_ISOCH_FS 1023 // Max full-speed isochronous packet #define EP_MAX_PKT_BULK_FS 64 // Max full-speed bulk packet #define EP_LG_PKT_BULK_FS 32 // Large full-speed bulk packet #define EP_MED_PKT_BULK_FS 16 // Medium full-speed bulk packet #define EP_SM_PKT_BULK_FS 8 // Small full-speed bulk packet // ***************************************************************************** /* USB OTG Descriptor Structure This struct defines the structure of a USB OTG Descriptor. Note that this structure may need to be packed, or even accessed as bytes, to properly access the correct fields when used on some device architectures. */ typedef struct __attribute__ ((packed)) _USB_OTG_DESCRIPTOR { unsigned char bLength; // Length of this descriptor. unsigned char bDescriptorType; // OTG descriptor type (USB_DESCRIPTOR_OTG). unsigned char bmAttributes; // OTG attributes. } USB_OTG_DESCRIPTOR; // ****************************************************************** // Section: USB String Descriptor Structure // ****************************************************************** // This structure describes the USB string descriptor. The string // descriptor provides user-readable information about various aspects of // the device. The first string desriptor (string descriptor zero (0)), // provides a list of the number of languages supported by the set of // string descriptors for this device instead of an actual string. // // Note: The strings are in 2-byte-per-character unicode, not ASCII. // // Note: This structure only describes the "header" of the string // descriptor. The actual data (either the language ID array or the // array of unicode characters making up the string, must be allocated // immediately following this header with no padding between them. typedef struct __attribute__ ((packed)) _USB_STRING_DSC { unsigned char bLength; // Size of this descriptor unsigned char bDescriptorType; // Type, USB_DSC_STRING } USB_STRING_DESCRIPTOR; #define USB_STRING_INIT(nchars) struct {\ unsigned char bLength; \ unsigned char bDescriptorType; \ unsigned short string[nchars]; \ } // ****************************************************************** // Section: USB Device Qualifier Descriptor Structure // ****************************************************************** // This structure describes the device qualifier descriptor. The device // qualifier descriptor provides overall device information if the device // supports "other" speeds. // // Note: A high-speed device may support "other" speeds (ie. full or low). // If so, it may need to implement the the device qualifier and other // speed descriptors. typedef struct __attribute__ ((packed)) _USB_DEVICE_QUALIFIER_DESCRIPTOR { unsigned char bLength; // Size of this descriptor unsigned char bType; // Type, always USB_DESCRIPTOR_DEVICE_QUALIFIER unsigned short bcdUSB; // USB spec version, in BCD unsigned char bDeviceClass; // Device class code unsigned char bDeviceSubClass; // Device sub-class code unsigned char bDeviceProtocol; // Device protocol unsigned char bMaxPacketSize0; // EP0, max packet size unsigned char bNumConfigurations; // Number of "other-speed" configurations unsigned char bReserved; // Always zero (0) } USB_DEVICE_QUALIFIER_DESCRIPTOR; // ****************************************************************** // Section: USB Setup Packet Structure // ****************************************************************** // This structure describes the data contained in a USB standard device // request's setup packet. It is the data packet sent from the host to // the device to control and configure the device. // // Note: Refer to the USB 2.0 specification for additional details on the // usage of the setup packet and standard device requests. typedef struct __attribute__ ((packed)) { union // offset description { // ------ ------------------------ unsigned char bmRequestType; // 0 Bit-map of request type struct { unsigned recipient: 5; // Recipient of the request unsigned type: 2; // Type of request unsigned direction: 1; // Direction of data X-fer }; } requestInfo; unsigned char bRequest; // 1 Request type unsigned short wValue; // 2 Depends on bRequest unsigned short wIndex; // 4 Depends on bRequest unsigned short wLength; // 6 Depends on bRequest } SETUP_PKT, *PSETUP_PKT; // // Section: USB Specification Constants // // Section: Valid PID Values #define PID_OUT 0x1 // PID for an OUT token #define PID_ACK 0x2 // PID for an ACK handshake #define PID_DATA0 0x3 // PID for DATA0 data #define PID_PING 0x4 // Special PID PING #define PID_SOF 0x5 // PID for a SOF token #define PID_NYET 0x6 // PID for a NYET handshake #define PID_DATA2 0x7 // PID for DATA2 data #define PID_SPLIT 0x8 // Special PID SPLIT #define PID_IN 0x9 // PID for a IN token #define PID_NAK 0xA // PID for a NAK handshake #define PID_DATA1 0xB // PID for DATA1 data #define PID_PRE 0xC // Special PID PRE (Same as PID_ERR) #define PID_ERR 0xC // Special PID ERR (Same as PID_PRE) #define PID_SETUP 0xD // PID for a SETUP token #define PID_STALL 0xE // PID for a STALL handshake #define PID_MDATA 0xF // PID for MDATA data #define PID_MASK_DATA 0x03 // Data PID mask #define PID_MASK_DATA_SHIFTED (PID_MASK_DATA << 2) // Data PID shift to proper position // Section: USB Token Types #define USB_TOKEN_OUT 0x01 // U1TOK - OUT token #define USB_TOKEN_IN 0x09 // U1TOK - IN token #define USB_TOKEN_SETUP 0x0D // U1TOK - SETUP token // Section: OTG Descriptor Constants #define OTG_HNP_SUPPORT 0x02 // OTG Descriptor bmAttributes - HNP support flag #define OTG_SRP_SUPPORT 0x01 // OTG Descriptor bmAttributes - SRP support flag // Section: Endpoint Directions #define USB_IN_EP 0x80 // IN endpoint mask #define USB_OUT_EP 0x00 // OUT endpoint mask // Section: Standard Device Requests #define USB_REQUEST_GET_STATUS 0 // Standard Device Request - GET STATUS #define USB_REQUEST_CLEAR_FEATURE 1 // Standard Device Request - CLEAR FEATURE #define USB_REQUEST_SET_FEATURE 3 // Standard Device Request - SET FEATURE #define USB_REQUEST_SET_ADDRESS 5 // Standard Device Request - SET ADDRESS #define USB_REQUEST_GET_DESCRIPTOR 6 // Standard Device Request - GET DESCRIPTOR #define USB_REQUEST_SET_DESCRIPTOR 7 // Standard Device Request - SET DESCRIPTOR #define USB_REQUEST_GET_CONFIGURATION 8 // Standard Device Request - GET CONFIGURATION #define USB_REQUEST_SET_CONFIGURATION 9 // Standard Device Request - SET CONFIGURATION #define USB_REQUEST_GET_INTERFACE 10 // Standard Device Request - GET INTERFACE #define USB_REQUEST_SET_INTERFACE 11 // Standard Device Request - SET INTERFACE #define USB_REQUEST_SYNCH_FRAME 12 // Standard Device Request - SYNCH FRAME #define USB_FEATURE_ENDPOINT_HALT 0 // CLEAR/SET FEATURE - Endpoint Halt #define USB_FEATURE_DEVICE_REMOTE_WAKEUP 1 // CLEAR/SET FEATURE - Device remote wake-up #define USB_FEATURE_TEST_MODE 2 // CLEAR/SET FEATURE - Test mode // Section: Setup Data Constants #define USB_SETUP_HOST_TO_DEVICE 0x00 // Device Request bmRequestType transfer direction - host to device transfer #define USB_SETUP_DEVICE_TO_HOST 0x80 // Device Request bmRequestType transfer direction - device to host transfer #define USB_SETUP_TYPE_STANDARD 0x00 // Device Request bmRequestType type - standard #define USB_SETUP_TYPE_CLASS 0x20 // Device Request bmRequestType type - class #define USB_SETUP_TYPE_VENDOR 0x40 // Device Request bmRequestType type - vendor #define USB_SETUP_RECIPIENT_DEVICE 0x00 // Device Request bmRequestType recipient - device #define USB_SETUP_RECIPIENT_INTERFACE 0x01 // Device Request bmRequestType recipient - interface #define USB_SETUP_RECIPIENT_ENDPOINT 0x02 // Device Request bmRequestType recipient - endpoint #define USB_SETUP_RECIPIENT_OTHER 0x03 // Device Request bmRequestType recipient - other // Section: OTG SET FEATURE Constants #define OTG_FEATURE_B_HNP_ENABLE 3 // SET FEATURE OTG - Enable B device to perform HNP #define OTG_FEATURE_A_HNP_SUPPORT 4 // SET FEATURE OTG - A device supports HNP #define OTG_FEATURE_A_ALT_HNP_SUPPORT 5 // SET FEATURE OTG - Another port on the A device supports HNP // Section: USB Endpoint Transfer Types #define USB_TRANSFER_TYPE_CONTROL 0x00 // Endpoint is a control endpoint. #define USB_TRANSFER_TYPE_ISOCHRONOUS 0x01 // Endpoint is an isochronous endpoint. #define USB_TRANSFER_TYPE_BULK 0x02 // Endpoint is a bulk endpoint. #define USB_TRANSFER_TYPE_INTERRUPT 0x03 // Endpoint is an interrupt endpoint. // Section: Standard Feature Selectors for CLEAR_FEATURE Requests #define USB_FEATURE_ENDPOINT_STALL 0 // Endpoint recipient #define USB_FEATURE_DEVICE_REMOTE_WAKEUP 1 // Device recipient #define USB_FEATURE_TEST_MODE 2 // Device recipient // Section: USB Class Code Definitions #define USB_HUB_CLASSCODE 0x09 // Class code for a hub. #endif // _USB_CH9_H_ ================================================ FILE: sys/arch/pic32/hal/usb_device.c ================================================ /* * This file contains functions, macros, definitions, variables, * datatypes, etc. that are required for usage with the MCHPFSUSB device * stack. This file should be included in projects that use the device stack. * * The software supplied herewith by Microchip Technology Incorporated * (the 'Company') for its PIC(R) Microcontroller is intended and * supplied to you, the Company's customer, for use solely and * exclusively on Microchip PIC Microcontroller products. The * software is owned by the Company and/or its supplier, and is * protected under applicable copyright laws. All rights are reserved. * Any use in violation of the foregoing restrictions may subject the * user to criminal sanctions under applicable laws, as well as to * civil liability for the breach of the terms and conditions of this license. * * THIS SOFTWARE IS PROVIDED IN AN 'AS IS' CONDITION. NO WARRANTIES, * WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED * TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT, * IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. */ #include #include #if (USB_PING_PONG_MODE != USB_PING_PONG__FULL_PING_PONG) #error "PIC32 only supports full ping pong mode." #endif unsigned usb_device_state; unsigned usb_active_configuration; static unsigned char usb_alternate_interface[USB_MAX_NUM_INT]; static volatile BDT_ENTRY *pBDTEntryEP0OutCurrent; static volatile BDT_ENTRY *pBDTEntryEP0OutNext; static volatile BDT_ENTRY *pBDTEntryOut[USB_MAX_EP_NUMBER+1]; static volatile BDT_ENTRY *pBDTEntryIn[USB_MAX_EP_NUMBER+1]; static unsigned short_packet_status; static unsigned control_transfer_state; static unsigned ustat_saved; IN_PIPE usb_in_pipe[1]; OUT_PIPE usb_out_pipe[1]; int usb_remote_wakeup; /* * Section A: Buffer Descriptor Table * - 0x400 - 0x4FF(max) * - USB_MAX_EP_NUMBER is defined in target.cfg */ volatile BDT_ENTRY usb_buffer [(USB_MAX_EP_NUMBER + 1) * 4] __attribute__ ((aligned (512))); /* * Section B: EP0 Buffer Space */ volatile CTRL_TRF_SETUP usb_setup_pkt; // 8-byte only // Buffer for control transfer data static volatile unsigned char ctrl_trf_data [USB_EP0_BUFF_SIZE]; /* * This function initializes the device stack * it in the default state * * The USB module will be completely reset including * all of the internal variables, registers, and * interrupt flags. */ void usb_device_init(void) { unsigned i; // Clear all USB error flags U1EIR = 0xFF; // Clears all USB interrupts U1IR = 0xFF; U1EIE = 0x9F; // Unmask all USB error interrupts U1IE = PIC32_U1I_URST | // Unmask Reset interrupt PIC32_U1I_IDLE | // Unmask Idle interrupt PIC32_U1I_UERR | // Unmask Error interrupt PIC32_U1I_TRN; // Transaction Complete Interrupt // Power up the module U1PWRC |= PIC32_U1PWRC_USBPWR; // Set the address of the BDT (if applicable) U1BDTP1 = (unsigned) usb_buffer >> 8; // Reset all of the Ping Pong buffers U1CON |= PIC32_U1CON_PPBRST; U1CON &= ~PIC32_U1CON_PPBRST; // Reset to default address U1ADDR = 0x00; // Clear all of the endpoint control registers for (i=1; iSTAT.Val == _USIE && pBDTEntryIn[0]->STAT.Val == (_USIE | _BSTALL)) { // Set ep0Bo to stall also pBDTEntryEP0OutCurrent->STAT.Val = _USIE|_DAT0|_DTSEN|_BSTALL; } // Clear stall status U1EP(0) &= ~PIC32_U1EP_EPSTALL; } U1IR = PIC32_U1I_STALL; } /* * This function handles if the host tries to suspend the device */ void usb_suspend(void) { /* * NOTE: Do not clear UIR_ACTVIF here! * Reason: * ACTVIF is only generated once an IDLEIF has been generated. * This is a 1:1 ratio interrupt generation. * For every IDLEIF, there will be only one ACTVIF regardless of * the number of subsequent bus transitions. * * If the ACTIF is cleared here, a problem could occur when: * [ IDLE ][bus activity -> * <--- 3 ms -----> ^ * ^ ACTVIF=1 * IDLEIF=1 * # # # # (#=Program polling flags) * ^ * This polling loop will see both * IDLEIF=1 and ACTVIF=1. * However, the program services IDLEIF first * because ACTIVIE=0. * If this routine clears the only ACTIVIF, * then it can never get out of the suspend * mode. */ U1OTGIE |= PIC32_U1OTGI_ACTV; // Enable bus activity interrupt U1IR = PIC32_U1I_IDLE; /* * At this point the PIC can go into sleep,idle, or * switch to a slower clock, etc. This should be done in the * usbcb_suspend() if necessary. */ usbcb_suspend(); // Required callback, see usbcallbacks.c } /* * Wake up the USB module from suspend. */ void usb_wake_from_suspend(void) { /* * If using clock switching, the place to restore the original * microcontroller core clock frequency is in the usbcb_wake_from_suspend() callback */ usbcb_wake_from_suspend(); // Required callback, see usbcallbacks.c U1OTGIE &= ~PIC32_U1OTGI_ACTV; /* Bug Fix: Feb 26, 2007 v2.1 ********************************************************************* The ACTVIF bit cannot be cleared immediately after the USB module wakes up from Suspend or while the USB module is suspended. A few clock cycles are required to synchronize the internal hardware state machine before the ACTIVIF bit can be cleared by firmware. Clearing the ACTVIF bit before the internal hardware is synchronized may not have an effect on the value of ACTVIF. Additonally, if the USB module uses the clock from the 96 MHz PLL source, then after clearing the SUSPND bit, the USB module may not be immediately operational while waiting for the 96 MHz PLL to lock. */ U1OTGIR = PIC32_U1OTGI_ACTV; } /* * usb_ctrl_ep_service checks for three transaction * types that it knows how to service and services them: * 1. EP0 SETUP * 2. EP0 OUT * 3. EP0 IN * It ignores all other types (i.e. EP1, EP2, etc.) * * PreCondition: USTAT is loaded with a valid endpoint address. */ void usb_ctrl_ep_service(void) { // If the last packet was a EP0 OUT packet if ((ustat_saved & USTAT_EP0_PP_MASK) == USTAT_EP0_OUT_EVEN) { // Point to the EP0 OUT buffer of the buffer that arrived pBDTEntryEP0OutCurrent = (volatile BDT_ENTRY*) &usb_buffer [(ustat_saved & USTAT_EP_MASK) >> 2]; // Set the next out to the current out packet pBDTEntryEP0OutNext = pBDTEntryEP0OutCurrent; // Toggle it to the next ping pong buffer (if applicable) *(unsigned char*)&pBDTEntryEP0OutNext ^= USB_NEXT_EP0_OUT_PING_PONG; // If the current EP0 OUT buffer has a SETUP token if (pBDTEntryEP0OutCurrent->STAT.PID == SETUP_TOKEN) { // Handle the control transfer usb_ctrl_trf_setup_handler(); } else { // Handle the DATA transfer usb_ctrl_trf_out_handler(); } } else if ((ustat_saved & USTAT_EP0_PP_MASK) == USTAT_EP0_IN) { // Otherwise the transmission was and EP0 IN // so take care of the IN transfer usb_ctrl_trf_in_handler(); } } /* * This routine is a task dispatcher and has 3 stages. * 1. It initializes the control transfer state machine. * 2. It calls on each of the module that may know how to * service the Setup Request from the host. * Module Example: USBD, HID, CDC, MSD, ... * A callback function, usbcb_check_other_req(), * is required to call other module handlers. * 3. Once each of the modules has had a chance to check if * it is responsible for servicing the request, stage 3 * then checks direction of the transfer to determine how * to prepare EP0 for the control transfer. * Refer to usb_ctrl_ep_service_complete() for more details. * * PreCondition: usb_setup_pkt buffer is loaded with valid USB Setup Data * * Microchip USB Firmware has three different states for * the control transfer state machine: * 1. WAIT_SETUP * 2. CTRL_TRF_TX * 3. CTRL_TRF_RX * Refer to firmware manual to find out how one state * is transitioned to another. * * A Control Transfer is composed of many USB transactions. * When transferring data over multiple transactions, * it is important to keep track of data source, data * destination, and data count. These three parameters are * stored in pSrc, pDst, and wCount. A flag is used to * note if the data source is from ROM or RAM. */ void usb_ctrl_trf_setup_handler(void) { //if the SIE currently owns the buffer if (pBDTEntryIn[0]->STAT.UOWN != 0) { // give control back to the CPU // Compensate for after a STALL pBDTEntryIn[0]->STAT.Val = _UCPU; } // Keep track of if a short packet has been sent yet or not short_packet_status = SHORT_PKT_NOT_USED; /* Stage 1 */ control_transfer_state = WAIT_SETUP; usb_in_pipe[0].wCount = 0; usb_in_pipe[0].info.Val = 0; /* Stage 2 */ usb_check_std_request(); usbcb_check_other_req(); // Required callback, see usbcallbacks.c /* Stage 3 */ usb_ctrl_ep_service_complete(); } /* * This routine handles an OUT transaction according to * which control transfer state is currently active. * * Note that if the the control transfer was from * host to device, the session owner should be notified * at the end of each OUT transaction to service the * received data. */ void usb_ctrl_trf_out_handler(void) { if (control_transfer_state == CTRL_TRF_RX) { usb_ctrl_trf_rx_service(); } else // CTRL_TRF_TX { usb_prepare_for_next_setup_trf(); } } /* * This routine handles an IN transaction according to * which control transfer state is currently active. * * A Set Address Request must not change the acutal address * of the device until the completion of the control * transfer. The end of the control transfer for Set Address * Request is an IN transaction. Therefore it is necessary * to service this unique situation when the condition is * right. Macro mUSBCheckAdrPendingState is defined in * usb9.h and its function is to specifically service this event. */ void usb_ctrl_trf_in_handler(void) { unsigned lastDTS; lastDTS = pBDTEntryIn[0]->STAT.DTS; //switch to the next ping pong buffer *(unsigned char*)&pBDTEntryIn[0] ^= USB_NEXT_EP0_IN_PING_PONG; //mUSBCheckAdrPendingState(); // Must check if in ADR_PENDING_STATE if (usb_device_state == ADR_PENDING_STATE) { U1ADDR = usb_setup_pkt.bDevADR; if (U1ADDR > 0) { usb_device_state = ADDRESS_STATE; } else { usb_device_state = DEFAULT_STATE; } }//end if if (control_transfer_state == CTRL_TRF_TX) { pBDTEntryIn[0]->ADR = ConvertToPhysicalAddress (ctrl_trf_data); usb_ctrl_trf_tx_service(); /* v2b fix */ if (short_packet_status == SHORT_PKT_SENT) { // If a short packet has been sent, don't want to send any more, // stall next time if host is still trying to read. pBDTEntryIn[0]->STAT.Val = _USIE|_BSTALL; } else { if (lastDTS == 0) { pBDTEntryIn[0]->STAT.Val = _USIE|_DAT1|_DTSEN; } else { pBDTEntryIn[0]->STAT.Val = _USIE|_DAT0|_DTSEN; } } } else { // CTRL_TRF_RX usb_prepare_for_next_setup_trf(); } } /* * The routine forces EP0 OUT to be ready for a new * Setup transaction, and forces EP0 IN to be owned by CPU. */ void usb_prepare_for_next_setup_trf(void) { /* Bug Fix: Feb 26, 2007 v2.1 ********************************************************************* Facts: A Setup Packet should never be stalled. (USB 2.0 Section 8.5.3) If a Setup PID is detected by the SIE, the DTSEN setting is ignored. This causes a problem at the end of a control write transaction. In usb_ctrl_ep_service_complete(), during a control write (Host to Device), the EP0_OUT is setup to write any data to the ctrl_trf_data buffer. If is completed and usb_ctrl_trf_in_handler() is not called before the next is received, then the latest Setup data will be written to the ctrl_trf_data buffer instead of the usb_setup_pkt buffer. If usb_ctrl_trf_in_handler() was called before the latest is received, then there would be no problem, because usb_prepare_for_next_setup_trf() would have been called and updated ep0Bo.ADR to point to the usb_setup_pkt buffer. Work around: Check for the problem as described above and copy the Setup data from ctrl_trf_data to usb_setup_pkt. */ if ((control_transfer_state == CTRL_TRF_RX) && (U1CON & PIC32_U1CON_PKTDIS) && (pBDTEntryEP0OutCurrent->CNT == sizeof(CTRL_TRF_SETUP)) && (pBDTEntryEP0OutCurrent->STAT.PID == SETUP_TOKEN) && (pBDTEntryEP0OutNext->STAT.UOWN == 0)) { unsigned setup_cnt; pBDTEntryEP0OutNext->ADR = ConvertToPhysicalAddress(&usb_setup_pkt); // The Setup data was written to the ctrl_trf_data buffer, must copy // it back to the usb_setup_pkt buffer so that it can be processed correctly // by usb_ctrl_trf_setup_handler(). for(setup_cnt = 0; setup_cnt < sizeof(CTRL_TRF_SETUP); setup_cnt++) { *(((unsigned char*) &usb_setup_pkt) + setup_cnt) = *(((unsigned char*) &ctrl_trf_data) + setup_cnt); } /* End v3b fix */ } else { control_transfer_state = WAIT_SETUP; pBDTEntryEP0OutNext->CNT = USB_EP0_BUFF_SIZE; // Defined in target.cfg pBDTEntryEP0OutNext->ADR = ConvertToPhysicalAddress(&usb_setup_pkt); /* Bug Fix: Feb 26, 2007 v2.1 (#F1) ********************************************************************* In the original firmware, if an OUT token is sent by the host before a SETUP token is sent, the firmware would respond with an ACK. This is not a correct response, the firmware should have sent a STALL. This is a minor non-compliance since a compliant host should not send an OUT before sending a SETUP token. The fix allows a SETUP transaction to be accepted while stalling OUT transactions. */ //ep0Bo.Stat.Val = _USIE|_DAT0|_DTSEN; // Removed pBDTEntryEP0OutNext->STAT.Val = _USIE|_DAT0|_DTSEN|_BSTALL; //Added #F1 /* Bug Fix: Feb 26, 2007 v2.1 (#F3) ********************************************************************* In the original firmware, if an IN token is sent by the host before a SETUP token is sent, the firmware would respond with an ACK. This is not a correct response, the firmware should have sent a STALL. This is a minor non-compliance since a compliant host should not send an IN before sending a SETUP token. Comment why this fix (#F3) is interfering with fix (#AF1). */ pBDTEntryIn[0]->STAT.Val = _UCPU; // Should be removed { BDT_ENTRY* p; p = (BDT_ENTRY*)(((unsigned int)pBDTEntryIn[0])^USB_NEXT_EP0_IN_PING_PONG); p->STAT.Val = _UCPU; } //ep0Bi.Stat.Val = _USIE|_BSTALL; // Should be added #F3 } //if someone is still expecting data from the control transfer // then make sure to terminate that request and let them know that // they are done if (usb_out_pipe[0].info.bits.busy == 1) { if (usb_out_pipe[0].pFunc != 0) { usb_out_pipe[0].pFunc(); } usb_out_pipe[0].info.bits.busy = 0; } }//end usb_prepare_for_next_setup_trf /* * This routine checks the setup data packet to see * if it knows how to handle it */ void usb_check_std_request(void) { if (usb_setup_pkt.RequestType != STANDARD) return; switch (usb_setup_pkt.bRequest) { case SET_ADR: usb_in_pipe[0].info.bits.busy = 1; // This will generate a zero length packet usb_device_state = ADR_PENDING_STATE; // Update state only /* See usb_ctrl_trf_in_handler() for the next step */ break; case GET_DSC: usb_std_get_dsc_handler(); break; case SET_CFG: usb_std_set_cfg_handler(); break; case GET_CFG: usb_in_pipe[0].pSrc.bRam = (unsigned char*)&usb_active_configuration; // Set Source usb_in_pipe[0].info.bits.ctrl_trf_mem = _RAM; // Set memory type usb_in_pipe[0].wCount |= 0xff; // Set data count usb_in_pipe[0].info.bits.busy = 1; break; case GET_STATUS: usb_std_get_status_handler(); break; case CLR_FEATURE: case SET_FEATURE: usb_std_feature_req_handler(); break; case GET_INTF: usb_in_pipe[0].pSrc.bRam = (unsigned char*)&usb_alternate_interface + usb_setup_pkt.bIntfID; // Set source usb_in_pipe[0].info.bits.ctrl_trf_mem = _RAM; // Set memory type usb_in_pipe[0].wCount |= 0xff; // Set data count usb_in_pipe[0].info.bits.busy = 1; break; case SET_INTF: usb_in_pipe[0].info.bits.busy = 1; usb_alternate_interface[usb_setup_pkt.bIntfID] = usb_setup_pkt.bAltID; break; case SET_DSC: usbcb_std_set_dsc_handler(); break; case SYNCH_FRAME: default: break; } } /* * This routine handles the standard SET & CLEAR * FEATURES requests */ void usb_std_feature_req_handler(void) { BDT_ENTRY *p; unsigned int *pUEP; #ifdef USB_SUPPORT_OTG if ((usb_setup_pkt.bFeature == OTG_FEATURE_B_HNP_ENABLE)&& (usb_setup_pkt.Recipient == RCPT_DEV)) { usb_in_pipe[0].info.bits.busy = 1; if (usb_setup_pkt.bRequest == SET_FEATURE) USBOTGEnableHnp(); else USBOTGDisableHnp(); } if ((usb_setup_pkt.bFeature == OTG_FEATURE_A_HNP_SUPPORT)&& (usb_setup_pkt.Recipient == RCPT_DEV)) { usb_in_pipe[0].info.bits.busy = 1; if (usb_setup_pkt.bRequest == SET_FEATURE) USBOTGEnableSupportHnp(); else USBOTGDisableSupportHnp(); } if ((usb_setup_pkt.bFeature == OTG_FEATURE_A_ALT_HNP_SUPPORT)&& (usb_setup_pkt.Recipient == RCPT_DEV)) { usb_in_pipe[0].info.bits.busy = 1; if (usb_setup_pkt.bRequest == SET_FEATURE) USBOTGEnableAltHnp(); else USBOTGDisableAltHnp(); } #endif if ((usb_setup_pkt.bFeature == DEVICE_REMOTE_WAKEUP)&& (usb_setup_pkt.Recipient == RCPT_DEV)) { usb_in_pipe[0].info.bits.busy = 1; if (usb_setup_pkt.bRequest == SET_FEATURE) usb_remote_wakeup = 1; else usb_remote_wakeup = 0; } if ((usb_setup_pkt.bFeature == ENDPOINT_HALT)&& (usb_setup_pkt.Recipient == RCPT_EP)&& (usb_setup_pkt.EPNum != 0)) { usb_in_pipe[0].info.bits.busy = 1; /* Must do address calculation here */ if (usb_setup_pkt.EPDir == 0) { p = (BDT_ENTRY*)pBDTEntryOut[usb_setup_pkt.EPNum]; } else { p = (BDT_ENTRY*)pBDTEntryIn[usb_setup_pkt.EPNum]; } //if it was a SET_FEATURE request if (usb_setup_pkt.bRequest == SET_FEATURE) { // Then STALL the endpoint p->STAT.Val = _USIE|_BSTALL; } else { // If it was not a SET_FEATURE // point to the appropriate UEP register pUEP = (unsigned int*) &U1EP(0); pUEP += usb_setup_pkt.EPNum * 4; //Clear the STALL bit in the UEP register *pUEP &= ~UEP_STALL; if (usb_setup_pkt.EPDir == 1) // IN { // If the endpoint is an IN endpoint then we // need to return it to the CPU and reset the // DTS bit so that the next transfer is correct #if (USB_PING_PONG_MODE == USB_PING_PONG__ALL_BUT_EP0) || \ (USB_PING_PONG_MODE == USB_PING_PONG__FULL_PING_PONG) p->STAT.Val = _UCPU | _DAT0; // toggle over the to the next buffer *(unsigned char*)&p ^= USB_NEXT_PING_PONG; p->STAT.Val = _UCPU | _DAT1; #else p->STAT.Val = _UCPU | _DAT1; #endif } else { // If the endpoint was an OUT endpoint then we // need to give control of the endpoint back to // the SIE so that the function driver can // receive the data as they expected. Also need // to set the DTS bit so the next packet will be // correct #if (USB_PING_PONG_MODE == USB_PING_PONG__ALL_BUT_EP0) || \ (USB_PING_PONG_MODE == USB_PING_PONG__FULL_PING_PONG) p->STAT.Val = _USIE|_DAT0|_DTSEN; //toggle over the to the next buffer *(unsigned char*)&p ^= USB_NEXT_PING_PONG; p->STAT.Val = _USIE|_DAT1|_DTSEN; #else p->STAT.Val = _USIE|_DAT1|_DTSEN; #endif } } } } /* * This routine handles the standard GET_DESCRIPTOR request. */ void usb_std_get_dsc_handler(void) { if (usb_setup_pkt.bmRequestType == 0x80) { usb_in_pipe[0].info.Val = USB_INPIPES_ROM | USB_INPIPES_BUSY | USB_INPIPES_INCLUDE_ZERO; switch(usb_setup_pkt.bDescriptorType) { case USB_DESCRIPTOR_DEVICE: usb_in_pipe[0].pSrc.bRom = (const unsigned char*) &usb_device; usb_in_pipe[0].wCount = sizeof(usb_device); break; case USB_DESCRIPTOR_CONFIGURATION: usb_in_pipe[0].pSrc.bRom = usb_config [usb_setup_pkt.bDscIndex]; usb_in_pipe[0].wCount = *(usb_in_pipe[0].pSrc.wRom+1); // Set data count break; case USB_DESCRIPTOR_STRING: #if defined(USB_NUM_STRING_DESCRIPTORS) if (usb_setup_pkt.bDscIndex < USB_NUM_STRING_DESCRIPTORS) #else if (1) #endif { //Get a pointer to the String descriptor requested usb_in_pipe[0].pSrc.bRom = usb_string [usb_setup_pkt.bDscIndex]; // Set data count usb_in_pipe[0].wCount = *usb_in_pipe[0].pSrc.bRom; } else { usb_in_pipe[0].info.Val = 0; } break; default: usb_in_pipe[0].info.Val = 0; break; }//end switch }//end if }//end usb_std_get_dsc_handler /* * This routine handles the standard GET_STATUS request */ void usb_std_get_status_handler(void) { ctrl_trf_data[0] = 0; // Initialize content ctrl_trf_data[1] = 0; switch(usb_setup_pkt.Recipient) { case RCPT_DEV: usb_in_pipe[0].info.bits.busy = 1; /* * [0]: bit0: Self-Powered Status [0] Bus-Powered [1] Self-Powered * bit1: RemoteWakeup [0] Disabled [1] Enabled */ ctrl_trf_data[0] |= 1; // self powered if (usb_remote_wakeup == 1) { ctrl_trf_data[0] |= 2; } break; case RCPT_INTF: usb_in_pipe[0].info.bits.busy = 1; // No data to update break; case RCPT_EP: usb_in_pipe[0].info.bits.busy = 1; /* * [0]: bit0: Halt Status [0] Not Halted [1] Halted */ { BDT_ENTRY *p; if (usb_setup_pkt.EPDir == 0) { p = (BDT_ENTRY*)pBDTEntryOut[usb_setup_pkt.EPNum]; } else { p = (BDT_ENTRY*)pBDTEntryIn[usb_setup_pkt.EPNum]; } if (p->STAT.Val & _BSTALL) // Use _BSTALL as a bit mask ctrl_trf_data[0] = 1; // Set bit0 break; } }//end switch if (usb_in_pipe[0].info.bits.busy == 1) { usb_in_pipe[0].pSrc.bRam = (unsigned char*) &ctrl_trf_data; // Set Source usb_in_pipe[0].info.bits.ctrl_trf_mem = _RAM; // Set memory type usb_in_pipe[0].wCount &= ~0xff; usb_in_pipe[0].wCount |= 2; // Set data count } } /* * This routine wrap up the ramaining tasks in servicing * a Setup Request. Its main task is to set the endpoint * controls appropriately for a given situation. See code * below. * There are three main scenarios: * a) There was no handler for the Request, in this case * a STALL should be sent out. * b) The host has requested a read control transfer, * endpoints are required to be setup in a specific way. * c) The host has requested a write control transfer, or * a control data stage is not required, endpoints are * required to be setup in a specific way. * * Packet processing is resumed by clearing PKTDIS bit. */ void usb_ctrl_ep_service_complete(void) { /* * PKTDIS bit is set when a Setup Transaction is received. * Clear to resume packet processing. */ U1CON &= ~PIC32_U1CON_PKTDIS; if (usb_in_pipe[0].info.bits.busy == 0) { if (usb_out_pipe[0].info.bits.busy == 1) { control_transfer_state = CTRL_TRF_RX; /* * Control Write: * ... | * * 1. Prepare IN EP to respond to early termination * * This is the same as a Zero Length Packet Response * for control transfer without a data stage */ pBDTEntryIn[0]->CNT = 0; pBDTEntryIn[0]->STAT.Val = _USIE|_DAT1|_DTSEN; /* * 2. Prepare OUT EP to receive data. */ pBDTEntryEP0OutNext->CNT = USB_EP0_BUFF_SIZE; pBDTEntryEP0OutNext->ADR = ConvertToPhysicalAddress (&ctrl_trf_data); pBDTEntryEP0OutNext->STAT.Val = _USIE|_DAT1|_DTSEN; } else { /* * If no one knows how to service this request then stall. * Must also prepare EP0 to receive the next SETUP transaction. */ pBDTEntryEP0OutNext->CNT = USB_EP0_BUFF_SIZE; pBDTEntryEP0OutNext->ADR = ConvertToPhysicalAddress(&usb_setup_pkt); /* v2b fix */ pBDTEntryEP0OutNext->STAT.Val = _USIE|_DAT0|_DTSEN|_BSTALL; pBDTEntryIn[0]->STAT.Val = _USIE|_BSTALL; } } else { // A module has claimed ownership of the control transfer session. if (usb_out_pipe[0].info.bits.busy == 0) { if (usb_setup_pkt.DataDir == DEV_TO_HOST) { if (usb_setup_pkt.wLength < usb_in_pipe[0].wCount) { usb_in_pipe[0].wCount = usb_setup_pkt.wLength; } usb_ctrl_trf_tx_service(); control_transfer_state = CTRL_TRF_TX; /* * Control Read: * ... | * 1. Prepare OUT EP to respond to early termination * * NOTE: * If something went wrong during the control transfer, * the last status stage may not be sent by the host. * When this happens, two different things could happen * depending on the host. * a) The host could send out a RESET. * b) The host could send out a new SETUP transaction * without sending a RESET first. * To properly handle case (b), the OUT EP must be setup * to receive either a zero length OUT transaction, or a * new SETUP transaction. * * Furthermore, the Cnt byte should be set to prepare for * the SETUP data (8-byte or more), and the buffer address * should be pointed to usb_setup_pkt. */ pBDTEntryEP0OutNext->CNT = USB_EP0_BUFF_SIZE; pBDTEntryEP0OutNext->ADR = ConvertToPhysicalAddress(&usb_setup_pkt); pBDTEntryEP0OutNext->STAT.Val = _USIE; // Note: DTSEN is 0! pBDTEntryEP0OutCurrent->CNT = USB_EP0_BUFF_SIZE; pBDTEntryEP0OutCurrent->ADR = (unsigned char*)&usb_setup_pkt; pBDTEntryEP0OutCurrent->STAT.Val = _USIE; // Note: DTSEN is 0! /* * 2. Prepare IN EP to transfer data, Cnt should have * been initialized by responsible request owner. */ pBDTEntryIn[0]->ADR = ConvertToPhysicalAddress (&ctrl_trf_data); pBDTEntryIn[0]->STAT.Val = _USIE|_DAT1|_DTSEN; } else { // (usb_setup_pkt.DataDir == HOST_TO_DEVICE) control_transfer_state = CTRL_TRF_RX; /* * Control Write: * ... | * * 1. Prepare IN EP to respond to early termination * * This is the same as a Zero Length Packet Response * for control transfer without a data stage */ pBDTEntryIn[0]->CNT = 0; pBDTEntryIn[0]->STAT.Val = _USIE|_DAT1|_DTSEN; /* * 2. Prepare OUT EP to receive data. */ pBDTEntryEP0OutNext->CNT = USB_EP0_BUFF_SIZE; pBDTEntryEP0OutNext->ADR = ConvertToPhysicalAddress (&ctrl_trf_data); pBDTEntryEP0OutNext->STAT.Val = _USIE|_DAT1|_DTSEN; } } } } /* * This routine should be called from only two places. * One from usb_ctrl_ep_service_complete() and one from * usb_ctrl_trf_in_handler(). It takes care of managing a * transfer over multiple USB transactions. * * This routine works with isochronous endpoint larger than * 256 bytes and is shown here as an example of how to deal * with BC9 and BC8. In reality, a control endpoint can never * be larger than 64 bytes. * * PreCondition: pSrc, wCount, and usb_stat.ctrl_trf_mem are setup properly. */ void usb_ctrl_trf_tx_service(void) { unsigned byteToSend; unsigned char *dst; /* * First, have to figure out how many byte of data to send. */ if (usb_in_pipe[0].wCount < USB_EP0_BUFF_SIZE) { byteToSend = usb_in_pipe[0].wCount; /* v2b fix */ if (short_packet_status == SHORT_PKT_NOT_USED) { short_packet_status = SHORT_PKT_PENDING; } else if (short_packet_status == SHORT_PKT_PENDING) { short_packet_status = SHORT_PKT_SENT; } /* end v2b fix for this section */ } else { byteToSend = USB_EP0_BUFF_SIZE; } /* * Next, load the number of bytes to send to BC9..0 in buffer descriptor */ pBDTEntryIn[0]->CNT = byteToSend; /* * Subtract the number of bytes just about to be sent from the total. */ usb_in_pipe[0].wCount = usb_in_pipe[0].wCount - byteToSend; // Set destination pointer dst = (unsigned char*) ctrl_trf_data; // Determine type of memory source if (usb_in_pipe[0].info.bits.ctrl_trf_mem == USB_INPIPES_ROM) { while (byteToSend) { *dst++ = *usb_in_pipe[0].pSrc.bRom++; byteToSend--; } } else { // RAM while (byteToSend) { *dst++ = *usb_in_pipe[0].pSrc.bRam++; byteToSend--; } } } /* * *** This routine is only partially complete. Check for * new version of the firmware. * * PreCondition: pDst and wCount are setup properly. * pSrc is always &ctrl_trf_data * usb_stat.ctrl_trf_mem is always _RAM. * wCount should be set to 0 at the start of each control transfer. */ void usb_ctrl_trf_rx_service(void) { unsigned byteToRead, i; byteToRead = pBDTEntryEP0OutCurrent->CNT; /* * Accumulate total number of bytes read */ if (byteToRead > usb_out_pipe[0].wCount) { byteToRead = usb_out_pipe[0].wCount; } else { usb_out_pipe[0].wCount = usb_out_pipe[0].wCount - byteToRead; } for(i=0;i 0) { /* * Don't have to worry about overwriting _KEEP bit * because if _KEEP was set, TRNIF would not have been * generated in the first place. */ pBDTEntryEP0OutNext->CNT = USB_EP0_BUFF_SIZE; pBDTEntryEP0OutNext->ADR = ConvertToPhysicalAddress (&ctrl_trf_data); if (pBDTEntryEP0OutCurrent->STAT.DTS == 0) { pBDTEntryEP0OutNext->STAT.Val = _USIE|_DAT1|_DTSEN; } else { pBDTEntryEP0OutNext->STAT.Val = _USIE|_DAT0|_DTSEN; } } else { pBDTEntryEP0OutNext->ADR = ConvertToPhysicalAddress(&usb_setup_pkt); if (usb_out_pipe[0].pFunc != 0) { usb_out_pipe[0].pFunc(); } usb_out_pipe[0].info.bits.busy = 0; } // reset ep0Bo.Cnt to USB_EP0_BUFF_SIZE }//end usb_ctrl_trf_rx_service /* * This routine first disables all endpoints by * clearing UEP registers. It then configures * (initializes) endpoints by calling the callback * function usbcb_init_ep(). */ void usb_std_set_cfg_handler(void) { unsigned i; // This will generate a zero length packet usb_in_pipe[0].info.bits.busy = 1; // disable all endpoints except endpoint 0 for (i=1; iSTAT.UOWN = 0; if (direction == 0) { pBDTEntryOut[epnum] = handle; } else { pBDTEntryIn[epnum] = handle; } #if (USB_PING_PONG_MODE == USB_PING_PONG__FULL_PING_PONG) handle->STAT.DTS = 0; (handle+1)->STAT.DTS = 1; #elif (USB_PING_PONG_MODE == USB_PING_PONG__NO_PING_PONG) //Set DTS to one because the first thing we will do //when transmitting is toggle the bit handle->STAT.DTS = 1; #elif (USB_PING_PONG_MODE == USB_PING_PONG__EP0_OUT_ONLY) if (epnum != 0) { handle->STAT.DTS = 1; } #elif (USB_PING_PONG_MODE == USB_PING_PONG__ALL_BUT_EP0) if (epnum != 0) { handle->STAT.DTS = 0; (handle+1)->STAT.DTS = 1; } #endif } /* * This function will enable the specified endpoint with the specified * options. * * Typical Usage: * * void usbcb_init_ep(void) * { * usb_enable_endpoint(MSD_DATA_IN_EP,USB_IN_ENABLED|USB_OUT_ENABLED|USB_HANDSHAKE_ENABLED|USB_DISALLOW_SETUP); * USBMSDInit(); * } * * * In the above example endpoint number MSD_DATA_IN_EP is being configured * for both IN and OUT traffic with handshaking enabled. Also since * MSD_DATA_IN_EP is not endpoint 0 (MSD does not allow this), then we can * explicitly disable SETUP packets on this endpoint. * * Input: * unsigned ep - the endpoint to be configured * unsigned options - optional settings for the endpoint. The options should * be ORed together to form a single options string. The * available optional settings for the endpoint. The * options should be ORed together to form a single options * string. The available options are the following\: * * USB_HANDSHAKE_ENABLED enables USB handshaking (ACK, * NAK) * * USB_HANDSHAKE_DISABLED disables USB handshaking (ACK, * NAK) * * USB_OUT_ENABLED enables the out direction * * USB_OUT_DISABLED disables the out direction * * USB_IN_ENABLED enables the in direction * * USB_IN_DISABLED disables the in direction * * USB_ALLOW_SETUP enables control transfers * * USB_DISALLOW_SETUP disables control transfers * * USB_STALL_ENDPOINT STALLs this endpoint */ void usb_enable_endpoint (unsigned ep, unsigned options) { // Set the options to the appropriate endpoint control register unsigned int *p = (unsigned int*) (&U1EP(0) + (4 * ep)); *p = options; if (options & USB_OUT_ENABLED) { usb_configure_endpoint(ep, 0); } if (options & USB_IN_ENABLED) { usb_configure_endpoint(ep, 1); } } /* * STALLs the specified endpoint * * Input: * unsigned ep - the endpoint the data will be transmitted on * unsigned dir - the direction of the transfer */ void usb_stall_endpoint (unsigned ep, unsigned dir) { BDT_ENTRY *p; if (ep == 0) { /* * If no one knows how to service this request then stall. * Must also prepare EP0 to receive the next SETUP transaction. */ pBDTEntryEP0OutNext->CNT = USB_EP0_BUFF_SIZE; pBDTEntryEP0OutNext->ADR = ConvertToPhysicalAddress(&usb_setup_pkt); /* v2b fix */ pBDTEntryEP0OutNext->STAT.Val = _USIE|_DAT0|_DTSEN|_BSTALL; pBDTEntryIn[0]->STAT.Val = _USIE|_BSTALL; } else { p = (BDT_ENTRY*) &usb_buffer[EP(ep, dir, 0)]; p->STAT.Val |= _BSTALL | _USIE; //If the device is in FULL or ALL_BUT_EP0 ping pong modes //then stall that entry as well #if (USB_PING_PONG_MODE == USB_PING_PONG__FULL_PING_PONG) || \ (USB_PING_PONG_MODE == USB_PING_PONG__ALL_BUT_EP0) p = (BDT_ENTRY*) &usb_buffer[EP(ep, dir, 1)]; p->STAT.Val |= _BSTALL | _USIE; #endif } } /* * Transfers one packet over the USB. * * Input: * unsigned ep - the endpoint the data will be transmitted on * unsigned dir - the direction of the transfer * This value is either OUT_FROM_HOST or IN_TO_HOST * unsigned char* data - pointer to the data to be sent * unsigned len - length of the data needing to be sent */ USB_HANDLE usb_transfer_one_packet (unsigned ep, unsigned dir, unsigned char* data, unsigned len) { USB_HANDLE handle; // If the direction is IN if (dir != 0) { // point to the IN BDT of the specified endpoint handle = pBDTEntryIn[ep]; } else { // else point to the OUT BDT of the specified endpoint handle = pBDTEntryOut[ep]; } //Toggle the DTS bit if required #if (USB_PING_PONG_MODE == USB_PING_PONG__NO_PING_PONG) handle->STAT.Val ^= _DTSMASK; #elif (USB_PING_PONG_MODE == USB_PING_PONG__EP0_OUT_ONLY) if (ep != 0) { handle->STAT.Val ^= _DTSMASK; } #endif //Set the data pointer, data length, and enable the endpoint handle->ADR = ConvertToPhysicalAddress(data); handle->CNT = len; handle->STAT.Val &= _DTSMASK; handle->STAT.Val |= _USIE | _DTSEN; // Point to the next buffer for ping pong purposes. if (dir != 0) { // toggle over the to the next buffer for an IN endpoint *(unsigned char*)&pBDTEntryIn[ep] ^= USB_NEXT_PING_PONG; } else { // toggle over the to the next buffer for an OUT endpoint *(unsigned char*)&pBDTEntryOut[ep] ^= USB_NEXT_PING_PONG; } return handle; } /* * USB Callback Functions */ /* * Call back that is invoked when a USB suspend is detected. */ void __attribute__((weak)) usbcb_suspend() { /* Empty. */ } /* * This call back is invoked when a wakeup from USB suspend is detected. */ void __attribute__((weak)) usbcb_wake_from_suspend() { /* Empty. */ } /* * Called when start-of-frame packet arrives, every 1 ms. */ void __attribute__((weak)) usbcb_sof_handler() { /* Empty. */ } /* * Called on any USB error interrupt, for debugging purposes. */ void __attribute__((weak)) usbcb_error_handler() { /* Empty. */ } /* * Handle a SETUP SET_DESCRIPTOR request (optional). */ void __attribute__((weak)) usbcb_std_set_dsc_handler() { /* Empty. */ } ================================================ FILE: sys/arch/pic32/hal/usb_device.h ================================================ /* * USB Device header file * * This file, with its associated C source file, provides the main substance of * the USB device side stack. These files will receive, transmit, and process * various USB commands as well as take action when required for various events * that occur on the bus. * * The software supplied herewith by Microchip Technology Incorporated * (the 'Company') for its PIC(R) Microcontroller is intended and * supplied to you, the Company's customer, for use solely and * exclusively on Microchip PIC Microcontroller products. The * software is owned by the Company and/or its supplier, and is * protected under applicable copyright laws. All rights are reserved. * Any use in violation of the foregoing restrictions may subject the * user to criminal sanctions under applicable laws, as well as to * civil liability for the breach of the terms and conditions of this * license. * * THIS SOFTWARE IS PROVIDED IN AN 'AS IS' CONDITION. NO WARRANTIES, * WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED * TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT, * IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. */ #ifndef USBDEVICE_H #define USBDEVICE_H #include #include /* * USB Endpoint Definitions * USB Standard EP Address Format: DIR:X:X:X:EP3:EP2:EP1:EP0 * This is used in the descriptors. See usbcfg.c * * NOTE: Do not use these values for checking against USTAT. * To check against USTAT, use values defined in usbd.h. */ #define _EP_IN 0x80 #define _EP_OUT 0x00 #define _EP01_OUT 0x01 #define _EP01_IN 0x81 #define _EP02_OUT 0x02 #define _EP02_IN 0x82 #define _EP03_OUT 0x03 #define _EP03_IN 0x83 #define _EP04_OUT 0x04 #define _EP04_IN 0x84 #define _EP05_OUT 0x05 #define _EP05_IN 0x85 #define _EP06_OUT 0x06 #define _EP06_IN 0x86 #define _EP07_OUT 0x07 #define _EP07_IN 0x87 #define _EP08_OUT 0x08 #define _EP08_IN 0x88 #define _EP09_OUT 0x09 #define _EP09_IN 0x89 #define _EP10_OUT 0x0A #define _EP10_IN 0x8A #define _EP11_OUT 0x0B #define _EP11_IN 0x8B #define _EP12_OUT 0x0C #define _EP12_IN 0x8C #define _EP13_OUT 0x0D #define _EP13_IN 0x8D #define _EP14_OUT 0x0E #define _EP14_IN 0x8E #define _EP15_OUT 0x0F #define _EP15_IN 0x8F /* Configuration Attributes */ #define _DEFAULT (0x01 << 7) // Default Value (Bit 7 is set) #define _SELF (0x01 << 6) // Self-powered (Supports if set) #define _RWU (0x01 << 5) // Remote Wakeup (Supports if set) #define _HNP (0x01 << 1) // HNP (Supports if set) #define _SRP (0x01) // SRP (Supports if set) /* Endpoint Transfer Type */ #define _CTRL 0x00 // Control Transfer #define _ISO 0x01 // Isochronous Transfer #define _BULK 0x02 // Bulk Transfer #define _INTERRUPT 0x03 // Interrupt Transfer /* Isochronous Endpoint Synchronization Type */ #define _NS (0x00 << 2) // No Synchronization #define _AS (0x01 << 2) // Asynchronous #define _AD (0x02 << 2) // Adaptive #define _SY (0x03 << 2) // Synchronous /* Isochronous Endpoint Usage Type */ #define _DE (0x00 << 4) // Data endpoint #define _FE (0x01 << 4) // Feedback endpoint #define _IE (0x02 << 4) // Implicit feedback Data endpoint #define _ROM USB_INPIPES_ROM #define _RAM USB_INPIPES_RAM //These are the directional indicators used for the usb_transfer_one_packet() // function. #define OUT_FROM_HOST 0 #define IN_TO_HOST 1 /* * CTRL_TRF_SETUP: Every setup packet has 8 bytes. This structure * allows direct access to the various members of the control * transfer. */ typedef union __attribute__ ((packed)) _CTRL_TRF_SETUP { /* Standard Device Requests */ struct __attribute__ ((packed)) { unsigned char bmRequestType; //from table 9-2 of USB2.0 spec unsigned char bRequest; //from table 9-2 of USB2.0 spec unsigned short wValue; //from table 9-2 of USB2.0 spec unsigned short wIndex; //from table 9-2 of USB2.0 spec unsigned short wLength; //from table 9-2 of USB2.0 spec }; struct __attribute__ ((packed)) { unsigned :8; unsigned :8; unsigned short W_Value; //from table 9-2 of USB2.0 spec, allows byte/bitwise access unsigned short W_Index; //from table 9-2 of USB2.0 spec, allows byte/bitwise access unsigned short W_Length; //from table 9-2 of USB2.0 spec, allows byte/bitwise access }; struct __attribute__ ((packed)) { unsigned Recipient:5; //Device,Interface,Endpoint,Other unsigned RequestType:2; //Standard,Class,Vendor,Reserved unsigned DataDir:1; //Host-to-device,Device-to-host unsigned :8; unsigned char bFeature; //DEVICE_REMOTE_WAKEUP,ENDPOINT_HALT unsigned :8; unsigned :8; unsigned :8; unsigned :8; unsigned :8; }; struct __attribute__ ((packed)) { unsigned :8; unsigned :8; unsigned char bDscIndex; //For Configuration and String DSC Only unsigned char bDescriptorType; //Device,Configuration,String unsigned short wLangID; //Language ID unsigned :8; unsigned :8; }; struct __attribute__ ((packed)) { unsigned :8; unsigned :8; unsigned char bDevADR; //Device Address 0-127 unsigned char bDevADRH; //Must equal zero unsigned :8; unsigned :8; unsigned :8; unsigned :8; }; struct __attribute__ ((packed)) { unsigned :8; unsigned :8; unsigned char bConfigurationValue; //Configuration Value 0-255 unsigned char bCfgRSD; //Must equal zero (Reserved) unsigned :8; unsigned :8; unsigned :8; unsigned :8; }; struct __attribute__ ((packed)) { unsigned :8; unsigned :8; unsigned char bAltID; //Alternate Setting Value 0-255 unsigned char bAltID_H; //Must equal zero unsigned char bIntfID; //Interface Number Value 0-255 unsigned char bIntfID_H; //Must equal zero unsigned :8; unsigned :8; }; struct __attribute__ ((packed)) { unsigned :8; unsigned :8; unsigned :8; unsigned :8; unsigned char bEPID; //Endpoint ID (Number & Direction) unsigned char bEPID_H; //Must equal zero unsigned :8; unsigned :8; }; struct __attribute__ ((packed)) { unsigned :8; unsigned :8; unsigned :8; unsigned :8; unsigned EPNum:4; //Endpoint Number 0-15 unsigned :3; unsigned EPDir:1; //Endpoint Direction: 0-OUT, 1-IN unsigned :8; unsigned :8; unsigned :8; }; /* End: Standard Device Requests */ } CTRL_TRF_SETUP; // Defintion of the PIPE structure // This structure is used to keep track of data that is sent out // of the stack automatically. typedef struct __attribute__ ((packed)) { union __attribute__ ((packed)) { //Various options of pointers that are available to // get the data from unsigned char *bRam; const unsigned char *bRom; unsigned short *wRam; const unsigned short *wRom; } pSrc; union __attribute__ ((packed)) { struct __attribute__ ((packed)) { //is this transfer from RAM or ROM? unsigned ctrl_trf_mem :1; unsigned reserved :5; //include a zero length packet after //data is done if data_size%ep_size = 0? unsigned includeZero :1; //is this PIPE currently in use unsigned busy :1; } bits; unsigned char Val; } info; unsigned short wCount; } IN_PIPE; #define CTRL_TRF_RETURN void #define CTRL_TRF_PARAMS void typedef struct __attribute__ ((packed)) { union __attribute__ ((packed)) { //Various options of pointers that are available to // get the data from unsigned char *bRam; unsigned short *wRam; } pDst; union __attribute__ ((packed)) { struct __attribute__ ((packed)) { unsigned reserved :7; //is this PIPE currently in use unsigned busy :1; } bits; unsigned char Val; } info; unsigned short wCount; CTRL_TRF_RETURN (*pFunc)(CTRL_TRF_PARAMS); } OUT_PIPE; //Various options for setting the PIPES #define USB_INPIPES_ROM 0x00 //Data comes from RAM #define USB_INPIPES_RAM 0x01 //Data comes from ROM #define USB_INPIPES_BUSY 0x80 //The PIPE is busy #define USB_INPIPES_INCLUDE_ZERO 0x40 //include a trailing zero packet #define USB_INPIPES_NO_DATA 0x00 //no data to send #define USB_INPIPES_NO_OPTIONS 0x00 //no options set #define USB_EP0_ROM USB_INPIPES_ROM #define USB_EP0_RAM USB_INPIPES_RAM #define USB_EP0_BUSY USB_INPIPES_BUSY #define USB_EP0_INCLUDE_ZERO USB_INPIPES_INCLUDE_ZERO #define USB_EP0_NO_DATA USB_INPIPES_NO_DATA #define USB_EP0_NO_OPTIONS USB_INPIPES_NO_OPTIONS /* * Standard Request Codes * USB 2.0 Spec Ref Table 9-4 */ #define GET_STATUS 0 #define CLR_FEATURE 1 #define SET_FEATURE 3 #define SET_ADR 5 #define GET_DSC 6 #define SET_DSC 7 #define GET_CFG 8 #define SET_CFG 9 #define GET_INTF 10 #define SET_INTF 11 #define SYNCH_FRAME 12 /* Section: Standard Feature Selectors */ #define DEVICE_REMOTE_WAKEUP 0x01 #define ENDPOINT_HALT 0x00 /* Section: USB Device States - To be used with [BYTE usb_device_state] */ /* Detached is the state in which the device is not attached to the bus. When * in the detached state a device should not have any pull-ups attached to either * the D+ or D- line. This defintions is a return value of the * function usb_get_device_state() */ #define DETACHED_STATE 0x00 /* Attached is the state in which the device is attached ot the bus but the * hub/port that it is attached to is not yet configured. This defintions is a * return value of the function usb_get_device_state() */ #define ATTACHED_STATE 0x01 /* Powered is the state in which the device is attached to the bus and the * hub/port that it is attached to is configured. This defintions is a return * value of the function usb_get_device_state() */ #define POWERED_STATE 0x02 /* Default state is the state after the device receives a RESET command from * the host. This defintions is a return value of the function usb_get_device_state() */ #define DEFAULT_STATE 0x04 /* Address pending state is not an official state of the USB defined states. * This state is internally used to indicate that the device has received a * SET_ADDRESS command but has not received the STATUS stage of the transfer yet. * The device is should not switch addresses until after the STATUS stage is * complete. This defintions is a return value of the function * usb_get_device_state() */ #define ADR_PENDING_STATE 0x08 /* Address is the state in which the device has its own specific address on the * bus. This defintions is a return value of the function usb_get_device_state(). */ #define ADDRESS_STATE 0x10 /* Configured is the state where the device has been fully enumerated and is * operating on the bus. The device is now allowed to excute its application * specific tasks. It is also allowed to increase its current consumption to the * value specified in the configuration descriptor of the current configuration. * This defintions is a return value of the function usb_get_device_state(). */ #define CONFIGURED_STATE 0x20 /* UCFG Initialization Parameters */ #define SetConfigurationOptions() {U1CNFG1 = 0;} /* UEPn Initialization Parameters */ #define EP_CTRL 0x0C // Cfg Control pipe for this ep #define EP_OUT 0x18 // Cfg OUT only pipe for this ep #define EP_IN 0x14 // Cfg IN only pipe for this ep #define EP_OUT_IN 0x1C // Cfg both OUT & IN pipes for this ep #define HSHK_EN 0x01 // Enable handshake packet // Handshake should be disable for isoch #define USB_HANDSHAKE_ENABLED 0x01 #define USB_HANDSHAKE_DISABLED 0x00 #define USB_OUT_ENABLED 0x08 #define USB_OUT_DISABLED 0x00 #define USB_IN_ENABLED 0x04 #define USB_IN_DISABLED 0x00 #define USB_ALLOW_SETUP 0x00 #define USB_DISALLOW_SETUP 0x10 #define USB_STALL_ENDPOINT 0x02 // USB_HANDLE is a pointer to an entry in the BDT. This pointer can be used // to read the length of the last transfer, the status of the last transfer, // and various other information. Insure to initialize USB_HANDLE objects // to NULL so that they are in a known state during their first usage. #define USB_HANDLE volatile BDT_ENTRY* // PIC32 supports only full ping-pong mode. #define USB_PING_PONG_MODE USB_PING_PONG__FULL_PING_PONG /* Size of buffer for end-point EP0. * Valid Options: 8, 16, 32, or 64 bytes. * Using larger options take more SRAM, but * does not provide much advantage in most types * of applications. Exceptions to this, are applications * that use EP0 IN or OUT for sending large amounts of * application related data. */ #ifndef USB_EP0_BUFF_SIZE # define USB_EP0_BUFF_SIZE 8 #endif /* * Only one interface by default. */ #ifndef USB_MAX_NUM_INT # define USB_MAX_NUM_INT 1 #endif // Definitions for the BDT extern volatile BDT_ENTRY usb_buffer[(USB_MAX_EP_NUMBER + 1) * 4]; // Device descriptor extern const USB_DEVICE_DESCRIPTOR usb_device; // Array of configuration descriptors extern const unsigned char *const usb_config[]; extern const unsigned char usb_config1_descriptor[]; // Array of string descriptors extern const unsigned char *const usb_string[]; // Buffer for control transfers extern volatile CTRL_TRF_SETUP usb_setup_pkt; // 8-byte only /* Control Transfer States */ #define WAIT_SETUP 0 #define CTRL_TRF_TX 1 #define CTRL_TRF_RX 2 /* v2.1 fix - Short Packet States - Used by Control Transfer Read - CTRL_TRF_TX */ #define SHORT_PKT_NOT_USED 0 #define SHORT_PKT_PENDING 1 #define SHORT_PKT_SENT 2 /* USB PID: Token Types - See chapter 8 in the USB specification */ #define SETUP_TOKEN 0x0D // 0b00001101 #define OUT_TOKEN 0x01 // 0b00000001 #define IN_TOKEN 0x09 // 0b00001001 /* bmRequestType Definitions */ #define HOST_TO_DEV 0 #define DEV_TO_HOST 1 #define STANDARD 0x00 #define CLASS 0x01 #define VENDOR 0x02 #define RCPT_DEV 0 #define RCPT_INTF 1 #define RCPT_EP 2 #define RCPT_OTH 3 extern unsigned usb_device_state; extern unsigned usb_active_configuration; extern IN_PIPE usb_in_pipe[1]; extern OUT_PIPE usb_out_pipe[1]; /* Function: void usb_device_tasks(void) Summary: This function is the main state machine of the USB device side stack. This function should be called periodically to receive and transmit packets through the stack. This function should be called preferably once every 100us during the enumeration process. After the enumeration process this function still needs to be called periodically to respond to various situations on the bus but is more relaxed in its time requirements. This function should also be called at least as fast as the OUT data expected from the PC. Description: This function is the main state machine of the USB device side stack. This function should be called periodically to receive and transmit packets through the stack. This function should be called preferably once every 100us during the enumeration process. After the enumeration process this function still needs to be called periodically to respond to various situations on the bus but is more relaxed in its time requirements. This function should also be called at least as fast as the OUT data expected from the PC. Typical usage: void main(void) { usb_device_init(); while (1) { usb_device_tasks(); if ((usb_get_device_state() \< CONFIGURED_STATE) || usb_is_device_suspended()) { // Either the device is not configured or we are suspended // so we don't want to do execute any application code continue; //go back to the top of the while loop } else { // Otherwise we are free to run user application code. UserApplication(); } } } Conditions: None Remarks: This function should be called preferably once every 100us during the enumeration process. After the enumeration process this function still needs to be called periodically to respond to various situations on the bus but is more relaxed in its time requirements. */ void usb_device_tasks(void); /* Function: void usb_device_init(void) Description: This function initializes the device stack it in the default state. The USB module will be completely reset including all of the internal variables, registers, and interrupt flags. Precondition: This function must be called before any of the other USB Device functions can be called, including usb_device_tasks(). Parameters: None Return Values: None Remarks: None */ void usb_device_init(void); /* Function: int usb_get_remote_wakeup_status(void) Summary: This function indicates if remote wakeup has been enabled by the host. Devices that support remote wakeup should use this function to determine if it should send a remote wakeup. Description: This function indicates if remote wakeup has been enabled by the host. Devices that support remote wakeup should use this function to determine if it should send a remote wakeup. If a device does not support remote wakeup (the Remote wakeup bit, bit 5, of the bmAttributes field of the Configuration descriptor is set to 1), then it should not send a remote wakeup command to the PC and this function is not of any use to the device. If a device does support remote wakeup then it should use this function as described below. If this function returns FALSE and the device is suspended, it should not issue a remote wakeup (resume). If this function returns TRUE and the device is suspended, it should issue a remote wakeup (resume). A device can add remote wakeup support by having the _RWU symbol added in the configuration descriptor (located in the usb_descriptors.c file in the project). This done in the 8th byte of the configuration descriptor. For example: const unsigned char configDescriptor1[]={ 0x09, // Size USB_DESCRIPTOR_CONFIGURATION, // descriptor type DESC_CONFIG_WORD(0x0022), // Total length 1, // Number of interfaces 1, // Index value of this cfg 0, // Configuration string index _DEFAULT | _SELF | _RWU, // Attributes, see usb_device.h 50, // Max power consumption in 2X mA(100mA) //The rest of the configuration descriptor should follow For more information about remote wakeup, see the following section of the USB v2.0 specification available at www.usb.org: * Section 9.2.5.2 * Table 9-10 * Section 7.1.7.7 * Section 9.4.5 Conditions: None Return Values: TRUE - Remote Wakeup has been enabled by the host FALSE - Remote Wakeup is not currently enabled Remarks: None */ #define usb_get_remote_wakeup_status() usb_remote_wakeup /* Function: unsigned usb_get_device_state(void) Summary: This function will return the current state of the device on the USB. This function should return CONFIGURED_STATE before an application tries to send information on the bus. Description: This function returns the current state of the device on the USB. This \function is used to determine when the device is ready to communicate on the bus. Applications should not try to send or receive data until this function returns CONFIGURED_STATE. It is also important that applications yield as much time as possible to the usb_device_tasks() function as possible while the this function \returns any value between ATTACHED_STATE through CONFIGURED_STATE. For more information about the various device states, please refer to the USB specification section 9.1 available from www.usb.org. Typical usage: void main(void) { usb_device_init(); while(1) { usb_device_tasks(); if ((usb_get_device_state() \< CONFIGURED_STATE) || usb_is_device_suspended()) { //Either the device is not configured or we are suspended // so we don't want to do execute any application code continue; //go back to the top of the while loop } else { //Otherwise we are free to run user application code. UserApplication(); } } } Conditions: None Return Values: DETACHED_STATE - The device is not attached to the bus ATTACHED_STATE - The device is attached to the bus but POWERED_STATE - The device is not officially in the powered state DEFAULT_STATE - The device has received a RESET from the host ADR_PENDING_STATE - The device has received the SET_ADDRESS command but hasn't received the STATUS stage of the command so it is still operating on address 0. ADDRESS_STATE - The device has an address assigned but has not received a SET_CONFIGURATION command yet or has received a SET_CONFIGURATION with a configuration number of 0 (deconfigured) CONFIGURED_STATE - the device has received a non\-zero SET_CONFIGURATION command is now ready for communication on the bus. Remarks: None */ #define usb_get_device_state() usb_device_state /* Function: int usb_is_device_suspended(void) Summary: This function indicates if this device is currently suspended. When a device is suspended it will not be able to transfer data over the bus. Description: This function indicates if this device is currently suspended. When a device is suspended it will not be able to transfer data over the bus. This function can be used by the application to skip over section of code that do not need to exectute if the device is unable to send data over the bus. Typical usage: void main(void) { usb_device_init(); while(1) { usb_device_tasks(); if ((usb_get_device_state() \< CONFIGURED_STATE) || usb_is_device_suspended()) { //Either the device is not configured or we are suspended // so we don't want to do execute any application code continue; //go back to the top of the while loop } else { //Otherwise we are free to run user application code. UserApplication(); } } } Conditions: None Return Values: TRUE - this device is suspended. FALSE - this device is not suspended. Remarks: None */ #define usb_is_device_suspended() (U1PWRC & PIC32_U1PWRC_USUSPEND) void usb_ctrl_ep_service (void); void usb_ctrl_trf_setup_handler (void); void usb_ctrl_trf_in_handler (void); void usb_check_std_request (void); void usb_std_get_dsc_handler (void); void usb_ctrl_ep_service_complete (void); void usb_ctrl_trf_tx_service (void); void usb_prepare_for_next_setup_trf (void); void usb_ctrl_trf_rx_service (void); void usb_std_set_cfg_handler (void); void usb_std_get_status_handler (void); void usb_std_feature_req_handler (void); void usb_ctrl_trf_out_handler (void); void usb_wake_from_suspend (void); void usb_suspend (void); void usb_stall_handler (void); volatile USB_HANDLE usb_transfer_one_packet (unsigned ep, unsigned dir, unsigned char* data, unsigned len); void usb_enable_endpoint (unsigned ep, unsigned options); void usb_configure_endpoint (unsigned EPNum, unsigned direction); #if defined(USB_DYNAMIC_EP_CONFIG) void usb_init_ep(unsigned char const* pConfig); #else #define usb_init_ep(a) #endif /* Section: CALLBACKS */ /* Function: void usbcb_suspend(void) Summary: Call back that is invoked when a USB suspend is detected. Description: Call back that is invoked when a USB suspend is detected. \Example power saving code. Insert appropriate code here for the desired application behavior. If the microcontroller will be put to sleep, a process similar to that shown below may be used: \Example Psuedo Code: ConfigureIOPinsForLowPower(); SaveStateOfAllInterruptEnableBits(); DisableAllInterruptEnableBits(); //should enable at least USBActivityIF as a wake source EnableOnlyTheInterruptsWhichWillBeUsedToWakeTheMicro(); Sleep(); //Preferrably, this should be done in the // usbcb_wake_from_suspend() function instead. RestoreStateOfAllPreviouslySavedInterruptEnableBits(); //Preferrably, this should be done in the // usbcb_wake_from_suspend() function instead. RestoreIOPinsToNormal(); IMPORTANT NOTE: Do not clear the USBActivityIF (ACTVIF) bit here. This bit is cleared inside the usb_device.c file. Clearing USBActivityIF here will cause things to not work as intended. Conditions: None Paramters: None Side Effects: None Remark: None */ void usbcb_suspend (void); /* Function: void usbcb_wake_from_suspend (void) Summary: This call back is invoked when a wakeup from USB suspend is detected. Description: The host may put USB peripheral devices in low power suspend mode (by "sending" 3+ms of idle). Once in suspend mode, the host may wake the device back up by sending non- idle state signalling. This call back is invoked when a wakeup from USB suspend is detected. If clock switching or other power savings measures were taken when executing the usbcb_suspend() function, now would be a good time to switch back to normal full power run mode conditions. The host allows a few milliseconds of wakeup time, after which the device must be fully back to normal, and capable of receiving and processing USB packets. In order to do this, the USB module must receive proper clocking (IE: 48MHz clock must be available to SIE for full speed USB operation). PreCondition: None Parameters: None Return Values: None Remarks: None */ void usbcb_wake_from_suspend (void); /* Function: void usbcb_sof_handler (void) Summary: This callback is called when a SOF packet is received by the host. (optional) Description: This callback is called when a SOF packet is received by the host. (optional) The USB host sends out a SOF packet to full-speed devices every 1 ms. This interrupt may be useful for isochronous pipes. End designers should implement callback routine as necessary. PreCondition: None Parameters: None Return Values: None Remarks: None */ void usbcb_sof_handler (void); /* Function: void usbcb_error_handler (void) Summary: This callback is called whenever a USB error occurs. (optional) Description: This callback is called whenever a USB error occurs. (optional) The purpose of this callback is mainly for debugging during development. Check UEIR to see which error causes the interrupt. PreCondition: None Parameters: None Return Values: None Remarks: No need to clear UEIR to 0 here. Callback caller is already doing that. Typically, user firmware does not need to do anything special if a USB error occurs. For example, if the host sends an OUT packet to your device, but the packet gets corrupted (ex: because of a bad connection, or the user unplugs the USB cable during the transmission) this will typically set one or more USB error interrupt flags. Nothing specific needs to be done however, since the SIE will automatically send a "NAK" packet to the host. In response to this, the host will normally retry to send the packet again, and no data loss occurs. The system will typically recover automatically, without the need for application firmware intervention. Nevertheless, this callback function is provided, such as for debugging purposes. */ void usbcb_error_handler (void); /* Function: void usbcb_check_other_req (void) Summary: This function is called whenever a request comes over endpoint 0 (the control endpoint) that the stack does not know how to handle. Description: When SETUP packets arrive from the host, some firmware must process the request and respond appropriately to fulfill the request. Some of the SETUP packets will be for standard USB "chapter 9" (as in, fulfilling chapter 9 of the official USB specifications) requests, while others may be specific to the USB device class that is being implemented. For \example, a HID class device needs to be able to respond to "GET REPORT" type of requests. This is not a standard USB chapter 9 request, and therefore not handled by usb_device.c. Instead this request should be handled by class specific firmware, such as that contained in usb_function_hid.c. Typical Usage: void usbcb_check_other_req (void) { //Since the stack didn't handle the request I need to check // my class drivers to see if it is for them USBCheckMSDRequest(); } Conditions: None Remarks: None */ void usbcb_check_other_req (void); /* Function: void usbcb_std_set_dsc_handler (void) Summary: This callback is called when a SET_DESCRIPTOR request is received (optional) Description: The usbcb_std_set_dsc_handler() callback function is called when a SETUP, bRequest: SET_DESCRIPTOR request arrives. Typically SET_DESCRIPTOR requests are not used in most applications, and it is optional to support this type of request. PreCondition: None Parameters: None Return Values: None Remark: None */ void usbcb_std_set_dsc_handler (void); /* Function: void usbcb_init_ep (void) Summary: This function is called whenever the device receives a SET_CONFIGURATION request. Description: This function is called when the device becomes initialized, which occurs after the host sends a SET_CONFIGURATION (wValue not = 0) request. This callback function should initialize the endpoints for the device's usage according to the current configuration. Typical Usage: void usbcb_init_ep (void) { usb_enable_endpoint(MSD_DATA_IN_EP,USB_IN_ENABLED|USB_OUT_ENABLED|USB_HANDSHAKE_ENABLED|USB_DISALLOW_SETUP); USBMSDInit(); } Conditions: None Remarks: None */ void usbcb_init_ep (void); /* Function: void usbcb_send_resume (void) Summary: This function should be called to initiate a remote wakeup. (optional) Description: The USB specifications allow some types of USB peripheral devices to wake up a host PC (such as if it is in a low power suspend to RAM state). This can be a very useful feature in some USB applications, such as an Infrared remote control receiver. If a user presses the "power" button on a remote control, it is nice that the IR receiver can detect this signalling, and then send a USB "command" to the PC to wake up. The usbcb_send_resume() "callback" function is used to send this special USB signalling which wakes up the PC. This function may be called by application firmware to wake up the PC. This function should only be called when: 1. The USB driver used on the host PC supports the remote wakeup capability. 2. The USB configuration descriptor indicates the device is remote wakeup capable in the bmAttributes field. (see usb_descriptors.c and _RWU) 3. The USB host PC is currently sleeping, and has previously sent your device a SET FEATURE setup packet which "armed" the remote wakeup capability. (see usb_get_remote_wakeup_status()) This callback should send a RESUME signal that has the period of 1-15ms. Typical Usage: if ((usb_device_state == CONFIGURED_STATE) && usb_is_device_suspended() && (usb_get_remote_wakeup_status() == TRUE)) { if (ButtonPressed) { // Wake up the USB module from suspend usb_wake_from_suspend(); // Issue a remote wakeup command on the bus usbcb_send_resume(); } } Conditions: None Remarks: A user can switch to primary first by calling usbcb_wake_from_suspend() if required/desired. The modifiable section in this routine should be changed to meet the application needs. Current implementation temporary blocks other functions from executing for a period of 1-13 ms depending on the core frequency. According to USB 2.0 specification section 7.1.7.7, "The remote wakeup device must hold the resume signaling for at lest 1 ms but for no more than 15 ms." The idea here is to use a delay counter loop, using a common value that would work over a wide range of core frequencies. That value selected is 1800. See table below: Core Freq(MHz) MIP (for PIC18) RESUME Signal Period (ms) --------------- ---------------- -------------------------- 48 12 1.05 4 1 12.6
* These timing could be incorrect when using code optimization or extended instruction mode, or when having other interrupts enabled. Make sure to verify using the MPLAB SIM's Stopwatch and verify the actual signal on an oscilloscope. * These timing numbers should be recalculated when using PIC24 or PIC32 as they have different clocking structures. * A timer can be used in place of the blocking loop if desired. */ void usbcb_send_resume (void); /* Function: void usbcb_ep0_data_received(void) Summary: This function is called whenever a EP0 data packet is received. (optional) Description: This function is called whenever a EP0 data packet is received. This gives the user (and thus the various class examples a way to get data that is received via the control endpoint. This function needs to be used in conjunction with the usbcb_check_other_req() function since the usbcb_check_other_req() function is the apps method for getting the initial control transfer before the data arrives. PreCondition: ENABLE_EP0_DATA_RECEIVED_CALLBACK must be defined already (in target.cfg) Parameters: None Return Values: None Remarks: None */ void usbcb_ep0_data_received (void); /* Section: MACROS */ #define DESC_CONFIG_BYTE(a) (a) #define DESC_CONFIG_WORD(a) (a&0xFF),((a>>8)&0xFF) #define DESC_CONFIG_DWORD(a) (a&0xFF),((a>>8)&0xFF),((a>>16)&0xFF),((a>>24)&0xFF) /* Function: int usb_handle_busy(USB_HANDLE handle) Summary: Checks to see if the input handle is busy Description: Checks to see if the input handle is busy Typical Usage //make sure that the last transfer isn't busy by checking the handle if (! usb_handle_busy(handle)) { //Send the data contained in the INPacket[] array out on // endpoint USBGEN_EP_NUM handle = USBGenWrite (USBGEN_EP_NUM, (unsigned char*) &INPacket[0], sizeof(INPacket)); } Conditions: None Input: USB_HANDLE handle - handle of the transfer that you want to check the status of Return Values: TRUE - The specified handle is busy FALSE - The specified handle is free and available for a transfer Remarks: None */ #define usb_handle_busy(handle) (handle != 0 && handle->STAT.UOWN) /* Function: unsigned short usb_handle_get_length(USB_HANDLE handle) Summary: Retrieves the length of the destination buffer of the input handle Description: Retrieves the length of the destination buffer of the input handle PreCondition: None Parameters: USB_HANDLE handle - the handle to the transfer you want the address for. Return Values: unsigned short - length of the current buffer that the input handle points to. If the transfer is complete then this is the length of the data transmitted or the length of data actually received. Remarks: None */ #define usb_handle_get_length(handle) (handle->CNT) /* Function: unsigned short usb_handle_get_addr(USB_HANDLE) Summary: Retrieves the address of the destination buffer of the input handle Description: Retrieves the address of the destination buffer of the input handle PreCondition: None Parameters: USB_HANDLE handle - the handle to the transfer you want the address for. Return Values: unsigned short - address of the current buffer that the input handle points to. Remarks: None */ #define usb_handle_get_addr(handle) (handle->ADR) /* Function: void usb_ep0_set_source_ram(unsigned char* src) Summary: Sets the address of the data to send over the control endpoint PreCondition: None Paramters: src - address of the data to send Return Values: None Remarks: None */ #define usb_ep0_set_source_ram(src) usb_in_pipe[0].pSrc.bRam = src /* Function: void usb_ep0_set_source_rom(unsigned char* src) Summary: Sets the address of the data to send over the control endpoint PreCondition: None Parameters: src - address of the data to send Return Values: None Remarks: None */ #define usb_ep0_set_source_rom(src) usb_in_pipe[0].pSrc.bRom = src /* Function: void usb_ep0_transmit(unsigned char options) Summary: Sets the address of the data to send over the control endpoint PreCondition: None Paramters: options - the various options that you want when sending the control data. Options are: USB_INPIPES_ROM USB_INPIPES_RAM USB_INPIPES_BUSY USB_INPIPES_INCLUDE_ZERO USB_INPIPES_NO_DATA USB_INPIPES_NO_OPTIONS Return Values: None Remarks: None */ #define usb_ep0_transmit(options) usb_in_pipe[0].info.Val = options | USB_INPIPES_BUSY /* Function: void usb_ep0_set_size(unsigned short size) Summary: Sets the size of the data to send over the control endpoint PreCondition: None Parameters: size - the size of the data needing to be transmitted Return Values: None Remarks: None */ #define usb_ep0_set_size(size) usb_in_pipe[0].wCount = size /* Function: void usb_ep0_send_ram_ptr(unsigned char* src, unsigned short size, unsigned char Options) Summary: Sets the source, size, and options of the data you wish to send from a RAM source PreCondition: None Parameters: src - address of the data to send size - the size of the data needing to be transmitted options - the various options that you want when sending the control data. Options are: USB_INPIPES_ROM USB_INPIPES_RAM USB_INPIPES_BUSY USB_INPIPES_INCLUDE_ZERO USB_INPIPES_NO_DATA USB_INPIPES_NO_OPTIONS Return Values: None Remarks: None */ #define usb_ep0_send_ram_ptr(src,size,options) {usb_ep0_set_source_ram(src);usb_ep0_set_size(size);usb_ep0_transmit(options | USB_EP0_RAM);} /* Function: void usb_ep0_send_rom_ptr(unsigned char* src, unsigned short size, unsigned char Options) Summary: Sets the source, size, and options of the data you wish to send from a ROM source PreCondition: None Parameters: src - address of the data to send size - the size of the data needing to be transmitted options - the various options that you want when sending the control data. Options are: USB_INPIPES_ROM USB_INPIPES_RAM USB_INPIPES_BUSY USB_INPIPES_INCLUDE_ZERO USB_INPIPES_NO_DATA USB_INPIPES_NO_OPTIONS Return Values: None Remarks: None */ #define usb_ep0_send_rom_ptr(src,size,options) {usb_ep0_set_source_rom(src);usb_ep0_set_size(size);usb_ep0_transmit(options | USB_EP0_ROM);} /* Function: USB_HANDLE usb_tx_one_packet(unsigned char ep, unsigned char* data, unsigned short len) Summary: Sends the specified data out the specified endpoint PreCondition: None Parameters: ep - the endpoint you want to send the data out of data - the data that you wish to send len - the length of the data that you wish to send Return Values: USB_HANDLE - a handle for the transfer. This information should be kept to track the status of the transfer Remarks: None */ #define usb_tx_one_packet(ep, data, len) usb_transfer_one_packet(ep, IN_TO_HOST, data, len) /* Function: void usb_rx_one_packet(unsigned char ep, unsigned char* data, unsigned short len) Summary: Receives the specified data out the specified endpoint PreCondition: None Parameters: ep - the endpoint you want to receive the data into data - where the data will go when it arrives len - the length of the data that you wish to receive Return Values: None Remarks: None */ #define usb_rx_one_packet(ep, data, len) usb_transfer_one_packet(ep, OUT_FROM_HOST, data, len) /* Function: void usb_stall_endpoint(unsigned ep, unsigned dir) Summary: STALLs the specified endpoint PreCondition: None Parameters: unsigned char ep - the endpoint the data will be transmitted on unsigned char dir - the direction of the transfer Return Values: None Remarks: None */ void usb_stall_endpoint(unsigned ep, unsigned dir); #if (USB_PING_PONG_MODE == USB_PING_PONG__NO_PING_PONG) #define USB_NEXT_EP0_OUT_PING_PONG 0x0000 // Used in USB Device Mode only #define USB_NEXT_EP0_IN_PING_PONG 0x0000 // Used in USB Device Mode only #define USB_NEXT_PING_PONG 0x0000 // Used in USB Device Mode only #define EP0_OUT_EVEN 0 // Used in USB Device Mode only #define EP0_OUT_ODD 0 // Used in USB Device Mode only #define EP0_IN_EVEN 1 // Used in USB Device Mode only #define EP0_IN_ODD 1 // Used in USB Device Mode only #define EP1_OUT_EVEN 2 // Used in USB Device Mode only #define EP1_OUT_ODD 2 // Used in USB Device Mode only #define EP1_IN_EVEN 3 // Used in USB Device Mode only #define EP1_IN_ODD 3 // Used in USB Device Mode only #define EP2_OUT_EVEN 4 // Used in USB Device Mode only #define EP2_OUT_ODD 4 // Used in USB Device Mode only #define EP2_IN_EVEN 5 // Used in USB Device Mode only #define EP2_IN_ODD 5 // Used in USB Device Mode only #define EP3_OUT_EVEN 6 // Used in USB Device Mode only #define EP3_OUT_ODD 6 // Used in USB Device Mode only #define EP3_IN_EVEN 7 // Used in USB Device Mode only #define EP3_IN_ODD 7 // Used in USB Device Mode only #define EP4_OUT_EVEN 8 // Used in USB Device Mode only #define EP4_OUT_ODD 8 // Used in USB Device Mode only #define EP4_IN_EVEN 9 // Used in USB Device Mode only #define EP4_IN_ODD 9 // Used in USB Device Mode only #define EP5_OUT_EVEN 10 // Used in USB Device Mode only #define EP5_OUT_ODD 10 // Used in USB Device Mode only #define EP5_IN_EVEN 11 // Used in USB Device Mode only #define EP5_IN_ODD 11 // Used in USB Device Mode only #define EP6_OUT_EVEN 12 // Used in USB Device Mode only #define EP6_OUT_ODD 12 // Used in USB Device Mode only #define EP6_IN_EVEN 13 // Used in USB Device Mode only #define EP6_IN_ODD 13 // Used in USB Device Mode only #define EP7_OUT_EVEN 14 // Used in USB Device Mode only #define EP7_OUT_ODD 14 // Used in USB Device Mode only #define EP7_IN_EVEN 15 // Used in USB Device Mode only #define EP7_IN_ODD 15 // Used in USB Device Mode only #define EP8_OUT_EVEN 16 // Used in USB Device Mode only #define EP8_OUT_ODD 16 // Used in USB Device Mode only #define EP8_IN_EVEN 17 // Used in USB Device Mode only #define EP8_IN_ODD 17 // Used in USB Device Mode only #define EP9_OUT_EVEN 18 // Used in USB Device Mode only #define EP9_OUT_ODD 18 // Used in USB Device Mode only #define EP9_IN_EVEN 19 // Used in USB Device Mode only #define EP9_IN_ODD 19 // Used in USB Device Mode only #define EP10_OUT_EVEN 20 // Used in USB Device Mode only #define EP10_OUT_ODD 20 // Used in USB Device Mode only #define EP10_IN_EVEN 21 // Used in USB Device Mode only #define EP10_IN_ODD 21 // Used in USB Device Mode only #define EP11_OUT_EVEN 22 // Used in USB Device Mode only #define EP11_OUT_ODD 22 // Used in USB Device Mode only #define EP11_IN_EVEN 23 // Used in USB Device Mode only #define EP11_IN_ODD 23 // Used in USB Device Mode only #define EP12_OUT_EVEN 24 // Used in USB Device Mode only #define EP12_OUT_ODD 24 // Used in USB Device Mode only #define EP12_IN_EVEN 25 // Used in USB Device Mode only #define EP12_IN_ODD 25 // Used in USB Device Mode only #define EP13_OUT_EVEN 26 // Used in USB Device Mode only #define EP13_OUT_ODD 26 // Used in USB Device Mode only #define EP13_IN_EVEN 27 // Used in USB Device Mode only #define EP13_IN_ODD 27 // Used in USB Device Mode only #define EP14_OUT_EVEN 28 // Used in USB Device Mode only #define EP14_OUT_ODD 28 // Used in USB Device Mode only #define EP14_IN_EVEN 29 // Used in USB Device Mode only #define EP14_IN_ODD 29 // Used in USB Device Mode only #define EP15_OUT_EVEN 30 // Used in USB Device Mode only #define EP15_OUT_ODD 30 // Used in USB Device Mode only #define EP15_IN_EVEN 31 // Used in USB Device Mode only #define EP15_IN_ODD 31 // Used in USB Device Mode only #define EP(ep,dir,pp) (2*ep+dir) // Used in USB Device Mode only #define BD(ep,dir,pp) ((8 * ep) + (4 * dir)) // Used in USB Device Mode only #elif (USB_PING_PONG_MODE == USB_PING_PONG__EP0_OUT_ONLY) #define USB_NEXT_EP0_OUT_PING_PONG 0x0004 #define USB_NEXT_EP0_IN_PING_PONG 0x0000 #define USB_NEXT_PING_PONG 0x0000 #define EP0_OUT_EVEN 0 #define EP0_OUT_ODD 1 #define EP0_IN_EVEN 2 #define EP0_IN_ODD 2 #define EP1_OUT_EVEN 3 #define EP1_OUT_ODD 3 #define EP1_IN_EVEN 4 #define EP1_IN_ODD 4 #define EP2_OUT_EVEN 5 #define EP2_OUT_ODD 5 #define EP2_IN_EVEN 6 #define EP2_IN_ODD 6 #define EP3_OUT_EVEN 7 #define EP3_OUT_ODD 7 #define EP3_IN_EVEN 8 #define EP3_IN_ODD 8 #define EP4_OUT_EVEN 9 #define EP4_OUT_ODD 9 #define EP4_IN_EVEN 10 #define EP4_IN_ODD 10 #define EP5_OUT_EVEN 11 #define EP5_OUT_ODD 11 #define EP5_IN_EVEN 12 #define EP5_IN_ODD 12 #define EP6_OUT_EVEN 13 #define EP6_OUT_ODD 13 #define EP6_IN_EVEN 14 #define EP6_IN_ODD 14 #define EP7_OUT_EVEN 15 #define EP7_OUT_ODD 15 #define EP7_IN_EVEN 16 #define EP7_IN_ODD 16 #define EP8_OUT_EVEN 17 #define EP8_OUT_ODD 17 #define EP8_IN_EVEN 18 #define EP8_IN_ODD 18 #define EP9_OUT_EVEN 19 #define EP9_OUT_ODD 19 #define EP9_IN_EVEN 20 #define EP9_IN_ODD 20 #define EP10_OUT_EVEN 21 #define EP10_OUT_ODD 21 #define EP10_IN_EVEN 22 #define EP10_IN_ODD 22 #define EP11_OUT_EVEN 23 #define EP11_OUT_ODD 23 #define EP11_IN_EVEN 24 #define EP11_IN_ODD 24 #define EP12_OUT_EVEN 25 #define EP12_OUT_ODD 25 #define EP12_IN_EVEN 26 #define EP12_IN_ODD 26 #define EP13_OUT_EVEN 27 #define EP13_OUT_ODD 27 #define EP13_IN_EVEN 28 #define EP13_IN_ODD 28 #define EP14_OUT_EVEN 29 #define EP14_OUT_ODD 29 #define EP14_IN_EVEN 30 #define EP14_IN_ODD 30 #define EP15_OUT_EVEN 31 #define EP15_OUT_ODD 31 #define EP15_IN_EVEN 32 #define EP15_IN_ODD 32 #define EP(ep,dir,pp) (2*ep+dir+(((ep==0)&&(dir==0))?pp:2)) #define BD(ep,dir,pp) (4*(ep+dir+(((ep==0)&&(dir==0))?pp:2))) #elif (USB_PING_PONG_MODE == USB_PING_PONG__FULL_PING_PONG) #define USB_NEXT_EP0_OUT_PING_PONG 0x0008 #define USB_NEXT_EP0_IN_PING_PONG 0x0008 #define USB_NEXT_PING_PONG 0x0008 #define EP0_OUT_EVEN 0 #define EP0_OUT_ODD 1 #define EP0_IN_EVEN 2 #define EP0_IN_ODD 3 #define EP1_OUT_EVEN 4 #define EP1_OUT_ODD 5 #define EP1_IN_EVEN 6 #define EP1_IN_ODD 7 #define EP2_OUT_EVEN 8 #define EP2_OUT_ODD 9 #define EP2_IN_EVEN 10 #define EP2_IN_ODD 11 #define EP3_OUT_EVEN 12 #define EP3_OUT_ODD 13 #define EP3_IN_EVEN 14 #define EP3_IN_ODD 15 #define EP4_OUT_EVEN 16 #define EP4_OUT_ODD 17 #define EP4_IN_EVEN 18 #define EP4_IN_ODD 19 #define EP5_OUT_EVEN 20 #define EP5_OUT_ODD 21 #define EP5_IN_EVEN 22 #define EP5_IN_ODD 23 #define EP6_OUT_EVEN 24 #define EP6_OUT_ODD 25 #define EP6_IN_EVEN 26 #define EP6_IN_ODD 27 #define EP7_OUT_EVEN 28 #define EP7_OUT_ODD 29 #define EP7_IN_EVEN 30 #define EP7_IN_ODD 31 #define EP8_OUT_EVEN 32 #define EP8_OUT_ODD 33 #define EP8_IN_EVEN 34 #define EP8_IN_ODD 35 #define EP9_OUT_EVEN 36 #define EP9_OUT_ODD 37 #define EP9_IN_EVEN 38 #define EP9_IN_ODD 39 #define EP10_OUT_EVEN 40 #define EP10_OUT_ODD 41 #define EP10_IN_EVEN 42 #define EP10_IN_ODD 43 #define EP11_OUT_EVEN 44 #define EP11_OUT_ODD 45 #define EP11_IN_EVEN 46 #define EP11_IN_ODD 47 #define EP12_OUT_EVEN 48 #define EP12_OUT_ODD 49 #define EP12_IN_EVEN 50 #define EP12_IN_ODD 51 #define EP13_OUT_EVEN 52 #define EP13_OUT_ODD 53 #define EP13_IN_EVEN 54 #define EP13_IN_ODD 55 #define EP14_OUT_EVEN 56 #define EP14_OUT_ODD 57 #define EP14_IN_EVEN 58 #define EP14_IN_ODD 59 #define EP15_OUT_EVEN 60 #define EP15_OUT_ODD 61 #define EP15_IN_EVEN 62 #define EP15_IN_ODD 63 #define EP(ep,dir,pp) (4*ep+2*dir+pp) #define BD(ep,dir,pp) (8*(4*ep+2*dir+pp)) #elif (USB_PING_PONG_MODE == USB_PING_PONG__ALL_BUT_EP0) #define USB_NEXT_EP0_OUT_PING_PONG 0x0000 #define USB_NEXT_EP0_IN_PING_PONG 0x0000 #define USB_NEXT_PING_PONG 0x0004 #define EP0_OUT_EVEN 0 #define EP0_OUT_ODD 0 #define EP0_IN_EVEN 1 #define EP0_IN_ODD 1 #define EP1_OUT_EVEN 2 #define EP1_OUT_ODD 3 #define EP1_IN_EVEN 4 #define EP1_IN_ODD 5 #define EP2_OUT_EVEN 6 #define EP2_OUT_ODD 7 #define EP2_IN_EVEN 8 #define EP2_IN_ODD 9 #define EP3_OUT_EVEN 10 #define EP3_OUT_ODD 11 #define EP3_IN_EVEN 12 #define EP3_IN_ODD 13 #define EP4_OUT_EVEN 14 #define EP4_OUT_ODD 15 #define EP4_IN_EVEN 16 #define EP4_IN_ODD 17 #define EP5_OUT_EVEN 18 #define EP5_OUT_ODD 19 #define EP5_IN_EVEN 20 #define EP5_IN_ODD 21 #define EP6_OUT_EVEN 22 #define EP6_OUT_ODD 23 #define EP6_IN_EVEN 24 #define EP6_IN_ODD 25 #define EP7_OUT_EVEN 26 #define EP7_OUT_ODD 27 #define EP7_IN_EVEN 28 #define EP7_IN_ODD 29 #define EP8_OUT_EVEN 30 #define EP8_OUT_ODD 31 #define EP8_IN_EVEN 32 #define EP8_IN_ODD 33 #define EP9_OUT_EVEN 34 #define EP9_OUT_ODD 35 #define EP9_IN_EVEN 36 #define EP9_IN_ODD 37 #define EP10_OUT_EVEN 38 #define EP10_OUT_ODD 39 #define EP10_IN_EVEN 40 #define EP10_IN_ODD 41 #define EP11_OUT_EVEN 42 #define EP11_OUT_ODD 43 #define EP11_IN_EVEN 44 #define EP11_IN_ODD 45 #define EP12_OUT_EVEN 46 #define EP12_OUT_ODD 47 #define EP12_IN_EVEN 48 #define EP12_IN_ODD 49 #define EP13_OUT_EVEN 50 #define EP13_OUT_ODD 51 #define EP13_IN_EVEN 52 #define EP13_IN_ODD 53 #define EP14_OUT_EVEN 54 #define EP14_OUT_ODD 55 #define EP14_IN_EVEN 56 #define EP14_IN_ODD 57 #define EP15_OUT_EVEN 58 #define EP15_OUT_ODD 59 #define EP15_IN_EVEN 60 #define EP15_IN_ODD 61 #define EP(ep,dir,pp) (4*ep+2*dir+((ep==0)?0:(pp-2))) #define BD(ep,dir,pp) (4*(4*ep+2*dir+((ep==0)?0:(pp-2)))) #else #error "No ping pong mode defined." #endif extern int usb_remote_wakeup; #endif //USBD_H ================================================ FILE: sys/arch/pic32/hal/usb_function_cdc.c ================================================ /* * This file contains all of functions, macros, definitions, variables, * datatypes, etc. that are required for usage with the CDC function * driver. This file should be included in projects that use the CDC * \function driver. * * The software supplied herewith by Microchip Technology Incorporated * (the 'Company') for its PIC(R) Microcontroller is intended and * supplied to you, the Company's customer, for use solely and * exclusively on Microchip PIC Microcontroller products. The * software is owned by the Company and/or its supplier, and is * protected under applicable copyright laws. All rights are reserved. * Any use in violation of the foregoing restrictions may subject the * user to criminal sanctions under applicable laws, as well as to * civil liability for the breach of the terms and conditions of this license. * * THIS SOFTWARE IS PROVIDED IN AN 'AS IS' CONDITION. NO WARRANTIES, * WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED * TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT, * IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. */ #include #include #include unsigned cdc_trf_state; // States are defined cdc.h unsigned cdc_tx_len; // total tx length LINE_CODING cdc_line_coding; // Buffer to store line coding information static USB_HANDLE data_out; static USB_HANDLE data_in; static CONTROL_SIGNAL_BITMAP control_signal_bitmap; static volatile unsigned char cdc_data_rx [CDC_DATA_OUT_EP_SIZE]; static volatile unsigned char cdc_data_tx [CDC_DATA_IN_EP_SIZE]; /* * SEND_ENCAPSULATED_COMMAND and GET_ENCAPSULATED_RESPONSE are required * requests according to the CDC specification. * However, it is not really being used here, therefore a dummy buffer is * used for conformance. */ #define DUMMY_LENGTH 0x08 static unsigned char dummy_encapsulated_cmd_response [DUMMY_LENGTH]; /* * This routine checks the setup data packet to see if it * knows how to handle it. */ void cdc_check_request() { /* * If request recipient is not an interface then return */ if (usb_setup_pkt.Recipient != RCPT_INTF) return; /* * If request type is not class-specific then return */ if (usb_setup_pkt.RequestType != CLASS) return; /* * Interface ID must match interface numbers associated with * CDC class, else return */ if (usb_setup_pkt.bIntfID != CDC_COMM_INTF_ID && usb_setup_pkt.bIntfID != CDC_DATA_INTF_ID) return; switch (usb_setup_pkt.bRequest) { case SEND_ENCAPSULATED_COMMAND: // send the packet usb_in_pipe[0].pSrc.bRam = (unsigned char*) &dummy_encapsulated_cmd_response; usb_in_pipe[0].wCount = DUMMY_LENGTH; usb_in_pipe[0].info.bits.ctrl_trf_mem = USB_INPIPES_RAM; usb_in_pipe[0].info.bits.busy = 1; break; case GET_ENCAPSULATED_RESPONSE: // Populate dummy_encapsulated_cmd_response first. usb_in_pipe[0].pSrc.bRam = (unsigned char*) &dummy_encapsulated_cmd_response; usb_in_pipe[0].info.bits.busy = 1; break; case SET_LINE_CODING: usb_out_pipe[0].wCount = usb_setup_pkt.wLength; usb_out_pipe[0].pDst.bRam = (unsigned char*) &cdc_line_coding._byte[0]; usb_out_pipe[0].pFunc = 0; usb_out_pipe[0].info.bits.busy = 1; break; case GET_LINE_CODING: usb_ep0_send_ram_ptr ((unsigned char*) &cdc_line_coding, LINE_CODING_LENGTH, USB_EP0_INCLUDE_ZERO); break; case SET_CONTROL_LINE_STATE: control_signal_bitmap._byte = (unsigned char)usb_setup_pkt.W_Value; CONFIGURE_RTS(control_signal_bitmap.CARRIER_CONTROL); CONFIGURE_DTR(control_signal_bitmap.DTE_PRESENT); usb_in_pipe[0].info.bits.busy = 1; break; } } /* * This function initializes the CDC function driver. This function sets * the default line coding (baud rate, bit parity, number of data bits, * and format). This function also enables the endpoints and prepares for * the first transfer from the host. * * This function should be called after the SET_CONFIGURATION command. * This is most simply done by calling this function from the * usbcb_init_ep() function. * * Usage: * void usbcb_init_ep() * { * cdc_init_ep(); * } */ void cdc_init_ep() { // Abstract line coding information cdc_line_coding.dwDTERate = 115200; // baud rate cdc_line_coding.bCharFormat = 0; // 1 stop bit cdc_line_coding.bParityType = 0; // None cdc_line_coding.bDataBits = 8; // 5,6,7,8, or 16 cdc_trf_state = CDC_TX_READY; cdc_tx_len = 0; /* * Do not have to init Cnt of IN pipes here. * Reason: Number of BYTEs to send to the host * varies from one transaction to * another. Cnt should equal the exact * number of BYTEs to transmit for * a given IN transaction. * This number of BYTEs will only * be known right before the data is * sent. */ usb_enable_endpoint (CDC_COMM_EP, USB_IN_ENABLED | USB_HANDSHAKE_ENABLED | USB_DISALLOW_SETUP); usb_enable_endpoint (CDC_DATA_EP, USB_IN_ENABLED | USB_OUT_ENABLED | USB_HANDSHAKE_ENABLED | USB_DISALLOW_SETUP); data_out = usb_rx_one_packet (CDC_DATA_EP, (unsigned char*) &cdc_data_rx, sizeof(cdc_data_rx)); data_in = 0; } /* * Get received data. */ int cdc_consume (void (*func) (int)) { unsigned len; if (! data_out || usb_handle_busy (data_out)) return 0; /* * Pass received data to user function. */ len = usb_handle_get_length (data_out); if (func != 0) { unsigned n; for (n=0; n 0); * } * Conditions: * cdc_is_tx_ready() must return TRUE. This indicates that the last * transfer is complete and is ready to receive a new block of data. */ int cdc_putc (int c) { if (cdc_trf_state != CDC_TX_READY || cdc_tx_len >= sizeof(cdc_data_tx)) return 0; cdc_data_tx [cdc_tx_len++] = c; return sizeof(cdc_data_tx) - cdc_tx_len; } /* * cdc_tx_service handles device-to-host transaction(s). This function * should be called once per Main Program loop after the device reaches * the configured state. * * Usage: * void main() * { * usb_device_init(); * while (1) * { * usb_device_tasks(); * if (USBGetDeviceState() < CONFIGURED_STATE || USBIsDeviceSuspended()) * { * // Either the device is not configured or we are suspended * // so we don't want to do execute any application code * continue; // go back to the top of the while loop * } else { * // Keep trying to send data to the PC as required * cdc_tx_service(); * * // Run application code. * UserApplication(); * } * } * } */ void cdc_tx_service() { // Check that USB connection is established. if (usb_device_state < CONFIGURED_STATE || (U1PWRC & PIC32_U1PWRC_USUSPEND)) return; if (usb_handle_busy(data_in)) return; /* * Completing stage is necessary while [ mCDCUSartTxIsBusy()==1 ]. * By having this stage, user can always check cdc_trf_state, * and not having to call mCDCUsartTxIsBusy() directly. */ if (cdc_trf_state == CDC_TX_COMPLETING) { cdc_trf_state = CDC_TX_READY; cdc_tx_len = 0; } /* * If CDC_TX_BUSY_ZLP state, send zero length packet */ if (cdc_trf_state == CDC_TX_BUSY_ZLP) { data_in = usb_tx_one_packet (CDC_DATA_EP, 0, 0); cdc_trf_state = CDC_TX_COMPLETING; return; } /* * Send a next packet. */ if (cdc_trf_state == CDC_TX_READY && cdc_tx_len > 0) { /* * Determine if a zero length packet state is necessary. * See explanation in USB Specification 2.0: Section 5.8.3 */ if (cdc_tx_len == CDC_DATA_IN_EP_SIZE) cdc_trf_state = CDC_TX_BUSY_ZLP; else cdc_trf_state = CDC_TX_COMPLETING; data_in = usb_tx_one_packet (CDC_DATA_EP, (unsigned char*)&cdc_data_tx, cdc_tx_len); } } ================================================ FILE: sys/arch/pic32/hal/usb_function_cdc.h ================================================ /* * USB CDC Function Driver File * * This file contains all of functions, macros, definitions, variables, * datatypes, etc. that are required for usage with the CDC function * driver. This file should be included in projects that use the CDC * \function driver. This file should also be included into the * usb_descriptors.c file and any other user file that requires access to the * CDC interface. * * The software supplied herewith by Microchip Technology Incorporated * (the 'Company') for its PIC(R) Microcontroller is intended and * supplied to you, the Company's customer, for use solely and * exclusively on Microchip PIC Microcontroller products. The * software is owned by the Company and/or its supplier, and is * protected under applicable copyright laws. All rights are reserved. * Any use in violation of the foregoing restrictions may subject the * user to criminal sanctions under applicable laws, as well as to * civil liability for the breach of the terms and conditions of this license. * * THIS SOFTWARE IS PROVIDED IN AN 'AS IS' CONDITION. NO WARRANTIES, * WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED * TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT, * IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. */ #ifndef CDC_H #define CDC_H /* * Default CDC configuration. */ #ifndef CDC_COMM_INTF_ID # define CDC_COMM_INTF_ID 0x0 #endif #ifndef CDC_COMM_EP # define CDC_COMM_EP 2 #endif #ifndef CDC_COMM_IN_EP_SIZE # define CDC_COMM_IN_EP_SIZE 8 #endif #ifndef CDC_DATA_INTF_ID # define CDC_DATA_INTF_ID 0x01 #endif #ifndef CDC_DATA_EP # define CDC_DATA_EP 3 #endif #ifndef CDC_DATA_OUT_EP_SIZE # define CDC_DATA_OUT_EP_SIZE 64 #endif #ifndef CDC_DATA_IN_EP_SIZE # define CDC_DATA_IN_EP_SIZE 64 #endif /* Class-Specific Requests */ #define SEND_ENCAPSULATED_COMMAND 0x00 #define GET_ENCAPSULATED_RESPONSE 0x01 #define SET_COMM_FEATURE 0x02 #define GET_COMM_FEATURE 0x03 #define CLEAR_COMM_FEATURE 0x04 #define SET_LINE_CODING 0x20 #define GET_LINE_CODING 0x21 #define SET_CONTROL_LINE_STATE 0x22 #define SEND_BREAK 0x23 /* Notifications * * Note: Notifications are polled over * Communication Interface (Interrupt Endpoint) */ #define NETWORK_CONNECTION 0x00 #define RESPONSE_AVAILABLE 0x01 #define SERIAL_STATE 0x20 /* Device Class Code */ #define CDC_DEVICE 0x02 /* Communication Interface Class Code */ #define COMM_INTF 0x02 /* Communication Interface Class SubClass Codes */ #define ABSTRACT_CONTROL_MODEL 0x02 /* Communication Interface Class Control Protocol Codes */ #define V25TER 0x01 // Common AT commands ("Hayes(TM)") /* Data Interface Class Codes */ #define DATA_INTF 0x0A /* Data Interface Class Protocol Codes */ #define NO_PROTOCOL 0x00 // No class specific protocol required /* Communication Feature Selector Codes */ #define ABSTRACT_STATE 0x01 #define COUNTRY_SETTING 0x02 /* Functional Descriptors */ /* Type Values for the bDscType Field */ #define CS_INTERFACE 0x24 #define CS_ENDPOINT 0x25 /* bDscSubType in Functional Descriptors */ #define DSC_FN_HEADER 0x00 #define DSC_FN_CALL_MGT 0x01 #define DSC_FN_ACM 0x02 // ACM - Abstract Control Management #define DSC_FN_DLM 0x03 // DLM - Direct Line Managment #define DSC_FN_TELEPHONE_RINGER 0x04 #define DSC_FN_RPT_CAPABILITIES 0x05 #define DSC_FN_UNION 0x06 #define DSC_FN_COUNTRY_SELECTION 0x07 #define DSC_FN_TEL_OP_MODES 0x08 #define DSC_FN_USB_TERMINAL 0x09 /* more.... see Table 25 in USB CDC Specification 1.1 */ /* CDC Bulk IN transfer states */ #define CDC_TX_READY 0 #define CDC_TX_BUSY_ZLP 2 // ZLP: Zero Length Packet #define CDC_TX_COMPLETING 3 #if defined(USB_CDC_SUPPORT_HARDWARE_FLOW_CONTROL) #define CONFIGURE_RTS(a) UART_RTS = a; #define CONFIGURE_DTR(a) UART_DTR = a; #else #define CONFIGURE_RTS(a) #define CONFIGURE_DTR(a) #endif #define USB_CDC_ACM_FN_DSC_VAL 0x02 /* * Function: * void cdc_set_baud_rate(unsigned int baudRate) * * Summary: * This macro is used set the baud rate reported back to the host during * a get line coding request. (optional) * * Description: * This macro is used set the baud rate reported back to the host during * a get line coding request. * * Typical Usage: * * cdc_set_baud_rate(19200); * * * This function is optional for CDC devices that do not actually convert * the USB traffic to a hardware UART. * * Parameters: * unsigned int baudRate - The desired baudrate */ #define cdc_set_baud_rate(baudRate) { cdc_line_coding.dwDTERate = baudRate; } /* * Function: * void cdc_set_character_format (unsigned charFormat) * * Summary: * This macro is used manually set the character format reported back to * the host during a get line coding request. (optional) * * Description: * This macro is used manually set the character format reported back to * the host during a get line coding request. * * Typical Usage: * * cdc_set_character_format(NUM_STOP_BITS_1); * * * This function is optional for CDC devices that do not actually convert * the USB traffic to a hardware UART. * * Parameters: * unsigned charFormat - number of stop bits. Available options are: * * NUM_STOP_BITS_1 - 1 Stop bit * * NUM_STOP_BITS_1_5 - 1.5 Stop bits * * NUM_STOP_BITS_2 - 2 Stop bits */ #define cdc_set_character_format(charFormat) { cdc_line_coding.bCharFormat = charFormat; } #define NUM_STOP_BITS_1 0 // 1 stop bit #define NUM_STOP_BITS_1_5 1 // 1.5 stop bit #define NUM_STOP_BITS_2 2 // 2 stop bit /* * Function: * void cdc_set_parity (unsigned parityType) * * Summary: * This function is used manually set the parity format reported back to * the host during a get line coding request. (optional) * * Description: * This macro is used manually set the parity format reported back to * the host during a get line coding request. * * Typical Usage: * * cdc_set_parity(PARITY_NONE); * * * This function is optional for CDC devices that do not actually convert * the USB traffic to a hardware UART. * * Parameters: * unsigned parityType - Type of parity. The options are the following: * * PARITY_NONE * * PARITY_ODD * * PARITY_EVEN * * PARITY_MARK * * PARITY_SPACE */ #define cdc_set_parity(parityType) { cdc_line_coding.bParityType = parityType; } #define PARITY_NONE 0 // no parity #define PARITY_ODD 1 // odd parity #define PARITY_EVEN 2 // even parity #define PARITY_MARK 3 // mark parity #define PARITY_SPACE 4 // space parity /* * Function: * void cdc_set_data_size (unsigned dataBits) * * Summary: * This function is used manually set the number of data bits reported back * to the host during a get line coding request. (optional) * * Description: * This function is used manually set the number of data bits reported back * to the host during a get line coding request. * * Typical Usage: * * cdc_set_data_size(8); * * * This function is optional for CDC devices that do not actually convert * the USB traffic to a hardware UART. * * Parameters: * unsigned dataBits - number of data bits. The options are 5, 6, 7, 8, or 16. */ #define cdc_set_data_size(dataBits) { cdc_line_coding.bDataBits = dataBits; } /* * Function: * void cdc_set_line_coding(unsigned int baud, unsigned format, unsigned parity, unsigned dataSize) * * Summary: * This function is used to manually set the data reported back * to the host during a get line coding request. (optional) * * Description: * This function is used to manually set the data reported back * to the host during a get line coding request. * * Typical Usage: * * cdc_set_line_coding(19200, NUM_STOP_BITS_1, PARITY_NONE, 8); * * * This function is optional for CDC devices that do not actually convert * the USB traffic to a hardware UART. * * Parameters: * unsigned baud - The desired baudrate * unsigned format - number of stop bits. Available options are: * * NUM_STOP_BITS_1 - 1 Stop bit * * NUM_STOP_BITS_1_5 - 1.5 Stop bits * * NUM_STOP_BITS_2 - 2 Stop bits * unsigned parity - Type of parity. The options are the following: * * PARITY_NONE * * PARITY_ODD * * PARITY_EVEN * * PARITY_MARK * * PARITY_SPACE * unsigned dataSize - number of data bits. The options are 5, 6, 7, 8, or 16. */ #define cdc_set_line_coding(baud, format, parity, dataSize) {\ cdc_set_baud_rate(baud);\ cdc_set_character_format(format);\ cdc_set_parity(parity);\ cdc_set_data_size(dataSize);\ } /* * Function: * bool_t cdc_is_tx_ready(void) * * Summary: * This macro is used to check if the CDC class is ready * to send more data. * * Description: * This macro is used to check if the CDC class is ready * to send more data. * * Typical Usage: * * if (cdc_is_tx_ready()) * { * cdc_putrs ("Hello World"); * } * */ #define cdc_is_tx_ready() (cdc_trf_state == CDC_TX_READY) /* * S T R U C T U R E S */ /* Line Coding Structure */ #define LINE_CODING_LENGTH 0x07 typedef union _LINE_CODING { struct { unsigned char _byte[LINE_CODING_LENGTH]; }; struct { unsigned long dwDTERate; // Complex data structure unsigned char bCharFormat; unsigned char bParityType; unsigned char bDataBits; }; } LINE_CODING; typedef union _CONTROL_SIGNAL_BITMAP { unsigned char _byte; struct { unsigned DTE_PRESENT:1; // [0] Not Present [1] Present unsigned CARRIER_CONTROL:1; // [0] Deactivate [1] Activate }; } CONTROL_SIGNAL_BITMAP; /* Functional Descriptor Structure - See CDC Specification 1.1 for details */ /* Header Functional Descriptor */ typedef struct __attribute__((packed)) _USB_CDC_HEADER_FN_DSC { unsigned char bFNLength; unsigned char bDscType; unsigned char bDscSubType; unsigned short bcdCDC; } USB_CDC_HEADER_FN_DSC; /* Abstract Control Management Functional Descriptor */ typedef struct __attribute__((packed)) _USB_CDC_ACM_FN_DSC { unsigned char bFNLength; unsigned char bDscType; unsigned char bDscSubType; unsigned char bmCapabilities; } USB_CDC_ACM_FN_DSC; /* Union Functional Descriptor */ typedef struct __attribute__((packed)) _USB_CDC_UNION_FN_DSC { unsigned char bFNLength; unsigned char bDscType; unsigned char bDscSubType; unsigned char bMasterIntf; unsigned char bSaveIntf0; } USB_CDC_UNION_FN_DSC; /* Call Management Functional Descriptor */ typedef struct __attribute__((packed)) _USB_CDC_CALL_MGT_FN_DSC { unsigned char bFNLength; unsigned char bDscType; unsigned char bDscSubType; unsigned char bmCapabilities; unsigned char bDataInterface; } USB_CDC_CALL_MGT_FN_DSC; typedef union __attribute__((packed)) _CDC_NOTICE { LINE_CODING GetLineCoding; LINE_CODING SetLineCoding; unsigned char packet[CDC_COMM_IN_EP_SIZE]; } CDC_NOTICE, *PCDC_NOTICE; /* * E X T E R N S */ extern unsigned cdc_rx_len; extern unsigned cdc_tx_len; extern unsigned cdc_trf_state; extern LINE_CODING cdc_line_coding; /* * Public Prototypes */ void cdc_check_request (void); void cdc_init_ep (void); void cdc_tx_service (void); int cdc_putc (int c); int cdc_consume (void (*func) (int)); #endif //CDC_H ================================================ FILE: sys/arch/pic32/hal/usb_function_hid.c ================================================ /* * USB HID Function Driver File * * This file contains all of functions, macros, definitions, variables, * datatypes, etc. that are required for usage with the HID function * driver. This file should be included in projects that use the HID * function driver. * * The software supplied herewith by Microchip Technology Incorporated * (the 'Company') for its PIC(R) Microcontroller is intended and * supplied to you, the Company's customer, for use solely and * exclusively on Microchip PIC Microcontroller products. The * software is owned by the Company and/or its supplier, and is * protected under applicable copyright laws. All rights are reserved. * Any use in violation of the foregoing restrictions may subject the * user to criminal sanctions under applicable laws, as well as to * civil liability for the breach of the terms and conditions of this license. * * THIS SOFTWARE IS PROVIDED IN AN 'AS IS' CONDITION. NO WARRANTIES, * WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED * TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT, * IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. */ #include #include unsigned char hid_idle_rate; unsigned char hid_active_protocol; // [0] Boot Protocol [1] Report Protocol /* * Section C: non-EP0 Buffer Space */ volatile unsigned char hid_report_out[HID_INT_OUT_EP_SIZE]; volatile unsigned char hid_report_in[HID_INT_IN_EP_SIZE]; volatile unsigned char hid_report_feature [HID_FEATURE_REPORT_BYTES]; /* * Check to see if the HID supports a specific Output or Feature report. * * Return: 1 if it's a supported Input report * 2 if it's a supported Output report * 3 if it's a supported Feature report * 0 for all other cases */ static unsigned char report_supported (void) { // Find out if an Output or Feature report has arrived on the control pipe. usb_device_tasks(); switch (usb_setup_pkt.W_Value >> 8) { case 0x01: // Input report switch (usb_setup_pkt.W_Value & 0xff) { case 0x00: return 1; // Report ID 0 default: return 0; // Other report IDs not supported. } case 0x02: // Output report switch (usb_setup_pkt.W_Value & 0xff) { case 0x00: return 2; // Report ID 0 default: return 0; // Other report IDs not supported. } case 0x03: // Feature report switch (usb_setup_pkt.W_Value & 0xff) { case 0x00: return 3; // Report ID 0 default: return 0; // Other report IDs not supported. } default: return 0; } } /* * Check to see if an Output or Feature report has arrived * on the control pipe. If yes, extract and use the data. */ static void report_handler (void) { unsigned char count = 0; // Find out if an Output or Feature report has arrived on the control pipe. // Get the report type from the Setup packet. switch (usb_setup_pkt.W_Value >> 8) { case 0x02: // Output report switch (usb_setup_pkt.W_Value & 0xff) { case 0: // Report ID 0 // This example application copies the Output report data // to hid_report_in. // (Assumes Input and Output reports are the same length.) // A "real" application would do something more useful with the data. // wCount holds the number of bytes read in the Data stage. // This example assumes the report fits in one transaction. for (count=0; count <= HID_OUTPUT_REPORT_BYTES - 1; count++) { hid_report_in[count] = hid_report_out[count]; } break; } break; case 0x03: // Feature report // Get the report ID from the Setup packet. switch (usb_setup_pkt.W_Value & 0xff) { case 0: // Report ID 0 // The Feature report data is in hid_report_feature. // This example application just sends the data back in the next // Get_Report request for a Feature report. // wCount holds the number of bytes read in the Data stage. // This example assumes the report fits in one transaction. // The Feature report uses a single buffer so to send the same data back // in the next IN Feature report, there is nothing to copy. // The data is in hid_report_feature[HID_FEATURE_REPORT_BYTES] break; } break; } } /* * This routine handles HID specific request that happen on EP0. These * include, but are not limited to, requests for the HID report * descriptors. This function should be called from the * USBCBCheckOtherReq() call back function whenever using an HID device. * * Typical Usage: * void USBCBCheckOtherReq(void) * { * // Since the stack didn't handle the request I need * // to check my class drivers to see if it is for them * hid_check_request(); * } */ void hid_check_request (void) { if (usb_setup_pkt.Recipient != RCPT_INTF) return; if (usb_setup_pkt.bIntfID != HID_INTF_ID) return; /* * There are two standard requests that hid.c may support. * 1. GET_DSC(DSC_HID,DSC_RPT,DSC_PHY); * 2. SET_DSC(DSC_HID,DSC_RPT,DSC_PHY); */ if (usb_setup_pkt.bRequest == GET_DSC) { switch (usb_setup_pkt.bDescriptorType) { case DSC_HID: if (usb_active_configuration == 1) { usb_ep0_send_rom_ptr ((const unsigned char*) &usb_config1_descriptor + 18, sizeof(USB_HID_DSC)+3, USB_EP0_INCLUDE_ZERO); } break; case DSC_RPT: if (usb_active_configuration == 1) { usb_ep0_send_rom_ptr ((const unsigned char*) &hid_rpt01[0], HID_RPT01_SIZE, // See target.cfg USB_EP0_INCLUDE_ZERO); } break; case DSC_PHY: usb_ep0_transmit (USB_EP0_NO_DATA); break; } } if (usb_setup_pkt.RequestType != CLASS) return; switch (usb_setup_pkt.bRequest) { case GET_REPORT: switch (report_supported()) { case 1: // Input Report usb_in_pipe[0].pSrc.bRam = (unsigned char*) &hid_report_in[0]; usb_in_pipe[0].info.bits.ctrl_trf_mem = _RAM; // Set memory type usb_in_pipe[0].wCount = HID_INPUT_REPORT_BYTES; // Set data count usb_in_pipe[0].info.bits.busy = 1; break; case 3: // Feature Report usb_in_pipe[0].pSrc.bRam = (unsigned char*) &hid_report_feature[0]; usb_in_pipe[0].info.bits.ctrl_trf_mem = _RAM; // Set memory type usb_in_pipe[0].wCount = HID_FEATURE_REPORT_BYTES; // Set data count usb_in_pipe[0].info.bits.busy = 1; break; } break; case SET_REPORT: switch (report_supported()) { case 2: // Output Report usb_out_pipe[0].wCount = usb_setup_pkt.wLength; usb_out_pipe[0].pFunc = report_handler; usb_out_pipe[0].pDst.bRam = (unsigned char*) &hid_report_out[0]; usb_out_pipe[0].info.bits.busy = 1; break; case 3: // Feature Report usb_out_pipe[0].wCount = usb_setup_pkt.wLength; usb_out_pipe[0].pFunc = report_handler; usb_out_pipe[0].pDst.bRam = (unsigned char*) &hid_report_feature[0]; usb_out_pipe[0].info.bits.busy = 1; break; } break; case GET_IDLE: usb_ep0_send_ram_ptr (&hid_idle_rate, 1, USB_EP0_INCLUDE_ZERO); break; case SET_IDLE: usb_ep0_transmit (USB_EP0_NO_DATA); hid_idle_rate = usb_setup_pkt.W_Value >> 8; break; case GET_PROTOCOL: usb_ep0_send_ram_ptr (&hid_active_protocol, 1, USB_EP0_NO_OPTIONS); break; case SET_PROTOCOL: usb_ep0_transmit (USB_EP0_NO_DATA); hid_active_protocol = usb_setup_pkt.W_Value & 0xff; break; } } ================================================ FILE: sys/arch/pic32/hal/usb_function_hid.h ================================================ /* * USB HID Function Driver File * * This file contains all of functions, macros, definitions, variables, * datatypes, etc. that are required for usage with the HID function * driver. This file should be included in projects that use the HID * function driver. This file should also be included into the * usb_descriptors.c file and any other user file that requires access to the * HID interface. * * The software supplied herewith by Microchip Technology Incorporated * (the 'Company') for its PIC(R) Microcontroller is intended and * supplied to you, the Company's customer, for use solely and * exclusively on Microchip PIC Microcontroller products. The * software is owned by the Company and/or its supplier, and is * protected under applicable copyright laws. All rights are reserved. * Any use in violation of the foregoing restrictions may subject the * user to criminal sanctions under applicable laws, as well as to * civil liability for the breach of the terms and conditions of this license. * * THIS SOFTWARE IS PROVIDED IN AN 'AS IS' CONDITION. NO WARRANTIES, * WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED * TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT, * IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. */ #ifndef HID_H #define HID_H /* * Default HID configuration. */ #ifndef HID_EP # define HID_EP 1 #endif #ifndef HID_INTF_ID # define HID_INTF_ID 0x00 #endif #ifndef HID_BD_OUT # define HID_BD_OUT USB_EP_1_OUT #endif #ifndef HID_INT_OUT_EP_SIZE # define HID_INT_OUT_EP_SIZE 3 #endif #ifndef HID_BD_IN # define HID_BD_IN USB_EP_1_IN #endif #ifndef HID_INT_IN_EP_SIZE # define HID_INT_IN_EP_SIZE 3 #endif #ifndef HID_NUM_OF_DSC # define HID_NUM_OF_DSC 1 #endif #ifndef HID_RPT01_SIZE # define HID_RPT01_SIZE 47 #endif /* Class-Specific Requests */ #define GET_REPORT 0x01 #define GET_IDLE 0x02 #define GET_PROTOCOL 0x03 #define SET_REPORT 0x09 #define SET_IDLE 0x0A #define SET_PROTOCOL 0x0B /* Class Descriptor Types */ #define DSC_HID 0x21 #define DSC_RPT 0x22 #define DSC_PHY 0x23 /* Protocol Selection */ #define BOOT_PROTOCOL 0x00 #define RPT_PROTOCOL 0x01 /* HID Interface Class Code */ #define HID_INTF 0x03 /* HID Interface Class SubClass Codes */ #define BOOT_INTF_SUBCLASS 0x01 /* HID Interface Class Protocol Codes */ #define HID_PROTOCOL_NONE 0x00 #define HID_PROTOCOL_KEYBOARD 0x01 #define HID_PROTOCOL_MOUSE 0x02 extern const unsigned char hid_rpt01 [HID_RPT01_SIZE]; extern volatile unsigned char hid_report_out[HID_INT_OUT_EP_SIZE]; extern volatile unsigned char hid_report_in[HID_INT_IN_EP_SIZE]; extern volatile unsigned char hid_report_feature[HID_FEATURE_REPORT_BYTES]; // // USB HID Descriptor header as detailed in section // "6.2.1 HID Descriptor" of the HID class definition specification // typedef struct _USB_HID_DSC_HEADER { unsigned char bDescriptorType; // offset 9 unsigned short wDscLength; // offset 10 } USB_HID_DSC_HEADER; // // USB HID Descriptor header as detailed in section // "6.2.1 HID Descriptor" of the HID class definition specification // typedef struct _USB_HID_DSC { unsigned char bLength; // offset 0 unsigned char bDescriptorType; // offset 1 unsigned short bcdHID; // offset 2 unsigned char bCountryCode; // offset 4 unsigned char bNumDsc; // offset 5 } USB_HID_DSC; void hid_check_request(void); #endif // HID_H ================================================ FILE: sys/arch/pic32/hal/usb_hal_pic32.h ================================================ /* * USB Hardware Abstraction Layer (HAL) (Header File) * * This file abstracts the hardware interface. The USB stack firmware can be * compiled to work on different USB microcontrollers, such as PIC18 and PIC24. * The USB related special function registers and bit names are generally very * similar between the device families, but small differences in naming exist. * * In order to make the same set of firmware work accross the device families, * when modifying SFR contents, a slightly abstracted name is used, which is * then "mapped" to the appropriate real name in the usb_hal_picxx.h header. * * Make sure to include the correct version of the usb_hal_picxx.h file for * the microcontroller family which will be used. * * The software supplied herewith by Microchip Technology Incorporated * (the 'Company') for its PICmicro(R) Microcontroller is intended and * supplied to you, the Company's customer, for use solely and * exclusively on Microchip PICmicro Microcontroller products. The * software is owned by the Company and/or its supplier, and is * protected under applicable copyright laws. All rights are reserved. * Any use in violation of the foregoing restrictions may subject the * user to criminal sanctions under applicable laws, as well as to * civil liability for the breach of the terms and conditions of this * license. * * THIS SOFTWARE IS PROVIDED IN AN 'AS IS' CONDITION. NO WARRANTIES, * WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED * TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT, * IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. */ #ifndef USB_HAL_PIC32_H #define USB_HAL_PIC32_H /* Buffer Descriptor Status Register Initialization Parameters */ //The _BSTALL definition is changed from 0x04 to 0x00 to // fix a difference in the PIC18 and PIC24 definitions of this // bit. This should be changed back once the definitions are // synced. #define _BSTALL 0x04 //Buffer Stall enable #define _DTSEN 0x08 //Data Toggle Synch enable #define _DAT0 0x00 //DATA0 packet expected next #define _DAT1 0x40 //DATA1 packet expected next #define _DTSMASK 0x40 //DTS Mask #define _USIE 0x80 //SIE owns buffer #define _UCPU 0x00 //CPU owns buffer #define _STAT_MASK 0xFC // Buffer Descriptor Status Register layout. typedef union __attribute__ ((packed)) _BD_STAT { struct __attribute__ ((packed)){ unsigned :2; unsigned BSTALL :1; //Buffer Stall Enable unsigned DTSEN :1; //Data Toggle Synch Enable unsigned :2; //Reserved - write as 00 unsigned DTS :1; //Data Toggle Synch Value unsigned UOWN :1; //USB Ownership }; struct __attribute__ ((packed)){ unsigned :2; unsigned PID0 :1; unsigned PID1 :1; unsigned PID2 :1; unsigned PID3 :1; }; struct __attribute__ ((packed)){ unsigned :2; unsigned PID :4; //Packet Identifier }; unsigned short Val; } BD_STAT; // BDT Entry Layout typedef union __attribute__ ((packed))__BDT { struct __attribute__ ((packed)) { BD_STAT STAT; unsigned CNT:10; unsigned char *ADR; //Buffer Address }; struct __attribute__ ((packed)) { unsigned res :16; unsigned count:10; }; unsigned int w[2]; unsigned short v[4]; unsigned long long Val; } BDT_ENTRY; #define USTAT_EP0_PP_MASK ~0x04 #define USTAT_EP_MASK 0xFC #define USTAT_EP0_OUT 0x00 #define USTAT_EP0_OUT_EVEN 0x00 #define USTAT_EP0_OUT_ODD 0x04 #define USTAT_EP0_IN 0x08 #define USTAT_EP0_IN_EVEN 0x08 #define USTAT_EP0_IN_ODD 0x0C #define UEP_STALL 0x0002 //#define USB_PING_PONG__NO_PING_PONG 0x00 //#define USB_PING_PONG__EP0_OUT_ONLY 0x01 #define USB_PING_PONG__FULL_PING_PONG 0x02 //#define USB_PING_PONG__ALL_BUT_EP0 0x03 /* * Translate virtual address to physical one. * Only for fixed mapping. */ static inline void *ConvertToPhysicalAddress (volatile void *addr) { unsigned virt = (unsigned) addr; unsigned phys; if (virt & 0x80000000) { if (virt & 0x40000000) { // kseg2 or kseg3 - no mapping phys = virt; } else { // kseg0 or kseg1, cut bits A[31:29] phys = virt & 0x1fffffff; } } else { // kuseg phys = virt + 0x40000000; } return (void*) phys; } /* * This macro is used to disable the USB module */ #define usb_module_disable() {\ U1CON = 0;\ U1IE = 0;\ U1OTGIE = 0;\ U1PWR |= PIC32_U1PWR_USBPWR;\ usb_device_state = DETACHED_STATE;\ } #endif ================================================ FILE: sys/arch/pic32/include/_float.h ================================================ #ifndef _MACHINE__FLOAT_H_ #define _MACHINE__FLOAT_H_ /* Characteristics of IEEE floating types */ #define FLT_RADIX 2 #define FLT_ROUNDS 1 /* * These values provide information pertaining to the float type. */ #define FLT_EPSILON 1.19209290E-07F /* b**(1-p) */ #define FLT_MAX 3.40282347E+38F /* (1-b**(-p))*b**emax */ #define FLT_MIN 1.17549435E-38F /* b**(emin-1) */ #define FLT_DIG 6 /* floor((p-1)*log10(b))+(b == 10) */ #define FLT_MANT_DIG 24 /* p */ #define FLT_MAX_10_EXP 38 /* floor(log10((1-b**(-p))*b**emax)) */ #define FLT_MAX_EXP 128 /* emax */ #define FLT_MIN_10_EXP (-37) /* ceil(log10(b**(emin-1))) */ #define FLT_MIN_EXP (-125) /* emin */ /* * These values provide information pertaining to the double type. */ #define DBL_EPSILON 2.2204460492503131E-16 #define DBL_MAX 1.7976931348623157E+308 #define DBL_MIN 2.2250738585072014E-308 #define DBL_DIG 15 #define DBL_MANT_DIG 53 #define DBL_MAX_10_EXP 308 #define DBL_MAX_EXP 1024 #define DBL_MIN_10_EXP (-307) #define DBL_MIN_EXP (-1021) /* * These values provide information pertaining to the long double type. */ #define LDBL_EPSILON DBL_EPSILON #define LDBL_MAX DBL_MAX #define LDBL_MIN DBL_MIN #define LDBL_DIG DBL_DIG #define LDBL_MANT_DIG DBL_MANT_DIG #define LDBL_MAX_10_EXP DBL_MAX_10_EXP #define LDBL_MAX_EXP DBL_MAX_EXP #define LDBL_MIN_10_EXP DBL_MIN_10_EXP #define LDBL_MIN_EXP DBL_MIN_EXP #endif /* _MACHINE__FLOAT_H_ */ ================================================ FILE: sys/arch/pic32/include/cpu.h ================================================ /* * Copyright (c) 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * * @(#)cpu.h 1.5 (2.11BSD GTE) 1998/4/3 */ /* * CTL_MACHDEP definitions. */ #define CPU_CONSDEV 1 /* dev_t: console terminal device */ #define CPU_ERRMSG 2 /* get error message by errno */ #define CPU_NLIST 3 /* get name address */ #define CPU_TIMO_CMD 4 #define CPU_TIMO_SEND_OP 5 #define CPU_TIMO_SEND_CSD 6 #define CPU_TIMO_READ 7 #define CPU_TIMO_WAIT_CMD 8 #define CPU_TIMO_WAIT_WDATA 9 #define CPU_TIMO_WAIT_WDONE 10 #define CPU_TIMO_WAIT_WSTOP 11 #define CPU_TIMO_WAIT_WIDLE 12 #define CPU_FREQ_KHZ 13 /* processor clock in kHz */ #define CPU_BUS_KHZ 14 /* i/o bus clock in kHz */ #define CPU_MAXID 15 /* number of valid machdep ids */ #ifndef KERNEL #define CTL_MACHDEP_NAMES { \ { 0, 0 }, \ { "console_device", CTLTYPE_STRUCT }, \ { 0, 0 }, \ { 0, 0 }, \ { "sd_timeout_cmd", CTLTYPE_INT }, \ { "sd_timeout_send_op", CTLTYPE_INT }, \ { "sd_timeout_send_csd", CTLTYPE_INT }, \ { "sd_timeout_read", CTLTYPE_INT }, \ { "sd_timeout_wait_cmd", CTLTYPE_INT }, \ { "sd_timeout_wait_wdata", CTLTYPE_INT }, \ { "sd_timeout_wait_wdone", CTLTYPE_INT }, \ { "sd_timeout_wait_wstop", CTLTYPE_INT }, \ { "sd_timeout_wait_widle", CTLTYPE_INT }, \ { "cpu_khz", CTLTYPE_INT }, \ { "bus_khz", CTLTYPE_INT }, \ } #endif ================================================ FILE: sys/arch/pic32/include/debug.h ================================================ #ifndef _DEBUG_H #define _DEBUG_H #define DEBUG(...) #define DEBUG1(...) #define DEBUG2(...) #define DEBUG3(...) #define DEBUG4(...) #define DEBUG5(...) #define DEBUG6(...) #define DEBUG7(...) #define DEBUG8(...) #define DEBUG9(...) #ifdef GLOBAL_DEBUG #undef DEBUG #define DEBUG(...) printf(__VA_ARGS__) #if (GLOBAL_DEBUG>=1) #undef DEBUG1 #define DEBUG1(...) printf(__VA_ARGS__) #endif #if (GLOBAL_DEBUG>=2) #undef DEBUG2 #define DEBUG2(...) printf(__VA_ARGS__) #endif #if (GLOBAL_DEBUG>=3) #undef DEBUG3 #define DEBUG3(...) printf(__VA_ARGS__) #endif #if (GLOBAL_DEBUG>=4) #undef DEBUG4 #define DEBUG4(...) printf(__VA_ARGS__) #endif #if (GLOBAL_DEBUG>=5) #undef DEBUG5 #define DEBUG5(...) printf(__VA_ARGS__) #endif #if (GLOBAL_DEBUG>=6) #undef DEBUG6 #define DEBUG6(...) printf(__VA_ARGS__) #endif #if (GLOBAL_DEBUG>=7) #undef DEBUG7 #define DEBUG7(...) printf(__VA_ARGS__) #endif #if (GLOBAL_DEBUG>=8) #undef DEBUG8 #define DEBUG8(...) printf(__VA_ARGS__) #endif #if (GLOBAL_DEBUG>=9) #undef DEBUG9 #define DEBUG9(...) printf(__VA_ARGS__) #endif #endif #define SETVAL(X) \ TRISECLR = 0b0000000011111111; \ LATECLR = 0b0000000011111111; \ LATESET = (X & 0xFF) /* TRISFCLR = 0b0000000000110000; \ LATFCLR = 0b0000000000110000; \ TRISBCLR = 0b1111111000000000; \ LATBCLR = 0b1111111000000000; \ LATBCLR = 0b0000001000000000; \ LATFSET = ((X & 0x01) << 5) | ((X & 0x02) << 3); \ LATBSET = ((X & 0x04) << 13) | ((X & 0x08) << 11) | ((X & 0x10) << 9) | ((X & 0x20) << 7) | ((X & 0x40) << 5) | ((X & 0x80) << 3); \ LATBSET = 0b0000001000000000; */ #define LED_ON(X,Y) TRIS_CLR(X) = 1<<(Y); LAT_SET(X) = 1<<(Y); #define LED_OFF(X,Y) TRIS_CLR(X) = 1<<(Y); LAT_CLR(X) = 1<<(Y); #endif ================================================ FILE: sys/arch/pic32/include/elf_machdep.h ================================================ /* $NetBSD: elf_machdep.h,v 1.20 2017/11/06 19:17:43 christos Exp $ */ /*- * Copyright (c) 2013 The NetBSD Foundation, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ #ifndef _MIPS_ELF_MACHDEP_H_ #define _MIPS_ELF_MACHDEP_H_ #ifdef _LP64 #define KERN_ELFSIZE 64 #define ARCH_ELFSIZE 64 /* MD native binary size */ #define ELFSIZE 64 #else #define KERN_ELFSIZE 32 #define ARCH_ELFSIZE 32 /* MD native binary size */ #define ELFSIZE 32 #endif #if ELFSIZE == 32 #define ELF32_MACHDEP_ID_CASES \ case EM_MIPS: \ break; #define ELF32_MACHDEP_ID EM_MIPS #elif ELFSIZE == 64 #define ELF64_MACHDEP_ID_CASES \ case EM_MIPS: \ break; #define ELF64_MACHDEP_ID EM_MIPS #endif /* mips relocs. */ #define R_MIPS_NONE 0 #define R_MIPS_16 1 #define R_MIPS_32 2 #define R_MIPS_REL32 3 #define R_MIPS_REL R_MIPS_REL32 #define R_MIPS_26 4 #define R_MIPS_HI16 5 /* high 16 bits of symbol value */ #define R_MIPS_LO16 6 /* low 16 bits of symbol value */ #define R_MIPS_GPREL16 7 /* GP-relative reference */ #define R_MIPS_LITERAL 8 /* Reference to literal section */ #define R_MIPS_GOT16 9 /* Reference to global offset table */ #define R_MIPS_GOT R_MIPS_GOT16 #define R_MIPS_PC16 10 /* 16 bit PC relative reference */ #define R_MIPS_CALL16 11 /* 16 bit call thru glbl offset tbl */ #define R_MIPS_CALL R_MIPS_CALL16 #define R_MIPS_GPREL32 12 /* 13, 14, 15 are not defined at this point. */ #define R_MIPS_UNUSED1 13 #define R_MIPS_UNUSED2 14 #define R_MIPS_UNUSED3 15 /* * The remaining relocs are apparently part of the 64-bit Irix ELF ABI. */ #define R_MIPS_SHIFT5 16 #define R_MIPS_SHIFT6 17 #define R_MIPS_64 18 #define R_MIPS_GOT_DISP 19 #define R_MIPS_GOT_PAGE 20 #define R_MIPS_GOT_OFST 21 #define R_MIPS_GOT_HI16 22 #define R_MIPS_GOT_LO16 23 #define R_MIPS_SUB 24 #define R_MIPS_INSERT_A 25 #define R_MIPS_INSERT_B 26 #define R_MIPS_DELETE 27 #define R_MIPS_HIGHER 28 #define R_MIPS_HIGHEST 29 #define R_MIPS_CALL_HI16 30 #define R_MIPS_CALL_LO16 31 #define R_MIPS_SCN_DISP 32 #define R_MIPS_REL16 33 #define R_MIPS_ADD_IMMEDIATE 34 #define R_MIPS_PJUMP 35 #define R_MIPS_RELGOT 36 #define R_MIPS_JALR 37 /* TLS relocations */ #define R_MIPS_TLS_DTPMOD32 38 /* Module number 32 bit */ #define R_MIPS_TLS_DTPREL32 39 /* Module-relative offset 32 bit */ #define R_MIPS_TLS_DTPMOD64 40 /* Module number 64 bit */ #define R_MIPS_TLS_DTPREL64 41 /* Module-relative offset 64 bit */ #define R_MIPS_TLS_GD 42 /* 16 bit GOT offset for GD */ #define R_MIPS_TLS_LDM 43 /* 16 bit GOT offset for LDM */ #define R_MIPS_TLS_DTPREL_HI16 44 /* Module-relative offset, high 16 bits */ #define R_MIPS_TLS_DTPREL_LO16 45 /* Module-relative offset, low 16 bits */ #define R_MIPS_TLS_GOTTPREL 46 /* 16 bit GOT offset for IE */ #define R_MIPS_TLS_TPREL32 47 /* TP-relative offset, 32 bit */ #define R_MIPS_TLS_TPREL64 48 /* TP-relative offset, 64 bit */ #define R_MIPS_TLS_TPREL_HI16 49 /* TP-relative offset, high 16 bits */ #define R_MIPS_TLS_TPREL_LO16 50 /* TP-relative offset, low 16 bits */ #define R_MIPS_max 51 #define R_TYPE(name) __CONCAT(R_MIPS_,name) #define R_MIPS16_min 100 #define R_MIPS16_26 100 #define R_MIPS16_GPREL 101 #define R_MIPS16_GOT16 102 #define R_MIPS16_CALL16 103 #define R_MIPS16_HI16 104 #define R_MIPS16_LO16 105 #define R_MIPS16_max 106 #define R_MIPS_COPY 126 #define R_MIPS_JUMP_SLOT 127 /* mips dynamic tags */ #define DT_MIPS_RLD_VERSION 0x70000001 #define DT_MIPS_TIME_STAMP 0x70000002 #define DT_MIPS_ICHECKSUM 0x70000003 #define DT_MIPS_IVERSION 0x70000004 #define DT_MIPS_FLAGS 0x70000005 #define DT_MIPS_BASE_ADDRESS 0x70000006 #define DT_MIPS_CONFLICT 0x70000008 #define DT_MIPS_LIBLIST 0x70000009 #define DT_MIPS_CONFLICTNO 0x7000000b #define DT_MIPS_LOCAL_GOTNO 0x7000000a /* number of local got ents */ #define DT_MIPS_LIBLISTNO 0x70000010 #define DT_MIPS_SYMTABNO 0x70000011 /* number of .dynsym entries */ #define DT_MIPS_UNREFEXTNO 0x70000012 #define DT_MIPS_GOTSYM 0x70000013 /* first dynamic sym in got */ #define DT_MIPS_HIPAGENO 0x70000014 #define DT_MIPS_RLD_MAP 0x70000016 /* address of loader map */ #define DT_MIPS_PLTGOT 0x70000032 #define DT_MIPS_RWPLT 0x70000034 /* * ELF Flags */ #define EF_MIPS_PIC 0x00000002 /* Contains PIC code */ #define EF_MIPS_CPIC 0x00000004 /* STD PIC calling sequence */ #define EF_MIPS_ABI2 0x00000020 /* N32 */ #define EF_MIPS_ARCH_ASE 0x0f000000 /* Architectural extensions */ #define EF_MIPS_ARCH_MDMX 0x08000000 /* MDMX multimedia extension */ #define EF_MIPS_ARCH_M16 0x04000000 /* MIPS-16 ISA extensions */ #define EF_MIPS_ARCH 0xf0000000 /* Architecture field */ #define EF_MIPS_ARCH_1 0x00000000 /* -mips1 code */ #define EF_MIPS_ARCH_2 0x10000000 /* -mips2 code */ #define EF_MIPS_ARCH_3 0x20000000 /* -mips3 code */ #define EF_MIPS_ARCH_4 0x30000000 /* -mips4 code */ #define EF_MIPS_ARCH_5 0x40000000 /* -mips5 code */ #define EF_MIPS_ARCH_32 0x50000000 /* -mips32 code */ #define EF_MIPS_ARCH_64 0x60000000 /* -mips64 code */ #define EF_MIPS_ARCH_32R2 0x70000000 /* -mips32r2 code */ #define EF_MIPS_ARCH_64R2 0x80000000 /* -mips64r2 code */ #define EF_MIPS_ABI 0x0000f000 #define EF_MIPS_ABI_O32 0x00001000 #define EF_MIPS_ABI_O64 0x00002000 #define EF_MIPS_ABI_EABI32 0x00003000 #define EF_MIPS_ABI_EABI64 0x00004000 #if defined(__MIPSEB__) #define ELF32_MACHDEP_ENDIANNESS ELFDATA2MSB #define ELF64_MACHDEP_ENDIANNESS ELFDATA2MSB #elif defined(__MIPSEL__) #define ELF32_MACHDEP_ENDIANNESS ELFDATA2LSB #define ELF64_MACHDEP_ENDIANNESS ELFDATA2LSB #elif !defined(HAVE_NBTOOL_CONFIG_H) #error neither __MIPSEL__ nor __MIPSEB__ are defined. #endif /* * Tell the kernel ELF exec code not to try relocating the interpreter * (ld.so) for dynamically-linked ELF binaries. */ #ifdef _KERNEL #define ELF_INTERP_NON_RELOCATABLE #endif #endif /* _MIPS_ELF_MACHDEP_H_ */ ================================================ FILE: sys/arch/pic32/include/frame.h ================================================ /* * Copyright (c) 2021 Christopher Hettrick * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #ifndef _MACHINE_FRAME_H_ #define _MACHINE_FRAME_H_ struct trapframe { u_int tf_r1; u_int tf_r2; u_int tf_r3; u_int tf_r4; u_int tf_r5; u_int tf_r6; u_int tf_r7; u_int tf_r8; u_int tf_r9; u_int tf_r10; u_int tf_r11; u_int tf_r12; u_int tf_r13; u_int tf_r14; u_int tf_r15; u_int tf_r16; u_int tf_r17; u_int tf_r18; u_int tf_r19; u_int tf_r20; u_int tf_r21; u_int tf_r22; u_int tf_r23; u_int tf_r24; u_int tf_r25; u_int tf_gp; u_int tf_sp; u_int tf_fp; u_int tf_ra; u_int tf_lo; u_int tf_hi; u_int tf_status; u_int tf_pc; }; #endif /* !_MACHINE_FRAME_H_ */ ================================================ FILE: sys/arch/pic32/include/io.h ================================================ /* * Hardware register defines for MIPS32 architecture. * * Copyright (C) 2008-2010 Serge Vakulenko, * * Permission to use, copy, modify, and distribute this software * and its documentation for any purpose and without fee is hereby * granted, provided that the above copyright notice appear in all * copies and that both that the copyright notice and this * permission notice and warranty disclaimer appear in supporting * documentation, and that the name of the author not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * * The author disclaim all warranties with regard to this * software, including all implied warranties of merchantability * and fitness. In no event shall the author be liable for any * special, indirect or consequential damages or any damages * whatsoever resulting from loss of use, data or profits, whether * in an action of contract, negligence or other tortious action, * arising out of or in connection with the use or performance of * this software. */ #ifdef PIC32MX4 # include "machine/pic32mx.h" #endif #ifdef PIC32MX7 # include "machine/pic32mx.h" #endif /* * Offsets of register values in saved context. */ #define FRAME_R1 0 #define FRAME_R2 1 #define FRAME_R3 2 #define FRAME_R4 3 #define FRAME_R5 4 #define FRAME_R6 5 #define FRAME_R7 6 #define FRAME_R8 7 #define FRAME_R9 8 #define FRAME_R10 9 #define FRAME_R11 10 #define FRAME_R12 11 #define FRAME_R13 12 #define FRAME_R14 13 #define FRAME_R15 14 #define FRAME_R16 15 #define FRAME_R17 16 #define FRAME_R18 17 #define FRAME_R19 18 #define FRAME_R20 19 #define FRAME_R21 20 #define FRAME_R22 21 #define FRAME_R23 22 #define FRAME_R24 23 #define FRAME_R25 24 #define FRAME_GP 25 #define FRAME_SP 26 #define FRAME_FP 27 #define FRAME_RA 28 #define FRAME_LO 29 #define FRAME_HI 30 #define FRAME_STATUS 31 #define FRAME_PC 32 #define FRAME_WORDS 33 #ifndef __ASSEMBLER__ #ifndef KERNEL /* * 2BSD system call extensions: use with care. */ /* * Read peripheral register. */ unsigned ufetch (unsigned addr); /* * Write peripheral register. */ unsigned ustore (unsigned addr, unsigned value); /* * Call a kernel function. */ unsigned ucall (int priority, void *address, int arg1, int arg2); #endif /* KERNEL */ /* * Set value of stack pointer register. */ static void inline __attribute__ ((always_inline)) mips_set_stack_pointer (void *x) { asm volatile ( "move $sp, %0" : : "r" (x) : "sp"); } /* * Get value of stack pointer register. */ static inline __attribute__ ((always_inline)) void *mips_get_stack_pointer () { void *x; asm volatile ( "move %0, $sp" : "=r" (x)); return x; } /* * Read C0 coprocessor register. */ #define mips_read_c0_register(reg,sel) \ ({ int __value; \ asm volatile ( \ "mfc0 %0, $%1, %2" \ : "=r" (__value) : "K" (reg), "K" (sel)); \ __value; \ }) /* * Write C0 coprocessor register. */ #define mips_write_c0_register(reg, sel, value) \ do { \ asm volatile ( \ "mtc0 %z0, $%1, %2 \n ehb" \ : : "r" ((unsigned int) (value)), "K" (reg), "K" (sel)); \ } while (0) /* * Disable the hardware interrupts, * saving the interrupt state into the supplied variable. */ static int inline __attribute__ ((always_inline)) mips_intr_disable () { int status; asm volatile ("di %0" : "=r" (status)); return status; } /* * Restore the hardware interrupt mode using the saved interrupt state. */ static void inline __attribute__ ((always_inline)) mips_intr_restore (int x) { /* C0_STATUS */ mips_write_c0_register (12, 0, x); } /* * Explicit hazard barrier. */ static void inline __attribute__ ((always_inline)) mips_ehb() { asm volatile ("ehb"); } /* * Enable hardware interrupts. */ static int inline __attribute__ ((always_inline)) mips_intr_enable () { int status; asm volatile ("ei %0" : "=r" (status)); return status; } /* * Count a number of leading (most significant) zero bits in a word. */ static int inline __attribute__ ((always_inline)) mips_clz (unsigned x) { int n; asm volatile ("clz %0, %1" : "=r" (n) : "r" (x)); return n; } /* * Swap bytes in a word: ABCD to DCBA. */ static unsigned inline __attribute__ ((always_inline)) mips_bswap (unsigned x) { int n; asm volatile ( "wsbh %0, %1 \n" "rotr %0, 16" : "=r" (n) : "r" (x)); return n; } #endif /* __ASSEMBLER__ */ ================================================ FILE: sys/arch/pic32/include/limits.h ================================================ /* * Copyright (c) 1988, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)limits.h 8.3.1 (2.11BSD) 1996/1/11 */ #define CHAR_BIT 8 /* number of bits in a char */ /* * According to ANSI (section 2.2.4.2), the values below must be usable by * #if preprocessing directives. Additionally, the expression must have the * same type as would an expression that is an object of the corresponding * type converted according to the integral promotions. The subtraction for * INT_MIN and LONG_MIN is so the value is not unsigned; 2147483648 is an * unsigned int for 32-bit two's complement ANSI compilers (section 3.1.3.2). * These numbers work for pcc as well. The UINT_MAX and ULONG_MAX values * are written as hex so that GCC will be quiet about large integer constants. */ #define SCHAR_MAX 127 /* min value for a signed char */ #define SCHAR_MIN (-128) /* max value for a signed char */ #define UCHAR_MAX 255 /* max value for an unsigned char */ #define CHAR_MAX 127 /* max value for a char */ #define CHAR_MIN (-128) /* min value for a char */ #define USHRT_MAX 65535 /* max value for an unsigned short */ #define SHRT_MAX 32767 /* max value for a short */ #define SHRT_MIN (-32768) /* min value for a short */ #define UINT_MAX 0xffffffff /* max value for an unsigned int */ #define INT_MAX 2147483647 /* max value for an int */ #define INT_MIN (-2147483647-1) /* min value for an int */ #define ULONG_MAX 0xffffffff /* max value for an unsigned long */ #define LONG_MAX 2147483647L /* max value for a long */ #define LONG_MIN (-2147483647L-1L) /* min value for a long */ #define SSIZE_MAX INT_MAX /* max value for a ssize_t */ #define SIZE_T_MAX UINT_MAX /* max value for a size_t */ ================================================ FILE: sys/arch/pic32/include/machparam.h ================================================ /* * Machine dependent constants for MIPS32. * * Copyright (c) 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * * @(#)machparam.h 1.4 (2.11BSD GTE) 1998/9/15 */ #ifndef ENDIAN #define MACHINE "pic32" #define MACHINE_ARCH "mips" /* * Definitions for byte order, * according to byte significance from low address to high. */ #define LITTLE 1234 /* least-significant byte first (vax) */ #define BIG 4321 /* most-significant byte first */ #define PDP 3412 /* LSB first in word, MSW first in long (pdp) */ #define ENDIAN LITTLE /* byte order on pic32 */ /* * The time for a process to be blocked before being very swappable. * This is a number of seconds which the system takes as being a non-trivial * amount of real time. You probably shouldn't change this; * it is used in subtle ways (fractions and multiples of it are, that is, like * half of a ``long time'', almost a long time, etc.) * It is related to human patience and other factors which don't really * change over time. */ #define MAXSLP 20 /* * Clock ticks per second. The HZ value must be an integer factor of 1000. */ #ifndef HZ #define HZ 200 #endif /* * System parameter formulae. */ #ifndef NBUF #define NBUF 10 /* number of i/o buffers */ #endif #ifndef MAXUSERS #define MAXUSERS 1 /* number of user logins */ #endif #ifndef NPROC #define NPROC 25 /* number of processes */ #endif #ifndef NINODE #define NINODE 24 #endif #ifndef NFILE #define NFILE 24 #endif #define NNAMECACHE (NINODE * 11/10) #define NCALL (16 + 2 * MAXUSERS) #define NCLIST 32 /* number or CBSIZE blocks */ #ifndef SMAPSIZ #define SMAPSIZ NPROC /* size of swap allocation map */ #endif /* * Disk blocks. */ #define DEV_BSIZE 1024 /* the same as MAXBSIZE */ #define DEV_BSHIFT 10 /* log2(DEV_BSIZE) */ #define DEV_BMASK (DEV_BSIZE-1) /* Bytes to disk blocks */ #define btod(x) (((x) + DEV_BSIZE-1) >> DEV_BSHIFT) /* * On PIC32, there are total 512 kbytes of flash and 128 kbytes of RAM. * We reserve for kernel 192 kbytes of flash and 32 kbytes of RAM. */ #define FLASH_SIZE (512*1024) #define DATA_SIZE (128*1024) #define KERNEL_FLASH_SIZE (192*1024) #ifdef KERNEL_EXECUTABLE_RAM extern void _keram_start(), _keram_end(); #define KERAM_SIZE ((unsigned)((char*)&_keram_end-(char*)&_keram_start)) #define KERNEL_DATA_SIZE (32*1024-KERAM_SIZE) #else #define KERNEL_DATA_SIZE (32*1024) #endif #define KERNEL_FLASH_START 0x9d000000 #define KERNEL_FLASH_END (KERNEL_FLASH_START + KERNEL_FLASH_SIZE) #define USER_FLASH_START (KERNEL_FLASH_END) #define USER_FLASH_END (KERNEL_FLASH_START + FLASH_SIZE) #define KERNEL_DATA_START 0x80000000 #define KERNEL_DATA_END (KERNEL_DATA_START + KERNEL_DATA_SIZE) #ifdef KERNEL_EXECUTABLE_RAM #define USER_DATA_START (0x7f000000 + KERNEL_DATA_SIZE+KERAM_SIZE) #else #define USER_DATA_START (0x7f000000 + KERNEL_DATA_SIZE) #endif #define USER_DATA_END (0x7f000000 + DATA_SIZE) #define stacktop(siz) (USER_DATA_END) #define stackbas(siz) (USER_DATA_END-(siz)) /* * User area: a user structure, followed by the kernel * stack. The number for USIZE is determined empirically. * * Note that the SBASE and STOP constants are only used by the assembly code, * but are defined here to localize information about the user area's * layout (see pdp/genassym.c). Note also that a networking stack is always * allocated even for non-networking systems. This prevents problems with * applications having to be recompiled for networking versus non-networking * systems. */ #define USIZE 3072 #define SSIZE 2048 /* initial stack size (bytes) */ /* * Collect kernel statistics by default. */ #if !defined(UCB_METER) && !defined(NO_UCB_METER) #define UCB_METER #endif #ifdef KERNEL #include "machine/io.h" /* * Macros to decode processor status word. */ #define USERMODE(ps) (((ps) & ST_UM) != 0) #define BASEPRI(ps) (CA_RIPL(ps) == 0) #define splbio() mips_intr_disable() #define spltty() mips_intr_disable() #define splclock() mips_intr_disable() #define splhigh() mips_intr_disable() #define splnet() mips_intr_enable() #define splsoftclock() mips_intr_enable() #define spl0() mips_intr_enable() #define splx(s) mips_intr_restore(s) #define noop() asm volatile("nop") /* * Wait for something to happen. */ void idle(void); /* * Microsecond delay routine. */ void udelay(unsigned usec); /* * Setup system timer for `hz' timer interrupts per second. */ void clkstart(void); /* * Control LEDs, installed on the board. */ #define LED_MISC4 0x80 #define LED_MISC3 0x40 #define LED_MISC2 0x20 #define LED_MISC1 0x10 #define LED_TTY 0x08 #define LED_SWAP 0x04 #define LED_DISK 0x02 #define LED_KERNEL 0x01 void led_control(int mask, int on); /* * Port i/o access, relative to TRIS base. */ #define TRIS_VAL(p) (&p)[0] #define TRIS_CLR(p) (&p)[1] #define TRIS_SET(p) (&p)[2] #define TRIS_INV(p) (&p)[3] #define PORT_VAL(p) (&p)[4] #define PORT_CLR(p) (&p)[5] #define PORT_SET(p) (&p)[6] #define PORT_INV(p) (&p)[7] #define LAT_VAL(p) (&p)[8] #define LAT_CLR(p) (&p)[9] #define LAT_SET(p) (&p)[10] #define LAT_INV(p) (&p)[11] /* * SD timeouts, for sysctl. */ extern int sd_timo_cmd; extern int sd_timo_send_op; extern int sd_timo_send_csd; extern int sd_timo_read; extern int sd_timo_wait_cmd; extern int sd_timo_wait_wdata; extern int sd_timo_wait_wdone; extern int sd_timo_wait_wstop; extern int sd_timo_wait_widle; /* * GPIO pins. */ void gpio_set_input(int pin); void gpio_set_output(int pin); void gpio_set(int pin); void gpio_clr(int pin); int gpio_get(int pin); char gpio_portname(int pin); int gpio_pinno(int pin); /* Convert port name/signal into a pin number. */ #define GPIO_PIN(x,n) (((x)-'A'+1) << 4 | (n)) /* * CPU package type: 64 pins or 100 pins. */ extern int cpu_pins; #endif /* KERNEL */ #endif /* ENDIAN */ ================================================ FILE: sys/arch/pic32/include/pic32mx.h ================================================ /* * Hardware register defines for all Microchip PIC32MX microcontrollers. * * Copyright (C) 2010 Serge Vakulenko, * * Permission to use, copy, modify, and distribute this software * and its documentation for any purpose and without fee is hereby * granted, provided that the above copyright notice appear in all * copies and that both that the copyright notice and this * permission notice and warranty disclaimer appear in supporting * documentation, and that the name of the author not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * * The author disclaim all warranties with regard to this * software, including all implied warranties of merchantability * and fitness. In no event shall the author be liable for any * special, indirect or consequential damages or any damages * whatsoever resulting from loss of use, data or profits, whether * in an action of contract, negligence or other tortious action, * arising out of or in connection with the use or performance of * this software. */ #ifndef _IO_PIC32MX_H #define _IO_PIC32MX_H /*-------------------------------------- * Coprocessor 0 registers. */ #define C0_HWRENA 7 /* Enable RDHWR in non-privileged mode */ #define C0_BADVADDR 8 /* Virtual address of last exception */ #define C0_COUNT 9 /* Processor cycle count */ #define C0_COMPARE 11 /* Timer interrupt control */ #define C0_STATUS 12 /* Processor status and control */ #define C0_INTCTL 12 /* Select 1: interrupt control */ #define C0_SRSCTL 12 /* Select 2: GPR shadow set control */ #define C0_SRSMAP 12 /* Select 3: vector to shadow set mapping */ #define C0_CAUSE 13 /* Cause of last exception */ #define C0_EPC 14 /* Program counter at last exception */ #define C0_PRID 15 /* Processor identification (read only) */ #define C0_EBASE 15 /* Select 1: exception base address */ #define C0_CONFIG 16 /* Configuration */ #define C0_CONFIG1 16 /* Select 1: configuration 1 */ #define C0_CONFIG2 16 /* Select 2: configuration 2 */ #define C0_CONFIG3 16 /* Select 3: configuration 3 */ #define C0_DEBUG 23 /* Debug control and status */ #define C0_DEPC 24 /* Program counter at last debug exception */ #define C0_ERROREPC 30 /* Program counter at last error */ #define C0_DESAVE 31 /* Debug handler scratchpad register */ /* * Status register. */ #define ST_CU0 0x10000000 /* Access to coprocessor 0 allowed (in user mode) */ #define ST_RP 0x08000000 /* Enable reduced power mode */ #define ST_RE 0x02000000 /* Reverse endianness (in user mode) */ #define ST_BEV 0x00400000 /* Exception vectors: bootstrap */ #define ST_SR 0x00100000 /* Soft reset */ #define ST_NMI 0x00080000 /* NMI reset */ #define ST_IPL(x) ((x) << 10) /* Current interrupt priority level */ #define ST_UM 0x00000010 /* User mode */ #define ST_ERL 0x00000004 /* Error level */ #define ST_EXL 0x00000002 /* Exception level */ #define ST_IE 0x00000001 /* Interrupt enable */ /* * Cause register. */ #define CA_BD 0x80000000 /* Exception occured in delay slot */ #define CA_TI 0x40000000 /* Timer interrupt is pending */ #define CA_CE 0x30000000 /* Coprocessor exception */ #define CA_DC 0x08000000 /* Disable COUNT register */ #define CA_IV 0x00800000 /* Use special interrupt vector 0x200 */ #define CA_RIPL(r) ((r)>>10 & 63) /* Requested interrupt priority level */ #define CA_IP1 0x00020000 /* Request software interrupt 1 */ #define CA_IP0 0x00010000 /* Request software interrupt 0 */ #define CA_EXC_CODE 0x0000007c /* Exception code */ #define CA_Int 0 /* Interrupt */ #define CA_AdEL (4 << 2) /* Address error, load or instruction fetch */ #define CA_AdES (5 << 2) /* Address error, store */ #define CA_IBE (6 << 2) /* Bus error, instruction fetch */ #define CA_DBE (7 << 2) /* Bus error, load or store */ #define CA_Sys (8 << 2) /* Syscall */ #define CA_Bp (9 << 2) /* Breakpoint */ #define CA_RI (10 << 2) /* Reserved instruction */ #define CA_CPU (11 << 2) /* Coprocessor unusable */ #define CA_Ov (12 << 2) /* Arithmetic overflow */ #define CA_Tr (13 << 2) /* Trap */ #define DB_DBD (1 << 31) /* Debug exception in a branch delay slot */ #define DB_DM (1 << 30) /* Debug mode */ #define DB_NODCR (1 << 29) /* No dseg present */ #define DB_LSNM (1 << 28) /* Load/stores in dseg go to main memory */ #define DB_DOZE (1 << 27) /* Processor was in low-power mode */ #define DB_HALT (1 << 26) /* Internal system bus clock was running */ #define DB_COUNTDM (1 << 25) /* Count register is running in Debug mode */ #define DB_IBUSEP (1 << 24) /* Instruction fetch bus error exception */ #define DB_DBUSEP (1 << 21) /* Data access bus error exception */ #define DB_IEXI (1 << 20) /* Imprecise error exception */ #define DB_VER (7 << 15) /* EJTAG version number */ #define DB_DEXCCODE (0x1f << 10) /* Cause of exception in Debug mode */ #define DB_SST (1 << 8) /* Single step exception enabled */ #define DB_DIBImpr (1 << 6) /* Imprecise debug instruction break */ #define DB_DINT (1 << 5) /* Debug interrupt exception */ #define DB_DIB (1 << 4) /* Debug instruction break exception */ #define DB_DDBS (1 << 3) /* Debug data break exception on store */ #define DB_DDBL (1 << 2) /* Debug data break exception on load */ #define DB_DBP (1 << 1) /* Debug software breakpoint exception */ #define DB_DSS (1 << 0) /* Debug single-step exception */ /*-------------------------------------- * Peripheral registers. */ #ifdef __ASSEMBLER__ #define PIC32_R(a) (0xBF800000 + (a)) #else #define PIC32_R(a) *(volatile unsigned*)(0xBF800000 + (a)) #endif /*-------------------------------------- * UART registers. */ #define U1MODE PIC32_R (0x6000) /* Mode */ #define U1MODECLR PIC32_R (0x6004) #define U1MODESET PIC32_R (0x6008) #define U1MODEINV PIC32_R (0x600C) #define U1STA PIC32_R (0x6010) /* Status and control */ #define U1STACLR PIC32_R (0x6014) #define U1STASET PIC32_R (0x6018) #define U1STAINV PIC32_R (0x601C) #define U1TXREG PIC32_R (0x6020) /* Transmit */ #define U1RXREG PIC32_R (0x6030) /* Receive */ #define U1BRG PIC32_R (0x6040) /* Baud rate */ #define U1BRGCLR PIC32_R (0x6044) #define U1BRGSET PIC32_R (0x6048) #define U1BRGINV PIC32_R (0x604C) #ifdef PIC32MX4 #define U2MODE PIC32_R (0x6200) /* Mode */ #define U2MODECLR PIC32_R (0x6204) #define U2MODESET PIC32_R (0x6208) #define U2MODEINV PIC32_R (0x620C) #define U2STA PIC32_R (0x6210) /* Status and control */ #define U2STACLR PIC32_R (0x6214) #define U2STASET PIC32_R (0x6218) #define U2STAINV PIC32_R (0x621C) #define U2TXREG PIC32_R (0x6220) /* Transmit */ #define U2RXREG PIC32_R (0x6230) /* Receive */ #define U2BRG PIC32_R (0x6240) /* Baud rate */ #define U2BRGCLR PIC32_R (0x6244) #define U2BRGSET PIC32_R (0x6248) #define U2BRGINV PIC32_R (0x624C) #endif #ifdef PIC32MX7 #define U4MODE PIC32_R (0x6200) /* Mode */ #define U4MODECLR PIC32_R (0x6204) #define U4MODESET PIC32_R (0x6208) #define U4MODEINV PIC32_R (0x620C) #define U4STA PIC32_R (0x6210) /* Status and control */ #define U4STACLR PIC32_R (0x6214) #define U4STASET PIC32_R (0x6218) #define U4STAINV PIC32_R (0x621C) #define U4TXREG PIC32_R (0x6220) /* Transmit */ #define U4RXREG PIC32_R (0x6230) /* Receive */ #define U4BRG PIC32_R (0x6240) /* Baud rate */ #define U4BRGCLR PIC32_R (0x6244) #define U4BRGSET PIC32_R (0x6248) #define U4BRGINV PIC32_R (0x624C) #define U3MODE PIC32_R (0x6400) /* Mode */ #define U3MODECLR PIC32_R (0x6404) #define U3MODESET PIC32_R (0x6408) #define U3MODEINV PIC32_R (0x640C) #define U3STA PIC32_R (0x6410) /* Status and control */ #define U3STACLR PIC32_R (0x6414) #define U3STASET PIC32_R (0x6418) #define U3STAINV PIC32_R (0x641C) #define U3TXREG PIC32_R (0x6420) /* Transmit */ #define U3RXREG PIC32_R (0x6430) /* Receive */ #define U3BRG PIC32_R (0x6440) /* Baud rate */ #define U3BRGCLR PIC32_R (0x6444) #define U3BRGSET PIC32_R (0x6448) #define U3BRGINV PIC32_R (0x644C) #define U6MODE PIC32_R (0x6600) /* Mode */ #define U6MODECLR PIC32_R (0x6604) #define U6MODESET PIC32_R (0x6608) #define U6MODEINV PIC32_R (0x660C) #define U6STA PIC32_R (0x6610) /* Status and control */ #define U6STACLR PIC32_R (0x6614) #define U6STASET PIC32_R (0x6618) #define U6STAINV PIC32_R (0x661C) #define U6TXREG PIC32_R (0x6620) /* Transmit */ #define U6RXREG PIC32_R (0x6630) /* Receive */ #define U6BRG PIC32_R (0x6640) /* Baud rate */ #define U6BRGCLR PIC32_R (0x6644) #define U6BRGSET PIC32_R (0x6648) #define U6BRGINV PIC32_R (0x664C) #define U2MODE PIC32_R (0x6800) /* Mode */ #define U2MODECLR PIC32_R (0x6804) #define U2MODESET PIC32_R (0x6808) #define U2MODEINV PIC32_R (0x680C) #define U2STA PIC32_R (0x6810) /* Status and control */ #define U2STACLR PIC32_R (0x6814) #define U2STASET PIC32_R (0x6818) #define U2STAINV PIC32_R (0x681C) #define U2TXREG PIC32_R (0x6820) /* Transmit */ #define U2RXREG PIC32_R (0x6830) /* Receive */ #define U2BRG PIC32_R (0x6840) /* Baud rate */ #define U2BRGCLR PIC32_R (0x6844) #define U2BRGSET PIC32_R (0x6848) #define U2BRGINV PIC32_R (0x684C) #define U5MODE PIC32_R (0x6A00) /* Mode */ #define U5MODECLR PIC32_R (0x6A04) #define U5MODESET PIC32_R (0x6A08) #define U5MODEINV PIC32_R (0x6A0C) #define U5STA PIC32_R (0x6A10) /* Status and control */ #define U5STACLR PIC32_R (0x6A14) #define U5STASET PIC32_R (0x6A18) #define U5STAINV PIC32_R (0x6A1C) #define U5TXREG PIC32_R (0x6A20) /* Transmit */ #define U5RXREG PIC32_R (0x6A30) /* Receive */ #define U5BRG PIC32_R (0x6A40) /* Baud rate */ #define U5BRGCLR PIC32_R (0x6A44) #define U5BRGSET PIC32_R (0x6A48) #define U5BRGINV PIC32_R (0x6A4C) #endif /* * UART Mode register. */ #define PIC32_UMODE_STSEL 0x0001 /* 2 Stop bits */ #define PIC32_UMODE_PDSEL 0x0006 /* Bitmask: */ #define PIC32_UMODE_PDSEL_8NPAR 0x0000 /* 8-bit data, no parity */ #define PIC32_UMODE_PDSEL_8EVEN 0x0002 /* 8-bit data, even parity */ #define PIC32_UMODE_PDSEL_8ODD 0x0004 /* 8-bit data, odd parity */ #define PIC32_UMODE_PDSEL_9NPAR 0x0006 /* 9-bit data, no parity */ #define PIC32_UMODE_BRGH 0x0008 /* High Baud Rate Enable */ #define PIC32_UMODE_RXINV 0x0010 /* Receive Polarity Inversion */ #define PIC32_UMODE_ABAUD 0x0020 /* Auto-Baud Enable */ #define PIC32_UMODE_LPBACK 0x0040 /* UARTx Loopback Mode */ #define PIC32_UMODE_WAKE 0x0080 /* Wake-up on start bit during Sleep Mode */ #define PIC32_UMODE_UEN 0x0300 /* Bitmask: */ #define PIC32_UMODE_UEN_RTS 0x0100 /* Using UxRTS pin */ #define PIC32_UMODE_UEN_RTSCTS 0x0200 /* Using UxCTS and UxRTS pins */ #define PIC32_UMODE_UEN_BCLK 0x0300 /* Using UxBCLK pin */ #define PIC32_UMODE_RTSMD 0x0800 /* UxRTS Pin Simplex mode */ #define PIC32_UMODE_IREN 0x1000 /* IrDA Encoder and Decoder Enable bit */ #define PIC32_UMODE_SIDL 0x2000 /* Stop in Idle Mode */ #define PIC32_UMODE_FRZ 0x4000 /* Freeze in Debug Exception Mode */ #define PIC32_UMODE_ON 0x8000 /* UART Enable */ /* * UART Control and status register. */ #define PIC32_USTA_URXDA 0x00000001 /* Receive Data Available (read-only) */ #define PIC32_USTA_OERR 0x00000002 /* Receive Buffer Overrun */ #define PIC32_USTA_FERR 0x00000004 /* Framing error detected (read-only) */ #define PIC32_USTA_PERR 0x00000008 /* Parity error detected (read-only) */ #define PIC32_USTA_RIDLE 0x00000010 /* Receiver is idle (read-only) */ #define PIC32_USTA_ADDEN 0x00000020 /* Address Detect mode */ #define PIC32_USTA_URXISEL 0x000000C0 /* Bitmask: receive interrupt is set when... */ #define PIC32_USTA_URXISEL_NEMP 0x00000000 /* ...receive buffer is not empty */ #define PIC32_USTA_URXISEL_HALF 0x00000040 /* ...receive buffer becomes 1/2 full */ #define PIC32_USTA_URXISEL_3_4 0x00000080 /* ...receive buffer becomes 3/4 full */ #define PIC32_USTA_TRMT 0x00000100 /* Transmit shift register is empty (read-only) */ #define PIC32_USTA_UTXBF 0x00000200 /* Transmit buffer is full (read-only) */ #define PIC32_USTA_UTXEN 0x00000400 /* Transmit Enable */ #define PIC32_USTA_UTXBRK 0x00000800 /* Transmit Break */ #define PIC32_USTA_URXEN 0x00001000 /* Receiver Enable */ #define PIC32_USTA_UTXINV 0x00002000 /* Transmit Polarity Inversion */ #define PIC32_USTA_UTXISEL 0x0000C000 /* Bitmask: TX interrupt is generated when... */ #define PIC32_USTA_UTXISEL_1 0x00000000 /* ...the transmit buffer contains at least one empty space */ #define PIC32_USTA_UTXISEL_ALL 0x00004000 /* ...all characters have been transmitted */ #define PIC32_USTA_UTXISEL_EMP 0x00008000 /* ...the transmit buffer becomes empty */ #define PIC32_USTA_ADDR 0x00FF0000 /* Automatic Address Mask */ #define PIC32_USTA_ADM_EN 0x01000000 /* Automatic Address Detect */ /* * Compute the 16-bit baud rate divisor, given * the bus frequency and baud rate. * Round to the nearest integer. */ #define PIC32_BRG_BAUD(fr,bd) ((((fr)/8 + (bd)) / (bd) / 2) - 1) /*-------------------------------------- * Port A-G registers. */ #define TRISA PIC32_R (0x86000) /* Port A: mask of inputs */ #define TRISACLR PIC32_R (0x86004) #define TRISASET PIC32_R (0x86008) #define TRISAINV PIC32_R (0x8600C) #define PORTA PIC32_R (0x86010) /* Port A: read inputs, write outputs */ #define PORTACLR PIC32_R (0x86014) #define PORTASET PIC32_R (0x86018) #define PORTAINV PIC32_R (0x8601C) #define LATA PIC32_R (0x86020) /* Port A: read/write outputs */ #define LATACLR PIC32_R (0x86024) #define LATASET PIC32_R (0x86028) #define LATAINV PIC32_R (0x8602C) #define ODCA PIC32_R (0x86030) /* Port A: open drain configuration */ #define ODCACLR PIC32_R (0x86034) #define ODCASET PIC32_R (0x86038) #define ODCAINV PIC32_R (0x8603C) #define TRISB PIC32_R (0x86040) /* Port B: mask of inputs */ #define TRISBCLR PIC32_R (0x86044) #define TRISBSET PIC32_R (0x86048) #define TRISBINV PIC32_R (0x8604C) #define PORTB PIC32_R (0x86050) /* Port B: read inputs, write outputs */ #define PORTBCLR PIC32_R (0x86054) #define PORTBSET PIC32_R (0x86058) #define PORTBINV PIC32_R (0x8605C) #define LATB PIC32_R (0x86060) /* Port B: read/write outputs */ #define LATBCLR PIC32_R (0x86064) #define LATBSET PIC32_R (0x86068) #define LATBINV PIC32_R (0x8606C) #define ODCB PIC32_R (0x86070) /* Port B: open drain configuration */ #define ODCBCLR PIC32_R (0x86074) #define ODCBSET PIC32_R (0x86078) #define ODCBINV PIC32_R (0x8607C) #define TRISC PIC32_R (0x86080) /* Port C: mask of inputs */ #define TRISCCLR PIC32_R (0x86084) #define TRISCSET PIC32_R (0x86088) #define TRISCINV PIC32_R (0x8608C) #define PORTC PIC32_R (0x86090) /* Port C: read inputs, write outputs */ #define PORTCCLR PIC32_R (0x86094) #define PORTCSET PIC32_R (0x86098) #define PORTCINV PIC32_R (0x8609C) #define LATC PIC32_R (0x860A0) /* Port C: read/write outputs */ #define LATCCLR PIC32_R (0x860A4) #define LATCSET PIC32_R (0x860A8) #define LATCINV PIC32_R (0x860AC) #define ODCC PIC32_R (0x860B0) /* Port C: open drain configuration */ #define ODCCCLR PIC32_R (0x860B4) #define ODCCSET PIC32_R (0x860B8) #define ODCCINV PIC32_R (0x860BC) #define TRISD PIC32_R (0x860C0) /* Port D: mask of inputs */ #define TRISDCLR PIC32_R (0x860C4) #define TRISDSET PIC32_R (0x860C8) #define TRISDINV PIC32_R (0x860CC) #define PORTD PIC32_R (0x860D0) /* Port D: read inputs, write outputs */ #define PORTDCLR PIC32_R (0x860D4) #define PORTDSET PIC32_R (0x860D8) #define PORTDINV PIC32_R (0x860DC) #define LATD PIC32_R (0x860E0) /* Port D: read/write outputs */ #define LATDCLR PIC32_R (0x860E4) #define LATDSET PIC32_R (0x860E8) #define LATDINV PIC32_R (0x860EC) #define ODCD PIC32_R (0x860F0) /* Port D: open drain configuration */ #define ODCDCLR PIC32_R (0x860F4) #define ODCDSET PIC32_R (0x860F8) #define ODCDINV PIC32_R (0x860FC) #define TRISE PIC32_R (0x86100) /* Port E: mask of inputs */ #define TRISECLR PIC32_R (0x86104) #define TRISESET PIC32_R (0x86108) #define TRISEINV PIC32_R (0x8610C) #define PORTE PIC32_R (0x86110) /* Port E: read inputs, write outputs */ #define PORTECLR PIC32_R (0x86114) #define PORTESET PIC32_R (0x86118) #define PORTEINV PIC32_R (0x8611C) #define LATE PIC32_R (0x86120) /* Port E: read/write outputs */ #define LATECLR PIC32_R (0x86124) #define LATESET PIC32_R (0x86128) #define LATEINV PIC32_R (0x8612C) #define ODCE PIC32_R (0x86130) /* Port E: open drain configuration */ #define ODCECLR PIC32_R (0x86134) #define ODCESET PIC32_R (0x86138) #define ODCEINV PIC32_R (0x8613C) #define TRISF PIC32_R (0x86140) /* Port F: mask of inputs */ #define TRISFCLR PIC32_R (0x86144) #define TRISFSET PIC32_R (0x86148) #define TRISFINV PIC32_R (0x8614C) #define PORTF PIC32_R (0x86150) /* Port F: read inputs, write outputs */ #define PORTFCLR PIC32_R (0x86154) #define PORTFSET PIC32_R (0x86158) #define PORTFINV PIC32_R (0x8615C) #define LATF PIC32_R (0x86160) /* Port F: read/write outputs */ #define LATFCLR PIC32_R (0x86164) #define LATFSET PIC32_R (0x86168) #define LATFINV PIC32_R (0x8616C) #define ODCF PIC32_R (0x86170) /* Port F: open drain configuration */ #define ODCFCLR PIC32_R (0x86174) #define ODCFSET PIC32_R (0x86178) #define ODCFINV PIC32_R (0x8617C) #define TRISG PIC32_R (0x86180) /* Port G: mask of inputs */ #define TRISGCLR PIC32_R (0x86184) #define TRISGSET PIC32_R (0x86188) #define TRISGINV PIC32_R (0x8618C) #define PORTG PIC32_R (0x86190) /* Port G: read inputs, write outputs */ #define PORTGCLR PIC32_R (0x86194) #define PORTGSET PIC32_R (0x86198) #define PORTGINV PIC32_R (0x8619C) #define LATG PIC32_R (0x861A0) /* Port G: read/write outputs */ #define LATGCLR PIC32_R (0x861A4) #define LATGSET PIC32_R (0x861A8) #define LATGINV PIC32_R (0x861AC) #define ODCG PIC32_R (0x861B0) /* Port G: open drain configuration */ #define ODCGCLR PIC32_R (0x861B4) #define ODCGSET PIC32_R (0x861B8) #define ODCGINV PIC32_R (0x861BC) #ifndef __ASSEMBLER__ /* * PIC32 port i/o registers. */ struct gpioreg { volatile unsigned tris; /* Mask of inputs */ volatile unsigned trisclr; volatile unsigned trisset; volatile unsigned trisinv; volatile unsigned port; /* Read inputs, write outputs */ volatile unsigned portclr; volatile unsigned portset; volatile unsigned portinv; volatile unsigned lat; /* Read/write outputs */ volatile unsigned latclr; volatile unsigned latset; volatile unsigned latinv; volatile unsigned odc; /* Open drain configuration */ volatile unsigned odcclr; volatile unsigned odcset; volatile unsigned odcinv; }; #endif #define CNCON PIC32_R (0x861C0) /* Interrupt-on-change control */ #define CNCONCLR PIC32_R (0x861C4) #define CNCONSET PIC32_R (0x861C8) #define CNCONINV PIC32_R (0x861CC) #define CNEN PIC32_R (0x861D0) /* Input change interrupt enable */ #define CNENCLR PIC32_R (0x861D4) #define CNENSET PIC32_R (0x861D8) #define CNENINV PIC32_R (0x861DC) #define CNPUE PIC32_R (0x861E0) /* Input pin pull-up enable */ #define CNPUECLR PIC32_R (0x861E4) #define CNPUESET PIC32_R (0x861E8) #define CNPUEINV PIC32_R (0x861EC) /*-------------------------------------- * A/D Converter registers. */ #define AD1CON1 PIC32_R (0x9000) /* Control register 1 */ #define AD1CON1CLR PIC32_R (0x9004) #define AD1CON1SET PIC32_R (0x9008) #define AD1CON1INV PIC32_R (0x900C) #define AD1CON2 PIC32_R (0x9010) /* Control register 2 */ #define AD1CON2CLR PIC32_R (0x9014) #define AD1CON2SET PIC32_R (0x9018) #define AD1CON2INV PIC32_R (0x901C) #define AD1CON3 PIC32_R (0x9020) /* Control register 3 */ #define AD1CON3CLR PIC32_R (0x9024) #define AD1CON3SET PIC32_R (0x9028) #define AD1CON3INV PIC32_R (0x902C) #define AD1CHS PIC32_R (0x9040) /* Channel select */ #define AD1CHSCLR PIC32_R (0x9044) #define AD1CHSSET PIC32_R (0x9048) #define AD1CHSINV PIC32_R (0x904C) #define AD1CSSL PIC32_R (0x9050) /* Input scan selection */ #define AD1CSSLCLR PIC32_R (0x9054) #define AD1CSSLSET PIC32_R (0x9058) #define AD1CSSLINV PIC32_R (0x905C) #define AD1PCFG PIC32_R (0x9060) /* Port configuration */ #define AD1PCFGCLR PIC32_R (0x9064) #define AD1PCFGSET PIC32_R (0x9068) #define AD1PCFGINV PIC32_R (0x906C) #define ADC1BUF0 PIC32_R (0x9070) /* Result words */ #define ADC1BUF1 PIC32_R (0x9080) #define ADC1BUF2 PIC32_R (0x9090) #define ADC1BUF3 PIC32_R (0x90A0) #define ADC1BUF4 PIC32_R (0x90B0) #define ADC1BUF5 PIC32_R (0x90C0) #define ADC1BUF6 PIC32_R (0x90D0) #define ADC1BUF7 PIC32_R (0x90E0) #define ADC1BUF8 PIC32_R (0x90F0) #define ADC1BUF9 PIC32_R (0x9100) #define ADC1BUFA PIC32_R (0x9110) #define ADC1BUFB PIC32_R (0x9120) #define ADC1BUFC PIC32_R (0x9130) #define ADC1BUFD PIC32_R (0x9140) #define ADC1BUFE PIC32_R (0x9150) #define ADC1BUFF PIC32_R (0x9160) /*-------------------------------------- * Parallel master port registers. */ #define PMCON PIC32_R (0x7000) /* Control */ #define PMCONCLR PIC32_R (0x7004) #define PMCONSET PIC32_R (0x7008) #define PMCONINV PIC32_R (0x700C) #define PMMODE PIC32_R (0x7010) /* Mode */ #define PMMODECLR PIC32_R (0x7014) #define PMMODESET PIC32_R (0x7018) #define PMMODEINV PIC32_R (0x701C) #define PMADDR PIC32_R (0x7020) /* Address */ #define PMADDRCLR PIC32_R (0x7024) #define PMADDRSET PIC32_R (0x7028) #define PMADDRINV PIC32_R (0x702C) #define PMDOUT PIC32_R (0x7030) /* Data output */ #define PMDOUTCLR PIC32_R (0x7034) #define PMDOUTSET PIC32_R (0x7038) #define PMDOUTINV PIC32_R (0x703C) #define PMDIN PIC32_R (0x7040) /* Data input */ #define PMDINCLR PIC32_R (0x7044) #define PMDINSET PIC32_R (0x7048) #define PMDININV PIC32_R (0x704C) #define PMAEN PIC32_R (0x7050) /* Pin enable */ #define PMAENCLR PIC32_R (0x7054) #define PMAENSET PIC32_R (0x7058) #define PMAENINV PIC32_R (0x705C) #define PMSTAT PIC32_R (0x7060) /* Status (slave only) */ #define PMSTATCLR PIC32_R (0x7064) #define PMSTATSET PIC32_R (0x7068) #define PMSTATINV PIC32_R (0x706C) /* * PMP Control register. */ #define PIC32_PMCON_RDSP 0x0001 /* Read strobe polarity active-high */ #define PIC32_PMCON_WRSP 0x0002 /* Write strobe polarity active-high */ #define PIC32_PMCON_CS1P 0x0008 /* Chip select 0 polarity active-high */ #define PIC32_PMCON_CS2P 0x0010 /* Chip select 1 polarity active-high */ #define PIC32_PMCON_ALP 0x0020 /* Address latch polarity active-high */ #define PIC32_PMCON_CSF 0x00C0 /* Chip select function bitmask: */ #define PIC32_PMCON_CSF_NONE 0x0000 /* PMCS2 and PMCS1 as A[15:14] */ #define PIC32_PMCON_CSF_CS2 0x0040 /* PMCS2 as chip select */ #define PIC32_PMCON_CSF_CS21 0x0080 /* PMCS2 and PMCS1 as chip select */ #define PIC32_PMCON_PTRDEN 0x0100 /* Read/write strobe port enable */ #define PIC32_PMCON_PTWREN 0x0200 /* Write enable strobe port enable */ #define PIC32_PMCON_PMPTTL 0x0400 /* TTL input buffer select */ #define PIC32_PMCON_ADRMUX 0x1800 /* Address/data mux selection bitmask: */ #define PIC32_PMCON_ADRMUX_NONE 0x0000 /* Address and data separate */ #define PIC32_PMCON_ADRMUX_AD 0x0800 /* Lower address on PMD[7:0], high on PMA[15:8] */ #define PIC32_PMCON_ADRMUX_D8 0x1000 /* All address on PMD[7:0] */ #define PIC32_PMCON_ADRMUX_D16 0x1800 /* All address on PMD[15:0] */ #define PIC32_PMCON_SIDL 0x2000 /* Stop in idle */ #define PIC32_PMCON_FRZ 0x4000 /* Freeze in debug exception */ #define PIC32_PMCON_ON 0x8000 /* Parallel master port enable */ /* * PMP Mode register. */ #define PIC32_PMMODE_WAITE(x) ((x)<<0) /* Wait states: data hold after RW strobe */ #define PIC32_PMMODE_WAITM(x) ((x)<<2) /* Wait states: data RW strobe */ #define PIC32_PMMODE_WAITB(x) ((x)<<6) /* Wait states: data setup to RW strobe */ #define PIC32_PMMODE_MODE 0x0300 /* Mode select bitmask: */ #define PIC32_PMMODE_MODE_SLAVE 0x0000 /* Legacy slave */ #define PIC32_PMMODE_MODE_SLENH 0x0100 /* Enhanced slave */ #define PIC32_PMMODE_MODE_MAST2 0x0200 /* Master mode 2 */ #define PIC32_PMMODE_MODE_MAST1 0x0300 /* Master mode 1 */ #define PIC32_PMMODE_MODE16 0x0400 /* 16-bit mode */ #define PIC32_PMMODE_INCM 0x1800 /* Address increment mode bitmask: */ #define PIC32_PMMODE_INCM_NONE 0x0000 /* No increment/decrement */ #define PIC32_PMMODE_INCM_INC 0x0800 /* Increment address */ #define PIC32_PMMODE_INCM_DEC 0x1000 /* Decrement address */ #define PIC32_PMMODE_INCM_SLAVE 0x1800 /* Slave auto-increment */ #define PIC32_PMMODE_IRQM 0x6000 /* Interrupt request bitmask: */ #define PIC32_PMMODE_IRQM_DIS 0x0000 /* No interrupt generated */ #define PIC32_PMMODE_IRQM_END 0x2000 /* Interrupt at end of read/write cycle */ #define PIC32_PMMODE_IRQM_A3 0x4000 /* Interrupt on address 3 */ #define PIC32_PMMODE_BUSY 0x8000 /* Port is busy */ /* * PMP Address register. */ #define PIC32_PMADDR_PADDR 0x3FFF /* Destination address */ #define PIC32_PMADDR_CS1 0x4000 /* Chip select 1 is active */ #define PIC32_PMADDR_CS2 0x8000 /* Chip select 2 is active */ /* * PMP status register (slave only). */ #define PIC32_PMSTAT_OB0E 0x0001 /* Output buffer 0 empty */ #define PIC32_PMSTAT_OB1E 0x0002 /* Output buffer 1 empty */ #define PIC32_PMSTAT_OB2E 0x0004 /* Output buffer 2 empty */ #define PIC32_PMSTAT_OB3E 0x0008 /* Output buffer 3 empty */ #define PIC32_PMSTAT_OBUF 0x0040 /* Output buffer underflow */ #define PIC32_PMSTAT_OBE 0x0080 /* Output buffer empty */ #define PIC32_PMSTAT_IB0F 0x0100 /* Input buffer 0 full */ #define PIC32_PMSTAT_IB1F 0x0200 /* Input buffer 1 full */ #define PIC32_PMSTAT_IB2F 0x0400 /* Input buffer 2 full */ #define PIC32_PMSTAT_IB3F 0x0800 /* Input buffer 3 full */ #define PIC32_PMSTAT_IBOV 0x4000 /* Input buffer overflow */ #define PIC32_PMSTAT_IBF 0x8000 /* Input buffer full */ /*-------------------------------------- * USB registers. */ #define U1OTGIR PIC32_R (0x85040) /* OTG interrupt flags */ #define U1OTGIE PIC32_R (0x85050) /* OTG interrupt enable */ #define U1OTGSTAT PIC32_R (0x85060) /* Comparator and pin status */ #define U1OTGCON PIC32_R (0x85070) /* Resistor and pin control */ #define U1PWRC PIC32_R (0x85080) /* Power control */ #define U1IR PIC32_R (0x85200) /* Pending interrupt */ #define U1IE PIC32_R (0x85210) /* Interrupt enable */ #define U1EIR PIC32_R (0x85220) /* Pending error interrupt */ #define U1EIE PIC32_R (0x85230) /* Error interrupt enable */ #define U1STAT PIC32_R (0x85240) /* Status FIFO */ #define U1CON PIC32_R (0x85250) /* Control */ #define U1ADDR PIC32_R (0x85260) /* Address */ #define U1BDTP1 PIC32_R (0x85270) /* Buffer descriptor table pointer 1 */ #define U1FRML PIC32_R (0x85280) /* Frame counter low */ #define U1FRMH PIC32_R (0x85290) /* Frame counter high */ #define U1TOK PIC32_R (0x852A0) /* Host control */ #define U1SOF PIC32_R (0x852B0) /* SOF counter */ #define U1BDTP2 PIC32_R (0x852C0) /* Buffer descriptor table pointer 2 */ #define U1BDTP3 PIC32_R (0x852D0) /* Buffer descriptor table pointer 3 */ #define U1CNFG1 PIC32_R (0x852E0) /* Debug and idle */ #define U1EP(n) PIC32_R (0x85300 + (n << 4)) /* Endpoint control */ /* * USB Control register. */ #define PIC32_U1CON_USBEN 0x0001 /* USB module enable (device mode) */ #define PIC32_U1CON_SOFEN 0x0001 /* SOF sent every 1 ms (host mode) */ #define PIC32_U1CON_PPBRST 0x0002 /* Ping-pong buffers reset */ #define PIC32_U1CON_RESUME 0x0004 /* Resume signaling enable */ #define PIC32_U1CON_HOSTEN 0x0008 /* Host mode enable */ #define PIC32_U1CON_USBRST 0x0010 /* USB reset */ #define PIC32_U1CON_PKTDIS 0x0020 /* Packet transfer disable */ #define PIC32_U1CON_TOKBUSY 0x0020 /* Token busy indicator */ #define PIC32_U1CON_SE0 0x0040 /* Single ended zero detected */ #define PIC32_U1CON_JSTATE 0x0080 /* Live differential receiver JSTATE flag */ /* * USB Power control register. */ #define PIC32_U1PWRC_USBPWR 0x0001 /* USB operation enable */ #define PIC32_U1PWRC_USUSPEND 0x0002 /* USB suspend mode */ #define PIC32_U1PWRC_USLPGRD 0x0010 /* USB sleep entry guard */ #define PIC32_U1PWRC_UACTPND 0x0080 /* UAB activity pending */ /* * USB Pending interrupt register. * USB Interrupt enable register. */ #define PIC32_U1I_DETACH 0x0001 /* Detach (host mode) */ #define PIC32_U1I_URST 0x0001 /* USB reset (device mode) */ #define PIC32_U1I_UERR 0x0002 /* USB error condition */ #define PIC32_U1I_SOF 0x0004 /* SOF token */ #define PIC32_U1I_TRN 0x0008 /* Token processing complete */ #define PIC32_U1I_IDLE 0x0010 /* Idle detect */ #define PIC32_U1I_RESUME 0x0020 /* Resume */ #define PIC32_U1I_ATTACH 0x0040 /* Peripheral attach */ #define PIC32_U1I_STALL 0x0080 /* STALL handshake */ /* * USB OTG interrupt flags register. * USB OTG interrupt enable register. */ #define PIC32_U1OTGI_VBUSVD 0x0001 /* A-device Vbus change */ #define PIC32_U1OTGI_SESEND 0x0004 /* B-device Vbus change */ #define PIC32_U1OTGI_SESVD 0x0008 /* Session valid change */ #define PIC32_U1OTGI_ACTV 0x0010 /* Bus activity indicator */ #define PIC32_U1OTGI_LSTATE 0x0020 /* Line state stable */ #define PIC32_U1OTGI_T1MSEC 0x0040 /* 1 millisecond timer expired */ #define PIC32_U1OTGI_ID 0x0080 /* ID state change */ #define PIC32_U1OTGSTAT_VBUSVD 0x0001 /* */ #define PIC32_U1OTGSTAT_SESEND 0x0004 /* */ #define PIC32_U1OTGSTAT_SESVD 0x0008 /* */ #define PIC32_U1OTGSTAT_LSTATE 0x0020 /* */ #define PIC32_U1OTGSTAT_ID 0x0080 /* */ #define PIC32_U1OTGCON_VBUSDIS 0x0001 /* */ #define PIC32_U1OTGCON_VBUSCHG 0x0002 /* */ #define PIC32_U1OTGCON_OTGEN 0x0004 /* */ #define PIC32_U1OTGCON_VBUSON 0x0008 /* */ #define PIC32_U1OTGCON_DMPULDWN 0x0010 /* */ #define PIC32_U1OTGCON_DPPULDWN 0x0020 /* */ #define PIC32_U1OTGCON_DMPULUP 0x0040 /* */ #define PIC32_U1OTGCON_DPPULUP 0x0080 /* */ #define PIC32_U1EI_PID 0x0001 /* */ #define PIC32_U1EI_CRC5 0x0002 /* */ #define PIC32_U1EI_EOF 0x0002 /* */ #define PIC32_U1EI_CRC16 0x0004 /* */ #define PIC32_U1EI_DFN8 0x0008 /* */ #define PIC32_U1EI_BTO 0x0010 /* */ #define PIC32_U1EI_DMA 0x0020 /* */ #define PIC32_U1EI_BMX 0x0040 /* */ #define PIC32_U1EI_BTS 0x0080 /* */ #define PIC32_U1STAT_PPBI 0x0004 /* */ #define PIC32_U1STAT_DIR 0x0008 /* */ #define PIC32_U1STAT_ENDPT(x) (((x) >> 4) & 0xF) /* */ #define PIC32_U1ADDR_DEVADDR 0x007F /* */ #define PIC32_U1ADDR_USBADDR0 0x0001 /* */ #define PIC32_U1ADDR_DEVADDR1 0x0002 /* */ #define PIC32_U1ADDR_DEVADDR2 0x0004 /* */ #define PIC32_U1ADDR_DEVADDR3 0x0008 /* */ #define PIC32_U1ADDR_DEVADDR4 0x0010 /* */ #define PIC32_U1ADDR_DEVADDR5 0x0020 /* */ #define PIC32_U1ADDR_DEVADDR6 0x0040 /* */ #define PIC32_U1ADDR_LSPDEN 0x0080 /* */ #define PIC32_U1FRML_FRM0 0x0001 /* */ #define PIC32_U1FRML_FRM1 0x0002 /* */ #define PIC32_U1FRML_FRM2 0x0004 /* */ #define PIC32_U1FRML_FRM3 0x0008 /* */ #define PIC32_U1FRML_FRM4 0x0010 /* */ #define PIC32_U1FRML_FRM5 0x0020 /* */ #define PIC32_U1FRML_FRM6 0x0040 /* */ #define PIC32_U1FRML_FRM7 0x0080 /* */ #define PIC32_U1FRMH_FRM8 0x0001 /* */ #define PIC32_U1FRMH_FRM9 0x0002 /* */ #define PIC32_U1FRMH_FRM10 0x0004 /* */ #define PIC32_U1TOK_EP0 0x0001 /* */ #define PIC32_U1TOK_EP 0x000F /* */ #define PIC32_U1TOK_EP1 0x0002 /* */ #define PIC32_U1TOK_EP2 0x0004 /* */ #define PIC32_U1TOK_EP3 0x0008 /* */ #define PIC32_U1TOK_PID0 0x0010 /* */ #define PIC32_U1TOK_PID 0x00F0 /* */ #define PIC32_U1TOK_PID1 0x0020 /* */ #define PIC32_U1TOK_PID2 0x0040 /* */ #define PIC32_U1TOK_PID3 0x0080 /* */ #define PIC32_U1CNFG1_USBSIDL 0x0010 /* */ #define PIC32_U1CNFG1_USBFRZ 0x0020 /* */ #define PIC32_U1CNFG1_UOEMON 0x0040 /* */ #define PIC32_U1CNFG1_UTEYE 0x0080 /* */ #define PIC32_U1EP_EPHSHK 0x0001 /* */ #define PIC32_U1EP_EPSTALL 0x0002 /* */ #define PIC32_U1EP_EPTXEN 0x0004 /* */ #define PIC32_U1EP_EPRXEN 0x0008 /* */ #define PIC32_U1EP_EPCONDIS 0x0010 /* */ #define PIC32_U1EP_RETRYDIS 0x0040 /* */ #define PIC32_U1EP_LSPD 0x0080 /* */ /* DB status field values */ #define PIC32_DB_BSTALL (1 << 2) #define PIC32_DB_DTS (1 << 3) #define PIC32_DB_NINC (1 << 4) #define PIC32_DB_KEEP (1 << 5) #define PIC32_DB_DATA1 (1 << 6) #define PIC32_DB_UOWN (1 << 7) #define PIC32_DB_GET_PID(x) (((x) >> 2) & 0xF) #define PIC32_DB_SET_PID(x) (((x) & 0xF) << 2) #define PIC32_DB_GET_COUNT(x) (((x) >> 16) & 0x3FF) #define PIC32_DB_SET_COUNT(x) (((x) & 0x3FF) << 16) /*-------------------------------------- * SPI registers. */ #ifdef PIC32MX4 #define SPI1CON PIC32_R (0x5800) /* Control */ #define SPI1CONCLR PIC32_R (0x5804) #define SPI1CONSET PIC32_R (0x5808) #define SPI1CONINV PIC32_R (0x580C) #define SPI1STAT PIC32_R (0x5810) /* Status */ #define SPI1STATCLR PIC32_R (0x5814) #define SPI1STATSET PIC32_R (0x5818) #define SPI1STATINV PIC32_R (0x581C) #define SPI1BUF PIC32_R (0x5820) /* Transmit and receive buffer */ #define SPI1BRG PIC32_R (0x5830) /* Baud rate generator */ #define SPI1BRGCLR PIC32_R (0x5834) #define SPI1BRGSET PIC32_R (0x5838) #define SPI1BRGINV PIC32_R (0x583C) #endif #ifdef PIC32MX7 #define SPI3CON PIC32_R (0x5800) /* Control */ #define SPI3CONCLR PIC32_R (0x5804) #define SPI3CONSET PIC32_R (0x5808) #define SPI3CONINV PIC32_R (0x580C) #define SPI3STAT PIC32_R (0x5810) /* Status */ #define SPI3STATCLR PIC32_R (0x5814) #define SPI3STATSET PIC32_R (0x5818) #define SPI3STATINV PIC32_R (0x581C) #define SPI3BUF PIC32_R (0x5820) /* Transmit and receive buffer */ #define SPI3BRG PIC32_R (0x5830) /* Baud rate generator */ #define SPI3BRGCLR PIC32_R (0x5834) #define SPI3BRGSET PIC32_R (0x5838) #define SPI3BRGINV PIC32_R (0x583C) #define SPI4CON PIC32_R (0x5C00) /* Control */ #define SPI4CONCLR PIC32_R (0x5C04) #define SPI4CONSET PIC32_R (0x5C08) #define SPI4CONINV PIC32_R (0x5C0C) #define SPI4STAT PIC32_R (0x5C10) /* Status */ #define SPI4STATCLR PIC32_R (0x5C14) #define SPI4STATSET PIC32_R (0x5C18) #define SPI4STATINV PIC32_R (0x5C1C) #define SPI4BUF PIC32_R (0x5C20) /* Transmit and receive buffer */ #define SPI4BRG PIC32_R (0x5C30) /* Baud rate generator */ #define SPI4BRGCLR PIC32_R (0x5C34) #define SPI4BRGSET PIC32_R (0x5C38) #define SPI4BRGINV PIC32_R (0x5C3C) #define SPI1CON PIC32_R (0x5E00) /* Control */ #define SPI1CONCLR PIC32_R (0x5E04) #define SPI1CONSET PIC32_R (0x5E08) #define SPI1CONINV PIC32_R (0x5E0C) #define SPI1STAT PIC32_R (0x5E10) /* Status */ #define SPI1STATCLR PIC32_R (0x5E14) #define SPI1STATSET PIC32_R (0x5E18) #define SPI1STATINV PIC32_R (0x5E1C) #define SPI1BUF PIC32_R (0x5E20) /* Transmit and receive buffer */ #define SPI1BRG PIC32_R (0x5E30) /* Baud rate generator */ #define SPI1BRGCLR PIC32_R (0x5E34) #define SPI1BRGSET PIC32_R (0x5E38) #define SPI1BRGINV PIC32_R (0x5E3C) #endif #define SPI2CON PIC32_R (0x5A00) /* Control */ #define SPI2CONCLR PIC32_R (0x5A04) #define SPI2CONSET PIC32_R (0x5A08) #define SPI2CONINV PIC32_R (0x5A0C) #define SPI2STAT PIC32_R (0x5A10) /* Status */ #define SPI2STATCLR PIC32_R (0x5A14) #define SPI2STATSET PIC32_R (0x5A18) #define SPI2STATINV PIC32_R (0x5A1C) #define SPI2BUF PIC32_R (0x5A20) /* Transmit and receive buffer */ #define SPI2BRG PIC32_R (0x5A30) /* Baud rate generator */ #define SPI2BRGCLR PIC32_R (0x5A34) #define SPI2BRGSET PIC32_R (0x5A38) #define SPI2BRGINV PIC32_R (0x5A3C) #ifndef __ASSEMBLER__ struct spireg { volatile unsigned con; /* Control */ volatile unsigned conclr; volatile unsigned conset; volatile unsigned coninv; volatile unsigned stat; /* Status */ volatile unsigned statclr; volatile unsigned statset; volatile unsigned statinv; volatile unsigned buf; /* Transmit and receive buffer */ volatile unsigned unused1; volatile unsigned unused2; volatile unsigned unused3; volatile unsigned brg; /* Baud rate generator */ volatile unsigned brgclr; volatile unsigned brgset; volatile unsigned brginv; }; #endif /* * SPI Control register. */ #define PIC32_SPICON_MSTEN 0x00000020 /* Master mode */ #define PIC32_SPICON_CKP 0x00000040 /* Idle clock is high level */ #define PIC32_SPICON_SSEN 0x00000080 /* Slave mode: SSx pin enable */ #define PIC32_SPICON_CKE 0x00000100 /* Output data changes on * transition from active clock * state to Idle clock state */ #define PIC32_SPICON_SMP 0x00000200 /* Master mode: input data sampled * at end of data output time. */ #define PIC32_SPICON_MODE16 0x00000400 /* 16-bit data width */ #define PIC32_SPICON_MODE32 0x00000800 /* 32-bit data width */ #define PIC32_SPICON_DISSDO 0x00001000 /* SDOx pin is not used */ #define PIC32_SPICON_SIDL 0x00002000 /* Stop in Idle mode */ #define PIC32_SPICON_FRZ 0x00004000 /* Freeze in Debug mode */ #define PIC32_SPICON_ON 0x00008000 /* SPI Peripheral is enabled */ #define PIC32_SPICON_ENHBUF 0x00010000 /* Enhanced buffer enable */ #define PIC32_SPICON_SPIFE 0x00020000 /* Frame synchronization pulse * coincides with the first bit clock */ #define PIC32_SPICON_FRMPOL 0x20000000 /* Frame pulse is active-high */ #define PIC32_SPICON_FRMSYNC 0x40000000 /* Frame sync pulse input (Slave mode) */ #define PIC32_SPICON_FRMEN 0x80000000 /* Framed SPI support */ /* * SPI Status register. */ #define PIC32_SPISTAT_SPIRBF 0x00000001 /* Receive buffer is full */ #define PIC32_SPISTAT_SPITBF 0x00000002 /* Transmit buffer is full */ #define PIC32_SPISTAT_SPITBE 0x00000008 /* Transmit buffer is empty */ #define PIC32_SPISTAT_SPIRBE 0x00000020 /* Receive buffer is empty */ #define PIC32_SPISTAT_SPIROV 0x00000040 /* Receive overflow flag */ #define PIC32_SPISTAT_SPIBUSY 0x00000800 /* SPI is busy */ /*-------------------------------------- * DMA controller registers. */ #define DMACON PIC32_R (0x83000) /* DMA Control */ #define DMACONCLR PIC32_R (0x83004) #define DMACONSET PIC32_R (0x83008) #define DMACONINV PIC32_R (0x8300C) #define DMASTAT PIC32_R (0x83010) /* DMA Status */ #define DMAADDR PIC32_R (0x83020) /* DMA Address */ /* TODO: other DMA registers. */ /*-------------------------------------- * System controller registers. */ #define OSCCON PIC32_R (0xf000) /* Oscillator Control */ #define OSCCONCLR PIC32_R (0xf004) #define OSCCONSET PIC32_R (0xf008) #define OSCCONINV PIC32_R (0xf00C) #define OSCTUN PIC32_R (0xf010) #define DDPCON PIC32_R (0xf200) /* Debug Data Port Control */ #define DEVID PIC32_R (0xf220) #define SYSKEY PIC32_R (0xf230) #define RCON PIC32_R (0xf600) #define RCONCLR PIC32_R (0xf604) #define RCONSET PIC32_R (0xf608) #define RCONINV PIC32_R (0xf60C) #define RSWRST PIC32_R (0xf610) #define RSWRSTCLR PIC32_R (0xf614) #define RSWRSTSET PIC32_R (0xf618) #define RSWRSTINV PIC32_R (0xf61C) /* * Oscillator control register. */ #define PIC32_OSCCON_OSWEN 0x00000001 /* Oscillator switch enable */ #define PIC32_OSCCON_SOSCEN 0x00000002 /* Secondary oscillator enable */ #define PIC32_OSCCON_UFRCEN 0x00000004 /* USB FRC clock enable */ #define PIC32_OSCCON_CF 0x00000008 /* Clock fail detect */ #define PIC32_OSCCON_SLPEN 0x00000010 /* Sleep mode enable */ #define PIC32_OSCCON_LOCK 0x00000020 /* PLL lock status */ #define PIC32_OSCCON_ULOCK 0x00000040 /* USB PLL lock status */ #define PIC32_OSCCON_CLKLOCK 0x00000080 /* Clock selection lock enable */ #define PIC32_OSCCON_NOSC 0x00000700 /* New oscillator selection */ #define PIC32_OSCCON_COSC 0x00007000 /* Current oscillator selection */ #define PIC32_OSCCON_PLLMULT 0x00070000 /* PLL multiplier */ #define PIC32_OSCCON_PBDIV_MASK 0x00180000 /* Peripheral bus clock divisor */ #define PIC32_OSCCON_PBDIV_1 0x00000000 /* SYSCLK / 1 */ #define PIC32_OSCCON_PBDIV_2 0x00080000 /* SYSCLK / 2 */ #define PIC32_OSCCON_PBDIV_4 0x00100000 /* SYSCLK / 4 */ #define PIC32_OSCCON_PBDIV_8 0x00180000 /* SYSCLK / 8 */ #define PIC32_OSCCON_SOSCRDY 0x00400000 /* Secondary oscillator ready */ #define PIC32_OSCCON_FRCDIV 0x07000000 /* Fast internal RC clock divider */ #define PIC32_OSCCON_PLLODIV 0x38000000 /* Output divider for PLL */ /* * Reset control register. */ #define PIC32_RCON_POR 0x00000001 #define PIC32_RCON_BOR 0x00000002 #define PIC32_RCON_IDLE 0x00000004 #define PIC32_RCON_SLEEP 0x00000008 #define PIC32_RCON_WDTO 0x00000010 #define PIC32_RCON_SWR 0x00000040 #define PIC32_RCON_EXTR 0x00000080 #define PIC32_RCON_VREGS 0x00000100 #define PIC32_RCON_CMR 0x00000200 /*-------------------------------------- * Prefetch cache controller registers. */ #define CHECON PIC32_R (0x84000) /* Prefetch cache control */ #define CHECONCLR PIC32_R (0x84004) #define CHECONSET PIC32_R (0x84008) #define CHECONINV PIC32_R (0x8400C) /* TODO: other prefetch registers. */ /*-------------------------------------- * Bus matrix control registers. */ #define BMXCON PIC32_R (0x82000) /* Memory configuration */ #define BMXCONCLR PIC32_R (0x82004) #define BMXCONSET PIC32_R (0x82008) #define BMXCONINV PIC32_R (0x8200C) #define BMXDKPBA PIC32_R (0x82010) /* Data RAM kernel program base address */ #define BMXDUDBA PIC32_R (0x82020) /* Data RAM user data base address */ #define BMXDUPBA PIC32_R (0x82030) /* Data RAM user program base address */ #define BMXDRMSZ PIC32_R (0x82040) /* Data RAM size */ #define BMXPUPBA PIC32_R (0x82050) /* Program Flash user program base address */ #define BMXPFMSZ PIC32_R (0x82060) /* Program Flash size */ #define BMXBOOTSZ PIC32_R (0x82070) /* Boot Flash size */ /*-------------------------------------- * Non-volatile memory control registers. */ #define NVMCON PIC32_R (0x0F400) #define NVMCONCLR PIC32_R (0x0F404) #define NVMCONSET PIC32_R (0x0F408) #define NVMCONINV PIC32_R (0x0F40C) #define NVMKEY PIC32_R (0x0F410) #define NVMADDR PIC32_R (0x0F420) #define NVMADDRCLR PIC32_R (0x0F424) #define NVMADDRSET PIC32_R (0x0F428) #define NVMADDRINV PIC32_R (0x0F42C) #define NVMDATA PIC32_R (0x0F430) #define NVMSRCADDR PIC32_R (0x0F440) #define PIC32_NVMCON_NVMOP 0x0000000F #define PIC32_NVMCON_NOP 0 /* No operation */ #define PIC32_NVMCON_WORD_PGM 1 /* Word program */ #define PIC32_NVMCON_ROW_PGM 3 /* Row program */ #define PIC32_NVMCON_PAGE_ERASE 4 /* Page erase */ #define PIC32_NVMCON_LVDSTAT 0x00000800 #define PIC32_NVMCON_LVDERR 0x00001000 #define PIC32_NVMCON_WRERR 0x00002000 #define PIC32_NVMCON_WREN 0x00004000 #define PIC32_NVMCON_WR 0x00008000 /* * Timer2 registers */ #define T2CON PIC32_R (0x0800) #define T2CONSET PIC32_R (0x0808) #define TMR2 PIC32_R (0x0810) #define PR2 PIC32_R (0x0820) /* * Output compare registers */ #define OC1CON PIC32_R (0x3000) #define OC1R PIC32_R (0x3010) #define OC1RS PIC32_R (0x3020) #define OC4CON PIC32_R (0x3600) #define OC4R PIC32_R (0x3610) #define OC4RS PIC32_R (0x3620) #define BLRKEY *(volatile unsigned*)(0x80000000) /*-------------------------------------- * Configuration registers. */ #define DEVCFG0 *(volatile unsigned*)0x9fc02ffc #define DEVCFG1 *(volatile unsigned*)0x9fc02ff8 #define DEVCFG2 *(volatile unsigned*)0x9fc02ff4 #define DEVCFG3 *(volatile unsigned*)0x9fc02ff0 #define PIC32_DEVCFG(cfg0, cfg1, cfg2, cfg3) \ asm (".section .config"); \ unsigned __DEVCFG0 __attribute__ ((section (".config0"))) = (cfg0) ^ 0x7fffffff; \ unsigned __DEVCFG1 __attribute__ ((section (".config1"))) = (cfg1) | DEVCFG1_UNUSED; \ unsigned __DEVCFG2 __attribute__ ((section (".config2"))) = (cfg2) | DEVCFG2_UNUSED; \ unsigned __DEVCFG3 __attribute__ ((section (".config3"))) = (cfg3) | DEVCFG3_UNUSED /* * Config0 register at 1fc02ffc, inverted. */ #define DEVCFG0_DEBUG_MASK 0x00000003 /* Debugger enable bits */ #define DEVCFG0_DEBUG_DISABLED 0x00000000 /* Debugger disabled */ #define DEVCFG0_DEBUG_ENABLED 0x00000002 /* Debugger enabled */ #define DEVCFG0_ICESEL 0x00000008 /* Use PGC1/PGD1 (default PGC2/PGD2) */ #define DEVCFG0_PWP_MASK 0x000ff000 /* Program flash write protect */ #define DEVCFG0_BWP 0x01000000 /* Boot flash write protect */ #define DEVCFG0_CP 0x10000000 /* Code protect */ /* * Config1 register at 1fc02ff8. */ #define DEVCFG1_UNUSED 0xff600858 #define DEVCFG1_FNOSC_MASK 0x00000007 /* Oscillator selection */ #define DEVCFG1_FNOSC_FRC 0x00000000 /* Fast RC */ #define DEVCFG1_FNOSC_FRCDIVPLL 0x00000001 /* Fast RC with divide-by-N and PLL */ #define DEVCFG1_FNOSC_PRI 0x00000002 /* Primary oscillator XT, HS, EC */ #define DEVCFG1_FNOSC_PRIPLL 0x00000003 /* Primary with PLL */ #define DEVCFG1_FNOSC_SEC 0x00000004 /* Secondary oscillator */ #define DEVCFG1_FNOSC_LPRC 0x00000005 /* Low-power RC */ #define DEVCFG1_FNOSC_FRCDIV 0x00000007 /* Fast RC with divide-by-N */ #define DEVCFG1_FSOSCEN 0x00000020 /* Secondary oscillator enable */ #define DEVCFG1_IESO 0x00000080 /* Internal-external switch over */ #define DEVCFG1_POSCMOD_MASK 0x00000300 /* Primary oscillator config */ #define DEVCFG1_POSCMOD_EXT 0x00000000 /* External mode */ #define DEVCFG1_POSCMOD_XT 0x00000100 /* XT oscillator */ #define DEVCFG1_POSCMOD_HS 0x00000200 /* HS oscillator */ #define DEVCFG1_POSCMOD_DISABLE 0x00000300 /* Disabled */ #define DEVCFG1_OSCIOFNC 0x00000400 /* CLKO output active */ #define DEVCFG1_FPBDIV_MASK 0x00003000 /* Peripheral bus clock divisor */ #define DEVCFG1_FPBDIV_1 0x00000000 /* SYSCLK / 1 */ #define DEVCFG1_FPBDIV_2 0x00001000 /* SYSCLK / 2 */ #define DEVCFG1_FPBDIV_4 0x00002000 /* SYSCLK / 4 */ #define DEVCFG1_FPBDIV_8 0x00003000 /* SYSCLK / 8 */ #define DEVCFG1_FCKM_DISABLE 0x00004000 /* Fail-safe clock monitor disable */ #define DEVCFG1_FCKS_DISABLE 0x00008000 /* Clock switching disable */ #define DEVCFG1_WDTPS_MASK 0x001f0000 /* Watchdog postscale */ #define DEVCFG1_WDTPS_1 0x00000000 /* 1:1 */ #define DEVCFG1_WDTPS_2 0x00010000 /* 1:2 */ #define DEVCFG1_WDTPS_4 0x00020000 /* 1:4 */ #define DEVCFG1_WDTPS_8 0x00030000 /* 1:8 */ #define DEVCFG1_WDTPS_16 0x00040000 /* 1:16 */ #define DEVCFG1_WDTPS_32 0x00050000 /* 1:32 */ #define DEVCFG1_WDTPS_64 0x00060000 /* 1:64 */ #define DEVCFG1_WDTPS_128 0x00070000 /* 1:128 */ #define DEVCFG1_WDTPS_256 0x00080000 /* 1:256 */ #define DEVCFG1_WDTPS_512 0x00090000 /* 1:512 */ #define DEVCFG1_WDTPS_1024 0x000a0000 /* 1:1024 */ #define DEVCFG1_WDTPS_2048 0x000b0000 /* 1:2048 */ #define DEVCFG1_WDTPS_4096 0x000c0000 /* 1:4096 */ #define DEVCFG1_WDTPS_8192 0x000d0000 /* 1:8192 */ #define DEVCFG1_WDTPS_16384 0x000e0000 /* 1:16384 */ #define DEVCFG1_WDTPS_32768 0x000f0000 /* 1:32768 */ #define DEVCFG1_WDTPS_65536 0x00100000 /* 1:65536 */ #define DEVCFG1_WDTPS_131072 0x00110000 /* 1:131072 */ #define DEVCFG1_WDTPS_262144 0x00120000 /* 1:262144 */ #define DEVCFG1_WDTPS_524288 0x00130000 /* 1:524288 */ #define DEVCFG1_WDTPS_1048576 0x00140000 /* 1:1048576 */ #define DEVCFG1_FWDTEN 0x00800000 /* Watchdog enable */ #define WDTCON PIC32_R (0x0000) /* Watchdog timer control */ #define WDTCONCLR PIC32_R (0x0004) /* Watchdog timer control */ #define WDTCONSET PIC32_R (0x0008) /* Watchdog timer control */ /* * Config2 register at 1fc02ff4. */ #define DEVCFG2_UNUSED 0xfff87888 #define DEVCFG2_FPLLIDIV_MASK 0x00000007 /* PLL input divider */ #define DEVCFG2_FPLLIDIV_1 0x00000000 /* 1x */ #define DEVCFG2_FPLLIDIV_2 0x00000001 /* 2x */ #define DEVCFG2_FPLLIDIV_3 0x00000002 /* 3x */ #define DEVCFG2_FPLLIDIV_4 0x00000003 /* 4x */ #define DEVCFG2_FPLLIDIV_5 0x00000004 /* 5x */ #define DEVCFG2_FPLLIDIV_6 0x00000005 /* 6x */ #define DEVCFG2_FPLLIDIV_10 0x00000006 /* 10x */ #define DEVCFG2_FPLLIDIV_12 0x00000007 /* 12x */ #define DEVCFG2_FPLLMUL_MASK 0x00000070 /* PLL multiplier */ #define DEVCFG2_FPLLMUL_15 0x00000000 /* 15x */ #define DEVCFG2_FPLLMUL_16 0x00000010 /* 16x */ #define DEVCFG2_FPLLMUL_17 0x00000020 /* 17x */ #define DEVCFG2_FPLLMUL_18 0x00000030 /* 18x */ #define DEVCFG2_FPLLMUL_19 0x00000040 /* 19x */ #define DEVCFG2_FPLLMUL_20 0x00000050 /* 20x */ #define DEVCFG2_FPLLMUL_21 0x00000060 /* 21x */ #define DEVCFG2_FPLLMUL_24 0x00000070 /* 24x */ #define DEVCFG2_UPLLIDIV_MASK 0x00000700 /* USB PLL input divider */ #define DEVCFG2_UPLLIDIV_1 0x00000000 /* 1x */ #define DEVCFG2_UPLLIDIV_2 0x00000100 /* 2x */ #define DEVCFG2_UPLLIDIV_3 0x00000200 /* 3x */ #define DEVCFG2_UPLLIDIV_4 0x00000300 /* 4x */ #define DEVCFG2_UPLLIDIV_5 0x00000400 /* 5x */ #define DEVCFG2_UPLLIDIV_6 0x00000500 /* 6x */ #define DEVCFG2_UPLLIDIV_10 0x00000600 /* 10x */ #define DEVCFG2_UPLLIDIV_12 0x00000700 /* 12x */ #define DEVCFG2_UPLLDIS 0x00008000 /* Disable USB PLL */ #define DEVCFG2_FPLLODIV_MASK 0x00070000 /* Default postscaler for PLL */ #define DEVCFG2_FPLLODIV_1 0x00000000 /* 1x */ #define DEVCFG2_FPLLODIV_2 0x00010000 /* 2x */ #define DEVCFG2_FPLLODIV_4 0x00020000 /* 4x */ #define DEVCFG2_FPLLODIV_8 0x00030000 /* 8x */ #define DEVCFG2_FPLLODIV_16 0x00040000 /* 16x */ #define DEVCFG2_FPLLODIV_32 0x00050000 /* 32x */ #define DEVCFG2_FPLLODIV_64 0x00060000 /* 64x */ #define DEVCFG2_FPLLODIV_256 0x00070000 /* 256x */ /* * Config3 register at 1fc02ff0. */ #define DEVCFG3_UNUSED 0x38f80000 #define DEVCFG3_USERID_MASK 0x0000ffff /* User-defined ID */ #define DEVCFG3_USERID(x) ((x) & 0xffff) #define DEVCFG3_FSRSSEL_MASK 0x00070000 /* SRS select */ #define DEVCFG3_FSRSSEL_ALL 0x00000000 /* All irqs assigned to shadow set */ #define DEVCFG3_FSRSSEL_1 0x00010000 /* Assign irq priority 1 to shadow set */ #define DEVCFG3_FSRSSEL_2 0x00020000 /* Assign irq priority 2 to shadow set */ #define DEVCFG3_FSRSSEL_3 0x00030000 /* Assign irq priority 3 to shadow set */ #define DEVCFG3_FSRSSEL_4 0x00040000 /* Assign irq priority 4 to shadow set */ #define DEVCFG3_FSRSSEL_5 0x00050000 /* Assign irq priority 5 to shadow set */ #define DEVCFG3_FSRSSEL_6 0x00060000 /* Assign irq priority 6 to shadow set */ #define DEVCFG3_FSRSSEL_7 0x00070000 /* Assign irq priority 7 to shadow set */ #define DEVCFG3_FMIIEN 0x01000000 /* Ethernet MII enable */ #define DEVCFG3_FETHIO 0x02000000 /* Ethernet pins default */ #define DEVCFG3_FCANIO 0x04000000 /* CAN pins default */ #define DEVCFG3_FUSBIDIO 0x40000000 /* USBID pin: controlled by USB */ #define DEVCFG3_FVBUSONIO 0x80000000 /* VBuson pin: controlled by USB */ /*-------------------------------------- * Interrupt controller registers. */ #define INTCON PIC32_R (0x81000) /* Interrupt Control */ #define INTCONCLR PIC32_R (0x81004) #define INTCONSET PIC32_R (0x81008) #define INTCONINV PIC32_R (0x8100C) #define INTSTAT PIC32_R (0x81010) /* Interrupt Status */ #define IPTMR PIC32_R (0x81020) /* Temporal Proximity Timer */ #define IPTMRCLR PIC32_R (0x81024) #define IPTMRSET PIC32_R (0x81028) #define IPTMRINV PIC32_R (0x8102C) #define IFS(n) PIC32_R (0x81030+((n)<<4)) /* IFS(0..2) - Interrupt Flag Status */ #define IFSCLR(n) PIC32_R (0x81034+((n)<<4)) #define IFSSET(n) PIC32_R (0x81038+((n)<<4)) #define IFSINV(n) PIC32_R (0x8103C+((n)<<4)) #define IEC(n) PIC32_R (0x81060+((n)<<4)) /* IEC(0..2) - Interrupt Enable Control */ #define IECCLR(n) PIC32_R (0x81064+((n)<<4)) #define IECSET(n) PIC32_R (0x81068+((n)<<4)) #define IECINV(n) PIC32_R (0x8106C+((n)<<4)) #define IPC(n) PIC32_R (0x81090+((n)<<4)) /* IPC(0..12) - Interrupt Priority Control */ #define IPCCLR(n) PIC32_R (0x81094+((n)<<4)) #define IPCSET(n) PIC32_R (0x81098+((n)<<4)) #define IPCINV(n) PIC32_R (0x8109C+((n)<<4)) /* * Interrupt Control register. */ #define PIC32_INTCON_INT0EP 0x0001 /* External interrupt 0 polarity rising edge */ #define PIC32_INTCON_INT1EP 0x0002 /* External interrupt 1 polarity rising edge */ #define PIC32_INTCON_INT2EP 0x0004 /* External interrupt 2 polarity rising edge */ #define PIC32_INTCON_INT3EP 0x0008 /* External interrupt 3 polarity rising edge */ #define PIC32_INTCON_INT4EP 0x0010 /* External interrupt 4 polarity rising edge */ #define PIC32_INTCON_TPC(x) ((x)<<8) /* Temporal proximity group priority */ #define PIC32_INTCON_MVEC 0x1000 /* Multi-vectored mode */ #define PIC32_INTCON_FRZ 0x4000 /* Freeze in debug mode */ #define PIC32_INTCON_SS0 0x8000 /* Single vector has a shadow register set */ /* * Interrupt Status register. */ #define PIC32_INTSTAT_VEC(s) ((s) & 0xFF) /* Interrupt vector */ #define PIC32_INTSTAT_SRIPL(s) ((s) >> 8 & 7) /* Requested priority level */ #define PIC32_INTSTAT_SRIPL_MASK 0x0700 /* * Interrupt Prority Control register. */ #define PIC32_IPC_IS0(x) (x) /* Interrupt 0 subpriority */ #define PIC32_IPC_IP0(x) ((x)<<2) /* Interrupt 0 priority */ #define PIC32_IPC_IS1(x) ((x)<<8) /* Interrupt 1 subpriority */ #define PIC32_IPC_IP1(x) ((x)<<10) /* Interrupt 1 priority */ #define PIC32_IPC_IS2(x) ((x)<<16) /* Interrupt 2 subpriority */ #define PIC32_IPC_IP2(x) ((x)<<18) /* Interrupt 2 priority */ #define PIC32_IPC_IS3(x) ((x)<<24) /* Interrupt 3 subpriority */ #define PIC32_IPC_IP3(x) ((x)<<26) /* Interrupt 3 priority */ /* * IRQ numbers for PIC32MX3xx/4xx/5xx/6xx/7xx */ #define PIC32_IRQ_CT 0 /* Core Timer Interrupt */ #define PIC32_IRQ_CS0 1 /* Core Software Interrupt 0 */ #define PIC32_IRQ_CS1 2 /* Core Software Interrupt 1 */ #define PIC32_IRQ_INT0 3 /* External Interrupt 0 */ #define PIC32_IRQ_T1 4 /* Timer1 */ #define PIC32_IRQ_IC1 5 /* Input Capture 1 */ #define PIC32_IRQ_OC1 6 /* Output Compare 1 */ #define PIC32_IRQ_INT1 7 /* External Interrupt 1 */ #define PIC32_IRQ_T2 8 /* Timer2 */ #define PIC32_IRQ_IC2 9 /* Input Capture 2 */ #define PIC32_IRQ_OC2 10 /* Output Compare 2 */ #define PIC32_IRQ_INT2 11 /* External Interrupt 2 */ #define PIC32_IRQ_T3 12 /* Timer3 */ #define PIC32_IRQ_IC3 13 /* Input Capture 3 */ #define PIC32_IRQ_OC3 14 /* Output Compare 3 */ #define PIC32_IRQ_INT3 15 /* External Interrupt 3 */ #define PIC32_IRQ_T4 16 /* Timer4 */ #define PIC32_IRQ_IC4 17 /* Input Capture 4 */ #define PIC32_IRQ_OC4 18 /* Output Compare 4 */ #define PIC32_IRQ_INT4 19 /* External Interrupt 4 */ #define PIC32_IRQ_T5 20 /* Timer5 */ #define PIC32_IRQ_IC5 21 /* Input Capture 5 */ #define PIC32_IRQ_OC5 22 /* Output Compare 5 */ #define PIC32_IRQ_SPI1E 23 /* SPI1 Fault */ #define PIC32_IRQ_SPI1TX 24 /* SPI1 Transfer Done */ #define PIC32_IRQ_SPI1RX 25 /* SPI1 Receive Done */ #define PIC32_IRQ_SPI3E 26 /* SPI3 Fault */ #define PIC32_IRQ_SPI3TX 27 /* SPI3 Transfer Done */ #define PIC32_IRQ_SPI3RX 28 /* SPI3 Receive Done */ #define PIC32_IRQ_U1E 26 /* UART1 Error */ #define PIC32_IRQ_U1RX 27 /* UART1 Receiver */ #define PIC32_IRQ_U1TX 28 /* UART1 Transmitter */ #define PIC32_IRQ_I2C3B 26 /* I2C3 Bus Collision Event */ #define PIC32_IRQ_I2C3S 27 /* I2C3 Slave Event */ #define PIC32_IRQ_I2C3M 28 /* I2C3 Master Event */ #define PIC32_IRQ_I2C1B 29 /* I2C1 Bus Collision Event */ #define PIC32_IRQ_I2C1S 30 /* I2C1 Slave Event */ #define PIC32_IRQ_I2C1M 31 /* I2C1 Master Event */ #define PIC32_IRQ_CN 32 /* Input Change Interrupt */ #define PIC32_IRQ_AD1 33 /* ADC1 Convert Done */ #define PIC32_IRQ_PMP 34 /* Parallel Master Port */ #define PIC32_IRQ_CMP1 35 /* Comparator Interrupt */ #define PIC32_IRQ_CMP2 36 /* Comparator Interrupt */ #define PIC32_IRQ_SPI2E 37 /* SPI2 Fault */ #define PIC32_IRQ_SPI2TX 38 /* SPI2 Transfer Done */ #define PIC32_IRQ_SPI2RX 39 /* SPI2 Receive Done */ #define PIC32_IRQ_U3E 37 /* UART3 Error */ #define PIC32_IRQ_U3RX 38 /* UART3 Receiver */ #define PIC32_IRQ_U3TX 39 /* UART3 Transmitter */ #define PIC32_IRQ_I2C4B 37 /* I2C4 Bus Collision Event */ #define PIC32_IRQ_I2C4S 38 /* I2C4 Slave Event */ #define PIC32_IRQ_I2C4M 39 /* I2C4 Master Event */ #define PIC32_IRQ_SPI4E 40 /* SPI4 Fault */ #define PIC32_IRQ_SPI4TX 41 /* SPI4 Transfer Done */ #define PIC32_IRQ_SPI4RX 42 /* SPI4 Receive Done */ #define PIC32_IRQ_U2E 40 /* UART2 Error */ #define PIC32_IRQ_U2RX 41 /* UART2 Receiver */ #define PIC32_IRQ_U2TX 42 /* UART2 Transmitter */ #define PIC32_IRQ_I2C5B 40 /* I2C5 Bus Collision Event */ #define PIC32_IRQ_I2C5S 41 /* I2C5 Slave Event */ #define PIC32_IRQ_I2C5M 42 /* I2C5 Master Event */ #define PIC32_IRQ_I2C2B 43 /* I2C2 Bus Collision Event */ #define PIC32_IRQ_I2C2S 44 /* I2C2 Slave Event */ #define PIC32_IRQ_I2C2M 45 /* I2C2 Master Event */ #define PIC32_IRQ_FSCM 46 /* Fail-Safe Clock Monitor */ #define PIC32_IRQ_RTCC 47 /* Real-Time Clock and Calendar */ #define PIC32_IRQ_DMA0 48 /* DMA Channel 0 */ #define PIC32_IRQ_DMA1 49 /* DMA Channel 1 */ #define PIC32_IRQ_DMA2 50 /* DMA Channel 2 */ #define PIC32_IRQ_DMA3 51 /* DMA Channel 3 */ #define PIC32_IRQ_DMA4 52 /* DMA Channel 4 */ #define PIC32_IRQ_DMA5 53 /* DMA Channel 5 */ #define PIC32_IRQ_DMA6 54 /* DMA Channel 6 */ #define PIC32_IRQ_DMA7 55 /* DMA Channel 7 */ #define PIC32_IRQ_FCE 56 /* Flash Control Event */ #define PIC32_IRQ_USB 57 /* USB */ #define PIC32_IRQ_CAN1 58 /* Control Area Network 1 */ #define PIC32_IRQ_CAN2 59 /* Control Area Network 2 */ #define PIC32_IRQ_ETH 60 /* Ethernet Interrupt */ #define PIC32_IRQ_IC1E 61 /* Input Capture 1 Error */ #define PIC32_IRQ_IC2E 62 /* Input Capture 2 Error */ #define PIC32_IRQ_IC3E 63 /* Input Capture 3 Error */ #define PIC32_IRQ_IC4E 64 /* Input Capture 4 Error */ #define PIC32_IRQ_IC5E 65 /* Input Capture 5 Error */ #define PIC32_IRQ_PMPE 66 /* Parallel Master Port Error */ #define PIC32_IRQ_U4E 67 /* UART4 Error */ #define PIC32_IRQ_U4RX 68 /* UART4 Receiver */ #define PIC32_IRQ_U4TX 69 /* UART4 Transmitter */ #define PIC32_IRQ_U6E 70 /* UART6 Error */ #define PIC32_IRQ_U6RX 71 /* UART6 Receiver */ #define PIC32_IRQ_U6TX 72 /* UART6 Transmitter */ #define PIC32_IRQ_U5E 73 /* UART5 Error */ #define PIC32_IRQ_U5RX 74 /* UART5 Receiver */ #define PIC32_IRQ_U5TX 75 /* UART5 Transmitter */ /* * Interrupt vector numbers for PIC32MX3xx/4xx/5xx/6xx/7xx */ #define PIC32_VECT_CT 0 /* Core Timer Interrupt */ #define PIC32_VECT_CS0 1 /* Core Software Interrupt 0 */ #define PIC32_VECT_CS1 2 /* Core Software Interrupt 1 */ #define PIC32_VECT_INT0 3 /* External Interrupt 0 */ #define PIC32_VECT_T1 4 /* Timer1 */ #define PIC32_VECT_IC1 5 /* Input Capture 1 */ #define PIC32_VECT_OC1 6 /* Output Compare 1 */ #define PIC32_VECT_INT1 7 /* External Interrupt 1 */ #define PIC32_VECT_T2 8 /* Timer2 */ #define PIC32_VECT_IC2 9 /* Input Capture 2 */ #define PIC32_VECT_OC2 10 /* Output Compare 2 */ #define PIC32_VECT_INT2 11 /* External Interrupt 2 */ #define PIC32_VECT_T3 12 /* Timer3 */ #define PIC32_VECT_IC3 13 /* Input Capture 3 */ #define PIC32_VECT_OC3 14 /* Output Compare 3 */ #define PIC32_VECT_INT3 15 /* External Interrupt 3 */ #define PIC32_VECT_T4 16 /* Timer4 */ #define PIC32_VECT_IC4 17 /* Input Capture 4 */ #define PIC32_VECT_OC4 18 /* Output Compare 4 */ #define PIC32_VECT_INT4 19 /* External Interrupt 4 */ #define PIC32_VECT_T5 20 /* Timer5 */ #define PIC32_VECT_IC5 21 /* Input Capture 5 */ #define PIC32_VECT_OC5 22 /* Output Compare 5 */ #define PIC32_VECT_SPI1 23 /* SPI1 */ #define PIC32_VECT_SPI3 24 /* SPI3 */ #define PIC32_VECT_U1 24 /* UART1 */ #define PIC32_VECT_I2C3 24 /* I2C3 */ #define PIC32_VECT_I2C1 25 /* I2C1 */ #define PIC32_VECT_CN 26 /* Input Change Interrupt */ #define PIC32_VECT_AD1 27 /* ADC1 Convert Done */ #define PIC32_VECT_PMP 28 /* Parallel Master Port */ #define PIC32_VECT_CMP1 29 /* Comparator Interrupt */ #define PIC32_VECT_CMP2 30 /* Comparator Interrupt */ #define PIC32_VECT_SPI2 31 /* SPI2 */ #define PIC32_VECT_U3 31 /* UART3 */ #define PIC32_VECT_I2C4 31 /* I2C4 */ #define PIC32_VECT_SPI4 32 /* SPI4 */ #define PIC32_VECT_U2 32 /* UART2 */ #define PIC32_VECT_I2C5 32 /* I2C5 */ #define PIC32_VECT_I2C2 33 /* I2C2 */ #define PIC32_VECT_FSCM 34 /* Fail-Safe Clock Monitor */ #define PIC32_VECT_RTCC 35 /* Real-Time Clock and Calendar */ #define PIC32_VECT_DMA0 36 /* DMA Channel 0 */ #define PIC32_VECT_DMA1 37 /* DMA Channel 1 */ #define PIC32_VECT_DMA2 38 /* DMA Channel 2 */ #define PIC32_VECT_DMA3 39 /* DMA Channel 3 */ #define PIC32_VECT_DMA4 40 /* DMA Channel 4 */ #define PIC32_VECT_DMA5 41 /* DMA Channel 5 */ #define PIC32_VECT_DMA6 42 /* DMA Channel 6 */ #define PIC32_VECT_DMA7 43 /* DMA Channel 7 */ #define PIC32_VECT_FCE 44 /* Flash Control Event */ #define PIC32_VECT_USB 45 /* USB */ #define PIC32_VECT_CAN1 46 /* Control Area Network 1 */ #define PIC32_VECT_CAN2 47 /* Control Area Network 2 */ #define PIC32_VECT_ETH 48 /* Ethernet Interrupt */ #define PIC32_VECT_U4 49 /* UART4 */ #define PIC32_VECT_U6 50 /* UART6 */ #define PIC32_VECT_U5 51 /* UART5 */ #endif /* _IO_PIC32MX_H */ ================================================ FILE: sys/arch/pic32/include/setjmp.h ================================================ /* * Copyright (c) 2022 Christopher Hettrick * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #ifndef _MACHINE_SETJMP_H_ #define _MACHINE_SETJMP_H_ /* * Total 14 words for MIPS architecture: * Twelve for registers: * env[0-11]: $s0-$s8, $ra, $gp, $sp * Two for signal mask: * env[12]: savesigs * env[13]: signal mask */ #define _JBLEN 14 #endif /* !_MACHINE_SETJMP_H_ */ ================================================ FILE: sys/arch/pic32/include/signal.h ================================================ /* * Copyright (c) 2021 Christopher Hettrick * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #ifndef _MACHINE_SIGNAL_H_ #define _MACHINE_SIGNAL_H_ /* * Information pushed on stack when a signal is delivered. * This is used by the kernel to restore state following * execution of the signal handler. It is also made available * to the handler to allow it to properly restore state if * a non-standard exit is performed. */ struct sigcontext { int sc_onstack; /* sigstack state to restore */ long sc_mask; /* signal mask to restore */ int sc_r1; /* r1 to restore */ int sc_r2; /* and other registers */ int sc_r3; int sc_r4; int sc_r5; int sc_r6; int sc_r7; int sc_r8; int sc_r9; int sc_r10; int sc_r11; int sc_r12; int sc_r13; int sc_r14; int sc_r15; int sc_r16; int sc_r17; int sc_r18; int sc_r19; int sc_r20; int sc_r21; int sc_r22; int sc_r23; int sc_r24; int sc_r25; int sc_gp; int sc_sp; /* sp to restore */ int sc_fp; int sc_ra; int sc_lo; int sc_hi; int sc_pc; /* pc to restore */ }; #endif /* !_MACHINE_SIGNAL_H_ */ ================================================ FILE: sys/arch/pic32/include/types.h ================================================ /* * Copyright (c) 2022 Christopher Hettrick * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #ifndef _MIPS_TYPES_H_ #define _MIPS_TYPES_H_ typedef struct label_t { unsigned val[12]; /* regs S0-S8, RA, GP and SP */ } label_t; #endif /* !_MIPS_TYPES_H_ */ ================================================ FILE: sys/arch/pic32/pic32/clock.c ================================================ /* * Copyright (c) 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * * @(#)clock.c 1.1 (2.10BSD Berkeley) 12/1/86 */ #include #include /* * Setup core timer for `hz' timer interrupts per second. */ void clkstart(void) { u_int count = mips_read_c0_register(C0_COUNT, 0); mips_write_c0_register(C0_COMPARE, 0, count + (CPU_KHZ * 1000 / HZ + 1) / 2); IECSET(0) = 1 << PIC32_IRQ_CT; } ================================================ FILE: sys/arch/pic32/pic32/conf.c ================================================ /* * Copyright (c) 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * * @(#)conf.c 3.2 (2.11BSD GTE) 1997/11/12 */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifdef SD_ENABLED #include #endif #ifdef RC_ENABLED #include #endif #ifdef DR_ENABLED #include #endif #ifdef MR_ENABLED #include #endif #ifdef SR_ENABLED #include #endif #ifdef UARTUSB_ENABLED #include #endif #ifdef ADC_ENABLED #include #endif #ifdef GLCD_ENABLED #include #endif #ifdef PWM_ENABLED #include #endif #ifdef PICGA_ENABLED #include #endif #ifdef PTY_ENABLED #include #endif #ifdef SKEL_ENABLED #include #endif #define __unused __attribute__((__unused__)) /* XXX */ int nullopen(dev_t dev __unused, int flag __unused, int mode __unused) { return 0; } int nullclose(dev_t dev __unused, int flag __unused, int mode __unused) { return 0; } int noopen(dev_t dev __unused, int flag __unused, int mode __unused) { return ENXIO; } int noclose(dev_t dev __unused, int flag __unused, int mode __unused) { return ENXIO; } int norw(dev_t dev __unused, struct uio *uio __unused, int flag __unused) { return 0; } int noioctl(dev_t dev __unused, u_int cmd __unused, caddr_t data __unused, int flag __unused) { return EIO; } int nullstop(struct tty *tp __unused, int flag __unused) { return 0; } /* * root attach routine. */ daddr_t nosize(dev_t dev __unused) { return 0; } #define NOBDEV \ noopen, noclose, nostrategy, \ nosize, noioctl, 0 /* * The RetroDisks require the same master number as the disk entry in the * rdisk.c file. A bit of a bind, but it means that the RetroDisk * devices must be numbered from master 0 upwards. */ const struct bdevsw bdevsw[] = { { /* 0 - sd */ #ifdef SD_ENABLED sdopen, sdclose, sdstrategy, sdsize, sdioctl, 0 #else NOBDEV #endif }, { /* 1 - sramc */ #ifdef RC_ENABLED sramc_open, sramc_close, sramc_strategy, sramc_size, sramc_ioctl, 0 #else NOBDEV #endif }, { /* 2 - sdramp */ #ifdef DR_ENABLED sdramp_open, sdramp_close, sdramp_strategy, sdramp_size, sdramp_ioctl, 0 #else NOBDEV #endif }, { /* 3 - mrams */ #ifdef MR_ENABLED mrams_open, mrams_close, mrams_strategy, mrams_size, mrams_ioctl, 0 #else NOBDEV #endif }, { /* 4 - swap */ swopen, swclose, swstrategy, swsize, swcioctl, 0 }, { /* 5 - spirams */ #ifdef SR_ENABLED spirams_open, spirams_close, spirams_strategy, spirams_size, spirams_ioctl, 0 #else NOBDEV #endif }, /* * End the list with a blank entry. */ { 0 }, }; const int nblkdev = sizeof(bdevsw) / sizeof(bdevsw[0]) - 1; #define NOCDEV \ noopen, noclose, norw, norw, \ noioctl, nullstop, 0, seltrue, \ nostrategy, 0, 0, const struct cdevsw cdevsw[] = { /* * Static drivers - every system has these: */ { /* 0 - console */ cnopen, cnclose, cnread, cnwrite, cnioctl, nullstop, cnttys, cnselect, nostrategy, 0, 0, }, { /* 1 - mem, kmem, null, zero */ #if MEM_MAJOR != 1 #error Wrong MEM_MAJOR value! #endif nullopen, nullclose, mmrw, mmrw, noioctl, nullstop, 0, seltrue, nostrategy, 0, 0, }, { /* 2 - tty */ syopen, nullclose, syread, sywrite, syioctl, nullstop, 0, syselect, nostrategy, 0, 0, }, { /* 3 - fd */ fdopen, nullclose, norw, norw, noioctl, nullstop, 0, seltrue, nostrategy, 0, 0, }, { /* 4 - temp (temporary allocation in swap space) */ swcopen, swcclose, swcread, swcwrite, swcioctl, nullstop, 0, seltrue, nostrategy, 0, 0, }, /* * Optional drivers from here on: */ { /* 5 - log */ #ifdef LOG_ENABLED logopen, logclose, logread, norw, logioctl, nullstop, 0, logselect, nostrategy, 0, 0, #else NOCDEV #endif }, { /* 6 - tty uart */ #if UART_MAJOR != 6 #error Wrong UART_MAJOR value! #endif #if defined(UART1_ENABLED) || defined(UART2_ENABLED) || \ defined(UART3_ENABLED) || defined(UART4_ENABLED) || \ defined(UART5_ENABLED) || defined(UART6_ENABLED) uartopen, uartclose, uartread, uartwrite, uartioctl, nullstop, uartttys, uartselect, nostrategy, uartgetc, uartputc, #else NOCDEV #endif }, { /* 7 - tty usb */ #if UARTUSB_MAJOR != 7 #error Wrong UARTUSB_MAJOR value! #endif #ifdef UARTUSB_ENABLED usbopen, usbclose, usbread, usbwrite, usbioctl, nullstop, usbttys, usbselect, nostrategy, usbgetc, usbputc, #else NOCDEV #endif }, { /* 8, 9 - pty */ #ifdef PTY_ENABLED ptsopen, ptsclose, ptsread, ptswrite, ptyioctl, nullstop, pt_tty, ptcselect, nostrategy, 0, 0, }, { ptcopen, ptcclose, ptcread, ptcwrite, ptyioctl, nullstop, pt_tty, ptcselect, nostrategy, 0, 0, #else NOCDEV }, { NOCDEV #endif }, { /* 10 - gpio */ #if defined(GPIO_ENABLED) || defined(GPIO1_ENABLED) || \ defined(GPIO2_ENABLED) || defined(GPIO3_ENABLED) || \ defined(GPIO4_ENABLED) || defined(GPIO5_ENABLED) || \ defined(GPIO6_ENABLED) gpioopen, gpioclose, gpioread, gpiowrite, gpioioctl, nullstop, 0, seltrue, nostrategy, 0, 0, #else NOCDEV #endif }, { /* 11 - adc */ #ifdef ADC_ENABLED adc_open, adc_close, adc_read, adc_write, adc_ioctl, nullstop, 0, seltrue, nostrategy, 0, 0, #else NOCDEV #endif }, { /* 12 - spi */ #if defined(SPI1_ENABLED) || defined(SPI2_ENABLED) || \ defined(SPI3_ENABLED) || defined(SPI4_ENABLED) spidev_open, spidev_close, spidev_read, spidev_write, spidev_ioctl, nullstop, 0, seltrue, nostrategy, 0, 0, #else NOCDEV #endif }, { /* 13 - glcd */ #ifdef GLCD_ENABLED glcd_open, glcd_close, glcd_read, glcd_write, glcd_ioctl, nullstop, 0, seltrue, nostrategy, 0, 0, #else NOCDEV #endif }, { /* 14 - pwm */ #ifdef PWM_ENABLED pwm_open, pwm_close, pwm_read, pwm_write, pwm_ioctl, nullstop, 0, seltrue, nostrategy, 0, 0, #else NOCDEV #endif }, { /* 15 - picga */ /* Ignore this for now - it's WIP. */ #ifdef PICGA_ENABLED picga_open, picga_close, picga_read, picga_write, picga_ioctl, nullstop, 0, seltrue, nostrategy, 0, 0, #else NOCDEV #endif }, { /* 16 - hxtft, gpanel, sgpanel */ /* * All LCD display drivers share the same device. * Only one such driver can be present in the kernel. */ #if GPANEL_MAJOR != 16 #error Wrong GPANEL_MAJOR value! #endif #if defined(HXTFT_ENABLED) || defined(GPANEL_ENABLED) || \ defined(SGPANEL_ENABLED) gpanel_open, gpanel_close, gpanel_read, gpanel_write, gpanel_ioctl, nullstop, 0, seltrue, nostrategy, 0, 0, #else NOCDEV #endif }, { /* 17 - skel */ #ifdef SKEL_ENABLED skeldev_open, skeldev_close, skeldev_read, skeldev_write, skeldev_ioctl, nullstop, 0, seltrue, nostrategy, 0, 0, #else NOCDEV #endif }, /* * End the list with a blank entry. */ { 0 }, }; const int nchrdev = sizeof(cdevsw) / sizeof(cdevsw[0]) - 1; /* * Routine that identifies /dev/mem and /dev/kmem. * * A minimal stub routine can always return 0. */ int iskmemdev(dev_t dev) { if (major(dev) == 1 && (minor(dev) == 0 || minor(dev) == 1)) return 1; return 0; } /* * Routine to determine if a device is a disk. * * A minimal stub routine can always return 0. */ int isdisk(dev_t dev, int type) { if (type != IFBLK) return 0; switch (major(dev)) { case 0: /* rd0 */ case 1: /* rd1 */ case 2: /* rd2 */ case 3: /* rd3 */ case 4: /* sw */ return 1; default: return 0; } /* NOTREACHED */ } /* * Routine to convert from character to block device number. * A minimal stub routine can always return NODEV. */ int chrtoblk(dev_t dev __unused) { return NODEV; } ================================================ FILE: sys/arch/pic32/pic32/exception.c ================================================ /* * Copyright (c) 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * * @(#)trap.c 1.6 (2.11BSD) 1999/9/13 */ #include #include #include #include #include #include #include #include #include #include #if 0 #define TRACE_EXCEPTIONS #endif #ifdef POWER_ENABLED extern void power_switch_check(); #endif /* * Copy of COP0 Debug register, saved by exception handler (in locore.S). */ int c0_debug; volatile unsigned int ct_ticks = 0; #ifdef TRACE_EXCEPTIONS static void print_args(narg, arg0, arg1, arg2, arg3, arg4, arg5) { void print_arg(val) { if (val & 0xff000000) printf("%08x", val); else printf("%u", val); } print_arg(arg0); if (narg > 1) { printf(", "); print_arg(arg1); } if (narg > 2) { printf(", "); print_arg(arg2); } if (narg > 3) { printf(", "); print_arg(arg3); } if (narg > 4) { printf(", "); print_arg(arg4); } if (narg > 5) { printf(", "); print_arg(arg5); } } #endif /* * Translate interrupt vector number to IRQ mask. */ static const unsigned mask_by_vector[] = { (1 << PIC32_IRQ_CT), /* 0 - Core Timer Interrupt */ (1 << PIC32_IRQ_CS0), /* 1 - Core Software Interrupt 0 */ (1 << PIC32_IRQ_CS1), /* 2 - Core Software Interrupt 1 */ (1 << PIC32_IRQ_INT0), /* 3 - External Interrupt 0 */ (1 << PIC32_IRQ_T1), /* 4 - Timer1 */ (1 << PIC32_IRQ_IC1), /* 5 - Input Capture 1 */ (1 << PIC32_IRQ_OC1), /* 6 - Output Compare 1 */ (1 << PIC32_IRQ_INT1), /* 7 - External Interrupt 1 */ (1 << PIC32_IRQ_T2), /* 8 - Timer2 */ (1 << PIC32_IRQ_IC2), /* 9 - Input Capture 2 */ (1 << PIC32_IRQ_OC2), /* 10 - Output Compare 2 */ (1 << PIC32_IRQ_INT2), /* 11 - External Interrupt 2 */ (1 << PIC32_IRQ_T3), /* 12 - Timer3 */ (1 << PIC32_IRQ_IC3), /* 13 - Input Capture 3 */ (1 << PIC32_IRQ_OC3), /* 14 - Output Compare 3 */ (1 << PIC32_IRQ_INT3), /* 15 - External Interrupt 3 */ (1 << PIC32_IRQ_T4), /* 16 - Timer4 */ (1 << PIC32_IRQ_IC4), /* 17 - Input Capture 4 */ (1 << PIC32_IRQ_OC4), /* 18 - Output Compare 4 */ (1 << PIC32_IRQ_INT4), /* 19 - External Interrupt 4 */ (1 << PIC32_IRQ_T5), /* 20 - Timer5 */ (1 << PIC32_IRQ_IC5), /* 21 - Input Capture 5 */ (1 << PIC32_IRQ_OC5), /* 22 - Output Compare 5 */ (1 << PIC32_IRQ_SPI1E) | /* 23 - SPI1 */ (1 << PIC32_IRQ_SPI1TX) | (1 << PIC32_IRQ_SPI1RX), (1 << PIC32_IRQ_U1E) | /* 24 - UART1 */ (1 << PIC32_IRQ_U1RX) | (1 << PIC32_IRQ_U1TX) | (1 << PIC32_IRQ_SPI3E) | /* 24 - SPI3 */ (1 << PIC32_IRQ_SPI3TX) | (1 << PIC32_IRQ_SPI3RX) | (1 << PIC32_IRQ_I2C3B) | /* 24 - I2C3 */ (1 << PIC32_IRQ_I2C3S) | (1 << PIC32_IRQ_I2C3M), (1 << PIC32_IRQ_I2C1B) | /* 25 - I2C1 */ (1 << PIC32_IRQ_I2C1S) | (1 << PIC32_IRQ_I2C1M), (1 << (PIC32_IRQ_CN-32)), /* 26 - Input Change Interrupt */ (1 << (PIC32_IRQ_AD1-32)), /* 27 - ADC1 Convert Done */ (1 << (PIC32_IRQ_PMP-32)), /* 28 - Parallel Master Port */ (1 << (PIC32_IRQ_CMP1-32)), /* 29 - Comparator Interrupt */ (1 << (PIC32_IRQ_CMP2-32)), /* 30 - Comparator Interrupt */ (1 << (PIC32_IRQ_U3E-32)) | /* 31 - UART3 */ (1 << (PIC32_IRQ_U3E-32)) | (1 << (PIC32_IRQ_U3E-32)) | (1 << (PIC32_IRQ_SPI2E-32)) | /* 31 - SPI2 */ (1 << (PIC32_IRQ_SPI2TX-32)) | (1 << (PIC32_IRQ_SPI2RX-32)) | (1 << (PIC32_IRQ_I2C4B-32)) | /* 31 - I2C4 */ (1 << (PIC32_IRQ_I2C4S-32)) | (1 << (PIC32_IRQ_I2C4M-32)), (1 << (PIC32_IRQ_U2E-32)) | /* 32 - UART2 */ (1 << (PIC32_IRQ_U2RX-32)) | (1 << (PIC32_IRQ_U2TX-32)) | (1 << (PIC32_IRQ_SPI4E-32)) | /* 32 - SPI4 */ (1 << (PIC32_IRQ_SPI4TX-32)) | (1 << (PIC32_IRQ_SPI4RX-32)) | (1 << (PIC32_IRQ_I2C5B-32)) | /* 32 - I2C5 */ (1 << (PIC32_IRQ_I2C5S-32)) | (1 << (PIC32_IRQ_I2C5M-32)), (1 << (PIC32_IRQ_I2C2B-32)) | /* 33 - I2C2 */ (1 << (PIC32_IRQ_I2C2S-32)) | (1 << (PIC32_IRQ_I2C2M-32)), (1 << (PIC32_IRQ_FSCM-32)), /* 34 - Fail-Safe Clock Monitor */ (1 << (PIC32_IRQ_RTCC-32)), /* 35 - Real-Time Clock and Calendar */ (1 << (PIC32_IRQ_DMA0-32)), /* 36 - DMA Channel 0 */ (1 << (PIC32_IRQ_DMA1-32)), /* 37 - DMA Channel 1 */ (1 << (PIC32_IRQ_DMA2-32)), /* 38 - DMA Channel 2 */ (1 << (PIC32_IRQ_DMA3-32)), /* 39 - DMA Channel 3 */ (1 << (PIC32_IRQ_DMA4-32)), /* 40 - DMA Channel 4 */ (1 << (PIC32_IRQ_DMA5-32)), /* 41 - DMA Channel 5 */ (1 << (PIC32_IRQ_DMA6-32)), /* 42 - DMA Channel 6 */ (1 << (PIC32_IRQ_DMA7-32)), /* 43 - DMA Channel 7 */ (1 << (PIC32_IRQ_FCE-32)), /* 44 - Flash Control Event */ (1 << (PIC32_IRQ_USB-32)), /* 45 - USB */ (1 << (PIC32_IRQ_CAN1-32)), /* 46 - Control Area Network 1 */ (1 << (PIC32_IRQ_CAN2-32)), /* 47 - Control Area Network 2 */ (1 << (PIC32_IRQ_ETH-32)), /* 48 - Ethernet Controller */ (1 << (PIC32_IRQ_U4E-64)) | /* 49 - UART4 */ (1 << (PIC32_IRQ_U4RX-64)) | (1 << (PIC32_IRQ_U4TX-64)), (1 << (PIC32_IRQ_U6E-64)) | /* 50 - UART6 */ (1 << (PIC32_IRQ_U6RX-64)) | (1 << (PIC32_IRQ_U6TX-64)), (1 << (PIC32_IRQ_U5E-64)) | /* 51 - UART5 */ (1 << (PIC32_IRQ_U5RX-64)) | (1 << (PIC32_IRQ_U5TX-64)) }; static void dumpregs(frame) struct trapframe *frame; { unsigned int cause; const char *code = 0; unsigned *stacktop = (unsigned*) 0x80007ffc; unsigned *p = (unsigned*) frame; printf("\n*** 0x%08x: exception ", frame->tf_pc); cause = mips_read_c0_register(C0_CAUSE, 0); switch (cause & CA_EXC_CODE) { case CA_Int: code = "Interrupt"; break; case CA_AdEL: code = "Address Load"; break; case CA_AdES: code = "Address Save"; break; case CA_IBE: code = "Bus fetch"; break; case CA_DBE: code = "Bus load/store"; break; case CA_Sys: code = "Syscall"; break; case CA_Bp: code = "Breakpoint"; break; case CA_RI: code = "Reserved Instruction"; break; case CA_CPU: code = "Coprocessor Unusable"; break; case CA_Ov: code = "Arithmetic Overflow"; break; case CA_Tr: code = "Trap"; break; } if (code) printf("'%s'\n", code); else printf("%d\n", cause >> 2 & 31); switch (cause & CA_EXC_CODE) { case CA_AdEL: case CA_AdES: printf("*** badvaddr = 0x%08x\n", mips_read_c0_register(C0_BADVADDR, 0)); } printf("*** stack frame at %8x\n", frame); while (p <= stacktop) { printf(" %8x", *p++); if (p <= stacktop) printf(" %8x", *p++); if (p <= stacktop) printf(" %8x", *p++); if (p <= stacktop) printf(" %8x", *p++); printf("\n"); } printf("*** registers:\n"); printf(" t0 = %8x s0 = %8x t8 = %8x lo = %8x\n", frame->tf_r8, frame->tf_r16, frame->tf_r24, frame->tf_lo); printf("at = %8x t1 = %8x s1 = %8x t9 = %8x hi = %8x\n", frame->tf_r1, frame->tf_r9, frame->tf_r17, frame->tf_r25, frame->tf_hi); printf("v0 = %8x t2 = %8x s2 = %8x status = %8x\n", frame->tf_r2, frame->tf_r10, frame->tf_r18, frame->tf_status); printf("v1 = %8x t3 = %8x s3 = %8x cause = %8x\n", frame->tf_r3, frame->tf_r11, frame->tf_r19, cause); printf("a0 = %8x t4 = %8x s4 = %8x gp = %8x epc = %8x\n", frame->tf_r4, frame->tf_r12, frame->tf_r20, frame->tf_gp, frame->tf_pc); printf("a1 = %8x t5 = %8x s5 = %8x sp = %8x\n", frame->tf_r5, frame->tf_r13, frame->tf_r21, frame->tf_sp); printf("a2 = %8x t6 = %8x s6 = %8x fp = %8x\n", frame->tf_r6, frame->tf_r14, frame->tf_r22, frame->tf_fp); printf("a3 = %8x t7 = %8x s7 = %8x ra = %8x\n", frame->tf_r7, frame->tf_r15, frame->tf_r23, frame->tf_ra); } /* * User mode flag added to cause code if exception is from user space. */ #define USER 1 /* * Called from locore.S when a processor exception occurs. * The argument is the array of registers saved on the system stack * by the hardware and software during the exception processing. */ void exception(frame) struct trapframe *frame; { register int psig; time_t syst; unsigned c, irq, status, cause, sp; led_control(LED_KERNEL, 1); if ((unsigned) frame < (unsigned) &u + sizeof(u)) { dumpregs(frame); panic("stack overflow"); /*NOTREACHED*/ } /* Switch to kernel mode, keep interrupts disabled. */ status = frame->tf_status; mips_write_c0_register(C0_STATUS, 0, status & ~(ST_UM | ST_EXL | ST_IE)); if (c0_debug & DB_DM) { cause = CA_Bp; c0_debug = 0; /* TODO: save DBD bit */ } else { cause = mips_read_c0_register(C0_CAUSE, 0); cause &= CA_EXC_CODE; } if (USERMODE(status)) cause |= USER; syst = u.u_ru.ru_stime; switch (cause) { /* * Exception. */ default: #ifdef UCB_METER cnt.v_trap++; #endif switch (cause) { default: /* Unknown exception: fatal kernel error */ dumpregs(frame); panic("unexpected exception"); /*NOTREACHED*/ case CA_IBE + USER: /* Bus error, instruction fetch */ case CA_DBE + USER: /* Bus error, load or store */ printf("*** 0x%08x: %s: bus error\n", frame->tf_pc, u.u_comm); psig = SIGBUS; break; case CA_RI + USER: /* Reserved instruction */ psig = SIGILL; break; case CA_Bp + USER: /* Breakpoint */ psig = SIGTRAP; break; case CA_Tr + USER: /* Trap */ psig = SIGIOT; break; case CA_CPU + USER: /* Coprocessor unusable */ psig = SIGEMT; break; case CA_Ov: /* Arithmetic overflow */ case CA_Ov + USER: psig = SIGFPE; break; case CA_AdEL + USER: /* Address error, load or instruction fetch */ case CA_AdES + USER: /* Address error, store */ printf("*** 0x%08x: %s: bad address 0x%08x\n", frame->tf_pc, u.u_comm, mips_read_c0_register(C0_BADVADDR, 0)); psig = SIGSEGV; break; } /* Enable interrupts. */ mips_intr_enable(); break; /* * Hardware interrupt. */ case CA_Int: /* Interrupt */ case CA_Int + USER: #ifdef UCB_METER cnt.v_intr++; #endif /* Get the current irq number */ c = INTSTAT; if ((c & PIC32_INTSTAT_SRIPL_MASK) == 0) { /* printf("*** unexpected interrupt: INTSTAT %08x\n", c); */ goto ret; } irq = PIC32_INTSTAT_VEC(c); /* Handle the interrupt. */ switch (irq) { case PIC32_VECT_CT: /* Core Timer */ ct_ticks++; /* Increment COMPARE register. */ IFSCLR(0) = 1 << PIC32_IRQ_CT; c = mips_read_c0_register(C0_COMPARE, 0); do { c += (CPU_KHZ * 1000 / HZ + 1) / 2; mips_write_c0_register(C0_COMPARE, 0, c); } while ((int) (c - (unsigned)mips_read_c0_register(C0_COUNT, 0)) < 0); hardclock((caddr_t) frame->tf_pc, status); #ifdef POWER_ENABLED power_switch_check(); #endif #ifdef UARTUSB_ENABLED /* Poll USB on every timer tick. */ usbintr(0); #endif break; #ifdef UART1_ENABLED case PIC32_VECT_U1: /* UART1 */ uartintr(makedev(UART_MAJOR, 0)); break; #endif #ifdef UART2_ENABLED case PIC32_VECT_U2: /* UART2 */ uartintr(makedev(UART_MAJOR, 1)); break; #endif #ifdef UART3_ENABLED case PIC32_VECT_U3: /* UART3 */ uartintr(makedev(UART_MAJOR, 2)); break; #endif #ifdef UART4_ENABLED case PIC32_VECT_U4: /* UART4 */ uartintr(makedev(UART_MAJOR, 3)); break; #endif #ifdef UART5_ENABLED case PIC32_VECT_U5: /* UART5 */ uartintr(makedev(UART_MAJOR, 4)); break; #endif #ifdef UART6_ENABLED case PIC32_VECT_U6: /* UART6 */ uartintr(makedev(UART_MAJOR, 5)); break; #endif #ifdef UARTUSB_ENABLED case PIC32_VECT_USB: /* USB */ IFSCLR(1) = 1 << (PIC32_IRQ_USB - 32); usbintr(0); break; #endif default: /* Disable the irq, to avoid loops */ printf("*** irq %u\n", irq); if (irq < PIC32_VECT_CN) { IECCLR(0) = mask_by_vector [irq]; IFSCLR(0) = mask_by_vector [irq]; } else { IECCLR(1) = mask_by_vector [irq]; IFSCLR(1) = mask_by_vector [irq]; } break; } if ((cause & USER) && runrun) { /* Need to switch processes: in user mode only. * Enable interrupts first. */ /* MADSCIFI start new code */ /* u.u_error = 0; */ u.u_frame = frame; u.u_code = frame->tf_pc; /* For signal handler */ /* Check stack. */ sp = frame->tf_sp; if (sp < u.u_procp->p_daddr + u.u_dsize) { /* Process has trashed its stack; give it an illegal * instruction violation to halt it in its tracks. */ panic("unexpected exception 2"); psig = SIGSEGV; break; } if (u.u_procp->p_ssize < USER_DATA_END - sp) { /* Expand stack. */ u.u_procp->p_ssize = USER_DATA_END - sp; u.u_procp->p_saddr = sp; u.u_ssize = u.u_procp->p_ssize; } /* MADSCIFI end new code */ mips_intr_enable(); goto out; } goto ret; /* * System call. */ case CA_Sys + USER: /* Syscall */ #ifdef UCB_METER cnt.v_syscall++; #endif /* Enable interrupts. */ mips_intr_enable(); u.u_error = 0; u.u_frame = frame; u.u_code = frame->tf_pc; /* For signal handler */ /* Check stack. */ sp = frame->tf_sp; if (sp < u.u_procp->p_daddr + u.u_dsize) { /* Process has trashed its stack; give it an illegal * instruction violation to halt it in its tracks. */ psig = SIGSEGV; break; } if (u.u_procp->p_ssize < USER_DATA_END - sp) { /* Expand stack. */ u.u_procp->p_ssize = USER_DATA_END - sp; u.u_procp->p_saddr = sp; u.u_ssize = u.u_procp->p_ssize; } /* Original pc for restarting syscalls */ int opc = frame->tf_pc; /* opc points at syscall */ frame->tf_pc = opc + 3*NBPW; /* no errors - skip 2 next instructions */ const struct sysent *callp = &sysent[0]; int code = (*(u_int*) opc >> 6) & 0377; /* bottom 8 bits are index */ if (code < nsysent) callp += code; if (callp->sy_narg) { u.u_arg[0] = frame->tf_r4; /* $a0 */ u.u_arg[1] = frame->tf_r5; /* $a1 */ u.u_arg[2] = frame->tf_r6; /* $a2 */ u.u_arg[3] = frame->tf_r7; /* $a3 */ if (callp->sy_narg > 4) { unsigned addr = (frame->tf_sp + 16) & ~3; if (! baduaddr((caddr_t) addr)) u.u_arg[4] = *(unsigned*) addr; } if (callp->sy_narg > 5) { unsigned addr = (frame->tf_sp + 20) & ~3; if (! baduaddr((caddr_t) addr)) u.u_arg[5] = *(unsigned*) addr; } } #ifdef TRACE_EXCEPTIONS printf("--- (%u)syscall: %s (", u.u_procp->p_pid, syscallnames [code >= nsysent ? 0 : code]); if (callp->sy_narg > 0) print_args(callp->sy_narg, u.u_arg[0], u.u_arg[1], u.u_arg[2], u.u_arg[3], u.u_arg[4], u.u_arg[5]); printf(") at %08x\n", opc); #endif u.u_rval = 0; if (setjmp(&u.u_qsave) == 0) { (*callp->sy_call)(); } switch (u.u_error) { case 0: #ifdef TRACE_EXCEPTIONS printf(" (%u)syscall returned %u\n", u.u_procp->p_pid, u.u_rval); #endif frame->tf_r2 = u.u_rval; /* $v0 - result */ break; case ERESTART: #ifdef TRACE_EXCEPTIONS printf(" (%u)syscall restarted at %#x\n", u.u_procp->p_pid, opc); #endif frame->tf_pc = opc; /* return to syscall */ break; case EJUSTRETURN: /* return from signal handler */ #ifdef TRACE_EXCEPTIONS printf(" (%u)jump to %#x, stack %#x\n", u.u_procp->p_pid, frame->tf_pc, frame->tf_sp); #endif break; default: #ifdef TRACE_EXCEPTIONS printf(" (%u)syscall failed, errno %d\n", u.u_procp->p_pid, u.u_error); #endif frame->tf_pc = opc + NBPW; /* return to next instruction */ frame->tf_r2 = -1; /* $v0 - result */ frame->tf_r8 = u.u_error; /* $t0 - errno */ break; } goto out; } /* From this point and further the interrupts must be enabled. */ psignal(u.u_procp, psig); out: userret(frame->tf_pc, syst); ret: led_control(LED_KERNEL, 0); } void sc_msec() { u.u_rval = ct_ticks * (1000 / HZ); } ================================================ FILE: sys/arch/pic32/pic32/locore.S ================================================ # # Startup code for Microchip PIC32 microcontrollers. # Using HID bootloader. # # Copyright (C) 2010 Serge Vakulenko, # # Permission to use, copy, modify, and distribute this software # and its documentation for any purpose and without fee is hereby # granted, provided that the above copyright notice appear in all # copies and that both that the copyright notice and this # permission notice and warranty disclaimer appear in supporting # documentation, and that the name of the author not be used in # advertising or publicity pertaining to distribution of the # software without specific, written prior permission. # # The author disclaim all warranties with regard to this # software, including all implied warranties of merchantability # and fitness. In no event shall the author be liable for any # special, indirect or consequential damages or any damages # whatsoever resulting from loss of use, data or profits, whether # in an action of contract, negligence or other tortious action, # arising out of or in connection with the use or performance of # this software. # #include #define UBASE 0x7f008000 /* User space base address */ .set noreorder .set mips32r2 .set nomips16 .extern u .extern u_end .extern u0 .extern main .extern exception #--------------------------------------- # Reset vector: main entry point # .section .startup,"ax",@progbits .org 0 .type _reset_vector_, @function _reset_vector_: .globl _reset_vector_ .set noat move $1, $zero # Clear all regs move $2, $zero move $3, $zero move $4, $zero move $5, $zero move $6, $zero move $7, $zero move $8, $zero move $9, $zero move $10, $zero move $11, $zero move $12, $zero move $13, $zero move $14, $zero move $15, $zero move $16, $zero move $17, $zero move $18, $zero move $19, $zero move $20, $zero move $21, $zero move $22, $zero move $23, $zero move $24, $zero move $25, $zero move $26, $zero move $27, $zero move $28, $zero move $29, $zero move $30, $zero move $31, $zero mtlo $zero mthi $zero .set at la $sp, u_end - 16 # Stack at end of U area la $a0, main jalr $a0 # Jump to main() lui $gp, 0x8000 # Set global pointer (delay slot) la $k0, UBASE mtc0 $k0, $C0_EPC # Entry to user code. mfc0 $k0, $C0_STATUS ori $k0, $k0, ST_UM | ST_EXL | ST_IE # Set user mode and enable interrupts mtc0 $k0, $C0_STATUS # Put SR back eret # PC <= EPC; EXL <= 0 nop # just to be safe #--------------------------------------- # Secondary entry point for RetroBSD bootloader. # .section .exception,"ax",@progbits _exception_base_: .globl _exception_base_ .org 0 .type _entry_vector_, @function _entry_vector_: .globl _entry_vector_ la $k0, _reset_vector_ jr $k0 nop /* * Data for bootloader. */ .org 0xf8 .type _ebase, @object _ebase: .word 0x9d000000 # EBase value .type _imgptr, @object _imgptr: .word -1 # Image header pointer #--------------------------------------- # Exception vector: handle exceptions # .org 0x180 .type _exception_vector_, @function _exception_vector_: .globl _exception_vector_ b _interrupt_vector_ nop #--------------------------------------- # Interrupt vector: handle interrupts # .org 0x200 .type _interrupt_vector_, @function _interrupt_vector_: .globl _interrupt_vector_ mfc0 $k0, $C0_STATUS andi $k1, $k0, ST_UM # Check user mode beqz $k1, kernel_exception move $k1, $sp # # Exception in user mode: switch stack. # user_exception: la $sp, u_end # Stack at end of U area kernel_exception: addi $sp, -16-FRAME_WORDS*4 # Allocate space for registers save_regs: sw $k0, (16+FRAME_STATUS*4) ($sp) sw $k1, (16+FRAME_SP*4) ($sp) .set noat sw $1, (16+FRAME_R1*4) ($sp) # Save general registers sw $2, (16+FRAME_R2*4) ($sp) sw $3, (16+FRAME_R3*4) ($sp) sw $4, (16+FRAME_R4*4) ($sp) sw $5, (16+FRAME_R5*4) ($sp) sw $6, (16+FRAME_R6*4) ($sp) sw $7, (16+FRAME_R7*4) ($sp) sw $8, (16+FRAME_R8*4) ($sp) sw $9, (16+FRAME_R9*4) ($sp) sw $10, (16+FRAME_R10*4) ($sp) sw $11, (16+FRAME_R11*4) ($sp) sw $12, (16+FRAME_R12*4) ($sp) sw $13, (16+FRAME_R13*4) ($sp) sw $14, (16+FRAME_R14*4) ($sp) sw $15, (16+FRAME_R15*4) ($sp) sw $16, (16+FRAME_R16*4) ($sp) sw $17, (16+FRAME_R17*4) ($sp) sw $18, (16+FRAME_R18*4) ($sp) sw $19, (16+FRAME_R19*4) ($sp) sw $20, (16+FRAME_R20*4) ($sp) sw $21, (16+FRAME_R21*4) ($sp) sw $22, (16+FRAME_R22*4) ($sp) sw $23, (16+FRAME_R23*4) ($sp) sw $24, (16+FRAME_R24*4) ($sp) sw $25, (16+FRAME_R25*4) ($sp) # Skip $26 - K0 # Skip $27 - K1 sw $28, (16+FRAME_GP*4) ($sp) # Skip $29 - SP sw $30, (16+FRAME_FP*4) ($sp) sw $31, (16+FRAME_RA*4) ($sp) .set at mfhi $k0 # Save special registers sw $k0, (16+FRAME_HI*4) ($sp) mflo $k0 sw $k0, (16+FRAME_LO*4) ($sp) mfc0 $k0, $C0_EPC sw $k0, (16+FRAME_PC*4) ($sp) move $a0, $sp addi $a0, 16 # Arg 0: saved regs. jal exception # Call C code. lui $gp, 0x8000 # Set global pointer (delay slot) # # Restore CPU state and return from interrupt. # restore_regs: lw $a0, (16+FRAME_LO*4) ($sp) # Load HI, LO registers mtlo $a0 lw $a0, (16+FRAME_HI*4) ($sp) mthi $a0 .set noat lw $1, (16+FRAME_R1*4) ($sp) # Load general registers lw $2, (16+FRAME_R2*4) ($sp) lw $3, (16+FRAME_R3*4) ($sp) lw $4, (16+FRAME_R4*4) ($sp) lw $5, (16+FRAME_R5*4) ($sp) lw $6, (16+FRAME_R6*4) ($sp) lw $7, (16+FRAME_R7*4) ($sp) lw $8, (16+FRAME_R8*4) ($sp) lw $9, (16+FRAME_R9*4) ($sp) lw $10, (16+FRAME_R10*4) ($sp) lw $11, (16+FRAME_R11*4) ($sp) lw $12, (16+FRAME_R12*4) ($sp) lw $13, (16+FRAME_R13*4) ($sp) lw $14, (16+FRAME_R14*4) ($sp) lw $15, (16+FRAME_R15*4) ($sp) lw $16, (16+FRAME_R16*4) ($sp) lw $17, (16+FRAME_R17*4) ($sp) lw $18, (16+FRAME_R18*4) ($sp) lw $19, (16+FRAME_R19*4) ($sp) lw $20, (16+FRAME_R20*4) ($sp) lw $21, (16+FRAME_R21*4) ($sp) lw $22, (16+FRAME_R22*4) ($sp) lw $23, (16+FRAME_R23*4) ($sp) lw $24, (16+FRAME_R24*4) ($sp) lw $25, (16+FRAME_R25*4) ($sp) # Skip $26 - K0 # Skip $27 - K1 lw $28, (16+FRAME_GP*4) ($sp) # Skip $29 - SP lw $30, (16+FRAME_FP*4) ($sp) .set at # Do not use k0/k1 here, as interrupts are still enabled lw $31, (16+FRAME_STATUS*4) ($sp) # K0 = saved status ori $31, ST_EXL # Set EXL mtc0 $31, $C0_STATUS # put SR back: disable interrupts ehb lw $k0, (16+FRAME_PC*4) ($sp) # K0 = EPC mtc0 $k0, $C0_EPC # put PC in EPC ext $k1, $31, 27, 1 # get RP bit: single-step request lw $31, (16+FRAME_RA*4) ($sp) lw $sp, (16+FRAME_SP*4) ($sp) # Restore stack # Return from exception bnez $k1, debug_request # single-step request eret # PC <= EPC; EXL <= 0 debug_request: sdbbp # enter debug mode #--------------------------------------- # Debug exception processing. # .org 0x480 .type _debug_vector_, @function _debug_vector_: .globl _debug_vector_ mfc0 $k0, $C0_DEPC la $k1, debug_request bne $k0, $k1, single_step_done nop # single step request mfc0 $k0, $C0_DEBUG ori $k0, DB_SST # set SST bit mtc0 $k0, $C0_DEBUG mfc0 $k1, $C0_EPC mtc0 $k1, $C0_DEPC # DEPC <= EPC mfc0 $k0, $C0_STATUS xori $k0, ST_EXL # Clear EXL mtc0 $k0, $C0_STATUS deret # PC <= DEPC; DM <= 0 # A single instruction of the user program # is executed here, then jump to _debug_vector_ # with updated DEPC. # Continue below. single_step_done: mtc0 $k0, $C0_EPC # EPC <= DEPC la $k1, _exception_vector_ mtc0 $k1, $C0_DEPC # DEPC <= exception handler mfc0 $k0, $C0_DEBUG sw $k0, c0_debug # save Debug register ori $k0, DB_SST xori $k0, DB_SST # clear SST bit mtc0 $k0, $C0_DEBUG mfc0 $k1, $C0_STATUS ori $k1, ST_EXL # Set EXL mtc0 $k1, $C0_STATUS deret # PC <= DEPC; DM <= 0 #--------------------------------------- # Icode is copied out to process 1 to exec /sbin/init. # If the exec fails, process 1 exits. # .globl icode, icodeend, initflags .type icode, @function .type icodeend, @function .type etcinit, @object .type argv, @object icode: la $a0, UBASE move $a1, $a0 addi $a0, etcinit - icode addi $a1, argv - icode syscall 11 # SYS_execv move $a0, $v0 syscall 1 # SYS_exit etcinit: .ascii "/sbin/init\0" .align 2 initflags: .ascii "-\0\0\0\0\0\0\0\0\0\0" # space for options argv: .word etcinit + 6 - icode + UBASE # address of "init\0" .word initflags - icode + UBASE # init options .word 0 icodeend: nop #--------------------------------------- # int setjmp (label_t *env); # # Setjmp(env) will save the process' current register variables, stack # and program counter context and return a zero. # .type setjmp, @function setjmp: .globl setjmp sw $s0, (0 * 4) ($a0) # save register variables s0-s8 sw $s1, (1 * 4) ($a0) sw $s2, (2 * 4) ($a0) sw $s3, (3 * 4) ($a0) sw $s4, (4 * 4) ($a0) sw $s5, (5 * 4) ($a0) sw $s6, (6 * 4) ($a0) sw $s7, (7 * 4) ($a0) sw $s8, (8 * 4) ($a0) # frame pointer sw $ra, (9 * 4) ($a0) # return address sw $gp, (10 * 4) ($a0) # global data pointer sw $sp, (11 * 4) ($a0) # stack pointer j $ra move $v0, $zero # return a zero for the setjmp call #--------------------------------------- # void longjmp (memaddr uaddr, label_t *env); # # Longjmp(uaddr, env) will generate a "return(1)" from the last # call to setjmp(env) by mapping in the user structure pointed to by uaddr, # restoring the context saved by setjmp in env and returning a "1". # Note that registers are recovered statically from the env buffer. # Stack is not used. # # This longjmp differs from the longjmp found in the standard library - # it's actually closer to the resume routine of the 4.3BSD kernel. # .type longjmp, @function longjmp: .globl longjmp di # can't let anything in till we get a valid stack... la $v0, u # pointer to &u beq $v0, $a0, 2f # if uaddr == &u... nop # ...no need to remap U area la $a3, u_end # pointer to &u + USIZE la $a0, u0 # pointer to &u0 lw $v1, 0($v0) # u.u_procp sw $a0, 60($v1) # u.u_procp->p_addr = &u0 # exchange contents of u and u0 move $v1, $v0 1: lw $t1, 0($v1) lw $t0, 0($a0) sw $t0, 0($v1) sw $t1, 0($a0) lw $t1, 4($v1) lw $t0, 4($a0) sw $t0, 4($v1) sw $t1, 4($a0) lw $t1, 8($v1) lw $t0, 8($a0) sw $t0, 8($v1) sw $t1, 8($a0) lw $t1, 12($v1) lw $t0, 12($a0) sw $t0, 12($v1) sw $t1, 12($a0) addiu $v1, $v1, 16 bne $a3, $v1, 1b addiu $a0, $a0, 16 lw $v1, 0($v0) # u.u_procp sw $v0, 60($v1) # u.u_procp->p_addr = &u 2: lw $s0, (0 * 4) ($a1) # restore register variables s0-s8 lw $s1, (1 * 4) ($a1) lw $s2, (2 * 4) ($a1) lw $s3, (3 * 4) ($a1) lw $s4, (4 * 4) ($a1) lw $s5, (5 * 4) ($a1) lw $s6, (6 * 4) ($a1) lw $s7, (7 * 4) ($a1) lw $s8, (8 * 4) ($a1) # frame pointer lw $ra, (9 * 4) ($a1) # return address lw $gp, (10 * 4) ($a1) # global data pointer lw $sp, (11 * 4) ($a1) # stack pointer ei # release interrupts j $ra # transfer back to setjmp() li $v0, 1 # return value of 1 ================================================ FILE: sys/arch/pic32/pic32/machdep.c ================================================ /* * Copyright (c) 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * * @(#)machdep.c 2.4 (2.11BSD) 1999/9/13 */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifdef UARTUSB_ENABLED # include # include #endif #ifdef POWER_ENABLED extern void power_init(); extern void power_off(); #endif #ifdef LED_TTY_INVERT #define LED_TTY_ON() LAT_CLR(LED_TTY_PORT) = 1 << LED_TTY_PIN #define LED_TTY_OFF() LAT_SET(LED_TTY_PORT) = 1 << LED_TTY_PIN #else #define LED_TTY_ON() LAT_SET(LED_TTY_PORT) = 1 << LED_TTY_PIN #define LED_TTY_OFF() LAT_CLR(LED_TTY_PORT) = 1 << LED_TTY_PIN #endif #ifdef LED_DISK_INVERT #define LED_DISK_ON() LAT_CLR(LED_DISK_PORT) = 1 << LED_DISK_PIN #define LED_DISK_OFF() LAT_SET(LED_DISK_PORT) = 1 << LED_DISK_PIN #else #define LED_DISK_ON() LAT_SET(LED_DISK_PORT) = 1 << LED_DISK_PIN #define LED_DISK_OFF() LAT_CLR(LED_DISK_PORT) = 1 << LED_DISK_PIN #endif #ifdef LED_KERNEL_INVERT #define LED_KERNEL_ON() LAT_CLR(LED_KERNEL_PORT) = 1 << LED_KERNEL_PIN #define LED_KERNEL_OFF() LAT_SET(LED_KERNEL_PORT) = 1 << LED_KERNEL_PIN #else #define LED_KERNEL_ON() LAT_SET(LED_KERNEL_PORT) = 1 << LED_KERNEL_PIN #define LED_KERNEL_OFF() LAT_CLR(LED_KERNEL_PORT) = 1 << LED_KERNEL_PIN #endif #ifdef LED_SWAP_INVERT #define LED_SWAP_ON() LAT_CLR(LED_SWAP_PORT) = 1 << LED_SWAP_PIN #define LED_SWAP_OFF() LAT_SET(LED_SWAP_PORT) = 1 << LED_SWAP_PIN #else #define LED_SWAP_ON() LAT_SET(LED_SWAP_PORT) = 1 << LED_SWAP_PIN #define LED_SWAP_OFF() LAT_CLR(LED_SWAP_PORT) = 1 << LED_SWAP_PIN #endif #ifdef LED_MISC1_INVERT #define LED_MISC1_ON() LAT_CLR(LED_MISC1_PORT) = 1 << LED_MISC1_PIN #define LED_MISC1_OFF() LAT_SET(LED_MISC1_PORT) = 1 << LED_MISC1_PIN #else #define LED_MISC1_ON() LAT_SET(LED_MISC1_PORT) = 1 << LED_MISC1_PIN #define LED_MISC1_OFF() LAT_CLR(LED_MISC1_PORT) = 1 << LED_MISC1_PIN #endif #ifdef LED_MISC2_INVERT #define LED_MISC2_ON() LAT_CLR(LED_MISC2_PORT) = 1 << LED_MISC2_PIN #define LED_MISC2_OFF() LAT_SET(LED_MISC2_PORT) = 1 << LED_MISC2_PIN #else #define LED_MISC2_ON() LAT_SET(LED_MISC2_PORT) = 1 << LED_MISC2_PIN #define LED_MISC2_OFF() LAT_CLR(LED_MISC2_PORT) = 1 << LED_MISC2_PIN #endif #ifdef LED_MISC3_INVERT #define LED_MISC3_ON() LAT_CLR(LED_MISC3_PORT) = 1 << LED_MISC3_PIN #define LED_MISC3_OFF() LAT_SET(LED_MISC3_PORT) = 1 << LED_MISC3_PIN #else #define LED_MISC3_ON() LAT_SET(LED_MISC3_PORT) = 1 << LED_MISC3_PIN #define LED_MISC3_OFF() LAT_CLR(LED_MISC3_PORT) = 1 << LED_MISC3_PIN #endif #ifdef LED_MISC4_INVERT #define LED_MISC4_ON() LAT_CLR(LED_MISC4_PORT) = 1 << LED_MISC4_PIN #define LED_MISC4_OFF() LAT_SET(LED_MISC4_PORT) = 1 << LED_MISC4_PIN #else #define LED_MISC4_ON() LAT_SET(LED_MISC4_PORT) = 1 << LED_MISC4_PIN #define LED_MISC4_OFF() LAT_CLR(LED_MISC4_PORT) = 1 << LED_MISC4_PIN #endif char machine[] = MACHINE; /* from */ char machine_arch[] = MACHINE_ARCH; /* from */ char cpu_model[64]; int hz = HZ; int usechz = (1000000L + HZ - 1) / HZ; #ifdef TIMEZONE struct timezone tz = { TIMEZONE, DST }; #else struct timezone tz = { 8*60, 1 }; #endif int nproc = NPROC; struct namecache namecache [NNAMECACHE]; char bufdata [NBUF * MAXBSIZE]; struct inode inode [NINODE]; struct callout callout [NCALL]; struct mount mount [NMOUNT]; struct buf buf [NBUF], bfreelist [BQUEUES]; struct bufhd bufhash [BUFHSZ]; struct cblock cfree [NCLIST]; struct proc proc [NPROC]; struct file file [NFILE]; /* * Remove the ifdef/endif to run the kernel in unsecure mode even when in * a multiuser state. Normally 'init' raises the security level to 1 * upon transitioning to multiuser. Setting the securelevel to -1 prevents * the secure level from being raised by init. */ #ifdef PERMANENTLY_INSECURE int securelevel = -1; #else int securelevel = 0; #endif struct mapent swapent[SMAPSIZ]; struct map swapmap[1] = { { swapent, &swapent[SMAPSIZ], "swapmap" }, }; int waittime = -1; /* CPU package type: 64 pins or 100 pins. */ int cpu_pins; static int nodump(dev) dev_t dev; { printf("\ndumping to dev %o off %D: not implemented\n", dumpdev, dumplo); return 0; } int (*dump)(dev_t) = nodump; dev_t pipedev; daddr_t dumplo = (daddr_t) 1024; /* * Check whether button 1 is pressed. */ static inline int button1_pressed() { #ifdef BUTTON1_PORT int val; TRIS_SET(BUTTON1_PORT) = 1 << BUTTON1_PIN; val = PORT_VAL(BUTTON1_PORT); #ifdef BUTTON1_INVERT val = ~val; #endif return (val >> BUTTON1_PIN) & 1; #else return 0; #endif } /* * Machine dependent startup code */ void startup() { extern void _etext(), _exception_base_(); extern unsigned __data_start; /* Initialize STATUS register: master interrupt disable. * Setup interrupt vector base. */ mips_write_c0_register(C0_STATUS, 0, ST_CU0 | ST_BEV); mips_write_c0_register(C0_EBASE, 1, _exception_base_); mips_write_c0_register(C0_STATUS, 0, ST_CU0); /* Set vector spacing: not used really, but must be nonzero. */ mips_write_c0_register(C0_INTCTL, 1, 32); /* Clear CAUSE register: use special interrupt vector 0x200. */ mips_write_c0_register(C0_CAUSE, 0, CA_IV); /* Setup memory. */ BMXPUPBA = 512 << 10; /* Kernel Flash memory size */ #ifdef KERNEL_EXECUTABLE_RAM /* * Set boundry for kernel executable ram on smallest * 2k boundry required to allow the keram segment to fit. * This means that there is possibly some u0area ramspace that * is executable, but as it is isolated from userspace this * should be ok, given the apparent goals of this project. */ extern void _keram_start(), _keram_end(); unsigned keram_size = (((char*)&_keram_end-(char*)&_keram_start+(2<<10))/(2<<10)*(2<<10)); BMXDKPBA = ((32<<10)-keram_size); /* Kernel RAM size */ BMXDUDBA = BMXDKPBA+(keram_size); /* Executable RAM in kernel */ #else BMXDKPBA = 32 << 10; /* Kernel RAM size */ BMXDUDBA = BMXDKPBA; /* Zero executable RAM in kernel */ #endif BMXDUPBA = BMXDUDBA; /* All user RAM is executable */ /* * Setup interrupt controller. */ INTCON = 0; /* Interrupt Control */ IPTMR = 0; /* Temporal Proximity Timer */ /* Interrupt Flag Status */ IFS(0) = PIC32_IPC_IP0(2) | PIC32_IPC_IP1(1) | PIC32_IPC_IP2(1) | PIC32_IPC_IP3(1) | PIC32_IPC_IS0(0) | PIC32_IPC_IS1(0) | PIC32_IPC_IS2(0) | PIC32_IPC_IS3(0) ; IFS(1) = 0; IFS(2) = 0; /* Interrupt Enable Control */ IEC(0) = 0; IEC(1) = 0; IEC(2) = 0; /* Interrupt Priority Control */ unsigned ipc = PIC32_IPC_IP0(1) | PIC32_IPC_IP1(1) | PIC32_IPC_IP2(1) | PIC32_IPC_IP3(1) | PIC32_IPC_IS0(0) | PIC32_IPC_IS1(0) | PIC32_IPC_IS2(0) | PIC32_IPC_IS3(0) ; IPC(0) = ipc; IPC(1) = ipc; IPC(2) = ipc; IPC(3) = ipc; IPC(4) = ipc; IPC(5) = ipc; IPC(6) = ipc; IPC(7) = ipc; IPC(8) = ipc; IPC(9) = ipc; IPC(10) = ipc; IPC(11) = ipc; IPC(12) = ipc; /* * Setup wait states. */ CHECON = 2; BMXCONCLR = 0x40; CHECONSET = 0x30; /* Disable JTAG port, to use it for i/o. */ DDPCON = 0; /* Use all B ports as digital. */ AD1PCFG = ~0; /* Config register: enable kseg0 caching. */ mips_write_c0_register(C0_CONFIG, 0, mips_read_c0_register(C0_CONFIG, 0) | 3); /* Kernel mode, interrupts disabled. */ mips_write_c0_register(C0_STATUS, 0, ST_CU0); mips_ehb(); /* * Configure LED pins. */ #ifdef LED_TTY_PORT /* Terminal i/o */ LED_TTY_OFF(); TRIS_CLR(LED_TTY_PORT) = 1 << LED_TTY_PIN; #endif #ifdef LED_DISK_PORT /* Disk i/o */ LED_DISK_OFF(); TRIS_CLR(LED_DISK_PORT) = 1 << LED_DISK_PIN; #endif #ifdef LED_KERNEL_PORT /* Kernel activity */ LED_KERNEL_OFF(); TRIS_CLR(LED_KERNEL_PORT) = 1 << LED_KERNEL_PIN; #endif #ifdef LED_SWAP_PORT /* Auxiliary */ LED_SWAP_OFF(); TRIS_CLR(LED_SWAP_PORT) = 1 << LED_SWAP_PIN; #endif #ifdef GPIO_CLEAR_PORT /* Clear pin */ LAT_CLR(GPIO_CLEAR_PORT) = 1 << GPIO_CLEAR_PIN; TRIS_CLR(GPIO_CLEAR_PORT) = 1 << GPIO_CLEAR_PIN; #endif #ifdef POWER_ENABLED power_init(); #endif /* SETVAL(0); */ /* Initialize .data + .bss segments by zeroes. */ bzero(&__data_start, KERNEL_DATA_SIZE - 96); #if __MPLABX__ /* Microchip C32 compiler generates a .dinit table with * initialization values for .data segment. */ extern const unsigned _dinit_addr[]; unsigned const *dinit = &_dinit_addr[0]; for (;;) { char *dst = (char*) (*dinit++); if (dst == 0) break; unsigned nbytes = *dinit++; unsigned fmt = *dinit++; if (fmt == 0) { /* Clear */ do { *dst++ = 0; } while (--nbytes > 0); } else { /* Copy */ char *src = (char*) dinit; do { *dst++ = *src++; } while (--nbytes > 0); dinit = (unsigned*) ((unsigned) (src + 3) & ~3); } } #else /* Copy the .data image from flash to ram. * Linker places it at the end of .text segment. */ extern unsigned _edata; unsigned *src = (unsigned*) &_etext; unsigned *dest = &__data_start; unsigned *limit = &_edata; while (dest < limit) { /* printf("copy %08x from (%08x) to (%08x)\n", *src, src, dest); */ *dest++ = *src++; } #ifdef KERNEL_EXECUTABLE_RAM /* Copy code that must run out of ram (due to timing restrictions) * from flash to the executable section of kernel ram. * This was added to support swap on sdram */ extern void _ramfunc_image_begin(); extern void _ramfunc_begin(); extern void _ramfunc_end(); unsigned *src1 = (unsigned*) &_ramfunc_image_begin; unsigned *dest1 = (unsigned*)&_ramfunc_begin; unsigned *limit1 = (unsigned*)&_ramfunc_end; /* printf("copy from (%08x) to (%08x)\n", src1, dest1); */ while (dest1 < limit1) { *dest1++ = *src1++; } #endif #endif /* __MPLABX__ */ /* * Setup peripheral bus clock divisor. */ unsigned osccon = OSCCON & ~PIC32_OSCCON_PBDIV_MASK; #if BUS_DIV == 1 osccon |= PIC32_OSCCON_PBDIV_1; #elif BUS_DIV == 2 osccon |= PIC32_OSCCON_PBDIV_2; #elif BUS_DIV == 4 osccon |= PIC32_OSCCON_PBDIV_4; #elif BUS_DIV == 8 osccon |= PIC32_OSCCON_PBDIV_8; #else #error Incorrect BUS_DIV value! #endif /* Unlock access to OSCCON register */ SYSKEY = 0; SYSKEY = 0xaa996655; SYSKEY = 0x556699aa; OSCCON = osccon; /* * Early setup for console devices. */ #if CONS_MAJOR == UART_MAJOR uartinit(CONS_MINOR); #endif #if CONS_MAJOR == UARTUSB_MAJOR usbinit(); #endif /* Get total RAM size. */ physmem = BMXDRMSZ; /* * When button 1 is pressed - boot to single user mode. */ boothowto = 0; if (button1_pressed()) { boothowto |= RB_SINGLE; } } static void cpuidentify() { unsigned devid = DEVID, osccon = OSCCON; static const char pllmult[] = { 15, 16, 17, 18, 19, 20, 21, 24 }; static const char plldiv[] = { 1, 2, 3, 4, 5, 6, 10, 12 }; static const char *poscmod[] = { "external", "XT crystal", "HS crystal", "(disabled)" }; printf("cpu: "); switch (devid & 0x0fffffff) { case 0x04307053: cpu_pins = 100; copystr("795F512L", cpu_model, sizeof(cpu_model), NULL); printf("795F512L"); break; case 0x0430E053: cpu_pins = 64; copystr("795F512H", cpu_model, sizeof(cpu_model), NULL); printf("795F512H"); break; case 0x04341053: cpu_pins = 100; copystr("695F512L", cpu_model, sizeof(cpu_model), NULL); printf("695F512L"); break; case 0x04325053: cpu_pins = 64; copystr("695F512H", cpu_model, sizeof(cpu_model), NULL); printf("695F512H"); break; default: /* Assume 100-pin package. */ copystr("PIC32 device unknown", cpu_model, sizeof(cpu_model), NULL); cpu_pins = 100; printf("DevID %08x", devid); } printf(" %u MHz, bus %u MHz\n", CPU_KHZ/1000, BUS_KHZ/1000); /* COSC: current oscillator selection bits */ printf("oscillator: "); switch (osccon >> 12 & 7) { case 0: printf("internal Fast RC\n"); break; case 1: printf("internal Fast RC, PLL div 1:%d mult x%d\n", plldiv [DEVCFG2 & 7], pllmult [osccon >> 16 & 7]); break; case 2: printf("%s\n", poscmod [DEVCFG1 >> 8 & 3]); break; case 3: printf("%s, PLL div 1:%d mult x%d\n", poscmod [DEVCFG1 >> 8 & 3], plldiv [DEVCFG2 & 7], pllmult [osccon >> 16 & 7]); break; case 4: printf("secondary\n"); break; case 5: printf("internal Low-Power RC\n"); break; case 6: printf("internal Fast RC, divided 1:16\n"); break; case 7: printf("internal Fast RC, divided\n"); break; } } /* * Check whether the controller has been successfully initialized. */ static int is_controller_alive(driver, unit) struct driver *driver; int unit; { struct conf_ctlr *ctlr; /* No controller - that's OK. */ if (driver == 0) return 1; for (ctlr = conf_ctlr_init; ctlr->ctlr_driver; ctlr++) { if (ctlr->ctlr_driver == driver && ctlr->ctlr_unit == unit && ctlr->ctlr_alive) { return 1; } } return 0; } /* * Configure all controllers and devices as specified * in the kernel configuration file. */ void config(void) { struct conf_ctlr *ctlr; struct conf_device *dev; cpuidentify(); /* Probe and initialize controllers first. */ for (ctlr = conf_ctlr_init; ctlr->ctlr_driver; ctlr++) { if ((*ctlr->ctlr_driver->d_init)(ctlr)) { ctlr->ctlr_alive = 1; } } /* Probe and initialize devices. */ for (dev = conf_device_init; dev->dev_driver; dev++) { if (is_controller_alive(dev->dev_cdriver, dev->dev_ctlr)) { if ((*dev->dev_driver->d_init)(dev)) { dev->dev_alive = 1; } } } } /* * Sit and wait for something to happen... */ void idle() { /* Indicate that no process is running. */ noproc = 1; /* Set SPL low so we can be interrupted. */ int x = spl0(); /* Wait for something to happen. */ asm volatile ("wait"); /* Restore previous SPL. */ splx(x); } void boot(dev, howto) register dev_t dev; register int howto; { if ((howto & RB_NOSYNC) == 0 && waittime < 0 && bfreelist[0].b_forw) { register struct fs *fp; register struct buf *bp; int iter, nbusy; /* * Force the root filesystem's superblock to be updated, * so the date will be as current as possible after * rebooting. */ fp = getfs(rootdev); if (fp) fp->fs_fmod = 1; waittime = 0; printf("syncing disks... "); (void) splnet(); sync(); for (iter = 0; iter < 20; iter++) { nbusy = 0; for (bp = &buf[NBUF]; --bp >= buf; ) if (bp->b_flags & B_BUSY) nbusy++; if (nbusy == 0) break; printf("%d ", nbusy); udelay(40000L * iter); } printf("done\n"); } (void) splhigh(); if (! (howto & RB_HALT)) { if ((howto & RB_DUMP) && dumpdev != NODEV) { /* * Take a dump of memory by calling (*dump)(), * which must correspond to dumpdev. * It should dump from dumplo blocks to the end * of memory or to the end of the logical device. */ (*dump)(dumpdev); } /* Restart from dev, howto */ #ifdef UARTUSB_ENABLED /* Disable USB module, and wait awhile for the USB cable * capacitance to discharge down to disconnected (SE0) state. */ U1CON = 0x0000; udelay(1000); /* Stop DMA */ if (! (DMACON & 0x1000)) { DMACONSET = 0x1000; while (DMACON & 0x800) continue; } #endif /* Unlock access to reset register */ SYSKEY = 0; SYSKEY = 0xaa996655; SYSKEY = 0x556699aa; /* Reset microcontroller */ RSWRSTSET = 1; (void) RSWRST; } printf("halted\n"); if (howto & RB_BOOTLOADER) { printf("entering bootloader\n"); BLRKEY = 0x12345678; /* Unlock access to reset register */ SYSKEY = 0; SYSKEY = 0xaa996655; SYSKEY = 0x556699aa; /* Reset microcontroller */ RSWRSTSET = 1; (void) RSWRST; } #ifdef HALTREBOOT printf("press any key to reboot..."); cngetc(); /* Unlock access to reset register */ SYSKEY = 0; SYSKEY = 0xaa996655; SYSKEY = 0x556699aa; /* Reset microcontroller */ RSWRSTSET = 1; (void) RSWRST; #endif for (;;) { #ifdef UARTUSB_ENABLED usb_device_tasks(); cdc_consume(0); cdc_tx_service(); #else #ifdef POWER_ENABLED if (howto & RB_POWEROFF) power_off(); #endif asm volatile ("wait"); #endif } /*NOTREACHED*/ } /* * Microsecond delay routine for MIPS processor. * * We rely on a hardware register Count, which is increased * every next clock cycle, i.e. at rate CPU_KHZ/2 per millisecond. */ void udelay(usec) u_int usec; { unsigned now = mips_read_c0_register(C0_COUNT, 0); unsigned final = now + usec * (CPU_KHZ / 1000) / 2; for (;;) { now = mips_read_c0_register(C0_COUNT, 0); /* This comparison is valid only when using a signed type. */ if ((int) (now - final) >= 0) break; } } /* * Control LEDs, installed on the board. */ void led_control(int mask, int on) { #ifdef LED_SWAP_PORT if (mask & LED_SWAP) { /* Auxiliary */ if (on) LED_SWAP_ON(); else LED_SWAP_OFF(); } #endif #ifdef LED_DISK_PORT if (mask & LED_DISK) { /* Disk i/o */ if (on) LED_DISK_ON(); else LED_DISK_OFF(); } #endif #ifdef LED_KERNEL_PORT if (mask & LED_KERNEL) { /* Kernel activity */ if (on) LED_KERNEL_ON(); else LED_KERNEL_OFF(); } #endif #ifdef LED_TTY_PORT if (mask & LED_TTY) { /* Terminal i/o */ if (on) LED_TTY_ON(); else LED_TTY_OFF(); } #endif } /* * Increment user profiling counters. */ void addupc(caddr_t pc, struct uprof *pbuf, int ticks) { unsigned indx; if (pc < (caddr_t) pbuf->pr_off) return; indx = pc - (caddr_t) pbuf->pr_off; indx = (indx * pbuf->pr_scale) >> 16; if (indx >= pbuf->pr_size) return; pbuf->pr_base[indx] += ticks; } /* * Find the index of the least significant set bit in the 32-bit word. * If LSB bit is set - return 1. * If only MSB bit is set - return 32. * Return 0 when no bit is set. */ int ffs(i) u_long i; { if (i != 0) i = 32 - mips_clz(i & -i); return i; } /* * Copy a null terminated string from one point to another. * Returns zero on success, ENOENT if maxlength exceeded. * If lencopied is non-zero, *lencopied gets the length of the copy * (including the null terminating byte). */ int copystr(src, dest, maxlength, lencopied) register caddr_t src, dest; register u_int maxlength, *lencopied; { caddr_t dest0 = dest; int error = ENOENT; if (maxlength != 0) { while ((*dest++ = *src++) != '\0') { if (--maxlength == 0) { /* Failed. */ goto done; } } /* Succeeded. */ error = 0; } done: if (lencopied != 0) *lencopied = dest - dest0; return error; } /* * Calculate the length of a string. */ size_t strlen(s) register const char *s; { const char *s0 = s; while (*s++ != '\0') ; return s - s0 - 1; } /* * Return 0 if a user address is valid. * There are two memory regions allowed for user: flash and RAM. */ int baduaddr(addr) register caddr_t addr; { if (addr >= (caddr_t) USER_FLASH_START && addr < (caddr_t) USER_FLASH_END) return 0; if (addr >= (caddr_t) USER_DATA_START && addr < (caddr_t) USER_DATA_END) return 0; return 1; } /* * Return 0 if a kernel address is valid. * There are two memory regions allowed for kernel: RAM and flash. */ int badkaddr(addr) register caddr_t addr; { if (addr >= (caddr_t) KERNEL_DATA_START && addr < (caddr_t) KERNEL_DATA_END) return 0; if (addr >= (caddr_t) KERNEL_FLASH_START && addr < (caddr_t) KERNEL_FLASH_END) return 0; return 1; } /* * Insert the specified element into a queue immediately after * the specified predecessor element. */ void insque(void *element, void *predecessor) { struct que { struct que *q_next; struct que *q_prev; }; register struct que *e = (struct que *) element; register struct que *prev = (struct que *) predecessor; e->q_prev = prev; e->q_next = prev->q_next; prev->q_next->q_prev = e; prev->q_next = e; } /* * Remove the specified element from the queue. */ void remque(void *element) { struct que { struct que *q_next; struct que *q_prev; }; register struct que *e = (struct que *) element; e->q_prev->q_next = e->q_next; e->q_next->q_prev = e->q_prev; } /* * Compare strings. */ int strncmp(const char *s1, const char *s2, size_t n) { register int ret, tmp; if (n == 0) return 0; do { ret = *s1++ - (tmp = *s2++); } while ((ret == 0) && (tmp != 0) && --n); return ret; } /* Nonzero if pointer is not aligned on a "sz" boundary. */ #define UNALIGNED(p, sz) ((unsigned) (p) & ((sz) - 1)) /* * Copy data from the memory region pointed to by src0 to the memory * region pointed to by dst0. * If the regions overlap, the behavior is undefined. */ void bcopy(const void *src0, void *dst0, size_t nbytes) { unsigned char *dst = dst0; const unsigned char *src = src0; unsigned *aligned_dst; const unsigned *aligned_src; /* printf("bcopy(%08x, %08x, %d)\n", src0, dst0, nbytes); */ /* If the size is small, or either SRC or DST is unaligned, * then punt into the byte copy loop. This should be rare. */ if (nbytes >= 4*sizeof(unsigned) && ! UNALIGNED(src, sizeof(unsigned)) && ! UNALIGNED(dst, sizeof(unsigned))) { aligned_dst = (unsigned*) dst; aligned_src = (const unsigned*) src; /* Copy 4X unsigned words at a time if possible. */ while (nbytes >= 4*sizeof(unsigned)) { *aligned_dst++ = *aligned_src++; *aligned_dst++ = *aligned_src++; *aligned_dst++ = *aligned_src++; *aligned_dst++ = *aligned_src++; nbytes -= 4*sizeof(unsigned); } /* Copy one unsigned word at a time if possible. */ while (nbytes >= sizeof(unsigned)) { *aligned_dst++ = *aligned_src++; nbytes -= sizeof(unsigned); } /* Pick up any residual with a byte copier. */ dst = (unsigned char*) aligned_dst; src = (const unsigned char*) aligned_src; } while (nbytes--) *dst++ = *src++; } void * memcpy(void *dst, const void *src, size_t nbytes) { bcopy(src, dst, nbytes); return dst; } /* * Fill the array with zeroes. */ void bzero(void *dst0, size_t nbytes) { unsigned char *dst; unsigned *aligned_dst; dst = (unsigned char*) dst0; while (UNALIGNED(dst, sizeof(unsigned))) { *dst++ = 0; if (--nbytes == 0) return; } if (nbytes >= sizeof(unsigned)) { /* If we get this far, we know that nbytes is large and dst is word-aligned. */ aligned_dst = (unsigned*) dst; while (nbytes >= 4*sizeof(unsigned)) { *aligned_dst++ = 0; *aligned_dst++ = 0; *aligned_dst++ = 0; *aligned_dst++ = 0; nbytes -= 4*sizeof(unsigned); } while (nbytes >= sizeof(unsigned)) { *aligned_dst++ = 0; nbytes -= sizeof(unsigned); } dst = (unsigned char*) aligned_dst; } /* Pick up the remainder with a bytewise loop. */ while (nbytes--) *dst++ = 0; } /* * Compare not more than nbytes of data pointed to by m1 with * the data pointed to by m2. Return an integer greater than, equal to or * less than zero according to whether the object pointed to by * m1 is greater than, equal to or less than the object * pointed to by m2. */ int bcmp(const void *m1, const void *m2, size_t nbytes) { const unsigned char *s1 = (const unsigned char*) m1; const unsigned char *s2 = (const unsigned char*) m2; const unsigned *aligned1, *aligned2; /* If the size is too small, or either pointer is unaligned, * then we punt to the byte compare loop. Hopefully this will * not turn up in inner loops. */ if (nbytes >= 4*sizeof(unsigned) && ! UNALIGNED(s1, sizeof(unsigned)) && ! UNALIGNED(s2, sizeof(unsigned))) { /* Otherwise, load and compare the blocks of memory one word at a time. */ aligned1 = (const unsigned*) s1; aligned2 = (const unsigned*) s2; while (nbytes >= sizeof(unsigned)) { if (*aligned1 != *aligned2) break; aligned1++; aligned2++; nbytes -= sizeof(unsigned); } /* check remaining characters */ s1 = (const unsigned char*) aligned1; s2 = (const unsigned char*) aligned2; } while (nbytes--) { if (*s1 != *s2) return *s1 - *s2; s1++; s2++; } return 0; } int copyout(caddr_t from, caddr_t to, u_int nbytes) { /* printf("copyout(from=%p, to=%p, nbytes=%u)\n", from, to, nbytes); */ if (baduaddr(to) || baduaddr(to + nbytes - 1)) return EFAULT; bcopy(from, to, nbytes); return 0; } int copyin (caddr_t from, caddr_t to, u_int nbytes) { if (baduaddr(from) || baduaddr(from + nbytes - 1)) return EFAULT; bcopy(from, to, nbytes); return 0; } /* * Routines for access to general purpose I/O pins. */ static const char pin_name[16] = "?ABCDEFG????????"; void gpio_set_input(int pin) { struct gpioreg *port = (struct gpioreg*) &TRISA; port += (pin >> 4 & 15) - 1; port->trisset = (1 << (pin & 15)); } void gpio_set_output(int pin) { struct gpioreg *port = (struct gpioreg*) &TRISA; port += (pin >> 4 & 15) - 1; port->trisclr = (1 << (pin & 15)); } void gpio_set(int pin) { struct gpioreg *port = (struct gpioreg*) &TRISA; port += (pin >> 4 & 15) - 1; port->latset = (1 << (pin & 15)); } void gpio_clr(int pin) { struct gpioreg *port = (struct gpioreg*) &TRISA; port += (pin >> 4 & 15) - 1; port->latclr = (1 << (pin & 15)); } int gpio_get(int pin) { struct gpioreg *port = (struct gpioreg*) &TRISA; port += (pin >> 4 & 15) - 1; return ((port->port & (1 << (pin & 15))) ? 1 : 0); } char gpio_portname(int pin) { return pin_name[(pin >> 4) & 15]; } int gpio_pinno(int pin) { return pin & 15; } ================================================ FILE: sys/arch/pic32/pic32/sig_machdep.c ================================================ /* * Copyright (c) 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * * @(#)machdep.c 2.4 (2.11BSD) 1999/9/13 */ #include #include #include #include #include #include #include #include #include #if 0 #define DIAGNOSTIC #endif /* * Send an interrupt to process. * * Stack is set up to allow trampoline code stored at u.u_sigtramp (as * specified by the user process) to call the user's real signal catch * routine, followed by sys sigreturn to the sigreturn routine below * (see lib/libc/mips/sys/sigaction.S). After sigreturn resets the signal * mask, the stack, and the frame pointer, it returns to the user specified * pc and regs. */ void sendsig (p, sig, mask) sig_t p; int sig; long mask; { struct sigframe { int sf_space [4]; struct sigcontext sf_sc; }; struct trapframe *regs = u.u_frame; register struct sigframe *sfp; int oonstack; #ifdef DIAGNOSTIC printf("(%u)sendsig %d, mask=%#x, handler=%#x, tramp=%#x\n", u.u_procp->p_pid, sig, mask, p, u.u_sigtramp); #endif oonstack = u.u_sigstk.ss_flags & SA_ONSTACK; /* * Allocate and validate space for the signal frame. */ if ((u.u_psflags & SAS_ALTSTACK) && ! (u.u_sigstk.ss_flags & SA_ONSTACK) && (u.u_sigonstack & sigmask(sig))) { sfp = (struct sigframe*) (u.u_sigstk.ss_base + u.u_sigstk.ss_size); u.u_sigstk.ss_flags |= SA_ONSTACK; } else sfp = (struct sigframe*) regs->tf_sp; sfp--; if (! (u.u_sigstk.ss_flags & SA_ONSTACK)) { if ((caddr_t) sfp < (caddr_t) u.u_procp->p_daddr + u.u_dsize) { /* * Process has trashed its stack; give it an illegal * instruction violation to halt it in its tracks. */ fatalsig(SIGILL); return; } if (u.u_procp->p_ssize < USER_DATA_END - (unsigned) sfp) { u.u_procp->p_ssize = USER_DATA_END - (unsigned) sfp; u.u_procp->p_saddr = (unsigned) sfp; u.u_ssize = u.u_procp->p_ssize; } } /* * Build the signal context to be used by sigreturn. */ sfp->sf_sc.sc_onstack = oonstack; sfp->sf_sc.sc_mask = mask; sfp->sf_sc.sc_r1 = regs->tf_r1; sfp->sf_sc.sc_r2 = regs->tf_r2; sfp->sf_sc.sc_r3 = regs->tf_r3; sfp->sf_sc.sc_r4 = regs->tf_r4; sfp->sf_sc.sc_r5 = regs->tf_r5; sfp->sf_sc.sc_r6 = regs->tf_r6; sfp->sf_sc.sc_r7 = regs->tf_r7; sfp->sf_sc.sc_r8 = regs->tf_r8; sfp->sf_sc.sc_r9 = regs->tf_r9; sfp->sf_sc.sc_r10 = regs->tf_r10; sfp->sf_sc.sc_r11 = regs->tf_r11; sfp->sf_sc.sc_r12 = regs->tf_r12; sfp->sf_sc.sc_r13 = regs->tf_r13; sfp->sf_sc.sc_r14 = regs->tf_r14; sfp->sf_sc.sc_r15 = regs->tf_r15; sfp->sf_sc.sc_r16 = regs->tf_r16; sfp->sf_sc.sc_r17 = regs->tf_r17; sfp->sf_sc.sc_r18 = regs->tf_r18; sfp->sf_sc.sc_r19 = regs->tf_r19; sfp->sf_sc.sc_r20 = regs->tf_r20; sfp->sf_sc.sc_r21 = regs->tf_r21; sfp->sf_sc.sc_r22 = regs->tf_r22; sfp->sf_sc.sc_r23 = regs->tf_r23; sfp->sf_sc.sc_r24 = regs->tf_r24; sfp->sf_sc.sc_r25 = regs->tf_r25; sfp->sf_sc.sc_gp = regs->tf_gp; sfp->sf_sc.sc_sp = regs->tf_sp; sfp->sf_sc.sc_fp = regs->tf_fp; sfp->sf_sc.sc_ra = regs->tf_ra; sfp->sf_sc.sc_lo = regs->tf_lo; sfp->sf_sc.sc_hi = regs->tf_hi; sfp->sf_sc.sc_pc = regs->tf_pc; /* Call signal handler */ regs->tf_r4 = sig; /* $a0 - signal number */ regs->tf_r5 = u.u_code; /* $a1 - code */ regs->tf_r6 = (int) &sfp->sf_sc; /* $a2 - address of sigcontext */ regs->tf_ra = (int) u.u_sigtramp; /* $ra - sigtramp */ regs->tf_sp = (int) sfp; regs->tf_pc = (int) p; #ifdef DIAGNOSTIC printf(" ...call handler %p (sig=%d, code=%#x, context=%p)\n", p, sig, u.u_code, &sfp->sf_sc); printf(" ...stack=%p, return to %p\n", sfp, u.u_sigtramp); #endif } /* * System call to cleanup state after a signal * has been taken. Reset signal mask and * stack state from context left by sendsig (above). * Return to previous pc and ps as specified by * context left by sendsig. Check carefully to * make sure that the user has not modified the * ps to gain improper priviledges or to cause * a machine fault. */ void sigreturn() { struct trapframe *regs = u.u_frame; register struct sigcontext *scp = (struct sigcontext*) (regs->tf_sp + 16); #ifdef DIAGNOSTIC printf("(%u)sigreturn stack=%#x, context=%p\n", u.u_procp->p_pid, regs->tf_sp, scp); #endif if (baduaddr ((caddr_t) scp) || baduaddr ((caddr_t) scp + sizeof(*scp))) { u.u_error = EFAULT; return; } u.u_error = EJUSTRETURN; if (scp->sc_onstack & SA_ONSTACK) u.u_sigstk.ss_flags |= SA_ONSTACK; else u.u_sigstk.ss_flags &= ~SA_ONSTACK; u.u_procp->p_sigmask = scp->sc_mask & ~sigcantmask; /* Return from signal handler */ regs->tf_r1 = scp->sc_r1; regs->tf_r2 = scp->sc_r2; regs->tf_r3 = scp->sc_r3; regs->tf_r4 = scp->sc_r4; regs->tf_r5 = scp->sc_r5; regs->tf_r6 = scp->sc_r6; regs->tf_r7 = scp->sc_r7; regs->tf_r8 = scp->sc_r8; regs->tf_r9 = scp->sc_r9; regs->tf_r10 = scp->sc_r10; regs->tf_r11 = scp->sc_r11; regs->tf_r12 = scp->sc_r12; regs->tf_r13 = scp->sc_r13; regs->tf_r14 = scp->sc_r14; regs->tf_r15 = scp->sc_r15; regs->tf_r16 = scp->sc_r16; regs->tf_r17 = scp->sc_r17; regs->tf_r18 = scp->sc_r18; regs->tf_r19 = scp->sc_r19; regs->tf_r20 = scp->sc_r20; regs->tf_r21 = scp->sc_r21; regs->tf_r22 = scp->sc_r22; regs->tf_r23 = scp->sc_r23; regs->tf_r24 = scp->sc_r24; regs->tf_r25 = scp->sc_r25; regs->tf_gp = scp->sc_gp; regs->tf_sp = scp->sc_sp; regs->tf_fp = scp->sc_fp; regs->tf_ra = scp->sc_ra; regs->tf_lo = scp->sc_lo; regs->tf_hi = scp->sc_hi; regs->tf_pc = scp->sc_pc; #ifdef DIAGNOSTIC printf(" ...to %#x, stack %#x\n", regs->tf_pc, regs->tf_sp); #endif } ================================================ FILE: sys/arch/pic32/pic32/sysctl.c ================================================ /* * Copyright (c) 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * * @(#)kern_pdp.c 1.4 (2.11BSD) 1998/5/12 */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifdef PTY_ENABLED # include #endif /* * Errno messages. */ static const char *errlist[] = { "Undefined error: 0", /* 0 - ENOERROR */ "Operation not permitted", /* 1 - EPERM */ "No such file or directory", /* 2 - ENOENT */ "No such process", /* 3 - ESRCH */ "Interrupted system call", /* 4 - EINTR */ "Input/output error", /* 5 - EIO */ "Device not configured", /* 6 - ENXIO */ "Argument list too long", /* 7 - E2BIG */ "Exec format error", /* 8 - ENOEXEC */ "Bad file descriptor", /* 9 - EBADF */ "No child processes", /* 10 - ECHILD */ "No more processes", /* 11 - EAGAIN */ "Cannot allocate memory", /* 12 - ENOMEM */ "Permission denied", /* 13 - EACCES */ "Bad address", /* 14 - EFAULT */ "Block device required", /* 15 - ENOTBLK */ "Device busy", /* 16 - EBUSY */ "File exists", /* 17 - EEXIST */ "Cross-device link", /* 18 - EXDEV */ "Operation not supported by device", /* 19 - ENODEV */ "Not a directory", /* 20 - ENOTDIR */ "Is a directory", /* 21 - EISDIR */ "Invalid argument", /* 22 - EINVAL */ "Too many open files in system", /* 23 - ENFILE */ "Too many open files", /* 24 - EMFILE */ "Inappropriate ioctl for device", /* 25 - ENOTTY */ "Text file busy", /* 26 - ETXTBSY */ "File too large", /* 27 - EFBIG */ "No space left on device", /* 28 - ENOSPC */ "Illegal seek", /* 29 - ESPIPE */ "Read-only file system", /* 30 - EROFS */ "Too many links", /* 31 - EMLINK */ "Broken pipe", /* 32 - EPIPE */ /* math software */ "Numerical argument out of domain", /* 33 - EDOM */ "Result too large", /* 34 - ERANGE */ /* non-blocking and interrupt i/o */ "Resource temporarily unavailable", /* 35 - EWOULDBLOCK */ "Operation now in progress", /* 36 - EINPROGRESS */ "Operation already in progress", /* 37 - EALREADY */ /* ipc/network software -- argument errors */ "Socket operation on non-socket", /* 38 - ENOTSOCK */ "Destination address required", /* 39 - EDESTADDRREQ */ "Message too long", /* 40 - EMSGSIZE */ "Protocol wrong type for socket", /* 41 - EPROTOTYPE */ "Protocol not available", /* 42 - ENOPROTOOPT */ "Protocol not supported", /* 43 - EPROTONOSUPPORT */ "Socket type not supported", /* 44 - ESOCKTNOSUPPORT */ "Operation not supported", /* 45 - EOPNOTSUPP */ "Protocol family not supported", /* 46 - EPFNOSUPPORT */ /* 47 - EAFNOSUPPORT */ "Address family not supported by protocol family", "Address already in use", /* 48 - EADDRINUSE */ "Can't assign requested address", /* 49 - EADDRNOTAVAIL */ /* ipc/network software -- operational errors */ "Network is down", /* 50 - ENETDOWN */ "Network is unreachable", /* 51 - ENETUNREACH */ "Network dropped connection on reset", /* 52 - ENETRESET */ "Software caused connection abort", /* 53 - ECONNABORTED */ "Connection reset by peer", /* 54 - ECONNRESET */ "No buffer space available", /* 55 - ENOBUFS */ "Socket is already connected", /* 56 - EISCONN */ "Socket is not connected", /* 57 - ENOTCONN */ "Can't send after socket shutdown", /* 58 - ESHUTDOWN */ "Too many references: can't splice", /* 59 - ETOOMANYREFS */ "Operation timed out", /* 60 - ETIMEDOUT */ "Connection refused", /* 61 - ECONNREFUSED */ "Too many levels of symbolic links", /* 62 - ELOOP */ "File name too long", /* 63 - ENAMETOOLONG */ /* should be rearranged */ "Host is down", /* 64 - EHOSTDOWN */ "No route to host", /* 65 - EHOSTUNREACH */ "Directory not empty", /* 66 - ENOTEMPTY */ /* quotas & mush */ "Too many processes", /* 67 - EPROCLIM */ "Too many users", /* 68 - EUSERS */ "Disc quota exceeded", /* 69 - EDQUOT */ /* Network File System */ "Stale NFS file handle", /* 70 - ESTALE */ "Too many levels of remote in path", /* 71 - EREMOTE */ "RPC struct is bad", /* 72 - EBADRPC */ "RPC version wrong", /* 73 - ERPCMISMATCH */ "RPC prog. not avail", /* 74 - EPROGUNAVAIL */ "Program version wrong", /* 75 - EPROGMISMATCH */ "Bad procedure for program", /* 76 - EPROCUNAVAIL */ "No locks available", /* 77 - ENOLCK */ "Function not implemented", /* 78 - ENOSYS */ "Inappropriate file type or format", /* 79 - EFTYPE */ "Authentication error", /* 80 - EAUTH */ "Need authenticator", /* 81 - ENEEDAUTH */ }; /* * Kernel symbol name list. */ static const struct { const char *name; int addr; } nlist[] = { { "_boottime", (int) &boottime }, /* vmstat */ { "_cnttys", (int) &cnttys }, /* pstat */ { "_cp_time", (int) &cp_time }, /* iostat vmstat */ { "_dk_busy", (int) &dk_busy }, /* iostat */ { "_dk_name", (int) &dk_name }, /* iostat vmstat */ { "_dk_ndrive", (int) &dk_ndrive }, /* iostat vmstat */ { "_dk_unit", (int) &dk_unit }, /* iostat vmstat */ { "_dk_bytes", (int) &dk_bytes }, /* iostat */ { "_dk_xfer", (int) &dk_xfer }, /* iostat vmstat */ { "_file", (int) &file }, /* pstat */ { "_forkstat", (int) &forkstat }, /* vmstat */ #ifdef UCB_METER { "_freemem", (int) &freemem }, /* vmstat */ #endif { "_hz", (int) &hz }, /* ps */ { "_inode", (int) &inode }, /* pstat */ { "_ipc", (int) &ipc }, /* ps */ { "_lbolt", (int) &lbolt }, /* ps */ { "_memlock", (int) &memlock }, /* ps */ { "_nchstats", (int) &nchstats }, /* vmstat */ { "_nproc", (int) &nproc }, /* ps pstat */ { "_nswap", (int) &nswap }, /* pstat */ { "_proc", (int) &proc }, /* ps pstat */ { "_runin", (int) &runin }, /* ps */ { "_runout", (int) &runout }, /* ps */ { "_selwait", (int) &selwait }, /* ps */ { "_swapmap", (int) &swapmap }, /* pstat */ { "_tk_nin", (int) &tk_nin }, /* iostat */ { "_tk_nout", (int) &tk_nout }, /* iostat */ { "_total", (int) &total }, /* vmstat */ { "_u", (int) &u }, /* ps */ #ifdef PTY_ENABLED { "_npty", (int) &npty }, /* pstat */ { "_pt_tty", (int) &pt_tty }, /* pstat */ #endif #ifdef UCB_METER { "_rate", (int) &rate }, /* vmstat */ { "_sum", (int) &sum }, /* vmstat */ #endif { "_bdevsw", (int) &bdevsw }, /* devupdate */ { "_cdevsw", (int) &cdevsw }, /* devupdate */ { "_nblkdev", (int) &nblkdev }, /* devupdate */ { "_nchrdev", (int) &nchrdev }, /* devupdate */ { 0, 0 }, }; /* * ucall allows user level code to call various kernel functions. * Autoconfig uses it to call the probe and attach routines of the * various device drivers. */ void ucall() { register struct a { int priority; int (*routine)(); int arg1; int arg2; } *uap = (struct a *)u.u_arg; int s; if (!suser()) return; switch (uap->priority) { case 0: s = spl0(); break; default: s = splhigh(); break; } u.u_rval = (*uap->routine) (uap->arg1, uap->arg2); splx(s); } /* * Fetch the word at addr from flash memory or i/o port. * This system call is required on PIC32 because in user mode * the access to flash memory region is not allowed. */ void ufetch() { unsigned addr = *(unsigned*) u.u_arg & ~3; /* Check root privileges */ if (! suser()) return; /* Low memory address - assume peripheral i/o space. */ if (addr < 0x90000) addr += 0xbf800000; /* Check address */ if (! (addr >= 0x9d000000 && addr < 0x9d000000 + FLASH_SIZE) && ! (addr >= 0xbd000000 && addr < 0xbd000000 + FLASH_SIZE) && /* Boot flash memory */ ! (addr >= 0x9fc00000 && addr < 0x9fc00000 + 12*1024) && ! (addr >= 0xbfc00000 && addr < 0xbfc00000 + 12*1024) && /* Peripheral registers */ ! (addr >= 0xbf800000 && addr < 0xbf810000) && ! (addr >= 0xbf880000 && addr < 0xbf890000)) { u.u_error = EFAULT; return; } u.u_rval = *(unsigned*) addr; } /* * Store the word at addr of i/o port. */ void ustore() { register struct a { unsigned addr; unsigned value; } *uap = (struct a *)u.u_arg; unsigned addr = uap->addr & ~3; /* Check root privileges */ if (! suser()) return; /* Low memory address - assume peripheral i/o space. */ if (addr < 0x90000) addr += 0xbf800000; /* Check address */ if (! (addr >= 0xbf800000 && addr < 0xbf810000) && ! (addr >= 0xbf880000 && addr < 0xbf890000)) { u.u_error = EFAULT; return; } *(unsigned*) addr = uap->value; } /* * This was moved here when the TMSCP portion was added. At that time it * became (even more) system specific and didn't belong in kern_sysctl.c */ int cpu_sysctl (name, namelen, oldp, oldlenp, newp, newlen) int *name; u_int namelen; void *oldp; size_t *oldlenp; void *newp; size_t newlen; { int i, khz; dev_t dev; switch (name[0]) { case CPU_CONSDEV: if (namelen != 1) return ENOTDIR; dev = makedev(CONS_MAJOR, CONS_MINOR); return sysctl_rdstruct (oldp, oldlenp, newp, &dev, sizeof dev); #if NTMSCP > 0 case CPU_TMSCP: /* All sysctl names at this level are terminal */ if (namelen != 2) return ENOTDIR; switch (name[1]) { case TMSCP_CACHE: return sysctl_int (oldp, oldlenp, newp, newlen, &tmscpcache); case TMSCP_PRINTF: return sysctl_int (oldp, oldlenp, newp, newlen, &tmscpprintf); default: } #endif case CPU_ERRMSG: if (namelen != 2) return ENOTDIR; if (name[1] < 1 || name[1] >= sizeof(errlist) / sizeof(errlist[0])) return EOPNOTSUPP; return sysctl_string(oldp, oldlenp, 0, 0, (char*) errlist[name[1]], 1 + strlen(errlist[name[1]])); case CPU_NLIST: for (i=0; nlist[i].name; i++) { if (strncmp (newp, nlist[i].name, newlen) == 0) { int addr = nlist[i].addr; if (! oldp) return 0; if (*oldlenp < sizeof(int)) return ENOMEM; *oldlenp = sizeof(int); return copyout ((caddr_t) &addr, (caddr_t) oldp, sizeof(int)); } } return EOPNOTSUPP; case CPU_TIMO_CMD: return sysctl_int(oldp, oldlenp, newp, newlen, &sd_timo_cmd); case CPU_TIMO_SEND_OP: return sysctl_int(oldp, oldlenp, newp, newlen, &sd_timo_send_op); case CPU_TIMO_SEND_CSD: return sysctl_int(oldp, oldlenp, newp, newlen, &sd_timo_send_csd); case CPU_TIMO_READ: return sysctl_int(oldp, oldlenp, newp, newlen, &sd_timo_read); case CPU_TIMO_WAIT_CMD: return sysctl_int(oldp, oldlenp, newp, newlen, &sd_timo_wait_cmd); case CPU_TIMO_WAIT_WDATA: return sysctl_int(oldp, oldlenp, newp, newlen, &sd_timo_wait_wdata); case CPU_TIMO_WAIT_WDONE: return sysctl_int(oldp, oldlenp, newp, newlen, &sd_timo_wait_wdone); case CPU_TIMO_WAIT_WSTOP: return sysctl_int(oldp, oldlenp, newp, newlen, &sd_timo_wait_wstop); case CPU_TIMO_WAIT_WIDLE: return sysctl_int(oldp, oldlenp, newp, newlen, &sd_timo_wait_widle); case CPU_FREQ_KHZ: if (namelen != 1) return ENOTDIR; khz = CPU_KHZ; return sysctl_rdstruct (oldp, oldlenp, newp, &khz, sizeof khz); case CPU_BUS_KHZ: if (namelen != 1) return ENOTDIR; khz = BUS_KHZ; return sysctl_rdstruct (oldp, oldlenp, newp, &khz, sizeof khz); default: return EOPNOTSUPP; } /* NOTREACHED */ } ================================================ FILE: sys/arch/stm32/conf/Makefile.inc ================================================ #BOARD?= F405WEACTCORE #BOARD?= F411RENUCLEO BOARD?= F412GDISCO #BOARD?= F412WEACTCORE #BOARD?= F413HDISCO #BOARD?= F446RENUCLEO #BOARD?= F446WEACTCORE #BOARD?= F469IDISCO #BOARD?= F4DISCOVERY #BOARD?= F4VEDEVEBOX KERNDIR= ${TOPSRC}/sys/arch/stm32/compile/${BOARD} KERN= unix CONFSCRIPT!=if [ x"${BOARD}" = x"F405WEACTCORE" ] ; then \ echo "board/st_nucleo_f4.cfg" ; \ elif [ x"${BOARD}" = x"F411RENUCLEO" ] ; then \ echo "board/st_nucleo_f4.cfg" ; \ elif [ x"${BOARD}" = x"F412GDISCO" ] ; then \ echo "board/stm32f412g-disco.cfg" ; \ elif [ x"${BOARD}" = x"F412WEACTCORE" ] ; then \ echo "board/st_nucleo_f4.cfg" ; \ elif [ x"${BOARD}" = x"F413HDISCO" ] ; then \ echo "board/stm32f413h-disco.cfg" ; \ elif [ x"${BOARD}" = x"F446RENUCLEO" ] ; then \ echo "board/st_nucleo_f4.cfg" ; \ elif [ x"${BOARD}" = x"F446WEACTCORE" ] ; then \ echo "board/st_nucleo_f4.cfg" ; \ elif [ x"${BOARD}" = x"F469IDISCO" ] ; then \ echo "board/stm32f469i-disco.cfg" ; \ elif [ x"${BOARD}" = x"F4DISCOVERY" ] ; then \ echo "board/stm32f4discovery.cfg" ; \ elif [ x"${BOARD}" = x"F4VEDEVEBOX" ] ; then \ echo "board/stm32f4discovery.cfg" ; \ else \ echo "does/not/exist" ; \ fi help: @echo "Targets are:" 1>&2 @echo " ocd, gdb-ocd" 1>&2 @echo "" 1>&2 @echo "=== Debugging elf file in Circuit Board ===" 1>&2 @echo "Run 'make ocd' in one terminal" 1>&2 @echo "Run 'make gdb-ocd' in another terminal" 1>&2 @echo "Enter 'c' in gdb to run the elf file" 1>&2 @echo "Enter 'mon reset halt' in gdb to reset the cpu" 1>&2 @echo "Enter 'load' in gdb to upload the elf file" 1>&2 ocd: sudo openocd -f "${CONFSCRIPT}" gdb-ocd: arm-none-eabi-gdb -q \ -ex 'cd ${KERNDIR}' \ -ex 'target extended-remote :3333' \ -ex 'mon reset halt' \ -ex 'load' \ ${KERNDIR}/${KERN} .PHONY: help ocd gdb-ocd ================================================ FILE: sys/arch/stm32/conf/Makefile.stm32 ================================================ # # Makefile for DiscoBSD/stm32 # # DEBUG is set to -g by config if debugging is requested (config -g). # # sources are located via $S relative to the compilation directory S= ../../../.. _mach?= stm32 _arch?= arm _machdir?= $S/arch/${_mach} _archdir?= $S/arch/${_arch} _confdir?= ${_machdir}/conf include ${_confdir}/compiler.mk INCLUDES= -nostdinc -I. -I$S -I$S/arch -I${_archdir}/include DEPFLAGS= -MT $@ -MP -MD -MF .deps/$*.dep DEFS= ${INCLUDES} ${PARAM} -DKERNEL ${DEPFLAGS} CWARNFLAGS= -Wall CMACHCPU= -mcpu=cortex-m4 CMACHFLAGS= -ffreestanding -fno-builtin -fcommon CMACHFLAGS+= -mfloat-abi=soft CMACHFLAGS+= -mthumb -mabi=aapcs -mlittle-endian CMACHFLAGS+= ${CMACHCPU} COPTS?= -O CFLAGS= ${DEBUG} ${CWARNFLAGS} ${CMACHFLAGS} ${COPTS} AFLAGS= -x assembler-with-cpp ${CWARNFLAGS} ${CMACHFLAGS} LDFLAGS= -T ${_confdir}/${LDSCRIPT} -T ${_confdir}/kern.ldscript LDFLAGS+= -nostdlib -Map=$@.map -z noexecstack LDADD= # compile rules: rules are named COMPILE_${SUFFIX} # SUFFIX is the file suffix, capitalized (e.g. C for a .c file). COMPILE_C= ${CC} ${CFLAGS} ${DEFS} -c $< COMPILE_S= ${AS} ${AFLAGS} ${DEFS} -c $< %OBJS %CFILES # load lines for config "xxx" will be emitted as: # xxx: ${SYSTEM_DEP} swapxxx.o # ${SYSTEM_LD_HEAD} # ${SYSTEM_LD} swapxxx.o # ${SYSTEM_LD_TAIL} SYSTEM_OBJ= locore0.o locore.o ${OBJS} ioconf.o SYSTEM_DEP= Makefile ioconf.c machine sys .deps ${SYSTEM_OBJ} SYSTEM_LD_HEAD= sh $S/conf/newvers.sh > vers.c; ${CC} ${CFLAGS} -c vers.c; rm -f $@ SYSTEM_LD= -@echo ${LD} ${LDFLAGS} '$${SYSTEM_OBJ}' vers.o -o $@ ${LDADD}; \ ${LD} ${LDFLAGS} ${SYSTEM_OBJ} vers.o -o $@ ${LDADD} SYSTEM_LD_TAIL= ${SIZE} $@; cp $@ $@.elf; \ ${OBJCOPY} -O ihex $@ $@.hex; \ ${OBJCOPY} -O binary $@ $@.bin; \ ${OBJDUMP} -d -S $@ > $@.dis %LOAD clean: rm -rf .deps unix *.elf *.o *.map *.dis *.bin *.hex machine sys clean-all: clean rm -f *.h ioconf.c swap*.c vers.c reconfig ioconf.c: Config $S/../tools/bin/config $S/../tools/bin/config Config ${MAKE} clean machine: ln -s ${_machdir}/include $@ sys: ln -s $S/sys $@ .deps: mkdir .deps locore.o: ${_machdir}/${_mach}/locore.S ${COMPILE_S} locore0.o: ${_machdir}/${_mach}/locore0.S ${COMPILE_S} ioconf.o: ioconf.c ${COMPILE_C} %RULES -include .deps/*.dep ================================================ FILE: sys/arch/stm32/conf/STM32F407XE.ld ================================================ /* * Kernel memory linker script for STM32F407XE. */ MEMORY { FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 512K /* 0x0800 0000 - 0x0807 FFFF */ RAM (rw!x) : ORIGIN = 0x10000000, LENGTH = 58K /* 0x1000 0000 - 0x1000 E7FF */ U0AREA (rw!x) : ORIGIN = 0x1000E800, LENGTH = 3K /* 0x1000 E800 - 0x1000 F3FF */ UAREA (rw!x) : ORIGIN = 0x1000F400, LENGTH = 3k /* 0x1000 F400 - 0x1000 FFFF */ USERRAM (rwx) : ORIGIN = 0x20000000, LENGTH = 96K /* 0x2000 0000 - 0x2001 7FFF */ } ================================================ FILE: sys/arch/stm32/conf/STM32F407XG.ld ================================================ /* * Kernel memory linker script for STM32F407XG. */ MEMORY { FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 1024K /* 0x0800 0000 - 0x080F FFFF */ RAM (rw!x) : ORIGIN = 0x10000000, LENGTH = 58K /* 0x1000 0000 - 0x1000 E7FF */ U0AREA (rw!x) : ORIGIN = 0x1000E800, LENGTH = 3K /* 0x1000 E800 - 0x1000 F3FF */ UAREA (rw!x) : ORIGIN = 0x1000F400, LENGTH = 3k /* 0x1000 F400 - 0x1000 FFFF */ USERRAM (rwx) : ORIGIN = 0x20000000, LENGTH = 96K /* 0x2000 0000 - 0x2001 7FFF */ } ================================================ FILE: sys/arch/stm32/conf/STM32F411XE.ld ================================================ /* * Kernel memory linker script for STM32F411XE. */ MEMORY { FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 512K /* 0x0800 0000 - 0x0807 FFFF */ RAM (rw!x) : ORIGIN = 0x20018000, LENGTH = 26K /* 0x2001 8000 - 0x2001 E7FF */ U0AREA (rw!x) : ORIGIN = 0x2001E800, LENGTH = 3K /* 0x2001 E800 - 0x2001 F3FF */ UAREA (rw!x) : ORIGIN = 0x2001F400, LENGTH = 3k /* 0x2001 F400 - 0x2001 FFFF */ USERRAM (rwx) : ORIGIN = 0x20000000, LENGTH = 96K - 0x80 /* 0x2000 0000 - 0x2001 7F7F */ /* USERRAM (rwx) : ORIGIN = 0x20000000, LENGTH = 96K *//* 0x2000 0000 - 0x2001 7FFF */ } ================================================ FILE: sys/arch/stm32/conf/STM32F412XE.ld ================================================ /* * Kernel memory linker script for STM32F412XE. */ MEMORY { FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 512K /* 0x0800 0000 - 0x0807 FFFF */ RAM (rw!x) : ORIGIN = 0x20038000, LENGTH = 26K /* 0x2003 8000 - 0x2003 E7FF */ U0AREA (rw!x) : ORIGIN = 0x2003E800, LENGTH = 3K /* 0x2003 E800 - 0x2003 F3FF */ UAREA (rw!x) : ORIGIN = 0x2003F400, LENGTH = 3k /* 0x2003 F400 - 0x2003 FFFF */ USERRAM (rwx) : ORIGIN = 0x20000000, LENGTH = 96K /* 0x2000 0000 - 0x2001 7FFF */ } ================================================ FILE: sys/arch/stm32/conf/STM32F412XG.ld ================================================ /* * Kernel memory linker script for STM32F412XG. */ MEMORY { FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 1024K /* 0x0800 0000 - 0x080F FFFF */ RAM (rw!x) : ORIGIN = 0x20038000, LENGTH = 26K /* 0x2003 8000 - 0x2003 E7FF */ U0AREA (rw!x) : ORIGIN = 0x2003E800, LENGTH = 3K /* 0x2003 E800 - 0x2003 F3FF */ UAREA (rw!x) : ORIGIN = 0x2003F400, LENGTH = 3k /* 0x2003 F400 - 0x2003 FFFF */ USERRAM (rwx) : ORIGIN = 0x20000000, LENGTH = 96K /* 0x2000 0000 - 0x2001 7FFF */ } ================================================ FILE: sys/arch/stm32/conf/STM32F413XH.ld ================================================ /* * Kernel memory linker script for STM32F413XH. */ MEMORY { FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 1536K /* 0x0800 0000 - 0x080F FFFF */ RAM (rw!x) : ORIGIN = 0x10000000, LENGTH = 58K /* 0x1000 0000 - 0x1000 E7FF */ U0AREA (rw!x) : ORIGIN = 0x1000E800, LENGTH = 3K /* 0x1000 E800 - 0x1000 F3FF */ UAREA (rw!x) : ORIGIN = 0x1000F400, LENGTH = 3k /* 0x1000 F400 - 0x1000 FFFF */ USERRAM (rwx) : ORIGIN = 0x20000000, LENGTH = 96K /* 0x2000 0000 - 0x2001 7FFF */ } ================================================ FILE: sys/arch/stm32/conf/STM32F446XE.ld ================================================ /* * Kernel memory linker script for STM32F446XE. */ MEMORY { FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 512K /* 0x0800 0000 - 0x0807 FFFF */ RAM (rw!x) : ORIGIN = 0x20018000, LENGTH = 26K /* 0x2001 8000 - 0x2001 E7FF */ U0AREA (rw!x) : ORIGIN = 0x2001E800, LENGTH = 3K /* 0x2001 E800 - 0x2001 F3FF */ UAREA (rw!x) : ORIGIN = 0x2001F400, LENGTH = 3k /* 0x2001 F400 - 0x2001 FFFF */ USERRAM (rwx) : ORIGIN = 0x20000000, LENGTH = 96K - 0x80 /* 0x2000 0000 - 0x2001 7F7F */ /* USERRAM (rwx) : ORIGIN = 0x20000000, LENGTH = 96K *//* 0x2000 0000 - 0x2001 7FFF */ } ================================================ FILE: sys/arch/stm32/conf/STM32F469XI.ld ================================================ /* * Kernel memory linker script for STM32F469XI. */ MEMORY { FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 1024K /* 0x0800 0000 - 0x080F FFFF */ RAM (rw!x) : ORIGIN = 0x10000000, LENGTH = 58K /* 0x1000 0000 - 0x1000 E7FF */ U0AREA (rw!x) : ORIGIN = 0x1000E800, LENGTH = 3K /* 0x1000 E800 - 0x1000 F3FF */ UAREA (rw!x) : ORIGIN = 0x1000F400, LENGTH = 3k /* 0x1000 F400 - 0x1000 FFFF */ USERRAM (rwx) : ORIGIN = 0x20000000, LENGTH = 112K /* 0x2000 0000 - 0x2001 BFFF */ } ================================================ FILE: sys/arch/stm32/conf/compiler.mk ================================================ # GCC arm-none-eabi toolchain on OpenBSD, FreeBSD, and Linux # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ _HOST_OSNAME!= uname -s ARM_GCC_PREFIX!=if [ x"${_HOST_OSNAME}" = x"OpenBSD" ] ; then \ echo "/usr/local/bin/arm-none-eabi" ; \ elif [ x"${_HOST_OSNAME}" = x"FreeBSD" ] ; then \ echo "/usr/local/gcc-arm-embedded/bin/arm-none-eabi" ; \ elif [ x"${_HOST_OSNAME}" = x"Linux" ] ; then \ echo "/usr/bin/arm-none-eabi" ; \ else \ echo "/does/not/exist" ; \ fi _AS= -gcc _CC= -gcc _CPP= -cpp _LD= -ld _SIZE= -size _OBJCOPY= -objcopy _OBJDUMP= -objdump AS= ${ARM_GCC_PREFIX}${_AS} CC= ${ARM_GCC_PREFIX}${_CC} CPP= ${ARM_GCC_PREFIX}${_CPP} LD= ${ARM_GCC_PREFIX}${_LD} SIZE= ${ARM_GCC_PREFIX}${_SIZE} OBJCOPY= ${ARM_GCC_PREFIX}${_OBJCOPY} OBJDUMP= ${ARM_GCC_PREFIX}${_OBJDUMP} ================================================ FILE: sys/arch/stm32/conf/devices.stm32 ================================================ # # List of block devices and majors # sd 0 ================================================ FILE: sys/arch/stm32/conf/files.stm32 ================================================ # # Kernel sources, architecture-agnostic. # kern/exec_aout.c standard kern/exec_conf.c standard kern/exec_elf.c standard kern/exec_script.c standard kern/exec_subr.c standard kern/init_main.c standard kern/init_sysent.c standard kern/kern_clock.c standard kern/kern_descrip.c standard kern/kern_exec.c standard kern/kern_exit.c standard kern/kern_fork.c standard kern/kern_mman.c standard kern/kern_proc.c standard kern/kern_prot.c standard kern/kern_prot2.c standard kern/kern_resource.c standard kern/kern_sig.c standard kern/kern_sig2.c standard kern/kern_subr.c standard kern/kern_synch.c standard kern/kern_sysctl.c standard kern/kern_time.c standard kern/subr_log.c optional log kern/subr_prf.c standard kern/subr_rmap.c standard kern/sys_generic.c standard kern/sys_inode.c standard kern/sys_pipe.c standard kern/sys_process.c standard kern/syscalls.c standard kern/tty.c standard kern/tty_pty.c optional pty kern/tty_subr.c standard kern/tty_tty.c standard kern/ufs_alloc.c standard kern/ufs_bio.c standard kern/ufs_bmap.c standard kern/ufs_dsort.c standard kern/ufs_fio.c standard kern/ufs_inode.c standard kern/ufs_mount.c standard kern/ufs_namei.c standard kern/ufs_subr.c standard kern/ufs_syscalls.c standard kern/ufs_syscalls2.c standard kern/vfs_vnops.c standard kern/vm_sched.c standard kern/vm_swap.c standard kern/vm_swp.c standard # # Driver sources, architecture-agnostic. # dev/cons.c standard dev/mem.c standard dev/swap.c standard # # STM32 platform. # arch/stm32/stm32/clock.c standard arch/stm32/stm32/conf.c standard arch/stm32/stm32/fault.c standard arch/stm32/stm32/machdep.c standard arch/stm32/stm32/mpu.c standard arch/stm32/stm32/sig_machdep.c standard arch/stm32/stm32/syscall.c standard arch/stm32/stm32/sysctl.c standard arch/stm32/stm32/systick.c standard # # STM32 hardware abstraction layer. # arch/stm32/hal/stm32f4xx_hal.c standard arch/stm32/hal/stm32f4xx_hal_sd.c optional sdio arch/stm32/hal/stm32f4xx_hal_spi.c optional spi #arch/stm32/hal/stm32f4xx_ll_rcc.c standard arch/stm32/hal/stm32f4xx_ll_sdmmc.c optional sdio #arch/stm32/hal/stm32f4xx_ll_usart.c optional uart arch/stm32/hal/stm32f4xx_ll_utils.c standard arch/stm32/hal/system_stm32f4xx.c standard # # STM32 drivers. # arch/stm32/dev/sd.c optional sd arch/stm32/dev/sdio.c optional sdio arch/stm32/dev/sdio_card.c optional sd arch/stm32/dev/spi.c optional spi arch/stm32/dev/uart.c optional uart # # STM32 BSP LED and Button drivers for boards. # arch/stm32/dev/stm32_bsp.c optional bsp # # STM32 SDIO SD driver for boards. # arch/stm32/dev/stm32_sdio_sd.c optional sdio # # STM32 SPI SD driver for ADAFRUIT_SD_ID254 board. # arch/stm32/dev/stm32_adafruit_sd.c optional spi arch/stm32/dev/stm32f4xx_nucleo_sd.c optional spi ================================================ FILE: sys/arch/stm32/conf/kern.ldscript ================================================ /* * Kernel common linker script for STM32. */ /* * On STM32, a minimum of 128 kbytes of flash and 128 kbytes of RAM is needed. * Reserve for the kernel at least 128 kbytes of flash and 32 kbytes of RAM. * Reserve for userland at least 96 kbytes of RAM. */ __kernel_flash_start = ORIGIN(FLASH); __kernel_flash_end = ORIGIN(FLASH) + LENGTH(FLASH); __kernel_data_start = ORIGIN(RAM); __kernel_data_end = ORIGIN(RAM) + LENGTH(RAM); __user_data_start = ORIGIN(USERRAM); __user_data_end = ORIGIN(USERRAM) + LENGTH(USERRAM); u0 = ORIGIN(U0AREA); u = ORIGIN(UAREA); u_end = ORIGIN(UAREA) + LENGTH(UAREA); _estack = ORIGIN(UAREA) + LENGTH(UAREA); ENTRY(Reset_Handler) SECTIONS { .text : { KEEP(*(.isr_vector)) . = ALIGN(8); *(.text*) . = ALIGN(8); *(.rodata*) } > FLASH .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } > FLASH .ARM.exidx : { __exidx_start = .; *(.ARM.exidx* .gnu.linkonce.armexidx.*) __exidx_end = .; } > FLASH __etext = .; _sidata = .; .data : { __data_start__ = .; _sdata = .; *(.data*) . = ALIGN(8); __data_end__ = .; _edata = .; } > RAM AT > FLASH .bss : { . = ALIGN(8); __bss_start__ = .; _sbss = .; *(.bss*) *(COMMON) . = ALIGN(8); __bss_end__ = .; _ebss = .; } > RAM } ================================================ FILE: sys/arch/stm32/dev/sd.c ================================================ /* * SD or SDHC card connected to SPI or SDIO port. * * Up to two cards can be connected to the same SPI port. * PC-compatible partition table is supported. * The following device numbers are used: * * Major Minor Device Partition * ---------------------------------------------- * 0 0 sd0 Main SD card, whole volume * 0 1 sd0a 1-st partition, usually root FS * 0 2 sd0b 2-nd partition, usually swap * 0 3 sd0c 3-rd partition * 0 4 sd0d 4-th partition * 0 8 sd1 Second SD card, whole volume * 0 9 sd1a 1-st partition * 0 10 sd1b 2-nd partition * 0 11 sd1c 3-rd partition * 0 12 sd1d 4-th partition * * Copyright (C) 2010-2015 Serge Vakulenko, * * Permission to use, copy, modify, and distribute this software * and its documentation for any purpose and without fee is hereby * granted, provided that the above copyright notice appear in all * copies and that both that the copyright notice and this * permission notice and warranty disclaimer appear in supporting * documentation, and that the name of the author not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * * The author disclaim all warranties with regard to this * software, including all implied warranties of merchantability * and fitness. In no event shall the author be liable for any * special, indirect or consequential damages or any damages * whatsoever resulting from loss of use, data or profits, whether * in an action of contract, negligence or other tortious action, * arising out of or in connection with the use or performance of * this software. */ #include #include #include #include #include #include #include #include #include #define sdunit(dev) ((minor(dev) & 8) >> 3) #define sdpart(dev) ((minor(dev) & 7)) #define RAWPART 0 /* 'x' partition */ /* * Detect a card. */ static int sd_setup(int unit) { struct disk *du = &sddrives[unit]; u_short buf[256]; if (! card_init(unit)) { printf("sd%d: no SD/MMC card detected\n", unit); return 0; } /* Get the size of raw partition. */ bzero(du->part, sizeof(du->part)); du->part[RAWPART].dp_offset = 0; du->part[RAWPART].dp_nsectors = card_size(unit); if (du->part[RAWPART].dp_nsectors == 0) { printf("sd%d: cannot get card size\n", unit); return 0; } printf("sd%d: type %s, size %u kbytes\n", unit, (du->card_type == TYPE_SDHC) ? "SDHC" : (du->card_type == TYPE_SD_II) ? "II" : "I", du->part[RAWPART].dp_nsectors / 2); /* Read partition table. */ int s = splbio(); if (! card_read(unit, 0, (char*)buf, sizeof(buf))) { splx(s); printf("sd%d: cannot read partition table\n", unit); return 0; } splx(s); if (buf[255] == MBR_MAGIC) { bcopy(&buf[223], &du->part[1], 64); int i; for (i=1; i<=NPARTITIONS; i++) { if (du->part[i].dp_type != 0) printf("sd%d%c: partition type %02x, sector %u, size %u kbytes\n", unit, i+'a'-1, du->part[i].dp_type, du->part[i].dp_offset, du->part[i].dp_nsectors / 2); } } return 1; } /* * Disable the SD card. */ static void sd_release(int unit) { struct disk *du = &sddrives[unit]; card_release(unit); /* Forget the partition table. */ du->part[RAWPART].dp_nsectors = 0; } /* * sd block device */ int sdopen(dev_t dev, int flags, int mode) { int unit = sdunit(dev); int part = sdpart(dev); struct disk *du = &sddrives[unit]; unsigned mask, i; if (unit >= NSD || part > NPARTITIONS) return ENXIO; /* * Setup the SD card interface. */ if (du->part[RAWPART].dp_nsectors == 0) { if (! sd_setup(unit)) { return ENODEV; } } mask = 1 << part; /* * Warn if a partion is opened * that overlaps another partition which is open * unless one is the "raw" partition (whole disk). */ if (part != RAWPART && (du->openpart & mask) == 0) { unsigned start = du->part[part].dp_offset; unsigned end = start + du->part[part].dp_nsectors; /* Check for overlapped partitions. */ for (i=0; i<=NPARTITIONS; i++) { struct diskpart *pp = &du->part[i]; if (i == part || i == RAWPART) continue; if (pp->dp_offset + pp->dp_nsectors <= start || pp->dp_offset >= end) continue; if (du->openpart & (1 << i)) printf("sd%d%c: overlaps open partition (sd%d%c)\n", unit, part + 'a' - 1, unit, pp - du->part + 'a' - 1); } } du->openpart |= mask; return 0; } int sdclose(dev_t dev, int mode, int flag) { int unit = sdunit(dev); int part = sdpart(dev); struct disk *du = &sddrives[unit]; if (unit >= NSD || part > NPARTITIONS) return ENODEV; du->openpart &= ~(1 << part); if (du->openpart == 0) { /* All partitions closed. * Release the SD card. */ sd_release(unit); } return 0; } /* * Get disk size in kbytes. * Return nonzero if successful. */ daddr_t sdsize(dev_t dev) { int unit = sdunit(dev); int part = sdpart(dev); struct disk *du = &sddrives[unit]; if (unit >= NSD || part > NPARTITIONS || du->openpart == 0) return 0; return du->part[part].dp_nsectors >> 1; } void sdstrategy(struct buf *bp) { int unit = sdunit(bp->b_dev); struct disk *du = &sddrives[unit]; struct diskpart *p = &du->part[sdpart(bp->b_dev)]; int part_size = p->dp_nsectors >> 1; int offset = bp->b_blkno; long nblk = btod(bp->b_bcount); int s; /* * Determine the size of the transfer, and make sure it is * within the boundaries of the partition. */ offset += p->dp_offset >> 1; if (offset == 0 && ! (bp->b_flags & B_READ) && ! du->label_writable) { /* Write to partition table not allowed. */ bp->b_error = EROFS; bad: bp->b_flags |= B_ERROR; biodone(bp); return; } if (bp->b_blkno + nblk > part_size) { /* if exactly at end of partition, return an EOF */ if (bp->b_blkno == part_size) { bp->b_resid = bp->b_bcount; biodone(bp); return; } /* or truncate if part of it fits */ nblk = part_size - bp->b_blkno; if (nblk <= 0) { bp->b_error = EINVAL; goto bad; } bp->b_bcount = nblk << DEV_BSHIFT; } if (bp->b_dev == swapdev) { led_control(LED_SWAP, 1); } else { led_control(LED_DISK, 1); } s = splbio(); #ifdef UCB_METER if (du->dkindex >= 0) { dk_busy |= 1 << du->dkindex; dk_xfer[du->dkindex]++; dk_bytes[du->dkindex] += bp->b_bcount; } #endif if (bp->b_flags & B_READ) { card_read(unit, offset, bp->b_addr, bp->b_bcount); } else { card_write(unit, offset, bp->b_addr, bp->b_bcount); } biodone(bp); if (bp->b_dev == swapdev) { led_control(LED_SWAP, 0); } else { led_control(LED_DISK, 0); } #ifdef UCB_METER if (du->dkindex >= 0) dk_busy &= ~(1 << du->dkindex); #endif splx(s); } int sdioctl(dev_t dev, u_int cmd, caddr_t addr, int flag) { int unit = sdunit(dev); int part = sdpart(dev); struct diskpart *dp; int i, error = 0; switch (cmd) { case DIOCGETMEDIASIZE: /* Get disk size in kbytes. */ dp = &sddrives[unit].part[part]; *(int*) addr = dp->dp_nsectors >> 1; break; case DIOCREINIT: for (i=0; i<=NPARTITIONS; i++) bflush(makedev(major(dev), i)); sd_setup(unit); break; case DIOCGETPART: /* Get partition table entry. */ dp = &sddrives[unit].part[part]; *(struct diskpart*) addr = *dp; break; default: error = EINVAL; break; } return error; } /* * Test to see if device is present. * Return true if found and initialized ok. */ static int sd_probe(config) struct conf_device *config; { int unit = config->dev_unit; const char *ctlr_name = config->dev_cdriver->d_name; int ctlr_num = config->dev_ctlr; if (unit < 0 || unit >= NSD) return 0; printf("sd%u: port %s%d\n", unit, ctlr_name, ctlr_num); if (! card_init(unit)) { printf("sd%u: cannot open %s%u port\n", unit, ctlr_name, ctlr_num); return 0; } /* Disable the SD card. */ sd_release(unit); #ifdef UCB_METER dk_alloc(&sddrives[unit].dkindex, 1, (unit == 0) ? "sd0" : "sd1"); #endif return 1; } struct driver sddriver = { "sd", sd_probe, }; ================================================ FILE: sys/arch/stm32/dev/sd.h ================================================ #ifndef _SD_H #define _SD_H #include /* * Driver's data per disk drive. */ struct disk { /* * Partition table. */ #define NPARTITIONS 4 struct diskpart part[NPARTITIONS+1]; #define TYPE_UNKNOWN 0 #define TYPE_SD_LEGACY 1 #define TYPE_SD_II 2 #define TYPE_SDHC 3 int card_type; int label_writable; /* is sector 0 writable? */ int dkindex; /* disk index for statistics */ u_int openpart; /* all partitions open on this drive */ u_char ocr[4]; /* operation condition register */ u_char csd[16]; /* card-specific data */ u_short group[6]; /* function group bitmasks */ int ma; /* power consumption */ }; struct disk sddrives[NSD]; /* Table of units */ #ifdef KERNEL extern int sdopen(dev_t dev, int flag, int mode); extern int sdclose(dev_t dev, int flag, int mode); extern void sdstrategy(struct buf *bp); extern daddr_t sdsize(dev_t dev); extern int sdioctl(dev_t dev, u_int cmd, caddr_t addr, int flag); #endif /* KERNEL */ #endif /* _SD_H */ ================================================ FILE: sys/arch/stm32/dev/sdio.c ================================================ /* * SDIO driver for STM32. */ #include #include #include #include int sdio_open(dev_t dev, int flag, int mode) { return (0); } int sdio_close(dev_t dev, int flag, int mode) { return (0); } int sdio_read(dev_t dev, struct uio *uio, int flag) { return (0); } int sdio_write(dev_t dev, struct uio *uio, int flag) { return (0); } int sdio_ioctl(dev_t dev, u_int cmd, caddr_t addr, int flag) { return (0); } static int sdio_probe(struct conf_ctlr *config) { return (1); } struct driver sdiodriver = { "sdio", sdio_probe, }; ================================================ FILE: sys/arch/stm32/dev/sdio.h ================================================ #ifndef _MACHINE_SDIO_H_ #define _MACHINE_SDIO_H_ #ifdef KERNEL int sdio_open(dev_t dev, int flag, int mode); int sdio_close(dev_t dev, int flag, int mode); int sdio_read(dev_t dev, struct uio *uio, int flag); int sdio_write(dev_t dev, struct uio *uio, int flag); int sdio_ioctl(dev_t dev, u_int cmd, caddr_t addr, int flag); #endif /* KERNEL */ #endif /* _MACHINE_SDIO_H_ */ ================================================ FILE: sys/arch/stm32/dev/sdio_card.c ================================================ /* * Copyright (c) 2021 Christopher Hettrick * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include #include #include #include #include #include #define SECTSIZE 512 extern struct disk sddrives[NSD]; /* * Initialize a card. * Return nonzero if successful. */ int card_init(int unit) { struct disk *du = &sddrives[unit]; BSP_SD_CardInfo ci; if (BSP_SD_Init() != BSP_SD_OK) { return 0; } BSP_SD_GetCardInfo(&ci); #if 0 // XXX SD CARD TYPE du->card_type = ci.CardType; #endif // XXX SD CARD TYPE du->card_type = TYPE_SDHC; // XXX SD CARD TYPE return 1; } /* * Get disk size in 512-byte sectors. * Return nonzero if successful. */ int card_size(int unit) { BSP_SD_CardInfo ci; BSP_SD_GetCardInfo(&ci); return ci.LogBlockNbr; } /* * Read a block of data. * Return nonzero if successful. */ int card_read(int unit, unsigned int offset, char *data, unsigned int bcount) { int nblocks; uint8_t SD_state = BSP_SD_OK; if ((bcount % SECTSIZE) == 0) { nblocks = bcount / SECTSIZE; } else { nblocks = (bcount / SECTSIZE) + 1; } DEBUG("card_read: bcount: %d\tnblocks: %d\tbcount \% %d: %d\n", bcount, nblocks, SECTSIZE, bcount % SECTSIZE); SD_state = BSP_SD_ReadBlocks((uint32_t *)data, offset << 1, nblocks, SD_DATATIMEOUT); if (SD_state != BSP_SD_OK) { printf("card_read: read failed\n"); return 0; } return 1; } /* * Write a block of data. * Return nonzero if successful. */ int card_write(int unit, unsigned offset, char *data, unsigned bcount) { int nblocks; uint8_t SD_state = BSP_SD_OK; if ((bcount % SECTSIZE) == 0) { nblocks = bcount / SECTSIZE; } else { nblocks = (bcount / SECTSIZE) + 1; } DEBUG("card_write: bcount: %d\tnblocks: %d\tbcount \% %d: %d\n", bcount, nblocks, SECTSIZE, bcount % SECTSIZE); SD_state = BSP_SD_WriteBlocks((uint32_t *)data, offset << 1, nblocks, SD_DATATIMEOUT); /* Wait for write completion. */ int x = spl0(); while (BSP_SD_GetCardState() != BSP_SD_OK) ; splx(x); if (SD_state != BSP_SD_OK) { printf("card_write: write failed\n"); return 0; } return 1; } /* * Disable the SD card. */ void card_release(int unit) { BSP_SD_DeInit(); } ================================================ FILE: sys/arch/stm32/dev/sdio_card.h ================================================ #ifndef _MACHINE_SDIO_CARD_H_ #define _MACHINE_SDIO_CARD_H_ #ifdef KERNEL int card_init(int unit); int card_size(int unit); int card_read(int unit, unsigned int offset, char *data, unsigned int bcount); int card_write(int unit, unsigned offset, char *data, unsigned bcount); void card_release(int unit); #endif /* KERNEL */ #endif /* _MACHINE_SDIO_CARD_H_ */ ================================================ FILE: sys/arch/stm32/dev/spi.c ================================================ /* * SPI driver for STM32. */ #include #include #include #include int spi_open(dev_t dev, int flag, int mode) { return (0); } int spi_close(dev_t dev, int flag, int mode) { return (0); } int spi_read(dev_t dev, struct uio *uio, int flag) { return (0); } int spi_write(dev_t dev, struct uio *uio, int flag) { return (0); } int spi_ioctl(dev_t dev, u_int cmd, caddr_t addr, int flag) { return (0); } static int spi_probe(struct conf_ctlr *config) { return (1); } struct driver spidriver = { "spi", spi_probe, }; ================================================ FILE: sys/arch/stm32/dev/spi.h ================================================ #ifndef _MACHINE_SPI_H_ #define _MACHINE_SPI_H_ #ifdef KERNEL int spi_open(dev_t dev, int flag, int mode); int spi_close(dev_t dev, int flag, int mode); int spi_read(dev_t dev, struct uio *uio, int flag); int spi_write(dev_t dev, struct uio *uio, int flag); int spi_ioctl(dev_t dev, u_int cmd, caddr_t addr, int flag); #endif /* KERNEL */ #endif /* _MACHINE_SPI_H_ */ ================================================ FILE: sys/arch/stm32/dev/stm32_adafruit_sd.c ================================================ /** ****************************************************************************** * @file stm32_adafruit_sd.c * @author MCD Application Team * @version V3.0.3 * @date 30-April-2018 * @brief This file provides a set of functions needed to manage the SD card * mounted on the Adafruit MicroSD Breakout Board+ (reference ID 254), * that is used with the STM32 Nucleo board through SPI interface. * It implements a high level communication layer for read and write * from/to this memory. The needed STM32XXxx hardware resources (SPI and * GPIO) are defined in stm32XXxx_nucleo_sd.h file, and the initialization is * performed in SD_IO_Init() function declared in stm32XXxx_nucleo_sd.c * file. * You can easily tailor this driver to any other development board, * by just adapting the defines for hardware resources and * SD_IO_Init() function. * * +-------------------------------------------------------+ * | Pin assignment | * +-------------------------+---------------+-------------+ * | STM32XXxx SPI Pins | SD | Pin | * +-------------------------+---------------+-------------+ * | SD_SPI_CS_PIN | ChipSelect | 1 | * | SD_SPI_MOSI_PIN / MOSI | DataIn | 2 | * | | GND | 3 (0 V) | * | | VDD | 4 (3.3 V)| * | SD_SPI_SCK_PIN / SCLK | Clock | 5 | * | | GND | 6 (0 V) | * | SD_SPI_MISO_PIN / MISO | DataOut | 7 | * +-------------------------+---------------+-------------+ ****************************************************************************** * @attention * *

© COPYRIGHT(c) 2016 STMicroelectronics

* * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. Neither the name of STMicroelectronics nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ /* File Info : ----------------------------------------------------------------- User NOTES 1. How to use this driver: -------------------------- - This driver does not need a specific component driver for the micro SD device to be included with. 2. Driver description: --------------------- + Initialization steps: o Initialize the micro SD card using the BSP_SD_Init() function. o Checking the SD card presence is not managed. o The function BSP_SD_GetCardInfo() is used to get the micro SD card information which is stored in the structure "BSP_SD_CardInfo". + Micro SD card operations o The micro SD card can be accessed with read/write block(s) operations once it is ready for access. The access can be performed in polling mode by calling the functions BSP_SD_ReadBlocks()/BSP_SD_WriteBlocks(). o The SD erase block(s) is performed using the function BSP_SD_Erase() with specifying the number of blocks to erase. o The SD runtime status is returned when calling the function BSP_SD_GetCardState(). ------------------------------------------------------------------------------*/ /* To be defined only if provided with the Adafruit MicroSD Breakout Board+ */ /* https://www.adafruit.com/product/254 */ #ifdef SPI_SD_ENABLED /* Kernel Config 'options' definition. */ /* Includes ------------------------------------------------------------------*/ #include #include #include /* Private typedef -----------------------------------------------------------*/ typedef struct { uint8_t r1; uint8_t r2; uint8_t r3; uint8_t r4; uint8_t r5; } SD_CmdAnswer_typedef; /* Private define ------------------------------------------------------------*/ #define SD_BLOCK_SIZE 0x200 #define SD_DUMMY_BYTE 0xFF #define SD_MAX_FRAME_LENGTH 17 /* Length = 16 + 1 */ #define SD_CMD_LENGTH 6 #define SD_MAX_TRY 100 /* Number of try */ #define SD_CSD_STRUCT_V1 0x2 /* CSD struct version V1 */ #define SD_CSD_STRUCT_V2 0x1 /* CSD struct version V2 */ /** * @brief SD answer format */ typedef enum { SD_ANSWER_R1_EXPECTED, SD_ANSWER_R1B_EXPECTED, SD_ANSWER_R2_EXPECTED, SD_ANSWER_R3_EXPECTED, SD_ANSWER_R4R5_EXPECTED, SD_ANSWER_R7_EXPECTED, }SD_Answer_type; /** * @brief Start Data tokens: * Tokens (necessary because at nop/idle (and CS active) only 0xff is * on the data/command line) */ #define SD_TOKEN_START_DATA_SINGLE_BLOCK_READ 0xFE /* Data token start byte, Start Single Block Read */ #define SD_TOKEN_START_DATA_MULTIPLE_BLOCK_READ 0xFE /* Data token start byte, Start Multiple Block Read */ #define SD_TOKEN_START_DATA_SINGLE_BLOCK_WRITE 0xFE /* Data token start byte, Start Single Block Write */ #define SD_TOKEN_START_DATA_MULTIPLE_BLOCK_WRITE 0xFD /* Data token start byte, Start Multiple Block Write */ #define SD_TOKEN_STOP_DATA_MULTIPLE_BLOCK_WRITE 0xFD /* Data token stop byte, Stop Multiple Block Write */ /** * @brief Commands: CMDxx = CMD-number | 0x40 */ #define SD_CMD_GO_IDLE_STATE 0 /* CMD0 = 0x40 */ #define SD_CMD_SEND_OP_COND 1 /* CMD1 = 0x41 */ #define SD_CMD_SEND_IF_COND 8 /* CMD8 = 0x48 */ #define SD_CMD_SEND_CSD 9 /* CMD9 = 0x49 */ #define SD_CMD_SEND_CID 10 /* CMD10 = 0x4A */ #define SD_CMD_STOP_TRANSMISSION 12 /* CMD12 = 0x4C */ #define SD_CMD_SEND_STATUS 13 /* CMD13 = 0x4D */ #define SD_CMD_SET_BLOCKLEN 16 /* CMD16 = 0x50 */ #define SD_CMD_READ_SINGLE_BLOCK 17 /* CMD17 = 0x51 */ #define SD_CMD_READ_MULT_BLOCK 18 /* CMD18 = 0x52 */ #define SD_CMD_SET_BLOCK_COUNT 23 /* CMD23 = 0x57 */ #define SD_CMD_WRITE_SINGLE_BLOCK 24 /* CMD24 = 0x58 */ #define SD_CMD_WRITE_MULT_BLOCK 25 /* CMD25 = 0x59 */ #define SD_CMD_PROG_CSD 27 /* CMD27 = 0x5B */ #define SD_CMD_SET_WRITE_PROT 28 /* CMD28 = 0x5C */ #define SD_CMD_CLR_WRITE_PROT 29 /* CMD29 = 0x5D */ #define SD_CMD_SEND_WRITE_PROT 30 /* CMD30 = 0x5E */ #define SD_CMD_SD_ERASE_GRP_START 32 /* CMD32 = 0x60 */ #define SD_CMD_SD_ERASE_GRP_END 33 /* CMD33 = 0x61 */ #define SD_CMD_UNTAG_SECTOR 34 /* CMD34 = 0x62 */ #define SD_CMD_ERASE_GRP_START 35 /* CMD35 = 0x63 */ #define SD_CMD_ERASE_GRP_END 36 /* CMD36 = 0x64 */ #define SD_CMD_UNTAG_ERASE_GROUP 37 /* CMD37 = 0x65 */ #define SD_CMD_ERASE 38 /* CMD38 = 0x66 */ #define SD_CMD_SD_APP_OP_COND 41 /* CMD41 = 0x69 */ #define SD_CMD_APP_CMD 55 /* CMD55 = 0x77 */ #define SD_CMD_READ_OCR 58 /* CMD55 = 0x79 */ /** * @brief SD responses and error flags */ typedef enum { /* R1 answer value */ SD_R1_NO_ERROR = (0x00), SD_R1_IN_IDLE_STATE = (0x01), SD_R1_ERASE_RESET = (0x02), SD_R1_ILLEGAL_COMMAND = (0x04), SD_R1_COM_CRC_ERROR = (0x08), SD_R1_ERASE_SEQUENCE_ERROR= (0x10), SD_R1_ADDRESS_ERROR = (0x20), SD_R1_PARAMETER_ERROR = (0x40), /* R2 answer value */ SD_R2_NO_ERROR = 0x00, SD_R2_CARD_LOCKED = 0x01, SD_R2_LOCKUNLOCK_ERROR = 0x02, SD_R2_ERROR = 0x04, SD_R2_CC_ERROR = 0x08, SD_R2_CARD_ECC_FAILED = 0x10, SD_R2_WP_VIOLATION = 0x20, SD_R2_ERASE_PARAM = 0x40, SD_R2_OUTOFRANGE = 0x80, /** * @brief Data response error */ SD_DATA_OK = (0x05), SD_DATA_CRC_ERROR = (0x0B), SD_DATA_WRITE_ERROR = (0x0D), SD_DATA_OTHER_ERROR = (0xFF) } SD_Error; /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ /* flag_SDHC : 0 : Standard capacity 1 : High capacity */ uint16_t flag_SDHC = 0; /* Private function prototypes -----------------------------------------------*/ static uint8_t SD_GetCSDRegister(SD_CSD* Csd); static uint8_t SD_GetCIDRegister(SD_CID* Cid); static SD_CmdAnswer_typedef SD_SendCmd(uint8_t Cmd, uint32_t Arg, uint8_t Crc, uint8_t Answer); static uint8_t SD_GetDataResponse(void); static uint8_t SD_ReadData(void); static uint8_t SD_WaitData(uint8_t data); static uint8_t SD_GoIdleState(void); /* Public functions ----------------------------------------------------------*/ /** * @brief Initializes the SD/SD communication. * @param None * @retval The SD Response: * - BSP_SD_ERROR: Sequence failed * - BSP_SD_OK: Sequence succeed */ uint8_t BSP_SD_Init(void) { /* Configure IO functionalities for SD pin */ SD_IO_Init(); /* SD initialized and set to SPI mode properly */ return SD_GoIdleState(); } /** * @brief DeInitializes the SD/SD communication. * @retval The SD Response: * - BSP_SD_ERROR: Sequence failed * - BSP_SD_OK: Sequence succeed */ uint8_t BSP_SD_DeInit(void) { uint8_t sd_state = BSP_SD_OK; return sd_state; } /** * @brief Reads block(s) from a specified address in the SD card, in polling mode. * @param pData: Pointer to the buffer that will contain the data to transmit * @param ReadAddr: Address from where data is to be read. The address is counted * in blocks of 512bytes * @param NumOfBlocks: Number of SD blocks to read * @param Timeout: This parameter is used for compatibility with BSP implementation * @retval SD status */ uint8_t BSP_SD_ReadBlocks(uint32_t *pData, uint32_t ReadAddr, uint32_t NumOfBlocks, uint32_t Timeout) { uint32_t offset = 0; uint32_t addr; uint8_t retr = BSP_SD_ERROR; uint8_t ptr[sizeof(uint8_t) * SD_BLOCK_SIZE]; SD_CmdAnswer_typedef response; /* Send CMD16 (SD_CMD_SET_BLOCKLEN) to set the size of the block and Check if the SD acknowledged the set block length command: R1 response (0x00: no errors) */ response = SD_SendCmd(SD_CMD_SET_BLOCKLEN, SD_BLOCK_SIZE, 0xFF, SD_ANSWER_R1_EXPECTED); SD_IO_CSState(1); SD_IO_WriteByte(SD_DUMMY_BYTE); if ( response.r1 != SD_R1_NO_ERROR) { goto error; } bzero(ptr, sizeof(uint8_t) * SD_BLOCK_SIZE); /* Initialize the address */ addr = (ReadAddr * ((flag_SDHC == 1) ? 1 : SD_BLOCK_SIZE)); /* Data transfer */ while (NumOfBlocks--) { /* Send CMD17 (SD_CMD_READ_SINGLE_BLOCK) to read one block */ /* Check if the SD acknowledged the read block command: R1 response (0x00: no errors) */ response = SD_SendCmd(SD_CMD_READ_SINGLE_BLOCK, addr, 0xFF, SD_ANSWER_R1_EXPECTED); if ( response.r1 != SD_R1_NO_ERROR) { goto error; } /* Now look for the data token to signify the start of the data */ if (SD_WaitData(SD_TOKEN_START_DATA_SINGLE_BLOCK_READ) == BSP_SD_OK) { /* Read the SD block data : read NumByteToRead data */ SD_IO_WriteReadData(ptr, (uint8_t*)pData + offset, SD_BLOCK_SIZE); /* Set next read address*/ offset += SD_BLOCK_SIZE; addr = ((flag_SDHC == 1) ? (addr + 1) : (addr + SD_BLOCK_SIZE)); /* get CRC bytes (not really needed by us, but required by SD) */ SD_IO_WriteByte(SD_DUMMY_BYTE); SD_IO_WriteByte(SD_DUMMY_BYTE); } else { goto error; } /* End the command data read cycle */ SD_IO_CSState(1); SD_IO_WriteByte(SD_DUMMY_BYTE); } retr = BSP_SD_OK; error: /* Send dummy byte: 8 Clock pulses of delay */ SD_IO_CSState(1); SD_IO_WriteByte(SD_DUMMY_BYTE); /* Return the response */ return retr; } /** * @brief Writes block(s) to a specified address in the SD card, in polling mode. * @param pData: Pointer to the buffer that will contain the data to transmit * @param WriteAddr: Address from where data is to be written. The address is counted * in blocks of 512bytes * @param NumOfBlocks: Number of SD blocks to write * @param Timeout: This parameter is used for compatibility with BSP implementation * @retval SD status */ uint8_t BSP_SD_WriteBlocks(uint32_t *pData, uint32_t WriteAddr, uint32_t NumOfBlocks, uint32_t Timeout) { uint32_t offset = 0; uint32_t addr; uint8_t retr = BSP_SD_ERROR; uint8_t ptr[sizeof(uint8_t) * SD_BLOCK_SIZE]; SD_CmdAnswer_typedef response; /* Send CMD16 (SD_CMD_SET_BLOCKLEN) to set the size of the block and Check if the SD acknowledged the set block length command: R1 response (0x00: no errors) */ response = SD_SendCmd(SD_CMD_SET_BLOCKLEN, SD_BLOCK_SIZE, 0xFF, SD_ANSWER_R1_EXPECTED); SD_IO_CSState(1); SD_IO_WriteByte(SD_DUMMY_BYTE); if ( response.r1 != SD_R1_NO_ERROR) { goto error; } /* Initialize the address */ addr = (WriteAddr * ((flag_SDHC == 1) ? 1 : SD_BLOCK_SIZE)); /* Data transfer */ while (NumOfBlocks--) { /* Send CMD24 (SD_CMD_WRITE_SINGLE_BLOCK) to write blocks and Check if the SD acknowledged the write block command: R1 response (0x00: no errors) */ response = SD_SendCmd(SD_CMD_WRITE_SINGLE_BLOCK, addr, 0xFF, SD_ANSWER_R1_EXPECTED); if (response.r1 != SD_R1_NO_ERROR) { goto error; } /* Send dummy byte for NWR timing : one byte between CMDWRITE and TOKEN */ SD_IO_WriteByte(SD_DUMMY_BYTE); SD_IO_WriteByte(SD_DUMMY_BYTE); /* Send the data token to signify the start of the data */ SD_IO_WriteByte(SD_TOKEN_START_DATA_SINGLE_BLOCK_WRITE); /* Write the block data to SD */ SD_IO_WriteReadData((uint8_t*)pData + offset, ptr, SD_BLOCK_SIZE); /* Set next write address */ offset += SD_BLOCK_SIZE; addr = ((flag_SDHC == 1) ? (addr + 1) : (addr + SD_BLOCK_SIZE)); /* Put CRC bytes (not really needed by us, but required by SD) */ SD_IO_WriteByte(SD_DUMMY_BYTE); SD_IO_WriteByte(SD_DUMMY_BYTE); /* Read data response */ if (SD_GetDataResponse() != SD_DATA_OK) { /* Set response value to failure */ goto error; } SD_IO_CSState(1); SD_IO_WriteByte(SD_DUMMY_BYTE); } retr = BSP_SD_OK; error: /* Send dummy byte: 8 Clock pulses of delay */ SD_IO_CSState(1); SD_IO_WriteByte(SD_DUMMY_BYTE); /* Return the response */ return retr; } /** * @brief Erases the specified memory area of the given SD card. * @param StartAddr: Start address in Blocks (Size of a block is 512bytes) * @param EndAddr: End address in Blocks (Size of a block is 512bytes) * @retval SD status */ uint8_t BSP_SD_Erase(uint32_t StartAddr, uint32_t EndAddr) { uint8_t retr = BSP_SD_ERROR; SD_CmdAnswer_typedef response; /* Send CMD32 (Erase group start) and check if the SD acknowledged the erase command: R1 response (0x00: no errors) */ response = SD_SendCmd(SD_CMD_SD_ERASE_GRP_START, (StartAddr) * (flag_SDHC == 1 ? 1 : SD_BLOCK_SIZE), 0xFF, SD_ANSWER_R1_EXPECTED); SD_IO_CSState(1); SD_IO_WriteByte(SD_DUMMY_BYTE); if (response.r1 == SD_R1_NO_ERROR) { /* Send CMD33 (Erase group end) and Check if the SD acknowledged the erase command: R1 response (0x00: no errors) */ response = SD_SendCmd(SD_CMD_SD_ERASE_GRP_END, (EndAddr*512) * (flag_SDHC == 1 ? 1 : SD_BLOCK_SIZE), 0xFF, SD_ANSWER_R1_EXPECTED); SD_IO_CSState(1); SD_IO_WriteByte(SD_DUMMY_BYTE); if (response.r1 == SD_R1_NO_ERROR) { /* Send CMD38 (Erase) and Check if the SD acknowledged the erase command: R1 response (0x00: no errors) */ response = SD_SendCmd(SD_CMD_ERASE, 0, 0xFF, SD_ANSWER_R1B_EXPECTED); if (response.r1 == SD_R1_NO_ERROR) { retr = BSP_SD_OK; } SD_IO_CSState(1); SD_IO_WriteByte(SD_DUMMY_BYTE); } } /* Return the response */ return retr; } /** * @brief Returns the SD status. * @param None * @retval The SD status. */ uint8_t BSP_SD_GetCardState(void) { SD_CmdAnswer_typedef retr; /* Send CMD13 (SD_SEND_STATUS) to get SD status */ retr = SD_SendCmd(SD_CMD_SEND_STATUS, 0, 0xFF, SD_ANSWER_R2_EXPECTED); SD_IO_CSState(1); SD_IO_WriteByte(SD_DUMMY_BYTE); /* Find SD status according to card state */ if(( retr.r1 == SD_R1_NO_ERROR) && ( retr.r2 == SD_R2_NO_ERROR)) { return BSP_SD_OK; } return BSP_SD_ERROR; } /** * @brief Returns information about specific card. * @param pCardInfo: Pointer to a BSP_SD_CardInfo structure that contains all SD * card information. * @retval The SD Response: * - BSP_SD_ERROR: Sequence failed * - BSP_SD_OK: Sequence succeed */ uint8_t BSP_SD_GetCardInfo(BSP_SD_CardInfo *pCardInfo) { uint8_t status; status = SD_GetCSDRegister(&(pCardInfo->Csd)); status|= SD_GetCIDRegister(&(pCardInfo->Cid)); if(flag_SDHC == 1 ) { pCardInfo->LogBlockSize = 512; pCardInfo->CardBlockSize = 512; pCardInfo->CardCapacity = (pCardInfo->Csd.version.v2.DeviceSize + 1) * 1024 * pCardInfo->LogBlockSize; pCardInfo->LogBlockNbr = (pCardInfo->CardCapacity) / (pCardInfo->LogBlockSize); } else { pCardInfo->CardCapacity = (pCardInfo->Csd.version.v1.DeviceSize + 1) ; pCardInfo->CardCapacity *= (1 << (pCardInfo->Csd.version.v1.DeviceSizeMul + 2)); pCardInfo->LogBlockSize = 512; pCardInfo->CardBlockSize = 1 << (pCardInfo->Csd.RdBlockLen); pCardInfo->CardCapacity *= pCardInfo->CardBlockSize; pCardInfo->LogBlockNbr = (pCardInfo->CardCapacity) / (pCardInfo->LogBlockSize); } return status; } /* Private functions ---------------------------------------------------------*/ /** * @brief Reads the SD card CSD register. * Reading the contents of the CSD register in SPI mode is a simple * read-block transaction. * @param Csd: pointer on an CSD register structure * @retval SD status */ uint8_t SD_GetCSDRegister(SD_CSD* Csd) { uint16_t counter = 0; uint8_t CSD_Tab[16]; uint8_t retr = BSP_SD_ERROR; SD_CmdAnswer_typedef response; /* Send CMD9 (CSD register) and Wait for response in the R1 format (0x00 is no errors) */ response = SD_SendCmd(SD_CMD_SEND_CSD, 0, 0xFF, SD_ANSWER_R1_EXPECTED); if(response.r1 == SD_R1_NO_ERROR) { if (SD_WaitData(SD_TOKEN_START_DATA_SINGLE_BLOCK_READ) == BSP_SD_OK) { for (counter = 0; counter < 16; counter++) { /* Store CSD register value on CSD_Tab */ CSD_Tab[counter] = SD_IO_WriteByte(SD_DUMMY_BYTE); } /* Get CRC bytes (not really needed by us, but required by SD) */ SD_IO_WriteByte(SD_DUMMY_BYTE); SD_IO_WriteByte(SD_DUMMY_BYTE); /************************************************************************* CSD header decoding *************************************************************************/ /* Byte 0 */ Csd->CSDStruct = (CSD_Tab[0] & 0xC0) >> 6; Csd->Reserved1 = CSD_Tab[0] & 0x3F; /* Byte 1 */ Csd->TAAC = CSD_Tab[1]; /* Byte 2 */ Csd->NSAC = CSD_Tab[2]; /* Byte 3 */ Csd->MaxBusClkFrec = CSD_Tab[3]; /* Byte 4/5 */ Csd->CardComdClasses = (CSD_Tab[4] << 4) | ((CSD_Tab[5] & 0xF0) >> 4); Csd->RdBlockLen = CSD_Tab[5] & 0x0F; /* Byte 6 */ Csd->PartBlockRead = (CSD_Tab[6] & 0x80) >> 7; Csd->WrBlockMisalign = (CSD_Tab[6] & 0x40) >> 6; Csd->RdBlockMisalign = (CSD_Tab[6] & 0x20) >> 5; Csd->DSRImpl = (CSD_Tab[6] & 0x10) >> 4; /************************************************************************* CSD v1/v2 decoding *************************************************************************/ if(flag_SDHC == 0) { Csd->version.v1.Reserved1 = ((CSD_Tab[6] & 0x0C) >> 2); Csd->version.v1.DeviceSize = ((CSD_Tab[6] & 0x03) << 10) | (CSD_Tab[7] << 2) | ((CSD_Tab[8] & 0xC0) >> 6); Csd->version.v1.MaxRdCurrentVDDMin = (CSD_Tab[8] & 0x38) >> 3; Csd->version.v1.MaxRdCurrentVDDMax = (CSD_Tab[8] & 0x07); Csd->version.v1.MaxWrCurrentVDDMin = (CSD_Tab[9] & 0xE0) >> 5; Csd->version.v1.MaxWrCurrentVDDMax = (CSD_Tab[9] & 0x1C) >> 2; Csd->version.v1.DeviceSizeMul = ((CSD_Tab[9] & 0x03) << 1) |((CSD_Tab[10] & 0x80) >> 7); } else { Csd->version.v2.Reserved1 = ((CSD_Tab[6] & 0x0F) << 2) | ((CSD_Tab[7] & 0xC0) >> 6); Csd->version.v2.DeviceSize= ((CSD_Tab[7] & 0x3F) << 16) | (CSD_Tab[8] << 8) | CSD_Tab[9]; Csd->version.v2.Reserved2 = ((CSD_Tab[10] & 0x80) >> 8); } Csd->EraseSingleBlockEnable = (CSD_Tab[10] & 0x40) >> 6; Csd->EraseSectorSize = ((CSD_Tab[10] & 0x3F) << 1) |((CSD_Tab[11] & 0x80) >> 7); Csd->WrProtectGrSize = (CSD_Tab[11] & 0x7F); Csd->WrProtectGrEnable = (CSD_Tab[12] & 0x80) >> 7; Csd->Reserved2 = (CSD_Tab[12] & 0x60) >> 5; Csd->WrSpeedFact = (CSD_Tab[12] & 0x1C) >> 2; Csd->MaxWrBlockLen = ((CSD_Tab[12] & 0x03) << 2) |((CSD_Tab[13] & 0xC0) >> 6); Csd->WriteBlockPartial = (CSD_Tab[13] & 0x20) >> 5; Csd->Reserved3 = (CSD_Tab[13] & 0x1F); Csd->FileFormatGroup = (CSD_Tab[14] & 0x80) >> 7; Csd->CopyFlag = (CSD_Tab[14] & 0x40) >> 6; Csd->PermWrProtect = (CSD_Tab[14] & 0x20) >> 5; Csd->TempWrProtect = (CSD_Tab[14] & 0x10) >> 4; Csd->FileFormat = (CSD_Tab[14] & 0x0C) >> 2; Csd->Reserved4 = (CSD_Tab[14] & 0x03); Csd->crc = (CSD_Tab[15] & 0xFE) >> 1; Csd->Reserved5 = (CSD_Tab[15] & 0x01); retr = BSP_SD_OK; } } /* Send dummy byte: 8 Clock pulses of delay */ SD_IO_CSState(1); SD_IO_WriteByte(SD_DUMMY_BYTE); /* Return the response */ return retr; } /** * @brief Reads the SD card CID register. * Reading the contents of the CID register in SPI mode is a simple * read-block transaction. * @param Cid: pointer on an CID register structure * @retval SD status */ uint8_t SD_GetCIDRegister(SD_CID* Cid) { uint32_t counter = 0; uint8_t CID_Tab[16]; uint8_t retr = BSP_SD_ERROR; SD_CmdAnswer_typedef response; /* Send CMD10 (CID register) and Wait for response in the R1 format (0x00 is no errors) */ response = SD_SendCmd(SD_CMD_SEND_CID, 0, 0xFF, SD_ANSWER_R1_EXPECTED); if(response.r1 == SD_R1_NO_ERROR) { if (SD_WaitData(SD_TOKEN_START_DATA_SINGLE_BLOCK_READ) == BSP_SD_OK) { for (counter = 0; counter < 16; counter++) { /* Store CID register value on CID_Tab */ CID_Tab[counter] = SD_IO_WriteByte(SD_DUMMY_BYTE); } /* Get CRC bytes (not really needed by us, but required by SD) */ SD_IO_WriteByte(SD_DUMMY_BYTE); SD_IO_WriteByte(SD_DUMMY_BYTE); /* Byte 0 */ Cid->ManufacturerID = CID_Tab[0]; /* Byte 1 */ Cid->OEM_AppliID = CID_Tab[1] << 8; /* Byte 2 */ Cid->OEM_AppliID |= CID_Tab[2]; /* Byte 3 */ Cid->ProdName1 = CID_Tab[3] << 24; /* Byte 4 */ Cid->ProdName1 |= CID_Tab[4] << 16; /* Byte 5 */ Cid->ProdName1 |= CID_Tab[5] << 8; /* Byte 6 */ Cid->ProdName1 |= CID_Tab[6]; /* Byte 7 */ Cid->ProdName2 = CID_Tab[7]; /* Byte 8 */ Cid->ProdRev = CID_Tab[8]; /* Byte 9 */ Cid->ProdSN = CID_Tab[9] << 24; /* Byte 10 */ Cid->ProdSN |= CID_Tab[10] << 16; /* Byte 11 */ Cid->ProdSN |= CID_Tab[11] << 8; /* Byte 12 */ Cid->ProdSN |= CID_Tab[12]; /* Byte 13 */ Cid->Reserved1 |= (CID_Tab[13] & 0xF0) >> 4; Cid->ManufactDate = (CID_Tab[13] & 0x0F) << 8; /* Byte 14 */ Cid->ManufactDate |= CID_Tab[14]; /* Byte 15 */ Cid->CID_CRC = (CID_Tab[15] & 0xFE) >> 1; Cid->Reserved2 = 1; retr = BSP_SD_OK; } } /* Send dummy byte: 8 Clock pulses of delay */ SD_IO_CSState(1); SD_IO_WriteByte(SD_DUMMY_BYTE); /* Return the response */ return retr; } /** * @brief Sends 5 bytes command to the SD card and get response * @param Cmd: The user expected command to send to SD card. * @param Arg: The command argument. * @param Crc: The CRC. * @param Answer: SD_ANSWER_NOT_EXPECTED or SD_ANSWER_EXPECTED * @retval SD status */ SD_CmdAnswer_typedef SD_SendCmd(uint8_t Cmd, uint32_t Arg, uint8_t Crc, uint8_t Answer) { uint8_t frame[SD_CMD_LENGTH], frameout[SD_CMD_LENGTH]; SD_CmdAnswer_typedef retr = {0xFF, 0xFF , 0xFF, 0xFF, 0xFF}; /* R1 Length = NCS(0)+ 6 Bytes command + NCR(min1 max8) + 1 Bytes answer + NEC(0) = 15bytes */ /* R1b identical to R1 + Busy information */ /* R2 Length = NCS(0)+ 6 Bytes command + NCR(min1 max8) + 2 Bytes answer + NEC(0) = 16bytes */ /* Prepare Frame to send */ frame[0] = (Cmd | 0x40); /* Construct byte 1 */ frame[1] = (uint8_t)(Arg >> 24); /* Construct byte 2 */ frame[2] = (uint8_t)(Arg >> 16); /* Construct byte 3 */ frame[3] = (uint8_t)(Arg >> 8); /* Construct byte 4 */ frame[4] = (uint8_t)(Arg); /* Construct byte 5 */ frame[5] = (Crc | 0x01); /* Construct byte 6 */ /* Send the command */ SD_IO_CSState(0); SD_IO_WriteReadData(frame, frameout, SD_CMD_LENGTH); /* Send the Cmd bytes */ switch(Answer) { case SD_ANSWER_R1_EXPECTED: retr.r1 = SD_ReadData(); break; case SD_ANSWER_R1B_EXPECTED: retr.r1 = SD_ReadData(); retr.r2 = SD_IO_WriteByte(SD_DUMMY_BYTE); /* Set CS High */ SD_IO_CSState(1); HAL_Delay(1); /* Set CS Low */ SD_IO_CSState(0); /* Wait IO line return 0xFF */ while (SD_IO_WriteByte(SD_DUMMY_BYTE) != 0xFF); break; case SD_ANSWER_R2_EXPECTED: retr.r1 = SD_ReadData(); retr.r2 = SD_IO_WriteByte(SD_DUMMY_BYTE); break; case SD_ANSWER_R3_EXPECTED: case SD_ANSWER_R7_EXPECTED: retr.r1 = SD_ReadData(); retr.r2 = SD_IO_WriteByte(SD_DUMMY_BYTE); retr.r3 = SD_IO_WriteByte(SD_DUMMY_BYTE); retr.r4 = SD_IO_WriteByte(SD_DUMMY_BYTE); retr.r5 = SD_IO_WriteByte(SD_DUMMY_BYTE); break; default: break; } return retr; } /** * @brief Gets the SD card data response and check the busy flag. * @param None * @retval The SD status: Read data response xxx01 * - status 010: Data accepted * - status 101: Data rejected due to a crc error * - status 110: Data rejected due to a Write error. * - status 111: Data rejected due to other error. */ uint8_t SD_GetDataResponse(void) { uint8_t dataresponse; uint8_t rvalue = SD_DATA_OTHER_ERROR; dataresponse = SD_IO_WriteByte(SD_DUMMY_BYTE); SD_IO_WriteByte(SD_DUMMY_BYTE); /* read the busy response byte*/ /* Mask unused bits */ switch (dataresponse & 0x1F) { case SD_DATA_OK: rvalue = SD_DATA_OK; /* Set CS High */ SD_IO_CSState(1); /* Set CS Low */ SD_IO_CSState(0); /* Wait IO line return 0xFF */ while (SD_IO_WriteByte(SD_DUMMY_BYTE) != 0xFF); break; case SD_DATA_CRC_ERROR: rvalue = SD_DATA_CRC_ERROR; break; case SD_DATA_WRITE_ERROR: rvalue = SD_DATA_WRITE_ERROR; break; default: break; } /* Return response */ return rvalue; } /** * @brief Waits a data until a value different from SD_DUMMY_BITE * @param None * @retval the value read */ uint8_t SD_ReadData(void) { uint8_t timeout = 0x08; uint8_t readvalue; /* Check if response is got or a timeout is happen */ do { readvalue = SD_IO_WriteByte(SD_DUMMY_BYTE); timeout--; }while ((readvalue == SD_DUMMY_BYTE) && timeout); /* Right response got */ return readvalue; } /** * @brief Waits a data from the SD card * @param data : Expected data from the SD card * @retval BSP_SD_OK or BSP_SD_TIMEOUT */ uint8_t SD_WaitData(uint8_t data) { uint16_t timeout = 0xFFFF; uint8_t readvalue; /* Check if response is got or a timeout is happen */ do { readvalue = SD_IO_WriteByte(SD_DUMMY_BYTE); timeout--; }while ((readvalue != data) && timeout); if (timeout == 0) { /* After time out */ return BSP_SD_TIMEOUT; } /* Right response got */ return BSP_SD_OK; } /** * @brief Put the SD in Idle state. * @param None * @retval SD status */ uint8_t SD_GoIdleState(void) { SD_CmdAnswer_typedef response; __IO uint8_t counter = 0; /* Send CMD0 (SD_CMD_GO_IDLE_STATE) to put SD in SPI mode and wait for In Idle State Response (R1 Format) equal to 0x01 */ do{ counter++; response = SD_SendCmd(SD_CMD_GO_IDLE_STATE, 0, 0x95, SD_ANSWER_R1_EXPECTED); SD_IO_CSState(1); SD_IO_WriteByte(SD_DUMMY_BYTE); if(counter >= SD_MAX_TRY) { return BSP_SD_ERROR; } } while(response.r1 != SD_R1_IN_IDLE_STATE); /* Send CMD8 (SD_CMD_SEND_IF_COND) to check the power supply status and wait until response (R7 Format) equal to 0xAA and */ response = SD_SendCmd(SD_CMD_SEND_IF_COND, 0x1AA, 0x87, SD_ANSWER_R7_EXPECTED); SD_IO_CSState(1); SD_IO_WriteByte(SD_DUMMY_BYTE); if((response.r1 & SD_R1_ILLEGAL_COMMAND) == SD_R1_ILLEGAL_COMMAND) { /* Initialize card V1 */ do { /* Initialize card V1 */ /* Send CMD55 (SD_CMD_APP_CMD) before any ACMD command: R1 response (0x00: no errors) */ response = SD_SendCmd(SD_CMD_APP_CMD, 0x00000000, 0xFF, SD_ANSWER_R1_EXPECTED); SD_IO_CSState(1); SD_IO_WriteByte(SD_DUMMY_BYTE); /* Send ACMD41 (SD_CMD_SD_APP_OP_COND) to initialize SDHC or SDXC cards: R1 response (0x00: no errors) */ response = SD_SendCmd(SD_CMD_SD_APP_OP_COND, 0x00000000, 0xFF, SD_ANSWER_R1_EXPECTED); SD_IO_CSState(1); SD_IO_WriteByte(SD_DUMMY_BYTE); } while(response.r1 == SD_R1_IN_IDLE_STATE); flag_SDHC = 0; } else if(response.r1 == SD_R1_IN_IDLE_STATE) { /* Initialize card V2 */ do { /* Send CMD55 (SD_CMD_APP_CMD) before any ACMD command: R1 response (0x00: no errors) */ response = SD_SendCmd(SD_CMD_APP_CMD, 0, 0xFF, SD_ANSWER_R1_EXPECTED); SD_IO_CSState(1); SD_IO_WriteByte(SD_DUMMY_BYTE); /* Send ACMD41 (SD_CMD_SD_APP_OP_COND) to initialize SDHC or SDXC cards: R1 response (0x00: no errors) */ response = SD_SendCmd(SD_CMD_SD_APP_OP_COND, 0x40000000, 0xFF, SD_ANSWER_R1_EXPECTED); SD_IO_CSState(1); SD_IO_WriteByte(SD_DUMMY_BYTE); } while(response.r1 == SD_R1_IN_IDLE_STATE); if((response.r1 & SD_R1_ILLEGAL_COMMAND) == SD_R1_ILLEGAL_COMMAND) { do { /* Send CMD55 (SD_CMD_APP_CMD) before any ACMD command: R1 response (0x00: no errors) */ response = SD_SendCmd(SD_CMD_APP_CMD, 0, 0xFF, SD_ANSWER_R1_EXPECTED); SD_IO_CSState(1); SD_IO_WriteByte(SD_DUMMY_BYTE); if(response.r1 != SD_R1_IN_IDLE_STATE) { return BSP_SD_ERROR; } /* Send ACMD41 (SD_CMD_SD_APP_OP_COND) to initialize SDHC or SDXC cards: R1 response (0x00: no errors) */ response = SD_SendCmd(SD_CMD_SD_APP_OP_COND, 0x00000000, 0xFF, SD_ANSWER_R1_EXPECTED); SD_IO_CSState(1); SD_IO_WriteByte(SD_DUMMY_BYTE); } while(response.r1 == SD_R1_IN_IDLE_STATE); } /* Send CMD58 (SD_CMD_READ_OCR) to initialize SDHC or SDXC cards: R3 response (0x00: no errors) */ response = SD_SendCmd(SD_CMD_READ_OCR, 0x00000000, 0xFF, SD_ANSWER_R3_EXPECTED); SD_IO_CSState(1); SD_IO_WriteByte(SD_DUMMY_BYTE); if(response.r1 != SD_R1_NO_ERROR) { return BSP_SD_ERROR; } flag_SDHC = (response.r2 & 0x40) >> 6; } else { return BSP_SD_ERROR; } return BSP_SD_OK; } #endif /* SPI_SD_ENABLED */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ ================================================ FILE: sys/arch/stm32/dev/stm32_bsp.c ================================================ /* * Copyright (c) 2022 Christopher Hettrick * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include #include struct bsp_gpio { GPIO_TypeDef *port; uint32_t pin; uint32_t invert; }; static const struct bsp_gpio led[LED_COUNT] = { #ifdef LED1_GPIO_PORT { LED1_GPIO_PORT, LED1_PIN, LED1_INVERT }, #endif #ifdef LED2_GPIO_PORT { LED2_GPIO_PORT, LED2_PIN, LED2_INVERT }, #endif #ifdef LED3_GPIO_PORT { LED3_GPIO_PORT, LED3_PIN, LED3_INVERT }, #endif #ifdef LED4_GPIO_PORT { LED4_GPIO_PORT, LED4_PIN, LED4_INVERT }, #endif }; static const struct bsp_gpio button[BUTTON_COUNT] = { #ifdef BUTTON_USER_GPIO_PORT { BUTTON_USER_GPIO_PORT, BUTTON_USER_PIN, BUTTON_USER_INVERT }, #endif }; void BSP_LED_Init(Led_TypeDef Led) { GPIO_TypeDef *port = led[Led].port; uint32_t pin = led[Led].pin; uint32_t invert = led[Led].invert; LL_GPIO_EnableClock(port); LL_GPIO_SetPinMode(port, pin, LL_GPIO_MODE_OUTPUT); LL_GPIO_SetPinSpeed(port, pin, LL_GPIO_SPEED_FREQ_HIGH); LL_GPIO_SetPinOutputType(port, pin, LL_GPIO_OUTPUT_PUSHPULL); if (invert) { LL_GPIO_SetPinPull(port, pin, LL_GPIO_PULL_NO); } else { LL_GPIO_SetPinPull(port, pin, LL_GPIO_PULL_UP); } BSP_LED_Off(Led); } void BSP_LED_On(Led_TypeDef Led) { GPIO_TypeDef *port = led[Led].port; uint32_t pin = led[Led].pin; uint32_t invert = led[Led].invert; if (invert) { LL_GPIO_ResetOutputPin(port, pin); } else { LL_GPIO_SetOutputPin(port, pin); } } void BSP_LED_Off(Led_TypeDef Led) { GPIO_TypeDef *port = led[Led].port; uint32_t pin = led[Led].pin; uint32_t invert = led[Led].invert; if (invert) { LL_GPIO_SetOutputPin(port, pin); } else { LL_GPIO_ResetOutputPin(port, pin); } } void BSP_LED_Toggle(Led_TypeDef Led) { GPIO_TypeDef *port = led[Led].port; uint32_t pin = led[Led].pin; LL_GPIO_TogglePin(port, pin); } void BSP_PB_Init(Button_TypeDef Button) { GPIO_TypeDef *port = button[Button].port; uint32_t pin = button[Button].pin; uint32_t invert = button[Button].invert; LL_GPIO_EnableClock(port); LL_GPIO_SetPinMode(port, pin, LL_GPIO_MODE_INPUT); LL_GPIO_SetPinSpeed(port, pin, LL_GPIO_SPEED_FREQ_HIGH); if (invert) { LL_GPIO_SetPinPull(port, pin, LL_GPIO_PULL_NO); } else { LL_GPIO_SetPinPull(port, pin, LL_GPIO_PULL_DOWN); } } uint32_t BSP_PB_GetState(Button_TypeDef Button) { GPIO_TypeDef *port = button[Button].port; uint32_t pin = button[Button].pin; uint32_t invert = button[Button].invert; uint32_t level = LL_GPIO_ReadInputPort(port) & pin; if (invert) { return ((level == 0) ? 1 : 0); } else { return ((level == 0) ? 0 : 1); } } ================================================ FILE: sys/arch/stm32/dev/stm32_bsp.h ================================================ /* * Copyright (c) 2022 Christopher Hettrick * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #ifndef _MACHINE_STM32_BSP_H_ #define _MACHINE_STM32_BSP_H_ #ifdef KERNEL #include typedef enum { #ifdef LED1_GPIO_PORT LED1, #endif #ifdef LED2_GPIO_PORT LED2, #endif #ifdef LED3_GPIO_PORT LED3, #endif #ifdef LED4_GPIO_PORT LED4, #endif LED_COUNT } Led_TypeDef; typedef enum { #ifdef BUTTON_USER_GPIO_PORT BUTTON_USER, #endif BUTTON_COUNT } Button_TypeDef; void BSP_LED_Init(Led_TypeDef Led); void BSP_LED_On(Led_TypeDef Led); void BSP_LED_Off(Led_TypeDef Led); void BSP_LED_Toggle(Led_TypeDef Led); void BSP_PB_Init(Button_TypeDef Button); uint32_t BSP_PB_GetState(Button_TypeDef Button); #endif /* KERNEL */ #endif /* !_MACHINE_STM32_BSP_H_ */ ================================================ FILE: sys/arch/stm32/dev/stm32_bsp_sd.h ================================================ /* * Copyright (c) 2016, 2017 STMicroelectronics * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. Neither the name of STMicroelectronics nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef _MACHINE_STM32_BSP_SD_H_ #define _MACHINE_STM32_BSP_SD_H_ #include #define SD_DATATIMEOUT ((uint32_t)100000000) enum { BSP_SD_OK = 0x00, BSP_SD_ERROR = 0x01, BSP_SD_TIMEOUT }; enum { SD_TRANSFER_OK = 0x00, SD_TRANSFER_BUSY = 0x01 }; #ifdef SPI_SD_ENABLED /* Kernel Config 'options' definition. */ typedef struct { uint8_t Reserved1:2; /* Reserved */ uint16_t DeviceSize:12; /* Device Size */ uint8_t MaxRdCurrentVDDMin:3; /* Max. read current @ VDD min */ uint8_t MaxRdCurrentVDDMax:3; /* Max. read current @ VDD max */ uint8_t MaxWrCurrentVDDMin:3; /* Max. write current @ VDD min */ uint8_t MaxWrCurrentVDDMax:3; /* Max. write current @ VDD max */ uint8_t DeviceSizeMul:3; /* Device size multiplier */ } struct_v1; typedef struct { uint8_t Reserved1:6; /* Reserved */ uint32_t DeviceSize:22; /* Device Size */ uint8_t Reserved2:1; /* Reserved */ } struct_v2; typedef struct { /* Header part */ uint8_t CSDStruct:2; /* CSD structure */ uint8_t Reserved1:6; /* Reserved */ uint8_t TAAC:8; /* Data read access-time 1 */ uint8_t NSAC:8; /* Data read access-time 2 in CLK cycles */ uint8_t MaxBusClkFrec:8; /* Max. bus clock frequency */ uint16_t CardComdClasses:12; /* Card command classes */ uint8_t RdBlockLen:4; /* Max. read data block length */ uint8_t PartBlockRead:1; /* Partial blocks for read allowed */ uint8_t WrBlockMisalign:1; /* Write block misalignment */ uint8_t RdBlockMisalign:1; /* Read block misalignment */ uint8_t DSRImpl:1; /* DSR implemented */ /* v1 or v2 struct */ union csd_version { struct_v1 v1; struct_v2 v2; } version; uint8_t EraseSingleBlockEnable:1; /* Erase single block enable */ uint8_t EraseSectorSize:7; /* Erase group size multiplier */ uint8_t WrProtectGrSize:7; /* Write protect group size */ uint8_t WrProtectGrEnable:1; /* Write protect group enable */ uint8_t Reserved2:2; /* Reserved */ uint8_t WrSpeedFact:3; /* Write speed factor */ uint8_t MaxWrBlockLen:4; /* Max. write data block length */ uint8_t WriteBlockPartial:1; /* Partial blocks for write allowed */ uint8_t Reserved3:5; /* Reserved */ uint8_t FileFormatGroup:1; /* File format group */ uint8_t CopyFlag:1; /* Copy flag (OTP) */ uint8_t PermWrProtect:1; /* Permanent write protection */ uint8_t TempWrProtect:1; /* Temporary write protection */ uint8_t FileFormat:2; /* File Format */ uint8_t Reserved4:2; /* Reserved */ uint8_t crc:7; /* Reserved */ uint8_t Reserved5:1; /* always 1 */ } SD_CSD; typedef struct { __IO uint8_t ManufacturerID; /* ManufacturerID */ __IO uint16_t OEM_AppliID; /* OEM/Application ID */ __IO uint32_t ProdName1; /* Product Name part1 */ __IO uint8_t ProdName2; /* Product Name part2 */ __IO uint8_t ProdRev; /* Product Revision */ __IO uint32_t ProdSN; /* Product Serial Number */ __IO uint8_t Reserved1; /* Reserved1 */ __IO uint16_t ManufactDate; /* Manufacturing Date */ __IO uint8_t CID_CRC; /* CID CRC */ __IO uint8_t Reserved2; /* always 1 */ } SD_CID; typedef struct { SD_CSD Csd; SD_CID Cid; uint32_t CardCapacity; /*!< Card Capacity */ uint32_t CardBlockSize; /*!< Card Block Size */ uint32_t LogBlockNbr; /*!< Specifies the Card logical Capacity in blocks */ uint32_t LogBlockSize; /*!< Specifies logical block size in bytes */ } SD_CardInfo; #define BSP_SD_CardInfo SD_CardInfo /* Link external functions for SD Card peripheral */ extern void SD_IO_Init(void); extern void SD_IO_CSState(uint8_t state); extern void SD_IO_WriteReadData(const uint8_t *DataIn, uint8_t *DataOut, uint16_t DataLength); extern uint8_t SD_IO_WriteByte(uint8_t Data); /* Link function for HAL delay */ void HAL_Delay(__IO uint32_t Delay); #endif /* SPI_SD_ENABLED */ #ifdef SDIO_ENABLED /* Kernel Config 'controller' definition. */ #define BSP_SD_CardInfo HAL_SD_CardInfoTypeDef void BSP_SD_MspInit(SD_HandleTypeDef *hsd, void *Params); void BSP_SD_MspDeInit(SD_HandleTypeDef *hsd, void *Params); #endif /* SDIO_ENABLED */ uint8_t BSP_SD_Init(void); uint8_t BSP_SD_DeInit(void); uint8_t BSP_SD_ReadBlocks(uint32_t *pData, uint32_t ReadAddr, uint32_t NumOfBlocks, uint32_t Timeout); uint8_t BSP_SD_WriteBlocks(uint32_t *pData, uint32_t WriteAddr, uint32_t NumOfBlocks, uint32_t Timeout); uint8_t BSP_SD_Erase(uint32_t StartAddr, uint32_t EndAddr); uint8_t BSP_SD_GetCardState(void); uint8_t BSP_SD_GetCardInfo(BSP_SD_CardInfo *pCardInfo); #endif /* !_MACHINE_STM32_BSP_SD_H_ */ ================================================ FILE: sys/arch/stm32/dev/stm32_sdio_sd.c ================================================ /** ****************************************************************************** * @file stm32_sdio_sd.c * @author MCD Application Team * @version V2.0.0 * @date 27-January-2017 * @brief This file includes the SDIO driver for micro SD cards on boards. ****************************************************************************** * @attention * *

© COPYRIGHT(c) 2017 STMicroelectronics

* * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. Neither the name of STMicroelectronics nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ /* File Info : ----------------------------------------------------------------- User NOTES 1. How To use this driver: -------------------------- - This driver is used to drive the external micro SD card mounted on boards. - This driver does not need a specific component driver for the micro SD device to be included with. 2. Driver description: --------------------- + Initialization steps: o Initialize the micro SD card using the BSP_SD_Init() function. This function includes the MSP layer hardware resources initialization and the SDIO interface configuration to interface with the external micro SD. It also includes the micro SD initialization sequence. o Checking the SD card presence is not managed. o The function BSP_SD_GetCardInfo() is used to get the micro SD card information which is stored in the structure "BSP_SD_CardInfo". + Micro SD card operations o The micro SD card can be accessed with read/write block(s) operations once it is ready for access. The access can be performed whether using the polling mode by calling the functions BSP_SD_ReadBlocks()/BSP_SD_WriteBlocks(), or by DMA transfer using the functions BSP_SD_ReadBlocks_DMA()/BSP_SD_WriteBlocks_DMA() o The DMA transfer complete is used with interrupt mode. Once the SD transfer is complete, the SD interrupt is handled using the function BSP_SD_IRQHandler(), the DMA Tx/Rx transfer complete are handled using the functions BSP_SD_DMA_Tx_IRQHandler()/BSP_SD_DMA_Rx_IRQHandler(). The corresponding user callbacks are implemented by the user at application level. o The SD erase block(s) is performed using the function BSP_SD_Erase() with specifying the number of blocks to erase. o The SD runtime status is returned when calling the function BSP_SD_GetCardState(). ------------------------------------------------------------------------------*/ #ifdef SDIO_ENABLED /* Kernel Config 'controller' definition. */ /* Includes ------------------------------------------------------------------*/ #include #include #include SD_HandleTypeDef uSdHandle; /** * @brief Initializes the SD card device. * @retval SD status */ uint8_t BSP_SD_Init(void) { uint8_t sd_state = BSP_SD_OK; /* PLLSAI is dedicated to LCD periph. Do not use it to get 48MHz. */ /* uSD device interface configuration */ uSdHandle.Instance = SDIO; uSdHandle.Init.ClockEdge = SDIO_CLOCK_EDGE_RISING; uSdHandle.Init.ClockBypass = SDIO_CLOCK_BYPASS_DISABLE; uSdHandle.Init.ClockPowerSave = SDIO_CLOCK_POWER_SAVE_DISABLE; uSdHandle.Init.BusWide = SDIO_BUS_WIDE_1B; uSdHandle.Init.HardwareFlowControl = SDIO_HARDWARE_FLOW_CONTROL_ENABLE; #if defined(SDIO_XFER_CLK_DIV) /* Kernel Config 'options' definition. */ uSdHandle.Init.ClockDiv = SDIO_XFER_CLK_DIV; #else /* Default in stm32f4xx_ll_sdmmc.h */ uSdHandle.Init.ClockDiv = SDIO_TRANSFER_CLK_DIV; #endif /* Msp SD initialization */ BSP_SD_MspInit(&uSdHandle, NULL); /* HAL SD initialization */ if (HAL_SD_Init(&uSdHandle) != HAL_OK) { sd_state = BSP_SD_ERROR; } /* Configure SD Bus width */ if (sd_state == BSP_SD_OK) { /* Enable wide operation */ if (HAL_SD_ConfigWideBusOperation(&uSdHandle, SDIO_BUS_WIDE_4B) != HAL_OK) { sd_state = BSP_SD_ERROR; } else { sd_state = BSP_SD_OK; } } return sd_state; } /** * @brief DeInitializes the SD card device. * @retval SD status */ uint8_t BSP_SD_DeInit(void) { uint8_t sd_state = BSP_SD_OK; uSdHandle.Instance = SDIO; /* HAL SD deinitialization */ if (HAL_SD_DeInit(&uSdHandle) != HAL_OK) { sd_state = BSP_SD_ERROR; } /* Msp SD deinitialization */ uSdHandle.Instance = SDIO; BSP_SD_MspDeInit(&uSdHandle, NULL); return sd_state; } /** * @brief Reads block(s) from a specified address in an SD card, in polling mode. * @param pData: Pointer to the buffer that will contain the data to transmit * @param ReadAddr: Address from where data is to be read * @param NumOfBlocks: Number of SD blocks to read * @param Timeout: Timeout for read operation * @retval SD status */ uint8_t BSP_SD_ReadBlocks(uint32_t *pData, uint32_t ReadAddr, uint32_t NumOfBlocks, uint32_t Timeout) { if (HAL_SD_ReadBlocks(&uSdHandle, (uint8_t *)pData, ReadAddr, NumOfBlocks, Timeout) != HAL_OK) { return BSP_SD_ERROR; } else { return BSP_SD_OK; } } /** * @brief Writes block(s) to a specified address in an SD card, in polling mode. * @param pData: Pointer to the buffer that will contain the data to transmit * @param WriteAddr: Address from where data is to be written * @param NumOfBlocks: Number of SD blocks to write * @param Timeout: Timeout for write operation * @retval SD status */ uint8_t BSP_SD_WriteBlocks(uint32_t *pData, uint32_t WriteAddr, uint32_t NumOfBlocks, uint32_t Timeout) { if (HAL_SD_WriteBlocks(&uSdHandle, (uint8_t *)pData, WriteAddr, NumOfBlocks, Timeout) != HAL_OK) { return BSP_SD_ERROR; } else { return BSP_SD_OK; } } /** * @brief Erases the specified memory area of the given SD card. * @param StartAddr: Start byte address * @param EndAddr: End byte address * @retval SD status */ uint8_t BSP_SD_Erase(uint32_t StartAddr, uint32_t EndAddr) { if (HAL_SD_Erase(&uSdHandle, StartAddr, EndAddr) != HAL_OK) { return BSP_SD_ERROR; } else { return BSP_SD_OK; } } /** * @brief Gets the current SD card data status. * @retval Data transfer state. * This value can be one of the following values: * @arg SD_TRANSFER_OK: No data transfer is acting * @arg SD_TRANSFER_BUSY: Data transfer is acting */ uint8_t BSP_SD_GetCardState(void) { return((HAL_SD_GetCardState(&uSdHandle) == HAL_SD_CARD_TRANSFER ) ? SD_TRANSFER_OK : SD_TRANSFER_BUSY); } /** * @brief Get SD information about specific SD card. * @param pCardInfo: Pointer to BSP_SD_CardInfo structure * @retval SD status */ uint8_t BSP_SD_GetCardInfo(BSP_SD_CardInfo *pCardInfo) { uint8_t status; /* Get SD card Information */ status = HAL_SD_GetCardInfo(&uSdHandle, pCardInfo); return status; } struct gpio_pin { GPIO_TypeDef *port; char port_name; uint32_t pin; uint32_t mode; uint32_t speed; uint32_t pull; uint32_t af; uint32_t out_type; }; struct sdio_inst { #define NUM_PINS 6 struct gpio_pin pins[NUM_PINS]; int prio; int irq; }; static const struct sdio_inst sdio = { #define PIN2 LL_GPIO_PIN_2 #define PIN6 LL_GPIO_PIN_6 #define PIN8 LL_GPIO_PIN_8 #define PIN9 LL_GPIO_PIN_9 #define PIN10 LL_GPIO_PIN_10 #define PIN11 LL_GPIO_PIN_11 #define PIN12 LL_GPIO_PIN_12 #define AF12 LL_GPIO_AF_12 #define ALT LL_GPIO_MODE_ALTERNATE #define VH LL_GPIO_SPEED_FREQ_VERY_HIGH #define PUP LL_GPIO_PULL_UP #define OPP LL_GPIO_OUTPUT_PUSHPULL { { GPIOC, 'C', PIN8, ALT, VH, PUP, AF12, OPP }, /* D0 */ { GPIOC, 'C', PIN9, ALT, VH, PUP, AF12, OPP }, /* D1 */ { GPIOC, 'C', PIN10, ALT, VH, PUP, AF12, OPP }, /* D2 */ { GPIOC, 'C', PIN11, ALT, VH, PUP, AF12, OPP }, /* D3 */ { GPIOC, 'C', PIN12, ALT, VH, PUP, AF12, OPP }, /* CLK */ #ifdef STM32F413xx { GPIOA, 'A', PIN6, ALT, VH, PUP, AF12, OPP }, /* CMD */ #else { GPIOD, 'D', PIN2, ALT, VH, PUP, AF12, OPP }, /* CMD */ #endif }, IPL_BIO, SDIO_IRQn }; /** * @brief Initializes the SD MSP. * @param hsd: SD handle * @param Params : pointer on additional configuration parameters, can be NULL. */ __weak void BSP_SD_MspInit(SD_HandleTypeDef *hsd, void *Params) { int i; int num_pins = sizeof(sdio.pins) / sizeof(sdio.pins[0]); /* Enable SDIO clock. */ LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_SDIO); /* Enable GPIO clocks and configure GPIO pins. */ for (i = 0; i < num_pins; ++i) { GPIO_TypeDef *port = sdio.pins[i].port; uint32_t pin = sdio.pins[i].pin; LL_GPIO_EnableClock(port); LL_GPIO_SetPinMode(port, pin, sdio.pins[i].mode); LL_GPIO_SetPinSpeed(port, pin, sdio.pins[i].speed); LL_GPIO_SetPinPull(port, pin, sdio.pins[i].pull); LL_GPIO_SetAFPin(port, pin, sdio.pins[i].af); LL_GPIO_SetPinOutputType(port, pin, sdio.pins[i].out_type); } /* NVIC configuration for SDIO interrupts. */ arm_intr_set_priority(sdio.irq, sdio.prio); arm_intr_enable_irq(sdio.irq); } /** * @brief DeInitializes the SD MSP. * @param hsd: SD handle * @param Params : pointer on additional configuration parameters, can be NULL. */ __weak void BSP_SD_MspDeInit(SD_HandleTypeDef *hsd, void *Params) { /* Disable NVIC for SDIO interrupts. */ arm_intr_disable_irq(sdio.irq); /* Disable SDIO clock. */ LL_APB2_GRP1_DisableClock(LL_APB2_GRP1_PERIPH_SDIO); } #endif /* SDIO_ENABLED */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ ================================================ FILE: sys/arch/stm32/dev/stm32f4xx_nucleo_sd.c ================================================ /** ****************************************************************************** * @file stm32f4xx_nucleo_sd.c * @author MCD Application Team * @version V1.2.6 * @date 27-January-2017 * @brief This file provides set of firmware functions to manage: * - MicroSD available on Adafruit MicroSD Breakout Board+ (ID 254) ****************************************************************************** * @attention * *

© COPYRIGHT(c) 2017 STMicroelectronics

* * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. Neither the name of STMicroelectronics nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ /* Includes ------------------------------------------------------------------*/ #include /** * @brief BUS variables */ #ifdef HAL_SPI_MODULE_ENABLED uint32_t SpixTimeout = NUCLEO_SPIx_TIMEOUT_MAX; /*
© COPYRIGHT(c) 2017 STMicroelectronics
* * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. Neither the name of STMicroelectronics nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ #ifndef __STM32F4XX_NUCLEO_SD_H #define __STM32F4XX_NUCLEO_SD_H #include #include #include #ifdef HAL_SPI_MODULE_ENABLED /* Maximum Timeout values for flags waiting loops. These timeouts are not based on accurate values, they just guarantee that the application will not remain stuck if the SPI communication is corrupted. You may modify these timeout values depending on CPU frequency and application conditions (interrupts routines ...). */ #define NUCLEO_SPIx_TIMEOUT_MAX 1000 /* To be defined only if provided with the Adafruit MicroSD Breakout Board+ */ /* https://www.adafruit.com/product/254 */ #ifdef SPI_SD_ENABLED /* Kernel Config 'options' definition. */ /* SD IO functions */ void SD_IO_Init(void); void SD_IO_CSState(uint8_t state); void SD_IO_WriteReadData(const uint8_t *DataIn, uint8_t *DataOut, uint16_t DataLength); uint8_t SD_IO_WriteByte(uint8_t Data); #endif /* SPI_SD_ENABLED */ #ifdef F4DISCOVERY /* Kernel Config 'board' definition. */ /* SPI2: CS PB12, SCK PB13, MISO PB14, MOSI PB15 */ #define NUCLEO_SPIx SPI2 #define NUCLEO_SPIx_CLK_ENABLE() LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_SPI2) #define NUCLEO_SPIx_SCK_AF ((uint32_t)LL_GPIO_AF_5) #define NUCLEO_SPIx_SCK_PIN ((uint32_t)LL_GPIO_PIN_13) #define NUCLEO_SPIx_SCK_GPIO_PORT ((GPIO_TypeDef *)GPIOB) #define NUCLEO_SPIx_MISO_MOSI_AF ((uint32_t)LL_GPIO_AF_5) #define NUCLEO_SPIx_MISO_PIN ((uint32_t)LL_GPIO_PIN_14) #define NUCLEO_SPIx_MOSI_PIN ((uint32_t)LL_GPIO_PIN_15) #define NUCLEO_SPIx_MISO_MOSI_GPIO_PORT ((GPIO_TypeDef *)GPIOB) #define SD_CS_PIN ((uint32_t)LL_GPIO_PIN_12) #define SD_CS_GPIO_PORT ((GPIO_TypeDef *)GPIOB) #define SD_CS_LOW() LL_GPIO_ResetOutputPin(SD_CS_GPIO_PORT, SD_CS_PIN) #define SD_CS_HIGH() LL_GPIO_SetOutputPin(SD_CS_GPIO_PORT, SD_CS_PIN) #endif /* F4DISCOVERY */ #if defined(F411RENUCLEO) || defined(F446RENUCLEO) /* Kernel Config 'board' definition. */ #define NUCLEO_SPIx SPI1 #define NUCLEO_SPIx_CLK_ENABLE() LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_SPI1) #define NUCLEO_SPIx_SCK_AF ((uint32_t)LL_GPIO_AF_5) #define NUCLEO_SPIx_SCK_PIN ((uint32_t)LL_GPIO_PIN_5) #define NUCLEO_SPIx_SCK_GPIO_PORT ((GPIO_TypeDef *)GPIOA) #define NUCLEO_SPIx_MISO_MOSI_AF ((uint32_t)LL_GPIO_AF_5) #define NUCLEO_SPIx_MISO_PIN ((uint32_t)LL_GPIO_PIN_6) #define NUCLEO_SPIx_MOSI_PIN ((uint32_t)LL_GPIO_PIN_7) #define NUCLEO_SPIx_MISO_MOSI_GPIO_PORT ((GPIO_TypeDef *)GPIOA) #define SD_CS_PIN ((uint32_t)LL_GPIO_PIN_6) #define SD_CS_GPIO_PORT ((GPIO_TypeDef *)GPIOB) #define SD_CS_LOW() LL_GPIO_ResetOutputPin(SD_CS_GPIO_PORT, SD_CS_PIN) #define SD_CS_HIGH() LL_GPIO_SetOutputPin(SD_CS_GPIO_PORT, SD_CS_PIN) #endif /* F411RENUCLEO || F446RENUCLEO */ #ifdef F469IDISCO /* Kernel Config 'board' definition. */ #define NUCLEO_SPIx SPI2 #define NUCLEO_SPIx_CLK_ENABLE() LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_SPI2) #define NUCLEO_SPIx_SCK_AF ((uint32_t)LL_GPIO_AF_5) #define NUCLEO_SPIx_SCK_PIN ((uint32_t)LL_GPIO_PIN_3) #define NUCLEO_SPIx_SCK_GPIO_PORT ((GPIO_TypeDef *)GPIOD) #define NUCLEO_SPIx_MISO_MOSI_AF ((uint32_t)LL_GPIO_AF_5) #define NUCLEO_SPIx_MISO_PIN ((uint32_t)LL_GPIO_PIN_14) #define NUCLEO_SPIx_MOSI_PIN ((uint32_t)LL_GPIO_PIN_15) #define NUCLEO_SPIx_MISO_MOSI_GPIO_PORT ((GPIO_TypeDef *)GPIOB) #define SD_CS_PIN ((uint32_t)LL_GPIO_PIN_6) #define SD_CS_GPIO_PORT ((GPIO_TypeDef *)GPIOH) #define SD_CS_LOW() LL_GPIO_ResetOutputPin(SD_CS_GPIO_PORT, SD_CS_PIN) #define SD_CS_HIGH() LL_GPIO_SetOutputPin(SD_CS_GPIO_PORT, SD_CS_PIN) #endif /* F469IDISCO */ #endif /* HAL_SPI_MODULE_ENABLED */ #endif /* __STM32F4XX_NUCLEO_SD_H */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ ================================================ FILE: sys/arch/stm32/dev/uart.c ================================================ /* * UART driver for STM32. * * Copyright (c) 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * * @(#)cons.c 1.3 (2.11BSD GTE) 1997/4/25 */ #include #include #include #include #include #include #include #include #include #include #include #define CONCAT(x,y) x ## y #define BBAUD(x) CONCAT(B,x) #ifndef UART_BAUD #define UART_BAUD 115200 #endif /* * STM32 USART/UART port. */ struct uart_port { GPIO_TypeDef *port; char port_name; u_long pin; }; /* * STM32 USART/UART instance. */ struct uart_inst { USART_TypeDef *inst; struct uart_port tx; struct uart_port rx; u_int apb_div; u_int af; }; /* * STM32 USART/UART. */ static const struct uart_inst uart[NUART] = { #define PIN0 LL_GPIO_PIN_0 #define PIN2 LL_GPIO_PIN_2 #define PIN3 LL_GPIO_PIN_3 #define PIN6 LL_GPIO_PIN_6 #define PIN7 LL_GPIO_PIN_7 #define PIN9 LL_GPIO_PIN_9 #define PIN10 LL_GPIO_PIN_10 #define PIN11 LL_GPIO_PIN_11 #define PIN14 LL_GPIO_PIN_14 #define AF7 LL_GPIO_AF_7 #define AF8 LL_GPIO_AF_8 #ifdef STM32F405xx { USART1, { GPIOA, 'A', PIN9 }, { GPIOA, 'A', PIN10 }, 2, AF7 }, { USART2, { GPIOA, 'A', PIN2 }, { GPIOA, 'A', PIN3 }, 4, AF7 }, { /* USART3 */ }, { /* UART4 */ }, { /* UART5 */ }, { /* USART6 */ }, #endif #ifdef STM32F407xx { USART1, { GPIOA, 'A', PIN9 }, { GPIOA, 'A', PIN10 }, 2, AF7 }, { USART2, { GPIOA, 'A', PIN2 }, { GPIOA, 'A', PIN3 }, 4, AF7 }, { /* USART3 */ }, { /* UART4 */ }, { /* UART5 */ }, { /* USART6 */ }, #endif #ifdef STM32F411xE { /* USART1 */ }, { USART2, { GPIOA, 'A', PIN2 }, { GPIOA, 'A', PIN3 }, 2, AF7 }, { /* none */ }, { /* none */ }, { /* none */ }, { /* USART6 */ }, #endif #ifdef STM32F412Rx { USART1, { GPIOA, 'A', PIN9 }, { GPIOA, 'A', PIN10 }, 2, AF7 }, { /* USART2 */ }, { /* USART3 */ }, { /* none */ }, { /* none */ }, { /* USART6 */ }, #endif #ifdef STM32F412Zx { /* USART1 */ }, { USART2, { GPIOA, 'A', PIN2 }, { GPIOA, 'A', PIN3 }, 2, AF7 }, { /* USART3 */ }, { /* none */ }, { /* none */ }, { USART6, { GPIOG, 'G', PIN14 }, { GPIOG, 'G', PIN9 }, 1, AF8 }, #endif #ifdef STM32F413xx { /* USART1 */ }, { /* USART2 */ }, { /* USART3 */ }, { /* UART4 */ }, { /* UART5 */ }, { USART6, { GPIOG, 'G', PIN14 }, { GPIOG, 'G', PIN9 }, 1, AF8 }, #endif #ifdef STM32F446xx { USART1, { GPIOA, 'A', PIN9 }, { GPIOA, 'A', PIN10 }, 2, AF7 }, { USART2, { GPIOA, 'A', PIN2 }, { GPIOA, 'A', PIN3 }, 2, AF7 }, { /* USART3 */ }, { /* UART4 */ }, { /* UART5 */ }, { /* USART6 */ }, #endif #ifdef STM32F469xx { /* USART1 */ }, { /* USART2 */ }, { USART3, { GPIOB, 'B', PIN10 }, { GPIOB, 'B', PIN11 }, 2, AF7 }, { /* UART4 */ }, { /* UART5 */ }, { USART6, { GPIOC, 'C', PIN6 }, { GPIOC, 'C', PIN7 }, 2, AF8 }, #endif }; struct tty uartttys[NUART]; #if 0 // XXX UART static unsigned speed_bps [NSPEEDS] = { 0, 50, 75, 150, 200, 300, 600, 1200, 1800, 2400, 4800, 9600, 19200, 38400, 57600, 115200, 230400, 460800, 500000, 576000, 921600, 1000000, 1152000, 1500000, 2000000, 2500000, 3000000, 3500000, 4000000 }; #endif // XXX UART void cnstart(struct tty *tp); void USART1_IRQHandler(void) { uartintr(makedev(UART_MAJOR, 0)); /* USART1 */ } void USART2_IRQHandler(void) { uartintr(makedev(UART_MAJOR, 1)); /* USART2 */ } void USART3_IRQHandler(void) { uartintr(makedev(UART_MAJOR, 2)); /* USART3 */ } void UART4_IRQHandler(void) { uartintr(makedev(UART_MAJOR, 3)); /* UART4 */ } void UART5_IRQHandler(void) { uartintr(makedev(UART_MAJOR, 4)); /* UART5 */ } void USART6_IRQHandler(void) { uartintr(makedev(UART_MAJOR, 5)); /* USART6 */ } /* * Setup USART/UART. */ void uartinit(int unit) { register USART_TypeDef *inst; register GPIO_TypeDef *tx_port; register u_int tx_pin; register GPIO_TypeDef *rx_port; register u_int rx_pin; register u_int apb_div; register u_int af; if (unit < 0 || unit >= NUART) return; inst = uart[unit].inst; tx_port = uart[unit].tx.port; tx_pin = uart[unit].tx.pin; rx_port = uart[unit].rx.port; rx_pin = uart[unit].rx.pin; apb_div = uart[unit].apb_div; af = uart[unit].af; /* * Configure and enable USART/UART NVIC interrupts. * Enable GPIO port peripheral clock and USART/UART peripheral clock. */ switch (unit) { case 0: /* USART1 */ #ifdef USART1 arm_intr_set_priority(USART1_IRQn, IPL_TTY); arm_intr_enable_irq(USART1_IRQn); #ifdef STM32F405xx /* USART1: APB2 84 MHz AF7: TX on PA.09, RX on PA.10 */ LL_GPIO_EnableClock(GPIOA); LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_USART1); #endif #ifdef STM32F407xx /* USART1: APB2 84 MHz AF7: TX on PA.09, RX on PA.10 */ LL_GPIO_EnableClock(GPIOA); LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_USART1); #endif #ifdef STM32F412Rx /* USART1: APB2 100 MHz AF7: TX on PA.09, RX on PA.10 */ LL_GPIO_EnableClock(GPIOA); LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_USART1); #endif #ifdef STM32F446xx /* USART1: APB2 90 MHz AF7: TX on PA.09, RX on PA.10 */ LL_GPIO_EnableClock(GPIOA); LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_USART1); #endif #endif /* USART1 */ break; case 1: /* USART2 */ #ifdef USART2 arm_intr_set_priority(USART2_IRQn, IPL_TTY); arm_intr_enable_irq(USART2_IRQn); #ifdef STM32F405xx /* USART2: APB1 42 MHz AF7: TX on PA.02, RX on PA.03 */ LL_GPIO_EnableClock(GPIOA); LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_USART2); #endif #ifdef STM32F407xx /* USART2: APB1 42 MHz AF7: TX on PA.02, RX on PA.03 */ LL_GPIO_EnableClock(GPIOA); LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_USART2); #endif #ifdef STM32F411xE /* USART2: APB1 50 MHz AF7: TX on PA.02, RX on PA.03 */ LL_GPIO_EnableClock(GPIOA); LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_USART2); #endif #ifdef STM32F412Zx /* USART2: APB1 50 MHz AF7: TX on PA.02, RX on PA.03 */ LL_GPIO_EnableClock(GPIOA); LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_USART2); #endif #ifdef STM32F446xx /* USART2: APB1 45 MHz AF7: TX on PA.02, RX on PA.03 */ LL_GPIO_EnableClock(GPIOA); LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_USART2); #endif #endif /* USART2 */ break; case 2: /* USART3 */ #ifdef USART3 arm_intr_set_priority(USART3_IRQn, IPL_TTY); arm_intr_enable_irq(USART3_IRQn); #ifdef STM32F469xx /* USART3: AHB1/APB1, 45 MHz, AF7, TX on PB.10, RX on PB.11 */ LL_GPIO_EnableClock(GPIOB); LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_USART3); #endif #endif /* USART3 */ break; case 3: /* UART4 */ #ifdef UART4 arm_intr_set_priority(UART4_IRQn, IPL_TTY); arm_intr_enable_irq(UART4_IRQn); #endif /* UART4 */ break; case 4: /* UART5 */ #ifdef UART5 arm_intr_set_priority(UART5_IRQn, IPL_TTY); arm_intr_enable_irq(UART5_IRQn); #endif /* UART5 */ break; case 5: /* USART6 */ #ifdef USART6 arm_intr_set_priority(USART6_IRQn, IPL_TTY); arm_intr_enable_irq(USART6_IRQn); #ifdef STM32F412Zx /* USART6: AHB1/APB2, 100 MHz AF8: TX on PG.14, RX on PG.09 */ LL_GPIO_EnableClock(GPIOG); LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_USART6); #endif #ifdef STM32F413xx /* USART6: AHB1/APB2, 100 MHz, AF8, TX on PG.14, RX on PG.09 */ LL_GPIO_EnableClock(GPIOG); LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_USART6); #endif #ifdef STM32F469xx /* USART6: AHB1/APB2, 90 MHz, AF8, TX on PC.06, RX on PC.07 */ /* USART6: CN12 Ext: 3V3 Pin 1, GND Pin 2, TX Pin 6, RX Pin 8 */ LL_GPIO_EnableClock(GPIOC); LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_USART6); #endif #endif /* USART6 */ break; default: break; } /* Config Tx Pin as: Alt func, High Speed, Push pull, Pull up */ LL_GPIO_SetPinMode(tx_port, tx_pin, LL_GPIO_MODE_ALTERNATE); LL_GPIO_SetAFPin(tx_port, tx_pin, af); LL_GPIO_SetPinSpeed(tx_port, tx_pin, LL_GPIO_SPEED_FREQ_HIGH); LL_GPIO_SetPinOutputType(tx_port, tx_pin, LL_GPIO_OUTPUT_PUSHPULL); LL_GPIO_SetPinPull(tx_port, tx_pin, LL_GPIO_PULL_UP); /* Config Rx Pin as: Alt func, High Speed, Push pull, Pull up */ LL_GPIO_SetPinMode(rx_port, rx_pin, LL_GPIO_MODE_ALTERNATE); LL_GPIO_SetAFPin(rx_port, rx_pin, af); LL_GPIO_SetPinSpeed(rx_port, rx_pin, LL_GPIO_SPEED_FREQ_HIGH); LL_GPIO_SetPinOutputType(rx_port, rx_pin, LL_GPIO_OUTPUT_PUSHPULL); LL_GPIO_SetPinPull(rx_port, rx_pin, LL_GPIO_PULL_UP); /* Transmit/Receive, 8 data bit, 1 start bit, 1 stop bit, no parity. */ LL_USART_Disable(inst); LL_USART_SetTransferDirection(inst, LL_USART_DIRECTION_TX_RX); LL_USART_ConfigCharacter(inst, LL_USART_DATAWIDTH_8B, LL_USART_PARITY_NONE, LL_USART_STOPBITS_1); LL_USART_SetBaudRate(inst, SystemCoreClock/apb_div, LL_USART_OVERSAMPLING_16, UART_BAUD); LL_USART_Enable(inst); } int uartopen(dev_t dev, int flag, int mode) { register struct uart_inst *uip; register struct tty *tp; register int unit = minor(dev); if (unit < 0 || unit >= NUART) return (ENXIO); tp = &uartttys[unit]; if (! tp->t_addr) return (ENXIO); uip = (struct uart_inst *)tp->t_addr; tp->t_oproc = uartstart; if ((tp->t_state & TS_ISOPEN) == 0) { if (tp->t_ispeed == 0) { tp->t_ispeed = BBAUD(UART_BAUD); tp->t_ospeed = BBAUD(UART_BAUD); } ttychars(tp); tp->t_state = TS_ISOPEN | TS_CARR_ON; tp->t_flags = ECHO | XTABS | CRMOD | CRTBS | CRTERA | CTLECH | CRTKIL; } if ((tp->t_state & TS_XCLUDE) && u.u_uid != 0) return (EBUSY); // XXX Clear USART state, then set up new state. LL_USART_Enable(uip->inst); LL_USART_EnableDirectionRx(uip->inst); LL_USART_EnableDirectionTx(uip->inst); #if 0 // XXX reg->sta = 0; reg->brg = PIC32_BRG_BAUD (BUS_KHZ * 1000, speed_bps [tp->t_ospeed]); reg->mode = PIC32_UMODE_PDSEL_8NPAR | PIC32_UMODE_ON; reg->staset = PIC32_USTA_URXEN | PIC32_USTA_UTXEN; #endif // XXX /* Enable receive interrupt. */ LL_USART_EnableIT_RXNE(uip->inst); return ttyopen(dev, tp); } /*ARGSUSED*/ int uartclose(dev_t dev, int flag, int mode) { register int unit = minor(dev); register struct tty *tp = &uartttys[unit]; if (! tp->t_addr) return ENODEV; ttywflush(tp); ttyclose(tp); return(0); } /*ARGSUSED*/ int uartread(dev_t dev, struct uio *uio, int flag) { register int unit = minor(dev); register struct tty *tp = &uartttys[unit]; if (! tp->t_addr) return ENODEV; return ttread(tp, uio, flag); } /*ARGSUSED*/ int uartwrite(dev_t dev, struct uio *uio, int flag) { register int unit = minor(dev); register struct tty *tp = &uartttys[unit]; if (! tp->t_addr) return ENODEV; return ttwrite(tp, uio, flag); } int uartselect(dev_t dev, int rw) { register int unit = minor(dev); register struct tty *tp = &uartttys[unit]; if (! tp->t_addr) return ENODEV; return (ttyselect (tp, rw)); } /*ARGSUSED*/ int uartioctl(dev_t dev, u_int cmd, caddr_t addr, int flag) { register int unit = minor(dev); register struct tty *tp = &uartttys[unit]; register int error; if (! tp->t_addr) return ENODEV; error = ttioctl(tp, cmd, addr, flag); if (error < 0) error = ENOTTY; return (error); } void uartintr(dev_t dev) { register int c; register int unit = minor(dev); register struct tty *tp = &uartttys[unit]; register struct uart_inst *uip; if (! tp->t_addr) return; uip = (struct uart_inst *)tp->t_addr; /* Receive */ while (LL_USART_IsActiveFlag_RXNE(uip->inst)) { c = LL_USART_ReceiveData8(uip->inst); ttyinput(c, tp); } #if 0 // XXX /* XXX Receive Buffer Overrun */ if (reg->sta & PIC32_USTA_OERR) reg->staclr = PIC32_USTA_OERR; #endif // XXX /* RXNE flag was cleared by reading DR register */ /* Transmit */ if (LL_USART_IsActiveFlag_TXE(uip->inst)) { led_control(LED_TTY, 0); /* Disable transmit interrupt. */ LL_USART_DisableIT_TXE(uip->inst); if (tp->t_state & TS_BUSY) { tp->t_state &= ~TS_BUSY; ttstart(tp); } } } /* * Start (restart) transmission on the given line. */ void uartstart(struct tty *tp) { register struct uart_inst *uip; register int c, s; if (! tp->t_addr) return; uip = (struct uart_inst *)tp->t_addr; /* * Must hold interrupts in following code to prevent * state of the tp from changing. */ s = spltty(); /* * If it is currently active, or delaying, no need to do anything. */ if (tp->t_state & (TS_TIMEOUT | TS_BUSY | TS_TTSTOP)) { out: led_control(LED_TTY, 0); splx(s); return; } /* * Wake up any sleepers. */ ttyowake(tp); /* * Now restart transmission unless the output queue is empty. */ if (tp->t_outq.c_cc == 0) goto out; if (LL_USART_IsActiveFlag_TXE(uip->inst)) { c = getc(&tp->t_outq); LL_USART_TransmitData8(uip->inst, c & 0xff); tp->t_state |= TS_BUSY; } /* Enable transmit interrupt. */ LL_USART_EnableIT_TXE(uip->inst); led_control(LED_TTY, 1); splx(s); } void uartputc(dev_t dev, char c) { int unit = minor(dev); struct tty *tp = &uartttys[unit]; register const struct uart_inst *uip = &uart[unit]; register int s, timo; s = spltty(); again: /* * Try waiting for the console tty to come ready, * otherwise give up after a reasonable time. */ timo = 30000; while (!LL_USART_IsActiveFlag_TXE(uip->inst)) if (--timo == 0) break; if (tp->t_state & TS_BUSY) { uartintr(dev); goto again; } led_control(LED_TTY, 1); LL_USART_ClearFlag_TC(uip->inst); LL_USART_TransmitData8(uip->inst, c); timo = 30000; while (!LL_USART_IsActiveFlag_TC(uip->inst)) if (--timo == 0) break; led_control(LED_TTY, 0); splx(s); } char uartgetc(dev_t dev) { int unit = minor(dev); register const struct uart_inst *uip = &uart[unit]; int s, c; s = spltty(); for (;;) { /* Wait for key pressed. */ if (LL_USART_IsActiveFlag_RXNE(uip->inst)) { c = LL_USART_ReceiveData8(uip->inst); break; } } /* RXNE flag was cleared by reading DR register */ splx(s); return (unsigned char) c; } /* * Test to see if device is present. * Return true if found and initialized ok. */ static int uartprobe(struct conf_device *config) { int unit = config->dev_unit - 1; int is_console = (CONS_MAJOR == UART_MAJOR && CONS_MINOR == unit); if (unit < 0 || unit >= NUART) return 0; printf("uart%d: pins tx=P%c%d/rx=P%c%d, af=%d", unit+1, uart[unit].tx.port_name, ffs(uart[unit].tx.pin)-1, uart[unit].rx.port_name, ffs(uart[unit].rx.pin)-1, uart[unit].af); if (is_console) printf(", console"); printf("\n"); /* Initialize the device. */ uartttys[unit].t_addr = (caddr_t) &uart[unit]; if (! is_console) uartinit(unit); return 1; } struct driver uartdriver = { "uart", uartprobe, }; ================================================ FILE: sys/arch/stm32/dev/uart.h ================================================ #ifndef _UART_H #define _UART_H #define NUART 6 #ifdef KERNEL void uartinit(int unit); int uartopen(dev_t dev, int flag, int mode); int uartclose(dev_t dev, int flag, int mode); int uartread(dev_t dev, struct uio *uio, int flag); int uartwrite(dev_t dev, struct uio *uio, int flag); int uartselect(dev_t dev, int rw); int uartioctl(dev_t dev, u_int cmd, caddr_t addr, int flag); void uartintr(dev_t dev); void uartstart(struct tty *tp); void uartputc(dev_t dev, char c); char uartgetc(dev_t dev); extern struct tty uartttys[NUART]; #endif /* KERNEL */ #endif /* !_UART_H */ ================================================ FILE: sys/arch/stm32/hal/stm32_assert.h ================================================ /** ****************************************************************************** * @file stm32_assert.h * @author MCD Application Team * @version V1.0.0 * @date 17-February-2017 * @brief STM32 assert template file. * This file should be copied to the application folder and renamed * to stm32_assert.h. ****************************************************************************** * @attention * *

© COPYRIGHT(c) 2017 STMicroelectronics

* * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. Neither the name of STMicroelectronics nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __STM32_ASSERT_H #define __STM32_ASSERT_H #ifdef __cplusplus extern "C" { #endif /* Exported types ------------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/ /* Includes ------------------------------------------------------------------*/ /* Exported macro ------------------------------------------------------------*/ #ifdef USE_FULL_ASSERT /** * @brief The assert_param macro is used for function's parameters check. * @param expr: If expr is false, it calls assert_failed function * which reports the name of the source file and the source * line number of the call that failed. * If expr is true, it returns no value. * @retval None */ #define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__)) /* Exported functions ------------------------------------------------------- */ void assert_failed(uint8_t* file, uint32_t line); #else #define assert_param(expr) ((void)0U) #endif /* USE_FULL_ASSERT */ #ifdef __cplusplus } #endif #endif /* __STM32_ASSERT_H */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ ================================================ FILE: sys/arch/stm32/hal/stm32f405xx.h ================================================ /** ****************************************************************************** * @file stm32f405xx.h * @author MCD Application Team * @version V2.6.4 * @date 06-December-2019 * @brief CMSIS STM32F405xx Device Peripheral Access Layer Header File. * * This file contains: * - Data structures and the address mapping for all peripherals * - peripherals registers declarations and bits definition * - Macros to access peripheral's registers hardware * ****************************************************************************** * @attention * *

© COPYRIGHT(c) 2017 STMicroelectronics

* * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. Neither the name of STMicroelectronics nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ /** @addtogroup CMSIS_Device * @{ */ /** @addtogroup stm32f405xx * @{ */ #ifndef __STM32F405xx_H #define __STM32F405xx_H #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ /** @addtogroup Configuration_section_for_CMSIS * @{ */ /** * @brief Configuration of the Cortex-M4 Processor and Core Peripherals */ #define __CM4_REV 0x0001U /*!< Core revision r0p1 */ #define __MPU_PRESENT 1U /*!< STM32F4XX provides an MPU */ #define __NVIC_PRIO_BITS 4U /*!< STM32F4XX uses 4 Bits for the Priority Levels */ #define __Vendor_SysTickConfig 0U /*!< Set to 1 if different SysTick Config is used */ #define __FPU_PRESENT 1U /*!< FPU present */ /** * @} */ /** @addtogroup Peripheral_interrupt_number_definition * @{ */ /** * @brief STM32F4XX Interrupt Number Definition, according to the selected device * in @ref Library_configuration_section */ typedef enum { /****** Cortex-M4 Processor Exceptions Numbers ****************************************************************/ NonMaskableInt_IRQn = -14, /*!< 2 Non Maskable Interrupt */ MemoryManagement_IRQn = -12, /*!< 4 Cortex-M4 Memory Management Interrupt */ BusFault_IRQn = -11, /*!< 5 Cortex-M4 Bus Fault Interrupt */ UsageFault_IRQn = -10, /*!< 6 Cortex-M4 Usage Fault Interrupt */ SVCall_IRQn = -5, /*!< 11 Cortex-M4 SV Call Interrupt */ DebugMonitor_IRQn = -4, /*!< 12 Cortex-M4 Debug Monitor Interrupt */ PendSV_IRQn = -2, /*!< 14 Cortex-M4 Pend SV Interrupt */ SysTick_IRQn = -1, /*!< 15 Cortex-M4 System Tick Interrupt */ /****** STM32 specific Interrupt Numbers **********************************************************************/ WWDG_IRQn = 0, /*!< Window WatchDog Interrupt */ PVD_IRQn = 1, /*!< PVD through EXTI Line detection Interrupt */ TAMP_STAMP_IRQn = 2, /*!< Tamper and TimeStamp interrupts through the EXTI line */ RTC_WKUP_IRQn = 3, /*!< RTC Wakeup interrupt through the EXTI line */ FLASH_IRQn = 4, /*!< FLASH global Interrupt */ RCC_IRQn = 5, /*!< RCC global Interrupt */ EXTI0_IRQn = 6, /*!< EXTI Line0 Interrupt */ EXTI1_IRQn = 7, /*!< EXTI Line1 Interrupt */ EXTI2_IRQn = 8, /*!< EXTI Line2 Interrupt */ EXTI3_IRQn = 9, /*!< EXTI Line3 Interrupt */ EXTI4_IRQn = 10, /*!< EXTI Line4 Interrupt */ DMA1_Stream0_IRQn = 11, /*!< DMA1 Stream 0 global Interrupt */ DMA1_Stream1_IRQn = 12, /*!< DMA1 Stream 1 global Interrupt */ DMA1_Stream2_IRQn = 13, /*!< DMA1 Stream 2 global Interrupt */ DMA1_Stream3_IRQn = 14, /*!< DMA1 Stream 3 global Interrupt */ DMA1_Stream4_IRQn = 15, /*!< DMA1 Stream 4 global Interrupt */ DMA1_Stream5_IRQn = 16, /*!< DMA1 Stream 5 global Interrupt */ DMA1_Stream6_IRQn = 17, /*!< DMA1 Stream 6 global Interrupt */ ADC_IRQn = 18, /*!< ADC1, ADC2 and ADC3 global Interrupts */ CAN1_TX_IRQn = 19, /*!< CAN1 TX Interrupt */ CAN1_RX0_IRQn = 20, /*!< CAN1 RX0 Interrupt */ CAN1_RX1_IRQn = 21, /*!< CAN1 RX1 Interrupt */ CAN1_SCE_IRQn = 22, /*!< CAN1 SCE Interrupt */ EXTI9_5_IRQn = 23, /*!< External Line[9:5] Interrupts */ TIM1_BRK_TIM9_IRQn = 24, /*!< TIM1 Break interrupt and TIM9 global interrupt */ TIM1_UP_TIM10_IRQn = 25, /*!< TIM1 Update Interrupt and TIM10 global interrupt */ TIM1_TRG_COM_TIM11_IRQn = 26, /*!< TIM1 Trigger and Commutation Interrupt and TIM11 global interrupt */ TIM1_CC_IRQn = 27, /*!< TIM1 Capture Compare Interrupt */ TIM2_IRQn = 28, /*!< TIM2 global Interrupt */ TIM3_IRQn = 29, /*!< TIM3 global Interrupt */ TIM4_IRQn = 30, /*!< TIM4 global Interrupt */ I2C1_EV_IRQn = 31, /*!< I2C1 Event Interrupt */ I2C1_ER_IRQn = 32, /*!< I2C1 Error Interrupt */ I2C2_EV_IRQn = 33, /*!< I2C2 Event Interrupt */ I2C2_ER_IRQn = 34, /*!< I2C2 Error Interrupt */ SPI1_IRQn = 35, /*!< SPI1 global Interrupt */ SPI2_IRQn = 36, /*!< SPI2 global Interrupt */ USART1_IRQn = 37, /*!< USART1 global Interrupt */ USART2_IRQn = 38, /*!< USART2 global Interrupt */ USART3_IRQn = 39, /*!< USART3 global Interrupt */ EXTI15_10_IRQn = 40, /*!< External Line[15:10] Interrupts */ RTC_Alarm_IRQn = 41, /*!< RTC Alarm (A and B) through EXTI Line Interrupt */ OTG_FS_WKUP_IRQn = 42, /*!< USB OTG FS Wakeup through EXTI line interrupt */ TIM8_BRK_TIM12_IRQn = 43, /*!< TIM8 Break Interrupt and TIM12 global interrupt */ TIM8_UP_TIM13_IRQn = 44, /*!< TIM8 Update Interrupt and TIM13 global interrupt */ TIM8_TRG_COM_TIM14_IRQn = 45, /*!< TIM8 Trigger and Commutation Interrupt and TIM14 global interrupt */ TIM8_CC_IRQn = 46, /*!< TIM8 Capture Compare global interrupt */ DMA1_Stream7_IRQn = 47, /*!< DMA1 Stream7 Interrupt */ FSMC_IRQn = 48, /*!< FSMC global Interrupt */ SDIO_IRQn = 49, /*!< SDIO global Interrupt */ TIM5_IRQn = 50, /*!< TIM5 global Interrupt */ SPI3_IRQn = 51, /*!< SPI3 global Interrupt */ UART4_IRQn = 52, /*!< UART4 global Interrupt */ UART5_IRQn = 53, /*!< UART5 global Interrupt */ TIM6_DAC_IRQn = 54, /*!< TIM6 global and DAC1&2 underrun error interrupts */ TIM7_IRQn = 55, /*!< TIM7 global interrupt */ DMA2_Stream0_IRQn = 56, /*!< DMA2 Stream 0 global Interrupt */ DMA2_Stream1_IRQn = 57, /*!< DMA2 Stream 1 global Interrupt */ DMA2_Stream2_IRQn = 58, /*!< DMA2 Stream 2 global Interrupt */ DMA2_Stream3_IRQn = 59, /*!< DMA2 Stream 3 global Interrupt */ DMA2_Stream4_IRQn = 60, /*!< DMA2 Stream 4 global Interrupt */ CAN2_TX_IRQn = 63, /*!< CAN2 TX Interrupt */ CAN2_RX0_IRQn = 64, /*!< CAN2 RX0 Interrupt */ CAN2_RX1_IRQn = 65, /*!< CAN2 RX1 Interrupt */ CAN2_SCE_IRQn = 66, /*!< CAN2 SCE Interrupt */ OTG_FS_IRQn = 67, /*!< USB OTG FS global Interrupt */ DMA2_Stream5_IRQn = 68, /*!< DMA2 Stream 5 global interrupt */ DMA2_Stream6_IRQn = 69, /*!< DMA2 Stream 6 global interrupt */ DMA2_Stream7_IRQn = 70, /*!< DMA2 Stream 7 global interrupt */ USART6_IRQn = 71, /*!< USART6 global interrupt */ I2C3_EV_IRQn = 72, /*!< I2C3 event interrupt */ I2C3_ER_IRQn = 73, /*!< I2C3 error interrupt */ OTG_HS_EP1_OUT_IRQn = 74, /*!< USB OTG HS End Point 1 Out global interrupt */ OTG_HS_EP1_IN_IRQn = 75, /*!< USB OTG HS End Point 1 In global interrupt */ OTG_HS_WKUP_IRQn = 76, /*!< USB OTG HS Wakeup through EXTI interrupt */ OTG_HS_IRQn = 77, /*!< USB OTG HS global interrupt */ RNG_IRQn = 80, /*!< RNG global Interrupt */ FPU_IRQn = 81 /*!< FPU global interrupt */ } IRQn_Type; /* Legacy define */ #define HASH_RNG_IRQn RNG_IRQn /** * @} */ #include "core_cm4.h" /* Cortex-M4 processor and core peripherals */ #include "system_stm32f4xx.h" #include /** @addtogroup Peripheral_registers_structures * @{ */ /** * @brief Analog to Digital Converter */ typedef struct { __IO uint32_t SR; /*!< ADC status register, Address offset: 0x00 */ __IO uint32_t CR1; /*!< ADC control register 1, Address offset: 0x04 */ __IO uint32_t CR2; /*!< ADC control register 2, Address offset: 0x08 */ __IO uint32_t SMPR1; /*!< ADC sample time register 1, Address offset: 0x0C */ __IO uint32_t SMPR2; /*!< ADC sample time register 2, Address offset: 0x10 */ __IO uint32_t JOFR1; /*!< ADC injected channel data offset register 1, Address offset: 0x14 */ __IO uint32_t JOFR2; /*!< ADC injected channel data offset register 2, Address offset: 0x18 */ __IO uint32_t JOFR3; /*!< ADC injected channel data offset register 3, Address offset: 0x1C */ __IO uint32_t JOFR4; /*!< ADC injected channel data offset register 4, Address offset: 0x20 */ __IO uint32_t HTR; /*!< ADC watchdog higher threshold register, Address offset: 0x24 */ __IO uint32_t LTR; /*!< ADC watchdog lower threshold register, Address offset: 0x28 */ __IO uint32_t SQR1; /*!< ADC regular sequence register 1, Address offset: 0x2C */ __IO uint32_t SQR2; /*!< ADC regular sequence register 2, Address offset: 0x30 */ __IO uint32_t SQR3; /*!< ADC regular sequence register 3, Address offset: 0x34 */ __IO uint32_t JSQR; /*!< ADC injected sequence register, Address offset: 0x38*/ __IO uint32_t JDR1; /*!< ADC injected data register 1, Address offset: 0x3C */ __IO uint32_t JDR2; /*!< ADC injected data register 2, Address offset: 0x40 */ __IO uint32_t JDR3; /*!< ADC injected data register 3, Address offset: 0x44 */ __IO uint32_t JDR4; /*!< ADC injected data register 4, Address offset: 0x48 */ __IO uint32_t DR; /*!< ADC regular data register, Address offset: 0x4C */ } ADC_TypeDef; typedef struct { __IO uint32_t CSR; /*!< ADC Common status register, Address offset: ADC1 base address + 0x300 */ __IO uint32_t CCR; /*!< ADC common control register, Address offset: ADC1 base address + 0x304 */ __IO uint32_t CDR; /*!< ADC common regular data register for dual AND triple modes, Address offset: ADC1 base address + 0x308 */ } ADC_Common_TypeDef; /** * @brief Controller Area Network TxMailBox */ typedef struct { __IO uint32_t TIR; /*!< CAN TX mailbox identifier register */ __IO uint32_t TDTR; /*!< CAN mailbox data length control and time stamp register */ __IO uint32_t TDLR; /*!< CAN mailbox data low register */ __IO uint32_t TDHR; /*!< CAN mailbox data high register */ } CAN_TxMailBox_TypeDef; /** * @brief Controller Area Network FIFOMailBox */ typedef struct { __IO uint32_t RIR; /*!< CAN receive FIFO mailbox identifier register */ __IO uint32_t RDTR; /*!< CAN receive FIFO mailbox data length control and time stamp register */ __IO uint32_t RDLR; /*!< CAN receive FIFO mailbox data low register */ __IO uint32_t RDHR; /*!< CAN receive FIFO mailbox data high register */ } CAN_FIFOMailBox_TypeDef; /** * @brief Controller Area Network FilterRegister */ typedef struct { __IO uint32_t FR1; /*!< CAN Filter bank register 1 */ __IO uint32_t FR2; /*!< CAN Filter bank register 1 */ } CAN_FilterRegister_TypeDef; /** * @brief Controller Area Network */ typedef struct { __IO uint32_t MCR; /*!< CAN master control register, Address offset: 0x00 */ __IO uint32_t MSR; /*!< CAN master status register, Address offset: 0x04 */ __IO uint32_t TSR; /*!< CAN transmit status register, Address offset: 0x08 */ __IO uint32_t RF0R; /*!< CAN receive FIFO 0 register, Address offset: 0x0C */ __IO uint32_t RF1R; /*!< CAN receive FIFO 1 register, Address offset: 0x10 */ __IO uint32_t IER; /*!< CAN interrupt enable register, Address offset: 0x14 */ __IO uint32_t ESR; /*!< CAN error status register, Address offset: 0x18 */ __IO uint32_t BTR; /*!< CAN bit timing register, Address offset: 0x1C */ uint32_t RESERVED0[88]; /*!< Reserved, 0x020 - 0x17F */ CAN_TxMailBox_TypeDef sTxMailBox[3]; /*!< CAN Tx MailBox, Address offset: 0x180 - 0x1AC */ CAN_FIFOMailBox_TypeDef sFIFOMailBox[2]; /*!< CAN FIFO MailBox, Address offset: 0x1B0 - 0x1CC */ uint32_t RESERVED1[12]; /*!< Reserved, 0x1D0 - 0x1FF */ __IO uint32_t FMR; /*!< CAN filter master register, Address offset: 0x200 */ __IO uint32_t FM1R; /*!< CAN filter mode register, Address offset: 0x204 */ uint32_t RESERVED2; /*!< Reserved, 0x208 */ __IO uint32_t FS1R; /*!< CAN filter scale register, Address offset: 0x20C */ uint32_t RESERVED3; /*!< Reserved, 0x210 */ __IO uint32_t FFA1R; /*!< CAN filter FIFO assignment register, Address offset: 0x214 */ uint32_t RESERVED4; /*!< Reserved, 0x218 */ __IO uint32_t FA1R; /*!< CAN filter activation register, Address offset: 0x21C */ uint32_t RESERVED5[8]; /*!< Reserved, 0x220-0x23F */ CAN_FilterRegister_TypeDef sFilterRegister[28]; /*!< CAN Filter Register, Address offset: 0x240-0x31C */ } CAN_TypeDef; /** * @brief CRC calculation unit */ typedef struct { __IO uint32_t DR; /*!< CRC Data register, Address offset: 0x00 */ __IO uint8_t IDR; /*!< CRC Independent data register, Address offset: 0x04 */ uint8_t RESERVED0; /*!< Reserved, 0x05 */ uint16_t RESERVED1; /*!< Reserved, 0x06 */ __IO uint32_t CR; /*!< CRC Control register, Address offset: 0x08 */ } CRC_TypeDef; /** * @brief Digital to Analog Converter */ typedef struct { __IO uint32_t CR; /*!< DAC control register, Address offset: 0x00 */ __IO uint32_t SWTRIGR; /*!< DAC software trigger register, Address offset: 0x04 */ __IO uint32_t DHR12R1; /*!< DAC channel1 12-bit right-aligned data holding register, Address offset: 0x08 */ __IO uint32_t DHR12L1; /*!< DAC channel1 12-bit left aligned data holding register, Address offset: 0x0C */ __IO uint32_t DHR8R1; /*!< DAC channel1 8-bit right aligned data holding register, Address offset: 0x10 */ __IO uint32_t DHR12R2; /*!< DAC channel2 12-bit right aligned data holding register, Address offset: 0x14 */ __IO uint32_t DHR12L2; /*!< DAC channel2 12-bit left aligned data holding register, Address offset: 0x18 */ __IO uint32_t DHR8R2; /*!< DAC channel2 8-bit right-aligned data holding register, Address offset: 0x1C */ __IO uint32_t DHR12RD; /*!< Dual DAC 12-bit right-aligned data holding register, Address offset: 0x20 */ __IO uint32_t DHR12LD; /*!< DUAL DAC 12-bit left aligned data holding register, Address offset: 0x24 */ __IO uint32_t DHR8RD; /*!< DUAL DAC 8-bit right aligned data holding register, Address offset: 0x28 */ __IO uint32_t DOR1; /*!< DAC channel1 data output register, Address offset: 0x2C */ __IO uint32_t DOR2; /*!< DAC channel2 data output register, Address offset: 0x30 */ __IO uint32_t SR; /*!< DAC status register, Address offset: 0x34 */ } DAC_TypeDef; /** * @brief Debug MCU */ typedef struct { __IO uint32_t IDCODE; /*!< MCU device ID code, Address offset: 0x00 */ __IO uint32_t CR; /*!< Debug MCU configuration register, Address offset: 0x04 */ __IO uint32_t APB1FZ; /*!< Debug MCU APB1 freeze register, Address offset: 0x08 */ __IO uint32_t APB2FZ; /*!< Debug MCU APB2 freeze register, Address offset: 0x0C */ }DBGMCU_TypeDef; /** * @brief DMA Controller */ typedef struct { __IO uint32_t CR; /*!< DMA stream x configuration register */ __IO uint32_t NDTR; /*!< DMA stream x number of data register */ __IO uint32_t PAR; /*!< DMA stream x peripheral address register */ __IO uint32_t M0AR; /*!< DMA stream x memory 0 address register */ __IO uint32_t M1AR; /*!< DMA stream x memory 1 address register */ __IO uint32_t FCR; /*!< DMA stream x FIFO control register */ } DMA_Stream_TypeDef; typedef struct { __IO uint32_t LISR; /*!< DMA low interrupt status register, Address offset: 0x00 */ __IO uint32_t HISR; /*!< DMA high interrupt status register, Address offset: 0x04 */ __IO uint32_t LIFCR; /*!< DMA low interrupt flag clear register, Address offset: 0x08 */ __IO uint32_t HIFCR; /*!< DMA high interrupt flag clear register, Address offset: 0x0C */ } DMA_TypeDef; /** * @brief External Interrupt/Event Controller */ typedef struct { __IO uint32_t IMR; /*!< EXTI Interrupt mask register, Address offset: 0x00 */ __IO uint32_t EMR; /*!< EXTI Event mask register, Address offset: 0x04 */ __IO uint32_t RTSR; /*!< EXTI Rising trigger selection register, Address offset: 0x08 */ __IO uint32_t FTSR; /*!< EXTI Falling trigger selection register, Address offset: 0x0C */ __IO uint32_t SWIER; /*!< EXTI Software interrupt event register, Address offset: 0x10 */ __IO uint32_t PR; /*!< EXTI Pending register, Address offset: 0x14 */ } EXTI_TypeDef; /** * @brief FLASH Registers */ typedef struct { __IO uint32_t ACR; /*!< FLASH access control register, Address offset: 0x00 */ __IO uint32_t KEYR; /*!< FLASH key register, Address offset: 0x04 */ __IO uint32_t OPTKEYR; /*!< FLASH option key register, Address offset: 0x08 */ __IO uint32_t SR; /*!< FLASH status register, Address offset: 0x0C */ __IO uint32_t CR; /*!< FLASH control register, Address offset: 0x10 */ __IO uint32_t OPTCR; /*!< FLASH option control register , Address offset: 0x14 */ __IO uint32_t OPTCR1; /*!< FLASH option control register 1, Address offset: 0x18 */ } FLASH_TypeDef; /** * @brief Flexible Static Memory Controller */ typedef struct { __IO uint32_t BTCR[8]; /*!< NOR/PSRAM chip-select control register(BCR) and chip-select timing register(BTR), Address offset: 0x00-1C */ } FSMC_Bank1_TypeDef; /** * @brief Flexible Static Memory Controller Bank1E */ typedef struct { __IO uint32_t BWTR[7]; /*!< NOR/PSRAM write timing registers, Address offset: 0x104-0x11C */ } FSMC_Bank1E_TypeDef; /** * @brief Flexible Static Memory Controller Bank2 */ typedef struct { __IO uint32_t PCR2; /*!< NAND Flash control register 2, Address offset: 0x60 */ __IO uint32_t SR2; /*!< NAND Flash FIFO status and interrupt register 2, Address offset: 0x64 */ __IO uint32_t PMEM2; /*!< NAND Flash Common memory space timing register 2, Address offset: 0x68 */ __IO uint32_t PATT2; /*!< NAND Flash Attribute memory space timing register 2, Address offset: 0x6C */ uint32_t RESERVED0; /*!< Reserved, 0x70 */ __IO uint32_t ECCR2; /*!< NAND Flash ECC result registers 2, Address offset: 0x74 */ uint32_t RESERVED1; /*!< Reserved, 0x78 */ uint32_t RESERVED2; /*!< Reserved, 0x7C */ __IO uint32_t PCR3; /*!< NAND Flash control register 3, Address offset: 0x80 */ __IO uint32_t SR3; /*!< NAND Flash FIFO status and interrupt register 3, Address offset: 0x84 */ __IO uint32_t PMEM3; /*!< NAND Flash Common memory space timing register 3, Address offset: 0x88 */ __IO uint32_t PATT3; /*!< NAND Flash Attribute memory space timing register 3, Address offset: 0x8C */ uint32_t RESERVED3; /*!< Reserved, 0x90 */ __IO uint32_t ECCR3; /*!< NAND Flash ECC result registers 3, Address offset: 0x94 */ } FSMC_Bank2_3_TypeDef; /** * @brief Flexible Static Memory Controller Bank4 */ typedef struct { __IO uint32_t PCR4; /*!< PC Card control register 4, Address offset: 0xA0 */ __IO uint32_t SR4; /*!< PC Card FIFO status and interrupt register 4, Address offset: 0xA4 */ __IO uint32_t PMEM4; /*!< PC Card Common memory space timing register 4, Address offset: 0xA8 */ __IO uint32_t PATT4; /*!< PC Card Attribute memory space timing register 4, Address offset: 0xAC */ __IO uint32_t PIO4; /*!< PC Card I/O space timing register 4, Address offset: 0xB0 */ } FSMC_Bank4_TypeDef; /** * @brief General Purpose I/O */ typedef struct { __IO uint32_t MODER; /*!< GPIO port mode register, Address offset: 0x00 */ __IO uint32_t OTYPER; /*!< GPIO port output type register, Address offset: 0x04 */ __IO uint32_t OSPEEDR; /*!< GPIO port output speed register, Address offset: 0x08 */ __IO uint32_t PUPDR; /*!< GPIO port pull-up/pull-down register, Address offset: 0x0C */ __IO uint32_t IDR; /*!< GPIO port input data register, Address offset: 0x10 */ __IO uint32_t ODR; /*!< GPIO port output data register, Address offset: 0x14 */ __IO uint32_t BSRR; /*!< GPIO port bit set/reset register, Address offset: 0x18 */ __IO uint32_t LCKR; /*!< GPIO port configuration lock register, Address offset: 0x1C */ __IO uint32_t AFR[2]; /*!< GPIO alternate function registers, Address offset: 0x20-0x24 */ } GPIO_TypeDef; /** * @brief System configuration controller */ typedef struct { __IO uint32_t MEMRMP; /*!< SYSCFG memory remap register, Address offset: 0x00 */ __IO uint32_t PMC; /*!< SYSCFG peripheral mode configuration register, Address offset: 0x04 */ __IO uint32_t EXTICR[4]; /*!< SYSCFG external interrupt configuration registers, Address offset: 0x08-0x14 */ uint32_t RESERVED[2]; /*!< Reserved, 0x18-0x1C */ __IO uint32_t CMPCR; /*!< SYSCFG Compensation cell control register, Address offset: 0x20 */ } SYSCFG_TypeDef; /** * @brief Inter-integrated Circuit Interface */ typedef struct { __IO uint32_t CR1; /*!< I2C Control register 1, Address offset: 0x00 */ __IO uint32_t CR2; /*!< I2C Control register 2, Address offset: 0x04 */ __IO uint32_t OAR1; /*!< I2C Own address register 1, Address offset: 0x08 */ __IO uint32_t OAR2; /*!< I2C Own address register 2, Address offset: 0x0C */ __IO uint32_t DR; /*!< I2C Data register, Address offset: 0x10 */ __IO uint32_t SR1; /*!< I2C Status register 1, Address offset: 0x14 */ __IO uint32_t SR2; /*!< I2C Status register 2, Address offset: 0x18 */ __IO uint32_t CCR; /*!< I2C Clock control register, Address offset: 0x1C */ __IO uint32_t TRISE; /*!< I2C TRISE register, Address offset: 0x20 */ } I2C_TypeDef; /** * @brief Independent WATCHDOG */ typedef struct { __IO uint32_t KR; /*!< IWDG Key register, Address offset: 0x00 */ __IO uint32_t PR; /*!< IWDG Prescaler register, Address offset: 0x04 */ __IO uint32_t RLR; /*!< IWDG Reload register, Address offset: 0x08 */ __IO uint32_t SR; /*!< IWDG Status register, Address offset: 0x0C */ } IWDG_TypeDef; /** * @brief Power Control */ typedef struct { __IO uint32_t CR; /*!< PWR power control register, Address offset: 0x00 */ __IO uint32_t CSR; /*!< PWR power control/status register, Address offset: 0x04 */ } PWR_TypeDef; /** * @brief Reset and Clock Control */ typedef struct { __IO uint32_t CR; /*!< RCC clock control register, Address offset: 0x00 */ __IO uint32_t PLLCFGR; /*!< RCC PLL configuration register, Address offset: 0x04 */ __IO uint32_t CFGR; /*!< RCC clock configuration register, Address offset: 0x08 */ __IO uint32_t CIR; /*!< RCC clock interrupt register, Address offset: 0x0C */ __IO uint32_t AHB1RSTR; /*!< RCC AHB1 peripheral reset register, Address offset: 0x10 */ __IO uint32_t AHB2RSTR; /*!< RCC AHB2 peripheral reset register, Address offset: 0x14 */ __IO uint32_t AHB3RSTR; /*!< RCC AHB3 peripheral reset register, Address offset: 0x18 */ uint32_t RESERVED0; /*!< Reserved, 0x1C */ __IO uint32_t APB1RSTR; /*!< RCC APB1 peripheral reset register, Address offset: 0x20 */ __IO uint32_t APB2RSTR; /*!< RCC APB2 peripheral reset register, Address offset: 0x24 */ uint32_t RESERVED1[2]; /*!< Reserved, 0x28-0x2C */ __IO uint32_t AHB1ENR; /*!< RCC AHB1 peripheral clock register, Address offset: 0x30 */ __IO uint32_t AHB2ENR; /*!< RCC AHB2 peripheral clock register, Address offset: 0x34 */ __IO uint32_t AHB3ENR; /*!< RCC AHB3 peripheral clock register, Address offset: 0x38 */ uint32_t RESERVED2; /*!< Reserved, 0x3C */ __IO uint32_t APB1ENR; /*!< RCC APB1 peripheral clock enable register, Address offset: 0x40 */ __IO uint32_t APB2ENR; /*!< RCC APB2 peripheral clock enable register, Address offset: 0x44 */ uint32_t RESERVED3[2]; /*!< Reserved, 0x48-0x4C */ __IO uint32_t AHB1LPENR; /*!< RCC AHB1 peripheral clock enable in low power mode register, Address offset: 0x50 */ __IO uint32_t AHB2LPENR; /*!< RCC AHB2 peripheral clock enable in low power mode register, Address offset: 0x54 */ __IO uint32_t AHB3LPENR; /*!< RCC AHB3 peripheral clock enable in low power mode register, Address offset: 0x58 */ uint32_t RESERVED4; /*!< Reserved, 0x5C */ __IO uint32_t APB1LPENR; /*!< RCC APB1 peripheral clock enable in low power mode register, Address offset: 0x60 */ __IO uint32_t APB2LPENR; /*!< RCC APB2 peripheral clock enable in low power mode register, Address offset: 0x64 */ uint32_t RESERVED5[2]; /*!< Reserved, 0x68-0x6C */ __IO uint32_t BDCR; /*!< RCC Backup domain control register, Address offset: 0x70 */ __IO uint32_t CSR; /*!< RCC clock control & status register, Address offset: 0x74 */ uint32_t RESERVED6[2]; /*!< Reserved, 0x78-0x7C */ __IO uint32_t SSCGR; /*!< RCC spread spectrum clock generation register, Address offset: 0x80 */ __IO uint32_t PLLI2SCFGR; /*!< RCC PLLI2S configuration register, Address offset: 0x84 */ } RCC_TypeDef; /** * @brief Real-Time Clock */ typedef struct { __IO uint32_t TR; /*!< RTC time register, Address offset: 0x00 */ __IO uint32_t DR; /*!< RTC date register, Address offset: 0x04 */ __IO uint32_t CR; /*!< RTC control register, Address offset: 0x08 */ __IO uint32_t ISR; /*!< RTC initialization and status register, Address offset: 0x0C */ __IO uint32_t PRER; /*!< RTC prescaler register, Address offset: 0x10 */ __IO uint32_t WUTR; /*!< RTC wakeup timer register, Address offset: 0x14 */ __IO uint32_t CALIBR; /*!< RTC calibration register, Address offset: 0x18 */ __IO uint32_t ALRMAR; /*!< RTC alarm A register, Address offset: 0x1C */ __IO uint32_t ALRMBR; /*!< RTC alarm B register, Address offset: 0x20 */ __IO uint32_t WPR; /*!< RTC write protection register, Address offset: 0x24 */ __IO uint32_t SSR; /*!< RTC sub second register, Address offset: 0x28 */ __IO uint32_t SHIFTR; /*!< RTC shift control register, Address offset: 0x2C */ __IO uint32_t TSTR; /*!< RTC time stamp time register, Address offset: 0x30 */ __IO uint32_t TSDR; /*!< RTC time stamp date register, Address offset: 0x34 */ __IO uint32_t TSSSR; /*!< RTC time-stamp sub second register, Address offset: 0x38 */ __IO uint32_t CALR; /*!< RTC calibration register, Address offset: 0x3C */ __IO uint32_t TAFCR; /*!< RTC tamper and alternate function configuration register, Address offset: 0x40 */ __IO uint32_t ALRMASSR;/*!< RTC alarm A sub second register, Address offset: 0x44 */ __IO uint32_t ALRMBSSR;/*!< RTC alarm B sub second register, Address offset: 0x48 */ uint32_t RESERVED7; /*!< Reserved, 0x4C */ __IO uint32_t BKP0R; /*!< RTC backup register 1, Address offset: 0x50 */ __IO uint32_t BKP1R; /*!< RTC backup register 1, Address offset: 0x54 */ __IO uint32_t BKP2R; /*!< RTC backup register 2, Address offset: 0x58 */ __IO uint32_t BKP3R; /*!< RTC backup register 3, Address offset: 0x5C */ __IO uint32_t BKP4R; /*!< RTC backup register 4, Address offset: 0x60 */ __IO uint32_t BKP5R; /*!< RTC backup register 5, Address offset: 0x64 */ __IO uint32_t BKP6R; /*!< RTC backup register 6, Address offset: 0x68 */ __IO uint32_t BKP7R; /*!< RTC backup register 7, Address offset: 0x6C */ __IO uint32_t BKP8R; /*!< RTC backup register 8, Address offset: 0x70 */ __IO uint32_t BKP9R; /*!< RTC backup register 9, Address offset: 0x74 */ __IO uint32_t BKP10R; /*!< RTC backup register 10, Address offset: 0x78 */ __IO uint32_t BKP11R; /*!< RTC backup register 11, Address offset: 0x7C */ __IO uint32_t BKP12R; /*!< RTC backup register 12, Address offset: 0x80 */ __IO uint32_t BKP13R; /*!< RTC backup register 13, Address offset: 0x84 */ __IO uint32_t BKP14R; /*!< RTC backup register 14, Address offset: 0x88 */ __IO uint32_t BKP15R; /*!< RTC backup register 15, Address offset: 0x8C */ __IO uint32_t BKP16R; /*!< RTC backup register 16, Address offset: 0x90 */ __IO uint32_t BKP17R; /*!< RTC backup register 17, Address offset: 0x94 */ __IO uint32_t BKP18R; /*!< RTC backup register 18, Address offset: 0x98 */ __IO uint32_t BKP19R; /*!< RTC backup register 19, Address offset: 0x9C */ } RTC_TypeDef; /** * @brief SD host Interface */ typedef struct { __IO uint32_t POWER; /*!< SDIO power control register, Address offset: 0x00 */ __IO uint32_t CLKCR; /*!< SDI clock control register, Address offset: 0x04 */ __IO uint32_t ARG; /*!< SDIO argument register, Address offset: 0x08 */ __IO uint32_t CMD; /*!< SDIO command register, Address offset: 0x0C */ __IO const uint32_t RESPCMD; /*!< SDIO command response register, Address offset: 0x10 */ __IO const uint32_t RESP1; /*!< SDIO response 1 register, Address offset: 0x14 */ __IO const uint32_t RESP2; /*!< SDIO response 2 register, Address offset: 0x18 */ __IO const uint32_t RESP3; /*!< SDIO response 3 register, Address offset: 0x1C */ __IO const uint32_t RESP4; /*!< SDIO response 4 register, Address offset: 0x20 */ __IO uint32_t DTIMER; /*!< SDIO data timer register, Address offset: 0x24 */ __IO uint32_t DLEN; /*!< SDIO data length register, Address offset: 0x28 */ __IO uint32_t DCTRL; /*!< SDIO data control register, Address offset: 0x2C */ __IO const uint32_t DCOUNT; /*!< SDIO data counter register, Address offset: 0x30 */ __IO const uint32_t STA; /*!< SDIO status register, Address offset: 0x34 */ __IO uint32_t ICR; /*!< SDIO interrupt clear register, Address offset: 0x38 */ __IO uint32_t MASK; /*!< SDIO mask register, Address offset: 0x3C */ uint32_t RESERVED0[2]; /*!< Reserved, 0x40-0x44 */ __IO const uint32_t FIFOCNT; /*!< SDIO FIFO counter register, Address offset: 0x48 */ uint32_t RESERVED1[13]; /*!< Reserved, 0x4C-0x7C */ __IO uint32_t FIFO; /*!< SDIO data FIFO register, Address offset: 0x80 */ } SDIO_TypeDef; /** * @brief Serial Peripheral Interface */ typedef struct { __IO uint32_t CR1; /*!< SPI control register 1 (not used in I2S mode), Address offset: 0x00 */ __IO uint32_t CR2; /*!< SPI control register 2, Address offset: 0x04 */ __IO uint32_t SR; /*!< SPI status register, Address offset: 0x08 */ __IO uint32_t DR; /*!< SPI data register, Address offset: 0x0C */ __IO uint32_t CRCPR; /*!< SPI CRC polynomial register (not used in I2S mode), Address offset: 0x10 */ __IO uint32_t RXCRCR; /*!< SPI RX CRC register (not used in I2S mode), Address offset: 0x14 */ __IO uint32_t TXCRCR; /*!< SPI TX CRC register (not used in I2S mode), Address offset: 0x18 */ __IO uint32_t I2SCFGR; /*!< SPI_I2S configuration register, Address offset: 0x1C */ __IO uint32_t I2SPR; /*!< SPI_I2S prescaler register, Address offset: 0x20 */ } SPI_TypeDef; /** * @brief TIM */ typedef struct { __IO uint32_t CR1; /*!< TIM control register 1, Address offset: 0x00 */ __IO uint32_t CR2; /*!< TIM control register 2, Address offset: 0x04 */ __IO uint32_t SMCR; /*!< TIM slave mode control register, Address offset: 0x08 */ __IO uint32_t DIER; /*!< TIM DMA/interrupt enable register, Address offset: 0x0C */ __IO uint32_t SR; /*!< TIM status register, Address offset: 0x10 */ __IO uint32_t EGR; /*!< TIM event generation register, Address offset: 0x14 */ __IO uint32_t CCMR1; /*!< TIM capture/compare mode register 1, Address offset: 0x18 */ __IO uint32_t CCMR2; /*!< TIM capture/compare mode register 2, Address offset: 0x1C */ __IO uint32_t CCER; /*!< TIM capture/compare enable register, Address offset: 0x20 */ __IO uint32_t CNT; /*!< TIM counter register, Address offset: 0x24 */ __IO uint32_t PSC; /*!< TIM prescaler, Address offset: 0x28 */ __IO uint32_t ARR; /*!< TIM auto-reload register, Address offset: 0x2C */ __IO uint32_t RCR; /*!< TIM repetition counter register, Address offset: 0x30 */ __IO uint32_t CCR1; /*!< TIM capture/compare register 1, Address offset: 0x34 */ __IO uint32_t CCR2; /*!< TIM capture/compare register 2, Address offset: 0x38 */ __IO uint32_t CCR3; /*!< TIM capture/compare register 3, Address offset: 0x3C */ __IO uint32_t CCR4; /*!< TIM capture/compare register 4, Address offset: 0x40 */ __IO uint32_t BDTR; /*!< TIM break and dead-time register, Address offset: 0x44 */ __IO uint32_t DCR; /*!< TIM DMA control register, Address offset: 0x48 */ __IO uint32_t DMAR; /*!< TIM DMA address for full transfer, Address offset: 0x4C */ __IO uint32_t OR; /*!< TIM option register, Address offset: 0x50 */ } TIM_TypeDef; /** * @brief Universal Synchronous Asynchronous Receiver Transmitter */ typedef struct { __IO uint32_t SR; /*!< USART Status register, Address offset: 0x00 */ __IO uint32_t DR; /*!< USART Data register, Address offset: 0x04 */ __IO uint32_t BRR; /*!< USART Baud rate register, Address offset: 0x08 */ __IO uint32_t CR1; /*!< USART Control register 1, Address offset: 0x0C */ __IO uint32_t CR2; /*!< USART Control register 2, Address offset: 0x10 */ __IO uint32_t CR3; /*!< USART Control register 3, Address offset: 0x14 */ __IO uint32_t GTPR; /*!< USART Guard time and prescaler register, Address offset: 0x18 */ } USART_TypeDef; /** * @brief Window WATCHDOG */ typedef struct { __IO uint32_t CR; /*!< WWDG Control register, Address offset: 0x00 */ __IO uint32_t CFR; /*!< WWDG Configuration register, Address offset: 0x04 */ __IO uint32_t SR; /*!< WWDG Status register, Address offset: 0x08 */ } WWDG_TypeDef; /** * @brief RNG */ typedef struct { __IO uint32_t CR; /*!< RNG control register, Address offset: 0x00 */ __IO uint32_t SR; /*!< RNG status register, Address offset: 0x04 */ __IO uint32_t DR; /*!< RNG data register, Address offset: 0x08 */ } RNG_TypeDef; /** * @brief USB_OTG_Core_Registers */ typedef struct { __IO uint32_t GOTGCTL; /*!< USB_OTG Control and Status Register 000h */ __IO uint32_t GOTGINT; /*!< USB_OTG Interrupt Register 004h */ __IO uint32_t GAHBCFG; /*!< Core AHB Configuration Register 008h */ __IO uint32_t GUSBCFG; /*!< Core USB Configuration Register 00Ch */ __IO uint32_t GRSTCTL; /*!< Core Reset Register 010h */ __IO uint32_t GINTSTS; /*!< Core Interrupt Register 014h */ __IO uint32_t GINTMSK; /*!< Core Interrupt Mask Register 018h */ __IO uint32_t GRXSTSR; /*!< Receive Sts Q Read Register 01Ch */ __IO uint32_t GRXSTSP; /*!< Receive Sts Q Read & POP Register 020h */ __IO uint32_t GRXFSIZ; /*!< Receive FIFO Size Register 024h */ __IO uint32_t DIEPTXF0_HNPTXFSIZ; /*!< EP0 / Non Periodic Tx FIFO Size Register 028h */ __IO uint32_t HNPTXSTS; /*!< Non Periodic Tx FIFO/Queue Sts reg 02Ch */ uint32_t Reserved30[2]; /*!< Reserved 030h */ __IO uint32_t GCCFG; /*!< General Purpose IO Register 038h */ __IO uint32_t CID; /*!< User ID Register 03Ch */ uint32_t Reserved40[48]; /*!< Reserved 0x40-0xFF */ __IO uint32_t HPTXFSIZ; /*!< Host Periodic Tx FIFO Size Reg 100h */ __IO uint32_t DIEPTXF[0x0F]; /*!< dev Periodic Transmit FIFO */ } USB_OTG_GlobalTypeDef; /** * @brief USB_OTG_device_Registers */ typedef struct { __IO uint32_t DCFG; /*!< dev Configuration Register 800h */ __IO uint32_t DCTL; /*!< dev Control Register 804h */ __IO uint32_t DSTS; /*!< dev Status Register (RO) 808h */ uint32_t Reserved0C; /*!< Reserved 80Ch */ __IO uint32_t DIEPMSK; /*!< dev IN Endpoint Mask 810h */ __IO uint32_t DOEPMSK; /*!< dev OUT Endpoint Mask 814h */ __IO uint32_t DAINT; /*!< dev All Endpoints Itr Reg 818h */ __IO uint32_t DAINTMSK; /*!< dev All Endpoints Itr Mask 81Ch */ uint32_t Reserved20; /*!< Reserved 820h */ uint32_t Reserved9; /*!< Reserved 824h */ __IO uint32_t DVBUSDIS; /*!< dev VBUS discharge Register 828h */ __IO uint32_t DVBUSPULSE; /*!< dev VBUS Pulse Register 82Ch */ __IO uint32_t DTHRCTL; /*!< dev threshold 830h */ __IO uint32_t DIEPEMPMSK; /*!< dev empty msk 834h */ __IO uint32_t DEACHINT; /*!< dedicated EP interrupt 838h */ __IO uint32_t DEACHMSK; /*!< dedicated EP msk 83Ch */ uint32_t Reserved40; /*!< dedicated EP mask 840h */ __IO uint32_t DINEP1MSK; /*!< dedicated EP mask 844h */ uint32_t Reserved44[15]; /*!< Reserved 844-87Ch */ __IO uint32_t DOUTEP1MSK; /*!< dedicated EP msk 884h */ } USB_OTG_DeviceTypeDef; /** * @brief USB_OTG_IN_Endpoint-Specific_Register */ typedef struct { __IO uint32_t DIEPCTL; /*!< dev IN Endpoint Control Reg 900h + (ep_num * 20h) + 00h */ uint32_t Reserved04; /*!< Reserved 900h + (ep_num * 20h) + 04h */ __IO uint32_t DIEPINT; /*!< dev IN Endpoint Itr Reg 900h + (ep_num * 20h) + 08h */ uint32_t Reserved0C; /*!< Reserved 900h + (ep_num * 20h) + 0Ch */ __IO uint32_t DIEPTSIZ; /*!< IN Endpoint Txfer Size 900h + (ep_num * 20h) + 10h */ __IO uint32_t DIEPDMA; /*!< IN Endpoint DMA Address Reg 900h + (ep_num * 20h) + 14h */ __IO uint32_t DTXFSTS; /*!< IN Endpoint Tx FIFO Status Reg 900h + (ep_num * 20h) + 18h */ uint32_t Reserved18; /*!< Reserved 900h+(ep_num*20h)+1Ch-900h+ (ep_num * 20h) + 1Ch */ } USB_OTG_INEndpointTypeDef; /** * @brief USB_OTG_OUT_Endpoint-Specific_Registers */ typedef struct { __IO uint32_t DOEPCTL; /*!< dev OUT Endpoint Control Reg B00h + (ep_num * 20h) + 00h */ uint32_t Reserved04; /*!< Reserved B00h + (ep_num * 20h) + 04h */ __IO uint32_t DOEPINT; /*!< dev OUT Endpoint Itr Reg B00h + (ep_num * 20h) + 08h */ uint32_t Reserved0C; /*!< Reserved B00h + (ep_num * 20h) + 0Ch */ __IO uint32_t DOEPTSIZ; /*!< dev OUT Endpoint Txfer Size B00h + (ep_num * 20h) + 10h */ __IO uint32_t DOEPDMA; /*!< dev OUT Endpoint DMA Address B00h + (ep_num * 20h) + 14h */ uint32_t Reserved18[2]; /*!< Reserved B00h + (ep_num * 20h) + 18h - B00h + (ep_num * 20h) + 1Ch */ } USB_OTG_OUTEndpointTypeDef; /** * @brief USB_OTG_Host_Mode_Register_Structures */ typedef struct { __IO uint32_t HCFG; /*!< Host Configuration Register 400h */ __IO uint32_t HFIR; /*!< Host Frame Interval Register 404h */ __IO uint32_t HFNUM; /*!< Host Frame Nbr/Frame Remaining 408h */ uint32_t Reserved40C; /*!< Reserved 40Ch */ __IO uint32_t HPTXSTS; /*!< Host Periodic Tx FIFO/ Queue Status 410h */ __IO uint32_t HAINT; /*!< Host All Channels Interrupt Register 414h */ __IO uint32_t HAINTMSK; /*!< Host All Channels Interrupt Mask 418h */ } USB_OTG_HostTypeDef; /** * @brief USB_OTG_Host_Channel_Specific_Registers */ typedef struct { __IO uint32_t HCCHAR; /*!< Host Channel Characteristics Register 500h */ __IO uint32_t HCSPLT; /*!< Host Channel Split Control Register 504h */ __IO uint32_t HCINT; /*!< Host Channel Interrupt Register 508h */ __IO uint32_t HCINTMSK; /*!< Host Channel Interrupt Mask Register 50Ch */ __IO uint32_t HCTSIZ; /*!< Host Channel Transfer Size Register 510h */ __IO uint32_t HCDMA; /*!< Host Channel DMA Address Register 514h */ uint32_t Reserved[2]; /*!< Reserved */ } USB_OTG_HostChannelTypeDef; /** * @} */ /** @addtogroup Peripheral_memory_map * @{ */ #define FLASH_BASE 0x08000000UL /*!< FLASH(up to 1 MB) base address in the alias region */ #define CCMDATARAM_BASE 0x10000000UL /*!< CCM(core coupled memory) data RAM(64 KB) base address in the alias region */ #define SRAM1_BASE 0x20000000UL /*!< SRAM1(112 KB) base address in the alias region */ #define SRAM2_BASE 0x2001C000UL /*!< SRAM2(16 KB) base address in the alias region */ #define PERIPH_BASE 0x40000000UL /*!< Peripheral base address in the alias region */ #define BKPSRAM_BASE 0x40024000UL /*!< Backup SRAM(4 KB) base address in the alias region */ #define FSMC_R_BASE 0xA0000000UL /*!< FSMC registers base address */ #define SRAM1_BB_BASE 0x22000000UL /*!< SRAM1(112 KB) base address in the bit-band region */ #define SRAM2_BB_BASE 0x22380000UL /*!< SRAM2(16 KB) base address in the bit-band region */ #define PERIPH_BB_BASE 0x42000000UL /*!< Peripheral base address in the bit-band region */ #define BKPSRAM_BB_BASE 0x42480000UL /*!< Backup SRAM(4 KB) base address in the bit-band region */ #define FLASH_END 0x080FFFFFUL /*!< FLASH end address */ #define FLASH_OTP_BASE 0x1FFF7800UL /*!< Base address of : (up to 528 Bytes) embedded FLASH OTP Area */ #define FLASH_OTP_END 0x1FFF7A0FUL /*!< End address of : (up to 528 Bytes) embedded FLASH OTP Area */ #define CCMDATARAM_END 0x1000FFFFUL /*!< CCM data RAM end address */ /* Legacy defines */ #define SRAM_BASE SRAM1_BASE #define SRAM_BB_BASE SRAM1_BB_BASE /*!< Peripheral memory map */ #define APB1PERIPH_BASE PERIPH_BASE #define APB2PERIPH_BASE (PERIPH_BASE + 0x00010000UL) #define AHB1PERIPH_BASE (PERIPH_BASE + 0x00020000UL) #define AHB2PERIPH_BASE (PERIPH_BASE + 0x10000000UL) /*!< APB1 peripherals */ #define TIM2_BASE (APB1PERIPH_BASE + 0x0000UL) #define TIM3_BASE (APB1PERIPH_BASE + 0x0400UL) #define TIM4_BASE (APB1PERIPH_BASE + 0x0800UL) #define TIM5_BASE (APB1PERIPH_BASE + 0x0C00UL) #define TIM6_BASE (APB1PERIPH_BASE + 0x1000UL) #define TIM7_BASE (APB1PERIPH_BASE + 0x1400UL) #define TIM12_BASE (APB1PERIPH_BASE + 0x1800UL) #define TIM13_BASE (APB1PERIPH_BASE + 0x1C00UL) #define TIM14_BASE (APB1PERIPH_BASE + 0x2000UL) #define RTC_BASE (APB1PERIPH_BASE + 0x2800UL) #define WWDG_BASE (APB1PERIPH_BASE + 0x2C00UL) #define IWDG_BASE (APB1PERIPH_BASE + 0x3000UL) #define I2S2ext_BASE (APB1PERIPH_BASE + 0x3400UL) #define SPI2_BASE (APB1PERIPH_BASE + 0x3800UL) #define SPI3_BASE (APB1PERIPH_BASE + 0x3C00UL) #define I2S3ext_BASE (APB1PERIPH_BASE + 0x4000UL) #define USART2_BASE (APB1PERIPH_BASE + 0x4400UL) #define USART3_BASE (APB1PERIPH_BASE + 0x4800UL) #define UART4_BASE (APB1PERIPH_BASE + 0x4C00UL) #define UART5_BASE (APB1PERIPH_BASE + 0x5000UL) #define I2C1_BASE (APB1PERIPH_BASE + 0x5400UL) #define I2C2_BASE (APB1PERIPH_BASE + 0x5800UL) #define I2C3_BASE (APB1PERIPH_BASE + 0x5C00UL) #define CAN1_BASE (APB1PERIPH_BASE + 0x6400UL) #define CAN2_BASE (APB1PERIPH_BASE + 0x6800UL) #define PWR_BASE (APB1PERIPH_BASE + 0x7000UL) #define DAC_BASE (APB1PERIPH_BASE + 0x7400UL) /*!< APB2 peripherals */ #define TIM1_BASE (APB2PERIPH_BASE + 0x0000UL) #define TIM8_BASE (APB2PERIPH_BASE + 0x0400UL) #define USART1_BASE (APB2PERIPH_BASE + 0x1000UL) #define USART6_BASE (APB2PERIPH_BASE + 0x1400UL) #define ADC1_BASE (APB2PERIPH_BASE + 0x2000UL) #define ADC2_BASE (APB2PERIPH_BASE + 0x2100UL) #define ADC3_BASE (APB2PERIPH_BASE + 0x2200UL) #define ADC123_COMMON_BASE (APB2PERIPH_BASE + 0x2300UL) /* Legacy define */ #define ADC_BASE ADC123_COMMON_BASE #define SDIO_BASE (APB2PERIPH_BASE + 0x2C00UL) #define SPI1_BASE (APB2PERIPH_BASE + 0x3000UL) #define SYSCFG_BASE (APB2PERIPH_BASE + 0x3800UL) #define EXTI_BASE (APB2PERIPH_BASE + 0x3C00UL) #define TIM9_BASE (APB2PERIPH_BASE + 0x4000UL) #define TIM10_BASE (APB2PERIPH_BASE + 0x4400UL) #define TIM11_BASE (APB2PERIPH_BASE + 0x4800UL) /*!< AHB1 peripherals */ #define GPIOA_BASE (AHB1PERIPH_BASE + 0x0000UL) #define GPIOB_BASE (AHB1PERIPH_BASE + 0x0400UL) #define GPIOC_BASE (AHB1PERIPH_BASE + 0x0800UL) #define GPIOD_BASE (AHB1PERIPH_BASE + 0x0C00UL) #define GPIOE_BASE (AHB1PERIPH_BASE + 0x1000UL) #define GPIOF_BASE (AHB1PERIPH_BASE + 0x1400UL) #define GPIOG_BASE (AHB1PERIPH_BASE + 0x1800UL) #define GPIOH_BASE (AHB1PERIPH_BASE + 0x1C00UL) #define GPIOI_BASE (AHB1PERIPH_BASE + 0x2000UL) #define CRC_BASE (AHB1PERIPH_BASE + 0x3000UL) #define RCC_BASE (AHB1PERIPH_BASE + 0x3800UL) #define FLASH_R_BASE (AHB1PERIPH_BASE + 0x3C00UL) #define DMA1_BASE (AHB1PERIPH_BASE + 0x6000UL) #define DMA1_Stream0_BASE (DMA1_BASE + 0x010UL) #define DMA1_Stream1_BASE (DMA1_BASE + 0x028UL) #define DMA1_Stream2_BASE (DMA1_BASE + 0x040UL) #define DMA1_Stream3_BASE (DMA1_BASE + 0x058UL) #define DMA1_Stream4_BASE (DMA1_BASE + 0x070UL) #define DMA1_Stream5_BASE (DMA1_BASE + 0x088UL) #define DMA1_Stream6_BASE (DMA1_BASE + 0x0A0UL) #define DMA1_Stream7_BASE (DMA1_BASE + 0x0B8UL) #define DMA2_BASE (AHB1PERIPH_BASE + 0x6400UL) #define DMA2_Stream0_BASE (DMA2_BASE + 0x010UL) #define DMA2_Stream1_BASE (DMA2_BASE + 0x028UL) #define DMA2_Stream2_BASE (DMA2_BASE + 0x040UL) #define DMA2_Stream3_BASE (DMA2_BASE + 0x058UL) #define DMA2_Stream4_BASE (DMA2_BASE + 0x070UL) #define DMA2_Stream5_BASE (DMA2_BASE + 0x088UL) #define DMA2_Stream6_BASE (DMA2_BASE + 0x0A0UL) #define DMA2_Stream7_BASE (DMA2_BASE + 0x0B8UL) /*!< AHB2 peripherals */ #define RNG_BASE (AHB2PERIPH_BASE + 0x60800UL) /*!< FSMC Bankx registers base address */ #define FSMC_Bank1_R_BASE (FSMC_R_BASE + 0x0000UL) #define FSMC_Bank1E_R_BASE (FSMC_R_BASE + 0x0104UL) #define FSMC_Bank2_3_R_BASE (FSMC_R_BASE + 0x0060UL) #define FSMC_Bank4_R_BASE (FSMC_R_BASE + 0x00A0UL) /*!< Debug MCU registers base address */ #define DBGMCU_BASE 0xE0042000UL /*!< USB registers base address */ #define USB_OTG_HS_PERIPH_BASE 0x40040000UL #define USB_OTG_FS_PERIPH_BASE 0x50000000UL #define USB_OTG_GLOBAL_BASE 0x000UL #define USB_OTG_DEVICE_BASE 0x800UL #define USB_OTG_IN_ENDPOINT_BASE 0x900UL #define USB_OTG_OUT_ENDPOINT_BASE 0xB00UL #define USB_OTG_EP_REG_SIZE 0x20UL #define USB_OTG_HOST_BASE 0x400UL #define USB_OTG_HOST_PORT_BASE 0x440UL #define USB_OTG_HOST_CHANNEL_BASE 0x500UL #define USB_OTG_HOST_CHANNEL_SIZE 0x20UL #define USB_OTG_PCGCCTL_BASE 0xE00UL #define USB_OTG_FIFO_BASE 0x1000UL #define USB_OTG_FIFO_SIZE 0x1000UL #define UID_BASE 0x1FFF7A10UL /*!< Unique device ID register base address */ #define FLASHSIZE_BASE 0x1FFF7A22UL /*!< FLASH Size register base address */ #define PACKAGE_BASE 0x1FFF7BF0UL /*!< Package size register base address */ /** * @} */ /** @addtogroup Peripheral_declaration * @{ */ #define TIM2 ((TIM_TypeDef *) TIM2_BASE) #define TIM3 ((TIM_TypeDef *) TIM3_BASE) #define TIM4 ((TIM_TypeDef *) TIM4_BASE) #define TIM5 ((TIM_TypeDef *) TIM5_BASE) #define TIM6 ((TIM_TypeDef *) TIM6_BASE) #define TIM7 ((TIM_TypeDef *) TIM7_BASE) #define TIM12 ((TIM_TypeDef *) TIM12_BASE) #define TIM13 ((TIM_TypeDef *) TIM13_BASE) #define TIM14 ((TIM_TypeDef *) TIM14_BASE) #define RTC ((RTC_TypeDef *) RTC_BASE) #define WWDG ((WWDG_TypeDef *) WWDG_BASE) #define IWDG ((IWDG_TypeDef *) IWDG_BASE) #define I2S2ext ((SPI_TypeDef *) I2S2ext_BASE) #define SPI2 ((SPI_TypeDef *) SPI2_BASE) #define SPI3 ((SPI_TypeDef *) SPI3_BASE) #define I2S3ext ((SPI_TypeDef *) I2S3ext_BASE) #define USART2 ((USART_TypeDef *) USART2_BASE) #define USART3 ((USART_TypeDef *) USART3_BASE) #define UART4 ((USART_TypeDef *) UART4_BASE) #define UART5 ((USART_TypeDef *) UART5_BASE) #define I2C1 ((I2C_TypeDef *) I2C1_BASE) #define I2C2 ((I2C_TypeDef *) I2C2_BASE) #define I2C3 ((I2C_TypeDef *) I2C3_BASE) #define CAN1 ((CAN_TypeDef *) CAN1_BASE) #define CAN2 ((CAN_TypeDef *) CAN2_BASE) #define PWR ((PWR_TypeDef *) PWR_BASE) #define DAC1 ((DAC_TypeDef *) DAC_BASE) #define DAC ((DAC_TypeDef *) DAC_BASE) /* Kept for legacy purpose */ #define TIM1 ((TIM_TypeDef *) TIM1_BASE) #define TIM8 ((TIM_TypeDef *) TIM8_BASE) #define USART1 ((USART_TypeDef *) USART1_BASE) #define USART6 ((USART_TypeDef *) USART6_BASE) #define ADC1 ((ADC_TypeDef *) ADC1_BASE) #define ADC2 ((ADC_TypeDef *) ADC2_BASE) #define ADC3 ((ADC_TypeDef *) ADC3_BASE) #define ADC123_COMMON ((ADC_Common_TypeDef *) ADC123_COMMON_BASE) /* Legacy define */ #define ADC ADC123_COMMON #define SDIO ((SDIO_TypeDef *) SDIO_BASE) #define SPI1 ((SPI_TypeDef *) SPI1_BASE) #define SYSCFG ((SYSCFG_TypeDef *) SYSCFG_BASE) #define EXTI ((EXTI_TypeDef *) EXTI_BASE) #define TIM9 ((TIM_TypeDef *) TIM9_BASE) #define TIM10 ((TIM_TypeDef *) TIM10_BASE) #define TIM11 ((TIM_TypeDef *) TIM11_BASE) #define GPIOA ((GPIO_TypeDef *) GPIOA_BASE) #define GPIOB ((GPIO_TypeDef *) GPIOB_BASE) #define GPIOC ((GPIO_TypeDef *) GPIOC_BASE) #define GPIOD ((GPIO_TypeDef *) GPIOD_BASE) #define GPIOE ((GPIO_TypeDef *) GPIOE_BASE) #define GPIOF ((GPIO_TypeDef *) GPIOF_BASE) #define GPIOG ((GPIO_TypeDef *) GPIOG_BASE) #define GPIOH ((GPIO_TypeDef *) GPIOH_BASE) #define GPIOI ((GPIO_TypeDef *) GPIOI_BASE) #define CRC ((CRC_TypeDef *) CRC_BASE) #define RCC ((RCC_TypeDef *) RCC_BASE) #define FLASH ((FLASH_TypeDef *) FLASH_R_BASE) #define DMA1 ((DMA_TypeDef *) DMA1_BASE) #define DMA1_Stream0 ((DMA_Stream_TypeDef *) DMA1_Stream0_BASE) #define DMA1_Stream1 ((DMA_Stream_TypeDef *) DMA1_Stream1_BASE) #define DMA1_Stream2 ((DMA_Stream_TypeDef *) DMA1_Stream2_BASE) #define DMA1_Stream3 ((DMA_Stream_TypeDef *) DMA1_Stream3_BASE) #define DMA1_Stream4 ((DMA_Stream_TypeDef *) DMA1_Stream4_BASE) #define DMA1_Stream5 ((DMA_Stream_TypeDef *) DMA1_Stream5_BASE) #define DMA1_Stream6 ((DMA_Stream_TypeDef *) DMA1_Stream6_BASE) #define DMA1_Stream7 ((DMA_Stream_TypeDef *) DMA1_Stream7_BASE) #define DMA2 ((DMA_TypeDef *) DMA2_BASE) #define DMA2_Stream0 ((DMA_Stream_TypeDef *) DMA2_Stream0_BASE) #define DMA2_Stream1 ((DMA_Stream_TypeDef *) DMA2_Stream1_BASE) #define DMA2_Stream2 ((DMA_Stream_TypeDef *) DMA2_Stream2_BASE) #define DMA2_Stream3 ((DMA_Stream_TypeDef *) DMA2_Stream3_BASE) #define DMA2_Stream4 ((DMA_Stream_TypeDef *) DMA2_Stream4_BASE) #define DMA2_Stream5 ((DMA_Stream_TypeDef *) DMA2_Stream5_BASE) #define DMA2_Stream6 ((DMA_Stream_TypeDef *) DMA2_Stream6_BASE) #define DMA2_Stream7 ((DMA_Stream_TypeDef *) DMA2_Stream7_BASE) #define RNG ((RNG_TypeDef *) RNG_BASE) #define FSMC_Bank1 ((FSMC_Bank1_TypeDef *) FSMC_Bank1_R_BASE) #define FSMC_Bank1E ((FSMC_Bank1E_TypeDef *) FSMC_Bank1E_R_BASE) #define FSMC_Bank2_3 ((FSMC_Bank2_3_TypeDef *) FSMC_Bank2_3_R_BASE) #define FSMC_Bank4 ((FSMC_Bank4_TypeDef *) FSMC_Bank4_R_BASE) #define DBGMCU ((DBGMCU_TypeDef *) DBGMCU_BASE) #define USB_OTG_FS ((USB_OTG_GlobalTypeDef *) USB_OTG_FS_PERIPH_BASE) #define USB_OTG_HS ((USB_OTG_GlobalTypeDef *) USB_OTG_HS_PERIPH_BASE) /** * @} */ /** @addtogroup Exported_constants * @{ */ /** @addtogroup Peripheral_Registers_Bits_Definition * @{ */ /******************************************************************************/ /* Peripheral Registers_Bits_Definition */ /******************************************************************************/ /******************************************************************************/ /* */ /* Analog to Digital Converter */ /* */ /******************************************************************************/ /* * @brief Specific device feature definitions (not present on all devices in the STM32F4 serie) */ #define ADC_MULTIMODE_SUPPORT /*!
© COPYRIGHT(c) 2017 STMicroelectronics
* * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. Neither the name of STMicroelectronics nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ /** @addtogroup CMSIS_Device * @{ */ /** @addtogroup stm32f407xx * @{ */ #ifndef __STM32F407xx_H #define __STM32F407xx_H #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ /** @addtogroup Configuration_section_for_CMSIS * @{ */ /** * @brief Configuration of the Cortex-M4 Processor and Core Peripherals */ #define __CM4_REV 0x0001U /*!< Core revision r0p1 */ #define __MPU_PRESENT 1U /*!< STM32F4XX provides an MPU */ #define __NVIC_PRIO_BITS 4U /*!< STM32F4XX uses 4 Bits for the Priority Levels */ #define __Vendor_SysTickConfig 0U /*!< Set to 1 if different SysTick Config is used */ #define __FPU_PRESENT 1U /*!< FPU present */ /** * @} */ /** @addtogroup Peripheral_interrupt_number_definition * @{ */ /** * @brief STM32F4XX Interrupt Number Definition, according to the selected device * in @ref Library_configuration_section */ typedef enum { /****** Cortex-M4 Processor Exceptions Numbers ****************************************************************/ NonMaskableInt_IRQn = -14, /*!< 2 Non Maskable Interrupt */ MemoryManagement_IRQn = -12, /*!< 4 Cortex-M4 Memory Management Interrupt */ BusFault_IRQn = -11, /*!< 5 Cortex-M4 Bus Fault Interrupt */ UsageFault_IRQn = -10, /*!< 6 Cortex-M4 Usage Fault Interrupt */ SVCall_IRQn = -5, /*!< 11 Cortex-M4 SV Call Interrupt */ DebugMonitor_IRQn = -4, /*!< 12 Cortex-M4 Debug Monitor Interrupt */ PendSV_IRQn = -2, /*!< 14 Cortex-M4 Pend SV Interrupt */ SysTick_IRQn = -1, /*!< 15 Cortex-M4 System Tick Interrupt */ /****** STM32 specific Interrupt Numbers **********************************************************************/ WWDG_IRQn = 0, /*!< Window WatchDog Interrupt */ PVD_IRQn = 1, /*!< PVD through EXTI Line detection Interrupt */ TAMP_STAMP_IRQn = 2, /*!< Tamper and TimeStamp interrupts through the EXTI line */ RTC_WKUP_IRQn = 3, /*!< RTC Wakeup interrupt through the EXTI line */ FLASH_IRQn = 4, /*!< FLASH global Interrupt */ RCC_IRQn = 5, /*!< RCC global Interrupt */ EXTI0_IRQn = 6, /*!< EXTI Line0 Interrupt */ EXTI1_IRQn = 7, /*!< EXTI Line1 Interrupt */ EXTI2_IRQn = 8, /*!< EXTI Line2 Interrupt */ EXTI3_IRQn = 9, /*!< EXTI Line3 Interrupt */ EXTI4_IRQn = 10, /*!< EXTI Line4 Interrupt */ DMA1_Stream0_IRQn = 11, /*!< DMA1 Stream 0 global Interrupt */ DMA1_Stream1_IRQn = 12, /*!< DMA1 Stream 1 global Interrupt */ DMA1_Stream2_IRQn = 13, /*!< DMA1 Stream 2 global Interrupt */ DMA1_Stream3_IRQn = 14, /*!< DMA1 Stream 3 global Interrupt */ DMA1_Stream4_IRQn = 15, /*!< DMA1 Stream 4 global Interrupt */ DMA1_Stream5_IRQn = 16, /*!< DMA1 Stream 5 global Interrupt */ DMA1_Stream6_IRQn = 17, /*!< DMA1 Stream 6 global Interrupt */ ADC_IRQn = 18, /*!< ADC1, ADC2 and ADC3 global Interrupts */ CAN1_TX_IRQn = 19, /*!< CAN1 TX Interrupt */ CAN1_RX0_IRQn = 20, /*!< CAN1 RX0 Interrupt */ CAN1_RX1_IRQn = 21, /*!< CAN1 RX1 Interrupt */ CAN1_SCE_IRQn = 22, /*!< CAN1 SCE Interrupt */ EXTI9_5_IRQn = 23, /*!< External Line[9:5] Interrupts */ TIM1_BRK_TIM9_IRQn = 24, /*!< TIM1 Break interrupt and TIM9 global interrupt */ TIM1_UP_TIM10_IRQn = 25, /*!< TIM1 Update Interrupt and TIM10 global interrupt */ TIM1_TRG_COM_TIM11_IRQn = 26, /*!< TIM1 Trigger and Commutation Interrupt and TIM11 global interrupt */ TIM1_CC_IRQn = 27, /*!< TIM1 Capture Compare Interrupt */ TIM2_IRQn = 28, /*!< TIM2 global Interrupt */ TIM3_IRQn = 29, /*!< TIM3 global Interrupt */ TIM4_IRQn = 30, /*!< TIM4 global Interrupt */ I2C1_EV_IRQn = 31, /*!< I2C1 Event Interrupt */ I2C1_ER_IRQn = 32, /*!< I2C1 Error Interrupt */ I2C2_EV_IRQn = 33, /*!< I2C2 Event Interrupt */ I2C2_ER_IRQn = 34, /*!< I2C2 Error Interrupt */ SPI1_IRQn = 35, /*!< SPI1 global Interrupt */ SPI2_IRQn = 36, /*!< SPI2 global Interrupt */ USART1_IRQn = 37, /*!< USART1 global Interrupt */ USART2_IRQn = 38, /*!< USART2 global Interrupt */ USART3_IRQn = 39, /*!< USART3 global Interrupt */ EXTI15_10_IRQn = 40, /*!< External Line[15:10] Interrupts */ RTC_Alarm_IRQn = 41, /*!< RTC Alarm (A and B) through EXTI Line Interrupt */ OTG_FS_WKUP_IRQn = 42, /*!< USB OTG FS Wakeup through EXTI line interrupt */ TIM8_BRK_TIM12_IRQn = 43, /*!< TIM8 Break Interrupt and TIM12 global interrupt */ TIM8_UP_TIM13_IRQn = 44, /*!< TIM8 Update Interrupt and TIM13 global interrupt */ TIM8_TRG_COM_TIM14_IRQn = 45, /*!< TIM8 Trigger and Commutation Interrupt and TIM14 global interrupt */ TIM8_CC_IRQn = 46, /*!< TIM8 Capture Compare global interrupt */ DMA1_Stream7_IRQn = 47, /*!< DMA1 Stream7 Interrupt */ FSMC_IRQn = 48, /*!< FSMC global Interrupt */ SDIO_IRQn = 49, /*!< SDIO global Interrupt */ TIM5_IRQn = 50, /*!< TIM5 global Interrupt */ SPI3_IRQn = 51, /*!< SPI3 global Interrupt */ UART4_IRQn = 52, /*!< UART4 global Interrupt */ UART5_IRQn = 53, /*!< UART5 global Interrupt */ TIM6_DAC_IRQn = 54, /*!< TIM6 global and DAC1&2 underrun error interrupts */ TIM7_IRQn = 55, /*!< TIM7 global interrupt */ DMA2_Stream0_IRQn = 56, /*!< DMA2 Stream 0 global Interrupt */ DMA2_Stream1_IRQn = 57, /*!< DMA2 Stream 1 global Interrupt */ DMA2_Stream2_IRQn = 58, /*!< DMA2 Stream 2 global Interrupt */ DMA2_Stream3_IRQn = 59, /*!< DMA2 Stream 3 global Interrupt */ DMA2_Stream4_IRQn = 60, /*!< DMA2 Stream 4 global Interrupt */ ETH_IRQn = 61, /*!< Ethernet global Interrupt */ ETH_WKUP_IRQn = 62, /*!< Ethernet Wakeup through EXTI line Interrupt */ CAN2_TX_IRQn = 63, /*!< CAN2 TX Interrupt */ CAN2_RX0_IRQn = 64, /*!< CAN2 RX0 Interrupt */ CAN2_RX1_IRQn = 65, /*!< CAN2 RX1 Interrupt */ CAN2_SCE_IRQn = 66, /*!< CAN2 SCE Interrupt */ OTG_FS_IRQn = 67, /*!< USB OTG FS global Interrupt */ DMA2_Stream5_IRQn = 68, /*!< DMA2 Stream 5 global interrupt */ DMA2_Stream6_IRQn = 69, /*!< DMA2 Stream 6 global interrupt */ DMA2_Stream7_IRQn = 70, /*!< DMA2 Stream 7 global interrupt */ USART6_IRQn = 71, /*!< USART6 global interrupt */ I2C3_EV_IRQn = 72, /*!< I2C3 event interrupt */ I2C3_ER_IRQn = 73, /*!< I2C3 error interrupt */ OTG_HS_EP1_OUT_IRQn = 74, /*!< USB OTG HS End Point 1 Out global interrupt */ OTG_HS_EP1_IN_IRQn = 75, /*!< USB OTG HS End Point 1 In global interrupt */ OTG_HS_WKUP_IRQn = 76, /*!< USB OTG HS Wakeup through EXTI interrupt */ OTG_HS_IRQn = 77, /*!< USB OTG HS global interrupt */ DCMI_IRQn = 78, /*!< DCMI global interrupt */ HASH_RNG_IRQn = 80, /*!< Hash and Rng global interrupt */ FPU_IRQn = 81 /*!< FPU global interrupt */ } IRQn_Type; /** * @} */ #include "core_cm4.h" /* Cortex-M4 processor and core peripherals */ #include "system_stm32f4xx.h" #include /** @addtogroup Peripheral_registers_structures * @{ */ /** * @brief Analog to Digital Converter */ typedef struct { __IO uint32_t SR; /*!< ADC status register, Address offset: 0x00 */ __IO uint32_t CR1; /*!< ADC control register 1, Address offset: 0x04 */ __IO uint32_t CR2; /*!< ADC control register 2, Address offset: 0x08 */ __IO uint32_t SMPR1; /*!< ADC sample time register 1, Address offset: 0x0C */ __IO uint32_t SMPR2; /*!< ADC sample time register 2, Address offset: 0x10 */ __IO uint32_t JOFR1; /*!< ADC injected channel data offset register 1, Address offset: 0x14 */ __IO uint32_t JOFR2; /*!< ADC injected channel data offset register 2, Address offset: 0x18 */ __IO uint32_t JOFR3; /*!< ADC injected channel data offset register 3, Address offset: 0x1C */ __IO uint32_t JOFR4; /*!< ADC injected channel data offset register 4, Address offset: 0x20 */ __IO uint32_t HTR; /*!< ADC watchdog higher threshold register, Address offset: 0x24 */ __IO uint32_t LTR; /*!< ADC watchdog lower threshold register, Address offset: 0x28 */ __IO uint32_t SQR1; /*!< ADC regular sequence register 1, Address offset: 0x2C */ __IO uint32_t SQR2; /*!< ADC regular sequence register 2, Address offset: 0x30 */ __IO uint32_t SQR3; /*!< ADC regular sequence register 3, Address offset: 0x34 */ __IO uint32_t JSQR; /*!< ADC injected sequence register, Address offset: 0x38*/ __IO uint32_t JDR1; /*!< ADC injected data register 1, Address offset: 0x3C */ __IO uint32_t JDR2; /*!< ADC injected data register 2, Address offset: 0x40 */ __IO uint32_t JDR3; /*!< ADC injected data register 3, Address offset: 0x44 */ __IO uint32_t JDR4; /*!< ADC injected data register 4, Address offset: 0x48 */ __IO uint32_t DR; /*!< ADC regular data register, Address offset: 0x4C */ } ADC_TypeDef; typedef struct { __IO uint32_t CSR; /*!< ADC Common status register, Address offset: ADC1 base address + 0x300 */ __IO uint32_t CCR; /*!< ADC common control register, Address offset: ADC1 base address + 0x304 */ __IO uint32_t CDR; /*!< ADC common regular data register for dual AND triple modes, Address offset: ADC1 base address + 0x308 */ } ADC_Common_TypeDef; /** * @brief Controller Area Network TxMailBox */ typedef struct { __IO uint32_t TIR; /*!< CAN TX mailbox identifier register */ __IO uint32_t TDTR; /*!< CAN mailbox data length control and time stamp register */ __IO uint32_t TDLR; /*!< CAN mailbox data low register */ __IO uint32_t TDHR; /*!< CAN mailbox data high register */ } CAN_TxMailBox_TypeDef; /** * @brief Controller Area Network FIFOMailBox */ typedef struct { __IO uint32_t RIR; /*!< CAN receive FIFO mailbox identifier register */ __IO uint32_t RDTR; /*!< CAN receive FIFO mailbox data length control and time stamp register */ __IO uint32_t RDLR; /*!< CAN receive FIFO mailbox data low register */ __IO uint32_t RDHR; /*!< CAN receive FIFO mailbox data high register */ } CAN_FIFOMailBox_TypeDef; /** * @brief Controller Area Network FilterRegister */ typedef struct { __IO uint32_t FR1; /*!< CAN Filter bank register 1 */ __IO uint32_t FR2; /*!< CAN Filter bank register 1 */ } CAN_FilterRegister_TypeDef; /** * @brief Controller Area Network */ typedef struct { __IO uint32_t MCR; /*!< CAN master control register, Address offset: 0x00 */ __IO uint32_t MSR; /*!< CAN master status register, Address offset: 0x04 */ __IO uint32_t TSR; /*!< CAN transmit status register, Address offset: 0x08 */ __IO uint32_t RF0R; /*!< CAN receive FIFO 0 register, Address offset: 0x0C */ __IO uint32_t RF1R; /*!< CAN receive FIFO 1 register, Address offset: 0x10 */ __IO uint32_t IER; /*!< CAN interrupt enable register, Address offset: 0x14 */ __IO uint32_t ESR; /*!< CAN error status register, Address offset: 0x18 */ __IO uint32_t BTR; /*!< CAN bit timing register, Address offset: 0x1C */ uint32_t RESERVED0[88]; /*!< Reserved, 0x020 - 0x17F */ CAN_TxMailBox_TypeDef sTxMailBox[3]; /*!< CAN Tx MailBox, Address offset: 0x180 - 0x1AC */ CAN_FIFOMailBox_TypeDef sFIFOMailBox[2]; /*!< CAN FIFO MailBox, Address offset: 0x1B0 - 0x1CC */ uint32_t RESERVED1[12]; /*!< Reserved, 0x1D0 - 0x1FF */ __IO uint32_t FMR; /*!< CAN filter master register, Address offset: 0x200 */ __IO uint32_t FM1R; /*!< CAN filter mode register, Address offset: 0x204 */ uint32_t RESERVED2; /*!< Reserved, 0x208 */ __IO uint32_t FS1R; /*!< CAN filter scale register, Address offset: 0x20C */ uint32_t RESERVED3; /*!< Reserved, 0x210 */ __IO uint32_t FFA1R; /*!< CAN filter FIFO assignment register, Address offset: 0x214 */ uint32_t RESERVED4; /*!< Reserved, 0x218 */ __IO uint32_t FA1R; /*!< CAN filter activation register, Address offset: 0x21C */ uint32_t RESERVED5[8]; /*!< Reserved, 0x220-0x23F */ CAN_FilterRegister_TypeDef sFilterRegister[28]; /*!< CAN Filter Register, Address offset: 0x240-0x31C */ } CAN_TypeDef; /** * @brief CRC calculation unit */ typedef struct { __IO uint32_t DR; /*!< CRC Data register, Address offset: 0x00 */ __IO uint8_t IDR; /*!< CRC Independent data register, Address offset: 0x04 */ uint8_t RESERVED0; /*!< Reserved, 0x05 */ uint16_t RESERVED1; /*!< Reserved, 0x06 */ __IO uint32_t CR; /*!< CRC Control register, Address offset: 0x08 */ } CRC_TypeDef; /** * @brief Digital to Analog Converter */ typedef struct { __IO uint32_t CR; /*!< DAC control register, Address offset: 0x00 */ __IO uint32_t SWTRIGR; /*!< DAC software trigger register, Address offset: 0x04 */ __IO uint32_t DHR12R1; /*!< DAC channel1 12-bit right-aligned data holding register, Address offset: 0x08 */ __IO uint32_t DHR12L1; /*!< DAC channel1 12-bit left aligned data holding register, Address offset: 0x0C */ __IO uint32_t DHR8R1; /*!< DAC channel1 8-bit right aligned data holding register, Address offset: 0x10 */ __IO uint32_t DHR12R2; /*!< DAC channel2 12-bit right aligned data holding register, Address offset: 0x14 */ __IO uint32_t DHR12L2; /*!< DAC channel2 12-bit left aligned data holding register, Address offset: 0x18 */ __IO uint32_t DHR8R2; /*!< DAC channel2 8-bit right-aligned data holding register, Address offset: 0x1C */ __IO uint32_t DHR12RD; /*!< Dual DAC 12-bit right-aligned data holding register, Address offset: 0x20 */ __IO uint32_t DHR12LD; /*!< DUAL DAC 12-bit left aligned data holding register, Address offset: 0x24 */ __IO uint32_t DHR8RD; /*!< DUAL DAC 8-bit right aligned data holding register, Address offset: 0x28 */ __IO uint32_t DOR1; /*!< DAC channel1 data output register, Address offset: 0x2C */ __IO uint32_t DOR2; /*!< DAC channel2 data output register, Address offset: 0x30 */ __IO uint32_t SR; /*!< DAC status register, Address offset: 0x34 */ } DAC_TypeDef; /** * @brief Debug MCU */ typedef struct { __IO uint32_t IDCODE; /*!< MCU device ID code, Address offset: 0x00 */ __IO uint32_t CR; /*!< Debug MCU configuration register, Address offset: 0x04 */ __IO uint32_t APB1FZ; /*!< Debug MCU APB1 freeze register, Address offset: 0x08 */ __IO uint32_t APB2FZ; /*!< Debug MCU APB2 freeze register, Address offset: 0x0C */ }DBGMCU_TypeDef; /** * @brief DCMI */ typedef struct { __IO uint32_t CR; /*!< DCMI control register 1, Address offset: 0x00 */ __IO uint32_t SR; /*!< DCMI status register, Address offset: 0x04 */ __IO uint32_t RISR; /*!< DCMI raw interrupt status register, Address offset: 0x08 */ __IO uint32_t IER; /*!< DCMI interrupt enable register, Address offset: 0x0C */ __IO uint32_t MISR; /*!< DCMI masked interrupt status register, Address offset: 0x10 */ __IO uint32_t ICR; /*!< DCMI interrupt clear register, Address offset: 0x14 */ __IO uint32_t ESCR; /*!< DCMI embedded synchronization code register, Address offset: 0x18 */ __IO uint32_t ESUR; /*!< DCMI embedded synchronization unmask register, Address offset: 0x1C */ __IO uint32_t CWSTRTR; /*!< DCMI crop window start, Address offset: 0x20 */ __IO uint32_t CWSIZER; /*!< DCMI crop window size, Address offset: 0x24 */ __IO uint32_t DR; /*!< DCMI data register, Address offset: 0x28 */ } DCMI_TypeDef; /** * @brief DMA Controller */ typedef struct { __IO uint32_t CR; /*!< DMA stream x configuration register */ __IO uint32_t NDTR; /*!< DMA stream x number of data register */ __IO uint32_t PAR; /*!< DMA stream x peripheral address register */ __IO uint32_t M0AR; /*!< DMA stream x memory 0 address register */ __IO uint32_t M1AR; /*!< DMA stream x memory 1 address register */ __IO uint32_t FCR; /*!< DMA stream x FIFO control register */ } DMA_Stream_TypeDef; typedef struct { __IO uint32_t LISR; /*!< DMA low interrupt status register, Address offset: 0x00 */ __IO uint32_t HISR; /*!< DMA high interrupt status register, Address offset: 0x04 */ __IO uint32_t LIFCR; /*!< DMA low interrupt flag clear register, Address offset: 0x08 */ __IO uint32_t HIFCR; /*!< DMA high interrupt flag clear register, Address offset: 0x0C */ } DMA_TypeDef; /** * @brief Ethernet MAC */ typedef struct { __IO uint32_t MACCR; __IO uint32_t MACFFR; __IO uint32_t MACHTHR; __IO uint32_t MACHTLR; __IO uint32_t MACMIIAR; __IO uint32_t MACMIIDR; __IO uint32_t MACFCR; __IO uint32_t MACVLANTR; /* 8 */ uint32_t RESERVED0[2]; __IO uint32_t MACRWUFFR; /* 11 */ __IO uint32_t MACPMTCSR; uint32_t RESERVED1; __IO uint32_t MACDBGR; __IO uint32_t MACSR; /* 15 */ __IO uint32_t MACIMR; __IO uint32_t MACA0HR; __IO uint32_t MACA0LR; __IO uint32_t MACA1HR; __IO uint32_t MACA1LR; __IO uint32_t MACA2HR; __IO uint32_t MACA2LR; __IO uint32_t MACA3HR; __IO uint32_t MACA3LR; /* 24 */ uint32_t RESERVED2[40]; __IO uint32_t MMCCR; /* 65 */ __IO uint32_t MMCRIR; __IO uint32_t MMCTIR; __IO uint32_t MMCRIMR; __IO uint32_t MMCTIMR; /* 69 */ uint32_t RESERVED3[14]; __IO uint32_t MMCTGFSCCR; /* 84 */ __IO uint32_t MMCTGFMSCCR; uint32_t RESERVED4[5]; __IO uint32_t MMCTGFCR; uint32_t RESERVED5[10]; __IO uint32_t MMCRFCECR; __IO uint32_t MMCRFAECR; uint32_t RESERVED6[10]; __IO uint32_t MMCRGUFCR; uint32_t RESERVED7[334]; __IO uint32_t PTPTSCR; __IO uint32_t PTPSSIR; __IO uint32_t PTPTSHR; __IO uint32_t PTPTSLR; __IO uint32_t PTPTSHUR; __IO uint32_t PTPTSLUR; __IO uint32_t PTPTSAR; __IO uint32_t PTPTTHR; __IO uint32_t PTPTTLR; __IO uint32_t RESERVED8; __IO uint32_t PTPTSSR; uint32_t RESERVED9[565]; __IO uint32_t DMABMR; __IO uint32_t DMATPDR; __IO uint32_t DMARPDR; __IO uint32_t DMARDLAR; __IO uint32_t DMATDLAR; __IO uint32_t DMASR; __IO uint32_t DMAOMR; __IO uint32_t DMAIER; __IO uint32_t DMAMFBOCR; __IO uint32_t DMARSWTR; uint32_t RESERVED10[8]; __IO uint32_t DMACHTDR; __IO uint32_t DMACHRDR; __IO uint32_t DMACHTBAR; __IO uint32_t DMACHRBAR; } ETH_TypeDef; /** * @brief External Interrupt/Event Controller */ typedef struct { __IO uint32_t IMR; /*!< EXTI Interrupt mask register, Address offset: 0x00 */ __IO uint32_t EMR; /*!< EXTI Event mask register, Address offset: 0x04 */ __IO uint32_t RTSR; /*!< EXTI Rising trigger selection register, Address offset: 0x08 */ __IO uint32_t FTSR; /*!< EXTI Falling trigger selection register, Address offset: 0x0C */ __IO uint32_t SWIER; /*!< EXTI Software interrupt event register, Address offset: 0x10 */ __IO uint32_t PR; /*!< EXTI Pending register, Address offset: 0x14 */ } EXTI_TypeDef; /** * @brief FLASH Registers */ typedef struct { __IO uint32_t ACR; /*!< FLASH access control register, Address offset: 0x00 */ __IO uint32_t KEYR; /*!< FLASH key register, Address offset: 0x04 */ __IO uint32_t OPTKEYR; /*!< FLASH option key register, Address offset: 0x08 */ __IO uint32_t SR; /*!< FLASH status register, Address offset: 0x0C */ __IO uint32_t CR; /*!< FLASH control register, Address offset: 0x10 */ __IO uint32_t OPTCR; /*!< FLASH option control register , Address offset: 0x14 */ __IO uint32_t OPTCR1; /*!< FLASH option control register 1, Address offset: 0x18 */ } FLASH_TypeDef; /** * @brief Flexible Static Memory Controller */ typedef struct { __IO uint32_t BTCR[8]; /*!< NOR/PSRAM chip-select control register(BCR) and chip-select timing register(BTR), Address offset: 0x00-1C */ } FSMC_Bank1_TypeDef; /** * @brief Flexible Static Memory Controller Bank1E */ typedef struct { __IO uint32_t BWTR[7]; /*!< NOR/PSRAM write timing registers, Address offset: 0x104-0x11C */ } FSMC_Bank1E_TypeDef; /** * @brief Flexible Static Memory Controller Bank2 */ typedef struct { __IO uint32_t PCR2; /*!< NAND Flash control register 2, Address offset: 0x60 */ __IO uint32_t SR2; /*!< NAND Flash FIFO status and interrupt register 2, Address offset: 0x64 */ __IO uint32_t PMEM2; /*!< NAND Flash Common memory space timing register 2, Address offset: 0x68 */ __IO uint32_t PATT2; /*!< NAND Flash Attribute memory space timing register 2, Address offset: 0x6C */ uint32_t RESERVED0; /*!< Reserved, 0x70 */ __IO uint32_t ECCR2; /*!< NAND Flash ECC result registers 2, Address offset: 0x74 */ uint32_t RESERVED1; /*!< Reserved, 0x78 */ uint32_t RESERVED2; /*!< Reserved, 0x7C */ __IO uint32_t PCR3; /*!< NAND Flash control register 3, Address offset: 0x80 */ __IO uint32_t SR3; /*!< NAND Flash FIFO status and interrupt register 3, Address offset: 0x84 */ __IO uint32_t PMEM3; /*!< NAND Flash Common memory space timing register 3, Address offset: 0x88 */ __IO uint32_t PATT3; /*!< NAND Flash Attribute memory space timing register 3, Address offset: 0x8C */ uint32_t RESERVED3; /*!< Reserved, 0x90 */ __IO uint32_t ECCR3; /*!< NAND Flash ECC result registers 3, Address offset: 0x94 */ } FSMC_Bank2_3_TypeDef; /** * @brief Flexible Static Memory Controller Bank4 */ typedef struct { __IO uint32_t PCR4; /*!< PC Card control register 4, Address offset: 0xA0 */ __IO uint32_t SR4; /*!< PC Card FIFO status and interrupt register 4, Address offset: 0xA4 */ __IO uint32_t PMEM4; /*!< PC Card Common memory space timing register 4, Address offset: 0xA8 */ __IO uint32_t PATT4; /*!< PC Card Attribute memory space timing register 4, Address offset: 0xAC */ __IO uint32_t PIO4; /*!< PC Card I/O space timing register 4, Address offset: 0xB0 */ } FSMC_Bank4_TypeDef; /** * @brief General Purpose I/O */ typedef struct { __IO uint32_t MODER; /*!< GPIO port mode register, Address offset: 0x00 */ __IO uint32_t OTYPER; /*!< GPIO port output type register, Address offset: 0x04 */ __IO uint32_t OSPEEDR; /*!< GPIO port output speed register, Address offset: 0x08 */ __IO uint32_t PUPDR; /*!< GPIO port pull-up/pull-down register, Address offset: 0x0C */ __IO uint32_t IDR; /*!< GPIO port input data register, Address offset: 0x10 */ __IO uint32_t ODR; /*!< GPIO port output data register, Address offset: 0x14 */ __IO uint32_t BSRR; /*!< GPIO port bit set/reset register, Address offset: 0x18 */ __IO uint32_t LCKR; /*!< GPIO port configuration lock register, Address offset: 0x1C */ __IO uint32_t AFR[2]; /*!< GPIO alternate function registers, Address offset: 0x20-0x24 */ } GPIO_TypeDef; /** * @brief System configuration controller */ typedef struct { __IO uint32_t MEMRMP; /*!< SYSCFG memory remap register, Address offset: 0x00 */ __IO uint32_t PMC; /*!< SYSCFG peripheral mode configuration register, Address offset: 0x04 */ __IO uint32_t EXTICR[4]; /*!< SYSCFG external interrupt configuration registers, Address offset: 0x08-0x14 */ uint32_t RESERVED[2]; /*!< Reserved, 0x18-0x1C */ __IO uint32_t CMPCR; /*!< SYSCFG Compensation cell control register, Address offset: 0x20 */ } SYSCFG_TypeDef; /** * @brief Inter-integrated Circuit Interface */ typedef struct { __IO uint32_t CR1; /*!< I2C Control register 1, Address offset: 0x00 */ __IO uint32_t CR2; /*!< I2C Control register 2, Address offset: 0x04 */ __IO uint32_t OAR1; /*!< I2C Own address register 1, Address offset: 0x08 */ __IO uint32_t OAR2; /*!< I2C Own address register 2, Address offset: 0x0C */ __IO uint32_t DR; /*!< I2C Data register, Address offset: 0x10 */ __IO uint32_t SR1; /*!< I2C Status register 1, Address offset: 0x14 */ __IO uint32_t SR2; /*!< I2C Status register 2, Address offset: 0x18 */ __IO uint32_t CCR; /*!< I2C Clock control register, Address offset: 0x1C */ __IO uint32_t TRISE; /*!< I2C TRISE register, Address offset: 0x20 */ } I2C_TypeDef; /** * @brief Independent WATCHDOG */ typedef struct { __IO uint32_t KR; /*!< IWDG Key register, Address offset: 0x00 */ __IO uint32_t PR; /*!< IWDG Prescaler register, Address offset: 0x04 */ __IO uint32_t RLR; /*!< IWDG Reload register, Address offset: 0x08 */ __IO uint32_t SR; /*!< IWDG Status register, Address offset: 0x0C */ } IWDG_TypeDef; /** * @brief Power Control */ typedef struct { __IO uint32_t CR; /*!< PWR power control register, Address offset: 0x00 */ __IO uint32_t CSR; /*!< PWR power control/status register, Address offset: 0x04 */ } PWR_TypeDef; /** * @brief Reset and Clock Control */ typedef struct { __IO uint32_t CR; /*!< RCC clock control register, Address offset: 0x00 */ __IO uint32_t PLLCFGR; /*!< RCC PLL configuration register, Address offset: 0x04 */ __IO uint32_t CFGR; /*!< RCC clock configuration register, Address offset: 0x08 */ __IO uint32_t CIR; /*!< RCC clock interrupt register, Address offset: 0x0C */ __IO uint32_t AHB1RSTR; /*!< RCC AHB1 peripheral reset register, Address offset: 0x10 */ __IO uint32_t AHB2RSTR; /*!< RCC AHB2 peripheral reset register, Address offset: 0x14 */ __IO uint32_t AHB3RSTR; /*!< RCC AHB3 peripheral reset register, Address offset: 0x18 */ uint32_t RESERVED0; /*!< Reserved, 0x1C */ __IO uint32_t APB1RSTR; /*!< RCC APB1 peripheral reset register, Address offset: 0x20 */ __IO uint32_t APB2RSTR; /*!< RCC APB2 peripheral reset register, Address offset: 0x24 */ uint32_t RESERVED1[2]; /*!< Reserved, 0x28-0x2C */ __IO uint32_t AHB1ENR; /*!< RCC AHB1 peripheral clock register, Address offset: 0x30 */ __IO uint32_t AHB2ENR; /*!< RCC AHB2 peripheral clock register, Address offset: 0x34 */ __IO uint32_t AHB3ENR; /*!< RCC AHB3 peripheral clock register, Address offset: 0x38 */ uint32_t RESERVED2; /*!< Reserved, 0x3C */ __IO uint32_t APB1ENR; /*!< RCC APB1 peripheral clock enable register, Address offset: 0x40 */ __IO uint32_t APB2ENR; /*!< RCC APB2 peripheral clock enable register, Address offset: 0x44 */ uint32_t RESERVED3[2]; /*!< Reserved, 0x48-0x4C */ __IO uint32_t AHB1LPENR; /*!< RCC AHB1 peripheral clock enable in low power mode register, Address offset: 0x50 */ __IO uint32_t AHB2LPENR; /*!< RCC AHB2 peripheral clock enable in low power mode register, Address offset: 0x54 */ __IO uint32_t AHB3LPENR; /*!< RCC AHB3 peripheral clock enable in low power mode register, Address offset: 0x58 */ uint32_t RESERVED4; /*!< Reserved, 0x5C */ __IO uint32_t APB1LPENR; /*!< RCC APB1 peripheral clock enable in low power mode register, Address offset: 0x60 */ __IO uint32_t APB2LPENR; /*!< RCC APB2 peripheral clock enable in low power mode register, Address offset: 0x64 */ uint32_t RESERVED5[2]; /*!< Reserved, 0x68-0x6C */ __IO uint32_t BDCR; /*!< RCC Backup domain control register, Address offset: 0x70 */ __IO uint32_t CSR; /*!< RCC clock control & status register, Address offset: 0x74 */ uint32_t RESERVED6[2]; /*!< Reserved, 0x78-0x7C */ __IO uint32_t SSCGR; /*!< RCC spread spectrum clock generation register, Address offset: 0x80 */ __IO uint32_t PLLI2SCFGR; /*!< RCC PLLI2S configuration register, Address offset: 0x84 */ } RCC_TypeDef; /** * @brief Real-Time Clock */ typedef struct { __IO uint32_t TR; /*!< RTC time register, Address offset: 0x00 */ __IO uint32_t DR; /*!< RTC date register, Address offset: 0x04 */ __IO uint32_t CR; /*!< RTC control register, Address offset: 0x08 */ __IO uint32_t ISR; /*!< RTC initialization and status register, Address offset: 0x0C */ __IO uint32_t PRER; /*!< RTC prescaler register, Address offset: 0x10 */ __IO uint32_t WUTR; /*!< RTC wakeup timer register, Address offset: 0x14 */ __IO uint32_t CALIBR; /*!< RTC calibration register, Address offset: 0x18 */ __IO uint32_t ALRMAR; /*!< RTC alarm A register, Address offset: 0x1C */ __IO uint32_t ALRMBR; /*!< RTC alarm B register, Address offset: 0x20 */ __IO uint32_t WPR; /*!< RTC write protection register, Address offset: 0x24 */ __IO uint32_t SSR; /*!< RTC sub second register, Address offset: 0x28 */ __IO uint32_t SHIFTR; /*!< RTC shift control register, Address offset: 0x2C */ __IO uint32_t TSTR; /*!< RTC time stamp time register, Address offset: 0x30 */ __IO uint32_t TSDR; /*!< RTC time stamp date register, Address offset: 0x34 */ __IO uint32_t TSSSR; /*!< RTC time-stamp sub second register, Address offset: 0x38 */ __IO uint32_t CALR; /*!< RTC calibration register, Address offset: 0x3C */ __IO uint32_t TAFCR; /*!< RTC tamper and alternate function configuration register, Address offset: 0x40 */ __IO uint32_t ALRMASSR;/*!< RTC alarm A sub second register, Address offset: 0x44 */ __IO uint32_t ALRMBSSR;/*!< RTC alarm B sub second register, Address offset: 0x48 */ uint32_t RESERVED7; /*!< Reserved, 0x4C */ __IO uint32_t BKP0R; /*!< RTC backup register 1, Address offset: 0x50 */ __IO uint32_t BKP1R; /*!< RTC backup register 1, Address offset: 0x54 */ __IO uint32_t BKP2R; /*!< RTC backup register 2, Address offset: 0x58 */ __IO uint32_t BKP3R; /*!< RTC backup register 3, Address offset: 0x5C */ __IO uint32_t BKP4R; /*!< RTC backup register 4, Address offset: 0x60 */ __IO uint32_t BKP5R; /*!< RTC backup register 5, Address offset: 0x64 */ __IO uint32_t BKP6R; /*!< RTC backup register 6, Address offset: 0x68 */ __IO uint32_t BKP7R; /*!< RTC backup register 7, Address offset: 0x6C */ __IO uint32_t BKP8R; /*!< RTC backup register 8, Address offset: 0x70 */ __IO uint32_t BKP9R; /*!< RTC backup register 9, Address offset: 0x74 */ __IO uint32_t BKP10R; /*!< RTC backup register 10, Address offset: 0x78 */ __IO uint32_t BKP11R; /*!< RTC backup register 11, Address offset: 0x7C */ __IO uint32_t BKP12R; /*!< RTC backup register 12, Address offset: 0x80 */ __IO uint32_t BKP13R; /*!< RTC backup register 13, Address offset: 0x84 */ __IO uint32_t BKP14R; /*!< RTC backup register 14, Address offset: 0x88 */ __IO uint32_t BKP15R; /*!< RTC backup register 15, Address offset: 0x8C */ __IO uint32_t BKP16R; /*!< RTC backup register 16, Address offset: 0x90 */ __IO uint32_t BKP17R; /*!< RTC backup register 17, Address offset: 0x94 */ __IO uint32_t BKP18R; /*!< RTC backup register 18, Address offset: 0x98 */ __IO uint32_t BKP19R; /*!< RTC backup register 19, Address offset: 0x9C */ } RTC_TypeDef; /** * @brief SD host Interface */ typedef struct { __IO uint32_t POWER; /*!< SDIO power control register, Address offset: 0x00 */ __IO uint32_t CLKCR; /*!< SDI clock control register, Address offset: 0x04 */ __IO uint32_t ARG; /*!< SDIO argument register, Address offset: 0x08 */ __IO uint32_t CMD; /*!< SDIO command register, Address offset: 0x0C */ __IO const uint32_t RESPCMD; /*!< SDIO command response register, Address offset: 0x10 */ __IO const uint32_t RESP1; /*!< SDIO response 1 register, Address offset: 0x14 */ __IO const uint32_t RESP2; /*!< SDIO response 2 register, Address offset: 0x18 */ __IO const uint32_t RESP3; /*!< SDIO response 3 register, Address offset: 0x1C */ __IO const uint32_t RESP4; /*!< SDIO response 4 register, Address offset: 0x20 */ __IO uint32_t DTIMER; /*!< SDIO data timer register, Address offset: 0x24 */ __IO uint32_t DLEN; /*!< SDIO data length register, Address offset: 0x28 */ __IO uint32_t DCTRL; /*!< SDIO data control register, Address offset: 0x2C */ __IO const uint32_t DCOUNT; /*!< SDIO data counter register, Address offset: 0x30 */ __IO const uint32_t STA; /*!< SDIO status register, Address offset: 0x34 */ __IO uint32_t ICR; /*!< SDIO interrupt clear register, Address offset: 0x38 */ __IO uint32_t MASK; /*!< SDIO mask register, Address offset: 0x3C */ uint32_t RESERVED0[2]; /*!< Reserved, 0x40-0x44 */ __IO const uint32_t FIFOCNT; /*!< SDIO FIFO counter register, Address offset: 0x48 */ uint32_t RESERVED1[13]; /*!< Reserved, 0x4C-0x7C */ __IO uint32_t FIFO; /*!< SDIO data FIFO register, Address offset: 0x80 */ } SDIO_TypeDef; /** * @brief Serial Peripheral Interface */ typedef struct { __IO uint32_t CR1; /*!< SPI control register 1 (not used in I2S mode), Address offset: 0x00 */ __IO uint32_t CR2; /*!< SPI control register 2, Address offset: 0x04 */ __IO uint32_t SR; /*!< SPI status register, Address offset: 0x08 */ __IO uint32_t DR; /*!< SPI data register, Address offset: 0x0C */ __IO uint32_t CRCPR; /*!< SPI CRC polynomial register (not used in I2S mode), Address offset: 0x10 */ __IO uint32_t RXCRCR; /*!< SPI RX CRC register (not used in I2S mode), Address offset: 0x14 */ __IO uint32_t TXCRCR; /*!< SPI TX CRC register (not used in I2S mode), Address offset: 0x18 */ __IO uint32_t I2SCFGR; /*!< SPI_I2S configuration register, Address offset: 0x1C */ __IO uint32_t I2SPR; /*!< SPI_I2S prescaler register, Address offset: 0x20 */ } SPI_TypeDef; /** * @brief TIM */ typedef struct { __IO uint32_t CR1; /*!< TIM control register 1, Address offset: 0x00 */ __IO uint32_t CR2; /*!< TIM control register 2, Address offset: 0x04 */ __IO uint32_t SMCR; /*!< TIM slave mode control register, Address offset: 0x08 */ __IO uint32_t DIER; /*!< TIM DMA/interrupt enable register, Address offset: 0x0C */ __IO uint32_t SR; /*!< TIM status register, Address offset: 0x10 */ __IO uint32_t EGR; /*!< TIM event generation register, Address offset: 0x14 */ __IO uint32_t CCMR1; /*!< TIM capture/compare mode register 1, Address offset: 0x18 */ __IO uint32_t CCMR2; /*!< TIM capture/compare mode register 2, Address offset: 0x1C */ __IO uint32_t CCER; /*!< TIM capture/compare enable register, Address offset: 0x20 */ __IO uint32_t CNT; /*!< TIM counter register, Address offset: 0x24 */ __IO uint32_t PSC; /*!< TIM prescaler, Address offset: 0x28 */ __IO uint32_t ARR; /*!< TIM auto-reload register, Address offset: 0x2C */ __IO uint32_t RCR; /*!< TIM repetition counter register, Address offset: 0x30 */ __IO uint32_t CCR1; /*!< TIM capture/compare register 1, Address offset: 0x34 */ __IO uint32_t CCR2; /*!< TIM capture/compare register 2, Address offset: 0x38 */ __IO uint32_t CCR3; /*!< TIM capture/compare register 3, Address offset: 0x3C */ __IO uint32_t CCR4; /*!< TIM capture/compare register 4, Address offset: 0x40 */ __IO uint32_t BDTR; /*!< TIM break and dead-time register, Address offset: 0x44 */ __IO uint32_t DCR; /*!< TIM DMA control register, Address offset: 0x48 */ __IO uint32_t DMAR; /*!< TIM DMA address for full transfer, Address offset: 0x4C */ __IO uint32_t OR; /*!< TIM option register, Address offset: 0x50 */ } TIM_TypeDef; /** * @brief Universal Synchronous Asynchronous Receiver Transmitter */ typedef struct { __IO uint32_t SR; /*!< USART Status register, Address offset: 0x00 */ __IO uint32_t DR; /*!< USART Data register, Address offset: 0x04 */ __IO uint32_t BRR; /*!< USART Baud rate register, Address offset: 0x08 */ __IO uint32_t CR1; /*!< USART Control register 1, Address offset: 0x0C */ __IO uint32_t CR2; /*!< USART Control register 2, Address offset: 0x10 */ __IO uint32_t CR3; /*!< USART Control register 3, Address offset: 0x14 */ __IO uint32_t GTPR; /*!< USART Guard time and prescaler register, Address offset: 0x18 */ } USART_TypeDef; /** * @brief Window WATCHDOG */ typedef struct { __IO uint32_t CR; /*!< WWDG Control register, Address offset: 0x00 */ __IO uint32_t CFR; /*!< WWDG Configuration register, Address offset: 0x04 */ __IO uint32_t SR; /*!< WWDG Status register, Address offset: 0x08 */ } WWDG_TypeDef; /** * @brief RNG */ typedef struct { __IO uint32_t CR; /*!< RNG control register, Address offset: 0x00 */ __IO uint32_t SR; /*!< RNG status register, Address offset: 0x04 */ __IO uint32_t DR; /*!< RNG data register, Address offset: 0x08 */ } RNG_TypeDef; /** * @brief USB_OTG_Core_Registers */ typedef struct { __IO uint32_t GOTGCTL; /*!< USB_OTG Control and Status Register 000h */ __IO uint32_t GOTGINT; /*!< USB_OTG Interrupt Register 004h */ __IO uint32_t GAHBCFG; /*!< Core AHB Configuration Register 008h */ __IO uint32_t GUSBCFG; /*!< Core USB Configuration Register 00Ch */ __IO uint32_t GRSTCTL; /*!< Core Reset Register 010h */ __IO uint32_t GINTSTS; /*!< Core Interrupt Register 014h */ __IO uint32_t GINTMSK; /*!< Core Interrupt Mask Register 018h */ __IO uint32_t GRXSTSR; /*!< Receive Sts Q Read Register 01Ch */ __IO uint32_t GRXSTSP; /*!< Receive Sts Q Read & POP Register 020h */ __IO uint32_t GRXFSIZ; /*!< Receive FIFO Size Register 024h */ __IO uint32_t DIEPTXF0_HNPTXFSIZ; /*!< EP0 / Non Periodic Tx FIFO Size Register 028h */ __IO uint32_t HNPTXSTS; /*!< Non Periodic Tx FIFO/Queue Sts reg 02Ch */ uint32_t Reserved30[2]; /*!< Reserved 030h */ __IO uint32_t GCCFG; /*!< General Purpose IO Register 038h */ __IO uint32_t CID; /*!< User ID Register 03Ch */ uint32_t Reserved40[48]; /*!< Reserved 0x40-0xFF */ __IO uint32_t HPTXFSIZ; /*!< Host Periodic Tx FIFO Size Reg 100h */ __IO uint32_t DIEPTXF[0x0F]; /*!< dev Periodic Transmit FIFO */ } USB_OTG_GlobalTypeDef; /** * @brief USB_OTG_device_Registers */ typedef struct { __IO uint32_t DCFG; /*!< dev Configuration Register 800h */ __IO uint32_t DCTL; /*!< dev Control Register 804h */ __IO uint32_t DSTS; /*!< dev Status Register (RO) 808h */ uint32_t Reserved0C; /*!< Reserved 80Ch */ __IO uint32_t DIEPMSK; /*!< dev IN Endpoint Mask 810h */ __IO uint32_t DOEPMSK; /*!< dev OUT Endpoint Mask 814h */ __IO uint32_t DAINT; /*!< dev All Endpoints Itr Reg 818h */ __IO uint32_t DAINTMSK; /*!< dev All Endpoints Itr Mask 81Ch */ uint32_t Reserved20; /*!< Reserved 820h */ uint32_t Reserved9; /*!< Reserved 824h */ __IO uint32_t DVBUSDIS; /*!< dev VBUS discharge Register 828h */ __IO uint32_t DVBUSPULSE; /*!< dev VBUS Pulse Register 82Ch */ __IO uint32_t DTHRCTL; /*!< dev threshold 830h */ __IO uint32_t DIEPEMPMSK; /*!< dev empty msk 834h */ __IO uint32_t DEACHINT; /*!< dedicated EP interrupt 838h */ __IO uint32_t DEACHMSK; /*!< dedicated EP msk 83Ch */ uint32_t Reserved40; /*!< dedicated EP mask 840h */ __IO uint32_t DINEP1MSK; /*!< dedicated EP mask 844h */ uint32_t Reserved44[15]; /*!< Reserved 844-87Ch */ __IO uint32_t DOUTEP1MSK; /*!< dedicated EP msk 884h */ } USB_OTG_DeviceTypeDef; /** * @brief USB_OTG_IN_Endpoint-Specific_Register */ typedef struct { __IO uint32_t DIEPCTL; /*!< dev IN Endpoint Control Reg 900h + (ep_num * 20h) + 00h */ uint32_t Reserved04; /*!< Reserved 900h + (ep_num * 20h) + 04h */ __IO uint32_t DIEPINT; /*!< dev IN Endpoint Itr Reg 900h + (ep_num * 20h) + 08h */ uint32_t Reserved0C; /*!< Reserved 900h + (ep_num * 20h) + 0Ch */ __IO uint32_t DIEPTSIZ; /*!< IN Endpoint Txfer Size 900h + (ep_num * 20h) + 10h */ __IO uint32_t DIEPDMA; /*!< IN Endpoint DMA Address Reg 900h + (ep_num * 20h) + 14h */ __IO uint32_t DTXFSTS; /*!< IN Endpoint Tx FIFO Status Reg 900h + (ep_num * 20h) + 18h */ uint32_t Reserved18; /*!< Reserved 900h+(ep_num*20h)+1Ch-900h+ (ep_num * 20h) + 1Ch */ } USB_OTG_INEndpointTypeDef; /** * @brief USB_OTG_OUT_Endpoint-Specific_Registers */ typedef struct { __IO uint32_t DOEPCTL; /*!< dev OUT Endpoint Control Reg B00h + (ep_num * 20h) + 00h */ uint32_t Reserved04; /*!< Reserved B00h + (ep_num * 20h) + 04h */ __IO uint32_t DOEPINT; /*!< dev OUT Endpoint Itr Reg B00h + (ep_num * 20h) + 08h */ uint32_t Reserved0C; /*!< Reserved B00h + (ep_num * 20h) + 0Ch */ __IO uint32_t DOEPTSIZ; /*!< dev OUT Endpoint Txfer Size B00h + (ep_num * 20h) + 10h */ __IO uint32_t DOEPDMA; /*!< dev OUT Endpoint DMA Address B00h + (ep_num * 20h) + 14h */ uint32_t Reserved18[2]; /*!< Reserved B00h + (ep_num * 20h) + 18h - B00h + (ep_num * 20h) + 1Ch */ } USB_OTG_OUTEndpointTypeDef; /** * @brief USB_OTG_Host_Mode_Register_Structures */ typedef struct { __IO uint32_t HCFG; /*!< Host Configuration Register 400h */ __IO uint32_t HFIR; /*!< Host Frame Interval Register 404h */ __IO uint32_t HFNUM; /*!< Host Frame Nbr/Frame Remaining 408h */ uint32_t Reserved40C; /*!< Reserved 40Ch */ __IO uint32_t HPTXSTS; /*!< Host Periodic Tx FIFO/ Queue Status 410h */ __IO uint32_t HAINT; /*!< Host All Channels Interrupt Register 414h */ __IO uint32_t HAINTMSK; /*!< Host All Channels Interrupt Mask 418h */ } USB_OTG_HostTypeDef; /** * @brief USB_OTG_Host_Channel_Specific_Registers */ typedef struct { __IO uint32_t HCCHAR; /*!< Host Channel Characteristics Register 500h */ __IO uint32_t HCSPLT; /*!< Host Channel Split Control Register 504h */ __IO uint32_t HCINT; /*!< Host Channel Interrupt Register 508h */ __IO uint32_t HCINTMSK; /*!< Host Channel Interrupt Mask Register 50Ch */ __IO uint32_t HCTSIZ; /*!< Host Channel Transfer Size Register 510h */ __IO uint32_t HCDMA; /*!< Host Channel DMA Address Register 514h */ uint32_t Reserved[2]; /*!< Reserved */ } USB_OTG_HostChannelTypeDef; /** * @} */ /** @addtogroup Peripheral_memory_map * @{ */ #define FLASH_BASE 0x08000000U /*!< FLASH(up to 1 MB) base address in the alias region */ #define CCMDATARAM_BASE 0x10000000U /*!< CCM(core coupled memory) data RAM(64 KB) base address in the alias region */ #define SRAM1_BASE 0x20000000U /*!< SRAM1(112 KB) base address in the alias region */ #define SRAM2_BASE 0x2001C000U /*!< SRAM2(16 KB) base address in the alias region */ #define PERIPH_BASE 0x40000000U /*!< Peripheral base address in the alias region */ #define BKPSRAM_BASE 0x40024000U /*!< Backup SRAM(4 KB) base address in the alias region */ #define FSMC_R_BASE 0xA0000000U /*!< FSMC registers base address */ #define SRAM1_BB_BASE 0x22000000U /*!< SRAM1(112 KB) base address in the bit-band region */ #define SRAM2_BB_BASE 0x22380000U /*!< SRAM2(16 KB) base address in the bit-band region */ #define PERIPH_BB_BASE 0x42000000U /*!< Peripheral base address in the bit-band region */ #define BKPSRAM_BB_BASE 0x42480000U /*!< Backup SRAM(4 KB) base address in the bit-band region */ #define FLASH_END 0x080FFFFFU /*!< FLASH end address */ #define FLASH_OTP_BASE 0x1FFF7800U /*!< Base address of : (up to 528 Bytes) embedded FLASH OTP Area */ #define FLASH_OTP_END 0x1FFF7A0FU /*!< End address of : (up to 528 Bytes) embedded FLASH OTP Area */ #define CCMDATARAM_END 0x1000FFFFU /*!< CCM data RAM end address */ /* Legacy defines */ #define SRAM_BASE SRAM1_BASE #define SRAM_BB_BASE SRAM1_BB_BASE /*!< Peripheral memory map */ #define APB1PERIPH_BASE PERIPH_BASE #define APB2PERIPH_BASE (PERIPH_BASE + 0x00010000U) #define AHB1PERIPH_BASE (PERIPH_BASE + 0x00020000U) #define AHB2PERIPH_BASE (PERIPH_BASE + 0x10000000U) /*!< APB1 peripherals */ #define TIM2_BASE (APB1PERIPH_BASE + 0x0000U) #define TIM3_BASE (APB1PERIPH_BASE + 0x0400U) #define TIM4_BASE (APB1PERIPH_BASE + 0x0800U) #define TIM5_BASE (APB1PERIPH_BASE + 0x0C00U) #define TIM6_BASE (APB1PERIPH_BASE + 0x1000U) #define TIM7_BASE (APB1PERIPH_BASE + 0x1400U) #define TIM12_BASE (APB1PERIPH_BASE + 0x1800U) #define TIM13_BASE (APB1PERIPH_BASE + 0x1C00U) #define TIM14_BASE (APB1PERIPH_BASE + 0x2000U) #define RTC_BASE (APB1PERIPH_BASE + 0x2800U) #define WWDG_BASE (APB1PERIPH_BASE + 0x2C00U) #define IWDG_BASE (APB1PERIPH_BASE + 0x3000U) #define I2S2ext_BASE (APB1PERIPH_BASE + 0x3400U) #define SPI2_BASE (APB1PERIPH_BASE + 0x3800U) #define SPI3_BASE (APB1PERIPH_BASE + 0x3C00U) #define I2S3ext_BASE (APB1PERIPH_BASE + 0x4000U) #define USART2_BASE (APB1PERIPH_BASE + 0x4400U) #define USART3_BASE (APB1PERIPH_BASE + 0x4800U) #define UART4_BASE (APB1PERIPH_BASE + 0x4C00U) #define UART5_BASE (APB1PERIPH_BASE + 0x5000U) #define I2C1_BASE (APB1PERIPH_BASE + 0x5400U) #define I2C2_BASE (APB1PERIPH_BASE + 0x5800U) #define I2C3_BASE (APB1PERIPH_BASE + 0x5C00U) #define CAN1_BASE (APB1PERIPH_BASE + 0x6400U) #define CAN2_BASE (APB1PERIPH_BASE + 0x6800U) #define PWR_BASE (APB1PERIPH_BASE + 0x7000U) #define DAC_BASE (APB1PERIPH_BASE + 0x7400U) /*!< APB2 peripherals */ #define TIM1_BASE (APB2PERIPH_BASE + 0x0000U) #define TIM8_BASE (APB2PERIPH_BASE + 0x0400U) #define USART1_BASE (APB2PERIPH_BASE + 0x1000U) #define USART6_BASE (APB2PERIPH_BASE + 0x1400U) #define ADC1_BASE (APB2PERIPH_BASE + 0x2000U) #define ADC2_BASE (APB2PERIPH_BASE + 0x2100U) #define ADC3_BASE (APB2PERIPH_BASE + 0x2200U) #define ADC123_COMMON_BASE (APB2PERIPH_BASE + 0x2300U) /* Legacy define */ #define ADC_BASE ADC123_COMMON_BASE #define SDIO_BASE (APB2PERIPH_BASE + 0x2C00U) #define SPI1_BASE (APB2PERIPH_BASE + 0x3000U) #define SYSCFG_BASE (APB2PERIPH_BASE + 0x3800U) #define EXTI_BASE (APB2PERIPH_BASE + 0x3C00U) #define TIM9_BASE (APB2PERIPH_BASE + 0x4000U) #define TIM10_BASE (APB2PERIPH_BASE + 0x4400U) #define TIM11_BASE (APB2PERIPH_BASE + 0x4800U) /*!< AHB1 peripherals */ #define GPIOA_BASE (AHB1PERIPH_BASE + 0x0000U) #define GPIOB_BASE (AHB1PERIPH_BASE + 0x0400U) #define GPIOC_BASE (AHB1PERIPH_BASE + 0x0800U) #define GPIOD_BASE (AHB1PERIPH_BASE + 0x0C00U) #define GPIOE_BASE (AHB1PERIPH_BASE + 0x1000U) #define GPIOF_BASE (AHB1PERIPH_BASE + 0x1400U) #define GPIOG_BASE (AHB1PERIPH_BASE + 0x1800U) #define GPIOH_BASE (AHB1PERIPH_BASE + 0x1C00U) #define GPIOI_BASE (AHB1PERIPH_BASE + 0x2000U) #define CRC_BASE (AHB1PERIPH_BASE + 0x3000U) #define RCC_BASE (AHB1PERIPH_BASE + 0x3800U) #define FLASH_R_BASE (AHB1PERIPH_BASE + 0x3C00U) #define DMA1_BASE (AHB1PERIPH_BASE + 0x6000U) #define DMA1_Stream0_BASE (DMA1_BASE + 0x010U) #define DMA1_Stream1_BASE (DMA1_BASE + 0x028U) #define DMA1_Stream2_BASE (DMA1_BASE + 0x040U) #define DMA1_Stream3_BASE (DMA1_BASE + 0x058U) #define DMA1_Stream4_BASE (DMA1_BASE + 0x070U) #define DMA1_Stream5_BASE (DMA1_BASE + 0x088U) #define DMA1_Stream6_BASE (DMA1_BASE + 0x0A0U) #define DMA1_Stream7_BASE (DMA1_BASE + 0x0B8U) #define DMA2_BASE (AHB1PERIPH_BASE + 0x6400U) #define DMA2_Stream0_BASE (DMA2_BASE + 0x010U) #define DMA2_Stream1_BASE (DMA2_BASE + 0x028U) #define DMA2_Stream2_BASE (DMA2_BASE + 0x040U) #define DMA2_Stream3_BASE (DMA2_BASE + 0x058U) #define DMA2_Stream4_BASE (DMA2_BASE + 0x070U) #define DMA2_Stream5_BASE (DMA2_BASE + 0x088U) #define DMA2_Stream6_BASE (DMA2_BASE + 0x0A0U) #define DMA2_Stream7_BASE (DMA2_BASE + 0x0B8U) #define ETH_BASE (AHB1PERIPH_BASE + 0x8000U) #define ETH_MAC_BASE (ETH_BASE) #define ETH_MMC_BASE (ETH_BASE + 0x0100U) #define ETH_PTP_BASE (ETH_BASE + 0x0700U) #define ETH_DMA_BASE (ETH_BASE + 0x1000U) /*!< AHB2 peripherals */ #define DCMI_BASE (AHB2PERIPH_BASE + 0x50000U) #define RNG_BASE (AHB2PERIPH_BASE + 0x60800U) /*!< FSMC Bankx registers base address */ #define FSMC_Bank1_R_BASE (FSMC_R_BASE + 0x0000U) #define FSMC_Bank1E_R_BASE (FSMC_R_BASE + 0x0104U) #define FSMC_Bank2_3_R_BASE (FSMC_R_BASE + 0x0060U) #define FSMC_Bank4_R_BASE (FSMC_R_BASE + 0x00A0U) /*!< Debug MCU registers base address */ #define DBGMCU_BASE 0xE0042000U /*!< USB registers base address */ #define USB_OTG_HS_PERIPH_BASE 0x40040000U #define USB_OTG_FS_PERIPH_BASE 0x50000000U #define USB_OTG_GLOBAL_BASE 0x000U #define USB_OTG_DEVICE_BASE 0x800U #define USB_OTG_IN_ENDPOINT_BASE 0x900U #define USB_OTG_OUT_ENDPOINT_BASE 0xB00U #define USB_OTG_EP_REG_SIZE 0x20U #define USB_OTG_HOST_BASE 0x400U #define USB_OTG_HOST_PORT_BASE 0x440U #define USB_OTG_HOST_CHANNEL_BASE 0x500U #define USB_OTG_HOST_CHANNEL_SIZE 0x20U #define USB_OTG_PCGCCTL_BASE 0xE00U #define USB_OTG_FIFO_BASE 0x1000U #define USB_OTG_FIFO_SIZE 0x1000U #define UID_BASE 0x1FFF7A10U /*!< Unique device ID register base address */ #define FLASHSIZE_BASE 0x1FFF7A22U /*!< FLASH Size register base address */ #define PACKAGE_BASE 0x1FFF7BF0U /*!< Package size register base address */ /** * @} */ /** @addtogroup Peripheral_declaration * @{ */ #define TIM2 ((TIM_TypeDef *) TIM2_BASE) #define TIM3 ((TIM_TypeDef *) TIM3_BASE) #define TIM4 ((TIM_TypeDef *) TIM4_BASE) #define TIM5 ((TIM_TypeDef *) TIM5_BASE) #define TIM6 ((TIM_TypeDef *) TIM6_BASE) #define TIM7 ((TIM_TypeDef *) TIM7_BASE) #define TIM12 ((TIM_TypeDef *) TIM12_BASE) #define TIM13 ((TIM_TypeDef *) TIM13_BASE) #define TIM14 ((TIM_TypeDef *) TIM14_BASE) #define RTC ((RTC_TypeDef *) RTC_BASE) #define WWDG ((WWDG_TypeDef *) WWDG_BASE) #define IWDG ((IWDG_TypeDef *) IWDG_BASE) #define I2S2ext ((SPI_TypeDef *) I2S2ext_BASE) #define SPI2 ((SPI_TypeDef *) SPI2_BASE) #define SPI3 ((SPI_TypeDef *) SPI3_BASE) #define I2S3ext ((SPI_TypeDef *) I2S3ext_BASE) #define USART2 ((USART_TypeDef *) USART2_BASE) #define USART3 ((USART_TypeDef *) USART3_BASE) #define UART4 ((USART_TypeDef *) UART4_BASE) #define UART5 ((USART_TypeDef *) UART5_BASE) #define I2C1 ((I2C_TypeDef *) I2C1_BASE) #define I2C2 ((I2C_TypeDef *) I2C2_BASE) #define I2C3 ((I2C_TypeDef *) I2C3_BASE) #define CAN1 ((CAN_TypeDef *) CAN1_BASE) #define CAN2 ((CAN_TypeDef *) CAN2_BASE) #define PWR ((PWR_TypeDef *) PWR_BASE) #define DAC1 ((DAC_TypeDef *) DAC_BASE) #define DAC ((DAC_TypeDef *) DAC_BASE) /* Kept for legacy purpose */ #define TIM1 ((TIM_TypeDef *) TIM1_BASE) #define TIM8 ((TIM_TypeDef *) TIM8_BASE) #define USART1 ((USART_TypeDef *) USART1_BASE) #define USART6 ((USART_TypeDef *) USART6_BASE) #define ADC1 ((ADC_TypeDef *) ADC1_BASE) #define ADC2 ((ADC_TypeDef *) ADC2_BASE) #define ADC3 ((ADC_TypeDef *) ADC3_BASE) #define ADC123_COMMON ((ADC_Common_TypeDef *) ADC123_COMMON_BASE) /* Legacy define */ #define ADC ADC123_COMMON #define SDIO ((SDIO_TypeDef *) SDIO_BASE) #define SPI1 ((SPI_TypeDef *) SPI1_BASE) #define SYSCFG ((SYSCFG_TypeDef *) SYSCFG_BASE) #define EXTI ((EXTI_TypeDef *) EXTI_BASE) #define TIM9 ((TIM_TypeDef *) TIM9_BASE) #define TIM10 ((TIM_TypeDef *) TIM10_BASE) #define TIM11 ((TIM_TypeDef *) TIM11_BASE) #define GPIOA ((GPIO_TypeDef *) GPIOA_BASE) #define GPIOB ((GPIO_TypeDef *) GPIOB_BASE) #define GPIOC ((GPIO_TypeDef *) GPIOC_BASE) #define GPIOD ((GPIO_TypeDef *) GPIOD_BASE) #define GPIOE ((GPIO_TypeDef *) GPIOE_BASE) #define GPIOF ((GPIO_TypeDef *) GPIOF_BASE) #define GPIOG ((GPIO_TypeDef *) GPIOG_BASE) #define GPIOH ((GPIO_TypeDef *) GPIOH_BASE) #define GPIOI ((GPIO_TypeDef *) GPIOI_BASE) #define CRC ((CRC_TypeDef *) CRC_BASE) #define RCC ((RCC_TypeDef *) RCC_BASE) #define FLASH ((FLASH_TypeDef *) FLASH_R_BASE) #define DMA1 ((DMA_TypeDef *) DMA1_BASE) #define DMA1_Stream0 ((DMA_Stream_TypeDef *) DMA1_Stream0_BASE) #define DMA1_Stream1 ((DMA_Stream_TypeDef *) DMA1_Stream1_BASE) #define DMA1_Stream2 ((DMA_Stream_TypeDef *) DMA1_Stream2_BASE) #define DMA1_Stream3 ((DMA_Stream_TypeDef *) DMA1_Stream3_BASE) #define DMA1_Stream4 ((DMA_Stream_TypeDef *) DMA1_Stream4_BASE) #define DMA1_Stream5 ((DMA_Stream_TypeDef *) DMA1_Stream5_BASE) #define DMA1_Stream6 ((DMA_Stream_TypeDef *) DMA1_Stream6_BASE) #define DMA1_Stream7 ((DMA_Stream_TypeDef *) DMA1_Stream7_BASE) #define DMA2 ((DMA_TypeDef *) DMA2_BASE) #define DMA2_Stream0 ((DMA_Stream_TypeDef *) DMA2_Stream0_BASE) #define DMA2_Stream1 ((DMA_Stream_TypeDef *) DMA2_Stream1_BASE) #define DMA2_Stream2 ((DMA_Stream_TypeDef *) DMA2_Stream2_BASE) #define DMA2_Stream3 ((DMA_Stream_TypeDef *) DMA2_Stream3_BASE) #define DMA2_Stream4 ((DMA_Stream_TypeDef *) DMA2_Stream4_BASE) #define DMA2_Stream5 ((DMA_Stream_TypeDef *) DMA2_Stream5_BASE) #define DMA2_Stream6 ((DMA_Stream_TypeDef *) DMA2_Stream6_BASE) #define DMA2_Stream7 ((DMA_Stream_TypeDef *) DMA2_Stream7_BASE) #define ETH ((ETH_TypeDef *) ETH_BASE) #define DCMI ((DCMI_TypeDef *) DCMI_BASE) #define RNG ((RNG_TypeDef *) RNG_BASE) #define FSMC_Bank1 ((FSMC_Bank1_TypeDef *) FSMC_Bank1_R_BASE) #define FSMC_Bank1E ((FSMC_Bank1E_TypeDef *) FSMC_Bank1E_R_BASE) #define FSMC_Bank2_3 ((FSMC_Bank2_3_TypeDef *) FSMC_Bank2_3_R_BASE) #define FSMC_Bank4 ((FSMC_Bank4_TypeDef *) FSMC_Bank4_R_BASE) #define DBGMCU ((DBGMCU_TypeDef *) DBGMCU_BASE) #define USB_OTG_FS ((USB_OTG_GlobalTypeDef *) USB_OTG_FS_PERIPH_BASE) #define USB_OTG_HS ((USB_OTG_GlobalTypeDef *) USB_OTG_HS_PERIPH_BASE) /** * @} */ /** @addtogroup Exported_constants * @{ */ /** @addtogroup Peripheral_Registers_Bits_Definition * @{ */ /******************************************************************************/ /* Peripheral Registers_Bits_Definition */ /******************************************************************************/ /******************************************************************************/ /* */ /* Analog to Digital Converter */ /* */ /******************************************************************************/ /* * @brief Specific device feature definitions (not present on all devices in the STM32F4 serie) */ #define ADC_MULTIMODE_SUPPORT /*!
© COPYRIGHT(c) 2017 STMicroelectronics
* * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. Neither the name of STMicroelectronics nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ /** @addtogroup CMSIS_Device * @{ */ /** @addtogroup stm32f411xe * @{ */ #ifndef __STM32F411xE_H #define __STM32F411xE_H #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ /** @addtogroup Configuration_section_for_CMSIS * @{ */ /** * @brief Configuration of the Cortex-M4 Processor and Core Peripherals */ #define __CM4_REV 0x0001U /*!< Core revision r0p1 */ #define __MPU_PRESENT 1U /*!< STM32F4XX provides an MPU */ #define __NVIC_PRIO_BITS 4U /*!< STM32F4XX uses 4 Bits for the Priority Levels */ #define __Vendor_SysTickConfig 0U /*!< Set to 1 if different SysTick Config is used */ #define __FPU_PRESENT 1U /*!< FPU present */ /** * @} */ /** @addtogroup Peripheral_interrupt_number_definition * @{ */ /** * @brief STM32F4XX Interrupt Number Definition, according to the selected device * in @ref Library_configuration_section */ typedef enum { /****** Cortex-M4 Processor Exceptions Numbers ****************************************************************/ NonMaskableInt_IRQn = -14, /*!< 2 Non Maskable Interrupt */ MemoryManagement_IRQn = -12, /*!< 4 Cortex-M4 Memory Management Interrupt */ BusFault_IRQn = -11, /*!< 5 Cortex-M4 Bus Fault Interrupt */ UsageFault_IRQn = -10, /*!< 6 Cortex-M4 Usage Fault Interrupt */ SVCall_IRQn = -5, /*!< 11 Cortex-M4 SV Call Interrupt */ DebugMonitor_IRQn = -4, /*!< 12 Cortex-M4 Debug Monitor Interrupt */ PendSV_IRQn = -2, /*!< 14 Cortex-M4 Pend SV Interrupt */ SysTick_IRQn = -1, /*!< 15 Cortex-M4 System Tick Interrupt */ /****** STM32 specific Interrupt Numbers **********************************************************************/ WWDG_IRQn = 0, /*!< Window WatchDog Interrupt */ PVD_IRQn = 1, /*!< PVD through EXTI Line detection Interrupt */ TAMP_STAMP_IRQn = 2, /*!< Tamper and TimeStamp interrupts through the EXTI line */ RTC_WKUP_IRQn = 3, /*!< RTC Wakeup interrupt through the EXTI line */ FLASH_IRQn = 4, /*!< FLASH global Interrupt */ RCC_IRQn = 5, /*!< RCC global Interrupt */ EXTI0_IRQn = 6, /*!< EXTI Line0 Interrupt */ EXTI1_IRQn = 7, /*!< EXTI Line1 Interrupt */ EXTI2_IRQn = 8, /*!< EXTI Line2 Interrupt */ EXTI3_IRQn = 9, /*!< EXTI Line3 Interrupt */ EXTI4_IRQn = 10, /*!< EXTI Line4 Interrupt */ DMA1_Stream0_IRQn = 11, /*!< DMA1 Stream 0 global Interrupt */ DMA1_Stream1_IRQn = 12, /*!< DMA1 Stream 1 global Interrupt */ DMA1_Stream2_IRQn = 13, /*!< DMA1 Stream 2 global Interrupt */ DMA1_Stream3_IRQn = 14, /*!< DMA1 Stream 3 global Interrupt */ DMA1_Stream4_IRQn = 15, /*!< DMA1 Stream 4 global Interrupt */ DMA1_Stream5_IRQn = 16, /*!< DMA1 Stream 5 global Interrupt */ DMA1_Stream6_IRQn = 17, /*!< DMA1 Stream 6 global Interrupt */ ADC_IRQn = 18, /*!< ADC1, ADC2 and ADC3 global Interrupts */ EXTI9_5_IRQn = 23, /*!< External Line[9:5] Interrupts */ TIM1_BRK_TIM9_IRQn = 24, /*!< TIM1 Break interrupt and TIM9 global interrupt */ TIM1_UP_TIM10_IRQn = 25, /*!< TIM1 Update Interrupt and TIM10 global interrupt */ TIM1_TRG_COM_TIM11_IRQn = 26, /*!< TIM1 Trigger and Commutation Interrupt and TIM11 global interrupt */ TIM1_CC_IRQn = 27, /*!< TIM1 Capture Compare Interrupt */ TIM2_IRQn = 28, /*!< TIM2 global Interrupt */ TIM3_IRQn = 29, /*!< TIM3 global Interrupt */ TIM4_IRQn = 30, /*!< TIM4 global Interrupt */ I2C1_EV_IRQn = 31, /*!< I2C1 Event Interrupt */ I2C1_ER_IRQn = 32, /*!< I2C1 Error Interrupt */ I2C2_EV_IRQn = 33, /*!< I2C2 Event Interrupt */ I2C2_ER_IRQn = 34, /*!< I2C2 Error Interrupt */ SPI1_IRQn = 35, /*!< SPI1 global Interrupt */ SPI2_IRQn = 36, /*!< SPI2 global Interrupt */ USART1_IRQn = 37, /*!< USART1 global Interrupt */ USART2_IRQn = 38, /*!< USART2 global Interrupt */ EXTI15_10_IRQn = 40, /*!< External Line[15:10] Interrupts */ RTC_Alarm_IRQn = 41, /*!< RTC Alarm (A and B) through EXTI Line Interrupt */ OTG_FS_WKUP_IRQn = 42, /*!< USB OTG FS Wakeup through EXTI line interrupt */ DMA1_Stream7_IRQn = 47, /*!< DMA1 Stream7 Interrupt */ SDIO_IRQn = 49, /*!< SDIO global Interrupt */ TIM5_IRQn = 50, /*!< TIM5 global Interrupt */ SPI3_IRQn = 51, /*!< SPI3 global Interrupt */ DMA2_Stream0_IRQn = 56, /*!< DMA2 Stream 0 global Interrupt */ DMA2_Stream1_IRQn = 57, /*!< DMA2 Stream 1 global Interrupt */ DMA2_Stream2_IRQn = 58, /*!< DMA2 Stream 2 global Interrupt */ DMA2_Stream3_IRQn = 59, /*!< DMA2 Stream 3 global Interrupt */ DMA2_Stream4_IRQn = 60, /*!< DMA2 Stream 4 global Interrupt */ OTG_FS_IRQn = 67, /*!< USB OTG FS global Interrupt */ DMA2_Stream5_IRQn = 68, /*!< DMA2 Stream 5 global interrupt */ DMA2_Stream6_IRQn = 69, /*!< DMA2 Stream 6 global interrupt */ DMA2_Stream7_IRQn = 70, /*!< DMA2 Stream 7 global interrupt */ USART6_IRQn = 71, /*!< USART6 global interrupt */ I2C3_EV_IRQn = 72, /*!< I2C3 event interrupt */ I2C3_ER_IRQn = 73, /*!< I2C3 error interrupt */ FPU_IRQn = 81, /*!< FPU global interrupt */ SPI4_IRQn = 84, /*!< SPI4 global Interrupt */ SPI5_IRQn = 85 /*!< SPI5 global Interrupt */ } IRQn_Type; /** * @} */ #include "core_cm4.h" /* Cortex-M4 processor and core peripherals */ #include "system_stm32f4xx.h" #include /** @addtogroup Peripheral_registers_structures * @{ */ /** * @brief Analog to Digital Converter */ typedef struct { __IO uint32_t SR; /*!< ADC status register, Address offset: 0x00 */ __IO uint32_t CR1; /*!< ADC control register 1, Address offset: 0x04 */ __IO uint32_t CR2; /*!< ADC control register 2, Address offset: 0x08 */ __IO uint32_t SMPR1; /*!< ADC sample time register 1, Address offset: 0x0C */ __IO uint32_t SMPR2; /*!< ADC sample time register 2, Address offset: 0x10 */ __IO uint32_t JOFR1; /*!< ADC injected channel data offset register 1, Address offset: 0x14 */ __IO uint32_t JOFR2; /*!< ADC injected channel data offset register 2, Address offset: 0x18 */ __IO uint32_t JOFR3; /*!< ADC injected channel data offset register 3, Address offset: 0x1C */ __IO uint32_t JOFR4; /*!< ADC injected channel data offset register 4, Address offset: 0x20 */ __IO uint32_t HTR; /*!< ADC watchdog higher threshold register, Address offset: 0x24 */ __IO uint32_t LTR; /*!< ADC watchdog lower threshold register, Address offset: 0x28 */ __IO uint32_t SQR1; /*!< ADC regular sequence register 1, Address offset: 0x2C */ __IO uint32_t SQR2; /*!< ADC regular sequence register 2, Address offset: 0x30 */ __IO uint32_t SQR3; /*!< ADC regular sequence register 3, Address offset: 0x34 */ __IO uint32_t JSQR; /*!< ADC injected sequence register, Address offset: 0x38*/ __IO uint32_t JDR1; /*!< ADC injected data register 1, Address offset: 0x3C */ __IO uint32_t JDR2; /*!< ADC injected data register 2, Address offset: 0x40 */ __IO uint32_t JDR3; /*!< ADC injected data register 3, Address offset: 0x44 */ __IO uint32_t JDR4; /*!< ADC injected data register 4, Address offset: 0x48 */ __IO uint32_t DR; /*!< ADC regular data register, Address offset: 0x4C */ } ADC_TypeDef; typedef struct { __IO uint32_t CSR; /*!< ADC Common status register, Address offset: ADC1 base address + 0x300 */ __IO uint32_t CCR; /*!< ADC common control register, Address offset: ADC1 base address + 0x304 */ __IO uint32_t CDR; /*!< ADC common regular data register for dual AND triple modes, Address offset: ADC1 base address + 0x308 */ } ADC_Common_TypeDef; /** * @brief CRC calculation unit */ typedef struct { __IO uint32_t DR; /*!< CRC Data register, Address offset: 0x00 */ __IO uint8_t IDR; /*!< CRC Independent data register, Address offset: 0x04 */ uint8_t RESERVED0; /*!< Reserved, 0x05 */ uint16_t RESERVED1; /*!< Reserved, 0x06 */ __IO uint32_t CR; /*!< CRC Control register, Address offset: 0x08 */ } CRC_TypeDef; /** * @brief Debug MCU */ typedef struct { __IO uint32_t IDCODE; /*!< MCU device ID code, Address offset: 0x00 */ __IO uint32_t CR; /*!< Debug MCU configuration register, Address offset: 0x04 */ __IO uint32_t APB1FZ; /*!< Debug MCU APB1 freeze register, Address offset: 0x08 */ __IO uint32_t APB2FZ; /*!< Debug MCU APB2 freeze register, Address offset: 0x0C */ }DBGMCU_TypeDef; /** * @brief DMA Controller */ typedef struct { __IO uint32_t CR; /*!< DMA stream x configuration register */ __IO uint32_t NDTR; /*!< DMA stream x number of data register */ __IO uint32_t PAR; /*!< DMA stream x peripheral address register */ __IO uint32_t M0AR; /*!< DMA stream x memory 0 address register */ __IO uint32_t M1AR; /*!< DMA stream x memory 1 address register */ __IO uint32_t FCR; /*!< DMA stream x FIFO control register */ } DMA_Stream_TypeDef; typedef struct { __IO uint32_t LISR; /*!< DMA low interrupt status register, Address offset: 0x00 */ __IO uint32_t HISR; /*!< DMA high interrupt status register, Address offset: 0x04 */ __IO uint32_t LIFCR; /*!< DMA low interrupt flag clear register, Address offset: 0x08 */ __IO uint32_t HIFCR; /*!< DMA high interrupt flag clear register, Address offset: 0x0C */ } DMA_TypeDef; /** * @brief External Interrupt/Event Controller */ typedef struct { __IO uint32_t IMR; /*!< EXTI Interrupt mask register, Address offset: 0x00 */ __IO uint32_t EMR; /*!< EXTI Event mask register, Address offset: 0x04 */ __IO uint32_t RTSR; /*!< EXTI Rising trigger selection register, Address offset: 0x08 */ __IO uint32_t FTSR; /*!< EXTI Falling trigger selection register, Address offset: 0x0C */ __IO uint32_t SWIER; /*!< EXTI Software interrupt event register, Address offset: 0x10 */ __IO uint32_t PR; /*!< EXTI Pending register, Address offset: 0x14 */ } EXTI_TypeDef; /** * @brief FLASH Registers */ typedef struct { __IO uint32_t ACR; /*!< FLASH access control register, Address offset: 0x00 */ __IO uint32_t KEYR; /*!< FLASH key register, Address offset: 0x04 */ __IO uint32_t OPTKEYR; /*!< FLASH option key register, Address offset: 0x08 */ __IO uint32_t SR; /*!< FLASH status register, Address offset: 0x0C */ __IO uint32_t CR; /*!< FLASH control register, Address offset: 0x10 */ __IO uint32_t OPTCR; /*!< FLASH option control register , Address offset: 0x14 */ __IO uint32_t OPTCR1; /*!< FLASH option control register 1, Address offset: 0x18 */ } FLASH_TypeDef; /** * @brief General Purpose I/O */ typedef struct { __IO uint32_t MODER; /*!< GPIO port mode register, Address offset: 0x00 */ __IO uint32_t OTYPER; /*!< GPIO port output type register, Address offset: 0x04 */ __IO uint32_t OSPEEDR; /*!< GPIO port output speed register, Address offset: 0x08 */ __IO uint32_t PUPDR; /*!< GPIO port pull-up/pull-down register, Address offset: 0x0C */ __IO uint32_t IDR; /*!< GPIO port input data register, Address offset: 0x10 */ __IO uint32_t ODR; /*!< GPIO port output data register, Address offset: 0x14 */ __IO uint32_t BSRR; /*!< GPIO port bit set/reset register, Address offset: 0x18 */ __IO uint32_t LCKR; /*!< GPIO port configuration lock register, Address offset: 0x1C */ __IO uint32_t AFR[2]; /*!< GPIO alternate function registers, Address offset: 0x20-0x24 */ } GPIO_TypeDef; /** * @brief System configuration controller */ typedef struct { __IO uint32_t MEMRMP; /*!< SYSCFG memory remap register, Address offset: 0x00 */ __IO uint32_t PMC; /*!< SYSCFG peripheral mode configuration register, Address offset: 0x04 */ __IO uint32_t EXTICR[4]; /*!< SYSCFG external interrupt configuration registers, Address offset: 0x08-0x14 */ uint32_t RESERVED[2]; /*!< Reserved, 0x18-0x1C */ __IO uint32_t CMPCR; /*!< SYSCFG Compensation cell control register, Address offset: 0x20 */ } SYSCFG_TypeDef; /** * @brief Inter-integrated Circuit Interface */ typedef struct { __IO uint32_t CR1; /*!< I2C Control register 1, Address offset: 0x00 */ __IO uint32_t CR2; /*!< I2C Control register 2, Address offset: 0x04 */ __IO uint32_t OAR1; /*!< I2C Own address register 1, Address offset: 0x08 */ __IO uint32_t OAR2; /*!< I2C Own address register 2, Address offset: 0x0C */ __IO uint32_t DR; /*!< I2C Data register, Address offset: 0x10 */ __IO uint32_t SR1; /*!< I2C Status register 1, Address offset: 0x14 */ __IO uint32_t SR2; /*!< I2C Status register 2, Address offset: 0x18 */ __IO uint32_t CCR; /*!< I2C Clock control register, Address offset: 0x1C */ __IO uint32_t TRISE; /*!< I2C TRISE register, Address offset: 0x20 */ __IO uint32_t FLTR; /*!< I2C FLTR register, Address offset: 0x24 */ } I2C_TypeDef; /** * @brief Independent WATCHDOG */ typedef struct { __IO uint32_t KR; /*!< IWDG Key register, Address offset: 0x00 */ __IO uint32_t PR; /*!< IWDG Prescaler register, Address offset: 0x04 */ __IO uint32_t RLR; /*!< IWDG Reload register, Address offset: 0x08 */ __IO uint32_t SR; /*!< IWDG Status register, Address offset: 0x0C */ } IWDG_TypeDef; /** * @brief Power Control */ typedef struct { __IO uint32_t CR; /*!< PWR power control register, Address offset: 0x00 */ __IO uint32_t CSR; /*!< PWR power control/status register, Address offset: 0x04 */ } PWR_TypeDef; /** * @brief Reset and Clock Control */ typedef struct { __IO uint32_t CR; /*!< RCC clock control register, Address offset: 0x00 */ __IO uint32_t PLLCFGR; /*!< RCC PLL configuration register, Address offset: 0x04 */ __IO uint32_t CFGR; /*!< RCC clock configuration register, Address offset: 0x08 */ __IO uint32_t CIR; /*!< RCC clock interrupt register, Address offset: 0x0C */ __IO uint32_t AHB1RSTR; /*!< RCC AHB1 peripheral reset register, Address offset: 0x10 */ __IO uint32_t AHB2RSTR; /*!< RCC AHB2 peripheral reset register, Address offset: 0x14 */ __IO uint32_t AHB3RSTR; /*!< RCC AHB3 peripheral reset register, Address offset: 0x18 */ uint32_t RESERVED0; /*!< Reserved, 0x1C */ __IO uint32_t APB1RSTR; /*!< RCC APB1 peripheral reset register, Address offset: 0x20 */ __IO uint32_t APB2RSTR; /*!< RCC APB2 peripheral reset register, Address offset: 0x24 */ uint32_t RESERVED1[2]; /*!< Reserved, 0x28-0x2C */ __IO uint32_t AHB1ENR; /*!< RCC AHB1 peripheral clock register, Address offset: 0x30 */ __IO uint32_t AHB2ENR; /*!< RCC AHB2 peripheral clock register, Address offset: 0x34 */ __IO uint32_t AHB3ENR; /*!< RCC AHB3 peripheral clock register, Address offset: 0x38 */ uint32_t RESERVED2; /*!< Reserved, 0x3C */ __IO uint32_t APB1ENR; /*!< RCC APB1 peripheral clock enable register, Address offset: 0x40 */ __IO uint32_t APB2ENR; /*!< RCC APB2 peripheral clock enable register, Address offset: 0x44 */ uint32_t RESERVED3[2]; /*!< Reserved, 0x48-0x4C */ __IO uint32_t AHB1LPENR; /*!< RCC AHB1 peripheral clock enable in low power mode register, Address offset: 0x50 */ __IO uint32_t AHB2LPENR; /*!< RCC AHB2 peripheral clock enable in low power mode register, Address offset: 0x54 */ __IO uint32_t AHB3LPENR; /*!< RCC AHB3 peripheral clock enable in low power mode register, Address offset: 0x58 */ uint32_t RESERVED4; /*!< Reserved, 0x5C */ __IO uint32_t APB1LPENR; /*!< RCC APB1 peripheral clock enable in low power mode register, Address offset: 0x60 */ __IO uint32_t APB2LPENR; /*!< RCC APB2 peripheral clock enable in low power mode register, Address offset: 0x64 */ uint32_t RESERVED5[2]; /*!< Reserved, 0x68-0x6C */ __IO uint32_t BDCR; /*!< RCC Backup domain control register, Address offset: 0x70 */ __IO uint32_t CSR; /*!< RCC clock control & status register, Address offset: 0x74 */ uint32_t RESERVED6[2]; /*!< Reserved, 0x78-0x7C */ __IO uint32_t SSCGR; /*!< RCC spread spectrum clock generation register, Address offset: 0x80 */ __IO uint32_t PLLI2SCFGR; /*!< RCC PLLI2S configuration register, Address offset: 0x84 */ uint32_t RESERVED7[1]; /*!< Reserved, 0x88 */ __IO uint32_t DCKCFGR; /*!< RCC Dedicated Clocks configuration register, Address offset: 0x8C */ } RCC_TypeDef; /** * @brief Real-Time Clock */ typedef struct { __IO uint32_t TR; /*!< RTC time register, Address offset: 0x00 */ __IO uint32_t DR; /*!< RTC date register, Address offset: 0x04 */ __IO uint32_t CR; /*!< RTC control register, Address offset: 0x08 */ __IO uint32_t ISR; /*!< RTC initialization and status register, Address offset: 0x0C */ __IO uint32_t PRER; /*!< RTC prescaler register, Address offset: 0x10 */ __IO uint32_t WUTR; /*!< RTC wakeup timer register, Address offset: 0x14 */ __IO uint32_t CALIBR; /*!< RTC calibration register, Address offset: 0x18 */ __IO uint32_t ALRMAR; /*!< RTC alarm A register, Address offset: 0x1C */ __IO uint32_t ALRMBR; /*!< RTC alarm B register, Address offset: 0x20 */ __IO uint32_t WPR; /*!< RTC write protection register, Address offset: 0x24 */ __IO uint32_t SSR; /*!< RTC sub second register, Address offset: 0x28 */ __IO uint32_t SHIFTR; /*!< RTC shift control register, Address offset: 0x2C */ __IO uint32_t TSTR; /*!< RTC time stamp time register, Address offset: 0x30 */ __IO uint32_t TSDR; /*!< RTC time stamp date register, Address offset: 0x34 */ __IO uint32_t TSSSR; /*!< RTC time-stamp sub second register, Address offset: 0x38 */ __IO uint32_t CALR; /*!< RTC calibration register, Address offset: 0x3C */ __IO uint32_t TAFCR; /*!< RTC tamper and alternate function configuration register, Address offset: 0x40 */ __IO uint32_t ALRMASSR;/*!< RTC alarm A sub second register, Address offset: 0x44 */ __IO uint32_t ALRMBSSR;/*!< RTC alarm B sub second register, Address offset: 0x48 */ uint32_t RESERVED7; /*!< Reserved, 0x4C */ __IO uint32_t BKP0R; /*!< RTC backup register 1, Address offset: 0x50 */ __IO uint32_t BKP1R; /*!< RTC backup register 1, Address offset: 0x54 */ __IO uint32_t BKP2R; /*!< RTC backup register 2, Address offset: 0x58 */ __IO uint32_t BKP3R; /*!< RTC backup register 3, Address offset: 0x5C */ __IO uint32_t BKP4R; /*!< RTC backup register 4, Address offset: 0x60 */ __IO uint32_t BKP5R; /*!< RTC backup register 5, Address offset: 0x64 */ __IO uint32_t BKP6R; /*!< RTC backup register 6, Address offset: 0x68 */ __IO uint32_t BKP7R; /*!< RTC backup register 7, Address offset: 0x6C */ __IO uint32_t BKP8R; /*!< RTC backup register 8, Address offset: 0x70 */ __IO uint32_t BKP9R; /*!< RTC backup register 9, Address offset: 0x74 */ __IO uint32_t BKP10R; /*!< RTC backup register 10, Address offset: 0x78 */ __IO uint32_t BKP11R; /*!< RTC backup register 11, Address offset: 0x7C */ __IO uint32_t BKP12R; /*!< RTC backup register 12, Address offset: 0x80 */ __IO uint32_t BKP13R; /*!< RTC backup register 13, Address offset: 0x84 */ __IO uint32_t BKP14R; /*!< RTC backup register 14, Address offset: 0x88 */ __IO uint32_t BKP15R; /*!< RTC backup register 15, Address offset: 0x8C */ __IO uint32_t BKP16R; /*!< RTC backup register 16, Address offset: 0x90 */ __IO uint32_t BKP17R; /*!< RTC backup register 17, Address offset: 0x94 */ __IO uint32_t BKP18R; /*!< RTC backup register 18, Address offset: 0x98 */ __IO uint32_t BKP19R; /*!< RTC backup register 19, Address offset: 0x9C */ } RTC_TypeDef; /** * @brief SD host Interface */ typedef struct { __IO uint32_t POWER; /*!< SDIO power control register, Address offset: 0x00 */ __IO uint32_t CLKCR; /*!< SDI clock control register, Address offset: 0x04 */ __IO uint32_t ARG; /*!< SDIO argument register, Address offset: 0x08 */ __IO uint32_t CMD; /*!< SDIO command register, Address offset: 0x0C */ __IO const uint32_t RESPCMD; /*!< SDIO command response register, Address offset: 0x10 */ __IO const uint32_t RESP1; /*!< SDIO response 1 register, Address offset: 0x14 */ __IO const uint32_t RESP2; /*!< SDIO response 2 register, Address offset: 0x18 */ __IO const uint32_t RESP3; /*!< SDIO response 3 register, Address offset: 0x1C */ __IO const uint32_t RESP4; /*!< SDIO response 4 register, Address offset: 0x20 */ __IO uint32_t DTIMER; /*!< SDIO data timer register, Address offset: 0x24 */ __IO uint32_t DLEN; /*!< SDIO data length register, Address offset: 0x28 */ __IO uint32_t DCTRL; /*!< SDIO data control register, Address offset: 0x2C */ __IO const uint32_t DCOUNT; /*!< SDIO data counter register, Address offset: 0x30 */ __IO const uint32_t STA; /*!< SDIO status register, Address offset: 0x34 */ __IO uint32_t ICR; /*!< SDIO interrupt clear register, Address offset: 0x38 */ __IO uint32_t MASK; /*!< SDIO mask register, Address offset: 0x3C */ uint32_t RESERVED0[2]; /*!< Reserved, 0x40-0x44 */ __IO const uint32_t FIFOCNT; /*!< SDIO FIFO counter register, Address offset: 0x48 */ uint32_t RESERVED1[13]; /*!< Reserved, 0x4C-0x7C */ __IO uint32_t FIFO; /*!< SDIO data FIFO register, Address offset: 0x80 */ } SDIO_TypeDef; /** * @brief Serial Peripheral Interface */ typedef struct { __IO uint32_t CR1; /*!< SPI control register 1 (not used in I2S mode), Address offset: 0x00 */ __IO uint32_t CR2; /*!< SPI control register 2, Address offset: 0x04 */ __IO uint32_t SR; /*!< SPI status register, Address offset: 0x08 */ __IO uint32_t DR; /*!< SPI data register, Address offset: 0x0C */ __IO uint32_t CRCPR; /*!< SPI CRC polynomial register (not used in I2S mode), Address offset: 0x10 */ __IO uint32_t RXCRCR; /*!< SPI RX CRC register (not used in I2S mode), Address offset: 0x14 */ __IO uint32_t TXCRCR; /*!< SPI TX CRC register (not used in I2S mode), Address offset: 0x18 */ __IO uint32_t I2SCFGR; /*!< SPI_I2S configuration register, Address offset: 0x1C */ __IO uint32_t I2SPR; /*!< SPI_I2S prescaler register, Address offset: 0x20 */ } SPI_TypeDef; /** * @brief TIM */ typedef struct { __IO uint32_t CR1; /*!< TIM control register 1, Address offset: 0x00 */ __IO uint32_t CR2; /*!< TIM control register 2, Address offset: 0x04 */ __IO uint32_t SMCR; /*!< TIM slave mode control register, Address offset: 0x08 */ __IO uint32_t DIER; /*!< TIM DMA/interrupt enable register, Address offset: 0x0C */ __IO uint32_t SR; /*!< TIM status register, Address offset: 0x10 */ __IO uint32_t EGR; /*!< TIM event generation register, Address offset: 0x14 */ __IO uint32_t CCMR1; /*!< TIM capture/compare mode register 1, Address offset: 0x18 */ __IO uint32_t CCMR2; /*!< TIM capture/compare mode register 2, Address offset: 0x1C */ __IO uint32_t CCER; /*!< TIM capture/compare enable register, Address offset: 0x20 */ __IO uint32_t CNT; /*!< TIM counter register, Address offset: 0x24 */ __IO uint32_t PSC; /*!< TIM prescaler, Address offset: 0x28 */ __IO uint32_t ARR; /*!< TIM auto-reload register, Address offset: 0x2C */ __IO uint32_t RCR; /*!< TIM repetition counter register, Address offset: 0x30 */ __IO uint32_t CCR1; /*!< TIM capture/compare register 1, Address offset: 0x34 */ __IO uint32_t CCR2; /*!< TIM capture/compare register 2, Address offset: 0x38 */ __IO uint32_t CCR3; /*!< TIM capture/compare register 3, Address offset: 0x3C */ __IO uint32_t CCR4; /*!< TIM capture/compare register 4, Address offset: 0x40 */ __IO uint32_t BDTR; /*!< TIM break and dead-time register, Address offset: 0x44 */ __IO uint32_t DCR; /*!< TIM DMA control register, Address offset: 0x48 */ __IO uint32_t DMAR; /*!< TIM DMA address for full transfer, Address offset: 0x4C */ __IO uint32_t OR; /*!< TIM option register, Address offset: 0x50 */ } TIM_TypeDef; /** * @brief Universal Synchronous Asynchronous Receiver Transmitter */ typedef struct { __IO uint32_t SR; /*!< USART Status register, Address offset: 0x00 */ __IO uint32_t DR; /*!< USART Data register, Address offset: 0x04 */ __IO uint32_t BRR; /*!< USART Baud rate register, Address offset: 0x08 */ __IO uint32_t CR1; /*!< USART Control register 1, Address offset: 0x0C */ __IO uint32_t CR2; /*!< USART Control register 2, Address offset: 0x10 */ __IO uint32_t CR3; /*!< USART Control register 3, Address offset: 0x14 */ __IO uint32_t GTPR; /*!< USART Guard time and prescaler register, Address offset: 0x18 */ } USART_TypeDef; /** * @brief Window WATCHDOG */ typedef struct { __IO uint32_t CR; /*!< WWDG Control register, Address offset: 0x00 */ __IO uint32_t CFR; /*!< WWDG Configuration register, Address offset: 0x04 */ __IO uint32_t SR; /*!< WWDG Status register, Address offset: 0x08 */ } WWDG_TypeDef; /** * @brief USB_OTG_Core_Registers */ typedef struct { __IO uint32_t GOTGCTL; /*!< USB_OTG Control and Status Register 000h */ __IO uint32_t GOTGINT; /*!< USB_OTG Interrupt Register 004h */ __IO uint32_t GAHBCFG; /*!< Core AHB Configuration Register 008h */ __IO uint32_t GUSBCFG; /*!< Core USB Configuration Register 00Ch */ __IO uint32_t GRSTCTL; /*!< Core Reset Register 010h */ __IO uint32_t GINTSTS; /*!< Core Interrupt Register 014h */ __IO uint32_t GINTMSK; /*!< Core Interrupt Mask Register 018h */ __IO uint32_t GRXSTSR; /*!< Receive Sts Q Read Register 01Ch */ __IO uint32_t GRXSTSP; /*!< Receive Sts Q Read & POP Register 020h */ __IO uint32_t GRXFSIZ; /*!< Receive FIFO Size Register 024h */ __IO uint32_t DIEPTXF0_HNPTXFSIZ; /*!< EP0 / Non Periodic Tx FIFO Size Register 028h */ __IO uint32_t HNPTXSTS; /*!< Non Periodic Tx FIFO/Queue Sts reg 02Ch */ uint32_t Reserved30[2]; /*!< Reserved 030h */ __IO uint32_t GCCFG; /*!< General Purpose IO Register 038h */ __IO uint32_t CID; /*!< User ID Register 03Ch */ uint32_t Reserved40[48]; /*!< Reserved 0x40-0xFF */ __IO uint32_t HPTXFSIZ; /*!< Host Periodic Tx FIFO Size Reg 100h */ __IO uint32_t DIEPTXF[0x0F]; /*!< dev Periodic Transmit FIFO */ } USB_OTG_GlobalTypeDef; /** * @brief USB_OTG_device_Registers */ typedef struct { __IO uint32_t DCFG; /*!< dev Configuration Register 800h */ __IO uint32_t DCTL; /*!< dev Control Register 804h */ __IO uint32_t DSTS; /*!< dev Status Register (RO) 808h */ uint32_t Reserved0C; /*!< Reserved 80Ch */ __IO uint32_t DIEPMSK; /*!< dev IN Endpoint Mask 810h */ __IO uint32_t DOEPMSK; /*!< dev OUT Endpoint Mask 814h */ __IO uint32_t DAINT; /*!< dev All Endpoints Itr Reg 818h */ __IO uint32_t DAINTMSK; /*!< dev All Endpoints Itr Mask 81Ch */ uint32_t Reserved20; /*!< Reserved 820h */ uint32_t Reserved9; /*!< Reserved 824h */ __IO uint32_t DVBUSDIS; /*!< dev VBUS discharge Register 828h */ __IO uint32_t DVBUSPULSE; /*!< dev VBUS Pulse Register 82Ch */ __IO uint32_t DTHRCTL; /*!< dev threshold 830h */ __IO uint32_t DIEPEMPMSK; /*!< dev empty msk 834h */ __IO uint32_t DEACHINT; /*!< dedicated EP interrupt 838h */ __IO uint32_t DEACHMSK; /*!< dedicated EP msk 83Ch */ uint32_t Reserved40; /*!< dedicated EP mask 840h */ __IO uint32_t DINEP1MSK; /*!< dedicated EP mask 844h */ uint32_t Reserved44[15]; /*!< Reserved 844-87Ch */ __IO uint32_t DOUTEP1MSK; /*!< dedicated EP msk 884h */ } USB_OTG_DeviceTypeDef; /** * @brief USB_OTG_IN_Endpoint-Specific_Register */ typedef struct { __IO uint32_t DIEPCTL; /*!< dev IN Endpoint Control Reg 900h + (ep_num * 20h) + 00h */ uint32_t Reserved04; /*!< Reserved 900h + (ep_num * 20h) + 04h */ __IO uint32_t DIEPINT; /*!< dev IN Endpoint Itr Reg 900h + (ep_num * 20h) + 08h */ uint32_t Reserved0C; /*!< Reserved 900h + (ep_num * 20h) + 0Ch */ __IO uint32_t DIEPTSIZ; /*!< IN Endpoint Txfer Size 900h + (ep_num * 20h) + 10h */ __IO uint32_t DIEPDMA; /*!< IN Endpoint DMA Address Reg 900h + (ep_num * 20h) + 14h */ __IO uint32_t DTXFSTS; /*!< IN Endpoint Tx FIFO Status Reg 900h + (ep_num * 20h) + 18h */ uint32_t Reserved18; /*!< Reserved 900h+(ep_num*20h)+1Ch-900h+ (ep_num * 20h) + 1Ch */ } USB_OTG_INEndpointTypeDef; /** * @brief USB_OTG_OUT_Endpoint-Specific_Registers */ typedef struct { __IO uint32_t DOEPCTL; /*!< dev OUT Endpoint Control Reg B00h + (ep_num * 20h) + 00h */ uint32_t Reserved04; /*!< Reserved B00h + (ep_num * 20h) + 04h */ __IO uint32_t DOEPINT; /*!< dev OUT Endpoint Itr Reg B00h + (ep_num * 20h) + 08h */ uint32_t Reserved0C; /*!< Reserved B00h + (ep_num * 20h) + 0Ch */ __IO uint32_t DOEPTSIZ; /*!< dev OUT Endpoint Txfer Size B00h + (ep_num * 20h) + 10h */ __IO uint32_t DOEPDMA; /*!< dev OUT Endpoint DMA Address B00h + (ep_num * 20h) + 14h */ uint32_t Reserved18[2]; /*!< Reserved B00h + (ep_num * 20h) + 18h - B00h + (ep_num * 20h) + 1Ch */ } USB_OTG_OUTEndpointTypeDef; /** * @brief USB_OTG_Host_Mode_Register_Structures */ typedef struct { __IO uint32_t HCFG; /*!< Host Configuration Register 400h */ __IO uint32_t HFIR; /*!< Host Frame Interval Register 404h */ __IO uint32_t HFNUM; /*!< Host Frame Nbr/Frame Remaining 408h */ uint32_t Reserved40C; /*!< Reserved 40Ch */ __IO uint32_t HPTXSTS; /*!< Host Periodic Tx FIFO/ Queue Status 410h */ __IO uint32_t HAINT; /*!< Host All Channels Interrupt Register 414h */ __IO uint32_t HAINTMSK; /*!< Host All Channels Interrupt Mask 418h */ } USB_OTG_HostTypeDef; /** * @brief USB_OTG_Host_Channel_Specific_Registers */ typedef struct { __IO uint32_t HCCHAR; /*!< Host Channel Characteristics Register 500h */ __IO uint32_t HCSPLT; /*!< Host Channel Split Control Register 504h */ __IO uint32_t HCINT; /*!< Host Channel Interrupt Register 508h */ __IO uint32_t HCINTMSK; /*!< Host Channel Interrupt Mask Register 50Ch */ __IO uint32_t HCTSIZ; /*!< Host Channel Transfer Size Register 510h */ __IO uint32_t HCDMA; /*!< Host Channel DMA Address Register 514h */ uint32_t Reserved[2]; /*!< Reserved */ } USB_OTG_HostChannelTypeDef; /** * @} */ /** @addtogroup Peripheral_memory_map * @{ */ #define FLASH_BASE 0x08000000UL /*!< FLASH(up to 1 MB) base address in the alias region */ #define SRAM1_BASE 0x20000000UL /*!< SRAM1(128 KB) base address in the alias region */ #define PERIPH_BASE 0x40000000UL /*!< Peripheral base address in the alias region */ #define SRAM1_BB_BASE 0x22000000UL /*!< SRAM1(128 KB) base address in the bit-band region */ #define PERIPH_BB_BASE 0x42000000UL /*!< Peripheral base address in the bit-band region */ #define BKPSRAM_BB_BASE 0x42480000UL /*!< Backup SRAM(4 KB) base address in the bit-band region */ #define FLASH_END 0x0807FFFFUL /*!< FLASH end address */ #define FLASH_OTP_BASE 0x1FFF7800UL /*!< Base address of : (up to 528 Bytes) embedded FLASH OTP Area */ #define FLASH_OTP_END 0x1FFF7A0FUL /*!< End address of : (up to 528 Bytes) embedded FLASH OTP Area */ /* Legacy defines */ #define SRAM_BASE SRAM1_BASE #define SRAM_BB_BASE SRAM1_BB_BASE /*!< Peripheral memory map */ #define APB1PERIPH_BASE PERIPH_BASE #define APB2PERIPH_BASE (PERIPH_BASE + 0x00010000UL) #define AHB1PERIPH_BASE (PERIPH_BASE + 0x00020000UL) #define AHB2PERIPH_BASE (PERIPH_BASE + 0x10000000UL) /*!< APB1 peripherals */ #define TIM2_BASE (APB1PERIPH_BASE + 0x0000UL) #define TIM3_BASE (APB1PERIPH_BASE + 0x0400UL) #define TIM4_BASE (APB1PERIPH_BASE + 0x0800UL) #define TIM5_BASE (APB1PERIPH_BASE + 0x0C00UL) #define RTC_BASE (APB1PERIPH_BASE + 0x2800UL) #define WWDG_BASE (APB1PERIPH_BASE + 0x2C00UL) #define IWDG_BASE (APB1PERIPH_BASE + 0x3000UL) #define I2S2ext_BASE (APB1PERIPH_BASE + 0x3400UL) #define SPI2_BASE (APB1PERIPH_BASE + 0x3800UL) #define SPI3_BASE (APB1PERIPH_BASE + 0x3C00UL) #define I2S3ext_BASE (APB1PERIPH_BASE + 0x4000UL) #define USART2_BASE (APB1PERIPH_BASE + 0x4400UL) #define I2C1_BASE (APB1PERIPH_BASE + 0x5400UL) #define I2C2_BASE (APB1PERIPH_BASE + 0x5800UL) #define I2C3_BASE (APB1PERIPH_BASE + 0x5C00UL) #define PWR_BASE (APB1PERIPH_BASE + 0x7000UL) /*!< APB2 peripherals */ #define TIM1_BASE (APB2PERIPH_BASE + 0x0000UL) #define USART1_BASE (APB2PERIPH_BASE + 0x1000UL) #define USART6_BASE (APB2PERIPH_BASE + 0x1400UL) #define ADC1_BASE (APB2PERIPH_BASE + 0x2000UL) #define ADC1_COMMON_BASE (APB2PERIPH_BASE + 0x2300UL) /* Legacy define */ #define ADC_BASE ADC1_COMMON_BASE #define SDIO_BASE (APB2PERIPH_BASE + 0x2C00UL) #define SPI1_BASE (APB2PERIPH_BASE + 0x3000UL) #define SPI4_BASE (APB2PERIPH_BASE + 0x3400UL) #define SYSCFG_BASE (APB2PERIPH_BASE + 0x3800UL) #define EXTI_BASE (APB2PERIPH_BASE + 0x3C00UL) #define TIM9_BASE (APB2PERIPH_BASE + 0x4000UL) #define TIM10_BASE (APB2PERIPH_BASE + 0x4400UL) #define TIM11_BASE (APB2PERIPH_BASE + 0x4800UL) #define SPI5_BASE (APB2PERIPH_BASE + 0x5000UL) /*!< AHB1 peripherals */ #define GPIOA_BASE (AHB1PERIPH_BASE + 0x0000UL) #define GPIOB_BASE (AHB1PERIPH_BASE + 0x0400UL) #define GPIOC_BASE (AHB1PERIPH_BASE + 0x0800UL) #define GPIOD_BASE (AHB1PERIPH_BASE + 0x0C00UL) #define GPIOE_BASE (AHB1PERIPH_BASE + 0x1000UL) #define GPIOH_BASE (AHB1PERIPH_BASE + 0x1C00UL) #define CRC_BASE (AHB1PERIPH_BASE + 0x3000UL) #define RCC_BASE (AHB1PERIPH_BASE + 0x3800UL) #define FLASH_R_BASE (AHB1PERIPH_BASE + 0x3C00UL) #define DMA1_BASE (AHB1PERIPH_BASE + 0x6000UL) #define DMA1_Stream0_BASE (DMA1_BASE + 0x010UL) #define DMA1_Stream1_BASE (DMA1_BASE + 0x028UL) #define DMA1_Stream2_BASE (DMA1_BASE + 0x040UL) #define DMA1_Stream3_BASE (DMA1_BASE + 0x058UL) #define DMA1_Stream4_BASE (DMA1_BASE + 0x070UL) #define DMA1_Stream5_BASE (DMA1_BASE + 0x088UL) #define DMA1_Stream6_BASE (DMA1_BASE + 0x0A0UL) #define DMA1_Stream7_BASE (DMA1_BASE + 0x0B8UL) #define DMA2_BASE (AHB1PERIPH_BASE + 0x6400UL) #define DMA2_Stream0_BASE (DMA2_BASE + 0x010UL) #define DMA2_Stream1_BASE (DMA2_BASE + 0x028UL) #define DMA2_Stream2_BASE (DMA2_BASE + 0x040UL) #define DMA2_Stream3_BASE (DMA2_BASE + 0x058UL) #define DMA2_Stream4_BASE (DMA2_BASE + 0x070UL) #define DMA2_Stream5_BASE (DMA2_BASE + 0x088UL) #define DMA2_Stream6_BASE (DMA2_BASE + 0x0A0UL) #define DMA2_Stream7_BASE (DMA2_BASE + 0x0B8UL) /*!< Debug MCU registers base address */ #define DBGMCU_BASE 0xE0042000UL /*!< USB registers base address */ #define USB_OTG_FS_PERIPH_BASE 0x50000000UL #define USB_OTG_GLOBAL_BASE 0x000UL #define USB_OTG_DEVICE_BASE 0x800UL #define USB_OTG_IN_ENDPOINT_BASE 0x900UL #define USB_OTG_OUT_ENDPOINT_BASE 0xB00UL #define USB_OTG_EP_REG_SIZE 0x20UL #define USB_OTG_HOST_BASE 0x400UL #define USB_OTG_HOST_PORT_BASE 0x440UL #define USB_OTG_HOST_CHANNEL_BASE 0x500UL #define USB_OTG_HOST_CHANNEL_SIZE 0x20UL #define USB_OTG_PCGCCTL_BASE 0xE00UL #define USB_OTG_FIFO_BASE 0x1000UL #define USB_OTG_FIFO_SIZE 0x1000UL #define UID_BASE 0x1FFF7A10UL /*!< Unique device ID register base address */ #define FLASHSIZE_BASE 0x1FFF7A22UL /*!< FLASH Size register base address */ #define PACKAGE_BASE 0x1FFF7BF0UL /*!< Package size register base address */ /** * @} */ /** @addtogroup Peripheral_declaration * @{ */ #define TIM2 ((TIM_TypeDef *) TIM2_BASE) #define TIM3 ((TIM_TypeDef *) TIM3_BASE) #define TIM4 ((TIM_TypeDef *) TIM4_BASE) #define TIM5 ((TIM_TypeDef *) TIM5_BASE) #define RTC ((RTC_TypeDef *) RTC_BASE) #define WWDG ((WWDG_TypeDef *) WWDG_BASE) #define IWDG ((IWDG_TypeDef *) IWDG_BASE) #define I2S2ext ((SPI_TypeDef *) I2S2ext_BASE) #define SPI2 ((SPI_TypeDef *) SPI2_BASE) #define SPI3 ((SPI_TypeDef *) SPI3_BASE) #define I2S3ext ((SPI_TypeDef *) I2S3ext_BASE) #define USART2 ((USART_TypeDef *) USART2_BASE) #define I2C1 ((I2C_TypeDef *) I2C1_BASE) #define I2C2 ((I2C_TypeDef *) I2C2_BASE) #define I2C3 ((I2C_TypeDef *) I2C3_BASE) #define PWR ((PWR_TypeDef *) PWR_BASE) #define TIM1 ((TIM_TypeDef *) TIM1_BASE) #define USART1 ((USART_TypeDef *) USART1_BASE) #define USART6 ((USART_TypeDef *) USART6_BASE) #define ADC1 ((ADC_TypeDef *) ADC1_BASE) #define ADC1_COMMON ((ADC_Common_TypeDef *) ADC1_COMMON_BASE) /* Legacy define */ #define ADC ADC1_COMMON #define SDIO ((SDIO_TypeDef *) SDIO_BASE) #define SPI1 ((SPI_TypeDef *) SPI1_BASE) #define SPI4 ((SPI_TypeDef *) SPI4_BASE) #define SYSCFG ((SYSCFG_TypeDef *) SYSCFG_BASE) #define EXTI ((EXTI_TypeDef *) EXTI_BASE) #define TIM9 ((TIM_TypeDef *) TIM9_BASE) #define TIM10 ((TIM_TypeDef *) TIM10_BASE) #define TIM11 ((TIM_TypeDef *) TIM11_BASE) #define SPI5 ((SPI_TypeDef *) SPI5_BASE) #define GPIOA ((GPIO_TypeDef *) GPIOA_BASE) #define GPIOB ((GPIO_TypeDef *) GPIOB_BASE) #define GPIOC ((GPIO_TypeDef *) GPIOC_BASE) #define GPIOD ((GPIO_TypeDef *) GPIOD_BASE) #define GPIOE ((GPIO_TypeDef *) GPIOE_BASE) #define GPIOH ((GPIO_TypeDef *) GPIOH_BASE) #define CRC ((CRC_TypeDef *) CRC_BASE) #define RCC ((RCC_TypeDef *) RCC_BASE) #define FLASH ((FLASH_TypeDef *) FLASH_R_BASE) #define DMA1 ((DMA_TypeDef *) DMA1_BASE) #define DMA1_Stream0 ((DMA_Stream_TypeDef *) DMA1_Stream0_BASE) #define DMA1_Stream1 ((DMA_Stream_TypeDef *) DMA1_Stream1_BASE) #define DMA1_Stream2 ((DMA_Stream_TypeDef *) DMA1_Stream2_BASE) #define DMA1_Stream3 ((DMA_Stream_TypeDef *) DMA1_Stream3_BASE) #define DMA1_Stream4 ((DMA_Stream_TypeDef *) DMA1_Stream4_BASE) #define DMA1_Stream5 ((DMA_Stream_TypeDef *) DMA1_Stream5_BASE) #define DMA1_Stream6 ((DMA_Stream_TypeDef *) DMA1_Stream6_BASE) #define DMA1_Stream7 ((DMA_Stream_TypeDef *) DMA1_Stream7_BASE) #define DMA2 ((DMA_TypeDef *) DMA2_BASE) #define DMA2_Stream0 ((DMA_Stream_TypeDef *) DMA2_Stream0_BASE) #define DMA2_Stream1 ((DMA_Stream_TypeDef *) DMA2_Stream1_BASE) #define DMA2_Stream2 ((DMA_Stream_TypeDef *) DMA2_Stream2_BASE) #define DMA2_Stream3 ((DMA_Stream_TypeDef *) DMA2_Stream3_BASE) #define DMA2_Stream4 ((DMA_Stream_TypeDef *) DMA2_Stream4_BASE) #define DMA2_Stream5 ((DMA_Stream_TypeDef *) DMA2_Stream5_BASE) #define DMA2_Stream6 ((DMA_Stream_TypeDef *) DMA2_Stream6_BASE) #define DMA2_Stream7 ((DMA_Stream_TypeDef *) DMA2_Stream7_BASE) #define DBGMCU ((DBGMCU_TypeDef *) DBGMCU_BASE) #define USB_OTG_FS ((USB_OTG_GlobalTypeDef *) USB_OTG_FS_PERIPH_BASE) /** * @} */ /** @addtogroup Exported_constants * @{ */ /** @addtogroup Peripheral_Registers_Bits_Definition * @{ */ /******************************************************************************/ /* Peripheral Registers_Bits_Definition */ /******************************************************************************/ /******************************************************************************/ /* */ /* Analog to Digital Converter */ /* */ /******************************************************************************/ /******************** Bit definition for ADC_SR register ********************/ #define ADC_SR_AWD_Pos (0U) #define ADC_SR_AWD_Msk (0x1UL << ADC_SR_AWD_Pos) /*!< 0x00000001 */ #define ADC_SR_AWD ADC_SR_AWD_Msk /*!
© COPYRIGHT(c) 2017 STMicroelectronics
* * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. Neither the name of STMicroelectronics nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ /** @addtogroup CMSIS_Device * @{ */ /** @addtogroup stm32f412rx * @{ */ #ifndef __STM32F412Rx_H #define __STM32F412Rx_H #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ /** @addtogroup Configuration_section_for_CMSIS * @{ */ /** * @brief Configuration of the Cortex-M4 Processor and Core Peripherals */ #define __CM4_REV 0x0001U /*!< Core revision r0p1 */ #define __MPU_PRESENT 1U /*!< STM32F4XX provides an MPU */ #define __NVIC_PRIO_BITS 4U /*!< STM32F4XX uses 4 Bits for the Priority Levels */ #define __Vendor_SysTickConfig 0U /*!< Set to 1 if different SysTick Config is used */ #define __FPU_PRESENT 1U /*!< FPU present */ /** * @} */ /** @addtogroup Peripheral_interrupt_number_definition * @{ */ /** * @brief STM32F4XX Interrupt Number Definition, according to the selected device * in @ref Library_configuration_section */ typedef enum { /****** Cortex-M4 Processor Exceptions Numbers ****************************************************************/ NonMaskableInt_IRQn = -14, /*!< 2 Non Maskable Interrupt */ MemoryManagement_IRQn = -12, /*!< 4 Cortex-M4 Memory Management Interrupt */ BusFault_IRQn = -11, /*!< 5 Cortex-M4 Bus Fault Interrupt */ UsageFault_IRQn = -10, /*!< 6 Cortex-M4 Usage Fault Interrupt */ SVCall_IRQn = -5, /*!< 11 Cortex-M4 SV Call Interrupt */ DebugMonitor_IRQn = -4, /*!< 12 Cortex-M4 Debug Monitor Interrupt */ PendSV_IRQn = -2, /*!< 14 Cortex-M4 Pend SV Interrupt */ SysTick_IRQn = -1, /*!< 15 Cortex-M4 System Tick Interrupt */ /****** STM32 specific Interrupt Numbers **********************************************************************/ WWDG_IRQn = 0, /*!< Window WatchDog Interrupt */ PVD_IRQn = 1, /*!< PVD through EXTI Line detection Interrupt */ TAMP_STAMP_IRQn = 2, /*!< Tamper and TimeStamp interrupts through the EXTI line */ RTC_WKUP_IRQn = 3, /*!< RTC Wakeup interrupt through the EXTI line */ FLASH_IRQn = 4, /*!< FLASH global Interrupt */ RCC_IRQn = 5, /*!< RCC global Interrupt */ EXTI0_IRQn = 6, /*!< EXTI Line0 Interrupt */ EXTI1_IRQn = 7, /*!< EXTI Line1 Interrupt */ EXTI2_IRQn = 8, /*!< EXTI Line2 Interrupt */ EXTI3_IRQn = 9, /*!< EXTI Line3 Interrupt */ EXTI4_IRQn = 10, /*!< EXTI Line4 Interrupt */ DMA1_Stream0_IRQn = 11, /*!< DMA1 Stream 0 global Interrupt */ DMA1_Stream1_IRQn = 12, /*!< DMA1 Stream 1 global Interrupt */ DMA1_Stream2_IRQn = 13, /*!< DMA1 Stream 2 global Interrupt */ DMA1_Stream3_IRQn = 14, /*!< DMA1 Stream 3 global Interrupt */ DMA1_Stream4_IRQn = 15, /*!< DMA1 Stream 4 global Interrupt */ DMA1_Stream5_IRQn = 16, /*!< DMA1 Stream 5 global Interrupt */ DMA1_Stream6_IRQn = 17, /*!< DMA1 Stream 6 global Interrupt */ ADC_IRQn = 18, /*!< ADC1, ADC2 and ADC3 global Interrupts */ CAN1_TX_IRQn = 19, /*!< CAN1 TX Interrupt */ CAN1_RX0_IRQn = 20, /*!< CAN1 RX0 Interrupt */ CAN1_RX1_IRQn = 21, /*!< CAN1 RX1 Interrupt */ CAN1_SCE_IRQn = 22, /*!< CAN1 SCE Interrupt */ EXTI9_5_IRQn = 23, /*!< External Line[9:5] Interrupts */ TIM1_BRK_TIM9_IRQn = 24, /*!< TIM1 Break interrupt and TIM9 global interrupt */ TIM1_UP_TIM10_IRQn = 25, /*!< TIM1 Update Interrupt and TIM10 global interrupt */ TIM1_TRG_COM_TIM11_IRQn = 26, /*!< TIM1 Trigger and Commutation Interrupt and TIM11 global interrupt */ TIM1_CC_IRQn = 27, /*!< TIM1 Capture Compare Interrupt */ TIM2_IRQn = 28, /*!< TIM2 global Interrupt */ TIM3_IRQn = 29, /*!< TIM3 global Interrupt */ TIM4_IRQn = 30, /*!< TIM4 global Interrupt */ I2C1_EV_IRQn = 31, /*!< I2C1 Event Interrupt */ I2C1_ER_IRQn = 32, /*!< I2C1 Error Interrupt */ I2C2_EV_IRQn = 33, /*!< I2C2 Event Interrupt */ I2C2_ER_IRQn = 34, /*!< I2C2 Error Interrupt */ SPI1_IRQn = 35, /*!< SPI1 global Interrupt */ SPI2_IRQn = 36, /*!< SPI2 global Interrupt */ USART1_IRQn = 37, /*!< USART1 global Interrupt */ USART2_IRQn = 38, /*!< USART2 global Interrupt */ USART3_IRQn = 39, /*!< USART3 global Interrupt */ EXTI15_10_IRQn = 40, /*!< External Line[15:10] Interrupts */ RTC_Alarm_IRQn = 41, /*!< RTC Alarm (A and B) through EXTI Line Interrupt */ OTG_FS_WKUP_IRQn = 42, /*!< USB OTG FS Wakeup through EXTI line interrupt */ TIM8_BRK_TIM12_IRQn = 43, /*!< TIM8 Break Interrupt and TIM12 global interrupt */ TIM8_UP_TIM13_IRQn = 44, /*!< TIM8 Update Interrupt and TIM13 global interrupt */ TIM8_TRG_COM_TIM14_IRQn = 45, /*!< TIM8 Trigger and Commutation Interrupt and TIM14 global interrupt */ TIM8_CC_IRQn = 46, /*!< TIM8 Capture Compare global interrupt */ DMA1_Stream7_IRQn = 47, /*!< DMA1 Stream7 Interrupt */ SDIO_IRQn = 49, /*!< SDIO global Interrupt */ TIM5_IRQn = 50, /*!< TIM5 global Interrupt */ SPI3_IRQn = 51, /*!< SPI3 global Interrupt */ TIM6_IRQn = 54, /*!< TIM6 global interrupt */ TIM7_IRQn = 55, /*!< TIM7 global interrupt */ DMA2_Stream0_IRQn = 56, /*!< DMA2 Stream 0 global Interrupt */ DMA2_Stream1_IRQn = 57, /*!< DMA2 Stream 1 global Interrupt */ DMA2_Stream2_IRQn = 58, /*!< DMA2 Stream 2 global Interrupt */ DMA2_Stream3_IRQn = 59, /*!< DMA2 Stream 3 global Interrupt */ DMA2_Stream4_IRQn = 60, /*!< DMA2 Stream 4 global Interrupt */ DFSDM1_FLT0_IRQn = 61, /*!< DFSDM1 Filter 0 global Interrupt */ DFSDM1_FLT1_IRQn = 62, /*!< DFSDM1 Filter 1 global Interrupt */ CAN2_TX_IRQn = 63, /*!< CAN2 TX Interrupt */ CAN2_RX0_IRQn = 64, /*!< CAN2 RX0 Interrupt */ CAN2_RX1_IRQn = 65, /*!< CAN2 RX1 Interrupt */ CAN2_SCE_IRQn = 66, /*!< CAN2 SCE Interrupt */ OTG_FS_IRQn = 67, /*!< USB OTG FS global Interrupt */ DMA2_Stream5_IRQn = 68, /*!< DMA2 Stream 5 global interrupt */ DMA2_Stream6_IRQn = 69, /*!< DMA2 Stream 6 global interrupt */ DMA2_Stream7_IRQn = 70, /*!< DMA2 Stream 7 global interrupt */ USART6_IRQn = 71, /*!< USART6 global interrupt */ I2C3_EV_IRQn = 72, /*!< I2C3 event interrupt */ I2C3_ER_IRQn = 73, /*!< I2C3 error interrupt */ RNG_IRQn = 80, /*!< RNG global Interrupt */ FPU_IRQn = 81, /*!< FPU global interrupt */ SPI4_IRQn = 84, /*!< SPI4 global Interrupt */ SPI5_IRQn = 85, /*!< SPI5 global Interrupt */ QUADSPI_IRQn = 92, /*!< QuadSPI global Interrupt */ FMPI2C1_EV_IRQn = 95, /*!< FMPI2C1 Event Interrupt */ FMPI2C1_ER_IRQn = 96 /*!< FMPI2C1 Error Interrupt */ } IRQn_Type; /** * @} */ #include "core_cm4.h" /* Cortex-M4 processor and core peripherals */ #include "system_stm32f4xx.h" #include /** @addtogroup Peripheral_registers_structures * @{ */ /** * @brief Analog to Digital Converter */ typedef struct { __IO uint32_t SR; /*!< ADC status register, Address offset: 0x00 */ __IO uint32_t CR1; /*!< ADC control register 1, Address offset: 0x04 */ __IO uint32_t CR2; /*!< ADC control register 2, Address offset: 0x08 */ __IO uint32_t SMPR1; /*!< ADC sample time register 1, Address offset: 0x0C */ __IO uint32_t SMPR2; /*!< ADC sample time register 2, Address offset: 0x10 */ __IO uint32_t JOFR1; /*!< ADC injected channel data offset register 1, Address offset: 0x14 */ __IO uint32_t JOFR2; /*!< ADC injected channel data offset register 2, Address offset: 0x18 */ __IO uint32_t JOFR3; /*!< ADC injected channel data offset register 3, Address offset: 0x1C */ __IO uint32_t JOFR4; /*!< ADC injected channel data offset register 4, Address offset: 0x20 */ __IO uint32_t HTR; /*!< ADC watchdog higher threshold register, Address offset: 0x24 */ __IO uint32_t LTR; /*!< ADC watchdog lower threshold register, Address offset: 0x28 */ __IO uint32_t SQR1; /*!< ADC regular sequence register 1, Address offset: 0x2C */ __IO uint32_t SQR2; /*!< ADC regular sequence register 2, Address offset: 0x30 */ __IO uint32_t SQR3; /*!< ADC regular sequence register 3, Address offset: 0x34 */ __IO uint32_t JSQR; /*!< ADC injected sequence register, Address offset: 0x38*/ __IO uint32_t JDR1; /*!< ADC injected data register 1, Address offset: 0x3C */ __IO uint32_t JDR2; /*!< ADC injected data register 2, Address offset: 0x40 */ __IO uint32_t JDR3; /*!< ADC injected data register 3, Address offset: 0x44 */ __IO uint32_t JDR4; /*!< ADC injected data register 4, Address offset: 0x48 */ __IO uint32_t DR; /*!< ADC regular data register, Address offset: 0x4C */ } ADC_TypeDef; typedef struct { __IO uint32_t CSR; /*!< ADC Common status register, Address offset: ADC1 base address + 0x300 */ __IO uint32_t CCR; /*!< ADC common control register, Address offset: ADC1 base address + 0x304 */ __IO uint32_t CDR; /*!< ADC common regular data register for dual AND triple modes, Address offset: ADC1 base address + 0x308 */ } ADC_Common_TypeDef; /** * @brief Controller Area Network TxMailBox */ typedef struct { __IO uint32_t TIR; /*!< CAN TX mailbox identifier register */ __IO uint32_t TDTR; /*!< CAN mailbox data length control and time stamp register */ __IO uint32_t TDLR; /*!< CAN mailbox data low register */ __IO uint32_t TDHR; /*!< CAN mailbox data high register */ } CAN_TxMailBox_TypeDef; /** * @brief Controller Area Network FIFOMailBox */ typedef struct { __IO uint32_t RIR; /*!< CAN receive FIFO mailbox identifier register */ __IO uint32_t RDTR; /*!< CAN receive FIFO mailbox data length control and time stamp register */ __IO uint32_t RDLR; /*!< CAN receive FIFO mailbox data low register */ __IO uint32_t RDHR; /*!< CAN receive FIFO mailbox data high register */ } CAN_FIFOMailBox_TypeDef; /** * @brief Controller Area Network FilterRegister */ typedef struct { __IO uint32_t FR1; /*!< CAN Filter bank register 1 */ __IO uint32_t FR2; /*!< CAN Filter bank register 1 */ } CAN_FilterRegister_TypeDef; /** * @brief Controller Area Network */ typedef struct { __IO uint32_t MCR; /*!< CAN master control register, Address offset: 0x00 */ __IO uint32_t MSR; /*!< CAN master status register, Address offset: 0x04 */ __IO uint32_t TSR; /*!< CAN transmit status register, Address offset: 0x08 */ __IO uint32_t RF0R; /*!< CAN receive FIFO 0 register, Address offset: 0x0C */ __IO uint32_t RF1R; /*!< CAN receive FIFO 1 register, Address offset: 0x10 */ __IO uint32_t IER; /*!< CAN interrupt enable register, Address offset: 0x14 */ __IO uint32_t ESR; /*!< CAN error status register, Address offset: 0x18 */ __IO uint32_t BTR; /*!< CAN bit timing register, Address offset: 0x1C */ uint32_t RESERVED0[88]; /*!< Reserved, 0x020 - 0x17F */ CAN_TxMailBox_TypeDef sTxMailBox[3]; /*!< CAN Tx MailBox, Address offset: 0x180 - 0x1AC */ CAN_FIFOMailBox_TypeDef sFIFOMailBox[2]; /*!< CAN FIFO MailBox, Address offset: 0x1B0 - 0x1CC */ uint32_t RESERVED1[12]; /*!< Reserved, 0x1D0 - 0x1FF */ __IO uint32_t FMR; /*!< CAN filter master register, Address offset: 0x200 */ __IO uint32_t FM1R; /*!< CAN filter mode register, Address offset: 0x204 */ uint32_t RESERVED2; /*!< Reserved, 0x208 */ __IO uint32_t FS1R; /*!< CAN filter scale register, Address offset: 0x20C */ uint32_t RESERVED3; /*!< Reserved, 0x210 */ __IO uint32_t FFA1R; /*!< CAN filter FIFO assignment register, Address offset: 0x214 */ uint32_t RESERVED4; /*!< Reserved, 0x218 */ __IO uint32_t FA1R; /*!< CAN filter activation register, Address offset: 0x21C */ uint32_t RESERVED5[8]; /*!< Reserved, 0x220-0x23F */ CAN_FilterRegister_TypeDef sFilterRegister[28]; /*!< CAN Filter Register, Address offset: 0x240-0x31C */ } CAN_TypeDef; /** * @brief CRC calculation unit */ typedef struct { __IO uint32_t DR; /*!< CRC Data register, Address offset: 0x00 */ __IO uint8_t IDR; /*!< CRC Independent data register, Address offset: 0x04 */ uint8_t RESERVED0; /*!< Reserved, 0x05 */ uint16_t RESERVED1; /*!< Reserved, 0x06 */ __IO uint32_t CR; /*!< CRC Control register, Address offset: 0x08 */ } CRC_TypeDef; /** * @brief DFSDM module registers */ typedef struct { __IO uint32_t FLTCR1; /*!< DFSDM control register1, Address offset: 0x100 */ __IO uint32_t FLTCR2; /*!< DFSDM control register2, Address offset: 0x104 */ __IO uint32_t FLTISR; /*!< DFSDM interrupt and status register, Address offset: 0x108 */ __IO uint32_t FLTICR; /*!< DFSDM interrupt flag clear register, Address offset: 0x10C */ __IO uint32_t FLTJCHGR; /*!< DFSDM injected channel group selection register, Address offset: 0x110 */ __IO uint32_t FLTFCR; /*!< DFSDM filter control register, Address offset: 0x114 */ __IO uint32_t FLTJDATAR; /*!< DFSDM data register for injected group, Address offset: 0x118 */ __IO uint32_t FLTRDATAR; /*!< DFSDM data register for regular group, Address offset: 0x11C */ __IO uint32_t FLTAWHTR; /*!< DFSDM analog watchdog high threshold register, Address offset: 0x120 */ __IO uint32_t FLTAWLTR; /*!< DFSDM analog watchdog low threshold register, Address offset: 0x124 */ __IO uint32_t FLTAWSR; /*!< DFSDM analog watchdog status register Address offset: 0x128 */ __IO uint32_t FLTAWCFR; /*!< DFSDM analog watchdog clear flag register Address offset: 0x12C */ __IO uint32_t FLTEXMAX; /*!< DFSDM extreme detector maximum register, Address offset: 0x130 */ __IO uint32_t FLTEXMIN; /*!< DFSDM extreme detector minimum register Address offset: 0x134 */ __IO uint32_t FLTCNVTIMR; /*!< DFSDM conversion timer, Address offset: 0x138 */ } DFSDM_Filter_TypeDef; /** * @brief DFSDM channel configuration registers */ typedef struct { __IO uint32_t CHCFGR1; /*!< DFSDM channel configuration register1, Address offset: 0x00 */ __IO uint32_t CHCFGR2; /*!< DFSDM channel configuration register2, Address offset: 0x04 */ __IO uint32_t CHAWSCDR; /*!< DFSDM channel analog watchdog and short circuit detector register, Address offset: 0x08 */ __IO uint32_t CHWDATAR; /*!< DFSDM channel watchdog filter data register, Address offset: 0x0C */ __IO uint32_t CHDATINR; /*!< DFSDM channel data input register, Address offset: 0x10 */ } DFSDM_Channel_TypeDef; /** * @brief Debug MCU */ typedef struct { __IO uint32_t IDCODE; /*!< MCU device ID code, Address offset: 0x00 */ __IO uint32_t CR; /*!< Debug MCU configuration register, Address offset: 0x04 */ __IO uint32_t APB1FZ; /*!< Debug MCU APB1 freeze register, Address offset: 0x08 */ __IO uint32_t APB2FZ; /*!< Debug MCU APB2 freeze register, Address offset: 0x0C */ }DBGMCU_TypeDef; /** * @brief DMA Controller */ typedef struct { __IO uint32_t CR; /*!< DMA stream x configuration register */ __IO uint32_t NDTR; /*!< DMA stream x number of data register */ __IO uint32_t PAR; /*!< DMA stream x peripheral address register */ __IO uint32_t M0AR; /*!< DMA stream x memory 0 address register */ __IO uint32_t M1AR; /*!< DMA stream x memory 1 address register */ __IO uint32_t FCR; /*!< DMA stream x FIFO control register */ } DMA_Stream_TypeDef; typedef struct { __IO uint32_t LISR; /*!< DMA low interrupt status register, Address offset: 0x00 */ __IO uint32_t HISR; /*!< DMA high interrupt status register, Address offset: 0x04 */ __IO uint32_t LIFCR; /*!< DMA low interrupt flag clear register, Address offset: 0x08 */ __IO uint32_t HIFCR; /*!< DMA high interrupt flag clear register, Address offset: 0x0C */ } DMA_TypeDef; /** * @brief External Interrupt/Event Controller */ typedef struct { __IO uint32_t IMR; /*!< EXTI Interrupt mask register, Address offset: 0x00 */ __IO uint32_t EMR; /*!< EXTI Event mask register, Address offset: 0x04 */ __IO uint32_t RTSR; /*!< EXTI Rising trigger selection register, Address offset: 0x08 */ __IO uint32_t FTSR; /*!< EXTI Falling trigger selection register, Address offset: 0x0C */ __IO uint32_t SWIER; /*!< EXTI Software interrupt event register, Address offset: 0x10 */ __IO uint32_t PR; /*!< EXTI Pending register, Address offset: 0x14 */ } EXTI_TypeDef; /** * @brief FLASH Registers */ typedef struct { __IO uint32_t ACR; /*!< FLASH access control register, Address offset: 0x00 */ __IO uint32_t KEYR; /*!< FLASH key register, Address offset: 0x04 */ __IO uint32_t OPTKEYR; /*!< FLASH option key register, Address offset: 0x08 */ __IO uint32_t SR; /*!< FLASH status register, Address offset: 0x0C */ __IO uint32_t CR; /*!< FLASH control register, Address offset: 0x10 */ __IO uint32_t OPTCR; /*!< FLASH option control register , Address offset: 0x14 */ __IO uint32_t OPTCR1; /*!< FLASH option control register 1, Address offset: 0x18 */ } FLASH_TypeDef; /** * @brief Flexible Static Memory Controller */ typedef struct { __IO uint32_t BTCR[8]; /*!< NOR/PSRAM chip-select control register(BCR) and chip-select timing register(BTR), Address offset: 0x00-1C */ } FSMC_Bank1_TypeDef; /** * @brief Flexible Static Memory Controller Bank1E */ typedef struct { __IO uint32_t BWTR[7]; /*!< NOR/PSRAM write timing registers, Address offset: 0x104-0x11C */ } FSMC_Bank1E_TypeDef; /** * @brief General Purpose I/O */ typedef struct { __IO uint32_t MODER; /*!< GPIO port mode register, Address offset: 0x00 */ __IO uint32_t OTYPER; /*!< GPIO port output type register, Address offset: 0x04 */ __IO uint32_t OSPEEDR; /*!< GPIO port output speed register, Address offset: 0x08 */ __IO uint32_t PUPDR; /*!< GPIO port pull-up/pull-down register, Address offset: 0x0C */ __IO uint32_t IDR; /*!< GPIO port input data register, Address offset: 0x10 */ __IO uint32_t ODR; /*!< GPIO port output data register, Address offset: 0x14 */ __IO uint32_t BSRR; /*!< GPIO port bit set/reset register, Address offset: 0x18 */ __IO uint32_t LCKR; /*!< GPIO port configuration lock register, Address offset: 0x1C */ __IO uint32_t AFR[2]; /*!< GPIO alternate function registers, Address offset: 0x20-0x24 */ } GPIO_TypeDef; /** * @brief System configuration controller */ typedef struct { __IO uint32_t MEMRMP; /*!< SYSCFG memory remap register, Address offset: 0x00 */ __IO uint32_t PMC; /*!< SYSCFG peripheral mode configuration register, Address offset: 0x04 */ __IO uint32_t EXTICR[4]; /*!< SYSCFG external interrupt configuration registers, Address offset: 0x08-0x14 */ uint32_t RESERVED; /*!< Reserved, 0x18 */ __IO uint32_t CFGR2; /*!< SYSCFG Configuration register2, Address offset: 0x1C */ __IO uint32_t CMPCR; /*!< SYSCFG Compensation cell control register, Address offset: 0x20 */ __IO uint32_t CFGR; /*!< SYSCFG Configuration register, Address offset: 0x24 */ } SYSCFG_TypeDef; /** * @brief Inter-integrated Circuit Interface */ typedef struct { __IO uint32_t CR1; /*!< I2C Control register 1, Address offset: 0x00 */ __IO uint32_t CR2; /*!< I2C Control register 2, Address offset: 0x04 */ __IO uint32_t OAR1; /*!< I2C Own address register 1, Address offset: 0x08 */ __IO uint32_t OAR2; /*!< I2C Own address register 2, Address offset: 0x0C */ __IO uint32_t DR; /*!< I2C Data register, Address offset: 0x10 */ __IO uint32_t SR1; /*!< I2C Status register 1, Address offset: 0x14 */ __IO uint32_t SR2; /*!< I2C Status register 2, Address offset: 0x18 */ __IO uint32_t CCR; /*!< I2C Clock control register, Address offset: 0x1C */ __IO uint32_t TRISE; /*!< I2C TRISE register, Address offset: 0x20 */ __IO uint32_t FLTR; /*!< I2C FLTR register, Address offset: 0x24 */ } I2C_TypeDef; /** * @brief Inter-integrated Circuit Interface */ typedef struct { __IO uint32_t CR1; /*!< FMPI2C Control register 1, Address offset: 0x00 */ __IO uint32_t CR2; /*!< FMPI2C Control register 2, Address offset: 0x04 */ __IO uint32_t OAR1; /*!< FMPI2C Own address 1 register, Address offset: 0x08 */ __IO uint32_t OAR2; /*!< FMPI2C Own address 2 register, Address offset: 0x0C */ __IO uint32_t TIMINGR; /*!< FMPI2C Timing register, Address offset: 0x10 */ __IO uint32_t TIMEOUTR; /*!< FMPI2C Timeout register, Address offset: 0x14 */ __IO uint32_t ISR; /*!< FMPI2C Interrupt and status register, Address offset: 0x18 */ __IO uint32_t ICR; /*!< FMPI2C Interrupt clear register, Address offset: 0x1C */ __IO uint32_t PECR; /*!< FMPI2C PEC register, Address offset: 0x20 */ __IO uint32_t RXDR; /*!< FMPI2C Receive data register, Address offset: 0x24 */ __IO uint32_t TXDR; /*!< FMPI2C Transmit data register, Address offset: 0x28 */ } FMPI2C_TypeDef; /** * @brief Independent WATCHDOG */ typedef struct { __IO uint32_t KR; /*!< IWDG Key register, Address offset: 0x00 */ __IO uint32_t PR; /*!< IWDG Prescaler register, Address offset: 0x04 */ __IO uint32_t RLR; /*!< IWDG Reload register, Address offset: 0x08 */ __IO uint32_t SR; /*!< IWDG Status register, Address offset: 0x0C */ } IWDG_TypeDef; /** * @brief Power Control */ typedef struct { __IO uint32_t CR; /*!< PWR power control register, Address offset: 0x00 */ __IO uint32_t CSR; /*!< PWR power control/status register, Address offset: 0x04 */ } PWR_TypeDef; /** * @brief Reset and Clock Control */ typedef struct { __IO uint32_t CR; /*!< RCC clock control register, Address offset: 0x00 */ __IO uint32_t PLLCFGR; /*!< RCC PLL configuration register, Address offset: 0x04 */ __IO uint32_t CFGR; /*!< RCC clock configuration register, Address offset: 0x08 */ __IO uint32_t CIR; /*!< RCC clock interrupt register, Address offset: 0x0C */ __IO uint32_t AHB1RSTR; /*!< RCC AHB1 peripheral reset register, Address offset: 0x10 */ __IO uint32_t AHB2RSTR; /*!< RCC AHB2 peripheral reset register, Address offset: 0x14 */ __IO uint32_t AHB3RSTR; /*!< RCC AHB3 peripheral reset register, Address offset: 0x18 */ uint32_t RESERVED0; /*!< Reserved, 0x1C */ __IO uint32_t APB1RSTR; /*!< RCC APB1 peripheral reset register, Address offset: 0x20 */ __IO uint32_t APB2RSTR; /*!< RCC APB2 peripheral reset register, Address offset: 0x24 */ uint32_t RESERVED1[2]; /*!< Reserved, 0x28-0x2C */ __IO uint32_t AHB1ENR; /*!< RCC AHB1 peripheral clock register, Address offset: 0x30 */ __IO uint32_t AHB2ENR; /*!< RCC AHB2 peripheral clock register, Address offset: 0x34 */ __IO uint32_t AHB3ENR; /*!< RCC AHB3 peripheral clock register, Address offset: 0x38 */ uint32_t RESERVED2; /*!< Reserved, 0x3C */ __IO uint32_t APB1ENR; /*!< RCC APB1 peripheral clock enable register, Address offset: 0x40 */ __IO uint32_t APB2ENR; /*!< RCC APB2 peripheral clock enable register, Address offset: 0x44 */ uint32_t RESERVED3[2]; /*!< Reserved, 0x48-0x4C */ __IO uint32_t AHB1LPENR; /*!< RCC AHB1 peripheral clock enable in low power mode register, Address offset: 0x50 */ __IO uint32_t AHB2LPENR; /*!< RCC AHB2 peripheral clock enable in low power mode register, Address offset: 0x54 */ __IO uint32_t AHB3LPENR; /*!< RCC AHB3 peripheral clock enable in low power mode register, Address offset: 0x58 */ uint32_t RESERVED4; /*!< Reserved, 0x5C */ __IO uint32_t APB1LPENR; /*!< RCC APB1 peripheral clock enable in low power mode register, Address offset: 0x60 */ __IO uint32_t APB2LPENR; /*!< RCC APB2 peripheral clock enable in low power mode register, Address offset: 0x64 */ uint32_t RESERVED5[2]; /*!< Reserved, 0x68-0x6C */ __IO uint32_t BDCR; /*!< RCC Backup domain control register, Address offset: 0x70 */ __IO uint32_t CSR; /*!< RCC clock control & status register, Address offset: 0x74 */ uint32_t RESERVED6[2]; /*!< Reserved, 0x78-0x7C */ __IO uint32_t SSCGR; /*!< RCC spread spectrum clock generation register, Address offset: 0x80 */ __IO uint32_t PLLI2SCFGR; /*!< RCC PLLI2S configuration register, Address offset: 0x84 */ uint32_t RESERVED7; /*!< Reserved, 0x88 */ __IO uint32_t DCKCFGR; /*!< RCC Dedicated Clocks configuration register, Address offset: 0x8C */ __IO uint32_t CKGATENR; /*!< RCC Clocks Gated ENable Register, Address offset: 0x90 */ __IO uint32_t DCKCFGR2; /*!< RCC Dedicated Clocks configuration register 2, Address offset: 0x94 */ } RCC_TypeDef; /** * @brief Real-Time Clock */ typedef struct { __IO uint32_t TR; /*!< RTC time register, Address offset: 0x00 */ __IO uint32_t DR; /*!< RTC date register, Address offset: 0x04 */ __IO uint32_t CR; /*!< RTC control register, Address offset: 0x08 */ __IO uint32_t ISR; /*!< RTC initialization and status register, Address offset: 0x0C */ __IO uint32_t PRER; /*!< RTC prescaler register, Address offset: 0x10 */ __IO uint32_t WUTR; /*!< RTC wakeup timer register, Address offset: 0x14 */ __IO uint32_t CALIBR; /*!< RTC calibration register, Address offset: 0x18 */ __IO uint32_t ALRMAR; /*!< RTC alarm A register, Address offset: 0x1C */ __IO uint32_t ALRMBR; /*!< RTC alarm B register, Address offset: 0x20 */ __IO uint32_t WPR; /*!< RTC write protection register, Address offset: 0x24 */ __IO uint32_t SSR; /*!< RTC sub second register, Address offset: 0x28 */ __IO uint32_t SHIFTR; /*!< RTC shift control register, Address offset: 0x2C */ __IO uint32_t TSTR; /*!< RTC time stamp time register, Address offset: 0x30 */ __IO uint32_t TSDR; /*!< RTC time stamp date register, Address offset: 0x34 */ __IO uint32_t TSSSR; /*!< RTC time-stamp sub second register, Address offset: 0x38 */ __IO uint32_t CALR; /*!< RTC calibration register, Address offset: 0x3C */ __IO uint32_t TAFCR; /*!< RTC tamper and alternate function configuration register, Address offset: 0x40 */ __IO uint32_t ALRMASSR;/*!< RTC alarm A sub second register, Address offset: 0x44 */ __IO uint32_t ALRMBSSR;/*!< RTC alarm B sub second register, Address offset: 0x48 */ uint32_t RESERVED7; /*!< Reserved, 0x4C */ __IO uint32_t BKP0R; /*!< RTC backup register 1, Address offset: 0x50 */ __IO uint32_t BKP1R; /*!< RTC backup register 1, Address offset: 0x54 */ __IO uint32_t BKP2R; /*!< RTC backup register 2, Address offset: 0x58 */ __IO uint32_t BKP3R; /*!< RTC backup register 3, Address offset: 0x5C */ __IO uint32_t BKP4R; /*!< RTC backup register 4, Address offset: 0x60 */ __IO uint32_t BKP5R; /*!< RTC backup register 5, Address offset: 0x64 */ __IO uint32_t BKP6R; /*!< RTC backup register 6, Address offset: 0x68 */ __IO uint32_t BKP7R; /*!< RTC backup register 7, Address offset: 0x6C */ __IO uint32_t BKP8R; /*!< RTC backup register 8, Address offset: 0x70 */ __IO uint32_t BKP9R; /*!< RTC backup register 9, Address offset: 0x74 */ __IO uint32_t BKP10R; /*!< RTC backup register 10, Address offset: 0x78 */ __IO uint32_t BKP11R; /*!< RTC backup register 11, Address offset: 0x7C */ __IO uint32_t BKP12R; /*!< RTC backup register 12, Address offset: 0x80 */ __IO uint32_t BKP13R; /*!< RTC backup register 13, Address offset: 0x84 */ __IO uint32_t BKP14R; /*!< RTC backup register 14, Address offset: 0x88 */ __IO uint32_t BKP15R; /*!< RTC backup register 15, Address offset: 0x8C */ __IO uint32_t BKP16R; /*!< RTC backup register 16, Address offset: 0x90 */ __IO uint32_t BKP17R; /*!< RTC backup register 17, Address offset: 0x94 */ __IO uint32_t BKP18R; /*!< RTC backup register 18, Address offset: 0x98 */ __IO uint32_t BKP19R; /*!< RTC backup register 19, Address offset: 0x9C */ } RTC_TypeDef; /** * @brief SD host Interface */ typedef struct { __IO uint32_t POWER; /*!< SDIO power control register, Address offset: 0x00 */ __IO uint32_t CLKCR; /*!< SDI clock control register, Address offset: 0x04 */ __IO uint32_t ARG; /*!< SDIO argument register, Address offset: 0x08 */ __IO uint32_t CMD; /*!< SDIO command register, Address offset: 0x0C */ __IO const uint32_t RESPCMD; /*!< SDIO command response register, Address offset: 0x10 */ __IO const uint32_t RESP1; /*!< SDIO response 1 register, Address offset: 0x14 */ __IO const uint32_t RESP2; /*!< SDIO response 2 register, Address offset: 0x18 */ __IO const uint32_t RESP3; /*!< SDIO response 3 register, Address offset: 0x1C */ __IO const uint32_t RESP4; /*!< SDIO response 4 register, Address offset: 0x20 */ __IO uint32_t DTIMER; /*!< SDIO data timer register, Address offset: 0x24 */ __IO uint32_t DLEN; /*!< SDIO data length register, Address offset: 0x28 */ __IO uint32_t DCTRL; /*!< SDIO data control register, Address offset: 0x2C */ __IO const uint32_t DCOUNT; /*!< SDIO data counter register, Address offset: 0x30 */ __IO const uint32_t STA; /*!< SDIO status register, Address offset: 0x34 */ __IO uint32_t ICR; /*!< SDIO interrupt clear register, Address offset: 0x38 */ __IO uint32_t MASK; /*!< SDIO mask register, Address offset: 0x3C */ uint32_t RESERVED0[2]; /*!< Reserved, 0x40-0x44 */ __IO const uint32_t FIFOCNT; /*!< SDIO FIFO counter register, Address offset: 0x48 */ uint32_t RESERVED1[13]; /*!< Reserved, 0x4C-0x7C */ __IO uint32_t FIFO; /*!< SDIO data FIFO register, Address offset: 0x80 */ } SDIO_TypeDef; /** * @brief Serial Peripheral Interface */ typedef struct { __IO uint32_t CR1; /*!< SPI control register 1 (not used in I2S mode), Address offset: 0x00 */ __IO uint32_t CR2; /*!< SPI control register 2, Address offset: 0x04 */ __IO uint32_t SR; /*!< SPI status register, Address offset: 0x08 */ __IO uint32_t DR; /*!< SPI data register, Address offset: 0x0C */ __IO uint32_t CRCPR; /*!< SPI CRC polynomial register (not used in I2S mode), Address offset: 0x10 */ __IO uint32_t RXCRCR; /*!< SPI RX CRC register (not used in I2S mode), Address offset: 0x14 */ __IO uint32_t TXCRCR; /*!< SPI TX CRC register (not used in I2S mode), Address offset: 0x18 */ __IO uint32_t I2SCFGR; /*!< SPI_I2S configuration register, Address offset: 0x1C */ __IO uint32_t I2SPR; /*!< SPI_I2S prescaler register, Address offset: 0x20 */ } SPI_TypeDef; /** * @brief QUAD Serial Peripheral Interface */ typedef struct { __IO uint32_t CR; /*!< QUADSPI Control register, Address offset: 0x00 */ __IO uint32_t DCR; /*!< QUADSPI Device Configuration register, Address offset: 0x04 */ __IO uint32_t SR; /*!< QUADSPI Status register, Address offset: 0x08 */ __IO uint32_t FCR; /*!< QUADSPI Flag Clear register, Address offset: 0x0C */ __IO uint32_t DLR; /*!< QUADSPI Data Length register, Address offset: 0x10 */ __IO uint32_t CCR; /*!< QUADSPI Communication Configuration register, Address offset: 0x14 */ __IO uint32_t AR; /*!< QUADSPI Address register, Address offset: 0x18 */ __IO uint32_t ABR; /*!< QUADSPI Alternate Bytes register, Address offset: 0x1C */ __IO uint32_t DR; /*!< QUADSPI Data register, Address offset: 0x20 */ __IO uint32_t PSMKR; /*!< QUADSPI Polling Status Mask register, Address offset: 0x24 */ __IO uint32_t PSMAR; /*!< QUADSPI Polling Status Match register, Address offset: 0x28 */ __IO uint32_t PIR; /*!< QUADSPI Polling Interval register, Address offset: 0x2C */ __IO uint32_t LPTR; /*!< QUADSPI Low Power Timeout register, Address offset: 0x30 */ } QUADSPI_TypeDef; /** * @brief TIM */ typedef struct { __IO uint32_t CR1; /*!< TIM control register 1, Address offset: 0x00 */ __IO uint32_t CR2; /*!< TIM control register 2, Address offset: 0x04 */ __IO uint32_t SMCR; /*!< TIM slave mode control register, Address offset: 0x08 */ __IO uint32_t DIER; /*!< TIM DMA/interrupt enable register, Address offset: 0x0C */ __IO uint32_t SR; /*!< TIM status register, Address offset: 0x10 */ __IO uint32_t EGR; /*!< TIM event generation register, Address offset: 0x14 */ __IO uint32_t CCMR1; /*!< TIM capture/compare mode register 1, Address offset: 0x18 */ __IO uint32_t CCMR2; /*!< TIM capture/compare mode register 2, Address offset: 0x1C */ __IO uint32_t CCER; /*!< TIM capture/compare enable register, Address offset: 0x20 */ __IO uint32_t CNT; /*!< TIM counter register, Address offset: 0x24 */ __IO uint32_t PSC; /*!< TIM prescaler, Address offset: 0x28 */ __IO uint32_t ARR; /*!< TIM auto-reload register, Address offset: 0x2C */ __IO uint32_t RCR; /*!< TIM repetition counter register, Address offset: 0x30 */ __IO uint32_t CCR1; /*!< TIM capture/compare register 1, Address offset: 0x34 */ __IO uint32_t CCR2; /*!< TIM capture/compare register 2, Address offset: 0x38 */ __IO uint32_t CCR3; /*!< TIM capture/compare register 3, Address offset: 0x3C */ __IO uint32_t CCR4; /*!< TIM capture/compare register 4, Address offset: 0x40 */ __IO uint32_t BDTR; /*!< TIM break and dead-time register, Address offset: 0x44 */ __IO uint32_t DCR; /*!< TIM DMA control register, Address offset: 0x48 */ __IO uint32_t DMAR; /*!< TIM DMA address for full transfer, Address offset: 0x4C */ __IO uint32_t OR; /*!< TIM option register, Address offset: 0x50 */ } TIM_TypeDef; /** * @brief Universal Synchronous Asynchronous Receiver Transmitter */ typedef struct { __IO uint32_t SR; /*!< USART Status register, Address offset: 0x00 */ __IO uint32_t DR; /*!< USART Data register, Address offset: 0x04 */ __IO uint32_t BRR; /*!< USART Baud rate register, Address offset: 0x08 */ __IO uint32_t CR1; /*!< USART Control register 1, Address offset: 0x0C */ __IO uint32_t CR2; /*!< USART Control register 2, Address offset: 0x10 */ __IO uint32_t CR3; /*!< USART Control register 3, Address offset: 0x14 */ __IO uint32_t GTPR; /*!< USART Guard time and prescaler register, Address offset: 0x18 */ } USART_TypeDef; /** * @brief Window WATCHDOG */ typedef struct { __IO uint32_t CR; /*!< WWDG Control register, Address offset: 0x00 */ __IO uint32_t CFR; /*!< WWDG Configuration register, Address offset: 0x04 */ __IO uint32_t SR; /*!< WWDG Status register, Address offset: 0x08 */ } WWDG_TypeDef; /** * @brief RNG */ typedef struct { __IO uint32_t CR; /*!< RNG control register, Address offset: 0x00 */ __IO uint32_t SR; /*!< RNG status register, Address offset: 0x04 */ __IO uint32_t DR; /*!< RNG data register, Address offset: 0x08 */ } RNG_TypeDef; /** * @brief USB_OTG_Core_Registers */ typedef struct { __IO uint32_t GOTGCTL; /*!< USB_OTG Control and Status Register 000h */ __IO uint32_t GOTGINT; /*!< USB_OTG Interrupt Register 004h */ __IO uint32_t GAHBCFG; /*!< Core AHB Configuration Register 008h */ __IO uint32_t GUSBCFG; /*!< Core USB Configuration Register 00Ch */ __IO uint32_t GRSTCTL; /*!< Core Reset Register 010h */ __IO uint32_t GINTSTS; /*!< Core Interrupt Register 014h */ __IO uint32_t GINTMSK; /*!< Core Interrupt Mask Register 018h */ __IO uint32_t GRXSTSR; /*!< Receive Sts Q Read Register 01Ch */ __IO uint32_t GRXSTSP; /*!< Receive Sts Q Read & POP Register 020h */ __IO uint32_t GRXFSIZ; /*!< Receive FIFO Size Register 024h */ __IO uint32_t DIEPTXF0_HNPTXFSIZ; /*!< EP0 / Non Periodic Tx FIFO Size Register 028h */ __IO uint32_t HNPTXSTS; /*!< Non Periodic Tx FIFO/Queue Sts reg 02Ch */ uint32_t Reserved30[2]; /*!< Reserved 030h */ __IO uint32_t GCCFG; /*!< General Purpose IO Register 038h */ __IO uint32_t CID; /*!< User ID Register 03Ch */ uint32_t Reserved5[3]; /*!< Reserved 040h-048h */ __IO uint32_t GHWCFG3; /*!< User HW config3 04Ch */ uint32_t Reserved6; /*!< Reserved 050h */ __IO uint32_t GLPMCFG; /*!< LPM Register 054h */ uint32_t Reserved; /*!< Reserved 058h */ __IO uint32_t GDFIFOCFG; /*!< DFIFO Software Config Register 05Ch */ uint32_t Reserved43[40]; /*!< Reserved 058h-0FFh */ __IO uint32_t HPTXFSIZ; /*!< Host Periodic Tx FIFO Size Reg 100h */ __IO uint32_t DIEPTXF[0x0F]; /*!< dev Periodic Transmit FIFO */ } USB_OTG_GlobalTypeDef; /** * @brief USB_OTG_device_Registers */ typedef struct { __IO uint32_t DCFG; /*!< dev Configuration Register 800h */ __IO uint32_t DCTL; /*!< dev Control Register 804h */ __IO uint32_t DSTS; /*!< dev Status Register (RO) 808h */ uint32_t Reserved0C; /*!< Reserved 80Ch */ __IO uint32_t DIEPMSK; /*!< dev IN Endpoint Mask 810h */ __IO uint32_t DOEPMSK; /*!< dev OUT Endpoint Mask 814h */ __IO uint32_t DAINT; /*!< dev All Endpoints Itr Reg 818h */ __IO uint32_t DAINTMSK; /*!< dev All Endpoints Itr Mask 81Ch */ uint32_t Reserved20; /*!< Reserved 820h */ uint32_t Reserved9; /*!< Reserved 824h */ __IO uint32_t DVBUSDIS; /*!< dev VBUS discharge Register 828h */ __IO uint32_t DVBUSPULSE; /*!< dev VBUS Pulse Register 82Ch */ __IO uint32_t DTHRCTL; /*!< dev threshold 830h */ __IO uint32_t DIEPEMPMSK; /*!< dev empty msk 834h */ __IO uint32_t DEACHINT; /*!< dedicated EP interrupt 838h */ __IO uint32_t DEACHMSK; /*!< dedicated EP msk 83Ch */ uint32_t Reserved40; /*!< dedicated EP mask 840h */ __IO uint32_t DINEP1MSK; /*!< dedicated EP mask 844h */ uint32_t Reserved44[15]; /*!< Reserved 844-87Ch */ __IO uint32_t DOUTEP1MSK; /*!< dedicated EP msk 884h */ } USB_OTG_DeviceTypeDef; /** * @brief USB_OTG_IN_Endpoint-Specific_Register */ typedef struct { __IO uint32_t DIEPCTL; /*!< dev IN Endpoint Control Reg 900h + (ep_num * 20h) + 00h */ uint32_t Reserved04; /*!< Reserved 900h + (ep_num * 20h) + 04h */ __IO uint32_t DIEPINT; /*!< dev IN Endpoint Itr Reg 900h + (ep_num * 20h) + 08h */ uint32_t Reserved0C; /*!< Reserved 900h + (ep_num * 20h) + 0Ch */ __IO uint32_t DIEPTSIZ; /*!< IN Endpoint Txfer Size 900h + (ep_num * 20h) + 10h */ __IO uint32_t DIEPDMA; /*!< IN Endpoint DMA Address Reg 900h + (ep_num * 20h) + 14h */ __IO uint32_t DTXFSTS; /*!< IN Endpoint Tx FIFO Status Reg 900h + (ep_num * 20h) + 18h */ uint32_t Reserved18; /*!< Reserved 900h+(ep_num*20h)+1Ch-900h+ (ep_num * 20h) + 1Ch */ } USB_OTG_INEndpointTypeDef; /** * @brief USB_OTG_OUT_Endpoint-Specific_Registers */ typedef struct { __IO uint32_t DOEPCTL; /*!< dev OUT Endpoint Control Reg B00h + (ep_num * 20h) + 00h */ uint32_t Reserved04; /*!< Reserved B00h + (ep_num * 20h) + 04h */ __IO uint32_t DOEPINT; /*!< dev OUT Endpoint Itr Reg B00h + (ep_num * 20h) + 08h */ uint32_t Reserved0C; /*!< Reserved B00h + (ep_num * 20h) + 0Ch */ __IO uint32_t DOEPTSIZ; /*!< dev OUT Endpoint Txfer Size B00h + (ep_num * 20h) + 10h */ __IO uint32_t DOEPDMA; /*!< dev OUT Endpoint DMA Address B00h + (ep_num * 20h) + 14h */ uint32_t Reserved18[2]; /*!< Reserved B00h + (ep_num * 20h) + 18h - B00h + (ep_num * 20h) + 1Ch */ } USB_OTG_OUTEndpointTypeDef; /** * @brief USB_OTG_Host_Mode_Register_Structures */ typedef struct { __IO uint32_t HCFG; /*!< Host Configuration Register 400h */ __IO uint32_t HFIR; /*!< Host Frame Interval Register 404h */ __IO uint32_t HFNUM; /*!< Host Frame Nbr/Frame Remaining 408h */ uint32_t Reserved40C; /*!< Reserved 40Ch */ __IO uint32_t HPTXSTS; /*!< Host Periodic Tx FIFO/ Queue Status 410h */ __IO uint32_t HAINT; /*!< Host All Channels Interrupt Register 414h */ __IO uint32_t HAINTMSK; /*!< Host All Channels Interrupt Mask 418h */ } USB_OTG_HostTypeDef; /** * @brief USB_OTG_Host_Channel_Specific_Registers */ typedef struct { __IO uint32_t HCCHAR; /*!< Host Channel Characteristics Register 500h */ __IO uint32_t HCSPLT; /*!< Host Channel Split Control Register 504h */ __IO uint32_t HCINT; /*!< Host Channel Interrupt Register 508h */ __IO uint32_t HCINTMSK; /*!< Host Channel Interrupt Mask Register 50Ch */ __IO uint32_t HCTSIZ; /*!< Host Channel Transfer Size Register 510h */ __IO uint32_t HCDMA; /*!< Host Channel DMA Address Register 514h */ uint32_t Reserved[2]; /*!< Reserved */ } USB_OTG_HostChannelTypeDef; /** * @} */ /** @addtogroup Peripheral_memory_map * @{ */ #define FLASH_BASE 0x08000000UL /*!< FLASH(up to 1 MB) base address in the alias region */ #define SRAM1_BASE 0x20000000UL /*!< SRAM1(256 KB) base address in the alias region */ #define PERIPH_BASE 0x40000000UL /*!< Peripheral base address in the alias region */ #define FSMC_R_BASE 0xA0000000UL /*!< FSMC registers base address */ #define QSPI_R_BASE 0xA0001000UL /*!< QuadSPI registers base address */ #define SRAM1_BB_BASE 0x22000000UL /*!< SRAM1(256 KB) base address in the bit-band region */ #define PERIPH_BB_BASE 0x42000000UL /*!< Peripheral base address in the bit-band region */ #define FLASH_END 0x080FFFFFUL /*!< FLASH end address */ #define FLASH_OTP_BASE 0x1FFF7800UL /*!< Base address of : (up to 528 Bytes) embedded FLASH OTP Area */ #define FLASH_OTP_END 0x1FFF7A0FUL /*!< End address of : (up to 528 Bytes) embedded FLASH OTP Area */ /* Legacy defines */ #define SRAM_BASE SRAM1_BASE #define SRAM_BB_BASE SRAM1_BB_BASE /*!< Peripheral memory map */ #define APB1PERIPH_BASE PERIPH_BASE #define APB2PERIPH_BASE (PERIPH_BASE + 0x00010000UL) #define AHB1PERIPH_BASE (PERIPH_BASE + 0x00020000UL) #define AHB2PERIPH_BASE (PERIPH_BASE + 0x10000000UL) /*!< APB1 peripherals */ #define TIM2_BASE (APB1PERIPH_BASE + 0x0000UL) #define TIM3_BASE (APB1PERIPH_BASE + 0x0400UL) #define TIM4_BASE (APB1PERIPH_BASE + 0x0800UL) #define TIM5_BASE (APB1PERIPH_BASE + 0x0C00UL) #define TIM6_BASE (APB1PERIPH_BASE + 0x1000UL) #define TIM7_BASE (APB1PERIPH_BASE + 0x1400UL) #define TIM12_BASE (APB1PERIPH_BASE + 0x1800UL) #define TIM13_BASE (APB1PERIPH_BASE + 0x1C00UL) #define TIM14_BASE (APB1PERIPH_BASE + 0x2000UL) #define RTC_BASE (APB1PERIPH_BASE + 0x2800UL) #define WWDG_BASE (APB1PERIPH_BASE + 0x2C00UL) #define IWDG_BASE (APB1PERIPH_BASE + 0x3000UL) #define I2S2ext_BASE (APB1PERIPH_BASE + 0x3400UL) #define SPI2_BASE (APB1PERIPH_BASE + 0x3800UL) #define SPI3_BASE (APB1PERIPH_BASE + 0x3C00UL) #define I2S3ext_BASE (APB1PERIPH_BASE + 0x4000UL) #define USART2_BASE (APB1PERIPH_BASE + 0x4400UL) #define USART3_BASE (APB1PERIPH_BASE + 0x4800UL) #define I2C1_BASE (APB1PERIPH_BASE + 0x5400UL) #define I2C2_BASE (APB1PERIPH_BASE + 0x5800UL) #define I2C3_BASE (APB1PERIPH_BASE + 0x5C00UL) #define FMPI2C1_BASE (APB1PERIPH_BASE + 0x6000UL) #define CAN1_BASE (APB1PERIPH_BASE + 0x6400UL) #define CAN2_BASE (APB1PERIPH_BASE + 0x6800UL) #define PWR_BASE (APB1PERIPH_BASE + 0x7000UL) /*!< APB2 peripherals */ #define TIM1_BASE (APB2PERIPH_BASE + 0x0000UL) #define TIM8_BASE (APB2PERIPH_BASE + 0x0400UL) #define USART1_BASE (APB2PERIPH_BASE + 0x1000UL) #define USART6_BASE (APB2PERIPH_BASE + 0x1400UL) #define ADC1_BASE (APB2PERIPH_BASE + 0x2000UL) #define ADC1_COMMON_BASE (APB2PERIPH_BASE + 0x2300UL) /* Legacy define */ #define ADC_BASE ADC1_COMMON_BASE #define SDIO_BASE (APB2PERIPH_BASE + 0x2C00UL) #define SPI1_BASE (APB2PERIPH_BASE + 0x3000UL) #define SPI4_BASE (APB2PERIPH_BASE + 0x3400UL) #define SYSCFG_BASE (APB2PERIPH_BASE + 0x3800UL) #define EXTI_BASE (APB2PERIPH_BASE + 0x3C00UL) #define TIM9_BASE (APB2PERIPH_BASE + 0x4000UL) #define TIM10_BASE (APB2PERIPH_BASE + 0x4400UL) #define TIM11_BASE (APB2PERIPH_BASE + 0x4800UL) #define SPI5_BASE (APB2PERIPH_BASE + 0x5000UL) #define DFSDM1_BASE (APB2PERIPH_BASE + 0x6000UL) #define DFSDM1_Channel0_BASE (DFSDM1_BASE + 0x00UL) #define DFSDM1_Channel1_BASE (DFSDM1_BASE + 0x20UL) #define DFSDM1_Channel2_BASE (DFSDM1_BASE + 0x40UL) #define DFSDM1_Channel3_BASE (DFSDM1_BASE + 0x60UL) #define DFSDM1_Filter0_BASE (DFSDM1_BASE + 0x100UL) #define DFSDM1_Filter1_BASE (DFSDM1_BASE + 0x180UL) /*!< AHB1 peripherals */ #define GPIOA_BASE (AHB1PERIPH_BASE + 0x0000UL) #define GPIOB_BASE (AHB1PERIPH_BASE + 0x0400UL) #define GPIOC_BASE (AHB1PERIPH_BASE + 0x0800UL) #define GPIOD_BASE (AHB1PERIPH_BASE + 0x0C00UL) #define GPIOH_BASE (AHB1PERIPH_BASE + 0x1C00UL) #define CRC_BASE (AHB1PERIPH_BASE + 0x3000UL) #define RCC_BASE (AHB1PERIPH_BASE + 0x3800UL) #define FLASH_R_BASE (AHB1PERIPH_BASE + 0x3C00UL) #define DMA1_BASE (AHB1PERIPH_BASE + 0x6000UL) #define DMA1_Stream0_BASE (DMA1_BASE + 0x010UL) #define DMA1_Stream1_BASE (DMA1_BASE + 0x028UL) #define DMA1_Stream2_BASE (DMA1_BASE + 0x040UL) #define DMA1_Stream3_BASE (DMA1_BASE + 0x058UL) #define DMA1_Stream4_BASE (DMA1_BASE + 0x070UL) #define DMA1_Stream5_BASE (DMA1_BASE + 0x088UL) #define DMA1_Stream6_BASE (DMA1_BASE + 0x0A0UL) #define DMA1_Stream7_BASE (DMA1_BASE + 0x0B8UL) #define DMA2_BASE (AHB1PERIPH_BASE + 0x6400UL) #define DMA2_Stream0_BASE (DMA2_BASE + 0x010UL) #define DMA2_Stream1_BASE (DMA2_BASE + 0x028UL) #define DMA2_Stream2_BASE (DMA2_BASE + 0x040UL) #define DMA2_Stream3_BASE (DMA2_BASE + 0x058UL) #define DMA2_Stream4_BASE (DMA2_BASE + 0x070UL) #define DMA2_Stream5_BASE (DMA2_BASE + 0x088UL) #define DMA2_Stream6_BASE (DMA2_BASE + 0x0A0UL) #define DMA2_Stream7_BASE (DMA2_BASE + 0x0B8UL) /*!< AHB2 peripherals */ #define RNG_BASE (AHB2PERIPH_BASE + 0x60800UL) /*!< FSMC Bankx registers base address */ #define FSMC_Bank1_R_BASE (FSMC_R_BASE + 0x0000UL) #define FSMC_Bank1E_R_BASE (FSMC_R_BASE + 0x0104UL) /*!< Debug MCU registers base address */ #define DBGMCU_BASE 0xE0042000UL /*!< USB registers base address */ #define USB_OTG_FS_PERIPH_BASE 0x50000000UL #define USB_OTG_GLOBAL_BASE 0x000UL #define USB_OTG_DEVICE_BASE 0x800UL #define USB_OTG_IN_ENDPOINT_BASE 0x900UL #define USB_OTG_OUT_ENDPOINT_BASE 0xB00UL #define USB_OTG_EP_REG_SIZE 0x20UL #define USB_OTG_HOST_BASE 0x400UL #define USB_OTG_HOST_PORT_BASE 0x440UL #define USB_OTG_HOST_CHANNEL_BASE 0x500UL #define USB_OTG_HOST_CHANNEL_SIZE 0x20UL #define USB_OTG_PCGCCTL_BASE 0xE00UL #define USB_OTG_FIFO_BASE 0x1000UL #define USB_OTG_FIFO_SIZE 0x1000UL #define UID_BASE 0x1FFF7A10UL /*!< Unique device ID register base address */ #define FLASHSIZE_BASE 0x1FFF7A22UL /*!< FLASH Size register base address */ #define PACKAGE_BASE 0x1FFF7BF0UL /*!< Package size register base address */ /** * @} */ /** @addtogroup Peripheral_declaration * @{ */ #define TIM2 ((TIM_TypeDef *) TIM2_BASE) #define TIM3 ((TIM_TypeDef *) TIM3_BASE) #define TIM4 ((TIM_TypeDef *) TIM4_BASE) #define TIM5 ((TIM_TypeDef *) TIM5_BASE) #define TIM6 ((TIM_TypeDef *) TIM6_BASE) #define TIM7 ((TIM_TypeDef *) TIM7_BASE) #define TIM12 ((TIM_TypeDef *) TIM12_BASE) #define TIM13 ((TIM_TypeDef *) TIM13_BASE) #define TIM14 ((TIM_TypeDef *) TIM14_BASE) #define RTC ((RTC_TypeDef *) RTC_BASE) #define WWDG ((WWDG_TypeDef *) WWDG_BASE) #define IWDG ((IWDG_TypeDef *) IWDG_BASE) #define I2S2ext ((SPI_TypeDef *) I2S2ext_BASE) #define SPI2 ((SPI_TypeDef *) SPI2_BASE) #define SPI3 ((SPI_TypeDef *) SPI3_BASE) #define I2S3ext ((SPI_TypeDef *) I2S3ext_BASE) #define USART2 ((USART_TypeDef *) USART2_BASE) #define USART3 ((USART_TypeDef *) USART3_BASE) #define I2C1 ((I2C_TypeDef *) I2C1_BASE) #define I2C2 ((I2C_TypeDef *) I2C2_BASE) #define I2C3 ((I2C_TypeDef *) I2C3_BASE) #define FMPI2C1 ((FMPI2C_TypeDef *) FMPI2C1_BASE) #define CAN1 ((CAN_TypeDef *) CAN1_BASE) #define CAN2 ((CAN_TypeDef *) CAN2_BASE) #define PWR ((PWR_TypeDef *) PWR_BASE) #define TIM1 ((TIM_TypeDef *) TIM1_BASE) #define TIM8 ((TIM_TypeDef *) TIM8_BASE) #define USART1 ((USART_TypeDef *) USART1_BASE) #define USART6 ((USART_TypeDef *) USART6_BASE) #define ADC1 ((ADC_TypeDef *) ADC1_BASE) #define ADC1_COMMON ((ADC_Common_TypeDef *) ADC1_COMMON_BASE) /* Legacy define */ #define ADC ADC1_COMMON #define SDIO ((SDIO_TypeDef *) SDIO_BASE) #define SPI1 ((SPI_TypeDef *) SPI1_BASE) #define SPI4 ((SPI_TypeDef *) SPI4_BASE) #define SYSCFG ((SYSCFG_TypeDef *) SYSCFG_BASE) #define EXTI ((EXTI_TypeDef *) EXTI_BASE) #define TIM9 ((TIM_TypeDef *) TIM9_BASE) #define TIM10 ((TIM_TypeDef *) TIM10_BASE) #define TIM11 ((TIM_TypeDef *) TIM11_BASE) #define SPI5 ((SPI_TypeDef *) SPI5_BASE) #define DFSDM1_Channel0 ((DFSDM_Channel_TypeDef *) DFSDM1_Channel0_BASE) #define DFSDM1_Channel1 ((DFSDM_Channel_TypeDef *) DFSDM1_Channel1_BASE) #define DFSDM1_Channel2 ((DFSDM_Channel_TypeDef *) DFSDM1_Channel2_BASE) #define DFSDM1_Channel3 ((DFSDM_Channel_TypeDef *) DFSDM1_Channel3_BASE) #define DFSDM1_Filter0 ((DFSDM_Filter_TypeDef *) DFSDM1_Filter0_BASE) #define DFSDM1_Filter1 ((DFSDM_Filter_TypeDef *) DFSDM1_Filter1_BASE) #define GPIOA ((GPIO_TypeDef *) GPIOA_BASE) #define GPIOB ((GPIO_TypeDef *) GPIOB_BASE) #define GPIOC ((GPIO_TypeDef *) GPIOC_BASE) #define GPIOD ((GPIO_TypeDef *) GPIOD_BASE) #define GPIOH ((GPIO_TypeDef *) GPIOH_BASE) #define CRC ((CRC_TypeDef *) CRC_BASE) #define RCC ((RCC_TypeDef *) RCC_BASE) #define FLASH ((FLASH_TypeDef *) FLASH_R_BASE) #define DMA1 ((DMA_TypeDef *) DMA1_BASE) #define DMA1_Stream0 ((DMA_Stream_TypeDef *) DMA1_Stream0_BASE) #define DMA1_Stream1 ((DMA_Stream_TypeDef *) DMA1_Stream1_BASE) #define DMA1_Stream2 ((DMA_Stream_TypeDef *) DMA1_Stream2_BASE) #define DMA1_Stream3 ((DMA_Stream_TypeDef *) DMA1_Stream3_BASE) #define DMA1_Stream4 ((DMA_Stream_TypeDef *) DMA1_Stream4_BASE) #define DMA1_Stream5 ((DMA_Stream_TypeDef *) DMA1_Stream5_BASE) #define DMA1_Stream6 ((DMA_Stream_TypeDef *) DMA1_Stream6_BASE) #define DMA1_Stream7 ((DMA_Stream_TypeDef *) DMA1_Stream7_BASE) #define DMA2 ((DMA_TypeDef *) DMA2_BASE) #define DMA2_Stream0 ((DMA_Stream_TypeDef *) DMA2_Stream0_BASE) #define DMA2_Stream1 ((DMA_Stream_TypeDef *) DMA2_Stream1_BASE) #define DMA2_Stream2 ((DMA_Stream_TypeDef *) DMA2_Stream2_BASE) #define DMA2_Stream3 ((DMA_Stream_TypeDef *) DMA2_Stream3_BASE) #define DMA2_Stream4 ((DMA_Stream_TypeDef *) DMA2_Stream4_BASE) #define DMA2_Stream5 ((DMA_Stream_TypeDef *) DMA2_Stream5_BASE) #define DMA2_Stream6 ((DMA_Stream_TypeDef *) DMA2_Stream6_BASE) #define DMA2_Stream7 ((DMA_Stream_TypeDef *) DMA2_Stream7_BASE) #define RNG ((RNG_TypeDef *) RNG_BASE) #define FSMC_Bank1 ((FSMC_Bank1_TypeDef *) FSMC_Bank1_R_BASE) #define FSMC_Bank1E ((FSMC_Bank1E_TypeDef *) FSMC_Bank1E_R_BASE) #define QUADSPI ((QUADSPI_TypeDef *) QSPI_R_BASE) #define DBGMCU ((DBGMCU_TypeDef *) DBGMCU_BASE) #define USB_OTG_FS ((USB_OTG_GlobalTypeDef *) USB_OTG_FS_PERIPH_BASE) /** * @} */ /** @addtogroup Exported_constants * @{ */ /** @addtogroup Peripheral_Registers_Bits_Definition * @{ */ /******************************************************************************/ /* Peripheral Registers_Bits_Definition */ /******************************************************************************/ /******************************************************************************/ /* */ /* Analog to Digital Converter */ /* */ /******************************************************************************/ /******************** Bit definition for ADC_SR register ********************/ #define ADC_SR_AWD_Pos (0U) #define ADC_SR_AWD_Msk (0x1UL << ADC_SR_AWD_Pos) /*!< 0x00000001 */ #define ADC_SR_AWD ADC_SR_AWD_Msk /*!
© COPYRIGHT(c) 2017 STMicroelectronics
* * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. Neither the name of STMicroelectronics nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ /** @addtogroup CMSIS_Device * @{ */ /** @addtogroup stm32f412zx * @{ */ #ifndef __STM32F412Zx_H #define __STM32F412Zx_H #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ /** @addtogroup Configuration_section_for_CMSIS * @{ */ /** * @brief Configuration of the Cortex-M4 Processor and Core Peripherals */ #define __CM4_REV 0x0001U /*!< Core revision r0p1 */ #define __MPU_PRESENT 1U /*!< STM32F4XX provides an MPU */ #define __NVIC_PRIO_BITS 4U /*!< STM32F4XX uses 4 Bits for the Priority Levels */ #define __Vendor_SysTickConfig 0U /*!< Set to 1 if different SysTick Config is used */ #define __FPU_PRESENT 1U /*!< FPU present */ /** * @} */ /** @addtogroup Peripheral_interrupt_number_definition * @{ */ /** * @brief STM32F4XX Interrupt Number Definition, according to the selected device * in @ref Library_configuration_section */ typedef enum { /****** Cortex-M4 Processor Exceptions Numbers ****************************************************************/ NonMaskableInt_IRQn = -14, /*!< 2 Non Maskable Interrupt */ MemoryManagement_IRQn = -12, /*!< 4 Cortex-M4 Memory Management Interrupt */ BusFault_IRQn = -11, /*!< 5 Cortex-M4 Bus Fault Interrupt */ UsageFault_IRQn = -10, /*!< 6 Cortex-M4 Usage Fault Interrupt */ SVCall_IRQn = -5, /*!< 11 Cortex-M4 SV Call Interrupt */ DebugMonitor_IRQn = -4, /*!< 12 Cortex-M4 Debug Monitor Interrupt */ PendSV_IRQn = -2, /*!< 14 Cortex-M4 Pend SV Interrupt */ SysTick_IRQn = -1, /*!< 15 Cortex-M4 System Tick Interrupt */ /****** STM32 specific Interrupt Numbers **********************************************************************/ WWDG_IRQn = 0, /*!< Window WatchDog Interrupt */ PVD_IRQn = 1, /*!< PVD through EXTI Line detection Interrupt */ TAMP_STAMP_IRQn = 2, /*!< Tamper and TimeStamp interrupts through the EXTI line */ RTC_WKUP_IRQn = 3, /*!< RTC Wakeup interrupt through the EXTI line */ FLASH_IRQn = 4, /*!< FLASH global Interrupt */ RCC_IRQn = 5, /*!< RCC global Interrupt */ EXTI0_IRQn = 6, /*!< EXTI Line0 Interrupt */ EXTI1_IRQn = 7, /*!< EXTI Line1 Interrupt */ EXTI2_IRQn = 8, /*!< EXTI Line2 Interrupt */ EXTI3_IRQn = 9, /*!< EXTI Line3 Interrupt */ EXTI4_IRQn = 10, /*!< EXTI Line4 Interrupt */ DMA1_Stream0_IRQn = 11, /*!< DMA1 Stream 0 global Interrupt */ DMA1_Stream1_IRQn = 12, /*!< DMA1 Stream 1 global Interrupt */ DMA1_Stream2_IRQn = 13, /*!< DMA1 Stream 2 global Interrupt */ DMA1_Stream3_IRQn = 14, /*!< DMA1 Stream 3 global Interrupt */ DMA1_Stream4_IRQn = 15, /*!< DMA1 Stream 4 global Interrupt */ DMA1_Stream5_IRQn = 16, /*!< DMA1 Stream 5 global Interrupt */ DMA1_Stream6_IRQn = 17, /*!< DMA1 Stream 6 global Interrupt */ ADC_IRQn = 18, /*!< ADC1, ADC2 and ADC3 global Interrupts */ CAN1_TX_IRQn = 19, /*!< CAN1 TX Interrupt */ CAN1_RX0_IRQn = 20, /*!< CAN1 RX0 Interrupt */ CAN1_RX1_IRQn = 21, /*!< CAN1 RX1 Interrupt */ CAN1_SCE_IRQn = 22, /*!< CAN1 SCE Interrupt */ EXTI9_5_IRQn = 23, /*!< External Line[9:5] Interrupts */ TIM1_BRK_TIM9_IRQn = 24, /*!< TIM1 Break interrupt and TIM9 global interrupt */ TIM1_UP_TIM10_IRQn = 25, /*!< TIM1 Update Interrupt and TIM10 global interrupt */ TIM1_TRG_COM_TIM11_IRQn = 26, /*!< TIM1 Trigger and Commutation Interrupt and TIM11 global interrupt */ TIM1_CC_IRQn = 27, /*!< TIM1 Capture Compare Interrupt */ TIM2_IRQn = 28, /*!< TIM2 global Interrupt */ TIM3_IRQn = 29, /*!< TIM3 global Interrupt */ TIM4_IRQn = 30, /*!< TIM4 global Interrupt */ I2C1_EV_IRQn = 31, /*!< I2C1 Event Interrupt */ I2C1_ER_IRQn = 32, /*!< I2C1 Error Interrupt */ I2C2_EV_IRQn = 33, /*!< I2C2 Event Interrupt */ I2C2_ER_IRQn = 34, /*!< I2C2 Error Interrupt */ SPI1_IRQn = 35, /*!< SPI1 global Interrupt */ SPI2_IRQn = 36, /*!< SPI2 global Interrupt */ USART1_IRQn = 37, /*!< USART1 global Interrupt */ USART2_IRQn = 38, /*!< USART2 global Interrupt */ USART3_IRQn = 39, /*!< USART3 global Interrupt */ EXTI15_10_IRQn = 40, /*!< External Line[15:10] Interrupts */ RTC_Alarm_IRQn = 41, /*!< RTC Alarm (A and B) through EXTI Line Interrupt */ OTG_FS_WKUP_IRQn = 42, /*!< USB OTG FS Wakeup through EXTI line interrupt */ TIM8_BRK_TIM12_IRQn = 43, /*!< TIM8 Break Interrupt and TIM12 global interrupt */ TIM8_UP_TIM13_IRQn = 44, /*!< TIM8 Update Interrupt and TIM13 global interrupt */ TIM8_TRG_COM_TIM14_IRQn = 45, /*!< TIM8 Trigger and Commutation Interrupt and TIM14 global interrupt */ TIM8_CC_IRQn = 46, /*!< TIM8 Capture Compare global interrupt */ DMA1_Stream7_IRQn = 47, /*!< DMA1 Stream7 Interrupt */ SDIO_IRQn = 49, /*!< SDIO global Interrupt */ TIM5_IRQn = 50, /*!< TIM5 global Interrupt */ SPI3_IRQn = 51, /*!< SPI3 global Interrupt */ TIM6_IRQn = 54, /*!< TIM6 global interrupt */ TIM7_IRQn = 55, /*!< TIM7 global interrupt */ DMA2_Stream0_IRQn = 56, /*!< DMA2 Stream 0 global Interrupt */ DMA2_Stream1_IRQn = 57, /*!< DMA2 Stream 1 global Interrupt */ DMA2_Stream2_IRQn = 58, /*!< DMA2 Stream 2 global Interrupt */ DMA2_Stream3_IRQn = 59, /*!< DMA2 Stream 3 global Interrupt */ DMA2_Stream4_IRQn = 60, /*!< DMA2 Stream 4 global Interrupt */ DFSDM1_FLT0_IRQn = 61, /*!< DFSDM1 Filter 0 global Interrupt */ DFSDM1_FLT1_IRQn = 62, /*!< DFSDM1 Filter 1 global Interrupt */ CAN2_TX_IRQn = 63, /*!< CAN2 TX Interrupt */ CAN2_RX0_IRQn = 64, /*!< CAN2 RX0 Interrupt */ CAN2_RX1_IRQn = 65, /*!< CAN2 RX1 Interrupt */ CAN2_SCE_IRQn = 66, /*!< CAN2 SCE Interrupt */ OTG_FS_IRQn = 67, /*!< USB OTG FS global Interrupt */ DMA2_Stream5_IRQn = 68, /*!< DMA2 Stream 5 global interrupt */ DMA2_Stream6_IRQn = 69, /*!< DMA2 Stream 6 global interrupt */ DMA2_Stream7_IRQn = 70, /*!< DMA2 Stream 7 global interrupt */ USART6_IRQn = 71, /*!< USART6 global interrupt */ I2C3_EV_IRQn = 72, /*!< I2C3 event interrupt */ I2C3_ER_IRQn = 73, /*!< I2C3 error interrupt */ RNG_IRQn = 80, /*!< RNG global Interrupt */ FPU_IRQn = 81, /*!< FPU global interrupt */ SPI4_IRQn = 84, /*!< SPI4 global Interrupt */ SPI5_IRQn = 85, /*!< SPI5 global Interrupt */ QUADSPI_IRQn = 92, /*!< QuadSPI global Interrupt */ FMPI2C1_EV_IRQn = 95, /*!< FMPI2C1 Event Interrupt */ FMPI2C1_ER_IRQn = 96 /*!< FMPI2C1 Error Interrupt */ } IRQn_Type; /** * @} */ #include "core_cm4.h" /* Cortex-M4 processor and core peripherals */ #include "system_stm32f4xx.h" #include /** @addtogroup Peripheral_registers_structures * @{ */ /** * @brief Analog to Digital Converter */ typedef struct { __IO uint32_t SR; /*!< ADC status register, Address offset: 0x00 */ __IO uint32_t CR1; /*!< ADC control register 1, Address offset: 0x04 */ __IO uint32_t CR2; /*!< ADC control register 2, Address offset: 0x08 */ __IO uint32_t SMPR1; /*!< ADC sample time register 1, Address offset: 0x0C */ __IO uint32_t SMPR2; /*!< ADC sample time register 2, Address offset: 0x10 */ __IO uint32_t JOFR1; /*!< ADC injected channel data offset register 1, Address offset: 0x14 */ __IO uint32_t JOFR2; /*!< ADC injected channel data offset register 2, Address offset: 0x18 */ __IO uint32_t JOFR3; /*!< ADC injected channel data offset register 3, Address offset: 0x1C */ __IO uint32_t JOFR4; /*!< ADC injected channel data offset register 4, Address offset: 0x20 */ __IO uint32_t HTR; /*!< ADC watchdog higher threshold register, Address offset: 0x24 */ __IO uint32_t LTR; /*!< ADC watchdog lower threshold register, Address offset: 0x28 */ __IO uint32_t SQR1; /*!< ADC regular sequence register 1, Address offset: 0x2C */ __IO uint32_t SQR2; /*!< ADC regular sequence register 2, Address offset: 0x30 */ __IO uint32_t SQR3; /*!< ADC regular sequence register 3, Address offset: 0x34 */ __IO uint32_t JSQR; /*!< ADC injected sequence register, Address offset: 0x38*/ __IO uint32_t JDR1; /*!< ADC injected data register 1, Address offset: 0x3C */ __IO uint32_t JDR2; /*!< ADC injected data register 2, Address offset: 0x40 */ __IO uint32_t JDR3; /*!< ADC injected data register 3, Address offset: 0x44 */ __IO uint32_t JDR4; /*!< ADC injected data register 4, Address offset: 0x48 */ __IO uint32_t DR; /*!< ADC regular data register, Address offset: 0x4C */ } ADC_TypeDef; typedef struct { __IO uint32_t CSR; /*!< ADC Common status register, Address offset: ADC1 base address + 0x300 */ __IO uint32_t CCR; /*!< ADC common control register, Address offset: ADC1 base address + 0x304 */ __IO uint32_t CDR; /*!< ADC common regular data register for dual AND triple modes, Address offset: ADC1 base address + 0x308 */ } ADC_Common_TypeDef; /** * @brief Controller Area Network TxMailBox */ typedef struct { __IO uint32_t TIR; /*!< CAN TX mailbox identifier register */ __IO uint32_t TDTR; /*!< CAN mailbox data length control and time stamp register */ __IO uint32_t TDLR; /*!< CAN mailbox data low register */ __IO uint32_t TDHR; /*!< CAN mailbox data high register */ } CAN_TxMailBox_TypeDef; /** * @brief Controller Area Network FIFOMailBox */ typedef struct { __IO uint32_t RIR; /*!< CAN receive FIFO mailbox identifier register */ __IO uint32_t RDTR; /*!< CAN receive FIFO mailbox data length control and time stamp register */ __IO uint32_t RDLR; /*!< CAN receive FIFO mailbox data low register */ __IO uint32_t RDHR; /*!< CAN receive FIFO mailbox data high register */ } CAN_FIFOMailBox_TypeDef; /** * @brief Controller Area Network FilterRegister */ typedef struct { __IO uint32_t FR1; /*!< CAN Filter bank register 1 */ __IO uint32_t FR2; /*!< CAN Filter bank register 1 */ } CAN_FilterRegister_TypeDef; /** * @brief Controller Area Network */ typedef struct { __IO uint32_t MCR; /*!< CAN master control register, Address offset: 0x00 */ __IO uint32_t MSR; /*!< CAN master status register, Address offset: 0x04 */ __IO uint32_t TSR; /*!< CAN transmit status register, Address offset: 0x08 */ __IO uint32_t RF0R; /*!< CAN receive FIFO 0 register, Address offset: 0x0C */ __IO uint32_t RF1R; /*!< CAN receive FIFO 1 register, Address offset: 0x10 */ __IO uint32_t IER; /*!< CAN interrupt enable register, Address offset: 0x14 */ __IO uint32_t ESR; /*!< CAN error status register, Address offset: 0x18 */ __IO uint32_t BTR; /*!< CAN bit timing register, Address offset: 0x1C */ uint32_t RESERVED0[88]; /*!< Reserved, 0x020 - 0x17F */ CAN_TxMailBox_TypeDef sTxMailBox[3]; /*!< CAN Tx MailBox, Address offset: 0x180 - 0x1AC */ CAN_FIFOMailBox_TypeDef sFIFOMailBox[2]; /*!< CAN FIFO MailBox, Address offset: 0x1B0 - 0x1CC */ uint32_t RESERVED1[12]; /*!< Reserved, 0x1D0 - 0x1FF */ __IO uint32_t FMR; /*!< CAN filter master register, Address offset: 0x200 */ __IO uint32_t FM1R; /*!< CAN filter mode register, Address offset: 0x204 */ uint32_t RESERVED2; /*!< Reserved, 0x208 */ __IO uint32_t FS1R; /*!< CAN filter scale register, Address offset: 0x20C */ uint32_t RESERVED3; /*!< Reserved, 0x210 */ __IO uint32_t FFA1R; /*!< CAN filter FIFO assignment register, Address offset: 0x214 */ uint32_t RESERVED4; /*!< Reserved, 0x218 */ __IO uint32_t FA1R; /*!< CAN filter activation register, Address offset: 0x21C */ uint32_t RESERVED5[8]; /*!< Reserved, 0x220-0x23F */ CAN_FilterRegister_TypeDef sFilterRegister[28]; /*!< CAN Filter Register, Address offset: 0x240-0x31C */ } CAN_TypeDef; /** * @brief CRC calculation unit */ typedef struct { __IO uint32_t DR; /*!< CRC Data register, Address offset: 0x00 */ __IO uint8_t IDR; /*!< CRC Independent data register, Address offset: 0x04 */ uint8_t RESERVED0; /*!< Reserved, 0x05 */ uint16_t RESERVED1; /*!< Reserved, 0x06 */ __IO uint32_t CR; /*!< CRC Control register, Address offset: 0x08 */ } CRC_TypeDef; /** * @brief DFSDM module registers */ typedef struct { __IO uint32_t FLTCR1; /*!< DFSDM control register1, Address offset: 0x100 */ __IO uint32_t FLTCR2; /*!< DFSDM control register2, Address offset: 0x104 */ __IO uint32_t FLTISR; /*!< DFSDM interrupt and status register, Address offset: 0x108 */ __IO uint32_t FLTICR; /*!< DFSDM interrupt flag clear register, Address offset: 0x10C */ __IO uint32_t FLTJCHGR; /*!< DFSDM injected channel group selection register, Address offset: 0x110 */ __IO uint32_t FLTFCR; /*!< DFSDM filter control register, Address offset: 0x114 */ __IO uint32_t FLTJDATAR; /*!< DFSDM data register for injected group, Address offset: 0x118 */ __IO uint32_t FLTRDATAR; /*!< DFSDM data register for regular group, Address offset: 0x11C */ __IO uint32_t FLTAWHTR; /*!< DFSDM analog watchdog high threshold register, Address offset: 0x120 */ __IO uint32_t FLTAWLTR; /*!< DFSDM analog watchdog low threshold register, Address offset: 0x124 */ __IO uint32_t FLTAWSR; /*!< DFSDM analog watchdog status register Address offset: 0x128 */ __IO uint32_t FLTAWCFR; /*!< DFSDM analog watchdog clear flag register Address offset: 0x12C */ __IO uint32_t FLTEXMAX; /*!< DFSDM extreme detector maximum register, Address offset: 0x130 */ __IO uint32_t FLTEXMIN; /*!< DFSDM extreme detector minimum register Address offset: 0x134 */ __IO uint32_t FLTCNVTIMR; /*!< DFSDM conversion timer, Address offset: 0x138 */ } DFSDM_Filter_TypeDef; /** * @brief DFSDM channel configuration registers */ typedef struct { __IO uint32_t CHCFGR1; /*!< DFSDM channel configuration register1, Address offset: 0x00 */ __IO uint32_t CHCFGR2; /*!< DFSDM channel configuration register2, Address offset: 0x04 */ __IO uint32_t CHAWSCDR; /*!< DFSDM channel analog watchdog and short circuit detector register, Address offset: 0x08 */ __IO uint32_t CHWDATAR; /*!< DFSDM channel watchdog filter data register, Address offset: 0x0C */ __IO uint32_t CHDATINR; /*!< DFSDM channel data input register, Address offset: 0x10 */ } DFSDM_Channel_TypeDef; /** * @brief Debug MCU */ typedef struct { __IO uint32_t IDCODE; /*!< MCU device ID code, Address offset: 0x00 */ __IO uint32_t CR; /*!< Debug MCU configuration register, Address offset: 0x04 */ __IO uint32_t APB1FZ; /*!< Debug MCU APB1 freeze register, Address offset: 0x08 */ __IO uint32_t APB2FZ; /*!< Debug MCU APB2 freeze register, Address offset: 0x0C */ }DBGMCU_TypeDef; /** * @brief DMA Controller */ typedef struct { __IO uint32_t CR; /*!< DMA stream x configuration register */ __IO uint32_t NDTR; /*!< DMA stream x number of data register */ __IO uint32_t PAR; /*!< DMA stream x peripheral address register */ __IO uint32_t M0AR; /*!< DMA stream x memory 0 address register */ __IO uint32_t M1AR; /*!< DMA stream x memory 1 address register */ __IO uint32_t FCR; /*!< DMA stream x FIFO control register */ } DMA_Stream_TypeDef; typedef struct { __IO uint32_t LISR; /*!< DMA low interrupt status register, Address offset: 0x00 */ __IO uint32_t HISR; /*!< DMA high interrupt status register, Address offset: 0x04 */ __IO uint32_t LIFCR; /*!< DMA low interrupt flag clear register, Address offset: 0x08 */ __IO uint32_t HIFCR; /*!< DMA high interrupt flag clear register, Address offset: 0x0C */ } DMA_TypeDef; /** * @brief External Interrupt/Event Controller */ typedef struct { __IO uint32_t IMR; /*!< EXTI Interrupt mask register, Address offset: 0x00 */ __IO uint32_t EMR; /*!< EXTI Event mask register, Address offset: 0x04 */ __IO uint32_t RTSR; /*!< EXTI Rising trigger selection register, Address offset: 0x08 */ __IO uint32_t FTSR; /*!< EXTI Falling trigger selection register, Address offset: 0x0C */ __IO uint32_t SWIER; /*!< EXTI Software interrupt event register, Address offset: 0x10 */ __IO uint32_t PR; /*!< EXTI Pending register, Address offset: 0x14 */ } EXTI_TypeDef; /** * @brief FLASH Registers */ typedef struct { __IO uint32_t ACR; /*!< FLASH access control register, Address offset: 0x00 */ __IO uint32_t KEYR; /*!< FLASH key register, Address offset: 0x04 */ __IO uint32_t OPTKEYR; /*!< FLASH option key register, Address offset: 0x08 */ __IO uint32_t SR; /*!< FLASH status register, Address offset: 0x0C */ __IO uint32_t CR; /*!< FLASH control register, Address offset: 0x10 */ __IO uint32_t OPTCR; /*!< FLASH option control register , Address offset: 0x14 */ __IO uint32_t OPTCR1; /*!< FLASH option control register 1, Address offset: 0x18 */ } FLASH_TypeDef; /** * @brief Flexible Static Memory Controller */ typedef struct { __IO uint32_t BTCR[8]; /*!< NOR/PSRAM chip-select control register(BCR) and chip-select timing register(BTR), Address offset: 0x00-1C */ } FSMC_Bank1_TypeDef; /** * @brief Flexible Static Memory Controller Bank1E */ typedef struct { __IO uint32_t BWTR[7]; /*!< NOR/PSRAM write timing registers, Address offset: 0x104-0x11C */ } FSMC_Bank1E_TypeDef; /** * @brief General Purpose I/O */ typedef struct { __IO uint32_t MODER; /*!< GPIO port mode register, Address offset: 0x00 */ __IO uint32_t OTYPER; /*!< GPIO port output type register, Address offset: 0x04 */ __IO uint32_t OSPEEDR; /*!< GPIO port output speed register, Address offset: 0x08 */ __IO uint32_t PUPDR; /*!< GPIO port pull-up/pull-down register, Address offset: 0x0C */ __IO uint32_t IDR; /*!< GPIO port input data register, Address offset: 0x10 */ __IO uint32_t ODR; /*!< GPIO port output data register, Address offset: 0x14 */ __IO uint32_t BSRR; /*!< GPIO port bit set/reset register, Address offset: 0x18 */ __IO uint32_t LCKR; /*!< GPIO port configuration lock register, Address offset: 0x1C */ __IO uint32_t AFR[2]; /*!< GPIO alternate function registers, Address offset: 0x20-0x24 */ } GPIO_TypeDef; /** * @brief System configuration controller */ typedef struct { __IO uint32_t MEMRMP; /*!< SYSCFG memory remap register, Address offset: 0x00 */ __IO uint32_t PMC; /*!< SYSCFG peripheral mode configuration register, Address offset: 0x04 */ __IO uint32_t EXTICR[4]; /*!< SYSCFG external interrupt configuration registers, Address offset: 0x08-0x14 */ uint32_t RESERVED; /*!< Reserved, 0x18 */ __IO uint32_t CFGR2; /*!< SYSCFG Configuration register2, Address offset: 0x1C */ __IO uint32_t CMPCR; /*!< SYSCFG Compensation cell control register, Address offset: 0x20 */ __IO uint32_t CFGR; /*!< SYSCFG Configuration register, Address offset: 0x24 */ } SYSCFG_TypeDef; /** * @brief Inter-integrated Circuit Interface */ typedef struct { __IO uint32_t CR1; /*!< I2C Control register 1, Address offset: 0x00 */ __IO uint32_t CR2; /*!< I2C Control register 2, Address offset: 0x04 */ __IO uint32_t OAR1; /*!< I2C Own address register 1, Address offset: 0x08 */ __IO uint32_t OAR2; /*!< I2C Own address register 2, Address offset: 0x0C */ __IO uint32_t DR; /*!< I2C Data register, Address offset: 0x10 */ __IO uint32_t SR1; /*!< I2C Status register 1, Address offset: 0x14 */ __IO uint32_t SR2; /*!< I2C Status register 2, Address offset: 0x18 */ __IO uint32_t CCR; /*!< I2C Clock control register, Address offset: 0x1C */ __IO uint32_t TRISE; /*!< I2C TRISE register, Address offset: 0x20 */ __IO uint32_t FLTR; /*!< I2C FLTR register, Address offset: 0x24 */ } I2C_TypeDef; /** * @brief Inter-integrated Circuit Interface */ typedef struct { __IO uint32_t CR1; /*!< FMPI2C Control register 1, Address offset: 0x00 */ __IO uint32_t CR2; /*!< FMPI2C Control register 2, Address offset: 0x04 */ __IO uint32_t OAR1; /*!< FMPI2C Own address 1 register, Address offset: 0x08 */ __IO uint32_t OAR2; /*!< FMPI2C Own address 2 register, Address offset: 0x0C */ __IO uint32_t TIMINGR; /*!< FMPI2C Timing register, Address offset: 0x10 */ __IO uint32_t TIMEOUTR; /*!< FMPI2C Timeout register, Address offset: 0x14 */ __IO uint32_t ISR; /*!< FMPI2C Interrupt and status register, Address offset: 0x18 */ __IO uint32_t ICR; /*!< FMPI2C Interrupt clear register, Address offset: 0x1C */ __IO uint32_t PECR; /*!< FMPI2C PEC register, Address offset: 0x20 */ __IO uint32_t RXDR; /*!< FMPI2C Receive data register, Address offset: 0x24 */ __IO uint32_t TXDR; /*!< FMPI2C Transmit data register, Address offset: 0x28 */ } FMPI2C_TypeDef; /** * @brief Independent WATCHDOG */ typedef struct { __IO uint32_t KR; /*!< IWDG Key register, Address offset: 0x00 */ __IO uint32_t PR; /*!< IWDG Prescaler register, Address offset: 0x04 */ __IO uint32_t RLR; /*!< IWDG Reload register, Address offset: 0x08 */ __IO uint32_t SR; /*!< IWDG Status register, Address offset: 0x0C */ } IWDG_TypeDef; /** * @brief Power Control */ typedef struct { __IO uint32_t CR; /*!< PWR power control register, Address offset: 0x00 */ __IO uint32_t CSR; /*!< PWR power control/status register, Address offset: 0x04 */ } PWR_TypeDef; /** * @brief Reset and Clock Control */ typedef struct { __IO uint32_t CR; /*!< RCC clock control register, Address offset: 0x00 */ __IO uint32_t PLLCFGR; /*!< RCC PLL configuration register, Address offset: 0x04 */ __IO uint32_t CFGR; /*!< RCC clock configuration register, Address offset: 0x08 */ __IO uint32_t CIR; /*!< RCC clock interrupt register, Address offset: 0x0C */ __IO uint32_t AHB1RSTR; /*!< RCC AHB1 peripheral reset register, Address offset: 0x10 */ __IO uint32_t AHB2RSTR; /*!< RCC AHB2 peripheral reset register, Address offset: 0x14 */ __IO uint32_t AHB3RSTR; /*!< RCC AHB3 peripheral reset register, Address offset: 0x18 */ uint32_t RESERVED0; /*!< Reserved, 0x1C */ __IO uint32_t APB1RSTR; /*!< RCC APB1 peripheral reset register, Address offset: 0x20 */ __IO uint32_t APB2RSTR; /*!< RCC APB2 peripheral reset register, Address offset: 0x24 */ uint32_t RESERVED1[2]; /*!< Reserved, 0x28-0x2C */ __IO uint32_t AHB1ENR; /*!< RCC AHB1 peripheral clock register, Address offset: 0x30 */ __IO uint32_t AHB2ENR; /*!< RCC AHB2 peripheral clock register, Address offset: 0x34 */ __IO uint32_t AHB3ENR; /*!< RCC AHB3 peripheral clock register, Address offset: 0x38 */ uint32_t RESERVED2; /*!< Reserved, 0x3C */ __IO uint32_t APB1ENR; /*!< RCC APB1 peripheral clock enable register, Address offset: 0x40 */ __IO uint32_t APB2ENR; /*!< RCC APB2 peripheral clock enable register, Address offset: 0x44 */ uint32_t RESERVED3[2]; /*!< Reserved, 0x48-0x4C */ __IO uint32_t AHB1LPENR; /*!< RCC AHB1 peripheral clock enable in low power mode register, Address offset: 0x50 */ __IO uint32_t AHB2LPENR; /*!< RCC AHB2 peripheral clock enable in low power mode register, Address offset: 0x54 */ __IO uint32_t AHB3LPENR; /*!< RCC AHB3 peripheral clock enable in low power mode register, Address offset: 0x58 */ uint32_t RESERVED4; /*!< Reserved, 0x5C */ __IO uint32_t APB1LPENR; /*!< RCC APB1 peripheral clock enable in low power mode register, Address offset: 0x60 */ __IO uint32_t APB2LPENR; /*!< RCC APB2 peripheral clock enable in low power mode register, Address offset: 0x64 */ uint32_t RESERVED5[2]; /*!< Reserved, 0x68-0x6C */ __IO uint32_t BDCR; /*!< RCC Backup domain control register, Address offset: 0x70 */ __IO uint32_t CSR; /*!< RCC clock control & status register, Address offset: 0x74 */ uint32_t RESERVED6[2]; /*!< Reserved, 0x78-0x7C */ __IO uint32_t SSCGR; /*!< RCC spread spectrum clock generation register, Address offset: 0x80 */ __IO uint32_t PLLI2SCFGR; /*!< RCC PLLI2S configuration register, Address offset: 0x84 */ uint32_t RESERVED7; /*!< Reserved, 0x88 */ __IO uint32_t DCKCFGR; /*!< RCC Dedicated Clocks configuration register, Address offset: 0x8C */ __IO uint32_t CKGATENR; /*!< RCC Clocks Gated ENable Register, Address offset: 0x90 */ __IO uint32_t DCKCFGR2; /*!< RCC Dedicated Clocks configuration register 2, Address offset: 0x94 */ } RCC_TypeDef; /** * @brief Real-Time Clock */ typedef struct { __IO uint32_t TR; /*!< RTC time register, Address offset: 0x00 */ __IO uint32_t DR; /*!< RTC date register, Address offset: 0x04 */ __IO uint32_t CR; /*!< RTC control register, Address offset: 0x08 */ __IO uint32_t ISR; /*!< RTC initialization and status register, Address offset: 0x0C */ __IO uint32_t PRER; /*!< RTC prescaler register, Address offset: 0x10 */ __IO uint32_t WUTR; /*!< RTC wakeup timer register, Address offset: 0x14 */ __IO uint32_t CALIBR; /*!< RTC calibration register, Address offset: 0x18 */ __IO uint32_t ALRMAR; /*!< RTC alarm A register, Address offset: 0x1C */ __IO uint32_t ALRMBR; /*!< RTC alarm B register, Address offset: 0x20 */ __IO uint32_t WPR; /*!< RTC write protection register, Address offset: 0x24 */ __IO uint32_t SSR; /*!< RTC sub second register, Address offset: 0x28 */ __IO uint32_t SHIFTR; /*!< RTC shift control register, Address offset: 0x2C */ __IO uint32_t TSTR; /*!< RTC time stamp time register, Address offset: 0x30 */ __IO uint32_t TSDR; /*!< RTC time stamp date register, Address offset: 0x34 */ __IO uint32_t TSSSR; /*!< RTC time-stamp sub second register, Address offset: 0x38 */ __IO uint32_t CALR; /*!< RTC calibration register, Address offset: 0x3C */ __IO uint32_t TAFCR; /*!< RTC tamper and alternate function configuration register, Address offset: 0x40 */ __IO uint32_t ALRMASSR;/*!< RTC alarm A sub second register, Address offset: 0x44 */ __IO uint32_t ALRMBSSR;/*!< RTC alarm B sub second register, Address offset: 0x48 */ uint32_t RESERVED7; /*!< Reserved, 0x4C */ __IO uint32_t BKP0R; /*!< RTC backup register 1, Address offset: 0x50 */ __IO uint32_t BKP1R; /*!< RTC backup register 1, Address offset: 0x54 */ __IO uint32_t BKP2R; /*!< RTC backup register 2, Address offset: 0x58 */ __IO uint32_t BKP3R; /*!< RTC backup register 3, Address offset: 0x5C */ __IO uint32_t BKP4R; /*!< RTC backup register 4, Address offset: 0x60 */ __IO uint32_t BKP5R; /*!< RTC backup register 5, Address offset: 0x64 */ __IO uint32_t BKP6R; /*!< RTC backup register 6, Address offset: 0x68 */ __IO uint32_t BKP7R; /*!< RTC backup register 7, Address offset: 0x6C */ __IO uint32_t BKP8R; /*!< RTC backup register 8, Address offset: 0x70 */ __IO uint32_t BKP9R; /*!< RTC backup register 9, Address offset: 0x74 */ __IO uint32_t BKP10R; /*!< RTC backup register 10, Address offset: 0x78 */ __IO uint32_t BKP11R; /*!< RTC backup register 11, Address offset: 0x7C */ __IO uint32_t BKP12R; /*!< RTC backup register 12, Address offset: 0x80 */ __IO uint32_t BKP13R; /*!< RTC backup register 13, Address offset: 0x84 */ __IO uint32_t BKP14R; /*!< RTC backup register 14, Address offset: 0x88 */ __IO uint32_t BKP15R; /*!< RTC backup register 15, Address offset: 0x8C */ __IO uint32_t BKP16R; /*!< RTC backup register 16, Address offset: 0x90 */ __IO uint32_t BKP17R; /*!< RTC backup register 17, Address offset: 0x94 */ __IO uint32_t BKP18R; /*!< RTC backup register 18, Address offset: 0x98 */ __IO uint32_t BKP19R; /*!< RTC backup register 19, Address offset: 0x9C */ } RTC_TypeDef; /** * @brief SD host Interface */ typedef struct { __IO uint32_t POWER; /*!< SDIO power control register, Address offset: 0x00 */ __IO uint32_t CLKCR; /*!< SDI clock control register, Address offset: 0x04 */ __IO uint32_t ARG; /*!< SDIO argument register, Address offset: 0x08 */ __IO uint32_t CMD; /*!< SDIO command register, Address offset: 0x0C */ __IO const uint32_t RESPCMD; /*!< SDIO command response register, Address offset: 0x10 */ __IO const uint32_t RESP1; /*!< SDIO response 1 register, Address offset: 0x14 */ __IO const uint32_t RESP2; /*!< SDIO response 2 register, Address offset: 0x18 */ __IO const uint32_t RESP3; /*!< SDIO response 3 register, Address offset: 0x1C */ __IO const uint32_t RESP4; /*!< SDIO response 4 register, Address offset: 0x20 */ __IO uint32_t DTIMER; /*!< SDIO data timer register, Address offset: 0x24 */ __IO uint32_t DLEN; /*!< SDIO data length register, Address offset: 0x28 */ __IO uint32_t DCTRL; /*!< SDIO data control register, Address offset: 0x2C */ __IO const uint32_t DCOUNT; /*!< SDIO data counter register, Address offset: 0x30 */ __IO const uint32_t STA; /*!< SDIO status register, Address offset: 0x34 */ __IO uint32_t ICR; /*!< SDIO interrupt clear register, Address offset: 0x38 */ __IO uint32_t MASK; /*!< SDIO mask register, Address offset: 0x3C */ uint32_t RESERVED0[2]; /*!< Reserved, 0x40-0x44 */ __IO const uint32_t FIFOCNT; /*!< SDIO FIFO counter register, Address offset: 0x48 */ uint32_t RESERVED1[13]; /*!< Reserved, 0x4C-0x7C */ __IO uint32_t FIFO; /*!< SDIO data FIFO register, Address offset: 0x80 */ } SDIO_TypeDef; /** * @brief Serial Peripheral Interface */ typedef struct { __IO uint32_t CR1; /*!< SPI control register 1 (not used in I2S mode), Address offset: 0x00 */ __IO uint32_t CR2; /*!< SPI control register 2, Address offset: 0x04 */ __IO uint32_t SR; /*!< SPI status register, Address offset: 0x08 */ __IO uint32_t DR; /*!< SPI data register, Address offset: 0x0C */ __IO uint32_t CRCPR; /*!< SPI CRC polynomial register (not used in I2S mode), Address offset: 0x10 */ __IO uint32_t RXCRCR; /*!< SPI RX CRC register (not used in I2S mode), Address offset: 0x14 */ __IO uint32_t TXCRCR; /*!< SPI TX CRC register (not used in I2S mode), Address offset: 0x18 */ __IO uint32_t I2SCFGR; /*!< SPI_I2S configuration register, Address offset: 0x1C */ __IO uint32_t I2SPR; /*!< SPI_I2S prescaler register, Address offset: 0x20 */ } SPI_TypeDef; /** * @brief QUAD Serial Peripheral Interface */ typedef struct { __IO uint32_t CR; /*!< QUADSPI Control register, Address offset: 0x00 */ __IO uint32_t DCR; /*!< QUADSPI Device Configuration register, Address offset: 0x04 */ __IO uint32_t SR; /*!< QUADSPI Status register, Address offset: 0x08 */ __IO uint32_t FCR; /*!< QUADSPI Flag Clear register, Address offset: 0x0C */ __IO uint32_t DLR; /*!< QUADSPI Data Length register, Address offset: 0x10 */ __IO uint32_t CCR; /*!< QUADSPI Communication Configuration register, Address offset: 0x14 */ __IO uint32_t AR; /*!< QUADSPI Address register, Address offset: 0x18 */ __IO uint32_t ABR; /*!< QUADSPI Alternate Bytes register, Address offset: 0x1C */ __IO uint32_t DR; /*!< QUADSPI Data register, Address offset: 0x20 */ __IO uint32_t PSMKR; /*!< QUADSPI Polling Status Mask register, Address offset: 0x24 */ __IO uint32_t PSMAR; /*!< QUADSPI Polling Status Match register, Address offset: 0x28 */ __IO uint32_t PIR; /*!< QUADSPI Polling Interval register, Address offset: 0x2C */ __IO uint32_t LPTR; /*!< QUADSPI Low Power Timeout register, Address offset: 0x30 */ } QUADSPI_TypeDef; /** * @brief TIM */ typedef struct { __IO uint32_t CR1; /*!< TIM control register 1, Address offset: 0x00 */ __IO uint32_t CR2; /*!< TIM control register 2, Address offset: 0x04 */ __IO uint32_t SMCR; /*!< TIM slave mode control register, Address offset: 0x08 */ __IO uint32_t DIER; /*!< TIM DMA/interrupt enable register, Address offset: 0x0C */ __IO uint32_t SR; /*!< TIM status register, Address offset: 0x10 */ __IO uint32_t EGR; /*!< TIM event generation register, Address offset: 0x14 */ __IO uint32_t CCMR1; /*!< TIM capture/compare mode register 1, Address offset: 0x18 */ __IO uint32_t CCMR2; /*!< TIM capture/compare mode register 2, Address offset: 0x1C */ __IO uint32_t CCER; /*!< TIM capture/compare enable register, Address offset: 0x20 */ __IO uint32_t CNT; /*!< TIM counter register, Address offset: 0x24 */ __IO uint32_t PSC; /*!< TIM prescaler, Address offset: 0x28 */ __IO uint32_t ARR; /*!< TIM auto-reload register, Address offset: 0x2C */ __IO uint32_t RCR; /*!< TIM repetition counter register, Address offset: 0x30 */ __IO uint32_t CCR1; /*!< TIM capture/compare register 1, Address offset: 0x34 */ __IO uint32_t CCR2; /*!< TIM capture/compare register 2, Address offset: 0x38 */ __IO uint32_t CCR3; /*!< TIM capture/compare register 3, Address offset: 0x3C */ __IO uint32_t CCR4; /*!< TIM capture/compare register 4, Address offset: 0x40 */ __IO uint32_t BDTR; /*!< TIM break and dead-time register, Address offset: 0x44 */ __IO uint32_t DCR; /*!< TIM DMA control register, Address offset: 0x48 */ __IO uint32_t DMAR; /*!< TIM DMA address for full transfer, Address offset: 0x4C */ __IO uint32_t OR; /*!< TIM option register, Address offset: 0x50 */ } TIM_TypeDef; /** * @brief Universal Synchronous Asynchronous Receiver Transmitter */ typedef struct { __IO uint32_t SR; /*!< USART Status register, Address offset: 0x00 */ __IO uint32_t DR; /*!< USART Data register, Address offset: 0x04 */ __IO uint32_t BRR; /*!< USART Baud rate register, Address offset: 0x08 */ __IO uint32_t CR1; /*!< USART Control register 1, Address offset: 0x0C */ __IO uint32_t CR2; /*!< USART Control register 2, Address offset: 0x10 */ __IO uint32_t CR3; /*!< USART Control register 3, Address offset: 0x14 */ __IO uint32_t GTPR; /*!< USART Guard time and prescaler register, Address offset: 0x18 */ } USART_TypeDef; /** * @brief Window WATCHDOG */ typedef struct { __IO uint32_t CR; /*!< WWDG Control register, Address offset: 0x00 */ __IO uint32_t CFR; /*!< WWDG Configuration register, Address offset: 0x04 */ __IO uint32_t SR; /*!< WWDG Status register, Address offset: 0x08 */ } WWDG_TypeDef; /** * @brief RNG */ typedef struct { __IO uint32_t CR; /*!< RNG control register, Address offset: 0x00 */ __IO uint32_t SR; /*!< RNG status register, Address offset: 0x04 */ __IO uint32_t DR; /*!< RNG data register, Address offset: 0x08 */ } RNG_TypeDef; /** * @brief USB_OTG_Core_Registers */ typedef struct { __IO uint32_t GOTGCTL; /*!< USB_OTG Control and Status Register 000h */ __IO uint32_t GOTGINT; /*!< USB_OTG Interrupt Register 004h */ __IO uint32_t GAHBCFG; /*!< Core AHB Configuration Register 008h */ __IO uint32_t GUSBCFG; /*!< Core USB Configuration Register 00Ch */ __IO uint32_t GRSTCTL; /*!< Core Reset Register 010h */ __IO uint32_t GINTSTS; /*!< Core Interrupt Register 014h */ __IO uint32_t GINTMSK; /*!< Core Interrupt Mask Register 018h */ __IO uint32_t GRXSTSR; /*!< Receive Sts Q Read Register 01Ch */ __IO uint32_t GRXSTSP; /*!< Receive Sts Q Read & POP Register 020h */ __IO uint32_t GRXFSIZ; /*!< Receive FIFO Size Register 024h */ __IO uint32_t DIEPTXF0_HNPTXFSIZ; /*!< EP0 / Non Periodic Tx FIFO Size Register 028h */ __IO uint32_t HNPTXSTS; /*!< Non Periodic Tx FIFO/Queue Sts reg 02Ch */ uint32_t Reserved30[2]; /*!< Reserved 030h */ __IO uint32_t GCCFG; /*!< General Purpose IO Register 038h */ __IO uint32_t CID; /*!< User ID Register 03Ch */ uint32_t Reserved5[3]; /*!< Reserved 040h-048h */ __IO uint32_t GHWCFG3; /*!< User HW config3 04Ch */ uint32_t Reserved6; /*!< Reserved 050h */ __IO uint32_t GLPMCFG; /*!< LPM Register 054h */ uint32_t Reserved; /*!< Reserved 058h */ __IO uint32_t GDFIFOCFG; /*!< DFIFO Software Config Register 05Ch */ uint32_t Reserved43[40]; /*!< Reserved 058h-0FFh */ __IO uint32_t HPTXFSIZ; /*!< Host Periodic Tx FIFO Size Reg 100h */ __IO uint32_t DIEPTXF[0x0F]; /*!< dev Periodic Transmit FIFO */ } USB_OTG_GlobalTypeDef; /** * @brief USB_OTG_device_Registers */ typedef struct { __IO uint32_t DCFG; /*!< dev Configuration Register 800h */ __IO uint32_t DCTL; /*!< dev Control Register 804h */ __IO uint32_t DSTS; /*!< dev Status Register (RO) 808h */ uint32_t Reserved0C; /*!< Reserved 80Ch */ __IO uint32_t DIEPMSK; /*!< dev IN Endpoint Mask 810h */ __IO uint32_t DOEPMSK; /*!< dev OUT Endpoint Mask 814h */ __IO uint32_t DAINT; /*!< dev All Endpoints Itr Reg 818h */ __IO uint32_t DAINTMSK; /*!< dev All Endpoints Itr Mask 81Ch */ uint32_t Reserved20; /*!< Reserved 820h */ uint32_t Reserved9; /*!< Reserved 824h */ __IO uint32_t DVBUSDIS; /*!< dev VBUS discharge Register 828h */ __IO uint32_t DVBUSPULSE; /*!< dev VBUS Pulse Register 82Ch */ __IO uint32_t DTHRCTL; /*!< dev threshold 830h */ __IO uint32_t DIEPEMPMSK; /*!< dev empty msk 834h */ __IO uint32_t DEACHINT; /*!< dedicated EP interrupt 838h */ __IO uint32_t DEACHMSK; /*!< dedicated EP msk 83Ch */ uint32_t Reserved40; /*!< dedicated EP mask 840h */ __IO uint32_t DINEP1MSK; /*!< dedicated EP mask 844h */ uint32_t Reserved44[15]; /*!< Reserved 844-87Ch */ __IO uint32_t DOUTEP1MSK; /*!< dedicated EP msk 884h */ } USB_OTG_DeviceTypeDef; /** * @brief USB_OTG_IN_Endpoint-Specific_Register */ typedef struct { __IO uint32_t DIEPCTL; /*!< dev IN Endpoint Control Reg 900h + (ep_num * 20h) + 00h */ uint32_t Reserved04; /*!< Reserved 900h + (ep_num * 20h) + 04h */ __IO uint32_t DIEPINT; /*!< dev IN Endpoint Itr Reg 900h + (ep_num * 20h) + 08h */ uint32_t Reserved0C; /*!< Reserved 900h + (ep_num * 20h) + 0Ch */ __IO uint32_t DIEPTSIZ; /*!< IN Endpoint Txfer Size 900h + (ep_num * 20h) + 10h */ __IO uint32_t DIEPDMA; /*!< IN Endpoint DMA Address Reg 900h + (ep_num * 20h) + 14h */ __IO uint32_t DTXFSTS; /*!< IN Endpoint Tx FIFO Status Reg 900h + (ep_num * 20h) + 18h */ uint32_t Reserved18; /*!< Reserved 900h+(ep_num*20h)+1Ch-900h+ (ep_num * 20h) + 1Ch */ } USB_OTG_INEndpointTypeDef; /** * @brief USB_OTG_OUT_Endpoint-Specific_Registers */ typedef struct { __IO uint32_t DOEPCTL; /*!< dev OUT Endpoint Control Reg B00h + (ep_num * 20h) + 00h */ uint32_t Reserved04; /*!< Reserved B00h + (ep_num * 20h) + 04h */ __IO uint32_t DOEPINT; /*!< dev OUT Endpoint Itr Reg B00h + (ep_num * 20h) + 08h */ uint32_t Reserved0C; /*!< Reserved B00h + (ep_num * 20h) + 0Ch */ __IO uint32_t DOEPTSIZ; /*!< dev OUT Endpoint Txfer Size B00h + (ep_num * 20h) + 10h */ __IO uint32_t DOEPDMA; /*!< dev OUT Endpoint DMA Address B00h + (ep_num * 20h) + 14h */ uint32_t Reserved18[2]; /*!< Reserved B00h + (ep_num * 20h) + 18h - B00h + (ep_num * 20h) + 1Ch */ } USB_OTG_OUTEndpointTypeDef; /** * @brief USB_OTG_Host_Mode_Register_Structures */ typedef struct { __IO uint32_t HCFG; /*!< Host Configuration Register 400h */ __IO uint32_t HFIR; /*!< Host Frame Interval Register 404h */ __IO uint32_t HFNUM; /*!< Host Frame Nbr/Frame Remaining 408h */ uint32_t Reserved40C; /*!< Reserved 40Ch */ __IO uint32_t HPTXSTS; /*!< Host Periodic Tx FIFO/ Queue Status 410h */ __IO uint32_t HAINT; /*!< Host All Channels Interrupt Register 414h */ __IO uint32_t HAINTMSK; /*!< Host All Channels Interrupt Mask 418h */ } USB_OTG_HostTypeDef; /** * @brief USB_OTG_Host_Channel_Specific_Registers */ typedef struct { __IO uint32_t HCCHAR; /*!< Host Channel Characteristics Register 500h */ __IO uint32_t HCSPLT; /*!< Host Channel Split Control Register 504h */ __IO uint32_t HCINT; /*!< Host Channel Interrupt Register 508h */ __IO uint32_t HCINTMSK; /*!< Host Channel Interrupt Mask Register 50Ch */ __IO uint32_t HCTSIZ; /*!< Host Channel Transfer Size Register 510h */ __IO uint32_t HCDMA; /*!< Host Channel DMA Address Register 514h */ uint32_t Reserved[2]; /*!< Reserved */ } USB_OTG_HostChannelTypeDef; /** * @} */ /** @addtogroup Peripheral_memory_map * @{ */ #define FLASH_BASE 0x08000000UL /*!< FLASH(up to 1 MB) base address in the alias region */ #define SRAM1_BASE 0x20000000UL /*!< SRAM1(256 KB) base address in the alias region */ #define PERIPH_BASE 0x40000000UL /*!< Peripheral base address in the alias region */ #define FSMC_R_BASE 0xA0000000UL /*!< FSMC registers base address */ #define QSPI_R_BASE 0xA0001000UL /*!< QuadSPI registers base address */ #define SRAM1_BB_BASE 0x22000000UL /*!< SRAM1(256 KB) base address in the bit-band region */ #define PERIPH_BB_BASE 0x42000000UL /*!< Peripheral base address in the bit-band region */ #define FLASH_END 0x080FFFFFUL /*!< FLASH end address */ #define FLASH_OTP_BASE 0x1FFF7800UL /*!< Base address of : (up to 528 Bytes) embedded FLASH OTP Area */ #define FLASH_OTP_END 0x1FFF7A0FUL /*!< End address of : (up to 528 Bytes) embedded FLASH OTP Area */ /* Legacy defines */ #define SRAM_BASE SRAM1_BASE #define SRAM_BB_BASE SRAM1_BB_BASE /*!< Peripheral memory map */ #define APB1PERIPH_BASE PERIPH_BASE #define APB2PERIPH_BASE (PERIPH_BASE + 0x00010000UL) #define AHB1PERIPH_BASE (PERIPH_BASE + 0x00020000UL) #define AHB2PERIPH_BASE (PERIPH_BASE + 0x10000000UL) /*!< APB1 peripherals */ #define TIM2_BASE (APB1PERIPH_BASE + 0x0000UL) #define TIM3_BASE (APB1PERIPH_BASE + 0x0400UL) #define TIM4_BASE (APB1PERIPH_BASE + 0x0800UL) #define TIM5_BASE (APB1PERIPH_BASE + 0x0C00UL) #define TIM6_BASE (APB1PERIPH_BASE + 0x1000UL) #define TIM7_BASE (APB1PERIPH_BASE + 0x1400UL) #define TIM12_BASE (APB1PERIPH_BASE + 0x1800UL) #define TIM13_BASE (APB1PERIPH_BASE + 0x1C00UL) #define TIM14_BASE (APB1PERIPH_BASE + 0x2000UL) #define RTC_BASE (APB1PERIPH_BASE + 0x2800UL) #define WWDG_BASE (APB1PERIPH_BASE + 0x2C00UL) #define IWDG_BASE (APB1PERIPH_BASE + 0x3000UL) #define I2S2ext_BASE (APB1PERIPH_BASE + 0x3400UL) #define SPI2_BASE (APB1PERIPH_BASE + 0x3800UL) #define SPI3_BASE (APB1PERIPH_BASE + 0x3C00UL) #define I2S3ext_BASE (APB1PERIPH_BASE + 0x4000UL) #define USART2_BASE (APB1PERIPH_BASE + 0x4400UL) #define USART3_BASE (APB1PERIPH_BASE + 0x4800UL) #define I2C1_BASE (APB1PERIPH_BASE + 0x5400UL) #define I2C2_BASE (APB1PERIPH_BASE + 0x5800UL) #define I2C3_BASE (APB1PERIPH_BASE + 0x5C00UL) #define FMPI2C1_BASE (APB1PERIPH_BASE + 0x6000UL) #define CAN1_BASE (APB1PERIPH_BASE + 0x6400UL) #define CAN2_BASE (APB1PERIPH_BASE + 0x6800UL) #define PWR_BASE (APB1PERIPH_BASE + 0x7000UL) /*!< APB2 peripherals */ #define TIM1_BASE (APB2PERIPH_BASE + 0x0000UL) #define TIM8_BASE (APB2PERIPH_BASE + 0x0400UL) #define USART1_BASE (APB2PERIPH_BASE + 0x1000UL) #define USART6_BASE (APB2PERIPH_BASE + 0x1400UL) #define ADC1_BASE (APB2PERIPH_BASE + 0x2000UL) #define ADC1_COMMON_BASE (APB2PERIPH_BASE + 0x2300UL) /* Legacy define */ #define ADC_BASE ADC1_COMMON_BASE #define SDIO_BASE (APB2PERIPH_BASE + 0x2C00UL) #define SPI1_BASE (APB2PERIPH_BASE + 0x3000UL) #define SPI4_BASE (APB2PERIPH_BASE + 0x3400UL) #define SYSCFG_BASE (APB2PERIPH_BASE + 0x3800UL) #define EXTI_BASE (APB2PERIPH_BASE + 0x3C00UL) #define TIM9_BASE (APB2PERIPH_BASE + 0x4000UL) #define TIM10_BASE (APB2PERIPH_BASE + 0x4400UL) #define TIM11_BASE (APB2PERIPH_BASE + 0x4800UL) #define SPI5_BASE (APB2PERIPH_BASE + 0x5000UL) #define DFSDM1_BASE (APB2PERIPH_BASE + 0x6000UL) #define DFSDM1_Channel0_BASE (DFSDM1_BASE + 0x00UL) #define DFSDM1_Channel1_BASE (DFSDM1_BASE + 0x20UL) #define DFSDM1_Channel2_BASE (DFSDM1_BASE + 0x40UL) #define DFSDM1_Channel3_BASE (DFSDM1_BASE + 0x60UL) #define DFSDM1_Filter0_BASE (DFSDM1_BASE + 0x100UL) #define DFSDM1_Filter1_BASE (DFSDM1_BASE + 0x180UL) /*!< AHB1 peripherals */ #define GPIOA_BASE (AHB1PERIPH_BASE + 0x0000UL) #define GPIOB_BASE (AHB1PERIPH_BASE + 0x0400UL) #define GPIOC_BASE (AHB1PERIPH_BASE + 0x0800UL) #define GPIOD_BASE (AHB1PERIPH_BASE + 0x0C00UL) #define GPIOE_BASE (AHB1PERIPH_BASE + 0x1000UL) #define GPIOF_BASE (AHB1PERIPH_BASE + 0x1400UL) #define GPIOG_BASE (AHB1PERIPH_BASE + 0x1800UL) #define GPIOH_BASE (AHB1PERIPH_BASE + 0x1C00UL) #define CRC_BASE (AHB1PERIPH_BASE + 0x3000UL) #define RCC_BASE (AHB1PERIPH_BASE + 0x3800UL) #define FLASH_R_BASE (AHB1PERIPH_BASE + 0x3C00UL) #define DMA1_BASE (AHB1PERIPH_BASE + 0x6000UL) #define DMA1_Stream0_BASE (DMA1_BASE + 0x010UL) #define DMA1_Stream1_BASE (DMA1_BASE + 0x028UL) #define DMA1_Stream2_BASE (DMA1_BASE + 0x040UL) #define DMA1_Stream3_BASE (DMA1_BASE + 0x058UL) #define DMA1_Stream4_BASE (DMA1_BASE + 0x070UL) #define DMA1_Stream5_BASE (DMA1_BASE + 0x088UL) #define DMA1_Stream6_BASE (DMA1_BASE + 0x0A0UL) #define DMA1_Stream7_BASE (DMA1_BASE + 0x0B8UL) #define DMA2_BASE (AHB1PERIPH_BASE + 0x6400UL) #define DMA2_Stream0_BASE (DMA2_BASE + 0x010UL) #define DMA2_Stream1_BASE (DMA2_BASE + 0x028UL) #define DMA2_Stream2_BASE (DMA2_BASE + 0x040UL) #define DMA2_Stream3_BASE (DMA2_BASE + 0x058UL) #define DMA2_Stream4_BASE (DMA2_BASE + 0x070UL) #define DMA2_Stream5_BASE (DMA2_BASE + 0x088UL) #define DMA2_Stream6_BASE (DMA2_BASE + 0x0A0UL) #define DMA2_Stream7_BASE (DMA2_BASE + 0x0B8UL) /*!< AHB2 peripherals */ #define RNG_BASE (AHB2PERIPH_BASE + 0x60800UL) /*!< FSMC Bankx registers base address */ #define FSMC_Bank1_R_BASE (FSMC_R_BASE + 0x0000UL) #define FSMC_Bank1E_R_BASE (FSMC_R_BASE + 0x0104UL) /*!< Debug MCU registers base address */ #define DBGMCU_BASE 0xE0042000UL /*!< USB registers base address */ #define USB_OTG_FS_PERIPH_BASE 0x50000000UL #define USB_OTG_GLOBAL_BASE 0x000UL #define USB_OTG_DEVICE_BASE 0x800UL #define USB_OTG_IN_ENDPOINT_BASE 0x900UL #define USB_OTG_OUT_ENDPOINT_BASE 0xB00UL #define USB_OTG_EP_REG_SIZE 0x20UL #define USB_OTG_HOST_BASE 0x400UL #define USB_OTG_HOST_PORT_BASE 0x440UL #define USB_OTG_HOST_CHANNEL_BASE 0x500UL #define USB_OTG_HOST_CHANNEL_SIZE 0x20UL #define USB_OTG_PCGCCTL_BASE 0xE00UL #define USB_OTG_FIFO_BASE 0x1000UL #define USB_OTG_FIFO_SIZE 0x1000UL #define UID_BASE 0x1FFF7A10UL /*!< Unique device ID register base address */ #define FLASHSIZE_BASE 0x1FFF7A22UL /*!< FLASH Size register base address */ #define PACKAGE_BASE 0x1FFF7BF0UL /*!< Package size register base address */ /** * @} */ /** @addtogroup Peripheral_declaration * @{ */ #define TIM2 ((TIM_TypeDef *) TIM2_BASE) #define TIM3 ((TIM_TypeDef *) TIM3_BASE) #define TIM4 ((TIM_TypeDef *) TIM4_BASE) #define TIM5 ((TIM_TypeDef *) TIM5_BASE) #define TIM6 ((TIM_TypeDef *) TIM6_BASE) #define TIM7 ((TIM_TypeDef *) TIM7_BASE) #define TIM12 ((TIM_TypeDef *) TIM12_BASE) #define TIM13 ((TIM_TypeDef *) TIM13_BASE) #define TIM14 ((TIM_TypeDef *) TIM14_BASE) #define RTC ((RTC_TypeDef *) RTC_BASE) #define WWDG ((WWDG_TypeDef *) WWDG_BASE) #define IWDG ((IWDG_TypeDef *) IWDG_BASE) #define I2S2ext ((SPI_TypeDef *) I2S2ext_BASE) #define SPI2 ((SPI_TypeDef *) SPI2_BASE) #define SPI3 ((SPI_TypeDef *) SPI3_BASE) #define I2S3ext ((SPI_TypeDef *) I2S3ext_BASE) #define USART2 ((USART_TypeDef *) USART2_BASE) #define USART3 ((USART_TypeDef *) USART3_BASE) #define I2C1 ((I2C_TypeDef *) I2C1_BASE) #define I2C2 ((I2C_TypeDef *) I2C2_BASE) #define I2C3 ((I2C_TypeDef *) I2C3_BASE) #define FMPI2C1 ((FMPI2C_TypeDef *) FMPI2C1_BASE) #define CAN1 ((CAN_TypeDef *) CAN1_BASE) #define CAN2 ((CAN_TypeDef *) CAN2_BASE) #define PWR ((PWR_TypeDef *) PWR_BASE) #define TIM1 ((TIM_TypeDef *) TIM1_BASE) #define TIM8 ((TIM_TypeDef *) TIM8_BASE) #define USART1 ((USART_TypeDef *) USART1_BASE) #define USART6 ((USART_TypeDef *) USART6_BASE) #define ADC1 ((ADC_TypeDef *) ADC1_BASE) #define ADC1_COMMON ((ADC_Common_TypeDef *) ADC1_COMMON_BASE) /* Legacy define */ #define ADC ADC1_COMMON #define SDIO ((SDIO_TypeDef *) SDIO_BASE) #define SPI1 ((SPI_TypeDef *) SPI1_BASE) #define SPI4 ((SPI_TypeDef *) SPI4_BASE) #define SYSCFG ((SYSCFG_TypeDef *) SYSCFG_BASE) #define EXTI ((EXTI_TypeDef *) EXTI_BASE) #define TIM9 ((TIM_TypeDef *) TIM9_BASE) #define TIM10 ((TIM_TypeDef *) TIM10_BASE) #define TIM11 ((TIM_TypeDef *) TIM11_BASE) #define SPI5 ((SPI_TypeDef *) SPI5_BASE) #define DFSDM1_Channel0 ((DFSDM_Channel_TypeDef *) DFSDM1_Channel0_BASE) #define DFSDM1_Channel1 ((DFSDM_Channel_TypeDef *) DFSDM1_Channel1_BASE) #define DFSDM1_Channel2 ((DFSDM_Channel_TypeDef *) DFSDM1_Channel2_BASE) #define DFSDM1_Channel3 ((DFSDM_Channel_TypeDef *) DFSDM1_Channel3_BASE) #define DFSDM1_Filter0 ((DFSDM_Filter_TypeDef *) DFSDM1_Filter0_BASE) #define DFSDM1_Filter1 ((DFSDM_Filter_TypeDef *) DFSDM1_Filter1_BASE) #define GPIOA ((GPIO_TypeDef *) GPIOA_BASE) #define GPIOB ((GPIO_TypeDef *) GPIOB_BASE) #define GPIOC ((GPIO_TypeDef *) GPIOC_BASE) #define GPIOD ((GPIO_TypeDef *) GPIOD_BASE) #define GPIOE ((GPIO_TypeDef *) GPIOE_BASE) #define GPIOF ((GPIO_TypeDef *) GPIOF_BASE) #define GPIOG ((GPIO_TypeDef *) GPIOG_BASE) #define GPIOH ((GPIO_TypeDef *) GPIOH_BASE) #define CRC ((CRC_TypeDef *) CRC_BASE) #define RCC ((RCC_TypeDef *) RCC_BASE) #define FLASH ((FLASH_TypeDef *) FLASH_R_BASE) #define DMA1 ((DMA_TypeDef *) DMA1_BASE) #define DMA1_Stream0 ((DMA_Stream_TypeDef *) DMA1_Stream0_BASE) #define DMA1_Stream1 ((DMA_Stream_TypeDef *) DMA1_Stream1_BASE) #define DMA1_Stream2 ((DMA_Stream_TypeDef *) DMA1_Stream2_BASE) #define DMA1_Stream3 ((DMA_Stream_TypeDef *) DMA1_Stream3_BASE) #define DMA1_Stream4 ((DMA_Stream_TypeDef *) DMA1_Stream4_BASE) #define DMA1_Stream5 ((DMA_Stream_TypeDef *) DMA1_Stream5_BASE) #define DMA1_Stream6 ((DMA_Stream_TypeDef *) DMA1_Stream6_BASE) #define DMA1_Stream7 ((DMA_Stream_TypeDef *) DMA1_Stream7_BASE) #define DMA2 ((DMA_TypeDef *) DMA2_BASE) #define DMA2_Stream0 ((DMA_Stream_TypeDef *) DMA2_Stream0_BASE) #define DMA2_Stream1 ((DMA_Stream_TypeDef *) DMA2_Stream1_BASE) #define DMA2_Stream2 ((DMA_Stream_TypeDef *) DMA2_Stream2_BASE) #define DMA2_Stream3 ((DMA_Stream_TypeDef *) DMA2_Stream3_BASE) #define DMA2_Stream4 ((DMA_Stream_TypeDef *) DMA2_Stream4_BASE) #define DMA2_Stream5 ((DMA_Stream_TypeDef *) DMA2_Stream5_BASE) #define DMA2_Stream6 ((DMA_Stream_TypeDef *) DMA2_Stream6_BASE) #define DMA2_Stream7 ((DMA_Stream_TypeDef *) DMA2_Stream7_BASE) #define RNG ((RNG_TypeDef *) RNG_BASE) #define FSMC_Bank1 ((FSMC_Bank1_TypeDef *) FSMC_Bank1_R_BASE) #define FSMC_Bank1E ((FSMC_Bank1E_TypeDef *) FSMC_Bank1E_R_BASE) #define QUADSPI ((QUADSPI_TypeDef *) QSPI_R_BASE) #define DBGMCU ((DBGMCU_TypeDef *) DBGMCU_BASE) #define USB_OTG_FS ((USB_OTG_GlobalTypeDef *) USB_OTG_FS_PERIPH_BASE) /** * @} */ /** @addtogroup Exported_constants * @{ */ /** @addtogroup Peripheral_Registers_Bits_Definition * @{ */ /******************************************************************************/ /* Peripheral Registers_Bits_Definition */ /******************************************************************************/ /******************************************************************************/ /* */ /* Analog to Digital Converter */ /* */ /******************************************************************************/ /******************** Bit definition for ADC_SR register ********************/ #define ADC_SR_AWD_Pos (0U) #define ADC_SR_AWD_Msk (0x1UL << ADC_SR_AWD_Pos) /*!< 0x00000001 */ #define ADC_SR_AWD ADC_SR_AWD_Msk /*!
© COPYRIGHT(c) 2017 STMicroelectronics
* * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. Neither the name of STMicroelectronics nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ /** @addtogroup CMSIS_Device * @{ */ /** @addtogroup stm32f413xx * @{ */ #ifndef __STM32F413xx_H #define __STM32F413xx_H #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ /** @addtogroup Configuration_section_for_CMSIS * @{ */ /** * @brief Configuration of the Cortex-M4 Processor and Core Peripherals */ #define __CM4_REV 0x0001U /*!< Core revision r0p1 */ #define __MPU_PRESENT 1U /*!< STM32F4XX provides an MPU */ #define __NVIC_PRIO_BITS 4U /*!< STM32F4XX uses 4 Bits for the Priority Levels */ #define __Vendor_SysTickConfig 0U /*!< Set to 1 if different SysTick Config is used */ #define __FPU_PRESENT 1U /*!< FPU present */ /** * @} */ /** @addtogroup Peripheral_interrupt_number_definition * @{ */ /** * @brief STM32F4XX Interrupt Number Definition, according to the selected device * in @ref Library_configuration_section */ typedef enum { /****** Cortex-M4 Processor Exceptions Numbers ****************************************************************/ NonMaskableInt_IRQn = -14, /*!< 2 Non Maskable Interrupt */ MemoryManagement_IRQn = -12, /*!< 4 Cortex-M4 Memory Management Interrupt */ BusFault_IRQn = -11, /*!< 5 Cortex-M4 Bus Fault Interrupt */ UsageFault_IRQn = -10, /*!< 6 Cortex-M4 Usage Fault Interrupt */ SVCall_IRQn = -5, /*!< 11 Cortex-M4 SV Call Interrupt */ DebugMonitor_IRQn = -4, /*!< 12 Cortex-M4 Debug Monitor Interrupt */ PendSV_IRQn = -2, /*!< 14 Cortex-M4 Pend SV Interrupt */ SysTick_IRQn = -1, /*!< 15 Cortex-M4 System Tick Interrupt */ /****** STM32 specific Interrupt Numbers **********************************************************************/ WWDG_IRQn = 0, /*!< Window WatchDog Interrupt */ PVD_IRQn = 1, /*!< PVD through EXTI Line detection Interrupt */ TAMP_STAMP_IRQn = 2, /*!< Tamper and TimeStamp interrupts through the EXTI line */ RTC_WKUP_IRQn = 3, /*!< RTC Wakeup interrupt through the EXTI line */ FLASH_IRQn = 4, /*!< FLASH global Interrupt */ RCC_IRQn = 5, /*!< RCC global Interrupt */ EXTI0_IRQn = 6, /*!< EXTI Line0 Interrupt */ EXTI1_IRQn = 7, /*!< EXTI Line1 Interrupt */ EXTI2_IRQn = 8, /*!< EXTI Line2 Interrupt */ EXTI3_IRQn = 9, /*!< EXTI Line3 Interrupt */ EXTI4_IRQn = 10, /*!< EXTI Line4 Interrupt */ DMA1_Stream0_IRQn = 11, /*!< DMA1 Stream 0 global Interrupt */ DMA1_Stream1_IRQn = 12, /*!< DMA1 Stream 1 global Interrupt */ DMA1_Stream2_IRQn = 13, /*!< DMA1 Stream 2 global Interrupt */ DMA1_Stream3_IRQn = 14, /*!< DMA1 Stream 3 global Interrupt */ DMA1_Stream4_IRQn = 15, /*!< DMA1 Stream 4 global Interrupt */ DMA1_Stream5_IRQn = 16, /*!< DMA1 Stream 5 global Interrupt */ DMA1_Stream6_IRQn = 17, /*!< DMA1 Stream 6 global Interrupt */ ADC_IRQn = 18, /*!< ADC1, ADC2 and ADC3 global Interrupts */ CAN1_TX_IRQn = 19, /*!< CAN1 TX Interrupt */ CAN1_RX0_IRQn = 20, /*!< CAN1 RX0 Interrupt */ CAN1_RX1_IRQn = 21, /*!< CAN1 RX1 Interrupt */ CAN1_SCE_IRQn = 22, /*!< CAN1 SCE Interrupt */ EXTI9_5_IRQn = 23, /*!< External Line[9:5] Interrupts */ TIM1_BRK_TIM9_IRQn = 24, /*!< TIM1 Break interrupt and TIM9 global interrupt */ TIM1_UP_TIM10_IRQn = 25, /*!< TIM1 Update Interrupt and TIM10 global interrupt */ TIM1_TRG_COM_TIM11_IRQn = 26, /*!< TIM1 Trigger and Commutation Interrupt and TIM11 global interrupt */ TIM1_CC_IRQn = 27, /*!< TIM1 Capture Compare Interrupt */ TIM2_IRQn = 28, /*!< TIM2 global Interrupt */ TIM3_IRQn = 29, /*!< TIM3 global Interrupt */ TIM4_IRQn = 30, /*!< TIM4 global Interrupt */ I2C1_EV_IRQn = 31, /*!< I2C1 Event Interrupt */ I2C1_ER_IRQn = 32, /*!< I2C1 Error Interrupt */ I2C2_EV_IRQn = 33, /*!< I2C2 Event Interrupt */ I2C2_ER_IRQn = 34, /*!< I2C2 Error Interrupt */ SPI1_IRQn = 35, /*!< SPI1 global Interrupt */ SPI2_IRQn = 36, /*!< SPI2 global Interrupt */ USART1_IRQn = 37, /*!< USART1 global Interrupt */ USART2_IRQn = 38, /*!< USART2 global Interrupt */ USART3_IRQn = 39, /*!< USART3 global Interrupt */ EXTI15_10_IRQn = 40, /*!< External Line[15:10] Interrupts */ RTC_Alarm_IRQn = 41, /*!< RTC Alarm (A and B) through EXTI Line Interrupt */ OTG_FS_WKUP_IRQn = 42, /*!< USB OTG FS Wakeup through EXTI line interrupt */ TIM8_BRK_TIM12_IRQn = 43, /*!< TIM8 Break Interrupt and TIM12 global interrupt */ TIM8_UP_TIM13_IRQn = 44, /*!< TIM8 Update Interrupt and TIM13 global interrupt */ TIM8_TRG_COM_TIM14_IRQn = 45, /*!< TIM8 Trigger and Commutation Interrupt and TIM14 global interrupt */ TIM8_CC_IRQn = 46, /*!< TIM8 Capture Compare global interrupt */ DMA1_Stream7_IRQn = 47, /*!< DMA1 Stream7 Interrupt */ SDIO_IRQn = 49, /*!< SDIO global Interrupt */ TIM5_IRQn = 50, /*!< TIM5 global Interrupt */ SPI3_IRQn = 51, /*!< SPI3 global Interrupt */ UART4_IRQn = 52, /*!< UART4 global Interrupt */ UART5_IRQn = 53, /*!< UART5 global Interrupt */ TIM6_DAC_IRQn = 54, /*!< TIM6 global and DAC1&2 underrun error interrupts */ TIM7_IRQn = 55, /*!< TIM7 global interrupt */ DMA2_Stream0_IRQn = 56, /*!< DMA2 Stream 0 global Interrupt */ DMA2_Stream1_IRQn = 57, /*!< DMA2 Stream 1 global Interrupt */ DMA2_Stream2_IRQn = 58, /*!< DMA2 Stream 2 global Interrupt */ DMA2_Stream3_IRQn = 59, /*!< DMA2 Stream 3 global Interrupt */ DMA2_Stream4_IRQn = 60, /*!< DMA2 Stream 4 global Interrupt */ DFSDM1_FLT0_IRQn = 61, /*!< DFSDM1 Filter 0 global Interrupt */ DFSDM1_FLT1_IRQn = 62, /*!< DFSDM1 Filter 1 global Interrupt */ CAN2_TX_IRQn = 63, /*!< CAN2 TX Interrupt */ CAN2_RX0_IRQn = 64, /*!< CAN2 RX0 Interrupt */ CAN2_RX1_IRQn = 65, /*!< CAN2 RX1 Interrupt */ CAN2_SCE_IRQn = 66, /*!< CAN2 SCE Interrupt */ OTG_FS_IRQn = 67, /*!< USB OTG FS global Interrupt */ DMA2_Stream5_IRQn = 68, /*!< DMA2 Stream 5 global interrupt */ DMA2_Stream6_IRQn = 69, /*!< DMA2 Stream 6 global interrupt */ DMA2_Stream7_IRQn = 70, /*!< DMA2 Stream 7 global interrupt */ USART6_IRQn = 71, /*!< USART6 global interrupt */ I2C3_EV_IRQn = 72, /*!< I2C3 event interrupt */ I2C3_ER_IRQn = 73, /*!< I2C3 error interrupt */ CAN3_TX_IRQn = 74, /*!< CAN3 TX Interrupt */ CAN3_RX0_IRQn = 75, /*!< CAN3 RX0 Interrupt */ CAN3_RX1_IRQn = 76, /*!< CAN3 RX1 Interrupt */ CAN3_SCE_IRQn = 77, /*!< CAN3 SCE Interrupt */ RNG_IRQn = 80, /*!< RNG global Interrupt */ FPU_IRQn = 81, /*!< FPU global interrupt */ UART7_IRQn = 82, /*!< UART7 global interrupt */ UART8_IRQn = 83, /*!< UART8 global interrupt */ SPI4_IRQn = 84, /*!< SPI4 global Interrupt */ SPI5_IRQn = 85, /*!< SPI5 global Interrupt */ SAI1_IRQn = 87, /*!< SAI1 global Interrupt */ UART9_IRQn = 88, /*!< UART9 global Interrupt */ UART10_IRQn = 89, /*!< UART10 global Interrupt */ QUADSPI_IRQn = 92, /*!< QuadSPI global Interrupt */ FMPI2C1_EV_IRQn = 95, /*!< FMPI2C1 Event Interrupt */ FMPI2C1_ER_IRQn = 96, /*!< FMPI2C1 Error Interrupt */ LPTIM1_IRQn = 97, /*!< LP TIM1 interrupt */ DFSDM2_FLT0_IRQn = 98, /*!< DFSDM2 Filter 0 global Interrupt */ DFSDM2_FLT1_IRQn = 99, /*!< DFSDM2 Filter 1 global Interrupt */ DFSDM2_FLT2_IRQn = 100, /*!< DFSDM2 Filter 2 global Interrupt */ DFSDM2_FLT3_IRQn = 101 /*!< DFSDM2 Filter 3 global Interrupt */ } IRQn_Type; /** * @} */ #include "core_cm4.h" /* Cortex-M4 processor and core peripherals */ #include "system_stm32f4xx.h" #include /** @addtogroup Peripheral_registers_structures * @{ */ /** * @brief Analog to Digital Converter */ typedef struct { __IO uint32_t SR; /*!< ADC status register, Address offset: 0x00 */ __IO uint32_t CR1; /*!< ADC control register 1, Address offset: 0x04 */ __IO uint32_t CR2; /*!< ADC control register 2, Address offset: 0x08 */ __IO uint32_t SMPR1; /*!< ADC sample time register 1, Address offset: 0x0C */ __IO uint32_t SMPR2; /*!< ADC sample time register 2, Address offset: 0x10 */ __IO uint32_t JOFR1; /*!< ADC injected channel data offset register 1, Address offset: 0x14 */ __IO uint32_t JOFR2; /*!< ADC injected channel data offset register 2, Address offset: 0x18 */ __IO uint32_t JOFR3; /*!< ADC injected channel data offset register 3, Address offset: 0x1C */ __IO uint32_t JOFR4; /*!< ADC injected channel data offset register 4, Address offset: 0x20 */ __IO uint32_t HTR; /*!< ADC watchdog higher threshold register, Address offset: 0x24 */ __IO uint32_t LTR; /*!< ADC watchdog lower threshold register, Address offset: 0x28 */ __IO uint32_t SQR1; /*!< ADC regular sequence register 1, Address offset: 0x2C */ __IO uint32_t SQR2; /*!< ADC regular sequence register 2, Address offset: 0x30 */ __IO uint32_t SQR3; /*!< ADC regular sequence register 3, Address offset: 0x34 */ __IO uint32_t JSQR; /*!< ADC injected sequence register, Address offset: 0x38*/ __IO uint32_t JDR1; /*!< ADC injected data register 1, Address offset: 0x3C */ __IO uint32_t JDR2; /*!< ADC injected data register 2, Address offset: 0x40 */ __IO uint32_t JDR3; /*!< ADC injected data register 3, Address offset: 0x44 */ __IO uint32_t JDR4; /*!< ADC injected data register 4, Address offset: 0x48 */ __IO uint32_t DR; /*!< ADC regular data register, Address offset: 0x4C */ } ADC_TypeDef; typedef struct { __IO uint32_t CSR; /*!< ADC Common status register, Address offset: ADC1 base address + 0x300 */ __IO uint32_t CCR; /*!< ADC common control register, Address offset: ADC1 base address + 0x304 */ __IO uint32_t CDR; /*!< ADC common regular data register for dual AND triple modes, Address offset: ADC1 base address + 0x308 */ } ADC_Common_TypeDef; /** * @brief Controller Area Network TxMailBox */ typedef struct { __IO uint32_t TIR; /*!< CAN TX mailbox identifier register */ __IO uint32_t TDTR; /*!< CAN mailbox data length control and time stamp register */ __IO uint32_t TDLR; /*!< CAN mailbox data low register */ __IO uint32_t TDHR; /*!< CAN mailbox data high register */ } CAN_TxMailBox_TypeDef; /** * @brief Controller Area Network FIFOMailBox */ typedef struct { __IO uint32_t RIR; /*!< CAN receive FIFO mailbox identifier register */ __IO uint32_t RDTR; /*!< CAN receive FIFO mailbox data length control and time stamp register */ __IO uint32_t RDLR; /*!< CAN receive FIFO mailbox data low register */ __IO uint32_t RDHR; /*!< CAN receive FIFO mailbox data high register */ } CAN_FIFOMailBox_TypeDef; /** * @brief Controller Area Network FilterRegister */ typedef struct { __IO uint32_t FR1; /*!< CAN Filter bank register 1 */ __IO uint32_t FR2; /*!< CAN Filter bank register 1 */ } CAN_FilterRegister_TypeDef; /** * @brief Controller Area Network */ typedef struct { __IO uint32_t MCR; /*!< CAN master control register, Address offset: 0x00 */ __IO uint32_t MSR; /*!< CAN master status register, Address offset: 0x04 */ __IO uint32_t TSR; /*!< CAN transmit status register, Address offset: 0x08 */ __IO uint32_t RF0R; /*!< CAN receive FIFO 0 register, Address offset: 0x0C */ __IO uint32_t RF1R; /*!< CAN receive FIFO 1 register, Address offset: 0x10 */ __IO uint32_t IER; /*!< CAN interrupt enable register, Address offset: 0x14 */ __IO uint32_t ESR; /*!< CAN error status register, Address offset: 0x18 */ __IO uint32_t BTR; /*!< CAN bit timing register, Address offset: 0x1C */ uint32_t RESERVED0[88]; /*!< Reserved, 0x020 - 0x17F */ CAN_TxMailBox_TypeDef sTxMailBox[3]; /*!< CAN Tx MailBox, Address offset: 0x180 - 0x1AC */ CAN_FIFOMailBox_TypeDef sFIFOMailBox[2]; /*!< CAN FIFO MailBox, Address offset: 0x1B0 - 0x1CC */ uint32_t RESERVED1[12]; /*!< Reserved, 0x1D0 - 0x1FF */ __IO uint32_t FMR; /*!< CAN filter master register, Address offset: 0x200 */ __IO uint32_t FM1R; /*!< CAN filter mode register, Address offset: 0x204 */ uint32_t RESERVED2; /*!< Reserved, 0x208 */ __IO uint32_t FS1R; /*!< CAN filter scale register, Address offset: 0x20C */ uint32_t RESERVED3; /*!< Reserved, 0x210 */ __IO uint32_t FFA1R; /*!< CAN filter FIFO assignment register, Address offset: 0x214 */ uint32_t RESERVED4; /*!< Reserved, 0x218 */ __IO uint32_t FA1R; /*!< CAN filter activation register, Address offset: 0x21C */ uint32_t RESERVED5[8]; /*!< Reserved, 0x220-0x23F */ CAN_FilterRegister_TypeDef sFilterRegister[28]; /*!< CAN Filter Register, Address offset: 0x240-0x31C */ } CAN_TypeDef; /** * @brief CRC calculation unit */ typedef struct { __IO uint32_t DR; /*!< CRC Data register, Address offset: 0x00 */ __IO uint8_t IDR; /*!< CRC Independent data register, Address offset: 0x04 */ uint8_t RESERVED0; /*!< Reserved, 0x05 */ uint16_t RESERVED1; /*!< Reserved, 0x06 */ __IO uint32_t CR; /*!< CRC Control register, Address offset: 0x08 */ } CRC_TypeDef; /** * @brief DFSDM module registers */ typedef struct { __IO uint32_t FLTCR1; /*!< DFSDM control register1, Address offset: 0x100 */ __IO uint32_t FLTCR2; /*!< DFSDM control register2, Address offset: 0x104 */ __IO uint32_t FLTISR; /*!< DFSDM interrupt and status register, Address offset: 0x108 */ __IO uint32_t FLTICR; /*!< DFSDM interrupt flag clear register, Address offset: 0x10C */ __IO uint32_t FLTJCHGR; /*!< DFSDM injected channel group selection register, Address offset: 0x110 */ __IO uint32_t FLTFCR; /*!< DFSDM filter control register, Address offset: 0x114 */ __IO uint32_t FLTJDATAR; /*!< DFSDM data register for injected group, Address offset: 0x118 */ __IO uint32_t FLTRDATAR; /*!< DFSDM data register for regular group, Address offset: 0x11C */ __IO uint32_t FLTAWHTR; /*!< DFSDM analog watchdog high threshold register, Address offset: 0x120 */ __IO uint32_t FLTAWLTR; /*!< DFSDM analog watchdog low threshold register, Address offset: 0x124 */ __IO uint32_t FLTAWSR; /*!< DFSDM analog watchdog status register Address offset: 0x128 */ __IO uint32_t FLTAWCFR; /*!< DFSDM analog watchdog clear flag register Address offset: 0x12C */ __IO uint32_t FLTEXMAX; /*!< DFSDM extreme detector maximum register, Address offset: 0x130 */ __IO uint32_t FLTEXMIN; /*!< DFSDM extreme detector minimum register Address offset: 0x134 */ __IO uint32_t FLTCNVTIMR; /*!< DFSDM conversion timer, Address offset: 0x138 */ } DFSDM_Filter_TypeDef; /** * @brief DFSDM channel configuration registers */ typedef struct { __IO uint32_t CHCFGR1; /*!< DFSDM channel configuration register1, Address offset: 0x00 */ __IO uint32_t CHCFGR2; /*!< DFSDM channel configuration register2, Address offset: 0x04 */ __IO uint32_t CHAWSCDR; /*!< DFSDM channel analog watchdog and short circuit detector register, Address offset: 0x08 */ __IO uint32_t CHWDATAR; /*!< DFSDM channel watchdog filter data register, Address offset: 0x0C */ __IO uint32_t CHDATINR; /*!< DFSDM channel data input register, Address offset: 0x10 */ } DFSDM_Channel_TypeDef; /** * @brief Digital to Analog Converter */ typedef struct { __IO uint32_t CR; /*!< DAC control register, Address offset: 0x00 */ __IO uint32_t SWTRIGR; /*!< DAC software trigger register, Address offset: 0x04 */ __IO uint32_t DHR12R1; /*!< DAC channel1 12-bit right-aligned data holding register, Address offset: 0x08 */ __IO uint32_t DHR12L1; /*!< DAC channel1 12-bit left aligned data holding register, Address offset: 0x0C */ __IO uint32_t DHR8R1; /*!< DAC channel1 8-bit right aligned data holding register, Address offset: 0x10 */ __IO uint32_t DHR12R2; /*!< DAC channel2 12-bit right aligned data holding register, Address offset: 0x14 */ __IO uint32_t DHR12L2; /*!< DAC channel2 12-bit left aligned data holding register, Address offset: 0x18 */ __IO uint32_t DHR8R2; /*!< DAC channel2 8-bit right-aligned data holding register, Address offset: 0x1C */ __IO uint32_t DHR12RD; /*!< Dual DAC 12-bit right-aligned data holding register, Address offset: 0x20 */ __IO uint32_t DHR12LD; /*!< DUAL DAC 12-bit left aligned data holding register, Address offset: 0x24 */ __IO uint32_t DHR8RD; /*!< DUAL DAC 8-bit right aligned data holding register, Address offset: 0x28 */ __IO uint32_t DOR1; /*!< DAC channel1 data output register, Address offset: 0x2C */ __IO uint32_t DOR2; /*!< DAC channel2 data output register, Address offset: 0x30 */ __IO uint32_t SR; /*!< DAC status register, Address offset: 0x34 */ } DAC_TypeDef; /** * @brief Debug MCU */ typedef struct { __IO uint32_t IDCODE; /*!< MCU device ID code, Address offset: 0x00 */ __IO uint32_t CR; /*!< Debug MCU configuration register, Address offset: 0x04 */ __IO uint32_t APB1FZ; /*!< Debug MCU APB1 freeze register, Address offset: 0x08 */ __IO uint32_t APB2FZ; /*!< Debug MCU APB2 freeze register, Address offset: 0x0C */ }DBGMCU_TypeDef; /** * @brief DMA Controller */ typedef struct { __IO uint32_t CR; /*!< DMA stream x configuration register */ __IO uint32_t NDTR; /*!< DMA stream x number of data register */ __IO uint32_t PAR; /*!< DMA stream x peripheral address register */ __IO uint32_t M0AR; /*!< DMA stream x memory 0 address register */ __IO uint32_t M1AR; /*!< DMA stream x memory 1 address register */ __IO uint32_t FCR; /*!< DMA stream x FIFO control register */ } DMA_Stream_TypeDef; typedef struct { __IO uint32_t LISR; /*!< DMA low interrupt status register, Address offset: 0x00 */ __IO uint32_t HISR; /*!< DMA high interrupt status register, Address offset: 0x04 */ __IO uint32_t LIFCR; /*!< DMA low interrupt flag clear register, Address offset: 0x08 */ __IO uint32_t HIFCR; /*!< DMA high interrupt flag clear register, Address offset: 0x0C */ } DMA_TypeDef; /** * @brief External Interrupt/Event Controller */ typedef struct { __IO uint32_t IMR; /*!< EXTI Interrupt mask register, Address offset: 0x00 */ __IO uint32_t EMR; /*!< EXTI Event mask register, Address offset: 0x04 */ __IO uint32_t RTSR; /*!< EXTI Rising trigger selection register, Address offset: 0x08 */ __IO uint32_t FTSR; /*!< EXTI Falling trigger selection register, Address offset: 0x0C */ __IO uint32_t SWIER; /*!< EXTI Software interrupt event register, Address offset: 0x10 */ __IO uint32_t PR; /*!< EXTI Pending register, Address offset: 0x14 */ } EXTI_TypeDef; /** * @brief FLASH Registers */ typedef struct { __IO uint32_t ACR; /*!< FLASH access control register, Address offset: 0x00 */ __IO uint32_t KEYR; /*!< FLASH key register, Address offset: 0x04 */ __IO uint32_t OPTKEYR; /*!< FLASH option key register, Address offset: 0x08 */ __IO uint32_t SR; /*!< FLASH status register, Address offset: 0x0C */ __IO uint32_t CR; /*!< FLASH control register, Address offset: 0x10 */ __IO uint32_t OPTCR; /*!< FLASH option control register , Address offset: 0x14 */ __IO uint32_t OPTCR1; /*!< FLASH option control register 1, Address offset: 0x18 */ } FLASH_TypeDef; /** * @brief Flexible Static Memory Controller */ typedef struct { __IO uint32_t BTCR[8]; /*!< NOR/PSRAM chip-select control register(BCR) and chip-select timing register(BTR), Address offset: 0x00-1C */ } FSMC_Bank1_TypeDef; /** * @brief Flexible Static Memory Controller Bank1E */ typedef struct { __IO uint32_t BWTR[7]; /*!< NOR/PSRAM write timing registers, Address offset: 0x104-0x11C */ } FSMC_Bank1E_TypeDef; /** * @brief General Purpose I/O */ typedef struct { __IO uint32_t MODER; /*!< GPIO port mode register, Address offset: 0x00 */ __IO uint32_t OTYPER; /*!< GPIO port output type register, Address offset: 0x04 */ __IO uint32_t OSPEEDR; /*!< GPIO port output speed register, Address offset: 0x08 */ __IO uint32_t PUPDR; /*!< GPIO port pull-up/pull-down register, Address offset: 0x0C */ __IO uint32_t IDR; /*!< GPIO port input data register, Address offset: 0x10 */ __IO uint32_t ODR; /*!< GPIO port output data register, Address offset: 0x14 */ __IO uint32_t BSRR; /*!< GPIO port bit set/reset register, Address offset: 0x18 */ __IO uint32_t LCKR; /*!< GPIO port configuration lock register, Address offset: 0x1C */ __IO uint32_t AFR[2]; /*!< GPIO alternate function registers, Address offset: 0x20-0x24 */ } GPIO_TypeDef; /** * @brief System configuration controller */ typedef struct { __IO uint32_t MEMRMP; /*!< SYSCFG memory remap register, Address offset: 0x00 */ __IO uint32_t PMC; /*!< SYSCFG peripheral mode configuration register, Address offset: 0x04 */ __IO uint32_t EXTICR[4]; /*!< SYSCFG external interrupt configuration registers, Address offset: 0x08-0x14 */ uint32_t RESERVED; /*!< Reserved, 0x18 */ __IO uint32_t CFGR2; /*!< SYSCFG Configuration register2, Address offset: 0x1C */ __IO uint32_t CMPCR; /*!< SYSCFG Compensation cell control register, Address offset: 0x20 */ uint32_t RESERVED1[2]; /*!< Reserved, 0x24-0x28 */ __IO uint32_t CFGR; /*!< SYSCFG Configuration register, Address offset: 0x2C */ __IO uint32_t MCHDLYCR; /*!< SYSCFG multi-channel delay register, Address offset: 0x30 */ } SYSCFG_TypeDef; /** * @brief Inter-integrated Circuit Interface */ typedef struct { __IO uint32_t CR1; /*!< I2C Control register 1, Address offset: 0x00 */ __IO uint32_t CR2; /*!< I2C Control register 2, Address offset: 0x04 */ __IO uint32_t OAR1; /*!< I2C Own address register 1, Address offset: 0x08 */ __IO uint32_t OAR2; /*!< I2C Own address register 2, Address offset: 0x0C */ __IO uint32_t DR; /*!< I2C Data register, Address offset: 0x10 */ __IO uint32_t SR1; /*!< I2C Status register 1, Address offset: 0x14 */ __IO uint32_t SR2; /*!< I2C Status register 2, Address offset: 0x18 */ __IO uint32_t CCR; /*!< I2C Clock control register, Address offset: 0x1C */ __IO uint32_t TRISE; /*!< I2C TRISE register, Address offset: 0x20 */ __IO uint32_t FLTR; /*!< I2C FLTR register, Address offset: 0x24 */ } I2C_TypeDef; /** * @brief Inter-integrated Circuit Interface */ typedef struct { __IO uint32_t CR1; /*!< FMPI2C Control register 1, Address offset: 0x00 */ __IO uint32_t CR2; /*!< FMPI2C Control register 2, Address offset: 0x04 */ __IO uint32_t OAR1; /*!< FMPI2C Own address 1 register, Address offset: 0x08 */ __IO uint32_t OAR2; /*!< FMPI2C Own address 2 register, Address offset: 0x0C */ __IO uint32_t TIMINGR; /*!< FMPI2C Timing register, Address offset: 0x10 */ __IO uint32_t TIMEOUTR; /*!< FMPI2C Timeout register, Address offset: 0x14 */ __IO uint32_t ISR; /*!< FMPI2C Interrupt and status register, Address offset: 0x18 */ __IO uint32_t ICR; /*!< FMPI2C Interrupt clear register, Address offset: 0x1C */ __IO uint32_t PECR; /*!< FMPI2C PEC register, Address offset: 0x20 */ __IO uint32_t RXDR; /*!< FMPI2C Receive data register, Address offset: 0x24 */ __IO uint32_t TXDR; /*!< FMPI2C Transmit data register, Address offset: 0x28 */ } FMPI2C_TypeDef; /** * @brief Independent WATCHDOG */ typedef struct { __IO uint32_t KR; /*!< IWDG Key register, Address offset: 0x00 */ __IO uint32_t PR; /*!< IWDG Prescaler register, Address offset: 0x04 */ __IO uint32_t RLR; /*!< IWDG Reload register, Address offset: 0x08 */ __IO uint32_t SR; /*!< IWDG Status register, Address offset: 0x0C */ } IWDG_TypeDef; /** * @brief Power Control */ typedef struct { __IO uint32_t CR; /*!< PWR power control register, Address offset: 0x00 */ __IO uint32_t CSR; /*!< PWR power control/status register, Address offset: 0x04 */ } PWR_TypeDef; /** * @brief Reset and Clock Control */ typedef struct { __IO uint32_t CR; /*!< RCC clock control register, Address offset: 0x00 */ __IO uint32_t PLLCFGR; /*!< RCC PLL configuration register, Address offset: 0x04 */ __IO uint32_t CFGR; /*!< RCC clock configuration register, Address offset: 0x08 */ __IO uint32_t CIR; /*!< RCC clock interrupt register, Address offset: 0x0C */ __IO uint32_t AHB1RSTR; /*!< RCC AHB1 peripheral reset register, Address offset: 0x10 */ __IO uint32_t AHB2RSTR; /*!< RCC AHB2 peripheral reset register, Address offset: 0x14 */ __IO uint32_t AHB3RSTR; /*!< RCC AHB3 peripheral reset register, Address offset: 0x18 */ uint32_t RESERVED0; /*!< Reserved, 0x1C */ __IO uint32_t APB1RSTR; /*!< RCC APB1 peripheral reset register, Address offset: 0x20 */ __IO uint32_t APB2RSTR; /*!< RCC APB2 peripheral reset register, Address offset: 0x24 */ uint32_t RESERVED1[2]; /*!< Reserved, 0x28-0x2C */ __IO uint32_t AHB1ENR; /*!< RCC AHB1 peripheral clock register, Address offset: 0x30 */ __IO uint32_t AHB2ENR; /*!< RCC AHB2 peripheral clock register, Address offset: 0x34 */ __IO uint32_t AHB3ENR; /*!< RCC AHB3 peripheral clock register, Address offset: 0x38 */ uint32_t RESERVED2; /*!< Reserved, 0x3C */ __IO uint32_t APB1ENR; /*!< RCC APB1 peripheral clock enable register, Address offset: 0x40 */ __IO uint32_t APB2ENR; /*!< RCC APB2 peripheral clock enable register, Address offset: 0x44 */ uint32_t RESERVED3[2]; /*!< Reserved, 0x48-0x4C */ __IO uint32_t AHB1LPENR; /*!< RCC AHB1 peripheral clock enable in low power mode register, Address offset: 0x50 */ __IO uint32_t AHB2LPENR; /*!< RCC AHB2 peripheral clock enable in low power mode register, Address offset: 0x54 */ __IO uint32_t AHB3LPENR; /*!< RCC AHB3 peripheral clock enable in low power mode register, Address offset: 0x58 */ uint32_t RESERVED4; /*!< Reserved, 0x5C */ __IO uint32_t APB1LPENR; /*!< RCC APB1 peripheral clock enable in low power mode register, Address offset: 0x60 */ __IO uint32_t APB2LPENR; /*!< RCC APB2 peripheral clock enable in low power mode register, Address offset: 0x64 */ uint32_t RESERVED5[2]; /*!< Reserved, 0x68-0x6C */ __IO uint32_t BDCR; /*!< RCC Backup domain control register, Address offset: 0x70 */ __IO uint32_t CSR; /*!< RCC clock control & status register, Address offset: 0x74 */ uint32_t RESERVED6[2]; /*!< Reserved, 0x78-0x7C */ __IO uint32_t SSCGR; /*!< RCC spread spectrum clock generation register, Address offset: 0x80 */ __IO uint32_t PLLI2SCFGR; /*!< RCC PLLI2S configuration register, Address offset: 0x84 */ uint32_t RESERVED7; /*!< Reserved, 0x84 */ __IO uint32_t DCKCFGR; /*!< RCC Dedicated Clocks configuration register, Address offset: 0x8C */ __IO uint32_t CKGATENR; /*!< RCC Clocks Gated ENable Register, Address offset: 0x90 */ __IO uint32_t DCKCFGR2; /*!< RCC Dedicated Clocks configuration register 2, Address offset: 0x94 */ } RCC_TypeDef; /** * @brief Real-Time Clock */ typedef struct { __IO uint32_t TR; /*!< RTC time register, Address offset: 0x00 */ __IO uint32_t DR; /*!< RTC date register, Address offset: 0x04 */ __IO uint32_t CR; /*!< RTC control register, Address offset: 0x08 */ __IO uint32_t ISR; /*!< RTC initialization and status register, Address offset: 0x0C */ __IO uint32_t PRER; /*!< RTC prescaler register, Address offset: 0x10 */ __IO uint32_t WUTR; /*!< RTC wakeup timer register, Address offset: 0x14 */ __IO uint32_t CALIBR; /*!< RTC calibration register, Address offset: 0x18 */ __IO uint32_t ALRMAR; /*!< RTC alarm A register, Address offset: 0x1C */ __IO uint32_t ALRMBR; /*!< RTC alarm B register, Address offset: 0x20 */ __IO uint32_t WPR; /*!< RTC write protection register, Address offset: 0x24 */ __IO uint32_t SSR; /*!< RTC sub second register, Address offset: 0x28 */ __IO uint32_t SHIFTR; /*!< RTC shift control register, Address offset: 0x2C */ __IO uint32_t TSTR; /*!< RTC time stamp time register, Address offset: 0x30 */ __IO uint32_t TSDR; /*!< RTC time stamp date register, Address offset: 0x34 */ __IO uint32_t TSSSR; /*!< RTC time-stamp sub second register, Address offset: 0x38 */ __IO uint32_t CALR; /*!< RTC calibration register, Address offset: 0x3C */ __IO uint32_t TAFCR; /*!< RTC tamper and alternate function configuration register, Address offset: 0x40 */ __IO uint32_t ALRMASSR;/*!< RTC alarm A sub second register, Address offset: 0x44 */ __IO uint32_t ALRMBSSR;/*!< RTC alarm B sub second register, Address offset: 0x48 */ uint32_t RESERVED7; /*!< Reserved, 0x4C */ __IO uint32_t BKP0R; /*!< RTC backup register 1, Address offset: 0x50 */ __IO uint32_t BKP1R; /*!< RTC backup register 1, Address offset: 0x54 */ __IO uint32_t BKP2R; /*!< RTC backup register 2, Address offset: 0x58 */ __IO uint32_t BKP3R; /*!< RTC backup register 3, Address offset: 0x5C */ __IO uint32_t BKP4R; /*!< RTC backup register 4, Address offset: 0x60 */ __IO uint32_t BKP5R; /*!< RTC backup register 5, Address offset: 0x64 */ __IO uint32_t BKP6R; /*!< RTC backup register 6, Address offset: 0x68 */ __IO uint32_t BKP7R; /*!< RTC backup register 7, Address offset: 0x6C */ __IO uint32_t BKP8R; /*!< RTC backup register 8, Address offset: 0x70 */ __IO uint32_t BKP9R; /*!< RTC backup register 9, Address offset: 0x74 */ __IO uint32_t BKP10R; /*!< RTC backup register 10, Address offset: 0x78 */ __IO uint32_t BKP11R; /*!< RTC backup register 11, Address offset: 0x7C */ __IO uint32_t BKP12R; /*!< RTC backup register 12, Address offset: 0x80 */ __IO uint32_t BKP13R; /*!< RTC backup register 13, Address offset: 0x84 */ __IO uint32_t BKP14R; /*!< RTC backup register 14, Address offset: 0x88 */ __IO uint32_t BKP15R; /*!< RTC backup register 15, Address offset: 0x8C */ __IO uint32_t BKP16R; /*!< RTC backup register 16, Address offset: 0x90 */ __IO uint32_t BKP17R; /*!< RTC backup register 17, Address offset: 0x94 */ __IO uint32_t BKP18R; /*!< RTC backup register 18, Address offset: 0x98 */ __IO uint32_t BKP19R; /*!< RTC backup register 19, Address offset: 0x9C */ } RTC_TypeDef; /** * @brief Serial Audio Interface */ typedef struct { __IO uint32_t GCR; /*!< SAI global configuration register, Address offset: 0x00 */ } SAI_TypeDef; typedef struct { __IO uint32_t CR1; /*!< SAI block x configuration register 1, Address offset: 0x04 */ __IO uint32_t CR2; /*!< SAI block x configuration register 2, Address offset: 0x08 */ __IO uint32_t FRCR; /*!< SAI block x frame configuration register, Address offset: 0x0C */ __IO uint32_t SLOTR; /*!< SAI block x slot register, Address offset: 0x10 */ __IO uint32_t IMR; /*!< SAI block x interrupt mask register, Address offset: 0x14 */ __IO uint32_t SR; /*!< SAI block x status register, Address offset: 0x18 */ __IO uint32_t CLRFR; /*!< SAI block x clear flag register, Address offset: 0x1C */ __IO uint32_t DR; /*!< SAI block x data register, Address offset: 0x20 */ } SAI_Block_TypeDef; /** * @brief SD host Interface */ typedef struct { __IO uint32_t POWER; /*!< SDIO power control register, Address offset: 0x00 */ __IO uint32_t CLKCR; /*!< SDI clock control register, Address offset: 0x04 */ __IO uint32_t ARG; /*!< SDIO argument register, Address offset: 0x08 */ __IO uint32_t CMD; /*!< SDIO command register, Address offset: 0x0C */ __IO const uint32_t RESPCMD; /*!< SDIO command response register, Address offset: 0x10 */ __IO const uint32_t RESP1; /*!< SDIO response 1 register, Address offset: 0x14 */ __IO const uint32_t RESP2; /*!< SDIO response 2 register, Address offset: 0x18 */ __IO const uint32_t RESP3; /*!< SDIO response 3 register, Address offset: 0x1C */ __IO const uint32_t RESP4; /*!< SDIO response 4 register, Address offset: 0x20 */ __IO uint32_t DTIMER; /*!< SDIO data timer register, Address offset: 0x24 */ __IO uint32_t DLEN; /*!< SDIO data length register, Address offset: 0x28 */ __IO uint32_t DCTRL; /*!< SDIO data control register, Address offset: 0x2C */ __IO const uint32_t DCOUNT; /*!< SDIO data counter register, Address offset: 0x30 */ __IO const uint32_t STA; /*!< SDIO status register, Address offset: 0x34 */ __IO uint32_t ICR; /*!< SDIO interrupt clear register, Address offset: 0x38 */ __IO uint32_t MASK; /*!< SDIO mask register, Address offset: 0x3C */ uint32_t RESERVED0[2]; /*!< Reserved, 0x40-0x44 */ __IO const uint32_t FIFOCNT; /*!< SDIO FIFO counter register, Address offset: 0x48 */ uint32_t RESERVED1[13]; /*!< Reserved, 0x4C-0x7C */ __IO uint32_t FIFO; /*!< SDIO data FIFO register, Address offset: 0x80 */ } SDIO_TypeDef; /** * @brief Serial Peripheral Interface */ typedef struct { __IO uint32_t CR1; /*!< SPI control register 1 (not used in I2S mode), Address offset: 0x00 */ __IO uint32_t CR2; /*!< SPI control register 2, Address offset: 0x04 */ __IO uint32_t SR; /*!< SPI status register, Address offset: 0x08 */ __IO uint32_t DR; /*!< SPI data register, Address offset: 0x0C */ __IO uint32_t CRCPR; /*!< SPI CRC polynomial register (not used in I2S mode), Address offset: 0x10 */ __IO uint32_t RXCRCR; /*!< SPI RX CRC register (not used in I2S mode), Address offset: 0x14 */ __IO uint32_t TXCRCR; /*!< SPI TX CRC register (not used in I2S mode), Address offset: 0x18 */ __IO uint32_t I2SCFGR; /*!< SPI_I2S configuration register, Address offset: 0x1C */ __IO uint32_t I2SPR; /*!< SPI_I2S prescaler register, Address offset: 0x20 */ } SPI_TypeDef; /** * @brief QUAD Serial Peripheral Interface */ typedef struct { __IO uint32_t CR; /*!< QUADSPI Control register, Address offset: 0x00 */ __IO uint32_t DCR; /*!< QUADSPI Device Configuration register, Address offset: 0x04 */ __IO uint32_t SR; /*!< QUADSPI Status register, Address offset: 0x08 */ __IO uint32_t FCR; /*!< QUADSPI Flag Clear register, Address offset: 0x0C */ __IO uint32_t DLR; /*!< QUADSPI Data Length register, Address offset: 0x10 */ __IO uint32_t CCR; /*!< QUADSPI Communication Configuration register, Address offset: 0x14 */ __IO uint32_t AR; /*!< QUADSPI Address register, Address offset: 0x18 */ __IO uint32_t ABR; /*!< QUADSPI Alternate Bytes register, Address offset: 0x1C */ __IO uint32_t DR; /*!< QUADSPI Data register, Address offset: 0x20 */ __IO uint32_t PSMKR; /*!< QUADSPI Polling Status Mask register, Address offset: 0x24 */ __IO uint32_t PSMAR; /*!< QUADSPI Polling Status Match register, Address offset: 0x28 */ __IO uint32_t PIR; /*!< QUADSPI Polling Interval register, Address offset: 0x2C */ __IO uint32_t LPTR; /*!< QUADSPI Low Power Timeout register, Address offset: 0x30 */ } QUADSPI_TypeDef; /** * @brief TIM */ typedef struct { __IO uint32_t CR1; /*!< TIM control register 1, Address offset: 0x00 */ __IO uint32_t CR2; /*!< TIM control register 2, Address offset: 0x04 */ __IO uint32_t SMCR; /*!< TIM slave mode control register, Address offset: 0x08 */ __IO uint32_t DIER; /*!< TIM DMA/interrupt enable register, Address offset: 0x0C */ __IO uint32_t SR; /*!< TIM status register, Address offset: 0x10 */ __IO uint32_t EGR; /*!< TIM event generation register, Address offset: 0x14 */ __IO uint32_t CCMR1; /*!< TIM capture/compare mode register 1, Address offset: 0x18 */ __IO uint32_t CCMR2; /*!< TIM capture/compare mode register 2, Address offset: 0x1C */ __IO uint32_t CCER; /*!< TIM capture/compare enable register, Address offset: 0x20 */ __IO uint32_t CNT; /*!< TIM counter register, Address offset: 0x24 */ __IO uint32_t PSC; /*!< TIM prescaler, Address offset: 0x28 */ __IO uint32_t ARR; /*!< TIM auto-reload register, Address offset: 0x2C */ __IO uint32_t RCR; /*!< TIM repetition counter register, Address offset: 0x30 */ __IO uint32_t CCR1; /*!< TIM capture/compare register 1, Address offset: 0x34 */ __IO uint32_t CCR2; /*!< TIM capture/compare register 2, Address offset: 0x38 */ __IO uint32_t CCR3; /*!< TIM capture/compare register 3, Address offset: 0x3C */ __IO uint32_t CCR4; /*!< TIM capture/compare register 4, Address offset: 0x40 */ __IO uint32_t BDTR; /*!< TIM break and dead-time register, Address offset: 0x44 */ __IO uint32_t DCR; /*!< TIM DMA control register, Address offset: 0x48 */ __IO uint32_t DMAR; /*!< TIM DMA address for full transfer, Address offset: 0x4C */ __IO uint32_t OR; /*!< TIM option register, Address offset: 0x50 */ } TIM_TypeDef; /** * @brief Universal Synchronous Asynchronous Receiver Transmitter */ typedef struct { __IO uint32_t SR; /*!< USART Status register, Address offset: 0x00 */ __IO uint32_t DR; /*!< USART Data register, Address offset: 0x04 */ __IO uint32_t BRR; /*!< USART Baud rate register, Address offset: 0x08 */ __IO uint32_t CR1; /*!< USART Control register 1, Address offset: 0x0C */ __IO uint32_t CR2; /*!< USART Control register 2, Address offset: 0x10 */ __IO uint32_t CR3; /*!< USART Control register 3, Address offset: 0x14 */ __IO uint32_t GTPR; /*!< USART Guard time and prescaler register, Address offset: 0x18 */ } USART_TypeDef; /** * @brief Window WATCHDOG */ typedef struct { __IO uint32_t CR; /*!< WWDG Control register, Address offset: 0x00 */ __IO uint32_t CFR; /*!< WWDG Configuration register, Address offset: 0x04 */ __IO uint32_t SR; /*!< WWDG Status register, Address offset: 0x08 */ } WWDG_TypeDef; /** * @brief RNG */ typedef struct { __IO uint32_t CR; /*!< RNG control register, Address offset: 0x00 */ __IO uint32_t SR; /*!< RNG status register, Address offset: 0x04 */ __IO uint32_t DR; /*!< RNG data register, Address offset: 0x08 */ } RNG_TypeDef; /** * @brief USB_OTG_Core_Registers */ typedef struct { __IO uint32_t GOTGCTL; /*!< USB_OTG Control and Status Register 000h */ __IO uint32_t GOTGINT; /*!< USB_OTG Interrupt Register 004h */ __IO uint32_t GAHBCFG; /*!< Core AHB Configuration Register 008h */ __IO uint32_t GUSBCFG; /*!< Core USB Configuration Register 00Ch */ __IO uint32_t GRSTCTL; /*!< Core Reset Register 010h */ __IO uint32_t GINTSTS; /*!< Core Interrupt Register 014h */ __IO uint32_t GINTMSK; /*!< Core Interrupt Mask Register 018h */ __IO uint32_t GRXSTSR; /*!< Receive Sts Q Read Register 01Ch */ __IO uint32_t GRXSTSP; /*!< Receive Sts Q Read & POP Register 020h */ __IO uint32_t GRXFSIZ; /*!< Receive FIFO Size Register 024h */ __IO uint32_t DIEPTXF0_HNPTXFSIZ; /*!< EP0 / Non Periodic Tx FIFO Size Register 028h */ __IO uint32_t HNPTXSTS; /*!< Non Periodic Tx FIFO/Queue Sts reg 02Ch */ uint32_t Reserved30[2]; /*!< Reserved 030h */ __IO uint32_t GCCFG; /*!< General Purpose IO Register 038h */ __IO uint32_t CID; /*!< User ID Register 03Ch */ uint32_t Reserved5[3]; /*!< Reserved 040h-048h */ __IO uint32_t GHWCFG3; /*!< User HW config3 04Ch */ uint32_t Reserved6; /*!< Reserved 050h */ __IO uint32_t GLPMCFG; /*!< LPM Register 054h */ uint32_t Reserved; /*!< Reserved 058h */ __IO uint32_t GDFIFOCFG; /*!< DFIFO Software Config Register 05Ch */ uint32_t Reserved43[40]; /*!< Reserved 058h-0FFh */ __IO uint32_t HPTXFSIZ; /*!< Host Periodic Tx FIFO Size Reg 100h */ __IO uint32_t DIEPTXF[0x0F]; /*!< dev Periodic Transmit FIFO */ } USB_OTG_GlobalTypeDef; /** * @brief USB_OTG_device_Registers */ typedef struct { __IO uint32_t DCFG; /*!< dev Configuration Register 800h */ __IO uint32_t DCTL; /*!< dev Control Register 804h */ __IO uint32_t DSTS; /*!< dev Status Register (RO) 808h */ uint32_t Reserved0C; /*!< Reserved 80Ch */ __IO uint32_t DIEPMSK; /*!< dev IN Endpoint Mask 810h */ __IO uint32_t DOEPMSK; /*!< dev OUT Endpoint Mask 814h */ __IO uint32_t DAINT; /*!< dev All Endpoints Itr Reg 818h */ __IO uint32_t DAINTMSK; /*!< dev All Endpoints Itr Mask 81Ch */ uint32_t Reserved20; /*!< Reserved 820h */ uint32_t Reserved9; /*!< Reserved 824h */ __IO uint32_t DVBUSDIS; /*!< dev VBUS discharge Register 828h */ __IO uint32_t DVBUSPULSE; /*!< dev VBUS Pulse Register 82Ch */ __IO uint32_t DTHRCTL; /*!< dev threshold 830h */ __IO uint32_t DIEPEMPMSK; /*!< dev empty msk 834h */ __IO uint32_t DEACHINT; /*!< dedicated EP interrupt 838h */ __IO uint32_t DEACHMSK; /*!< dedicated EP msk 83Ch */ uint32_t Reserved40; /*!< dedicated EP mask 840h */ __IO uint32_t DINEP1MSK; /*!< dedicated EP mask 844h */ uint32_t Reserved44[15]; /*!< Reserved 844-87Ch */ __IO uint32_t DOUTEP1MSK; /*!< dedicated EP msk 884h */ } USB_OTG_DeviceTypeDef; /** * @brief USB_OTG_IN_Endpoint-Specific_Register */ typedef struct { __IO uint32_t DIEPCTL; /*!< dev IN Endpoint Control Reg 900h + (ep_num * 20h) + 00h */ uint32_t Reserved04; /*!< Reserved 900h + (ep_num * 20h) + 04h */ __IO uint32_t DIEPINT; /*!< dev IN Endpoint Itr Reg 900h + (ep_num * 20h) + 08h */ uint32_t Reserved0C; /*!< Reserved 900h + (ep_num * 20h) + 0Ch */ __IO uint32_t DIEPTSIZ; /*!< IN Endpoint Txfer Size 900h + (ep_num * 20h) + 10h */ __IO uint32_t DIEPDMA; /*!< IN Endpoint DMA Address Reg 900h + (ep_num * 20h) + 14h */ __IO uint32_t DTXFSTS; /*!< IN Endpoint Tx FIFO Status Reg 900h + (ep_num * 20h) + 18h */ uint32_t Reserved18; /*!< Reserved 900h+(ep_num*20h)+1Ch-900h+ (ep_num * 20h) + 1Ch */ } USB_OTG_INEndpointTypeDef; /** * @brief USB_OTG_OUT_Endpoint-Specific_Registers */ typedef struct { __IO uint32_t DOEPCTL; /*!< dev OUT Endpoint Control Reg B00h + (ep_num * 20h) + 00h */ uint32_t Reserved04; /*!< Reserved B00h + (ep_num * 20h) + 04h */ __IO uint32_t DOEPINT; /*!< dev OUT Endpoint Itr Reg B00h + (ep_num * 20h) + 08h */ uint32_t Reserved0C; /*!< Reserved B00h + (ep_num * 20h) + 0Ch */ __IO uint32_t DOEPTSIZ; /*!< dev OUT Endpoint Txfer Size B00h + (ep_num * 20h) + 10h */ __IO uint32_t DOEPDMA; /*!< dev OUT Endpoint DMA Address B00h + (ep_num * 20h) + 14h */ uint32_t Reserved18[2]; /*!< Reserved B00h + (ep_num * 20h) + 18h - B00h + (ep_num * 20h) + 1Ch */ } USB_OTG_OUTEndpointTypeDef; /** * @brief USB_OTG_Host_Mode_Register_Structures */ typedef struct { __IO uint32_t HCFG; /*!< Host Configuration Register 400h */ __IO uint32_t HFIR; /*!< Host Frame Interval Register 404h */ __IO uint32_t HFNUM; /*!< Host Frame Nbr/Frame Remaining 408h */ uint32_t Reserved40C; /*!< Reserved 40Ch */ __IO uint32_t HPTXSTS; /*!< Host Periodic Tx FIFO/ Queue Status 410h */ __IO uint32_t HAINT; /*!< Host All Channels Interrupt Register 414h */ __IO uint32_t HAINTMSK; /*!< Host All Channels Interrupt Mask 418h */ } USB_OTG_HostTypeDef; /** * @brief USB_OTG_Host_Channel_Specific_Registers */ typedef struct { __IO uint32_t HCCHAR; /*!< Host Channel Characteristics Register 500h */ __IO uint32_t HCSPLT; /*!< Host Channel Split Control Register 504h */ __IO uint32_t HCINT; /*!< Host Channel Interrupt Register 508h */ __IO uint32_t HCINTMSK; /*!< Host Channel Interrupt Mask Register 50Ch */ __IO uint32_t HCTSIZ; /*!< Host Channel Transfer Size Register 510h */ __IO uint32_t HCDMA; /*!< Host Channel DMA Address Register 514h */ uint32_t Reserved[2]; /*!< Reserved */ } USB_OTG_HostChannelTypeDef; /** * @brief LPTIMER */ typedef struct { __IO uint32_t ISR; /*!< LPTIM Interrupt and Status register, Address offset: 0x00 */ __IO uint32_t ICR; /*!< LPTIM Interrupt Clear register, Address offset: 0x04 */ __IO uint32_t IER; /*!< LPTIM Interrupt Enable register, Address offset: 0x08 */ __IO uint32_t CFGR; /*!< LPTIM Configuration register, Address offset: 0x0C */ __IO uint32_t CR; /*!< LPTIM Control register, Address offset: 0x10 */ __IO uint32_t CMP; /*!< LPTIM Compare register, Address offset: 0x14 */ __IO uint32_t ARR; /*!< LPTIM Autoreload register, Address offset: 0x18 */ __IO uint32_t CNT; /*!< LPTIM Counter register, Address offset: 0x1C */ __IO uint32_t OR; /*!< LPTIM Option register, Address offset: 0x20 */ } LPTIM_TypeDef; /** * @} */ /** @addtogroup Peripheral_memory_map * @{ */ #define FLASH_BASE 0x08000000UL /*!< FLASH (up to 1.5 MB) base address in the alias region */ #define SRAM1_BASE 0x20000000UL /*!< SRAM1(256 KB) base address in the alias region */ #define SRAM2_BASE 0x20040000UL /*!< SRAM2(64 KB) base address in the alias region */ #define PERIPH_BASE 0x40000000UL /*!< Peripheral base address in the alias region */ #define FSMC_R_BASE 0xA0000000UL /*!< FSMC registers base address */ #define QSPI_R_BASE 0xA0001000UL /*!< QuadSPI registers base address */ #define SRAM1_BB_BASE 0x22000000UL /*!< SRAM1(256 KB) base address in the bit-band region */ #define SRAM2_BB_BASE 0x22800000UL /*!< SRAM2(64 KB) base address in the bit-band region */ #define PERIPH_BB_BASE 0x42000000UL /*!< Peripheral base address in the bit-band region */ #define FLASH_END 0x0817FFFFUL /*!< FLASH end address */ #define FLASH_OTP_BASE 0x1FFF7800UL /*!< Base address of : (up to 528 Bytes) embedded FLASH OTP Area */ #define FLASH_OTP_END 0x1FFF7A0FUL /*!< End address of : (up to 528 Bytes) embedded FLASH OTP Area */ /* Legacy defines */ #define SRAM_BASE SRAM1_BASE #define SRAM_BB_BASE SRAM1_BB_BASE /*!< Peripheral memory map */ #define APB1PERIPH_BASE PERIPH_BASE #define APB2PERIPH_BASE (PERIPH_BASE + 0x00010000UL) #define AHB1PERIPH_BASE (PERIPH_BASE + 0x00020000UL) #define AHB2PERIPH_BASE (PERIPH_BASE + 0x10000000UL) /*!< APB1 peripherals */ #define TIM2_BASE (APB1PERIPH_BASE + 0x0000UL) #define TIM3_BASE (APB1PERIPH_BASE + 0x0400UL) #define TIM4_BASE (APB1PERIPH_BASE + 0x0800UL) #define TIM5_BASE (APB1PERIPH_BASE + 0x0C00UL) #define TIM6_BASE (APB1PERIPH_BASE + 0x1000UL) #define TIM7_BASE (APB1PERIPH_BASE + 0x1400UL) #define TIM12_BASE (APB1PERIPH_BASE + 0x1800UL) #define TIM13_BASE (APB1PERIPH_BASE + 0x1C00UL) #define TIM14_BASE (APB1PERIPH_BASE + 0x2000UL) #define LPTIM1_BASE (APB1PERIPH_BASE + 0x2400UL) #define RTC_BASE (APB1PERIPH_BASE + 0x2800UL) #define WWDG_BASE (APB1PERIPH_BASE + 0x2C00UL) #define IWDG_BASE (APB1PERIPH_BASE + 0x3000UL) #define I2S2ext_BASE (APB1PERIPH_BASE + 0x3400UL) #define SPI2_BASE (APB1PERIPH_BASE + 0x3800UL) #define SPI3_BASE (APB1PERIPH_BASE + 0x3C00UL) #define I2S3ext_BASE (APB1PERIPH_BASE + 0x4000UL) #define USART2_BASE (APB1PERIPH_BASE + 0x4400UL) #define USART3_BASE (APB1PERIPH_BASE + 0x4800UL) #define UART4_BASE (APB1PERIPH_BASE + 0x4C00UL) #define UART5_BASE (APB1PERIPH_BASE + 0x5000UL) #define I2C1_BASE (APB1PERIPH_BASE + 0x5400UL) #define I2C2_BASE (APB1PERIPH_BASE + 0x5800UL) #define I2C3_BASE (APB1PERIPH_BASE + 0x5C00UL) #define FMPI2C1_BASE (APB1PERIPH_BASE + 0x6000UL) #define CAN1_BASE (APB1PERIPH_BASE + 0x6400UL) #define CAN2_BASE (APB1PERIPH_BASE + 0x6800UL) #define CAN3_BASE (APB1PERIPH_BASE + 0x6C00UL) #define PWR_BASE (APB1PERIPH_BASE + 0x7000UL) #define DAC_BASE (APB1PERIPH_BASE + 0x7400UL) #define UART7_BASE (APB1PERIPH_BASE + 0x7800UL) #define UART8_BASE (APB1PERIPH_BASE + 0x7C00UL) /*!< APB2 peripherals */ #define TIM1_BASE (APB2PERIPH_BASE + 0x0000UL) #define TIM8_BASE (APB2PERIPH_BASE + 0x0400UL) #define USART1_BASE (APB2PERIPH_BASE + 0x1000UL) #define USART6_BASE (APB2PERIPH_BASE + 0x1400UL) #define UART9_BASE (APB2PERIPH_BASE + 0x1800UL) #define UART10_BASE (APB2PERIPH_BASE + 0x1C00UL) #define ADC1_BASE (APB2PERIPH_BASE + 0x2000UL) #define ADC1_COMMON_BASE (APB2PERIPH_BASE + 0x2300UL) /* Legacy define */ #define ADC_BASE ADC1_COMMON_BASE #define SDIO_BASE (APB2PERIPH_BASE + 0x2C00UL) #define SPI1_BASE (APB2PERIPH_BASE + 0x3000UL) #define SPI4_BASE (APB2PERIPH_BASE + 0x3400UL) #define SYSCFG_BASE (APB2PERIPH_BASE + 0x3800UL) #define EXTI_BASE (APB2PERIPH_BASE + 0x3C00UL) #define TIM9_BASE (APB2PERIPH_BASE + 0x4000UL) #define TIM10_BASE (APB2PERIPH_BASE + 0x4400UL) #define TIM11_BASE (APB2PERIPH_BASE + 0x4800UL) #define SPI5_BASE (APB2PERIPH_BASE + 0x5000UL) #define DFSDM1_BASE (APB2PERIPH_BASE + 0x6000UL) #define DFSDM2_BASE (APB2PERIPH_BASE + 0x6400UL) #define DFSDM1_Channel0_BASE (DFSDM1_BASE + 0x00UL) #define DFSDM1_Channel1_BASE (DFSDM1_BASE + 0x20UL) #define DFSDM1_Channel2_BASE (DFSDM1_BASE + 0x40UL) #define DFSDM1_Channel3_BASE (DFSDM1_BASE + 0x60UL) #define DFSDM1_Filter0_BASE (DFSDM1_BASE + 0x100UL) #define DFSDM1_Filter1_BASE (DFSDM1_BASE + 0x180UL) #define DFSDM2_Channel0_BASE (DFSDM2_BASE + 0x00UL) #define DFSDM2_Channel1_BASE (DFSDM2_BASE + 0x20UL) #define DFSDM2_Channel2_BASE (DFSDM2_BASE + 0x40UL) #define DFSDM2_Channel3_BASE (DFSDM2_BASE + 0x60UL) #define DFSDM2_Channel4_BASE (DFSDM2_BASE + 0x80UL) #define DFSDM2_Channel5_BASE (DFSDM2_BASE + 0xA0UL) #define DFSDM2_Channel6_BASE (DFSDM2_BASE + 0xC0UL) #define DFSDM2_Channel7_BASE (DFSDM2_BASE + 0xE0UL) #define DFSDM2_Filter0_BASE (DFSDM2_BASE + 0x100UL) #define DFSDM2_Filter1_BASE (DFSDM2_BASE + 0x180UL) #define DFSDM2_Filter2_BASE (DFSDM2_BASE + 0x200UL) #define DFSDM2_Filter3_BASE (DFSDM2_BASE + 0x280UL) #define SAI1_BASE (APB2PERIPH_BASE + 0x5800UL) #define SAI1_Block_A_BASE (SAI1_BASE + 0x004UL) #define SAI1_Block_B_BASE (SAI1_BASE + 0x024UL) /*!< AHB1 peripherals */ #define GPIOA_BASE (AHB1PERIPH_BASE + 0x0000UL) #define GPIOB_BASE (AHB1PERIPH_BASE + 0x0400UL) #define GPIOC_BASE (AHB1PERIPH_BASE + 0x0800UL) #define GPIOD_BASE (AHB1PERIPH_BASE + 0x0C00UL) #define GPIOE_BASE (AHB1PERIPH_BASE + 0x1000UL) #define GPIOF_BASE (AHB1PERIPH_BASE + 0x1400UL) #define GPIOG_BASE (AHB1PERIPH_BASE + 0x1800UL) #define GPIOH_BASE (AHB1PERIPH_BASE + 0x1C00UL) #define CRC_BASE (AHB1PERIPH_BASE + 0x3000UL) #define RCC_BASE (AHB1PERIPH_BASE + 0x3800UL) #define FLASH_R_BASE (AHB1PERIPH_BASE + 0x3C00UL) #define DMA1_BASE (AHB1PERIPH_BASE + 0x6000UL) #define DMA1_Stream0_BASE (DMA1_BASE + 0x010UL) #define DMA1_Stream1_BASE (DMA1_BASE + 0x028UL) #define DMA1_Stream2_BASE (DMA1_BASE + 0x040UL) #define DMA1_Stream3_BASE (DMA1_BASE + 0x058UL) #define DMA1_Stream4_BASE (DMA1_BASE + 0x070UL) #define DMA1_Stream5_BASE (DMA1_BASE + 0x088UL) #define DMA1_Stream6_BASE (DMA1_BASE + 0x0A0UL) #define DMA1_Stream7_BASE (DMA1_BASE + 0x0B8UL) #define DMA2_BASE (AHB1PERIPH_BASE + 0x6400UL) #define DMA2_Stream0_BASE (DMA2_BASE + 0x010UL) #define DMA2_Stream1_BASE (DMA2_BASE + 0x028UL) #define DMA2_Stream2_BASE (DMA2_BASE + 0x040UL) #define DMA2_Stream3_BASE (DMA2_BASE + 0x058UL) #define DMA2_Stream4_BASE (DMA2_BASE + 0x070UL) #define DMA2_Stream5_BASE (DMA2_BASE + 0x088UL) #define DMA2_Stream6_BASE (DMA2_BASE + 0x0A0UL) #define DMA2_Stream7_BASE (DMA2_BASE + 0x0B8UL) /*!< AHB2 peripherals */ #define RNG_BASE (AHB2PERIPH_BASE + 0x60800UL) /*!< FSMC Bankx registers base address */ #define FSMC_Bank1_R_BASE (FSMC_R_BASE + 0x0000UL) #define FSMC_Bank1E_R_BASE (FSMC_R_BASE + 0x0104UL) /*!< Debug MCU registers base address */ #define DBGMCU_BASE 0xE0042000UL /*!< USB registers base address */ #define USB_OTG_FS_PERIPH_BASE 0x50000000UL #define USB_OTG_GLOBAL_BASE 0x000UL #define USB_OTG_DEVICE_BASE 0x800UL #define USB_OTG_IN_ENDPOINT_BASE 0x900UL #define USB_OTG_OUT_ENDPOINT_BASE 0xB00UL #define USB_OTG_EP_REG_SIZE 0x20UL #define USB_OTG_HOST_BASE 0x400UL #define USB_OTG_HOST_PORT_BASE 0x440UL #define USB_OTG_HOST_CHANNEL_BASE 0x500UL #define USB_OTG_HOST_CHANNEL_SIZE 0x20UL #define USB_OTG_PCGCCTL_BASE 0xE00UL #define USB_OTG_FIFO_BASE 0x1000UL #define USB_OTG_FIFO_SIZE 0x1000UL #define UID_BASE 0x1FFF7A10UL /*!< Unique device ID register base address */ #define FLASHSIZE_BASE 0x1FFF7A22UL /*!< FLASH Size register base address */ #define PACKAGE_BASE 0x1FFF7BF0UL /*!< Package size register base address */ /** * @} */ /** @addtogroup Peripheral_declaration * @{ */ #define TIM2 ((TIM_TypeDef *) TIM2_BASE) #define TIM3 ((TIM_TypeDef *) TIM3_BASE) #define TIM4 ((TIM_TypeDef *) TIM4_BASE) #define TIM5 ((TIM_TypeDef *) TIM5_BASE) #define TIM6 ((TIM_TypeDef *) TIM6_BASE) #define TIM7 ((TIM_TypeDef *) TIM7_BASE) #define TIM12 ((TIM_TypeDef *) TIM12_BASE) #define TIM13 ((TIM_TypeDef *) TIM13_BASE) #define TIM14 ((TIM_TypeDef *) TIM14_BASE) #define LPTIM1 ((LPTIM_TypeDef *) LPTIM1_BASE) #define RTC ((RTC_TypeDef *) RTC_BASE) #define WWDG ((WWDG_TypeDef *) WWDG_BASE) #define IWDG ((IWDG_TypeDef *) IWDG_BASE) #define I2S2ext ((SPI_TypeDef *) I2S2ext_BASE) #define SPI2 ((SPI_TypeDef *) SPI2_BASE) #define SPI3 ((SPI_TypeDef *) SPI3_BASE) #define I2S3ext ((SPI_TypeDef *) I2S3ext_BASE) #define USART2 ((USART_TypeDef *) USART2_BASE) #define USART3 ((USART_TypeDef *) USART3_BASE) #define UART4 ((USART_TypeDef *) UART4_BASE) #define UART5 ((USART_TypeDef *) UART5_BASE) #define I2C1 ((I2C_TypeDef *) I2C1_BASE) #define I2C2 ((I2C_TypeDef *) I2C2_BASE) #define I2C3 ((I2C_TypeDef *) I2C3_BASE) #define FMPI2C1 ((FMPI2C_TypeDef *) FMPI2C1_BASE) #define CAN1 ((CAN_TypeDef *) CAN1_BASE) #define CAN2 ((CAN_TypeDef *) CAN2_BASE) #define CAN3 ((CAN_TypeDef *) CAN3_BASE) #define PWR ((PWR_TypeDef *) PWR_BASE) #define DAC1 ((DAC_TypeDef *) DAC_BASE) #define DAC ((DAC_TypeDef *) DAC_BASE) /* Kept for legacy purpose */ #define UART7 ((USART_TypeDef *) UART7_BASE) #define UART8 ((USART_TypeDef *) UART8_BASE) #define TIM1 ((TIM_TypeDef *) TIM1_BASE) #define TIM8 ((TIM_TypeDef *) TIM8_BASE) #define USART1 ((USART_TypeDef *) USART1_BASE) #define USART6 ((USART_TypeDef *) USART6_BASE) #define UART9 ((USART_TypeDef *) UART9_BASE) #define UART10 ((USART_TypeDef *) UART10_BASE) #define ADC1 ((ADC_TypeDef *) ADC1_BASE) #define ADC1_COMMON ((ADC_Common_TypeDef *) ADC1_COMMON_BASE) /* Legacy define */ #define ADC ADC1_COMMON #define SDIO ((SDIO_TypeDef *) SDIO_BASE) #define SPI1 ((SPI_TypeDef *) SPI1_BASE) #define SPI4 ((SPI_TypeDef *) SPI4_BASE) #define SYSCFG ((SYSCFG_TypeDef *) SYSCFG_BASE) #define EXTI ((EXTI_TypeDef *) EXTI_BASE) #define TIM9 ((TIM_TypeDef *) TIM9_BASE) #define TIM10 ((TIM_TypeDef *) TIM10_BASE) #define TIM11 ((TIM_TypeDef *) TIM11_BASE) #define SPI5 ((SPI_TypeDef *) SPI5_BASE) #define DFSDM1_Channel0 ((DFSDM_Channel_TypeDef *) DFSDM1_Channel0_BASE) #define DFSDM1_Channel1 ((DFSDM_Channel_TypeDef *) DFSDM1_Channel1_BASE) #define DFSDM1_Channel2 ((DFSDM_Channel_TypeDef *) DFSDM1_Channel2_BASE) #define DFSDM1_Channel3 ((DFSDM_Channel_TypeDef *) DFSDM1_Channel3_BASE) #define DFSDM1_Filter0 ((DFSDM_Filter_TypeDef *) DFSDM1_Filter0_BASE) #define DFSDM1_Filter1 ((DFSDM_Filter_TypeDef *) DFSDM1_Filter1_BASE) #define DFSDM2_Channel0 ((DFSDM_Channel_TypeDef *) DFSDM2_Channel0_BASE) #define DFSDM2_Channel1 ((DFSDM_Channel_TypeDef *) DFSDM2_Channel1_BASE) #define DFSDM2_Channel2 ((DFSDM_Channel_TypeDef *) DFSDM2_Channel2_BASE) #define DFSDM2_Channel3 ((DFSDM_Channel_TypeDef *) DFSDM2_Channel3_BASE) #define DFSDM2_Channel4 ((DFSDM_Channel_TypeDef *) DFSDM2_Channel4_BASE) #define DFSDM2_Channel5 ((DFSDM_Channel_TypeDef *) DFSDM2_Channel5_BASE) #define DFSDM2_Channel6 ((DFSDM_Channel_TypeDef *) DFSDM2_Channel6_BASE) #define DFSDM2_Channel7 ((DFSDM_Channel_TypeDef *) DFSDM2_Channel7_BASE) #define DFSDM2_Filter0 ((DFSDM_Filter_TypeDef *) DFSDM2_Filter0_BASE) #define DFSDM2_Filter1 ((DFSDM_Filter_TypeDef *) DFSDM2_Filter1_BASE) #define DFSDM2_Filter2 ((DFSDM_Filter_TypeDef *) DFSDM2_Filter2_BASE) #define DFSDM2_Filter3 ((DFSDM_Filter_TypeDef *) DFSDM2_Filter3_BASE) #define SAI1 ((SAI_TypeDef *) SAI1_BASE) #define SAI1_Block_A ((SAI_Block_TypeDef *)SAI1_Block_A_BASE) #define SAI1_Block_B ((SAI_Block_TypeDef *)SAI1_Block_B_BASE) #define GPIOA ((GPIO_TypeDef *) GPIOA_BASE) #define GPIOB ((GPIO_TypeDef *) GPIOB_BASE) #define GPIOC ((GPIO_TypeDef *) GPIOC_BASE) #define GPIOD ((GPIO_TypeDef *) GPIOD_BASE) #define GPIOE ((GPIO_TypeDef *) GPIOE_BASE) #define GPIOF ((GPIO_TypeDef *) GPIOF_BASE) #define GPIOG ((GPIO_TypeDef *) GPIOG_BASE) #define GPIOH ((GPIO_TypeDef *) GPIOH_BASE) #define CRC ((CRC_TypeDef *) CRC_BASE) #define RCC ((RCC_TypeDef *) RCC_BASE) #define FLASH ((FLASH_TypeDef *) FLASH_R_BASE) #define DMA1 ((DMA_TypeDef *) DMA1_BASE) #define DMA1_Stream0 ((DMA_Stream_TypeDef *) DMA1_Stream0_BASE) #define DMA1_Stream1 ((DMA_Stream_TypeDef *) DMA1_Stream1_BASE) #define DMA1_Stream2 ((DMA_Stream_TypeDef *) DMA1_Stream2_BASE) #define DMA1_Stream3 ((DMA_Stream_TypeDef *) DMA1_Stream3_BASE) #define DMA1_Stream4 ((DMA_Stream_TypeDef *) DMA1_Stream4_BASE) #define DMA1_Stream5 ((DMA_Stream_TypeDef *) DMA1_Stream5_BASE) #define DMA1_Stream6 ((DMA_Stream_TypeDef *) DMA1_Stream6_BASE) #define DMA1_Stream7 ((DMA_Stream_TypeDef *) DMA1_Stream7_BASE) #define DMA2 ((DMA_TypeDef *) DMA2_BASE) #define DMA2_Stream0 ((DMA_Stream_TypeDef *) DMA2_Stream0_BASE) #define DMA2_Stream1 ((DMA_Stream_TypeDef *) DMA2_Stream1_BASE) #define DMA2_Stream2 ((DMA_Stream_TypeDef *) DMA2_Stream2_BASE) #define DMA2_Stream3 ((DMA_Stream_TypeDef *) DMA2_Stream3_BASE) #define DMA2_Stream4 ((DMA_Stream_TypeDef *) DMA2_Stream4_BASE) #define DMA2_Stream5 ((DMA_Stream_TypeDef *) DMA2_Stream5_BASE) #define DMA2_Stream6 ((DMA_Stream_TypeDef *) DMA2_Stream6_BASE) #define DMA2_Stream7 ((DMA_Stream_TypeDef *) DMA2_Stream7_BASE) #define RNG ((RNG_TypeDef *) RNG_BASE) #define FSMC_Bank1 ((FSMC_Bank1_TypeDef *) FSMC_Bank1_R_BASE) #define FSMC_Bank1E ((FSMC_Bank1E_TypeDef *) FSMC_Bank1E_R_BASE) #define QUADSPI ((QUADSPI_TypeDef *) QSPI_R_BASE) #define DBGMCU ((DBGMCU_TypeDef *) DBGMCU_BASE) #define USB_OTG_FS ((USB_OTG_GlobalTypeDef *) USB_OTG_FS_PERIPH_BASE) /** * @} */ /** @addtogroup Exported_constants * @{ */ /** @addtogroup Peripheral_Registers_Bits_Definition * @{ */ /******************************************************************************/ /* Peripheral Registers_Bits_Definition */ /******************************************************************************/ /******************************************************************************/ /* */ /* Analog to Digital Converter */ /* */ /******************************************************************************/ /******************** Bit definition for ADC_SR register ********************/ #define ADC_SR_AWD_Pos (0U) #define ADC_SR_AWD_Msk (0x1UL << ADC_SR_AWD_Pos) /*!< 0x00000001 */ #define ADC_SR_AWD ADC_SR_AWD_Msk /*!
© COPYRIGHT(c) 2017 STMicroelectronics
* * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. Neither the name of STMicroelectronics nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ /** @addtogroup CMSIS_Device * @{ */ /** @addtogroup stm32f446xx * @{ */ #ifndef __STM32F446xx_H #define __STM32F446xx_H #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ /** @addtogroup Configuration_section_for_CMSIS * @{ */ /** * @brief Configuration of the Cortex-M4 Processor and Core Peripherals */ #define __CM4_REV 0x0001U /*!< Core revision r0p1 */ #define __MPU_PRESENT 1U /*!< STM32F4XX provides an MPU */ #define __NVIC_PRIO_BITS 4U /*!< STM32F4XX uses 4 Bits for the Priority Levels */ #define __Vendor_SysTickConfig 0U /*!< Set to 1 if different SysTick Config is used */ #define __FPU_PRESENT 1U /*!< FPU present */ /** * @} */ /** @addtogroup Peripheral_interrupt_number_definition * @{ */ /** * @brief STM32F4XX Interrupt Number Definition, according to the selected device * in @ref Library_configuration_section */ typedef enum { /****** Cortex-M4 Processor Exceptions Numbers ****************************************************************/ NonMaskableInt_IRQn = -14, /*!< 2 Non Maskable Interrupt */ MemoryManagement_IRQn = -12, /*!< 4 Cortex-M4 Memory Management Interrupt */ BusFault_IRQn = -11, /*!< 5 Cortex-M4 Bus Fault Interrupt */ UsageFault_IRQn = -10, /*!< 6 Cortex-M4 Usage Fault Interrupt */ SVCall_IRQn = -5, /*!< 11 Cortex-M4 SV Call Interrupt */ DebugMonitor_IRQn = -4, /*!< 12 Cortex-M4 Debug Monitor Interrupt */ PendSV_IRQn = -2, /*!< 14 Cortex-M4 Pend SV Interrupt */ SysTick_IRQn = -1, /*!< 15 Cortex-M4 System Tick Interrupt */ /****** STM32 specific Interrupt Numbers **********************************************************************/ WWDG_IRQn = 0, /*!< Window WatchDog Interrupt */ PVD_IRQn = 1, /*!< PVD through EXTI Line detection Interrupt */ TAMP_STAMP_IRQn = 2, /*!< Tamper and TimeStamp interrupts through the EXTI line */ RTC_WKUP_IRQn = 3, /*!< RTC Wakeup interrupt through the EXTI line */ FLASH_IRQn = 4, /*!< FLASH global Interrupt */ RCC_IRQn = 5, /*!< RCC global Interrupt */ EXTI0_IRQn = 6, /*!< EXTI Line0 Interrupt */ EXTI1_IRQn = 7, /*!< EXTI Line1 Interrupt */ EXTI2_IRQn = 8, /*!< EXTI Line2 Interrupt */ EXTI3_IRQn = 9, /*!< EXTI Line3 Interrupt */ EXTI4_IRQn = 10, /*!< EXTI Line4 Interrupt */ DMA1_Stream0_IRQn = 11, /*!< DMA1 Stream 0 global Interrupt */ DMA1_Stream1_IRQn = 12, /*!< DMA1 Stream 1 global Interrupt */ DMA1_Stream2_IRQn = 13, /*!< DMA1 Stream 2 global Interrupt */ DMA1_Stream3_IRQn = 14, /*!< DMA1 Stream 3 global Interrupt */ DMA1_Stream4_IRQn = 15, /*!< DMA1 Stream 4 global Interrupt */ DMA1_Stream5_IRQn = 16, /*!< DMA1 Stream 5 global Interrupt */ DMA1_Stream6_IRQn = 17, /*!< DMA1 Stream 6 global Interrupt */ ADC_IRQn = 18, /*!< ADC1, ADC2 and ADC3 global Interrupts */ CAN1_TX_IRQn = 19, /*!< CAN1 TX Interrupt */ CAN1_RX0_IRQn = 20, /*!< CAN1 RX0 Interrupt */ CAN1_RX1_IRQn = 21, /*!< CAN1 RX1 Interrupt */ CAN1_SCE_IRQn = 22, /*!< CAN1 SCE Interrupt */ EXTI9_5_IRQn = 23, /*!< External Line[9:5] Interrupts */ TIM1_BRK_TIM9_IRQn = 24, /*!< TIM1 Break interrupt and TIM9 global interrupt */ TIM1_UP_TIM10_IRQn = 25, /*!< TIM1 Update Interrupt and TIM10 global interrupt */ TIM1_TRG_COM_TIM11_IRQn = 26, /*!< TIM1 Trigger and Commutation Interrupt and TIM11 global interrupt */ TIM1_CC_IRQn = 27, /*!< TIM1 Capture Compare Interrupt */ TIM2_IRQn = 28, /*!< TIM2 global Interrupt */ TIM3_IRQn = 29, /*!< TIM3 global Interrupt */ TIM4_IRQn = 30, /*!< TIM4 global Interrupt */ I2C1_EV_IRQn = 31, /*!< I2C1 Event Interrupt */ I2C1_ER_IRQn = 32, /*!< I2C1 Error Interrupt */ I2C2_EV_IRQn = 33, /*!< I2C2 Event Interrupt */ I2C2_ER_IRQn = 34, /*!< I2C2 Error Interrupt */ SPI1_IRQn = 35, /*!< SPI1 global Interrupt */ SPI2_IRQn = 36, /*!< SPI2 global Interrupt */ USART1_IRQn = 37, /*!< USART1 global Interrupt */ USART2_IRQn = 38, /*!< USART2 global Interrupt */ USART3_IRQn = 39, /*!< USART3 global Interrupt */ EXTI15_10_IRQn = 40, /*!< External Line[15:10] Interrupts */ RTC_Alarm_IRQn = 41, /*!< RTC Alarm (A and B) through EXTI Line Interrupt */ OTG_FS_WKUP_IRQn = 42, /*!< USB OTG FS Wakeup through EXTI line interrupt */ TIM8_BRK_TIM12_IRQn = 43, /*!< TIM8 Break Interrupt and TIM12 global interrupt */ TIM8_UP_TIM13_IRQn = 44, /*!< TIM8 Update Interrupt and TIM13 global interrupt */ TIM8_TRG_COM_TIM14_IRQn = 45, /*!< TIM8 Trigger and Commutation Interrupt and TIM14 global interrupt */ TIM8_CC_IRQn = 46, /*!< TIM8 Capture Compare global interrupt */ DMA1_Stream7_IRQn = 47, /*!< DMA1 Stream7 Interrupt */ FMC_IRQn = 48, /*!< FMC global Interrupt */ SDIO_IRQn = 49, /*!< SDIO global Interrupt */ TIM5_IRQn = 50, /*!< TIM5 global Interrupt */ SPI3_IRQn = 51, /*!< SPI3 global Interrupt */ UART4_IRQn = 52, /*!< UART4 global Interrupt */ UART5_IRQn = 53, /*!< UART5 global Interrupt */ TIM6_DAC_IRQn = 54, /*!< TIM6 global and DAC1&2 underrun error interrupts */ TIM7_IRQn = 55, /*!< TIM7 global interrupt */ DMA2_Stream0_IRQn = 56, /*!< DMA2 Stream 0 global Interrupt */ DMA2_Stream1_IRQn = 57, /*!< DMA2 Stream 1 global Interrupt */ DMA2_Stream2_IRQn = 58, /*!< DMA2 Stream 2 global Interrupt */ DMA2_Stream3_IRQn = 59, /*!< DMA2 Stream 3 global Interrupt */ DMA2_Stream4_IRQn = 60, /*!< DMA2 Stream 4 global Interrupt */ CAN2_TX_IRQn = 63, /*!< CAN2 TX Interrupt */ CAN2_RX0_IRQn = 64, /*!< CAN2 RX0 Interrupt */ CAN2_RX1_IRQn = 65, /*!< CAN2 RX1 Interrupt */ CAN2_SCE_IRQn = 66, /*!< CAN2 SCE Interrupt */ OTG_FS_IRQn = 67, /*!< USB OTG FS global Interrupt */ DMA2_Stream5_IRQn = 68, /*!< DMA2 Stream 5 global interrupt */ DMA2_Stream6_IRQn = 69, /*!< DMA2 Stream 6 global interrupt */ DMA2_Stream7_IRQn = 70, /*!< DMA2 Stream 7 global interrupt */ USART6_IRQn = 71, /*!< USART6 global interrupt */ I2C3_EV_IRQn = 72, /*!< I2C3 event interrupt */ I2C3_ER_IRQn = 73, /*!< I2C3 error interrupt */ OTG_HS_EP1_OUT_IRQn = 74, /*!< USB OTG HS End Point 1 Out global interrupt */ OTG_HS_EP1_IN_IRQn = 75, /*!< USB OTG HS End Point 1 In global interrupt */ OTG_HS_WKUP_IRQn = 76, /*!< USB OTG HS Wakeup through EXTI interrupt */ OTG_HS_IRQn = 77, /*!< USB OTG HS global interrupt */ DCMI_IRQn = 78, /*!< DCMI global interrupt */ FPU_IRQn = 81, /*!< FPU global interrupt */ SPI4_IRQn = 84, /*!< SPI4 global Interrupt */ SAI1_IRQn = 87, /*!< SAI1 global Interrupt */ SAI2_IRQn = 91, /*!< SAI2 global Interrupt */ QUADSPI_IRQn = 92, /*!< QuadSPI global Interrupt */ CEC_IRQn = 93, /*!< CEC global Interrupt */ SPDIF_RX_IRQn = 94, /*!< SPDIF-RX global Interrupt */ FMPI2C1_EV_IRQn = 95, /*!< FMPI2C1 Event Interrupt */ FMPI2C1_ER_IRQn = 96 /*!< FMPI2C1 Error Interrupt */ } IRQn_Type; /** * @} */ #include "core_cm4.h" /* Cortex-M4 processor and core peripherals */ #include "system_stm32f4xx.h" #include /** @addtogroup Peripheral_registers_structures * @{ */ /** * @brief Analog to Digital Converter */ typedef struct { __IO uint32_t SR; /*!< ADC status register, Address offset: 0x00 */ __IO uint32_t CR1; /*!< ADC control register 1, Address offset: 0x04 */ __IO uint32_t CR2; /*!< ADC control register 2, Address offset: 0x08 */ __IO uint32_t SMPR1; /*!< ADC sample time register 1, Address offset: 0x0C */ __IO uint32_t SMPR2; /*!< ADC sample time register 2, Address offset: 0x10 */ __IO uint32_t JOFR1; /*!< ADC injected channel data offset register 1, Address offset: 0x14 */ __IO uint32_t JOFR2; /*!< ADC injected channel data offset register 2, Address offset: 0x18 */ __IO uint32_t JOFR3; /*!< ADC injected channel data offset register 3, Address offset: 0x1C */ __IO uint32_t JOFR4; /*!< ADC injected channel data offset register 4, Address offset: 0x20 */ __IO uint32_t HTR; /*!< ADC watchdog higher threshold register, Address offset: 0x24 */ __IO uint32_t LTR; /*!< ADC watchdog lower threshold register, Address offset: 0x28 */ __IO uint32_t SQR1; /*!< ADC regular sequence register 1, Address offset: 0x2C */ __IO uint32_t SQR2; /*!< ADC regular sequence register 2, Address offset: 0x30 */ __IO uint32_t SQR3; /*!< ADC regular sequence register 3, Address offset: 0x34 */ __IO uint32_t JSQR; /*!< ADC injected sequence register, Address offset: 0x38*/ __IO uint32_t JDR1; /*!< ADC injected data register 1, Address offset: 0x3C */ __IO uint32_t JDR2; /*!< ADC injected data register 2, Address offset: 0x40 */ __IO uint32_t JDR3; /*!< ADC injected data register 3, Address offset: 0x44 */ __IO uint32_t JDR4; /*!< ADC injected data register 4, Address offset: 0x48 */ __IO uint32_t DR; /*!< ADC regular data register, Address offset: 0x4C */ } ADC_TypeDef; typedef struct { __IO uint32_t CSR; /*!< ADC Common status register, Address offset: ADC1 base address + 0x300 */ __IO uint32_t CCR; /*!< ADC common control register, Address offset: ADC1 base address + 0x304 */ __IO uint32_t CDR; /*!< ADC common regular data register for dual AND triple modes, Address offset: ADC1 base address + 0x308 */ } ADC_Common_TypeDef; /** * @brief Controller Area Network TxMailBox */ typedef struct { __IO uint32_t TIR; /*!< CAN TX mailbox identifier register */ __IO uint32_t TDTR; /*!< CAN mailbox data length control and time stamp register */ __IO uint32_t TDLR; /*!< CAN mailbox data low register */ __IO uint32_t TDHR; /*!< CAN mailbox data high register */ } CAN_TxMailBox_TypeDef; /** * @brief Controller Area Network FIFOMailBox */ typedef struct { __IO uint32_t RIR; /*!< CAN receive FIFO mailbox identifier register */ __IO uint32_t RDTR; /*!< CAN receive FIFO mailbox data length control and time stamp register */ __IO uint32_t RDLR; /*!< CAN receive FIFO mailbox data low register */ __IO uint32_t RDHR; /*!< CAN receive FIFO mailbox data high register */ } CAN_FIFOMailBox_TypeDef; /** * @brief Controller Area Network FilterRegister */ typedef struct { __IO uint32_t FR1; /*!< CAN Filter bank register 1 */ __IO uint32_t FR2; /*!< CAN Filter bank register 1 */ } CAN_FilterRegister_TypeDef; /** * @brief Controller Area Network */ typedef struct { __IO uint32_t MCR; /*!< CAN master control register, Address offset: 0x00 */ __IO uint32_t MSR; /*!< CAN master status register, Address offset: 0x04 */ __IO uint32_t TSR; /*!< CAN transmit status register, Address offset: 0x08 */ __IO uint32_t RF0R; /*!< CAN receive FIFO 0 register, Address offset: 0x0C */ __IO uint32_t RF1R; /*!< CAN receive FIFO 1 register, Address offset: 0x10 */ __IO uint32_t IER; /*!< CAN interrupt enable register, Address offset: 0x14 */ __IO uint32_t ESR; /*!< CAN error status register, Address offset: 0x18 */ __IO uint32_t BTR; /*!< CAN bit timing register, Address offset: 0x1C */ uint32_t RESERVED0[88]; /*!< Reserved, 0x020 - 0x17F */ CAN_TxMailBox_TypeDef sTxMailBox[3]; /*!< CAN Tx MailBox, Address offset: 0x180 - 0x1AC */ CAN_FIFOMailBox_TypeDef sFIFOMailBox[2]; /*!< CAN FIFO MailBox, Address offset: 0x1B0 - 0x1CC */ uint32_t RESERVED1[12]; /*!< Reserved, 0x1D0 - 0x1FF */ __IO uint32_t FMR; /*!< CAN filter master register, Address offset: 0x200 */ __IO uint32_t FM1R; /*!< CAN filter mode register, Address offset: 0x204 */ uint32_t RESERVED2; /*!< Reserved, 0x208 */ __IO uint32_t FS1R; /*!< CAN filter scale register, Address offset: 0x20C */ uint32_t RESERVED3; /*!< Reserved, 0x210 */ __IO uint32_t FFA1R; /*!< CAN filter FIFO assignment register, Address offset: 0x214 */ uint32_t RESERVED4; /*!< Reserved, 0x218 */ __IO uint32_t FA1R; /*!< CAN filter activation register, Address offset: 0x21C */ uint32_t RESERVED5[8]; /*!< Reserved, 0x220-0x23F */ CAN_FilterRegister_TypeDef sFilterRegister[28]; /*!< CAN Filter Register, Address offset: 0x240-0x31C */ } CAN_TypeDef; /** * @brief Consumer Electronics Control */ typedef struct { __IO uint32_t CR; /*!< CEC control register, Address offset:0x00 */ __IO uint32_t CFGR; /*!< CEC configuration register, Address offset:0x04 */ __IO uint32_t TXDR; /*!< CEC Tx data register , Address offset:0x08 */ __IO uint32_t RXDR; /*!< CEC Rx Data Register, Address offset:0x0C */ __IO uint32_t ISR; /*!< CEC Interrupt and Status Register, Address offset:0x10 */ __IO uint32_t IER; /*!< CEC interrupt enable register, Address offset:0x14 */ }CEC_TypeDef; /** * @brief CRC calculation unit */ typedef struct { __IO uint32_t DR; /*!< CRC Data register, Address offset: 0x00 */ __IO uint8_t IDR; /*!< CRC Independent data register, Address offset: 0x04 */ uint8_t RESERVED0; /*!< Reserved, 0x05 */ uint16_t RESERVED1; /*!< Reserved, 0x06 */ __IO uint32_t CR; /*!< CRC Control register, Address offset: 0x08 */ } CRC_TypeDef; /** * @brief Digital to Analog Converter */ typedef struct { __IO uint32_t CR; /*!< DAC control register, Address offset: 0x00 */ __IO uint32_t SWTRIGR; /*!< DAC software trigger register, Address offset: 0x04 */ __IO uint32_t DHR12R1; /*!< DAC channel1 12-bit right-aligned data holding register, Address offset: 0x08 */ __IO uint32_t DHR12L1; /*!< DAC channel1 12-bit left aligned data holding register, Address offset: 0x0C */ __IO uint32_t DHR8R1; /*!< DAC channel1 8-bit right aligned data holding register, Address offset: 0x10 */ __IO uint32_t DHR12R2; /*!< DAC channel2 12-bit right aligned data holding register, Address offset: 0x14 */ __IO uint32_t DHR12L2; /*!< DAC channel2 12-bit left aligned data holding register, Address offset: 0x18 */ __IO uint32_t DHR8R2; /*!< DAC channel2 8-bit right-aligned data holding register, Address offset: 0x1C */ __IO uint32_t DHR12RD; /*!< Dual DAC 12-bit right-aligned data holding register, Address offset: 0x20 */ __IO uint32_t DHR12LD; /*!< DUAL DAC 12-bit left aligned data holding register, Address offset: 0x24 */ __IO uint32_t DHR8RD; /*!< DUAL DAC 8-bit right aligned data holding register, Address offset: 0x28 */ __IO uint32_t DOR1; /*!< DAC channel1 data output register, Address offset: 0x2C */ __IO uint32_t DOR2; /*!< DAC channel2 data output register, Address offset: 0x30 */ __IO uint32_t SR; /*!< DAC status register, Address offset: 0x34 */ } DAC_TypeDef; /** * @brief Debug MCU */ typedef struct { __IO uint32_t IDCODE; /*!< MCU device ID code, Address offset: 0x00 */ __IO uint32_t CR; /*!< Debug MCU configuration register, Address offset: 0x04 */ __IO uint32_t APB1FZ; /*!< Debug MCU APB1 freeze register, Address offset: 0x08 */ __IO uint32_t APB2FZ; /*!< Debug MCU APB2 freeze register, Address offset: 0x0C */ }DBGMCU_TypeDef; /** * @brief DCMI */ typedef struct { __IO uint32_t CR; /*!< DCMI control register 1, Address offset: 0x00 */ __IO uint32_t SR; /*!< DCMI status register, Address offset: 0x04 */ __IO uint32_t RISR; /*!< DCMI raw interrupt status register, Address offset: 0x08 */ __IO uint32_t IER; /*!< DCMI interrupt enable register, Address offset: 0x0C */ __IO uint32_t MISR; /*!< DCMI masked interrupt status register, Address offset: 0x10 */ __IO uint32_t ICR; /*!< DCMI interrupt clear register, Address offset: 0x14 */ __IO uint32_t ESCR; /*!< DCMI embedded synchronization code register, Address offset: 0x18 */ __IO uint32_t ESUR; /*!< DCMI embedded synchronization unmask register, Address offset: 0x1C */ __IO uint32_t CWSTRTR; /*!< DCMI crop window start, Address offset: 0x20 */ __IO uint32_t CWSIZER; /*!< DCMI crop window size, Address offset: 0x24 */ __IO uint32_t DR; /*!< DCMI data register, Address offset: 0x28 */ } DCMI_TypeDef; /** * @brief DMA Controller */ typedef struct { __IO uint32_t CR; /*!< DMA stream x configuration register */ __IO uint32_t NDTR; /*!< DMA stream x number of data register */ __IO uint32_t PAR; /*!< DMA stream x peripheral address register */ __IO uint32_t M0AR; /*!< DMA stream x memory 0 address register */ __IO uint32_t M1AR; /*!< DMA stream x memory 1 address register */ __IO uint32_t FCR; /*!< DMA stream x FIFO control register */ } DMA_Stream_TypeDef; typedef struct { __IO uint32_t LISR; /*!< DMA low interrupt status register, Address offset: 0x00 */ __IO uint32_t HISR; /*!< DMA high interrupt status register, Address offset: 0x04 */ __IO uint32_t LIFCR; /*!< DMA low interrupt flag clear register, Address offset: 0x08 */ __IO uint32_t HIFCR; /*!< DMA high interrupt flag clear register, Address offset: 0x0C */ } DMA_TypeDef; /** * @brief External Interrupt/Event Controller */ typedef struct { __IO uint32_t IMR; /*!< EXTI Interrupt mask register, Address offset: 0x00 */ __IO uint32_t EMR; /*!< EXTI Event mask register, Address offset: 0x04 */ __IO uint32_t RTSR; /*!< EXTI Rising trigger selection register, Address offset: 0x08 */ __IO uint32_t FTSR; /*!< EXTI Falling trigger selection register, Address offset: 0x0C */ __IO uint32_t SWIER; /*!< EXTI Software interrupt event register, Address offset: 0x10 */ __IO uint32_t PR; /*!< EXTI Pending register, Address offset: 0x14 */ } EXTI_TypeDef; /** * @brief FLASH Registers */ typedef struct { __IO uint32_t ACR; /*!< FLASH access control register, Address offset: 0x00 */ __IO uint32_t KEYR; /*!< FLASH key register, Address offset: 0x04 */ __IO uint32_t OPTKEYR; /*!< FLASH option key register, Address offset: 0x08 */ __IO uint32_t SR; /*!< FLASH status register, Address offset: 0x0C */ __IO uint32_t CR; /*!< FLASH control register, Address offset: 0x10 */ __IO uint32_t OPTCR; /*!< FLASH option control register , Address offset: 0x14 */ __IO uint32_t OPTCR1; /*!< FLASH option control register 1, Address offset: 0x18 */ } FLASH_TypeDef; /** * @brief Flexible Memory Controller */ typedef struct { __IO uint32_t BTCR[8]; /*!< NOR/PSRAM chip-select control register(BCR) and chip-select timing register(BTR), Address offset: 0x00-1C */ } FMC_Bank1_TypeDef; /** * @brief Flexible Memory Controller Bank1E */ typedef struct { __IO uint32_t BWTR[7]; /*!< NOR/PSRAM write timing registers, Address offset: 0x104-0x11C */ } FMC_Bank1E_TypeDef; /** * @brief Flexible Memory Controller Bank3 */ typedef struct { __IO uint32_t PCR; /*!< NAND Flash control register, Address offset: 0x80 */ __IO uint32_t SR; /*!< NAND Flash FIFO status and interrupt register, Address offset: 0x84 */ __IO uint32_t PMEM; /*!< NAND Flash Common memory space timing register, Address offset: 0x88 */ __IO uint32_t PATT; /*!< NAND Flash Attribute memory space timing register, Address offset: 0x8C */ uint32_t RESERVED; /*!< Reserved, 0x90 */ __IO uint32_t ECCR; /*!< NAND Flash ECC result registers, Address offset: 0x94 */ } FMC_Bank3_TypeDef; /** * @brief Flexible Memory Controller Bank5_6 */ typedef struct { __IO uint32_t SDCR[2]; /*!< SDRAM Control registers , Address offset: 0x140-0x144 */ __IO uint32_t SDTR[2]; /*!< SDRAM Timing registers , Address offset: 0x148-0x14C */ __IO uint32_t SDCMR; /*!< SDRAM Command Mode register, Address offset: 0x150 */ __IO uint32_t SDRTR; /*!< SDRAM Refresh Timer register, Address offset: 0x154 */ __IO uint32_t SDSR; /*!< SDRAM Status register, Address offset: 0x158 */ } FMC_Bank5_6_TypeDef; /** * @brief General Purpose I/O */ typedef struct { __IO uint32_t MODER; /*!< GPIO port mode register, Address offset: 0x00 */ __IO uint32_t OTYPER; /*!< GPIO port output type register, Address offset: 0x04 */ __IO uint32_t OSPEEDR; /*!< GPIO port output speed register, Address offset: 0x08 */ __IO uint32_t PUPDR; /*!< GPIO port pull-up/pull-down register, Address offset: 0x0C */ __IO uint32_t IDR; /*!< GPIO port input data register, Address offset: 0x10 */ __IO uint32_t ODR; /*!< GPIO port output data register, Address offset: 0x14 */ __IO uint32_t BSRR; /*!< GPIO port bit set/reset register, Address offset: 0x18 */ __IO uint32_t LCKR; /*!< GPIO port configuration lock register, Address offset: 0x1C */ __IO uint32_t AFR[2]; /*!< GPIO alternate function registers, Address offset: 0x20-0x24 */ } GPIO_TypeDef; /** * @brief System configuration controller */ typedef struct { __IO uint32_t MEMRMP; /*!< SYSCFG memory remap register, Address offset: 0x00 */ __IO uint32_t PMC; /*!< SYSCFG peripheral mode configuration register, Address offset: 0x04 */ __IO uint32_t EXTICR[4]; /*!< SYSCFG external interrupt configuration registers, Address offset: 0x08-0x14 */ uint32_t RESERVED[2]; /*!< Reserved, 0x18-0x1C */ __IO uint32_t CMPCR; /*!< SYSCFG Compensation cell control register, Address offset: 0x20 */ uint32_t RESERVED1[2]; /*!< Reserved, 0x24-0x28 */ __IO uint32_t CFGR; /*!< SYSCFG Configuration register, Address offset: 0x2C */ } SYSCFG_TypeDef; /** * @brief Inter-integrated Circuit Interface */ typedef struct { __IO uint32_t CR1; /*!< I2C Control register 1, Address offset: 0x00 */ __IO uint32_t CR2; /*!< I2C Control register 2, Address offset: 0x04 */ __IO uint32_t OAR1; /*!< I2C Own address register 1, Address offset: 0x08 */ __IO uint32_t OAR2; /*!< I2C Own address register 2, Address offset: 0x0C */ __IO uint32_t DR; /*!< I2C Data register, Address offset: 0x10 */ __IO uint32_t SR1; /*!< I2C Status register 1, Address offset: 0x14 */ __IO uint32_t SR2; /*!< I2C Status register 2, Address offset: 0x18 */ __IO uint32_t CCR; /*!< I2C Clock control register, Address offset: 0x1C */ __IO uint32_t TRISE; /*!< I2C TRISE register, Address offset: 0x20 */ __IO uint32_t FLTR; /*!< I2C FLTR register, Address offset: 0x24 */ } I2C_TypeDef; /** * @brief Inter-integrated Circuit Interface */ typedef struct { __IO uint32_t CR1; /*!< FMPI2C Control register 1, Address offset: 0x00 */ __IO uint32_t CR2; /*!< FMPI2C Control register 2, Address offset: 0x04 */ __IO uint32_t OAR1; /*!< FMPI2C Own address 1 register, Address offset: 0x08 */ __IO uint32_t OAR2; /*!< FMPI2C Own address 2 register, Address offset: 0x0C */ __IO uint32_t TIMINGR; /*!< FMPI2C Timing register, Address offset: 0x10 */ __IO uint32_t TIMEOUTR; /*!< FMPI2C Timeout register, Address offset: 0x14 */ __IO uint32_t ISR; /*!< FMPI2C Interrupt and status register, Address offset: 0x18 */ __IO uint32_t ICR; /*!< FMPI2C Interrupt clear register, Address offset: 0x1C */ __IO uint32_t PECR; /*!< FMPI2C PEC register, Address offset: 0x20 */ __IO uint32_t RXDR; /*!< FMPI2C Receive data register, Address offset: 0x24 */ __IO uint32_t TXDR; /*!< FMPI2C Transmit data register, Address offset: 0x28 */ } FMPI2C_TypeDef; /** * @brief Independent WATCHDOG */ typedef struct { __IO uint32_t KR; /*!< IWDG Key register, Address offset: 0x00 */ __IO uint32_t PR; /*!< IWDG Prescaler register, Address offset: 0x04 */ __IO uint32_t RLR; /*!< IWDG Reload register, Address offset: 0x08 */ __IO uint32_t SR; /*!< IWDG Status register, Address offset: 0x0C */ } IWDG_TypeDef; /** * @brief Power Control */ typedef struct { __IO uint32_t CR; /*!< PWR power control register, Address offset: 0x00 */ __IO uint32_t CSR; /*!< PWR power control/status register, Address offset: 0x04 */ } PWR_TypeDef; /** * @brief Reset and Clock Control */ typedef struct { __IO uint32_t CR; /*!< RCC clock control register, Address offset: 0x00 */ __IO uint32_t PLLCFGR; /*!< RCC PLL configuration register, Address offset: 0x04 */ __IO uint32_t CFGR; /*!< RCC clock configuration register, Address offset: 0x08 */ __IO uint32_t CIR; /*!< RCC clock interrupt register, Address offset: 0x0C */ __IO uint32_t AHB1RSTR; /*!< RCC AHB1 peripheral reset register, Address offset: 0x10 */ __IO uint32_t AHB2RSTR; /*!< RCC AHB2 peripheral reset register, Address offset: 0x14 */ __IO uint32_t AHB3RSTR; /*!< RCC AHB3 peripheral reset register, Address offset: 0x18 */ uint32_t RESERVED0; /*!< Reserved, 0x1C */ __IO uint32_t APB1RSTR; /*!< RCC APB1 peripheral reset register, Address offset: 0x20 */ __IO uint32_t APB2RSTR; /*!< RCC APB2 peripheral reset register, Address offset: 0x24 */ uint32_t RESERVED1[2]; /*!< Reserved, 0x28-0x2C */ __IO uint32_t AHB1ENR; /*!< RCC AHB1 peripheral clock register, Address offset: 0x30 */ __IO uint32_t AHB2ENR; /*!< RCC AHB2 peripheral clock register, Address offset: 0x34 */ __IO uint32_t AHB3ENR; /*!< RCC AHB3 peripheral clock register, Address offset: 0x38 */ uint32_t RESERVED2; /*!< Reserved, 0x3C */ __IO uint32_t APB1ENR; /*!< RCC APB1 peripheral clock enable register, Address offset: 0x40 */ __IO uint32_t APB2ENR; /*!< RCC APB2 peripheral clock enable register, Address offset: 0x44 */ uint32_t RESERVED3[2]; /*!< Reserved, 0x48-0x4C */ __IO uint32_t AHB1LPENR; /*!< RCC AHB1 peripheral clock enable in low power mode register, Address offset: 0x50 */ __IO uint32_t AHB2LPENR; /*!< RCC AHB2 peripheral clock enable in low power mode register, Address offset: 0x54 */ __IO uint32_t AHB3LPENR; /*!< RCC AHB3 peripheral clock enable in low power mode register, Address offset: 0x58 */ uint32_t RESERVED4; /*!< Reserved, 0x5C */ __IO uint32_t APB1LPENR; /*!< RCC APB1 peripheral clock enable in low power mode register, Address offset: 0x60 */ __IO uint32_t APB2LPENR; /*!< RCC APB2 peripheral clock enable in low power mode register, Address offset: 0x64 */ uint32_t RESERVED5[2]; /*!< Reserved, 0x68-0x6C */ __IO uint32_t BDCR; /*!< RCC Backup domain control register, Address offset: 0x70 */ __IO uint32_t CSR; /*!< RCC clock control & status register, Address offset: 0x74 */ uint32_t RESERVED6[2]; /*!< Reserved, 0x78-0x7C */ __IO uint32_t SSCGR; /*!< RCC spread spectrum clock generation register, Address offset: 0x80 */ __IO uint32_t PLLI2SCFGR; /*!< RCC PLLI2S configuration register, Address offset: 0x84 */ __IO uint32_t PLLSAICFGR; /*!< RCC PLLSAI configuration register, Address offset: 0x88 */ __IO uint32_t DCKCFGR; /*!< RCC Dedicated Clocks configuration register, Address offset: 0x8C */ __IO uint32_t CKGATENR; /*!< RCC Clocks Gated ENable Register, Address offset: 0x90 */ __IO uint32_t DCKCFGR2; /*!< RCC Dedicated Clocks configuration register 2, Address offset: 0x94 */ } RCC_TypeDef; /** * @brief Real-Time Clock */ typedef struct { __IO uint32_t TR; /*!< RTC time register, Address offset: 0x00 */ __IO uint32_t DR; /*!< RTC date register, Address offset: 0x04 */ __IO uint32_t CR; /*!< RTC control register, Address offset: 0x08 */ __IO uint32_t ISR; /*!< RTC initialization and status register, Address offset: 0x0C */ __IO uint32_t PRER; /*!< RTC prescaler register, Address offset: 0x10 */ __IO uint32_t WUTR; /*!< RTC wakeup timer register, Address offset: 0x14 */ __IO uint32_t CALIBR; /*!< RTC calibration register, Address offset: 0x18 */ __IO uint32_t ALRMAR; /*!< RTC alarm A register, Address offset: 0x1C */ __IO uint32_t ALRMBR; /*!< RTC alarm B register, Address offset: 0x20 */ __IO uint32_t WPR; /*!< RTC write protection register, Address offset: 0x24 */ __IO uint32_t SSR; /*!< RTC sub second register, Address offset: 0x28 */ __IO uint32_t SHIFTR; /*!< RTC shift control register, Address offset: 0x2C */ __IO uint32_t TSTR; /*!< RTC time stamp time register, Address offset: 0x30 */ __IO uint32_t TSDR; /*!< RTC time stamp date register, Address offset: 0x34 */ __IO uint32_t TSSSR; /*!< RTC time-stamp sub second register, Address offset: 0x38 */ __IO uint32_t CALR; /*!< RTC calibration register, Address offset: 0x3C */ __IO uint32_t TAFCR; /*!< RTC tamper and alternate function configuration register, Address offset: 0x40 */ __IO uint32_t ALRMASSR;/*!< RTC alarm A sub second register, Address offset: 0x44 */ __IO uint32_t ALRMBSSR;/*!< RTC alarm B sub second register, Address offset: 0x48 */ uint32_t RESERVED7; /*!< Reserved, 0x4C */ __IO uint32_t BKP0R; /*!< RTC backup register 1, Address offset: 0x50 */ __IO uint32_t BKP1R; /*!< RTC backup register 1, Address offset: 0x54 */ __IO uint32_t BKP2R; /*!< RTC backup register 2, Address offset: 0x58 */ __IO uint32_t BKP3R; /*!< RTC backup register 3, Address offset: 0x5C */ __IO uint32_t BKP4R; /*!< RTC backup register 4, Address offset: 0x60 */ __IO uint32_t BKP5R; /*!< RTC backup register 5, Address offset: 0x64 */ __IO uint32_t BKP6R; /*!< RTC backup register 6, Address offset: 0x68 */ __IO uint32_t BKP7R; /*!< RTC backup register 7, Address offset: 0x6C */ __IO uint32_t BKP8R; /*!< RTC backup register 8, Address offset: 0x70 */ __IO uint32_t BKP9R; /*!< RTC backup register 9, Address offset: 0x74 */ __IO uint32_t BKP10R; /*!< RTC backup register 10, Address offset: 0x78 */ __IO uint32_t BKP11R; /*!< RTC backup register 11, Address offset: 0x7C */ __IO uint32_t BKP12R; /*!< RTC backup register 12, Address offset: 0x80 */ __IO uint32_t BKP13R; /*!< RTC backup register 13, Address offset: 0x84 */ __IO uint32_t BKP14R; /*!< RTC backup register 14, Address offset: 0x88 */ __IO uint32_t BKP15R; /*!< RTC backup register 15, Address offset: 0x8C */ __IO uint32_t BKP16R; /*!< RTC backup register 16, Address offset: 0x90 */ __IO uint32_t BKP17R; /*!< RTC backup register 17, Address offset: 0x94 */ __IO uint32_t BKP18R; /*!< RTC backup register 18, Address offset: 0x98 */ __IO uint32_t BKP19R; /*!< RTC backup register 19, Address offset: 0x9C */ } RTC_TypeDef; /** * @brief Serial Audio Interface */ typedef struct { __IO uint32_t GCR; /*!< SAI global configuration register, Address offset: 0x00 */ } SAI_TypeDef; typedef struct { __IO uint32_t CR1; /*!< SAI block x configuration register 1, Address offset: 0x04 */ __IO uint32_t CR2; /*!< SAI block x configuration register 2, Address offset: 0x08 */ __IO uint32_t FRCR; /*!< SAI block x frame configuration register, Address offset: 0x0C */ __IO uint32_t SLOTR; /*!< SAI block x slot register, Address offset: 0x10 */ __IO uint32_t IMR; /*!< SAI block x interrupt mask register, Address offset: 0x14 */ __IO uint32_t SR; /*!< SAI block x status register, Address offset: 0x18 */ __IO uint32_t CLRFR; /*!< SAI block x clear flag register, Address offset: 0x1C */ __IO uint32_t DR; /*!< SAI block x data register, Address offset: 0x20 */ } SAI_Block_TypeDef; /** * @brief SD host Interface */ typedef struct { __IO uint32_t POWER; /*!< SDIO power control register, Address offset: 0x00 */ __IO uint32_t CLKCR; /*!< SDI clock control register, Address offset: 0x04 */ __IO uint32_t ARG; /*!< SDIO argument register, Address offset: 0x08 */ __IO uint32_t CMD; /*!< SDIO command register, Address offset: 0x0C */ __IO const uint32_t RESPCMD; /*!< SDIO command response register, Address offset: 0x10 */ __IO const uint32_t RESP1; /*!< SDIO response 1 register, Address offset: 0x14 */ __IO const uint32_t RESP2; /*!< SDIO response 2 register, Address offset: 0x18 */ __IO const uint32_t RESP3; /*!< SDIO response 3 register, Address offset: 0x1C */ __IO const uint32_t RESP4; /*!< SDIO response 4 register, Address offset: 0x20 */ __IO uint32_t DTIMER; /*!< SDIO data timer register, Address offset: 0x24 */ __IO uint32_t DLEN; /*!< SDIO data length register, Address offset: 0x28 */ __IO uint32_t DCTRL; /*!< SDIO data control register, Address offset: 0x2C */ __IO const uint32_t DCOUNT; /*!< SDIO data counter register, Address offset: 0x30 */ __IO const uint32_t STA; /*!< SDIO status register, Address offset: 0x34 */ __IO uint32_t ICR; /*!< SDIO interrupt clear register, Address offset: 0x38 */ __IO uint32_t MASK; /*!< SDIO mask register, Address offset: 0x3C */ uint32_t RESERVED0[2]; /*!< Reserved, 0x40-0x44 */ __IO const uint32_t FIFOCNT; /*!< SDIO FIFO counter register, Address offset: 0x48 */ uint32_t RESERVED1[13]; /*!< Reserved, 0x4C-0x7C */ __IO uint32_t FIFO; /*!< SDIO data FIFO register, Address offset: 0x80 */ } SDIO_TypeDef; /** * @brief Serial Peripheral Interface */ typedef struct { __IO uint32_t CR1; /*!< SPI control register 1 (not used in I2S mode), Address offset: 0x00 */ __IO uint32_t CR2; /*!< SPI control register 2, Address offset: 0x04 */ __IO uint32_t SR; /*!< SPI status register, Address offset: 0x08 */ __IO uint32_t DR; /*!< SPI data register, Address offset: 0x0C */ __IO uint32_t CRCPR; /*!< SPI CRC polynomial register (not used in I2S mode), Address offset: 0x10 */ __IO uint32_t RXCRCR; /*!< SPI RX CRC register (not used in I2S mode), Address offset: 0x14 */ __IO uint32_t TXCRCR; /*!< SPI TX CRC register (not used in I2S mode), Address offset: 0x18 */ __IO uint32_t I2SCFGR; /*!< SPI_I2S configuration register, Address offset: 0x1C */ __IO uint32_t I2SPR; /*!< SPI_I2S prescaler register, Address offset: 0x20 */ } SPI_TypeDef; /** * @brief QUAD Serial Peripheral Interface */ typedef struct { __IO uint32_t CR; /*!< QUADSPI Control register, Address offset: 0x00 */ __IO uint32_t DCR; /*!< QUADSPI Device Configuration register, Address offset: 0x04 */ __IO uint32_t SR; /*!< QUADSPI Status register, Address offset: 0x08 */ __IO uint32_t FCR; /*!< QUADSPI Flag Clear register, Address offset: 0x0C */ __IO uint32_t DLR; /*!< QUADSPI Data Length register, Address offset: 0x10 */ __IO uint32_t CCR; /*!< QUADSPI Communication Configuration register, Address offset: 0x14 */ __IO uint32_t AR; /*!< QUADSPI Address register, Address offset: 0x18 */ __IO uint32_t ABR; /*!< QUADSPI Alternate Bytes register, Address offset: 0x1C */ __IO uint32_t DR; /*!< QUADSPI Data register, Address offset: 0x20 */ __IO uint32_t PSMKR; /*!< QUADSPI Polling Status Mask register, Address offset: 0x24 */ __IO uint32_t PSMAR; /*!< QUADSPI Polling Status Match register, Address offset: 0x28 */ __IO uint32_t PIR; /*!< QUADSPI Polling Interval register, Address offset: 0x2C */ __IO uint32_t LPTR; /*!< QUADSPI Low Power Timeout register, Address offset: 0x30 */ } QUADSPI_TypeDef; /** * @brief SPDIFRX Interface */ typedef struct { __IO uint32_t CR; /*!< Control register, Address offset: 0x00 */ __IO uint16_t IMR; /*!< Interrupt mask register, Address offset: 0x04 */ uint16_t RESERVED0; /*!< Reserved, 0x06 */ __IO uint32_t SR; /*!< Status register, Address offset: 0x08 */ __IO uint16_t IFCR; /*!< Interrupt Flag Clear register, Address offset: 0x0C */ uint16_t RESERVED1; /*!< Reserved, 0x0E */ __IO uint32_t DR; /*!< Data input register, Address offset: 0x10 */ __IO uint32_t CSR; /*!< Channel Status register, Address offset: 0x14 */ __IO uint32_t DIR; /*!< Debug Information register, Address offset: 0x18 */ uint16_t RESERVED2; /*!< Reserved, 0x1A */ } SPDIFRX_TypeDef; /** * @brief TIM */ typedef struct { __IO uint32_t CR1; /*!< TIM control register 1, Address offset: 0x00 */ __IO uint32_t CR2; /*!< TIM control register 2, Address offset: 0x04 */ __IO uint32_t SMCR; /*!< TIM slave mode control register, Address offset: 0x08 */ __IO uint32_t DIER; /*!< TIM DMA/interrupt enable register, Address offset: 0x0C */ __IO uint32_t SR; /*!< TIM status register, Address offset: 0x10 */ __IO uint32_t EGR; /*!< TIM event generation register, Address offset: 0x14 */ __IO uint32_t CCMR1; /*!< TIM capture/compare mode register 1, Address offset: 0x18 */ __IO uint32_t CCMR2; /*!< TIM capture/compare mode register 2, Address offset: 0x1C */ __IO uint32_t CCER; /*!< TIM capture/compare enable register, Address offset: 0x20 */ __IO uint32_t CNT; /*!< TIM counter register, Address offset: 0x24 */ __IO uint32_t PSC; /*!< TIM prescaler, Address offset: 0x28 */ __IO uint32_t ARR; /*!< TIM auto-reload register, Address offset: 0x2C */ __IO uint32_t RCR; /*!< TIM repetition counter register, Address offset: 0x30 */ __IO uint32_t CCR1; /*!< TIM capture/compare register 1, Address offset: 0x34 */ __IO uint32_t CCR2; /*!< TIM capture/compare register 2, Address offset: 0x38 */ __IO uint32_t CCR3; /*!< TIM capture/compare register 3, Address offset: 0x3C */ __IO uint32_t CCR4; /*!< TIM capture/compare register 4, Address offset: 0x40 */ __IO uint32_t BDTR; /*!< TIM break and dead-time register, Address offset: 0x44 */ __IO uint32_t DCR; /*!< TIM DMA control register, Address offset: 0x48 */ __IO uint32_t DMAR; /*!< TIM DMA address for full transfer, Address offset: 0x4C */ __IO uint32_t OR; /*!< TIM option register, Address offset: 0x50 */ } TIM_TypeDef; /** * @brief Universal Synchronous Asynchronous Receiver Transmitter */ typedef struct { __IO uint32_t SR; /*!< USART Status register, Address offset: 0x00 */ __IO uint32_t DR; /*!< USART Data register, Address offset: 0x04 */ __IO uint32_t BRR; /*!< USART Baud rate register, Address offset: 0x08 */ __IO uint32_t CR1; /*!< USART Control register 1, Address offset: 0x0C */ __IO uint32_t CR2; /*!< USART Control register 2, Address offset: 0x10 */ __IO uint32_t CR3; /*!< USART Control register 3, Address offset: 0x14 */ __IO uint32_t GTPR; /*!< USART Guard time and prescaler register, Address offset: 0x18 */ } USART_TypeDef; /** * @brief Window WATCHDOG */ typedef struct { __IO uint32_t CR; /*!< WWDG Control register, Address offset: 0x00 */ __IO uint32_t CFR; /*!< WWDG Configuration register, Address offset: 0x04 */ __IO uint32_t SR; /*!< WWDG Status register, Address offset: 0x08 */ } WWDG_TypeDef; /** * @brief USB_OTG_Core_Registers */ typedef struct { __IO uint32_t GOTGCTL; /*!< USB_OTG Control and Status Register 000h */ __IO uint32_t GOTGINT; /*!< USB_OTG Interrupt Register 004h */ __IO uint32_t GAHBCFG; /*!< Core AHB Configuration Register 008h */ __IO uint32_t GUSBCFG; /*!< Core USB Configuration Register 00Ch */ __IO uint32_t GRSTCTL; /*!< Core Reset Register 010h */ __IO uint32_t GINTSTS; /*!< Core Interrupt Register 014h */ __IO uint32_t GINTMSK; /*!< Core Interrupt Mask Register 018h */ __IO uint32_t GRXSTSR; /*!< Receive Sts Q Read Register 01Ch */ __IO uint32_t GRXSTSP; /*!< Receive Sts Q Read & POP Register 020h */ __IO uint32_t GRXFSIZ; /*!< Receive FIFO Size Register 024h */ __IO uint32_t DIEPTXF0_HNPTXFSIZ; /*!< EP0 / Non Periodic Tx FIFO Size Register 028h */ __IO uint32_t HNPTXSTS; /*!< Non Periodic Tx FIFO/Queue Sts reg 02Ch */ uint32_t Reserved30[2]; /*!< Reserved 030h */ __IO uint32_t GCCFG; /*!< General Purpose IO Register 038h */ __IO uint32_t CID; /*!< User ID Register 03Ch */ uint32_t Reserved5[3]; /*!< Reserved 040h-048h */ __IO uint32_t GHWCFG3; /*!< User HW config3 04Ch */ uint32_t Reserved6; /*!< Reserved 050h */ __IO uint32_t GLPMCFG; /*!< LPM Register 054h */ uint32_t Reserved; /*!< Reserved 058h */ __IO uint32_t GDFIFOCFG; /*!< DFIFO Software Config Register 05Ch */ uint32_t Reserved43[40]; /*!< Reserved 058h-0FFh */ __IO uint32_t HPTXFSIZ; /*!< Host Periodic Tx FIFO Size Reg 100h */ __IO uint32_t DIEPTXF[0x0F]; /*!< dev Periodic Transmit FIFO */ } USB_OTG_GlobalTypeDef; /** * @brief USB_OTG_device_Registers */ typedef struct { __IO uint32_t DCFG; /*!< dev Configuration Register 800h */ __IO uint32_t DCTL; /*!< dev Control Register 804h */ __IO uint32_t DSTS; /*!< dev Status Register (RO) 808h */ uint32_t Reserved0C; /*!< Reserved 80Ch */ __IO uint32_t DIEPMSK; /*!< dev IN Endpoint Mask 810h */ __IO uint32_t DOEPMSK; /*!< dev OUT Endpoint Mask 814h */ __IO uint32_t DAINT; /*!< dev All Endpoints Itr Reg 818h */ __IO uint32_t DAINTMSK; /*!< dev All Endpoints Itr Mask 81Ch */ uint32_t Reserved20; /*!< Reserved 820h */ uint32_t Reserved9; /*!< Reserved 824h */ __IO uint32_t DVBUSDIS; /*!< dev VBUS discharge Register 828h */ __IO uint32_t DVBUSPULSE; /*!< dev VBUS Pulse Register 82Ch */ __IO uint32_t DTHRCTL; /*!< dev threshold 830h */ __IO uint32_t DIEPEMPMSK; /*!< dev empty msk 834h */ __IO uint32_t DEACHINT; /*!< dedicated EP interrupt 838h */ __IO uint32_t DEACHMSK; /*!< dedicated EP msk 83Ch */ uint32_t Reserved40; /*!< dedicated EP mask 840h */ __IO uint32_t DINEP1MSK; /*!< dedicated EP mask 844h */ uint32_t Reserved44[15]; /*!< Reserved 844-87Ch */ __IO uint32_t DOUTEP1MSK; /*!< dedicated EP msk 884h */ } USB_OTG_DeviceTypeDef; /** * @brief USB_OTG_IN_Endpoint-Specific_Register */ typedef struct { __IO uint32_t DIEPCTL; /*!< dev IN Endpoint Control Reg 900h + (ep_num * 20h) + 00h */ uint32_t Reserved04; /*!< Reserved 900h + (ep_num * 20h) + 04h */ __IO uint32_t DIEPINT; /*!< dev IN Endpoint Itr Reg 900h + (ep_num * 20h) + 08h */ uint32_t Reserved0C; /*!< Reserved 900h + (ep_num * 20h) + 0Ch */ __IO uint32_t DIEPTSIZ; /*!< IN Endpoint Txfer Size 900h + (ep_num * 20h) + 10h */ __IO uint32_t DIEPDMA; /*!< IN Endpoint DMA Address Reg 900h + (ep_num * 20h) + 14h */ __IO uint32_t DTXFSTS; /*!< IN Endpoint Tx FIFO Status Reg 900h + (ep_num * 20h) + 18h */ uint32_t Reserved18; /*!< Reserved 900h+(ep_num*20h)+1Ch-900h+ (ep_num * 20h) + 1Ch */ } USB_OTG_INEndpointTypeDef; /** * @brief USB_OTG_OUT_Endpoint-Specific_Registers */ typedef struct { __IO uint32_t DOEPCTL; /*!< dev OUT Endpoint Control Reg B00h + (ep_num * 20h) + 00h */ uint32_t Reserved04; /*!< Reserved B00h + (ep_num * 20h) + 04h */ __IO uint32_t DOEPINT; /*!< dev OUT Endpoint Itr Reg B00h + (ep_num * 20h) + 08h */ uint32_t Reserved0C; /*!< Reserved B00h + (ep_num * 20h) + 0Ch */ __IO uint32_t DOEPTSIZ; /*!< dev OUT Endpoint Txfer Size B00h + (ep_num * 20h) + 10h */ __IO uint32_t DOEPDMA; /*!< dev OUT Endpoint DMA Address B00h + (ep_num * 20h) + 14h */ uint32_t Reserved18[2]; /*!< Reserved B00h + (ep_num * 20h) + 18h - B00h + (ep_num * 20h) + 1Ch */ } USB_OTG_OUTEndpointTypeDef; /** * @brief USB_OTG_Host_Mode_Register_Structures */ typedef struct { __IO uint32_t HCFG; /*!< Host Configuration Register 400h */ __IO uint32_t HFIR; /*!< Host Frame Interval Register 404h */ __IO uint32_t HFNUM; /*!< Host Frame Nbr/Frame Remaining 408h */ uint32_t Reserved40C; /*!< Reserved 40Ch */ __IO uint32_t HPTXSTS; /*!< Host Periodic Tx FIFO/ Queue Status 410h */ __IO uint32_t HAINT; /*!< Host All Channels Interrupt Register 414h */ __IO uint32_t HAINTMSK; /*!< Host All Channels Interrupt Mask 418h */ } USB_OTG_HostTypeDef; /** * @brief USB_OTG_Host_Channel_Specific_Registers */ typedef struct { __IO uint32_t HCCHAR; /*!< Host Channel Characteristics Register 500h */ __IO uint32_t HCSPLT; /*!< Host Channel Split Control Register 504h */ __IO uint32_t HCINT; /*!< Host Channel Interrupt Register 508h */ __IO uint32_t HCINTMSK; /*!< Host Channel Interrupt Mask Register 50Ch */ __IO uint32_t HCTSIZ; /*!< Host Channel Transfer Size Register 510h */ __IO uint32_t HCDMA; /*!< Host Channel DMA Address Register 514h */ uint32_t Reserved[2]; /*!< Reserved */ } USB_OTG_HostChannelTypeDef; /** * @} */ /** @addtogroup Peripheral_memory_map * @{ */ #define FLASH_BASE 0x08000000UL /*!< FLASH(up to 1 MB) base address in the alias region */ #define SRAM1_BASE 0x20000000UL /*!< SRAM1(112 KB) base address in the alias region */ #define SRAM2_BASE 0x2001C000UL /*!< SRAM2(16 KB) base address in the alias region */ #define PERIPH_BASE 0x40000000UL /*!< Peripheral base address in the alias region */ #define BKPSRAM_BASE 0x40024000UL /*!< Backup SRAM(4 KB) base address in the alias region */ #define FMC_R_BASE 0xA0000000UL /*!< FMC registers base address */ #define QSPI_R_BASE 0xA0001000UL /*!< QuadSPI registers base address */ #define SRAM1_BB_BASE 0x22000000UL /*!< SRAM1(112 KB) base address in the bit-band region */ #define SRAM2_BB_BASE 0x22380000UL /*!< SRAM2(16 KB) base address in the bit-band region */ #define PERIPH_BB_BASE 0x42000000UL /*!< Peripheral base address in the bit-band region */ #define BKPSRAM_BB_BASE 0x42480000UL /*!< Backup SRAM(4 KB) base address in the bit-band region */ #define FLASH_END 0x0807FFFFUL /*!< FLASH end address */ #define FLASH_OTP_BASE 0x1FFF7800UL /*!< Base address of : (up to 528 Bytes) embedded FLASH OTP Area */ #define FLASH_OTP_END 0x1FFF7A0FUL /*!< End address of : (up to 528 Bytes) embedded FLASH OTP Area */ /* Legacy defines */ #define SRAM_BASE SRAM1_BASE #define SRAM_BB_BASE SRAM1_BB_BASE /*!< Peripheral memory map */ #define APB1PERIPH_BASE PERIPH_BASE #define APB2PERIPH_BASE (PERIPH_BASE + 0x00010000UL) #define AHB1PERIPH_BASE (PERIPH_BASE + 0x00020000UL) #define AHB2PERIPH_BASE (PERIPH_BASE + 0x10000000UL) /*!< APB1 peripherals */ #define TIM2_BASE (APB1PERIPH_BASE + 0x0000UL) #define TIM3_BASE (APB1PERIPH_BASE + 0x0400UL) #define TIM4_BASE (APB1PERIPH_BASE + 0x0800UL) #define TIM5_BASE (APB1PERIPH_BASE + 0x0C00UL) #define TIM6_BASE (APB1PERIPH_BASE + 0x1000UL) #define TIM7_BASE (APB1PERIPH_BASE + 0x1400UL) #define TIM12_BASE (APB1PERIPH_BASE + 0x1800UL) #define TIM13_BASE (APB1PERIPH_BASE + 0x1C00UL) #define TIM14_BASE (APB1PERIPH_BASE + 0x2000UL) #define RTC_BASE (APB1PERIPH_BASE + 0x2800UL) #define WWDG_BASE (APB1PERIPH_BASE + 0x2C00UL) #define IWDG_BASE (APB1PERIPH_BASE + 0x3000UL) #define SPI2_BASE (APB1PERIPH_BASE + 0x3800UL) #define SPI3_BASE (APB1PERIPH_BASE + 0x3C00UL) #define SPDIFRX_BASE (APB1PERIPH_BASE + 0x4000UL) #define USART2_BASE (APB1PERIPH_BASE + 0x4400UL) #define USART3_BASE (APB1PERIPH_BASE + 0x4800UL) #define UART4_BASE (APB1PERIPH_BASE + 0x4C00UL) #define UART5_BASE (APB1PERIPH_BASE + 0x5000UL) #define I2C1_BASE (APB1PERIPH_BASE + 0x5400UL) #define I2C2_BASE (APB1PERIPH_BASE + 0x5800UL) #define I2C3_BASE (APB1PERIPH_BASE + 0x5C00UL) #define FMPI2C1_BASE (APB1PERIPH_BASE + 0x6000UL) #define CAN1_BASE (APB1PERIPH_BASE + 0x6400UL) #define CAN2_BASE (APB1PERIPH_BASE + 0x6800UL) #define CEC_BASE (APB1PERIPH_BASE + 0x6C00UL) #define PWR_BASE (APB1PERIPH_BASE + 0x7000UL) #define DAC_BASE (APB1PERIPH_BASE + 0x7400UL) /*!< APB2 peripherals */ #define TIM1_BASE (APB2PERIPH_BASE + 0x0000UL) #define TIM8_BASE (APB2PERIPH_BASE + 0x0400UL) #define USART1_BASE (APB2PERIPH_BASE + 0x1000UL) #define USART6_BASE (APB2PERIPH_BASE + 0x1400UL) #define ADC1_BASE (APB2PERIPH_BASE + 0x2000UL) #define ADC2_BASE (APB2PERIPH_BASE + 0x2100UL) #define ADC3_BASE (APB2PERIPH_BASE + 0x2200UL) #define ADC123_COMMON_BASE (APB2PERIPH_BASE + 0x2300UL) /* Legacy define */ #define ADC_BASE ADC123_COMMON_BASE #define SDIO_BASE (APB2PERIPH_BASE + 0x2C00UL) #define SPI1_BASE (APB2PERIPH_BASE + 0x3000UL) #define SPI4_BASE (APB2PERIPH_BASE + 0x3400UL) #define SYSCFG_BASE (APB2PERIPH_BASE + 0x3800UL) #define EXTI_BASE (APB2PERIPH_BASE + 0x3C00UL) #define TIM9_BASE (APB2PERIPH_BASE + 0x4000UL) #define TIM10_BASE (APB2PERIPH_BASE + 0x4400UL) #define TIM11_BASE (APB2PERIPH_BASE + 0x4800UL) #define SAI1_BASE (APB2PERIPH_BASE + 0x5800UL) #define SAI1_Block_A_BASE (SAI1_BASE + 0x004UL) #define SAI1_Block_B_BASE (SAI1_BASE + 0x024UL) #define SAI2_BASE (APB2PERIPH_BASE + 0x5C00UL) #define SAI2_Block_A_BASE (SAI2_BASE + 0x004UL) #define SAI2_Block_B_BASE (SAI2_BASE + 0x024UL) /*!< AHB1 peripherals */ #define GPIOA_BASE (AHB1PERIPH_BASE + 0x0000UL) #define GPIOB_BASE (AHB1PERIPH_BASE + 0x0400UL) #define GPIOC_BASE (AHB1PERIPH_BASE + 0x0800UL) #define GPIOD_BASE (AHB1PERIPH_BASE + 0x0C00UL) #define GPIOE_BASE (AHB1PERIPH_BASE + 0x1000UL) #define GPIOF_BASE (AHB1PERIPH_BASE + 0x1400UL) #define GPIOG_BASE (AHB1PERIPH_BASE + 0x1800UL) #define GPIOH_BASE (AHB1PERIPH_BASE + 0x1C00UL) #define CRC_BASE (AHB1PERIPH_BASE + 0x3000UL) #define RCC_BASE (AHB1PERIPH_BASE + 0x3800UL) #define FLASH_R_BASE (AHB1PERIPH_BASE + 0x3C00UL) #define DMA1_BASE (AHB1PERIPH_BASE + 0x6000UL) #define DMA1_Stream0_BASE (DMA1_BASE + 0x010UL) #define DMA1_Stream1_BASE (DMA1_BASE + 0x028UL) #define DMA1_Stream2_BASE (DMA1_BASE + 0x040UL) #define DMA1_Stream3_BASE (DMA1_BASE + 0x058UL) #define DMA1_Stream4_BASE (DMA1_BASE + 0x070UL) #define DMA1_Stream5_BASE (DMA1_BASE + 0x088UL) #define DMA1_Stream6_BASE (DMA1_BASE + 0x0A0UL) #define DMA1_Stream7_BASE (DMA1_BASE + 0x0B8UL) #define DMA2_BASE (AHB1PERIPH_BASE + 0x6400UL) #define DMA2_Stream0_BASE (DMA2_BASE + 0x010UL) #define DMA2_Stream1_BASE (DMA2_BASE + 0x028UL) #define DMA2_Stream2_BASE (DMA2_BASE + 0x040UL) #define DMA2_Stream3_BASE (DMA2_BASE + 0x058UL) #define DMA2_Stream4_BASE (DMA2_BASE + 0x070UL) #define DMA2_Stream5_BASE (DMA2_BASE + 0x088UL) #define DMA2_Stream6_BASE (DMA2_BASE + 0x0A0UL) #define DMA2_Stream7_BASE (DMA2_BASE + 0x0B8UL) /*!< AHB2 peripherals */ #define DCMI_BASE (AHB2PERIPH_BASE + 0x50000UL) /*!< FMC Bankx registers base address */ #define FMC_Bank1_R_BASE (FMC_R_BASE + 0x0000UL) #define FMC_Bank1E_R_BASE (FMC_R_BASE + 0x0104UL) #define FMC_Bank3_R_BASE (FMC_R_BASE + 0x0080UL) #define FMC_Bank5_6_R_BASE (FMC_R_BASE + 0x0140UL) /*!< Debug MCU registers base address */ #define DBGMCU_BASE 0xE0042000UL /*!< USB registers base address */ #define USB_OTG_HS_PERIPH_BASE 0x40040000UL #define USB_OTG_FS_PERIPH_BASE 0x50000000UL #define USB_OTG_GLOBAL_BASE 0x000UL #define USB_OTG_DEVICE_BASE 0x800UL #define USB_OTG_IN_ENDPOINT_BASE 0x900UL #define USB_OTG_OUT_ENDPOINT_BASE 0xB00UL #define USB_OTG_EP_REG_SIZE 0x20UL #define USB_OTG_HOST_BASE 0x400UL #define USB_OTG_HOST_PORT_BASE 0x440UL #define USB_OTG_HOST_CHANNEL_BASE 0x500UL #define USB_OTG_HOST_CHANNEL_SIZE 0x20UL #define USB_OTG_PCGCCTL_BASE 0xE00UL #define USB_OTG_FIFO_BASE 0x1000UL #define USB_OTG_FIFO_SIZE 0x1000UL #define UID_BASE 0x1FFF7A10UL /*!< Unique device ID register base address */ #define FLASHSIZE_BASE 0x1FFF7A22UL /*!< FLASH Size register base address */ #define PACKAGE_BASE 0x1FFF7BF0UL /*!< Package size register base address */ /** * @} */ /** @addtogroup Peripheral_declaration * @{ */ #define TIM2 ((TIM_TypeDef *) TIM2_BASE) #define TIM3 ((TIM_TypeDef *) TIM3_BASE) #define TIM4 ((TIM_TypeDef *) TIM4_BASE) #define TIM5 ((TIM_TypeDef *) TIM5_BASE) #define TIM6 ((TIM_TypeDef *) TIM6_BASE) #define TIM7 ((TIM_TypeDef *) TIM7_BASE) #define TIM12 ((TIM_TypeDef *) TIM12_BASE) #define TIM13 ((TIM_TypeDef *) TIM13_BASE) #define TIM14 ((TIM_TypeDef *) TIM14_BASE) #define RTC ((RTC_TypeDef *) RTC_BASE) #define WWDG ((WWDG_TypeDef *) WWDG_BASE) #define IWDG ((IWDG_TypeDef *) IWDG_BASE) #define SPI2 ((SPI_TypeDef *) SPI2_BASE) #define SPI3 ((SPI_TypeDef *) SPI3_BASE) #define SPDIFRX ((SPDIFRX_TypeDef *) SPDIFRX_BASE) #define USART2 ((USART_TypeDef *) USART2_BASE) #define USART3 ((USART_TypeDef *) USART3_BASE) #define UART4 ((USART_TypeDef *) UART4_BASE) #define UART5 ((USART_TypeDef *) UART5_BASE) #define I2C1 ((I2C_TypeDef *) I2C1_BASE) #define I2C2 ((I2C_TypeDef *) I2C2_BASE) #define I2C3 ((I2C_TypeDef *) I2C3_BASE) #define FMPI2C1 ((FMPI2C_TypeDef *) FMPI2C1_BASE) #define CAN1 ((CAN_TypeDef *) CAN1_BASE) #define CAN2 ((CAN_TypeDef *) CAN2_BASE) #define CEC ((CEC_TypeDef *) CEC_BASE) #define PWR ((PWR_TypeDef *) PWR_BASE) #define DAC1 ((DAC_TypeDef *) DAC_BASE) #define DAC ((DAC_TypeDef *) DAC_BASE) /* Kept for legacy purpose */ #define TIM1 ((TIM_TypeDef *) TIM1_BASE) #define TIM8 ((TIM_TypeDef *) TIM8_BASE) #define USART1 ((USART_TypeDef *) USART1_BASE) #define USART6 ((USART_TypeDef *) USART6_BASE) #define ADC1 ((ADC_TypeDef *) ADC1_BASE) #define ADC2 ((ADC_TypeDef *) ADC2_BASE) #define ADC3 ((ADC_TypeDef *) ADC3_BASE) #define ADC123_COMMON ((ADC_Common_TypeDef *) ADC123_COMMON_BASE) /* Legacy define */ #define ADC ADC123_COMMON #define SDIO ((SDIO_TypeDef *) SDIO_BASE) #define SPI1 ((SPI_TypeDef *) SPI1_BASE) #define SPI4 ((SPI_TypeDef *) SPI4_BASE) #define SYSCFG ((SYSCFG_TypeDef *) SYSCFG_BASE) #define EXTI ((EXTI_TypeDef *) EXTI_BASE) #define TIM9 ((TIM_TypeDef *) TIM9_BASE) #define TIM10 ((TIM_TypeDef *) TIM10_BASE) #define TIM11 ((TIM_TypeDef *) TIM11_BASE) #define SAI1 ((SAI_TypeDef *) SAI1_BASE) #define SAI1_Block_A ((SAI_Block_TypeDef *)SAI1_Block_A_BASE) #define SAI1_Block_B ((SAI_Block_TypeDef *)SAI1_Block_B_BASE) #define SAI2 ((SAI_TypeDef *) SAI2_BASE) #define SAI2_Block_A ((SAI_Block_TypeDef *)SAI2_Block_A_BASE) #define SAI2_Block_B ((SAI_Block_TypeDef *)SAI2_Block_B_BASE) #define GPIOA ((GPIO_TypeDef *) GPIOA_BASE) #define GPIOB ((GPIO_TypeDef *) GPIOB_BASE) #define GPIOC ((GPIO_TypeDef *) GPIOC_BASE) #define GPIOD ((GPIO_TypeDef *) GPIOD_BASE) #define GPIOE ((GPIO_TypeDef *) GPIOE_BASE) #define GPIOF ((GPIO_TypeDef *) GPIOF_BASE) #define GPIOG ((GPIO_TypeDef *) GPIOG_BASE) #define GPIOH ((GPIO_TypeDef *) GPIOH_BASE) #define CRC ((CRC_TypeDef *) CRC_BASE) #define RCC ((RCC_TypeDef *) RCC_BASE) #define FLASH ((FLASH_TypeDef *) FLASH_R_BASE) #define DMA1 ((DMA_TypeDef *) DMA1_BASE) #define DMA1_Stream0 ((DMA_Stream_TypeDef *) DMA1_Stream0_BASE) #define DMA1_Stream1 ((DMA_Stream_TypeDef *) DMA1_Stream1_BASE) #define DMA1_Stream2 ((DMA_Stream_TypeDef *) DMA1_Stream2_BASE) #define DMA1_Stream3 ((DMA_Stream_TypeDef *) DMA1_Stream3_BASE) #define DMA1_Stream4 ((DMA_Stream_TypeDef *) DMA1_Stream4_BASE) #define DMA1_Stream5 ((DMA_Stream_TypeDef *) DMA1_Stream5_BASE) #define DMA1_Stream6 ((DMA_Stream_TypeDef *) DMA1_Stream6_BASE) #define DMA1_Stream7 ((DMA_Stream_TypeDef *) DMA1_Stream7_BASE) #define DMA2 ((DMA_TypeDef *) DMA2_BASE) #define DMA2_Stream0 ((DMA_Stream_TypeDef *) DMA2_Stream0_BASE) #define DMA2_Stream1 ((DMA_Stream_TypeDef *) DMA2_Stream1_BASE) #define DMA2_Stream2 ((DMA_Stream_TypeDef *) DMA2_Stream2_BASE) #define DMA2_Stream3 ((DMA_Stream_TypeDef *) DMA2_Stream3_BASE) #define DMA2_Stream4 ((DMA_Stream_TypeDef *) DMA2_Stream4_BASE) #define DMA2_Stream5 ((DMA_Stream_TypeDef *) DMA2_Stream5_BASE) #define DMA2_Stream6 ((DMA_Stream_TypeDef *) DMA2_Stream6_BASE) #define DMA2_Stream7 ((DMA_Stream_TypeDef *) DMA2_Stream7_BASE) #define DCMI ((DCMI_TypeDef *) DCMI_BASE) #define FMC_Bank1 ((FMC_Bank1_TypeDef *) FMC_Bank1_R_BASE) #define FMC_Bank1E ((FMC_Bank1E_TypeDef *) FMC_Bank1E_R_BASE) #define FMC_Bank3 ((FMC_Bank3_TypeDef *) FMC_Bank3_R_BASE) #define FMC_Bank5_6 ((FMC_Bank5_6_TypeDef *) FMC_Bank5_6_R_BASE) #define QUADSPI ((QUADSPI_TypeDef *) QSPI_R_BASE) #define DBGMCU ((DBGMCU_TypeDef *) DBGMCU_BASE) #define USB_OTG_FS ((USB_OTG_GlobalTypeDef *) USB_OTG_FS_PERIPH_BASE) #define USB_OTG_HS ((USB_OTG_GlobalTypeDef *) USB_OTG_HS_PERIPH_BASE) /** * @} */ /** @addtogroup Exported_constants * @{ */ /** @addtogroup Peripheral_Registers_Bits_Definition * @{ */ /******************************************************************************/ /* Peripheral Registers_Bits_Definition */ /******************************************************************************/ /******************************************************************************/ /* */ /* Analog to Digital Converter */ /* */ /******************************************************************************/ /* * @brief Specific device feature definitions (not present on all devices in the STM32F4 serie) */ #define ADC_MULTIMODE_SUPPORT /*!
© COPYRIGHT(c) 2017 STMicroelectronics
* * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. Neither the name of STMicroelectronics nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ /** @addtogroup CMSIS_Device * @{ */ /** @addtogroup stm32f469xx * @{ */ #ifndef __STM32F469xx_H #define __STM32F469xx_H #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ /** @addtogroup Configuration_section_for_CMSIS * @{ */ /** * @brief Configuration of the Cortex-M4 Processor and Core Peripherals */ #define __CM4_REV 0x0001U /*!< Core revision r0p1 */ #define __MPU_PRESENT 1U /*!< STM32F4XX provides an MPU */ #define __NVIC_PRIO_BITS 4U /*!< STM32F4XX uses 4 Bits for the Priority Levels */ #define __Vendor_SysTickConfig 0U /*!< Set to 1 if different SysTick Config is used */ #define __FPU_PRESENT 1U /*!< FPU present */ /** * @} */ /** @addtogroup Peripheral_interrupt_number_definition * @{ */ /** * @brief STM32F4XX Interrupt Number Definition, according to the selected device * in @ref Library_configuration_section */ typedef enum { /****** Cortex-M4 Processor Exceptions Numbers ****************************************************************/ NonMaskableInt_IRQn = -14, /*!< 2 Non Maskable Interrupt */ MemoryManagement_IRQn = -12, /*!< 4 Cortex-M4 Memory Management Interrupt */ BusFault_IRQn = -11, /*!< 5 Cortex-M4 Bus Fault Interrupt */ UsageFault_IRQn = -10, /*!< 6 Cortex-M4 Usage Fault Interrupt */ SVCall_IRQn = -5, /*!< 11 Cortex-M4 SV Call Interrupt */ DebugMonitor_IRQn = -4, /*!< 12 Cortex-M4 Debug Monitor Interrupt */ PendSV_IRQn = -2, /*!< 14 Cortex-M4 Pend SV Interrupt */ SysTick_IRQn = -1, /*!< 15 Cortex-M4 System Tick Interrupt */ /****** STM32 specific Interrupt Numbers **********************************************************************/ WWDG_IRQn = 0, /*!< Window WatchDog Interrupt */ PVD_IRQn = 1, /*!< PVD through EXTI Line detection Interrupt */ TAMP_STAMP_IRQn = 2, /*!< Tamper and TimeStamp interrupts through the EXTI line */ RTC_WKUP_IRQn = 3, /*!< RTC Wakeup interrupt through the EXTI line */ FLASH_IRQn = 4, /*!< FLASH global Interrupt */ RCC_IRQn = 5, /*!< RCC global Interrupt */ EXTI0_IRQn = 6, /*!< EXTI Line0 Interrupt */ EXTI1_IRQn = 7, /*!< EXTI Line1 Interrupt */ EXTI2_IRQn = 8, /*!< EXTI Line2 Interrupt */ EXTI3_IRQn = 9, /*!< EXTI Line3 Interrupt */ EXTI4_IRQn = 10, /*!< EXTI Line4 Interrupt */ DMA1_Stream0_IRQn = 11, /*!< DMA1 Stream 0 global Interrupt */ DMA1_Stream1_IRQn = 12, /*!< DMA1 Stream 1 global Interrupt */ DMA1_Stream2_IRQn = 13, /*!< DMA1 Stream 2 global Interrupt */ DMA1_Stream3_IRQn = 14, /*!< DMA1 Stream 3 global Interrupt */ DMA1_Stream4_IRQn = 15, /*!< DMA1 Stream 4 global Interrupt */ DMA1_Stream5_IRQn = 16, /*!< DMA1 Stream 5 global Interrupt */ DMA1_Stream6_IRQn = 17, /*!< DMA1 Stream 6 global Interrupt */ ADC_IRQn = 18, /*!< ADC1, ADC2 and ADC3 global Interrupts */ CAN1_TX_IRQn = 19, /*!< CAN1 TX Interrupt */ CAN1_RX0_IRQn = 20, /*!< CAN1 RX0 Interrupt */ CAN1_RX1_IRQn = 21, /*!< CAN1 RX1 Interrupt */ CAN1_SCE_IRQn = 22, /*!< CAN1 SCE Interrupt */ EXTI9_5_IRQn = 23, /*!< External Line[9:5] Interrupts */ TIM1_BRK_TIM9_IRQn = 24, /*!< TIM1 Break interrupt and TIM9 global interrupt */ TIM1_UP_TIM10_IRQn = 25, /*!< TIM1 Update Interrupt and TIM10 global interrupt */ TIM1_TRG_COM_TIM11_IRQn = 26, /*!< TIM1 Trigger and Commutation Interrupt and TIM11 global interrupt */ TIM1_CC_IRQn = 27, /*!< TIM1 Capture Compare Interrupt */ TIM2_IRQn = 28, /*!< TIM2 global Interrupt */ TIM3_IRQn = 29, /*!< TIM3 global Interrupt */ TIM4_IRQn = 30, /*!< TIM4 global Interrupt */ I2C1_EV_IRQn = 31, /*!< I2C1 Event Interrupt */ I2C1_ER_IRQn = 32, /*!< I2C1 Error Interrupt */ I2C2_EV_IRQn = 33, /*!< I2C2 Event Interrupt */ I2C2_ER_IRQn = 34, /*!< I2C2 Error Interrupt */ SPI1_IRQn = 35, /*!< SPI1 global Interrupt */ SPI2_IRQn = 36, /*!< SPI2 global Interrupt */ USART1_IRQn = 37, /*!< USART1 global Interrupt */ USART2_IRQn = 38, /*!< USART2 global Interrupt */ USART3_IRQn = 39, /*!< USART3 global Interrupt */ EXTI15_10_IRQn = 40, /*!< External Line[15:10] Interrupts */ RTC_Alarm_IRQn = 41, /*!< RTC Alarm (A and B) through EXTI Line Interrupt */ OTG_FS_WKUP_IRQn = 42, /*!< USB OTG FS Wakeup through EXTI line interrupt */ TIM8_BRK_TIM12_IRQn = 43, /*!< TIM8 Break Interrupt and TIM12 global interrupt */ TIM8_UP_TIM13_IRQn = 44, /*!< TIM8 Update Interrupt and TIM13 global interrupt */ TIM8_TRG_COM_TIM14_IRQn = 45, /*!< TIM8 Trigger and Commutation Interrupt and TIM14 global interrupt */ TIM8_CC_IRQn = 46, /*!< TIM8 Capture Compare global interrupt */ DMA1_Stream7_IRQn = 47, /*!< DMA1 Stream7 Interrupt */ FMC_IRQn = 48, /*!< FMC global Interrupt */ SDIO_IRQn = 49, /*!< SDIO global Interrupt */ TIM5_IRQn = 50, /*!< TIM5 global Interrupt */ SPI3_IRQn = 51, /*!< SPI3 global Interrupt */ UART4_IRQn = 52, /*!< UART4 global Interrupt */ UART5_IRQn = 53, /*!< UART5 global Interrupt */ TIM6_DAC_IRQn = 54, /*!< TIM6 global and DAC1&2 underrun error interrupts */ TIM7_IRQn = 55, /*!< TIM7 global interrupt */ DMA2_Stream0_IRQn = 56, /*!< DMA2 Stream 0 global Interrupt */ DMA2_Stream1_IRQn = 57, /*!< DMA2 Stream 1 global Interrupt */ DMA2_Stream2_IRQn = 58, /*!< DMA2 Stream 2 global Interrupt */ DMA2_Stream3_IRQn = 59, /*!< DMA2 Stream 3 global Interrupt */ DMA2_Stream4_IRQn = 60, /*!< DMA2 Stream 4 global Interrupt */ ETH_IRQn = 61, /*!< Ethernet global Interrupt */ ETH_WKUP_IRQn = 62, /*!< Ethernet Wakeup through EXTI line Interrupt */ CAN2_TX_IRQn = 63, /*!< CAN2 TX Interrupt */ CAN2_RX0_IRQn = 64, /*!< CAN2 RX0 Interrupt */ CAN2_RX1_IRQn = 65, /*!< CAN2 RX1 Interrupt */ CAN2_SCE_IRQn = 66, /*!< CAN2 SCE Interrupt */ OTG_FS_IRQn = 67, /*!< USB OTG FS global Interrupt */ DMA2_Stream5_IRQn = 68, /*!< DMA2 Stream 5 global interrupt */ DMA2_Stream6_IRQn = 69, /*!< DMA2 Stream 6 global interrupt */ DMA2_Stream7_IRQn = 70, /*!< DMA2 Stream 7 global interrupt */ USART6_IRQn = 71, /*!< USART6 global interrupt */ I2C3_EV_IRQn = 72, /*!< I2C3 event interrupt */ I2C3_ER_IRQn = 73, /*!< I2C3 error interrupt */ OTG_HS_EP1_OUT_IRQn = 74, /*!< USB OTG HS End Point 1 Out global interrupt */ OTG_HS_EP1_IN_IRQn = 75, /*!< USB OTG HS End Point 1 In global interrupt */ OTG_HS_WKUP_IRQn = 76, /*!< USB OTG HS Wakeup through EXTI interrupt */ OTG_HS_IRQn = 77, /*!< USB OTG HS global interrupt */ DCMI_IRQn = 78, /*!< DCMI global interrupt */ HASH_RNG_IRQn = 80, /*!< Hash and Rng global interrupt */ FPU_IRQn = 81, /*!< FPU global interrupt */ UART7_IRQn = 82, /*!< UART7 global interrupt */ UART8_IRQn = 83, /*!< UART8 global interrupt */ SPI4_IRQn = 84, /*!< SPI4 global Interrupt */ SPI5_IRQn = 85, /*!< SPI5 global Interrupt */ SPI6_IRQn = 86, /*!< SPI6 global Interrupt */ SAI1_IRQn = 87, /*!< SAI1 global Interrupt */ LTDC_IRQn = 88, /*!< LTDC global Interrupt */ LTDC_ER_IRQn = 89, /*!< LTDC Error global Interrupt */ DMA2D_IRQn = 90, /*!< DMA2D global Interrupt */ QUADSPI_IRQn = 91, /*!< QUADSPI global Interrupt */ DSI_IRQn = 92 /*!< DSI global Interrupt */ } IRQn_Type; /** * @} */ #include "core_cm4.h" /* Cortex-M4 processor and core peripherals */ #include "system_stm32f4xx.h" #include /** @addtogroup Peripheral_registers_structures * @{ */ /** * @brief Analog to Digital Converter */ typedef struct { __IO uint32_t SR; /*!< ADC status register, Address offset: 0x00 */ __IO uint32_t CR1; /*!< ADC control register 1, Address offset: 0x04 */ __IO uint32_t CR2; /*!< ADC control register 2, Address offset: 0x08 */ __IO uint32_t SMPR1; /*!< ADC sample time register 1, Address offset: 0x0C */ __IO uint32_t SMPR2; /*!< ADC sample time register 2, Address offset: 0x10 */ __IO uint32_t JOFR1; /*!< ADC injected channel data offset register 1, Address offset: 0x14 */ __IO uint32_t JOFR2; /*!< ADC injected channel data offset register 2, Address offset: 0x18 */ __IO uint32_t JOFR3; /*!< ADC injected channel data offset register 3, Address offset: 0x1C */ __IO uint32_t JOFR4; /*!< ADC injected channel data offset register 4, Address offset: 0x20 */ __IO uint32_t HTR; /*!< ADC watchdog higher threshold register, Address offset: 0x24 */ __IO uint32_t LTR; /*!< ADC watchdog lower threshold register, Address offset: 0x28 */ __IO uint32_t SQR1; /*!< ADC regular sequence register 1, Address offset: 0x2C */ __IO uint32_t SQR2; /*!< ADC regular sequence register 2, Address offset: 0x30 */ __IO uint32_t SQR3; /*!< ADC regular sequence register 3, Address offset: 0x34 */ __IO uint32_t JSQR; /*!< ADC injected sequence register, Address offset: 0x38*/ __IO uint32_t JDR1; /*!< ADC injected data register 1, Address offset: 0x3C */ __IO uint32_t JDR2; /*!< ADC injected data register 2, Address offset: 0x40 */ __IO uint32_t JDR3; /*!< ADC injected data register 3, Address offset: 0x44 */ __IO uint32_t JDR4; /*!< ADC injected data register 4, Address offset: 0x48 */ __IO uint32_t DR; /*!< ADC regular data register, Address offset: 0x4C */ } ADC_TypeDef; typedef struct { __IO uint32_t CSR; /*!< ADC Common status register, Address offset: ADC1 base address + 0x300 */ __IO uint32_t CCR; /*!< ADC common control register, Address offset: ADC1 base address + 0x304 */ __IO uint32_t CDR; /*!< ADC common regular data register for dual AND triple modes, Address offset: ADC1 base address + 0x308 */ } ADC_Common_TypeDef; /** * @brief Controller Area Network TxMailBox */ typedef struct { __IO uint32_t TIR; /*!< CAN TX mailbox identifier register */ __IO uint32_t TDTR; /*!< CAN mailbox data length control and time stamp register */ __IO uint32_t TDLR; /*!< CAN mailbox data low register */ __IO uint32_t TDHR; /*!< CAN mailbox data high register */ } CAN_TxMailBox_TypeDef; /** * @brief Controller Area Network FIFOMailBox */ typedef struct { __IO uint32_t RIR; /*!< CAN receive FIFO mailbox identifier register */ __IO uint32_t RDTR; /*!< CAN receive FIFO mailbox data length control and time stamp register */ __IO uint32_t RDLR; /*!< CAN receive FIFO mailbox data low register */ __IO uint32_t RDHR; /*!< CAN receive FIFO mailbox data high register */ } CAN_FIFOMailBox_TypeDef; /** * @brief Controller Area Network FilterRegister */ typedef struct { __IO uint32_t FR1; /*!< CAN Filter bank register 1 */ __IO uint32_t FR2; /*!< CAN Filter bank register 1 */ } CAN_FilterRegister_TypeDef; /** * @brief Controller Area Network */ typedef struct { __IO uint32_t MCR; /*!< CAN master control register, Address offset: 0x00 */ __IO uint32_t MSR; /*!< CAN master status register, Address offset: 0x04 */ __IO uint32_t TSR; /*!< CAN transmit status register, Address offset: 0x08 */ __IO uint32_t RF0R; /*!< CAN receive FIFO 0 register, Address offset: 0x0C */ __IO uint32_t RF1R; /*!< CAN receive FIFO 1 register, Address offset: 0x10 */ __IO uint32_t IER; /*!< CAN interrupt enable register, Address offset: 0x14 */ __IO uint32_t ESR; /*!< CAN error status register, Address offset: 0x18 */ __IO uint32_t BTR; /*!< CAN bit timing register, Address offset: 0x1C */ uint32_t RESERVED0[88]; /*!< Reserved, 0x020 - 0x17F */ CAN_TxMailBox_TypeDef sTxMailBox[3]; /*!< CAN Tx MailBox, Address offset: 0x180 - 0x1AC */ CAN_FIFOMailBox_TypeDef sFIFOMailBox[2]; /*!< CAN FIFO MailBox, Address offset: 0x1B0 - 0x1CC */ uint32_t RESERVED1[12]; /*!< Reserved, 0x1D0 - 0x1FF */ __IO uint32_t FMR; /*!< CAN filter master register, Address offset: 0x200 */ __IO uint32_t FM1R; /*!< CAN filter mode register, Address offset: 0x204 */ uint32_t RESERVED2; /*!< Reserved, 0x208 */ __IO uint32_t FS1R; /*!< CAN filter scale register, Address offset: 0x20C */ uint32_t RESERVED3; /*!< Reserved, 0x210 */ __IO uint32_t FFA1R; /*!< CAN filter FIFO assignment register, Address offset: 0x214 */ uint32_t RESERVED4; /*!< Reserved, 0x218 */ __IO uint32_t FA1R; /*!< CAN filter activation register, Address offset: 0x21C */ uint32_t RESERVED5[8]; /*!< Reserved, 0x220-0x23F */ CAN_FilterRegister_TypeDef sFilterRegister[28]; /*!< CAN Filter Register, Address offset: 0x240-0x31C */ } CAN_TypeDef; /** * @brief CRC calculation unit */ typedef struct { __IO uint32_t DR; /*!< CRC Data register, Address offset: 0x00 */ __IO uint8_t IDR; /*!< CRC Independent data register, Address offset: 0x04 */ uint8_t RESERVED0; /*!< Reserved, 0x05 */ uint16_t RESERVED1; /*!< Reserved, 0x06 */ __IO uint32_t CR; /*!< CRC Control register, Address offset: 0x08 */ } CRC_TypeDef; /** * @brief Digital to Analog Converter */ typedef struct { __IO uint32_t CR; /*!< DAC control register, Address offset: 0x00 */ __IO uint32_t SWTRIGR; /*!< DAC software trigger register, Address offset: 0x04 */ __IO uint32_t DHR12R1; /*!< DAC channel1 12-bit right-aligned data holding register, Address offset: 0x08 */ __IO uint32_t DHR12L1; /*!< DAC channel1 12-bit left aligned data holding register, Address offset: 0x0C */ __IO uint32_t DHR8R1; /*!< DAC channel1 8-bit right aligned data holding register, Address offset: 0x10 */ __IO uint32_t DHR12R2; /*!< DAC channel2 12-bit right aligned data holding register, Address offset: 0x14 */ __IO uint32_t DHR12L2; /*!< DAC channel2 12-bit left aligned data holding register, Address offset: 0x18 */ __IO uint32_t DHR8R2; /*!< DAC channel2 8-bit right-aligned data holding register, Address offset: 0x1C */ __IO uint32_t DHR12RD; /*!< Dual DAC 12-bit right-aligned data holding register, Address offset: 0x20 */ __IO uint32_t DHR12LD; /*!< DUAL DAC 12-bit left aligned data holding register, Address offset: 0x24 */ __IO uint32_t DHR8RD; /*!< DUAL DAC 8-bit right aligned data holding register, Address offset: 0x28 */ __IO uint32_t DOR1; /*!< DAC channel1 data output register, Address offset: 0x2C */ __IO uint32_t DOR2; /*!< DAC channel2 data output register, Address offset: 0x30 */ __IO uint32_t SR; /*!< DAC status register, Address offset: 0x34 */ } DAC_TypeDef; /** * @brief Debug MCU */ typedef struct { __IO uint32_t IDCODE; /*!< MCU device ID code, Address offset: 0x00 */ __IO uint32_t CR; /*!< Debug MCU configuration register, Address offset: 0x04 */ __IO uint32_t APB1FZ; /*!< Debug MCU APB1 freeze register, Address offset: 0x08 */ __IO uint32_t APB2FZ; /*!< Debug MCU APB2 freeze register, Address offset: 0x0C */ }DBGMCU_TypeDef; /** * @brief DCMI */ typedef struct { __IO uint32_t CR; /*!< DCMI control register 1, Address offset: 0x00 */ __IO uint32_t SR; /*!< DCMI status register, Address offset: 0x04 */ __IO uint32_t RISR; /*!< DCMI raw interrupt status register, Address offset: 0x08 */ __IO uint32_t IER; /*!< DCMI interrupt enable register, Address offset: 0x0C */ __IO uint32_t MISR; /*!< DCMI masked interrupt status register, Address offset: 0x10 */ __IO uint32_t ICR; /*!< DCMI interrupt clear register, Address offset: 0x14 */ __IO uint32_t ESCR; /*!< DCMI embedded synchronization code register, Address offset: 0x18 */ __IO uint32_t ESUR; /*!< DCMI embedded synchronization unmask register, Address offset: 0x1C */ __IO uint32_t CWSTRTR; /*!< DCMI crop window start, Address offset: 0x20 */ __IO uint32_t CWSIZER; /*!< DCMI crop window size, Address offset: 0x24 */ __IO uint32_t DR; /*!< DCMI data register, Address offset: 0x28 */ } DCMI_TypeDef; /** * @brief DMA Controller */ typedef struct { __IO uint32_t CR; /*!< DMA stream x configuration register */ __IO uint32_t NDTR; /*!< DMA stream x number of data register */ __IO uint32_t PAR; /*!< DMA stream x peripheral address register */ __IO uint32_t M0AR; /*!< DMA stream x memory 0 address register */ __IO uint32_t M1AR; /*!< DMA stream x memory 1 address register */ __IO uint32_t FCR; /*!< DMA stream x FIFO control register */ } DMA_Stream_TypeDef; typedef struct { __IO uint32_t LISR; /*!< DMA low interrupt status register, Address offset: 0x00 */ __IO uint32_t HISR; /*!< DMA high interrupt status register, Address offset: 0x04 */ __IO uint32_t LIFCR; /*!< DMA low interrupt flag clear register, Address offset: 0x08 */ __IO uint32_t HIFCR; /*!< DMA high interrupt flag clear register, Address offset: 0x0C */ } DMA_TypeDef; /** * @brief DMA2D Controller */ typedef struct { __IO uint32_t CR; /*!< DMA2D Control Register, Address offset: 0x00 */ __IO uint32_t ISR; /*!< DMA2D Interrupt Status Register, Address offset: 0x04 */ __IO uint32_t IFCR; /*!< DMA2D Interrupt Flag Clear Register, Address offset: 0x08 */ __IO uint32_t FGMAR; /*!< DMA2D Foreground Memory Address Register, Address offset: 0x0C */ __IO uint32_t FGOR; /*!< DMA2D Foreground Offset Register, Address offset: 0x10 */ __IO uint32_t BGMAR; /*!< DMA2D Background Memory Address Register, Address offset: 0x14 */ __IO uint32_t BGOR; /*!< DMA2D Background Offset Register, Address offset: 0x18 */ __IO uint32_t FGPFCCR; /*!< DMA2D Foreground PFC Control Register, Address offset: 0x1C */ __IO uint32_t FGCOLR; /*!< DMA2D Foreground Color Register, Address offset: 0x20 */ __IO uint32_t BGPFCCR; /*!< DMA2D Background PFC Control Register, Address offset: 0x24 */ __IO uint32_t BGCOLR; /*!< DMA2D Background Color Register, Address offset: 0x28 */ __IO uint32_t FGCMAR; /*!< DMA2D Foreground CLUT Memory Address Register, Address offset: 0x2C */ __IO uint32_t BGCMAR; /*!< DMA2D Background CLUT Memory Address Register, Address offset: 0x30 */ __IO uint32_t OPFCCR; /*!< DMA2D Output PFC Control Register, Address offset: 0x34 */ __IO uint32_t OCOLR; /*!< DMA2D Output Color Register, Address offset: 0x38 */ __IO uint32_t OMAR; /*!< DMA2D Output Memory Address Register, Address offset: 0x3C */ __IO uint32_t OOR; /*!< DMA2D Output Offset Register, Address offset: 0x40 */ __IO uint32_t NLR; /*!< DMA2D Number of Line Register, Address offset: 0x44 */ __IO uint32_t LWR; /*!< DMA2D Line Watermark Register, Address offset: 0x48 */ __IO uint32_t AMTCR; /*!< DMA2D AHB Master Timer Configuration Register, Address offset: 0x4C */ uint32_t RESERVED[236]; /*!< Reserved, 0x50-0x3FF */ __IO uint32_t FGCLUT[256]; /*!< DMA2D Foreground CLUT, Address offset:400-7FF */ __IO uint32_t BGCLUT[256]; /*!< DMA2D Background CLUT, Address offset:800-BFF */ } DMA2D_TypeDef; /** * @brief DSI Controller */ typedef struct { __IO uint32_t VR; /*!< DSI Host Version Register, Address offset: 0x00 */ __IO uint32_t CR; /*!< DSI Host Control Register, Address offset: 0x04 */ __IO uint32_t CCR; /*!< DSI HOST Clock Control Register, Address offset: 0x08 */ __IO uint32_t LVCIDR; /*!< DSI Host LTDC VCID Register, Address offset: 0x0C */ __IO uint32_t LCOLCR; /*!< DSI Host LTDC Color Coding Register, Address offset: 0x10 */ __IO uint32_t LPCR; /*!< DSI Host LTDC Polarity Configuration Register, Address offset: 0x14 */ __IO uint32_t LPMCR; /*!< DSI Host Low-Power Mode Configuration Register, Address offset: 0x18 */ uint32_t RESERVED0[4]; /*!< Reserved, 0x1C - 0x2B */ __IO uint32_t PCR; /*!< DSI Host Protocol Configuration Register, Address offset: 0x2C */ __IO uint32_t GVCIDR; /*!< DSI Host Generic VCID Register, Address offset: 0x30 */ __IO uint32_t MCR; /*!< DSI Host Mode Configuration Register, Address offset: 0x34 */ __IO uint32_t VMCR; /*!< DSI Host Video Mode Configuration Register, Address offset: 0x38 */ __IO uint32_t VPCR; /*!< DSI Host Video Packet Configuration Register, Address offset: 0x3C */ __IO uint32_t VCCR; /*!< DSI Host Video Chunks Configuration Register, Address offset: 0x40 */ __IO uint32_t VNPCR; /*!< DSI Host Video Null Packet Configuration Register, Address offset: 0x44 */ __IO uint32_t VHSACR; /*!< DSI Host Video HSA Configuration Register, Address offset: 0x48 */ __IO uint32_t VHBPCR; /*!< DSI Host Video HBP Configuration Register, Address offset: 0x4C */ __IO uint32_t VLCR; /*!< DSI Host Video Line Configuration Register, Address offset: 0x50 */ __IO uint32_t VVSACR; /*!< DSI Host Video VSA Configuration Register, Address offset: 0x54 */ __IO uint32_t VVBPCR; /*!< DSI Host Video VBP Configuration Register, Address offset: 0x58 */ __IO uint32_t VVFPCR; /*!< DSI Host Video VFP Configuration Register, Address offset: 0x5C */ __IO uint32_t VVACR; /*!< DSI Host Video VA Configuration Register, Address offset: 0x60 */ __IO uint32_t LCCR; /*!< DSI Host LTDC Command Configuration Register, Address offset: 0x64 */ __IO uint32_t CMCR; /*!< DSI Host Command Mode Configuration Register, Address offset: 0x68 */ __IO uint32_t GHCR; /*!< DSI Host Generic Header Configuration Register, Address offset: 0x6C */ __IO uint32_t GPDR; /*!< DSI Host Generic Payload Data Register, Address offset: 0x70 */ __IO uint32_t GPSR; /*!< DSI Host Generic Packet Status Register, Address offset: 0x74 */ __IO uint32_t TCCR[6]; /*!< DSI Host Timeout Counter Configuration Register, Address offset: 0x78-0x8F */ __IO uint32_t TDCR; /*!< DSI Host 3D Configuration Register, Address offset: 0x90 */ __IO uint32_t CLCR; /*!< DSI Host Clock Lane Configuration Register, Address offset: 0x94 */ __IO uint32_t CLTCR; /*!< DSI Host Clock Lane Timer Configuration Register, Address offset: 0x98 */ __IO uint32_t DLTCR; /*!< DSI Host Data Lane Timer Configuration Register, Address offset: 0x9C */ __IO uint32_t PCTLR; /*!< DSI Host PHY Control Register, Address offset: 0xA0 */ __IO uint32_t PCONFR; /*!< DSI Host PHY Configuration Register, Address offset: 0xA4 */ __IO uint32_t PUCR; /*!< DSI Host PHY ULPS Control Register, Address offset: 0xA8 */ __IO uint32_t PTTCR; /*!< DSI Host PHY TX Triggers Configuration Register, Address offset: 0xAC */ __IO uint32_t PSR; /*!< DSI Host PHY Status Register, Address offset: 0xB0 */ uint32_t RESERVED1[2]; /*!< Reserved, 0xB4 - 0xBB */ __IO uint32_t ISR[2]; /*!< DSI Host Interrupt & Status Register, Address offset: 0xBC-0xC3 */ __IO uint32_t IER[2]; /*!< DSI Host Interrupt Enable Register, Address offset: 0xC4-0xCB */ uint32_t RESERVED2[3]; /*!< Reserved, 0xD0 - 0xD7 */ __IO uint32_t FIR[2]; /*!< DSI Host Force Interrupt Register, Address offset: 0xD8-0xDF */ uint32_t RESERVED3[8]; /*!< Reserved, 0xE0 - 0xFF */ __IO uint32_t VSCR; /*!< DSI Host Video Shadow Control Register, Address offset: 0x100 */ uint32_t RESERVED4[2]; /*!< Reserved, 0x104 - 0x10B */ __IO uint32_t LCVCIDR; /*!< DSI Host LTDC Current VCID Register, Address offset: 0x10C */ __IO uint32_t LCCCR; /*!< DSI Host LTDC Current Color Coding Register, Address offset: 0x110 */ uint32_t RESERVED5; /*!< Reserved, 0x114 */ __IO uint32_t LPMCCR; /*!< DSI Host Low-power Mode Current Configuration Register, Address offset: 0x118 */ uint32_t RESERVED6[7]; /*!< Reserved, 0x11C - 0x137 */ __IO uint32_t VMCCR; /*!< DSI Host Video Mode Current Configuration Register, Address offset: 0x138 */ __IO uint32_t VPCCR; /*!< DSI Host Video Packet Current Configuration Register, Address offset: 0x13C */ __IO uint32_t VCCCR; /*!< DSI Host Video Chuncks Current Configuration Register, Address offset: 0x140 */ __IO uint32_t VNPCCR; /*!< DSI Host Video Null Packet Current Configuration Register, Address offset: 0x144 */ __IO uint32_t VHSACCR; /*!< DSI Host Video HSA Current Configuration Register, Address offset: 0x148 */ __IO uint32_t VHBPCCR; /*!< DSI Host Video HBP Current Configuration Register, Address offset: 0x14C */ __IO uint32_t VLCCR; /*!< DSI Host Video Line Current Configuration Register, Address offset: 0x150 */ __IO uint32_t VVSACCR; /*!< DSI Host Video VSA Current Configuration Register, Address offset: 0x154 */ __IO uint32_t VVBPCCR; /*!< DSI Host Video VBP Current Configuration Register, Address offset: 0x158 */ __IO uint32_t VVFPCCR; /*!< DSI Host Video VFP Current Configuration Register, Address offset: 0x15C */ __IO uint32_t VVACCR; /*!< DSI Host Video VA Current Configuration Register, Address offset: 0x160 */ uint32_t RESERVED7[11]; /*!< Reserved, 0x164 - 0x18F */ __IO uint32_t TDCCR; /*!< DSI Host 3D Current Configuration Register, Address offset: 0x190 */ uint32_t RESERVED8[155]; /*!< Reserved, 0x194 - 0x3FF */ __IO uint32_t WCFGR; /*!< DSI Wrapper Configuration Register, Address offset: 0x400 */ __IO uint32_t WCR; /*!< DSI Wrapper Control Register, Address offset: 0x404 */ __IO uint32_t WIER; /*!< DSI Wrapper Interrupt Enable Register, Address offset: 0x408 */ __IO uint32_t WISR; /*!< DSI Wrapper Interrupt and Status Register, Address offset: 0x40C */ __IO uint32_t WIFCR; /*!< DSI Wrapper Interrupt Flag Clear Register, Address offset: 0x410 */ uint32_t RESERVED9; /*!< Reserved, 0x414 */ __IO uint32_t WPCR[5]; /*!< DSI Wrapper PHY Configuration Register, Address offset: 0x418-0x42B */ uint32_t RESERVED10; /*!< Reserved, 0x42C */ __IO uint32_t WRPCR; /*!< DSI Wrapper Regulator and PLL Control Register, Address offset: 0x430 */ } DSI_TypeDef; /** * @brief Ethernet MAC */ typedef struct { __IO uint32_t MACCR; __IO uint32_t MACFFR; __IO uint32_t MACHTHR; __IO uint32_t MACHTLR; __IO uint32_t MACMIIAR; __IO uint32_t MACMIIDR; __IO uint32_t MACFCR; __IO uint32_t MACVLANTR; /* 8 */ uint32_t RESERVED0[2]; __IO uint32_t MACRWUFFR; /* 11 */ __IO uint32_t MACPMTCSR; uint32_t RESERVED1; __IO uint32_t MACDBGR; __IO uint32_t MACSR; /* 15 */ __IO uint32_t MACIMR; __IO uint32_t MACA0HR; __IO uint32_t MACA0LR; __IO uint32_t MACA1HR; __IO uint32_t MACA1LR; __IO uint32_t MACA2HR; __IO uint32_t MACA2LR; __IO uint32_t MACA3HR; __IO uint32_t MACA3LR; /* 24 */ uint32_t RESERVED2[40]; __IO uint32_t MMCCR; /* 65 */ __IO uint32_t MMCRIR; __IO uint32_t MMCTIR; __IO uint32_t MMCRIMR; __IO uint32_t MMCTIMR; /* 69 */ uint32_t RESERVED3[14]; __IO uint32_t MMCTGFSCCR; /* 84 */ __IO uint32_t MMCTGFMSCCR; uint32_t RESERVED4[5]; __IO uint32_t MMCTGFCR; uint32_t RESERVED5[10]; __IO uint32_t MMCRFCECR; __IO uint32_t MMCRFAECR; uint32_t RESERVED6[10]; __IO uint32_t MMCRGUFCR; uint32_t RESERVED7[334]; __IO uint32_t PTPTSCR; __IO uint32_t PTPSSIR; __IO uint32_t PTPTSHR; __IO uint32_t PTPTSLR; __IO uint32_t PTPTSHUR; __IO uint32_t PTPTSLUR; __IO uint32_t PTPTSAR; __IO uint32_t PTPTTHR; __IO uint32_t PTPTTLR; __IO uint32_t RESERVED8; __IO uint32_t PTPTSSR; uint32_t RESERVED9[565]; __IO uint32_t DMABMR; __IO uint32_t DMATPDR; __IO uint32_t DMARPDR; __IO uint32_t DMARDLAR; __IO uint32_t DMATDLAR; __IO uint32_t DMASR; __IO uint32_t DMAOMR; __IO uint32_t DMAIER; __IO uint32_t DMAMFBOCR; __IO uint32_t DMARSWTR; uint32_t RESERVED10[8]; __IO uint32_t DMACHTDR; __IO uint32_t DMACHRDR; __IO uint32_t DMACHTBAR; __IO uint32_t DMACHRBAR; } ETH_TypeDef; /** * @brief External Interrupt/Event Controller */ typedef struct { __IO uint32_t IMR; /*!< EXTI Interrupt mask register, Address offset: 0x00 */ __IO uint32_t EMR; /*!< EXTI Event mask register, Address offset: 0x04 */ __IO uint32_t RTSR; /*!< EXTI Rising trigger selection register, Address offset: 0x08 */ __IO uint32_t FTSR; /*!< EXTI Falling trigger selection register, Address offset: 0x0C */ __IO uint32_t SWIER; /*!< EXTI Software interrupt event register, Address offset: 0x10 */ __IO uint32_t PR; /*!< EXTI Pending register, Address offset: 0x14 */ } EXTI_TypeDef; /** * @brief FLASH Registers */ typedef struct { __IO uint32_t ACR; /*!< FLASH access control register, Address offset: 0x00 */ __IO uint32_t KEYR; /*!< FLASH key register, Address offset: 0x04 */ __IO uint32_t OPTKEYR; /*!< FLASH option key register, Address offset: 0x08 */ __IO uint32_t SR; /*!< FLASH status register, Address offset: 0x0C */ __IO uint32_t CR; /*!< FLASH control register, Address offset: 0x10 */ __IO uint32_t OPTCR; /*!< FLASH option control register , Address offset: 0x14 */ __IO uint32_t OPTCR1; /*!< FLASH option control register 1, Address offset: 0x18 */ } FLASH_TypeDef; /** * @brief Flexible Memory Controller */ typedef struct { __IO uint32_t BTCR[8]; /*!< NOR/PSRAM chip-select control register(BCR) and chip-select timing register(BTR), Address offset: 0x00-1C */ } FMC_Bank1_TypeDef; /** * @brief Flexible Memory Controller Bank1E */ typedef struct { __IO uint32_t BWTR[7]; /*!< NOR/PSRAM write timing registers, Address offset: 0x104-0x11C */ } FMC_Bank1E_TypeDef; /** * @brief Flexible Memory Controller Bank3 */ typedef struct { __IO uint32_t PCR; /*!< NAND Flash control register, Address offset: 0x80 */ __IO uint32_t SR; /*!< NAND Flash FIFO status and interrupt register, Address offset: 0x84 */ __IO uint32_t PMEM; /*!< NAND Flash Common memory space timing register, Address offset: 0x88 */ __IO uint32_t PATT; /*!< NAND Flash Attribute memory space timing register, Address offset: 0x8C */ uint32_t RESERVED; /*!< Reserved, 0x90 */ __IO uint32_t ECCR; /*!< NAND Flash ECC result registers, Address offset: 0x94 */ } FMC_Bank3_TypeDef; /** * @brief Flexible Memory Controller Bank5_6 */ typedef struct { __IO uint32_t SDCR[2]; /*!< SDRAM Control registers , Address offset: 0x140-0x144 */ __IO uint32_t SDTR[2]; /*!< SDRAM Timing registers , Address offset: 0x148-0x14C */ __IO uint32_t SDCMR; /*!< SDRAM Command Mode register, Address offset: 0x150 */ __IO uint32_t SDRTR; /*!< SDRAM Refresh Timer register, Address offset: 0x154 */ __IO uint32_t SDSR; /*!< SDRAM Status register, Address offset: 0x158 */ } FMC_Bank5_6_TypeDef; /** * @brief General Purpose I/O */ typedef struct { __IO uint32_t MODER; /*!< GPIO port mode register, Address offset: 0x00 */ __IO uint32_t OTYPER; /*!< GPIO port output type register, Address offset: 0x04 */ __IO uint32_t OSPEEDR; /*!< GPIO port output speed register, Address offset: 0x08 */ __IO uint32_t PUPDR; /*!< GPIO port pull-up/pull-down register, Address offset: 0x0C */ __IO uint32_t IDR; /*!< GPIO port input data register, Address offset: 0x10 */ __IO uint32_t ODR; /*!< GPIO port output data register, Address offset: 0x14 */ __IO uint32_t BSRR; /*!< GPIO port bit set/reset register, Address offset: 0x18 */ __IO uint32_t LCKR; /*!< GPIO port configuration lock register, Address offset: 0x1C */ __IO uint32_t AFR[2]; /*!< GPIO alternate function registers, Address offset: 0x20-0x24 */ } GPIO_TypeDef; /** * @brief System configuration controller */ typedef struct { __IO uint32_t MEMRMP; /*!< SYSCFG memory remap register, Address offset: 0x00 */ __IO uint32_t PMC; /*!< SYSCFG peripheral mode configuration register, Address offset: 0x04 */ __IO uint32_t EXTICR[4]; /*!< SYSCFG external interrupt configuration registers, Address offset: 0x08-0x14 */ uint32_t RESERVED[2]; /*!< Reserved, 0x18-0x1C */ __IO uint32_t CMPCR; /*!< SYSCFG Compensation cell control register, Address offset: 0x20 */ } SYSCFG_TypeDef; /** * @brief Inter-integrated Circuit Interface */ typedef struct { __IO uint32_t CR1; /*!< I2C Control register 1, Address offset: 0x00 */ __IO uint32_t CR2; /*!< I2C Control register 2, Address offset: 0x04 */ __IO uint32_t OAR1; /*!< I2C Own address register 1, Address offset: 0x08 */ __IO uint32_t OAR2; /*!< I2C Own address register 2, Address offset: 0x0C */ __IO uint32_t DR; /*!< I2C Data register, Address offset: 0x10 */ __IO uint32_t SR1; /*!< I2C Status register 1, Address offset: 0x14 */ __IO uint32_t SR2; /*!< I2C Status register 2, Address offset: 0x18 */ __IO uint32_t CCR; /*!< I2C Clock control register, Address offset: 0x1C */ __IO uint32_t TRISE; /*!< I2C TRISE register, Address offset: 0x20 */ __IO uint32_t FLTR; /*!< I2C FLTR register, Address offset: 0x24 */ } I2C_TypeDef; /** * @brief Independent WATCHDOG */ typedef struct { __IO uint32_t KR; /*!< IWDG Key register, Address offset: 0x00 */ __IO uint32_t PR; /*!< IWDG Prescaler register, Address offset: 0x04 */ __IO uint32_t RLR; /*!< IWDG Reload register, Address offset: 0x08 */ __IO uint32_t SR; /*!< IWDG Status register, Address offset: 0x0C */ } IWDG_TypeDef; /** * @brief LCD-TFT Display Controller */ typedef struct { uint32_t RESERVED0[2]; /*!< Reserved, 0x00-0x04 */ __IO uint32_t SSCR; /*!< LTDC Synchronization Size Configuration Register, Address offset: 0x08 */ __IO uint32_t BPCR; /*!< LTDC Back Porch Configuration Register, Address offset: 0x0C */ __IO uint32_t AWCR; /*!< LTDC Active Width Configuration Register, Address offset: 0x10 */ __IO uint32_t TWCR; /*!< LTDC Total Width Configuration Register, Address offset: 0x14 */ __IO uint32_t GCR; /*!< LTDC Global Control Register, Address offset: 0x18 */ uint32_t RESERVED1[2]; /*!< Reserved, 0x1C-0x20 */ __IO uint32_t SRCR; /*!< LTDC Shadow Reload Configuration Register, Address offset: 0x24 */ uint32_t RESERVED2[1]; /*!< Reserved, 0x28 */ __IO uint32_t BCCR; /*!< LTDC Background Color Configuration Register, Address offset: 0x2C */ uint32_t RESERVED3[1]; /*!< Reserved, 0x30 */ __IO uint32_t IER; /*!< LTDC Interrupt Enable Register, Address offset: 0x34 */ __IO uint32_t ISR; /*!< LTDC Interrupt Status Register, Address offset: 0x38 */ __IO uint32_t ICR; /*!< LTDC Interrupt Clear Register, Address offset: 0x3C */ __IO uint32_t LIPCR; /*!< LTDC Line Interrupt Position Configuration Register, Address offset: 0x40 */ __IO uint32_t CPSR; /*!< LTDC Current Position Status Register, Address offset: 0x44 */ __IO uint32_t CDSR; /*!< LTDC Current Display Status Register, Address offset: 0x48 */ } LTDC_TypeDef; /** * @brief LCD-TFT Display layer x Controller */ typedef struct { __IO uint32_t CR; /*!< LTDC Layerx Control Register Address offset: 0x84 */ __IO uint32_t WHPCR; /*!< LTDC Layerx Window Horizontal Position Configuration Register Address offset: 0x88 */ __IO uint32_t WVPCR; /*!< LTDC Layerx Window Vertical Position Configuration Register Address offset: 0x8C */ __IO uint32_t CKCR; /*!< LTDC Layerx Color Keying Configuration Register Address offset: 0x90 */ __IO uint32_t PFCR; /*!< LTDC Layerx Pixel Format Configuration Register Address offset: 0x94 */ __IO uint32_t CACR; /*!< LTDC Layerx Constant Alpha Configuration Register Address offset: 0x98 */ __IO uint32_t DCCR; /*!< LTDC Layerx Default Color Configuration Register Address offset: 0x9C */ __IO uint32_t BFCR; /*!< LTDC Layerx Blending Factors Configuration Register Address offset: 0xA0 */ uint32_t RESERVED0[2]; /*!< Reserved */ __IO uint32_t CFBAR; /*!< LTDC Layerx Color Frame Buffer Address Register Address offset: 0xAC */ __IO uint32_t CFBLR; /*!< LTDC Layerx Color Frame Buffer Length Register Address offset: 0xB0 */ __IO uint32_t CFBLNR; /*!< LTDC Layerx ColorFrame Buffer Line Number Register Address offset: 0xB4 */ uint32_t RESERVED1[3]; /*!< Reserved */ __IO uint32_t CLUTWR; /*!< LTDC Layerx CLUT Write Register Address offset: 0x144*/ } LTDC_Layer_TypeDef; /** * @brief Power Control */ typedef struct { __IO uint32_t CR; /*!< PWR power control register, Address offset: 0x00 */ __IO uint32_t CSR; /*!< PWR power control/status register, Address offset: 0x04 */ } PWR_TypeDef; /** * @brief Reset and Clock Control */ typedef struct { __IO uint32_t CR; /*!< RCC clock control register, Address offset: 0x00 */ __IO uint32_t PLLCFGR; /*!< RCC PLL configuration register, Address offset: 0x04 */ __IO uint32_t CFGR; /*!< RCC clock configuration register, Address offset: 0x08 */ __IO uint32_t CIR; /*!< RCC clock interrupt register, Address offset: 0x0C */ __IO uint32_t AHB1RSTR; /*!< RCC AHB1 peripheral reset register, Address offset: 0x10 */ __IO uint32_t AHB2RSTR; /*!< RCC AHB2 peripheral reset register, Address offset: 0x14 */ __IO uint32_t AHB3RSTR; /*!< RCC AHB3 peripheral reset register, Address offset: 0x18 */ uint32_t RESERVED0; /*!< Reserved, 0x1C */ __IO uint32_t APB1RSTR; /*!< RCC APB1 peripheral reset register, Address offset: 0x20 */ __IO uint32_t APB2RSTR; /*!< RCC APB2 peripheral reset register, Address offset: 0x24 */ uint32_t RESERVED1[2]; /*!< Reserved, 0x28-0x2C */ __IO uint32_t AHB1ENR; /*!< RCC AHB1 peripheral clock register, Address offset: 0x30 */ __IO uint32_t AHB2ENR; /*!< RCC AHB2 peripheral clock register, Address offset: 0x34 */ __IO uint32_t AHB3ENR; /*!< RCC AHB3 peripheral clock register, Address offset: 0x38 */ uint32_t RESERVED2; /*!< Reserved, 0x3C */ __IO uint32_t APB1ENR; /*!< RCC APB1 peripheral clock enable register, Address offset: 0x40 */ __IO uint32_t APB2ENR; /*!< RCC APB2 peripheral clock enable register, Address offset: 0x44 */ uint32_t RESERVED3[2]; /*!< Reserved, 0x48-0x4C */ __IO uint32_t AHB1LPENR; /*!< RCC AHB1 peripheral clock enable in low power mode register, Address offset: 0x50 */ __IO uint32_t AHB2LPENR; /*!< RCC AHB2 peripheral clock enable in low power mode register, Address offset: 0x54 */ __IO uint32_t AHB3LPENR; /*!< RCC AHB3 peripheral clock enable in low power mode register, Address offset: 0x58 */ uint32_t RESERVED4; /*!< Reserved, 0x5C */ __IO uint32_t APB1LPENR; /*!< RCC APB1 peripheral clock enable in low power mode register, Address offset: 0x60 */ __IO uint32_t APB2LPENR; /*!< RCC APB2 peripheral clock enable in low power mode register, Address offset: 0x64 */ uint32_t RESERVED5[2]; /*!< Reserved, 0x68-0x6C */ __IO uint32_t BDCR; /*!< RCC Backup domain control register, Address offset: 0x70 */ __IO uint32_t CSR; /*!< RCC clock control & status register, Address offset: 0x74 */ uint32_t RESERVED6[2]; /*!< Reserved, 0x78-0x7C */ __IO uint32_t SSCGR; /*!< RCC spread spectrum clock generation register, Address offset: 0x80 */ __IO uint32_t PLLI2SCFGR; /*!< RCC PLLI2S configuration register, Address offset: 0x84 */ __IO uint32_t PLLSAICFGR; /*!< RCC PLLSAI configuration register, Address offset: 0x88 */ __IO uint32_t DCKCFGR; /*!< RCC Dedicated Clocks configuration register, Address offset: 0x8C */ } RCC_TypeDef; /** * @brief Real-Time Clock */ typedef struct { __IO uint32_t TR; /*!< RTC time register, Address offset: 0x00 */ __IO uint32_t DR; /*!< RTC date register, Address offset: 0x04 */ __IO uint32_t CR; /*!< RTC control register, Address offset: 0x08 */ __IO uint32_t ISR; /*!< RTC initialization and status register, Address offset: 0x0C */ __IO uint32_t PRER; /*!< RTC prescaler register, Address offset: 0x10 */ __IO uint32_t WUTR; /*!< RTC wakeup timer register, Address offset: 0x14 */ __IO uint32_t CALIBR; /*!< RTC calibration register, Address offset: 0x18 */ __IO uint32_t ALRMAR; /*!< RTC alarm A register, Address offset: 0x1C */ __IO uint32_t ALRMBR; /*!< RTC alarm B register, Address offset: 0x20 */ __IO uint32_t WPR; /*!< RTC write protection register, Address offset: 0x24 */ __IO uint32_t SSR; /*!< RTC sub second register, Address offset: 0x28 */ __IO uint32_t SHIFTR; /*!< RTC shift control register, Address offset: 0x2C */ __IO uint32_t TSTR; /*!< RTC time stamp time register, Address offset: 0x30 */ __IO uint32_t TSDR; /*!< RTC time stamp date register, Address offset: 0x34 */ __IO uint32_t TSSSR; /*!< RTC time-stamp sub second register, Address offset: 0x38 */ __IO uint32_t CALR; /*!< RTC calibration register, Address offset: 0x3C */ __IO uint32_t TAFCR; /*!< RTC tamper and alternate function configuration register, Address offset: 0x40 */ __IO uint32_t ALRMASSR;/*!< RTC alarm A sub second register, Address offset: 0x44 */ __IO uint32_t ALRMBSSR;/*!< RTC alarm B sub second register, Address offset: 0x48 */ uint32_t RESERVED7; /*!< Reserved, 0x4C */ __IO uint32_t BKP0R; /*!< RTC backup register 1, Address offset: 0x50 */ __IO uint32_t BKP1R; /*!< RTC backup register 1, Address offset: 0x54 */ __IO uint32_t BKP2R; /*!< RTC backup register 2, Address offset: 0x58 */ __IO uint32_t BKP3R; /*!< RTC backup register 3, Address offset: 0x5C */ __IO uint32_t BKP4R; /*!< RTC backup register 4, Address offset: 0x60 */ __IO uint32_t BKP5R; /*!< RTC backup register 5, Address offset: 0x64 */ __IO uint32_t BKP6R; /*!< RTC backup register 6, Address offset: 0x68 */ __IO uint32_t BKP7R; /*!< RTC backup register 7, Address offset: 0x6C */ __IO uint32_t BKP8R; /*!< RTC backup register 8, Address offset: 0x70 */ __IO uint32_t BKP9R; /*!< RTC backup register 9, Address offset: 0x74 */ __IO uint32_t BKP10R; /*!< RTC backup register 10, Address offset: 0x78 */ __IO uint32_t BKP11R; /*!< RTC backup register 11, Address offset: 0x7C */ __IO uint32_t BKP12R; /*!< RTC backup register 12, Address offset: 0x80 */ __IO uint32_t BKP13R; /*!< RTC backup register 13, Address offset: 0x84 */ __IO uint32_t BKP14R; /*!< RTC backup register 14, Address offset: 0x88 */ __IO uint32_t BKP15R; /*!< RTC backup register 15, Address offset: 0x8C */ __IO uint32_t BKP16R; /*!< RTC backup register 16, Address offset: 0x90 */ __IO uint32_t BKP17R; /*!< RTC backup register 17, Address offset: 0x94 */ __IO uint32_t BKP18R; /*!< RTC backup register 18, Address offset: 0x98 */ __IO uint32_t BKP19R; /*!< RTC backup register 19, Address offset: 0x9C */ } RTC_TypeDef; /** * @brief Serial Audio Interface */ typedef struct { __IO uint32_t GCR; /*!< SAI global configuration register, Address offset: 0x00 */ } SAI_TypeDef; typedef struct { __IO uint32_t CR1; /*!< SAI block x configuration register 1, Address offset: 0x04 */ __IO uint32_t CR2; /*!< SAI block x configuration register 2, Address offset: 0x08 */ __IO uint32_t FRCR; /*!< SAI block x frame configuration register, Address offset: 0x0C */ __IO uint32_t SLOTR; /*!< SAI block x slot register, Address offset: 0x10 */ __IO uint32_t IMR; /*!< SAI block x interrupt mask register, Address offset: 0x14 */ __IO uint32_t SR; /*!< SAI block x status register, Address offset: 0x18 */ __IO uint32_t CLRFR; /*!< SAI block x clear flag register, Address offset: 0x1C */ __IO uint32_t DR; /*!< SAI block x data register, Address offset: 0x20 */ } SAI_Block_TypeDef; /** * @brief SD host Interface */ typedef struct { __IO uint32_t POWER; /*!< SDIO power control register, Address offset: 0x00 */ __IO uint32_t CLKCR; /*!< SDI clock control register, Address offset: 0x04 */ __IO uint32_t ARG; /*!< SDIO argument register, Address offset: 0x08 */ __IO uint32_t CMD; /*!< SDIO command register, Address offset: 0x0C */ __IO const uint32_t RESPCMD; /*!< SDIO command response register, Address offset: 0x10 */ __IO const uint32_t RESP1; /*!< SDIO response 1 register, Address offset: 0x14 */ __IO const uint32_t RESP2; /*!< SDIO response 2 register, Address offset: 0x18 */ __IO const uint32_t RESP3; /*!< SDIO response 3 register, Address offset: 0x1C */ __IO const uint32_t RESP4; /*!< SDIO response 4 register, Address offset: 0x20 */ __IO uint32_t DTIMER; /*!< SDIO data timer register, Address offset: 0x24 */ __IO uint32_t DLEN; /*!< SDIO data length register, Address offset: 0x28 */ __IO uint32_t DCTRL; /*!< SDIO data control register, Address offset: 0x2C */ __IO const uint32_t DCOUNT; /*!< SDIO data counter register, Address offset: 0x30 */ __IO const uint32_t STA; /*!< SDIO status register, Address offset: 0x34 */ __IO uint32_t ICR; /*!< SDIO interrupt clear register, Address offset: 0x38 */ __IO uint32_t MASK; /*!< SDIO mask register, Address offset: 0x3C */ uint32_t RESERVED0[2]; /*!< Reserved, 0x40-0x44 */ __IO const uint32_t FIFOCNT; /*!< SDIO FIFO counter register, Address offset: 0x48 */ uint32_t RESERVED1[13]; /*!< Reserved, 0x4C-0x7C */ __IO uint32_t FIFO; /*!< SDIO data FIFO register, Address offset: 0x80 */ } SDIO_TypeDef; /** * @brief Serial Peripheral Interface */ typedef struct { __IO uint32_t CR1; /*!< SPI control register 1 (not used in I2S mode), Address offset: 0x00 */ __IO uint32_t CR2; /*!< SPI control register 2, Address offset: 0x04 */ __IO uint32_t SR; /*!< SPI status register, Address offset: 0x08 */ __IO uint32_t DR; /*!< SPI data register, Address offset: 0x0C */ __IO uint32_t CRCPR; /*!< SPI CRC polynomial register (not used in I2S mode), Address offset: 0x10 */ __IO uint32_t RXCRCR; /*!< SPI RX CRC register (not used in I2S mode), Address offset: 0x14 */ __IO uint32_t TXCRCR; /*!< SPI TX CRC register (not used in I2S mode), Address offset: 0x18 */ __IO uint32_t I2SCFGR; /*!< SPI_I2S configuration register, Address offset: 0x1C */ __IO uint32_t I2SPR; /*!< SPI_I2S prescaler register, Address offset: 0x20 */ } SPI_TypeDef; /** * @brief QUAD Serial Peripheral Interface */ typedef struct { __IO uint32_t CR; /*!< QUADSPI Control register, Address offset: 0x00 */ __IO uint32_t DCR; /*!< QUADSPI Device Configuration register, Address offset: 0x04 */ __IO uint32_t SR; /*!< QUADSPI Status register, Address offset: 0x08 */ __IO uint32_t FCR; /*!< QUADSPI Flag Clear register, Address offset: 0x0C */ __IO uint32_t DLR; /*!< QUADSPI Data Length register, Address offset: 0x10 */ __IO uint32_t CCR; /*!< QUADSPI Communication Configuration register, Address offset: 0x14 */ __IO uint32_t AR; /*!< QUADSPI Address register, Address offset: 0x18 */ __IO uint32_t ABR; /*!< QUADSPI Alternate Bytes register, Address offset: 0x1C */ __IO uint32_t DR; /*!< QUADSPI Data register, Address offset: 0x20 */ __IO uint32_t PSMKR; /*!< QUADSPI Polling Status Mask register, Address offset: 0x24 */ __IO uint32_t PSMAR; /*!< QUADSPI Polling Status Match register, Address offset: 0x28 */ __IO uint32_t PIR; /*!< QUADSPI Polling Interval register, Address offset: 0x2C */ __IO uint32_t LPTR; /*!< QUADSPI Low Power Timeout register, Address offset: 0x30 */ } QUADSPI_TypeDef; /** * @brief TIM */ typedef struct { __IO uint32_t CR1; /*!< TIM control register 1, Address offset: 0x00 */ __IO uint32_t CR2; /*!< TIM control register 2, Address offset: 0x04 */ __IO uint32_t SMCR; /*!< TIM slave mode control register, Address offset: 0x08 */ __IO uint32_t DIER; /*!< TIM DMA/interrupt enable register, Address offset: 0x0C */ __IO uint32_t SR; /*!< TIM status register, Address offset: 0x10 */ __IO uint32_t EGR; /*!< TIM event generation register, Address offset: 0x14 */ __IO uint32_t CCMR1; /*!< TIM capture/compare mode register 1, Address offset: 0x18 */ __IO uint32_t CCMR2; /*!< TIM capture/compare mode register 2, Address offset: 0x1C */ __IO uint32_t CCER; /*!< TIM capture/compare enable register, Address offset: 0x20 */ __IO uint32_t CNT; /*!< TIM counter register, Address offset: 0x24 */ __IO uint32_t PSC; /*!< TIM prescaler, Address offset: 0x28 */ __IO uint32_t ARR; /*!< TIM auto-reload register, Address offset: 0x2C */ __IO uint32_t RCR; /*!< TIM repetition counter register, Address offset: 0x30 */ __IO uint32_t CCR1; /*!< TIM capture/compare register 1, Address offset: 0x34 */ __IO uint32_t CCR2; /*!< TIM capture/compare register 2, Address offset: 0x38 */ __IO uint32_t CCR3; /*!< TIM capture/compare register 3, Address offset: 0x3C */ __IO uint32_t CCR4; /*!< TIM capture/compare register 4, Address offset: 0x40 */ __IO uint32_t BDTR; /*!< TIM break and dead-time register, Address offset: 0x44 */ __IO uint32_t DCR; /*!< TIM DMA control register, Address offset: 0x48 */ __IO uint32_t DMAR; /*!< TIM DMA address for full transfer, Address offset: 0x4C */ __IO uint32_t OR; /*!< TIM option register, Address offset: 0x50 */ } TIM_TypeDef; /** * @brief Universal Synchronous Asynchronous Receiver Transmitter */ typedef struct { __IO uint32_t SR; /*!< USART Status register, Address offset: 0x00 */ __IO uint32_t DR; /*!< USART Data register, Address offset: 0x04 */ __IO uint32_t BRR; /*!< USART Baud rate register, Address offset: 0x08 */ __IO uint32_t CR1; /*!< USART Control register 1, Address offset: 0x0C */ __IO uint32_t CR2; /*!< USART Control register 2, Address offset: 0x10 */ __IO uint32_t CR3; /*!< USART Control register 3, Address offset: 0x14 */ __IO uint32_t GTPR; /*!< USART Guard time and prescaler register, Address offset: 0x18 */ } USART_TypeDef; /** * @brief Window WATCHDOG */ typedef struct { __IO uint32_t CR; /*!< WWDG Control register, Address offset: 0x00 */ __IO uint32_t CFR; /*!< WWDG Configuration register, Address offset: 0x04 */ __IO uint32_t SR; /*!< WWDG Status register, Address offset: 0x08 */ } WWDG_TypeDef; /** * @brief RNG */ typedef struct { __IO uint32_t CR; /*!< RNG control register, Address offset: 0x00 */ __IO uint32_t SR; /*!< RNG status register, Address offset: 0x04 */ __IO uint32_t DR; /*!< RNG data register, Address offset: 0x08 */ } RNG_TypeDef; /** * @brief USB_OTG_Core_Registers */ typedef struct { __IO uint32_t GOTGCTL; /*!< USB_OTG Control and Status Register 000h */ __IO uint32_t GOTGINT; /*!< USB_OTG Interrupt Register 004h */ __IO uint32_t GAHBCFG; /*!< Core AHB Configuration Register 008h */ __IO uint32_t GUSBCFG; /*!< Core USB Configuration Register 00Ch */ __IO uint32_t GRSTCTL; /*!< Core Reset Register 010h */ __IO uint32_t GINTSTS; /*!< Core Interrupt Register 014h */ __IO uint32_t GINTMSK; /*!< Core Interrupt Mask Register 018h */ __IO uint32_t GRXSTSR; /*!< Receive Sts Q Read Register 01Ch */ __IO uint32_t GRXSTSP; /*!< Receive Sts Q Read & POP Register 020h */ __IO uint32_t GRXFSIZ; /*!< Receive FIFO Size Register 024h */ __IO uint32_t DIEPTXF0_HNPTXFSIZ; /*!< EP0 / Non Periodic Tx FIFO Size Register 028h */ __IO uint32_t HNPTXSTS; /*!< Non Periodic Tx FIFO/Queue Sts reg 02Ch */ uint32_t Reserved30[2]; /*!< Reserved 030h */ __IO uint32_t GCCFG; /*!< General Purpose IO Register 038h */ __IO uint32_t CID; /*!< User ID Register 03Ch */ uint32_t Reserved5[3]; /*!< Reserved 040h-048h */ __IO uint32_t GHWCFG3; /*!< User HW config3 04Ch */ uint32_t Reserved6; /*!< Reserved 050h */ __IO uint32_t GLPMCFG; /*!< LPM Register 054h */ uint32_t Reserved; /*!< Reserved 058h */ __IO uint32_t GDFIFOCFG; /*!< DFIFO Software Config Register 05Ch */ uint32_t Reserved43[40]; /*!< Reserved 058h-0FFh */ __IO uint32_t HPTXFSIZ; /*!< Host Periodic Tx FIFO Size Reg 100h */ __IO uint32_t DIEPTXF[0x0F]; /*!< dev Periodic Transmit FIFO */ } USB_OTG_GlobalTypeDef; /** * @brief USB_OTG_device_Registers */ typedef struct { __IO uint32_t DCFG; /*!< dev Configuration Register 800h */ __IO uint32_t DCTL; /*!< dev Control Register 804h */ __IO uint32_t DSTS; /*!< dev Status Register (RO) 808h */ uint32_t Reserved0C; /*!< Reserved 80Ch */ __IO uint32_t DIEPMSK; /*!< dev IN Endpoint Mask 810h */ __IO uint32_t DOEPMSK; /*!< dev OUT Endpoint Mask 814h */ __IO uint32_t DAINT; /*!< dev All Endpoints Itr Reg 818h */ __IO uint32_t DAINTMSK; /*!< dev All Endpoints Itr Mask 81Ch */ uint32_t Reserved20; /*!< Reserved 820h */ uint32_t Reserved9; /*!< Reserved 824h */ __IO uint32_t DVBUSDIS; /*!< dev VBUS discharge Register 828h */ __IO uint32_t DVBUSPULSE; /*!< dev VBUS Pulse Register 82Ch */ __IO uint32_t DTHRCTL; /*!< dev threshold 830h */ __IO uint32_t DIEPEMPMSK; /*!< dev empty msk 834h */ __IO uint32_t DEACHINT; /*!< dedicated EP interrupt 838h */ __IO uint32_t DEACHMSK; /*!< dedicated EP msk 83Ch */ uint32_t Reserved40; /*!< dedicated EP mask 840h */ __IO uint32_t DINEP1MSK; /*!< dedicated EP mask 844h */ uint32_t Reserved44[15]; /*!< Reserved 844-87Ch */ __IO uint32_t DOUTEP1MSK; /*!< dedicated EP msk 884h */ } USB_OTG_DeviceTypeDef; /** * @brief USB_OTG_IN_Endpoint-Specific_Register */ typedef struct { __IO uint32_t DIEPCTL; /*!< dev IN Endpoint Control Reg 900h + (ep_num * 20h) + 00h */ uint32_t Reserved04; /*!< Reserved 900h + (ep_num * 20h) + 04h */ __IO uint32_t DIEPINT; /*!< dev IN Endpoint Itr Reg 900h + (ep_num * 20h) + 08h */ uint32_t Reserved0C; /*!< Reserved 900h + (ep_num * 20h) + 0Ch */ __IO uint32_t DIEPTSIZ; /*!< IN Endpoint Txfer Size 900h + (ep_num * 20h) + 10h */ __IO uint32_t DIEPDMA; /*!< IN Endpoint DMA Address Reg 900h + (ep_num * 20h) + 14h */ __IO uint32_t DTXFSTS; /*!< IN Endpoint Tx FIFO Status Reg 900h + (ep_num * 20h) + 18h */ uint32_t Reserved18; /*!< Reserved 900h+(ep_num*20h)+1Ch-900h+ (ep_num * 20h) + 1Ch */ } USB_OTG_INEndpointTypeDef; /** * @brief USB_OTG_OUT_Endpoint-Specific_Registers */ typedef struct { __IO uint32_t DOEPCTL; /*!< dev OUT Endpoint Control Reg B00h + (ep_num * 20h) + 00h */ uint32_t Reserved04; /*!< Reserved B00h + (ep_num * 20h) + 04h */ __IO uint32_t DOEPINT; /*!< dev OUT Endpoint Itr Reg B00h + (ep_num * 20h) + 08h */ uint32_t Reserved0C; /*!< Reserved B00h + (ep_num * 20h) + 0Ch */ __IO uint32_t DOEPTSIZ; /*!< dev OUT Endpoint Txfer Size B00h + (ep_num * 20h) + 10h */ __IO uint32_t DOEPDMA; /*!< dev OUT Endpoint DMA Address B00h + (ep_num * 20h) + 14h */ uint32_t Reserved18[2]; /*!< Reserved B00h + (ep_num * 20h) + 18h - B00h + (ep_num * 20h) + 1Ch */ } USB_OTG_OUTEndpointTypeDef; /** * @brief USB_OTG_Host_Mode_Register_Structures */ typedef struct { __IO uint32_t HCFG; /*!< Host Configuration Register 400h */ __IO uint32_t HFIR; /*!< Host Frame Interval Register 404h */ __IO uint32_t HFNUM; /*!< Host Frame Nbr/Frame Remaining 408h */ uint32_t Reserved40C; /*!< Reserved 40Ch */ __IO uint32_t HPTXSTS; /*!< Host Periodic Tx FIFO/ Queue Status 410h */ __IO uint32_t HAINT; /*!< Host All Channels Interrupt Register 414h */ __IO uint32_t HAINTMSK; /*!< Host All Channels Interrupt Mask 418h */ } USB_OTG_HostTypeDef; /** * @brief USB_OTG_Host_Channel_Specific_Registers */ typedef struct { __IO uint32_t HCCHAR; /*!< Host Channel Characteristics Register 500h */ __IO uint32_t HCSPLT; /*!< Host Channel Split Control Register 504h */ __IO uint32_t HCINT; /*!< Host Channel Interrupt Register 508h */ __IO uint32_t HCINTMSK; /*!< Host Channel Interrupt Mask Register 50Ch */ __IO uint32_t HCTSIZ; /*!< Host Channel Transfer Size Register 510h */ __IO uint32_t HCDMA; /*!< Host Channel DMA Address Register 514h */ uint32_t Reserved[2]; /*!< Reserved */ } USB_OTG_HostChannelTypeDef; /** * @} */ /** @addtogroup Peripheral_memory_map * @{ */ #define FLASH_BASE 0x08000000U /*!< FLASH(up to 1 MB) base address in the alias region */ #define CCMDATARAM_BASE 0x10000000U /*!< CCM(core coupled memory) data RAM(64 KB) base address in the alias region */ #define SRAM1_BASE 0x20000000U /*!< SRAM1(160 KB) base address in the alias region */ #define SRAM2_BASE 0x20028000U /*!< SRAM2(32 KB) base address in the alias region */ #define SRAM3_BASE 0x20030000U /*!< SRAM3(128 KB) base address in the alias region */ #define PERIPH_BASE 0x40000000U /*!< Peripheral base address in the alias region */ #define BKPSRAM_BASE 0x40024000U /*!< Backup SRAM(4 KB) base address in the alias region */ #define FMC_R_BASE 0xA0000000U /*!< FMC registers base address */ #define QSPI_R_BASE 0xA0001000U /*!< QuadSPI registers base address */ #define SRAM1_BB_BASE 0x22000000U /*!< SRAM1(112 KB) base address in the bit-band region */ #define SRAM2_BB_BASE 0x22500000U /*!< SRAM2(16 KB) base address in the bit-band region */ #define SRAM3_BB_BASE 0x22600000U /*!< SRAM3(64 KB) base address in the bit-band region */ #define PERIPH_BB_BASE 0x42000000U /*!< Peripheral base address in the bit-band region */ #define BKPSRAM_BB_BASE 0x42480000U /*!< Backup SRAM(4 KB) base address in the bit-band region */ #define FLASH_END 0x081FFFFFU /*!< FLASH end address */ #define FLASH_OTP_BASE 0x1FFF7800U /*!< Base address of : (up to 528 Bytes) embedded FLASH OTP Area */ #define FLASH_OTP_END 0x1FFF7A0FU /*!< End address of : (up to 528 Bytes) embedded FLASH OTP Area */ #define CCMDATARAM_END 0x1000FFFFU /*!< CCM data RAM end address */ /* Legacy defines */ #define SRAM_BASE SRAM1_BASE #define SRAM_BB_BASE SRAM1_BB_BASE /*!< Peripheral memory map */ #define APB1PERIPH_BASE PERIPH_BASE #define APB2PERIPH_BASE (PERIPH_BASE + 0x00010000U) #define AHB1PERIPH_BASE (PERIPH_BASE + 0x00020000U) #define AHB2PERIPH_BASE (PERIPH_BASE + 0x10000000U) /*!< APB1 peripherals */ #define TIM2_BASE (APB1PERIPH_BASE + 0x0000U) #define TIM3_BASE (APB1PERIPH_BASE + 0x0400U) #define TIM4_BASE (APB1PERIPH_BASE + 0x0800U) #define TIM5_BASE (APB1PERIPH_BASE + 0x0C00U) #define TIM6_BASE (APB1PERIPH_BASE + 0x1000U) #define TIM7_BASE (APB1PERIPH_BASE + 0x1400U) #define TIM12_BASE (APB1PERIPH_BASE + 0x1800U) #define TIM13_BASE (APB1PERIPH_BASE + 0x1C00U) #define TIM14_BASE (APB1PERIPH_BASE + 0x2000U) #define RTC_BASE (APB1PERIPH_BASE + 0x2800U) #define WWDG_BASE (APB1PERIPH_BASE + 0x2C00U) #define IWDG_BASE (APB1PERIPH_BASE + 0x3000U) #define I2S2ext_BASE (APB1PERIPH_BASE + 0x3400U) #define SPI2_BASE (APB1PERIPH_BASE + 0x3800U) #define SPI3_BASE (APB1PERIPH_BASE + 0x3C00U) #define I2S3ext_BASE (APB1PERIPH_BASE + 0x4000U) #define USART2_BASE (APB1PERIPH_BASE + 0x4400U) #define USART3_BASE (APB1PERIPH_BASE + 0x4800U) #define UART4_BASE (APB1PERIPH_BASE + 0x4C00U) #define UART5_BASE (APB1PERIPH_BASE + 0x5000U) #define I2C1_BASE (APB1PERIPH_BASE + 0x5400U) #define I2C2_BASE (APB1PERIPH_BASE + 0x5800U) #define I2C3_BASE (APB1PERIPH_BASE + 0x5C00U) #define CAN1_BASE (APB1PERIPH_BASE + 0x6400U) #define CAN2_BASE (APB1PERIPH_BASE + 0x6800U) #define PWR_BASE (APB1PERIPH_BASE + 0x7000U) #define DAC_BASE (APB1PERIPH_BASE + 0x7400U) #define UART7_BASE (APB1PERIPH_BASE + 0x7800U) #define UART8_BASE (APB1PERIPH_BASE + 0x7C00U) /*!< APB2 peripherals */ #define TIM1_BASE (APB2PERIPH_BASE + 0x0000U) #define TIM8_BASE (APB2PERIPH_BASE + 0x0400U) #define USART1_BASE (APB2PERIPH_BASE + 0x1000U) #define USART6_BASE (APB2PERIPH_BASE + 0x1400U) #define ADC1_BASE (APB2PERIPH_BASE + 0x2000U) #define ADC2_BASE (APB2PERIPH_BASE + 0x2100U) #define ADC3_BASE (APB2PERIPH_BASE + 0x2200U) #define ADC123_COMMON_BASE (APB2PERIPH_BASE + 0x2300U) /* Legacy define */ #define ADC_BASE ADC123_COMMON_BASE #define SDIO_BASE (APB2PERIPH_BASE + 0x2C00U) #define SPI1_BASE (APB2PERIPH_BASE + 0x3000U) #define SPI4_BASE (APB2PERIPH_BASE + 0x3400U) #define SYSCFG_BASE (APB2PERIPH_BASE + 0x3800U) #define EXTI_BASE (APB2PERIPH_BASE + 0x3C00U) #define TIM9_BASE (APB2PERIPH_BASE + 0x4000U) #define TIM10_BASE (APB2PERIPH_BASE + 0x4400U) #define TIM11_BASE (APB2PERIPH_BASE + 0x4800U) #define SPI5_BASE (APB2PERIPH_BASE + 0x5000U) #define SPI6_BASE (APB2PERIPH_BASE + 0x5400U) #define SAI1_BASE (APB2PERIPH_BASE + 0x5800U) #define SAI1_Block_A_BASE (SAI1_BASE + 0x004U) #define SAI1_Block_B_BASE (SAI1_BASE + 0x024U) #define LTDC_BASE (APB2PERIPH_BASE + 0x6800U) #define LTDC_Layer1_BASE (LTDC_BASE + 0x84U) #define LTDC_Layer2_BASE (LTDC_BASE + 0x104U) #define DSI_BASE (APB2PERIPH_BASE + 0x6C00U) /*!< AHB1 peripherals */ #define GPIOA_BASE (AHB1PERIPH_BASE + 0x0000U) #define GPIOB_BASE (AHB1PERIPH_BASE + 0x0400U) #define GPIOC_BASE (AHB1PERIPH_BASE + 0x0800U) #define GPIOD_BASE (AHB1PERIPH_BASE + 0x0C00U) #define GPIOE_BASE (AHB1PERIPH_BASE + 0x1000U) #define GPIOF_BASE (AHB1PERIPH_BASE + 0x1400U) #define GPIOG_BASE (AHB1PERIPH_BASE + 0x1800U) #define GPIOH_BASE (AHB1PERIPH_BASE + 0x1C00U) #define GPIOI_BASE (AHB1PERIPH_BASE + 0x2000U) #define GPIOJ_BASE (AHB1PERIPH_BASE + 0x2400U) #define GPIOK_BASE (AHB1PERIPH_BASE + 0x2800U) #define CRC_BASE (AHB1PERIPH_BASE + 0x3000U) #define RCC_BASE (AHB1PERIPH_BASE + 0x3800U) #define FLASH_R_BASE (AHB1PERIPH_BASE + 0x3C00U) #define DMA1_BASE (AHB1PERIPH_BASE + 0x6000U) #define DMA1_Stream0_BASE (DMA1_BASE + 0x010U) #define DMA1_Stream1_BASE (DMA1_BASE + 0x028U) #define DMA1_Stream2_BASE (DMA1_BASE + 0x040U) #define DMA1_Stream3_BASE (DMA1_BASE + 0x058U) #define DMA1_Stream4_BASE (DMA1_BASE + 0x070U) #define DMA1_Stream5_BASE (DMA1_BASE + 0x088U) #define DMA1_Stream6_BASE (DMA1_BASE + 0x0A0U) #define DMA1_Stream7_BASE (DMA1_BASE + 0x0B8U) #define DMA2_BASE (AHB1PERIPH_BASE + 0x6400U) #define DMA2_Stream0_BASE (DMA2_BASE + 0x010U) #define DMA2_Stream1_BASE (DMA2_BASE + 0x028U) #define DMA2_Stream2_BASE (DMA2_BASE + 0x040U) #define DMA2_Stream3_BASE (DMA2_BASE + 0x058U) #define DMA2_Stream4_BASE (DMA2_BASE + 0x070U) #define DMA2_Stream5_BASE (DMA2_BASE + 0x088U) #define DMA2_Stream6_BASE (DMA2_BASE + 0x0A0U) #define DMA2_Stream7_BASE (DMA2_BASE + 0x0B8U) #define ETH_BASE (AHB1PERIPH_BASE + 0x8000U) #define ETH_MAC_BASE (ETH_BASE) #define ETH_MMC_BASE (ETH_BASE + 0x0100U) #define ETH_PTP_BASE (ETH_BASE + 0x0700U) #define ETH_DMA_BASE (ETH_BASE + 0x1000U) #define DMA2D_BASE (AHB1PERIPH_BASE + 0xB000U) /*!< AHB2 peripherals */ #define DCMI_BASE (AHB2PERIPH_BASE + 0x50000U) #define RNG_BASE (AHB2PERIPH_BASE + 0x60800U) /*!< FMC Bankx registers base address */ #define FMC_Bank1_R_BASE (FMC_R_BASE + 0x0000U) #define FMC_Bank1E_R_BASE (FMC_R_BASE + 0x0104U) #define FMC_Bank3_R_BASE (FMC_R_BASE + 0x0080U) #define FMC_Bank5_6_R_BASE (FMC_R_BASE + 0x0140U) /*!< Debug MCU registers base address */ #define DBGMCU_BASE 0xE0042000U /*!< USB registers base address */ #define USB_OTG_HS_PERIPH_BASE 0x40040000U #define USB_OTG_FS_PERIPH_BASE 0x50000000U #define USB_OTG_GLOBAL_BASE 0x000U #define USB_OTG_DEVICE_BASE 0x800U #define USB_OTG_IN_ENDPOINT_BASE 0x900U #define USB_OTG_OUT_ENDPOINT_BASE 0xB00U #define USB_OTG_EP_REG_SIZE 0x20U #define USB_OTG_HOST_BASE 0x400U #define USB_OTG_HOST_PORT_BASE 0x440U #define USB_OTG_HOST_CHANNEL_BASE 0x500U #define USB_OTG_HOST_CHANNEL_SIZE 0x20U #define USB_OTG_PCGCCTL_BASE 0xE00U #define USB_OTG_FIFO_BASE 0x1000U #define USB_OTG_FIFO_SIZE 0x1000U #define UID_BASE 0x1FFF7A10U /*!< Unique device ID register base address */ #define FLASHSIZE_BASE 0x1FFF7A22U /*!< FLASH Size register base address */ #define PACKAGE_BASE 0x1FFF7BF0U /*!< Package size register base address */ /** * @} */ /** @addtogroup Peripheral_declaration * @{ */ #define TIM2 ((TIM_TypeDef *) TIM2_BASE) #define TIM3 ((TIM_TypeDef *) TIM3_BASE) #define TIM4 ((TIM_TypeDef *) TIM4_BASE) #define TIM5 ((TIM_TypeDef *) TIM5_BASE) #define TIM6 ((TIM_TypeDef *) TIM6_BASE) #define TIM7 ((TIM_TypeDef *) TIM7_BASE) #define TIM12 ((TIM_TypeDef *) TIM12_BASE) #define TIM13 ((TIM_TypeDef *) TIM13_BASE) #define TIM14 ((TIM_TypeDef *) TIM14_BASE) #define RTC ((RTC_TypeDef *) RTC_BASE) #define WWDG ((WWDG_TypeDef *) WWDG_BASE) #define IWDG ((IWDG_TypeDef *) IWDG_BASE) #define I2S2ext ((SPI_TypeDef *) I2S2ext_BASE) #define SPI2 ((SPI_TypeDef *) SPI2_BASE) #define SPI3 ((SPI_TypeDef *) SPI3_BASE) #define I2S3ext ((SPI_TypeDef *) I2S3ext_BASE) #define USART2 ((USART_TypeDef *) USART2_BASE) #define USART3 ((USART_TypeDef *) USART3_BASE) #define UART4 ((USART_TypeDef *) UART4_BASE) #define UART5 ((USART_TypeDef *) UART5_BASE) #define I2C1 ((I2C_TypeDef *) I2C1_BASE) #define I2C2 ((I2C_TypeDef *) I2C2_BASE) #define I2C3 ((I2C_TypeDef *) I2C3_BASE) #define CAN1 ((CAN_TypeDef *) CAN1_BASE) #define CAN2 ((CAN_TypeDef *) CAN2_BASE) #define PWR ((PWR_TypeDef *) PWR_BASE) #define DAC1 ((DAC_TypeDef *) DAC_BASE) #define DAC ((DAC_TypeDef *) DAC_BASE) /* Kept for legacy purpose */ #define UART7 ((USART_TypeDef *) UART7_BASE) #define UART8 ((USART_TypeDef *) UART8_BASE) #define TIM1 ((TIM_TypeDef *) TIM1_BASE) #define TIM8 ((TIM_TypeDef *) TIM8_BASE) #define USART1 ((USART_TypeDef *) USART1_BASE) #define USART6 ((USART_TypeDef *) USART6_BASE) #define ADC1 ((ADC_TypeDef *) ADC1_BASE) #define ADC2 ((ADC_TypeDef *) ADC2_BASE) #define ADC3 ((ADC_TypeDef *) ADC3_BASE) #define ADC123_COMMON ((ADC_Common_TypeDef *) ADC123_COMMON_BASE) /* Legacy define */ #define ADC ADC123_COMMON #define SDIO ((SDIO_TypeDef *) SDIO_BASE) #define SPI1 ((SPI_TypeDef *) SPI1_BASE) #define SPI4 ((SPI_TypeDef *) SPI4_BASE) #define SYSCFG ((SYSCFG_TypeDef *) SYSCFG_BASE) #define EXTI ((EXTI_TypeDef *) EXTI_BASE) #define TIM9 ((TIM_TypeDef *) TIM9_BASE) #define TIM10 ((TIM_TypeDef *) TIM10_BASE) #define TIM11 ((TIM_TypeDef *) TIM11_BASE) #define SPI5 ((SPI_TypeDef *) SPI5_BASE) #define SPI6 ((SPI_TypeDef *) SPI6_BASE) #define SAI1 ((SAI_TypeDef *) SAI1_BASE) #define SAI1_Block_A ((SAI_Block_TypeDef *)SAI1_Block_A_BASE) #define SAI1_Block_B ((SAI_Block_TypeDef *)SAI1_Block_B_BASE) #define LTDC ((LTDC_TypeDef *)LTDC_BASE) #define LTDC_Layer1 ((LTDC_Layer_TypeDef *)LTDC_Layer1_BASE) #define LTDC_Layer2 ((LTDC_Layer_TypeDef *)LTDC_Layer2_BASE) #define DSI ((DSI_TypeDef *)DSI_BASE) #define GPIOA ((GPIO_TypeDef *) GPIOA_BASE) #define GPIOB ((GPIO_TypeDef *) GPIOB_BASE) #define GPIOC ((GPIO_TypeDef *) GPIOC_BASE) #define GPIOD ((GPIO_TypeDef *) GPIOD_BASE) #define GPIOE ((GPIO_TypeDef *) GPIOE_BASE) #define GPIOF ((GPIO_TypeDef *) GPIOF_BASE) #define GPIOG ((GPIO_TypeDef *) GPIOG_BASE) #define GPIOH ((GPIO_TypeDef *) GPIOH_BASE) #define GPIOI ((GPIO_TypeDef *) GPIOI_BASE) #define GPIOJ ((GPIO_TypeDef *) GPIOJ_BASE) #define GPIOK ((GPIO_TypeDef *) GPIOK_BASE) #define CRC ((CRC_TypeDef *) CRC_BASE) #define RCC ((RCC_TypeDef *) RCC_BASE) #define FLASH ((FLASH_TypeDef *) FLASH_R_BASE) #define DMA1 ((DMA_TypeDef *) DMA1_BASE) #define DMA1_Stream0 ((DMA_Stream_TypeDef *) DMA1_Stream0_BASE) #define DMA1_Stream1 ((DMA_Stream_TypeDef *) DMA1_Stream1_BASE) #define DMA1_Stream2 ((DMA_Stream_TypeDef *) DMA1_Stream2_BASE) #define DMA1_Stream3 ((DMA_Stream_TypeDef *) DMA1_Stream3_BASE) #define DMA1_Stream4 ((DMA_Stream_TypeDef *) DMA1_Stream4_BASE) #define DMA1_Stream5 ((DMA_Stream_TypeDef *) DMA1_Stream5_BASE) #define DMA1_Stream6 ((DMA_Stream_TypeDef *) DMA1_Stream6_BASE) #define DMA1_Stream7 ((DMA_Stream_TypeDef *) DMA1_Stream7_BASE) #define DMA2 ((DMA_TypeDef *) DMA2_BASE) #define DMA2_Stream0 ((DMA_Stream_TypeDef *) DMA2_Stream0_BASE) #define DMA2_Stream1 ((DMA_Stream_TypeDef *) DMA2_Stream1_BASE) #define DMA2_Stream2 ((DMA_Stream_TypeDef *) DMA2_Stream2_BASE) #define DMA2_Stream3 ((DMA_Stream_TypeDef *) DMA2_Stream3_BASE) #define DMA2_Stream4 ((DMA_Stream_TypeDef *) DMA2_Stream4_BASE) #define DMA2_Stream5 ((DMA_Stream_TypeDef *) DMA2_Stream5_BASE) #define DMA2_Stream6 ((DMA_Stream_TypeDef *) DMA2_Stream6_BASE) #define DMA2_Stream7 ((DMA_Stream_TypeDef *) DMA2_Stream7_BASE) #define ETH ((ETH_TypeDef *) ETH_BASE) #define DMA2D ((DMA2D_TypeDef *)DMA2D_BASE) #define DCMI ((DCMI_TypeDef *) DCMI_BASE) #define RNG ((RNG_TypeDef *) RNG_BASE) #define FMC_Bank1 ((FMC_Bank1_TypeDef *) FMC_Bank1_R_BASE) #define FMC_Bank1E ((FMC_Bank1E_TypeDef *) FMC_Bank1E_R_BASE) #define FMC_Bank3 ((FMC_Bank3_TypeDef *) FMC_Bank3_R_BASE) #define FMC_Bank5_6 ((FMC_Bank5_6_TypeDef *) FMC_Bank5_6_R_BASE) #define QUADSPI ((QUADSPI_TypeDef *) QSPI_R_BASE) #define DBGMCU ((DBGMCU_TypeDef *) DBGMCU_BASE) #define USB_OTG_FS ((USB_OTG_GlobalTypeDef *) USB_OTG_FS_PERIPH_BASE) #define USB_OTG_HS ((USB_OTG_GlobalTypeDef *) USB_OTG_HS_PERIPH_BASE) /** * @} */ /** @addtogroup Exported_constants * @{ */ /** @addtogroup Peripheral_Registers_Bits_Definition * @{ */ /******************************************************************************/ /* Peripheral Registers_Bits_Definition */ /******************************************************************************/ /******************************************************************************/ /* */ /* Analog to Digital Converter */ /* */ /******************************************************************************/ /* * @brief Specific device feature definitions (not present on all devices in the STM32F4 serie) */ #define ADC_MULTIMODE_SUPPORT /*!
© COPYRIGHT(c) 2017 STMicroelectronics
* * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. Neither the name of STMicroelectronics nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ /** @addtogroup CMSIS * @{ */ /** @addtogroup stm32f4xx * @{ */ #ifndef __STM32F4xx_H #define __STM32F4xx_H #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ /** @addtogroup Library_configuration_section * @{ */ /** * @brief STM32 Family */ #if !defined (STM32F4) #define STM32F4 #endif /* STM32F4 */ /* Uncomment the line below according to the target STM32 device used in your application */ #if !defined (STM32F405xx) && !defined (STM32F415xx) && !defined (STM32F407xx) && !defined (STM32F417xx) && \ !defined (STM32F427xx) && !defined (STM32F437xx) && !defined (STM32F429xx) && !defined (STM32F439xx) && \ !defined (STM32F401xC) && !defined (STM32F401xE) && !defined (STM32F410Tx) && !defined (STM32F410Cx) && \ !defined (STM32F410Rx) && !defined (STM32F411xE) && !defined (STM32F446xx) && !defined (STM32F469xx) && \ !defined (STM32F479xx) && !defined (STM32F412Cx) && !defined (STM32F412Rx) && !defined (STM32F412Vx) && \ !defined (STM32F412Zx) && !defined (STM32F413xx) && !defined (STM32F423xx) /* #define STM32F405xx */ /*!< STM32F405RG, STM32F405VG and STM32F405ZG Devices */ /* #define STM32F415xx */ /*!< STM32F415RG, STM32F415VG and STM32F415ZG Devices */ /* #define STM32F407xx */ /*!< STM32F407VG, STM32F407VE, STM32F407ZG, STM32F407ZE, STM32F407IG and STM32F407IE Devices */ /* #define STM32F417xx */ /*!< STM32F417VG, STM32F417VE, STM32F417ZG, STM32F417ZE, STM32F417IG and STM32F417IE Devices */ /* #define STM32F427xx */ /*!< STM32F427VG, STM32F427VI, STM32F427ZG, STM32F427ZI, STM32F427IG and STM32F427II Devices */ /* #define STM32F437xx */ /*!< STM32F437VG, STM32F437VI, STM32F437ZG, STM32F437ZI, STM32F437IG and STM32F437II Devices */ /* #define STM32F429xx */ /*!< STM32F429VG, STM32F429VI, STM32F429ZG, STM32F429ZI, STM32F429BG, STM32F429BI, STM32F429NG, STM32F439NI, STM32F429IG and STM32F429II Devices */ /* #define STM32F439xx */ /*!< STM32F439VG, STM32F439VI, STM32F439ZG, STM32F439ZI, STM32F439BG, STM32F439BI, STM32F439NG, STM32F439NI, STM32F439IG and STM32F439II Devices */ /* #define STM32F401xC */ /*!< STM32F401CB, STM32F401CC, STM32F401RB, STM32F401RC, STM32F401VB and STM32F401VC Devices */ /* #define STM32F401xE */ /*!< STM32F401CD, STM32F401RD, STM32F401VD, STM32F401CE, STM32F401RE and STM32F401VE Devices */ /* #define STM32F410Tx */ /*!< STM32F410T8 and STM32F410TB Devices */ /* #define STM32F410Cx */ /*!< STM32F410C8 and STM32F410CB Devices */ /* #define STM32F410Rx */ /*!< STM32F410R8 and STM32F410RB Devices */ /* #define STM32F411xE */ /*!< STM32F411CC, STM32F411RC, STM32F411VC, STM32F411CE, STM32F411RE and STM32F411VE Devices */ /* #define STM32F446xx */ /*!< STM32F446MC, STM32F446ME, STM32F446RC, STM32F446RE, STM32F446VC, STM32F446VE, STM32F446ZC, and STM32F446ZE Devices */ /* #define STM32F469xx */ /*!< STM32F469AI, STM32F469II, STM32F469BI, STM32F469NI, STM32F469AG, STM32F469IG, STM32F469BG, STM32F469NG, STM32F469AE, STM32F469IE, STM32F469BE and STM32F469NE Devices */ /* #define STM32F479xx */ /*!< STM32F479AI, STM32F479II, STM32F479BI, STM32F479NI, STM32F479AG, STM32F479IG, STM32F479BG and STM32F479NG Devices */ /* #define STM32F412Cx */ /*!< STM32F412CEU and STM32F412CGU Devices */ /* #define STM32F412Zx */ /*!< STM32F412ZET, STM32F412ZGT, STM32F412ZEJ and STM32F412ZGJ Devices */ /* #define STM32F412Vx */ /*!< STM32F412VET, STM32F412VGT, STM32F412VEH and STM32F412VGH Devices */ /* #define STM32F412Rx */ /*!< STM32F412RET, STM32F412RGT, STM32F412REY and STM32F412RGY Devices */ /* #define STM32F413xx */ /*!< STM32F413CH, STM32F413MH, STM32F413RH, STM32F413VH, STM32F413ZH, STM32F413CG, STM32F413MG, STM32F413RG, STM32F413VG and STM32F413ZG Devices */ /* #define STM32F423xx */ /*!< STM32F423CH, STM32F423RH, STM32F423VH and STM32F423ZH Devices */ #endif /* Tip: To avoid modifying this file each time you need to switch between these devices, you can define the device in your toolchain compiler preprocessor. */ #if !defined (USE_HAL_DRIVER) /** * @brief Comment the line below if you will not use the peripherals drivers. In this case, these drivers will not be included and the application code will be based on direct access to peripherals registers */ /*#define USE_HAL_DRIVER */ #endif /* USE_HAL_DRIVER */ /** * @brief CMSIS version number V2.6.3 */ #define __STM32F4xx_CMSIS_VERSION_MAIN (0x02U) /*!< [31:24] main version */ #define __STM32F4xx_CMSIS_VERSION_SUB1 (0x06U) /*!< [23:16] sub1 version */ #define __STM32F4xx_CMSIS_VERSION_SUB2 (0x03U) /*!< [15:8] sub2 version */ #define __STM32F4xx_CMSIS_VERSION_RC (0x00U) /*!< [7:0] release candidate */ #define __STM32F4xx_CMSIS_VERSION ((__STM32F4xx_CMSIS_VERSION_MAIN << 24)\ |(__STM32F4xx_CMSIS_VERSION_SUB1 << 16)\ |(__STM32F4xx_CMSIS_VERSION_SUB2 << 8 )\ |(__STM32F4xx_CMSIS_VERSION)) /** * @} */ /** @addtogroup Device_Included * @{ */ #if defined(STM32F405xx) #include "stm32f405xx.h" #elif defined(STM32F415xx) #include "stm32f415xx.h" #elif defined(STM32F407xx) #include "stm32f407xx.h" #elif defined(STM32F417xx) #include "stm32f417xx.h" #elif defined(STM32F427xx) #include "stm32f427xx.h" #elif defined(STM32F437xx) #include "stm32f437xx.h" #elif defined(STM32F429xx) #include "stm32f429xx.h" #elif defined(STM32F439xx) #include "stm32f439xx.h" #elif defined(STM32F401xC) #include "stm32f401xc.h" #elif defined(STM32F401xE) #include "stm32f401xe.h" #elif defined(STM32F410Tx) #include "stm32f410tx.h" #elif defined(STM32F410Cx) #include "stm32f410cx.h" #elif defined(STM32F410Rx) #include "stm32f410rx.h" #elif defined(STM32F411xE) #include "stm32f411xe.h" #elif defined(STM32F446xx) #include "stm32f446xx.h" #elif defined(STM32F469xx) #include "stm32f469xx.h" #elif defined(STM32F479xx) #include "stm32f479xx.h" #elif defined(STM32F412Cx) #include "stm32f412cx.h" #elif defined(STM32F412Zx) #include "stm32f412zx.h" #elif defined(STM32F412Rx) #include "stm32f412rx.h" #elif defined(STM32F412Vx) #include "stm32f412vx.h" #elif defined(STM32F413xx) #include "stm32f413xx.h" #elif defined(STM32F423xx) #include "stm32f423xx.h" #else #error "Please select first the target STM32F4xx device used in your application (in stm32f4xx.h file)" #endif /** * @} */ /** @addtogroup Exported_types * @{ */ typedef enum { RESET = 0U, SET = !RESET } FlagStatus, ITStatus; typedef enum { DISABLE = 0U, ENABLE = !DISABLE } FunctionalState; #define IS_FUNCTIONAL_STATE(STATE) (((STATE) == DISABLE) || ((STATE) == ENABLE)) typedef enum { SUCCESS = 0U, ERROR = !SUCCESS } ErrorStatus; /** * @} */ /** @addtogroup Exported_macro * @{ */ #define SET_BIT(REG, BIT) ((REG) |= (BIT)) #define CLEAR_BIT(REG, BIT) ((REG) &= ~(BIT)) #define READ_BIT(REG, BIT) ((REG) & (BIT)) #define CLEAR_REG(REG) ((REG) = (0x0)) #define WRITE_REG(REG, VAL) ((REG) = (VAL)) #define READ_REG(REG) ((REG)) #define MODIFY_REG(REG, CLEARMASK, SETMASK) WRITE_REG((REG), (((READ_REG(REG)) & (~(CLEARMASK))) | (SETMASK))) #define POSITION_VAL(VAL) (__CLZ(__RBIT(VAL))) /** * @} */ #if defined (USE_HAL_DRIVER) #include "stm32f4xx_hal.h" #endif /* USE_HAL_DRIVER */ #ifdef __cplusplus } #endif /* __cplusplus */ #endif /* __STM32F4xx_H */ /** * @} */ /** * @} */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ ================================================ FILE: sys/arch/stm32/hal/stm32f4xx_hal.c ================================================ /** ****************************************************************************** * @file stm32f4xx_hal.c * @author MCD Application Team * @version V1.7.1 * @date 14-April-2017 * @brief HAL module driver. * This is the common part of the HAL initialization * @verbatim ============================================================================== ##### How to use this driver ##### ============================================================================== [..] The common HAL driver contains a set of generic and common APIs that can be used by the PPP peripheral drivers and the user to start using the HAL. [..] The HAL contains two APIs' categories: (+) Common HAL APIs (+) Services HAL APIs @endverbatim ****************************************************************************** * @attention * *

© COPYRIGHT(c) 2017 STMicroelectronics

* * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. Neither the name of STMicroelectronics nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ /* Includes ------------------------------------------------------------------*/ #include "stm32f4xx_hal.h" #include "stm32f4xx_ll_system.h" // XXX For LL_FLASH_* functions. /** @addtogroup STM32F4xx_HAL_Driver * @{ */ /** @defgroup HAL HAL * @brief HAL module driver. * @{ */ /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ /** @addtogroup HAL_Private_Constants * @{ */ /** * @brief STM32F4xx HAL Driver version number V1.7.1 */ #define __STM32F4xx_HAL_VERSION_MAIN (0x01U) /*!< [31:24] main version */ #define __STM32F4xx_HAL_VERSION_SUB1 (0x07U) /*!< [23:16] sub1 version */ #define __STM32F4xx_HAL_VERSION_SUB2 (0x01U) /*!< [15:8] sub2 version */ #define __STM32F4xx_HAL_VERSION_RC (0x00U) /*!< [7:0] release candidate */ #define __STM32F4xx_HAL_VERSION ((__STM32F4xx_HAL_VERSION_MAIN << 24U)\ |(__STM32F4xx_HAL_VERSION_SUB1 << 16U)\ |(__STM32F4xx_HAL_VERSION_SUB2 << 8U )\ |(__STM32F4xx_HAL_VERSION_RC)) #define IDCODE_DEVID_MASK 0x00000FFFU /* ------------ RCC registers bit address in the alias region ----------- */ #define SYSCFG_OFFSET (SYSCFG_BASE - PERIPH_BASE) /* --- MEMRMP Register ---*/ /* Alias word address of UFB_MODE bit */ #define MEMRMP_OFFSET SYSCFG_OFFSET #define UFB_MODE_BIT_NUMBER POSITION_VAL(SYSCFG_MEMRMP_UFB_MODE) #define UFB_MODE_BB (uint32_t)(PERIPH_BB_BASE + (MEMRMP_OFFSET * 32U) + (UFB_MODE_BIT_NUMBER * 4U)) /* --- CMPCR Register ---*/ /* Alias word address of CMP_PD bit */ #define CMPCR_OFFSET (SYSCFG_OFFSET + 0x20U) #define CMP_PD_BIT_NUMBER POSITION_VAL(SYSCFG_CMPCR_CMP_PD) #define CMPCR_CMP_PD_BB (uint32_t)(PERIPH_BB_BASE + (CMPCR_OFFSET * 32U) + (CMP_PD_BIT_NUMBER * 4U)) /* --- MCHDLYCR Register ---*/ /* Alias word address of BSCKSEL bit */ #define MCHDLYCR_OFFSET (SYSCFG_OFFSET + 0x30U) #define BSCKSEL_BIT_NUMBER POSITION_VAL(SYSCFG_MCHDLYCR_BSCKSEL) #define MCHDLYCR_BSCKSEL_BB (uint32_t)(PERIPH_BB_BASE + (MCHDLYCR_OFFSET * 32U) + (BSCKSEL_BIT_NUMBER * 4U)) /** * @} */ /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ /** @addtogroup HAL_Private_Variables * @{ */ __IO uint32_t uwTick; /** * @} */ /* Private function prototypes -----------------------------------------------*/ /* Private functions ---------------------------------------------------------*/ /** @defgroup HAL_Exported_Functions HAL Exported Functions * @{ */ /** @defgroup HAL_Exported_Functions_Group1 Initialization and de-initialization Functions * @brief Initialization and de-initialization functions * @verbatim =============================================================================== ##### Initialization and de-initialization functions ##### =============================================================================== [..] This section provides functions allowing to: (+) Initializes the Flash interface the NVIC allocation and initial clock configuration. It initializes the systick also when timeout is needed and the backup domain when enabled. (+) de-Initializes common part of the HAL (+) Configure The time base source to have 1ms time base with a dedicated Tick interrupt priority. (++) Systick timer is used by default as source of time base, but user can eventually implement his proper time base source (a general purpose timer for example or other time source), keeping in mind that Time base duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and handled in milliseconds basis. (++) Time base configuration function (HAL_InitTick ()) is called automatically at the beginning of the program after reset by HAL_Init() or at any time when clock is configured, by HAL_RCC_ClockConfig(). (++) Source of time base is configured to generate interrupts at regular time intervals. Care must be taken if HAL_Delay() is called from a peripheral ISR process, the Tick interrupt line must have higher priority (numerically lower) than the peripheral interrupt. Otherwise the caller ISR process will be blocked. (++) functions affecting time base configurations are declared as __weak to make override possible in case of other implementations in user file. @endverbatim * @{ */ /** * @brief This function is used to initialize the HAL Library; it must be the first * instruction to be executed in the main program (before to call any other * HAL function), it performs the following: * Configure the Flash prefetch, instruction and Data caches. * Configures the SysTick to generate an interrupt each 1 millisecond, * which is clocked by the HSI (at this stage, the clock is not yet * configured and thus the system is running from the internal HSI at 16 MHz). * Set NVIC Group Priority to 4. * Calls the HAL_MspInit() callback function defined in user file * "stm32f4xx_hal_msp.c" to do the global low level hardware initialization * * @note SysTick is used as time base for the HAL_Delay() function, the application * need to ensure that the SysTick time base is always set to 1 millisecond * to have correct HAL operation. * @retval HAL status */ HAL_StatusTypeDef HAL_Init(void) { /* Configure Flash prefetch, Instruction cache, Data cache */ #if (INSTRUCTION_CACHE_ENABLE != 0U) LL_FLASH_EnableInstCache(); // XXX __HAL_FLASH_INSTRUCTION_CACHE_ENABLE(); #endif /* INSTRUCTION_CACHE_ENABLE */ #if (DATA_CACHE_ENABLE != 0U) LL_FLASH_EnableDataCache(); // XXX __HAL_FLASH_DATA_CACHE_ENABLE(); #endif /* DATA_CACHE_ENABLE */ #if (PREFETCH_ENABLE != 0U) LL_FLASH_EnablePrefetch(); // XXX __HAL_FLASH_PREFETCH_BUFFER_ENABLE(); #endif /* PREFETCH_ENABLE */ #ifdef __thumb2__ /* Set Interrupt Group Priority */ NVIC_SetPriorityGrouping(0); // XXX HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4); #endif /* Use systick as time base source and configure 1ms tick (default clock after Reset is HSI) */ // XXX HAL_InitTick(TICK_INT_PRIORITY); /* Init the low level hardware */ HAL_MspInit(); /* Return function status */ return HAL_OK; } /** * @brief This function de-Initializes common part of the HAL and stops the systick. * This function is optional. * @retval HAL status */ HAL_StatusTypeDef HAL_DeInit(void) { #if 0 // XXX to change to LL_RCC functions. /* Reset of all peripherals */ __HAL_RCC_APB1_FORCE_RESET(); __HAL_RCC_APB1_RELEASE_RESET(); __HAL_RCC_APB2_FORCE_RESET(); __HAL_RCC_APB2_RELEASE_RESET(); __HAL_RCC_AHB1_FORCE_RESET(); __HAL_RCC_AHB1_RELEASE_RESET(); __HAL_RCC_AHB2_FORCE_RESET(); __HAL_RCC_AHB2_RELEASE_RESET(); __HAL_RCC_AHB3_FORCE_RESET(); __HAL_RCC_AHB3_RELEASE_RESET(); #endif // XXX /* De-Init the low level hardware */ HAL_MspDeInit(); /* Return function status */ return HAL_OK; } /** * @brief Initializes the MSP. * @retval None */ __weak void HAL_MspInit(void) { /* NOTE : This function Should not be modified, when the callback is needed, the HAL_MspInit could be implemented in the user file */ } /** * @brief DeInitializes the MSP. * @retval None */ __weak void HAL_MspDeInit(void) { /* NOTE : This function Should not be modified, when the callback is needed, the HAL_MspDeInit could be implemented in the user file */ } /** * @brief This function configures the source of the time base. * The time source is configured to have 1ms time base with a dedicated * Tick interrupt priority. * @note This function is called automatically at the beginning of program after * reset by HAL_Init() or at any time when clock is reconfigured by HAL_RCC_ClockConfig(). * @note In the default implementation, SysTick timer is the source of time base. * It is used to generate interrupts at regular time intervals. * Care must be taken if HAL_Delay() is called from a peripheral ISR process, * The the SysTick interrupt must have higher priority (numerically lower) * than the peripheral interrupt. Otherwise the caller ISR process will be blocked. * The function is declared as __weak to be overwritten in case of other * implementation in user file. * @param TickPriority: Tick interrupt priority. * @retval HAL status */ __weak HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority) { /*Configure the SysTick to have interrupt in 1ms time basis*/ // XXX HAL_SYSTICK_Config(SystemCoreClock/1000U); SysTick_Config(SystemCoreClock/1000U); /*Configure the SysTick IRQ priority */ // XXX HAL_NVIC_SetPriority(SysTick_IRQn, TickPriority, 0U); NVIC_SetPriority(SysTick_IRQn, TickPriority); /* Return function status */ return HAL_OK; } /** * @} */ /** @defgroup HAL_Exported_Functions_Group2 HAL Control functions * @brief HAL Control functions * @verbatim =============================================================================== ##### HAL Control functions ##### =============================================================================== [..] This section provides functions allowing to: (+) Provide a tick value in millisecond (+) Provide a blocking delay in millisecond (+) Suspend the time base source interrupt (+) Resume the time base source interrupt (+) Get the HAL API driver version (+) Get the device identifier (+) Get the device revision identifier (+) Enable/Disable Debug module during SLEEP mode (+) Enable/Disable Debug module during STOP mode (+) Enable/Disable Debug module during STANDBY mode @endverbatim * @{ */ /** * @brief This function is called to increment a global variable "uwTick" * used as application time base. * @note In the default implementation, this variable is incremented each 1ms * in Systick ISR. * @note This function is declared as __weak to be overwritten in case of other * implementations in user file. * @retval None */ __weak void HAL_IncTick(void) { uwTick++; } /** * @brief Provides a tick value in millisecond. * @note This function is declared as __weak to be overwritten in case of other * implementations in user file. * @retval tick value */ __weak uint32_t HAL_GetTick(void) { return uwTick; } /** * @brief This function provides minimum delay (in milliseconds) based * on variable incremented. * @note In the default implementation , SysTick timer is the source of time base. * It is used to generate interrupts at regular time intervals where uwTick * is incremented. * @note This function is declared as __weak to be overwritten in case of other * implementations in user file. * @param Delay: specifies the delay time length, in milliseconds. * @retval None */ __weak void HAL_Delay(__IO uint32_t Delay) { uint32_t tickstart = HAL_GetTick(); uint32_t wait = Delay; /* Add a period to guarantee minimum wait */ if (wait < HAL_MAX_DELAY) { wait++; } while((HAL_GetTick() - tickstart) < wait) { } } /** * @brief Suspend Tick increment. * @note In the default implementation , SysTick timer is the source of time base. It is * used to generate interrupts at regular time intervals. Once HAL_SuspendTick() * is called, the SysTick interrupt will be disabled and so Tick increment * is suspended. * @note This function is declared as __weak to be overwritten in case of other * implementations in user file. * @retval None */ __weak void HAL_SuspendTick(void) { /* Disable SysTick Interrupt */ SysTick->CTRL &= ~SysTick_CTRL_TICKINT_Msk; } /** * @brief Resume Tick increment. * @note In the default implementation , SysTick timer is the source of time base. It is * used to generate interrupts at regular time intervals. Once HAL_ResumeTick() * is called, the SysTick interrupt will be enabled and so Tick increment * is resumed. * @note This function is declared as __weak to be overwritten in case of other * implementations in user file. * @retval None */ __weak void HAL_ResumeTick(void) { /* Enable SysTick Interrupt */ SysTick->CTRL |= SysTick_CTRL_TICKINT_Msk; } /** * @brief Returns the HAL revision * @retval version : 0xXYZR (8bits for each decimal, R for RC) */ uint32_t HAL_GetHalVersion(void) { return __STM32F4xx_HAL_VERSION; } /** * @brief Returns the device revision identifier. * @retval Device revision identifier */ uint32_t HAL_GetREVID(void) { return((DBGMCU->IDCODE) >> 16U); } /** * @brief Returns the device identifier. * @retval Device identifier */ uint32_t HAL_GetDEVID(void) { return((DBGMCU->IDCODE) & IDCODE_DEVID_MASK); } /** * @brief Enable the Debug Module during SLEEP mode * @retval None */ void HAL_DBGMCU_EnableDBGSleepMode(void) { SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_SLEEP); } /** * @brief Disable the Debug Module during SLEEP mode * @retval None */ void HAL_DBGMCU_DisableDBGSleepMode(void) { CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_SLEEP); } /** * @brief Enable the Debug Module during STOP mode * @retval None */ void HAL_DBGMCU_EnableDBGStopMode(void) { SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STOP); } /** * @brief Disable the Debug Module during STOP mode * @retval None */ void HAL_DBGMCU_DisableDBGStopMode(void) { CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STOP); } /** * @brief Enable the Debug Module during STANDBY mode * @retval None */ void HAL_DBGMCU_EnableDBGStandbyMode(void) { SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STANDBY); } /** * @brief Disable the Debug Module during STANDBY mode * @retval None */ void HAL_DBGMCU_DisableDBGStandbyMode(void) { CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STANDBY); } /** * @brief Enables the I/O Compensation Cell. * @note The I/O compensation cell can be used only when the device supply * voltage ranges from 2.4 to 3.6 V. * @retval None */ void HAL_EnableCompensationCell(void) { *(__IO uint32_t *)CMPCR_CMP_PD_BB = (uint32_t)ENABLE; } /** * @brief Power-down the I/O Compensation Cell. * @note The I/O compensation cell can be used only when the device supply * voltage ranges from 2.4 to 3.6 V. * @retval None */ void HAL_DisableCompensationCell(void) { *(__IO uint32_t *)CMPCR_CMP_PD_BB = (uint32_t)DISABLE; } /** * @brief Return the unique device identifier (UID based on 96 bits) * @param UID: pointer to 3 words array. * @retval Device identifier */ void HAL_GetUID(uint32_t *UID) { UID[0] = (uint32_t)(READ_REG(*((uint32_t *)UID_BASE))); UID[1] = (uint32_t)(READ_REG(*((uint32_t *)(UID_BASE + 4U)))); UID[2] = (uint32_t)(READ_REG(*((uint32_t *)(UID_BASE + 8U)))); } #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx)|| defined(STM32F439xx) ||\ defined(STM32F469xx) || defined(STM32F479xx) /** * @brief Enables the Internal FLASH Bank Swapping. * * @note This function can be used only for STM32F42xxx/43xxx devices. * * @note Flash Bank2 mapped at 0x08000000 (and aliased @0x00000000) * and Flash Bank1 mapped at 0x08100000 (and aliased at 0x00100000) * * @retval None */ void HAL_EnableMemorySwappingBank(void) { *(__IO uint32_t *)UFB_MODE_BB = (uint32_t)ENABLE; } /** * @brief Disables the Internal FLASH Bank Swapping. * * @note This function can be used only for STM32F42xxx/43xxx devices. * * @note The default state : Flash Bank1 mapped at 0x08000000 (and aliased @0x00000000) * and Flash Bank2 mapped at 0x08100000 (and aliased at 0x00100000) * * @retval None */ void HAL_DisableMemorySwappingBank(void) { *(__IO uint32_t *)UFB_MODE_BB = (uint32_t)DISABLE; } #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F469xx || STM32F479xx */ /** * @} */ /** * @} */ /** * @} */ /** * @} */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ ================================================ FILE: sys/arch/stm32/hal/stm32f4xx_hal.h ================================================ /** ****************************************************************************** * @file stm32f4xx_hal.h * @author MCD Application Team * @version V1.7.1 * @date 14-April-2017 * @brief This file contains all the functions prototypes for the HAL * module driver. ****************************************************************************** * @attention * *

© COPYRIGHT(c) 2017 STMicroelectronics

* * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. Neither the name of STMicroelectronics nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __STM32F4xx_HAL_H #define __STM32F4xx_HAL_H #ifdef __cplusplus extern "C" { #endif /* Includes ------------------------------------------------------------------*/ #include "stm32f4xx_hal_conf.h" /** @addtogroup STM32F4xx_HAL_Driver * @{ */ /** @addtogroup HAL * @{ */ /* Exported types ------------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/ /* Exported macro ------------------------------------------------------------*/ /** @defgroup HAL_Exported_Macros HAL Exported Macros * @{ */ /** @brief Freeze/Unfreeze Peripherals in Debug mode */ #define __HAL_DBGMCU_FREEZE_TIM2() (DBGMCU->APB1FZ |= (DBGMCU_APB1_FZ_DBG_TIM2_STOP)) #define __HAL_DBGMCU_FREEZE_TIM3() (DBGMCU->APB1FZ |= (DBGMCU_APB1_FZ_DBG_TIM3_STOP)) #define __HAL_DBGMCU_FREEZE_TIM4() (DBGMCU->APB1FZ |= (DBGMCU_APB1_FZ_DBG_TIM4_STOP)) #define __HAL_DBGMCU_FREEZE_TIM5() (DBGMCU->APB1FZ |= (DBGMCU_APB1_FZ_DBG_TIM5_STOP)) #define __HAL_DBGMCU_FREEZE_TIM6() (DBGMCU->APB1FZ |= (DBGMCU_APB1_FZ_DBG_TIM6_STOP)) #define __HAL_DBGMCU_FREEZE_TIM7() (DBGMCU->APB1FZ |= (DBGMCU_APB1_FZ_DBG_TIM7_STOP)) #define __HAL_DBGMCU_FREEZE_TIM12() (DBGMCU->APB1FZ |= (DBGMCU_APB1_FZ_DBG_TIM12_STOP)) #define __HAL_DBGMCU_FREEZE_TIM13() (DBGMCU->APB1FZ |= (DBGMCU_APB1_FZ_DBG_TIM13_STOP)) #define __HAL_DBGMCU_FREEZE_TIM14() (DBGMCU->APB1FZ |= (DBGMCU_APB1_FZ_DBG_TIM14_STOP)) #define __HAL_DBGMCU_FREEZE_RTC() (DBGMCU->APB1FZ |= (DBGMCU_APB1_FZ_DBG_RTC_STOP)) #define __HAL_DBGMCU_FREEZE_WWDG() (DBGMCU->APB1FZ |= (DBGMCU_APB1_FZ_DBG_WWDG_STOP)) #define __HAL_DBGMCU_FREEZE_IWDG() (DBGMCU->APB1FZ |= (DBGMCU_APB1_FZ_DBG_IWDG_STOP)) #define __HAL_DBGMCU_FREEZE_I2C1_TIMEOUT() (DBGMCU->APB1FZ |= (DBGMCU_APB1_FZ_DBG_I2C1_SMBUS_TIMEOUT)) #define __HAL_DBGMCU_FREEZE_I2C2_TIMEOUT() (DBGMCU->APB1FZ |= (DBGMCU_APB1_FZ_DBG_I2C2_SMBUS_TIMEOUT)) #define __HAL_DBGMCU_FREEZE_I2C3_TIMEOUT() (DBGMCU->APB1FZ |= (DBGMCU_APB1_FZ_DBG_I2C3_SMBUS_TIMEOUT)) #define __HAL_DBGMCU_FREEZE_CAN1() (DBGMCU->APB1FZ |= (DBGMCU_APB1_FZ_DBG_CAN1_STOP)) #define __HAL_DBGMCU_FREEZE_CAN2() (DBGMCU->APB1FZ |= (DBGMCU_APB1_FZ_DBG_CAN2_STOP)) #define __HAL_DBGMCU_FREEZE_TIM1() (DBGMCU->APB2FZ |= (DBGMCU_APB2_FZ_DBG_TIM1_STOP)) #define __HAL_DBGMCU_FREEZE_TIM8() (DBGMCU->APB2FZ |= (DBGMCU_APB2_FZ_DBG_TIM8_STOP)) #define __HAL_DBGMCU_FREEZE_TIM9() (DBGMCU->APB2FZ |= (DBGMCU_APB2_FZ_DBG_TIM9_STOP)) #define __HAL_DBGMCU_FREEZE_TIM10() (DBGMCU->APB2FZ |= (DBGMCU_APB2_FZ_DBG_TIM10_STOP)) #define __HAL_DBGMCU_FREEZE_TIM11() (DBGMCU->APB2FZ |= (DBGMCU_APB2_FZ_DBG_TIM11_STOP)) #define __HAL_DBGMCU_UNFREEZE_TIM2() (DBGMCU->APB1FZ &= ~(DBGMCU_APB1_FZ_DBG_TIM2_STOP)) #define __HAL_DBGMCU_UNFREEZE_TIM3() (DBGMCU->APB1FZ &= ~(DBGMCU_APB1_FZ_DBG_TIM3_STOP)) #define __HAL_DBGMCU_UNFREEZE_TIM4() (DBGMCU->APB1FZ &= ~(DBGMCU_APB1_FZ_DBG_TIM4_STOP)) #define __HAL_DBGMCU_UNFREEZE_TIM5() (DBGMCU->APB1FZ &= ~(DBGMCU_APB1_FZ_DBG_TIM5_STOP)) #define __HAL_DBGMCU_UNFREEZE_TIM6() (DBGMCU->APB1FZ &= ~(DBGMCU_APB1_FZ_DBG_TIM6_STOP)) #define __HAL_DBGMCU_UNFREEZE_TIM7() (DBGMCU->APB1FZ &= ~(DBGMCU_APB1_FZ_DBG_TIM7_STOP)) #define __HAL_DBGMCU_UNFREEZE_TIM12() (DBGMCU->APB1FZ &= ~(DBGMCU_APB1_FZ_DBG_TIM12_STOP)) #define __HAL_DBGMCU_UNFREEZE_TIM13() (DBGMCU->APB1FZ &= ~(DBGMCU_APB1_FZ_DBG_TIM13_STOP)) #define __HAL_DBGMCU_UNFREEZE_TIM14() (DBGMCU->APB1FZ &= ~(DBGMCU_APB1_FZ_DBG_TIM14_STOP)) #define __HAL_DBGMCU_UNFREEZE_RTC() (DBGMCU->APB1FZ &= ~(DBGMCU_APB1_FZ_DBG_RTC_STOP)) #define __HAL_DBGMCU_UNFREEZE_WWDG() (DBGMCU->APB1FZ &= ~(DBGMCU_APB1_FZ_DBG_WWDG_STOP)) #define __HAL_DBGMCU_UNFREEZE_IWDG() (DBGMCU->APB1FZ &= ~(DBGMCU_APB1_FZ_DBG_IWDG_STOP)) #define __HAL_DBGMCU_UNFREEZE_I2C1_TIMEOUT() (DBGMCU->APB1FZ &= ~(DBGMCU_APB1_FZ_DBG_I2C1_SMBUS_TIMEOUT)) #define __HAL_DBGMCU_UNFREEZE_I2C2_TIMEOUT() (DBGMCU->APB1FZ &= ~(DBGMCU_APB1_FZ_DBG_I2C2_SMBUS_TIMEOUT)) #define __HAL_DBGMCU_UNFREEZE_I2C3_TIMEOUT() (DBGMCU->APB1FZ &= ~(DBGMCU_APB1_FZ_DBG_I2C3_SMBUS_TIMEOUT)) #define __HAL_DBGMCU_UNFREEZE_CAN1() (DBGMCU->APB1FZ &= ~(DBGMCU_APB1_FZ_DBG_CAN1_STOP)) #define __HAL_DBGMCU_UNFREEZE_CAN2() (DBGMCU->APB1FZ &= ~(DBGMCU_APB1_FZ_DBG_CAN2_STOP)) #define __HAL_DBGMCU_UNFREEZE_TIM1() (DBGMCU->APB2FZ &= ~(DBGMCU_APB2_FZ_DBG_TIM1_STOP)) #define __HAL_DBGMCU_UNFREEZE_TIM8() (DBGMCU->APB2FZ &= ~(DBGMCU_APB2_FZ_DBG_TIM8_STOP)) #define __HAL_DBGMCU_UNFREEZE_TIM9() (DBGMCU->APB2FZ &= ~(DBGMCU_APB2_FZ_DBG_TIM9_STOP)) #define __HAL_DBGMCU_UNFREEZE_TIM10() (DBGMCU->APB2FZ &= ~(DBGMCU_APB2_FZ_DBG_TIM10_STOP)) #define __HAL_DBGMCU_UNFREEZE_TIM11() (DBGMCU->APB2FZ &= ~(DBGMCU_APB2_FZ_DBG_TIM11_STOP)) /** @brief Main Flash memory mapped at 0x00000000 */ #define __HAL_SYSCFG_REMAPMEMORY_FLASH() (SYSCFG->MEMRMP &= ~(SYSCFG_MEMRMP_MEM_MODE)) /** @brief System Flash memory mapped at 0x00000000 */ #define __HAL_SYSCFG_REMAPMEMORY_SYSTEMFLASH() do {SYSCFG->MEMRMP &= ~(SYSCFG_MEMRMP_MEM_MODE);\ SYSCFG->MEMRMP |= SYSCFG_MEMRMP_MEM_MODE_0;\ }while(0); /** @brief Embedded SRAM mapped at 0x00000000 */ #define __HAL_SYSCFG_REMAPMEMORY_SRAM() do {SYSCFG->MEMRMP &= ~(SYSCFG_MEMRMP_MEM_MODE);\ SYSCFG->MEMRMP |= (SYSCFG_MEMRMP_MEM_MODE_0 | SYSCFG_MEMRMP_MEM_MODE_1);\ }while(0); #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx)|| defined(STM32F417xx) /** @brief FSMC Bank1 (NOR/PSRAM 1 and 2) mapped at 0x00000000 */ #define __HAL_SYSCFG_REMAPMEMORY_FSMC() do {SYSCFG->MEMRMP &= ~(SYSCFG_MEMRMP_MEM_MODE);\ SYSCFG->MEMRMP |= (SYSCFG_MEMRMP_MEM_MODE_1);\ }while(0); #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx */ #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx)|| defined(STM32F439xx) ||\ defined(STM32F469xx) || defined(STM32F479xx) /** @brief FMC Bank1 (NOR/PSRAM 1 and 2) mapped at 0x00000000 */ #define __HAL_SYSCFG_REMAPMEMORY_FMC() do {SYSCFG->MEMRMP &= ~(SYSCFG_MEMRMP_MEM_MODE);\ SYSCFG->MEMRMP |= (SYSCFG_MEMRMP_MEM_MODE_1);\ }while(0); /** @brief FMC/SDRAM Bank 1 and 2 mapped at 0x00000000 */ #define __HAL_SYSCFG_REMAPMEMORY_FMC_SDRAM() do {SYSCFG->MEMRMP &= ~(SYSCFG_MEMRMP_MEM_MODE);\ SYSCFG->MEMRMP |= (SYSCFG_MEMRMP_MEM_MODE_2);\ }while(0); #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F469xx || STM32F479xx */ #if defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx) || defined(STM32F413xx) || defined(STM32F423xx) /** @defgroup Cortex_Lockup_Enable Cortex Lockup Enable * @{ */ /** @brief SYSCFG Break Lockup lock * Enables and locks the connection of Cortex-M4 LOCKUP (Hardfault) output to TIM1/8 input * @note The selected configuration is locked and can be unlocked by system reset */ #define __HAL_SYSCFG_BREAK_PVD_LOCK() do {SYSCFG->CFGR2 &= ~(SYSCFG_CFGR2_PVD_LOCK); \ SYSCFG->CFGR2 |= SYSCFG_CFGR2_PVD_LOCK; \ }while(0) /** * @} */ /** @defgroup PVD_Lock_Enable PVD Lock * @{ */ /** @brief SYSCFG Break PVD lock * Enables and locks the PVD connection with Timer1/8 Break Input, , as well as the PVDE and PLS[2:0] in the PWR_CR register * @note The selected configuration is locked and can be unlocked by system reset */ #define __HAL_SYSCFG_BREAK_LOCKUP_LOCK() do {SYSCFG->CFGR2 &= ~(SYSCFG_CFGR2_LOCKUP_LOCK); \ SYSCFG->CFGR2 |= SYSCFG_CFGR2_LOCKUP_LOCK; \ }while(0) /** * @} */ #endif /* STM32F410Tx || STM32F410Cx || STM32F410Rx || STM32F413xx || STM32F423xx */ /** * @} */ /* Exported functions --------------------------------------------------------*/ /** @addtogroup HAL_Exported_Functions * @{ */ /** @addtogroup HAL_Exported_Functions_Group1 * @{ */ /* Initialization and de-initialization functions ******************************/ HAL_StatusTypeDef HAL_Init(void); HAL_StatusTypeDef HAL_DeInit(void); void HAL_MspInit(void); void HAL_MspDeInit(void); HAL_StatusTypeDef HAL_InitTick (uint32_t TickPriority); /** * @} */ /** @addtogroup HAL_Exported_Functions_Group2 * @{ */ /* Peripheral Control functions ************************************************/ void HAL_IncTick(void); void HAL_Delay(__IO uint32_t Delay); uint32_t HAL_GetTick(void); void HAL_SuspendTick(void); void HAL_ResumeTick(void); uint32_t HAL_GetHalVersion(void); uint32_t HAL_GetREVID(void); uint32_t HAL_GetDEVID(void); void HAL_DBGMCU_EnableDBGSleepMode(void); void HAL_DBGMCU_DisableDBGSleepMode(void); void HAL_DBGMCU_EnableDBGStopMode(void); void HAL_DBGMCU_DisableDBGStopMode(void); void HAL_DBGMCU_EnableDBGStandbyMode(void); void HAL_DBGMCU_DisableDBGStandbyMode(void); void HAL_EnableCompensationCell(void); void HAL_DisableCompensationCell(void); void HAL_GetUID(uint32_t *UID); #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx)|| defined(STM32F439xx) ||\ defined(STM32F469xx) || defined(STM32F479xx) void HAL_EnableMemorySwappingBank(void); void HAL_DisableMemorySwappingBank(void); #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F469xx || STM32F479xx */ /** * @} */ /** * @} */ /* Private types -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ /** @defgroup HAL_Private_Variables HAL Private Variables * @{ */ /** * @} */ /* Private constants ---------------------------------------------------------*/ /** @defgroup HAL_Private_Constants HAL Private Constants * @{ */ /** * @} */ /* Private macros ------------------------------------------------------------*/ /* Private functions ---------------------------------------------------------*/ /** * @} */ /** * @} */ #ifdef __cplusplus } #endif #endif /* __STM32F4xx_HAL_H */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ ================================================ FILE: sys/arch/stm32/hal/stm32f4xx_hal_conf.h ================================================ /** ****************************************************************************** * @file BSP/inc/stm32f4xx_hal_conf.h * @author MCD Application Team * @version V1.1.0 * @date 17-February-2017 * @brief HAL configuration file. ****************************************************************************** * @attention * *

© COPYRIGHT(c) 2017 STMicroelectronics

* * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. Neither the name of STMicroelectronics nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __STM32F4xx_HAL_CONF_H #define __STM32F4xx_HAL_CONF_H #ifdef __cplusplus extern "C" { #endif /* Exported types ------------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/ /* ########################## Module Selection ############################## */ /** * @brief This is the list of modules to be used in the HAL driver */ #define HAL_MODULE_ENABLED #define HAL_SD_MODULE_ENABLED #define HAL_SPI_MODULE_ENABLED /* ########################## HSE/HSI Values adaptation ##################### */ /** * @brief Adjust the value of External High Speed oscillator (HSE) used in your application. * This value is used by the RCC HAL module to compute the system frequency * (when HSE is used as system clock source, directly or through the PLL). */ #if !defined (HSE_VALUE) #if defined(USE_STM32469I_DISCO_REVA) #define HSE_VALUE (25000000U) /*!< Default value of the External oscillator in Hz */ #else #define HSE_VALUE (8000000U) /*!< Default value of the External oscillator in Hz */ #endif /* USE_STM32469I_DISCO_REVA */ #endif /* HSE_VALUE */ #if !defined (HSE_STARTUP_TIMEOUT) #define HSE_STARTUP_TIMEOUT (100U) /*!< Time out for HSE start up, in ms */ #endif /* HSE_STARTUP_TIMEOUT */ /** * @brief Internal High Speed oscillator (HSI) value. * This value is used by the RCC HAL module to compute the system frequency * (when HSI is used as system clock source, directly or through the PLL). */ #if !defined (HSI_VALUE) #define HSI_VALUE (16000000U) /*!< Value of the Internal oscillator in Hz*/ #endif /* HSI_VALUE */ /** * @brief Internal Low Speed oscillator (LSI) value. */ #if !defined (LSI_VALUE) #define LSI_VALUE (32000U) #endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz The real value may vary depending on the variations in voltage and temperature. */ /** * @brief External Low Speed oscillator (LSE) value. */ #if !defined (LSE_VALUE) #define LSE_VALUE (32768U) /*!< Value of the External Low Speed oscillator in Hz */ #endif /* LSE_VALUE */ #if !defined (LSE_STARTUP_TIMEOUT) #define LSE_STARTUP_TIMEOUT (5000U) /*!< Time out for LSE start up, in ms */ #endif /* LSE_STARTUP_TIMEOUT */ /** * @brief External clock source for I2S peripheral * This value is used by the I2S HAL module to compute the I2S clock source * frequency, this source is inserted directly through I2S_CKIN pad. */ #if !defined (EXTERNAL_CLOCK_VALUE) #define EXTERNAL_CLOCK_VALUE (12288000U) /*!< Value of the external oscillator in Hz*/ #endif /* EXTERNAL_CLOCK_VALUE */ /* Tip: To avoid modifying this file each time you need to use different HSE, === you can define the HSE value in your toolchain compiler preprocessor. */ /* ########################### System Configuration ######################### */ /** * @brief This is the HAL system configuration section */ #define VDD_VALUE (3300U) /*!< Value of VDD in mv */ #define TICK_INT_PRIORITY (0x0FU) /*!< tick interrupt priority */ #define USE_RTOS 0 #define PREFETCH_ENABLE 1 #define INSTRUCTION_CACHE_ENABLE 1 #define DATA_CACHE_ENABLE 1 /* ########################## Assert Selection ############################## */ /** * @brief Uncomment the line below to expanse the "assert_param" macro in the * HAL drivers code */ // XXX #define USE_FULL_ASSERT 0 /* ################## SPI peripheral configuration ########################## */ /* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver * Activated: CRC code is present inside driver * Deactivated: CRC code cleaned from driver */ #define USE_SPI_CRC 1U /* Includes ------------------------------------------------------------------*/ /** * @brief Include module's header file */ #ifdef HAL_SD_MODULE_ENABLED #include "stm32f4xx_hal_sd.h" #endif /* HAL_SD_MODULE_ENABLED */ #ifdef HAL_SPI_MODULE_ENABLED #include "stm32f4xx_hal_spi.h" #endif /* HAL_SPI_MODULE_ENABLED */ /* Exported macro ------------------------------------------------------------*/ #ifdef USE_FULL_ASSERT /** * @brief The assert_param macro is used for function's parameters check. * @param expr: If expr is false, it calls assert_failed function * which reports the name of the source file and the source * line number of the call that failed. * If expr is true, it returns no value. * @retval None */ #define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__)) /* Exported functions ------------------------------------------------------- */ void assert_failed(uint8_t* file, uint32_t line); #else #define assert_param(expr) ((void)0U) #endif /* USE_FULL_ASSERT */ /** * @} */ /** * @} */ #ifdef __cplusplus } #endif #endif /* __STM32F4xx_HAL_CONF_H */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ ================================================ FILE: sys/arch/stm32/hal/stm32f4xx_hal_def.h ================================================ /** ****************************************************************************** * @file stm32f4xx_hal_def.h * @author MCD Application Team * @version V1.7.1 * @date 14-April-2017 * @brief This file contains HAL common defines, enumeration, macros and * structures definitions. ****************************************************************************** * @attention * *

© COPYRIGHT(c) 2017 STMicroelectronics

* * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. Neither the name of STMicroelectronics nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __STM32F4xx_HAL_DEF #define __STM32F4xx_HAL_DEF #ifdef __cplusplus extern "C" { #endif /* Includes ------------------------------------------------------------------*/ #include "stm32f4xx.h" #include /* Exported types ------------------------------------------------------------*/ /** * @brief HAL Status structures definition */ typedef enum { HAL_OK = 0x00U, HAL_ERROR = 0x01U, HAL_BUSY = 0x02U, HAL_TIMEOUT = 0x03U } HAL_StatusTypeDef; /** * @brief HAL Lock structures definition */ typedef enum { HAL_UNLOCKED = 0x00U, HAL_LOCKED = 0x01U } HAL_LockTypeDef; /* Exported macro ------------------------------------------------------------*/ #define HAL_MAX_DELAY 0xFFFFFFFFU #define HAL_IS_BIT_SET(REG, BIT) (((REG) & (BIT)) != RESET) #define HAL_IS_BIT_CLR(REG, BIT) (((REG) & (BIT)) == RESET) #define __HAL_LINKDMA(__HANDLE__, __PPP_DMA_FIELD__, __DMA_HANDLE__) \ do{ \ (__HANDLE__)->__PPP_DMA_FIELD__ = &(__DMA_HANDLE__); \ (__DMA_HANDLE__).Parent = (__HANDLE__); \ } while(0) #define UNUSED(x) ((void)(x)) /** @brief Reset the Handle's State field. * @param __HANDLE__: specifies the Peripheral Handle. * @note This macro can be used for the following purpose: * - When the Handle is declared as local variable; before passing it as parameter * to HAL_PPP_Init() for the first time, it is mandatory to use this macro * to set to 0 the Handle's "State" field. * Otherwise, "State" field may have any random value and the first time the function * HAL_PPP_Init() is called, the low level hardware initialization will be missed * (i.e. HAL_PPP_MspInit() will not be executed). * - When there is a need to reconfigure the low level hardware: instead of calling * HAL_PPP_DeInit() then HAL_PPP_Init(), user can make a call to this macro then HAL_PPP_Init(). * In this later function, when the Handle's "State" field is set to 0, it will execute the function * HAL_PPP_MspInit() which will reconfigure the low level hardware. * @retval None */ #define __HAL_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = 0U) #if (USE_RTOS == 1U) /* Reserved for future use */ #error "USE_RTOS should be 0 in the current HAL release" #else #define __HAL_LOCK(__HANDLE__) \ do{ \ if((__HANDLE__)->Lock == HAL_LOCKED) \ { \ return HAL_BUSY; \ } \ else \ { \ (__HANDLE__)->Lock = HAL_LOCKED; \ } \ }while (0U) #define __HAL_UNLOCK(__HANDLE__) \ do{ \ (__HANDLE__)->Lock = HAL_UNLOCKED; \ }while (0U) #endif /* USE_RTOS */ #if defined ( __GNUC__ ) #ifndef __weak #define __weak __attribute__((weak)) #endif /* __weak */ #ifndef __packed #define __packed __attribute__((__packed__)) #endif /* __packed */ #endif /* __GNUC__ */ /* Macro to get variable aligned on 4-bytes, for __ICCARM__ the directive "#pragma data_alignment=4" must be used instead */ #if defined (__GNUC__) /* GNU Compiler */ #ifndef __ALIGN_END #define __ALIGN_END __attribute__ ((aligned (4))) #endif /* __ALIGN_END */ #ifndef __ALIGN_BEGIN #define __ALIGN_BEGIN #endif /* __ALIGN_BEGIN */ #else #ifndef __ALIGN_END #define __ALIGN_END #endif /* __ALIGN_END */ #ifndef __ALIGN_BEGIN #if defined (__CC_ARM) /* ARM Compiler */ #define __ALIGN_BEGIN __align(4) #elif defined (__ICCARM__) /* IAR Compiler */ #define __ALIGN_BEGIN #endif /* __CC_ARM */ #endif /* __ALIGN_BEGIN */ #endif /* __GNUC__ */ /** * @brief __RAM_FUNC definition */ #if defined ( __CC_ARM ) /* ARM Compiler ------------ RAM functions are defined using the toolchain options. Functions that are executed in RAM should reside in a separate source module. Using the 'Options for File' dialog you can simply change the 'Code / Const' area of a module to a memory space in physical RAM. Available memory areas are declared in the 'Target' tab of the 'Options for Target' dialog. */ #define __RAM_FUNC HAL_StatusTypeDef #elif defined ( __ICCARM__ ) /* ICCARM Compiler --------------- RAM functions are defined using a specific toolchain keyword "__ramfunc". */ #define __RAM_FUNC __ramfunc HAL_StatusTypeDef #elif defined ( __GNUC__ ) /* GNU Compiler ------------ RAM functions are defined using a specific toolchain attribute "__attribute__((section(".RamFunc")))". */ #define __RAM_FUNC HAL_StatusTypeDef __attribute__((section(".RamFunc"))) #endif /** * @brief __NOINLINE definition */ #if defined ( __CC_ARM ) || defined ( __GNUC__ ) /* ARM & GNUCompiler ---------------- */ #define __NOINLINE __attribute__ ( (noinline) ) #elif defined ( __ICCARM__ ) /* ICCARM Compiler --------------- */ #define __NOINLINE _Pragma("optimize = no_inline") #endif #ifdef __cplusplus } #endif #endif /* ___STM32F4xx_HAL_DEF */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ ================================================ FILE: sys/arch/stm32/hal/stm32f4xx_hal_sd.c ================================================ /** ****************************************************************************** * @file stm32f4xx_hal_sd.c * @author MCD Application Team * @version V1.7.1 * @date 14-April-2017 * @brief SD card HAL module driver. * This file provides firmware functions to manage the following * functionalities of the Secure Digital (SD) peripheral: * + Initialization and de-initialization functions * + IO operation functions * + Peripheral Control functions * + Peripheral State functions * @verbatim ============================================================================== ##### How to use this driver ##### ============================================================================== [..] This driver implements a high level communication layer for read and write from/to this memory. The needed STM32 hardware resources (SDIO and GPIO) are performed by the user in HAL_SD_MspInit() function (MSP layer). Basically, the MSP layer configuration should be the same as we provide in the examples. You can easily tailor this configuration according to hardware resources. [..] This driver is a generic layered driver for SDIO memories which uses the HAL SDIO driver functions to interface with SD and uSD cards devices. It is used as follows: (#) Initialize the SDIO low level resources by implementing the HAL_SD_MspInit() API: (##) Enable the SDIO interface clock using __HAL_RCC_SDIO_CLK_ENABLE(); (##) SDIO pins configuration for SD card (+++) Enable the clock for the SDIO GPIOs using the functions __HAL_RCC_GPIOx_CLK_ENABLE(); (+++) Configure these SDIO pins as alternate function pull-up using HAL_GPIO_Init() and according to your pin assignment; (##) DMA configuration if you need to use DMA process (HAL_SD_ReadBlocks_DMA() and HAL_SD_WriteBlocks_DMA() APIs). (+++) Enable the DMAx interface clock using __HAL_RCC_DMAx_CLK_ENABLE(); (+++) Configure the DMA using the function HAL_DMA_Init() with predeclared and filled. (##) NVIC configuration if you need to use interrupt process when using DMA transfer. (+++) Configure the SDIO and DMA interrupt priorities using functions HAL_NVIC_SetPriority(); DMA priority is superior to SDIO's priority (+++) Enable the NVIC DMA and SDIO IRQs using function HAL_NVIC_EnableIRQ() (+++) SDIO interrupts are managed using the macros __HAL_SD_ENABLE_IT() and __HAL_SD_DISABLE_IT() inside the communication process. (+++) SDIO interrupts pending bits are managed using the macros __HAL_SD_GET_IT() and __HAL_SD_CLEAR_IT() (##) NVIC configuration if you need to use interrupt process (HAL_SD_ReadBlocks_IT() and HAL_SD_WriteBlocks_IT() APIs). (+++) Configure the SDIO interrupt priorities using function HAL_NVIC_SetPriority(); (+++) Enable the NVIC SDIO IRQs using function HAL_NVIC_EnableIRQ() (+++) SDIO interrupts are managed using the macros __HAL_SD_ENABLE_IT() and __HAL_SD_DISABLE_IT() inside the communication process. (+++) SDIO interrupts pending bits are managed using the macros __HAL_SD_GET_IT() and __HAL_SD_CLEAR_IT() (#) At this stage, you can perform SD read/write/erase operations after SD card initialization *** SD Card Initialization and configuration *** ================================================ [..] To initialize the SD Card, use the HAL_SD_Init() function. It Initializes SDIO Peripheral(STM32 side) and the SD Card, and put it into StandBy State (Ready for data transfer). This function provide the following operations: (#) Apply the SD Card initialization process at 400KHz and check the SD Card type (Standard Capacity or High Capacity). You can change or adapt this frequency by adjusting the "ClockDiv" field. The SD Card frequency (SDIO_CK) is computed as follows: SDIO_CK = SDIOCLK / (ClockDiv + 2) In initialization mode and according to the SD Card standard, make sure that the SDIO_CK frequency doesn't exceed 400KHz. This phase of initialization is done through SDIO_Init() and SDIO_PowerState_ON() SDIO low level APIs. (#) Initialize the SD card. The API used is HAL_SD_InitCard(). This phase allows the card initialization and identification and check the SD Card type (Standard Capacity or High Capacity) The initialization flow is compatible with SD standard. This API (HAL_SD_InitCard()) could be used also to reinitialize the card in case of plug-off plug-in. (#) Configure the SD Card Data transfer frequency. You can change or adapt this frequency by adjusting the "ClockDiv" field. In transfer mode and according to the SD Card standard, make sure that the SDIO_CK frequency doesn't exceed 25MHz and 50MHz in High-speed mode switch. To be able to use a frequency higher than 24MHz, you should use the SDIO peripheral in bypass mode. Refer to the corresponding reference manual for more details. (#) Select the corresponding SD Card according to the address read with the step 2. (#) Configure the SD Card in wide bus mode: 4-bits data. *** SD Card Read operation *** ============================== [..] (+) You can read from SD card in polling mode by using function HAL_SD_ReadBlocks(). This function support only 512-bytes block length (the block size should be chosen as 512 bytes). You can choose either one block read operation or multiple block read operation by adjusting the "NumberOfBlocks" parameter. After this, you have to ensure that the transfer is done correctly. The check is done through HAL_SD_GetCardState() function for SD card state. (+) You can read from SD card in DMA mode by using function HAL_SD_ReadBlocks_DMA(). This function support only 512-bytes block length (the block size should be chosen as 512 bytes). You can choose either one block read operation or multiple block read operation by adjusting the "NumberOfBlocks" parameter. After this, you have to ensure that the transfer is done correctly. The check is done through HAL_SD_GetCardState() function for SD card state. You could also check the DMA transfer process through the SD Rx interrupt event. (+) You can read from SD card in Interrupt mode by using function HAL_SD_ReadBlocks_IT(). This function support only 512-bytes block length (the block size should be chosen as 512 bytes). You can choose either one block read operation or multiple block read operation by adjusting the "NumberOfBlocks" parameter. After this, you have to ensure that the transfer is done correctly. The check is done through HAL_SD_GetCardState() function for SD card state. You could also check the IT transfer process through the SD Rx interrupt event. *** SD Card Write operation *** =============================== [..] (+) You can write to SD card in polling mode by using function HAL_SD_WriteBlocks(). This function support only 512-bytes block length (the block size should be chosen as 512 bytes). You can choose either one block read operation or multiple block read operation by adjusting the "NumberOfBlocks" parameter. After this, you have to ensure that the transfer is done correctly. The check is done through HAL_SD_GetCardState() function for SD card state. (+) You can write to SD card in DMA mode by using function HAL_SD_WriteBlocks_DMA(). This function support only 512-bytes block length (the block size should be chosen as 512 bytes). You can choose either one block read operation or multiple block read operation by adjusting the "NumberOfBlocks" parameter. After this, you have to ensure that the transfer is done correctly. The check is done through HAL_SD_GetCardState() function for SD card state. You could also check the DMA transfer process through the SD Tx interrupt event. (+) You can write to SD card in Interrupt mode by using function HAL_SD_WriteBlocks_IT(). This function support only 512-bytes block length (the block size should be chosen as 512 bytes). You can choose either one block read operation or multiple block read operation by adjusting the "NumberOfBlocks" parameter. After this, you have to ensure that the transfer is done correctly. The check is done through HAL_SD_GetCardState() function for SD card state. You could also check the IT transfer process through the SD Tx interrupt event. *** SD card status *** ====================== [..] (+) The SD Status contains status bits that are related to the SD Memory Card proprietary features. To get SD card status use the HAL_SD_GetCardStatus(). *** SD card information *** =========================== [..] (+) To get SD card information, you can use the function HAL_SD_GetCardInfo(). It returns useful information about the SD card such as block size, card type, block number ... *** SD card CSD register *** ============================ (+) The HAL_SD_GetCardCSD() API allows to get the parameters of the CSD register. Some of the CSD parameters are useful for card initialization and identification. *** SD card CID register *** ============================ (+) The HAL_SD_GetCardCID() API allows to get the parameters of the CID register. Some of the CSD parameters are useful for card initialization and identification. *** SD HAL driver macros list *** ================================== [..] Below the list of most used macros in SD HAL driver. (+) __HAL_SD_ENABLE : Enable the SD device (+) __HAL_SD_DISABLE : Disable the SD device (+) __HAL_SD_DMA_ENABLE: Enable the SDIO DMA transfer (+) __HAL_SD_DMA_DISABLE: Disable the SDIO DMA transfer (+) __HAL_SD_ENABLE_IT: Enable the SD device interrupt (+) __HAL_SD_DISABLE_IT: Disable the SD device interrupt (+) __HAL_SD_GET_FLAG:Check whether the specified SD flag is set or not (+) __HAL_SD_CLEAR_FLAG: Clear the SD's pending flags (@) You can refer to the SD HAL driver header file for more useful macros *** Callback registration *** ============================================= [..] The compilation define USE_HAL_SD_REGISTER_CALLBACKS when set to 1 allows the user to configure dynamically the driver callbacks. Use Functions @ref HAL_SD_RegisterCallback() to register a user callback, it allows to register following callbacks: (+) TxCpltCallback : callback when a transmission transfer is completed. (+) RxCpltCallback : callback when a reception transfer is completed. (+) ErrorCallback : callback when error occurs. (+) AbortCpltCallback : callback when abort is completed. (+) MspInitCallback : SD MspInit. (+) MspDeInitCallback : SD MspDeInit. This function takes as parameters the HAL peripheral handle, the Callback ID and a pointer to the user callback function. Use function @ref HAL_SD_UnRegisterCallback() to reset a callback to the default weak (surcharged) function. It allows to reset following callbacks: (+) TxCpltCallback : callback when a transmission transfer is completed. (+) RxCpltCallback : callback when a reception transfer is completed. (+) ErrorCallback : callback when error occurs. (+) AbortCpltCallback : callback when abort is completed. (+) MspInitCallback : SD MspInit. (+) MspDeInitCallback : SD MspDeInit. This function takes as parameters the HAL peripheral handle and the Callback ID. By default, after the @ref HAL_SD_Init and if the state is HAL_SD_STATE_RESET all callbacks are reset to the corresponding legacy weak (surcharged) functions. Exception done for MspInit and MspDeInit callbacks that are respectively reset to the legacy weak (surcharged) functions in the @ref HAL_SD_Init and @ref HAL_SD_DeInit only when these callbacks are null (not registered beforehand). If not, MspInit or MspDeInit are not null, the @ref HAL_SD_Init and @ref HAL_SD_DeInit keep and use the user MspInit/MspDeInit callbacks (registered beforehand) Callbacks can be registered/unregistered in READY state only. Exception done for MspInit/MspDeInit callbacks that can be registered/unregistered in READY or RESET state, thus registered (user) MspInit/DeInit callbacks can be used during the Init/DeInit. In that case first register the MspInit/MspDeInit user callbacks using @ref HAL_SD_RegisterCallback before calling @ref HAL_SD_DeInit or @ref HAL_SD_Init function. When the compilation define USE_HAL_SD_REGISTER_CALLBACKS is set to 0 or not defined, the callback registering feature is not available and weak (surcharged) callbacks are used. @endverbatim ****************************************************************************** * @attention * *

© COPYRIGHT(c) 2017 STMicroelectronics

* * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. Neither the name of STMicroelectronics nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ /* Includes ------------------------------------------------------------------*/ #include "stm32f4xx_hal.h" /** @addtogroup STM32F4xx_HAL_Driver * @{ */ /** @addtogroup SD * @{ */ #ifdef HAL_SD_MODULE_ENABLED #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) || \ defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) || \ defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F411xE) || defined(STM32F446xx) || \ defined(STM32F469xx) || defined(STM32F479xx) || defined(STM32F412Zx) || defined(STM32F412Vx) || \ defined(STM32F412Rx) || defined(STM32F412Cx) || defined(STM32F413xx) || defined(STM32F423xx) /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ /** @addtogroup SD_Private_Defines * @{ */ /** * @} */ /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/ /* Private functions ---------------------------------------------------------*/ /** @defgroup SD_Private_Functions SD Private Functions * @{ */ static uint32_t SD_InitCard(SD_HandleTypeDef *hsd); static uint32_t SD_PowerON(SD_HandleTypeDef *hsd); static uint32_t SD_SendSDStatus(SD_HandleTypeDef *hsd, uint32_t *pSDstatus); static uint32_t SD_SendStatus(SD_HandleTypeDef *hsd, uint32_t *pCardStatus); static uint32_t SD_WideBus_Enable(SD_HandleTypeDef *hsd); static uint32_t SD_WideBus_Disable(SD_HandleTypeDef *hsd); static uint32_t SD_FindSCR(SD_HandleTypeDef *hsd, uint32_t *pSCR); static void SD_PowerOFF(SD_HandleTypeDef *hsd); static void SD_Write_IT(SD_HandleTypeDef *hsd); static void SD_Read_IT(SD_HandleTypeDef *hsd); #if 0 // XXX DMA static void SD_DMATransmitCplt(DMA_HandleTypeDef *hdma); static void SD_DMAReceiveCplt(DMA_HandleTypeDef *hdma); static void SD_DMAError(DMA_HandleTypeDef *hdma); static void SD_DMATxAbort(DMA_HandleTypeDef *hdma); static void SD_DMARxAbort(DMA_HandleTypeDef *hdma); #endif // XXX DMA /** * @} */ /* Exported functions --------------------------------------------------------*/ /** @addtogroup SD_Exported_Functions * @{ */ /** @addtogroup SD_Exported_Functions_Group1 * @brief Initialization and de-initialization functions * @verbatim ============================================================================== ##### Initialization and de-initialization functions ##### ============================================================================== [..] This section provides functions allowing to initialize/de-initialize the SD card device to be ready for use. @endverbatim * @{ */ /** * @brief Initializes the SD according to the specified parameters in the SD_HandleTypeDef and create the associated handle. * @param hsd: Pointer to the SD handle * @retval HAL status */ HAL_StatusTypeDef HAL_SD_Init(SD_HandleTypeDef *hsd) { /* Check the SD handle allocation */ if(hsd == NULL) { return HAL_ERROR; } /* Check the parameters */ assert_param(IS_SDIO_ALL_INSTANCE(hsd->Instance)); assert_param(IS_SDIO_CLOCK_EDGE(hsd->Init.ClockEdge)); assert_param(IS_SDIO_CLOCK_BYPASS(hsd->Init.ClockBypass)); assert_param(IS_SDIO_CLOCK_POWER_SAVE(hsd->Init.ClockPowerSave)); assert_param(IS_SDIO_BUS_WIDE(hsd->Init.BusWide)); assert_param(IS_SDIO_HARDWARE_FLOW_CONTROL(hsd->Init.HardwareFlowControl)); assert_param(IS_SDIO_CLKDIV(hsd->Init.ClockDiv)); if(hsd->State == HAL_SD_STATE_RESET) { /* Allocate lock resource and initialize it */ hsd->Lock = HAL_UNLOCKED; #if defined (USE_HAL_SD_REGISTER_CALLBACKS) && (USE_HAL_SD_REGISTER_CALLBACKS == 1U) /* Reset Callback pointers in HAL_SD_STATE_RESET only */ hsd->TxCpltCallback = HAL_SD_TxCpltCallback; hsd->RxCpltCallback = HAL_SD_RxCpltCallback; hsd->ErrorCallback = HAL_SD_ErrorCallback; hsd->AbortCpltCallback = HAL_SD_AbortCallback; if(hsd->MspInitCallback == NULL) { hsd->MspInitCallback = HAL_SD_MspInit; } /* Init the low level hardware */ hsd->MspInitCallback(hsd); #else /* Init the low level hardware : GPIO, CLOCK, CORTEX...etc */ HAL_SD_MspInit(hsd); #endif /* USE_HAL_SD_REGISTER_CALLBACKS */ } hsd->State = HAL_SD_STATE_BUSY; /* Initialize the Card parameters */ if (HAL_SD_InitCard(hsd) != HAL_OK) { return HAL_ERROR; } /* Initialize the error code */ hsd->ErrorCode = HAL_SD_ERROR_NONE; /* Initialize the SD operation */ hsd->Context = SD_CONTEXT_NONE; /* Initialize the SD state */ hsd->State = HAL_SD_STATE_READY; return HAL_OK; } /** * @brief Initializes the SD Card. * @param hsd: Pointer to SD handle * @note This function initializes the SD card. It could be used when a card re-initialization is needed. * @retval HAL status */ HAL_StatusTypeDef HAL_SD_InitCard(SD_HandleTypeDef *hsd) { uint32_t errorstate; HAL_StatusTypeDef status; SD_InitTypeDef Init; /* Default SDIO peripheral configuration for SD card initialization */ Init.ClockEdge = SDIO_CLOCK_EDGE_RISING; Init.ClockBypass = SDIO_CLOCK_BYPASS_DISABLE; Init.ClockPowerSave = SDIO_CLOCK_POWER_SAVE_DISABLE; Init.BusWide = SDIO_BUS_WIDE_1B; Init.HardwareFlowControl = SDIO_HARDWARE_FLOW_CONTROL_DISABLE; Init.ClockDiv = SDIO_INIT_CLK_DIV; /* Initialize SDIO peripheral interface with default configuration */ status = SDIO_Init(hsd->Instance, Init); if(status != HAL_OK) { return HAL_ERROR; } /* Disable SDIO Clock */ __HAL_SD_DISABLE(hsd); /* Set Power State to ON */ (void)SDIO_PowerState_ON(hsd->Instance); /* Enable SDIO Clock */ __HAL_SD_ENABLE(hsd); /* Identify card operating voltage */ errorstate = SD_PowerON(hsd); if(errorstate != HAL_SD_ERROR_NONE) { hsd->State = HAL_SD_STATE_READY; hsd->ErrorCode |= errorstate; return HAL_ERROR; } /* Card initialization */ errorstate = SD_InitCard(hsd); if(errorstate != HAL_SD_ERROR_NONE) { hsd->State = HAL_SD_STATE_READY; hsd->ErrorCode |= errorstate; return HAL_ERROR; } return HAL_OK; } /** * @brief De-Initializes the SD card. * @param hsd: Pointer to SD handle * @retval HAL status */ HAL_StatusTypeDef HAL_SD_DeInit(SD_HandleTypeDef *hsd) { /* Check the SD handle allocation */ if(hsd == NULL) { return HAL_ERROR; } /* Check the parameters */ assert_param(IS_SDIO_ALL_INSTANCE(hsd->Instance)); hsd->State = HAL_SD_STATE_BUSY; /* Set SD power state to off */ SD_PowerOFF(hsd); #if defined (USE_HAL_SD_REGISTER_CALLBACKS) && (USE_HAL_SD_REGISTER_CALLBACKS == 1U) if(hsd->MspDeInitCallback == NULL) { hsd->MspDeInitCallback = HAL_SD_MspDeInit; } /* DeInit the low level hardware */ hsd->MspDeInitCallback(hsd); #else /* De-Initialize the MSP layer */ HAL_SD_MspDeInit(hsd); #endif /* USE_HAL_SD_REGISTER_CALLBACKS */ hsd->ErrorCode = HAL_SD_ERROR_NONE; hsd->State = HAL_SD_STATE_RESET; return HAL_OK; } /** * @brief Initializes the SD MSP. * @param hsd: Pointer to SD handle * @retval None */ __weak void HAL_SD_MspInit(SD_HandleTypeDef *hsd) { /* Prevent unused argument(s) compilation warning */ UNUSED(hsd); /* NOTE : This function should not be modified, when the callback is needed, the HAL_SD_MspInit could be implemented in the user file */ } /** * @brief De-Initialize SD MSP. * @param hsd: Pointer to SD handle * @retval None */ __weak void HAL_SD_MspDeInit(SD_HandleTypeDef *hsd) { /* Prevent unused argument(s) compilation warning */ UNUSED(hsd); /* NOTE : This function should not be modified, when the callback is needed, the HAL_SD_MspDeInit could be implemented in the user file */ } /** * @} */ /** @addtogroup SD_Exported_Functions_Group2 * @brief Data transfer functions * @verbatim ============================================================================== ##### IO operation functions ##### ============================================================================== [..] This subsection provides a set of functions allowing to manage the data transfer from/to SD card. @endverbatim * @{ */ /** * @brief Reads block(s) from a specified address in a card. The Data transfer * is managed by polling mode. * @note This API should be followed by a check on the card state through * HAL_SD_GetCardState(). * @param hsd: Pointer to SD handle * @param pData: pointer to the buffer that will contain the received data * @param BlockAdd: Block Address from where data is to be read * @param NumberOfBlocks: Number of SD blocks to read * @param Timeout: Specify timeout value * @retval HAL status */ HAL_StatusTypeDef HAL_SD_ReadBlocks(SD_HandleTypeDef *hsd, uint8_t *pData, uint32_t BlockAdd, uint32_t NumberOfBlocks, uint32_t Timeout) { SDIO_DataInitTypeDef config; uint32_t errorstate; uint32_t tickstart = HAL_GetTick(); uint32_t count, data, dataremaining; uint32_t add = BlockAdd; uint8_t *tempbuff = pData; if(NULL == pData) { hsd->ErrorCode |= HAL_SD_ERROR_PARAM; return HAL_ERROR; } if(hsd->State == HAL_SD_STATE_READY) { hsd->ErrorCode = HAL_SD_ERROR_NONE; if((add + NumberOfBlocks) > (hsd->SdCard.LogBlockNbr)) { hsd->ErrorCode |= HAL_SD_ERROR_ADDR_OUT_OF_RANGE; return HAL_ERROR; } hsd->State = HAL_SD_STATE_BUSY; /* Initialize data control register */ hsd->Instance->DCTRL = 0U; if(hsd->SdCard.CardType != CARD_SDHC_SDXC) { add *= 512U; } /* Set Block Size for Card */ errorstate = SDMMC_CmdBlockLength(hsd->Instance, BLOCKSIZE); if(errorstate != HAL_SD_ERROR_NONE) { /* Clear all the static flags */ __HAL_SD_CLEAR_FLAG(hsd, SDIO_STATIC_FLAGS); hsd->ErrorCode |= errorstate; hsd->State = HAL_SD_STATE_READY; return HAL_ERROR; } /* Configure the SD DPSM (Data Path State Machine) */ config.DataTimeOut = SDMMC_DATATIMEOUT; config.DataLength = NumberOfBlocks * BLOCKSIZE; config.DataBlockSize = SDIO_DATABLOCK_SIZE_512B; config.TransferDir = SDIO_TRANSFER_DIR_TO_SDIO; config.TransferMode = SDIO_TRANSFER_MODE_BLOCK; config.DPSM = SDIO_DPSM_ENABLE; (void)SDIO_ConfigData(hsd->Instance, &config); /* Read block(s) in polling mode */ if(NumberOfBlocks > 1U) { hsd->Context = SD_CONTEXT_READ_MULTIPLE_BLOCK; /* Read Multi Block command */ errorstate = SDMMC_CmdReadMultiBlock(hsd->Instance, add); } else { hsd->Context = SD_CONTEXT_READ_SINGLE_BLOCK; /* Read Single Block command */ errorstate = SDMMC_CmdReadSingleBlock(hsd->Instance, add); } if(errorstate != HAL_SD_ERROR_NONE) { /* Clear all the static flags */ __HAL_SD_CLEAR_FLAG(hsd, SDIO_STATIC_FLAGS); hsd->ErrorCode |= errorstate; hsd->State = HAL_SD_STATE_READY; hsd->Context = SD_CONTEXT_NONE; return HAL_ERROR; } /* Poll on SDIO flags */ dataremaining = config.DataLength; #if defined(SDIO_STA_STBITERR) while(!__HAL_SD_GET_FLAG(hsd, SDIO_FLAG_RXOVERR | SDIO_FLAG_DCRCFAIL | SDIO_FLAG_DTIMEOUT | SDIO_FLAG_DATAEND | SDIO_FLAG_STBITERR)) #else /* SDIO_STA_STBITERR not defined */ while(!__HAL_SD_GET_FLAG(hsd, SDIO_FLAG_RXOVERR | SDIO_FLAG_DCRCFAIL | SDIO_FLAG_DTIMEOUT | SDIO_FLAG_DATAEND)) #endif /* SDIO_STA_STBITERR */ { if(__HAL_SD_GET_FLAG(hsd, SDIO_FLAG_RXFIFOHF) && (dataremaining > 0U)) { /* Read data from SDIO Rx FIFO */ for(count = 0U; count < 8U; count++) { data = SDIO_ReadFIFO(hsd->Instance); *tempbuff = (uint8_t)(data & 0xFFU); tempbuff++; dataremaining--; *tempbuff = (uint8_t)((data >> 8U) & 0xFFU); tempbuff++; dataremaining--; *tempbuff = (uint8_t)((data >> 16U) & 0xFFU); tempbuff++; dataremaining--; *tempbuff = (uint8_t)((data >> 24U) & 0xFFU); tempbuff++; dataremaining--; } } if(((HAL_GetTick()-tickstart) >= Timeout) || (Timeout == 0U)) { /* Clear all the static flags */ __HAL_SD_CLEAR_FLAG(hsd, SDIO_STATIC_FLAGS); hsd->ErrorCode |= HAL_SD_ERROR_TIMEOUT; hsd->State= HAL_SD_STATE_READY; hsd->Context = SD_CONTEXT_NONE; return HAL_TIMEOUT; } } /* Send stop transmission command in case of multiblock read */ if(__HAL_SD_GET_FLAG(hsd, SDIO_FLAG_DATAEND) && (NumberOfBlocks > 1U)) { if(hsd->SdCard.CardType != CARD_SECURED) { /* Send stop transmission command */ errorstate = SDMMC_CmdStopTransfer(hsd->Instance); if(errorstate != HAL_SD_ERROR_NONE) { /* Clear all the static flags */ __HAL_SD_CLEAR_FLAG(hsd, SDIO_STATIC_FLAGS); hsd->ErrorCode |= errorstate; hsd->State = HAL_SD_STATE_READY; hsd->Context = SD_CONTEXT_NONE; return HAL_ERROR; } } } /* Get error state */ if(__HAL_SD_GET_FLAG(hsd, SDIO_FLAG_DTIMEOUT)) { /* Clear all the static flags */ __HAL_SD_CLEAR_FLAG(hsd, SDIO_STATIC_FLAGS); hsd->ErrorCode |= HAL_SD_ERROR_DATA_TIMEOUT; hsd->State = HAL_SD_STATE_READY; hsd->Context = SD_CONTEXT_NONE; return HAL_ERROR; } else if(__HAL_SD_GET_FLAG(hsd, SDIO_FLAG_DCRCFAIL)) { /* Clear all the static flags */ __HAL_SD_CLEAR_FLAG(hsd, SDIO_STATIC_FLAGS); hsd->ErrorCode |= HAL_SD_ERROR_DATA_CRC_FAIL; hsd->State = HAL_SD_STATE_READY; hsd->Context = SD_CONTEXT_NONE; return HAL_ERROR; } else if(__HAL_SD_GET_FLAG(hsd, SDIO_FLAG_RXOVERR)) { /* Clear all the static flags */ __HAL_SD_CLEAR_FLAG(hsd, SDIO_STATIC_FLAGS); hsd->ErrorCode |= HAL_SD_ERROR_RX_OVERRUN; hsd->State = HAL_SD_STATE_READY; hsd->Context = SD_CONTEXT_NONE; return HAL_ERROR; } else { /* Nothing to do */ } /* Empty FIFO if there is still any data */ while ((__HAL_SD_GET_FLAG(hsd, SDIO_FLAG_RXDAVL)) && (dataremaining > 0U)) { data = SDIO_ReadFIFO(hsd->Instance); *tempbuff = (uint8_t)(data & 0xFFU); tempbuff++; dataremaining--; *tempbuff = (uint8_t)((data >> 8U) & 0xFFU); tempbuff++; dataremaining--; *tempbuff = (uint8_t)((data >> 16U) & 0xFFU); tempbuff++; dataremaining--; *tempbuff = (uint8_t)((data >> 24U) & 0xFFU); tempbuff++; dataremaining--; if(((HAL_GetTick()-tickstart) >= Timeout) || (Timeout == 0U)) { /* Clear all the static flags */ __HAL_SD_CLEAR_FLAG(hsd, SDIO_STATIC_FLAGS); hsd->ErrorCode |= HAL_SD_ERROR_TIMEOUT; hsd->State= HAL_SD_STATE_READY; hsd->Context = SD_CONTEXT_NONE; return HAL_ERROR; } } /* Clear all the static flags */ __HAL_SD_CLEAR_FLAG(hsd, SDIO_STATIC_DATA_FLAGS); hsd->State = HAL_SD_STATE_READY; return HAL_OK; } else { hsd->ErrorCode |= HAL_SD_ERROR_BUSY; return HAL_ERROR; } } /** * @brief Allows to write block(s) to a specified address in a card. The Data * transfer is managed by polling mode. * @note This API should be followed by a check on the card state through * HAL_SD_GetCardState(). * @param hsd: Pointer to SD handle * @param pData: pointer to the buffer that will contain the data to transmit * @param BlockAdd: Block Address where data will be written * @param NumberOfBlocks: Number of SD blocks to write * @param Timeout: Specify timeout value * @retval HAL status */ HAL_StatusTypeDef HAL_SD_WriteBlocks(SD_HandleTypeDef *hsd, uint8_t *pData, uint32_t BlockAdd, uint32_t NumberOfBlocks, uint32_t Timeout) { SDIO_DataInitTypeDef config; uint32_t errorstate; uint32_t tickstart = HAL_GetTick(); uint32_t count, data, dataremaining; uint32_t add = BlockAdd; uint8_t *tempbuff = pData; if(NULL == pData) { hsd->ErrorCode |= HAL_SD_ERROR_PARAM; return HAL_ERROR; } if(hsd->State == HAL_SD_STATE_READY) { hsd->ErrorCode = HAL_SD_ERROR_NONE; if((add + NumberOfBlocks) > (hsd->SdCard.LogBlockNbr)) { hsd->ErrorCode |= HAL_SD_ERROR_ADDR_OUT_OF_RANGE; return HAL_ERROR; } hsd->State = HAL_SD_STATE_BUSY; /* Initialize data control register */ hsd->Instance->DCTRL = 0U; if(hsd->SdCard.CardType != CARD_SDHC_SDXC) { add *= 512U; } /* Set Block Size for Card */ errorstate = SDMMC_CmdBlockLength(hsd->Instance, BLOCKSIZE); if(errorstate != HAL_SD_ERROR_NONE) { /* Clear all the static flags */ __HAL_SD_CLEAR_FLAG(hsd, SDIO_STATIC_FLAGS); hsd->ErrorCode |= errorstate; hsd->State = HAL_SD_STATE_READY; return HAL_ERROR; } /* Configure the SD DPSM (Data Path State Machine) */ config.DataTimeOut = SDMMC_DATATIMEOUT; config.DataLength = NumberOfBlocks * BLOCKSIZE; config.DataBlockSize = SDIO_DATABLOCK_SIZE_512B; config.TransferDir = SDIO_TRANSFER_DIR_TO_CARD; config.TransferMode = SDIO_TRANSFER_MODE_BLOCK; config.DPSM = SDIO_DPSM_ENABLE; (void)SDIO_ConfigData(hsd->Instance, &config); /* Write Blocks in Polling mode */ if(NumberOfBlocks > 1U) { hsd->Context = SD_CONTEXT_WRITE_MULTIPLE_BLOCK; /* Write Multi Block command */ errorstate = SDMMC_CmdWriteMultiBlock(hsd->Instance, add); } else { hsd->Context = SD_CONTEXT_WRITE_SINGLE_BLOCK; /* Write Single Block command */ errorstate = SDMMC_CmdWriteSingleBlock(hsd->Instance, add); } if(errorstate != HAL_SD_ERROR_NONE) { /* Clear all the static flags */ __HAL_SD_CLEAR_FLAG(hsd, SDIO_STATIC_FLAGS); hsd->ErrorCode |= errorstate; hsd->State = HAL_SD_STATE_READY; hsd->Context = SD_CONTEXT_NONE; return HAL_ERROR; } /* Write block(s) in polling mode */ dataremaining = config.DataLength; #if defined(SDIO_STA_STBITERR) while(!__HAL_SD_GET_FLAG(hsd, SDIO_FLAG_TXUNDERR | SDIO_FLAG_DCRCFAIL | SDIO_FLAG_DTIMEOUT | SDIO_FLAG_DATAEND | SDIO_FLAG_STBITERR)) #else /* SDIO_STA_STBITERR not defined */ while(!__HAL_SD_GET_FLAG(hsd, SDIO_FLAG_TXUNDERR | SDIO_FLAG_DCRCFAIL | SDIO_FLAG_DTIMEOUT | SDIO_FLAG_DATAEND)) #endif /* SDIO_STA_STBITERR */ { if(__HAL_SD_GET_FLAG(hsd, SDIO_FLAG_TXFIFOHE) && (dataremaining > 0U)) { /* Write data to SDIO Tx FIFO */ for(count = 0U; count < 8U; count++) { data = (uint32_t)(*tempbuff); tempbuff++; dataremaining--; data |= ((uint32_t)(*tempbuff) << 8U); tempbuff++; dataremaining--; data |= ((uint32_t)(*tempbuff) << 16U); tempbuff++; dataremaining--; data |= ((uint32_t)(*tempbuff) << 24U); tempbuff++; dataremaining--; (void)SDIO_WriteFIFO(hsd->Instance, &data); } } if(((HAL_GetTick()-tickstart) >= Timeout) || (Timeout == 0U)) { /* Clear all the static flags */ __HAL_SD_CLEAR_FLAG(hsd, SDIO_STATIC_FLAGS); hsd->ErrorCode |= errorstate; hsd->State = HAL_SD_STATE_READY; hsd->Context = SD_CONTEXT_NONE; return HAL_TIMEOUT; } } /* Send stop transmission command in case of multiblock write */ if(__HAL_SD_GET_FLAG(hsd, SDIO_FLAG_DATAEND) && (NumberOfBlocks > 1U)) { if(hsd->SdCard.CardType != CARD_SECURED) { /* Send stop transmission command */ errorstate = SDMMC_CmdStopTransfer(hsd->Instance); if(errorstate != HAL_SD_ERROR_NONE) { /* Clear all the static flags */ __HAL_SD_CLEAR_FLAG(hsd, SDIO_STATIC_FLAGS); hsd->ErrorCode |= errorstate; hsd->State = HAL_SD_STATE_READY; hsd->Context = SD_CONTEXT_NONE; return HAL_ERROR; } } } /* Get error state */ if(__HAL_SD_GET_FLAG(hsd, SDIO_FLAG_DTIMEOUT)) { /* Clear all the static flags */ __HAL_SD_CLEAR_FLAG(hsd, SDIO_STATIC_FLAGS); hsd->ErrorCode |= HAL_SD_ERROR_DATA_TIMEOUT; hsd->State = HAL_SD_STATE_READY; hsd->Context = SD_CONTEXT_NONE; return HAL_ERROR; } else if(__HAL_SD_GET_FLAG(hsd, SDIO_FLAG_DCRCFAIL)) { /* Clear all the static flags */ __HAL_SD_CLEAR_FLAG(hsd, SDIO_STATIC_FLAGS); hsd->ErrorCode |= HAL_SD_ERROR_DATA_CRC_FAIL; hsd->State = HAL_SD_STATE_READY; hsd->Context = SD_CONTEXT_NONE; return HAL_ERROR; } else if(__HAL_SD_GET_FLAG(hsd, SDIO_FLAG_TXUNDERR)) { /* Clear all the static flags */ __HAL_SD_CLEAR_FLAG(hsd, SDIO_STATIC_FLAGS); hsd->ErrorCode |= HAL_SD_ERROR_TX_UNDERRUN; hsd->State = HAL_SD_STATE_READY; hsd->Context = SD_CONTEXT_NONE; return HAL_ERROR; } else { /* Nothing to do */ } /* Clear all the static flags */ __HAL_SD_CLEAR_FLAG(hsd, SDIO_STATIC_DATA_FLAGS); hsd->State = HAL_SD_STATE_READY; return HAL_OK; } else { hsd->ErrorCode |= HAL_SD_ERROR_BUSY; return HAL_ERROR; } } /** * @brief Reads block(s) from a specified address in a card. The Data transfer * is managed in interrupt mode. * @note This API should be followed by a check on the card state through * HAL_SD_GetCardState(). * @note You could also check the IT transfer process through the SD Rx * interrupt event. * @param hsd: Pointer to SD handle * @param pData: Pointer to the buffer that will contain the received data * @param BlockAdd: Block Address from where data is to be read * @param NumberOfBlocks: Number of blocks to read. * @retval HAL status */ HAL_StatusTypeDef HAL_SD_ReadBlocks_IT(SD_HandleTypeDef *hsd, uint8_t *pData, uint32_t BlockAdd, uint32_t NumberOfBlocks) { SDIO_DataInitTypeDef config; uint32_t errorstate; uint32_t add = BlockAdd; if(NULL == pData) { hsd->ErrorCode |= HAL_SD_ERROR_PARAM; return HAL_ERROR; } if(hsd->State == HAL_SD_STATE_READY) { hsd->ErrorCode = HAL_SD_ERROR_NONE; if((add + NumberOfBlocks) > (hsd->SdCard.LogBlockNbr)) { hsd->ErrorCode |= HAL_SD_ERROR_ADDR_OUT_OF_RANGE; return HAL_ERROR; } hsd->State = HAL_SD_STATE_BUSY; /* Initialize data control register */ hsd->Instance->DCTRL = 0U; hsd->pRxBuffPtr = pData; hsd->RxXferSize = BLOCKSIZE * NumberOfBlocks; #if defined(SDIO_STA_STBITERR) __HAL_SD_ENABLE_IT(hsd, (SDIO_IT_DCRCFAIL | SDIO_IT_DTIMEOUT | SDIO_IT_RXOVERR | SDIO_IT_DATAEND | SDIO_FLAG_RXFIFOHF | SDIO_IT_STBITERR)); #else /* SDIO_STA_STBITERR not defined */ __HAL_SD_ENABLE_IT(hsd, (SDIO_IT_DCRCFAIL | SDIO_IT_DTIMEOUT | SDIO_IT_RXOVERR | SDIO_IT_DATAEND | SDIO_FLAG_RXFIFOHF)); #endif /* SDIO_STA_STBITERR */ if(hsd->SdCard.CardType != CARD_SDHC_SDXC) { add *= 512U; } /* Set Block Size for Card */ errorstate = SDMMC_CmdBlockLength(hsd->Instance, BLOCKSIZE); if(errorstate != HAL_SD_ERROR_NONE) { /* Clear all the static flags */ __HAL_SD_CLEAR_FLAG(hsd, SDIO_STATIC_FLAGS); hsd->ErrorCode |= errorstate; hsd->State = HAL_SD_STATE_READY; return HAL_ERROR; } /* Configure the SD DPSM (Data Path State Machine) */ config.DataTimeOut = SDMMC_DATATIMEOUT; config.DataLength = BLOCKSIZE * NumberOfBlocks; config.DataBlockSize = SDIO_DATABLOCK_SIZE_512B; config.TransferDir = SDIO_TRANSFER_DIR_TO_SDIO; config.TransferMode = SDIO_TRANSFER_MODE_BLOCK; config.DPSM = SDIO_DPSM_ENABLE; (void)SDIO_ConfigData(hsd->Instance, &config); /* Read Blocks in IT mode */ if(NumberOfBlocks > 1U) { hsd->Context = (SD_CONTEXT_READ_MULTIPLE_BLOCK | SD_CONTEXT_IT); /* Read Multi Block command */ errorstate = SDMMC_CmdReadMultiBlock(hsd->Instance, add); } else { hsd->Context = (SD_CONTEXT_READ_SINGLE_BLOCK | SD_CONTEXT_IT); /* Read Single Block command */ errorstate = SDMMC_CmdReadSingleBlock(hsd->Instance, add); } if(errorstate != HAL_SD_ERROR_NONE) { /* Clear all the static flags */ __HAL_SD_CLEAR_FLAG(hsd, SDIO_STATIC_FLAGS); hsd->ErrorCode |= errorstate; hsd->State = HAL_SD_STATE_READY; hsd->Context = SD_CONTEXT_NONE; return HAL_ERROR; } return HAL_OK; } else { return HAL_BUSY; } } /** * @brief Writes block(s) to a specified address in a card. The Data transfer * is managed in interrupt mode. * @note This API should be followed by a check on the card state through * HAL_SD_GetCardState(). * @note You could also check the IT transfer process through the SD Tx * interrupt event. * @param hsd: Pointer to SD handle * @param pData: Pointer to the buffer that will contain the data to transmit * @param BlockAdd: Block Address where data will be written * @param NumberOfBlocks: Number of blocks to write * @retval HAL status */ HAL_StatusTypeDef HAL_SD_WriteBlocks_IT(SD_HandleTypeDef *hsd, uint8_t *pData, uint32_t BlockAdd, uint32_t NumberOfBlocks) { SDIO_DataInitTypeDef config; uint32_t errorstate; uint32_t add = BlockAdd; if(NULL == pData) { hsd->ErrorCode |= HAL_SD_ERROR_PARAM; return HAL_ERROR; } if(hsd->State == HAL_SD_STATE_READY) { hsd->ErrorCode = HAL_SD_ERROR_NONE; if((add + NumberOfBlocks) > (hsd->SdCard.LogBlockNbr)) { hsd->ErrorCode |= HAL_SD_ERROR_ADDR_OUT_OF_RANGE; return HAL_ERROR; } hsd->State = HAL_SD_STATE_BUSY; /* Initialize data control register */ hsd->Instance->DCTRL = 0U; hsd->pTxBuffPtr = pData; hsd->TxXferSize = BLOCKSIZE * NumberOfBlocks; /* Enable transfer interrupts */ #if defined(SDIO_STA_STBITERR) __HAL_SD_ENABLE_IT(hsd, (SDIO_IT_DCRCFAIL | SDIO_IT_DTIMEOUT | SDIO_IT_TXUNDERR | SDIO_IT_DATAEND | SDIO_FLAG_TXFIFOHE | SDIO_IT_STBITERR)); #else /* SDIO_STA_STBITERR not defined */ __HAL_SD_ENABLE_IT(hsd, (SDIO_IT_DCRCFAIL | SDIO_IT_DTIMEOUT | SDIO_IT_TXUNDERR | SDIO_IT_DATAEND | SDIO_FLAG_TXFIFOHE)); #endif /* SDIO_STA_STBITERR */ if(hsd->SdCard.CardType != CARD_SDHC_SDXC) { add *= 512U; } /* Set Block Size for Card */ errorstate = SDMMC_CmdBlockLength(hsd->Instance, BLOCKSIZE); if(errorstate != HAL_SD_ERROR_NONE) { /* Clear all the static flags */ __HAL_SD_CLEAR_FLAG(hsd, SDIO_STATIC_FLAGS); hsd->ErrorCode |= errorstate; hsd->State = HAL_SD_STATE_READY; return HAL_ERROR; } /* Write Blocks in Polling mode */ if(NumberOfBlocks > 1U) { hsd->Context = (SD_CONTEXT_WRITE_MULTIPLE_BLOCK| SD_CONTEXT_IT); /* Write Multi Block command */ errorstate = SDMMC_CmdWriteMultiBlock(hsd->Instance, add); } else { hsd->Context = (SD_CONTEXT_WRITE_SINGLE_BLOCK | SD_CONTEXT_IT); /* Write Single Block command */ errorstate = SDMMC_CmdWriteSingleBlock(hsd->Instance, add); } if(errorstate != HAL_SD_ERROR_NONE) { /* Clear all the static flags */ __HAL_SD_CLEAR_FLAG(hsd, SDIO_STATIC_FLAGS); hsd->ErrorCode |= errorstate; hsd->State = HAL_SD_STATE_READY; hsd->Context = SD_CONTEXT_NONE; return HAL_ERROR; } /* Configure the SD DPSM (Data Path State Machine) */ config.DataTimeOut = SDMMC_DATATIMEOUT; config.DataLength = BLOCKSIZE * NumberOfBlocks; config.DataBlockSize = SDIO_DATABLOCK_SIZE_512B; config.TransferDir = SDIO_TRANSFER_DIR_TO_CARD; config.TransferMode = SDIO_TRANSFER_MODE_BLOCK; config.DPSM = SDIO_DPSM_ENABLE; (void)SDIO_ConfigData(hsd->Instance, &config); return HAL_OK; } else { return HAL_BUSY; } } #if 0 // XXX DMA /** * @brief Reads block(s) from a specified address in a card. The Data transfer * is managed by DMA mode. * @note This API should be followed by a check on the card state through * HAL_SD_GetCardState(). * @note You could also check the DMA transfer process through the SD Rx * interrupt event. * @param hsd: Pointer SD handle * @param pData: Pointer to the buffer that will contain the received data * @param BlockAdd: Block Address from where data is to be read * @param NumberOfBlocks: Number of blocks to read. * @retval HAL status */ HAL_StatusTypeDef HAL_SD_ReadBlocks_DMA(SD_HandleTypeDef *hsd, uint8_t *pData, uint32_t BlockAdd, uint32_t NumberOfBlocks) { SDIO_DataInitTypeDef config; uint32_t errorstate; uint32_t add = BlockAdd; if(NULL == pData) { hsd->ErrorCode |= HAL_SD_ERROR_PARAM; return HAL_ERROR; } if(hsd->State == HAL_SD_STATE_READY) { hsd->ErrorCode = HAL_SD_ERROR_NONE; if((add + NumberOfBlocks) > (hsd->SdCard.LogBlockNbr)) { hsd->ErrorCode |= HAL_SD_ERROR_ADDR_OUT_OF_RANGE; return HAL_ERROR; } hsd->State = HAL_SD_STATE_BUSY; /* Initialize data control register */ hsd->Instance->DCTRL = 0U; #if defined(SDIO_STA_STBITERR) __HAL_SD_ENABLE_IT(hsd, (SDIO_IT_DCRCFAIL | SDIO_IT_DTIMEOUT | SDIO_IT_RXOVERR | SDIO_IT_DATAEND | SDIO_IT_STBITERR)); #else /* SDIO_STA_STBITERR not defined */ __HAL_SD_ENABLE_IT(hsd, (SDIO_IT_DCRCFAIL | SDIO_IT_DTIMEOUT | SDIO_IT_RXOVERR | SDIO_IT_DATAEND)); #endif /* SDIO_STA_STBITERR */ /* Set the DMA transfer complete callback */ hsd->hdmarx->XferCpltCallback = SD_DMAReceiveCplt; /* Set the DMA error callback */ hsd->hdmarx->XferErrorCallback = SD_DMAError; /* Set the DMA Abort callback */ hsd->hdmarx->XferAbortCallback = NULL; /* Enable the DMA Channel */ if(HAL_DMA_Start_IT(hsd->hdmarx, (uint32_t)&hsd->Instance->FIFO, (uint32_t)pData, (uint32_t)(BLOCKSIZE * NumberOfBlocks)/4U) != HAL_OK) { __HAL_SD_DISABLE_IT(hsd, (SDIO_IT_DCRCFAIL | SDIO_IT_DTIMEOUT | SDIO_IT_RXOVERR | SDIO_IT_DATAEND)); __HAL_SD_CLEAR_FLAG(hsd, SDIO_STATIC_FLAGS); hsd->ErrorCode |= HAL_SD_ERROR_DMA; hsd->State = HAL_SD_STATE_READY; return HAL_ERROR; } else { /* Enable SD DMA transfer */ __HAL_SD_DMA_ENABLE(hsd); if(hsd->SdCard.CardType != CARD_SDHC_SDXC) { add *= 512U; } /* Set Block Size for Card */ errorstate = SDMMC_CmdBlockLength(hsd->Instance, BLOCKSIZE); if(errorstate != HAL_SD_ERROR_NONE) { /* Clear all the static flags */ __HAL_SD_CLEAR_FLAG(hsd, SDIO_STATIC_FLAGS); hsd->ErrorCode |= errorstate; hsd->State = HAL_SD_STATE_READY; return HAL_ERROR; } /* Configure the SD DPSM (Data Path State Machine) */ config.DataTimeOut = SDMMC_DATATIMEOUT; config.DataLength = BLOCKSIZE * NumberOfBlocks; config.DataBlockSize = SDIO_DATABLOCK_SIZE_512B; config.TransferDir = SDIO_TRANSFER_DIR_TO_SDIO; config.TransferMode = SDIO_TRANSFER_MODE_BLOCK; config.DPSM = SDIO_DPSM_ENABLE; (void)SDIO_ConfigData(hsd->Instance, &config); /* Read Blocks in DMA mode */ if(NumberOfBlocks > 1U) { hsd->Context = (SD_CONTEXT_READ_MULTIPLE_BLOCK | SD_CONTEXT_DMA); /* Read Multi Block command */ errorstate = SDMMC_CmdReadMultiBlock(hsd->Instance, add); } else { hsd->Context = (SD_CONTEXT_READ_SINGLE_BLOCK | SD_CONTEXT_DMA); /* Read Single Block command */ errorstate = SDMMC_CmdReadSingleBlock(hsd->Instance, add); } if(errorstate != HAL_SD_ERROR_NONE) { /* Clear all the static flags */ __HAL_SD_CLEAR_FLAG(hsd, SDIO_STATIC_FLAGS); hsd->ErrorCode |= errorstate; hsd->State = HAL_SD_STATE_READY; hsd->Context = SD_CONTEXT_NONE; return HAL_ERROR; } return HAL_OK; } } else { return HAL_BUSY; } } /** * @brief Writes block(s) to a specified address in a card. The Data transfer * is managed by DMA mode. * @note This API should be followed by a check on the card state through * HAL_SD_GetCardState(). * @note You could also check the DMA transfer process through the SD Tx * interrupt event. * @param hsd: Pointer to SD handle * @param pData: Pointer to the buffer that will contain the data to transmit * @param BlockAdd: Block Address where data will be written * @param NumberOfBlocks: Number of blocks to write * @retval HAL status */ HAL_StatusTypeDef HAL_SD_WriteBlocks_DMA(SD_HandleTypeDef *hsd, uint8_t *pData, uint32_t BlockAdd, uint32_t NumberOfBlocks) { SDIO_DataInitTypeDef config; uint32_t errorstate; uint32_t add = BlockAdd; if(NULL == pData) { hsd->ErrorCode |= HAL_SD_ERROR_PARAM; return HAL_ERROR; } if(hsd->State == HAL_SD_STATE_READY) { hsd->ErrorCode = HAL_SD_ERROR_NONE; if((add + NumberOfBlocks) > (hsd->SdCard.LogBlockNbr)) { hsd->ErrorCode |= HAL_SD_ERROR_ADDR_OUT_OF_RANGE; return HAL_ERROR; } hsd->State = HAL_SD_STATE_BUSY; /* Initialize data control register */ hsd->Instance->DCTRL = 0U; /* Enable SD Error interrupts */ #if defined(SDIO_STA_STBITERR) __HAL_SD_ENABLE_IT(hsd, (SDIO_IT_DCRCFAIL | SDIO_IT_DTIMEOUT | SDIO_IT_TXUNDERR | SDIO_IT_STBITERR)); #else /* SDIO_STA_STBITERR not defined */ __HAL_SD_ENABLE_IT(hsd, (SDIO_IT_DCRCFAIL | SDIO_IT_DTIMEOUT | SDIO_IT_TXUNDERR)); #endif /* SDIO_STA_STBITERR */ /* Set the DMA transfer complete callback */ hsd->hdmatx->XferCpltCallback = SD_DMATransmitCplt; /* Set the DMA error callback */ hsd->hdmatx->XferErrorCallback = SD_DMAError; /* Set the DMA Abort callback */ hsd->hdmatx->XferAbortCallback = NULL; if(hsd->SdCard.CardType != CARD_SDHC_SDXC) { add *= 512U; } /* Set Block Size for Card */ errorstate = SDMMC_CmdBlockLength(hsd->Instance, BLOCKSIZE); if(errorstate != HAL_SD_ERROR_NONE) { /* Clear all the static flags */ __HAL_SD_CLEAR_FLAG(hsd, SDIO_STATIC_FLAGS); hsd->ErrorCode |= errorstate; hsd->State = HAL_SD_STATE_READY; return HAL_ERROR; } /* Write Blocks in Polling mode */ if(NumberOfBlocks > 1U) { hsd->Context = (SD_CONTEXT_WRITE_MULTIPLE_BLOCK | SD_CONTEXT_DMA); /* Write Multi Block command */ errorstate = SDMMC_CmdWriteMultiBlock(hsd->Instance, add); } else { hsd->Context = (SD_CONTEXT_WRITE_SINGLE_BLOCK | SD_CONTEXT_DMA); /* Write Single Block command */ errorstate = SDMMC_CmdWriteSingleBlock(hsd->Instance, add); } if(errorstate != HAL_SD_ERROR_NONE) { /* Clear all the static flags */ __HAL_SD_CLEAR_FLAG(hsd, SDIO_STATIC_FLAGS); hsd->ErrorCode |= errorstate; hsd->State = HAL_SD_STATE_READY; hsd->Context = SD_CONTEXT_NONE; return HAL_ERROR; } /* Enable SDIO DMA transfer */ __HAL_SD_DMA_ENABLE(hsd); /* Enable the DMA Channel */ if(HAL_DMA_Start_IT(hsd->hdmatx, (uint32_t)pData, (uint32_t)&hsd->Instance->FIFO, (uint32_t)(BLOCKSIZE * NumberOfBlocks)/4U) != HAL_OK) { #if defined(SDIO_STA_STBITERR) __HAL_SD_DISABLE_IT(hsd, (SDIO_IT_DCRCFAIL | SDIO_IT_DTIMEOUT | SDIO_IT_TXUNDERR | SDIO_IT_STBITERR)); #else /* SDIO_STA_STBITERR not defined */ __HAL_SD_DISABLE_IT(hsd, (SDIO_IT_DCRCFAIL | SDIO_IT_DTIMEOUT | SDIO_IT_TXUNDERR)); #endif /* SDIO_STA_STBITERR */ __HAL_SD_CLEAR_FLAG(hsd, SDIO_STATIC_FLAGS); hsd->ErrorCode |= HAL_SD_ERROR_DMA; hsd->State = HAL_SD_STATE_READY; hsd->Context = SD_CONTEXT_NONE; return HAL_ERROR; } else { /* Configure the SD DPSM (Data Path State Machine) */ config.DataTimeOut = SDMMC_DATATIMEOUT; config.DataLength = BLOCKSIZE * NumberOfBlocks; config.DataBlockSize = SDIO_DATABLOCK_SIZE_512B; config.TransferDir = SDIO_TRANSFER_DIR_TO_CARD; config.TransferMode = SDIO_TRANSFER_MODE_BLOCK; config.DPSM = SDIO_DPSM_ENABLE; (void)SDIO_ConfigData(hsd->Instance, &config); return HAL_OK; } } else { return HAL_BUSY; } } #endif // XXX DMA /** * @brief Erases the specified memory area of the given SD card. * @note This API should be followed by a check on the card state through * HAL_SD_GetCardState(). * @param hsd: Pointer to SD handle * @param BlockStartAdd: Start Block address * @param BlockEndAdd: End Block address * @retval HAL status */ HAL_StatusTypeDef HAL_SD_Erase(SD_HandleTypeDef *hsd, uint32_t BlockStartAdd, uint32_t BlockEndAdd) { uint32_t errorstate; uint32_t start_add = BlockStartAdd; uint32_t end_add = BlockEndAdd; if(hsd->State == HAL_SD_STATE_READY) { hsd->ErrorCode = HAL_SD_ERROR_NONE; if(end_add < start_add) { hsd->ErrorCode |= HAL_SD_ERROR_PARAM; return HAL_ERROR; } if(end_add > (hsd->SdCard.LogBlockNbr)) { hsd->ErrorCode |= HAL_SD_ERROR_ADDR_OUT_OF_RANGE; return HAL_ERROR; } hsd->State = HAL_SD_STATE_BUSY; /* Check if the card command class supports erase command */ if(((hsd->SdCard.Class) & SDIO_CCCC_ERASE) == 0U) { /* Clear all the static flags */ __HAL_SD_CLEAR_FLAG(hsd, SDIO_STATIC_FLAGS); hsd->ErrorCode |= HAL_SD_ERROR_REQUEST_NOT_APPLICABLE; hsd->State = HAL_SD_STATE_READY; return HAL_ERROR; } if((SDIO_GetResponse(hsd->Instance, SDIO_RESP1) & SDMMC_CARD_LOCKED) == SDMMC_CARD_LOCKED) { /* Clear all the static flags */ __HAL_SD_CLEAR_FLAG(hsd, SDIO_STATIC_FLAGS); hsd->ErrorCode |= HAL_SD_ERROR_LOCK_UNLOCK_FAILED; hsd->State = HAL_SD_STATE_READY; return HAL_ERROR; } /* Get start and end block for high capacity cards */ if(hsd->SdCard.CardType != CARD_SDHC_SDXC) { start_add *= 512U; end_add *= 512U; } /* According to sd-card spec 1.0 ERASE_GROUP_START (CMD32) and erase_group_end(CMD33) */ if(hsd->SdCard.CardType != CARD_SECURED) { /* Send CMD32 SD_ERASE_GRP_START with argument as addr */ errorstate = SDMMC_CmdSDEraseStartAdd(hsd->Instance, start_add); if(errorstate != HAL_SD_ERROR_NONE) { /* Clear all the static flags */ __HAL_SD_CLEAR_FLAG(hsd, SDIO_STATIC_FLAGS); hsd->ErrorCode |= errorstate; hsd->State = HAL_SD_STATE_READY; return HAL_ERROR; } /* Send CMD33 SD_ERASE_GRP_END with argument as addr */ errorstate = SDMMC_CmdSDEraseEndAdd(hsd->Instance, end_add); if(errorstate != HAL_SD_ERROR_NONE) { /* Clear all the static flags */ __HAL_SD_CLEAR_FLAG(hsd, SDIO_STATIC_FLAGS); hsd->ErrorCode |= errorstate; hsd->State = HAL_SD_STATE_READY; return HAL_ERROR; } } /* Send CMD38 ERASE */ errorstate = SDMMC_CmdErase(hsd->Instance); if(errorstate != HAL_SD_ERROR_NONE) { /* Clear all the static flags */ __HAL_SD_CLEAR_FLAG(hsd, SDIO_STATIC_FLAGS); hsd->ErrorCode |= errorstate; hsd->State = HAL_SD_STATE_READY; return HAL_ERROR; } hsd->State = HAL_SD_STATE_READY; return HAL_OK; } else { return HAL_BUSY; } } /** * @brief This function handles SD card interrupt request. * @param hsd: Pointer to SD handle * @retval None */ void HAL_SD_IRQHandler(SD_HandleTypeDef *hsd) { uint32_t errorstate; uint32_t context = hsd->Context; /* Check for SDIO interrupt flags */ if((__HAL_SD_GET_FLAG(hsd, SDIO_FLAG_RXFIFOHF) != RESET) && ((context & SD_CONTEXT_IT) != 0U)) { SD_Read_IT(hsd); } else if(__HAL_SD_GET_FLAG(hsd, SDIO_FLAG_DATAEND) != RESET) { __HAL_SD_CLEAR_FLAG(hsd, SDIO_FLAG_DATAEND); #if defined(SDIO_STA_STBITERR) __HAL_SD_DISABLE_IT(hsd, SDIO_IT_DATAEND | SDIO_IT_DCRCFAIL | SDIO_IT_DTIMEOUT|\ SDIO_IT_TXUNDERR | SDIO_IT_RXOVERR | SDIO_IT_TXFIFOHE |\ SDIO_IT_RXFIFOHF | SDIO_IT_STBITERR); #else /* SDIO_STA_STBITERR not defined */ __HAL_SD_DISABLE_IT(hsd, SDIO_IT_DATAEND | SDIO_IT_DCRCFAIL | SDIO_IT_DTIMEOUT|\ SDIO_IT_TXUNDERR | SDIO_IT_RXOVERR | SDIO_IT_TXFIFOHE |\ SDIO_IT_RXFIFOHF); #endif /* SDIO_STA_STBITERR */ hsd->Instance->DCTRL &= ~(SDIO_DCTRL_DTEN); if((context & SD_CONTEXT_IT) != 0U) { if(((context & SD_CONTEXT_READ_MULTIPLE_BLOCK) != 0U) || ((context & SD_CONTEXT_WRITE_MULTIPLE_BLOCK) != 0U)) { errorstate = SDMMC_CmdStopTransfer(hsd->Instance); if(errorstate != HAL_SD_ERROR_NONE) { hsd->ErrorCode |= errorstate; #if defined (USE_HAL_SD_REGISTER_CALLBACKS) && (USE_HAL_SD_REGISTER_CALLBACKS == 1U) hsd->ErrorCallback(hsd); #else HAL_SD_ErrorCallback(hsd); #endif /* USE_HAL_SD_REGISTER_CALLBACKS */ } } /* Clear all the static flags */ __HAL_SD_CLEAR_FLAG(hsd, SDIO_STATIC_DATA_FLAGS); hsd->State = HAL_SD_STATE_READY; hsd->Context = SD_CONTEXT_NONE; if(((context & SD_CONTEXT_READ_SINGLE_BLOCK) != 0U) || ((context & SD_CONTEXT_READ_MULTIPLE_BLOCK) != 0U)) { #if defined (USE_HAL_SD_REGISTER_CALLBACKS) && (USE_HAL_SD_REGISTER_CALLBACKS == 1U) hsd->RxCpltCallback(hsd); #else HAL_SD_RxCpltCallback(hsd); #endif /* USE_HAL_SD_REGISTER_CALLBACKS */ } else { #if defined (USE_HAL_SD_REGISTER_CALLBACKS) && (USE_HAL_SD_REGISTER_CALLBACKS == 1U) hsd->TxCpltCallback(hsd); #else HAL_SD_TxCpltCallback(hsd); #endif /* USE_HAL_SD_REGISTER_CALLBACKS */ } } else if((context & SD_CONTEXT_DMA) != 0U) { if((context & SD_CONTEXT_WRITE_MULTIPLE_BLOCK) != 0U) { errorstate = SDMMC_CmdStopTransfer(hsd->Instance); if(errorstate != HAL_SD_ERROR_NONE) { hsd->ErrorCode |= errorstate; #if defined (USE_HAL_SD_REGISTER_CALLBACKS) && (USE_HAL_SD_REGISTER_CALLBACKS == 1U) hsd->ErrorCallback(hsd); #else HAL_SD_ErrorCallback(hsd); #endif /* USE_HAL_SD_REGISTER_CALLBACKS */ } } if(((context & SD_CONTEXT_READ_SINGLE_BLOCK) == 0U) && ((context & SD_CONTEXT_READ_MULTIPLE_BLOCK) == 0U)) { /* Disable the DMA transfer for transmit request by setting the DMAEN bit in the SD DCTRL register */ hsd->Instance->DCTRL &= (uint32_t)~((uint32_t)SDIO_DCTRL_DMAEN); hsd->State = HAL_SD_STATE_READY; #if defined (USE_HAL_SD_REGISTER_CALLBACKS) && (USE_HAL_SD_REGISTER_CALLBACKS == 1U) hsd->TxCpltCallback(hsd); #else HAL_SD_TxCpltCallback(hsd); #endif /* USE_HAL_SD_REGISTER_CALLBACKS */ } } else { /* Nothing to do */ } } else if((__HAL_SD_GET_FLAG(hsd, SDIO_FLAG_TXFIFOHE) != RESET) && ((context & SD_CONTEXT_IT) != 0U)) { SD_Write_IT(hsd); } #if defined(SDIO_STA_STBITERR) else if(__HAL_SD_GET_FLAG(hsd, SDIO_FLAG_DCRCFAIL | SDIO_FLAG_DTIMEOUT | SDIO_FLAG_RXOVERR | SDIO_FLAG_TXUNDERR | SDIO_FLAG_STBITERR) != RESET) #else /* SDIO_STA_STBITERR not defined */ else if(__HAL_SD_GET_FLAG(hsd, SDIO_FLAG_DCRCFAIL | SDIO_FLAG_DTIMEOUT | SDIO_FLAG_RXOVERR | SDIO_FLAG_TXUNDERR) != RESET) #endif /* SDIO_STA_STBITERR */ { /* Set Error code */ if(__HAL_SD_GET_FLAG(hsd, SDIO_FLAG_DCRCFAIL) != RESET) { hsd->ErrorCode |= HAL_SD_ERROR_DATA_CRC_FAIL; } if(__HAL_SD_GET_FLAG(hsd, SDIO_FLAG_DTIMEOUT) != RESET) { hsd->ErrorCode |= HAL_SD_ERROR_DATA_TIMEOUT; } if(__HAL_SD_GET_FLAG(hsd, SDIO_FLAG_RXOVERR) != RESET) { hsd->ErrorCode |= HAL_SD_ERROR_RX_OVERRUN; } if(__HAL_SD_GET_FLAG(hsd, SDIO_FLAG_TXUNDERR) != RESET) { hsd->ErrorCode |= HAL_SD_ERROR_TX_UNDERRUN; } #if defined(SDIO_STA_STBITERR) if(__HAL_SD_GET_FLAG(hsd, SDIO_FLAG_STBITERR) != RESET) { hsd->ErrorCode |= HAL_SD_ERROR_DATA_TIMEOUT; } #endif /* SDIO_STA_STBITERR */ #if defined(SDIO_STA_STBITERR) /* Clear All flags */ __HAL_SD_CLEAR_FLAG(hsd, SDIO_STATIC_DATA_FLAGS | SDIO_FLAG_STBITERR); /* Disable all interrupts */ __HAL_SD_DISABLE_IT(hsd, SDIO_IT_DATAEND | SDIO_IT_DCRCFAIL | SDIO_IT_DTIMEOUT|\ SDIO_IT_TXUNDERR| SDIO_IT_RXOVERR | SDIO_IT_STBITERR); #else /* SDIO_STA_STBITERR not defined */ /* Clear All flags */ __HAL_SD_CLEAR_FLAG(hsd, SDIO_STATIC_DATA_FLAGS); /* Disable all interrupts */ __HAL_SD_DISABLE_IT(hsd, SDIO_IT_DATAEND | SDIO_IT_DCRCFAIL | SDIO_IT_DTIMEOUT|\ SDIO_IT_TXUNDERR| SDIO_IT_RXOVERR); #endif /* SDIO_STA_STBITERR */ hsd->ErrorCode |= SDMMC_CmdStopTransfer(hsd->Instance); if((context & SD_CONTEXT_IT) != 0U) { /* Set the SD state to ready to be able to start again the process */ hsd->State = HAL_SD_STATE_READY; hsd->Context = SD_CONTEXT_NONE; #if defined (USE_HAL_SD_REGISTER_CALLBACKS) && (USE_HAL_SD_REGISTER_CALLBACKS == 1U) hsd->ErrorCallback(hsd); #else HAL_SD_ErrorCallback(hsd); #endif /* USE_HAL_SD_REGISTER_CALLBACKS */ } else if((context & SD_CONTEXT_DMA) != 0U) { #if 0 // XXX DMA /* Abort the SD DMA channel */ if(((context & SD_CONTEXT_WRITE_SINGLE_BLOCK) != 0U) || ((context & SD_CONTEXT_WRITE_MULTIPLE_BLOCK) != 0U)) { /* Set the DMA Tx abort callback */ hsd->hdmatx->XferAbortCallback = SD_DMATxAbort; /* Abort DMA in IT mode */ if(HAL_DMA_Abort_IT(hsd->hdmatx) != HAL_OK) { SD_DMATxAbort(hsd->hdmatx); } } else if(((context & SD_CONTEXT_READ_SINGLE_BLOCK) != 0U) || ((context & SD_CONTEXT_READ_MULTIPLE_BLOCK) != 0U)) { /* Set the DMA Rx abort callback */ hsd->hdmarx->XferAbortCallback = SD_DMARxAbort; /* Abort DMA in IT mode */ if(HAL_DMA_Abort_IT(hsd->hdmarx) != HAL_OK) { SD_DMARxAbort(hsd->hdmarx); } } else { hsd->ErrorCode = HAL_SD_ERROR_NONE; hsd->State = HAL_SD_STATE_READY; hsd->Context = SD_CONTEXT_NONE; #if defined (USE_HAL_SD_REGISTER_CALLBACKS) && (USE_HAL_SD_REGISTER_CALLBACKS == 1U) hsd->AbortCpltCallback(hsd); #else HAL_SD_AbortCallback(hsd); #endif /* USE_HAL_SD_REGISTER_CALLBACKS */ } #endif // XXX DMA } else { /* Nothing to do */ } } else { /* Nothing to do */ } } /** * @brief return the SD state * @param hsd: Pointer to sd handle * @retval HAL state */ HAL_SD_StateTypeDef HAL_SD_GetState(SD_HandleTypeDef *hsd) { return hsd->State; } /** * @brief Return the SD error code * @param hsd : Pointer to a SD_HandleTypeDef structure that contains * the configuration information. * @retval SD Error Code */ uint32_t HAL_SD_GetError(SD_HandleTypeDef *hsd) { return hsd->ErrorCode; } /** * @brief Tx Transfer completed callbacks * @param hsd: Pointer to SD handle * @retval None */ __weak void HAL_SD_TxCpltCallback(SD_HandleTypeDef *hsd) { /* Prevent unused argument(s) compilation warning */ UNUSED(hsd); /* NOTE : This function should not be modified, when the callback is needed, the HAL_SD_TxCpltCallback can be implemented in the user file */ } /** * @brief Rx Transfer completed callbacks * @param hsd: Pointer SD handle * @retval None */ __weak void HAL_SD_RxCpltCallback(SD_HandleTypeDef *hsd) { /* Prevent unused argument(s) compilation warning */ UNUSED(hsd); /* NOTE : This function should not be modified, when the callback is needed, the HAL_SD_RxCpltCallback can be implemented in the user file */ } /** * @brief SD error callbacks * @param hsd: Pointer SD handle * @retval None */ __weak void HAL_SD_ErrorCallback(SD_HandleTypeDef *hsd) { /* Prevent unused argument(s) compilation warning */ UNUSED(hsd); /* NOTE : This function should not be modified, when the callback is needed, the HAL_SD_ErrorCallback can be implemented in the user file */ } /** * @brief SD Abort callbacks * @param hsd: Pointer SD handle * @retval None */ __weak void HAL_SD_AbortCallback(SD_HandleTypeDef *hsd) { /* Prevent unused argument(s) compilation warning */ UNUSED(hsd); /* NOTE : This function should not be modified, when the callback is needed, the HAL_SD_AbortCallback can be implemented in the user file */ } #if defined (USE_HAL_SD_REGISTER_CALLBACKS) && (USE_HAL_SD_REGISTER_CALLBACKS == 1U) /** * @brief Register a User SD Callback * To be used instead of the weak (surcharged) predefined callback * @param hsd : SD handle * @param CallbackID : ID of the callback to be registered * This parameter can be one of the following values: * @arg @ref HAL_SD_TX_CPLT_CB_ID SD Tx Complete Callback ID * @arg @ref HAL_SD_RX_CPLT_CB_ID SD Rx Complete Callback ID * @arg @ref HAL_SD_ERROR_CB_ID SD Error Callback ID * @arg @ref HAL_SD_ABORT_CB_ID SD Abort Callback ID * @arg @ref HAL_SD_MSP_INIT_CB_ID SD MspInit Callback ID * @arg @ref HAL_SD_MSP_DEINIT_CB_ID SD MspDeInit Callback ID * @param pCallback : pointer to the Callback function * @retval status */ HAL_StatusTypeDef HAL_SD_RegisterCallback(SD_HandleTypeDef *hsd, HAL_SD_CallbackIDTypeDef CallbackID, pSD_CallbackTypeDef pCallback) { HAL_StatusTypeDef status = HAL_OK; if(pCallback == NULL) { /* Update the error code */ hsd->ErrorCode |= HAL_SD_ERROR_INVALID_CALLBACK; return HAL_ERROR; } /* Process locked */ __HAL_LOCK(hsd); if(hsd->State == HAL_SD_STATE_READY) { switch (CallbackID) { case HAL_SD_TX_CPLT_CB_ID : hsd->TxCpltCallback = pCallback; break; case HAL_SD_RX_CPLT_CB_ID : hsd->RxCpltCallback = pCallback; break; case HAL_SD_ERROR_CB_ID : hsd->ErrorCallback = pCallback; break; case HAL_SD_ABORT_CB_ID : hsd->AbortCpltCallback = pCallback; break; case HAL_SD_MSP_INIT_CB_ID : hsd->MspInitCallback = pCallback; break; case HAL_SD_MSP_DEINIT_CB_ID : hsd->MspDeInitCallback = pCallback; break; default : /* Update the error code */ hsd->ErrorCode |= HAL_SD_ERROR_INVALID_CALLBACK; /* update return status */ status = HAL_ERROR; break; } } else if (hsd->State == HAL_SD_STATE_RESET) { switch (CallbackID) { case HAL_SD_MSP_INIT_CB_ID : hsd->MspInitCallback = pCallback; break; case HAL_SD_MSP_DEINIT_CB_ID : hsd->MspDeInitCallback = pCallback; break; default : /* Update the error code */ hsd->ErrorCode |= HAL_SD_ERROR_INVALID_CALLBACK; /* update return status */ status = HAL_ERROR; break; } } else { /* Update the error code */ hsd->ErrorCode |= HAL_SD_ERROR_INVALID_CALLBACK; /* update return status */ status = HAL_ERROR; } /* Release Lock */ __HAL_UNLOCK(hsd); return status; } /** * @brief Unregister a User SD Callback * SD Callback is redirected to the weak (surcharged) predefined callback * @param hsd : SD handle * @param CallbackID : ID of the callback to be unregistered * This parameter can be one of the following values: * @arg @ref HAL_SD_TX_CPLT_CB_ID SD Tx Complete Callback ID * @arg @ref HAL_SD_RX_CPLT_CB_ID SD Rx Complete Callback ID * @arg @ref HAL_SD_ERROR_CB_ID SD Error Callback ID * @arg @ref HAL_SD_ABORT_CB_ID SD Abort Callback ID * @arg @ref HAL_SD_MSP_INIT_CB_ID SD MspInit Callback ID * @arg @ref HAL_SD_MSP_DEINIT_CB_ID SD MspDeInit Callback ID * @retval status */ HAL_StatusTypeDef HAL_SD_UnRegisterCallback(SD_HandleTypeDef *hsd, HAL_SD_CallbackIDTypeDef CallbackID) { HAL_StatusTypeDef status = HAL_OK; /* Process locked */ __HAL_LOCK(hsd); if(hsd->State == HAL_SD_STATE_READY) { switch (CallbackID) { case HAL_SD_TX_CPLT_CB_ID : hsd->TxCpltCallback = HAL_SD_TxCpltCallback; break; case HAL_SD_RX_CPLT_CB_ID : hsd->RxCpltCallback = HAL_SD_RxCpltCallback; break; case HAL_SD_ERROR_CB_ID : hsd->ErrorCallback = HAL_SD_ErrorCallback; break; case HAL_SD_ABORT_CB_ID : hsd->AbortCpltCallback = HAL_SD_AbortCallback; break; case HAL_SD_MSP_INIT_CB_ID : hsd->MspInitCallback = HAL_SD_MspInit; break; case HAL_SD_MSP_DEINIT_CB_ID : hsd->MspDeInitCallback = HAL_SD_MspDeInit; break; default : /* Update the error code */ hsd->ErrorCode |= HAL_SD_ERROR_INVALID_CALLBACK; /* update return status */ status = HAL_ERROR; break; } } else if (hsd->State == HAL_SD_STATE_RESET) { switch (CallbackID) { case HAL_SD_MSP_INIT_CB_ID : hsd->MspInitCallback = HAL_SD_MspInit; break; case HAL_SD_MSP_DEINIT_CB_ID : hsd->MspDeInitCallback = HAL_SD_MspDeInit; break; default : /* Update the error code */ hsd->ErrorCode |= HAL_SD_ERROR_INVALID_CALLBACK; /* update return status */ status = HAL_ERROR; break; } } else { /* Update the error code */ hsd->ErrorCode |= HAL_SD_ERROR_INVALID_CALLBACK; /* update return status */ status = HAL_ERROR; } /* Release Lock */ __HAL_UNLOCK(hsd); return status; } #endif /* USE_HAL_SD_REGISTER_CALLBACKS */ /** * @} */ /** @addtogroup SD_Exported_Functions_Group3 * @brief management functions * @verbatim ============================================================================== ##### Peripheral Control functions ##### ============================================================================== [..] This subsection provides a set of functions allowing to control the SD card operations and get the related information @endverbatim * @{ */ /** * @brief Returns information the information of the card which are stored on * the CID register. * @param hsd: Pointer to SD handle * @param pCID: Pointer to a HAL_SD_CardCIDTypeDef structure that * contains all CID register parameters * @retval HAL status */ HAL_StatusTypeDef HAL_SD_GetCardCID(SD_HandleTypeDef *hsd, HAL_SD_CardCIDTypeDef *pCID) { pCID->ManufacturerID = (uint8_t)((hsd->CID[0] & 0xFF000000U) >> 24U); pCID->OEM_AppliID = (uint16_t)((hsd->CID[0] & 0x00FFFF00U) >> 8U); pCID->ProdName1 = (((hsd->CID[0] & 0x000000FFU) << 24U) | ((hsd->CID[1] & 0xFFFFFF00U) >> 8U)); pCID->ProdName2 = (uint8_t)(hsd->CID[1] & 0x000000FFU); pCID->ProdRev = (uint8_t)((hsd->CID[2] & 0xFF000000U) >> 24U); pCID->ProdSN = (((hsd->CID[2] & 0x00FFFFFFU) << 8U) | ((hsd->CID[3] & 0xFF000000U) >> 24U)); pCID->Reserved1 = (uint8_t)((hsd->CID[3] & 0x00F00000U) >> 20U); pCID->ManufactDate = (uint16_t)((hsd->CID[3] & 0x000FFF00U) >> 8U); pCID->CID_CRC = (uint8_t)((hsd->CID[3] & 0x000000FEU) >> 1U); pCID->Reserved2 = 1U; return HAL_OK; } /** * @brief Returns information the information of the card which are stored on * the CSD register. * @param hsd: Pointer to SD handle * @param pCSD: Pointer to a HAL_SD_CardCSDTypeDef structure that * contains all CSD register parameters * @retval HAL status */ HAL_StatusTypeDef HAL_SD_GetCardCSD(SD_HandleTypeDef *hsd, HAL_SD_CardCSDTypeDef *pCSD) { pCSD->CSDStruct = (uint8_t)((hsd->CSD[0] & 0xC0000000U) >> 30U); pCSD->SysSpecVersion = (uint8_t)((hsd->CSD[0] & 0x3C000000U) >> 26U); pCSD->Reserved1 = (uint8_t)((hsd->CSD[0] & 0x03000000U) >> 24U); pCSD->TAAC = (uint8_t)((hsd->CSD[0] & 0x00FF0000U) >> 16U); pCSD->NSAC = (uint8_t)((hsd->CSD[0] & 0x0000FF00U) >> 8U); pCSD->MaxBusClkFrec = (uint8_t)(hsd->CSD[0] & 0x000000FFU); pCSD->CardComdClasses = (uint16_t)((hsd->CSD[1] & 0xFFF00000U) >> 20U); pCSD->RdBlockLen = (uint8_t)((hsd->CSD[1] & 0x000F0000U) >> 16U); pCSD->PartBlockRead = (uint8_t)((hsd->CSD[1] & 0x00008000U) >> 15U); pCSD->WrBlockMisalign = (uint8_t)((hsd->CSD[1] & 0x00004000U) >> 14U); pCSD->RdBlockMisalign = (uint8_t)((hsd->CSD[1] & 0x00002000U) >> 13U); pCSD->DSRImpl = (uint8_t)((hsd->CSD[1] & 0x00001000U) >> 12U); pCSD->Reserved2 = 0U; /*!< Reserved */ if(hsd->SdCard.CardType == CARD_SDSC) { pCSD->DeviceSize = (((hsd->CSD[1] & 0x000003FFU) << 2U) | ((hsd->CSD[2] & 0xC0000000U) >> 30U)); pCSD->MaxRdCurrentVDDMin = (uint8_t)((hsd->CSD[2] & 0x38000000U) >> 27U); pCSD->MaxRdCurrentVDDMax = (uint8_t)((hsd->CSD[2] & 0x07000000U) >> 24U); pCSD->MaxWrCurrentVDDMin = (uint8_t)((hsd->CSD[2] & 0x00E00000U) >> 21U); pCSD->MaxWrCurrentVDDMax = (uint8_t)((hsd->CSD[2] & 0x001C0000U) >> 18U); pCSD->DeviceSizeMul = (uint8_t)((hsd->CSD[2] & 0x00038000U) >> 15U); hsd->SdCard.BlockNbr = (pCSD->DeviceSize + 1U) ; hsd->SdCard.BlockNbr *= (1UL << ((pCSD->DeviceSizeMul & 0x07U) + 2U)); hsd->SdCard.BlockSize = (1UL << (pCSD->RdBlockLen & 0x0FU)); hsd->SdCard.LogBlockNbr = (hsd->SdCard.BlockNbr) * ((hsd->SdCard.BlockSize) / 512U); hsd->SdCard.LogBlockSize = 512U; } else if(hsd->SdCard.CardType == CARD_SDHC_SDXC) { /* Byte 7 */ pCSD->DeviceSize = (((hsd->CSD[1] & 0x0000003FU) << 16U) | ((hsd->CSD[2] & 0xFFFF0000U) >> 16U)); hsd->SdCard.BlockNbr = ((pCSD->DeviceSize + 1U) * 1024U); hsd->SdCard.LogBlockNbr = hsd->SdCard.BlockNbr; hsd->SdCard.BlockSize = 512U; hsd->SdCard.LogBlockSize = hsd->SdCard.BlockSize; } else { /* Clear all the static flags */ __HAL_SD_CLEAR_FLAG(hsd, SDIO_STATIC_FLAGS); hsd->ErrorCode |= HAL_SD_ERROR_UNSUPPORTED_FEATURE; hsd->State = HAL_SD_STATE_READY; return HAL_ERROR; } pCSD->EraseGrSize = (uint8_t)((hsd->CSD[2] & 0x00004000U) >> 14U); pCSD->EraseGrMul = (uint8_t)((hsd->CSD[2] & 0x00003F80U) >> 7U); pCSD->WrProtectGrSize = (uint8_t)(hsd->CSD[2] & 0x0000007FU); pCSD->WrProtectGrEnable = (uint8_t)((hsd->CSD[3] & 0x80000000U) >> 31U); pCSD->ManDeflECC = (uint8_t)((hsd->CSD[3] & 0x60000000U) >> 29U); pCSD->WrSpeedFact = (uint8_t)((hsd->CSD[3] & 0x1C000000U) >> 26U); pCSD->MaxWrBlockLen= (uint8_t)((hsd->CSD[3] & 0x03C00000U) >> 22U); pCSD->WriteBlockPaPartial = (uint8_t)((hsd->CSD[3] & 0x00200000U) >> 21U); pCSD->Reserved3 = 0; pCSD->ContentProtectAppli = (uint8_t)((hsd->CSD[3] & 0x00010000U) >> 16U); pCSD->FileFormatGroup = (uint8_t)((hsd->CSD[3] & 0x00008000U) >> 15U); pCSD->CopyFlag = (uint8_t)((hsd->CSD[3] & 0x00004000U) >> 14U); pCSD->PermWrProtect = (uint8_t)((hsd->CSD[3] & 0x00002000U) >> 13U); pCSD->TempWrProtect = (uint8_t)((hsd->CSD[3] & 0x00001000U) >> 12U); pCSD->FileFormat = (uint8_t)((hsd->CSD[3] & 0x00000C00U) >> 10U); pCSD->ECC= (uint8_t)((hsd->CSD[3] & 0x00000300U) >> 8U); pCSD->CSD_CRC = (uint8_t)((hsd->CSD[3] & 0x000000FEU) >> 1U); pCSD->Reserved4 = 1; return HAL_OK; } /** * @brief Gets the SD status info. * @param hsd: Pointer to SD handle * @param pStatus: Pointer to the HAL_SD_CardStatusTypeDef structure that * will contain the SD card status information * @retval HAL status */ HAL_StatusTypeDef HAL_SD_GetCardStatus(SD_HandleTypeDef *hsd, HAL_SD_CardStatusTypeDef *pStatus) { uint32_t sd_status[16]; uint32_t errorstate; errorstate = SD_SendSDStatus(hsd, sd_status); if(errorstate != HAL_SD_ERROR_NONE) { /* Clear all the static flags */ __HAL_SD_CLEAR_FLAG(hsd, SDIO_STATIC_FLAGS); hsd->ErrorCode |= errorstate; hsd->State = HAL_SD_STATE_READY; return HAL_ERROR; } else { pStatus->DataBusWidth = (uint8_t)((sd_status[0] & 0xC0U) >> 6U); pStatus->SecuredMode = (uint8_t)((sd_status[0] & 0x20U) >> 5U); pStatus->CardType = (uint16_t)(((sd_status[0] & 0x00FF0000U) >> 8U) | ((sd_status[0] & 0xFF000000U) >> 24U)); pStatus->ProtectedAreaSize = (((sd_status[1] & 0xFFU) << 24U) | ((sd_status[1] & 0xFF00U) << 8U) | ((sd_status[1] & 0xFF0000U) >> 8U) | ((sd_status[1] & 0xFF000000U) >> 24U)); pStatus->SpeedClass = (uint8_t)(sd_status[2] & 0xFFU); pStatus->PerformanceMove = (uint8_t)((sd_status[2] & 0xFF00U) >> 8U); pStatus->AllocationUnitSize = (uint8_t)((sd_status[2] & 0xF00000U) >> 20U); pStatus->EraseSize = (uint16_t)(((sd_status[2] & 0xFF000000U) >> 16U) | (sd_status[3] & 0xFFU)); pStatus->EraseTimeout = (uint8_t)((sd_status[3] & 0xFC00U) >> 10U); pStatus->EraseOffset = (uint8_t)((sd_status[3] & 0x0300U) >> 8U); } return HAL_OK; } /** * @brief Gets the SD card info. * @param hsd: Pointer to SD handle * @param pCardInfo: Pointer to the HAL_SD_CardInfoTypeDef structure that * will contain the SD card status information * @retval HAL status */ HAL_StatusTypeDef HAL_SD_GetCardInfo(SD_HandleTypeDef *hsd, HAL_SD_CardInfoTypeDef *pCardInfo) { pCardInfo->CardType = (uint32_t)(hsd->SdCard.CardType); pCardInfo->CardVersion = (uint32_t)(hsd->SdCard.CardVersion); pCardInfo->Class = (uint32_t)(hsd->SdCard.Class); pCardInfo->RelCardAdd = (uint32_t)(hsd->SdCard.RelCardAdd); pCardInfo->BlockNbr = (uint32_t)(hsd->SdCard.BlockNbr); pCardInfo->BlockSize = (uint32_t)(hsd->SdCard.BlockSize); pCardInfo->LogBlockNbr = (uint32_t)(hsd->SdCard.LogBlockNbr); pCardInfo->LogBlockSize = (uint32_t)(hsd->SdCard.LogBlockSize); return HAL_OK; } /** * @brief Enables wide bus operation for the requested card if supported by * card. * @param hsd: Pointer to SD handle * @param WideMode: Specifies the SD card wide bus mode * This parameter can be one of the following values: * @arg SDIO_BUS_WIDE_8B: 8-bit data transfer * @arg SDIO_BUS_WIDE_4B: 4-bit data transfer * @arg SDIO_BUS_WIDE_1B: 1-bit data transfer * @retval HAL status */ HAL_StatusTypeDef HAL_SD_ConfigWideBusOperation(SD_HandleTypeDef *hsd, uint32_t WideMode) { SDIO_InitTypeDef Init; uint32_t errorstate; /* Check the parameters */ assert_param(IS_SDIO_BUS_WIDE(WideMode)); /* Change State */ hsd->State = HAL_SD_STATE_BUSY; if(hsd->SdCard.CardType != CARD_SECURED) { if(WideMode == SDIO_BUS_WIDE_8B) { hsd->ErrorCode |= HAL_SD_ERROR_UNSUPPORTED_FEATURE; } else if(WideMode == SDIO_BUS_WIDE_4B) { errorstate = SD_WideBus_Enable(hsd); hsd->ErrorCode |= errorstate; } else if(WideMode == SDIO_BUS_WIDE_1B) { errorstate = SD_WideBus_Disable(hsd); hsd->ErrorCode |= errorstate; } else { /* WideMode is not a valid argument*/ hsd->ErrorCode |= HAL_SD_ERROR_PARAM; } } else { /* MMC Card does not support this feature */ hsd->ErrorCode |= HAL_SD_ERROR_UNSUPPORTED_FEATURE; } if(hsd->ErrorCode != HAL_SD_ERROR_NONE) { /* Clear all the static flags */ __HAL_SD_CLEAR_FLAG(hsd, SDIO_STATIC_FLAGS); hsd->State = HAL_SD_STATE_READY; return HAL_ERROR; } else { /* Configure the SDIO peripheral */ Init.ClockEdge = hsd->Init.ClockEdge; Init.ClockBypass = hsd->Init.ClockBypass; Init.ClockPowerSave = hsd->Init.ClockPowerSave; Init.BusWide = WideMode; Init.HardwareFlowControl = hsd->Init.HardwareFlowControl; Init.ClockDiv = hsd->Init.ClockDiv; (void)SDIO_Init(hsd->Instance, Init); } /* Change State */ hsd->State = HAL_SD_STATE_READY; return HAL_OK; } /** * @brief Gets the current sd card data state. * @param hsd: pointer to SD handle * @retval Card state */ HAL_SD_CardStateTypeDef HAL_SD_GetCardState(SD_HandleTypeDef *hsd) { uint32_t cardstate; uint32_t errorstate; uint32_t resp1 = 0; errorstate = SD_SendStatus(hsd, &resp1); if(errorstate != HAL_SD_ERROR_NONE) { hsd->ErrorCode |= errorstate; } cardstate = ((resp1 >> 9U) & 0x0FU); return (HAL_SD_CardStateTypeDef)cardstate; } /** * @brief Abort the current transfer and disable the SD. * @param hsd: pointer to a SD_HandleTypeDef structure that contains * the configuration information for SD module. * @retval HAL status */ HAL_StatusTypeDef HAL_SD_Abort(SD_HandleTypeDef *hsd) { HAL_SD_CardStateTypeDef CardState; #if 0 // XXX DMA uint32_t context = hsd->Context; #endif // XXX DMA /* DIsable All interrupts */ __HAL_SD_DISABLE_IT(hsd, SDIO_IT_DATAEND | SDIO_IT_DCRCFAIL | SDIO_IT_DTIMEOUT|\ SDIO_IT_TXUNDERR| SDIO_IT_RXOVERR); /* Clear All flags */ __HAL_SD_CLEAR_FLAG(hsd, SDIO_STATIC_DATA_FLAGS); CLEAR_BIT(hsd->Instance->DCTRL, SDIO_DCTRL_DTEN); #if 0 // XXX DMA if ((context & SD_CONTEXT_DMA) != 0U) { /* Disable the SD DMA request */ hsd->Instance->DCTRL &= (uint32_t)~((uint32_t)SDIO_DCTRL_DMAEN); /* Abort the SD DMA Tx channel */ if (((context & SD_CONTEXT_WRITE_SINGLE_BLOCK) != 0U) || ((context & SD_CONTEXT_WRITE_MULTIPLE_BLOCK) != 0U)) { if(HAL_DMA_Abort(hsd->hdmatx) != HAL_OK) { hsd->ErrorCode |= HAL_SD_ERROR_DMA; } } /* Abort the SD DMA Rx channel */ else if (((context & SD_CONTEXT_READ_SINGLE_BLOCK) != 0U) || ((context & SD_CONTEXT_READ_MULTIPLE_BLOCK) != 0U)) { if(HAL_DMA_Abort(hsd->hdmarx) != HAL_OK) { hsd->ErrorCode |= HAL_SD_ERROR_DMA; } } else { /* Nothing to do */ } } #endif // XXX DMA hsd->State = HAL_SD_STATE_READY; /* Initialize the SD operation */ hsd->Context = SD_CONTEXT_NONE; CardState = HAL_SD_GetCardState(hsd); if((CardState == HAL_SD_CARD_RECEIVING) || (CardState == HAL_SD_CARD_SENDING)) { hsd->ErrorCode = SDMMC_CmdStopTransfer(hsd->Instance); } if(hsd->ErrorCode != HAL_SD_ERROR_NONE) { return HAL_ERROR; } return HAL_OK; } /** * @brief Abort the current transfer and disable the SD (IT mode). * @param hsd: pointer to a SD_HandleTypeDef structure that contains * the configuration information for SD module. * @retval HAL status */ HAL_StatusTypeDef HAL_SD_Abort_IT(SD_HandleTypeDef *hsd) { #if 0 // XXX DMA HAL_SD_CardStateTypeDef CardState; uint32_t context = hsd->Context; #endif // XXX DMA /* Disable All interrupts */ __HAL_SD_DISABLE_IT(hsd, SDIO_IT_DATAEND | SDIO_IT_DCRCFAIL | SDIO_IT_DTIMEOUT|\ SDIO_IT_TXUNDERR| SDIO_IT_RXOVERR); CLEAR_BIT(hsd->Instance->DCTRL, SDIO_DCTRL_DTEN); #if 0 // XXX DMA if ((context & SD_CONTEXT_DMA) != 0U) { /* Disable the SD DMA request */ hsd->Instance->DCTRL &= (uint32_t)~((uint32_t)SDIO_DCTRL_DMAEN); /* Abort the SD DMA Tx channel */ if (((context & SD_CONTEXT_WRITE_SINGLE_BLOCK) != 0U) || ((context & SD_CONTEXT_WRITE_MULTIPLE_BLOCK) != 0U)) { hsd->hdmatx->XferAbortCallback = SD_DMATxAbort; if(HAL_DMA_Abort_IT(hsd->hdmatx) != HAL_OK) { hsd->hdmatx = NULL; } } /* Abort the SD DMA Rx channel */ else if (((context & SD_CONTEXT_READ_SINGLE_BLOCK) != 0U) || ((context & SD_CONTEXT_READ_MULTIPLE_BLOCK) != 0U)) { hsd->hdmarx->XferAbortCallback = SD_DMARxAbort; if(HAL_DMA_Abort_IT(hsd->hdmarx) != HAL_OK) { hsd->hdmarx = NULL; } } else { /* Nothing to do */ } } /* No transfer ongoing on both DMA channels*/ else { /* Clear All flags */ __HAL_SD_CLEAR_FLAG(hsd, SDIO_STATIC_DATA_FLAGS); CardState = HAL_SD_GetCardState(hsd); hsd->State = HAL_SD_STATE_READY; hsd->Context = SD_CONTEXT_NONE; if((CardState == HAL_SD_CARD_RECEIVING) || (CardState == HAL_SD_CARD_SENDING)) { hsd->ErrorCode = SDMMC_CmdStopTransfer(hsd->Instance); } if(hsd->ErrorCode != HAL_SD_ERROR_NONE) { return HAL_ERROR; } else { #if defined (USE_HAL_SD_REGISTER_CALLBACKS) && (USE_HAL_SD_REGISTER_CALLBACKS == 1U) hsd->AbortCpltCallback(hsd); #else HAL_SD_AbortCallback(hsd); #endif /* USE_HAL_SD_REGISTER_CALLBACKS */ } } #endif // XXX DMA return HAL_OK; } /** * @} */ /** * @} */ /* Private function ----------------------------------------------------------*/ /** @addtogroup SD_Private_Functions * @{ */ #if 0 // XXX DMA /** * @brief DMA SD transmit process complete callback * @param hdma: DMA handle * @retval None */ static void SD_DMATransmitCplt(DMA_HandleTypeDef *hdma) { SD_HandleTypeDef* hsd = (SD_HandleTypeDef* )(hdma->Parent); /* Enable DATAEND Interrupt */ __HAL_SD_ENABLE_IT(hsd, (SDIO_IT_DATAEND)); } /** * @brief DMA SD receive process complete callback * @param hdma: DMA handle * @retval None */ static void SD_DMAReceiveCplt(DMA_HandleTypeDef *hdma) { SD_HandleTypeDef* hsd = (SD_HandleTypeDef* )(hdma->Parent); uint32_t errorstate; /* Send stop command in multiblock write */ if(hsd->Context == (SD_CONTEXT_READ_MULTIPLE_BLOCK | SD_CONTEXT_DMA)) { errorstate = SDMMC_CmdStopTransfer(hsd->Instance); if(errorstate != HAL_SD_ERROR_NONE) { hsd->ErrorCode |= errorstate; #if (USE_HAL_SD_REGISTER_CALLBACKS == 1) hsd->ErrorCallback(hsd); #else HAL_SD_ErrorCallback(hsd); #endif } } /* Disable the DMA transfer for transmit request by setting the DMAEN bit in the SD DCTRL register */ hsd->Instance->DCTRL &= (uint32_t)~((uint32_t)SDIO_DCTRL_DMAEN); /* Clear all the static flags */ __HAL_SD_CLEAR_FLAG(hsd, SDIO_STATIC_DATA_FLAGS); hsd->State = HAL_SD_STATE_READY; hsd->Context = SD_CONTEXT_NONE; #if (USE_HAL_SD_REGISTER_CALLBACKS == 1) hsd->RxCpltCallback(hsd); #else HAL_SD_RxCpltCallback(hsd); #endif } /** * @brief DMA SD communication error callback * @param hdma: DMA handle * @retval None */ static void SD_DMAError(DMA_HandleTypeDef *hdma) { SD_HandleTypeDef* hsd = (SD_HandleTypeDef* )(hdma->Parent); HAL_SD_CardStateTypeDef CardState; uint32_t RxErrorCode, TxErrorCode; /* if DMA error is FIFO error ignore it */ if(HAL_DMA_GetError(hdma) != HAL_DMA_ERROR_FE) { RxErrorCode = hsd->hdmarx->ErrorCode; TxErrorCode = hsd->hdmatx->ErrorCode; if((RxErrorCode == HAL_DMA_ERROR_TE) || (TxErrorCode == HAL_DMA_ERROR_TE)) { /* Clear All flags */ __HAL_SD_CLEAR_FLAG(hsd, SDIO_STATIC_FLAGS); /* Disable All interrupts */ __HAL_SD_DISABLE_IT(hsd, SDIO_IT_DATAEND | SDIO_IT_DCRCFAIL | SDIO_IT_DTIMEOUT|\ SDIO_IT_TXUNDERR| SDIO_IT_RXOVERR); hsd->ErrorCode |= HAL_SD_ERROR_DMA; CardState = HAL_SD_GetCardState(hsd); if((CardState == HAL_SD_CARD_RECEIVING) || (CardState == HAL_SD_CARD_SENDING)) { hsd->ErrorCode |= SDMMC_CmdStopTransfer(hsd->Instance); } hsd->State = HAL_SD_STATE_READY; hsd->Context = SD_CONTEXT_NONE; } #if (USE_HAL_SD_REGISTER_CALLBACKS == 1) hsd->ErrorCallback(hsd); #else HAL_SD_ErrorCallback(hsd); #endif } } /** * @brief DMA SD Tx Abort callback * @param hdma: DMA handle * @retval None */ static void SD_DMATxAbort(DMA_HandleTypeDef *hdma) { SD_HandleTypeDef* hsd = (SD_HandleTypeDef* )(hdma->Parent); HAL_SD_CardStateTypeDef CardState; /* Clear All flags */ __HAL_SD_CLEAR_FLAG(hsd, SDIO_STATIC_DATA_FLAGS); CardState = HAL_SD_GetCardState(hsd); hsd->State = HAL_SD_STATE_READY; hsd->Context = SD_CONTEXT_NONE; if((CardState == HAL_SD_CARD_RECEIVING) || (CardState == HAL_SD_CARD_SENDING)) { hsd->ErrorCode |= SDMMC_CmdStopTransfer(hsd->Instance); } if(hsd->ErrorCode == HAL_SD_ERROR_NONE) { #if (USE_HAL_SD_REGISTER_CALLBACKS == 1) hsd->AbortCpltCallback(hsd); #else HAL_SD_AbortCallback(hsd); #endif } else { #if (USE_HAL_SD_REGISTER_CALLBACKS == 1) hsd->ErrorCallback(hsd); #else HAL_SD_ErrorCallback(hsd); #endif } } /** * @brief DMA SD Rx Abort callback * @param hdma: DMA handle * @retval None */ static void SD_DMARxAbort(DMA_HandleTypeDef *hdma) { SD_HandleTypeDef* hsd = (SD_HandleTypeDef* )(hdma->Parent); HAL_SD_CardStateTypeDef CardState; /* Clear All flags */ __HAL_SD_CLEAR_FLAG(hsd, SDIO_STATIC_DATA_FLAGS); CardState = HAL_SD_GetCardState(hsd); hsd->State = HAL_SD_STATE_READY; hsd->Context = SD_CONTEXT_NONE; if((CardState == HAL_SD_CARD_RECEIVING) || (CardState == HAL_SD_CARD_SENDING)) { hsd->ErrorCode |= SDMMC_CmdStopTransfer(hsd->Instance); } if(hsd->ErrorCode == HAL_SD_ERROR_NONE) { #if (USE_HAL_SD_REGISTER_CALLBACKS == 1) hsd->AbortCpltCallback(hsd); #else HAL_SD_AbortCallback(hsd); #endif } else { #if (USE_HAL_SD_REGISTER_CALLBACKS == 1) hsd->ErrorCallback(hsd); #else HAL_SD_ErrorCallback(hsd); #endif } } #endif // XXX DMA /** * @brief Initializes the sd card. * @param hsd: Pointer to SD handle * @retval SD Card error state */ static uint32_t SD_InitCard(SD_HandleTypeDef *hsd) { HAL_SD_CardCSDTypeDef CSD; uint32_t errorstate; uint16_t sd_rca = 1U; /* Check the power State */ if(SDIO_GetPowerState(hsd->Instance) == 0U) { /* Power off */ return HAL_SD_ERROR_REQUEST_NOT_APPLICABLE; } if(hsd->SdCard.CardType != CARD_SECURED) { /* Send CMD2 ALL_SEND_CID */ errorstate = SDMMC_CmdSendCID(hsd->Instance); if(errorstate != HAL_SD_ERROR_NONE) { return errorstate; } else { /* Get Card identification number data */ hsd->CID[0U] = SDIO_GetResponse(hsd->Instance, SDIO_RESP1); hsd->CID[1U] = SDIO_GetResponse(hsd->Instance, SDIO_RESP2); hsd->CID[2U] = SDIO_GetResponse(hsd->Instance, SDIO_RESP3); hsd->CID[3U] = SDIO_GetResponse(hsd->Instance, SDIO_RESP4); } } if(hsd->SdCard.CardType != CARD_SECURED) { /* Send CMD3 SET_REL_ADDR with argument 0 */ /* SD Card publishes its RCA. */ errorstate = SDMMC_CmdSetRelAdd(hsd->Instance, &sd_rca); if(errorstate != HAL_SD_ERROR_NONE) { return errorstate; } } if(hsd->SdCard.CardType != CARD_SECURED) { /* Get the SD card RCA */ hsd->SdCard.RelCardAdd = sd_rca; /* Send CMD9 SEND_CSD with argument as card's RCA */ errorstate = SDMMC_CmdSendCSD(hsd->Instance, (uint32_t)(hsd->SdCard.RelCardAdd << 16U)); if(errorstate != HAL_SD_ERROR_NONE) { return errorstate; } else { /* Get Card Specific Data */ hsd->CSD[0U] = SDIO_GetResponse(hsd->Instance, SDIO_RESP1); hsd->CSD[1U] = SDIO_GetResponse(hsd->Instance, SDIO_RESP2); hsd->CSD[2U] = SDIO_GetResponse(hsd->Instance, SDIO_RESP3); hsd->CSD[3U] = SDIO_GetResponse(hsd->Instance, SDIO_RESP4); } } /* Get the Card Class */ hsd->SdCard.Class = (SDIO_GetResponse(hsd->Instance, SDIO_RESP2) >> 20U); /* Get CSD parameters */ if (HAL_SD_GetCardCSD(hsd, &CSD) != HAL_OK) { return HAL_SD_ERROR_UNSUPPORTED_FEATURE; } /* Select the Card */ errorstate = SDMMC_CmdSelDesel(hsd->Instance, (uint32_t)(((uint32_t)hsd->SdCard.RelCardAdd) << 16U)); if(errorstate != HAL_SD_ERROR_NONE) { return errorstate; } /* Configure SDIO peripheral interface */ (void)SDIO_Init(hsd->Instance, hsd->Init); /* All cards are initialized */ return HAL_SD_ERROR_NONE; } /** * @brief Enquires cards about their operating voltage and configures clock * controls and stores SD information that will be needed in future * in the SD handle. * @param hsd: Pointer to SD handle * @retval error state */ static uint32_t SD_PowerON(SD_HandleTypeDef *hsd) { __IO uint32_t count = 0U; uint32_t response = 0U, validvoltage = 0U; uint32_t errorstate; /* CMD0: GO_IDLE_STATE */ errorstate = SDMMC_CmdGoIdleState(hsd->Instance); if(errorstate != HAL_SD_ERROR_NONE) { return errorstate; } /* CMD8: SEND_IF_COND: Command available only on V2.0 cards */ errorstate = SDMMC_CmdOperCond(hsd->Instance); if(errorstate != HAL_SD_ERROR_NONE) { hsd->SdCard.CardVersion = CARD_V1_X; /* CMD0: GO_IDLE_STATE */ errorstate = SDMMC_CmdGoIdleState(hsd->Instance); if(errorstate != HAL_SD_ERROR_NONE) { return errorstate; } } else { hsd->SdCard.CardVersion = CARD_V2_X; } if( hsd->SdCard.CardVersion == CARD_V2_X) { /* SEND CMD55 APP_CMD with RCA as 0 */ errorstate = SDMMC_CmdAppCommand(hsd->Instance, 0); if(errorstate != HAL_SD_ERROR_NONE) { return HAL_SD_ERROR_UNSUPPORTED_FEATURE; } } /* SD CARD */ /* Send ACMD41 SD_APP_OP_COND with Argument 0x80100000 */ while((count < SDMMC_MAX_VOLT_TRIAL) && (validvoltage == 0U)) { /* SEND CMD55 APP_CMD with RCA as 0 */ errorstate = SDMMC_CmdAppCommand(hsd->Instance, 0); if(errorstate != HAL_SD_ERROR_NONE) { return errorstate; } /* Send CMD41 */ errorstate = SDMMC_CmdAppOperCommand(hsd->Instance, SDMMC_VOLTAGE_WINDOW_SD | SDMMC_HIGH_CAPACITY | SD_SWITCH_1_8V_CAPACITY); if(errorstate != HAL_SD_ERROR_NONE) { return HAL_SD_ERROR_UNSUPPORTED_FEATURE; } /* Get command response */ response = SDIO_GetResponse(hsd->Instance, SDIO_RESP1); /* Get operating voltage */ validvoltage = (((response >> 31U) == 1U) ? 1U : 0U); count++; } if(count >= SDMMC_MAX_VOLT_TRIAL) { return HAL_SD_ERROR_INVALID_VOLTRANGE; } if((response & SDMMC_HIGH_CAPACITY) == SDMMC_HIGH_CAPACITY) /* (response &= SD_HIGH_CAPACITY) */ { hsd->SdCard.CardType = CARD_SDHC_SDXC; } else { hsd->SdCard.CardType = CARD_SDSC; } return HAL_SD_ERROR_NONE; } /** * @brief Turns the SDIO output signals off. * @param hsd: Pointer to SD handle * @retval None */ static void SD_PowerOFF(SD_HandleTypeDef *hsd) { /* Set Power State to OFF */ (void)SDIO_PowerState_OFF(hsd->Instance); } /** * @brief Send Status info command. * @param hsd: pointer to SD handle * @param pSDstatus: Pointer to the buffer that will contain the SD card status * SD Status register) * @retval error state */ static uint32_t SD_SendSDStatus(SD_HandleTypeDef *hsd, uint32_t *pSDstatus) { SDIO_DataInitTypeDef config; uint32_t errorstate; uint32_t tickstart = HAL_GetTick(); uint32_t count; uint32_t *pData = pSDstatus; /* Check SD response */ if((SDIO_GetResponse(hsd->Instance, SDIO_RESP1) & SDMMC_CARD_LOCKED) == SDMMC_CARD_LOCKED) { return HAL_SD_ERROR_LOCK_UNLOCK_FAILED; } /* Set block size for card if it is not equal to current block size for card */ errorstate = SDMMC_CmdBlockLength(hsd->Instance, 64U); if(errorstate != HAL_SD_ERROR_NONE) { hsd->ErrorCode |= HAL_SD_ERROR_NONE; return errorstate; } /* Send CMD55 */ errorstate = SDMMC_CmdAppCommand(hsd->Instance, (uint32_t)(hsd->SdCard.RelCardAdd << 16U)); if(errorstate != HAL_SD_ERROR_NONE) { hsd->ErrorCode |= HAL_SD_ERROR_NONE; return errorstate; } /* Configure the SD DPSM (Data Path State Machine) */ config.DataTimeOut = SDMMC_DATATIMEOUT; config.DataLength = 64U; config.DataBlockSize = SDIO_DATABLOCK_SIZE_64B; config.TransferDir = SDIO_TRANSFER_DIR_TO_SDIO; config.TransferMode = SDIO_TRANSFER_MODE_BLOCK; config.DPSM = SDIO_DPSM_ENABLE; (void)SDIO_ConfigData(hsd->Instance, &config); /* Send ACMD13 (SD_APP_STAUS) with argument as card's RCA */ errorstate = SDMMC_CmdStatusRegister(hsd->Instance); if(errorstate != HAL_SD_ERROR_NONE) { hsd->ErrorCode |= HAL_SD_ERROR_NONE; return errorstate; } /* Get status data */ while(!__HAL_SD_GET_FLAG(hsd, SDIO_FLAG_RXOVERR | SDIO_FLAG_DCRCFAIL | SDIO_FLAG_DTIMEOUT | SDIO_FLAG_DBCKEND)) { if(__HAL_SD_GET_FLAG(hsd, SDIO_FLAG_RXFIFOHF)) { for(count = 0U; count < 8U; count++) { *pData = SDIO_ReadFIFO(hsd->Instance); pData++; } } if((HAL_GetTick() - tickstart) >= SDMMC_DATATIMEOUT) { return HAL_SD_ERROR_TIMEOUT; } } if(__HAL_SD_GET_FLAG(hsd, SDIO_FLAG_DTIMEOUT)) { return HAL_SD_ERROR_DATA_TIMEOUT; } else if(__HAL_SD_GET_FLAG(hsd, SDIO_FLAG_DCRCFAIL)) { return HAL_SD_ERROR_DATA_CRC_FAIL; } else if(__HAL_SD_GET_FLAG(hsd, SDIO_FLAG_RXOVERR)) { return HAL_SD_ERROR_RX_OVERRUN; } else { /* Nothing to do */ } while ((__HAL_SD_GET_FLAG(hsd, SDIO_FLAG_RXDAVL))) { *pData = SDIO_ReadFIFO(hsd->Instance); pData++; if((HAL_GetTick() - tickstart) >= SDMMC_DATATIMEOUT) { return HAL_SD_ERROR_TIMEOUT; } } /* Clear all the static status flags*/ __HAL_SD_CLEAR_FLAG(hsd, SDIO_STATIC_DATA_FLAGS); return HAL_SD_ERROR_NONE; } /** * @brief Returns the current card's status. * @param hsd: Pointer to SD handle * @param pCardStatus: pointer to the buffer that will contain the SD card * status (Card Status register) * @retval error state */ static uint32_t SD_SendStatus(SD_HandleTypeDef *hsd, uint32_t *pCardStatus) { uint32_t errorstate; if(pCardStatus == NULL) { return HAL_SD_ERROR_PARAM; } /* Send Status command */ errorstate = SDMMC_CmdSendStatus(hsd->Instance, (uint32_t)(hsd->SdCard.RelCardAdd << 16U)); if(errorstate != HAL_SD_ERROR_NONE) { return errorstate; } /* Get SD card status */ *pCardStatus = SDIO_GetResponse(hsd->Instance, SDIO_RESP1); return HAL_SD_ERROR_NONE; } /** * @brief Enables the SDIO wide bus mode. * @param hsd: pointer to SD handle * @retval error state */ static uint32_t SD_WideBus_Enable(SD_HandleTypeDef *hsd) { uint32_t scr[2U] = {0U, 0U}; uint32_t errorstate; if((SDIO_GetResponse(hsd->Instance, SDIO_RESP1) & SDMMC_CARD_LOCKED) == SDMMC_CARD_LOCKED) { return HAL_SD_ERROR_LOCK_UNLOCK_FAILED; } /* Get SCR Register */ errorstate = SD_FindSCR(hsd, scr); if(errorstate != HAL_SD_ERROR_NONE) { return errorstate; } /* If requested card supports wide bus operation */ if((scr[1U] & SDMMC_WIDE_BUS_SUPPORT) != SDMMC_ALLZERO) { /* Send CMD55 APP_CMD with argument as card's RCA.*/ errorstate = SDMMC_CmdAppCommand(hsd->Instance, (uint32_t)(hsd->SdCard.RelCardAdd << 16U)); if(errorstate != HAL_SD_ERROR_NONE) { return errorstate; } /* Send ACMD6 APP_CMD with argument as 2 for wide bus mode */ errorstate = SDMMC_CmdBusWidth(hsd->Instance, 2U); if(errorstate != HAL_SD_ERROR_NONE) { return errorstate; } return HAL_SD_ERROR_NONE; } else { return HAL_SD_ERROR_REQUEST_NOT_APPLICABLE; } } /** * @brief Disables the SDIO wide bus mode. * @param hsd: Pointer to SD handle * @retval error state */ static uint32_t SD_WideBus_Disable(SD_HandleTypeDef *hsd) { uint32_t scr[2U] = {0U, 0U}; uint32_t errorstate; if((SDIO_GetResponse(hsd->Instance, SDIO_RESP1) & SDMMC_CARD_LOCKED) == SDMMC_CARD_LOCKED) { return HAL_SD_ERROR_LOCK_UNLOCK_FAILED; } /* Get SCR Register */ errorstate = SD_FindSCR(hsd, scr); if(errorstate != HAL_SD_ERROR_NONE) { return errorstate; } /* If requested card supports 1 bit mode operation */ if((scr[1U] & SDMMC_SINGLE_BUS_SUPPORT) != SDMMC_ALLZERO) { /* Send CMD55 APP_CMD with argument as card's RCA */ errorstate = SDMMC_CmdAppCommand(hsd->Instance, (uint32_t)(hsd->SdCard.RelCardAdd << 16U)); if(errorstate != HAL_SD_ERROR_NONE) { return errorstate; } /* Send ACMD6 APP_CMD with argument as 0 for single bus mode */ errorstate = SDMMC_CmdBusWidth(hsd->Instance, 0U); if(errorstate != HAL_SD_ERROR_NONE) { return errorstate; } return HAL_SD_ERROR_NONE; } else { return HAL_SD_ERROR_REQUEST_NOT_APPLICABLE; } } /** * @brief Finds the SD card SCR register value. * @param hsd: Pointer to SD handle * @param pSCR: pointer to the buffer that will contain the SCR value * @retval error state */ static uint32_t SD_FindSCR(SD_HandleTypeDef *hsd, uint32_t *pSCR) { SDIO_DataInitTypeDef config; uint32_t errorstate; uint32_t tickstart = HAL_GetTick(); uint32_t index = 0U; uint32_t tempscr[2U] = {0U, 0U}; uint32_t *scr = pSCR; /* Set Block Size To 8 Bytes */ errorstate = SDMMC_CmdBlockLength(hsd->Instance, 8U); if(errorstate != HAL_SD_ERROR_NONE) { return errorstate; } /* Send CMD55 APP_CMD with argument as card's RCA */ errorstate = SDMMC_CmdAppCommand(hsd->Instance, (uint32_t)((hsd->SdCard.RelCardAdd) << 16U)); if(errorstate != HAL_SD_ERROR_NONE) { return errorstate; } config.DataTimeOut = SDMMC_DATATIMEOUT; config.DataLength = 8U; config.DataBlockSize = SDIO_DATABLOCK_SIZE_8B; config.TransferDir = SDIO_TRANSFER_DIR_TO_SDIO; config.TransferMode = SDIO_TRANSFER_MODE_BLOCK; config.DPSM = SDIO_DPSM_ENABLE; (void)SDIO_ConfigData(hsd->Instance, &config); /* Send ACMD51 SD_APP_SEND_SCR with argument as 0 */ errorstate = SDMMC_CmdSendSCR(hsd->Instance); if(errorstate != HAL_SD_ERROR_NONE) { return errorstate; } while(!__HAL_SD_GET_FLAG(hsd, SDIO_FLAG_RXOVERR | SDIO_FLAG_DCRCFAIL | SDIO_FLAG_DTIMEOUT | SDIO_FLAG_DBCKEND)) { if(__HAL_SD_GET_FLAG(hsd, SDIO_FLAG_RXDAVL)) { *(tempscr + index) = SDIO_ReadFIFO(hsd->Instance); index++; } if((HAL_GetTick() - tickstart) >= SDMMC_DATATIMEOUT) { return HAL_SD_ERROR_TIMEOUT; } } if(__HAL_SD_GET_FLAG(hsd, SDIO_FLAG_DTIMEOUT)) { __HAL_SD_CLEAR_FLAG(hsd, SDIO_FLAG_DTIMEOUT); return HAL_SD_ERROR_DATA_TIMEOUT; } else if(__HAL_SD_GET_FLAG(hsd, SDIO_FLAG_DCRCFAIL)) { __HAL_SD_CLEAR_FLAG(hsd, SDIO_FLAG_DCRCFAIL); return HAL_SD_ERROR_DATA_CRC_FAIL; } else if(__HAL_SD_GET_FLAG(hsd, SDIO_FLAG_RXOVERR)) { __HAL_SD_CLEAR_FLAG(hsd, SDIO_FLAG_RXOVERR); return HAL_SD_ERROR_RX_OVERRUN; } else { /* No error flag set */ /* Clear all the static flags */ __HAL_SD_CLEAR_FLAG(hsd, SDIO_STATIC_DATA_FLAGS); *scr = (((tempscr[1] & SDMMC_0TO7BITS) << 24) | ((tempscr[1] & SDMMC_8TO15BITS) << 8) |\ ((tempscr[1] & SDMMC_16TO23BITS) >> 8) | ((tempscr[1] & SDMMC_24TO31BITS) >> 24)); scr++; *scr = (((tempscr[0] & SDMMC_0TO7BITS) << 24) | ((tempscr[0] & SDMMC_8TO15BITS) << 8) |\ ((tempscr[0] & SDMMC_16TO23BITS) >> 8) | ((tempscr[0] & SDMMC_24TO31BITS) >> 24)); } return HAL_SD_ERROR_NONE; } /** * @brief Wrap up reading in non-blocking mode. * @param hsd: pointer to a SD_HandleTypeDef structure that contains * the configuration information. * @retval None */ static void SD_Read_IT(SD_HandleTypeDef *hsd) { uint32_t count, data, dataremaining; uint8_t* tmp; tmp = hsd->pRxBuffPtr; dataremaining = hsd->RxXferSize; if (dataremaining > 0U) { /* Read data from SDIO Rx FIFO */ for(count = 0U; count < 8U; count++) { data = SDIO_ReadFIFO(hsd->Instance); *tmp = (uint8_t)(data & 0xFFU); tmp++; dataremaining--; *tmp = (uint8_t)((data >> 8U) & 0xFFU); tmp++; dataremaining--; *tmp = (uint8_t)((data >> 16U) & 0xFFU); tmp++; dataremaining--; *tmp = (uint8_t)((data >> 24U) & 0xFFU); tmp++; dataremaining--; } hsd->pRxBuffPtr = tmp; hsd->RxXferSize = dataremaining; } } /** * @brief Wrap up writing in non-blocking mode. * @param hsd: pointer to a SD_HandleTypeDef structure that contains * the configuration information. * @retval None */ static void SD_Write_IT(SD_HandleTypeDef *hsd) { uint32_t count, data, dataremaining; uint8_t* tmp; tmp = hsd->pTxBuffPtr; dataremaining = hsd->TxXferSize; if (dataremaining > 0U) { /* Write data to SDIO Tx FIFO */ for(count = 0U; count < 8U; count++) { data = (uint32_t)(*tmp); tmp++; dataremaining--; data |= ((uint32_t)(*tmp) << 8U); tmp++; dataremaining--; data |= ((uint32_t)(*tmp) << 16U); tmp++; dataremaining--; data |= ((uint32_t)(*tmp) << 24U); tmp++; dataremaining--; (void)SDIO_WriteFIFO(hsd->Instance, &data); } hsd->pTxBuffPtr = tmp; hsd->TxXferSize = dataremaining; } } /** * @} */ #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F401xC || STM32F401xE || STM32F411xE || STM32F446xx || STM32F469xx || STM32F479xx || STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx || STM32F413xx || STM32F423xx */ #endif /* HAL_SD_MODULE_ENABLED */ /** * @} */ /** * @} */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ ================================================ FILE: sys/arch/stm32/hal/stm32f4xx_hal_sd.h ================================================ /** ****************************************************************************** * @file stm32f4xx_hal_sd.h * @author MCD Application Team * @version V1.7.1 * @date 14-April-2017 * @brief Header file of SD HAL module. ****************************************************************************** * @attention * *

© COPYRIGHT(c) 2017 STMicroelectronics

* * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. Neither the name of STMicroelectronics nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __STM32F4xx_HAL_SD_H #define __STM32F4xx_HAL_SD_H #ifdef __cplusplus extern "C" { #endif #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) || \ defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) || \ defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F411xE) || defined(STM32F446xx) || \ defined(STM32F469xx) || defined(STM32F479xx) || defined(STM32F412Zx) || defined(STM32F412Vx) || \ defined(STM32F412Rx) || defined(STM32F412Cx) || defined(STM32F413xx) || defined(STM32F423xx) /* Includes ------------------------------------------------------------------*/ #include "stm32f4xx_ll_sdmmc.h" /** @addtogroup STM32F4xx_HAL_Driver * @{ */ /** @defgroup SD SD * @brief SD HAL module driver * @{ */ /* Exported types ------------------------------------------------------------*/ /** @defgroup SD_Exported_Types SD Exported Types * @{ */ /** @defgroup SD_Exported_Types_Group1 SD State enumeration structure * @{ */ typedef enum { HAL_SD_STATE_RESET = 0x00000000U, /*!< SD not yet initialized or disabled */ HAL_SD_STATE_READY = 0x00000001U, /*!< SD initialized and ready for use */ HAL_SD_STATE_TIMEOUT = 0x00000002U, /*!< SD Timeout state */ HAL_SD_STATE_BUSY = 0x00000003U, /*!< SD process ongoing */ HAL_SD_STATE_PROGRAMMING = 0x00000004U, /*!< SD Programming State */ HAL_SD_STATE_RECEIVING = 0x00000005U, /*!< SD Receiving State */ HAL_SD_STATE_TRANSFER = 0x00000006U, /*!< SD Transfert State */ HAL_SD_STATE_ERROR = 0x0000000FU /*!< SD is in error state */ }HAL_SD_StateTypeDef; /** * @} */ /** @defgroup SD_Exported_Types_Group2 SD Card State enumeration structure * @{ */ typedef uint32_t HAL_SD_CardStateTypeDef; #define HAL_SD_CARD_READY 0x00000001U /*!< Card state is ready */ #define HAL_SD_CARD_IDENTIFICATION 0x00000002U /*!< Card is in identification state */ #define HAL_SD_CARD_STANDBY 0x00000003U /*!< Card is in standby state */ #define HAL_SD_CARD_TRANSFER 0x00000004U /*!< Card is in transfer state */ #define HAL_SD_CARD_SENDING 0x00000005U /*!< Card is sending an operation */ #define HAL_SD_CARD_RECEIVING 0x00000006U /*!< Card is receiving operation information */ #define HAL_SD_CARD_PROGRAMMING 0x00000007U /*!< Card is in programming state */ #define HAL_SD_CARD_DISCONNECTED 0x00000008U /*!< Card is disconnected */ #define HAL_SD_CARD_ERROR 0x000000FFU /*!< Card response Error */ /** * @} */ /** @defgroup SD_Exported_Types_Group3 SD Handle Structure definition * @{ */ #define SD_InitTypeDef SDIO_InitTypeDef #define SD_TypeDef SDIO_TypeDef /** * @brief SD Card Information Structure definition */ typedef struct { uint32_t CardType; /*!< Specifies the card Type */ uint32_t CardVersion; /*!< Specifies the card version */ uint32_t Class; /*!< Specifies the class of the card class */ uint32_t RelCardAdd; /*!< Specifies the Relative Card Address */ uint32_t BlockNbr; /*!< Specifies the Card Capacity in blocks */ uint32_t BlockSize; /*!< Specifies one block size in bytes */ uint32_t LogBlockNbr; /*!< Specifies the Card logical Capacity in blocks */ uint32_t LogBlockSize; /*!< Specifies logical block size in bytes */ }HAL_SD_CardInfoTypeDef; /** * @brief SD handle Structure definition */ #if defined (USE_HAL_SD_REGISTER_CALLBACKS) && (USE_HAL_SD_REGISTER_CALLBACKS == 1U) typedef struct __SD_HandleTypeDef #else typedef struct #endif /* USE_HAL_SD_REGISTER_CALLBACKS */ { SD_TypeDef *Instance; /*!< SD registers base address */ SD_InitTypeDef Init; /*!< SD required parameters */ HAL_LockTypeDef Lock; /*!< SD locking object */ uint8_t *pTxBuffPtr; /*!< Pointer to SD Tx transfer Buffer */ uint32_t TxXferSize; /*!< SD Tx Transfer size */ uint8_t *pRxBuffPtr; /*!< Pointer to SD Rx transfer Buffer */ uint32_t RxXferSize; /*!< SD Rx Transfer size */ __IO uint32_t Context; /*!< SD transfer context */ __IO HAL_SD_StateTypeDef State; /*!< SD card State */ __IO uint32_t ErrorCode; /*!< SD Card Error codes */ #if 0 // XXX DMA DMA_HandleTypeDef *hdmarx; /*!< SD Rx DMA handle parameters */ DMA_HandleTypeDef *hdmatx; /*!< SD Tx DMA handle parameters */ #endif // XXX DMA HAL_SD_CardInfoTypeDef SdCard; /*!< SD Card information */ uint32_t CSD[4]; /*!< SD card specific data table */ uint32_t CID[4]; /*!< SD card identification number table */ #if defined (USE_HAL_SD_REGISTER_CALLBACKS) && (USE_HAL_SD_REGISTER_CALLBACKS == 1U) void (* TxCpltCallback) (struct __SD_HandleTypeDef *hsd); void (* RxCpltCallback) (struct __SD_HandleTypeDef *hsd); void (* ErrorCallback) (struct __SD_HandleTypeDef *hsd); void (* AbortCpltCallback) (struct __SD_HandleTypeDef *hsd); void (* MspInitCallback) (struct __SD_HandleTypeDef *hsd); void (* MspDeInitCallback) (struct __SD_HandleTypeDef *hsd); #endif /* USE_HAL_SD_REGISTER_CALLBACKS */ }SD_HandleTypeDef; /** * @} */ /** @defgroup SD_Exported_Types_Group4 Card Specific Data: CSD Register * @{ */ typedef struct { __IO uint8_t CSDStruct; /*!< CSD structure */ __IO uint8_t SysSpecVersion; /*!< System specification version */ __IO uint8_t Reserved1; /*!< Reserved */ __IO uint8_t TAAC; /*!< Data read access time 1 */ __IO uint8_t NSAC; /*!< Data read access time 2 in CLK cycles */ __IO uint8_t MaxBusClkFrec; /*!< Max. bus clock frequency */ __IO uint16_t CardComdClasses; /*!< Card command classes */ __IO uint8_t RdBlockLen; /*!< Max. read data block length */ __IO uint8_t PartBlockRead; /*!< Partial blocks for read allowed */ __IO uint8_t WrBlockMisalign; /*!< Write block misalignment */ __IO uint8_t RdBlockMisalign; /*!< Read block misalignment */ __IO uint8_t DSRImpl; /*!< DSR implemented */ __IO uint8_t Reserved2; /*!< Reserved */ __IO uint32_t DeviceSize; /*!< Device Size */ __IO uint8_t MaxRdCurrentVDDMin; /*!< Max. read current @ VDD min */ __IO uint8_t MaxRdCurrentVDDMax; /*!< Max. read current @ VDD max */ __IO uint8_t MaxWrCurrentVDDMin; /*!< Max. write current @ VDD min */ __IO uint8_t MaxWrCurrentVDDMax; /*!< Max. write current @ VDD max */ __IO uint8_t DeviceSizeMul; /*!< Device size multiplier */ __IO uint8_t EraseGrSize; /*!< Erase group size */ __IO uint8_t EraseGrMul; /*!< Erase group size multiplier */ __IO uint8_t WrProtectGrSize; /*!< Write protect group size */ __IO uint8_t WrProtectGrEnable; /*!< Write protect group enable */ __IO uint8_t ManDeflECC; /*!< Manufacturer default ECC */ __IO uint8_t WrSpeedFact; /*!< Write speed factor */ __IO uint8_t MaxWrBlockLen; /*!< Max. write data block length */ __IO uint8_t WriteBlockPaPartial; /*!< Partial blocks for write allowed */ __IO uint8_t Reserved3; /*!< Reserved */ __IO uint8_t ContentProtectAppli; /*!< Content protection application */ __IO uint8_t FileFormatGroup; /*!< File format group */ __IO uint8_t CopyFlag; /*!< Copy flag (OTP) */ __IO uint8_t PermWrProtect; /*!< Permanent write protection */ __IO uint8_t TempWrProtect; /*!< Temporary write protection */ __IO uint8_t FileFormat; /*!< File format */ __IO uint8_t ECC; /*!< ECC code */ __IO uint8_t CSD_CRC; /*!< CSD CRC */ __IO uint8_t Reserved4; /*!< Always 1 */ }HAL_SD_CardCSDTypeDef; /** * @} */ /** @defgroup SD_Exported_Types_Group5 Card Identification Data: CID Register * @{ */ typedef struct { __IO uint8_t ManufacturerID; /*!< Manufacturer ID */ __IO uint16_t OEM_AppliID; /*!< OEM/Application ID */ __IO uint32_t ProdName1; /*!< Product Name part1 */ __IO uint8_t ProdName2; /*!< Product Name part2 */ __IO uint8_t ProdRev; /*!< Product Revision */ __IO uint32_t ProdSN; /*!< Product Serial Number */ __IO uint8_t Reserved1; /*!< Reserved1 */ __IO uint16_t ManufactDate; /*!< Manufacturing Date */ __IO uint8_t CID_CRC; /*!< CID CRC */ __IO uint8_t Reserved2; /*!< Always 1 */ }HAL_SD_CardCIDTypeDef; /** * @} */ /** @defgroup SD_Exported_Types_Group6 SD Card Status returned by ACMD13 * @{ */ typedef struct { __IO uint8_t DataBusWidth; /*!< Shows the currently defined data bus width */ __IO uint8_t SecuredMode; /*!< Card is in secured mode of operation */ __IO uint16_t CardType; /*!< Carries information about card type */ __IO uint32_t ProtectedAreaSize; /*!< Carries information about the capacity of protected area */ __IO uint8_t SpeedClass; /*!< Carries information about the speed class of the card */ __IO uint8_t PerformanceMove; /*!< Carries information about the card's performance move */ __IO uint8_t AllocationUnitSize; /*!< Carries information about the card's allocation unit size */ __IO uint16_t EraseSize; /*!< Determines the number of AUs to be erased in one operation */ __IO uint8_t EraseTimeout; /*!< Determines the timeout for any number of AU erase */ __IO uint8_t EraseOffset; /*!< Carries information about the erase offset */ }HAL_SD_CardStatusTypeDef; /** * @} */ #if defined (USE_HAL_SD_REGISTER_CALLBACKS) && (USE_HAL_SD_REGISTER_CALLBACKS == 1U) /** @defgroup SD_Exported_Types_Group7 SD Callback ID enumeration definition * @{ */ typedef enum { HAL_SD_TX_CPLT_CB_ID = 0x00U, /*!< SD Tx Complete Callback ID */ HAL_SD_RX_CPLT_CB_ID = 0x01U, /*!< SD Rx Complete Callback ID */ HAL_SD_ERROR_CB_ID = 0x02U, /*!< SD Error Callback ID */ HAL_SD_ABORT_CB_ID = 0x03U, /*!< SD Abort Callback ID */ HAL_SD_MSP_INIT_CB_ID = 0x10U, /*!< SD MspInit Callback ID */ HAL_SD_MSP_DEINIT_CB_ID = 0x11U /*!< SD MspDeInit Callback ID */ }HAL_SD_CallbackIDTypeDef; /** * @} */ /** @defgroup SD_Exported_Types_Group8 SD Callback pointer definition * @{ */ typedef void (*pSD_CallbackTypeDef) (SD_HandleTypeDef *hsd); /** * @} */ #endif /* USE_HAL_SD_REGISTER_CALLBACKS */ /** * @} */ /* Exported constants --------------------------------------------------------*/ /** @defgroup SD_Exported_Constants Exported Constants * @{ */ #define BLOCKSIZE 512U /*!< Block size is 512 bytes */ /** @defgroup SD_Exported_Constansts_Group1 SD Error status enumeration Structure definition * @{ */ #define HAL_SD_ERROR_NONE SDMMC_ERROR_NONE /*!< No error */ #define HAL_SD_ERROR_CMD_CRC_FAIL SDMMC_ERROR_CMD_CRC_FAIL /*!< Command response received (but CRC check failed) */ #define HAL_SD_ERROR_DATA_CRC_FAIL SDMMC_ERROR_DATA_CRC_FAIL /*!< Data block sent/received (CRC check failed) */ #define HAL_SD_ERROR_CMD_RSP_TIMEOUT SDMMC_ERROR_CMD_RSP_TIMEOUT /*!< Command response timeout */ #define HAL_SD_ERROR_DATA_TIMEOUT SDMMC_ERROR_DATA_TIMEOUT /*!< Data timeout */ #define HAL_SD_ERROR_TX_UNDERRUN SDMMC_ERROR_TX_UNDERRUN /*!< Transmit FIFO underrun */ #define HAL_SD_ERROR_RX_OVERRUN SDMMC_ERROR_RX_OVERRUN /*!< Receive FIFO overrun */ #define HAL_SD_ERROR_ADDR_MISALIGNED SDMMC_ERROR_ADDR_MISALIGNED /*!< Misaligned address */ #define HAL_SD_ERROR_BLOCK_LEN_ERR SDMMC_ERROR_BLOCK_LEN_ERR /*!< Transferred block length is not allowed for the card or the number of transferred bytes does not match the block length */ #define HAL_SD_ERROR_ERASE_SEQ_ERR SDMMC_ERROR_ERASE_SEQ_ERR /*!< An error in the sequence of erase command occurs */ #define HAL_SD_ERROR_BAD_ERASE_PARAM SDMMC_ERROR_BAD_ERASE_PARAM /*!< An invalid selection for erase groups */ #define HAL_SD_ERROR_WRITE_PROT_VIOLATION SDMMC_ERROR_WRITE_PROT_VIOLATION /*!< Attempt to program a write protect block */ #define HAL_SD_ERROR_LOCK_UNLOCK_FAILED SDMMC_ERROR_LOCK_UNLOCK_FAILED /*!< Sequence or password error has been detected in unlock command or if there was an attempt to access a locked card */ #define HAL_SD_ERROR_COM_CRC_FAILED SDMMC_ERROR_COM_CRC_FAILED /*!< CRC check of the previous command failed */ #define HAL_SD_ERROR_ILLEGAL_CMD SDMMC_ERROR_ILLEGAL_CMD /*!< Command is not legal for the card state */ #define HAL_SD_ERROR_CARD_ECC_FAILED SDMMC_ERROR_CARD_ECC_FAILED /*!< Card internal ECC was applied but failed to correct the data */ #define HAL_SD_ERROR_CC_ERR SDMMC_ERROR_CC_ERR /*!< Internal card controller error */ #define HAL_SD_ERROR_GENERAL_UNKNOWN_ERR SDMMC_ERROR_GENERAL_UNKNOWN_ERR /*!< General or unknown error */ #define HAL_SD_ERROR_STREAM_READ_UNDERRUN SDMMC_ERROR_STREAM_READ_UNDERRUN /*!< The card could not sustain data reading in stream rmode */ #define HAL_SD_ERROR_STREAM_WRITE_OVERRUN SDMMC_ERROR_STREAM_WRITE_OVERRUN /*!< The card could not sustain data programming in stream mode */ #define HAL_SD_ERROR_CID_CSD_OVERWRITE SDMMC_ERROR_CID_CSD_OVERWRITE /*!< CID/CSD overwrite error */ #define HAL_SD_ERROR_WP_ERASE_SKIP SDMMC_ERROR_WP_ERASE_SKIP /*!< Only partial address space was erased */ #define HAL_SD_ERROR_CARD_ECC_DISABLED SDMMC_ERROR_CARD_ECC_DISABLED /*!< Command has been executed without using internal ECC */ #define HAL_SD_ERROR_ERASE_RESET SDMMC_ERROR_ERASE_RESET /*!< Erase sequence was cleared before executing because an out of erase sequence command was received */ #define HAL_SD_ERROR_AKE_SEQ_ERR SDMMC_ERROR_AKE_SEQ_ERR /*!< Error in sequence of authentication */ #define HAL_SD_ERROR_INVALID_VOLTRANGE SDMMC_ERROR_INVALID_VOLTRANGE /*!< Error in case of invalid voltage range */ #define HAL_SD_ERROR_ADDR_OUT_OF_RANGE SDMMC_ERROR_ADDR_OUT_OF_RANGE /*!< Error when addressed block is out of range */ #define HAL_SD_ERROR_REQUEST_NOT_APPLICABLE SDMMC_ERROR_REQUEST_NOT_APPLICABLE /*!< Error when command request is not applicable */ #define HAL_SD_ERROR_PARAM SDMMC_ERROR_INVALID_PARAMETER /*!< the used parameter is not valid */ #define HAL_SD_ERROR_UNSUPPORTED_FEATURE SDMMC_ERROR_UNSUPPORTED_FEATURE /*!< Error when feature is not insupported */ #define HAL_SD_ERROR_BUSY SDMMC_ERROR_BUSY /*!< Error when transfer process is busy */ #define HAL_SD_ERROR_DMA SDMMC_ERROR_DMA /*!< Error while DMA transfer */ #define HAL_SD_ERROR_TIMEOUT SDMMC_ERROR_TIMEOUT /*!< Timeout error */ #if defined (USE_HAL_SD_REGISTER_CALLBACKS) && (USE_HAL_SD_REGISTER_CALLBACKS == 1U) #define HAL_SD_ERROR_INVALID_CALLBACK SDMMC_ERROR_INVALID_PARAMETER /*!< Invalid callback error */ #endif /* USE_HAL_SD_REGISTER_CALLBACKS */ /** * @} */ /** @defgroup SD_Exported_Constansts_Group2 SD context enumeration * @{ */ #define SD_CONTEXT_NONE 0x00000000U /*!< None */ #define SD_CONTEXT_READ_SINGLE_BLOCK 0x00000001U /*!< Read single block operation */ #define SD_CONTEXT_READ_MULTIPLE_BLOCK 0x00000002U /*!< Read multiple blocks operation */ #define SD_CONTEXT_WRITE_SINGLE_BLOCK 0x00000010U /*!< Write single block operation */ #define SD_CONTEXT_WRITE_MULTIPLE_BLOCK 0x00000020U /*!< Write multiple blocks operation */ #define SD_CONTEXT_IT 0x00000008U /*!< Process in Interrupt mode */ #define SD_CONTEXT_DMA 0x00000080U /*!< Process in DMA mode */ /** * @} */ /** @defgroup SD_Exported_Constansts_Group3 SD Supported Memory Cards * @{ */ #define CARD_SDSC 0x00000000U /*!< SD Standard Capacity <2Go */ #define CARD_SDHC_SDXC 0x00000001U /*!< SD High Capacity <32Go, SD Extended Capacity <2To */ #define CARD_SECURED 0x00000003U /** * @} */ /** @defgroup SD_Exported_Constansts_Group4 SD Supported Version * @{ */ #define CARD_V1_X 0x00000000U #define CARD_V2_X 0x00000001U /** * @} */ /** * @} */ /* Exported macro ------------------------------------------------------------*/ /** @defgroup SD_Exported_macros SD Exported Macros * @brief macros to handle interrupts and specific clock configurations * @{ */ /** @brief Reset SD handle state. * @param __HANDLE__ : SD handle. * @retval None */ #if defined (USE_HAL_SD_REGISTER_CALLBACKS) && (USE_HAL_SD_REGISTER_CALLBACKS == 1U) #define __HAL_SD_RESET_HANDLE_STATE(__HANDLE__) do { \ (__HANDLE__)->State = HAL_SD_STATE_RESET; \ (__HANDLE__)->MspInitCallback = NULL; \ (__HANDLE__)->MspDeInitCallback = NULL; \ } while(0) #else #define __HAL_SD_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_SD_STATE_RESET) #endif /* USE_HAL_SD_REGISTER_CALLBACKS */ /** * @brief Enable the SD device. * @retval None */ #define __HAL_SD_ENABLE(__HANDLE__) __SDIO_ENABLE((__HANDLE__)->Instance) /** * @brief Disable the SD device. * @retval None */ #define __HAL_SD_DISABLE(__HANDLE__) __SDIO_DISABLE((__HANDLE__)->Instance) /** * @brief Enable the SDMMC DMA transfer. * @retval None */ #define __HAL_SD_DMA_ENABLE(__HANDLE__) __SDIO_DMA_ENABLE((__HANDLE__)->Instance) /** * @brief Disable the SDMMC DMA transfer. * @retval None */ #define __HAL_SD_DMA_DISABLE(__HANDLE__) __SDIO_DMA_DISABLE((__HANDLE__)->Instance) /** * @brief Enable the SD device interrupt. * @param __HANDLE__: SD Handle * @param __INTERRUPT__: specifies the SDMMC interrupt sources to be enabled. * This parameter can be one or a combination of the following values: * @arg SDIO_IT_CCRCFAIL: Command response received (CRC check failed) interrupt * @arg SDIO_IT_DCRCFAIL: Data block sent/received (CRC check failed) interrupt * @arg SDIO_IT_CTIMEOUT: Command response timeout interrupt * @arg SDIO_IT_DTIMEOUT: Data timeout interrupt * @arg SDIO_IT_TXUNDERR: Transmit FIFO underrun error interrupt * @arg SDIO_IT_RXOVERR: Received FIFO overrun error interrupt * @arg SDIO_IT_CMDREND: Command response received (CRC check passed) interrupt * @arg SDIO_IT_CMDSENT: Command sent (no response required) interrupt * @arg SDIO_IT_DATAEND: Data end (data counter, DATACOUNT, is zero) interrupt * @arg SDIO_IT_DBCKEND: Data block sent/received (CRC check passed) interrupt * @arg SDIO_IT_CMDACT: Command transfer in progress interrupt * @arg SDIO_IT_TXACT: Data transmit in progress interrupt * @arg SDIO_IT_RXACT: Data receive in progress interrupt * @arg SDIO_IT_TXFIFOHE: Transmit FIFO Half Empty interrupt * @arg SDIO_IT_RXFIFOHF: Receive FIFO Half Full interrupt * @arg SDIO_IT_TXFIFOF: Transmit FIFO full interrupt * @arg SDIO_IT_RXFIFOF: Receive FIFO full interrupt * @arg SDIO_IT_TXFIFOE: Transmit FIFO empty interrupt * @arg SDIO_IT_RXFIFOE: Receive FIFO empty interrupt * @arg SDIO_IT_TXDAVL: Data available in transmit FIFO interrupt * @arg SDIO_IT_RXDAVL: Data available in receive FIFO interrupt * @arg SDIO_IT_SDIOIT: SDIO interrupt received interrupt * @retval None */ #define __HAL_SD_ENABLE_IT(__HANDLE__, __INTERRUPT__) __SDIO_ENABLE_IT((__HANDLE__)->Instance, (__INTERRUPT__)) /** * @brief Disable the SD device interrupt. * @param __HANDLE__: SD Handle * @param __INTERRUPT__: specifies the SDMMC interrupt sources to be disabled. * This parameter can be one or a combination of the following values: * @arg SDIO_IT_CCRCFAIL: Command response received (CRC check failed) interrupt * @arg SDIO_IT_DCRCFAIL: Data block sent/received (CRC check failed) interrupt * @arg SDIO_IT_CTIMEOUT: Command response timeout interrupt * @arg SDIO_IT_DTIMEOUT: Data timeout interrupt * @arg SDIO_IT_TXUNDERR: Transmit FIFO underrun error interrupt * @arg SDIO_IT_RXOVERR: Received FIFO overrun error interrupt * @arg SDIO_IT_CMDREND: Command response received (CRC check passed) interrupt * @arg SDIO_IT_CMDSENT: Command sent (no response required) interrupt * @arg SDIO_IT_DATAEND: Data end (data counter, DATACOUNT, is zero) interrupt * @arg SDIO_IT_DBCKEND: Data block sent/received (CRC check passed) interrupt * @arg SDIO_IT_CMDACT: Command transfer in progress interrupt * @arg SDIO_IT_TXACT: Data transmit in progress interrupt * @arg SDIO_IT_RXACT: Data receive in progress interrupt * @arg SDIO_IT_TXFIFOHE: Transmit FIFO Half Empty interrupt * @arg SDIO_IT_RXFIFOHF: Receive FIFO Half Full interrupt * @arg SDIO_IT_TXFIFOF: Transmit FIFO full interrupt * @arg SDIO_IT_RXFIFOF: Receive FIFO full interrupt * @arg SDIO_IT_TXFIFOE: Transmit FIFO empty interrupt * @arg SDIO_IT_RXFIFOE: Receive FIFO empty interrupt * @arg SDIO_IT_TXDAVL: Data available in transmit FIFO interrupt * @arg SDIO_IT_RXDAVL: Data available in receive FIFO interrupt * @arg SDIO_IT_SDIOIT: SDIO interrupt received interrupt * @retval None */ #define __HAL_SD_DISABLE_IT(__HANDLE__, __INTERRUPT__) __SDIO_DISABLE_IT((__HANDLE__)->Instance, (__INTERRUPT__)) /** * @brief Check whether the specified SD flag is set or not. * @param __HANDLE__: SD Handle * @param __FLAG__: specifies the flag to check. * This parameter can be one of the following values: * @arg SDIO_FLAG_CCRCFAIL: Command response received (CRC check failed) * @arg SDIO_FLAG_DCRCFAIL: Data block sent/received (CRC check failed) * @arg SDIO_FLAG_CTIMEOUT: Command response timeout * @arg SDIO_FLAG_DTIMEOUT: Data timeout * @arg SDIO_FLAG_TXUNDERR: Transmit FIFO underrun error * @arg SDIO_FLAG_RXOVERR: Received FIFO overrun error * @arg SDIO_FLAG_CMDREND: Command response received (CRC check passed) * @arg SDIO_FLAG_CMDSENT: Command sent (no response required) * @arg SDIO_FLAG_DATAEND: Data end (data counter, DATACOUNT, is zero) * @arg SDIO_FLAG_DBCKEND: Data block sent/received (CRC check passed) * @arg SDIO_FLAG_CMDACT: Command transfer in progress * @arg SDIO_FLAG_TXACT: Data transmit in progress * @arg SDIO_FLAG_RXACT: Data receive in progress * @arg SDIO_FLAG_TXFIFOHE: Transmit FIFO Half Empty * @arg SDIO_FLAG_RXFIFOHF: Receive FIFO Half Full * @arg SDIO_FLAG_TXFIFOF: Transmit FIFO full * @arg SDIO_FLAG_RXFIFOF: Receive FIFO full * @arg SDIO_FLAG_TXFIFOE: Transmit FIFO empty * @arg SDIO_FLAG_RXFIFOE: Receive FIFO empty * @arg SDIO_FLAG_TXDAVL: Data available in transmit FIFO * @arg SDIO_FLAG_RXDAVL: Data available in receive FIFO * @arg SDIO_FLAG_SDIOIT: SDIO interrupt received * @retval The new state of SD FLAG (SET or RESET). */ #define __HAL_SD_GET_FLAG(__HANDLE__, __FLAG__) __SDIO_GET_FLAG((__HANDLE__)->Instance, (__FLAG__)) /** * @brief Clear the SD's pending flags. * @param __HANDLE__: SD Handle * @param __FLAG__: specifies the flag to clear. * This parameter can be one or a combination of the following values: * @arg SDIO_FLAG_CCRCFAIL: Command response received (CRC check failed) * @arg SDIO_FLAG_DCRCFAIL: Data block sent/received (CRC check failed) * @arg SDIO_FLAG_CTIMEOUT: Command response timeout * @arg SDIO_FLAG_DTIMEOUT: Data timeout * @arg SDIO_FLAG_TXUNDERR: Transmit FIFO underrun error * @arg SDIO_FLAG_RXOVERR: Received FIFO overrun error * @arg SDIO_FLAG_CMDREND: Command response received (CRC check passed) * @arg SDIO_FLAG_CMDSENT: Command sent (no response required) * @arg SDIO_FLAG_DATAEND: Data end (data counter, DATACOUNT, is zero) * @arg SDIO_FLAG_DBCKEND: Data block sent/received (CRC check passed) * @arg SDIO_FLAG_SDIOIT: SDIO interrupt received * @retval None */ #define __HAL_SD_CLEAR_FLAG(__HANDLE__, __FLAG__) __SDIO_CLEAR_FLAG((__HANDLE__)->Instance, (__FLAG__)) /** * @brief Check whether the specified SD interrupt has occurred or not. * @param __HANDLE__: SD Handle * @param __INTERRUPT__: specifies the SDMMC interrupt source to check. * This parameter can be one of the following values: * @arg SDIO_IT_CCRCFAIL: Command response received (CRC check failed) interrupt * @arg SDIO_IT_DCRCFAIL: Data block sent/received (CRC check failed) interrupt * @arg SDIO_IT_CTIMEOUT: Command response timeout interrupt * @arg SDIO_IT_DTIMEOUT: Data timeout interrupt * @arg SDIO_IT_TXUNDERR: Transmit FIFO underrun error interrupt * @arg SDIO_IT_RXOVERR: Received FIFO overrun error interrupt * @arg SDIO_IT_CMDREND: Command response received (CRC check passed) interrupt * @arg SDIO_IT_CMDSENT: Command sent (no response required) interrupt * @arg SDIO_IT_DATAEND: Data end (data counter, DATACOUNT, is zero) interrupt * @arg SDIO_IT_DBCKEND: Data block sent/received (CRC check passed) interrupt * @arg SDIO_IT_CMDACT: Command transfer in progress interrupt * @arg SDIO_IT_TXACT: Data transmit in progress interrupt * @arg SDIO_IT_RXACT: Data receive in progress interrupt * @arg SDIO_IT_TXFIFOHE: Transmit FIFO Half Empty interrupt * @arg SDIO_IT_RXFIFOHF: Receive FIFO Half Full interrupt * @arg SDIO_IT_TXFIFOF: Transmit FIFO full interrupt * @arg SDIO_IT_RXFIFOF: Receive FIFO full interrupt * @arg SDIO_IT_TXFIFOE: Transmit FIFO empty interrupt * @arg SDIO_IT_RXFIFOE: Receive FIFO empty interrupt * @arg SDIO_IT_TXDAVL: Data available in transmit FIFO interrupt * @arg SDIO_IT_RXDAVL: Data available in receive FIFO interrupt * @arg SDIO_IT_SDIOIT: SDIO interrupt received interrupt * @retval The new state of SD IT (SET or RESET). */ #define __HAL_SD_GET_IT(__HANDLE__, __INTERRUPT__) __SDIO_GET_IT((__HANDLE__)->Instance, (__INTERRUPT__)) /** * @brief Clear the SD's interrupt pending bits. * @param __HANDLE__: SD Handle * @param __INTERRUPT__: specifies the interrupt pending bit to clear. * This parameter can be one or a combination of the following values: * @arg SDIO_IT_CCRCFAIL: Command response received (CRC check failed) interrupt * @arg SDIO_IT_DCRCFAIL: Data block sent/received (CRC check failed) interrupt * @arg SDIO_IT_CTIMEOUT: Command response timeout interrupt * @arg SDIO_IT_DTIMEOUT: Data timeout interrupt * @arg SDIO_IT_TXUNDERR: Transmit FIFO underrun error interrupt * @arg SDIO_IT_RXOVERR: Received FIFO overrun error interrupt * @arg SDIO_IT_CMDREND: Command response received (CRC check passed) interrupt * @arg SDIO_IT_CMDSENT: Command sent (no response required) interrupt * @arg SDIO_IT_DATAEND: Data end (data counter, DATACOUNT, is zero) interrupt * @arg SDIO_IT_SDIOIT: SDIO interrupt received interrupt * @retval None */ #define __HAL_SD_CLEAR_IT(__HANDLE__, __INTERRUPT__) __SDIO_CLEAR_IT((__HANDLE__)->Instance, (__INTERRUPT__)) /** * @} */ /* Exported functions --------------------------------------------------------*/ /** @defgroup SD_Exported_Functions SD Exported Functions * @{ */ /** @defgroup SD_Exported_Functions_Group1 Initialization and de-initialization functions * @{ */ HAL_StatusTypeDef HAL_SD_Init(SD_HandleTypeDef *hsd); HAL_StatusTypeDef HAL_SD_InitCard(SD_HandleTypeDef *hsd); HAL_StatusTypeDef HAL_SD_DeInit (SD_HandleTypeDef *hsd); void HAL_SD_MspInit(SD_HandleTypeDef *hsd); void HAL_SD_MspDeInit(SD_HandleTypeDef *hsd); /** * @} */ /** @defgroup SD_Exported_Functions_Group2 Input and Output operation functions * @{ */ /* Blocking mode: Polling */ HAL_StatusTypeDef HAL_SD_ReadBlocks(SD_HandleTypeDef *hsd, uint8_t *pData, uint32_t BlockAdd, uint32_t NumberOfBlocks, uint32_t Timeout); HAL_StatusTypeDef HAL_SD_WriteBlocks(SD_HandleTypeDef *hsd, uint8_t *pData, uint32_t BlockAdd, uint32_t NumberOfBlocks, uint32_t Timeout); HAL_StatusTypeDef HAL_SD_Erase(SD_HandleTypeDef *hsd, uint32_t BlockStartAdd, uint32_t BlockEndAdd); /* Non-Blocking mode: IT */ HAL_StatusTypeDef HAL_SD_ReadBlocks_IT(SD_HandleTypeDef *hsd, uint8_t *pData, uint32_t BlockAdd, uint32_t NumberOfBlocks); HAL_StatusTypeDef HAL_SD_WriteBlocks_IT(SD_HandleTypeDef *hsd, uint8_t *pData, uint32_t BlockAdd, uint32_t NumberOfBlocks); #if 0 // XXX DMA /* Non-Blocking mode: DMA */ HAL_StatusTypeDef HAL_SD_ReadBlocks_DMA(SD_HandleTypeDef *hsd, uint8_t *pData, uint32_t BlockAdd, uint32_t NumberOfBlocks); HAL_StatusTypeDef HAL_SD_WriteBlocks_DMA(SD_HandleTypeDef *hsd, uint8_t *pData, uint32_t BlockAdd, uint32_t NumberOfBlocks); #endif // XXX DMA void HAL_SD_IRQHandler(SD_HandleTypeDef *hsd); /* Callback in non blocking modes (DMA) */ void HAL_SD_TxCpltCallback(SD_HandleTypeDef *hsd); void HAL_SD_RxCpltCallback(SD_HandleTypeDef *hsd); void HAL_SD_ErrorCallback(SD_HandleTypeDef *hsd); void HAL_SD_AbortCallback(SD_HandleTypeDef *hsd); #if defined (USE_HAL_SD_REGISTER_CALLBACKS) && (USE_HAL_SD_REGISTER_CALLBACKS == 1U) /* SD callback registering/unregistering */ HAL_StatusTypeDef HAL_SD_RegisterCallback (SD_HandleTypeDef *hsd, HAL_SD_CallbackIDTypeDef CallbackId, pSD_CallbackTypeDef pCallback); HAL_StatusTypeDef HAL_SD_UnRegisterCallback(SD_HandleTypeDef *hsd, HAL_SD_CallbackIDTypeDef CallbackId); #endif /* USE_HAL_SD_REGISTER_CALLBACKS */ /** * @} */ /** @defgroup SD_Exported_Functions_Group3 Peripheral Control functions * @{ */ HAL_StatusTypeDef HAL_SD_ConfigWideBusOperation(SD_HandleTypeDef *hsd, uint32_t WideMode); /** * @} */ /** @defgroup SD_Exported_Functions_Group4 SD card related functions * @{ */ HAL_StatusTypeDef HAL_SD_SendSDStatus(SD_HandleTypeDef *hsd, uint32_t *pSDstatus); HAL_SD_CardStateTypeDef HAL_SD_GetCardState(SD_HandleTypeDef *hsd); HAL_StatusTypeDef HAL_SD_GetCardCID(SD_HandleTypeDef *hsd, HAL_SD_CardCIDTypeDef *pCID); HAL_StatusTypeDef HAL_SD_GetCardCSD(SD_HandleTypeDef *hsd, HAL_SD_CardCSDTypeDef *pCSD); HAL_StatusTypeDef HAL_SD_GetCardStatus(SD_HandleTypeDef *hsd, HAL_SD_CardStatusTypeDef *pStatus); HAL_StatusTypeDef HAL_SD_GetCardInfo(SD_HandleTypeDef *hsd, HAL_SD_CardInfoTypeDef *pCardInfo); /** * @} */ /** @defgroup SD_Exported_Functions_Group5 Peripheral State and Errors functions * @{ */ HAL_SD_StateTypeDef HAL_SD_GetState(SD_HandleTypeDef *hsd); uint32_t HAL_SD_GetError(SD_HandleTypeDef *hsd); /** * @} */ /** @defgroup SD_Exported_Functions_Group6 Perioheral Abort management * @{ */ HAL_StatusTypeDef HAL_SD_Abort(SD_HandleTypeDef *hsd); HAL_StatusTypeDef HAL_SD_Abort_IT(SD_HandleTypeDef *hsd); /** * @} */ /* Private types -------------------------------------------------------------*/ /** @defgroup SD_Private_Types SD Private Types * @{ */ /** * @} */ /* Private defines -----------------------------------------------------------*/ /** @defgroup SD_Private_Defines SD Private Defines * @{ */ /** * @} */ /* Private variables ---------------------------------------------------------*/ /** @defgroup SD_Private_Variables SD Private Variables * @{ */ /** * @} */ /* Private constants ---------------------------------------------------------*/ /** @defgroup SD_Private_Constants SD Private Constants * @{ */ /** * @} */ /* Private macros ------------------------------------------------------------*/ /** @defgroup SD_Private_Macros SD Private Macros * @{ */ /** * @} */ /* Private functions prototypes ----------------------------------------------*/ /** @defgroup SD_Private_Functions_Prototypes SD Private Functions Prototypes * @{ */ /** * @} */ /* Private functions ---------------------------------------------------------*/ /** @defgroup SD_Private_Functions SD Private Functions * @{ */ /** * @} */ /** * @} */ /** * @} */ /** * @} */ #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F401xC || STM32F401xE || STM32F411xE || STM32F446xx || STM32F469xx || STM32F479xx || STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx || STM32F413xx || STM32F423xx */ #ifdef __cplusplus } #endif #endif /* __STM32F4xx_HAL_SD_H */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ ================================================ FILE: sys/arch/stm32/hal/stm32f4xx_hal_spi.c ================================================ /** ****************************************************************************** * @file stm32f4xx_hal_spi.c * @author MCD Application Team * @version V1.7.1 * @date 14-April-2017 * @brief SPI HAL module driver. * This file provides firmware functions to manage the following * functionalities of the Serial Peripheral Interface (SPI) peripheral: * + Initialization and de-initialization functions * + IO operation functions * + Peripheral Control functions * + Peripheral State functions * @verbatim ============================================================================== ##### How to use this driver ##### ============================================================================== [..] The SPI HAL driver can be used as follows: (#) Declare a SPI_HandleTypeDef handle structure, for example: SPI_HandleTypeDef hspi; (#)Initialize the SPI low level resources by implementing the HAL_SPI_MspInit() API: (##) Enable the SPIx interface clock (##) SPI pins configuration (+++) Enable the clock for the SPI GPIOs (+++) Configure these SPI pins as alternate function push-pull (##) NVIC configuration if you need to use interrupt process (+++) Configure the SPIx interrupt priority (+++) Enable the NVIC SPI IRQ handle (##) DMA Configuration if you need to use DMA process (+++) Declare a DMA_HandleTypeDef handle structure for the transmit or receive stream (+++) Enable the DMAx clock (+++) Configure the DMA handle parameters (+++) Configure the DMA Tx or Rx stream (+++) Associate the initialized hdma_tx handle to the hspi DMA Tx or Rx handle (+++) Configure the priority and enable the NVIC for the transfer complete interrupt on the DMA Tx or Rx stream (#) Program the Mode, BidirectionalMode , Data size, Baudrate Prescaler, NSS management, Clock polarity and phase, FirstBit and CRC configuration in the hspi Init structure. (#) Initialize the SPI registers by calling the HAL_SPI_Init() API: (++) This API configures also the low level Hardware GPIO, CLOCK, CORTEX...etc) by calling the customized HAL_SPI_MspInit() API. [..] Circular mode restriction: (#) The DMA circular mode cannot be used when the SPI is configured in these modes: (##) Master 2Lines RxOnly (##) Master 1Line Rx (#) The CRC feature is not managed when the DMA circular mode is enabled (#) When the SPI DMA Pause/Stop features are used, we must use the following APIs the HAL_SPI_DMAPause()/ HAL_SPI_DMAStop() only under the SPI callbacks [..] Master Receive mode restriction: (#) In Master unidirectional receive-only mode (MSTR =1, BIDIMODE=0, RXONLY=0) or bidirectional receive mode (MSTR=1, BIDIMODE=1, BIDIOE=0), to ensure that the SPI does not initiate a new transfer the following procedure has to be respected: (##) HAL_SPI_DeInit() (##) HAL_SPI_Init() @endverbatim Using the HAL it is not possible to reach all supported SPI frequency with the differents SPI Modes, the following tables resume the max SPI frequency reached with data size 8bits/16bits, according to frequency used on APBx Peripheral Clock (fPCLK) used by the SPI instance : DataSize = SPI_DATASIZE_8BIT: +----------------------------------------------------------------------------------------------+ | | | 2Lines Fullduplex | 2Lines RxOnly | 1Line | | Process | Tranfert mode |---------------------|----------------------|----------------------| | | | Master | Slave | Master | Slave | Master | Slave | |==============================================================================================| | T | Polling | Fpclk/2 | Fpclk/2 | NA | NA | NA | NA | | X |----------------|----------|----------|-----------|----------|-----------|----------| | / | Interrupt | Fpclk/4 | Fpclk/8 | NA | NA | NA | NA | | R |----------------|----------|----------|-----------|----------|-----------|----------| | X | DMA | Fpclk/2 | Fpclk/2 | NA | NA | NA | NA | |=========|================|==========|==========|===========|==========|===========|==========| | | Polling | Fpclk/2 | Fpclk/2 | Fpclk/64 | Fpclk/2 | Fpclk/64 | Fpclk/2 | | |----------------|----------|----------|-----------|----------|-----------|----------| | R | Interrupt | Fpclk/8 | Fpclk/8 | Fpclk/64 | Fpclk/2 | Fpclk/64 | Fpclk/2 | | X |----------------|----------|----------|-----------|----------|-----------|----------| | | DMA | Fpclk/2 | Fpclk/2 | Fpclk/64 | Fpclk/2 | Fpclk/128 | Fpclk/2 | |=========|================|==========|==========|===========|==========|===========|==========| | | Polling | Fpclk/2 | Fpclk/4 | NA | NA | Fpclk/2 | Fpclk/64 | | |----------------|----------|----------|-----------|----------|-----------|----------| | T | Interrupt | Fpclk/2 | Fpclk/4 | NA | NA | Fpclk/2 | Fpclk/64 | | X |----------------|----------|----------|-----------|----------|-----------|----------| | | DMA | Fpclk/2 | Fpclk/2 | NA | NA | Fpclk/2 | Fpclk/128| +----------------------------------------------------------------------------------------------+ DataSize = SPI_DATASIZE_16BIT: +----------------------------------------------------------------------------------------------+ | | | 2Lines Fullduplex | 2Lines RxOnly | 1Line | | Process | Tranfert mode |---------------------|----------------------|----------------------| | | | Master | Slave | Master | Slave | Master | Slave | |==============================================================================================| | T | Polling | Fpclk/2 | Fpclk/2 | NA | NA | NA | NA | | X |----------------|----------|----------|-----------|----------|-----------|----------| | / | Interrupt | Fpclk/4 | Fpclk/4 | NA | NA | NA | NA | | R |----------------|----------|----------|-----------|----------|-----------|----------| | X | DMA | Fpclk/2 | Fpclk/2 | NA | NA | NA | NA | |=========|================|==========|==========|===========|==========|===========|==========| | | Polling | Fpclk/2 | Fpclk/2 | Fpclk/64 | Fpclk/2 | Fpclk/32 | Fpclk/2 | | |----------------|----------|----------|-----------|----------|-----------|----------| | R | Interrupt | Fpclk/4 | Fpclk/4 | Fpclk/64 | Fpclk/2 | Fpclk/64 | Fpclk/2 | | X |----------------|----------|----------|-----------|----------|-----------|----------| | | DMA | Fpclk/2 | Fpclk/2 | Fpclk/64 | Fpclk/2 | Fpclk/128 | Fpclk/2 | |=========|================|==========|==========|===========|==========|===========|==========| | | Polling | Fpclk/2 | Fpclk/2 | NA | NA | Fpclk/2 | Fpclk/32 | | |----------------|----------|----------|-----------|----------|-----------|----------| | T | Interrupt | Fpclk/2 | Fpclk/2 | NA | NA | Fpclk/2 | Fpclk/64 | | X |----------------|----------|----------|-----------|----------|-----------|----------| | | DMA | Fpclk/2 | Fpclk/2 | NA | NA | Fpclk/2 | Fpclk/128| +----------------------------------------------------------------------------------------------+ [..] (@) The max SPI frequency depend on SPI data size (8bits, 16bits), SPI mode(2 Lines fullduplex, 2 lines RxOnly, 1 line TX/RX) and Process mode (Polling, IT, DMA). (@) (+@) TX/RX processes are HAL_SPI_TransmitReceive(), HAL_SPI_TransmitReceive_IT() and HAL_SPI_TransmitReceive_DMA() (+@) RX processes are HAL_SPI_Receive(), HAL_SPI_Receive_IT() and HAL_SPI_Receive_DMA() (+@) TX processes are HAL_SPI_Transmit(), HAL_SPI_Transmit_IT() and HAL_SPI_Transmit_DMA() ****************************************************************************** * @attention * *

© COPYRIGHT(c) 2017 STMicroelectronics

* * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. Neither the name of STMicroelectronics nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ /* Includes ------------------------------------------------------------------*/ #include "stm32f4xx_hal.h" /** @addtogroup STM32F4xx_HAL_Driver * @{ */ /** @defgroup SPI SPI * @brief SPI HAL module driver * @{ */ #ifdef HAL_SPI_MODULE_ENABLED /* Private typedef -----------------------------------------------------------*/ /* Private defines -----------------------------------------------------------*/ /** @defgroup SPI_Private_Constants SPI Private Constants * @{ */ #define SPI_DEFAULT_TIMEOUT 100U /** * @} */ /* Private macros ------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/ /** @addtogroup SPI_Private_Functions * @{ */ #if 0 // XXX DMA static void SPI_DMATransmitCplt(DMA_HandleTypeDef *hdma); static void SPI_DMAReceiveCplt(DMA_HandleTypeDef *hdma); static void SPI_DMATransmitReceiveCplt(DMA_HandleTypeDef *hdma); static void SPI_DMAHalfTransmitCplt(DMA_HandleTypeDef *hdma); static void SPI_DMAHalfReceiveCplt(DMA_HandleTypeDef *hdma); static void SPI_DMAHalfTransmitReceiveCplt(DMA_HandleTypeDef *hdma); static void SPI_DMAError(DMA_HandleTypeDef *hdma); static void SPI_DMAAbortOnError(DMA_HandleTypeDef *hdma); static void SPI_DMATxAbortCallback(DMA_HandleTypeDef *hdma); static void SPI_DMARxAbortCallback(DMA_HandleTypeDef *hdma); #endif // XXX DMA static HAL_StatusTypeDef SPI_WaitFlagStateUntilTimeout(SPI_HandleTypeDef *hspi, uint32_t Flag, uint32_t State, uint32_t Timeout, uint32_t Tickstart); static void SPI_TxISR_8BIT(struct __SPI_HandleTypeDef *hspi); static void SPI_TxISR_16BIT(struct __SPI_HandleTypeDef *hspi); static void SPI_RxISR_8BIT(struct __SPI_HandleTypeDef *hspi); static void SPI_RxISR_16BIT(struct __SPI_HandleTypeDef *hspi); static void SPI_2linesRxISR_8BIT(struct __SPI_HandleTypeDef *hspi); static void SPI_2linesTxISR_8BIT(struct __SPI_HandleTypeDef *hspi); static void SPI_2linesTxISR_16BIT(struct __SPI_HandleTypeDef *hspi); static void SPI_2linesRxISR_16BIT(struct __SPI_HandleTypeDef *hspi); #if (USE_SPI_CRC != 0U) static void SPI_RxISR_8BITCRC(struct __SPI_HandleTypeDef *hspi); static void SPI_RxISR_16BITCRC(struct __SPI_HandleTypeDef *hspi); static void SPI_2linesRxISR_8BITCRC(struct __SPI_HandleTypeDef *hspi); static void SPI_2linesRxISR_16BITCRC(struct __SPI_HandleTypeDef *hspi); #endif /* USE_SPI_CRC */ static void SPI_AbortRx_ISR(SPI_HandleTypeDef *hspi); static void SPI_AbortTx_ISR(SPI_HandleTypeDef *hspi); static void SPI_CloseRxTx_ISR(SPI_HandleTypeDef *hspi); static void SPI_CloseRx_ISR(SPI_HandleTypeDef *hspi); static void SPI_CloseTx_ISR(SPI_HandleTypeDef *hspi); static HAL_StatusTypeDef SPI_CheckFlag_BSY(SPI_HandleTypeDef *hspi, uint32_t Timeout, uint32_t Tickstart); /** * @} */ /* Exported functions --------------------------------------------------------*/ /** @defgroup SPI_Exported_Functions SPI Exported Functions * @{ */ /** @defgroup SPI_Exported_Functions_Group1 Initialization and de-initialization functions * @brief Initialization and Configuration functions * @verbatim =============================================================================== ##### Initialization and de-initialization functions ##### =============================================================================== [..] This subsection provides a set of functions allowing to initialize and de-initialize the SPIx peripheral: (+) User must implement HAL_SPI_MspInit() function in which he configures all related peripherals resources (CLOCK, GPIO, DMA, IT and NVIC ). (+) Call the function HAL_SPI_Init() to configure the selected device with the selected configuration: (++) Mode (++) Direction (++) Data Size (++) Clock Polarity and Phase (++) NSS Management (++) BaudRate Prescaler (++) FirstBit (++) TIMode (++) CRC Calculation (++) CRC Polynomial if CRC enabled (+) Call the function HAL_SPI_DeInit() to restore the default configuration of the selected SPIx peripheral. @endverbatim * @{ */ /** * @brief Initialize the SPI according to the specified parameters * in the SPI_InitTypeDef and initialize the associated handle. * @param hspi: pointer to a SPI_HandleTypeDef structure that contains * the configuration information for SPI module. * @retval HAL status */ HAL_StatusTypeDef HAL_SPI_Init(SPI_HandleTypeDef *hspi) { /* Check the SPI handle allocation */ if(hspi == NULL) { return HAL_ERROR; } /* Check the parameters */ assert_param(IS_SPI_ALL_INSTANCE(hspi->Instance)); assert_param(IS_SPI_MODE(hspi->Init.Mode)); assert_param(IS_SPI_DIRECTION(hspi->Init.Direction)); assert_param(IS_SPI_DATASIZE(hspi->Init.DataSize)); assert_param(IS_SPI_NSS(hspi->Init.NSS)); assert_param(IS_SPI_BAUDRATE_PRESCALER(hspi->Init.BaudRatePrescaler)); assert_param(IS_SPI_FIRST_BIT(hspi->Init.FirstBit)); assert_param(IS_SPI_TIMODE(hspi->Init.TIMode)); if(hspi->Init.TIMode == SPI_TIMODE_DISABLE) { assert_param(IS_SPI_CPOL(hspi->Init.CLKPolarity)); assert_param(IS_SPI_CPHA(hspi->Init.CLKPhase)); } #if (USE_SPI_CRC != 0U) assert_param(IS_SPI_CRC_CALCULATION(hspi->Init.CRCCalculation)); if(hspi->Init.CRCCalculation == SPI_CRCCALCULATION_ENABLE) { assert_param(IS_SPI_CRC_POLYNOMIAL(hspi->Init.CRCPolynomial)); } #else hspi->Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE; #endif /* USE_SPI_CRC */ if(hspi->State == HAL_SPI_STATE_RESET) { /* Allocate lock resource and initialize it */ hspi->Lock = HAL_UNLOCKED; /* Init the low level hardware : GPIO, CLOCK, NVIC... */ HAL_SPI_MspInit(hspi); } hspi->State = HAL_SPI_STATE_BUSY; /* Disable the selected SPI peripheral */ __HAL_SPI_DISABLE(hspi); /*----------------------- SPIx CR1 & CR2 Configuration ---------------------*/ /* Configure : SPI Mode, Communication Mode, Data size, Clock polarity and phase, NSS management, Communication speed, First bit and CRC calculation state */ WRITE_REG(hspi->Instance->CR1, (hspi->Init.Mode | hspi->Init.Direction | hspi->Init.DataSize | hspi->Init.CLKPolarity | hspi->Init.CLKPhase | (hspi->Init.NSS & SPI_CR1_SSM) | hspi->Init.BaudRatePrescaler | hspi->Init.FirstBit | hspi->Init.CRCCalculation) ); /* Configure : NSS management */ WRITE_REG(hspi->Instance->CR2, (((hspi->Init.NSS >> 16U) & SPI_CR2_SSOE) | hspi->Init.TIMode)); #if (USE_SPI_CRC != 0U) /*---------------------------- SPIx CRCPOLY Configuration ------------------*/ /* Configure : CRC Polynomial */ if(hspi->Init.CRCCalculation == SPI_CRCCALCULATION_ENABLE) { WRITE_REG(hspi->Instance->CRCPR, hspi->Init.CRCPolynomial); } #endif /* USE_SPI_CRC */ #if defined(SPI_I2SCFGR_I2SMOD) /* Activate the SPI mode (Make sure that I2SMOD bit in I2SCFGR register is reset) */ CLEAR_BIT(hspi->Instance->I2SCFGR, SPI_I2SCFGR_I2SMOD); #endif /* USE_SPI_CRC */ hspi->ErrorCode = HAL_SPI_ERROR_NONE; hspi->State = HAL_SPI_STATE_READY; return HAL_OK; } /** * @brief De Initialize the SPI peripheral. * @param hspi: pointer to a SPI_HandleTypeDef structure that contains * the configuration information for SPI module. * @retval HAL status */ HAL_StatusTypeDef HAL_SPI_DeInit(SPI_HandleTypeDef *hspi) { /* Check the SPI handle allocation */ if(hspi == NULL) { return HAL_ERROR; } /* Check SPI Instance parameter */ assert_param(IS_SPI_ALL_INSTANCE(hspi->Instance)); hspi->State = HAL_SPI_STATE_BUSY; /* Disable the SPI Peripheral Clock */ __HAL_SPI_DISABLE(hspi); /* DeInit the low level hardware: GPIO, CLOCK, NVIC... */ HAL_SPI_MspDeInit(hspi); hspi->ErrorCode = HAL_SPI_ERROR_NONE; hspi->State = HAL_SPI_STATE_RESET; /* Release Lock */ __HAL_UNLOCK(hspi); return HAL_OK; } /** * @brief Initialize the SPI MSP. * @param hspi: pointer to a SPI_HandleTypeDef structure that contains * the configuration information for SPI module. * @retval None */ __weak void HAL_SPI_MspInit(SPI_HandleTypeDef *hspi) { /* Prevent unused argument(s) compilation warning */ UNUSED(hspi); /* NOTE : This function should not be modified, when the callback is needed, the HAL_SPI_MspInit should be implemented in the user file */ } /** * @brief De-Initialize the SPI MSP. * @param hspi: pointer to a SPI_HandleTypeDef structure that contains * the configuration information for SPI module. * @retval None */ __weak void HAL_SPI_MspDeInit(SPI_HandleTypeDef *hspi) { /* Prevent unused argument(s) compilation warning */ UNUSED(hspi); /* NOTE : This function should not be modified, when the callback is needed, the HAL_SPI_MspDeInit should be implemented in the user file */ } /** * @} */ /** @defgroup SPI_Exported_Functions_Group2 IO operation functions * @brief Data transfers functions * @verbatim ============================================================================== ##### IO operation functions ##### =============================================================================== [..] This subsection provides a set of functions allowing to manage the SPI data transfers. [..] The SPI supports master and slave mode : (#) There are two modes of transfer: (++) Blocking mode: The communication is performed in polling mode. The HAL status of all data processing is returned by the same function after finishing transfer. (++) No-Blocking mode: The communication is performed using Interrupts or DMA, These APIs return the HAL status. The end of the data processing will be indicated through the dedicated SPI IRQ when using Interrupt mode or the DMA IRQ when using DMA mode. The HAL_SPI_TxCpltCallback(), HAL_SPI_RxCpltCallback() and HAL_SPI_TxRxCpltCallback() user callbacks will be executed respectively at the end of the transmit or Receive process The HAL_SPI_ErrorCallback()user callback will be executed when a communication error is detected (#) APIs provided for these 2 transfer modes (Blocking mode or Non blocking mode using either Interrupt or DMA) exist for 1Line (simplex) and 2Lines (full duplex) modes. @endverbatim * @{ */ /** * @brief Transmit an amount of data in blocking mode. * @param hspi: pointer to a SPI_HandleTypeDef structure that contains * the configuration information for SPI module. * @param pData: pointer to data buffer * @param Size: amount of data to be sent * @param Timeout: Timeout duration * @retval HAL status */ HAL_StatusTypeDef HAL_SPI_Transmit(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size, uint32_t Timeout) { uint32_t tickstart = 0U; HAL_StatusTypeDef errorcode = HAL_OK; /* Check Direction parameter */ assert_param(IS_SPI_DIRECTION_2LINES_OR_1LINE(hspi->Init.Direction)); /* Process Locked */ __HAL_LOCK(hspi); /* Init tickstart for timeout management*/ tickstart = HAL_GetTick(); if(hspi->State != HAL_SPI_STATE_READY) { errorcode = HAL_BUSY; goto error; } if((pData == NULL ) || (Size == 0)) { errorcode = HAL_ERROR; goto error; } /* Set the transaction information */ hspi->State = HAL_SPI_STATE_BUSY_TX; hspi->ErrorCode = HAL_SPI_ERROR_NONE; hspi->pTxBuffPtr = (uint8_t *)pData; hspi->TxXferSize = Size; hspi->TxXferCount = Size; /*Init field not used in handle to zero */ hspi->pRxBuffPtr = (uint8_t *)NULL; hspi->RxXferSize = 0U; hspi->RxXferCount = 0U; hspi->TxISR = NULL; hspi->RxISR = NULL; /* Configure communication direction : 1Line */ if(hspi->Init.Direction == SPI_DIRECTION_1LINE) { SPI_1LINE_TX(hspi); } #if (USE_SPI_CRC != 0U) /* Reset CRC Calculation */ if(hspi->Init.CRCCalculation == SPI_CRCCALCULATION_ENABLE) { SPI_RESET_CRC(hspi); } #endif /* USE_SPI_CRC */ /* Check if the SPI is already enabled */ if((hspi->Instance->CR1 & SPI_CR1_SPE) != SPI_CR1_SPE) { /* Enable SPI peripheral */ __HAL_SPI_ENABLE(hspi); } /* Transmit data in 16 Bit mode */ if(hspi->Init.DataSize == SPI_DATASIZE_16BIT) { if((hspi->Init.Mode == SPI_MODE_SLAVE) || (hspi->TxXferCount == 0x01)) { hspi->Instance->DR = *((uint16_t *)pData); pData += sizeof(uint16_t); hspi->TxXferCount--; } /* Transmit data in 16 Bit mode */ while (hspi->TxXferCount > 0U) { /* Wait until TXE flag is set to send data */ if(__HAL_SPI_GET_FLAG(hspi, SPI_FLAG_TXE)) { hspi->Instance->DR = *((uint16_t *)pData); pData += sizeof(uint16_t); hspi->TxXferCount--; } else { /* Timeout management */ if((Timeout == 0U) || ((Timeout != HAL_MAX_DELAY) && ((HAL_GetTick()-tickstart) >= Timeout))) { errorcode = HAL_TIMEOUT; goto error; } } } } /* Transmit data in 8 Bit mode */ else { if((hspi->Init.Mode == SPI_MODE_SLAVE)|| (hspi->TxXferCount == 0x01)) { *((__IO uint8_t*)&hspi->Instance->DR) = (*pData); pData += sizeof(uint8_t); hspi->TxXferCount--; } while (hspi->TxXferCount > 0U) { /* Wait until TXE flag is set to send data */ if(__HAL_SPI_GET_FLAG(hspi, SPI_FLAG_TXE)) { *((__IO uint8_t*)&hspi->Instance->DR) = (*pData); pData += sizeof(uint8_t); hspi->TxXferCount--; } else { /* Timeout management */ if((Timeout == 0U) || ((Timeout != HAL_MAX_DELAY) && ((HAL_GetTick()-tickstart) >= Timeout))) { errorcode = HAL_TIMEOUT; goto error; } } } } /* Wait until TXE flag */ if(SPI_WaitFlagStateUntilTimeout(hspi, SPI_FLAG_TXE, SET, Timeout, tickstart) != HAL_OK) { errorcode = HAL_TIMEOUT; goto error; } /* Check Busy flag */ if(SPI_CheckFlag_BSY(hspi, Timeout, tickstart) != HAL_OK) { errorcode = HAL_ERROR; hspi->ErrorCode = HAL_SPI_ERROR_FLAG; goto error; } /* Clear overrun flag in 2 Lines communication mode because received is not read */ if(hspi->Init.Direction == SPI_DIRECTION_2LINES) { __HAL_SPI_CLEAR_OVRFLAG(hspi); } #if (USE_SPI_CRC != 0U) /* Enable CRC Transmission */ if(hspi->Init.CRCCalculation == SPI_CRCCALCULATION_ENABLE) { SET_BIT(hspi->Instance->CR1, SPI_CR1_CRCNEXT); } #endif /* USE_SPI_CRC */ if(hspi->ErrorCode != HAL_SPI_ERROR_NONE) { errorcode = HAL_ERROR; } error: hspi->State = HAL_SPI_STATE_READY; /* Process Unlocked */ __HAL_UNLOCK(hspi); return errorcode; } /** * @brief Receive an amount of data in blocking mode. * @param hspi: pointer to a SPI_HandleTypeDef structure that contains * the configuration information for SPI module. * @param pData: pointer to data buffer * @param Size: amount of data to be received * @param Timeout: Timeout duration * @retval HAL status */ HAL_StatusTypeDef HAL_SPI_Receive(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size, uint32_t Timeout) { #if (USE_SPI_CRC != 0U) __IO uint16_t tmpreg = 0U; #endif /* USE_SPI_CRC */ uint32_t tickstart = 0U; HAL_StatusTypeDef errorcode = HAL_OK; if((hspi->Init.Mode == SPI_MODE_MASTER) && (hspi->Init.Direction == SPI_DIRECTION_2LINES)) { hspi->State = HAL_SPI_STATE_BUSY_RX; /* Call transmit-receive function to send Dummy data on Tx line and generate clock on CLK line */ return HAL_SPI_TransmitReceive(hspi,pData,pData,Size,Timeout); } /* Process Locked */ __HAL_LOCK(hspi); /* Init tickstart for timeout management*/ tickstart = HAL_GetTick(); if(hspi->State != HAL_SPI_STATE_READY) { errorcode = HAL_BUSY; goto error; } if((pData == NULL ) || (Size == 0)) { errorcode = HAL_ERROR; goto error; } /* Set the transaction information */ hspi->State = HAL_SPI_STATE_BUSY_RX; hspi->ErrorCode = HAL_SPI_ERROR_NONE; hspi->pRxBuffPtr = (uint8_t *)pData; hspi->RxXferSize = Size; hspi->RxXferCount = Size; /*Init field not used in handle to zero */ hspi->pTxBuffPtr = (uint8_t *)NULL; hspi->TxXferSize = 0U; hspi->TxXferCount = 0U; hspi->RxISR = NULL; hspi->TxISR = NULL; #if (USE_SPI_CRC != 0U) /* Reset CRC Calculation */ if(hspi->Init.CRCCalculation == SPI_CRCCALCULATION_ENABLE) { SPI_RESET_CRC(hspi); /* this is done to handle the CRCNEXT before the latest data */ hspi->RxXferCount--; } #endif /* USE_SPI_CRC */ /* Configure communication direction: 1Line */ if(hspi->Init.Direction == SPI_DIRECTION_1LINE) { SPI_1LINE_RX(hspi); } /* Check if the SPI is already enabled */ if((hspi->Instance->CR1 & SPI_CR1_SPE) != SPI_CR1_SPE) { /* Enable SPI peripheral */ __HAL_SPI_ENABLE(hspi); } /* Receive data in 8 Bit mode */ if(hspi->Init.DataSize == SPI_DATASIZE_8BIT) { /* Transfer loop */ while(hspi->RxXferCount > 0U) { /* Check the RXNE flag */ if(__HAL_SPI_GET_FLAG(hspi, SPI_FLAG_RXNE)) { /* read the received data */ (* (uint8_t *)pData)= *(__IO uint8_t *)&hspi->Instance->DR; pData += sizeof(uint8_t); hspi->RxXferCount--; } else { /* Timeout management */ if((Timeout == 0U) || ((Timeout != HAL_MAX_DELAY) && ((HAL_GetTick()-tickstart) >= Timeout))) { errorcode = HAL_TIMEOUT; goto error; } } } } else { /* Transfer loop */ while(hspi->RxXferCount > 0U) { /* Check the RXNE flag */ if(__HAL_SPI_GET_FLAG(hspi, SPI_FLAG_RXNE)) { *((uint16_t*)pData) = hspi->Instance->DR; pData += sizeof(uint16_t); hspi->RxXferCount--; } else { /* Timeout management */ if((Timeout == 0U) || ((Timeout != HAL_MAX_DELAY) && ((HAL_GetTick()-tickstart) >= Timeout))) { errorcode = HAL_TIMEOUT; goto error; } } } } #if (USE_SPI_CRC != 0U) /* Handle the CRC Transmission */ if(hspi->Init.CRCCalculation == SPI_CRCCALCULATION_ENABLE) { /* freeze the CRC before the latest data */ SET_BIT(hspi->Instance->CR1, SPI_CR1_CRCNEXT); /* Read the latest data */ if(SPI_WaitFlagStateUntilTimeout(hspi, SPI_FLAG_RXNE, SET, Timeout, tickstart) != HAL_OK) { /* the latest data has not been received */ errorcode = HAL_TIMEOUT; goto error; } /* Receive last data in 16 Bit mode */ if(hspi->Init.DataSize == SPI_DATASIZE_16BIT) { *((uint16_t*)pData) = hspi->Instance->DR; } /* Receive last data in 8 Bit mode */ else { (*(uint8_t *)pData) = *(__IO uint8_t *)&hspi->Instance->DR; } /* Wait the CRC data */ if(SPI_WaitFlagStateUntilTimeout(hspi, SPI_FLAG_RXNE, SET, Timeout, tickstart) != HAL_OK) { SET_BIT(hspi->ErrorCode, HAL_SPI_ERROR_CRC); errorcode = HAL_TIMEOUT; goto error; } /* Read CRC to Flush DR and RXNE flag */ tmpreg = hspi->Instance->DR; /* To avoid GCC warning */ UNUSED(tmpreg); } #endif /* USE_SPI_CRC */ /* Check the end of the transaction */ if((hspi->Init.Mode == SPI_MODE_MASTER)&&((hspi->Init.Direction == SPI_DIRECTION_1LINE)||(hspi->Init.Direction == SPI_DIRECTION_2LINES_RXONLY))) { /* Disable SPI peripheral */ __HAL_SPI_DISABLE(hspi); } #if (USE_SPI_CRC != 0U) /* Check if CRC error occurred */ if(__HAL_SPI_GET_FLAG(hspi, SPI_FLAG_CRCERR)) { SET_BIT(hspi->ErrorCode, HAL_SPI_ERROR_CRC); __HAL_SPI_CLEAR_CRCERRFLAG(hspi); } #endif /* USE_SPI_CRC */ if(hspi->ErrorCode != HAL_SPI_ERROR_NONE) { errorcode = HAL_ERROR; } error : hspi->State = HAL_SPI_STATE_READY; __HAL_UNLOCK(hspi); return errorcode; } /** * @brief Transmit and Receive an amount of data in blocking mode. * @param hspi: pointer to a SPI_HandleTypeDef structure that contains * the configuration information for SPI module. * @param pTxData: pointer to transmission data buffer * @param pRxData: pointer to reception data buffer * @param Size: amount of data to be sent and received * @param Timeout: Timeout duration * @retval HAL status */ HAL_StatusTypeDef HAL_SPI_TransmitReceive(SPI_HandleTypeDef *hspi, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size, uint32_t Timeout) { uint32_t tmp = 0U, tmp1 = 0U; #if (USE_SPI_CRC != 0U) __IO uint16_t tmpreg1 = 0U; #endif /* USE_SPI_CRC */ uint32_t tickstart = 0U; /* Variable used to alternate Rx and Tx during transfer */ uint32_t txallowed = 1U; HAL_StatusTypeDef errorcode = HAL_OK; /* Check Direction parameter */ assert_param(IS_SPI_DIRECTION_2LINES(hspi->Init.Direction)); /* Process Locked */ __HAL_LOCK(hspi); /* Init tickstart for timeout management*/ tickstart = HAL_GetTick(); tmp = hspi->State; tmp1 = hspi->Init.Mode; if(!((tmp == HAL_SPI_STATE_READY) || \ ((tmp1 == SPI_MODE_MASTER) && (hspi->Init.Direction == SPI_DIRECTION_2LINES) && (tmp == HAL_SPI_STATE_BUSY_RX)))) { errorcode = HAL_BUSY; goto error; } if((pTxData == NULL) || (pRxData == NULL) || (Size == 0)) { errorcode = HAL_ERROR; goto error; } /* Don't overwrite in case of HAL_SPI_STATE_BUSY_RX */ if(hspi->State == HAL_SPI_STATE_READY) { hspi->State = HAL_SPI_STATE_BUSY_TX_RX; } /* Set the transaction information */ hspi->ErrorCode = HAL_SPI_ERROR_NONE; hspi->pRxBuffPtr = (uint8_t *)pRxData; hspi->RxXferCount = Size; hspi->RxXferSize = Size; hspi->pTxBuffPtr = (uint8_t *)pTxData; hspi->TxXferCount = Size; hspi->TxXferSize = Size; /*Init field not used in handle to zero */ hspi->RxISR = NULL; hspi->TxISR = NULL; #if (USE_SPI_CRC != 0U) /* Reset CRC Calculation */ if(hspi->Init.CRCCalculation == SPI_CRCCALCULATION_ENABLE) { SPI_RESET_CRC(hspi); } #endif /* USE_SPI_CRC */ /* Check if the SPI is already enabled */ if((hspi->Instance->CR1 &SPI_CR1_SPE) != SPI_CR1_SPE) { /* Enable SPI peripheral */ __HAL_SPI_ENABLE(hspi); } /* Transmit and Receive data in 16 Bit mode */ if(hspi->Init.DataSize == SPI_DATASIZE_16BIT) { if((hspi->Init.Mode == SPI_MODE_SLAVE) || (hspi->TxXferCount == 0x01U)) { hspi->Instance->DR = *((uint16_t *)pTxData); pTxData += sizeof(uint16_t); hspi->TxXferCount--; } while ((hspi->TxXferCount > 0U) || (hspi->RxXferCount > 0U)) { /* Check TXE flag */ if(txallowed && (hspi->TxXferCount > 0U) && (__HAL_SPI_GET_FLAG(hspi, SPI_FLAG_TXE))) { hspi->Instance->DR = *((uint16_t *)pTxData); pTxData += sizeof(uint16_t); hspi->TxXferCount--; /* Next Data is a reception (Rx). Tx not allowed */ txallowed = 0U; #if (USE_SPI_CRC != 0U) /* Enable CRC Transmission */ if((hspi->TxXferCount == 0U) && (hspi->Init.CRCCalculation == SPI_CRCCALCULATION_ENABLE)) { SET_BIT(hspi->Instance->CR1, SPI_CR1_CRCNEXT); } #endif /* USE_SPI_CRC */ } /* Check RXNE flag */ if((hspi->RxXferCount > 0U) && (__HAL_SPI_GET_FLAG(hspi, SPI_FLAG_RXNE))) { *((uint16_t *)pRxData) = hspi->Instance->DR; pRxData += sizeof(uint16_t); hspi->RxXferCount--; /* Next Data is a Transmission (Tx). Tx is allowed */ txallowed = 1U; } if((Timeout != HAL_MAX_DELAY) && ((HAL_GetTick()-tickstart) >= Timeout)) { errorcode = HAL_TIMEOUT; goto error; } } } /* Transmit and Receive data in 8 Bit mode */ else { if((hspi->Init.Mode == SPI_MODE_SLAVE) || (hspi->TxXferCount == 0x01U)) { *((__IO uint8_t*)&hspi->Instance->DR) = (*pTxData); pTxData += sizeof(uint8_t); hspi->TxXferCount--; } while((hspi->TxXferCount > 0U) || (hspi->RxXferCount > 0U)) { /* check TXE flag */ if(txallowed && (hspi->TxXferCount > 0U) && (__HAL_SPI_GET_FLAG(hspi, SPI_FLAG_TXE))) { *(__IO uint8_t *)&hspi->Instance->DR = (*pTxData++); hspi->TxXferCount--; /* Next Data is a reception (Rx). Tx not allowed */ txallowed = 0U; #if (USE_SPI_CRC != 0U) /* Enable CRC Transmission */ if((hspi->TxXferCount == 0U) && (hspi->Init.CRCCalculation == SPI_CRCCALCULATION_ENABLE)) { SET_BIT(hspi->Instance->CR1, SPI_CR1_CRCNEXT); } #endif /* USE_SPI_CRC */ } /* Wait until RXNE flag is reset */ if((hspi->RxXferCount > 0U) && (__HAL_SPI_GET_FLAG(hspi, SPI_FLAG_RXNE))) { (*(uint8_t *)pRxData++) = hspi->Instance->DR; hspi->RxXferCount--; /* Next Data is a Transmission (Tx). Tx is allowed */ txallowed = 1U; } if((Timeout != HAL_MAX_DELAY) && ((HAL_GetTick()-tickstart) >= Timeout)) { errorcode = HAL_TIMEOUT; goto error; } } } #if (USE_SPI_CRC != 0U) /* Read CRC from DR to close CRC calculation process */ if(hspi->Init.CRCCalculation == SPI_CRCCALCULATION_ENABLE) { /* Wait until TXE flag */ if(SPI_WaitFlagStateUntilTimeout(hspi, SPI_FLAG_RXNE, SET, Timeout, tickstart) != HAL_OK) { /* Error on the CRC reception */ SET_BIT(hspi->ErrorCode, HAL_SPI_ERROR_CRC); errorcode = HAL_TIMEOUT; goto error; } /* Read CRC */ tmpreg1 = hspi->Instance->DR; /* To avoid GCC warning */ UNUSED(tmpreg1); } /* Check if CRC error occurred */ if(__HAL_SPI_GET_FLAG(hspi, SPI_FLAG_CRCERR)) { SET_BIT(hspi->ErrorCode, HAL_SPI_ERROR_CRC); /* Clear CRC Flag */ __HAL_SPI_CLEAR_CRCERRFLAG(hspi); errorcode = HAL_ERROR; } #endif /* USE_SPI_CRC */ /* Wait until TXE flag */ if(SPI_WaitFlagStateUntilTimeout(hspi, SPI_FLAG_TXE, SET, Timeout, tickstart) != HAL_OK) { errorcode = HAL_TIMEOUT; goto error; } /* Check Busy flag */ if(SPI_CheckFlag_BSY(hspi, Timeout, tickstart) != HAL_OK) { errorcode = HAL_ERROR; hspi->ErrorCode = HAL_SPI_ERROR_FLAG; goto error; } /* Clear overrun flag in 2 Lines communication mode because received is not read */ if(hspi->Init.Direction == SPI_DIRECTION_2LINES) { __HAL_SPI_CLEAR_OVRFLAG(hspi); } error : hspi->State = HAL_SPI_STATE_READY; __HAL_UNLOCK(hspi); return errorcode; } /** * @brief Transmit an amount of data in non-blocking mode with Interrupt. * @param hspi: pointer to a SPI_HandleTypeDef structure that contains * the configuration information for SPI module. * @param pData: pointer to data buffer * @param Size: amount of data to be sent * @retval HAL status */ HAL_StatusTypeDef HAL_SPI_Transmit_IT(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size) { HAL_StatusTypeDef errorcode = HAL_OK; /* Check Direction parameter */ assert_param(IS_SPI_DIRECTION_2LINES_OR_1LINE(hspi->Init.Direction)); /* Process Locked */ __HAL_LOCK(hspi); if((pData == NULL) || (Size == 0)) { errorcode = HAL_ERROR; goto error; } if(hspi->State != HAL_SPI_STATE_READY) { errorcode = HAL_BUSY; goto error; } /* Set the transaction information */ hspi->State = HAL_SPI_STATE_BUSY_TX; hspi->ErrorCode = HAL_SPI_ERROR_NONE; hspi->pTxBuffPtr = (uint8_t *)pData; hspi->TxXferSize = Size; hspi->TxXferCount = Size; /* Init field not used in handle to zero */ hspi->pRxBuffPtr = (uint8_t *)NULL; hspi->RxXferSize = 0U; hspi->RxXferCount = 0U; hspi->RxISR = NULL; /* Set the function for IT treatment */ if(hspi->Init.DataSize > SPI_DATASIZE_8BIT ) { hspi->TxISR = SPI_TxISR_16BIT; } else { hspi->TxISR = SPI_TxISR_8BIT; } /* Configure communication direction : 1Line */ if(hspi->Init.Direction == SPI_DIRECTION_1LINE) { SPI_1LINE_TX(hspi); } #if (USE_SPI_CRC != 0U) /* Reset CRC Calculation */ if(hspi->Init.CRCCalculation == SPI_CRCCALCULATION_ENABLE) { SPI_RESET_CRC(hspi); } #endif /* USE_SPI_CRC */ if (hspi->Init.Direction == SPI_DIRECTION_2LINES) { /* Enable TXE interrupt */ __HAL_SPI_ENABLE_IT(hspi, (SPI_IT_TXE)); } else { /* Enable TXE and ERR interrupt */ __HAL_SPI_ENABLE_IT(hspi, (SPI_IT_TXE | SPI_IT_ERR)); } /* Check if the SPI is already enabled */ if((hspi->Instance->CR1 &SPI_CR1_SPE) != SPI_CR1_SPE) { /* Enable SPI peripheral */ __HAL_SPI_ENABLE(hspi); } error : __HAL_UNLOCK(hspi); return errorcode; } /** * @brief Receive an amount of data in non-blocking mode with Interrupt. * @param hspi: pointer to a SPI_HandleTypeDef structure that contains * the configuration information for SPI module. * @param pData: pointer to data buffer * @param Size: amount of data to be sent * @retval HAL status */ HAL_StatusTypeDef HAL_SPI_Receive_IT(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size) { HAL_StatusTypeDef errorcode = HAL_OK; if((hspi->Init.Direction == SPI_DIRECTION_2LINES) && (hspi->Init.Mode == SPI_MODE_MASTER)) { hspi->State = HAL_SPI_STATE_BUSY_RX; /* Call transmit-receive function to send Dummy data on Tx line and generate clock on CLK line */ return HAL_SPI_TransmitReceive_IT(hspi, pData, pData, Size); } /* Process Locked */ __HAL_LOCK(hspi); if(hspi->State != HAL_SPI_STATE_READY) { errorcode = HAL_BUSY; goto error; } if((pData == NULL) || (Size == 0)) { errorcode = HAL_ERROR; goto error; } /* Set the transaction information */ hspi->State = HAL_SPI_STATE_BUSY_RX; hspi->ErrorCode = HAL_SPI_ERROR_NONE; hspi->pRxBuffPtr = (uint8_t *)pData; hspi->RxXferSize = Size; hspi->RxXferCount = Size; /* Init field not used in handle to zero */ hspi->pTxBuffPtr = (uint8_t *)NULL; hspi->TxXferSize = 0U; hspi->TxXferCount = 0U; hspi->TxISR = NULL; /* Set the function for IT treatment */ if(hspi->Init.DataSize > SPI_DATASIZE_8BIT ) { hspi->RxISR = SPI_RxISR_16BIT; } else { hspi->RxISR = SPI_RxISR_8BIT; } /* Configure communication direction : 1Line */ if(hspi->Init.Direction == SPI_DIRECTION_1LINE) { SPI_1LINE_RX(hspi); } #if (USE_SPI_CRC != 0U) /* Reset CRC Calculation */ if(hspi->Init.CRCCalculation == SPI_CRCCALCULATION_ENABLE) { SPI_RESET_CRC(hspi); } #endif /* USE_SPI_CRC */ /* Enable TXE and ERR interrupt */ __HAL_SPI_ENABLE_IT(hspi, (SPI_IT_RXNE | SPI_IT_ERR)); /* Note : The SPI must be enabled after unlocking current process to avoid the risk of SPI interrupt handle execution before current process unlock */ /* Check if the SPI is already enabled */ if((hspi->Instance->CR1 &SPI_CR1_SPE) != SPI_CR1_SPE) { /* Enable SPI peripheral */ __HAL_SPI_ENABLE(hspi); } error : /* Process Unlocked */ __HAL_UNLOCK(hspi); return errorcode; } /** * @brief Transmit and Receive an amount of data in non-blocking mode with Interrupt. * @param hspi: pointer to a SPI_HandleTypeDef structure that contains * the configuration information for SPI module. * @param pTxData: pointer to transmission data buffer * @param pRxData: pointer to reception data buffer * @param Size: amount of data to be sent and received * @retval HAL status */ HAL_StatusTypeDef HAL_SPI_TransmitReceive_IT(SPI_HandleTypeDef *hspi, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size) { uint32_t tmp = 0U, tmp1 = 0U; HAL_StatusTypeDef errorcode = HAL_OK; /* Check Direction parameter */ assert_param(IS_SPI_DIRECTION_2LINES(hspi->Init.Direction)); /* Process locked */ __HAL_LOCK(hspi); tmp = hspi->State; tmp1 = hspi->Init.Mode; if(!((tmp == HAL_SPI_STATE_READY) || \ ((tmp1 == SPI_MODE_MASTER) && (hspi->Init.Direction == SPI_DIRECTION_2LINES) && (tmp == HAL_SPI_STATE_BUSY_RX)))) { errorcode = HAL_BUSY; goto error; } if((pTxData == NULL ) || (pRxData == NULL ) || (Size == 0)) { errorcode = HAL_ERROR; goto error; } /* Don't overwrite in case of HAL_SPI_STATE_BUSY_RX */ if(hspi->State == HAL_SPI_STATE_READY) { hspi->State = HAL_SPI_STATE_BUSY_TX_RX; } /* Set the transaction information */ hspi->ErrorCode = HAL_SPI_ERROR_NONE; hspi->pTxBuffPtr = (uint8_t *)pTxData; hspi->TxXferSize = Size; hspi->TxXferCount = Size; hspi->pRxBuffPtr = (uint8_t *)pRxData; hspi->RxXferSize = Size; hspi->RxXferCount = Size; /* Set the function for IT treatment */ if(hspi->Init.DataSize > SPI_DATASIZE_8BIT ) { hspi->RxISR = SPI_2linesRxISR_16BIT; hspi->TxISR = SPI_2linesTxISR_16BIT; } else { hspi->RxISR = SPI_2linesRxISR_8BIT; hspi->TxISR = SPI_2linesTxISR_8BIT; } #if (USE_SPI_CRC != 0U) /* Reset CRC Calculation */ if(hspi->Init.CRCCalculation == SPI_CRCCALCULATION_ENABLE) { SPI_RESET_CRC(hspi); } #endif /* USE_SPI_CRC */ /* Enable TXE, RXNE and ERR interrupt */ __HAL_SPI_ENABLE_IT(hspi, (SPI_IT_TXE | SPI_IT_RXNE | SPI_IT_ERR)); /* Check if the SPI is already enabled */ if((hspi->Instance->CR1 &SPI_CR1_SPE) != SPI_CR1_SPE) { /* Enable SPI peripheral */ __HAL_SPI_ENABLE(hspi); } error : /* Process Unlocked */ __HAL_UNLOCK(hspi); return errorcode; } #if 0 // XXX DMA /** * @brief Transmit an amount of data in non-blocking mode with DMA. * @param hspi: pointer to a SPI_HandleTypeDef structure that contains * the configuration information for SPI module. * @param pData: pointer to data buffer * @param Size: amount of data to be sent * @retval HAL status */ HAL_StatusTypeDef HAL_SPI_Transmit_DMA(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size) { HAL_StatusTypeDef errorcode = HAL_OK; /* Check Direction parameter */ assert_param(IS_SPI_DIRECTION_2LINES_OR_1LINE(hspi->Init.Direction)); /* Process Locked */ __HAL_LOCK(hspi); if(hspi->State != HAL_SPI_STATE_READY) { errorcode = HAL_BUSY; goto error; } if((pData == NULL) || (Size == 0)) { errorcode = HAL_ERROR; goto error; } /* Set the transaction information */ hspi->State = HAL_SPI_STATE_BUSY_TX; hspi->ErrorCode = HAL_SPI_ERROR_NONE; hspi->pTxBuffPtr = (uint8_t *)pData; hspi->TxXferSize = Size; hspi->TxXferCount = Size; /* Init field not used in handle to zero */ hspi->pRxBuffPtr = (uint8_t *)NULL; hspi->TxISR = NULL; hspi->RxISR = NULL; hspi->RxXferSize = 0U; hspi->RxXferCount = 0U; /* Configure communication direction : 1Line */ if(hspi->Init.Direction == SPI_DIRECTION_1LINE) { SPI_1LINE_TX(hspi); } #if (USE_SPI_CRC != 0U) /* Reset CRC Calculation */ if(hspi->Init.CRCCalculation == SPI_CRCCALCULATION_ENABLE) { SPI_RESET_CRC(hspi); } #endif /* USE_SPI_CRC */ /* Set the SPI TxDMA Half transfer complete callback */ hspi->hdmatx->XferHalfCpltCallback = SPI_DMAHalfTransmitCplt; /* Set the SPI TxDMA transfer complete callback */ hspi->hdmatx->XferCpltCallback = SPI_DMATransmitCplt; /* Set the DMA error callback */ hspi->hdmatx->XferErrorCallback = SPI_DMAError; /* Set the DMA AbortCpltCallback */ hspi->hdmatx->XferAbortCallback = NULL; /* Enable the Tx DMA Stream */ HAL_DMA_Start_IT(hspi->hdmatx, (uint32_t)hspi->pTxBuffPtr, (uint32_t)&hspi->Instance->DR, hspi->TxXferCount); /* Check if the SPI is already enabled */ if((hspi->Instance->CR1 &SPI_CR1_SPE) != SPI_CR1_SPE) { /* Enable SPI peripheral */ __HAL_SPI_ENABLE(hspi); } /* Enable the SPI Error Interrupt Bit */ SET_BIT(hspi->Instance->CR2, SPI_CR2_ERRIE); /* Enable Tx DMA Request */ SET_BIT(hspi->Instance->CR2, SPI_CR2_TXDMAEN); error : /* Process Unlocked */ __HAL_UNLOCK(hspi); return errorcode; } /** * @brief Receive an amount of data in non-blocking mode with DMA. * @param hspi: pointer to a SPI_HandleTypeDef structure that contains * the configuration information for SPI module. * @param pData: pointer to data buffer * @note When the CRC feature is enabled the pData Length must be Size + 1. * @param Size: amount of data to be sent * @retval HAL status */ HAL_StatusTypeDef HAL_SPI_Receive_DMA(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size) { HAL_StatusTypeDef errorcode = HAL_OK; if((hspi->Init.Direction == SPI_DIRECTION_2LINES)&&(hspi->Init.Mode == SPI_MODE_MASTER)) { hspi->State = HAL_SPI_STATE_BUSY_RX; /* Call transmit-receive function to send Dummy data on Tx line and generate clock on CLK line */ return HAL_SPI_TransmitReceive_DMA(hspi, pData, pData, Size); } /* Process Locked */ __HAL_LOCK(hspi); if(hspi->State != HAL_SPI_STATE_READY) { errorcode = HAL_BUSY; goto error; } if((pData == NULL) || (Size == 0)) { errorcode = HAL_ERROR; goto error; } /* Set the transaction information */ hspi->State = HAL_SPI_STATE_BUSY_RX; hspi->ErrorCode = HAL_SPI_ERROR_NONE; hspi->pRxBuffPtr = (uint8_t *)pData; hspi->RxXferSize = Size; hspi->RxXferCount = Size; /*Init field not used in handle to zero */ hspi->RxISR = NULL; hspi->TxISR = NULL; hspi->TxXferSize = 0U; hspi->TxXferCount = 0U; /* Configure communication direction : 1Line */ if(hspi->Init.Direction == SPI_DIRECTION_1LINE) { SPI_1LINE_RX(hspi); } #if (USE_SPI_CRC != 0U) /* Reset CRC Calculation */ if(hspi->Init.CRCCalculation == SPI_CRCCALCULATION_ENABLE) { SPI_RESET_CRC(hspi); } #endif /* USE_SPI_CRC */ /* Set the SPI RxDMA Half transfer complete callback */ hspi->hdmarx->XferHalfCpltCallback = SPI_DMAHalfReceiveCplt; /* Set the SPI Rx DMA transfer complete callback */ hspi->hdmarx->XferCpltCallback = SPI_DMAReceiveCplt; /* Set the DMA error callback */ hspi->hdmarx->XferErrorCallback = SPI_DMAError; /* Set the DMA AbortCpltCallback */ hspi->hdmarx->XferAbortCallback = NULL; /* Enable the Rx DMA Stream */ HAL_DMA_Start_IT(hspi->hdmarx, (uint32_t)&hspi->Instance->DR, (uint32_t)hspi->pRxBuffPtr, hspi->RxXferCount); /* Check if the SPI is already enabled */ if((hspi->Instance->CR1 &SPI_CR1_SPE) != SPI_CR1_SPE) { /* Enable SPI peripheral */ __HAL_SPI_ENABLE(hspi); } /* Enable the SPI Error Interrupt Bit */ SET_BIT(hspi->Instance->CR2, SPI_CR2_ERRIE); /* Enable Rx DMA Request */ SET_BIT(hspi->Instance->CR2, SPI_CR2_RXDMAEN); error: /* Process Unlocked */ __HAL_UNLOCK(hspi); return errorcode; } /** * @brief Transmit and Receive an amount of data in non-blocking mode with DMA. * @param hspi: pointer to a SPI_HandleTypeDef structure that contains * the configuration information for SPI module. * @param pTxData: pointer to transmission data buffer * @param pRxData: pointer to reception data buffer * @note When the CRC feature is enabled the pRxData Length must be Size + 1 * @param Size: amount of data to be sent * @retval HAL status */ HAL_StatusTypeDef HAL_SPI_TransmitReceive_DMA(SPI_HandleTypeDef *hspi, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size) { uint32_t tmp = 0U, tmp1 = 0U; HAL_StatusTypeDef errorcode = HAL_OK; /* Check Direction parameter */ assert_param(IS_SPI_DIRECTION_2LINES(hspi->Init.Direction)); /* Process locked */ __HAL_LOCK(hspi); tmp = hspi->State; tmp1 = hspi->Init.Mode; if(!((tmp == HAL_SPI_STATE_READY) || ((tmp1 == SPI_MODE_MASTER) && (hspi->Init.Direction == SPI_DIRECTION_2LINES) && (tmp == HAL_SPI_STATE_BUSY_RX)))) { errorcode = HAL_BUSY; goto error; } if((pTxData == NULL ) || (pRxData == NULL ) || (Size == 0)) { errorcode = HAL_ERROR; goto error; } /* Don't overwrite in case of HAL_SPI_STATE_BUSY_RX */ if(hspi->State == HAL_SPI_STATE_READY) { hspi->State = HAL_SPI_STATE_BUSY_TX_RX; } /* Set the transaction information */ hspi->ErrorCode = HAL_SPI_ERROR_NONE; hspi->pTxBuffPtr = (uint8_t*)pTxData; hspi->TxXferSize = Size; hspi->TxXferCount = Size; hspi->pRxBuffPtr = (uint8_t*)pRxData; hspi->RxXferSize = Size; hspi->RxXferCount = Size; /* Init field not used in handle to zero */ hspi->RxISR = NULL; hspi->TxISR = NULL; #if (USE_SPI_CRC != 0U) /* Reset CRC Calculation */ if(hspi->Init.CRCCalculation == SPI_CRCCALCULATION_ENABLE) { SPI_RESET_CRC(hspi); } #endif /* USE_SPI_CRC */ /* Check if we are in Rx only or in Rx/Tx Mode and configure the DMA transfer complete callback */ if(hspi->State == HAL_SPI_STATE_BUSY_RX) { /* Set the SPI Rx DMA Half transfer complete callback */ hspi->hdmarx->XferHalfCpltCallback = SPI_DMAHalfReceiveCplt; hspi->hdmarx->XferCpltCallback = SPI_DMAReceiveCplt; } else { /* Set the SPI Tx/Rx DMA Half transfer complete callback */ hspi->hdmarx->XferHalfCpltCallback = SPI_DMAHalfTransmitReceiveCplt; hspi->hdmarx->XferCpltCallback = SPI_DMATransmitReceiveCplt; } /* Set the DMA error callback */ hspi->hdmarx->XferErrorCallback = SPI_DMAError; /* Set the DMA AbortCpltCallback */ hspi->hdmarx->XferAbortCallback = NULL; /* Enable the Rx DMA Stream */ HAL_DMA_Start_IT(hspi->hdmarx, (uint32_t)&hspi->Instance->DR, (uint32_t)hspi->pRxBuffPtr, hspi->RxXferCount); /* Enable Rx DMA Request */ SET_BIT(hspi->Instance->CR2, SPI_CR2_RXDMAEN); /* Set the SPI Tx DMA transfer complete callback as NULL because the communication closing is performed in DMA reception complete callback */ hspi->hdmatx->XferHalfCpltCallback = NULL; hspi->hdmatx->XferCpltCallback = NULL; hspi->hdmatx->XferErrorCallback = NULL; hspi->hdmatx->XferAbortCallback = NULL; /* Enable the Tx DMA Stream */ HAL_DMA_Start_IT(hspi->hdmatx, (uint32_t)hspi->pTxBuffPtr, (uint32_t)&hspi->Instance->DR, hspi->TxXferCount); /* Check if the SPI is already enabled */ if((hspi->Instance->CR1 &SPI_CR1_SPE) != SPI_CR1_SPE) { /* Enable SPI peripheral */ __HAL_SPI_ENABLE(hspi); } /* Enable the SPI Error Interrupt Bit */ SET_BIT(hspi->Instance->CR2, SPI_CR2_ERRIE); /* Enable Tx DMA Request */ SET_BIT(hspi->Instance->CR2, SPI_CR2_TXDMAEN); error : /* Process Unlocked */ __HAL_UNLOCK(hspi); return errorcode; } #endif // XXX DMA /** * @brief Abort ongoing transfer (blocking mode). * @param hspi SPI handle. * @note This procedure could be used for aborting any ongoing transfer (Tx and Rx), * started in Interrupt or DMA mode. * This procedure performs following operations : * - Disable SPI Interrupts (depending of transfer direction) * - Disable the DMA transfer in the peripheral register (if enabled) * - Abort DMA transfer by calling HAL_DMA_Abort (in case of transfer in DMA mode) * - Set handle State to READY * @note This procedure is executed in blocking mode : when exiting function, Abort is considered as completed. * @note Once transfer is aborted, the __HAL_SPI_CLEAR_OVRFLAG() macro must be called in user application * before starting new SPI receive process. * @retval HAL status */ HAL_StatusTypeDef HAL_SPI_Abort(SPI_HandleTypeDef *hspi) { #if 0 // XXX DMA __IO uint32_t count = SPI_DEFAULT_TIMEOUT * (SystemCoreClock / 24U / 1000U); #endif // XXX DMA /* Disable TXEIE, RXNEIE and ERRIE(mode fault event, overrun error, TI frame error) interrupts */ if(HAL_IS_BIT_SET(hspi->Instance->CR2, SPI_CR2_TXEIE)) { hspi->TxISR = SPI_AbortTx_ISR; } if(HAL_IS_BIT_SET(hspi->Instance->CR2, SPI_CR2_RXNEIE)) { hspi->RxISR = SPI_AbortRx_ISR; } /* Clear ERRIE interrupts in case of DMA Mode */ CLEAR_BIT(hspi->Instance->CR2, SPI_CR2_ERRIE); /* Disable the SPI DMA Tx or SPI DMA Rx request if enabled */ if ((HAL_IS_BIT_SET(hspi->Instance->CR2, SPI_CR2_TXDMAEN)) || (HAL_IS_BIT_SET(hspi->Instance->CR2, SPI_CR2_RXDMAEN))) { #if 0 // XXX DMA /* Abort the SPI DMA Tx channel : use blocking DMA Abort API (no callback) */ if(hspi->hdmatx != NULL) { /* Set the SPI DMA Abort callback : will lead to call HAL_SPI_AbortCpltCallback() at end of DMA abort procedure */ hspi->hdmatx->XferAbortCallback = NULL; /* Abort DMA Tx Handle linked to SPI Peripheral */ HAL_DMA_Abort(hspi->hdmatx); /* Disable Tx DMA Request */ CLEAR_BIT(hspi->Instance->CR2, (SPI_CR2_TXDMAEN)); /* Wait until TXE flag is set */ do { if(count-- == 0U) { SET_BIT(hspi->ErrorCode, HAL_SPI_ERROR_FLAG); break; } } while((hspi->Instance->SR & SPI_FLAG_TXE) == RESET); } /* Abort the SPI DMA Rx channel : use blocking DMA Abort API (no callback) */ if(hspi->hdmarx != NULL) { /* Set the SPI DMA Abort callback : will lead to call HAL_SPI_AbortCpltCallback() at end of DMA abort procedure */ hspi->hdmarx->XferAbortCallback = NULL; /* Abort DMA Rx Handle linked to SPI Peripheral */ HAL_DMA_Abort(hspi->hdmarx); /* Disable peripheral */ __HAL_SPI_DISABLE(hspi); /* Disable Rx DMA Request */ CLEAR_BIT(hspi->Instance->CR2, (SPI_CR2_RXDMAEN)); } #endif // XXX DMA } /* Reset Tx and Rx transfer counters */ hspi->RxXferCount = 0U; hspi->TxXferCount = 0U; /* Reset errorCode */ hspi->ErrorCode = HAL_SPI_ERROR_NONE; /* Clear the Error flags in the SR register */ __HAL_SPI_CLEAR_OVRFLAG(hspi); __HAL_SPI_CLEAR_FREFLAG(hspi); /* Restore hspi->state to ready */ hspi->State = HAL_SPI_STATE_READY; return HAL_OK; } /** * @brief Abort ongoing transfer (Interrupt mode). * @param hspi SPI handle. * @note This procedure could be used for aborting any ongoing transfer (Tx and Rx), * started in Interrupt or DMA mode. * This procedure performs following operations : * - Disable SPI Interrupts (depending of transfer direction) * - Disable the DMA transfer in the peripheral register (if enabled) * - Abort DMA transfer by calling HAL_DMA_Abort_IT (in case of transfer in DMA mode) * - Set handle State to READY * - At abort completion, call user abort complete callback * @note This procedure is executed in Interrupt mode, meaning that abort procedure could be * considered as completed only when user abort complete callback is executed (not when exiting function). * @note Once transfer is aborted, the __HAL_SPI_CLEAR_OVRFLAG() macro must be called in user application * before starting new SPI receive process. * @retval HAL status */ HAL_StatusTypeDef HAL_SPI_Abort_IT(SPI_HandleTypeDef *hspi) { uint32_t abortcplt; /* Change Rx and Tx Irq Handler to Disable TXEIE, RXNEIE and ERRIE interrupts */ if(HAL_IS_BIT_SET(hspi->Instance->CR2, SPI_CR2_TXEIE)) { hspi->TxISR = SPI_AbortTx_ISR; } if(HAL_IS_BIT_SET(hspi->Instance->CR2, SPI_CR2_RXNEIE)) { hspi->RxISR = SPI_AbortRx_ISR; } /* Clear ERRIE interrupts in case of DMA Mode */ CLEAR_BIT(hspi->Instance->CR2, SPI_CR2_ERRIE); abortcplt = 1U; #if 0 // XXX DMA /* If DMA Tx and/or DMA Rx Handles are associated to SPI Handle, DMA Abort complete callbacks should be initialized before any call to DMA Abort functions */ /* DMA Tx Handle is valid */ if(hspi->hdmatx != NULL) { /* Set DMA Abort Complete callback if UART DMA Tx request if enabled. Otherwise, set it to NULL */ if(HAL_IS_BIT_SET(hspi->Instance->CR2, SPI_CR2_TXDMAEN)) { hspi->hdmatx->XferAbortCallback = SPI_DMATxAbortCallback; } else { hspi->hdmatx->XferAbortCallback = NULL; } } /* DMA Rx Handle is valid */ if(hspi->hdmarx != NULL) { /* Set DMA Abort Complete callback if UART DMA Rx request if enabled. Otherwise, set it to NULL */ if(HAL_IS_BIT_SET(hspi->Instance->CR2, SPI_CR2_RXDMAEN)) { hspi->hdmarx->XferAbortCallback = SPI_DMARxAbortCallback; } else { hspi->hdmarx->XferAbortCallback = NULL; } } /* Disable the SPI DMA Tx or the SPI Rx request if enabled */ if((HAL_IS_BIT_SET(hspi->Instance->CR2, SPI_CR2_TXDMAEN)) && (HAL_IS_BIT_SET(hspi->Instance->CR2, SPI_CR2_RXDMAEN))) { /* Abort the SPI DMA Tx channel */ if(hspi->hdmatx != NULL) { /* Abort DMA Tx Handle linked to SPI Peripheral */ if(HAL_DMA_Abort_IT(hspi->hdmatx) != HAL_OK) { hspi->hdmatx->XferAbortCallback = NULL; } else { abortcplt = 0U; } } /* Abort the SPI DMA Rx channel */ if(hspi->hdmarx != NULL) { /* Abort DMA Rx Handle linked to SPI Peripheral */ if(HAL_DMA_Abort_IT(hspi->hdmarx)!= HAL_OK) { hspi->hdmarx->XferAbortCallback = NULL; abortcplt = 1U; } else { abortcplt = 0U; } } } /* Disable the SPI DMA Tx or the SPI Rx request if enabled */ if (HAL_IS_BIT_SET(hspi->Instance->CR2, SPI_CR2_TXDMAEN)) { /* Abort the SPI DMA Tx channel */ if(hspi->hdmatx != NULL) { /* Abort DMA Tx Handle linked to SPI Peripheral */ if(HAL_DMA_Abort_IT(hspi->hdmatx) != HAL_OK) { hspi->hdmatx->XferAbortCallback = NULL; } else { abortcplt = 0U; } } } /* Disable the SPI DMA Tx or the SPI Rx request if enabled */ if (HAL_IS_BIT_SET(hspi->Instance->CR2, SPI_CR2_RXDMAEN)) { /* Abort the SPI DMA Rx channel */ if(hspi->hdmarx != NULL) { /* Abort DMA Rx Handle linked to SPI Peripheral */ if(HAL_DMA_Abort_IT(hspi->hdmarx)!= HAL_OK) { hspi->hdmarx->XferAbortCallback = NULL; } else { abortcplt = 0U; } } } #endif // XXX DMA if(abortcplt == 1U) { /* Reset Tx and Rx transfer counters */ hspi->RxXferCount = 0U; hspi->TxXferCount = 0U; /* Reset errorCode */ hspi->ErrorCode = HAL_SPI_ERROR_NONE; /* Clear the Error flags in the SR register */ __HAL_SPI_CLEAR_OVRFLAG(hspi); __HAL_SPI_CLEAR_FREFLAG(hspi); /* Restore hspi->State to Ready */ hspi->State = HAL_SPI_STATE_READY; /* As no DMA to be aborted, call directly user Abort complete callback */ HAL_SPI_AbortCpltCallback(hspi); } return HAL_OK; } #if 0 // XXX DMA /** * @brief Pause the DMA Transfer. * @param hspi: pointer to a SPI_HandleTypeDef structure that contains * the configuration information for the specified SPI module. * @retval HAL status */ HAL_StatusTypeDef HAL_SPI_DMAPause(SPI_HandleTypeDef *hspi) { /* Process Locked */ __HAL_LOCK(hspi); /* Disable the SPI DMA Tx & Rx requests */ CLEAR_BIT(hspi->Instance->CR2, SPI_CR2_TXDMAEN | SPI_CR2_RXDMAEN); /* Process Unlocked */ __HAL_UNLOCK(hspi); return HAL_OK; } /** * @brief Resume the DMA Transfer. * @param hspi: pointer to a SPI_HandleTypeDef structure that contains * the configuration information for the specified SPI module. * @retval HAL status */ HAL_StatusTypeDef HAL_SPI_DMAResume(SPI_HandleTypeDef *hspi) { /* Process Locked */ __HAL_LOCK(hspi); /* Enable the SPI DMA Tx & Rx requests */ SET_BIT(hspi->Instance->CR2, SPI_CR2_TXDMAEN | SPI_CR2_RXDMAEN); /* Process Unlocked */ __HAL_UNLOCK(hspi); return HAL_OK; } /** * @brief Stop the DMA Transfer. * @param hspi: pointer to a SPI_HandleTypeDef structure that contains * the configuration information for the specified SPI module. * @retval HAL status */ HAL_StatusTypeDef HAL_SPI_DMAStop(SPI_HandleTypeDef *hspi) { /* The Lock is not implemented on this API to allow the user application to call the HAL SPI API under callbacks HAL_SPI_TxCpltCallback() or HAL_SPI_RxCpltCallback() or HAL_SPI_TxRxCpltCallback(): when calling HAL_DMA_Abort() API the DMA TX/RX Transfer complete interrupt is generated and the correspond call back is executed HAL_SPI_TxCpltCallback() or HAL_SPI_RxCpltCallback() or HAL_SPI_TxRxCpltCallback() */ /* Abort the SPI DMA tx Stream */ if(hspi->hdmatx != NULL) { HAL_DMA_Abort(hspi->hdmatx); } /* Abort the SPI DMA rx Stream */ if(hspi->hdmarx != NULL) { HAL_DMA_Abort(hspi->hdmarx); } /* Disable the SPI DMA Tx & Rx requests */ CLEAR_BIT(hspi->Instance->CR2, SPI_CR2_TXDMAEN | SPI_CR2_RXDMAEN); hspi->State = HAL_SPI_STATE_READY; return HAL_OK; } #endif // XXX DMA /** * @brief Handle SPI interrupt request. * @param hspi: pointer to a SPI_HandleTypeDef structure that contains * the configuration information for the specified SPI module. * @retval None */ void HAL_SPI_IRQHandler(SPI_HandleTypeDef *hspi) { uint32_t itsource = hspi->Instance->CR2; uint32_t itflag = hspi->Instance->SR; /* SPI in mode Receiver ----------------------------------------------------*/ if(((itflag & SPI_FLAG_OVR) == RESET) && ((itflag & SPI_FLAG_RXNE) != RESET) && ((itsource & SPI_IT_RXNE) != RESET)) { hspi->RxISR(hspi); return; } /* SPI in mode Transmitter -------------------------------------------------*/ if(((itflag & SPI_FLAG_TXE) != RESET) && ((itsource & SPI_IT_TXE) != RESET)) { hspi->TxISR(hspi); return; } /* SPI in Error Treatment --------------------------------------------------*/ if(((itflag & (SPI_FLAG_MODF | SPI_FLAG_OVR | SPI_FLAG_FRE)) != RESET) && ((itsource & SPI_IT_ERR) != RESET)) { /* SPI Overrun error interrupt occurred ----------------------------------*/ if((itflag & SPI_FLAG_OVR) != RESET) { if(hspi->State != HAL_SPI_STATE_BUSY_TX) { SET_BIT(hspi->ErrorCode, HAL_SPI_ERROR_OVR); __HAL_SPI_CLEAR_OVRFLAG(hspi); } else { __HAL_SPI_CLEAR_OVRFLAG(hspi); return; } } /* SPI Mode Fault error interrupt occurred -------------------------------*/ if((itflag & SPI_FLAG_MODF) != RESET) { SET_BIT(hspi->ErrorCode, HAL_SPI_ERROR_MODF); __HAL_SPI_CLEAR_MODFFLAG(hspi); } /* SPI Frame error interrupt occurred ------------------------------------*/ if((itflag & SPI_FLAG_FRE) != RESET) { SET_BIT(hspi->ErrorCode, HAL_SPI_ERROR_FRE); __HAL_SPI_CLEAR_FREFLAG(hspi); } if(hspi->ErrorCode != HAL_SPI_ERROR_NONE) { /* Disable all interrupts */ __HAL_SPI_DISABLE_IT(hspi, SPI_IT_RXNE | SPI_IT_TXE | SPI_IT_ERR); hspi->State = HAL_SPI_STATE_READY; /* Disable the SPI DMA requests if enabled */ if ((HAL_IS_BIT_SET(itsource, SPI_CR2_TXDMAEN))||(HAL_IS_BIT_SET(itsource, SPI_CR2_RXDMAEN))) { #if 0 // XXX DMA CLEAR_BIT(hspi->Instance->CR2, (SPI_CR2_TXDMAEN | SPI_CR2_RXDMAEN)); /* Abort the SPI DMA Rx channel */ if(hspi->hdmarx != NULL) { /* Set the SPI DMA Abort callback : will lead to call HAL_SPI_ErrorCallback() at end of DMA abort procedure */ hspi->hdmarx->XferAbortCallback = SPI_DMAAbortOnError; HAL_DMA_Abort_IT(hspi->hdmarx); } /* Abort the SPI DMA Tx channel */ if(hspi->hdmatx != NULL) { /* Set the SPI DMA Abort callback : will lead to call HAL_SPI_ErrorCallback() at end of DMA abort procedure */ hspi->hdmatx->XferAbortCallback = SPI_DMAAbortOnError; HAL_DMA_Abort_IT(hspi->hdmatx); } #endif // XXX DMA } else { /* Call user error callback */ HAL_SPI_ErrorCallback(hspi); } } return; } } /** * @brief Tx Transfer completed callback. * @param hspi: pointer to a SPI_HandleTypeDef structure that contains * the configuration information for SPI module. * @retval None */ __weak void HAL_SPI_TxCpltCallback(SPI_HandleTypeDef *hspi) { /* Prevent unused argument(s) compilation warning */ UNUSED(hspi); /* NOTE : This function should not be modified, when the callback is needed, the HAL_SPI_TxCpltCallback should be implemented in the user file */ } /** * @brief Rx Transfer completed callback. * @param hspi: pointer to a SPI_HandleTypeDef structure that contains * the configuration information for SPI module. * @retval None */ __weak void HAL_SPI_RxCpltCallback(SPI_HandleTypeDef *hspi) { /* Prevent unused argument(s) compilation warning */ UNUSED(hspi); /* NOTE : This function should not be modified, when the callback is needed, the HAL_SPI_RxCpltCallback should be implemented in the user file */ } /** * @brief Tx and Rx Transfer completed callback. * @param hspi: pointer to a SPI_HandleTypeDef structure that contains * the configuration information for SPI module. * @retval None */ __weak void HAL_SPI_TxRxCpltCallback(SPI_HandleTypeDef *hspi) { /* Prevent unused argument(s) compilation warning */ UNUSED(hspi); /* NOTE : This function should not be modified, when the callback is needed, the HAL_SPI_TxRxCpltCallback should be implemented in the user file */ } /** * @brief Tx Half Transfer completed callback. * @param hspi: pointer to a SPI_HandleTypeDef structure that contains * the configuration information for SPI module. * @retval None */ __weak void HAL_SPI_TxHalfCpltCallback(SPI_HandleTypeDef *hspi) { /* Prevent unused argument(s) compilation warning */ UNUSED(hspi); /* NOTE : This function should not be modified, when the callback is needed, the HAL_SPI_TxHalfCpltCallback should be implemented in the user file */ } /** * @brief Rx Half Transfer completed callback. * @param hspi: pointer to a SPI_HandleTypeDef structure that contains * the configuration information for SPI module. * @retval None */ __weak void HAL_SPI_RxHalfCpltCallback(SPI_HandleTypeDef *hspi) { /* Prevent unused argument(s) compilation warning */ UNUSED(hspi); /* NOTE : This function should not be modified, when the callback is needed, the HAL_SPI_RxHalfCpltCallback() should be implemented in the user file */ } /** * @brief Tx and Rx Half Transfer callback. * @param hspi: pointer to a SPI_HandleTypeDef structure that contains * the configuration information for SPI module. * @retval None */ __weak void HAL_SPI_TxRxHalfCpltCallback(SPI_HandleTypeDef *hspi) { /* Prevent unused argument(s) compilation warning */ UNUSED(hspi); /* NOTE : This function should not be modified, when the callback is needed, the HAL_SPI_TxRxHalfCpltCallback() should be implemented in the user file */ } /** * @brief SPI error callback. * @param hspi: pointer to a SPI_HandleTypeDef structure that contains * the configuration information for SPI module. * @retval None */ __weak void HAL_SPI_ErrorCallback(SPI_HandleTypeDef *hspi) { /* Prevent unused argument(s) compilation warning */ UNUSED(hspi); /* NOTE : This function should not be modified, when the callback is needed, the HAL_SPI_ErrorCallback should be implemented in the user file */ /* NOTE : The ErrorCode parameter in the hspi handle is updated by the SPI processes and user can use HAL_SPI_GetError() API to check the latest error occurred */ } /** * @brief SPI Abort Complete callback. * @param hspi SPI handle. * @retval None */ __weak void HAL_SPI_AbortCpltCallback(SPI_HandleTypeDef *hspi) { /* Prevent unused argument(s) compilation warning */ UNUSED(hspi); /* NOTE : This function should not be modified, when the callback is needed, the HAL_SPI_AbortCpltCallback can be implemented in the user file. */ } /** * @} */ /** @defgroup SPI_Exported_Functions_Group3 Peripheral State and Errors functions * @brief SPI control functions * @verbatim =============================================================================== ##### Peripheral State and Errors functions ##### =============================================================================== [..] This subsection provides a set of functions allowing to control the SPI. (+) HAL_SPI_GetState() API can be helpful to check in run-time the state of the SPI peripheral (+) HAL_SPI_GetError() check in run-time Errors occurring during communication @endverbatim * @{ */ /** * @brief Return the SPI handle state. * @param hspi: pointer to a SPI_HandleTypeDef structure that contains * the configuration information for SPI module. * @retval SPI state */ HAL_SPI_StateTypeDef HAL_SPI_GetState(SPI_HandleTypeDef *hspi) { /* Return SPI handle state */ return hspi->State; } /** * @brief Return the SPI error code. * @param hspi: pointer to a SPI_HandleTypeDef structure that contains * the configuration information for SPI module. * @retval SPI error code in bitmap format */ uint32_t HAL_SPI_GetError(SPI_HandleTypeDef *hspi) { /* Return SPI ErrorCode */ return hspi->ErrorCode; } /** * @} */ /** * @} */ /** @addtogroup SPI_Private_Functions * @brief Private functions * @{ */ #if 0 // XXX DMA /** * @brief DMA SPI transmit process complete callback. * @param hdma: pointer to a DMA_HandleTypeDef structure that contains * the configuration information for the specified DMA module. * @retval None */ static void SPI_DMATransmitCplt(DMA_HandleTypeDef *hdma) { SPI_HandleTypeDef* hspi = ( SPI_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent; uint32_t tickstart = 0U; /* Init tickstart for timeout managment*/ tickstart = HAL_GetTick(); /* DMA Normal Mode */ if((hdma->Instance->CR & DMA_SxCR_CIRC) == 0U) { /* Disable Tx DMA Request */ CLEAR_BIT(hspi->Instance->CR2, SPI_CR2_TXDMAEN); /* Check the end of the transaction */ if(SPI_CheckFlag_BSY(hspi, SPI_DEFAULT_TIMEOUT, tickstart) != HAL_OK) { SET_BIT(hspi->ErrorCode, HAL_SPI_ERROR_FLAG); } /* Clear overrun flag in 2 Lines communication mode because received data is not read */ if(hspi->Init.Direction == SPI_DIRECTION_2LINES) { __HAL_SPI_CLEAR_OVRFLAG(hspi); } hspi->TxXferCount = 0U; hspi->State = HAL_SPI_STATE_READY; if(hspi->ErrorCode != HAL_SPI_ERROR_NONE) { HAL_SPI_ErrorCallback(hspi); return; } } HAL_SPI_TxCpltCallback(hspi); } /** * @brief DMA SPI receive process complete callback. * @param hdma: pointer to a DMA_HandleTypeDef structure that contains * the configuration information for the specified DMA module. * @retval None */ static void SPI_DMAReceiveCplt(DMA_HandleTypeDef *hdma) { SPI_HandleTypeDef* hspi = ( SPI_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent; #if (USE_SPI_CRC != 0U) uint32_t tickstart = 0U; __IO uint16_t tmpreg = 0U; /* Init tickstart for timeout management*/ tickstart = HAL_GetTick(); #endif /* USE_SPI_CRC */ if((hdma->Instance->CR & DMA_SxCR_CIRC) == 0U) { #if (USE_SPI_CRC != 0U) /* CRC handling */ if(hspi->Init.CRCCalculation == SPI_CRCCALCULATION_ENABLE) { /* Wait until RXNE flag */ if(SPI_WaitFlagStateUntilTimeout(hspi, SPI_FLAG_RXNE, SPI_FLAG_RXNE, SPI_DEFAULT_TIMEOUT, tickstart) != HAL_OK) { /* Error on the CRC reception */ SET_BIT(hspi->ErrorCode, HAL_SPI_ERROR_CRC); } /* Read CRC */ tmpreg = hspi->Instance->DR; /* To avoid GCC warning */ UNUSED(tmpreg); } #endif /* USE_SPI_CRC */ /* Disable Rx/Tx DMA Request (done by default to handle the case master rx direction 2 lines) */ CLEAR_BIT(hspi->Instance->CR2, SPI_CR2_TXDMAEN | SPI_CR2_RXDMAEN); /* Check the end of the transaction */ if((hspi->Init.Mode == SPI_MODE_MASTER)&&((hspi->Init.Direction == SPI_DIRECTION_1LINE)||(hspi->Init.Direction == SPI_DIRECTION_2LINES_RXONLY))) { /* Disable SPI peripheral */ __HAL_SPI_DISABLE(hspi); } hspi->RxXferCount = 0U; hspi->State = HAL_SPI_STATE_READY; #if (USE_SPI_CRC != 0U) /* Check if CRC error occurred */ if(__HAL_SPI_GET_FLAG(hspi, SPI_FLAG_CRCERR)) { SET_BIT(hspi->ErrorCode, HAL_SPI_ERROR_CRC); __HAL_SPI_CLEAR_CRCERRFLAG(hspi); } #endif /* USE_SPI_CRC */ if(hspi->ErrorCode != HAL_SPI_ERROR_NONE) { HAL_SPI_ErrorCallback(hspi); return; } } HAL_SPI_RxCpltCallback(hspi); } /** * @brief DMA SPI transmit receive process complete callback. * @param hdma: pointer to a DMA_HandleTypeDef structure that contains * the configuration information for the specified DMA module. * @retval None */ static void SPI_DMATransmitReceiveCplt(DMA_HandleTypeDef *hdma) { SPI_HandleTypeDef* hspi = ( SPI_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent; uint32_t tickstart = 0U; #if (USE_SPI_CRC != 0U) __IO int16_t tmpreg = 0U; #endif /* USE_SPI_CRC */ /* Init tickstart for timeout management*/ tickstart = HAL_GetTick(); if((hdma->Instance->CR & DMA_SxCR_CIRC) == 0U) { #if (USE_SPI_CRC != 0U) /* CRC handling */ if(hspi->Init.CRCCalculation == SPI_CRCCALCULATION_ENABLE) { /* Wait the CRC data */ if(SPI_WaitFlagStateUntilTimeout(hspi, SPI_FLAG_RXNE, SET, SPI_DEFAULT_TIMEOUT, tickstart) != HAL_OK) { SET_BIT(hspi->ErrorCode, HAL_SPI_ERROR_CRC); } /* Read CRC to Flush DR and RXNE flag */ tmpreg = hspi->Instance->DR; /* To avoid GCC warning */ UNUSED(tmpreg); } #endif /* USE_SPI_CRC */ /* Check the end of the transaction */ if(SPI_CheckFlag_BSY(hspi, SPI_DEFAULT_TIMEOUT, tickstart) != HAL_OK) { SET_BIT(hspi->ErrorCode, HAL_SPI_ERROR_FLAG); } /* Disable Rx/Tx DMA Request */ CLEAR_BIT(hspi->Instance->CR2, SPI_CR2_TXDMAEN | SPI_CR2_RXDMAEN); hspi->TxXferCount = 0U; hspi->RxXferCount = 0U; hspi->State = HAL_SPI_STATE_READY; #if (USE_SPI_CRC != 0U) /* Check if CRC error occurred */ if(__HAL_SPI_GET_FLAG(hspi, SPI_FLAG_CRCERR)) { SET_BIT(hspi->ErrorCode, HAL_SPI_ERROR_CRC); __HAL_SPI_CLEAR_CRCERRFLAG(hspi); } #endif /* USE_SPI_CRC */ if(hspi->ErrorCode != HAL_SPI_ERROR_NONE) { HAL_SPI_ErrorCallback(hspi); return; } } HAL_SPI_TxRxCpltCallback(hspi); } /** * @brief DMA SPI half transmit process complete callback. * @param hdma: pointer to a DMA_HandleTypeDef structure that contains * the configuration information for the specified DMA module. * @retval None */ static void SPI_DMAHalfTransmitCplt(DMA_HandleTypeDef *hdma) { SPI_HandleTypeDef* hspi = ( SPI_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent; HAL_SPI_TxHalfCpltCallback(hspi); } /** * @brief DMA SPI half receive process complete callback * @param hdma: pointer to a DMA_HandleTypeDef structure that contains * the configuration information for the specified DMA module. * @retval None */ static void SPI_DMAHalfReceiveCplt(DMA_HandleTypeDef *hdma) { SPI_HandleTypeDef* hspi = ( SPI_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent; HAL_SPI_RxHalfCpltCallback(hspi); } /** * @brief DMA SPI half transmit receive process complete callback. * @param hdma: pointer to a DMA_HandleTypeDef structure that contains * the configuration information for the specified DMA module. * @retval None */ static void SPI_DMAHalfTransmitReceiveCplt(DMA_HandleTypeDef *hdma) { SPI_HandleTypeDef* hspi = ( SPI_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent; HAL_SPI_TxRxHalfCpltCallback(hspi); } /** * @brief DMA SPI communication error callback. * @param hdma: pointer to a DMA_HandleTypeDef structure that contains * the configuration information for the specified DMA module. * @retval None */ static void SPI_DMAError(DMA_HandleTypeDef *hdma) { SPI_HandleTypeDef* hspi = (SPI_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent; /* Stop the disable DMA transfer on SPI side */ CLEAR_BIT(hspi->Instance->CR2, SPI_CR2_TXDMAEN | SPI_CR2_RXDMAEN); SET_BIT(hspi->ErrorCode, HAL_SPI_ERROR_DMA); hspi->State = HAL_SPI_STATE_READY; HAL_SPI_ErrorCallback(hspi); } /** * @brief DMA SPI communication abort callback, when initiated by HAL services on Error * (To be called at end of DMA Abort procedure following error occurrence). * @param hdma DMA handle. * @retval None */ static void SPI_DMAAbortOnError(DMA_HandleTypeDef *hdma) { SPI_HandleTypeDef* hspi = ( SPI_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent; hspi->RxXferCount = 0U; hspi->TxXferCount = 0U; HAL_SPI_ErrorCallback(hspi); } /** * @brief DMA SPI Tx communication abort callback, when initiated by user * (To be called at end of DMA Tx Abort procedure following user abort request). * @note When this callback is executed, User Abort complete call back is called only if no * Abort still ongoing for Rx DMA Handle. * @param hdma DMA handle. * @retval None */ static void SPI_DMATxAbortCallback(DMA_HandleTypeDef *hdma) { __IO uint32_t count = SPI_DEFAULT_TIMEOUT * (SystemCoreClock / 24U / 1000U); SPI_HandleTypeDef* hspi = ( SPI_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent; hspi->hdmatx->XferAbortCallback = NULL; /* Disable Tx DMA Request */ CLEAR_BIT(hspi->Instance->CR2, SPI_CR2_TXDMAEN ); /* Wait until TXE flag is set */ do { if(count-- == 0U) { SET_BIT(hspi->ErrorCode, HAL_SPI_ERROR_FLAG); break; } } while((hspi->Instance->SR & SPI_FLAG_TXE) == RESET); /* Check if an Abort process is still ongoing */ if(hspi->hdmarx != NULL) { if(hspi->hdmarx->XferAbortCallback != NULL) { return; } } /* No Abort process still ongoing : All DMA channels are aborted, call user Abort Complete callback */ hspi->RxXferCount = 0U; hspi->TxXferCount = 0U; /* Reset errorCode */ hspi->ErrorCode = HAL_SPI_ERROR_NONE; /* Clear the Error flags in the SR register */ __HAL_SPI_CLEAR_FREFLAG(hspi); /* Restore hspi->State to Ready */ hspi->State = HAL_SPI_STATE_READY; /* Call user Abort complete callback */ HAL_SPI_AbortCpltCallback(hspi); } /** * @brief DMA SPI Rx communication abort callback, when initiated by user * (To be called at end of DMA Rx Abort procedure following user abort request). * @note When this callback is executed, User Abort complete call back is called only if no * Abort still ongoing for Tx DMA Handle. * @param hdma DMA handle. * @retval None */ static void SPI_DMARxAbortCallback(DMA_HandleTypeDef *hdma) { SPI_HandleTypeDef* hspi = ( SPI_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent; /* Disable SPI Peripheral */ __HAL_SPI_DISABLE(hspi); hspi->hdmarx->XferAbortCallback = NULL; /* Disable Rx DMA Request */ CLEAR_BIT(hspi->Instance->CR2, SPI_CR2_RXDMAEN); /* Check if an Abort process is still ongoing */ if(hspi->hdmatx != NULL) { if(hspi->hdmatx->XferAbortCallback != NULL) { return; } } /* No Abort process still ongoing : All DMA channels are aborted, call user Abort Complete callback */ hspi->RxXferCount = 0U; hspi->TxXferCount = 0U; /* Reset errorCode */ hspi->ErrorCode = HAL_SPI_ERROR_NONE; /* Clear the Error flags in the SR register */ __HAL_SPI_CLEAR_OVRFLAG(hspi); __HAL_SPI_CLEAR_FREFLAG(hspi); /* Restore hspi->State to Ready */ hspi->State = HAL_SPI_STATE_READY; /* Call user Abort complete callback */ HAL_SPI_AbortCpltCallback(hspi); } #endif // XXX DMA /** * @brief Rx 8-bit handler for Transmit and Receive in Interrupt mode. * @param hspi: pointer to a SPI_HandleTypeDef structure that contains * the configuration information for SPI module. * @retval None */ static void SPI_2linesRxISR_8BIT(struct __SPI_HandleTypeDef *hspi) { /* Receive data in 8bit mode */ *hspi->pRxBuffPtr++ = *((__IO uint8_t *)&hspi->Instance->DR); hspi->RxXferCount--; /* check end of the reception */ if(hspi->RxXferCount == 0U) { #if (USE_SPI_CRC != 0U) if(hspi->Init.CRCCalculation == SPI_CRCCALCULATION_ENABLE) { hspi->RxISR = SPI_2linesRxISR_8BITCRC; return; } #endif /* USE_SPI_CRC */ /* Disable RXNE interrupt */ __HAL_SPI_DISABLE_IT(hspi, (SPI_IT_RXNE | SPI_IT_ERR)); if(hspi->TxXferCount == 0U) { SPI_CloseRxTx_ISR(hspi); } } } #if (USE_SPI_CRC != 0U) /** * @brief Rx 8-bit handler for Transmit and Receive in Interrupt mode. * @param hspi: pointer to a SPI_HandleTypeDef structure that contains * the configuration information for SPI module. * @retval None */ static void SPI_2linesRxISR_8BITCRC(struct __SPI_HandleTypeDef *hspi) { __IO uint8_t tmpreg = 0U; /* Read data register to flush CRC */ tmpreg = *((__IO uint8_t *)&hspi->Instance->DR); /* To avoid GCC warning */ UNUSED(tmpreg); /* Disable RXNE interrupt */ __HAL_SPI_DISABLE_IT(hspi, (SPI_IT_RXNE | SPI_IT_ERR)); if(hspi->TxXferCount == 0U) { SPI_CloseRxTx_ISR(hspi); } } #endif /* USE_SPI_CRC */ /** * @brief Tx 8-bit handler for Transmit and Receive in Interrupt mode. * @param hspi: pointer to a SPI_HandleTypeDef structure that contains * the configuration information for SPI module. * @retval None */ static void SPI_2linesTxISR_8BIT(struct __SPI_HandleTypeDef *hspi) { *(__IO uint8_t *)&hspi->Instance->DR = (*hspi->pTxBuffPtr++); hspi->TxXferCount--; /* check the end of the transmission */ if(hspi->TxXferCount == 0U) { #if (USE_SPI_CRC != 0U) if(hspi->Init.CRCCalculation == SPI_CRCCALCULATION_ENABLE) { SET_BIT(hspi->Instance->CR1, SPI_CR1_CRCNEXT); __HAL_SPI_DISABLE_IT(hspi, SPI_IT_TXE); return; } #endif /* USE_SPI_CRC */ /* Disable TXE interrupt */ __HAL_SPI_DISABLE_IT(hspi, SPI_IT_TXE); if(hspi->RxXferCount == 0U) { SPI_CloseRxTx_ISR(hspi); } } } /** * @brief Rx 16-bit handler for Transmit and Receive in Interrupt mode. * @param hspi: pointer to a SPI_HandleTypeDef structure that contains * the configuration information for SPI module. * @retval None */ static void SPI_2linesRxISR_16BIT(struct __SPI_HandleTypeDef *hspi) { /* Receive data in 16 Bit mode */ *((uint16_t*)hspi->pRxBuffPtr) = hspi->Instance->DR; hspi->pRxBuffPtr += sizeof(uint16_t); hspi->RxXferCount--; if(hspi->RxXferCount == 0U) { #if (USE_SPI_CRC != 0U) if(hspi->Init.CRCCalculation == SPI_CRCCALCULATION_ENABLE) { hspi->RxISR = SPI_2linesRxISR_16BITCRC; return; } #endif /* USE_SPI_CRC */ /* Disable RXNE interrupt */ __HAL_SPI_DISABLE_IT(hspi, SPI_IT_RXNE); if(hspi->TxXferCount == 0U) { SPI_CloseRxTx_ISR(hspi); } } } #if (USE_SPI_CRC != 0U) /** * @brief Manage the CRC 16-bit receive for Transmit and Receive in Interrupt mode. * @param hspi: pointer to a SPI_HandleTypeDef structure that contains * the configuration information for SPI module. * @retval None */ static void SPI_2linesRxISR_16BITCRC(struct __SPI_HandleTypeDef *hspi) { /* Receive data in 16 Bit mode */ __IO uint16_t tmpreg = 0U; /* Read data register to flush CRC */ tmpreg = hspi->Instance->DR; /* To avoid GCC warning */ UNUSED(tmpreg); /* Disable RXNE interrupt */ __HAL_SPI_DISABLE_IT(hspi, SPI_IT_RXNE); SPI_CloseRxTx_ISR(hspi); } #endif /* USE_SPI_CRC */ /** * @brief Tx 16-bit handler for Transmit and Receive in Interrupt mode. * @param hspi: pointer to a SPI_HandleTypeDef structure that contains * the configuration information for SPI module. * @retval None */ static void SPI_2linesTxISR_16BIT(struct __SPI_HandleTypeDef *hspi) { /* Transmit data in 16 Bit mode */ hspi->Instance->DR = *((uint16_t *)hspi->pTxBuffPtr); hspi->pTxBuffPtr += sizeof(uint16_t); hspi->TxXferCount--; /* Enable CRC Transmission */ if(hspi->TxXferCount == 0U) { #if (USE_SPI_CRC != 0U) if(hspi->Init.CRCCalculation == SPI_CRCCALCULATION_ENABLE) { SET_BIT(hspi->Instance->CR1, SPI_CR1_CRCNEXT); __HAL_SPI_DISABLE_IT(hspi, SPI_IT_TXE); return; } #endif /* USE_SPI_CRC */ /* Disable TXE interrupt */ __HAL_SPI_DISABLE_IT(hspi, SPI_IT_TXE); if(hspi->RxXferCount == 0U) { SPI_CloseRxTx_ISR(hspi); } } } #if (USE_SPI_CRC != 0U) /** * @brief Manage the CRC 8-bit receive in Interrupt context. * @param hspi: pointer to a SPI_HandleTypeDef structure that contains * the configuration information for SPI module. * @retval None */ static void SPI_RxISR_8BITCRC(struct __SPI_HandleTypeDef *hspi) { __IO uint8_t tmpreg = 0U; /* Read data register to flush CRC */ tmpreg = *((__IO uint8_t*)&hspi->Instance->DR); /* To avoid GCC warning */ UNUSED(tmpreg); SPI_CloseRx_ISR(hspi); } #endif /* USE_SPI_CRC */ /** * @brief Manage the receive 8-bit in Interrupt context. * @param hspi: pointer to a SPI_HandleTypeDef structure that contains * the configuration information for SPI module. * @retval None */ static void SPI_RxISR_8BIT(struct __SPI_HandleTypeDef *hspi) { *hspi->pRxBuffPtr++ = (*(__IO uint8_t *)&hspi->Instance->DR); hspi->RxXferCount--; #if (USE_SPI_CRC != 0U) /* Enable CRC Transmission */ if((hspi->RxXferCount == 1U) && (hspi->Init.CRCCalculation == SPI_CRCCALCULATION_ENABLE)) { SET_BIT(hspi->Instance->CR1, SPI_CR1_CRCNEXT); } #endif /* USE_SPI_CRC */ if(hspi->RxXferCount == 0U) { #if (USE_SPI_CRC != 0U) if(hspi->Init.CRCCalculation == SPI_CRCCALCULATION_ENABLE) { hspi->RxISR = SPI_RxISR_8BITCRC; return; } #endif /* USE_SPI_CRC */ SPI_CloseRx_ISR(hspi); } } #if (USE_SPI_CRC != 0U) /** * @brief Manage the CRC 16-bit receive in Interrupt context. * @param hspi: pointer to a SPI_HandleTypeDef structure that contains * the configuration information for SPI module. * @retval None */ static void SPI_RxISR_16BITCRC(struct __SPI_HandleTypeDef *hspi) { __IO uint16_t tmpreg = 0U; /* Read data register to flush CRC */ tmpreg = hspi->Instance->DR; /* To avoid GCC warning */ UNUSED(tmpreg); /* Disable RXNE and ERR interrupt */ __HAL_SPI_DISABLE_IT(hspi, (SPI_IT_RXNE | SPI_IT_ERR)); SPI_CloseRx_ISR(hspi); } #endif /* USE_SPI_CRC */ /** * @brief Manage the 16-bit receive in Interrupt context. * @param hspi: pointer to a SPI_HandleTypeDef structure that contains * the configuration information for SPI module. * @retval None */ static void SPI_RxISR_16BIT(struct __SPI_HandleTypeDef *hspi) { *((uint16_t *)hspi->pRxBuffPtr) = hspi->Instance->DR; hspi->pRxBuffPtr += sizeof(uint16_t); hspi->RxXferCount--; #if (USE_SPI_CRC != 0U) /* Enable CRC Transmission */ if((hspi->RxXferCount == 1U) && (hspi->Init.CRCCalculation == SPI_CRCCALCULATION_ENABLE)) { SET_BIT(hspi->Instance->CR1, SPI_CR1_CRCNEXT); } #endif /* USE_SPI_CRC */ if(hspi->RxXferCount == 0U) { #if (USE_SPI_CRC != 0U) if(hspi->Init.CRCCalculation == SPI_CRCCALCULATION_ENABLE) { hspi->RxISR = SPI_RxISR_16BITCRC; return; } #endif /* USE_SPI_CRC */ SPI_CloseRx_ISR(hspi); } } /** * @brief Handle the data 8-bit transmit in Interrupt mode. * @param hspi: pointer to a SPI_HandleTypeDef structure that contains * the configuration information for SPI module. * @retval None */ static void SPI_TxISR_8BIT(struct __SPI_HandleTypeDef *hspi) { *(__IO uint8_t *)&hspi->Instance->DR = (*hspi->pTxBuffPtr++); hspi->TxXferCount--; if(hspi->TxXferCount == 0U) { #if (USE_SPI_CRC != 0U) if(hspi->Init.CRCCalculation == SPI_CRCCALCULATION_ENABLE) { /* Enable CRC Transmission */ SET_BIT(hspi->Instance->CR1, SPI_CR1_CRCNEXT); } #endif /* USE_SPI_CRC */ SPI_CloseTx_ISR(hspi); } } /** * @brief Handle the data 16-bit transmit in Interrupt mode. * @param hspi: pointer to a SPI_HandleTypeDef structure that contains * the configuration information for SPI module. * @retval None */ static void SPI_TxISR_16BIT(struct __SPI_HandleTypeDef *hspi) { /* Transmit data in 16 Bit mode */ hspi->Instance->DR = *((uint16_t *)hspi->pTxBuffPtr); hspi->pTxBuffPtr += sizeof(uint16_t); hspi->TxXferCount--; if(hspi->TxXferCount == 0U) { #if (USE_SPI_CRC != 0U) if(hspi->Init.CRCCalculation == SPI_CRCCALCULATION_ENABLE) { /* Enable CRC Transmission */ SET_BIT(hspi->Instance->CR1, SPI_CR1_CRCNEXT); } #endif /* USE_SPI_CRC */ SPI_CloseTx_ISR(hspi); } } /** * @brief Handle SPI Communication Timeout. * @param hspi: pointer to a SPI_HandleTypeDef structure that contains * the configuration information for SPI module. * @param Flag: SPI flag to check * @param State: flag state to check * @param Timeout: Timeout duration * @param Tickstart: tick start value * @retval HAL status */ static HAL_StatusTypeDef SPI_WaitFlagStateUntilTimeout(SPI_HandleTypeDef *hspi, uint32_t Flag, uint32_t State, uint32_t Timeout, uint32_t Tickstart) { while((((hspi->Instance->SR & Flag) == (Flag)) ? SET : RESET) != State) { if(Timeout != HAL_MAX_DELAY) { if((Timeout == 0U) || ((HAL_GetTick()-Tickstart) >= Timeout)) { /* Disable the SPI and reset the CRC: the CRC value should be cleared on both master and slave sides in order to resynchronize the master and slave for their respective CRC calculation */ /* Disable TXE, RXNE and ERR interrupts for the interrupt process */ __HAL_SPI_DISABLE_IT(hspi, (SPI_IT_TXE | SPI_IT_RXNE | SPI_IT_ERR)); if((hspi->Init.Mode == SPI_MODE_MASTER)&&((hspi->Init.Direction == SPI_DIRECTION_1LINE)||(hspi->Init.Direction == SPI_DIRECTION_2LINES_RXONLY))) { /* Disable SPI peripheral */ __HAL_SPI_DISABLE(hspi); } /* Reset CRC Calculation */ if(hspi->Init.CRCCalculation == SPI_CRCCALCULATION_ENABLE) { SPI_RESET_CRC(hspi); } hspi->State= HAL_SPI_STATE_READY; /* Process Unlocked */ __HAL_UNLOCK(hspi); return HAL_TIMEOUT; } } } return HAL_OK; } /** * @brief Handle to check BSY flag before start a new transaction. * @param hspi: pointer to a SPI_HandleTypeDef structure that contains * the configuration information for SPI module. * @param Timeout: Timeout duration * @param Tickstart: tick start value * @retval HAL status */ static HAL_StatusTypeDef SPI_CheckFlag_BSY(SPI_HandleTypeDef *hspi, uint32_t Timeout, uint32_t Tickstart) { /* Control the BSY flag */ if(SPI_WaitFlagStateUntilTimeout(hspi, SPI_FLAG_BSY, RESET, Timeout, Tickstart) != HAL_OK) { SET_BIT(hspi->ErrorCode, HAL_SPI_ERROR_FLAG); return HAL_TIMEOUT; } return HAL_OK; } /** * @brief Handle the end of the RXTX transaction. * @param hspi: pointer to a SPI_HandleTypeDef structure that contains * the configuration information for SPI module. * @retval None */ static void SPI_CloseRxTx_ISR(SPI_HandleTypeDef *hspi) { uint32_t tickstart = 0U; __IO uint32_t count = SPI_DEFAULT_TIMEOUT * (SystemCoreClock / 24U / 1000U); /* Init tickstart for timeout managment*/ tickstart = HAL_GetTick(); /* Disable ERR interrupt */ __HAL_SPI_DISABLE_IT(hspi, SPI_IT_ERR); /* Wait until TXE flag is set */ do { if(count-- == 0U) { SET_BIT(hspi->ErrorCode, HAL_SPI_ERROR_FLAG); break; } } while((hspi->Instance->SR & SPI_FLAG_TXE) == RESET); /* Check the end of the transaction */ if(SPI_CheckFlag_BSY(hspi, SPI_DEFAULT_TIMEOUT, tickstart)!=HAL_OK) { SET_BIT(hspi->ErrorCode, HAL_SPI_ERROR_FLAG); } /* Clear overrun flag in 2 Lines communication mode because received is not read */ if(hspi->Init.Direction == SPI_DIRECTION_2LINES) { __HAL_SPI_CLEAR_OVRFLAG(hspi); } #if (USE_SPI_CRC != 0U) /* Check if CRC error occurred */ if(__HAL_SPI_GET_FLAG(hspi, SPI_FLAG_CRCERR) != RESET) { hspi->State = HAL_SPI_STATE_READY; SET_BIT(hspi->ErrorCode, HAL_SPI_ERROR_CRC); __HAL_SPI_CLEAR_CRCERRFLAG(hspi); HAL_SPI_ErrorCallback(hspi); } else { #endif /* USE_SPI_CRC */ if(hspi->ErrorCode == HAL_SPI_ERROR_NONE) { if(hspi->State == HAL_SPI_STATE_BUSY_RX) { hspi->State = HAL_SPI_STATE_READY; HAL_SPI_RxCpltCallback(hspi); } else { hspi->State = HAL_SPI_STATE_READY; HAL_SPI_TxRxCpltCallback(hspi); } } else { hspi->State = HAL_SPI_STATE_READY; HAL_SPI_ErrorCallback(hspi); } #if (USE_SPI_CRC != 0U) } #endif /* USE_SPI_CRC */ } /** * @brief Handle the end of the RX transaction. * @param hspi: pointer to a SPI_HandleTypeDef structure that contains * the configuration information for SPI module. * @retval None */ static void SPI_CloseRx_ISR(SPI_HandleTypeDef *hspi) { /* Disable RXNE and ERR interrupt */ __HAL_SPI_DISABLE_IT(hspi, (SPI_IT_RXNE | SPI_IT_ERR)); /* Check the end of the transaction */ if((hspi->Init.Mode == SPI_MODE_MASTER)&&((hspi->Init.Direction == SPI_DIRECTION_1LINE)||(hspi->Init.Direction == SPI_DIRECTION_2LINES_RXONLY))) { /* Disable SPI peripheral */ __HAL_SPI_DISABLE(hspi); } /* Clear overrun flag in 2 Lines communication mode because received is not read */ if(hspi->Init.Direction == SPI_DIRECTION_2LINES) { __HAL_SPI_CLEAR_OVRFLAG(hspi); } hspi->State = HAL_SPI_STATE_READY; #if (USE_SPI_CRC != 0U) /* Check if CRC error occurred */ if(__HAL_SPI_GET_FLAG(hspi, SPI_FLAG_CRCERR) != RESET) { SET_BIT(hspi->ErrorCode, HAL_SPI_ERROR_CRC); __HAL_SPI_CLEAR_CRCERRFLAG(hspi); HAL_SPI_ErrorCallback(hspi); } else { #endif /* USE_SPI_CRC */ if(hspi->ErrorCode == HAL_SPI_ERROR_NONE) { HAL_SPI_RxCpltCallback(hspi); } else { HAL_SPI_ErrorCallback(hspi); } #if (USE_SPI_CRC != 0U) } #endif /* USE_SPI_CRC */ } /** * @brief Handle the end of the TX transaction. * @param hspi: pointer to a SPI_HandleTypeDef structure that contains * the configuration information for SPI module. * @retval None */ static void SPI_CloseTx_ISR(SPI_HandleTypeDef *hspi) { uint32_t tickstart = 0U; __IO uint32_t count = SPI_DEFAULT_TIMEOUT * (SystemCoreClock / 24U / 1000U); /* Init tickstart for timeout management*/ tickstart = HAL_GetTick(); /* Wait until TXE flag is set */ do { if(count-- == 0U) { SET_BIT(hspi->ErrorCode, HAL_SPI_ERROR_FLAG); break; } } while((hspi->Instance->SR & SPI_FLAG_TXE) == RESET); /* Disable TXE and ERR interrupt */ __HAL_SPI_DISABLE_IT(hspi, (SPI_IT_TXE | SPI_IT_ERR)); /* Check Busy flag */ if(SPI_CheckFlag_BSY(hspi, SPI_DEFAULT_TIMEOUT, tickstart) != HAL_OK) { SET_BIT(hspi->ErrorCode, HAL_SPI_ERROR_FLAG); } /* Clear overrun flag in 2 Lines communication mode because received is not read */ if(hspi->Init.Direction == SPI_DIRECTION_2LINES) { __HAL_SPI_CLEAR_OVRFLAG(hspi); } hspi->State = HAL_SPI_STATE_READY; if(hspi->ErrorCode != HAL_SPI_ERROR_NONE) { HAL_SPI_ErrorCallback(hspi); } else { HAL_SPI_TxCpltCallback(hspi); } } /** * @} */ /** * @brief Handle abort a Tx or Rx transaction. * @param hspi: pointer to a SPI_HandleTypeDef structure that contains * the configuration information for SPI module. * @retval None */ static void SPI_AbortRx_ISR(SPI_HandleTypeDef *hspi) { __IO uint32_t tmpreg = 0U; __IO uint32_t count = SPI_DEFAULT_TIMEOUT * (SystemCoreClock / 24U / 1000U); /* Wait until TXE flag is set */ do { if(count-- == 0U) { SET_BIT(hspi->ErrorCode, HAL_SPI_ERROR_FLAG); break; } } while((hspi->Instance->SR & SPI_FLAG_TXE) == RESET); /* Disable SPI Peripheral */ __HAL_SPI_DISABLE(hspi); /* Disable TXEIE, RXNEIE and ERRIE(mode fault event, overrun error, TI frame error) interrupts */ CLEAR_BIT(hspi->Instance->CR2, (SPI_CR2_TXEIE | SPI_CR2_RXNEIE | SPI_CR2_ERRIE)); /* Flush DR Register */ tmpreg = (*(__IO uint32_t *)&hspi->Instance->DR); /* To avoid GCC warning */ UNUSED(tmpreg); } /** * @brief Handle abort a Tx or Rx transaction. * @param hspi: pointer to a SPI_HandleTypeDef structure that contains * the configuration information for SPI module. * @retval None */ static void SPI_AbortTx_ISR(SPI_HandleTypeDef *hspi) { /* Disable TXEIE, RXNEIE and ERRIE(mode fault event, overrun error, TI frame error) interrupts */ CLEAR_BIT(hspi->Instance->CR2, (SPI_CR2_TXEIE | SPI_CR2_RXNEIE | SPI_CR2_ERRIE)); /* Disable SPI Peripheral */ __HAL_SPI_DISABLE(hspi); } /** * @} */ #endif /* HAL_SPI_MODULE_ENABLED */ /** * @} */ /** * @} */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ ================================================ FILE: sys/arch/stm32/hal/stm32f4xx_hal_spi.h ================================================ /** ****************************************************************************** * @file stm32f4xx_hal_spi.h * @author MCD Application Team * @version V1.7.1 * @date 14-April-2017 * @brief Header file of SPI HAL module. ****************************************************************************** * @attention * *

© COPYRIGHT(c) 2017 STMicroelectronics

* * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. Neither the name of STMicroelectronics nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __STM32F4xx_HAL_SPI_H #define __STM32F4xx_HAL_SPI_H #ifdef __cplusplus extern "C" { #endif /* Includes ------------------------------------------------------------------*/ #include "stm32f4xx_hal_def.h" /** @addtogroup STM32F4xx_HAL_Driver * @{ */ /** @addtogroup SPI * @{ */ /* Exported types ------------------------------------------------------------*/ /** @defgroup SPI_Exported_Types SPI Exported Types * @{ */ /** * @brief SPI Configuration Structure definition */ typedef struct { uint32_t Mode; /*!< Specifies the SPI operating mode. This parameter can be a value of @ref SPI_Mode */ uint32_t Direction; /*!< Specifies the SPI bidirectional mode state. This parameter can be a value of @ref SPI_Direction */ uint32_t DataSize; /*!< Specifies the SPI data size. This parameter can be a value of @ref SPI_Data_Size */ uint32_t CLKPolarity; /*!< Specifies the serial clock steady state. This parameter can be a value of @ref SPI_Clock_Polarity */ uint32_t CLKPhase; /*!< Specifies the clock active edge for the bit capture. This parameter can be a value of @ref SPI_Clock_Phase */ uint32_t NSS; /*!< Specifies whether the NSS signal is managed by hardware (NSS pin) or by software using the SSI bit. This parameter can be a value of @ref SPI_Slave_Select_management */ uint32_t BaudRatePrescaler; /*!< Specifies the Baud Rate prescaler value which will be used to configure the transmit and receive SCK clock. This parameter can be a value of @ref SPI_BaudRate_Prescaler @note The communication clock is derived from the master clock. The slave clock does not need to be set. */ uint32_t FirstBit; /*!< Specifies whether data transfers start from MSB or LSB bit. This parameter can be a value of @ref SPI_MSB_LSB_transmission */ uint32_t TIMode; /*!< Specifies if the TI mode is enabled or not. This parameter can be a value of @ref SPI_TI_mode */ uint32_t CRCCalculation; /*!< Specifies if the CRC calculation is enabled or not. This parameter can be a value of @ref SPI_CRC_Calculation */ uint32_t CRCPolynomial; /*!< Specifies the polynomial used for the CRC calculation. This parameter must be a number between Min_Data = 0 and Max_Data = 65535 */ }SPI_InitTypeDef; /** * @brief HAL SPI State structure definition */ typedef enum { HAL_SPI_STATE_RESET = 0x00U, /*!< Peripheral not Initialized */ HAL_SPI_STATE_READY = 0x01U, /*!< Peripheral Initialized and ready for use */ HAL_SPI_STATE_BUSY = 0x02U, /*!< an internal process is ongoing */ HAL_SPI_STATE_BUSY_TX = 0x03U, /*!< Data Transmission process is ongoing */ HAL_SPI_STATE_BUSY_RX = 0x04U, /*!< Data Reception process is ongoing */ HAL_SPI_STATE_BUSY_TX_RX = 0x05U, /*!< Data Transmission and Reception process is ongoing */ HAL_SPI_STATE_ERROR = 0x06U /*!< SPI error state */ }HAL_SPI_StateTypeDef; /** * @brief SPI handle Structure definition */ typedef struct __SPI_HandleTypeDef { SPI_TypeDef *Instance; /* SPI registers base address */ SPI_InitTypeDef Init; /* SPI communication parameters */ uint8_t *pTxBuffPtr; /* Pointer to SPI Tx transfer Buffer */ uint16_t TxXferSize; /* SPI Tx Transfer size */ __IO uint16_t TxXferCount; /* SPI Tx Transfer Counter */ uint8_t *pRxBuffPtr; /* Pointer to SPI Rx transfer Buffer */ uint16_t RxXferSize; /* SPI Rx Transfer size */ __IO uint16_t RxXferCount; /* SPI Rx Transfer Counter */ void (*RxISR)(struct __SPI_HandleTypeDef * hspi); /* function pointer on Rx ISR */ void (*TxISR)(struct __SPI_HandleTypeDef * hspi); /* function pointer on Tx ISR */ #if 0 // XXX DMA DMA_HandleTypeDef *hdmatx; /* SPI Tx DMA Handle parameters */ DMA_HandleTypeDef *hdmarx; /* SPI Rx DMA Handle parameters */ #endif // XXX DMA HAL_LockTypeDef Lock; /* Locking object */ __IO HAL_SPI_StateTypeDef State; /* SPI communication state */ __IO uint32_t ErrorCode; /* SPI Error code */ }SPI_HandleTypeDef; /** * @} */ /* Exported constants --------------------------------------------------------*/ /** @defgroup SPI_Exported_Constants SPI Exported Constants * @{ */ /** @defgroup SPI_Error_Code SPI Error Code * @{ */ #define HAL_SPI_ERROR_NONE 0x00000000U /*!< No error */ #define HAL_SPI_ERROR_MODF 0x00000001U /*!< MODF error */ #define HAL_SPI_ERROR_CRC 0x00000002U /*!< CRC error */ #define HAL_SPI_ERROR_OVR 0x00000004U /*!< OVR error */ #define HAL_SPI_ERROR_FRE 0x00000008U /*!< FRE error */ #define HAL_SPI_ERROR_DMA 0x00000010U /*!< DMA transfer error */ #define HAL_SPI_ERROR_FLAG 0x00000020U /*!< Flag: RXNE,TXE, BSY */ /** * @} */ /** @defgroup SPI_Mode SPI Mode * @{ */ #define SPI_MODE_SLAVE 0x00000000U #define SPI_MODE_MASTER (SPI_CR1_MSTR | SPI_CR1_SSI) /** * @} */ /** @defgroup SPI_Direction SPI Direction Mode * @{ */ #define SPI_DIRECTION_2LINES 0x00000000U #define SPI_DIRECTION_2LINES_RXONLY SPI_CR1_RXONLY #define SPI_DIRECTION_1LINE SPI_CR1_BIDIMODE /** * @} */ /** @defgroup SPI_Data_Size SPI Data Size * @{ */ #define SPI_DATASIZE_8BIT 0x00000000U #define SPI_DATASIZE_16BIT SPI_CR1_DFF /** * @} */ /** @defgroup SPI_Clock_Polarity SPI Clock Polarity * @{ */ #define SPI_POLARITY_LOW 0x00000000U #define SPI_POLARITY_HIGH SPI_CR1_CPOL /** * @} */ /** @defgroup SPI_Clock_Phase SPI Clock Phase * @{ */ #define SPI_PHASE_1EDGE 0x00000000U #define SPI_PHASE_2EDGE SPI_CR1_CPHA /** * @} */ /** @defgroup SPI_Slave_Select_management SPI Slave Select Management * @{ */ #define SPI_NSS_SOFT SPI_CR1_SSM #define SPI_NSS_HARD_INPUT 0x00000000U #define SPI_NSS_HARD_OUTPUT 0x00040000U /** * @} */ /** @defgroup SPI_BaudRate_Prescaler SPI BaudRate Prescaler * @{ */ #define SPI_BAUDRATEPRESCALER_2 0x00000000U #define SPI_BAUDRATEPRESCALER_4 0x00000008U #define SPI_BAUDRATEPRESCALER_8 0x00000010U #define SPI_BAUDRATEPRESCALER_16 0x00000018U #define SPI_BAUDRATEPRESCALER_32 0x00000020U #define SPI_BAUDRATEPRESCALER_64 0x00000028U #define SPI_BAUDRATEPRESCALER_128 0x00000030U #define SPI_BAUDRATEPRESCALER_256 0x00000038U /** * @} */ /** @defgroup SPI_MSB_LSB_transmission SPI MSB LSB Transmission * @{ */ #define SPI_FIRSTBIT_MSB 0x00000000U #define SPI_FIRSTBIT_LSB SPI_CR1_LSBFIRST /** * @} */ /** @defgroup SPI_TI_mode SPI TI Mode * @{ */ #define SPI_TIMODE_DISABLE 0x00000000U #define SPI_TIMODE_ENABLE SPI_CR2_FRF /** * @} */ /** @defgroup SPI_CRC_Calculation SPI CRC Calculation * @{ */ #define SPI_CRCCALCULATION_DISABLE 0x00000000U #define SPI_CRCCALCULATION_ENABLE SPI_CR1_CRCEN /** * @} */ /** @defgroup SPI_Interrupt_definition SPI Interrupt Definition * @{ */ #define SPI_IT_TXE SPI_CR2_TXEIE #define SPI_IT_RXNE SPI_CR2_RXNEIE #define SPI_IT_ERR SPI_CR2_ERRIE /** * @} */ /** @defgroup SPI_Flags_definition SPI Flags Definition * @{ */ #define SPI_FLAG_RXNE SPI_SR_RXNE /* SPI status flag: Rx buffer not empty flag */ #define SPI_FLAG_TXE SPI_SR_TXE /* SPI status flag: Tx buffer empty flag */ #define SPI_FLAG_BSY SPI_SR_BSY /* SPI status flag: Busy flag */ #define SPI_FLAG_CRCERR SPI_SR_CRCERR /* SPI Error flag: CRC error flag */ #define SPI_FLAG_MODF SPI_SR_MODF /* SPI Error flag: Mode fault flag */ #define SPI_FLAG_OVR SPI_SR_OVR /* SPI Error flag: Overrun flag */ #define SPI_FLAG_FRE SPI_SR_FRE /* SPI Error flag: TI mode frame format error flag */ /** * @} */ /** * @} */ /* Exported macro ------------------------------------------------------------*/ /** @defgroup SPI_Exported_Macros SPI Exported Macros * @{ */ /** @brief Reset SPI handle state. * @param __HANDLE__: specifies the SPI Handle. * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral. * @retval None */ #define __HAL_SPI_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_SPI_STATE_RESET) /** @brief Enable or disable the specified SPI interrupts. * @param __HANDLE__: specifies the SPI Handle. * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral. * @param __INTERRUPT__: specifies the interrupt source to enable or disable. * This parameter can be one of the following values: * @arg SPI_IT_TXE: Tx buffer empty interrupt enable * @arg SPI_IT_RXNE: RX buffer not empty interrupt enable * @arg SPI_IT_ERR: Error interrupt enable * @retval None */ #define __HAL_SPI_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR2 |= (__INTERRUPT__)) #define __HAL_SPI_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR2 &= (~(__INTERRUPT__))) /** @brief Check whether the specified SPI interrupt source is enabled or not. * @param __HANDLE__: specifies the SPI Handle. * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral. * @param __INTERRUPT__: specifies the SPI interrupt source to check. * This parameter can be one of the following values: * @arg SPI_IT_TXE: Tx buffer empty interrupt enable * @arg SPI_IT_RXNE: RX buffer not empty interrupt enable * @arg SPI_IT_ERR: Error interrupt enable * @retval The new state of __IT__ (TRUE or FALSE). */ #define __HAL_SPI_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((__HANDLE__)->Instance->CR2 & (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET) /** @brief Check whether the specified SPI flag is set or not. * @param __HANDLE__: specifies the SPI Handle. * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral. * @param __FLAG__: specifies the flag to check. * This parameter can be one of the following values: * @arg SPI_FLAG_RXNE: Receive buffer not empty flag * @arg SPI_FLAG_TXE: Transmit buffer empty flag * @arg SPI_FLAG_CRCERR: CRC error flag * @arg SPI_FLAG_MODF: Mode fault flag * @arg SPI_FLAG_OVR: Overrun flag * @arg SPI_FLAG_BSY: Busy flag * @arg SPI_FLAG_FRE: Frame format error flag * @retval The new state of __FLAG__ (TRUE or FALSE). */ #define __HAL_SPI_GET_FLAG(__HANDLE__, __FLAG__) ((((__HANDLE__)->Instance->SR) & (__FLAG__)) == (__FLAG__)) /** @brief Clear the SPI CRCERR pending flag. * @param __HANDLE__: specifies the SPI Handle. * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral. * @retval None */ #define __HAL_SPI_CLEAR_CRCERRFLAG(__HANDLE__) ((__HANDLE__)->Instance->SR = (uint16_t)(~SPI_FLAG_CRCERR)) /** @brief Clear the SPI MODF pending flag. * @param __HANDLE__: specifies the SPI Handle. * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral. * @retval None */ #define __HAL_SPI_CLEAR_MODFFLAG(__HANDLE__) \ do{ \ __IO uint32_t tmpreg_modf = 0x00U; \ tmpreg_modf = (__HANDLE__)->Instance->SR; \ (__HANDLE__)->Instance->CR1 &= (~SPI_CR1_SPE); \ UNUSED(tmpreg_modf); \ } while(0U) /** @brief Clear the SPI OVR pending flag. * @param __HANDLE__: specifies the SPI Handle. * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral. * @retval None */ #define __HAL_SPI_CLEAR_OVRFLAG(__HANDLE__) \ do{ \ __IO uint32_t tmpreg_ovr = 0x00U; \ tmpreg_ovr = (__HANDLE__)->Instance->DR; \ tmpreg_ovr = (__HANDLE__)->Instance->SR; \ UNUSED(tmpreg_ovr); \ } while(0U) /** @brief Clear the SPI FRE pending flag. * @param __HANDLE__: specifies the SPI Handle. * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral. * @retval None */ #define __HAL_SPI_CLEAR_FREFLAG(__HANDLE__) \ do{ \ __IO uint32_t tmpreg_fre = 0x00U; \ tmpreg_fre = (__HANDLE__)->Instance->SR; \ UNUSED(tmpreg_fre); \ }while(0U) /** @brief Enable the SPI peripheral. * @param __HANDLE__: specifies the SPI Handle. * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral. * @retval None */ #define __HAL_SPI_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 |= SPI_CR1_SPE) /** @brief Disable the SPI peripheral. * @param __HANDLE__: specifies the SPI Handle. * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral. * @retval None */ #define __HAL_SPI_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 &= (~SPI_CR1_SPE)) /** * @} */ /* Exported functions --------------------------------------------------------*/ /** @addtogroup SPI_Exported_Functions * @{ */ /** @addtogroup SPI_Exported_Functions_Group1 * @{ */ /* Initialization/de-initialization functions **********************************/ HAL_StatusTypeDef HAL_SPI_Init(SPI_HandleTypeDef *hspi); HAL_StatusTypeDef HAL_SPI_DeInit (SPI_HandleTypeDef *hspi); void HAL_SPI_MspInit(SPI_HandleTypeDef *hspi); void HAL_SPI_MspDeInit(SPI_HandleTypeDef *hspi); /** * @} */ /** @addtogroup SPI_Exported_Functions_Group2 * @{ */ /* I/O operation functions *****************************************************/ HAL_StatusTypeDef HAL_SPI_Transmit(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size, uint32_t Timeout); HAL_StatusTypeDef HAL_SPI_Receive(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size, uint32_t Timeout); HAL_StatusTypeDef HAL_SPI_TransmitReceive(SPI_HandleTypeDef *hspi, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size, uint32_t Timeout); HAL_StatusTypeDef HAL_SPI_Transmit_IT(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size); HAL_StatusTypeDef HAL_SPI_Receive_IT(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size); HAL_StatusTypeDef HAL_SPI_TransmitReceive_IT(SPI_HandleTypeDef *hspi, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size); #if 0 // XXX DMA HAL_StatusTypeDef HAL_SPI_Transmit_DMA(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size); HAL_StatusTypeDef HAL_SPI_Receive_DMA(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size); HAL_StatusTypeDef HAL_SPI_TransmitReceive_DMA(SPI_HandleTypeDef *hspi, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size); HAL_StatusTypeDef HAL_SPI_DMAPause(SPI_HandleTypeDef *hspi); HAL_StatusTypeDef HAL_SPI_DMAResume(SPI_HandleTypeDef *hspi); HAL_StatusTypeDef HAL_SPI_DMAStop(SPI_HandleTypeDef *hspi); #endif // XXX DMA /* Transfer Abort functions */ HAL_StatusTypeDef HAL_SPI_Abort(SPI_HandleTypeDef *hspi); HAL_StatusTypeDef HAL_SPI_Abort_IT(SPI_HandleTypeDef *hspi); void HAL_SPI_IRQHandler(SPI_HandleTypeDef *hspi); void HAL_SPI_TxCpltCallback(SPI_HandleTypeDef *hspi); void HAL_SPI_RxCpltCallback(SPI_HandleTypeDef *hspi); void HAL_SPI_TxRxCpltCallback(SPI_HandleTypeDef *hspi); void HAL_SPI_TxHalfCpltCallback(SPI_HandleTypeDef *hspi); void HAL_SPI_RxHalfCpltCallback(SPI_HandleTypeDef *hspi); void HAL_SPI_TxRxHalfCpltCallback(SPI_HandleTypeDef *hspi); void HAL_SPI_ErrorCallback(SPI_HandleTypeDef *hspi); void HAL_SPI_AbortCpltCallback(SPI_HandleTypeDef *hspi); /** * @} */ /** @addtogroup SPI_Exported_Functions_Group3 * @{ */ /* Peripheral State and Error functions ***************************************/ HAL_SPI_StateTypeDef HAL_SPI_GetState(SPI_HandleTypeDef *hspi); uint32_t HAL_SPI_GetError(SPI_HandleTypeDef *hspi); /** * @} */ /** * @} */ /* Private types -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ /* Private constants ---------------------------------------------------------*/ /* Private macros ------------------------------------------------------------*/ /** @defgroup SPI_Private_Macros SPI Private Macros * @{ */ /** @brief Set the SPI transmit-only mode. * @param __HANDLE__: specifies the SPI Handle. * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral. * @retval None */ #define SPI_1LINE_TX(__HANDLE__) ((__HANDLE__)->Instance->CR1 |= SPI_CR1_BIDIOE) /** @brief Set the SPI receive-only mode. * @param __HANDLE__: specifies the SPI Handle. * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral. * @retval None */ #define SPI_1LINE_RX(__HANDLE__) ((__HANDLE__)->Instance->CR1 &= (~SPI_CR1_BIDIOE)) /** @brief Reset the CRC calculation of the SPI. * @param __HANDLE__: specifies the SPI Handle. * This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral. * @retval None */ #define SPI_RESET_CRC(__HANDLE__) do{(__HANDLE__)->Instance->CR1 &= (uint16_t)(~SPI_CR1_CRCEN);\ (__HANDLE__)->Instance->CR1 |= SPI_CR1_CRCEN;}while(0U) #define IS_SPI_MODE(MODE) (((MODE) == SPI_MODE_SLAVE) || \ ((MODE) == SPI_MODE_MASTER)) #define IS_SPI_DIRECTION(MODE) (((MODE) == SPI_DIRECTION_2LINES) || \ ((MODE) == SPI_DIRECTION_2LINES_RXONLY) || \ ((MODE) == SPI_DIRECTION_1LINE)) #define IS_SPI_DIRECTION_2LINES(MODE) ((MODE) == SPI_DIRECTION_2LINES) #define IS_SPI_DIRECTION_2LINES_OR_1LINE(MODE) (((MODE) == SPI_DIRECTION_2LINES) || \ ((MODE) == SPI_DIRECTION_1LINE)) #define IS_SPI_DATASIZE(DATASIZE) (((DATASIZE) == SPI_DATASIZE_16BIT) || \ ((DATASIZE) == SPI_DATASIZE_8BIT)) #define IS_SPI_CPOL(CPOL) (((CPOL) == SPI_POLARITY_LOW) || \ ((CPOL) == SPI_POLARITY_HIGH)) #define IS_SPI_CPHA(CPHA) (((CPHA) == SPI_PHASE_1EDGE) || \ ((CPHA) == SPI_PHASE_2EDGE)) #define IS_SPI_NSS(NSS) (((NSS) == SPI_NSS_SOFT) || \ ((NSS) == SPI_NSS_HARD_INPUT) || \ ((NSS) == SPI_NSS_HARD_OUTPUT)) #define IS_SPI_BAUDRATE_PRESCALER(PRESCALER) (((PRESCALER) == SPI_BAUDRATEPRESCALER_2) || \ ((PRESCALER) == SPI_BAUDRATEPRESCALER_4) || \ ((PRESCALER) == SPI_BAUDRATEPRESCALER_8) || \ ((PRESCALER) == SPI_BAUDRATEPRESCALER_16) || \ ((PRESCALER) == SPI_BAUDRATEPRESCALER_32) || \ ((PRESCALER) == SPI_BAUDRATEPRESCALER_64) || \ ((PRESCALER) == SPI_BAUDRATEPRESCALER_128) || \ ((PRESCALER) == SPI_BAUDRATEPRESCALER_256)) #define IS_SPI_FIRST_BIT(BIT) (((BIT) == SPI_FIRSTBIT_MSB) || \ ((BIT) == SPI_FIRSTBIT_LSB)) #define IS_SPI_TIMODE(MODE) (((MODE) == SPI_TIMODE_DISABLE) || \ ((MODE) == SPI_TIMODE_ENABLE)) #define IS_SPI_CRC_CALCULATION(CALCULATION) (((CALCULATION) == SPI_CRCCALCULATION_DISABLE) || \ ((CALCULATION) == SPI_CRCCALCULATION_ENABLE)) #define IS_SPI_CRC_POLYNOMIAL(POLYNOMIAL) (((POLYNOMIAL) >= 0x01U) && ((POLYNOMIAL) <= 0xFFFFU)) /** * @} */ /* Private functions ---------------------------------------------------------*/ /** @defgroup SPI_Private_Functions SPI Private Functions * @{ */ /** * @} */ /** * @} */ /** * @} */ #ifdef __cplusplus } #endif #endif /* __STM32F4xx_HAL_SPI_H */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ ================================================ FILE: sys/arch/stm32/hal/stm32f4xx_ll_bus.h ================================================ /** ****************************************************************************** * @file stm32f4xx_ll_bus.h * @author MCD Application Team * @version V1.7.1 * @date 14-April-2017 * @brief Header file of BUS LL module. @verbatim ##### RCC Limitations ##### ============================================================================== [..] A delay between an RCC peripheral clock enable and the effective peripheral enabling should be taken into account in order to manage the peripheral read/write from/to registers. (+) This delay depends on the peripheral mapping. (++) AHB & APB peripherals, 1 dummy read is necessary [..] Workarounds: (#) For AHB & APB peripherals, a dummy read to the peripheral register has been inserted in each LL_{BUS}_GRP{x}_EnableClock() function. @endverbatim ****************************************************************************** * @attention * *

© COPYRIGHT(c) 2017 STMicroelectronics

* * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. Neither the name of STMicroelectronics nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __STM32F4xx_LL_BUS_H #define __STM32F4xx_LL_BUS_H #ifdef __cplusplus extern "C" { #endif /* Includes ------------------------------------------------------------------*/ #include "stm32f4xx.h" /** @addtogroup STM32F4xx_LL_Driver * @{ */ #if defined(RCC) /** @defgroup BUS_LL BUS * @{ */ /* Private types -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ /* Private constants ---------------------------------------------------------*/ /* Private macros ------------------------------------------------------------*/ /* Exported types ------------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/ /** @defgroup BUS_LL_Exported_Constants BUS Exported Constants * @{ */ /** @defgroup BUS_LL_EC_AHB1_GRP1_PERIPH AHB1 GRP1 PERIPH * @{ */ #define LL_AHB1_GRP1_PERIPH_ALL 0xFFFFFFFFU #define LL_AHB1_GRP1_PERIPH_GPIOA RCC_AHB1ENR_GPIOAEN #define LL_AHB1_GRP1_PERIPH_GPIOB RCC_AHB1ENR_GPIOBEN #define LL_AHB1_GRP1_PERIPH_GPIOC RCC_AHB1ENR_GPIOCEN #if defined(GPIOD) #define LL_AHB1_GRP1_PERIPH_GPIOD RCC_AHB1ENR_GPIODEN #endif /* GPIOD */ #if defined(GPIOE) #define LL_AHB1_GRP1_PERIPH_GPIOE RCC_AHB1ENR_GPIOEEN #endif /* GPIOE */ #if defined(GPIOF) #define LL_AHB1_GRP1_PERIPH_GPIOF RCC_AHB1ENR_GPIOFEN #endif /* GPIOF */ #if defined(GPIOG) #define LL_AHB1_GRP1_PERIPH_GPIOG RCC_AHB1ENR_GPIOGEN #endif /* GPIOG */ #if defined(GPIOH) #define LL_AHB1_GRP1_PERIPH_GPIOH RCC_AHB1ENR_GPIOHEN #endif /* GPIOH */ #if defined(GPIOI) #define LL_AHB1_GRP1_PERIPH_GPIOI RCC_AHB1ENR_GPIOIEN #endif /* GPIOI */ #if defined(GPIOJ) #define LL_AHB1_GRP1_PERIPH_GPIOJ RCC_AHB1ENR_GPIOJEN #endif /* GPIOJ */ #if defined(GPIOK) #define LL_AHB1_GRP1_PERIPH_GPIOK RCC_AHB1ENR_GPIOKEN #endif /* GPIOK */ #define LL_AHB1_GRP1_PERIPH_CRC RCC_AHB1ENR_CRCEN #if defined(RCC_AHB1ENR_BKPSRAMEN) #define LL_AHB1_GRP1_PERIPH_BKPSRAM RCC_AHB1ENR_BKPSRAMEN #endif /* RCC_AHB1ENR_BKPSRAMEN */ #if defined(RCC_AHB1ENR_CCMDATARAMEN) #define LL_AHB1_GRP1_PERIPH_CCMDATARAM RCC_AHB1ENR_CCMDATARAMEN #endif /* RCC_AHB1ENR_CCMDATARAMEN */ #define LL_AHB1_GRP1_PERIPH_DMA1 RCC_AHB1ENR_DMA1EN #define LL_AHB1_GRP1_PERIPH_DMA2 RCC_AHB1ENR_DMA2EN #if defined(RCC_AHB1ENR_RNGEN) #define LL_AHB1_GRP1_PERIPH_RNG RCC_AHB1ENR_RNGEN #endif /* RCC_AHB1ENR_RNGEN */ #if defined(DMA2D) #define LL_AHB1_GRP1_PERIPH_DMA2D RCC_AHB1ENR_DMA2DEN #endif /* DMA2D */ #if defined(ETH) #define LL_AHB1_GRP1_PERIPH_ETHMAC RCC_AHB1ENR_ETHMACEN #define LL_AHB1_GRP1_PERIPH_ETHMACTX RCC_AHB1ENR_ETHMACTXEN #define LL_AHB1_GRP1_PERIPH_ETHMACRX RCC_AHB1ENR_ETHMACRXEN #define LL_AHB1_GRP1_PERIPH_ETHMACPTP RCC_AHB1ENR_ETHMACPTPEN #endif /* ETH */ #if defined(USB_OTG_HS) #define LL_AHB1_GRP1_PERIPH_OTGHS RCC_AHB1ENR_OTGHSEN #define LL_AHB1_GRP1_PERIPH_OTGHSULPI RCC_AHB1ENR_OTGHSULPIEN #endif /* USB_OTG_HS */ #define LL_AHB1_GRP1_PERIPH_FLITF RCC_AHB1LPENR_FLITFLPEN #define LL_AHB1_GRP1_PERIPH_SRAM1 RCC_AHB1LPENR_SRAM1LPEN #if defined(RCC_AHB1LPENR_SRAM2LPEN) #define LL_AHB1_GRP1_PERIPH_SRAM2 RCC_AHB1LPENR_SRAM2LPEN #endif /* RCC_AHB1LPENR_SRAM2LPEN */ #if defined(RCC_AHB1LPENR_SRAM3LPEN) #define LL_AHB1_GRP1_PERIPH_SRAM3 RCC_AHB1LPENR_SRAM3LPEN #endif /* RCC_AHB1LPENR_SRAM3LPEN */ /** * @} */ #if defined(RCC_AHB2_SUPPORT) /** @defgroup BUS_LL_EC_AHB2_GRP1_PERIPH AHB2 GRP1 PERIPH * @{ */ #define LL_AHB2_GRP1_PERIPH_ALL 0xFFFFFFFFU #if defined(DCMI) #define LL_AHB2_GRP1_PERIPH_DCMI RCC_AHB2ENR_DCMIEN #endif /* DCMI */ #if defined(CRYP) #define LL_AHB2_GRP1_PERIPH_CRYP RCC_AHB2ENR_CRYPEN #endif /* CRYP */ #if defined(AES) #define LL_AHB2_GRP1_PERIPH_AES RCC_AHB2ENR_AESEN #endif /* AES */ #if defined(HASH) #define LL_AHB2_GRP1_PERIPH_HASH RCC_AHB2ENR_HASHEN #endif /* HASH */ #if defined(RCC_AHB2ENR_RNGEN) #define LL_AHB2_GRP1_PERIPH_RNG RCC_AHB2ENR_RNGEN #endif /* RCC_AHB2ENR_RNGEN */ #if defined(USB_OTG_FS) #define LL_AHB2_GRP1_PERIPH_OTGFS RCC_AHB2ENR_OTGFSEN #endif /* USB_OTG_FS */ /** * @} */ #endif /* RCC_AHB2_SUPPORT */ #if defined(RCC_AHB3_SUPPORT) /** @defgroup BUS_LL_EC_AHB3_GRP1_PERIPH AHB3 GRP1 PERIPH * @{ */ #define LL_AHB3_GRP1_PERIPH_ALL 0xFFFFFFFFU #if defined(FSMC_Bank1) #define LL_AHB3_GRP1_PERIPH_FSMC RCC_AHB3ENR_FSMCEN #endif /* FSMC_Bank1 */ #if defined(FMC_Bank1) #define LL_AHB3_GRP1_PERIPH_FMC RCC_AHB3ENR_FMCEN #endif /* FMC_Bank1 */ #if defined(QUADSPI) #define LL_AHB3_GRP1_PERIPH_QSPI RCC_AHB3ENR_QSPIEN #endif /* QUADSPI */ /** * @} */ #endif /* RCC_AHB3_SUPPORT */ /** @defgroup BUS_LL_EC_APB1_GRP1_PERIPH APB1 GRP1 PERIPH * @{ */ #define LL_APB1_GRP1_PERIPH_ALL 0xFFFFFFFFU #if defined(TIM2) #define LL_APB1_GRP1_PERIPH_TIM2 RCC_APB1ENR_TIM2EN #endif /* TIM2 */ #if defined(TIM3) #define LL_APB1_GRP1_PERIPH_TIM3 RCC_APB1ENR_TIM3EN #endif /* TIM3 */ #if defined(TIM4) #define LL_APB1_GRP1_PERIPH_TIM4 RCC_APB1ENR_TIM4EN #endif /* TIM4 */ #define LL_APB1_GRP1_PERIPH_TIM5 RCC_APB1ENR_TIM5EN #if defined(TIM6) #define LL_APB1_GRP1_PERIPH_TIM6 RCC_APB1ENR_TIM6EN #endif /* TIM6 */ #if defined(TIM7) #define LL_APB1_GRP1_PERIPH_TIM7 RCC_APB1ENR_TIM7EN #endif /* TIM7 */ #if defined(TIM12) #define LL_APB1_GRP1_PERIPH_TIM12 RCC_APB1ENR_TIM12EN #endif /* TIM12 */ #if defined(TIM13) #define LL_APB1_GRP1_PERIPH_TIM13 RCC_APB1ENR_TIM13EN #endif /* TIM13 */ #if defined(TIM14) #define LL_APB1_GRP1_PERIPH_TIM14 RCC_APB1ENR_TIM14EN #endif /* TIM14 */ #if defined(LPTIM1) #define LL_APB1_GRP1_PERIPH_LPTIM1 RCC_APB1ENR_LPTIM1EN #endif /* LPTIM1 */ #if defined(RCC_APB1ENR_RTCAPBEN) #define LL_APB1_GRP1_PERIPH_RTCAPB RCC_APB1ENR_RTCAPBEN #endif /* RCC_APB1ENR_RTCAPBEN */ #define LL_APB1_GRP1_PERIPH_WWDG RCC_APB1ENR_WWDGEN #if defined(SPI2) #define LL_APB1_GRP1_PERIPH_SPI2 RCC_APB1ENR_SPI2EN #endif /* SPI2 */ #if defined(SPI3) #define LL_APB1_GRP1_PERIPH_SPI3 RCC_APB1ENR_SPI3EN #endif /* SPI3 */ #if defined(SPDIFRX) #define LL_APB1_GRP1_PERIPH_SPDIFRX RCC_APB1ENR_SPDIFRXEN #endif /* SPDIFRX */ #define LL_APB1_GRP1_PERIPH_USART2 RCC_APB1ENR_USART2EN #if defined(USART3) #define LL_APB1_GRP1_PERIPH_USART3 RCC_APB1ENR_USART3EN #endif /* USART3 */ #if defined(UART4) #define LL_APB1_GRP1_PERIPH_UART4 RCC_APB1ENR_UART4EN #endif /* UART4 */ #if defined(UART5) #define LL_APB1_GRP1_PERIPH_UART5 RCC_APB1ENR_UART5EN #endif /* UART5 */ #define LL_APB1_GRP1_PERIPH_I2C1 RCC_APB1ENR_I2C1EN #define LL_APB1_GRP1_PERIPH_I2C2 RCC_APB1ENR_I2C2EN #if defined(I2C3) #define LL_APB1_GRP1_PERIPH_I2C3 RCC_APB1ENR_I2C3EN #endif /* I2C3 */ #if defined(FMPI2C1) #define LL_APB1_GRP1_PERIPH_FMPI2C1 RCC_APB1ENR_FMPI2C1EN #endif /* FMPI2C1 */ #if defined(CAN1) #define LL_APB1_GRP1_PERIPH_CAN1 RCC_APB1ENR_CAN1EN #endif /* CAN1 */ #if defined(CAN2) #define LL_APB1_GRP1_PERIPH_CAN2 RCC_APB1ENR_CAN2EN #endif /* CAN2 */ #if defined(CAN3) #define LL_APB1_GRP1_PERIPH_CAN3 RCC_APB1ENR_CAN3EN #endif /* CAN3 */ #if defined(CEC) #define LL_APB1_GRP1_PERIPH_CEC RCC_APB1ENR_CECEN #endif /* CEC */ #define LL_APB1_GRP1_PERIPH_PWR RCC_APB1ENR_PWREN #if defined(DAC1) #define LL_APB1_GRP1_PERIPH_DAC1 RCC_APB1ENR_DACEN #endif /* DAC1 */ #if defined(UART7) #define LL_APB1_GRP1_PERIPH_UART7 RCC_APB1ENR_UART7EN #endif /* UART7 */ #if defined(UART8) #define LL_APB1_GRP1_PERIPH_UART8 RCC_APB1ENR_UART8EN #endif /* UART8 */ /** * @} */ /** @defgroup BUS_LL_EC_APB2_GRP1_PERIPH APB2 GRP1 PERIPH * @{ */ #define LL_APB2_GRP1_PERIPH_ALL 0xFFFFFFFFU #define LL_APB2_GRP1_PERIPH_TIM1 RCC_APB2ENR_TIM1EN #if defined(TIM8) #define LL_APB2_GRP1_PERIPH_TIM8 RCC_APB2ENR_TIM8EN #endif /* TIM8 */ #define LL_APB2_GRP1_PERIPH_USART1 RCC_APB2ENR_USART1EN #if defined(USART6) #define LL_APB2_GRP1_PERIPH_USART6 RCC_APB2ENR_USART6EN #endif /* USART6 */ #if defined(UART9) #define LL_APB2_GRP1_PERIPH_UART9 RCC_APB2ENR_UART9EN #endif /* UART9 */ #if defined(UART10) #define LL_APB2_GRP1_PERIPH_UART10 RCC_APB2ENR_UART10EN #endif /* UART10 */ #define LL_APB2_GRP1_PERIPH_ADC1 RCC_APB2ENR_ADC1EN #if defined(ADC2) #define LL_APB2_GRP1_PERIPH_ADC2 RCC_APB2ENR_ADC2EN #endif /* ADC2 */ #if defined(ADC3) #define LL_APB2_GRP1_PERIPH_ADC3 RCC_APB2ENR_ADC3EN #endif /* ADC3 */ #if defined(SDIO) #define LL_APB2_GRP1_PERIPH_SDIO RCC_APB2ENR_SDIOEN #endif /* SDIO */ #define LL_APB2_GRP1_PERIPH_SPI1 RCC_APB2ENR_SPI1EN #if defined(SPI4) #define LL_APB2_GRP1_PERIPH_SPI4 RCC_APB2ENR_SPI4EN #endif /* SPI4 */ #define LL_APB2_GRP1_PERIPH_SYSCFG RCC_APB2ENR_SYSCFGEN #if defined(RCC_APB2ENR_EXTITEN) #define LL_APB2_GRP1_PERIPH_EXTI RCC_APB2ENR_EXTITEN #endif /* RCC_APB2ENR_EXTITEN */ #define LL_APB2_GRP1_PERIPH_TIM9 RCC_APB2ENR_TIM9EN #if defined(TIM10) #define LL_APB2_GRP1_PERIPH_TIM10 RCC_APB2ENR_TIM10EN #endif /* TIM10 */ #define LL_APB2_GRP1_PERIPH_TIM11 RCC_APB2ENR_TIM11EN #if defined(SPI5) #define LL_APB2_GRP1_PERIPH_SPI5 RCC_APB2ENR_SPI5EN #endif /* SPI5 */ #if defined(SPI6) #define LL_APB2_GRP1_PERIPH_SPI6 RCC_APB2ENR_SPI6EN #endif /* SPI6 */ #if defined(SAI1) #define LL_APB2_GRP1_PERIPH_SAI1 RCC_APB2ENR_SAI1EN #endif /* SAI1 */ #if defined(SAI2) #define LL_APB2_GRP1_PERIPH_SAI2 RCC_APB2ENR_SAI2EN #endif /* SAI2 */ #if defined(LTDC) #define LL_APB2_GRP1_PERIPH_LTDC RCC_APB2ENR_LTDCEN #endif /* LTDC */ #if defined(DSI) #define LL_APB2_GRP1_PERIPH_DSI RCC_APB2ENR_DSIEN #endif /* DSI */ #if defined(DFSDM1_Channel0) #define LL_APB2_GRP1_PERIPH_DFSDM1 RCC_APB2ENR_DFSDM1EN #endif /* DFSDM1_Channel0 */ #if defined(DFSDM2_Channel0) #define LL_APB2_GRP1_PERIPH_DFSDM2 RCC_APB2ENR_DFSDM2EN #endif /* DFSDM2_Channel0 */ #define LL_APB2_GRP1_PERIPH_ADC RCC_APB2RSTR_ADCRST /** * @} */ /** * @} */ /* Exported macro ------------------------------------------------------------*/ /* Exported functions --------------------------------------------------------*/ /** @defgroup BUS_LL_Exported_Functions BUS Exported Functions * @{ */ /** @defgroup BUS_LL_EF_AHB1 AHB1 * @{ */ /** * @brief Enable AHB1 peripherals clock. * @rmtoll AHB1ENR GPIOAEN LL_AHB1_GRP1_EnableClock\n * AHB1ENR GPIOBEN LL_AHB1_GRP1_EnableClock\n * AHB1ENR GPIOCEN LL_AHB1_GRP1_EnableClock\n * AHB1ENR GPIODEN LL_AHB1_GRP1_EnableClock\n * AHB1ENR GPIOEEN LL_AHB1_GRP1_EnableClock\n * AHB1ENR GPIOFEN LL_AHB1_GRP1_EnableClock\n * AHB1ENR GPIOGEN LL_AHB1_GRP1_EnableClock\n * AHB1ENR GPIOHEN LL_AHB1_GRP1_EnableClock\n * AHB1ENR GPIOIEN LL_AHB1_GRP1_EnableClock\n * AHB1ENR GPIOJEN LL_AHB1_GRP1_EnableClock\n * AHB1ENR GPIOKEN LL_AHB1_GRP1_EnableClock\n * AHB1ENR CRCEN LL_AHB1_GRP1_EnableClock\n * AHB1ENR BKPSRAMEN LL_AHB1_GRP1_EnableClock\n * AHB1ENR CCMDATARAMEN LL_AHB1_GRP1_EnableClock\n * AHB1ENR DMA1EN LL_AHB1_GRP1_EnableClock\n * AHB1ENR DMA2EN LL_AHB1_GRP1_EnableClock\n * AHB1ENR RNGEN LL_AHB1_GRP1_EnableClock\n * AHB1ENR DMA2DEN LL_AHB1_GRP1_EnableClock\n * AHB1ENR ETHMACEN LL_AHB1_GRP1_EnableClock\n * AHB1ENR ETHMACTXEN LL_AHB1_GRP1_EnableClock\n * AHB1ENR ETHMACRXEN LL_AHB1_GRP1_EnableClock\n * AHB1ENR ETHMACPTPEN LL_AHB1_GRP1_EnableClock\n * AHB1ENR OTGHSEN LL_AHB1_GRP1_EnableClock\n * AHB1ENR OTGHSULPIEN LL_AHB1_GRP1_EnableClock * @param Periphs This parameter can be a combination of the following values: * @arg @ref LL_AHB1_GRP1_PERIPH_GPIOA * @arg @ref LL_AHB1_GRP1_PERIPH_GPIOB * @arg @ref LL_AHB1_GRP1_PERIPH_GPIOC * @arg @ref LL_AHB1_GRP1_PERIPH_GPIOD (*) * @arg @ref LL_AHB1_GRP1_PERIPH_GPIOE (*) * @arg @ref LL_AHB1_GRP1_PERIPH_GPIOF (*) * @arg @ref LL_AHB1_GRP1_PERIPH_GPIOG (*) * @arg @ref LL_AHB1_GRP1_PERIPH_GPIOH (*) * @arg @ref LL_AHB1_GRP1_PERIPH_GPIOI (*) * @arg @ref LL_AHB1_GRP1_PERIPH_GPIOJ (*) * @arg @ref LL_AHB1_GRP1_PERIPH_GPIOK (*) * @arg @ref LL_AHB1_GRP1_PERIPH_CRC * @arg @ref LL_AHB1_GRP1_PERIPH_BKPSRAM (*) * @arg @ref LL_AHB1_GRP1_PERIPH_CCMDATARAM (*) * @arg @ref LL_AHB1_GRP1_PERIPH_DMA1 * @arg @ref LL_AHB1_GRP1_PERIPH_DMA2 * @arg @ref LL_AHB1_GRP1_PERIPH_RNG (*) * @arg @ref LL_AHB1_GRP1_PERIPH_DMA2D (*) * @arg @ref LL_AHB1_GRP1_PERIPH_ETHMAC (*) * @arg @ref LL_AHB1_GRP1_PERIPH_ETHMACTX (*) * @arg @ref LL_AHB1_GRP1_PERIPH_ETHMACRX (*) * @arg @ref LL_AHB1_GRP1_PERIPH_ETHMACPTP (*) * @arg @ref LL_AHB1_GRP1_PERIPH_OTGHS (*) * @arg @ref LL_AHB1_GRP1_PERIPH_OTGHSULPI (*) * * (*) value not defined in all devices. * @retval None */ __STATIC_INLINE void LL_AHB1_GRP1_EnableClock(uint32_t Periphs) { __IO uint32_t tmpreg; SET_BIT(RCC->AHB1ENR, Periphs); /* Delay after an RCC peripheral clock enabling */ tmpreg = READ_BIT(RCC->AHB1ENR, Periphs); (void)tmpreg; } /** * @brief Check if AHB1 peripheral clock is enabled or not * @rmtoll AHB1ENR GPIOAEN LL_AHB1_GRP1_IsEnabledClock\n * AHB1ENR GPIOBEN LL_AHB1_GRP1_IsEnabledClock\n * AHB1ENR GPIOCEN LL_AHB1_GRP1_IsEnabledClock\n * AHB1ENR GPIODEN LL_AHB1_GRP1_IsEnabledClock\n * AHB1ENR GPIOEEN LL_AHB1_GRP1_IsEnabledClock\n * AHB1ENR GPIOFEN LL_AHB1_GRP1_IsEnabledClock\n * AHB1ENR GPIOGEN LL_AHB1_GRP1_IsEnabledClock\n * AHB1ENR GPIOHEN LL_AHB1_GRP1_IsEnabledClock\n * AHB1ENR GPIOIEN LL_AHB1_GRP1_IsEnabledClock\n * AHB1ENR GPIOJEN LL_AHB1_GRP1_IsEnabledClock\n * AHB1ENR GPIOKEN LL_AHB1_GRP1_IsEnabledClock\n * AHB1ENR CRCEN LL_AHB1_GRP1_IsEnabledClock\n * AHB1ENR BKPSRAMEN LL_AHB1_GRP1_IsEnabledClock\n * AHB1ENR CCMDATARAMEN LL_AHB1_GRP1_IsEnabledClock\n * AHB1ENR DMA1EN LL_AHB1_GRP1_IsEnabledClock\n * AHB1ENR DMA2EN LL_AHB1_GRP1_IsEnabledClock\n * AHB1ENR RNGEN LL_AHB1_GRP1_IsEnabledClock\n * AHB1ENR DMA2DEN LL_AHB1_GRP1_IsEnabledClock\n * AHB1ENR ETHMACEN LL_AHB1_GRP1_IsEnabledClock\n * AHB1ENR ETHMACTXEN LL_AHB1_GRP1_IsEnabledClock\n * AHB1ENR ETHMACRXEN LL_AHB1_GRP1_IsEnabledClock\n * AHB1ENR ETHMACPTPEN LL_AHB1_GRP1_IsEnabledClock\n * AHB1ENR OTGHSEN LL_AHB1_GRP1_IsEnabledClock\n * AHB1ENR OTGHSULPIEN LL_AHB1_GRP1_IsEnabledClock * @param Periphs This parameter can be a combination of the following values: * @arg @ref LL_AHB1_GRP1_PERIPH_GPIOA * @arg @ref LL_AHB1_GRP1_PERIPH_GPIOB * @arg @ref LL_AHB1_GRP1_PERIPH_GPIOC * @arg @ref LL_AHB1_GRP1_PERIPH_GPIOD (*) * @arg @ref LL_AHB1_GRP1_PERIPH_GPIOE (*) * @arg @ref LL_AHB1_GRP1_PERIPH_GPIOF (*) * @arg @ref LL_AHB1_GRP1_PERIPH_GPIOG (*) * @arg @ref LL_AHB1_GRP1_PERIPH_GPIOH (*) * @arg @ref LL_AHB1_GRP1_PERIPH_GPIOI (*) * @arg @ref LL_AHB1_GRP1_PERIPH_GPIOJ (*) * @arg @ref LL_AHB1_GRP1_PERIPH_GPIOK (*) * @arg @ref LL_AHB1_GRP1_PERIPH_CRC * @arg @ref LL_AHB1_GRP1_PERIPH_BKPSRAM (*) * @arg @ref LL_AHB1_GRP1_PERIPH_CCMDATARAM (*) * @arg @ref LL_AHB1_GRP1_PERIPH_DMA1 * @arg @ref LL_AHB1_GRP1_PERIPH_DMA2 * @arg @ref LL_AHB1_GRP1_PERIPH_RNG (*) * @arg @ref LL_AHB1_GRP1_PERIPH_DMA2D (*) * @arg @ref LL_AHB1_GRP1_PERIPH_ETHMAC (*) * @arg @ref LL_AHB1_GRP1_PERIPH_ETHMACTX (*) * @arg @ref LL_AHB1_GRP1_PERIPH_ETHMACRX (*) * @arg @ref LL_AHB1_GRP1_PERIPH_ETHMACPTP (*) * @arg @ref LL_AHB1_GRP1_PERIPH_OTGHS (*) * @arg @ref LL_AHB1_GRP1_PERIPH_OTGHSULPI (*) * * (*) value not defined in all devices. * @retval State of Periphs (1 or 0). */ __STATIC_INLINE uint32_t LL_AHB1_GRP1_IsEnabledClock(uint32_t Periphs) { return (READ_BIT(RCC->AHB1ENR, Periphs) == Periphs); } /** * @brief Disable AHB1 peripherals clock. * @rmtoll AHB1ENR GPIOAEN LL_AHB1_GRP1_DisableClock\n * AHB1ENR GPIOBEN LL_AHB1_GRP1_DisableClock\n * AHB1ENR GPIOCEN LL_AHB1_GRP1_DisableClock\n * AHB1ENR GPIODEN LL_AHB1_GRP1_DisableClock\n * AHB1ENR GPIOEEN LL_AHB1_GRP1_DisableClock\n * AHB1ENR GPIOFEN LL_AHB1_GRP1_DisableClock\n * AHB1ENR GPIOGEN LL_AHB1_GRP1_DisableClock\n * AHB1ENR GPIOHEN LL_AHB1_GRP1_DisableClock\n * AHB1ENR GPIOIEN LL_AHB1_GRP1_DisableClock\n * AHB1ENR GPIOJEN LL_AHB1_GRP1_DisableClock\n * AHB1ENR GPIOKEN LL_AHB1_GRP1_DisableClock\n * AHB1ENR CRCEN LL_AHB1_GRP1_DisableClock\n * AHB1ENR BKPSRAMEN LL_AHB1_GRP1_DisableClock\n * AHB1ENR CCMDATARAMEN LL_AHB1_GRP1_DisableClock\n * AHB1ENR DMA1EN LL_AHB1_GRP1_DisableClock\n * AHB1ENR DMA2EN LL_AHB1_GRP1_DisableClock\n * AHB1ENR RNGEN LL_AHB1_GRP1_DisableClock\n * AHB1ENR DMA2DEN LL_AHB1_GRP1_DisableClock\n * AHB1ENR ETHMACEN LL_AHB1_GRP1_DisableClock\n * AHB1ENR ETHMACTXEN LL_AHB1_GRP1_DisableClock\n * AHB1ENR ETHMACRXEN LL_AHB1_GRP1_DisableClock\n * AHB1ENR ETHMACPTPEN LL_AHB1_GRP1_DisableClock\n * AHB1ENR OTGHSEN LL_AHB1_GRP1_DisableClock\n * AHB1ENR OTGHSULPIEN LL_AHB1_GRP1_DisableClock * @param Periphs This parameter can be a combination of the following values: * @arg @ref LL_AHB1_GRP1_PERIPH_GPIOA * @arg @ref LL_AHB1_GRP1_PERIPH_GPIOB * @arg @ref LL_AHB1_GRP1_PERIPH_GPIOC * @arg @ref LL_AHB1_GRP1_PERIPH_GPIOD (*) * @arg @ref LL_AHB1_GRP1_PERIPH_GPIOE (*) * @arg @ref LL_AHB1_GRP1_PERIPH_GPIOF (*) * @arg @ref LL_AHB1_GRP1_PERIPH_GPIOG (*) * @arg @ref LL_AHB1_GRP1_PERIPH_GPIOH (*) * @arg @ref LL_AHB1_GRP1_PERIPH_GPIOI (*) * @arg @ref LL_AHB1_GRP1_PERIPH_GPIOJ (*) * @arg @ref LL_AHB1_GRP1_PERIPH_GPIOK (*) * @arg @ref LL_AHB1_GRP1_PERIPH_CRC * @arg @ref LL_AHB1_GRP1_PERIPH_BKPSRAM (*) * @arg @ref LL_AHB1_GRP1_PERIPH_CCMDATARAM (*) * @arg @ref LL_AHB1_GRP1_PERIPH_DMA1 * @arg @ref LL_AHB1_GRP1_PERIPH_DMA2 * @arg @ref LL_AHB1_GRP1_PERIPH_RNG (*) * @arg @ref LL_AHB1_GRP1_PERIPH_DMA2D (*) * @arg @ref LL_AHB1_GRP1_PERIPH_ETHMAC (*) * @arg @ref LL_AHB1_GRP1_PERIPH_ETHMACTX (*) * @arg @ref LL_AHB1_GRP1_PERIPH_ETHMACRX (*) * @arg @ref LL_AHB1_GRP1_PERIPH_ETHMACPTP (*) * @arg @ref LL_AHB1_GRP1_PERIPH_OTGHS (*) * @arg @ref LL_AHB1_GRP1_PERIPH_OTGHSULPI (*) * * (*) value not defined in all devices. * @retval None */ __STATIC_INLINE void LL_AHB1_GRP1_DisableClock(uint32_t Periphs) { CLEAR_BIT(RCC->AHB1ENR, Periphs); } /** * @brief Force AHB1 peripherals reset. * @rmtoll AHB1RSTR GPIOARST LL_AHB1_GRP1_ForceReset\n * AHB1RSTR GPIOBRST LL_AHB1_GRP1_ForceReset\n * AHB1RSTR GPIOCRST LL_AHB1_GRP1_ForceReset\n * AHB1RSTR GPIODRST LL_AHB1_GRP1_ForceReset\n * AHB1RSTR GPIOERST LL_AHB1_GRP1_ForceReset\n * AHB1RSTR GPIOFRST LL_AHB1_GRP1_ForceReset\n * AHB1RSTR GPIOGRST LL_AHB1_GRP1_ForceReset\n * AHB1RSTR GPIOHRST LL_AHB1_GRP1_ForceReset\n * AHB1RSTR GPIOIRST LL_AHB1_GRP1_ForceReset\n * AHB1RSTR GPIOJRST LL_AHB1_GRP1_ForceReset\n * AHB1RSTR GPIOKRST LL_AHB1_GRP1_ForceReset\n * AHB1RSTR CRCRST LL_AHB1_GRP1_ForceReset\n * AHB1RSTR DMA1RST LL_AHB1_GRP1_ForceReset\n * AHB1RSTR DMA2RST LL_AHB1_GRP1_ForceReset\n * AHB1RSTR RNGRST LL_AHB1_GRP1_ForceReset\n * AHB1RSTR DMA2DRST LL_AHB1_GRP1_ForceReset\n * AHB1RSTR ETHMACRST LL_AHB1_GRP1_ForceReset\n * AHB1RSTR OTGHSRST LL_AHB1_GRP1_ForceReset * @param Periphs This parameter can be a combination of the following values: * @arg @ref LL_AHB1_GRP1_PERIPH_ALL * @arg @ref LL_AHB1_GRP1_PERIPH_GPIOA * @arg @ref LL_AHB1_GRP1_PERIPH_GPIOB * @arg @ref LL_AHB1_GRP1_PERIPH_GPIOC * @arg @ref LL_AHB1_GRP1_PERIPH_GPIOD (*) * @arg @ref LL_AHB1_GRP1_PERIPH_GPIOE (*) * @arg @ref LL_AHB1_GRP1_PERIPH_GPIOF (*) * @arg @ref LL_AHB1_GRP1_PERIPH_GPIOG (*) * @arg @ref LL_AHB1_GRP1_PERIPH_GPIOH (*) * @arg @ref LL_AHB1_GRP1_PERIPH_GPIOI (*) * @arg @ref LL_AHB1_GRP1_PERIPH_GPIOJ (*) * @arg @ref LL_AHB1_GRP1_PERIPH_GPIOK (*) * @arg @ref LL_AHB1_GRP1_PERIPH_CRC * @arg @ref LL_AHB1_GRP1_PERIPH_DMA1 * @arg @ref LL_AHB1_GRP1_PERIPH_DMA2 * @arg @ref LL_AHB1_GRP1_PERIPH_RNG (*) * @arg @ref LL_AHB1_GRP1_PERIPH_DMA2D (*) * @arg @ref LL_AHB1_GRP1_PERIPH_ETHMAC (*) * @arg @ref LL_AHB1_GRP1_PERIPH_OTGHS (*) * * (*) value not defined in all devices. * @retval None */ __STATIC_INLINE void LL_AHB1_GRP1_ForceReset(uint32_t Periphs) { SET_BIT(RCC->AHB1RSTR, Periphs); } /** * @brief Release AHB1 peripherals reset. * @rmtoll AHB1RSTR GPIOARST LL_AHB1_GRP1_ReleaseReset\n * AHB1RSTR GPIOBRST LL_AHB1_GRP1_ReleaseReset\n * AHB1RSTR GPIOCRST LL_AHB1_GRP1_ReleaseReset\n * AHB1RSTR GPIODRST LL_AHB1_GRP1_ReleaseReset\n * AHB1RSTR GPIOERST LL_AHB1_GRP1_ReleaseReset\n * AHB1RSTR GPIOFRST LL_AHB1_GRP1_ReleaseReset\n * AHB1RSTR GPIOGRST LL_AHB1_GRP1_ReleaseReset\n * AHB1RSTR GPIOHRST LL_AHB1_GRP1_ReleaseReset\n * AHB1RSTR GPIOIRST LL_AHB1_GRP1_ReleaseReset\n * AHB1RSTR GPIOJRST LL_AHB1_GRP1_ReleaseReset\n * AHB1RSTR GPIOKRST LL_AHB1_GRP1_ReleaseReset\n * AHB1RSTR CRCRST LL_AHB1_GRP1_ReleaseReset\n * AHB1RSTR DMA1RST LL_AHB1_GRP1_ReleaseReset\n * AHB1RSTR DMA2RST LL_AHB1_GRP1_ReleaseReset\n * AHB1RSTR RNGRST LL_AHB1_GRP1_ReleaseReset\n * AHB1RSTR DMA2DRST LL_AHB1_GRP1_ReleaseReset\n * AHB1RSTR ETHMACRST LL_AHB1_GRP1_ReleaseReset\n * AHB1RSTR OTGHSRST LL_AHB1_GRP1_ReleaseReset * @param Periphs This parameter can be a combination of the following values: * @arg @ref LL_AHB1_GRP1_PERIPH_ALL * @arg @ref LL_AHB1_GRP1_PERIPH_GPIOA * @arg @ref LL_AHB1_GRP1_PERIPH_GPIOB * @arg @ref LL_AHB1_GRP1_PERIPH_GPIOC * @arg @ref LL_AHB1_GRP1_PERIPH_GPIOD (*) * @arg @ref LL_AHB1_GRP1_PERIPH_GPIOE (*) * @arg @ref LL_AHB1_GRP1_PERIPH_GPIOF (*) * @arg @ref LL_AHB1_GRP1_PERIPH_GPIOG (*) * @arg @ref LL_AHB1_GRP1_PERIPH_GPIOH (*) * @arg @ref LL_AHB1_GRP1_PERIPH_GPIOI (*) * @arg @ref LL_AHB1_GRP1_PERIPH_GPIOJ (*) * @arg @ref LL_AHB1_GRP1_PERIPH_GPIOK (*) * @arg @ref LL_AHB1_GRP1_PERIPH_CRC * @arg @ref LL_AHB1_GRP1_PERIPH_DMA1 * @arg @ref LL_AHB1_GRP1_PERIPH_DMA2 * @arg @ref LL_AHB1_GRP1_PERIPH_RNG (*) * @arg @ref LL_AHB1_GRP1_PERIPH_DMA2D (*) * @arg @ref LL_AHB1_GRP1_PERIPH_ETHMAC (*) * @arg @ref LL_AHB1_GRP1_PERIPH_OTGHS (*) * * (*) value not defined in all devices. * @retval None */ __STATIC_INLINE void LL_AHB1_GRP1_ReleaseReset(uint32_t Periphs) { CLEAR_BIT(RCC->AHB1RSTR, Periphs); } /** * @brief Enable AHB1 peripheral clocks in low-power mode * @rmtoll AHB1LPENR GPIOALPEN LL_AHB1_GRP1_EnableClockLowPower\n * AHB1LPENR GPIOBLPEN LL_AHB1_GRP1_EnableClockLowPower\n * AHB1LPENR GPIOCLPEN LL_AHB1_GRP1_EnableClockLowPower\n * AHB1LPENR GPIODLPEN LL_AHB1_GRP1_EnableClockLowPower\n * AHB1LPENR GPIOELPEN LL_AHB1_GRP1_EnableClockLowPower\n * AHB1LPENR GPIOFLPEN LL_AHB1_GRP1_EnableClockLowPower\n * AHB1LPENR GPIOGLPEN LL_AHB1_GRP1_EnableClockLowPower\n * AHB1LPENR GPIOHLPEN LL_AHB1_GRP1_EnableClockLowPower\n * AHB1LPENR GPIOILPEN LL_AHB1_GRP1_EnableClockLowPower\n * AHB1LPENR GPIOJLPEN LL_AHB1_GRP1_EnableClockLowPower\n * AHB1LPENR GPIOKLPEN LL_AHB1_GRP1_EnableClockLowPower\n * AHB1LPENR CRCLPEN LL_AHB1_GRP1_EnableClockLowPower\n * AHB1LPENR BKPSRAMLPEN LL_AHB1_GRP1_EnableClockLowPower\n * AHB1LPENR FLITFLPEN LL_AHB1_GRP1_EnableClockLowPower\n * AHB1LPENR SRAM1LPEN LL_AHB1_GRP1_EnableClockLowPower\n * AHB1LPENR SRAM2LPEN LL_AHB1_GRP1_EnableClockLowPower\n * AHB1LPENR SRAM3LPEN LL_AHB1_GRP1_EnableClockLowPower\n * AHB1LPENR BKPSRAMLPEN LL_AHB1_GRP1_EnableClockLowPower\n * AHB1LPENR DMA1LPEN LL_AHB1_GRP1_EnableClockLowPower\n * AHB1LPENR DMA2LPEN LL_AHB1_GRP1_EnableClockLowPower\n * AHB1LPENR DMA2DLPEN LL_AHB1_GRP1_EnableClockLowPower\n * AHB1LPENR RNGLPEN LL_AHB1_GRP1_EnableClockLowPower\n * AHB1LPENR ETHMACLPEN LL_AHB1_GRP1_EnableClockLowPower\n * AHB1LPENR ETHMACTXLPEN LL_AHB1_GRP1_EnableClockLowPower\n * AHB1LPENR ETHMACRXLPEN LL_AHB1_GRP1_EnableClockLowPower\n * AHB1LPENR ETHMACPTPLPEN LL_AHB1_GRP1_EnableClockLowPower\n * AHB1LPENR OTGHSLPEN LL_AHB1_GRP1_EnableClockLowPower\n * AHB1LPENR OTGHSULPILPEN LL_AHB1_GRP1_EnableClockLowPower * @param Periphs This parameter can be a combination of the following values: * @arg @ref LL_AHB1_GRP1_PERIPH_GPIOA * @arg @ref LL_AHB1_GRP1_PERIPH_GPIOB * @arg @ref LL_AHB1_GRP1_PERIPH_GPIOC * @arg @ref LL_AHB1_GRP1_PERIPH_GPIOD (*) * @arg @ref LL_AHB1_GRP1_PERIPH_GPIOE (*) * @arg @ref LL_AHB1_GRP1_PERIPH_GPIOF (*) * @arg @ref LL_AHB1_GRP1_PERIPH_GPIOG (*) * @arg @ref LL_AHB1_GRP1_PERIPH_GPIOH (*) * @arg @ref LL_AHB1_GRP1_PERIPH_GPIOI (*) * @arg @ref LL_AHB1_GRP1_PERIPH_GPIOJ (*) * @arg @ref LL_AHB1_GRP1_PERIPH_GPIOK (*) * @arg @ref LL_AHB1_GRP1_PERIPH_CRC * @arg @ref LL_AHB1_GRP1_PERIPH_BKPSRAM (*) * @arg @ref LL_AHB1_GRP1_PERIPH_FLITF * @arg @ref LL_AHB1_GRP1_PERIPH_SRAM1 * @arg @ref LL_AHB1_GRP1_PERIPH_SRAM2 (*) * @arg @ref LL_AHB1_GRP1_PERIPH_SRAM3 (*) * @arg @ref LL_AHB1_GRP1_PERIPH_DMA1 * @arg @ref LL_AHB1_GRP1_PERIPH_DMA2 * @arg @ref LL_AHB1_GRP1_PERIPH_RNG (*) * @arg @ref LL_AHB1_GRP1_PERIPH_DMA2D (*) * @arg @ref LL_AHB1_GRP1_PERIPH_ETHMAC (*) * @arg @ref LL_AHB1_GRP1_PERIPH_ETHMACTX (*) * @arg @ref LL_AHB1_GRP1_PERIPH_ETHMACRX (*) * @arg @ref LL_AHB1_GRP1_PERIPH_ETHMACPTP (*) * @arg @ref LL_AHB1_GRP1_PERIPH_OTGHS (*) * @arg @ref LL_AHB1_GRP1_PERIPH_OTGHSULPI (*) * * (*) value not defined in all devices. * @retval None */ __STATIC_INLINE void LL_AHB1_GRP1_EnableClockLowPower(uint32_t Periphs) { __IO uint32_t tmpreg; SET_BIT(RCC->AHB1LPENR, Periphs); /* Delay after an RCC peripheral clock enabling */ tmpreg = READ_BIT(RCC->AHB1LPENR, Periphs); (void)tmpreg; } /** * @brief Disable AHB1 peripheral clocks in low-power mode * @rmtoll AHB1LPENR GPIOALPEN LL_AHB1_GRP1_DisableClockLowPower\n * AHB1LPENR GPIOBLPEN LL_AHB1_GRP1_DisableClockLowPower\n * AHB1LPENR GPIOCLPEN LL_AHB1_GRP1_DisableClockLowPower\n * AHB1LPENR GPIODLPEN LL_AHB1_GRP1_DisableClockLowPower\n * AHB1LPENR GPIOELPEN LL_AHB1_GRP1_DisableClockLowPower\n * AHB1LPENR GPIOFLPEN LL_AHB1_GRP1_DisableClockLowPower\n * AHB1LPENR GPIOGLPEN LL_AHB1_GRP1_DisableClockLowPower\n * AHB1LPENR GPIOHLPEN LL_AHB1_GRP1_DisableClockLowPower\n * AHB1LPENR GPIOILPEN LL_AHB1_GRP1_DisableClockLowPower\n * AHB1LPENR GPIOJLPEN LL_AHB1_GRP1_DisableClockLowPower\n * AHB1LPENR GPIOKLPEN LL_AHB1_GRP1_DisableClockLowPower\n * AHB1LPENR CRCLPEN LL_AHB1_GRP1_DisableClockLowPower\n * AHB1LPENR BKPSRAMLPEN LL_AHB1_GRP1_DisableClockLowPower\n * AHB1LPENR FLITFLPEN LL_AHB1_GRP1_DisableClockLowPower\n * AHB1LPENR SRAM1LPEN LL_AHB1_GRP1_DisableClockLowPower\n * AHB1LPENR SRAM2LPEN LL_AHB1_GRP1_DisableClockLowPower\n * AHB1LPENR SRAM3LPEN LL_AHB1_GRP1_DisableClockLowPower\n * AHB1LPENR BKPSRAMLPEN LL_AHB1_GRP1_DisableClockLowPower\n * AHB1LPENR DMA1LPEN LL_AHB1_GRP1_DisableClockLowPower\n * AHB1LPENR DMA2LPEN LL_AHB1_GRP1_DisableClockLowPower\n * AHB1LPENR DMA2DLPEN LL_AHB1_GRP1_DisableClockLowPower\n * AHB1LPENR RNGLPEN LL_AHB1_GRP1_DisableClockLowPower\n * AHB1LPENR ETHMACLPEN LL_AHB1_GRP1_DisableClockLowPower\n * AHB1LPENR ETHMACTXLPEN LL_AHB1_GRP1_DisableClockLowPower\n * AHB1LPENR ETHMACRXLPEN LL_AHB1_GRP1_DisableClockLowPower\n * AHB1LPENR ETHMACPTPLPEN LL_AHB1_GRP1_DisableClockLowPower\n * AHB1LPENR OTGHSLPEN LL_AHB1_GRP1_DisableClockLowPower\n * AHB1LPENR OTGHSULPILPEN LL_AHB1_GRP1_DisableClockLowPower * @param Periphs This parameter can be a combination of the following values: * @arg @ref LL_AHB1_GRP1_PERIPH_GPIOA * @arg @ref LL_AHB1_GRP1_PERIPH_GPIOB * @arg @ref LL_AHB1_GRP1_PERIPH_GPIOC * @arg @ref LL_AHB1_GRP1_PERIPH_GPIOD (*) * @arg @ref LL_AHB1_GRP1_PERIPH_GPIOE (*) * @arg @ref LL_AHB1_GRP1_PERIPH_GPIOF (*) * @arg @ref LL_AHB1_GRP1_PERIPH_GPIOG (*) * @arg @ref LL_AHB1_GRP1_PERIPH_GPIOH (*) * @arg @ref LL_AHB1_GRP1_PERIPH_GPIOI (*) * @arg @ref LL_AHB1_GRP1_PERIPH_GPIOJ (*) * @arg @ref LL_AHB1_GRP1_PERIPH_GPIOK (*) * @arg @ref LL_AHB1_GRP1_PERIPH_CRC * @arg @ref LL_AHB1_GRP1_PERIPH_BKPSRAM (*) * @arg @ref LL_AHB1_GRP1_PERIPH_FLITF * @arg @ref LL_AHB1_GRP1_PERIPH_SRAM1 * @arg @ref LL_AHB1_GRP1_PERIPH_SRAM2 (*) * @arg @ref LL_AHB1_GRP1_PERIPH_SRAM3 (*) * @arg @ref LL_AHB1_GRP1_PERIPH_DMA1 * @arg @ref LL_AHB1_GRP1_PERIPH_DMA2 * @arg @ref LL_AHB1_GRP1_PERIPH_RNG (*) * @arg @ref LL_AHB1_GRP1_PERIPH_DMA2D (*) * @arg @ref LL_AHB1_GRP1_PERIPH_ETHMAC (*) * @arg @ref LL_AHB1_GRP1_PERIPH_ETHMACTX (*) * @arg @ref LL_AHB1_GRP1_PERIPH_ETHMACRX (*) * @arg @ref LL_AHB1_GRP1_PERIPH_ETHMACPTP (*) * @arg @ref LL_AHB1_GRP1_PERIPH_OTGHS (*) * @arg @ref LL_AHB1_GRP1_PERIPH_OTGHSULPI (*) * * (*) value not defined in all devices. * @retval None */ __STATIC_INLINE void LL_AHB1_GRP1_DisableClockLowPower(uint32_t Periphs) { CLEAR_BIT(RCC->AHB1LPENR, Periphs); } /** * @} */ #if defined(RCC_AHB2_SUPPORT) /** @defgroup BUS_LL_EF_AHB2 AHB2 * @{ */ /** * @brief Enable AHB2 peripherals clock. * @rmtoll AHB2ENR DCMIEN LL_AHB2_GRP1_EnableClock\n * AHB2ENR CRYPEN LL_AHB2_GRP1_EnableClock\n * AHB2ENR AESEN LL_AHB2_GRP1_EnableClock\n * AHB2ENR HASHEN LL_AHB2_GRP1_EnableClock\n * AHB2ENR RNGEN LL_AHB2_GRP1_EnableClock\n * AHB2ENR OTGFSEN LL_AHB2_GRP1_EnableClock * @param Periphs This parameter can be a combination of the following values: * @arg @ref LL_AHB2_GRP1_PERIPH_DCMI (*) * @arg @ref LL_AHB2_GRP1_PERIPH_CRYP (*) * @arg @ref LL_AHB2_GRP1_PERIPH_AES (*) * @arg @ref LL_AHB2_GRP1_PERIPH_HASH (*) * @arg @ref LL_AHB2_GRP1_PERIPH_RNG (*) * @arg @ref LL_AHB2_GRP1_PERIPH_OTGFS (*) * * (*) value not defined in all devices. * @retval None */ __STATIC_INLINE void LL_AHB2_GRP1_EnableClock(uint32_t Periphs) { __IO uint32_t tmpreg; SET_BIT(RCC->AHB2ENR, Periphs); /* Delay after an RCC peripheral clock enabling */ tmpreg = READ_BIT(RCC->AHB2ENR, Periphs); (void)tmpreg; } /** * @brief Check if AHB2 peripheral clock is enabled or not * @rmtoll AHB2ENR DCMIEN LL_AHB2_GRP1_IsEnabledClock\n * AHB2ENR CRYPEN LL_AHB2_GRP1_IsEnabledClock\n * AHB2ENR AESEN LL_AHB2_GRP1_IsEnabledClock\n * AHB2ENR HASHEN LL_AHB2_GRP1_IsEnabledClock\n * AHB2ENR RNGEN LL_AHB2_GRP1_IsEnabledClock\n * AHB2ENR OTGFSEN LL_AHB2_GRP1_IsEnabledClock * @param Periphs This parameter can be a combination of the following values: * @arg @ref LL_AHB2_GRP1_PERIPH_DCMI (*) * @arg @ref LL_AHB2_GRP1_PERIPH_CRYP (*) * @arg @ref LL_AHB2_GRP1_PERIPH_AES (*) * @arg @ref LL_AHB2_GRP1_PERIPH_HASH (*) * @arg @ref LL_AHB2_GRP1_PERIPH_RNG (*) * @arg @ref LL_AHB2_GRP1_PERIPH_OTGFS (*) * * (*) value not defined in all devices. * @retval State of Periphs (1 or 0). */ __STATIC_INLINE uint32_t LL_AHB2_GRP1_IsEnabledClock(uint32_t Periphs) { return (READ_BIT(RCC->AHB2ENR, Periphs) == Periphs); } /** * @brief Disable AHB2 peripherals clock. * @rmtoll AHB2ENR DCMIEN LL_AHB2_GRP1_DisableClock\n * AHB2ENR CRYPEN LL_AHB2_GRP1_DisableClock\n * AHB2ENR AESEN LL_AHB2_GRP1_DisableClock\n * AHB2ENR HASHEN LL_AHB2_GRP1_DisableClock\n * AHB2ENR RNGEN LL_AHB2_GRP1_DisableClock\n * AHB2ENR OTGFSEN LL_AHB2_GRP1_DisableClock * @param Periphs This parameter can be a combination of the following values: * @arg @ref LL_AHB2_GRP1_PERIPH_DCMI (*) * @arg @ref LL_AHB2_GRP1_PERIPH_CRYP (*) * @arg @ref LL_AHB2_GRP1_PERIPH_AES (*) * @arg @ref LL_AHB2_GRP1_PERIPH_HASH (*) * @arg @ref LL_AHB2_GRP1_PERIPH_RNG (*) * @arg @ref LL_AHB2_GRP1_PERIPH_OTGFS (*) * * (*) value not defined in all devices. * @retval None */ __STATIC_INLINE void LL_AHB2_GRP1_DisableClock(uint32_t Periphs) { CLEAR_BIT(RCC->AHB2ENR, Periphs); } /** * @brief Force AHB2 peripherals reset. * @rmtoll AHB2RSTR DCMIRST LL_AHB2_GRP1_ForceReset\n * AHB2RSTR CRYPRST LL_AHB2_GRP1_ForceReset\n * AHB2RSTR AESRST LL_AHB2_GRP1_ForceReset\n * AHB2RSTR HASHRST LL_AHB2_GRP1_ForceReset\n * AHB2RSTR RNGRST LL_AHB2_GRP1_ForceReset\n * AHB2RSTR OTGFSRST LL_AHB2_GRP1_ForceReset * @param Periphs This parameter can be a combination of the following values: * @arg @ref LL_AHB2_GRP1_PERIPH_ALL * @arg @ref LL_AHB2_GRP1_PERIPH_DCMI (*) * @arg @ref LL_AHB2_GRP1_PERIPH_CRYP (*) * @arg @ref LL_AHB2_GRP1_PERIPH_AES (*) * @arg @ref LL_AHB2_GRP1_PERIPH_HASH (*) * @arg @ref LL_AHB2_GRP1_PERIPH_RNG (*) * @arg @ref LL_AHB2_GRP1_PERIPH_OTGFS (*) * * (*) value not defined in all devices. * @retval None */ __STATIC_INLINE void LL_AHB2_GRP1_ForceReset(uint32_t Periphs) { SET_BIT(RCC->AHB2RSTR, Periphs); } /** * @brief Release AHB2 peripherals reset. * @rmtoll AHB2RSTR DCMIRST LL_AHB2_GRP1_ReleaseReset\n * AHB2RSTR CRYPRST LL_AHB2_GRP1_ReleaseReset\n * AHB2RSTR AESRST LL_AHB2_GRP1_ReleaseReset\n * AHB2RSTR HASHRST LL_AHB2_GRP1_ReleaseReset\n * AHB2RSTR RNGRST LL_AHB2_GRP1_ReleaseReset\n * AHB2RSTR OTGFSRST LL_AHB2_GRP1_ReleaseReset * @param Periphs This parameter can be a combination of the following values: * @arg @ref LL_AHB2_GRP1_PERIPH_ALL * @arg @ref LL_AHB2_GRP1_PERIPH_DCMI (*) * @arg @ref LL_AHB2_GRP1_PERIPH_CRYP (*) * @arg @ref LL_AHB2_GRP1_PERIPH_AES (*) * @arg @ref LL_AHB2_GRP1_PERIPH_HASH (*) * @arg @ref LL_AHB2_GRP1_PERIPH_RNG (*) * @arg @ref LL_AHB2_GRP1_PERIPH_OTGFS (*) * * (*) value not defined in all devices. * @retval None */ __STATIC_INLINE void LL_AHB2_GRP1_ReleaseReset(uint32_t Periphs) { CLEAR_BIT(RCC->AHB2RSTR, Periphs); } /** * @brief Enable AHB2 peripheral clocks in low-power mode * @rmtoll AHB2LPENR DCMILPEN LL_AHB2_GRP1_EnableClockLowPower\n * AHB2LPENR CRYPLPEN LL_AHB2_GRP1_EnableClockLowPower\n * AHB2LPENR AESLPEN LL_AHB2_GRP1_EnableClockLowPower\n * AHB2LPENR HASHLPEN LL_AHB2_GRP1_EnableClockLowPower\n * AHB2LPENR RNGLPEN LL_AHB2_GRP1_EnableClockLowPower\n * AHB2LPENR OTGFSLPEN LL_AHB2_GRP1_EnableClockLowPower * @param Periphs This parameter can be a combination of the following values: * @arg @ref LL_AHB2_GRP1_PERIPH_DCMI (*) * @arg @ref LL_AHB2_GRP1_PERIPH_CRYP (*) * @arg @ref LL_AHB2_GRP1_PERIPH_AES (*) * @arg @ref LL_AHB2_GRP1_PERIPH_HASH (*) * @arg @ref LL_AHB2_GRP1_PERIPH_RNG (*) * @arg @ref LL_AHB2_GRP1_PERIPH_OTGFS (*) * * (*) value not defined in all devices. * @retval None */ __STATIC_INLINE void LL_AHB2_GRP1_EnableClockLowPower(uint32_t Periphs) { __IO uint32_t tmpreg; SET_BIT(RCC->AHB2LPENR, Periphs); /* Delay after an RCC peripheral clock enabling */ tmpreg = READ_BIT(RCC->AHB2LPENR, Periphs); (void)tmpreg; } /** * @brief Disable AHB2 peripheral clocks in low-power mode * @rmtoll AHB2LPENR DCMILPEN LL_AHB2_GRP1_DisableClockLowPower\n * AHB2LPENR CRYPLPEN LL_AHB2_GRP1_DisableClockLowPower\n * AHB2LPENR AESLPEN LL_AHB2_GRP1_DisableClockLowPower\n * AHB2LPENR HASHLPEN LL_AHB2_GRP1_DisableClockLowPower\n * AHB2LPENR RNGLPEN LL_AHB2_GRP1_DisableClockLowPower\n * AHB2LPENR OTGFSLPEN LL_AHB2_GRP1_DisableClockLowPower * @param Periphs This parameter can be a combination of the following values: * @arg @ref LL_AHB2_GRP1_PERIPH_DCMI (*) * @arg @ref LL_AHB2_GRP1_PERIPH_CRYP (*) * @arg @ref LL_AHB2_GRP1_PERIPH_AES (*) * @arg @ref LL_AHB2_GRP1_PERIPH_HASH (*) * @arg @ref LL_AHB2_GRP1_PERIPH_RNG (*) * @arg @ref LL_AHB2_GRP1_PERIPH_OTGFS (*) * * (*) value not defined in all devices. * @retval None */ __STATIC_INLINE void LL_AHB2_GRP1_DisableClockLowPower(uint32_t Periphs) { CLEAR_BIT(RCC->AHB2LPENR, Periphs); } /** * @} */ #endif /* RCC_AHB2_SUPPORT */ #if defined(RCC_AHB3_SUPPORT) /** @defgroup BUS_LL_EF_AHB3 AHB3 * @{ */ /** * @brief Enable AHB3 peripherals clock. * @rmtoll AHB3ENR FMCEN LL_AHB3_GRP1_EnableClock\n * AHB3ENR FSMCEN LL_AHB3_GRP1_EnableClock\n * AHB3ENR QSPIEN LL_AHB3_GRP1_EnableClock * @param Periphs This parameter can be a combination of the following values: * @arg @ref LL_AHB3_GRP1_PERIPH_FMC (*) * @arg @ref LL_AHB3_GRP1_PERIPH_FSMC (*) * @arg @ref LL_AHB3_GRP1_PERIPH_QSPI (*) * * (*) value not defined in all devices. * @retval None */ __STATIC_INLINE void LL_AHB3_GRP1_EnableClock(uint32_t Periphs) { __IO uint32_t tmpreg; SET_BIT(RCC->AHB3ENR, Periphs); /* Delay after an RCC peripheral clock enabling */ tmpreg = READ_BIT(RCC->AHB3ENR, Periphs); (void)tmpreg; } /** * @brief Check if AHB3 peripheral clock is enabled or not * @rmtoll AHB3ENR FMCEN LL_AHB3_GRP1_IsEnabledClock\n * AHB3ENR FSMCEN LL_AHB3_GRP1_IsEnabledClock\n * AHB3ENR QSPIEN LL_AHB3_GRP1_IsEnabledClock * @param Periphs This parameter can be a combination of the following values: * @arg @ref LL_AHB3_GRP1_PERIPH_FMC (*) * @arg @ref LL_AHB3_GRP1_PERIPH_FSMC (*) * @arg @ref LL_AHB3_GRP1_PERIPH_QSPI (*) * * (*) value not defined in all devices. * @retval State of Periphs (1 or 0). */ __STATIC_INLINE uint32_t LL_AHB3_GRP1_IsEnabledClock(uint32_t Periphs) { return (READ_BIT(RCC->AHB3ENR, Periphs) == Periphs); } /** * @brief Disable AHB3 peripherals clock. * @rmtoll AHB3ENR FMCEN LL_AHB3_GRP1_DisableClock\n * AHB3ENR FSMCEN LL_AHB3_GRP1_DisableClock\n * AHB3ENR QSPIEN LL_AHB3_GRP1_DisableClock * @param Periphs This parameter can be a combination of the following values: * @arg @ref LL_AHB3_GRP1_PERIPH_FMC (*) * @arg @ref LL_AHB3_GRP1_PERIPH_FSMC (*) * @arg @ref LL_AHB3_GRP1_PERIPH_QSPI (*) * * (*) value not defined in all devices. * @retval None */ __STATIC_INLINE void LL_AHB3_GRP1_DisableClock(uint32_t Periphs) { CLEAR_BIT(RCC->AHB3ENR, Periphs); } /** * @brief Force AHB3 peripherals reset. * @rmtoll AHB3RSTR FMCRST LL_AHB3_GRP1_ForceReset\n * AHB3RSTR FSMCRST LL_AHB3_GRP1_ForceReset\n * AHB3RSTR QSPIRST LL_AHB3_GRP1_ForceReset * @param Periphs This parameter can be a combination of the following values: * @arg @ref LL_AHB3_GRP1_PERIPH_ALL * @arg @ref LL_AHB3_GRP1_PERIPH_FMC (*) * @arg @ref LL_AHB3_GRP1_PERIPH_FSMC (*) * @arg @ref LL_AHB3_GRP1_PERIPH_QSPI (*) * * (*) value not defined in all devices. * @retval None */ __STATIC_INLINE void LL_AHB3_GRP1_ForceReset(uint32_t Periphs) { SET_BIT(RCC->AHB3RSTR, Periphs); } /** * @brief Release AHB3 peripherals reset. * @rmtoll AHB3RSTR FMCRST LL_AHB3_GRP1_ReleaseReset\n * AHB3RSTR FSMCRST LL_AHB3_GRP1_ReleaseReset\n * AHB3RSTR QSPIRST LL_AHB3_GRP1_ReleaseReset * @param Periphs This parameter can be a combination of the following values: * @arg @ref LL_AHB2_GRP1_PERIPH_ALL * @arg @ref LL_AHB3_GRP1_PERIPH_FMC (*) * @arg @ref LL_AHB3_GRP1_PERIPH_FSMC (*) * @arg @ref LL_AHB3_GRP1_PERIPH_QSPI (*) * * (*) value not defined in all devices. * @retval None */ __STATIC_INLINE void LL_AHB3_GRP1_ReleaseReset(uint32_t Periphs) { CLEAR_BIT(RCC->AHB3RSTR, Periphs); } /** * @brief Enable AHB3 peripheral clocks in low-power mode * @rmtoll AHB3LPENR FMCLPEN LL_AHB3_GRP1_EnableClockLowPower\n * AHB3LPENR FSMCLPEN LL_AHB3_GRP1_EnableClockLowPower\n * AHB3LPENR QSPILPEN LL_AHB3_GRP1_EnableClockLowPower * @param Periphs This parameter can be a combination of the following values: * @arg @ref LL_AHB3_GRP1_PERIPH_FMC (*) * @arg @ref LL_AHB3_GRP1_PERIPH_FSMC (*) * @arg @ref LL_AHB3_GRP1_PERIPH_QSPI (*) * * (*) value not defined in all devices. * @retval None */ __STATIC_INLINE void LL_AHB3_GRP1_EnableClockLowPower(uint32_t Periphs) { __IO uint32_t tmpreg; SET_BIT(RCC->AHB3LPENR, Periphs); /* Delay after an RCC peripheral clock enabling */ tmpreg = READ_BIT(RCC->AHB3LPENR, Periphs); (void)tmpreg; } /** * @brief Disable AHB3 peripheral clocks in low-power mode * @rmtoll AHB3LPENR FMCLPEN LL_AHB3_GRP1_DisableClockLowPower\n * AHB3LPENR FSMCLPEN LL_AHB3_GRP1_DisableClockLowPower\n * AHB3LPENR QSPILPEN LL_AHB3_GRP1_DisableClockLowPower * @param Periphs This parameter can be a combination of the following values: * @arg @ref LL_AHB3_GRP1_PERIPH_FMC (*) * @arg @ref LL_AHB3_GRP1_PERIPH_FSMC (*) * @arg @ref LL_AHB3_GRP1_PERIPH_QSPI (*) * * (*) value not defined in all devices. * @retval None */ __STATIC_INLINE void LL_AHB3_GRP1_DisableClockLowPower(uint32_t Periphs) { CLEAR_BIT(RCC->AHB3LPENR, Periphs); } /** * @} */ #endif /* RCC_AHB3_SUPPORT */ /** @defgroup BUS_LL_EF_APB1 APB1 * @{ */ /** * @brief Enable APB1 peripherals clock. * @rmtoll APB1ENR TIM2EN LL_APB1_GRP1_EnableClock\n * APB1ENR TIM3EN LL_APB1_GRP1_EnableClock\n * APB1ENR TIM4EN LL_APB1_GRP1_EnableClock\n * APB1ENR TIM5EN LL_APB1_GRP1_EnableClock\n * APB1ENR TIM6EN LL_APB1_GRP1_EnableClock\n * APB1ENR TIM7EN LL_APB1_GRP1_EnableClock\n * APB1ENR TIM12EN LL_APB1_GRP1_EnableClock\n * APB1ENR TIM13EN LL_APB1_GRP1_EnableClock\n * APB1ENR TIM14EN LL_APB1_GRP1_EnableClock\n * APB1ENR LPTIM1EN LL_APB1_GRP1_EnableClock\n * APB1ENR WWDGEN LL_APB1_GRP1_EnableClock\n * APB1ENR SPI2EN LL_APB1_GRP1_EnableClock\n * APB1ENR SPI3EN LL_APB1_GRP1_EnableClock\n * APB1ENR SPDIFRXEN LL_APB1_GRP1_EnableClock\n * APB1ENR USART2EN LL_APB1_GRP1_EnableClock\n * APB1ENR USART3EN LL_APB1_GRP1_EnableClock\n * APB1ENR UART4EN LL_APB1_GRP1_EnableClock\n * APB1ENR UART5EN LL_APB1_GRP1_EnableClock\n * APB1ENR I2C1EN LL_APB1_GRP1_EnableClock\n * APB1ENR I2C2EN LL_APB1_GRP1_EnableClock\n * APB1ENR I2C3EN LL_APB1_GRP1_EnableClock\n * APB1ENR FMPI2C1EN LL_APB1_GRP1_EnableClock\n * APB1ENR CAN1EN LL_APB1_GRP1_EnableClock\n * APB1ENR CAN2EN LL_APB1_GRP1_EnableClock\n * APB1ENR CAN3EN LL_APB1_GRP1_EnableClock\n * APB1ENR CECEN LL_APB1_GRP1_EnableClock\n * APB1ENR PWREN LL_APB1_GRP1_EnableClock\n * APB1ENR DACEN LL_APB1_GRP1_EnableClock\n * APB1ENR UART7EN LL_APB1_GRP1_EnableClock\n * APB1ENR UART8EN LL_APB1_GRP1_EnableClock\n * APB1ENR RTCAPBEN LL_APB1_GRP1_EnableClock * @param Periphs This parameter can be a combination of the following values: * @arg @ref LL_APB1_GRP1_PERIPH_TIM2 (*) * @arg @ref LL_APB1_GRP1_PERIPH_TIM3 (*) * @arg @ref LL_APB1_GRP1_PERIPH_TIM4 (*) * @arg @ref LL_APB1_GRP1_PERIPH_TIM5 * @arg @ref LL_APB1_GRP1_PERIPH_TIM6 (*) * @arg @ref LL_APB1_GRP1_PERIPH_TIM7 (*) * @arg @ref LL_APB1_GRP1_PERIPH_TIM12 (*) * @arg @ref LL_APB1_GRP1_PERIPH_TIM13 (*) * @arg @ref LL_APB1_GRP1_PERIPH_TIM14 (*) * @arg @ref LL_APB1_GRP1_PERIPH_LPTIM1 (*) * @arg @ref LL_APB1_GRP1_PERIPH_WWDG * @arg @ref LL_APB1_GRP1_PERIPH_SPI2 (*) * @arg @ref LL_APB1_GRP1_PERIPH_SPI3 (*) * @arg @ref LL_APB1_GRP1_PERIPH_SPDIFRX (*) * @arg @ref LL_APB1_GRP1_PERIPH_USART2 * @arg @ref LL_APB1_GRP1_PERIPH_USART3 (*) * @arg @ref LL_APB1_GRP1_PERIPH_UART4 (*) * @arg @ref LL_APB1_GRP1_PERIPH_UART5 (*) * @arg @ref LL_APB1_GRP1_PERIPH_I2C1 * @arg @ref LL_APB1_GRP1_PERIPH_I2C2 * @arg @ref LL_APB1_GRP1_PERIPH_I2C3 (*) * @arg @ref LL_APB1_GRP1_PERIPH_FMPI2C1 (*) * @arg @ref LL_APB1_GRP1_PERIPH_CAN1 (*) * @arg @ref LL_APB1_GRP1_PERIPH_CAN2 (*) * @arg @ref LL_APB1_GRP1_PERIPH_CAN3 (*) * @arg @ref LL_APB1_GRP1_PERIPH_CEC (*) * @arg @ref LL_APB1_GRP1_PERIPH_PWR * @arg @ref LL_APB1_GRP1_PERIPH_DAC1 (*) * @arg @ref LL_APB1_GRP1_PERIPH_UART7 (*) * @arg @ref LL_APB1_GRP1_PERIPH_UART8 (*) * @arg @ref LL_APB1_GRP1_PERIPH_RTCAPB (*) * * (*) value not defined in all devices. * @retval None */ __STATIC_INLINE void LL_APB1_GRP1_EnableClock(uint32_t Periphs) { __IO uint32_t tmpreg; SET_BIT(RCC->APB1ENR, Periphs); /* Delay after an RCC peripheral clock enabling */ tmpreg = READ_BIT(RCC->APB1ENR, Periphs); (void)tmpreg; } /** * @brief Check if APB1 peripheral clock is enabled or not * @rmtoll APB1ENR TIM2EN LL_APB1_GRP1_IsEnabledClock\n * APB1ENR TIM3EN LL_APB1_GRP1_IsEnabledClock\n * APB1ENR TIM4EN LL_APB1_GRP1_IsEnabledClock\n * APB1ENR TIM5EN LL_APB1_GRP1_IsEnabledClock\n * APB1ENR TIM6EN LL_APB1_GRP1_IsEnabledClock\n * APB1ENR TIM7EN LL_APB1_GRP1_IsEnabledClock\n * APB1ENR TIM12EN LL_APB1_GRP1_IsEnabledClock\n * APB1ENR TIM13EN LL_APB1_GRP1_IsEnabledClock\n * APB1ENR TIM14EN LL_APB1_GRP1_IsEnabledClock\n * APB1ENR LPTIM1EN LL_APB1_GRP1_IsEnabledClock\n * APB1ENR WWDGEN LL_APB1_GRP1_IsEnabledClock\n * APB1ENR SPI2EN LL_APB1_GRP1_IsEnabledClock\n * APB1ENR SPI3EN LL_APB1_GRP1_IsEnabledClock\n * APB1ENR SPDIFRXEN LL_APB1_GRP1_IsEnabledClock\n * APB1ENR USART2EN LL_APB1_GRP1_IsEnabledClock\n * APB1ENR USART3EN LL_APB1_GRP1_IsEnabledClock\n * APB1ENR UART4EN LL_APB1_GRP1_IsEnabledClock\n * APB1ENR UART5EN LL_APB1_GRP1_IsEnabledClock\n * APB1ENR I2C1EN LL_APB1_GRP1_IsEnabledClock\n * APB1ENR I2C2EN LL_APB1_GRP1_IsEnabledClock\n * APB1ENR I2C3EN LL_APB1_GRP1_IsEnabledClock\n * APB1ENR FMPI2C1EN LL_APB1_GRP1_IsEnabledClock\n * APB1ENR CAN1EN LL_APB1_GRP1_IsEnabledClock\n * APB1ENR CAN2EN LL_APB1_GRP1_IsEnabledClock\n * APB1ENR CAN3EN LL_APB1_GRP1_IsEnabledClock\n * APB1ENR CECEN LL_APB1_GRP1_IsEnabledClock\n * APB1ENR PWREN LL_APB1_GRP1_IsEnabledClock\n * APB1ENR DACEN LL_APB1_GRP1_IsEnabledClock\n * APB1ENR UART7EN LL_APB1_GRP1_IsEnabledClock\n * APB1ENR UART8EN LL_APB1_GRP1_IsEnabledClock\n * APB1ENR RTCAPBEN LL_APB1_GRP1_IsEnabledClock * @param Periphs This parameter can be a combination of the following values: * @arg @ref LL_APB1_GRP1_PERIPH_TIM2 (*) * @arg @ref LL_APB1_GRP1_PERIPH_TIM3 (*) * @arg @ref LL_APB1_GRP1_PERIPH_TIM4 (*) * @arg @ref LL_APB1_GRP1_PERIPH_TIM5 * @arg @ref LL_APB1_GRP1_PERIPH_TIM6 (*) * @arg @ref LL_APB1_GRP1_PERIPH_TIM7 (*) * @arg @ref LL_APB1_GRP1_PERIPH_TIM12 (*) * @arg @ref LL_APB1_GRP1_PERIPH_TIM13 (*) * @arg @ref LL_APB1_GRP1_PERIPH_TIM14 (*) * @arg @ref LL_APB1_GRP1_PERIPH_LPTIM1 (*) * @arg @ref LL_APB1_GRP1_PERIPH_WWDG * @arg @ref LL_APB1_GRP1_PERIPH_SPI2 (*) * @arg @ref LL_APB1_GRP1_PERIPH_SPI3 (*) * @arg @ref LL_APB1_GRP1_PERIPH_SPDIFRX (*) * @arg @ref LL_APB1_GRP1_PERIPH_USART2 * @arg @ref LL_APB1_GRP1_PERIPH_USART3 (*) * @arg @ref LL_APB1_GRP1_PERIPH_UART4 (*) * @arg @ref LL_APB1_GRP1_PERIPH_UART5 (*) * @arg @ref LL_APB1_GRP1_PERIPH_I2C1 * @arg @ref LL_APB1_GRP1_PERIPH_I2C2 * @arg @ref LL_APB1_GRP1_PERIPH_I2C3 (*) * @arg @ref LL_APB1_GRP1_PERIPH_FMPI2C1 (*) * @arg @ref LL_APB1_GRP1_PERIPH_CAN1 (*) * @arg @ref LL_APB1_GRP1_PERIPH_CAN2 (*) * @arg @ref LL_APB1_GRP1_PERIPH_CAN3 (*) * @arg @ref LL_APB1_GRP1_PERIPH_CEC (*) * @arg @ref LL_APB1_GRP1_PERIPH_PWR * @arg @ref LL_APB1_GRP1_PERIPH_DAC1 (*) * @arg @ref LL_APB1_GRP1_PERIPH_UART7 (*) * @arg @ref LL_APB1_GRP1_PERIPH_UART8 (*) * @arg @ref LL_APB1_GRP1_PERIPH_RTCAPB (*) * * (*) value not defined in all devices. * @retval State of Periphs (1 or 0). */ __STATIC_INLINE uint32_t LL_APB1_GRP1_IsEnabledClock(uint32_t Periphs) { return (READ_BIT(RCC->APB1ENR, Periphs) == Periphs); } /** * @brief Disable APB1 peripherals clock. * @rmtoll APB1ENR TIM2EN LL_APB1_GRP1_DisableClock\n * APB1ENR TIM3EN LL_APB1_GRP1_DisableClock\n * APB1ENR TIM4EN LL_APB1_GRP1_DisableClock\n * APB1ENR TIM5EN LL_APB1_GRP1_DisableClock\n * APB1ENR TIM6EN LL_APB1_GRP1_DisableClock\n * APB1ENR TIM7EN LL_APB1_GRP1_DisableClock\n * APB1ENR TIM12EN LL_APB1_GRP1_DisableClock\n * APB1ENR TIM13EN LL_APB1_GRP1_DisableClock\n * APB1ENR TIM14EN LL_APB1_GRP1_DisableClock\n * APB1ENR LPTIM1EN LL_APB1_GRP1_DisableClock\n * APB1ENR WWDGEN LL_APB1_GRP1_DisableClock\n * APB1ENR SPI2EN LL_APB1_GRP1_DisableClock\n * APB1ENR SPI3EN LL_APB1_GRP1_DisableClock\n * APB1ENR SPDIFRXEN LL_APB1_GRP1_DisableClock\n * APB1ENR USART2EN LL_APB1_GRP1_DisableClock\n * APB1ENR USART3EN LL_APB1_GRP1_DisableClock\n * APB1ENR UART4EN LL_APB1_GRP1_DisableClock\n * APB1ENR UART5EN LL_APB1_GRP1_DisableClock\n * APB1ENR I2C1EN LL_APB1_GRP1_DisableClock\n * APB1ENR I2C2EN LL_APB1_GRP1_DisableClock\n * APB1ENR I2C3EN LL_APB1_GRP1_DisableClock\n * APB1ENR FMPI2C1EN LL_APB1_GRP1_DisableClock\n * APB1ENR CAN1EN LL_APB1_GRP1_DisableClock\n * APB1ENR CAN2EN LL_APB1_GRP1_DisableClock\n * APB1ENR CAN3EN LL_APB1_GRP1_DisableClock\n * APB1ENR CECEN LL_APB1_GRP1_DisableClock\n * APB1ENR PWREN LL_APB1_GRP1_DisableClock\n * APB1ENR DACEN LL_APB1_GRP1_DisableClock\n * APB1ENR UART7EN LL_APB1_GRP1_DisableClock\n * APB1ENR UART8EN LL_APB1_GRP1_DisableClock\n * APB1ENR RTCAPBEN LL_APB1_GRP1_DisableClock * @param Periphs This parameter can be a combination of the following values: * @arg @ref LL_APB1_GRP1_PERIPH_TIM2 (*) * @arg @ref LL_APB1_GRP1_PERIPH_TIM3 (*) * @arg @ref LL_APB1_GRP1_PERIPH_TIM4 (*) * @arg @ref LL_APB1_GRP1_PERIPH_TIM5 * @arg @ref LL_APB1_GRP1_PERIPH_TIM6 (*) * @arg @ref LL_APB1_GRP1_PERIPH_TIM7 (*) * @arg @ref LL_APB1_GRP1_PERIPH_TIM12 (*) * @arg @ref LL_APB1_GRP1_PERIPH_TIM13 (*) * @arg @ref LL_APB1_GRP1_PERIPH_TIM14 (*) * @arg @ref LL_APB1_GRP1_PERIPH_LPTIM1 (*) * @arg @ref LL_APB1_GRP1_PERIPH_WWDG * @arg @ref LL_APB1_GRP1_PERIPH_SPI2 (*) * @arg @ref LL_APB1_GRP1_PERIPH_SPI3 (*) * @arg @ref LL_APB1_GRP1_PERIPH_SPDIFRX (*) * @arg @ref LL_APB1_GRP1_PERIPH_USART2 * @arg @ref LL_APB1_GRP1_PERIPH_USART3 (*) * @arg @ref LL_APB1_GRP1_PERIPH_UART4 (*) * @arg @ref LL_APB1_GRP1_PERIPH_UART5 (*) * @arg @ref LL_APB1_GRP1_PERIPH_I2C1 * @arg @ref LL_APB1_GRP1_PERIPH_I2C2 * @arg @ref LL_APB1_GRP1_PERIPH_I2C3 (*) * @arg @ref LL_APB1_GRP1_PERIPH_FMPI2C1 (*) * @arg @ref LL_APB1_GRP1_PERIPH_CAN1 (*) * @arg @ref LL_APB1_GRP1_PERIPH_CAN2 (*) * @arg @ref LL_APB1_GRP1_PERIPH_CAN3 (*) * @arg @ref LL_APB1_GRP1_PERIPH_CEC (*) * @arg @ref LL_APB1_GRP1_PERIPH_PWR * @arg @ref LL_APB1_GRP1_PERIPH_DAC1 (*) * @arg @ref LL_APB1_GRP1_PERIPH_UART7 (*) * @arg @ref LL_APB1_GRP1_PERIPH_UART8 (*) * @arg @ref LL_APB1_GRP1_PERIPH_RTCAPB (*) * * (*) value not defined in all devices. * @retval None */ __STATIC_INLINE void LL_APB1_GRP1_DisableClock(uint32_t Periphs) { CLEAR_BIT(RCC->APB1ENR, Periphs); } /** * @brief Force APB1 peripherals reset. * @rmtoll APB1RSTR TIM2RST LL_APB1_GRP1_ForceReset\n * APB1RSTR TIM3RST LL_APB1_GRP1_ForceReset\n * APB1RSTR TIM4RST LL_APB1_GRP1_ForceReset\n * APB1RSTR TIM5RST LL_APB1_GRP1_ForceReset\n * APB1RSTR TIM6RST LL_APB1_GRP1_ForceReset\n * APB1RSTR TIM7RST LL_APB1_GRP1_ForceReset\n * APB1RSTR TIM12RST LL_APB1_GRP1_ForceReset\n * APB1RSTR TIM13RST LL_APB1_GRP1_ForceReset\n * APB1RSTR TIM14RST LL_APB1_GRP1_ForceReset\n * APB1RSTR LPTIM1RST LL_APB1_GRP1_ForceReset\n * APB1RSTR WWDGRST LL_APB1_GRP1_ForceReset\n * APB1RSTR SPI2RST LL_APB1_GRP1_ForceReset\n * APB1RSTR SPI3RST LL_APB1_GRP1_ForceReset\n * APB1RSTR SPDIFRXRST LL_APB1_GRP1_ForceReset\n * APB1RSTR USART2RST LL_APB1_GRP1_ForceReset\n * APB1RSTR USART3RST LL_APB1_GRP1_ForceReset\n * APB1RSTR UART4RST LL_APB1_GRP1_ForceReset\n * APB1RSTR UART5RST LL_APB1_GRP1_ForceReset\n * APB1RSTR I2C1RST LL_APB1_GRP1_ForceReset\n * APB1RSTR I2C2RST LL_APB1_GRP1_ForceReset\n * APB1RSTR I2C3RST LL_APB1_GRP1_ForceReset\n * APB1RSTR FMPI2C1RST LL_APB1_GRP1_ForceReset\n * APB1RSTR CAN1RST LL_APB1_GRP1_ForceReset\n * APB1RSTR CAN2RST LL_APB1_GRP1_ForceReset\n * APB1RSTR CAN3RST LL_APB1_GRP1_ForceReset\n * APB1RSTR CECRST LL_APB1_GRP1_ForceReset\n * APB1RSTR PWRRST LL_APB1_GRP1_ForceReset\n * APB1RSTR DACRST LL_APB1_GRP1_ForceReset\n * APB1RSTR UART7RST LL_APB1_GRP1_ForceReset\n * APB1RSTR UART8RST LL_APB1_GRP1_ForceReset * @param Periphs This parameter can be a combination of the following values: * @arg @ref LL_APB1_GRP1_PERIPH_TIM2 (*) * @arg @ref LL_APB1_GRP1_PERIPH_TIM3 (*) * @arg @ref LL_APB1_GRP1_PERIPH_TIM4 (*) * @arg @ref LL_APB1_GRP1_PERIPH_TIM5 * @arg @ref LL_APB1_GRP1_PERIPH_TIM6 (*) * @arg @ref LL_APB1_GRP1_PERIPH_TIM7 (*) * @arg @ref LL_APB1_GRP1_PERIPH_TIM12 (*) * @arg @ref LL_APB1_GRP1_PERIPH_TIM13 (*) * @arg @ref LL_APB1_GRP1_PERIPH_TIM14 (*) * @arg @ref LL_APB1_GRP1_PERIPH_LPTIM1 (*) * @arg @ref LL_APB1_GRP1_PERIPH_WWDG * @arg @ref LL_APB1_GRP1_PERIPH_SPI2 (*) * @arg @ref LL_APB1_GRP1_PERIPH_SPI3 (*) * @arg @ref LL_APB1_GRP1_PERIPH_SPDIFRX (*) * @arg @ref LL_APB1_GRP1_PERIPH_USART2 * @arg @ref LL_APB1_GRP1_PERIPH_USART3 (*) * @arg @ref LL_APB1_GRP1_PERIPH_UART4 (*) * @arg @ref LL_APB1_GRP1_PERIPH_UART5 (*) * @arg @ref LL_APB1_GRP1_PERIPH_I2C1 * @arg @ref LL_APB1_GRP1_PERIPH_I2C2 * @arg @ref LL_APB1_GRP1_PERIPH_I2C3 (*) * @arg @ref LL_APB1_GRP1_PERIPH_FMPI2C1 (*) * @arg @ref LL_APB1_GRP1_PERIPH_CAN1 (*) * @arg @ref LL_APB1_GRP1_PERIPH_CAN2 (*) * @arg @ref LL_APB1_GRP1_PERIPH_CAN3 (*) * @arg @ref LL_APB1_GRP1_PERIPH_CEC (*) * @arg @ref LL_APB1_GRP1_PERIPH_PWR * @arg @ref LL_APB1_GRP1_PERIPH_DAC1 (*) * @arg @ref LL_APB1_GRP1_PERIPH_UART7 (*) * @arg @ref LL_APB1_GRP1_PERIPH_UART8 (*) * * (*) value not defined in all devices. * @retval None */ __STATIC_INLINE void LL_APB1_GRP1_ForceReset(uint32_t Periphs) { SET_BIT(RCC->APB1RSTR, Periphs); } /** * @brief Release APB1 peripherals reset. * @rmtoll APB1RSTR TIM2RST LL_APB1_GRP1_ReleaseReset\n * APB1RSTR TIM3RST LL_APB1_GRP1_ReleaseReset\n * APB1RSTR TIM4RST LL_APB1_GRP1_ReleaseReset\n * APB1RSTR TIM5RST LL_APB1_GRP1_ReleaseReset\n * APB1RSTR TIM6RST LL_APB1_GRP1_ReleaseReset\n * APB1RSTR TIM7RST LL_APB1_GRP1_ReleaseReset\n * APB1RSTR TIM12RST LL_APB1_GRP1_ReleaseReset\n * APB1RSTR TIM13RST LL_APB1_GRP1_ReleaseReset\n * APB1RSTR TIM14RST LL_APB1_GRP1_ReleaseReset\n * APB1RSTR LPTIM1RST LL_APB1_GRP1_ReleaseReset\n * APB1RSTR WWDGRST LL_APB1_GRP1_ReleaseReset\n * APB1RSTR SPI2RST LL_APB1_GRP1_ReleaseReset\n * APB1RSTR SPI3RST LL_APB1_GRP1_ReleaseReset\n * APB1RSTR SPDIFRXRST LL_APB1_GRP1_ReleaseReset\n * APB1RSTR USART2RST LL_APB1_GRP1_ReleaseReset\n * APB1RSTR USART3RST LL_APB1_GRP1_ReleaseReset\n * APB1RSTR UART4RST LL_APB1_GRP1_ReleaseReset\n * APB1RSTR UART5RST LL_APB1_GRP1_ReleaseReset\n * APB1RSTR I2C1RST LL_APB1_GRP1_ReleaseReset\n * APB1RSTR I2C2RST LL_APB1_GRP1_ReleaseReset\n * APB1RSTR I2C3RST LL_APB1_GRP1_ReleaseReset\n * APB1RSTR FMPI2C1RST LL_APB1_GRP1_ReleaseReset\n * APB1RSTR CAN1RST LL_APB1_GRP1_ReleaseReset\n * APB1RSTR CAN2RST LL_APB1_GRP1_ReleaseReset\n * APB1RSTR CAN3RST LL_APB1_GRP1_ReleaseReset\n * APB1RSTR CECRST LL_APB1_GRP1_ReleaseReset\n * APB1RSTR PWRRST LL_APB1_GRP1_ReleaseReset\n * APB1RSTR DACRST LL_APB1_GRP1_ReleaseReset\n * APB1RSTR UART7RST LL_APB1_GRP1_ReleaseReset\n * APB1RSTR UART8RST LL_APB1_GRP1_ReleaseReset * @param Periphs This parameter can be a combination of the following values: * @arg @ref LL_APB1_GRP1_PERIPH_TIM2 (*) * @arg @ref LL_APB1_GRP1_PERIPH_TIM3 (*) * @arg @ref LL_APB1_GRP1_PERIPH_TIM4 (*) * @arg @ref LL_APB1_GRP1_PERIPH_TIM5 * @arg @ref LL_APB1_GRP1_PERIPH_TIM6 (*) * @arg @ref LL_APB1_GRP1_PERIPH_TIM7 (*) * @arg @ref LL_APB1_GRP1_PERIPH_TIM12 (*) * @arg @ref LL_APB1_GRP1_PERIPH_TIM13 (*) * @arg @ref LL_APB1_GRP1_PERIPH_TIM14 (*) * @arg @ref LL_APB1_GRP1_PERIPH_LPTIM1 (*) * @arg @ref LL_APB1_GRP1_PERIPH_WWDG * @arg @ref LL_APB1_GRP1_PERIPH_SPI2 (*) * @arg @ref LL_APB1_GRP1_PERIPH_SPI3 (*) * @arg @ref LL_APB1_GRP1_PERIPH_SPDIFRX (*) * @arg @ref LL_APB1_GRP1_PERIPH_USART2 * @arg @ref LL_APB1_GRP1_PERIPH_USART3 (*) * @arg @ref LL_APB1_GRP1_PERIPH_UART4 (*) * @arg @ref LL_APB1_GRP1_PERIPH_UART5 (*) * @arg @ref LL_APB1_GRP1_PERIPH_I2C1 * @arg @ref LL_APB1_GRP1_PERIPH_I2C2 * @arg @ref LL_APB1_GRP1_PERIPH_I2C3 (*) * @arg @ref LL_APB1_GRP1_PERIPH_FMPI2C1 (*) * @arg @ref LL_APB1_GRP1_PERIPH_CAN1 (*) * @arg @ref LL_APB1_GRP1_PERIPH_CAN2 (*) * @arg @ref LL_APB1_GRP1_PERIPH_CAN3 (*) * @arg @ref LL_APB1_GRP1_PERIPH_CEC (*) * @arg @ref LL_APB1_GRP1_PERIPH_PWR * @arg @ref LL_APB1_GRP1_PERIPH_DAC1 (*) * @arg @ref LL_APB1_GRP1_PERIPH_UART7 (*) * @arg @ref LL_APB1_GRP1_PERIPH_UART8 (*) * * (*) value not defined in all devices. * @retval None */ __STATIC_INLINE void LL_APB1_GRP1_ReleaseReset(uint32_t Periphs) { CLEAR_BIT(RCC->APB1RSTR, Periphs); } /** * @brief Enable APB1 peripheral clocks in low-power mode * @rmtoll APB1LPENR TIM2LPEN LL_APB1_GRP1_EnableClockLowPower\n * APB1LPENR TIM3LPEN LL_APB1_GRP1_EnableClockLowPower\n * APB1LPENR TIM4LPEN LL_APB1_GRP1_EnableClockLowPower\n * APB1LPENR TIM5LPEN LL_APB1_GRP1_EnableClockLowPower\n * APB1LPENR TIM6LPEN LL_APB1_GRP1_EnableClockLowPower\n * APB1LPENR TIM7LPEN LL_APB1_GRP1_EnableClockLowPower\n * APB1LPENR TIM12LPEN LL_APB1_GRP1_EnableClockLowPower\n * APB1LPENR TIM13LPEN LL_APB1_GRP1_EnableClockLowPower\n * APB1LPENR TIM14LPEN LL_APB1_GRP1_EnableClockLowPower\n * APB1LPENR LPTIM1LPEN LL_APB1_GRP1_EnableClockLowPower\n * APB1LPENR WWDGLPEN LL_APB1_GRP1_EnableClockLowPower\n * APB1LPENR SPI2LPEN LL_APB1_GRP1_EnableClockLowPower\n * APB1LPENR SPI3LPEN LL_APB1_GRP1_EnableClockLowPower\n * APB1LPENR SPDIFRXLPEN LL_APB1_GRP1_EnableClockLowPower\n * APB1LPENR USART2LPEN LL_APB1_GRP1_EnableClockLowPower\n * APB1LPENR USART3LPEN LL_APB1_GRP1_EnableClockLowPower\n * APB1LPENR UART4LPEN LL_APB1_GRP1_EnableClockLowPower\n * APB1LPENR UART5LPEN LL_APB1_GRP1_EnableClockLowPower\n * APB1LPENR I2C1LPEN LL_APB1_GRP1_EnableClockLowPower\n * APB1LPENR I2C2LPEN LL_APB1_GRP1_EnableClockLowPower\n * APB1LPENR I2C3LPEN LL_APB1_GRP1_EnableClockLowPower\n * APB1LPENR FMPI2C1LPEN LL_APB1_GRP1_EnableClockLowPower\n * APB1LPENR CAN1LPEN LL_APB1_GRP1_EnableClockLowPower\n * APB1LPENR CAN2LPEN LL_APB1_GRP1_EnableClockLowPower\n * APB1LPENR CAN3LPEN LL_APB1_GRP1_EnableClockLowPower\n * APB1LPENR CECLPEN LL_APB1_GRP1_EnableClockLowPower\n * APB1LPENR PWRLPEN LL_APB1_GRP1_EnableClockLowPower\n * APB1LPENR DACLPEN LL_APB1_GRP1_EnableClockLowPower\n * APB1LPENR UART7LPEN LL_APB1_GRP1_EnableClockLowPower\n * APB1LPENR UART8LPEN LL_APB1_GRP1_EnableClockLowPower\n * APB1LPENR RTCAPBLPEN LL_APB1_GRP1_EnableClockLowPower * @param Periphs This parameter can be a combination of the following values: * @arg @ref LL_APB1_GRP1_PERIPH_TIM2 (*) * @arg @ref LL_APB1_GRP1_PERIPH_TIM3 (*) * @arg @ref LL_APB1_GRP1_PERIPH_TIM4 (*) * @arg @ref LL_APB1_GRP1_PERIPH_TIM5 * @arg @ref LL_APB1_GRP1_PERIPH_TIM6 (*) * @arg @ref LL_APB1_GRP1_PERIPH_TIM7 (*) * @arg @ref LL_APB1_GRP1_PERIPH_TIM12 (*) * @arg @ref LL_APB1_GRP1_PERIPH_TIM13 (*) * @arg @ref LL_APB1_GRP1_PERIPH_TIM14 (*) * @arg @ref LL_APB1_GRP1_PERIPH_LPTIM1 (*) * @arg @ref LL_APB1_GRP1_PERIPH_WWDG * @arg @ref LL_APB1_GRP1_PERIPH_SPI2 (*) * @arg @ref LL_APB1_GRP1_PERIPH_SPI3 (*) * @arg @ref LL_APB1_GRP1_PERIPH_SPDIFRX (*) * @arg @ref LL_APB1_GRP1_PERIPH_USART2 * @arg @ref LL_APB1_GRP1_PERIPH_USART3 (*) * @arg @ref LL_APB1_GRP1_PERIPH_UART4 (*) * @arg @ref LL_APB1_GRP1_PERIPH_UART5 (*) * @arg @ref LL_APB1_GRP1_PERIPH_I2C1 * @arg @ref LL_APB1_GRP1_PERIPH_I2C2 * @arg @ref LL_APB1_GRP1_PERIPH_I2C3 (*) * @arg @ref LL_APB1_GRP1_PERIPH_FMPI2C1 (*) * @arg @ref LL_APB1_GRP1_PERIPH_CAN1 (*) * @arg @ref LL_APB1_GRP1_PERIPH_CAN2 (*) * @arg @ref LL_APB1_GRP1_PERIPH_CAN3 (*) * @arg @ref LL_APB1_GRP1_PERIPH_CEC (*) * @arg @ref LL_APB1_GRP1_PERIPH_PWR * @arg @ref LL_APB1_GRP1_PERIPH_DAC1 (*) * @arg @ref LL_APB1_GRP1_PERIPH_UART7 (*) * @arg @ref LL_APB1_GRP1_PERIPH_UART8 (*) * @arg @ref LL_APB1_GRP1_PERIPH_RTCAPB (*) * * (*) value not defined in all devices. * @retval None */ __STATIC_INLINE void LL_APB1_GRP1_EnableClockLowPower(uint32_t Periphs) { __IO uint32_t tmpreg; SET_BIT(RCC->APB1LPENR, Periphs); /* Delay after an RCC peripheral clock enabling */ tmpreg = READ_BIT(RCC->APB1LPENR, Periphs); (void)tmpreg; } /** * @brief Disable APB1 peripheral clocks in low-power mode * @rmtoll APB1LPENR TIM2LPEN LL_APB1_GRP1_DisableClockLowPower\n * APB1LPENR TIM3LPEN LL_APB1_GRP1_DisableClockLowPower\n * APB1LPENR TIM4LPEN LL_APB1_GRP1_DisableClockLowPower\n * APB1LPENR TIM5LPEN LL_APB1_GRP1_DisableClockLowPower\n * APB1LPENR TIM6LPEN LL_APB1_GRP1_DisableClockLowPower\n * APB1LPENR TIM7LPEN LL_APB1_GRP1_DisableClockLowPower\n * APB1LPENR TIM12LPEN LL_APB1_GRP1_DisableClockLowPower\n * APB1LPENR TIM13LPEN LL_APB1_GRP1_DisableClockLowPower\n * APB1LPENR TIM14LPEN LL_APB1_GRP1_DisableClockLowPower\n * APB1LPENR LPTIM1LPEN LL_APB1_GRP1_DisableClockLowPower\n * APB1LPENR WWDGLPEN LL_APB1_GRP1_DisableClockLowPower\n * APB1LPENR SPI2LPEN LL_APB1_GRP1_DisableClockLowPower\n * APB1LPENR SPI3LPEN LL_APB1_GRP1_DisableClockLowPower\n * APB1LPENR SPDIFRXLPEN LL_APB1_GRP1_DisableClockLowPower\n * APB1LPENR USART2LPEN LL_APB1_GRP1_DisableClockLowPower\n * APB1LPENR USART3LPEN LL_APB1_GRP1_DisableClockLowPower\n * APB1LPENR UART4LPEN LL_APB1_GRP1_DisableClockLowPower\n * APB1LPENR UART5LPEN LL_APB1_GRP1_DisableClockLowPower\n * APB1LPENR I2C1LPEN LL_APB1_GRP1_DisableClockLowPower\n * APB1LPENR I2C2LPEN LL_APB1_GRP1_DisableClockLowPower\n * APB1LPENR I2C3LPEN LL_APB1_GRP1_DisableClockLowPower\n * APB1LPENR FMPI2C1LPEN LL_APB1_GRP1_DisableClockLowPower\n * APB1LPENR CAN1LPEN LL_APB1_GRP1_DisableClockLowPower\n * APB1LPENR CAN2LPEN LL_APB1_GRP1_DisableClockLowPower\n * APB1LPENR CAN3LPEN LL_APB1_GRP1_DisableClockLowPower\n * APB1LPENR CECLPEN LL_APB1_GRP1_DisableClockLowPower\n * APB1LPENR PWRLPEN LL_APB1_GRP1_DisableClockLowPower\n * APB1LPENR DACLPEN LL_APB1_GRP1_DisableClockLowPower\n * APB1LPENR UART7LPEN LL_APB1_GRP1_DisableClockLowPower\n * APB1LPENR UART8LPEN LL_APB1_GRP1_DisableClockLowPower\n * APB1LPENR RTCAPBLPEN LL_APB1_GRP1_DisableClockLowPower * @param Periphs This parameter can be a combination of the following values: * @arg @ref LL_APB1_GRP1_PERIPH_TIM2 (*) * @arg @ref LL_APB1_GRP1_PERIPH_TIM3 (*) * @arg @ref LL_APB1_GRP1_PERIPH_TIM4 (*) * @arg @ref LL_APB1_GRP1_PERIPH_TIM5 * @arg @ref LL_APB1_GRP1_PERIPH_TIM6 (*) * @arg @ref LL_APB1_GRP1_PERIPH_TIM7 (*) * @arg @ref LL_APB1_GRP1_PERIPH_TIM12 (*) * @arg @ref LL_APB1_GRP1_PERIPH_TIM13 (*) * @arg @ref LL_APB1_GRP1_PERIPH_TIM14 (*) * @arg @ref LL_APB1_GRP1_PERIPH_LPTIM1 (*) * @arg @ref LL_APB1_GRP1_PERIPH_WWDG * @arg @ref LL_APB1_GRP1_PERIPH_SPI2 (*) * @arg @ref LL_APB1_GRP1_PERIPH_SPI3 (*) * @arg @ref LL_APB1_GRP1_PERIPH_SPDIFRX (*) * @arg @ref LL_APB1_GRP1_PERIPH_USART2 * @arg @ref LL_APB1_GRP1_PERIPH_USART3 (*) * @arg @ref LL_APB1_GRP1_PERIPH_UART4 (*) * @arg @ref LL_APB1_GRP1_PERIPH_UART5 (*) * @arg @ref LL_APB1_GRP1_PERIPH_I2C1 * @arg @ref LL_APB1_GRP1_PERIPH_I2C2 * @arg @ref LL_APB1_GRP1_PERIPH_I2C3 (*) * @arg @ref LL_APB1_GRP1_PERIPH_FMPI2C1 (*) * @arg @ref LL_APB1_GRP1_PERIPH_CAN1 (*) * @arg @ref LL_APB1_GRP1_PERIPH_CAN2 (*) * @arg @ref LL_APB1_GRP1_PERIPH_CAN3 (*) * @arg @ref LL_APB1_GRP1_PERIPH_CEC (*) * @arg @ref LL_APB1_GRP1_PERIPH_PWR * @arg @ref LL_APB1_GRP1_PERIPH_DAC1 (*) * @arg @ref LL_APB1_GRP1_PERIPH_UART7 (*) * @arg @ref LL_APB1_GRP1_PERIPH_UART8 (*) * @arg @ref LL_APB1_GRP1_PERIPH_RTCAPB (*) * * (*) value not defined in all devices. * @retval None */ __STATIC_INLINE void LL_APB1_GRP1_DisableClockLowPower(uint32_t Periphs) { CLEAR_BIT(RCC->APB1LPENR, Periphs); } /** * @} */ /** @defgroup BUS_LL_EF_APB2 APB2 * @{ */ /** * @brief Enable APB2 peripherals clock. * @rmtoll APB2ENR TIM1EN LL_APB2_GRP1_EnableClock\n * APB2ENR TIM8EN LL_APB2_GRP1_EnableClock\n * APB2ENR USART1EN LL_APB2_GRP1_EnableClock\n * APB2ENR USART6EN LL_APB2_GRP1_EnableClock\n * APB2ENR UART9EN LL_APB2_GRP1_EnableClock\n * APB2ENR UART10EN LL_APB2_GRP1_EnableClock\n * APB2ENR ADC1EN LL_APB2_GRP1_EnableClock\n * APB2ENR ADC2EN LL_APB2_GRP1_EnableClock\n * APB2ENR ADC3EN LL_APB2_GRP1_EnableClock\n * APB2ENR SDIOEN LL_APB2_GRP1_EnableClock\n * APB2ENR SPI1EN LL_APB2_GRP1_EnableClock\n * APB2ENR SPI4EN LL_APB2_GRP1_EnableClock\n * APB2ENR SYSCFGEN LL_APB2_GRP1_EnableClock\n * APB2ENR EXTITEN LL_APB2_GRP1_EnableClock\n * APB2ENR TIM9EN LL_APB2_GRP1_EnableClock\n * APB2ENR TIM10EN LL_APB2_GRP1_EnableClock\n * APB2ENR TIM11EN LL_APB2_GRP1_EnableClock\n * APB2ENR SPI5EN LL_APB2_GRP1_EnableClock\n * APB2ENR SPI6EN LL_APB2_GRP1_EnableClock\n * APB2ENR SAI1EN LL_APB2_GRP1_EnableClock\n * APB2ENR SAI2EN LL_APB2_GRP1_EnableClock\n * APB2ENR LTDCEN LL_APB2_GRP1_EnableClock\n * APB2ENR DSIEN LL_APB2_GRP1_EnableClock\n * APB2ENR DFSDM1EN LL_APB2_GRP1_EnableClock\n * APB2ENR DFSDM2EN LL_APB2_GRP1_EnableClock * @param Periphs This parameter can be a combination of the following values: * @arg @ref LL_APB2_GRP1_PERIPH_TIM1 * @arg @ref LL_APB2_GRP1_PERIPH_TIM8 (*) * @arg @ref LL_APB2_GRP1_PERIPH_USART1 * @arg @ref LL_APB2_GRP1_PERIPH_USART6 (*) * @arg @ref LL_APB2_GRP1_PERIPH_UART9 (*) * @arg @ref LL_APB2_GRP1_PERIPH_UART10 (*) * @arg @ref LL_APB2_GRP1_PERIPH_ADC1 * @arg @ref LL_APB2_GRP1_PERIPH_ADC2 (*) * @arg @ref LL_APB2_GRP1_PERIPH_ADC3 (*) * @arg @ref LL_APB2_GRP1_PERIPH_SDIO (*) * @arg @ref LL_APB2_GRP1_PERIPH_SPI1 * @arg @ref LL_APB2_GRP1_PERIPH_SPI4 (*) * @arg @ref LL_APB2_GRP1_PERIPH_SYSCFG * @arg @ref LL_APB2_GRP1_PERIPH_EXTI (*) * @arg @ref LL_APB2_GRP1_PERIPH_TIM9 * @arg @ref LL_APB2_GRP1_PERIPH_TIM10 (*) * @arg @ref LL_APB2_GRP1_PERIPH_TIM11 * @arg @ref LL_APB2_GRP1_PERIPH_SPI5 (*) * @arg @ref LL_APB2_GRP1_PERIPH_SPI6 (*) * @arg @ref LL_APB2_GRP1_PERIPH_SAI1 (*) * @arg @ref LL_APB2_GRP1_PERIPH_SAI2 (*) * @arg @ref LL_APB2_GRP1_PERIPH_LTDC (*) * @arg @ref LL_APB2_GRP1_PERIPH_DSI (*) * @arg @ref LL_APB2_GRP1_PERIPH_DFSDM1 (*) * @arg @ref LL_APB2_GRP1_PERIPH_DFSDM2 (*) * * (*) value not defined in all devices. * @retval None */ __STATIC_INLINE void LL_APB2_GRP1_EnableClock(uint32_t Periphs) { __IO uint32_t tmpreg; SET_BIT(RCC->APB2ENR, Periphs); /* Delay after an RCC peripheral clock enabling */ tmpreg = READ_BIT(RCC->APB2ENR, Periphs); (void)tmpreg; } /** * @brief Check if APB2 peripheral clock is enabled or not * @rmtoll APB2ENR TIM1EN LL_APB2_GRP1_IsEnabledClock\n * APB2ENR TIM8EN LL_APB2_GRP1_IsEnabledClock\n * APB2ENR USART1EN LL_APB2_GRP1_IsEnabledClock\n * APB2ENR USART6EN LL_APB2_GRP1_IsEnabledClock\n * APB2ENR UART9EN LL_APB2_GRP1_IsEnabledClock\n * APB2ENR UART10EN LL_APB2_GRP1_IsEnabledClock\n * APB2ENR ADC1EN LL_APB2_GRP1_IsEnabledClock\n * APB2ENR ADC2EN LL_APB2_GRP1_IsEnabledClock\n * APB2ENR ADC3EN LL_APB2_GRP1_IsEnabledClock\n * APB2ENR SDIOEN LL_APB2_GRP1_IsEnabledClock\n * APB2ENR SPI1EN LL_APB2_GRP1_IsEnabledClock\n * APB2ENR SPI4EN LL_APB2_GRP1_IsEnabledClock\n * APB2ENR SYSCFGEN LL_APB2_GRP1_IsEnabledClock\n * APB2ENR EXTITEN LL_APB2_GRP1_IsEnabledClock\n * APB2ENR TIM9EN LL_APB2_GRP1_IsEnabledClock\n * APB2ENR TIM10EN LL_APB2_GRP1_IsEnabledClock\n * APB2ENR TIM11EN LL_APB2_GRP1_IsEnabledClock\n * APB2ENR SPI5EN LL_APB2_GRP1_IsEnabledClock\n * APB2ENR SPI6EN LL_APB2_GRP1_IsEnabledClock\n * APB2ENR SAI1EN LL_APB2_GRP1_IsEnabledClock\n * APB2ENR SAI2EN LL_APB2_GRP1_IsEnabledClock\n * APB2ENR LTDCEN LL_APB2_GRP1_IsEnabledClock\n * APB2ENR DSIEN LL_APB2_GRP1_IsEnabledClock\n * APB2ENR DFSDM1EN LL_APB2_GRP1_IsEnabledClock\n * APB2ENR DFSDM2EN LL_APB2_GRP1_IsEnabledClock * @param Periphs This parameter can be a combination of the following values: * @arg @ref LL_APB2_GRP1_PERIPH_TIM1 * @arg @ref LL_APB2_GRP1_PERIPH_TIM8 (*) * @arg @ref LL_APB2_GRP1_PERIPH_USART1 * @arg @ref LL_APB2_GRP1_PERIPH_USART6 (*) * @arg @ref LL_APB2_GRP1_PERIPH_UART9 (*) * @arg @ref LL_APB2_GRP1_PERIPH_UART10 (*) * @arg @ref LL_APB2_GRP1_PERIPH_ADC1 * @arg @ref LL_APB2_GRP1_PERIPH_ADC2 (*) * @arg @ref LL_APB2_GRP1_PERIPH_ADC3 (*) * @arg @ref LL_APB2_GRP1_PERIPH_SDIO (*) * @arg @ref LL_APB2_GRP1_PERIPH_SPI1 * @arg @ref LL_APB2_GRP1_PERIPH_SPI4 (*) * @arg @ref LL_APB2_GRP1_PERIPH_SYSCFG * @arg @ref LL_APB2_GRP1_PERIPH_EXTI (*) * @arg @ref LL_APB2_GRP1_PERIPH_TIM9 * @arg @ref LL_APB2_GRP1_PERIPH_TIM10 (*) * @arg @ref LL_APB2_GRP1_PERIPH_TIM11 * @arg @ref LL_APB2_GRP1_PERIPH_SPI5 (*) * @arg @ref LL_APB2_GRP1_PERIPH_SPI6 (*) * @arg @ref LL_APB2_GRP1_PERIPH_SAI1 (*) * @arg @ref LL_APB2_GRP1_PERIPH_SAI2 (*) * @arg @ref LL_APB2_GRP1_PERIPH_LTDC (*) * @arg @ref LL_APB2_GRP1_PERIPH_DSI (*) * @arg @ref LL_APB2_GRP1_PERIPH_DFSDM1 (*) * @arg @ref LL_APB2_GRP1_PERIPH_DFSDM2 (*) * * (*) value not defined in all devices. * @retval State of Periphs (1 or 0). */ __STATIC_INLINE uint32_t LL_APB2_GRP1_IsEnabledClock(uint32_t Periphs) { return (READ_BIT(RCC->APB2ENR, Periphs) == Periphs); } /** * @brief Disable APB2 peripherals clock. * @rmtoll APB2ENR TIM1EN LL_APB2_GRP1_DisableClock\n * APB2ENR TIM8EN LL_APB2_GRP1_DisableClock\n * APB2ENR USART1EN LL_APB2_GRP1_DisableClock\n * APB2ENR USART6EN LL_APB2_GRP1_DisableClock\n * APB2ENR UART9EN LL_APB2_GRP1_DisableClock\n * APB2ENR UART10EN LL_APB2_GRP1_DisableClock\n * APB2ENR ADC1EN LL_APB2_GRP1_DisableClock\n * APB2ENR ADC2EN LL_APB2_GRP1_DisableClock\n * APB2ENR ADC3EN LL_APB2_GRP1_DisableClock\n * APB2ENR SDIOEN LL_APB2_GRP1_DisableClock\n * APB2ENR SPI1EN LL_APB2_GRP1_DisableClock\n * APB2ENR SPI4EN LL_APB2_GRP1_DisableClock\n * APB2ENR SYSCFGEN LL_APB2_GRP1_DisableClock\n * APB2ENR EXTITEN LL_APB2_GRP1_DisableClock\n * APB2ENR TIM9EN LL_APB2_GRP1_DisableClock\n * APB2ENR TIM10EN LL_APB2_GRP1_DisableClock\n * APB2ENR TIM11EN LL_APB2_GRP1_DisableClock\n * APB2ENR SPI5EN LL_APB2_GRP1_DisableClock\n * APB2ENR SPI6EN LL_APB2_GRP1_DisableClock\n * APB2ENR SAI1EN LL_APB2_GRP1_DisableClock\n * APB2ENR SAI2EN LL_APB2_GRP1_DisableClock\n * APB2ENR LTDCEN LL_APB2_GRP1_DisableClock\n * APB2ENR DSIEN LL_APB2_GRP1_DisableClock\n * APB2ENR DFSDM1EN LL_APB2_GRP1_DisableClock\n * APB2ENR DFSDM2EN LL_APB2_GRP1_DisableClock * @param Periphs This parameter can be a combination of the following values: * @arg @ref LL_APB2_GRP1_PERIPH_TIM1 * @arg @ref LL_APB2_GRP1_PERIPH_TIM8 (*) * @arg @ref LL_APB2_GRP1_PERIPH_USART1 * @arg @ref LL_APB2_GRP1_PERIPH_USART6 (*) * @arg @ref LL_APB2_GRP1_PERIPH_UART9 (*) * @arg @ref LL_APB2_GRP1_PERIPH_UART10 (*) * @arg @ref LL_APB2_GRP1_PERIPH_ADC1 * @arg @ref LL_APB2_GRP1_PERIPH_ADC2 (*) * @arg @ref LL_APB2_GRP1_PERIPH_ADC3 (*) * @arg @ref LL_APB2_GRP1_PERIPH_SDIO (*) * @arg @ref LL_APB2_GRP1_PERIPH_SPI1 * @arg @ref LL_APB2_GRP1_PERIPH_SPI4 (*) * @arg @ref LL_APB2_GRP1_PERIPH_SYSCFG * @arg @ref LL_APB2_GRP1_PERIPH_EXTI (*) * @arg @ref LL_APB2_GRP1_PERIPH_TIM9 * @arg @ref LL_APB2_GRP1_PERIPH_TIM10 (*) * @arg @ref LL_APB2_GRP1_PERIPH_TIM11 * @arg @ref LL_APB2_GRP1_PERIPH_SPI5 (*) * @arg @ref LL_APB2_GRP1_PERIPH_SPI6 (*) * @arg @ref LL_APB2_GRP1_PERIPH_SAI1 (*) * @arg @ref LL_APB2_GRP1_PERIPH_SAI2 (*) * @arg @ref LL_APB2_GRP1_PERIPH_LTDC (*) * @arg @ref LL_APB2_GRP1_PERIPH_DSI (*) * @arg @ref LL_APB2_GRP1_PERIPH_DFSDM1 (*) * @arg @ref LL_APB2_GRP1_PERIPH_DFSDM2 (*) * * (*) value not defined in all devices. * @retval None */ __STATIC_INLINE void LL_APB2_GRP1_DisableClock(uint32_t Periphs) { CLEAR_BIT(RCC->APB2ENR, Periphs); } /** * @brief Force APB2 peripherals reset. * @rmtoll APB2RSTR TIM1RST LL_APB2_GRP1_ForceReset\n * APB2RSTR TIM8RST LL_APB2_GRP1_ForceReset\n * APB2RSTR USART1RST LL_APB2_GRP1_ForceReset\n * APB2RSTR USART6RST LL_APB2_GRP1_ForceReset\n * APB2RSTR UART9RST LL_APB2_GRP1_ForceReset\n * APB2RSTR UART10RST LL_APB2_GRP1_ForceReset\n * APB2RSTR ADCRST LL_APB2_GRP1_ForceReset\n * APB2RSTR SDIORST LL_APB2_GRP1_ForceReset\n * APB2RSTR SPI1RST LL_APB2_GRP1_ForceReset\n * APB2RSTR SPI4RST LL_APB2_GRP1_ForceReset\n * APB2RSTR SYSCFGRST LL_APB2_GRP1_ForceReset\n * APB2RSTR TIM9RST LL_APB2_GRP1_ForceReset\n * APB2RSTR TIM10RST LL_APB2_GRP1_ForceReset\n * APB2RSTR TIM11RST LL_APB2_GRP1_ForceReset\n * APB2RSTR SPI5RST LL_APB2_GRP1_ForceReset\n * APB2RSTR SPI6RST LL_APB2_GRP1_ForceReset\n * APB2RSTR SAI1RST LL_APB2_GRP1_ForceReset\n * APB2RSTR SAI2RST LL_APB2_GRP1_ForceReset\n * APB2RSTR LTDCRST LL_APB2_GRP1_ForceReset\n * APB2RSTR DSIRST LL_APB2_GRP1_ForceReset\n * APB2RSTR DFSDM1RST LL_APB2_GRP1_ForceReset\n * APB2RSTR DFSDM2RST LL_APB2_GRP1_ForceReset * @param Periphs This parameter can be a combination of the following values: * @arg @ref LL_APB2_GRP1_PERIPH_ALL * @arg @ref LL_APB2_GRP1_PERIPH_TIM1 * @arg @ref LL_APB2_GRP1_PERIPH_TIM8 (*) * @arg @ref LL_APB2_GRP1_PERIPH_USART1 * @arg @ref LL_APB2_GRP1_PERIPH_USART6 (*) * @arg @ref LL_APB2_GRP1_PERIPH_UART9 (*) * @arg @ref LL_APB2_GRP1_PERIPH_UART10 (*) * @arg @ref LL_APB2_GRP1_PERIPH_ADC * @arg @ref LL_APB2_GRP1_PERIPH_SDIO (*) * @arg @ref LL_APB2_GRP1_PERIPH_SPI1 * @arg @ref LL_APB2_GRP1_PERIPH_SPI4 (*) * @arg @ref LL_APB2_GRP1_PERIPH_SYSCFG * @arg @ref LL_APB2_GRP1_PERIPH_TIM9 * @arg @ref LL_APB2_GRP1_PERIPH_TIM10 (*) * @arg @ref LL_APB2_GRP1_PERIPH_TIM11 * @arg @ref LL_APB2_GRP1_PERIPH_SPI5 (*) * @arg @ref LL_APB2_GRP1_PERIPH_SPI6 (*) * @arg @ref LL_APB2_GRP1_PERIPH_SAI1 (*) * @arg @ref LL_APB2_GRP1_PERIPH_SAI2 (*) * @arg @ref LL_APB2_GRP1_PERIPH_LTDC (*) * @arg @ref LL_APB2_GRP1_PERIPH_DSI (*) * @arg @ref LL_APB2_GRP1_PERIPH_DFSDM1 (*) * @arg @ref LL_APB2_GRP1_PERIPH_DFSDM2 (*) * * (*) value not defined in all devices. * @retval None */ __STATIC_INLINE void LL_APB2_GRP1_ForceReset(uint32_t Periphs) { SET_BIT(RCC->APB2RSTR, Periphs); } /** * @brief Release APB2 peripherals reset. * @rmtoll APB2RSTR TIM1RST LL_APB2_GRP1_ReleaseReset\n * APB2RSTR TIM8RST LL_APB2_GRP1_ReleaseReset\n * APB2RSTR USART1RST LL_APB2_GRP1_ReleaseReset\n * APB2RSTR USART6RST LL_APB2_GRP1_ReleaseReset\n * APB2RSTR UART9RST LL_APB2_GRP1_ReleaseReset\n * APB2RSTR UART10RST LL_APB2_GRP1_ReleaseReset\n * APB2RSTR ADCRST LL_APB2_GRP1_ReleaseReset\n * APB2RSTR SDIORST LL_APB2_GRP1_ReleaseReset\n * APB2RSTR SPI1RST LL_APB2_GRP1_ReleaseReset\n * APB2RSTR SPI4RST LL_APB2_GRP1_ReleaseReset\n * APB2RSTR SYSCFGRST LL_APB2_GRP1_ReleaseReset\n * APB2RSTR TIM9RST LL_APB2_GRP1_ReleaseReset\n * APB2RSTR TIM10RST LL_APB2_GRP1_ReleaseReset\n * APB2RSTR TIM11RST LL_APB2_GRP1_ReleaseReset\n * APB2RSTR SPI5RST LL_APB2_GRP1_ReleaseReset\n * APB2RSTR SPI6RST LL_APB2_GRP1_ReleaseReset\n * APB2RSTR SAI1RST LL_APB2_GRP1_ReleaseReset\n * APB2RSTR SAI2RST LL_APB2_GRP1_ReleaseReset\n * APB2RSTR LTDCRST LL_APB2_GRP1_ReleaseReset\n * APB2RSTR DSIRST LL_APB2_GRP1_ReleaseReset\n * APB2RSTR DFSDM1RST LL_APB2_GRP1_ReleaseReset\n * APB2RSTR DFSDM2RST LL_APB2_GRP1_ReleaseReset * @param Periphs This parameter can be a combination of the following values: * @arg @ref LL_APB2_GRP1_PERIPH_ALL * @arg @ref LL_APB2_GRP1_PERIPH_TIM1 * @arg @ref LL_APB2_GRP1_PERIPH_TIM8 (*) * @arg @ref LL_APB2_GRP1_PERIPH_USART1 * @arg @ref LL_APB2_GRP1_PERIPH_USART6 (*) * @arg @ref LL_APB2_GRP1_PERIPH_UART9 (*) * @arg @ref LL_APB2_GRP1_PERIPH_UART10 (*) * @arg @ref LL_APB2_GRP1_PERIPH_ADC * @arg @ref LL_APB2_GRP1_PERIPH_SDIO (*) * @arg @ref LL_APB2_GRP1_PERIPH_SPI1 * @arg @ref LL_APB2_GRP1_PERIPH_SPI4 (*) * @arg @ref LL_APB2_GRP1_PERIPH_SYSCFG * @arg @ref LL_APB2_GRP1_PERIPH_EXTI (*) * @arg @ref LL_APB2_GRP1_PERIPH_TIM9 * @arg @ref LL_APB2_GRP1_PERIPH_TIM10 (*) * @arg @ref LL_APB2_GRP1_PERIPH_TIM11 * @arg @ref LL_APB2_GRP1_PERIPH_SPI5 (*) * @arg @ref LL_APB2_GRP1_PERIPH_SPI6 (*) * @arg @ref LL_APB2_GRP1_PERIPH_SAI1 (*) * @arg @ref LL_APB2_GRP1_PERIPH_SAI2 (*) * @arg @ref LL_APB2_GRP1_PERIPH_LTDC (*) * @arg @ref LL_APB2_GRP1_PERIPH_DSI (*) * @arg @ref LL_APB2_GRP1_PERIPH_DFSDM1 (*) * @arg @ref LL_APB2_GRP1_PERIPH_DFSDM2 (*) * * (*) value not defined in all devices. * @retval None */ __STATIC_INLINE void LL_APB2_GRP1_ReleaseReset(uint32_t Periphs) { CLEAR_BIT(RCC->APB2RSTR, Periphs); } /** * @brief Enable APB2 peripheral clocks in low-power mode * @rmtoll APB2LPENR TIM1LPEN LL_APB2_GRP1_EnableClockLowPower\n * APB2LPENR TIM8LPEN LL_APB2_GRP1_EnableClockLowPower\n * APB2LPENR USART1LPEN LL_APB2_GRP1_EnableClockLowPower\n * APB2LPENR USART6LPEN LL_APB2_GRP1_EnableClockLowPower\n * APB2LPENR UART9LPEN LL_APB2_GRP1_EnableClockLowPower\n * APB2LPENR UART10LPEN LL_APB2_GRP1_EnableClockLowPower\n * APB2LPENR ADC1LPEN LL_APB2_GRP1_EnableClockLowPower\n * APB2LPENR ADC2LPEN LL_APB2_GRP1_EnableClockLowPower\n * APB2LPENR ADC3LPEN LL_APB2_GRP1_EnableClockLowPower\n * APB2LPENR SDIOLPEN LL_APB2_GRP1_EnableClockLowPower\n * APB2LPENR SPI1LPEN LL_APB2_GRP1_EnableClockLowPower\n * APB2LPENR SPI4LPEN LL_APB2_GRP1_EnableClockLowPower\n * APB2LPENR SYSCFGLPEN LL_APB2_GRP1_EnableClockLowPower\n * APB2LPENR EXTITLPEN LL_APB2_GRP1_EnableClockLowPower\n * APB2LPENR TIM9LPEN LL_APB2_GRP1_EnableClockLowPower\n * APB2LPENR TIM10LPEN LL_APB2_GRP1_EnableClockLowPower\n * APB2LPENR TIM11LPEN LL_APB2_GRP1_EnableClockLowPower\n * APB2LPENR SPI5LPEN LL_APB2_GRP1_EnableClockLowPower\n * APB2LPENR SPI6LPEN LL_APB2_GRP1_EnableClockLowPower\n * APB2LPENR SAI1LPEN LL_APB2_GRP1_EnableClockLowPower\n * APB2LPENR SAI2LPEN LL_APB2_GRP1_EnableClockLowPower\n * APB2LPENR LTDCLPEN LL_APB2_GRP1_EnableClockLowPower\n * APB2LPENR DSILPEN LL_APB2_GRP1_EnableClockLowPower\n * APB2LPENR DFSDM1LPEN LL_APB2_GRP1_EnableClockLowPower\n * APB2LPENR DSILPEN LL_APB2_GRP1_EnableClockLowPower\n * APB2LPENR DFSDM2LPEN LL_APB2_GRP1_EnableClockLowPower * @param Periphs This parameter can be a combination of the following values: * @arg @ref LL_APB2_GRP1_PERIPH_TIM1 * @arg @ref LL_APB2_GRP1_PERIPH_TIM8 (*) * @arg @ref LL_APB2_GRP1_PERIPH_USART1 * @arg @ref LL_APB2_GRP1_PERIPH_USART6 (*) * @arg @ref LL_APB2_GRP1_PERIPH_UART9 (*) * @arg @ref LL_APB2_GRP1_PERIPH_UART10 (*) * @arg @ref LL_APB2_GRP1_PERIPH_ADC1 * @arg @ref LL_APB2_GRP1_PERIPH_ADC2 (*) * @arg @ref LL_APB2_GRP1_PERIPH_ADC3 (*) * @arg @ref LL_APB2_GRP1_PERIPH_SDIO (*) * @arg @ref LL_APB2_GRP1_PERIPH_SPI1 * @arg @ref LL_APB2_GRP1_PERIPH_SPI4 (*) * @arg @ref LL_APB2_GRP1_PERIPH_SYSCFG * @arg @ref LL_APB2_GRP1_PERIPH_EXTI (*) * @arg @ref LL_APB2_GRP1_PERIPH_TIM9 * @arg @ref LL_APB2_GRP1_PERIPH_TIM10 (*) * @arg @ref LL_APB2_GRP1_PERIPH_TIM11 * @arg @ref LL_APB2_GRP1_PERIPH_SPI5 (*) * @arg @ref LL_APB2_GRP1_PERIPH_SPI6 (*) * @arg @ref LL_APB2_GRP1_PERIPH_SAI1 (*) * @arg @ref LL_APB2_GRP1_PERIPH_SAI2 (*) * @arg @ref LL_APB2_GRP1_PERIPH_LTDC (*) * @arg @ref LL_APB2_GRP1_PERIPH_DSI (*) * @arg @ref LL_APB2_GRP1_PERIPH_DFSDM1 (*) * @arg @ref LL_APB2_GRP1_PERIPH_DFSDM2 (*) * * (*) value not defined in all devices. * @retval None */ __STATIC_INLINE void LL_APB2_GRP1_EnableClockLowPower(uint32_t Periphs) { __IO uint32_t tmpreg; SET_BIT(RCC->APB2LPENR, Periphs); /* Delay after an RCC peripheral clock enabling */ tmpreg = READ_BIT(RCC->APB2LPENR, Periphs); (void)tmpreg; } /** * @brief Disable APB2 peripheral clocks in low-power mode * @rmtoll APB2LPENR TIM1LPEN LL_APB2_GRP1_DisableClockLowPower\n * APB2LPENR TIM8LPEN LL_APB2_GRP1_DisableClockLowPower\n * APB2LPENR USART1LPEN LL_APB2_GRP1_DisableClockLowPower\n * APB2LPENR USART6LPEN LL_APB2_GRP1_DisableClockLowPower\n * APB2LPENR UART9LPEN LL_APB2_GRP1_DisableClockLowPower\n * APB2LPENR UART10LPEN LL_APB2_GRP1_DisableClockLowPower\n * APB2LPENR ADC1LPEN LL_APB2_GRP1_DisableClockLowPower\n * APB2LPENR ADC2LPEN LL_APB2_GRP1_DisableClockLowPower\n * APB2LPENR ADC3LPEN LL_APB2_GRP1_DisableClockLowPower\n * APB2LPENR SDIOLPEN LL_APB2_GRP1_DisableClockLowPower\n * APB2LPENR SPI1LPEN LL_APB2_GRP1_DisableClockLowPower\n * APB2LPENR SPI4LPEN LL_APB2_GRP1_DisableClockLowPower\n * APB2LPENR SYSCFGLPEN LL_APB2_GRP1_DisableClockLowPower\n * APB2LPENR EXTITLPEN LL_APB2_GRP1_DisableClockLowPower\n * APB2LPENR TIM9LPEN LL_APB2_GRP1_DisableClockLowPower\n * APB2LPENR TIM10LPEN LL_APB2_GRP1_DisableClockLowPower\n * APB2LPENR TIM11LPEN LL_APB2_GRP1_DisableClockLowPower\n * APB2LPENR SPI5LPEN LL_APB2_GRP1_DisableClockLowPower\n * APB2LPENR SPI6LPEN LL_APB2_GRP1_DisableClockLowPower\n * APB2LPENR SAI1LPEN LL_APB2_GRP1_DisableClockLowPower\n * APB2LPENR SAI2LPEN LL_APB2_GRP1_DisableClockLowPower\n * APB2LPENR LTDCLPEN LL_APB2_GRP1_DisableClockLowPower\n * APB2LPENR DSILPEN LL_APB2_GRP1_DisableClockLowPower\n * APB2LPENR DFSDM1LPEN LL_APB2_GRP1_DisableClockLowPower\n * APB2LPENR DSILPEN LL_APB2_GRP1_DisableClockLowPower\n * APB2LPENR DFSDM2LPEN LL_APB2_GRP1_DisableClockLowPower * @param Periphs This parameter can be a combination of the following values: * @arg @ref LL_APB2_GRP1_PERIPH_TIM1 * @arg @ref LL_APB2_GRP1_PERIPH_TIM8 (*) * @arg @ref LL_APB2_GRP1_PERIPH_USART1 * @arg @ref LL_APB2_GRP1_PERIPH_USART6 (*) * @arg @ref LL_APB2_GRP1_PERIPH_UART9 (*) * @arg @ref LL_APB2_GRP1_PERIPH_UART10 (*) * @arg @ref LL_APB2_GRP1_PERIPH_ADC1 * @arg @ref LL_APB2_GRP1_PERIPH_ADC2 (*) * @arg @ref LL_APB2_GRP1_PERIPH_ADC3 (*) * @arg @ref LL_APB2_GRP1_PERIPH_SDIO (*) * @arg @ref LL_APB2_GRP1_PERIPH_SPI1 * @arg @ref LL_APB2_GRP1_PERIPH_SPI4 (*) * @arg @ref LL_APB2_GRP1_PERIPH_SYSCFG * @arg @ref LL_APB2_GRP1_PERIPH_EXTI (*) * @arg @ref LL_APB2_GRP1_PERIPH_TIM9 * @arg @ref LL_APB2_GRP1_PERIPH_TIM10 (*) * @arg @ref LL_APB2_GRP1_PERIPH_TIM11 * @arg @ref LL_APB2_GRP1_PERIPH_SPI5 (*) * @arg @ref LL_APB2_GRP1_PERIPH_SPI6 (*) * @arg @ref LL_APB2_GRP1_PERIPH_SAI1 (*) * @arg @ref LL_APB2_GRP1_PERIPH_SAI2 (*) * @arg @ref LL_APB2_GRP1_PERIPH_LTDC (*) * @arg @ref LL_APB2_GRP1_PERIPH_DSI (*) * @arg @ref LL_APB2_GRP1_PERIPH_DFSDM1 (*) * @arg @ref LL_APB2_GRP1_PERIPH_DFSDM2 (*) * * (*) value not defined in all devices. * @retval None */ __STATIC_INLINE void LL_APB2_GRP1_DisableClockLowPower(uint32_t Periphs) { CLEAR_BIT(RCC->APB2LPENR, Periphs); } /** * @} */ /** * @} */ /** * @} */ #endif /* defined(RCC) */ /** * @} */ #ifdef __cplusplus } #endif #endif /* __STM32F4xx_LL_BUS_H */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ ================================================ FILE: sys/arch/stm32/hal/stm32f4xx_ll_cortex.h ================================================ /** ****************************************************************************** * @file stm32f4xx_ll_cortex.h * @author MCD Application Team * @version V1.8.2 * @date 08-November-2023 * @brief Header file of CORTEX LL module. @verbatim ============================================================================== ##### How to use this driver ##### ============================================================================== [..] The LL CORTEX driver contains a set of generic APIs that can be used by user: (+) SYSTICK configuration used by LL_mDelay and LL_Init1msTick functions (+) Low power mode configuration (SCB register of Cortex-MCU) (+) MPU API to configure and enable regions (MPU services provided only on some devices) (+) API to access to MCU info (CPUID register) (+) API to enable fault handler (SHCSR accesses) @endverbatim ****************************************************************************** * @attention * *

© COPYRIGHT(c) 2017 STMicroelectronics

* * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. Neither the name of STMicroelectronics nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __STM32F4xx_LL_CORTEX_H #define __STM32F4xx_LL_CORTEX_H #ifdef __cplusplus extern "C" { #endif /* Includes ------------------------------------------------------------------*/ #include "stm32f4xx.h" /** @addtogroup STM32F4xx_LL_Driver * @{ */ /** @defgroup CORTEX_LL CORTEX * @{ */ /* Private types -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ /* Private constants ---------------------------------------------------------*/ /* Private macros ------------------------------------------------------------*/ /* Exported types ------------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/ /** @defgroup CORTEX_LL_Exported_Constants CORTEX Exported Constants * @{ */ /** @defgroup CORTEX_LL_EC_CLKSOURCE_HCLK SYSTICK Clock Source * @{ */ #define LL_SYSTICK_CLKSOURCE_HCLK_DIV8 0x00000000U /*!< AHB clock divided by 8 selected as SysTick clock source.*/ #define LL_SYSTICK_CLKSOURCE_HCLK SysTick_CTRL_CLKSOURCE_Msk /*!< AHB clock selected as SysTick clock source. */ /** * @} */ /** @defgroup CORTEX_LL_EC_FAULT Handler Fault type * @{ */ #define LL_HANDLER_FAULT_USG SCB_SHCSR_USGFAULTENA_Msk /*!< Usage fault */ #define LL_HANDLER_FAULT_BUS SCB_SHCSR_BUSFAULTENA_Msk /*!< Bus fault */ #define LL_HANDLER_FAULT_MEM SCB_SHCSR_MEMFAULTENA_Msk /*!< Memory management fault */ /** * @} */ #if __MPU_PRESENT /** @defgroup CORTEX_LL_EC_CTRL_HFNMI_PRIVDEF MPU Control * @{ */ #define LL_MPU_CTRL_HFNMI_PRIVDEF_NONE 0x00000000U /*!< Disable NMI and privileged SW access */ #define LL_MPU_CTRL_HARDFAULT_NMI MPU_CTRL_HFNMIENA_Msk /*!< Enables the operation of MPU during hard fault, NMI, and FAULTMASK handlers */ #define LL_MPU_CTRL_PRIVILEGED_DEFAULT MPU_CTRL_PRIVDEFENA_Msk /*!< Enable privileged software access to default memory map */ #define LL_MPU_CTRL_HFNMI_PRIVDEF (MPU_CTRL_HFNMIENA_Msk | MPU_CTRL_PRIVDEFENA_Msk) /*!< Enable NMI and privileged SW access */ /** * @} */ /** @defgroup CORTEX_LL_EC_REGION MPU Region Number * @{ */ #define LL_MPU_REGION_NUMBER0 0x00U /*!< REGION Number 0 */ #define LL_MPU_REGION_NUMBER1 0x01U /*!< REGION Number 1 */ #define LL_MPU_REGION_NUMBER2 0x02U /*!< REGION Number 2 */ #define LL_MPU_REGION_NUMBER3 0x03U /*!< REGION Number 3 */ #define LL_MPU_REGION_NUMBER4 0x04U /*!< REGION Number 4 */ #define LL_MPU_REGION_NUMBER5 0x05U /*!< REGION Number 5 */ #define LL_MPU_REGION_NUMBER6 0x06U /*!< REGION Number 6 */ #define LL_MPU_REGION_NUMBER7 0x07U /*!< REGION Number 7 */ /** * @} */ /** @defgroup CORTEX_LL_EC_REGION_SIZE MPU Region Size * @{ */ #define LL_MPU_REGION_SIZE_32B (0x04U << MPU_RASR_SIZE_Pos) /*!< 32B Size of the MPU protection region */ #define LL_MPU_REGION_SIZE_64B (0x05U << MPU_RASR_SIZE_Pos) /*!< 64B Size of the MPU protection region */ #define LL_MPU_REGION_SIZE_128B (0x06U << MPU_RASR_SIZE_Pos) /*!< 128B Size of the MPU protection region */ #define LL_MPU_REGION_SIZE_256B (0x07U << MPU_RASR_SIZE_Pos) /*!< 256B Size of the MPU protection region */ #define LL_MPU_REGION_SIZE_512B (0x08U << MPU_RASR_SIZE_Pos) /*!< 512B Size of the MPU protection region */ #define LL_MPU_REGION_SIZE_1KB (0x09U << MPU_RASR_SIZE_Pos) /*!< 1KB Size of the MPU protection region */ #define LL_MPU_REGION_SIZE_2KB (0x0AU << MPU_RASR_SIZE_Pos) /*!< 2KB Size of the MPU protection region */ #define LL_MPU_REGION_SIZE_4KB (0x0BU << MPU_RASR_SIZE_Pos) /*!< 4KB Size of the MPU protection region */ #define LL_MPU_REGION_SIZE_8KB (0x0CU << MPU_RASR_SIZE_Pos) /*!< 8KB Size of the MPU protection region */ #define LL_MPU_REGION_SIZE_16KB (0x0DU << MPU_RASR_SIZE_Pos) /*!< 16KB Size of the MPU protection region */ #define LL_MPU_REGION_SIZE_32KB (0x0EU << MPU_RASR_SIZE_Pos) /*!< 32KB Size of the MPU protection region */ #define LL_MPU_REGION_SIZE_64KB (0x0FU << MPU_RASR_SIZE_Pos) /*!< 64KB Size of the MPU protection region */ #define LL_MPU_REGION_SIZE_128KB (0x10U << MPU_RASR_SIZE_Pos) /*!< 128KB Size of the MPU protection region */ #define LL_MPU_REGION_SIZE_256KB (0x11U << MPU_RASR_SIZE_Pos) /*!< 256KB Size of the MPU protection region */ #define LL_MPU_REGION_SIZE_512KB (0x12U << MPU_RASR_SIZE_Pos) /*!< 512KB Size of the MPU protection region */ #define LL_MPU_REGION_SIZE_1MB (0x13U << MPU_RASR_SIZE_Pos) /*!< 1MB Size of the MPU protection region */ #define LL_MPU_REGION_SIZE_2MB (0x14U << MPU_RASR_SIZE_Pos) /*!< 2MB Size of the MPU protection region */ #define LL_MPU_REGION_SIZE_4MB (0x15U << MPU_RASR_SIZE_Pos) /*!< 4MB Size of the MPU protection region */ #define LL_MPU_REGION_SIZE_8MB (0x16U << MPU_RASR_SIZE_Pos) /*!< 8MB Size of the MPU protection region */ #define LL_MPU_REGION_SIZE_16MB (0x17U << MPU_RASR_SIZE_Pos) /*!< 16MB Size of the MPU protection region */ #define LL_MPU_REGION_SIZE_32MB (0x18U << MPU_RASR_SIZE_Pos) /*!< 32MB Size of the MPU protection region */ #define LL_MPU_REGION_SIZE_64MB (0x19U << MPU_RASR_SIZE_Pos) /*!< 64MB Size of the MPU protection region */ #define LL_MPU_REGION_SIZE_128MB (0x1AU << MPU_RASR_SIZE_Pos) /*!< 128MB Size of the MPU protection region */ #define LL_MPU_REGION_SIZE_256MB (0x1BU << MPU_RASR_SIZE_Pos) /*!< 256MB Size of the MPU protection region */ #define LL_MPU_REGION_SIZE_512MB (0x1CU << MPU_RASR_SIZE_Pos) /*!< 512MB Size of the MPU protection region */ #define LL_MPU_REGION_SIZE_1GB (0x1DU << MPU_RASR_SIZE_Pos) /*!< 1GB Size of the MPU protection region */ #define LL_MPU_REGION_SIZE_2GB (0x1EU << MPU_RASR_SIZE_Pos) /*!< 2GB Size of the MPU protection region */ #define LL_MPU_REGION_SIZE_4GB (0x1FU << MPU_RASR_SIZE_Pos) /*!< 4GB Size of the MPU protection region */ /** * @} */ /** @defgroup CORTEX_LL_EC_REGION_PRIVILEDGES MPU Region Privileges * @{ */ #define LL_MPU_REGION_NO_ACCESS (0x00U << MPU_RASR_AP_Pos) /*!< No access*/ #define LL_MPU_REGION_PRIV_RW (0x01U << MPU_RASR_AP_Pos) /*!< RW privileged (privileged access only)*/ #define LL_MPU_REGION_PRIV_RW_URO (0x02U << MPU_RASR_AP_Pos) /*!< RW privileged - RO user (Write in a user program generates a fault) */ #define LL_MPU_REGION_FULL_ACCESS (0x03U << MPU_RASR_AP_Pos) /*!< RW privileged & user (Full access) */ #define LL_MPU_REGION_PRIV_RO (0x05U << MPU_RASR_AP_Pos) /*!< RO privileged (privileged read only)*/ #define LL_MPU_REGION_PRIV_RO_URO (0x06U << MPU_RASR_AP_Pos) /*!< RO privileged & user (read only) */ /** * @} */ /** @defgroup CORTEX_LL_EC_TEX MPU TEX Level * @{ */ #define LL_MPU_TEX_LEVEL0 (0x00U << MPU_RASR_TEX_Pos) /*!< b000 for TEX bits */ #define LL_MPU_TEX_LEVEL1 (0x01U << MPU_RASR_TEX_Pos) /*!< b001 for TEX bits */ #define LL_MPU_TEX_LEVEL2 (0x02U << MPU_RASR_TEX_Pos) /*!< b010 for TEX bits */ #define LL_MPU_TEX_LEVEL4 (0x04U << MPU_RASR_TEX_Pos) /*!< b100 for TEX bits */ /** * @} */ /** @defgroup CORTEX_LL_EC_INSTRUCTION_ACCESS MPU Instruction Access * @{ */ #define LL_MPU_INSTRUCTION_ACCESS_ENABLE 0x00U /*!< Instruction fetches enabled */ #define LL_MPU_INSTRUCTION_ACCESS_DISABLE MPU_RASR_XN_Msk /*!< Instruction fetches disabled*/ /** * @} */ /** @defgroup CORTEX_LL_EC_SHAREABLE_ACCESS MPU Shareable Access * @{ */ #define LL_MPU_ACCESS_SHAREABLE MPU_RASR_S_Msk /*!< Shareable memory attribute */ #define LL_MPU_ACCESS_NOT_SHAREABLE 0x00U /*!< Not Shareable memory attribute */ /** * @} */ /** @defgroup CORTEX_LL_EC_CACHEABLE_ACCESS MPU Cacheable Access * @{ */ #define LL_MPU_ACCESS_CACHEABLE MPU_RASR_C_Msk /*!< Cacheable memory attribute */ #define LL_MPU_ACCESS_NOT_CACHEABLE 0x00U /*!< Not Cacheable memory attribute */ /** * @} */ /** @defgroup CORTEX_LL_EC_BUFFERABLE_ACCESS MPU Bufferable Access * @{ */ #define LL_MPU_ACCESS_BUFFERABLE MPU_RASR_B_Msk /*!< Bufferable memory attribute */ #define LL_MPU_ACCESS_NOT_BUFFERABLE 0x00U /*!< Not Bufferable memory attribute */ /** * @} */ #endif /* __MPU_PRESENT */ /** * @} */ /* Exported macro ------------------------------------------------------------*/ /* Exported functions --------------------------------------------------------*/ /** @defgroup CORTEX_LL_Exported_Functions CORTEX Exported Functions * @{ */ /** @defgroup CORTEX_LL_EF_SYSTICK SYSTICK * @{ */ /** * @brief This function checks if the Systick counter flag is active or not. * @note It can be used in timeout function on application side. * @rmtoll STK_CTRL COUNTFLAG LL_SYSTICK_IsActiveCounterFlag * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_SYSTICK_IsActiveCounterFlag(void) { return ((SysTick->CTRL & SysTick_CTRL_COUNTFLAG_Msk) == (SysTick_CTRL_COUNTFLAG_Msk)); } /** * @brief Configures the SysTick clock source * @rmtoll STK_CTRL CLKSOURCE LL_SYSTICK_SetClkSource * @param Source This parameter can be one of the following values: * @arg @ref LL_SYSTICK_CLKSOURCE_HCLK_DIV8 * @arg @ref LL_SYSTICK_CLKSOURCE_HCLK * @retval None */ __STATIC_INLINE void LL_SYSTICK_SetClkSource(uint32_t Source) { if (Source == LL_SYSTICK_CLKSOURCE_HCLK) { SET_BIT(SysTick->CTRL, LL_SYSTICK_CLKSOURCE_HCLK); } else { CLEAR_BIT(SysTick->CTRL, LL_SYSTICK_CLKSOURCE_HCLK); } } /** * @brief Get the SysTick clock source * @rmtoll STK_CTRL CLKSOURCE LL_SYSTICK_GetClkSource * @retval Returned value can be one of the following values: * @arg @ref LL_SYSTICK_CLKSOURCE_HCLK_DIV8 * @arg @ref LL_SYSTICK_CLKSOURCE_HCLK */ __STATIC_INLINE uint32_t LL_SYSTICK_GetClkSource(void) { return READ_BIT(SysTick->CTRL, LL_SYSTICK_CLKSOURCE_HCLK); } /** * @brief Enable SysTick exception request * @rmtoll STK_CTRL TICKINT LL_SYSTICK_EnableIT * @retval None */ __STATIC_INLINE void LL_SYSTICK_EnableIT(void) { SET_BIT(SysTick->CTRL, SysTick_CTRL_TICKINT_Msk); } /** * @brief Disable SysTick exception request * @rmtoll STK_CTRL TICKINT LL_SYSTICK_DisableIT * @retval None */ __STATIC_INLINE void LL_SYSTICK_DisableIT(void) { CLEAR_BIT(SysTick->CTRL, SysTick_CTRL_TICKINT_Msk); } /** * @brief Checks if the SYSTICK interrupt is enabled or disabled. * @rmtoll STK_CTRL TICKINT LL_SYSTICK_IsEnabledIT * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_SYSTICK_IsEnabledIT(void) { return (READ_BIT(SysTick->CTRL, SysTick_CTRL_TICKINT_Msk) == (SysTick_CTRL_TICKINT_Msk)); } /** * @} */ /** @defgroup CORTEX_LL_EF_LOW_POWER_MODE LOW POWER MODE * @{ */ /** * @brief Processor uses sleep as its low power mode * @rmtoll SCB_SCR SLEEPDEEP LL_LPM_EnableSleep * @retval None */ __STATIC_INLINE void LL_LPM_EnableSleep(void) { /* Clear SLEEPDEEP bit of Cortex System Control Register */ CLEAR_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPDEEP_Msk)); } /** * @brief Processor uses deep sleep as its low power mode * @rmtoll SCB_SCR SLEEPDEEP LL_LPM_EnableDeepSleep * @retval None */ __STATIC_INLINE void LL_LPM_EnableDeepSleep(void) { /* Set SLEEPDEEP bit of Cortex System Control Register */ SET_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPDEEP_Msk)); } /** * @brief Configures sleep-on-exit when returning from Handler mode to Thread mode. * @note Setting this bit to 1 enables an interrupt-driven application to avoid returning to an * empty main application. * @rmtoll SCB_SCR SLEEPONEXIT LL_LPM_EnableSleepOnExit * @retval None */ __STATIC_INLINE void LL_LPM_EnableSleepOnExit(void) { /* Set SLEEPONEXIT bit of Cortex System Control Register */ SET_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPONEXIT_Msk)); } /** * @brief Do not sleep when returning to Thread mode. * @rmtoll SCB_SCR SLEEPONEXIT LL_LPM_DisableSleepOnExit * @retval None */ __STATIC_INLINE void LL_LPM_DisableSleepOnExit(void) { /* Clear SLEEPONEXIT bit of Cortex System Control Register */ CLEAR_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPONEXIT_Msk)); } /** * @brief Enabled events and all interrupts, including disabled interrupts, can wakeup the * processor. * @rmtoll SCB_SCR SEVEONPEND LL_LPM_EnableEventOnPend * @retval None */ __STATIC_INLINE void LL_LPM_EnableEventOnPend(void) { /* Set SEVEONPEND bit of Cortex System Control Register */ SET_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SEVONPEND_Msk)); } /** * @brief Only enabled interrupts or events can wakeup the processor, disabled interrupts are * excluded * @rmtoll SCB_SCR SEVEONPEND LL_LPM_DisableEventOnPend * @retval None */ __STATIC_INLINE void LL_LPM_DisableEventOnPend(void) { /* Clear SEVEONPEND bit of Cortex System Control Register */ CLEAR_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SEVONPEND_Msk)); } /** * @brief Clear pending events. * @retval None */ __STATIC_INLINE void LL_LPM_ClearEvent(void) { __SEV(); __WFE(); } /** * @} */ /** @defgroup CORTEX_LL_EF_HANDLER HANDLER * @{ */ /** * @brief Enable a fault in System handler control register (SHCSR) * @rmtoll SCB_SHCSR MEMFAULTENA LL_HANDLER_EnableFault * @param Fault This parameter can be a combination of the following values: * @arg @ref LL_HANDLER_FAULT_USG * @arg @ref LL_HANDLER_FAULT_BUS * @arg @ref LL_HANDLER_FAULT_MEM * @retval None */ __STATIC_INLINE void LL_HANDLER_EnableFault(uint32_t Fault) { /* Enable the system handler fault */ SET_BIT(SCB->SHCSR, Fault); } /** * @brief Disable a fault in System handler control register (SHCSR) * @rmtoll SCB_SHCSR MEMFAULTENA LL_HANDLER_DisableFault * @param Fault This parameter can be a combination of the following values: * @arg @ref LL_HANDLER_FAULT_USG * @arg @ref LL_HANDLER_FAULT_BUS * @arg @ref LL_HANDLER_FAULT_MEM * @retval None */ __STATIC_INLINE void LL_HANDLER_DisableFault(uint32_t Fault) { /* Disable the system handler fault */ CLEAR_BIT(SCB->SHCSR, Fault); } /** * @} */ /** @defgroup CORTEX_LL_EF_MCU_INFO MCU INFO * @{ */ /** * @brief Get Implementer code * @rmtoll SCB_CPUID IMPLEMENTER LL_CPUID_GetImplementer * @retval Value should be equal to 0x41 for ARM */ __STATIC_INLINE uint32_t LL_CPUID_GetImplementer(void) { return (uint32_t)(READ_BIT(SCB->CPUID, SCB_CPUID_IMPLEMENTER_Msk) >> SCB_CPUID_IMPLEMENTER_Pos); } /** * @brief Get Variant number (The r value in the rnpn product revision identifier) * @rmtoll SCB_CPUID VARIANT LL_CPUID_GetVariant * @retval Value between 0 and 255 (0x0: revision 0) */ __STATIC_INLINE uint32_t LL_CPUID_GetVariant(void) { return (uint32_t)(READ_BIT(SCB->CPUID, SCB_CPUID_VARIANT_Msk) >> SCB_CPUID_VARIANT_Pos); } /** * @brief Get Constant number * @rmtoll SCB_CPUID ARCHITECTURE LL_CPUID_GetConstant * @retval Value should be equal to 0xF for Cortex-M4 devices */ __STATIC_INLINE uint32_t LL_CPUID_GetConstant(void) { return (uint32_t)(READ_BIT(SCB->CPUID, SCB_CPUID_ARCHITECTURE_Msk) >> SCB_CPUID_ARCHITECTURE_Pos); } /** * @brief Get Part number * @rmtoll SCB_CPUID PARTNO LL_CPUID_GetParNo * @retval Value should be equal to 0xC24 for Cortex-M4 */ __STATIC_INLINE uint32_t LL_CPUID_GetParNo(void) { return (uint32_t)(READ_BIT(SCB->CPUID, SCB_CPUID_PARTNO_Msk) >> SCB_CPUID_PARTNO_Pos); } /** * @brief Get Revision number (The p value in the rnpn product revision identifier, indicates patch release) * @rmtoll SCB_CPUID REVISION LL_CPUID_GetRevision * @retval Value between 0 and 255 (0x1: patch 1) */ __STATIC_INLINE uint32_t LL_CPUID_GetRevision(void) { return (uint32_t)(READ_BIT(SCB->CPUID, SCB_CPUID_REVISION_Msk) >> SCB_CPUID_REVISION_Pos); } /** * @} */ #if __MPU_PRESENT /** @defgroup CORTEX_LL_EF_MPU MPU * @{ */ /** * @brief Enable MPU with input Options * @rmtoll MPU_CTRL ENABLE LL_MPU_Enable * @param Options This parameter can be one of the following values: * @arg @ref LL_MPU_CTRL_HFNMI_PRIVDEF_NONE * @arg @ref LL_MPU_CTRL_HARDFAULT_NMI * @arg @ref LL_MPU_CTRL_PRIVILEGED_DEFAULT * @arg @ref LL_MPU_CTRL_HFNMI_PRIVDEF * @retval None */ __STATIC_INLINE void LL_MPU_Enable(uint32_t Options) { /* Enable MPU. */ WRITE_REG(MPU->CTRL, (MPU_CTRL_ENABLE_Msk | Options)); /* Ensure MPU settings take effect. */ __DSB(); /* Sequence instruction fetches using updated settings. */ __ISB(); } /** * @brief Disable MPU * @rmtoll MPU_CTRL ENABLE LL_MPU_Disable * @retval None */ __STATIC_INLINE void LL_MPU_Disable(void) { /* Make sure outstanding transfers are done. */ __DMB(); /* Disable MPU. */ WRITE_REG(MPU->CTRL, 0U); } /** * @brief Check if MPU is enabled or not * @rmtoll MPU_CTRL ENABLE LL_MPU_IsEnabled * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_MPU_IsEnabled(void) { return (READ_BIT(MPU->CTRL, MPU_CTRL_ENABLE_Msk) == (MPU_CTRL_ENABLE_Msk)); } /** * @brief Enable MPU Region * @rmtoll MPU_RASR ENABLE LL_MPU_EnableRegion * @param Region This parameter can be one of the following values: * @arg @ref LL_MPU_REGION_NUMBER0 * @arg @ref LL_MPU_REGION_NUMBER1 * @arg @ref LL_MPU_REGION_NUMBER2 * @arg @ref LL_MPU_REGION_NUMBER3 * @arg @ref LL_MPU_REGION_NUMBER4 * @arg @ref LL_MPU_REGION_NUMBER5 * @arg @ref LL_MPU_REGION_NUMBER6 * @arg @ref LL_MPU_REGION_NUMBER7 * @retval None */ __STATIC_INLINE void LL_MPU_EnableRegion(uint32_t Region) { /* Set Region number. */ WRITE_REG(MPU->RNR, Region); /* Enable MPU Region. */ SET_BIT(MPU->RASR, MPU_RASR_ENABLE_Msk); } /** * @brief Configure and enable Region * @rmtoll MPU_RNR REGION LL_MPU_ConfigRegion\n * MPU_RBAR REGION LL_MPU_ConfigRegion\n * MPU_RBAR ADDR LL_MPU_ConfigRegion\n * MPU_RASR XN LL_MPU_ConfigRegion\n * MPU_RASR AP LL_MPU_ConfigRegion\n * MPU_RASR S LL_MPU_ConfigRegion\n * MPU_RASR C LL_MPU_ConfigRegion\n * MPU_RASR B LL_MPU_ConfigRegion\n * MPU_RASR SIZE LL_MPU_ConfigRegion * @param Region This parameter can be one of the following values: * @arg @ref LL_MPU_REGION_NUMBER0 * @arg @ref LL_MPU_REGION_NUMBER1 * @arg @ref LL_MPU_REGION_NUMBER2 * @arg @ref LL_MPU_REGION_NUMBER3 * @arg @ref LL_MPU_REGION_NUMBER4 * @arg @ref LL_MPU_REGION_NUMBER5 * @arg @ref LL_MPU_REGION_NUMBER6 * @arg @ref LL_MPU_REGION_NUMBER7 * @param Address Value of Region Base Address * @param SubRegionDisable Sub-Region disable value between Min_Data = 0x00 and Max_Data = 0xFF * @param Attributes This parameter can be a combination of the following values: * @arg @ref LL_MPU_REGION_SIZE_32B or @ref LL_MPU_REGION_SIZE_64B or @ref LL_MPU_REGION_SIZE_128B or @ref LL_MPU_REGION_SIZE_256B or @ref LL_MPU_REGION_SIZE_512B * or @ref LL_MPU_REGION_SIZE_1KB or @ref LL_MPU_REGION_SIZE_2KB or @ref LL_MPU_REGION_SIZE_4KB or @ref LL_MPU_REGION_SIZE_8KB or @ref LL_MPU_REGION_SIZE_16KB * or @ref LL_MPU_REGION_SIZE_32KB or @ref LL_MPU_REGION_SIZE_64KB or @ref LL_MPU_REGION_SIZE_128KB or @ref LL_MPU_REGION_SIZE_256KB or @ref LL_MPU_REGION_SIZE_512KB * or @ref LL_MPU_REGION_SIZE_1MB or @ref LL_MPU_REGION_SIZE_2MB or @ref LL_MPU_REGION_SIZE_4MB or @ref LL_MPU_REGION_SIZE_8MB or @ref LL_MPU_REGION_SIZE_16MB * or @ref LL_MPU_REGION_SIZE_32MB or @ref LL_MPU_REGION_SIZE_64MB or @ref LL_MPU_REGION_SIZE_128MB or @ref LL_MPU_REGION_SIZE_256MB or @ref LL_MPU_REGION_SIZE_512MB * or @ref LL_MPU_REGION_SIZE_1GB or @ref LL_MPU_REGION_SIZE_2GB or @ref LL_MPU_REGION_SIZE_4GB * @arg @ref LL_MPU_REGION_NO_ACCESS or @ref LL_MPU_REGION_PRIV_RW or @ref LL_MPU_REGION_PRIV_RW_URO or @ref LL_MPU_REGION_FULL_ACCESS * or @ref LL_MPU_REGION_PRIV_RO or @ref LL_MPU_REGION_PRIV_RO_URO * @arg @ref LL_MPU_TEX_LEVEL0 or @ref LL_MPU_TEX_LEVEL1 or @ref LL_MPU_TEX_LEVEL2 or @ref LL_MPU_TEX_LEVEL4 * @arg @ref LL_MPU_INSTRUCTION_ACCESS_ENABLE or @ref LL_MPU_INSTRUCTION_ACCESS_DISABLE * @arg @ref LL_MPU_ACCESS_SHAREABLE or @ref LL_MPU_ACCESS_NOT_SHAREABLE * @arg @ref LL_MPU_ACCESS_CACHEABLE or @ref LL_MPU_ACCESS_NOT_CACHEABLE * @arg @ref LL_MPU_ACCESS_BUFFERABLE or @ref LL_MPU_ACCESS_NOT_BUFFERABLE * @retval None */ __STATIC_INLINE void LL_MPU_ConfigRegion(uint32_t Region, uint32_t SubRegionDisable, uint32_t Address, uint32_t Attributes) { /* Set Region number. */ WRITE_REG(MPU->RNR, Region); /* Set Base Address. */ WRITE_REG(MPU->RBAR, (Address & 0xFFFFFFE0U)); /* Configure MPU. */ WRITE_REG(MPU->RASR, (MPU_RASR_ENABLE_Msk | Attributes | (SubRegionDisable << MPU_RASR_SRD_Pos))); } /** * @brief Disable Region * @rmtoll MPU_RNR REGION LL_MPU_DisableRegion\n * MPU_RASR ENABLE LL_MPU_DisableRegion * @param Region This parameter can be one of the following values: * @arg @ref LL_MPU_REGION_NUMBER0 * @arg @ref LL_MPU_REGION_NUMBER1 * @arg @ref LL_MPU_REGION_NUMBER2 * @arg @ref LL_MPU_REGION_NUMBER3 * @arg @ref LL_MPU_REGION_NUMBER4 * @arg @ref LL_MPU_REGION_NUMBER5 * @arg @ref LL_MPU_REGION_NUMBER6 * @arg @ref LL_MPU_REGION_NUMBER7 * @retval None */ __STATIC_INLINE void LL_MPU_DisableRegion(uint32_t Region) { /* Set Region number. */ WRITE_REG(MPU->RNR, Region); /* Disable MPU Region. */ CLEAR_BIT(MPU->RASR, MPU_RASR_ENABLE_Msk); } /** * @brief Get MPU Control Register. * @note This function is an extension to the LL_CORTEX library. * @retval Values of MPU Enable, Hard Fault NMI Enable, and Background Region Enable. */ __STATIC_INLINE uint32_t LL_MPU_GetCtrl(void) { return (uint32_t)(READ_REG(MPU->CTRL)); } /** * @brief Set MPU Control Register with Options. * @note This function is an extension to the LL_CORTEX library. * @retval None */ __STATIC_INLINE void LL_MPU_SetCtrl(uint32_t Options) { /* Configure MPU Control Register. */ WRITE_REG(MPU->CTRL, ((MPU_CTRL_PRIVDEFENA_Msk | MPU_CTRL_HFNMIENA_Msk | MPU_CTRL_ENABLE_Msk) & Options)); /* Ensure MPU settings take effect. */ __DSB(); /* Sequence instruction fetches using updated settings. */ __ISB(); } /** * @brief Get number of Regions the MPU supports. * @note This function is an extension to the LL_CORTEX library. * @retval Value should be equal to 0x8 for Cortex-M4 devices; 0x0 if no MPU implemented. */ __STATIC_INLINE uint32_t LL_MPU_GetNumRegions(void) { return (uint32_t)(READ_BIT(MPU->TYPE, MPU_TYPE_DREGION_Msk) >> MPU_TYPE_DREGION_Pos); } /** * @brief Check if the MPU supports separate instruction and data address maps. * @note This function is an extension to the LL_CORTEX library. * @retval Value should be equal to 0x0 for Cortex-M4 devices; ARMv7-M only supports a unified MPU. */ __STATIC_INLINE uint32_t LL_MPU_GetSeparate(void) { return (uint32_t)(READ_BIT(MPU->TYPE, MPU_TYPE_SEPARATE_Msk) >> MPU_TYPE_SEPARATE_Pos); } /** * @brief Get MPU Region's Region Base Address. * @rmtoll MPU_RNR REGION LL_MPU_GetRegionBaseAddress * @param Region This parameter can be one of the following values: * @arg @ref LL_MPU_REGION_NUMBER0 * @arg @ref LL_MPU_REGION_NUMBER1 * @arg @ref LL_MPU_REGION_NUMBER2 * @arg @ref LL_MPU_REGION_NUMBER3 * @arg @ref LL_MPU_REGION_NUMBER4 * @arg @ref LL_MPU_REGION_NUMBER5 * @arg @ref LL_MPU_REGION_NUMBER6 * @arg @ref LL_MPU_REGION_NUMBER7 * @note This function is an extension to the LL_CORTEX library. * @retval Value of the Region Base Address Register for the supplied Region parameter. */ __STATIC_INLINE uint32_t LL_MPU_GetRegionBaseAddress(uint32_t Region) { /* Set Region number. */ WRITE_REG(MPU->RNR, Region); return (uint32_t)(READ_REG(MPU->RBAR & MPU_RBAR_ADDR_Msk)); } /** * @brief Get MPU Region's Region Attribute and Size Register. * @rmtoll MPU_RNR REGION LL_MPU_GetRegionAttrSize * @param Region This parameter can be one of the following values: * @arg @ref LL_MPU_REGION_NUMBER0 * @arg @ref LL_MPU_REGION_NUMBER1 * @arg @ref LL_MPU_REGION_NUMBER2 * @arg @ref LL_MPU_REGION_NUMBER3 * @arg @ref LL_MPU_REGION_NUMBER4 * @arg @ref LL_MPU_REGION_NUMBER5 * @arg @ref LL_MPU_REGION_NUMBER6 * @arg @ref LL_MPU_REGION_NUMBER7 * @note This function is an extension to the LL_CORTEX library. * @retval Value of the Region Attribute and Size Register for the supplied Region parameter. */ __STATIC_INLINE uint32_t LL_MPU_GetRegionAttrSize(uint32_t Region) { /* Set Region number. */ WRITE_REG(MPU->RNR, Region); return (uint32_t)(READ_REG(MPU->RASR)); } /** * @} */ #endif /* __MPU_PRESENT */ /** * @} */ /** * @} */ /** * @} */ #ifdef __cplusplus } #endif #endif /* __STM32F4xx_LL_CORTEX_H */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ ================================================ FILE: sys/arch/stm32/hal/stm32f4xx_ll_gpio.h ================================================ /** ****************************************************************************** * @file stm32f4xx_ll_gpio.h * @author MCD Application Team * @version V1.7.1 * @date 14-April-2017 * @brief Header file of GPIO LL module. ****************************************************************************** * @attention * *

© COPYRIGHT(c) 2017 STMicroelectronics

* * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. Neither the name of STMicroelectronics nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __STM32F4xx_LL_GPIO_H #define __STM32F4xx_LL_GPIO_H #ifdef __cplusplus extern "C" { #endif /* Includes ------------------------------------------------------------------*/ #include "stm32f4xx.h" /** @addtogroup STM32F4xx_LL_Driver * @{ */ #if defined (GPIOA) || defined (GPIOB) || defined (GPIOC) || defined (GPIOD) || defined (GPIOE) || defined (GPIOF) || defined (GPIOG) || defined (GPIOH) || defined (GPIOI) || defined (GPIOJ) || defined (GPIOK) /** @defgroup GPIO_LL GPIO * @{ */ /* Private types -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ /* Private constants ---------------------------------------------------------*/ /* Private macros ------------------------------------------------------------*/ #if defined(USE_FULL_LL_DRIVER) /** @defgroup GPIO_LL_Private_Macros GPIO Private Macros * @{ */ /** * @} */ #endif /*USE_FULL_LL_DRIVER*/ /* Exported types ------------------------------------------------------------*/ #if defined(USE_FULL_LL_DRIVER) /** @defgroup GPIO_LL_ES_INIT GPIO Exported Init structures * @{ */ /** * @brief LL GPIO Init Structure definition */ typedef struct { uint32_t Pin; /*!< Specifies the GPIO pins to be configured. This parameter can be any value of @ref GPIO_LL_EC_PIN */ uint32_t Mode; /*!< Specifies the operating mode for the selected pins. This parameter can be a value of @ref GPIO_LL_EC_MODE. GPIO HW configuration can be modified afterwards using unitary function @ref LL_GPIO_SetPinMode().*/ uint32_t Speed; /*!< Specifies the speed for the selected pins. This parameter can be a value of @ref GPIO_LL_EC_SPEED. GPIO HW configuration can be modified afterwards using unitary function @ref LL_GPIO_SetPinSpeed().*/ uint32_t OutputType; /*!< Specifies the operating output type for the selected pins. This parameter can be a value of @ref GPIO_LL_EC_OUTPUT. GPIO HW configuration can be modified afterwards using unitary function @ref LL_GPIO_SetPinOutputType().*/ uint32_t Pull; /*!< Specifies the operating Pull-up/Pull down for the selected pins. This parameter can be a value of @ref GPIO_LL_EC_PULL. GPIO HW configuration can be modified afterwards using unitary function @ref LL_GPIO_SetPinPull().*/ uint32_t Alternate; /*!< Specifies the Peripheral to be connected to the selected pins. This parameter can be a value of @ref GPIO_LL_EC_AF. GPIO HW configuration can be modified afterwards using unitary function @ref LL_GPIO_SetAFPin_0_7() and LL_GPIO_SetAFPin_8_15().*/ } LL_GPIO_InitTypeDef; /** * @} */ #endif /* USE_FULL_LL_DRIVER */ /* Exported constants --------------------------------------------------------*/ /** @defgroup GPIO_LL_Exported_Constants GPIO Exported Constants * @{ */ /** @defgroup GPIO_LL_EC_PIN PIN * @{ */ #define LL_GPIO_PIN_0 GPIO_BSRR_BS_0 /*!< Select pin 0 */ #define LL_GPIO_PIN_1 GPIO_BSRR_BS_1 /*!< Select pin 1 */ #define LL_GPIO_PIN_2 GPIO_BSRR_BS_2 /*!< Select pin 2 */ #define LL_GPIO_PIN_3 GPIO_BSRR_BS_3 /*!< Select pin 3 */ #define LL_GPIO_PIN_4 GPIO_BSRR_BS_4 /*!< Select pin 4 */ #define LL_GPIO_PIN_5 GPIO_BSRR_BS_5 /*!< Select pin 5 */ #define LL_GPIO_PIN_6 GPIO_BSRR_BS_6 /*!< Select pin 6 */ #define LL_GPIO_PIN_7 GPIO_BSRR_BS_7 /*!< Select pin 7 */ #define LL_GPIO_PIN_8 GPIO_BSRR_BS_8 /*!< Select pin 8 */ #define LL_GPIO_PIN_9 GPIO_BSRR_BS_9 /*!< Select pin 9 */ #define LL_GPIO_PIN_10 GPIO_BSRR_BS_10 /*!< Select pin 10 */ #define LL_GPIO_PIN_11 GPIO_BSRR_BS_11 /*!< Select pin 11 */ #define LL_GPIO_PIN_12 GPIO_BSRR_BS_12 /*!< Select pin 12 */ #define LL_GPIO_PIN_13 GPIO_BSRR_BS_13 /*!< Select pin 13 */ #define LL_GPIO_PIN_14 GPIO_BSRR_BS_14 /*!< Select pin 14 */ #define LL_GPIO_PIN_15 GPIO_BSRR_BS_15 /*!< Select pin 15 */ #define LL_GPIO_PIN_ALL (GPIO_BSRR_BS_0 | GPIO_BSRR_BS_1 | GPIO_BSRR_BS_2 | \ GPIO_BSRR_BS_3 | GPIO_BSRR_BS_4 | GPIO_BSRR_BS_5 | \ GPIO_BSRR_BS_6 | GPIO_BSRR_BS_7 | GPIO_BSRR_BS_8 | \ GPIO_BSRR_BS_9 | GPIO_BSRR_BS_10 | GPIO_BSRR_BS_11 | \ GPIO_BSRR_BS_12 | GPIO_BSRR_BS_13 | GPIO_BSRR_BS_14 | \ GPIO_BSRR_BS_15) /*!< Select all pins */ /** * @} */ /** @defgroup GPIO_LL_EC_MODE Mode * @{ */ #define LL_GPIO_MODE_INPUT (0x00000000U) /*!< Select input mode */ #define LL_GPIO_MODE_OUTPUT GPIO_MODER_MODER0_0 /*!< Select output mode */ #define LL_GPIO_MODE_ALTERNATE GPIO_MODER_MODER0_1 /*!< Select alternate function mode */ #define LL_GPIO_MODE_ANALOG GPIO_MODER_MODER0 /*!< Select analog mode */ /** * @} */ /** @defgroup GPIO_LL_EC_OUTPUT Output Type * @{ */ #define LL_GPIO_OUTPUT_PUSHPULL (0x00000000U) /*!< Select push-pull as output type */ #define LL_GPIO_OUTPUT_OPENDRAIN GPIO_OTYPER_OT_0 /*!< Select open-drain as output type */ /** * @} */ /** @defgroup GPIO_LL_EC_SPEED Output Speed * @{ */ #define LL_GPIO_SPEED_FREQ_LOW (0x00000000U) /*!< Select I/O low output speed */ #define LL_GPIO_SPEED_FREQ_MEDIUM GPIO_OSPEEDER_OSPEEDR0_0 /*!< Select I/O medium output speed */ #define LL_GPIO_SPEED_FREQ_HIGH GPIO_OSPEEDER_OSPEEDR0_1 /*!< Select I/O fast output speed */ #define LL_GPIO_SPEED_FREQ_VERY_HIGH GPIO_OSPEEDER_OSPEEDR0 /*!< Select I/O high output speed */ /** * @} */ /** @defgroup GPIO_LL_EC_PULL Pull Up Pull Down * @{ */ #define LL_GPIO_PULL_NO (0x00000000U) /*!< Select I/O no pull */ #define LL_GPIO_PULL_UP GPIO_PUPDR_PUPDR0_0 /*!< Select I/O pull up */ #define LL_GPIO_PULL_DOWN GPIO_PUPDR_PUPDR0_1 /*!< Select I/O pull down */ /** * @} */ /** @defgroup GPIO_LL_EC_AF Alternate Function * @{ */ #define LL_GPIO_AF_0 (0x0000000U) /*!< Select alternate function 0 */ #define LL_GPIO_AF_1 (0x0000001U) /*!< Select alternate function 1 */ #define LL_GPIO_AF_2 (0x0000002U) /*!< Select alternate function 2 */ #define LL_GPIO_AF_3 (0x0000003U) /*!< Select alternate function 3 */ #define LL_GPIO_AF_4 (0x0000004U) /*!< Select alternate function 4 */ #define LL_GPIO_AF_5 (0x0000005U) /*!< Select alternate function 5 */ #define LL_GPIO_AF_6 (0x0000006U) /*!< Select alternate function 6 */ #define LL_GPIO_AF_7 (0x0000007U) /*!< Select alternate function 7 */ #define LL_GPIO_AF_8 (0x0000008U) /*!< Select alternate function 8 */ #define LL_GPIO_AF_9 (0x0000009U) /*!< Select alternate function 9 */ #define LL_GPIO_AF_10 (0x000000AU) /*!< Select alternate function 10 */ #define LL_GPIO_AF_11 (0x000000BU) /*!< Select alternate function 11 */ #define LL_GPIO_AF_12 (0x000000CU) /*!< Select alternate function 12 */ #define LL_GPIO_AF_13 (0x000000DU) /*!< Select alternate function 13 */ #define LL_GPIO_AF_14 (0x000000EU) /*!< Select alternate function 14 */ #define LL_GPIO_AF_15 (0x000000FU) /*!< Select alternate function 15 */ /** * @} */ /** * @} */ /* Exported macro ------------------------------------------------------------*/ /** @defgroup GPIO_LL_Exported_Macros GPIO Exported Macros * @{ */ /** @defgroup GPIO_LL_EM_WRITE_READ Common Write and read registers Macros * @{ */ /** * @brief Write a value in GPIO register * @param __INSTANCE__ GPIO Instance * @param __REG__ Register to be written * @param __VALUE__ Value to be written in the register * @retval None */ #define LL_GPIO_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__)) /** * @brief Read a value in GPIO register * @param __INSTANCE__ GPIO Instance * @param __REG__ Register to be read * @retval Register value */ #define LL_GPIO_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__) /** * @} */ /** * @} */ /* Exported functions --------------------------------------------------------*/ /** @defgroup GPIO_LL_Exported_Functions GPIO Exported Functions * @{ */ /** @defgroup GPIO_LL_EF_Port_Configuration Port Configuration * @{ */ /** * @brief Configure gpio mode for a dedicated pin on dedicated port. * @note I/O mode can be Input mode, General purpose output, Alternate function mode or Analog. * @note Warning: only one pin can be passed as parameter. * @rmtoll MODER MODEy LL_GPIO_SetPinMode * @param GPIOx GPIO Port * @param Pin This parameter can be one of the following values: * @arg @ref LL_GPIO_PIN_0 * @arg @ref LL_GPIO_PIN_1 * @arg @ref LL_GPIO_PIN_2 * @arg @ref LL_GPIO_PIN_3 * @arg @ref LL_GPIO_PIN_4 * @arg @ref LL_GPIO_PIN_5 * @arg @ref LL_GPIO_PIN_6 * @arg @ref LL_GPIO_PIN_7 * @arg @ref LL_GPIO_PIN_8 * @arg @ref LL_GPIO_PIN_9 * @arg @ref LL_GPIO_PIN_10 * @arg @ref LL_GPIO_PIN_11 * @arg @ref LL_GPIO_PIN_12 * @arg @ref LL_GPIO_PIN_13 * @arg @ref LL_GPIO_PIN_14 * @arg @ref LL_GPIO_PIN_15 * @param Mode This parameter can be one of the following values: * @arg @ref LL_GPIO_MODE_INPUT * @arg @ref LL_GPIO_MODE_OUTPUT * @arg @ref LL_GPIO_MODE_ALTERNATE * @arg @ref LL_GPIO_MODE_ANALOG * @retval None */ __STATIC_INLINE void LL_GPIO_SetPinMode(GPIO_TypeDef *GPIOx, uint32_t Pin, uint32_t Mode) { MODIFY_REG(GPIOx->MODER, (GPIO_MODER_MODER0 << (POSITION_VAL(Pin) * 2U)), (Mode << (POSITION_VAL(Pin) * 2U))); } /** * @brief Return gpio mode for a dedicated pin on dedicated port. * @note I/O mode can be Input mode, General purpose output, Alternate function mode or Analog. * @note Warning: only one pin can be passed as parameter. * @rmtoll MODER MODEy LL_GPIO_GetPinMode * @param GPIOx GPIO Port * @param Pin This parameter can be one of the following values: * @arg @ref LL_GPIO_PIN_0 * @arg @ref LL_GPIO_PIN_1 * @arg @ref LL_GPIO_PIN_2 * @arg @ref LL_GPIO_PIN_3 * @arg @ref LL_GPIO_PIN_4 * @arg @ref LL_GPIO_PIN_5 * @arg @ref LL_GPIO_PIN_6 * @arg @ref LL_GPIO_PIN_7 * @arg @ref LL_GPIO_PIN_8 * @arg @ref LL_GPIO_PIN_9 * @arg @ref LL_GPIO_PIN_10 * @arg @ref LL_GPIO_PIN_11 * @arg @ref LL_GPIO_PIN_12 * @arg @ref LL_GPIO_PIN_13 * @arg @ref LL_GPIO_PIN_14 * @arg @ref LL_GPIO_PIN_15 * @retval Returned value can be one of the following values: * @arg @ref LL_GPIO_MODE_INPUT * @arg @ref LL_GPIO_MODE_OUTPUT * @arg @ref LL_GPIO_MODE_ALTERNATE * @arg @ref LL_GPIO_MODE_ANALOG */ __STATIC_INLINE uint32_t LL_GPIO_GetPinMode(GPIO_TypeDef *GPIOx, uint32_t Pin) { return (uint32_t)(READ_BIT(GPIOx->MODER, (GPIO_MODER_MODER0 << (POSITION_VAL(Pin) * 2U))) >> (POSITION_VAL(Pin) * 2U)); } /** * @brief Configure gpio output type for several pins on dedicated port. * @note Output type as to be set when gpio pin is in output or * alternate modes. Possible type are Push-pull or Open-drain. * @rmtoll OTYPER OTy LL_GPIO_SetPinOutputType * @param GPIOx GPIO Port * @param PinMask This parameter can be a combination of the following values: * @arg @ref LL_GPIO_PIN_0 * @arg @ref LL_GPIO_PIN_1 * @arg @ref LL_GPIO_PIN_2 * @arg @ref LL_GPIO_PIN_3 * @arg @ref LL_GPIO_PIN_4 * @arg @ref LL_GPIO_PIN_5 * @arg @ref LL_GPIO_PIN_6 * @arg @ref LL_GPIO_PIN_7 * @arg @ref LL_GPIO_PIN_8 * @arg @ref LL_GPIO_PIN_9 * @arg @ref LL_GPIO_PIN_10 * @arg @ref LL_GPIO_PIN_11 * @arg @ref LL_GPIO_PIN_12 * @arg @ref LL_GPIO_PIN_13 * @arg @ref LL_GPIO_PIN_14 * @arg @ref LL_GPIO_PIN_15 * @arg @ref LL_GPIO_PIN_ALL * @param OutputType This parameter can be one of the following values: * @arg @ref LL_GPIO_OUTPUT_PUSHPULL * @arg @ref LL_GPIO_OUTPUT_OPENDRAIN * @retval None */ __STATIC_INLINE void LL_GPIO_SetPinOutputType(GPIO_TypeDef *GPIOx, uint32_t Pin, uint32_t OutputType) { MODIFY_REG(GPIOx->OTYPER, (GPIO_OTYPER_OT_0 << POSITION_VAL(Pin)), (OutputType << POSITION_VAL(Pin))); } /** * @brief Return gpio output type for several pins on dedicated port. * @note Output type as to be set when gpio pin is in output or * alternate modes. Possible type are Push-pull or Open-drain. * @note Warning: only one pin can be passed as parameter. * @rmtoll OTYPER OTy LL_GPIO_GetPinOutputType * @param GPIOx GPIO Port * @param Pin This parameter can be one of the following values: * @arg @ref LL_GPIO_PIN_0 * @arg @ref LL_GPIO_PIN_1 * @arg @ref LL_GPIO_PIN_2 * @arg @ref LL_GPIO_PIN_3 * @arg @ref LL_GPIO_PIN_4 * @arg @ref LL_GPIO_PIN_5 * @arg @ref LL_GPIO_PIN_6 * @arg @ref LL_GPIO_PIN_7 * @arg @ref LL_GPIO_PIN_8 * @arg @ref LL_GPIO_PIN_9 * @arg @ref LL_GPIO_PIN_10 * @arg @ref LL_GPIO_PIN_11 * @arg @ref LL_GPIO_PIN_12 * @arg @ref LL_GPIO_PIN_13 * @arg @ref LL_GPIO_PIN_14 * @arg @ref LL_GPIO_PIN_15 * @arg @ref LL_GPIO_PIN_ALL * @retval Returned value can be one of the following values: * @arg @ref LL_GPIO_OUTPUT_PUSHPULL * @arg @ref LL_GPIO_OUTPUT_OPENDRAIN */ __STATIC_INLINE uint32_t LL_GPIO_GetPinOutputType(GPIO_TypeDef *GPIOx, uint32_t Pin) { return (uint32_t)(READ_BIT(GPIOx->OTYPER, Pin) >> POSITION_VAL(Pin)); } /** * @brief Configure gpio speed for a dedicated pin on dedicated port. * @note I/O speed can be Low, Medium, Fast or High speed. * @note Warning: only one pin can be passed as parameter. * @note Refer to datasheet for frequency specifications and the power * supply and load conditions for each speed. * @rmtoll OSPEEDR OSPEEDy LL_GPIO_SetPinSpeed * @param GPIOx GPIO Port * @param Pin This parameter can be one of the following values: * @arg @ref LL_GPIO_PIN_0 * @arg @ref LL_GPIO_PIN_1 * @arg @ref LL_GPIO_PIN_2 * @arg @ref LL_GPIO_PIN_3 * @arg @ref LL_GPIO_PIN_4 * @arg @ref LL_GPIO_PIN_5 * @arg @ref LL_GPIO_PIN_6 * @arg @ref LL_GPIO_PIN_7 * @arg @ref LL_GPIO_PIN_8 * @arg @ref LL_GPIO_PIN_9 * @arg @ref LL_GPIO_PIN_10 * @arg @ref LL_GPIO_PIN_11 * @arg @ref LL_GPIO_PIN_12 * @arg @ref LL_GPIO_PIN_13 * @arg @ref LL_GPIO_PIN_14 * @arg @ref LL_GPIO_PIN_15 * @param Speed This parameter can be one of the following values: * @arg @ref LL_GPIO_SPEED_FREQ_LOW * @arg @ref LL_GPIO_SPEED_FREQ_MEDIUM * @arg @ref LL_GPIO_SPEED_FREQ_HIGH * @arg @ref LL_GPIO_SPEED_FREQ_VERY_HIGH * @retval None */ __STATIC_INLINE void LL_GPIO_SetPinSpeed(GPIO_TypeDef *GPIOx, uint32_t Pin, uint32_t Speed) { MODIFY_REG(GPIOx->OSPEEDR, (GPIO_OSPEEDER_OSPEEDR0 << (POSITION_VAL(Pin) * 2U)), (Speed << (POSITION_VAL(Pin) * 2U))); } /** * @brief Return gpio speed for a dedicated pin on dedicated port. * @note I/O speed can be Low, Medium, Fast or High speed. * @note Warning: only one pin can be passed as parameter. * @note Refer to datasheet for frequency specifications and the power * supply and load conditions for each speed. * @rmtoll OSPEEDR OSPEEDy LL_GPIO_GetPinSpeed * @param GPIOx GPIO Port * @param Pin This parameter can be one of the following values: * @arg @ref LL_GPIO_PIN_0 * @arg @ref LL_GPIO_PIN_1 * @arg @ref LL_GPIO_PIN_2 * @arg @ref LL_GPIO_PIN_3 * @arg @ref LL_GPIO_PIN_4 * @arg @ref LL_GPIO_PIN_5 * @arg @ref LL_GPIO_PIN_6 * @arg @ref LL_GPIO_PIN_7 * @arg @ref LL_GPIO_PIN_8 * @arg @ref LL_GPIO_PIN_9 * @arg @ref LL_GPIO_PIN_10 * @arg @ref LL_GPIO_PIN_11 * @arg @ref LL_GPIO_PIN_12 * @arg @ref LL_GPIO_PIN_13 * @arg @ref LL_GPIO_PIN_14 * @arg @ref LL_GPIO_PIN_15 * @retval Returned value can be one of the following values: * @arg @ref LL_GPIO_SPEED_FREQ_LOW * @arg @ref LL_GPIO_SPEED_FREQ_MEDIUM * @arg @ref LL_GPIO_SPEED_FREQ_HIGH * @arg @ref LL_GPIO_SPEED_FREQ_VERY_HIGH */ __STATIC_INLINE uint32_t LL_GPIO_GetPinSpeed(GPIO_TypeDef *GPIOx, uint32_t Pin) { return (uint32_t)(READ_BIT(GPIOx->OSPEEDR, (GPIO_OSPEEDER_OSPEEDR0 << (POSITION_VAL(Pin) * 2U))) >> (POSITION_VAL(Pin) * 2U)); } /** * @brief Configure gpio pull-up or pull-down for a dedicated pin on a dedicated port. * @note Warning: only one pin can be passed as parameter. * @rmtoll PUPDR PUPDy LL_GPIO_SetPinPull * @param GPIOx GPIO Port * @param Pin This parameter can be one of the following values: * @arg @ref LL_GPIO_PIN_0 * @arg @ref LL_GPIO_PIN_1 * @arg @ref LL_GPIO_PIN_2 * @arg @ref LL_GPIO_PIN_3 * @arg @ref LL_GPIO_PIN_4 * @arg @ref LL_GPIO_PIN_5 * @arg @ref LL_GPIO_PIN_6 * @arg @ref LL_GPIO_PIN_7 * @arg @ref LL_GPIO_PIN_8 * @arg @ref LL_GPIO_PIN_9 * @arg @ref LL_GPIO_PIN_10 * @arg @ref LL_GPIO_PIN_11 * @arg @ref LL_GPIO_PIN_12 * @arg @ref LL_GPIO_PIN_13 * @arg @ref LL_GPIO_PIN_14 * @arg @ref LL_GPIO_PIN_15 * @param Pull This parameter can be one of the following values: * @arg @ref LL_GPIO_PULL_NO * @arg @ref LL_GPIO_PULL_UP * @arg @ref LL_GPIO_PULL_DOWN * @retval None */ __STATIC_INLINE void LL_GPIO_SetPinPull(GPIO_TypeDef *GPIOx, uint32_t Pin, uint32_t Pull) { MODIFY_REG(GPIOx->PUPDR, (GPIO_PUPDR_PUPDR0 << (POSITION_VAL(Pin) * 2U)), (Pull << (POSITION_VAL(Pin) * 2U))); } /** * @brief Return gpio pull-up or pull-down for a dedicated pin on a dedicated port * @note Warning: only one pin can be passed as parameter. * @rmtoll PUPDR PUPDy LL_GPIO_GetPinPull * @param GPIOx GPIO Port * @param Pin This parameter can be one of the following values: * @arg @ref LL_GPIO_PIN_0 * @arg @ref LL_GPIO_PIN_1 * @arg @ref LL_GPIO_PIN_2 * @arg @ref LL_GPIO_PIN_3 * @arg @ref LL_GPIO_PIN_4 * @arg @ref LL_GPIO_PIN_5 * @arg @ref LL_GPIO_PIN_6 * @arg @ref LL_GPIO_PIN_7 * @arg @ref LL_GPIO_PIN_8 * @arg @ref LL_GPIO_PIN_9 * @arg @ref LL_GPIO_PIN_10 * @arg @ref LL_GPIO_PIN_11 * @arg @ref LL_GPIO_PIN_12 * @arg @ref LL_GPIO_PIN_13 * @arg @ref LL_GPIO_PIN_14 * @arg @ref LL_GPIO_PIN_15 * @retval Returned value can be one of the following values: * @arg @ref LL_GPIO_PULL_NO * @arg @ref LL_GPIO_PULL_UP * @arg @ref LL_GPIO_PULL_DOWN */ __STATIC_INLINE uint32_t LL_GPIO_GetPinPull(GPIO_TypeDef *GPIOx, uint32_t Pin) { return (uint32_t)(READ_BIT(GPIOx->PUPDR, (GPIO_PUPDR_PUPDR0 << (POSITION_VAL(Pin) * 2U))) >> (POSITION_VAL(Pin) * 2U)); } /** * @brief Configure gpio alternate function of a dedicated pin from 0 to 7 for a dedicated port. * @note Possible values are from AF0 to AF15 depending on target. * @note Warning: only one pin can be passed as parameter. * @rmtoll AFRL AFSELy LL_GPIO_SetAFPin_0_7 * @param GPIOx GPIO Port * @param Pin This parameter can be one of the following values: * @arg @ref LL_GPIO_PIN_0 * @arg @ref LL_GPIO_PIN_1 * @arg @ref LL_GPIO_PIN_2 * @arg @ref LL_GPIO_PIN_3 * @arg @ref LL_GPIO_PIN_4 * @arg @ref LL_GPIO_PIN_5 * @arg @ref LL_GPIO_PIN_6 * @arg @ref LL_GPIO_PIN_7 * @param Alternate This parameter can be one of the following values: * @arg @ref LL_GPIO_AF_0 * @arg @ref LL_GPIO_AF_1 * @arg @ref LL_GPIO_AF_2 * @arg @ref LL_GPIO_AF_3 * @arg @ref LL_GPIO_AF_4 * @arg @ref LL_GPIO_AF_5 * @arg @ref LL_GPIO_AF_6 * @arg @ref LL_GPIO_AF_7 * @arg @ref LL_GPIO_AF_8 * @arg @ref LL_GPIO_AF_9 * @arg @ref LL_GPIO_AF_10 * @arg @ref LL_GPIO_AF_11 * @arg @ref LL_GPIO_AF_12 * @arg @ref LL_GPIO_AF_13 * @arg @ref LL_GPIO_AF_14 * @arg @ref LL_GPIO_AF_15 * @retval None */ __STATIC_INLINE void LL_GPIO_SetAFPin_0_7(GPIO_TypeDef *GPIOx, uint32_t Pin, uint32_t Alternate) { MODIFY_REG(GPIOx->AFR[0], (GPIO_AFRL_AFSEL0 << (POSITION_VAL(Pin) * 4U)), (Alternate << (POSITION_VAL(Pin) * 4U))); } /** * @brief Return gpio alternate function of a dedicated pin from 0 to 7 for a dedicated port. * @rmtoll AFRL AFSELy LL_GPIO_GetAFPin_0_7 * @param GPIOx GPIO Port * @param Pin This parameter can be one of the following values: * @arg @ref LL_GPIO_PIN_0 * @arg @ref LL_GPIO_PIN_1 * @arg @ref LL_GPIO_PIN_2 * @arg @ref LL_GPIO_PIN_3 * @arg @ref LL_GPIO_PIN_4 * @arg @ref LL_GPIO_PIN_5 * @arg @ref LL_GPIO_PIN_6 * @arg @ref LL_GPIO_PIN_7 * @retval Returned value can be one of the following values: * @arg @ref LL_GPIO_AF_0 * @arg @ref LL_GPIO_AF_1 * @arg @ref LL_GPIO_AF_2 * @arg @ref LL_GPIO_AF_3 * @arg @ref LL_GPIO_AF_4 * @arg @ref LL_GPIO_AF_5 * @arg @ref LL_GPIO_AF_6 * @arg @ref LL_GPIO_AF_7 * @arg @ref LL_GPIO_AF_8 * @arg @ref LL_GPIO_AF_9 * @arg @ref LL_GPIO_AF_10 * @arg @ref LL_GPIO_AF_11 * @arg @ref LL_GPIO_AF_12 * @arg @ref LL_GPIO_AF_13 * @arg @ref LL_GPIO_AF_14 * @arg @ref LL_GPIO_AF_15 */ __STATIC_INLINE uint32_t LL_GPIO_GetAFPin_0_7(GPIO_TypeDef *GPIOx, uint32_t Pin) { return (uint32_t)(READ_BIT(GPIOx->AFR[0], (GPIO_AFRL_AFSEL0 << (POSITION_VAL(Pin) * 4U))) >> (POSITION_VAL(Pin) * 4U)); } /** * @brief Configure gpio alternate function of a dedicated pin from 8 to 15 for a dedicated port. * @note Possible values are from AF0 to AF15 depending on target. * @note Warning: only one pin can be passed as parameter. * @rmtoll AFRH AFSELy LL_GPIO_SetAFPin_8_15 * @param GPIOx GPIO Port * @param Pin This parameter can be one of the following values: * @arg @ref LL_GPIO_PIN_8 * @arg @ref LL_GPIO_PIN_9 * @arg @ref LL_GPIO_PIN_10 * @arg @ref LL_GPIO_PIN_11 * @arg @ref LL_GPIO_PIN_12 * @arg @ref LL_GPIO_PIN_13 * @arg @ref LL_GPIO_PIN_14 * @arg @ref LL_GPIO_PIN_15 * @param Alternate This parameter can be one of the following values: * @arg @ref LL_GPIO_AF_0 * @arg @ref LL_GPIO_AF_1 * @arg @ref LL_GPIO_AF_2 * @arg @ref LL_GPIO_AF_3 * @arg @ref LL_GPIO_AF_4 * @arg @ref LL_GPIO_AF_5 * @arg @ref LL_GPIO_AF_6 * @arg @ref LL_GPIO_AF_7 * @arg @ref LL_GPIO_AF_8 * @arg @ref LL_GPIO_AF_9 * @arg @ref LL_GPIO_AF_10 * @arg @ref LL_GPIO_AF_11 * @arg @ref LL_GPIO_AF_12 * @arg @ref LL_GPIO_AF_13 * @arg @ref LL_GPIO_AF_14 * @arg @ref LL_GPIO_AF_15 * @retval None */ __STATIC_INLINE void LL_GPIO_SetAFPin_8_15(GPIO_TypeDef *GPIOx, uint32_t Pin, uint32_t Alternate) { MODIFY_REG(GPIOx->AFR[1], (GPIO_AFRH_AFSEL8 << (POSITION_VAL(Pin >> 8U) * 4U)), (Alternate << (POSITION_VAL(Pin >> 8U) * 4U))); } /** * @brief Return gpio alternate function of a dedicated pin from 8 to 15 for a dedicated port. * @note Possible values are from AF0 to AF15 depending on target. * @rmtoll AFRH AFSELy LL_GPIO_GetAFPin_8_15 * @param GPIOx GPIO Port * @param Pin This parameter can be one of the following values: * @arg @ref LL_GPIO_PIN_8 * @arg @ref LL_GPIO_PIN_9 * @arg @ref LL_GPIO_PIN_10 * @arg @ref LL_GPIO_PIN_11 * @arg @ref LL_GPIO_PIN_12 * @arg @ref LL_GPIO_PIN_13 * @arg @ref LL_GPIO_PIN_14 * @arg @ref LL_GPIO_PIN_15 * @retval Returned value can be one of the following values: * @arg @ref LL_GPIO_AF_0 * @arg @ref LL_GPIO_AF_1 * @arg @ref LL_GPIO_AF_2 * @arg @ref LL_GPIO_AF_3 * @arg @ref LL_GPIO_AF_4 * @arg @ref LL_GPIO_AF_5 * @arg @ref LL_GPIO_AF_6 * @arg @ref LL_GPIO_AF_7 * @arg @ref LL_GPIO_AF_8 * @arg @ref LL_GPIO_AF_9 * @arg @ref LL_GPIO_AF_10 * @arg @ref LL_GPIO_AF_11 * @arg @ref LL_GPIO_AF_12 * @arg @ref LL_GPIO_AF_13 * @arg @ref LL_GPIO_AF_14 * @arg @ref LL_GPIO_AF_15 */ __STATIC_INLINE uint32_t LL_GPIO_GetAFPin_8_15(GPIO_TypeDef *GPIOx, uint32_t Pin) { return (uint32_t)(READ_BIT(GPIOx->AFR[1], (GPIO_AFRH_AFSEL8 << (POSITION_VAL(Pin >> 8U) * 4U))) >> (POSITION_VAL(Pin >> 8U) * 4U)); } /** * @brief Lock configuration of several pins for a dedicated port. * @note When the lock sequence has been applied on a port bit, the * value of this port bit can no longer be modified until the * next reset. * @note Each lock bit freezes a specific configuration register * (control and alternate function registers). * @rmtoll LCKR LCKK LL_GPIO_LockPin * @param GPIOx GPIO Port * @param PinMask This parameter can be a combination of the following values: * @arg @ref LL_GPIO_PIN_0 * @arg @ref LL_GPIO_PIN_1 * @arg @ref LL_GPIO_PIN_2 * @arg @ref LL_GPIO_PIN_3 * @arg @ref LL_GPIO_PIN_4 * @arg @ref LL_GPIO_PIN_5 * @arg @ref LL_GPIO_PIN_6 * @arg @ref LL_GPIO_PIN_7 * @arg @ref LL_GPIO_PIN_8 * @arg @ref LL_GPIO_PIN_9 * @arg @ref LL_GPIO_PIN_10 * @arg @ref LL_GPIO_PIN_11 * @arg @ref LL_GPIO_PIN_12 * @arg @ref LL_GPIO_PIN_13 * @arg @ref LL_GPIO_PIN_14 * @arg @ref LL_GPIO_PIN_15 * @arg @ref LL_GPIO_PIN_ALL * @retval None */ __STATIC_INLINE void LL_GPIO_LockPin(GPIO_TypeDef *GPIOx, uint32_t PinMask) { __IO uint32_t temp; WRITE_REG(GPIOx->LCKR, GPIO_LCKR_LCKK | PinMask); WRITE_REG(GPIOx->LCKR, PinMask); WRITE_REG(GPIOx->LCKR, GPIO_LCKR_LCKK | PinMask); temp = READ_REG(GPIOx->LCKR); (void) temp; } /** * @brief Return 1 if all pins passed as parameter, of a dedicated port, are locked. else Return 0. * @rmtoll LCKR LCKy LL_GPIO_IsPinLocked * @param GPIOx GPIO Port * @param PinMask This parameter can be a combination of the following values: * @arg @ref LL_GPIO_PIN_0 * @arg @ref LL_GPIO_PIN_1 * @arg @ref LL_GPIO_PIN_2 * @arg @ref LL_GPIO_PIN_3 * @arg @ref LL_GPIO_PIN_4 * @arg @ref LL_GPIO_PIN_5 * @arg @ref LL_GPIO_PIN_6 * @arg @ref LL_GPIO_PIN_7 * @arg @ref LL_GPIO_PIN_8 * @arg @ref LL_GPIO_PIN_9 * @arg @ref LL_GPIO_PIN_10 * @arg @ref LL_GPIO_PIN_11 * @arg @ref LL_GPIO_PIN_12 * @arg @ref LL_GPIO_PIN_13 * @arg @ref LL_GPIO_PIN_14 * @arg @ref LL_GPIO_PIN_15 * @arg @ref LL_GPIO_PIN_ALL * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_GPIO_IsPinLocked(GPIO_TypeDef *GPIOx, uint32_t PinMask) { return (READ_BIT(GPIOx->LCKR, PinMask) == (PinMask)); } /** * @brief Return 1 if one of the pin of a dedicated port is locked. else return 0. * @rmtoll LCKR LCKK LL_GPIO_IsAnyPinLocked * @param GPIOx GPIO Port * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_GPIO_IsAnyPinLocked(GPIO_TypeDef *GPIOx) { return (READ_BIT(GPIOx->LCKR, GPIO_LCKR_LCKK) == (GPIO_LCKR_LCKK)); } /** * @} */ /** @defgroup GPIO_LL_EF_Data_Access Data Access * @{ */ /** * @brief Return full input data register value for a dedicated port. * @rmtoll IDR IDy LL_GPIO_ReadInputPort * @param GPIOx GPIO Port * @retval Input data register value of port */ __STATIC_INLINE uint32_t LL_GPIO_ReadInputPort(GPIO_TypeDef *GPIOx) { return (uint32_t)(READ_REG(GPIOx->IDR)); } /** * @brief Return if input data level for several pins of dedicated port is high or low. * @rmtoll IDR IDy LL_GPIO_IsInputPinSet * @param GPIOx GPIO Port * @param PinMask This parameter can be a combination of the following values: * @arg @ref LL_GPIO_PIN_0 * @arg @ref LL_GPIO_PIN_1 * @arg @ref LL_GPIO_PIN_2 * @arg @ref LL_GPIO_PIN_3 * @arg @ref LL_GPIO_PIN_4 * @arg @ref LL_GPIO_PIN_5 * @arg @ref LL_GPIO_PIN_6 * @arg @ref LL_GPIO_PIN_7 * @arg @ref LL_GPIO_PIN_8 * @arg @ref LL_GPIO_PIN_9 * @arg @ref LL_GPIO_PIN_10 * @arg @ref LL_GPIO_PIN_11 * @arg @ref LL_GPIO_PIN_12 * @arg @ref LL_GPIO_PIN_13 * @arg @ref LL_GPIO_PIN_14 * @arg @ref LL_GPIO_PIN_15 * @arg @ref LL_GPIO_PIN_ALL * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_GPIO_IsInputPinSet(GPIO_TypeDef *GPIOx, uint32_t PinMask) { return (READ_BIT(GPIOx->IDR, PinMask) == (PinMask)); } /** * @brief Write output data register for the port. * @rmtoll ODR ODy LL_GPIO_WriteOutputPort * @param GPIOx GPIO Port * @param PortValue Level value for each pin of the port * @retval None */ __STATIC_INLINE void LL_GPIO_WriteOutputPort(GPIO_TypeDef *GPIOx, uint32_t PortValue) { WRITE_REG(GPIOx->ODR, PortValue); } /** * @brief Return full output data register value for a dedicated port. * @rmtoll ODR ODy LL_GPIO_ReadOutputPort * @param GPIOx GPIO Port * @retval Output data register value of port */ __STATIC_INLINE uint32_t LL_GPIO_ReadOutputPort(GPIO_TypeDef *GPIOx) { return (uint32_t)(READ_REG(GPIOx->ODR)); } /** * @brief Return if input data level for several pins of dedicated port is high or low. * @rmtoll ODR ODy LL_GPIO_IsOutputPinSet * @param GPIOx GPIO Port * @param PinMask This parameter can be a combination of the following values: * @arg @ref LL_GPIO_PIN_0 * @arg @ref LL_GPIO_PIN_1 * @arg @ref LL_GPIO_PIN_2 * @arg @ref LL_GPIO_PIN_3 * @arg @ref LL_GPIO_PIN_4 * @arg @ref LL_GPIO_PIN_5 * @arg @ref LL_GPIO_PIN_6 * @arg @ref LL_GPIO_PIN_7 * @arg @ref LL_GPIO_PIN_8 * @arg @ref LL_GPIO_PIN_9 * @arg @ref LL_GPIO_PIN_10 * @arg @ref LL_GPIO_PIN_11 * @arg @ref LL_GPIO_PIN_12 * @arg @ref LL_GPIO_PIN_13 * @arg @ref LL_GPIO_PIN_14 * @arg @ref LL_GPIO_PIN_15 * @arg @ref LL_GPIO_PIN_ALL * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_GPIO_IsOutputPinSet(GPIO_TypeDef *GPIOx, uint32_t PinMask) { return (READ_BIT(GPIOx->ODR, PinMask) == (PinMask)); } /** * @brief Set several pins to high level on dedicated gpio port. * @rmtoll BSRR BSy LL_GPIO_SetOutputPin * @param GPIOx GPIO Port * @param PinMask This parameter can be a combination of the following values: * @arg @ref LL_GPIO_PIN_0 * @arg @ref LL_GPIO_PIN_1 * @arg @ref LL_GPIO_PIN_2 * @arg @ref LL_GPIO_PIN_3 * @arg @ref LL_GPIO_PIN_4 * @arg @ref LL_GPIO_PIN_5 * @arg @ref LL_GPIO_PIN_6 * @arg @ref LL_GPIO_PIN_7 * @arg @ref LL_GPIO_PIN_8 * @arg @ref LL_GPIO_PIN_9 * @arg @ref LL_GPIO_PIN_10 * @arg @ref LL_GPIO_PIN_11 * @arg @ref LL_GPIO_PIN_12 * @arg @ref LL_GPIO_PIN_13 * @arg @ref LL_GPIO_PIN_14 * @arg @ref LL_GPIO_PIN_15 * @arg @ref LL_GPIO_PIN_ALL * @retval None */ __STATIC_INLINE void LL_GPIO_SetOutputPin(GPIO_TypeDef *GPIOx, uint32_t PinMask) { WRITE_REG(GPIOx->BSRR, PinMask); } /** * @brief Set several pins to low level on dedicated gpio port. * @rmtoll BSRR BRy LL_GPIO_ResetOutputPin * @param GPIOx GPIO Port * @param PinMask This parameter can be a combination of the following values: * @arg @ref LL_GPIO_PIN_0 * @arg @ref LL_GPIO_PIN_1 * @arg @ref LL_GPIO_PIN_2 * @arg @ref LL_GPIO_PIN_3 * @arg @ref LL_GPIO_PIN_4 * @arg @ref LL_GPIO_PIN_5 * @arg @ref LL_GPIO_PIN_6 * @arg @ref LL_GPIO_PIN_7 * @arg @ref LL_GPIO_PIN_8 * @arg @ref LL_GPIO_PIN_9 * @arg @ref LL_GPIO_PIN_10 * @arg @ref LL_GPIO_PIN_11 * @arg @ref LL_GPIO_PIN_12 * @arg @ref LL_GPIO_PIN_13 * @arg @ref LL_GPIO_PIN_14 * @arg @ref LL_GPIO_PIN_15 * @arg @ref LL_GPIO_PIN_ALL * @retval None */ __STATIC_INLINE void LL_GPIO_ResetOutputPin(GPIO_TypeDef *GPIOx, uint32_t PinMask) { WRITE_REG(GPIOx->BSRR, (PinMask << 16)); } /** * @brief Toggle data value for several pin of dedicated port. * @rmtoll ODR ODy LL_GPIO_TogglePin * @param GPIOx GPIO Port * @param PinMask This parameter can be a combination of the following values: * @arg @ref LL_GPIO_PIN_0 * @arg @ref LL_GPIO_PIN_1 * @arg @ref LL_GPIO_PIN_2 * @arg @ref LL_GPIO_PIN_3 * @arg @ref LL_GPIO_PIN_4 * @arg @ref LL_GPIO_PIN_5 * @arg @ref LL_GPIO_PIN_6 * @arg @ref LL_GPIO_PIN_7 * @arg @ref LL_GPIO_PIN_8 * @arg @ref LL_GPIO_PIN_9 * @arg @ref LL_GPIO_PIN_10 * @arg @ref LL_GPIO_PIN_11 * @arg @ref LL_GPIO_PIN_12 * @arg @ref LL_GPIO_PIN_13 * @arg @ref LL_GPIO_PIN_14 * @arg @ref LL_GPIO_PIN_15 * @arg @ref LL_GPIO_PIN_ALL * @retval None */ __STATIC_INLINE void LL_GPIO_TogglePin(GPIO_TypeDef *GPIOx, uint32_t PinMask) { WRITE_REG(GPIOx->ODR, READ_REG(GPIOx->ODR) ^ PinMask); } /** * @brief Call proper function to configure gpio alternate function of a dedicated pin for a dedicated port. * @note This function is an extension to the LL_GPIO library. */ __STATIC_INLINE void LL_GPIO_SetAFPin(GPIO_TypeDef *GPIOx, uint32_t Pin, uint32_t Alternate) { if (Pin >= LL_GPIO_PIN_0 && Pin <= LL_GPIO_PIN_7) { LL_GPIO_SetAFPin_0_7(GPIOx, Pin, Alternate); } else { LL_GPIO_SetAFPin_8_15(GPIOx, Pin, Alternate); } } /** * @} */ #if defined(USE_FULL_LL_DRIVER) /** @defgroup GPIO_LL_EF_Init Initialization and de-initialization functions * @{ */ ErrorStatus LL_GPIO_DeInit(GPIO_TypeDef *GPIOx); ErrorStatus LL_GPIO_Init(GPIO_TypeDef *GPIOx, LL_GPIO_InitTypeDef *GPIO_InitStruct); void LL_GPIO_StructInit(LL_GPIO_InitTypeDef *GPIO_InitStruct); /** * @} */ #endif /* USE_FULL_LL_DRIVER */ /** * @} */ /** * @} */ #endif /* defined (GPIOA) || defined (GPIOB) || defined (GPIOC) || defined (GPIOD) || defined (GPIOE) || defined (GPIOF) || defined (GPIOG) || defined (GPIOH) || defined (GPIOI) || defined (GPIOJ) || defined (GPIOK) */ /** * @} */ #ifdef __cplusplus } #endif #endif /* __STM32F4xx_LL_GPIO_H */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ ================================================ FILE: sys/arch/stm32/hal/stm32f4xx_ll_pwr.h ================================================ /** ****************************************************************************** * @file stm32f4xx_ll_pwr.h * @author MCD Application Team * @version V1.7.1 * @date 14-April-2017 * @brief Header file of PWR LL module. ****************************************************************************** * @attention * *

© COPYRIGHT(c) 2017 STMicroelectronics

* * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. Neither the name of STMicroelectronics nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __STM32F4xx_LL_PWR_H #define __STM32F4xx_LL_PWR_H #ifdef __cplusplus extern "C" { #endif /* Includes ------------------------------------------------------------------*/ #include "stm32f4xx.h" /** @addtogroup STM32F4xx_LL_Driver * @{ */ #if defined(PWR) /** @defgroup PWR_LL PWR * @{ */ /* Private types -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ /* Private constants ---------------------------------------------------------*/ /* Private macros ------------------------------------------------------------*/ /* Exported types ------------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/ /** @defgroup PWR_LL_Exported_Constants PWR Exported Constants * @{ */ /** @defgroup PWR_LL_EC_CLEAR_FLAG Clear Flags Defines * @brief Flags defines which can be used with LL_PWR_WriteReg function * @{ */ #define LL_PWR_CR_CSBF PWR_CR_CSBF /*!< Clear standby flag */ #define LL_PWR_CR_CWUF PWR_CR_CWUF /*!< Clear wakeup flag */ /** * @} */ /** @defgroup PWR_LL_EC_GET_FLAG Get Flags Defines * @brief Flags defines which can be used with LL_PWR_ReadReg function * @{ */ #define LL_PWR_CSR_WUF PWR_CSR_WUF /*!< Wakeup flag */ #define LL_PWR_CSR_SBF PWR_CSR_SBF /*!< Standby flag */ #define LL_PWR_CSR_PVDO PWR_CSR_PVDO /*!< Power voltage detector output flag */ #define LL_PWR_CSR_VOS PWR_CSR_VOSRDY /*!< Voltage scaling select flag */ #if defined(PWR_CSR_EWUP) #define LL_PWR_CSR_EWUP1 PWR_CSR_EWUP /*!< Enable WKUP pin */ #elif defined(PWR_CSR_EWUP1) #define LL_PWR_CSR_EWUP1 PWR_CSR_EWUP1 /*!< Enable WKUP pin 1 */ #endif /* PWR_CSR_EWUP */ #if defined(PWR_CSR_EWUP2) #define LL_PWR_CSR_EWUP2 PWR_CSR_EWUP2 /*!< Enable WKUP pin 2 */ #endif /* PWR_CSR_EWUP2 */ #if defined(PWR_CSR_EWUP3) #define LL_PWR_CSR_EWUP3 PWR_CSR_EWUP3 /*!< Enable WKUP pin 3 */ #endif /* PWR_CSR_EWUP3 */ /** * @} */ /** @defgroup PWR_LL_EC_REGU_VOLTAGE Regulator Voltage * @{ */ #if defined(PWR_CR_VOS_0) #define LL_PWR_REGU_VOLTAGE_SCALE3 (PWR_CR_VOS_0) #define LL_PWR_REGU_VOLTAGE_SCALE2 (PWR_CR_VOS_1) #define LL_PWR_REGU_VOLTAGE_SCALE1 (PWR_CR_VOS_0 | PWR_CR_VOS_1) /* The SCALE1 is not available for STM32F401xx devices */ #else #define LL_PWR_REGU_VOLTAGE_SCALE1 (PWR_CR_VOS) #define LL_PWR_REGU_VOLTAGE_SCALE2 0x00000000U #endif /* PWR_CR_VOS_0 */ /** * @} */ /** @defgroup PWR_LL_EC_MODE_PWR Mode Power * @{ */ #define LL_PWR_MODE_STOP_MAINREGU 0x00000000U /*!< Enter Stop mode when the CPU enters deepsleep */ #define LL_PWR_MODE_STOP_LPREGU (PWR_CR_LPDS) /*!< Enter Stop mode (with low power Regulator ON) when the CPU enters deepsleep */ #if defined(PWR_CR_MRUDS) && defined(PWR_CR_LPUDS) && defined(PWR_CR_FPDS) #define LL_PWR_MODE_STOP_MAINREGU_UNDERDRIVE (PWR_CR_MRUDS | PWR_CR_FPDS) /*!< Enter Stop mode (with main Regulator in under-drive mode) when the CPU enters deepsleep */ #define LL_PWR_MODE_STOP_LPREGU_UNDERDRIVE (PWR_CR_LPDS | PWR_CR_LPUDS | PWR_CR_FPDS) /*!< Enter Stop mode (with low power Regulator in under-drive mode) when the CPU enters deepsleep */ #endif /* PWR_CR_MRUDS && PWR_CR_LPUDS && PWR_CR_FPDS */ #if defined(PWR_CR_MRLVDS) && defined(PWR_CR_LPLVDS) && defined(PWR_CR_FPDS) #define LL_PWR_MODE_STOP_MAINREGU_DEEPSLEEP (PWR_CR_MRLVDS | PWR_CR_FPDS) /*!< Enter Stop mode (with main Regulator in Deep Sleep mode) when the CPU enters deepsleep */ #define LL_PWR_MODE_STOP_LPREGU_DEEPSLEEP (PWR_CR_LPDS | PWR_CR_LPLVDS | PWR_CR_FPDS) /*!< Enter Stop mode (with low power Regulator in Deep Sleep mode) when the CPU enters deepsleep */ #endif /* PWR_CR_MRLVDS && PWR_CR_LPLVDS && PWR_CR_FPDS */ #define LL_PWR_MODE_STANDBY (PWR_CR_PDDS) /*!< Enter Standby mode when the CPU enters deepsleep */ /** * @} */ /** @defgroup PWR_LL_EC_REGU_MODE_DS_MODE Regulator Mode In Deep Sleep Mode * @{ */ #define LL_PWR_REGU_DSMODE_MAIN 0x00000000U /*!< Voltage Regulator in main mode during deepsleep mode */ #define LL_PWR_REGU_DSMODE_LOW_POWER (PWR_CR_LPDS) /*!< Voltage Regulator in low-power mode during deepsleep mode */ /** * @} */ /** @defgroup PWR_LL_EC_PVDLEVEL Power Voltage Detector Level * @{ */ #define LL_PWR_PVDLEVEL_0 (PWR_CR_PLS_LEV0) /*!< Voltage threshold detected by PVD 2.2 V */ #define LL_PWR_PVDLEVEL_1 (PWR_CR_PLS_LEV1) /*!< Voltage threshold detected by PVD 2.3 V */ #define LL_PWR_PVDLEVEL_2 (PWR_CR_PLS_LEV2) /*!< Voltage threshold detected by PVD 2.4 V */ #define LL_PWR_PVDLEVEL_3 (PWR_CR_PLS_LEV3) /*!< Voltage threshold detected by PVD 2.5 V */ #define LL_PWR_PVDLEVEL_4 (PWR_CR_PLS_LEV4) /*!< Voltage threshold detected by PVD 2.6 V */ #define LL_PWR_PVDLEVEL_5 (PWR_CR_PLS_LEV5) /*!< Voltage threshold detected by PVD 2.7 V */ #define LL_PWR_PVDLEVEL_6 (PWR_CR_PLS_LEV6) /*!< Voltage threshold detected by PVD 2.8 V */ #define LL_PWR_PVDLEVEL_7 (PWR_CR_PLS_LEV7) /*!< Voltage threshold detected by PVD 2.9 V */ /** * @} */ /** @defgroup PWR_LL_EC_WAKEUP_PIN Wakeup Pins * @{ */ #if defined(PWR_CSR_EWUP) #define LL_PWR_WAKEUP_PIN1 (PWR_CSR_EWUP) /*!< WKUP pin : PA0 */ #endif /* PWR_CSR_EWUP */ #if defined(PWR_CSR_EWUP1) #define LL_PWR_WAKEUP_PIN1 (PWR_CSR_EWUP1) /*!< WKUP pin 1 : PA0 */ #endif /* PWR_CSR_EWUP1 */ #if defined(PWR_CSR_EWUP2) #define LL_PWR_WAKEUP_PIN2 (PWR_CSR_EWUP2) /*!< WKUP pin 2 : PC0 or PC13 according to device */ #endif /* PWR_CSR_EWUP2 */ #if defined(PWR_CSR_EWUP3) #define LL_PWR_WAKEUP_PIN3 (PWR_CSR_EWUP3) /*!< WKUP pin 3 : PC1 */ #endif /* PWR_CSR_EWUP3 */ /** * @} */ /** * @} */ /* Exported macro ------------------------------------------------------------*/ /** @defgroup PWR_LL_Exported_Macros PWR Exported Macros * @{ */ /** @defgroup PWR_LL_EM_WRITE_READ Common write and read registers Macros * @{ */ /** * @brief Write a value in PWR register * @param __REG__ Register to be written * @param __VALUE__ Value to be written in the register * @retval None */ #define LL_PWR_WriteReg(__REG__, __VALUE__) WRITE_REG(PWR->__REG__, (__VALUE__)) /** * @brief Read a value in PWR register * @param __REG__ Register to be read * @retval Register value */ #define LL_PWR_ReadReg(__REG__) READ_REG(PWR->__REG__) /** * @} */ /** * @} */ /* Exported functions --------------------------------------------------------*/ /** @defgroup PWR_LL_Exported_Functions PWR Exported Functions * @{ */ /** @defgroup PWR_LL_EF_Configuration Configuration * @{ */ #if defined(PWR_CR_FISSR) /** * @brief Enable FLASH interface STOP while system Run is ON * @rmtoll CR FISSR LL_PWR_EnableFLASHInterfaceSTOP * @note This mode is enabled only with STOP low power mode. * @retval None */ __STATIC_INLINE void LL_PWR_EnableFLASHInterfaceSTOP(void) { SET_BIT(PWR->CR, PWR_CR_FISSR); } /** * @brief Disable FLASH Interface STOP while system Run is ON * @rmtoll CR FISSR LL_PWR_DisableFLASHInterfaceSTOP * @retval None */ __STATIC_INLINE void LL_PWR_DisableFLASHInterfaceSTOP(void) { CLEAR_BIT(PWR->CR, PWR_CR_FISSR); } /** * @brief Check if FLASH Interface STOP while system Run feature is enabled * @rmtoll CR FISSR LL_PWR_IsEnabledFLASHInterfaceSTOP * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_PWR_IsEnabledFLASHInterfaceSTOP(void) { return (READ_BIT(PWR->CR, PWR_CR_FISSR) == (PWR_CR_FISSR)); } #endif /* PWR_CR_FISSR */ #if defined(PWR_CR_FMSSR) /** * @brief Enable FLASH Memory STOP while system Run is ON * @rmtoll CR FMSSR LL_PWR_EnableFLASHMemorySTOP * @note This mode is enabled only with STOP low power mode. * @retval None */ __STATIC_INLINE void LL_PWR_EnableFLASHMemorySTOP(void) { SET_BIT(PWR->CR, PWR_CR_FMSSR); } /** * @brief Disable FLASH Memory STOP while system Run is ON * @rmtoll CR FMSSR LL_PWR_DisableFLASHMemorySTOP * @retval None */ __STATIC_INLINE void LL_PWR_DisableFLASHMemorySTOP(void) { CLEAR_BIT(PWR->CR, PWR_CR_FMSSR); } /** * @brief Check if FLASH Memory STOP while system Run feature is enabled * @rmtoll CR FMSSR LL_PWR_IsEnabledFLASHMemorySTOP * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_PWR_IsEnabledFLASHMemorySTOP(void) { return (READ_BIT(PWR->CR, PWR_CR_FMSSR) == (PWR_CR_FMSSR)); } #endif /* PWR_CR_FMSSR */ #if defined(PWR_CR_UDEN) /** * @brief Enable Under Drive Mode * @rmtoll CR UDEN LL_PWR_EnableUnderDriveMode * @note This mode is enabled only with STOP low power mode. * In this mode, the 1.2V domain is preserved in reduced leakage mode. This * mode is only available when the main Regulator or the low power Regulator * is in low voltage mode. * @note If the Under-drive mode was enabled, it is automatically disabled after * exiting Stop mode. * When the voltage Regulator operates in Under-drive mode, an additional * startup delay is induced when waking up from Stop mode. * @retval None */ __STATIC_INLINE void LL_PWR_EnableUnderDriveMode(void) { SET_BIT(PWR->CR, PWR_CR_UDEN); } /** * @brief Disable Under Drive Mode * @rmtoll CR UDEN LL_PWR_DisableUnderDriveMode * @retval None */ __STATIC_INLINE void LL_PWR_DisableUnderDriveMode(void) { CLEAR_BIT(PWR->CR, PWR_CR_UDEN); } /** * @brief Check if Under Drive Mode is enabled * @rmtoll CR UDEN LL_PWR_IsEnabledUnderDriveMode * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_PWR_IsEnabledUnderDriveMode(void) { return (READ_BIT(PWR->CR, PWR_CR_UDEN) == (PWR_CR_UDEN)); } #endif /* PWR_CR_UDEN */ #if defined(PWR_CR_ODSWEN) /** * @brief Enable Over drive switching * @rmtoll CR ODSWEN LL_PWR_EnableOverDriveSwitching * @retval None */ __STATIC_INLINE void LL_PWR_EnableOverDriveSwitching(void) { SET_BIT(PWR->CR, PWR_CR_ODSWEN); } /** * @brief Disable Over drive switching * @rmtoll CR ODSWEN LL_PWR_DisableOverDriveSwitching * @retval None */ __STATIC_INLINE void LL_PWR_DisableOverDriveSwitching(void) { CLEAR_BIT(PWR->CR, PWR_CR_ODSWEN); } /** * @brief Check if Over drive switching is enabled * @rmtoll CR ODSWEN LL_PWR_IsEnabledOverDriveSwitching * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_PWR_IsEnabledOverDriveSwitching(void) { return (READ_BIT(PWR->CR, PWR_CR_ODSWEN) == (PWR_CR_ODSWEN)); } #endif /* PWR_CR_ODSWEN */ #if defined(PWR_CR_ODEN) /** * @brief Enable Over drive Mode * @rmtoll CR ODEN LL_PWR_EnableOverDriveMode * @retval None */ __STATIC_INLINE void LL_PWR_EnableOverDriveMode(void) { SET_BIT(PWR->CR, PWR_CR_ODEN); } /** * @brief Disable Over drive Mode * @rmtoll CR ODEN LL_PWR_DisableOverDriveMode * @retval None */ __STATIC_INLINE void LL_PWR_DisableOverDriveMode(void) { CLEAR_BIT(PWR->CR, PWR_CR_ODEN); } /** * @brief Check if Over drive switching is enabled * @rmtoll CR ODEN LL_PWR_IsEnabledOverDriveMode * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_PWR_IsEnabledOverDriveMode(void) { return (READ_BIT(PWR->CR, PWR_CR_ODEN) == (PWR_CR_ODEN)); } #endif /* PWR_CR_ODEN */ #if defined(PWR_CR_MRUDS) /** * @brief Enable Main Regulator in deepsleep under-drive Mode * @rmtoll CR MRUDS LL_PWR_EnableMainRegulatorDeepSleepUDMode * @retval None */ __STATIC_INLINE void LL_PWR_EnableMainRegulatorDeepSleepUDMode(void) { SET_BIT(PWR->CR, PWR_CR_MRUDS); } /** * @brief Disable Main Regulator in deepsleep under-drive Mode * @rmtoll CR MRUDS LL_PWR_DisableMainRegulatorDeepSleepUDMode * @retval None */ __STATIC_INLINE void LL_PWR_DisableMainRegulatorDeepSleepUDMode(void) { CLEAR_BIT(PWR->CR, PWR_CR_MRUDS); } /** * @brief Check if Main Regulator in deepsleep under-drive Mode is enabled * @rmtoll CR MRUDS LL_PWR_IsEnabledMainRegulatorDeepSleepUDMode * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_PWR_IsEnabledMainRegulatorDeepSleepUDMode(void) { return (READ_BIT(PWR->CR, PWR_CR_MRUDS) == (PWR_CR_MRUDS)); } #endif /* PWR_CR_MRUDS */ #if defined(PWR_CR_LPUDS) /** * @brief Enable Low Power Regulator in deepsleep under-drive Mode * @rmtoll CR LPUDS LL_PWR_EnableLowPowerRegulatorDeepSleepUDMode * @retval None */ __STATIC_INLINE void LL_PWR_EnableLowPowerRegulatorDeepSleepUDMode(void) { SET_BIT(PWR->CR, PWR_CR_LPUDS); } /** * @brief Disable Low Power Regulator in deepsleep under-drive Mode * @rmtoll CR LPUDS LL_PWR_DisableLowPowerRegulatorDeepSleepUDMode * @retval None */ __STATIC_INLINE void LL_PWR_DisableLowPowerRegulatorDeepSleepUDMode(void) { CLEAR_BIT(PWR->CR, PWR_CR_LPUDS); } /** * @brief Check if Low Power Regulator in deepsleep under-drive Mode is enabled * @rmtoll CR LPUDS LL_PWR_IsEnabledLowPowerRegulatorDeepSleepUDMode * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_PWR_IsEnabledLowPowerRegulatorDeepSleepUDMode(void) { return (READ_BIT(PWR->CR, PWR_CR_LPUDS) == (PWR_CR_LPUDS)); } #endif /* PWR_CR_LPUDS */ #if defined(PWR_CR_MRLVDS) /** * @brief Enable Main Regulator low voltage Mode * @rmtoll CR MRLVDS LL_PWR_EnableMainRegulatorLowVoltageMode * @retval None */ __STATIC_INLINE void LL_PWR_EnableMainRegulatorLowVoltageMode(void) { SET_BIT(PWR->CR, PWR_CR_MRLVDS); } /** * @brief Disable Main Regulator low voltage Mode * @rmtoll CR MRLVDS LL_PWR_DisableMainRegulatorLowVoltageMode * @retval None */ __STATIC_INLINE void LL_PWR_DisableMainRegulatorLowVoltageMode(void) { CLEAR_BIT(PWR->CR, PWR_CR_MRLVDS); } /** * @brief Check if Main Regulator low voltage Mode is enabled * @rmtoll CR MRLVDS LL_PWR_IsEnabledMainRegulatorLowVoltageMode * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_PWR_IsEnabledMainRegulatorLowVoltageMode(void) { return (READ_BIT(PWR->CR, PWR_CR_MRLVDS) == (PWR_CR_MRLVDS)); } #endif /* PWR_CR_MRLVDS */ #if defined(PWR_CR_LPLVDS) /** * @brief Enable Low Power Regulator low voltage Mode * @rmtoll CR LPLVDS LL_PWR_EnableLowPowerRegulatorLowVoltageMode * @retval None */ __STATIC_INLINE void LL_PWR_EnableLowPowerRegulatorLowVoltageMode(void) { SET_BIT(PWR->CR, PWR_CR_LPLVDS); } /** * @brief Disable Low Power Regulator low voltage Mode * @rmtoll CR LPLVDS LL_PWR_DisableLowPowerRegulatorLowVoltageMode * @retval None */ __STATIC_INLINE void LL_PWR_DisableLowPowerRegulatorLowVoltageMode(void) { CLEAR_BIT(PWR->CR, PWR_CR_LPLVDS); } /** * @brief Check if Low Power Regulator low voltage Mode is enabled * @rmtoll CR LPLVDS LL_PWR_IsEnabledLowPowerRegulatorLowVoltageMode * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_PWR_IsEnabledLowPowerRegulatorLowVoltageMode(void) { return (READ_BIT(PWR->CR, PWR_CR_LPLVDS) == (PWR_CR_LPLVDS)); } #endif /* PWR_CR_LPLVDS */ /** * @brief Set the main internal Regulator output voltage * @rmtoll CR VOS LL_PWR_SetRegulVoltageScaling * @param VoltageScaling This parameter can be one of the following values: * @arg @ref LL_PWR_REGU_VOLTAGE_SCALE1 (*) * @arg @ref LL_PWR_REGU_VOLTAGE_SCALE2 * @arg @ref LL_PWR_REGU_VOLTAGE_SCALE3 * (*) LL_PWR_REGU_VOLTAGE_SCALE1 is not available for STM32F401xx devices * @retval None */ __STATIC_INLINE void LL_PWR_SetRegulVoltageScaling(uint32_t VoltageScaling) { MODIFY_REG(PWR->CR, PWR_CR_VOS, VoltageScaling); } /** * @brief Get the main internal Regulator output voltage * @rmtoll CR VOS LL_PWR_GetRegulVoltageScaling * @retval Returned value can be one of the following values: * @arg @ref LL_PWR_REGU_VOLTAGE_SCALE1 (*) * @arg @ref LL_PWR_REGU_VOLTAGE_SCALE2 * @arg @ref LL_PWR_REGU_VOLTAGE_SCALE3 * (*) LL_PWR_REGU_VOLTAGE_SCALE1 is not available for STM32F401xx devices */ __STATIC_INLINE uint32_t LL_PWR_GetRegulVoltageScaling(void) { return (uint32_t)(READ_BIT(PWR->CR, PWR_CR_VOS)); } /** * @brief Enable the Flash Power Down in Stop Mode * @rmtoll CR FPDS LL_PWR_EnableFlashPowerDown * @retval None */ __STATIC_INLINE void LL_PWR_EnableFlashPowerDown(void) { SET_BIT(PWR->CR, PWR_CR_FPDS); } /** * @brief Disable the Flash Power Down in Stop Mode * @rmtoll CR FPDS LL_PWR_DisableFlashPowerDown * @retval None */ __STATIC_INLINE void LL_PWR_DisableFlashPowerDown(void) { CLEAR_BIT(PWR->CR, PWR_CR_FPDS); } /** * @brief Check if the Flash Power Down in Stop Mode is enabled * @rmtoll CR FPDS LL_PWR_IsEnabledFlashPowerDown * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_PWR_IsEnabledFlashPowerDown(void) { return (READ_BIT(PWR->CR, PWR_CR_FPDS) == (PWR_CR_FPDS)); } /** * @brief Enable access to the backup domain * @rmtoll CR DBP LL_PWR_EnableBkUpAccess * @retval None */ __STATIC_INLINE void LL_PWR_EnableBkUpAccess(void) { SET_BIT(PWR->CR, PWR_CR_DBP); } /** * @brief Disable access to the backup domain * @rmtoll CR DBP LL_PWR_DisableBkUpAccess * @retval None */ __STATIC_INLINE void LL_PWR_DisableBkUpAccess(void) { CLEAR_BIT(PWR->CR, PWR_CR_DBP); } /** * @brief Check if the backup domain is enabled * @rmtoll CR DBP LL_PWR_IsEnabledBkUpAccess * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_PWR_IsEnabledBkUpAccess(void) { return (READ_BIT(PWR->CR, PWR_CR_DBP) == (PWR_CR_DBP)); } /** * @brief Enable the backup Regulator * @rmtoll CSR BRE LL_PWR_EnableBkUpRegulator * @note The BRE bit of the PWR_CSR register is protected against parasitic write access. * The LL_PWR_EnableBkUpAccess() must be called before using this API. * @retval None */ __STATIC_INLINE void LL_PWR_EnableBkUpRegulator(void) { SET_BIT(PWR->CSR, PWR_CSR_BRE); } /** * @brief Disable the backup Regulator * @rmtoll CSR BRE LL_PWR_DisableBkUpRegulator * @note The BRE bit of the PWR_CSR register is protected against parasitic write access. * The LL_PWR_EnableBkUpAccess() must be called before using this API. * @retval None */ __STATIC_INLINE void LL_PWR_DisableBkUpRegulator(void) { CLEAR_BIT(PWR->CSR, PWR_CSR_BRE); } /** * @brief Check if the backup Regulator is enabled * @rmtoll CSR BRE LL_PWR_IsEnabledBkUpRegulator * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_PWR_IsEnabledBkUpRegulator(void) { return (READ_BIT(PWR->CSR, PWR_CSR_BRE) == (PWR_CSR_BRE)); } /** * @brief Set voltage Regulator mode during deep sleep mode * @rmtoll CR LPDS LL_PWR_SetRegulModeDS * @param RegulMode This parameter can be one of the following values: * @arg @ref LL_PWR_REGU_DSMODE_MAIN * @arg @ref LL_PWR_REGU_DSMODE_LOW_POWER * @retval None */ __STATIC_INLINE void LL_PWR_SetRegulModeDS(uint32_t RegulMode) { MODIFY_REG(PWR->CR, PWR_CR_LPDS, RegulMode); } /** * @brief Get voltage Regulator mode during deep sleep mode * @rmtoll CR LPDS LL_PWR_GetRegulModeDS * @retval Returned value can be one of the following values: * @arg @ref LL_PWR_REGU_DSMODE_MAIN * @arg @ref LL_PWR_REGU_DSMODE_LOW_POWER */ __STATIC_INLINE uint32_t LL_PWR_GetRegulModeDS(void) { return (uint32_t)(READ_BIT(PWR->CR, PWR_CR_LPDS)); } /** * @brief Set Power Down mode when CPU enters deepsleep * @rmtoll CR PDDS LL_PWR_SetPowerMode\n * @rmtoll CR MRUDS LL_PWR_SetPowerMode\n * @rmtoll CR LPUDS LL_PWR_SetPowerMode\n * @rmtoll CR FPDS LL_PWR_SetPowerMode\n * @rmtoll CR MRLVDS LL_PWR_SetPowerMode\n * @rmtoll CR LPlVDS LL_PWR_SetPowerMode\n * @rmtoll CR FPDS LL_PWR_SetPowerMode\n * @rmtoll CR LPDS LL_PWR_SetPowerMode * @param PDMode This parameter can be one of the following values: * @arg @ref LL_PWR_MODE_STOP_MAINREGU * @arg @ref LL_PWR_MODE_STOP_LPREGU * @arg @ref LL_PWR_MODE_STOP_MAINREGU_UNDERDRIVE (*) * @arg @ref LL_PWR_MODE_STOP_LPREGU_UNDERDRIVE (*) * @arg @ref LL_PWR_MODE_STOP_MAINREGU_DEEPSLEEP (*) * @arg @ref LL_PWR_MODE_STOP_LPREGU_DEEPSLEEP (*) * * (*) not available on all devices * @arg @ref LL_PWR_MODE_STANDBY * @retval None */ __STATIC_INLINE void LL_PWR_SetPowerMode(uint32_t PDMode) { #if defined(PWR_CR_MRUDS) && defined(PWR_CR_LPUDS) && defined(PWR_CR_FPDS) MODIFY_REG(PWR->CR, (PWR_CR_PDDS | PWR_CR_LPDS | PWR_CR_FPDS | PWR_CR_LPUDS | PWR_CR_MRUDS), PDMode); #elif defined(PWR_CR_MRLVDS) && defined(PWR_CR_LPLVDS) && defined(PWR_CR_FPDS) MODIFY_REG(PWR->CR, (PWR_CR_PDDS | PWR_CR_LPDS | PWR_CR_FPDS | PWR_CR_LPLVDS | PWR_CR_MRLVDS), PDMode); #else MODIFY_REG(PWR->CR, (PWR_CR_PDDS| PWR_CR_LPDS), PDMode); #endif /* PWR_CR_MRUDS && PWR_CR_LPUDS && PWR_CR_FPDS */ } /** * @brief Get Power Down mode when CPU enters deepsleep * @rmtoll CR PDDS LL_PWR_GetPowerMode\n * @rmtoll CR MRUDS LL_PWR_GetPowerMode\n * @rmtoll CR LPUDS LL_PWR_GetPowerMode\n * @rmtoll CR FPDS LL_PWR_GetPowerMode\n * @rmtoll CR MRLVDS LL_PWR_GetPowerMode\n * @rmtoll CR LPLVDS LL_PWR_GetPowerMode\n * @rmtoll CR FPDS LL_PWR_GetPowerMode\n * @rmtoll CR LPDS LL_PWR_GetPowerMode * @retval Returned value can be one of the following values: * @arg @ref LL_PWR_MODE_STOP_MAINREGU * @arg @ref LL_PWR_MODE_STOP_LPREGU * @arg @ref LL_PWR_MODE_STOP_MAINREGU_UNDERDRIVE (*) * @arg @ref LL_PWR_MODE_STOP_LPREGU_UNDERDRIVE (*) * @arg @ref LL_PWR_MODE_STOP_MAINREGU_DEEPSLEEP (*) * @arg @ref LL_PWR_MODE_STOP_LPREGU_DEEPSLEEP (*) * * (*) not available on all devices * @arg @ref LL_PWR_MODE_STANDBY */ __STATIC_INLINE uint32_t LL_PWR_GetPowerMode(void) { #if defined(PWR_CR_MRUDS) && defined(PWR_CR_LPUDS) && defined(PWR_CR_FPDS) return (uint32_t)(READ_BIT(PWR->CR, (PWR_CR_PDDS | PWR_CR_LPDS | PWR_CR_FPDS | PWR_CR_LPUDS | PWR_CR_MRUDS))); #elif defined(PWR_CR_MRLVDS) && defined(PWR_CR_LPLVDS) && defined(PWR_CR_FPDS) return (uint32_t)(READ_BIT(PWR->CR, (PWR_CR_PDDS | PWR_CR_LPDS | PWR_CR_FPDS | PWR_CR_LPLVDS | PWR_CR_MRLVDS))); #else return (uint32_t)(READ_BIT(PWR->CR, (PWR_CR_PDDS| PWR_CR_LPDS))); #endif /* PWR_CR_MRUDS && PWR_CR_LPUDS && PWR_CR_FPDS */ } /** * @brief Configure the voltage threshold detected by the Power Voltage Detector * @rmtoll CR PLS LL_PWR_SetPVDLevel * @param PVDLevel This parameter can be one of the following values: * @arg @ref LL_PWR_PVDLEVEL_0 * @arg @ref LL_PWR_PVDLEVEL_1 * @arg @ref LL_PWR_PVDLEVEL_2 * @arg @ref LL_PWR_PVDLEVEL_3 * @arg @ref LL_PWR_PVDLEVEL_4 * @arg @ref LL_PWR_PVDLEVEL_5 * @arg @ref LL_PWR_PVDLEVEL_6 * @arg @ref LL_PWR_PVDLEVEL_7 * @retval None */ __STATIC_INLINE void LL_PWR_SetPVDLevel(uint32_t PVDLevel) { MODIFY_REG(PWR->CR, PWR_CR_PLS, PVDLevel); } /** * @brief Get the voltage threshold detection * @rmtoll CR PLS LL_PWR_GetPVDLevel * @retval Returned value can be one of the following values: * @arg @ref LL_PWR_PVDLEVEL_0 * @arg @ref LL_PWR_PVDLEVEL_1 * @arg @ref LL_PWR_PVDLEVEL_2 * @arg @ref LL_PWR_PVDLEVEL_3 * @arg @ref LL_PWR_PVDLEVEL_4 * @arg @ref LL_PWR_PVDLEVEL_5 * @arg @ref LL_PWR_PVDLEVEL_6 * @arg @ref LL_PWR_PVDLEVEL_7 */ __STATIC_INLINE uint32_t LL_PWR_GetPVDLevel(void) { return (uint32_t)(READ_BIT(PWR->CR, PWR_CR_PLS)); } /** * @brief Enable Power Voltage Detector * @rmtoll CR PVDE LL_PWR_EnablePVD * @retval None */ __STATIC_INLINE void LL_PWR_EnablePVD(void) { SET_BIT(PWR->CR, PWR_CR_PVDE); } /** * @brief Disable Power Voltage Detector * @rmtoll CR PVDE LL_PWR_DisablePVD * @retval None */ __STATIC_INLINE void LL_PWR_DisablePVD(void) { CLEAR_BIT(PWR->CR, PWR_CR_PVDE); } /** * @brief Check if Power Voltage Detector is enabled * @rmtoll CR PVDE LL_PWR_IsEnabledPVD * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_PWR_IsEnabledPVD(void) { return (READ_BIT(PWR->CR, PWR_CR_PVDE) == (PWR_CR_PVDE)); } /** * @brief Enable the WakeUp PINx functionality * @rmtoll CSR EWUP LL_PWR_EnableWakeUpPin\n * @rmtoll CSR EWUP1 LL_PWR_EnableWakeUpPin\n * @rmtoll CSR EWUP2 LL_PWR_EnableWakeUpPin\n * @rmtoll CSR EWUP3 LL_PWR_EnableWakeUpPin * @param WakeUpPin This parameter can be one of the following values: * @arg @ref LL_PWR_WAKEUP_PIN1 * @arg @ref LL_PWR_WAKEUP_PIN2 (*) * @arg @ref LL_PWR_WAKEUP_PIN3 (*) * * (*) not available on all devices * @retval None */ __STATIC_INLINE void LL_PWR_EnableWakeUpPin(uint32_t WakeUpPin) { SET_BIT(PWR->CSR, WakeUpPin); } /** * @brief Disable the WakeUp PINx functionality * @rmtoll CSR EWUP LL_PWR_DisableWakeUpPin\n * @rmtoll CSR EWUP1 LL_PWR_DisableWakeUpPin\n * @rmtoll CSR EWUP2 LL_PWR_DisableWakeUpPin\n * @rmtoll CSR EWUP3 LL_PWR_DisableWakeUpPin * @param WakeUpPin This parameter can be one of the following values: * @arg @ref LL_PWR_WAKEUP_PIN1 * @arg @ref LL_PWR_WAKEUP_PIN2 (*) * @arg @ref LL_PWR_WAKEUP_PIN3 (*) * * (*) not available on all devices * @retval None */ __STATIC_INLINE void LL_PWR_DisableWakeUpPin(uint32_t WakeUpPin) { CLEAR_BIT(PWR->CSR, WakeUpPin); } /** * @brief Check if the WakeUp PINx functionality is enabled * @rmtoll CSR EWUP LL_PWR_IsEnabledWakeUpPin\n * @rmtoll CSR EWUP1 LL_PWR_IsEnabledWakeUpPin\n * @rmtoll CSR EWUP2 LL_PWR_IsEnabledWakeUpPin\n * @rmtoll CSR EWUP3 LL_PWR_IsEnabledWakeUpPin * @param WakeUpPin This parameter can be one of the following values: * @arg @ref LL_PWR_WAKEUP_PIN1 * @arg @ref LL_PWR_WAKEUP_PIN2 (*) * @arg @ref LL_PWR_WAKEUP_PIN3 (*) * * (*) not available on all devices * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_PWR_IsEnabledWakeUpPin(uint32_t WakeUpPin) { return (READ_BIT(PWR->CSR, WakeUpPin) == (WakeUpPin)); } /** * @} */ /** @defgroup PWR_LL_EF_FLAG_Management FLAG_Management * @{ */ /** * @brief Get Wake-up Flag * @rmtoll CSR WUF LL_PWR_IsActiveFlag_WU * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_PWR_IsActiveFlag_WU(void) { return (READ_BIT(PWR->CSR, PWR_CSR_WUF) == (PWR_CSR_WUF)); } /** * @brief Get Standby Flag * @rmtoll CSR SBF LL_PWR_IsActiveFlag_SB * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_PWR_IsActiveFlag_SB(void) { return (READ_BIT(PWR->CSR, PWR_CSR_SBF) == (PWR_CSR_SBF)); } /** * @brief Get Backup Regulator ready Flag * @rmtoll CSR BRR LL_PWR_IsActiveFlag_BRR * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_PWR_IsActiveFlag_BRR(void) { return (READ_BIT(PWR->CSR, PWR_CSR_BRR) == (PWR_CSR_BRR)); } /** * @brief Indicate whether VDD voltage is below the selected PVD threshold * @rmtoll CSR PVDO LL_PWR_IsActiveFlag_PVDO * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_PWR_IsActiveFlag_PVDO(void) { return (READ_BIT(PWR->CSR, PWR_CSR_PVDO) == (PWR_CSR_PVDO)); } /** * @brief Indicate whether the Regulator is ready in the selected voltage range or if its output voltage is still changing to the required voltage level * @rmtoll CSR VOS LL_PWR_IsActiveFlag_VOS * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_PWR_IsActiveFlag_VOS(void) { return (READ_BIT(PWR->CSR, LL_PWR_CSR_VOS) == (LL_PWR_CSR_VOS)); } #if defined(PWR_CR_ODEN) /** * @brief Indicate whether the Over-Drive mode is ready or not * @rmtoll CSR ODRDY LL_PWR_IsActiveFlag_OD * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_PWR_IsActiveFlag_OD(void) { return (READ_BIT(PWR->CSR, PWR_CSR_ODRDY) == (PWR_CSR_ODRDY)); } #endif /* PWR_CR_ODEN */ #if defined(PWR_CR_ODSWEN) /** * @brief Indicate whether the Over-Drive mode switching is ready or not * @rmtoll CSR ODSWRDY LL_PWR_IsActiveFlag_ODSW * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_PWR_IsActiveFlag_ODSW(void) { return (READ_BIT(PWR->CSR, PWR_CSR_ODSWRDY) == (PWR_CSR_ODSWRDY)); } #endif /* PWR_CR_ODSWEN */ #if defined(PWR_CR_UDEN) /** * @brief Indicate whether the Under-Drive mode is ready or not * @rmtoll CSR UDRDY LL_PWR_IsActiveFlag_UD * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_PWR_IsActiveFlag_UD(void) { return (READ_BIT(PWR->CSR, PWR_CSR_UDRDY) == (PWR_CSR_UDRDY)); } #endif /* PWR_CR_UDEN */ /** * @brief Clear Standby Flag * @rmtoll CR CSBF LL_PWR_ClearFlag_SB * @retval None */ __STATIC_INLINE void LL_PWR_ClearFlag_SB(void) { SET_BIT(PWR->CR, PWR_CR_CSBF); } /** * @brief Clear Wake-up Flags * @rmtoll CR CWUF LL_PWR_ClearFlag_WU * @retval None */ __STATIC_INLINE void LL_PWR_ClearFlag_WU(void) { SET_BIT(PWR->CR, PWR_CR_CWUF); } #if defined(PWR_CSR_UDRDY) /** * @brief Clear Under-Drive ready Flag * @rmtoll CSR UDRDY LL_PWR_ClearFlag_UD * @retval None */ __STATIC_INLINE void LL_PWR_ClearFlag_UD(void) { WRITE_REG(PWR->CSR, PWR_CSR_UDRDY); } #endif /* PWR_CSR_UDRDY */ /** * @} */ #if defined(USE_FULL_LL_DRIVER) /** @defgroup PWR_LL_EF_Init De-initialization function * @{ */ ErrorStatus LL_PWR_DeInit(void); /** * @} */ #endif /* USE_FULL_LL_DRIVER */ /** * @} */ /** * @} */ #endif /* defined(PWR) */ /** * @} */ #ifdef __cplusplus } #endif #endif /* __STM32F4xx_LL_PWR_H */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ ================================================ FILE: sys/arch/stm32/hal/stm32f4xx_ll_rcc.c ================================================ /** ****************************************************************************** * @file stm32f4xx_ll_rcc.c * @author MCD Application Team * @version V1.7.1 * @date 14-April-2017 * @brief RCC LL module driver. ****************************************************************************** * @attention * *

© COPYRIGHT(c) 2017 STMicroelectronics

* * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. Neither the name of STMicroelectronics nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ #if defined(USE_FULL_LL_DRIVER) /* Includes ------------------------------------------------------------------*/ #include "stm32f4xx_ll_rcc.h" #ifdef USE_FULL_ASSERT #include "stm32_assert.h" #else #define assert_param(expr) ((void)0U) #endif /** @addtogroup STM32F4xx_LL_Driver * @{ */ #if defined(RCC) /** @addtogroup RCC_LL * @{ */ /* Private types -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ /* Private constants ---------------------------------------------------------*/ /* Private macros ------------------------------------------------------------*/ /** @addtogroup RCC_LL_Private_Macros * @{ */ #if defined(FMPI2C1) #define IS_LL_RCC_FMPI2C_CLKSOURCE(__VALUE__) ((__VALUE__) == LL_RCC_FMPI2C1_CLKSOURCE) #endif /* FMPI2C1 */ #if defined(LPTIM1) #define IS_LL_RCC_LPTIM_CLKSOURCE(__VALUE__) (((__VALUE__) == LL_RCC_LPTIM1_CLKSOURCE)) #endif /* LPTIM1 */ #if defined(SAI1) #if defined(RCC_DCKCFGR_SAI1SRC) #define IS_LL_RCC_SAI_CLKSOURCE(__VALUE__) (((__VALUE__) == LL_RCC_SAI1_CLKSOURCE) \ || ((__VALUE__) == LL_RCC_SAI2_CLKSOURCE)) #elif defined(RCC_DCKCFGR_SAI1ASRC) #define IS_LL_RCC_SAI_CLKSOURCE(__VALUE__) (((__VALUE__) == LL_RCC_SAI1_A_CLKSOURCE) \ || ((__VALUE__) == LL_RCC_SAI1_B_CLKSOURCE)) #endif /* RCC_DCKCFGR_SAI1SRC */ #endif /* SAI1 */ #if defined(SDIO) #define IS_LL_RCC_SDIO_CLKSOURCE(__VALUE__) (((__VALUE__) == LL_RCC_SDIO_CLKSOURCE)) #endif /* SDIO */ #if defined(RNG) #define IS_LL_RCC_RNG_CLKSOURCE(__VALUE__) (((__VALUE__) == LL_RCC_RNG_CLKSOURCE)) #endif /* RNG */ #if defined(USB_OTG_FS) || defined(USB_OTG_HS) #define IS_LL_RCC_USB_CLKSOURCE(__VALUE__) (((__VALUE__) == LL_RCC_USB_CLKSOURCE)) #endif /* USB_OTG_FS || USB_OTG_HS */ #if defined(DFSDM2_Channel0) #define IS_LL_RCC_DFSDM_CLKSOURCE(__VALUE__) (((__VALUE__) == LL_RCC_DFSDM1_CLKSOURCE)) #define IS_LL_RCC_DFSDM_AUDIO_CLKSOURCE(__VALUE__) (((__VALUE__) == LL_RCC_DFSDM1_AUDIO_CLKSOURCE) \ || ((__VALUE__) == LL_RCC_DFSDM2_AUDIO_CLKSOURCE)) #elif defined(DFSDM1_Channel0) #define IS_LL_RCC_DFSDM_CLKSOURCE(__VALUE__) (((__VALUE__) == LL_RCC_DFSDM1_CLKSOURCE)) #define IS_LL_RCC_DFSDM_AUDIO_CLKSOURCE(__VALUE__) (((__VALUE__) == LL_RCC_DFSDM1_AUDIO_CLKSOURCE)) #endif /* DFSDM2_Channel0 */ #if defined(RCC_DCKCFGR_I2S2SRC) #define IS_LL_RCC_I2S_CLKSOURCE(__VALUE__) (((__VALUE__) == LL_RCC_I2S1_CLKSOURCE) \ || ((__VALUE__) == LL_RCC_I2S2_CLKSOURCE)) #else #define IS_LL_RCC_I2S_CLKSOURCE(__VALUE__) (((__VALUE__) == LL_RCC_I2S1_CLKSOURCE)) #endif /* RCC_DCKCFGR_I2S2SRC */ #if defined(CEC) #define IS_LL_RCC_CEC_CLKSOURCE(__VALUE__) (((__VALUE__) == LL_RCC_CEC_CLKSOURCE)) #endif /* CEC */ #if defined(DSI) #define IS_LL_RCC_DSI_CLKSOURCE(__VALUE__) (((__VALUE__) == LL_RCC_DSI_CLKSOURCE)) #endif /* DSI */ #if defined(LTDC) #define IS_LL_RCC_LTDC_CLKSOURCE(__VALUE__) (((__VALUE__) == LL_RCC_LTDC_CLKSOURCE)) #endif /* LTDC */ #if defined(SPDIFRX) #define IS_LL_RCC_SPDIFRX_CLKSOURCE(__VALUE__) (((__VALUE__) == LL_RCC_SPDIFRX1_CLKSOURCE)) #endif /* SPDIFRX */ /** * @} */ /* Private function prototypes -----------------------------------------------*/ /** @defgroup RCC_LL_Private_Functions RCC Private functions * @{ */ uint32_t RCC_GetSystemClockFreq(void); uint32_t RCC_GetHCLKClockFreq(uint32_t SYSCLK_Frequency); uint32_t RCC_GetPCLK1ClockFreq(uint32_t HCLK_Frequency); uint32_t RCC_GetPCLK2ClockFreq(uint32_t HCLK_Frequency); uint32_t RCC_PLL_GetFreqDomain_SYS(uint32_t SYSCLK_Source); uint32_t RCC_PLL_GetFreqDomain_48M(void); #if defined(RCC_DCKCFGR_I2SSRC) || defined(RCC_DCKCFGR_I2S1SRC) uint32_t RCC_PLL_GetFreqDomain_I2S(void); #endif /* RCC_DCKCFGR_I2SSRC || RCC_DCKCFGR_I2S1SRC */ #if defined(SPDIFRX) uint32_t RCC_PLL_GetFreqDomain_SPDIFRX(void); #endif /* SPDIFRX */ #if defined(RCC_PLLCFGR_PLLR) #if defined(SAI1) uint32_t RCC_PLL_GetFreqDomain_SAI(void); #endif /* SAI1 */ #endif /* RCC_PLLCFGR_PLLR */ #if defined(DSI) uint32_t RCC_PLL_GetFreqDomain_DSI(void); #endif /* DSI */ #if defined(RCC_PLLSAI_SUPPORT) uint32_t RCC_PLLSAI_GetFreqDomain_SAI(void); #if defined(RCC_PLLSAICFGR_PLLSAIP) uint32_t RCC_PLLSAI_GetFreqDomain_48M(void); #endif /* RCC_PLLSAICFGR_PLLSAIP */ #if defined(LTDC) uint32_t RCC_PLLSAI_GetFreqDomain_LTDC(void); #endif /* LTDC */ #endif /* RCC_PLLSAI_SUPPORT */ #if defined(RCC_PLLI2S_SUPPORT) uint32_t RCC_PLLI2S_GetFreqDomain_I2S(void); #if defined(RCC_PLLI2SCFGR_PLLI2SQ) && !defined(RCC_DCKCFGR_PLLI2SDIVQ) uint32_t RCC_PLLI2S_GetFreqDomain_48M(void); #endif /* RCC_PLLI2SCFGR_PLLI2SQ && !RCC_DCKCFGR_PLLI2SDIVQ */ #if defined(SAI1) uint32_t RCC_PLLI2S_GetFreqDomain_SAI(void); #endif /* SAI1 */ #if defined(SPDIFRX) uint32_t RCC_PLLI2S_GetFreqDomain_SPDIFRX(void); #endif /* SPDIFRX */ #endif /* RCC_PLLI2S_SUPPORT */ /** * @} */ /* Exported functions --------------------------------------------------------*/ /** @addtogroup RCC_LL_Exported_Functions * @{ */ /** @addtogroup RCC_LL_EF_Init * @{ */ /** * @brief Reset the RCC clock configuration to the default reset state. * @note The default reset state of the clock configuration is given below: * - HSI ON and used as system clock source * - HSE and PLL OFF * - AHB, APB1 and APB2 prescaler set to 1. * - CSS, MCO OFF * - All interrupts disabled * @note This function doesn't modify the configuration of the * - Peripheral clocks * - LSI, LSE and RTC clocks * @retval An ErrorStatus enumeration value: * - SUCCESS: RCC registers are de-initialized * - ERROR: not applicable */ ErrorStatus LL_RCC_DeInit(void) { __IO uint32_t vl_mask; /* Set HSION bit */ LL_RCC_HSI_Enable(); /* Wait for HSI READY bit */ while(LL_RCC_HSI_IsReady() != 1U) {} /* Reset CFGR register */ LL_RCC_WriteReg(CFGR, 0x00000000U); /* Read CR register */ vl_mask = LL_RCC_ReadReg(CR); /* Reset HSEON, HSEBYP, PLLON, CSSON bits */ CLEAR_BIT(vl_mask, (RCC_CR_HSEON | RCC_CR_HSEBYP | RCC_CR_PLLON | RCC_CR_CSSON)); #if defined(RCC_PLLSAI_SUPPORT) /* Reset PLLSAION bit */ CLEAR_BIT(vl_mask, RCC_CR_PLLSAION); #endif /* RCC_PLLSAI_SUPPORT */ #if defined(RCC_PLLI2S_SUPPORT) /* Reset PLLI2SON bit */ CLEAR_BIT(vl_mask, RCC_CR_PLLI2SON); #endif /* RCC_PLLI2S_SUPPORT */ /* Write new value in CR register */ LL_RCC_WriteReg(CR, vl_mask); /* Set HSITRIM bits to the reset value*/ LL_RCC_HSI_SetCalibTrimming(0x10U); /* Wait for PLL READY bit to be reset */ while(LL_RCC_PLL_IsReady() != 0U) {} /* Reset PLLCFGR register */ LL_RCC_WriteReg(PLLCFGR, RCC_PLLCFGR_RST_VALUE); #if defined(RCC_PLLI2S_SUPPORT) /* Reset PLLI2SCFGR register */ LL_RCC_WriteReg(PLLI2SCFGR, RCC_PLLI2SCFGR_RST_VALUE); #endif /* RCC_PLLI2S_SUPPORT */ #if defined(RCC_PLLSAI_SUPPORT) /* Reset PLLSAICFGR register */ LL_RCC_WriteReg(PLLSAICFGR, RCC_PLLSAICFGR_RST_VALUE); #endif /* RCC_PLLSAI_SUPPORT */ /* Disable all interrupts */ CLEAR_BIT(RCC->CIR, RCC_CIR_LSIRDYIE | RCC_CIR_LSERDYIE | RCC_CIR_HSIRDYIE | RCC_CIR_HSERDYIE | RCC_CIR_PLLRDYIE); #if defined(RCC_CIR_PLLI2SRDYIE) CLEAR_BIT(RCC->CIR, RCC_CIR_PLLI2SRDYIE); #endif /* RCC_CIR_PLLI2SRDYIE */ #if defined(RCC_CIR_PLLSAIRDYIE) CLEAR_BIT(RCC->CIR, RCC_CIR_PLLSAIRDYIE); #endif /* RCC_CIR_PLLSAIRDYIE */ /* Clear all interrupt flags */ SET_BIT(RCC->CIR, RCC_CIR_LSIRDYC | RCC_CIR_LSERDYC | RCC_CIR_HSIRDYC | RCC_CIR_HSERDYC | RCC_CIR_PLLRDYC | RCC_CIR_CSSC); #if defined(RCC_CIR_PLLI2SRDYC) SET_BIT(RCC->CIR, RCC_CIR_PLLI2SRDYC); #endif /* RCC_CIR_PLLI2SRDYC */ #if defined(RCC_CIR_PLLSAIRDYC) SET_BIT(RCC->CIR, RCC_CIR_PLLSAIRDYC); #endif /* RCC_CIR_PLLSAIRDYC */ /* Clear LSION bit */ CLEAR_BIT(RCC->CSR, RCC_CSR_LSION); /* Reset all CSR flags */ SET_BIT(RCC->CSR, RCC_CSR_RMVF); return SUCCESS; } /** * @} */ /** @addtogroup RCC_LL_EF_Get_Freq * @brief Return the frequencies of different on chip clocks; System, AHB, APB1 and APB2 buses clocks * and different peripheral clocks available on the device. * @note If SYSCLK source is HSI, function returns values based on HSI_VALUE(**) * @note If SYSCLK source is HSE, function returns values based on HSE_VALUE(***) * @note If SYSCLK source is PLL, function returns values based on HSE_VALUE(***) * or HSI_VALUE(**) multiplied/divided by the PLL factors. * @note (**) HSI_VALUE is a constant defined in this file (default value * 16 MHz) but the real value may vary depending on the variations * in voltage and temperature. * @note (***) HSE_VALUE is a constant defined in this file (default value * 25 MHz), user has to ensure that HSE_VALUE is same as the real * frequency of the crystal used. Otherwise, this function may * have wrong result. * @note The result of this function could be incorrect when using fractional * value for HSE crystal. * @note This function can be used by the user application to compute the * baud-rate for the communication peripherals or configure other parameters. * @{ */ /** * @brief Return the frequencies of different on chip clocks; System, AHB, APB1 and APB2 buses clocks * @note Each time SYSCLK, HCLK, PCLK1 and/or PCLK2 clock changes, this function * must be called to update structure fields. Otherwise, any * configuration based on this function will be incorrect. * @param RCC_Clocks pointer to a @ref LL_RCC_ClocksTypeDef structure which will hold the clocks frequencies * @retval None */ void LL_RCC_GetSystemClocksFreq(LL_RCC_ClocksTypeDef *RCC_Clocks) { /* Get SYSCLK frequency */ RCC_Clocks->SYSCLK_Frequency = RCC_GetSystemClockFreq(); /* HCLK clock frequency */ RCC_Clocks->HCLK_Frequency = RCC_GetHCLKClockFreq(RCC_Clocks->SYSCLK_Frequency); /* PCLK1 clock frequency */ RCC_Clocks->PCLK1_Frequency = RCC_GetPCLK1ClockFreq(RCC_Clocks->HCLK_Frequency); /* PCLK2 clock frequency */ RCC_Clocks->PCLK2_Frequency = RCC_GetPCLK2ClockFreq(RCC_Clocks->HCLK_Frequency); } #if defined(FMPI2C1) /** * @brief Return FMPI2Cx clock frequency * @param FMPI2CxSource This parameter can be one of the following values: * @arg @ref LL_RCC_FMPI2C1_CLKSOURCE * @retval FMPI2C clock frequency (in Hz) * - @ref LL_RCC_PERIPH_FREQUENCY_NO indicates that HSI oscillator is not ready */ uint32_t LL_RCC_GetFMPI2CClockFreq(uint32_t FMPI2CxSource) { uint32_t FMPI2C_frequency = LL_RCC_PERIPH_FREQUENCY_NO; /* Check parameter */ assert_param(IS_LL_RCC_FMPI2C_CLKSOURCE(FMPI2CxSource)); if (FMPI2CxSource == LL_RCC_FMPI2C1_CLKSOURCE) { /* FMPI2C1 CLK clock frequency */ switch (LL_RCC_GetFMPI2CClockSource(FMPI2CxSource)) { case LL_RCC_FMPI2C1_CLKSOURCE_SYSCLK: /* FMPI2C1 Clock is System Clock */ FMPI2C_frequency = RCC_GetSystemClockFreq(); break; case LL_RCC_FMPI2C1_CLKSOURCE_HSI: /* FMPI2C1 Clock is HSI Osc. */ if (LL_RCC_HSI_IsReady()) { FMPI2C_frequency = HSI_VALUE; } break; case LL_RCC_FMPI2C1_CLKSOURCE_PCLK1: /* FMPI2C1 Clock is PCLK1 */ default: FMPI2C_frequency = RCC_GetPCLK1ClockFreq(RCC_GetHCLKClockFreq(RCC_GetSystemClockFreq())); break; } } return FMPI2C_frequency; } #endif /* FMPI2C1 */ /** * @brief Return I2Sx clock frequency * @param I2SxSource This parameter can be one of the following values: * @arg @ref LL_RCC_I2S1_CLKSOURCE * @arg @ref LL_RCC_I2S2_CLKSOURCE (*) * * (*) value not defined in all devices. * @retval I2S clock frequency (in Hz) * - @ref LL_RCC_PERIPH_FREQUENCY_NO indicates that oscillator is not ready */ uint32_t LL_RCC_GetI2SClockFreq(uint32_t I2SxSource) { uint32_t i2s_frequency = LL_RCC_PERIPH_FREQUENCY_NO; /* Check parameter */ assert_param(IS_LL_RCC_I2S_CLKSOURCE(I2SxSource)); if (I2SxSource == LL_RCC_I2S1_CLKSOURCE) { /* I2S1 CLK clock frequency */ switch (LL_RCC_GetI2SClockSource(I2SxSource)) { #if defined(RCC_PLLI2S_SUPPORT) case LL_RCC_I2S1_CLKSOURCE_PLLI2S: /* I2S1 Clock is PLLI2S */ if (LL_RCC_PLLI2S_IsReady()) { i2s_frequency = RCC_PLLI2S_GetFreqDomain_I2S(); } break; #endif /* RCC_PLLI2S_SUPPORT */ #if defined(RCC_DCKCFGR_I2SSRC) || defined(RCC_DCKCFGR_I2S1SRC) case LL_RCC_I2S1_CLKSOURCE_PLL: /* I2S1 Clock is PLL */ if (LL_RCC_PLL_IsReady()) { i2s_frequency = RCC_PLL_GetFreqDomain_I2S(); } break; case LL_RCC_I2S1_CLKSOURCE_PLLSRC: /* I2S1 Clock is PLL Main source */ switch (LL_RCC_PLL_GetMainSource()) { case LL_RCC_PLLSOURCE_HSE: /* I2S1 Clock is HSE Osc. */ if (LL_RCC_HSE_IsReady()) { i2s_frequency = HSE_VALUE; } break; case LL_RCC_PLLSOURCE_HSI: /* I2S1 Clock is HSI Osc. */ default: if (LL_RCC_HSI_IsReady()) { i2s_frequency = HSI_VALUE; } break; } break; #endif /* RCC_DCKCFGR_I2SSRC || RCC_DCKCFGR_I2S1SRC */ case LL_RCC_I2S1_CLKSOURCE_PIN: /* I2S1 Clock is External clock */ default: i2s_frequency = EXTERNAL_CLOCK_VALUE; break; } } #if defined(RCC_DCKCFGR_I2S2SRC) else { /* I2S2 CLK clock frequency */ switch (LL_RCC_GetI2SClockSource(I2SxSource)) { case LL_RCC_I2S2_CLKSOURCE_PLLI2S: /* I2S2 Clock is PLLI2S */ if (LL_RCC_PLLI2S_IsReady()) { i2s_frequency = RCC_PLLI2S_GetFreqDomain_I2S(); } break; case LL_RCC_I2S2_CLKSOURCE_PLL: /* I2S2 Clock is PLL */ if (LL_RCC_PLL_IsReady()) { i2s_frequency = RCC_PLL_GetFreqDomain_I2S(); } break; case LL_RCC_I2S2_CLKSOURCE_PLLSRC: /* I2S2 Clock is PLL Main source */ switch (LL_RCC_PLL_GetMainSource()) { case LL_RCC_PLLSOURCE_HSE: /* I2S2 Clock is HSE Osc. */ if (LL_RCC_HSE_IsReady()) { i2s_frequency = HSE_VALUE; } break; case LL_RCC_PLLSOURCE_HSI: /* I2S2 Clock is HSI Osc. */ default: if (LL_RCC_HSI_IsReady()) { i2s_frequency = HSI_VALUE; } break; } break; case LL_RCC_I2S2_CLKSOURCE_PIN: /* I2S2 Clock is External clock */ default: i2s_frequency = EXTERNAL_CLOCK_VALUE; break; } } #endif /* RCC_DCKCFGR_I2S2SRC */ return i2s_frequency; } #if defined(LPTIM1) /** * @brief Return LPTIMx clock frequency * @param LPTIMxSource This parameter can be one of the following values: * @arg @ref LL_RCC_LPTIM1_CLKSOURCE * @retval LPTIM clock frequency (in Hz) * - @ref LL_RCC_PERIPH_FREQUENCY_NO indicates that oscillator (HSI, LSI or LSE) is not ready */ uint32_t LL_RCC_GetLPTIMClockFreq(uint32_t LPTIMxSource) { uint32_t lptim_frequency = LL_RCC_PERIPH_FREQUENCY_NO; /* Check parameter */ assert_param(IS_LL_RCC_LPTIM_CLKSOURCE(LPTIMxSource)); if (LPTIMxSource == LL_RCC_LPTIM1_CLKSOURCE) { /* LPTIM1CLK clock frequency */ switch (LL_RCC_GetLPTIMClockSource(LPTIMxSource)) { case LL_RCC_LPTIM1_CLKSOURCE_LSI: /* LPTIM1 Clock is LSI Osc. */ if (LL_RCC_LSI_IsReady()) { lptim_frequency = LSI_VALUE; } break; case LL_RCC_LPTIM1_CLKSOURCE_HSI: /* LPTIM1 Clock is HSI Osc. */ if (LL_RCC_HSI_IsReady()) { lptim_frequency = HSI_VALUE; } break; case LL_RCC_LPTIM1_CLKSOURCE_LSE: /* LPTIM1 Clock is LSE Osc. */ if (LL_RCC_LSE_IsReady()) { lptim_frequency = LSE_VALUE; } break; case LL_RCC_LPTIM1_CLKSOURCE_PCLK1: /* LPTIM1 Clock is PCLK1 */ default: lptim_frequency = RCC_GetPCLK1ClockFreq(RCC_GetHCLKClockFreq(RCC_GetSystemClockFreq())); break; } } return lptim_frequency; } #endif /* LPTIM1 */ #if defined(SAI1) /** * @brief Return SAIx clock frequency * @param SAIxSource This parameter can be one of the following values: * @arg @ref LL_RCC_SAI1_CLKSOURCE (*) * @arg @ref LL_RCC_SAI2_CLKSOURCE (*) * @arg @ref LL_RCC_SAI1_A_CLKSOURCE (*) * @arg @ref LL_RCC_SAI1_B_CLKSOURCE (*) * * (*) value not defined in all devices. * @retval SAI clock frequency (in Hz) * - @ref LL_RCC_PERIPH_FREQUENCY_NO indicates that oscillator is not ready */ uint32_t LL_RCC_GetSAIClockFreq(uint32_t SAIxSource) { uint32_t sai_frequency = LL_RCC_PERIPH_FREQUENCY_NO; /* Check parameter */ assert_param(IS_LL_RCC_SAI_CLKSOURCE(SAIxSource)); #if defined(RCC_DCKCFGR_SAI1SRC) if ((SAIxSource == LL_RCC_SAI1_CLKSOURCE) || (SAIxSource == LL_RCC_SAI2_CLKSOURCE)) { /* SAI1CLK clock frequency */ switch (LL_RCC_GetSAIClockSource(SAIxSource)) { case LL_RCC_SAI1_CLKSOURCE_PLLSAI: /* PLLSAI clock used as SAI1 clock source */ case LL_RCC_SAI2_CLKSOURCE_PLLSAI: /* PLLSAI clock used as SAI2 clock source */ if (LL_RCC_PLLSAI_IsReady()) { sai_frequency = RCC_PLLSAI_GetFreqDomain_SAI(); } break; case LL_RCC_SAI1_CLKSOURCE_PLLI2S: /* PLLI2S clock used as SAI1 clock source */ case LL_RCC_SAI2_CLKSOURCE_PLLI2S: /* PLLI2S clock used as SAI2 clock source */ if (LL_RCC_PLLI2S_IsReady()) { sai_frequency = RCC_PLLI2S_GetFreqDomain_SAI(); } break; case LL_RCC_SAI1_CLKSOURCE_PLL: /* PLL clock used as SAI1 clock source */ case LL_RCC_SAI2_CLKSOURCE_PLL: /* PLL clock used as SAI2 clock source */ if (LL_RCC_PLL_IsReady()) { sai_frequency = RCC_PLL_GetFreqDomain_SAI(); } break; case LL_RCC_SAI2_CLKSOURCE_PLLSRC: switch (LL_RCC_PLL_GetMainSource()) { case LL_RCC_PLLSOURCE_HSE: /* HSE clock used as SAI2 clock source */ if (LL_RCC_HSE_IsReady()) { sai_frequency = HSE_VALUE; } break; case LL_RCC_PLLSOURCE_HSI: /* HSI clock used as SAI2 clock source */ default: if (LL_RCC_HSI_IsReady()) { sai_frequency = HSI_VALUE; } break; } break; case LL_RCC_SAI1_CLKSOURCE_PIN: /* External input clock used as SAI1 clock source */ default: sai_frequency = EXTERNAL_CLOCK_VALUE; break; } } #endif /* RCC_DCKCFGR_SAI1SRC */ #if defined(RCC_DCKCFGR_SAI1ASRC) if ((SAIxSource == LL_RCC_SAI1_A_CLKSOURCE) || (SAIxSource == LL_RCC_SAI1_B_CLKSOURCE)) { /* SAI1CLK clock frequency */ switch (LL_RCC_GetSAIClockSource(SAIxSource)) { #if defined(RCC_PLLSAI_SUPPORT) case LL_RCC_SAI1_A_CLKSOURCE_PLLSAI: /* PLLSAI clock used as SAI1 Block A clock source */ case LL_RCC_SAI1_B_CLKSOURCE_PLLSAI: /* PLLSAI clock used as SAI1 Block B clock source */ if (LL_RCC_PLLSAI_IsReady()) { sai_frequency = RCC_PLLSAI_GetFreqDomain_SAI(); } break; #endif /* RCC_PLLSAI_SUPPORT */ case LL_RCC_SAI1_A_CLKSOURCE_PLLI2S: /* PLLI2S clock used as SAI1 Block A clock source */ case LL_RCC_SAI1_B_CLKSOURCE_PLLI2S: /* PLLI2S clock used as SAI1 Block B clock source */ if (LL_RCC_PLLI2S_IsReady()) { sai_frequency = RCC_PLLI2S_GetFreqDomain_SAI(); } break; #if defined(RCC_SAI1A_PLLSOURCE_SUPPORT) case LL_RCC_SAI1_A_CLKSOURCE_PLL: /* PLL clock used as SAI1 Block A clock source */ case LL_RCC_SAI1_B_CLKSOURCE_PLL: /* PLL clock used as SAI1 Block B clock source */ if (LL_RCC_PLL_IsReady()) { sai_frequency = RCC_PLL_GetFreqDomain_SAI(); } break; case LL_RCC_SAI1_A_CLKSOURCE_PLLSRC: case LL_RCC_SAI1_B_CLKSOURCE_PLLSRC: switch (LL_RCC_PLL_GetMainSource()) { case LL_RCC_PLLSOURCE_HSE: /* HSE clock used as SAI1 Block A or B clock source */ if (LL_RCC_HSE_IsReady()) { sai_frequency = HSE_VALUE; } break; case LL_RCC_PLLSOURCE_HSI: /* HSI clock used as SAI1 Block A or B clock source */ default: if (LL_RCC_HSI_IsReady()) { sai_frequency = HSI_VALUE; } break; } break; #endif /* RCC_SAI1A_PLLSOURCE_SUPPORT */ case LL_RCC_SAI1_A_CLKSOURCE_PIN: /* External input clock used as SAI1 Block A clock source */ case LL_RCC_SAI1_B_CLKSOURCE_PIN: /* External input clock used as SAI1 Block B clock source */ default: sai_frequency = EXTERNAL_CLOCK_VALUE; break; } } #endif /* RCC_DCKCFGR_SAI1ASRC */ return sai_frequency; } #endif /* SAI1 */ #if defined(SDIO) /** * @brief Return SDIOx clock frequency * @param SDIOxSource This parameter can be one of the following values: * @arg @ref LL_RCC_SDIO_CLKSOURCE * @retval SDIO clock frequency (in Hz) * - @ref LL_RCC_PERIPH_FREQUENCY_NO indicates that oscillator is not ready */ uint32_t LL_RCC_GetSDIOClockFreq(uint32_t SDIOxSource) { uint32_t SDIO_frequency = LL_RCC_PERIPH_FREQUENCY_NO; /* Check parameter */ assert_param(IS_LL_RCC_SDIO_CLKSOURCE(SDIOxSource)); if (SDIOxSource == LL_RCC_SDIO_CLKSOURCE) { #if defined(RCC_DCKCFGR_SDIOSEL) || defined(RCC_DCKCFGR2_SDIOSEL) /* SDIOCLK clock frequency */ switch (LL_RCC_GetSDIOClockSource(SDIOxSource)) { case LL_RCC_SDIO_CLKSOURCE_PLL48CLK: /* PLL48M clock used as SDIO clock source */ switch (LL_RCC_GetCK48MClockSource(LL_RCC_CK48M_CLKSOURCE)) { case LL_RCC_CK48M_CLKSOURCE_PLL: /* PLL clock used as 48Mhz domain clock */ if (LL_RCC_PLL_IsReady()) { SDIO_frequency = RCC_PLL_GetFreqDomain_48M(); } break; #if defined(RCC_PLLSAI_SUPPORT) case LL_RCC_CK48M_CLKSOURCE_PLLSAI: /* PLLSAI clock used as 48Mhz domain clock */ default: if (LL_RCC_PLLSAI_IsReady()) { SDIO_frequency = RCC_PLLSAI_GetFreqDomain_48M(); } break; #endif /* RCC_PLLSAI_SUPPORT */ #if defined(RCC_PLLI2SCFGR_PLLI2SQ) && !defined(RCC_DCKCFGR_PLLI2SDIVQ) case LL_RCC_CK48M_CLKSOURCE_PLLI2S: /* PLLI2S clock used as 48Mhz domain clock */ default: if (LL_RCC_PLLI2S_IsReady()) { SDIO_frequency = RCC_PLLI2S_GetFreqDomain_48M(); } break; #endif /* RCC_PLLI2SCFGR_PLLI2SQ && !RCC_DCKCFGR_PLLI2SDIVQ */ } break; case LL_RCC_SDIO_CLKSOURCE_SYSCLK: /* PLL clock used as SDIO clock source */ default: SDIO_frequency = RCC_GetSystemClockFreq(); break; } #else /* PLL clock used as 48Mhz domain clock */ if (LL_RCC_PLL_IsReady()) { SDIO_frequency = RCC_PLL_GetFreqDomain_48M(); } #endif /* RCC_DCKCFGR_SDIOSEL || RCC_DCKCFGR2_SDIOSEL */ } return SDIO_frequency; } #endif /* SDIO */ #if defined(RNG) /** * @brief Return RNGx clock frequency * @param RNGxSource This parameter can be one of the following values: * @arg @ref LL_RCC_RNG_CLKSOURCE * @retval RNG clock frequency (in Hz) * - @ref LL_RCC_PERIPH_FREQUENCY_NO indicates that oscillator is not ready */ uint32_t LL_RCC_GetRNGClockFreq(uint32_t RNGxSource) { uint32_t rng_frequency = LL_RCC_PERIPH_FREQUENCY_NO; /* Check parameter */ assert_param(IS_LL_RCC_RNG_CLKSOURCE(RNGxSource)); #if defined(RCC_DCKCFGR_CK48MSEL) || defined(RCC_DCKCFGR2_CK48MSEL) /* RNGCLK clock frequency */ switch (LL_RCC_GetRNGClockSource(RNGxSource)) { #if defined(RCC_PLLI2SCFGR_PLLI2SQ) && !defined(RCC_DCKCFGR_PLLI2SDIVQ) case LL_RCC_RNG_CLKSOURCE_PLLI2S: /* PLLI2S clock used as RNG clock source */ if (LL_RCC_PLLI2S_IsReady()) { rng_frequency = RCC_PLLI2S_GetFreqDomain_48M(); } break; #endif /* RCC_PLLI2SCFGR_PLLI2SQ && !RCC_DCKCFGR_PLLI2SDIVQ */ #if defined(RCC_PLLSAI_SUPPORT) case LL_RCC_RNG_CLKSOURCE_PLLSAI: /* PLLSAI clock used as RNG clock source */ if (LL_RCC_PLLSAI_IsReady()) { rng_frequency = RCC_PLLSAI_GetFreqDomain_48M(); } break; #endif /* RCC_PLLSAI_SUPPORT */ case LL_RCC_RNG_CLKSOURCE_PLL: /* PLL clock used as RNG clock source */ default: if (LL_RCC_PLL_IsReady()) { rng_frequency = RCC_PLL_GetFreqDomain_48M(); } break; } #else /* PLL clock used as RNG clock source */ if (LL_RCC_PLL_IsReady()) { rng_frequency = RCC_PLL_GetFreqDomain_48M(); } #endif /* RCC_DCKCFGR_CK48MSEL || RCC_DCKCFGR2_CK48MSEL */ return rng_frequency; } #endif /* RNG */ #if defined(CEC) /** * @brief Return CEC clock frequency * @param CECxSource This parameter can be one of the following values: * @arg @ref LL_RCC_CEC_CLKSOURCE * @retval CEC clock frequency (in Hz) * - @ref LL_RCC_PERIPH_FREQUENCY_NO indicates that oscillator (HSI or LSE) is not ready */ uint32_t LL_RCC_GetCECClockFreq(uint32_t CECxSource) { uint32_t cec_frequency = LL_RCC_PERIPH_FREQUENCY_NO; /* Check parameter */ assert_param(IS_LL_RCC_CEC_CLKSOURCE(CECxSource)); /* CECCLK clock frequency */ switch (LL_RCC_GetCECClockSource(CECxSource)) { case LL_RCC_CEC_CLKSOURCE_LSE: /* CEC Clock is LSE Osc. */ if (LL_RCC_LSE_IsReady()) { cec_frequency = LSE_VALUE; } break; case LL_RCC_CEC_CLKSOURCE_HSI_DIV488: /* CEC Clock is HSI Osc. */ default: if (LL_RCC_HSI_IsReady()) { cec_frequency = HSI_VALUE/488U; } break; } return cec_frequency; } #endif /* CEC */ #if defined(USB_OTG_FS) || defined(USB_OTG_HS) /** * @brief Return USBx clock frequency * @param USBxSource This parameter can be one of the following values: * @arg @ref LL_RCC_USB_CLKSOURCE * @retval USB clock frequency (in Hz) * - @ref LL_RCC_PERIPH_FREQUENCY_NO indicates that oscillator is not ready */ uint32_t LL_RCC_GetUSBClockFreq(uint32_t USBxSource) { uint32_t usb_frequency = LL_RCC_PERIPH_FREQUENCY_NO; /* Check parameter */ assert_param(IS_LL_RCC_USB_CLKSOURCE(USBxSource)); #if defined(RCC_DCKCFGR_CK48MSEL) || defined(RCC_DCKCFGR2_CK48MSEL) /* USBCLK clock frequency */ switch (LL_RCC_GetUSBClockSource(USBxSource)) { #if defined(RCC_PLLI2SCFGR_PLLI2SQ) && !defined(RCC_DCKCFGR_PLLI2SDIVQ) case LL_RCC_USB_CLKSOURCE_PLLI2S: /* PLLI2S clock used as USB clock source */ if (LL_RCC_PLLI2S_IsReady()) { usb_frequency = RCC_PLLI2S_GetFreqDomain_48M(); } break; #endif /* RCC_PLLI2SCFGR_PLLI2SQ && !RCC_DCKCFGR_PLLI2SDIVQ */ #if defined(RCC_PLLSAI_SUPPORT) case LL_RCC_USB_CLKSOURCE_PLLSAI: /* PLLSAI clock used as USB clock source */ if (LL_RCC_PLLSAI_IsReady()) { usb_frequency = RCC_PLLSAI_GetFreqDomain_48M(); } break; #endif /* RCC_PLLSAI_SUPPORT */ case LL_RCC_USB_CLKSOURCE_PLL: /* PLL clock used as USB clock source */ default: if (LL_RCC_PLL_IsReady()) { usb_frequency = RCC_PLL_GetFreqDomain_48M(); } break; } #else /* PLL clock used as USB clock source */ if (LL_RCC_PLL_IsReady()) { usb_frequency = RCC_PLL_GetFreqDomain_48M(); } #endif /* RCC_DCKCFGR_CK48MSEL || RCC_DCKCFGR2_CK48MSEL */ return usb_frequency; } #endif /* USB_OTG_FS || USB_OTG_HS */ #if defined(DFSDM1_Channel0) /** * @brief Return DFSDMx clock frequency * @param DFSDMxSource This parameter can be one of the following values: * @arg @ref LL_RCC_DFSDM1_CLKSOURCE * @arg @ref LL_RCC_DFSDM2_CLKSOURCE (*) * * (*) value not defined in all devices. * @retval DFSDM clock frequency (in Hz) */ uint32_t LL_RCC_GetDFSDMClockFreq(uint32_t DFSDMxSource) { uint32_t dfsdm_frequency = LL_RCC_PERIPH_FREQUENCY_NO; /* Check parameter */ assert_param(IS_LL_RCC_DFSDM_CLKSOURCE(DFSDMxSource)); if (DFSDMxSource == LL_RCC_DFSDM1_CLKSOURCE) { /* DFSDM1CLK clock frequency */ switch (LL_RCC_GetDFSDMClockSource(DFSDMxSource)) { case LL_RCC_DFSDM1_CLKSOURCE_SYSCLK: /* DFSDM1 Clock is SYSCLK */ dfsdm_frequency = RCC_GetSystemClockFreq(); break; case LL_RCC_DFSDM1_CLKSOURCE_PCLK2: /* DFSDM1 Clock is PCLK2 */ default: dfsdm_frequency = RCC_GetPCLK2ClockFreq(RCC_GetHCLKClockFreq(RCC_GetSystemClockFreq())); break; } } #if defined(DFSDM2_Channel0) else { /* DFSDM2CLK clock frequency */ switch (LL_RCC_GetDFSDMClockSource(DFSDMxSource)) { case LL_RCC_DFSDM2_CLKSOURCE_SYSCLK: /* DFSDM2 Clock is SYSCLK */ dfsdm_frequency = RCC_GetSystemClockFreq(); break; case LL_RCC_DFSDM2_CLKSOURCE_PCLK2: /* DFSDM2 Clock is PCLK2 */ default: dfsdm_frequency = RCC_GetPCLK2ClockFreq(RCC_GetHCLKClockFreq(RCC_GetSystemClockFreq())); break; } } #endif /* DFSDM2_Channel0 */ return dfsdm_frequency; } /** * @brief Return DFSDMx Audio clock frequency * @param DFSDMxSource This parameter can be one of the following values: * @arg @ref LL_RCC_DFSDM1_AUDIO_CLKSOURCE * @arg @ref LL_RCC_DFSDM2_AUDIO_CLKSOURCE (*) * * (*) value not defined in all devices. * @retval DFSDM clock frequency (in Hz) * - @ref LL_RCC_PERIPH_FREQUENCY_NO indicates that oscillator is not ready */ uint32_t LL_RCC_GetDFSDMAudioClockFreq(uint32_t DFSDMxSource) { uint32_t dfsdm_frequency = LL_RCC_PERIPH_FREQUENCY_NO; /* Check parameter */ assert_param(IS_LL_RCC_DFSDM_AUDIO_CLKSOURCE(DFSDMxSource)); if (DFSDMxSource == LL_RCC_DFSDM1_AUDIO_CLKSOURCE) { /* DFSDM1CLK clock frequency */ switch (LL_RCC_GetDFSDMAudioClockSource(DFSDMxSource)) { case LL_RCC_DFSDM1_AUDIO_CLKSOURCE_I2S1: /* I2S1 clock used as DFSDM1 clock */ dfsdm_frequency = LL_RCC_GetI2SClockFreq(LL_RCC_I2S1_CLKSOURCE); break; case LL_RCC_DFSDM1_AUDIO_CLKSOURCE_I2S2: /* I2S2 clock used as DFSDM1 clock */ default: dfsdm_frequency = LL_RCC_GetI2SClockFreq(LL_RCC_I2S2_CLKSOURCE); break; } } #if defined(DFSDM2_Channel0) else { /* DFSDM2CLK clock frequency */ switch (LL_RCC_GetDFSDMAudioClockSource(DFSDMxSource)) { case LL_RCC_DFSDM2_AUDIO_CLKSOURCE_I2S1: /* I2S1 clock used as DFSDM2 clock */ dfsdm_frequency = LL_RCC_GetI2SClockFreq(LL_RCC_I2S1_CLKSOURCE); break; case LL_RCC_DFSDM2_AUDIO_CLKSOURCE_I2S2: /* I2S2 clock used as DFSDM2 clock */ default: dfsdm_frequency = LL_RCC_GetI2SClockFreq(LL_RCC_I2S2_CLKSOURCE); break; } } #endif /* DFSDM2_Channel0 */ return dfsdm_frequency; } #endif /* DFSDM1_Channel0 */ #if defined(DSI) /** * @brief Return DSI clock frequency * @param DSIxSource This parameter can be one of the following values: * @arg @ref LL_RCC_DSI_CLKSOURCE * @retval DSI clock frequency (in Hz) * - @ref LL_RCC_PERIPH_FREQUENCY_NO indicates that oscillator is not ready * - @ref LL_RCC_PERIPH_FREQUENCY_NA indicates that external clock is used */ uint32_t LL_RCC_GetDSIClockFreq(uint32_t DSIxSource) { uint32_t dsi_frequency = LL_RCC_PERIPH_FREQUENCY_NO; /* Check parameter */ assert_param(IS_LL_RCC_DSI_CLKSOURCE(DSIxSource)); /* DSICLK clock frequency */ switch (LL_RCC_GetDSIClockSource(DSIxSource)) { case LL_RCC_DSI_CLKSOURCE_PLL: /* DSI Clock is PLL Osc. */ if (LL_RCC_PLL_IsReady()) { dsi_frequency = RCC_PLL_GetFreqDomain_DSI(); } break; case LL_RCC_DSI_CLKSOURCE_PHY: /* DSI Clock is DSI physical clock. */ default: dsi_frequency = LL_RCC_PERIPH_FREQUENCY_NA; break; } return dsi_frequency; } #endif /* DSI */ #if defined(LTDC) /** * @brief Return LTDC clock frequency * @param LTDCxSource This parameter can be one of the following values: * @arg @ref LL_RCC_LTDC_CLKSOURCE * @retval LTDC clock frequency (in Hz) * - @ref LL_RCC_PERIPH_FREQUENCY_NO indicates that oscillator PLLSAI is not ready */ uint32_t LL_RCC_GetLTDCClockFreq(uint32_t LTDCxSource) { uint32_t ltdc_frequency = LL_RCC_PERIPH_FREQUENCY_NO; /* Check parameter */ assert_param(IS_LL_RCC_LTDC_CLKSOURCE(LTDCxSource)); if (LL_RCC_PLLSAI_IsReady()) { ltdc_frequency = RCC_PLLSAI_GetFreqDomain_LTDC(); } return ltdc_frequency; } #endif /* LTDC */ #if defined(SPDIFRX) /** * @brief Return SPDIFRX clock frequency * @param SPDIFRXxSource This parameter can be one of the following values: * @arg @ref LL_RCC_SPDIFRX1_CLKSOURCE * @retval SPDIFRX clock frequency (in Hz) * - @ref LL_RCC_PERIPH_FREQUENCY_NO indicates that oscillator is not ready */ uint32_t LL_RCC_GetSPDIFRXClockFreq(uint32_t SPDIFRXxSource) { uint32_t spdifrx_frequency = LL_RCC_PERIPH_FREQUENCY_NO; /* Check parameter */ assert_param(IS_LL_RCC_SPDIFRX_CLKSOURCE(SPDIFRXxSource)); /* SPDIFRX1CLK clock frequency */ switch (LL_RCC_GetSPDIFRXClockSource(SPDIFRXxSource)) { case LL_RCC_SPDIFRX1_CLKSOURCE_PLLI2S: /* SPDIFRX Clock is PLLI2S Osc. */ if (LL_RCC_PLLI2S_IsReady()) { spdifrx_frequency = RCC_PLLI2S_GetFreqDomain_SPDIFRX(); } break; case LL_RCC_SPDIFRX1_CLKSOURCE_PLL: /* SPDIFRX Clock is PLL Osc. */ default: if (LL_RCC_PLL_IsReady()) { spdifrx_frequency = RCC_PLL_GetFreqDomain_SPDIFRX(); } break; } return spdifrx_frequency; } #endif /* SPDIFRX */ /** * @} */ /** * @} */ /** @addtogroup RCC_LL_Private_Functions * @{ */ /** * @brief Return SYSTEM clock frequency * @retval SYSTEM clock frequency (in Hz) */ uint32_t RCC_GetSystemClockFreq(void) { uint32_t frequency = 0U; /* Get SYSCLK source -------------------------------------------------------*/ switch (LL_RCC_GetSysClkSource()) { case LL_RCC_SYS_CLKSOURCE_STATUS_HSI: /* HSI used as system clock source */ frequency = HSI_VALUE; break; case LL_RCC_SYS_CLKSOURCE_STATUS_HSE: /* HSE used as system clock source */ frequency = HSE_VALUE; break; case LL_RCC_SYS_CLKSOURCE_STATUS_PLL: /* PLL used as system clock source */ frequency = RCC_PLL_GetFreqDomain_SYS(LL_RCC_SYS_CLKSOURCE_STATUS_PLL); break; #if defined(RCC_PLLR_SYSCLK_SUPPORT) case LL_RCC_SYS_CLKSOURCE_STATUS_PLLR: /* PLLR used as system clock source */ frequency = RCC_PLL_GetFreqDomain_SYS(LL_RCC_SYS_CLKSOURCE_STATUS_PLLR); break; #endif /* RCC_PLLR_SYSCLK_SUPPORT */ default: frequency = HSI_VALUE; break; } return frequency; } /** * @brief Return HCLK clock frequency * @param SYSCLK_Frequency SYSCLK clock frequency * @retval HCLK clock frequency (in Hz) */ uint32_t RCC_GetHCLKClockFreq(uint32_t SYSCLK_Frequency) { /* HCLK clock frequency */ return __LL_RCC_CALC_HCLK_FREQ(SYSCLK_Frequency, LL_RCC_GetAHBPrescaler()); } /** * @brief Return PCLK1 clock frequency * @param HCLK_Frequency HCLK clock frequency * @retval PCLK1 clock frequency (in Hz) */ uint32_t RCC_GetPCLK1ClockFreq(uint32_t HCLK_Frequency) { /* PCLK1 clock frequency */ return __LL_RCC_CALC_PCLK1_FREQ(HCLK_Frequency, LL_RCC_GetAPB1Prescaler()); } /** * @brief Return PCLK2 clock frequency * @param HCLK_Frequency HCLK clock frequency * @retval PCLK2 clock frequency (in Hz) */ uint32_t RCC_GetPCLK2ClockFreq(uint32_t HCLK_Frequency) { /* PCLK2 clock frequency */ return __LL_RCC_CALC_PCLK2_FREQ(HCLK_Frequency, LL_RCC_GetAPB2Prescaler()); } /** * @brief Return PLL clock frequency used for system domain * @param SYSCLK_Source System clock source * @retval PLL clock frequency (in Hz) */ uint32_t RCC_PLL_GetFreqDomain_SYS(uint32_t SYSCLK_Source) { uint32_t pllinputfreq = 0U, pllsource = 0U, plloutputfreq = 0U; /* PLL_VCO = (HSE_VALUE or HSI_VALUE / PLLM) * PLLN SYSCLK = PLL_VCO / (PLLP or PLLR) */ pllsource = LL_RCC_PLL_GetMainSource(); switch (pllsource) { case LL_RCC_PLLSOURCE_HSI: /* HSI used as PLL clock source */ pllinputfreq = HSI_VALUE; break; case LL_RCC_PLLSOURCE_HSE: /* HSE used as PLL clock source */ pllinputfreq = HSE_VALUE; break; default: pllinputfreq = HSI_VALUE; break; } if (SYSCLK_Source == LL_RCC_SYS_CLKSOURCE_STATUS_PLL) { plloutputfreq = __LL_RCC_CALC_PLLCLK_FREQ(pllinputfreq, LL_RCC_PLL_GetDivider(), LL_RCC_PLL_GetN(), LL_RCC_PLL_GetP()); } #if defined(RCC_PLLR_SYSCLK_SUPPORT) else { plloutputfreq = __LL_RCC_CALC_PLLRCLK_FREQ(pllinputfreq, LL_RCC_PLL_GetDivider(), LL_RCC_PLL_GetN(), LL_RCC_PLL_GetR()); } #endif /* RCC_PLLR_SYSCLK_SUPPORT */ return plloutputfreq; } /** * @brief Return PLL clock frequency used for 48 MHz domain * @retval PLL clock frequency (in Hz) */ uint32_t RCC_PLL_GetFreqDomain_48M(void) { uint32_t pllinputfreq = 0U, pllsource = 0U; /* PLL_VCO = (HSE_VALUE or HSI_VALUE / PLLM ) * PLLN 48M Domain clock = PLL_VCO / PLLQ */ pllsource = LL_RCC_PLL_GetMainSource(); switch (pllsource) { case LL_RCC_PLLSOURCE_HSI: /* HSI used as PLL clock source */ pllinputfreq = HSI_VALUE; break; case LL_RCC_PLLSOURCE_HSE: /* HSE used as PLL clock source */ pllinputfreq = HSE_VALUE; break; default: pllinputfreq = HSI_VALUE; break; } return __LL_RCC_CALC_PLLCLK_48M_FREQ(pllinputfreq, LL_RCC_PLL_GetDivider(), LL_RCC_PLL_GetN(), LL_RCC_PLL_GetQ()); } #if defined(DSI) /** * @brief Return PLL clock frequency used for DSI clock * @retval PLL clock frequency (in Hz) */ uint32_t RCC_PLL_GetFreqDomain_DSI(void) { uint32_t pllinputfreq = 0U, pllsource = 0U; /* PLL_VCO = (HSE_VALUE or HSI_VALUE / PLLM) * PLLN DSICLK = PLL_VCO / PLLR */ pllsource = LL_RCC_PLL_GetMainSource(); switch (pllsource) { case LL_RCC_PLLSOURCE_HSE: /* HSE used as PLL clock source */ pllinputfreq = HSE_VALUE; break; case LL_RCC_PLLSOURCE_HSI: /* HSI used as PLL clock source */ default: pllinputfreq = HSI_VALUE; break; } return __LL_RCC_CALC_PLLCLK_DSI_FREQ(pllinputfreq, LL_RCC_PLL_GetDivider(), LL_RCC_PLL_GetN(), LL_RCC_PLL_GetR()); } #endif /* DSI */ #if defined(RCC_DCKCFGR_I2SSRC) || defined(RCC_DCKCFGR_I2S1SRC) /** * @brief Return PLL clock frequency used for I2S clock * @retval PLL clock frequency (in Hz) */ uint32_t RCC_PLL_GetFreqDomain_I2S(void) { uint32_t pllinputfreq = 0U, pllsource = 0U; /* PLL_VCO = (HSE_VALUE or HSI_VALUE / PLLM) * PLLN I2SCLK = PLL_VCO / PLLR */ pllsource = LL_RCC_PLL_GetMainSource(); switch (pllsource) { case LL_RCC_PLLSOURCE_HSE: /* HSE used as PLL clock source */ pllinputfreq = HSE_VALUE; break; case LL_RCC_PLLSOURCE_HSI: /* HSI used as PLL clock source */ default: pllinputfreq = HSI_VALUE; break; } return __LL_RCC_CALC_PLLCLK_I2S_FREQ(pllinputfreq, LL_RCC_PLL_GetDivider(), LL_RCC_PLL_GetN(), LL_RCC_PLL_GetR()); } #endif /* RCC_DCKCFGR_I2SSRC || RCC_DCKCFGR_I2S1SRC */ #if defined(SPDIFRX) /** * @brief Return PLL clock frequency used for SPDIFRX clock * @retval PLL clock frequency (in Hz) */ uint32_t RCC_PLL_GetFreqDomain_SPDIFRX(void) { uint32_t pllinputfreq = 0U, pllsource = 0U; /* PLL_VCO = (HSE_VALUE or HSI_VALUE / PLLM) * PLLN SPDIFRXCLK = PLL_VCO / PLLR */ pllsource = LL_RCC_PLL_GetMainSource(); switch (pllsource) { case LL_RCC_PLLSOURCE_HSE: /* HSE used as PLL clock source */ pllinputfreq = HSE_VALUE; break; case LL_RCC_PLLSOURCE_HSI: /* HSI used as PLL clock source */ default: pllinputfreq = HSI_VALUE; break; } return __LL_RCC_CALC_PLLCLK_SPDIFRX_FREQ(pllinputfreq, LL_RCC_PLL_GetDivider(), LL_RCC_PLL_GetN(), LL_RCC_PLL_GetR()); } #endif /* SPDIFRX */ #if defined(RCC_PLLCFGR_PLLR) #if defined(SAI1) /** * @brief Return PLL clock frequency used for SAI clock * @retval PLL clock frequency (in Hz) */ uint32_t RCC_PLL_GetFreqDomain_SAI(void) { uint32_t pllinputfreq = 0U, pllsource = 0U, plloutputfreq = 0U; /* PLL_VCO = (HSE_VALUE or HSI_VALUE / PLLM) * PLLN SAICLK = (PLL_VCO / PLLR) / PLLDIVR or SAICLK = PLL_VCO / PLLR */ pllsource = LL_RCC_PLL_GetMainSource(); switch (pllsource) { case LL_RCC_PLLSOURCE_HSE: /* HSE used as PLL clock source */ pllinputfreq = HSE_VALUE; break; case LL_RCC_PLLSOURCE_HSI: /* HSI used as PLL clock source */ default: pllinputfreq = HSI_VALUE; break; } #if defined(RCC_DCKCFGR_PLLDIVR) plloutputfreq = __LL_RCC_CALC_PLLCLK_SAI_FREQ(pllinputfreq, LL_RCC_PLL_GetDivider(), LL_RCC_PLL_GetN(), LL_RCC_PLL_GetR(), LL_RCC_PLL_GetDIVR()); #else plloutputfreq = __LL_RCC_CALC_PLLCLK_SAI_FREQ(pllinputfreq, LL_RCC_PLL_GetDivider(), LL_RCC_PLL_GetN(), LL_RCC_PLL_GetR()); #endif /* RCC_DCKCFGR_PLLDIVR */ return plloutputfreq; } #endif /* SAI1 */ #endif /* RCC_PLLCFGR_PLLR */ #if defined(RCC_PLLSAI_SUPPORT) /** * @brief Return PLLSAI clock frequency used for SAI domain * @retval PLLSAI clock frequency (in Hz) */ uint32_t RCC_PLLSAI_GetFreqDomain_SAI(void) { uint32_t pllinputfreq = 0U, pllsource = 0U; /* PLLSAI_VCO = (HSE_VALUE or HSI_VALUE / PLLSAIM) * PLLSAIN SAI domain clock = (PLLSAI_VCO / PLLSAIQ) / PLLSAIDIVQ */ pllsource = LL_RCC_PLL_GetMainSource(); switch (pllsource) { case LL_RCC_PLLSOURCE_HSI: /* HSI used as PLLSAI clock source */ pllinputfreq = HSI_VALUE; break; case LL_RCC_PLLSOURCE_HSE: /* HSE used as PLLSAI clock source */ pllinputfreq = HSE_VALUE; break; default: pllinputfreq = HSI_VALUE; break; } return __LL_RCC_CALC_PLLSAI_SAI_FREQ(pllinputfreq, LL_RCC_PLLSAI_GetDivider(), LL_RCC_PLLSAI_GetN(), LL_RCC_PLLSAI_GetQ(), LL_RCC_PLLSAI_GetDIVQ()); } #if defined(RCC_PLLSAICFGR_PLLSAIP) /** * @brief Return PLLSAI clock frequency used for 48Mhz domain * @retval PLLSAI clock frequency (in Hz) */ uint32_t RCC_PLLSAI_GetFreqDomain_48M(void) { uint32_t pllinputfreq = 0U, pllsource = 0U; /* PLLSAI_VCO = (HSE_VALUE or HSI_VALUE / PLLSAIM) * PLLSAIN 48M Domain clock = PLLSAI_VCO / PLLSAIP */ pllsource = LL_RCC_PLL_GetMainSource(); switch (pllsource) { case LL_RCC_PLLSOURCE_HSI: /* HSI used as PLLSAI clock source */ pllinputfreq = HSI_VALUE; break; case LL_RCC_PLLSOURCE_HSE: /* HSE used as PLLSAI clock source */ pllinputfreq = HSE_VALUE; break; default: pllinputfreq = HSI_VALUE; break; } return __LL_RCC_CALC_PLLSAI_48M_FREQ(pllinputfreq, LL_RCC_PLLSAI_GetDivider(), LL_RCC_PLLSAI_GetN(), LL_RCC_PLLSAI_GetP()); } #endif /* RCC_PLLSAICFGR_PLLSAIP */ #if defined(LTDC) /** * @brief Return PLLSAI clock frequency used for LTDC domain * @retval PLLSAI clock frequency (in Hz) */ uint32_t RCC_PLLSAI_GetFreqDomain_LTDC(void) { uint32_t pllinputfreq = 0U, pllsource = 0U; /* PLLSAI_VCO = (HSE_VALUE or HSI_VALUE / PLLSAIM) * PLLSAIN LTDC Domain clock = (PLLSAI_VCO / PLLSAIR) / PLLSAIDIVR */ pllsource = LL_RCC_PLL_GetMainSource(); switch (pllsource) { case LL_RCC_PLLSOURCE_HSI: /* HSI used as PLLSAI clock source */ pllinputfreq = HSI_VALUE; break; case LL_RCC_PLLSOURCE_HSE: /* HSE used as PLLSAI clock source */ pllinputfreq = HSE_VALUE; break; default: pllinputfreq = HSI_VALUE; break; } return __LL_RCC_CALC_PLLSAI_LTDC_FREQ(pllinputfreq, LL_RCC_PLLSAI_GetDivider(), LL_RCC_PLLSAI_GetN(), LL_RCC_PLLSAI_GetR(), LL_RCC_PLLSAI_GetDIVR()); } #endif /* LTDC */ #endif /* RCC_PLLSAI_SUPPORT */ #if defined(RCC_PLLI2S_SUPPORT) #if defined(SAI1) /** * @brief Return PLLI2S clock frequency used for SAI domains * @retval PLLI2S clock frequency (in Hz) */ uint32_t RCC_PLLI2S_GetFreqDomain_SAI(void) { uint32_t plli2sinputfreq = 0U, plli2ssource = 0U, plli2soutputfreq = 0U; /* PLLI2S_VCO = (HSE_VALUE or HSI_VALUE / PLLI2SM) * PLLI2SN SAI domain clock = (PLLI2S_VCO / PLLI2SQ) / PLLI2SDIVQ or SAI domain clock = (PLLI2S_VCO / PLLI2SR) / PLLI2SDIVR */ plli2ssource = LL_RCC_PLLI2S_GetMainSource(); switch (plli2ssource) { case LL_RCC_PLLSOURCE_HSE: /* HSE used as PLLI2S clock source */ plli2sinputfreq = HSE_VALUE; break; #if defined(RCC_PLLI2SCFGR_PLLI2SSRC) case LL_RCC_PLLI2SSOURCE_PIN: /* External pin input clock used as PLLI2S clock source */ plli2sinputfreq = EXTERNAL_CLOCK_VALUE; break; #endif /* RCC_PLLI2SCFGR_PLLI2SSRC */ case LL_RCC_PLLSOURCE_HSI: /* HSI used as PLLI2S clock source */ default: plli2sinputfreq = HSI_VALUE; break; } #if defined(RCC_DCKCFGR_PLLI2SDIVQ) plli2soutputfreq = __LL_RCC_CALC_PLLI2S_SAI_FREQ(plli2sinputfreq, LL_RCC_PLLI2S_GetDivider(), LL_RCC_PLLI2S_GetN(), LL_RCC_PLLI2S_GetQ(), LL_RCC_PLLI2S_GetDIVQ()); #else plli2soutputfreq = __LL_RCC_CALC_PLLI2S_SAI_FREQ(plli2sinputfreq, LL_RCC_PLLI2S_GetDivider(), LL_RCC_PLLI2S_GetN(), LL_RCC_PLLI2S_GetR(), LL_RCC_PLLI2S_GetDIVR()); #endif /* RCC_DCKCFGR_PLLI2SDIVQ */ return plli2soutputfreq; } #endif /* SAI1 */ #if defined(SPDIFRX) /** * @brief Return PLLI2S clock frequency used for SPDIFRX domain * @retval PLLI2S clock frequency (in Hz) */ uint32_t RCC_PLLI2S_GetFreqDomain_SPDIFRX(void) { uint32_t pllinputfreq = 0U, pllsource = 0U; /* PLLI2S_VCO = (HSE_VALUE or HSI_VALUE / PLLI2SM) * PLLI2SN SPDIFRX Domain clock = PLLI2S_VCO / PLLI2SP */ pllsource = LL_RCC_PLLI2S_GetMainSource(); switch (pllsource) { case LL_RCC_PLLSOURCE_HSE: /* HSE used as PLLI2S clock source */ pllinputfreq = HSE_VALUE; break; case LL_RCC_PLLSOURCE_HSI: /* HSI used as PLLI2S clock source */ default: pllinputfreq = HSI_VALUE; break; } return __LL_RCC_CALC_PLLI2S_SPDIFRX_FREQ(pllinputfreq, LL_RCC_PLLI2S_GetDivider(), LL_RCC_PLLI2S_GetN(), LL_RCC_PLLI2S_GetP()); } #endif /* SPDIFRX */ /** * @brief Return PLLI2S clock frequency used for I2S domain * @retval PLLI2S clock frequency (in Hz) */ uint32_t RCC_PLLI2S_GetFreqDomain_I2S(void) { uint32_t plli2sinputfreq = 0U, plli2ssource = 0U, plli2soutputfreq = 0U; /* PLLI2S_VCO = (HSE_VALUE or HSI_VALUE / PLLI2SM) * PLLI2SN I2S Domain clock = PLLI2S_VCO / PLLI2SR */ plli2ssource = LL_RCC_PLLI2S_GetMainSource(); switch (plli2ssource) { case LL_RCC_PLLSOURCE_HSE: /* HSE used as PLLI2S clock source */ plli2sinputfreq = HSE_VALUE; break; #if defined(RCC_PLLI2SCFGR_PLLI2SSRC) case LL_RCC_PLLI2SSOURCE_PIN: /* External pin input clock used as PLLI2S clock source */ plli2sinputfreq = EXTERNAL_CLOCK_VALUE; break; #endif /* RCC_PLLI2SCFGR_PLLI2SSRC */ case LL_RCC_PLLSOURCE_HSI: /* HSI used as PLLI2S clock source */ default: plli2sinputfreq = HSI_VALUE; break; } plli2soutputfreq = __LL_RCC_CALC_PLLI2S_I2S_FREQ(plli2sinputfreq, LL_RCC_PLLI2S_GetDivider(), LL_RCC_PLLI2S_GetN(), LL_RCC_PLLI2S_GetR()); return plli2soutputfreq; } #if defined(RCC_PLLI2SCFGR_PLLI2SQ) && !defined(RCC_DCKCFGR_PLLI2SDIVQ) /** * @brief Return PLLI2S clock frequency used for 48Mhz domain * @retval PLLI2S clock frequency (in Hz) */ uint32_t RCC_PLLI2S_GetFreqDomain_48M(void) { uint32_t plli2sinputfreq = 0U, plli2ssource = 0U, plli2soutputfreq = 0U; /* PLL48M_VCO = (HSE_VALUE or HSI_VALUE / PLLI2SM) * PLLI2SN 48M Domain clock = PLLI2S_VCO / PLLI2SQ */ plli2ssource = LL_RCC_PLLI2S_GetMainSource(); switch (plli2ssource) { case LL_RCC_PLLSOURCE_HSE: /* HSE used as PLLI2S clock source */ plli2sinputfreq = HSE_VALUE; break; #if defined(RCC_PLLI2SCFGR_PLLI2SSRC) case LL_RCC_PLLI2SSOURCE_PIN: /* External pin input clock used as PLLI2S clock source */ plli2sinputfreq = EXTERNAL_CLOCK_VALUE; break; #endif /* RCC_PLLI2SCFGR_PLLI2SSRC */ case LL_RCC_PLLSOURCE_HSI: /* HSI used as PLLI2S clock source */ default: plli2sinputfreq = HSI_VALUE; break; } plli2soutputfreq = __LL_RCC_CALC_PLLI2S_48M_FREQ(plli2sinputfreq, LL_RCC_PLLI2S_GetDivider(), LL_RCC_PLLI2S_GetN(), LL_RCC_PLLI2S_GetQ()); return plli2soutputfreq; } #endif /* RCC_PLLI2SCFGR_PLLI2SQ && !RCC_DCKCFGR_PLLI2SDIVQ */ #endif /* RCC_PLLI2S_SUPPORT */ /** * @} */ /** * @} */ #endif /* defined(RCC) */ /** * @} */ #endif /* USE_FULL_LL_DRIVER */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ ================================================ FILE: sys/arch/stm32/hal/stm32f4xx_ll_rcc.h ================================================ /** ****************************************************************************** * @file stm32f4xx_ll_rcc.h * @author MCD Application Team * @version V1.7.1 * @date 14-April-2017 * @brief Header file of RCC LL module. ****************************************************************************** * @attention * *

© COPYRIGHT(c) 2017 STMicroelectronics

* * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. Neither the name of STMicroelectronics nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __STM32F4xx_LL_RCC_H #define __STM32F4xx_LL_RCC_H #ifdef __cplusplus extern "C" { #endif /* Includes ------------------------------------------------------------------*/ #include "stm32f4xx.h" /** @addtogroup STM32F4xx_LL_Driver * @{ */ #if defined(RCC) /** @defgroup RCC_LL RCC * @{ */ /* Private types -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ /** @defgroup RCC_LL_Private_Variables RCC Private Variables * @{ */ #if defined(RCC_DCKCFGR_PLLSAIDIVR) static const uint8_t aRCC_PLLSAIDIVRPrescTable[4] = {2, 4, 8, 16}; #endif /* RCC_DCKCFGR_PLLSAIDIVR */ /** * @} */ /* Private constants ---------------------------------------------------------*/ /* Private macros ------------------------------------------------------------*/ #if defined(USE_FULL_LL_DRIVER) /** @defgroup RCC_LL_Private_Macros RCC Private Macros * @{ */ /** * @} */ #endif /*USE_FULL_LL_DRIVER*/ /* Exported types ------------------------------------------------------------*/ #if defined(USE_FULL_LL_DRIVER) /** @defgroup RCC_LL_Exported_Types RCC Exported Types * @{ */ /** @defgroup LL_ES_CLOCK_FREQ Clocks Frequency Structure * @{ */ /** * @brief RCC Clocks Frequency Structure */ typedef struct { uint32_t SYSCLK_Frequency; /*!< SYSCLK clock frequency */ uint32_t HCLK_Frequency; /*!< HCLK clock frequency */ uint32_t PCLK1_Frequency; /*!< PCLK1 clock frequency */ uint32_t PCLK2_Frequency; /*!< PCLK2 clock frequency */ } LL_RCC_ClocksTypeDef; /** * @} */ /** * @} */ #endif /* USE_FULL_LL_DRIVER */ /* Exported constants --------------------------------------------------------*/ /** @defgroup RCC_LL_Exported_Constants RCC Exported Constants * @{ */ /** @defgroup RCC_LL_EC_OSC_VALUES Oscillator Values adaptation * @brief Defines used to adapt values of different oscillators * @note These values could be modified in the user environment according to * HW set-up. * @{ */ #if !defined (HSE_VALUE) #define HSE_VALUE 25000000U /*!< Value of the HSE oscillator in Hz */ #endif /* HSE_VALUE */ #if !defined (HSI_VALUE) #define HSI_VALUE 16000000U /*!< Value of the HSI oscillator in Hz */ #endif /* HSI_VALUE */ #if !defined (LSE_VALUE) #define LSE_VALUE 32768U /*!< Value of the LSE oscillator in Hz */ #endif /* LSE_VALUE */ #if !defined (LSI_VALUE) #define LSI_VALUE 32000U /*!< Value of the LSI oscillator in Hz */ #endif /* LSI_VALUE */ #if !defined (EXTERNAL_CLOCK_VALUE) #define EXTERNAL_CLOCK_VALUE 12288000U /*!< Value of the I2S_CKIN external oscillator in Hz */ #endif /* EXTERNAL_CLOCK_VALUE */ /** * @} */ /** @defgroup RCC_LL_EC_CLEAR_FLAG Clear Flags Defines * @brief Flags defines which can be used with LL_RCC_WriteReg function * @{ */ #define LL_RCC_CIR_LSIRDYC RCC_CIR_LSIRDYC /*!< LSI Ready Interrupt Clear */ #define LL_RCC_CIR_LSERDYC RCC_CIR_LSERDYC /*!< LSE Ready Interrupt Clear */ #define LL_RCC_CIR_HSIRDYC RCC_CIR_HSIRDYC /*!< HSI Ready Interrupt Clear */ #define LL_RCC_CIR_HSERDYC RCC_CIR_HSERDYC /*!< HSE Ready Interrupt Clear */ #define LL_RCC_CIR_PLLRDYC RCC_CIR_PLLRDYC /*!< PLL Ready Interrupt Clear */ #if defined(RCC_PLLI2S_SUPPORT) #define LL_RCC_CIR_PLLI2SRDYC RCC_CIR_PLLI2SRDYC /*!< PLLI2S Ready Interrupt Clear */ #endif /* RCC_PLLI2S_SUPPORT */ #if defined(RCC_PLLSAI_SUPPORT) #define LL_RCC_CIR_PLLSAIRDYC RCC_CIR_PLLSAIRDYC /*!< PLLSAI Ready Interrupt Clear */ #endif /* RCC_PLLSAI_SUPPORT */ #define LL_RCC_CIR_CSSC RCC_CIR_CSSC /*!< Clock Security System Interrupt Clear */ /** * @} */ /** @defgroup RCC_LL_EC_GET_FLAG Get Flags Defines * @brief Flags defines which can be used with LL_RCC_ReadReg function * @{ */ #define LL_RCC_CIR_LSIRDYF RCC_CIR_LSIRDYF /*!< LSI Ready Interrupt flag */ #define LL_RCC_CIR_LSERDYF RCC_CIR_LSERDYF /*!< LSE Ready Interrupt flag */ #define LL_RCC_CIR_HSIRDYF RCC_CIR_HSIRDYF /*!< HSI Ready Interrupt flag */ #define LL_RCC_CIR_HSERDYF RCC_CIR_HSERDYF /*!< HSE Ready Interrupt flag */ #define LL_RCC_CIR_PLLRDYF RCC_CIR_PLLRDYF /*!< PLL Ready Interrupt flag */ #if defined(RCC_PLLI2S_SUPPORT) #define LL_RCC_CIR_PLLI2SRDYF RCC_CIR_PLLI2SRDYF /*!< PLLI2S Ready Interrupt flag */ #endif /* RCC_PLLI2S_SUPPORT */ #if defined(RCC_PLLSAI_SUPPORT) #define LL_RCC_CIR_PLLSAIRDYF RCC_CIR_PLLSAIRDYF /*!< PLLSAI Ready Interrupt flag */ #endif /* RCC_PLLSAI_SUPPORT */ #define LL_RCC_CIR_CSSF RCC_CIR_CSSF /*!< Clock Security System Interrupt flag */ #define LL_RCC_CSR_LPWRRSTF RCC_CSR_LPWRRSTF /*!< Low-Power reset flag */ #define LL_RCC_CSR_PINRSTF RCC_CSR_PINRSTF /*!< PIN reset flag */ #define LL_RCC_CSR_PORRSTF RCC_CSR_PORRSTF /*!< POR/PDR reset flag */ #define LL_RCC_CSR_SFTRSTF RCC_CSR_SFTRSTF /*!< Software Reset flag */ #define LL_RCC_CSR_IWDGRSTF RCC_CSR_IWDGRSTF /*!< Independent Watchdog reset flag */ #define LL_RCC_CSR_WWDGRSTF RCC_CSR_WWDGRSTF /*!< Window watchdog reset flag */ #if defined(RCC_CSR_BORRSTF) #define LL_RCC_CSR_BORRSTF RCC_CSR_BORRSTF /*!< BOR reset flag */ #endif /* RCC_CSR_BORRSTF */ /** * @} */ /** @defgroup RCC_LL_EC_IT IT Defines * @brief IT defines which can be used with LL_RCC_ReadReg and LL_RCC_WriteReg functions * @{ */ #define LL_RCC_CIR_LSIRDYIE RCC_CIR_LSIRDYIE /*!< LSI Ready Interrupt Enable */ #define LL_RCC_CIR_LSERDYIE RCC_CIR_LSERDYIE /*!< LSE Ready Interrupt Enable */ #define LL_RCC_CIR_HSIRDYIE RCC_CIR_HSIRDYIE /*!< HSI Ready Interrupt Enable */ #define LL_RCC_CIR_HSERDYIE RCC_CIR_HSERDYIE /*!< HSE Ready Interrupt Enable */ #define LL_RCC_CIR_PLLRDYIE RCC_CIR_PLLRDYIE /*!< PLL Ready Interrupt Enable */ #if defined(RCC_PLLI2S_SUPPORT) #define LL_RCC_CIR_PLLI2SRDYIE RCC_CIR_PLLI2SRDYIE /*!< PLLI2S Ready Interrupt Enable */ #endif /* RCC_PLLI2S_SUPPORT */ #if defined(RCC_PLLSAI_SUPPORT) #define LL_RCC_CIR_PLLSAIRDYIE RCC_CIR_PLLSAIRDYIE /*!< PLLSAI Ready Interrupt Enable */ #endif /* RCC_PLLSAI_SUPPORT */ /** * @} */ /** @defgroup RCC_LL_EC_SYS_CLKSOURCE System clock switch * @{ */ #define LL_RCC_SYS_CLKSOURCE_HSI RCC_CFGR_SW_HSI /*!< HSI selection as system clock */ #define LL_RCC_SYS_CLKSOURCE_HSE RCC_CFGR_SW_HSE /*!< HSE selection as system clock */ #define LL_RCC_SYS_CLKSOURCE_PLL RCC_CFGR_SW_PLL /*!< PLL selection as system clock */ #if defined(RCC_CFGR_SW_PLLR) #define LL_RCC_SYS_CLKSOURCE_PLLR RCC_CFGR_SW_PLLR /*!< PLLR selection as system clock */ #endif /* RCC_CFGR_SW_PLLR */ /** * @} */ /** @defgroup RCC_LL_EC_SYS_CLKSOURCE_STATUS System clock switch status * @{ */ #define LL_RCC_SYS_CLKSOURCE_STATUS_HSI RCC_CFGR_SWS_HSI /*!< HSI used as system clock */ #define LL_RCC_SYS_CLKSOURCE_STATUS_HSE RCC_CFGR_SWS_HSE /*!< HSE used as system clock */ #define LL_RCC_SYS_CLKSOURCE_STATUS_PLL RCC_CFGR_SWS_PLL /*!< PLL used as system clock */ #if defined(RCC_PLLR_SYSCLK_SUPPORT) #define LL_RCC_SYS_CLKSOURCE_STATUS_PLLR RCC_CFGR_SWS_PLLR /*!< PLLR used as system clock */ #endif /* RCC_PLLR_SYSCLK_SUPPORT */ /** * @} */ /** @defgroup RCC_LL_EC_SYSCLK_DIV AHB prescaler * @{ */ #define LL_RCC_SYSCLK_DIV_1 RCC_CFGR_HPRE_DIV1 /*!< SYSCLK not divided */ #define LL_RCC_SYSCLK_DIV_2 RCC_CFGR_HPRE_DIV2 /*!< SYSCLK divided by 2 */ #define LL_RCC_SYSCLK_DIV_4 RCC_CFGR_HPRE_DIV4 /*!< SYSCLK divided by 4 */ #define LL_RCC_SYSCLK_DIV_8 RCC_CFGR_HPRE_DIV8 /*!< SYSCLK divided by 8 */ #define LL_RCC_SYSCLK_DIV_16 RCC_CFGR_HPRE_DIV16 /*!< SYSCLK divided by 16 */ #define LL_RCC_SYSCLK_DIV_64 RCC_CFGR_HPRE_DIV64 /*!< SYSCLK divided by 64 */ #define LL_RCC_SYSCLK_DIV_128 RCC_CFGR_HPRE_DIV128 /*!< SYSCLK divided by 128 */ #define LL_RCC_SYSCLK_DIV_256 RCC_CFGR_HPRE_DIV256 /*!< SYSCLK divided by 256 */ #define LL_RCC_SYSCLK_DIV_512 RCC_CFGR_HPRE_DIV512 /*!< SYSCLK divided by 512 */ /** * @} */ /** @defgroup RCC_LL_EC_APB1_DIV APB low-speed prescaler (APB1) * @{ */ #define LL_RCC_APB1_DIV_1 RCC_CFGR_PPRE1_DIV1 /*!< HCLK not divided */ #define LL_RCC_APB1_DIV_2 RCC_CFGR_PPRE1_DIV2 /*!< HCLK divided by 2 */ #define LL_RCC_APB1_DIV_4 RCC_CFGR_PPRE1_DIV4 /*!< HCLK divided by 4 */ #define LL_RCC_APB1_DIV_8 RCC_CFGR_PPRE1_DIV8 /*!< HCLK divided by 8 */ #define LL_RCC_APB1_DIV_16 RCC_CFGR_PPRE1_DIV16 /*!< HCLK divided by 16 */ /** * @} */ /** @defgroup RCC_LL_EC_APB2_DIV APB high-speed prescaler (APB2) * @{ */ #define LL_RCC_APB2_DIV_1 RCC_CFGR_PPRE2_DIV1 /*!< HCLK not divided */ #define LL_RCC_APB2_DIV_2 RCC_CFGR_PPRE2_DIV2 /*!< HCLK divided by 2 */ #define LL_RCC_APB2_DIV_4 RCC_CFGR_PPRE2_DIV4 /*!< HCLK divided by 4 */ #define LL_RCC_APB2_DIV_8 RCC_CFGR_PPRE2_DIV8 /*!< HCLK divided by 8 */ #define LL_RCC_APB2_DIV_16 RCC_CFGR_PPRE2_DIV16 /*!< HCLK divided by 16 */ /** * @} */ /** @defgroup RCC_LL_EC_MCOxSOURCE MCO source selection * @{ */ #define LL_RCC_MCO1SOURCE_HSI (uint32_t)(RCC_CFGR_MCO1|0x00000000U) /*!< HSI selection as MCO1 source */ #define LL_RCC_MCO1SOURCE_LSE (uint32_t)(RCC_CFGR_MCO1|(RCC_CFGR_MCO1_0 >> 16U)) /*!< LSE selection as MCO1 source */ #define LL_RCC_MCO1SOURCE_HSE (uint32_t)(RCC_CFGR_MCO1|(RCC_CFGR_MCO1_1 >> 16U)) /*!< HSE selection as MCO1 source */ #define LL_RCC_MCO1SOURCE_PLLCLK (uint32_t)(RCC_CFGR_MCO1|((RCC_CFGR_MCO1_1|RCC_CFGR_MCO1_0) >> 16U)) /*!< PLLCLK selection as MCO1 source */ #if defined(RCC_CFGR_MCO2) #define LL_RCC_MCO2SOURCE_SYSCLK (uint32_t)(RCC_CFGR_MCO2|0x00000000U) /*!< SYSCLK selection as MCO2 source */ #define LL_RCC_MCO2SOURCE_PLLI2S (uint32_t)(RCC_CFGR_MCO2|(RCC_CFGR_MCO2_0 >> 16U)) /*!< PLLI2S selection as MCO2 source */ #define LL_RCC_MCO2SOURCE_HSE (uint32_t)(RCC_CFGR_MCO2|(RCC_CFGR_MCO2_1 >> 16U)) /*!< HSE selection as MCO2 source */ #define LL_RCC_MCO2SOURCE_PLLCLK (uint32_t)(RCC_CFGR_MCO2|((RCC_CFGR_MCO2_1|RCC_CFGR_MCO2_0) >> 16U)) /*!< PLLCLK selection as MCO2 source */ #endif /* RCC_CFGR_MCO2 */ /** * @} */ /** @defgroup RCC_LL_EC_MCOx_DIV MCO prescaler * @{ */ #define LL_RCC_MCO1_DIV_1 (uint32_t)(RCC_CFGR_MCO1PRE|0x00000000U) /*!< MCO1 not divided */ #define LL_RCC_MCO1_DIV_2 (uint32_t)(RCC_CFGR_MCO1PRE|(RCC_CFGR_MCO1PRE_2 >> 16U)) /*!< MCO1 divided by 2 */ #define LL_RCC_MCO1_DIV_3 (uint32_t)(RCC_CFGR_MCO1PRE|((RCC_CFGR_MCO1PRE_2|RCC_CFGR_MCO1PRE_0) >> 16U)) /*!< MCO1 divided by 3 */ #define LL_RCC_MCO1_DIV_4 (uint32_t)(RCC_CFGR_MCO1PRE|((RCC_CFGR_MCO1PRE_2|RCC_CFGR_MCO1PRE_1) >> 16U)) /*!< MCO1 divided by 4 */ #define LL_RCC_MCO1_DIV_5 (uint32_t)(RCC_CFGR_MCO1PRE|(RCC_CFGR_MCO1PRE >> 16U)) /*!< MCO1 divided by 5 */ #if defined(RCC_CFGR_MCO2PRE) #define LL_RCC_MCO2_DIV_1 (uint32_t)(RCC_CFGR_MCO2PRE|0x00000000U) /*!< MCO2 not divided */ #define LL_RCC_MCO2_DIV_2 (uint32_t)(RCC_CFGR_MCO2PRE|(RCC_CFGR_MCO2PRE_2 >> 16U)) /*!< MCO2 divided by 2 */ #define LL_RCC_MCO2_DIV_3 (uint32_t)(RCC_CFGR_MCO2PRE|((RCC_CFGR_MCO2PRE_2|RCC_CFGR_MCO2PRE_0) >> 16U)) /*!< MCO2 divided by 3 */ #define LL_RCC_MCO2_DIV_4 (uint32_t)(RCC_CFGR_MCO2PRE|((RCC_CFGR_MCO2PRE_2|RCC_CFGR_MCO2PRE_1) >> 16U)) /*!< MCO2 divided by 4 */ #define LL_RCC_MCO2_DIV_5 (uint32_t)(RCC_CFGR_MCO2PRE|(RCC_CFGR_MCO2PRE >> 16U)) /*!< MCO2 divided by 5 */ #endif /* RCC_CFGR_MCO2PRE */ /** * @} */ /** @defgroup RCC_LL_EC_RTC_HSEDIV HSE prescaler for RTC clock * @{ */ #define LL_RCC_RTC_NOCLOCK 0x00000000U /*!< HSE not divided */ #define LL_RCC_RTC_HSE_DIV_2 RCC_CFGR_RTCPRE_1 /*!< HSE clock divided by 2 */ #define LL_RCC_RTC_HSE_DIV_3 (RCC_CFGR_RTCPRE_1|RCC_CFGR_RTCPRE_0) /*!< HSE clock divided by 3 */ #define LL_RCC_RTC_HSE_DIV_4 RCC_CFGR_RTCPRE_2 /*!< HSE clock divided by 4 */ #define LL_RCC_RTC_HSE_DIV_5 (RCC_CFGR_RTCPRE_2|RCC_CFGR_RTCPRE_0) /*!< HSE clock divided by 5 */ #define LL_RCC_RTC_HSE_DIV_6 (RCC_CFGR_RTCPRE_2|RCC_CFGR_RTCPRE_1) /*!< HSE clock divided by 6 */ #define LL_RCC_RTC_HSE_DIV_7 (RCC_CFGR_RTCPRE_2|RCC_CFGR_RTCPRE_1|RCC_CFGR_RTCPRE_0) /*!< HSE clock divided by 7 */ #define LL_RCC_RTC_HSE_DIV_8 RCC_CFGR_RTCPRE_3 /*!< HSE clock divided by 8 */ #define LL_RCC_RTC_HSE_DIV_9 (RCC_CFGR_RTCPRE_3|RCC_CFGR_RTCPRE_0) /*!< HSE clock divided by 9 */ #define LL_RCC_RTC_HSE_DIV_10 (RCC_CFGR_RTCPRE_3|RCC_CFGR_RTCPRE_1) /*!< HSE clock divided by 10 */ #define LL_RCC_RTC_HSE_DIV_11 (RCC_CFGR_RTCPRE_3|RCC_CFGR_RTCPRE_1|RCC_CFGR_RTCPRE_0) /*!< HSE clock divided by 11 */ #define LL_RCC_RTC_HSE_DIV_12 (RCC_CFGR_RTCPRE_3|RCC_CFGR_RTCPRE_2) /*!< HSE clock divided by 12 */ #define LL_RCC_RTC_HSE_DIV_13 (RCC_CFGR_RTCPRE_3|RCC_CFGR_RTCPRE_2|RCC_CFGR_RTCPRE_0) /*!< HSE clock divided by 13 */ #define LL_RCC_RTC_HSE_DIV_14 (RCC_CFGR_RTCPRE_3|RCC_CFGR_RTCPRE_2|RCC_CFGR_RTCPRE_1) /*!< HSE clock divided by 14 */ #define LL_RCC_RTC_HSE_DIV_15 (RCC_CFGR_RTCPRE_3|RCC_CFGR_RTCPRE_2|RCC_CFGR_RTCPRE_1|RCC_CFGR_RTCPRE_0) /*!< HSE clock divided by 15 */ #define LL_RCC_RTC_HSE_DIV_16 RCC_CFGR_RTCPRE_4 /*!< HSE clock divided by 16 */ #define LL_RCC_RTC_HSE_DIV_17 (RCC_CFGR_RTCPRE_4|RCC_CFGR_RTCPRE_0) /*!< HSE clock divided by 17 */ #define LL_RCC_RTC_HSE_DIV_18 (RCC_CFGR_RTCPRE_4|RCC_CFGR_RTCPRE_1) /*!< HSE clock divided by 18 */ #define LL_RCC_RTC_HSE_DIV_19 (RCC_CFGR_RTCPRE_4|RCC_CFGR_RTCPRE_1|RCC_CFGR_RTCPRE_0) /*!< HSE clock divided by 19 */ #define LL_RCC_RTC_HSE_DIV_20 (RCC_CFGR_RTCPRE_4|RCC_CFGR_RTCPRE_2) /*!< HSE clock divided by 20 */ #define LL_RCC_RTC_HSE_DIV_21 (RCC_CFGR_RTCPRE_4|RCC_CFGR_RTCPRE_2|RCC_CFGR_RTCPRE_0) /*!< HSE clock divided by 21 */ #define LL_RCC_RTC_HSE_DIV_22 (RCC_CFGR_RTCPRE_4|RCC_CFGR_RTCPRE_2|RCC_CFGR_RTCPRE_1) /*!< HSE clock divided by 22 */ #define LL_RCC_RTC_HSE_DIV_23 (RCC_CFGR_RTCPRE_4|RCC_CFGR_RTCPRE_2|RCC_CFGR_RTCPRE_1|RCC_CFGR_RTCPRE_0) /*!< HSE clock divided by 23 */ #define LL_RCC_RTC_HSE_DIV_24 (RCC_CFGR_RTCPRE_4|RCC_CFGR_RTCPRE_3) /*!< HSE clock divided by 24 */ #define LL_RCC_RTC_HSE_DIV_25 (RCC_CFGR_RTCPRE_4|RCC_CFGR_RTCPRE_3|RCC_CFGR_RTCPRE_0) /*!< HSE clock divided by 25 */ #define LL_RCC_RTC_HSE_DIV_26 (RCC_CFGR_RTCPRE_4|RCC_CFGR_RTCPRE_3|RCC_CFGR_RTCPRE_1) /*!< HSE clock divided by 26 */ #define LL_RCC_RTC_HSE_DIV_27 (RCC_CFGR_RTCPRE_4|RCC_CFGR_RTCPRE_3|RCC_CFGR_RTCPRE_1|RCC_CFGR_RTCPRE_0) /*!< HSE clock divided by 27 */ #define LL_RCC_RTC_HSE_DIV_28 (RCC_CFGR_RTCPRE_4|RCC_CFGR_RTCPRE_3|RCC_CFGR_RTCPRE_2) /*!< HSE clock divided by 28 */ #define LL_RCC_RTC_HSE_DIV_29 (RCC_CFGR_RTCPRE_4|RCC_CFGR_RTCPRE_3|RCC_CFGR_RTCPRE_2|RCC_CFGR_RTCPRE_0) /*!< HSE clock divided by 29 */ #define LL_RCC_RTC_HSE_DIV_30 (RCC_CFGR_RTCPRE_4|RCC_CFGR_RTCPRE_3|RCC_CFGR_RTCPRE_2|RCC_CFGR_RTCPRE_1) /*!< HSE clock divided by 30 */ #define LL_RCC_RTC_HSE_DIV_31 (RCC_CFGR_RTCPRE_4|RCC_CFGR_RTCPRE_3|RCC_CFGR_RTCPRE_2|RCC_CFGR_RTCPRE_1|RCC_CFGR_RTCPRE_0) /*!< HSE clock divided by 31 */ /** * @} */ #if defined(USE_FULL_LL_DRIVER) /** @defgroup RCC_LL_EC_PERIPH_FREQUENCY Peripheral clock frequency * @{ */ #define LL_RCC_PERIPH_FREQUENCY_NO 0x00000000U /*!< No clock enabled for the peripheral */ #define LL_RCC_PERIPH_FREQUENCY_NA 0xFFFFFFFFU /*!< Frequency cannot be provided as external clock */ /** * @} */ #endif /* USE_FULL_LL_DRIVER */ #if defined(FMPI2C1) /** @defgroup RCC_LL_EC_FMPI2C1_CLKSOURCE Peripheral FMPI2C clock source selection * @{ */ #define LL_RCC_FMPI2C1_CLKSOURCE_PCLK1 0x00000000U /*!< PCLK1 clock used as FMPI2C1 clock source */ #define LL_RCC_FMPI2C1_CLKSOURCE_SYSCLK RCC_DCKCFGR2_FMPI2C1SEL_0 /*!< SYSCLK clock used as FMPI2C1 clock source */ #define LL_RCC_FMPI2C1_CLKSOURCE_HSI RCC_DCKCFGR2_FMPI2C1SEL_1 /*!< HSI clock used as FMPI2C1 clock source */ /** * @} */ #endif /* FMPI2C1 */ #if defined(LPTIM1) /** @defgroup RCC_LL_EC_LPTIM1_CLKSOURCE Peripheral LPTIM clock source selection * @{ */ #define LL_RCC_LPTIM1_CLKSOURCE_PCLK1 0x00000000U /*!< PCLK1 clock used as LPTIM1 clock */ #define LL_RCC_LPTIM1_CLKSOURCE_HSI RCC_DCKCFGR2_LPTIM1SEL_0 /*!< LSI oscillator clock used as LPTIM1 clock */ #define LL_RCC_LPTIM1_CLKSOURCE_LSI RCC_DCKCFGR2_LPTIM1SEL_1 /*!< HSI oscillator clock used as LPTIM1 clock */ #define LL_RCC_LPTIM1_CLKSOURCE_LSE (uint32_t)(RCC_DCKCFGR2_LPTIM1SEL_1 | RCC_DCKCFGR2_LPTIM1SEL_0) /*!< LSE oscillator clock used as LPTIM1 clock */ /** * @} */ #endif /* LPTIM1 */ #if defined(SAI1) /** @defgroup RCC_LL_EC_SAIx_CLKSOURCE Peripheral SAI clock source selection * @{ */ #if defined(RCC_DCKCFGR_SAI1SRC) #define LL_RCC_SAI1_CLKSOURCE_PLLSAI (uint32_t)(RCC_DCKCFGR_SAI1SRC | 0x00000000U) /*!< PLLSAI clock used as SAI1 clock source */ #define LL_RCC_SAI1_CLKSOURCE_PLLI2S (uint32_t)(RCC_DCKCFGR_SAI1SRC | (RCC_DCKCFGR_SAI1SRC_0 >> 16)) /*!< PLLI2S clock used as SAI1 clock source */ #define LL_RCC_SAI1_CLKSOURCE_PLL (uint32_t)(RCC_DCKCFGR_SAI1SRC | (RCC_DCKCFGR_SAI1SRC_1 >> 16)) /*!< PLL clock used as SAI1 clock source */ #define LL_RCC_SAI1_CLKSOURCE_PIN (uint32_t)(RCC_DCKCFGR_SAI1SRC | (RCC_DCKCFGR_SAI1SRC >> 16)) /*!< External pin clock used as SAI1 clock source */ #endif /* RCC_DCKCFGR_SAI1SRC */ #if defined(RCC_DCKCFGR_SAI2SRC) #define LL_RCC_SAI2_CLKSOURCE_PLLSAI (uint32_t)(RCC_DCKCFGR_SAI2SRC | 0x00000000U) /*!< PLLSAI clock used as SAI2 clock source */ #define LL_RCC_SAI2_CLKSOURCE_PLLI2S (uint32_t)(RCC_DCKCFGR_SAI2SRC | (RCC_DCKCFGR_SAI2SRC_0 >> 16)) /*!< PLLI2S clock used as SAI2 clock source */ #define LL_RCC_SAI2_CLKSOURCE_PLL (uint32_t)(RCC_DCKCFGR_SAI2SRC | (RCC_DCKCFGR_SAI2SRC_1 >> 16)) /*!< PLL clock used as SAI2 clock source */ #define LL_RCC_SAI2_CLKSOURCE_PLLSRC (uint32_t)(RCC_DCKCFGR_SAI2SRC | (RCC_DCKCFGR_SAI2SRC >> 16)) /*!< PLL Main clock used as SAI2 clock source */ #endif /* RCC_DCKCFGR_SAI2SRC */ #if defined(RCC_DCKCFGR_SAI1ASRC) #if defined(RCC_SAI1A_PLLSOURCE_SUPPORT) #define LL_RCC_SAI1_A_CLKSOURCE_PLLI2S (uint32_t)(RCC_DCKCFGR_SAI1ASRC | 0x00000000U) /*!< PLLI2S clock used as SAI1 block A clock source */ #define LL_RCC_SAI1_A_CLKSOURCE_PIN (uint32_t)(RCC_DCKCFGR_SAI1ASRC | (RCC_DCKCFGR_SAI1ASRC_0 >> 16)) /*!< External pin used as SAI1 block A clock source */ #define LL_RCC_SAI1_A_CLKSOURCE_PLL (uint32_t)(RCC_DCKCFGR_SAI1ASRC | (RCC_DCKCFGR_SAI1ASRC_1 >> 16)) /*!< PLL clock used as SAI1 block A clock source */ #define LL_RCC_SAI1_A_CLKSOURCE_PLLSRC (uint32_t)(RCC_DCKCFGR_SAI1ASRC | (RCC_DCKCFGR_SAI1ASRC >> 16)) /*!< PLL Main clock used as SAI1 block A clock source */ #else #define LL_RCC_SAI1_A_CLKSOURCE_PLLSAI (uint32_t)(RCC_DCKCFGR_SAI1ASRC | 0x00000000U) /*!< PLLSAI clock used as SAI1 block A clock source */ #define LL_RCC_SAI1_A_CLKSOURCE_PLLI2S (uint32_t)(RCC_DCKCFGR_SAI1ASRC | (RCC_DCKCFGR_SAI1ASRC_0 >> 16)) /*!< PLLI2S clock used as SAI1 block A clock source */ #define LL_RCC_SAI1_A_CLKSOURCE_PIN (uint32_t)(RCC_DCKCFGR_SAI1ASRC | (RCC_DCKCFGR_SAI1ASRC_1 >> 16)) /*!< External pin clock used as SAI1 block A clock source */ #endif /* RCC_SAI1A_PLLSOURCE_SUPPORT */ #endif /* RCC_DCKCFGR_SAI1ASRC */ #if defined(RCC_DCKCFGR_SAI1BSRC) #if defined(RCC_SAI1B_PLLSOURCE_SUPPORT) #define LL_RCC_SAI1_B_CLKSOURCE_PLLI2S (uint32_t)(RCC_DCKCFGR_SAI1BSRC | 0x00000000U) /*!< PLLI2S clock used as SAI1 block B clock source */ #define LL_RCC_SAI1_B_CLKSOURCE_PIN (uint32_t)(RCC_DCKCFGR_SAI1BSRC | (RCC_DCKCFGR_SAI1BSRC_0 >> 16)) /*!< External pin used as SAI1 block B clock source */ #define LL_RCC_SAI1_B_CLKSOURCE_PLL (uint32_t)(RCC_DCKCFGR_SAI1BSRC | (RCC_DCKCFGR_SAI1BSRC_1 >> 16)) /*!< PLL clock used as SAI1 block B clock source */ #define LL_RCC_SAI1_B_CLKSOURCE_PLLSRC (uint32_t)(RCC_DCKCFGR_SAI1BSRC | (RCC_DCKCFGR_SAI1BSRC >> 16)) /*!< PLL Main clock used as SAI1 block B clock source */ #else #define LL_RCC_SAI1_B_CLKSOURCE_PLLSAI (uint32_t)(RCC_DCKCFGR_SAI1BSRC | 0x00000000U) /*!< PLLSAI clock used as SAI1 block B clock source */ #define LL_RCC_SAI1_B_CLKSOURCE_PLLI2S (uint32_t)(RCC_DCKCFGR_SAI1BSRC | (RCC_DCKCFGR_SAI1BSRC_0 >> 16)) /*!< PLLI2S clock used as SAI1 block B clock source */ #define LL_RCC_SAI1_B_CLKSOURCE_PIN (uint32_t)(RCC_DCKCFGR_SAI1BSRC | (RCC_DCKCFGR_SAI1BSRC_1 >> 16)) /*!< External pin clock used as SAI1 block B clock source */ #endif /* RCC_SAI1B_PLLSOURCE_SUPPORT */ #endif /* RCC_DCKCFGR_SAI1BSRC */ /** * @} */ #endif /* SAI1 */ #if defined(RCC_DCKCFGR_SDIOSEL) || defined(RCC_DCKCFGR2_SDIOSEL) /** @defgroup RCC_LL_EC_SDIOx_CLKSOURCE Peripheral SDIO clock source selection * @{ */ #define LL_RCC_SDIO_CLKSOURCE_PLL48CLK 0x00000000U /*!< PLL 48M domain clock used as SDIO clock */ #if defined(RCC_DCKCFGR_SDIOSEL) #define LL_RCC_SDIO_CLKSOURCE_SYSCLK RCC_DCKCFGR_SDIOSEL /*!< System clock clock used as SDIO clock */ #else #define LL_RCC_SDIO_CLKSOURCE_SYSCLK RCC_DCKCFGR2_SDIOSEL /*!< System clock clock used as SDIO clock */ #endif /* RCC_DCKCFGR_SDIOSEL */ /** * @} */ #endif /* RCC_DCKCFGR_SDIOSEL || RCC_DCKCFGR2_SDIOSEL */ #if defined(DSI) /** @defgroup RCC_LL_EC_DSI_CLKSOURCE Peripheral DSI clock source selection * @{ */ #define LL_RCC_DSI_CLKSOURCE_PHY 0x00000000U /*!< DSI-PHY clock used as DSI byte lane clock source */ #define LL_RCC_DSI_CLKSOURCE_PLL RCC_DCKCFGR_DSISEL /*!< PLL clock used as DSI byte lane clock source */ /** * @} */ #endif /* DSI */ #if defined(CEC) /** @defgroup RCC_LL_EC_CEC_CLKSOURCE Peripheral CEC clock source selection * @{ */ #define LL_RCC_CEC_CLKSOURCE_HSI_DIV488 0x00000000U /*!< HSI oscillator clock divided by 488 used as CEC clock */ #define LL_RCC_CEC_CLKSOURCE_LSE RCC_DCKCFGR2_CECSEL /*!< LSE oscillator clock used as CEC clock */ /** * @} */ #endif /* CEC */ /** @defgroup RCC_LL_EC_I2S1_CLKSOURCE Peripheral I2S clock source selection * @{ */ #if defined(RCC_CFGR_I2SSRC) #define LL_RCC_I2S1_CLKSOURCE_PLLI2S 0x00000000U /*!< I2S oscillator clock used as I2S1 clock */ #define LL_RCC_I2S1_CLKSOURCE_PIN RCC_CFGR_I2SSRC /*!< External pin clock used as I2S1 clock */ #endif /* RCC_CFGR_I2SSRC */ #if defined(RCC_DCKCFGR_I2SSRC) #define LL_RCC_I2S1_CLKSOURCE_PLL (uint32_t)(RCC_DCKCFGR_I2SSRC | 0x00000000U) /*!< PLL clock used as I2S1 clock source */ #define LL_RCC_I2S1_CLKSOURCE_PIN (uint32_t)(RCC_DCKCFGR_I2SSRC | (RCC_DCKCFGR_I2SSRC_0 >> 16)) /*!< External pin used as I2S1 clock source */ #define LL_RCC_I2S1_CLKSOURCE_PLLSRC (uint32_t)(RCC_DCKCFGR_I2SSRC | (RCC_DCKCFGR_I2SSRC_1 >> 16)) /*!< PLL Main clock used as I2S1 clock source */ #endif /* RCC_DCKCFGR_I2SSRC */ #if defined(RCC_DCKCFGR_I2S1SRC) #define LL_RCC_I2S1_CLKSOURCE_PLLI2S (uint32_t)(RCC_DCKCFGR_I2S1SRC | 0x00000000U) /*!< PLLI2S clock used as I2S1 clock source */ #define LL_RCC_I2S1_CLKSOURCE_PIN (uint32_t)(RCC_DCKCFGR_I2S1SRC | (RCC_DCKCFGR_I2S1SRC_0 >> 16)) /*!< External pin used as I2S1 clock source */ #define LL_RCC_I2S1_CLKSOURCE_PLL (uint32_t)(RCC_DCKCFGR_I2S1SRC | (RCC_DCKCFGR_I2S1SRC_1 >> 16)) /*!< PLL clock used as I2S1 clock source */ #define LL_RCC_I2S1_CLKSOURCE_PLLSRC (uint32_t)(RCC_DCKCFGR_I2S1SRC | (RCC_DCKCFGR_I2S1SRC >> 16)) /*!< PLL Main clock used as I2S1 clock source */ #endif /* RCC_DCKCFGR_I2S1SRC */ #if defined(RCC_DCKCFGR_I2S2SRC) #define LL_RCC_I2S2_CLKSOURCE_PLLI2S (uint32_t)(RCC_DCKCFGR_I2S2SRC | 0x00000000U) /*!< PLLI2S clock used as I2S2 clock source */ #define LL_RCC_I2S2_CLKSOURCE_PIN (uint32_t)(RCC_DCKCFGR_I2S2SRC | (RCC_DCKCFGR_I2S2SRC_0 >> 16)) /*!< External pin used as I2S2 clock source */ #define LL_RCC_I2S2_CLKSOURCE_PLL (uint32_t)(RCC_DCKCFGR_I2S2SRC | (RCC_DCKCFGR_I2S2SRC_1 >> 16)) /*!< PLL clock used as I2S2 clock source */ #define LL_RCC_I2S2_CLKSOURCE_PLLSRC (uint32_t)(RCC_DCKCFGR_I2S2SRC | (RCC_DCKCFGR_I2S2SRC >> 16)) /*!< PLL Main clock used as I2S2 clock source */ #endif /* RCC_DCKCFGR_I2S2SRC */ /** * @} */ #if defined(RCC_DCKCFGR_CK48MSEL) || defined(RCC_DCKCFGR2_CK48MSEL) /** @defgroup RCC_LL_EC_CK48M_CLKSOURCE Peripheral 48Mhz domain clock source selection * @{ */ #if defined(RCC_DCKCFGR_CK48MSEL) #define LL_RCC_CK48M_CLKSOURCE_PLL 0x00000000U /*!< PLL oscillator clock used as 48Mhz domain clock */ #define LL_RCC_CK48M_CLKSOURCE_PLLSAI RCC_DCKCFGR_CK48MSEL /*!< PLLSAI oscillator clock used as 48Mhz domain clock */ #endif /* RCC_DCKCFGR_CK48MSEL */ #if defined(RCC_DCKCFGR2_CK48MSEL) #define LL_RCC_CK48M_CLKSOURCE_PLL 0x00000000U /*!< PLL oscillator clock used as 48Mhz domain clock */ #if defined(RCC_PLLSAI_SUPPORT) #define LL_RCC_CK48M_CLKSOURCE_PLLSAI RCC_DCKCFGR2_CK48MSEL /*!< PLLSAI oscillator clock used as 48Mhz domain clock */ #endif /* RCC_PLLSAI_SUPPORT */ #if defined(RCC_PLLI2SCFGR_PLLI2SQ) && !defined(RCC_DCKCFGR_PLLI2SDIVQ) #define LL_RCC_CK48M_CLKSOURCE_PLLI2S RCC_DCKCFGR2_CK48MSEL /*!< PLLI2S oscillator clock used as 48Mhz domain clock */ #endif /* RCC_PLLI2SCFGR_PLLI2SQ && !RCC_DCKCFGR_PLLI2SDIVQ */ #endif /* RCC_DCKCFGR2_CK48MSEL */ /** * @} */ #if defined(RNG) /** @defgroup RCC_LL_EC_RNG_CLKSOURCE Peripheral RNG clock source selection * @{ */ #define LL_RCC_RNG_CLKSOURCE_PLL LL_RCC_CK48M_CLKSOURCE_PLL /*!< PLL clock used as RNG clock source */ #if defined(RCC_PLLSAI_SUPPORT) #define LL_RCC_RNG_CLKSOURCE_PLLSAI LL_RCC_CK48M_CLKSOURCE_PLLSAI /*!< PLLSAI clock used as RNG clock source */ #endif /* RCC_PLLSAI_SUPPORT */ #if defined(RCC_PLLI2SCFGR_PLLI2SQ) && !defined(RCC_DCKCFGR_PLLI2SDIVQ) #define LL_RCC_RNG_CLKSOURCE_PLLI2S LL_RCC_CK48M_CLKSOURCE_PLLI2S /*!< PLLI2S clock used as RNG clock source */ #endif /* RCC_PLLI2SCFGR_PLLI2SQ && !RCC_DCKCFGR_PLLI2SDIVQ */ /** * @} */ #endif /* RNG */ #if defined(USB_OTG_FS) || defined(USB_OTG_HS) /** @defgroup RCC_LL_EC_USB_CLKSOURCE Peripheral USB clock source selection * @{ */ #define LL_RCC_USB_CLKSOURCE_PLL LL_RCC_CK48M_CLKSOURCE_PLL /*!< PLL clock used as USB clock source */ #if defined(RCC_PLLSAI_SUPPORT) #define LL_RCC_USB_CLKSOURCE_PLLSAI LL_RCC_CK48M_CLKSOURCE_PLLSAI /*!< PLLSAI clock used as USB clock source */ #endif /* RCC_PLLSAI_SUPPORT */ #if defined(RCC_PLLI2SCFGR_PLLI2SQ) && !defined(RCC_DCKCFGR_PLLI2SDIVQ) #define LL_RCC_USB_CLKSOURCE_PLLI2S LL_RCC_CK48M_CLKSOURCE_PLLI2S /*!< PLLI2S clock used as USB clock source */ #endif /* RCC_PLLI2SCFGR_PLLI2SQ && !RCC_DCKCFGR_PLLI2SDIVQ */ /** * @} */ #endif /* USB_OTG_FS || USB_OTG_HS */ #endif /* RCC_DCKCFGR_CK48MSEL || RCC_DCKCFGR2_CK48MSEL */ #if defined(DFSDM1_Channel0) || defined(DFSDM2_Channel0) /** @defgroup RCC_LL_EC_DFSDM1_AUDIO_CLKSOURCE Peripheral DFSDM Audio clock source selection * @{ */ #define LL_RCC_DFSDM1_AUDIO_CLKSOURCE_I2S1 (uint32_t)(RCC_DCKCFGR_CKDFSDM1ASEL | 0x00000000U) /*!< I2S1 clock used as DFSDM1 Audio clock source */ #define LL_RCC_DFSDM1_AUDIO_CLKSOURCE_I2S2 (uint32_t)(RCC_DCKCFGR_CKDFSDM1ASEL | (RCC_DCKCFGR_CKDFSDM1ASEL << 16)) /*!< I2S2 clock used as DFSDM1 Audio clock source */ #if defined(DFSDM2_Channel0) #define LL_RCC_DFSDM2_AUDIO_CLKSOURCE_I2S1 (uint32_t)(RCC_DCKCFGR_CKDFSDM2ASEL | 0x00000000U) /*!< I2S1 clock used as DFSDM2 Audio clock source */ #define LL_RCC_DFSDM2_AUDIO_CLKSOURCE_I2S2 (uint32_t)(RCC_DCKCFGR_CKDFSDM2ASEL | (RCC_DCKCFGR_CKDFSDM2ASEL << 16)) /*!< I2S2 clock used as DFSDM2 Audio clock source */ #endif /* DFSDM2_Channel0 */ /** * @} */ /** @defgroup RCC_LL_EC_DFSDM1_CLKSOURCE Peripheral DFSDM clock source selection * @{ */ #define LL_RCC_DFSDM1_CLKSOURCE_PCLK2 0x00000000U /*!< PCLK2 clock used as DFSDM1 clock */ #define LL_RCC_DFSDM1_CLKSOURCE_SYSCLK RCC_DCKCFGR_CKDFSDM1SEL /*!< System clock used as DFSDM1 clock */ #if defined(DFSDM2_Channel0) #define LL_RCC_DFSDM2_CLKSOURCE_PCLK2 0x00000000U /*!< PCLK2 clock used as DFSDM2 clock */ #define LL_RCC_DFSDM2_CLKSOURCE_SYSCLK RCC_DCKCFGR_CKDFSDM1SEL /*!< System clock used as DFSDM2 clock */ #endif /* DFSDM2_Channel0 */ /** * @} */ #endif /* DFSDM1_Channel0 || DFSDM2_Channel0 */ #if defined(FMPI2C1) /** @defgroup RCC_LL_EC_FMPI2C1 Peripheral FMPI2C get clock source * @{ */ #define LL_RCC_FMPI2C1_CLKSOURCE RCC_DCKCFGR2_FMPI2C1SEL /*!< FMPI2C1 Clock source selection */ /** * @} */ #endif /* FMPI2C1 */ #if defined(SPDIFRX) /** @defgroup RCC_LL_EC_SPDIFRX_CLKSOURCE Peripheral SPDIFRX clock source selection * @{ */ #define LL_RCC_SPDIFRX1_CLKSOURCE_PLL 0x00000000U /*!< PLL clock used as SPDIFRX clock source */ #define LL_RCC_SPDIFRX1_CLKSOURCE_PLLI2S RCC_DCKCFGR2_SPDIFRXSEL /*!< PLLI2S clock used as SPDIFRX clock source */ /** * @} */ #endif /* SPDIFRX */ #if defined(LPTIM1) /** @defgroup RCC_LL_EC_LPTIM1 Peripheral LPTIM get clock source * @{ */ #define LL_RCC_LPTIM1_CLKSOURCE RCC_DCKCFGR2_LPTIM1SEL /*!< LPTIM1 Clock source selection */ /** * @} */ #endif /* LPTIM1 */ #if defined(SAI1) /** @defgroup RCC_LL_EC_SAIx Peripheral SAI get clock source * @{ */ #if defined(RCC_DCKCFGR_SAI1ASRC) #define LL_RCC_SAI1_A_CLKSOURCE RCC_DCKCFGR_SAI1ASRC /*!< SAI1 block A Clock source selection */ #endif /* RCC_DCKCFGR_SAI1ASRC */ #if defined(RCC_DCKCFGR_SAI1BSRC) #define LL_RCC_SAI1_B_CLKSOURCE RCC_DCKCFGR_SAI1BSRC /*!< SAI1 block B Clock source selection */ #endif /* RCC_DCKCFGR_SAI1BSRC */ #if defined(RCC_DCKCFGR_SAI1SRC) #define LL_RCC_SAI1_CLKSOURCE RCC_DCKCFGR_SAI1SRC /*!< SAI1 Clock source selection */ #endif /* RCC_DCKCFGR_SAI1SRC */ #if defined(RCC_DCKCFGR_SAI2SRC) #define LL_RCC_SAI2_CLKSOURCE RCC_DCKCFGR_SAI2SRC /*!< SAI2 Clock source selection */ #endif /* RCC_DCKCFGR_SAI2SRC */ /** * @} */ #endif /* SAI1 */ #if defined(SDIO) /** @defgroup RCC_LL_EC_SDIOx Peripheral SDIO get clock source * @{ */ #if defined(RCC_DCKCFGR_SDIOSEL) #define LL_RCC_SDIO_CLKSOURCE RCC_DCKCFGR_SDIOSEL /*!< SDIO Clock source selection */ #elif defined(RCC_DCKCFGR2_SDIOSEL) #define LL_RCC_SDIO_CLKSOURCE RCC_DCKCFGR2_SDIOSEL /*!< SDIO Clock source selection */ #else #define LL_RCC_SDIO_CLKSOURCE RCC_PLLCFGR_PLLQ /*!< SDIO Clock source selection */ #endif /** * @} */ #endif /* SDIO */ #if defined(RCC_DCKCFGR_CK48MSEL) || defined(RCC_DCKCFGR2_CK48MSEL) /** @defgroup RCC_LL_EC_CK48M Peripheral CK48M get clock source * @{ */ #if defined(RCC_DCKCFGR_CK48MSEL) #define LL_RCC_CK48M_CLKSOURCE RCC_DCKCFGR_CK48MSEL /*!< CK48M Domain clock source selection */ #endif /* RCC_DCKCFGR_CK48MSEL */ #if defined(RCC_DCKCFGR2_CK48MSEL) #define LL_RCC_CK48M_CLKSOURCE RCC_DCKCFGR2_CK48MSEL /*!< CK48M Domain clock source selection */ #endif /* RCC_DCKCFGR_CK48MSEL */ /** * @} */ #endif /* RCC_DCKCFGR_CK48MSEL || RCC_DCKCFGR2_CK48MSEL */ #if defined(RNG) /** @defgroup RCC_LL_EC_RNG Peripheral RNG get clock source * @{ */ #if defined(RCC_DCKCFGR_CK48MSEL) || defined(RCC_DCKCFGR2_CK48MSEL) #define LL_RCC_RNG_CLKSOURCE LL_RCC_CK48M_CLKSOURCE /*!< RNG Clock source selection */ #else #define LL_RCC_RNG_CLKSOURCE RCC_PLLCFGR_PLLQ /*!< RNG Clock source selection */ #endif /* RCC_DCKCFGR_CK48MSEL || RCC_DCKCFGR2_CK48MSEL */ /** * @} */ #endif /* RNG */ #if defined(USB_OTG_FS) || defined(USB_OTG_HS) /** @defgroup RCC_LL_EC_USB Peripheral USB get clock source * @{ */ #if defined(RCC_DCKCFGR_CK48MSEL) || defined(RCC_DCKCFGR2_CK48MSEL) #define LL_RCC_USB_CLKSOURCE LL_RCC_CK48M_CLKSOURCE /*!< USB Clock source selection */ #else #define LL_RCC_USB_CLKSOURCE RCC_PLLCFGR_PLLQ /*!< USB Clock source selection */ #endif /* RCC_DCKCFGR_CK48MSEL || RCC_DCKCFGR2_CK48MSEL */ /** * @} */ #endif /* USB_OTG_FS || USB_OTG_HS */ #if defined(CEC) /** @defgroup RCC_LL_EC_CEC Peripheral CEC get clock source * @{ */ #define LL_RCC_CEC_CLKSOURCE RCC_DCKCFGR2_CECSEL /*!< CEC Clock source selection */ /** * @} */ #endif /* CEC */ /** @defgroup RCC_LL_EC_I2S1 Peripheral I2S get clock source * @{ */ #if defined(RCC_CFGR_I2SSRC) #define LL_RCC_I2S1_CLKSOURCE RCC_CFGR_I2SSRC /*!< I2S1 Clock source selection */ #endif /* RCC_CFGR_I2SSRC */ #if defined(RCC_DCKCFGR_I2SSRC) #define LL_RCC_I2S1_CLKSOURCE RCC_DCKCFGR_I2SSRC /*!< I2S1 Clock source selection */ #endif /* RCC_DCKCFGR_I2SSRC */ #if defined(RCC_DCKCFGR_I2S1SRC) #define LL_RCC_I2S1_CLKSOURCE RCC_DCKCFGR_I2S1SRC /*!< I2S1 Clock source selection */ #endif /* RCC_DCKCFGR_I2S1SRC */ #if defined(RCC_DCKCFGR_I2S2SRC) #define LL_RCC_I2S2_CLKSOURCE RCC_DCKCFGR_I2S2SRC /*!< I2S2 Clock source selection */ #endif /* RCC_DCKCFGR_I2S2SRC */ /** * @} */ #if defined(DFSDM1_Channel0) || defined(DFSDM2_Channel0) /** @defgroup RCC_LL_EC_DFSDM_AUDIO Peripheral DFSDM Audio get clock source * @{ */ #define LL_RCC_DFSDM1_AUDIO_CLKSOURCE RCC_DCKCFGR_CKDFSDM1ASEL /*!< DFSDM1 Audio Clock source selection */ #if defined(DFSDM2_Channel0) #define LL_RCC_DFSDM2_AUDIO_CLKSOURCE RCC_DCKCFGR_CKDFSDM2ASEL /*!< DFSDM2 Audio Clock source selection */ #endif /* DFSDM2_Channel0 */ /** * @} */ /** @defgroup RCC_LL_EC_DFSDM Peripheral DFSDM get clock source * @{ */ #define LL_RCC_DFSDM1_CLKSOURCE RCC_DCKCFGR_CKDFSDM1SEL /*!< DFSDM1 Clock source selection */ #if defined(DFSDM2_Channel0) #define LL_RCC_DFSDM2_CLKSOURCE RCC_DCKCFGR_CKDFSDM1SEL /*!< DFSDM2 Clock source selection */ #endif /* DFSDM2_Channel0 */ /** * @} */ #endif /* DFSDM1_Channel0 || DFSDM2_Channel0 */ #if defined(SPDIFRX) /** @defgroup RCC_LL_EC_SPDIFRX Peripheral SPDIFRX get clock source * @{ */ #define LL_RCC_SPDIFRX1_CLKSOURCE RCC_DCKCFGR2_SPDIFRXSEL /*!< SPDIFRX Clock source selection */ /** * @} */ #endif /* SPDIFRX */ #if defined(DSI) /** @defgroup RCC_LL_EC_DSI Peripheral DSI get clock source * @{ */ #define LL_RCC_DSI_CLKSOURCE RCC_DCKCFGR_DSISEL /*!< DSI Clock source selection */ /** * @} */ #endif /* DSI */ #if defined(LTDC) /** @defgroup RCC_LL_EC_LTDC Peripheral LTDC get clock source * @{ */ #define LL_RCC_LTDC_CLKSOURCE RCC_DCKCFGR_PLLSAIDIVR /*!< LTDC Clock source selection */ /** * @} */ #endif /* LTDC */ /** @defgroup RCC_LL_EC_RTC_CLKSOURCE RTC clock source selection * @{ */ #define LL_RCC_RTC_CLKSOURCE_NONE 0x00000000U /*!< No clock used as RTC clock */ #define LL_RCC_RTC_CLKSOURCE_LSE RCC_BDCR_RTCSEL_0 /*!< LSE oscillator clock used as RTC clock */ #define LL_RCC_RTC_CLKSOURCE_LSI RCC_BDCR_RTCSEL_1 /*!< LSI oscillator clock used as RTC clock */ #define LL_RCC_RTC_CLKSOURCE_HSE RCC_BDCR_RTCSEL /*!< HSE oscillator clock divided by HSE prescaler used as RTC clock */ /** * @} */ #if defined(RCC_DCKCFGR_TIMPRE) /** @defgroup RCC_LL_EC_TIM_CLKPRESCALER Timers clocks prescalers selection * @{ */ #define LL_RCC_TIM_PRESCALER_TWICE 0x00000000U /*!< Timers clock to twice PCLK */ #define LL_RCC_TIM_PRESCALER_FOUR_TIMES RCC_DCKCFGR_TIMPRE /*!< Timers clock to four time PCLK */ /** * @} */ #endif /* RCC_DCKCFGR_TIMPRE */ /** @defgroup RCC_LL_EC_PLLSOURCE PLL, PLLI2S and PLLSAI entry clock source * @{ */ #define LL_RCC_PLLSOURCE_HSI RCC_PLLCFGR_PLLSRC_HSI /*!< HSI16 clock selected as PLL entry clock source */ #define LL_RCC_PLLSOURCE_HSE RCC_PLLCFGR_PLLSRC_HSE /*!< HSE clock selected as PLL entry clock source */ #if defined(RCC_PLLI2SCFGR_PLLI2SSRC) #define LL_RCC_PLLI2SSOURCE_PIN (RCC_PLLI2SCFGR_PLLI2SSRC | 0x80U) /*!< I2S External pin input clock selected as PLLI2S entry clock source */ #endif /* RCC_PLLI2SCFGR_PLLI2SSRC */ /** * @} */ /** @defgroup RCC_LL_EC_PLLM_DIV PLL, PLLI2S and PLLSAI division factor * @{ */ #define LL_RCC_PLLM_DIV_2 (RCC_PLLCFGR_PLLM_1) /*!< PLL, PLLI2S and PLLSAI division factor by 2 */ #define LL_RCC_PLLM_DIV_3 (RCC_PLLCFGR_PLLM_1 | RCC_PLLCFGR_PLLM_0) /*!< PLL, PLLI2S and PLLSAI division factor by 3 */ #define LL_RCC_PLLM_DIV_4 (RCC_PLLCFGR_PLLM_2) /*!< PLL, PLLI2S and PLLSAI division factor by 4 */ #define LL_RCC_PLLM_DIV_5 (RCC_PLLCFGR_PLLM_2 | RCC_PLLCFGR_PLLM_0) /*!< PLL, PLLI2S and PLLSAI division factor by 5 */ #define LL_RCC_PLLM_DIV_6 (RCC_PLLCFGR_PLLM_2 | RCC_PLLCFGR_PLLM_1) /*!< PLL, PLLI2S and PLLSAI division factor by 6 */ #define LL_RCC_PLLM_DIV_7 (RCC_PLLCFGR_PLLM_2 | RCC_PLLCFGR_PLLM_1 | RCC_PLLCFGR_PLLM_0) /*!< PLL, PLLI2S and PLLSAI division factor by 7 */ #define LL_RCC_PLLM_DIV_8 (RCC_PLLCFGR_PLLM_3) /*!< PLL, PLLI2S and PLLSAI division factor by 8 */ #define LL_RCC_PLLM_DIV_9 (RCC_PLLCFGR_PLLM_3 | RCC_PLLCFGR_PLLM_0) /*!< PLL, PLLI2S and PLLSAI division factor by 9 */ #define LL_RCC_PLLM_DIV_10 (RCC_PLLCFGR_PLLM_3 | RCC_PLLCFGR_PLLM_1) /*!< PLL, PLLI2S and PLLSAI division factor by 10 */ #define LL_RCC_PLLM_DIV_11 (RCC_PLLCFGR_PLLM_3 | RCC_PLLCFGR_PLLM_1 | RCC_PLLCFGR_PLLM_0) /*!< PLL, PLLI2S and PLLSAI division factor by 11 */ #define LL_RCC_PLLM_DIV_12 (RCC_PLLCFGR_PLLM_3 | RCC_PLLCFGR_PLLM_2) /*!< PLL, PLLI2S and PLLSAI division factor by 12 */ #define LL_RCC_PLLM_DIV_13 (RCC_PLLCFGR_PLLM_3 | RCC_PLLCFGR_PLLM_2 | RCC_PLLCFGR_PLLM_0) /*!< PLL, PLLI2S and PLLSAI division factor by 13 */ #define LL_RCC_PLLM_DIV_14 (RCC_PLLCFGR_PLLM_3 | RCC_PLLCFGR_PLLM_2 | RCC_PLLCFGR_PLLM_1) /*!< PLL, PLLI2S and PLLSAI division factor by 14 */ #define LL_RCC_PLLM_DIV_15 (RCC_PLLCFGR_PLLM_3 | RCC_PLLCFGR_PLLM_2 | RCC_PLLCFGR_PLLM_1 | RCC_PLLCFGR_PLLM_0) /*!< PLL, PLLI2S and PLLSAI division factor by 15 */ #define LL_RCC_PLLM_DIV_16 (RCC_PLLCFGR_PLLM_4) /*!< PLL, PLLI2S and PLLSAI division factor by 16 */ #define LL_RCC_PLLM_DIV_17 (RCC_PLLCFGR_PLLM_4 | RCC_PLLCFGR_PLLM_0) /*!< PLL, PLLI2S and PLLSAI division factor by 17 */ #define LL_RCC_PLLM_DIV_18 (RCC_PLLCFGR_PLLM_4 | RCC_PLLCFGR_PLLM_1) /*!< PLL, PLLI2S and PLLSAI division factor by 18 */ #define LL_RCC_PLLM_DIV_19 (RCC_PLLCFGR_PLLM_4 | RCC_PLLCFGR_PLLM_1 | RCC_PLLCFGR_PLLM_0) /*!< PLL, PLLI2S and PLLSAI division factor by 19 */ #define LL_RCC_PLLM_DIV_20 (RCC_PLLCFGR_PLLM_4 | RCC_PLLCFGR_PLLM_2) /*!< PLL, PLLI2S and PLLSAI division factor by 20 */ #define LL_RCC_PLLM_DIV_21 (RCC_PLLCFGR_PLLM_4 | RCC_PLLCFGR_PLLM_2 | RCC_PLLCFGR_PLLM_0) /*!< PLL, PLLI2S and PLLSAI division factor by 21 */ #define LL_RCC_PLLM_DIV_22 (RCC_PLLCFGR_PLLM_4 | RCC_PLLCFGR_PLLM_2 | RCC_PLLCFGR_PLLM_1) /*!< PLL, PLLI2S and PLLSAI division factor by 22 */ #define LL_RCC_PLLM_DIV_23 (RCC_PLLCFGR_PLLM_4 | RCC_PLLCFGR_PLLM_2 | RCC_PLLCFGR_PLLM_1 | RCC_PLLCFGR_PLLM_0) /*!< PLL, PLLI2S and PLLSAI division factor by 23 */ #define LL_RCC_PLLM_DIV_24 (RCC_PLLCFGR_PLLM_4 | RCC_PLLCFGR_PLLM_3) /*!< PLL, PLLI2S and PLLSAI division factor by 24 */ #define LL_RCC_PLLM_DIV_25 (RCC_PLLCFGR_PLLM_4 | RCC_PLLCFGR_PLLM_3 | RCC_PLLCFGR_PLLM_0) /*!< PLL, PLLI2S and PLLSAI division factor by 25 */ #define LL_RCC_PLLM_DIV_26 (RCC_PLLCFGR_PLLM_4 | RCC_PLLCFGR_PLLM_3 | RCC_PLLCFGR_PLLM_1) /*!< PLL, PLLI2S and PLLSAI division factor by 26 */ #define LL_RCC_PLLM_DIV_27 (RCC_PLLCFGR_PLLM_4 | RCC_PLLCFGR_PLLM_3 | RCC_PLLCFGR_PLLM_1 | RCC_PLLCFGR_PLLM_0) /*!< PLL, PLLI2S and PLLSAI division factor by 27 */ #define LL_RCC_PLLM_DIV_28 (RCC_PLLCFGR_PLLM_4 | RCC_PLLCFGR_PLLM_3 | RCC_PLLCFGR_PLLM_2) /*!< PLL, PLLI2S and PLLSAI division factor by 28 */ #define LL_RCC_PLLM_DIV_29 (RCC_PLLCFGR_PLLM_4 | RCC_PLLCFGR_PLLM_3 | RCC_PLLCFGR_PLLM_2 | RCC_PLLCFGR_PLLM_0) /*!< PLL, PLLI2S and PLLSAI division factor by 29 */ #define LL_RCC_PLLM_DIV_30 (RCC_PLLCFGR_PLLM_4 | RCC_PLLCFGR_PLLM_3 | RCC_PLLCFGR_PLLM_2 | RCC_PLLCFGR_PLLM_1) /*!< PLL, PLLI2S and PLLSAI division factor by 30 */ #define LL_RCC_PLLM_DIV_31 (RCC_PLLCFGR_PLLM_4 | RCC_PLLCFGR_PLLM_3 | RCC_PLLCFGR_PLLM_2 | RCC_PLLCFGR_PLLM_1 | RCC_PLLCFGR_PLLM_0) /*!< PLL, PLLI2S and PLLSAI division factor by 31 */ #define LL_RCC_PLLM_DIV_32 (RCC_PLLCFGR_PLLM_5) /*!< PLL, PLLI2S and PLLSAI division factor by 32 */ #define LL_RCC_PLLM_DIV_33 (RCC_PLLCFGR_PLLM_5 | RCC_PLLCFGR_PLLM_0) /*!< PLL, PLLI2S and PLLSAI division factor by 33 */ #define LL_RCC_PLLM_DIV_34 (RCC_PLLCFGR_PLLM_5 | RCC_PLLCFGR_PLLM_1) /*!< PLL, PLLI2S and PLLSAI division factor by 34 */ #define LL_RCC_PLLM_DIV_35 (RCC_PLLCFGR_PLLM_5 | RCC_PLLCFGR_PLLM_1 | RCC_PLLCFGR_PLLM_0) /*!< PLL, PLLI2S and PLLSAI division factor by 35 */ #define LL_RCC_PLLM_DIV_36 (RCC_PLLCFGR_PLLM_5 | RCC_PLLCFGR_PLLM_2) /*!< PLL, PLLI2S and PLLSAI division factor by 36 */ #define LL_RCC_PLLM_DIV_37 (RCC_PLLCFGR_PLLM_5 | RCC_PLLCFGR_PLLM_2 | RCC_PLLCFGR_PLLM_0) /*!< PLL, PLLI2S and PLLSAI division factor by 37 */ #define LL_RCC_PLLM_DIV_38 (RCC_PLLCFGR_PLLM_5 | RCC_PLLCFGR_PLLM_2 | RCC_PLLCFGR_PLLM_1) /*!< PLL, PLLI2S and PLLSAI division factor by 38 */ #define LL_RCC_PLLM_DIV_39 (RCC_PLLCFGR_PLLM_5 | RCC_PLLCFGR_PLLM_2 | RCC_PLLCFGR_PLLM_1 | RCC_PLLCFGR_PLLM_0) /*!< PLL, PLLI2S and PLLSAI division factor by 39 */ #define LL_RCC_PLLM_DIV_40 (RCC_PLLCFGR_PLLM_5 | RCC_PLLCFGR_PLLM_3) /*!< PLL, PLLI2S and PLLSAI division factor by 40 */ #define LL_RCC_PLLM_DIV_41 (RCC_PLLCFGR_PLLM_5 | RCC_PLLCFGR_PLLM_3 | RCC_PLLCFGR_PLLM_0) /*!< PLL, PLLI2S and PLLSAI division factor by 41 */ #define LL_RCC_PLLM_DIV_42 (RCC_PLLCFGR_PLLM_5 | RCC_PLLCFGR_PLLM_3 | RCC_PLLCFGR_PLLM_1) /*!< PLL, PLLI2S and PLLSAI division factor by 42 */ #define LL_RCC_PLLM_DIV_43 (RCC_PLLCFGR_PLLM_5 | RCC_PLLCFGR_PLLM_3 | RCC_PLLCFGR_PLLM_1 | RCC_PLLCFGR_PLLM_0) /*!< PLL, PLLI2S and PLLSAI division factor by 43 */ #define LL_RCC_PLLM_DIV_44 (RCC_PLLCFGR_PLLM_5 | RCC_PLLCFGR_PLLM_3 | RCC_PLLCFGR_PLLM_2) /*!< PLL, PLLI2S and PLLSAI division factor by 44 */ #define LL_RCC_PLLM_DIV_45 (RCC_PLLCFGR_PLLM_5 | RCC_PLLCFGR_PLLM_3 | RCC_PLLCFGR_PLLM_2 | RCC_PLLCFGR_PLLM_0) /*!< PLL, PLLI2S and PLLSAI division factor by 45 */ #define LL_RCC_PLLM_DIV_46 (RCC_PLLCFGR_PLLM_5 | RCC_PLLCFGR_PLLM_3 | RCC_PLLCFGR_PLLM_2 | RCC_PLLCFGR_PLLM_1) /*!< PLL, PLLI2S and PLLSAI division factor by 46 */ #define LL_RCC_PLLM_DIV_47 (RCC_PLLCFGR_PLLM_5 | RCC_PLLCFGR_PLLM_3 | RCC_PLLCFGR_PLLM_2 | RCC_PLLCFGR_PLLM_1 | RCC_PLLCFGR_PLLM_0) /*!< PLL, PLLI2S and PLLSAI division factor by 47 */ #define LL_RCC_PLLM_DIV_48 (RCC_PLLCFGR_PLLM_5 | RCC_PLLCFGR_PLLM_4) /*!< PLL, PLLI2S and PLLSAI division factor by 48 */ #define LL_RCC_PLLM_DIV_49 (RCC_PLLCFGR_PLLM_5 | RCC_PLLCFGR_PLLM_4 | RCC_PLLCFGR_PLLM_0) /*!< PLL, PLLI2S and PLLSAI division factor by 49 */ #define LL_RCC_PLLM_DIV_50 (RCC_PLLCFGR_PLLM_5 | RCC_PLLCFGR_PLLM_4 | RCC_PLLCFGR_PLLM_1) /*!< PLL, PLLI2S and PLLSAI division factor by 50 */ #define LL_RCC_PLLM_DIV_51 (RCC_PLLCFGR_PLLM_5 | RCC_PLLCFGR_PLLM_4 | RCC_PLLCFGR_PLLM_1 | RCC_PLLCFGR_PLLM_0) /*!< PLL, PLLI2S and PLLSAI division factor by 51 */ #define LL_RCC_PLLM_DIV_52 (RCC_PLLCFGR_PLLM_5 | RCC_PLLCFGR_PLLM_4 | RCC_PLLCFGR_PLLM_2) /*!< PLL, PLLI2S and PLLSAI division factor by 52 */ #define LL_RCC_PLLM_DIV_53 (RCC_PLLCFGR_PLLM_5 | RCC_PLLCFGR_PLLM_4 | RCC_PLLCFGR_PLLM_2 | RCC_PLLCFGR_PLLM_0) /*!< PLL, PLLI2S and PLLSAI division factor by 53 */ #define LL_RCC_PLLM_DIV_54 (RCC_PLLCFGR_PLLM_5 | RCC_PLLCFGR_PLLM_4 | RCC_PLLCFGR_PLLM_2 | RCC_PLLCFGR_PLLM_1) /*!< PLL, PLLI2S and PLLSAI division factor by 54 */ #define LL_RCC_PLLM_DIV_55 (RCC_PLLCFGR_PLLM_5 | RCC_PLLCFGR_PLLM_4 | RCC_PLLCFGR_PLLM_2 | RCC_PLLCFGR_PLLM_1 | RCC_PLLCFGR_PLLM_0) /*!< PLL, PLLI2S and PLLSAI division factor by 55 */ #define LL_RCC_PLLM_DIV_56 (RCC_PLLCFGR_PLLM_5 | RCC_PLLCFGR_PLLM_4 | RCC_PLLCFGR_PLLM_3) /*!< PLL, PLLI2S and PLLSAI division factor by 56 */ #define LL_RCC_PLLM_DIV_57 (RCC_PLLCFGR_PLLM_5 | RCC_PLLCFGR_PLLM_4 | RCC_PLLCFGR_PLLM_3 | RCC_PLLCFGR_PLLM_0) /*!< PLL, PLLI2S and PLLSAI division factor by 57 */ #define LL_RCC_PLLM_DIV_58 (RCC_PLLCFGR_PLLM_5 | RCC_PLLCFGR_PLLM_4 | RCC_PLLCFGR_PLLM_3 | RCC_PLLCFGR_PLLM_1) /*!< PLL, PLLI2S and PLLSAI division factor by 58 */ #define LL_RCC_PLLM_DIV_59 (RCC_PLLCFGR_PLLM_5 | RCC_PLLCFGR_PLLM_4 | RCC_PLLCFGR_PLLM_3 | RCC_PLLCFGR_PLLM_1 | RCC_PLLCFGR_PLLM_0) /*!< PLL, PLLI2S and PLLSAI division factor by 59 */ #define LL_RCC_PLLM_DIV_60 (RCC_PLLCFGR_PLLM_5 | RCC_PLLCFGR_PLLM_4 | RCC_PLLCFGR_PLLM_3 | RCC_PLLCFGR_PLLM_2) /*!< PLL, PLLI2S and PLLSAI division factor by 60 */ #define LL_RCC_PLLM_DIV_61 (RCC_PLLCFGR_PLLM_5 | RCC_PLLCFGR_PLLM_4 | RCC_PLLCFGR_PLLM_3 | RCC_PLLCFGR_PLLM_2 | RCC_PLLCFGR_PLLM_0) /*!< PLL, PLLI2S and PLLSAI division factor by 61 */ #define LL_RCC_PLLM_DIV_62 (RCC_PLLCFGR_PLLM_5 | RCC_PLLCFGR_PLLM_4 | RCC_PLLCFGR_PLLM_3 | RCC_PLLCFGR_PLLM_2 | RCC_PLLCFGR_PLLM_1) /*!< PLL, PLLI2S and PLLSAI division factor by 62 */ #define LL_RCC_PLLM_DIV_63 (RCC_PLLCFGR_PLLM_5 | RCC_PLLCFGR_PLLM_4 | RCC_PLLCFGR_PLLM_3 | RCC_PLLCFGR_PLLM_2 | RCC_PLLCFGR_PLLM_1 | RCC_PLLCFGR_PLLM_0) /*!< PLL, PLLI2S and PLLSAI division factor by 63 */ /** * @} */ #if defined(RCC_PLLCFGR_PLLR) /** @defgroup RCC_LL_EC_PLLR_DIV PLL division factor (PLLR) * @{ */ #define LL_RCC_PLLR_DIV_2 (RCC_PLLCFGR_PLLR_1) /*!< Main PLL division factor for PLLCLK (system clock) by 2 */ #define LL_RCC_PLLR_DIV_3 (RCC_PLLCFGR_PLLR_1|RCC_PLLCFGR_PLLR_0) /*!< Main PLL division factor for PLLCLK (system clock) by 3 */ #define LL_RCC_PLLR_DIV_4 (RCC_PLLCFGR_PLLR_2) /*!< Main PLL division factor for PLLCLK (system clock) by 4 */ #define LL_RCC_PLLR_DIV_5 (RCC_PLLCFGR_PLLR_2|RCC_PLLCFGR_PLLR_0) /*!< Main PLL division factor for PLLCLK (system clock) by 5 */ #define LL_RCC_PLLR_DIV_6 (RCC_PLLCFGR_PLLR_2|RCC_PLLCFGR_PLLR_1) /*!< Main PLL division factor for PLLCLK (system clock) by 6 */ #define LL_RCC_PLLR_DIV_7 (RCC_PLLCFGR_PLLR) /*!< Main PLL division factor for PLLCLK (system clock) by 7 */ /** * @} */ #endif /* RCC_PLLCFGR_PLLR */ #if defined(RCC_DCKCFGR_PLLDIVR) /** @defgroup RCC_LL_EC_PLLDIVR PLLDIVR division factor (PLLDIVR) * @{ */ #define LL_RCC_PLLDIVR_DIV_1 (RCC_DCKCFGR_PLLDIVR_0) /*!< PLL division factor for PLLDIVR output by 1 */ #define LL_RCC_PLLDIVR_DIV_2 (RCC_DCKCFGR_PLLDIVR_1) /*!< PLL division factor for PLLDIVR output by 2 */ #define LL_RCC_PLLDIVR_DIV_3 (RCC_DCKCFGR_PLLDIVR_1 | RCC_DCKCFGR_PLLDIVR_0) /*!< PLL division factor for PLLDIVR output by 3 */ #define LL_RCC_PLLDIVR_DIV_4 (RCC_DCKCFGR_PLLDIVR_2) /*!< PLL division factor for PLLDIVR output by 4 */ #define LL_RCC_PLLDIVR_DIV_5 (RCC_DCKCFGR_PLLDIVR_2 | RCC_DCKCFGR_PLLDIVR_0) /*!< PLL division factor for PLLDIVR output by 5 */ #define LL_RCC_PLLDIVR_DIV_6 (RCC_DCKCFGR_PLLDIVR_2 | RCC_DCKCFGR_PLLDIVR_1) /*!< PLL division factor for PLLDIVR output by 6 */ #define LL_RCC_PLLDIVR_DIV_7 (RCC_DCKCFGR_PLLDIVR_2 | RCC_DCKCFGR_PLLDIVR_1 | RCC_DCKCFGR_PLLDIVR_0) /*!< PLL division factor for PLLDIVR output by 7 */ #define LL_RCC_PLLDIVR_DIV_8 (RCC_DCKCFGR_PLLDIVR_3) /*!< PLL division factor for PLLDIVR output by 8 */ #define LL_RCC_PLLDIVR_DIV_9 (RCC_DCKCFGR_PLLDIVR_3 | RCC_DCKCFGR_PLLDIVR_0) /*!< PLL division factor for PLLDIVR output by 9 */ #define LL_RCC_PLLDIVR_DIV_10 (RCC_DCKCFGR_PLLDIVR_3 | RCC_DCKCFGR_PLLDIVR_1) /*!< PLL division factor for PLLDIVR output by 10 */ #define LL_RCC_PLLDIVR_DIV_11 (RCC_DCKCFGR_PLLDIVR_3 | RCC_DCKCFGR_PLLDIVR_1 | RCC_DCKCFGR_PLLDIVR_0) /*!< PLL division factor for PLLDIVR output by 11 */ #define LL_RCC_PLLDIVR_DIV_12 (RCC_DCKCFGR_PLLDIVR_3 | RCC_DCKCFGR_PLLDIVR_2) /*!< PLL division factor for PLLDIVR output by 12 */ #define LL_RCC_PLLDIVR_DIV_13 (RCC_DCKCFGR_PLLDIVR_3 | RCC_DCKCFGR_PLLDIVR_2 | RCC_DCKCFGR_PLLDIVR_0) /*!< PLL division factor for PLLDIVR output by 13 */ #define LL_RCC_PLLDIVR_DIV_14 (RCC_DCKCFGR_PLLDIVR_3 | RCC_DCKCFGR_PLLDIVR_2 | RCC_DCKCFGR_PLLDIVR_1) /*!< PLL division factor for PLLDIVR output by 14 */ #define LL_RCC_PLLDIVR_DIV_15 (RCC_DCKCFGR_PLLDIVR_3 | RCC_DCKCFGR_PLLDIVR_2 | RCC_DCKCFGR_PLLDIVR_1 | RCC_DCKCFGR_PLLDIVR_0) /*!< PLL division factor for PLLDIVR output by 15 */ #define LL_RCC_PLLDIVR_DIV_16 (RCC_DCKCFGR_PLLDIVR_4) /*!< PLL division factor for PLLDIVR output by 16 */ #define LL_RCC_PLLDIVR_DIV_17 (RCC_DCKCFGR_PLLDIVR_4 | RCC_DCKCFGR_PLLDIVR_0) /*!< PLL division factor for PLLDIVR output by 17 */ #define LL_RCC_PLLDIVR_DIV_18 (RCC_DCKCFGR_PLLDIVR_4 | RCC_DCKCFGR_PLLDIVR_1) /*!< PLL division factor for PLLDIVR output by 18 */ #define LL_RCC_PLLDIVR_DIV_19 (RCC_DCKCFGR_PLLDIVR_4 | RCC_DCKCFGR_PLLDIVR_1 | RCC_DCKCFGR_PLLDIVR_0) /*!< PLL division factor for PLLDIVR output by 19 */ #define LL_RCC_PLLDIVR_DIV_20 (RCC_DCKCFGR_PLLDIVR_4 | RCC_DCKCFGR_PLLDIVR_2) /*!< PLL division factor for PLLDIVR output by 20 */ #define LL_RCC_PLLDIVR_DIV_21 (RCC_DCKCFGR_PLLDIVR_4 | RCC_DCKCFGR_PLLDIVR_2 | RCC_DCKCFGR_PLLDIVR_0) /*!< PLL division factor for PLLDIVR output by 21 */ #define LL_RCC_PLLDIVR_DIV_22 (RCC_DCKCFGR_PLLDIVR_4 | RCC_DCKCFGR_PLLDIVR_2 | RCC_DCKCFGR_PLLDIVR_1) /*!< PLL division factor for PLLDIVR output by 22 */ #define LL_RCC_PLLDIVR_DIV_23 (RCC_DCKCFGR_PLLDIVR_4 | RCC_DCKCFGR_PLLDIVR_2 | RCC_DCKCFGR_PLLDIVR_1 | RCC_DCKCFGR_PLLDIVR_0) /*!< PLL division factor for PLLDIVR output by 23 */ #define LL_RCC_PLLDIVR_DIV_24 (RCC_DCKCFGR_PLLDIVR_4 | RCC_DCKCFGR_PLLDIVR_3) /*!< PLL division factor for PLLDIVR output by 24 */ #define LL_RCC_PLLDIVR_DIV_25 (RCC_DCKCFGR_PLLDIVR_4 | RCC_DCKCFGR_PLLDIVR_3 | RCC_DCKCFGR_PLLDIVR_0) /*!< PLL division factor for PLLDIVR output by 25 */ #define LL_RCC_PLLDIVR_DIV_26 (RCC_DCKCFGR_PLLDIVR_4 | RCC_DCKCFGR_PLLDIVR_3 | RCC_DCKCFGR_PLLDIVR_1) /*!< PLL division factor for PLLDIVR output by 26 */ #define LL_RCC_PLLDIVR_DIV_27 (RCC_DCKCFGR_PLLDIVR_4 | RCC_DCKCFGR_PLLDIVR_3 | RCC_DCKCFGR_PLLDIVR_1 | RCC_DCKCFGR_PLLDIVR_0) /*!< PLL division factor for PLLDIVR output by 27 */ #define LL_RCC_PLLDIVR_DIV_28 (RCC_DCKCFGR_PLLDIVR_4 | RCC_DCKCFGR_PLLDIVR_3 | RCC_DCKCFGR_PLLDIVR_2) /*!< PLL division factor for PLLDIVR output by 28 */ #define LL_RCC_PLLDIVR_DIV_29 (RCC_DCKCFGR_PLLDIVR_4 | RCC_DCKCFGR_PLLDIVR_3 | RCC_DCKCFGR_PLLDIVR_2 | RCC_DCKCFGR_PLLDIVR_0) /*!< PLL division factor for PLLDIVR output by 29 */ #define LL_RCC_PLLDIVR_DIV_30 (RCC_DCKCFGR_PLLDIVR_4 | RCC_DCKCFGR_PLLDIVR_3 | RCC_DCKCFGR_PLLDIVR_2 | RCC_DCKCFGR_PLLDIVR_1) /*!< PLL division factor for PLLDIVR output by 30 */ #define LL_RCC_PLLDIVR_DIV_31 (RCC_DCKCFGR_PLLDIVR_4 | RCC_DCKCFGR_PLLDIVR_3 | RCC_DCKCFGR_PLLDIVR_2 | RCC_DCKCFGR_PLLDIVR_1 | RCC_DCKCFGR_PLLDIVR_0) /*!< PLL division factor for PLLDIVR output by 31 */ /** * @} */ #endif /* RCC_DCKCFGR_PLLDIVR */ /** @defgroup RCC_LL_EC_PLLP_DIV PLL division factor (PLLP) * @{ */ #define LL_RCC_PLLP_DIV_2 0x00000000U /*!< Main PLL division factor for PLLP output by 2 */ #define LL_RCC_PLLP_DIV_4 RCC_PLLCFGR_PLLP_0 /*!< Main PLL division factor for PLLP output by 4 */ #define LL_RCC_PLLP_DIV_6 RCC_PLLCFGR_PLLP_1 /*!< Main PLL division factor for PLLP output by 6 */ #define LL_RCC_PLLP_DIV_8 (RCC_PLLCFGR_PLLP_1 | RCC_PLLCFGR_PLLP_0) /*!< Main PLL division factor for PLLP output by 8 */ /** * @} */ /** @defgroup RCC_LL_EC_PLLQ_DIV PLL division factor (PLLQ) * @{ */ #define LL_RCC_PLLQ_DIV_2 RCC_PLLCFGR_PLLQ_1 /*!< Main PLL division factor for PLLQ output by 2 */ #define LL_RCC_PLLQ_DIV_3 (RCC_PLLCFGR_PLLQ_1|RCC_PLLCFGR_PLLQ_0) /*!< Main PLL division factor for PLLQ output by 3 */ #define LL_RCC_PLLQ_DIV_4 RCC_PLLCFGR_PLLQ_2 /*!< Main PLL division factor for PLLQ output by 4 */ #define LL_RCC_PLLQ_DIV_5 (RCC_PLLCFGR_PLLQ_2|RCC_PLLCFGR_PLLQ_0) /*!< Main PLL division factor for PLLQ output by 5 */ #define LL_RCC_PLLQ_DIV_6 (RCC_PLLCFGR_PLLQ_2|RCC_PLLCFGR_PLLQ_1) /*!< Main PLL division factor for PLLQ output by 6 */ #define LL_RCC_PLLQ_DIV_7 (RCC_PLLCFGR_PLLQ_2|RCC_PLLCFGR_PLLQ_1|RCC_PLLCFGR_PLLQ_0) /*!< Main PLL division factor for PLLQ output by 7 */ #define LL_RCC_PLLQ_DIV_8 RCC_PLLCFGR_PLLQ_3 /*!< Main PLL division factor for PLLQ output by 8 */ #define LL_RCC_PLLQ_DIV_9 (RCC_PLLCFGR_PLLQ_3|RCC_PLLCFGR_PLLQ_0) /*!< Main PLL division factor for PLLQ output by 9 */ #define LL_RCC_PLLQ_DIV_10 (RCC_PLLCFGR_PLLQ_3|RCC_PLLCFGR_PLLQ_1) /*!< Main PLL division factor for PLLQ output by 10 */ #define LL_RCC_PLLQ_DIV_11 (RCC_PLLCFGR_PLLQ_3|RCC_PLLCFGR_PLLQ_1|RCC_PLLCFGR_PLLQ_0) /*!< Main PLL division factor for PLLQ output by 11 */ #define LL_RCC_PLLQ_DIV_12 (RCC_PLLCFGR_PLLQ_3|RCC_PLLCFGR_PLLQ_2) /*!< Main PLL division factor for PLLQ output by 12 */ #define LL_RCC_PLLQ_DIV_13 (RCC_PLLCFGR_PLLQ_3|RCC_PLLCFGR_PLLQ_2|RCC_PLLCFGR_PLLQ_0) /*!< Main PLL division factor for PLLQ output by 13 */ #define LL_RCC_PLLQ_DIV_14 (RCC_PLLCFGR_PLLQ_3|RCC_PLLCFGR_PLLQ_2|RCC_PLLCFGR_PLLQ_1) /*!< Main PLL division factor for PLLQ output by 14 */ #define LL_RCC_PLLQ_DIV_15 (RCC_PLLCFGR_PLLQ_3|RCC_PLLCFGR_PLLQ_2|RCC_PLLCFGR_PLLQ_1|RCC_PLLCFGR_PLLQ_0) /*!< Main PLL division factor for PLLQ output by 15 */ /** * @} */ /** @defgroup RCC_LL_EC_PLL_SPRE_SEL PLL Spread Spectrum Selection * @{ */ #define LL_RCC_SPREAD_SELECT_CENTER 0x00000000U /*!< PLL center spread spectrum selection */ #define LL_RCC_SPREAD_SELECT_DOWN RCC_SSCGR_SPREADSEL /*!< PLL down spread spectrum selection */ /** * @} */ #if defined(RCC_PLLI2S_SUPPORT) /** @defgroup RCC_LL_EC_PLLI2SM PLLI2SM division factor (PLLI2SM) * @{ */ #if defined(RCC_PLLI2SCFGR_PLLI2SM) #define LL_RCC_PLLI2SM_DIV_2 (RCC_PLLI2SCFGR_PLLI2SM_1) /*!< PLLI2S division factor for PLLI2SM output by 2 */ #define LL_RCC_PLLI2SM_DIV_3 (RCC_PLLI2SCFGR_PLLI2SM_1 | RCC_PLLI2SCFGR_PLLI2SM_0) /*!< PLLI2S division factor for PLLI2SM output by 3 */ #define LL_RCC_PLLI2SM_DIV_4 (RCC_PLLI2SCFGR_PLLI2SM_2) /*!< PLLI2S division factor for PLLI2SM output by 4 */ #define LL_RCC_PLLI2SM_DIV_5 (RCC_PLLI2SCFGR_PLLI2SM_2 | RCC_PLLI2SCFGR_PLLI2SM_0) /*!< PLLI2S division factor for PLLI2SM output by 5 */ #define LL_RCC_PLLI2SM_DIV_6 (RCC_PLLI2SCFGR_PLLI2SM_2 | RCC_PLLI2SCFGR_PLLI2SM_1) /*!< PLLI2S division factor for PLLI2SM output by 6 */ #define LL_RCC_PLLI2SM_DIV_7 (RCC_PLLI2SCFGR_PLLI2SM_2 | RCC_PLLI2SCFGR_PLLI2SM_1 | RCC_PLLI2SCFGR_PLLI2SM_0) /*!< PLLI2S division factor for PLLI2SM output by 7 */ #define LL_RCC_PLLI2SM_DIV_8 (RCC_PLLI2SCFGR_PLLI2SM_3) /*!< PLLI2S division factor for PLLI2SM output by 8 */ #define LL_RCC_PLLI2SM_DIV_9 (RCC_PLLI2SCFGR_PLLI2SM_3 | RCC_PLLI2SCFGR_PLLI2SM_0) /*!< PLLI2S division factor for PLLI2SM output by 9 */ #define LL_RCC_PLLI2SM_DIV_10 (RCC_PLLI2SCFGR_PLLI2SM_3 | RCC_PLLI2SCFGR_PLLI2SM_1) /*!< PLLI2S division factor for PLLI2SM output by 10 */ #define LL_RCC_PLLI2SM_DIV_11 (RCC_PLLI2SCFGR_PLLI2SM_3 | RCC_PLLI2SCFGR_PLLI2SM_1 | RCC_PLLI2SCFGR_PLLI2SM_0) /*!< PLLI2S division factor for PLLI2SM output by 11 */ #define LL_RCC_PLLI2SM_DIV_12 (RCC_PLLI2SCFGR_PLLI2SM_3 | RCC_PLLI2SCFGR_PLLI2SM_2) /*!< PLLI2S division factor for PLLI2SM output by 12 */ #define LL_RCC_PLLI2SM_DIV_13 (RCC_PLLI2SCFGR_PLLI2SM_3 | RCC_PLLI2SCFGR_PLLI2SM_2 | RCC_PLLI2SCFGR_PLLI2SM_0) /*!< PLLI2S division factor for PLLI2SM output by 13 */ #define LL_RCC_PLLI2SM_DIV_14 (RCC_PLLI2SCFGR_PLLI2SM_3 | RCC_PLLI2SCFGR_PLLI2SM_2 | RCC_PLLI2SCFGR_PLLI2SM_1) /*!< PLLI2S division factor for PLLI2SM output by 14 */ #define LL_RCC_PLLI2SM_DIV_15 (RCC_PLLI2SCFGR_PLLI2SM_3 | RCC_PLLI2SCFGR_PLLI2SM_2 | RCC_PLLI2SCFGR_PLLI2SM_1 | RCC_PLLI2SCFGR_PLLI2SM_0) /*!< PLLI2S division factor for PLLI2SM output by 15 */ #define LL_RCC_PLLI2SM_DIV_16 (RCC_PLLI2SCFGR_PLLI2SM_4) /*!< PLLI2S division factor for PLLI2SM output by 16 */ #define LL_RCC_PLLI2SM_DIV_17 (RCC_PLLI2SCFGR_PLLI2SM_4 | RCC_PLLI2SCFGR_PLLI2SM_0) /*!< PLLI2S division factor for PLLI2SM output by 17 */ #define LL_RCC_PLLI2SM_DIV_18 (RCC_PLLI2SCFGR_PLLI2SM_4 | RCC_PLLI2SCFGR_PLLI2SM_1) /*!< PLLI2S division factor for PLLI2SM output by 18 */ #define LL_RCC_PLLI2SM_DIV_19 (RCC_PLLI2SCFGR_PLLI2SM_4 | RCC_PLLI2SCFGR_PLLI2SM_1 | RCC_PLLI2SCFGR_PLLI2SM_0) /*!< PLLI2S division factor for PLLI2SM output by 19 */ #define LL_RCC_PLLI2SM_DIV_20 (RCC_PLLI2SCFGR_PLLI2SM_4 | RCC_PLLI2SCFGR_PLLI2SM_2) /*!< PLLI2S division factor for PLLI2SM output by 20 */ #define LL_RCC_PLLI2SM_DIV_21 (RCC_PLLI2SCFGR_PLLI2SM_4 | RCC_PLLI2SCFGR_PLLI2SM_2 | RCC_PLLI2SCFGR_PLLI2SM_0) /*!< PLLI2S division factor for PLLI2SM output by 21 */ #define LL_RCC_PLLI2SM_DIV_22 (RCC_PLLI2SCFGR_PLLI2SM_4 | RCC_PLLI2SCFGR_PLLI2SM_2 | RCC_PLLI2SCFGR_PLLI2SM_1) /*!< PLLI2S division factor for PLLI2SM output by 22 */ #define LL_RCC_PLLI2SM_DIV_23 (RCC_PLLI2SCFGR_PLLI2SM_4 | RCC_PLLI2SCFGR_PLLI2SM_2 | RCC_PLLI2SCFGR_PLLI2SM_1 | RCC_PLLI2SCFGR_PLLI2SM_0) /*!< PLLI2S division factor for PLLI2SM output by 23 */ #define LL_RCC_PLLI2SM_DIV_24 (RCC_PLLI2SCFGR_PLLI2SM_4 | RCC_PLLI2SCFGR_PLLI2SM_3) /*!< PLLI2S division factor for PLLI2SM output by 24 */ #define LL_RCC_PLLI2SM_DIV_25 (RCC_PLLI2SCFGR_PLLI2SM_4 | RCC_PLLI2SCFGR_PLLI2SM_3 | RCC_PLLI2SCFGR_PLLI2SM_0) /*!< PLLI2S division factor for PLLI2SM output by 25 */ #define LL_RCC_PLLI2SM_DIV_26 (RCC_PLLI2SCFGR_PLLI2SM_4 | RCC_PLLI2SCFGR_PLLI2SM_3 | RCC_PLLI2SCFGR_PLLI2SM_1) /*!< PLLI2S division factor for PLLI2SM output by 26 */ #define LL_RCC_PLLI2SM_DIV_27 (RCC_PLLI2SCFGR_PLLI2SM_4 | RCC_PLLI2SCFGR_PLLI2SM_3 | RCC_PLLI2SCFGR_PLLI2SM_1 | RCC_PLLI2SCFGR_PLLI2SM_0) /*!< PLLI2S division factor for PLLI2SM output by 27 */ #define LL_RCC_PLLI2SM_DIV_28 (RCC_PLLI2SCFGR_PLLI2SM_4 | RCC_PLLI2SCFGR_PLLI2SM_3 | RCC_PLLI2SCFGR_PLLI2SM_2) /*!< PLLI2S division factor for PLLI2SM output by 28 */ #define LL_RCC_PLLI2SM_DIV_29 (RCC_PLLI2SCFGR_PLLI2SM_4 | RCC_PLLI2SCFGR_PLLI2SM_3 | RCC_PLLI2SCFGR_PLLI2SM_2 | RCC_PLLI2SCFGR_PLLI2SM_0) /*!< PLLI2S division factor for PLLI2SM output by 29 */ #define LL_RCC_PLLI2SM_DIV_30 (RCC_PLLI2SCFGR_PLLI2SM_4 | RCC_PLLI2SCFGR_PLLI2SM_3 | RCC_PLLI2SCFGR_PLLI2SM_2 | RCC_PLLI2SCFGR_PLLI2SM_1) /*!< PLLI2S division factor for PLLI2SM output by 30 */ #define LL_RCC_PLLI2SM_DIV_31 (RCC_PLLI2SCFGR_PLLI2SM_4 | RCC_PLLI2SCFGR_PLLI2SM_3 | RCC_PLLI2SCFGR_PLLI2SM_2 | RCC_PLLI2SCFGR_PLLI2SM_1 | RCC_PLLI2SCFGR_PLLI2SM_0) /*!< PLLI2S division factor for PLLI2SM output by 31 */ #define LL_RCC_PLLI2SM_DIV_32 (RCC_PLLI2SCFGR_PLLI2SM_5) /*!< PLLI2S division factor for PLLI2SM output by 32 */ #define LL_RCC_PLLI2SM_DIV_33 (RCC_PLLI2SCFGR_PLLI2SM_5 | RCC_PLLI2SCFGR_PLLI2SM_0) /*!< PLLI2S division factor for PLLI2SM output by 33 */ #define LL_RCC_PLLI2SM_DIV_34 (RCC_PLLI2SCFGR_PLLI2SM_5 | RCC_PLLI2SCFGR_PLLI2SM_1) /*!< PLLI2S division factor for PLLI2SM output by 34 */ #define LL_RCC_PLLI2SM_DIV_35 (RCC_PLLI2SCFGR_PLLI2SM_5 | RCC_PLLI2SCFGR_PLLI2SM_1 | RCC_PLLI2SCFGR_PLLI2SM_0) /*!< PLLI2S division factor for PLLI2SM output by 35 */ #define LL_RCC_PLLI2SM_DIV_36 (RCC_PLLI2SCFGR_PLLI2SM_5 | RCC_PLLI2SCFGR_PLLI2SM_2) /*!< PLLI2S division factor for PLLI2SM output by 36 */ #define LL_RCC_PLLI2SM_DIV_37 (RCC_PLLI2SCFGR_PLLI2SM_5 | RCC_PLLI2SCFGR_PLLI2SM_2 | RCC_PLLI2SCFGR_PLLI2SM_0) /*!< PLLI2S division factor for PLLI2SM output by 37 */ #define LL_RCC_PLLI2SM_DIV_38 (RCC_PLLI2SCFGR_PLLI2SM_5 | RCC_PLLI2SCFGR_PLLI2SM_2 | RCC_PLLI2SCFGR_PLLI2SM_1) /*!< PLLI2S division factor for PLLI2SM output by 38 */ #define LL_RCC_PLLI2SM_DIV_39 (RCC_PLLI2SCFGR_PLLI2SM_5 | RCC_PLLI2SCFGR_PLLI2SM_2 | RCC_PLLI2SCFGR_PLLI2SM_1 | RCC_PLLI2SCFGR_PLLI2SM_0) /*!< PLLI2S division factor for PLLI2SM output by 39 */ #define LL_RCC_PLLI2SM_DIV_40 (RCC_PLLI2SCFGR_PLLI2SM_5 | RCC_PLLI2SCFGR_PLLI2SM_3) /*!< PLLI2S division factor for PLLI2SM output by 40 */ #define LL_RCC_PLLI2SM_DIV_41 (RCC_PLLI2SCFGR_PLLI2SM_5 | RCC_PLLI2SCFGR_PLLI2SM_3 | RCC_PLLI2SCFGR_PLLI2SM_0) /*!< PLLI2S division factor for PLLI2SM output by 41 */ #define LL_RCC_PLLI2SM_DIV_42 (RCC_PLLI2SCFGR_PLLI2SM_5 | RCC_PLLI2SCFGR_PLLI2SM_3 | RCC_PLLI2SCFGR_PLLI2SM_1) /*!< PLLI2S division factor for PLLI2SM output by 42 */ #define LL_RCC_PLLI2SM_DIV_43 (RCC_PLLI2SCFGR_PLLI2SM_5 | RCC_PLLI2SCFGR_PLLI2SM_3 | RCC_PLLI2SCFGR_PLLI2SM_1 | RCC_PLLI2SCFGR_PLLI2SM_0) /*!< PLLI2S division factor for PLLI2SM output by 43 */ #define LL_RCC_PLLI2SM_DIV_44 (RCC_PLLI2SCFGR_PLLI2SM_5 | RCC_PLLI2SCFGR_PLLI2SM_3 | RCC_PLLI2SCFGR_PLLI2SM_2) /*!< PLLI2S division factor for PLLI2SM output by 44 */ #define LL_RCC_PLLI2SM_DIV_45 (RCC_PLLI2SCFGR_PLLI2SM_5 | RCC_PLLI2SCFGR_PLLI2SM_3 | RCC_PLLI2SCFGR_PLLI2SM_2 | RCC_PLLI2SCFGR_PLLI2SM_0) /*!< PLLI2S division factor for PLLI2SM output by 45 */ #define LL_RCC_PLLI2SM_DIV_46 (RCC_PLLI2SCFGR_PLLI2SM_5 | RCC_PLLI2SCFGR_PLLI2SM_3 | RCC_PLLI2SCFGR_PLLI2SM_2 | RCC_PLLI2SCFGR_PLLI2SM_1) /*!< PLLI2S division factor for PLLI2SM output by 46 */ #define LL_RCC_PLLI2SM_DIV_47 (RCC_PLLI2SCFGR_PLLI2SM_5 | RCC_PLLI2SCFGR_PLLI2SM_3 | RCC_PLLI2SCFGR_PLLI2SM_2 | RCC_PLLI2SCFGR_PLLI2SM_1 | RCC_PLLI2SCFGR_PLLI2SM_0) /*!< PLLI2S division factor for PLLI2SM output by 47 */ #define LL_RCC_PLLI2SM_DIV_48 (RCC_PLLI2SCFGR_PLLI2SM_5 | RCC_PLLI2SCFGR_PLLI2SM_4) /*!< PLLI2S division factor for PLLI2SM output by 48 */ #define LL_RCC_PLLI2SM_DIV_49 (RCC_PLLI2SCFGR_PLLI2SM_5 | RCC_PLLI2SCFGR_PLLI2SM_4 | RCC_PLLI2SCFGR_PLLI2SM_0) /*!< PLLI2S division factor for PLLI2SM output by 49 */ #define LL_RCC_PLLI2SM_DIV_50 (RCC_PLLI2SCFGR_PLLI2SM_5 | RCC_PLLI2SCFGR_PLLI2SM_4 | RCC_PLLI2SCFGR_PLLI2SM_1) /*!< PLLI2S division factor for PLLI2SM output by 50 */ #define LL_RCC_PLLI2SM_DIV_51 (RCC_PLLI2SCFGR_PLLI2SM_5 | RCC_PLLI2SCFGR_PLLI2SM_4 | RCC_PLLI2SCFGR_PLLI2SM_1 | RCC_PLLI2SCFGR_PLLI2SM_0) /*!< PLLI2S division factor for PLLI2SM output by 51 */ #define LL_RCC_PLLI2SM_DIV_52 (RCC_PLLI2SCFGR_PLLI2SM_5 | RCC_PLLI2SCFGR_PLLI2SM_4 | RCC_PLLI2SCFGR_PLLI2SM_2) /*!< PLLI2S division factor for PLLI2SM output by 52 */ #define LL_RCC_PLLI2SM_DIV_53 (RCC_PLLI2SCFGR_PLLI2SM_5 | RCC_PLLI2SCFGR_PLLI2SM_4 | RCC_PLLI2SCFGR_PLLI2SM_2 | RCC_PLLI2SCFGR_PLLI2SM_0) /*!< PLLI2S division factor for PLLI2SM output by 53 */ #define LL_RCC_PLLI2SM_DIV_54 (RCC_PLLI2SCFGR_PLLI2SM_5 | RCC_PLLI2SCFGR_PLLI2SM_4 | RCC_PLLI2SCFGR_PLLI2SM_2 | RCC_PLLI2SCFGR_PLLI2SM_1) /*!< PLLI2S division factor for PLLI2SM output by 54 */ #define LL_RCC_PLLI2SM_DIV_55 (RCC_PLLI2SCFGR_PLLI2SM_5 | RCC_PLLI2SCFGR_PLLI2SM_4 | RCC_PLLI2SCFGR_PLLI2SM_2 | RCC_PLLI2SCFGR_PLLI2SM_1 | RCC_PLLI2SCFGR_PLLI2SM_0) /*!< PLLI2S division factor for PLLI2SM output by 55 */ #define LL_RCC_PLLI2SM_DIV_56 (RCC_PLLI2SCFGR_PLLI2SM_5 | RCC_PLLI2SCFGR_PLLI2SM_4 | RCC_PLLI2SCFGR_PLLI2SM_3) /*!< PLLI2S division factor for PLLI2SM output by 56 */ #define LL_RCC_PLLI2SM_DIV_57 (RCC_PLLI2SCFGR_PLLI2SM_5 | RCC_PLLI2SCFGR_PLLI2SM_4 | RCC_PLLI2SCFGR_PLLI2SM_3 | RCC_PLLI2SCFGR_PLLI2SM_0) /*!< PLLI2S division factor for PLLI2SM output by 57 */ #define LL_RCC_PLLI2SM_DIV_58 (RCC_PLLI2SCFGR_PLLI2SM_5 | RCC_PLLI2SCFGR_PLLI2SM_4 | RCC_PLLI2SCFGR_PLLI2SM_3 | RCC_PLLI2SCFGR_PLLI2SM_1) /*!< PLLI2S division factor for PLLI2SM output by 58 */ #define LL_RCC_PLLI2SM_DIV_59 (RCC_PLLI2SCFGR_PLLI2SM_5 | RCC_PLLI2SCFGR_PLLI2SM_4 | RCC_PLLI2SCFGR_PLLI2SM_3 | RCC_PLLI2SCFGR_PLLI2SM_1 | RCC_PLLI2SCFGR_PLLI2SM_0) /*!< PLLI2S division factor for PLLI2SM output by 59 */ #define LL_RCC_PLLI2SM_DIV_60 (RCC_PLLI2SCFGR_PLLI2SM_5 | RCC_PLLI2SCFGR_PLLI2SM_4 | RCC_PLLI2SCFGR_PLLI2SM_3 | RCC_PLLI2SCFGR_PLLI2SM_2) /*!< PLLI2S division factor for PLLI2SM output by 60 */ #define LL_RCC_PLLI2SM_DIV_61 (RCC_PLLI2SCFGR_PLLI2SM_5 | RCC_PLLI2SCFGR_PLLI2SM_4 | RCC_PLLI2SCFGR_PLLI2SM_3 | RCC_PLLI2SCFGR_PLLI2SM_2 | RCC_PLLI2SCFGR_PLLI2SM_0) /*!< PLLI2S division factor for PLLI2SM output by 61 */ #define LL_RCC_PLLI2SM_DIV_62 (RCC_PLLI2SCFGR_PLLI2SM_5 | RCC_PLLI2SCFGR_PLLI2SM_4 | RCC_PLLI2SCFGR_PLLI2SM_3 | RCC_PLLI2SCFGR_PLLI2SM_2 | RCC_PLLI2SCFGR_PLLI2SM_1) /*!< PLLI2S division factor for PLLI2SM output by 62 */ #define LL_RCC_PLLI2SM_DIV_63 (RCC_PLLI2SCFGR_PLLI2SM_5 | RCC_PLLI2SCFGR_PLLI2SM_4 | RCC_PLLI2SCFGR_PLLI2SM_3 | RCC_PLLI2SCFGR_PLLI2SM_2 | RCC_PLLI2SCFGR_PLLI2SM_1 | RCC_PLLI2SCFGR_PLLI2SM_0) /*!< PLLI2S division factor for PLLI2SM output by 63 */ #else #define LL_RCC_PLLI2SM_DIV_2 LL_RCC_PLLM_DIV_2 /*!< PLLI2S division factor for PLLI2SM output by 2 */ #define LL_RCC_PLLI2SM_DIV_3 LL_RCC_PLLM_DIV_3 /*!< PLLI2S division factor for PLLI2SM output by 3 */ #define LL_RCC_PLLI2SM_DIV_4 LL_RCC_PLLM_DIV_4 /*!< PLLI2S division factor for PLLI2SM output by 4 */ #define LL_RCC_PLLI2SM_DIV_5 LL_RCC_PLLM_DIV_5 /*!< PLLI2S division factor for PLLI2SM output by 5 */ #define LL_RCC_PLLI2SM_DIV_6 LL_RCC_PLLM_DIV_6 /*!< PLLI2S division factor for PLLI2SM output by 6 */ #define LL_RCC_PLLI2SM_DIV_7 LL_RCC_PLLM_DIV_7 /*!< PLLI2S division factor for PLLI2SM output by 7 */ #define LL_RCC_PLLI2SM_DIV_8 LL_RCC_PLLM_DIV_8 /*!< PLLI2S division factor for PLLI2SM output by 8 */ #define LL_RCC_PLLI2SM_DIV_9 LL_RCC_PLLM_DIV_9 /*!< PLLI2S division factor for PLLI2SM output by 9 */ #define LL_RCC_PLLI2SM_DIV_10 LL_RCC_PLLM_DIV_10 /*!< PLLI2S division factor for PLLI2SM output by 10 */ #define LL_RCC_PLLI2SM_DIV_11 LL_RCC_PLLM_DIV_11 /*!< PLLI2S division factor for PLLI2SM output by 11 */ #define LL_RCC_PLLI2SM_DIV_12 LL_RCC_PLLM_DIV_12 /*!< PLLI2S division factor for PLLI2SM output by 12 */ #define LL_RCC_PLLI2SM_DIV_13 LL_RCC_PLLM_DIV_13 /*!< PLLI2S division factor for PLLI2SM output by 13 */ #define LL_RCC_PLLI2SM_DIV_14 LL_RCC_PLLM_DIV_14 /*!< PLLI2S division factor for PLLI2SM output by 14 */ #define LL_RCC_PLLI2SM_DIV_15 LL_RCC_PLLM_DIV_15 /*!< PLLI2S division factor for PLLI2SM output by 15 */ #define LL_RCC_PLLI2SM_DIV_16 LL_RCC_PLLM_DIV_16 /*!< PLLI2S division factor for PLLI2SM output by 16 */ #define LL_RCC_PLLI2SM_DIV_17 LL_RCC_PLLM_DIV_17 /*!< PLLI2S division factor for PLLI2SM output by 17 */ #define LL_RCC_PLLI2SM_DIV_18 LL_RCC_PLLM_DIV_18 /*!< PLLI2S division factor for PLLI2SM output by 18 */ #define LL_RCC_PLLI2SM_DIV_19 LL_RCC_PLLM_DIV_19 /*!< PLLI2S division factor for PLLI2SM output by 19 */ #define LL_RCC_PLLI2SM_DIV_20 LL_RCC_PLLM_DIV_20 /*!< PLLI2S division factor for PLLI2SM output by 20 */ #define LL_RCC_PLLI2SM_DIV_21 LL_RCC_PLLM_DIV_21 /*!< PLLI2S division factor for PLLI2SM output by 21 */ #define LL_RCC_PLLI2SM_DIV_22 LL_RCC_PLLM_DIV_22 /*!< PLLI2S division factor for PLLI2SM output by 22 */ #define LL_RCC_PLLI2SM_DIV_23 LL_RCC_PLLM_DIV_23 /*!< PLLI2S division factor for PLLI2SM output by 23 */ #define LL_RCC_PLLI2SM_DIV_24 LL_RCC_PLLM_DIV_24 /*!< PLLI2S division factor for PLLI2SM output by 24 */ #define LL_RCC_PLLI2SM_DIV_25 LL_RCC_PLLM_DIV_25 /*!< PLLI2S division factor for PLLI2SM output by 25 */ #define LL_RCC_PLLI2SM_DIV_26 LL_RCC_PLLM_DIV_26 /*!< PLLI2S division factor for PLLI2SM output by 26 */ #define LL_RCC_PLLI2SM_DIV_27 LL_RCC_PLLM_DIV_27 /*!< PLLI2S division factor for PLLI2SM output by 27 */ #define LL_RCC_PLLI2SM_DIV_28 LL_RCC_PLLM_DIV_28 /*!< PLLI2S division factor for PLLI2SM output by 28 */ #define LL_RCC_PLLI2SM_DIV_29 LL_RCC_PLLM_DIV_29 /*!< PLLI2S division factor for PLLI2SM output by 29 */ #define LL_RCC_PLLI2SM_DIV_30 LL_RCC_PLLM_DIV_30 /*!< PLLI2S division factor for PLLI2SM output by 30 */ #define LL_RCC_PLLI2SM_DIV_31 LL_RCC_PLLM_DIV_31 /*!< PLLI2S division factor for PLLI2SM output by 31 */ #define LL_RCC_PLLI2SM_DIV_32 LL_RCC_PLLM_DIV_32 /*!< PLLI2S division factor for PLLI2SM output by 32 */ #define LL_RCC_PLLI2SM_DIV_33 LL_RCC_PLLM_DIV_33 /*!< PLLI2S division factor for PLLI2SM output by 33 */ #define LL_RCC_PLLI2SM_DIV_34 LL_RCC_PLLM_DIV_34 /*!< PLLI2S division factor for PLLI2SM output by 34 */ #define LL_RCC_PLLI2SM_DIV_35 LL_RCC_PLLM_DIV_35 /*!< PLLI2S division factor for PLLI2SM output by 35 */ #define LL_RCC_PLLI2SM_DIV_36 LL_RCC_PLLM_DIV_36 /*!< PLLI2S division factor for PLLI2SM output by 36 */ #define LL_RCC_PLLI2SM_DIV_37 LL_RCC_PLLM_DIV_37 /*!< PLLI2S division factor for PLLI2SM output by 37 */ #define LL_RCC_PLLI2SM_DIV_38 LL_RCC_PLLM_DIV_38 /*!< PLLI2S division factor for PLLI2SM output by 38 */ #define LL_RCC_PLLI2SM_DIV_39 LL_RCC_PLLM_DIV_39 /*!< PLLI2S division factor for PLLI2SM output by 39 */ #define LL_RCC_PLLI2SM_DIV_40 LL_RCC_PLLM_DIV_40 /*!< PLLI2S division factor for PLLI2SM output by 40 */ #define LL_RCC_PLLI2SM_DIV_41 LL_RCC_PLLM_DIV_41 /*!< PLLI2S division factor for PLLI2SM output by 41 */ #define LL_RCC_PLLI2SM_DIV_42 LL_RCC_PLLM_DIV_42 /*!< PLLI2S division factor for PLLI2SM output by 42 */ #define LL_RCC_PLLI2SM_DIV_43 LL_RCC_PLLM_DIV_43 /*!< PLLI2S division factor for PLLI2SM output by 43 */ #define LL_RCC_PLLI2SM_DIV_44 LL_RCC_PLLM_DIV_44 /*!< PLLI2S division factor for PLLI2SM output by 44 */ #define LL_RCC_PLLI2SM_DIV_45 LL_RCC_PLLM_DIV_45 /*!< PLLI2S division factor for PLLI2SM output by 45 */ #define LL_RCC_PLLI2SM_DIV_46 LL_RCC_PLLM_DIV_46 /*!< PLLI2S division factor for PLLI2SM output by 46 */ #define LL_RCC_PLLI2SM_DIV_47 LL_RCC_PLLM_DIV_47 /*!< PLLI2S division factor for PLLI2SM output by 47 */ #define LL_RCC_PLLI2SM_DIV_48 LL_RCC_PLLM_DIV_48 /*!< PLLI2S division factor for PLLI2SM output by 48 */ #define LL_RCC_PLLI2SM_DIV_49 LL_RCC_PLLM_DIV_49 /*!< PLLI2S division factor for PLLI2SM output by 49 */ #define LL_RCC_PLLI2SM_DIV_50 LL_RCC_PLLM_DIV_50 /*!< PLLI2S division factor for PLLI2SM output by 50 */ #define LL_RCC_PLLI2SM_DIV_51 LL_RCC_PLLM_DIV_51 /*!< PLLI2S division factor for PLLI2SM output by 51 */ #define LL_RCC_PLLI2SM_DIV_52 LL_RCC_PLLM_DIV_52 /*!< PLLI2S division factor for PLLI2SM output by 52 */ #define LL_RCC_PLLI2SM_DIV_53 LL_RCC_PLLM_DIV_53 /*!< PLLI2S division factor for PLLI2SM output by 53 */ #define LL_RCC_PLLI2SM_DIV_54 LL_RCC_PLLM_DIV_54 /*!< PLLI2S division factor for PLLI2SM output by 54 */ #define LL_RCC_PLLI2SM_DIV_55 LL_RCC_PLLM_DIV_55 /*!< PLLI2S division factor for PLLI2SM output by 55 */ #define LL_RCC_PLLI2SM_DIV_56 LL_RCC_PLLM_DIV_56 /*!< PLLI2S division factor for PLLI2SM output by 56 */ #define LL_RCC_PLLI2SM_DIV_57 LL_RCC_PLLM_DIV_57 /*!< PLLI2S division factor for PLLI2SM output by 57 */ #define LL_RCC_PLLI2SM_DIV_58 LL_RCC_PLLM_DIV_58 /*!< PLLI2S division factor for PLLI2SM output by 58 */ #define LL_RCC_PLLI2SM_DIV_59 LL_RCC_PLLM_DIV_59 /*!< PLLI2S division factor for PLLI2SM output by 59 */ #define LL_RCC_PLLI2SM_DIV_60 LL_RCC_PLLM_DIV_60 /*!< PLLI2S division factor for PLLI2SM output by 60 */ #define LL_RCC_PLLI2SM_DIV_61 LL_RCC_PLLM_DIV_61 /*!< PLLI2S division factor for PLLI2SM output by 61 */ #define LL_RCC_PLLI2SM_DIV_62 LL_RCC_PLLM_DIV_62 /*!< PLLI2S division factor for PLLI2SM output by 62 */ #define LL_RCC_PLLI2SM_DIV_63 LL_RCC_PLLM_DIV_63 /*!< PLLI2S division factor for PLLI2SM output by 63 */ #endif /* RCC_PLLI2SCFGR_PLLI2SM */ /** * @} */ #if defined(RCC_PLLI2SCFGR_PLLI2SQ) /** @defgroup RCC_LL_EC_PLLI2SQ PLLI2SQ division factor (PLLI2SQ) * @{ */ #define LL_RCC_PLLI2SQ_DIV_2 RCC_PLLI2SCFGR_PLLI2SQ_1 /*!< PLLI2S division factor for PLLI2SQ output by 2 */ #define LL_RCC_PLLI2SQ_DIV_3 (RCC_PLLI2SCFGR_PLLI2SQ_1 | RCC_PLLI2SCFGR_PLLI2SQ_0) /*!< PLLI2S division factor for PLLI2SQ output by 3 */ #define LL_RCC_PLLI2SQ_DIV_4 RCC_PLLI2SCFGR_PLLI2SQ_2 /*!< PLLI2S division factor for PLLI2SQ output by 4 */ #define LL_RCC_PLLI2SQ_DIV_5 (RCC_PLLI2SCFGR_PLLI2SQ_2 | RCC_PLLI2SCFGR_PLLI2SQ_0) /*!< PLLI2S division factor for PLLI2SQ output by 5 */ #define LL_RCC_PLLI2SQ_DIV_6 (RCC_PLLI2SCFGR_PLLI2SQ_2 | RCC_PLLI2SCFGR_PLLI2SQ_1) /*!< PLLI2S division factor for PLLI2SQ output by 6 */ #define LL_RCC_PLLI2SQ_DIV_7 (RCC_PLLI2SCFGR_PLLI2SQ_2 | RCC_PLLI2SCFGR_PLLI2SQ_1 | RCC_PLLI2SCFGR_PLLI2SQ_0) /*!< PLLI2S division factor for PLLI2SQ output by 7 */ #define LL_RCC_PLLI2SQ_DIV_8 RCC_PLLI2SCFGR_PLLI2SQ_3 /*!< PLLI2S division factor for PLLI2SQ output by 8 */ #define LL_RCC_PLLI2SQ_DIV_9 (RCC_PLLI2SCFGR_PLLI2SQ_3 | RCC_PLLI2SCFGR_PLLI2SQ_0) /*!< PLLI2S division factor for PLLI2SQ output by 9 */ #define LL_RCC_PLLI2SQ_DIV_10 (RCC_PLLI2SCFGR_PLLI2SQ_3 | RCC_PLLI2SCFGR_PLLI2SQ_1) /*!< PLLI2S division factor for PLLI2SQ output by 10 */ #define LL_RCC_PLLI2SQ_DIV_11 (RCC_PLLI2SCFGR_PLLI2SQ_3 | RCC_PLLI2SCFGR_PLLI2SQ_1 | RCC_PLLI2SCFGR_PLLI2SQ_0) /*!< PLLI2S division factor for PLLI2SQ output by 11 */ #define LL_RCC_PLLI2SQ_DIV_12 (RCC_PLLI2SCFGR_PLLI2SQ_3 | RCC_PLLI2SCFGR_PLLI2SQ_2) /*!< PLLI2S division factor for PLLI2SQ output by 12 */ #define LL_RCC_PLLI2SQ_DIV_13 (RCC_PLLI2SCFGR_PLLI2SQ_3 | RCC_PLLI2SCFGR_PLLI2SQ_2 | RCC_PLLI2SCFGR_PLLI2SQ_0) /*!< PLLI2S division factor for PLLI2SQ output by 13 */ #define LL_RCC_PLLI2SQ_DIV_14 (RCC_PLLI2SCFGR_PLLI2SQ_3 | RCC_PLLI2SCFGR_PLLI2SQ_2 | RCC_PLLI2SCFGR_PLLI2SQ_1) /*!< PLLI2S division factor for PLLI2SQ output by 14 */ #define LL_RCC_PLLI2SQ_DIV_15 (RCC_PLLI2SCFGR_PLLI2SQ_3 | RCC_PLLI2SCFGR_PLLI2SQ_2 | RCC_PLLI2SCFGR_PLLI2SQ_1 | RCC_PLLI2SCFGR_PLLI2SQ_0) /*!< PLLI2S division factor for PLLI2SQ output by 15 */ /** * @} */ #endif /* RCC_PLLI2SCFGR_PLLI2SQ */ #if defined(RCC_DCKCFGR_PLLI2SDIVQ) /** @defgroup RCC_LL_EC_PLLI2SDIVQ PLLI2SDIVQ division factor (PLLI2SDIVQ) * @{ */ #define LL_RCC_PLLI2SDIVQ_DIV_1 0x00000000U /*!< PLLI2S division factor for PLLI2SDIVQ output by 1 */ #define LL_RCC_PLLI2SDIVQ_DIV_2 RCC_DCKCFGR_PLLI2SDIVQ_0 /*!< PLLI2S division factor for PLLI2SDIVQ output by 2 */ #define LL_RCC_PLLI2SDIVQ_DIV_3 RCC_DCKCFGR_PLLI2SDIVQ_1 /*!< PLLI2S division factor for PLLI2SDIVQ output by 3 */ #define LL_RCC_PLLI2SDIVQ_DIV_4 (RCC_DCKCFGR_PLLI2SDIVQ_1 | RCC_DCKCFGR_PLLI2SDIVQ_0) /*!< PLLI2S division factor for PLLI2SDIVQ output by 4 */ #define LL_RCC_PLLI2SDIVQ_DIV_5 RCC_DCKCFGR_PLLI2SDIVQ_2 /*!< PLLI2S division factor for PLLI2SDIVQ output by 5 */ #define LL_RCC_PLLI2SDIVQ_DIV_6 (RCC_DCKCFGR_PLLI2SDIVQ_2 | RCC_DCKCFGR_PLLI2SDIVQ_0) /*!< PLLI2S division factor for PLLI2SDIVQ output by 6 */ #define LL_RCC_PLLI2SDIVQ_DIV_7 (RCC_DCKCFGR_PLLI2SDIVQ_2 | RCC_DCKCFGR_PLLI2SDIVQ_1) /*!< PLLI2S division factor for PLLI2SDIVQ output by 7 */ #define LL_RCC_PLLI2SDIVQ_DIV_8 (RCC_DCKCFGR_PLLI2SDIVQ_2 | RCC_DCKCFGR_PLLI2SDIVQ_1 | RCC_DCKCFGR_PLLI2SDIVQ_0) /*!< PLLI2S division factor for PLLI2SDIVQ output by 8 */ #define LL_RCC_PLLI2SDIVQ_DIV_9 RCC_DCKCFGR_PLLI2SDIVQ_3 /*!< PLLI2S division factor for PLLI2SDIVQ output by 9 */ #define LL_RCC_PLLI2SDIVQ_DIV_10 (RCC_DCKCFGR_PLLI2SDIVQ_3 | RCC_DCKCFGR_PLLI2SDIVQ_0) /*!< PLLI2S division factor for PLLI2SDIVQ output by 10 */ #define LL_RCC_PLLI2SDIVQ_DIV_11 (RCC_DCKCFGR_PLLI2SDIVQ_3 | RCC_DCKCFGR_PLLI2SDIVQ_1) /*!< PLLI2S division factor for PLLI2SDIVQ output by 11 */ #define LL_RCC_PLLI2SDIVQ_DIV_12 (RCC_DCKCFGR_PLLI2SDIVQ_3 | RCC_DCKCFGR_PLLI2SDIVQ_1 | RCC_DCKCFGR_PLLI2SDIVQ_0) /*!< PLLI2S division factor for PLLI2SDIVQ output by 12 */ #define LL_RCC_PLLI2SDIVQ_DIV_13 (RCC_DCKCFGR_PLLI2SDIVQ_3 | RCC_DCKCFGR_PLLI2SDIVQ_2) /*!< PLLI2S division factor for PLLI2SDIVQ output by 13 */ #define LL_RCC_PLLI2SDIVQ_DIV_14 (RCC_DCKCFGR_PLLI2SDIVQ_3 | RCC_DCKCFGR_PLLI2SDIVQ_2 | RCC_DCKCFGR_PLLI2SDIVQ_0) /*!< PLLI2S division factor for PLLI2SDIVQ output by 14 */ #define LL_RCC_PLLI2SDIVQ_DIV_15 (RCC_DCKCFGR_PLLI2SDIVQ_3 | RCC_DCKCFGR_PLLI2SDIVQ_2 | RCC_DCKCFGR_PLLI2SDIVQ_1) /*!< PLLI2S division factor for PLLI2SDIVQ output by 15 */ #define LL_RCC_PLLI2SDIVQ_DIV_16 (RCC_DCKCFGR_PLLI2SDIVQ_3 | RCC_DCKCFGR_PLLI2SDIVQ_2 | RCC_DCKCFGR_PLLI2SDIVQ_1 | RCC_DCKCFGR_PLLI2SDIVQ_0) /*!< PLLI2S division factor for PLLI2SDIVQ output by 16 */ #define LL_RCC_PLLI2SDIVQ_DIV_17 RCC_DCKCFGR_PLLI2SDIVQ_4 /*!< PLLI2S division factor for PLLI2SDIVQ output by 17 */ #define LL_RCC_PLLI2SDIVQ_DIV_18 (RCC_DCKCFGR_PLLI2SDIVQ_4 | RCC_DCKCFGR_PLLI2SDIVQ_0) /*!< PLLI2S division factor for PLLI2SDIVQ output by 18 */ #define LL_RCC_PLLI2SDIVQ_DIV_19 (RCC_DCKCFGR_PLLI2SDIVQ_4 | RCC_DCKCFGR_PLLI2SDIVQ_1) /*!< PLLI2S division factor for PLLI2SDIVQ output by 19 */ #define LL_RCC_PLLI2SDIVQ_DIV_20 (RCC_DCKCFGR_PLLI2SDIVQ_4 | RCC_DCKCFGR_PLLI2SDIVQ_1 | RCC_DCKCFGR_PLLI2SDIVQ_0) /*!< PLLI2S division factor for PLLI2SDIVQ output by 20 */ #define LL_RCC_PLLI2SDIVQ_DIV_21 (RCC_DCKCFGR_PLLI2SDIVQ_4 | RCC_DCKCFGR_PLLI2SDIVQ_2) /*!< PLLI2S division factor for PLLI2SDIVQ output by 21 */ #define LL_RCC_PLLI2SDIVQ_DIV_22 (RCC_DCKCFGR_PLLI2SDIVQ_4 | RCC_DCKCFGR_PLLI2SDIVQ_2 | RCC_DCKCFGR_PLLI2SDIVQ_0) /*!< PLLI2S division factor for PLLI2SDIVQ output by 22 */ #define LL_RCC_PLLI2SDIVQ_DIV_23 (RCC_DCKCFGR_PLLI2SDIVQ_4 | RCC_DCKCFGR_PLLI2SDIVQ_2 | RCC_DCKCFGR_PLLI2SDIVQ_1) /*!< PLLI2S division factor for PLLI2SDIVQ output by 23 */ #define LL_RCC_PLLI2SDIVQ_DIV_24 (RCC_DCKCFGR_PLLI2SDIVQ_4 | RCC_DCKCFGR_PLLI2SDIVQ_2 | RCC_DCKCFGR_PLLI2SDIVQ_1 | RCC_DCKCFGR_PLLI2SDIVQ_0) /*!< PLLI2S division factor for PLLI2SDIVQ output by 24 */ #define LL_RCC_PLLI2SDIVQ_DIV_25 (RCC_DCKCFGR_PLLI2SDIVQ_4 | RCC_DCKCFGR_PLLI2SDIVQ_3) /*!< PLLI2S division factor for PLLI2SDIVQ output by 25 */ #define LL_RCC_PLLI2SDIVQ_DIV_26 (RCC_DCKCFGR_PLLI2SDIVQ_4 | RCC_DCKCFGR_PLLI2SDIVQ_3 | RCC_DCKCFGR_PLLI2SDIVQ_0) /*!< PLLI2S division factor for PLLI2SDIVQ output by 26 */ #define LL_RCC_PLLI2SDIVQ_DIV_27 (RCC_DCKCFGR_PLLI2SDIVQ_4 | RCC_DCKCFGR_PLLI2SDIVQ_3 | RCC_DCKCFGR_PLLI2SDIVQ_1) /*!< PLLI2S division factor for PLLI2SDIVQ output by 27 */ #define LL_RCC_PLLI2SDIVQ_DIV_28 (RCC_DCKCFGR_PLLI2SDIVQ_4 | RCC_DCKCFGR_PLLI2SDIVQ_3 | RCC_DCKCFGR_PLLI2SDIVQ_1 | RCC_DCKCFGR_PLLI2SDIVQ_0) /*!< PLLI2S division factor for PLLI2SDIVQ output by 28 */ #define LL_RCC_PLLI2SDIVQ_DIV_29 (RCC_DCKCFGR_PLLI2SDIVQ_4 | RCC_DCKCFGR_PLLI2SDIVQ_3 | RCC_DCKCFGR_PLLI2SDIVQ_2) /*!< PLLI2S division factor for PLLI2SDIVQ output by 29 */ #define LL_RCC_PLLI2SDIVQ_DIV_30 (RCC_DCKCFGR_PLLI2SDIVQ_4 | RCC_DCKCFGR_PLLI2SDIVQ_3 | RCC_DCKCFGR_PLLI2SDIVQ_2 | RCC_DCKCFGR_PLLI2SDIVQ_0) /*!< PLLI2S division factor for PLLI2SDIVQ output by 30 */ #define LL_RCC_PLLI2SDIVQ_DIV_31 (RCC_DCKCFGR_PLLI2SDIVQ_4 | RCC_DCKCFGR_PLLI2SDIVQ_3 | RCC_DCKCFGR_PLLI2SDIVQ_2 | RCC_DCKCFGR_PLLI2SDIVQ_1) /*!< PLLI2S division factor for PLLI2SDIVQ output by 31 */ #define LL_RCC_PLLI2SDIVQ_DIV_32 (RCC_DCKCFGR_PLLI2SDIVQ_4 | RCC_DCKCFGR_PLLI2SDIVQ_3 | RCC_DCKCFGR_PLLI2SDIVQ_2 | RCC_DCKCFGR_PLLI2SDIVQ_1 | RCC_DCKCFGR_PLLI2SDIVQ_0) /*!< PLLI2S division factor for PLLI2SDIVQ output by 32 */ /** * @} */ #endif /* RCC_DCKCFGR_PLLI2SDIVQ */ #if defined(RCC_DCKCFGR_PLLI2SDIVR) /** @defgroup RCC_LL_EC_PLLI2SDIVR PLLI2SDIVR division factor (PLLI2SDIVR) * @{ */ #define LL_RCC_PLLI2SDIVR_DIV_1 (RCC_DCKCFGR_PLLI2SDIVR_0) /*!< PLLI2S division factor for PLLI2SDIVR output by 1 */ #define LL_RCC_PLLI2SDIVR_DIV_2 (RCC_DCKCFGR_PLLI2SDIVR_1) /*!< PLLI2S division factor for PLLI2SDIVR output by 2 */ #define LL_RCC_PLLI2SDIVR_DIV_3 (RCC_DCKCFGR_PLLI2SDIVR_1 | RCC_DCKCFGR_PLLI2SDIVR_0) /*!< PLLI2S division factor for PLLI2SDIVR output by 3 */ #define LL_RCC_PLLI2SDIVR_DIV_4 (RCC_DCKCFGR_PLLI2SDIVR_2) /*!< PLLI2S division factor for PLLI2SDIVR output by 4 */ #define LL_RCC_PLLI2SDIVR_DIV_5 (RCC_DCKCFGR_PLLI2SDIVR_2 | RCC_DCKCFGR_PLLI2SDIVR_0) /*!< PLLI2S division factor for PLLI2SDIVR output by 5 */ #define LL_RCC_PLLI2SDIVR_DIV_6 (RCC_DCKCFGR_PLLI2SDIVR_2 | RCC_DCKCFGR_PLLI2SDIVR_1) /*!< PLLI2S division factor for PLLI2SDIVR output by 6 */ #define LL_RCC_PLLI2SDIVR_DIV_7 (RCC_DCKCFGR_PLLI2SDIVR_2 | RCC_DCKCFGR_PLLI2SDIVR_1 | RCC_DCKCFGR_PLLI2SDIVR_0) /*!< PLLI2S division factor for PLLI2SDIVR output by 7 */ #define LL_RCC_PLLI2SDIVR_DIV_8 (RCC_DCKCFGR_PLLI2SDIVR_3) /*!< PLLI2S division factor for PLLI2SDIVR output by 8 */ #define LL_RCC_PLLI2SDIVR_DIV_9 (RCC_DCKCFGR_PLLI2SDIVR_3 | RCC_DCKCFGR_PLLI2SDIVR_0) /*!< PLLI2S division factor for PLLI2SDIVR output by 9 */ #define LL_RCC_PLLI2SDIVR_DIV_10 (RCC_DCKCFGR_PLLI2SDIVR_3 | RCC_DCKCFGR_PLLI2SDIVR_1) /*!< PLLI2S division factor for PLLI2SDIVR output by 10 */ #define LL_RCC_PLLI2SDIVR_DIV_11 (RCC_DCKCFGR_PLLI2SDIVR_3 | RCC_DCKCFGR_PLLI2SDIVR_1 | RCC_DCKCFGR_PLLI2SDIVR_0) /*!< PLLI2S division factor for PLLI2SDIVR output by 11 */ #define LL_RCC_PLLI2SDIVR_DIV_12 (RCC_DCKCFGR_PLLI2SDIVR_3 | RCC_DCKCFGR_PLLI2SDIVR_2) /*!< PLLI2S division factor for PLLI2SDIVR output by 12 */ #define LL_RCC_PLLI2SDIVR_DIV_13 (RCC_DCKCFGR_PLLI2SDIVR_3 | RCC_DCKCFGR_PLLI2SDIVR_2 | RCC_DCKCFGR_PLLI2SDIVR_0) /*!< PLLI2S division factor for PLLI2SDIVR output by 13 */ #define LL_RCC_PLLI2SDIVR_DIV_14 (RCC_DCKCFGR_PLLI2SDIVR_3 | RCC_DCKCFGR_PLLI2SDIVR_2 | RCC_DCKCFGR_PLLI2SDIVR_1) /*!< PLLI2S division factor for PLLI2SDIVR output by 14 */ #define LL_RCC_PLLI2SDIVR_DIV_15 (RCC_DCKCFGR_PLLI2SDIVR_3 | RCC_DCKCFGR_PLLI2SDIVR_2 | RCC_DCKCFGR_PLLI2SDIVR_1 | RCC_DCKCFGR_PLLI2SDIVR_0) /*!< PLLI2S division factor for PLLI2SDIVR output by 15 */ #define LL_RCC_PLLI2SDIVR_DIV_16 (RCC_DCKCFGR_PLLI2SDIVR_4) /*!< PLLI2S division factor for PLLI2SDIVR output by 16 */ #define LL_RCC_PLLI2SDIVR_DIV_17 (RCC_DCKCFGR_PLLI2SDIVR_4 | RCC_DCKCFGR_PLLI2SDIVR_0) /*!< PLLI2S division factor for PLLI2SDIVR output by 17 */ #define LL_RCC_PLLI2SDIVR_DIV_18 (RCC_DCKCFGR_PLLI2SDIVR_4 | RCC_DCKCFGR_PLLI2SDIVR_1) /*!< PLLI2S division factor for PLLI2SDIVR output by 18 */ #define LL_RCC_PLLI2SDIVR_DIV_19 (RCC_DCKCFGR_PLLI2SDIVR_4 | RCC_DCKCFGR_PLLI2SDIVR_1 | RCC_DCKCFGR_PLLI2SDIVR_0) /*!< PLLI2S division factor for PLLI2SDIVR output by 19 */ #define LL_RCC_PLLI2SDIVR_DIV_20 (RCC_DCKCFGR_PLLI2SDIVR_4 | RCC_DCKCFGR_PLLI2SDIVR_2) /*!< PLLI2S division factor for PLLI2SDIVR output by 20 */ #define LL_RCC_PLLI2SDIVR_DIV_21 (RCC_DCKCFGR_PLLI2SDIVR_4 | RCC_DCKCFGR_PLLI2SDIVR_2 | RCC_DCKCFGR_PLLI2SDIVR_0) /*!< PLLI2S division factor for PLLI2SDIVR output by 21 */ #define LL_RCC_PLLI2SDIVR_DIV_22 (RCC_DCKCFGR_PLLI2SDIVR_4 | RCC_DCKCFGR_PLLI2SDIVR_2 | RCC_DCKCFGR_PLLI2SDIVR_1) /*!< PLLI2S division factor for PLLI2SDIVR output by 22 */ #define LL_RCC_PLLI2SDIVR_DIV_23 (RCC_DCKCFGR_PLLI2SDIVR_4 | RCC_DCKCFGR_PLLI2SDIVR_2 | RCC_DCKCFGR_PLLI2SDIVR_1 | RCC_DCKCFGR_PLLI2SDIVR_0) /*!< PLLI2S division factor for PLLI2SDIVR output by 23 */ #define LL_RCC_PLLI2SDIVR_DIV_24 (RCC_DCKCFGR_PLLI2SDIVR_4 | RCC_DCKCFGR_PLLI2SDIVR_3) /*!< PLLI2S division factor for PLLI2SDIVR output by 24 */ #define LL_RCC_PLLI2SDIVR_DIV_25 (RCC_DCKCFGR_PLLI2SDIVR_4 | RCC_DCKCFGR_PLLI2SDIVR_3 | RCC_DCKCFGR_PLLI2SDIVR_0) /*!< PLLI2S division factor for PLLI2SDIVR output by 25 */ #define LL_RCC_PLLI2SDIVR_DIV_26 (RCC_DCKCFGR_PLLI2SDIVR_4 | RCC_DCKCFGR_PLLI2SDIVR_3 | RCC_DCKCFGR_PLLI2SDIVR_1) /*!< PLLI2S division factor for PLLI2SDIVR output by 26 */ #define LL_RCC_PLLI2SDIVR_DIV_27 (RCC_DCKCFGR_PLLI2SDIVR_4 | RCC_DCKCFGR_PLLI2SDIVR_3 | RCC_DCKCFGR_PLLI2SDIVR_1 | RCC_DCKCFGR_PLLI2SDIVR_0) /*!< PLLI2S division factor for PLLI2SDIVR output by 27 */ #define LL_RCC_PLLI2SDIVR_DIV_28 (RCC_DCKCFGR_PLLI2SDIVR_4 | RCC_DCKCFGR_PLLI2SDIVR_3 | RCC_DCKCFGR_PLLI2SDIVR_2) /*!< PLLI2S division factor for PLLI2SDIVR output by 28 */ #define LL_RCC_PLLI2SDIVR_DIV_29 (RCC_DCKCFGR_PLLI2SDIVR_4 | RCC_DCKCFGR_PLLI2SDIVR_3 | RCC_DCKCFGR_PLLI2SDIVR_2 | RCC_DCKCFGR_PLLI2SDIVR_0) /*!< PLLI2S division factor for PLLI2SDIVR output by 29 */ #define LL_RCC_PLLI2SDIVR_DIV_30 (RCC_DCKCFGR_PLLI2SDIVR_4 | RCC_DCKCFGR_PLLI2SDIVR_3 | RCC_DCKCFGR_PLLI2SDIVR_2 | RCC_DCKCFGR_PLLI2SDIVR_1) /*!< PLLI2S division factor for PLLI2SDIVR output by 30 */ #define LL_RCC_PLLI2SDIVR_DIV_31 (RCC_DCKCFGR_PLLI2SDIVR_4 | RCC_DCKCFGR_PLLI2SDIVR_3 | RCC_DCKCFGR_PLLI2SDIVR_2 | RCC_DCKCFGR_PLLI2SDIVR_1 | RCC_DCKCFGR_PLLI2SDIVR_0) /*!< PLLI2S division factor for PLLI2SDIVR output by 31 */ /** * @} */ #endif /* RCC_DCKCFGR_PLLI2SDIVR */ /** @defgroup RCC_LL_EC_PLLI2SR PLLI2SR division factor (PLLI2SR) * @{ */ #define LL_RCC_PLLI2SR_DIV_2 RCC_PLLI2SCFGR_PLLI2SR_1 /*!< PLLI2S division factor for PLLI2SR output by 2 */ #define LL_RCC_PLLI2SR_DIV_3 (RCC_PLLI2SCFGR_PLLI2SR_1 | RCC_PLLI2SCFGR_PLLI2SR_0) /*!< PLLI2S division factor for PLLI2SR output by 3 */ #define LL_RCC_PLLI2SR_DIV_4 RCC_PLLI2SCFGR_PLLI2SR_2 /*!< PLLI2S division factor for PLLI2SR output by 4 */ #define LL_RCC_PLLI2SR_DIV_5 (RCC_PLLI2SCFGR_PLLI2SR_2 | RCC_PLLI2SCFGR_PLLI2SR_0) /*!< PLLI2S division factor for PLLI2SR output by 5 */ #define LL_RCC_PLLI2SR_DIV_6 (RCC_PLLI2SCFGR_PLLI2SR_2 | RCC_PLLI2SCFGR_PLLI2SR_1) /*!< PLLI2S division factor for PLLI2SR output by 6 */ #define LL_RCC_PLLI2SR_DIV_7 (RCC_PLLI2SCFGR_PLLI2SR_2 | RCC_PLLI2SCFGR_PLLI2SR_1 | RCC_PLLI2SCFGR_PLLI2SR_0) /*!< PLLI2S division factor for PLLI2SR output by 7 */ /** * @} */ #if defined(RCC_PLLI2SCFGR_PLLI2SP) /** @defgroup RCC_LL_EC_PLLI2SP PLLI2SP division factor (PLLI2SP) * @{ */ #define LL_RCC_PLLI2SP_DIV_2 0x00000000U /*!< PLLI2S division factor for PLLI2SP output by 2 */ #define LL_RCC_PLLI2SP_DIV_4 RCC_PLLI2SCFGR_PLLI2SP_0 /*!< PLLI2S division factor for PLLI2SP output by 4 */ #define LL_RCC_PLLI2SP_DIV_6 RCC_PLLI2SCFGR_PLLI2SP_1 /*!< PLLI2S division factor for PLLI2SP output by 6 */ #define LL_RCC_PLLI2SP_DIV_8 (RCC_PLLI2SCFGR_PLLI2SP_1 | RCC_PLLI2SCFGR_PLLI2SP_0) /*!< PLLI2S division factor for PLLI2SP output by 8 */ /** * @} */ #endif /* RCC_PLLI2SCFGR_PLLI2SP */ #endif /* RCC_PLLI2S_SUPPORT */ #if defined(RCC_PLLSAI_SUPPORT) /** @defgroup RCC_LL_EC_PLLSAIM PLLSAIM division factor (PLLSAIM or PLLM) * @{ */ #if defined(RCC_PLLSAICFGR_PLLSAIM) #define LL_RCC_PLLSAIM_DIV_2 (RCC_PLLSAICFGR_PLLSAIM_1) /*!< PLLSAI division factor for PLLSAIM output by 2 */ #define LL_RCC_PLLSAIM_DIV_3 (RCC_PLLSAICFGR_PLLSAIM_1 | RCC_PLLSAICFGR_PLLSAIM_0) /*!< PLLSAI division factor for PLLSAIM output by 3 */ #define LL_RCC_PLLSAIM_DIV_4 (RCC_PLLSAICFGR_PLLSAIM_2) /*!< PLLSAI division factor for PLLSAIM output by 4 */ #define LL_RCC_PLLSAIM_DIV_5 (RCC_PLLSAICFGR_PLLSAIM_2 | RCC_PLLSAICFGR_PLLSAIM_0) /*!< PLLSAI division factor for PLLSAIM output by 5 */ #define LL_RCC_PLLSAIM_DIV_6 (RCC_PLLSAICFGR_PLLSAIM_2 | RCC_PLLSAICFGR_PLLSAIM_1) /*!< PLLSAI division factor for PLLSAIM output by 6 */ #define LL_RCC_PLLSAIM_DIV_7 (RCC_PLLSAICFGR_PLLSAIM_2 | RCC_PLLSAICFGR_PLLSAIM_1 | RCC_PLLSAICFGR_PLLSAIM_0) /*!< PLLSAI division factor for PLLSAIM output by 7 */ #define LL_RCC_PLLSAIM_DIV_8 (RCC_PLLSAICFGR_PLLSAIM_3) /*!< PLLSAI division factor for PLLSAIM output by 8 */ #define LL_RCC_PLLSAIM_DIV_9 (RCC_PLLSAICFGR_PLLSAIM_3 | RCC_PLLSAICFGR_PLLSAIM_0) /*!< PLLSAI division factor for PLLSAIM output by 9 */ #define LL_RCC_PLLSAIM_DIV_10 (RCC_PLLSAICFGR_PLLSAIM_3 | RCC_PLLSAICFGR_PLLSAIM_1) /*!< PLLSAI division factor for PLLSAIM output by 10 */ #define LL_RCC_PLLSAIM_DIV_11 (RCC_PLLSAICFGR_PLLSAIM_3 | RCC_PLLSAICFGR_PLLSAIM_1 | RCC_PLLSAICFGR_PLLSAIM_0) /*!< PLLSAI division factor for PLLSAIM output by 11 */ #define LL_RCC_PLLSAIM_DIV_12 (RCC_PLLSAICFGR_PLLSAIM_3 | RCC_PLLSAICFGR_PLLSAIM_2) /*!< PLLSAI division factor for PLLSAIM output by 12 */ #define LL_RCC_PLLSAIM_DIV_13 (RCC_PLLSAICFGR_PLLSAIM_3 | RCC_PLLSAICFGR_PLLSAIM_2 | RCC_PLLSAICFGR_PLLSAIM_0) /*!< PLLSAI division factor for PLLSAIM output by 13 */ #define LL_RCC_PLLSAIM_DIV_14 (RCC_PLLSAICFGR_PLLSAIM_3 | RCC_PLLSAICFGR_PLLSAIM_2 | RCC_PLLSAICFGR_PLLSAIM_1) /*!< PLLSAI division factor for PLLSAIM output by 14 */ #define LL_RCC_PLLSAIM_DIV_15 (RCC_PLLSAICFGR_PLLSAIM_3 | RCC_PLLSAICFGR_PLLSAIM_2 | RCC_PLLSAICFGR_PLLSAIM_1 | RCC_PLLSAICFGR_PLLSAIM_0) /*!< PLLSAI division factor for PLLSAIM output by 15 */ #define LL_RCC_PLLSAIM_DIV_16 (RCC_PLLSAICFGR_PLLSAIM_4) /*!< PLLSAI division factor for PLLSAIM output by 16 */ #define LL_RCC_PLLSAIM_DIV_17 (RCC_PLLSAICFGR_PLLSAIM_4 | RCC_PLLSAICFGR_PLLSAIM_0) /*!< PLLSAI division factor for PLLSAIM output by 17 */ #define LL_RCC_PLLSAIM_DIV_18 (RCC_PLLSAICFGR_PLLSAIM_4 | RCC_PLLSAICFGR_PLLSAIM_1) /*!< PLLSAI division factor for PLLSAIM output by 18 */ #define LL_RCC_PLLSAIM_DIV_19 (RCC_PLLSAICFGR_PLLSAIM_4 | RCC_PLLSAICFGR_PLLSAIM_1 | RCC_PLLSAICFGR_PLLSAIM_0) /*!< PLLSAI division factor for PLLSAIM output by 19 */ #define LL_RCC_PLLSAIM_DIV_20 (RCC_PLLSAICFGR_PLLSAIM_4 | RCC_PLLSAICFGR_PLLSAIM_2) /*!< PLLSAI division factor for PLLSAIM output by 20 */ #define LL_RCC_PLLSAIM_DIV_21 (RCC_PLLSAICFGR_PLLSAIM_4 | RCC_PLLSAICFGR_PLLSAIM_2 | RCC_PLLSAICFGR_PLLSAIM_0) /*!< PLLSAI division factor for PLLSAIM output by 21 */ #define LL_RCC_PLLSAIM_DIV_22 (RCC_PLLSAICFGR_PLLSAIM_4 | RCC_PLLSAICFGR_PLLSAIM_2 | RCC_PLLSAICFGR_PLLSAIM_1) /*!< PLLSAI division factor for PLLSAIM output by 22 */ #define LL_RCC_PLLSAIM_DIV_23 (RCC_PLLSAICFGR_PLLSAIM_4 | RCC_PLLSAICFGR_PLLSAIM_2 | RCC_PLLSAICFGR_PLLSAIM_1 | RCC_PLLSAICFGR_PLLSAIM_0) /*!< PLLSAI division factor for PLLSAIM output by 23 */ #define LL_RCC_PLLSAIM_DIV_24 (RCC_PLLSAICFGR_PLLSAIM_4 | RCC_PLLSAICFGR_PLLSAIM_3) /*!< PLLSAI division factor for PLLSAIM output by 24 */ #define LL_RCC_PLLSAIM_DIV_25 (RCC_PLLSAICFGR_PLLSAIM_4 | RCC_PLLSAICFGR_PLLSAIM_3 | RCC_PLLSAICFGR_PLLSAIM_0) /*!< PLLSAI division factor for PLLSAIM output by 25 */ #define LL_RCC_PLLSAIM_DIV_26 (RCC_PLLSAICFGR_PLLSAIM_4 | RCC_PLLSAICFGR_PLLSAIM_3 | RCC_PLLSAICFGR_PLLSAIM_1) /*!< PLLSAI division factor for PLLSAIM output by 26 */ #define LL_RCC_PLLSAIM_DIV_27 (RCC_PLLSAICFGR_PLLSAIM_4 | RCC_PLLSAICFGR_PLLSAIM_3 | RCC_PLLSAICFGR_PLLSAIM_1 | RCC_PLLSAICFGR_PLLSAIM_0) /*!< PLLSAI division factor for PLLSAIM output by 27 */ #define LL_RCC_PLLSAIM_DIV_28 (RCC_PLLSAICFGR_PLLSAIM_4 | RCC_PLLSAICFGR_PLLSAIM_3 | RCC_PLLSAICFGR_PLLSAIM_2) /*!< PLLSAI division factor for PLLSAIM output by 28 */ #define LL_RCC_PLLSAIM_DIV_29 (RCC_PLLSAICFGR_PLLSAIM_4 | RCC_PLLSAICFGR_PLLSAIM_3 | RCC_PLLSAICFGR_PLLSAIM_2 | RCC_PLLSAICFGR_PLLSAIM_0) /*!< PLLSAI division factor for PLLSAIM output by 29 */ #define LL_RCC_PLLSAIM_DIV_30 (RCC_PLLSAICFGR_PLLSAIM_4 | RCC_PLLSAICFGR_PLLSAIM_3 | RCC_PLLSAICFGR_PLLSAIM_2 | RCC_PLLSAICFGR_PLLSAIM_1) /*!< PLLSAI division factor for PLLSAIM output by 30 */ #define LL_RCC_PLLSAIM_DIV_31 (RCC_PLLSAICFGR_PLLSAIM_4 | RCC_PLLSAICFGR_PLLSAIM_3 | RCC_PLLSAICFGR_PLLSAIM_2 | RCC_PLLSAICFGR_PLLSAIM_1 | RCC_PLLSAICFGR_PLLSAIM_0) /*!< PLLSAI division factor for PLLSAIM output by 31 */ #define LL_RCC_PLLSAIM_DIV_32 (RCC_PLLSAICFGR_PLLSAIM_5) /*!< PLLSAI division factor for PLLSAIM output by 32 */ #define LL_RCC_PLLSAIM_DIV_33 (RCC_PLLSAICFGR_PLLSAIM_5 | RCC_PLLSAICFGR_PLLSAIM_0) /*!< PLLSAI division factor for PLLSAIM output by 33 */ #define LL_RCC_PLLSAIM_DIV_34 (RCC_PLLSAICFGR_PLLSAIM_5 | RCC_PLLSAICFGR_PLLSAIM_1) /*!< PLLSAI division factor for PLLSAIM output by 34 */ #define LL_RCC_PLLSAIM_DIV_35 (RCC_PLLSAICFGR_PLLSAIM_5 | RCC_PLLSAICFGR_PLLSAIM_1 | RCC_PLLSAICFGR_PLLSAIM_0) /*!< PLLSAI division factor for PLLSAIM output by 35 */ #define LL_RCC_PLLSAIM_DIV_36 (RCC_PLLSAICFGR_PLLSAIM_5 | RCC_PLLSAICFGR_PLLSAIM_2) /*!< PLLSAI division factor for PLLSAIM output by 36 */ #define LL_RCC_PLLSAIM_DIV_37 (RCC_PLLSAICFGR_PLLSAIM_5 | RCC_PLLSAICFGR_PLLSAIM_2 | RCC_PLLSAICFGR_PLLSAIM_0) /*!< PLLSAI division factor for PLLSAIM output by 37 */ #define LL_RCC_PLLSAIM_DIV_38 (RCC_PLLSAICFGR_PLLSAIM_5 | RCC_PLLSAICFGR_PLLSAIM_2 | RCC_PLLSAICFGR_PLLSAIM_1) /*!< PLLSAI division factor for PLLSAIM output by 38 */ #define LL_RCC_PLLSAIM_DIV_39 (RCC_PLLSAICFGR_PLLSAIM_5 | RCC_PLLSAICFGR_PLLSAIM_2 | RCC_PLLSAICFGR_PLLSAIM_1 | RCC_PLLSAICFGR_PLLSAIM_0) /*!< PLLSAI division factor for PLLSAIM output by 39 */ #define LL_RCC_PLLSAIM_DIV_40 (RCC_PLLSAICFGR_PLLSAIM_5 | RCC_PLLSAICFGR_PLLSAIM_3) /*!< PLLSAI division factor for PLLSAIM output by 40 */ #define LL_RCC_PLLSAIM_DIV_41 (RCC_PLLSAICFGR_PLLSAIM_5 | RCC_PLLSAICFGR_PLLSAIM_3 | RCC_PLLSAICFGR_PLLSAIM_0) /*!< PLLSAI division factor for PLLSAIM output by 41 */ #define LL_RCC_PLLSAIM_DIV_42 (RCC_PLLSAICFGR_PLLSAIM_5 | RCC_PLLSAICFGR_PLLSAIM_3 | RCC_PLLSAICFGR_PLLSAIM_1) /*!< PLLSAI division factor for PLLSAIM output by 42 */ #define LL_RCC_PLLSAIM_DIV_43 (RCC_PLLSAICFGR_PLLSAIM_5 | RCC_PLLSAICFGR_PLLSAIM_3 | RCC_PLLSAICFGR_PLLSAIM_1 | RCC_PLLSAICFGR_PLLSAIM_0) /*!< PLLSAI division factor for PLLSAIM output by 43 */ #define LL_RCC_PLLSAIM_DIV_44 (RCC_PLLSAICFGR_PLLSAIM_5 | RCC_PLLSAICFGR_PLLSAIM_3 | RCC_PLLSAICFGR_PLLSAIM_2) /*!< PLLSAI division factor for PLLSAIM output by 44 */ #define LL_RCC_PLLSAIM_DIV_45 (RCC_PLLSAICFGR_PLLSAIM_5 | RCC_PLLSAICFGR_PLLSAIM_3 | RCC_PLLSAICFGR_PLLSAIM_2 | RCC_PLLSAICFGR_PLLSAIM_0) /*!< PLLSAI division factor for PLLSAIM output by 45 */ #define LL_RCC_PLLSAIM_DIV_46 (RCC_PLLSAICFGR_PLLSAIM_5 | RCC_PLLSAICFGR_PLLSAIM_3 | RCC_PLLSAICFGR_PLLSAIM_2 | RCC_PLLSAICFGR_PLLSAIM_1) /*!< PLLSAI division factor for PLLSAIM output by 46 */ #define LL_RCC_PLLSAIM_DIV_47 (RCC_PLLSAICFGR_PLLSAIM_5 | RCC_PLLSAICFGR_PLLSAIM_3 | RCC_PLLSAICFGR_PLLSAIM_2 | RCC_PLLSAICFGR_PLLSAIM_1 | RCC_PLLSAICFGR_PLLSAIM_0) /*!< PLLSAI division factor for PLLSAIM output by 47 */ #define LL_RCC_PLLSAIM_DIV_48 (RCC_PLLSAICFGR_PLLSAIM_5 | RCC_PLLSAICFGR_PLLSAIM_4) /*!< PLLSAI division factor for PLLSAIM output by 48 */ #define LL_RCC_PLLSAIM_DIV_49 (RCC_PLLSAICFGR_PLLSAIM_5 | RCC_PLLSAICFGR_PLLSAIM_4 | RCC_PLLSAICFGR_PLLSAIM_0) /*!< PLLSAI division factor for PLLSAIM output by 49 */ #define LL_RCC_PLLSAIM_DIV_50 (RCC_PLLSAICFGR_PLLSAIM_5 | RCC_PLLSAICFGR_PLLSAIM_4 | RCC_PLLSAICFGR_PLLSAIM_1) /*!< PLLSAI division factor for PLLSAIM output by 50 */ #define LL_RCC_PLLSAIM_DIV_51 (RCC_PLLSAICFGR_PLLSAIM_5 | RCC_PLLSAICFGR_PLLSAIM_4 | RCC_PLLSAICFGR_PLLSAIM_1 | RCC_PLLSAICFGR_PLLSAIM_0) /*!< PLLSAI division factor for PLLSAIM output by 51 */ #define LL_RCC_PLLSAIM_DIV_52 (RCC_PLLSAICFGR_PLLSAIM_5 | RCC_PLLSAICFGR_PLLSAIM_4 | RCC_PLLSAICFGR_PLLSAIM_2) /*!< PLLSAI division factor for PLLSAIM output by 52 */ #define LL_RCC_PLLSAIM_DIV_53 (RCC_PLLSAICFGR_PLLSAIM_5 | RCC_PLLSAICFGR_PLLSAIM_4 | RCC_PLLSAICFGR_PLLSAIM_2 | RCC_PLLSAICFGR_PLLSAIM_0) /*!< PLLSAI division factor for PLLSAIM output by 53 */ #define LL_RCC_PLLSAIM_DIV_54 (RCC_PLLSAICFGR_PLLSAIM_5 | RCC_PLLSAICFGR_PLLSAIM_4 | RCC_PLLSAICFGR_PLLSAIM_2 | RCC_PLLSAICFGR_PLLSAIM_1) /*!< PLLSAI division factor for PLLSAIM output by 54 */ #define LL_RCC_PLLSAIM_DIV_55 (RCC_PLLSAICFGR_PLLSAIM_5 | RCC_PLLSAICFGR_PLLSAIM_4 | RCC_PLLSAICFGR_PLLSAIM_2 | RCC_PLLSAICFGR_PLLSAIM_1 | RCC_PLLSAICFGR_PLLSAIM_0) /*!< PLLSAI division factor for PLLSAIM output by 55 */ #define LL_RCC_PLLSAIM_DIV_56 (RCC_PLLSAICFGR_PLLSAIM_5 | RCC_PLLSAICFGR_PLLSAIM_4 | RCC_PLLSAICFGR_PLLSAIM_3) /*!< PLLSAI division factor for PLLSAIM output by 56 */ #define LL_RCC_PLLSAIM_DIV_57 (RCC_PLLSAICFGR_PLLSAIM_5 | RCC_PLLSAICFGR_PLLSAIM_4 | RCC_PLLSAICFGR_PLLSAIM_3 | RCC_PLLSAICFGR_PLLSAIM_0) /*!< PLLSAI division factor for PLLSAIM output by 57 */ #define LL_RCC_PLLSAIM_DIV_58 (RCC_PLLSAICFGR_PLLSAIM_5 | RCC_PLLSAICFGR_PLLSAIM_4 | RCC_PLLSAICFGR_PLLSAIM_3 | RCC_PLLSAICFGR_PLLSAIM_1) /*!< PLLSAI division factor for PLLSAIM output by 58 */ #define LL_RCC_PLLSAIM_DIV_59 (RCC_PLLSAICFGR_PLLSAIM_5 | RCC_PLLSAICFGR_PLLSAIM_4 | RCC_PLLSAICFGR_PLLSAIM_3 | RCC_PLLSAICFGR_PLLSAIM_1 | RCC_PLLSAICFGR_PLLSAIM_0) /*!< PLLSAI division factor for PLLSAIM output by 59 */ #define LL_RCC_PLLSAIM_DIV_60 (RCC_PLLSAICFGR_PLLSAIM_5 | RCC_PLLSAICFGR_PLLSAIM_4 | RCC_PLLSAICFGR_PLLSAIM_3 | RCC_PLLSAICFGR_PLLSAIM_2) /*!< PLLSAI division factor for PLLSAIM output by 60 */ #define LL_RCC_PLLSAIM_DIV_61 (RCC_PLLSAICFGR_PLLSAIM_5 | RCC_PLLSAICFGR_PLLSAIM_4 | RCC_PLLSAICFGR_PLLSAIM_3 | RCC_PLLSAICFGR_PLLSAIM_2 | RCC_PLLSAICFGR_PLLSAIM_0) /*!< PLLSAI division factor for PLLSAIM output by 61 */ #define LL_RCC_PLLSAIM_DIV_62 (RCC_PLLSAICFGR_PLLSAIM_5 | RCC_PLLSAICFGR_PLLSAIM_4 | RCC_PLLSAICFGR_PLLSAIM_3 | RCC_PLLSAICFGR_PLLSAIM_2 | RCC_PLLSAICFGR_PLLSAIM_1) /*!< PLLSAI division factor for PLLSAIM output by 62 */ #define LL_RCC_PLLSAIM_DIV_63 (RCC_PLLSAICFGR_PLLSAIM_5 | RCC_PLLSAICFGR_PLLSAIM_4 | RCC_PLLSAICFGR_PLLSAIM_3 | RCC_PLLSAICFGR_PLLSAIM_2 | RCC_PLLSAICFGR_PLLSAIM_1 | RCC_PLLSAICFGR_PLLSAIM_0) /*!< PLLSAI division factor for PLLSAIM output by 63 */ #else #define LL_RCC_PLLSAIM_DIV_2 LL_RCC_PLLM_DIV_2 /*!< PLLSAI division factor for PLLSAIM output by 2 */ #define LL_RCC_PLLSAIM_DIV_3 LL_RCC_PLLM_DIV_3 /*!< PLLSAI division factor for PLLSAIM output by 3 */ #define LL_RCC_PLLSAIM_DIV_4 LL_RCC_PLLM_DIV_4 /*!< PLLSAI division factor for PLLSAIM output by 4 */ #define LL_RCC_PLLSAIM_DIV_5 LL_RCC_PLLM_DIV_5 /*!< PLLSAI division factor for PLLSAIM output by 5 */ #define LL_RCC_PLLSAIM_DIV_6 LL_RCC_PLLM_DIV_6 /*!< PLLSAI division factor for PLLSAIM output by 6 */ #define LL_RCC_PLLSAIM_DIV_7 LL_RCC_PLLM_DIV_7 /*!< PLLSAI division factor for PLLSAIM output by 7 */ #define LL_RCC_PLLSAIM_DIV_8 LL_RCC_PLLM_DIV_8 /*!< PLLSAI division factor for PLLSAIM output by 8 */ #define LL_RCC_PLLSAIM_DIV_9 LL_RCC_PLLM_DIV_9 /*!< PLLSAI division factor for PLLSAIM output by 9 */ #define LL_RCC_PLLSAIM_DIV_10 LL_RCC_PLLM_DIV_10 /*!< PLLSAI division factor for PLLSAIM output by 10 */ #define LL_RCC_PLLSAIM_DIV_11 LL_RCC_PLLM_DIV_11 /*!< PLLSAI division factor for PLLSAIM output by 11 */ #define LL_RCC_PLLSAIM_DIV_12 LL_RCC_PLLM_DIV_12 /*!< PLLSAI division factor for PLLSAIM output by 12 */ #define LL_RCC_PLLSAIM_DIV_13 LL_RCC_PLLM_DIV_13 /*!< PLLSAI division factor for PLLSAIM output by 13 */ #define LL_RCC_PLLSAIM_DIV_14 LL_RCC_PLLM_DIV_14 /*!< PLLSAI division factor for PLLSAIM output by 14 */ #define LL_RCC_PLLSAIM_DIV_15 LL_RCC_PLLM_DIV_15 /*!< PLLSAI division factor for PLLSAIM output by 15 */ #define LL_RCC_PLLSAIM_DIV_16 LL_RCC_PLLM_DIV_16 /*!< PLLSAI division factor for PLLSAIM output by 16 */ #define LL_RCC_PLLSAIM_DIV_17 LL_RCC_PLLM_DIV_17 /*!< PLLSAI division factor for PLLSAIM output by 17 */ #define LL_RCC_PLLSAIM_DIV_18 LL_RCC_PLLM_DIV_18 /*!< PLLSAI division factor for PLLSAIM output by 18 */ #define LL_RCC_PLLSAIM_DIV_19 LL_RCC_PLLM_DIV_19 /*!< PLLSAI division factor for PLLSAIM output by 19 */ #define LL_RCC_PLLSAIM_DIV_20 LL_RCC_PLLM_DIV_20 /*!< PLLSAI division factor for PLLSAIM output by 20 */ #define LL_RCC_PLLSAIM_DIV_21 LL_RCC_PLLM_DIV_21 /*!< PLLSAI division factor for PLLSAIM output by 21 */ #define LL_RCC_PLLSAIM_DIV_22 LL_RCC_PLLM_DIV_22 /*!< PLLSAI division factor for PLLSAIM output by 22 */ #define LL_RCC_PLLSAIM_DIV_23 LL_RCC_PLLM_DIV_23 /*!< PLLSAI division factor for PLLSAIM output by 23 */ #define LL_RCC_PLLSAIM_DIV_24 LL_RCC_PLLM_DIV_24 /*!< PLLSAI division factor for PLLSAIM output by 24 */ #define LL_RCC_PLLSAIM_DIV_25 LL_RCC_PLLM_DIV_25 /*!< PLLSAI division factor for PLLSAIM output by 25 */ #define LL_RCC_PLLSAIM_DIV_26 LL_RCC_PLLM_DIV_26 /*!< PLLSAI division factor for PLLSAIM output by 26 */ #define LL_RCC_PLLSAIM_DIV_27 LL_RCC_PLLM_DIV_27 /*!< PLLSAI division factor for PLLSAIM output by 27 */ #define LL_RCC_PLLSAIM_DIV_28 LL_RCC_PLLM_DIV_28 /*!< PLLSAI division factor for PLLSAIM output by 28 */ #define LL_RCC_PLLSAIM_DIV_29 LL_RCC_PLLM_DIV_29 /*!< PLLSAI division factor for PLLSAIM output by 29 */ #define LL_RCC_PLLSAIM_DIV_30 LL_RCC_PLLM_DIV_30 /*!< PLLSAI division factor for PLLSAIM output by 30 */ #define LL_RCC_PLLSAIM_DIV_31 LL_RCC_PLLM_DIV_31 /*!< PLLSAI division factor for PLLSAIM output by 31 */ #define LL_RCC_PLLSAIM_DIV_32 LL_RCC_PLLM_DIV_32 /*!< PLLSAI division factor for PLLSAIM output by 32 */ #define LL_RCC_PLLSAIM_DIV_33 LL_RCC_PLLM_DIV_33 /*!< PLLSAI division factor for PLLSAIM output by 33 */ #define LL_RCC_PLLSAIM_DIV_34 LL_RCC_PLLM_DIV_34 /*!< PLLSAI division factor for PLLSAIM output by 34 */ #define LL_RCC_PLLSAIM_DIV_35 LL_RCC_PLLM_DIV_35 /*!< PLLSAI division factor for PLLSAIM output by 35 */ #define LL_RCC_PLLSAIM_DIV_36 LL_RCC_PLLM_DIV_36 /*!< PLLSAI division factor for PLLSAIM output by 36 */ #define LL_RCC_PLLSAIM_DIV_37 LL_RCC_PLLM_DIV_37 /*!< PLLSAI division factor for PLLSAIM output by 37 */ #define LL_RCC_PLLSAIM_DIV_38 LL_RCC_PLLM_DIV_38 /*!< PLLSAI division factor for PLLSAIM output by 38 */ #define LL_RCC_PLLSAIM_DIV_39 LL_RCC_PLLM_DIV_39 /*!< PLLSAI division factor for PLLSAIM output by 39 */ #define LL_RCC_PLLSAIM_DIV_40 LL_RCC_PLLM_DIV_40 /*!< PLLSAI division factor for PLLSAIM output by 40 */ #define LL_RCC_PLLSAIM_DIV_41 LL_RCC_PLLM_DIV_41 /*!< PLLSAI division factor for PLLSAIM output by 41 */ #define LL_RCC_PLLSAIM_DIV_42 LL_RCC_PLLM_DIV_42 /*!< PLLSAI division factor for PLLSAIM output by 42 */ #define LL_RCC_PLLSAIM_DIV_43 LL_RCC_PLLM_DIV_43 /*!< PLLSAI division factor for PLLSAIM output by 43 */ #define LL_RCC_PLLSAIM_DIV_44 LL_RCC_PLLM_DIV_44 /*!< PLLSAI division factor for PLLSAIM output by 44 */ #define LL_RCC_PLLSAIM_DIV_45 LL_RCC_PLLM_DIV_45 /*!< PLLSAI division factor for PLLSAIM output by 45 */ #define LL_RCC_PLLSAIM_DIV_46 LL_RCC_PLLM_DIV_46 /*!< PLLSAI division factor for PLLSAIM output by 46 */ #define LL_RCC_PLLSAIM_DIV_47 LL_RCC_PLLM_DIV_47 /*!< PLLSAI division factor for PLLSAIM output by 47 */ #define LL_RCC_PLLSAIM_DIV_48 LL_RCC_PLLM_DIV_48 /*!< PLLSAI division factor for PLLSAIM output by 48 */ #define LL_RCC_PLLSAIM_DIV_49 LL_RCC_PLLM_DIV_49 /*!< PLLSAI division factor for PLLSAIM output by 49 */ #define LL_RCC_PLLSAIM_DIV_50 LL_RCC_PLLM_DIV_50 /*!< PLLSAI division factor for PLLSAIM output by 50 */ #define LL_RCC_PLLSAIM_DIV_51 LL_RCC_PLLM_DIV_51 /*!< PLLSAI division factor for PLLSAIM output by 51 */ #define LL_RCC_PLLSAIM_DIV_52 LL_RCC_PLLM_DIV_52 /*!< PLLSAI division factor for PLLSAIM output by 52 */ #define LL_RCC_PLLSAIM_DIV_53 LL_RCC_PLLM_DIV_53 /*!< PLLSAI division factor for PLLSAIM output by 53 */ #define LL_RCC_PLLSAIM_DIV_54 LL_RCC_PLLM_DIV_54 /*!< PLLSAI division factor for PLLSAIM output by 54 */ #define LL_RCC_PLLSAIM_DIV_55 LL_RCC_PLLM_DIV_55 /*!< PLLSAI division factor for PLLSAIM output by 55 */ #define LL_RCC_PLLSAIM_DIV_56 LL_RCC_PLLM_DIV_56 /*!< PLLSAI division factor for PLLSAIM output by 56 */ #define LL_RCC_PLLSAIM_DIV_57 LL_RCC_PLLM_DIV_57 /*!< PLLSAI division factor for PLLSAIM output by 57 */ #define LL_RCC_PLLSAIM_DIV_58 LL_RCC_PLLM_DIV_58 /*!< PLLSAI division factor for PLLSAIM output by 58 */ #define LL_RCC_PLLSAIM_DIV_59 LL_RCC_PLLM_DIV_59 /*!< PLLSAI division factor for PLLSAIM output by 59 */ #define LL_RCC_PLLSAIM_DIV_60 LL_RCC_PLLM_DIV_60 /*!< PLLSAI division factor for PLLSAIM output by 60 */ #define LL_RCC_PLLSAIM_DIV_61 LL_RCC_PLLM_DIV_61 /*!< PLLSAI division factor for PLLSAIM output by 61 */ #define LL_RCC_PLLSAIM_DIV_62 LL_RCC_PLLM_DIV_62 /*!< PLLSAI division factor for PLLSAIM output by 62 */ #define LL_RCC_PLLSAIM_DIV_63 LL_RCC_PLLM_DIV_63 /*!< PLLSAI division factor for PLLSAIM output by 63 */ #endif /* RCC_PLLSAICFGR_PLLSAIM */ /** * @} */ /** @defgroup RCC_LL_EC_PLLSAIQ PLLSAIQ division factor (PLLSAIQ) * @{ */ #define LL_RCC_PLLSAIQ_DIV_2 RCC_PLLSAICFGR_PLLSAIQ_1 /*!< PLLSAI division factor for PLLSAIQ output by 2 */ #define LL_RCC_PLLSAIQ_DIV_3 (RCC_PLLSAICFGR_PLLSAIQ_1 | RCC_PLLSAICFGR_PLLSAIQ_0) /*!< PLLSAI division factor for PLLSAIQ output by 3 */ #define LL_RCC_PLLSAIQ_DIV_4 RCC_PLLSAICFGR_PLLSAIQ_2 /*!< PLLSAI division factor for PLLSAIQ output by 4 */ #define LL_RCC_PLLSAIQ_DIV_5 (RCC_PLLSAICFGR_PLLSAIQ_2 | RCC_PLLSAICFGR_PLLSAIQ_0) /*!< PLLSAI division factor for PLLSAIQ output by 5 */ #define LL_RCC_PLLSAIQ_DIV_6 (RCC_PLLSAICFGR_PLLSAIQ_2 | RCC_PLLSAICFGR_PLLSAIQ_1) /*!< PLLSAI division factor for PLLSAIQ output by 6 */ #define LL_RCC_PLLSAIQ_DIV_7 (RCC_PLLSAICFGR_PLLSAIQ_2 | RCC_PLLSAICFGR_PLLSAIQ_1 | RCC_PLLSAICFGR_PLLSAIQ_0) /*!< PLLSAI division factor for PLLSAIQ output by 7 */ #define LL_RCC_PLLSAIQ_DIV_8 RCC_PLLSAICFGR_PLLSAIQ_3 /*!< PLLSAI division factor for PLLSAIQ output by 8 */ #define LL_RCC_PLLSAIQ_DIV_9 (RCC_PLLSAICFGR_PLLSAIQ_3 | RCC_PLLSAICFGR_PLLSAIQ_0) /*!< PLLSAI division factor for PLLSAIQ output by 9 */ #define LL_RCC_PLLSAIQ_DIV_10 (RCC_PLLSAICFGR_PLLSAIQ_3 | RCC_PLLSAICFGR_PLLSAIQ_1) /*!< PLLSAI division factor for PLLSAIQ output by 10 */ #define LL_RCC_PLLSAIQ_DIV_11 (RCC_PLLSAICFGR_PLLSAIQ_3 | RCC_PLLSAICFGR_PLLSAIQ_1 | RCC_PLLSAICFGR_PLLSAIQ_0) /*!< PLLSAI division factor for PLLSAIQ output by 11 */ #define LL_RCC_PLLSAIQ_DIV_12 (RCC_PLLSAICFGR_PLLSAIQ_3 | RCC_PLLSAICFGR_PLLSAIQ_2) /*!< PLLSAI division factor for PLLSAIQ output by 12 */ #define LL_RCC_PLLSAIQ_DIV_13 (RCC_PLLSAICFGR_PLLSAIQ_3 | RCC_PLLSAICFGR_PLLSAIQ_2 | RCC_PLLSAICFGR_PLLSAIQ_0) /*!< PLLSAI division factor for PLLSAIQ output by 13 */ #define LL_RCC_PLLSAIQ_DIV_14 (RCC_PLLSAICFGR_PLLSAIQ_3 | RCC_PLLSAICFGR_PLLSAIQ_2 | RCC_PLLSAICFGR_PLLSAIQ_1) /*!< PLLSAI division factor for PLLSAIQ output by 14 */ #define LL_RCC_PLLSAIQ_DIV_15 (RCC_PLLSAICFGR_PLLSAIQ_3 | RCC_PLLSAICFGR_PLLSAIQ_2 | RCC_PLLSAICFGR_PLLSAIQ_1 | RCC_PLLSAICFGR_PLLSAIQ_0) /*!< PLLSAI division factor for PLLSAIQ output by 15 */ /** * @} */ #if defined(RCC_DCKCFGR_PLLSAIDIVQ) /** @defgroup RCC_LL_EC_PLLSAIDIVQ PLLSAIDIVQ division factor (PLLSAIDIVQ) * @{ */ #define LL_RCC_PLLSAIDIVQ_DIV_1 0x00000000U /*!< PLLSAI division factor for PLLSAIDIVQ output by 1 */ #define LL_RCC_PLLSAIDIVQ_DIV_2 RCC_DCKCFGR_PLLSAIDIVQ_0 /*!< PLLSAI division factor for PLLSAIDIVQ output by 2 */ #define LL_RCC_PLLSAIDIVQ_DIV_3 RCC_DCKCFGR_PLLSAIDIVQ_1 /*!< PLLSAI division factor for PLLSAIDIVQ output by 3 */ #define LL_RCC_PLLSAIDIVQ_DIV_4 (RCC_DCKCFGR_PLLSAIDIVQ_1 | RCC_DCKCFGR_PLLSAIDIVQ_0) /*!< PLLSAI division factor for PLLSAIDIVQ output by 4 */ #define LL_RCC_PLLSAIDIVQ_DIV_5 RCC_DCKCFGR_PLLSAIDIVQ_2 /*!< PLLSAI division factor for PLLSAIDIVQ output by 5 */ #define LL_RCC_PLLSAIDIVQ_DIV_6 (RCC_DCKCFGR_PLLSAIDIVQ_2 | RCC_DCKCFGR_PLLSAIDIVQ_0) /*!< PLLSAI division factor for PLLSAIDIVQ output by 6 */ #define LL_RCC_PLLSAIDIVQ_DIV_7 (RCC_DCKCFGR_PLLSAIDIVQ_2 | RCC_DCKCFGR_PLLSAIDIVQ_1) /*!< PLLSAI division factor for PLLSAIDIVQ output by 7 */ #define LL_RCC_PLLSAIDIVQ_DIV_8 (RCC_DCKCFGR_PLLSAIDIVQ_2 | RCC_DCKCFGR_PLLSAIDIVQ_1 | RCC_DCKCFGR_PLLSAIDIVQ_0) /*!< PLLSAI division factor for PLLSAIDIVQ output by 8 */ #define LL_RCC_PLLSAIDIVQ_DIV_9 RCC_DCKCFGR_PLLSAIDIVQ_3 /*!< PLLSAI division factor for PLLSAIDIVQ output by 9 */ #define LL_RCC_PLLSAIDIVQ_DIV_10 (RCC_DCKCFGR_PLLSAIDIVQ_3 | RCC_DCKCFGR_PLLSAIDIVQ_0) /*!< PLLSAI division factor for PLLSAIDIVQ output by 10 */ #define LL_RCC_PLLSAIDIVQ_DIV_11 (RCC_DCKCFGR_PLLSAIDIVQ_3 | RCC_DCKCFGR_PLLSAIDIVQ_1) /*!< PLLSAI division factor for PLLSAIDIVQ output by 11 */ #define LL_RCC_PLLSAIDIVQ_DIV_12 (RCC_DCKCFGR_PLLSAIDIVQ_3 | RCC_DCKCFGR_PLLSAIDIVQ_1 | RCC_DCKCFGR_PLLSAIDIVQ_0) /*!< PLLSAI division factor for PLLSAIDIVQ output by 12 */ #define LL_RCC_PLLSAIDIVQ_DIV_13 (RCC_DCKCFGR_PLLSAIDIVQ_3 | RCC_DCKCFGR_PLLSAIDIVQ_2) /*!< PLLSAI division factor for PLLSAIDIVQ output by 13 */ #define LL_RCC_PLLSAIDIVQ_DIV_14 (RCC_DCKCFGR_PLLSAIDIVQ_3 | RCC_DCKCFGR_PLLSAIDIVQ_2 | RCC_DCKCFGR_PLLSAIDIVQ_0) /*!< PLLSAI division factor for PLLSAIDIVQ output by 14 */ #define LL_RCC_PLLSAIDIVQ_DIV_15 (RCC_DCKCFGR_PLLSAIDIVQ_3 | RCC_DCKCFGR_PLLSAIDIVQ_2 | RCC_DCKCFGR_PLLSAIDIVQ_1) /*!< PLLSAI division factor for PLLSAIDIVQ output by 15 */ #define LL_RCC_PLLSAIDIVQ_DIV_16 (RCC_DCKCFGR_PLLSAIDIVQ_3 | RCC_DCKCFGR_PLLSAIDIVQ_2 | RCC_DCKCFGR_PLLSAIDIVQ_1 | RCC_DCKCFGR_PLLSAIDIVQ_0) /*!< PLLSAI division factor for PLLSAIDIVQ output by 16 */ #define LL_RCC_PLLSAIDIVQ_DIV_17 RCC_DCKCFGR_PLLSAIDIVQ_4 /*!< PLLSAI division factor for PLLSAIDIVQ output by 17 */ #define LL_RCC_PLLSAIDIVQ_DIV_18 (RCC_DCKCFGR_PLLSAIDIVQ_4 | RCC_DCKCFGR_PLLSAIDIVQ_0) /*!< PLLSAI division factor for PLLSAIDIVQ output by 18 */ #define LL_RCC_PLLSAIDIVQ_DIV_19 (RCC_DCKCFGR_PLLSAIDIVQ_4 | RCC_DCKCFGR_PLLSAIDIVQ_1) /*!< PLLSAI division factor for PLLSAIDIVQ output by 19 */ #define LL_RCC_PLLSAIDIVQ_DIV_20 (RCC_DCKCFGR_PLLSAIDIVQ_4 | RCC_DCKCFGR_PLLSAIDIVQ_1 | RCC_DCKCFGR_PLLSAIDIVQ_0) /*!< PLLSAI division factor for PLLSAIDIVQ output by 20 */ #define LL_RCC_PLLSAIDIVQ_DIV_21 (RCC_DCKCFGR_PLLSAIDIVQ_4 | RCC_DCKCFGR_PLLSAIDIVQ_2) /*!< PLLSAI division factor for PLLSAIDIVQ output by 21 */ #define LL_RCC_PLLSAIDIVQ_DIV_22 (RCC_DCKCFGR_PLLSAIDIVQ_4 | RCC_DCKCFGR_PLLSAIDIVQ_2 | RCC_DCKCFGR_PLLSAIDIVQ_0) /*!< PLLSAI division factor for PLLSAIDIVQ output by 22 */ #define LL_RCC_PLLSAIDIVQ_DIV_23 (RCC_DCKCFGR_PLLSAIDIVQ_4 | RCC_DCKCFGR_PLLSAIDIVQ_2 | RCC_DCKCFGR_PLLSAIDIVQ_1) /*!< PLLSAI division factor for PLLSAIDIVQ output by 23 */ #define LL_RCC_PLLSAIDIVQ_DIV_24 (RCC_DCKCFGR_PLLSAIDIVQ_4 | RCC_DCKCFGR_PLLSAIDIVQ_2 | RCC_DCKCFGR_PLLSAIDIVQ_1 | RCC_DCKCFGR_PLLSAIDIVQ_0) /*!< PLLSAI division factor for PLLSAIDIVQ output by 24 */ #define LL_RCC_PLLSAIDIVQ_DIV_25 (RCC_DCKCFGR_PLLSAIDIVQ_4 | RCC_DCKCFGR_PLLSAIDIVQ_3) /*!< PLLSAI division factor for PLLSAIDIVQ output by 25 */ #define LL_RCC_PLLSAIDIVQ_DIV_26 (RCC_DCKCFGR_PLLSAIDIVQ_4 | RCC_DCKCFGR_PLLSAIDIVQ_3 | RCC_DCKCFGR_PLLSAIDIVQ_0) /*!< PLLSAI division factor for PLLSAIDIVQ output by 26 */ #define LL_RCC_PLLSAIDIVQ_DIV_27 (RCC_DCKCFGR_PLLSAIDIVQ_4 | RCC_DCKCFGR_PLLSAIDIVQ_3 | RCC_DCKCFGR_PLLSAIDIVQ_1) /*!< PLLSAI division factor for PLLSAIDIVQ output by 27 */ #define LL_RCC_PLLSAIDIVQ_DIV_28 (RCC_DCKCFGR_PLLSAIDIVQ_4 | RCC_DCKCFGR_PLLSAIDIVQ_3 | RCC_DCKCFGR_PLLSAIDIVQ_1 | RCC_DCKCFGR_PLLSAIDIVQ_0) /*!< PLLSAI division factor for PLLSAIDIVQ output by 28 */ #define LL_RCC_PLLSAIDIVQ_DIV_29 (RCC_DCKCFGR_PLLSAIDIVQ_4 | RCC_DCKCFGR_PLLSAIDIVQ_3 | RCC_DCKCFGR_PLLSAIDIVQ_2) /*!< PLLSAI division factor for PLLSAIDIVQ output by 29 */ #define LL_RCC_PLLSAIDIVQ_DIV_30 (RCC_DCKCFGR_PLLSAIDIVQ_4 | RCC_DCKCFGR_PLLSAIDIVQ_3 | RCC_DCKCFGR_PLLSAIDIVQ_2 | RCC_DCKCFGR_PLLSAIDIVQ_0) /*!< PLLSAI division factor for PLLSAIDIVQ output by 30 */ #define LL_RCC_PLLSAIDIVQ_DIV_31 (RCC_DCKCFGR_PLLSAIDIVQ_4 | RCC_DCKCFGR_PLLSAIDIVQ_3 | RCC_DCKCFGR_PLLSAIDIVQ_2 | RCC_DCKCFGR_PLLSAIDIVQ_1) /*!< PLLSAI division factor for PLLSAIDIVQ output by 31 */ #define LL_RCC_PLLSAIDIVQ_DIV_32 (RCC_DCKCFGR_PLLSAIDIVQ_4 | RCC_DCKCFGR_PLLSAIDIVQ_3 | RCC_DCKCFGR_PLLSAIDIVQ_2 | RCC_DCKCFGR_PLLSAIDIVQ_1 | RCC_DCKCFGR_PLLSAIDIVQ_0) /*!< PLLSAI division factor for PLLSAIDIVQ output by 32 */ /** * @} */ #endif /* RCC_DCKCFGR_PLLSAIDIVQ */ #if defined(RCC_PLLSAICFGR_PLLSAIR) /** @defgroup RCC_LL_EC_PLLSAIR PLLSAIR division factor (PLLSAIR) * @{ */ #define LL_RCC_PLLSAIR_DIV_2 RCC_PLLSAICFGR_PLLSAIR_1 /*!< PLLSAI division factor for PLLSAIR output by 2 */ #define LL_RCC_PLLSAIR_DIV_3 (RCC_PLLSAICFGR_PLLSAIR_1 | RCC_PLLSAICFGR_PLLSAIR_0) /*!< PLLSAI division factor for PLLSAIR output by 3 */ #define LL_RCC_PLLSAIR_DIV_4 RCC_PLLSAICFGR_PLLSAIR_2 /*!< PLLSAI division factor for PLLSAIR output by 4 */ #define LL_RCC_PLLSAIR_DIV_5 (RCC_PLLSAICFGR_PLLSAIR_2 | RCC_PLLSAICFGR_PLLSAIR_0) /*!< PLLSAI division factor for PLLSAIR output by 5 */ #define LL_RCC_PLLSAIR_DIV_6 (RCC_PLLSAICFGR_PLLSAIR_2 | RCC_PLLSAICFGR_PLLSAIR_1) /*!< PLLSAI division factor for PLLSAIR output by 6 */ #define LL_RCC_PLLSAIR_DIV_7 (RCC_PLLSAICFGR_PLLSAIR_2 | RCC_PLLSAICFGR_PLLSAIR_1 | RCC_PLLSAICFGR_PLLSAIR_0) /*!< PLLSAI division factor for PLLSAIR output by 7 */ /** * @} */ #endif /* RCC_PLLSAICFGR_PLLSAIR */ #if defined(RCC_DCKCFGR_PLLSAIDIVR) /** @defgroup RCC_LL_EC_PLLSAIDIVR PLLSAIDIVR division factor (PLLSAIDIVR) * @{ */ #define LL_RCC_PLLSAIDIVR_DIV_2 0x00000000U /*!< PLLSAI division factor for PLLSAIDIVR output by 2 */ #define LL_RCC_PLLSAIDIVR_DIV_4 RCC_DCKCFGR_PLLSAIDIVR_0 /*!< PLLSAI division factor for PLLSAIDIVR output by 4 */ #define LL_RCC_PLLSAIDIVR_DIV_8 RCC_DCKCFGR_PLLSAIDIVR_1 /*!< PLLSAI division factor for PLLSAIDIVR output by 8 */ #define LL_RCC_PLLSAIDIVR_DIV_16 (RCC_DCKCFGR_PLLSAIDIVR_1 | RCC_DCKCFGR_PLLSAIDIVR_0) /*!< PLLSAI division factor for PLLSAIDIVR output by 16 */ /** * @} */ #endif /* RCC_DCKCFGR_PLLSAIDIVR */ #if defined(RCC_PLLSAICFGR_PLLSAIP) /** @defgroup RCC_LL_EC_PLLSAIP PLLSAIP division factor (PLLSAIP) * @{ */ #define LL_RCC_PLLSAIP_DIV_2 0x00000000U /*!< PLLSAI division factor for PLLSAIP output by 2 */ #define LL_RCC_PLLSAIP_DIV_4 RCC_PLLSAICFGR_PLLSAIP_0 /*!< PLLSAI division factor for PLLSAIP output by 4 */ #define LL_RCC_PLLSAIP_DIV_6 RCC_PLLSAICFGR_PLLSAIP_1 /*!< PLLSAI division factor for PLLSAIP output by 6 */ #define LL_RCC_PLLSAIP_DIV_8 (RCC_PLLSAICFGR_PLLSAIP_1 | RCC_PLLSAICFGR_PLLSAIP_0) /*!< PLLSAI division factor for PLLSAIP output by 8 */ /** * @} */ #endif /* RCC_PLLSAICFGR_PLLSAIP */ #endif /* RCC_PLLSAI_SUPPORT */ /** * @} */ /* Exported macro ------------------------------------------------------------*/ /** @defgroup RCC_LL_Exported_Macros RCC Exported Macros * @{ */ /** @defgroup RCC_LL_EM_WRITE_READ Common Write and read registers Macros * @{ */ /** * @brief Write a value in RCC register * @param __REG__ Register to be written * @param __VALUE__ Value to be written in the register * @retval None */ #define LL_RCC_WriteReg(__REG__, __VALUE__) WRITE_REG(RCC->__REG__, (__VALUE__)) /** * @brief Read a value in RCC register * @param __REG__ Register to be read * @retval Register value */ #define LL_RCC_ReadReg(__REG__) READ_REG(RCC->__REG__) /** * @} */ /** @defgroup RCC_LL_EM_CALC_FREQ Calculate frequencies * @{ */ /** * @brief Helper macro to calculate the PLLCLK frequency on system domain * @note ex: @ref __LL_RCC_CALC_PLLCLK_FREQ (HSE_VALUE,@ref LL_RCC_PLL_GetDivider (), * @ref LL_RCC_PLL_GetN (), @ref LL_RCC_PLL_GetP ()); * @param __INPUTFREQ__ PLL Input frequency (based on HSE/HSI) * @param __PLLM__ This parameter can be one of the following values: * @arg @ref LL_RCC_PLLM_DIV_2 * @arg @ref LL_RCC_PLLM_DIV_3 * @arg @ref LL_RCC_PLLM_DIV_4 * @arg @ref LL_RCC_PLLM_DIV_5 * @arg @ref LL_RCC_PLLM_DIV_6 * @arg @ref LL_RCC_PLLM_DIV_7 * @arg @ref LL_RCC_PLLM_DIV_8 * @arg @ref LL_RCC_PLLM_DIV_9 * @arg @ref LL_RCC_PLLM_DIV_10 * @arg @ref LL_RCC_PLLM_DIV_11 * @arg @ref LL_RCC_PLLM_DIV_12 * @arg @ref LL_RCC_PLLM_DIV_13 * @arg @ref LL_RCC_PLLM_DIV_14 * @arg @ref LL_RCC_PLLM_DIV_15 * @arg @ref LL_RCC_PLLM_DIV_16 * @arg @ref LL_RCC_PLLM_DIV_17 * @arg @ref LL_RCC_PLLM_DIV_18 * @arg @ref LL_RCC_PLLM_DIV_19 * @arg @ref LL_RCC_PLLM_DIV_20 * @arg @ref LL_RCC_PLLM_DIV_21 * @arg @ref LL_RCC_PLLM_DIV_22 * @arg @ref LL_RCC_PLLM_DIV_23 * @arg @ref LL_RCC_PLLM_DIV_24 * @arg @ref LL_RCC_PLLM_DIV_25 * @arg @ref LL_RCC_PLLM_DIV_26 * @arg @ref LL_RCC_PLLM_DIV_27 * @arg @ref LL_RCC_PLLM_DIV_28 * @arg @ref LL_RCC_PLLM_DIV_29 * @arg @ref LL_RCC_PLLM_DIV_30 * @arg @ref LL_RCC_PLLM_DIV_31 * @arg @ref LL_RCC_PLLM_DIV_32 * @arg @ref LL_RCC_PLLM_DIV_33 * @arg @ref LL_RCC_PLLM_DIV_34 * @arg @ref LL_RCC_PLLM_DIV_35 * @arg @ref LL_RCC_PLLM_DIV_36 * @arg @ref LL_RCC_PLLM_DIV_37 * @arg @ref LL_RCC_PLLM_DIV_38 * @arg @ref LL_RCC_PLLM_DIV_39 * @arg @ref LL_RCC_PLLM_DIV_40 * @arg @ref LL_RCC_PLLM_DIV_41 * @arg @ref LL_RCC_PLLM_DIV_42 * @arg @ref LL_RCC_PLLM_DIV_43 * @arg @ref LL_RCC_PLLM_DIV_44 * @arg @ref LL_RCC_PLLM_DIV_45 * @arg @ref LL_RCC_PLLM_DIV_46 * @arg @ref LL_RCC_PLLM_DIV_47 * @arg @ref LL_RCC_PLLM_DIV_48 * @arg @ref LL_RCC_PLLM_DIV_49 * @arg @ref LL_RCC_PLLM_DIV_50 * @arg @ref LL_RCC_PLLM_DIV_51 * @arg @ref LL_RCC_PLLM_DIV_52 * @arg @ref LL_RCC_PLLM_DIV_53 * @arg @ref LL_RCC_PLLM_DIV_54 * @arg @ref LL_RCC_PLLM_DIV_55 * @arg @ref LL_RCC_PLLM_DIV_56 * @arg @ref LL_RCC_PLLM_DIV_57 * @arg @ref LL_RCC_PLLM_DIV_58 * @arg @ref LL_RCC_PLLM_DIV_59 * @arg @ref LL_RCC_PLLM_DIV_60 * @arg @ref LL_RCC_PLLM_DIV_61 * @arg @ref LL_RCC_PLLM_DIV_62 * @arg @ref LL_RCC_PLLM_DIV_63 * @param __PLLN__ Between 50/192(*) and 432 * * (*) value not defined in all devices. * @param __PLLP__ This parameter can be one of the following values: * @arg @ref LL_RCC_PLLP_DIV_2 * @arg @ref LL_RCC_PLLP_DIV_4 * @arg @ref LL_RCC_PLLP_DIV_6 * @arg @ref LL_RCC_PLLP_DIV_8 * @retval PLL clock frequency (in Hz) */ #define __LL_RCC_CALC_PLLCLK_FREQ(__INPUTFREQ__, __PLLM__, __PLLN__, __PLLP__) ((__INPUTFREQ__) / (__PLLM__) * (__PLLN__) / \ ((((__PLLP__) >> RCC_PLLCFGR_PLLP_Pos ) + 1U) * 2U)) #if defined(RCC_PLLR_SYSCLK_SUPPORT) /** * @brief Helper macro to calculate the PLLRCLK frequency on system domain * @note ex: @ref __LL_RCC_CALC_PLLRCLK_FREQ (HSE_VALUE,@ref LL_RCC_PLL_GetDivider (), * @ref LL_RCC_PLL_GetN (), @ref LL_RCC_PLL_GetR ()); * @param __INPUTFREQ__ PLL Input frequency (based on HSE/HSI) * @param __PLLM__ This parameter can be one of the following values: * @arg @ref LL_RCC_PLLM_DIV_2 * @arg @ref LL_RCC_PLLM_DIV_3 * @arg @ref LL_RCC_PLLM_DIV_4 * @arg @ref LL_RCC_PLLM_DIV_5 * @arg @ref LL_RCC_PLLM_DIV_6 * @arg @ref LL_RCC_PLLM_DIV_7 * @arg @ref LL_RCC_PLLM_DIV_8 * @arg @ref LL_RCC_PLLM_DIV_9 * @arg @ref LL_RCC_PLLM_DIV_10 * @arg @ref LL_RCC_PLLM_DIV_11 * @arg @ref LL_RCC_PLLM_DIV_12 * @arg @ref LL_RCC_PLLM_DIV_13 * @arg @ref LL_RCC_PLLM_DIV_14 * @arg @ref LL_RCC_PLLM_DIV_15 * @arg @ref LL_RCC_PLLM_DIV_16 * @arg @ref LL_RCC_PLLM_DIV_17 * @arg @ref LL_RCC_PLLM_DIV_18 * @arg @ref LL_RCC_PLLM_DIV_19 * @arg @ref LL_RCC_PLLM_DIV_20 * @arg @ref LL_RCC_PLLM_DIV_21 * @arg @ref LL_RCC_PLLM_DIV_22 * @arg @ref LL_RCC_PLLM_DIV_23 * @arg @ref LL_RCC_PLLM_DIV_24 * @arg @ref LL_RCC_PLLM_DIV_25 * @arg @ref LL_RCC_PLLM_DIV_26 * @arg @ref LL_RCC_PLLM_DIV_27 * @arg @ref LL_RCC_PLLM_DIV_28 * @arg @ref LL_RCC_PLLM_DIV_29 * @arg @ref LL_RCC_PLLM_DIV_30 * @arg @ref LL_RCC_PLLM_DIV_31 * @arg @ref LL_RCC_PLLM_DIV_32 * @arg @ref LL_RCC_PLLM_DIV_33 * @arg @ref LL_RCC_PLLM_DIV_34 * @arg @ref LL_RCC_PLLM_DIV_35 * @arg @ref LL_RCC_PLLM_DIV_36 * @arg @ref LL_RCC_PLLM_DIV_37 * @arg @ref LL_RCC_PLLM_DIV_38 * @arg @ref LL_RCC_PLLM_DIV_39 * @arg @ref LL_RCC_PLLM_DIV_40 * @arg @ref LL_RCC_PLLM_DIV_41 * @arg @ref LL_RCC_PLLM_DIV_42 * @arg @ref LL_RCC_PLLM_DIV_43 * @arg @ref LL_RCC_PLLM_DIV_44 * @arg @ref LL_RCC_PLLM_DIV_45 * @arg @ref LL_RCC_PLLM_DIV_46 * @arg @ref LL_RCC_PLLM_DIV_47 * @arg @ref LL_RCC_PLLM_DIV_48 * @arg @ref LL_RCC_PLLM_DIV_49 * @arg @ref LL_RCC_PLLM_DIV_50 * @arg @ref LL_RCC_PLLM_DIV_51 * @arg @ref LL_RCC_PLLM_DIV_52 * @arg @ref LL_RCC_PLLM_DIV_53 * @arg @ref LL_RCC_PLLM_DIV_54 * @arg @ref LL_RCC_PLLM_DIV_55 * @arg @ref LL_RCC_PLLM_DIV_56 * @arg @ref LL_RCC_PLLM_DIV_57 * @arg @ref LL_RCC_PLLM_DIV_58 * @arg @ref LL_RCC_PLLM_DIV_59 * @arg @ref LL_RCC_PLLM_DIV_60 * @arg @ref LL_RCC_PLLM_DIV_61 * @arg @ref LL_RCC_PLLM_DIV_62 * @arg @ref LL_RCC_PLLM_DIV_63 * @param __PLLN__ Between 50 and 432 * @param __PLLR__ This parameter can be one of the following values: * @arg @ref LL_RCC_PLLR_DIV_2 * @arg @ref LL_RCC_PLLR_DIV_3 * @arg @ref LL_RCC_PLLR_DIV_4 * @arg @ref LL_RCC_PLLR_DIV_5 * @arg @ref LL_RCC_PLLR_DIV_6 * @arg @ref LL_RCC_PLLR_DIV_7 * @retval PLL clock frequency (in Hz) */ #define __LL_RCC_CALC_PLLRCLK_FREQ(__INPUTFREQ__, __PLLM__, __PLLN__, __PLLR__) ((__INPUTFREQ__) / (__PLLM__) * (__PLLN__) / \ ((__PLLR__) >> RCC_PLLCFGR_PLLR_Pos )) #endif /* RCC_PLLR_SYSCLK_SUPPORT */ /** * @brief Helper macro to calculate the PLLCLK frequency used on 48M domain * @note ex: @ref __LL_RCC_CALC_PLLCLK_48M_FREQ (HSE_VALUE,@ref LL_RCC_PLL_GetDivider (), * @ref LL_RCC_PLL_GetN (), @ref LL_RCC_PLL_GetQ ()); * @param __INPUTFREQ__ PLL Input frequency (based on HSE/HSI) * @param __PLLM__ This parameter can be one of the following values: * @arg @ref LL_RCC_PLLM_DIV_2 * @arg @ref LL_RCC_PLLM_DIV_3 * @arg @ref LL_RCC_PLLM_DIV_4 * @arg @ref LL_RCC_PLLM_DIV_5 * @arg @ref LL_RCC_PLLM_DIV_6 * @arg @ref LL_RCC_PLLM_DIV_7 * @arg @ref LL_RCC_PLLM_DIV_8 * @arg @ref LL_RCC_PLLM_DIV_9 * @arg @ref LL_RCC_PLLM_DIV_10 * @arg @ref LL_RCC_PLLM_DIV_11 * @arg @ref LL_RCC_PLLM_DIV_12 * @arg @ref LL_RCC_PLLM_DIV_13 * @arg @ref LL_RCC_PLLM_DIV_14 * @arg @ref LL_RCC_PLLM_DIV_15 * @arg @ref LL_RCC_PLLM_DIV_16 * @arg @ref LL_RCC_PLLM_DIV_17 * @arg @ref LL_RCC_PLLM_DIV_18 * @arg @ref LL_RCC_PLLM_DIV_19 * @arg @ref LL_RCC_PLLM_DIV_20 * @arg @ref LL_RCC_PLLM_DIV_21 * @arg @ref LL_RCC_PLLM_DIV_22 * @arg @ref LL_RCC_PLLM_DIV_23 * @arg @ref LL_RCC_PLLM_DIV_24 * @arg @ref LL_RCC_PLLM_DIV_25 * @arg @ref LL_RCC_PLLM_DIV_26 * @arg @ref LL_RCC_PLLM_DIV_27 * @arg @ref LL_RCC_PLLM_DIV_28 * @arg @ref LL_RCC_PLLM_DIV_29 * @arg @ref LL_RCC_PLLM_DIV_30 * @arg @ref LL_RCC_PLLM_DIV_31 * @arg @ref LL_RCC_PLLM_DIV_32 * @arg @ref LL_RCC_PLLM_DIV_33 * @arg @ref LL_RCC_PLLM_DIV_34 * @arg @ref LL_RCC_PLLM_DIV_35 * @arg @ref LL_RCC_PLLM_DIV_36 * @arg @ref LL_RCC_PLLM_DIV_37 * @arg @ref LL_RCC_PLLM_DIV_38 * @arg @ref LL_RCC_PLLM_DIV_39 * @arg @ref LL_RCC_PLLM_DIV_40 * @arg @ref LL_RCC_PLLM_DIV_41 * @arg @ref LL_RCC_PLLM_DIV_42 * @arg @ref LL_RCC_PLLM_DIV_43 * @arg @ref LL_RCC_PLLM_DIV_44 * @arg @ref LL_RCC_PLLM_DIV_45 * @arg @ref LL_RCC_PLLM_DIV_46 * @arg @ref LL_RCC_PLLM_DIV_47 * @arg @ref LL_RCC_PLLM_DIV_48 * @arg @ref LL_RCC_PLLM_DIV_49 * @arg @ref LL_RCC_PLLM_DIV_50 * @arg @ref LL_RCC_PLLM_DIV_51 * @arg @ref LL_RCC_PLLM_DIV_52 * @arg @ref LL_RCC_PLLM_DIV_53 * @arg @ref LL_RCC_PLLM_DIV_54 * @arg @ref LL_RCC_PLLM_DIV_55 * @arg @ref LL_RCC_PLLM_DIV_56 * @arg @ref LL_RCC_PLLM_DIV_57 * @arg @ref LL_RCC_PLLM_DIV_58 * @arg @ref LL_RCC_PLLM_DIV_59 * @arg @ref LL_RCC_PLLM_DIV_60 * @arg @ref LL_RCC_PLLM_DIV_61 * @arg @ref LL_RCC_PLLM_DIV_62 * @arg @ref LL_RCC_PLLM_DIV_63 * @param __PLLN__ Between 50/192(*) and 432 * * (*) value not defined in all devices. * @param __PLLQ__ This parameter can be one of the following values: * @arg @ref LL_RCC_PLLQ_DIV_2 * @arg @ref LL_RCC_PLLQ_DIV_3 * @arg @ref LL_RCC_PLLQ_DIV_4 * @arg @ref LL_RCC_PLLQ_DIV_5 * @arg @ref LL_RCC_PLLQ_DIV_6 * @arg @ref LL_RCC_PLLQ_DIV_7 * @arg @ref LL_RCC_PLLQ_DIV_8 * @arg @ref LL_RCC_PLLQ_DIV_9 * @arg @ref LL_RCC_PLLQ_DIV_10 * @arg @ref LL_RCC_PLLQ_DIV_11 * @arg @ref LL_RCC_PLLQ_DIV_12 * @arg @ref LL_RCC_PLLQ_DIV_13 * @arg @ref LL_RCC_PLLQ_DIV_14 * @arg @ref LL_RCC_PLLQ_DIV_15 * @retval PLL clock frequency (in Hz) */ #define __LL_RCC_CALC_PLLCLK_48M_FREQ(__INPUTFREQ__, __PLLM__, __PLLN__, __PLLQ__) ((__INPUTFREQ__) / (__PLLM__) * (__PLLN__) / \ ((__PLLQ__) >> RCC_PLLCFGR_PLLQ_Pos )) #if defined(DSI) /** * @brief Helper macro to calculate the PLLCLK frequency used on DSI * @note ex: @ref __LL_RCC_CALC_PLLCLK_DSI_FREQ (HSE_VALUE, @ref LL_RCC_PLL_GetDivider (), * @ref LL_RCC_PLL_GetN (), @ref LL_RCC_PLL_GetR ()); * @param __INPUTFREQ__ PLL Input frequency (based on HSE/HSI) * @param __PLLM__ This parameter can be one of the following values: * @arg @ref LL_RCC_PLLM_DIV_2 * @arg @ref LL_RCC_PLLM_DIV_3 * @arg @ref LL_RCC_PLLM_DIV_4 * @arg @ref LL_RCC_PLLM_DIV_5 * @arg @ref LL_RCC_PLLM_DIV_6 * @arg @ref LL_RCC_PLLM_DIV_7 * @arg @ref LL_RCC_PLLM_DIV_8 * @arg @ref LL_RCC_PLLM_DIV_9 * @arg @ref LL_RCC_PLLM_DIV_10 * @arg @ref LL_RCC_PLLM_DIV_11 * @arg @ref LL_RCC_PLLM_DIV_12 * @arg @ref LL_RCC_PLLM_DIV_13 * @arg @ref LL_RCC_PLLM_DIV_14 * @arg @ref LL_RCC_PLLM_DIV_15 * @arg @ref LL_RCC_PLLM_DIV_16 * @arg @ref LL_RCC_PLLM_DIV_17 * @arg @ref LL_RCC_PLLM_DIV_18 * @arg @ref LL_RCC_PLLM_DIV_19 * @arg @ref LL_RCC_PLLM_DIV_20 * @arg @ref LL_RCC_PLLM_DIV_21 * @arg @ref LL_RCC_PLLM_DIV_22 * @arg @ref LL_RCC_PLLM_DIV_23 * @arg @ref LL_RCC_PLLM_DIV_24 * @arg @ref LL_RCC_PLLM_DIV_25 * @arg @ref LL_RCC_PLLM_DIV_26 * @arg @ref LL_RCC_PLLM_DIV_27 * @arg @ref LL_RCC_PLLM_DIV_28 * @arg @ref LL_RCC_PLLM_DIV_29 * @arg @ref LL_RCC_PLLM_DIV_30 * @arg @ref LL_RCC_PLLM_DIV_31 * @arg @ref LL_RCC_PLLM_DIV_32 * @arg @ref LL_RCC_PLLM_DIV_33 * @arg @ref LL_RCC_PLLM_DIV_34 * @arg @ref LL_RCC_PLLM_DIV_35 * @arg @ref LL_RCC_PLLM_DIV_36 * @arg @ref LL_RCC_PLLM_DIV_37 * @arg @ref LL_RCC_PLLM_DIV_38 * @arg @ref LL_RCC_PLLM_DIV_39 * @arg @ref LL_RCC_PLLM_DIV_40 * @arg @ref LL_RCC_PLLM_DIV_41 * @arg @ref LL_RCC_PLLM_DIV_42 * @arg @ref LL_RCC_PLLM_DIV_43 * @arg @ref LL_RCC_PLLM_DIV_44 * @arg @ref LL_RCC_PLLM_DIV_45 * @arg @ref LL_RCC_PLLM_DIV_46 * @arg @ref LL_RCC_PLLM_DIV_47 * @arg @ref LL_RCC_PLLM_DIV_48 * @arg @ref LL_RCC_PLLM_DIV_49 * @arg @ref LL_RCC_PLLM_DIV_50 * @arg @ref LL_RCC_PLLM_DIV_51 * @arg @ref LL_RCC_PLLM_DIV_52 * @arg @ref LL_RCC_PLLM_DIV_53 * @arg @ref LL_RCC_PLLM_DIV_54 * @arg @ref LL_RCC_PLLM_DIV_55 * @arg @ref LL_RCC_PLLM_DIV_56 * @arg @ref LL_RCC_PLLM_DIV_57 * @arg @ref LL_RCC_PLLM_DIV_58 * @arg @ref LL_RCC_PLLM_DIV_59 * @arg @ref LL_RCC_PLLM_DIV_60 * @arg @ref LL_RCC_PLLM_DIV_61 * @arg @ref LL_RCC_PLLM_DIV_62 * @arg @ref LL_RCC_PLLM_DIV_63 * @param __PLLN__ Between 50 and 432 * @param __PLLR__ This parameter can be one of the following values: * @arg @ref LL_RCC_PLLR_DIV_2 * @arg @ref LL_RCC_PLLR_DIV_3 * @arg @ref LL_RCC_PLLR_DIV_4 * @arg @ref LL_RCC_PLLR_DIV_5 * @arg @ref LL_RCC_PLLR_DIV_6 * @arg @ref LL_RCC_PLLR_DIV_7 * @retval PLL clock frequency (in Hz) */ #define __LL_RCC_CALC_PLLCLK_DSI_FREQ(__INPUTFREQ__, __PLLM__, __PLLN__, __PLLR__) ((__INPUTFREQ__) / (__PLLM__) * (__PLLN__) / \ ((__PLLR__) >> RCC_PLLCFGR_PLLR_Pos )) #endif /* DSI */ #if defined(RCC_PLLR_I2S_CLKSOURCE_SUPPORT) /** * @brief Helper macro to calculate the PLLCLK frequency used on I2S * @note ex: @ref __LL_RCC_CALC_PLLCLK_I2S_FREQ (HSE_VALUE, @ref LL_RCC_PLL_GetDivider (), * @ref LL_RCC_PLL_GetN (), @ref LL_RCC_PLL_GetR ()); * @param __INPUTFREQ__ PLL Input frequency (based on HSE/HSI) * @param __PLLM__ This parameter can be one of the following values: * @arg @ref LL_RCC_PLLM_DIV_2 * @arg @ref LL_RCC_PLLM_DIV_3 * @arg @ref LL_RCC_PLLM_DIV_4 * @arg @ref LL_RCC_PLLM_DIV_5 * @arg @ref LL_RCC_PLLM_DIV_6 * @arg @ref LL_RCC_PLLM_DIV_7 * @arg @ref LL_RCC_PLLM_DIV_8 * @arg @ref LL_RCC_PLLM_DIV_9 * @arg @ref LL_RCC_PLLM_DIV_10 * @arg @ref LL_RCC_PLLM_DIV_11 * @arg @ref LL_RCC_PLLM_DIV_12 * @arg @ref LL_RCC_PLLM_DIV_13 * @arg @ref LL_RCC_PLLM_DIV_14 * @arg @ref LL_RCC_PLLM_DIV_15 * @arg @ref LL_RCC_PLLM_DIV_16 * @arg @ref LL_RCC_PLLM_DIV_17 * @arg @ref LL_RCC_PLLM_DIV_18 * @arg @ref LL_RCC_PLLM_DIV_19 * @arg @ref LL_RCC_PLLM_DIV_20 * @arg @ref LL_RCC_PLLM_DIV_21 * @arg @ref LL_RCC_PLLM_DIV_22 * @arg @ref LL_RCC_PLLM_DIV_23 * @arg @ref LL_RCC_PLLM_DIV_24 * @arg @ref LL_RCC_PLLM_DIV_25 * @arg @ref LL_RCC_PLLM_DIV_26 * @arg @ref LL_RCC_PLLM_DIV_27 * @arg @ref LL_RCC_PLLM_DIV_28 * @arg @ref LL_RCC_PLLM_DIV_29 * @arg @ref LL_RCC_PLLM_DIV_30 * @arg @ref LL_RCC_PLLM_DIV_31 * @arg @ref LL_RCC_PLLM_DIV_32 * @arg @ref LL_RCC_PLLM_DIV_33 * @arg @ref LL_RCC_PLLM_DIV_34 * @arg @ref LL_RCC_PLLM_DIV_35 * @arg @ref LL_RCC_PLLM_DIV_36 * @arg @ref LL_RCC_PLLM_DIV_37 * @arg @ref LL_RCC_PLLM_DIV_38 * @arg @ref LL_RCC_PLLM_DIV_39 * @arg @ref LL_RCC_PLLM_DIV_40 * @arg @ref LL_RCC_PLLM_DIV_41 * @arg @ref LL_RCC_PLLM_DIV_42 * @arg @ref LL_RCC_PLLM_DIV_43 * @arg @ref LL_RCC_PLLM_DIV_44 * @arg @ref LL_RCC_PLLM_DIV_45 * @arg @ref LL_RCC_PLLM_DIV_46 * @arg @ref LL_RCC_PLLM_DIV_47 * @arg @ref LL_RCC_PLLM_DIV_48 * @arg @ref LL_RCC_PLLM_DIV_49 * @arg @ref LL_RCC_PLLM_DIV_50 * @arg @ref LL_RCC_PLLM_DIV_51 * @arg @ref LL_RCC_PLLM_DIV_52 * @arg @ref LL_RCC_PLLM_DIV_53 * @arg @ref LL_RCC_PLLM_DIV_54 * @arg @ref LL_RCC_PLLM_DIV_55 * @arg @ref LL_RCC_PLLM_DIV_56 * @arg @ref LL_RCC_PLLM_DIV_57 * @arg @ref LL_RCC_PLLM_DIV_58 * @arg @ref LL_RCC_PLLM_DIV_59 * @arg @ref LL_RCC_PLLM_DIV_60 * @arg @ref LL_RCC_PLLM_DIV_61 * @arg @ref LL_RCC_PLLM_DIV_62 * @arg @ref LL_RCC_PLLM_DIV_63 * @param __PLLN__ Between 50 and 432 * @param __PLLR__ This parameter can be one of the following values: * @arg @ref LL_RCC_PLLR_DIV_2 * @arg @ref LL_RCC_PLLR_DIV_3 * @arg @ref LL_RCC_PLLR_DIV_4 * @arg @ref LL_RCC_PLLR_DIV_5 * @arg @ref LL_RCC_PLLR_DIV_6 * @arg @ref LL_RCC_PLLR_DIV_7 * @retval PLL clock frequency (in Hz) */ #define __LL_RCC_CALC_PLLCLK_I2S_FREQ(__INPUTFREQ__, __PLLM__, __PLLN__, __PLLR__) ((__INPUTFREQ__) / (__PLLM__) * (__PLLN__) / \ ((__PLLR__) >> RCC_PLLCFGR_PLLR_Pos )) #endif /* RCC_PLLR_I2S_CLKSOURCE_SUPPORT */ #if defined(SPDIFRX) /** * @brief Helper macro to calculate the PLLCLK frequency used on SPDIFRX * @note ex: @ref __LL_RCC_CALC_PLLCLK_SPDIFRX_FREQ (HSE_VALUE, @ref LL_RCC_PLL_GetDivider (), * @ref LL_RCC_PLL_GetN (), @ref LL_RCC_PLL_GetR ()); * @param __INPUTFREQ__ PLL Input frequency (based on HSE/HSI) * @param __PLLM__ This parameter can be one of the following values: * @arg @ref LL_RCC_PLLM_DIV_2 * @arg @ref LL_RCC_PLLM_DIV_3 * @arg @ref LL_RCC_PLLM_DIV_4 * @arg @ref LL_RCC_PLLM_DIV_5 * @arg @ref LL_RCC_PLLM_DIV_6 * @arg @ref LL_RCC_PLLM_DIV_7 * @arg @ref LL_RCC_PLLM_DIV_8 * @arg @ref LL_RCC_PLLM_DIV_9 * @arg @ref LL_RCC_PLLM_DIV_10 * @arg @ref LL_RCC_PLLM_DIV_11 * @arg @ref LL_RCC_PLLM_DIV_12 * @arg @ref LL_RCC_PLLM_DIV_13 * @arg @ref LL_RCC_PLLM_DIV_14 * @arg @ref LL_RCC_PLLM_DIV_15 * @arg @ref LL_RCC_PLLM_DIV_16 * @arg @ref LL_RCC_PLLM_DIV_17 * @arg @ref LL_RCC_PLLM_DIV_18 * @arg @ref LL_RCC_PLLM_DIV_19 * @arg @ref LL_RCC_PLLM_DIV_20 * @arg @ref LL_RCC_PLLM_DIV_21 * @arg @ref LL_RCC_PLLM_DIV_22 * @arg @ref LL_RCC_PLLM_DIV_23 * @arg @ref LL_RCC_PLLM_DIV_24 * @arg @ref LL_RCC_PLLM_DIV_25 * @arg @ref LL_RCC_PLLM_DIV_26 * @arg @ref LL_RCC_PLLM_DIV_27 * @arg @ref LL_RCC_PLLM_DIV_28 * @arg @ref LL_RCC_PLLM_DIV_29 * @arg @ref LL_RCC_PLLM_DIV_30 * @arg @ref LL_RCC_PLLM_DIV_31 * @arg @ref LL_RCC_PLLM_DIV_32 * @arg @ref LL_RCC_PLLM_DIV_33 * @arg @ref LL_RCC_PLLM_DIV_34 * @arg @ref LL_RCC_PLLM_DIV_35 * @arg @ref LL_RCC_PLLM_DIV_36 * @arg @ref LL_RCC_PLLM_DIV_37 * @arg @ref LL_RCC_PLLM_DIV_38 * @arg @ref LL_RCC_PLLM_DIV_39 * @arg @ref LL_RCC_PLLM_DIV_40 * @arg @ref LL_RCC_PLLM_DIV_41 * @arg @ref LL_RCC_PLLM_DIV_42 * @arg @ref LL_RCC_PLLM_DIV_43 * @arg @ref LL_RCC_PLLM_DIV_44 * @arg @ref LL_RCC_PLLM_DIV_45 * @arg @ref LL_RCC_PLLM_DIV_46 * @arg @ref LL_RCC_PLLM_DIV_47 * @arg @ref LL_RCC_PLLM_DIV_48 * @arg @ref LL_RCC_PLLM_DIV_49 * @arg @ref LL_RCC_PLLM_DIV_50 * @arg @ref LL_RCC_PLLM_DIV_51 * @arg @ref LL_RCC_PLLM_DIV_52 * @arg @ref LL_RCC_PLLM_DIV_53 * @arg @ref LL_RCC_PLLM_DIV_54 * @arg @ref LL_RCC_PLLM_DIV_55 * @arg @ref LL_RCC_PLLM_DIV_56 * @arg @ref LL_RCC_PLLM_DIV_57 * @arg @ref LL_RCC_PLLM_DIV_58 * @arg @ref LL_RCC_PLLM_DIV_59 * @arg @ref LL_RCC_PLLM_DIV_60 * @arg @ref LL_RCC_PLLM_DIV_61 * @arg @ref LL_RCC_PLLM_DIV_62 * @arg @ref LL_RCC_PLLM_DIV_63 * @param __PLLN__ Between 50 and 432 * @param __PLLR__ This parameter can be one of the following values: * @arg @ref LL_RCC_PLLR_DIV_2 * @arg @ref LL_RCC_PLLR_DIV_3 * @arg @ref LL_RCC_PLLR_DIV_4 * @arg @ref LL_RCC_PLLR_DIV_5 * @arg @ref LL_RCC_PLLR_DIV_6 * @arg @ref LL_RCC_PLLR_DIV_7 * @retval PLL clock frequency (in Hz) */ #define __LL_RCC_CALC_PLLCLK_SPDIFRX_FREQ(__INPUTFREQ__, __PLLM__, __PLLN__, __PLLR__) ((__INPUTFREQ__) / (__PLLM__) * (__PLLN__) / \ ((__PLLR__) >> RCC_PLLCFGR_PLLR_Pos )) #endif /* SPDIFRX */ #if defined(RCC_PLLCFGR_PLLR) #if defined(SAI1) /** * @brief Helper macro to calculate the PLLCLK frequency used on SAI * @note ex: @ref __LL_RCC_CALC_PLLCLK_SAI_FREQ (HSE_VALUE, @ref LL_RCC_PLL_GetDivider (), * @ref LL_RCC_PLL_GetN (), @ref LL_RCC_PLL_GetR (), @ref LL_RCC_PLL_GetDIVR ()); * @param __INPUTFREQ__ PLL Input frequency (based on HSE/HSI) * @param __PLLM__ This parameter can be one of the following values: * @arg @ref LL_RCC_PLLM_DIV_2 * @arg @ref LL_RCC_PLLM_DIV_3 * @arg @ref LL_RCC_PLLM_DIV_4 * @arg @ref LL_RCC_PLLM_DIV_5 * @arg @ref LL_RCC_PLLM_DIV_6 * @arg @ref LL_RCC_PLLM_DIV_7 * @arg @ref LL_RCC_PLLM_DIV_8 * @arg @ref LL_RCC_PLLM_DIV_9 * @arg @ref LL_RCC_PLLM_DIV_10 * @arg @ref LL_RCC_PLLM_DIV_11 * @arg @ref LL_RCC_PLLM_DIV_12 * @arg @ref LL_RCC_PLLM_DIV_13 * @arg @ref LL_RCC_PLLM_DIV_14 * @arg @ref LL_RCC_PLLM_DIV_15 * @arg @ref LL_RCC_PLLM_DIV_16 * @arg @ref LL_RCC_PLLM_DIV_17 * @arg @ref LL_RCC_PLLM_DIV_18 * @arg @ref LL_RCC_PLLM_DIV_19 * @arg @ref LL_RCC_PLLM_DIV_20 * @arg @ref LL_RCC_PLLM_DIV_21 * @arg @ref LL_RCC_PLLM_DIV_22 * @arg @ref LL_RCC_PLLM_DIV_23 * @arg @ref LL_RCC_PLLM_DIV_24 * @arg @ref LL_RCC_PLLM_DIV_25 * @arg @ref LL_RCC_PLLM_DIV_26 * @arg @ref LL_RCC_PLLM_DIV_27 * @arg @ref LL_RCC_PLLM_DIV_28 * @arg @ref LL_RCC_PLLM_DIV_29 * @arg @ref LL_RCC_PLLM_DIV_30 * @arg @ref LL_RCC_PLLM_DIV_31 * @arg @ref LL_RCC_PLLM_DIV_32 * @arg @ref LL_RCC_PLLM_DIV_33 * @arg @ref LL_RCC_PLLM_DIV_34 * @arg @ref LL_RCC_PLLM_DIV_35 * @arg @ref LL_RCC_PLLM_DIV_36 * @arg @ref LL_RCC_PLLM_DIV_37 * @arg @ref LL_RCC_PLLM_DIV_38 * @arg @ref LL_RCC_PLLM_DIV_39 * @arg @ref LL_RCC_PLLM_DIV_40 * @arg @ref LL_RCC_PLLM_DIV_41 * @arg @ref LL_RCC_PLLM_DIV_42 * @arg @ref LL_RCC_PLLM_DIV_43 * @arg @ref LL_RCC_PLLM_DIV_44 * @arg @ref LL_RCC_PLLM_DIV_45 * @arg @ref LL_RCC_PLLM_DIV_46 * @arg @ref LL_RCC_PLLM_DIV_47 * @arg @ref LL_RCC_PLLM_DIV_48 * @arg @ref LL_RCC_PLLM_DIV_49 * @arg @ref LL_RCC_PLLM_DIV_50 * @arg @ref LL_RCC_PLLM_DIV_51 * @arg @ref LL_RCC_PLLM_DIV_52 * @arg @ref LL_RCC_PLLM_DIV_53 * @arg @ref LL_RCC_PLLM_DIV_54 * @arg @ref LL_RCC_PLLM_DIV_55 * @arg @ref LL_RCC_PLLM_DIV_56 * @arg @ref LL_RCC_PLLM_DIV_57 * @arg @ref LL_RCC_PLLM_DIV_58 * @arg @ref LL_RCC_PLLM_DIV_59 * @arg @ref LL_RCC_PLLM_DIV_60 * @arg @ref LL_RCC_PLLM_DIV_61 * @arg @ref LL_RCC_PLLM_DIV_62 * @arg @ref LL_RCC_PLLM_DIV_63 * @param __PLLN__ Between 50 and 432 * @param __PLLR__ This parameter can be one of the following values: * @arg @ref LL_RCC_PLLR_DIV_2 * @arg @ref LL_RCC_PLLR_DIV_3 * @arg @ref LL_RCC_PLLR_DIV_4 * @arg @ref LL_RCC_PLLR_DIV_5 * @arg @ref LL_RCC_PLLR_DIV_6 * @arg @ref LL_RCC_PLLR_DIV_7 * @param __PLLDIVR__ This parameter can be one of the following values: * @arg @ref LL_RCC_PLLDIVR_DIV_1 (*) * @arg @ref LL_RCC_PLLDIVR_DIV_2 (*) * @arg @ref LL_RCC_PLLDIVR_DIV_3 (*) * @arg @ref LL_RCC_PLLDIVR_DIV_4 (*) * @arg @ref LL_RCC_PLLDIVR_DIV_5 (*) * @arg @ref LL_RCC_PLLDIVR_DIV_6 (*) * @arg @ref LL_RCC_PLLDIVR_DIV_7 (*) * @arg @ref LL_RCC_PLLDIVR_DIV_8 (*) * @arg @ref LL_RCC_PLLDIVR_DIV_9 (*) * @arg @ref LL_RCC_PLLDIVR_DIV_10 (*) * @arg @ref LL_RCC_PLLDIVR_DIV_11 (*) * @arg @ref LL_RCC_PLLDIVR_DIV_12 (*) * @arg @ref LL_RCC_PLLDIVR_DIV_13 (*) * @arg @ref LL_RCC_PLLDIVR_DIV_14 (*) * @arg @ref LL_RCC_PLLDIVR_DIV_15 (*) * @arg @ref LL_RCC_PLLDIVR_DIV_16 (*) * @arg @ref LL_RCC_PLLDIVR_DIV_17 (*) * @arg @ref LL_RCC_PLLDIVR_DIV_18 (*) * @arg @ref LL_RCC_PLLDIVR_DIV_19 (*) * @arg @ref LL_RCC_PLLDIVR_DIV_20 (*) * @arg @ref LL_RCC_PLLDIVR_DIV_21 (*) * @arg @ref LL_RCC_PLLDIVR_DIV_22 (*) * @arg @ref LL_RCC_PLLDIVR_DIV_23 (*) * @arg @ref LL_RCC_PLLDIVR_DIV_24 (*) * @arg @ref LL_RCC_PLLDIVR_DIV_25 (*) * @arg @ref LL_RCC_PLLDIVR_DIV_26 (*) * @arg @ref LL_RCC_PLLDIVR_DIV_27 (*) * @arg @ref LL_RCC_PLLDIVR_DIV_28 (*) * @arg @ref LL_RCC_PLLDIVR_DIV_29 (*) * @arg @ref LL_RCC_PLLDIVR_DIV_30 (*) * @arg @ref LL_RCC_PLLDIVR_DIV_31 (*) * * (*) value not defined in all devices. * @retval PLL clock frequency (in Hz) */ #if defined(RCC_DCKCFGR_PLLDIVR) #define __LL_RCC_CALC_PLLCLK_SAI_FREQ(__INPUTFREQ__, __PLLM__, __PLLN__, __PLLR__, __PLLDIVR__) (((__INPUTFREQ__) / (__PLLM__) * (__PLLN__) / \ ((__PLLR__) >> RCC_PLLCFGR_PLLR_Pos )) / ((__PLLDIVR__) >> RCC_DCKCFGR_PLLDIVR_Pos )) #else #define __LL_RCC_CALC_PLLCLK_SAI_FREQ(__INPUTFREQ__, __PLLM__, __PLLN__, __PLLR__) ((__INPUTFREQ__) / (__PLLM__) * (__PLLN__) / \ ((__PLLR__) >> RCC_PLLCFGR_PLLR_Pos )) #endif /* RCC_DCKCFGR_PLLDIVR */ #endif /* SAI1 */ #endif /* RCC_PLLCFGR_PLLR */ #if defined(RCC_PLLSAI_SUPPORT) /** * @brief Helper macro to calculate the PLLSAI frequency used for SAI domain * @note ex: @ref __LL_RCC_CALC_PLLSAI_SAI_FREQ (HSE_VALUE,@ref LL_RCC_PLLSAI_GetDivider (), * @ref LL_RCC_PLLSAI_GetN (), @ref LL_RCC_PLLSAI_GetQ (), @ref LL_RCC_PLLSAI_GetDIVQ ()); * @param __INPUTFREQ__ PLL Input frequency (based on HSE/HSI) * @param __PLLM__ This parameter can be one of the following values: * @arg @ref LL_RCC_PLLSAIM_DIV_2 * @arg @ref LL_RCC_PLLSAIM_DIV_3 * @arg @ref LL_RCC_PLLSAIM_DIV_4 * @arg @ref LL_RCC_PLLSAIM_DIV_5 * @arg @ref LL_RCC_PLLSAIM_DIV_6 * @arg @ref LL_RCC_PLLSAIM_DIV_7 * @arg @ref LL_RCC_PLLSAIM_DIV_8 * @arg @ref LL_RCC_PLLSAIM_DIV_9 * @arg @ref LL_RCC_PLLSAIM_DIV_10 * @arg @ref LL_RCC_PLLSAIM_DIV_11 * @arg @ref LL_RCC_PLLSAIM_DIV_12 * @arg @ref LL_RCC_PLLSAIM_DIV_13 * @arg @ref LL_RCC_PLLSAIM_DIV_14 * @arg @ref LL_RCC_PLLSAIM_DIV_15 * @arg @ref LL_RCC_PLLSAIM_DIV_16 * @arg @ref LL_RCC_PLLSAIM_DIV_17 * @arg @ref LL_RCC_PLLSAIM_DIV_18 * @arg @ref LL_RCC_PLLSAIM_DIV_19 * @arg @ref LL_RCC_PLLSAIM_DIV_20 * @arg @ref LL_RCC_PLLSAIM_DIV_21 * @arg @ref LL_RCC_PLLSAIM_DIV_22 * @arg @ref LL_RCC_PLLSAIM_DIV_23 * @arg @ref LL_RCC_PLLSAIM_DIV_24 * @arg @ref LL_RCC_PLLSAIM_DIV_25 * @arg @ref LL_RCC_PLLSAIM_DIV_26 * @arg @ref LL_RCC_PLLSAIM_DIV_27 * @arg @ref LL_RCC_PLLSAIM_DIV_28 * @arg @ref LL_RCC_PLLSAIM_DIV_29 * @arg @ref LL_RCC_PLLSAIM_DIV_30 * @arg @ref LL_RCC_PLLSAIM_DIV_31 * @arg @ref LL_RCC_PLLSAIM_DIV_32 * @arg @ref LL_RCC_PLLSAIM_DIV_33 * @arg @ref LL_RCC_PLLSAIM_DIV_34 * @arg @ref LL_RCC_PLLSAIM_DIV_35 * @arg @ref LL_RCC_PLLSAIM_DIV_36 * @arg @ref LL_RCC_PLLSAIM_DIV_37 * @arg @ref LL_RCC_PLLSAIM_DIV_38 * @arg @ref LL_RCC_PLLSAIM_DIV_39 * @arg @ref LL_RCC_PLLSAIM_DIV_40 * @arg @ref LL_RCC_PLLSAIM_DIV_41 * @arg @ref LL_RCC_PLLSAIM_DIV_42 * @arg @ref LL_RCC_PLLSAIM_DIV_43 * @arg @ref LL_RCC_PLLSAIM_DIV_44 * @arg @ref LL_RCC_PLLSAIM_DIV_45 * @arg @ref LL_RCC_PLLSAIM_DIV_46 * @arg @ref LL_RCC_PLLSAIM_DIV_47 * @arg @ref LL_RCC_PLLSAIM_DIV_48 * @arg @ref LL_RCC_PLLSAIM_DIV_49 * @arg @ref LL_RCC_PLLSAIM_DIV_50 * @arg @ref LL_RCC_PLLSAIM_DIV_51 * @arg @ref LL_RCC_PLLSAIM_DIV_52 * @arg @ref LL_RCC_PLLSAIM_DIV_53 * @arg @ref LL_RCC_PLLSAIM_DIV_54 * @arg @ref LL_RCC_PLLSAIM_DIV_55 * @arg @ref LL_RCC_PLLSAIM_DIV_56 * @arg @ref LL_RCC_PLLSAIM_DIV_57 * @arg @ref LL_RCC_PLLSAIM_DIV_58 * @arg @ref LL_RCC_PLLSAIM_DIV_59 * @arg @ref LL_RCC_PLLSAIM_DIV_60 * @arg @ref LL_RCC_PLLSAIM_DIV_61 * @arg @ref LL_RCC_PLLSAIM_DIV_62 * @arg @ref LL_RCC_PLLSAIM_DIV_63 * @param __PLLSAIN__ Between 49/50(*) and 432 * * (*) value not defined in all devices. * @param __PLLSAIQ__ This parameter can be one of the following values: * @arg @ref LL_RCC_PLLSAIQ_DIV_2 * @arg @ref LL_RCC_PLLSAIQ_DIV_3 * @arg @ref LL_RCC_PLLSAIQ_DIV_4 * @arg @ref LL_RCC_PLLSAIQ_DIV_5 * @arg @ref LL_RCC_PLLSAIQ_DIV_6 * @arg @ref LL_RCC_PLLSAIQ_DIV_7 * @arg @ref LL_RCC_PLLSAIQ_DIV_8 * @arg @ref LL_RCC_PLLSAIQ_DIV_9 * @arg @ref LL_RCC_PLLSAIQ_DIV_10 * @arg @ref LL_RCC_PLLSAIQ_DIV_11 * @arg @ref LL_RCC_PLLSAIQ_DIV_12 * @arg @ref LL_RCC_PLLSAIQ_DIV_13 * @arg @ref LL_RCC_PLLSAIQ_DIV_14 * @arg @ref LL_RCC_PLLSAIQ_DIV_15 * @param __PLLSAIDIVQ__ This parameter can be one of the following values: * @arg @ref LL_RCC_PLLSAIDIVQ_DIV_1 * @arg @ref LL_RCC_PLLSAIDIVQ_DIV_2 * @arg @ref LL_RCC_PLLSAIDIVQ_DIV_3 * @arg @ref LL_RCC_PLLSAIDIVQ_DIV_4 * @arg @ref LL_RCC_PLLSAIDIVQ_DIV_5 * @arg @ref LL_RCC_PLLSAIDIVQ_DIV_6 * @arg @ref LL_RCC_PLLSAIDIVQ_DIV_7 * @arg @ref LL_RCC_PLLSAIDIVQ_DIV_8 * @arg @ref LL_RCC_PLLSAIDIVQ_DIV_9 * @arg @ref LL_RCC_PLLSAIDIVQ_DIV_10 * @arg @ref LL_RCC_PLLSAIDIVQ_DIV_11 * @arg @ref LL_RCC_PLLSAIDIVQ_DIV_12 * @arg @ref LL_RCC_PLLSAIDIVQ_DIV_13 * @arg @ref LL_RCC_PLLSAIDIVQ_DIV_14 * @arg @ref LL_RCC_PLLSAIDIVQ_DIV_15 * @arg @ref LL_RCC_PLLSAIDIVQ_DIV_16 * @arg @ref LL_RCC_PLLSAIDIVQ_DIV_17 * @arg @ref LL_RCC_PLLSAIDIVQ_DIV_18 * @arg @ref LL_RCC_PLLSAIDIVQ_DIV_19 * @arg @ref LL_RCC_PLLSAIDIVQ_DIV_20 * @arg @ref LL_RCC_PLLSAIDIVQ_DIV_21 * @arg @ref LL_RCC_PLLSAIDIVQ_DIV_22 * @arg @ref LL_RCC_PLLSAIDIVQ_DIV_23 * @arg @ref LL_RCC_PLLSAIDIVQ_DIV_24 * @arg @ref LL_RCC_PLLSAIDIVQ_DIV_25 * @arg @ref LL_RCC_PLLSAIDIVQ_DIV_26 * @arg @ref LL_RCC_PLLSAIDIVQ_DIV_27 * @arg @ref LL_RCC_PLLSAIDIVQ_DIV_28 * @arg @ref LL_RCC_PLLSAIDIVQ_DIV_29 * @arg @ref LL_RCC_PLLSAIDIVQ_DIV_30 * @arg @ref LL_RCC_PLLSAIDIVQ_DIV_31 * @arg @ref LL_RCC_PLLSAIDIVQ_DIV_32 * @retval PLLSAI clock frequency (in Hz) */ #define __LL_RCC_CALC_PLLSAI_SAI_FREQ(__INPUTFREQ__, __PLLM__, __PLLSAIN__, __PLLSAIQ__, __PLLSAIDIVQ__) (((__INPUTFREQ__) / (__PLLM__)) * (__PLLSAIN__) / \ (((__PLLSAIQ__) >> RCC_PLLSAICFGR_PLLSAIQ_Pos) * (((__PLLSAIDIVQ__) >> RCC_DCKCFGR_PLLSAIDIVQ_Pos) + 1U))) #if defined(RCC_PLLSAICFGR_PLLSAIP) /** * @brief Helper macro to calculate the PLLSAI frequency used on 48Mhz domain * @note ex: @ref __LL_RCC_CALC_PLLSAI_48M_FREQ (HSE_VALUE,@ref LL_RCC_PLLSAI_GetDivider (), * @ref LL_RCC_PLLSAI_GetN (), @ref LL_RCC_PLLSAI_GetP ()); * @param __INPUTFREQ__ PLL Input frequency (based on HSE/HSI) * @param __PLLM__ This parameter can be one of the following values: * @arg @ref LL_RCC_PLLSAIM_DIV_2 * @arg @ref LL_RCC_PLLSAIM_DIV_3 * @arg @ref LL_RCC_PLLSAIM_DIV_4 * @arg @ref LL_RCC_PLLSAIM_DIV_5 * @arg @ref LL_RCC_PLLSAIM_DIV_6 * @arg @ref LL_RCC_PLLSAIM_DIV_7 * @arg @ref LL_RCC_PLLSAIM_DIV_8 * @arg @ref LL_RCC_PLLSAIM_DIV_9 * @arg @ref LL_RCC_PLLSAIM_DIV_10 * @arg @ref LL_RCC_PLLSAIM_DIV_11 * @arg @ref LL_RCC_PLLSAIM_DIV_12 * @arg @ref LL_RCC_PLLSAIM_DIV_13 * @arg @ref LL_RCC_PLLSAIM_DIV_14 * @arg @ref LL_RCC_PLLSAIM_DIV_15 * @arg @ref LL_RCC_PLLSAIM_DIV_16 * @arg @ref LL_RCC_PLLSAIM_DIV_17 * @arg @ref LL_RCC_PLLSAIM_DIV_18 * @arg @ref LL_RCC_PLLSAIM_DIV_19 * @arg @ref LL_RCC_PLLSAIM_DIV_20 * @arg @ref LL_RCC_PLLSAIM_DIV_21 * @arg @ref LL_RCC_PLLSAIM_DIV_22 * @arg @ref LL_RCC_PLLSAIM_DIV_23 * @arg @ref LL_RCC_PLLSAIM_DIV_24 * @arg @ref LL_RCC_PLLSAIM_DIV_25 * @arg @ref LL_RCC_PLLSAIM_DIV_26 * @arg @ref LL_RCC_PLLSAIM_DIV_27 * @arg @ref LL_RCC_PLLSAIM_DIV_28 * @arg @ref LL_RCC_PLLSAIM_DIV_29 * @arg @ref LL_RCC_PLLSAIM_DIV_30 * @arg @ref LL_RCC_PLLSAIM_DIV_31 * @arg @ref LL_RCC_PLLSAIM_DIV_32 * @arg @ref LL_RCC_PLLSAIM_DIV_33 * @arg @ref LL_RCC_PLLSAIM_DIV_34 * @arg @ref LL_RCC_PLLSAIM_DIV_35 * @arg @ref LL_RCC_PLLSAIM_DIV_36 * @arg @ref LL_RCC_PLLSAIM_DIV_37 * @arg @ref LL_RCC_PLLSAIM_DIV_38 * @arg @ref LL_RCC_PLLSAIM_DIV_39 * @arg @ref LL_RCC_PLLSAIM_DIV_40 * @arg @ref LL_RCC_PLLSAIM_DIV_41 * @arg @ref LL_RCC_PLLSAIM_DIV_42 * @arg @ref LL_RCC_PLLSAIM_DIV_43 * @arg @ref LL_RCC_PLLSAIM_DIV_44 * @arg @ref LL_RCC_PLLSAIM_DIV_45 * @arg @ref LL_RCC_PLLSAIM_DIV_46 * @arg @ref LL_RCC_PLLSAIM_DIV_47 * @arg @ref LL_RCC_PLLSAIM_DIV_48 * @arg @ref LL_RCC_PLLSAIM_DIV_49 * @arg @ref LL_RCC_PLLSAIM_DIV_50 * @arg @ref LL_RCC_PLLSAIM_DIV_51 * @arg @ref LL_RCC_PLLSAIM_DIV_52 * @arg @ref LL_RCC_PLLSAIM_DIV_53 * @arg @ref LL_RCC_PLLSAIM_DIV_54 * @arg @ref LL_RCC_PLLSAIM_DIV_55 * @arg @ref LL_RCC_PLLSAIM_DIV_56 * @arg @ref LL_RCC_PLLSAIM_DIV_57 * @arg @ref LL_RCC_PLLSAIM_DIV_58 * @arg @ref LL_RCC_PLLSAIM_DIV_59 * @arg @ref LL_RCC_PLLSAIM_DIV_60 * @arg @ref LL_RCC_PLLSAIM_DIV_61 * @arg @ref LL_RCC_PLLSAIM_DIV_62 * @arg @ref LL_RCC_PLLSAIM_DIV_63 * @param __PLLSAIN__ Between 50 and 432 * @param __PLLSAIP__ This parameter can be one of the following values: * @arg @ref LL_RCC_PLLSAIP_DIV_2 * @arg @ref LL_RCC_PLLSAIP_DIV_4 * @arg @ref LL_RCC_PLLSAIP_DIV_6 * @arg @ref LL_RCC_PLLSAIP_DIV_8 * @retval PLLSAI clock frequency (in Hz) */ #define __LL_RCC_CALC_PLLSAI_48M_FREQ(__INPUTFREQ__, __PLLM__, __PLLSAIN__, __PLLSAIP__) (((__INPUTFREQ__) / (__PLLM__)) * (__PLLSAIN__) / \ ((((__PLLSAIP__) >> RCC_PLLSAICFGR_PLLSAIP_Pos) + 1U) * 2U)) #endif /* RCC_PLLSAICFGR_PLLSAIP */ #if defined(LTDC) /** * @brief Helper macro to calculate the PLLSAI frequency used for LTDC domain * @note ex: @ref __LL_RCC_CALC_PLLSAI_LTDC_FREQ (HSE_VALUE,@ref LL_RCC_PLLSAI_GetDivider (), * @ref LL_RCC_PLLSAI_GetN (), @ref LL_RCC_PLLSAI_GetR (), @ref LL_RCC_PLLSAI_GetDIVR ()); * @param __INPUTFREQ__ PLL Input frequency (based on HSE/HSI) * @param __PLLM__ This parameter can be one of the following values: * @arg @ref LL_RCC_PLLSAIM_DIV_2 * @arg @ref LL_RCC_PLLSAIM_DIV_3 * @arg @ref LL_RCC_PLLSAIM_DIV_4 * @arg @ref LL_RCC_PLLSAIM_DIV_5 * @arg @ref LL_RCC_PLLSAIM_DIV_6 * @arg @ref LL_RCC_PLLSAIM_DIV_7 * @arg @ref LL_RCC_PLLSAIM_DIV_8 * @arg @ref LL_RCC_PLLSAIM_DIV_9 * @arg @ref LL_RCC_PLLSAIM_DIV_10 * @arg @ref LL_RCC_PLLSAIM_DIV_11 * @arg @ref LL_RCC_PLLSAIM_DIV_12 * @arg @ref LL_RCC_PLLSAIM_DIV_13 * @arg @ref LL_RCC_PLLSAIM_DIV_14 * @arg @ref LL_RCC_PLLSAIM_DIV_15 * @arg @ref LL_RCC_PLLSAIM_DIV_16 * @arg @ref LL_RCC_PLLSAIM_DIV_17 * @arg @ref LL_RCC_PLLSAIM_DIV_18 * @arg @ref LL_RCC_PLLSAIM_DIV_19 * @arg @ref LL_RCC_PLLSAIM_DIV_20 * @arg @ref LL_RCC_PLLSAIM_DIV_21 * @arg @ref LL_RCC_PLLSAIM_DIV_22 * @arg @ref LL_RCC_PLLSAIM_DIV_23 * @arg @ref LL_RCC_PLLSAIM_DIV_24 * @arg @ref LL_RCC_PLLSAIM_DIV_25 * @arg @ref LL_RCC_PLLSAIM_DIV_26 * @arg @ref LL_RCC_PLLSAIM_DIV_27 * @arg @ref LL_RCC_PLLSAIM_DIV_28 * @arg @ref LL_RCC_PLLSAIM_DIV_29 * @arg @ref LL_RCC_PLLSAIM_DIV_30 * @arg @ref LL_RCC_PLLSAIM_DIV_31 * @arg @ref LL_RCC_PLLSAIM_DIV_32 * @arg @ref LL_RCC_PLLSAIM_DIV_33 * @arg @ref LL_RCC_PLLSAIM_DIV_34 * @arg @ref LL_RCC_PLLSAIM_DIV_35 * @arg @ref LL_RCC_PLLSAIM_DIV_36 * @arg @ref LL_RCC_PLLSAIM_DIV_37 * @arg @ref LL_RCC_PLLSAIM_DIV_38 * @arg @ref LL_RCC_PLLSAIM_DIV_39 * @arg @ref LL_RCC_PLLSAIM_DIV_40 * @arg @ref LL_RCC_PLLSAIM_DIV_41 * @arg @ref LL_RCC_PLLSAIM_DIV_42 * @arg @ref LL_RCC_PLLSAIM_DIV_43 * @arg @ref LL_RCC_PLLSAIM_DIV_44 * @arg @ref LL_RCC_PLLSAIM_DIV_45 * @arg @ref LL_RCC_PLLSAIM_DIV_46 * @arg @ref LL_RCC_PLLSAIM_DIV_47 * @arg @ref LL_RCC_PLLSAIM_DIV_48 * @arg @ref LL_RCC_PLLSAIM_DIV_49 * @arg @ref LL_RCC_PLLSAIM_DIV_50 * @arg @ref LL_RCC_PLLSAIM_DIV_51 * @arg @ref LL_RCC_PLLSAIM_DIV_52 * @arg @ref LL_RCC_PLLSAIM_DIV_53 * @arg @ref LL_RCC_PLLSAIM_DIV_54 * @arg @ref LL_RCC_PLLSAIM_DIV_55 * @arg @ref LL_RCC_PLLSAIM_DIV_56 * @arg @ref LL_RCC_PLLSAIM_DIV_57 * @arg @ref LL_RCC_PLLSAIM_DIV_58 * @arg @ref LL_RCC_PLLSAIM_DIV_59 * @arg @ref LL_RCC_PLLSAIM_DIV_60 * @arg @ref LL_RCC_PLLSAIM_DIV_61 * @arg @ref LL_RCC_PLLSAIM_DIV_62 * @arg @ref LL_RCC_PLLSAIM_DIV_63 * @param __PLLSAIN__ Between 49/50(*) and 432 * * (*) value not defined in all devices. * @param __PLLSAIR__ This parameter can be one of the following values: * @arg @ref LL_RCC_PLLSAIR_DIV_2 * @arg @ref LL_RCC_PLLSAIR_DIV_3 * @arg @ref LL_RCC_PLLSAIR_DIV_4 * @arg @ref LL_RCC_PLLSAIR_DIV_5 * @arg @ref LL_RCC_PLLSAIR_DIV_6 * @arg @ref LL_RCC_PLLSAIR_DIV_7 * @param __PLLSAIDIVR__ This parameter can be one of the following values: * @arg @ref LL_RCC_PLLSAIDIVR_DIV_2 * @arg @ref LL_RCC_PLLSAIDIVR_DIV_4 * @arg @ref LL_RCC_PLLSAIDIVR_DIV_8 * @arg @ref LL_RCC_PLLSAIDIVR_DIV_16 * @retval PLLSAI clock frequency (in Hz) */ #define __LL_RCC_CALC_PLLSAI_LTDC_FREQ(__INPUTFREQ__, __PLLM__, __PLLSAIN__, __PLLSAIR__, __PLLSAIDIVR__) (((__INPUTFREQ__) / (__PLLM__)) * (__PLLSAIN__) / \ (((__PLLSAIR__) >> RCC_PLLSAICFGR_PLLSAIR_Pos) * (aRCC_PLLSAIDIVRPrescTable[(__PLLSAIDIVR__) >> RCC_DCKCFGR_PLLSAIDIVR_Pos]))) #endif /* LTDC */ #endif /* RCC_PLLSAI_SUPPORT */ #if defined(RCC_PLLI2S_SUPPORT) #if defined(RCC_DCKCFGR_PLLI2SDIVQ) || defined(RCC_DCKCFGR_PLLI2SDIVR) /** * @brief Helper macro to calculate the PLLI2S frequency used for SAI domain * @note ex: @ref __LL_RCC_CALC_PLLI2S_SAI_FREQ (HSE_VALUE,@ref LL_RCC_PLLI2S_GetDivider (), * @ref LL_RCC_PLLI2S_GetN (), @ref LL_RCC_PLLI2S_GetQ (), @ref LL_RCC_PLLI2S_GetDIVQ ()); * @param __INPUTFREQ__ PLL Input frequency (based on HSE/HSI) * @param __PLLM__ This parameter can be one of the following values: * @arg @ref LL_RCC_PLLI2SM_DIV_2 * @arg @ref LL_RCC_PLLI2SM_DIV_3 * @arg @ref LL_RCC_PLLI2SM_DIV_4 * @arg @ref LL_RCC_PLLI2SM_DIV_5 * @arg @ref LL_RCC_PLLI2SM_DIV_6 * @arg @ref LL_RCC_PLLI2SM_DIV_7 * @arg @ref LL_RCC_PLLI2SM_DIV_8 * @arg @ref LL_RCC_PLLI2SM_DIV_9 * @arg @ref LL_RCC_PLLI2SM_DIV_10 * @arg @ref LL_RCC_PLLI2SM_DIV_11 * @arg @ref LL_RCC_PLLI2SM_DIV_12 * @arg @ref LL_RCC_PLLI2SM_DIV_13 * @arg @ref LL_RCC_PLLI2SM_DIV_14 * @arg @ref LL_RCC_PLLI2SM_DIV_15 * @arg @ref LL_RCC_PLLI2SM_DIV_16 * @arg @ref LL_RCC_PLLI2SM_DIV_17 * @arg @ref LL_RCC_PLLI2SM_DIV_18 * @arg @ref LL_RCC_PLLI2SM_DIV_19 * @arg @ref LL_RCC_PLLI2SM_DIV_20 * @arg @ref LL_RCC_PLLI2SM_DIV_21 * @arg @ref LL_RCC_PLLI2SM_DIV_22 * @arg @ref LL_RCC_PLLI2SM_DIV_23 * @arg @ref LL_RCC_PLLI2SM_DIV_24 * @arg @ref LL_RCC_PLLI2SM_DIV_25 * @arg @ref LL_RCC_PLLI2SM_DIV_26 * @arg @ref LL_RCC_PLLI2SM_DIV_27 * @arg @ref LL_RCC_PLLI2SM_DIV_28 * @arg @ref LL_RCC_PLLI2SM_DIV_29 * @arg @ref LL_RCC_PLLI2SM_DIV_30 * @arg @ref LL_RCC_PLLI2SM_DIV_31 * @arg @ref LL_RCC_PLLI2SM_DIV_32 * @arg @ref LL_RCC_PLLI2SM_DIV_33 * @arg @ref LL_RCC_PLLI2SM_DIV_34 * @arg @ref LL_RCC_PLLI2SM_DIV_35 * @arg @ref LL_RCC_PLLI2SM_DIV_36 * @arg @ref LL_RCC_PLLI2SM_DIV_37 * @arg @ref LL_RCC_PLLI2SM_DIV_38 * @arg @ref LL_RCC_PLLI2SM_DIV_39 * @arg @ref LL_RCC_PLLI2SM_DIV_40 * @arg @ref LL_RCC_PLLI2SM_DIV_41 * @arg @ref LL_RCC_PLLI2SM_DIV_42 * @arg @ref LL_RCC_PLLI2SM_DIV_43 * @arg @ref LL_RCC_PLLI2SM_DIV_44 * @arg @ref LL_RCC_PLLI2SM_DIV_45 * @arg @ref LL_RCC_PLLI2SM_DIV_46 * @arg @ref LL_RCC_PLLI2SM_DIV_47 * @arg @ref LL_RCC_PLLI2SM_DIV_48 * @arg @ref LL_RCC_PLLI2SM_DIV_49 * @arg @ref LL_RCC_PLLI2SM_DIV_50 * @arg @ref LL_RCC_PLLI2SM_DIV_51 * @arg @ref LL_RCC_PLLI2SM_DIV_52 * @arg @ref LL_RCC_PLLI2SM_DIV_53 * @arg @ref LL_RCC_PLLI2SM_DIV_54 * @arg @ref LL_RCC_PLLI2SM_DIV_55 * @arg @ref LL_RCC_PLLI2SM_DIV_56 * @arg @ref LL_RCC_PLLI2SM_DIV_57 * @arg @ref LL_RCC_PLLI2SM_DIV_58 * @arg @ref LL_RCC_PLLI2SM_DIV_59 * @arg @ref LL_RCC_PLLI2SM_DIV_60 * @arg @ref LL_RCC_PLLI2SM_DIV_61 * @arg @ref LL_RCC_PLLI2SM_DIV_62 * @arg @ref LL_RCC_PLLI2SM_DIV_63 * @param __PLLI2SN__ Between 50/192(*) and 432 * * (*) value not defined in all devices. * @param __PLLI2SQ_R__ This parameter can be one of the following values: * @arg @ref LL_RCC_PLLI2SQ_DIV_2 (*) * @arg @ref LL_RCC_PLLI2SQ_DIV_3 (*) * @arg @ref LL_RCC_PLLI2SQ_DIV_4 (*) * @arg @ref LL_RCC_PLLI2SQ_DIV_5 (*) * @arg @ref LL_RCC_PLLI2SQ_DIV_6 (*) * @arg @ref LL_RCC_PLLI2SQ_DIV_7 (*) * @arg @ref LL_RCC_PLLI2SQ_DIV_8 (*) * @arg @ref LL_RCC_PLLI2SQ_DIV_9 (*) * @arg @ref LL_RCC_PLLI2SQ_DIV_10 (*) * @arg @ref LL_RCC_PLLI2SQ_DIV_11 (*) * @arg @ref LL_RCC_PLLI2SQ_DIV_12 (*) * @arg @ref LL_RCC_PLLI2SQ_DIV_13 (*) * @arg @ref LL_RCC_PLLI2SQ_DIV_14 (*) * @arg @ref LL_RCC_PLLI2SQ_DIV_15 (*) * @arg @ref LL_RCC_PLLI2SR_DIV_2 (*) * @arg @ref LL_RCC_PLLI2SR_DIV_3 (*) * @arg @ref LL_RCC_PLLI2SR_DIV_4 (*) * @arg @ref LL_RCC_PLLI2SR_DIV_5 (*) * @arg @ref LL_RCC_PLLI2SR_DIV_6 (*) * @arg @ref LL_RCC_PLLI2SR_DIV_7 (*) * * (*) value not defined in all devices. * @param __PLLI2SDIVQ_R__ This parameter can be one of the following values: * @arg @ref LL_RCC_PLLI2SDIVQ_DIV_1 (*) * @arg @ref LL_RCC_PLLI2SDIVQ_DIV_2 (*) * @arg @ref LL_RCC_PLLI2SDIVQ_DIV_3 (*) * @arg @ref LL_RCC_PLLI2SDIVQ_DIV_4 (*) * @arg @ref LL_RCC_PLLI2SDIVQ_DIV_5 (*) * @arg @ref LL_RCC_PLLI2SDIVQ_DIV_6 (*) * @arg @ref LL_RCC_PLLI2SDIVQ_DIV_7 (*) * @arg @ref LL_RCC_PLLI2SDIVQ_DIV_8 (*) * @arg @ref LL_RCC_PLLI2SDIVQ_DIV_9 (*) * @arg @ref LL_RCC_PLLI2SDIVQ_DIV_10 (*) * @arg @ref LL_RCC_PLLI2SDIVQ_DIV_11 (*) * @arg @ref LL_RCC_PLLI2SDIVQ_DIV_12 (*) * @arg @ref LL_RCC_PLLI2SDIVQ_DIV_13 (*) * @arg @ref LL_RCC_PLLI2SDIVQ_DIV_14 (*) * @arg @ref LL_RCC_PLLI2SDIVQ_DIV_15 (*) * @arg @ref LL_RCC_PLLI2SDIVQ_DIV_16 (*) * @arg @ref LL_RCC_PLLI2SDIVQ_DIV_17 (*) * @arg @ref LL_RCC_PLLI2SDIVQ_DIV_18 (*) * @arg @ref LL_RCC_PLLI2SDIVQ_DIV_19 (*) * @arg @ref LL_RCC_PLLI2SDIVQ_DIV_20 (*) * @arg @ref LL_RCC_PLLI2SDIVQ_DIV_21 (*) * @arg @ref LL_RCC_PLLI2SDIVQ_DIV_22 (*) * @arg @ref LL_RCC_PLLI2SDIVQ_DIV_23 (*) * @arg @ref LL_RCC_PLLI2SDIVQ_DIV_24 (*) * @arg @ref LL_RCC_PLLI2SDIVQ_DIV_25 (*) * @arg @ref LL_RCC_PLLI2SDIVQ_DIV_26 (*) * @arg @ref LL_RCC_PLLI2SDIVQ_DIV_27 (*) * @arg @ref LL_RCC_PLLI2SDIVQ_DIV_28 (*) * @arg @ref LL_RCC_PLLI2SDIVQ_DIV_29 (*) * @arg @ref LL_RCC_PLLI2SDIVQ_DIV_30 (*) * @arg @ref LL_RCC_PLLI2SDIVQ_DIV_31 (*) * @arg @ref LL_RCC_PLLI2SDIVQ_DIV_32 (*) * @arg @ref LL_RCC_PLLI2SDIVR_DIV_1 (*) * @arg @ref LL_RCC_PLLI2SDIVR_DIV_2 (*) * @arg @ref LL_RCC_PLLI2SDIVR_DIV_3 (*) * @arg @ref LL_RCC_PLLI2SDIVR_DIV_4 (*) * @arg @ref LL_RCC_PLLI2SDIVR_DIV_5 (*) * @arg @ref LL_RCC_PLLI2SDIVR_DIV_6 (*) * @arg @ref LL_RCC_PLLI2SDIVR_DIV_7 (*) * @arg @ref LL_RCC_PLLI2SDIVR_DIV_8 (*) * @arg @ref LL_RCC_PLLI2SDIVR_DIV_9 (*) * @arg @ref LL_RCC_PLLI2SDIVR_DIV_10 (*) * @arg @ref LL_RCC_PLLI2SDIVR_DIV_11 (*) * @arg @ref LL_RCC_PLLI2SDIVR_DIV_12 (*) * @arg @ref LL_RCC_PLLI2SDIVR_DIV_13 (*) * @arg @ref LL_RCC_PLLI2SDIVR_DIV_14 (*) * @arg @ref LL_RCC_PLLI2SDIVR_DIV_15 (*) * @arg @ref LL_RCC_PLLI2SDIVR_DIV_16 (*) * @arg @ref LL_RCC_PLLI2SDIVR_DIV_17 (*) * @arg @ref LL_RCC_PLLI2SDIVR_DIV_18 (*) * @arg @ref LL_RCC_PLLI2SDIVR_DIV_19 (*) * @arg @ref LL_RCC_PLLI2SDIVR_DIV_20 (*) * @arg @ref LL_RCC_PLLI2SDIVR_DIV_21 (*) * @arg @ref LL_RCC_PLLI2SDIVR_DIV_22 (*) * @arg @ref LL_RCC_PLLI2SDIVR_DIV_23 (*) * @arg @ref LL_RCC_PLLI2SDIVR_DIV_24 (*) * @arg @ref LL_RCC_PLLI2SDIVR_DIV_25 (*) * @arg @ref LL_RCC_PLLI2SDIVR_DIV_26 (*) * @arg @ref LL_RCC_PLLI2SDIVR_DIV_27 (*) * @arg @ref LL_RCC_PLLI2SDIVR_DIV_28 (*) * @arg @ref LL_RCC_PLLI2SDIVR_DIV_29 (*) * @arg @ref LL_RCC_PLLI2SDIVR_DIV_30 (*) * @arg @ref LL_RCC_PLLI2SDIVR_DIV_31 (*) * * (*) value not defined in all devices. * @retval PLLI2S clock frequency (in Hz) */ #if defined(RCC_DCKCFGR_PLLI2SDIVQ) #define __LL_RCC_CALC_PLLI2S_SAI_FREQ(__INPUTFREQ__, __PLLM__, __PLLI2SN__, __PLLI2SQ_R__, __PLLI2SDIVQ_R__) (((__INPUTFREQ__) / (__PLLM__)) * (__PLLI2SN__) / \ (((__PLLI2SQ_R__) >> RCC_PLLI2SCFGR_PLLI2SQ_Pos) * (((__PLLI2SDIVQ_R__) >> RCC_DCKCFGR_PLLI2SDIVQ_Pos) + 1U))) #else #define __LL_RCC_CALC_PLLI2S_SAI_FREQ(__INPUTFREQ__, __PLLM__, __PLLI2SN__, __PLLI2SQ_R__, __PLLI2SDIVQ_R__) (((__INPUTFREQ__) / (__PLLM__)) * (__PLLI2SN__) / \ (((__PLLI2SQ_R__) >> RCC_PLLI2SCFGR_PLLI2SR_Pos) * ((__PLLI2SDIVQ_R__) >> RCC_DCKCFGR_PLLI2SDIVR_Pos))) #endif /* RCC_DCKCFGR_PLLI2SDIVQ */ #endif /* RCC_DCKCFGR_PLLI2SDIVQ || RCC_DCKCFGR_PLLI2SDIVR */ #if defined(SPDIFRX) /** * @brief Helper macro to calculate the PLLI2S frequency used on SPDIFRX domain * @note ex: @ref __LL_RCC_CALC_PLLI2S_SPDIFRX_FREQ (HSE_VALUE,@ref LL_RCC_PLLI2S_GetDivider (), * @ref LL_RCC_PLLI2S_GetN (), @ref LL_RCC_PLLI2S_GetP ()); * @param __INPUTFREQ__ PLL Input frequency (based on HSE/HSI) * @param __PLLM__ This parameter can be one of the following values: * @arg @ref LL_RCC_PLLI2SM_DIV_2 * @arg @ref LL_RCC_PLLI2SM_DIV_3 * @arg @ref LL_RCC_PLLI2SM_DIV_4 * @arg @ref LL_RCC_PLLI2SM_DIV_5 * @arg @ref LL_RCC_PLLI2SM_DIV_6 * @arg @ref LL_RCC_PLLI2SM_DIV_7 * @arg @ref LL_RCC_PLLI2SM_DIV_8 * @arg @ref LL_RCC_PLLI2SM_DIV_9 * @arg @ref LL_RCC_PLLI2SM_DIV_10 * @arg @ref LL_RCC_PLLI2SM_DIV_11 * @arg @ref LL_RCC_PLLI2SM_DIV_12 * @arg @ref LL_RCC_PLLI2SM_DIV_13 * @arg @ref LL_RCC_PLLI2SM_DIV_14 * @arg @ref LL_RCC_PLLI2SM_DIV_15 * @arg @ref LL_RCC_PLLI2SM_DIV_16 * @arg @ref LL_RCC_PLLI2SM_DIV_17 * @arg @ref LL_RCC_PLLI2SM_DIV_18 * @arg @ref LL_RCC_PLLI2SM_DIV_19 * @arg @ref LL_RCC_PLLI2SM_DIV_20 * @arg @ref LL_RCC_PLLI2SM_DIV_21 * @arg @ref LL_RCC_PLLI2SM_DIV_22 * @arg @ref LL_RCC_PLLI2SM_DIV_23 * @arg @ref LL_RCC_PLLI2SM_DIV_24 * @arg @ref LL_RCC_PLLI2SM_DIV_25 * @arg @ref LL_RCC_PLLI2SM_DIV_26 * @arg @ref LL_RCC_PLLI2SM_DIV_27 * @arg @ref LL_RCC_PLLI2SM_DIV_28 * @arg @ref LL_RCC_PLLI2SM_DIV_29 * @arg @ref LL_RCC_PLLI2SM_DIV_30 * @arg @ref LL_RCC_PLLI2SM_DIV_31 * @arg @ref LL_RCC_PLLI2SM_DIV_32 * @arg @ref LL_RCC_PLLI2SM_DIV_33 * @arg @ref LL_RCC_PLLI2SM_DIV_34 * @arg @ref LL_RCC_PLLI2SM_DIV_35 * @arg @ref LL_RCC_PLLI2SM_DIV_36 * @arg @ref LL_RCC_PLLI2SM_DIV_37 * @arg @ref LL_RCC_PLLI2SM_DIV_38 * @arg @ref LL_RCC_PLLI2SM_DIV_39 * @arg @ref LL_RCC_PLLI2SM_DIV_40 * @arg @ref LL_RCC_PLLI2SM_DIV_41 * @arg @ref LL_RCC_PLLI2SM_DIV_42 * @arg @ref LL_RCC_PLLI2SM_DIV_43 * @arg @ref LL_RCC_PLLI2SM_DIV_44 * @arg @ref LL_RCC_PLLI2SM_DIV_45 * @arg @ref LL_RCC_PLLI2SM_DIV_46 * @arg @ref LL_RCC_PLLI2SM_DIV_47 * @arg @ref LL_RCC_PLLI2SM_DIV_48 * @arg @ref LL_RCC_PLLI2SM_DIV_49 * @arg @ref LL_RCC_PLLI2SM_DIV_50 * @arg @ref LL_RCC_PLLI2SM_DIV_51 * @arg @ref LL_RCC_PLLI2SM_DIV_52 * @arg @ref LL_RCC_PLLI2SM_DIV_53 * @arg @ref LL_RCC_PLLI2SM_DIV_54 * @arg @ref LL_RCC_PLLI2SM_DIV_55 * @arg @ref LL_RCC_PLLI2SM_DIV_56 * @arg @ref LL_RCC_PLLI2SM_DIV_57 * @arg @ref LL_RCC_PLLI2SM_DIV_58 * @arg @ref LL_RCC_PLLI2SM_DIV_59 * @arg @ref LL_RCC_PLLI2SM_DIV_60 * @arg @ref LL_RCC_PLLI2SM_DIV_61 * @arg @ref LL_RCC_PLLI2SM_DIV_62 * @arg @ref LL_RCC_PLLI2SM_DIV_63 * @param __PLLI2SN__ Between 50 and 432 * @param __PLLI2SP__ This parameter can be one of the following values: * @arg @ref LL_RCC_PLLI2SP_DIV_2 * @arg @ref LL_RCC_PLLI2SP_DIV_4 * @arg @ref LL_RCC_PLLI2SP_DIV_6 * @arg @ref LL_RCC_PLLI2SP_DIV_8 * @retval PLLI2S clock frequency (in Hz) */ #define __LL_RCC_CALC_PLLI2S_SPDIFRX_FREQ(__INPUTFREQ__, __PLLM__, __PLLI2SN__, __PLLI2SP__) (((__INPUTFREQ__) / (__PLLM__)) * (__PLLI2SN__) / \ ((((__PLLI2SP__) >> RCC_PLLI2SCFGR_PLLI2SP_Pos) + 1U) * 2U)) #endif /* SPDIFRX */ /** * @brief Helper macro to calculate the PLLI2S frequency used for I2S domain * @note ex: @ref __LL_RCC_CALC_PLLI2S_I2S_FREQ (HSE_VALUE,@ref LL_RCC_PLLI2S_GetDivider (), * @ref LL_RCC_PLLI2S_GetN (), @ref LL_RCC_PLLI2S_GetR ()); * @param __INPUTFREQ__ PLL Input frequency (based on HSE/HSI) * @param __PLLM__ This parameter can be one of the following values: * @arg @ref LL_RCC_PLLI2SM_DIV_2 * @arg @ref LL_RCC_PLLI2SM_DIV_3 * @arg @ref LL_RCC_PLLI2SM_DIV_4 * @arg @ref LL_RCC_PLLI2SM_DIV_5 * @arg @ref LL_RCC_PLLI2SM_DIV_6 * @arg @ref LL_RCC_PLLI2SM_DIV_7 * @arg @ref LL_RCC_PLLI2SM_DIV_8 * @arg @ref LL_RCC_PLLI2SM_DIV_9 * @arg @ref LL_RCC_PLLI2SM_DIV_10 * @arg @ref LL_RCC_PLLI2SM_DIV_11 * @arg @ref LL_RCC_PLLI2SM_DIV_12 * @arg @ref LL_RCC_PLLI2SM_DIV_13 * @arg @ref LL_RCC_PLLI2SM_DIV_14 * @arg @ref LL_RCC_PLLI2SM_DIV_15 * @arg @ref LL_RCC_PLLI2SM_DIV_16 * @arg @ref LL_RCC_PLLI2SM_DIV_17 * @arg @ref LL_RCC_PLLI2SM_DIV_18 * @arg @ref LL_RCC_PLLI2SM_DIV_19 * @arg @ref LL_RCC_PLLI2SM_DIV_20 * @arg @ref LL_RCC_PLLI2SM_DIV_21 * @arg @ref LL_RCC_PLLI2SM_DIV_22 * @arg @ref LL_RCC_PLLI2SM_DIV_23 * @arg @ref LL_RCC_PLLI2SM_DIV_24 * @arg @ref LL_RCC_PLLI2SM_DIV_25 * @arg @ref LL_RCC_PLLI2SM_DIV_26 * @arg @ref LL_RCC_PLLI2SM_DIV_27 * @arg @ref LL_RCC_PLLI2SM_DIV_28 * @arg @ref LL_RCC_PLLI2SM_DIV_29 * @arg @ref LL_RCC_PLLI2SM_DIV_30 * @arg @ref LL_RCC_PLLI2SM_DIV_31 * @arg @ref LL_RCC_PLLI2SM_DIV_32 * @arg @ref LL_RCC_PLLI2SM_DIV_33 * @arg @ref LL_RCC_PLLI2SM_DIV_34 * @arg @ref LL_RCC_PLLI2SM_DIV_35 * @arg @ref LL_RCC_PLLI2SM_DIV_36 * @arg @ref LL_RCC_PLLI2SM_DIV_37 * @arg @ref LL_RCC_PLLI2SM_DIV_38 * @arg @ref LL_RCC_PLLI2SM_DIV_39 * @arg @ref LL_RCC_PLLI2SM_DIV_40 * @arg @ref LL_RCC_PLLI2SM_DIV_41 * @arg @ref LL_RCC_PLLI2SM_DIV_42 * @arg @ref LL_RCC_PLLI2SM_DIV_43 * @arg @ref LL_RCC_PLLI2SM_DIV_44 * @arg @ref LL_RCC_PLLI2SM_DIV_45 * @arg @ref LL_RCC_PLLI2SM_DIV_46 * @arg @ref LL_RCC_PLLI2SM_DIV_47 * @arg @ref LL_RCC_PLLI2SM_DIV_48 * @arg @ref LL_RCC_PLLI2SM_DIV_49 * @arg @ref LL_RCC_PLLI2SM_DIV_50 * @arg @ref LL_RCC_PLLI2SM_DIV_51 * @arg @ref LL_RCC_PLLI2SM_DIV_52 * @arg @ref LL_RCC_PLLI2SM_DIV_53 * @arg @ref LL_RCC_PLLI2SM_DIV_54 * @arg @ref LL_RCC_PLLI2SM_DIV_55 * @arg @ref LL_RCC_PLLI2SM_DIV_56 * @arg @ref LL_RCC_PLLI2SM_DIV_57 * @arg @ref LL_RCC_PLLI2SM_DIV_58 * @arg @ref LL_RCC_PLLI2SM_DIV_59 * @arg @ref LL_RCC_PLLI2SM_DIV_60 * @arg @ref LL_RCC_PLLI2SM_DIV_61 * @arg @ref LL_RCC_PLLI2SM_DIV_62 * @arg @ref LL_RCC_PLLI2SM_DIV_63 * @param __PLLI2SN__ Between 50/192(*) and 432 * * (*) value not defined in all devices. * @param __PLLI2SR__ This parameter can be one of the following values: * @arg @ref LL_RCC_PLLI2SR_DIV_2 * @arg @ref LL_RCC_PLLI2SR_DIV_3 * @arg @ref LL_RCC_PLLI2SR_DIV_4 * @arg @ref LL_RCC_PLLI2SR_DIV_5 * @arg @ref LL_RCC_PLLI2SR_DIV_6 * @arg @ref LL_RCC_PLLI2SR_DIV_7 * @retval PLLI2S clock frequency (in Hz) */ #define __LL_RCC_CALC_PLLI2S_I2S_FREQ(__INPUTFREQ__, __PLLM__, __PLLI2SN__, __PLLI2SR__) (((__INPUTFREQ__) / (__PLLM__)) * (__PLLI2SN__) / \ ((__PLLI2SR__) >> RCC_PLLI2SCFGR_PLLI2SR_Pos)) #if defined(RCC_PLLI2SCFGR_PLLI2SQ) && !defined(RCC_DCKCFGR_PLLI2SDIVQ) /** * @brief Helper macro to calculate the PLLI2S frequency used for 48Mhz domain * @note ex: @ref __LL_RCC_CALC_PLLI2S_48M_FREQ (HSE_VALUE,@ref LL_RCC_PLLI2S_GetDivider (), * @ref LL_RCC_PLLI2S_GetN (), @ref LL_RCC_PLLI2S_GetQ ()); * @param __INPUTFREQ__ PLL Input frequency (based on HSE/HSI) * @param __PLLM__ This parameter can be one of the following values: * @arg @ref LL_RCC_PLLI2SM_DIV_2 * @arg @ref LL_RCC_PLLI2SM_DIV_3 * @arg @ref LL_RCC_PLLI2SM_DIV_4 * @arg @ref LL_RCC_PLLI2SM_DIV_5 * @arg @ref LL_RCC_PLLI2SM_DIV_6 * @arg @ref LL_RCC_PLLI2SM_DIV_7 * @arg @ref LL_RCC_PLLI2SM_DIV_8 * @arg @ref LL_RCC_PLLI2SM_DIV_9 * @arg @ref LL_RCC_PLLI2SM_DIV_10 * @arg @ref LL_RCC_PLLI2SM_DIV_11 * @arg @ref LL_RCC_PLLI2SM_DIV_12 * @arg @ref LL_RCC_PLLI2SM_DIV_13 * @arg @ref LL_RCC_PLLI2SM_DIV_14 * @arg @ref LL_RCC_PLLI2SM_DIV_15 * @arg @ref LL_RCC_PLLI2SM_DIV_16 * @arg @ref LL_RCC_PLLI2SM_DIV_17 * @arg @ref LL_RCC_PLLI2SM_DIV_18 * @arg @ref LL_RCC_PLLI2SM_DIV_19 * @arg @ref LL_RCC_PLLI2SM_DIV_20 * @arg @ref LL_RCC_PLLI2SM_DIV_21 * @arg @ref LL_RCC_PLLI2SM_DIV_22 * @arg @ref LL_RCC_PLLI2SM_DIV_23 * @arg @ref LL_RCC_PLLI2SM_DIV_24 * @arg @ref LL_RCC_PLLI2SM_DIV_25 * @arg @ref LL_RCC_PLLI2SM_DIV_26 * @arg @ref LL_RCC_PLLI2SM_DIV_27 * @arg @ref LL_RCC_PLLI2SM_DIV_28 * @arg @ref LL_RCC_PLLI2SM_DIV_29 * @arg @ref LL_RCC_PLLI2SM_DIV_30 * @arg @ref LL_RCC_PLLI2SM_DIV_31 * @arg @ref LL_RCC_PLLI2SM_DIV_32 * @arg @ref LL_RCC_PLLI2SM_DIV_33 * @arg @ref LL_RCC_PLLI2SM_DIV_34 * @arg @ref LL_RCC_PLLI2SM_DIV_35 * @arg @ref LL_RCC_PLLI2SM_DIV_36 * @arg @ref LL_RCC_PLLI2SM_DIV_37 * @arg @ref LL_RCC_PLLI2SM_DIV_38 * @arg @ref LL_RCC_PLLI2SM_DIV_39 * @arg @ref LL_RCC_PLLI2SM_DIV_40 * @arg @ref LL_RCC_PLLI2SM_DIV_41 * @arg @ref LL_RCC_PLLI2SM_DIV_42 * @arg @ref LL_RCC_PLLI2SM_DIV_43 * @arg @ref LL_RCC_PLLI2SM_DIV_44 * @arg @ref LL_RCC_PLLI2SM_DIV_45 * @arg @ref LL_RCC_PLLI2SM_DIV_46 * @arg @ref LL_RCC_PLLI2SM_DIV_47 * @arg @ref LL_RCC_PLLI2SM_DIV_48 * @arg @ref LL_RCC_PLLI2SM_DIV_49 * @arg @ref LL_RCC_PLLI2SM_DIV_50 * @arg @ref LL_RCC_PLLI2SM_DIV_51 * @arg @ref LL_RCC_PLLI2SM_DIV_52 * @arg @ref LL_RCC_PLLI2SM_DIV_53 * @arg @ref LL_RCC_PLLI2SM_DIV_54 * @arg @ref LL_RCC_PLLI2SM_DIV_55 * @arg @ref LL_RCC_PLLI2SM_DIV_56 * @arg @ref LL_RCC_PLLI2SM_DIV_57 * @arg @ref LL_RCC_PLLI2SM_DIV_58 * @arg @ref LL_RCC_PLLI2SM_DIV_59 * @arg @ref LL_RCC_PLLI2SM_DIV_60 * @arg @ref LL_RCC_PLLI2SM_DIV_61 * @arg @ref LL_RCC_PLLI2SM_DIV_62 * @arg @ref LL_RCC_PLLI2SM_DIV_63 * @param __PLLI2SN__ Between 50 and 432 * @param __PLLI2SQ__ This parameter can be one of the following values: * @arg @ref LL_RCC_PLLI2SQ_DIV_2 * @arg @ref LL_RCC_PLLI2SQ_DIV_3 * @arg @ref LL_RCC_PLLI2SQ_DIV_4 * @arg @ref LL_RCC_PLLI2SQ_DIV_5 * @arg @ref LL_RCC_PLLI2SQ_DIV_6 * @arg @ref LL_RCC_PLLI2SQ_DIV_7 * @arg @ref LL_RCC_PLLI2SQ_DIV_8 * @arg @ref LL_RCC_PLLI2SQ_DIV_9 * @arg @ref LL_RCC_PLLI2SQ_DIV_10 * @arg @ref LL_RCC_PLLI2SQ_DIV_11 * @arg @ref LL_RCC_PLLI2SQ_DIV_12 * @arg @ref LL_RCC_PLLI2SQ_DIV_13 * @arg @ref LL_RCC_PLLI2SQ_DIV_14 * @arg @ref LL_RCC_PLLI2SQ_DIV_15 * @retval PLLI2S clock frequency (in Hz) */ #define __LL_RCC_CALC_PLLI2S_48M_FREQ(__INPUTFREQ__, __PLLM__, __PLLI2SN__, __PLLI2SQ__) (((__INPUTFREQ__) / (__PLLM__)) * (__PLLI2SN__) / \ ((__PLLI2SQ__) >> RCC_PLLI2SCFGR_PLLI2SQ_Pos)) #endif /* RCC_PLLI2SCFGR_PLLI2SQ && !RCC_DCKCFGR_PLLI2SDIVQ */ #endif /* RCC_PLLI2S_SUPPORT */ /** * @brief Helper macro to calculate the HCLK frequency * @param __SYSCLKFREQ__ SYSCLK frequency (based on HSE/HSI/PLLCLK) * @param __AHBPRESCALER__ This parameter can be one of the following values: * @arg @ref LL_RCC_SYSCLK_DIV_1 * @arg @ref LL_RCC_SYSCLK_DIV_2 * @arg @ref LL_RCC_SYSCLK_DIV_4 * @arg @ref LL_RCC_SYSCLK_DIV_8 * @arg @ref LL_RCC_SYSCLK_DIV_16 * @arg @ref LL_RCC_SYSCLK_DIV_64 * @arg @ref LL_RCC_SYSCLK_DIV_128 * @arg @ref LL_RCC_SYSCLK_DIV_256 * @arg @ref LL_RCC_SYSCLK_DIV_512 * @retval HCLK clock frequency (in Hz) */ #define __LL_RCC_CALC_HCLK_FREQ(__SYSCLKFREQ__, __AHBPRESCALER__) ((__SYSCLKFREQ__) >> AHBPrescTable[((__AHBPRESCALER__) & RCC_CFGR_HPRE) >> RCC_CFGR_HPRE_Pos]) /** * @brief Helper macro to calculate the PCLK1 frequency (ABP1) * @param __HCLKFREQ__ HCLK frequency * @param __APB1PRESCALER__ This parameter can be one of the following values: * @arg @ref LL_RCC_APB1_DIV_1 * @arg @ref LL_RCC_APB1_DIV_2 * @arg @ref LL_RCC_APB1_DIV_4 * @arg @ref LL_RCC_APB1_DIV_8 * @arg @ref LL_RCC_APB1_DIV_16 * @retval PCLK1 clock frequency (in Hz) */ #define __LL_RCC_CALC_PCLK1_FREQ(__HCLKFREQ__, __APB1PRESCALER__) ((__HCLKFREQ__) >> APBPrescTable[(__APB1PRESCALER__) >> RCC_CFGR_PPRE1_Pos]) /** * @brief Helper macro to calculate the PCLK2 frequency (ABP2) * @param __HCLKFREQ__ HCLK frequency * @param __APB2PRESCALER__ This parameter can be one of the following values: * @arg @ref LL_RCC_APB2_DIV_1 * @arg @ref LL_RCC_APB2_DIV_2 * @arg @ref LL_RCC_APB2_DIV_4 * @arg @ref LL_RCC_APB2_DIV_8 * @arg @ref LL_RCC_APB2_DIV_16 * @retval PCLK2 clock frequency (in Hz) */ #define __LL_RCC_CALC_PCLK2_FREQ(__HCLKFREQ__, __APB2PRESCALER__) ((__HCLKFREQ__) >> APBPrescTable[(__APB2PRESCALER__) >> RCC_CFGR_PPRE2_Pos]) /** * @} */ /** * @} */ /* Exported functions --------------------------------------------------------*/ /** @defgroup RCC_LL_Exported_Functions RCC Exported Functions * @{ */ /** @defgroup RCC_LL_EF_HSE HSE * @{ */ /** * @brief Enable the Clock Security System. * @rmtoll CR CSSON LL_RCC_HSE_EnableCSS * @retval None */ __STATIC_INLINE void LL_RCC_HSE_EnableCSS(void) { SET_BIT(RCC->CR, RCC_CR_CSSON); } /** * @brief Enable HSE external oscillator (HSE Bypass) * @rmtoll CR HSEBYP LL_RCC_HSE_EnableBypass * @retval None */ __STATIC_INLINE void LL_RCC_HSE_EnableBypass(void) { SET_BIT(RCC->CR, RCC_CR_HSEBYP); } /** * @brief Disable HSE external oscillator (HSE Bypass) * @rmtoll CR HSEBYP LL_RCC_HSE_DisableBypass * @retval None */ __STATIC_INLINE void LL_RCC_HSE_DisableBypass(void) { CLEAR_BIT(RCC->CR, RCC_CR_HSEBYP); } /** * @brief Enable HSE crystal oscillator (HSE ON) * @rmtoll CR HSEON LL_RCC_HSE_Enable * @retval None */ __STATIC_INLINE void LL_RCC_HSE_Enable(void) { SET_BIT(RCC->CR, RCC_CR_HSEON); } /** * @brief Disable HSE crystal oscillator (HSE ON) * @rmtoll CR HSEON LL_RCC_HSE_Disable * @retval None */ __STATIC_INLINE void LL_RCC_HSE_Disable(void) { CLEAR_BIT(RCC->CR, RCC_CR_HSEON); } /** * @brief Check if HSE oscillator Ready * @rmtoll CR HSERDY LL_RCC_HSE_IsReady * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_RCC_HSE_IsReady(void) { return (READ_BIT(RCC->CR, RCC_CR_HSERDY) == (RCC_CR_HSERDY)); } /** * @} */ /** @defgroup RCC_LL_EF_HSI HSI * @{ */ /** * @brief Enable HSI oscillator * @rmtoll CR HSION LL_RCC_HSI_Enable * @retval None */ __STATIC_INLINE void LL_RCC_HSI_Enable(void) { SET_BIT(RCC->CR, RCC_CR_HSION); } /** * @brief Disable HSI oscillator * @rmtoll CR HSION LL_RCC_HSI_Disable * @retval None */ __STATIC_INLINE void LL_RCC_HSI_Disable(void) { CLEAR_BIT(RCC->CR, RCC_CR_HSION); } /** * @brief Check if HSI clock is ready * @rmtoll CR HSIRDY LL_RCC_HSI_IsReady * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_RCC_HSI_IsReady(void) { return (READ_BIT(RCC->CR, RCC_CR_HSIRDY) == (RCC_CR_HSIRDY)); } /** * @brief Get HSI Calibration value * @note When HSITRIM is written, HSICAL is updated with the sum of * HSITRIM and the factory trim value * @rmtoll CR HSICAL LL_RCC_HSI_GetCalibration * @retval Between Min_Data = 0x00 and Max_Data = 0xFF */ __STATIC_INLINE uint32_t LL_RCC_HSI_GetCalibration(void) { return (uint32_t)(READ_BIT(RCC->CR, RCC_CR_HSICAL) >> RCC_CR_HSICAL_Pos); } /** * @brief Set HSI Calibration trimming * @note user-programmable trimming value that is added to the HSICAL * @note Default value is 16, which, when added to the HSICAL value, * should trim the HSI to 16 MHz +/- 1 % * @rmtoll CR HSITRIM LL_RCC_HSI_SetCalibTrimming * @param Value Between Min_Data = 0 and Max_Data = 31 * @retval None */ __STATIC_INLINE void LL_RCC_HSI_SetCalibTrimming(uint32_t Value) { MODIFY_REG(RCC->CR, RCC_CR_HSITRIM, Value << RCC_CR_HSITRIM_Pos); } /** * @brief Get HSI Calibration trimming * @rmtoll CR HSITRIM LL_RCC_HSI_GetCalibTrimming * @retval Between Min_Data = 0 and Max_Data = 31 */ __STATIC_INLINE uint32_t LL_RCC_HSI_GetCalibTrimming(void) { return (uint32_t)(READ_BIT(RCC->CR, RCC_CR_HSITRIM) >> RCC_CR_HSITRIM_Pos); } /** * @} */ /** @defgroup RCC_LL_EF_LSE LSE * @{ */ /** * @brief Enable Low Speed External (LSE) crystal. * @rmtoll BDCR LSEON LL_RCC_LSE_Enable * @retval None */ __STATIC_INLINE void LL_RCC_LSE_Enable(void) { SET_BIT(RCC->BDCR, RCC_BDCR_LSEON); } /** * @brief Disable Low Speed External (LSE) crystal. * @rmtoll BDCR LSEON LL_RCC_LSE_Disable * @retval None */ __STATIC_INLINE void LL_RCC_LSE_Disable(void) { CLEAR_BIT(RCC->BDCR, RCC_BDCR_LSEON); } /** * @brief Enable external clock source (LSE bypass). * @rmtoll BDCR LSEBYP LL_RCC_LSE_EnableBypass * @retval None */ __STATIC_INLINE void LL_RCC_LSE_EnableBypass(void) { SET_BIT(RCC->BDCR, RCC_BDCR_LSEBYP); } /** * @brief Disable external clock source (LSE bypass). * @rmtoll BDCR LSEBYP LL_RCC_LSE_DisableBypass * @retval None */ __STATIC_INLINE void LL_RCC_LSE_DisableBypass(void) { CLEAR_BIT(RCC->BDCR, RCC_BDCR_LSEBYP); } /** * @brief Check if LSE oscillator Ready * @rmtoll BDCR LSERDY LL_RCC_LSE_IsReady * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_RCC_LSE_IsReady(void) { return (READ_BIT(RCC->BDCR, RCC_BDCR_LSERDY) == (RCC_BDCR_LSERDY)); } #if defined(RCC_BDCR_LSEMOD) /** * @brief Enable LSE high drive mode. * @note LSE high drive mode can be enabled only when the LSE clock is disabled * @rmtoll BDCR LSEMOD LL_RCC_LSE_EnableHighDriveMode * @retval None */ __STATIC_INLINE void LL_RCC_LSE_EnableHighDriveMode(void) { SET_BIT(RCC->BDCR, RCC_BDCR_LSEMOD); } /** * @brief Disable LSE high drive mode. * @note LSE high drive mode can be disabled only when the LSE clock is disabled * @rmtoll BDCR LSEMOD LL_RCC_LSE_DisableHighDriveMode * @retval None */ __STATIC_INLINE void LL_RCC_LSE_DisableHighDriveMode(void) { CLEAR_BIT(RCC->BDCR, RCC_BDCR_LSEMOD); } #endif /* RCC_BDCR_LSEMOD */ /** * @} */ /** @defgroup RCC_LL_EF_LSI LSI * @{ */ /** * @brief Enable LSI Oscillator * @rmtoll CSR LSION LL_RCC_LSI_Enable * @retval None */ __STATIC_INLINE void LL_RCC_LSI_Enable(void) { SET_BIT(RCC->CSR, RCC_CSR_LSION); } /** * @brief Disable LSI Oscillator * @rmtoll CSR LSION LL_RCC_LSI_Disable * @retval None */ __STATIC_INLINE void LL_RCC_LSI_Disable(void) { CLEAR_BIT(RCC->CSR, RCC_CSR_LSION); } /** * @brief Check if LSI is Ready * @rmtoll CSR LSIRDY LL_RCC_LSI_IsReady * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_RCC_LSI_IsReady(void) { return (READ_BIT(RCC->CSR, RCC_CSR_LSIRDY) == (RCC_CSR_LSIRDY)); } /** * @} */ /** @defgroup RCC_LL_EF_System System * @{ */ /** * @brief Configure the system clock source * @rmtoll CFGR SW LL_RCC_SetSysClkSource * @param Source This parameter can be one of the following values: * @arg @ref LL_RCC_SYS_CLKSOURCE_HSI * @arg @ref LL_RCC_SYS_CLKSOURCE_HSE * @arg @ref LL_RCC_SYS_CLKSOURCE_PLL * @arg @ref LL_RCC_SYS_CLKSOURCE_PLLR (*) * * (*) value not defined in all devices. * @retval None */ __STATIC_INLINE void LL_RCC_SetSysClkSource(uint32_t Source) { MODIFY_REG(RCC->CFGR, RCC_CFGR_SW, Source); } /** * @brief Get the system clock source * @rmtoll CFGR SWS LL_RCC_GetSysClkSource * @retval Returned value can be one of the following values: * @arg @ref LL_RCC_SYS_CLKSOURCE_STATUS_HSI * @arg @ref LL_RCC_SYS_CLKSOURCE_STATUS_HSE * @arg @ref LL_RCC_SYS_CLKSOURCE_STATUS_PLL * @arg @ref LL_RCC_SYS_CLKSOURCE_STATUS_PLLR (*) * * (*) value not defined in all devices. */ __STATIC_INLINE uint32_t LL_RCC_GetSysClkSource(void) { return (uint32_t)(READ_BIT(RCC->CFGR, RCC_CFGR_SWS)); } /** * @brief Set AHB prescaler * @rmtoll CFGR HPRE LL_RCC_SetAHBPrescaler * @param Prescaler This parameter can be one of the following values: * @arg @ref LL_RCC_SYSCLK_DIV_1 * @arg @ref LL_RCC_SYSCLK_DIV_2 * @arg @ref LL_RCC_SYSCLK_DIV_4 * @arg @ref LL_RCC_SYSCLK_DIV_8 * @arg @ref LL_RCC_SYSCLK_DIV_16 * @arg @ref LL_RCC_SYSCLK_DIV_64 * @arg @ref LL_RCC_SYSCLK_DIV_128 * @arg @ref LL_RCC_SYSCLK_DIV_256 * @arg @ref LL_RCC_SYSCLK_DIV_512 * @retval None */ __STATIC_INLINE void LL_RCC_SetAHBPrescaler(uint32_t Prescaler) { MODIFY_REG(RCC->CFGR, RCC_CFGR_HPRE, Prescaler); } /** * @brief Set APB1 prescaler * @rmtoll CFGR PPRE1 LL_RCC_SetAPB1Prescaler * @param Prescaler This parameter can be one of the following values: * @arg @ref LL_RCC_APB1_DIV_1 * @arg @ref LL_RCC_APB1_DIV_2 * @arg @ref LL_RCC_APB1_DIV_4 * @arg @ref LL_RCC_APB1_DIV_8 * @arg @ref LL_RCC_APB1_DIV_16 * @retval None */ __STATIC_INLINE void LL_RCC_SetAPB1Prescaler(uint32_t Prescaler) { MODIFY_REG(RCC->CFGR, RCC_CFGR_PPRE1, Prescaler); } /** * @brief Set APB2 prescaler * @rmtoll CFGR PPRE2 LL_RCC_SetAPB2Prescaler * @param Prescaler This parameter can be one of the following values: * @arg @ref LL_RCC_APB2_DIV_1 * @arg @ref LL_RCC_APB2_DIV_2 * @arg @ref LL_RCC_APB2_DIV_4 * @arg @ref LL_RCC_APB2_DIV_8 * @arg @ref LL_RCC_APB2_DIV_16 * @retval None */ __STATIC_INLINE void LL_RCC_SetAPB2Prescaler(uint32_t Prescaler) { MODIFY_REG(RCC->CFGR, RCC_CFGR_PPRE2, Prescaler); } /** * @brief Get AHB prescaler * @rmtoll CFGR HPRE LL_RCC_GetAHBPrescaler * @retval Returned value can be one of the following values: * @arg @ref LL_RCC_SYSCLK_DIV_1 * @arg @ref LL_RCC_SYSCLK_DIV_2 * @arg @ref LL_RCC_SYSCLK_DIV_4 * @arg @ref LL_RCC_SYSCLK_DIV_8 * @arg @ref LL_RCC_SYSCLK_DIV_16 * @arg @ref LL_RCC_SYSCLK_DIV_64 * @arg @ref LL_RCC_SYSCLK_DIV_128 * @arg @ref LL_RCC_SYSCLK_DIV_256 * @arg @ref LL_RCC_SYSCLK_DIV_512 */ __STATIC_INLINE uint32_t LL_RCC_GetAHBPrescaler(void) { return (uint32_t)(READ_BIT(RCC->CFGR, RCC_CFGR_HPRE)); } /** * @brief Get APB1 prescaler * @rmtoll CFGR PPRE1 LL_RCC_GetAPB1Prescaler * @retval Returned value can be one of the following values: * @arg @ref LL_RCC_APB1_DIV_1 * @arg @ref LL_RCC_APB1_DIV_2 * @arg @ref LL_RCC_APB1_DIV_4 * @arg @ref LL_RCC_APB1_DIV_8 * @arg @ref LL_RCC_APB1_DIV_16 */ __STATIC_INLINE uint32_t LL_RCC_GetAPB1Prescaler(void) { return (uint32_t)(READ_BIT(RCC->CFGR, RCC_CFGR_PPRE1)); } /** * @brief Get APB2 prescaler * @rmtoll CFGR PPRE2 LL_RCC_GetAPB2Prescaler * @retval Returned value can be one of the following values: * @arg @ref LL_RCC_APB2_DIV_1 * @arg @ref LL_RCC_APB2_DIV_2 * @arg @ref LL_RCC_APB2_DIV_4 * @arg @ref LL_RCC_APB2_DIV_8 * @arg @ref LL_RCC_APB2_DIV_16 */ __STATIC_INLINE uint32_t LL_RCC_GetAPB2Prescaler(void) { return (uint32_t)(READ_BIT(RCC->CFGR, RCC_CFGR_PPRE2)); } /** * @} */ /** @defgroup RCC_LL_EF_MCO MCO * @{ */ #if defined(RCC_CFGR_MCO1EN) /** * @brief Enable MCO1 output * @rmtoll CFGR RCC_CFGR_MCO1EN LL_RCC_MCO1_Enable * @retval None */ __STATIC_INLINE void LL_RCC_MCO1_Enable(void) { SET_BIT(RCC->CFGR, RCC_CFGR_MCO1EN); } /** * @brief Disable MCO1 output * @rmtoll CFGR RCC_CFGR_MCO1EN LL_RCC_MCO1_Disable * @retval None */ __STATIC_INLINE void LL_RCC_MCO1_Disable(void) { CLEAR_BIT(RCC->CFGR, RCC_CFGR_MCO1EN); } #endif /* RCC_CFGR_MCO1EN */ #if defined(RCC_CFGR_MCO2EN) /** * @brief Enable MCO2 output * @rmtoll CFGR RCC_CFGR_MCO2EN LL_RCC_MCO2_Enable * @retval None */ __STATIC_INLINE void LL_RCC_MCO2_Enable(void) { SET_BIT(RCC->CFGR, RCC_CFGR_MCO2EN); } /** * @brief Disable MCO2 output * @rmtoll CFGR RCC_CFGR_MCO2EN LL_RCC_MCO2_Disable * @retval None */ __STATIC_INLINE void LL_RCC_MCO2_Disable(void) { CLEAR_BIT(RCC->CFGR, RCC_CFGR_MCO2EN); } #endif /* RCC_CFGR_MCO2EN */ /** * @brief Configure MCOx * @rmtoll CFGR MCO1 LL_RCC_ConfigMCO\n * CFGR MCO1PRE LL_RCC_ConfigMCO\n * CFGR MCO2 LL_RCC_ConfigMCO\n * CFGR MCO2PRE LL_RCC_ConfigMCO * @param MCOxSource This parameter can be one of the following values: * @arg @ref LL_RCC_MCO1SOURCE_HSI * @arg @ref LL_RCC_MCO1SOURCE_LSE * @arg @ref LL_RCC_MCO1SOURCE_HSE * @arg @ref LL_RCC_MCO1SOURCE_PLLCLK * @arg @ref LL_RCC_MCO2SOURCE_SYSCLK * @arg @ref LL_RCC_MCO2SOURCE_PLLI2S * @arg @ref LL_RCC_MCO2SOURCE_HSE * @arg @ref LL_RCC_MCO2SOURCE_PLLCLK * @param MCOxPrescaler This parameter can be one of the following values: * @arg @ref LL_RCC_MCO1_DIV_1 * @arg @ref LL_RCC_MCO1_DIV_2 * @arg @ref LL_RCC_MCO1_DIV_3 * @arg @ref LL_RCC_MCO1_DIV_4 * @arg @ref LL_RCC_MCO1_DIV_5 * @arg @ref LL_RCC_MCO2_DIV_1 * @arg @ref LL_RCC_MCO2_DIV_2 * @arg @ref LL_RCC_MCO2_DIV_3 * @arg @ref LL_RCC_MCO2_DIV_4 * @arg @ref LL_RCC_MCO2_DIV_5 * @retval None */ __STATIC_INLINE void LL_RCC_ConfigMCO(uint32_t MCOxSource, uint32_t MCOxPrescaler) { MODIFY_REG(RCC->CFGR, (MCOxSource & 0xFFFF0000U) | (MCOxPrescaler & 0xFFFF0000U), (MCOxSource << 16U) | (MCOxPrescaler << 16U)); } /** * @} */ /** @defgroup RCC_LL_EF_Peripheral_Clock_Source Peripheral Clock Source * @{ */ #if defined(FMPI2C1) /** * @brief Configure FMPI2C clock source * @rmtoll DCKCFGR2 FMPI2C1SEL LL_RCC_SetFMPI2CClockSource * @param FMPI2CxSource This parameter can be one of the following values: * @arg @ref LL_RCC_FMPI2C1_CLKSOURCE_PCLK1 * @arg @ref LL_RCC_FMPI2C1_CLKSOURCE_SYSCLK * @arg @ref LL_RCC_FMPI2C1_CLKSOURCE_HSI * @retval None */ __STATIC_INLINE void LL_RCC_SetFMPI2CClockSource(uint32_t FMPI2CxSource) { MODIFY_REG(RCC->DCKCFGR2, RCC_DCKCFGR2_FMPI2C1SEL, FMPI2CxSource); } #endif /* FMPI2C1 */ #if defined(LPTIM1) /** * @brief Configure LPTIMx clock source * @rmtoll DCKCFGR2 LPTIM1SEL LL_RCC_SetLPTIMClockSource * @param LPTIMxSource This parameter can be one of the following values: * @arg @ref LL_RCC_LPTIM1_CLKSOURCE_PCLK1 * @arg @ref LL_RCC_LPTIM1_CLKSOURCE_HSI * @arg @ref LL_RCC_LPTIM1_CLKSOURCE_LSI * @arg @ref LL_RCC_LPTIM1_CLKSOURCE_LSE * @retval None */ __STATIC_INLINE void LL_RCC_SetLPTIMClockSource(uint32_t LPTIMxSource) { MODIFY_REG(RCC->DCKCFGR2, RCC_DCKCFGR2_LPTIM1SEL, LPTIMxSource); } #endif /* LPTIM1 */ #if defined(SAI1) /** * @brief Configure SAIx clock source * @rmtoll DCKCFGR SAI1SRC LL_RCC_SetSAIClockSource\n * DCKCFGR SAI2SRC LL_RCC_SetSAIClockSource\n * DCKCFGR SAI1ASRC LL_RCC_SetSAIClockSource\n * DCKCFGR SAI1BSRC LL_RCC_SetSAIClockSource * @param SAIxSource This parameter can be one of the following values: * @arg @ref LL_RCC_SAI1_CLKSOURCE_PLLSAI (*) * @arg @ref LL_RCC_SAI1_CLKSOURCE_PLLI2S (*) * @arg @ref LL_RCC_SAI1_CLKSOURCE_PLL (*) * @arg @ref LL_RCC_SAI1_CLKSOURCE_PIN (*) * @arg @ref LL_RCC_SAI2_CLKSOURCE_PLLSAI (*) * @arg @ref LL_RCC_SAI2_CLKSOURCE_PLLI2S (*) * @arg @ref LL_RCC_SAI2_CLKSOURCE_PLL (*) * @arg @ref LL_RCC_SAI2_CLKSOURCE_PLLSRC (*) * @arg @ref LL_RCC_SAI1_A_CLKSOURCE_PLLSAI (*) * @arg @ref LL_RCC_SAI1_A_CLKSOURCE_PLLI2S (*) * @arg @ref LL_RCC_SAI1_A_CLKSOURCE_PIN (*) * @arg @ref LL_RCC_SAI1_A_CLKSOURCE_PLL (*) * @arg @ref LL_RCC_SAI1_A_CLKSOURCE_PLLSRC (*) * @arg @ref LL_RCC_SAI1_B_CLKSOURCE_PLLSAI (*) * @arg @ref LL_RCC_SAI1_B_CLKSOURCE_PLLI2S (*) * @arg @ref LL_RCC_SAI1_B_CLKSOURCE_PIN (*) * @arg @ref LL_RCC_SAI1_B_CLKSOURCE_PLL (*) * @arg @ref LL_RCC_SAI1_B_CLKSOURCE_PLLSRC (*) * * (*) value not defined in all devices. * @retval None */ __STATIC_INLINE void LL_RCC_SetSAIClockSource(uint32_t SAIxSource) { MODIFY_REG(RCC->DCKCFGR, (SAIxSource & 0xFFFF0000U), (SAIxSource << 16U)); } #endif /* SAI1 */ #if defined(RCC_DCKCFGR_SDIOSEL) || defined(RCC_DCKCFGR2_SDIOSEL) /** * @brief Configure SDIO clock source * @rmtoll DCKCFGR SDIOSEL LL_RCC_SetSDIOClockSource\n * DCKCFGR2 SDIOSEL LL_RCC_SetSDIOClockSource * @param SDIOxSource This parameter can be one of the following values: * @arg @ref LL_RCC_SDIO_CLKSOURCE_PLL48CLK * @arg @ref LL_RCC_SDIO_CLKSOURCE_SYSCLK * @retval None */ __STATIC_INLINE void LL_RCC_SetSDIOClockSource(uint32_t SDIOxSource) { #if defined(RCC_DCKCFGR_SDIOSEL) MODIFY_REG(RCC->DCKCFGR, RCC_DCKCFGR_SDIOSEL, SDIOxSource); #else MODIFY_REG(RCC->DCKCFGR2, RCC_DCKCFGR2_SDIOSEL, SDIOxSource); #endif /* RCC_DCKCFGR_SDIOSEL */ } #endif /* RCC_DCKCFGR_SDIOSEL || RCC_DCKCFGR2_SDIOSEL */ #if defined(RCC_DCKCFGR_CK48MSEL) || defined(RCC_DCKCFGR2_CK48MSEL) /** * @brief Configure 48Mhz domain clock source * @rmtoll DCKCFGR CK48MSEL LL_RCC_SetCK48MClockSource\n * DCKCFGR2 CK48MSEL LL_RCC_SetCK48MClockSource * @param CK48MxSource This parameter can be one of the following values: * @arg @ref LL_RCC_CK48M_CLKSOURCE_PLL * @arg @ref LL_RCC_CK48M_CLKSOURCE_PLLSAI (*) * @arg @ref LL_RCC_CK48M_CLKSOURCE_PLLI2S (*) * * (*) value not defined in all devices. * @retval None */ __STATIC_INLINE void LL_RCC_SetCK48MClockSource(uint32_t CK48MxSource) { #if defined(RCC_DCKCFGR_CK48MSEL) MODIFY_REG(RCC->DCKCFGR, RCC_DCKCFGR_CK48MSEL, CK48MxSource); #else MODIFY_REG(RCC->DCKCFGR2, RCC_DCKCFGR2_CK48MSEL, CK48MxSource); #endif /* RCC_DCKCFGR_CK48MSEL */ } #if defined(RNG) /** * @brief Configure RNG clock source * @rmtoll DCKCFGR CK48MSEL LL_RCC_SetRNGClockSource\n * DCKCFGR2 CK48MSEL LL_RCC_SetRNGClockSource * @param RNGxSource This parameter can be one of the following values: * @arg @ref LL_RCC_RNG_CLKSOURCE_PLL * @arg @ref LL_RCC_RNG_CLKSOURCE_PLLSAI (*) * @arg @ref LL_RCC_RNG_CLKSOURCE_PLLI2S (*) * * (*) value not defined in all devices. * @retval None */ __STATIC_INLINE void LL_RCC_SetRNGClockSource(uint32_t RNGxSource) { #if defined(RCC_DCKCFGR_CK48MSEL) MODIFY_REG(RCC->DCKCFGR, RCC_DCKCFGR_CK48MSEL, RNGxSource); #else MODIFY_REG(RCC->DCKCFGR2, RCC_DCKCFGR2_CK48MSEL, RNGxSource); #endif /* RCC_DCKCFGR_CK48MSEL */ } #endif /* RNG */ #if defined(USB_OTG_FS) || defined(USB_OTG_HS) /** * @brief Configure USB clock source * @rmtoll DCKCFGR CK48MSEL LL_RCC_SetUSBClockSource\n * DCKCFGR2 CK48MSEL LL_RCC_SetUSBClockSource * @param USBxSource This parameter can be one of the following values: * @arg @ref LL_RCC_USB_CLKSOURCE_PLL * @arg @ref LL_RCC_USB_CLKSOURCE_PLLSAI (*) * @arg @ref LL_RCC_USB_CLKSOURCE_PLLI2S (*) * * (*) value not defined in all devices. * @retval None */ __STATIC_INLINE void LL_RCC_SetUSBClockSource(uint32_t USBxSource) { #if defined(RCC_DCKCFGR_CK48MSEL) MODIFY_REG(RCC->DCKCFGR, RCC_DCKCFGR_CK48MSEL, USBxSource); #else MODIFY_REG(RCC->DCKCFGR2, RCC_DCKCFGR2_CK48MSEL, USBxSource); #endif /* RCC_DCKCFGR_CK48MSEL */ } #endif /* USB_OTG_FS || USB_OTG_HS */ #endif /* RCC_DCKCFGR_CK48MSEL || RCC_DCKCFGR2_CK48MSEL */ #if defined(CEC) /** * @brief Configure CEC clock source * @rmtoll DCKCFGR2 CECSEL LL_RCC_SetCECClockSource * @param Source This parameter can be one of the following values: * @arg @ref LL_RCC_CEC_CLKSOURCE_HSI_DIV488 * @arg @ref LL_RCC_CEC_CLKSOURCE_LSE * @retval None */ __STATIC_INLINE void LL_RCC_SetCECClockSource(uint32_t Source) { MODIFY_REG(RCC->DCKCFGR2, RCC_DCKCFGR2_CECSEL, Source); } #endif /* CEC */ /** * @brief Configure I2S clock source * @rmtoll CFGR I2SSRC LL_RCC_SetI2SClockSource\n * DCKCFGR I2SSRC LL_RCC_SetI2SClockSource\n * DCKCFGR I2S1SRC LL_RCC_SetI2SClockSource\n * DCKCFGR I2S2SRC LL_RCC_SetI2SClockSource * @param Source This parameter can be one of the following values: * @arg @ref LL_RCC_I2S1_CLKSOURCE_PLLI2S (*) * @arg @ref LL_RCC_I2S1_CLKSOURCE_PIN * @arg @ref LL_RCC_I2S1_CLKSOURCE_PLL (*) * @arg @ref LL_RCC_I2S1_CLKSOURCE_PLLSRC (*) * @arg @ref LL_RCC_I2S2_CLKSOURCE_PLLI2S (*) * @arg @ref LL_RCC_I2S2_CLKSOURCE_PIN (*) * @arg @ref LL_RCC_I2S2_CLKSOURCE_PLL (*) * @arg @ref LL_RCC_I2S2_CLKSOURCE_PLLSRC (*) * * (*) value not defined in all devices. * @retval None */ __STATIC_INLINE void LL_RCC_SetI2SClockSource(uint32_t Source) { #if defined(RCC_CFGR_I2SSRC) MODIFY_REG(RCC->CFGR, RCC_CFGR_I2SSRC, Source); #else MODIFY_REG(RCC->DCKCFGR, (Source & 0xFFFF0000U), (Source << 16U)); #endif /* RCC_CFGR_I2SSRC */ } #if defined(DSI) /** * @brief Configure DSI clock source * @rmtoll DCKCFGR DSISEL LL_RCC_SetDSIClockSource * @param Source This parameter can be one of the following values: * @arg @ref LL_RCC_DSI_CLKSOURCE_PHY * @arg @ref LL_RCC_DSI_CLKSOURCE_PLL * @retval None */ __STATIC_INLINE void LL_RCC_SetDSIClockSource(uint32_t Source) { MODIFY_REG(RCC->DCKCFGR, RCC_DCKCFGR_DSISEL, Source); } #endif /* DSI */ #if defined(DFSDM1_Channel0) /** * @brief Configure DFSDM Audio clock source * @rmtoll DCKCFGR CKDFSDM1ASEL LL_RCC_SetDFSDMAudioClockSource\n * DCKCFGR CKDFSDM2ASEL LL_RCC_SetDFSDMAudioClockSource * @param Source This parameter can be one of the following values: * @arg @ref LL_RCC_DFSDM1_AUDIO_CLKSOURCE_I2S1 * @arg @ref LL_RCC_DFSDM1_AUDIO_CLKSOURCE_I2S2 * @arg @ref LL_RCC_DFSDM2_AUDIO_CLKSOURCE_I2S1 (*) * @arg @ref LL_RCC_DFSDM2_AUDIO_CLKSOURCE_I2S2 (*) * * (*) value not defined in all devices. * @retval None */ __STATIC_INLINE void LL_RCC_SetDFSDMAudioClockSource(uint32_t Source) { MODIFY_REG(RCC->DCKCFGR, (Source & 0x0000FFFFU), (Source >> 16U)); } /** * @brief Configure DFSDM Kernel clock source * @rmtoll DCKCFGR CKDFSDM1SEL LL_RCC_SetDFSDMClockSource * @param Source This parameter can be one of the following values: * @arg @ref LL_RCC_DFSDM1_CLKSOURCE_PCLK2 * @arg @ref LL_RCC_DFSDM1_CLKSOURCE_SYSCLK * @arg @ref LL_RCC_DFSDM2_CLKSOURCE_PCLK2 (*) * @arg @ref LL_RCC_DFSDM2_CLKSOURCE_SYSCLK (*) * * (*) value not defined in all devices. * @retval None */ __STATIC_INLINE void LL_RCC_SetDFSDMClockSource(uint32_t Source) { MODIFY_REG(RCC->DCKCFGR, RCC_DCKCFGR_CKDFSDM1SEL, Source); } #endif /* DFSDM1_Channel0 */ #if defined(SPDIFRX) /** * @brief Configure SPDIFRX clock source * @rmtoll DCKCFGR2 SPDIFRXSEL LL_RCC_SetSPDIFRXClockSource * @param SPDIFRXxSource This parameter can be one of the following values: * @arg @ref LL_RCC_SPDIFRX1_CLKSOURCE_PLL * @arg @ref LL_RCC_SPDIFRX1_CLKSOURCE_PLLI2S * * (*) value not defined in all devices. * @retval None */ __STATIC_INLINE void LL_RCC_SetSPDIFRXClockSource(uint32_t SPDIFRXxSource) { MODIFY_REG(RCC->DCKCFGR2, RCC_DCKCFGR2_SPDIFRXSEL, SPDIFRXxSource); } #endif /* SPDIFRX */ #if defined(FMPI2C1) /** * @brief Get FMPI2C clock source * @rmtoll DCKCFGR2 FMPI2C1SEL LL_RCC_GetFMPI2CClockSource * @param FMPI2Cx This parameter can be one of the following values: * @arg @ref LL_RCC_FMPI2C1_CLKSOURCE * @retval Returned value can be one of the following values: * @arg @ref LL_RCC_FMPI2C1_CLKSOURCE_PCLK1 * @arg @ref LL_RCC_FMPI2C1_CLKSOURCE_SYSCLK * @arg @ref LL_RCC_FMPI2C1_CLKSOURCE_HSI */ __STATIC_INLINE uint32_t LL_RCC_GetFMPI2CClockSource(uint32_t FMPI2Cx) { return (uint32_t)(READ_BIT(RCC->DCKCFGR2, FMPI2Cx)); } #endif /* FMPI2C1 */ #if defined(LPTIM1) /** * @brief Get LPTIMx clock source * @rmtoll DCKCFGR2 LPTIM1SEL LL_RCC_GetLPTIMClockSource * @param LPTIMx This parameter can be one of the following values: * @arg @ref LL_RCC_LPTIM1_CLKSOURCE * @retval Returned value can be one of the following values: * @arg @ref LL_RCC_LPTIM1_CLKSOURCE_PCLK1 * @arg @ref LL_RCC_LPTIM1_CLKSOURCE_HSI * @arg @ref LL_RCC_LPTIM1_CLKSOURCE_LSI * @arg @ref LL_RCC_LPTIM1_CLKSOURCE_LSE */ __STATIC_INLINE uint32_t LL_RCC_GetLPTIMClockSource(uint32_t LPTIMx) { return (uint32_t)(READ_BIT(RCC->DCKCFGR2, RCC_DCKCFGR2_LPTIM1SEL)); } #endif /* LPTIM1 */ #if defined(SAI1) /** * @brief Get SAIx clock source * @rmtoll DCKCFGR SAI1SEL LL_RCC_GetSAIClockSource\n * DCKCFGR SAI2SEL LL_RCC_GetSAIClockSource\n * DCKCFGR SAI1ASRC LL_RCC_GetSAIClockSource\n * DCKCFGR SAI1BSRC LL_RCC_GetSAIClockSource * @param SAIx This parameter can be one of the following values: * @arg @ref LL_RCC_SAI1_CLKSOURCE (*) * @arg @ref LL_RCC_SAI2_CLKSOURCE (*) * @arg @ref LL_RCC_SAI1_A_CLKSOURCE (*) * @arg @ref LL_RCC_SAI1_B_CLKSOURCE (*) * * (*) value not defined in all devices. * @retval Returned value can be one of the following values: * @arg @ref LL_RCC_SAI1_CLKSOURCE_PLLSAI (*) * @arg @ref LL_RCC_SAI1_CLKSOURCE_PLLI2S (*) * @arg @ref LL_RCC_SAI1_CLKSOURCE_PLL (*) * @arg @ref LL_RCC_SAI1_CLKSOURCE_PIN (*) * @arg @ref LL_RCC_SAI2_CLKSOURCE_PLLSAI (*) * @arg @ref LL_RCC_SAI2_CLKSOURCE_PLLI2S (*) * @arg @ref LL_RCC_SAI2_CLKSOURCE_PLL (*) * @arg @ref LL_RCC_SAI2_CLKSOURCE_PLLSRC (*) * @arg @ref LL_RCC_SAI1_A_CLKSOURCE_PLLSAI (*) * @arg @ref LL_RCC_SAI1_A_CLKSOURCE_PLLI2S (*) * @arg @ref LL_RCC_SAI1_A_CLKSOURCE_PIN (*) * @arg @ref LL_RCC_SAI1_A_CLKSOURCE_PLL (*) * @arg @ref LL_RCC_SAI1_A_CLKSOURCE_PLLSRC (*) * @arg @ref LL_RCC_SAI1_B_CLKSOURCE_PLLSAI (*) * @arg @ref LL_RCC_SAI1_B_CLKSOURCE_PLLI2S (*) * @arg @ref LL_RCC_SAI1_B_CLKSOURCE_PIN (*) * @arg @ref LL_RCC_SAI1_B_CLKSOURCE_PLL (*) * @arg @ref LL_RCC_SAI1_B_CLKSOURCE_PLLSRC (*) * * (*) value not defined in all devices. */ __STATIC_INLINE uint32_t LL_RCC_GetSAIClockSource(uint32_t SAIx) { return (uint32_t)(READ_BIT(RCC->DCKCFGR, SAIx) >> 16U | SAIx); } #endif /* SAI1 */ #if defined(RCC_DCKCFGR_SDIOSEL) || defined(RCC_DCKCFGR2_SDIOSEL) /** * @brief Get SDIOx clock source * @rmtoll DCKCFGR SDIOSEL LL_RCC_GetSDIOClockSource\n * DCKCFGR2 SDIOSEL LL_RCC_GetSDIOClockSource * @param SDIOx This parameter can be one of the following values: * @arg @ref LL_RCC_SDIO_CLKSOURCE * @retval Returned value can be one of the following values: * @arg @ref LL_RCC_SDIO_CLKSOURCE_PLL48CLK * @arg @ref LL_RCC_SDIO_CLKSOURCE_SYSCLK */ __STATIC_INLINE uint32_t LL_RCC_GetSDIOClockSource(uint32_t SDIOx) { #if defined(RCC_DCKCFGR_SDIOSEL) return (uint32_t)(READ_BIT(RCC->DCKCFGR, SDIOx)); #else return (uint32_t)(READ_BIT(RCC->DCKCFGR2, SDIOx)); #endif /* RCC_DCKCFGR_SDIOSEL */ } #endif /* RCC_DCKCFGR_SDIOSEL || RCC_DCKCFGR2_SDIOSEL */ #if defined(RCC_DCKCFGR_CK48MSEL) || defined(RCC_DCKCFGR2_CK48MSEL) /** * @brief Get 48Mhz domain clock source * @rmtoll DCKCFGR CK48MSEL LL_RCC_GetCK48MClockSource\n * DCKCFGR2 CK48MSEL LL_RCC_GetCK48MClockSource * @param CK48Mx This parameter can be one of the following values: * @arg @ref LL_RCC_CK48M_CLKSOURCE * @retval Returned value can be one of the following values: * @arg @ref LL_RCC_CK48M_CLKSOURCE_PLL * @arg @ref LL_RCC_CK48M_CLKSOURCE_PLLSAI (*) * @arg @ref LL_RCC_CK48M_CLKSOURCE_PLLI2S (*) * * (*) value not defined in all devices. */ __STATIC_INLINE uint32_t LL_RCC_GetCK48MClockSource(uint32_t CK48Mx) { #if defined(RCC_DCKCFGR_CK48MSEL) return (uint32_t)(READ_BIT(RCC->DCKCFGR, CK48Mx)); #else return (uint32_t)(READ_BIT(RCC->DCKCFGR2, CK48Mx)); #endif /* RCC_DCKCFGR_CK48MSEL */ } #if defined(RNG) /** * @brief Get RNGx clock source * @rmtoll DCKCFGR CK48MSEL LL_RCC_GetRNGClockSource\n * DCKCFGR2 CK48MSEL LL_RCC_GetRNGClockSource * @param RNGx This parameter can be one of the following values: * @arg @ref LL_RCC_RNG_CLKSOURCE * @retval Returned value can be one of the following values: * @arg @ref LL_RCC_RNG_CLKSOURCE_PLL * @arg @ref LL_RCC_RNG_CLKSOURCE_PLLSAI (*) * @arg @ref LL_RCC_RNG_CLKSOURCE_PLLI2S (*) * * (*) value not defined in all devices. */ __STATIC_INLINE uint32_t LL_RCC_GetRNGClockSource(uint32_t RNGx) { #if defined(RCC_DCKCFGR_CK48MSEL) return (uint32_t)(READ_BIT(RCC->DCKCFGR, RNGx)); #else return (uint32_t)(READ_BIT(RCC->DCKCFGR2, RNGx)); #endif /* RCC_DCKCFGR_CK48MSEL */ } #endif /* RNG */ #if defined(USB_OTG_FS) || defined(USB_OTG_HS) /** * @brief Get USBx clock source * @rmtoll DCKCFGR CK48MSEL LL_RCC_GetUSBClockSource\n * DCKCFGR2 CK48MSEL LL_RCC_GetUSBClockSource * @param USBx This parameter can be one of the following values: * @arg @ref LL_RCC_USB_CLKSOURCE * @retval Returned value can be one of the following values: * @arg @ref LL_RCC_USB_CLKSOURCE_PLL * @arg @ref LL_RCC_USB_CLKSOURCE_PLLSAI (*) * @arg @ref LL_RCC_USB_CLKSOURCE_PLLI2S (*) * * (*) value not defined in all devices. */ __STATIC_INLINE uint32_t LL_RCC_GetUSBClockSource(uint32_t USBx) { #if defined(RCC_DCKCFGR_CK48MSEL) return (uint32_t)(READ_BIT(RCC->DCKCFGR, USBx)); #else return (uint32_t)(READ_BIT(RCC->DCKCFGR2, USBx)); #endif /* RCC_DCKCFGR_CK48MSEL */ } #endif /* USB_OTG_FS || USB_OTG_HS */ #endif /* RCC_DCKCFGR_CK48MSEL || RCC_DCKCFGR2_CK48MSEL */ #if defined(CEC) /** * @brief Get CEC Clock Source * @rmtoll DCKCFGR2 CECSEL LL_RCC_GetCECClockSource * @param CECx This parameter can be one of the following values: * @arg @ref LL_RCC_CEC_CLKSOURCE * @retval Returned value can be one of the following values: * @arg @ref LL_RCC_CEC_CLKSOURCE_HSI_DIV488 * @arg @ref LL_RCC_CEC_CLKSOURCE_LSE */ __STATIC_INLINE uint32_t LL_RCC_GetCECClockSource(uint32_t CECx) { return (uint32_t)(READ_BIT(RCC->DCKCFGR2, CECx)); } #endif /* CEC */ /** * @brief Get I2S Clock Source * @rmtoll CFGR I2SSRC LL_RCC_GetI2SClockSource\n * DCKCFGR I2SSRC LL_RCC_GetI2SClockSource\n * DCKCFGR I2S1SRC LL_RCC_GetI2SClockSource\n * DCKCFGR I2S2SRC LL_RCC_GetI2SClockSource * @param I2Sx This parameter can be one of the following values: * @arg @ref LL_RCC_I2S1_CLKSOURCE * @arg @ref LL_RCC_I2S2_CLKSOURCE (*) * @retval Returned value can be one of the following values: * @arg @ref LL_RCC_I2S1_CLKSOURCE_PLLI2S (*) * @arg @ref LL_RCC_I2S1_CLKSOURCE_PIN * @arg @ref LL_RCC_I2S1_CLKSOURCE_PLL (*) * @arg @ref LL_RCC_I2S1_CLKSOURCE_PLLSRC (*) * @arg @ref LL_RCC_I2S2_CLKSOURCE_PLLI2S (*) * @arg @ref LL_RCC_I2S2_CLKSOURCE_PIN (*) * @arg @ref LL_RCC_I2S2_CLKSOURCE_PLL (*) * @arg @ref LL_RCC_I2S2_CLKSOURCE_PLLSRC (*) * * (*) value not defined in all devices. */ __STATIC_INLINE uint32_t LL_RCC_GetI2SClockSource(uint32_t I2Sx) { #if defined(RCC_CFGR_I2SSRC) return (uint32_t)(READ_BIT(RCC->CFGR, I2Sx)); #else return (uint32_t)(READ_BIT(RCC->DCKCFGR, I2Sx) >> 16U | I2Sx); #endif /* RCC_CFGR_I2SSRC */ } #if defined(DFSDM1_Channel0) /** * @brief Get DFSDM Audio Clock Source * @rmtoll DCKCFGR CKDFSDM1ASEL LL_RCC_GetDFSDMAudioClockSource\n * DCKCFGR CKDFSDM2ASEL LL_RCC_GetDFSDMAudioClockSource * @param DFSDMx This parameter can be one of the following values: * @arg @ref LL_RCC_DFSDM1_AUDIO_CLKSOURCE * @arg @ref LL_RCC_DFSDM2_AUDIO_CLKSOURCE (*) * @retval Returned value can be one of the following values: * @arg @ref LL_RCC_DFSDM1_AUDIO_CLKSOURCE_I2S1 * @arg @ref LL_RCC_DFSDM1_AUDIO_CLKSOURCE_I2S2 * @arg @ref LL_RCC_DFSDM2_AUDIO_CLKSOURCE_I2S1 (*) * @arg @ref LL_RCC_DFSDM2_AUDIO_CLKSOURCE_I2S2 (*) * * (*) value not defined in all devices. */ __STATIC_INLINE uint32_t LL_RCC_GetDFSDMAudioClockSource(uint32_t DFSDMx) { return (uint32_t)(READ_BIT(RCC->DCKCFGR, DFSDMx) << 16U | DFSDMx); } /** * @brief Get DFSDM Audio Clock Source * @rmtoll DCKCFGR CKDFSDM1SEL LL_RCC_GetDFSDMClockSource * @param DFSDMx This parameter can be one of the following values: * @arg @ref LL_RCC_DFSDM1_CLKSOURCE * @arg @ref LL_RCC_DFSDM2_CLKSOURCE (*) * @retval Returned value can be one of the following values: * @arg @ref LL_RCC_DFSDM1_CLKSOURCE_PCLK2 * @arg @ref LL_RCC_DFSDM1_CLKSOURCE_SYSCLK * @arg @ref LL_RCC_DFSDM2_CLKSOURCE_PCLK2 (*) * @arg @ref LL_RCC_DFSDM2_CLKSOURCE_SYSCLK (*) * * (*) value not defined in all devices. */ __STATIC_INLINE uint32_t LL_RCC_GetDFSDMClockSource(uint32_t DFSDMx) { return (uint32_t)(READ_BIT(RCC->DCKCFGR, DFSDMx)); } #endif /* DFSDM1_Channel0 */ #if defined(SPDIFRX) /** * @brief Get SPDIFRX clock source * @rmtoll DCKCFGR2 SPDIFRXSEL LL_RCC_GetSPDIFRXClockSource * @param SPDIFRXx This parameter can be one of the following values: * @arg @ref LL_RCC_SPDIFRX1_CLKSOURCE * @retval Returned value can be one of the following values: * @arg @ref LL_RCC_SPDIFRX1_CLKSOURCE_PLL * @arg @ref LL_RCC_SPDIFRX1_CLKSOURCE_PLLI2S * * (*) value not defined in all devices. */ __STATIC_INLINE uint32_t LL_RCC_GetSPDIFRXClockSource(uint32_t SPDIFRXx) { return (uint32_t)(READ_BIT(RCC->DCKCFGR2, SPDIFRXx)); } #endif /* SPDIFRX */ #if defined(DSI) /** * @brief Get DSI Clock Source * @rmtoll DCKCFGR DSISEL LL_RCC_GetDSIClockSource * @param DSIx This parameter can be one of the following values: * @arg @ref LL_RCC_DSI_CLKSOURCE * @retval Returned value can be one of the following values: * @arg @ref LL_RCC_DSI_CLKSOURCE_PHY * @arg @ref LL_RCC_DSI_CLKSOURCE_PLL */ __STATIC_INLINE uint32_t LL_RCC_GetDSIClockSource(uint32_t DSIx) { return (uint32_t)(READ_BIT(RCC->DCKCFGR, DSIx)); } #endif /* DSI */ /** * @} */ /** @defgroup RCC_LL_EF_RTC RTC * @{ */ /** * @brief Set RTC Clock Source * @note Once the RTC clock source has been selected, it cannot be changed anymore unless * the Backup domain is reset, or unless a failure is detected on LSE (LSECSSD is * set). The BDRST bit can be used to reset them. * @rmtoll BDCR RTCSEL LL_RCC_SetRTCClockSource * @param Source This parameter can be one of the following values: * @arg @ref LL_RCC_RTC_CLKSOURCE_NONE * @arg @ref LL_RCC_RTC_CLKSOURCE_LSE * @arg @ref LL_RCC_RTC_CLKSOURCE_LSI * @arg @ref LL_RCC_RTC_CLKSOURCE_HSE * @retval None */ __STATIC_INLINE void LL_RCC_SetRTCClockSource(uint32_t Source) { MODIFY_REG(RCC->BDCR, RCC_BDCR_RTCSEL, Source); } /** * @brief Get RTC Clock Source * @rmtoll BDCR RTCSEL LL_RCC_GetRTCClockSource * @retval Returned value can be one of the following values: * @arg @ref LL_RCC_RTC_CLKSOURCE_NONE * @arg @ref LL_RCC_RTC_CLKSOURCE_LSE * @arg @ref LL_RCC_RTC_CLKSOURCE_LSI * @arg @ref LL_RCC_RTC_CLKSOURCE_HSE */ __STATIC_INLINE uint32_t LL_RCC_GetRTCClockSource(void) { return (uint32_t)(READ_BIT(RCC->BDCR, RCC_BDCR_RTCSEL)); } /** * @brief Enable RTC * @rmtoll BDCR RTCEN LL_RCC_EnableRTC * @retval None */ __STATIC_INLINE void LL_RCC_EnableRTC(void) { SET_BIT(RCC->BDCR, RCC_BDCR_RTCEN); } /** * @brief Disable RTC * @rmtoll BDCR RTCEN LL_RCC_DisableRTC * @retval None */ __STATIC_INLINE void LL_RCC_DisableRTC(void) { CLEAR_BIT(RCC->BDCR, RCC_BDCR_RTCEN); } /** * @brief Check if RTC has been enabled or not * @rmtoll BDCR RTCEN LL_RCC_IsEnabledRTC * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_RCC_IsEnabledRTC(void) { return (READ_BIT(RCC->BDCR, RCC_BDCR_RTCEN) == (RCC_BDCR_RTCEN)); } /** * @brief Force the Backup domain reset * @rmtoll BDCR BDRST LL_RCC_ForceBackupDomainReset * @retval None */ __STATIC_INLINE void LL_RCC_ForceBackupDomainReset(void) { SET_BIT(RCC->BDCR, RCC_BDCR_BDRST); } /** * @brief Release the Backup domain reset * @rmtoll BDCR BDRST LL_RCC_ReleaseBackupDomainReset * @retval None */ __STATIC_INLINE void LL_RCC_ReleaseBackupDomainReset(void) { CLEAR_BIT(RCC->BDCR, RCC_BDCR_BDRST); } /** * @brief Set HSE Prescalers for RTC Clock * @rmtoll CFGR RTCPRE LL_RCC_SetRTC_HSEPrescaler * @param Prescaler This parameter can be one of the following values: * @arg @ref LL_RCC_RTC_NOCLOCK * @arg @ref LL_RCC_RTC_HSE_DIV_2 * @arg @ref LL_RCC_RTC_HSE_DIV_3 * @arg @ref LL_RCC_RTC_HSE_DIV_4 * @arg @ref LL_RCC_RTC_HSE_DIV_5 * @arg @ref LL_RCC_RTC_HSE_DIV_6 * @arg @ref LL_RCC_RTC_HSE_DIV_7 * @arg @ref LL_RCC_RTC_HSE_DIV_8 * @arg @ref LL_RCC_RTC_HSE_DIV_9 * @arg @ref LL_RCC_RTC_HSE_DIV_10 * @arg @ref LL_RCC_RTC_HSE_DIV_11 * @arg @ref LL_RCC_RTC_HSE_DIV_12 * @arg @ref LL_RCC_RTC_HSE_DIV_13 * @arg @ref LL_RCC_RTC_HSE_DIV_14 * @arg @ref LL_RCC_RTC_HSE_DIV_15 * @arg @ref LL_RCC_RTC_HSE_DIV_16 * @arg @ref LL_RCC_RTC_HSE_DIV_17 * @arg @ref LL_RCC_RTC_HSE_DIV_18 * @arg @ref LL_RCC_RTC_HSE_DIV_19 * @arg @ref LL_RCC_RTC_HSE_DIV_20 * @arg @ref LL_RCC_RTC_HSE_DIV_21 * @arg @ref LL_RCC_RTC_HSE_DIV_22 * @arg @ref LL_RCC_RTC_HSE_DIV_23 * @arg @ref LL_RCC_RTC_HSE_DIV_24 * @arg @ref LL_RCC_RTC_HSE_DIV_25 * @arg @ref LL_RCC_RTC_HSE_DIV_26 * @arg @ref LL_RCC_RTC_HSE_DIV_27 * @arg @ref LL_RCC_RTC_HSE_DIV_28 * @arg @ref LL_RCC_RTC_HSE_DIV_29 * @arg @ref LL_RCC_RTC_HSE_DIV_30 * @arg @ref LL_RCC_RTC_HSE_DIV_31 * @retval None */ __STATIC_INLINE void LL_RCC_SetRTC_HSEPrescaler(uint32_t Prescaler) { MODIFY_REG(RCC->CFGR, RCC_CFGR_RTCPRE, Prescaler); } /** * @brief Get HSE Prescalers for RTC Clock * @rmtoll CFGR RTCPRE LL_RCC_GetRTC_HSEPrescaler * @retval Returned value can be one of the following values: * @arg @ref LL_RCC_RTC_NOCLOCK * @arg @ref LL_RCC_RTC_HSE_DIV_2 * @arg @ref LL_RCC_RTC_HSE_DIV_3 * @arg @ref LL_RCC_RTC_HSE_DIV_4 * @arg @ref LL_RCC_RTC_HSE_DIV_5 * @arg @ref LL_RCC_RTC_HSE_DIV_6 * @arg @ref LL_RCC_RTC_HSE_DIV_7 * @arg @ref LL_RCC_RTC_HSE_DIV_8 * @arg @ref LL_RCC_RTC_HSE_DIV_9 * @arg @ref LL_RCC_RTC_HSE_DIV_10 * @arg @ref LL_RCC_RTC_HSE_DIV_11 * @arg @ref LL_RCC_RTC_HSE_DIV_12 * @arg @ref LL_RCC_RTC_HSE_DIV_13 * @arg @ref LL_RCC_RTC_HSE_DIV_14 * @arg @ref LL_RCC_RTC_HSE_DIV_15 * @arg @ref LL_RCC_RTC_HSE_DIV_16 * @arg @ref LL_RCC_RTC_HSE_DIV_17 * @arg @ref LL_RCC_RTC_HSE_DIV_18 * @arg @ref LL_RCC_RTC_HSE_DIV_19 * @arg @ref LL_RCC_RTC_HSE_DIV_20 * @arg @ref LL_RCC_RTC_HSE_DIV_21 * @arg @ref LL_RCC_RTC_HSE_DIV_22 * @arg @ref LL_RCC_RTC_HSE_DIV_23 * @arg @ref LL_RCC_RTC_HSE_DIV_24 * @arg @ref LL_RCC_RTC_HSE_DIV_25 * @arg @ref LL_RCC_RTC_HSE_DIV_26 * @arg @ref LL_RCC_RTC_HSE_DIV_27 * @arg @ref LL_RCC_RTC_HSE_DIV_28 * @arg @ref LL_RCC_RTC_HSE_DIV_29 * @arg @ref LL_RCC_RTC_HSE_DIV_30 * @arg @ref LL_RCC_RTC_HSE_DIV_31 */ __STATIC_INLINE uint32_t LL_RCC_GetRTC_HSEPrescaler(void) { return (uint32_t)(READ_BIT(RCC->CFGR, RCC_CFGR_RTCPRE)); } /** * @} */ #if defined(RCC_DCKCFGR_TIMPRE) /** @defgroup RCC_LL_EF_TIM_CLOCK_PRESCALER TIM * @{ */ /** * @brief Set Timers Clock Prescalers * @rmtoll DCKCFGR TIMPRE LL_RCC_SetTIMPrescaler * @param Prescaler This parameter can be one of the following values: * @arg @ref LL_RCC_TIM_PRESCALER_TWICE * @arg @ref LL_RCC_TIM_PRESCALER_FOUR_TIMES * @retval None */ __STATIC_INLINE void LL_RCC_SetTIMPrescaler(uint32_t Prescaler) { MODIFY_REG(RCC->DCKCFGR, RCC_DCKCFGR_TIMPRE, Prescaler); } /** * @brief Get Timers Clock Prescalers * @rmtoll DCKCFGR TIMPRE LL_RCC_GetTIMPrescaler * @retval Returned value can be one of the following values: * @arg @ref LL_RCC_TIM_PRESCALER_TWICE * @arg @ref LL_RCC_TIM_PRESCALER_FOUR_TIMES */ __STATIC_INLINE uint32_t LL_RCC_GetTIMPrescaler(void) { return (uint32_t)(READ_BIT(RCC->DCKCFGR, RCC_DCKCFGR_TIMPRE)); } /** * @} */ #endif /* RCC_DCKCFGR_TIMPRE */ /** @defgroup RCC_LL_EF_PLL PLL * @{ */ /** * @brief Enable PLL * @rmtoll CR PLLON LL_RCC_PLL_Enable * @retval None */ __STATIC_INLINE void LL_RCC_PLL_Enable(void) { SET_BIT(RCC->CR, RCC_CR_PLLON); } /** * @brief Disable PLL * @note Cannot be disabled if the PLL clock is used as the system clock * @rmtoll CR PLLON LL_RCC_PLL_Disable * @retval None */ __STATIC_INLINE void LL_RCC_PLL_Disable(void) { CLEAR_BIT(RCC->CR, RCC_CR_PLLON); } /** * @brief Check if PLL Ready * @rmtoll CR PLLRDY LL_RCC_PLL_IsReady * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_RCC_PLL_IsReady(void) { return (READ_BIT(RCC->CR, RCC_CR_PLLRDY) == (RCC_CR_PLLRDY)); } /** * @brief Configure PLL used for SYSCLK Domain * @note PLL Source and PLLM Divider can be written only when PLL, * PLLI2S and PLLSAI(*) are disabled * @note PLLN/PLLP can be written only when PLL is disabled * @rmtoll PLLCFGR PLLSRC LL_RCC_PLL_ConfigDomain_SYS\n * PLLCFGR PLLM LL_RCC_PLL_ConfigDomain_SYS\n * PLLCFGR PLLN LL_RCC_PLL_ConfigDomain_SYS\n * PLLCFGR PLLR LL_RCC_PLL_ConfigDomain_SYS\n * PLLCFGR PLLP LL_RCC_PLL_ConfigDomain_SYS * @param Source This parameter can be one of the following values: * @arg @ref LL_RCC_PLLSOURCE_HSI * @arg @ref LL_RCC_PLLSOURCE_HSE * @param PLLM This parameter can be one of the following values: * @arg @ref LL_RCC_PLLM_DIV_2 * @arg @ref LL_RCC_PLLM_DIV_3 * @arg @ref LL_RCC_PLLM_DIV_4 * @arg @ref LL_RCC_PLLM_DIV_5 * @arg @ref LL_RCC_PLLM_DIV_6 * @arg @ref LL_RCC_PLLM_DIV_7 * @arg @ref LL_RCC_PLLM_DIV_8 * @arg @ref LL_RCC_PLLM_DIV_9 * @arg @ref LL_RCC_PLLM_DIV_10 * @arg @ref LL_RCC_PLLM_DIV_11 * @arg @ref LL_RCC_PLLM_DIV_12 * @arg @ref LL_RCC_PLLM_DIV_13 * @arg @ref LL_RCC_PLLM_DIV_14 * @arg @ref LL_RCC_PLLM_DIV_15 * @arg @ref LL_RCC_PLLM_DIV_16 * @arg @ref LL_RCC_PLLM_DIV_17 * @arg @ref LL_RCC_PLLM_DIV_18 * @arg @ref LL_RCC_PLLM_DIV_19 * @arg @ref LL_RCC_PLLM_DIV_20 * @arg @ref LL_RCC_PLLM_DIV_21 * @arg @ref LL_RCC_PLLM_DIV_22 * @arg @ref LL_RCC_PLLM_DIV_23 * @arg @ref LL_RCC_PLLM_DIV_24 * @arg @ref LL_RCC_PLLM_DIV_25 * @arg @ref LL_RCC_PLLM_DIV_26 * @arg @ref LL_RCC_PLLM_DIV_27 * @arg @ref LL_RCC_PLLM_DIV_28 * @arg @ref LL_RCC_PLLM_DIV_29 * @arg @ref LL_RCC_PLLM_DIV_30 * @arg @ref LL_RCC_PLLM_DIV_31 * @arg @ref LL_RCC_PLLM_DIV_32 * @arg @ref LL_RCC_PLLM_DIV_33 * @arg @ref LL_RCC_PLLM_DIV_34 * @arg @ref LL_RCC_PLLM_DIV_35 * @arg @ref LL_RCC_PLLM_DIV_36 * @arg @ref LL_RCC_PLLM_DIV_37 * @arg @ref LL_RCC_PLLM_DIV_38 * @arg @ref LL_RCC_PLLM_DIV_39 * @arg @ref LL_RCC_PLLM_DIV_40 * @arg @ref LL_RCC_PLLM_DIV_41 * @arg @ref LL_RCC_PLLM_DIV_42 * @arg @ref LL_RCC_PLLM_DIV_43 * @arg @ref LL_RCC_PLLM_DIV_44 * @arg @ref LL_RCC_PLLM_DIV_45 * @arg @ref LL_RCC_PLLM_DIV_46 * @arg @ref LL_RCC_PLLM_DIV_47 * @arg @ref LL_RCC_PLLM_DIV_48 * @arg @ref LL_RCC_PLLM_DIV_49 * @arg @ref LL_RCC_PLLM_DIV_50 * @arg @ref LL_RCC_PLLM_DIV_51 * @arg @ref LL_RCC_PLLM_DIV_52 * @arg @ref LL_RCC_PLLM_DIV_53 * @arg @ref LL_RCC_PLLM_DIV_54 * @arg @ref LL_RCC_PLLM_DIV_55 * @arg @ref LL_RCC_PLLM_DIV_56 * @arg @ref LL_RCC_PLLM_DIV_57 * @arg @ref LL_RCC_PLLM_DIV_58 * @arg @ref LL_RCC_PLLM_DIV_59 * @arg @ref LL_RCC_PLLM_DIV_60 * @arg @ref LL_RCC_PLLM_DIV_61 * @arg @ref LL_RCC_PLLM_DIV_62 * @arg @ref LL_RCC_PLLM_DIV_63 * @param PLLN Between 50/192(*) and 432 * * (*) value not defined in all devices. * @param PLLP_R This parameter can be one of the following values: * @arg @ref LL_RCC_PLLP_DIV_2 * @arg @ref LL_RCC_PLLP_DIV_4 * @arg @ref LL_RCC_PLLP_DIV_6 * @arg @ref LL_RCC_PLLP_DIV_8 * @arg @ref LL_RCC_PLLR_DIV_2 (*) * @arg @ref LL_RCC_PLLR_DIV_3 (*) * @arg @ref LL_RCC_PLLR_DIV_4 (*) * @arg @ref LL_RCC_PLLR_DIV_5 (*) * @arg @ref LL_RCC_PLLR_DIV_6 (*) * @arg @ref LL_RCC_PLLR_DIV_7 (*) * * (*) value not defined in all devices. * @retval None */ __STATIC_INLINE void LL_RCC_PLL_ConfigDomain_SYS(uint32_t Source, uint32_t PLLM, uint32_t PLLN, uint32_t PLLP_R) { MODIFY_REG(RCC->PLLCFGR, RCC_PLLCFGR_PLLSRC | RCC_PLLCFGR_PLLM | RCC_PLLCFGR_PLLN, Source | PLLM | PLLN << RCC_PLLCFGR_PLLN_Pos); MODIFY_REG(RCC->PLLCFGR, RCC_PLLCFGR_PLLP, PLLP_R); #if defined(RCC_PLLR_SYSCLK_SUPPORT) MODIFY_REG(RCC->PLLCFGR, RCC_PLLCFGR_PLLR, PLLP_R); #endif /* RCC_PLLR_SYSCLK_SUPPORT */ } /** * @brief Configure PLL used for 48Mhz domain clock * @note PLL Source and PLLM Divider can be written only when PLL, * PLLI2S and PLLSAI(*) are disabled * @note PLLN/PLLQ can be written only when PLL is disabled * @note This can be selected for USB, RNG, SDIO * @rmtoll PLLCFGR PLLSRC LL_RCC_PLL_ConfigDomain_48M\n * PLLCFGR PLLM LL_RCC_PLL_ConfigDomain_48M\n * PLLCFGR PLLN LL_RCC_PLL_ConfigDomain_48M\n * PLLCFGR PLLQ LL_RCC_PLL_ConfigDomain_48M * @param Source This parameter can be one of the following values: * @arg @ref LL_RCC_PLLSOURCE_HSI * @arg @ref LL_RCC_PLLSOURCE_HSE * @param PLLM This parameter can be one of the following values: * @arg @ref LL_RCC_PLLM_DIV_2 * @arg @ref LL_RCC_PLLM_DIV_3 * @arg @ref LL_RCC_PLLM_DIV_4 * @arg @ref LL_RCC_PLLM_DIV_5 * @arg @ref LL_RCC_PLLM_DIV_6 * @arg @ref LL_RCC_PLLM_DIV_7 * @arg @ref LL_RCC_PLLM_DIV_8 * @arg @ref LL_RCC_PLLM_DIV_9 * @arg @ref LL_RCC_PLLM_DIV_10 * @arg @ref LL_RCC_PLLM_DIV_11 * @arg @ref LL_RCC_PLLM_DIV_12 * @arg @ref LL_RCC_PLLM_DIV_13 * @arg @ref LL_RCC_PLLM_DIV_14 * @arg @ref LL_RCC_PLLM_DIV_15 * @arg @ref LL_RCC_PLLM_DIV_16 * @arg @ref LL_RCC_PLLM_DIV_17 * @arg @ref LL_RCC_PLLM_DIV_18 * @arg @ref LL_RCC_PLLM_DIV_19 * @arg @ref LL_RCC_PLLM_DIV_20 * @arg @ref LL_RCC_PLLM_DIV_21 * @arg @ref LL_RCC_PLLM_DIV_22 * @arg @ref LL_RCC_PLLM_DIV_23 * @arg @ref LL_RCC_PLLM_DIV_24 * @arg @ref LL_RCC_PLLM_DIV_25 * @arg @ref LL_RCC_PLLM_DIV_26 * @arg @ref LL_RCC_PLLM_DIV_27 * @arg @ref LL_RCC_PLLM_DIV_28 * @arg @ref LL_RCC_PLLM_DIV_29 * @arg @ref LL_RCC_PLLM_DIV_30 * @arg @ref LL_RCC_PLLM_DIV_31 * @arg @ref LL_RCC_PLLM_DIV_32 * @arg @ref LL_RCC_PLLM_DIV_33 * @arg @ref LL_RCC_PLLM_DIV_34 * @arg @ref LL_RCC_PLLM_DIV_35 * @arg @ref LL_RCC_PLLM_DIV_36 * @arg @ref LL_RCC_PLLM_DIV_37 * @arg @ref LL_RCC_PLLM_DIV_38 * @arg @ref LL_RCC_PLLM_DIV_39 * @arg @ref LL_RCC_PLLM_DIV_40 * @arg @ref LL_RCC_PLLM_DIV_41 * @arg @ref LL_RCC_PLLM_DIV_42 * @arg @ref LL_RCC_PLLM_DIV_43 * @arg @ref LL_RCC_PLLM_DIV_44 * @arg @ref LL_RCC_PLLM_DIV_45 * @arg @ref LL_RCC_PLLM_DIV_46 * @arg @ref LL_RCC_PLLM_DIV_47 * @arg @ref LL_RCC_PLLM_DIV_48 * @arg @ref LL_RCC_PLLM_DIV_49 * @arg @ref LL_RCC_PLLM_DIV_50 * @arg @ref LL_RCC_PLLM_DIV_51 * @arg @ref LL_RCC_PLLM_DIV_52 * @arg @ref LL_RCC_PLLM_DIV_53 * @arg @ref LL_RCC_PLLM_DIV_54 * @arg @ref LL_RCC_PLLM_DIV_55 * @arg @ref LL_RCC_PLLM_DIV_56 * @arg @ref LL_RCC_PLLM_DIV_57 * @arg @ref LL_RCC_PLLM_DIV_58 * @arg @ref LL_RCC_PLLM_DIV_59 * @arg @ref LL_RCC_PLLM_DIV_60 * @arg @ref LL_RCC_PLLM_DIV_61 * @arg @ref LL_RCC_PLLM_DIV_62 * @arg @ref LL_RCC_PLLM_DIV_63 * @param PLLN Between 50/192(*) and 432 * * (*) value not defined in all devices. * @param PLLQ This parameter can be one of the following values: * @arg @ref LL_RCC_PLLQ_DIV_2 * @arg @ref LL_RCC_PLLQ_DIV_3 * @arg @ref LL_RCC_PLLQ_DIV_4 * @arg @ref LL_RCC_PLLQ_DIV_5 * @arg @ref LL_RCC_PLLQ_DIV_6 * @arg @ref LL_RCC_PLLQ_DIV_7 * @arg @ref LL_RCC_PLLQ_DIV_8 * @arg @ref LL_RCC_PLLQ_DIV_9 * @arg @ref LL_RCC_PLLQ_DIV_10 * @arg @ref LL_RCC_PLLQ_DIV_11 * @arg @ref LL_RCC_PLLQ_DIV_12 * @arg @ref LL_RCC_PLLQ_DIV_13 * @arg @ref LL_RCC_PLLQ_DIV_14 * @arg @ref LL_RCC_PLLQ_DIV_15 * @retval None */ __STATIC_INLINE void LL_RCC_PLL_ConfigDomain_48M(uint32_t Source, uint32_t PLLM, uint32_t PLLN, uint32_t PLLQ) { MODIFY_REG(RCC->PLLCFGR, RCC_PLLCFGR_PLLSRC | RCC_PLLCFGR_PLLM | RCC_PLLCFGR_PLLN | RCC_PLLCFGR_PLLQ, Source | PLLM | PLLN << RCC_PLLCFGR_PLLN_Pos | PLLQ); } #if defined(DSI) /** * @brief Configure PLL used for DSI clock * @note PLL Source and PLLM Divider can be written only when PLL, * PLLI2S and PLLSAI are disabled * @note PLLN/PLLR can be written only when PLL is disabled * @note This can be selected for DSI * @rmtoll PLLCFGR PLLSRC LL_RCC_PLL_ConfigDomain_DSI\n * PLLCFGR PLLM LL_RCC_PLL_ConfigDomain_DSI\n * PLLCFGR PLLN LL_RCC_PLL_ConfigDomain_DSI\n * PLLCFGR PLLR LL_RCC_PLL_ConfigDomain_DSI * @param Source This parameter can be one of the following values: * @arg @ref LL_RCC_PLLSOURCE_HSI * @arg @ref LL_RCC_PLLSOURCE_HSE * @param PLLM This parameter can be one of the following values: * @arg @ref LL_RCC_PLLM_DIV_2 * @arg @ref LL_RCC_PLLM_DIV_3 * @arg @ref LL_RCC_PLLM_DIV_4 * @arg @ref LL_RCC_PLLM_DIV_5 * @arg @ref LL_RCC_PLLM_DIV_6 * @arg @ref LL_RCC_PLLM_DIV_7 * @arg @ref LL_RCC_PLLM_DIV_8 * @arg @ref LL_RCC_PLLM_DIV_9 * @arg @ref LL_RCC_PLLM_DIV_10 * @arg @ref LL_RCC_PLLM_DIV_11 * @arg @ref LL_RCC_PLLM_DIV_12 * @arg @ref LL_RCC_PLLM_DIV_13 * @arg @ref LL_RCC_PLLM_DIV_14 * @arg @ref LL_RCC_PLLM_DIV_15 * @arg @ref LL_RCC_PLLM_DIV_16 * @arg @ref LL_RCC_PLLM_DIV_17 * @arg @ref LL_RCC_PLLM_DIV_18 * @arg @ref LL_RCC_PLLM_DIV_19 * @arg @ref LL_RCC_PLLM_DIV_20 * @arg @ref LL_RCC_PLLM_DIV_21 * @arg @ref LL_RCC_PLLM_DIV_22 * @arg @ref LL_RCC_PLLM_DIV_23 * @arg @ref LL_RCC_PLLM_DIV_24 * @arg @ref LL_RCC_PLLM_DIV_25 * @arg @ref LL_RCC_PLLM_DIV_26 * @arg @ref LL_RCC_PLLM_DIV_27 * @arg @ref LL_RCC_PLLM_DIV_28 * @arg @ref LL_RCC_PLLM_DIV_29 * @arg @ref LL_RCC_PLLM_DIV_30 * @arg @ref LL_RCC_PLLM_DIV_31 * @arg @ref LL_RCC_PLLM_DIV_32 * @arg @ref LL_RCC_PLLM_DIV_33 * @arg @ref LL_RCC_PLLM_DIV_34 * @arg @ref LL_RCC_PLLM_DIV_35 * @arg @ref LL_RCC_PLLM_DIV_36 * @arg @ref LL_RCC_PLLM_DIV_37 * @arg @ref LL_RCC_PLLM_DIV_38 * @arg @ref LL_RCC_PLLM_DIV_39 * @arg @ref LL_RCC_PLLM_DIV_40 * @arg @ref LL_RCC_PLLM_DIV_41 * @arg @ref LL_RCC_PLLM_DIV_42 * @arg @ref LL_RCC_PLLM_DIV_43 * @arg @ref LL_RCC_PLLM_DIV_44 * @arg @ref LL_RCC_PLLM_DIV_45 * @arg @ref LL_RCC_PLLM_DIV_46 * @arg @ref LL_RCC_PLLM_DIV_47 * @arg @ref LL_RCC_PLLM_DIV_48 * @arg @ref LL_RCC_PLLM_DIV_49 * @arg @ref LL_RCC_PLLM_DIV_50 * @arg @ref LL_RCC_PLLM_DIV_51 * @arg @ref LL_RCC_PLLM_DIV_52 * @arg @ref LL_RCC_PLLM_DIV_53 * @arg @ref LL_RCC_PLLM_DIV_54 * @arg @ref LL_RCC_PLLM_DIV_55 * @arg @ref LL_RCC_PLLM_DIV_56 * @arg @ref LL_RCC_PLLM_DIV_57 * @arg @ref LL_RCC_PLLM_DIV_58 * @arg @ref LL_RCC_PLLM_DIV_59 * @arg @ref LL_RCC_PLLM_DIV_60 * @arg @ref LL_RCC_PLLM_DIV_61 * @arg @ref LL_RCC_PLLM_DIV_62 * @arg @ref LL_RCC_PLLM_DIV_63 * @param PLLN Between 50 and 432 * @param PLLR This parameter can be one of the following values: * @arg @ref LL_RCC_PLLR_DIV_2 * @arg @ref LL_RCC_PLLR_DIV_3 * @arg @ref LL_RCC_PLLR_DIV_4 * @arg @ref LL_RCC_PLLR_DIV_5 * @arg @ref LL_RCC_PLLR_DIV_6 * @arg @ref LL_RCC_PLLR_DIV_7 * @retval None */ __STATIC_INLINE void LL_RCC_PLL_ConfigDomain_DSI(uint32_t Source, uint32_t PLLM, uint32_t PLLN, uint32_t PLLR) { MODIFY_REG(RCC->PLLCFGR, RCC_PLLCFGR_PLLSRC | RCC_PLLCFGR_PLLM | RCC_PLLCFGR_PLLN | RCC_PLLCFGR_PLLR, Source | PLLM | PLLN << RCC_PLLCFGR_PLLN_Pos | PLLR); } #endif /* DSI */ #if defined(RCC_PLLR_I2S_CLKSOURCE_SUPPORT) /** * @brief Configure PLL used for I2S clock * @note PLL Source and PLLM Divider can be written only when PLL, * PLLI2S and PLLSAI are disabled * @note PLLN/PLLR can be written only when PLL is disabled * @note This can be selected for I2S * @rmtoll PLLCFGR PLLSRC LL_RCC_PLL_ConfigDomain_I2S\n * PLLCFGR PLLM LL_RCC_PLL_ConfigDomain_I2S\n * PLLCFGR PLLN LL_RCC_PLL_ConfigDomain_I2S\n * PLLCFGR PLLR LL_RCC_PLL_ConfigDomain_I2S * @param Source This parameter can be one of the following values: * @arg @ref LL_RCC_PLLSOURCE_HSI * @arg @ref LL_RCC_PLLSOURCE_HSE * @param PLLM This parameter can be one of the following values: * @arg @ref LL_RCC_PLLM_DIV_2 * @arg @ref LL_RCC_PLLM_DIV_3 * @arg @ref LL_RCC_PLLM_DIV_4 * @arg @ref LL_RCC_PLLM_DIV_5 * @arg @ref LL_RCC_PLLM_DIV_6 * @arg @ref LL_RCC_PLLM_DIV_7 * @arg @ref LL_RCC_PLLM_DIV_8 * @arg @ref LL_RCC_PLLM_DIV_9 * @arg @ref LL_RCC_PLLM_DIV_10 * @arg @ref LL_RCC_PLLM_DIV_11 * @arg @ref LL_RCC_PLLM_DIV_12 * @arg @ref LL_RCC_PLLM_DIV_13 * @arg @ref LL_RCC_PLLM_DIV_14 * @arg @ref LL_RCC_PLLM_DIV_15 * @arg @ref LL_RCC_PLLM_DIV_16 * @arg @ref LL_RCC_PLLM_DIV_17 * @arg @ref LL_RCC_PLLM_DIV_18 * @arg @ref LL_RCC_PLLM_DIV_19 * @arg @ref LL_RCC_PLLM_DIV_20 * @arg @ref LL_RCC_PLLM_DIV_21 * @arg @ref LL_RCC_PLLM_DIV_22 * @arg @ref LL_RCC_PLLM_DIV_23 * @arg @ref LL_RCC_PLLM_DIV_24 * @arg @ref LL_RCC_PLLM_DIV_25 * @arg @ref LL_RCC_PLLM_DIV_26 * @arg @ref LL_RCC_PLLM_DIV_27 * @arg @ref LL_RCC_PLLM_DIV_28 * @arg @ref LL_RCC_PLLM_DIV_29 * @arg @ref LL_RCC_PLLM_DIV_30 * @arg @ref LL_RCC_PLLM_DIV_31 * @arg @ref LL_RCC_PLLM_DIV_32 * @arg @ref LL_RCC_PLLM_DIV_33 * @arg @ref LL_RCC_PLLM_DIV_34 * @arg @ref LL_RCC_PLLM_DIV_35 * @arg @ref LL_RCC_PLLM_DIV_36 * @arg @ref LL_RCC_PLLM_DIV_37 * @arg @ref LL_RCC_PLLM_DIV_38 * @arg @ref LL_RCC_PLLM_DIV_39 * @arg @ref LL_RCC_PLLM_DIV_40 * @arg @ref LL_RCC_PLLM_DIV_41 * @arg @ref LL_RCC_PLLM_DIV_42 * @arg @ref LL_RCC_PLLM_DIV_43 * @arg @ref LL_RCC_PLLM_DIV_44 * @arg @ref LL_RCC_PLLM_DIV_45 * @arg @ref LL_RCC_PLLM_DIV_46 * @arg @ref LL_RCC_PLLM_DIV_47 * @arg @ref LL_RCC_PLLM_DIV_48 * @arg @ref LL_RCC_PLLM_DIV_49 * @arg @ref LL_RCC_PLLM_DIV_50 * @arg @ref LL_RCC_PLLM_DIV_51 * @arg @ref LL_RCC_PLLM_DIV_52 * @arg @ref LL_RCC_PLLM_DIV_53 * @arg @ref LL_RCC_PLLM_DIV_54 * @arg @ref LL_RCC_PLLM_DIV_55 * @arg @ref LL_RCC_PLLM_DIV_56 * @arg @ref LL_RCC_PLLM_DIV_57 * @arg @ref LL_RCC_PLLM_DIV_58 * @arg @ref LL_RCC_PLLM_DIV_59 * @arg @ref LL_RCC_PLLM_DIV_60 * @arg @ref LL_RCC_PLLM_DIV_61 * @arg @ref LL_RCC_PLLM_DIV_62 * @arg @ref LL_RCC_PLLM_DIV_63 * @param PLLN Between 50 and 432 * @param PLLR This parameter can be one of the following values: * @arg @ref LL_RCC_PLLR_DIV_2 * @arg @ref LL_RCC_PLLR_DIV_3 * @arg @ref LL_RCC_PLLR_DIV_4 * @arg @ref LL_RCC_PLLR_DIV_5 * @arg @ref LL_RCC_PLLR_DIV_6 * @arg @ref LL_RCC_PLLR_DIV_7 * @retval None */ __STATIC_INLINE void LL_RCC_PLL_ConfigDomain_I2S(uint32_t Source, uint32_t PLLM, uint32_t PLLN, uint32_t PLLR) { MODIFY_REG(RCC->PLLCFGR, RCC_PLLCFGR_PLLSRC | RCC_PLLCFGR_PLLM | RCC_PLLCFGR_PLLN | RCC_PLLCFGR_PLLR, Source | PLLM | PLLN << RCC_PLLCFGR_PLLN_Pos | PLLR); } #endif /* RCC_PLLR_I2S_CLKSOURCE_SUPPORT */ #if defined(SPDIFRX) /** * @brief Configure PLL used for SPDIFRX clock * @note PLL Source and PLLM Divider can be written only when PLL, * PLLI2S and PLLSAI are disabled * @note PLLN/PLLR can be written only when PLL is disabled * @note This can be selected for SPDIFRX * @rmtoll PLLCFGR PLLSRC LL_RCC_PLL_ConfigDomain_SPDIFRX\n * PLLCFGR PLLM LL_RCC_PLL_ConfigDomain_SPDIFRX\n * PLLCFGR PLLN LL_RCC_PLL_ConfigDomain_SPDIFRX\n * PLLCFGR PLLR LL_RCC_PLL_ConfigDomain_SPDIFRX * @param Source This parameter can be one of the following values: * @arg @ref LL_RCC_PLLSOURCE_HSI * @arg @ref LL_RCC_PLLSOURCE_HSE * @param PLLM This parameter can be one of the following values: * @arg @ref LL_RCC_PLLM_DIV_2 * @arg @ref LL_RCC_PLLM_DIV_3 * @arg @ref LL_RCC_PLLM_DIV_4 * @arg @ref LL_RCC_PLLM_DIV_5 * @arg @ref LL_RCC_PLLM_DIV_6 * @arg @ref LL_RCC_PLLM_DIV_7 * @arg @ref LL_RCC_PLLM_DIV_8 * @arg @ref LL_RCC_PLLM_DIV_9 * @arg @ref LL_RCC_PLLM_DIV_10 * @arg @ref LL_RCC_PLLM_DIV_11 * @arg @ref LL_RCC_PLLM_DIV_12 * @arg @ref LL_RCC_PLLM_DIV_13 * @arg @ref LL_RCC_PLLM_DIV_14 * @arg @ref LL_RCC_PLLM_DIV_15 * @arg @ref LL_RCC_PLLM_DIV_16 * @arg @ref LL_RCC_PLLM_DIV_17 * @arg @ref LL_RCC_PLLM_DIV_18 * @arg @ref LL_RCC_PLLM_DIV_19 * @arg @ref LL_RCC_PLLM_DIV_20 * @arg @ref LL_RCC_PLLM_DIV_21 * @arg @ref LL_RCC_PLLM_DIV_22 * @arg @ref LL_RCC_PLLM_DIV_23 * @arg @ref LL_RCC_PLLM_DIV_24 * @arg @ref LL_RCC_PLLM_DIV_25 * @arg @ref LL_RCC_PLLM_DIV_26 * @arg @ref LL_RCC_PLLM_DIV_27 * @arg @ref LL_RCC_PLLM_DIV_28 * @arg @ref LL_RCC_PLLM_DIV_29 * @arg @ref LL_RCC_PLLM_DIV_30 * @arg @ref LL_RCC_PLLM_DIV_31 * @arg @ref LL_RCC_PLLM_DIV_32 * @arg @ref LL_RCC_PLLM_DIV_33 * @arg @ref LL_RCC_PLLM_DIV_34 * @arg @ref LL_RCC_PLLM_DIV_35 * @arg @ref LL_RCC_PLLM_DIV_36 * @arg @ref LL_RCC_PLLM_DIV_37 * @arg @ref LL_RCC_PLLM_DIV_38 * @arg @ref LL_RCC_PLLM_DIV_39 * @arg @ref LL_RCC_PLLM_DIV_40 * @arg @ref LL_RCC_PLLM_DIV_41 * @arg @ref LL_RCC_PLLM_DIV_42 * @arg @ref LL_RCC_PLLM_DIV_43 * @arg @ref LL_RCC_PLLM_DIV_44 * @arg @ref LL_RCC_PLLM_DIV_45 * @arg @ref LL_RCC_PLLM_DIV_46 * @arg @ref LL_RCC_PLLM_DIV_47 * @arg @ref LL_RCC_PLLM_DIV_48 * @arg @ref LL_RCC_PLLM_DIV_49 * @arg @ref LL_RCC_PLLM_DIV_50 * @arg @ref LL_RCC_PLLM_DIV_51 * @arg @ref LL_RCC_PLLM_DIV_52 * @arg @ref LL_RCC_PLLM_DIV_53 * @arg @ref LL_RCC_PLLM_DIV_54 * @arg @ref LL_RCC_PLLM_DIV_55 * @arg @ref LL_RCC_PLLM_DIV_56 * @arg @ref LL_RCC_PLLM_DIV_57 * @arg @ref LL_RCC_PLLM_DIV_58 * @arg @ref LL_RCC_PLLM_DIV_59 * @arg @ref LL_RCC_PLLM_DIV_60 * @arg @ref LL_RCC_PLLM_DIV_61 * @arg @ref LL_RCC_PLLM_DIV_62 * @arg @ref LL_RCC_PLLM_DIV_63 * @param PLLN Between 50 and 432 * @param PLLR This parameter can be one of the following values: * @arg @ref LL_RCC_PLLR_DIV_2 * @arg @ref LL_RCC_PLLR_DIV_3 * @arg @ref LL_RCC_PLLR_DIV_4 * @arg @ref LL_RCC_PLLR_DIV_5 * @arg @ref LL_RCC_PLLR_DIV_6 * @arg @ref LL_RCC_PLLR_DIV_7 * @retval None */ __STATIC_INLINE void LL_RCC_PLL_ConfigDomain_SPDIFRX(uint32_t Source, uint32_t PLLM, uint32_t PLLN, uint32_t PLLR) { MODIFY_REG(RCC->PLLCFGR, RCC_PLLCFGR_PLLSRC | RCC_PLLCFGR_PLLM | RCC_PLLCFGR_PLLN | RCC_PLLCFGR_PLLR, Source | PLLM | PLLN << RCC_PLLCFGR_PLLN_Pos | PLLR); } #endif /* SPDIFRX */ #if defined(RCC_PLLCFGR_PLLR) #if defined(SAI1) /** * @brief Configure PLL used for SAI clock * @note PLL Source and PLLM Divider can be written only when PLL, * PLLI2S and PLLSAI are disabled * @note PLLN/PLLR can be written only when PLL is disabled * @note This can be selected for SAI * @rmtoll PLLCFGR PLLSRC LL_RCC_PLL_ConfigDomain_SAI\n * PLLCFGR PLLM LL_RCC_PLL_ConfigDomain_SAI\n * PLLCFGR PLLN LL_RCC_PLL_ConfigDomain_SAI\n * PLLCFGR PLLR LL_RCC_PLL_ConfigDomain_SAI\n * DCKCFGR PLLDIVR LL_RCC_PLL_ConfigDomain_SAI * @param Source This parameter can be one of the following values: * @arg @ref LL_RCC_PLLSOURCE_HSI * @arg @ref LL_RCC_PLLSOURCE_HSE * @param PLLM This parameter can be one of the following values: * @arg @ref LL_RCC_PLLM_DIV_2 * @arg @ref LL_RCC_PLLM_DIV_3 * @arg @ref LL_RCC_PLLM_DIV_4 * @arg @ref LL_RCC_PLLM_DIV_5 * @arg @ref LL_RCC_PLLM_DIV_6 * @arg @ref LL_RCC_PLLM_DIV_7 * @arg @ref LL_RCC_PLLM_DIV_8 * @arg @ref LL_RCC_PLLM_DIV_9 * @arg @ref LL_RCC_PLLM_DIV_10 * @arg @ref LL_RCC_PLLM_DIV_11 * @arg @ref LL_RCC_PLLM_DIV_12 * @arg @ref LL_RCC_PLLM_DIV_13 * @arg @ref LL_RCC_PLLM_DIV_14 * @arg @ref LL_RCC_PLLM_DIV_15 * @arg @ref LL_RCC_PLLM_DIV_16 * @arg @ref LL_RCC_PLLM_DIV_17 * @arg @ref LL_RCC_PLLM_DIV_18 * @arg @ref LL_RCC_PLLM_DIV_19 * @arg @ref LL_RCC_PLLM_DIV_20 * @arg @ref LL_RCC_PLLM_DIV_21 * @arg @ref LL_RCC_PLLM_DIV_22 * @arg @ref LL_RCC_PLLM_DIV_23 * @arg @ref LL_RCC_PLLM_DIV_24 * @arg @ref LL_RCC_PLLM_DIV_25 * @arg @ref LL_RCC_PLLM_DIV_26 * @arg @ref LL_RCC_PLLM_DIV_27 * @arg @ref LL_RCC_PLLM_DIV_28 * @arg @ref LL_RCC_PLLM_DIV_29 * @arg @ref LL_RCC_PLLM_DIV_30 * @arg @ref LL_RCC_PLLM_DIV_31 * @arg @ref LL_RCC_PLLM_DIV_32 * @arg @ref LL_RCC_PLLM_DIV_33 * @arg @ref LL_RCC_PLLM_DIV_34 * @arg @ref LL_RCC_PLLM_DIV_35 * @arg @ref LL_RCC_PLLM_DIV_36 * @arg @ref LL_RCC_PLLM_DIV_37 * @arg @ref LL_RCC_PLLM_DIV_38 * @arg @ref LL_RCC_PLLM_DIV_39 * @arg @ref LL_RCC_PLLM_DIV_40 * @arg @ref LL_RCC_PLLM_DIV_41 * @arg @ref LL_RCC_PLLM_DIV_42 * @arg @ref LL_RCC_PLLM_DIV_43 * @arg @ref LL_RCC_PLLM_DIV_44 * @arg @ref LL_RCC_PLLM_DIV_45 * @arg @ref LL_RCC_PLLM_DIV_46 * @arg @ref LL_RCC_PLLM_DIV_47 * @arg @ref LL_RCC_PLLM_DIV_48 * @arg @ref LL_RCC_PLLM_DIV_49 * @arg @ref LL_RCC_PLLM_DIV_50 * @arg @ref LL_RCC_PLLM_DIV_51 * @arg @ref LL_RCC_PLLM_DIV_52 * @arg @ref LL_RCC_PLLM_DIV_53 * @arg @ref LL_RCC_PLLM_DIV_54 * @arg @ref LL_RCC_PLLM_DIV_55 * @arg @ref LL_RCC_PLLM_DIV_56 * @arg @ref LL_RCC_PLLM_DIV_57 * @arg @ref LL_RCC_PLLM_DIV_58 * @arg @ref LL_RCC_PLLM_DIV_59 * @arg @ref LL_RCC_PLLM_DIV_60 * @arg @ref LL_RCC_PLLM_DIV_61 * @arg @ref LL_RCC_PLLM_DIV_62 * @arg @ref LL_RCC_PLLM_DIV_63 * @param PLLN Between 50 and 432 * @param PLLR This parameter can be one of the following values: * @arg @ref LL_RCC_PLLR_DIV_2 * @arg @ref LL_RCC_PLLR_DIV_3 * @arg @ref LL_RCC_PLLR_DIV_4 * @arg @ref LL_RCC_PLLR_DIV_5 * @arg @ref LL_RCC_PLLR_DIV_6 * @arg @ref LL_RCC_PLLR_DIV_7 * @param PLLDIVR This parameter can be one of the following values: * @arg @ref LL_RCC_PLLDIVR_DIV_1 (*) * @arg @ref LL_RCC_PLLDIVR_DIV_2 (*) * @arg @ref LL_RCC_PLLDIVR_DIV_3 (*) * @arg @ref LL_RCC_PLLDIVR_DIV_4 (*) * @arg @ref LL_RCC_PLLDIVR_DIV_5 (*) * @arg @ref LL_RCC_PLLDIVR_DIV_6 (*) * @arg @ref LL_RCC_PLLDIVR_DIV_7 (*) * @arg @ref LL_RCC_PLLDIVR_DIV_8 (*) * @arg @ref LL_RCC_PLLDIVR_DIV_9 (*) * @arg @ref LL_RCC_PLLDIVR_DIV_10 (*) * @arg @ref LL_RCC_PLLDIVR_DIV_11 (*) * @arg @ref LL_RCC_PLLDIVR_DIV_12 (*) * @arg @ref LL_RCC_PLLDIVR_DIV_13 (*) * @arg @ref LL_RCC_PLLDIVR_DIV_14 (*) * @arg @ref LL_RCC_PLLDIVR_DIV_15 (*) * @arg @ref LL_RCC_PLLDIVR_DIV_16 (*) * @arg @ref LL_RCC_PLLDIVR_DIV_17 (*) * @arg @ref LL_RCC_PLLDIVR_DIV_18 (*) * @arg @ref LL_RCC_PLLDIVR_DIV_19 (*) * @arg @ref LL_RCC_PLLDIVR_DIV_20 (*) * @arg @ref LL_RCC_PLLDIVR_DIV_21 (*) * @arg @ref LL_RCC_PLLDIVR_DIV_22 (*) * @arg @ref LL_RCC_PLLDIVR_DIV_23 (*) * @arg @ref LL_RCC_PLLDIVR_DIV_24 (*) * @arg @ref LL_RCC_PLLDIVR_DIV_25 (*) * @arg @ref LL_RCC_PLLDIVR_DIV_26 (*) * @arg @ref LL_RCC_PLLDIVR_DIV_27 (*) * @arg @ref LL_RCC_PLLDIVR_DIV_28 (*) * @arg @ref LL_RCC_PLLDIVR_DIV_29 (*) * @arg @ref LL_RCC_PLLDIVR_DIV_30 (*) * @arg @ref LL_RCC_PLLDIVR_DIV_31 (*) * * (*) value not defined in all devices. * @retval None */ #if defined(RCC_DCKCFGR_PLLDIVR) __STATIC_INLINE void LL_RCC_PLL_ConfigDomain_SAI(uint32_t Source, uint32_t PLLM, uint32_t PLLN, uint32_t PLLR, uint32_t PLLDIVR) #else __STATIC_INLINE void LL_RCC_PLL_ConfigDomain_SAI(uint32_t Source, uint32_t PLLM, uint32_t PLLN, uint32_t PLLR) #endif /* RCC_DCKCFGR_PLLDIVR */ { MODIFY_REG(RCC->PLLCFGR, RCC_PLLCFGR_PLLSRC | RCC_PLLCFGR_PLLM | RCC_PLLCFGR_PLLN | RCC_PLLCFGR_PLLR, Source | PLLM | PLLN << RCC_PLLCFGR_PLLN_Pos | PLLR); #if defined(RCC_DCKCFGR_PLLDIVR) MODIFY_REG(RCC->DCKCFGR, RCC_DCKCFGR_PLLDIVR, PLLDIVR); #endif /* RCC_DCKCFGR_PLLDIVR */ } #endif /* SAI1 */ #endif /* RCC_PLLCFGR_PLLR */ /** * @brief Configure PLL clock source * @rmtoll PLLCFGR PLLSRC LL_RCC_PLL_SetMainSource * @param PLLSource This parameter can be one of the following values: * @arg @ref LL_RCC_PLLSOURCE_HSI * @arg @ref LL_RCC_PLLSOURCE_HSE * @retval None */ __STATIC_INLINE void LL_RCC_PLL_SetMainSource(uint32_t PLLSource) { MODIFY_REG(RCC->PLLCFGR, RCC_PLLCFGR_PLLSRC, PLLSource); } /** * @brief Get the oscillator used as PLL clock source. * @rmtoll PLLCFGR PLLSRC LL_RCC_PLL_GetMainSource * @retval Returned value can be one of the following values: * @arg @ref LL_RCC_PLLSOURCE_HSI * @arg @ref LL_RCC_PLLSOURCE_HSE */ __STATIC_INLINE uint32_t LL_RCC_PLL_GetMainSource(void) { return (uint32_t)(READ_BIT(RCC->PLLCFGR, RCC_PLLCFGR_PLLSRC)); } /** * @brief Get Main PLL multiplication factor for VCO * @rmtoll PLLCFGR PLLN LL_RCC_PLL_GetN * @retval Between 50/192(*) and 432 * * (*) value not defined in all devices. */ __STATIC_INLINE uint32_t LL_RCC_PLL_GetN(void) { return (uint32_t)(READ_BIT(RCC->PLLCFGR, RCC_PLLCFGR_PLLN) >> RCC_PLLCFGR_PLLN_Pos); } /** * @brief Get Main PLL division factor for PLLP * @rmtoll PLLCFGR PLLP LL_RCC_PLL_GetP * @retval Returned value can be one of the following values: * @arg @ref LL_RCC_PLLP_DIV_2 * @arg @ref LL_RCC_PLLP_DIV_4 * @arg @ref LL_RCC_PLLP_DIV_6 * @arg @ref LL_RCC_PLLP_DIV_8 */ __STATIC_INLINE uint32_t LL_RCC_PLL_GetP(void) { return (uint32_t)(READ_BIT(RCC->PLLCFGR, RCC_PLLCFGR_PLLP)); } /** * @brief Get Main PLL division factor for PLLQ * @note used for PLL48MCLK selected for USB, RNG, SDIO (48 MHz clock) * @rmtoll PLLCFGR PLLQ LL_RCC_PLL_GetQ * @retval Returned value can be one of the following values: * @arg @ref LL_RCC_PLLQ_DIV_2 * @arg @ref LL_RCC_PLLQ_DIV_3 * @arg @ref LL_RCC_PLLQ_DIV_4 * @arg @ref LL_RCC_PLLQ_DIV_5 * @arg @ref LL_RCC_PLLQ_DIV_6 * @arg @ref LL_RCC_PLLQ_DIV_7 * @arg @ref LL_RCC_PLLQ_DIV_8 * @arg @ref LL_RCC_PLLQ_DIV_9 * @arg @ref LL_RCC_PLLQ_DIV_10 * @arg @ref LL_RCC_PLLQ_DIV_11 * @arg @ref LL_RCC_PLLQ_DIV_12 * @arg @ref LL_RCC_PLLQ_DIV_13 * @arg @ref LL_RCC_PLLQ_DIV_14 * @arg @ref LL_RCC_PLLQ_DIV_15 */ __STATIC_INLINE uint32_t LL_RCC_PLL_GetQ(void) { return (uint32_t)(READ_BIT(RCC->PLLCFGR, RCC_PLLCFGR_PLLQ)); } #if defined(RCC_PLLCFGR_PLLR) /** * @brief Get Main PLL division factor for PLLR * @note used for PLLCLK (system clock) * @rmtoll PLLCFGR PLLR LL_RCC_PLL_GetR * @retval Returned value can be one of the following values: * @arg @ref LL_RCC_PLLR_DIV_2 * @arg @ref LL_RCC_PLLR_DIV_3 * @arg @ref LL_RCC_PLLR_DIV_4 * @arg @ref LL_RCC_PLLR_DIV_5 * @arg @ref LL_RCC_PLLR_DIV_6 * @arg @ref LL_RCC_PLLR_DIV_7 */ __STATIC_INLINE uint32_t LL_RCC_PLL_GetR(void) { return (uint32_t)(READ_BIT(RCC->PLLCFGR, RCC_PLLCFGR_PLLR)); } #endif /* RCC_PLLCFGR_PLLR */ #if defined(RCC_DCKCFGR_PLLDIVR) /** * @brief Get Main PLL division factor for PLLDIVR * @note used for PLLSAICLK (SAI1 and SAI2 clock) * @rmtoll DCKCFGR PLLDIVR LL_RCC_PLL_GetDIVR * @retval Returned value can be one of the following values: * @arg @ref LL_RCC_PLLDIVR_DIV_1 * @arg @ref LL_RCC_PLLDIVR_DIV_2 * @arg @ref LL_RCC_PLLDIVR_DIV_3 * @arg @ref LL_RCC_PLLDIVR_DIV_4 * @arg @ref LL_RCC_PLLDIVR_DIV_5 * @arg @ref LL_RCC_PLLDIVR_DIV_6 * @arg @ref LL_RCC_PLLDIVR_DIV_7 * @arg @ref LL_RCC_PLLDIVR_DIV_8 * @arg @ref LL_RCC_PLLDIVR_DIV_9 * @arg @ref LL_RCC_PLLDIVR_DIV_10 * @arg @ref LL_RCC_PLLDIVR_DIV_11 * @arg @ref LL_RCC_PLLDIVR_DIV_12 * @arg @ref LL_RCC_PLLDIVR_DIV_13 * @arg @ref LL_RCC_PLLDIVR_DIV_14 * @arg @ref LL_RCC_PLLDIVR_DIV_15 * @arg @ref LL_RCC_PLLDIVR_DIV_16 * @arg @ref LL_RCC_PLLDIVR_DIV_17 * @arg @ref LL_RCC_PLLDIVR_DIV_18 * @arg @ref LL_RCC_PLLDIVR_DIV_19 * @arg @ref LL_RCC_PLLDIVR_DIV_20 * @arg @ref LL_RCC_PLLDIVR_DIV_21 * @arg @ref LL_RCC_PLLDIVR_DIV_22 * @arg @ref LL_RCC_PLLDIVR_DIV_23 * @arg @ref LL_RCC_PLLDIVR_DIV_24 * @arg @ref LL_RCC_PLLDIVR_DIV_25 * @arg @ref LL_RCC_PLLDIVR_DIV_26 * @arg @ref LL_RCC_PLLDIVR_DIV_27 * @arg @ref LL_RCC_PLLDIVR_DIV_28 * @arg @ref LL_RCC_PLLDIVR_DIV_29 * @arg @ref LL_RCC_PLLDIVR_DIV_30 * @arg @ref LL_RCC_PLLDIVR_DIV_31 */ __STATIC_INLINE uint32_t LL_RCC_PLL_GetDIVR(void) { return (uint32_t)(READ_BIT(RCC->DCKCFGR, RCC_DCKCFGR_PLLDIVR)); } #endif /* RCC_DCKCFGR_PLLDIVR */ /** * @brief Get Division factor for the main PLL and other PLL * @rmtoll PLLCFGR PLLM LL_RCC_PLL_GetDivider * @retval Returned value can be one of the following values: * @arg @ref LL_RCC_PLLM_DIV_2 * @arg @ref LL_RCC_PLLM_DIV_3 * @arg @ref LL_RCC_PLLM_DIV_4 * @arg @ref LL_RCC_PLLM_DIV_5 * @arg @ref LL_RCC_PLLM_DIV_6 * @arg @ref LL_RCC_PLLM_DIV_7 * @arg @ref LL_RCC_PLLM_DIV_8 * @arg @ref LL_RCC_PLLM_DIV_9 * @arg @ref LL_RCC_PLLM_DIV_10 * @arg @ref LL_RCC_PLLM_DIV_11 * @arg @ref LL_RCC_PLLM_DIV_12 * @arg @ref LL_RCC_PLLM_DIV_13 * @arg @ref LL_RCC_PLLM_DIV_14 * @arg @ref LL_RCC_PLLM_DIV_15 * @arg @ref LL_RCC_PLLM_DIV_16 * @arg @ref LL_RCC_PLLM_DIV_17 * @arg @ref LL_RCC_PLLM_DIV_18 * @arg @ref LL_RCC_PLLM_DIV_19 * @arg @ref LL_RCC_PLLM_DIV_20 * @arg @ref LL_RCC_PLLM_DIV_21 * @arg @ref LL_RCC_PLLM_DIV_22 * @arg @ref LL_RCC_PLLM_DIV_23 * @arg @ref LL_RCC_PLLM_DIV_24 * @arg @ref LL_RCC_PLLM_DIV_25 * @arg @ref LL_RCC_PLLM_DIV_26 * @arg @ref LL_RCC_PLLM_DIV_27 * @arg @ref LL_RCC_PLLM_DIV_28 * @arg @ref LL_RCC_PLLM_DIV_29 * @arg @ref LL_RCC_PLLM_DIV_30 * @arg @ref LL_RCC_PLLM_DIV_31 * @arg @ref LL_RCC_PLLM_DIV_32 * @arg @ref LL_RCC_PLLM_DIV_33 * @arg @ref LL_RCC_PLLM_DIV_34 * @arg @ref LL_RCC_PLLM_DIV_35 * @arg @ref LL_RCC_PLLM_DIV_36 * @arg @ref LL_RCC_PLLM_DIV_37 * @arg @ref LL_RCC_PLLM_DIV_38 * @arg @ref LL_RCC_PLLM_DIV_39 * @arg @ref LL_RCC_PLLM_DIV_40 * @arg @ref LL_RCC_PLLM_DIV_41 * @arg @ref LL_RCC_PLLM_DIV_42 * @arg @ref LL_RCC_PLLM_DIV_43 * @arg @ref LL_RCC_PLLM_DIV_44 * @arg @ref LL_RCC_PLLM_DIV_45 * @arg @ref LL_RCC_PLLM_DIV_46 * @arg @ref LL_RCC_PLLM_DIV_47 * @arg @ref LL_RCC_PLLM_DIV_48 * @arg @ref LL_RCC_PLLM_DIV_49 * @arg @ref LL_RCC_PLLM_DIV_50 * @arg @ref LL_RCC_PLLM_DIV_51 * @arg @ref LL_RCC_PLLM_DIV_52 * @arg @ref LL_RCC_PLLM_DIV_53 * @arg @ref LL_RCC_PLLM_DIV_54 * @arg @ref LL_RCC_PLLM_DIV_55 * @arg @ref LL_RCC_PLLM_DIV_56 * @arg @ref LL_RCC_PLLM_DIV_57 * @arg @ref LL_RCC_PLLM_DIV_58 * @arg @ref LL_RCC_PLLM_DIV_59 * @arg @ref LL_RCC_PLLM_DIV_60 * @arg @ref LL_RCC_PLLM_DIV_61 * @arg @ref LL_RCC_PLLM_DIV_62 * @arg @ref LL_RCC_PLLM_DIV_63 */ __STATIC_INLINE uint32_t LL_RCC_PLL_GetDivider(void) { return (uint32_t)(READ_BIT(RCC->PLLCFGR, RCC_PLLCFGR_PLLM)); } /** * @brief Configure Spread Spectrum used for PLL * @note These bits must be written before enabling PLL * @rmtoll SSCGR MODPER LL_RCC_PLL_ConfigSpreadSpectrum\n * SSCGR INCSTEP LL_RCC_PLL_ConfigSpreadSpectrum\n * SSCGR SPREADSEL LL_RCC_PLL_ConfigSpreadSpectrum * @param Mod Between Min_Data=0 and Max_Data=8191 * @param Inc Between Min_Data=0 and Max_Data=32767 * @param Sel This parameter can be one of the following values: * @arg @ref LL_RCC_SPREAD_SELECT_CENTER * @arg @ref LL_RCC_SPREAD_SELECT_DOWN * @retval None */ __STATIC_INLINE void LL_RCC_PLL_ConfigSpreadSpectrum(uint32_t Mod, uint32_t Inc, uint32_t Sel) { MODIFY_REG(RCC->SSCGR, RCC_SSCGR_MODPER | RCC_SSCGR_INCSTEP | RCC_SSCGR_SPREADSEL, Mod | (Inc << RCC_SSCGR_INCSTEP_Pos) | Sel); } /** * @brief Get Spread Spectrum Modulation Period for PLL * @rmtoll SSCGR MODPER LL_RCC_PLL_GetPeriodModulation * @retval Between Min_Data=0 and Max_Data=8191 */ __STATIC_INLINE uint32_t LL_RCC_PLL_GetPeriodModulation(void) { return (uint32_t)(READ_BIT(RCC->SSCGR, RCC_SSCGR_MODPER)); } /** * @brief Get Spread Spectrum Incrementation Step for PLL * @note Must be written before enabling PLL * @rmtoll SSCGR INCSTEP LL_RCC_PLL_GetStepIncrementation * @retval Between Min_Data=0 and Max_Data=32767 */ __STATIC_INLINE uint32_t LL_RCC_PLL_GetStepIncrementation(void) { return (uint32_t)(READ_BIT(RCC->SSCGR, RCC_SSCGR_INCSTEP) >> RCC_SSCGR_INCSTEP_Pos); } /** * @brief Get Spread Spectrum Selection for PLL * @note Must be written before enabling PLL * @rmtoll SSCGR SPREADSEL LL_RCC_PLL_GetSpreadSelection * @retval Returned value can be one of the following values: * @arg @ref LL_RCC_SPREAD_SELECT_CENTER * @arg @ref LL_RCC_SPREAD_SELECT_DOWN */ __STATIC_INLINE uint32_t LL_RCC_PLL_GetSpreadSelection(void) { return (uint32_t)(READ_BIT(RCC->SSCGR, RCC_SSCGR_SPREADSEL)); } /** * @brief Enable Spread Spectrum for PLL. * @rmtoll SSCGR SSCGEN LL_RCC_PLL_SpreadSpectrum_Enable * @retval None */ __STATIC_INLINE void LL_RCC_PLL_SpreadSpectrum_Enable(void) { SET_BIT(RCC->SSCGR, RCC_SSCGR_SSCGEN); } /** * @brief Disable Spread Spectrum for PLL. * @rmtoll SSCGR SSCGEN LL_RCC_PLL_SpreadSpectrum_Disable * @retval None */ __STATIC_INLINE void LL_RCC_PLL_SpreadSpectrum_Disable(void) { CLEAR_BIT(RCC->SSCGR, RCC_SSCGR_SSCGEN); } /** * @} */ #if defined(RCC_PLLI2S_SUPPORT) /** @defgroup RCC_LL_EF_PLLI2S PLLI2S * @{ */ /** * @brief Enable PLLI2S * @rmtoll CR PLLI2SON LL_RCC_PLLI2S_Enable * @retval None */ __STATIC_INLINE void LL_RCC_PLLI2S_Enable(void) { SET_BIT(RCC->CR, RCC_CR_PLLI2SON); } /** * @brief Disable PLLI2S * @rmtoll CR PLLI2SON LL_RCC_PLLI2S_Disable * @retval None */ __STATIC_INLINE void LL_RCC_PLLI2S_Disable(void) { CLEAR_BIT(RCC->CR, RCC_CR_PLLI2SON); } /** * @brief Check if PLLI2S Ready * @rmtoll CR PLLI2SRDY LL_RCC_PLLI2S_IsReady * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_RCC_PLLI2S_IsReady(void) { return (READ_BIT(RCC->CR, RCC_CR_PLLI2SRDY) == (RCC_CR_PLLI2SRDY)); } #if (defined(RCC_DCKCFGR_PLLI2SDIVQ) || defined(RCC_DCKCFGR_PLLI2SDIVR)) /** * @brief Configure PLLI2S used for SAI domain clock * @note PLL Source and PLLM Divider can be written only when PLL, * PLLI2S and PLLSAI(*) are disabled * @note PLLN/PLLQ/PLLR can be written only when PLLI2S is disabled * @note This can be selected for SAI * @rmtoll PLLCFGR PLLSRC LL_RCC_PLLI2S_ConfigDomain_SAI\n * PLLI2SCFGR PLLI2SSRC LL_RCC_PLLI2S_ConfigDomain_SAI\n * PLLCFGR PLLM LL_RCC_PLLI2S_ConfigDomain_SAI\n * PLLI2SCFGR PLLI2SM LL_RCC_PLLI2S_ConfigDomain_SAI\n * PLLI2SCFGR PLLI2SN LL_RCC_PLLI2S_ConfigDomain_SAI\n * PLLI2SCFGR PLLI2SQ LL_RCC_PLLI2S_ConfigDomain_SAI\n * PLLI2SCFGR PLLI2SR LL_RCC_PLLI2S_ConfigDomain_SAI\n * DCKCFGR PLLI2SDIVQ LL_RCC_PLLI2S_ConfigDomain_SAI\n * DCKCFGR PLLI2SDIVR LL_RCC_PLLI2S_ConfigDomain_SAI * @param Source This parameter can be one of the following values: * @arg @ref LL_RCC_PLLSOURCE_HSI * @arg @ref LL_RCC_PLLSOURCE_HSE * @arg @ref LL_RCC_PLLI2SSOURCE_PIN (*) * * (*) value not defined in all devices. * @param PLLM This parameter can be one of the following values: * @arg @ref LL_RCC_PLLI2SM_DIV_2 * @arg @ref LL_RCC_PLLI2SM_DIV_3 * @arg @ref LL_RCC_PLLI2SM_DIV_4 * @arg @ref LL_RCC_PLLI2SM_DIV_5 * @arg @ref LL_RCC_PLLI2SM_DIV_6 * @arg @ref LL_RCC_PLLI2SM_DIV_7 * @arg @ref LL_RCC_PLLI2SM_DIV_8 * @arg @ref LL_RCC_PLLI2SM_DIV_9 * @arg @ref LL_RCC_PLLI2SM_DIV_10 * @arg @ref LL_RCC_PLLI2SM_DIV_11 * @arg @ref LL_RCC_PLLI2SM_DIV_12 * @arg @ref LL_RCC_PLLI2SM_DIV_13 * @arg @ref LL_RCC_PLLI2SM_DIV_14 * @arg @ref LL_RCC_PLLI2SM_DIV_15 * @arg @ref LL_RCC_PLLI2SM_DIV_16 * @arg @ref LL_RCC_PLLI2SM_DIV_17 * @arg @ref LL_RCC_PLLI2SM_DIV_18 * @arg @ref LL_RCC_PLLI2SM_DIV_19 * @arg @ref LL_RCC_PLLI2SM_DIV_20 * @arg @ref LL_RCC_PLLI2SM_DIV_21 * @arg @ref LL_RCC_PLLI2SM_DIV_22 * @arg @ref LL_RCC_PLLI2SM_DIV_23 * @arg @ref LL_RCC_PLLI2SM_DIV_24 * @arg @ref LL_RCC_PLLI2SM_DIV_25 * @arg @ref LL_RCC_PLLI2SM_DIV_26 * @arg @ref LL_RCC_PLLI2SM_DIV_27 * @arg @ref LL_RCC_PLLI2SM_DIV_28 * @arg @ref LL_RCC_PLLI2SM_DIV_29 * @arg @ref LL_RCC_PLLI2SM_DIV_30 * @arg @ref LL_RCC_PLLI2SM_DIV_31 * @arg @ref LL_RCC_PLLI2SM_DIV_32 * @arg @ref LL_RCC_PLLI2SM_DIV_33 * @arg @ref LL_RCC_PLLI2SM_DIV_34 * @arg @ref LL_RCC_PLLI2SM_DIV_35 * @arg @ref LL_RCC_PLLI2SM_DIV_36 * @arg @ref LL_RCC_PLLI2SM_DIV_37 * @arg @ref LL_RCC_PLLI2SM_DIV_38 * @arg @ref LL_RCC_PLLI2SM_DIV_39 * @arg @ref LL_RCC_PLLI2SM_DIV_40 * @arg @ref LL_RCC_PLLI2SM_DIV_41 * @arg @ref LL_RCC_PLLI2SM_DIV_42 * @arg @ref LL_RCC_PLLI2SM_DIV_43 * @arg @ref LL_RCC_PLLI2SM_DIV_44 * @arg @ref LL_RCC_PLLI2SM_DIV_45 * @arg @ref LL_RCC_PLLI2SM_DIV_46 * @arg @ref LL_RCC_PLLI2SM_DIV_47 * @arg @ref LL_RCC_PLLI2SM_DIV_48 * @arg @ref LL_RCC_PLLI2SM_DIV_49 * @arg @ref LL_RCC_PLLI2SM_DIV_50 * @arg @ref LL_RCC_PLLI2SM_DIV_51 * @arg @ref LL_RCC_PLLI2SM_DIV_52 * @arg @ref LL_RCC_PLLI2SM_DIV_53 * @arg @ref LL_RCC_PLLI2SM_DIV_54 * @arg @ref LL_RCC_PLLI2SM_DIV_55 * @arg @ref LL_RCC_PLLI2SM_DIV_56 * @arg @ref LL_RCC_PLLI2SM_DIV_57 * @arg @ref LL_RCC_PLLI2SM_DIV_58 * @arg @ref LL_RCC_PLLI2SM_DIV_59 * @arg @ref LL_RCC_PLLI2SM_DIV_60 * @arg @ref LL_RCC_PLLI2SM_DIV_61 * @arg @ref LL_RCC_PLLI2SM_DIV_62 * @arg @ref LL_RCC_PLLI2SM_DIV_63 * @param PLLN Between 50/192(*) and 432 * * (*) value not defined in all devices. * @param PLLQ_R This parameter can be one of the following values: * @arg @ref LL_RCC_PLLI2SQ_DIV_2 (*) * @arg @ref LL_RCC_PLLI2SQ_DIV_3 (*) * @arg @ref LL_RCC_PLLI2SQ_DIV_4 (*) * @arg @ref LL_RCC_PLLI2SQ_DIV_5 (*) * @arg @ref LL_RCC_PLLI2SQ_DIV_6 (*) * @arg @ref LL_RCC_PLLI2SQ_DIV_7 (*) * @arg @ref LL_RCC_PLLI2SQ_DIV_8 (*) * @arg @ref LL_RCC_PLLI2SQ_DIV_9 (*) * @arg @ref LL_RCC_PLLI2SQ_DIV_10 (*) * @arg @ref LL_RCC_PLLI2SQ_DIV_11 (*) * @arg @ref LL_RCC_PLLI2SQ_DIV_12 (*) * @arg @ref LL_RCC_PLLI2SQ_DIV_13 (*) * @arg @ref LL_RCC_PLLI2SQ_DIV_14 (*) * @arg @ref LL_RCC_PLLI2SQ_DIV_15 (*) * @arg @ref LL_RCC_PLLI2SR_DIV_2 (*) * @arg @ref LL_RCC_PLLI2SR_DIV_3 (*) * @arg @ref LL_RCC_PLLI2SR_DIV_4 (*) * @arg @ref LL_RCC_PLLI2SR_DIV_5 (*) * @arg @ref LL_RCC_PLLI2SR_DIV_6 (*) * @arg @ref LL_RCC_PLLI2SR_DIV_7 (*) * * (*) value not defined in all devices. * @param PLLDIVQ_R This parameter can be one of the following values: * @arg @ref LL_RCC_PLLI2SDIVQ_DIV_1 (*) * @arg @ref LL_RCC_PLLI2SDIVQ_DIV_2 (*) * @arg @ref LL_RCC_PLLI2SDIVQ_DIV_3 (*) * @arg @ref LL_RCC_PLLI2SDIVQ_DIV_4 (*) * @arg @ref LL_RCC_PLLI2SDIVQ_DIV_5 (*) * @arg @ref LL_RCC_PLLI2SDIVQ_DIV_6 (*) * @arg @ref LL_RCC_PLLI2SDIVQ_DIV_7 (*) * @arg @ref LL_RCC_PLLI2SDIVQ_DIV_8 (*) * @arg @ref LL_RCC_PLLI2SDIVQ_DIV_9 (*) * @arg @ref LL_RCC_PLLI2SDIVQ_DIV_10 (*) * @arg @ref LL_RCC_PLLI2SDIVQ_DIV_11 (*) * @arg @ref LL_RCC_PLLI2SDIVQ_DIV_12 (*) * @arg @ref LL_RCC_PLLI2SDIVQ_DIV_13 (*) * @arg @ref LL_RCC_PLLI2SDIVQ_DIV_14 (*) * @arg @ref LL_RCC_PLLI2SDIVQ_DIV_15 (*) * @arg @ref LL_RCC_PLLI2SDIVQ_DIV_16 (*) * @arg @ref LL_RCC_PLLI2SDIVQ_DIV_17 (*) * @arg @ref LL_RCC_PLLI2SDIVQ_DIV_18 (*) * @arg @ref LL_RCC_PLLI2SDIVQ_DIV_19 (*) * @arg @ref LL_RCC_PLLI2SDIVQ_DIV_20 (*) * @arg @ref LL_RCC_PLLI2SDIVQ_DIV_21 (*) * @arg @ref LL_RCC_PLLI2SDIVQ_DIV_22 (*) * @arg @ref LL_RCC_PLLI2SDIVQ_DIV_23 (*) * @arg @ref LL_RCC_PLLI2SDIVQ_DIV_24 (*) * @arg @ref LL_RCC_PLLI2SDIVQ_DIV_25 (*) * @arg @ref LL_RCC_PLLI2SDIVQ_DIV_26 (*) * @arg @ref LL_RCC_PLLI2SDIVQ_DIV_27 (*) * @arg @ref LL_RCC_PLLI2SDIVQ_DIV_28 (*) * @arg @ref LL_RCC_PLLI2SDIVQ_DIV_29 (*) * @arg @ref LL_RCC_PLLI2SDIVQ_DIV_30 (*) * @arg @ref LL_RCC_PLLI2SDIVQ_DIV_31 (*) * @arg @ref LL_RCC_PLLI2SDIVQ_DIV_32 (*) * @arg @ref LL_RCC_PLLI2SDIVR_DIV_1 (*) * @arg @ref LL_RCC_PLLI2SDIVR_DIV_2 (*) * @arg @ref LL_RCC_PLLI2SDIVR_DIV_3 (*) * @arg @ref LL_RCC_PLLI2SDIVR_DIV_4 (*) * @arg @ref LL_RCC_PLLI2SDIVR_DIV_5 (*) * @arg @ref LL_RCC_PLLI2SDIVR_DIV_6 (*) * @arg @ref LL_RCC_PLLI2SDIVR_DIV_7 (*) * @arg @ref LL_RCC_PLLI2SDIVR_DIV_8 (*) * @arg @ref LL_RCC_PLLI2SDIVR_DIV_9 (*) * @arg @ref LL_RCC_PLLI2SDIVR_DIV_10 (*) * @arg @ref LL_RCC_PLLI2SDIVR_DIV_11 (*) * @arg @ref LL_RCC_PLLI2SDIVR_DIV_12 (*) * @arg @ref LL_RCC_PLLI2SDIVR_DIV_13 (*) * @arg @ref LL_RCC_PLLI2SDIVR_DIV_14 (*) * @arg @ref LL_RCC_PLLI2SDIVR_DIV_15 (*) * @arg @ref LL_RCC_PLLI2SDIVR_DIV_16 (*) * @arg @ref LL_RCC_PLLI2SDIVR_DIV_17 (*) * @arg @ref LL_RCC_PLLI2SDIVR_DIV_18 (*) * @arg @ref LL_RCC_PLLI2SDIVR_DIV_19 (*) * @arg @ref LL_RCC_PLLI2SDIVR_DIV_20 (*) * @arg @ref LL_RCC_PLLI2SDIVR_DIV_21 (*) * @arg @ref LL_RCC_PLLI2SDIVR_DIV_22 (*) * @arg @ref LL_RCC_PLLI2SDIVR_DIV_23 (*) * @arg @ref LL_RCC_PLLI2SDIVR_DIV_24 (*) * @arg @ref LL_RCC_PLLI2SDIVR_DIV_25 (*) * @arg @ref LL_RCC_PLLI2SDIVR_DIV_26 (*) * @arg @ref LL_RCC_PLLI2SDIVR_DIV_27 (*) * @arg @ref LL_RCC_PLLI2SDIVR_DIV_28 (*) * @arg @ref LL_RCC_PLLI2SDIVR_DIV_29 (*) * @arg @ref LL_RCC_PLLI2SDIVR_DIV_30 (*) * @arg @ref LL_RCC_PLLI2SDIVR_DIV_31 (*) * * (*) value not defined in all devices. * @retval None */ __STATIC_INLINE void LL_RCC_PLLI2S_ConfigDomain_SAI(uint32_t Source, uint32_t PLLM, uint32_t PLLN, uint32_t PLLQ_R, uint32_t PLLDIVQ_R) { register __IO uint32_t *pReg = (__IO uint32_t *)((uint32_t)((uint32_t)(&RCC->PLLCFGR) + (Source & 0x80U))); MODIFY_REG(*pReg, RCC_PLLCFGR_PLLSRC, (Source & (~0x80U))); #if defined(RCC_PLLI2SCFGR_PLLI2SM) MODIFY_REG(RCC->PLLI2SCFGR, RCC_PLLI2SCFGR_PLLI2SM, PLLM); #else MODIFY_REG(RCC->PLLCFGR, RCC_PLLCFGR_PLLM, PLLM); #endif /* RCC_PLLI2SCFGR_PLLI2SM */ MODIFY_REG(RCC->PLLI2SCFGR, RCC_PLLI2SCFGR_PLLI2SN, PLLN << RCC_PLLI2SCFGR_PLLI2SN_Pos); #if defined(RCC_DCKCFGR_PLLI2SDIVQ) MODIFY_REG(RCC->PLLI2SCFGR, RCC_PLLI2SCFGR_PLLI2SQ, PLLQ_R); MODIFY_REG(RCC->DCKCFGR, RCC_DCKCFGR_PLLI2SDIVQ, PLLDIVQ_R); #else MODIFY_REG(RCC->PLLI2SCFGR, RCC_PLLI2SCFGR_PLLI2SR, PLLQ_R); MODIFY_REG(RCC->DCKCFGR, RCC_DCKCFGR_PLLI2SDIVR, PLLDIVQ_R); #endif /* RCC_DCKCFGR_PLLI2SDIVQ */ } #endif /* RCC_DCKCFGR_PLLI2SDIVQ && RCC_DCKCFGR_PLLI2SDIVR */ #if defined(RCC_PLLI2SCFGR_PLLI2SQ) && !defined(RCC_DCKCFGR_PLLI2SDIVQ) /** * @brief Configure PLLI2S used for 48Mhz domain clock * @note PLL Source and PLLM Divider can be written only when PLL, * PLLI2S and PLLSAI(*) are disabled * @note PLLN/PLLQ can be written only when PLLI2S is disabled * @note This can be selected for RNG, USB, SDIO * @rmtoll PLLCFGR PLLSRC LL_RCC_PLLI2S_ConfigDomain_48M\n * PLLI2SCFGR PLLI2SSRC LL_RCC_PLLI2S_ConfigDomain_48M\n * PLLCFGR PLLM LL_RCC_PLLI2S_ConfigDomain_48M\n * PLLI2SCFGR PLLI2SM LL_RCC_PLLI2S_ConfigDomain_48M\n * PLLI2SCFGR PLLI2SN LL_RCC_PLLI2S_ConfigDomain_48M\n * PLLI2SCFGR PLLI2SQ LL_RCC_PLLI2S_ConfigDomain_48M * @param Source This parameter can be one of the following values: * @arg @ref LL_RCC_PLLSOURCE_HSI * @arg @ref LL_RCC_PLLSOURCE_HSE * @arg @ref LL_RCC_PLLI2SSOURCE_PIN (*) * * (*) value not defined in all devices. * @param PLLM This parameter can be one of the following values: * @arg @ref LL_RCC_PLLI2SM_DIV_2 * @arg @ref LL_RCC_PLLI2SM_DIV_3 * @arg @ref LL_RCC_PLLI2SM_DIV_4 * @arg @ref LL_RCC_PLLI2SM_DIV_5 * @arg @ref LL_RCC_PLLI2SM_DIV_6 * @arg @ref LL_RCC_PLLI2SM_DIV_7 * @arg @ref LL_RCC_PLLI2SM_DIV_8 * @arg @ref LL_RCC_PLLI2SM_DIV_9 * @arg @ref LL_RCC_PLLI2SM_DIV_10 * @arg @ref LL_RCC_PLLI2SM_DIV_11 * @arg @ref LL_RCC_PLLI2SM_DIV_12 * @arg @ref LL_RCC_PLLI2SM_DIV_13 * @arg @ref LL_RCC_PLLI2SM_DIV_14 * @arg @ref LL_RCC_PLLI2SM_DIV_15 * @arg @ref LL_RCC_PLLI2SM_DIV_16 * @arg @ref LL_RCC_PLLI2SM_DIV_17 * @arg @ref LL_RCC_PLLI2SM_DIV_18 * @arg @ref LL_RCC_PLLI2SM_DIV_19 * @arg @ref LL_RCC_PLLI2SM_DIV_20 * @arg @ref LL_RCC_PLLI2SM_DIV_21 * @arg @ref LL_RCC_PLLI2SM_DIV_22 * @arg @ref LL_RCC_PLLI2SM_DIV_23 * @arg @ref LL_RCC_PLLI2SM_DIV_24 * @arg @ref LL_RCC_PLLI2SM_DIV_25 * @arg @ref LL_RCC_PLLI2SM_DIV_26 * @arg @ref LL_RCC_PLLI2SM_DIV_27 * @arg @ref LL_RCC_PLLI2SM_DIV_28 * @arg @ref LL_RCC_PLLI2SM_DIV_29 * @arg @ref LL_RCC_PLLI2SM_DIV_30 * @arg @ref LL_RCC_PLLI2SM_DIV_31 * @arg @ref LL_RCC_PLLI2SM_DIV_32 * @arg @ref LL_RCC_PLLI2SM_DIV_33 * @arg @ref LL_RCC_PLLI2SM_DIV_34 * @arg @ref LL_RCC_PLLI2SM_DIV_35 * @arg @ref LL_RCC_PLLI2SM_DIV_36 * @arg @ref LL_RCC_PLLI2SM_DIV_37 * @arg @ref LL_RCC_PLLI2SM_DIV_38 * @arg @ref LL_RCC_PLLI2SM_DIV_39 * @arg @ref LL_RCC_PLLI2SM_DIV_40 * @arg @ref LL_RCC_PLLI2SM_DIV_41 * @arg @ref LL_RCC_PLLI2SM_DIV_42 * @arg @ref LL_RCC_PLLI2SM_DIV_43 * @arg @ref LL_RCC_PLLI2SM_DIV_44 * @arg @ref LL_RCC_PLLI2SM_DIV_45 * @arg @ref LL_RCC_PLLI2SM_DIV_46 * @arg @ref LL_RCC_PLLI2SM_DIV_47 * @arg @ref LL_RCC_PLLI2SM_DIV_48 * @arg @ref LL_RCC_PLLI2SM_DIV_49 * @arg @ref LL_RCC_PLLI2SM_DIV_50 * @arg @ref LL_RCC_PLLI2SM_DIV_51 * @arg @ref LL_RCC_PLLI2SM_DIV_52 * @arg @ref LL_RCC_PLLI2SM_DIV_53 * @arg @ref LL_RCC_PLLI2SM_DIV_54 * @arg @ref LL_RCC_PLLI2SM_DIV_55 * @arg @ref LL_RCC_PLLI2SM_DIV_56 * @arg @ref LL_RCC_PLLI2SM_DIV_57 * @arg @ref LL_RCC_PLLI2SM_DIV_58 * @arg @ref LL_RCC_PLLI2SM_DIV_59 * @arg @ref LL_RCC_PLLI2SM_DIV_60 * @arg @ref LL_RCC_PLLI2SM_DIV_61 * @arg @ref LL_RCC_PLLI2SM_DIV_62 * @arg @ref LL_RCC_PLLI2SM_DIV_63 * @param PLLN Between 50 and 432 * @param PLLQ This parameter can be one of the following values: * @arg @ref LL_RCC_PLLI2SQ_DIV_2 * @arg @ref LL_RCC_PLLI2SQ_DIV_3 * @arg @ref LL_RCC_PLLI2SQ_DIV_4 * @arg @ref LL_RCC_PLLI2SQ_DIV_5 * @arg @ref LL_RCC_PLLI2SQ_DIV_6 * @arg @ref LL_RCC_PLLI2SQ_DIV_7 * @arg @ref LL_RCC_PLLI2SQ_DIV_8 * @arg @ref LL_RCC_PLLI2SQ_DIV_9 * @arg @ref LL_RCC_PLLI2SQ_DIV_10 * @arg @ref LL_RCC_PLLI2SQ_DIV_11 * @arg @ref LL_RCC_PLLI2SQ_DIV_12 * @arg @ref LL_RCC_PLLI2SQ_DIV_13 * @arg @ref LL_RCC_PLLI2SQ_DIV_14 * @arg @ref LL_RCC_PLLI2SQ_DIV_15 * @retval None */ __STATIC_INLINE void LL_RCC_PLLI2S_ConfigDomain_48M(uint32_t Source, uint32_t PLLM, uint32_t PLLN, uint32_t PLLQ) { register __IO uint32_t *pReg = (__IO uint32_t *)((uint32_t)((uint32_t)(&RCC->PLLCFGR) + (Source & 0x80U))); MODIFY_REG(*pReg, RCC_PLLCFGR_PLLSRC, (Source & (~0x80U))); #if defined(RCC_PLLI2SCFGR_PLLI2SM) MODIFY_REG(RCC->PLLI2SCFGR, RCC_PLLI2SCFGR_PLLI2SM, PLLM); #else MODIFY_REG(RCC->PLLCFGR, RCC_PLLCFGR_PLLM, PLLM); #endif /* RCC_PLLI2SCFGR_PLLI2SM */ MODIFY_REG(RCC->PLLI2SCFGR, RCC_PLLI2SCFGR_PLLI2SN | RCC_PLLI2SCFGR_PLLI2SQ, PLLN << RCC_PLLI2SCFGR_PLLI2SN_Pos | PLLQ); } #endif /* RCC_PLLI2SCFGR_PLLI2SQ && !RCC_DCKCFGR_PLLI2SDIVQ */ #if defined(SPDIFRX) /** * @brief Configure PLLI2S used for SPDIFRX domain clock * @note PLL Source and PLLM Divider can be written only when PLL, * PLLI2S and PLLSAI(*) are disabled * @note PLLN/PLLP can be written only when PLLI2S is disabled * @note This can be selected for SPDIFRX * @rmtoll PLLCFGR PLLSRC LL_RCC_PLLI2S_ConfigDomain_SPDIFRX\n * PLLCFGR PLLM LL_RCC_PLLI2S_ConfigDomain_SPDIFRX\n * PLLI2SCFGR PLLI2SM LL_RCC_PLLI2S_ConfigDomain_SPDIFRX\n * PLLI2SCFGR PLLI2SN LL_RCC_PLLI2S_ConfigDomain_SPDIFRX\n * PLLI2SCFGR PLLI2SP LL_RCC_PLLI2S_ConfigDomain_SPDIFRX * @param Source This parameter can be one of the following values: * @arg @ref LL_RCC_PLLSOURCE_HSI * @arg @ref LL_RCC_PLLSOURCE_HSE * @param PLLM This parameter can be one of the following values: * @arg @ref LL_RCC_PLLI2SM_DIV_2 * @arg @ref LL_RCC_PLLI2SM_DIV_3 * @arg @ref LL_RCC_PLLI2SM_DIV_4 * @arg @ref LL_RCC_PLLI2SM_DIV_5 * @arg @ref LL_RCC_PLLI2SM_DIV_6 * @arg @ref LL_RCC_PLLI2SM_DIV_7 * @arg @ref LL_RCC_PLLI2SM_DIV_8 * @arg @ref LL_RCC_PLLI2SM_DIV_9 * @arg @ref LL_RCC_PLLI2SM_DIV_10 * @arg @ref LL_RCC_PLLI2SM_DIV_11 * @arg @ref LL_RCC_PLLI2SM_DIV_12 * @arg @ref LL_RCC_PLLI2SM_DIV_13 * @arg @ref LL_RCC_PLLI2SM_DIV_14 * @arg @ref LL_RCC_PLLI2SM_DIV_15 * @arg @ref LL_RCC_PLLI2SM_DIV_16 * @arg @ref LL_RCC_PLLI2SM_DIV_17 * @arg @ref LL_RCC_PLLI2SM_DIV_18 * @arg @ref LL_RCC_PLLI2SM_DIV_19 * @arg @ref LL_RCC_PLLI2SM_DIV_20 * @arg @ref LL_RCC_PLLI2SM_DIV_21 * @arg @ref LL_RCC_PLLI2SM_DIV_22 * @arg @ref LL_RCC_PLLI2SM_DIV_23 * @arg @ref LL_RCC_PLLI2SM_DIV_24 * @arg @ref LL_RCC_PLLI2SM_DIV_25 * @arg @ref LL_RCC_PLLI2SM_DIV_26 * @arg @ref LL_RCC_PLLI2SM_DIV_27 * @arg @ref LL_RCC_PLLI2SM_DIV_28 * @arg @ref LL_RCC_PLLI2SM_DIV_29 * @arg @ref LL_RCC_PLLI2SM_DIV_30 * @arg @ref LL_RCC_PLLI2SM_DIV_31 * @arg @ref LL_RCC_PLLI2SM_DIV_32 * @arg @ref LL_RCC_PLLI2SM_DIV_33 * @arg @ref LL_RCC_PLLI2SM_DIV_34 * @arg @ref LL_RCC_PLLI2SM_DIV_35 * @arg @ref LL_RCC_PLLI2SM_DIV_36 * @arg @ref LL_RCC_PLLI2SM_DIV_37 * @arg @ref LL_RCC_PLLI2SM_DIV_38 * @arg @ref LL_RCC_PLLI2SM_DIV_39 * @arg @ref LL_RCC_PLLI2SM_DIV_40 * @arg @ref LL_RCC_PLLI2SM_DIV_41 * @arg @ref LL_RCC_PLLI2SM_DIV_42 * @arg @ref LL_RCC_PLLI2SM_DIV_43 * @arg @ref LL_RCC_PLLI2SM_DIV_44 * @arg @ref LL_RCC_PLLI2SM_DIV_45 * @arg @ref LL_RCC_PLLI2SM_DIV_46 * @arg @ref LL_RCC_PLLI2SM_DIV_47 * @arg @ref LL_RCC_PLLI2SM_DIV_48 * @arg @ref LL_RCC_PLLI2SM_DIV_49 * @arg @ref LL_RCC_PLLI2SM_DIV_50 * @arg @ref LL_RCC_PLLI2SM_DIV_51 * @arg @ref LL_RCC_PLLI2SM_DIV_52 * @arg @ref LL_RCC_PLLI2SM_DIV_53 * @arg @ref LL_RCC_PLLI2SM_DIV_54 * @arg @ref LL_RCC_PLLI2SM_DIV_55 * @arg @ref LL_RCC_PLLI2SM_DIV_56 * @arg @ref LL_RCC_PLLI2SM_DIV_57 * @arg @ref LL_RCC_PLLI2SM_DIV_58 * @arg @ref LL_RCC_PLLI2SM_DIV_59 * @arg @ref LL_RCC_PLLI2SM_DIV_60 * @arg @ref LL_RCC_PLLI2SM_DIV_61 * @arg @ref LL_RCC_PLLI2SM_DIV_62 * @arg @ref LL_RCC_PLLI2SM_DIV_63 * @param PLLN Between 50 and 432 * @param PLLP This parameter can be one of the following values: * @arg @ref LL_RCC_PLLI2SP_DIV_2 * @arg @ref LL_RCC_PLLI2SP_DIV_4 * @arg @ref LL_RCC_PLLI2SP_DIV_6 * @arg @ref LL_RCC_PLLI2SP_DIV_8 * @retval None */ __STATIC_INLINE void LL_RCC_PLLI2S_ConfigDomain_SPDIFRX(uint32_t Source, uint32_t PLLM, uint32_t PLLN, uint32_t PLLP) { MODIFY_REG(RCC->PLLCFGR, RCC_PLLCFGR_PLLSRC, Source); #if defined(RCC_PLLI2SCFGR_PLLI2SM) MODIFY_REG(RCC->PLLI2SCFGR, RCC_PLLI2SCFGR_PLLI2SM, PLLM); #else MODIFY_REG(RCC->PLLCFGR, RCC_PLLCFGR_PLLM, PLLM); #endif /* RCC_PLLI2SCFGR_PLLI2SM */ MODIFY_REG(RCC->PLLI2SCFGR, RCC_PLLI2SCFGR_PLLI2SN | RCC_PLLI2SCFGR_PLLI2SP, PLLN << RCC_PLLI2SCFGR_PLLI2SN_Pos | PLLP); } #endif /* SPDIFRX */ /** * @brief Configure PLLI2S used for I2S1 domain clock * @note PLL Source and PLLM Divider can be written only when PLL, * PLLI2S and PLLSAI(*) are disabled * @note PLLN/PLLR can be written only when PLLI2S is disabled * @note This can be selected for I2S * @rmtoll PLLCFGR PLLSRC LL_RCC_PLLI2S_ConfigDomain_I2S\n * PLLCFGR PLLM LL_RCC_PLLI2S_ConfigDomain_I2S\n * PLLI2SCFGR PLLI2SSRC LL_RCC_PLLI2S_ConfigDomain_I2S\n * PLLI2SCFGR PLLI2SM LL_RCC_PLLI2S_ConfigDomain_I2S\n * PLLI2SCFGR PLLI2SN LL_RCC_PLLI2S_ConfigDomain_I2S\n * PLLI2SCFGR PLLI2SR LL_RCC_PLLI2S_ConfigDomain_I2S * @param Source This parameter can be one of the following values: * @arg @ref LL_RCC_PLLSOURCE_HSI * @arg @ref LL_RCC_PLLSOURCE_HSE * @arg @ref LL_RCC_PLLI2SSOURCE_PIN (*) * * (*) value not defined in all devices. * @param PLLM This parameter can be one of the following values: * @arg @ref LL_RCC_PLLI2SM_DIV_2 * @arg @ref LL_RCC_PLLI2SM_DIV_3 * @arg @ref LL_RCC_PLLI2SM_DIV_4 * @arg @ref LL_RCC_PLLI2SM_DIV_5 * @arg @ref LL_RCC_PLLI2SM_DIV_6 * @arg @ref LL_RCC_PLLI2SM_DIV_7 * @arg @ref LL_RCC_PLLI2SM_DIV_8 * @arg @ref LL_RCC_PLLI2SM_DIV_9 * @arg @ref LL_RCC_PLLI2SM_DIV_10 * @arg @ref LL_RCC_PLLI2SM_DIV_11 * @arg @ref LL_RCC_PLLI2SM_DIV_12 * @arg @ref LL_RCC_PLLI2SM_DIV_13 * @arg @ref LL_RCC_PLLI2SM_DIV_14 * @arg @ref LL_RCC_PLLI2SM_DIV_15 * @arg @ref LL_RCC_PLLI2SM_DIV_16 * @arg @ref LL_RCC_PLLI2SM_DIV_17 * @arg @ref LL_RCC_PLLI2SM_DIV_18 * @arg @ref LL_RCC_PLLI2SM_DIV_19 * @arg @ref LL_RCC_PLLI2SM_DIV_20 * @arg @ref LL_RCC_PLLI2SM_DIV_21 * @arg @ref LL_RCC_PLLI2SM_DIV_22 * @arg @ref LL_RCC_PLLI2SM_DIV_23 * @arg @ref LL_RCC_PLLI2SM_DIV_24 * @arg @ref LL_RCC_PLLI2SM_DIV_25 * @arg @ref LL_RCC_PLLI2SM_DIV_26 * @arg @ref LL_RCC_PLLI2SM_DIV_27 * @arg @ref LL_RCC_PLLI2SM_DIV_28 * @arg @ref LL_RCC_PLLI2SM_DIV_29 * @arg @ref LL_RCC_PLLI2SM_DIV_30 * @arg @ref LL_RCC_PLLI2SM_DIV_31 * @arg @ref LL_RCC_PLLI2SM_DIV_32 * @arg @ref LL_RCC_PLLI2SM_DIV_33 * @arg @ref LL_RCC_PLLI2SM_DIV_34 * @arg @ref LL_RCC_PLLI2SM_DIV_35 * @arg @ref LL_RCC_PLLI2SM_DIV_36 * @arg @ref LL_RCC_PLLI2SM_DIV_37 * @arg @ref LL_RCC_PLLI2SM_DIV_38 * @arg @ref LL_RCC_PLLI2SM_DIV_39 * @arg @ref LL_RCC_PLLI2SM_DIV_40 * @arg @ref LL_RCC_PLLI2SM_DIV_41 * @arg @ref LL_RCC_PLLI2SM_DIV_42 * @arg @ref LL_RCC_PLLI2SM_DIV_43 * @arg @ref LL_RCC_PLLI2SM_DIV_44 * @arg @ref LL_RCC_PLLI2SM_DIV_45 * @arg @ref LL_RCC_PLLI2SM_DIV_46 * @arg @ref LL_RCC_PLLI2SM_DIV_47 * @arg @ref LL_RCC_PLLI2SM_DIV_48 * @arg @ref LL_RCC_PLLI2SM_DIV_49 * @arg @ref LL_RCC_PLLI2SM_DIV_50 * @arg @ref LL_RCC_PLLI2SM_DIV_51 * @arg @ref LL_RCC_PLLI2SM_DIV_52 * @arg @ref LL_RCC_PLLI2SM_DIV_53 * @arg @ref LL_RCC_PLLI2SM_DIV_54 * @arg @ref LL_RCC_PLLI2SM_DIV_55 * @arg @ref LL_RCC_PLLI2SM_DIV_56 * @arg @ref LL_RCC_PLLI2SM_DIV_57 * @arg @ref LL_RCC_PLLI2SM_DIV_58 * @arg @ref LL_RCC_PLLI2SM_DIV_59 * @arg @ref LL_RCC_PLLI2SM_DIV_60 * @arg @ref LL_RCC_PLLI2SM_DIV_61 * @arg @ref LL_RCC_PLLI2SM_DIV_62 * @arg @ref LL_RCC_PLLI2SM_DIV_63 * @param PLLN Between 50/192(*) and 432 * * (*) value not defined in all devices. * @param PLLR This parameter can be one of the following values: * @arg @ref LL_RCC_PLLI2SR_DIV_2 * @arg @ref LL_RCC_PLLI2SR_DIV_3 * @arg @ref LL_RCC_PLLI2SR_DIV_4 * @arg @ref LL_RCC_PLLI2SR_DIV_5 * @arg @ref LL_RCC_PLLI2SR_DIV_6 * @arg @ref LL_RCC_PLLI2SR_DIV_7 * @retval None */ __STATIC_INLINE void LL_RCC_PLLI2S_ConfigDomain_I2S(uint32_t Source, uint32_t PLLM, uint32_t PLLN, uint32_t PLLR) { register __IO uint32_t *pReg = (__IO uint32_t *)((uint32_t)((uint32_t)(&RCC->PLLCFGR) + (Source & 0x80U))); MODIFY_REG(*pReg, RCC_PLLCFGR_PLLSRC, (Source & (~0x80U))); #if defined(RCC_PLLI2SCFGR_PLLI2SM) MODIFY_REG(RCC->PLLI2SCFGR, RCC_PLLI2SCFGR_PLLI2SM, PLLM); #else MODIFY_REG(RCC->PLLCFGR, RCC_PLLCFGR_PLLM, PLLM); #endif /* RCC_PLLI2SCFGR_PLLI2SM */ MODIFY_REG(RCC->PLLI2SCFGR, RCC_PLLI2SCFGR_PLLI2SN | RCC_PLLI2SCFGR_PLLI2SR, PLLN << RCC_PLLI2SCFGR_PLLI2SN_Pos | PLLR); } /** * @brief Get I2SPLL multiplication factor for VCO * @rmtoll PLLI2SCFGR PLLI2SN LL_RCC_PLLI2S_GetN * @retval Between 50/192(*) and 432 * * (*) value not defined in all devices. */ __STATIC_INLINE uint32_t LL_RCC_PLLI2S_GetN(void) { return (uint32_t)(READ_BIT(RCC->PLLI2SCFGR, RCC_PLLI2SCFGR_PLLI2SN) >> RCC_PLLI2SCFGR_PLLI2SN_Pos); } #if defined(RCC_PLLI2SCFGR_PLLI2SQ) /** * @brief Get I2SPLL division factor for PLLI2SQ * @rmtoll PLLI2SCFGR PLLI2SQ LL_RCC_PLLI2S_GetQ * @retval Returned value can be one of the following values: * @arg @ref LL_RCC_PLLI2SQ_DIV_2 * @arg @ref LL_RCC_PLLI2SQ_DIV_3 * @arg @ref LL_RCC_PLLI2SQ_DIV_4 * @arg @ref LL_RCC_PLLI2SQ_DIV_5 * @arg @ref LL_RCC_PLLI2SQ_DIV_6 * @arg @ref LL_RCC_PLLI2SQ_DIV_7 * @arg @ref LL_RCC_PLLI2SQ_DIV_8 * @arg @ref LL_RCC_PLLI2SQ_DIV_9 * @arg @ref LL_RCC_PLLI2SQ_DIV_10 * @arg @ref LL_RCC_PLLI2SQ_DIV_11 * @arg @ref LL_RCC_PLLI2SQ_DIV_12 * @arg @ref LL_RCC_PLLI2SQ_DIV_13 * @arg @ref LL_RCC_PLLI2SQ_DIV_14 * @arg @ref LL_RCC_PLLI2SQ_DIV_15 */ __STATIC_INLINE uint32_t LL_RCC_PLLI2S_GetQ(void) { return (uint32_t)(READ_BIT(RCC->PLLI2SCFGR, RCC_PLLI2SCFGR_PLLI2SQ)); } #endif /* RCC_PLLI2SCFGR_PLLI2SQ */ /** * @brief Get I2SPLL division factor for PLLI2SR * @note used for PLLI2SCLK (I2S clock) * @rmtoll PLLI2SCFGR PLLI2SR LL_RCC_PLLI2S_GetR * @retval Returned value can be one of the following values: * @arg @ref LL_RCC_PLLI2SR_DIV_2 * @arg @ref LL_RCC_PLLI2SR_DIV_3 * @arg @ref LL_RCC_PLLI2SR_DIV_4 * @arg @ref LL_RCC_PLLI2SR_DIV_5 * @arg @ref LL_RCC_PLLI2SR_DIV_6 * @arg @ref LL_RCC_PLLI2SR_DIV_7 */ __STATIC_INLINE uint32_t LL_RCC_PLLI2S_GetR(void) { return (uint32_t)(READ_BIT(RCC->PLLI2SCFGR, RCC_PLLI2SCFGR_PLLI2SR)); } #if defined(RCC_PLLI2SCFGR_PLLI2SP) /** * @brief Get I2SPLL division factor for PLLI2SP * @note used for PLLSPDIFRXCLK (SPDIFRX clock) * @rmtoll PLLI2SCFGR PLLI2SP LL_RCC_PLLI2S_GetP * @retval Returned value can be one of the following values: * @arg @ref LL_RCC_PLLI2SP_DIV_2 * @arg @ref LL_RCC_PLLI2SP_DIV_4 * @arg @ref LL_RCC_PLLI2SP_DIV_6 * @arg @ref LL_RCC_PLLI2SP_DIV_8 */ __STATIC_INLINE uint32_t LL_RCC_PLLI2S_GetP(void) { return (uint32_t)(READ_BIT(RCC->PLLI2SCFGR, RCC_PLLI2SCFGR_PLLI2SP)); } #endif /* RCC_PLLI2SCFGR_PLLI2SP */ #if defined(RCC_DCKCFGR_PLLI2SDIVQ) /** * @brief Get I2SPLL division factor for PLLI2SDIVQ * @note used PLLSAICLK selected (SAI clock) * @rmtoll DCKCFGR PLLI2SDIVQ LL_RCC_PLLI2S_GetDIVQ * @retval Returned value can be one of the following values: * @arg @ref LL_RCC_PLLI2SDIVQ_DIV_1 * @arg @ref LL_RCC_PLLI2SDIVQ_DIV_2 * @arg @ref LL_RCC_PLLI2SDIVQ_DIV_3 * @arg @ref LL_RCC_PLLI2SDIVQ_DIV_4 * @arg @ref LL_RCC_PLLI2SDIVQ_DIV_5 * @arg @ref LL_RCC_PLLI2SDIVQ_DIV_6 * @arg @ref LL_RCC_PLLI2SDIVQ_DIV_7 * @arg @ref LL_RCC_PLLI2SDIVQ_DIV_8 * @arg @ref LL_RCC_PLLI2SDIVQ_DIV_9 * @arg @ref LL_RCC_PLLI2SDIVQ_DIV_10 * @arg @ref LL_RCC_PLLI2SDIVQ_DIV_11 * @arg @ref LL_RCC_PLLI2SDIVQ_DIV_12 * @arg @ref LL_RCC_PLLI2SDIVQ_DIV_13 * @arg @ref LL_RCC_PLLI2SDIVQ_DIV_14 * @arg @ref LL_RCC_PLLI2SDIVQ_DIV_15 * @arg @ref LL_RCC_PLLI2SDIVQ_DIV_16 * @arg @ref LL_RCC_PLLI2SDIVQ_DIV_17 * @arg @ref LL_RCC_PLLI2SDIVQ_DIV_18 * @arg @ref LL_RCC_PLLI2SDIVQ_DIV_19 * @arg @ref LL_RCC_PLLI2SDIVQ_DIV_20 * @arg @ref LL_RCC_PLLI2SDIVQ_DIV_21 * @arg @ref LL_RCC_PLLI2SDIVQ_DIV_22 * @arg @ref LL_RCC_PLLI2SDIVQ_DIV_23 * @arg @ref LL_RCC_PLLI2SDIVQ_DIV_24 * @arg @ref LL_RCC_PLLI2SDIVQ_DIV_25 * @arg @ref LL_RCC_PLLI2SDIVQ_DIV_26 * @arg @ref LL_RCC_PLLI2SDIVQ_DIV_27 * @arg @ref LL_RCC_PLLI2SDIVQ_DIV_28 * @arg @ref LL_RCC_PLLI2SDIVQ_DIV_29 * @arg @ref LL_RCC_PLLI2SDIVQ_DIV_30 * @arg @ref LL_RCC_PLLI2SDIVQ_DIV_31 * @arg @ref LL_RCC_PLLI2SDIVQ_DIV_32 */ __STATIC_INLINE uint32_t LL_RCC_PLLI2S_GetDIVQ(void) { return (uint32_t)(READ_BIT(RCC->DCKCFGR, RCC_DCKCFGR_PLLI2SDIVQ)); } #endif /* RCC_DCKCFGR_PLLI2SDIVQ */ #if defined(RCC_DCKCFGR_PLLI2SDIVR) /** * @brief Get I2SPLL division factor for PLLI2SDIVR * @note used PLLSAICLK selected (SAI clock) * @rmtoll DCKCFGR PLLI2SDIVR LL_RCC_PLLI2S_GetDIVR * @retval Returned value can be one of the following values: * @arg @ref LL_RCC_PLLI2SDIVR_DIV_1 * @arg @ref LL_RCC_PLLI2SDIVR_DIV_2 * @arg @ref LL_RCC_PLLI2SDIVR_DIV_3 * @arg @ref LL_RCC_PLLI2SDIVR_DIV_4 * @arg @ref LL_RCC_PLLI2SDIVR_DIV_5 * @arg @ref LL_RCC_PLLI2SDIVR_DIV_6 * @arg @ref LL_RCC_PLLI2SDIVR_DIV_7 * @arg @ref LL_RCC_PLLI2SDIVR_DIV_8 * @arg @ref LL_RCC_PLLI2SDIVR_DIV_9 * @arg @ref LL_RCC_PLLI2SDIVR_DIV_10 * @arg @ref LL_RCC_PLLI2SDIVR_DIV_11 * @arg @ref LL_RCC_PLLI2SDIVR_DIV_12 * @arg @ref LL_RCC_PLLI2SDIVR_DIV_13 * @arg @ref LL_RCC_PLLI2SDIVR_DIV_14 * @arg @ref LL_RCC_PLLI2SDIVR_DIV_15 * @arg @ref LL_RCC_PLLI2SDIVR_DIV_16 * @arg @ref LL_RCC_PLLI2SDIVR_DIV_17 * @arg @ref LL_RCC_PLLI2SDIVR_DIV_18 * @arg @ref LL_RCC_PLLI2SDIVR_DIV_19 * @arg @ref LL_RCC_PLLI2SDIVR_DIV_20 * @arg @ref LL_RCC_PLLI2SDIVR_DIV_21 * @arg @ref LL_RCC_PLLI2SDIVR_DIV_22 * @arg @ref LL_RCC_PLLI2SDIVR_DIV_23 * @arg @ref LL_RCC_PLLI2SDIVR_DIV_24 * @arg @ref LL_RCC_PLLI2SDIVR_DIV_25 * @arg @ref LL_RCC_PLLI2SDIVR_DIV_26 * @arg @ref LL_RCC_PLLI2SDIVR_DIV_27 * @arg @ref LL_RCC_PLLI2SDIVR_DIV_28 * @arg @ref LL_RCC_PLLI2SDIVR_DIV_29 * @arg @ref LL_RCC_PLLI2SDIVR_DIV_30 * @arg @ref LL_RCC_PLLI2SDIVR_DIV_31 */ __STATIC_INLINE uint32_t LL_RCC_PLLI2S_GetDIVR(void) { return (uint32_t)(READ_BIT(RCC->DCKCFGR, RCC_DCKCFGR_PLLI2SDIVR)); } #endif /* RCC_DCKCFGR_PLLI2SDIVR */ /** * @brief Get division factor for PLLI2S input clock * @rmtoll PLLCFGR PLLM LL_RCC_PLLI2S_GetDivider\n * PLLI2SCFGR PLLI2SM LL_RCC_PLLI2S_GetDivider * @retval Returned value can be one of the following values: * @arg @ref LL_RCC_PLLI2SM_DIV_2 * @arg @ref LL_RCC_PLLI2SM_DIV_3 * @arg @ref LL_RCC_PLLI2SM_DIV_4 * @arg @ref LL_RCC_PLLI2SM_DIV_5 * @arg @ref LL_RCC_PLLI2SM_DIV_6 * @arg @ref LL_RCC_PLLI2SM_DIV_7 * @arg @ref LL_RCC_PLLI2SM_DIV_8 * @arg @ref LL_RCC_PLLI2SM_DIV_9 * @arg @ref LL_RCC_PLLI2SM_DIV_10 * @arg @ref LL_RCC_PLLI2SM_DIV_11 * @arg @ref LL_RCC_PLLI2SM_DIV_12 * @arg @ref LL_RCC_PLLI2SM_DIV_13 * @arg @ref LL_RCC_PLLI2SM_DIV_14 * @arg @ref LL_RCC_PLLI2SM_DIV_15 * @arg @ref LL_RCC_PLLI2SM_DIV_16 * @arg @ref LL_RCC_PLLI2SM_DIV_17 * @arg @ref LL_RCC_PLLI2SM_DIV_18 * @arg @ref LL_RCC_PLLI2SM_DIV_19 * @arg @ref LL_RCC_PLLI2SM_DIV_20 * @arg @ref LL_RCC_PLLI2SM_DIV_21 * @arg @ref LL_RCC_PLLI2SM_DIV_22 * @arg @ref LL_RCC_PLLI2SM_DIV_23 * @arg @ref LL_RCC_PLLI2SM_DIV_24 * @arg @ref LL_RCC_PLLI2SM_DIV_25 * @arg @ref LL_RCC_PLLI2SM_DIV_26 * @arg @ref LL_RCC_PLLI2SM_DIV_27 * @arg @ref LL_RCC_PLLI2SM_DIV_28 * @arg @ref LL_RCC_PLLI2SM_DIV_29 * @arg @ref LL_RCC_PLLI2SM_DIV_30 * @arg @ref LL_RCC_PLLI2SM_DIV_31 * @arg @ref LL_RCC_PLLI2SM_DIV_32 * @arg @ref LL_RCC_PLLI2SM_DIV_33 * @arg @ref LL_RCC_PLLI2SM_DIV_34 * @arg @ref LL_RCC_PLLI2SM_DIV_35 * @arg @ref LL_RCC_PLLI2SM_DIV_36 * @arg @ref LL_RCC_PLLI2SM_DIV_37 * @arg @ref LL_RCC_PLLI2SM_DIV_38 * @arg @ref LL_RCC_PLLI2SM_DIV_39 * @arg @ref LL_RCC_PLLI2SM_DIV_40 * @arg @ref LL_RCC_PLLI2SM_DIV_41 * @arg @ref LL_RCC_PLLI2SM_DIV_42 * @arg @ref LL_RCC_PLLI2SM_DIV_43 * @arg @ref LL_RCC_PLLI2SM_DIV_44 * @arg @ref LL_RCC_PLLI2SM_DIV_45 * @arg @ref LL_RCC_PLLI2SM_DIV_46 * @arg @ref LL_RCC_PLLI2SM_DIV_47 * @arg @ref LL_RCC_PLLI2SM_DIV_48 * @arg @ref LL_RCC_PLLI2SM_DIV_49 * @arg @ref LL_RCC_PLLI2SM_DIV_50 * @arg @ref LL_RCC_PLLI2SM_DIV_51 * @arg @ref LL_RCC_PLLI2SM_DIV_52 * @arg @ref LL_RCC_PLLI2SM_DIV_53 * @arg @ref LL_RCC_PLLI2SM_DIV_54 * @arg @ref LL_RCC_PLLI2SM_DIV_55 * @arg @ref LL_RCC_PLLI2SM_DIV_56 * @arg @ref LL_RCC_PLLI2SM_DIV_57 * @arg @ref LL_RCC_PLLI2SM_DIV_58 * @arg @ref LL_RCC_PLLI2SM_DIV_59 * @arg @ref LL_RCC_PLLI2SM_DIV_60 * @arg @ref LL_RCC_PLLI2SM_DIV_61 * @arg @ref LL_RCC_PLLI2SM_DIV_62 * @arg @ref LL_RCC_PLLI2SM_DIV_63 */ __STATIC_INLINE uint32_t LL_RCC_PLLI2S_GetDivider(void) { #if defined(RCC_PLLI2SCFGR_PLLI2SM) return (uint32_t)(READ_BIT(RCC->PLLI2SCFGR, RCC_PLLI2SCFGR_PLLI2SM)); #else return (uint32_t)(READ_BIT(RCC->PLLCFGR, RCC_PLLCFGR_PLLM)); #endif /* RCC_PLLI2SCFGR_PLLI2SM */ } /** * @brief Get the oscillator used as PLL clock source. * @rmtoll PLLCFGR PLLSRC LL_RCC_PLLI2S_GetMainSource\n * PLLI2SCFGR PLLI2SSRC LL_RCC_PLLI2S_GetMainSource * @retval Returned value can be one of the following values: * @arg @ref LL_RCC_PLLSOURCE_HSI * @arg @ref LL_RCC_PLLSOURCE_HSE * @arg @ref LL_RCC_PLLI2SSOURCE_PIN (*) * * (*) value not defined in all devices. */ __STATIC_INLINE uint32_t LL_RCC_PLLI2S_GetMainSource(void) { #if defined(RCC_PLLI2SCFGR_PLLI2SSRC) register uint32_t pllsrc = READ_BIT(RCC->PLLCFGR, RCC_PLLCFGR_PLLSRC); register uint32_t plli2sssrc0 = READ_BIT(RCC->PLLI2SCFGR, RCC_PLLI2SCFGR_PLLI2SSRC); register uint32_t plli2sssrc1 = READ_BIT(RCC->PLLI2SCFGR, RCC_PLLI2SCFGR_PLLI2SSRC) >> 15U; return (uint32_t)(pllsrc | plli2sssrc0 | plli2sssrc1); #else return (uint32_t)(READ_BIT(RCC->PLLCFGR, RCC_PLLCFGR_PLLSRC)); #endif /* RCC_PLLI2SCFGR_PLLI2SSRC */ } /** * @} */ #endif /* RCC_PLLI2S_SUPPORT */ #if defined(RCC_PLLSAI_SUPPORT) /** @defgroup RCC_LL_EF_PLLSAI PLLSAI * @{ */ /** * @brief Enable PLLSAI * @rmtoll CR PLLSAION LL_RCC_PLLSAI_Enable * @retval None */ __STATIC_INLINE void LL_RCC_PLLSAI_Enable(void) { SET_BIT(RCC->CR, RCC_CR_PLLSAION); } /** * @brief Disable PLLSAI * @rmtoll CR PLLSAION LL_RCC_PLLSAI_Disable * @retval None */ __STATIC_INLINE void LL_RCC_PLLSAI_Disable(void) { CLEAR_BIT(RCC->CR, RCC_CR_PLLSAION); } /** * @brief Check if PLLSAI Ready * @rmtoll CR PLLSAIRDY LL_RCC_PLLSAI_IsReady * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_RCC_PLLSAI_IsReady(void) { return (READ_BIT(RCC->CR, RCC_CR_PLLSAIRDY) == (RCC_CR_PLLSAIRDY)); } /** * @brief Configure PLLSAI used for SAI domain clock * @note PLL Source and PLLM Divider can be written only when PLL, * PLLI2S and PLLSAI(*) are disabled * @note PLLN/PLLQ can be written only when PLLSAI is disabled * @note This can be selected for SAI * @rmtoll PLLCFGR PLLSRC LL_RCC_PLLSAI_ConfigDomain_SAI\n * PLLCFGR PLLM LL_RCC_PLLSAI_ConfigDomain_SAI\n * PLLSAICFGR PLLSAIM LL_RCC_PLLSAI_ConfigDomain_SAI\n * PLLSAICFGR PLLSAIN LL_RCC_PLLSAI_ConfigDomain_SAI\n * PLLSAICFGR PLLSAIQ LL_RCC_PLLSAI_ConfigDomain_SAI\n * DCKCFGR PLLSAIDIVQ LL_RCC_PLLSAI_ConfigDomain_SAI * @param Source This parameter can be one of the following values: * @arg @ref LL_RCC_PLLSOURCE_HSI * @arg @ref LL_RCC_PLLSOURCE_HSE * @param PLLM This parameter can be one of the following values: * @arg @ref LL_RCC_PLLSAIM_DIV_2 * @arg @ref LL_RCC_PLLSAIM_DIV_3 * @arg @ref LL_RCC_PLLSAIM_DIV_4 * @arg @ref LL_RCC_PLLSAIM_DIV_5 * @arg @ref LL_RCC_PLLSAIM_DIV_6 * @arg @ref LL_RCC_PLLSAIM_DIV_7 * @arg @ref LL_RCC_PLLSAIM_DIV_8 * @arg @ref LL_RCC_PLLSAIM_DIV_9 * @arg @ref LL_RCC_PLLSAIM_DIV_10 * @arg @ref LL_RCC_PLLSAIM_DIV_11 * @arg @ref LL_RCC_PLLSAIM_DIV_12 * @arg @ref LL_RCC_PLLSAIM_DIV_13 * @arg @ref LL_RCC_PLLSAIM_DIV_14 * @arg @ref LL_RCC_PLLSAIM_DIV_15 * @arg @ref LL_RCC_PLLSAIM_DIV_16 * @arg @ref LL_RCC_PLLSAIM_DIV_17 * @arg @ref LL_RCC_PLLSAIM_DIV_18 * @arg @ref LL_RCC_PLLSAIM_DIV_19 * @arg @ref LL_RCC_PLLSAIM_DIV_20 * @arg @ref LL_RCC_PLLSAIM_DIV_21 * @arg @ref LL_RCC_PLLSAIM_DIV_22 * @arg @ref LL_RCC_PLLSAIM_DIV_23 * @arg @ref LL_RCC_PLLSAIM_DIV_24 * @arg @ref LL_RCC_PLLSAIM_DIV_25 * @arg @ref LL_RCC_PLLSAIM_DIV_26 * @arg @ref LL_RCC_PLLSAIM_DIV_27 * @arg @ref LL_RCC_PLLSAIM_DIV_28 * @arg @ref LL_RCC_PLLSAIM_DIV_29 * @arg @ref LL_RCC_PLLSAIM_DIV_30 * @arg @ref LL_RCC_PLLSAIM_DIV_31 * @arg @ref LL_RCC_PLLSAIM_DIV_32 * @arg @ref LL_RCC_PLLSAIM_DIV_33 * @arg @ref LL_RCC_PLLSAIM_DIV_34 * @arg @ref LL_RCC_PLLSAIM_DIV_35 * @arg @ref LL_RCC_PLLSAIM_DIV_36 * @arg @ref LL_RCC_PLLSAIM_DIV_37 * @arg @ref LL_RCC_PLLSAIM_DIV_38 * @arg @ref LL_RCC_PLLSAIM_DIV_39 * @arg @ref LL_RCC_PLLSAIM_DIV_40 * @arg @ref LL_RCC_PLLSAIM_DIV_41 * @arg @ref LL_RCC_PLLSAIM_DIV_42 * @arg @ref LL_RCC_PLLSAIM_DIV_43 * @arg @ref LL_RCC_PLLSAIM_DIV_44 * @arg @ref LL_RCC_PLLSAIM_DIV_45 * @arg @ref LL_RCC_PLLSAIM_DIV_46 * @arg @ref LL_RCC_PLLSAIM_DIV_47 * @arg @ref LL_RCC_PLLSAIM_DIV_48 * @arg @ref LL_RCC_PLLSAIM_DIV_49 * @arg @ref LL_RCC_PLLSAIM_DIV_50 * @arg @ref LL_RCC_PLLSAIM_DIV_51 * @arg @ref LL_RCC_PLLSAIM_DIV_52 * @arg @ref LL_RCC_PLLSAIM_DIV_53 * @arg @ref LL_RCC_PLLSAIM_DIV_54 * @arg @ref LL_RCC_PLLSAIM_DIV_55 * @arg @ref LL_RCC_PLLSAIM_DIV_56 * @arg @ref LL_RCC_PLLSAIM_DIV_57 * @arg @ref LL_RCC_PLLSAIM_DIV_58 * @arg @ref LL_RCC_PLLSAIM_DIV_59 * @arg @ref LL_RCC_PLLSAIM_DIV_60 * @arg @ref LL_RCC_PLLSAIM_DIV_61 * @arg @ref LL_RCC_PLLSAIM_DIV_62 * @arg @ref LL_RCC_PLLSAIM_DIV_63 * @param PLLN Between 49/50(*) and 432 * * (*) value not defined in all devices. * @param PLLQ This parameter can be one of the following values: * @arg @ref LL_RCC_PLLSAIQ_DIV_2 * @arg @ref LL_RCC_PLLSAIQ_DIV_3 * @arg @ref LL_RCC_PLLSAIQ_DIV_4 * @arg @ref LL_RCC_PLLSAIQ_DIV_5 * @arg @ref LL_RCC_PLLSAIQ_DIV_6 * @arg @ref LL_RCC_PLLSAIQ_DIV_7 * @arg @ref LL_RCC_PLLSAIQ_DIV_8 * @arg @ref LL_RCC_PLLSAIQ_DIV_9 * @arg @ref LL_RCC_PLLSAIQ_DIV_10 * @arg @ref LL_RCC_PLLSAIQ_DIV_11 * @arg @ref LL_RCC_PLLSAIQ_DIV_12 * @arg @ref LL_RCC_PLLSAIQ_DIV_13 * @arg @ref LL_RCC_PLLSAIQ_DIV_14 * @arg @ref LL_RCC_PLLSAIQ_DIV_15 * @param PLLDIVQ This parameter can be one of the following values: * @arg @ref LL_RCC_PLLSAIDIVQ_DIV_1 * @arg @ref LL_RCC_PLLSAIDIVQ_DIV_2 * @arg @ref LL_RCC_PLLSAIDIVQ_DIV_3 * @arg @ref LL_RCC_PLLSAIDIVQ_DIV_4 * @arg @ref LL_RCC_PLLSAIDIVQ_DIV_5 * @arg @ref LL_RCC_PLLSAIDIVQ_DIV_6 * @arg @ref LL_RCC_PLLSAIDIVQ_DIV_7 * @arg @ref LL_RCC_PLLSAIDIVQ_DIV_8 * @arg @ref LL_RCC_PLLSAIDIVQ_DIV_9 * @arg @ref LL_RCC_PLLSAIDIVQ_DIV_10 * @arg @ref LL_RCC_PLLSAIDIVQ_DIV_11 * @arg @ref LL_RCC_PLLSAIDIVQ_DIV_12 * @arg @ref LL_RCC_PLLSAIDIVQ_DIV_13 * @arg @ref LL_RCC_PLLSAIDIVQ_DIV_14 * @arg @ref LL_RCC_PLLSAIDIVQ_DIV_15 * @arg @ref LL_RCC_PLLSAIDIVQ_DIV_16 * @arg @ref LL_RCC_PLLSAIDIVQ_DIV_17 * @arg @ref LL_RCC_PLLSAIDIVQ_DIV_18 * @arg @ref LL_RCC_PLLSAIDIVQ_DIV_19 * @arg @ref LL_RCC_PLLSAIDIVQ_DIV_20 * @arg @ref LL_RCC_PLLSAIDIVQ_DIV_21 * @arg @ref LL_RCC_PLLSAIDIVQ_DIV_22 * @arg @ref LL_RCC_PLLSAIDIVQ_DIV_23 * @arg @ref LL_RCC_PLLSAIDIVQ_DIV_24 * @arg @ref LL_RCC_PLLSAIDIVQ_DIV_25 * @arg @ref LL_RCC_PLLSAIDIVQ_DIV_26 * @arg @ref LL_RCC_PLLSAIDIVQ_DIV_27 * @arg @ref LL_RCC_PLLSAIDIVQ_DIV_28 * @arg @ref LL_RCC_PLLSAIDIVQ_DIV_29 * @arg @ref LL_RCC_PLLSAIDIVQ_DIV_30 * @arg @ref LL_RCC_PLLSAIDIVQ_DIV_31 * @arg @ref LL_RCC_PLLSAIDIVQ_DIV_32 * @retval None */ __STATIC_INLINE void LL_RCC_PLLSAI_ConfigDomain_SAI(uint32_t Source, uint32_t PLLM, uint32_t PLLN, uint32_t PLLQ, uint32_t PLLDIVQ) { MODIFY_REG(RCC->PLLCFGR, RCC_PLLCFGR_PLLSRC, Source); #if defined(RCC_PLLSAICFGR_PLLSAIM) MODIFY_REG(RCC->PLLSAICFGR, RCC_PLLSAICFGR_PLLSAIM, PLLM); #else MODIFY_REG(RCC->PLLCFGR, RCC_PLLCFGR_PLLM, PLLM); #endif /* RCC_PLLSAICFGR_PLLSAIM */ MODIFY_REG(RCC->PLLSAICFGR, RCC_PLLSAICFGR_PLLSAIN | RCC_PLLSAICFGR_PLLSAIQ, PLLN << RCC_PLLSAICFGR_PLLSAIN_Pos | PLLQ); MODIFY_REG(RCC->DCKCFGR, RCC_DCKCFGR_PLLSAIDIVQ, PLLDIVQ); } #if defined(RCC_PLLSAICFGR_PLLSAIP) /** * @brief Configure PLLSAI used for 48Mhz domain clock * @note PLL Source and PLLM Divider can be written only when PLL, * PLLI2S and PLLSAI(*) are disabled * @note PLLN/PLLP can be written only when PLLSAI is disabled * @note This can be selected for USB, RNG, SDIO * @rmtoll PLLCFGR PLLSRC LL_RCC_PLLSAI_ConfigDomain_48M\n * PLLCFGR PLLM LL_RCC_PLLSAI_ConfigDomain_48M\n * PLLSAICFGR PLLSAIM LL_RCC_PLLSAI_ConfigDomain_48M\n * PLLSAICFGR PLLSAIN LL_RCC_PLLSAI_ConfigDomain_48M\n * PLLSAICFGR PLLSAIP LL_RCC_PLLSAI_ConfigDomain_48M * @param Source This parameter can be one of the following values: * @arg @ref LL_RCC_PLLSOURCE_HSI * @arg @ref LL_RCC_PLLSOURCE_HSE * @param PLLM This parameter can be one of the following values: * @arg @ref LL_RCC_PLLSAIM_DIV_2 * @arg @ref LL_RCC_PLLSAIM_DIV_3 * @arg @ref LL_RCC_PLLSAIM_DIV_4 * @arg @ref LL_RCC_PLLSAIM_DIV_5 * @arg @ref LL_RCC_PLLSAIM_DIV_6 * @arg @ref LL_RCC_PLLSAIM_DIV_7 * @arg @ref LL_RCC_PLLSAIM_DIV_8 * @arg @ref LL_RCC_PLLSAIM_DIV_9 * @arg @ref LL_RCC_PLLSAIM_DIV_10 * @arg @ref LL_RCC_PLLSAIM_DIV_11 * @arg @ref LL_RCC_PLLSAIM_DIV_12 * @arg @ref LL_RCC_PLLSAIM_DIV_13 * @arg @ref LL_RCC_PLLSAIM_DIV_14 * @arg @ref LL_RCC_PLLSAIM_DIV_15 * @arg @ref LL_RCC_PLLSAIM_DIV_16 * @arg @ref LL_RCC_PLLSAIM_DIV_17 * @arg @ref LL_RCC_PLLSAIM_DIV_18 * @arg @ref LL_RCC_PLLSAIM_DIV_19 * @arg @ref LL_RCC_PLLSAIM_DIV_20 * @arg @ref LL_RCC_PLLSAIM_DIV_21 * @arg @ref LL_RCC_PLLSAIM_DIV_22 * @arg @ref LL_RCC_PLLSAIM_DIV_23 * @arg @ref LL_RCC_PLLSAIM_DIV_24 * @arg @ref LL_RCC_PLLSAIM_DIV_25 * @arg @ref LL_RCC_PLLSAIM_DIV_26 * @arg @ref LL_RCC_PLLSAIM_DIV_27 * @arg @ref LL_RCC_PLLSAIM_DIV_28 * @arg @ref LL_RCC_PLLSAIM_DIV_29 * @arg @ref LL_RCC_PLLSAIM_DIV_30 * @arg @ref LL_RCC_PLLSAIM_DIV_31 * @arg @ref LL_RCC_PLLSAIM_DIV_32 * @arg @ref LL_RCC_PLLSAIM_DIV_33 * @arg @ref LL_RCC_PLLSAIM_DIV_34 * @arg @ref LL_RCC_PLLSAIM_DIV_35 * @arg @ref LL_RCC_PLLSAIM_DIV_36 * @arg @ref LL_RCC_PLLSAIM_DIV_37 * @arg @ref LL_RCC_PLLSAIM_DIV_38 * @arg @ref LL_RCC_PLLSAIM_DIV_39 * @arg @ref LL_RCC_PLLSAIM_DIV_40 * @arg @ref LL_RCC_PLLSAIM_DIV_41 * @arg @ref LL_RCC_PLLSAIM_DIV_42 * @arg @ref LL_RCC_PLLSAIM_DIV_43 * @arg @ref LL_RCC_PLLSAIM_DIV_44 * @arg @ref LL_RCC_PLLSAIM_DIV_45 * @arg @ref LL_RCC_PLLSAIM_DIV_46 * @arg @ref LL_RCC_PLLSAIM_DIV_47 * @arg @ref LL_RCC_PLLSAIM_DIV_48 * @arg @ref LL_RCC_PLLSAIM_DIV_49 * @arg @ref LL_RCC_PLLSAIM_DIV_50 * @arg @ref LL_RCC_PLLSAIM_DIV_51 * @arg @ref LL_RCC_PLLSAIM_DIV_52 * @arg @ref LL_RCC_PLLSAIM_DIV_53 * @arg @ref LL_RCC_PLLSAIM_DIV_54 * @arg @ref LL_RCC_PLLSAIM_DIV_55 * @arg @ref LL_RCC_PLLSAIM_DIV_56 * @arg @ref LL_RCC_PLLSAIM_DIV_57 * @arg @ref LL_RCC_PLLSAIM_DIV_58 * @arg @ref LL_RCC_PLLSAIM_DIV_59 * @arg @ref LL_RCC_PLLSAIM_DIV_60 * @arg @ref LL_RCC_PLLSAIM_DIV_61 * @arg @ref LL_RCC_PLLSAIM_DIV_62 * @arg @ref LL_RCC_PLLSAIM_DIV_63 * @param PLLN Between 50 and 432 * @param PLLP This parameter can be one of the following values: * @arg @ref LL_RCC_PLLSAIP_DIV_2 * @arg @ref LL_RCC_PLLSAIP_DIV_4 * @arg @ref LL_RCC_PLLSAIP_DIV_6 * @arg @ref LL_RCC_PLLSAIP_DIV_8 * @retval None */ __STATIC_INLINE void LL_RCC_PLLSAI_ConfigDomain_48M(uint32_t Source, uint32_t PLLM, uint32_t PLLN, uint32_t PLLP) { MODIFY_REG(RCC->PLLCFGR, RCC_PLLCFGR_PLLSRC, Source); #if defined(RCC_PLLSAICFGR_PLLSAIM) MODIFY_REG(RCC->PLLSAICFGR, RCC_PLLSAICFGR_PLLSAIM, PLLM); #else MODIFY_REG(RCC->PLLCFGR, RCC_PLLCFGR_PLLM, PLLM); #endif /* RCC_PLLSAICFGR_PLLSAIM */ MODIFY_REG(RCC->PLLSAICFGR, RCC_PLLSAICFGR_PLLSAIN | RCC_PLLSAICFGR_PLLSAIP, PLLN << RCC_PLLSAICFGR_PLLSAIN_Pos | PLLP); } #endif /* RCC_PLLSAICFGR_PLLSAIP */ #if defined(LTDC) /** * @brief Configure PLLSAI used for LTDC domain clock * @note PLL Source and PLLM Divider can be written only when PLL, * PLLI2S and PLLSAI(*) are disabled * @note PLLN/PLLR can be written only when PLLSAI is disabled * @note This can be selected for LTDC * @rmtoll PLLCFGR PLLSRC LL_RCC_PLLSAI_ConfigDomain_LTDC\n * PLLCFGR PLLM LL_RCC_PLLSAI_ConfigDomain_LTDC\n * PLLSAICFGR PLLSAIN LL_RCC_PLLSAI_ConfigDomain_LTDC\n * PLLSAICFGR PLLSAIR LL_RCC_PLLSAI_ConfigDomain_LTDC\n * DCKCFGR PLLSAIDIVR LL_RCC_PLLSAI_ConfigDomain_LTDC * @param Source This parameter can be one of the following values: * @arg @ref LL_RCC_PLLSOURCE_HSI * @arg @ref LL_RCC_PLLSOURCE_HSE * @param PLLM This parameter can be one of the following values: * @arg @ref LL_RCC_PLLSAIM_DIV_2 * @arg @ref LL_RCC_PLLSAIM_DIV_3 * @arg @ref LL_RCC_PLLSAIM_DIV_4 * @arg @ref LL_RCC_PLLSAIM_DIV_5 * @arg @ref LL_RCC_PLLSAIM_DIV_6 * @arg @ref LL_RCC_PLLSAIM_DIV_7 * @arg @ref LL_RCC_PLLSAIM_DIV_8 * @arg @ref LL_RCC_PLLSAIM_DIV_9 * @arg @ref LL_RCC_PLLSAIM_DIV_10 * @arg @ref LL_RCC_PLLSAIM_DIV_11 * @arg @ref LL_RCC_PLLSAIM_DIV_12 * @arg @ref LL_RCC_PLLSAIM_DIV_13 * @arg @ref LL_RCC_PLLSAIM_DIV_14 * @arg @ref LL_RCC_PLLSAIM_DIV_15 * @arg @ref LL_RCC_PLLSAIM_DIV_16 * @arg @ref LL_RCC_PLLSAIM_DIV_17 * @arg @ref LL_RCC_PLLSAIM_DIV_18 * @arg @ref LL_RCC_PLLSAIM_DIV_19 * @arg @ref LL_RCC_PLLSAIM_DIV_20 * @arg @ref LL_RCC_PLLSAIM_DIV_21 * @arg @ref LL_RCC_PLLSAIM_DIV_22 * @arg @ref LL_RCC_PLLSAIM_DIV_23 * @arg @ref LL_RCC_PLLSAIM_DIV_24 * @arg @ref LL_RCC_PLLSAIM_DIV_25 * @arg @ref LL_RCC_PLLSAIM_DIV_26 * @arg @ref LL_RCC_PLLSAIM_DIV_27 * @arg @ref LL_RCC_PLLSAIM_DIV_28 * @arg @ref LL_RCC_PLLSAIM_DIV_29 * @arg @ref LL_RCC_PLLSAIM_DIV_30 * @arg @ref LL_RCC_PLLSAIM_DIV_31 * @arg @ref LL_RCC_PLLSAIM_DIV_32 * @arg @ref LL_RCC_PLLSAIM_DIV_33 * @arg @ref LL_RCC_PLLSAIM_DIV_34 * @arg @ref LL_RCC_PLLSAIM_DIV_35 * @arg @ref LL_RCC_PLLSAIM_DIV_36 * @arg @ref LL_RCC_PLLSAIM_DIV_37 * @arg @ref LL_RCC_PLLSAIM_DIV_38 * @arg @ref LL_RCC_PLLSAIM_DIV_39 * @arg @ref LL_RCC_PLLSAIM_DIV_40 * @arg @ref LL_RCC_PLLSAIM_DIV_41 * @arg @ref LL_RCC_PLLSAIM_DIV_42 * @arg @ref LL_RCC_PLLSAIM_DIV_43 * @arg @ref LL_RCC_PLLSAIM_DIV_44 * @arg @ref LL_RCC_PLLSAIM_DIV_45 * @arg @ref LL_RCC_PLLSAIM_DIV_46 * @arg @ref LL_RCC_PLLSAIM_DIV_47 * @arg @ref LL_RCC_PLLSAIM_DIV_48 * @arg @ref LL_RCC_PLLSAIM_DIV_49 * @arg @ref LL_RCC_PLLSAIM_DIV_50 * @arg @ref LL_RCC_PLLSAIM_DIV_51 * @arg @ref LL_RCC_PLLSAIM_DIV_52 * @arg @ref LL_RCC_PLLSAIM_DIV_53 * @arg @ref LL_RCC_PLLSAIM_DIV_54 * @arg @ref LL_RCC_PLLSAIM_DIV_55 * @arg @ref LL_RCC_PLLSAIM_DIV_56 * @arg @ref LL_RCC_PLLSAIM_DIV_57 * @arg @ref LL_RCC_PLLSAIM_DIV_58 * @arg @ref LL_RCC_PLLSAIM_DIV_59 * @arg @ref LL_RCC_PLLSAIM_DIV_60 * @arg @ref LL_RCC_PLLSAIM_DIV_61 * @arg @ref LL_RCC_PLLSAIM_DIV_62 * @arg @ref LL_RCC_PLLSAIM_DIV_63 * @param PLLN Between 49/50(*) and 432 * * (*) value not defined in all devices. * @param PLLR This parameter can be one of the following values: * @arg @ref LL_RCC_PLLSAIR_DIV_2 * @arg @ref LL_RCC_PLLSAIR_DIV_3 * @arg @ref LL_RCC_PLLSAIR_DIV_4 * @arg @ref LL_RCC_PLLSAIR_DIV_5 * @arg @ref LL_RCC_PLLSAIR_DIV_6 * @arg @ref LL_RCC_PLLSAIR_DIV_7 * @param PLLDIVR This parameter can be one of the following values: * @arg @ref LL_RCC_PLLSAIDIVR_DIV_2 * @arg @ref LL_RCC_PLLSAIDIVR_DIV_4 * @arg @ref LL_RCC_PLLSAIDIVR_DIV_8 * @arg @ref LL_RCC_PLLSAIDIVR_DIV_16 * @retval None */ __STATIC_INLINE void LL_RCC_PLLSAI_ConfigDomain_LTDC(uint32_t Source, uint32_t PLLM, uint32_t PLLN, uint32_t PLLR, uint32_t PLLDIVR) { MODIFY_REG(RCC->PLLCFGR, RCC_PLLCFGR_PLLSRC | RCC_PLLCFGR_PLLM, Source | PLLM); MODIFY_REG(RCC->PLLSAICFGR, RCC_PLLSAICFGR_PLLSAIN | RCC_PLLSAICFGR_PLLSAIR, PLLN << RCC_PLLSAICFGR_PLLSAIN_Pos | PLLR); MODIFY_REG(RCC->DCKCFGR, RCC_DCKCFGR_PLLSAIDIVR, PLLDIVR); } #endif /* LTDC */ /** * @brief Get division factor for PLLSAI input clock * @rmtoll PLLCFGR PLLM LL_RCC_PLLSAI_GetDivider\n * PLLSAICFGR PLLSAIM LL_RCC_PLLSAI_GetDivider * @retval Returned value can be one of the following values: * @arg @ref LL_RCC_PLLSAIM_DIV_2 * @arg @ref LL_RCC_PLLSAIM_DIV_3 * @arg @ref LL_RCC_PLLSAIM_DIV_4 * @arg @ref LL_RCC_PLLSAIM_DIV_5 * @arg @ref LL_RCC_PLLSAIM_DIV_6 * @arg @ref LL_RCC_PLLSAIM_DIV_7 * @arg @ref LL_RCC_PLLSAIM_DIV_8 * @arg @ref LL_RCC_PLLSAIM_DIV_9 * @arg @ref LL_RCC_PLLSAIM_DIV_10 * @arg @ref LL_RCC_PLLSAIM_DIV_11 * @arg @ref LL_RCC_PLLSAIM_DIV_12 * @arg @ref LL_RCC_PLLSAIM_DIV_13 * @arg @ref LL_RCC_PLLSAIM_DIV_14 * @arg @ref LL_RCC_PLLSAIM_DIV_15 * @arg @ref LL_RCC_PLLSAIM_DIV_16 * @arg @ref LL_RCC_PLLSAIM_DIV_17 * @arg @ref LL_RCC_PLLSAIM_DIV_18 * @arg @ref LL_RCC_PLLSAIM_DIV_19 * @arg @ref LL_RCC_PLLSAIM_DIV_20 * @arg @ref LL_RCC_PLLSAIM_DIV_21 * @arg @ref LL_RCC_PLLSAIM_DIV_22 * @arg @ref LL_RCC_PLLSAIM_DIV_23 * @arg @ref LL_RCC_PLLSAIM_DIV_24 * @arg @ref LL_RCC_PLLSAIM_DIV_25 * @arg @ref LL_RCC_PLLSAIM_DIV_26 * @arg @ref LL_RCC_PLLSAIM_DIV_27 * @arg @ref LL_RCC_PLLSAIM_DIV_28 * @arg @ref LL_RCC_PLLSAIM_DIV_29 * @arg @ref LL_RCC_PLLSAIM_DIV_30 * @arg @ref LL_RCC_PLLSAIM_DIV_31 * @arg @ref LL_RCC_PLLSAIM_DIV_32 * @arg @ref LL_RCC_PLLSAIM_DIV_33 * @arg @ref LL_RCC_PLLSAIM_DIV_34 * @arg @ref LL_RCC_PLLSAIM_DIV_35 * @arg @ref LL_RCC_PLLSAIM_DIV_36 * @arg @ref LL_RCC_PLLSAIM_DIV_37 * @arg @ref LL_RCC_PLLSAIM_DIV_38 * @arg @ref LL_RCC_PLLSAIM_DIV_39 * @arg @ref LL_RCC_PLLSAIM_DIV_40 * @arg @ref LL_RCC_PLLSAIM_DIV_41 * @arg @ref LL_RCC_PLLSAIM_DIV_42 * @arg @ref LL_RCC_PLLSAIM_DIV_43 * @arg @ref LL_RCC_PLLSAIM_DIV_44 * @arg @ref LL_RCC_PLLSAIM_DIV_45 * @arg @ref LL_RCC_PLLSAIM_DIV_46 * @arg @ref LL_RCC_PLLSAIM_DIV_47 * @arg @ref LL_RCC_PLLSAIM_DIV_48 * @arg @ref LL_RCC_PLLSAIM_DIV_49 * @arg @ref LL_RCC_PLLSAIM_DIV_50 * @arg @ref LL_RCC_PLLSAIM_DIV_51 * @arg @ref LL_RCC_PLLSAIM_DIV_52 * @arg @ref LL_RCC_PLLSAIM_DIV_53 * @arg @ref LL_RCC_PLLSAIM_DIV_54 * @arg @ref LL_RCC_PLLSAIM_DIV_55 * @arg @ref LL_RCC_PLLSAIM_DIV_56 * @arg @ref LL_RCC_PLLSAIM_DIV_57 * @arg @ref LL_RCC_PLLSAIM_DIV_58 * @arg @ref LL_RCC_PLLSAIM_DIV_59 * @arg @ref LL_RCC_PLLSAIM_DIV_60 * @arg @ref LL_RCC_PLLSAIM_DIV_61 * @arg @ref LL_RCC_PLLSAIM_DIV_62 * @arg @ref LL_RCC_PLLSAIM_DIV_63 */ __STATIC_INLINE uint32_t LL_RCC_PLLSAI_GetDivider(void) { #if defined(RCC_PLLSAICFGR_PLLSAIM) return (uint32_t)(READ_BIT(RCC->PLLSAICFGR, RCC_PLLSAICFGR_PLLSAIM)); #else return (uint32_t)(READ_BIT(RCC->PLLCFGR, RCC_PLLCFGR_PLLM)); #endif /* RCC_PLLSAICFGR_PLLSAIM */ } /** * @brief Get SAIPLL multiplication factor for VCO * @rmtoll PLLSAICFGR PLLSAIN LL_RCC_PLLSAI_GetN * @retval Between 49/50(*) and 432 * * (*) value not defined in all devices. */ __STATIC_INLINE uint32_t LL_RCC_PLLSAI_GetN(void) { return (uint32_t)(READ_BIT(RCC->PLLSAICFGR, RCC_PLLSAICFGR_PLLSAIN) >> RCC_PLLSAICFGR_PLLSAIN_Pos); } /** * @brief Get SAIPLL division factor for PLLSAIQ * @rmtoll PLLSAICFGR PLLSAIQ LL_RCC_PLLSAI_GetQ * @retval Returned value can be one of the following values: * @arg @ref LL_RCC_PLLSAIQ_DIV_2 * @arg @ref LL_RCC_PLLSAIQ_DIV_3 * @arg @ref LL_RCC_PLLSAIQ_DIV_4 * @arg @ref LL_RCC_PLLSAIQ_DIV_5 * @arg @ref LL_RCC_PLLSAIQ_DIV_6 * @arg @ref LL_RCC_PLLSAIQ_DIV_7 * @arg @ref LL_RCC_PLLSAIQ_DIV_8 * @arg @ref LL_RCC_PLLSAIQ_DIV_9 * @arg @ref LL_RCC_PLLSAIQ_DIV_10 * @arg @ref LL_RCC_PLLSAIQ_DIV_11 * @arg @ref LL_RCC_PLLSAIQ_DIV_12 * @arg @ref LL_RCC_PLLSAIQ_DIV_13 * @arg @ref LL_RCC_PLLSAIQ_DIV_14 * @arg @ref LL_RCC_PLLSAIQ_DIV_15 */ __STATIC_INLINE uint32_t LL_RCC_PLLSAI_GetQ(void) { return (uint32_t)(READ_BIT(RCC->PLLSAICFGR, RCC_PLLSAICFGR_PLLSAIQ)); } #if defined(RCC_PLLSAICFGR_PLLSAIR) /** * @brief Get SAIPLL division factor for PLLSAIR * @note used for PLLSAICLK (SAI clock) * @rmtoll PLLSAICFGR PLLSAIR LL_RCC_PLLSAI_GetR * @retval Returned value can be one of the following values: * @arg @ref LL_RCC_PLLSAIR_DIV_2 * @arg @ref LL_RCC_PLLSAIR_DIV_3 * @arg @ref LL_RCC_PLLSAIR_DIV_4 * @arg @ref LL_RCC_PLLSAIR_DIV_5 * @arg @ref LL_RCC_PLLSAIR_DIV_6 * @arg @ref LL_RCC_PLLSAIR_DIV_7 */ __STATIC_INLINE uint32_t LL_RCC_PLLSAI_GetR(void) { return (uint32_t)(READ_BIT(RCC->PLLSAICFGR, RCC_PLLSAICFGR_PLLSAIR)); } #endif /* RCC_PLLSAICFGR_PLLSAIR */ #if defined(RCC_PLLSAICFGR_PLLSAIP) /** * @brief Get SAIPLL division factor for PLLSAIP * @note used for PLL48MCLK (48M domain clock) * @rmtoll PLLSAICFGR PLLSAIP LL_RCC_PLLSAI_GetP * @retval Returned value can be one of the following values: * @arg @ref LL_RCC_PLLSAIP_DIV_2 * @arg @ref LL_RCC_PLLSAIP_DIV_4 * @arg @ref LL_RCC_PLLSAIP_DIV_6 * @arg @ref LL_RCC_PLLSAIP_DIV_8 */ __STATIC_INLINE uint32_t LL_RCC_PLLSAI_GetP(void) { return (uint32_t)(READ_BIT(RCC->PLLSAICFGR, RCC_PLLSAICFGR_PLLSAIP)); } #endif /* RCC_PLLSAICFGR_PLLSAIP */ /** * @brief Get SAIPLL division factor for PLLSAIDIVQ * @note used PLLSAICLK selected (SAI clock) * @rmtoll DCKCFGR PLLSAIDIVQ LL_RCC_PLLSAI_GetDIVQ * @retval Returned value can be one of the following values: * @arg @ref LL_RCC_PLLSAIDIVQ_DIV_1 * @arg @ref LL_RCC_PLLSAIDIVQ_DIV_2 * @arg @ref LL_RCC_PLLSAIDIVQ_DIV_3 * @arg @ref LL_RCC_PLLSAIDIVQ_DIV_4 * @arg @ref LL_RCC_PLLSAIDIVQ_DIV_5 * @arg @ref LL_RCC_PLLSAIDIVQ_DIV_6 * @arg @ref LL_RCC_PLLSAIDIVQ_DIV_7 * @arg @ref LL_RCC_PLLSAIDIVQ_DIV_8 * @arg @ref LL_RCC_PLLSAIDIVQ_DIV_9 * @arg @ref LL_RCC_PLLSAIDIVQ_DIV_10 * @arg @ref LL_RCC_PLLSAIDIVQ_DIV_11 * @arg @ref LL_RCC_PLLSAIDIVQ_DIV_12 * @arg @ref LL_RCC_PLLSAIDIVQ_DIV_13 * @arg @ref LL_RCC_PLLSAIDIVQ_DIV_14 * @arg @ref LL_RCC_PLLSAIDIVQ_DIV_15 * @arg @ref LL_RCC_PLLSAIDIVQ_DIV_16 * @arg @ref LL_RCC_PLLSAIDIVQ_DIV_17 * @arg @ref LL_RCC_PLLSAIDIVQ_DIV_18 * @arg @ref LL_RCC_PLLSAIDIVQ_DIV_19 * @arg @ref LL_RCC_PLLSAIDIVQ_DIV_20 * @arg @ref LL_RCC_PLLSAIDIVQ_DIV_21 * @arg @ref LL_RCC_PLLSAIDIVQ_DIV_22 * @arg @ref LL_RCC_PLLSAIDIVQ_DIV_23 * @arg @ref LL_RCC_PLLSAIDIVQ_DIV_24 * @arg @ref LL_RCC_PLLSAIDIVQ_DIV_25 * @arg @ref LL_RCC_PLLSAIDIVQ_DIV_26 * @arg @ref LL_RCC_PLLSAIDIVQ_DIV_27 * @arg @ref LL_RCC_PLLSAIDIVQ_DIV_28 * @arg @ref LL_RCC_PLLSAIDIVQ_DIV_29 * @arg @ref LL_RCC_PLLSAIDIVQ_DIV_30 * @arg @ref LL_RCC_PLLSAIDIVQ_DIV_31 * @arg @ref LL_RCC_PLLSAIDIVQ_DIV_32 */ __STATIC_INLINE uint32_t LL_RCC_PLLSAI_GetDIVQ(void) { return (uint32_t)(READ_BIT(RCC->DCKCFGR, RCC_DCKCFGR_PLLSAIDIVQ)); } #if defined(RCC_DCKCFGR_PLLSAIDIVR) /** * @brief Get SAIPLL division factor for PLLSAIDIVR * @note used for LTDC domain clock * @rmtoll DCKCFGR PLLSAIDIVR LL_RCC_PLLSAI_GetDIVR * @retval Returned value can be one of the following values: * @arg @ref LL_RCC_PLLSAIDIVR_DIV_2 * @arg @ref LL_RCC_PLLSAIDIVR_DIV_4 * @arg @ref LL_RCC_PLLSAIDIVR_DIV_8 * @arg @ref LL_RCC_PLLSAIDIVR_DIV_16 */ __STATIC_INLINE uint32_t LL_RCC_PLLSAI_GetDIVR(void) { return (uint32_t)(READ_BIT(RCC->DCKCFGR, RCC_DCKCFGR_PLLSAIDIVR)); } #endif /* RCC_DCKCFGR_PLLSAIDIVR */ /** * @} */ #endif /* RCC_PLLSAI_SUPPORT */ /** @defgroup RCC_LL_EF_FLAG_Management FLAG Management * @{ */ /** * @brief Clear LSI ready interrupt flag * @rmtoll CIR LSIRDYC LL_RCC_ClearFlag_LSIRDY * @retval None */ __STATIC_INLINE void LL_RCC_ClearFlag_LSIRDY(void) { SET_BIT(RCC->CIR, RCC_CIR_LSIRDYC); } /** * @brief Clear LSE ready interrupt flag * @rmtoll CIR LSERDYC LL_RCC_ClearFlag_LSERDY * @retval None */ __STATIC_INLINE void LL_RCC_ClearFlag_LSERDY(void) { SET_BIT(RCC->CIR, RCC_CIR_LSERDYC); } /** * @brief Clear HSI ready interrupt flag * @rmtoll CIR HSIRDYC LL_RCC_ClearFlag_HSIRDY * @retval None */ __STATIC_INLINE void LL_RCC_ClearFlag_HSIRDY(void) { SET_BIT(RCC->CIR, RCC_CIR_HSIRDYC); } /** * @brief Clear HSE ready interrupt flag * @rmtoll CIR HSERDYC LL_RCC_ClearFlag_HSERDY * @retval None */ __STATIC_INLINE void LL_RCC_ClearFlag_HSERDY(void) { SET_BIT(RCC->CIR, RCC_CIR_HSERDYC); } /** * @brief Clear PLL ready interrupt flag * @rmtoll CIR PLLRDYC LL_RCC_ClearFlag_PLLRDY * @retval None */ __STATIC_INLINE void LL_RCC_ClearFlag_PLLRDY(void) { SET_BIT(RCC->CIR, RCC_CIR_PLLRDYC); } #if defined(RCC_PLLI2S_SUPPORT) /** * @brief Clear PLLI2S ready interrupt flag * @rmtoll CIR PLLI2SRDYC LL_RCC_ClearFlag_PLLI2SRDY * @retval None */ __STATIC_INLINE void LL_RCC_ClearFlag_PLLI2SRDY(void) { SET_BIT(RCC->CIR, RCC_CIR_PLLI2SRDYC); } #endif /* RCC_PLLI2S_SUPPORT */ #if defined(RCC_PLLSAI_SUPPORT) /** * @brief Clear PLLSAI ready interrupt flag * @rmtoll CIR PLLSAIRDYC LL_RCC_ClearFlag_PLLSAIRDY * @retval None */ __STATIC_INLINE void LL_RCC_ClearFlag_PLLSAIRDY(void) { SET_BIT(RCC->CIR, RCC_CIR_PLLSAIRDYC); } #endif /* RCC_PLLSAI_SUPPORT */ /** * @brief Clear Clock security system interrupt flag * @rmtoll CIR CSSC LL_RCC_ClearFlag_HSECSS * @retval None */ __STATIC_INLINE void LL_RCC_ClearFlag_HSECSS(void) { SET_BIT(RCC->CIR, RCC_CIR_CSSC); } /** * @brief Check if LSI ready interrupt occurred or not * @rmtoll CIR LSIRDYF LL_RCC_IsActiveFlag_LSIRDY * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_RCC_IsActiveFlag_LSIRDY(void) { return (READ_BIT(RCC->CIR, RCC_CIR_LSIRDYF) == (RCC_CIR_LSIRDYF)); } /** * @brief Check if LSE ready interrupt occurred or not * @rmtoll CIR LSERDYF LL_RCC_IsActiveFlag_LSERDY * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_RCC_IsActiveFlag_LSERDY(void) { return (READ_BIT(RCC->CIR, RCC_CIR_LSERDYF) == (RCC_CIR_LSERDYF)); } /** * @brief Check if HSI ready interrupt occurred or not * @rmtoll CIR HSIRDYF LL_RCC_IsActiveFlag_HSIRDY * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_RCC_IsActiveFlag_HSIRDY(void) { return (READ_BIT(RCC->CIR, RCC_CIR_HSIRDYF) == (RCC_CIR_HSIRDYF)); } /** * @brief Check if HSE ready interrupt occurred or not * @rmtoll CIR HSERDYF LL_RCC_IsActiveFlag_HSERDY * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_RCC_IsActiveFlag_HSERDY(void) { return (READ_BIT(RCC->CIR, RCC_CIR_HSERDYF) == (RCC_CIR_HSERDYF)); } /** * @brief Check if PLL ready interrupt occurred or not * @rmtoll CIR PLLRDYF LL_RCC_IsActiveFlag_PLLRDY * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_RCC_IsActiveFlag_PLLRDY(void) { return (READ_BIT(RCC->CIR, RCC_CIR_PLLRDYF) == (RCC_CIR_PLLRDYF)); } #if defined(RCC_PLLI2S_SUPPORT) /** * @brief Check if PLLI2S ready interrupt occurred or not * @rmtoll CIR PLLI2SRDYF LL_RCC_IsActiveFlag_PLLI2SRDY * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_RCC_IsActiveFlag_PLLI2SRDY(void) { return (READ_BIT(RCC->CIR, RCC_CIR_PLLI2SRDYF) == (RCC_CIR_PLLI2SRDYF)); } #endif /* RCC_PLLI2S_SUPPORT */ #if defined(RCC_PLLSAI_SUPPORT) /** * @brief Check if PLLSAI ready interrupt occurred or not * @rmtoll CIR PLLSAIRDYF LL_RCC_IsActiveFlag_PLLSAIRDY * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_RCC_IsActiveFlag_PLLSAIRDY(void) { return (READ_BIT(RCC->CIR, RCC_CIR_PLLSAIRDYF) == (RCC_CIR_PLLSAIRDYF)); } #endif /* RCC_PLLSAI_SUPPORT */ /** * @brief Check if Clock security system interrupt occurred or not * @rmtoll CIR CSSF LL_RCC_IsActiveFlag_HSECSS * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_RCC_IsActiveFlag_HSECSS(void) { return (READ_BIT(RCC->CIR, RCC_CIR_CSSF) == (RCC_CIR_CSSF)); } /** * @brief Check if RCC flag Independent Watchdog reset is set or not. * @rmtoll CSR IWDGRSTF LL_RCC_IsActiveFlag_IWDGRST * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_RCC_IsActiveFlag_IWDGRST(void) { return (READ_BIT(RCC->CSR, RCC_CSR_IWDGRSTF) == (RCC_CSR_IWDGRSTF)); } /** * @brief Check if RCC flag Low Power reset is set or not. * @rmtoll CSR LPWRRSTF LL_RCC_IsActiveFlag_LPWRRST * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_RCC_IsActiveFlag_LPWRRST(void) { return (READ_BIT(RCC->CSR, RCC_CSR_LPWRRSTF) == (RCC_CSR_LPWRRSTF)); } /** * @brief Check if RCC flag Pin reset is set or not. * @rmtoll CSR PINRSTF LL_RCC_IsActiveFlag_PINRST * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_RCC_IsActiveFlag_PINRST(void) { return (READ_BIT(RCC->CSR, RCC_CSR_PINRSTF) == (RCC_CSR_PINRSTF)); } /** * @brief Check if RCC flag POR/PDR reset is set or not. * @rmtoll CSR PORRSTF LL_RCC_IsActiveFlag_PORRST * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_RCC_IsActiveFlag_PORRST(void) { return (READ_BIT(RCC->CSR, RCC_CSR_PORRSTF) == (RCC_CSR_PORRSTF)); } /** * @brief Check if RCC flag Software reset is set or not. * @rmtoll CSR SFTRSTF LL_RCC_IsActiveFlag_SFTRST * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_RCC_IsActiveFlag_SFTRST(void) { return (READ_BIT(RCC->CSR, RCC_CSR_SFTRSTF) == (RCC_CSR_SFTRSTF)); } /** * @brief Check if RCC flag Window Watchdog reset is set or not. * @rmtoll CSR WWDGRSTF LL_RCC_IsActiveFlag_WWDGRST * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_RCC_IsActiveFlag_WWDGRST(void) { return (READ_BIT(RCC->CSR, RCC_CSR_WWDGRSTF) == (RCC_CSR_WWDGRSTF)); } #if defined(RCC_CSR_BORRSTF) /** * @brief Check if RCC flag BOR reset is set or not. * @rmtoll CSR BORRSTF LL_RCC_IsActiveFlag_BORRST * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_RCC_IsActiveFlag_BORRST(void) { return (READ_BIT(RCC->CSR, RCC_CSR_BORRSTF) == (RCC_CSR_BORRSTF)); } #endif /* RCC_CSR_BORRSTF */ /** * @brief Set RMVF bit to clear the reset flags. * @rmtoll CSR RMVF LL_RCC_ClearResetFlags * @retval None */ __STATIC_INLINE void LL_RCC_ClearResetFlags(void) { SET_BIT(RCC->CSR, RCC_CSR_RMVF); } /** * @} */ /** @defgroup RCC_LL_EF_IT_Management IT Management * @{ */ /** * @brief Enable LSI ready interrupt * @rmtoll CIR LSIRDYIE LL_RCC_EnableIT_LSIRDY * @retval None */ __STATIC_INLINE void LL_RCC_EnableIT_LSIRDY(void) { SET_BIT(RCC->CIR, RCC_CIR_LSIRDYIE); } /** * @brief Enable LSE ready interrupt * @rmtoll CIR LSERDYIE LL_RCC_EnableIT_LSERDY * @retval None */ __STATIC_INLINE void LL_RCC_EnableIT_LSERDY(void) { SET_BIT(RCC->CIR, RCC_CIR_LSERDYIE); } /** * @brief Enable HSI ready interrupt * @rmtoll CIR HSIRDYIE LL_RCC_EnableIT_HSIRDY * @retval None */ __STATIC_INLINE void LL_RCC_EnableIT_HSIRDY(void) { SET_BIT(RCC->CIR, RCC_CIR_HSIRDYIE); } /** * @brief Enable HSE ready interrupt * @rmtoll CIR HSERDYIE LL_RCC_EnableIT_HSERDY * @retval None */ __STATIC_INLINE void LL_RCC_EnableIT_HSERDY(void) { SET_BIT(RCC->CIR, RCC_CIR_HSERDYIE); } /** * @brief Enable PLL ready interrupt * @rmtoll CIR PLLRDYIE LL_RCC_EnableIT_PLLRDY * @retval None */ __STATIC_INLINE void LL_RCC_EnableIT_PLLRDY(void) { SET_BIT(RCC->CIR, RCC_CIR_PLLRDYIE); } #if defined(RCC_PLLI2S_SUPPORT) /** * @brief Enable PLLI2S ready interrupt * @rmtoll CIR PLLI2SRDYIE LL_RCC_EnableIT_PLLI2SRDY * @retval None */ __STATIC_INLINE void LL_RCC_EnableIT_PLLI2SRDY(void) { SET_BIT(RCC->CIR, RCC_CIR_PLLI2SRDYIE); } #endif /* RCC_PLLI2S_SUPPORT */ #if defined(RCC_PLLSAI_SUPPORT) /** * @brief Enable PLLSAI ready interrupt * @rmtoll CIR PLLSAIRDYIE LL_RCC_EnableIT_PLLSAIRDY * @retval None */ __STATIC_INLINE void LL_RCC_EnableIT_PLLSAIRDY(void) { SET_BIT(RCC->CIR, RCC_CIR_PLLSAIRDYIE); } #endif /* RCC_PLLSAI_SUPPORT */ /** * @brief Disable LSI ready interrupt * @rmtoll CIR LSIRDYIE LL_RCC_DisableIT_LSIRDY * @retval None */ __STATIC_INLINE void LL_RCC_DisableIT_LSIRDY(void) { CLEAR_BIT(RCC->CIR, RCC_CIR_LSIRDYIE); } /** * @brief Disable LSE ready interrupt * @rmtoll CIR LSERDYIE LL_RCC_DisableIT_LSERDY * @retval None */ __STATIC_INLINE void LL_RCC_DisableIT_LSERDY(void) { CLEAR_BIT(RCC->CIR, RCC_CIR_LSERDYIE); } /** * @brief Disable HSI ready interrupt * @rmtoll CIR HSIRDYIE LL_RCC_DisableIT_HSIRDY * @retval None */ __STATIC_INLINE void LL_RCC_DisableIT_HSIRDY(void) { CLEAR_BIT(RCC->CIR, RCC_CIR_HSIRDYIE); } /** * @brief Disable HSE ready interrupt * @rmtoll CIR HSERDYIE LL_RCC_DisableIT_HSERDY * @retval None */ __STATIC_INLINE void LL_RCC_DisableIT_HSERDY(void) { CLEAR_BIT(RCC->CIR, RCC_CIR_HSERDYIE); } /** * @brief Disable PLL ready interrupt * @rmtoll CIR PLLRDYIE LL_RCC_DisableIT_PLLRDY * @retval None */ __STATIC_INLINE void LL_RCC_DisableIT_PLLRDY(void) { CLEAR_BIT(RCC->CIR, RCC_CIR_PLLRDYIE); } #if defined(RCC_PLLI2S_SUPPORT) /** * @brief Disable PLLI2S ready interrupt * @rmtoll CIR PLLI2SRDYIE LL_RCC_DisableIT_PLLI2SRDY * @retval None */ __STATIC_INLINE void LL_RCC_DisableIT_PLLI2SRDY(void) { CLEAR_BIT(RCC->CIR, RCC_CIR_PLLI2SRDYIE); } #endif /* RCC_PLLI2S_SUPPORT */ #if defined(RCC_PLLSAI_SUPPORT) /** * @brief Disable PLLSAI ready interrupt * @rmtoll CIR PLLSAIRDYIE LL_RCC_DisableIT_PLLSAIRDY * @retval None */ __STATIC_INLINE void LL_RCC_DisableIT_PLLSAIRDY(void) { CLEAR_BIT(RCC->CIR, RCC_CIR_PLLSAIRDYIE); } #endif /* RCC_PLLSAI_SUPPORT */ /** * @brief Checks if LSI ready interrupt source is enabled or disabled. * @rmtoll CIR LSIRDYIE LL_RCC_IsEnabledIT_LSIRDY * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_RCC_IsEnabledIT_LSIRDY(void) { return (READ_BIT(RCC->CIR, RCC_CIR_LSIRDYIE) == (RCC_CIR_LSIRDYIE)); } /** * @brief Checks if LSE ready interrupt source is enabled or disabled. * @rmtoll CIR LSERDYIE LL_RCC_IsEnabledIT_LSERDY * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_RCC_IsEnabledIT_LSERDY(void) { return (READ_BIT(RCC->CIR, RCC_CIR_LSERDYIE) == (RCC_CIR_LSERDYIE)); } /** * @brief Checks if HSI ready interrupt source is enabled or disabled. * @rmtoll CIR HSIRDYIE LL_RCC_IsEnabledIT_HSIRDY * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_RCC_IsEnabledIT_HSIRDY(void) { return (READ_BIT(RCC->CIR, RCC_CIR_HSIRDYIE) == (RCC_CIR_HSIRDYIE)); } /** * @brief Checks if HSE ready interrupt source is enabled or disabled. * @rmtoll CIR HSERDYIE LL_RCC_IsEnabledIT_HSERDY * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_RCC_IsEnabledIT_HSERDY(void) { return (READ_BIT(RCC->CIR, RCC_CIR_HSERDYIE) == (RCC_CIR_HSERDYIE)); } /** * @brief Checks if PLL ready interrupt source is enabled or disabled. * @rmtoll CIR PLLRDYIE LL_RCC_IsEnabledIT_PLLRDY * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_RCC_IsEnabledIT_PLLRDY(void) { return (READ_BIT(RCC->CIR, RCC_CIR_PLLRDYIE) == (RCC_CIR_PLLRDYIE)); } #if defined(RCC_PLLI2S_SUPPORT) /** * @brief Checks if PLLI2S ready interrupt source is enabled or disabled. * @rmtoll CIR PLLI2SRDYIE LL_RCC_IsEnabledIT_PLLI2SRDY * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_RCC_IsEnabledIT_PLLI2SRDY(void) { return (READ_BIT(RCC->CIR, RCC_CIR_PLLI2SRDYIE) == (RCC_CIR_PLLI2SRDYIE)); } #endif /* RCC_PLLI2S_SUPPORT */ #if defined(RCC_PLLSAI_SUPPORT) /** * @brief Checks if PLLSAI ready interrupt source is enabled or disabled. * @rmtoll CIR PLLSAIRDYIE LL_RCC_IsEnabledIT_PLLSAIRDY * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_RCC_IsEnabledIT_PLLSAIRDY(void) { return (READ_BIT(RCC->CIR, RCC_CIR_PLLSAIRDYIE) == (RCC_CIR_PLLSAIRDYIE)); } #endif /* RCC_PLLSAI_SUPPORT */ /** * @} */ #if defined(USE_FULL_LL_DRIVER) /** @defgroup RCC_LL_EF_Init De-initialization function * @{ */ ErrorStatus LL_RCC_DeInit(void); /** * @} */ /** @defgroup RCC_LL_EF_Get_Freq Get system and peripherals clocks frequency functions * @{ */ void LL_RCC_GetSystemClocksFreq(LL_RCC_ClocksTypeDef *RCC_Clocks); #if defined(FMPI2C1) uint32_t LL_RCC_GetFMPI2CClockFreq(uint32_t FMPI2CxSource); #endif /* FMPI2C1 */ #if defined(LPTIM1) uint32_t LL_RCC_GetLPTIMClockFreq(uint32_t LPTIMxSource); #endif /* LPTIM1 */ #if defined(SAI1) uint32_t LL_RCC_GetSAIClockFreq(uint32_t SAIxSource); #endif /* SAI1 */ #if defined(SDIO) uint32_t LL_RCC_GetSDIOClockFreq(uint32_t SDIOxSource); #endif /* SDIO */ #if defined(RNG) uint32_t LL_RCC_GetRNGClockFreq(uint32_t RNGxSource); #endif /* RNG */ #if defined(USB_OTG_FS) || defined(USB_OTG_HS) uint32_t LL_RCC_GetUSBClockFreq(uint32_t USBxSource); #endif /* USB_OTG_FS || USB_OTG_HS */ #if defined(DFSDM1_Channel0) uint32_t LL_RCC_GetDFSDMClockFreq(uint32_t DFSDMxSource); uint32_t LL_RCC_GetDFSDMAudioClockFreq(uint32_t DFSDMxSource); #endif /* DFSDM1_Channel0 */ uint32_t LL_RCC_GetI2SClockFreq(uint32_t I2SxSource); #if defined(CEC) uint32_t LL_RCC_GetCECClockFreq(uint32_t CECxSource); #endif /* CEC */ #if defined(LTDC) uint32_t LL_RCC_GetLTDCClockFreq(uint32_t LTDCxSource); #endif /* LTDC */ #if defined(SPDIFRX) uint32_t LL_RCC_GetSPDIFRXClockFreq(uint32_t SPDIFRXxSource); #endif /* SPDIFRX */ #if defined(DSI) uint32_t LL_RCC_GetDSIClockFreq(uint32_t DSIxSource); #endif /* DSI */ /** * @} */ #endif /* USE_FULL_LL_DRIVER */ /** * @} */ /** * @} */ #endif /* defined(RCC) */ /** * @} */ #ifdef __cplusplus } #endif #endif /* __STM32F4xx_LL_RCC_H */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ ================================================ FILE: sys/arch/stm32/hal/stm32f4xx_ll_sdmmc.c ================================================ /** ****************************************************************************** * @file stm32f4xx_ll_sdmmc.c * @author MCD Application Team * @version V1.7.1 * @date 14-April-2017 * @brief SDMMC Low Layer HAL module driver. * * This file provides firmware functions to manage the following * functionalities of the SDMMC peripheral: * + Initialization/de-initialization functions * + I/O operation functions * + Peripheral Control functions * + Peripheral State functions * @verbatim ============================================================================== ##### SDMMC peripheral features ##### ============================================================================== [..] The SD/SDMMC MMC card host interface (SDMMC) provides an interface between the AHB peripheral bus and MultiMedia cards (MMCs), SD memory cards, SDMMC cards and CE-ATA devices. [..] The SDMMC features include the following: (+) Full compliance with MultiMedia Card System Specification Version 4.2. Card support for three different databus modes: 1-bit (default), 4-bit and 8-bit (+) Full compatibility with previous versions of MultiMedia Cards (forward compatibility) (+) Full compliance with SD Memory Card Specifications Version 2.0 (+) Full compliance with SD I/O Card Specification Version 2.0: card support for two different data bus modes: 1-bit (default) and 4-bit (+) Full support of the CE-ATA features (full compliance with CE-ATA digital protocol Rev1.1) (+) Data transfer up to 48 MHz for the 8 bit mode (+) Data and command output enable signals to control external bidirectional drivers ##### How to use this driver ##### ============================================================================== [..] This driver is a considered as a driver of service for external devices drivers that interfaces with the SDMMC peripheral. According to the device used (SD card/ MMC card / SDMMC card ...), a set of APIs is used in the device's driver to perform SDMMC operations and functionalities. This driver is almost transparent for the final user, it is only used to implement other functionalities of the external device. [..] (+) The SDMMC clock (SDMMCCLK = 48 MHz) is coming from a specific output (MSI, PLLUSB1CLK, PLLUSB2CLK). Before start working with SDMMC peripheral make sure that the PLL is well configured. The SDMMC peripheral uses two clock signals: (++) SDMMC adapter clock (SDMMCCLK = 48 MHz) (++) APB2 bus clock (PCLK2) -@@- PCLK2 and SDMMC_CK clock frequencies must respect the following condition: Frequency(PCLK2) >= (3 / 8 x Frequency(SDMMC_CK)) (+) Enable/Disable peripheral clock using RCC peripheral macros related to SDMMC peripheral. (+) Enable the Power ON State using the SDIO_PowerState_ON() function and disable it using the function SDIO_PowerState_OFF(). (+) Enable/Disable the clock using the __SDIO_ENABLE()/__SDIO_DISABLE() macros. (+) Enable/Disable the peripheral interrupts using the macros __SDIO_ENABLE_IT() and __SDIO_DISABLE_IT() if you need to use interrupt mode. (+) When using the DMA mode (++) Configure the DMA in the MSP layer of the external device (++) Active the needed channel Request (++) Enable the DMA using __SDIO_DMA_ENABLE() macro or Disable it using the macro __SDIO_DMA_DISABLE(). (+) To control the CPSM (Command Path State Machine) and send commands to the card use the SDIO_SendCommand(), SDIO_GetCommandResponse() and SDIO_GetResponse() functions. First, user has to fill the command structure (pointer to SDIO_CmdInitTypeDef) according to the selected command to be sent. The parameters that should be filled are: (++) Command Argument (++) Command Index (++) Command Response type (++) Command Wait (++) CPSM Status (Enable or Disable). -@@- To check if the command is well received, read the SDIO_CMDRESP register using the SDIO_GetCommandResponse(). The SDMMC responses registers (SDIO_RESP1 to SDIO_RESP2), use the SDIO_GetResponse() function. (+) To control the DPSM (Data Path State Machine) and send/receive data to/from the card use the SDIO_ConfigData(), SDIO_GetDataCounter(), SDIO_ReadFIFO(), SDIO_WriteFIFO() and SDIO_GetFIFOCount() functions. *** Read Operations *** ======================= [..] (#) First, user has to fill the data structure (pointer to SDIO_DataInitTypeDef) according to the selected data type to be received. The parameters that should be filled are: (++) Data TimeOut (++) Data Length (++) Data Block size (++) Data Transfer direction: should be from card (To SDMMC) (++) Data Transfer mode (++) DPSM Status (Enable or Disable) (#) Configure the SDMMC resources to receive the data from the card according to selected transfer mode (Refer to Step 8, 9 and 10). (#) Send the selected Read command (refer to step 11). (#) Use the SDIO flags/interrupts to check the transfer status. *** Write Operations *** ======================== [..] (#) First, user has to fill the data structure (pointer to SDIO_DataInitTypeDef) according to the selected data type to be received. The parameters that should be filled are: (++) Data TimeOut (++) Data Length (++) Data Block size (++) Data Transfer direction: should be to card (To CARD) (++) Data Transfer mode (++) DPSM Status (Enable or Disable) (#) Configure the SDMMC resources to send the data to the card according to selected transfer mode. (#) Send the selected Write command. (#) Use the SDIO flags/interrupts to check the transfer status. *** Command management operations *** ===================================== [..] (#) The commands used for Read/Write/Erase operations are managed in separate functions. Each function allows to send the needed command with the related argument, then check the response. By the same approach, you could implement a command and check the response. @endverbatim ****************************************************************************** * @attention * *

© COPYRIGHT(c) 2017 STMicroelectronics

* * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. Neither the name of STMicroelectronics nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ /* Includes ------------------------------------------------------------------*/ #include "stm32f4xx_hal.h" /** @addtogroup STM32F4xx_HAL_Driver * @{ */ /** @defgroup SDMMC_LL SDMMC Low Layer * @brief Low layer module for SD * @{ */ #if defined(HAL_SD_MODULE_ENABLED) || defined(HAL_MMC_MODULE_ENABLED) #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) || \ defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) || \ defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F411xE) || defined(STM32F446xx) || \ defined(STM32F469xx) || defined(STM32F479xx) || defined(STM32F412Zx) || defined(STM32F412Vx) || \ defined(STM32F412Rx) || defined(STM32F412Cx) || defined(STM32F413xx) || defined(STM32F423xx) /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/ static uint32_t SDMMC_GetCmdError(SDIO_TypeDef *SDIOx); static uint32_t SDMMC_GetCmdResp1(SDIO_TypeDef *SDIOx, uint8_t SD_CMD, uint32_t Timeout); static uint32_t SDMMC_GetCmdResp2(SDIO_TypeDef *SDIOx); static uint32_t SDMMC_GetCmdResp3(SDIO_TypeDef *SDIOx); static uint32_t SDMMC_GetCmdResp7(SDIO_TypeDef *SDIOx); static uint32_t SDMMC_GetCmdResp6(SDIO_TypeDef *SDIOx, uint8_t SD_CMD, uint16_t *pRCA); /* Exported functions --------------------------------------------------------*/ /** @defgroup SDMMC_LL_Exported_Functions SDMMC Low Layer Exported Functions * @{ */ /** @defgroup HAL_SDMMC_LL_Group1 Initialization de-initialization functions * @brief Initialization and Configuration functions * @verbatim =============================================================================== ##### Initialization/de-initialization functions ##### =============================================================================== [..] This section provides functions allowing to: @endverbatim * @{ */ /** * @brief Initializes the SDMMC according to the specified * parameters in the SDMMC_InitTypeDef and create the associated handle. * @param SDIOx: Pointer to SDMMC register base * @param Init: SDMMC initialization structure * @retval HAL status */ HAL_StatusTypeDef SDIO_Init(SDIO_TypeDef *SDIOx, SDIO_InitTypeDef Init) { uint32_t tmpreg = 0; /* Check the parameters */ assert_param(IS_SDIO_ALL_INSTANCE(SDIOx)); assert_param(IS_SDIO_CLOCK_EDGE(Init.ClockEdge)); assert_param(IS_SDIO_CLOCK_BYPASS(Init.ClockBypass)); assert_param(IS_SDIO_CLOCK_POWER_SAVE(Init.ClockPowerSave)); assert_param(IS_SDIO_BUS_WIDE(Init.BusWide)); assert_param(IS_SDIO_HARDWARE_FLOW_CONTROL(Init.HardwareFlowControl)); assert_param(IS_SDIO_CLKDIV(Init.ClockDiv)); /* Set SDMMC configuration parameters */ tmpreg |= (Init.ClockEdge |\ Init.ClockBypass |\ Init.ClockPowerSave |\ Init.BusWide |\ Init.HardwareFlowControl |\ Init.ClockDiv ); /* Write to SDMMC CLKCR */ MODIFY_REG(SDIOx->CLKCR, CLKCR_CLEAR_MASK, tmpreg); return HAL_OK; } /** * @} */ /** @defgroup HAL_SDMMC_LL_Group2 IO operation functions * @brief Data transfers functions * @verbatim =============================================================================== ##### I/O operation functions ##### =============================================================================== [..] This subsection provides a set of functions allowing to manage the SDMMC data transfers. @endverbatim * @{ */ /** * @brief Read data (word) from Rx FIFO in blocking mode (polling) * @param SDIOx: Pointer to SDMMC register base * @retval HAL status */ uint32_t SDIO_ReadFIFO(SDIO_TypeDef *SDIOx) { /* Read data from Rx FIFO */ return (SDIOx->FIFO); } /** * @brief Write data (word) to Tx FIFO in blocking mode (polling) * @param SDIOx: Pointer to SDMMC register base * @param pWriteData: pointer to data to write * @retval HAL status */ HAL_StatusTypeDef SDIO_WriteFIFO(SDIO_TypeDef *SDIOx, uint32_t *pWriteData) { /* Write data to FIFO */ SDIOx->FIFO = *pWriteData; return HAL_OK; } /** * @} */ /** @defgroup HAL_SDMMC_LL_Group3 Peripheral Control functions * @brief management functions * @verbatim =============================================================================== ##### Peripheral Control functions ##### =============================================================================== [..] This subsection provides a set of functions allowing to control the SDMMC data transfers. @endverbatim * @{ */ /** * @brief Set SDMMC Power state to ON. * @param SDIOx: Pointer to SDMMC register base * @retval HAL status */ HAL_StatusTypeDef SDIO_PowerState_ON(SDIO_TypeDef *SDIOx) { /* Set power state to ON */ SDIOx->POWER = SDIO_POWER_PWRCTRL; /* Required power up waiting time before starting the SD initialization sequence */ LL_mDelay(2U); return HAL_OK; } /** * @brief Set SDMMC Power state to OFF. * @param SDIOx: Pointer to SDMMC register base * @retval HAL status */ HAL_StatusTypeDef SDIO_PowerState_OFF(SDIO_TypeDef *SDIOx) { /* Set power state to OFF */ SDIOx->POWER = (uint32_t)0x00000000; return HAL_OK; } /** * @brief Get SDMMC Power state. * @param SDIOx: Pointer to SDMMC register base * @retval Power status of the controller. The returned value can be one of the * following values: * - 0x00: Power OFF * - 0x02: Power UP * - 0x03: Power ON */ uint32_t SDIO_GetPowerState(SDIO_TypeDef *SDIOx) { return (SDIOx->POWER & SDIO_POWER_PWRCTRL); } /** * @brief Configure the SDMMC command path according to the specified parameters in * SDIO_CmdInitTypeDef structure and send the command * @param SDIOx: Pointer to SDMMC register base * @param Command: pointer to a SDIO_CmdInitTypeDef structure that contains * the configuration information for the SDMMC command * @retval HAL status */ HAL_StatusTypeDef SDIO_SendCommand(SDIO_TypeDef *SDIOx, SDIO_CmdInitTypeDef *Command) { uint32_t tmpreg = 0; /* Check the parameters */ assert_param(IS_SDIO_CMD_INDEX(Command->CmdIndex)); assert_param(IS_SDIO_RESPONSE(Command->Response)); assert_param(IS_SDIO_WAIT(Command->WaitForInterrupt)); assert_param(IS_SDIO_CPSM(Command->CPSM)); /* Set the SDMMC Argument value */ SDIOx->ARG = Command->Argument; /* Set SDMMC command parameters */ tmpreg |= (uint32_t)(Command->CmdIndex |\ Command->Response |\ Command->WaitForInterrupt |\ Command->CPSM); /* Write to SDMMC CMD register */ MODIFY_REG(SDIOx->CMD, CMD_CLEAR_MASK, tmpreg); return HAL_OK; } /** * @brief Return the command index of last command for which response received * @param SDIOx: Pointer to SDMMC register base * @retval Command index of the last command response received */ uint8_t SDIO_GetCommandResponse(SDIO_TypeDef *SDIOx) { return (uint8_t)(SDIOx->RESPCMD); } /** * @brief Return the response received from the card for the last command * @param SDIOx: Pointer to SDMMC register base * @param Response: Specifies the SDMMC response register. * This parameter can be one of the following values: * @arg SDIO_RESP1: Response Register 1 * @arg SDIO_RESP2: Response Register 2 * @arg SDIO_RESP3: Response Register 3 * @arg SDIO_RESP4: Response Register 4 * @retval The Corresponding response register value */ uint32_t SDIO_GetResponse(SDIO_TypeDef *SDIOx, uint32_t Response) { uint32_t tmp; /* Check the parameters */ assert_param(IS_SDIO_RESP(Response)); /* Get the response */ tmp = (uint32_t)(&(SDIOx->RESP1)) + Response; return (*(__IO uint32_t *) tmp); } /** * @brief Configure the SDMMC data path according to the specified * parameters in the SDIO_DataInitTypeDef. * @param SDIOx: Pointer to SDIO register base * @param Data : pointer to a SDIO_DataInitTypeDef structure * that contains the configuration information for the SDMMC data. * @retval HAL status */ HAL_StatusTypeDef SDIO_ConfigData(SDIO_TypeDef *SDIOx, SDIO_DataInitTypeDef* Data) { uint32_t tmpreg = 0; /* Check the parameters */ assert_param(IS_SDIO_DATA_LENGTH(Data->DataLength)); assert_param(IS_SDIO_BLOCK_SIZE(Data->DataBlockSize)); assert_param(IS_SDIO_TRANSFER_DIR(Data->TransferDir)); assert_param(IS_SDIO_TRANSFER_MODE(Data->TransferMode)); assert_param(IS_SDIO_DPSM(Data->DPSM)); /* Set the SDMMC Data TimeOut value */ SDIOx->DTIMER = Data->DataTimeOut; /* Set the SDMMC DataLength value */ SDIOx->DLEN = Data->DataLength; /* Set the SDMMC data configuration parameters */ tmpreg |= (uint32_t)(Data->DataBlockSize |\ Data->TransferDir |\ Data->TransferMode |\ Data->DPSM); /* Write to SDMMC DCTRL */ MODIFY_REG(SDIOx->DCTRL, DCTRL_CLEAR_MASK, tmpreg); return HAL_OK; } /** * @brief Returns number of remaining data bytes to be transferred. * @param SDIOx: Pointer to SDIO register base * @retval Number of remaining data bytes to be transferred */ uint32_t SDIO_GetDataCounter(SDIO_TypeDef *SDIOx) { return (SDIOx->DCOUNT); } /** * @brief Get the FIFO data * @param SDIOx: Pointer to SDIO register base * @retval Data received */ uint32_t SDIO_GetFIFOCount(SDIO_TypeDef *SDIOx) { return (SDIOx->FIFO); } /** * @brief Sets one of the two options of inserting read wait interval. * @param SDIOx: Pointer to SDIO register base * @param SDIO_ReadWaitMode: SDMMC Read Wait operation mode. * This parameter can be: * @arg SDIO_READ_WAIT_MODE_CLK: Read Wait control by stopping SDMMCCLK * @arg SDIO_READ_WAIT_MODE_DATA2: Read Wait control using SDMMC_DATA2 * @retval None */ HAL_StatusTypeDef SDIO_SetSDMMCReadWaitMode(SDIO_TypeDef *SDIOx, uint32_t SDIO_ReadWaitMode) { /* Check the parameters */ assert_param(IS_SDIO_READWAIT_MODE(SDIO_ReadWaitMode)); /* Set SDMMC read wait mode */ MODIFY_REG(SDIOx->DCTRL, SDIO_DCTRL_RWMOD, SDIO_ReadWaitMode); return HAL_OK; } /** * @} */ /** @defgroup HAL_SDMMC_LL_Group4 Command management functions * @brief Data transfers functions * @verbatim =============================================================================== ##### Commands management functions ##### =============================================================================== [..] This subsection provides a set of functions allowing to manage the needed commands. @endverbatim * @{ */ /** * @brief Send the Data Block Lenght command and check the response * @param SDIOx: Pointer to SDIO register base * @retval HAL status */ uint32_t SDMMC_CmdBlockLength(SDIO_TypeDef *SDIOx, uint32_t BlockSize) { SDIO_CmdInitTypeDef sdmmc_cmdinit; uint32_t errorstate; /* Set Block Size for Card */ sdmmc_cmdinit.Argument = (uint32_t)BlockSize; sdmmc_cmdinit.CmdIndex = SDMMC_CMD_SET_BLOCKLEN; sdmmc_cmdinit.Response = SDIO_RESPONSE_SHORT; sdmmc_cmdinit.WaitForInterrupt = SDIO_WAIT_NO; sdmmc_cmdinit.CPSM = SDIO_CPSM_ENABLE; (void)SDIO_SendCommand(SDIOx, &sdmmc_cmdinit); /* Check for error conditions */ errorstate = SDMMC_GetCmdResp1(SDIOx, SDMMC_CMD_SET_BLOCKLEN, SDIO_CMDTIMEOUT); return errorstate; } /** * @brief Send the Read Single Block command and check the response * @param SDIOx: Pointer to SDIO register base * @retval HAL status */ uint32_t SDMMC_CmdReadSingleBlock(SDIO_TypeDef *SDIOx, uint32_t ReadAdd) { SDIO_CmdInitTypeDef sdmmc_cmdinit; uint32_t errorstate; /* Set Block Size for Card */ sdmmc_cmdinit.Argument = (uint32_t)ReadAdd; sdmmc_cmdinit.CmdIndex = SDMMC_CMD_READ_SINGLE_BLOCK; sdmmc_cmdinit.Response = SDIO_RESPONSE_SHORT; sdmmc_cmdinit.WaitForInterrupt = SDIO_WAIT_NO; sdmmc_cmdinit.CPSM = SDIO_CPSM_ENABLE; (void)SDIO_SendCommand(SDIOx, &sdmmc_cmdinit); /* Check for error conditions */ errorstate = SDMMC_GetCmdResp1(SDIOx, SDMMC_CMD_READ_SINGLE_BLOCK, SDIO_CMDTIMEOUT); return errorstate; } /** * @brief Send the Read Multi Block command and check the response * @param SDIOx: Pointer to SDIO register base * @retval HAL status */ uint32_t SDMMC_CmdReadMultiBlock(SDIO_TypeDef *SDIOx, uint32_t ReadAdd) { SDIO_CmdInitTypeDef sdmmc_cmdinit; uint32_t errorstate; /* Set Block Size for Card */ sdmmc_cmdinit.Argument = (uint32_t)ReadAdd; sdmmc_cmdinit.CmdIndex = SDMMC_CMD_READ_MULT_BLOCK; sdmmc_cmdinit.Response = SDIO_RESPONSE_SHORT; sdmmc_cmdinit.WaitForInterrupt = SDIO_WAIT_NO; sdmmc_cmdinit.CPSM = SDIO_CPSM_ENABLE; (void)SDIO_SendCommand(SDIOx, &sdmmc_cmdinit); /* Check for error conditions */ errorstate = SDMMC_GetCmdResp1(SDIOx, SDMMC_CMD_READ_MULT_BLOCK, SDIO_CMDTIMEOUT); return errorstate; } /** * @brief Send the Write Single Block command and check the response * @param SDIOx: Pointer to SDIO register base * @retval HAL status */ uint32_t SDMMC_CmdWriteSingleBlock(SDIO_TypeDef *SDIOx, uint32_t WriteAdd) { SDIO_CmdInitTypeDef sdmmc_cmdinit; uint32_t errorstate; /* Set Block Size for Card */ sdmmc_cmdinit.Argument = (uint32_t)WriteAdd; sdmmc_cmdinit.CmdIndex = SDMMC_CMD_WRITE_SINGLE_BLOCK; sdmmc_cmdinit.Response = SDIO_RESPONSE_SHORT; sdmmc_cmdinit.WaitForInterrupt = SDIO_WAIT_NO; sdmmc_cmdinit.CPSM = SDIO_CPSM_ENABLE; (void)SDIO_SendCommand(SDIOx, &sdmmc_cmdinit); /* Check for error conditions */ errorstate = SDMMC_GetCmdResp1(SDIOx, SDMMC_CMD_WRITE_SINGLE_BLOCK, SDIO_CMDTIMEOUT); return errorstate; } /** * @brief Send the Write Multi Block command and check the response * @param SDIOx: Pointer to SDIO register base * @retval HAL status */ uint32_t SDMMC_CmdWriteMultiBlock(SDIO_TypeDef *SDIOx, uint32_t WriteAdd) { SDIO_CmdInitTypeDef sdmmc_cmdinit; uint32_t errorstate; /* Set Block Size for Card */ sdmmc_cmdinit.Argument = (uint32_t)WriteAdd; sdmmc_cmdinit.CmdIndex = SDMMC_CMD_WRITE_MULT_BLOCK; sdmmc_cmdinit.Response = SDIO_RESPONSE_SHORT; sdmmc_cmdinit.WaitForInterrupt = SDIO_WAIT_NO; sdmmc_cmdinit.CPSM = SDIO_CPSM_ENABLE; (void)SDIO_SendCommand(SDIOx, &sdmmc_cmdinit); /* Check for error conditions */ errorstate = SDMMC_GetCmdResp1(SDIOx, SDMMC_CMD_WRITE_MULT_BLOCK, SDIO_CMDTIMEOUT); return errorstate; } /** * @brief Send the Start Address Erase command for SD and check the response * @param SDIOx: Pointer to SDIO register base * @retval HAL status */ uint32_t SDMMC_CmdSDEraseStartAdd(SDIO_TypeDef *SDIOx, uint32_t StartAdd) { SDIO_CmdInitTypeDef sdmmc_cmdinit; uint32_t errorstate; /* Set Block Size for Card */ sdmmc_cmdinit.Argument = (uint32_t)StartAdd; sdmmc_cmdinit.CmdIndex = SDMMC_CMD_SD_ERASE_GRP_START; sdmmc_cmdinit.Response = SDIO_RESPONSE_SHORT; sdmmc_cmdinit.WaitForInterrupt = SDIO_WAIT_NO; sdmmc_cmdinit.CPSM = SDIO_CPSM_ENABLE; (void)SDIO_SendCommand(SDIOx, &sdmmc_cmdinit); /* Check for error conditions */ errorstate = SDMMC_GetCmdResp1(SDIOx, SDMMC_CMD_SD_ERASE_GRP_START, SDIO_CMDTIMEOUT); return errorstate; } /** * @brief Send the End Address Erase command for SD and check the response * @param SDIOx: Pointer to SDIO register base * @retval HAL status */ uint32_t SDMMC_CmdSDEraseEndAdd(SDIO_TypeDef *SDIOx, uint32_t EndAdd) { SDIO_CmdInitTypeDef sdmmc_cmdinit; uint32_t errorstate; /* Set Block Size for Card */ sdmmc_cmdinit.Argument = (uint32_t)EndAdd; sdmmc_cmdinit.CmdIndex = SDMMC_CMD_SD_ERASE_GRP_END; sdmmc_cmdinit.Response = SDIO_RESPONSE_SHORT; sdmmc_cmdinit.WaitForInterrupt = SDIO_WAIT_NO; sdmmc_cmdinit.CPSM = SDIO_CPSM_ENABLE; (void)SDIO_SendCommand(SDIOx, &sdmmc_cmdinit); /* Check for error conditions */ errorstate = SDMMC_GetCmdResp1(SDIOx, SDMMC_CMD_SD_ERASE_GRP_END, SDIO_CMDTIMEOUT); return errorstate; } /** * @brief Send the Start Address Erase command and check the response * @param SDIOx: Pointer to SDIO register base * @retval HAL status */ uint32_t SDMMC_CmdEraseStartAdd(SDIO_TypeDef *SDIOx, uint32_t StartAdd) { SDIO_CmdInitTypeDef sdmmc_cmdinit; uint32_t errorstate; /* Set Block Size for Card */ sdmmc_cmdinit.Argument = (uint32_t)StartAdd; sdmmc_cmdinit.CmdIndex = SDMMC_CMD_ERASE_GRP_START; sdmmc_cmdinit.Response = SDIO_RESPONSE_SHORT; sdmmc_cmdinit.WaitForInterrupt = SDIO_WAIT_NO; sdmmc_cmdinit.CPSM = SDIO_CPSM_ENABLE; (void)SDIO_SendCommand(SDIOx, &sdmmc_cmdinit); /* Check for error conditions */ errorstate = SDMMC_GetCmdResp1(SDIOx, SDMMC_CMD_ERASE_GRP_START, SDIO_CMDTIMEOUT); return errorstate; } /** * @brief Send the End Address Erase command and check the response * @param SDIOx: Pointer to SDIO register base * @retval HAL status */ uint32_t SDMMC_CmdEraseEndAdd(SDIO_TypeDef *SDIOx, uint32_t EndAdd) { SDIO_CmdInitTypeDef sdmmc_cmdinit; uint32_t errorstate; /* Set Block Size for Card */ sdmmc_cmdinit.Argument = (uint32_t)EndAdd; sdmmc_cmdinit.CmdIndex = SDMMC_CMD_ERASE_GRP_END; sdmmc_cmdinit.Response = SDIO_RESPONSE_SHORT; sdmmc_cmdinit.WaitForInterrupt = SDIO_WAIT_NO; sdmmc_cmdinit.CPSM = SDIO_CPSM_ENABLE; (void)SDIO_SendCommand(SDIOx, &sdmmc_cmdinit); /* Check for error conditions */ errorstate = SDMMC_GetCmdResp1(SDIOx, SDMMC_CMD_ERASE_GRP_END, SDIO_CMDTIMEOUT); return errorstate; } /** * @brief Send the Erase command and check the response * @param SDIOx: Pointer to SDIO register base * @retval HAL status */ uint32_t SDMMC_CmdErase(SDIO_TypeDef *SDIOx) { SDIO_CmdInitTypeDef sdmmc_cmdinit; uint32_t errorstate; /* Set Block Size for Card */ sdmmc_cmdinit.Argument = 0U; sdmmc_cmdinit.CmdIndex = SDMMC_CMD_ERASE; sdmmc_cmdinit.Response = SDIO_RESPONSE_SHORT; sdmmc_cmdinit.WaitForInterrupt = SDIO_WAIT_NO; sdmmc_cmdinit.CPSM = SDIO_CPSM_ENABLE; (void)SDIO_SendCommand(SDIOx, &sdmmc_cmdinit); /* Check for error conditions */ errorstate = SDMMC_GetCmdResp1(SDIOx, SDMMC_CMD_ERASE, SDIO_MAXERASETIMEOUT); return errorstate; } /** * @brief Send the Stop Transfer command and check the response. * @param SDIOx: Pointer to SDIO register base * @retval HAL status */ uint32_t SDMMC_CmdStopTransfer(SDIO_TypeDef *SDIOx) { SDIO_CmdInitTypeDef sdmmc_cmdinit; uint32_t errorstate; /* Send CMD12 STOP_TRANSMISSION */ sdmmc_cmdinit.Argument = 0U; sdmmc_cmdinit.CmdIndex = SDMMC_CMD_STOP_TRANSMISSION; sdmmc_cmdinit.Response = SDIO_RESPONSE_SHORT; sdmmc_cmdinit.WaitForInterrupt = SDIO_WAIT_NO; sdmmc_cmdinit.CPSM = SDIO_CPSM_ENABLE; (void)SDIO_SendCommand(SDIOx, &sdmmc_cmdinit); /* Check for error conditions */ errorstate = SDMMC_GetCmdResp1(SDIOx, SDMMC_CMD_STOP_TRANSMISSION, SDIO_STOPTRANSFERTIMEOUT); return errorstate; } /** * @brief Send the Select Deselect command and check the response. * @param SDIOx: Pointer to SDIO register base * @param addr: Address of the card to be selected * @retval HAL status */ uint32_t SDMMC_CmdSelDesel(SDIO_TypeDef *SDIOx, uint64_t Addr) { SDIO_CmdInitTypeDef sdmmc_cmdinit; uint32_t errorstate; /* Send CMD7 SDMMC_SEL_DESEL_CARD */ sdmmc_cmdinit.Argument = (uint32_t)Addr; sdmmc_cmdinit.CmdIndex = SDMMC_CMD_SEL_DESEL_CARD; sdmmc_cmdinit.Response = SDIO_RESPONSE_SHORT; sdmmc_cmdinit.WaitForInterrupt = SDIO_WAIT_NO; sdmmc_cmdinit.CPSM = SDIO_CPSM_ENABLE; (void)SDIO_SendCommand(SDIOx, &sdmmc_cmdinit); /* Check for error conditions */ errorstate = SDMMC_GetCmdResp1(SDIOx, SDMMC_CMD_SEL_DESEL_CARD, SDIO_CMDTIMEOUT); return errorstate; } /** * @brief Send the Go Idle State command and check the response. * @param SDIOx: Pointer to SDIO register base * @retval HAL status */ uint32_t SDMMC_CmdGoIdleState(SDIO_TypeDef *SDIOx) { SDIO_CmdInitTypeDef sdmmc_cmdinit; uint32_t errorstate; sdmmc_cmdinit.Argument = 0U; sdmmc_cmdinit.CmdIndex = SDMMC_CMD_GO_IDLE_STATE; sdmmc_cmdinit.Response = SDIO_RESPONSE_NO; sdmmc_cmdinit.WaitForInterrupt = SDIO_WAIT_NO; sdmmc_cmdinit.CPSM = SDIO_CPSM_ENABLE; (void)SDIO_SendCommand(SDIOx, &sdmmc_cmdinit); /* Check for error conditions */ errorstate = SDMMC_GetCmdError(SDIOx); return errorstate; } /** * @brief Send the Operating Condition command and check the response. * @param SDIOx: Pointer to SDIO register base * @retval HAL status */ uint32_t SDMMC_CmdOperCond(SDIO_TypeDef *SDIOx) { SDIO_CmdInitTypeDef sdmmc_cmdinit; uint32_t errorstate; /* Send CMD8 to verify SD card interface operating condition */ /* Argument: - [31:12]: Reserved (shall be set to '0') - [11:8]: Supply Voltage (VHS) 0x1 (Range: 2.7-3.6 V) - [7:0]: Check Pattern (recommended 0xAA) */ /* CMD Response: R7 */ sdmmc_cmdinit.Argument = SDMMC_CHECK_PATTERN; sdmmc_cmdinit.CmdIndex = SDMMC_CMD_HS_SEND_EXT_CSD; sdmmc_cmdinit.Response = SDIO_RESPONSE_SHORT; sdmmc_cmdinit.WaitForInterrupt = SDIO_WAIT_NO; sdmmc_cmdinit.CPSM = SDIO_CPSM_ENABLE; (void)SDIO_SendCommand(SDIOx, &sdmmc_cmdinit); /* Check for error conditions */ errorstate = SDMMC_GetCmdResp7(SDIOx); return errorstate; } /** * @brief Send the Application command to verify that that the next command * is an application specific com-mand rather than a standard command * and check the response. * @param SDIOx: Pointer to SDIO register base * @param Argument: Command Argument * @retval HAL status */ uint32_t SDMMC_CmdAppCommand(SDIO_TypeDef *SDIOx, uint32_t Argument) { SDIO_CmdInitTypeDef sdmmc_cmdinit; uint32_t errorstate; sdmmc_cmdinit.Argument = (uint32_t)Argument; sdmmc_cmdinit.CmdIndex = SDMMC_CMD_APP_CMD; sdmmc_cmdinit.Response = SDIO_RESPONSE_SHORT; sdmmc_cmdinit.WaitForInterrupt = SDIO_WAIT_NO; sdmmc_cmdinit.CPSM = SDIO_CPSM_ENABLE; (void)SDIO_SendCommand(SDIOx, &sdmmc_cmdinit); /* Check for error conditions */ /* If there is a HAL_ERROR, it is a MMC card, else it is a SD card: SD card 2.0 (voltage range mismatch) or SD card 1.x */ errorstate = SDMMC_GetCmdResp1(SDIOx, SDMMC_CMD_APP_CMD, SDIO_CMDTIMEOUT); return errorstate; } /** * @brief Send the command asking the accessed card to send its operating * condition register (OCR) * @param SDIOx: Pointer to SDIO register base * @param Argument: Command Argument * @retval HAL status */ uint32_t SDMMC_CmdAppOperCommand(SDIO_TypeDef *SDIOx, uint32_t Argument) { SDIO_CmdInitTypeDef sdmmc_cmdinit; uint32_t errorstate; sdmmc_cmdinit.Argument = SDMMC_VOLTAGE_WINDOW_SD | Argument; sdmmc_cmdinit.CmdIndex = SDMMC_CMD_SD_APP_OP_COND; sdmmc_cmdinit.Response = SDIO_RESPONSE_SHORT; sdmmc_cmdinit.WaitForInterrupt = SDIO_WAIT_NO; sdmmc_cmdinit.CPSM = SDIO_CPSM_ENABLE; (void)SDIO_SendCommand(SDIOx, &sdmmc_cmdinit); /* Check for error conditions */ errorstate = SDMMC_GetCmdResp3(SDIOx); return errorstate; } /** * @brief Send the Bus Width command and check the response. * @param SDIOx: Pointer to SDIO register base * @param BusWidth: BusWidth * @retval HAL status */ uint32_t SDMMC_CmdBusWidth(SDIO_TypeDef *SDIOx, uint32_t BusWidth) { SDIO_CmdInitTypeDef sdmmc_cmdinit; uint32_t errorstate; sdmmc_cmdinit.Argument = (uint32_t)BusWidth; sdmmc_cmdinit.CmdIndex = SDMMC_CMD_APP_SD_SET_BUSWIDTH; sdmmc_cmdinit.Response = SDIO_RESPONSE_SHORT; sdmmc_cmdinit.WaitForInterrupt = SDIO_WAIT_NO; sdmmc_cmdinit.CPSM = SDIO_CPSM_ENABLE; (void)SDIO_SendCommand(SDIOx, &sdmmc_cmdinit); /* Check for error conditions */ errorstate = SDMMC_GetCmdResp1(SDIOx, SDMMC_CMD_APP_SD_SET_BUSWIDTH, SDIO_CMDTIMEOUT); return errorstate; } /** * @brief Send the Send SCR command and check the response. * @param SDIOx: Pointer to SDIO register base * @retval HAL status */ uint32_t SDMMC_CmdSendSCR(SDIO_TypeDef *SDIOx) { SDIO_CmdInitTypeDef sdmmc_cmdinit; uint32_t errorstate; /* Send CMD51 SD_APP_SEND_SCR */ sdmmc_cmdinit.Argument = 0U; sdmmc_cmdinit.CmdIndex = SDMMC_CMD_SD_APP_SEND_SCR; sdmmc_cmdinit.Response = SDIO_RESPONSE_SHORT; sdmmc_cmdinit.WaitForInterrupt = SDIO_WAIT_NO; sdmmc_cmdinit.CPSM = SDIO_CPSM_ENABLE; (void)SDIO_SendCommand(SDIOx, &sdmmc_cmdinit); /* Check for error conditions */ errorstate = SDMMC_GetCmdResp1(SDIOx, SDMMC_CMD_SD_APP_SEND_SCR, SDIO_CMDTIMEOUT); return errorstate; } /** * @brief Send the Send CID command and check the response. * @param SDIOx: Pointer to SDIO register base * @retval HAL status */ uint32_t SDMMC_CmdSendCID(SDIO_TypeDef *SDIOx) { SDIO_CmdInitTypeDef sdmmc_cmdinit; uint32_t errorstate; /* Send CMD2 ALL_SEND_CID */ sdmmc_cmdinit.Argument = 0U; sdmmc_cmdinit.CmdIndex = SDMMC_CMD_ALL_SEND_CID; sdmmc_cmdinit.Response = SDIO_RESPONSE_LONG; sdmmc_cmdinit.WaitForInterrupt = SDIO_WAIT_NO; sdmmc_cmdinit.CPSM = SDIO_CPSM_ENABLE; (void)SDIO_SendCommand(SDIOx, &sdmmc_cmdinit); /* Check for error conditions */ errorstate = SDMMC_GetCmdResp2(SDIOx); return errorstate; } /** * @brief Send the Send CSD command and check the response. * @param SDIOx: Pointer to SDIO register base * @param Argument: Command Argument * @retval HAL status */ uint32_t SDMMC_CmdSendCSD(SDIO_TypeDef *SDIOx, uint32_t Argument) { SDIO_CmdInitTypeDef sdmmc_cmdinit; uint32_t errorstate; /* Send CMD9 SEND_CSD */ sdmmc_cmdinit.Argument = Argument; sdmmc_cmdinit.CmdIndex = SDMMC_CMD_SEND_CSD; sdmmc_cmdinit.Response = SDIO_RESPONSE_LONG; sdmmc_cmdinit.WaitForInterrupt = SDIO_WAIT_NO; sdmmc_cmdinit.CPSM = SDIO_CPSM_ENABLE; (void)SDIO_SendCommand(SDIOx, &sdmmc_cmdinit); /* Check for error conditions */ errorstate = SDMMC_GetCmdResp2(SDIOx); return errorstate; } /** * @brief Send the Send CSD command and check the response. * @param SDIOx: Pointer to SDIO register base * @param pRCA: Card RCA * @retval HAL status */ uint32_t SDMMC_CmdSetRelAdd(SDIO_TypeDef *SDIOx, uint16_t *pRCA) { SDIO_CmdInitTypeDef sdmmc_cmdinit; uint32_t errorstate; /* Send CMD3 SD_CMD_SET_REL_ADDR */ sdmmc_cmdinit.Argument = 0U; sdmmc_cmdinit.CmdIndex = SDMMC_CMD_SET_REL_ADDR; sdmmc_cmdinit.Response = SDIO_RESPONSE_SHORT; sdmmc_cmdinit.WaitForInterrupt = SDIO_WAIT_NO; sdmmc_cmdinit.CPSM = SDIO_CPSM_ENABLE; (void)SDIO_SendCommand(SDIOx, &sdmmc_cmdinit); /* Check for error conditions */ errorstate = SDMMC_GetCmdResp6(SDIOx, SDMMC_CMD_SET_REL_ADDR, pRCA); return errorstate; } /** * @brief Send the Status command and check the response. * @param SDIOx: Pointer to SDIO register base * @param Argument: Command Argument * @retval HAL status */ uint32_t SDMMC_CmdSendStatus(SDIO_TypeDef *SDIOx, uint32_t Argument) { SDIO_CmdInitTypeDef sdmmc_cmdinit; uint32_t errorstate; sdmmc_cmdinit.Argument = Argument; sdmmc_cmdinit.CmdIndex = SDMMC_CMD_SEND_STATUS; sdmmc_cmdinit.Response = SDIO_RESPONSE_SHORT; sdmmc_cmdinit.WaitForInterrupt = SDIO_WAIT_NO; sdmmc_cmdinit.CPSM = SDIO_CPSM_ENABLE; (void)SDIO_SendCommand(SDIOx, &sdmmc_cmdinit); /* Check for error conditions */ errorstate = SDMMC_GetCmdResp1(SDIOx, SDMMC_CMD_SEND_STATUS, SDIO_CMDTIMEOUT); return errorstate; } /** * @brief Send the Status register command and check the response. * @param SDIOx: Pointer to SDIO register base * @retval HAL status */ uint32_t SDMMC_CmdStatusRegister(SDIO_TypeDef *SDIOx) { SDIO_CmdInitTypeDef sdmmc_cmdinit; uint32_t errorstate; sdmmc_cmdinit.Argument = 0U; sdmmc_cmdinit.CmdIndex = SDMMC_CMD_SD_APP_STATUS; sdmmc_cmdinit.Response = SDIO_RESPONSE_SHORT; sdmmc_cmdinit.WaitForInterrupt = SDIO_WAIT_NO; sdmmc_cmdinit.CPSM = SDIO_CPSM_ENABLE; (void)SDIO_SendCommand(SDIOx, &sdmmc_cmdinit); /* Check for error conditions */ errorstate = SDMMC_GetCmdResp1(SDIOx, SDMMC_CMD_SD_APP_STATUS, SDIO_CMDTIMEOUT); return errorstate; } /** * @brief Sends host capacity support information and activates the card's * initialization process. Send SDMMC_CMD_SEND_OP_COND command * @param SDIOx: Pointer to SDIO register base * @parame Argument: Argument used for the command * @retval HAL status */ uint32_t SDMMC_CmdOpCondition(SDIO_TypeDef *SDIOx, uint32_t Argument) { SDIO_CmdInitTypeDef sdmmc_cmdinit; uint32_t errorstate; sdmmc_cmdinit.Argument = Argument; sdmmc_cmdinit.CmdIndex = SDMMC_CMD_SEND_OP_COND; sdmmc_cmdinit.Response = SDIO_RESPONSE_SHORT; sdmmc_cmdinit.WaitForInterrupt = SDIO_WAIT_NO; sdmmc_cmdinit.CPSM = SDIO_CPSM_ENABLE; (void)SDIO_SendCommand(SDIOx, &sdmmc_cmdinit); /* Check for error conditions */ errorstate = SDMMC_GetCmdResp3(SDIOx); return errorstate; } /** * @brief Checks switchable function and switch card function. SDMMC_CMD_HS_SWITCH comand * @param SDIOx: Pointer to SDIO register base * @parame Argument: Argument used for the command * @retval HAL status */ uint32_t SDMMC_CmdSwitch(SDIO_TypeDef *SDIOx, uint32_t Argument) { SDIO_CmdInitTypeDef sdmmc_cmdinit; uint32_t errorstate; /* Send CMD6 to activate SDR50 Mode and Power Limit 1.44W */ /* CMD Response: R1 */ sdmmc_cmdinit.Argument = Argument; /* SDMMC_SDR25_SWITCH_PATTERN */ sdmmc_cmdinit.CmdIndex = SDMMC_CMD_HS_SWITCH; sdmmc_cmdinit.Response = SDIO_RESPONSE_SHORT; sdmmc_cmdinit.WaitForInterrupt = SDIO_WAIT_NO; sdmmc_cmdinit.CPSM = SDIO_CPSM_ENABLE; (void)SDIO_SendCommand(SDIOx, &sdmmc_cmdinit); /* Check for error conditions */ errorstate = SDMMC_GetCmdResp1(SDIOx, SDMMC_CMD_HS_SWITCH, SDIO_CMDTIMEOUT); return errorstate; } /** * @} */ /* Private function ----------------------------------------------------------*/ /** @addtogroup SD_Private_Functions * @{ */ /** * @brief Checks for error conditions for CMD0. * @param hsd: SD handle * @retval SD Card error state */ static uint32_t SDMMC_GetCmdError(SDIO_TypeDef *SDIOx) { /* 8 is the number of required instructions cycles for the below loop statement. The SDIO_CMDTIMEOUT is expressed in ms */ register uint32_t count = SDIO_CMDTIMEOUT * (SystemCoreClock / 8U /1000U); do { if (count-- == 0U) { return SDMMC_ERROR_TIMEOUT; } }while(!__SDIO_GET_FLAG(SDIOx, SDIO_FLAG_CMDSENT)); /* Clear all the static flags */ __SDIO_CLEAR_FLAG(SDIOx, SDIO_STATIC_CMD_FLAGS); return SDMMC_ERROR_NONE; } /** * @brief Checks for error conditions for R1 response. * @param hsd: SD handle * @param SD_CMD: The sent command index * @retval SD Card error state */ static uint32_t SDMMC_GetCmdResp1(SDIO_TypeDef *SDIOx, uint8_t SD_CMD, uint32_t Timeout) { uint32_t response_r1; uint32_t sta_reg; /* 8 is the number of required instructions cycles for the below loop statement. The Timeout is expressed in ms */ register uint32_t count = Timeout * (SystemCoreClock / 8U /1000U); do { if (count-- == 0U) { return SDMMC_ERROR_TIMEOUT; } sta_reg = SDIOx->STA; }while(((sta_reg & (SDIO_FLAG_CCRCFAIL | SDIO_FLAG_CMDREND | SDIO_FLAG_CTIMEOUT)) == 0U) || ((sta_reg & SDIO_FLAG_CMDACT) != 0U )); if(__SDIO_GET_FLAG(SDIOx, SDIO_FLAG_CTIMEOUT)) { __SDIO_CLEAR_FLAG(SDIOx, SDIO_FLAG_CTIMEOUT); return SDMMC_ERROR_CMD_RSP_TIMEOUT; } else if(__SDIO_GET_FLAG(SDIOx, SDIO_FLAG_CCRCFAIL)) { __SDIO_CLEAR_FLAG(SDIOx, SDIO_FLAG_CCRCFAIL); return SDMMC_ERROR_CMD_CRC_FAIL; } else { /* Nothing to do */ } /* Clear all the static flags */ __SDIO_CLEAR_FLAG(SDIOx, SDIO_STATIC_CMD_FLAGS); /* Check response received is of desired command */ if(SDIO_GetCommandResponse(SDIOx) != SD_CMD) { return SDMMC_ERROR_CMD_CRC_FAIL; } /* We have received response, retrieve it for analysis */ response_r1 = SDIO_GetResponse(SDIOx, SDIO_RESP1); if((response_r1 & SDMMC_OCR_ERRORBITS) == SDMMC_ALLZERO) { return SDMMC_ERROR_NONE; } else if((response_r1 & SDMMC_OCR_ADDR_OUT_OF_RANGE) == SDMMC_OCR_ADDR_OUT_OF_RANGE) { return SDMMC_ERROR_ADDR_OUT_OF_RANGE; } else if((response_r1 & SDMMC_OCR_ADDR_MISALIGNED) == SDMMC_OCR_ADDR_MISALIGNED) { return SDMMC_ERROR_ADDR_MISALIGNED; } else if((response_r1 & SDMMC_OCR_BLOCK_LEN_ERR) == SDMMC_OCR_BLOCK_LEN_ERR) { return SDMMC_ERROR_BLOCK_LEN_ERR; } else if((response_r1 & SDMMC_OCR_ERASE_SEQ_ERR) == SDMMC_OCR_ERASE_SEQ_ERR) { return SDMMC_ERROR_ERASE_SEQ_ERR; } else if((response_r1 & SDMMC_OCR_BAD_ERASE_PARAM) == SDMMC_OCR_BAD_ERASE_PARAM) { return SDMMC_ERROR_BAD_ERASE_PARAM; } else if((response_r1 & SDMMC_OCR_WRITE_PROT_VIOLATION) == SDMMC_OCR_WRITE_PROT_VIOLATION) { return SDMMC_ERROR_WRITE_PROT_VIOLATION; } else if((response_r1 & SDMMC_OCR_LOCK_UNLOCK_FAILED) == SDMMC_OCR_LOCK_UNLOCK_FAILED) { return SDMMC_ERROR_LOCK_UNLOCK_FAILED; } else if((response_r1 & SDMMC_OCR_COM_CRC_FAILED) == SDMMC_OCR_COM_CRC_FAILED) { return SDMMC_ERROR_COM_CRC_FAILED; } else if((response_r1 & SDMMC_OCR_ILLEGAL_CMD) == SDMMC_OCR_ILLEGAL_CMD) { return SDMMC_ERROR_ILLEGAL_CMD; } else if((response_r1 & SDMMC_OCR_CARD_ECC_FAILED) == SDMMC_OCR_CARD_ECC_FAILED) { return SDMMC_ERROR_CARD_ECC_FAILED; } else if((response_r1 & SDMMC_OCR_CC_ERROR) == SDMMC_OCR_CC_ERROR) { return SDMMC_ERROR_CC_ERR; } else if((response_r1 & SDMMC_OCR_STREAM_READ_UNDERRUN) == SDMMC_OCR_STREAM_READ_UNDERRUN) { return SDMMC_ERROR_STREAM_READ_UNDERRUN; } else if((response_r1 & SDMMC_OCR_STREAM_WRITE_OVERRUN) == SDMMC_OCR_STREAM_WRITE_OVERRUN) { return SDMMC_ERROR_STREAM_WRITE_OVERRUN; } else if((response_r1 & SDMMC_OCR_CID_CSD_OVERWRITE) == SDMMC_OCR_CID_CSD_OVERWRITE) { return SDMMC_ERROR_CID_CSD_OVERWRITE; } else if((response_r1 & SDMMC_OCR_WP_ERASE_SKIP) == SDMMC_OCR_WP_ERASE_SKIP) { return SDMMC_ERROR_WP_ERASE_SKIP; } else if((response_r1 & SDMMC_OCR_CARD_ECC_DISABLED) == SDMMC_OCR_CARD_ECC_DISABLED) { return SDMMC_ERROR_CARD_ECC_DISABLED; } else if((response_r1 & SDMMC_OCR_ERASE_RESET) == SDMMC_OCR_ERASE_RESET) { return SDMMC_ERROR_ERASE_RESET; } else if((response_r1 & SDMMC_OCR_AKE_SEQ_ERROR) == SDMMC_OCR_AKE_SEQ_ERROR) { return SDMMC_ERROR_AKE_SEQ_ERR; } else { return SDMMC_ERROR_GENERAL_UNKNOWN_ERR; } } /** * @brief Checks for error conditions for R2 (CID or CSD) response. * @param hsd: SD handle * @retval SD Card error state */ static uint32_t SDMMC_GetCmdResp2(SDIO_TypeDef *SDIOx) { uint32_t sta_reg; /* 8 is the number of required instructions cycles for the below loop statement. The SDIO_CMDTIMEOUT is expressed in ms */ register uint32_t count = SDIO_CMDTIMEOUT * (SystemCoreClock / 8U /1000U); do { if (count-- == 0U) { return SDMMC_ERROR_TIMEOUT; } sta_reg = SDIOx->STA; }while(((sta_reg & (SDIO_FLAG_CCRCFAIL | SDIO_FLAG_CMDREND | SDIO_FLAG_CTIMEOUT)) == 0U) || ((sta_reg & SDIO_FLAG_CMDACT) != 0U )); if (__SDIO_GET_FLAG(SDIOx, SDIO_FLAG_CTIMEOUT)) { __SDIO_CLEAR_FLAG(SDIOx, SDIO_FLAG_CTIMEOUT); return SDMMC_ERROR_CMD_RSP_TIMEOUT; } else if (__SDIO_GET_FLAG(SDIOx, SDIO_FLAG_CCRCFAIL)) { __SDIO_CLEAR_FLAG(SDIOx, SDIO_FLAG_CCRCFAIL); return SDMMC_ERROR_CMD_CRC_FAIL; } else { /* No error flag set */ /* Clear all the static flags */ __SDIO_CLEAR_FLAG(SDIOx, SDIO_STATIC_CMD_FLAGS); } return SDMMC_ERROR_NONE; } /** * @brief Checks for error conditions for R3 (OCR) response. * @param hsd: SD handle * @retval SD Card error state */ static uint32_t SDMMC_GetCmdResp3(SDIO_TypeDef *SDIOx) { uint32_t sta_reg; /* 8 is the number of required instructions cycles for the below loop statement. The SDIO_CMDTIMEOUT is expressed in ms */ register uint32_t count = SDIO_CMDTIMEOUT * (SystemCoreClock / 8U /1000U); do { if (count-- == 0U) { return SDMMC_ERROR_TIMEOUT; } sta_reg = SDIOx->STA; }while(((sta_reg & (SDIO_FLAG_CCRCFAIL | SDIO_FLAG_CMDREND | SDIO_FLAG_CTIMEOUT)) == 0U) || ((sta_reg & SDIO_FLAG_CMDACT) != 0U )); if(__SDIO_GET_FLAG(SDIOx, SDIO_FLAG_CTIMEOUT)) { __SDIO_CLEAR_FLAG(SDIOx, SDIO_FLAG_CTIMEOUT); return SDMMC_ERROR_CMD_RSP_TIMEOUT; } else { /* Clear all the static flags */ __SDIO_CLEAR_FLAG(SDIOx, SDIO_STATIC_CMD_FLAGS); } return SDMMC_ERROR_NONE; } /** * @brief Checks for error conditions for R6 (RCA) response. * @param hsd: SD handle * @param SD_CMD: The sent command index * @param pRCA: Pointer to the variable that will contain the SD card relative * address RCA * @retval SD Card error state */ static uint32_t SDMMC_GetCmdResp6(SDIO_TypeDef *SDIOx, uint8_t SD_CMD, uint16_t *pRCA) { uint32_t response_r1; uint32_t sta_reg; /* 8 is the number of required instructions cycles for the below loop statement. The SDIO_CMDTIMEOUT is expressed in ms */ register uint32_t count = SDIO_CMDTIMEOUT * (SystemCoreClock / 8U /1000U); do { if (count-- == 0U) { return SDMMC_ERROR_TIMEOUT; } sta_reg = SDIOx->STA; }while(((sta_reg & (SDIO_FLAG_CCRCFAIL | SDIO_FLAG_CMDREND | SDIO_FLAG_CTIMEOUT)) == 0U) || ((sta_reg & SDIO_FLAG_CMDACT) != 0U )); if(__SDIO_GET_FLAG(SDIOx, SDIO_FLAG_CTIMEOUT)) { __SDIO_CLEAR_FLAG(SDIOx, SDIO_FLAG_CTIMEOUT); return SDMMC_ERROR_CMD_RSP_TIMEOUT; } else if(__SDIO_GET_FLAG(SDIOx, SDIO_FLAG_CCRCFAIL)) { __SDIO_CLEAR_FLAG(SDIOx, SDIO_FLAG_CCRCFAIL); return SDMMC_ERROR_CMD_CRC_FAIL; } else { /* Nothing to do */ } /* Check response received is of desired command */ if(SDIO_GetCommandResponse(SDIOx) != SD_CMD) { return SDMMC_ERROR_CMD_CRC_FAIL; } /* Clear all the static flags */ __SDIO_CLEAR_FLAG(SDIOx, SDIO_STATIC_CMD_FLAGS); /* We have received response, retrieve it. */ response_r1 = SDIO_GetResponse(SDIOx, SDIO_RESP1); if((response_r1 & (SDMMC_R6_GENERAL_UNKNOWN_ERROR | SDMMC_R6_ILLEGAL_CMD | SDMMC_R6_COM_CRC_FAILED)) == SDMMC_ALLZERO) { *pRCA = (uint16_t) (response_r1 >> 16); return SDMMC_ERROR_NONE; } else if((response_r1 & SDMMC_R6_ILLEGAL_CMD) == SDMMC_R6_ILLEGAL_CMD) { return SDMMC_ERROR_ILLEGAL_CMD; } else if((response_r1 & SDMMC_R6_COM_CRC_FAILED) == SDMMC_R6_COM_CRC_FAILED) { return SDMMC_ERROR_COM_CRC_FAILED; } else { return SDMMC_ERROR_GENERAL_UNKNOWN_ERR; } } /** * @brief Checks for error conditions for R7 response. * @param hsd: SD handle * @retval SD Card error state */ static uint32_t SDMMC_GetCmdResp7(SDIO_TypeDef *SDIOx) { uint32_t sta_reg; /* 8 is the number of required instructions cycles for the below loop statement. The SDIO_CMDTIMEOUT is expressed in ms */ register uint32_t count = SDIO_CMDTIMEOUT * (SystemCoreClock / 8U /1000U); do { if (count-- == 0U) { return SDMMC_ERROR_TIMEOUT; } sta_reg = SDIOx->STA; }while(((sta_reg & (SDIO_FLAG_CCRCFAIL | SDIO_FLAG_CMDREND | SDIO_FLAG_CTIMEOUT)) == 0U) || ((sta_reg & SDIO_FLAG_CMDACT) != 0U )); if(__SDIO_GET_FLAG(SDIOx, SDIO_FLAG_CTIMEOUT)) { /* Card is SD V2.0 compliant */ __SDIO_CLEAR_FLAG(SDIOx, SDIO_FLAG_CTIMEOUT); return SDMMC_ERROR_CMD_RSP_TIMEOUT; } else if(__SDIO_GET_FLAG(SDIOx, SDIO_FLAG_CCRCFAIL)) { /* Card is SD V2.0 compliant */ __SDIO_CLEAR_FLAG(SDIOx, SDIO_FLAG_CCRCFAIL); return SDMMC_ERROR_CMD_CRC_FAIL; } else { /* Nothing to do */ } if(__SDIO_GET_FLAG(SDIOx, SDIO_FLAG_CMDREND)) { /* Card is SD V2.0 compliant */ __SDIO_CLEAR_FLAG(SDIOx, SDIO_FLAG_CMDREND); } return SDMMC_ERROR_NONE; } /** * @} */ /** * @} */ #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F401xC || STM32F401xE || STM32F411xE || STM32F446xx || STM32F469xx || STM32F479xx || STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx || STM32F413xx || STM32F423xx */ #endif /* (HAL_SD_MODULE_ENABLED) || (HAL_MMC_MODULE_ENABLED) */ /** * @} */ /** * @} */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ ================================================ FILE: sys/arch/stm32/hal/stm32f4xx_ll_sdmmc.h ================================================ /** ****************************************************************************** * @file stm32f4xx_ll_sdmmc.h * @author MCD Application Team * @version V1.7.1 * @date 14-April-2017 * @brief Header file of SDMMC HAL module. ****************************************************************************** * @attention * *

© COPYRIGHT(c) 2017 STMicroelectronics

* * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. Neither the name of STMicroelectronics nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __STM32F4xx_LL_SDMMC_H #define __STM32F4xx_LL_SDMMC_H #ifdef __cplusplus extern "C" { #endif #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) || \ defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) || \ defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F411xE) || defined(STM32F446xx) || \ defined(STM32F469xx) || defined(STM32F479xx) || defined(STM32F412Zx) || defined(STM32F412Vx) || \ defined(STM32F412Rx) || defined(STM32F412Cx) || defined(STM32F413xx) || defined(STM32F423xx) /* Includes ------------------------------------------------------------------*/ #include "stm32f4xx_hal_def.h" #include "stm32f4xx_ll_utils.h" /* LL_mDelay() */ /** @addtogroup STM32F4xx_Driver * @{ */ /** @addtogroup SDMMC_LL * @{ */ /* Exported types ------------------------------------------------------------*/ /** @defgroup SDMMC_LL_Exported_Types SDMMC_LL Exported Types * @{ */ /** * @brief SDMMC Configuration Structure definition */ typedef struct { uint32_t ClockEdge; /*!< Specifies the clock transition on which the bit capture is made. This parameter can be a value of @ref SDMMC_LL_Clock_Edge */ uint32_t ClockBypass; /*!< Specifies whether the SDMMC Clock divider bypass is enabled or disabled. This parameter can be a value of @ref SDMMC_LL_Clock_Bypass */ uint32_t ClockPowerSave; /*!< Specifies whether SDMMC Clock output is enabled or disabled when the bus is idle. This parameter can be a value of @ref SDMMC_LL_Clock_Power_Save */ uint32_t BusWide; /*!< Specifies the SDMMC bus width. This parameter can be a value of @ref SDMMC_LL_Bus_Wide */ uint32_t HardwareFlowControl; /*!< Specifies whether the SDMMC hardware flow control is enabled or disabled. This parameter can be a value of @ref SDMMC_LL_Hardware_Flow_Control */ uint32_t ClockDiv; /*!< Specifies the clock frequency of the SDMMC controller. This parameter can be a value between Min_Data = 0 and Max_Data = 255 */ }SDIO_InitTypeDef; /** * @brief SDMMC Command Control structure */ typedef struct { uint32_t Argument; /*!< Specifies the SDMMC command argument which is sent to a card as part of a command message. If a command contains an argument, it must be loaded into this register before writing the command to the command register. */ uint32_t CmdIndex; /*!< Specifies the SDMMC command index. It must be Min_Data = 0 and Max_Data = 64 */ uint32_t Response; /*!< Specifies the SDMMC response type. This parameter can be a value of @ref SDMMC_LL_Response_Type */ uint32_t WaitForInterrupt; /*!< Specifies whether SDMMC wait for interrupt request is enabled or disabled. This parameter can be a value of @ref SDMMC_LL_Wait_Interrupt_State */ uint32_t CPSM; /*!< Specifies whether SDMMC Command path state machine (CPSM) is enabled or disabled. This parameter can be a value of @ref SDMMC_LL_CPSM_State */ }SDIO_CmdInitTypeDef; /** * @brief SDMMC Data Control structure */ typedef struct { uint32_t DataTimeOut; /*!< Specifies the data timeout period in card bus clock periods. */ uint32_t DataLength; /*!< Specifies the number of data bytes to be transferred. */ uint32_t DataBlockSize; /*!< Specifies the data block size for block transfer. This parameter can be a value of @ref SDMMC_LL_Data_Block_Size */ uint32_t TransferDir; /*!< Specifies the data transfer direction, whether the transfer is a read or write. This parameter can be a value of @ref SDMMC_LL_Transfer_Direction */ uint32_t TransferMode; /*!< Specifies whether data transfer is in stream or block mode. This parameter can be a value of @ref SDMMC_LL_Transfer_Type */ uint32_t DPSM; /*!< Specifies whether SDMMC Data path state machine (DPSM) is enabled or disabled. This parameter can be a value of @ref SDMMC_LL_DPSM_State */ }SDIO_DataInitTypeDef; /** * @} */ /* Exported constants --------------------------------------------------------*/ /** @defgroup SDMMC_LL_Exported_Constants SDMMC_LL Exported Constants * @{ */ #define SDMMC_ERROR_NONE 0x00000000U /*!< No error */ #define SDMMC_ERROR_CMD_CRC_FAIL 0x00000001U /*!< Command response received (but CRC check failed) */ #define SDMMC_ERROR_DATA_CRC_FAIL 0x00000002U /*!< Data block sent/received (CRC check failed) */ #define SDMMC_ERROR_CMD_RSP_TIMEOUT 0x00000004U /*!< Command response timeout */ #define SDMMC_ERROR_DATA_TIMEOUT 0x00000008U /*!< Data timeout */ #define SDMMC_ERROR_TX_UNDERRUN 0x00000010U /*!< Transmit FIFO underrun */ #define SDMMC_ERROR_RX_OVERRUN 0x00000020U /*!< Receive FIFO overrun */ #define SDMMC_ERROR_ADDR_MISALIGNED 0x00000040U /*!< Misaligned address */ #define SDMMC_ERROR_BLOCK_LEN_ERR 0x00000080U /*!< Transferred block length is not allowed for the card or the number of transferred bytes does not match the block length */ #define SDMMC_ERROR_ERASE_SEQ_ERR 0x00000100U /*!< An error in the sequence of erase command occurs */ #define SDMMC_ERROR_BAD_ERASE_PARAM 0x00000200U /*!< An invalid selection for erase groups */ #define SDMMC_ERROR_WRITE_PROT_VIOLATION 0x00000400U /*!< Attempt to program a write protect block */ #define SDMMC_ERROR_LOCK_UNLOCK_FAILED 0x00000800U /*!< Sequence or password error has been detected in unlock command or if there was an attempt to access a locked card */ #define SDMMC_ERROR_COM_CRC_FAILED 0x00001000U /*!< CRC check of the previous command failed */ #define SDMMC_ERROR_ILLEGAL_CMD 0x00002000U /*!< Command is not legal for the card state */ #define SDMMC_ERROR_CARD_ECC_FAILED 0x00004000U /*!< Card internal ECC was applied but failed to correct the data */ #define SDMMC_ERROR_CC_ERR 0x00008000U /*!< Internal card controller error */ #define SDMMC_ERROR_GENERAL_UNKNOWN_ERR 0x00010000U /*!< General or unknown error */ #define SDMMC_ERROR_STREAM_READ_UNDERRUN 0x00020000U /*!< The card could not sustain data reading in stream rmode */ #define SDMMC_ERROR_STREAM_WRITE_OVERRUN 0x00040000U /*!< The card could not sustain data programming in stream mode */ #define SDMMC_ERROR_CID_CSD_OVERWRITE 0x00080000U /*!< CID/CSD overwrite error */ #define SDMMC_ERROR_WP_ERASE_SKIP 0x00100000U /*!< Only partial address space was erased */ #define SDMMC_ERROR_CARD_ECC_DISABLED 0x00200000U /*!< Command has been executed without using internal ECC */ #define SDMMC_ERROR_ERASE_RESET 0x00400000U /*!< Erase sequence was cleared before executing because an out of erase sequence command was received */ #define SDMMC_ERROR_AKE_SEQ_ERR 0x00800000U /*!< Error in sequence of authentication */ #define SDMMC_ERROR_INVALID_VOLTRANGE 0x01000000U /*!< Error in case of invalid voltage range */ #define SDMMC_ERROR_ADDR_OUT_OF_RANGE 0x02000000U /*!< Error when addressed block is out of range */ #define SDMMC_ERROR_REQUEST_NOT_APPLICABLE 0x04000000U /*!< Error when command request is not applicable */ #define SDMMC_ERROR_INVALID_PARAMETER 0x08000000U /*!< the used parameter is not valid */ #define SDMMC_ERROR_UNSUPPORTED_FEATURE 0x10000000U /*!< Error when feature is not insupported */ #define SDMMC_ERROR_BUSY 0x20000000U /*!< Error when transfer process is busy */ #define SDMMC_ERROR_DMA 0x40000000U /*!< Error while DMA transfer */ #define SDMMC_ERROR_TIMEOUT 0x80000000U /*!< Timeout error */ /** * @brief SDMMC Commands Index */ #define SDMMC_CMD_GO_IDLE_STATE 0U /*!< Resets the SD memory card. */ #define SDMMC_CMD_SEND_OP_COND 1U /*!< Sends host capacity support information and activates the card's initialization process. */ #define SDMMC_CMD_ALL_SEND_CID 2U /*!< Asks any card connected to the host to send the CID numbers on the CMD line. */ #define SDMMC_CMD_SET_REL_ADDR 3U /*!< Asks the card to publish a new relative address (RCA). */ #define SDMMC_CMD_SET_DSR 4U /*!< Programs the DSR of all cards. */ #define SDMMC_CMD_SDMMC_SEN_OP_COND 5U /*!< Sends host capacity support information (HCS) and asks the accessed card to send its operating condition register (OCR) content in the response on the CMD line. */ #define SDMMC_CMD_HS_SWITCH 6U /*!< Checks switchable function (mode 0) and switch card function (mode 1). */ #define SDMMC_CMD_SEL_DESEL_CARD 7U /*!< Selects the card by its own relative address and gets deselected by any other address */ #define SDMMC_CMD_HS_SEND_EXT_CSD 8U /*!< Sends SD Memory Card interface condition, which includes host supply voltage information and asks the card whether card supports voltage. */ #define SDMMC_CMD_SEND_CSD 9U /*!< Addressed card sends its card specific data (CSD) on the CMD line. */ #define SDMMC_CMD_SEND_CID 10U /*!< Addressed card sends its card identification (CID) on the CMD line. */ #define SDMMC_CMD_READ_DAT_UNTIL_STOP 11U /*!< SD card doesn't support it. */ #define SDMMC_CMD_STOP_TRANSMISSION 12U /*!< Forces the card to stop transmission. */ #define SDMMC_CMD_SEND_STATUS 13U /*!< Addressed card sends its status register. */ #define SDMMC_CMD_HS_BUSTEST_READ 14U /*!< Reserved */ #define SDMMC_CMD_GO_INACTIVE_STATE 15U /*!< Sends an addressed card into the inactive state. */ #define SDMMC_CMD_SET_BLOCKLEN 16U /*!< Sets the block length (in bytes for SDSC) for all following block commands (read, write, lock). Default block length is fixed to 512 Bytes. Not effective for SDHS and SDXC. */ #define SDMMC_CMD_READ_SINGLE_BLOCK 17U /*!< Reads single block of size selected by SET_BLOCKLEN in case of SDSC, and a block of fixed 512 bytes in case of SDHC and SDXC. */ #define SDMMC_CMD_READ_MULT_BLOCK 18U /*!< Continuously transfers data blocks from card to host until interrupted by STOP_TRANSMISSION command. */ #define SDMMC_CMD_HS_BUSTEST_WRITE 19U /*!< 64 bytes tuning pattern is sent for SDR50 and SDR104. */ #define SDMMC_CMD_WRITE_DAT_UNTIL_STOP 20U /*!< Speed class control command. */ #define SDMMC_CMD_SET_BLOCK_COUNT 23U /*!< Specify block count for CMD18 and CMD25. */ #define SDMMC_CMD_WRITE_SINGLE_BLOCK 24U /*!< Writes single block of size selected by SET_BLOCKLEN in case of SDSC, and a block of fixed 512 bytes in case of SDHC and SDXC. */ #define SDMMC_CMD_WRITE_MULT_BLOCK 25U /*!< Continuously writes blocks of data until a STOP_TRANSMISSION follows. */ #define SDMMC_CMD_PROG_CID 26U /*!< Reserved for manufacturers. */ #define SDMMC_CMD_PROG_CSD 27U /*!< Programming of the programmable bits of the CSD. */ #define SDMMC_CMD_SET_WRITE_PROT 28U /*!< Sets the write protection bit of the addressed group. */ #define SDMMC_CMD_CLR_WRITE_PROT 29U /*!< Clears the write protection bit of the addressed group. */ #define SDMMC_CMD_SEND_WRITE_PROT 30U /*!< Asks the card to send the status of the write protection bits. */ #define SDMMC_CMD_SD_ERASE_GRP_START 32U /*!< Sets the address of the first write block to be erased. (For SD card only). */ #define SDMMC_CMD_SD_ERASE_GRP_END 33U /*!< Sets the address of the last write block of the continuous range to be erased. */ #define SDMMC_CMD_ERASE_GRP_START 35U /*!< Sets the address of the first write block to be erased. Reserved for each command system set by switch function command (CMD6). */ #define SDMMC_CMD_ERASE_GRP_END 36U /*!< Sets the address of the last write block of the continuous range to be erased. Reserved for each command system set by switch function command (CMD6). */ #define SDMMC_CMD_ERASE 38U /*!< Reserved for SD security applications. */ #define SDMMC_CMD_FAST_IO 39U /*!< SD card doesn't support it (Reserved). */ #define SDMMC_CMD_GO_IRQ_STATE 40U /*!< SD card doesn't support it (Reserved). */ #define SDMMC_CMD_LOCK_UNLOCK 42U /*!< Sets/resets the password or lock/unlock the card. The size of the data block is set by the SET_BLOCK_LEN command. */ #define SDMMC_CMD_APP_CMD 55U /*!< Indicates to the card that the next command is an application specific command rather than a standard command. */ #define SDMMC_CMD_GEN_CMD 56U /*!< Used either to transfer a data block to the card or to get a data block from the card for general purpose/application specific commands. */ #define SDMMC_CMD_NO_CMD 64U /*!< No command */ /** * @brief Following commands are SD Card Specific commands. * SDMMC_APP_CMD should be sent before sending these commands. */ #define SDMMC_CMD_APP_SD_SET_BUSWIDTH 6U /*!< (ACMD6) Defines the data bus width to be used for data transfer. The allowed data bus widths are given in SCR register. */ #define SDMMC_CMD_SD_APP_STATUS 13U /*!< (ACMD13) Sends the SD status. */ #define SDMMC_CMD_SD_APP_SEND_NUM_WRITE_BLOCKS 22U /*!< (ACMD22) Sends the number of the written (without errors) write blocks. Responds with 32bit+CRC data block. */ #define SDMMC_CMD_SD_APP_OP_COND 41U /*!< (ACMD41) Sends host capacity support information (HCS) and asks the accessed card to send its operating condition register (OCR) content in the response on the CMD line. */ #define SDMMC_CMD_SD_APP_SET_CLR_CARD_DETECT 42U /*!< (ACMD42) Connect/Disconnect the 50 KOhm pull-up resistor on CD/DAT3 (pin 1) of the card */ #define SDMMC_CMD_SD_APP_SEND_SCR 51U /*!< Reads the SD Configuration Register (SCR). */ #define SDMMC_CMD_SDMMC_RW_DIRECT 52U /*!< For SD I/O card only, reserved for security specification. */ #define SDMMC_CMD_SDMMC_RW_EXTENDED 53U /*!< For SD I/O card only, reserved for security specification. */ /** * @brief Following commands are SD Card Specific security commands. * SDMMC_CMD_APP_CMD should be sent before sending these commands. */ #define SDMMC_CMD_SD_APP_GET_MKB 43U #define SDMMC_CMD_SD_APP_GET_MID 44U #define SDMMC_CMD_SD_APP_SET_CER_RN1 45U #define SDMMC_CMD_SD_APP_GET_CER_RN2 46U #define SDMMC_CMD_SD_APP_SET_CER_RES2 47U #define SDMMC_CMD_SD_APP_GET_CER_RES1 48U #define SDMMC_CMD_SD_APP_SECURE_READ_MULTIPLE_BLOCK 18U #define SDMMC_CMD_SD_APP_SECURE_WRITE_MULTIPLE_BLOCK 25U #define SDMMC_CMD_SD_APP_SECURE_ERASE 38U #define SDMMC_CMD_SD_APP_CHANGE_SECURE_AREA 49U #define SDMMC_CMD_SD_APP_SECURE_WRITE_MKB 48U /** * @brief Masks for errors Card Status R1 (OCR Register) */ #define SDMMC_OCR_ADDR_OUT_OF_RANGE 0x80000000U #define SDMMC_OCR_ADDR_MISALIGNED 0x40000000U #define SDMMC_OCR_BLOCK_LEN_ERR 0x20000000U #define SDMMC_OCR_ERASE_SEQ_ERR 0x10000000U #define SDMMC_OCR_BAD_ERASE_PARAM 0x08000000U #define SDMMC_OCR_WRITE_PROT_VIOLATION 0x04000000U #define SDMMC_OCR_LOCK_UNLOCK_FAILED 0x01000000U #define SDMMC_OCR_COM_CRC_FAILED 0x00800000U #define SDMMC_OCR_ILLEGAL_CMD 0x00400000U #define SDMMC_OCR_CARD_ECC_FAILED 0x00200000U #define SDMMC_OCR_CC_ERROR 0x00100000U #define SDMMC_OCR_GENERAL_UNKNOWN_ERROR 0x00080000U #define SDMMC_OCR_STREAM_READ_UNDERRUN 0x00040000U #define SDMMC_OCR_STREAM_WRITE_OVERRUN 0x00020000U #define SDMMC_OCR_CID_CSD_OVERWRITE 0x00010000U #define SDMMC_OCR_WP_ERASE_SKIP 0x00008000U #define SDMMC_OCR_CARD_ECC_DISABLED 0x00004000U #define SDMMC_OCR_ERASE_RESET 0x00002000U #define SDMMC_OCR_AKE_SEQ_ERROR 0x00000008U #define SDMMC_OCR_ERRORBITS 0xFDFFE008U /** * @brief Masks for R6 Response */ #define SDMMC_R6_GENERAL_UNKNOWN_ERROR 0x00002000U #define SDMMC_R6_ILLEGAL_CMD 0x00004000U #define SDMMC_R6_COM_CRC_FAILED 0x00008000U #define SDMMC_VOLTAGE_WINDOW_SD 0x80100000U #define SDMMC_HIGH_CAPACITY 0x40000000U #define SDMMC_STD_CAPACITY 0x00000000U #define SDMMC_CHECK_PATTERN 0x000001AAU #define SD_SWITCH_1_8V_CAPACITY 0x01000000U #define SDMMC_MAX_VOLT_TRIAL 0x0000FFFFU #define SDMMC_MAX_TRIAL 0x0000FFFFU #define SDMMC_ALLZERO 0x00000000U #define SDMMC_WIDE_BUS_SUPPORT 0x00040000U #define SDMMC_SINGLE_BUS_SUPPORT 0x00010000U #define SDMMC_CARD_LOCKED 0x02000000U #define SDMMC_DATATIMEOUT 0xFFFFFFFFU #define SDMMC_0TO7BITS 0x000000FFU #define SDMMC_8TO15BITS 0x0000FF00U #define SDMMC_16TO23BITS 0x00FF0000U #define SDMMC_24TO31BITS 0xFF000000U #define SDMMC_MAX_DATA_LENGTH 0x01FFFFFFU #define SDMMC_HALFFIFO 0x00000008U #define SDMMC_HALFFIFOBYTES 0x00000020U /** * @brief Command Class supported */ #define SDIO_CCCC_ERASE 0x00000020U #define SDIO_CMDTIMEOUT 5000U /* Command send and response timeout */ #define SDIO_MAXERASETIMEOUT 63000U /* Max erase Timeout 63 s */ #define SDIO_STOPTRANSFERTIMEOUT 100000000U /* Timeout for STOP TRANSMISSION command */ /** @defgroup SDIO_LL_Clock_Edge Clock Edge * @{ */ #define SDIO_CLOCK_EDGE_RISING 0x00000000U #define SDIO_CLOCK_EDGE_FALLING SDIO_CLKCR_NEGEDGE #define IS_SDIO_CLOCK_EDGE(EDGE) (((EDGE) == SDIO_CLOCK_EDGE_RISING) || \ ((EDGE) == SDIO_CLOCK_EDGE_FALLING)) /** * @} */ /** @defgroup SDIO_LL_Clock_Bypass Clock Bypass * @{ */ #define SDIO_CLOCK_BYPASS_DISABLE 0x00000000U #define SDIO_CLOCK_BYPASS_ENABLE SDIO_CLKCR_BYPASS #define IS_SDIO_CLOCK_BYPASS(BYPASS) (((BYPASS) == SDIO_CLOCK_BYPASS_DISABLE) || \ ((BYPASS) == SDIO_CLOCK_BYPASS_ENABLE)) /** * @} */ /** @defgroup SDIO_LL_Clock_Power_Save Clock Power Saving * @{ */ #define SDIO_CLOCK_POWER_SAVE_DISABLE 0x00000000U #define SDIO_CLOCK_POWER_SAVE_ENABLE SDIO_CLKCR_PWRSAV #define IS_SDIO_CLOCK_POWER_SAVE(SAVE) (((SAVE) == SDIO_CLOCK_POWER_SAVE_DISABLE) || \ ((SAVE) == SDIO_CLOCK_POWER_SAVE_ENABLE)) /** * @} */ /** @defgroup SDIO_LL_Bus_Wide Bus Width * @{ */ #define SDIO_BUS_WIDE_1B 0x00000000U #define SDIO_BUS_WIDE_4B SDIO_CLKCR_WIDBUS_0 #define SDIO_BUS_WIDE_8B SDIO_CLKCR_WIDBUS_1 #define IS_SDIO_BUS_WIDE(WIDE) (((WIDE) == SDIO_BUS_WIDE_1B) || \ ((WIDE) == SDIO_BUS_WIDE_4B) || \ ((WIDE) == SDIO_BUS_WIDE_8B)) /** * @} */ /** @defgroup SDIO_LL_Hardware_Flow_Control Hardware Flow Control * @{ */ #define SDIO_HARDWARE_FLOW_CONTROL_DISABLE 0x00000000U #define SDIO_HARDWARE_FLOW_CONTROL_ENABLE SDIO_CLKCR_HWFC_EN #define IS_SDIO_HARDWARE_FLOW_CONTROL(CONTROL) (((CONTROL) == SDIO_HARDWARE_FLOW_CONTROL_DISABLE) || \ ((CONTROL) == SDIO_HARDWARE_FLOW_CONTROL_ENABLE)) /** * @} */ /** @defgroup SDIO_LL_Clock_Division Clock Division * @{ */ #define IS_SDIO_CLKDIV(DIV) ((DIV) <= 0xFFU) /** * @} */ /** @defgroup SDIO_LL_Command_Index Command Index * @{ */ #define IS_SDIO_CMD_INDEX(INDEX) ((INDEX) < 0x40U) /** * @} */ /** @defgroup SDIO_LL_Response_Type Response Type * @{ */ #define SDIO_RESPONSE_NO 0x00000000U #define SDIO_RESPONSE_SHORT SDIO_CMD_WAITRESP_0 #define SDIO_RESPONSE_LONG SDIO_CMD_WAITRESP #define IS_SDIO_RESPONSE(RESPONSE) (((RESPONSE) == SDIO_RESPONSE_NO) || \ ((RESPONSE) == SDIO_RESPONSE_SHORT) || \ ((RESPONSE) == SDIO_RESPONSE_LONG)) /** * @} */ /** @defgroup SDIO_LL_Wait_Interrupt_State Wait Interrupt * @{ */ #define SDIO_WAIT_NO 0x00000000U #define SDIO_WAIT_IT SDIO_CMD_WAITINT #define SDIO_WAIT_PEND SDIO_CMD_WAITPEND #define IS_SDIO_WAIT(WAIT) (((WAIT) == SDIO_WAIT_NO) || \ ((WAIT) == SDIO_WAIT_IT) || \ ((WAIT) == SDIO_WAIT_PEND)) /** * @} */ /** @defgroup SDIO_LL_CPSM_State CPSM State * @{ */ #define SDIO_CPSM_DISABLE 0x00000000U #define SDIO_CPSM_ENABLE SDIO_CMD_CPSMEN #define IS_SDIO_CPSM(CPSM) (((CPSM) == SDIO_CPSM_DISABLE) || \ ((CPSM) == SDIO_CPSM_ENABLE)) /** * @} */ /** @defgroup SDIO_LL_Response_Registers Response Register * @{ */ #define SDIO_RESP1 0x00000000U #define SDIO_RESP2 0x00000004U #define SDIO_RESP3 0x00000008U #define SDIO_RESP4 0x0000000CU #define IS_SDIO_RESP(RESP) (((RESP) == SDIO_RESP1) || \ ((RESP) == SDIO_RESP2) || \ ((RESP) == SDIO_RESP3) || \ ((RESP) == SDIO_RESP4)) /** * @} */ /** @defgroup SDIO_LL_Data_Length Data Lenght * @{ */ #define IS_SDIO_DATA_LENGTH(LENGTH) ((LENGTH) <= 0x01FFFFFFU) /** * @} */ /** @defgroup SDIO_LL_Data_Block_Size Data Block Size * @{ */ #define SDIO_DATABLOCK_SIZE_1B 0x00000000U #define SDIO_DATABLOCK_SIZE_2B SDIO_DCTRL_DBLOCKSIZE_0 #define SDIO_DATABLOCK_SIZE_4B SDIO_DCTRL_DBLOCKSIZE_1 #define SDIO_DATABLOCK_SIZE_8B (SDIO_DCTRL_DBLOCKSIZE_0|SDIO_DCTRL_DBLOCKSIZE_1) #define SDIO_DATABLOCK_SIZE_16B SDIO_DCTRL_DBLOCKSIZE_2 #define SDIO_DATABLOCK_SIZE_32B (SDIO_DCTRL_DBLOCKSIZE_0|SDIO_DCTRL_DBLOCKSIZE_2) #define SDIO_DATABLOCK_SIZE_64B (SDIO_DCTRL_DBLOCKSIZE_1|SDIO_DCTRL_DBLOCKSIZE_2) #define SDIO_DATABLOCK_SIZE_128B (SDIO_DCTRL_DBLOCKSIZE_0|SDIO_DCTRL_DBLOCKSIZE_1|SDIO_DCTRL_DBLOCKSIZE_2) #define SDIO_DATABLOCK_SIZE_256B SDIO_DCTRL_DBLOCKSIZE_3 #define SDIO_DATABLOCK_SIZE_512B (SDIO_DCTRL_DBLOCKSIZE_0|SDIO_DCTRL_DBLOCKSIZE_3) #define SDIO_DATABLOCK_SIZE_1024B (SDIO_DCTRL_DBLOCKSIZE_1|SDIO_DCTRL_DBLOCKSIZE_3) #define SDIO_DATABLOCK_SIZE_2048B (SDIO_DCTRL_DBLOCKSIZE_0|SDIO_DCTRL_DBLOCKSIZE_1|SDIO_DCTRL_DBLOCKSIZE_3) #define SDIO_DATABLOCK_SIZE_4096B (SDIO_DCTRL_DBLOCKSIZE_2|SDIO_DCTRL_DBLOCKSIZE_3) #define SDIO_DATABLOCK_SIZE_8192B (SDIO_DCTRL_DBLOCKSIZE_0|SDIO_DCTRL_DBLOCKSIZE_2|SDIO_DCTRL_DBLOCKSIZE_3) #define SDIO_DATABLOCK_SIZE_16384B (SDIO_DCTRL_DBLOCKSIZE_1|SDIO_DCTRL_DBLOCKSIZE_2|SDIO_DCTRL_DBLOCKSIZE_3) #define IS_SDIO_BLOCK_SIZE(SIZE) (((SIZE) == SDIO_DATABLOCK_SIZE_1B) || \ ((SIZE) == SDIO_DATABLOCK_SIZE_2B) || \ ((SIZE) == SDIO_DATABLOCK_SIZE_4B) || \ ((SIZE) == SDIO_DATABLOCK_SIZE_8B) || \ ((SIZE) == SDIO_DATABLOCK_SIZE_16B) || \ ((SIZE) == SDIO_DATABLOCK_SIZE_32B) || \ ((SIZE) == SDIO_DATABLOCK_SIZE_64B) || \ ((SIZE) == SDIO_DATABLOCK_SIZE_128B) || \ ((SIZE) == SDIO_DATABLOCK_SIZE_256B) || \ ((SIZE) == SDIO_DATABLOCK_SIZE_512B) || \ ((SIZE) == SDIO_DATABLOCK_SIZE_1024B) || \ ((SIZE) == SDIO_DATABLOCK_SIZE_2048B) || \ ((SIZE) == SDIO_DATABLOCK_SIZE_4096B) || \ ((SIZE) == SDIO_DATABLOCK_SIZE_8192B) || \ ((SIZE) == SDIO_DATABLOCK_SIZE_16384B)) /** * @} */ /** @defgroup SDIO_LL_Transfer_Direction Transfer Direction * @{ */ #define SDIO_TRANSFER_DIR_TO_CARD 0x00000000U #define SDIO_TRANSFER_DIR_TO_SDIO SDIO_DCTRL_DTDIR #define IS_SDIO_TRANSFER_DIR(DIR) (((DIR) == SDIO_TRANSFER_DIR_TO_CARD) || \ ((DIR) == SDIO_TRANSFER_DIR_TO_SDIO)) /** * @} */ /** @defgroup SDIO_LL_Transfer_Type Transfer Type * @{ */ #define SDIO_TRANSFER_MODE_BLOCK 0x00000000U #define SDIO_TRANSFER_MODE_STREAM SDIO_DCTRL_DTMODE #define IS_SDIO_TRANSFER_MODE(MODE) (((MODE) == SDIO_TRANSFER_MODE_BLOCK) || \ ((MODE) == SDIO_TRANSFER_MODE_STREAM)) /** * @} */ /** @defgroup SDIO_LL_DPSM_State DPSM State * @{ */ #define SDIO_DPSM_DISABLE 0x00000000U #define SDIO_DPSM_ENABLE SDIO_DCTRL_DTEN #define IS_SDIO_DPSM(DPSM) (((DPSM) == SDIO_DPSM_DISABLE) ||\ ((DPSM) == SDIO_DPSM_ENABLE)) /** * @} */ /** @defgroup SDIO_LL_Read_Wait_Mode Read Wait Mode * @{ */ #define SDIO_READ_WAIT_MODE_DATA2 0x00000000U #define SDIO_READ_WAIT_MODE_CLK (SDIO_DCTRL_RWMOD) #define IS_SDIO_READWAIT_MODE(MODE) (((MODE) == SDIO_READ_WAIT_MODE_CLK) || \ ((MODE) == SDIO_READ_WAIT_MODE_DATA2)) /** * @} */ /** @defgroup SDIO_LL_Interrupt_sources Interrupt Sources * @{ */ #define SDIO_IT_CCRCFAIL SDIO_MASK_CCRCFAILIE #define SDIO_IT_DCRCFAIL SDIO_MASK_DCRCFAILIE #define SDIO_IT_CTIMEOUT SDIO_MASK_CTIMEOUTIE #define SDIO_IT_DTIMEOUT SDIO_MASK_DTIMEOUTIE #define SDIO_IT_TXUNDERR SDIO_MASK_TXUNDERRIE #define SDIO_IT_RXOVERR SDIO_MASK_RXOVERRIE #define SDIO_IT_CMDREND SDIO_MASK_CMDRENDIE #define SDIO_IT_CMDSENT SDIO_MASK_CMDSENTIE #define SDIO_IT_DATAEND SDIO_MASK_DATAENDIE #if defined(SDIO_STA_STBITERR) #define SDIO_IT_STBITERR SDIO_MASK_STBITERRIE #endif #define SDIO_IT_DBCKEND SDIO_MASK_DBCKENDIE #define SDIO_IT_CMDACT SDIO_MASK_CMDACTIE #define SDIO_IT_TXACT SDIO_MASK_TXACTIE #define SDIO_IT_RXACT SDIO_MASK_RXACTIE #define SDIO_IT_TXFIFOHE SDIO_MASK_TXFIFOHEIE #define SDIO_IT_RXFIFOHF SDIO_MASK_RXFIFOHFIE #define SDIO_IT_TXFIFOF SDIO_MASK_TXFIFOFIE #define SDIO_IT_RXFIFOF SDIO_MASK_RXFIFOFIE #define SDIO_IT_TXFIFOE SDIO_MASK_TXFIFOEIE #define SDIO_IT_RXFIFOE SDIO_MASK_RXFIFOEIE #define SDIO_IT_TXDAVL SDIO_MASK_TXDAVLIE #define SDIO_IT_RXDAVL SDIO_MASK_RXDAVLIE #define SDIO_IT_SDIOIT SDIO_MASK_SDIOITIE #if defined(SDIO_CMD_CEATACMD) #define SDIO_IT_CEATAEND SDIO_MASK_CEATAENDIE #endif /** * @} */ /** @defgroup SDIO_LL_Flags Flags * @{ */ #define SDIO_FLAG_CCRCFAIL SDIO_STA_CCRCFAIL #define SDIO_FLAG_DCRCFAIL SDIO_STA_DCRCFAIL #define SDIO_FLAG_CTIMEOUT SDIO_STA_CTIMEOUT #define SDIO_FLAG_DTIMEOUT SDIO_STA_DTIMEOUT #define SDIO_FLAG_TXUNDERR SDIO_STA_TXUNDERR #define SDIO_FLAG_RXOVERR SDIO_STA_RXOVERR #define SDIO_FLAG_CMDREND SDIO_STA_CMDREND #define SDIO_FLAG_CMDSENT SDIO_STA_CMDSENT #define SDIO_FLAG_DATAEND SDIO_STA_DATAEND #if defined(SDIO_STA_STBITERR) #define SDIO_FLAG_STBITERR SDIO_STA_STBITERR #endif #define SDIO_FLAG_DBCKEND SDIO_STA_DBCKEND #define SDIO_FLAG_CMDACT SDIO_STA_CMDACT #define SDIO_FLAG_TXACT SDIO_STA_TXACT #define SDIO_FLAG_RXACT SDIO_STA_RXACT #define SDIO_FLAG_TXFIFOHE SDIO_STA_TXFIFOHE #define SDIO_FLAG_RXFIFOHF SDIO_STA_RXFIFOHF #define SDIO_FLAG_TXFIFOF SDIO_STA_TXFIFOF #define SDIO_FLAG_RXFIFOF SDIO_STA_RXFIFOF #define SDIO_FLAG_TXFIFOE SDIO_STA_TXFIFOE #define SDIO_FLAG_RXFIFOE SDIO_STA_RXFIFOE #define SDIO_FLAG_TXDAVL SDIO_STA_TXDAVL #define SDIO_FLAG_RXDAVL SDIO_STA_RXDAVL #define SDIO_FLAG_SDIOIT SDIO_STA_SDIOIT #if defined(SDIO_CMD_CEATACMD) #define SDIO_FLAG_CEATAEND SDIO_STA_CEATAEND #endif #define SDIO_STATIC_FLAGS ((uint32_t)(SDIO_FLAG_CCRCFAIL | SDIO_FLAG_DCRCFAIL | SDIO_FLAG_CTIMEOUT |\ SDIO_FLAG_DTIMEOUT | SDIO_FLAG_TXUNDERR | SDIO_FLAG_RXOVERR |\ SDIO_FLAG_CMDREND | SDIO_FLAG_CMDSENT | SDIO_FLAG_DATAEND |\ SDIO_FLAG_DBCKEND | SDIO_FLAG_SDIOIT)) #define SDIO_STATIC_CMD_FLAGS ((uint32_t)(SDIO_FLAG_CCRCFAIL | SDIO_FLAG_CTIMEOUT | SDIO_FLAG_CMDREND |\ SDIO_FLAG_CMDSENT)) #define SDIO_STATIC_DATA_FLAGS ((uint32_t)(SDIO_FLAG_DCRCFAIL | SDIO_FLAG_DTIMEOUT | SDIO_FLAG_TXUNDERR |\ SDIO_FLAG_RXOVERR | SDIO_FLAG_DATAEND | SDIO_FLAG_DBCKEND)) /** * @} */ /** * @} */ /* Exported macro ------------------------------------------------------------*/ /** @defgroup SDIO_LL_Exported_macros SDIO_LL Exported Macros * @{ */ /** @defgroup SDMMC_LL_Alias_Region Bit Address in the alias region * @{ */ /* ------------ SDIO registers bit address in the alias region -------------- */ #define SDIO_OFFSET (SDIO_BASE - PERIPH_BASE) /* --- CLKCR Register ---*/ /* Alias word address of CLKEN bit */ #define CLKCR_OFFSET (SDIO_OFFSET + 0x04U) #define CLKEN_BITNUMBER 0x08U #define CLKCR_CLKEN_BB (PERIPH_BB_BASE + (CLKCR_OFFSET * 32U) + (CLKEN_BITNUMBER * 4U)) /* --- CMD Register ---*/ /* Alias word address of SDIOSUSPEND bit */ #define CMD_OFFSET (SDIO_OFFSET + 0x0CU) #define SDIOSUSPEND_BITNUMBER 0x0BU #define CMD_SDIOSUSPEND_BB (PERIPH_BB_BASE + (CMD_OFFSET * 32U) + (SDIOSUSPEND_BITNUMBER * 4U)) /* Alias word address of ENCMDCOMPL bit */ #define ENCMDCOMPL_BITNUMBER 0x0CU #define CMD_ENCMDCOMPL_BB (PERIPH_BB_BASE + (CMD_OFFSET * 32U) + (ENCMDCOMPL_BITNUMBER * 4U)) /* Alias word address of NIEN bit */ #define NIEN_BITNUMBER 0x0DU #define CMD_NIEN_BB (PERIPH_BB_BASE + (CMD_OFFSET * 32U) + (NIEN_BITNUMBER * 4U)) /* Alias word address of ATACMD bit */ #define ATACMD_BITNUMBER 0x0EU #define CMD_ATACMD_BB (PERIPH_BB_BASE + (CMD_OFFSET * 32U) + (ATACMD_BITNUMBER * 4U)) /* --- DCTRL Register ---*/ /* Alias word address of DMAEN bit */ #define DCTRL_OFFSET (SDIO_OFFSET + 0x2CU) #define DMAEN_BITNUMBER 0x03U #define DCTRL_DMAEN_BB (PERIPH_BB_BASE + (DCTRL_OFFSET * 32U) + (DMAEN_BITNUMBER * 4U)) /* Alias word address of RWSTART bit */ #define RWSTART_BITNUMBER 0x08U #define DCTRL_RWSTART_BB (PERIPH_BB_BASE + (DCTRL_OFFSET * 32U) + (RWSTART_BITNUMBER * 4U)) /* Alias word address of RWSTOP bit */ #define RWSTOP_BITNUMBER 0x09U #define DCTRL_RWSTOP_BB (PERIPH_BB_BASE + (DCTRL_OFFSET * 32U) + (RWSTOP_BITNUMBER * 4U)) /* Alias word address of RWMOD bit */ #define RWMOD_BITNUMBER 0x0AU #define DCTRL_RWMOD_BB (PERIPH_BB_BASE + (DCTRL_OFFSET * 32U) + (RWMOD_BITNUMBER * 4U)) /* Alias word address of SDIOEN bit */ #define SDIOEN_BITNUMBER 0x0BU #define DCTRL_SDIOEN_BB (PERIPH_BB_BASE + (DCTRL_OFFSET * 32U) + (SDIOEN_BITNUMBER * 4U)) /** * @} */ /** @defgroup SDIO_LL_Register Bits And Addresses Definitions * @brief SDIO_LL registers bit address in the alias region * @{ */ /* ---------------------- SDIO registers bit mask --------------------------- */ /* --- CLKCR Register ---*/ /* CLKCR register clear mask */ #define CLKCR_CLEAR_MASK ((uint32_t)(SDIO_CLKCR_CLKDIV | SDIO_CLKCR_PWRSAV |\ SDIO_CLKCR_BYPASS | SDIO_CLKCR_WIDBUS |\ SDIO_CLKCR_NEGEDGE | SDIO_CLKCR_HWFC_EN)) /* --- DCTRL Register ---*/ /* SDIO DCTRL Clear Mask */ #define DCTRL_CLEAR_MASK ((uint32_t)(SDIO_DCTRL_DTEN | SDIO_DCTRL_DTDIR |\ SDIO_DCTRL_DTMODE | SDIO_DCTRL_DBLOCKSIZE)) /* --- CMD Register ---*/ /* CMD Register clear mask */ #define CMD_CLEAR_MASK ((uint32_t)(SDIO_CMD_CMDINDEX | SDIO_CMD_WAITRESP |\ SDIO_CMD_WAITINT | SDIO_CMD_WAITPEND |\ SDIO_CMD_CPSMEN | SDIO_CMD_SDIOSUSPEND)) /* SDIO Initialization Frequency (400KHz max) */ #define SDIO_INIT_CLK_DIV ((uint8_t)0x76) /* 48MHz / (SDMMC_INIT_CLK_DIV + 2) < 400KHz */ /* SDIO Data Transfer Frequency (25MHz max) */ #define SDIO_TRANSFER_CLK_DIV ((uint8_t)0x0) /* 48MHz / (SDMMC_TRANSFER_CLK_DIV + 2) < 25MHz */ /** * @} */ /** @defgroup SDIO_LL_Interrupt_Clock Interrupt And Clock Configuration * @brief macros to handle interrupts and specific clock configurations * @{ */ /** * @brief Enable the SDIO device. * @param __INSTANCE__: SDIO Instance * @retval None */ #define __SDIO_ENABLE(__INSTANCE__) (*(__IO uint32_t *)CLKCR_CLKEN_BB = ENABLE) /** * @brief Disable the SDIO device. * @param __INSTANCE__: SDIO Instance * @retval None */ #define __SDIO_DISABLE(__INSTANCE__) (*(__IO uint32_t *)CLKCR_CLKEN_BB = DISABLE) /** * @brief Enable the SDIO DMA transfer. * @param __INSTANCE__: SDIO Instance * @retval None */ #define __SDIO_DMA_ENABLE(__INSTANCE__) (*(__IO uint32_t *)DCTRL_DMAEN_BB = ENABLE) /** * @brief Disable the SDIO DMA transfer. * @param __INSTANCE__: SDIO Instance * @retval None */ #define __SDIO_DMA_DISABLE(__INSTANCE__) (*(__IO uint32_t *)DCTRL_DMAEN_BB = DISABLE) /** * @brief Enable the SDIO device interrupt. * @param __INSTANCE__ : Pointer to SDIO register base * @param __INTERRUPT__ : specifies the SDIO interrupt sources to be enabled. * This parameter can be one or a combination of the following values: * @arg SDIO_IT_CCRCFAIL: Command response received (CRC check failed) interrupt * @arg SDIO_IT_DCRCFAIL: Data block sent/received (CRC check failed) interrupt * @arg SDIO_IT_CTIMEOUT: Command response timeout interrupt * @arg SDIO_IT_DTIMEOUT: Data timeout interrupt * @arg SDIO_IT_TXUNDERR: Transmit FIFO underrun error interrupt * @arg SDIO_IT_RXOVERR: Received FIFO overrun error interrupt * @arg SDIO_IT_CMDREND: Command response received (CRC check passed) interrupt * @arg SDIO_IT_CMDSENT: Command sent (no response required) interrupt * @arg SDIO_IT_DATAEND: Data end (data counter, DATACOUNT, is zero) interrupt * @arg SDIO_IT_DBCKEND: Data block sent/received (CRC check passed) interrupt * @arg SDIO_IT_CMDACT: Command transfer in progress interrupt * @arg SDIO_IT_TXACT: Data transmit in progress interrupt * @arg SDIO_IT_RXACT: Data receive in progress interrupt * @arg SDIO_IT_TXFIFOHE: Transmit FIFO Half Empty interrupt * @arg SDIO_IT_RXFIFOHF: Receive FIFO Half Full interrupt * @arg SDIO_IT_TXFIFOF: Transmit FIFO full interrupt * @arg SDIO_IT_RXFIFOF: Receive FIFO full interrupt * @arg SDIO_IT_TXFIFOE: Transmit FIFO empty interrupt * @arg SDIO_IT_RXFIFOE: Receive FIFO empty interrupt * @arg SDIO_IT_TXDAVL: Data available in transmit FIFO interrupt * @arg SDIO_IT_RXDAVL: Data available in receive FIFO interrupt * @arg SDIO_IT_SDIOIT: SDIO interrupt received interrupt * @retval None */ #define __SDIO_ENABLE_IT(__INSTANCE__, __INTERRUPT__) ((__INSTANCE__)->MASK |= (__INTERRUPT__)) /** * @brief Disable the SDIO device interrupt. * @param __INSTANCE__ : Pointer to SDIO register base * @param __INTERRUPT__ : specifies the SDIO interrupt sources to be disabled. * This parameter can be one or a combination of the following values: * @arg SDIO_IT_CCRCFAIL: Command response received (CRC check failed) interrupt * @arg SDIO_IT_DCRCFAIL: Data block sent/received (CRC check failed) interrupt * @arg SDIO_IT_CTIMEOUT: Command response timeout interrupt * @arg SDIO_IT_DTIMEOUT: Data timeout interrupt * @arg SDIO_IT_TXUNDERR: Transmit FIFO underrun error interrupt * @arg SDIO_IT_RXOVERR: Received FIFO overrun error interrupt * @arg SDIO_IT_CMDREND: Command response received (CRC check passed) interrupt * @arg SDIO_IT_CMDSENT: Command sent (no response required) interrupt * @arg SDIO_IT_DATAEND: Data end (data counter, DATACOUNT, is zero) interrupt * @arg SDIO_IT_DBCKEND: Data block sent/received (CRC check passed) interrupt * @arg SDIO_IT_CMDACT: Command transfer in progress interrupt * @arg SDIO_IT_TXACT: Data transmit in progress interrupt * @arg SDIO_IT_RXACT: Data receive in progress interrupt * @arg SDIO_IT_TXFIFOHE: Transmit FIFO Half Empty interrupt * @arg SDIO_IT_RXFIFOHF: Receive FIFO Half Full interrupt * @arg SDIO_IT_TXFIFOF: Transmit FIFO full interrupt * @arg SDIO_IT_RXFIFOF: Receive FIFO full interrupt * @arg SDIO_IT_TXFIFOE: Transmit FIFO empty interrupt * @arg SDIO_IT_RXFIFOE: Receive FIFO empty interrupt * @arg SDIO_IT_TXDAVL: Data available in transmit FIFO interrupt * @arg SDIO_IT_RXDAVL: Data available in receive FIFO interrupt * @arg SDIO_IT_SDIOIT: SDIO interrupt received interrupt * @retval None */ #define __SDIO_DISABLE_IT(__INSTANCE__, __INTERRUPT__) ((__INSTANCE__)->MASK &= ~(__INTERRUPT__)) /** * @brief Checks whether the specified SDIO flag is set or not. * @param __INSTANCE__ : Pointer to SDIO register base * @param __FLAG__: specifies the flag to check. * This parameter can be one of the following values: * @arg SDIO_FLAG_CCRCFAIL: Command response received (CRC check failed) * @arg SDIO_FLAG_DCRCFAIL: Data block sent/received (CRC check failed) * @arg SDIO_FLAG_CTIMEOUT: Command response timeout * @arg SDIO_FLAG_DTIMEOUT: Data timeout * @arg SDIO_FLAG_TXUNDERR: Transmit FIFO underrun error * @arg SDIO_FLAG_RXOVERR: Received FIFO overrun error * @arg SDIO_FLAG_CMDREND: Command response received (CRC check passed) * @arg SDIO_FLAG_CMDSENT: Command sent (no response required) * @arg SDIO_FLAG_DATAEND: Data end (data counter, DATACOUNT, is zero) * @arg SDIO_FLAG_DBCKEND: Data block sent/received (CRC check passed) * @arg SDIO_FLAG_CMDACT: Command transfer in progress * @arg SDIO_FLAG_TXACT: Data transmit in progress * @arg SDIO_FLAG_RXACT: Data receive in progress * @arg SDIO_FLAG_TXFIFOHE: Transmit FIFO Half Empty * @arg SDIO_FLAG_RXFIFOHF: Receive FIFO Half Full * @arg SDIO_FLAG_TXFIFOF: Transmit FIFO full * @arg SDIO_FLAG_RXFIFOF: Receive FIFO full * @arg SDIO_FLAG_TXFIFOE: Transmit FIFO empty * @arg SDIO_FLAG_RXFIFOE: Receive FIFO empty * @arg SDIO_FLAG_TXDAVL: Data available in transmit FIFO * @arg SDIO_FLAG_RXDAVL: Data available in receive FIFO * @arg SDIO_FLAG_SDIOIT: SDIO interrupt received * @retval The new state of SDIO_FLAG (SET or RESET). */ #define __SDIO_GET_FLAG(__INSTANCE__, __FLAG__) (((__INSTANCE__)->STA &(__FLAG__)) != 0U) /** * @brief Clears the SDIO pending flags. * @param __INSTANCE__ : Pointer to SDIO register base * @param __FLAG__: specifies the flag to clear. * This parameter can be one or a combination of the following values: * @arg SDIO_FLAG_CCRCFAIL: Command response received (CRC check failed) * @arg SDIO_FLAG_DCRCFAIL: Data block sent/received (CRC check failed) * @arg SDIO_FLAG_CTIMEOUT: Command response timeout * @arg SDIO_FLAG_DTIMEOUT: Data timeout * @arg SDIO_FLAG_TXUNDERR: Transmit FIFO underrun error * @arg SDIO_FLAG_RXOVERR: Received FIFO overrun error * @arg SDIO_FLAG_CMDREND: Command response received (CRC check passed) * @arg SDIO_FLAG_CMDSENT: Command sent (no response required) * @arg SDIO_FLAG_DATAEND: Data end (data counter, DATACOUNT, is zero) * @arg SDIO_FLAG_DBCKEND: Data block sent/received (CRC check passed) * @arg SDIO_FLAG_SDIOIT: SDIO interrupt received * @retval None */ #define __SDIO_CLEAR_FLAG(__INSTANCE__, __FLAG__) ((__INSTANCE__)->ICR = (__FLAG__)) /** * @brief Checks whether the specified SDIO interrupt has occurred or not. * @param __INSTANCE__ : Pointer to SDIO register base * @param __INTERRUPT__: specifies the SDIO interrupt source to check. * This parameter can be one of the following values: * @arg SDIO_IT_CCRCFAIL: Command response received (CRC check failed) interrupt * @arg SDIO_IT_DCRCFAIL: Data block sent/received (CRC check failed) interrupt * @arg SDIO_IT_CTIMEOUT: Command response timeout interrupt * @arg SDIO_IT_DTIMEOUT: Data timeout interrupt * @arg SDIO_IT_TXUNDERR: Transmit FIFO underrun error interrupt * @arg SDIO_IT_RXOVERR: Received FIFO overrun error interrupt * @arg SDIO_IT_CMDREND: Command response received (CRC check passed) interrupt * @arg SDIO_IT_CMDSENT: Command sent (no response required) interrupt * @arg SDIO_IT_DATAEND: Data end (data counter, DATACOUNT, is zero) interrupt * @arg SDIO_IT_DBCKEND: Data block sent/received (CRC check passed) interrupt * @arg SDIO_IT_CMDACT: Command transfer in progress interrupt * @arg SDIO_IT_TXACT: Data transmit in progress interrupt * @arg SDIO_IT_RXACT: Data receive in progress interrupt * @arg SDIO_IT_TXFIFOHE: Transmit FIFO Half Empty interrupt * @arg SDIO_IT_RXFIFOHF: Receive FIFO Half Full interrupt * @arg SDIO_IT_TXFIFOF: Transmit FIFO full interrupt * @arg SDIO_IT_RXFIFOF: Receive FIFO full interrupt * @arg SDIO_IT_TXFIFOE: Transmit FIFO empty interrupt * @arg SDIO_IT_RXFIFOE: Receive FIFO empty interrupt * @arg SDIO_IT_TXDAVL: Data available in transmit FIFO interrupt * @arg SDIO_IT_RXDAVL: Data available in receive FIFO interrupt * @arg SDIO_IT_SDIOIT: SDIO interrupt received interrupt * @retval The new state of SDIO_IT (SET or RESET). */ #define __SDIO_GET_IT (__INSTANCE__, __INTERRUPT__) (((__INSTANCE__)->STA &(__INTERRUPT__)) == (__INTERRUPT__)) /** * @brief Clears the SDIO's interrupt pending bits. * @param __INSTANCE__ : Pointer to SDIO register base * @param __INTERRUPT__: specifies the interrupt pending bit to clear. * This parameter can be one or a combination of the following values: * @arg SDIO_IT_CCRCFAIL: Command response received (CRC check failed) interrupt * @arg SDIO_IT_DCRCFAIL: Data block sent/received (CRC check failed) interrupt * @arg SDIO_IT_CTIMEOUT: Command response timeout interrupt * @arg SDIO_IT_DTIMEOUT: Data timeout interrupt * @arg SDIO_IT_TXUNDERR: Transmit FIFO underrun error interrupt * @arg SDIO_IT_RXOVERR: Received FIFO overrun error interrupt * @arg SDIO_IT_CMDREND: Command response received (CRC check passed) interrupt * @arg SDIO_IT_CMDSENT: Command sent (no response required) interrupt * @arg SDIO_IT_DATAEND: Data end (data counter, DATACOUNT, is zero) interrupt * @arg SDIO_IT_SDIOIT: SDIO interrupt received interrupt * @retval None */ #define __SDIO_CLEAR_IT(__INSTANCE__, __INTERRUPT__) ((__INSTANCE__)->ICR = (__INTERRUPT__)) /** * @brief Enable Start the SD I/O Read Wait operation. * @param __INSTANCE__ : Pointer to SDIO register base * @retval None */ #define __SDIO_START_READWAIT_ENABLE(__INSTANCE__) (*(__IO uint32_t *) DCTRL_RWSTART_BB = ENABLE) /** * @brief Disable Start the SD I/O Read Wait operations. * @param __INSTANCE__ : Pointer to SDIO register base * @retval None */ #define __SDIO_START_READWAIT_DISABLE(__INSTANCE__) (*(__IO uint32_t *) DCTRL_RWSTART_BB = DISABLE) /** * @brief Enable Start the SD I/O Read Wait operation. * @param __INSTANCE__ : Pointer to SDIO register base * @retval None */ #define __SDIO_STOP_READWAIT_ENABLE(__INSTANCE__) (*(__IO uint32_t *) DCTRL_RWSTOP_BB = ENABLE) /** * @brief Disable Stop the SD I/O Read Wait operations. * @param __INSTANCE__ : Pointer to SDIO register base * @retval None */ #define __SDIO_STOP_READWAIT_DISABLE(__INSTANCE__) (*(__IO uint32_t *) DCTRL_RWSTOP_BB = DISABLE) /** * @brief Enable the SD I/O Mode Operation. * @param __INSTANCE__ : Pointer to SDIO register base * @retval None */ #define __SDIO_OPERATION_ENABLE(__INSTANCE__) (*(__IO uint32_t *) DCTRL_SDIOEN_BB = ENABLE) /** * @brief Disable the SD I/O Mode Operation. * @param __INSTANCE__ : Pointer to SDIO register base * @retval None */ #define __SDIO_OPERATION_DISABLE(__INSTANCE__) (*(__IO uint32_t *) DCTRL_SDIOEN_BB = DISABLE) /** * @brief Enable the SD I/O Suspend command sending. * @param __INSTANCE__ : Pointer to SDIO register base * @retval None */ #define __SDIO_SUSPEND_CMD_ENABLE(__INSTANCE__) (*(__IO uint32_t *) CMD_SDIOSUSPEND_BB = ENABLE) /** * @brief Disable the SD I/O Suspend command sending. * @param __INSTANCE__ : Pointer to SDIO register base * @retval None */ #define __SDIO_SUSPEND_CMD_DISABLE(__INSTANCE__) (*(__IO uint32_t *) CMD_SDIOSUSPEND_BB = DISABLE) #if defined(SDIO_CMD_CEATACMD) /** * @brief Enable the command completion signal. * @retval None */ #define __SDIO_CEATA_CMD_COMPLETION_ENABLE() (*(__IO uint32_t *) CMD_ENCMDCOMPL_BB = ENABLE) /** * @brief Disable the command completion signal. * @retval None */ #define __SDIO_CEATA_CMD_COMPLETION_DISABLE() (*(__IO uint32_t *) CMD_ENCMDCOMPL_BB = DISABLE) /** * @brief Enable the CE-ATA interrupt. * @retval None */ #define __SDIO_CEATA_ENABLE_IT() (*(__IO uint32_t *) CMD_NIEN_BB = (uint32_t)0U) /** * @brief Disable the CE-ATA interrupt. * @retval None */ #define __SDIO_CEATA_DISABLE_IT() (*(__IO uint32_t *) CMD_NIEN_BB = (uint32_t)1U) /** * @brief Enable send CE-ATA command (CMD61). * @retval None */ #define __SDIO_CEATA_SENDCMD_ENABLE() (*(__IO uint32_t *) CMD_ATACMD_BB = ENABLE) /** * @brief Disable send CE-ATA command (CMD61). * @retval None */ #define __SDIO_CEATA_SENDCMD_DISABLE() (*(__IO uint32_t *) CMD_ATACMD_BB = DISABLE) #endif /* SDIO_CMD_CEATACMD */ /** * @} */ /** * @} */ /* Exported functions --------------------------------------------------------*/ /** @addtogroup SDMMC_LL_Exported_Functions * @{ */ /* Initialization/de-initialization functions **********************************/ /** @addtogroup HAL_SDMMC_LL_Group1 * @{ */ HAL_StatusTypeDef SDIO_Init(SDIO_TypeDef *SDIOx, SDIO_InitTypeDef Init); /** * @} */ /* I/O operation functions *****************************************************/ /** @addtogroup HAL_SDMMC_LL_Group2 * @{ */ uint32_t SDIO_ReadFIFO(SDIO_TypeDef *SDIOx); HAL_StatusTypeDef SDIO_WriteFIFO(SDIO_TypeDef *SDIOx, uint32_t *pWriteData); /** * @} */ /* Peripheral Control functions ************************************************/ /** @addtogroup HAL_SDMMC_LL_Group3 * @{ */ HAL_StatusTypeDef SDIO_PowerState_ON(SDIO_TypeDef *SDIOx); HAL_StatusTypeDef SDIO_PowerState_OFF(SDIO_TypeDef *SDIOx); uint32_t SDIO_GetPowerState(SDIO_TypeDef *SDIOx); /* Command path state machine (CPSM) management functions */ HAL_StatusTypeDef SDIO_SendCommand(SDIO_TypeDef *SDIOx, SDIO_CmdInitTypeDef *Command); uint8_t SDIO_GetCommandResponse(SDIO_TypeDef *SDIOx); uint32_t SDIO_GetResponse(SDIO_TypeDef *SDIOx, uint32_t Response); /* Data path state machine (DPSM) management functions */ HAL_StatusTypeDef SDIO_ConfigData(SDIO_TypeDef *SDIOx, SDIO_DataInitTypeDef* Data); uint32_t SDIO_GetDataCounter(SDIO_TypeDef *SDIOx); uint32_t SDIO_GetFIFOCount(SDIO_TypeDef *SDIOx); /* SDMMC Cards mode management functions */ HAL_StatusTypeDef SDIO_SetSDMMCReadWaitMode(SDIO_TypeDef *SDIOx, uint32_t SDIO_ReadWaitMode); /* SDMMC Commands management functions */ uint32_t SDMMC_CmdBlockLength(SDIO_TypeDef *SDIOx, uint32_t BlockSize); uint32_t SDMMC_CmdReadSingleBlock(SDIO_TypeDef *SDIOx, uint32_t ReadAdd); uint32_t SDMMC_CmdReadMultiBlock(SDIO_TypeDef *SDIOx, uint32_t ReadAdd); uint32_t SDMMC_CmdWriteSingleBlock(SDIO_TypeDef *SDIOx, uint32_t WriteAdd); uint32_t SDMMC_CmdWriteMultiBlock(SDIO_TypeDef *SDIOx, uint32_t WriteAdd); uint32_t SDMMC_CmdEraseStartAdd(SDIO_TypeDef *SDIOx, uint32_t StartAdd); uint32_t SDMMC_CmdSDEraseStartAdd(SDIO_TypeDef *SDIOx, uint32_t StartAdd); uint32_t SDMMC_CmdEraseEndAdd(SDIO_TypeDef *SDIOx, uint32_t EndAdd); uint32_t SDMMC_CmdSDEraseEndAdd(SDIO_TypeDef *SDIOx, uint32_t EndAdd); uint32_t SDMMC_CmdErase(SDIO_TypeDef *SDIOx); uint32_t SDMMC_CmdStopTransfer(SDIO_TypeDef *SDIOx); uint32_t SDMMC_CmdSelDesel(SDIO_TypeDef *SDIOx, uint64_t Addr); uint32_t SDMMC_CmdGoIdleState(SDIO_TypeDef *SDIOx); uint32_t SDMMC_CmdOperCond(SDIO_TypeDef *SDIOx); uint32_t SDMMC_CmdAppCommand(SDIO_TypeDef *SDIOx, uint32_t Argument); uint32_t SDMMC_CmdAppOperCommand(SDIO_TypeDef *SDIOx, uint32_t Argument); uint32_t SDMMC_CmdBusWidth(SDIO_TypeDef *SDIOx, uint32_t BusWidth); uint32_t SDMMC_CmdSendSCR(SDIO_TypeDef *SDIOx); uint32_t SDMMC_CmdSendCID(SDIO_TypeDef *SDIOx); uint32_t SDMMC_CmdSendCSD(SDIO_TypeDef *SDIOx, uint32_t Argument); uint32_t SDMMC_CmdSetRelAdd(SDIO_TypeDef *SDIOx, uint16_t *pRCA); uint32_t SDMMC_CmdSendStatus(SDIO_TypeDef *SDIOx, uint32_t Argument); uint32_t SDMMC_CmdStatusRegister(SDIO_TypeDef *SDIOx); uint32_t SDMMC_CmdOpCondition(SDIO_TypeDef *SDIOx, uint32_t Argument); uint32_t SDMMC_CmdSwitch(SDIO_TypeDef *SDIOx, uint32_t Argument); /** * @} */ /** * @} */ /** * @} */ /** * @} */ #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F401xC || STM32F401xE || STM32F411xE || STM32F446xx || STM32F469xx || STM32F479xx || STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx || STM32F413xx || STM32F423xx */ #ifdef __cplusplus } #endif #endif /* __STM32F4xx_LL_SDMMC_H */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ ================================================ FILE: sys/arch/stm32/hal/stm32f4xx_ll_system.h ================================================ /** ****************************************************************************** * @file stm32f4xx_ll_system.h * @author MCD Application Team * @version V1.7.1 * @date 14-April-2017 * @brief Header file of SYSTEM LL module. @verbatim ============================================================================== ##### How to use this driver ##### ============================================================================== [..] The LL SYSTEM driver contains a set of generic APIs that can be used by user: (+) Some of the FLASH features need to be handled in the SYSTEM file. (+) Access to DBGCMU registers (+) Access to SYSCFG registers @endverbatim ****************************************************************************** * @attention * *

© COPYRIGHT(c) 2017 STMicroelectronics

* * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. Neither the name of STMicroelectronics nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __STM32F4xx_LL_SYSTEM_H #define __STM32F4xx_LL_SYSTEM_H #ifdef __cplusplus extern "C" { #endif /* Includes ------------------------------------------------------------------*/ #include "stm32f4xx.h" /** @addtogroup STM32F4xx_LL_Driver * @{ */ #if defined (FLASH) || defined (SYSCFG) || defined (DBGMCU) /** @defgroup SYSTEM_LL SYSTEM * @{ */ /* Private types -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ /* Private constants ---------------------------------------------------------*/ /** @defgroup SYSTEM_LL_Private_Constants SYSTEM Private Constants * @{ */ /** * @} */ /* Private macros ------------------------------------------------------------*/ /* Exported types ------------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/ /** @defgroup SYSTEM_LL_Exported_Constants SYSTEM Exported Constants * @{ */ /** @defgroup SYSTEM_LL_EC_REMAP SYSCFG REMAP * @{ */ #define LL_SYSCFG_REMAP_FLASH (uint32_t)0x00000000 /*!< Main Flash memory mapped at 0x00000000 */ #define LL_SYSCFG_REMAP_SYSTEMFLASH SYSCFG_MEMRMP_MEM_MODE_0 /*!< System Flash memory mapped at 0x00000000 */ #if defined(FSMC_Bank1) #define LL_SYSCFG_REMAP_FSMC SYSCFG_MEMRMP_MEM_MODE_1 /*!< FSMC(NOR/PSRAM 1 and 2) mapped at 0x00000000 */ #endif /* FSMC_Bank1 */ #if defined(FMC_Bank1) #define LL_SYSCFG_REMAP_FMC SYSCFG_MEMRMP_MEM_MODE_1 /*!< FMC(NOR/PSRAM 1 and 2) mapped at 0x00000000 */ #endif /* FMC_Bank1 */ #define LL_SYSCFG_REMAP_SRAM (SYSCFG_MEMRMP_MEM_MODE_1 | SYSCFG_MEMRMP_MEM_MODE_0) /*!< SRAM1 mapped at 0x00000000 */ /** * @} */ #if defined(SYSCFG_PMC_MII_RMII_SEL) /** @defgroup SYSTEM_LL_EC_PMC SYSCFG PMC * @{ */ #define LL_SYSCFG_PMC_ETHMII (uint32_t)0x00000000 /*!< ETH Media MII interface */ #define LL_SYSCFG_PMC_ETHRMII (uint32_t)SYSCFG_PMC_MII_RMII_SEL /*!< ETH Media RMII interface */ /** * @} */ #endif /* SYSCFG_PMC_MII_RMII_SEL */ #if defined(SYSCFG_MEMRMP_UFB_MODE) /** @defgroup SYSTEM_LL_EC_BANKMODE SYSCFG BANK MODE * @{ */ #define LL_SYSCFG_BANKMODE_BANK1 (uint32_t)0x00000000 /*!< Flash Bank 1 base address mapped at 0x0800 0000 (AXI) and 0x0020 0000 (TCM) and Flash Bank 2 base address mapped at 0x0810 0000 (AXI) and 0x0030 0000 (TCM)*/ #define LL_SYSCFG_BANKMODE_BANK2 SYSCFG_MEMRMP_UFB_MODE /*!< Flash Bank 2 base address mapped at 0x0800 0000 (AXI) and 0x0020 0000(TCM) and Flash Bank 1 base address mapped at 0x0810 0000 (AXI) and 0x0030 0000(TCM) */ /** * @} */ #endif /* SYSCFG_MEMRMP_UFB_MODE */ /** @defgroup SYSTEM_LL_EC_I2C_FASTMODEPLUS SYSCFG I2C FASTMODEPLUS * @{ */ #if defined(SYSCFG_CFGR_FMPI2C1_SCL) #define LL_SYSCFG_I2C_FASTMODEPLUS_SCL SYSCFG_CFGR_FMPI2C1_SCL /*!< Enable Fast Mode Plus on FMPI2C_SCL pin */ #define LL_SYSCFG_I2C_FASTMODEPLUS_SDA SYSCFG_CFGR_FMPI2C1_SDA /*!< Enable Fast Mode Plus on FMPI2C_SDA pin*/ #endif /* SYSCFG_CFGR_FMPI2C1_SCL */ /** * @} */ /** @defgroup SYSTEM_LL_EC_EXTI_PORT SYSCFG EXTI PORT * @{ */ #define LL_SYSCFG_EXTI_PORTA (uint32_t)0 /*!< EXTI PORT A */ #define LL_SYSCFG_EXTI_PORTB (uint32_t)1 /*!< EXTI PORT B */ #define LL_SYSCFG_EXTI_PORTC (uint32_t)2 /*!< EXTI PORT C */ #define LL_SYSCFG_EXTI_PORTD (uint32_t)3 /*!< EXTI PORT D */ #define LL_SYSCFG_EXTI_PORTE (uint32_t)4 /*!< EXTI PORT E */ #if defined(GPIOF) #define LL_SYSCFG_EXTI_PORTF (uint32_t)5 /*!< EXTI PORT F */ #endif /* GPIOF */ #if defined(GPIOG) #define LL_SYSCFG_EXTI_PORTG (uint32_t)6 /*!< EXTI PORT G */ #endif /* GPIOG */ #define LL_SYSCFG_EXTI_PORTH (uint32_t)7 /*!< EXTI PORT H */ #if defined(GPIOI) #define LL_SYSCFG_EXTI_PORTI (uint32_t)8 /*!< EXTI PORT I */ #endif /* GPIOI */ #if defined(GPIOJ) #define LL_SYSCFG_EXTI_PORTJ (uint32_t)9 /*!< EXTI PORT J */ #endif /* GPIOJ */ #if defined(GPIOK) #define LL_SYSCFG_EXTI_PORTK (uint32_t)10 /*!< EXTI PORT k */ #endif /* GPIOK */ /** * @} */ /** @defgroup SYSTEM_LL_EC_EXTI_LINE SYSCFG EXTI LINE * @{ */ #define LL_SYSCFG_EXTI_LINE0 (uint32_t)(0x000FU << 16 | 0) /*!< EXTI_POSITION_0 | EXTICR[0] */ #define LL_SYSCFG_EXTI_LINE1 (uint32_t)(0x00F0U << 16 | 0) /*!< EXTI_POSITION_4 | EXTICR[0] */ #define LL_SYSCFG_EXTI_LINE2 (uint32_t)(0x0F00U << 16 | 0) /*!< EXTI_POSITION_8 | EXTICR[0] */ #define LL_SYSCFG_EXTI_LINE3 (uint32_t)(0xF000U << 16 | 0) /*!< EXTI_POSITION_12 | EXTICR[0] */ #define LL_SYSCFG_EXTI_LINE4 (uint32_t)(0x000FU << 16 | 1) /*!< EXTI_POSITION_0 | EXTICR[1] */ #define LL_SYSCFG_EXTI_LINE5 (uint32_t)(0x00F0U << 16 | 1) /*!< EXTI_POSITION_4 | EXTICR[1] */ #define LL_SYSCFG_EXTI_LINE6 (uint32_t)(0x0F00U << 16 | 1) /*!< EXTI_POSITION_8 | EXTICR[1] */ #define LL_SYSCFG_EXTI_LINE7 (uint32_t)(0xF000U << 16 | 1) /*!< EXTI_POSITION_12 | EXTICR[1] */ #define LL_SYSCFG_EXTI_LINE8 (uint32_t)(0x000FU << 16 | 2) /*!< EXTI_POSITION_0 | EXTICR[2] */ #define LL_SYSCFG_EXTI_LINE9 (uint32_t)(0x00F0U << 16 | 2) /*!< EXTI_POSITION_4 | EXTICR[2] */ #define LL_SYSCFG_EXTI_LINE10 (uint32_t)(0x0F00U << 16 | 2) /*!< EXTI_POSITION_8 | EXTICR[2] */ #define LL_SYSCFG_EXTI_LINE11 (uint32_t)(0xF000U << 16 | 2) /*!< EXTI_POSITION_12 | EXTICR[2] */ #define LL_SYSCFG_EXTI_LINE12 (uint32_t)(0x000FU << 16 | 3) /*!< EXTI_POSITION_0 | EXTICR[3] */ #define LL_SYSCFG_EXTI_LINE13 (uint32_t)(0x00F0U << 16 | 3) /*!< EXTI_POSITION_4 | EXTICR[3] */ #define LL_SYSCFG_EXTI_LINE14 (uint32_t)(0x0F00U << 16 | 3) /*!< EXTI_POSITION_8 | EXTICR[3] */ #define LL_SYSCFG_EXTI_LINE15 (uint32_t)(0xF000U << 16 | 3) /*!< EXTI_POSITION_12 | EXTICR[3] */ /** * @} */ /** @defgroup SYSTEM_LL_EC_TIMBREAK SYSCFG TIMER BREAK * @{ */ #if defined(SYSCFG_CFGR2_LOCKUP_LOCK) #define LL_SYSCFG_TIMBREAK_LOCKUP SYSCFG_CFGR2_LOCKUP_LOCK /*!< Enables and locks the LOCKUP output of CortexM4 with Break Input of TIM1/8 */ #define LL_SYSCFG_TIMBREAK_PVD SYSCFG_CFGR2_PVD_LOCK /*!< Enables and locks the PVD connection with TIM1/8 Break Input and also the PVDE and PLS bits of the Power Control Interface */ #endif /* SYSCFG_CFGR2_CLL */ /** * @} */ #if defined(SYSCFG_MCHDLYCR_BSCKSEL) /** @defgroup SYSTEM_LL_DFSDM_BitStream_ClockSource SYSCFG MCHDLY BCKKSEL * @{ */ #define LL_SYSCFG_BITSTREAM_CLOCK_TIM2OC1 (uint32_t)0x00000000 #define LL_SYSCFG_BITSTREAM_CLOCK_DFSDM2 SYSCFG_MCHDLYCR_BSCKSEL /** * @} */ /** @defgroup SYSTEM_LL_DFSDM_MCHDLYEN SYSCFG MCHDLY MCHDLYEN * @{ */ #define LL_SYSCFG_DFSDM1_MCHDLYEN SYSCFG_MCHDLYCR_MCHDLY1EN #define LL_SYSCFG_DFSDM2_MCHDLYEN SYSCFG_MCHDLYCR_MCHDLY2EN /** * @} */ /** @defgroup SYSTEM_LL_DFSDM_DataIn0_Source SYSCFG MCHDLY DFSDMD0SEL * @{ */ #define LL_SYSCFG_DFSDM1_DataIn0 SYSCFG_MCHDLYCR_DFSDM1D0SEL #define LL_SYSCFG_DFSDM2_DataIn0 SYSCFG_MCHDLYCR_DFSDM2D0SEL #define LL_SYSCFG_DFSDM1_DataIn0_PAD (uint32_t)((SYSCFG_MCHDLYCR_DFSDM1D0SEL << 16) | 0x00000000) #define LL_SYSCFG_DFSDM1_DataIn0_DM (uint32_t)((SYSCFG_MCHDLYCR_DFSDM1D0SEL << 16) | SYSCFG_MCHDLYCR_DFSDM1D0SEL) #define LL_SYSCFG_DFSDM2_DataIn0_PAD (uint32_t)((SYSCFG_MCHDLYCR_DFSDM2D0SEL << 16) | 0x00000000) #define LL_SYSCFG_DFSDM2_DataIn0_DM (uint32_t)((SYSCFG_MCHDLYCR_DFSDM2D0SEL << 16) | SYSCFG_MCHDLYCR_DFSDM2D0SEL) /** * @} */ /** @defgroup SYSTEM_LL_DFSDM_DataIn2_Source SYSCFG MCHDLY DFSDMD2SEL * @{ */ #define LL_SYSCFG_DFSDM1_DataIn2 SYSCFG_MCHDLYCR_DFSDM1D2SEL #define LL_SYSCFG_DFSDM2_DataIn2 SYSCFG_MCHDLYCR_DFSDM2D2SEL #define LL_SYSCFG_DFSDM1_DataIn2_PAD (uint32_t)((SYSCFG_MCHDLYCR_DFSDM1D2SEL << 16) | 0x00000000) #define LL_SYSCFG_DFSDM1_DataIn2_DM (uint32_t)((SYSCFG_MCHDLYCR_DFSDM1D2SEL << 16) | SYSCFG_MCHDLYCR_DFSDM1D2SEL) #define LL_SYSCFG_DFSDM2_DataIn2_PAD (uint32_t)((SYSCFG_MCHDLYCR_DFSDM2D2SEL << 16) | 0x00000000) #define LL_SYSCFG_DFSDM2_DataIn2_DM (uint32_t)((SYSCFG_MCHDLYCR_DFSDM2D2SEL << 16) | SYSCFG_MCHDLYCR_DFSDM2D2SEL) /** * @} */ /** @defgroup SYSTEM_LL_DFSDM1_TIM4OC2_BitstreamDistribution SYSCFG MCHDLY DFSDM1CK02SEL * @{ */ #define LL_SYSCFG_DFSDM1_TIM4OC2_CLKIN0 (uint32_t)0x00000000 #define LL_SYSCFG_DFSDM1_TIM4OC2_CLKIN2 SYSCFG_MCHDLYCR_DFSDM1CK02SEL /** * @} */ /** @defgroup SYSTEM_LL_DFSDM1_TIM4OC1_BitstreamDistribution SYSCFG MCHDLY DFSDM1CK13SEL * @{ */ #define LL_SYSCFG_DFSDM1_TIM4OC1_CLKIN1 (uint32_t)0x00000000 #define LL_SYSCFG_DFSDM1_TIM4OC1_CLKIN3 SYSCFG_MCHDLYCR_DFSDM1CK13SEL /** * @} */ /** @defgroup SYSTEM_LL_DFSDM1_CLKIN_SourceSelection SYSCFG MCHDLY DFSDMCFG * @{ */ #define LL_SYSCFG_DFSDM1_CKIN_PAD (uint32_t)0x00000000 #define LL_SYSCFG_DFSDM1_CKIN_DM SYSCFG_MCHDLYCR_DFSDM1CFG /** * @} */ /** @defgroup SYSTEM_LL_DFSDM1_CLKOUT_SourceSelection SYSCFG MCHDLY DFSDM1CKOSEL * @{ */ #define LL_SYSCFG_DFSDM1_CKOUT (uint32_t)0x00000000 #define LL_SYSCFG_DFSDM1_CKOUT_M27 SYSCFG_MCHDLYCR_DFSDM1CKOSEL /** * @} */ /** @defgroup SYSTEM_LL_DFSDM2_DataIn4_SourceSelection SYSCFG MCHDLY DFSDM2D4SEL * @{ */ #define LL_SYSCFG_DFSDM2_DataIn4_PAD (uint32_t)0x00000000 #define LL_SYSCFG_DFSDM2_DataIn4_DM SYSCFG_MCHDLYCR_DFSDM2D4SEL /** * @} */ /** @defgroup SYSTEM_LL_DFSDM2_DataIn6_SourceSelection SYSCFG MCHDLY DFSDM2D6SEL * @{ */ #define LL_SYSCFG_DFSDM2_DataIn6_PAD (uint32_t)0x00000000 #define LL_SYSCFG_DFSDM2_DataIn6_DM SYSCFG_MCHDLYCR_DFSDM2D6SEL /** * @} */ /** @defgroup SYSTEM_LL_DFSDM2_TIM3OC4_BitstreamDistribution SYSCFG MCHDLY DFSDM2CK04SEL * @{ */ #define LL_SYSCFG_DFSDM2_TIM3OC4_CLKIN0 (uint32_t)0x00000000 #define LL_SYSCFG_DFSDM2_TIM3OC4_CLKIN4 SYSCFG_MCHDLYCR_DFSDM2CK04SEL /** * @} */ /** @defgroup SYSTEM_LL_DFSDM2_TIM3OC3_BitstreamDistribution SYSCFG MCHDLY DFSDM2CK15SEL * @{ */ #define LL_SYSCFG_DFSDM2_TIM3OC3_CLKIN1 (uint32_t)0x00000000 #define LL_SYSCFG_DFSDM2_TIM3OC3_CLKIN5 SYSCFG_MCHDLYCR_DFSDM2CK15SEL /** * @} */ /** @defgroup SYSTEM_LL_DFSDM2_TIM3OC2_BitstreamDistribution SYSCFG MCHDLY DFSDM2CK26SEL * @{ */ #define LL_SYSCFG_DFSDM2_TIM3OC2_CLKIN2 (uint32_t)0x00000000 #define LL_SYSCFG_DFSDM2_TIM3OC2_CLKIN6 SYSCFG_MCHDLYCR_DFSDM2CK26SEL /** * @} */ /** @defgroup SYSTEM_LL_DFSDM2_TIM3OC1_BitstreamDistribution SYSCFG MCHDLY DFSDM2CK37SEL * @{ */ #define LL_SYSCFG_DFSDM2_TIM3OC1_CLKIN3 (uint32_t)0x00000000 #define LL_SYSCFG_DFSDM2_TIM3OC1_CLKIN7 SYSCFG_MCHDLYCR_DFSDM2CK37SEL /** * @} */ /** @defgroup SYSTEM_LL_DFSDM2_CLKIN_SourceSelection SYSCFG MCHDLY DFSDM2CFG * @{ */ #define LL_SYSCFG_DFSDM2_CKIN_PAD (uint32_t)0x00000000 #define LL_SYSCFG_DFSDM2_CKIN_DM SYSCFG_MCHDLYCR_DFSDM2CFG /** * @} */ /** @defgroup SYSTEM_LL_DFSDM2_CLKOUT_SourceSelection SYSCFG MCHDLY DFSDM2CKOSEL * @{ */ #define LL_SYSCFG_DFSDM2_CKOUT (uint32_t)0x00000000 #define LL_SYSCFG_DFSDM2_CKOUT_M27 SYSCFG_MCHDLYCR_DFSDM2CKOSEL /** * @} */ #endif /* SYSCFG_MCHDLYCR_BSCKSEL */ /** @defgroup SYSTEM_LL_EC_TRACE DBGMCU TRACE Pin Assignment * @{ */ #define LL_DBGMCU_TRACE_NONE 0x00000000U /*!< TRACE pins not assigned (default state) */ #define LL_DBGMCU_TRACE_ASYNCH DBGMCU_CR_TRACE_IOEN /*!< TRACE pin assignment for Asynchronous Mode */ #define LL_DBGMCU_TRACE_SYNCH_SIZE1 (DBGMCU_CR_TRACE_IOEN | DBGMCU_CR_TRACE_MODE_0) /*!< TRACE pin assignment for Synchronous Mode with a TRACEDATA size of 1 */ #define LL_DBGMCU_TRACE_SYNCH_SIZE2 (DBGMCU_CR_TRACE_IOEN | DBGMCU_CR_TRACE_MODE_1) /*!< TRACE pin assignment for Synchronous Mode with a TRACEDATA size of 2 */ #define LL_DBGMCU_TRACE_SYNCH_SIZE4 (DBGMCU_CR_TRACE_IOEN | DBGMCU_CR_TRACE_MODE) /*!< TRACE pin assignment for Synchronous Mode with a TRACEDATA size of 4 */ /** * @} */ /** @defgroup SYSTEM_LL_EC_APB1_GRP1_STOP_IP DBGMCU APB1 GRP1 STOP IP * @{ */ #if defined(DBGMCU_APB1_FZ_DBG_TIM2_STOP) #define LL_DBGMCU_APB1_GRP1_TIM2_STOP DBGMCU_APB1_FZ_DBG_TIM2_STOP /*!< TIM2 counter stopped when core is halted */ #endif /* DBGMCU_APB1_FZ_DBG_TIM2_STOP */ #if defined(DBGMCU_APB1_FZ_DBG_TIM3_STOP) #define LL_DBGMCU_APB1_GRP1_TIM3_STOP DBGMCU_APB1_FZ_DBG_TIM3_STOP /*!< TIM3 counter stopped when core is halted */ #endif /* DBGMCU_APB1_FZ_DBG_TIM3_STOP */ #if defined(DBGMCU_APB1_FZ_DBG_TIM4_STOP) #define LL_DBGMCU_APB1_GRP1_TIM4_STOP DBGMCU_APB1_FZ_DBG_TIM4_STOP /*!< TIM4 counter stopped when core is halted */ #endif /* DBGMCU_APB1_FZ_DBG_TIM4_STOP */ #define LL_DBGMCU_APB1_GRP1_TIM5_STOP DBGMCU_APB1_FZ_DBG_TIM5_STOP /*!< TIM5 counter stopped when core is halted */ #if defined(DBGMCU_APB1_FZ_DBG_TIM6_STOP) #define LL_DBGMCU_APB1_GRP1_TIM6_STOP DBGMCU_APB1_FZ_DBG_TIM6_STOP /*!< TIM6 counter stopped when core is halted */ #endif /* DBGMCU_APB1_FZ_DBG_TIM6_STOP */ #if defined(DBGMCU_APB1_FZ_DBG_TIM7_STOP) #define LL_DBGMCU_APB1_GRP1_TIM7_STOP DBGMCU_APB1_FZ_DBG_TIM7_STOP /*!< TIM7 counter stopped when core is halted */ #endif /* DBGMCU_APB1_FZ_DBG_TIM7_STOP */ #if defined(DBGMCU_APB1_FZ_DBG_TIM12_STOP) #define LL_DBGMCU_APB1_GRP1_TIM12_STOP DBGMCU_APB1_FZ_DBG_TIM12_STOP /*!< TIM12 counter stopped when core is halted */ #endif /* DBGMCU_APB1_FZ_DBG_TIM12_STOP */ #if defined(DBGMCU_APB1_FZ_DBG_TIM13_STOP) #define LL_DBGMCU_APB1_GRP1_TIM13_STOP DBGMCU_APB1_FZ_DBG_TIM13_STOP /*!< TIM13 counter stopped when core is halted */ #endif /* DBGMCU_APB1_FZ_DBG_TIM13_STOP */ #if defined(DBGMCU_APB1_FZ_DBG_TIM14_STOP) #define LL_DBGMCU_APB1_GRP1_TIM14_STOP DBGMCU_APB1_FZ_DBG_TIM14_STOP /*!< TIM14 counter stopped when core is halted */ #endif /* DBGMCU_APB1_FZ_DBG_TIM14_STOP */ #if defined(DBGMCU_APB1_FZ_DBG_LPTIM_STOP) #define LL_DBGMCU_APB1_GRP1_LPTIM_STOP DBGMCU_APB1_FZ_DBG_LPTIM_STOP /*!< LPTIM counter stopped when core is halted */ #endif /* DBGMCU_APB1_FZ_DBG_LPTIM_STOP */ #define LL_DBGMCU_APB1_GRP1_RTC_STOP DBGMCU_APB1_FZ_DBG_RTC_STOP /*!< RTC counter stopped when core is halted */ #define LL_DBGMCU_APB1_GRP1_WWDG_STOP DBGMCU_APB1_FZ_DBG_WWDG_STOP /*!< Debug Window Watchdog stopped when Core is halted */ #define LL_DBGMCU_APB1_GRP1_IWDG_STOP DBGMCU_APB1_FZ_DBG_IWDG_STOP /*!< Debug Independent Watchdog stopped when Core is halted */ #define LL_DBGMCU_APB1_GRP1_I2C1_STOP DBGMCU_APB1_FZ_DBG_I2C1_SMBUS_TIMEOUT /*!< I2C1 SMBUS timeout mode stopped when Core is halted */ #define LL_DBGMCU_APB1_GRP1_I2C2_STOP DBGMCU_APB1_FZ_DBG_I2C2_SMBUS_TIMEOUT /*!< I2C2 SMBUS timeout mode stopped when Core is halted */ #if defined(DBGMCU_APB1_FZ_DBG_I2C3_SMBUS_TIMEOUT) #define LL_DBGMCU_APB1_GRP1_I2C3_STOP DBGMCU_APB1_FZ_DBG_I2C3_SMBUS_TIMEOUT /*!< I2C3 SMBUS timeout mode stopped when Core is halted */ #endif /* DBGMCU_APB1_FZ_DBG_I2C3_SMBUS_TIMEOUT */ #if defined(DBGMCU_APB1_FZ_DBG_I2C4_SMBUS_TIMEOUT) #define LL_DBGMCU_APB1_GRP1_I2C4_STOP DBGMCU_APB1_FZ_DBG_I2C4_SMBUS_TIMEOUT /*!< I2C4 SMBUS timeout mode stopped when Core is halted */ #endif /* DBGMCU_APB1_FZ_DBG_I2C4_SMBUS_TIMEOUT */ #if defined(DBGMCU_APB1_FZ_DBG_CAN1_STOP) #define LL_DBGMCU_APB1_GRP1_CAN1_STOP DBGMCU_APB1_FZ_DBG_CAN1_STOP /*!< CAN1 debug stopped when Core is halted */ #endif /* DBGMCU_APB1_FZ_DBG_CAN1_STOP */ #if defined(DBGMCU_APB1_FZ_DBG_CAN2_STOP) #define LL_DBGMCU_APB1_GRP1_CAN2_STOP DBGMCU_APB1_FZ_DBG_CAN2_STOP /*!< CAN2 debug stopped when Core is halted */ #endif /* DBGMCU_APB1_FZ_DBG_CAN2_STOP */ #if defined(DBGMCU_APB1_FZ_DBG_CAN3_STOP) #define LL_DBGMCU_APB1_GRP1_CAN3_STOP DBGMCU_APB1_FZ_DBG_CAN3_STOP /*!< CAN3 debug stopped when Core is halted */ #endif /* DBGMCU_APB1_FZ_DBG_CAN3_STOP */ /** * @} */ /** @defgroup SYSTEM_LL_EC_APB2_GRP1_STOP_IP DBGMCU APB2 GRP1 STOP IP * @{ */ #define LL_DBGMCU_APB2_GRP1_TIM1_STOP DBGMCU_APB2_FZ_DBG_TIM1_STOP /*!< TIM1 counter stopped when core is halted */ #if defined(DBGMCU_APB2_FZ_DBG_TIM8_STOP) #define LL_DBGMCU_APB2_GRP1_TIM8_STOP DBGMCU_APB2_FZ_DBG_TIM8_STOP /*!< TIM8 counter stopped when core is halted */ #endif /* DBGMCU_APB2_FZ_DBG_TIM8_STOP */ #define LL_DBGMCU_APB2_GRP1_TIM9_STOP DBGMCU_APB2_FZ_DBG_TIM9_STOP /*!< TIM9 counter stopped when core is halted */ #if defined(DBGMCU_APB2_FZ_DBG_TIM10_STOP) #define LL_DBGMCU_APB2_GRP1_TIM10_STOP DBGMCU_APB2_FZ_DBG_TIM10_STOP /*!< TIM10 counter stopped when core is halted */ #endif /* DBGMCU_APB2_FZ_DBG_TIM10_STOP */ #define LL_DBGMCU_APB2_GRP1_TIM11_STOP DBGMCU_APB2_FZ_DBG_TIM11_STOP /*!< TIM11 counter stopped when core is halted */ /** * @} */ /** @defgroup SYSTEM_LL_EC_LATENCY FLASH LATENCY * @{ */ #define LL_FLASH_LATENCY_0 FLASH_ACR_LATENCY_0WS /*!< FLASH Zero wait state */ #define LL_FLASH_LATENCY_1 FLASH_ACR_LATENCY_1WS /*!< FLASH One wait state */ #define LL_FLASH_LATENCY_2 FLASH_ACR_LATENCY_2WS /*!< FLASH Two wait states */ #define LL_FLASH_LATENCY_3 FLASH_ACR_LATENCY_3WS /*!< FLASH Three wait states */ #define LL_FLASH_LATENCY_4 FLASH_ACR_LATENCY_4WS /*!< FLASH Four wait states */ #define LL_FLASH_LATENCY_5 FLASH_ACR_LATENCY_5WS /*!< FLASH five wait state */ #define LL_FLASH_LATENCY_6 FLASH_ACR_LATENCY_6WS /*!< FLASH six wait state */ #define LL_FLASH_LATENCY_7 FLASH_ACR_LATENCY_7WS /*!< FLASH seven wait states */ #define LL_FLASH_LATENCY_8 FLASH_ACR_LATENCY_8WS /*!< FLASH eight wait states */ #define LL_FLASH_LATENCY_9 FLASH_ACR_LATENCY_9WS /*!< FLASH nine wait states */ #define LL_FLASH_LATENCY_10 FLASH_ACR_LATENCY_10WS /*!< FLASH ten wait states */ #define LL_FLASH_LATENCY_11 FLASH_ACR_LATENCY_11WS /*!< FLASH eleven wait states */ #define LL_FLASH_LATENCY_12 FLASH_ACR_LATENCY_12WS /*!< FLASH twelve wait states */ #define LL_FLASH_LATENCY_13 FLASH_ACR_LATENCY_13WS /*!< FLASH thirteen wait states */ #define LL_FLASH_LATENCY_14 FLASH_ACR_LATENCY_14WS /*!< FLASH fourteen wait states */ #define LL_FLASH_LATENCY_15 FLASH_ACR_LATENCY_15WS /*!< FLASH fifteen wait states */ /** * @} */ /** * @} */ /* Exported macro ------------------------------------------------------------*/ /* Exported functions --------------------------------------------------------*/ /** @defgroup SYSTEM_LL_Exported_Functions SYSTEM Exported Functions * @{ */ /** @defgroup SYSTEM_LL_EF_SYSCFG SYSCFG * @{ */ /** * @brief Set memory mapping at address 0x00000000 * @rmtoll SYSCFG_MEMRMP MEM_MODE LL_SYSCFG_SetRemapMemory * @param Memory This parameter can be one of the following values: * @arg @ref LL_SYSCFG_REMAP_FLASH * @arg @ref LL_SYSCFG_REMAP_SYSTEMFLASH * @arg @ref LL_SYSCFG_REMAP_SRAM * @arg @ref LL_SYSCFG_REMAP_FSMC (*) * @arg @ref LL_SYSCFG_REMAP_FMC (*) * @retval None */ __STATIC_INLINE void LL_SYSCFG_SetRemapMemory(uint32_t Memory) { MODIFY_REG(SYSCFG->MEMRMP, SYSCFG_MEMRMP_MEM_MODE, Memory); } /** * @brief Get memory mapping at address 0x00000000 * @rmtoll SYSCFG_MEMRMP MEM_MODE LL_SYSCFG_GetRemapMemory * @retval Returned value can be one of the following values: * @arg @ref LL_SYSCFG_REMAP_FLASH * @arg @ref LL_SYSCFG_REMAP_SYSTEMFLASH * @arg @ref LL_SYSCFG_REMAP_SRAM * @arg @ref LL_SYSCFG_REMAP_FSMC (*) * @arg @ref LL_SYSCFG_REMAP_FMC (*) */ __STATIC_INLINE uint32_t LL_SYSCFG_GetRemapMemory(void) { return (uint32_t)(READ_BIT(SYSCFG->MEMRMP, SYSCFG_MEMRMP_MEM_MODE)); } #if defined(SYSCFG_MEMRMP_SWP_FMC) /** * @brief Enables the FMC Memory Mapping Swapping * @rmtoll SYSCFG_MEMRMP SWP_FMC LL_SYSCFG_EnableFMCMemorySwapping * @note SDRAM is accessible at 0x60000000 and NOR/RAM * is accessible at 0xC0000000 * @retval None */ __STATIC_INLINE void LL_SYSCFG_EnableFMCMemorySwapping(void) { SET_BIT(SYSCFG->MEMRMP, SYSCFG_MEMRMP_SWP_FMC_0); } /** * @brief Disables the FMC Memory Mapping Swapping * @rmtoll SYSCFG_MEMRMP SWP_FMC LL_SYSCFG_DisableFMCMemorySwapping * @note SDRAM is accessible at 0xC0000000 (default mapping) * and NOR/RAM is accessible at 0x60000000 (default mapping) * @retval None */ __STATIC_INLINE void LL_SYSCFG_DisableFMCMemorySwapping(void) { CLEAR_BIT(SYSCFG->MEMRMP, SYSCFG_MEMRMP_SWP_FMC); } #endif /* SYSCFG_MEMRMP_SWP_FMC */ /** * @brief Enables the Compensation cell Power Down * @rmtoll SYSCFG_CMPCR CMP_PD LL_SYSCFG_EnableCompensationCell * @note The I/O compensation cell can be used only when the device supply * voltage ranges from 2.4 to 3.6 V * @retval None */ __STATIC_INLINE void LL_SYSCFG_EnableCompensationCell(void) { SET_BIT(SYSCFG->CMPCR, SYSCFG_CMPCR_CMP_PD); } /** * @brief Disables the Compensation cell Power Down * @rmtoll SYSCFG_CMPCR CMP_PD LL_SYSCFG_DisableCompensationCell * @note The I/O compensation cell can be used only when the device supply * voltage ranges from 2.4 to 3.6 V * @retval None */ __STATIC_INLINE void LL_SYSCFG_DisableCompensationCell(void) { CLEAR_BIT(SYSCFG->CMPCR, SYSCFG_CMPCR_CMP_PD); } /** * @brief Get Compensation Cell ready Flag * @rmtoll SYSCFG_CMPCR READY LL_SYSCFG_IsActiveFlag_CMPCR * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_SYSCFG_IsActiveFlag_CMPCR(void) { return (READ_BIT(SYSCFG->CMPCR, SYSCFG_CMPCR_READY) == (SYSCFG_CMPCR_READY)); } #if defined(SYSCFG_PMC_MII_RMII_SEL) /** * @brief Select Ethernet PHY interface * @rmtoll SYSCFG_PMC MII_RMII_SEL LL_SYSCFG_SetPHYInterface * @param Interface This parameter can be one of the following values: * @arg @ref LL_SYSCFG_PMC_ETHMII * @arg @ref LL_SYSCFG_PMC_ETHRMII * @retval None */ __STATIC_INLINE void LL_SYSCFG_SetPHYInterface(uint32_t Interface) { MODIFY_REG(SYSCFG->PMC, SYSCFG_PMC_MII_RMII_SEL, Interface); } /** * @brief Get Ethernet PHY interface * @rmtoll SYSCFG_PMC MII_RMII_SEL LL_SYSCFG_GetPHYInterface * @retval Returned value can be one of the following values: * @arg @ref LL_SYSCFG_PMC_ETHMII * @arg @ref LL_SYSCFG_PMC_ETHRMII * @retval None */ __STATIC_INLINE uint32_t LL_SYSCFG_GetPHYInterface(void) { return (uint32_t)(READ_BIT(SYSCFG->PMC, SYSCFG_PMC_MII_RMII_SEL)); } #endif /* SYSCFG_PMC_MII_RMII_SEL */ #if defined(SYSCFG_MEMRMP_UFB_MODE) /** * @brief Select Flash bank mode (Bank flashed at 0x08000000) * @rmtoll SYSCFG_MEMRMP UFB_MODE LL_SYSCFG_SetFlashBankMode * @param Bank This parameter can be one of the following values: * @arg @ref LL_SYSCFG_BANKMODE_BANK1 * @arg @ref LL_SYSCFG_BANKMODE_BANK2 * @retval None */ __STATIC_INLINE void LL_SYSCFG_SetFlashBankMode(uint32_t Bank) { MODIFY_REG(SYSCFG->MEMRMP, SYSCFG_MEMRMP_UFB_MODE, Bank); } /** * @brief Get Flash bank mode (Bank flashed at 0x08000000) * @rmtoll SYSCFG_MEMRMP UFB_MODE LL_SYSCFG_GetFlashBankMode * @retval Returned value can be one of the following values: * @arg @ref LL_SYSCFG_BANKMODE_BANK1 * @arg @ref LL_SYSCFG_BANKMODE_BANK2 */ __STATIC_INLINE uint32_t LL_SYSCFG_GetFlashBankMode(void) { return (uint32_t)(READ_BIT(SYSCFG->MEMRMP, SYSCFG_MEMRMP_UFB_MODE)); } #endif /* SYSCFG_MEMRMP_UFB_MODE */ #if defined(SYSCFG_CFGR_FMPI2C1_SCL) /** * @brief Enable the I2C fast mode plus driving capability. * @rmtoll SYSCFG_CFGR FMPI2C1_SCL LL_SYSCFG_EnableFastModePlus\n * SYSCFG_CFGR FMPI2C1_SDA LL_SYSCFG_EnableFastModePlus * @param ConfigFastModePlus This parameter can be a combination of the following values: * @arg @ref LL_SYSCFG_I2C_FASTMODEPLUS_SCL * @arg @ref LL_SYSCFG_I2C_FASTMODEPLUS_SDA * (*) value not defined in all devices * @retval None */ __STATIC_INLINE void LL_SYSCFG_EnableFastModePlus(uint32_t ConfigFastModePlus) { SET_BIT(SYSCFG->CFGR, ConfigFastModePlus); } /** * @brief Disable the I2C fast mode plus driving capability. * @rmtoll SYSCFG_CFGR FMPI2C1_SCL LL_SYSCFG_DisableFastModePlus\n * SYSCFG_CFGR FMPI2C1_SDA LL_SYSCFG_DisableFastModePlus\n * @param ConfigFastModePlus This parameter can be a combination of the following values: * @arg @ref LL_SYSCFG_I2C_FASTMODEPLUS_SCL * @arg @ref LL_SYSCFG_I2C_FASTMODEPLUS_SDA * (*) value not defined in all devices * @retval None */ __STATIC_INLINE void LL_SYSCFG_DisableFastModePlus(uint32_t ConfigFastModePlus) { CLEAR_BIT(SYSCFG->CFGR, ConfigFastModePlus); } #endif /* SYSCFG_CFGR_FMPI2C1_SCL */ /** * @brief Configure source input for the EXTI external interrupt. * @rmtoll SYSCFG_EXTICR1 EXTIx LL_SYSCFG_SetEXTISource\n * SYSCFG_EXTICR2 EXTIx LL_SYSCFG_SetEXTISource\n * SYSCFG_EXTICR3 EXTIx LL_SYSCFG_SetEXTISource\n * SYSCFG_EXTICR4 EXTIx LL_SYSCFG_SetEXTISource * @param Port This parameter can be one of the following values: * @arg @ref LL_SYSCFG_EXTI_PORTA * @arg @ref LL_SYSCFG_EXTI_PORTB * @arg @ref LL_SYSCFG_EXTI_PORTC * @arg @ref LL_SYSCFG_EXTI_PORTD * @arg @ref LL_SYSCFG_EXTI_PORTE * @arg @ref LL_SYSCFG_EXTI_PORTF (*) * @arg @ref LL_SYSCFG_EXTI_PORTG (*) * @arg @ref LL_SYSCFG_EXTI_PORTH * * (*) value not defined in all devices * @param Line This parameter can be one of the following values: * @arg @ref LL_SYSCFG_EXTI_LINE0 * @arg @ref LL_SYSCFG_EXTI_LINE1 * @arg @ref LL_SYSCFG_EXTI_LINE2 * @arg @ref LL_SYSCFG_EXTI_LINE3 * @arg @ref LL_SYSCFG_EXTI_LINE4 * @arg @ref LL_SYSCFG_EXTI_LINE5 * @arg @ref LL_SYSCFG_EXTI_LINE6 * @arg @ref LL_SYSCFG_EXTI_LINE7 * @arg @ref LL_SYSCFG_EXTI_LINE8 * @arg @ref LL_SYSCFG_EXTI_LINE9 * @arg @ref LL_SYSCFG_EXTI_LINE10 * @arg @ref LL_SYSCFG_EXTI_LINE11 * @arg @ref LL_SYSCFG_EXTI_LINE12 * @arg @ref LL_SYSCFG_EXTI_LINE13 * @arg @ref LL_SYSCFG_EXTI_LINE14 * @arg @ref LL_SYSCFG_EXTI_LINE15 * @retval None */ __STATIC_INLINE void LL_SYSCFG_SetEXTISource(uint32_t Port, uint32_t Line) { MODIFY_REG(SYSCFG->EXTICR[Line & 0xFF], (Line >> 16), Port << POSITION_VAL((Line >> 16))); } /** * @brief Get the configured defined for specific EXTI Line * @rmtoll SYSCFG_EXTICR1 EXTIx LL_SYSCFG_GetEXTISource\n * SYSCFG_EXTICR2 EXTIx LL_SYSCFG_GetEXTISource\n * SYSCFG_EXTICR3 EXTIx LL_SYSCFG_GetEXTISource\n * SYSCFG_EXTICR4 EXTIx LL_SYSCFG_GetEXTISource * @param Line This parameter can be one of the following values: * @arg @ref LL_SYSCFG_EXTI_LINE0 * @arg @ref LL_SYSCFG_EXTI_LINE1 * @arg @ref LL_SYSCFG_EXTI_LINE2 * @arg @ref LL_SYSCFG_EXTI_LINE3 * @arg @ref LL_SYSCFG_EXTI_LINE4 * @arg @ref LL_SYSCFG_EXTI_LINE5 * @arg @ref LL_SYSCFG_EXTI_LINE6 * @arg @ref LL_SYSCFG_EXTI_LINE7 * @arg @ref LL_SYSCFG_EXTI_LINE8 * @arg @ref LL_SYSCFG_EXTI_LINE9 * @arg @ref LL_SYSCFG_EXTI_LINE10 * @arg @ref LL_SYSCFG_EXTI_LINE11 * @arg @ref LL_SYSCFG_EXTI_LINE12 * @arg @ref LL_SYSCFG_EXTI_LINE13 * @arg @ref LL_SYSCFG_EXTI_LINE14 * @arg @ref LL_SYSCFG_EXTI_LINE15 * @retval Returned value can be one of the following values: * @arg @ref LL_SYSCFG_EXTI_PORTA * @arg @ref LL_SYSCFG_EXTI_PORTB * @arg @ref LL_SYSCFG_EXTI_PORTC * @arg @ref LL_SYSCFG_EXTI_PORTD * @arg @ref LL_SYSCFG_EXTI_PORTE * @arg @ref LL_SYSCFG_EXTI_PORTF (*) * @arg @ref LL_SYSCFG_EXTI_PORTG (*) * @arg @ref LL_SYSCFG_EXTI_PORTH * (*) value not defined in all devices */ __STATIC_INLINE uint32_t LL_SYSCFG_GetEXTISource(uint32_t Line) { return (uint32_t)(READ_BIT(SYSCFG->EXTICR[Line & 0xFF], (Line >> 16)) >> POSITION_VAL(Line >> 16)); } #if defined(SYSCFG_CFGR2_LOCKUP_LOCK) /** * @brief Set connections to TIM1/8 break inputs * @rmtoll SYSCFG_CFGR2 LockUp Lock LL_SYSCFG_SetTIMBreakInputs \n * SYSCFG_CFGR2 PVD Lock LL_SYSCFG_SetTIMBreakInputs * @param Break This parameter can be a combination of the following values: * @arg @ref LL_SYSCFG_TIMBREAK_LOCKUP * @arg @ref LL_SYSCFG_TIMBREAK_PVD * @retval None */ __STATIC_INLINE void LL_SYSCFG_SetTIMBreakInputs(uint32_t Break) { MODIFY_REG(SYSCFG->CFGR2, SYSCFG_CFGR2_LOCKUP_LOCK | SYSCFG_CFGR2_PVD_LOCK, Break); } /** * @brief Get connections to TIM1/8 Break inputs * @rmtoll SYSCFG_CFGR2 LockUp Lock LL_SYSCFG_SetTIMBreakInputs \n * SYSCFG_CFGR2 PVD Lock LL_SYSCFG_SetTIMBreakInputs * @retval Returned value can be can be a combination of the following values: * @arg @ref LL_SYSCFG_TIMBREAK_LOCKUP * @arg @ref LL_SYSCFG_TIMBREAK_PVD */ __STATIC_INLINE uint32_t LL_SYSCFG_GetTIMBreakInputs(void) { return (uint32_t)(READ_BIT(SYSCFG->CFGR2, SYSCFG_CFGR2_LOCKUP_LOCK | SYSCFG_CFGR2_PVD_LOCK)); } #endif /* SYSCFG_CFGR2_LOCKUP_LOCK */ #if defined(SYSCFG_MCHDLYCR_BSCKSEL) /** * @brief Select the DFSDM2 or TIM2_OC1 as clock source for the bitstream clock. * @rmtoll SYSCFG_MCHDLYCR BSCKSEL LL_SYSCFG_DFSDM_SetBitstreamClockSourceSelection * @param ClockSource This parameter can be one of the following values: * @arg @ref LL_SYSCFG_BITSTREAM_CLOCK_DFSDM2 * @arg @ref LL_SYSCFG_BITSTREAM_CLOCK_TIM2OC1 * @retval None */ __STATIC_INLINE void LL_SYSCFG_DFSDM_SetBitstreamClockSourceSelection(uint32_t ClockSource) { MODIFY_REG(SYSCFG->MCHDLYCR, SYSCFG_MCHDLYCR_BSCKSEL, ClockSource); } /** * @brief Get the DFSDM2 or TIM2_OC1 as clock source for the bitstream clock. * @rmtoll SYSCFG_MCHDLYCR BSCKSEL LL_SYSCFG_DFSDM_GetBitstreamClockSourceSelection * @retval Returned value can be one of the following values: * @arg @ref LL_SYSCFG_BITSTREAM_CLOCK_DFSDM2 * @arg @ref LL_SYSCFG_BITSTREAM_CLOCK_TIM2OC1 * @retval None */ __STATIC_INLINE uint32_t LL_SYSCFG_DFSDM_GetBitstreamClockSourceSelection(void) { return (uint32_t)(READ_BIT(SYSCFG->MCHDLYCR, SYSCFG_MCHDLYCR_BSCKSEL)); } /** * @brief Enables the DFSDM1 or DFSDM2 Delay clock * @rmtoll SYSCFG_MCHDLYCR MCHDLYEN LL_SYSCFG_DFSDM_EnableDelayClock * @param MCHDLY This paramater can be one of the following values * @arg @ref LL_SYSCFG_DFSDM1_MCHDLYEN * @arg @ref LL_SYSCFG_DFSDM2_MCHDLYEN * @retval None */ __STATIC_INLINE void LL_SYSCFG_DFSDM_EnableDelayClock(uint32_t MCHDLY) { SET_BIT(SYSCFG->MCHDLYCR, MCHDLY); } /** * @brief Disables the DFSDM1 or the DFSDM2 Delay clock * @rmtoll SYSCFG_MCHDLYCR MCHDLY1EN LL_SYSCFG_DFSDM1_DisableDelayClock * @param MCHDLY This paramater can be one of the following values * @arg @ref LL_SYSCFG_DFSDM1_MCHDLYEN * @arg @ref LL_SYSCFG_DFSDM2_MCHDLYEN * @retval None */ __STATIC_INLINE void LL_SYSCFG_DFSDM_DisableDelayClock(uint32_t MCHDLY) { CLEAR_BIT(SYSCFG->MCHDLYCR, MCHDLY); } /** * @brief Select the source for DFSDM1 or DFSDM2 DatIn0 * @rmtoll SYSCFG_MCHDLYCR DFSDMD0SEL LL_SYSCFG_DFSDM_SetDataIn0Source * @param Source This parameter can be one of the following values: * @arg @ref LL_SYSCFG_DFSDM1_DataIn0_PAD * @arg @ref LL_SYSCFG_DFSDM1_DataIn0_DM * @arg @ref LL_SYSCFG_DFSDM2_DataIn0_PAD * @arg @ref LL_SYSCFG_DFSDM2_DataIn0_DM * @retval None */ __STATIC_INLINE void LL_SYSCFG_DFSDM_SetDataIn0Source(uint32_t Source) { MODIFY_REG(SYSCFG->MCHDLYCR, (Source >> 16), (Source & 0x0000FFFF)); } /** * @brief Get the source for DFSDM1 or DFSDM2 DatIn0. * @rmtoll SYSCFG_MCHDLYCR DFSDMD0SEL LL_SYSCFG_DFSDM_GetDataIn0Source * @param Source This parameter can be one of the following values: * @arg @ref LL_SYSCFG_DFSDM1_DataIn0 * @arg @ref LL_SYSCFG_DFSDM2_DataIn0 * @retval Returned value can be one of the following values: * @arg @ref LL_SYSCFG_DFSDM1_DataIn0_PAD * @arg @ref LL_SYSCFG_DFSDM1_DataIn0_DM * @arg @ref LL_SYSCFG_DFSDM2_DataIn0_PAD * @arg @ref LL_SYSCFG_DFSDM2_DataIn0_DM * @retval None */ __STATIC_INLINE uint32_t LL_SYSCFG_DFSDM_GetDataIn0Source(uint32_t Source) { return (uint32_t)(READ_BIT(SYSCFG->MCHDLYCR, Source)); } /** * @brief Select the source for DFSDM1 or DFSDM2 DatIn2 * @rmtoll SYSCFG_MCHDLYCR DFSDMD2SEL LL_SYSCFG_DFSDM_SetDataIn2Source * @param Source This parameter can be one of the following values: * @arg @ref LL_SYSCFG_DFSDM1_DataIn2_PAD * @arg @ref LL_SYSCFG_DFSDM1_DataIn2_DM * @arg @ref LL_SYSCFG_DFSDM2_DataIn2_PAD * @arg @ref LL_SYSCFG_DFSDM2_DataIn2_DM * @retval None */ __STATIC_INLINE void LL_SYSCFG_DFSDM_SetDataIn2Source(uint32_t Source) { MODIFY_REG(SYSCFG->MCHDLYCR, (Source >> 16), (Source & 0x0000FFFF)); } /** * @brief Get the source for DFSDM1 or DFSDM2 DatIn2. * @rmtoll SYSCFG_MCHDLYCR DFSDMD2SEL LL_SYSCFG_DFSDM_GetDataIn2Source * @param Source This parameter can be one of the following values: * @arg @ref LL_SYSCFG_DFSDM1_DataIn2 * @arg @ref LL_SYSCFG_DFSDM2_DataIn2 * @retval Returned value can be one of the following values: * @arg @ref LL_SYSCFG_DFSDM1_DataIn2_PAD * @arg @ref LL_SYSCFG_DFSDM1_DataIn2_DM * @arg @ref LL_SYSCFG_DFSDM2_DataIn2_PAD * @arg @ref LL_SYSCFG_DFSDM2_DataIn2_DM * @retval None */ __STATIC_INLINE uint32_t LL_SYSCFG_DFSDM_GetDataIn2Source(uint32_t Source) { return (uint32_t)(READ_BIT(SYSCFG->MCHDLYCR, Source)); } /** * @brief Select the distribution of the bitsream lock gated by TIM4 OC2 * @rmtoll SYSCFG_MCHDLYCR DFSDM1CK02SEL LL_SYSCFG_DFSDM1_SetTIM4OC2BitStreamDistribution * @param Source This parameter can be one of the following values: * @arg @ref LL_SYSCFG_DFSDM1_TIM4OC2_CLKIN0 * @arg @ref LL_SYSCFG_DFSDM1_TIM4OC2_CLKIN2 * @retval None */ __STATIC_INLINE void LL_SYSCFG_DFSDM1_SetTIM4OC2BitStreamDistribution(uint32_t Source) { MODIFY_REG(SYSCFG->MCHDLYCR, SYSCFG_MCHDLYCR_DFSDM1CK02SEL, Source); } /** * @brief Get the distribution of the bitsream lock gated by TIM4 OC2 * @rmtoll SYSCFG_MCHDLYCR DFSDM1D2SEL LL_SYSCFG_DFSDM1_GetTIM4OC2BitStreamDistribution * @retval Returned value can be one of the following values: * @arg @ref LL_SYSCFG_DFSDM1_TIM4OC2_CLKIN0 * @arg @ref LL_SYSCFG_DFSDM1_TIM4OC2_CLKIN2 * @retval None */ __STATIC_INLINE uint32_t LL_SYSCFG_DFSDM1_GetTIM4OC2BitStreamDistribution(void) { return (uint32_t)(READ_BIT(SYSCFG->MCHDLYCR, SYSCFG_MCHDLYCR_DFSDM1CK02SEL)); } /** * @brief Select the distribution of the bitsream lock gated by TIM4 OC1 * @rmtoll SYSCFG_MCHDLYCR DFSDM1CK13SEL LL_SYSCFG_DFSDM1_SetTIM4OC1BitStreamDistribution * @param Source This parameter can be one of the following values: * @arg @ref LL_SYSCFG_DFSDM1_TIM4OC1_CLKIN1 * @arg @ref LL_SYSCFG_DFSDM1_TIM4OC1_CLKIN3 * @retval None */ __STATIC_INLINE void LL_SYSCFG_DFSDM1_SetTIM4OC1BitStreamDistribution(uint32_t Source) { MODIFY_REG(SYSCFG->MCHDLYCR, SYSCFG_MCHDLYCR_DFSDM1CK13SEL, Source); } /** * @brief Get the distribution of the bitsream lock gated by TIM4 OC1 * @rmtoll SYSCFG_MCHDLYCR DFSDM1D2SEL LL_SYSCFG_DFSDM1_GetTIM4OC1BitStreamDistribution * @retval Returned value can be one of the following values: * @arg @ref LL_SYSCFG_DFSDM1_TIM4OC1_CLKIN1 * @arg @ref LL_SYSCFG_DFSDM1_TIM4OC1_CLKIN3 * @retval None */ __STATIC_INLINE uint32_t LL_SYSCFG_DFSDM1_GetTIM4OC1BitStreamDistribution(void) { return (uint32_t)(READ_BIT(SYSCFG->MCHDLYCR, SYSCFG_MCHDLYCR_DFSDM1CK13SEL)); } /** * @brief Select the DFSDM1 Clock In * @rmtoll SYSCFG_MCHDLYCR DFSDM1CFG LL_SYSCFG_DFSDM1_SetClockInSourceSelection * @param ClockSource This parameter can be one of the following values: * @arg @ref LL_SYSCFG_DFSDM1_CKIN_PAD * @arg @ref LL_SYSCFG_DFSDM1_CKIN_DM * @retval None */ __STATIC_INLINE void LL_SYSCFG_DFSDM1_SetClockInSourceSelection(uint32_t ClockSource) { MODIFY_REG(SYSCFG->MCHDLYCR, SYSCFG_MCHDLYCR_DFSDM1CFG, ClockSource); } /** * @brief GET the DFSDM1 Clock In * @rmtoll SYSCFG_MCHDLYCR DFSDM1CFG LL_SYSCFG_DFSDM1_GetClockInSourceSelection * @retval Returned value can be one of the following values: * @arg @ref LL_SYSCFG_DFSDM1_CKIN_PAD * @arg @ref LL_SYSCFG_DFSDM1_CKIN_DM * @retval None */ __STATIC_INLINE uint32_t LL_SYSCFG_DFSDM1_GetClockInSourceSelection(void) { return (uint32_t)(READ_BIT(SYSCFG->MCHDLYCR, SYSCFG_MCHDLYCR_DFSDM1CFG)); } /** * @brief Select the DFSDM1 Clock Out * @rmtoll SYSCFG_MCHDLYCR DFSDM1CKOSEL LL_SYSCFG_DFSDM1_SetClockOutSourceSelection * @param ClockSource This parameter can be one of the following values: * @arg @ref LL_SYSCFG_DFSDM1_CKOUT * @arg @ref LL_SYSCFG_DFSDM1_CKOUT_M27 * @retval None */ __STATIC_INLINE void LL_SYSCFG_DFSDM1_SetClockOutSourceSelection(uint32_t ClockSource) { MODIFY_REG(SYSCFG->MCHDLYCR, SYSCFG_MCHDLYCR_DFSDM1CKOSEL, ClockSource); } /** * @brief GET the DFSDM1 Clock Out * @rmtoll SYSCFG_MCHDLYCR DFSDM1CKOSEL LL_SYSCFG_DFSDM1_GetClockOutSourceSelection * @retval Returned value can be one of the following values: * @arg @ref LL_SYSCFG_DFSDM1_CKOUT * @arg @ref LL_SYSCFG_DFSDM1_CKOUT_M27 * @retval None */ __STATIC_INLINE uint32_t LL_SYSCFG_DFSDM1_GetClockOutSourceSelection(void) { return (uint32_t)(READ_BIT(SYSCFG->MCHDLYCR, SYSCFG_MCHDLYCR_DFSDM1CKOSEL)); } /** * @brief Enables the DFSDM2 Delay clock * @rmtoll SYSCFG_MCHDLYCR MCHDLY2EN LL_SYSCFG_DFSDM2_EnableDelayClock * @retval None */ __STATIC_INLINE void LL_SYSCFG_DFSDM2_EnableDelayClock(void) { SET_BIT(SYSCFG->MCHDLYCR, SYSCFG_MCHDLYCR_MCHDLY2EN); } /** * @brief Disables the DFSDM2 Delay clock * @rmtoll SYSCFG_MCHDLYCR MCHDLY2EN LL_SYSCFG_DFSDM2_DisableDelayClock * @retval None */ __STATIC_INLINE void LL_SYSCFG_DFSDM2_DisableDelayClock(void) { CLEAR_BIT(SYSCFG->MCHDLYCR, SYSCFG_MCHDLYCR_MCHDLY2EN); } /** * @brief Select the source for DFSDM2 DatIn0 * @rmtoll SYSCFG_MCHDLYCR DFSDM2D0SEL LL_SYSCFG_DFSDM2_SetDataIn0Source * @param Source This parameter can be one of the following values: * @arg @ref LL_SYSCFG_DFSDM2_DataIn0_PAD * @arg @ref LL_SYSCFG_DFSDM2_DataIn0_DM * @retval None */ __STATIC_INLINE void LL_SYSCFG_DFSDM2_SetDataIn0Source(uint32_t Source) { MODIFY_REG(SYSCFG->MCHDLYCR, SYSCFG_MCHDLYCR_DFSDM2D0SEL, Source); } /** * @brief Get the source for DFSDM2 DatIn0. * @rmtoll SYSCFG_MCHDLYCR DFSDM2D0SEL LL_SYSCFG_DFSDM2_GetDataIn0Source * @retval Returned value can be one of the following values: * @arg @ref LL_SYSCFG_DFSDM2_DataIn0_PAD * @arg @ref LL_SYSCFG_DFSDM2_DataIn0_DM * @retval None */ __STATIC_INLINE uint32_t LL_SYSCFG_DFSDM2_GetDataIn0Source(void) { return (uint32_t)(READ_BIT(SYSCFG->MCHDLYCR, SYSCFG_MCHDLYCR_DFSDM2D0SEL)); } /** * @brief Select the source for DFSDM2 DatIn2 * @rmtoll SYSCFG_MCHDLYCR DFSDM2D2SEL LL_SYSCFG_DFSDM2_SetDataIn2Source * @param Source This parameter can be one of the following values: * @arg @ref LL_SYSCFG_DFSDM2_DataIn2_PAD * @arg @ref LL_SYSCFG_DFSDM2_DataIn2_DM * @retval None */ __STATIC_INLINE void LL_SYSCFG_DFSDM2_SetDataIn2Source(uint32_t Source) { MODIFY_REG(SYSCFG->MCHDLYCR, SYSCFG_MCHDLYCR_DFSDM2D2SEL, Source); } /** * @brief Get the source for DFSDM2 DatIn2. * @rmtoll SYSCFG_MCHDLYCR DFSDM2D2SEL LL_SYSCFG_DFSDM2_GetDataIn2Source * @retval Returned value can be one of the following values: * @arg @ref LL_SYSCFG_DFSDM2_DataIn2_PAD * @arg @ref LL_SYSCFG_DFSDM2_DataIn2_DM * @retval None */ __STATIC_INLINE uint32_t LL_SYSCFG_DFSDM2_GetDataIn2Source(void) { return (uint32_t)(READ_BIT(SYSCFG->MCHDLYCR, SYSCFG_MCHDLYCR_DFSDM2D2SEL)); } /** * @brief Select the source for DFSDM2 DatIn4 * @rmtoll SYSCFG_MCHDLYCR DFSDM2D4SEL LL_SYSCFG_DFSDM2_SetDataIn4Source * @param Source This parameter can be one of the following values: * @arg @ref LL_SYSCFG_DFSDM2_DataIn4_PAD * @arg @ref LL_SYSCFG_DFSDM2_DataIn4_DM * @retval None */ __STATIC_INLINE void LL_SYSCFG_DFSDM2_SetDataIn4Source(uint32_t Source) { MODIFY_REG(SYSCFG->MCHDLYCR, SYSCFG_MCHDLYCR_DFSDM2D4SEL, Source); } /** * @brief Get the source for DFSDM2 DatIn4. * @rmtoll SYSCFG_MCHDLYCR DFSDM2D4SEL LL_SYSCFG_DFSDM2_GetDataIn4Source * @retval Returned value can be one of the following values: * @arg @ref LL_SYSCFG_DFSDM2_DataIn4_PAD * @arg @ref LL_SYSCFG_DFSDM2_DataIn4_DM * @retval None */ __STATIC_INLINE uint32_t LL_SYSCFG_DFSDM2_GetDataIn4Source(void) { return (uint32_t)(READ_BIT(SYSCFG->MCHDLYCR, SYSCFG_MCHDLYCR_DFSDM2D4SEL)); } /** * @brief Select the source for DFSDM2 DatIn6 * @rmtoll SYSCFG_MCHDLYCR DFSDM2D6SEL LL_SYSCFG_DFSDM2_SetDataIn6Source * @param Source This parameter can be one of the following values: * @arg @ref LL_SYSCFG_DFSDM2_DataIn6_PAD * @arg @ref LL_SYSCFG_DFSDM2_DataIn6_DM * @retval None */ __STATIC_INLINE void LL_SYSCFG_DFSDM2_SetDataIn6Source(uint32_t Source) { MODIFY_REG(SYSCFG->MCHDLYCR, SYSCFG_MCHDLYCR_DFSDM2D6SEL, Source); } /** * @brief Get the source for DFSDM2 DatIn6. * @rmtoll SYSCFG_MCHDLYCR DFSDM2D6SEL LL_SYSCFG_DFSDM2_GetDataIn6Source * @retval Returned value can be one of the following values: * @arg @ref LL_SYSCFG_DFSDM2_DataIn6_PAD * @arg @ref LL_SYSCFG_DFSDM2_DataIn6_DM * @retval None */ __STATIC_INLINE uint32_t LL_SYSCFG_DFSDM2_GetDataIn6Source(void) { return (uint32_t)(READ_BIT(SYSCFG->MCHDLYCR, SYSCFG_MCHDLYCR_DFSDM2D6SEL)); } /** * @brief Select the distribution of the bitsream lock gated by TIM3 OC4 * @rmtoll SYSCFG_MCHDLYCR DFSDM2CK04SEL LL_SYSCFG_DFSDM2_SetTIM3OC4BitStreamDistribution * @param Source This parameter can be one of the following values: * @arg @ref LL_SYSCFG_DFSDM2_TIM3OC4_CLKIN0 * @arg @ref LL_SYSCFG_DFSDM2_TIM3OC4_CLKIN4 * @retval None */ __STATIC_INLINE void LL_SYSCFG_DFSDM2_SetTIM3OC4BitStreamDistribution(uint32_t Source) { MODIFY_REG(SYSCFG->MCHDLYCR, SYSCFG_MCHDLYCR_DFSDM2CK04SEL, Source); } /** * @brief Get the distribution of the bitsream lock gated by TIM3 OC4 * @rmtoll SYSCFG_MCHDLYCR DFSDM2CK04SEL LL_SYSCFG_DFSDM2_GetTIM3OC4BitStreamDistribution * @retval Returned value can be one of the following values: * @arg @ref LL_SYSCFG_DFSDM2_TIM3OC4_CLKIN0 * @arg @ref LL_SYSCFG_DFSDM2_TIM3OC4_CLKIN4 * @retval None */ __STATIC_INLINE uint32_t LL_SYSCFG_DFSDM2_GetTIM3OC4BitStreamDistribution(void) { return (uint32_t)(READ_BIT(SYSCFG->MCHDLYCR, SYSCFG_MCHDLYCR_DFSDM2CK04SEL)); } /** * @brief Select the distribution of the bitsream lock gated by TIM3 OC3 * @rmtoll SYSCFG_MCHDLYCR DFSDM2CK15SEL LL_SYSCFG_DFSDM2_SetTIM3OC3BitStreamDistribution * @param Source This parameter can be one of the following values: * @arg @ref LL_SYSCFG_DFSDM2_TIM3OC3_CLKIN1 * @arg @ref LL_SYSCFG_DFSDM2_TIM3OC3_CLKIN5 * @retval None */ __STATIC_INLINE void LL_SYSCFG_DFSDM2_SetTIM3OC3BitStreamDistribution(uint32_t Source) { MODIFY_REG(SYSCFG->MCHDLYCR, SYSCFG_MCHDLYCR_DFSDM2CK15SEL, Source); } /** * @brief Get the distribution of the bitsream lock gated by TIM3 OC4 * @rmtoll SYSCFG_MCHDLYCR DFSDM2CK04SEL LL_SYSCFG_DFSDM2_GetTIM3OC3BitStreamDistribution * @retval Returned value can be one of the following values: * @arg @ref LL_SYSCFG_DFSDM2_TIM3OC3_CLKIN1 * @arg @ref LL_SYSCFG_DFSDM2_TIM3OC3_CLKIN5 * @retval None */ __STATIC_INLINE uint32_t LL_SYSCFG_DFSDM2_GetTIM3OC3BitStreamDistribution(void) { return (uint32_t)(READ_BIT(SYSCFG->MCHDLYCR, SYSCFG_MCHDLYCR_DFSDM2CK15SEL)); } /** * @brief Select the distribution of the bitsream lock gated by TIM3 OC2 * @rmtoll SYSCFG_MCHDLYCR DFSDM2CK26SEL LL_SYSCFG_DFSDM2_SetTIM3OC2BitStreamDistribution * @param Source This parameter can be one of the following values: * @arg @ref LL_SYSCFG_DFSDM2_TIM3OC2_CLKIN2 * @arg @ref LL_SYSCFG_DFSDM2_TIM3OC2_CLKIN6 * @retval None */ __STATIC_INLINE void LL_SYSCFG_DFSDM2_SetTIM3OC2BitStreamDistribution(uint32_t Source) { MODIFY_REG(SYSCFG->MCHDLYCR, SYSCFG_MCHDLYCR_DFSDM2CK26SEL, Source); } /** * @brief Get the distribution of the bitsream lock gated by TIM3 OC2 * @rmtoll SYSCFG_MCHDLYCR DFSDM2CK04SEL LL_SYSCFG_DFSDM2_GetTIM3OC2BitStreamDistribution * @retval Returned value can be one of the following values: * @arg @ref LL_SYSCFG_DFSDM2_TIM3OC2_CLKIN2 * @arg @ref LL_SYSCFG_DFSDM2_TIM3OC2_CLKIN6 * @retval None */ __STATIC_INLINE uint32_t LL_SYSCFG_DFSDM2_GetTIM3OC2BitStreamDistribution(void) { return (uint32_t)(READ_BIT(SYSCFG->MCHDLYCR, SYSCFG_MCHDLYCR_DFSDM2CK26SEL)); } /** * @brief Select the distribution of the bitsream lock gated by TIM3 OC1 * @rmtoll SYSCFG_MCHDLYCR DFSDM2CK37SEL LL_SYSCFG_DFSDM2_SetTIM3OC1BitStreamDistribution * @param Source This parameter can be one of the following values: * @arg @ref LL_SYSCFG_DFSDM2_TIM3OC1_CLKIN3 * @arg @ref LL_SYSCFG_DFSDM2_TIM3OC1_CLKIN7 * @retval None */ __STATIC_INLINE void LL_SYSCFG_DFSDM2_SetTIM3OC1BitStreamDistribution(uint32_t Source) { MODIFY_REG(SYSCFG->MCHDLYCR, SYSCFG_MCHDLYCR_DFSDM2CK37SEL, Source); } /** * @brief Get the distribution of the bitsream lock gated by TIM3 OC1 * @rmtoll SYSCFG_MCHDLYCR DFSDM2CK37SEL LL_SYSCFG_DFSDM2_GetTIM3OC1BitStreamDistribution * @retval Returned value can be one of the following values: * @arg @ref LL_SYSCFG_DFSDM2_TIM3OC1_CLKIN3 * @arg @ref LL_SYSCFG_DFSDM2_TIM3OC1_CLKIN7 * @retval None */ __STATIC_INLINE uint32_t LL_SYSCFG_DFSDM2_GetTIM3OC1BitStreamDistribution(void) { return (uint32_t)(READ_BIT(SYSCFG->MCHDLYCR, SYSCFG_MCHDLYCR_DFSDM2CK37SEL)); } /** * @brief Select the DFSDM2 Clock In * @rmtoll SYSCFG_MCHDLYCR DFSDM2CFG LL_SYSCFG_DFSDM2_SetClockInSourceSelection * @param ClockSource This parameter can be one of the following values: * @arg @ref LL_SYSCFG_DFSDM2_CKIN_PAD * @arg @ref LL_SYSCFG_DFSDM2_CKIN_DM * @retval None */ __STATIC_INLINE void LL_SYSCFG_DFSDM2_SetClockInSourceSelection(uint32_t ClockSource) { MODIFY_REG(SYSCFG->MCHDLYCR, SYSCFG_MCHDLYCR_DFSDM2CFG, ClockSource); } /** * @brief GET the DFSDM2 Clock In * @rmtoll SYSCFG_MCHDLYCR DFSDM2CFG LL_SYSCFG_DFSDM2_GetClockInSourceSelection * @retval Returned value can be one of the following values: * @arg @ref LL_SYSCFG_DFSDM2_CKIN_PAD * @arg @ref LL_SYSCFG_DFSDM2_CKIN_DM * @retval None */ __STATIC_INLINE uint32_t LL_SYSCFG_DFSDM2_GetClockInSourceSelection(void) { return (uint32_t)(READ_BIT(SYSCFG->MCHDLYCR, SYSCFG_MCHDLYCR_DFSDM2CFG)); } /** * @brief Select the DFSDM2 Clock Out * @rmtoll SYSCFG_MCHDLYCR DFSDM2CKOSEL LL_SYSCFG_DFSDM2_SetClockOutSourceSelection * @param ClockSource This parameter can be one of the following values: * @arg @ref LL_SYSCFG_DFSDM2_CKOUT * @arg @ref LL_SYSCFG_DFSDM2_CKOUT_M27 * @retval None */ __STATIC_INLINE void LL_SYSCFG_DFSDM2_SetClockOutSourceSelection(uint32_t ClockSource) { MODIFY_REG(SYSCFG->MCHDLYCR, SYSCFG_MCHDLYCR_DFSDM2CKOSEL, ClockSource); } /** * @brief GET the DFSDM2 Clock Out * @rmtoll SYSCFG_MCHDLYCR DFSDM2CKOSEL LL_SYSCFG_DFSDM2_GetClockOutSourceSelection * @retval Returned value can be one of the following values: * @arg @ref LL_SYSCFG_DFSDM2_CKOUT * @arg @ref LL_SYSCFG_DFSDM2_CKOUT_M27 * @retval None */ __STATIC_INLINE uint32_t LL_SYSCFG_DFSDM2_GetClockOutSourceSelection(void) { return (uint32_t)(READ_BIT(SYSCFG->MCHDLYCR, SYSCFG_MCHDLYCR_DFSDM2CKOSEL)); } #endif /* SYSCFG_MCHDLYCR_BSCKSEL */ /** * @} */ /** @defgroup SYSTEM_LL_EF_DBGMCU DBGMCU * @{ */ /** * @brief Return the device identifier * @note For STM32F405/407xx and STM32F415/417xx devices, the device ID is 0x413 * @note For STM32F42xxx and STM32F43xxx devices, the device ID is 0x419 * @note For STM32F401xx devices, the device ID is 0x423 * @note For STM32F401xx devices, the device ID is 0x433 * @note For STM32F411xx devices, the device ID is 0x431 * @note For STM32F410xx devices, the device ID is 0x458 * @note For STM32F412xx devices, the device ID is 0x441 * @note For STM32F413xx and STM32423xx devices, the device ID is 0x463 * @note For STM32F446xx devices, the device ID is 0x421 * @note For STM32F469xx and STM32F479xx devices, the device ID is 0x434 * @rmtoll DBGMCU_IDCODE DEV_ID LL_DBGMCU_GetDeviceID * @retval Values between Min_Data=0x00 and Max_Data=0xFFF */ __STATIC_INLINE uint32_t LL_DBGMCU_GetDeviceID(void) { return (uint32_t)(READ_BIT(DBGMCU->IDCODE, DBGMCU_IDCODE_DEV_ID)); } /** * @brief Return the device revision identifier * @note This field indicates the revision of the device. For example, it is read as RevA -> 0x1000, Cat 2 revZ -> 0x1001, rev1 -> 0x1003, rev2 ->0x1007, revY -> 0x100F for STM32F405/407xx and STM32F415/417xx devices For example, it is read as RevA -> 0x1000, Cat 2 revY -> 0x1003, rev1 -> 0x1007, rev3 ->0x2001 for STM32F42xxx and STM32F43xxx devices For example, it is read as RevZ -> 0x1000, Cat 2 revA -> 0x1001 for STM32F401xB/C devices For example, it is read as RevA -> 0x1000, Cat 2 revZ -> 0x1001 for STM32F401xD/E devices For example, it is read as RevA -> 0x1000 for STM32F411xx,STM32F413/423xx,STM32F469/423xx, STM32F446xx and STM32F410xx devices For example, it is read as RevZ -> 0x1001, Cat 2 revB -> 0x2000, revC -> 0x3000 for STM32F412xx devices * @rmtoll DBGMCU_IDCODE REV_ID LL_DBGMCU_GetRevisionID * @retval Values between Min_Data=0x00 and Max_Data=0xFFFF */ __STATIC_INLINE uint32_t LL_DBGMCU_GetRevisionID(void) { return (uint32_t)(READ_BIT(DBGMCU->IDCODE, DBGMCU_IDCODE_REV_ID) >> DBGMCU_IDCODE_REV_ID_Pos); } /** * @brief Enable the Debug Module during SLEEP mode * @rmtoll DBGMCU_CR DBG_SLEEP LL_DBGMCU_EnableDBGSleepMode * @retval None */ __STATIC_INLINE void LL_DBGMCU_EnableDBGSleepMode(void) { SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_SLEEP); } /** * @brief Disable the Debug Module during SLEEP mode * @rmtoll DBGMCU_CR DBG_SLEEP LL_DBGMCU_DisableDBGSleepMode * @retval None */ __STATIC_INLINE void LL_DBGMCU_DisableDBGSleepMode(void) { CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_SLEEP); } /** * @brief Enable the Debug Module during STOP mode * @rmtoll DBGMCU_CR DBG_STOP LL_DBGMCU_EnableDBGStopMode * @retval None */ __STATIC_INLINE void LL_DBGMCU_EnableDBGStopMode(void) { SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STOP); } /** * @brief Disable the Debug Module during STOP mode * @rmtoll DBGMCU_CR DBG_STOP LL_DBGMCU_DisableDBGStopMode * @retval None */ __STATIC_INLINE void LL_DBGMCU_DisableDBGStopMode(void) { CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STOP); } /** * @brief Enable the Debug Module during STANDBY mode * @rmtoll DBGMCU_CR DBG_STANDBY LL_DBGMCU_EnableDBGStandbyMode * @retval None */ __STATIC_INLINE void LL_DBGMCU_EnableDBGStandbyMode(void) { SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STANDBY); } /** * @brief Disable the Debug Module during STANDBY mode * @rmtoll DBGMCU_CR DBG_STANDBY LL_DBGMCU_DisableDBGStandbyMode * @retval None */ __STATIC_INLINE void LL_DBGMCU_DisableDBGStandbyMode(void) { CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STANDBY); } /** * @brief Set Trace pin assignment control * @rmtoll DBGMCU_CR TRACE_IOEN LL_DBGMCU_SetTracePinAssignment\n * DBGMCU_CR TRACE_MODE LL_DBGMCU_SetTracePinAssignment * @param PinAssignment This parameter can be one of the following values: * @arg @ref LL_DBGMCU_TRACE_NONE * @arg @ref LL_DBGMCU_TRACE_ASYNCH * @arg @ref LL_DBGMCU_TRACE_SYNCH_SIZE1 * @arg @ref LL_DBGMCU_TRACE_SYNCH_SIZE2 * @arg @ref LL_DBGMCU_TRACE_SYNCH_SIZE4 * @retval None */ __STATIC_INLINE void LL_DBGMCU_SetTracePinAssignment(uint32_t PinAssignment) { MODIFY_REG(DBGMCU->CR, DBGMCU_CR_TRACE_IOEN | DBGMCU_CR_TRACE_MODE, PinAssignment); } /** * @brief Get Trace pin assignment control * @rmtoll DBGMCU_CR TRACE_IOEN LL_DBGMCU_GetTracePinAssignment\n * DBGMCU_CR TRACE_MODE LL_DBGMCU_GetTracePinAssignment * @retval Returned value can be one of the following values: * @arg @ref LL_DBGMCU_TRACE_NONE * @arg @ref LL_DBGMCU_TRACE_ASYNCH * @arg @ref LL_DBGMCU_TRACE_SYNCH_SIZE1 * @arg @ref LL_DBGMCU_TRACE_SYNCH_SIZE2 * @arg @ref LL_DBGMCU_TRACE_SYNCH_SIZE4 */ __STATIC_INLINE uint32_t LL_DBGMCU_GetTracePinAssignment(void) { return (uint32_t)(READ_BIT(DBGMCU->CR, DBGMCU_CR_TRACE_IOEN | DBGMCU_CR_TRACE_MODE)); } /** * @brief Freeze APB1 peripherals (group1 peripherals) * @rmtoll DBGMCU_APB1_FZ DBG_TIM2_STOP LL_DBGMCU_APB1_GRP1_FreezePeriph\n * DBGMCU_APB1_FZ DBG_TIM3_STOP LL_DBGMCU_APB1_GRP1_FreezePeriph\n * DBGMCU_APB1_FZ DBG_TIM4_STOP LL_DBGMCU_APB1_GRP1_FreezePeriph\n * DBGMCU_APB1_FZ DBG_TIM5_STOP LL_DBGMCU_APB1_GRP1_FreezePeriph\n * DBGMCU_APB1_FZ DBG_TIM6_STOP LL_DBGMCU_APB1_GRP1_FreezePeriph\n * DBGMCU_APB1_FZ DBG_TIM7_STOP LL_DBGMCU_APB1_GRP1_FreezePeriph\n * DBGMCU_APB1_FZ DBG_TIM12_STOP LL_DBGMCU_APB1_GRP1_FreezePeriph\n * DBGMCU_APB1_FZ DBG_TIM13_STOP LL_DBGMCU_APB1_GRP1_FreezePeriph\n * DBGMCU_APB1_FZ DBG_TIM14_STOP LL_DBGMCU_APB1_GRP1_FreezePeriph\n * DBGMCU_APB1_FZ DBG_LPTIM_STOP LL_DBGMCU_APB1_GRP1_FreezePeriph\n * DBGMCU_APB1_FZ DBG_RTC_STOP LL_DBGMCU_APB1_GRP1_FreezePeriph\n * DBGMCU_APB1_FZ DBG_WWDG_STOP LL_DBGMCU_APB1_GRP1_FreezePeriph\n * DBGMCU_APB1_FZ DBG_IWDG_STOP LL_DBGMCU_APB1_GRP1_FreezePeriph\n * DBGMCU_APB1_FZ DBG_I2C1_SMBUS_TIMEOUT LL_DBGMCU_APB1_GRP1_FreezePeriph\n * DBGMCU_APB1_FZ DBG_I2C2_SMBUS_TIMEOUT LL_DBGMCU_APB1_GRP1_FreezePeriph\n * DBGMCU_APB1_FZ DBG_I2C3_SMBUS_TIMEOUT LL_DBGMCU_APB1_GRP1_FreezePeriph\n * DBGMCU_APB1_FZ DBG_I2C4_SMBUS_TIMEOUT LL_DBGMCU_APB1_GRP1_FreezePeriph\n * DBGMCU_APB1_FZ DBG_CAN1_STOP LL_DBGMCU_APB1_GRP1_FreezePeriph\n * DBGMCU_APB1_FZ DBG_CAN2_STOP LL_DBGMCU_APB1_GRP1_FreezePeriph\n * DBGMCU_APB1_FZ DBG_CAN3_STOP LL_DBGMCU_APB1_GRP1_FreezePeriph * @param Periphs This parameter can be a combination of the following values: * @arg @ref LL_DBGMCU_APB1_GRP1_TIM2_STOP (*) * @arg @ref LL_DBGMCU_APB1_GRP1_TIM3_STOP (*) * @arg @ref LL_DBGMCU_APB1_GRP1_TIM4_STOP (*) * @arg @ref LL_DBGMCU_APB1_GRP1_TIM5_STOP * @arg @ref LL_DBGMCU_APB1_GRP1_TIM6_STOP (*) * @arg @ref LL_DBGMCU_APB1_GRP1_TIM7_STOP (*) * @arg @ref LL_DBGMCU_APB1_GRP1_TIM12_STOP (*) * @arg @ref LL_DBGMCU_APB1_GRP1_TIM13_STOP (*) * @arg @ref LL_DBGMCU_APB1_GRP1_TIM14_STOP (*) * @arg @ref LL_DBGMCU_APB1_GRP1_LPTIM_STOP (*) * @arg @ref LL_DBGMCU_APB1_GRP1_RTC_STOP * @arg @ref LL_DBGMCU_APB1_GRP1_WWDG_STOP * @arg @ref LL_DBGMCU_APB1_GRP1_IWDG_STOP * @arg @ref LL_DBGMCU_APB1_GRP1_I2C1_STOP * @arg @ref LL_DBGMCU_APB1_GRP1_I2C2_STOP * @arg @ref LL_DBGMCU_APB1_GRP1_I2C3_STOP (*) * @arg @ref LL_DBGMCU_APB1_GRP1_I2C4_STOP (*) * @arg @ref LL_DBGMCU_APB1_GRP1_CAN1_STOP (*) * @arg @ref LL_DBGMCU_APB1_GRP1_CAN2_STOP (*) * @arg @ref LL_DBGMCU_APB1_GRP1_CAN3_STOP (*) * * (*) value not defined in all devices. * @retval None */ __STATIC_INLINE void LL_DBGMCU_APB1_GRP1_FreezePeriph(uint32_t Periphs) { SET_BIT(DBGMCU->APB1FZ, Periphs); } /** * @brief Unfreeze APB1 peripherals (group1 peripherals) * @rmtoll DBGMCU_APB1_FZ DBG_TIM2_STOP LL_DBGMCU_APB1_GRP1_UnFreezePeriph\n * DBGMCU_APB1_FZ DBG_TIM3_STOP LL_DBGMCU_APB1_GRP1_UnFreezePeriph\n * DBGMCU_APB1_FZ DBG_TIM4_STOP LL_DBGMCU_APB1_GRP1_UnFreezePeriph\n * DBGMCU_APB1_FZ DBG_TIM5_STOP LL_DBGMCU_APB1_GRP1_UnFreezePeriph\n * DBGMCU_APB1_FZ DBG_TIM6_STOP LL_DBGMCU_APB1_GRP1_UnFreezePeriph\n * DBGMCU_APB1_FZ DBG_TIM7_STOP LL_DBGMCU_APB1_GRP1_UnFreezePeriph\n * DBGMCU_APB1_FZ DBG_TIM12_STOP LL_DBGMCU_APB1_GRP1_UnFreezePeriph\n * DBGMCU_APB1_FZ DBG_TIM13_STOP LL_DBGMCU_APB1_GRP1_UnFreezePeriph\n * DBGMCU_APB1_FZ DBG_TIM14_STOP LL_DBGMCU_APB1_GRP1_UnFreezePeriph\n * DBGMCU_APB1_FZ DBG_LPTIM_STOP LL_DBGMCU_APB1_GRP1_UnFreezePeriph\n * DBGMCU_APB1_FZ DBG_RTC_STOP LL_DBGMCU_APB1_GRP1_UnFreezePeriph\n * DBGMCU_APB1_FZ DBG_WWDG_STOP LL_DBGMCU_APB1_GRP1_UnFreezePeriph\n * DBGMCU_APB1_FZ DBG_IWDG_STOP LL_DBGMCU_APB1_GRP1_UnFreezePeriph\n * DBGMCU_APB1_FZ DBG_I2C1_SMBUS_TIMEOUT LL_DBGMCU_APB1_GRP1_UnFreezePeriph\n * DBGMCU_APB1_FZ DBG_I2C2_SMBUS_TIMEOUT LL_DBGMCU_APB1_GRP1_UnFreezePeriph\n * DBGMCU_APB1_FZ DBG_I2C3_SMBUS_TIMEOUT LL_DBGMCU_APB1_GRP1_UnFreezePeriph\n * DBGMCU_APB1_FZ DBG_I2C4_SMBUS_TIMEOUT LL_DBGMCU_APB1_GRP1_UnFreezePeriph\n * DBGMCU_APB1_FZ DBG_CAN1_STOP LL_DBGMCU_APB1_GRP1_UnFreezePeriph\n * DBGMCU_APB1_FZ DBG_CAN2_STOP LL_DBGMCU_APB1_GRP1_UnFreezePeriph\n * DBGMCU_APB1_FZ DBG_CAN3_STOP LL_DBGMCU_APB1_GRP1_UnFreezePeriph * @param Periphs This parameter can be a combination of the following values: * @arg @ref LL_DBGMCU_APB1_GRP1_TIM2_STOP (*) * @arg @ref LL_DBGMCU_APB1_GRP1_TIM3_STOP (*) * @arg @ref LL_DBGMCU_APB1_GRP1_TIM4_STOP (*) * @arg @ref LL_DBGMCU_APB1_GRP1_TIM5_STOP * @arg @ref LL_DBGMCU_APB1_GRP1_TIM6_STOP (*) * @arg @ref LL_DBGMCU_APB1_GRP1_TIM7_STOP (*) * @arg @ref LL_DBGMCU_APB1_GRP1_TIM12_STOP (*) * @arg @ref LL_DBGMCU_APB1_GRP1_TIM13_STOP (*) * @arg @ref LL_DBGMCU_APB1_GRP1_TIM14_STOP (*) * @arg @ref LL_DBGMCU_APB1_GRP1_LPTIM_STOP (*) * @arg @ref LL_DBGMCU_APB1_GRP1_RTC_STOP * @arg @ref LL_DBGMCU_APB1_GRP1_WWDG_STOP * @arg @ref LL_DBGMCU_APB1_GRP1_IWDG_STOP * @arg @ref LL_DBGMCU_APB1_GRP1_I2C1_STOP * @arg @ref LL_DBGMCU_APB1_GRP1_I2C2_STOP * @arg @ref LL_DBGMCU_APB1_GRP1_I2C3_STOP (*) * @arg @ref LL_DBGMCU_APB1_GRP1_I2C4_STOP (*) * @arg @ref LL_DBGMCU_APB1_GRP1_CAN1_STOP (*) * @arg @ref LL_DBGMCU_APB1_GRP1_CAN2_STOP (*) * @arg @ref LL_DBGMCU_APB1_GRP1_CAN3_STOP (*) * * (*) value not defined in all devices. * @retval None */ __STATIC_INLINE void LL_DBGMCU_APB1_GRP1_UnFreezePeriph(uint32_t Periphs) { CLEAR_BIT(DBGMCU->APB1FZ, Periphs); } /** * @brief Freeze APB2 peripherals * @rmtoll DBGMCU_APB2_FZ DBG_TIM1_STOP LL_DBGMCU_APB2_GRP1_FreezePeriph\n * DBGMCU_APB2_FZ DBG_TIM8_STOP LL_DBGMCU_APB2_GRP1_FreezePeriph\n * DBGMCU_APB2_FZ DBG_TIM9_STOP LL_DBGMCU_APB2_GRP1_FreezePeriph\n * DBGMCU_APB2_FZ DBG_TIM10_STOP LL_DBGMCU_APB2_GRP1_FreezePeriph\n * DBGMCU_APB2_FZ DBG_TIM11_STOP LL_DBGMCU_APB2_GRP1_FreezePeriph * @param Periphs This parameter can be a combination of the following values: * @arg @ref LL_DBGMCU_APB2_GRP1_TIM1_STOP * @arg @ref LL_DBGMCU_APB2_GRP1_TIM8_STOP (*) * @arg @ref LL_DBGMCU_APB2_GRP1_TIM9_STOP (*) * @arg @ref LL_DBGMCU_APB2_GRP1_TIM10_STOP (*) * @arg @ref LL_DBGMCU_APB2_GRP1_TIM11_STOP (*) * * (*) value not defined in all devices. * @retval None */ __STATIC_INLINE void LL_DBGMCU_APB2_GRP1_FreezePeriph(uint32_t Periphs) { SET_BIT(DBGMCU->APB2FZ, Periphs); } /** * @brief Unfreeze APB2 peripherals * @rmtoll DBGMCU_APB2_FZ DBG_TIM1_STOP LL_DBGMCU_APB2_GRP1_UnFreezePeriph\n * DBGMCU_APB2_FZ DBG_TIM8_STOP LL_DBGMCU_APB2_GRP1_UnFreezePeriph\n * DBGMCU_APB2_FZ DBG_TIM9_STOP LL_DBGMCU_APB2_GRP1_UnFreezePeriph\n * DBGMCU_APB2_FZ DBG_TIM10_STOP LL_DBGMCU_APB2_GRP1_UnFreezePeriph\n * DBGMCU_APB2_FZ DBG_TIM11_STOP LL_DBGMCU_APB2_GRP1_UnFreezePeriph * @param Periphs This parameter can be a combination of the following values: * @arg @ref LL_DBGMCU_APB2_GRP1_TIM1_STOP * @arg @ref LL_DBGMCU_APB2_GRP1_TIM8_STOP (*) * @arg @ref LL_DBGMCU_APB2_GRP1_TIM9_STOP (*) * @arg @ref LL_DBGMCU_APB2_GRP1_TIM10_STOP (*) * @arg @ref LL_DBGMCU_APB2_GRP1_TIM11_STOP (*) * * (*) value not defined in all devices. * @retval None */ __STATIC_INLINE void LL_DBGMCU_APB2_GRP1_UnFreezePeriph(uint32_t Periphs) { CLEAR_BIT(DBGMCU->APB2FZ, Periphs); } /** * @} */ /** @defgroup SYSTEM_LL_EF_FLASH FLASH * @{ */ /** * @brief Set FLASH Latency * @rmtoll FLASH_ACR LATENCY LL_FLASH_SetLatency * @param Latency This parameter can be one of the following values: * @arg @ref LL_FLASH_LATENCY_0 * @arg @ref LL_FLASH_LATENCY_1 * @arg @ref LL_FLASH_LATENCY_2 * @arg @ref LL_FLASH_LATENCY_3 * @arg @ref LL_FLASH_LATENCY_4 * @arg @ref LL_FLASH_LATENCY_5 * @arg @ref LL_FLASH_LATENCY_6 * @arg @ref LL_FLASH_LATENCY_7 * @arg @ref LL_FLASH_LATENCY_8 * @arg @ref LL_FLASH_LATENCY_9 * @arg @ref LL_FLASH_LATENCY_10 * @arg @ref LL_FLASH_LATENCY_11 * @arg @ref LL_FLASH_LATENCY_12 * @arg @ref LL_FLASH_LATENCY_13 * @arg @ref LL_FLASH_LATENCY_14 * @arg @ref LL_FLASH_LATENCY_15 * @retval None */ __STATIC_INLINE void LL_FLASH_SetLatency(uint32_t Latency) { MODIFY_REG(FLASH->ACR, FLASH_ACR_LATENCY, Latency); } /** * @brief Get FLASH Latency * @rmtoll FLASH_ACR LATENCY LL_FLASH_GetLatency * @retval Returned value can be one of the following values: * @arg @ref LL_FLASH_LATENCY_0 * @arg @ref LL_FLASH_LATENCY_1 * @arg @ref LL_FLASH_LATENCY_2 * @arg @ref LL_FLASH_LATENCY_3 * @arg @ref LL_FLASH_LATENCY_4 * @arg @ref LL_FLASH_LATENCY_5 * @arg @ref LL_FLASH_LATENCY_6 * @arg @ref LL_FLASH_LATENCY_7 * @arg @ref LL_FLASH_LATENCY_8 * @arg @ref LL_FLASH_LATENCY_9 * @arg @ref LL_FLASH_LATENCY_10 * @arg @ref LL_FLASH_LATENCY_11 * @arg @ref LL_FLASH_LATENCY_12 * @arg @ref LL_FLASH_LATENCY_13 * @arg @ref LL_FLASH_LATENCY_14 * @arg @ref LL_FLASH_LATENCY_15 */ __STATIC_INLINE uint32_t LL_FLASH_GetLatency(void) { return (uint32_t)(READ_BIT(FLASH->ACR, FLASH_ACR_LATENCY)); } /** * @brief Enable Prefetch * @rmtoll FLASH_ACR PRFTEN LL_FLASH_EnablePrefetch * @retval None */ __STATIC_INLINE void LL_FLASH_EnablePrefetch(void) { SET_BIT(FLASH->ACR, FLASH_ACR_PRFTEN); } /** * @brief Disable Prefetch * @rmtoll FLASH_ACR PRFTEN LL_FLASH_DisablePrefetch * @retval None */ __STATIC_INLINE void LL_FLASH_DisablePrefetch(void) { CLEAR_BIT(FLASH->ACR, FLASH_ACR_PRFTEN); } /** * @brief Check if Prefetch buffer is enabled * @rmtoll FLASH_ACR PRFTEN LL_FLASH_IsPrefetchEnabled * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_FLASH_IsPrefetchEnabled(void) { return (READ_BIT(FLASH->ACR, FLASH_ACR_PRFTEN) == (FLASH_ACR_PRFTEN)); } /** * @brief Enable Instruction cache * @rmtoll FLASH_ACR ICEN LL_FLASH_EnableInstCache * @retval None */ __STATIC_INLINE void LL_FLASH_EnableInstCache(void) { SET_BIT(FLASH->ACR, FLASH_ACR_ICEN); } /** * @brief Disable Instruction cache * @rmtoll FLASH_ACR ICEN LL_FLASH_DisableInstCache * @retval None */ __STATIC_INLINE void LL_FLASH_DisableInstCache(void) { CLEAR_BIT(FLASH->ACR, FLASH_ACR_ICEN); } /** * @brief Enable Data cache * @rmtoll FLASH_ACR DCEN LL_FLASH_EnableDataCache * @retval None */ __STATIC_INLINE void LL_FLASH_EnableDataCache(void) { SET_BIT(FLASH->ACR, FLASH_ACR_DCEN); } /** * @brief Disable Data cache * @rmtoll FLASH_ACR DCEN LL_FLASH_DisableDataCache * @retval None */ __STATIC_INLINE void LL_FLASH_DisableDataCache(void) { CLEAR_BIT(FLASH->ACR, FLASH_ACR_DCEN); } /** * @brief Enable Instruction cache reset * @note bit can be written only when the instruction cache is disabled * @rmtoll FLASH_ACR ICRST LL_FLASH_EnableInstCacheReset * @retval None */ __STATIC_INLINE void LL_FLASH_EnableInstCacheReset(void) { SET_BIT(FLASH->ACR, FLASH_ACR_ICRST); } /** * @brief Disable Instruction cache reset * @rmtoll FLASH_ACR ICRST LL_FLASH_DisableInstCacheReset * @retval None */ __STATIC_INLINE void LL_FLASH_DisableInstCacheReset(void) { CLEAR_BIT(FLASH->ACR, FLASH_ACR_ICRST); } /** * @brief Enable Data cache reset * @note bit can be written only when the data cache is disabled * @rmtoll FLASH_ACR DCRST LL_FLASH_EnableDataCacheReset * @retval None */ __STATIC_INLINE void LL_FLASH_EnableDataCacheReset(void) { SET_BIT(FLASH->ACR, FLASH_ACR_DCRST); } /** * @brief Disable Data cache reset * @rmtoll FLASH_ACR DCRST LL_FLASH_DisableDataCacheReset * @retval None */ __STATIC_INLINE void LL_FLASH_DisableDataCacheReset(void) { CLEAR_BIT(FLASH->ACR, FLASH_ACR_DCRST); } /** * @} */ /** * @} */ /** * @} */ #endif /* defined (FLASH) || defined (SYSCFG) || defined (DBGMCU) */ /** * @} */ #ifdef __cplusplus } #endif #endif /* __STM32F4xx_LL_SYSTEM_H */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ ================================================ FILE: sys/arch/stm32/hal/stm32f4xx_ll_usart.c ================================================ /** ****************************************************************************** * @file stm32f4xx_ll_usart.c * @author MCD Application Team * @version V1.7.1 * @date 14-April-2017 * @brief USART LL module driver. ****************************************************************************** * @attention * *

© COPYRIGHT(c) 2017 STMicroelectronics

* * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. Neither the name of STMicroelectronics nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ #if defined(USE_FULL_LL_DRIVER) /* Includes ------------------------------------------------------------------*/ #include "stm32f4xx_ll_usart.h" #include "stm32f4xx_ll_rcc.h" #include "stm32f4xx_ll_bus.h" #ifdef USE_FULL_ASSERT #include "stm32_assert.h" #else #define assert_param(expr) ((void)0U) #endif /** @addtogroup STM32F4xx_LL_Driver * @{ */ #if defined (USART1) || defined (USART2) || defined (USART3) || defined (USART6) || defined (UART4) || defined (UART5) || defined (UART7) || defined (UART8) || defined (UART9) || defined (UART10) /** @addtogroup USART_LL * @{ */ /* Private types -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ /* Private constants ---------------------------------------------------------*/ /** @addtogroup USART_LL_Private_Constants * @{ */ /** * @} */ /* Private macros ------------------------------------------------------------*/ /** @addtogroup USART_LL_Private_Macros * @{ */ /* __BAUDRATE__ The maximum Baud Rate is derived from the maximum clock available * divided by the smallest oversampling used on the USART (i.e. 8) */ #define IS_LL_USART_BAUDRATE(__BAUDRATE__) ((__BAUDRATE__) <= 10000000U) #define IS_LL_USART_DIRECTION(__VALUE__) (((__VALUE__) == LL_USART_DIRECTION_NONE) \ || ((__VALUE__) == LL_USART_DIRECTION_RX) \ || ((__VALUE__) == LL_USART_DIRECTION_TX) \ || ((__VALUE__) == LL_USART_DIRECTION_TX_RX)) #define IS_LL_USART_PARITY(__VALUE__) (((__VALUE__) == LL_USART_PARITY_NONE) \ || ((__VALUE__) == LL_USART_PARITY_EVEN) \ || ((__VALUE__) == LL_USART_PARITY_ODD)) #define IS_LL_USART_DATAWIDTH(__VALUE__) (((__VALUE__) == LL_USART_DATAWIDTH_8B) \ || ((__VALUE__) == LL_USART_DATAWIDTH_9B)) #define IS_LL_USART_OVERSAMPLING(__VALUE__) (((__VALUE__) == LL_USART_OVERSAMPLING_16) \ || ((__VALUE__) == LL_USART_OVERSAMPLING_8)) #define IS_LL_USART_LASTBITCLKOUTPUT(__VALUE__) (((__VALUE__) == LL_USART_LASTCLKPULSE_NO_OUTPUT) \ || ((__VALUE__) == LL_USART_LASTCLKPULSE_OUTPUT)) #define IS_LL_USART_CLOCKPHASE(__VALUE__) (((__VALUE__) == LL_USART_PHASE_1EDGE) \ || ((__VALUE__) == LL_USART_PHASE_2EDGE)) #define IS_LL_USART_CLOCKPOLARITY(__VALUE__) (((__VALUE__) == LL_USART_POLARITY_LOW) \ || ((__VALUE__) == LL_USART_POLARITY_HIGH)) #define IS_LL_USART_CLOCKOUTPUT(__VALUE__) (((__VALUE__) == LL_USART_CLOCK_DISABLE) \ || ((__VALUE__) == LL_USART_CLOCK_ENABLE)) #define IS_LL_USART_STOPBITS(__VALUE__) (((__VALUE__) == LL_USART_STOPBITS_0_5) \ || ((__VALUE__) == LL_USART_STOPBITS_1) \ || ((__VALUE__) == LL_USART_STOPBITS_1_5) \ || ((__VALUE__) == LL_USART_STOPBITS_2)) #define IS_LL_USART_HWCONTROL(__VALUE__) (((__VALUE__) == LL_USART_HWCONTROL_NONE) \ || ((__VALUE__) == LL_USART_HWCONTROL_RTS) \ || ((__VALUE__) == LL_USART_HWCONTROL_CTS) \ || ((__VALUE__) == LL_USART_HWCONTROL_RTS_CTS)) /** * @} */ /* Private function prototypes -----------------------------------------------*/ /* Exported functions --------------------------------------------------------*/ /** @addtogroup USART_LL_Exported_Functions * @{ */ /** @addtogroup USART_LL_EF_Init * @{ */ /** * @brief De-initialize USART registers (Registers restored to their default values). * @param USARTx USART Instance * @retval An ErrorStatus enumeration value: * - SUCCESS: USART registers are de-initialized * - ERROR: USART registers are not de-initialized */ ErrorStatus LL_USART_DeInit(USART_TypeDef *USARTx) { ErrorStatus status = SUCCESS; /* Check the parameters */ assert_param(IS_UART_INSTANCE(USARTx)); if (USARTx == USART1) { /* Force reset of USART clock */ LL_APB2_GRP1_ForceReset(LL_APB2_GRP1_PERIPH_USART1); /* Release reset of USART clock */ LL_APB2_GRP1_ReleaseReset(LL_APB2_GRP1_PERIPH_USART1); } else if (USARTx == USART2) { /* Force reset of USART clock */ LL_APB1_GRP1_ForceReset(LL_APB1_GRP1_PERIPH_USART2); /* Release reset of USART clock */ LL_APB1_GRP1_ReleaseReset(LL_APB1_GRP1_PERIPH_USART2); } #if defined(USART3) else if (USARTx == USART3) { /* Force reset of USART clock */ LL_APB1_GRP1_ForceReset(LL_APB1_GRP1_PERIPH_USART3); /* Release reset of USART clock */ LL_APB1_GRP1_ReleaseReset(LL_APB1_GRP1_PERIPH_USART3); } #endif /* USART3 */ #if defined(USART6) else if (USARTx == USART6) { /* Force reset of USART clock */ LL_APB2_GRP1_ForceReset(LL_APB2_GRP1_PERIPH_USART6); /* Release reset of USART clock */ LL_APB2_GRP1_ReleaseReset(LL_APB2_GRP1_PERIPH_USART6); } #endif /* USART6 */ #if defined(UART4) else if (USARTx == UART4) { /* Force reset of UART clock */ LL_APB1_GRP1_ForceReset(LL_APB1_GRP1_PERIPH_UART4); /* Release reset of UART clock */ LL_APB1_GRP1_ReleaseReset(LL_APB1_GRP1_PERIPH_UART4); } #endif /* UART4 */ #if defined(UART5) else if (USARTx == UART5) { /* Force reset of UART clock */ LL_APB1_GRP1_ForceReset(LL_APB1_GRP1_PERIPH_UART5); /* Release reset of UART clock */ LL_APB1_GRP1_ReleaseReset(LL_APB1_GRP1_PERIPH_UART5); } #endif /* UART5 */ #if defined(UART7) else if (USARTx == UART7) { /* Force reset of UART clock */ LL_APB1_GRP1_ForceReset(LL_APB1_GRP1_PERIPH_UART7); /* Release reset of UART clock */ LL_APB1_GRP1_ReleaseReset(LL_APB1_GRP1_PERIPH_UART7); } #endif /* UART7 */ #if defined(UART8) else if (USARTx == UART8) { /* Force reset of UART clock */ LL_APB1_GRP1_ForceReset(LL_APB1_GRP1_PERIPH_UART8); /* Release reset of UART clock */ LL_APB1_GRP1_ReleaseReset(LL_APB1_GRP1_PERIPH_UART8); } #endif /* UART8 */ #if defined(UART9) else if (USARTx == UART9) { /* Force reset of UART clock */ LL_APB2_GRP1_ForceReset(LL_APB2_GRP1_PERIPH_UART9); /* Release reset of UART clock */ LL_APB2_GRP1_ReleaseReset(LL_APB2_GRP1_PERIPH_UART9); } #endif /* UART9 */ #if defined(UART10) else if (USARTx == UART10) { /* Force reset of UART clock */ LL_APB2_GRP1_ForceReset(LL_APB2_GRP1_PERIPH_UART10); /* Release reset of UART clock */ LL_APB2_GRP1_ReleaseReset(LL_APB2_GRP1_PERIPH_UART10); } #endif /* UART10 */ else { status = ERROR; } return (status); } /** * @brief Initialize USART registers according to the specified * parameters in USART_InitStruct. * @note As some bits in USART configuration registers can only be written when the USART is disabled (USART_CR1_UE bit =0), * USART IP should be in disabled state prior calling this function. Otherwise, ERROR result will be returned. * @note Baud rate value stored in USART_InitStruct BaudRate field, should be valid (different from 0). * @param USARTx USART Instance * @param USART_InitStruct: pointer to a LL_USART_InitTypeDef structure * that contains the configuration information for the specified USART peripheral. * @retval An ErrorStatus enumeration value: * - SUCCESS: USART registers are initialized according to USART_InitStruct content * - ERROR: Problem occurred during USART Registers initialization */ ErrorStatus LL_USART_Init(USART_TypeDef *USARTx, LL_USART_InitTypeDef *USART_InitStruct) { ErrorStatus status = ERROR; uint32_t periphclk = LL_RCC_PERIPH_FREQUENCY_NO; LL_RCC_ClocksTypeDef rcc_clocks; /* Check the parameters */ assert_param(IS_UART_INSTANCE(USARTx)); assert_param(IS_LL_USART_BAUDRATE(USART_InitStruct->BaudRate)); assert_param(IS_LL_USART_DATAWIDTH(USART_InitStruct->DataWidth)); assert_param(IS_LL_USART_STOPBITS(USART_InitStruct->StopBits)); assert_param(IS_LL_USART_PARITY(USART_InitStruct->Parity)); assert_param(IS_LL_USART_DIRECTION(USART_InitStruct->TransferDirection)); assert_param(IS_LL_USART_HWCONTROL(USART_InitStruct->HardwareFlowControl)); assert_param(IS_LL_USART_OVERSAMPLING(USART_InitStruct->OverSampling)); /* USART needs to be in disabled state, in order to be able to configure some bits in CRx registers */ if (LL_USART_IsEnabled(USARTx) == 0U) { /*---------------------------- USART CR1 Configuration ----------------------- * Configure USARTx CR1 (USART Word Length, Parity, Mode and Oversampling bits) with parameters: * - DataWidth: USART_CR1_M bits according to USART_InitStruct->DataWidth value * - Parity: USART_CR1_PCE, USART_CR1_PS bits according to USART_InitStruct->Parity value * - TransferDirection: USART_CR1_TE, USART_CR1_RE bits according to USART_InitStruct->TransferDirection value * - Oversampling: USART_CR1_OVER8 bit according to USART_InitStruct->OverSampling value. */ MODIFY_REG(USARTx->CR1, (USART_CR1_M | USART_CR1_PCE | USART_CR1_PS | USART_CR1_TE | USART_CR1_RE | USART_CR1_OVER8), (USART_InitStruct->DataWidth | USART_InitStruct->Parity | USART_InitStruct->TransferDirection | USART_InitStruct->OverSampling)); /*---------------------------- USART CR2 Configuration ----------------------- * Configure USARTx CR2 (Stop bits) with parameters: * - Stop Bits: USART_CR2_STOP bits according to USART_InitStruct->StopBits value. * - CLKEN, CPOL, CPHA and LBCL bits are to be configured using LL_USART_ClockInit(). */ LL_USART_SetStopBitsLength(USARTx, USART_InitStruct->StopBits); /*---------------------------- USART CR3 Configuration ----------------------- * Configure USARTx CR3 (Hardware Flow Control) with parameters: * - HardwareFlowControl: USART_CR3_RTSE, USART_CR3_CTSE bits according to USART_InitStruct->HardwareFlowControl value. */ LL_USART_SetHWFlowCtrl(USARTx, USART_InitStruct->HardwareFlowControl); /*---------------------------- USART BRR Configuration ----------------------- * Retrieve Clock frequency used for USART Peripheral */ LL_RCC_GetSystemClocksFreq(&rcc_clocks); if (USARTx == USART1) { periphclk = rcc_clocks.PCLK2_Frequency; } else if (USARTx == USART2) { periphclk = rcc_clocks.PCLK1_Frequency; } #if defined(USART3) else if (USARTx == USART3) { periphclk = rcc_clocks.PCLK1_Frequency; } #endif /* USART3 */ #if defined(USART6) else if (USARTx == USART6) { periphclk = rcc_clocks.PCLK2_Frequency; } #endif /* USART6 */ #if defined(UART4) else if (USARTx == UART4) { periphclk = rcc_clocks.PCLK1_Frequency; } #endif /* UART4 */ #if defined(UART5) else if (USARTx == UART5) { periphclk = rcc_clocks.PCLK1_Frequency; } #endif /* UART5 */ #if defined(UART7) else if (USARTx == UART7) { periphclk = rcc_clocks.PCLK1_Frequency; } #endif /* UART7 */ #if defined(UART8) else if (USARTx == UART8) { periphclk = rcc_clocks.PCLK1_Frequency; } #endif /* UART8 */ #if defined(UART9) else if (USARTx == UART9) { periphclk = rcc_clocks.PCLK1_Frequency; } #endif /* UART9 */ #if defined(UART10) else if (USARTx == UART5) { periphclk = rcc_clocks.PCLK1_Frequency; } #endif /* UART10 */ else { /* Nothing to do, as error code is already assigned to ERROR value */ } /* Configure the USART Baud Rate : - valid baud rate value (different from 0) is required - Peripheral clock as returned by RCC service, should be valid (different from 0). */ if ((periphclk != LL_RCC_PERIPH_FREQUENCY_NO) && (USART_InitStruct->BaudRate != 0U)) { status = SUCCESS; LL_USART_SetBaudRate(USARTx, periphclk, USART_InitStruct->OverSampling, USART_InitStruct->BaudRate); } } /* Endif (=> USART not in Disabled state => return ERROR) */ return (status); } /** * @brief Set each @ref LL_USART_InitTypeDef field to default value. * @param USART_InitStruct: pointer to a @ref LL_USART_InitTypeDef structure * whose fields will be set to default values. * @retval None */ void LL_USART_StructInit(LL_USART_InitTypeDef *USART_InitStruct) { /* Set USART_InitStruct fields to default values */ USART_InitStruct->BaudRate = 9600U; USART_InitStruct->DataWidth = LL_USART_DATAWIDTH_8B; USART_InitStruct->StopBits = LL_USART_STOPBITS_1; USART_InitStruct->Parity = LL_USART_PARITY_NONE ; USART_InitStruct->TransferDirection = LL_USART_DIRECTION_TX_RX; USART_InitStruct->HardwareFlowControl = LL_USART_HWCONTROL_NONE; USART_InitStruct->OverSampling = LL_USART_OVERSAMPLING_16; } /** * @brief Initialize USART Clock related settings according to the * specified parameters in the USART_ClockInitStruct. * @note As some bits in USART configuration registers can only be written when the USART is disabled (USART_CR1_UE bit =0), * USART IP should be in disabled state prior calling this function. Otherwise, ERROR result will be returned. * @param USARTx USART Instance * @param USART_ClockInitStruct: pointer to a @ref LL_USART_ClockInitTypeDef structure * that contains the Clock configuration information for the specified USART peripheral. * @retval An ErrorStatus enumeration value: * - SUCCESS: USART registers related to Clock settings are initialized according to USART_ClockInitStruct content * - ERROR: Problem occurred during USART Registers initialization */ ErrorStatus LL_USART_ClockInit(USART_TypeDef *USARTx, LL_USART_ClockInitTypeDef *USART_ClockInitStruct) { ErrorStatus status = SUCCESS; /* Check USART Instance and Clock signal output parameters */ assert_param(IS_UART_INSTANCE(USARTx)); assert_param(IS_LL_USART_CLOCKOUTPUT(USART_ClockInitStruct->ClockOutput)); /* USART needs to be in disabled state, in order to be able to configure some bits in CRx registers */ if (LL_USART_IsEnabled(USARTx) == 0U) { /*---------------------------- USART CR2 Configuration -----------------------*/ /* If Clock signal has to be output */ if (USART_ClockInitStruct->ClockOutput == LL_USART_CLOCK_DISABLE) { /* Deactivate Clock signal delivery : * - Disable Clock Output: USART_CR2_CLKEN cleared */ LL_USART_DisableSCLKOutput(USARTx); } else { /* Ensure USART instance is USART capable */ assert_param(IS_USART_INSTANCE(USARTx)); /* Check clock related parameters */ assert_param(IS_LL_USART_CLOCKPOLARITY(USART_ClockInitStruct->ClockPolarity)); assert_param(IS_LL_USART_CLOCKPHASE(USART_ClockInitStruct->ClockPhase)); assert_param(IS_LL_USART_LASTBITCLKOUTPUT(USART_ClockInitStruct->LastBitClockPulse)); /*---------------------------- USART CR2 Configuration ----------------------- * Configure USARTx CR2 (Clock signal related bits) with parameters: * - Enable Clock Output: USART_CR2_CLKEN set * - Clock Polarity: USART_CR2_CPOL bit according to USART_ClockInitStruct->ClockPolarity value * - Clock Phase: USART_CR2_CPHA bit according to USART_ClockInitStruct->ClockPhase value * - Last Bit Clock Pulse Output: USART_CR2_LBCL bit according to USART_ClockInitStruct->LastBitClockPulse value. */ MODIFY_REG(USARTx->CR2, USART_CR2_CLKEN | USART_CR2_CPHA | USART_CR2_CPOL | USART_CR2_LBCL, USART_CR2_CLKEN | USART_ClockInitStruct->ClockPolarity | USART_ClockInitStruct->ClockPhase | USART_ClockInitStruct->LastBitClockPulse); } } /* Else (USART not in Disabled state => return ERROR */ else { status = ERROR; } return (status); } /** * @brief Set each field of a @ref LL_USART_ClockInitTypeDef type structure to default value. * @param USART_ClockInitStruct: pointer to a @ref LL_USART_ClockInitTypeDef structure * whose fields will be set to default values. * @retval None */ void LL_USART_ClockStructInit(LL_USART_ClockInitTypeDef *USART_ClockInitStruct) { /* Set LL_USART_ClockInitStruct fields with default values */ USART_ClockInitStruct->ClockOutput = LL_USART_CLOCK_DISABLE; USART_ClockInitStruct->ClockPolarity = LL_USART_POLARITY_LOW; /* Not relevant when ClockOutput = LL_USART_CLOCK_DISABLE */ USART_ClockInitStruct->ClockPhase = LL_USART_PHASE_1EDGE; /* Not relevant when ClockOutput = LL_USART_CLOCK_DISABLE */ USART_ClockInitStruct->LastBitClockPulse = LL_USART_LASTCLKPULSE_NO_OUTPUT; /* Not relevant when ClockOutput = LL_USART_CLOCK_DISABLE */ } /** * @} */ /** * @} */ /** * @} */ #endif /* USART1 || USART2 || USART3 || USART6 || UART4 || UART5 || UART7 || UART8 || UART9 || UART10 */ /** * @} */ #endif /* USE_FULL_LL_DRIVER */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ ================================================ FILE: sys/arch/stm32/hal/stm32f4xx_ll_usart.h ================================================ /** ****************************************************************************** * @file stm32f4xx_ll_usart.h * @author MCD Application Team * @version V1.7.1 * @date 14-April-2017 * @brief Header file of USART LL module. ****************************************************************************** * @attention * *

© COPYRIGHT(c) 2017 STMicroelectronics

* * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. Neither the name of STMicroelectronics nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __STM32F4xx_LL_USART_H #define __STM32F4xx_LL_USART_H #ifdef __cplusplus extern "C" { #endif /* Includes ------------------------------------------------------------------*/ #include "stm32f4xx.h" /** @addtogroup STM32F4xx_LL_Driver * @{ */ #if defined (USART1) || defined (USART2) || defined (USART3) || defined (USART6) || defined (UART4) || defined (UART5) || defined (UART7) || defined (UART8) || defined (UART9) || defined (UART10) /** @defgroup USART_LL USART * @{ */ /* Private types -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ /* Private constants ---------------------------------------------------------*/ /** @defgroup USART_LL_Private_Constants USART Private Constants * @{ */ /* Defines used for the bit position in the register and perform offsets*/ #define USART_POSITION_GTPR_GT USART_GTPR_GT_Pos /** * @} */ /* Private macros ------------------------------------------------------------*/ #if defined(USE_FULL_LL_DRIVER) /** @defgroup USART_LL_Private_Macros USART Private Macros * @{ */ /** * @} */ #endif /*USE_FULL_LL_DRIVER*/ /* Exported types ------------------------------------------------------------*/ #if defined(USE_FULL_LL_DRIVER) /** @defgroup USART_LL_ES_INIT USART Exported Init structures * @{ */ /** * @brief LL USART Init Structure definition */ typedef struct { uint32_t BaudRate; /*!< This field defines expected Usart communication baud rate. This feature can be modified afterwards using unitary function @ref LL_USART_SetBaudRate().*/ uint32_t DataWidth; /*!< Specifies the number of data bits transmitted or received in a frame. This parameter can be a value of @ref USART_LL_EC_DATAWIDTH. This feature can be modified afterwards using unitary function @ref LL_USART_SetDataWidth().*/ uint32_t StopBits; /*!< Specifies the number of stop bits transmitted. This parameter can be a value of @ref USART_LL_EC_STOPBITS. This feature can be modified afterwards using unitary function @ref LL_USART_SetStopBitsLength().*/ uint32_t Parity; /*!< Specifies the parity mode. This parameter can be a value of @ref USART_LL_EC_PARITY. This feature can be modified afterwards using unitary function @ref LL_USART_SetParity().*/ uint32_t TransferDirection; /*!< Specifies whether the Receive and/or Transmit mode is enabled or disabled. This parameter can be a value of @ref USART_LL_EC_DIRECTION. This feature can be modified afterwards using unitary function @ref LL_USART_SetTransferDirection().*/ uint32_t HardwareFlowControl; /*!< Specifies whether the hardware flow control mode is enabled or disabled. This parameter can be a value of @ref USART_LL_EC_HWCONTROL. This feature can be modified afterwards using unitary function @ref LL_USART_SetHWFlowCtrl().*/ uint32_t OverSampling; /*!< Specifies whether USART oversampling mode is 16 or 8. This parameter can be a value of @ref USART_LL_EC_OVERSAMPLING. This feature can be modified afterwards using unitary function @ref LL_USART_SetOverSampling().*/ } LL_USART_InitTypeDef; /** * @brief LL USART Clock Init Structure definition */ typedef struct { uint32_t ClockOutput; /*!< Specifies whether the USART clock is enabled or disabled. This parameter can be a value of @ref USART_LL_EC_CLOCK. USART HW configuration can be modified afterwards using unitary functions @ref LL_USART_EnableSCLKOutput() or @ref LL_USART_DisableSCLKOutput(). For more details, refer to description of this function. */ uint32_t ClockPolarity; /*!< Specifies the steady state of the serial clock. This parameter can be a value of @ref USART_LL_EC_POLARITY. USART HW configuration can be modified afterwards using unitary functions @ref LL_USART_SetClockPolarity(). For more details, refer to description of this function. */ uint32_t ClockPhase; /*!< Specifies the clock transition on which the bit capture is made. This parameter can be a value of @ref USART_LL_EC_PHASE. USART HW configuration can be modified afterwards using unitary functions @ref LL_USART_SetClockPhase(). For more details, refer to description of this function. */ uint32_t LastBitClockPulse; /*!< Specifies whether the clock pulse corresponding to the last transmitted data bit (MSB) has to be output on the SCLK pin in synchronous mode. This parameter can be a value of @ref USART_LL_EC_LASTCLKPULSE. USART HW configuration can be modified afterwards using unitary functions @ref LL_USART_SetLastClkPulseOutput(). For more details, refer to description of this function. */ } LL_USART_ClockInitTypeDef; /** * @} */ #endif /* USE_FULL_LL_DRIVER */ /* Exported constants --------------------------------------------------------*/ /** @defgroup USART_LL_Exported_Constants USART Exported Constants * @{ */ /** @defgroup USART_LL_EC_GET_FLAG Get Flags Defines * @brief Flags defines which can be used with LL_USART_ReadReg function * @{ */ #define LL_USART_SR_PE USART_SR_PE /*!< Parity error flag */ #define LL_USART_SR_FE USART_SR_FE /*!< Framing error flag */ #define LL_USART_SR_NE USART_SR_NE /*!< Noise detected flag */ #define LL_USART_SR_ORE USART_SR_ORE /*!< Overrun error flag */ #define LL_USART_SR_IDLE USART_SR_IDLE /*!< Idle line detected flag */ #define LL_USART_SR_RXNE USART_SR_RXNE /*!< Read data register not empty flag */ #define LL_USART_SR_TC USART_SR_TC /*!< Transmission complete flag */ #define LL_USART_SR_TXE USART_SR_TXE /*!< Transmit data register empty flag */ #define LL_USART_SR_LBD USART_SR_LBD /*!< LIN break detection flag */ #define LL_USART_SR_CTS USART_SR_CTS /*!< CTS flag */ /** * @} */ /** @defgroup USART_LL_EC_IT IT Defines * @brief IT defines which can be used with LL_USART_ReadReg and LL_USART_WriteReg functions * @{ */ #define LL_USART_CR1_IDLEIE USART_CR1_IDLEIE /*!< IDLE interrupt enable */ #define LL_USART_CR1_RXNEIE USART_CR1_RXNEIE /*!< Read data register not empty interrupt enable */ #define LL_USART_CR1_TCIE USART_CR1_TCIE /*!< Transmission complete interrupt enable */ #define LL_USART_CR1_TXEIE USART_CR1_TXEIE /*!< Transmit data register empty interrupt enable */ #define LL_USART_CR1_PEIE USART_CR1_PEIE /*!< Parity error */ #define LL_USART_CR2_LBDIE USART_CR2_LBDIE /*!< LIN break detection interrupt enable */ #define LL_USART_CR3_EIE USART_CR3_EIE /*!< Error interrupt enable */ #define LL_USART_CR3_CTSIE USART_CR3_CTSIE /*!< CTS interrupt enable */ /** * @} */ /** @defgroup USART_LL_EC_DIRECTION Communication Direction * @{ */ #define LL_USART_DIRECTION_NONE 0x00000000U /*!< Transmitter and Receiver are disabled */ #define LL_USART_DIRECTION_RX USART_CR1_RE /*!< Transmitter is disabled and Receiver is enabled */ #define LL_USART_DIRECTION_TX USART_CR1_TE /*!< Transmitter is enabled and Receiver is disabled */ #define LL_USART_DIRECTION_TX_RX (USART_CR1_TE |USART_CR1_RE) /*!< Transmitter and Receiver are enabled */ /** * @} */ /** @defgroup USART_LL_EC_PARITY Parity Control * @{ */ #define LL_USART_PARITY_NONE 0x00000000U /*!< Parity control disabled */ #define LL_USART_PARITY_EVEN USART_CR1_PCE /*!< Parity control enabled and Even Parity is selected */ #define LL_USART_PARITY_ODD (USART_CR1_PCE | USART_CR1_PS) /*!< Parity control enabled and Odd Parity is selected */ /** * @} */ /** @defgroup USART_LL_EC_WAKEUP Wakeup * @{ */ #define LL_USART_WAKEUP_IDLELINE 0x00000000U /*!< USART wake up from Mute mode on Idle Line */ #define LL_USART_WAKEUP_ADDRESSMARK USART_CR1_WAKE /*!< USART wake up from Mute mode on Address Mark */ /** * @} */ /** @defgroup USART_LL_EC_DATAWIDTH Datawidth * @{ */ #define LL_USART_DATAWIDTH_8B 0x00000000U /*!< 8 bits word length : Start bit, 8 data bits, n stop bits */ #define LL_USART_DATAWIDTH_9B USART_CR1_M /*!< 9 bits word length : Start bit, 9 data bits, n stop bits */ /** * @} */ /** @defgroup USART_LL_EC_OVERSAMPLING Oversampling * @{ */ #define LL_USART_OVERSAMPLING_16 0x00000000U /*!< Oversampling by 16 */ #define LL_USART_OVERSAMPLING_8 USART_CR1_OVER8 /*!< Oversampling by 8 */ /** * @} */ #if defined(USE_FULL_LL_DRIVER) /** @defgroup USART_LL_EC_CLOCK Clock Signal * @{ */ #define LL_USART_CLOCK_DISABLE 0x00000000U /*!< Clock signal not provided */ #define LL_USART_CLOCK_ENABLE USART_CR2_CLKEN /*!< Clock signal provided */ /** * @} */ #endif /*USE_FULL_LL_DRIVER*/ /** @defgroup USART_LL_EC_LASTCLKPULSE Last Clock Pulse * @{ */ #define LL_USART_LASTCLKPULSE_NO_OUTPUT 0x00000000U /*!< The clock pulse of the last data bit is not output to the SCLK pin */ #define LL_USART_LASTCLKPULSE_OUTPUT USART_CR2_LBCL /*!< The clock pulse of the last data bit is output to the SCLK pin */ /** * @} */ /** @defgroup USART_LL_EC_PHASE Clock Phase * @{ */ #define LL_USART_PHASE_1EDGE 0x00000000U /*!< The first clock transition is the first data capture edge */ #define LL_USART_PHASE_2EDGE USART_CR2_CPHA /*!< The second clock transition is the first data capture edge */ /** * @} */ /** @defgroup USART_LL_EC_POLARITY Clock Polarity * @{ */ #define LL_USART_POLARITY_LOW 0x00000000U /*!< Steady low value on SCLK pin outside transmission window*/ #define LL_USART_POLARITY_HIGH USART_CR2_CPOL /*!< Steady high value on SCLK pin outside transmission window */ /** * @} */ /** @defgroup USART_LL_EC_STOPBITS Stop Bits * @{ */ #define LL_USART_STOPBITS_0_5 USART_CR2_STOP_0 /*!< 0.5 stop bit */ #define LL_USART_STOPBITS_1 0x00000000U /*!< 1 stop bit */ #define LL_USART_STOPBITS_1_5 (USART_CR2_STOP_0 | USART_CR2_STOP_1) /*!< 1.5 stop bits */ #define LL_USART_STOPBITS_2 USART_CR2_STOP_1 /*!< 2 stop bits */ /** * @} */ /** @defgroup USART_LL_EC_HWCONTROL Hardware Control * @{ */ #define LL_USART_HWCONTROL_NONE 0x00000000U /*!< CTS and RTS hardware flow control disabled */ #define LL_USART_HWCONTROL_RTS USART_CR3_RTSE /*!< RTS output enabled, data is only requested when there is space in the receive buffer */ #define LL_USART_HWCONTROL_CTS USART_CR3_CTSE /*!< CTS mode enabled, data is only transmitted when the nCTS input is asserted (tied to 0) */ #define LL_USART_HWCONTROL_RTS_CTS (USART_CR3_RTSE | USART_CR3_CTSE) /*!< CTS and RTS hardware flow control enabled */ /** * @} */ /** @defgroup USART_LL_EC_IRDA_POWER IrDA Power * @{ */ #define LL_USART_IRDA_POWER_NORMAL 0x00000000U /*!< IrDA normal power mode */ #define LL_USART_IRDA_POWER_LOW USART_CR3_IRLP /*!< IrDA low power mode */ /** * @} */ /** @defgroup USART_LL_EC_LINBREAK_DETECT LIN Break Detection Length * @{ */ #define LL_USART_LINBREAK_DETECT_10B 0x00000000U /*!< 10-bit break detection method selected */ #define LL_USART_LINBREAK_DETECT_11B USART_CR2_LBDL /*!< 11-bit break detection method selected */ /** * @} */ /** * @} */ /* Exported macro ------------------------------------------------------------*/ /** @defgroup USART_LL_Exported_Macros USART Exported Macros * @{ */ /** @defgroup USART_LL_EM_WRITE_READ Common Write and read registers Macros * @{ */ /** * @brief Write a value in USART register * @param __INSTANCE__ USART Instance * @param __REG__ Register to be written * @param __VALUE__ Value to be written in the register * @retval None */ #define LL_USART_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__)) /** * @brief Read a value in USART register * @param __INSTANCE__ USART Instance * @param __REG__ Register to be read * @retval Register value */ #define LL_USART_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__) /** * @} */ /** @defgroup USART_LL_EM_Exported_Macros_Helper Exported_Macros_Helper * @{ */ /** * @brief Compute USARTDIV value according to Peripheral Clock and * expected Baud Rate in 8 bits sampling mode (32 bits value of USARTDIV is returned) * @param __PERIPHCLK__ Peripheral Clock frequency used for USART instance * @param __BAUDRATE__ Baud rate value to achieve * @retval USARTDIV value to be used for BRR register filling in OverSampling_8 case */ #define __LL_USART_DIV_SAMPLING8_100(__PERIPHCLK__, __BAUDRATE__) (((__PERIPHCLK__)*25)/(2*(__BAUDRATE__))) #define __LL_USART_DIVMANT_SAMPLING8(__PERIPHCLK__, __BAUDRATE__) (__LL_USART_DIV_SAMPLING8_100((__PERIPHCLK__), (__BAUDRATE__))/100) #define __LL_USART_DIVFRAQ_SAMPLING8(__PERIPHCLK__, __BAUDRATE__) (((__LL_USART_DIV_SAMPLING8_100((__PERIPHCLK__), (__BAUDRATE__)) - (__LL_USART_DIVMANT_SAMPLING8((__PERIPHCLK__), (__BAUDRATE__)) * 100)) * 8 + 50) / 100) /* UART BRR = mantissa + overflow + fraction = (UART DIVMANT << 4) + ((UART DIVFRAQ & 0xF8) << 1) + (UART DIVFRAQ & 0x07) */ #define __LL_USART_DIV_SAMPLING8(__PERIPHCLK__, __BAUDRATE__) (((__LL_USART_DIVMANT_SAMPLING8((__PERIPHCLK__), (__BAUDRATE__)) << 4) + \ ((__LL_USART_DIVFRAQ_SAMPLING8((__PERIPHCLK__), (__BAUDRATE__)) & 0xF8) << 1)) + \ (__LL_USART_DIVFRAQ_SAMPLING8((__PERIPHCLK__), (__BAUDRATE__)) & 0x07)) /** * @brief Compute USARTDIV value according to Peripheral Clock and * expected Baud Rate in 16 bits sampling mode (32 bits value of USARTDIV is returned) * @param __PERIPHCLK__ Peripheral Clock frequency used for USART instance * @param __BAUDRATE__ Baud rate value to achieve * @retval USARTDIV value to be used for BRR register filling in OverSampling_16 case */ #define __LL_USART_DIV_SAMPLING16_100(__PERIPHCLK__, __BAUDRATE__) (((__PERIPHCLK__)*25)/(4*(__BAUDRATE__))) #define __LL_USART_DIVMANT_SAMPLING16(__PERIPHCLK__, __BAUDRATE__) (__LL_USART_DIV_SAMPLING16_100((__PERIPHCLK__), (__BAUDRATE__))/100) #define __LL_USART_DIVFRAQ_SAMPLING16(__PERIPHCLK__, __BAUDRATE__) (((__LL_USART_DIV_SAMPLING16_100((__PERIPHCLK__), (__BAUDRATE__)) - (__LL_USART_DIVMANT_SAMPLING16((__PERIPHCLK__), (__BAUDRATE__)) * 100)) * 16 + 50) / 100) /* USART BRR = mantissa + overflow + fraction = (USART DIVMANT << 4) + (USART DIVFRAQ & 0xF0) + (USART DIVFRAQ & 0x0F) */ #define __LL_USART_DIV_SAMPLING16(__PERIPHCLK__, __BAUDRATE__) (((__LL_USART_DIVMANT_SAMPLING16((__PERIPHCLK__), (__BAUDRATE__)) << 4) + \ (__LL_USART_DIVFRAQ_SAMPLING16((__PERIPHCLK__), (__BAUDRATE__)) & 0xF0)) + \ (__LL_USART_DIVFRAQ_SAMPLING16((__PERIPHCLK__), (__BAUDRATE__)) & 0x0F)) /** * @} */ /** * @} */ /* Exported functions --------------------------------------------------------*/ /** @defgroup USART_LL_Exported_Functions USART Exported Functions * @{ */ /** @defgroup USART_LL_EF_Configuration Configuration functions * @{ */ /** * @brief USART Enable * @rmtoll CR1 UE LL_USART_Enable * @param USARTx USART Instance * @retval None */ __STATIC_INLINE void LL_USART_Enable(USART_TypeDef *USARTx) { SET_BIT(USARTx->CR1, USART_CR1_UE); } /** * @brief USART Disable (all USART prescalers and outputs are disabled) * @note When USART is disabled, USART prescalers and outputs are stopped immediately, * and current operations are discarded. The configuration of the USART is kept, but all the status * flags, in the USARTx_SR are set to their default values. * @rmtoll CR1 UE LL_USART_Disable * @param USARTx USART Instance * @retval None */ __STATIC_INLINE void LL_USART_Disable(USART_TypeDef *USARTx) { CLEAR_BIT(USARTx->CR1, USART_CR1_UE); } /** * @brief Indicate if USART is enabled * @rmtoll CR1 UE LL_USART_IsEnabled * @param USARTx USART Instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_USART_IsEnabled(USART_TypeDef *USARTx) { return (READ_BIT(USARTx->CR1, USART_CR1_UE) == (USART_CR1_UE)); } /** * @brief Receiver Enable (Receiver is enabled and begins searching for a start bit) * @rmtoll CR1 RE LL_USART_EnableDirectionRx * @param USARTx USART Instance * @retval None */ __STATIC_INLINE void LL_USART_EnableDirectionRx(USART_TypeDef *USARTx) { SET_BIT(USARTx->CR1, USART_CR1_RE); } /** * @brief Receiver Disable * @rmtoll CR1 RE LL_USART_DisableDirectionRx * @param USARTx USART Instance * @retval None */ __STATIC_INLINE void LL_USART_DisableDirectionRx(USART_TypeDef *USARTx) { CLEAR_BIT(USARTx->CR1, USART_CR1_RE); } /** * @brief Transmitter Enable * @rmtoll CR1 TE LL_USART_EnableDirectionTx * @param USARTx USART Instance * @retval None */ __STATIC_INLINE void LL_USART_EnableDirectionTx(USART_TypeDef *USARTx) { SET_BIT(USARTx->CR1, USART_CR1_TE); } /** * @brief Transmitter Disable * @rmtoll CR1 TE LL_USART_DisableDirectionTx * @param USARTx USART Instance * @retval None */ __STATIC_INLINE void LL_USART_DisableDirectionTx(USART_TypeDef *USARTx) { CLEAR_BIT(USARTx->CR1, USART_CR1_TE); } /** * @brief Configure simultaneously enabled/disabled states * of Transmitter and Receiver * @rmtoll CR1 RE LL_USART_SetTransferDirection\n * CR1 TE LL_USART_SetTransferDirection * @param USARTx USART Instance * @param TransferDirection This parameter can be one of the following values: * @arg @ref LL_USART_DIRECTION_NONE * @arg @ref LL_USART_DIRECTION_RX * @arg @ref LL_USART_DIRECTION_TX * @arg @ref LL_USART_DIRECTION_TX_RX * @retval None */ __STATIC_INLINE void LL_USART_SetTransferDirection(USART_TypeDef *USARTx, uint32_t TransferDirection) { MODIFY_REG(USARTx->CR1, USART_CR1_RE | USART_CR1_TE, TransferDirection); } /** * @brief Return enabled/disabled states of Transmitter and Receiver * @rmtoll CR1 RE LL_USART_GetTransferDirection\n * CR1 TE LL_USART_GetTransferDirection * @param USARTx USART Instance * @retval Returned value can be one of the following values: * @arg @ref LL_USART_DIRECTION_NONE * @arg @ref LL_USART_DIRECTION_RX * @arg @ref LL_USART_DIRECTION_TX * @arg @ref LL_USART_DIRECTION_TX_RX */ __STATIC_INLINE uint32_t LL_USART_GetTransferDirection(USART_TypeDef *USARTx) { return (uint32_t)(READ_BIT(USARTx->CR1, USART_CR1_RE | USART_CR1_TE)); } /** * @brief Configure Parity (enabled/disabled and parity mode if enabled). * @note This function selects if hardware parity control (generation and detection) is enabled or disabled. * When the parity control is enabled (Odd or Even), computed parity bit is inserted at the MSB position * (9th or 8th bit depending on data width) and parity is checked on the received data. * @rmtoll CR1 PS LL_USART_SetParity\n * CR1 PCE LL_USART_SetParity * @param USARTx USART Instance * @param Parity This parameter can be one of the following values: * @arg @ref LL_USART_PARITY_NONE * @arg @ref LL_USART_PARITY_EVEN * @arg @ref LL_USART_PARITY_ODD * @retval None */ __STATIC_INLINE void LL_USART_SetParity(USART_TypeDef *USARTx, uint32_t Parity) { MODIFY_REG(USARTx->CR1, USART_CR1_PS | USART_CR1_PCE, Parity); } /** * @brief Return Parity configuration (enabled/disabled and parity mode if enabled) * @rmtoll CR1 PS LL_USART_GetParity\n * CR1 PCE LL_USART_GetParity * @param USARTx USART Instance * @retval Returned value can be one of the following values: * @arg @ref LL_USART_PARITY_NONE * @arg @ref LL_USART_PARITY_EVEN * @arg @ref LL_USART_PARITY_ODD */ __STATIC_INLINE uint32_t LL_USART_GetParity(USART_TypeDef *USARTx) { return (uint32_t)(READ_BIT(USARTx->CR1, USART_CR1_PS | USART_CR1_PCE)); } /** * @brief Set Receiver Wake Up method from Mute mode. * @rmtoll CR1 WAKE LL_USART_SetWakeUpMethod * @param USARTx USART Instance * @param Method This parameter can be one of the following values: * @arg @ref LL_USART_WAKEUP_IDLELINE * @arg @ref LL_USART_WAKEUP_ADDRESSMARK * @retval None */ __STATIC_INLINE void LL_USART_SetWakeUpMethod(USART_TypeDef *USARTx, uint32_t Method) { MODIFY_REG(USARTx->CR1, USART_CR1_WAKE, Method); } /** * @brief Return Receiver Wake Up method from Mute mode * @rmtoll CR1 WAKE LL_USART_GetWakeUpMethod * @param USARTx USART Instance * @retval Returned value can be one of the following values: * @arg @ref LL_USART_WAKEUP_IDLELINE * @arg @ref LL_USART_WAKEUP_ADDRESSMARK */ __STATIC_INLINE uint32_t LL_USART_GetWakeUpMethod(USART_TypeDef *USARTx) { return (uint32_t)(READ_BIT(USARTx->CR1, USART_CR1_WAKE)); } /** * @brief Set Word length (i.e. nb of data bits, excluding start and stop bits) * @rmtoll CR1 M LL_USART_SetDataWidth * @param USARTx USART Instance * @param DataWidth This parameter can be one of the following values: * @arg @ref LL_USART_DATAWIDTH_8B * @arg @ref LL_USART_DATAWIDTH_9B * @retval None */ __STATIC_INLINE void LL_USART_SetDataWidth(USART_TypeDef *USARTx, uint32_t DataWidth) { MODIFY_REG(USARTx->CR1, USART_CR1_M, DataWidth); } /** * @brief Return Word length (i.e. nb of data bits, excluding start and stop bits) * @rmtoll CR1 M LL_USART_GetDataWidth * @param USARTx USART Instance * @retval Returned value can be one of the following values: * @arg @ref LL_USART_DATAWIDTH_8B * @arg @ref LL_USART_DATAWIDTH_9B */ __STATIC_INLINE uint32_t LL_USART_GetDataWidth(USART_TypeDef *USARTx) { return (uint32_t)(READ_BIT(USARTx->CR1, USART_CR1_M)); } /** * @brief Set Oversampling to 8-bit or 16-bit mode * @rmtoll CR1 OVER8 LL_USART_SetOverSampling * @param USARTx USART Instance * @param OverSampling This parameter can be one of the following values: * @arg @ref LL_USART_OVERSAMPLING_16 * @arg @ref LL_USART_OVERSAMPLING_8 * @retval None */ __STATIC_INLINE void LL_USART_SetOverSampling(USART_TypeDef *USARTx, uint32_t OverSampling) { MODIFY_REG(USARTx->CR1, USART_CR1_OVER8, OverSampling); } /** * @brief Return Oversampling mode * @rmtoll CR1 OVER8 LL_USART_GetOverSampling * @param USARTx USART Instance * @retval Returned value can be one of the following values: * @arg @ref LL_USART_OVERSAMPLING_16 * @arg @ref LL_USART_OVERSAMPLING_8 */ __STATIC_INLINE uint32_t LL_USART_GetOverSampling(USART_TypeDef *USARTx) { return (uint32_t)(READ_BIT(USARTx->CR1, USART_CR1_OVER8)); } /** * @brief Configure if Clock pulse of the last data bit is output to the SCLK pin or not * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not * Synchronous mode is supported by the USARTx instance. * @rmtoll CR2 LBCL LL_USART_SetLastClkPulseOutput * @param USARTx USART Instance * @param LastBitClockPulse This parameter can be one of the following values: * @arg @ref LL_USART_LASTCLKPULSE_NO_OUTPUT * @arg @ref LL_USART_LASTCLKPULSE_OUTPUT * @retval None */ __STATIC_INLINE void LL_USART_SetLastClkPulseOutput(USART_TypeDef *USARTx, uint32_t LastBitClockPulse) { MODIFY_REG(USARTx->CR2, USART_CR2_LBCL, LastBitClockPulse); } /** * @brief Retrieve Clock pulse of the last data bit output configuration * (Last bit Clock pulse output to the SCLK pin or not) * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not * Synchronous mode is supported by the USARTx instance. * @rmtoll CR2 LBCL LL_USART_GetLastClkPulseOutput * @param USARTx USART Instance * @retval Returned value can be one of the following values: * @arg @ref LL_USART_LASTCLKPULSE_NO_OUTPUT * @arg @ref LL_USART_LASTCLKPULSE_OUTPUT */ __STATIC_INLINE uint32_t LL_USART_GetLastClkPulseOutput(USART_TypeDef *USARTx) { return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_LBCL)); } /** * @brief Select the phase of the clock output on the SCLK pin in synchronous mode * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not * Synchronous mode is supported by the USARTx instance. * @rmtoll CR2 CPHA LL_USART_SetClockPhase * @param USARTx USART Instance * @param ClockPhase This parameter can be one of the following values: * @arg @ref LL_USART_PHASE_1EDGE * @arg @ref LL_USART_PHASE_2EDGE * @retval None */ __STATIC_INLINE void LL_USART_SetClockPhase(USART_TypeDef *USARTx, uint32_t ClockPhase) { MODIFY_REG(USARTx->CR2, USART_CR2_CPHA, ClockPhase); } /** * @brief Return phase of the clock output on the SCLK pin in synchronous mode * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not * Synchronous mode is supported by the USARTx instance. * @rmtoll CR2 CPHA LL_USART_GetClockPhase * @param USARTx USART Instance * @retval Returned value can be one of the following values: * @arg @ref LL_USART_PHASE_1EDGE * @arg @ref LL_USART_PHASE_2EDGE */ __STATIC_INLINE uint32_t LL_USART_GetClockPhase(USART_TypeDef *USARTx) { return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_CPHA)); } /** * @brief Select the polarity of the clock output on the SCLK pin in synchronous mode * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not * Synchronous mode is supported by the USARTx instance. * @rmtoll CR2 CPOL LL_USART_SetClockPolarity * @param USARTx USART Instance * @param ClockPolarity This parameter can be one of the following values: * @arg @ref LL_USART_POLARITY_LOW * @arg @ref LL_USART_POLARITY_HIGH * @retval None */ __STATIC_INLINE void LL_USART_SetClockPolarity(USART_TypeDef *USARTx, uint32_t ClockPolarity) { MODIFY_REG(USARTx->CR2, USART_CR2_CPOL, ClockPolarity); } /** * @brief Return polarity of the clock output on the SCLK pin in synchronous mode * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not * Synchronous mode is supported by the USARTx instance. * @rmtoll CR2 CPOL LL_USART_GetClockPolarity * @param USARTx USART Instance * @retval Returned value can be one of the following values: * @arg @ref LL_USART_POLARITY_LOW * @arg @ref LL_USART_POLARITY_HIGH */ __STATIC_INLINE uint32_t LL_USART_GetClockPolarity(USART_TypeDef *USARTx) { return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_CPOL)); } /** * @brief Configure Clock signal format (Phase Polarity and choice about output of last bit clock pulse) * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not * Synchronous mode is supported by the USARTx instance. * @note Call of this function is equivalent to following function call sequence : * - Clock Phase configuration using @ref LL_USART_SetClockPhase() function * - Clock Polarity configuration using @ref LL_USART_SetClockPolarity() function * - Output of Last bit Clock pulse configuration using @ref LL_USART_SetLastClkPulseOutput() function * @rmtoll CR2 CPHA LL_USART_ConfigClock\n * CR2 CPOL LL_USART_ConfigClock\n * CR2 LBCL LL_USART_ConfigClock * @param USARTx USART Instance * @param Phase This parameter can be one of the following values: * @arg @ref LL_USART_PHASE_1EDGE * @arg @ref LL_USART_PHASE_2EDGE * @param Polarity This parameter can be one of the following values: * @arg @ref LL_USART_POLARITY_LOW * @arg @ref LL_USART_POLARITY_HIGH * @param LBCPOutput This parameter can be one of the following values: * @arg @ref LL_USART_LASTCLKPULSE_NO_OUTPUT * @arg @ref LL_USART_LASTCLKPULSE_OUTPUT * @retval None */ __STATIC_INLINE void LL_USART_ConfigClock(USART_TypeDef *USARTx, uint32_t Phase, uint32_t Polarity, uint32_t LBCPOutput) { MODIFY_REG(USARTx->CR2, USART_CR2_CPHA | USART_CR2_CPOL | USART_CR2_LBCL, Phase | Polarity | LBCPOutput); } /** * @brief Enable Clock output on SCLK pin * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not * Synchronous mode is supported by the USARTx instance. * @rmtoll CR2 CLKEN LL_USART_EnableSCLKOutput * @param USARTx USART Instance * @retval None */ __STATIC_INLINE void LL_USART_EnableSCLKOutput(USART_TypeDef *USARTx) { SET_BIT(USARTx->CR2, USART_CR2_CLKEN); } /** * @brief Disable Clock output on SCLK pin * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not * Synchronous mode is supported by the USARTx instance. * @rmtoll CR2 CLKEN LL_USART_DisableSCLKOutput * @param USARTx USART Instance * @retval None */ __STATIC_INLINE void LL_USART_DisableSCLKOutput(USART_TypeDef *USARTx) { CLEAR_BIT(USARTx->CR2, USART_CR2_CLKEN); } /** * @brief Indicate if Clock output on SCLK pin is enabled * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not * Synchronous mode is supported by the USARTx instance. * @rmtoll CR2 CLKEN LL_USART_IsEnabledSCLKOutput * @param USARTx USART Instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_USART_IsEnabledSCLKOutput(USART_TypeDef *USARTx) { return (READ_BIT(USARTx->CR2, USART_CR2_CLKEN) == (USART_CR2_CLKEN)); } /** * @brief Set the length of the stop bits * @rmtoll CR2 STOP LL_USART_SetStopBitsLength * @param USARTx USART Instance * @param StopBits This parameter can be one of the following values: * @arg @ref LL_USART_STOPBITS_0_5 * @arg @ref LL_USART_STOPBITS_1 * @arg @ref LL_USART_STOPBITS_1_5 * @arg @ref LL_USART_STOPBITS_2 * @retval None */ __STATIC_INLINE void LL_USART_SetStopBitsLength(USART_TypeDef *USARTx, uint32_t StopBits) { MODIFY_REG(USARTx->CR2, USART_CR2_STOP, StopBits); } /** * @brief Retrieve the length of the stop bits * @rmtoll CR2 STOP LL_USART_GetStopBitsLength * @param USARTx USART Instance * @retval Returned value can be one of the following values: * @arg @ref LL_USART_STOPBITS_0_5 * @arg @ref LL_USART_STOPBITS_1 * @arg @ref LL_USART_STOPBITS_1_5 * @arg @ref LL_USART_STOPBITS_2 */ __STATIC_INLINE uint32_t LL_USART_GetStopBitsLength(USART_TypeDef *USARTx) { return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_STOP)); } /** * @brief Configure Character frame format (Datawidth, Parity control, Stop Bits) * @note Call of this function is equivalent to following function call sequence : * - Data Width configuration using @ref LL_USART_SetDataWidth() function * - Parity Control and mode configuration using @ref LL_USART_SetParity() function * - Stop bits configuration using @ref LL_USART_SetStopBitsLength() function * @rmtoll CR1 PS LL_USART_ConfigCharacter\n * CR1 PCE LL_USART_ConfigCharacter\n * CR1 M LL_USART_ConfigCharacter\n * CR2 STOP LL_USART_ConfigCharacter * @param USARTx USART Instance * @param DataWidth This parameter can be one of the following values: * @arg @ref LL_USART_DATAWIDTH_8B * @arg @ref LL_USART_DATAWIDTH_9B * @param Parity This parameter can be one of the following values: * @arg @ref LL_USART_PARITY_NONE * @arg @ref LL_USART_PARITY_EVEN * @arg @ref LL_USART_PARITY_ODD * @param StopBits This parameter can be one of the following values: * @arg @ref LL_USART_STOPBITS_0_5 * @arg @ref LL_USART_STOPBITS_1 * @arg @ref LL_USART_STOPBITS_1_5 * @arg @ref LL_USART_STOPBITS_2 * @retval None */ __STATIC_INLINE void LL_USART_ConfigCharacter(USART_TypeDef *USARTx, uint32_t DataWidth, uint32_t Parity, uint32_t StopBits) { MODIFY_REG(USARTx->CR1, USART_CR1_PS | USART_CR1_PCE | USART_CR1_M, Parity | DataWidth); MODIFY_REG(USARTx->CR2, USART_CR2_STOP, StopBits); } /** * @brief Set Address of the USART node. * @note This is used in multiprocessor communication during Mute mode or Stop mode, * for wake up with address mark detection. * @rmtoll CR2 ADD LL_USART_SetNodeAddress * @param USARTx USART Instance * @param NodeAddress 4 bit Address of the USART node. * @retval None */ __STATIC_INLINE void LL_USART_SetNodeAddress(USART_TypeDef *USARTx, uint32_t NodeAddress) { MODIFY_REG(USARTx->CR2, USART_CR2_ADD, (NodeAddress & USART_CR2_ADD)); } /** * @brief Return 4 bit Address of the USART node as set in ADD field of CR2. * @note only 4bits (b3-b0) of returned value are relevant (b31-b4 are not relevant) * @rmtoll CR2 ADD LL_USART_GetNodeAddress * @param USARTx USART Instance * @retval Address of the USART node (Value between Min_Data=0 and Max_Data=255) */ __STATIC_INLINE uint32_t LL_USART_GetNodeAddress(USART_TypeDef *USARTx) { return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_ADD)); } /** * @brief Enable RTS HW Flow Control * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not * Hardware Flow control feature is supported by the USARTx instance. * @rmtoll CR3 RTSE LL_USART_EnableRTSHWFlowCtrl * @param USARTx USART Instance * @retval None */ __STATIC_INLINE void LL_USART_EnableRTSHWFlowCtrl(USART_TypeDef *USARTx) { SET_BIT(USARTx->CR3, USART_CR3_RTSE); } /** * @brief Disable RTS HW Flow Control * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not * Hardware Flow control feature is supported by the USARTx instance. * @rmtoll CR3 RTSE LL_USART_DisableRTSHWFlowCtrl * @param USARTx USART Instance * @retval None */ __STATIC_INLINE void LL_USART_DisableRTSHWFlowCtrl(USART_TypeDef *USARTx) { CLEAR_BIT(USARTx->CR3, USART_CR3_RTSE); } /** * @brief Enable CTS HW Flow Control * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not * Hardware Flow control feature is supported by the USARTx instance. * @rmtoll CR3 CTSE LL_USART_EnableCTSHWFlowCtrl * @param USARTx USART Instance * @retval None */ __STATIC_INLINE void LL_USART_EnableCTSHWFlowCtrl(USART_TypeDef *USARTx) { SET_BIT(USARTx->CR3, USART_CR3_CTSE); } /** * @brief Disable CTS HW Flow Control * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not * Hardware Flow control feature is supported by the USARTx instance. * @rmtoll CR3 CTSE LL_USART_DisableCTSHWFlowCtrl * @param USARTx USART Instance * @retval None */ __STATIC_INLINE void LL_USART_DisableCTSHWFlowCtrl(USART_TypeDef *USARTx) { CLEAR_BIT(USARTx->CR3, USART_CR3_CTSE); } /** * @brief Configure HW Flow Control mode (both CTS and RTS) * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not * Hardware Flow control feature is supported by the USARTx instance. * @rmtoll CR3 RTSE LL_USART_SetHWFlowCtrl\n * CR3 CTSE LL_USART_SetHWFlowCtrl * @param USARTx USART Instance * @param HardwareFlowControl This parameter can be one of the following values: * @arg @ref LL_USART_HWCONTROL_NONE * @arg @ref LL_USART_HWCONTROL_RTS * @arg @ref LL_USART_HWCONTROL_CTS * @arg @ref LL_USART_HWCONTROL_RTS_CTS * @retval None */ __STATIC_INLINE void LL_USART_SetHWFlowCtrl(USART_TypeDef *USARTx, uint32_t HardwareFlowControl) { MODIFY_REG(USARTx->CR3, USART_CR3_RTSE | USART_CR3_CTSE, HardwareFlowControl); } /** * @brief Return HW Flow Control configuration (both CTS and RTS) * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not * Hardware Flow control feature is supported by the USARTx instance. * @rmtoll CR3 RTSE LL_USART_GetHWFlowCtrl\n * CR3 CTSE LL_USART_GetHWFlowCtrl * @param USARTx USART Instance * @retval Returned value can be one of the following values: * @arg @ref LL_USART_HWCONTROL_NONE * @arg @ref LL_USART_HWCONTROL_RTS * @arg @ref LL_USART_HWCONTROL_CTS * @arg @ref LL_USART_HWCONTROL_RTS_CTS */ __STATIC_INLINE uint32_t LL_USART_GetHWFlowCtrl(USART_TypeDef *USARTx) { return (uint32_t)(READ_BIT(USARTx->CR3, USART_CR3_RTSE | USART_CR3_CTSE)); } /** * @brief Enable One bit sampling method * @rmtoll CR3 ONEBIT LL_USART_EnableOneBitSamp * @param USARTx USART Instance * @retval None */ __STATIC_INLINE void LL_USART_EnableOneBitSamp(USART_TypeDef *USARTx) { SET_BIT(USARTx->CR3, USART_CR3_ONEBIT); } /** * @brief Disable One bit sampling method * @rmtoll CR3 ONEBIT LL_USART_DisableOneBitSamp * @param USARTx USART Instance * @retval None */ __STATIC_INLINE void LL_USART_DisableOneBitSamp(USART_TypeDef *USARTx) { CLEAR_BIT(USARTx->CR3, USART_CR3_ONEBIT); } /** * @brief Indicate if One bit sampling method is enabled * @rmtoll CR3 ONEBIT LL_USART_IsEnabledOneBitSamp * @param USARTx USART Instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_USART_IsEnabledOneBitSamp(USART_TypeDef *USARTx) { return (READ_BIT(USARTx->CR3, USART_CR3_ONEBIT) == (USART_CR3_ONEBIT)); } /** * @brief Configure USART BRR register for achieving expected Baud Rate value. * @note Compute and set USARTDIV value in BRR Register (full BRR content) * according to used Peripheral Clock, Oversampling mode, and expected Baud Rate values * @note Peripheral clock and Baud rate values provided as function parameters should be valid * (Baud rate value != 0) * @rmtoll BRR BRR LL_USART_SetBaudRate * @param USARTx USART Instance * @param PeriphClk Peripheral Clock * @param OverSampling This parameter can be one of the following values: * @arg @ref LL_USART_OVERSAMPLING_16 * @arg @ref LL_USART_OVERSAMPLING_8 * @param BaudRate Baud Rate * @retval None */ __STATIC_INLINE void LL_USART_SetBaudRate(USART_TypeDef *USARTx, uint32_t PeriphClk, uint32_t OverSampling, uint32_t BaudRate) { if (OverSampling == LL_USART_OVERSAMPLING_8) { USARTx->BRR = (uint16_t)(__LL_USART_DIV_SAMPLING8(PeriphClk, BaudRate)); } else { USARTx->BRR = (uint16_t)(__LL_USART_DIV_SAMPLING16(PeriphClk, BaudRate)); } } /** * @brief Return current Baud Rate value, according to USARTDIV present in BRR register * (full BRR content), and to used Peripheral Clock and Oversampling mode values * @note In case of non-initialized or invalid value stored in BRR register, value 0 will be returned. * @rmtoll BRR BRR LL_USART_GetBaudRate * @param USARTx USART Instance * @param PeriphClk Peripheral Clock * @param OverSampling This parameter can be one of the following values: * @arg @ref LL_USART_OVERSAMPLING_16 * @arg @ref LL_USART_OVERSAMPLING_8 * @retval Baud Rate */ __STATIC_INLINE uint32_t LL_USART_GetBaudRate(USART_TypeDef *USARTx, uint32_t PeriphClk, uint32_t OverSampling) { register uint32_t usartdiv = 0x0U; register uint32_t brrresult = 0x0U; usartdiv = USARTx->BRR; if (OverSampling == LL_USART_OVERSAMPLING_8) { if ((usartdiv & 0xFFF7U) != 0U) { usartdiv = (uint16_t)((usartdiv & 0xFFF0U) | ((usartdiv & 0x0007U) << 1U)) ; brrresult = (PeriphClk * 2U) / usartdiv; } } else { if ((usartdiv & 0xFFFFU) != 0U) { brrresult = PeriphClk / usartdiv; } } return (brrresult); } /** * @} */ /** @defgroup USART_LL_EF_Configuration_IRDA Configuration functions related to Irda feature * @{ */ /** * @brief Enable IrDA mode * @note Macro @ref IS_IRDA_INSTANCE(USARTx) can be used to check whether or not * IrDA feature is supported by the USARTx instance. * @rmtoll CR3 IREN LL_USART_EnableIrda * @param USARTx USART Instance * @retval None */ __STATIC_INLINE void LL_USART_EnableIrda(USART_TypeDef *USARTx) { SET_BIT(USARTx->CR3, USART_CR3_IREN); } /** * @brief Disable IrDA mode * @note Macro @ref IS_IRDA_INSTANCE(USARTx) can be used to check whether or not * IrDA feature is supported by the USARTx instance. * @rmtoll CR3 IREN LL_USART_DisableIrda * @param USARTx USART Instance * @retval None */ __STATIC_INLINE void LL_USART_DisableIrda(USART_TypeDef *USARTx) { CLEAR_BIT(USARTx->CR3, USART_CR3_IREN); } /** * @brief Indicate if IrDA mode is enabled * @note Macro @ref IS_IRDA_INSTANCE(USARTx) can be used to check whether or not * IrDA feature is supported by the USARTx instance. * @rmtoll CR3 IREN LL_USART_IsEnabledIrda * @param USARTx USART Instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_USART_IsEnabledIrda(USART_TypeDef *USARTx) { return (READ_BIT(USARTx->CR3, USART_CR3_IREN) == (USART_CR3_IREN)); } /** * @brief Configure IrDA Power Mode (Normal or Low Power) * @note Macro @ref IS_IRDA_INSTANCE(USARTx) can be used to check whether or not * IrDA feature is supported by the USARTx instance. * @rmtoll CR3 IRLP LL_USART_SetIrdaPowerMode * @param USARTx USART Instance * @param PowerMode This parameter can be one of the following values: * @arg @ref LL_USART_IRDA_POWER_NORMAL * @arg @ref LL_USART_IRDA_POWER_LOW * @retval None */ __STATIC_INLINE void LL_USART_SetIrdaPowerMode(USART_TypeDef *USARTx, uint32_t PowerMode) { MODIFY_REG(USARTx->CR3, USART_CR3_IRLP, PowerMode); } /** * @brief Retrieve IrDA Power Mode configuration (Normal or Low Power) * @note Macro @ref IS_IRDA_INSTANCE(USARTx) can be used to check whether or not * IrDA feature is supported by the USARTx instance. * @rmtoll CR3 IRLP LL_USART_GetIrdaPowerMode * @param USARTx USART Instance * @retval Returned value can be one of the following values: * @arg @ref LL_USART_IRDA_POWER_NORMAL * @arg @ref LL_USART_PHASE_2EDGE */ __STATIC_INLINE uint32_t LL_USART_GetIrdaPowerMode(USART_TypeDef *USARTx) { return (uint32_t)(READ_BIT(USARTx->CR3, USART_CR3_IRLP)); } /** * @brief Set Irda prescaler value, used for dividing the USART clock source * to achieve the Irda Low Power frequency (8 bits value) * @note Macro @ref IS_IRDA_INSTANCE(USARTx) can be used to check whether or not * IrDA feature is supported by the USARTx instance. * @rmtoll GTPR PSC LL_USART_SetIrdaPrescaler * @param USARTx USART Instance * @param PrescalerValue Value between Min_Data=0x00 and Max_Data=0xFF * @retval None */ __STATIC_INLINE void LL_USART_SetIrdaPrescaler(USART_TypeDef *USARTx, uint32_t PrescalerValue) { MODIFY_REG(USARTx->GTPR, USART_GTPR_PSC, PrescalerValue); } /** * @brief Return Irda prescaler value, used for dividing the USART clock source * to achieve the Irda Low Power frequency (8 bits value) * @note Macro @ref IS_IRDA_INSTANCE(USARTx) can be used to check whether or not * IrDA feature is supported by the USARTx instance. * @rmtoll GTPR PSC LL_USART_GetIrdaPrescaler * @param USARTx USART Instance * @retval Irda prescaler value (Value between Min_Data=0x00 and Max_Data=0xFF) */ __STATIC_INLINE uint32_t LL_USART_GetIrdaPrescaler(USART_TypeDef *USARTx) { return (uint32_t)(READ_BIT(USARTx->GTPR, USART_GTPR_PSC)); } /** * @} */ /** @defgroup USART_LL_EF_Configuration_Smartcard Configuration functions related to Smartcard feature * @{ */ /** * @brief Enable Smartcard NACK transmission * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not * Smartcard feature is supported by the USARTx instance. * @rmtoll CR3 NACK LL_USART_EnableSmartcardNACK * @param USARTx USART Instance * @retval None */ __STATIC_INLINE void LL_USART_EnableSmartcardNACK(USART_TypeDef *USARTx) { SET_BIT(USARTx->CR3, USART_CR3_NACK); } /** * @brief Disable Smartcard NACK transmission * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not * Smartcard feature is supported by the USARTx instance. * @rmtoll CR3 NACK LL_USART_DisableSmartcardNACK * @param USARTx USART Instance * @retval None */ __STATIC_INLINE void LL_USART_DisableSmartcardNACK(USART_TypeDef *USARTx) { CLEAR_BIT(USARTx->CR3, USART_CR3_NACK); } /** * @brief Indicate if Smartcard NACK transmission is enabled * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not * Smartcard feature is supported by the USARTx instance. * @rmtoll CR3 NACK LL_USART_IsEnabledSmartcardNACK * @param USARTx USART Instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_USART_IsEnabledSmartcardNACK(USART_TypeDef *USARTx) { return (READ_BIT(USARTx->CR3, USART_CR3_NACK) == (USART_CR3_NACK)); } /** * @brief Enable Smartcard mode * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not * Smartcard feature is supported by the USARTx instance. * @rmtoll CR3 SCEN LL_USART_EnableSmartcard * @param USARTx USART Instance * @retval None */ __STATIC_INLINE void LL_USART_EnableSmartcard(USART_TypeDef *USARTx) { SET_BIT(USARTx->CR3, USART_CR3_SCEN); } /** * @brief Disable Smartcard mode * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not * Smartcard feature is supported by the USARTx instance. * @rmtoll CR3 SCEN LL_USART_DisableSmartcard * @param USARTx USART Instance * @retval None */ __STATIC_INLINE void LL_USART_DisableSmartcard(USART_TypeDef *USARTx) { CLEAR_BIT(USARTx->CR3, USART_CR3_SCEN); } /** * @brief Indicate if Smartcard mode is enabled * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not * Smartcard feature is supported by the USARTx instance. * @rmtoll CR3 SCEN LL_USART_IsEnabledSmartcard * @param USARTx USART Instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_USART_IsEnabledSmartcard(USART_TypeDef *USARTx) { return (READ_BIT(USARTx->CR3, USART_CR3_SCEN) == (USART_CR3_SCEN)); } /** * @brief Set Smartcard prescaler value, used for dividing the USART clock * source to provide the SMARTCARD Clock (5 bits value) * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not * Smartcard feature is supported by the USARTx instance. * @rmtoll GTPR PSC LL_USART_SetSmartcardPrescaler * @param USARTx USART Instance * @param PrescalerValue Value between Min_Data=0 and Max_Data=31 * @retval None */ __STATIC_INLINE void LL_USART_SetSmartcardPrescaler(USART_TypeDef *USARTx, uint32_t PrescalerValue) { MODIFY_REG(USARTx->GTPR, USART_GTPR_PSC, PrescalerValue); } /** * @brief Return Smartcard prescaler value, used for dividing the USART clock * source to provide the SMARTCARD Clock (5 bits value) * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not * Smartcard feature is supported by the USARTx instance. * @rmtoll GTPR PSC LL_USART_GetSmartcardPrescaler * @param USARTx USART Instance * @retval Smartcard prescaler value (Value between Min_Data=0 and Max_Data=31) */ __STATIC_INLINE uint32_t LL_USART_GetSmartcardPrescaler(USART_TypeDef *USARTx) { return (uint32_t)(READ_BIT(USARTx->GTPR, USART_GTPR_PSC)); } /** * @brief Set Smartcard Guard time value, expressed in nb of baud clocks periods * (GT[7:0] bits : Guard time value) * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not * Smartcard feature is supported by the USARTx instance. * @rmtoll GTPR GT LL_USART_SetSmartcardGuardTime * @param USARTx USART Instance * @param GuardTime Value between Min_Data=0x00 and Max_Data=0xFF * @retval None */ __STATIC_INLINE void LL_USART_SetSmartcardGuardTime(USART_TypeDef *USARTx, uint32_t GuardTime) { MODIFY_REG(USARTx->GTPR, USART_GTPR_GT, GuardTime << USART_POSITION_GTPR_GT); } /** * @brief Return Smartcard Guard time value, expressed in nb of baud clocks periods * (GT[7:0] bits : Guard time value) * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not * Smartcard feature is supported by the USARTx instance. * @rmtoll GTPR GT LL_USART_GetSmartcardGuardTime * @param USARTx USART Instance * @retval Smartcard Guard time value (Value between Min_Data=0x00 and Max_Data=0xFF) */ __STATIC_INLINE uint32_t LL_USART_GetSmartcardGuardTime(USART_TypeDef *USARTx) { return (uint32_t)(READ_BIT(USARTx->GTPR, USART_GTPR_GT) >> USART_POSITION_GTPR_GT); } /** * @} */ /** @defgroup USART_LL_EF_Configuration_HalfDuplex Configuration functions related to Half Duplex feature * @{ */ /** * @brief Enable Single Wire Half-Duplex mode * @note Macro @ref IS_UART_HALFDUPLEX_INSTANCE(USARTx) can be used to check whether or not * Half-Duplex mode is supported by the USARTx instance. * @rmtoll CR3 HDSEL LL_USART_EnableHalfDuplex * @param USARTx USART Instance * @retval None */ __STATIC_INLINE void LL_USART_EnableHalfDuplex(USART_TypeDef *USARTx) { SET_BIT(USARTx->CR3, USART_CR3_HDSEL); } /** * @brief Disable Single Wire Half-Duplex mode * @note Macro @ref IS_UART_HALFDUPLEX_INSTANCE(USARTx) can be used to check whether or not * Half-Duplex mode is supported by the USARTx instance. * @rmtoll CR3 HDSEL LL_USART_DisableHalfDuplex * @param USARTx USART Instance * @retval None */ __STATIC_INLINE void LL_USART_DisableHalfDuplex(USART_TypeDef *USARTx) { CLEAR_BIT(USARTx->CR3, USART_CR3_HDSEL); } /** * @brief Indicate if Single Wire Half-Duplex mode is enabled * @note Macro @ref IS_UART_HALFDUPLEX_INSTANCE(USARTx) can be used to check whether or not * Half-Duplex mode is supported by the USARTx instance. * @rmtoll CR3 HDSEL LL_USART_IsEnabledHalfDuplex * @param USARTx USART Instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_USART_IsEnabledHalfDuplex(USART_TypeDef *USARTx) { return (READ_BIT(USARTx->CR3, USART_CR3_HDSEL) == (USART_CR3_HDSEL)); } /** * @} */ /** @defgroup USART_LL_EF_Configuration_LIN Configuration functions related to LIN feature * @{ */ /** * @brief Set LIN Break Detection Length * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not * LIN feature is supported by the USARTx instance. * @rmtoll CR2 LBDL LL_USART_SetLINBrkDetectionLen * @param USARTx USART Instance * @param LINBDLength This parameter can be one of the following values: * @arg @ref LL_USART_LINBREAK_DETECT_10B * @arg @ref LL_USART_LINBREAK_DETECT_11B * @retval None */ __STATIC_INLINE void LL_USART_SetLINBrkDetectionLen(USART_TypeDef *USARTx, uint32_t LINBDLength) { MODIFY_REG(USARTx->CR2, USART_CR2_LBDL, LINBDLength); } /** * @brief Return LIN Break Detection Length * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not * LIN feature is supported by the USARTx instance. * @rmtoll CR2 LBDL LL_USART_GetLINBrkDetectionLen * @param USARTx USART Instance * @retval Returned value can be one of the following values: * @arg @ref LL_USART_LINBREAK_DETECT_10B * @arg @ref LL_USART_LINBREAK_DETECT_11B */ __STATIC_INLINE uint32_t LL_USART_GetLINBrkDetectionLen(USART_TypeDef *USARTx) { return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_LBDL)); } /** * @brief Enable LIN mode * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not * LIN feature is supported by the USARTx instance. * @rmtoll CR2 LINEN LL_USART_EnableLIN * @param USARTx USART Instance * @retval None */ __STATIC_INLINE void LL_USART_EnableLIN(USART_TypeDef *USARTx) { SET_BIT(USARTx->CR2, USART_CR2_LINEN); } /** * @brief Disable LIN mode * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not * LIN feature is supported by the USARTx instance. * @rmtoll CR2 LINEN LL_USART_DisableLIN * @param USARTx USART Instance * @retval None */ __STATIC_INLINE void LL_USART_DisableLIN(USART_TypeDef *USARTx) { CLEAR_BIT(USARTx->CR2, USART_CR2_LINEN); } /** * @brief Indicate if LIN mode is enabled * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not * LIN feature is supported by the USARTx instance. * @rmtoll CR2 LINEN LL_USART_IsEnabledLIN * @param USARTx USART Instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_USART_IsEnabledLIN(USART_TypeDef *USARTx) { return (READ_BIT(USARTx->CR2, USART_CR2_LINEN) == (USART_CR2_LINEN)); } /** * @} */ /** @defgroup USART_LL_EF_AdvancedConfiguration Advanced Configurations services * @{ */ /** * @brief Perform basic configuration of USART for enabling use in Asynchronous Mode (UART) * @note In UART mode, the following bits must be kept cleared: * - LINEN bit in the USART_CR2 register, * - CLKEN bit in the USART_CR2 register, * - SCEN bit in the USART_CR3 register, * - IREN bit in the USART_CR3 register, * - HDSEL bit in the USART_CR3 register. * @note Call of this function is equivalent to following function call sequence : * - Clear LINEN in CR2 using @ref LL_USART_DisableLIN() function * - Clear CLKEN in CR2 using @ref LL_USART_DisableSCLKOutput() function * - Clear SCEN in CR3 using @ref LL_USART_DisableSmartcard() function * - Clear IREN in CR3 using @ref LL_USART_DisableIrda() function * - Clear HDSEL in CR3 using @ref LL_USART_DisableHalfDuplex() function * @note Other remaining configurations items related to Asynchronous Mode * (as Baud Rate, Word length, Parity, ...) should be set using * dedicated functions * @rmtoll CR2 LINEN LL_USART_ConfigAsyncMode\n * CR2 CLKEN LL_USART_ConfigAsyncMode\n * CR3 SCEN LL_USART_ConfigAsyncMode\n * CR3 IREN LL_USART_ConfigAsyncMode\n * CR3 HDSEL LL_USART_ConfigAsyncMode * @param USARTx USART Instance * @retval None */ __STATIC_INLINE void LL_USART_ConfigAsyncMode(USART_TypeDef *USARTx) { /* In Asynchronous mode, the following bits must be kept cleared: - LINEN, CLKEN bits in the USART_CR2 register, - SCEN, IREN and HDSEL bits in the USART_CR3 register.*/ CLEAR_BIT(USARTx->CR2, (USART_CR2_LINEN | USART_CR2_CLKEN)); CLEAR_BIT(USARTx->CR3, (USART_CR3_SCEN | USART_CR3_IREN | USART_CR3_HDSEL)); } /** * @brief Perform basic configuration of USART for enabling use in Synchronous Mode * @note In Synchronous mode, the following bits must be kept cleared: * - LINEN bit in the USART_CR2 register, * - SCEN bit in the USART_CR3 register, * - IREN bit in the USART_CR3 register, * - HDSEL bit in the USART_CR3 register. * This function also sets the USART in Synchronous mode. * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not * Synchronous mode is supported by the USARTx instance. * @note Call of this function is equivalent to following function call sequence : * - Clear LINEN in CR2 using @ref LL_USART_DisableLIN() function * - Clear IREN in CR3 using @ref LL_USART_DisableIrda() function * - Clear SCEN in CR3 using @ref LL_USART_DisableSmartcard() function * - Clear HDSEL in CR3 using @ref LL_USART_DisableHalfDuplex() function * - Set CLKEN in CR2 using @ref LL_USART_EnableSCLKOutput() function * @note Other remaining configurations items related to Synchronous Mode * (as Baud Rate, Word length, Parity, Clock Polarity, ...) should be set using * dedicated functions * @rmtoll CR2 LINEN LL_USART_ConfigSyncMode\n * CR2 CLKEN LL_USART_ConfigSyncMode\n * CR3 SCEN LL_USART_ConfigSyncMode\n * CR3 IREN LL_USART_ConfigSyncMode\n * CR3 HDSEL LL_USART_ConfigSyncMode * @param USARTx USART Instance * @retval None */ __STATIC_INLINE void LL_USART_ConfigSyncMode(USART_TypeDef *USARTx) { /* In Synchronous mode, the following bits must be kept cleared: - LINEN bit in the USART_CR2 register, - SCEN, IREN and HDSEL bits in the USART_CR3 register.*/ CLEAR_BIT(USARTx->CR2, (USART_CR2_LINEN)); CLEAR_BIT(USARTx->CR3, (USART_CR3_SCEN | USART_CR3_IREN | USART_CR3_HDSEL)); /* set the UART/USART in Synchronous mode */ SET_BIT(USARTx->CR2, USART_CR2_CLKEN); } /** * @brief Perform basic configuration of USART for enabling use in LIN Mode * @note In LIN mode, the following bits must be kept cleared: * - STOP and CLKEN bits in the USART_CR2 register, * - SCEN bit in the USART_CR3 register, * - IREN bit in the USART_CR3 register, * - HDSEL bit in the USART_CR3 register. * This function also set the UART/USART in LIN mode. * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not * LIN feature is supported by the USARTx instance. * @note Call of this function is equivalent to following function call sequence : * - Clear CLKEN in CR2 using @ref LL_USART_DisableSCLKOutput() function * - Clear STOP in CR2 using @ref LL_USART_SetStopBitsLength() function * - Clear SCEN in CR3 using @ref LL_USART_DisableSmartcard() function * - Clear IREN in CR3 using @ref LL_USART_DisableIrda() function * - Clear HDSEL in CR3 using @ref LL_USART_DisableHalfDuplex() function * - Set LINEN in CR2 using @ref LL_USART_EnableLIN() function * @note Other remaining configurations items related to LIN Mode * (as Baud Rate, Word length, LIN Break Detection Length, ...) should be set using * dedicated functions * @rmtoll CR2 CLKEN LL_USART_ConfigLINMode\n * CR2 STOP LL_USART_ConfigLINMode\n * CR2 LINEN LL_USART_ConfigLINMode\n * CR3 IREN LL_USART_ConfigLINMode\n * CR3 SCEN LL_USART_ConfigLINMode\n * CR3 HDSEL LL_USART_ConfigLINMode * @param USARTx USART Instance * @retval None */ __STATIC_INLINE void LL_USART_ConfigLINMode(USART_TypeDef *USARTx) { /* In LIN mode, the following bits must be kept cleared: - STOP and CLKEN bits in the USART_CR2 register, - IREN, SCEN and HDSEL bits in the USART_CR3 register.*/ CLEAR_BIT(USARTx->CR2, (USART_CR2_CLKEN | USART_CR2_STOP)); CLEAR_BIT(USARTx->CR3, (USART_CR3_IREN | USART_CR3_SCEN | USART_CR3_HDSEL)); /* Set the UART/USART in LIN mode */ SET_BIT(USARTx->CR2, USART_CR2_LINEN); } /** * @brief Perform basic configuration of USART for enabling use in Half Duplex Mode * @note In Half Duplex mode, the following bits must be kept cleared: * - LINEN bit in the USART_CR2 register, * - CLKEN bit in the USART_CR2 register, * - SCEN bit in the USART_CR3 register, * - IREN bit in the USART_CR3 register, * This function also sets the UART/USART in Half Duplex mode. * @note Macro @ref IS_UART_HALFDUPLEX_INSTANCE(USARTx) can be used to check whether or not * Half-Duplex mode is supported by the USARTx instance. * @note Call of this function is equivalent to following function call sequence : * - Clear LINEN in CR2 using @ref LL_USART_DisableLIN() function * - Clear CLKEN in CR2 using @ref LL_USART_DisableSCLKOutput() function * - Clear SCEN in CR3 using @ref LL_USART_DisableSmartcard() function * - Clear IREN in CR3 using @ref LL_USART_DisableIrda() function * - Set HDSEL in CR3 using @ref LL_USART_EnableHalfDuplex() function * @note Other remaining configurations items related to Half Duplex Mode * (as Baud Rate, Word length, Parity, ...) should be set using * dedicated functions * @rmtoll CR2 LINEN LL_USART_ConfigHalfDuplexMode\n * CR2 CLKEN LL_USART_ConfigHalfDuplexMode\n * CR3 HDSEL LL_USART_ConfigHalfDuplexMode\n * CR3 SCEN LL_USART_ConfigHalfDuplexMode\n * CR3 IREN LL_USART_ConfigHalfDuplexMode * @param USARTx USART Instance * @retval None */ __STATIC_INLINE void LL_USART_ConfigHalfDuplexMode(USART_TypeDef *USARTx) { /* In Half Duplex mode, the following bits must be kept cleared: - LINEN and CLKEN bits in the USART_CR2 register, - SCEN and IREN bits in the USART_CR3 register.*/ CLEAR_BIT(USARTx->CR2, (USART_CR2_LINEN | USART_CR2_CLKEN)); CLEAR_BIT(USARTx->CR3, (USART_CR3_SCEN | USART_CR3_IREN)); /* set the UART/USART in Half Duplex mode */ SET_BIT(USARTx->CR3, USART_CR3_HDSEL); } /** * @brief Perform basic configuration of USART for enabling use in Smartcard Mode * @note In Smartcard mode, the following bits must be kept cleared: * - LINEN bit in the USART_CR2 register, * - IREN bit in the USART_CR3 register, * - HDSEL bit in the USART_CR3 register. * This function also configures Stop bits to 1.5 bits and * sets the USART in Smartcard mode (SCEN bit). * Clock Output is also enabled (CLKEN). * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not * Smartcard feature is supported by the USARTx instance. * @note Call of this function is equivalent to following function call sequence : * - Clear LINEN in CR2 using @ref LL_USART_DisableLIN() function * - Clear IREN in CR3 using @ref LL_USART_DisableIrda() function * - Clear HDSEL in CR3 using @ref LL_USART_DisableHalfDuplex() function * - Configure STOP in CR2 using @ref LL_USART_SetStopBitsLength() function * - Set CLKEN in CR2 using @ref LL_USART_EnableSCLKOutput() function * - Set SCEN in CR3 using @ref LL_USART_EnableSmartcard() function * @note Other remaining configurations items related to Smartcard Mode * (as Baud Rate, Word length, Parity, ...) should be set using * dedicated functions * @rmtoll CR2 LINEN LL_USART_ConfigSmartcardMode\n * CR2 STOP LL_USART_ConfigSmartcardMode\n * CR2 CLKEN LL_USART_ConfigSmartcardMode\n * CR3 HDSEL LL_USART_ConfigSmartcardMode\n * CR3 SCEN LL_USART_ConfigSmartcardMode * @param USARTx USART Instance * @retval None */ __STATIC_INLINE void LL_USART_ConfigSmartcardMode(USART_TypeDef *USARTx) { /* In Smartcard mode, the following bits must be kept cleared: - LINEN bit in the USART_CR2 register, - IREN and HDSEL bits in the USART_CR3 register.*/ CLEAR_BIT(USARTx->CR2, (USART_CR2_LINEN)); CLEAR_BIT(USARTx->CR3, (USART_CR3_IREN | USART_CR3_HDSEL)); /* Configure Stop bits to 1.5 bits */ /* Synchronous mode is activated by default */ SET_BIT(USARTx->CR2, (USART_CR2_STOP_0 | USART_CR2_STOP_1 | USART_CR2_CLKEN)); /* set the UART/USART in Smartcard mode */ SET_BIT(USARTx->CR3, USART_CR3_SCEN); } /** * @brief Perform basic configuration of USART for enabling use in Irda Mode * @note In IRDA mode, the following bits must be kept cleared: * - LINEN bit in the USART_CR2 register, * - STOP and CLKEN bits in the USART_CR2 register, * - SCEN bit in the USART_CR3 register, * - HDSEL bit in the USART_CR3 register. * This function also sets the UART/USART in IRDA mode (IREN bit). * @note Macro @ref IS_IRDA_INSTANCE(USARTx) can be used to check whether or not * IrDA feature is supported by the USARTx instance. * @note Call of this function is equivalent to following function call sequence : * - Clear LINEN in CR2 using @ref LL_USART_DisableLIN() function * - Clear CLKEN in CR2 using @ref LL_USART_DisableSCLKOutput() function * - Clear SCEN in CR3 using @ref LL_USART_DisableSmartcard() function * - Clear HDSEL in CR3 using @ref LL_USART_DisableHalfDuplex() function * - Configure STOP in CR2 using @ref LL_USART_SetStopBitsLength() function * - Set IREN in CR3 using @ref LL_USART_EnableIrda() function * @note Other remaining configurations items related to Irda Mode * (as Baud Rate, Word length, Power mode, ...) should be set using * dedicated functions * @rmtoll CR2 LINEN LL_USART_ConfigIrdaMode\n * CR2 CLKEN LL_USART_ConfigIrdaMode\n * CR2 STOP LL_USART_ConfigIrdaMode\n * CR3 SCEN LL_USART_ConfigIrdaMode\n * CR3 HDSEL LL_USART_ConfigIrdaMode\n * CR3 IREN LL_USART_ConfigIrdaMode * @param USARTx USART Instance * @retval None */ __STATIC_INLINE void LL_USART_ConfigIrdaMode(USART_TypeDef *USARTx) { /* In IRDA mode, the following bits must be kept cleared: - LINEN, STOP and CLKEN bits in the USART_CR2 register, - SCEN and HDSEL bits in the USART_CR3 register.*/ CLEAR_BIT(USARTx->CR2, (USART_CR2_LINEN | USART_CR2_CLKEN | USART_CR2_STOP)); CLEAR_BIT(USARTx->CR3, (USART_CR3_SCEN | USART_CR3_HDSEL)); /* set the UART/USART in IRDA mode */ SET_BIT(USARTx->CR3, USART_CR3_IREN); } /** * @brief Perform basic configuration of USART for enabling use in Multi processor Mode * (several USARTs connected in a network, one of the USARTs can be the master, * its TX output connected to the RX inputs of the other slaves USARTs). * @note In MultiProcessor mode, the following bits must be kept cleared: * - LINEN bit in the USART_CR2 register, * - CLKEN bit in the USART_CR2 register, * - SCEN bit in the USART_CR3 register, * - IREN bit in the USART_CR3 register, * - HDSEL bit in the USART_CR3 register. * @note Call of this function is equivalent to following function call sequence : * - Clear LINEN in CR2 using @ref LL_USART_DisableLIN() function * - Clear CLKEN in CR2 using @ref LL_USART_DisableSCLKOutput() function * - Clear SCEN in CR3 using @ref LL_USART_DisableSmartcard() function * - Clear IREN in CR3 using @ref LL_USART_DisableIrda() function * - Clear HDSEL in CR3 using @ref LL_USART_DisableHalfDuplex() function * @note Other remaining configurations items related to Multi processor Mode * (as Baud Rate, Wake Up Method, Node address, ...) should be set using * dedicated functions * @rmtoll CR2 LINEN LL_USART_ConfigMultiProcessMode\n * CR2 CLKEN LL_USART_ConfigMultiProcessMode\n * CR3 SCEN LL_USART_ConfigMultiProcessMode\n * CR3 HDSEL LL_USART_ConfigMultiProcessMode\n * CR3 IREN LL_USART_ConfigMultiProcessMode * @param USARTx USART Instance * @retval None */ __STATIC_INLINE void LL_USART_ConfigMultiProcessMode(USART_TypeDef *USARTx) { /* In Multi Processor mode, the following bits must be kept cleared: - LINEN and CLKEN bits in the USART_CR2 register, - IREN, SCEN and HDSEL bits in the USART_CR3 register.*/ CLEAR_BIT(USARTx->CR2, (USART_CR2_LINEN | USART_CR2_CLKEN)); CLEAR_BIT(USARTx->CR3, (USART_CR3_SCEN | USART_CR3_HDSEL | USART_CR3_IREN)); } /** * @} */ /** @defgroup USART_LL_EF_FLAG_Management FLAG_Management * @{ */ /** * @brief Check if the USART Parity Error Flag is set or not * @rmtoll SR PE LL_USART_IsActiveFlag_PE * @param USARTx USART Instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_PE(USART_TypeDef *USARTx) { return (READ_BIT(USARTx->SR, USART_SR_PE) == (USART_SR_PE)); } /** * @brief Check if the USART Framing Error Flag is set or not * @rmtoll SR FE LL_USART_IsActiveFlag_FE * @param USARTx USART Instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_FE(USART_TypeDef *USARTx) { return (READ_BIT(USARTx->SR, USART_SR_FE) == (USART_SR_FE)); } /** * @brief Check if the USART Noise error detected Flag is set or not * @rmtoll SR NF LL_USART_IsActiveFlag_NE * @param USARTx USART Instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_NE(USART_TypeDef *USARTx) { return (READ_BIT(USARTx->SR, USART_SR_NE) == (USART_SR_NE)); } /** * @brief Check if the USART OverRun Error Flag is set or not * @rmtoll SR ORE LL_USART_IsActiveFlag_ORE * @param USARTx USART Instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_ORE(USART_TypeDef *USARTx) { return (READ_BIT(USARTx->SR, USART_SR_ORE) == (USART_SR_ORE)); } /** * @brief Check if the USART IDLE line detected Flag is set or not * @rmtoll SR IDLE LL_USART_IsActiveFlag_IDLE * @param USARTx USART Instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_IDLE(USART_TypeDef *USARTx) { return (READ_BIT(USARTx->SR, USART_SR_IDLE) == (USART_SR_IDLE)); } /** * @brief Check if the USART Read Data Register Not Empty Flag is set or not * @rmtoll SR RXNE LL_USART_IsActiveFlag_RXNE * @param USARTx USART Instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_RXNE(USART_TypeDef *USARTx) { return (READ_BIT(USARTx->SR, USART_SR_RXNE) == (USART_SR_RXNE)); } /** * @brief Check if the USART Transmission Complete Flag is set or not * @rmtoll SR TC LL_USART_IsActiveFlag_TC * @param USARTx USART Instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_TC(USART_TypeDef *USARTx) { return (READ_BIT(USARTx->SR, USART_SR_TC) == (USART_SR_TC)); } /** * @brief Check if the USART Transmit Data Register Empty Flag is set or not * @rmtoll SR TXE LL_USART_IsActiveFlag_TXE * @param USARTx USART Instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_TXE(USART_TypeDef *USARTx) { return (READ_BIT(USARTx->SR, USART_SR_TXE) == (USART_SR_TXE)); } /** * @brief Check if the USART LIN Break Detection Flag is set or not * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not * LIN feature is supported by the USARTx instance. * @rmtoll SR LBD LL_USART_IsActiveFlag_LBD * @param USARTx USART Instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_LBD(USART_TypeDef *USARTx) { return (READ_BIT(USARTx->SR, USART_SR_LBD) == (USART_SR_LBD)); } /** * @brief Check if the USART CTS Flag is set or not * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not * Hardware Flow control feature is supported by the USARTx instance. * @rmtoll SR CTS LL_USART_IsActiveFlag_nCTS * @param USARTx USART Instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_nCTS(USART_TypeDef *USARTx) { return (READ_BIT(USARTx->SR, USART_SR_CTS) == (USART_SR_CTS)); } /** * @brief Check if the USART Send Break Flag is set or not * @rmtoll CR1 SBK LL_USART_IsActiveFlag_SBK * @param USARTx USART Instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_SBK(USART_TypeDef *USARTx) { return (READ_BIT(USARTx->CR1, USART_CR1_SBK) == (USART_CR1_SBK)); } /** * @brief Check if the USART Receive Wake Up from mute mode Flag is set or not * @rmtoll CR1 RWU LL_USART_IsActiveFlag_RWU * @param USARTx USART Instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_RWU(USART_TypeDef *USARTx) { return (READ_BIT(USARTx->CR1, USART_CR1_RWU) == (USART_CR1_RWU)); } /** * @brief Clear Parity Error Flag * @note Clearing this flag is done by a read access to the USARTx_SR * register followed by a read access to the USARTx_DR register. * @note Please also consider that when clearing this flag, other flags as * NE, FE, ORE, IDLE would also be cleared. * @rmtoll SR PE LL_USART_ClearFlag_PE * @param USARTx USART Instance * @retval None */ __STATIC_INLINE void LL_USART_ClearFlag_PE(USART_TypeDef *USARTx) { __IO uint32_t tmpreg; tmpreg = USARTx->SR; (void) tmpreg; tmpreg = USARTx->DR; (void) tmpreg; } /** * @brief Clear Framing Error Flag * @note Clearing this flag is done by a read access to the USARTx_SR * register followed by a read access to the USARTx_DR register. * @note Please also consider that when clearing this flag, other flags as * PE, NE, ORE, IDLE would also be cleared. * @rmtoll SR FE LL_USART_ClearFlag_FE * @param USARTx USART Instance * @retval None */ __STATIC_INLINE void LL_USART_ClearFlag_FE(USART_TypeDef *USARTx) { __IO uint32_t tmpreg; tmpreg = USARTx->SR; (void) tmpreg; tmpreg = USARTx->DR; (void) tmpreg; } /** * @brief Clear Noise detected Flag * @note Clearing this flag is done by a read access to the USARTx_SR * register followed by a read access to the USARTx_DR register. * @note Please also consider that when clearing this flag, other flags as * PE, FE, ORE, IDLE would also be cleared. * @rmtoll SR NF LL_USART_ClearFlag_NE * @param USARTx USART Instance * @retval None */ __STATIC_INLINE void LL_USART_ClearFlag_NE(USART_TypeDef *USARTx) { __IO uint32_t tmpreg; tmpreg = USARTx->SR; (void) tmpreg; tmpreg = USARTx->DR; (void) tmpreg; } /** * @brief Clear OverRun Error Flag * @note Clearing this flag is done by a read access to the USARTx_SR * register followed by a read access to the USARTx_DR register. * @note Please also consider that when clearing this flag, other flags as * PE, NE, FE, IDLE would also be cleared. * @rmtoll SR ORE LL_USART_ClearFlag_ORE * @param USARTx USART Instance * @retval None */ __STATIC_INLINE void LL_USART_ClearFlag_ORE(USART_TypeDef *USARTx) { __IO uint32_t tmpreg; tmpreg = USARTx->SR; (void) tmpreg; tmpreg = USARTx->DR; (void) tmpreg; } /** * @brief Clear IDLE line detected Flag * @note Clearing this flag is done by a read access to the USARTx_SR * register followed by a read access to the USARTx_DR register. * @note Please also consider that when clearing this flag, other flags as * PE, NE, FE, ORE would also be cleared. * @rmtoll SR IDLE LL_USART_ClearFlag_IDLE * @param USARTx USART Instance * @retval None */ __STATIC_INLINE void LL_USART_ClearFlag_IDLE(USART_TypeDef *USARTx) { __IO uint32_t tmpreg; tmpreg = USARTx->SR; (void) tmpreg; tmpreg = USARTx->DR; (void) tmpreg; } /** * @brief Clear Transmission Complete Flag * @rmtoll SR TC LL_USART_ClearFlag_TC * @param USARTx USART Instance * @retval None */ __STATIC_INLINE void LL_USART_ClearFlag_TC(USART_TypeDef *USARTx) { WRITE_REG(USARTx->SR , ~(USART_SR_TC)); } /** * @brief Clear RX Not Empty Flag * @rmtoll SR RXNE LL_USART_ClearFlag_RXNE * @param USARTx USART Instance * @retval None */ __STATIC_INLINE void LL_USART_ClearFlag_RXNE(USART_TypeDef *USARTx) { WRITE_REG(USARTx->SR , ~(USART_SR_RXNE)); } /** * @brief Clear LIN Break Detection Flag * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not * LIN feature is supported by the USARTx instance. * @rmtoll SR LBD LL_USART_ClearFlag_LBD * @param USARTx USART Instance * @retval None */ __STATIC_INLINE void LL_USART_ClearFlag_LBD(USART_TypeDef *USARTx) { WRITE_REG(USARTx->SR , ~(USART_SR_LBD)); } /** * @brief Clear CTS Interrupt Flag * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not * Hardware Flow control feature is supported by the USARTx instance. * @rmtoll SR CTS LL_USART_ClearFlag_nCTS * @param USARTx USART Instance * @retval None */ __STATIC_INLINE void LL_USART_ClearFlag_nCTS(USART_TypeDef *USARTx) { WRITE_REG(USARTx->SR , ~(USART_SR_CTS)); } /** * @} */ /** @defgroup USART_LL_EF_IT_Management IT_Management * @{ */ /** * @brief Enable IDLE Interrupt * @rmtoll CR1 IDLEIE LL_USART_EnableIT_IDLE * @param USARTx USART Instance * @retval None */ __STATIC_INLINE void LL_USART_EnableIT_IDLE(USART_TypeDef *USARTx) { SET_BIT(USARTx->CR1, USART_CR1_IDLEIE); } /** * @brief Enable RX Not Empty Interrupt * @rmtoll CR1 RXNEIE LL_USART_EnableIT_RXNE * @param USARTx USART Instance * @retval None */ __STATIC_INLINE void LL_USART_EnableIT_RXNE(USART_TypeDef *USARTx) { SET_BIT(USARTx->CR1, USART_CR1_RXNEIE); } /** * @brief Enable Transmission Complete Interrupt * @rmtoll CR1 TCIE LL_USART_EnableIT_TC * @param USARTx USART Instance * @retval None */ __STATIC_INLINE void LL_USART_EnableIT_TC(USART_TypeDef *USARTx) { SET_BIT(USARTx->CR1, USART_CR1_TCIE); } /** * @brief Enable TX Empty Interrupt * @rmtoll CR1 TXEIE LL_USART_EnableIT_TXE * @param USARTx USART Instance * @retval None */ __STATIC_INLINE void LL_USART_EnableIT_TXE(USART_TypeDef *USARTx) { SET_BIT(USARTx->CR1, USART_CR1_TXEIE); } /** * @brief Enable Parity Error Interrupt * @rmtoll CR1 PEIE LL_USART_EnableIT_PE * @param USARTx USART Instance * @retval None */ __STATIC_INLINE void LL_USART_EnableIT_PE(USART_TypeDef *USARTx) { SET_BIT(USARTx->CR1, USART_CR1_PEIE); } /** * @brief Enable LIN Break Detection Interrupt * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not * LIN feature is supported by the USARTx instance. * @rmtoll CR2 LBDIE LL_USART_EnableIT_LBD * @param USARTx USART Instance * @retval None */ __STATIC_INLINE void LL_USART_EnableIT_LBD(USART_TypeDef *USARTx) { SET_BIT(USARTx->CR2, USART_CR2_LBDIE); } /** * @brief Enable Error Interrupt * @note When set, Error Interrupt Enable Bit is enabling interrupt generation in case of a framing * error, overrun error or noise flag (FE=1 or ORE=1 or NF=1 in the USARTx_SR register). * 0: Interrupt is inhibited * 1: An interrupt is generated when FE=1 or ORE=1 or NF=1 in the USARTx_SR register. * @rmtoll CR3 EIE LL_USART_EnableIT_ERROR * @param USARTx USART Instance * @retval None */ __STATIC_INLINE void LL_USART_EnableIT_ERROR(USART_TypeDef *USARTx) { SET_BIT(USARTx->CR3, USART_CR3_EIE); } /** * @brief Enable CTS Interrupt * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not * Hardware Flow control feature is supported by the USARTx instance. * @rmtoll CR3 CTSIE LL_USART_EnableIT_CTS * @param USARTx USART Instance * @retval None */ __STATIC_INLINE void LL_USART_EnableIT_CTS(USART_TypeDef *USARTx) { SET_BIT(USARTx->CR3, USART_CR3_CTSIE); } /** * @brief Disable IDLE Interrupt * @rmtoll CR1 IDLEIE LL_USART_DisableIT_IDLE * @param USARTx USART Instance * @retval None */ __STATIC_INLINE void LL_USART_DisableIT_IDLE(USART_TypeDef *USARTx) { CLEAR_BIT(USARTx->CR1, USART_CR1_IDLEIE); } /** * @brief Disable RX Not Empty Interrupt * @rmtoll CR1 RXNEIE LL_USART_DisableIT_RXNE * @param USARTx USART Instance * @retval None */ __STATIC_INLINE void LL_USART_DisableIT_RXNE(USART_TypeDef *USARTx) { CLEAR_BIT(USARTx->CR1, USART_CR1_RXNEIE); } /** * @brief Disable Transmission Complete Interrupt * @rmtoll CR1 TCIE LL_USART_DisableIT_TC * @param USARTx USART Instance * @retval None */ __STATIC_INLINE void LL_USART_DisableIT_TC(USART_TypeDef *USARTx) { CLEAR_BIT(USARTx->CR1, USART_CR1_TCIE); } /** * @brief Disable TX Empty Interrupt * @rmtoll CR1 TXEIE LL_USART_DisableIT_TXE * @param USARTx USART Instance * @retval None */ __STATIC_INLINE void LL_USART_DisableIT_TXE(USART_TypeDef *USARTx) { CLEAR_BIT(USARTx->CR1, USART_CR1_TXEIE); } /** * @brief Disable Parity Error Interrupt * @rmtoll CR1 PEIE LL_USART_DisableIT_PE * @param USARTx USART Instance * @retval None */ __STATIC_INLINE void LL_USART_DisableIT_PE(USART_TypeDef *USARTx) { CLEAR_BIT(USARTx->CR1, USART_CR1_PEIE); } /** * @brief Disable LIN Break Detection Interrupt * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not * LIN feature is supported by the USARTx instance. * @rmtoll CR2 LBDIE LL_USART_DisableIT_LBD * @param USARTx USART Instance * @retval None */ __STATIC_INLINE void LL_USART_DisableIT_LBD(USART_TypeDef *USARTx) { CLEAR_BIT(USARTx->CR2, USART_CR2_LBDIE); } /** * @brief Disable Error Interrupt * @note When set, Error Interrupt Enable Bit is enabling interrupt generation in case of a framing * error, overrun error or noise flag (FE=1 or ORE=1 or NF=1 in the USARTx_SR register). * 0: Interrupt is inhibited * 1: An interrupt is generated when FE=1 or ORE=1 or NF=1 in the USARTx_SR register. * @rmtoll CR3 EIE LL_USART_DisableIT_ERROR * @param USARTx USART Instance * @retval None */ __STATIC_INLINE void LL_USART_DisableIT_ERROR(USART_TypeDef *USARTx) { CLEAR_BIT(USARTx->CR3, USART_CR3_EIE); } /** * @brief Disable CTS Interrupt * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not * Hardware Flow control feature is supported by the USARTx instance. * @rmtoll CR3 CTSIE LL_USART_DisableIT_CTS * @param USARTx USART Instance * @retval None */ __STATIC_INLINE void LL_USART_DisableIT_CTS(USART_TypeDef *USARTx) { CLEAR_BIT(USARTx->CR3, USART_CR3_CTSIE); } /** * @brief Check if the USART IDLE Interrupt source is enabled or disabled. * @rmtoll CR1 IDLEIE LL_USART_IsEnabledIT_IDLE * @param USARTx USART Instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_IDLE(USART_TypeDef *USARTx) { return (READ_BIT(USARTx->CR1, USART_CR1_IDLEIE) == (USART_CR1_IDLEIE)); } /** * @brief Check if the USART RX Not Empty Interrupt is enabled or disabled. * @rmtoll CR1 RXNEIE LL_USART_IsEnabledIT_RXNE * @param USARTx USART Instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_RXNE(USART_TypeDef *USARTx) { return (READ_BIT(USARTx->CR1, USART_CR1_RXNEIE) == (USART_CR1_RXNEIE)); } /** * @brief Check if the USART Transmission Complete Interrupt is enabled or disabled. * @rmtoll CR1 TCIE LL_USART_IsEnabledIT_TC * @param USARTx USART Instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_TC(USART_TypeDef *USARTx) { return (READ_BIT(USARTx->CR1, USART_CR1_TCIE) == (USART_CR1_TCIE)); } /** * @brief Check if the USART TX Empty Interrupt is enabled or disabled. * @rmtoll CR1 TXEIE LL_USART_IsEnabledIT_TXE * @param USARTx USART Instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_TXE(USART_TypeDef *USARTx) { return (READ_BIT(USARTx->CR1, USART_CR1_TXEIE) == (USART_CR1_TXEIE)); } /** * @brief Check if the USART Parity Error Interrupt is enabled or disabled. * @rmtoll CR1 PEIE LL_USART_IsEnabledIT_PE * @param USARTx USART Instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_PE(USART_TypeDef *USARTx) { return (READ_BIT(USARTx->CR1, USART_CR1_PEIE) == (USART_CR1_PEIE)); } /** * @brief Check if the USART LIN Break Detection Interrupt is enabled or disabled. * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not * LIN feature is supported by the USARTx instance. * @rmtoll CR2 LBDIE LL_USART_IsEnabledIT_LBD * @param USARTx USART Instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_LBD(USART_TypeDef *USARTx) { return (READ_BIT(USARTx->CR2, USART_CR2_LBDIE) == (USART_CR2_LBDIE)); } /** * @brief Check if the USART Error Interrupt is enabled or disabled. * @rmtoll CR3 EIE LL_USART_IsEnabledIT_ERROR * @param USARTx USART Instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_ERROR(USART_TypeDef *USARTx) { return (READ_BIT(USARTx->CR3, USART_CR3_EIE) == (USART_CR3_EIE)); } /** * @brief Check if the USART CTS Interrupt is enabled or disabled. * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not * Hardware Flow control feature is supported by the USARTx instance. * @rmtoll CR3 CTSIE LL_USART_IsEnabledIT_CTS * @param USARTx USART Instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_CTS(USART_TypeDef *USARTx) { return (READ_BIT(USARTx->CR3, USART_CR3_CTSIE) == (USART_CR3_CTSIE)); } /** * @} */ /** @defgroup USART_LL_EF_DMA_Management DMA_Management * @{ */ /** * @brief Enable DMA Mode for reception * @rmtoll CR3 DMAR LL_USART_EnableDMAReq_RX * @param USARTx USART Instance * @retval None */ __STATIC_INLINE void LL_USART_EnableDMAReq_RX(USART_TypeDef *USARTx) { SET_BIT(USARTx->CR3, USART_CR3_DMAR); } /** * @brief Disable DMA Mode for reception * @rmtoll CR3 DMAR LL_USART_DisableDMAReq_RX * @param USARTx USART Instance * @retval None */ __STATIC_INLINE void LL_USART_DisableDMAReq_RX(USART_TypeDef *USARTx) { CLEAR_BIT(USARTx->CR3, USART_CR3_DMAR); } /** * @brief Check if DMA Mode is enabled for reception * @rmtoll CR3 DMAR LL_USART_IsEnabledDMAReq_RX * @param USARTx USART Instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_USART_IsEnabledDMAReq_RX(USART_TypeDef *USARTx) { return (READ_BIT(USARTx->CR3, USART_CR3_DMAR) == (USART_CR3_DMAR)); } /** * @brief Enable DMA Mode for transmission * @rmtoll CR3 DMAT LL_USART_EnableDMAReq_TX * @param USARTx USART Instance * @retval None */ __STATIC_INLINE void LL_USART_EnableDMAReq_TX(USART_TypeDef *USARTx) { SET_BIT(USARTx->CR3, USART_CR3_DMAT); } /** * @brief Disable DMA Mode for transmission * @rmtoll CR3 DMAT LL_USART_DisableDMAReq_TX * @param USARTx USART Instance * @retval None */ __STATIC_INLINE void LL_USART_DisableDMAReq_TX(USART_TypeDef *USARTx) { CLEAR_BIT(USARTx->CR3, USART_CR3_DMAT); } /** * @brief Check if DMA Mode is enabled for transmission * @rmtoll CR3 DMAT LL_USART_IsEnabledDMAReq_TX * @param USARTx USART Instance * @retval State of bit (1 or 0). */ __STATIC_INLINE uint32_t LL_USART_IsEnabledDMAReq_TX(USART_TypeDef *USARTx) { return (READ_BIT(USARTx->CR3, USART_CR3_DMAT) == (USART_CR3_DMAT)); } /** * @brief Get the data register address used for DMA transfer * @rmtoll DR DR LL_USART_DMA_GetRegAddr * @note Address of Data Register is valid for both Transmit and Receive transfers. * @param USARTx USART Instance * @retval Address of data register */ __STATIC_INLINE uint32_t LL_USART_DMA_GetRegAddr(USART_TypeDef *USARTx) { /* return address of DR register */ return ((uint32_t) &(USARTx->DR)); } /** * @} */ /** @defgroup USART_LL_EF_Data_Management Data_Management * @{ */ /** * @brief Read Receiver Data register (Receive Data value, 8 bits) * @rmtoll DR DR LL_USART_ReceiveData8 * @param USARTx USART Instance * @retval Value between Min_Data=0x00 and Max_Data=0xFF */ __STATIC_INLINE uint8_t LL_USART_ReceiveData8(USART_TypeDef *USARTx) { return (uint8_t)(READ_BIT(USARTx->DR, USART_DR_DR)); } /** * @brief Read Receiver Data register (Receive Data value, 9 bits) * @rmtoll DR DR LL_USART_ReceiveData9 * @param USARTx USART Instance * @retval Value between Min_Data=0x00 and Max_Data=0x1FF */ __STATIC_INLINE uint16_t LL_USART_ReceiveData9(USART_TypeDef *USARTx) { return (uint16_t)(READ_BIT(USARTx->DR, USART_DR_DR)); } /** * @brief Write in Transmitter Data Register (Transmit Data value, 8 bits) * @rmtoll DR DR LL_USART_TransmitData8 * @param USARTx USART Instance * @param Value between Min_Data=0x00 and Max_Data=0xFF * @retval None */ __STATIC_INLINE void LL_USART_TransmitData8(USART_TypeDef *USARTx, uint8_t Value) { USARTx->DR = Value; } /** * @brief Write in Transmitter Data Register (Transmit Data value, 9 bits) * @rmtoll DR DR LL_USART_TransmitData9 * @param USARTx USART Instance * @param Value between Min_Data=0x00 and Max_Data=0x1FF * @retval None */ __STATIC_INLINE void LL_USART_TransmitData9(USART_TypeDef *USARTx, uint16_t Value) { USARTx->DR = Value & 0x1FFU; } /** * @} */ /** @defgroup USART_LL_EF_Execution Execution * @{ */ /** * @brief Request Break sending * @rmtoll CR1 SBK LL_USART_RequestBreakSending * @param USARTx USART Instance * @retval None */ __STATIC_INLINE void LL_USART_RequestBreakSending(USART_TypeDef *USARTx) { SET_BIT(USARTx->CR1, USART_CR1_SBK); } /** * @brief Put USART in Mute mode * @rmtoll CR1 RWU LL_USART_RequestEnterMuteMode * @param USARTx USART Instance * @retval None */ __STATIC_INLINE void LL_USART_RequestEnterMuteMode(USART_TypeDef *USARTx) { SET_BIT(USARTx->CR1, USART_CR1_RWU); } /** * @brief Put USART in Active mode * @rmtoll CR1 RWU LL_USART_RequestExitMuteMode * @param USARTx USART Instance * @retval None */ __STATIC_INLINE void LL_USART_RequestExitMuteMode(USART_TypeDef *USARTx) { CLEAR_BIT(USARTx->CR1, USART_CR1_RWU); } /** * @} */ #if defined(USE_FULL_LL_DRIVER) /** @defgroup USART_LL_EF_Init Initialization and de-initialization functions * @{ */ ErrorStatus LL_USART_DeInit(USART_TypeDef *USARTx); ErrorStatus LL_USART_Init(USART_TypeDef *USARTx, LL_USART_InitTypeDef *USART_InitStruct); void LL_USART_StructInit(LL_USART_InitTypeDef *USART_InitStruct); ErrorStatus LL_USART_ClockInit(USART_TypeDef *USARTx, LL_USART_ClockInitTypeDef *USART_ClockInitStruct); void LL_USART_ClockStructInit(LL_USART_ClockInitTypeDef *USART_ClockInitStruct); /** * @} */ #endif /* USE_FULL_LL_DRIVER */ /** * @} */ /** * @} */ #endif /* USART1 || USART2 || USART3 || USART6 || UART4 || UART5 || UART7 || UART8 || UART9 || UART10 */ /** * @} */ #ifdef __cplusplus } #endif #endif /* __STM32F4xx_LL_USART_H */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ ================================================ FILE: sys/arch/stm32/hal/stm32f4xx_ll_utils.c ================================================ /** ****************************************************************************** * @file stm32f4xx_ll_utils.c * @author MCD Application Team * @version V1.7.1 * @date 14-April-2017 * @brief UTILS LL module driver. ****************************************************************************** * @attention * *

© COPYRIGHT(c) 2017 STMicroelectronics

* * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. Neither the name of STMicroelectronics nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ /* Includes ------------------------------------------------------------------*/ #include "stm32f4xx_ll_utils.h" #include "stm32f4xx_ll_rcc.h" #include "stm32f4xx_ll_system.h" #include "stm32f4xx_ll_pwr.h" #ifdef USE_FULL_ASSERT #include "stm32_assert.h" #else #define assert_param(expr) ((void)0U) #endif /* USE_FULL_ASSERT */ /** @addtogroup STM32F4xx_LL_Driver * @{ */ /** @addtogroup UTILS_LL * @{ */ /* Private types -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ /* Private constants ---------------------------------------------------------*/ /** @addtogroup UTILS_LL_Private_Constants * @{ */ #if defined(RCC_MAX_FREQUENCY_SCALE1) #define UTILS_MAX_FREQUENCY_SCALE1 RCC_MAX_FREQUENCY /*!< Maximum frequency for system clock at power scale1, in Hz */ #endif /*RCC_MAX_FREQUENCY_SCALE1 */ #define UTILS_MAX_FREQUENCY_SCALE2 RCC_MAX_FREQUENCY_SCALE2 /*!< Maximum frequency for system clock at power scale2, in Hz */ #if defined(RCC_MAX_FREQUENCY_SCALE3) #define UTILS_MAX_FREQUENCY_SCALE3 RCC_MAX_FREQUENCY_SCALE3 /*!< Maximum frequency for system clock at power scale3, in Hz */ #endif /* MAX_FREQUENCY_SCALE3 */ /* Defines used for PLL range */ #define UTILS_PLLVCO_INPUT_MIN RCC_PLLVCO_INPUT_MIN /*!< Frequency min for PLLVCO input, in Hz */ #define UTILS_PLLVCO_INPUT_MAX RCC_PLLVCO_INPUT_MAX /*!< Frequency max for PLLVCO input, in Hz */ #define UTILS_PLLVCO_OUTPUT_MIN RCC_PLLVCO_OUTPUT_MIN /*!< Frequency min for PLLVCO output, in Hz */ #define UTILS_PLLVCO_OUTPUT_MAX RCC_PLLVCO_OUTPUT_MAX /*!< Frequency max for PLLVCO output, in Hz */ /* Defines used for HSE range */ #define UTILS_HSE_FREQUENCY_MIN 4000000U /*!< Frequency min for HSE frequency, in Hz */ #define UTILS_HSE_FREQUENCY_MAX 26000000U /*!< Frequency max for HSE frequency, in Hz */ /* Defines used for FLASH latency according to HCLK Frequency */ #if defined(FLASH_SCALE1_LATENCY1_FREQ) #define UTILS_SCALE1_LATENCY1_FREQ FLASH_SCALE1_LATENCY1_FREQ /*!< HCLK frequency to set FLASH latency 1 in power scale 1 */ #endif #if defined(FLASH_SCALE1_LATENCY2_FREQ) #define UTILS_SCALE1_LATENCY2_FREQ FLASH_SCALE1_LATENCY2_FREQ /*!< HCLK frequency to set FLASH latency 2 in power scale 1 */ #endif #if defined(FLASH_SCALE1_LATENCY3_FREQ) #define UTILS_SCALE1_LATENCY3_FREQ FLASH_SCALE1_LATENCY3_FREQ /*!< HCLK frequency to set FLASH latency 3 in power scale 1 */ #endif #if defined(FLASH_SCALE1_LATENCY4_FREQ) #define UTILS_SCALE1_LATENCY4_FREQ FLASH_SCALE1_LATENCY4_FREQ /*!< HCLK frequency to set FLASH latency 4 in power scale 1 */ #endif #if defined(FLASH_SCALE1_LATENCY5_FREQ) #define UTILS_SCALE1_LATENCY5_FREQ FLASH_SCALE1_LATENCY5_FREQ /*!< HCLK frequency to set FLASH latency 5 in power scale 1 */ #endif #define UTILS_SCALE2_LATENCY1_FREQ FLASH_SCALE2_LATENCY1_FREQ /*!< HCLK frequency to set FLASH latency 1 in power scale 2 */ #define UTILS_SCALE2_LATENCY2_FREQ FLASH_SCALE2_LATENCY2_FREQ /*!< HCLK frequency to set FLASH latency 2 in power scale 2 */ #if defined(FLASH_SCALE2_LATENCY3_FREQ) #define UTILS_SCALE2_LATENCY3_FREQ FLASH_SCALE2_LATENCY3_FREQ /*!< HCLK frequency to set FLASH latency 2 in power scale 2 */ #endif #if defined(FLASH_SCALE2_LATENCY4_FREQ) #define UTILS_SCALE2_LATENCY4_FREQ FLASH_SCALE2_LATENCY4_FREQ /*!< HCLK frequency to set FLASH latency 4 in power scale 2 */ #endif #if defined(FLASH_SCALE2_LATENCY5_FREQ) #define UTILS_SCALE2_LATENCY5_FREQ FLASH_SCALE2_LATENCY5_FREQ /*!< HCLK frequency to set FLASH latency 5 in power scale 2 */ #endif #if defined(FLASH_SCALE3_LATENCY1_FREQ) #define UTILS_SCALE3_LATENCY1_FREQ FLASH_SCALE3_LATENCY1_FREQ /*!< HCLK frequency to set FLASH latency 1 in power scale 3 */ #endif #if defined(FLASH_SCALE3_LATENCY2_FREQ) #define UTILS_SCALE3_LATENCY2_FREQ FLASH_SCALE3_LATENCY2_FREQ /*!< HCLK frequency to set FLASH latency 2 in power scale 3 */ #endif #if defined(FLASH_SCALE3_LATENCY3_FREQ) #define UTILS_SCALE3_LATENCY3_FREQ FLASH_SCALE3_LATENCY3_FREQ /*!< HCLK frequency to set FLASH latency 3 in power scale 3 */ #endif #if defined(FLASH_SCALE3_LATENCY4_FREQ) #define UTILS_SCALE3_LATENCY4_FREQ FLASH_SCALE3_LATENCY4_FREQ /*!< HCLK frequency to set FLASH latency 4 in power scale 3 */ #endif #if defined(FLASH_SCALE3_LATENCY5_FREQ) #define UTILS_SCALE3_LATENCY5_FREQ FLASH_SCALE3_LATENCY5_FREQ /*!< HCLK frequency to set FLASH latency 5 in power scale 3 */ #endif /** * @} */ /* Private macros ------------------------------------------------------------*/ /** @addtogroup UTILS_LL_Private_Macros * @{ */ #define IS_LL_UTILS_SYSCLK_DIV(__VALUE__) (((__VALUE__) == LL_RCC_SYSCLK_DIV_1) \ || ((__VALUE__) == LL_RCC_SYSCLK_DIV_2) \ || ((__VALUE__) == LL_RCC_SYSCLK_DIV_4) \ || ((__VALUE__) == LL_RCC_SYSCLK_DIV_8) \ || ((__VALUE__) == LL_RCC_SYSCLK_DIV_16) \ || ((__VALUE__) == LL_RCC_SYSCLK_DIV_64) \ || ((__VALUE__) == LL_RCC_SYSCLK_DIV_128) \ || ((__VALUE__) == LL_RCC_SYSCLK_DIV_256) \ || ((__VALUE__) == LL_RCC_SYSCLK_DIV_512)) #define IS_LL_UTILS_APB1_DIV(__VALUE__) (((__VALUE__) == LL_RCC_APB1_DIV_1) \ || ((__VALUE__) == LL_RCC_APB1_DIV_2) \ || ((__VALUE__) == LL_RCC_APB1_DIV_4) \ || ((__VALUE__) == LL_RCC_APB1_DIV_8) \ || ((__VALUE__) == LL_RCC_APB1_DIV_16)) #define IS_LL_UTILS_APB2_DIV(__VALUE__) (((__VALUE__) == LL_RCC_APB2_DIV_1) \ || ((__VALUE__) == LL_RCC_APB2_DIV_2) \ || ((__VALUE__) == LL_RCC_APB2_DIV_4) \ || ((__VALUE__) == LL_RCC_APB2_DIV_8) \ || ((__VALUE__) == LL_RCC_APB2_DIV_16)) #define IS_LL_UTILS_PLLM_VALUE(__VALUE__) (((__VALUE__) == LL_RCC_PLLM_DIV_2) \ || ((__VALUE__) == LL_RCC_PLLM_DIV_3) \ || ((__VALUE__) == LL_RCC_PLLM_DIV_4) \ || ((__VALUE__) == LL_RCC_PLLM_DIV_5) \ || ((__VALUE__) == LL_RCC_PLLM_DIV_6) \ || ((__VALUE__) == LL_RCC_PLLM_DIV_7) \ || ((__VALUE__) == LL_RCC_PLLM_DIV_8) \ || ((__VALUE__) == LL_RCC_PLLM_DIV_9) \ || ((__VALUE__) == LL_RCC_PLLM_DIV_10) \ || ((__VALUE__) == LL_RCC_PLLM_DIV_11) \ || ((__VALUE__) == LL_RCC_PLLM_DIV_12) \ || ((__VALUE__) == LL_RCC_PLLM_DIV_13) \ || ((__VALUE__) == LL_RCC_PLLM_DIV_14) \ || ((__VALUE__) == LL_RCC_PLLM_DIV_15) \ || ((__VALUE__) == LL_RCC_PLLM_DIV_16) \ || ((__VALUE__) == LL_RCC_PLLM_DIV_17) \ || ((__VALUE__) == LL_RCC_PLLM_DIV_18) \ || ((__VALUE__) == LL_RCC_PLLM_DIV_19) \ || ((__VALUE__) == LL_RCC_PLLM_DIV_20) \ || ((__VALUE__) == LL_RCC_PLLM_DIV_21) \ || ((__VALUE__) == LL_RCC_PLLM_DIV_22) \ || ((__VALUE__) == LL_RCC_PLLM_DIV_23) \ || ((__VALUE__) == LL_RCC_PLLM_DIV_24) \ || ((__VALUE__) == LL_RCC_PLLM_DIV_25) \ || ((__VALUE__) == LL_RCC_PLLM_DIV_26) \ || ((__VALUE__) == LL_RCC_PLLM_DIV_27) \ || ((__VALUE__) == LL_RCC_PLLM_DIV_28) \ || ((__VALUE__) == LL_RCC_PLLM_DIV_29) \ || ((__VALUE__) == LL_RCC_PLLM_DIV_30) \ || ((__VALUE__) == LL_RCC_PLLM_DIV_31) \ || ((__VALUE__) == LL_RCC_PLLM_DIV_32) \ || ((__VALUE__) == LL_RCC_PLLM_DIV_33) \ || ((__VALUE__) == LL_RCC_PLLM_DIV_34) \ || ((__VALUE__) == LL_RCC_PLLM_DIV_35) \ || ((__VALUE__) == LL_RCC_PLLM_DIV_36) \ || ((__VALUE__) == LL_RCC_PLLM_DIV_37) \ || ((__VALUE__) == LL_RCC_PLLM_DIV_38) \ || ((__VALUE__) == LL_RCC_PLLM_DIV_39) \ || ((__VALUE__) == LL_RCC_PLLM_DIV_40) \ || ((__VALUE__) == LL_RCC_PLLM_DIV_41) \ || ((__VALUE__) == LL_RCC_PLLM_DIV_42) \ || ((__VALUE__) == LL_RCC_PLLM_DIV_43) \ || ((__VALUE__) == LL_RCC_PLLM_DIV_44) \ || ((__VALUE__) == LL_RCC_PLLM_DIV_45) \ || ((__VALUE__) == LL_RCC_PLLM_DIV_46) \ || ((__VALUE__) == LL_RCC_PLLM_DIV_47) \ || ((__VALUE__) == LL_RCC_PLLM_DIV_48) \ || ((__VALUE__) == LL_RCC_PLLM_DIV_49) \ || ((__VALUE__) == LL_RCC_PLLM_DIV_50) \ || ((__VALUE__) == LL_RCC_PLLM_DIV_51) \ || ((__VALUE__) == LL_RCC_PLLM_DIV_52) \ || ((__VALUE__) == LL_RCC_PLLM_DIV_53) \ || ((__VALUE__) == LL_RCC_PLLM_DIV_54) \ || ((__VALUE__) == LL_RCC_PLLM_DIV_55) \ || ((__VALUE__) == LL_RCC_PLLM_DIV_56) \ || ((__VALUE__) == LL_RCC_PLLM_DIV_57) \ || ((__VALUE__) == LL_RCC_PLLM_DIV_58) \ || ((__VALUE__) == LL_RCC_PLLM_DIV_59) \ || ((__VALUE__) == LL_RCC_PLLM_DIV_60) \ || ((__VALUE__) == LL_RCC_PLLM_DIV_61) \ || ((__VALUE__) == LL_RCC_PLLM_DIV_62) \ || ((__VALUE__) == LL_RCC_PLLM_DIV_63)) #define IS_LL_UTILS_PLLN_VALUE(__VALUE__) ((RCC_PLLN_MIN_VALUE <= (__VALUE__)) && ((__VALUE__) <= RCC_PLLN_MAX_VALUE)) #define IS_LL_UTILS_PLLP_VALUE(__VALUE__) (((__VALUE__) == LL_RCC_PLLP_DIV_2) \ || ((__VALUE__) == LL_RCC_PLLP_DIV_4) \ || ((__VALUE__) == LL_RCC_PLLP_DIV_6) \ || ((__VALUE__) == LL_RCC_PLLP_DIV_8)) #define IS_LL_UTILS_PLLVCO_INPUT(__VALUE__) ((UTILS_PLLVCO_INPUT_MIN <= (__VALUE__)) && ((__VALUE__) <= UTILS_PLLVCO_INPUT_MAX)) #define IS_LL_UTILS_PLLVCO_OUTPUT(__VALUE__) ((UTILS_PLLVCO_OUTPUT_MIN <= (__VALUE__)) && ((__VALUE__) <= UTILS_PLLVCO_OUTPUT_MAX)) #if !defined(RCC_MAX_FREQUENCY_SCALE1) #define IS_LL_UTILS_PLL_FREQUENCY(__VALUE__) ((LL_PWR_GetRegulVoltageScaling() == LL_PWR_REGU_VOLTAGE_SCALE2) ? ((__VALUE__) <= UTILS_MAX_FREQUENCY_SCALE2) : \ ((__VALUE__) <= UTILS_MAX_FREQUENCY_SCALE3)) #elif defined(RCC_MAX_FREQUENCY_SCALE3) #define IS_LL_UTILS_PLL_FREQUENCY(__VALUE__) ((LL_PWR_GetRegulVoltageScaling() == LL_PWR_REGU_VOLTAGE_SCALE1) ? ((__VALUE__) <= UTILS_MAX_FREQUENCY_SCALE1) : \ (LL_PWR_GetRegulVoltageScaling() == LL_PWR_REGU_VOLTAGE_SCALE2) ? ((__VALUE__) <= UTILS_MAX_FREQUENCY_SCALE2) : \ ((__VALUE__) <= UTILS_MAX_FREQUENCY_SCALE3)) #else #define IS_LL_UTILS_PLL_FREQUENCY(__VALUE__) ((LL_PWR_GetRegulVoltageScaling() == LL_PWR_REGU_VOLTAGE_SCALE1) ? ((__VALUE__) <= UTILS_MAX_FREQUENCY_SCALE1) : \ ((__VALUE__) <= UTILS_MAX_FREQUENCY_SCALE2)) #endif /* RCC_MAX_FREQUENCY_SCALE1*/ #define IS_LL_UTILS_HSE_BYPASS(__STATE__) (((__STATE__) == LL_UTILS_HSEBYPASS_ON) \ || ((__STATE__) == LL_UTILS_HSEBYPASS_OFF)) #define IS_LL_UTILS_HSE_FREQUENCY(__FREQUENCY__) (((__FREQUENCY__) >= UTILS_HSE_FREQUENCY_MIN) && ((__FREQUENCY__) <= UTILS_HSE_FREQUENCY_MAX)) /** * @} */ /* Private function prototypes -----------------------------------------------*/ /** @defgroup UTILS_LL_Private_Functions UTILS Private functions * @{ */ static uint32_t UTILS_GetPLLOutputFrequency(uint32_t PLL_InputFrequency, LL_UTILS_PLLInitTypeDef *UTILS_PLLInitStruct); static ErrorStatus UTILS_SetFlashLatency(uint32_t HCLK_Frequency); static ErrorStatus UTILS_EnablePLLAndSwitchSystem(uint32_t SYSCLK_Frequency, LL_UTILS_ClkInitTypeDef *UTILS_ClkInitStruct); static ErrorStatus UTILS_PLL_IsBusy(void); /** * @} */ /* Exported functions --------------------------------------------------------*/ /** @addtogroup UTILS_LL_Exported_Functions * @{ */ /** @addtogroup UTILS_LL_EF_DELAY * @{ */ /** * @brief This function configures the Cortex-M SysTick source to have 1ms time base. * @note When a RTOS is used, it is recommended to avoid changing the Systick * configuration by calling this function, for a delay use rather osDelay RTOS service. * @param HCLKFrequency HCLK frequency in Hz * @note HCLK frequency can be calculated thanks to RCC helper macro or function @ref LL_RCC_GetSystemClocksFreq * @retval None */ void LL_Init1msTick(uint32_t HCLKFrequency) { /* Use frequency provided in argument */ LL_InitTick(HCLKFrequency, 1000U); } /** * @brief This function provides accurate delay (in milliseconds) based * on SysTick counter flag * @note When a RTOS is used, it is recommended to avoid using blocking delay * and use rather osDelay service. * @note To respect 1ms timebase, user should call @ref LL_Init1msTick function which * will configure Systick to 1ms * @param Delay specifies the delay time length, in milliseconds. * @retval None */ void LL_mDelay(uint32_t Delay) { __IO uint32_t tmp = SysTick->CTRL; /* Clear the COUNTFLAG first */ /* Add this code to indicate that local variable is not used */ ((void)tmp); /* Add a period to guaranty minimum wait */ if(Delay < LL_MAX_DELAY) { Delay++; } while (Delay) { if((SysTick->CTRL & SysTick_CTRL_COUNTFLAG_Msk) != 0U) { Delay--; } } } /** * @} */ /** @addtogroup UTILS_EF_SYSTEM * @brief System Configuration functions * @verbatim =============================================================================== ##### System Configuration functions ##### =============================================================================== [..] System, AHB and APB buses clocks configuration (+) The maximum frequency of the SYSCLK, HCLK, PCLK1 and PCLK2 is 180000000 Hz. @endverbatim @internal Depending on the device voltage range, the maximum frequency should be adapted accordingly to the Refenece manual. @endinternal * @{ */ /** * @brief This function sets directly SystemCoreClock CMSIS variable. * @note Variable can be calculated also through SystemCoreClockUpdate function. * @param HCLKFrequency HCLK frequency in Hz (can be calculated thanks to RCC helper macro) * @retval None */ void LL_SetSystemCoreClock(uint32_t HCLKFrequency) { /* HCLK clock frequency */ SystemCoreClock = HCLKFrequency; } /** * @brief This function configures system clock at maximum frequency with HSI as clock source of the PLL * @note The application need to ensure that PLL is disabled. * @note Function is based on the following formula: * - PLL output frequency = (((HSI frequency / PLLM) * PLLN) / PLLP) * - PLLM: ensure that the VCO input frequency ranges from @ref RCC_PLLVCO_INPUT_MIN to @ref RCC_PLLVCO_INPUT_MAX (PLLVCO_input = HSI frequency / PLLM) * - PLLN: ensure that the VCO output frequency is between @ref RCC_PLLVCO_OUTPUT_MIN and @ref RCC_PLLVCO_OUTPUT_MAX (PLLVCO_output = PLLVCO_input * PLLN) * - PLLP: ensure that max frequency at 180000000 Hz is reach (PLLVCO_output / PLLP) * @param UTILS_PLLInitStruct pointer to a @ref LL_UTILS_PLLInitTypeDef structure that contains * the configuration information for the PLL. * @param UTILS_ClkInitStruct pointer to a @ref LL_UTILS_ClkInitTypeDef structure that contains * the configuration information for the BUS prescalers. * @retval An ErrorStatus enumeration value: * - SUCCESS: Max frequency configuration done * - ERROR: Max frequency configuration not done */ ErrorStatus LL_PLL_ConfigSystemClock_HSI(LL_UTILS_PLLInitTypeDef *UTILS_PLLInitStruct, LL_UTILS_ClkInitTypeDef *UTILS_ClkInitStruct) { ErrorStatus status = SUCCESS; uint32_t pllfreq = 0U; /* Check if one of the PLL is enabled */ if(UTILS_PLL_IsBusy() == SUCCESS) { /* Calculate the new PLL output frequency */ pllfreq = UTILS_GetPLLOutputFrequency(HSI_VALUE, UTILS_PLLInitStruct); /* Enable HSI if not enabled */ if(LL_RCC_HSI_IsReady() != 1U) { LL_RCC_HSI_Enable(); while (LL_RCC_HSI_IsReady() != 1U) { /* Wait for HSI ready */ } } /* Configure PLL */ LL_RCC_PLL_ConfigDomain_SYS(LL_RCC_PLLSOURCE_HSI, UTILS_PLLInitStruct->PLLM, UTILS_PLLInitStruct->PLLN, UTILS_PLLInitStruct->PLLP); /* Enable PLL and switch system clock to PLL */ status = UTILS_EnablePLLAndSwitchSystem(pllfreq, UTILS_ClkInitStruct); } else { /* Current PLL configuration cannot be modified */ status = ERROR; } return status; } /** * @brief This function configures system clock with HSE as clock source of the PLL * @note The application need to ensure that PLL is disabled. * - PLL output frequency = (((HSI frequency / PLLM) * PLLN) / PLLP) * - PLLM: ensure that the VCO input frequency ranges from @ref RCC_PLLVCO_INPUT_MIN to @ref RCC_PLLVCO_INPUT_MAX (PLLVCO_input = HSI frequency / PLLM) * - PLLN: ensure that the VCO output frequency is between @ref RCC_PLLVCO_OUTPUT_MIN and @ref RCC_PLLVCO_OUTPUT_MAX (PLLVCO_output = PLLVCO_input * PLLN) * - PLLP: ensure that max frequency at 180000000 Hz is reach (PLLVCO_output / PLLP) * @param HSEFrequency Value between Min_Data = 4000000 and Max_Data = 26000000 * @param HSEBypass This parameter can be one of the following values: * @arg @ref LL_UTILS_HSEBYPASS_ON * @arg @ref LL_UTILS_HSEBYPASS_OFF * @param UTILS_PLLInitStruct pointer to a @ref LL_UTILS_PLLInitTypeDef structure that contains * the configuration information for the PLL. * @param UTILS_ClkInitStruct pointer to a @ref LL_UTILS_ClkInitTypeDef structure that contains * the configuration information for the BUS prescalers. * @retval An ErrorStatus enumeration value: * - SUCCESS: Max frequency configuration done * - ERROR: Max frequency configuration not done */ ErrorStatus LL_PLL_ConfigSystemClock_HSE(uint32_t HSEFrequency, uint32_t HSEBypass, LL_UTILS_PLLInitTypeDef *UTILS_PLLInitStruct, LL_UTILS_ClkInitTypeDef *UTILS_ClkInitStruct) { ErrorStatus status = SUCCESS; uint32_t pllfreq = 0U; /* Check the parameters */ assert_param(IS_LL_UTILS_HSE_FREQUENCY(HSEFrequency)); assert_param(IS_LL_UTILS_HSE_BYPASS(HSEBypass)); /* Check if one of the PLL is enabled */ if(UTILS_PLL_IsBusy() == SUCCESS) { /* Calculate the new PLL output frequency */ pllfreq = UTILS_GetPLLOutputFrequency(HSEFrequency, UTILS_PLLInitStruct); /* Enable HSE if not enabled */ if(LL_RCC_HSE_IsReady() != 1U) { /* Check if need to enable HSE bypass feature or not */ if(HSEBypass == LL_UTILS_HSEBYPASS_ON) { LL_RCC_HSE_EnableBypass(); } else { LL_RCC_HSE_DisableBypass(); } /* Enable HSE */ LL_RCC_HSE_Enable(); while (LL_RCC_HSE_IsReady() != 1U) { /* Wait for HSE ready */ } } /* Configure PLL */ LL_RCC_PLL_ConfigDomain_SYS(LL_RCC_PLLSOURCE_HSE, UTILS_PLLInitStruct->PLLM, UTILS_PLLInitStruct->PLLN, UTILS_PLLInitStruct->PLLP); /* Enable PLL and switch system clock to PLL */ status = UTILS_EnablePLLAndSwitchSystem(pllfreq, UTILS_ClkInitStruct); } else { /* Current PLL configuration cannot be modified */ status = ERROR; } return status; } /** * @} */ /** * @} */ /** @addtogroup UTILS_LL_Private_Functions * @{ */ /** * @brief Update number of Flash wait states in line with new frequency and current voltage range. * @note This Function support ONLY devices with supply voltage (voltage range) between 2.7V and 3.6V * @param HCLK_Frequency HCLK frequency * @retval An ErrorStatus enumeration value: * - SUCCESS: Latency has been modified * - ERROR: Latency cannot be modified */ static ErrorStatus UTILS_SetFlashLatency(uint32_t HCLK_Frequency) { ErrorStatus status = SUCCESS; uint32_t latency = LL_FLASH_LATENCY_0; /* default value 0WS */ /* Frequency cannot be equal to 0 */ if(HCLK_Frequency == 0U) { status = ERROR; } else { if(LL_PWR_GetRegulVoltageScaling() == LL_PWR_REGU_VOLTAGE_SCALE1) { #if defined (UTILS_SCALE1_LATENCY5_FREQ) if((HCLK_Frequency > UTILS_SCALE1_LATENCY5_FREQ)&&(latency == LL_FLASH_LATENCY_0)) { latency = LL_FLASH_LATENCY_5; } #endif /*UTILS_SCALE1_LATENCY5_FREQ */ #if defined (UTILS_SCALE1_LATENCY4_FREQ) if((HCLK_Frequency > UTILS_SCALE1_LATENCY4_FREQ)&&(latency == LL_FLASH_LATENCY_0)) { latency = LL_FLASH_LATENCY_4; } #endif /* UTILS_SCALE1_LATENCY4_FREQ */ #if defined (UTILS_SCALE1_LATENCY3_FREQ) if((HCLK_Frequency > UTILS_SCALE1_LATENCY3_FREQ)&&(latency == LL_FLASH_LATENCY_0)) { latency = LL_FLASH_LATENCY_3; } #endif /* UTILS_SCALE1_LATENCY3_FREQ */ #if defined (UTILS_SCALE1_LATENCY2_FREQ) if((HCLK_Frequency > UTILS_SCALE1_LATENCY2_FREQ)&&(latency == LL_FLASH_LATENCY_0)) { latency = LL_FLASH_LATENCY_2; } else { if((HCLK_Frequency > UTILS_SCALE1_LATENCY1_FREQ)&&(latency == LL_FLASH_LATENCY_0)) { latency = LL_FLASH_LATENCY_1; } } #endif /* UTILS_SCALE1_LATENCY2_FREQ */ } if(LL_PWR_GetRegulVoltageScaling() == LL_PWR_REGU_VOLTAGE_SCALE2) { #if defined (UTILS_SCALE2_LATENCY5_FREQ) if((HCLK_Frequency > UTILS_SCALE2_LATENCY5_FREQ)&&(latency == LL_FLASH_LATENCY_0)) { latency = LL_FLASH_LATENCY_5; } #endif /*UTILS_SCALE1_LATENCY5_FREQ */ #if defined (UTILS_SCALE2_LATENCY4_FREQ) if((HCLK_Frequency > UTILS_SCALE2_LATENCY4_FREQ)&&(latency == LL_FLASH_LATENCY_0)) { latency = LL_FLASH_LATENCY_4; } #endif /*UTILS_SCALE1_LATENCY4_FREQ */ #if defined (UTILS_SCALE2_LATENCY3_FREQ) if((HCLK_Frequency > UTILS_SCALE2_LATENCY3_FREQ)&&(latency == LL_FLASH_LATENCY_0)) { latency = LL_FLASH_LATENCY_3; } #endif /*UTILS_SCALE1_LATENCY3_FREQ */ if((HCLK_Frequency > UTILS_SCALE2_LATENCY2_FREQ)&&(latency == LL_FLASH_LATENCY_0)) { latency = LL_FLASH_LATENCY_2; } else { if((HCLK_Frequency > UTILS_SCALE2_LATENCY1_FREQ)&&(latency == LL_FLASH_LATENCY_0)) { latency = LL_FLASH_LATENCY_1; } } } #if defined (LL_PWR_REGU_VOLTAGE_SCALE3) if(LL_PWR_GetRegulVoltageScaling() == LL_PWR_REGU_VOLTAGE_SCALE3) { #if defined (UTILS_SCALE3_LATENCY3_FREQ) if((HCLK_Frequency > UTILS_SCALE3_LATENCY3_FREQ)&&(latency == LL_FLASH_LATENCY_0)) { latency = LL_FLASH_LATENCY_3; } #endif /*UTILS_SCALE1_LATENCY3_FREQ */ #if defined (UTILS_SCALE3_LATENCY2_FREQ) if((HCLK_Frequency > UTILS_SCALE3_LATENCY2_FREQ)&&(latency == LL_FLASH_LATENCY_0)) { latency = LL_FLASH_LATENCY_2; } else { if((HCLK_Frequency > UTILS_SCALE3_LATENCY1_FREQ)&&(latency == LL_FLASH_LATENCY_0)) { latency = LL_FLASH_LATENCY_1; } } } #endif /*UTILS_SCALE1_LATENCY2_FREQ */ #endif /* LL_PWR_REGU_VOLTAGE_SCALE3 */ LL_FLASH_SetLatency(latency); /* Check that the new number of wait states is taken into account to access the Flash memory by reading the FLASH_ACR register */ if(LL_FLASH_GetLatency() != latency) { status = ERROR; } } return status; } /** * @brief Function to check that PLL can be modified * @param PLL_InputFrequency PLL input frequency (in Hz) * @param UTILS_PLLInitStruct pointer to a @ref LL_UTILS_PLLInitTypeDef structure that contains * the configuration information for the PLL. * @retval PLL output frequency (in Hz) */ static uint32_t UTILS_GetPLLOutputFrequency(uint32_t PLL_InputFrequency, LL_UTILS_PLLInitTypeDef *UTILS_PLLInitStruct) { uint32_t pllfreq = 0U; /* Check the parameters */ assert_param(IS_LL_UTILS_PLLM_VALUE(UTILS_PLLInitStruct->PLLM)); assert_param(IS_LL_UTILS_PLLN_VALUE(UTILS_PLLInitStruct->PLLN)); assert_param(IS_LL_UTILS_PLLP_VALUE(UTILS_PLLInitStruct->PLLP)); /* Check different PLL parameters according to RM */ /* - PLLM: ensure that the VCO input frequency ranges from @ref UTILS_PLLVCO_INPUT_MIN to @ref UTILS_PLLVCO_INPUT_MAX MHz. */ pllfreq = PLL_InputFrequency / (UTILS_PLLInitStruct->PLLM & (RCC_PLLCFGR_PLLM >> RCC_PLLCFGR_PLLM_Pos)); assert_param(IS_LL_UTILS_PLLVCO_INPUT(pllfreq)); /* - PLLN: ensure that the VCO output frequency is between @ref UTILS_PLLVCO_OUTPUT_MIN and @ref UTILS_PLLVCO_OUTPUT_MAX .*/ pllfreq = pllfreq * (UTILS_PLLInitStruct->PLLN & (RCC_PLLCFGR_PLLN >> RCC_PLLCFGR_PLLN_Pos)); assert_param(IS_LL_UTILS_PLLVCO_OUTPUT(pllfreq)); /* - PLLP: ensure that max frequency at @ref RCC_MAX_FREQUENCY Hz is reached */ pllfreq = pllfreq / (((UTILS_PLLInitStruct->PLLP >> RCC_PLLCFGR_PLLP_Pos) + 1) * 2); assert_param(IS_LL_UTILS_PLL_FREQUENCY(pllfreq)); return pllfreq; } /** * @brief Function to check that PLL can be modified * @retval An ErrorStatus enumeration value: * - SUCCESS: PLL modification can be done * - ERROR: PLL is busy */ static ErrorStatus UTILS_PLL_IsBusy(void) { ErrorStatus status = SUCCESS; /* Check if PLL is busy*/ if(LL_RCC_PLL_IsReady() != 0U) { /* PLL configuration cannot be modified */ status = ERROR; } #if defined(RCC_PLLSAI_SUPPORT) /* Check if PLLSAI is busy*/ if(LL_RCC_PLLSAI_IsReady() != 0U) { /* PLLSAI1 configuration cannot be modified */ status = ERROR; } #endif /*RCC_PLLSAI_SUPPORT*/ #if defined(RCC_PLLI2S_SUPPORT) /* Check if PLLI2S is busy*/ if(LL_RCC_PLLI2S_IsReady() != 0U) { /* PLLI2S configuration cannot be modified */ status = ERROR; } #endif /*RCC_PLLI2S_SUPPORT*/ return status; } /** * @brief Function to enable PLL and switch system clock to PLL * @param SYSCLK_Frequency SYSCLK frequency * @param UTILS_ClkInitStruct pointer to a @ref LL_UTILS_ClkInitTypeDef structure that contains * the configuration information for the BUS prescalers. * @retval An ErrorStatus enumeration value: * - SUCCESS: No problem to switch system to PLL * - ERROR: Problem to switch system to PLL */ static ErrorStatus UTILS_EnablePLLAndSwitchSystem(uint32_t SYSCLK_Frequency, LL_UTILS_ClkInitTypeDef *UTILS_ClkInitStruct) { ErrorStatus status = SUCCESS; uint32_t hclk_frequency = 0U; assert_param(IS_LL_UTILS_SYSCLK_DIV(UTILS_ClkInitStruct->AHBCLKDivider)); assert_param(IS_LL_UTILS_APB1_DIV(UTILS_ClkInitStruct->APB1CLKDivider)); assert_param(IS_LL_UTILS_APB2_DIV(UTILS_ClkInitStruct->APB2CLKDivider)); /* Calculate HCLK frequency */ hclk_frequency = __LL_RCC_CALC_HCLK_FREQ(SYSCLK_Frequency, UTILS_ClkInitStruct->AHBCLKDivider); /* Increasing the number of wait states because of higher CPU frequency */ if(SystemCoreClock < hclk_frequency) { /* Set FLASH latency to highest latency */ status = UTILS_SetFlashLatency(hclk_frequency); } /* Update system clock configuration */ if(status == SUCCESS) { /* Enable PLL */ LL_RCC_PLL_Enable(); while (LL_RCC_PLL_IsReady() != 1U) { /* Wait for PLL ready */ } /* Sysclk activation on the main PLL */ LL_RCC_SetAHBPrescaler(UTILS_ClkInitStruct->AHBCLKDivider); LL_RCC_SetSysClkSource(LL_RCC_SYS_CLKSOURCE_PLL); while (LL_RCC_GetSysClkSource() != LL_RCC_SYS_CLKSOURCE_STATUS_PLL) { /* Wait for system clock switch to PLL */ } /* Set APB1 & APB2 prescaler*/ LL_RCC_SetAPB1Prescaler(UTILS_ClkInitStruct->APB1CLKDivider); LL_RCC_SetAPB2Prescaler(UTILS_ClkInitStruct->APB2CLKDivider); } /* Decreasing the number of wait states because of lower CPU frequency */ if(SystemCoreClock > hclk_frequency) { /* Set FLASH latency to lowest latency */ status = UTILS_SetFlashLatency(hclk_frequency); } /* Update SystemCoreClock variable */ if(status == SUCCESS) { LL_SetSystemCoreClock(hclk_frequency); } return status; } /** * @} */ /** * @} */ /** * @} */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ ================================================ FILE: sys/arch/stm32/hal/stm32f4xx_ll_utils.h ================================================ /** ****************************************************************************** * @file stm32f4xx_ll_utils.h * @author MCD Application Team * @version V1.7.1 * @date 14-April-2017 * @brief Header file of UTILS LL module. @verbatim ============================================================================== ##### How to use this driver ##### ============================================================================== [..] The LL UTILS driver contains a set of generic APIs that can be used by user: (+) Device electronic signature (+) Timing functions (+) PLL configuration functions @endverbatim ****************************************************************************** * @attention * *

© COPYRIGHT(c) 2017 STMicroelectronics

* * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. Neither the name of STMicroelectronics nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __STM32F4xx_LL_UTILS_H #define __STM32F4xx_LL_UTILS_H #ifdef __cplusplus extern "C" { #endif /* Includes ------------------------------------------------------------------*/ #include "stm32f4xx.h" /** @addtogroup STM32F4xx_LL_Driver * @{ */ /** @defgroup UTILS_LL UTILS * @{ */ /* Private types -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ /* Private constants ---------------------------------------------------------*/ /** @defgroup UTILS_LL_Private_Constants UTILS Private Constants * @{ */ /* Max delay can be used in LL_mDelay */ #define LL_MAX_DELAY 0xFFFFFFFFU /** * @brief Unique device ID register base address */ #define UID_BASE_ADDRESS UID_BASE /** * @brief Flash size data register base address */ #define FLASHSIZE_BASE_ADDRESS FLASHSIZE_BASE /** * @brief Package data register base address */ #define PACKAGE_BASE_ADDRESS PACKAGE_BASE /** * @} */ /* Private macros ------------------------------------------------------------*/ /** @defgroup UTILS_LL_Private_Macros UTILS Private Macros * @{ */ /** * @} */ /* Exported types ------------------------------------------------------------*/ /** @defgroup UTILS_LL_ES_INIT UTILS Exported structures * @{ */ /** * @brief UTILS PLL structure definition */ typedef struct { uint32_t PLLM; /*!< Division factor for PLL VCO input clock. This parameter can be a value of @ref RCC_LL_EC_PLLM_DIV This feature can be modified afterwards using unitary function @ref LL_RCC_PLL_ConfigDomain_SYS(). */ uint32_t PLLN; /*!< Multiplication factor for PLL VCO output clock. This parameter must be a number between Min_Data = @ref RCC_PLLN_MIN_VALUE and Max_Data = @ref RCC_PLLN_MIN_VALUE This feature can be modified afterwards using unitary function @ref LL_RCC_PLL_ConfigDomain_SYS(). */ uint32_t PLLP; /*!< Division for the main system clock. This parameter can be a value of @ref RCC_LL_EC_PLLP_DIV This feature can be modified afterwards using unitary function @ref LL_RCC_PLL_ConfigDomain_SYS(). */ } LL_UTILS_PLLInitTypeDef; /** * @brief UTILS System, AHB and APB buses clock configuration structure definition */ typedef struct { uint32_t AHBCLKDivider; /*!< The AHB clock (HCLK) divider. This clock is derived from the system clock (SYSCLK). This parameter can be a value of @ref RCC_LL_EC_SYSCLK_DIV This feature can be modified afterwards using unitary function @ref LL_RCC_SetAHBPrescaler(). */ uint32_t APB1CLKDivider; /*!< The APB1 clock (PCLK1) divider. This clock is derived from the AHB clock (HCLK). This parameter can be a value of @ref RCC_LL_EC_APB1_DIV This feature can be modified afterwards using unitary function @ref LL_RCC_SetAPB1Prescaler(). */ uint32_t APB2CLKDivider; /*!< The APB2 clock (PCLK2) divider. This clock is derived from the AHB clock (HCLK). This parameter can be a value of @ref RCC_LL_EC_APB2_DIV This feature can be modified afterwards using unitary function @ref LL_RCC_SetAPB2Prescaler(). */ } LL_UTILS_ClkInitTypeDef; /** * @} */ /* Exported constants --------------------------------------------------------*/ /** @defgroup UTILS_LL_Exported_Constants UTILS Exported Constants * @{ */ /** @defgroup UTILS_EC_HSE_BYPASS HSE Bypass activation * @{ */ #define LL_UTILS_HSEBYPASS_OFF 0x00000000U /*!< HSE Bypass is not enabled */ #define LL_UTILS_HSEBYPASS_ON 0x00000001U /*!< HSE Bypass is enabled */ /** * @} */ /** @defgroup UTILS_EC_PACKAGETYPE PACKAGE TYPE * @{ */ #define LL_UTILS_PACKAGETYPE_WLCSP36_UFQFPN48_LQFP64 0x00000000U /*!< WLCSP36 or UFQFPN48 or LQFP64 package type */ #define LL_UTILS_PACKAGETYPE_WLCSP168_FBGA169_LQFP100_LQFP64_UFQFPN48 0x00000100U /*!< WLCSP168 or FBGA169 or LQFP100 or LQFP64 or UFQFPN48 package type */ #define LL_UTILS_PACKAGETYPE_WLCSP64_WLCSP81_LQFP176_UFBGA176 0x00000200U /*!< WLCSP64 or WLCSP81 or LQFP176 or UFBGA176 package type */ #define LL_UTILS_PACKAGETYPE_LQFP144_UFBGA144_UFBGA144_UFBGA100 0x00000300U /*!< LQFP144 or UFBGA144 or UFBGA144 or UFBGA100 package type */ #define LL_UTILS_PACKAGETYPE_LQFP100_LQFP208_TFBGA216 0x00000400U /*!< LQFP100 or LQFP208 or TFBGA216 package type */ #define LL_UTILS_PACKAGETYPE_LQFP208_TFBGA216 0x00000500U /*!< LQFP208 or TFBGA216 package type */ #define LL_UTILS_PACKAGETYPE_TQFP64_UFBGA144_LQFP144 0x00000700U /*!< TQFP64 or UFBGA144 or LQFP144 package type */ /** * @} */ /** * @} */ /* Exported macro ------------------------------------------------------------*/ /* Exported functions --------------------------------------------------------*/ /** @defgroup UTILS_LL_Exported_Functions UTILS Exported Functions * @{ */ /** @defgroup UTILS_EF_DEVICE_ELECTRONIC_SIGNATURE DEVICE ELECTRONIC SIGNATURE * @{ */ /** * @brief Get Word0 of the unique device identifier (UID based on 96 bits) * @retval UID[31:0] */ __STATIC_INLINE uint32_t LL_GetUID_Word0(void) { return (uint32_t)(READ_REG(*((uint32_t *)UID_BASE_ADDRESS))); } /** * @brief Get Word1 of the unique device identifier (UID based on 96 bits) * @retval UID[63:32] */ __STATIC_INLINE uint32_t LL_GetUID_Word1(void) { return (uint32_t)(READ_REG(*((uint32_t *)(UID_BASE_ADDRESS + 4U)))); } /** * @brief Get Word2 of the unique device identifier (UID based on 96 bits) * @retval UID[95:64] */ __STATIC_INLINE uint32_t LL_GetUID_Word2(void) { return (uint32_t)(READ_REG(*((uint32_t *)(UID_BASE_ADDRESS + 8U)))); } /** * @brief Get Flash memory size * @note This bitfield indicates the size of the device Flash memory expressed in * Kbytes. As an example, 0x040 corresponds to 64 Kbytes. * @retval FLASH_SIZE[15:0]: Flash memory size */ __STATIC_INLINE uint32_t LL_GetFlashSize(void) { return (uint16_t)(READ_REG(*((uint32_t *)FLASHSIZE_BASE_ADDRESS))); } /** * @brief Get Package type * @retval Returned value can be one of the following values: * @arg @ref LL_UTILS_PACKAGETYPE_WLCSP36_UFQFPN48_LQFP64 (*) * @arg @ref LL_UTILS_PACKAGETYPE_WLCSP168_FBGA169_LQFP100_LQFP64_UFQFPN48 (*) * @arg @ref LL_UTILS_PACKAGETYPE_WLCSP64_WLCSP81_LQFP176_UFBGA176 (*) * @arg @ref LL_UTILS_PACKAGETYPE_LQFP144_UFBGA144_UFBGA144_UFBGA100 (*) * @arg @ref LL_UTILS_PACKAGETYPE_LQFP100_LQFP208_TFBGA216 (*) * @arg @ref LL_UTILS_PACKAGETYPE_LQFP208_TFBGA216 (*) * @arg @ref LL_UTILS_PACKAGETYPE_TQFP64_UFBGA144_LQFP144 (*) * * (*) value not defined in all devices. */ __STATIC_INLINE uint32_t LL_GetPackageType(void) { return (uint8_t)(READ_REG(*((uint32_t *)PACKAGE_BASE_ADDRESS)) & 0x0700U); } /** * @} */ /** @defgroup UTILS_LL_EF_DELAY DELAY * @{ */ /** * @brief This function configures the Cortex-M SysTick source of the time base. * @param HCLKFrequency HCLK frequency in Hz (can be calculated thanks to RCC helper macro) * @note When a RTOS is used, it is recommended to avoid changing the SysTick * configuration by calling this function, for a delay use rather osDelay RTOS service. * @param Ticks Number of ticks * @retval None */ __STATIC_INLINE void LL_InitTick(uint32_t HCLKFrequency, uint32_t Ticks) { /* Configure the SysTick to have interrupt in 1ms time base */ SysTick->LOAD = (uint32_t)((HCLKFrequency / Ticks) - 1UL); /* set reload register */ SysTick->VAL = 0UL; /* Load the SysTick Counter Value */ SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | SysTick_CTRL_ENABLE_Msk; /* Enable the Systick Timer */ } void LL_Init1msTick(uint32_t HCLKFrequency); void LL_mDelay(uint32_t Delay); /** * @} */ /** @defgroup UTILS_EF_SYSTEM SYSTEM * @{ */ void LL_SetSystemCoreClock(uint32_t HCLKFrequency); ErrorStatus LL_PLL_ConfigSystemClock_HSI(LL_UTILS_PLLInitTypeDef *UTILS_PLLInitStruct, LL_UTILS_ClkInitTypeDef *UTILS_ClkInitStruct); ErrorStatus LL_PLL_ConfigSystemClock_HSE(uint32_t HSEFrequency, uint32_t HSEBypass, LL_UTILS_PLLInitTypeDef *UTILS_PLLInitStruct, LL_UTILS_ClkInitTypeDef *UTILS_ClkInitStruct); /** * @} */ /** * @} */ /** * @} */ /** * @} */ #ifdef __cplusplus } #endif #endif /* __STM32F4xx_LL_UTILS_H */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ ================================================ FILE: sys/arch/stm32/hal/system_stm32f4xx.c ================================================ /** ****************************************************************************** * @file system_stm32f4xx.c * @author MCD Application Team * @version V1.0.0 * @date 17-February-2017 * @brief CMSIS Cortex-M4 Device Peripheral Access Layer System Source File. * * This file provides two functions and one global variable to be called from * user application: * - SystemInit(): This function is called at startup just after reset and * before branch to main program. This call is made inside * the "startup_stm32f4xx.s" file. * * - SystemCoreClock variable: Contains the core clock (HCLK), it can be used * by the user application to setup the SysTick * timer or configure other parameters. * * - SystemCoreClockUpdate(): Updates the variable SystemCoreClock and must * be called whenever the core clock is changed * during program execution. * * ****************************************************************************** * @attention * *

© COPYRIGHT 2017 STMicroelectronics

* * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. Neither the name of STMicroelectronics nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ /** @addtogroup CMSIS * @{ */ /** @addtogroup stm32f4xx_system * @{ */ /** @addtogroup STM32F4xx_System_Private_Includes * @{ */ #include "stm32f4xx.h" #if !defined (HSE_VALUE) #define HSE_VALUE ((uint32_t)8000000) /*!< Default value of the External oscillator in Hz */ #endif /* HSE_VALUE */ #if !defined (HSI_VALUE) #define HSI_VALUE ((uint32_t)16000000) /*!< Value of the Internal oscillator in Hz*/ #endif /* HSI_VALUE */ /** * @} */ /** @addtogroup STM32F4xx_System_Private_TypesDefinitions * @{ */ /** * @} */ /** @addtogroup STM32F4xx_System_Private_Defines * @{ */ /************************* Miscellaneous Configuration ************************/ /*!< Uncomment the following line if you need to relocate your vector Table in Internal SRAM. */ /* #define VECT_TAB_SRAM */ #define VECT_TAB_OFFSET 0x00 /*!< Vector Table base offset field. This value must be a multiple of 0x200. */ /******************************************************************************/ /** * @} */ /** @addtogroup STM32F4xx_System_Private_Macros * @{ */ /** * @} */ /** @addtogroup STM32F4xx_System_Private_Variables * @{ */ /* This variable is updated in three ways: 1) by calling CMSIS function SystemCoreClockUpdate() 2) by calling HAL API function HAL_RCC_GetHCLKFreq() 3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency Note: If you use this function to configure the system clock; then there is no need to call the 2 first functions listed above, since SystemCoreClock variable is updated automatically. */ uint32_t SystemCoreClock = 16000000; const uint8_t AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9}; const uint8_t APBPrescTable[8] = {0, 0, 0, 0, 1, 2, 3, 4}; /** * @} */ /** @addtogroup STM32F4xx_System_Private_FunctionPrototypes * @{ */ /** * @} */ /** @addtogroup STM32F4xx_System_Private_Functions * @{ */ /** * @brief Setup the microcontroller system * Initialize the FPU setting, vector table location and External memory * configuration. * @param None * @retval None */ void SystemInit(void) { /* Ensure double-word stack alignment is enabled. */ SCB->CCR |= SCB_CCR_STKALIGN_Msk; /* FPU settings ------------------------------------------------------------*/ #if (__FPU_PRESENT == 1) && (__FPU_USED == 1) SCB->CPACR |= ((3UL << 10*2)|(3UL << 11*2)); /* set CP10 and CP11 Full Access */ #endif /* Reset the RCC clock configuration to the default reset state ------------*/ /* Set HSION bit */ RCC->CR |= (uint32_t)0x00000001; /* Reset CFGR register */ RCC->CFGR = 0x00000000; /* Reset HSEON, CSSON and PLLON bits */ RCC->CR &= (uint32_t)0xFEF6FFFF; /* Reset PLLCFGR register */ RCC->PLLCFGR = 0x24003010; /* Reset HSEBYP bit */ RCC->CR &= (uint32_t)0xFFFBFFFF; /* Disable all interrupts */ RCC->CIR = 0x00000000; /* Configure the Vector Table location add offset address ------------------*/ #ifdef VECT_TAB_SRAM SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */ #else SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */ #endif } /** * @brief Update SystemCoreClock variable according to Clock Register Values. * The SystemCoreClock variable contains the core clock (HCLK), it can * be used by the user application to setup the SysTick timer or configure * other parameters. * * @note Each time the core clock (HCLK) changes, this function must be called * to update SystemCoreClock variable value. Otherwise, any configuration * based on this variable will be incorrect. * * @note - The system frequency computed by this function is not the real * frequency in the chip. It is calculated based on the predefined * constant and the selected clock source: * * - If SYSCLK source is HSI, SystemCoreClock will contain the HSI_VALUE(*) * * - If SYSCLK source is HSE, SystemCoreClock will contain the HSE_VALUE(**) * * - If SYSCLK source is PLL, SystemCoreClock will contain the HSE_VALUE(**) * or HSI_VALUE(*) multiplied/divided by the PLL factors. * * (*) HSI_VALUE is a constant defined in stm32f4xx_hal_conf.h file (default value * 16 MHz) but the real value may vary depending on the variations * in voltage and temperature. * * (**) HSE_VALUE is a constant defined in stm32f4xx_hal_conf.h file (its value * depends on the application requirements), user has to ensure that HSE_VALUE * is same as the real frequency of the crystal used. Otherwise, this function * may have wrong result. * * - The result of this function could be not correct when using fractional * value for HSE crystal. * * @param None * @retval None */ void SystemCoreClockUpdate(void) { uint32_t tmp = 0, pllvco = 0, pllp = 2, pllsource = 0, pllm = 2; /* Get SYSCLK source -------------------------------------------------------*/ tmp = RCC->CFGR & RCC_CFGR_SWS; switch (tmp) { case 0x00: /* HSI used as system clock source */ SystemCoreClock = HSI_VALUE; break; case 0x04: /* HSE used as system clock source */ SystemCoreClock = HSE_VALUE; break; case 0x08: /* PLL used as system clock source */ /* PLL_VCO = (HSE_VALUE or HSI_VALUE / PLL_M) * PLL_N SYSCLK = PLL_VCO / PLL_P */ pllsource = (RCC->PLLCFGR & RCC_PLLCFGR_PLLSRC) >> 22; pllm = RCC->PLLCFGR & RCC_PLLCFGR_PLLM; if (pllsource != 0) { /* HSE used as PLL clock source */ pllvco = (HSE_VALUE / pllm) * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 6); } else { /* HSI used as PLL clock source */ pllvco = (HSI_VALUE / pllm) * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 6); } pllp = (((RCC->PLLCFGR & RCC_PLLCFGR_PLLP) >>16) + 1 ) *2; SystemCoreClock = pllvco/pllp; break; default: SystemCoreClock = HSI_VALUE; break; } /* Compute HCLK frequency --------------------------------------------------*/ /* Get HCLK prescaler */ tmp = AHBPrescTable[((RCC->CFGR & RCC_CFGR_HPRE) >> 4)]; /* HCLK frequency */ SystemCoreClock >>= tmp; } /** * @} */ /** * @} */ /** * @} */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ ================================================ FILE: sys/arch/stm32/hal/system_stm32f4xx.h ================================================ /** ****************************************************************************** * @file system_stm32f4xx.h * @author MCD Application Team * @version V2.6.1 * @date 14-February-2017 * @brief CMSIS Cortex-M4 Device System Source File for STM32F4xx devices. ****************************************************************************** * @attention * *

© COPYRIGHT(c) 2017 STMicroelectronics

* * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. Neither the name of STMicroelectronics nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ /** @addtogroup CMSIS * @{ */ /** @addtogroup stm32f4xx_system * @{ */ /** * @brief Define to prevent recursive inclusion */ #ifndef __SYSTEM_STM32F4XX_H #define __SYSTEM_STM32F4XX_H #ifdef __cplusplus extern "C" { #endif /** @addtogroup STM32F4xx_System_Includes * @{ */ /** * @} */ /** @addtogroup STM32F4xx_System_Exported_types * @{ */ /* This variable is updated in three ways: 1) by calling CMSIS function SystemCoreClockUpdate() 2) by calling HAL API function HAL_RCC_GetSysClockFreq() 3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency Note: If you use this function to configure the system clock; then there is no need to call the 2 first functions listed above, since SystemCoreClock variable is updated automatically. */ extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ extern const uint8_t AHBPrescTable[16]; /*!< AHB prescalers table values */ extern const uint8_t APBPrescTable[8]; /*!< APB prescalers table values */ /** * @} */ /** @addtogroup STM32F4xx_System_Exported_Constants * @{ */ /** * @} */ /** @addtogroup STM32F4xx_System_Exported_Macros * @{ */ /** * @} */ /** @addtogroup STM32F4xx_System_Exported_Functions * @{ */ extern void SystemInit(void); extern void SystemCoreClockUpdate(void); /** * @} */ #ifdef __cplusplus } #endif #endif /*__SYSTEM_STM32F4XX_H */ /** * @} */ /** * @} */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ ================================================ FILE: sys/arch/stm32/include/_float.h ================================================ #ifndef _MACHINE__FLOAT_H_ #define _MACHINE__FLOAT_H_ /* Characteristics of IEEE floating types */ #define FLT_RADIX 2 #define FLT_ROUNDS 1 /* * These values provide information pertaining to the float type. */ #define FLT_EPSILON 1.19209290E-07F /* b**(1-p) */ #define FLT_MAX 3.40282347E+38F /* (1-b**(-p))*b**emax */ #define FLT_MIN 1.17549435E-38F /* b**(emin-1) */ #define FLT_DIG 6 /* floor((p-1)*log10(b))+(b == 10) */ #define FLT_MANT_DIG 24 /* p */ #define FLT_MAX_10_EXP 38 /* floor(log10((1-b**(-p))*b**emax)) */ #define FLT_MAX_EXP 128 /* emax */ #define FLT_MIN_10_EXP (-37) /* ceil(log10(b**(emin-1))) */ #define FLT_MIN_EXP (-125) /* emin */ /* * These values provide information pertaining to the double type. */ #define DBL_EPSILON 2.2204460492503131E-16 #define DBL_MAX 1.7976931348623157E+308 #define DBL_MIN 2.2250738585072014E-308 #define DBL_DIG 15 #define DBL_MANT_DIG 53 #define DBL_MAX_10_EXP 308 #define DBL_MAX_EXP 1024 #define DBL_MIN_10_EXP (-307) #define DBL_MIN_EXP (-1021) /* * These values provide information pertaining to the long double type. */ #define LDBL_EPSILON DBL_EPSILON #define LDBL_MAX DBL_MAX #define LDBL_MIN DBL_MIN #define LDBL_DIG DBL_DIG #define LDBL_MANT_DIG DBL_MANT_DIG #define LDBL_MAX_10_EXP DBL_MAX_10_EXP #define LDBL_MAX_EXP DBL_MAX_EXP #define LDBL_MIN_10_EXP DBL_MIN_10_EXP #define LDBL_MIN_EXP DBL_MIN_EXP #endif /* _MACHINE__FLOAT_H_ */ ================================================ FILE: sys/arch/stm32/include/cpu.h ================================================ /* * Copyright (c) 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * * @(#)cpu.h 1.5 (2.11BSD GTE) 1998/4/3 */ /* * CTL_MACHDEP definitions. */ #define CPU_CONSDEV 1 /* dev_t: console terminal device */ #define CPU_ERRMSG 2 /* get error message by errno */ #define CPU_NLIST 3 /* get name address */ #define CPU_FREQ_KHZ 4 /* processor clock in kHz */ #define CPU_BUS_KHZ 5 /* i/o bus clock in kHz */ #define CPU_MPU 6 /* node: memory protection unit */ #define CPU_MAXID 7 /* number of valid machdep ids */ #ifndef KERNEL #define CTL_MACHDEP_NAMES { \ { 0, 0 }, \ { "console_device", CTLTYPE_STRUCT }, \ { 0, 0 }, \ { 0, 0 }, \ { "cpu_khz", CTLTYPE_INT }, \ { "bus_khz", CTLTYPE_INT }, \ { "mpu", CTLTYPE_NODE }, \ } #endif /* !KERNEL */ ================================================ FILE: sys/arch/stm32/include/debug.h ================================================ #ifndef _DEBUG_H #define _DEBUG_H #define DEBUG(...) #define DEBUG1(...) #define DEBUG2(...) #define DEBUG3(...) #define DEBUG4(...) #define DEBUG5(...) #define DEBUG6(...) #define DEBUG7(...) #define DEBUG8(...) #define DEBUG9(...) #ifdef GLOBAL_DEBUG #undef DEBUG #define DEBUG(...) printf(__VA_ARGS__) #if (GLOBAL_DEBUG>=1) #undef DEBUG1 #define DEBUG1(...) printf(__VA_ARGS__) #endif #if (GLOBAL_DEBUG>=2) #undef DEBUG2 #define DEBUG2(...) printf(__VA_ARGS__) #endif #if (GLOBAL_DEBUG>=3) #undef DEBUG3 #define DEBUG3(...) printf(__VA_ARGS__) #endif #if (GLOBAL_DEBUG>=4) #undef DEBUG4 #define DEBUG4(...) printf(__VA_ARGS__) #endif #if (GLOBAL_DEBUG>=5) #undef DEBUG5 #define DEBUG5(...) printf(__VA_ARGS__) #endif #if (GLOBAL_DEBUG>=6) #undef DEBUG6 #define DEBUG6(...) printf(__VA_ARGS__) #endif #if (GLOBAL_DEBUG>=7) #undef DEBUG7 #define DEBUG7(...) printf(__VA_ARGS__) #endif #if (GLOBAL_DEBUG>=8) #undef DEBUG8 #define DEBUG8(...) printf(__VA_ARGS__) #endif #if (GLOBAL_DEBUG>=9) #undef DEBUG9 #define DEBUG9(...) printf(__VA_ARGS__) #endif #endif /* GLOBAL_DEBUG */ #endif /* _DEBUG_H */ ================================================ FILE: sys/arch/stm32/include/elf_machdep.h ================================================ /* $NetBSD: elf_machdep.h,v 1.19 2017/11/06 03:47:45 christos Exp $ */ #ifndef _ARM_ELF_MACHDEP_H_ #define _ARM_ELF_MACHDEP_H_ #if defined(__ARMEB__) #define ELF32_MACHDEP_ENDIANNESS ELFDATA2MSB #else #define ELF32_MACHDEP_ENDIANNESS ELFDATA2LSB #endif #define ELF64_MACHDEP_ENDIANNESS XXX /* break compilation */ #define ELF64_MACHDEP_ID_CASES \ /* no 64-bit ELF machine types supported */ /* Processor specific flags for the ELF header e_flags field. */ #define EF_ARM_RELEXEC 0x00000001 #define EF_ARM_HASENTRY 0x00000002 #define EF_ARM_INTERWORK 0x00000004 /* GNU binutils 000413 */ #define EF_ARM_SYMSARESORTED 0x00000004 /* ARM ELF A08 */ #define EF_ARM_APCS_26 0x00000008 /* GNU binutils 000413 */ #define EF_ARM_DYNSYMSUSESEGIDX 0x00000008 /* ARM ELF B01 */ #define EF_ARM_APCS_FLOAT 0x00000010 /* GNU binutils 000413 */ #define EF_ARM_MAPSYMSFIRST 0x00000010 /* ARM ELF B01 */ #define EF_ARM_PIC 0x00000020 #define EF_ARM_ALIGN8 0x00000040 /* 8-bit structure alignment. */ #define EF_ARM_NEW_ABI 0x00000080 #define EF_ARM_OLD_ABI 0x00000100 #define EF_ARM_SOFT_FLOAT 0x00000200 #define EF_ARM_BE8 0x00800000 #define EF_ARM_EABIMASK 0xff000000 #define EF_ARM_EABI_VER1 0x01000000 #define EF_ARM_EABI_VER2 0x02000000 #define EF_ARM_EABI_VER3 0x03000000 #define EF_ARM_EABI_VER4 0x04000000 #define EF_ARM_EABI_VER5 0x05000000 #define ELF32_MACHDEP_ID_CASES \ case EM_ARM: \ break; #define ELF32_MACHDEP_ID EM_ARM #define KERN_ELFSIZE 32 #define ARCH_ELFSIZE 32 /* MD native binary size */ /* Processor specific relocation types */ #define R_ARM_NONE 0 #define R_ARM_PC24 1 #define R_ARM_ABS32 2 #define R_ARM_REL32 3 #define R_ARM_PC13 4 #define R_ARM_ABS16 5 #define R_ARM_ABS12 6 #define R_ARM_THM_ABS5 7 #define R_ARM_ABS8 8 #define R_ARM_SBREL32 9 #define R_ARM_THM_PC22 10 #define R_ARM_THM_PC8 11 #define R_ARM_AMP_VCALL9 12 #define R_ARM_SWI24 13 #define R_ARM_THM_SWI8 14 #define R_ARM_XPC25 15 #define R_ARM_THM_XPC22 16 /* TLS relocations */ #define R_ARM_TLS_DTPMOD32 17 /* ID of module containing symbol */ #define R_ARM_TLS_DTPOFF32 18 /* Offset in TLS block */ #define R_ARM_TLS_TPOFF32 19 /* Offset in static TLS block */ /* 20-31 are reserved for ARM Linux. */ #define R_ARM_COPY 20 #define R_ARM_GLOB_DAT 21 #define R_ARM_JUMP_SLOT 22 #define R_ARM_RELATIVE 23 #define R_ARM_GOTOFF 24 #define R_ARM_GOTPC 25 #define R_ARM_GOT32 26 #define R_ARM_PLT32 27 #define R_ARM_CALL 28 #define R_ARM_JUMP24 29 #define R_ARM_THM_JUMP24 30 #define R_ARM_BASE_ABS 31 #define R_ARM_ALU_PCREL_7_0 32 #define R_ARM_ALU_PCREL_15_8 33 #define R_ARM_ALU_PCREL_23_15 34 #define R_ARM_ALU_SBREL_11_0 35 #define R_ARM_ALU_SBREL_19_12 36 #define R_ARM_ALU_SBREL_27_20 37 /* deprecated */ #define R_ARM_TARGET1 38 #define R_ARM_SBREL31 39 /* deprecated */ #define R_ARM_V4BX 40 #define R_ARM_TARGET2 41 #define R_ARM_PREL31 42 #define R_ARM_MOVW_ABS_NC 43 #define R_ARM_MOVT_ABS 44 #define R_ARM_MOVW_PREL_NC 45 #define R_ARM_MOVT_PREL 46 #define R_ARM_THM_MOVW_ABS_NC 47 #define R_ARM_THM_MOVT_ABS 48 #define R_ARM_THM_MOVW_PREL_NC 49 #define R_ARM_THM_MOVT_PREL 50 /* 96-111 are reserved to G++. */ #define R_ARM_GNU_VTENTRY 100 #define R_ARM_GNU_VTINHERIT 101 #define R_ARM_THM_PC11 102 #define R_ARM_THM_PC9 103 /* More TLS relocations */ #define R_ARM_TLS_GD32 104 /* PC-rel 32 bit for global dynamic */ #define R_ARM_TLS_LDM32 105 /* PC-rel 32 bit for local dynamic */ #define R_ARM_TLS_LDO32 106 /* 32 bit offset relative to TLS */ #define R_ARM_TLS_IE32 107 /* PC-rel 32 bit for GOT entry of */ #define R_ARM_TLS_LE32 108 #define R_ARM_TLS_LDO12 109 #define R_ARM_TLS_LE12 110 #define R_ARM_TLS_IE12GP 111 /* 112-127 are reserved for private experiments. */ #define R_ARM_IRELATIVE 160 #define R_ARM_RXPC25 249 #define R_ARM_RSBREL32 250 #define R_ARM_THM_RPC22 251 #define R_ARM_RREL32 252 #define R_ARM_RABS32 253 #define R_ARM_RPC24 254 #define R_ARM_RBASE 255 #define R_TYPE(name) __CONCAT(R_ARM_,name) /* Processor specific program header flags */ #define PF_ARM_SB 0x10000000 #define PF_ARM_PI 0x20000000 #define PF_ARM_ENTRY 0x80000000 /* Processor specific program header types */ #define PT_ARM_EXIDX (PT_LOPROC + 1) /* Processor specific section header flags */ #define SHF_ENTRYSECT 0x10000000 #define SHF_COMDEF 0x80000000 /* Processor specific symbol types */ #define STT_ARM_TFUNC STT_LOPROC /* * Tell the kernel ELF exec code not to try relocating the interpreter * (ld.so) for dynamically-linked ELF binaries. */ #ifdef _KERNEL #define ELF_INTERP_NON_RELOCATABLE #endif #endif /* _ARM_ELF_MACHDEP_H_ */ ================================================ FILE: sys/arch/stm32/include/fault.h ================================================ /* * Copyright (c) 2023 Christopher Hettrick * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #ifndef _MACHINE_FAULT_H_ #define _MACHINE_FAULT_H_ /* * Fault types ARMv7-M * * Reference: "ARMv7-M Architecture Reference Manual" * DDI 0403E.d * June 29, 2018 * Sections B3.2.14 - B3.2.18 */ /* * HardFault Status Register bit assignments * HFSR * * Bit position |31 0| * HFSR register | HardFault Status Register | * Fault bits | 11xx xxxx xxxx xxxx xxxx xxxx xxxx xx1x | */ #define FAULTED(reg, bit, mask) ((((reg) & (mask)) >> (bit)) & 0x1) #define T_ALL_HARDF_MASK 0xc0000002 /* Fault bits of HFSR */ #define HARD_FAULT(reg, bit) FAULTED(reg, bit, T_ALL_HARDF_MASK) /* HardFault */ #define T_HF_VECTTBL 1 /* vector read error */ #define T_HF_FORCED 30 /* fault escalation */ #define T_HF_DEBUGEVT 31 /* breakpoint escalation */ /* * Configurable Fault Status Register bit assignments * CFSR = UFSR UsageFault Status Register * | BFSR BusFault Status Register * | MMFSR MemManage Fault Status Register * * Bit position |31 16|15 8|7 0| * CFSR register | UsageFault | BusFault | MemManage | * Fault bits | xxxx xx11 xxxx 1111 | xx11 1111 | xx11 1x11 | */ #define T_CFSR_FAULTS_MASK 0x030f3f3b /* Fault bits of CFSR */ #define CFSR_FAULT(reg, bit) FAULTED(reg, bit, T_CFSR_FAULTS_MASK) /* MemManage Fault */ #define T_MM_IACCVIOL 0 /* instruction access */ #define T_MM_DACCVIOL 1 /* data access */ #define T_MM_MUNSTKERR 3 /* exception return unstacking */ #define T_MM_MSTKERR 4 /* exception entry stacking */ #define T_MM_MLSPERR 5 /* fp lazy state preservation */ /* BusFault */ #define T_BF_IBUSERR 8 /* precise instruction prefetch */ #define T_BF_PRECISERR 9 /* precise data bus access */ #define T_BF_IMPRECISERR 10 /* imprecise data bus access */ #define T_BF_UNSTKERR 11 /* exception return unstacking */ #define T_BF_STKERR 12 /* exception entry stacking */ #define T_BF_LSPERR 13 /* fp lazy state preservation */ /* UsageFault */ #define T_UF_UNDEFINSTR 16 /* undefined instruction */ #define T_UF_INVSTATE 17 /* invalid execution state */ #define T_UF_INVPC 18 /* exception return integrity */ #define T_UF_NOCP 19 /* no coprocessor access */ #define T_UF_UNALIGNED 24 /* unaligned load or store */ #define T_UF_DIVBYZERO 25 /* divide by zero */ #define MMFARVALID_BIT 0x0080 /* CFSR bit[7] MMFAR contents valid */ #define BFARVALID_BIT 0x8000 /* CFSR bit[15] BFAR contents valid */ #define T_HF 0x1 /* Fault type HardFault */ #define T_MM 0x2 /* Fault type MemManage Fault */ #define T_BF 0x4 /* Fault type BusFault */ #define T_UF 0x8 /* Fault type UsageFault */ #define MM_FAULT_ENABLE SCB_SHCSR_MEMFAULTENA_Msk #define BF_FAULT_ENABLE SCB_SHCSR_BUSFAULTENA_Msk #define UF_FAULT_ENABLE SCB_SHCSR_USGFAULTENA_Msk static inline void arm_disable_fault(uint32_t fault) { SCB->SHCSR &= ~fault; } static inline void arm_enable_fault(uint32_t fault) { SCB->SHCSR |= fault; } static inline void arm_clear_fault(int bit, int type) { /* Writing a 1 to the fault indicator bit will clear it. */ switch (type) { /* Fault type is HardFault. */ case T_HF: SCB->HFSR |= 1UL << bit; break; /* Fault type is MemManage Fault, BusFault, or UsageFault. */ case T_MM: case T_BF: case T_UF: SCB->CFSR |= 1UL << bit; break; /* Unknown fault type. */ default: printf("not clearing unknown fault type %d\n", type); break; } } #endif /* !_MACHINE_FAULT_H_ */ ================================================ FILE: sys/arch/stm32/include/frame.h ================================================ /* * Copyright (c) 2021, 2022 Christopher Hettrick * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #ifndef _MACHINE_FRAME_H_ #define _MACHINE_FRAME_H_ #define INSN_SZ 2 /* Thumb are 2 bytes; some are 4 bytes. */ #define PSR_C (1UL << 29U) /* Carry bit. */ struct trapframe { /* The following 8 registers are pushed on stack by hardware in an SVCall. */ u_int tf_r0; /* Argument / Scratch Register 1 */ u_int tf_r1; /* Argument / Scratch Register 2 */ u_int tf_r2; /* Argument / Scratch Register 3 */ u_int tf_r3; /* Argument / Scratch Register 4 */ u_int tf_ip; /* Stack Pointer (as passed by IP) */ u_int tf_lr; /* Link Register */ u_int tf_pc; /* Program Counter */ u_int tf_psr; /* Program Status Register */ /* The following 8 registers are manually pushed on stack in SVC_Handler. */ u_int tf_r4; /* Variable Register 1 */ u_int tf_r5; /* Variable Register 2 */ u_int tf_r6; /* Variable Register 3 */ u_int tf_r7; /* Variable Register 4 */ u_int tf_r8; /* Variable Register 5 */ u_int tf_r9; /* Variable Register 6 */ u_int tf_r10; /* Variable Register 7 */ u_int tf_r11; /* Variable Register 8 or Frame Pointer */ }; #define tf_r12 tf_ip /* Intra-Procedure-Call Scratch Register */ #define tf_sp tf_ip /* Stack Pointer (as passed by IP) */ #define tf_r14 tf_lr /* Link Register */ #define tf_r15 tf_pc /* Program Counter */ /* * Exception stack frame of a SysTick exception. * A clockframe encapsulates the machine state when the SysTick * exception occured. * The clockframe is used by hardclock(), softclock(), and gatherstats(). */ struct clockframe { /* These 8 registers are pushed on stack by hardware in an exception. */ u_int cf_r0; /* Argument / Scratch Register 1 */ u_int cf_r1; /* Argument / Scratch Register 2 */ u_int cf_r2; /* Argument / Scratch Register 3 */ u_int cf_r3; /* Argument / Scratch Register 4 */ u_int cf_ip; /* Stack Pointer (as passed by IP) */ u_int cf_lr; /* Link Register */ u_int cf_pc; /* Program Counter */ u_int cf_psr; /* Program Status Register */ }; #define cf_sp cf_ip /* Stack Pointer (as passed by IP) */ /* * Exception stack frame of a fault exception. * A faultframe encapsulates the machine state when the fault occured. * * ARMv6-M fault types: HardFault * ARMv7-M fault types: HardFault, MemManage, BusFault, UsageFault */ struct faultframe { /* These 8 registers are pushed on stack by hardware in a fault exception. */ u_int ff_r0; /* Argument / Scratch Register 1 */ u_int ff_r1; /* Argument / Scratch Register 2 */ u_int ff_r2; /* Argument / Scratch Register 3 */ u_int ff_r3; /* Argument / Scratch Register 4 */ u_int ff_ip; /* Stack Pointer (as passed by IP) */ u_int ff_lr; /* Link Register */ u_int ff_pc; /* Program Counter */ u_int ff_psr; /* Program Status Register */ }; #define ff_sp ff_ip /* Stack Pointer (as passed by IP) */ #endif /* !_MACHINE_FRAME_H_ */ ================================================ FILE: sys/arch/stm32/include/intr.h ================================================ /* * Copyright (c) 2022 Christopher Hettrick * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #ifndef _MACHINE_INTR_H_ #define _MACHINE_INTR_H_ #ifdef KERNEL #include /* * Logical interrupt priority level: low prio (0) -> high prio (6) * Interrupts at or lower than numerical level are blocked. * * Notes: * - IPLs are the inverse of the Cortex-M hardware interrupt scheme. * low prio (0b111x.xxxx) -> high prio (0b001x.xxxx), 3 NVIC prio bits * low prio (0b0111.xxxx) -> high prio (0b0001.xxxx), 4 NVIC prio bits * - A zero value disables BASEPRI register; IPL levels are 0 -> 6. * - PendSV exception is IPL level 0; SVCall exception is IPL level 7. */ #define IPL_NONE 0 /* Blocks nothing. */ #define IPL_SOFTCLOCK 1 /* Blocks low-priority clock processing. */ #define IPL_NET 2 /* Blocks network protocol processing. */ #define IPL_BIO 3 /* Blocks disk controllers. */ #define IPL_TTY 4 /* Blocks terminal multiplexers. */ #define IPL_CLOCK 5 /* Blocks high-priority clock processing. */ #define IPL_HIGH 6 /* Blocks all interrupt activity. */ #define IPL_TOP (IPL_HIGH + 1) /* +1 since zero disables BASEPRI. */ #define IPL_BITS (8U - __NVIC_PRIO_BITS) /* MSB prio shift bits. */ /* Cortex-M core exception/interrupt priority levels. */ #define IPL_PENDSV IPL_NONE /* PendSV exception at lowest prio. */ #define IPL_SVCALL IPL_TOP /* SVC exception at highest prio. */ #define IPL_SYSTICK IPL_CLOCK /* SysTick exception at clock prio. */ #define IPLTOREG(ipl) \ (uint8_t)((ipl) ? (((IPL_TOP - (ipl)) << IPL_BITS) & 0xFFUL) : 0) #define REGTOIPL(reg) \ (uint32_t)((reg) ? (IPL_TOP - ((reg) >> IPL_BITS)) : 0) static inline int arm_intr_disable(void) { int s = __get_PRIMASK(); __disable_irq(); /* Disable interrupts. */ __ISB(); return s; } static inline int arm_intr_enable(void) { int s = __get_PRIMASK(); __enable_irq(); /* Enable interrupts. */ __ISB(); return s; } static inline void arm_intr_restore(int s) { __set_PRIMASK(s); __ISB(); } static inline void arm_intr_disable_irq(int irq) { NVIC_DisableIRQ(irq); } static inline void arm_intr_enable_irq(int irq) { NVIC_EnableIRQ(irq); } static inline void arm_intr_set_priority(int irq, int prio) { /* * This CMSIS function bitshifts prio into the most significant bits * and expects an inverted prio for the Cortex-M interrupt priority * scheme (zero has more priority than one), so IPL_TOP - prio. */ NVIC_SetPriority(irq, IPL_TOP - prio); } #ifdef __thumb2__ static inline int splraise(int new) { int old; old = REGTOIPL(__get_BASEPRI()); __set_BASEPRI_MAX(IPLTOREG(new)); __ISB(); return old; } #define splhigh() splraise(IPL_HIGH) #define splclock() splraise(IPL_CLOCK) #define spltty() splraise(IPL_TTY) #define splnet() splraise(IPL_NET) #define splbio() splraise(IPL_BIO) #define splsoftclock() splraise(IPL_SOFTCLOCK) static inline void splx(int s) { __set_BASEPRI(IPLTOREG(s)); __ISB(); } static inline int spl0(void) { int old; old = REGTOIPL(__get_BASEPRI()); splx(IPL_NONE); return old; } #else /* __thumb__ */ #define splhigh() arm_intr_disable() #define splclock() arm_intr_disable() #define spltty() arm_intr_disable() #define splnet() arm_intr_disable() #define splbio() arm_intr_disable() #define splsoftclock() arm_intr_enable() #define splx(s) arm_intr_restore(s) #define spl0() arm_intr_enable() #endif #endif /* KERNEL */ #endif /* !_MACHINE_INTR_H_ */ ================================================ FILE: sys/arch/stm32/include/io.h ================================================ /* * Hardware register defines for MIPS32 architecture. * * Copyright (C) 2008-2010 Serge Vakulenko, * * Permission to use, copy, modify, and distribute this software * and its documentation for any purpose and without fee is hereby * granted, provided that the above copyright notice appear in all * copies and that both that the copyright notice and this * permission notice and warranty disclaimer appear in supporting * documentation, and that the name of the author not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * * The author disclaim all warranties with regard to this * software, including all implied warranties of merchantability * and fitness. In no event shall the author be liable for any * special, indirect or consequential damages or any damages * whatsoever resulting from loss of use, data or profits, whether * in an action of contract, negligence or other tortious action, * arising out of or in connection with the use or performance of * this software. */ #ifndef __ASSEMBLER__ #ifndef KERNEL /* * 2BSD system call extensions: use with care. */ /* * Read peripheral register. */ unsigned ufetch (unsigned addr); /* * Write peripheral register. */ unsigned ustore (unsigned addr, unsigned value); /* * Call a kernel function. */ unsigned ucall (int priority, void *address, int arg1, int arg2); #endif /* KERNEL */ #endif /* __ASSEMBLER__ */ ================================================ FILE: sys/arch/stm32/include/limits.h ================================================ /* * Copyright (c) 1988, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)limits.h 8.3.1 (2.11BSD) 1996/1/11 */ #define CHAR_BIT 8 /* number of bits in a char */ /* * According to ANSI (section 2.2.4.2), the values below must be usable by * #if preprocessing directives. Additionally, the expression must have the * same type as would an expression that is an object of the corresponding * type converted according to the integral promotions. The subtraction for * INT_MIN and LONG_MIN is so the value is not unsigned; 2147483648 is an * unsigned int for 32-bit two's complement ANSI compilers (section 3.1.3.2). * These numbers work for pcc as well. The UINT_MAX and ULONG_MAX values * are written as hex so that GCC will be quiet about large integer constants. */ #define SCHAR_MAX 127 /* min value for a signed char */ #define SCHAR_MIN (-128) /* max value for a signed char */ #define UCHAR_MAX 255 /* max value for an unsigned char */ #define CHAR_MAX 127 /* max value for a char */ #define CHAR_MIN (-128) /* min value for a char */ #define USHRT_MAX 65535 /* max value for an unsigned short */ #define SHRT_MAX 32767 /* max value for a short */ #define SHRT_MIN (-32768) /* min value for a short */ #define UINT_MAX 0xffffffff /* max value for an unsigned int */ #define INT_MAX 2147483647 /* max value for an int */ #define INT_MIN (-2147483647-1) /* min value for an int */ #define ULONG_MAX 0xffffffff /* max value for an unsigned long */ #define LONG_MAX 2147483647L /* max value for a long */ #define LONG_MIN (-2147483647L-1L) /* min value for a long */ #define SSIZE_MAX INT_MAX /* max value for a ssize_t */ #define SIZE_T_MAX UINT_MAX /* max value for a size_t */ ================================================ FILE: sys/arch/stm32/include/machparam.h ================================================ /* * Machine dependent constants for STM32. * * Copyright (c) 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * * @(#)machparam.h 1.4 (2.11BSD GTE) 1998/9/15 */ #ifndef ENDIAN #define MACHINE "stm32" #define MACHINE_ARCH "arm" /* * Definitions for byte order, * according to byte significance from low address to high. */ #define LITTLE 1234 /* least-significant byte first (vax) */ #define BIG 4321 /* most-significant byte first */ #define PDP 3412 /* LSB first in word, MSW first in long (pdp) */ #define ENDIAN LITTLE /* byte order on stm32 */ /* * The time for a process to be blocked before being very swappable. * This is a number of seconds which the system takes as being a non-trivial * amount of real time. You probably shouldn't change this; * it is used in subtle ways (fractions and multiples of it are, that is, like * half of a ``long time'', almost a long time, etc.) * It is related to human patience and other factors which don't really * change over time. */ #define MAXSLP 20 /* * Clock ticks per second. The HZ value must be an integer factor of 1000. * Cortex-M SysTick operates with a 1ms time base, hence 1000 for HZ. */ #ifndef HZ #define HZ 1000 #endif /* * System parameter formulae. */ #ifndef NBUF #define NBUF 10 /* number of i/o buffers */ #endif #ifndef MAXUSERS #define MAXUSERS 1 /* number of user logins */ #endif #ifndef NPROC #define NPROC 25 /* number of processes */ #endif #ifndef NINODE #define NINODE 24 #endif #ifndef NFILE #define NFILE 24 #endif #define NNAMECACHE (NINODE * 11/10) #define NCALL (16 + 2 * MAXUSERS) #define NCLIST 32 /* number or CBSIZE blocks */ #ifndef SMAPSIZ #define SMAPSIZ NPROC /* size of swap allocation map */ #endif /* * Disk blocks. */ #define DEV_BSIZE 1024 /* the same as MAXBSIZE */ #define DEV_BSHIFT 10 /* log2(DEV_BSIZE) */ #define DEV_BMASK (DEV_BSIZE-1) /* Bytes to disk blocks */ #define btod(x) (((x) + DEV_BSIZE-1) >> DEV_BSHIFT) #if 1 /* XXX Needed for ps, w, smlrc. To be removed. */ #define USER_DATA_START (0x20000000) #define USER_DATA_SIZE (96 * 1024) /* 96kb for user RAM. */ #define USER_DATA_END (USER_DATA_START + USER_DATA_SIZE) #define stacktop(siz) (USER_DATA_END) #define stackbas(siz) (USER_DATA_END-(siz)) #endif /* XXX Needed for ps, w, smlrc. To be removed. */ /* * User area: a user structure, followed by the kernel * stack. The number for USIZE is determined empirically. * * Note that the SBASE and STOP constants are only used by the assembly code, * but are defined here to localize information about the user area's * layout (see pdp/genassym.c). Note also that a networking stack is always * allocated even for non-networking systems. This prevents problems with * applications having to be recompiled for networking versus non-networking * systems. */ #define USIZE 3072 #define SSIZE 2048 /* initial stack size (bytes) */ /* * Collect kernel statistics by default. */ #if !defined(UCB_METER) && !defined(NO_UCB_METER) #define UCB_METER #endif #ifdef KERNEL #include /* * Macros to decode processor status word. */ #define USERMODE(psr) ((psr & IPSR_ISR_Msk) == 0) /* No exceptions. */ #define BASEPRI(psr) (__get_BASEPRI() == 0) /* No masking. */ #define noop() asm volatile("nop") /* * Wait for something to happen. */ void idle(void); /* * Millisecond delay routine. */ void mdelay(unsigned msec); /* * Setup system timer for `hz' timer interrupts per second. */ void clkstart(void); /* * Control LEDs, installed on the board. */ #define LED_TTY 0x08 #define LED_SWAP 0x04 #define LED_DISK 0x02 #define LED_KERNEL 0x01 #define LED_ALL (LED_TTY | LED_SWAP | LED_DISK | LED_KERNEL) void led_control(int mask, int on); void LL_GPIO_EnableClock(GPIO_TypeDef *GPIOx); #endif /* KERNEL */ #endif /* ENDIAN */ ================================================ FILE: sys/arch/stm32/include/mpuvar.h ================================================ /* * Copyright (c) 2025 Christopher Hettrick * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #ifndef _MACHINE_MPUVAR_H_ #define _MACHINE_MPUVAR_H_ int mpu_sysctl(int *, u_int, void *, size_t *, void *, size_t); /* * CTL_MPU definitions. */ #define CPU_MPU_ENABLE 1 #define CPU_MPU_CTRL 2 #define CPU_MPU_NREGIONS 3 #define CPU_MPU_SEPARATE 4 #define CPU_MPU_MAXID 5 #ifndef KERNEL #define CTL_MPU_NAMES { \ { 0, 0 }, \ { "enable", CTLTYPE_INT }, \ { "ctrl", CTLTYPE_INT }, \ { "nregions", CTLTYPE_INT }, \ { "separate", CTLTYPE_INT }, \ } #endif /* !KERNEL */ #endif /* !_MACHINE_MPUVAR_H_ */ ================================================ FILE: sys/arch/stm32/include/setjmp.h ================================================ /* * Copyright (c) 2022 Christopher Hettrick * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #ifndef _MACHINE_SETJMP_H_ #define _MACHINE_SETJMP_H_ /* * Total 12 words for Arm architecture: * Two for signal mask: * env[0]: savesigs * env[1]: signal mask * Ten for registers: * env[2-11]: v1-v8, ip, lr (r4-r11, r12, r14) */ #define _JBLEN 12 #endif /* !_MACHINE_SETJMP_H_ */ ================================================ FILE: sys/arch/stm32/include/signal.h ================================================ /* * Copyright (c) 2021, 2022 Christopher Hettrick * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #ifndef _MACHINE_SIGNAL_H_ #define _MACHINE_SIGNAL_H_ /* * Information pushed on stack when a signal is delivered. * This is used by the kernel to restore state following * execution of the signal handler. It is also made available * to the handler to allow it to properly restore state if * a non-standard exit is performed. */ struct sigcontext { int sc_onstack; /* sigstack state to restore */ long sc_mask; /* signal mask to restore */ u_int sc_r0; u_int sc_r1; u_int sc_r2; u_int sc_r3; u_int sc_ip; u_int sc_lr; u_int sc_pc; u_int sc_psr; u_int sc_r4; u_int sc_r5; u_int sc_r6; u_int sc_r7; u_int sc_r8; u_int sc_r9; u_int sc_r10; u_int sc_r11; }; #define sc_r12 sc_ip /* Intra-Procedure-Call Scratch Register */ #define sc_sp sc_ip /* Stack Pointer (as passed by IP) */ #define sc_r14 sc_lr /* Link Register */ #define sc_r15 sc_pc /* Program Counter */ #endif /* !_MACHINE_SIGNAL_H_ */ ================================================ FILE: sys/arch/stm32/include/types.h ================================================ /* * Copyright (c) 2022 Christopher Hettrick * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #ifndef _ARM_TYPES_H_ #define _ARM_TYPES_H_ typedef struct label_t { /* regs v1-v7, FP, IP/SP, LR (r4-r10, r11, r12, r14) */ long val[10]; } label_t; #endif /* !_ARM_TYPES_H_ */ ================================================ FILE: sys/arch/stm32/stm32/clock.c ================================================ /* * Copyright (c) 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * * @(#)clock.c 1.1 (2.10BSD Berkeley) 12/1/86 */ #include /* * Setup core timer for `hz' timer interrupts per second. */ void clkstart(void) { } ================================================ FILE: sys/arch/stm32/stm32/conf.c ================================================ /* * Copyright (c) 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * * @(#)conf.c 3.2 (2.11BSD GTE) 1997/11/12 */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifdef SD_ENABLED #include #endif #ifdef PTY_ENABLED #include #endif #ifdef SDIO_ENABLED #include #endif #define __unused __attribute__((__unused__)) /* XXX */ int nullopen(dev_t dev __unused, int flag __unused, int mode __unused) { return 0; } int nullclose(dev_t dev __unused, int flag __unused, int mode __unused) { return 0; } int noopen(dev_t dev __unused, int flag __unused, int mode __unused) { return ENXIO; } int noclose(dev_t dev __unused, int flag __unused, int mode __unused) { return ENXIO; } int norw(dev_t dev __unused, struct uio *uio __unused, int flag __unused) { return 0; } int noioctl(dev_t dev __unused, u_int cmd __unused, caddr_t data __unused, int flag __unused) { return EIO; } int nullstop(struct tty *tp __unused, int flag __unused) { return 0; } /* * root attach routine. */ daddr_t nosize(dev_t dev __unused) { return 0; } #define NOBDEV \ noopen, noclose, nostrategy, \ nosize, noioctl, 0 /* * The RetroDisks require the same master number as the disk entry in the * rdisk.c file. A bit of a bind, but it means that the RetroDisk * devices must be numbered from master 0 upwards. */ const struct bdevsw bdevsw[] = { { /* 0 - sd */ #ifdef SD_ENABLED sdopen, sdclose, sdstrategy, sdsize, sdioctl, 0 #else NOBDEV #endif }, { /* 1 - sramc */ NOBDEV }, { /* 2 - sdramp */ NOBDEV }, { /* 3 - mrams */ NOBDEV }, { /* 4 - swap */ swopen, swclose, swstrategy, swsize, swcioctl, 0 }, { /* 5 - spirams */ NOBDEV }, /* * End the list with a blank entry. */ { 0 }, }; const int nblkdev = sizeof(bdevsw) / sizeof(bdevsw[0]) - 1; #define NOCDEV \ noopen, noclose, norw, norw, \ noioctl, nullstop, 0, seltrue, \ nostrategy, 0, 0, const struct cdevsw cdevsw[] = { /* * Static drivers - every system has these: */ { /* 0 - console */ cnopen, cnclose, cnread, cnwrite, cnioctl, nullstop, cnttys, cnselect, nostrategy, 0, 0, }, { /* 1 - mem, kmem, null, zero */ #if MEM_MAJOR != 1 #error Wrong MEM_MAJOR value! #endif nullopen, nullclose, mmrw, mmrw, noioctl, nullstop, 0, seltrue, nostrategy, 0, 0, }, { /* 2 - tty */ syopen, nullclose, syread, sywrite, syioctl, nullstop, 0, syselect, nostrategy, 0, 0, }, { /* 3 - fd */ fdopen, nullclose, norw, norw, noioctl, nullstop, 0, seltrue, nostrategy, 0, 0, }, { /* 4 - temp (temporary allocation in swap space) */ swcopen, swcclose, swcread, swcwrite, swcioctl, nullstop, 0, seltrue, nostrategy, 0, 0, }, /* * Optional drivers from here on: */ { /* 5 - log */ #ifdef LOG_ENABLED logopen, logclose, logread, norw, logioctl, nullstop, 0, logselect, nostrategy, 0, 0, #else NOCDEV #endif }, { /* 6 - tty uart */ #if UART_MAJOR != 6 #error Wrong UART_MAJOR value! #endif #if defined(UART1_ENABLED) || defined(UART2_ENABLED) || \ defined(UART3_ENABLED) || defined(UART4_ENABLED) || \ defined(UART5_ENABLED) || defined(UART6_ENABLED) uartopen, uartclose, uartread, uartwrite, uartioctl, nullstop, uartttys, uartselect, nostrategy, uartgetc, uartputc, #else NOCDEV #endif }, { /* 7 - tty usb */ NOCDEV }, { /* 8, 9 - pty */ #ifdef PTY_ENABLED ptsopen, ptsclose, ptsread, ptswrite, ptyioctl, nullstop, pt_tty, ptcselect, nostrategy, 0, 0, }, { ptcopen, ptcclose, ptcread, ptcwrite, ptyioctl, nullstop, pt_tty, ptcselect, nostrategy, 0, 0, #else NOCDEV }, { NOCDEV #endif }, { /* 10 - gpio */ NOCDEV }, { /* 11 - adc */ NOCDEV }, { /* 12 - spi */ #if defined(SPI1_ENABLED) || defined(SPI2_ENABLED) || \ defined(SPI3_ENABLED) || defined(SPI4_ENABLED) || \ defined(SPI5_ENABLED) || defined(SPI6_ENABLED) || \ defined(SPI7_ENABLED) || defined(SPI8_ENABLED) spi_open, spi_close, spi_read, spi_write, spi_ioctl, nullstop, 0, seltrue, nostrategy, 0, 0, #else NOCDEV #endif }, { /* 13 - glcd */ NOCDEV }, { /* 14 - pwm */ NOCDEV }, { /* 15 - picga */ /* Ignore this for now - it's WIP. */ NOCDEV }, { /* 16 - hxtft, gpanel, sgpanel */ NOCDEV }, { /* 17 - skel */ NOCDEV }, { /* 18 - sdio */ #ifdef SDIO_ENABLED sdio_open, sdio_close, sdio_read, sdio_write, sdio_ioctl, nullstop, 0, seltrue, nostrategy, 0, 0, #else NOCDEV #endif }, /* * End the list with a blank entry. */ { 0 }, }; const int nchrdev = sizeof(cdevsw) / sizeof(cdevsw[0]) - 1; /* * Routine that identifies /dev/mem and /dev/kmem. * * A minimal stub routine can always return 0. */ int iskmemdev(dev_t dev) { if (major(dev) == 1 && (minor(dev) == 0 || minor(dev) == 1)) return 1; return 0; } /* * Routine to determine if a device is a disk. * * A minimal stub routine can always return 0. */ int isdisk(dev_t dev, int type) { if (type != IFBLK) return 0; switch (major(dev)) { case 0: /* rd0 */ case 1: /* rd1 */ case 2: /* rd2 */ case 3: /* rd3 */ case 4: /* sw */ return 1; default: return 0; } /* NOTREACHED */ } /* * Routine to convert from character to block device number. * A minimal stub routine can always return NODEV. */ int chrtoblk(dev_t dev __unused) { return NODEV; } ================================================ FILE: sys/arch/stm32/stm32/fault.c ================================================ /* * Copyright (c) 2022, 2023 Christopher Hettrick * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * ARMv7-M Fault Handling */ #include #include #include #include #include #include #include /* * Fault descriptions of Configurable Fault Status Register bits. */ const char * const fault_type[] = { "instruction access", /* 0 T_MM_IACCVIOL */ "data access", /* 1 T_MM_DACCVIOL */ "reserved", "exception return unstacking", /* 3 T_MM_MUNSTKERR */ "exception entry stacking", /* 4 T_MM_MSTKERR */ "fp lazy state preservation", /* 5 T_MM_MLSPERR */ "reserved", "reserved", "precise instruction prefetch", /* 8 T_BF_IBUSERR */ "precise data bus access", /* 9 T_BF_PRECISERR */ "imprecise data bus access", /* 10 T_BF_IMPRECISERR */ "exception return unstacking", /* 11 T_BF_UNSTKERR */ "exception entry stacking", /* 12 T_BF_STKERR */ "fp lazy state preservation", /* 13 T_BF_LSPERR */ "reserved", "reserved", "undefined instruction", /* 16 T_UF_UNDEFINSTR */ "invalid execution state", /* 17 T_UF_INVSTATE */ "exception return integrity", /* 18 T_UF_INVPC */ "no coprocessor access", /* 19 T_UF_NOCP */ "reserved", "reserved", "reserved", "reserved", "unaligned load or store", /* 24 T_UF_UNALIGNED */ "divide by zero", /* 25 T_UF_DIVBYZERO */ }; const int fault_types = sizeof(fault_type) / sizeof(fault_type[0]); /* * Bus error received during vector fetch. * Escalation of configurable fault exceptions. * Execution of breakpoint instruction (BKPT) with a debugger attached * (halt debugging not enabled) and debug monitor exception not enabled. */ void HardFault_Handler(void) { __asm volatile ( " .syntax unified \n\t" " .thumb \n\t" " mov r2, #(0x01) \n\t" /* Fault type is HardFault T_HF. */ " mov r1, lr \n\t" /* Value of lr when fault occurred. */ " tst lr, #0x4 \n\t" /* Test bit 2 (SPSEL) of EXC_RETURN. */ " ite eq \n\t" /* Came from user or kernel mode? */ " mrseq r0, MSP \n\t" /* Kernel mode; fault frame on MSP. */ " mrsne r0, PSP \n\t" /* User mode; fault frame on PSP. */ " b arm_fault \n\t" /* Call arm_fault(frame, lr, type); */ ); } /* * Violation of access rules defined by MPU configuration. * Attempt to execute program code in execute never (XN) region. */ void MemManage_Handler(void) { __asm volatile ( " .syntax unified \n\t" " .thumb \n\t" " mov r2, #(0x02) \n\t" /* Fault type is MemManage T_MM. */ " mov r1, lr \n\t" /* Value of lr when fault occurred. */ " tst lr, #0x4 \n\t" /* Test bit 2 (SPSEL) of EXC_RETURN. */ " ite eq \n\t" /* Came from user or kernel mode? */ " mrseq r0, MSP \n\t" /* Kernel mode; fault frame on MSP. */ " mrsne r0, PSP \n\t" /* User mode; fault frame on PSP. */ " b arm_fault \n\t" /* Call arm_fault(frame, lr, type); */ ); } /* * Error responses received from the processor bus interface * during a memory access, for example: * instruction fetch or read, also called prefetch abort; * data read or write, also called data abort. * Bus fault during stacking/unstacking of exception handling sequence. * * Attempt to access an invalid memory location. * Unprivileged access to the Private Peripheral Bus (PPB) that * violates the default memory access permission. */ void BusFault_Handler(void) { __asm volatile ( " .syntax unified \n\t" " .thumb \n\t" " mov r2, #(0x04) \n\t" /* Fault type is BusFault T_BF. */ " mov r1, lr \n\t" /* Value of lr when fault occurred. */ " tst lr, #0x4 \n\t" /* Test bit 2 (SPSEL) of EXC_RETURN. */ " ite eq \n\t" /* Came from user or kernel mode? */ " mrseq r0, MSP \n\t" /* Kernel mode; fault frame on MSP. */ " mrsne r0, PSP \n\t" /* User mode; fault frame on PSP. */ " b arm_fault \n\t" /* Call arm_fault(frame, lr, type); */ ); } /* * Execution of undefined instruction or co-processor instruction. * Trying to switch to ARM state (only Thumb ISA is supported). * Invalid EXC_RETURN code during exception return sequence. * Unaligned memory access with multiple load or store instructions. * Execution of SVC when priority level of SVC is same or lower * than current level. * Exception return with Interrupt-Continuable Instruction (ICI) * bits in unstacked xPSR, but instruction being executed after * exception return is not a multiple-load/store instruction. * * If Configuration Control Register (CCR) is set up: * Divide by zero; * All unaligned memory accesses. */ void UsageFault_Handler(void) { __asm volatile ( " .syntax unified \n\t" " .thumb \n\t" " mov r2, #(0x08) \n\t" /* Fault type is UsageFault T_UF. */ " mov r1, lr \n\t" /* Value of lr when fault occurred. */ " tst lr, #0x4 \n\t" /* Test bit 2 (SPSEL) of EXC_RETURN. */ " ite eq \n\t" /* Came from user or kernel mode? */ " mrseq r0, MSP \n\t" /* Kernel mode; fault frame on MSP. */ " mrsne r0, PSP \n\t" /* User mode; fault frame on PSP. */ " b arm_fault \n\t" /* Call arm_fault(frame, lr, type); */ ); } void arm_fault(struct faultframe *frame, uint32_t fault_lr, int type) { int psig = SIGILL; /* Default signal. */ time_t syst; int bit; /* MUST read MMFAR and BFAR registers before reading CFSR. */ uint32_t mmfar = SCB->MMFAR; /* MemManage Fault Address */ uint32_t bfar = SCB->BFAR; /* BusFault Address */ uint32_t hfsr = SCB->HFSR; /* HardFault Status */ uint32_t cfsr = SCB->CFSR; /* Configurable Fault Status */ /* If true, MMFAR holds the MemManage fault-triggering address. */ uint32_t mmfarvalid = cfsr & MMFARVALID_BIT; /* CFSR bit[7] */ /* If true, BFAR holds the BusFault fault-triggering address. */ uint32_t bfarvalid = cfsr & BFARVALID_BIT; /* CFSR bit[15] */ led_control(LED_KERNEL, 1); syst = u.u_ru.ru_stime; #ifdef UCB_METER cnt.v_trap++; #endif printf("fault type: 0x%x", type); printf("%s\n", HARD_FAULT(hfsr, T_HF_FORCED) ? ", fault escalated" : ""); for (bit = 0; bit < fault_types; ++bit) { if (CFSR_FAULT(cfsr, bit)) { printf("fault %d: %s, ", bit, fault_type[bit]); switch (bit) { case T_MM_IACCVIOL: case T_MM_DACCVIOL: case T_MM_MUNSTKERR: case T_MM_MSTKERR: case T_MM_MLSPERR: psig = SIGSEGV; printf("MemManage Fault\n"); arm_clear_fault(bit, T_MM); break; case T_BF_IBUSERR: case T_BF_PRECISERR: case T_BF_IMPRECISERR: case T_BF_UNSTKERR: case T_BF_STKERR: case T_BF_LSPERR: psig = SIGBUS; printf("BusFault\n"); arm_clear_fault(bit, T_BF); break; case T_UF_UNDEFINSTR: case T_UF_INVSTATE: case T_UF_INVPC: case T_UF_NOCP: case T_UF_UNALIGNED: case T_UF_DIVBYZERO: psig = SIGILL; printf("UsageFault\n"); arm_clear_fault(bit, T_UF); break; default: psig = SIGILL; printf("unknown fault type\n"); arm_clear_fault(bit, type); break; } } } printf("fault trap frame:\n"); printf(" r0:\t0x%08x\tip:\t0x%08x\n", frame->ff_r0, frame->ff_ip); printf(" r1:\t0x%08x\tlr:\t0x%08x\n", frame->ff_r1, frame->ff_lr); printf(" r2:\t0x%08x\tpc:\t0x%08x\n", frame->ff_r2, frame->ff_pc); printf(" r3:\t0x%08x\tpsr:\t0x%08x\n", frame->ff_r3, frame->ff_psr); printf("fault status registers:\n"); printf(" hfsr:\t0x%08x\tcfsr:\t0x%08x\n", hfsr, cfsr); printf("fault address registers:\n"); printf(" mmfar:\t0x%08x\t%svalid\n", mmfar, mmfarvalid ? "" : "not "); printf(" bfar:\t0x%08x\t%svalid\n", bfar, bfarvalid ? "" : "not "); printf("fault entry EXC_RETURN value:\n"); printf(" lr:\t0x%08x\n", fault_lr); arm_intr_enable(); psignal(u.u_procp, psig); userret(frame->ff_pc, syst); led_control(LED_KERNEL, 0); } ================================================ FILE: sys/arch/stm32/stm32/locore.S ================================================ /* * Copyright (c) 2022 Christopher Hettrick * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #define UBASE 0x20000000 /* User space base address. */ #define USIZE 3072 /* From user.h */ .syntax unified .thumb /* * setjmp(env) * label_t *env; * * setjmp(env) will save the process' current register context * and return a zero. */ .text .align 2 .thumb_func .globl setjmp .type setjmp, %function setjmp: mov ip, sp #ifdef __thumb2__ stmea r0!, {r4-r10,fp,ip,lr} /* Save regs in env arg. */ #else /* __thumb__ */ stmea r0!, {r4-r7} /* Save v1-v4 in env arg. Incr r0. */ mov r4, r8 /* Bring high register v5 to low. */ mov r5, r9 /* Bring high register v6 to low. */ mov r6, r10 /* Bring high register v7 to low. */ mov r7, r11 /* Bring high register v8 to low. */ stmea r0!, {r4-r7} /* Save v5-v8 in env arg. Incr r0. */ mov r4, ip /* Bring high register ip to low. */ mov r5, lr /* Bring high register lr to low. */ stmea r0!, {r4-r5} /* Save ip and lr in env arg. */ #endif movs r0, #0 /* Returns zero. */ bx lr .size setjmp, . - setjmp /* * longjmp(u, env) * resume(u, env) * memaddr u; * label_t *env; * * longjmp(u, env) (and resume) will generate a "return(1)" from the last * call to setjmp(env) by mapping in the user structure pointed to by u, * restoring the context saved by setjmp in env and returning a one. * Note that registers are recovered statically from the env buffer rather * than dynamically from the stack ... * * This longjmp differs from the longjmp found in the standard library and * the VAX 4.3 kernel - it's actually closer to the resume routine of the * 4.3 kernel and, indeed, even used to be called resume in the 2.9 kernel. * We've given it both names to promote some degree of compatibility between * the 4.3 and 2.10 C kernel source ... */ .extern u0 .extern u .text .align 2 .thumb_func .globl longjmp .type longjmp, %function longjmp: .globl resume .type resume, %function resume: cpsid i /* Disable interrupts. */ mov r10, a2 /* Save env (second arg). */ ldr r1, =u0 /* Pointer to u0. area start addr. */ ldr r2, =u /* Pointer to u. area start addr. */ cmp a1, r2 /* If u (first arg) is not u. area, */ bne 1f /* then remap u. area. */ ldr r3, =(2f + 1) /* else no need to remap u. area. */ bx r3 /* The +1 sets Thumb mode bit. */ .pool /* Insert literal pool for labels. */ 1: ldr r3, [r2, #0] /* Pointer to u.u_procp structure. */ str r1, [r3, #60] /* Save &u0 in u.u_procp->p_addr. */ /* Exchange contents of u. and u0. */ mov r0, r2 /* Pointer to u. area start addr. */ .rept USIZE / 3 / 4 /* 4 * 3 * 256 = 3072 = USIZE */ #ifdef __thumb2__ ldmia r0, {r2-r4} ldmia r1, {r5-r7} #else /* __thumb__ */ ldmia r0!, {r2-r4} ldmia r1!, {r5-r7} subs r0, #(3 * 4) subs r1, #(3 * 4) #endif stmia r1!, {r2-r4} stmia r0!, {r5-r7} .endr ldr r2, =u /* Pointer to u. area start addr. */ ldr r3, [r2, #0] /* Pointer to u.u_procp structure. */ str r2, [r3, #60] /* Save &u in u.u_procp->p_addr. */ 2: mov a2, r10 /* Restore env (second arg). */ #ifdef __thumb2__ ldmia a2!, {r4-r10,fp,ip,lr} /* Restore regs from env arg. */ #else /* __thumb__ */ adds a2, #(8 * 4) /* Index to &env[8]. */ ldmia a2!, {r4-r5} /* Restore ip and lr to low regs. */ mov ip, r4 /* Move temp low register to ip. */ mov lr, r5 /* Move temp low register to lr. */ subs a2, #(6 * 4) /* Index to &env[4]. */ ldmia a2!, {r4-r7} /* Restore v5-v8 to low regs. */ mov r8, r4 /* Move temp low register to v5. */ mov r9, r5 /* Move temp low register to v6. */ mov r10, r6 /* Move temp low register to v7. */ mov r11, r7 /* Move temp low register to v8. */ subs a2, #(8 * 4) /* Index to &env[0]. */ ldmia a2!, {r4-r7} /* Restore v1-v4 to own registers. */ #endif mov sp, ip cpsie i /* Enable interrupts. */ movs a1, #1 /* Transfer back to setjmp() return */ bx lr /* with a return value of one. */ .pool /* Literal pool for local labels. */ .size longjmp, . - longjmp /* * icode() is copied out to process 1 to exec /sbin/init. * If the exec fails, process 1 exits. */ .text .align 2 .globl icode .type icode, %object icode: .thumb_func .type icode1, %function icode1: movs.n r0, #(sbininit - icode) /* Offset for /sbin/init path. */ movs.n r1, #(argv - icode) /* Offset for *argv[] array. */ ldr r2, =UBASE /* User space base address. */ add r0, r2 /* execv() *name argument. */ add r1, r2 /* execv() *argv[] argument. */ svc #11 /* Make SYS_execv syscall. */ svc #1 /* Make SYS_exit syscall. */ forever: /* Catch runaway code. */ b forever .pool /* Put literal pool inside icode(). */ .align 2 .type sbininit, %object sbininit: .ascii "/sbin/init\0" .globl initflags .type initflags, %object initflags: .ascii "-\0\0\0\0\0\0\0\0\0\0" /* Space for options. */ .align 2 .type argv, %object argv: .word sbininit+6-icode+UBASE /* Address of "init\0". */ .word initflags-icode+UBASE /* Init options. */ .word 0 .globl icodeend .type icodeend, %object icodeend: .size icode, . - icode ================================================ FILE: sys/arch/stm32/stm32/locore0.S ================================================ /** ****************************************************************************** * @file startup_stm32f407xx.s * @author MCD Application Team * @version V1.0.0 * @date 17-February-2017 * @brief STM32F407xx Devices vector table for GCC based toolchains. * * After Reset the Cortex-M4 processor is in Thread mode, * priority is Privileged, and the Stack is set to Main. * * This module performs: * - Set initial SP, * - Set initial PC == Reset_Handler, * - Set vector table entries with exception ISR addresses, * - Branch to main(), set up user mode, then run icode(). ****************************************************************************** * @attention * *

© COPYRIGHT 2017 STMicroelectronics

* * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. Neither the name of STMicroelectronics nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ .syntax unified .cpu cortex-m4 .fpu softvfp .thumb .globl g_pfnVectors .globl Default_Handler /* * Memory addresses defined in linker script. */ .word __user_data_start /* Start addr of user RAM. */ .word __user_data_end /* End addr of user RAM. */ .word u_end /* End addr of kernel RAM u. area. */ .word _sidata /* Start addr for .data init values. */ .word _sdata /* Start addr for .data section. */ .word _edata /* End addr for .data section. */ .word _sbss /* Start addr for .bss section. */ .word _ebss /* End addr for .bss section. */ .section .text.Reset_Handler .weak Reset_Handler .type Reset_Handler, %function Reset_Handler: ldr sp, =_estack /* Set Main Stack Pointer (MSP). */ /* Zero fill the data segment. */ ldr r2, =_sdata b LoopFillZeroData FillZeroData: movs r3, #0 str r3, [r2], #4 LoopFillZeroData: ldr r3, =u_end cmp r2, r3 bcc FillZeroData /* Copy data segment initializers from flash to SRAM. */ movs r1, #0 b LoopCopyDataInit CopyDataInit: ldr r3, =_sidata ldr r3, [r3, r1] str r3, [r0, r1] adds r1, r1, #4 LoopCopyDataInit: ldr r0, =_sdata ldr r3, =_edata adds r2, r0, r1 cmp r2, r3 bcc CopyDataInit /* Zero fill the bss segment. */ ldr r2, =_sbss b LoopFillZeroBss FillZeroBss: movs r3, #0 str r3, [r2], #4 LoopFillZeroBss: ldr r3, =_ebss cmp r2, r3 bcc FillZeroBss system_init_and_main: bl SystemInit bl main /* * Switch from kernel mode to user mode in user space. */ setup_user_mode: cpsid i /* Disable interrupts. */ /* Initialize BASEPRI register to spl0; no interrupt masking. */ movs r0, #0 /* Turn BASEPRI off; mask nothing. */ msr BASEPRI, r0 /* Switch SPSEL to Process Stack Pointer (PSP) for user space. */ ldr r0, =__user_data_end msr PSP, r0 /* PSP is the user space stack pointer. */ isb /* Just to be safe. */ /* nPRIV -> 1 sets unprivileged Thread Mode for user space. */ mrs r0, CONTROL orrs r0, r0, #0x1 /* CONTROL[0] -> 1 sets unprivileged level. */ orrs r0, r0, #0x2 /* CONTROL[1] -> 1 sets PSP as active. */ cpsie i /* Enable interrupts. */ msr CONTROL, r0 /* PSP is current sp; unprivileged level. */ isb /* Just to be safe. */ /* Run icode() in user space. */ ldr lr, =__user_data_start + 1 /* In Thumb must set lsbit. */ bx lr .size Reset_Handler, . - Reset_Handler /** * @brief This is the code that gets called when the processor receives an * unexpected interrupt. This simply enters an infinite loop, * preserving the system state for examination by a debugger. * @param None * @retval None */ .section .text.Default_Handler, "ax", %progbits Default_Handler: Infinite_Loop: b Infinite_Loop .size Default_Handler, . - Default_Handler /****************************************************************************** * * The minimal vector table for a Cortex M4. Note that the proper constructs * must be placed on this to ensure that it ends up at physical address * 0x0000.0000. * *******************************************************************************/ .section .isr_vector, "a", %progbits .type g_pfnVectors, %object .size g_pfnVectors, . - g_pfnVectors g_pfnVectors: .word _estack .word Reset_Handler .word NMI_Handler .word HardFault_Handler .word MemManage_Handler .word BusFault_Handler .word UsageFault_Handler .word 0 .word 0 .word 0 .word 0 .word SVC_Handler .word DebugMon_Handler .word 0 .word PendSV_Handler .word SysTick_Handler /* External Interrupts */ .word WWDG_IRQHandler /* Window WatchDog */ .word PVD_IRQHandler /* PVD through EXTI Line detection */ .word TAMP_STAMP_IRQHandler /* Tamper and TimeStamps through the EXTI line */ .word RTC_WKUP_IRQHandler /* RTC Wakeup through the EXTI line */ .word FLASH_IRQHandler /* FLASH */ .word RCC_IRQHandler /* RCC */ .word EXTI0_IRQHandler /* EXTI Line0 */ .word EXTI1_IRQHandler /* EXTI Line1 */ .word EXTI2_IRQHandler /* EXTI Line2 */ .word EXTI3_IRQHandler /* EXTI Line3 */ .word EXTI4_IRQHandler /* EXTI Line4 */ .word DMA1_Stream0_IRQHandler /* DMA1 Stream 0 */ .word DMA1_Stream1_IRQHandler /* DMA1 Stream 1 */ .word DMA1_Stream2_IRQHandler /* DMA1 Stream 2 */ .word DMA1_Stream3_IRQHandler /* DMA1 Stream 3 */ .word DMA1_Stream4_IRQHandler /* DMA1 Stream 4 */ .word DMA1_Stream5_IRQHandler /* DMA1 Stream 5 */ .word DMA1_Stream6_IRQHandler /* DMA1 Stream 6 */ .word ADC_IRQHandler /* ADC1, ADC2 and ADC3s */ .word CAN1_TX_IRQHandler /* CAN1 TX */ .word CAN1_RX0_IRQHandler /* CAN1 RX0 */ .word CAN1_RX1_IRQHandler /* CAN1 RX1 */ .word CAN1_SCE_IRQHandler /* CAN1 SCE */ .word EXTI9_5_IRQHandler /* External Line[9:5]s */ .word TIM1_BRK_TIM9_IRQHandler /* TIM1 Break and TIM9 */ .word TIM1_UP_TIM10_IRQHandler /* TIM1 Update and TIM10 */ .word TIM1_TRG_COM_TIM11_IRQHandler /* TIM1 Trigger and Commutation and TIM11 */ .word TIM1_CC_IRQHandler /* TIM1 Capture Compare */ .word TIM2_IRQHandler /* TIM2 */ .word TIM3_IRQHandler /* TIM3 */ .word TIM4_IRQHandler /* TIM4 */ .word I2C1_EV_IRQHandler /* I2C1 Event */ .word I2C1_ER_IRQHandler /* I2C1 Error */ .word I2C2_EV_IRQHandler /* I2C2 Event */ .word I2C2_ER_IRQHandler /* I2C2 Error */ .word SPI1_IRQHandler /* SPI1 */ .word SPI2_IRQHandler /* SPI2 */ .word USART1_IRQHandler /* USART1 */ .word USART2_IRQHandler /* USART2 */ .word USART3_IRQHandler /* USART3 */ .word EXTI15_10_IRQHandler /* External Line[15:10]s */ .word RTC_Alarm_IRQHandler /* RTC Alarm (A and B) through EXTI Line */ .word OTG_FS_WKUP_IRQHandler /* USB OTG FS Wakeup through EXTI line */ .word TIM8_BRK_TIM12_IRQHandler /* TIM8 Break and TIM12 */ .word TIM8_UP_TIM13_IRQHandler /* TIM8 Update and TIM13 */ .word TIM8_TRG_COM_TIM14_IRQHandler /* TIM8 Trigger and Commutation and TIM14 */ .word TIM8_CC_IRQHandler /* TIM8 Capture Compare */ .word DMA1_Stream7_IRQHandler /* DMA1 Stream7 */ .word FSMC_IRQHandler /* FSMC */ .word SDIO_IRQHandler /* SDIO */ .word TIM5_IRQHandler /* TIM5 */ .word SPI3_IRQHandler /* SPI3 */ .word UART4_IRQHandler /* UART4 */ .word UART5_IRQHandler /* UART5 */ .word TIM6_DAC_IRQHandler /* TIM6 and DAC1&2 underrun errors */ .word TIM7_IRQHandler /* TIM7 */ .word DMA2_Stream0_IRQHandler /* DMA2 Stream 0 */ .word DMA2_Stream1_IRQHandler /* DMA2 Stream 1 */ .word DMA2_Stream2_IRQHandler /* DMA2 Stream 2 */ .word DMA2_Stream3_IRQHandler /* DMA2 Stream 3 */ .word DMA2_Stream4_IRQHandler /* DMA2 Stream 4 */ .word ETH_IRQHandler /* Ethernet */ .word ETH_WKUP_IRQHandler /* Ethernet Wakeup through EXTI line */ .word CAN2_TX_IRQHandler /* CAN2 TX */ .word CAN2_RX0_IRQHandler /* CAN2 RX0 */ .word CAN2_RX1_IRQHandler /* CAN2 RX1 */ .word CAN2_SCE_IRQHandler /* CAN2 SCE */ .word OTG_FS_IRQHandler /* USB OTG FS */ .word DMA2_Stream5_IRQHandler /* DMA2 Stream 5 */ .word DMA2_Stream6_IRQHandler /* DMA2 Stream 6 */ .word DMA2_Stream7_IRQHandler /* DMA2 Stream 7 */ .word USART6_IRQHandler /* USART6 */ .word I2C3_EV_IRQHandler /* I2C3 event */ .word I2C3_ER_IRQHandler /* I2C3 error */ .word OTG_HS_EP1_OUT_IRQHandler /* USB OTG HS End Point 1 Out */ .word OTG_HS_EP1_IN_IRQHandler /* USB OTG HS End Point 1 In */ .word OTG_HS_WKUP_IRQHandler /* USB OTG HS Wakeup through EXTI */ .word OTG_HS_IRQHandler /* USB OTG HS */ .word DCMI_IRQHandler /* DCMI */ .word 0 /* CRYP crypto */ .word HASH_RNG_IRQHandler /* Hash and Rng */ .word FPU_IRQHandler /* FPU */ /******************************************************************************* * * Provide weak aliases for each Exception handler to the Default_Handler. * As they are weak aliases, any function with the same name will override * this definition. * *******************************************************************************/ .weak NMI_Handler .thumb_set NMI_Handler,Default_Handler .weak HardFault_Handler .thumb_set HardFault_Handler,Default_Handler .weak MemManage_Handler .thumb_set MemManage_Handler,Default_Handler .weak BusFault_Handler .thumb_set BusFault_Handler,Default_Handler .weak UsageFault_Handler .thumb_set UsageFault_Handler,Default_Handler .weak SVC_Handler .thumb_set SVC_Handler,Default_Handler .weak DebugMon_Handler .thumb_set DebugMon_Handler,Default_Handler .weak PendSV_Handler .thumb_set PendSV_Handler,Default_Handler .weak SysTick_Handler .thumb_set SysTick_Handler,Default_Handler .weak WWDG_IRQHandler .thumb_set WWDG_IRQHandler,Default_Handler .weak PVD_IRQHandler .thumb_set PVD_IRQHandler,Default_Handler .weak TAMP_STAMP_IRQHandler .thumb_set TAMP_STAMP_IRQHandler,Default_Handler .weak RTC_WKUP_IRQHandler .thumb_set RTC_WKUP_IRQHandler,Default_Handler .weak FLASH_IRQHandler .thumb_set FLASH_IRQHandler,Default_Handler .weak RCC_IRQHandler .thumb_set RCC_IRQHandler,Default_Handler .weak EXTI0_IRQHandler .thumb_set EXTI0_IRQHandler,Default_Handler .weak EXTI1_IRQHandler .thumb_set EXTI1_IRQHandler,Default_Handler .weak EXTI2_IRQHandler .thumb_set EXTI2_IRQHandler,Default_Handler .weak EXTI3_IRQHandler .thumb_set EXTI3_IRQHandler,Default_Handler .weak EXTI4_IRQHandler .thumb_set EXTI4_IRQHandler,Default_Handler .weak DMA1_Stream0_IRQHandler .thumb_set DMA1_Stream0_IRQHandler,Default_Handler .weak DMA1_Stream1_IRQHandler .thumb_set DMA1_Stream1_IRQHandler,Default_Handler .weak DMA1_Stream2_IRQHandler .thumb_set DMA1_Stream2_IRQHandler,Default_Handler .weak DMA1_Stream3_IRQHandler .thumb_set DMA1_Stream3_IRQHandler,Default_Handler .weak DMA1_Stream4_IRQHandler .thumb_set DMA1_Stream4_IRQHandler,Default_Handler .weak DMA1_Stream5_IRQHandler .thumb_set DMA1_Stream5_IRQHandler,Default_Handler .weak DMA1_Stream6_IRQHandler .thumb_set DMA1_Stream6_IRQHandler,Default_Handler .weak ADC_IRQHandler .thumb_set ADC_IRQHandler,Default_Handler .weak CAN1_TX_IRQHandler .thumb_set CAN1_TX_IRQHandler,Default_Handler .weak CAN1_RX0_IRQHandler .thumb_set CAN1_RX0_IRQHandler,Default_Handler .weak CAN1_RX1_IRQHandler .thumb_set CAN1_RX1_IRQHandler,Default_Handler .weak CAN1_SCE_IRQHandler .thumb_set CAN1_SCE_IRQHandler,Default_Handler .weak EXTI9_5_IRQHandler .thumb_set EXTI9_5_IRQHandler,Default_Handler .weak TIM1_BRK_TIM9_IRQHandler .thumb_set TIM1_BRK_TIM9_IRQHandler,Default_Handler .weak TIM1_UP_TIM10_IRQHandler .thumb_set TIM1_UP_TIM10_IRQHandler,Default_Handler .weak TIM1_TRG_COM_TIM11_IRQHandler .thumb_set TIM1_TRG_COM_TIM11_IRQHandler,Default_Handler .weak TIM1_CC_IRQHandler .thumb_set TIM1_CC_IRQHandler,Default_Handler .weak TIM2_IRQHandler .thumb_set TIM2_IRQHandler,Default_Handler .weak TIM3_IRQHandler .thumb_set TIM3_IRQHandler,Default_Handler .weak TIM4_IRQHandler .thumb_set TIM4_IRQHandler,Default_Handler .weak I2C1_EV_IRQHandler .thumb_set I2C1_EV_IRQHandler,Default_Handler .weak I2C1_ER_IRQHandler .thumb_set I2C1_ER_IRQHandler,Default_Handler .weak I2C2_EV_IRQHandler .thumb_set I2C2_EV_IRQHandler,Default_Handler .weak I2C2_ER_IRQHandler .thumb_set I2C2_ER_IRQHandler,Default_Handler .weak SPI1_IRQHandler .thumb_set SPI1_IRQHandler,Default_Handler .weak SPI2_IRQHandler .thumb_set SPI2_IRQHandler,Default_Handler .weak USART1_IRQHandler .thumb_set USART1_IRQHandler,Default_Handler .weak USART2_IRQHandler .thumb_set USART2_IRQHandler,Default_Handler .weak USART3_IRQHandler .thumb_set USART3_IRQHandler,Default_Handler .weak EXTI15_10_IRQHandler .thumb_set EXTI15_10_IRQHandler,Default_Handler .weak RTC_Alarm_IRQHandler .thumb_set RTC_Alarm_IRQHandler,Default_Handler .weak OTG_FS_WKUP_IRQHandler .thumb_set OTG_FS_WKUP_IRQHandler,Default_Handler .weak TIM8_BRK_TIM12_IRQHandler .thumb_set TIM8_BRK_TIM12_IRQHandler,Default_Handler .weak TIM8_UP_TIM13_IRQHandler .thumb_set TIM8_UP_TIM13_IRQHandler,Default_Handler .weak TIM8_TRG_COM_TIM14_IRQHandler .thumb_set TIM8_TRG_COM_TIM14_IRQHandler,Default_Handler .weak TIM8_CC_IRQHandler .thumb_set TIM8_CC_IRQHandler,Default_Handler .weak DMA1_Stream7_IRQHandler .thumb_set DMA1_Stream7_IRQHandler,Default_Handler .weak FSMC_IRQHandler .thumb_set FSMC_IRQHandler,Default_Handler .weak SDIO_IRQHandler .thumb_set SDIO_IRQHandler,Default_Handler .weak TIM5_IRQHandler .thumb_set TIM5_IRQHandler,Default_Handler .weak SPI3_IRQHandler .thumb_set SPI3_IRQHandler,Default_Handler .weak UART4_IRQHandler .thumb_set UART4_IRQHandler,Default_Handler .weak UART5_IRQHandler .thumb_set UART5_IRQHandler,Default_Handler .weak TIM6_DAC_IRQHandler .thumb_set TIM6_DAC_IRQHandler,Default_Handler .weak TIM7_IRQHandler .thumb_set TIM7_IRQHandler,Default_Handler .weak DMA2_Stream0_IRQHandler .thumb_set DMA2_Stream0_IRQHandler,Default_Handler .weak DMA2_Stream1_IRQHandler .thumb_set DMA2_Stream1_IRQHandler,Default_Handler .weak DMA2_Stream2_IRQHandler .thumb_set DMA2_Stream2_IRQHandler,Default_Handler .weak DMA2_Stream3_IRQHandler .thumb_set DMA2_Stream3_IRQHandler,Default_Handler .weak DMA2_Stream4_IRQHandler .thumb_set DMA2_Stream4_IRQHandler,Default_Handler .weak ETH_IRQHandler .thumb_set ETH_IRQHandler,Default_Handler .weak ETH_WKUP_IRQHandler .thumb_set ETH_WKUP_IRQHandler,Default_Handler .weak CAN2_TX_IRQHandler .thumb_set CAN2_TX_IRQHandler,Default_Handler .weak CAN2_RX0_IRQHandler .thumb_set CAN2_RX0_IRQHandler,Default_Handler .weak CAN2_RX1_IRQHandler .thumb_set CAN2_RX1_IRQHandler,Default_Handler .weak CAN2_SCE_IRQHandler .thumb_set CAN2_SCE_IRQHandler,Default_Handler .weak OTG_FS_IRQHandler .thumb_set OTG_FS_IRQHandler,Default_Handler .weak DMA2_Stream5_IRQHandler .thumb_set DMA2_Stream5_IRQHandler,Default_Handler .weak DMA2_Stream6_IRQHandler .thumb_set DMA2_Stream6_IRQHandler,Default_Handler .weak DMA2_Stream7_IRQHandler .thumb_set DMA2_Stream7_IRQHandler,Default_Handler .weak USART6_IRQHandler .thumb_set USART6_IRQHandler,Default_Handler .weak I2C3_EV_IRQHandler .thumb_set I2C3_EV_IRQHandler,Default_Handler .weak I2C3_ER_IRQHandler .thumb_set I2C3_ER_IRQHandler,Default_Handler .weak OTG_HS_EP1_OUT_IRQHandler .thumb_set OTG_HS_EP1_OUT_IRQHandler,Default_Handler .weak OTG_HS_EP1_IN_IRQHandler .thumb_set OTG_HS_EP1_IN_IRQHandler,Default_Handler .weak OTG_HS_WKUP_IRQHandler .thumb_set OTG_HS_WKUP_IRQHandler,Default_Handler .weak OTG_HS_IRQHandler .thumb_set OTG_HS_IRQHandler,Default_Handler .weak DCMI_IRQHandler .thumb_set DCMI_IRQHandler,Default_Handler .weak HASH_RNG_IRQHandler .thumb_set HASH_RNG_IRQHandler,Default_Handler .weak FPU_IRQHandler .thumb_set FPU_IRQHandler,Default_Handler /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ ================================================ FILE: sys/arch/stm32/stm32/machdep.c ================================================ /* * Copyright (c) 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * * @(#)machdep.c 2.4 (2.11BSD) 1999/9/13 */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include /* * Kernel-specific uses of LEDs and buttons provided by the * board support package and defined in the kernel Config. * LED activity indicators: TTY, SWAP, DISK, KERNEL * User Button: Enter single user mode when pressed during boot. */ #if defined(BSP) && defined(BSP_LED_TTY) #define LED_TTY_INIT() BSP_LED_Init(BSP_LED_TTY) #define LED_TTY_ON() BSP_LED_On(BSP_LED_TTY) #define LED_TTY_OFF() BSP_LED_Off(BSP_LED_TTY) #else #define LED_TTY_INIT() /* Nothing. */ #define LED_TTY_ON() /* Nothing. */ #define LED_TTY_OFF() /* Nothing. */ #endif #if defined(BSP) && defined(BSP_LED_SWAP) #define LED_SWAP_INIT() BSP_LED_Init(BSP_LED_SWAP) #define LED_SWAP_ON() BSP_LED_On(BSP_LED_SWAP) #define LED_SWAP_OFF() BSP_LED_Off(BSP_LED_SWAP) #else #define LED_SWAP_INIT() /* Nothing. */ #define LED_SWAP_ON() /* Nothing. */ #define LED_SWAP_OFF() /* Nothing. */ #endif #if defined(BSP) && defined(BSP_LED_DISK) #define LED_DISK_INIT() BSP_LED_Init(BSP_LED_DISK) #define LED_DISK_ON() BSP_LED_On(BSP_LED_DISK) #define LED_DISK_OFF() BSP_LED_Off(BSP_LED_DISK) #else #define LED_DISK_INIT() /* Nothing. */ #define LED_DISK_ON() /* Nothing. */ #define LED_DISK_OFF() /* Nothing. */ #endif #if defined(BSP) && defined(BSP_LED_KERNEL) #define LED_KERNEL_INIT() BSP_LED_Init(BSP_LED_KERNEL) #define LED_KERNEL_ON() BSP_LED_On(BSP_LED_KERNEL) #define LED_KERNEL_OFF() BSP_LED_Off(BSP_LED_KERNEL) #else #define LED_KERNEL_INIT() /* Nothing. */ #define LED_KERNEL_ON() /* Nothing. */ #define LED_KERNEL_OFF() /* Nothing. */ #endif #if defined(BSP) && defined(BSP_BUTTON_USER) #define BUTTON_USER_INIT() BSP_PB_Init(BSP_BUTTON_USER) #define BUTTON_USER_PRESSED() BSP_PB_GetState(BSP_BUTTON_USER) #else #define BUTTON_USER_INIT() /* Nothing. */ #define BUTTON_USER_PRESSED() (0) /* Not pressed. */ #endif char machine[] = MACHINE; /* from */ char machine_arch[] = MACHINE_ARCH; /* from */ char cpu_model[64]; int hz = HZ; int usechz = (1000000L + HZ - 1) / HZ; #ifdef TIMEZONE struct timezone tz = { TIMEZONE, DST }; #else struct timezone tz = { 8 * 60, 1 }; #endif int nproc = NPROC; struct namecache namecache[NNAMECACHE]; char bufdata[NBUF * MAXBSIZE]; struct inode inode[NINODE]; struct callout callout[NCALL]; struct mount mount[NMOUNT]; struct buf buf[NBUF], bfreelist[BQUEUES]; struct bufhd bufhash[BUFHSZ]; struct cblock cfree[NCLIST]; struct proc proc[NPROC]; struct file file[NFILE]; /* * Remove the ifdef/endif to run the kernel in unsecure mode even when in * a multiuser state. Normally 'init' raises the security level to 1 * upon transitioning to multiuser. Setting the securelevel to -1 prevents * the secure level from being raised by init. */ #ifdef PERMANENTLY_INSECURE int securelevel = -1; #else int securelevel = 0; #endif struct mapent swapent[SMAPSIZ]; struct map swapmap[1] = { { swapent, &swapent[SMAPSIZ], "swapmap" }, }; int waittime = -1; static int nodump(dev_t dev) { printf("\ndumping to dev %o off %D: not implemented\n", dumpdev, dumplo); return 0; } int (*dump)(dev_t) = nodump; dev_t pipedev; daddr_t dumplo = (daddr_t)1024; static void SystemClock_Config(void) { /* Enable HSE oscillator. */ #if defined(STM32F411xE) || defined(STM32F413xx) LL_RCC_HSE_EnableBypass(); #endif LL_RCC_HSE_Enable(); while (LL_RCC_HSE_IsReady() != 1) ; /* Set FLASH latency. */ #if defined(STM32F405xx) || defined(STM32F407xx) || defined(STM32F446xx) || \ defined(STM32F469xx) LL_FLASH_SetLatency(LL_FLASH_LATENCY_5); #endif #if defined(STM32F411xE) || defined(STM32F412Rx) || defined(STM32F412Zx) || \ defined(STM32F413xx) LL_FLASH_SetLatency(LL_FLASH_LATENCY_3); #endif /* Enable PWR clock. */ LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_PWR); LL_PWR_SetRegulVoltageScaling(LL_PWR_REGU_VOLTAGE_SCALE1); #if defined(STM32F446xx) || defined(STM32F469xx) /* Activation OverDrive Mode. */ LL_PWR_EnableOverDriveMode(); while (LL_PWR_IsActiveFlag_OD() != 1) ; /* Activation OverDrive Switching. */ LL_PWR_EnableOverDriveSwitching(); while (LL_PWR_IsActiveFlag_ODSW() != 1) ; #endif /* Main PLL configuration and activation. */ #ifdef STM32F405xx /* 168 MHz */ LL_RCC_PLL_ConfigDomain_SYS(LL_RCC_PLLSOURCE_HSE, LL_RCC_PLLM_DIV_8, 336, LL_RCC_PLLP_DIV_2); #endif #ifdef STM32F407xx /* 168 MHz */ LL_RCC_PLL_ConfigDomain_SYS(LL_RCC_PLLSOURCE_HSE, LL_RCC_PLLM_DIV_8, 336, LL_RCC_PLLP_DIV_2); #endif #ifdef STM32F411xE /* 100 MHz */ LL_RCC_PLL_ConfigDomain_SYS(LL_RCC_PLLSOURCE_HSE, LL_RCC_PLLM_DIV_8, 400, LL_RCC_PLLP_DIV_4); #endif #ifdef STM32F412Rx /* 100 MHz */ LL_RCC_PLL_ConfigDomain_SYS(LL_RCC_PLLSOURCE_HSE, LL_RCC_PLLM_DIV_8, 200, LL_RCC_PLLP_DIV_2); #endif #ifdef STM32F412Zx /* 100 MHz */ LL_RCC_PLL_ConfigDomain_SYS(LL_RCC_PLLSOURCE_HSE, LL_RCC_PLLM_DIV_8, 200, LL_RCC_PLLP_DIV_2); #endif #ifdef STM32F413xx /* 100 MHz */ LL_RCC_PLL_ConfigDomain_SYS(LL_RCC_PLLSOURCE_HSE, LL_RCC_PLLM_DIV_8, 200, LL_RCC_PLLP_DIV_2); #endif #ifdef STM32F446xx /* 180 MHz */ LL_RCC_PLL_ConfigDomain_SYS(LL_RCC_PLLSOURCE_HSE, LL_RCC_PLLM_DIV_8, 360, LL_RCC_PLLP_DIV_2); #endif #ifdef STM32F469xx /* 180 MHz */ LL_RCC_PLL_ConfigDomain_SYS(LL_RCC_PLLSOURCE_HSE, LL_RCC_PLLM_DIV_8, 360, LL_RCC_PLLP_DIV_2); #endif LL_RCC_PLL_Enable(); while (LL_RCC_PLL_IsReady() != 1) ; /* SysClk activation on the main PLL. */ LL_RCC_SetAHBPrescaler(LL_RCC_SYSCLK_DIV_1); LL_RCC_SetSysClkSource(LL_RCC_SYS_CLKSOURCE_PLL); while (LL_RCC_GetSysClkSource() != LL_RCC_SYS_CLKSOURCE_STATUS_PLL) ; /* Set APB1 & APB2 prescaler. */ #ifdef STM32F405xx /* 168 MHz */ LL_RCC_SetAPB1Prescaler(LL_RCC_APB1_DIV_4); LL_RCC_SetAPB2Prescaler(LL_RCC_APB2_DIV_2); #endif #ifdef STM32F407xx /* 168 MHz */ LL_RCC_SetAPB1Prescaler(LL_RCC_APB1_DIV_4); LL_RCC_SetAPB2Prescaler(LL_RCC_APB2_DIV_2); #endif #ifdef STM32F411xE /* 100 MHz */ LL_RCC_SetAPB1Prescaler(LL_RCC_APB1_DIV_2); LL_RCC_SetAPB2Prescaler(LL_RCC_APB2_DIV_1); #endif #ifdef STM32F412Rx /* 100 MHz */ LL_RCC_SetAPB1Prescaler(LL_RCC_APB1_DIV_2); LL_RCC_SetAPB2Prescaler(LL_RCC_APB2_DIV_2); #endif #ifdef STM32F412Zx /* 100 MHz */ LL_RCC_SetAPB1Prescaler(LL_RCC_APB1_DIV_2); LL_RCC_SetAPB2Prescaler(LL_RCC_APB2_DIV_1); #endif #ifdef STM32F413xx /* 100 MHz */ LL_RCC_SetAPB1Prescaler(LL_RCC_APB1_DIV_2); LL_RCC_SetAPB2Prescaler(LL_RCC_APB2_DIV_1); #endif #ifdef STM32F446xx /* 180 MHz */ LL_RCC_SetAPB1Prescaler(LL_RCC_APB1_DIV_2); LL_RCC_SetAPB2Prescaler(LL_RCC_APB2_DIV_2); #endif #ifdef STM32F469xx /* 180 MHz */ LL_RCC_SetAPB1Prescaler(LL_RCC_APB1_DIV_2); LL_RCC_SetAPB2Prescaler(LL_RCC_APB2_DIV_2); #endif /* Set SysTick to 1ms. */ SysTick_Config(CPU_KHZ); /* Update CMSIS variable (or through SystemCoreClockUpdate()). */ SystemCoreClock = CPU_KHZ * 1000; } /* * Machine dependent startup code. */ void startup(void) { HAL_Init(); SystemClock_Config(); /* Enable all configurable fault handlers. */ arm_enable_fault(MM_FAULT_ENABLE); arm_enable_fault(BF_FAULT_ENABLE); arm_enable_fault(UF_FAULT_ENABLE); /* Syscalls (via PendSV) have the lowest interrupt priority. */ arm_intr_set_priority(PendSV_IRQn, IPL_PENDSV); /* SVCall exceptions have the highest interrupt priority. */ arm_intr_set_priority(SVCall_IRQn, IPL_SVCALL); /* SysTick exceptions have the interrupt priority of IPL_CLOCK. */ arm_intr_set_priority(SysTick_IRQn, IPL_SYSTICK); /* * Configure LED pins. */ LED_TTY_INIT(); /* Green. Terminal i/o */ LED_SWAP_INIT(); /* Orange. Auxiliary swap */ LED_DISK_INIT(); /* Red. Disk i/o */ LED_KERNEL_INIT(); /* Blue. Kernel activity */ LED_TTY_ON(); LED_SWAP_ON(); LED_DISK_ON(); LED_KERNEL_ON(); LED_TTY_OFF(); LED_SWAP_OFF(); LED_DISK_OFF(); LED_KERNEL_OFF(); led_control(LED_ALL, 1); led_control(LED_ALL, 0); /* * Configure User Button. */ BUTTON_USER_INIT(); /* * Early setup for console devices. */ #if CONS_MAJOR == UART_MAJOR uartinit(CONS_MINOR); #endif /* * When User button is pressed - boot to single user mode. */ boothowto = 0; if (BUTTON_USER_PRESSED()) { boothowto |= RB_SINGLE; } } static void cpuidentify(void) { u_int devid = LL_DBGMCU_GetDeviceID(); u_int revid = LL_DBGMCU_GetRevisionID(); printf("cpu: "); switch (devid) { /* * Device errata 2.2.2: MCU device ID is incorrect. * * Revision A STM32F40x and STM32F41x devices have the same * MCU device ID as the STM32F20x and STM32F21x devices. * Reading the revision identifier returns 0x2000 instead of 0x1000. */ case 0x0411: physmem = 192 * 1024; /* Total 192kb RAM size. */ copystr("STM32F405/407xx", cpu_model, sizeof(cpu_model), NULL); printf("STM32F405/407xx"); printf(" rev "); switch (revid) { case 0x2000: printf("A"); break; default: printf("unknown 0x%04x", revid); break; } break; case 0x0413: physmem = 192 * 1024; /* Total 192kb RAM size. */ copystr("STM32F405/407xx", cpu_model, sizeof(cpu_model), NULL); printf("STM32F405/407xx"); printf(" rev "); switch (revid) { case 0x1000: printf("A"); break; case 0x1001: printf("Z"); break; case 0x1003: printf("1"); break; case 0x1007: printf("2"); break; case 0x100f: /* Device marking revisions 4 and Y. */ printf("4/Y"); break; case 0x101f: /* Device marking revisions 5 and 6. */ printf("5/6"); break; default: printf("unknown 0x%04x", revid); break; } break; case 0x0421: physmem = 128 * 1024; /* Total 128kb RAM size. */ copystr("STM32F446xx", cpu_model, sizeof(cpu_model), NULL); printf("STM32F446xx"); printf(" rev "); switch (revid) { case 0x1000: /* Device marking revisions 1 and A. */ printf("1/A"); break; default: printf("unknown 0x%04x", revid); break; } break; case 0x0431: physmem = 128 * 1024; /* Total 128kb RAM size. */ copystr("STM32F411xC/E", cpu_model, sizeof(cpu_model), NULL); printf("STM32F411xC/E"); printf(" rev "); switch (revid) { case 0x1000: /* Device marking revisions 1, 2, and A. */ printf("1/2/A"); break; default: printf("unknown 0x%04x", revid); break; } break; case 0x0434: physmem = 384 * 1024; /* Total 384kb RAM size. */ copystr("STM32F469/479xx", cpu_model, sizeof(cpu_model), NULL); printf("STM32F469/479xx"); printf(" rev "); switch (revid) { case 0x1000: /* Device marking revisions 1 and A. */ printf("1/A"); break; default: printf("unknown 0x%04x", revid); break; } break; case 0x0441: physmem = 256 * 1024; /* Total 256kb RAM size. */ copystr("STM32F412xE/G", cpu_model, sizeof(cpu_model), NULL); printf("STM32F412xE/G"); printf(" rev "); switch (revid) { case 0x1001: printf("Z"); break; case 0x2000: printf("B"); break; case 0x3000: /* Device marking revisions 1 and C. */ printf("1/C"); break; default: printf("unknown 0x%04x", revid); break; } break; case 0x0463: physmem = 320 * 1024; /* Total 320kb RAM size. */ copystr("STM32F413xG/H", cpu_model, sizeof(cpu_model), NULL); printf("STM32F413xG/H"); printf(" rev "); switch (revid) { case 0x1000: /* Device marking revisions A and 1. */ printf("A/1"); break; default: printf("unknown 0x%04x", revid); break; } break; default: physmem = 128 * 1024; /* Minimum of 128kb total RAM size. */ copystr("STM32 device unknown", cpu_model, sizeof(cpu_model), NULL); printf("device unknown 0x%04x", devid); printf(" rev unknown 0x%04x", revid); break; } printf(", %u MHz, bus %u MHz\n", CPU_KHZ/1000, BUS_KHZ/1000); printf("oscillator: "); switch (LL_RCC_GetSysClkSource()) { case LL_RCC_SYS_CLKSOURCE_STATUS_HSI: printf("high speed internal\n"); break; case LL_RCC_SYS_CLKSOURCE_STATUS_HSE: printf("high speed external\n"); break; case LL_RCC_SYS_CLKSOURCE_STATUS_PLL: printf("phase-locked loop, clock source: "); switch (LL_RCC_PLL_GetMainSource()) { case LL_RCC_PLLSOURCE_HSI: printf("high speed internal\n"); break; case LL_RCC_PLLSOURCE_HSE: printf("high speed external\n"); break; default: printf("unknown\n"); break; } break; default: printf("unknown\n"); break; } } /* * Check whether the controller has been successfully initialized. */ static int is_controller_alive(struct driver *driver, int unit) { struct conf_ctlr *ctlr; /* No controller - that's OK. */ if (driver == 0) return 1; for (ctlr = conf_ctlr_init; ctlr->ctlr_driver; ctlr++) { if (ctlr->ctlr_driver == driver && ctlr->ctlr_unit == unit && ctlr->ctlr_alive) { return 1; } } return 0; } /* * Configure all controllers and devices as specified * in the kernel configuration file. */ void config(void) { struct conf_ctlr *ctlr; struct conf_device *dev; cpuidentify(); /* Probe and initialize controllers first. */ for (ctlr = conf_ctlr_init; ctlr->ctlr_driver; ctlr++) { if ((*ctlr->ctlr_driver->d_init)(ctlr)) { ctlr->ctlr_alive = 1; } } /* Probe and initialize devices. */ for (dev = conf_device_init; dev->dev_driver; dev++) { if (is_controller_alive(dev->dev_cdriver, dev->dev_ctlr)) { if ((*dev->dev_driver->d_init)(dev)) { dev->dev_alive = 1; } } } } /* * Sit and wait for something to happen... */ void idle(void) { /* Indicate that no process is running. */ noproc = 1; /* Set SPL low so we can be interrupted. */ int x = spl0(); led_control(LED_KERNEL, 0); /* Wait for something to happen. */ __DSB(); __ISB(); __WFI(); /* Restore previous SPL. */ splx(x); } void boot(dev_t dev, int howto) { if ((howto & RB_NOSYNC) == 0 && waittime < 0 && bfreelist[0].b_forw) { struct fs *fp; struct buf *bp; int iter, nbusy; /* * Force the root filesystem's superblock to be updated, * so the date will be as current as possible after * rebooting. */ fp = getfs(rootdev); if (fp) fp->fs_fmod = 1; waittime = 0; printf("syncing disks... "); (void)splnet(); sync(); for (iter = 0; iter < 20; iter++) { nbusy = 0; for (bp = &buf[NBUF]; --bp >= buf;) if (bp->b_flags & B_BUSY) nbusy++; if (nbusy == 0) break; printf("%d ", nbusy); mdelay(40L * iter); } printf("done\n"); } (void)splhigh(); if (!(howto & RB_HALT)) { if ((howto & RB_DUMP) && dumpdev != NODEV) { /* * Take a dump of memory by calling (*dump)(), * which must correspond to dumpdev. * It should dump from dumplo blocks to the end * of memory or to the end of the logical device. */ (*dump)(dumpdev); } /* Restart from dev, howto. */ /* Reset microcontroller. */ NVIC_SystemReset(); /* NOTREACHED */ } printf("halted\n"); #ifdef HALTREBOOT printf("press any key to reboot...\n"); cngetc(); /* Reset microcontroller. */ NVIC_SystemReset(); /* NOTREACHED */ #endif printf("reboot failed; spinning\n"); for (;;) { __DSB(); __ISB(); __WFI(); } /* NOTREACHED */ } /* * Millisecond delay routine. * * Uses SysTick, which must be configured to a 1ms timebase. * This is a busy-wait blocking delay, so be wise with use. */ void mdelay(u_int msec) { LL_mDelay(msec); } /* * Control LEDs, installed on the board. */ void led_control(int mask, int on) { if (mask & LED_TTY) { /* Terminal i/o */ if (on) LED_TTY_ON(); else LED_TTY_OFF(); } if (mask & LED_SWAP) { /* Auxiliary swap */ if (on) LED_SWAP_ON(); else LED_SWAP_OFF(); } if (mask & LED_DISK) { /* Disk i/o */ if (on) LED_DISK_ON(); else LED_DISK_OFF(); } if (mask & LED_KERNEL) { /* Kernel activity */ if (on) LED_KERNEL_ON(); else LED_KERNEL_OFF(); } } /* * Increment user profiling counters. */ void addupc(caddr_t pc, struct uprof *pbuf, int ticks) { u_int indx; if (pc < (caddr_t)pbuf->pr_off) return; indx = pc - (caddr_t)pbuf->pr_off; indx = (indx * pbuf->pr_scale) >> 16; if (indx >= pbuf->pr_size) return; pbuf->pr_base[indx] += ticks; } /* * ffs -- vax ffs instruction */ int ffs(u_long mask) { int cnt; if (mask == 0) return 0; for (cnt = 1; !(mask & 1); cnt++) mask >>= 1; return cnt; } /* * Copy a null terminated string from one point to another. * Returns zero on success, ENOENT if maxlength exceeded. * If lencopied is non-zero, *lencopied gets the length of the copy * (including the null terminating byte). */ int copystr(caddr_t src, caddr_t dest, u_int maxlength, u_int *lencopied) { caddr_t dest0 = dest; int error = ENOENT; if (maxlength != 0) { while ((*dest++ = *src++) != '\0') { if (--maxlength == 0) { /* Failed. */ goto done; } } /* Succeeded. */ error = 0; } done: if (lencopied != 0) *lencopied = dest - dest0; return error; } /* * Calculate the length of a string. */ size_t strlen(const char *s) { const char *s0 = s; while (*s++ != '\0') ; return s - s0 - 1; } /* * Return 0 if a user address is valid. * There is only one memory region allowed for user: RAM. */ int baduaddr(caddr_t addr) { if (addr >= (caddr_t)__user_data_start && addr < (caddr_t)__user_data_end) return 0; return 1; } /* * Return 0 if a kernel address is valid. * There are two memory regions allowed for kernel: RAM and flash. */ int badkaddr(caddr_t addr) { if (addr >= (caddr_t)__kernel_data_start && addr < (caddr_t)__kernel_data_end) return 0; if (addr >= (caddr_t)__kernel_flash_start && addr < (caddr_t)__kernel_flash_end) return 0; return 1; } /* * Insert the specified element into a queue immediately after * the specified predecessor element. */ void insque(void *element, void *predecessor) { struct que { struct que *q_next; struct que *q_prev; }; struct que *e = (struct que *)element; struct que *prev = (struct que *)predecessor; e->q_prev = prev; e->q_next = prev->q_next; prev->q_next->q_prev = e; prev->q_next = e; } /* * Remove the specified element from the queue. */ void remque(void *element) { struct que { struct que *q_next; struct que *q_prev; }; struct que *e = (struct que *)element; e->q_prev->q_next = e->q_next; e->q_next->q_prev = e->q_prev; } /* * Compare strings. */ int strncmp(const char *s1, const char *s2, size_t n) { int ret, tmp; if (n == 0) return 0; do { ret = *s1++ - (tmp = *s2++); } while ((ret == 0) && (tmp != 0) && --n); return ret; } /* Nonzero if pointer is not aligned on a "sz" boundary. */ #define UNALIGNED(p, sz) ((u_int)(p) & ((sz) - 1)) /* * Copy data from the memory region pointed to by src0 to the memory * region pointed to by dst0. * If the regions overlap, the behavior is undefined. */ void bcopy(const void *src0, void *dst0, size_t nbytes) { u_char *dst = dst0; const u_char *src = src0; u_int *aligned_dst; const u_int *aligned_src; /* printf("bcopy (%08x, %08x, %d)\n", src0, dst0, nbytes); */ /* If the size is small, or either SRC or DST is unaligned, * then punt into the byte copy loop. This should be rare. */ if (nbytes >= 4 * sizeof(u_int) && !UNALIGNED(src, sizeof(u_int)) && !UNALIGNED(dst, sizeof(u_int))) { aligned_dst = (u_int *)dst; aligned_src = (const u_int *)src; /* Copy 4X unsigned words at a time if possible. */ while (nbytes >= 4 * sizeof(u_int)) { *aligned_dst++ = *aligned_src++; *aligned_dst++ = *aligned_src++; *aligned_dst++ = *aligned_src++; *aligned_dst++ = *aligned_src++; nbytes -= 4 * sizeof(u_int); } /* Copy one unsigned word at a time if possible. */ while (nbytes >= sizeof(u_int)) { *aligned_dst++ = *aligned_src++; nbytes -= sizeof(u_int); } /* Pick up any residual with a byte copier. */ dst = (u_char *)aligned_dst; src = (const u_char *)aligned_src; } while (nbytes--) *dst++ = *src++; } void * memcpy(void *dst, const void *src, size_t nbytes) { bcopy(src, dst, nbytes); return dst; } /* * Fill the array with zeroes. */ void bzero(void *dst0, size_t nbytes) { u_char *dst; u_int *aligned_dst; dst = (u_char *)dst0; while (UNALIGNED(dst, sizeof(u_int))) { *dst++ = 0; if (--nbytes == 0) return; } if (nbytes >= sizeof(u_int)) { /* * If we get this far, we know that nbytes is large * and dst is word-aligned. */ aligned_dst = (u_int *)dst; while (nbytes >= 4 * sizeof(u_int)) { *aligned_dst++ = 0; *aligned_dst++ = 0; *aligned_dst++ = 0; *aligned_dst++ = 0; nbytes -= 4 * sizeof(u_int); } while (nbytes >= sizeof(u_int)) { *aligned_dst++ = 0; nbytes -= sizeof(u_int); } dst = (u_char *)aligned_dst; } /* Pick up the remainder with a bytewise loop. */ while (nbytes--) *dst++ = 0; } /* * Compare not more than nbytes of data pointed to by m1 with * the data pointed to by m2. * Return an integer greater than, equal to or less than zero * according to whether the object pointed to by m1 is greater * than, equal to or less than the object pointed to by m2. */ int bcmp(const void *m1, const void *m2, size_t nbytes) { const u_char *s1 = (const u_char *)m1; const u_char *s2 = (const u_char *)m2; const u_int *aligned1, *aligned2; /* * If the size is too small, or either pointer is unaligned, * then we punt to the byte compare loop. * Hopefully this will not turn up in inner loops. */ if (nbytes >= 4 * sizeof(u_int) && !UNALIGNED(s1, sizeof(u_int)) && !UNALIGNED(s2, sizeof(u_int))) { /* Otherwise, load and compare the blocks of memory one word at a time. */ aligned1 = (const u_int *)s1; aligned2 = (const u_int *)s2; while (nbytes >= sizeof(u_int)) { if (*aligned1 != *aligned2) break; aligned1++; aligned2++; nbytes -= sizeof(u_int); } /* Check remaining characters. */ s1 = (const u_char *)aligned1; s2 = (const u_char *)aligned2; } while (nbytes--) { if (*s1 != *s2) return *s1 - *s2; s1++; s2++; } return 0; } int copyout(caddr_t from, caddr_t to, u_int nbytes) { /* printf("copyout(from=%p, to=%p, nbytes=%u)\n", from, to, nbytes); */ if (baduaddr(to) || baduaddr(to + nbytes - 1)) return EFAULT; bcopy(from, to, nbytes); return 0; } int copyin(caddr_t from, caddr_t to, u_int nbytes) { if (baduaddr(from) || baduaddr(from + nbytes - 1)) return EFAULT; bcopy(from, to, nbytes); return 0; } /** * @brief Enable AHB1 peripherals clock on dedicated port. * @param GPIOx GPIO Port * @note This function is an extension to the LL_GPIO library. */ void LL_GPIO_EnableClock(GPIO_TypeDef *GPIOx) { /* Check the parameters. */ assert_param(IS_GPIO_ALL_INSTANCE(GPIOx)); if (GPIOx == GPIOA) { LL_AHB1_GRP1_EnableClock(LL_AHB1_GRP1_PERIPH_GPIOA); } else if (GPIOx == GPIOB) { LL_AHB1_GRP1_EnableClock(LL_AHB1_GRP1_PERIPH_GPIOB); } else if (GPIOx == GPIOC) { LL_AHB1_GRP1_EnableClock(LL_AHB1_GRP1_PERIPH_GPIOC); #if defined(GPIOD) } else if (GPIOx == GPIOD) { LL_AHB1_GRP1_EnableClock(LL_AHB1_GRP1_PERIPH_GPIOD); #endif #if defined(GPIOE) } else if (GPIOx == GPIOE) { LL_AHB1_GRP1_EnableClock(LL_AHB1_GRP1_PERIPH_GPIOE); #endif #if defined(GPIOF) } else if (GPIOx == GPIOF) { LL_AHB1_GRP1_EnableClock(LL_AHB1_GRP1_PERIPH_GPIOF); #endif #if defined(GPIOG) } else if (GPIOx == GPIOG) { LL_AHB1_GRP1_EnableClock(LL_AHB1_GRP1_PERIPH_GPIOG); #endif #if defined(GPIOH) } else if (GPIOx == GPIOH) { LL_AHB1_GRP1_EnableClock(LL_AHB1_GRP1_PERIPH_GPIOH); #endif #if defined(GPIOI) } else if (GPIOx == GPIOI) { LL_AHB1_GRP1_EnableClock(LL_AHB1_GRP1_PERIPH_GPIOI); #endif #if defined(GPIOJ) } else if (GPIOx == GPIOJ) { LL_AHB1_GRP1_EnableClock(LL_AHB1_GRP1_PERIPH_GPIOJ); #endif #if defined(GPIOK) } else if (GPIOx == GPIOK) { LL_AHB1_GRP1_EnableClock(LL_AHB1_GRP1_PERIPH_GPIOK); #endif } } ================================================ FILE: sys/arch/stm32/stm32/mpu.c ================================================ /* * Copyright (c) 2025 Christopher Hettrick * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include #include #include #include #include #include #include #include #include int mpu_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, size_t newlen) { /* All sysctl names at this level are terminal. */ if (namelen != 1) return ENOTDIR; switch (name[0]) { case CPU_MPU_ENABLE: return sysctl_rdint(oldp, oldlenp, newp, LL_MPU_IsEnabled()); case CPU_MPU_CTRL: return sysctl_rdint(oldp, oldlenp, newp, LL_MPU_GetCtrl()); case CPU_MPU_NREGIONS: return sysctl_rdint(oldp, oldlenp, newp, LL_MPU_GetNumRegions()); case CPU_MPU_SEPARATE: return sysctl_rdint(oldp, oldlenp, newp, LL_MPU_GetSeparate()); default: return EOPNOTSUPP; } } ================================================ FILE: sys/arch/stm32/stm32/sig_machdep.c ================================================ /* * Copyright (c) 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * * @(#)machdep.c 2.4 (2.11BSD) 1999/9/13 */ #include #include #include #include #include #include #include #include #include #if 0 #define DIAGNOSTIC #endif /* * Send an interrupt to process. * * Stack is set up to allow trampoline code stored at u.u_sigtramp (as * specified by the user process) to call the user's real signal catch * routine, followed by sys sigreturn to the sigreturn routine below * (see lib/libc/arm/sys/sigaction.S). After sigreturn resets the signal * mask, the stack, and the frame pointer, it returns to the user specified * pc and regs. */ void sendsig(sig_t p, int sig, long mask) { struct sigframe { int sf_space[4]; struct sigcontext sf_sc; }; struct trapframe *regs = u.u_frame; struct sigframe *sfp; int oonstack; #ifdef DIAGNOSTIC printf("(%u)sendsig %d, mask=%#x, handler=%#x, tramp=%#x\n", u.u_procp->p_pid, sig, mask, p, u.u_sigtramp); #endif oonstack = u.u_sigstk.ss_flags & SA_ONSTACK; /* * Allocate and validate space for the signal frame. */ if ((u.u_psflags & SAS_ALTSTACK) && !(u.u_sigstk.ss_flags & SA_ONSTACK) && (u.u_sigonstack & sigmask(sig))) { sfp = (struct sigframe *)(u.u_sigstk.ss_base + u.u_sigstk.ss_size); u.u_sigstk.ss_flags |= SA_ONSTACK; } else sfp = (struct sigframe *)regs->tf_sp; sfp--; if (!(u.u_sigstk.ss_flags & SA_ONSTACK)) { if ((caddr_t)sfp < (caddr_t)u.u_procp->p_daddr + u.u_dsize) { /* * Process has trashed its stack; give it an illegal * instruction violation to halt it in its tracks. */ fatalsig(SIGILL); return; } if (u.u_procp->p_ssize < (size_t)__user_data_end - (u_int)sfp) { u.u_procp->p_ssize = (size_t)__user_data_end - (u_int)sfp; u.u_procp->p_saddr = (u_int)sfp; u.u_ssize = u.u_procp->p_ssize; } } /* * Build the signal context to be used by sigreturn. */ sfp->sf_sc.sc_onstack = oonstack; sfp->sf_sc.sc_mask = mask; sfp->sf_sc.sc_r0 = regs->tf_r0; sfp->sf_sc.sc_r1 = regs->tf_r1; sfp->sf_sc.sc_r2 = regs->tf_r2; sfp->sf_sc.sc_r3 = regs->tf_r3; sfp->sf_sc.sc_sp = regs->tf_sp; sfp->sf_sc.sc_lr = regs->tf_lr; sfp->sf_sc.sc_pc = regs->tf_pc; sfp->sf_sc.sc_psr = regs->tf_psr; sfp->sf_sc.sc_r4 = regs->tf_r4; sfp->sf_sc.sc_r5 = regs->tf_r5; sfp->sf_sc.sc_r6 = regs->tf_r6; sfp->sf_sc.sc_r7 = regs->tf_r7; sfp->sf_sc.sc_r8 = regs->tf_r8; sfp->sf_sc.sc_r9 = regs->tf_r9; sfp->sf_sc.sc_r10 = regs->tf_r10; sfp->sf_sc.sc_r11 = regs->tf_r11; /* Call signal handler. */ regs->tf_r0 = sig; /* $a1 - signal number */ regs->tf_r1 = u.u_code; /* $a2 - code */ regs->tf_r2 = (int)&sfp->sf_sc; /* $a3 - addr of sigcontext */ regs->tf_lr = (int)u.u_sigtramp; /* $lr - sigtramp */ regs->tf_sp = (int)sfp; /* $sp - stack */ regs->tf_pc = (int)p; /* $pc - handler */ #ifdef DIAGNOSTIC printf(" ...call handler %p (sig=%d, code=%#x, context=%p)\n", p, sig, u.u_code, &sfp->sf_sc); printf(" ...stack=%p, return to %p\n", sfp, u.u_sigtramp); #endif } /* * System call to cleanup state after a signal * has been taken. Reset signal mask and * stack state from context left by sendsig (above). * Return to previous pc and ps as specified by * context left by sendsig. Check carefully to * make sure that the user has not modified the * ps to gain improper priviledges or to cause * a machine fault. */ void sigreturn(void) { struct trapframe *regs = u.u_frame; struct sigcontext *scp = (struct sigcontext *)(regs->tf_sp + 16); #ifdef DIAGNOSTIC printf("(%u)sigreturn stack=%#x, context=%p\n", u.u_procp->p_pid, regs->tf_sp, scp); #endif if (baduaddr((caddr_t)scp) || baduaddr((caddr_t)scp + sizeof(*scp))) { u.u_error = EFAULT; return; } u.u_error = EJUSTRETURN; if (scp->sc_onstack & SA_ONSTACK) u.u_sigstk.ss_flags |= SA_ONSTACK; else u.u_sigstk.ss_flags &= ~SA_ONSTACK; u.u_procp->p_sigmask = scp->sc_mask & ~sigcantmask; /* Return from signal handler. */ regs->tf_r0 = scp->sc_r0; regs->tf_r1 = scp->sc_r1; regs->tf_r2 = scp->sc_r2; regs->tf_r3 = scp->sc_r3; regs->tf_sp = scp->sc_sp; regs->tf_lr = scp->sc_lr; regs->tf_pc = scp->sc_pc; regs->tf_psr = scp->sc_psr; regs->tf_r4 = scp->sc_r4; regs->tf_r5 = scp->sc_r5; regs->tf_r6 = scp->sc_r6; regs->tf_r7 = scp->sc_r7; regs->tf_r8 = scp->sc_r8; regs->tf_r9 = scp->sc_r9; regs->tf_r10 = scp->sc_r10; regs->tf_r11 = scp->sc_r11; #ifdef DIAGNOSTIC printf(" ...to %#x, stack %#x\n", regs->tf_pc, regs->tf_sp); #endif } ================================================ FILE: sys/arch/stm32/stm32/syscall.c ================================================ /* * Copyright (c) 2022 Christopher Hettrick * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include #include #include #include #include #include #include /* * SVC_Handler(frame) * struct trapframe *frame; * * Exception handler entry point for system calls (via 'svc' instruction). * The real work is done in PendSV_Handler at the lowest exception priority. */ void SVC_Handler(void) { /* Set a PendSV exception to immediately tail-chain into. */ SCB->ICSR |= SCB_ICSR_PENDSVSET_Msk; __DSB(); __ISB(); /* PendSV has lowest priority, so need to allow it to fire. */ (void)spl0(); } /* * PendSV_Handler(frame) * struct trapframe *frame; * * System call handler (via SVC_Handler pending a PendSV exception). * Save the processor state in a trap frame and pass it to syscall(). * Restore processor state from returned trap frame on return from syscall(). */ void PendSV_Handler(void) { __asm volatile ( " .syntax unified \n\t" " .thumb \n\t" " cpsid i \n\t" /* Disable interrupts. */ #ifdef __thumb2__ /* * ARMv7-M hardware already pushed r0-r3, ip, lr, pc, psr on PSP, * and then switched to MSP and is currently in Handler Mode. */ " push {r4-r11} \n\t" /* Push v1-v8 registers onto MSP. */ " mrs r1, PSP \n\t" /* Get pointer to trap frame. */ " ldmfd r1, {r2-r9} \n\t" /* Copy trap frame from PSP. */ " mov r6, r1 \n\t" /* Set trap frame sp as PSP. */ " push {r2-r9} \n\t" /* Push that trap frame onto MSP. */ " mrs r0, MSP \n\t" /* MSP trap frame is syscall() arg. */ " bl syscall \n\t" /* Call syscall() with MSP as arg. */ " pop {r2-r9} \n\t" /* Pop off trap frame from MSP. */ " mov r1, r6 \n\t" /* PSP will be trap frame sp. */ " stmia r1, {r2-r9} \n\t" /* Hardware pops off PSP on return. */ " msr PSP, r1 \n\t" /* Set PSP as trap frame sp. */ " pop {r4-r11} \n\t" /* Pop from MSP into v1-v8 regs. */ /* * On return, ARMv7-M hardware sets PSP as stack pointer, * pops from PSP to registers r0-r3, ip, lr, pc, psr, * and then switches back to Thread Mode (exception completed). */ " mov lr, #0xFFFFFFFD \n\t" /* EXC_RETURN Thread Mode, PSP */ /* Return to Thread Mode. */ #else /* __thumb__ */ /* * ARMv6-M hardware already pushed r0-r3, ip, lr, pc, psr on PSP, * and then switched to MSP and is currently in Handler Mode. */ " mov r0, r8 \n\t" /* Bring high register v5 to low. */ " mov r1, r9 \n\t" /* Bring high register v6 to low. */ " mov r2, r10 \n\t" /* Bring high register v7 to low. */ " mov r3, r11 \n\t" /* Bring high register v8 to low. */ " push {r0-r3} \n\t" /* Push v5-v8 registers onto MSP. */ " push {r4-r7} \n\t" /* Push v1-v4 registers onto MSP. */ " mrs r1, PSP \n\t" /* Get pointer to trap frame. */ " mov r2, r1 \n\t" /* Pointer to use for top half. */ " adds r2, #(4 * 4) \n\t" /* Index to top half of trap frame. */ " ldmfd r2!, {r4-r7} \n\t" /* Copy frame top half from PSP. */ " mov r4, r1 \n\t" /* Set trap frame sp as PSP. */ " push {r4-r7} \n\t" /* Push frame top half onto MSP. */ " ldmfd r1!, {r4-r7} \n\t" /* Copy frame low half from PSP. */ " push {r4-r7} \n\t" /* Push frame low half onto MSP. */ " mrs r0, MSP \n\t" /* MSP trap frame is syscall() arg. */ " bl syscall \n\t" /* Call syscall() with MSP as arg. */ " pop {r0-r7} \n\t" /* Pop off trap frame from MSP. */ " msr PSP, r4 \n\t" /* Set PSP as trap frame sp. */ " stmia r4!, {r0-r3} \n\t" /* Copy trap frame low half to PSP. */ " mrs r1, PSP \n\t" /* Get PSP again as trap frame sp. */ " stmia r4!, {r1,r5-r7} \n\t" /* Copy trap frame top half to PSP. */ " pop {r4-r7} \n\t" /* Pop from MSP into v1-v4 regs. */ " pop {r0-r3} \n\t" /* Pop from MSP for v5-v8 regs. */ " mov r11, r3 \n\t" /* Move low register to high v8. */ " mov r10, r2 \n\t" /* Move low register to high v7. */ " mov r9, r1 \n\t" /* Move low register to high v6. */ " mov r8, r0 \n\t" /* Move low register to high v5. */ /* * On return, ARMv6-M hardware sets PSP as stack pointer, * pops from PSP to registers r0-r3, ip, lr, pc, psr, * and then switches back to Thread Mode (exception completed). */ " ldr r1, =0xFFFFFFFD \n\t" /* EXC_RETURN Thread Mode, PSP */ " mov lr, r1 \n\t" /* Return to Thread Mode. */ #endif ); } void syscall(struct trapframe *frame) { int psig; time_t syst; int code; u_int sp; syst = u.u_ru.ru_stime; if ((u_int)frame < (u_int)&u + sizeof(u)) { panic("stack overflow"); /* NOTREACHED */ } #ifdef UCB_METER cnt.v_trap++; cnt.v_syscall++; #endif /* Enable interrupts. */ (void)arm_intr_enable(); u.u_error = 0; u.u_frame = frame; u.u_code = u.u_frame->tf_pc - INSN_SZ; /* Syscall for sig handler. */ led_control(LED_KERNEL, 1); /* Check stack. */ sp = u.u_frame->tf_sp; if (sp < u.u_procp->p_daddr + u.u_dsize) { /* Process has trashed its stack; give it an illegal * instruction violation to halt it in its tracks. */ psig = SIGSEGV; goto bad; } if (u.u_procp->p_ssize < (size_t)__user_data_end - sp) { /* Expand stack. */ u.u_procp->p_ssize = (size_t)__user_data_end - sp; u.u_procp->p_saddr = sp; u.u_ssize = u.u_procp->p_ssize; } code = *(int *)u.u_code & 0377; /* Bottom 8 bits are index. */ const struct sysent *callp = &sysent[0]; if (code < nsysent) callp += code; if (callp->sy_narg) { /* In AAPCS, first four args are from trapframe regs r0-r3. */ u.u_arg[0] = u.u_frame->tf_r0; /* $a1 */ u.u_arg[1] = u.u_frame->tf_r1; /* $a2 */ u.u_arg[2] = u.u_frame->tf_r2; /* $a3 */ u.u_arg[3] = u.u_frame->tf_r3; /* $a4 */ /* In AAPCS, stack must be double-word aligned. */ int stkalign = 0; if (u.u_frame->tf_psr & SCB_CCR_STKALIGN_Msk) { stkalign = 4; /* Skip over padding byte. */ } /* Remaining args are from the stack, after the trapframe. */ if (callp->sy_narg > 4) { u_int addr = (u.u_frame->tf_sp + 32 + stkalign) & ~3; if (!baduaddr((caddr_t)addr)) u.u_arg[4] = *(u_int *)addr; } if (callp->sy_narg > 5) { u_int addr = (u.u_frame->tf_sp + 36 + stkalign) & ~3; if (!baduaddr((caddr_t)addr)) u.u_arg[5] = *(u_int *)addr; } } u.u_rval = 0; if (setjmp(&u.u_qsave) == 0) { (*callp->sy_call)(); /* Make syscall. */ } switch (u.u_error) { case 0: u.u_frame->tf_psr &= ~PSR_C; /* Clear carry bit. */ u.u_frame->tf_r0 = u.u_rval; /* $a1 - result. */ break; case ERESTART: u.u_frame->tf_pc -= INSN_SZ; /* Return to svc syscall. */ break; case EJUSTRETURN: /* Return from sig handler. */ break; default: u.u_frame->tf_psr |= PSR_C; /* Set carry bit. */ u.u_frame->tf_r0 = u.u_error; /* $a1 - result. */ break; } goto out; bad: /* From this point and further the interrupts must be enabled. */ psignal(u.u_procp, psig); out: userret(u.u_frame->tf_pc, syst); led_control(LED_KERNEL, 0); } ================================================ FILE: sys/arch/stm32/stm32/sysctl.c ================================================ /* * Copyright (c) 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * * @(#)kern_pdp.c 1.4 (2.11BSD) 1998/5/12 */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifdef PTY_ENABLED #include #endif #include #include /* * Errno messages. */ static const char *errlist[] = { "Undefined error: 0", /* 0 - ENOERROR */ "Operation not permitted", /* 1 - EPERM */ "No such file or directory", /* 2 - ENOENT */ "No such process", /* 3 - ESRCH */ "Interrupted system call", /* 4 - EINTR */ "Input/output error", /* 5 - EIO */ "Device not configured", /* 6 - ENXIO */ "Argument list too long", /* 7 - E2BIG */ "Exec format error", /* 8 - ENOEXEC */ "Bad file descriptor", /* 9 - EBADF */ "No child processes", /* 10 - ECHILD */ "No more processes", /* 11 - EAGAIN */ "Cannot allocate memory", /* 12 - ENOMEM */ "Permission denied", /* 13 - EACCES */ "Bad address", /* 14 - EFAULT */ "Block device required", /* 15 - ENOTBLK */ "Device busy", /* 16 - EBUSY */ "File exists", /* 17 - EEXIST */ "Cross-device link", /* 18 - EXDEV */ "Operation not supported by device", /* 19 - ENODEV */ "Not a directory", /* 20 - ENOTDIR */ "Is a directory", /* 21 - EISDIR */ "Invalid argument", /* 22 - EINVAL */ "Too many open files in system", /* 23 - ENFILE */ "Too many open files", /* 24 - EMFILE */ "Inappropriate ioctl for device", /* 25 - ENOTTY */ "Text file busy", /* 26 - ETXTBSY */ "File too large", /* 27 - EFBIG */ "No space left on device", /* 28 - ENOSPC */ "Illegal seek", /* 29 - ESPIPE */ "Read-only file system", /* 30 - EROFS */ "Too many links", /* 31 - EMLINK */ "Broken pipe", /* 32 - EPIPE */ /* math software */ "Numerical argument out of domain", /* 33 - EDOM */ "Result too large", /* 34 - ERANGE */ /* non-blocking and interrupt i/o */ "Resource temporarily unavailable", /* 35 - EWOULDBLOCK */ "Operation now in progress", /* 36 - EINPROGRESS */ "Operation already in progress", /* 37 - EALREADY */ /* ipc/network software -- argument errors */ "Socket operation on non-socket", /* 38 - ENOTSOCK */ "Destination address required", /* 39 - EDESTADDRREQ */ "Message too long", /* 40 - EMSGSIZE */ "Protocol wrong type for socket", /* 41 - EPROTOTYPE */ "Protocol not available", /* 42 - ENOPROTOOPT */ "Protocol not supported", /* 43 - EPROTONOSUPPORT */ "Socket type not supported", /* 44 - ESOCKTNOSUPPORT */ "Operation not supported", /* 45 - EOPNOTSUPP */ "Protocol family not supported", /* 46 - EPFNOSUPPORT */ /* 47 - EAFNOSUPPORT */ "Address family not supported by protocol family", "Address already in use", /* 48 - EADDRINUSE */ "Can't assign requested address", /* 49 - EADDRNOTAVAIL */ /* ipc/network software -- operational errors */ "Network is down", /* 50 - ENETDOWN */ "Network is unreachable", /* 51 - ENETUNREACH */ "Network dropped connection on reset", /* 52 - ENETRESET */ "Software caused connection abort", /* 53 - ECONNABORTED */ "Connection reset by peer", /* 54 - ECONNRESET */ "No buffer space available", /* 55 - ENOBUFS */ "Socket is already connected", /* 56 - EISCONN */ "Socket is not connected", /* 57 - ENOTCONN */ "Can't send after socket shutdown", /* 58 - ESHUTDOWN */ "Too many references: can't splice", /* 59 - ETOOMANYREFS */ "Operation timed out", /* 60 - ETIMEDOUT */ "Connection refused", /* 61 - ECONNREFUSED */ "Too many levels of symbolic links", /* 62 - ELOOP */ "File name too long", /* 63 - ENAMETOOLONG */ /* should be rearranged */ "Host is down", /* 64 - EHOSTDOWN */ "No route to host", /* 65 - EHOSTUNREACH */ "Directory not empty", /* 66 - ENOTEMPTY */ /* quotas & mush */ "Too many processes", /* 67 - EPROCLIM */ "Too many users", /* 68 - EUSERS */ "Disc quota exceeded", /* 69 - EDQUOT */ /* Network File System */ "Stale NFS file handle", /* 70 - ESTALE */ "Too many levels of remote in path", /* 71 - EREMOTE */ "RPC struct is bad", /* 72 - EBADRPC */ "RPC version wrong", /* 73 - ERPCMISMATCH */ "RPC prog. not avail", /* 74 - EPROGUNAVAIL */ "Program version wrong", /* 75 - EPROGMISMATCH */ "Bad procedure for program", /* 76 - EPROCUNAVAIL */ "No locks available", /* 77 - ENOLCK */ "Function not implemented", /* 78 - ENOSYS */ "Inappropriate file type or format", /* 79 - EFTYPE */ "Authentication error", /* 80 - EAUTH */ "Need authenticator", /* 81 - ENEEDAUTH */ }; /* * Kernel symbol name list. */ static const struct { const char *name; int addr; } nlist[] = { { "_boottime", (int)&boottime }, /* vmstat */ { "_cnttys", (int)&cnttys }, /* pstat */ { "_cp_time", (int)&cp_time }, /* iostat vmstat */ { "_dk_busy", (int)&dk_busy }, /* iostat */ { "_dk_name", (int)&dk_name }, /* iostat vmstat */ { "_dk_ndrive", (int)&dk_ndrive }, /* iostat vmstat */ { "_dk_unit", (int)&dk_unit }, /* iostat vmstat */ { "_dk_bytes", (int)&dk_bytes }, /* iostat */ { "_dk_xfer", (int)&dk_xfer }, /* iostat vmstat */ { "_file", (int)&file }, /* pstat */ { "_forkstat", (int)&forkstat }, /* vmstat */ #ifdef UCB_METER { "_freemem", (int)&freemem }, /* vmstat */ #endif { "_hz", (int)&hz }, /* ps */ { "_inode", (int)&inode }, /* pstat */ { "_ipc", (int)&ipc }, /* ps */ { "_lbolt", (int)&lbolt }, /* ps */ { "_memlock", (int)&memlock }, /* ps */ { "_nchstats", (int)&nchstats }, /* vmstat */ { "_nproc", (int)&nproc }, /* ps pstat */ { "_nswap", (int)&nswap }, /* pstat */ { "_proc", (int)&proc }, /* ps pstat */ { "_runin", (int)&runin }, /* ps */ { "_runout", (int)&runout }, /* ps */ { "_selwait", (int)&selwait }, /* ps */ { "_swapmap", (int)&swapmap }, /* pstat */ { "_tk_nin", (int)&tk_nin }, /* iostat */ { "_tk_nout", (int)&tk_nout }, /* iostat */ { "_total", (int)&total }, /* vmstat */ { "_u", (int)&u }, /* ps */ #ifdef PTY_ENABLED { "_npty", (int)&npty }, /* pstat */ { "_pt_tty", (int)&pt_tty }, /* pstat */ #endif #ifdef UCB_METER { "_rate", (int)&rate }, /* vmstat */ { "_sum", (int)&sum }, /* vmstat */ #endif { "_bdevsw", (int)&bdevsw }, /* devupdate */ { "_cdevsw", (int)&cdevsw }, /* devupdate */ { "_nblkdev", (int)&nblkdev }, /* devupdate */ { "_nchrdev", (int)&nchrdev }, /* devupdate */ { 0, 0 }, }; /* * ucall allows user level code to call various kernel functions. * Autoconfig uses it to call the probe and attach routines of the * various device drivers. */ void ucall(void) { struct a { int priority; int (*routine)(); int arg1; int arg2; } *uap = (struct a *)u.u_arg; int s; if (!suser()) return; switch (uap->priority) { case 0: s = spl0(); break; default: s = splhigh(); break; } u.u_rval = (*uap->routine)(uap->arg1, uap->arg2); splx(s); } /* * Fetch the word at addr from flash memory or i/o port. * This system call is required on PIC32 because in user mode * the access to flash memory region is not allowed. */ void ufetch(void) { /* Check root privileges */ if (!suser()) return; /* XXX Not implemented */ u.u_error = EOPNOTSUPP; return; } /* * Store the word at addr of i/o port. */ void ustore(void) { /* Check root privileges */ if (!suser()) return; /* XXX Not implemented */ u.u_error = EOPNOTSUPP; return; } void sc_msec(void) { /* XXX Not implemented */ u.u_rval = 0; } /* * This was moved here when the TMSCP portion was added. At that time it * became (even more) system specific and didn't belong in kern_sysctl.c */ int cpu_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, size_t newlen) { int i, khz; dev_t dev; /* All sysctl names at this level except mpu are terminal. */ switch (name[0]) { case CPU_CONSDEV: if (namelen != 1) return ENOTDIR; dev = makedev(CONS_MAJOR, CONS_MINOR); return sysctl_rdstruct(oldp, oldlenp, newp, &dev, sizeof dev); #if NTMSCP > 0 case CPU_TMSCP: if (namelen != 2) return ENOTDIR; switch (name[1]) { case TMSCP_CACHE: return sysctl_int(oldp, oldlenp, newp, newlen, &tmscpcache); case TMSCP_PRINTF: return sysctl_int(oldp, oldlenp, newp, newlen, &tmscpprintf); default: } #endif case CPU_ERRMSG: if (namelen != 2) return ENOTDIR; if (name[1] < 1 || name[1] >= sizeof(errlist) / sizeof(errlist[0])) return EOPNOTSUPP; return sysctl_string(oldp, oldlenp, 0, 0, (char *)errlist[name[1]], 1 + strlen(errlist[name[1]])); case CPU_NLIST: for (i = 0; nlist[i].name; i++) { if (strncmp(newp, nlist[i].name, newlen) == 0) { int addr = nlist[i].addr; if (!oldp) return 0; if (*oldlenp < sizeof(int)) return ENOMEM; *oldlenp = sizeof(int); return copyout((caddr_t)&addr, (caddr_t)oldp, sizeof(int)); } } return EOPNOTSUPP; case CPU_FREQ_KHZ: if (namelen != 1) return ENOTDIR; khz = CPU_KHZ; return sysctl_rdstruct(oldp, oldlenp, newp, &khz, sizeof khz); case CPU_BUS_KHZ: if (namelen != 1) return ENOTDIR; khz = BUS_KHZ; return sysctl_rdstruct(oldp, oldlenp, newp, &khz, sizeof khz); case CPU_MPU: return mpu_sysctl(name + 1, namelen - 1, oldp, oldlenp, newp, newlen); default: return EOPNOTSUPP; } /* NOTREACHED */ } ================================================ FILE: sys/arch/stm32/stm32/systick.c ================================================ /* * Copyright (c) 2022 Christopher Hettrick * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include #include #include #include #include #include #include #include #include void SysTick_Handler(void) { __asm volatile ( " .syntax unified \n\t" " .thumb \n\t" #ifdef __thumb2__ " tst lr, #0x4 \n\t" /* Test bit 2 (SPSEL) of EXC_RETURN. */ " ite eq \n\t" /* Came from user or kernel mode? */ " mrseq r0, MSP \n\t" /* Kernel mode; stack frame on MSP. */ " mrsne r0, PSP \n\t" /* User mode; stack frame on PSP. */ " b systick \n\t" /* Call systick(frame); */ #else /* __thumb__ */ " movs r0, #0x4 \n\t" /* Test bit 2 (SPSEL).. */ " mov r1, lr \n\t" /* of EXC_RETURN in lr. */ " tst r0, r1 \n\t" /* Came from user or kernel mode? */ " beq 1f \n\t" " mrs r0, PSP \n\t" /* User mode; stack frame on PSP. */ " ldr r1, =systick \n\t" /* Call systick(frame); */ " bx r1 \n\t" "1: mrs r0, MSP \n\t" /* Kernel mode; stack frame on MSP. */ " ldr r1, =systick \n\t" /* Call systick(frame); */ " bx r1 \n\t" #endif ); } /* * Default system time base for Cortex-M. * Internal hardware SysTick interrupt every 1 millisecond. */ void systick(struct clockframe *frame) { HAL_IncTick(); /* Required for HAL driver subsystems. */ hardclock((caddr_t)frame->cf_pc, frame->cf_psr); } ================================================ FILE: sys/conf/newvers.sh ================================================ #!/bin/sh - # # Copyright (c) 1980 Regents of the University of California. # All rights reserved. The Berkeley software License Agreement # specifies the terms and conditions for redistribution. # # Things which need version number upgrades: # sys/conf/newvers.sh: # OSR # sys/sys/param.h: # DiscoBSD # DiscoBSD_X_X # share/mk/sys.mk: # OSMAJOR # OSMINOR # # After a release, move to S="-current" and keep same version number. # Before a release, move to S="-beta" and increment version number. # For a release, move to S="" and keep same version number. OST="DiscoBSD" OSR="2.6" S="-current" #S="-beta" #S="" if [ ! -r .compileversion -o ! -s .compileversion ] then echo 0 >.compileversion fi CV=`cat .compileversion` CV=`expr $CV + 1` if [ ! -r .oldversion -o ! -s .oldversion ] then echo 0 >.oldversion fi OV=`cat .oldversion` GITREV=`git rev-list HEAD --count` GITDIR=`git rev-parse --show-toplevel` if [ "x$GITREV" = "x" ] then GITREV="Untracked" fi if [ "x$GITREV" != "x$OV" ] then CV=1 fi echo $CV >.compileversion echo $GITREV >.oldversion H=`hostname` D=${PWD#$GITDIR} ID=`basename "${D}"` echo $GITREV $CV ${USER-root} $H $D $OST $OSR $ID $S| \ awk '{ gitrev = $1; cv = $2; user = $3; host = $4; dir = $5; date = strftime(); ost = $6; osr = $7; id = toupper($8); status = $9; printf "const char version[] = \"%s %s%s (%s) #%d %s: %s\\n", \ ost, osr, status, id, cv, gitrev, date; printf " %s@%s:%s\\n\";\n", user, host, dir; printf "const char ostype[] = \"%s\";\n", ost; printf "const char osversion[] = \"%s#%d\";\n", id, cv; printf "const char osrelease[] = \"%s\";\n", osr; }' ================================================ FILE: sys/dev/cons.c ================================================ /* * Copyright (c) 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * * @(#)cons.c 1.3 (2.11BSD GTE) 1997/4/25 */ /* * Console driver. */ #include #include #include #include #include #include struct tty cnttys[1]; int cnopen(dev_t cn, int flag, int mode) { dev_t dev = makedev(CONS_MAJOR, CONS_MINOR); return cdevsw[CONS_MAJOR].d_open(dev, flag, mode); } int cnclose(dev_t cn, int flag, int mode) { dev_t dev = makedev(CONS_MAJOR, CONS_MINOR); return cdevsw[CONS_MAJOR].d_close(dev, flag, mode); } int cnread(dev_t cn, struct uio *uio, int flag) { dev_t dev = makedev(CONS_MAJOR, CONS_MINOR); return cdevsw[CONS_MAJOR].d_read(dev, uio, flag); } int cnwrite(dev_t cn, struct uio *uio, int flag) { dev_t dev = makedev(CONS_MAJOR, CONS_MINOR); return cdevsw[CONS_MAJOR].d_write(dev, uio, flag); } int cnselect(dev_t cn, int rw) { dev_t dev = makedev(CONS_MAJOR, CONS_MINOR); return cdevsw[CONS_MAJOR].d_select(dev, rw); } int cnioctl(dev_t cn, u_int cmd, caddr_t addr, int flag) { dev_t dev = makedev(CONS_MAJOR, CONS_MINOR); return cdevsw[CONS_MAJOR].d_ioctl(dev, cmd, addr, flag); } /* * Put a symbol on console terminal. */ void cnputc(char c) { if (cdevsw[CONS_MAJOR].r_write) { dev_t dev = makedev(CONS_MAJOR, CONS_MINOR); cdevsw[CONS_MAJOR].r_write(dev, c); } else { putc(c, &cdevsw[CONS_MAJOR].d_ttys[CONS_MINOR].t_outq); ttstart(&cdevsw[CONS_MAJOR].d_ttys[CONS_MINOR]); ttyflush(&cdevsw[CONS_MAJOR].d_ttys[CONS_MINOR], 0); } if (c == '\n') cnputc('\r'); } /* * Receive a symbol from console terminal. */ int cngetc(void) { if (cdevsw[CONS_MAJOR].r_read) { dev_t dev = makedev(CONS_MAJOR, CONS_MINOR); return cdevsw[CONS_MAJOR].r_read(dev); } else { return getc(&cdevsw[CONS_MAJOR].d_ttys[CONS_MINOR].t_rawq); } } ================================================ FILE: sys/dev/mem.c ================================================ /* * Copyright (c) 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * * @(#)mem.c 1.3 (2.11BSD GTE) 1996/5/15 */ #include #include #include #include #include void kmemdev(void) { u.u_rval = makedev(MEM_MAJOR, 1); } /* * Read/write routine for /dev/mem family. */ int mmrw(dev_t dev, struct uio *uio, int flag) { struct iovec *iov; int error = 0; u_int c; caddr_t addr; #if 0 printf("mmrw(dev=%u, len=%u, flag=%d)\n", dev, uio->uio_iov->iov_len, flag); #endif while (uio->uio_resid && error == 0) { iov = uio->uio_iov; if (iov->iov_len == 0) { uio->uio_iov++; uio->uio_iovcnt--; if (uio->uio_iovcnt < 0) panic("mmrw"); continue; } switch (minor(dev)) { case 0: /* minor device 0 is physical memory (/dev/mem) */ case 1: /* minor device 1 is kernel memory (/dev/kmem) */ addr = (caddr_t)uio->uio_offset; if ((badkaddr(addr) && baduaddr(addr)) || (badkaddr(addr + iov->iov_len - 1) && baduaddr(addr + iov->iov_len - 1))) { error = EFAULT; break; } error = uiomove(addr, iov->iov_len, uio); break; case 2: /* minor device 2 is EOF/RATHOLE (/dev/null) */ if (uio->uio_rw == UIO_READ) return 0; c = iov->iov_len; iov->iov_base += c; iov->iov_len -= c; uio->uio_offset += c; uio->uio_resid -= c; break; case 3: /* minor device 3 is ZERO (/dev/zero) */ if (uio->uio_rw == UIO_WRITE) return EIO; c = iov->iov_len; bzero(iov->iov_base, c); iov->iov_base += c; iov->iov_len -= c; uio->uio_offset += c; uio->uio_resid -= c; break; default: return EINVAL; } } return error; } ================================================ FILE: sys/dev/swap.c ================================================ /* * Simple proxy for swap partition. * * Forwards requests for /dev/swap on to the * device specified by swapdev. */ #include #include #include #include #include #include #include #include #include #include #include #ifndef NTMP #define NTMP 3 #endif extern struct buf *getnewbuf(void); static u_int tdsize[NTMP]; /* Number of blocks allocated */ static u_int tdstart[NTMP]; /* Starting location in map */ extern dev_t swapdev; extern int physio(void (*strat)(struct buf *), struct buf *bp, dev_t dev, int rw, struct uio *uio); extern void swap(size_t blkno, size_t coreaddr, int count, int rdflg); int swopen(dev_t dev, int mode, int flag) { int unit = minor(dev); if (unit == 64) return bdevsw[major(swapdev)].d_open(swapdev, mode, flag); if (unit >= NTMP) return ENODEV; return 0; } int swclose(dev_t dev, int mode, int flag) { int unit = minor(dev); if (unit == 64) return bdevsw[major(swapdev)].d_close(swapdev, mode, flag); if (unit >= NTMP) return ENODEV; return 0; } daddr_t swsize(dev_t dev) { int unit = minor(dev); if (unit == 64) return bdevsw[major(dev)].d_psize(dev); if (unit >= NTMP) return ENODEV; return tdsize[unit]; } int swcopen(dev_t dev, int mode, int flag) { int unit = minor(dev); if (unit >= NTMP) { printf("temp%d: Device number out of range\n", minor(dev)); return ENODEV; } return 0; } int swcclose(dev_t dev, int mode, int flag) { int unit = minor(dev); if (unit >= NTMP) return ENODEV; return 0; } int swcread(dev_t dev, struct uio *uio, int flag) { u_int block; u_int boff; struct buf *bp; u_int rsize; u_int rlen; int unit = minor(dev); if (unit >= NTMP) { printf("temp%d: Device number out of range\n", minor(dev)); return ENODEV; } if (tdstart[unit] == 0) return EIO; if (uio->uio_offset >= tdsize[unit] << 10) return EIO; bp = getnewbuf(); block = uio->uio_offset >> 10; boff = uio->uio_offset - (block << 10); rsize = DEV_BSIZE - boff; rlen = uio->uio_iov->iov_len; while ((rlen > 0) && (block < tdsize[unit])) { swap(tdstart[unit] + block, (size_t)bp->b_addr, DEV_BSIZE, B_READ); uiomove(bp->b_addr + boff, rsize, uio); boff = 0; block++; rlen -= rsize; rsize = rlen >= DEV_BSIZE ? DEV_BSIZE : rlen; } brelse(bp); return 0; } int swcwrite(dev_t dev, struct uio *uio, int flag) { u_int block; u_int boff; struct buf *bp; u_int rsize; u_int rlen; int unit = minor(dev); if (unit >= NTMP) { printf("temp%d: Device number out of range\n", minor(dev)); return ENODEV; } if (tdstart[unit] == 0) { printf("temp%d: attempt to write with no allocation\n", unit); return EIO; } if (uio->uio_offset >= tdsize[unit] << 10) { printf("temp%d: attempt to write past end of allocation\n", unit); return EIO; } bp = getnewbuf(); block = uio->uio_offset >> 10; boff = uio->uio_offset - (block << 10); rsize = DEV_BSIZE - boff; rlen = uio->uio_iov->iov_len; while (rlen > 0 && block < tdsize[unit]) { uiomove(bp->b_addr + boff, rsize, uio); swap(tdstart[unit] + block, (size_t)bp->b_addr, DEV_BSIZE, B_WRITE); boff = 0; block++; rlen -= rsize; rsize = rlen >= DEV_BSIZE ? DEV_BSIZE : rlen; } brelse(bp); return 0; } int swcioctl(dev_t dev, u_int cmd, caddr_t addr, int flag) { u_int *uival; off_t *offtval; int unit = minor(dev); if (unit >= NTMP) { printf("temp%d: Device number out of range\n", minor(dev)); return ENODEV; } uival = (u_int *)addr; offtval = (off_t *)addr; switch (cmd) { case TFALLOC: if (tdstart[unit] > 0) mfree(swapmap, tdsize[unit], tdstart[unit]); if (*offtval > 0) { tdstart[unit] = malloc(swapmap, *offtval); if (tdstart[unit] > 0) { tdsize[unit] = *offtval; /* printf("temp%d: allocated %lu blocks\n", unit, tdsize[unit]); */ return 0; } *offtval = 0; printf("temp%d: failed to allocate %lu blocks\n", tdsize[unit]); return 0; } else { /* printf("temp%d: released allocation\n", unit); */ } break; case DIOCGETMEDIASIZE: *uival = swsize(dev); break; } return EINVAL; } void swstrategy(struct buf *bp) { int unit = minor(bp->b_dev); if (unit == 64) { dev_t od = bp->b_dev; bp->b_dev = swapdev; bdevsw[major(swapdev)].d_strategy(bp); bp->b_dev = od; } else { if (unit >= NTMP) return; if (tdstart[unit] == 0) { printf("swap%d: attempt to access unallocated device\n", unit); return; } if (bp->b_blkno > tdsize[unit]) { printf("swap%d: attempt to access past end of allocation\n", unit); return; } if (bp->b_flags & B_READ) { swap(tdstart[unit] + bp->b_blkno, (size_t)bp->b_addr, bp->b_bcount, B_READ); } else { swap(tdstart[unit] + bp->b_blkno, (size_t)bp->b_addr, bp->b_bcount, B_WRITE); } biodone(bp); } } ================================================ FILE: sys/kern/exec_aout.c ================================================ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include int exec_aout_check(struct exec_params *epp) { int error; DEBUG("\texec_aout_check(): start\n"); if (epp->hdr_len < sizeof(struct exec)) { DEBUG("\texec_aout_check(): error: wrong header length\n"); DEBUG("\texec_aout_check(): end\n"); return ENOEXEC; } if (!(N_GETMID(epp->hdr.aout) == MID_ZERO && N_GETFLAG(epp->hdr.aout) == 0)) { DEBUG("\texec_aout_check(): error: not an a.out\n"); DEBUG("\texec_aout_check(): end\n"); return ENOEXEC; } switch (N_GETMAGIC(epp->hdr.aout)) { case OMAGIC: epp->hdr.aout.a_data += epp->hdr.aout.a_text; epp->hdr.aout.a_text = 0; break; default: printf("Bad a.out magic = %0o\n", N_GETMAGIC(epp->hdr.aout)); return ENOEXEC; } /* * Save arglist */ exec_save_args(epp); DEBUG("\texec_aout_check(): exec file header\n"); /* magic number */ DEBUG("\texec_aout_check(): a_midmag = %#x\n", epp->hdr.aout.a_midmag); /* size of text segment */ DEBUG("\texec_aout_check(): a_text = %d\n", epp->hdr.aout.a_text); /* size of initialized data */ DEBUG("\texec_aout_check(): a_data = %d\n", epp->hdr.aout.a_data); /* size of uninitialized data */ DEBUG("\texec_aout_check(): a_bss = %d\n", epp->hdr.aout.a_bss); /* size of text relocation info */ DEBUG("\texec_aout_check(): a_reltext = %d\n", epp->hdr.aout.a_reltext); /* size of data relocation info */ DEBUG("\texec_aout_check(): a_reldata = %d\n", epp->hdr.aout.a_reldata); /* size of symbol table */ DEBUG("\texec_aout_check(): a_syms = %d\n", epp->hdr.aout.a_syms); /* entry point */ DEBUG("\texec_aout_check(): a_entry = %#x\n", epp->hdr.aout.a_entry); /* * Set up memory allocation */ epp->text.vaddr = epp->heap.vaddr = NO_ADDR; epp->text.len = epp->heap.len = 0; epp->data.vaddr = (caddr_t)__user_data_start; epp->data.len = epp->hdr.aout.a_data; epp->bss.vaddr = epp->data.vaddr + epp->data.len; epp->bss.len = epp->hdr.aout.a_bss; epp->heap.vaddr = epp->bss.vaddr + epp->bss.len; epp->heap.len = 0; epp->stack.len = SSIZE + roundup(epp->argbc + epp->envbc, NBPW) + (epp->argc + epp->envc+4)*NBPW; epp->stack.vaddr = (caddr_t)__user_data_end - epp->stack.len; /* * Allocate core at this point, committed to the new image. * TODO: What to do for errors? */ exec_estab(epp); /* read in text and data */ DEBUG("\texec_aout_check(): reading a.out image\n"); error = rdwri (UIO_READ, epp->ip, (caddr_t)epp->data.vaddr, epp->hdr.aout.a_data, sizeof(struct exec) + epp->hdr.aout.a_text, IO_UNIT, 0); if (error) DEBUG("\texec_aout_check(): error: read image returned: %d\n", error); if (error) { /* * Error - all is lost, when the old image is possible corrupt * and we could not load a new. */ psignal (u.u_procp, SIGSEGV); return error; } exec_clear(epp); exec_setupstack(epp->hdr.aout.a_entry, epp); DEBUG("\texec_aout_check(): end\n"); return 0; } ================================================ FILE: sys/kern/exec_conf.c ================================================ /* * Copyright (c) 1993, 1994 Christopher G. Demetriou * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by Christopher G. Demetriou. * 4. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #include #include int exec_script_check(struct exec_params *epp); int exec_aout_check(struct exec_params *epp); int exec_elf_check(struct exec_params *epp); const struct execsw execsw[] = { { exec_aout_check, "a.out" }, /* a.out binaries */ { exec_elf_check, "elf" }, /* 32bit ELF bins */ { exec_script_check, "script" }, /* shell scripts */ }; int nexecs = (sizeof(execsw) / sizeof(*execsw)); int exec_maxhdrsz; ================================================ FILE: sys/kern/exec_elf.c ================================================ /*- * Copyright (c) 1994 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Christos Zoulas. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the NetBSD * Foundation, Inc. and its contributors. * 4. Neither the name of The NetBSD Foundation nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Copyright (c) 1996 Christopher G. Demetriou * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include extern char sigcode[], esigcode[]; /* round up and down to page boundaries. */ #define ELF_ROUND(a, b) (((a) + (b) - 1) & ~((b) - 1)) #define ELF_TRUNC(a, b) ((a) & ~((b) - 1)) /* * elf_check(): Prepare an Elf binary's exec package * * First, set of the various offsets/lengths in the exec package. * * Then, mark the text image busy (so it can be demand paged) or error * out if this is not possible. Finally, set up vmcmds for the * text, data, bss, and stack segments. */ int exec_elf_check(struct exec_params *epp) { struct elf_phdr *ph; int error, i, phsize; const char elfident[] = {ELFMAG0, ELFMAG1, ELFMAG2, ELFMAG3, ELFCLASS32, ELFDATA2LSB, EV_CURRENT, ELFOSABI_SYSV, 0}; DEBUG("\texec_elf_check(): start\n"); /* * Check that this is an ELF file that we can handle, * and do some sanity checks on the header */ if (epp->hdr_len < sizeof(struct elf_ehdr)) { DEBUG("\texec_elf_check(): error: wrong header length\n"); DEBUG("\texec_elf_check(): end\n"); return ENOEXEC; } for (i = 0; i < sizeof elfident; i++) { if (epp->hdr.elf.e_ident[i] != elfident[i]) { DEBUG("\texec_elf_check(): error: not an elf\n"); DEBUG("\texec_elf_check(): end\n"); return ENOEXEC; } } if (epp->hdr.elf.e_type != ET_EXEC) return ENOEXEC; if (epp->hdr.elf.e_machine != ELF32_MACHDEP_ID || epp->hdr.elf.e_version != EV_CURRENT) return ENOEXEC; if (epp->hdr.elf.e_phentsize != sizeof(struct elf_phdr) || epp->hdr.elf.e_phoff == 0 || epp->hdr.elf.e_phnum == 0) return ENOEXEC; if (epp->hdr.elf.e_shnum == 0 || epp->hdr.elf.e_shentsize != sizeof(struct elf_shdr)) return ENOEXEC; /* * Read program headers */ phsize = epp->hdr.elf.e_phnum * sizeof(struct elf_phdr); ph = exec_alloc(phsize, NBPW, epp); if (ph == NULL) { printf("can't alloc ph[] sz=%d\n", phsize); return ENOEXEC; } if ((error = rdwri(UIO_READ, epp->ip, (caddr_t)ph, phsize, epp->hdr.elf.e_phoff, IO_UNIT, 0)) != 0) return ENOEXEC; epp->text.len = epp->data.len = epp->bss.len = epp->stack.len = epp->heap.len = 0; epp->text.vaddr = epp->data.vaddr = epp->bss.vaddr = epp->stack.vaddr = epp->heap.vaddr = NO_ADDR; if (epp->hdr.elf.e_phnum == 1 && ph[0].p_type == PT_LOAD && ph[0].p_flags == (PF_R|PF_W|PF_X)) { /* * In the simple a.out type link, in elf format, there is only * one loadable segment that is RWE containing everything * Here we fix the memory allocation, and we are done. */ epp->data.vaddr = (caddr_t)ph[0].p_vaddr; epp->data.len = ph[0].p_memsz; epp->heap.vaddr = (caddr_t)ph[0].p_vaddr + ph[0].p_memsz; epp->heap.len = 0; epp->stack.len = SSIZE + epp->argbc + epp->envbc + (epp->argc+epp->envc+4)*NBPW; epp->stack.vaddr = (caddr_t)__user_data_end - epp->stack.len; /* * We assume .bss is the different between the memory data * section size and the file size. */ epp->bss.vaddr = epp->data.vaddr + ph[0].p_filesz; epp->bss.len = ph[0].p_memsz - ph[0].p_filesz; epp->data.len = epp->bss.vaddr - epp->data.vaddr; } else { /* * At the current moment we don't handle anything else * The rest of the code is implemented as need arise. */ return ENOEXEC; } /* * Save arglist */ exec_save_args(epp); /* * Establish memory */ if ((error = exec_estab(epp)) != 0) return error; /* * Now load the program sections into memory */ for (i = 0; i < epp->hdr.elf.e_phnum; i++) { if (ph[i].p_type != PT_LOAD) continue; /* * Sanity check that the load is to our intended address space. */ if (!((epp->text.vaddr != NO_ADDR && ((caddr_t)ph[i].p_vaddr >= epp->text.vaddr && (caddr_t)ph[i].p_vaddr + ph[i].p_filesz <= epp->text.vaddr + epp->text.len)) || (epp->data.vaddr != NO_ADDR && (caddr_t)ph[i].p_vaddr >= epp->data.vaddr && (caddr_t)ph[i].p_vaddr + ph[i].p_filesz <= epp->data.vaddr + epp->data.len)) || ph[i].p_filesz >= ph[i].p_memsz || ph[i].p_filesz <= 0) return ENOEXEC; error = rdwri(UIO_READ, epp->ip, (caddr_t)ph[i].p_vaddr, ph[i].p_filesz, ph[i].p_offset, IO_UNIT, 0); } exec_clear(epp); exec_setupstack(epp->hdr.elf.e_entry, epp); DEBUG("\texec_elf_check(): end\n"); return 0; } ================================================ FILE: sys/kern/exec_script.c ================================================ #include #include #include #include #include #include #include #include int exec_script_check(struct exec_params *epp) { char *cp; struct nameidata nd; struct nameidata *ndp; int error; struct inode *ip = 0; DEBUG("\texec_script_check(): start\n"); /* * We come here with the first line of the executable * script file. * Check is to see if it starts with the magic marker: #! */ if (epp->hdr.sh[0] != '#' || epp->hdr.sh[1] != '!' || epp->sh.interpreted) return ENOEXEC; epp->sh.interpreted = 1; /* * If setuid/gid scripts were to be disallowed this is where it would * have to be done. * u.u_uid = uid; * u.u_gid = u_groups[0]; */ /* * The first line of the text file * should be one line on the format: * #! \n */ cp = &epp->hdr.sh[2]; while (cp < &epp->hdr.sh[MIN(epp->hdr_len, SHSIZE)]) { if (*cp == '\t') *cp = ' '; else if (*cp == '\n') { *cp = '\0'; break; } cp++; } if (cp == &epp->hdr.sh[MIN(epp->hdr_len, SHSIZE)]) return ENOEXEC; /* * Pick up script interpreter file name */ cp = &epp->hdr.sh[2]; while (*cp == ' ') cp++; if (!*cp) return ENOEXEC; bzero(&nd, sizeof nd); ndp = &nd; ndp->ni_dirp = cp; while (*cp && *cp != ' ') cp++; if (*cp != '\0') { *cp++ = 0; while (*cp && *cp == ' ') cp++; if (*cp) { if ((error = copystr(cp, epp->sh.interparg, sizeof epp->sh.interparg, NULL))) goto done; } } /* * the interpreter is the new file to exec */ ndp->ni_nameiop = LOOKUP | FOLLOW; ip = namei (ndp); if (ip == NULL) return u.u_error; if ((error = copystr(ndp->ni_dent.d_name, epp->sh.interpname, sizeof epp->sh.interpname, NULL))) goto done; /* * Everything set up, do the recursive exec() */ DEBUG("\texec_script_check(): do recursive exec\n"); epp->ip = ip; error = exec_check(epp); done: if (ip) iput(ip); DEBUG("\texec_script_check(): end\n"); return error; } ================================================ FILE: sys/kern/exec_subr.c ================================================ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include /* * How memory is set up. * * var a: *__user_data_end:!----------! * ! +P_ssize ! stack * p_saddr -> !----------! * * !----------! * ! +P_dsize ! .data + .bss + heap * P_daddr -> !----------! * * var b: * *__user_data_end:!--------! * ! +ssize ! stack * saddr -> !--------! * ! +hsize ! heap * haddr -> !--------! * ! +dsize ! .data + .bss * daddr -> !--------! * ! +tsize ! .text * taddr -> !--------! * paddr -> +psize * * var c: * !--------! * ! +tsize ! .text (read only section) * taddr -> !--------! * ! +ssize ! stack * saddr -> !--------! * ! +hsize ! heap * haddr -> !--------! * ! +dsize ! .data + .bss * daddr -> !--------! * paddr -> +psize */ /* * Set up user memory. * * The following is a key to top of the stack and the variables used. * * topp-> [argv] top word for /bin/ps * <0> * n * g * r * a * ... * <0> * 0 * g * r * ucp -> a * [0] * [envn] * ... * envp -> [env0] * [0] * [argn] ptr to argn * ... * argp -> [arg0] ptr to arg0 * [] \ * [] | 16 bytes for Mips * [] | 64 bytes for Arm * sp -> [] / * */ void exec_setupstack(unsigned entryaddr, struct exec_params *epp) { int nc,i; u_int len; char *ucp; char **argp, **envp, ***topp; DEBUG("\texec_setupstack(): start\n"); /* * Set up top of stack structure as above * This depends on that kernel and user spaces * map to the same addresses. */ topp = (char ***)(epp->stack.vaddr + epp->stack.len - NBPW); /* Last word of RAM */ ucp = (char *)((unsigned)topp - roundup(epp->envbc + epp->argbc,NBPW)); /* arg string space */ envp = (char **)(ucp - (epp->envc+1)*NBPW); /* Make place for envp[...], +1 for the 0 */ argp = envp - (epp->argc+1)*NBPW; /* Make place for argv[...] */ #ifdef __mips__ u.u_frame->tf_sp = (int)(argp-16); u.u_frame->tf_r4 = epp->argc; /* $a0 := argc */ u.u_frame->tf_r5 = (int)argp; /* $a1 := argp */ u.u_frame->tf_r6 = (int)envp; /* $a2 := env */ #elif __thumb2__ || __thumb__ u.u_frame->tf_sp = (int)(argp-0x40); /* 0x40 for svc trap frame. */ u.u_frame->tf_r0 = epp->argc; /* $a1 := argc */ u.u_rval = epp->argc; /* $a1 := argc via syscall() */ u.u_frame->tf_r1 = (int)argp; /* $a2 := argp */ u.u_frame->tf_r2 = (int)envp; /* $a3 := envp */ u.u_frame->tf_lr = 0xffffffff; /* lr, set -1 (reset value) */ u.u_frame->tf_psr = 0x01000000; /* psr, Thumb state bit set */ #else #error "set up top of stack for unknown architecture" #endif *topp = argp; /* for /bin/ps */ /* * copy the arguments into the structure */ nc = 0; for (i = 0; i < epp->argc; i++) { argp[i] = (caddr_t)ucp; if (copystr((caddr_t)epp->argp[i], (caddr_t)ucp, (caddr_t)topp-ucp, &len) == 0) { nc += len; ucp += len; } } argp[epp->argc] = NULL; for (i = 0; i < epp->envc; i++) { envp[i] = ucp; if (copystr((caddr_t)epp->envp[i], (caddr_t)ucp, (caddr_t)topp-ucp, &len) == 0) { nc += len; ucp += len; } } envp[epp->envc] = NULL; ucp = (caddr_t)roundup((unsigned)ucp, NBPW); if ((caddr_t)ucp != (caddr_t)topp) { DEBUG("\texec_setupstack(): error: copy arg list, ucp = %#x, topp = %#x\n", ucp, topp); panic("exec check"); } u.u_frame->tf_pc = entryaddr; DEBUG("\texec_setupstack(): new PC = %#x\n", entryaddr); /* * Remember file name for accounting. */ (void) copystr(argp[0], u.u_comm, MAXCOMLEN, 0); DEBUG("\texec_setupstack(): end\n"); } /* * A simple memory allocator used within exec code using file buffers as storage. * Will return NULL if allocation is not possible. * Total max memory allocatable is MAXALLOCBUF*MAXBSIZE * Max size of allocatable chunk is MAXBSIZE * * All memory allocated with this function will be freed by a call * to exec_alloc_freeall() */ void *exec_alloc(int size, int ru, struct exec_params *epp) { char *cp; int i; for (i = 0; i < MAXALLOCBUF; i++) if (MAXBSIZE - (ru<=1?epp->alloc[i].fill:roundup(epp->alloc[i].fill,ru)) >= size) break; if (i == MAXALLOCBUF) return NULL; if (epp->alloc[i].bp == NULL) { if ((epp->alloc[i].bp = geteblk()) == NULL) { DEBUG("\texec_alloc(): no buf\n"); return NULL; } } if (ru > 1) epp->alloc[i].fill = roundup(epp->alloc[i].fill, ru); cp = epp->alloc[i].bp->b_addr + epp->alloc[i].fill; epp->alloc[i].fill += size; bzero (cp, size); return cp; } /* * this will deallocate all memory allocated by exec_alloc */ void exec_alloc_freeall(struct exec_params *epp) { int i; for (i = 0; i < MAXALLOCBUF; i++) { if (epp->alloc[i].bp) { brelse(epp->alloc[i].bp); epp->alloc[i].bp = NULL; epp->alloc[i].fill = 0; } } } /* * Establish memory for the image based on the * values picked up from the executable file and stored * in the exec params block. */ int exec_estab(struct exec_params *epp) { DEBUG("\texec_estab(): start\n"); DEBUG("\texec_estab(): text = %#x..%#x, len = %d\n", epp->text.vaddr, epp->text.vaddr + epp->text.len, epp->text.len); DEBUG("\texec_estab(): data = %#x..%#x, len = %d\n", epp->data.vaddr, epp->data.vaddr + epp->data.len, epp->data.len); DEBUG("\texec_estab(): bss = %#x..%#x, len = %d\n", epp->bss.vaddr, epp->bss.vaddr + epp->bss.len, epp->bss.len); DEBUG("\texec_estab(): heap = %#x..%#x, len = %d\n", epp->heap.vaddr, epp->heap.vaddr + epp->heap.len, epp->heap.len); DEBUG("\texec_estab(): stack = %#x..%#x, len = %d\n", epp->stack.vaddr, epp->stack.vaddr + epp->stack.len, epp->stack.len); /* * Right now we can only handle the simple original a.out * case, so we double check for that case here. */ if (epp->text.vaddr != NO_ADDR || epp->data.vaddr == NO_ADDR || epp->data.vaddr != (caddr_t)__user_data_start || epp->stack.vaddr != (caddr_t)__user_data_end - epp->stack.len) { DEBUG("\texec_estab(): error: not an a.out executable\n"); return ENOMEM; } /* * Try out for overflow */ if (epp->text.len + epp->data.len + epp->heap.len + epp->stack.len > MAXMEM) { DEBUG("\texec_estab(): error: memory overflow\n"); return ENOMEM; } if (roundup((unsigned)epp->data.vaddr + epp->data.len, NBPW) != roundup((unsigned)epp->bss.vaddr, NBPW)) { DEBUG("\texec_estab(): error: .bss does not follow .data\n"); return ENOMEM; } /* * Allocate core at this point, committed to the new image. */ u.u_prof.pr_scale = 0; if (u.u_procp->p_flag & SVFORK) endvfork(); u.u_procp->p_dsize = epp->data.len + epp->bss.len; u.u_procp->p_daddr = (size_t)epp->data.vaddr; u.u_procp->p_ssize = epp->stack.len; u.u_procp->p_saddr = (size_t)epp->stack.vaddr; DEBUG("\texec_estab(): core allocation\n"); DEBUG("\texec_estab(): daddr = %#x..%#x, len = %d\n", u.u_procp->p_daddr, u.u_procp->p_daddr + u.u_procp->p_dsize, u.u_procp->p_dsize); DEBUG("\texec_estab(): saddr = %#x..%#x, len = %d\n", u.u_procp->p_saddr, u.u_procp->p_saddr + u.u_procp->p_ssize, u.u_procp->p_ssize); DEBUG("\texec_estab(): end\n"); return 0; } /* * Save argv[] and envp[] */ void exec_save_args(struct exec_params *epp) { unsigned len; caddr_t cp; int argc, i, l; char **argp, *ap; DEBUG("\texec_save_args(): start\n"); epp->argc = epp->envc = 0; epp->argbc = epp->envbc = 0; argc = 0; if ((argp = epp->userargp) != NULL) while (argp[argc]) argc++; if (epp->sh.interpreted) { argc++; if (epp->sh.interparg[0]) argc++; } if (argc != 0) { if ((epp->argp = (char **)exec_alloc(argc * sizeof(char *), NBPW, epp)) == NULL) return; for (;;) { /* * For a interpreter script, the arg list is changed to * #! * arg[0] - the interpreter executable name (path) * arg[1] - interpreter arg (optional) * arg[2 or 1] - script name * arg[3 or 2...] - script arg[1...] */ if (argp) ap = *argp++; else ap = NULL; if (epp->sh.interpreted) { if (epp->argc == 0) ap = epp->sh.interpname; else if (epp->argc == 1 && epp->sh.interparg[0]) { ap = epp->sh.interparg; --argp; } else if ((epp->argc == 1 || (epp->argc == 2 && epp->sh.interparg[0]))) { ap = epp->userfname; --argp; } } if (ap == 0) break; l = strlen(ap)+1; if ((cp = exec_alloc(l, 1, epp)) == NULL) return; if (copystr(ap, cp, l, &len) != 0) return; epp->argp[epp->argc++] = cp; epp->argbc += len;; } } argc = 0; if ((argp = epp->userenvp) != NULL) while (argp[argc]) argc++; epp->envc = 0; epp->envbc = 0; if (argc != 0) { if ((epp->envp = (char **)exec_alloc(argc * sizeof(char *), NBPW, epp)) == NULL) return; for (;;) { if (argp) ap = *argp++; else ap = NULL; if (ap == 0) break; l = strlen(ap)+1; if ((cp = exec_alloc(l, 1, epp)) == NULL) return; if (copystr(ap, cp, l, &len) != 0) return; epp->envp[epp->envc++] = cp; epp->envbc += len; } } for (i = 0; i < epp->argc; i++) DEBUG("\texec_save_args(): arg[%d] = \"%s\"\n", i, epp->argp[i]); for (i = 0; i < epp->envc; i++) DEBUG("\texec_save_args(): env[%d] = \"%s\"\n", i, epp->envp[i]); DEBUG("\texec_save_args(): end\n"); } void exec_clear(struct exec_params *epp) { char *cp; int cc; DEBUG("\texec_clear(): start\n"); /* clear BSS */ if (epp->bss.len > 0) bzero((void *)epp->bss.vaddr, epp->bss.len); if (epp->heap.len > 0) bzero((void *)epp->heap.vaddr, epp->heap.len); /* Clear stack */ bzero((void *)epp->stack.vaddr, epp->stack.len); /* * set SUID/SGID protections, if no tracing */ if ((u.u_procp->p_flag & P_TRACED) == 0) { u.u_uid = epp->uid; u.u_procp->p_uid = epp->uid; u.u_groups[0] = epp->gid; } else psignal (u.u_procp, SIGTRAP); u.u_svuid = u.u_uid; u.u_svgid = u.u_groups[0]; u.u_tsize = epp->text.len; u.u_dsize = epp->data.len + epp->bss.len; u.u_ssize = epp->stack.len; /* * Clear registers. */ #ifdef __mips__ u.u_frame->tf_r1 = 0; /* $at */ u.u_frame->tf_r2 = 0; /* $v0 */ u.u_frame->tf_r3 = 0; /* $v1 */ u.u_frame->tf_r7 = 0; /* $a3 */ u.u_frame->tf_r8 = 0; /* $t0 */ u.u_frame->tf_r9 = 0; /* $t1 */ u.u_frame->tf_r10 = 0; /* $t2 */ u.u_frame->tf_r11 = 0; /* $t3 */ u.u_frame->tf_r12 = 0; /* $t4 */ u.u_frame->tf_r13 = 0; /* $t5 */ u.u_frame->tf_r14 = 0; /* $t6 */ u.u_frame->tf_r15 = 0; /* $t7 */ u.u_frame->tf_r16 = 0; /* $s0 */ u.u_frame->tf_r17 = 0; /* $s1 */ u.u_frame->tf_r18 = 0; /* $s2 */ u.u_frame->tf_r19 = 0; /* $s3 */ u.u_frame->tf_r20 = 0; /* $s4 */ u.u_frame->tf_r21 = 0; /* $s5 */ u.u_frame->tf_r22 = 0; /* $s6 */ u.u_frame->tf_r23 = 0; /* $s7 */ u.u_frame->tf_r24 = 0; /* $t8 */ u.u_frame->tf_r25 = 0; /* $t9 */ u.u_frame->tf_fp = 0; u.u_frame->tf_ra = 0; u.u_frame->tf_lo = 0; u.u_frame->tf_hi = 0; u.u_frame->tf_gp = 0; #elif __thumb2__ || __thumb__ u.u_frame->tf_r0 = 0; /* a1 */ u.u_frame->tf_r1 = 0; /* a2 */ u.u_frame->tf_r2 = 0; /* a3 */ u.u_frame->tf_r3 = 0; /* a4 */ u.u_frame->tf_ip = 0; /* sp, as passed as ip */ u.u_frame->tf_lr = 0; /* lr */ u.u_frame->tf_pc = 0; /* pc */ u.u_frame->tf_psr = 0; /* psr */ u.u_frame->tf_r4 = 0; /* v1 */ u.u_frame->tf_r5 = 0; /* v2 */ u.u_frame->tf_r6 = 0; /* v3 */ u.u_frame->tf_r7 = 0; /* v4 */ u.u_frame->tf_r8 = 0; /* v5 */ u.u_frame->tf_r9 = 0; /* v6 */ u.u_frame->tf_r10 = 0; /* v7 */ u.u_frame->tf_r11 = 0; /* v8 */ #else #error "clear trap frame registers for unknown architecture" #endif execsigs (u.u_procp); /* * Clear (close) files */ for (cp = u.u_pofile, cc = 0; cc <= u.u_lastfile; cc++, cp++) { if (*cp & UF_EXCLOSE) { (void) closef (u.u_ofile [cc]); u.u_ofile [cc] = NULL; *cp = 0; } } while (u.u_lastfile >= 0 && u.u_ofile [u.u_lastfile] == NULL) u.u_lastfile--; DEBUG("\texec_clear(): end\n"); } ================================================ FILE: sys/kern/init_main.c ================================================ /* * Copyright (c) 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * * @(#)init_main.c 2.5 (2.11BSD GTE) 1997/9/26 */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include static void bhinit(void); static void binit(void); static void cinit(void); u_int swapstart, nswap; /* start and size of swap space */ size_t physmem; /* total amount of physical memory */ int boothowto; /* reboot flags, from boot */ /* * Initialization code. * Called from cold start routine as * soon as a stack and segmentation * have been established. * Functions: * clear and free user core * turn on clock * hand craft 0th process * call all initialization routines * fork - process 0 to schedule * - process 1 execute bootstrap */ int main(void) { struct proc *p; int i; struct fs *fs = NULL; int s __attribute__((unused)); startup(); printf("\n%s", version); config(); /* * Set up system process 0 (swapper). */ p = &proc[0]; p->p_addr = (size_t)&u; p->p_stat = SRUN; p->p_flag |= SLOAD | SSYS; p->p_nice = NZERO; u.u_procp = p; /* init user structure */ u.u_cmask = CMASK; u.u_lastfile = -1; for (i = 1; i < NGROUPS; i++) u.u_groups[i] = NOGROUP; for (i = 0; i < sizeof(u.u_rlimit)/sizeof(u.u_rlimit[0]); i++) u.u_rlimit[i].rlim_cur = u.u_rlimit[i].rlim_max = RLIM_INFINITY; /* Initialize signal state for process 0 */ siginit(p); /* * Initialize tables, protocols, and set up well-known inodes. */ #ifdef LOG_ENABLED loginit(); #endif coutinit(); cinit(); pqinit(); ihinit(); bhinit(); binit(); nchinit(); clkstart(); pipedev = rootdev; /* Attach services. */ struct conf_service *svc; for (svc = conf_service_init; svc->svc_attach != NULL; svc++) (*svc->svc_attach)(); /* Mount a root filesystem. */ s = spl0(); fs = mountfs(rootdev, (boothowto & RB_RDONLY) ? MNT_RDONLY : 0, 0); if (!fs) panic("No root filesystem found!"); mount[0].m_inodp = (struct inode *)1; /* XXX */ mount_updname(fs, "/", "root", 1, 4); time.tv_sec = fs->fs_time; boottime = time; /* Find a swap file. */ swapstart = 1; (*bdevsw[major(swapdev)].d_open)(swapdev, FREAD|FWRITE, S_IFBLK); nswap = (*bdevsw[major(swapdev)].d_psize)(swapdev); if (nswap <= 0) panic("swap size"); /* don't want to panic, but what ? */ mfree(swapmap, nswap, swapstart); printf("phys mem = %u kbytes\n", physmem / 1024); printf("user mem = %u kbytes\n", MAXMEM / 1024); printf("root dev = (%d,%d)\n", major(rootdev), minor(rootdev)); printf("swap dev = (%d,%d)\n", major(swapdev), minor(swapdev)); printf("root size = %u kbytes\n", fs->fs_fsize * DEV_BSIZE / 1024); printf("swap size = %u kbytes\n", nswap * DEV_BSIZE / 1024); /* Kick off timeout driven events by calling first time. */ schedcpu(0); /* Set up the root file system. */ rootdir = iget(rootdev, &mount[0].m_filsys, (ino_t)ROOTINO); iunlock(rootdir); u.u_cdir = iget(rootdev, &mount[0].m_filsys, (ino_t)ROOTINO); iunlock(u.u_cdir); u.u_rdir = NULL; /* * Make init process. */ if (newproc(0) == 0) { /* Parent process with pid 0: swapper. */ /* No return from sched. */ sched(); } /* Child process with pid 1: init. */ s = splhigh(); p = u.u_procp; p->p_dsize = icodeend - icode; p->p_daddr = (size_t)__user_data_start; p->p_ssize = 1024; /* One kbyte of stack. */ p->p_saddr = (size_t)__user_data_end - 1024; bcopy((caddr_t)icode, (caddr_t)__user_data_start, icodeend - icode); /* Start in single user mode, if asked. */ if (boothowto & RB_SINGLE) { char *iflags = (char *)__user_data_start + (initflags - icode); /* Call /sbin/init with option '-s'. */ iflags[1] = 's'; } /* * return goes to location 0 of user init code * just copied out. */ return 0; } /* * Initialize hash links for buffers. */ static void bhinit(void) { int i; struct bufhd *bp; for (bp = bufhash, i = 0; i < BUFHSZ; i++, bp++) bp->b_forw = bp->b_back = (struct buf *)bp; } /* * Initialize the buffer I/O system by freeing * all buffers and setting all device buffer lists to empty. */ static void binit(void) { struct buf *bp; int i; caddr_t paddr; for (bp = bfreelist; bp < &bfreelist[BQUEUES]; bp++) bp->b_forw = bp->b_back = bp->av_forw = bp->av_back = bp; paddr = bufdata; for (i = 0; i < NBUF; i++, paddr += MAXBSIZE) { bp = &buf[i]; bp->b_dev = NODEV; bp->b_bcount = 0; bp->b_addr = paddr; binshash(bp, &bfreelist[BQ_AGE]); bp->b_flags = B_BUSY|B_INVAL; brelse(bp); } } /* * Initialize clist by freeing all character blocks, then count * number of character devices. (Once-only routine) */ static void cinit(void) { int ccp; struct cblock *cp; ccp = (int)cfree; ccp = (ccp + CROUND) & ~CROUND; for (cp = (struct cblock *)ccp; cp <= &cfree[NCLIST - 1]; cp++) { cp->c_next = cfreelist; cfreelist = cp; cfreecount += CBSIZE; } } ================================================ FILE: sys/kern/init_sysent.c ================================================ /* * System call switch table. * * Copyright (c) 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include #include #include #ifdef INET # define ifnet(narg, name) narg, name # define errnet(narg, name) narg, name #else # define ifnet(narg, name) 0, nosys # define errnet(narg, name) 0, nonet #endif extern void sc_msec(); /* * Reserved/unimplemented system calls in the range 0-150 inclusive * are reserved for use in future Berkeley releases. * Additional system calls implemented in vendor and other * redistributions should be placed in the reserved range at the end * of the current calls. */ /* * This table is the switch used to transfer to the appropriate routine for * processing a system call. Each row contains the number of words of * arguments expected in registers, how many on the stack, and a pointer to * the routine. * * The maximum number of direct system calls is 255 since system call numbers * are encoded in the lower byte of the trap instruction -- see trap.c. */ const struct sysent sysent[] = { { 1, nosys }, /* 0 = out-of-range */ { 1, rexit }, /* 1 = exit */ { 0, fork }, /* 2 = fork */ { 3, read }, /* 3 = read */ { 3, write }, /* 4 = write */ { 3, open }, /* 5 = open */ { 1, close }, /* 6 = close */ { 4, wait4 }, /* 7 = wait4 */ { 0, nosys }, /* 8 = (old creat) */ { 2, link }, /* 9 = link */ { 1, unlink }, /* 10 = unlink */ { 2, execv }, /* 11 = execv */ { 1, chdir }, /* 12 = chdir */ { 1, fchdir }, /* 13 = fchdir */ { 3, mknod }, /* 14 = mknod */ { 2, chmod }, /* 15 = chmod */ { 3, chown }, /* 16 = chown; now 3 args */ { 2, chflags }, /* 17 = chflags */ { 2, fchflags }, /* 18 = fchflags */ { 4, lseek }, /* 19 = lseek */ { 0, getpid }, /* 20 = getpid */ { 3, smount }, /* 21 = mount */ { 1, umount }, /* 22 = umount */ { 6, __sysctl }, /* 23 = __sysctl */ { 0, getuid }, /* 24 = getuid */ { 0, geteuid }, /* 25 = geteuid */ { 4, ptrace }, /* 26 = ptrace */ { 0, getppid }, /* 27 = getppid */ { 2, statfs }, /* 28 = statfs */ { 2, fstatfs }, /* 29 = fstatfs */ { 3, getfsstat }, /* 30 = getfsstat */ { 4, sigaction }, /* 31 = sigaction */ { 3, sigprocmask }, /* 32 = sigprocmask */ { 2, saccess }, /* 33 = access */ { 1, sigpending }, /* 34 = sigpending */ { 2, sigaltstack }, /* 35 = sigaltstack */ { 0, sync }, /* 36 = sync */ { 2, kill }, /* 37 = kill */ { 2, stat }, /* 38 = stat */ { 2, nosys }, /* 39 = getlogin */ { 2, lstat }, /* 40 = lstat */ { 1, dup }, /* 41 = dup */ { 0, pipe }, /* 42 = pipe */ { 1, nosys }, /* 43 = setlogin */ { 4, profil }, /* 44 = profil */ { 1, setuid }, /* 45 = setuid */ { 1, seteuid }, /* 46 = seteuid */ { 0, getgid }, /* 47 = getgid */ { 0, getegid }, /* 48 = getegid */ { 1, setgid }, /* 49 = setgid */ { 1, setegid }, /* 50 = setegid */ { 0, kmemdev }, /* 51 = kmemdev */ { 3, nosys }, /* 52 = (2.9) set phys addr */ { 1, nosys }, /* 53 = (2.9) lock in core */ { 4, ioctl }, /* 54 = ioctl */ { 1, reboot }, /* 55 = reboot */ { 2, sigwait }, /* 56 = sigwait */ { 2, symlink }, /* 57 = symlink */ { 3, readlink }, /* 58 = readlink */ { 3, execve }, /* 59 = execve */ { 1, umask }, /* 60 = umask */ { 1, chroot }, /* 61 = chroot */ { 2, fstat }, /* 62 = fstat */ { 0, nosys }, /* 63 = reserved */ { 0, nosys }, /* 64 = (old getpagesize) */ { 6, pselect }, /* 65 = pselect */ { 0, vfork }, /* 66 = vfork */ { 0, nosys }, /* 67 = unused */ { 0, nosys }, /* 68 = unused */ { 1, brk }, /* 69 = brk */ #ifdef GLOB_ENABLED { 1, rdglob }, /* 70 = read from global */ { 2, wrglob }, /* 71 = write to global */ #else { 1, nosys }, { 2, nosys }, #endif { 0, sc_msec }, /* 72 = msec */ { 0, nosys }, /* 73 = unused */ { 0, nosys }, /* 74 = unused */ { 0, nosys }, /* 75 = unused */ { 0, vhangup }, /* 76 = vhangup */ { 0, nosys }, /* 77 = unused */ { 0, nosys }, /* 78 = unused */ { 2, getgroups }, /* 79 = getgroups */ { 2, setgroups }, /* 80 = setgroups */ { 1, getpgrp }, /* 81 = getpgrp */ { 2, setpgrp }, /* 82 = setpgrp */ { 3, setitimer }, /* 83 = setitimer */ { 0, nosys }, /* 84 = (old wait,wait3) */ { 0, nosys }, /* 85 = unused */ { 2, getitimer }, /* 86 = getitimer */ { 0, nosys }, /* 87 = (old gethostname) */ { 0, nosys }, /* 88 = (old sethostname) */ { 0, getdtablesize }, /* 89 = getdtablesize */ { 2, dup2 }, /* 90 = dup2 */ { 0, nosys }, /* 91 = unused */ { 3, fcntl }, /* 92 = fcntl */ { 5, select }, /* 93 = select */ { 0, nosys }, /* 94 = unused */ { 1, fsync }, /* 95 = fsync */ { 3, setpriority }, /* 96 = setpriority */ { errnet(3, socket) }, /* 97 = socket */ { ifnet(3, connect) }, /* 98 = connect */ { ifnet(3, accept) }, /* 99 = accept */ { 2, getpriority }, /* 100 = getpriority */ { ifnet(4, send) }, /* 101 = send */ { ifnet(4, recv) }, /* 102 = recv */ { 1, sigreturn }, /* 103 = sigreturn */ { ifnet(3, bind) }, /* 104 = bind */ { ifnet(5, setsockopt) }, /* 105 = setsockopt */ { ifnet(2, listen) }, /* 106 = listen */ { 1, sigsuspend }, /* 107 = sigsuspend */ { 0, nosys }, /* 108 = (old sigvec) */ { 0, nosys }, /* 109 = (old sigblock) */ { 0, nosys }, /* 110 = (old sigsetmask) */ { 0, nosys }, /* 111 = (old sigpause) */ { 2, sigstack }, /* 112 = sigstack COMPAT-43 */ { ifnet(3, recvmsg) }, /* 113 = recvmsg */ { ifnet(3, sendmsg) }, /* 114 = sendmsg */ { 0, nosys }, /* 115 = unused */ { 2, gettimeofday }, /* 116 = gettimeofday */ { 2, getrusage }, /* 117 = getrusage */ { ifnet(5, getsockopt) }, /* 118 = getsockopt */ { 0, nosys }, /* 119 = unused */ { 3, readv }, /* 120 = readv */ { 3, writev }, /* 121 = writev */ { 2, settimeofday }, /* 122 = settimeofday */ { 3, fchown }, /* 123 = fchown */ { 2, fchmod }, /* 124 = fchmod */ { ifnet(6, recvfrom) }, /* 125 = recvfrom */ { 0, nosys }, /* 126 = (old setreuid) */ { 0, nosys }, /* 127 = (old setregid) */ { 2, rename }, /* 128 = rename */ { 3, truncate }, /* 129 = truncate */ { 3, ftruncate }, /* 130 = ftruncate */ { 2, flock }, /* 131 = flock */ { 0, nosys }, /* 132 = nosys */ { ifnet(6, sendto) }, /* 133 = sendto */ { ifnet(2, shutdown) }, /* 134 = shutdown */ { errnet(4, socketpair) }, /* 135 = socketpair */ { 2, mkdir }, /* 136 = mkdir */ { 1, rmdir }, /* 137 = rmdir */ { 2, utimes }, /* 138 = utimes */ { 0, nosys }, /* 139 = unused */ { 2, adjtime }, /* 140 = adjtime */ { ifnet(3, getpeername) }, /* 141 = getpeername */ { 0, nosys }, /* 142 = (old gethostid) */ { 0, nosys }, /* 143 = (old sethostid) */ { 2, getrlimit }, /* 144 = getrlimit */ { 2, setrlimit }, /* 145 = setrlimit */ { 2, killpg }, /* 146 = killpg */ { 0, nosys }, /* 147 = nosys */ { 2, nosys }, /* 148 = quota */ { 4, nosys }, /* 149 = qquota */ { ifnet(3, getsockname) }, /* 150 = getsockname */ /* * Syscalls 151-180 inclusive are reserved for vendor-specific * system calls. (This includes various calls added for compatibity * with other Unix variants.) */ /* * 2BSD special calls */ { 0, nosys }, /* 151 = unused */ { 2, ustore }, /* 152 = ustore */ { 1, ufetch }, /* 153 = ufetch */ { 4, ucall }, /* 154 = ucall */ { 0, nosys }, /* 155 = fperr */ }; const int nsysent = sizeof (sysent) / sizeof (sysent[0]); ================================================ FILE: sys/kern/kern_clock.c ================================================ /* * Copyright (c) 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include #include #include #include #include #include #include int noproc; /* no one is running just now */ struct callout *callfree, calltodo; #ifdef UCB_METER int dk_ndrive = DK_NDRIVE; /* * Gather statistics on resource utilization. * * We make a gross assumption: that the system has been in the * state it is in (user state, kernel state, interrupt state, * or idle state) for the entire last time interval, and * update statistics accordingly. */ /*ARGSUSED*/ void gatherstats(pc, ps) caddr_t pc; int ps; { register int cpstate; /* * Determine what state the cpu is in. */ if (USERMODE(ps)) { /* * CPU was in user state. */ if (u.u_procp->p_nice > NZERO) cpstate = CP_NICE; else cpstate = CP_USER; } else { /* * CPU was in system state. If profiling kernel * increment a counter. If no process is running * then this is a system tick if we were running * at a non-zero IPL (in a driver). If a process is running, * then we charge it with system time even if we were * at a non-zero IPL, since the system often runs * this way during processing of system calls. * This is approximate, but the lack of true interval * timers makes doing anything else difficult. */ cpstate = CP_SYS; if (noproc && BASEPRI(ps)) cpstate = CP_IDLE; } /* * We maintain statistics shown by user-level statistics * programs: the amount of time in each cpu state, and * the amount of time each of DK_NDRIVE ``drives'' is busy. */ cp_time[cpstate]++; } #endif /* UCB_METER */ /* * Software priority level clock interrupt. * Run periodic events from timeout queue. */ void softclock(pc, ps) caddr_t pc; int ps; { for (;;) { register struct callout *p1; register caddr_t arg; register void (*func) (caddr_t); register int s; s = splhigh(); if ((p1 = calltodo.c_next) == 0 || p1->c_time > 0) { splx(s); break; } arg = p1->c_arg; func = p1->c_func; calltodo.c_next = p1->c_next; p1->c_next = callfree; callfree = p1; splx(s); (*func) (arg); } /* * If trapped user-mode and profiling, give it * a profiling tick. */ if (USERMODE(ps)) { register struct proc *p = u.u_procp; if (u.u_prof.pr_scale) addupc(pc, &u.u_prof, 1); /* * Check to see if process has accumulated * more than 10 minutes of user time. If so * reduce priority to give others a chance. */ if (p->p_uid && p->p_nice == NZERO && u.u_ru.ru_utime > 10L * 60L * hz) { p->p_nice = NZERO+4; (void) setpri(p); } } } /* * The hz hardware interval timer. * We update the events relating to real time. * Also gather statistics. * * reprime clock * implement callouts * maintain user/system times * maintain date * profile */ void hardclock(pc, ps) caddr_t pc; int ps; { register struct callout *p1; register struct proc *p; register int needsoft = 0; /* * Update real-time timeout queue. * At front of queue are some number of events which are ``due''. * The time to these is <= 0 and if negative represents the * number of ticks which have passed since it was supposed to happen. * The rest of the q elements (times > 0) are events yet to happen, * where the time for each is given as a delta from the previous. * Decrementing just the first of these serves to decrement the time * to all events. */ p1 = calltodo.c_next; while (p1) { if (--p1->c_time > 0) break; needsoft = 1; if (p1->c_time == 0) break; p1 = p1->c_next; } /* * Charge the time out based on the mode the cpu is in. * Here again we fudge for the lack of proper interval timers * assuming that the current state has been around at least * one tick. */ if (USERMODE(ps)) { if (u.u_prof.pr_scale) needsoft = 1; /* * CPU was in user state. Increment * user time counter, and process process-virtual time * interval timer. */ u.u_ru.ru_utime++; if (u.u_timer[ITIMER_VIRTUAL - 1].it_value && !--u.u_timer[ITIMER_VIRTUAL - 1].it_value) { psignal(u.u_procp, SIGVTALRM); u.u_timer[ITIMER_VIRTUAL - 1].it_value = u.u_timer[ITIMER_VIRTUAL - 1].it_interval; } } else { /* * CPU was in system state. */ if (!noproc) u.u_ru.ru_stime++; } /* * If the cpu is currently scheduled to a process, then * charge it with resource utilization for a tick, updating * statistics which run in (user+system) virtual time, * such as the cpu time limit and profiling timers. * This assumes that the current process has been running * the entire last tick. */ if (noproc == 0) { p = u.u_procp; if (++p->p_cpu == 0) p->p_cpu--; if ((u.u_ru.ru_utime+u.u_ru.ru_stime+1) > u.u_rlimit[RLIMIT_CPU].rlim_cur) { psignal(p, SIGXCPU); if (u.u_rlimit[RLIMIT_CPU].rlim_cur < u.u_rlimit[RLIMIT_CPU].rlim_max) u.u_rlimit[RLIMIT_CPU].rlim_cur += 5 * hz; } if (u.u_timer[ITIMER_PROF - 1].it_value && !--u.u_timer[ITIMER_PROF - 1].it_value) { psignal(p, SIGPROF); u.u_timer[ITIMER_PROF - 1].it_value = u.u_timer[ITIMER_PROF - 1].it_interval; } } #ifdef UCB_METER gatherstats (pc, ps); #endif /* * Increment the time-of-day, process callouts at a very * low cpu priority, so we don't keep the relatively high * clock interrupt priority any longer than necessary. */ if (adjdelta) { if (adjdelta > 0) { ++lbolt; --adjdelta; } else { --lbolt; ++adjdelta; } } if (++lbolt >= hz) { lbolt -= hz; ++time.tv_sec; } if (needsoft && BASEPRI(ps)) { /* if ps is high, just return */ (void) splsoftclock(); softclock (pc, ps); } } /* * Arrange that (*fun)(arg) is called in t/hz seconds. */ void timeout (fun, arg, t) void (*fun) (caddr_t); caddr_t arg; register int t; { register struct callout *p1, *p2, *pnew; register int s = splclock(); if (t <= 0) t = 1; pnew = callfree; if (pnew == NULL) panic("timeout table overflow"); callfree = pnew->c_next; pnew->c_arg = arg; pnew->c_func = fun; for (p1 = &calltodo; (p2 = p1->c_next) && p2->c_time < t; p1 = p2) if (p2->c_time > 0) t -= p2->c_time; p1->c_next = pnew; pnew->c_next = p2; pnew->c_time = t; if (p2) p2->c_time -= t; splx(s); } /* * untimeout is called to remove a function timeout call * from the callout structure. */ void untimeout (fun, arg) void (*fun) (caddr_t); caddr_t arg; { register struct callout *p1, *p2; register int s; s = splclock(); for (p1 = &calltodo; (p2 = p1->c_next) != 0; p1 = p2) { if (p2->c_func == fun && p2->c_arg == arg) { if (p2->c_next && p2->c_time > 0) p2->c_next->c_time += p2->c_time; p1->c_next = p2->c_next; p2->c_next = callfree; callfree = p2; break; } } splx(s); } void profil() { register struct a { unsigned *bufbase; unsigned bufsize; unsigned pcoffset; unsigned pcscale; } *uap = (struct a*) u.u_arg; register struct uprof *upp = &u.u_prof; upp->pr_base = uap->bufbase; upp->pr_size = uap->bufsize; upp->pr_off = uap->pcoffset; upp->pr_scale = uap->pcscale; } /* * Compute number of hz until specified time. * Used to compute third argument to timeout() from an * absolute time. */ int hzto(tv) register struct timeval *tv; { register long ticks; register long sec; register int s = splhigh(); /* * If number of milliseconds will fit in 32 bit arithmetic, * then compute number of milliseconds to time and scale to * ticks. Otherwise just compute number of hz in time, rounding * times greater than representible to maximum value. * * Delta times less than 25 days can be computed ``exactly''. * Maximum value for any timeout in 10ms ticks is 250 days. */ sec = tv->tv_sec - time.tv_sec; if (sec <= 0x7fffffff / 1000 - 1000) ticks = ((tv->tv_sec - time.tv_sec) * 1000 + (tv->tv_usec - time.tv_usec) / 1000) / (1000/hz); else if (sec <= 0x7fffffff / hz) ticks = sec * hz; else ticks = 0x7fffffff; splx(s); #ifdef pdp11 /* stored in an "int", so 16-bit max */ if (ticks > 0x7fff) ticks = 0x7fff; #endif return ((int)ticks); } /* * Initialize callouts. */ void coutinit() { int i; callfree = callout; for (i=1; i #include #include #include #include #include #include #include #include #ifdef INET #include #include #endif #include /* * Descriptor management. */ /* * Allocate a user file descriptor. */ static int ufalloc(i) register int i; { for (; i < NOFILE; i++) if (u.u_ofile[i] == NULL) { u.u_rval = i; u.u_pofile[i] = 0; if (i > u.u_lastfile) u.u_lastfile = i; return (i); } u.u_error = EMFILE; return (-1); } /* * System calls on descriptors. */ void getdtablesize() { u.u_rval = NOFILE; } static void dupit(fd, fp, flags) register int fd; register struct file *fp; int flags; { u.u_ofile[fd] = fp; u.u_pofile[fd] = flags; fp->f_count++; if (fd > u.u_lastfile) u.u_lastfile = fd; } void dup() { register struct a { int i; } *uap = (struct a *) u.u_arg; register struct file *fp; register int j; if (uap->i &~ 077) { uap->i &= 077; dup2(); return; } /* XXX */ GETF(fp, uap->i); j = ufalloc(0); if (j < 0) return; dupit(j, fp, u.u_pofile[uap->i] &~ UF_EXCLOSE); } void dup2() { register struct a { int i, j; } *uap = (struct a *) u.u_arg; register struct file *fp; GETF(fp, uap->i); if (uap->j < 0 || uap->j >= NOFILE) { u.u_error = EBADF; return; } u.u_rval = uap->j; if (uap->i == uap->j) return; if (u.u_ofile[uap->j]) /* * dup2 must succeed even if the close has an error. */ (void) closef(u.u_ofile[uap->j]); dupit(uap->j, fp, u.u_pofile[uap->i] &~ UF_EXCLOSE); } /* * The file control system call. */ void fcntl() { register struct file *fp; register struct a { int fdes; int cmd; int arg; } *uap; register int i; register char *pop; uap = (struct a *)u.u_arg; fp = getf(uap->fdes); if (fp == NULL) return; pop = &u.u_pofile[uap->fdes]; switch(uap->cmd) { case F_DUPFD: i = uap->arg; if (i < 0 || i >= NOFILE) { u.u_error = EINVAL; return; } if ((i = ufalloc(i)) < 0) return; dupit(i, fp, *pop &~ UF_EXCLOSE); break; case F_GETFD: u.u_rval = *pop & 1; break; case F_SETFD: *pop = (*pop &~ 1) | (uap->arg & 1); break; case F_GETFL: u.u_rval = OFLAGS(fp->f_flag); break; case F_SETFL: fp->f_flag &= ~FCNTLFLAGS; fp->f_flag |= (FFLAGS(uap->arg)) & FCNTLFLAGS; u.u_error = fset (fp, FNONBLOCK, fp->f_flag & FNONBLOCK); if (u.u_error) break; u.u_error = fset (fp, FASYNC, fp->f_flag & FASYNC); if (u.u_error) (void) fset (fp, FNONBLOCK, 0); break; case F_GETOWN: u.u_error = fgetown (fp, &u.u_rval); break; case F_SETOWN: u.u_error = fsetown (fp, uap->arg); break; default: u.u_error = EINVAL; } } int fioctl(fp, cmd, value) register struct file *fp; u_int cmd; caddr_t value; { return ((*Fops[fp->f_type]->fo_ioctl)(fp, cmd, value)); } /* * Set/clear file flags: nonblock and async. */ int fset (fp, bit, value) register struct file *fp; int bit, value; { if (value) fp->f_flag |= bit; else fp->f_flag &= ~bit; return (fioctl(fp, (u_int)(bit == FNONBLOCK ? FIONBIO : FIOASYNC), (caddr_t)&value)); } /* * Get process group id for a file. */ int fgetown(fp, valuep) register struct file *fp; register int *valuep; { register int error; #ifdef INET if (fp->f_type == DTYPE_SOCKET) { *valuep = mfsd(&fp->f_socket->so_pgrp); return (0); } #endif error = fioctl(fp, (u_int)TIOCGPGRP, (caddr_t)valuep); *valuep = -*valuep; return (error); } /* * Set process group id for a file. */ int fsetown(fp, value) register struct file *fp; int value; { #ifdef INET if (fp->f_type == DTYPE_SOCKET) { mtsd(&fp->f_socket->so_pgrp, value); return (0); } #endif if (value > 0) { register struct proc *p = pfind(value); if (p == 0) return (ESRCH); value = p->p_pgrp; } else value = -value; return (fioctl(fp, (u_int)TIOCSPGRP, (caddr_t)&value)); } void close() { register struct a { int i; } *uap = (struct a *)u.u_arg; register struct file *fp; GETF(fp, uap->i); u.u_ofile[uap->i] = NULL; while (u.u_lastfile >= 0 && u.u_ofile[u.u_lastfile] == NULL) u.u_lastfile--; u.u_error = closef(fp); /* WHAT IF u.u_error ? */ } void fstat() { register struct file *fp; register struct a { int fdes; struct stat *sb; } *uap; struct stat ub; uap = (struct a *)u.u_arg; fp = getf(uap->fdes); if (fp == NULL) return; switch (fp->f_type) { case DTYPE_PIPE: case DTYPE_INODE: u.u_error = ino_stat((struct inode *)fp->f_data, &ub); if (fp->f_type == DTYPE_PIPE) ub.st_size -= fp->f_offset; break; #ifdef INET case DTYPE_SOCKET: u.u_error = SOO_STAT(fp->f_socket, &ub); break; #endif default: u.u_error = EINVAL; break; } if (u.u_error == 0) u.u_error = copyout((caddr_t)&ub, (caddr_t)uap->sb, sizeof (ub)); } struct file *lastf; /* * Allocate a user file descriptor * and a file structure. * Initialize the descriptor * to point at the file structure. */ struct file * falloc() { register struct file *fp; register int i; i = ufalloc(0); if (i < 0) return (NULL); if (lastf == 0) lastf = file; for (fp = lastf; fp < file+NFILE; fp++) if (fp->f_count == 0) goto slot; for (fp = file; fp < lastf; fp++) if (fp->f_count == 0) goto slot; log(LOG_ERR, "file: table full\n"); u.u_error = ENFILE; return (NULL); slot: u.u_ofile[i] = fp; fp->f_count = 1; fp->f_data = 0; fp->f_offset = 0; lastf = fp + 1; return (fp); } /* * Convert a user supplied file descriptor into a pointer * to a file structure. Only task is to check range of the descriptor. * Critical paths should use the GETF macro unless code size is a * consideration. */ struct file * getf(f) register int f; { register struct file *fp; if ((unsigned)f >= NOFILE || (fp = u.u_ofile[f]) == NULL) { u.u_error = EBADF; return (NULL); } return (fp); } /* * Internal form of close. * Decrement reference count on file structure. */ int closef(fp) register struct file *fp; { int error; if (fp == NULL) return(0); if (fp->f_count > 1) { fp->f_count--; return(0); } if ((fp->f_flag & (FSHLOCK|FEXLOCK)) && fp->f_type == DTYPE_INODE) ino_unlock(fp, FSHLOCK|FEXLOCK); error = (*Fops[fp->f_type]->fo_close)(fp); fp->f_count = 0; return(error); } /* * Apply an advisory lock on a file descriptor. */ void flock() { register struct a { int fd; int how; } *uap = (struct a *)u.u_arg; register struct file *fp; int error; if ((fp = getf(uap->fd)) == NULL) return; if (fp->f_type != DTYPE_INODE) { u.u_error = EOPNOTSUPP; return; } if (uap->how & LOCK_UN) { ino_unlock(fp, FSHLOCK | FEXLOCK); return; } if ((uap->how & (LOCK_SH | LOCK_EX)) == 0) return; /* error? */ if (uap->how & LOCK_EX) uap->how &= ~LOCK_SH; /* avoid work... */ if ((fp->f_flag & FEXLOCK) && (uap->how & LOCK_EX)) return; if ((fp->f_flag & FSHLOCK) && (uap->how & LOCK_SH)) return; error = ino_lock(fp, uap->how); u.u_error = error; } /* * File Descriptor pseudo-device driver (/dev/fd/). * * Opening minor device N dup()s the file (if any) connected to file * descriptor N belonging to the calling process. Note that this driver * consists of only the ``open()'' routine, because all subsequent * references to this file will be direct to the other driver. */ /* ARGSUSED */ int fdopen(dev, mode, type) dev_t dev; int mode, type; { /* * XXX Kludge: set u.u_dupfd to contain the value of the * the file descriptor being sought for duplication. The error * return ensures that the vnode for this device will be released * by vn_open. Open will detect this special error and take the * actions in dupfdopen below. Other callers of vn_open will * simply report the error. */ u.u_dupfd = minor(dev); return(ENODEV); } /* * Duplicate the specified descriptor to a free descriptor. */ int dupfdopen (indx, dfd, mode, error) register int indx, dfd; int mode; int error; { register struct file *wfp; struct file *fp; /* * If the to-be-dup'd fd number is greater than the allowed number * of file descriptors, or the fd to be dup'd has already been * closed, reject. Note, check for new == old is necessary as * falloc could allocate an already closed to-be-dup'd descriptor * as the new descriptor. */ fp = u.u_ofile[indx]; if (dfd >= NOFILE || (wfp = u.u_ofile[dfd]) == NULL || fp == wfp) return(EBADF); /* * There are two cases of interest here. * * For ENODEV simply dup (dfd) to file descriptor * (indx) and return. * * For ENXIO steal away the file structure from (dfd) and * store it in (indx). (dfd) is effectively closed by * this operation. * * NOTE: ENXIO only comes out of the 'portal fs' code of 4.4 - since * 2.11BSD does not implement the portal fs the code is ifdef'd out * and a short message output. * * Any other error code is just returned. */ switch (error) { case ENODEV: /* * Check that the mode the file is being opened for is a * subset of the mode of the existing descriptor. */ if (((mode & (FREAD|FWRITE)) | wfp->f_flag) != wfp->f_flag) return(EACCES); u.u_ofile[indx] = wfp; u.u_pofile[indx] = u.u_pofile[dfd]; wfp->f_count++; if (indx > u.u_lastfile) u.u_lastfile = indx; return(0); #ifdef haveportalfs case ENXIO: /* * Steal away the file pointer from dfd, and stuff it into indx. */ fdp->fd_ofiles[indx] = fdp->fd_ofiles[dfd]; fdp->fd_ofiles[dfd] = NULL; fdp->fd_ofileflags[indx] = fdp->fd_ofileflags[dfd]; fdp->fd_ofileflags[dfd] = 0; /* * Complete the clean up of the filedesc structure by * recomputing the various hints. */ if (indx > fdp->fd_lastfile) fdp->fd_lastfile = indx; else while (fdp->fd_lastfile > 0 && fdp->fd_ofiles[fdp->fd_lastfile] == NULL) fdp->fd_lastfile--; if (dfd < fdp->fd_freefile) fdp->fd_freefile = dfd; return (0); #else log(LOG_NOTICE, "dupfdopen"); /* FALLTHROUGH */ #endif default: return(error); } /* NOTREACHED */ } ================================================ FILE: sys/kern/kern_exec.c ================================================ /* * Copyright (c) 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include /* * exec system call, with and without environments. */ struct execa { char *fname; char **argp; char **envp; }; /* * This is the internal form of the exec() function. * * It is called with the inode of the executable * and the exec_params structure, which is used to * keep information during the exec. * * It returns the error code, and with the ip still locked. */ int exec_check(struct exec_params *epp) { int error, i, r; DEBUG("\texec_check(): start\n"); if (access (epp->ip, IEXEC)) return ENOEXEC; if ((u.u_procp->p_flag & P_TRACED) && access (epp->ip, IREAD)) return ENOEXEC; if ((epp->ip->i_mode & IFMT) != IFREG || (epp->ip->i_mode & (IEXEC | (IEXEC>>3) | (IEXEC>>6))) == 0) return EACCES; /* * Read in first few bytes of file for segment sizes, magic number: * 407 = plain executable * Also an ASCII line beginning with #! is * the file name of a ``interpreter'' and arguments may be prepended * to the argument list if given here. * * INTERPRETER NAMES ARE LIMITED IN LENGTH. * * ONLY ONE ARGUMENT MAY BE PASSED TO THE INTERPRETER FROM * THE ASCII LINE. */ /* * Read the first 'SHSIZE' bytes from the file to execute */ DEBUG("\texec_check(): read header %d bytes\n", sizeof(epp->hdr)); epp->hdr.sh[0] = '\0'; /* for zero length files */ error = rdwri(UIO_READ, epp->ip, (caddr_t) &epp->hdr, sizeof(epp->hdr), (off_t)0, IO_UNIT, &r); if (error) return error; epp->hdr_len = sizeof(epp->hdr) - r; /* * Given the first part of the image * loop through the exec file handlers to find * someone who can handle this file format. */ error = ENOEXEC; DEBUG("\texec_check(): trying %d exec formats\n", nexecs); for (i = 0; i < nexecs && error != 0; i++) { DEBUG("\texec_check(): trying format %d: %s\n", i, execsw[i].es_name); if (execsw[i].es_check == NULL) continue; error = (*execsw[i].es_check)(epp); if (error == 0) break; } DEBUG("\texec_check(): end\n"); return error; } void execv() { struct execa *arg = (struct execa *)u.u_arg; arg->envp = NULL; execve(); } void execve() { struct execa *uap = (struct execa *)u.u_arg; int error; struct inode *ip; struct nameidata nd; register struct nameidata *ndp = &nd; struct exec_params eparam; DEBUG("\n\texecve(): start\n"); DEBUG("\texecve(): args: '%s', ['%s', '%s', ...]\n", uap->fname, uap->argp[0], uap->argp[1]); NDINIT (ndp, LOOKUP, FOLLOW, uap->fname); ip = namei (ndp); if (ip == NULL) { DEBUG("\texecve(): file '%s' not found\n", uap->fname); return; } /* * The exec_param structure is used to * keep information about the executable during exec's processing */ bzero(&eparam, sizeof eparam); eparam.userfname = uap->fname; eparam.userargp = uap->argp; eparam.userenvp = uap->envp; eparam.uid = u.u_uid; eparam.gid = u.u_groups[0]; if (ip->i_fs->fs_flags & MNT_NOEXEC) { u.u_error = EACCES; DEBUG("\texecve(): EACCES\n"); goto done; } if ((ip->i_fs->fs_flags & MNT_NOSUID) == 0) { if (ip->i_mode & ISUID) eparam.uid = ip->i_uid; if (ip->i_mode & ISGID) eparam.gid = ip->i_gid; } eparam.ip = ip; if ((error = exec_check(&eparam))) u.u_error = error; done: exec_alloc_freeall(&eparam); if (ip) iput(ip); DEBUG("\texecve(): end\n\n"); } ================================================ FILE: sys/kern/kern_exit.c ================================================ /* * Copyright (c) 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include #include #include #include #include #include #include #include #include #include /* * Notify parent that vfork child is finished with parent's data. Called * during exit/exec(getxfile). The child * must be locked in core so it will be in core when the parent runs. */ void endvfork() { register struct proc *rip, *rpp; rpp = u.u_procp; rip = rpp->p_pptr; rpp->p_flag &= ~SVFORK; rpp->p_flag |= SLOCK; wakeup ((caddr_t) rpp); while (! (rpp->p_flag & SVFDONE)) sleep ((caddr_t) rip, PZERO-1); /* * The parent has taken back our data+stack, set our sizes to 0. */ u.u_dsize = rpp->p_dsize = 0; u.u_ssize = rpp->p_ssize = 0; rpp->p_flag &= ~(SVFDONE | SLOCK); } /* * Exit: deallocate address space and other resources, * change proc state to zombie, and unlink proc from allproc * list. Save exit status and rusage for wait4(). * Check for child processes and orphan them. */ void exit (rv) int rv; { register int i; register struct proc *p; struct proc **pp; p = u.u_procp; p->p_flag &= ~P_TRACED; p->p_sigignore = ~0; p->p_sig = 0; /* * 2.11 doesn't need to do this and it gets overwritten anyway. * p->p_realtimer.it_value = 0; */ for (i = 0; i <= u.u_lastfile; i++) { register struct file *f; f = u.u_ofile[i]; u.u_ofile[i] = NULL; u.u_pofile[i] = 0; (void) closef(f); } ilock(u.u_cdir); iput(u.u_cdir); if (u.u_rdir) { ilock(u.u_rdir); iput(u.u_rdir); } u.u_rlimit[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY; if (p->p_flag & SVFORK) endvfork(); if (p->p_pid == 1) panic("init died"); if ((*p->p_prev = p->p_nxt) != NULL) /* off allproc queue */ p->p_nxt->p_prev = p->p_prev; p->p_nxt = zombproc; /* onto zombproc */ if (p->p_nxt != NULL) p->p_nxt->p_prev = &p->p_nxt; p->p_prev = &zombproc; zombproc = p; p->p_stat = SZOMB; noproc = 1; for (pp = &pidhash[PIDHASH(p->p_pid)]; *pp; pp = &(*pp)->p_hash) if (*pp == p) { *pp = p->p_hash; goto done; } panic("exit"); done: /* * Overwrite p_alive substructure of proc - better not be anything * important left! */ p->p_xstat = rv; p->p_ru = u.u_ru; ruadd(&p->p_ru, &u.u_cru); { register struct proc *q; int doingzomb = 0; q = allproc; again: for(; q; q = q->p_nxt) if (q->p_pptr == p) { q->p_pptr = &proc[1]; q->p_ppid = 1; wakeup((caddr_t)&proc[1]); if (q->p_flag& P_TRACED) { q->p_flag &= ~P_TRACED; psignal(q, SIGKILL); } else if (q->p_stat == SSTOP) { psignal(q, SIGHUP); psignal(q, SIGCONT); } } if (!doingzomb) { doingzomb = 1; q = zombproc; goto again; } } psignal(p->p_pptr, SIGCHLD); wakeup((caddr_t) p->p_pptr); wakeup((caddr_t) &runin); swtch(); /* NOTREACHED */ } /* * exit system call: pass back caller's arg */ void rexit() { register struct a { int rval; } *uap = (struct a*) u.u_arg; exit (W_EXITCODE (uap->rval, 0)); /* NOTREACHED */ } struct args { int pid; int *status; int options; struct rusage *rusage; }; /* * Wait: check child processes to see if any have exited, * stopped under trace or (optionally) stopped by a signal. * Pass back status and make available for reuse the exited * child's proc structure. */ static int wait1 (q, uap, retval) struct proc *q; register struct args *uap; int retval[]; { int nfound, status; struct rusage ru; /* used for local conversion */ register struct proc *p; register int error; if (uap->pid == WAIT_MYPGRP) /* == 0 */ uap->pid = -q->p_pgrp; loop: nfound = 0; /* * 4.X has child links in the proc structure, so they consolidate * these two tests into one loop. We only have the zombie chain * and the allproc chain, so we check for ZOMBIES first, then for * children that have changed state. We check for ZOMBIES first * because they are more common, and, as the list is typically small, * a faster check. */ for (p = zombproc; p; p = p->p_nxt) { if (p->p_pptr != q) /* are we the parent of this process? */ continue; if (uap->pid != WAIT_ANY && p->p_pid != uap->pid && p->p_pgrp != -uap->pid) continue; retval[0] = p->p_pid; retval[1] = p->p_xstat; if (uap->status && (error = copyout ((caddr_t) &p->p_xstat, (caddr_t) uap->status, sizeof (uap->status)))) return(error); if (uap->rusage) { rucvt(&ru, &p->p_ru); error = copyout ((caddr_t) &ru, (caddr_t) uap->rusage, sizeof (ru)); if (error) return(error); } ruadd(&u.u_cru, &p->p_ru); p->p_xstat = 0; p->p_stat = NULL; p->p_pid = 0; p->p_ppid = 0; if ((*p->p_prev = p->p_nxt) != NULL) /* off zombproc */ p->p_nxt->p_prev = p->p_prev; p->p_nxt = freeproc; /* onto freeproc */ freeproc = p; p->p_pptr = 0; p->p_sig = 0; p->p_sigcatch = 0; p->p_sigignore = 0; p->p_sigmask = 0; p->p_pgrp = 0; p->p_flag = 0; p->p_wchan = 0; return (0); } for (p = allproc; p;p = p->p_nxt) { if (p->p_pptr != q) continue; if (uap->pid != WAIT_ANY && p->p_pid != uap->pid && p->p_pgrp != -uap->pid) continue; ++nfound; if (p->p_stat == SSTOP && ! (p->p_flag & P_WAITED) && (p->p_flag & P_TRACED || uap->options & WUNTRACED)) { p->p_flag |= P_WAITED; retval[0] = p->p_pid; error = 0; if (uap->status) { status = W_STOPCODE(p->p_ptracesig); error = copyout ((caddr_t) &status, (caddr_t) uap->status, sizeof (status)); } return (error); } } if (nfound == 0) return (ECHILD); if (uap->options&WNOHANG) { retval[0] = 0; return (0); } error = tsleep ((caddr_t) q, PWAIT|PCATCH, 0); if (error == 0) goto loop; return(error); } void wait4() { int retval[2]; register struct args *uap = (struct args*) u.u_arg; retval[0] = 0; u.u_error = wait1 (u.u_procp, uap, retval); if (! u.u_error) u.u_rval = retval[0]; } void reboot() { struct a { int opt; }; if (suser ()) boot (rootdev, ((struct a*)u.u_arg)->opt); } ================================================ FILE: sys/kern/kern_fork.c ================================================ /* * Copyright (c) 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include #include #include #include #include #include #include #include #include #include int mpid; /* generic for unique process id's */ /* * Create a new process -- the internal version of system call fork. * It returns 1 in the new process, 0 in the old. */ int newproc (isvfork) int isvfork; { register struct proc *child, *parent; register int n; static int pidchecked = 0; struct file *fp; /* * First, just locate a slot for a process * and copy the useful info from this process into it. * The panic "cannot happen" because fork has already * checked for the existence of a slot. */ mpid++; retry: if (mpid >= 30000) { mpid = 100; pidchecked = 0; } if (mpid >= pidchecked) { int doingzomb = 0; pidchecked = 30000; /* * Scan the proc table to check whether this pid * is in use. Remember the lowest pid that's greater * than mpid, so we can avoid checking for a while. */ child = allproc; again: for (; child != NULL; child = child->p_nxt) { if (child->p_pid == mpid || child->p_pgrp == mpid) { mpid++; if (mpid >= pidchecked) goto retry; } if (child->p_pid > mpid && pidchecked > child->p_pid) pidchecked = child->p_pid; if (child->p_pgrp > mpid && pidchecked > child->p_pgrp) pidchecked = child->p_pgrp; } if (!doingzomb) { doingzomb = 1; child = zombproc; goto again; } } child = freeproc; if (child == NULL) panic("no procs"); freeproc = child->p_nxt; /* off freeproc */ /* * Make a proc table entry for the new process. */ parent = u.u_procp; child->p_stat = SIDL; child->p_realtimer.it_value = 0; child->p_flag = SLOAD; child->p_uid = parent->p_uid; child->p_pgrp = parent->p_pgrp; child->p_nice = parent->p_nice; child->p_pid = mpid; child->p_ppid = parent->p_pid; child->p_pptr = parent; child->p_time = 0; child->p_cpu = 0; child->p_sigmask = parent->p_sigmask; child->p_sigcatch = parent->p_sigcatch; child->p_sigignore = parent->p_sigignore; /* take along any pending signals like stops? */ #ifdef UCB_METER if (isvfork) { forkstat.cntvfork++; forkstat.sizvfork += (parent->p_dsize + parent->p_ssize) >> 10; } else { forkstat.cntfork++; forkstat.sizfork += (parent->p_dsize + parent->p_ssize) >> 10; } #endif child->p_wchan = 0; child->p_slptime = 0; { struct proc **hash = &pidhash [PIDHASH (child->p_pid)]; child->p_hash = *hash; *hash = child; } /* * some shuffling here -- in most UNIX kernels, the allproc assign * is done after grabbing the struct off of the freeproc list. We * wait so that if the clock interrupts us and vmtotal walks allproc * the text pointer isn't garbage. */ child->p_nxt = allproc; /* onto allproc */ child->p_nxt->p_prev = &child->p_nxt; /* (allproc is never NULL) */ child->p_prev = &allproc; allproc = child; /* * Increase reference counts on shared objects. */ for (n = 0; n <= u.u_lastfile; n++) { fp = u.u_ofile[n]; if (fp == NULL) continue; fp->f_count++; } u.u_cdir->i_count++; if (u.u_rdir) u.u_rdir->i_count++; /* * When the longjmp is executed for the new process, * here's where it will resume. */ if (setjmp (&u.u_ssave)) { return(1); } child->p_dsize = parent->p_dsize; child->p_ssize = parent->p_ssize; child->p_daddr = parent->p_daddr; child->p_saddr = parent->p_saddr; /* * Partially simulate the environment of the new process so that * when it is actually created (by copying) it will look right. */ u.u_procp = child; /* * Swap out the current process to generate the copy. */ parent->p_stat = SIDL; child->p_addr = parent->p_addr; child->p_stat = SRUN; swapout (child, X_DONTFREE, X_OLDSIZE, X_OLDSIZE); child->p_flag |= SSWAP; parent->p_stat = SRUN; u.u_procp = parent; if (isvfork) { /* * Wait for the child to finish with it. * RetroBSD: to make this work, significant * changes in scheduler are required. */ parent->p_dsize = 0; parent->p_ssize = 0; child->p_flag |= SVFORK; parent->p_flag |= SVFPRNT; while (child->p_flag & SVFORK) sleep ((caddr_t)child, PSWP+1); if ((child->p_flag & SLOAD) == 0) panic ("newproc vfork"); u.u_dsize = parent->p_dsize = child->p_dsize; parent->p_daddr = child->p_daddr; child->p_dsize = 0; u.u_ssize = parent->p_ssize = child->p_ssize; parent->p_saddr = child->p_saddr; child->p_ssize = 0; child->p_flag |= SVFDONE; wakeup ((caddr_t) parent); parent->p_flag &= ~SVFPRNT; } return(0); } static void fork1 (isvfork) int isvfork; { register int a; register struct proc *p1, *p2; a = 0; if (u.u_uid != 0) { for (p1 = allproc; p1; p1 = p1->p_nxt) if (p1->p_uid == u.u_uid) a++; for (p1 = zombproc; p1; p1 = p1->p_nxt) if (p1->p_uid == u.u_uid) a++; } /* * Disallow if * No processes at all; * not su and too many procs owned; or * not su and would take last slot. */ p2 = freeproc; if (p2==NULL) log(LOG_ERR, "proc: table full\n"); if (p2==NULL || (u.u_uid!=0 && (p2->p_nxt == NULL || a>MAXUPRC))) { u.u_error = EAGAIN; return; } p1 = u.u_procp; if (newproc (isvfork)) { /* Child */ u.u_rval = 0; u.u_start = time.tv_sec; bzero(&u.u_ru, sizeof(u.u_ru)); bzero(&u.u_cru, sizeof(u.u_cru)); return; } /* Parent */ u.u_rval = p2->p_pid; } /* * fork system call */ void fork() { fork1 (0); } /* * vfork system call, fast version of fork */ void vfork() { fork1 (1); } ================================================ FILE: sys/kern/kern_glob.c ================================================ /* * Global memory area system. * * Works with two system calls: * * byte = rdglob(addr); * success = wrglob(addr,byte); */ #include #include #include #ifndef GLOBSZ #define GLOBSZ 256 #endif unsigned char global_segment[GLOBSZ]; void rdglob() { struct a { int addr; } *uap = (struct a *)u.u_arg; // Only root should have access to the shared memory block if(u.u_uid!=0) { u.u_rval = -1; return; } if(uap->addr>=GLOBSZ) { u.u_rval = -1; return; } u.u_rval = global_segment[uap->addr]; } void wrglob() { struct a { int addr; unsigned char value; } *uap = (struct a *)u.u_arg; // Only root should have access to the shared memory block if(u.u_uid!=0) { u.u_rval = -1; return; } if(uap->addr>=GLOBSZ) { u.u_rval = -1; return; } u.u_rval = 0; global_segment[uap->addr] = uap->value; } ================================================ FILE: sys/kern/kern_mman.c ================================================ /* * Copyright (c) 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include #include #include #include #include void brk() { struct a { int naddr; }; register int newsize, d; /* set newsize to new data size */ newsize = ((struct a*)u.u_arg)->naddr - u.u_procp->p_daddr; if (newsize < 0) newsize = 0; if (u.u_tsize + newsize + u.u_ssize > MAXMEM) { u.u_error = ENOMEM; return; } u.u_procp->p_dsize = newsize; /* set d to (new - old) */ d = newsize - u.u_dsize; //printf ("brk: new size %u bytes, incremented by %d\n", newsize, d); if (d > 0) bzero ((void*) (u.u_procp->p_daddr + u.u_dsize), d); u.u_dsize = newsize; u.u_rval = u.u_procp->p_daddr + u.u_dsize; } ================================================ FILE: sys/kern/kern_proc.c ================================================ /* * Copyright (c) 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include #include #include #include /* * Is p an inferior of the current process? */ int inferior(p) register struct proc *p; { for (; p != u.u_procp; p = p->p_pptr) if (p->p_ppid == 0) return (0); return (1); } /* * Find a process by pid. */ struct proc * pfind (pid) register int pid; { register struct proc *p = pidhash [PIDHASH(pid)]; for (; p; p = p->p_hash) if (p->p_pid == pid) return (p); return ((struct proc *)0); } /* * init the process queues */ void pqinit() { register struct proc *p; /* * most procs are initially on freequeue * nb: we place them there in their "natural" order. */ freeproc = NULL; for (p = proc+NPROC; --p > proc; freeproc = p) p->p_nxt = freeproc; /* * but proc[0] is special ... */ allproc = p; p->p_nxt = NULL; p->p_prev = &allproc; zombproc = NULL; } ================================================ FILE: sys/kern/kern_prot.c ================================================ /* * System calls related to processes and protection. * * Copyright (c) 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include #include #include #include void getpid() { u.u_rval = u.u_procp->p_pid; } void getppid() { u.u_rval = u.u_procp->p_ppid; } void getpgrp() { register struct a { int pid; } *uap = (struct a *)u.u_arg; register struct proc *p; if (uap->pid == 0) /* silly... */ uap->pid = u.u_procp->p_pid; p = pfind(uap->pid); if (p == 0) { u.u_error = ESRCH; return; } u.u_rval = p->p_pgrp; } void getuid() { u.u_rval = u.u_ruid; } void geteuid() { u.u_rval = u.u_uid; } void getgid() { u.u_rval = u.u_rgid; } void getegid() { u.u_rval = u.u_groups[0]; } /* * getgroups and setgroups differ from 4.X because the VAX stores group * entries in the user structure as shorts and has to convert them to ints. */ void getgroups() { register struct a { u_int gidsetsize; int *gidset; } *uap = (struct a *)u.u_arg; register gid_t *gp; for (gp = &u.u_groups[NGROUPS]; gp > u.u_groups; gp--) if (gp[-1] != NOGROUP) break; if (uap->gidsetsize < gp - u.u_groups) { u.u_error = EINVAL; return; } uap->gidsetsize = gp - u.u_groups; u.u_error = copyout((caddr_t)u.u_groups, (caddr_t)uap->gidset, uap->gidsetsize * sizeof(u.u_groups[0])); if (u.u_error) return; u.u_rval = uap->gidsetsize; } void setpgrp() { register struct proc *p; register struct a { int pid; int pgrp; } *uap = (struct a *)u.u_arg; if (uap->pid == 0) /* silly... */ uap->pid = u.u_procp->p_pid; p = pfind(uap->pid); if (p == 0) { u.u_error = ESRCH; return; } /* need better control mechanisms for process groups */ if (p->p_uid != u.u_uid && u.u_uid && !inferior(p)) { u.u_error = EPERM; return; } p->p_pgrp = uap->pgrp; } void setgroups() { register struct a { u_int gidsetsize; int *gidset; } *uap = (struct a *)u.u_arg; register gid_t *gp; if (!suser()) return; if (uap->gidsetsize > sizeof (u.u_groups) / sizeof (u.u_groups[0])) { u.u_error = EINVAL; return; } u.u_error = copyin((caddr_t)uap->gidset, (caddr_t)u.u_groups, uap->gidsetsize * sizeof (u.u_groups[0])); if (u.u_error) return; for (gp = &u.u_groups[uap->gidsetsize]; gp < &u.u_groups[NGROUPS]; gp++) *gp = NOGROUP; } /* * Check if gid is a member of the group set. */ int groupmember(gid) gid_t gid; { register gid_t *gp; for (gp = u.u_groups; gp < &u.u_groups[NGROUPS] && *gp != NOGROUP; gp++) if (*gp == gid) return (1); return (0); } ================================================ FILE: sys/kern/kern_prot2.c ================================================ /* * Copyright (c) 1982, 1986, 1989, 1990, 1991, 1993 * The Regents of the University of California. All rights reserved. * (c) UNIX System Laboratories, Inc. * All or some portions of this file are derived from material licensed * to the University of California by American Telephone and Telegraph * Co. or Unix System Laboratories, Inc. and are reproduced herein with * the permission of UNIX System Laboratories, Inc. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #include #include #include void setuid() { struct a { uid_t uid; } *uap = (struct a*) u.u_arg; register uid_t uid; uid = uap->uid; if (uid != u.u_ruid && ! suser()) return; /* * Everything's okay, do it. */ u.u_procp->p_uid = uid; u.u_uid = uid; u.u_ruid = uid; u.u_svuid = uid; u.u_error = 0; } void seteuid() { struct a { uid_t euid; } *uap = (struct a *)u.u_arg; register uid_t euid; euid = uap->euid; if (euid != u.u_ruid && euid != u.u_svuid && ! suser()) return; /* * Everything's okay, do it. */ u.u_uid = euid; u.u_error = 0; } void setgid() { struct a { gid_t gid; } *uap = (struct a *)u.u_arg; register gid_t gid; gid = uap->gid; if (gid != u.u_rgid && ! suser()) return; u.u_groups[0] = gid; /* effective gid is u_groups[0] */ u.u_rgid = gid; u.u_svgid = gid; u.u_error = 0; } void setegid() { struct a { gid_t egid; } *uap = (struct a *)u.u_arg; register gid_t egid; egid = uap->egid; if (egid != u.u_rgid && egid != u.u_svgid && ! suser()) return; u.u_groups[0] = egid; u.u_error = 0; } ================================================ FILE: sys/kern/kern_resource.c ================================================ /* * Copyright (c) 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include #include #include #include #include #include /* * Resource controls and accounting. */ void getpriority() { register struct a { int which; int who; } *uap = (struct a *)u.u_arg; register struct proc *p; register int low = PRIO_MAX + 1; switch (uap->which) { case PRIO_PROCESS: if (uap->who == 0) p = u.u_procp; else p = pfind(uap->who); if (p == 0) break; low = p->p_nice; break; case PRIO_PGRP: if (uap->who == 0) uap->who = u.u_procp->p_pgrp; for (p = allproc; p != NULL; p = p->p_nxt) { if (p->p_pgrp == uap->who && p->p_nice < low) low = p->p_nice; } break; case PRIO_USER: if (uap->who == 0) uap->who = u.u_uid; for (p = allproc; p != NULL; p = p->p_nxt) { if (p->p_uid == uap->who && p->p_nice < low) low = p->p_nice; } break; default: u.u_error = EINVAL; return; } if (low == PRIO_MAX + 1) { u.u_error = ESRCH; return; } u.u_rval = low; } static void donice(p, n) register struct proc *p; register int n; { if (u.u_uid && u.u_ruid && u.u_uid != p->p_uid && u.u_ruid != p->p_uid) { u.u_error = EPERM; return; } if (n > PRIO_MAX) n = PRIO_MAX; if (n < PRIO_MIN) n = PRIO_MIN; if (n < p->p_nice && !suser()) { u.u_error = EACCES; return; } p->p_nice = n; } void setpriority() { register struct a { int which; int who; int prio; } *uap = (struct a *)u.u_arg; register struct proc *p; register int found = 0; switch (uap->which) { case PRIO_PROCESS: if (uap->who == 0) p = u.u_procp; else p = pfind(uap->who); if (p == 0) break; donice(p, uap->prio); found++; break; case PRIO_PGRP: if (uap->who == 0) uap->who = u.u_procp->p_pgrp; for (p = allproc; p != NULL; p = p->p_nxt) if (p->p_pgrp == uap->who) { donice(p, uap->prio); found++; } break; case PRIO_USER: if (uap->who == 0) uap->who = u.u_uid; for (p = allproc; p != NULL; p = p->p_nxt) if (p->p_uid == uap->who) { donice(p, uap->prio); found++; } break; default: u.u_error = EINVAL; return; } if (found == 0) u.u_error = ESRCH; } void setrlimit() { register struct a { u_int which; struct rlimit *lim; } *uap = (struct a *)u.u_arg; struct rlimit alim; register struct rlimit *alimp; if (uap->which >= RLIM_NLIMITS) { u.u_error = EINVAL; return; } alimp = &u.u_rlimit[uap->which]; u.u_error = copyin((caddr_t)uap->lim, (caddr_t)&alim, sizeof (struct rlimit)); if (u.u_error) return; if (uap->which == RLIMIT_CPU) { /* * 2.11 stores RLIMIT_CPU as ticks to keep from making * hardclock() do long multiplication/division. */ if (alim.rlim_cur >= RLIM_INFINITY / hz) alim.rlim_cur = RLIM_INFINITY; else alim.rlim_cur = alim.rlim_cur * hz; if (alim.rlim_max >= RLIM_INFINITY / hz) alim.rlim_max = RLIM_INFINITY; else alim.rlim_max = alim.rlim_max * hz; } if (alim.rlim_cur > alimp->rlim_max || alim.rlim_max > alimp->rlim_max) if (!suser()) return; *alimp = alim; } void getrlimit() { register struct a { u_int which; struct rlimit *rlp; } *uap = (struct a *)u.u_arg; if (uap->which >= RLIM_NLIMITS) { u.u_error = EINVAL; return; } if (uap->which == RLIMIT_CPU) { struct rlimit alim; alim = u.u_rlimit[uap->which]; if (alim.rlim_cur != RLIM_INFINITY) alim.rlim_cur = alim.rlim_cur / hz; if (alim.rlim_max != RLIM_INFINITY) alim.rlim_max = alim.rlim_max / hz; u.u_error = copyout((caddr_t)&alim, (caddr_t)uap->rlp,sizeof (struct rlimit)); } else u.u_error = copyout((caddr_t)&u.u_rlimit[uap->which], (caddr_t)uap->rlp,sizeof (struct rlimit)); } void getrusage() { register struct a { int who; struct rusage *rusage; } *uap = (struct a *)u.u_arg; register struct k_rusage *rup; struct rusage ru; switch (uap->who) { case RUSAGE_SELF: rup = &u.u_ru; break; case RUSAGE_CHILDREN: rup = &u.u_cru; break; default: u.u_error = EINVAL; return; } rucvt(&ru,rup); u.u_error = copyout((caddr_t)&ru, (caddr_t)uap->rusage, sizeof (struct rusage)); } /* * Add resource usage data. */ void ruadd(ru, ru2) struct k_rusage *ru, *ru2; { register long *ip, *ip2; register int i; /* * since the kernel timeval structures are single longs, * fold them into the loop. */ ip = &ru->k_ru_first; ip2 = &ru2->k_ru_first; for (i = &ru->k_ru_last - &ru->k_ru_first; i >= 0; i--) *ip++ += *ip2++; } /* * Convert an internal kernel rusage structure into a `real' rusage structure. */ void rucvt (rup, krup) register struct rusage *rup; register struct k_rusage *krup; { bzero((caddr_t)rup, sizeof(*rup)); rup->ru_utime.tv_sec = krup->ru_utime / hz; rup->ru_utime.tv_usec = (krup->ru_utime % hz) * usechz; rup->ru_stime.tv_sec = krup->ru_stime / hz; rup->ru_stime.tv_usec = (krup->ru_stime % hz) * usechz; rup->ru_nswap = krup->ru_nswap; rup->ru_inblock = krup->ru_inblock; rup->ru_oublock = krup->ru_oublock; rup->ru_msgsnd = krup->ru_msgsnd; rup->ru_msgrcv = krup->ru_msgrcv; rup->ru_nsignals = krup->ru_nsignals; rup->ru_nvcsw = krup->ru_nvcsw; rup->ru_nivcsw = krup->ru_nivcsw; } ================================================ FILE: sys/kern/kern_sig.c ================================================ /* * Copyright (c) 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include #include #include #include #include #include #include /* * Can the current process send the signal `signum' to process `q'? * This is complicated by the need to access the `real uid' of `q'. * The 'real uid' is in the u area and `q' may be (but usually is not) swapped * out. Use the routine `fill_from_u' which the sysctl() call uses. See the * notes in kern_sysctl.c * * The previous checks for a process to post a signal to another process * checked _only_ the effective userid. With the implementation of the * 'saved id' feature and the ability of a setuid program to assume either * uid that check was inadequate. * * The 'c'urrent process is allowed to send a signal to a 't'arget process if * 1) either the real or effective user ids match OR 2) if the signal is * SIGCONT and the target process is a descendant of the current process */ static int cansignal (q, signum) register struct proc *q; int signum; { register struct proc *curp = u.u_procp; uid_t ruid; fill_from_u(q, &ruid, NULL, NULL); /* XXX */ if (curp->p_uid == 0 || /* c effective root */ u.u_ruid == ruid || /* c real = t real */ curp->p_uid == ruid || /* c effective = t real */ u.u_ruid == q->p_uid || /* c real = t effective */ curp->p_uid == q->p_uid || /* c effective = t effective */ (signum == SIGCONT && inferior(q))) return(1); return(0); } /* * 4.3 Compatibility */ void sigstack() { register struct a { struct sigstack *nss; struct sigstack *oss; } *uap = (struct a*) u.u_arg; struct sigstack ss; register int error = 0; ss.ss_sp = u.u_sigstk.ss_base; ss.ss_onstack = u.u_sigstk.ss_flags & SA_ONSTACK; if(uap->oss && (error = copyout ((caddr_t) &ss, (caddr_t) uap->oss, sizeof (ss)))) goto out; if (uap->nss && (error = copyin ((caddr_t) uap->nss, (caddr_t) &ss, sizeof (ss))) == 0) { u.u_sigstk.ss_base = ss.ss_sp; u.u_sigstk.ss_size = 0; u.u_sigstk.ss_flags |= (ss.ss_onstack & SA_ONSTACK); u.u_psflags |= SAS_ALTSTACK; } out: u.u_error = error; } static int killpg1 (signo, pgrp, all) int signo, pgrp, all; { register struct proc *p; int f, error = 0; if (! all && pgrp == 0) { /* * Zero process id means send to my process group. */ pgrp = u.u_procp->p_pgrp; if (pgrp == 0) return (ESRCH); } for (f = 0, p = allproc; p != NULL; p = p->p_nxt) { if ((p->p_pgrp != pgrp && !all) || p->p_ppid == 0 || (p->p_flag&SSYS) || (all && p == u.u_procp)) continue; if (! cansignal (p, signo)) { if (!all) error = EPERM; continue; } f++; if (signo) psignal(p, signo); } return (error ? error : (f == 0 ? ESRCH : 0)); } void kill() { register struct a { int pid; int signo; } *uap = (struct a *)u.u_arg; register struct proc *p; register int error = 0; /* * BSD4.3 botches the comparison against NSIG - it's a good thing for * them psignal catches the error - however, since psignal is the * kernel's internel signal mechanism and *should be getting correct * parameters from the rest of the kernel, psignal shouldn't *have* * to check it's parameters for validity. If you feel differently, * feel free to clutter up the entire inner kernel with parameter * checks - start with postsig ... */ if (uap->signo < 0 || uap->signo >= NSIG) { error = EINVAL; goto out; } if (uap->pid > 0) { /* kill single process */ p = pfind(uap->pid); if (p == 0) { error = ESRCH; goto out; } if (! cansignal (p, uap->signo)) error = EPERM; else if (uap->signo) psignal (p, uap->signo); goto out; } switch (uap->pid) { case -1: /* broadcast signal */ error = killpg1 (uap->signo, 0, 1); break; case 0: /* signal own process group */ error = killpg1 (uap->signo, 0, 0); break; default: /* negative explicit process group */ error = killpg1 (uap->signo, -uap->pid, 0); break; } out: u.u_error = error; } void killpg() { register struct a { int pgrp; int signo; } *uap = (struct a *)u.u_arg; register int error = 0; if (uap->signo < 0 || uap->signo >= NSIG) { error = EINVAL; goto out; } error = killpg1 (uap->signo, uap->pgrp, 0); out: u.u_error = error; } /* * Put the argument process into the stopped * state and notify the parent via wakeup. * Signals are handled elsewhere. */ void stop(p) register struct proc *p; { p->p_stat = SSTOP; p->p_flag &= ~P_WAITED; wakeup((caddr_t)p->p_pptr); } /* * Send the specified signal to * all processes with 'pgrp' as * process group. */ void gsignal (pgrp, sig) register int pgrp; register int sig; { register struct proc *p; if (pgrp == 0) return; for (p = allproc; p != NULL; p = p->p_nxt) if (p->p_pgrp == pgrp) psignal(p, sig); } /* * Send the specified signal to * the specified process. */ void psignal(p, sig) register struct proc *p; register int sig; { register int s; sig_t action; int prop; long mask; mask = sigmask(sig); prop = sigprop[sig]; /* * If proc is traced, always give parent a chance. */ if (p->p_flag & P_TRACED) action = SIG_DFL; else { /* * If the signal is being ignored, * then we forget about it immediately. */ if (p->p_sigignore & mask) return; if (p->p_sigmask & mask) action = SIG_HOLD; else if (p->p_sigcatch & mask) action = SIG_CATCH; else action = SIG_DFL; } if (p->p_nice > NZERO && action == SIG_DFL && (prop & SA_KILL) && (p->p_flag & P_TRACED) == 0) p->p_nice = NZERO; if (prop & SA_CONT) p->p_sig &= ~stopsigmask; if (prop & SA_STOP) { /* * If sending a tty stop signal to a member of an orphaned * process group (i.e. a child of init), discard the signal * here if the action is default; don't stop the process * below if sleeping, and don't clear any pending SIGCONT. */ if ((prop & SA_TTYSTOP) && (p->p_pptr == &proc[1]) && action == SIG_DFL) return; p->p_sig &= ~contsigmask; } p->p_sig |= mask; /* * Defer further processing for signals which are held. */ if (action == SIG_HOLD && ((prop & SA_CONT) == 0 || p->p_stat != SSTOP)) return; s = splhigh(); switch (p->p_stat) { case SSLEEP: /* * If process is sleeping uninterruptibly we can not * interrupt the sleep... the signal will be noticed * when the process returns through trap() or syscall(). */ if ((p->p_flag & P_SINTR) == 0) goto out; /* * Process is sleeping and traced... make it runnable * so it can discover the signal in issignal() and stop * for the parent. */ if (p->p_flag & P_TRACED) goto run; /* * If SIGCONT is default (or ignored) and process is * asleep, we are finished; the process should not * be awakened. */ if ((prop & SA_CONT) && action == SIG_DFL) { p->p_sig &= ~mask; goto out; } /* * When a sleeping process receives a stop * signal, process immediately if possible. * All other (caught or default) signals * cause the process to run. */ if (prop & SA_STOP) { if (action != SIG_DFL) goto run; /* * If a child holding parent blocked, * stopping could cause deadlock. */ if (p->p_flag & SVFORK) goto out; p->p_sig &= ~mask; p->p_ptracesig = sig; if ((p->p_pptr->p_flag & P_NOCLDSTOP) == 0) psignal(p->p_pptr, SIGCHLD); stop(p); goto out; } else goto run; /*NOTREACHED*/ case SSTOP: /* * If traced process is already stopped, * then no further action is necessary. */ if (p->p_flag & P_TRACED) goto out; if (sig == SIGKILL) goto run; if (prop & SA_CONT) { /* * If SIGCONT is default (or ignored), we continue the * process but don't leave the signal in p_sig, as * it has no further action. If SIGCONT is held, we * continue the process and leave the signal in * p_sig. If the process catches SIGCONT, let it * handle the signal itself. If it isn't waiting on * an event, then it goes back to run state. * Otherwise, process goes back to sleep state. */ if (action == SIG_DFL) p->p_sig &= ~mask; if (action == SIG_CATCH || p->p_wchan == 0) goto run; p->p_stat = SSLEEP; goto out; } if (prop & SA_STOP) { /* * Already stopped, don't need to stop again. * (If we did the shell could get confused.) */ p->p_sig &= ~mask; /* take it away */ goto out; } /* * If process is sleeping interruptibly, then simulate a * wakeup so that when it is continued, it will be made * runnable and can look at the signal. But don't make * the process runnable, leave it stopped. */ if (p->p_wchan && (p->p_flag & P_SINTR)) unsleep(p); goto out; /*NOTREACHED*/ default: /* * SRUN, SIDL, SZOMB do nothing with the signal, * other than kicking ourselves if we are running. * It will either never be noticed, or noticed very soon. */ goto out; } /*NOTREACHED*/ run: /* * Raise priority to at least PUSER. */ if (p->p_pri > PUSER) p->p_pri = PUSER; setrun(p); out: splx(s); } /* * If the current process has received a signal (should be caught * or cause termination, should interrupt current syscall) return the * signal number. Stop signals with default action are processed * immediately then cleared; they are not returned. This is checked * after each entry into the kernel for a syscall of trap (though this * can usually be done without calling issignal by checking the pending * signals masks in CURSIG)/ The normal sequence is: * * while (signum = CURSIG(u.u_procp)) * postsig(signum); */ int issignal (p) register struct proc *p; { register int sig; long mask; int prop; for (;;) { mask = p->p_sig & ~p->p_sigmask; if (p->p_flag&SVFORK) mask &= ~stopsigmask; if (mask == 0) return(0); /* No signals to send */ sig = ffs(mask); mask = sigmask(sig); prop = sigprop[sig]; /* * We should see pending but ignored signals * only if P_TRACED was on when they were posted. */ if ((mask & p->p_sigignore) && ! (p->p_flag & P_TRACED)) { p->p_sig &= ~mask; continue; } if ((p->p_flag & P_TRACED) && ! (p->p_flag & SVFORK)) { /* * If traced, always stop, and stay * stopped until released by the parent. * * Note that we must clear the pending signal * before we call procxmt since that routine * might cause a fault, calling sleep and * leading us back here again with the same signal. * Then we would be deadlocked because the tracer * would still be blocked on the ipc struct from * the initial request. */ p->p_sig &= ~mask; p->p_ptracesig = sig; psignal(p->p_pptr, SIGCHLD); do { stop(p); swtch(); } while (! procxmt() && (p->p_flag & P_TRACED)); /* * If parent wants us to take the signal, * then it will leave it in p->p_ptracesig; * otherwise we just look for signals again. */ sig = p->p_ptracesig; if (sig == 0) continue; /* * Put the new signal into p_sig. If the * signal is being masked, look for other signals. */ mask = sigmask(sig); p->p_sig |= mask; if (p->p_sigmask & mask) continue; /* * If the traced bit got turned off, go back up * to the top to rescan signals. This ensures * that p_sig* and u_signal are consistent. */ if ((p->p_flag& P_TRACED) == 0) continue; prop = sigprop[sig]; } switch ((int)u.u_signal[sig]) { case (int)SIG_DFL: /* * Don't take default actions on system processes. */ if (p->p_pid <= 1) { #ifdef DIAGNOSTIC /* * Are you sure you want to ignore SIGSEGV * in init? XXX */ printf("Process (pid %d) got signal %d\n", p->p_pid, sig); #endif break; } /* * If there is a pending stop signal to process * with default action, stop here, * then clear the signal. However, * if process is member of an orphaned * process group, ignore tty stop signals. */ if (prop & SA_STOP) { if (p->p_flag & P_TRACED || (p->p_pptr == &proc[1] && prop & SA_TTYSTOP)) break; /* == ignore */ p->p_ptracesig = sig; if ((p->p_pptr->p_flag & P_NOCLDSTOP) == 0) psignal(p->p_pptr, SIGCHLD); stop(p); swtch(); break; } else if (prop & SA_IGNORE) { /* * Except for SIGCONT, shouldn't get here. * Default action is to ignore; drop it. */ break; /* == ignore */ } else return(sig); /*NOTREACHED*/ case (int)SIG_IGN: /* * Masking above should prevent us * ever trying to take action on a held * or ignored signal, unless process is traced. */ if ((prop & SA_CONT) == 0 && (p->p_flag & P_TRACED) == 0) printf("issig\n"); break; /* == ignore */ default: /* * This signal has an action, let postsig process it. */ return(sig); } p->p_sig &= ~mask; /* take the signal away! */ } /* NOTREACHED */ } /* * Create a core image on the file "core" * If you are looking for protection glitches, * there are probably a wealth of them here * when this occurs to a suid command. * * It writes UPAGES (USIZE for pdp11) block of the * user.h area followed by the entire * data+stack segments. */ static int core() { register struct inode *ip; struct nameidata nd; register struct nameidata *ndp = &nd; register char *np; char *cp, name[MAXCOMLEN + 6]; /* * Don't dump if not root. */ if (! suser()) return(0); if (USIZE + u.u_dsize + u.u_ssize >= u.u_rlimit[RLIMIT_CORE].rlim_cur) return (0); cp = u.u_comm; np = name; while ((*np++ = *cp++)) ; cp = ".core"; np--; while ((*np++ = *cp++)) ; u.u_error = 0; NDINIT (ndp, CREATE, FOLLOW, name); ip = namei(ndp); if (ip == NULL) { if (u.u_error) return (0); ip = maknode (0644, ndp); if (ip==NULL) return (0); } if (access(ip, IWRITE) || (ip->i_mode&IFMT) != IFREG || ip->i_nlink != 1) { u.u_error = EFAULT; goto out; } itrunc(ip, (u_long)0, 0); u.u_error = rdwri (UIO_WRITE, ip, (caddr_t) &u, USIZE, (off_t) 0, IO_UNIT, (int*) 0); if (u.u_error) goto out; u.u_error = rdwri (UIO_WRITE, ip, (caddr_t)__user_data_start, u.u_dsize, (off_t) USIZE, IO_UNIT, (int*) 0); if (u.u_error) goto out; u.u_error = rdwri (UIO_WRITE, ip, (caddr_t)__user_data_end - u.u_ssize, u.u_ssize, (off_t) USIZE + u.u_dsize, IO_UNIT, (int*) 0); out: iput(ip); return (u.u_error == 0); } /* * Take the action for the specified signal * from the current set of pending signals. */ void postsig(sig) int sig; { register struct proc *p = u.u_procp; long mask = sigmask(sig), returnmask; register sig_t action; p->p_sig &= ~mask; action = u.u_signal[sig]; if (action != SIG_DFL) { #ifdef DIAGNOSTIC if (action == SIG_IGN || (p->p_sigmask & mask)) panic("postsig action"); #endif u.u_error = 0; /* XXX - why? */ /* * Set the new mask value and also defer further * occurences of this signal. * * Special case: user has done a sigsuspend. Here the * current mask is not of interest, but rather the * mask from before the sigsuspend is what we want restored * after the signal processing is completed. */ (void) splhigh(); if (u.u_psflags & SAS_OLDMASK) { returnmask = u.u_oldmask; u.u_psflags &= ~SAS_OLDMASK; } else returnmask = p->p_sigmask; p->p_sigmask |= u.u_sigmask[sig] | mask; (void) spl0(); u.u_ru.ru_nsignals++; sendsig(action, sig, returnmask); return; } if (sigprop[sig] & SA_CORE) { u.u_arg[0] = sig; if (core()) sig |= 0200; } exit(sig); } /* * Reset signals for an exec of the specified process. In 4.4 this function * was in kern_sig.c but since in 2.11 kern_sig and kern_exec will likely be * in different overlays placing this here potentially saves a kernel overlay * switch. */ void execsigs(register struct proc *p) { register int nc; unsigned long mask; /* * Reset caught signals. Held signals remain held * through p_sigmask (unless they were caught, * and are now ignored by default). */ while (p->p_sigcatch) { nc = ffs(p->p_sigcatch); mask = sigmask(nc); p->p_sigcatch &= ~mask; if (sigprop[nc] & SA_IGNORE) { if (nc != SIGCONT) p->p_sigignore |= mask; p->p_sig &= ~mask; } u.u_signal[nc] = SIG_DFL; } /* * Reset stack state to the user stack (disable the alternate stack). */ u.u_sigstk.ss_flags = SA_DISABLE; u.u_sigstk.ss_size = 0; u.u_sigstk.ss_base = 0; u.u_psflags = 0; } /* * nonexistent system call-- signal process (may want to handle it) * flag error if process won't see signal immediately * Q: should we do that all the time ?? */ void nosys() { if (u.u_signal[SIGSYS] == SIG_IGN || u.u_signal[SIGSYS] == SIG_HOLD) u.u_error = EINVAL; psignal(u.u_procp, SIGSYS); } void userret(int pc, time_t syst) { int psig; /* Process all received signals. */ for (;;) { psig = CURSIG(u.u_procp); if (psig <= 0) break; postsig(psig); } curpri = setpri(u.u_procp); /* Switch to another process. */ if (runrun) { setrq(u.u_procp); u.u_ru.ru_nivcsw++; swtch(); } /* Update profiling information. */ if (u.u_prof.pr_scale) addupc((caddr_t)pc, &u.u_prof, (int)(u.u_ru.ru_stime - syst)); } ================================================ FILE: sys/kern/kern_sig2.c ================================================ /* * Copyright (c) 1982, 1986, 1989, 1991, 1993 * The Regents of the University of California. All rights reserved. * (c) UNIX System Laboratories, Inc. * All or some portions of this file are derived from material licensed * to the University of California by American Telephone and Telegraph * Co. or Unix System Laboratories, Inc. and are reproduced herein with * the permission of UNIX System Laboratories, Inc. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ /* * This module is a hacked down version of kern_sig.c from 4.4BSD. The * original signal handling code is still present in 2.11's kern_sig.c. This * was done because large modules are very hard to fit into the kernel's * overlay structure. A smaller kern_sig2.c fits more easily into an overlaid * kernel. */ #define SIGPROP /* include signal properties table */ #include #include #include #include #include #include #include #include #include #include #include /* for coredump */ static void setsigvec(signum, sa) int signum; register struct sigaction *sa; { unsigned long bit; register struct proc *p = u.u_procp; bit = sigmask(signum); /* * Change setting atomically. */ (void) splhigh(); u.u_signal[signum] = sa->sa_handler; u.u_sigmask[signum] = sa->sa_mask &~ sigcantmask; if ((sa->sa_flags & SA_RESTART) == 0) u.u_sigintr |= bit; else u.u_sigintr &= ~bit; if (sa->sa_flags & SA_ONSTACK) u.u_sigonstack |= bit; else u.u_sigonstack &= ~bit; if (signum == SIGCHLD) { if (sa->sa_flags & SA_NOCLDSTOP) p->p_flag |= P_NOCLDSTOP; else p->p_flag &= ~P_NOCLDSTOP; } /* * Set bit in p_sigignore for signals that are set to SIG_IGN, * and for signals set to SIG_DFL where the default is to ignore. * However, don't put SIGCONT in p_sigignore, * as we have to restart the process. */ if (sa->sa_handler == SIG_IGN || (sigprop[signum] & SA_IGNORE && sa->sa_handler == SIG_DFL)) { p->p_sig &= ~bit; /* never to be seen again */ if (signum != SIGCONT) p->p_sigignore |= bit; /* easier in psignal */ p->p_sigcatch &= ~bit; } else { p->p_sigignore &= ~bit; if (sa->sa_handler == SIG_DFL) p->p_sigcatch &= ~bit; else p->p_sigcatch |= bit; } (void) spl0(); } void sigaction() { register struct a { int signum; struct sigaction *nsa; struct sigaction *osa; u_int sigtramp; } *uap = (struct a *)u.u_arg; struct sigaction vec; register struct sigaction *sa; register int signum; u_long bit; int error = 0; u.u_sigtramp = uap->sigtramp; /* save trampoline address */ signum = uap->signum; if (signum <= 0 || signum >= NSIG) { error = EINVAL; goto out; } if (uap->nsa && (signum == SIGKILL || signum == SIGSTOP)) { error = EINVAL; goto out; } sa = &vec; if (uap->osa) { sa->sa_handler = u.u_signal[signum]; sa->sa_mask = u.u_sigmask[signum]; bit = sigmask(signum); sa->sa_flags = 0; if ((u.u_sigonstack & bit) != 0) sa->sa_flags |= SA_ONSTACK; if ((u.u_sigintr & bit) == 0) sa->sa_flags |= SA_RESTART; if (u.u_procp->p_flag & P_NOCLDSTOP) sa->sa_flags |= SA_NOCLDSTOP; error = copyout ((caddr_t) sa, (caddr_t) uap->osa, sizeof(vec)); if (error != 0) goto out; } if (uap->nsa) { error = copyin ((caddr_t) uap->nsa, (caddr_t) sa, sizeof(vec)); if (error != 0) goto out; setsigvec(signum, sa); } out: u.u_error = error; } /* * Kill current process with the specified signal in an uncatchable manner; * used when process is too confused to continue, or we are unable to * reconstruct the process state safely. */ void fatalsig(signum) int signum; { unsigned long mask; register struct proc *p = u.u_procp; u.u_signal[signum] = SIG_DFL; mask = sigmask(signum); p->p_sigignore &= ~mask; p->p_sigcatch &= ~mask; p->p_sigmask &= ~mask; psignal(p, signum); } /* * Initialize signal state for process 0; * set to ignore signals that are ignored by default. */ void siginit(p) register struct proc *p; { register int i; for (i = 0; i < NSIG; i++) if (sigprop[i] & SA_IGNORE && i != SIGCONT) p->p_sigignore |= sigmask(i); } /* * Manipulate signal mask. * Unlike 4.4BSD we do not receive a pointer to the new and old mask areas and * do a copyin/copyout instead of storing indirectly thru a 'retval' parameter. * This is because we have to return both an error indication (which is 16 bits) * _AND_ the new mask (which is 32 bits). Can't do both at the same time with * the 2BSD syscall return mechanism. */ void sigprocmask() { register struct a { int how; sigset_t *set; sigset_t *oset; } *uap = (struct a *)u.u_arg; int error = 0; sigset_t oldmask, newmask; register struct proc *p = u.u_procp; oldmask = p->p_sigmask; if (! uap->set) /* No new mask, go possibly return old mask */ goto out; error = copyin ((caddr_t) uap->set, (caddr_t) &newmask, sizeof (newmask)); if (error) goto out; (void) splhigh(); switch (uap->how) { case SIG_BLOCK: p->p_sigmask |= (newmask &~ sigcantmask); break; case SIG_UNBLOCK: p->p_sigmask &= ~newmask; break; case SIG_SETMASK: p->p_sigmask = newmask &~ sigcantmask; break; default: error = EINVAL; break; } (void) spl0(); out: if (error == 0 && uap->oset) error = copyout ((caddr_t) &oldmask, (caddr_t) uap->oset, sizeof (oldmask)); u.u_error = error; } /* * sigpending and sigsuspend use the standard calling sequence unlike 4.4 which * used a nonstandard (mask instead of pointer) calling convention. */ void sigpending() { register struct a { struct sigset_t *set; } *uap = (struct a *)u.u_arg; register int error = 0; struct proc *p = u.u_procp; if (uap->set) error = copyout((caddr_t)&p->p_sig, (caddr_t)uap->set, sizeof (p->p_sig)); else error = EINVAL; u.u_error = error; } /* * sigsuspend is supposed to always return EINTR so we ignore errors on the * copyin by assuming a mask of 0. */ void sigsuspend() { register struct a { struct sigset_t *set; } *uap = (struct a *)u.u_arg; sigset_t nmask = 0; struct proc *p = u.u_procp; int error; if (uap->set && (error = copyin ((caddr_t) uap->set, (caddr_t) &nmask, sizeof (nmask)))) nmask = 0; /* * When returning from sigsuspend, we want the old mask to be restored * after the signal handler has finished. Thus, we save it here and set * a flag to indicate this. */ u.u_oldmask = p->p_sigmask; u.u_psflags |= SAS_OLDMASK; p->p_sigmask = nmask &~ sigcantmask; while (tsleep((caddr_t)&u, PPAUSE|PCATCH, 0) == 0) ; /* always return EINTR rather than ERESTART */ u.u_error = EINTR; } void sigaltstack() { register struct a { struct sigaltstack * nss; struct sigaltstack * oss; } *uap = (struct a *)u.u_arg; struct sigaltstack ss; int error = 0; if ((u.u_psflags & SAS_ALTSTACK) == 0) u.u_sigstk.ss_flags |= SA_DISABLE; if (uap->oss && (error = copyout((caddr_t)&u.u_sigstk, (caddr_t)uap->oss, sizeof (struct sigaltstack)))) goto out; if (uap->nss == 0) goto out; error = copyin ((caddr_t) uap->nss, (caddr_t) &ss, sizeof(ss)); if (error != 0) goto out; if (ss.ss_flags & SA_DISABLE) { if (u.u_sigstk.ss_flags & SA_ONSTACK) { error = EINVAL; goto out; } u.u_psflags &= ~SAS_ALTSTACK; u.u_sigstk.ss_flags = ss.ss_flags; goto out; } if (ss.ss_size < MINSIGSTKSZ) { error = ENOMEM; goto out; } u.u_psflags |= SAS_ALTSTACK; u.u_sigstk = ss; out: u.u_error = error; } void sigwait() { register struct a { sigset_t *set; int *sig; } *uap = (struct a *)u.u_arg; sigset_t wanted, sigsavail; register struct proc *p = u.u_procp; int signo, error; if (uap->set == 0 || uap->sig == 0) { error = EINVAL; goto out; } error = copyin ((caddr_t) uap->set, (caddr_t) &wanted, sizeof (sigset_t)); if (error) goto out; wanted |= sigcantmask; while ((sigsavail = (wanted & p->p_sig)) == 0) tsleep ((caddr_t) &u.u_signal[0], PPAUSE | PCATCH, 0); if (sigsavail & sigcantmask) { error = EINTR; goto out; } signo = ffs(sigsavail); p->p_sig &= ~sigmask(signo); error = copyout ((caddr_t) &signo, (caddr_t) uap->sig, sizeof (int)); out: u.u_error = error; } ================================================ FILE: sys/kern/kern_subr.c ================================================ /* * Copyright (c) 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include #include #include #include #include /* * Move data to/from user space. */ int uiomove (cp, n, uio) caddr_t cp; u_int n; register struct uio *uio; { register struct iovec *iov; int error = 0; register u_int cnt; while (n > 0 && uio->uio_resid) { iov = uio->uio_iov; cnt = iov->iov_len; if (cnt == 0) { uio->uio_iov++; uio->uio_iovcnt--; continue; } if (cnt > n) cnt = n; if (uio->uio_rw == UIO_READ) bcopy ((caddr_t) cp, iov->iov_base, cnt); else bcopy (iov->iov_base, (caddr_t) cp, cnt); iov->iov_base += cnt; iov->iov_len -= cnt; uio->uio_resid -= cnt; uio->uio_offset += cnt; cp += cnt; n -= cnt; } return (error); } /* * Give next character to user as result of read. */ int ureadc (c, uio) register int c; register struct uio *uio; { register struct iovec *iov; again: if (uio->uio_iovcnt == 0) panic("ureadc"); iov = uio->uio_iov; if (iov->iov_len == 0 || uio->uio_resid == 0) { uio->uio_iovcnt--; uio->uio_iov++; goto again; } *iov->iov_base = c; iov->iov_base++; iov->iov_len--; uio->uio_resid--; uio->uio_offset++; return (0); } /* * Get next character written in by user from uio. */ int uwritec(uio) register struct uio *uio; { register struct iovec *iov; register int c; if (uio->uio_resid == 0) return (-1); again: if (uio->uio_iovcnt <= 0) panic("uwritec"); iov = uio->uio_iov; if (iov->iov_len == 0) { uio->uio_iov++; if (--uio->uio_iovcnt == 0) return (-1); goto again; } c = (u_char) *iov->iov_base; iov->iov_base++; iov->iov_len--; uio->uio_resid--; uio->uio_offset++; return (c & 0377); } /* * Copy bytes to/from the kernel and the user. */ int uiofmove(cp, n, uio, iov) caddr_t cp; register int n; struct uio *uio; struct iovec *iov; { if (uio->uio_rw == UIO_READ) { /* From kernel to user. */ bcopy(cp, iov->iov_base, n); } else { /* From user to kernel. */ bcopy(iov->iov_base, cp, n); } return(0); } ================================================ FILE: sys/kern/kern_synch.c ================================================ /* * Copyright (c) 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include #include #include #include #include #include #include #include #include #define SQSIZE 16 /* Must be power of 2 */ #define HASH(x) (((int)x >> 5) & (SQSIZE - 1)) #define SCHMAG 8/10 struct proc *slpque[SQSIZE]; int runrun; /* scheduling flag */ char curpri; /* more scheduling */ /* * Recompute process priorities, once a second */ void schedcpu (caddr_t arg) { register struct proc *p; register int a; wakeup((caddr_t)&lbolt); for (p = allproc; p != NULL; p = p->p_nxt) { if (p->p_time != 127) p->p_time++; /* * this is where 2.11 does its real time alarms. 4.X uses * timeouts, since it offers better than second resolution. * Putting it here allows us to continue using use an int * to store the number of ticks in the callout structure, * since the kernel never has a timeout of greater than * around 9 minutes. */ if (p->p_realtimer.it_value && !--p->p_realtimer.it_value) { psignal(p, SIGALRM); p->p_realtimer.it_value = p->p_realtimer.it_interval; } if (p->p_stat == SSLEEP || p->p_stat == SSTOP) if (p->p_slptime != 127) p->p_slptime++; if (p->p_slptime > 1) continue; a = (p->p_cpu & 0377) * SCHMAG + p->p_nice; if (a < 0) a = 0; if (a > 255) a = 255; p->p_cpu = a; if (p->p_pri >= PUSER) setpri(p); } vmmeter(); if (runin != 0) { runin = 0; wakeup((caddr_t)&runin); } ++runrun; /* swtch at least once a second */ timeout (schedcpu, (caddr_t) 0, hz); } /* * Recalculate the priority of a process after it has slept for a while. */ void updatepri(p) register struct proc *p; { register int a = p->p_cpu & 0377; p->p_slptime--; /* the first time was done in schedcpu */ while (a && --p->p_slptime) a = (SCHMAG * a) /* + p->p_nice */; if (a < 0) a = 0; if (a > 255) a = 255; p->p_cpu = a; (void) setpri(p); } /* * Implement timeout for tsleep above. If process hasn't been awakened * (p_wchan non zero) then set timeout flag and undo the sleep. If proc * is stopped just unsleep so it will remain stopped. */ static void endtsleep (p) register struct proc *p; { register int s; s = splhigh(); if (p->p_wchan) { if (p->p_stat == SSLEEP) setrun(p); else unsleep(p); p->p_flag |= P_TIMEOUT; } splx(s); } /* * General sleep call "borrowed" from 4.4BSD - the 'wmesg' parameter was * removed due to data space concerns. Sleeps at most timo/hz seconds * 0 means no timeout). NOTE: timeouts in 2.11BSD use a signed int and * thus can be at most 32767 'ticks' or about 540 seconds in the US with * 60hz power (~650 seconds if 50hz power is being used). * * If 'pri' includes the PCATCH flag signals are checked before and after * sleeping otherwise signals are not checked. Returns 0 if a wakeup was * done, EWOULDBLOCK if the timeout expired, ERESTART if the current system * call should be restarted, and EINTR if the system call should be * interrupted and EINTR returned to the user process. */ int tsleep (ident, priority, timo) caddr_t ident; int priority; u_int timo; { register struct proc *p = u.u_procp; register struct proc **qp; int s; int sig, catch = priority & PCATCH; s = splhigh(); if (panicstr) { /* * After a panic just give interrupts a chance then just return. Don't * run any other procs (or panic again below) in case this is the idle * process and already asleep. The splnet should be spl0 if the network * was being used but for now avoid network interrupts that might cause * another panic. */ (void) splnet(); noop(); splx(s); return(0); } #ifdef DIAGNOSTIC if (ident == NULL || p->p_stat != SRUN) panic("tsleep"); #endif p->p_wchan = ident; p->p_slptime = 0; p->p_pri = priority & PRIMASK; qp = &slpque[HASH(ident)]; p->p_link = *qp; *qp = p; if (timo) timeout (endtsleep, (caddr_t)p, timo); /* * We put outselves on the sleep queue and start the timeout before calling * CURSIG as we could stop there and a wakeup or a SIGCONT (or both) could * occur while we were stopped. A SIGCONT would cause us to be marked SSLEEP * without resuming us thus we must be ready for sleep when CURSIG is called. * If the wakeup happens while we're stopped p->p_wchan will be 0 upon * return from CURSIG. */ if (catch) { p->p_flag |= P_SINTR; sig = CURSIG(p); if (sig) { if (p->p_wchan) unsleep(p); p->p_stat = SRUN; goto resume; } if (p->p_wchan == 0) { catch = 0; goto resume; } } else sig = 0; p->p_stat = SSLEEP; if (p != &proc[0]) wakeup((caddr_t) &runin); u.u_ru.ru_nvcsw++; swtch(); resume: splx(s); p->p_flag &= ~P_SINTR; if (p->p_flag & P_TIMEOUT) { p->p_flag &= ~P_TIMEOUT; if (sig == 0) return(EWOULDBLOCK); } else if (timo) untimeout (endtsleep, (caddr_t)p); if (catch && (sig != 0 || (sig = CURSIG(p)))) { if (u.u_sigintr & sigmask(sig)) return(EINTR); return(ERESTART); } return(0); } /* * Give up the processor till a wakeup occurs on chan, at which time the * process enters the scheduling queue at priority pri. * * This routine was rewritten to use 'tsleep'. The old behaviour of sleep * being interruptible (if 'pri>PZERO') is emulated by setting PCATCH and * then performing the 'longjmp' if the return value of 'tsleep' is * ERESTART. * * Callers of this routine must be prepared for premature return, and check * that the reason for sleeping has gone away. */ void sleep (chan, pri) caddr_t chan; int pri; { register int priority = pri; if (pri > PZERO) priority |= PCATCH; u.u_error = tsleep (chan, priority, 0); /* * sleep does not return anything. If it was a non-interruptible sleep _or_ * a successful/normal sleep (one for which a wakeup was done) then return. */ if ((priority & PCATCH) == 0 || (u.u_error == 0)) return; /* * XXX - compatibility uglyness. * * The tsleep() above will leave one of the following in u_error: * * 0 - a wakeup was done, this is handled above * EWOULDBLOCK - since no timeout was passed to tsleep we will not see this * EINTR - put into u_error for trap.c to find (interrupted syscall) * ERESTART - system call to be restared */ longjmp (u.u_procp->p_addr, &u.u_qsave); /*NOTREACHED*/ } /* * Remove a process from its wait queue */ void unsleep (p) register struct proc *p; { register struct proc **hp; register int s; s = splhigh(); if (p->p_wchan) { hp = &slpque[HASH(p->p_wchan)]; while (*hp != p) hp = &(*hp)->p_link; *hp = p->p_link; p->p_wchan = 0; } splx(s); } /* * Wake up all processes sleeping on chan. */ void wakeup (chan) register caddr_t chan; { register struct proc *p, **q; struct proc **qp; int s; /* * Since we are called at interrupt time, must insure normal * kernel mapping to access proc. */ s = splclock(); qp = &slpque[HASH(chan)]; restart: for (q = qp; (p = *q); ) { if (p->p_stat != SSLEEP && p->p_stat != SSTOP) panic("wakeup"); if (p->p_wchan==chan) { p->p_wchan = 0; *q = p->p_link; if (p->p_stat == SSLEEP) { /* OPTIMIZED INLINE EXPANSION OF setrun(p) */ if (p->p_slptime > 1) updatepri(p); p->p_slptime = 0; p->p_stat = SRUN; if (p->p_flag & SLOAD) setrq(p); /* * Since curpri is a usrpri, * p->p_pri is always better than curpri. */ runrun++; if (! (p->p_flag & SLOAD)) { if (runout != 0) { runout = 0; wakeup((caddr_t)&runout); } } /* END INLINE EXPANSION */ goto restart; } p->p_slptime = 0; } else q = &p->p_link; } splx(s); } /* * Set the process running; * arrange for it to be swapped in if necessary. */ void setrun (p) register struct proc *p; { register int s; s = splhigh(); switch (p->p_stat) { case 0: case SWAIT: case SRUN: case SZOMB: default: panic("setrun"); case SSTOP: case SSLEEP: unsleep(p); /* e.g. when sending signals */ break; case SIDL: break; } if (p->p_slptime > 1) updatepri(p); p->p_stat = SRUN; if (p->p_flag & SLOAD) setrq(p); splx(s); if (p->p_pri < curpri) runrun++; if (! (p->p_flag & SLOAD)) { if (runout != 0) { runout = 0; wakeup((caddr_t)&runout); } } } /* * Set user priority. * The rescheduling flag (runrun) * is set if the priority is better * than the currently running process. */ int setpri (pp) register struct proc *pp; { register int p; p = (pp->p_cpu & 0377)/16; p += PUSER + pp->p_nice; if (p > 127) p = 127; if (p < curpri) runrun++; pp->p_pri = p; return (p); } /* * This routine is called to reschedule the CPU. If the calling process is * not in RUN state, arrangements for it to restart must have been made * elsewhere, usually by calling via sleep. There is a race here. A process * may become ready after it has been examined. In this case, idle() will be * called and will return in at most 1hz time, e.g. it's not worth putting an * spl() in. */ void swtch() { register struct proc *p, *q; register int n; struct proc *pp, *pq; int s; #ifdef UCB_METER cnt.v_swtch++; #endif /* If not the idle process, resume the idle process. */ if (u.u_procp != &proc[0]) { if (setjmp (&u.u_rsave)) { /* Returned from swapper to user process. */ return; } /* Switch from user process to swapper. */ longjmp (proc[0].p_addr, &u.u_qsave); } /* * The first save returns nonzero when proc 0 is resumed * by another process (above); then the second is not done * and the process-search loop is entered. */ if (setjmp (&u.u_qsave)) { /* Returned from user process. */ goto loop; } /* * The first save returns 0 when swtch is called in proc 0 * from sched(). The second save returns 0 immediately, so * in this case too the process-search loop is entered. * Thus when proc 0 is awakened by being made runnable, it will * find itself and resume itself at rsave, and return to sched(). */ if (setjmp (&u.u_rsave)) { /* Swapper resumed by itself. */ return; } loop: s = splhigh(); noproc = 0; runrun = 0; #ifdef DIAGNOSTIC for (p = qs; p; p = p->p_link) if (p->p_stat != SRUN) panic ("swtch SRUN"); #endif pp = NULL; q = NULL; n = 128; /* * search for highest-priority runnable process */ pq = 0; for (p = qs; p; p = p->p_link) { if (p->p_flag & SLOAD && p->p_pri < n) { pp = p; pq = q; n = p->p_pri; } q = p; } /* * if no process is runnable, idle. */ p = pp; if (p == NULL) { idle(); goto loop; } if (pq) pq->p_link = p->p_link; else qs = p->p_link; curpri = n; splx(s); /* * the rsave (ssave) contents are interpreted * in the new address space */ n = p->p_flag & SSWAP; p->p_flag &= ~SSWAP; longjmp (p->p_addr, n ? &u.u_ssave : &u.u_rsave); } /* * Put the process into the run queue. */ void setrq (p) register struct proc *p; { register int s; s = splhigh(); #ifdef DIAGNOSTIC { /* see if already on the run queue */ register struct proc *q; for (q = qs;q != NULL;q = q->p_link) if (q == p) panic("setrq"); } #endif p->p_link = qs; qs = p; splx(s); } /* * Remove runnable job from run queue. This is done when a runnable job * is swapped out so that it won't be selected in swtch(). It will be * reinserted in the qs with setrq when it is swapped back in. */ void remrq (p) register struct proc *p; { register struct proc *q; register int s; s = splhigh(); if (p == qs) qs = p->p_link; else { for (q = qs; q; q = q->p_link) if (q->p_link == p) { q->p_link = p->p_link; goto done; } panic("remrq"); } done: splx(s); } ================================================ FILE: sys/kern/kern_sysctl.c ================================================ /*- * Copyright (c) 1982, 1986, 1989, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Mike Karels at Berkeley Software Design, Inc. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)kern_sysctl.c 8.4.12 (2.11BSD) 2000/5/17 */ /* * sysctl system call. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include sysctlfn kern_sysctl; sysctlfn hw_sysctl; #ifdef DEBUG sysctlfn debug_sysctl; #endif sysctlfn vm_sysctl; sysctlfn fs_sysctl; #ifdef INET sysctlfn net_sysctl; #endif sysctlfn cpu_sysctl; struct sysctl_args { int *name; u_int namelen; void *old; size_t *oldlenp; void *new; size_t newlen; }; void __sysctl() { struct sysctl_args *uap = (struct sysctl_args *)u.u_arg; int error; u_int oldlen = 0; sysctlfn *fn; int name[CTL_MAXNAME]; if (uap->new != NULL && !suser()) return; /* * All top-level sysctl names are non-terminal. */ if (uap->namelen > CTL_MAXNAME || uap->namelen < 2) { u.u_error = EINVAL; return; } error = copyin((caddr_t)uap->name, (caddr_t)&name, uap->namelen * sizeof(int)); if (error) { u.u_error = error; return; } switch (name[0]) { case CTL_KERN: fn = kern_sysctl; break; case CTL_HW: fn = hw_sysctl; break; case CTL_VM: fn = vm_sysctl; break; #ifdef INET case CTL_NET: fn = net_sysctl; break; #endif #ifdef notyet case CTL_FS: fn = fs_sysctl; break; #endif case CTL_MACHDEP: fn = cpu_sysctl; break; #ifdef DEBUG case CTL_DEBUG: fn = debug_sysctl; break; #endif default: u.u_error = EOPNOTSUPP; return; } if (uap->oldlenp && (error = copyin((caddr_t)uap->oldlenp, (caddr_t)&oldlen, sizeof(oldlen)))) { u.u_error = error; return; } if (uap->old != NULL) { while (memlock.sl_lock) { memlock.sl_want = 1; sleep((caddr_t)&memlock, PRIBIO + 1); memlock.sl_locked++; } memlock.sl_lock = 1; } error = (*fn)(name + 1, uap->namelen - 1, uap->old, &oldlen, uap->new, uap->newlen); if (uap->old != NULL) { memlock.sl_lock = 0; if (memlock.sl_want) { memlock.sl_want = 0; wakeup((caddr_t)&memlock); } } if (error) { u.u_error = error; return; } if (uap->oldlenp) { error = copyout((caddr_t)&oldlen, (caddr_t)uap->oldlenp, sizeof(oldlen)); if (error) { u.u_error = error; return; } } u.u_rval = oldlen; } /* * Kernel related system variables. */ int kern_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, size_t newlen) { int error, level; u_long longhostid; /* All sysctl names at this level are terminal. */ if (namelen != 1 && !(name[0] == KERN_PROC || name[0] == KERN_PROF)) return (ENOTDIR); /* overloaded */ switch (name[0]) { case KERN_OSTYPE: return (sysctl_rdstring(oldp, oldlenp, newp, ostype)); case KERN_OSRELEASE: return (sysctl_rdstring(oldp, oldlenp, newp, osrelease)); case KERN_OSREV: return (sysctl_rdlong(oldp, oldlenp, newp, (long)DiscoBSD)); case KERN_OSVERSION: return (sysctl_rdstring(oldp, oldlenp, newp, osversion)); case KERN_VERSION: return (sysctl_rdstring(oldp, oldlenp, newp, version)); case KERN_MAXINODES: return (sysctl_rdint(oldp, oldlenp, newp, NINODE)); case KERN_MAXPROC: return (sysctl_rdint(oldp, oldlenp, newp, NPROC)); case KERN_MAXFILES: return (sysctl_rdint(oldp, oldlenp, newp, NFILE)); case KERN_ARGMAX: return (sysctl_rdint(oldp, oldlenp, newp, NCARGS)); case KERN_SECURELVL: level = securelevel; if ((error = sysctl_int(oldp, oldlenp, newp, newlen, &level)) || newp == NULL) return (error); if (level < securelevel && u.u_procp->p_pid != 1) return (EPERM); securelevel = level; return (0); case KERN_HOSTNAME: error = sysctl_string(oldp, oldlenp, newp, newlen, hostname, sizeof(hostname)); if (newp && !error) hostnamelen = newlen; return (error); case KERN_HOSTID: longhostid = hostid; error = sysctl_long(oldp, oldlenp, newp, newlen, (long *)&longhostid); hostid = longhostid; return (error); case KERN_CLOCKRATE: return (sysctl_clockrate(oldp, oldlenp)); case KERN_BOOTTIME: return (sysctl_rdstruct(oldp, oldlenp, newp, &boottime, sizeof(struct timeval))); case KERN_INODE: return (sysctl_inode(oldp, oldlenp)); case KERN_PROC: return (sysctl_doproc(name + 1, namelen - 1, oldp, oldlenp)); case KERN_FILE: return (sysctl_file(oldp, oldlenp)); #ifdef GPROF case KERN_PROF: return (sysctl_doprof(name + 1, namelen - 1, oldp, oldlenp, newp, newlen)); #endif case KERN_NGROUPS: return (sysctl_rdint(oldp, oldlenp, newp, NGROUPS)); case KERN_JOB_CONTROL: return (sysctl_rdint(oldp, oldlenp, newp, 1)); case KERN_POSIX1: case KERN_SAVED_IDS: return (sysctl_rdint(oldp, oldlenp, newp, 0)); default: return (EOPNOTSUPP); } /* NOTREACHED */ } /* * Hardware related system variables. */ int hw_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, size_t newlen) { extern char machine[], machine_arch[], cpu_model[]; /* All sysctl names at this level are terminal. */ if (namelen != 1) return (ENOTDIR); /* overloaded */ switch (name[0]) { case HW_MACHINE: return (sysctl_rdstring(oldp, oldlenp, newp, machine)); case HW_MODEL: return (sysctl_rdstring(oldp, oldlenp, newp, cpu_model)); case HW_NCPU: return (sysctl_rdint(oldp, oldlenp, newp, 1)); /* XXX */ case HW_BYTEORDER: return (sysctl_rdint(oldp, oldlenp, newp, ENDIAN)); case HW_PHYSMEM: return (sysctl_rdlong(oldp, oldlenp, newp, physmem)); #ifdef UCB_METER case HW_USERMEM: return (sysctl_rdlong(oldp, oldlenp, newp, freemem)); #endif case HW_PAGESIZE: return (sysctl_rdint(oldp, oldlenp, newp, DEV_BSIZE)); case HW_MACHINE_ARCH: return (sysctl_rdstring(oldp, oldlenp, newp, machine_arch)); default: return (EOPNOTSUPP); } /* NOTREACHED */ } #ifdef DEBUG /* * Debugging related system variables. */ struct ctldebug debug0, debug1, debug2, debug3, debug4; struct ctldebug debug5, debug6, debug7, debug8, debug9; struct ctldebug debug10, debug11, debug12, debug13, debug14; struct ctldebug debug15, debug16, debug17, debug18, debug19; static struct ctldebug *debugvars[CTL_DEBUG_MAXID] = { &debug0, &debug1, &debug2, &debug3, &debug4, &debug5, &debug6, &debug7, &debug8, &debug9, &debug10, &debug11, &debug12, &debug13, &debug14, &debug15, &debug16, &debug17, &debug18, &debug19, }; int debug_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, size_t newlen) { struct ctldebug *cdp; /* All sysctl names at this level are name and field. */ if (namelen != 2) return (ENOTDIR); /* overloaded */ cdp = debugvars[name[0]]; if (cdp->debugname == 0) return (EOPNOTSUPP); switch (name[1]) { case CTL_DEBUG_NAME: return (sysctl_rdstring(oldp, oldlenp, newp, cdp->debugname)); case CTL_DEBUG_VALUE: return (sysctl_int(oldp, oldlenp, newp, newlen, cdp->debugvar)); default: return (EOPNOTSUPP); } /* NOTREACHED */ } #endif /* DEBUG */ /* * Bit of a hack. 2.11 currently uses 'short avenrun[3]' and a fixed scale * of 256. In order not to break all the applications which nlist() for * 'avenrun' we build a local 'averunnable' structure here to return to the * user. Eventually (after all applications which look up the load average * the old way) have been converted we can change things. * * We do not call vmtotal(), that could get rather expensive, rather we rely * on the 5 second update. * * The swapmap case is a 2.11BSD extension. */ int vm_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, size_t newlen) { struct loadavg averunnable; /* loadavg in resource.h */ /* All sysctl names at this level are terminal. */ if (namelen != 1) return (ENOTDIR); /* overloaded */ switch (name[0]) { case VM_LOADAVG: averunnable.fscale = 256; averunnable.ldavg[0] = avenrun[0]; averunnable.ldavg[1] = avenrun[1]; averunnable.ldavg[2] = avenrun[2]; return (sysctl_rdstruct(oldp, oldlenp, newp, &averunnable, sizeof(averunnable))); case VM_METER: #ifdef notsure vmtotal(); /* Could be expensive to do this every time. */ #endif return (sysctl_rdstruct(oldp, oldlenp, newp, &total, sizeof(total))); case VM_SWAPMAP: if (oldp == NULL) { *oldlenp = (char *)swapmap[0].m_limit - (char *)swapmap[0].m_map; return (0); } return (sysctl_rdstruct(oldp, oldlenp, newp, swapmap, (int)swapmap[0].m_limit - (int)swapmap[0].m_map)); default: return (EOPNOTSUPP); } /* NOTREACHED */ } /* * Validate parameters and get old / set new parameters * for an integer-valued sysctl function. */ int sysctl_int(void *oldp, size_t *oldlenp, void *newp, size_t newlen, int *valp) { int error = 0; if (oldp && *oldlenp < sizeof(int)) return (ENOMEM); if (newp && newlen != sizeof(int)) return (EINVAL); *oldlenp = sizeof(int); if (oldp) error = copyout((caddr_t)valp, (caddr_t)oldp, sizeof(int)); if (error == 0 && newp) error = copyin((caddr_t)newp, (caddr_t)valp, sizeof(int)); return (error); } /* * As above, but read-only. */ int sysctl_rdint(void *oldp, size_t *oldlenp, void *newp, int val) { int error = 0; if (oldp && *oldlenp < sizeof(int)) return (ENOMEM); if (newp) return (EPERM); *oldlenp = sizeof(int); if (oldp) error = copyout((caddr_t)&val, oldp, sizeof(int)); return (error); } /* * Validate parameters and get old / set new parameters * for a long-valued sysctl function. */ int sysctl_long(void *oldp, size_t *oldlenp, void *newp, size_t newlen, long *valp) { int error = 0; if (oldp && *oldlenp < sizeof(long)) return (ENOMEM); if (newp && newlen != sizeof(long)) return (EINVAL); *oldlenp = sizeof(long); if (oldp) error = copyout((caddr_t)valp, (caddr_t)oldp, sizeof(long)); if (error == 0 && newp) error = copyin((caddr_t)newp, (caddr_t)valp, sizeof(long)); return (error); } /* * As above, but read-only. */ int sysctl_rdlong(void *oldp, size_t *oldlenp, void *newp, long val) { int error = 0; if (oldp && *oldlenp < sizeof(long)) return (ENOMEM); if (newp) return (EPERM); *oldlenp = sizeof(long); if (oldp) error = copyout((caddr_t)&val, oldp, sizeof(long)); return (error); } /* * Validate parameters and get old / set new parameters * for a string-valued sysctl function. */ int sysctl_string(void *oldp, size_t *oldlenp, void *newp, size_t newlen, char *str, int maxlen) { int len, error = 0; len = strlen(str) + 1; if (oldp && *oldlenp < len) return (ENOMEM); if (newp && newlen >= maxlen) return (EINVAL); if (oldp) { *oldlenp = len; error = copyout(str, oldp, len); } if (error == 0 && newp) { error = copyin(newp, str, newlen); str[newlen] = 0; } return (error); } /* * As above, but read-only. */ int sysctl_rdstring(void *oldp, size_t *oldlenp, void *newp, const char *str) { int len, error = 0; len = strlen(str) + 1; if (oldp && *oldlenp < len) return (ENOMEM); if (newp) return (EPERM); *oldlenp = len; if (oldp) error = copyout((caddr_t)str, oldp, len); return (error); } /* * Validate parameters and get old / set new parameters * for a structure-oriented sysctl function. */ int sysctl_struct(void *oldp, size_t *oldlenp, void *newp, size_t newlen, void *sp, int len) { int error = 0; if (oldp && *oldlenp < len) return (ENOMEM); if (newp && newlen > len) return (EINVAL); if (oldp) { *oldlenp = len; error = copyout(sp, oldp, len); } if (error == 0 && newp) error = copyin(newp, sp, len); return (error); } /* * As above, but read-only. */ int sysctl_rdstruct(void *oldp, size_t *oldlenp, void *newp, void *sp, int len) { int error = 0; if (oldp && *oldlenp < len) return (ENOMEM); if (newp) return (EPERM); *oldlenp = len; if (oldp) error = copyout(sp, oldp, len); return (error); } /* * Get file structures. */ int sysctl_file(char *where, size_t *sizep) { int buflen, error; struct file *fp; struct file *fpp; char *start = where; int i; buflen = *sizep; if (where == NULL) { for (i = 0, fp = file; fp < file + NFILE; fp++) if (fp->f_count) i++; #define FPTRSZ sizeof(struct file *) #define FILESZ sizeof(struct file) /* * Overestimate by 5 files. */ *sizep = (i + 5) * (FILESZ + FPTRSZ); return (0); } /* * Array of extended file structures: first the address then the * file structure. */ for (fp = file; fp < file + NFILE; fp++) { if (fp->f_count == 0) continue; if (buflen < (FPTRSZ + FILESZ)) { *sizep = where - start; return (ENOMEM); } fpp = fp; if ((error = copyout((caddr_t)&fpp, (caddr_t)where, FPTRSZ)) || (error = copyout((caddr_t)fp, (caddr_t)(where + FPTRSZ), FILESZ))) return (error); buflen -= (FPTRSZ + FILESZ); where += (FPTRSZ + FILESZ); } *sizep = where - start; return (0); } /* * This one is in kern_clock.c in 4.4 but placed here for the reasons * given earlier (back around line 367). */ int sysctl_clockrate(char *where, size_t *sizep) { struct clockinfo clkinfo; /* * Construct clockinfo structure. */ bzero(&clkinfo, sizeof clkinfo); clkinfo.tick = usechz; clkinfo.hz = hz; clkinfo.profhz = 0; clkinfo.stathz = hz; return (sysctl_rdstruct(where, sizep, NULL, &clkinfo, sizeof clkinfo)); } /* * Dump inode list (via sysctl). * Copyout address of inode followed by inode. */ /* ARGSUSED */ int sysctl_inode(char *where, size_t *sizep) { struct inode *ip; char *bp = where; struct inode *ipp; char *ewhere; int error, numi; for (numi = 0, ip = inode; ip < inode + NINODE; ip++) if (ip->i_count) numi++; #define IPTRSZ sizeof(struct inode *) #define INODESZ sizeof(struct inode) if (where == NULL) { *sizep = (numi + 5) * (IPTRSZ + INODESZ); return (0); } ewhere = where + *sizep; for (ip = inode; ip < inode + NINODE; ip++) { if (ip->i_count == 0) continue; if (bp + IPTRSZ + INODESZ > ewhere) { *sizep = bp - where; return (ENOMEM); } ipp = ip; if ((error = copyout((caddr_t)&ipp, bp, IPTRSZ)) || (error = copyout((caddr_t)ip, bp + IPTRSZ, INODESZ))) return (error); bp += IPTRSZ + INODESZ; } *sizep = bp - where; return (0); } /* * Try overestimating by 5 procs. */ #define KERN_PROCSLOP (5 * sizeof(struct kinfo_proc)) int sysctl_doproc(int *name, u_int namelen, char *where, size_t *sizep) { struct proc *p; struct kinfo_proc *dp = (struct kinfo_proc *)where; int needed = 0; int buflen = where != NULL ? *sizep : 0; int doingzomb; struct eproc eproc; int error = 0; dev_t ttyd; uid_t ruid; struct tty *ttyp; if (namelen != 2 && !(namelen == 1 && name[0] == KERN_PROC_ALL)) return (EINVAL); p = (struct proc *)allproc; doingzomb = 0; again: for (; p != NULL; p = p->p_nxt) { /* * Skip embryonic processes. */ if (p->p_stat == SIDL) continue; /* * TODO: sysctl_oproc - make more efficient (see notes below). * do by session. */ switch (name[0]) { case KERN_PROC_PID: /* Could do this with just a lookup. */ if (p->p_pid != (pid_t)name[1]) continue; break; case KERN_PROC_PGRP: /* Could do this by traversing pgrp. */ if (p->p_pgrp != (pid_t)name[1]) continue; break; case KERN_PROC_TTY: fill_from_u(p, &ruid, &ttyp, &ttyd); if (!ttyp || ttyd != (dev_t)name[1]) continue; break; case KERN_PROC_UID: if (p->p_uid != (uid_t)name[1]) continue; break; case KERN_PROC_RUID: fill_from_u(p, &ruid, &ttyp, &ttyd); if (ruid != (uid_t)name[1]) continue; break; case KERN_PROC_ALL: break; default: return (EINVAL); } if (buflen >= sizeof(struct kinfo_proc)) { fill_eproc(p, &eproc); if ((error = copyout((caddr_t)p, (caddr_t)&dp->kp_proc, sizeof(struct proc)))) return (error); if ((error = copyout((caddr_t)&eproc, (caddr_t)&dp->kp_eproc, sizeof(eproc)))) return (error); dp++; buflen -= sizeof(struct kinfo_proc); } needed += sizeof(struct kinfo_proc); } if (doingzomb == 0) { p = zombproc; doingzomb++; goto again; } if (where != NULL) { *sizep = (caddr_t)dp - where; if (needed > *sizep) return (ENOMEM); } else { needed += KERN_PROCSLOP; *sizep = needed; } return (0); } /* * Fill in an eproc structure for the specified process. Slightly * inefficient because we have to access the u area again for the * information not kept in the proc structure itself. Can't afford * to expand the proc struct so we take a slight speed hit here. */ void fill_eproc(struct proc *p, struct eproc *ep) { struct tty *ttyp; ep->e_paddr = p; fill_from_u(p, &ep->e_ruid, &ttyp, &ep->e_tdev); if (ttyp) ep->e_tpgid = ttyp->t_pgrp; else ep->e_tpgid = 0; } /* * Three pieces of information we need about a process are not kept in * the proc table: real uid, controlling terminal device, and controlling * terminal tty struct pointer. For these we must look in either the u * area or the swap area. If the process is still in memory this is * easy but if the process has been swapped out we have to read in the * u area. * * XXX - We rely on the fact that u_ttyp, u_ttyd, and u_ruid are all within * XXX - the first 1kb of the u area. If this ever changes the logic below * XXX - will break (and badly). At the present time (97/9/2) the u area * XXX - is 856 bytes long. */ void fill_from_u(struct proc *p, uid_t *rup, struct tty **ttp, dev_t *tdp) { struct buf *bp; dev_t ttyd; uid_t ruid; struct tty *ttyp; struct user *up; if (p->p_stat == SZOMB) { ruid = (uid_t)-2; ttyp = NULL; ttyd = NODEV; goto out; } if (p->p_flag & SLOAD) { ttyd = ((struct user *)p->p_addr)->u_ttyd; ttyp = ((struct user *)p->p_addr)->u_ttyp; ruid = ((struct user *)p->p_addr)->u_ruid; } else { bp = geteblk(); bp->b_dev = swapdev; bp->b_blkno = (daddr_t)p->p_addr; bp->b_bcount = DEV_BSIZE; /* XXX */ bp->b_flags = B_READ; (*bdevsw[major(swapdev)].d_strategy)(bp); biowait(bp); if (u.u_error) { ttyd = NODEV; ttyp = NULL; ruid = (uid_t)-2; } else { up = (struct user *)bp->b_addr; ruid = up->u_ruid; /* u_ruid = offset 164 */ ttyd = up->u_ttyd; /* u_ttyd = offset 654 */ ttyp = up->u_ttyp; /* u_ttyp = offset 652 */ } bp->b_flags |= B_AGE; brelse(bp); u.u_error = 0; /* XXX */ } out: if (rup) *rup = ruid; if (ttp) *ttp = ttyp; if (tdp) *tdp = ttyd; } ================================================ FILE: sys/kern/kern_time.c ================================================ /* * Copyright (c) 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include #include #include #include #include static void setthetime (tv) register struct timeval *tv; { int s; if (! suser()) return; #ifdef NOTNOW /* * If the system is secure, we do not allow the time to be set to an * earlier value. The time may be slowed (using adjtime) but not set back. * * NOTE: Can not do this until ntpd is updated to deal with the coarse (50, 60 * hz) clocks. Ntpd wants to adjust time system clock a few microseconds * at a time (which gets rounded to 0 in adjtime below). If that fails * ntpd uses settimeofday to step the time backwards which obviously * will fail if the next 'if' is enabled - all that does is fill up the * logfiles with "can't set time" messages and the time keeps drifting. */ if (securelevel > 0 && timercmp(tv, &time, <)) { u.u_error = EPERM; /* XXX */ return; } #endif /* WHAT DO WE DO ABOUT PENDING REAL-TIME TIMEOUTS??? */ boottime.tv_sec += tv->tv_sec - time.tv_sec; s = splhigh(); time = *tv; lbolt = time.tv_usec / usechz; splx(s); #ifdef notyet /* * if you have a time of day board, use it here */ resettodr(); #endif } /* * Time of day and interval timer support. * * These routines provide the kernel entry points to get and set * the time-of-day. */ void gettimeofday() { register struct a { struct timeval *tp; struct timezone *tzp; } *uap = (struct a *)u.u_arg; struct timeval atv; int s; register u_int ms; if (uap->tp) { /* * We don't resolve the milliseconds on every clock tick; it's * easier to do it here. Long casts are out of paranoia. */ s = splhigh(); atv = time; ms = lbolt; splx(s); atv.tv_usec = (long)ms * usechz; u.u_error = copyout ((caddr_t) &atv, (caddr_t) uap->tp, sizeof(atv)); if (u.u_error) return; } if (uap->tzp) u.u_error = copyout ((caddr_t) &tz, (caddr_t) uap->tzp, sizeof (tz)); } void settimeofday() { register struct a { struct timeval *tv; struct timezone *tzp; } *uap = (struct a *)u.u_arg; struct timeval atv; struct timezone atz; if (uap->tv) { u.u_error = copyin((caddr_t)uap->tv, (caddr_t)&atv, sizeof (struct timeval)); if (u.u_error) return; setthetime(&atv); if (u.u_error) return; } if (uap->tzp && suser()) { u.u_error = copyin((caddr_t)uap->tzp, (caddr_t)&atz, sizeof (atz)); if (u.u_error == 0) tz = atz; } } void adjtime() { register struct a { struct timeval *delta; struct timeval *olddelta; } *uap = (struct a *)u.u_arg; struct timeval atv; register int s; long adjust; if (!suser()) return; u.u_error = copyin((caddr_t)uap->delta, (caddr_t)&atv, sizeof (struct timeval)); if (u.u_error) return; adjust = (atv.tv_sec * hz) + (atv.tv_usec / usechz); /* if unstoreable values, just set the clock */ if (adjust > 0x7fff || adjust < 0x8000) { s = splclock(); time.tv_sec += atv.tv_sec; lbolt += atv.tv_usec / usechz; while (lbolt >= hz) { lbolt -= hz; ++time.tv_sec; } splx(s); if (!uap->olddelta) return; atv.tv_sec = atv.tv_usec = 0; } else { if (!uap->olddelta) { adjdelta = adjust; return; } atv.tv_sec = adjdelta / hz; atv.tv_usec = (adjdelta % hz) * usechz; adjdelta = adjust; } u.u_error = copyout ((caddr_t) &atv, (caddr_t) uap->olddelta, sizeof (struct timeval)); } void getitimer() { register struct a { u_int which; struct itimerval *itv; } *uap = (struct a *)u.u_arg; struct itimerval aitv; register int s; if (uap->which > ITIMER_PROF) { u.u_error = EINVAL; return; } aitv.it_interval.tv_usec = 0; aitv.it_value.tv_usec = 0; s = splclock(); if (uap->which == ITIMER_REAL) { register struct proc *p = u.u_procp; aitv.it_interval.tv_sec = p->p_realtimer.it_interval; aitv.it_value.tv_sec = p->p_realtimer.it_value; } else { register struct k_itimerval *t = &u.u_timer[uap->which - 1]; aitv.it_interval.tv_sec = t->it_interval / hz; aitv.it_value.tv_sec = t->it_value / hz; } splx(s); u.u_error = copyout ((caddr_t)&aitv, (caddr_t)uap->itv, sizeof (struct itimerval)); } void setitimer() { register struct a { u_int which; struct itimerval *itv, *oitv; } *uap = (struct a *)u.u_arg; struct itimerval aitv; register struct itimerval *aitvp; int s; if (uap->which > ITIMER_PROF) { u.u_error = EINVAL; return; } aitvp = uap->itv; if (uap->oitv) { uap->itv = uap->oitv; getitimer(); } if (aitvp == 0) return; u.u_error = copyin((caddr_t)aitvp, (caddr_t)&aitv, sizeof (struct itimerval)); if (u.u_error) return; s = splclock(); if (uap->which == ITIMER_REAL) { register struct proc *p = u.u_procp; p->p_realtimer.it_value = aitv.it_value.tv_sec; if (aitv.it_value.tv_usec) ++p->p_realtimer.it_value; p->p_realtimer.it_interval = aitv.it_interval.tv_sec; if (aitv.it_interval.tv_usec) ++p->p_realtimer.it_interval; } else { register struct k_itimerval *t = &u.u_timer[uap->which - 1]; t->it_value = aitv.it_value.tv_sec * hz; if (aitv.it_value.tv_usec) t->it_value += hz; t->it_interval = aitv.it_interval.tv_sec * hz; if (aitv.it_interval.tv_usec) t->it_interval += hz; } splx(s); } /* * Check that a proposed value to load into the .it_value or * .it_interval part of an interval timer is acceptable, and * fix it to have at least minimal value (i.e. if it is less * than the resolution of the clock, round it up.) */ int itimerfix(tv) struct timeval *tv; { if (tv->tv_sec < 0 || tv->tv_sec > 100000000L || tv->tv_usec < 0 || tv->tv_usec >= 1000000L) return (EINVAL); if (tv->tv_sec == 0 && tv->tv_usec != 0 && tv->tv_usec < (1000/hz)) tv->tv_usec = 1000/hz; return (0); } #ifdef NOT_CURRENTLY_IN_USE /* * Decrement an interval timer by a specified number * of microseconds, which must be less than a second, * i.e. < 1000000. If the timer expires, then reload * it. In this case, carry over (usec - old value) to * reducint the value reloaded into the timer so that * the timer does not drift. This routine assumes * that it is called in a context where the timers * on which it is operating cannot change in value. */ itimerdecr(itp, usec) register struct itimerval *itp; int usec; { if (itp->it_value.tv_usec < usec) { if (itp->it_value.tv_sec == 0) { /* expired, and already in next interval */ usec -= itp->it_value.tv_usec; goto expire; } itp->it_value.tv_usec += 1000000L; itp->it_value.tv_sec--; } itp->it_value.tv_usec -= usec; usec = 0; if (timerisset(&itp->it_value)) return (1); /* expired, exactly at end of interval */ expire: if (timerisset(&itp->it_interval)) { itp->it_value = itp->it_interval; itp->it_value.tv_usec -= usec; if (itp->it_value.tv_usec < 0) { itp->it_value.tv_usec += 1000000L; itp->it_value.tv_sec--; } } else itp->it_value.tv_usec = 0; /* sec is already 0 */ return (0); } #endif /* NOT_CURRENTLY_IN_USE */ static void tvfix(t1) struct timeval *t1; { if (t1->tv_usec < 0) { t1->tv_sec--; t1->tv_usec += 1000000L; } if (t1->tv_usec >= 1000000L) { t1->tv_sec++; t1->tv_usec -= 1000000L; } } /* * Add and subtract routines for timevals. * N.B.: subtract routine doesn't deal with * results which are before the beginning, * it just gets very confused in this case. * Caveat emptor. */ void timevaladd(t1, t2) struct timeval *t1, *t2; { t1->tv_sec += t2->tv_sec; t1->tv_usec += t2->tv_usec; tvfix(t1); } #ifdef NOT_CURRENTLY_IN_USE void timevalsub(t1, t2) struct timeval *t1, *t2; { t1->tv_sec -= t2->tv_sec; t1->tv_usec -= t2->tv_usec; tvfix(t1); } #endif ================================================ FILE: sys/kern/subr_log.c ================================================ /* * Copyright (c) 1982, 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ /* * logioctl() had the wrong number of arguments. Argh! Apparently this * driver was overlooked when 'dev' was added to ioctl entry points. * * logclose() returned garbage. this went unnoticed because most programs * don't check status when doing a close. * Add support for multiple log devices. Minor device 0 is the traditional * kernel logger (/dev/klog), minor device 1 is reserved for the future device * error logging daemon. */ #define NLOG 1 int nlog = 1; #include #include #include #include #include #include #include #include #include #include #include #include const struct devspec logdevs[] = { { 0, "klog" }, { 0, 0 } }; #define LOG_RDPRI (PZERO + 1) #define LOG_OPEN 0x01 #define LOG_ASYNC 0x04 #define LOG_RDWAIT 0x08 struct msgbuf msgbuf[NLOG]; static struct logsoftc { int sc_state; /* see above for possibilities */ struct proc *sc_selp; /* process waiting on select call */ int sc_pgid; /* process/group for async I/O */ int sc_overrun; /* full buffer count */ } logsoftc[NLOG]; /*ARGSUSED*/ int logopen(dev, mode, unused) dev_t dev; int mode; { register int unit = minor(dev); if (unit >= NLOG) return(ENODEV); if (logisopen(unit)) return(EBUSY); if (msgbuf[unit].msg_bufc == 0) /* no buffer allocated */ return(ENOMEM); logsoftc[unit].sc_state |= LOG_OPEN; logsoftc[unit].sc_pgid = u.u_procp->p_pid; /* signal process only */ logsoftc[unit].sc_overrun = 0; return(0); } /*ARGSUSED*/ int logclose(dev, flag, unused) dev_t dev; int flag; { register int unit = minor(dev); logsoftc[unit].sc_state = 0; return(0); } /* * This is a helper function to keep knowledge of this driver's data * structures away from the rest of the kernel. */ int logisopen(unit) int unit; { if (logsoftc[unit].sc_state & LOG_OPEN) return(1); return(0); } /*ARGSUSED*/ int logread(dev, uio, flag) dev_t dev; struct uio *uio; int flag; { register int l; register struct logsoftc *lp; register struct msgbuf *mp; int s, error = 0; char buf [128]; l = minor(dev); lp = &logsoftc[l]; mp = &msgbuf[l]; s = splhigh(); while (mp->msg_bufr == mp->msg_bufx) { if (flag & IO_NDELAY) { splx(s); return(EWOULDBLOCK); } lp->sc_state |= LOG_RDWAIT; sleep((caddr_t)mp, LOG_RDPRI); } lp->sc_state &= ~LOG_RDWAIT; while (uio->uio_resid) { l = mp->msg_bufx - mp->msg_bufr; /* * If the reader and writer are equal then we have caught up and there * is nothing more to transfer. */ if (l == 0) break; /* * If the write pointer is behind the reader then only consider as * available for now the bytes from the read pointer thru the end of * the buffer. */ if (l < 0) { l = MSG_BSIZE - mp->msg_bufr; /* * If the reader is exactly at the end of the buffer it is * time to wrap it around to the beginning and recalculate the * amount of data to transfer. */ if (l == 0) { mp->msg_bufr = 0; continue; } } l = MIN (l, uio->uio_resid); l = MIN (l, sizeof buf); bcopy (&mp->msg_bufc[mp->msg_bufr], buf, l); error = uiomove (buf, l, uio); if (error) break; mp->msg_bufr += l; } splx(s); return(error); } /*ARGSUSED*/ int logselect(dev, rw) dev_t dev; int rw; { register int s = splhigh(); int unit = minor(dev); switch (rw) { case FREAD: if (msgbuf[unit].msg_bufr != msgbuf[unit].msg_bufx) { splx(s); return(1); } logsoftc[unit].sc_selp = u.u_procp; break; } splx(s); return(0); } void logwakeup(unit) int unit; { register struct proc *p; register struct logsoftc *lp; register struct msgbuf *mp; if (! logisopen(unit)) return; lp = &logsoftc[unit]; mp = &msgbuf[unit]; if (lp->sc_selp) { selwakeup(lp->sc_selp, (long) 0); lp->sc_selp = 0; } if (lp->sc_state & LOG_ASYNC && (mp->msg_bufx != mp->msg_bufr)) { if (lp->sc_pgid < 0) gsignal(-lp->sc_pgid, SIGIO); else if ((p = pfind(lp->sc_pgid))) psignal(p, SIGIO); } if (lp->sc_state & LOG_RDWAIT) { wakeup((caddr_t)mp); lp->sc_state &= ~LOG_RDWAIT; } } /*ARGSUSED*/ int logioctl(dev, com, data, flag) dev_t dev; u_int com; caddr_t data; int flag; { long l; register int s; int unit; register struct logsoftc *lp; register struct msgbuf *mp; unit = minor(dev); lp = &logsoftc[unit]; mp = &msgbuf[unit]; switch (com) { case FIONREAD: s = splhigh(); l = mp->msg_bufx - mp->msg_bufr; splx(s); if (l < 0) l += MSG_BSIZE; *(off_t *)data = l; break; case FIONBIO: break; case FIOASYNC: if (*(int *)data) lp->sc_state |= LOG_ASYNC; else lp->sc_state &= ~LOG_ASYNC; break; case TIOCSPGRP: lp->sc_pgid = *(int *)data; break; case TIOCGPGRP: *(int *)data = lp->sc_pgid; break; default: return(-1); } return(0); } /* * This is inefficient for single character writes. Alas, changing this * to be buffered would affect the networking code's use of printf. */ int logwrt (buf, len, log) char *buf; int len; int log; { register struct msgbuf *mp = &msgbuf[log]; struct logsoftc *lp = &logsoftc[log]; register int infront; int s, n, writer, err = 0; if (mp->msg_magic != MSG_MAGIC || (len > MSG_BSIZE)) return(-1); /* * Hate to do this but since this can be called from anywhere in the kernel * we have to hold off any interrupt service routines so they don't change * things. This looks like a lot of code but it isn't really. */ s = splhigh(); while (len) { again: infront = MSG_BSIZE - mp->msg_bufx; if (infront <= 0) { mp->msg_bufx = 0; infront = MSG_BSIZE - mp->msg_bufr; } n = mp->msg_bufr - mp->msg_bufx; if (n < 0) /* bufr < bufx */ writer = (MSG_BSIZE - mp->msg_bufx) + mp->msg_bufr; else if (n == 0) writer = MSG_BSIZE; else { writer = n; infront = n; } if (len > writer) { /* * won't fit. the total number of bytes to be written is * greater than the number available. the buffer is full. * throw away the old data and keep the current data by resetting * the 'writer' pointer to the current 'reader' position. Bump the * overrun counter in case anyone wants to look at it for debugging. */ lp->sc_overrun++; mp->msg_bufx = mp->msg_bufr; goto again; } if (infront > len) infront = len; bcopy(buf, &mp->msg_bufc[mp->msg_bufx], infront); mp->msg_bufx += infront; len -= infront; buf += infront; } splx(s); return(err); } /* * Initialize the log driver. Called from the system startup code (machdep2.c). * All buffers are the same (MSG_BSIZE) size. */ int loginit() { register struct msgbuf *mp; for (mp = &msgbuf[0]; mp < &msgbuf[NLOG]; mp++) { mp->msg_magic = MSG_MAGIC; mp->msg_bufx = mp->msg_bufr = 0; } return(0); } ================================================ FILE: sys/kern/subr_prf.c ================================================ /* * Copyright (c) 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include #include #include #include #include #include #include #include #include #include #define TOCONS 0x1 #define TOTTY 0x2 #define TOLOG 0x4 /* * In case console is off, * panicstr contains argument to last * call to panic. */ char *panicstr; /* * Print a character on console or users terminal. * If destination is console then the last MSGBUFS characters * are saved in msgbuf for inspection later. */ static void putchar (c, flags, tp) int c, flags; register struct tty *tp; { if (flags & TOTTY) { register int s = spltty(); if (tp && (tp->t_state & (TS_CARR_ON | TS_ISOPEN)) == (TS_CARR_ON | TS_ISOPEN)) { if (c == '\n') (void) ttyoutput('\r', tp); (void) ttyoutput(c, tp); ttstart(tp); } splx(s); } #ifdef LOG_ENABLED if ((flags & TOLOG) && c != '\0' && c != '\r' && c != 0177) { char sym = c; logwrt (&sym, 1, logMSG); } #endif if ((flags & TOCONS) && c != '\0') cnputc(c); } static unsigned mkhex (unsigned ch) { ch &= 15; if (ch > 9) return ch + 'a' - 10; return ch + '0'; } /* * Put a NUL-terminated ASCII number (base <= 16) in a buffer in reverse * order; return an optional length and a pointer to the last character * written in the buffer (i.e., the first character of the string). * The buffer pointed to by `nbuf' must have length >= MAXNBUF. */ static char * ksprintn (char *nbuf, unsigned long ul, int base, int width, int *lenp) { char *p; p = nbuf; *p = 0; for (;;) { *++p = mkhex (ul % base); ul /= base; if (--width > 0) continue; if (! ul) break; } if (lenp) *lenp = p - nbuf; return (p); } void puts(char *s, int flags, struct tty *ttyp) { while(*s) putchar(*(s++), flags, ttyp); } /* * Scaled down version of printf(3). * Two additional formats: %b anf %D. * Based on FreeBSD sources. * Heavily rewritten by Serge Vakulenko. * * The format %b is supported to decode error registers. * Its usage is: * * printf("reg=%b\n", regval, "*"); * * where is the output base expressed as a control character, e.g. * \10 gives octal; \20 gives hex. Each arg is a sequence of characters, * the first of which gives the bit number to be inspected (origin 1), and * the next characters (up to a control character, i.e. a character <= 32), * give the name of the register. Thus: * * kvprintf("reg=%b\n", 3, "\10\2BITTWO\1BITONE\n"); * * would produce output: * * reg=3 * * The format %D -- Hexdump, takes a pointer. Sharp flag - use `:' as * a separator, instead of a space. For example: * * ("%6D", ptr) -> XX XX XX XX XX XX * ("%#*D", len, ptr) -> XX:XX:XX:XX ... */ #define PUTC(C) putchar(C,flags,ttyp) #define HION "\e[1m" #define HIOFF "\e[0m" static void prf (fmt, ap, flags, ttyp) register char *fmt; register u_int *ap; int flags; struct tty *ttyp; { #define va_arg(ap,type) *(type*) (void*) (ap++) char *q, nbuf [sizeof(long) * 8 + 1]; const char *s; int c, padding, base, lflag, ladjust, sharpflag, neg, dot, size; int n, width, dwidth, uppercase, extrazeros, sign; unsigned long ul; #ifdef KERNEL_HIGHLIGHT puts(HION, flags, ttyp); #endif if (! fmt) fmt = "(null)\n"; for (;;) { while ((c = *fmt++) != '%') { if (! c) { #ifdef KERNEL_HIGHLIGHT puts(HIOFF, flags, ttyp); #endif return; } PUTC (c); } padding = ' '; width = 0; extrazeros = 0; lflag = 0; ladjust = 0; sharpflag = 0; neg = 0; sign = 0; dot = 0; uppercase = 0; dwidth = -1; reswitch: c = *fmt++; switch (c) { case '.': dot = 1; padding = ' '; dwidth = 0; goto reswitch; case '#': sharpflag = 1; goto reswitch; case '+': sign = -1; goto reswitch; case '-': ladjust = 1; goto reswitch; case '%': PUTC (c); break; case '*': if (! dot) { width = va_arg (ap, int); if (width < 0) { ladjust = !ladjust; width = -width; } } else { dwidth = va_arg (ap, int); } goto reswitch; case '0': if (! dot) { padding = '0'; goto reswitch; } case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': for (n=0; ; ++fmt) { n = n * 10 + c - '0'; c = *fmt; if (c < '0' || c > '9') break; } if (dot) dwidth = n; else width = n; goto reswitch; case 'b': ul = va_arg (ap, int); s = va_arg (ap, const char*); q = ksprintn (nbuf, ul, *s++, -1, 0); while (*q) PUTC (*q--); if (! ul) break; size = 0; while (*s) { n = *s++; if ((char) (ul >> (n-1)) & 1) { PUTC (size ? ',' : '<'); for (; (n = *s) > ' '; ++s) PUTC (n); size = 1; } else { while (*s > ' ') ++s; } } if (size) PUTC ('>'); break; case 'c': if (! ladjust && width > 0) { while (width--) PUTC (' '); } PUTC (va_arg (ap, int)); if (ladjust && width > 0) { while (width--) PUTC (' '); } break; case 'D': s = va_arg (ap, const char*); if (! width) width = 16; if (sharpflag) padding = ':'; while (width--) { c = *s++; PUTC (mkhex (c >> 4)); PUTC (mkhex (c)); if (width) PUTC (padding); } break; case 'd': ul = lflag ? va_arg (ap, long) : va_arg (ap, int); if (! sign) sign = 1; base = 10; goto number; case 'l': lflag = 1; goto reswitch; case 'o': ul = lflag ? va_arg (ap, unsigned long) : va_arg (ap, unsigned int); base = 8; goto nosign; case 'p': ul = (size_t) va_arg (ap, void*); if (! ul) { s = "(nil)"; goto const_string; } base = 16; sharpflag = (width == 0); goto nosign; case 'n': ul = lflag ? va_arg (ap, unsigned long) : sign ? (unsigned long) va_arg (ap, int) : va_arg (ap, unsigned int); base = 10; goto number; case 's': s = va_arg (ap, char*); if (! s) s = (const char*) "(null)"; const_string: if (! dot) n = strlen (s); else for (n=0; n 0) { while (width--) PUTC (' '); } while (n--) PUTC (*s++); if (ladjust && width > 0) { while (width--) PUTC (' '); } break; case 'u': ul = lflag ? va_arg (ap, unsigned long) : va_arg (ap, unsigned int); base = 10; goto nosign; case 'x': case 'X': ul = lflag ? va_arg (ap, unsigned long) : va_arg (ap, unsigned int); base = 16; uppercase = (c == 'X'); goto nosign; case 'z': case 'Z': ul = lflag ? va_arg (ap, unsigned long) : sign ? (unsigned long) va_arg (ap, int) : va_arg (ap, unsigned int); base = 16; uppercase = (c == 'Z'); goto number; nosign: sign = 0; number: if (sign && ((long) ul != 0L)) { if ((long) ul < 0L) { neg = '-'; ul = -(long) ul; } else if (sign < 0) neg = '+'; } if (dwidth >= (int) sizeof(nbuf)) { extrazeros = dwidth - sizeof(nbuf) + 1; dwidth = sizeof(nbuf) - 1; } s = ksprintn (nbuf, ul, base, dwidth, &size); if (sharpflag && ul != 0) { if (base == 8) size++; else if (base == 16) size += 2; } if (neg) size++; if (! ladjust && width && padding == ' ' && (width -= size) > 0) { do { PUTC (' '); } while (--width > 0); } if (neg) PUTC (neg); if (sharpflag && ul != 0) { if (base == 8) { PUTC ('0'); } else if (base == 16) { PUTC ('0'); PUTC (uppercase ? 'X' : 'x'); } } if (extrazeros) { do { PUTC ('0'); } while (--extrazeros > 0); } if (! ladjust && width && (width -= size) > 0) { do { PUTC (padding); } while (--width > 0); } for (; *s; --s) { if (uppercase && *s>='a' && *s<='z') { PUTC (*s + 'A' - 'a'); } else { PUTC (*s); } } if (ladjust && width && (width -= size) > 0) { do { PUTC (' '); } while (--width > 0); } break; default: PUTC ('%'); if (lflag) PUTC ('l'); PUTC (c); break; } } #ifdef KERNEL_HIGHLIGHT puts(HIOFF,flags,ttyp); #endif } static void logpri (level) int level; { putchar ('<', TOLOG, (struct tty*) 0); prf ("%u", &level, TOLOG, (struct tty*) 0); putchar ('>', TOLOG, (struct tty*) 0); } /* * Scaled down version of C Library printf. * Used to print diagnostic information directly on console tty. * Since it is not interrupt driven, all system activities are * suspended. Printf should not be used for chit-chat. * * One additional format: %b is supported to decode error registers. * Usage is: * printf("reg=%b\n", regval, "*"); * Where is the output base expressed as a control character, * e.g. \10 gives octal; \20 gives hex. Each arg is a sequence of * characters, the first of which gives the bit number to be inspected * (origin 1), and the next characters (up to a control character, i.e. * a character <= 32), give the name of the register. Thus * printf("reg=%b\n", 3, "\10\2BITTWO\1BITONE\n"); * would produce output: * reg=3 */ void printf(char *fmt, ...) { prf(fmt, &fmt + 1, TOCONS | TOLOG, (struct tty *)0); } /* * Microchip MPLABX C32 compiler generates calls to _printf_s() * and other strange names. */ #ifdef __MPLABX__ void _printf_s(char *fmt, ...) __attribute__((alias ("printf"))); void _printf_cdnopuxX(char *fmt, ...) __attribute__((alias ("printf"))); void _printf_cdnopsuxX(char *fmt, ...) __attribute__((alias ("printf"))); #endif /* * Uprintf prints to the current user's terminal, * guarantees not to sleep (so could be called by interrupt routines; * but prints on the tty of the current process) * and does no watermark checking - (so no verbose messages). * NOTE: with current kernel mapping scheme, the user structure is * not guaranteed to be accessible at interrupt level (see seg.h); * a savemap/restormap would be needed here or in putchar if uprintf * was to be used at interrupt time. */ void uprintf (char *fmt, ...) { register struct tty *tp; tp = u.u_ttyp; if (tp == NULL) return; if (ttycheckoutq (tp, 1)) prf (fmt, &fmt+1, TOTTY, tp); } /* * tprintf prints on the specified terminal (console if none) * and logs the message. It is designed for error messages from * single-open devices, and may be called from interrupt level * (does not sleep). */ void tprintf (register struct tty *tp, char *fmt, ...) { int flags = TOTTY | TOLOG; logpri (LOG_INFO); if (tp == (struct tty*) NULL) tp = &cnttys[0]; if (ttycheckoutq (tp, 0) == 0) flags = TOLOG; prf (fmt, &fmt + 1, flags, tp); #ifdef LOG_ENABLED logwakeup (logMSG); #endif } /* * Log writes to the log buffer, * and guarantees not to sleep (so can be called by interrupt routines). * If there is no process reading the log yet, it writes to the console also. */ /*VARARGS2*/ void log (int level, char *fmt, ...) { register int s = splhigh(); logpri(level); prf(fmt, &fmt + 1, TOLOG, (struct tty *)0); splx(s); #ifdef LOG_ENABLED if (! logisopen(logMSG)) #endif prf(fmt, &fmt + 1, TOCONS, (struct tty *)0); #ifdef LOG_ENABLED logwakeup(logMSG); #endif } /* * Panic is called on unresolvable fatal errors. * It prints "panic: mesg", and then reboots. * If we are called twice, then we avoid trying to * sync the disks as this often leads to recursive panics. */ void panic(s) char *s; { int bootopt = RB_HALT | RB_DUMP; if (panicstr) { bootopt |= RB_NOSYNC; } else { panicstr = s; } printf ("panic: %s\n", s); boot (rootdev, bootopt); } ================================================ FILE: sys/kern/subr_rmap.c ================================================ /* * Copyright (c) 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include #include #include #include /* * Resource map handling routines. * * A resource map is an array of structures each of which describes a * segment of the address space of an available resource. The segments * are described by their base address and length, and sorted in address * order. Each resource map has a fixed maximum number of segments * allowed. Resources are allocated by taking part or all of one of the * segments of the map. * * Returning of resources will require another segment if the returned * resources are not adjacent in the address space to an existing segment. * If the return of a segment would require a slot which is not available, * then one of the resource map segments is discarded after a warning is * printed. * * Returning of resources may also cause the map to collapse by coalescing * two existing segments and the returned space into a single segment. In * this case the resource map is made smaller by copying together to fill * the resultant gap. * * N.B.: the current implementation uses a dense array and does not admit * the value ``0'' as a legal address or size, since that is used as a * delimiter. */ /* * Allocate 'size' units from the given map. Return the base of the * allocated space. In a map, the addresses are increasing and the * list is terminated by a 0 size. * * Algorithm is first-fit. */ size_t malloc (mp, size) struct map *mp; register size_t size; { register struct mapent *bp, *ep; size_t addr; if (! size) panic ("malloc: size = 0"); /* * Search for a piece of the resource map which has enough * free space to accomodate the request. */ for (bp = mp->m_map; bp->m_size; ++bp) if (bp->m_size >= size) { /* * Allocate from the map. If we allocated the entire * piece, move the rest of the map to the left. */ addr = bp->m_addr; bp->m_size -= size; if (bp->m_size) bp->m_addr += size; else for (ep = bp;; ++ep) { *ep = *++bp; if (!bp->m_size) break; } return(addr); } /* no entries big enough */ return 0; } /* * Free the previously allocated size units at addr into the specified * map. Sort addr into map and combine on one or both ends if possible. */ void mfree (mp, size, addr) struct map *mp; size_t size; register size_t addr; { register struct mapent *bp, *ep; struct mapent *start; if (! size) return; /* the address must not be 0, or the protocol has broken down. */ if (! addr) panic ("mfree: addr = 0"); /* * locate the piece of the map which starts after the * returned space (or the end of the map). */ bp = mp->m_map; /* printf ("mfree (size=%u, addr=%u) m_map = %08x\n", size, addr, bp); */ while (bp->m_size && bp->m_addr <= addr) { /*printf ("skip m_map[%d]: m_addr %u <= addr %u\n", bp - mp->m_map, bp->m_addr, addr);*/ ++bp; } /* if there is a piece on the left abutting us, combine with it. */ ep = bp - 1; if (bp != mp->m_map && ep->m_addr + ep->m_size >= addr) { #ifdef DIAGNOSTIC /* any overlap is an internal error */ if (ep->m_addr + ep->m_size > addr) panic("mfree overlap #1"); #endif /* add into piece on the left by increasing its size. */ ep->m_size += size; /* * if the combined piece abuts the piece on the right now, * compress it in also, by shifting the remaining pieces * of the map over. */ if (bp->m_size && addr + size >= bp->m_addr) { #ifdef DIAGNOSTIC if (addr + size > bp->m_addr) panic("mfree overlap #2"); #endif ep->m_size += bp->m_size; do { *++ep = *++bp; } while (bp->m_size); } return; } /* if doesn't abut on the left, check for abutting on the right. */ if (bp->m_size && addr + size >= bp->m_addr) { #ifdef DIAGNOSTIC if (addr + size > bp->m_addr) panic("mfree overlap #3"); #endif bp->m_addr = addr; bp->m_size += size; return; } /* doesn't abut. Make a new entry and check for map overflow. */ for (start = bp; bp->m_size; ++bp); if (++bp > mp->m_limit) /* * too many segments; if this happens, the correct fix * is to make the map bigger; you can't afford to lose * chunks of the map. If you need to implement recovery, * use the above "for" loop to find the smallest entry * and toss it. */ printf("%s: overflow, lost %u clicks at 0%o\n", mp->m_name, size, addr); else { for (ep = bp - 1; ep >= start; *bp-- = *ep--); start->m_addr = addr; start->m_size = size; } } /* * Allocate resources for the three segments of a process (data, stack * and u.), attempting to minimize the cost of failure part-way through. * Since the segments are located successively, it is best for the sizes * to be in decreasing order; generally, data, stack, then u. will be * best. Returns NULL on failure, address of u. on success. */ size_t malloc3 (mp, d_size, s_size, u_size, a) struct map *mp; size_t d_size, s_size, u_size; size_t a[3]; { register struct mapent *bp, *remap; register int next; struct mapent *madd[3]; size_t sizes[3]; int found; sizes[0] = d_size; sizes[1] = s_size; sizes[2] = u_size; /* * note, this has to work for d_size and s_size of zero, * since init() comes in that way. */ madd[0] = madd[1] = madd[2] = remap = NULL; for (found = 0, bp = mp->m_map; bp->m_size; ++bp) for (next = 0; next < 3; ++next) if (!madd[next] && sizes[next] <= bp->m_size) { madd[next] = bp; bp->m_size -= sizes[next]; if (!bp->m_size && !remap) remap = bp; if (++found == 3) goto resolve; } /* couldn't get it all; restore the old sizes, try again */ for (next = 0; next < 3; ++next) if (madd[next]) madd[next]->m_size += sizes[next]; return 0; resolve: /* got it all, update the addresses. */ for (next = 0; next < 3; ++next) { bp = madd[next]; a[next] = bp->m_addr; bp->m_addr += sizes[next]; } /* remove any entries of size 0; addr of 0 terminates */ if (remap) { for (bp = remap + 1;; ++bp) { if (bp->m_size || !bp->m_addr) { *remap++ = *bp; if (!bp->m_addr) break; } } } return(a[2]); } ================================================ FILE: sys/kern/sys_generic.c ================================================ /* * Copyright (c) 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include #include #include #include #include #include #include #include #include #include #include int selwait; static void rwuio (uio) register struct uio *uio; { struct a { int fdes; }; register struct file *fp; register struct iovec *iov; u_int i, count; off_t total; GETF(fp, ((struct a *)u.u_arg)->fdes); if ((fp->f_flag & (uio->uio_rw == UIO_READ ? FREAD : FWRITE)) == 0) { u.u_error = EBADF; return; } total = 0; uio->uio_resid = 0; for (iov = uio->uio_iov, i = 0; i < uio->uio_iovcnt; i++, iov++) total += iov->iov_len; uio->uio_resid = total; if (uio->uio_resid != total) { /* check wraparound */ u.u_error = EINVAL; return; } count = uio->uio_resid; if (setjmp (&u.u_qsave)) { /* * The ONLY way we can get here is via the longjump in sleep. Thus signals * have been checked and u_error set accordingly. If no bytes have been * transferred then all that needs to be done now is 'return'; the system * call will either be restarted or reported as interrupted. If bytes have * been transferred then we need to calculate the number of bytes transferred. */ if (uio->uio_resid == count) return; u.u_error = 0; } else u.u_error = (*Fops[fp->f_type]->fo_rw) (fp, uio); u.u_rval = count - uio->uio_resid; } /* * Read system call. */ void read() { register struct a { int fdes; char *cbuf; unsigned count; } *uap = (struct a *)u.u_arg; struct uio auio; struct iovec aiov; aiov.iov_base = (caddr_t)uap->cbuf; aiov.iov_len = uap->count; auio.uio_iov = &aiov; auio.uio_iovcnt = 1; auio.uio_rw = UIO_READ; rwuio (&auio); } void readv() { register struct a { int fdes; struct iovec *iovp; unsigned iovcnt; } *uap = (struct a *)u.u_arg; struct uio auio; struct iovec aiov[16]; /* XXX */ if (uap->iovcnt > sizeof(aiov)/sizeof(aiov[0])) { u.u_error = EINVAL; return; } auio.uio_iov = aiov; auio.uio_iovcnt = uap->iovcnt; auio.uio_rw = UIO_READ; u.u_error = copyin ((caddr_t)uap->iovp, (caddr_t)aiov, uap->iovcnt * sizeof (struct iovec)); if (u.u_error) return; rwuio (&auio); } /* * Write system call */ void write() { register struct a { int fdes; char *cbuf; unsigned count; } *uap = (struct a *)u.u_arg; struct uio auio; struct iovec aiov; auio.uio_iov = &aiov; auio.uio_iovcnt = 1; auio.uio_rw = UIO_WRITE; aiov.iov_base = uap->cbuf; aiov.iov_len = uap->count; rwuio (&auio); } void writev() { register struct a { int fdes; struct iovec *iovp; unsigned iovcnt; } *uap = (struct a *)u.u_arg; struct uio auio; struct iovec aiov[16]; /* XXX */ if (uap->iovcnt > sizeof(aiov)/sizeof(aiov[0])) { u.u_error = EINVAL; return; } auio.uio_iov = aiov; auio.uio_iovcnt = uap->iovcnt; auio.uio_rw = UIO_WRITE; u.u_error = copyin ((caddr_t)uap->iovp, (caddr_t)aiov, uap->iovcnt * sizeof (struct iovec)); if (u.u_error) return; rwuio (&auio); } /* * Ioctl system call */ void ioctl() { register struct file *fp; register struct a { int fdes; long cmd; caddr_t cmarg; } *uap; u_int com; uap = (struct a *)u.u_arg; fp = getf(uap->fdes); if (! fp) return; if (! (fp->f_flag & (FREAD | FWRITE))) { u.u_error = EBADF; return; } com = (u_int) uap->cmd; if (com & (IOC_IN | IOC_OUT)) { /* Check user address. */ u_int nbytes = (com & ~(IOC_INOUT | IOC_VOID)) >> 16; if (baduaddr (uap->cmarg) || baduaddr (uap->cmarg + nbytes - 1)) { u.u_error = EFAULT; return; } } switch (com) { case FIOCLEX: u.u_pofile[uap->fdes] |= UF_EXCLOSE; return; case FIONCLEX: u.u_pofile[uap->fdes] &= ~UF_EXCLOSE; return; case FIONBIO: u.u_error = fset (fp, FNONBLOCK, *(int*) uap->cmarg); return; case FIOASYNC: u.u_error = fset (fp, FASYNC, *(int*) uap->cmarg); return; case FIOSETOWN: u.u_error = fsetown (fp, *(int*) uap->cmarg); return; case FIOGETOWN: u.u_error = fgetown (fp, (int*) uap->cmarg); return; } u.u_error = (*Fops[fp->f_type]->fo_ioctl) (fp, com, uap->cmarg); } int nselcoll; struct pselect_args { int nd; fd_set *in; fd_set *ou; fd_set *ex; struct timespec *ts; sigset_t *maskp; }; int selscan(ibits, obits, nfd, retval) fd_set *ibits, *obits; int nfd, *retval; { register int i, j, flag = 0; fd_mask bits; struct file *fp; int which, n = 0; for (which = 0; which < 3; which++) { switch (which) { case 0: flag = FREAD; break; case 1: flag = FWRITE; break; case 2: flag = 0; break; } for (i = 0; i < nfd; i += NFDBITS) { bits = ibits[which].fds_bits[i/NFDBITS]; while ((j = ffs(bits)) && i + --j < nfd) { bits &= ~(1L << j); fp = u.u_ofile[i + j]; if (fp == NULL) return(EBADF); if ((*Fops[fp->f_type]->fo_select) (fp, flag)) { FD_SET(i + j, &obits[which]); n++; } } } } *retval = n; return(0); } /* * Select helper function common to both select() and pselect() */ static int select1(uap, is_pselect) register struct pselect_args *uap; int is_pselect; { fd_set ibits[3], obits[3]; struct timeval atv; sigset_t sigmsk; unsigned int timo = 0; register int error, ni; int ncoll, s; bzero((caddr_t)ibits, sizeof(ibits)); bzero((caddr_t)obits, sizeof(obits)); if (uap->nd > NOFILE) uap->nd = NOFILE; /* forgiving, if slightly wrong */ ni = howmany(uap->nd, NFDBITS); #define getbits(name, x) \ if (uap->name) { \ error = copyin((caddr_t)uap->name, (caddr_t)&ibits[x], \ (unsigned)(ni * sizeof(fd_mask))); \ if (error) \ goto done; \ } getbits(in, 0); getbits(ou, 1); getbits(ex, 2); #undef getbits if (uap->maskp) { error = copyin ((caddr_t) uap->maskp, (caddr_t) &sigmsk, sizeof(sigmsk)); sigmsk &= ~sigcantmask; if (error) goto done; } if (uap->ts) { error = copyin ((caddr_t) uap->ts, (caddr_t) &atv, sizeof (atv)); if (error) goto done; /* * nanoseconds ('struct timespec') on a PDP-11 are stupid since a 50 or 60 hz * clock is all we have. Keeping the names and logic made porting easier * though. */ if (is_pselect) { struct timespec *ts = (struct timespec *)&atv; if (ts->tv_sec == 0 && ts->tv_nsec < 1000) atv.tv_usec = 1; else atv.tv_usec = ts->tv_nsec / 1000; } if (itimerfix(&atv)) { error = EINVAL; goto done; } s = splhigh(); time.tv_usec = lbolt * usechz; timevaladd(&atv, &time); splx(s); } retry: ncoll = nselcoll; u.u_procp->p_flag |= P_SELECT; error = selscan(ibits, obits, uap->nd, &u.u_rval); if (error || u.u_rval) goto done; s = splhigh(); if (uap->ts) { /* this should be timercmp(&time, &atv, >=) */ if ((time.tv_sec > atv.tv_sec || (time.tv_sec == atv.tv_sec && lbolt * usechz >= atv.tv_usec))) { splx(s); goto done; } timo = hzto(&atv); if (timo == 0) timo = 1; } if ((u.u_procp->p_flag & P_SELECT) == 0 || nselcoll != ncoll) { u.u_procp->p_flag &= ~P_SELECT; splx(s); goto retry; } u.u_procp->p_flag &= ~P_SELECT; /* * If doing a pselect() need to set a temporary mask while in tsleep. * Returning from pselect after catching a signal the old mask has to be * restored. Save it here and set the appropriate flag. */ if (uap->maskp) { u.u_oldmask = u.u_procp->p_sigmask; u.u_psflags |= SAS_OLDMASK; u.u_procp->p_sigmask = sigmsk; } error = tsleep ((caddr_t) &selwait, PSOCK | PCATCH, timo); if (uap->maskp) u.u_procp->p_sigmask = u.u_oldmask; splx(s); if (error == 0) goto retry; done: u.u_procp->p_flag &= ~P_SELECT; /* select is not restarted after signals... */ if (error == ERESTART) error = EINTR; if (error == EWOULDBLOCK) error = 0; #define putbits(name, x) \ if (uap->name && \ (error2 = copyout ((caddr_t) &obits[x], (caddr_t) uap->name, ni*sizeof(fd_mask)))) \ error = error2; if (error == 0) { int error2; putbits(in, 0); putbits(ou, 1); putbits(ex, 2); #undef putbits } return(error); } /* * Select system call. */ void select() { struct uap { int nd; fd_set *in, *ou, *ex; struct timeval *tv; } *uap = (struct uap *)u.u_arg; register struct pselect_args *pselargs = (struct pselect_args *)uap; /* * Fake the 6th parameter of pselect. See the comment below about the * number of parameters! */ pselargs->maskp = 0; u.u_error = select1 (pselargs, 0); } /* * pselect (posix select) * * N.B. There is only room for 6 arguments - see user.h - so pselect() is * at the maximum! See user.h */ void pselect() { register struct pselect_args *uap = (struct pselect_args *)u.u_arg; u.u_error = select1(uap, 1); } /*ARGSUSED*/ int seltrue(dev, flag) dev_t dev; int flag; { return (1); } void selwakeup (p, coll) register struct proc *p; long coll; { if (coll) { nselcoll++; wakeup ((caddr_t)&selwait); } if (p) { register int s = splhigh(); if (p->p_wchan == (caddr_t)&selwait) { if (p->p_stat == SSLEEP) setrun(p); else unsleep(p); } else if (p->p_flag & P_SELECT) p->p_flag &= ~P_SELECT; splx(s); } } int sorw(fp, uio) register struct file *fp; register struct uio *uio; { #ifdef INET if (uio->uio_rw == UIO_READ) return(SORECEIVE((struct socket *)fp->f_socket, 0, uio, 0, 0)); return(SOSEND((struct socket *)fp->f_socket, 0, uio, 0, 0)); #else return (EOPNOTSUPP); #endif } int soctl(fp, com, data) struct file *fp; u_int com; char *data; { #ifdef INET return (SOO_IOCTL(fp, com, data)); #else return (EOPNOTSUPP); #endif } int sosel(fp, flag) struct file *fp; int flag; { #ifdef INET return (SOO_SELECT(fp, flag)); #else return (EOPNOTSUPP); #endif } int socls(fp) register struct file *fp; { register int error = 0; #ifdef INET if (fp->f_data) error = SOCLOSE((struct socket *)fp->f_data); fp->f_data = 0; #else error = EOPNOTSUPP; #endif return(error); } /* * this is consolidated here rather than being scattered all over the * place. the socketops table has to be in kernel space, but since * networking might not be defined an appropriate error has to be set */ const struct fileops socketops = { sorw, soctl, sosel, socls }; const struct fileops *const Fops[] = { NULL, &inodeops, &socketops, &pipeops }; /* * Routine placed in illegal entries in the bdevsw and cdevsw tables. */ void nostrategy (bp) struct buf *bp; { /* Empty. */ } #ifndef INET /* * socket(2) and socketpair(2) if networking not available. */ void nonet() { u.u_error = EPROTONOSUPPORT; } #endif ================================================ FILE: sys/kern/sys_inode.c ================================================ /* * Copyright (c) 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include daddr_t rablock; /* block to be read ahead */ int ino_rw(fp, uio) struct file *fp; register struct uio *uio; { register struct inode *ip = (struct inode *)fp->f_data; u_int count, error; int ioflag; if ((ip->i_mode&IFMT) != IFCHR) ILOCK(ip); uio->uio_offset = fp->f_offset; count = uio->uio_resid; if (uio->uio_rw == UIO_READ) { error = rwip(ip, uio, fp->f_flag & FNONBLOCK ? IO_NDELAY : 0); fp->f_offset += (count - uio->uio_resid); } else { ioflag = 0; if ((ip->i_mode&IFMT) == IFREG && (fp->f_flag & FAPPEND)) ioflag |= IO_APPEND; if (fp->f_flag & FNONBLOCK) ioflag |= IO_NDELAY; if (fp->f_flag & FFSYNC || (ip->i_fs->fs_flags & MNT_SYNCHRONOUS)) ioflag |= IO_SYNC; error = rwip(ip, uio, ioflag); if (ioflag & IO_APPEND) fp->f_offset = uio->uio_offset; else fp->f_offset += (count - uio->uio_resid); } if ((ip->i_mode&IFMT) != IFCHR) IUNLOCK(ip); return (error); } int ino_ioctl(fp, com, data) register struct file *fp; register u_int com; caddr_t data; { register struct inode *ip = ((struct inode *)fp->f_data); dev_t dev; switch (ip->i_mode & IFMT) { case IFREG: case IFDIR: if (com == FIONREAD) { if (fp->f_type==DTYPE_PIPE && !(fp->f_flag&FREAD)) *(off_t *)data = 0; else *(off_t *)data = ip->i_size - fp->f_offset; return (0); } if (com == FIONBIO || com == FIOASYNC) /* XXX */ return (0); /* XXX */ /* fall into ... */ default: return (ENOTTY); case IFCHR: dev = ip->i_rdev; u.u_rval = 0; if (setjmp(&u.u_qsave)) { /* * The ONLY way we can get here is via the longjump in sleep. Signals have * been checked for and u_error set accordingly. All that remains to do * is 'return'. */ return(u.u_error); } return((*cdevsw[major(dev)].d_ioctl)(dev,com,data,fp->f_flag)); case IFBLK: dev = ip->i_rdev; u.u_rval = 0; if (setjmp(&u.u_qsave)) { /* * The ONLY way we can get here is via the longjump in sleep. Signals have * been checked for and u_error set accordingly. All that remains to do * is 'return'. */ return(u.u_error); } return((*bdevsw[major(dev)].d_ioctl)(dev,com,data,fp->f_flag)); } } int ino_select(fp, which) struct file *fp; int which; { register struct inode *ip = (struct inode *)fp->f_data; register dev_t dev; switch (ip->i_mode & IFMT) { default: return (1); /* XXX */ case IFCHR: dev = ip->i_rdev; return (*cdevsw[major(dev)].d_select)(dev, which); } } const struct fileops inodeops = { ino_rw, ino_ioctl, ino_select, vn_closefile }; int rdwri (rw, ip, base, len, offset, ioflg, aresid) enum uio_rw rw; struct inode *ip; caddr_t base; int len; off_t offset; int ioflg; register int *aresid; { struct uio auio; struct iovec aiov; register int error; auio.uio_iov = &aiov; auio.uio_iovcnt = 1; aiov.iov_base = base; aiov.iov_len = len; auio.uio_rw = rw; auio.uio_resid = len; auio.uio_offset = offset; error = rwip(ip, &auio, ioflg); if (aresid) *aresid = auio.uio_resid; else if (auio.uio_resid) error = EIO; return (error); } int rwip (ip, uio, ioflag) register struct inode *ip; register struct uio *uio; int ioflag; { dev_t dev = (dev_t)ip->i_rdev; register struct buf *bp; off_t osize; daddr_t lbn, bn; int n, on, type, resid; int error = 0; int flags; //if (uio->uio_offset < 0) //return (EINVAL); type = ip->i_mode & IFMT; /* * The write case below checks that i/o is done synchronously to directories * and that i/o to append only files takes place at the end of file. * We do not panic on non-sync directory i/o - the sync bit is forced on. */ if (uio->uio_rw == UIO_READ) { if (! (ip->i_fs->fs_flags & MNT_NOATIME)) ip->i_flag |= IACC; } else { switch (type) { case IFREG: if (ioflag & IO_APPEND) uio->uio_offset = ip->i_size; if (ip->i_flags & APPEND && uio->uio_offset != ip->i_size) return(EPERM); break; case IFDIR: if ((ioflag & IO_SYNC) == 0) ioflag |= IO_SYNC; break; case IFLNK: case IFBLK: case IFCHR: break; default: return (EFTYPE); } } /* * The IO_SYNC flag is turned off here if the 'async' mount flag is on. * Otherwise directory I/O (which is done by the kernel) would still * synchronous (because the kernel carefully passes IO_SYNC for all directory * I/O) even if the fs was mounted with "-o async". * * A side effect of this is that if the system administrator mounts a filesystem * 'async' then the O_FSYNC flag to open() is ignored. * * This behaviour should probably be selectable via "sysctl fs.async.dirs" and * "fs.async.ofsync". A project for a rainy day. */ if (type == IFREG || (type == IFDIR && (ip->i_fs->fs_flags & MNT_ASYNC))) ioflag &= ~IO_SYNC; if (type == IFCHR) { if (uio->uio_rw == UIO_READ) { if (! (ip->i_fs->fs_flags & MNT_NOATIME)) ip->i_flag |= IACC; error = (*cdevsw[major(dev)].d_read)(dev, uio, ioflag); } else { ip->i_flag |= IUPD|ICHG; error = (*cdevsw[major(dev)].d_write)(dev, uio, ioflag); } return (error); } if (uio->uio_resid == 0) return (0); if (uio->uio_rw == UIO_WRITE && type == IFREG && uio->uio_offset + uio->uio_resid > u.u_rlimit[RLIMIT_FSIZE].rlim_cur) { psignal(u.u_procp, SIGXFSZ); return (EFBIG); } if (type != IFBLK) dev = ip->i_dev; resid = uio->uio_resid; osize = ip->i_size; flags = ioflag & IO_SYNC ? B_SYNC : 0; do { lbn = lblkno(uio->uio_offset); on = blkoff(uio->uio_offset); n = MIN((u_int)(DEV_BSIZE - on), uio->uio_resid); if (type != IFBLK) { if (uio->uio_rw == UIO_READ) { off_t diff = ip->i_size - uio->uio_offset; if (diff <= 0) return (0); if (diff < n) n = diff; bn = bmap(ip, lbn, B_READ, flags); } else bn = bmap(ip,lbn,B_WRITE, n == DEV_BSIZE ? flags : flags|B_CLRBUF); if (u.u_error || (uio->uio_rw == UIO_WRITE && (long)bn < 0)) return (u.u_error); if (uio->uio_rw == UIO_WRITE && uio->uio_offset + n > ip->i_size && (type == IFDIR || type == IFREG || type == IFLNK)) ip->i_size = uio->uio_offset + n; } else { bn = lbn; rablock = bn + 1; } if (uio->uio_rw == UIO_READ) { if ((long)bn < 0) { bp = geteblk(); bzero (bp->b_addr, MAXBSIZE); } else if (ip->i_lastr + 1 == lbn) bp = breada (dev, bn, rablock); else bp = bread (dev, bn); ip->i_lastr = lbn; } else { if (n == DEV_BSIZE) bp = getblk (dev, bn); else bp = bread (dev, bn); /* * 4.3 didn't do this, but 2.10 did. not sure why. * something about tape drivers don't clear buffers on end-of-tape * any longer (clrbuf can't be called from interrupt). */ if (bp->b_resid == DEV_BSIZE) { bp->b_resid = 0; bzero (bp->b_addr, MAXBSIZE); } } n = MIN(n, DEV_BSIZE - bp->b_resid); if (bp->b_flags & B_ERROR) { error = EIO; brelse(bp); break; } u.u_error = uiomove (bp->b_addr + on, n, uio); if (uio->uio_rw == UIO_READ) { if (n + on == DEV_BSIZE || uio->uio_offset == ip->i_size) { bp->b_flags |= B_AGE; if (ip->i_flag & IPIPE) bp->b_flags &= ~B_DELWRI; } brelse(bp); } else { if (ioflag & IO_SYNC) bwrite(bp); /* * The check below interacts _very_ badly with virtual memory tmp files * such as those used by 'ld'. These files tend to be small and repeatedly * rewritten in 1kb chunks. The check below causes the device driver to be * called (and I/O initiated) constantly. Not sure what to do about this yet * but this comment is being placed here as a reminder. */ else if (n + on == DEV_BSIZE && !(ip->i_flag & IPIPE)) { bp->b_flags |= B_AGE; bawrite(bp); } else bdwrite(bp); ip->i_flag |= IUPD|ICHG; if (u.u_ruid != 0) ip->i_mode &= ~(ISUID|ISGID); } } while (u.u_error == 0 && uio->uio_resid && n != 0); if (error == 0) /* XXX */ error = u.u_error; /* XXX */ if (error && (uio->uio_rw == UIO_WRITE) && (ioflag & IO_UNIT) && (type != IFBLK)) { itrunc(ip, osize, ioflag & IO_SYNC); uio->uio_offset -= (resid - uio->uio_resid); uio->uio_resid = resid; /* * Should back out the change to the quota here but that would be a lot * of work for little benefit. Besides we've already made the assumption * that the entire write would succeed and users can't turn on the IO_UNIT * bit for their writes anyways. */ } #ifdef whybother if (! error && (ioflag & IO_SYNC)) IUPDAT(ip, &time, &time, 1); #endif return (error); } int ino_stat(ip, sb) register struct inode *ip; register struct stat *sb; { register struct icommon2 *ic2; ic2 = &ip->i_ic2; /* * inlined ITIMES which takes advantage of the common times pointer. */ if (ip->i_flag & (IUPD|IACC|ICHG)) { ip->i_flag |= IMOD; if (ip->i_flag & IACC) ic2->ic_atime = time.tv_sec; if (ip->i_flag & IUPD) ic2->ic_mtime = time.tv_sec; if (ip->i_flag & ICHG) ic2->ic_ctime = time.tv_sec; ip->i_flag &= ~(IUPD|IACC|ICHG); } sb->st_dev = ip->i_dev; sb->st_ino = ip->i_number; sb->st_mode = ip->i_mode; sb->st_nlink = ip->i_nlink; sb->st_uid = ip->i_uid; sb->st_gid = ip->i_gid; sb->st_rdev = (dev_t)ip->i_rdev; sb->st_size = ip->i_size; sb->st_atime = ic2->ic_atime; sb->st_mtime = ic2->ic_mtime; sb->st_ctime = ic2->ic_ctime; sb->st_blksize = MAXBSIZE; /* * blocks are too tough to do; it's not worth the effort. */ sb->st_blocks = btod (ip->i_size); sb->st_flags = ip->i_flags; return (0); } /* * This routine, like its counterpart openi(), calls the device driver for * special (IBLK, ICHR) files. Normal files simply return early (the default * case in the switch statement). Pipes and sockets do NOT come here because * they have their own close routines. */ int closei (ip, flag) register struct inode *ip; int flag; { register struct mount *mp; register struct file *fp; int mode, error; dev_t dev; int (*cfunc)(); mode = ip->i_mode & IFMT; dev = ip->i_rdev; switch (mode) { case IFCHR: cfunc = cdevsw[major(dev)].d_close; break; case IFBLK: /* * We don't want to really close the device if it is mounted */ /* MOUNT TABLE SHOULD HOLD INODE */ for (mp = mount; mp < &mount[NMOUNT]; mp++) if (mp->m_inodp != NULL && mp->m_dev == dev) return(0); cfunc = bdevsw[major(dev)].d_close; break; default: return(0); } /* * Check that another inode for the same device isn't active. * This is because the same device can be referenced by two * different inodes. */ for (fp = file; fp < file+NFILE; fp++) { if (fp->f_type != DTYPE_INODE) continue; if (fp->f_count && (ip = (struct inode *)fp->f_data) && ip->i_rdev == dev && (ip->i_mode&IFMT) == mode) return(0); } if (mode == IFBLK) { /* * On last close of a block device (that isn't mounted) * we must invalidate any in core blocks, so that * we can, for instance, change floppy disks. */ bflush(dev); binval(dev); } /* * NOTE: none of the device drivers appear to either set u_error OR return * anything meaningful from their close routines. It's a good thing * programs don't bother checking the error status on close() calls. * Apparently the only time "errno" is meaningful after a "close" is * when the process is interrupted. */ if (setjmp (&u.u_qsave)) { /* * If device close routine is interrupted, * must return so closef can clean up. */ if ((error = u.u_error) == 0) error = EINTR; } else error = (*cfunc)(dev, flag, mode); return (error); } /* * Place an advisory lock on an inode. * NOTE: callers of this routine must be prepared to deal with the pseudo * error return ERESTART. */ int ino_lock(fp, cmd) register struct file *fp; int cmd; { register int priority = PLOCK; register struct inode *ip = (struct inode *)fp->f_data; int error; if ((cmd & LOCK_EX) == 0) priority += 4; /* * If there's a exclusive lock currently applied to the file then we've * gotta wait for the lock with everyone else. * * NOTE: We can NOT sleep on i_exlockc because it is on an odd byte boundary * and the low (oddness) bit is reserved for networking/supervisor mode * sleep channels. Thus we always sleep on i_shlockc and simply check * the proper bits to see if the lock we want is granted. This may * mean an extra wakeup/sleep event is done once in a while but * everything will work correctly. */ again: while (ip->i_flag & IEXLOCK) { /* * If we're holding an exclusive * lock, then release it. */ if (fp->f_flag & FEXLOCK) { ino_unlock(fp, FEXLOCK); continue; } if (cmd & LOCK_NB) return (EWOULDBLOCK); ip->i_flag |= ILWAIT; error = tsleep((caddr_t)&ip->i_shlockc, priority | PCATCH, 0); if (error) return(error); } if ((cmd & LOCK_EX) && (ip->i_flag & ISHLOCK)) { /* * Must wait for any shared locks to finish * before we try to apply a exclusive lock. * * If we're holding a shared * lock, then release it. */ if (fp->f_flag & FSHLOCK) { ino_unlock(fp, FSHLOCK); goto again; } if (cmd & LOCK_NB) return (EWOULDBLOCK); ip->i_flag |= ILWAIT; error = tsleep((caddr_t)&ip->i_shlockc, PLOCK | PCATCH, 0); if (error) return(error); goto again; } if (cmd & LOCK_EX) { cmd &= ~LOCK_SH; ip->i_exlockc++; ip->i_flag |= IEXLOCK; fp->f_flag |= FEXLOCK; } if ((cmd & LOCK_SH) && (fp->f_flag & FSHLOCK) == 0) { ip->i_shlockc++; ip->i_flag |= ISHLOCK; fp->f_flag |= FSHLOCK; } return (0); } /* * Unlock a file. */ void ino_unlock(fp, kind) register struct file *fp; int kind; { register struct inode *ip = (struct inode *)fp->f_data; register int flags; kind &= fp->f_flag; if (ip == NULL || kind == 0) return; flags = ip->i_flag; if (kind & FSHLOCK) { if (--ip->i_shlockc == 0) { ip->i_flag &= ~ISHLOCK; if (flags & ILWAIT) wakeup((caddr_t)&ip->i_shlockc); } fp->f_flag &= ~FSHLOCK; } if (kind & FEXLOCK) { if (--ip->i_exlockc == 0) { ip->i_flag &= ~(IEXLOCK|ILWAIT); if (flags & ILWAIT) wakeup((caddr_t)&ip->i_shlockc); } fp->f_flag &= ~FEXLOCK; } } /* * Openi called to allow handler of special files to initialize and * validate before actual IO. */ int openi (ip, mode) register struct inode *ip; int mode; { register dev_t dev = ip->i_rdev; register int maj = major(dev); dev_t bdev; int error; switch (ip->i_mode&IFMT) { case IFCHR: if (ip->i_fs->fs_flags & MNT_NODEV) return(ENXIO); if ((u_int)maj >= nchrdev) return (ENXIO); if (mode & FWRITE) { /* * When running in very secure mode, do not allow * opens for writing of any disk character devices. */ if (securelevel >= 2 && isdisk(dev, IFCHR)) return(EPERM); /* * When running in secure mode, do not allow opens * for writing of /dev/mem, /dev/kmem, or character * devices whose corresponding block devices are * currently mounted. */ if (securelevel >= 1) { if ((bdev = chrtoblk(dev)) != NODEV && (error = ufs_mountedon(bdev))) return(error); if (iskmemdev(dev)) return(EPERM); } } return ((*cdevsw[maj].d_open)(dev, mode, S_IFCHR)); case IFBLK: if (ip->i_fs->fs_flags & MNT_NODEV) return(ENXIO); if ((u_int)maj >= nblkdev) return (ENXIO); /* * When running in very secure mode, do not allow * opens for writing of any disk block devices. */ if (securelevel >= 2 && (mode & FWRITE) && isdisk(dev, IFBLK)) return(EPERM); /* * Do not allow opens of block devices that are * currently mounted. * * 2.11BSD must relax this restriction to allow 'fsck' to * open the root filesystem (which is always mounted) during * a reboot. Once in secure or very secure mode the * above restriction is fully effective. On the otherhand * fsck should 1) use the raw device, 2) not do sync calls... */ if (securelevel > 0 && (error = ufs_mountedon(dev))) return(error); return ((*bdevsw[maj].d_open)(dev, mode, S_IFBLK)); } return (0); } static void forceclose(dev) register dev_t dev; { register struct file *fp; register struct inode *ip; for (fp = file; fp < file+NFILE; fp++) { if (fp->f_count == 0) continue; if (fp->f_type != DTYPE_INODE) continue; ip = (struct inode *)fp->f_data; if (ip == 0) continue; if ((ip->i_mode & IFMT) != IFCHR) continue; if (ip->i_rdev != dev) continue; fp->f_flag &= ~(FREAD | FWRITE); } } /* * Revoke access the current tty by all processes. * Used only by the super-user in init * to give ``clean'' terminals at login. */ void vhangup() { if (! suser()) return; if (u.u_ttyp == NULL) return; forceclose(u.u_ttyd); if ((u.u_ttyp->t_state) & TS_ISOPEN) gsignal(u.u_ttyp->t_pgrp, SIGHUP); } ================================================ FILE: sys/kern/sys_pipe.c ================================================ /* * Copyright (c) 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include #include #include #include #include #include #include #include #include #include int readp (fp, uio, flag) register struct file *fp; register struct uio *uio; int flag; { register struct inode *ip; int error; ip = (struct inode *)fp->f_data; loop: /* Very conservative locking. */ ILOCK(ip); /* If nothing in the pipe, wait (unless FNONBLOCK is set). */ if (ip->i_size == 0) { /* * If there are not both reader and writer active, * return without satisfying read. */ IUNLOCK(ip); if (ip->i_count != 2) return (0); if (fp->f_flag & FNONBLOCK) return (EWOULDBLOCK); ip->i_mode |= IREAD; sleep((caddr_t)ip+4, PPIPE); goto loop; } uio->uio_offset = fp->f_offset; error = rwip(ip, uio, flag); fp->f_offset = uio->uio_offset; /* * If reader has caught up with writer, reset * offset and size to 0. */ if (fp->f_offset == ip->i_size) { fp->f_offset = 0; ip->i_size = 0; if (ip->i_mode & IWRITE) { ip->i_mode &= ~IWRITE; wakeup((caddr_t)ip+2); } if (ip->i_wsel) { selwakeup(ip->i_wsel, (long)(ip->i_flag & IWCOLL)); ip->i_wsel = 0; ip->i_flag &= ~IWCOLL; } } IUNLOCK(ip); return (error); } int writep (fp, uio, flag) struct file *fp; register struct uio *uio; int flag; { register struct inode *ip; register int c; int error = 0; ip = (struct inode *)fp->f_data; c = uio->uio_resid; ILOCK(ip); if ((fp->f_flag & FNONBLOCK) && ip->i_size + c >= MAXPIPSIZ) { error = EWOULDBLOCK; goto done; } loop: /* If all done, return. */ if (c == 0) { uio->uio_resid = 0; goto done; } /* * If there are not both read and write sides of the pipe active, * return error and signal too. */ if (ip->i_count != 2) { psignal(u.u_procp, SIGPIPE); error = EPIPE; done: IUNLOCK(ip); return (error); } /* * If the pipe is full, wait for reads to deplete * and truncate it. */ if (ip->i_size >= MAXPIPSIZ) { ip->i_mode |= IWRITE; IUNLOCK(ip); sleep((caddr_t)ip+2, PPIPE); ILOCK(ip); goto loop; } /* * Write what is possible and loop back. * If writing less than MAXPIPSIZ, it always goes. * One can therefore get a file > MAXPIPSIZ if write * sizes do not divide MAXPIPSIZ. */ uio->uio_offset = ip->i_size; uio->uio_resid = MIN((u_int)c, (u_int)MAXPIPSIZ); c -= uio->uio_resid; error = rwip(ip, uio, flag); if (ip->i_mode&IREAD) { ip->i_mode &= ~IREAD; wakeup((caddr_t)ip+4); } if (ip->i_rsel) { selwakeup(ip->i_rsel, (long)(ip->i_flag & IRCOLL)); ip->i_rsel = 0; ip->i_flag &= ~IRCOLL; } goto loop; } int pipe_rw (fp, uio, flag) register struct file *fp; register struct uio *uio; int flag; { if (uio->uio_rw == UIO_READ) return (readp(fp, uio, flag)); return (writep(fp, uio, flag)); } int pipe_select (fp, which) struct file *fp; int which; { register struct inode *ip = (struct inode *)fp->f_data; register struct proc *p; register int retval = 0; extern int selwait; ILOCK(ip); if (ip->i_count != 2) retval = 1; else switch (which) { case FREAD: if (ip->i_size) { retval = 1; break; } if ((p = ip->i_rsel) && p->p_wchan == (caddr_t)&selwait) ip->i_flag |= IRCOLL; else ip->i_rsel = u.u_procp; break; case FWRITE: if (ip->i_size < MAXPIPSIZ) { retval = 1; break; } if ((p = ip->i_wsel) && p->p_wchan == (caddr_t)&selwait) ip->i_flag |= IWCOLL; else ip->i_wsel = u.u_procp; break; } IUNLOCK(ip); return(retval); } /* * This routine was pulled out of what used to be called 'ino_close'. Doing * so saved a test of the inode belonging to a pipe. We know this is a pipe * because the inode type was DTYPE_PIPE. The dispatch in closef() can come * directly here instead of the general inode close routine. * * This routine frees the inode by calling 'iput'. The inode must be * unlocked prior to calling this routine because an 'ilock' is done prior * to the select wakeup processing. */ int pipe_close(fp) struct file *fp; { register struct inode *ip = (struct inode *)fp->f_data; ilock(ip); #ifdef DIAGNOSTIC if ((ip->i_flag & IPIPE) == 0) panic("pipe_close !IPIPE"); #endif if (ip->i_rsel) { selwakeup(ip->i_rsel, (long)(ip->i_flag & IRCOLL)); ip->i_rsel = 0; ip->i_flag &= ~IRCOLL; } if (ip->i_wsel) { selwakeup(ip->i_wsel, (long)(ip->i_flag & IWCOLL)); ip->i_wsel = 0; ip->i_flag &= ~IWCOLL; } ip->i_mode &= ~(IREAD|IWRITE); wakeup((caddr_t)ip+2); wakeup((caddr_t)ip+4); /* * And finally decrement the reference count and (likely) release the inode. */ iput(ip); return(0); } const struct fileops pipeops = { pipe_rw, ino_ioctl, pipe_select, pipe_close }; /* * The sys-pipe entry. * Allocate an inode on the root device. Allocate 2 * file structures. Put it all together with flags. */ void pipe() { register struct inode *ip; register struct file *rf, *wf; static struct mount *mp; struct inode itmp; int r; /* * if pipedev not yet found, or not available, get it; if can't * find it, use rootdev. It would be cleaner to wander around * and fix it so that this and getfs() only check m_dev OR * m_inodp, but hopefully the mount table isn't scanned enough * to make it a problem. Besides, 4.3's is just as bad. Basic * fantasy is that if m_inodp is set, m_dev *will* be okay. */ if (! mp || ! mp->m_inodp || mp->m_dev != pipedev) { for (mp = &mount[0]; ; ++mp) { if (mp == &mount[NMOUNT]) { mp = &mount[0]; /* use root */ break; } if (mp->m_inodp == NULL || mp->m_dev != pipedev) continue; break; } if (mp->m_filsys.fs_ronly) { u.u_error = EROFS; return; } } itmp.i_fs = &mp->m_filsys; itmp.i_dev = mp->m_dev; ip = ialloc (&itmp); if (ip == NULL) return; rf = falloc(); if (rf == NULL) { iput (ip); return; } r = u.u_rval; wf = falloc(); if (wf == NULL) { rf->f_count = 0; u.u_ofile[r] = NULL; iput (ip); return; } /* 'Write' end of pipe (for filedes[1]). */ #ifdef __mips__ /* Move a secondary return value to register $v1. */ u.u_frame->tf_r3 = u.u_rval; #elif __thumb2__ || __thumb__ /* Move a secondary return value to register $a2. */ u.u_frame->tf_r1 = u.u_rval; #else #error "pipe return value for unknown architecture" #endif /* 'Read' end of pipe (for filedes[0]). */ u.u_rval = r; wf->f_flag = FWRITE; rf->f_flag = FREAD; rf->f_type = wf->f_type = DTYPE_PIPE; rf->f_data = wf->f_data = (caddr_t) ip; ip->i_count = 2; ip->i_mode = IFREG; ip->i_flag = IACC | IUPD | ICHG | IPIPE; } ================================================ FILE: sys/kern/sys_process.c ================================================ /* * Copyright (c) 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include #include #include #include #include #include #include #include /* * sys-trace system call. */ void ptrace() { register struct proc *p; register struct a { int req; int pid; int *addr; int data; } *uap; uap = (struct a *)u.u_arg; if (uap->req <= 0) { u.u_procp->p_flag |= P_TRACED; return; } p = pfind(uap->pid); if (p == 0 || p->p_stat != SSTOP || p->p_ppid != u.u_procp->p_pid || !(p->p_flag & P_TRACED)) { u.u_error = ESRCH; return; } while (ipc.ip_lock) sleep((caddr_t)&ipc, PZERO); ipc.ip_lock = p->p_pid; ipc.ip_data = uap->data; ipc.ip_addr = uap->addr; ipc.ip_req = uap->req; p->p_flag &= ~P_WAITED; setrun(p); while (ipc.ip_req > 0) sleep((caddr_t)&ipc, PZERO); u.u_rval = ipc.ip_data; if (ipc.ip_req < 0) u.u_error = EIO; ipc.ip_lock = 0; wakeup((caddr_t)&ipc); } /* * Code that the child process * executes to implement the command * of the parent process in tracing. */ int procxmt() { register int i, *p; if (ipc.ip_lock != u.u_procp->p_pid) return(0); u.u_procp->p_slptime = 0; i = ipc.ip_req; ipc.ip_req = 0; wakeup ((caddr_t)&ipc); switch (i) { /* read user I */ case PT_READ_I: /* read user D */ case PT_READ_D: if (baduaddr ((caddr_t) ipc.ip_addr)) goto error; ipc.ip_data = *(int*) ipc.ip_addr; break; /* read u */ case PT_READ_U: i = (int) ipc.ip_addr; if (i < 0 || i >= USIZE) goto error; ipc.ip_data = ((unsigned*)&u) [i/sizeof(int)]; break; /* write user I */ case PT_WRITE_I: /* write user D */ case PT_WRITE_D: if (baduaddr ((caddr_t) ipc.ip_addr)) goto error; *(int*) ipc.ip_addr = ipc.ip_data; break; /* write u */ case PT_WRITE_U: i = (int)ipc.ip_addr; p = (int*)&u + i/sizeof(int); #ifdef __mips__ for (i=0; itf_status |= ST_RP; #elif __thumb2__ || __thumb__ /* XXX FRAME */ #else #error "single step process status for unknown architecture" #endif /* FALL THROUGH TO ... */ case PT_CONTINUE: if ((int)ipc.ip_addr != 1) u.u_frame->tf_pc = (int)ipc.ip_addr; /* XXX FRAME */ if (ipc.ip_data > NSIG) goto error; u.u_procp->p_ptracesig = ipc.ip_data; return(1); /* force exit */ case PT_KILL: exit(u.u_procp->p_ptracesig); /*NOTREACHED*/ default: error: ipc.ip_req = -1; } return(0); } ================================================ FILE: sys/kern/syscalls.c ================================================ /* * Copyright (c) 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ /* * System call names. */ #ifndef pdp11 const char *const syscallnames[] = { "indir", /* 0 = indir */ "exit", /* 1 = exit */ "fork", /* 2 = fork */ "read", /* 3 = read */ "write", /* 4 = write */ "open", /* 5 = open */ "close", /* 6 = close */ "wait4", /* 7 = wait4 */ "#8", /* 8 = (old creat) */ "link", /* 9 = link */ "unlink", /* 10 = unlink */ "execv", /* 11 = execv */ "chdir", /* 12 = chdir */ "fchdir", /* 13 = fchdir */ "mknod", /* 14 = mknod */ "chmod", /* 15 = chmod */ "chown", /* 16 = chown; now 3 args */ "chflags", /* 17 = chflags */ "fchflags", /* 18 = fchflags */ "lseek", /* 19 = lseek */ "getpid", /* 20 = getpid */ "mount", /* 21 = mount */ "umount", /* 22 = umount */ "__sysctl", /* 23 = __sysctl */ "getuid", /* 24 = getuid */ "geteuid", /* 25 = geteuid */ "ptrace", /* 26 = ptrace */ "getppid", /* 27 = getppid */ "statfs", /* 28 = statfs */ "fstatfs", /* 29 = fstatfs */ "getfsstat", /* 30 = getfsstat */ "sigaction", /* 31 = sigaction */ "sigprocmask", /* 32 = sigprocmask */ "access", /* 33 = access */ "sigpending", /* 34 = sigpending */ "sigaltstack", /* 35 = sigaltstack */ "sync", /* 36 = sync */ "kill", /* 37 = kill */ "stat", /* 38 = stat */ "getlogin", /* 39 = getlogin */ "lstat", /* 40 = lstat */ "dup", /* 41 = dup */ "pipe", /* 42 = pipe */ "setlogin", /* 43 = setlogin */ "profil", /* 44 = profil */ "setuid", /* 45 = setuid */ "seteuid", /* 46 = seteuid */ "getgid", /* 47 = getgid */ "getegid", /* 48 = getegid */ "setgid", /* 49 = setgid */ "setegid", /* 50 = setegid */ "kmemdev", /* 51 = kmemdev */ "phys", /* 52 = (2.9) set phys addr */ "lock", /* 53 = (2.9) lock in core */ "ioctl", /* 54 = ioctl */ "reboot", /* 55 = reboot */ "sigwait", /* 56 = sigwait */ "symlink", /* 57 = symlink */ "readlink", /* 58 = readlink */ "execve", /* 59 = execve */ "umask", /* 60 = umask */ "chroot", /* 61 = chroot */ "fstat", /* 62 = fstat */ "#63", /* 63 = unused */ "#64", /* 64 = (old getpagesize) */ "pselect", /* 65 = pselect */ "vfork", /* 66 = vfork */ "#67", /* 67 = unused */ "#68", /* 68 = unused */ "brk", /* 69 = brk */ "rdglob", /* 70 = read from global space */ "wrglob", /* 71 = write to global space */ "msec", /* 72 = kticks */ "#73", /* 73 = unused */ "#74", /* 74 = unused */ "#75", /* 75 = unused */ "vhangup", /* 76 = vhangup */ "#77", /* 77 = unused */ "#78", /* 78 = unused */ "getgroups", /* 79 = getgroups */ "setgroups", /* 80 = setgroups */ "getpgrp", /* 81 = getpgrp */ "setpgrp", /* 82 = setpgrp */ "setitimer", /* 83 = setitimer */ "old wait", /* 84 = wait,wait3 COMPAT*/ "#85", /* 85 = unused */ "getitimer", /* 86 = getitimer */ "#87", /* 87 = (old gethostname) */ "#88", /* 88 = (old sethostname) */ "getdtablesize", /* 89 = getdtablesize */ "dup2", /* 90 = dup2 */ "#91", /* 91 = unused */ "fcntl", /* 92 = fcntl */ "select", /* 93 = select */ "#94", /* 94 = unused */ "fsync", /* 95 = fsync */ "setpriority", /* 96 = setpriority */ "socket", /* 97 = socket */ "connect", /* 98 = connect */ "accept", /* 99 = accept */ "getpriority", /* 100 = getpriority */ "send", /* 101 = send */ "recv", /* 102 = recv */ "sigreturn", /* 103 = sigreturn */ "bind", /* 104 = bind */ "setsockopt", /* 105 = setsockopt */ "listen", /* 106 = listen */ "sigsuspend", /* 107 = sigsuspend */ "#108", /* 108 = (old sigvec) */ "#109", /* 109 = (old sigblock) */ "#110", /* 110 = (old sigsetmask) */ "#111", /* 111 = (old sigpause) */ "sigstack", /* 112 = sigstack COMPAT-43 */ "recvmsg", /* 113 = recvmsg */ "sendmsg", /* 114 = sendmsg */ "#115", /* 115 = unused */ "gettimeofday", /* 116 = gettimeofday */ "getrusage", /* 117 = getrusage */ "getsockopt", /* 118 = getsockopt */ "#119", /* 119 = unused */ "readv", /* 120 = readv */ "writev", /* 121 = writev */ "settimeofday", /* 122 = settimeofday */ "fchown", /* 123 = fchown */ "fchmod", /* 124 = fchmod */ "recvfrom", /* 125 = recvfrom */ "#126", /* 126 = (old setreuid) */ "#127", /* 127 = (old setregid) */ "rename", /* 128 = rename */ "truncate", /* 129 = truncate */ "ftruncate", /* 130 = ftruncate */ "flock", /* 131 = flock */ "#132", /* 132 = unused */ "sendto", /* 133 = sendto */ "shutdown", /* 134 = shutdown */ "socketpair", /* 135 = socketpair */ "mkdir", /* 136 = mkdir */ "rmdir", /* 137 = rmdir */ "utimes", /* 138 = utimes */ "#139", /* 139 = unused */ "adjtime", /* 140 = adjtime */ "getpeername", /* 141 = getpeername */ "#142", /* 142 = (old gethostid) */ "#143", /* 143 = (old sethostid) */ "getrlimit", /* 144 = getrlimit */ "setrlimit", /* 145 = setrlimit */ "killpg", /* 146 = killpg */ "#147", /* 147 = unused */ "setquota", /* 148 = setquota */ "quota", /* 149 = quota */ "getsockname", /* 150 = getsockname */ "#151", /* 151 = unused */ "ustore", /* 152 = ustore */ "ufetch", /* 153 = ufetch */ "ucall", /* 154 = ucall */ "#155", /* 155 = unused */ }; #endif ================================================ FILE: sys/kern/tty.c ================================================ /* * Copyright (c) 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include #include #include #include #include #include #include #include #include #include #include #include #include static int rts = TIOCM_RTS; /* * These were moved here from tty.h so that they could be easily modified * and/or patched instead of recompiling the kernel. There is only 1 other * place which references these - see tty_pty.c * * The block and unblock numbers may look low but certain devices (the DHV-11 * for example) have poor silo handling and at high data rates (19200) the * raw queue overflows even though we've stopped the sending device. At 192 * characters for the 'block' point c-kermit would regularily see dropped data * during interactive mode at 19200. * * It would be nice to have a larger than 8kb clist area and raise these limits * but that would require 2 mapping registers and/or a rewrite of the entire * clist handling. */ int TTYHOG = 255; int TTYBLOCK = 128; int TTYUNBLOCK = 64; /* * Table giving parity for characters and indicating * character classes to tty driver. In particular, * if the low 6 bits are 0, then the character needs * no special processing on output. */ const char partab[] = { 0001,0201,0201,0001,0201,0001,0001,0201, 0202,0004,0003,0201,0005,0206,0201,0001, 0201,0001,0001,0201,0001,0201,0201,0001, 0001,0201,0201,0001,0201,0001,0001,0201, 0200,0000,0000,0200,0000,0200,0200,0000, 0000,0200,0200,0000,0200,0000,0000,0200, 0000,0200,0200,0000,0200,0000,0000,0200, 0200,0000,0000,0200,0000,0200,0200,0000, 0200,0000,0000,0200,0000,0200,0200,0000, 0000,0200,0200,0000,0200,0000,0000,0200, 0000,0200,0200,0000,0200,0000,0000,0200, 0200,0000,0000,0200,0000,0200,0200,0000, 0000,0200,0200,0000,0200,0000,0000,0200, 0200,0000,0000,0200,0000,0200,0200,0000, 0200,0000,0000,0200,0000,0200,0200,0000, 0000,0200,0200,0000,0200,0000,0000,0201, /* * 7 bit ascii ends with the last character above, * but we contine through all 256 codes for the sake * of the tty output routines which use special vax * instructions which need a 256 character trt table. */ 0007,0007,0007,0007,0007,0007,0007,0007, 0007,0007,0007,0007,0007,0007,0007,0007, 0007,0007,0007,0007,0007,0007,0007,0007, 0007,0007,0007,0007,0007,0007,0007,0007, 0007,0007,0007,0007,0007,0007,0007,0007, 0007,0007,0007,0007,0007,0007,0007,0007, 0007,0007,0007,0007,0007,0007,0007,0007, 0007,0007,0007,0007,0007,0007,0007,0007, 0007,0007,0007,0007,0007,0007,0007,0007, 0007,0007,0007,0007,0007,0007,0007,0007, 0007,0007,0007,0007,0007,0007,0007,0007, 0007,0007,0007,0007,0007,0007,0007,0007, 0007,0007,0007,0007,0007,0007,0007,0007, 0007,0007,0007,0007,0007,0007,0007,0007, 0007,0007,0007,0007,0007,0007,0007,0007, 0007,0007,0007,0007,0007,0007,0007,0007 }; const int tthiwat[NSPEEDS] = { 100, /* 0 baud */ 100, /* 50 baud */ 100, /* 75 baud */ 100, /* 150 baud */ 100, /* 200 baud */ 100, /* 300 baud */ 100, /* 600 baud */ 200, /* 1200 baud */ 200, /* 1800 baud */ 400, /* 2400 baud */ 400, /* 4800 baud */ 400, /* 9600 baud */ 650, /* 19200 baud */ 650, /* 38400 baud */ 1300, /* 57600 baud */ 2000, /* 115.2 kbaud */ 2000, /* 230.4 kbaud */ 2000, /* 460.8 kbaud */ 2000, /* 500 kbaud */ 2000, /* 576 kbaud */ 2000, /* 921.6 kbaud */ 2000, /* 1000 kbaud */ 2000, /* 1152 kbaud */ 2000, /* 1500 kbaud */ 2000, /* 2000 kbaud */ 2000, /* 2500 kbaud */ 2000, /* 3000 kbaud */ 2000, /* 3500 kbaud */ 2000, /* 4000 kbaud */ }; const int ttlowat[NSPEEDS] = { 30, /* 0 baud */ 30, /* 50 baud */ 30, /* 75 baud */ 30, /* 150 baud */ 30, /* 200 baud */ 30, /* 300 baud */ 30, /* 600 baud */ 50, /* 1200 baud */ 50, /* 1800 baud */ 120, /* 2400 baud */ 120, /* 4800 baud */ 120, /* 9600 baud */ 125, /* 19200 baud */ 125, /* 38400 baud */ 125, /* 57600 baud */ 125, /* 115.2 kbaud */ 125, /* 230.4 kbaud */ 125, /* 460.8 kbaud */ 125, /* 500 kbaud */ 125, /* 576 kbaud */ 125, /* 921.6 kbaud */ 125, /* 1000 kbaud */ 125, /* 1152 kbaud */ 125, /* 1500 kbaud */ 125, /* 2000 kbaud */ 125, /* 2500 kbaud */ 125, /* 3000 kbaud */ 125, /* 3500 kbaud */ 125, /* 4000 kbaud */ }; #define SET(t,f) (t) |= (f) #define CLR(t,f) (t) &= ~(f) #define ISSET(t,f) ((t) & (f)) /* * Set t_chars to default values. */ void ttychars(tp) struct tty *tp; { static const struct ttychars ttydefaults = { CERASE, CKILL, CINTR, CQUIT, CSTART, CSTOP, CEOF, CBRK, CSUSP, CDSUSP, CRPRNT, CFLUSH, CWERASE,CLNEXT }; tp->t_chars = ttydefaults; } /* * Wakeup processes waiting on output flow control (TS_ASLEEP). Normally * called from driver start routine (dhvstart, etc) after a transmit done * interrupt. If t_outq.c_cc <= t_lowat then do the wakeup. */ void ttyowake(tp) register struct tty *tp; { if (tp->t_outq.c_cc <= TTLOWAT(tp)) { if (ISSET(tp->t_state,TS_ASLEEP)) { CLR(tp->t_state,TS_ASLEEP); wakeup ((caddr_t)&tp->t_outq); } if (tp->t_wsel) { selwakeup (tp->t_wsel, tp->t_state & TS_WCOLL); tp->t_wsel = 0; CLR(tp->t_state,TS_WCOLL); } } } static void ttywait(tp) register struct tty *tp; { register int s = spltty(); while ((tp->t_outq.c_cc || tp->t_state & TS_BUSY) && tp->t_state & TS_CARR_ON && tp->t_oproc) { (*tp->t_oproc)(tp); /* * If the output routine drains the queue and the device is no longer busy * then don't wait for something that's already happened. */ if (tp->t_outq.c_cc == 0 && !ISSET(tp->t_state,TS_BUSY)) break; tp->t_state |= TS_ASLEEP; sleep((caddr_t)&tp->t_outq, TTOPRI); splx(s); /* drop priority, give interrupts a chance */ s = spltty(); } splx(s); } /* * Wait for output to drain, then flush input waiting. */ void ttywflush(tp) register struct tty *tp; { ttywait(tp); ttyflush(tp, FREAD); } static void ttyunblock (tp) register struct tty *tp; { if (ISSET(tp->t_flags,TANDEM) && tp->t_startc != _POSIX_VDISABLE && putc(tp->t_startc, &tp->t_outq) == 0) { CLR(tp->t_state,TS_TBLOCK); ttstart(tp); } if (ISSET(tp->t_flags, RTSCTS) && (*cdevsw[major(tp->t_dev)].d_ioctl) (tp->t_dev, TIOCMBIS, (caddr_t) &rts, 0) == 0) { CLR(tp->t_state, TS_TBLOCK); } } /* * Flush all TTY queues. */ void ttyflush (tp, rw) register struct tty *tp; int rw; { register int s; s = spltty(); if (rw & FREAD) { while (getc(&tp->t_canq) >= 0) ; while (getc(&tp->t_rawq) >= 0) ; tp->t_rocount = 0; tp->t_rocol = 0; tp->t_state &= ~TS_LOCAL; ttwakeup (tp); } if (rw & FWRITE) { tp->t_state &= ~TS_TTSTOP; (*cdevsw[major(tp->t_dev)].d_stop)(tp, rw); wakeup ((caddr_t)&tp->t_outq); while (getc(&tp->t_outq) >= 0) ; selwakeup (tp->t_wsel, tp->t_state & TS_WCOLL); CLR(tp->t_state, TS_WCOLL); tp->t_wsel = 0; } if (rw & FREAD && ISSET(tp->t_state,TS_TBLOCK)) ttyunblock(tp); splx(s); } /* * Send stop character on input overflow. */ void ttyblock(tp) register struct tty *tp; { register int total; total = tp->t_rawq.c_cc + tp->t_canq.c_cc; /* * Block further input iff: * Current input > threshold AND input is available to user program */ if (total >= TTYBLOCK && ((tp->t_flags & (RAW|CBREAK)) || (tp->t_canq.c_cc > 0)) && (tp->t_state & TS_TBLOCK) == 0) { /* * TANDEM is the same as IXOFF for all intents and purposes. Since we could * get called for either software or hardware flow control we need to check * the IXOFF bit. */ if (ISSET(tp->t_flags,TANDEM) && tp->t_stopc != _POSIX_VDISABLE && putc(tp->t_stopc, &tp->t_outq) == 0) { SET(tp->t_state, TS_TBLOCK); ttstart(tp); } /* * If queue is full, drop RTS to tell modem to stop sending us stuff */ if (ISSET(tp->t_flags, RTSCTS) && (*cdevsw[major(tp->t_dev)].d_ioctl) (tp->t_dev, TIOCMBIC, (caddr_t) &rts, 0) == 0) { SET(tp->t_state, TS_TBLOCK); } } } /* * Restart typewriter output following a delay timeout. * The name of the routine is passed to the timeout * subroutine and it is called during a clock interrupt. */ void ttrstrt(tp) register struct tty *tp; { tp->t_state &= ~TS_TIMEOUT; ttstart(tp); } /* * Start output on the typewriter. It is used from the top half * after some characters have been put on the output queue, * from the interrupt routine to transmit the next * character, and after a timeout has finished. * * The spl calls were removed because the priority should already be spltty. */ void ttstart(tp) register struct tty *tp; { if (tp->t_oproc) /* kludge for pty */ (*tp->t_oproc) (tp); } /* * reinput pending characters after state switch * call at spltty(). */ static void ttypend (tp) register struct tty *tp; { struct clist tq; register int c; tp->t_flags &= ~PENDIN; tp->t_state |= TS_TYPEN; tq = tp->t_rawq; tp->t_rawq.c_cc = 0; tp->t_rawq.c_cf = tp->t_rawq.c_cl = 0; while ((c = getc(&tq)) >= 0) ttyinput(c, tp); tp->t_state &= ~TS_TYPEN; } static int ttnread (tp) register struct tty *tp; { register int nread = 0; if (tp->t_flags & PENDIN) ttypend(tp); nread = tp->t_canq.c_cc; if (tp->t_flags & (RAW|CBREAK)) nread += tp->t_rawq.c_cc; return (nread); } /* * Common code for tty ioctls. */ /*ARGSUSED*/ int ttioctl(tp, com, data, flag) register struct tty *tp; u_int com; caddr_t data; int flag; { int s; long newflags; //printf ("ttioctl (com=%08x, data=%08x, flag=%d)\n", com, data, flag); /* * If the ioctl involves modification, * hang if in the background. */ switch (com) { case TIOCSETD: case TIOCSETP: case TIOCSETN: case TIOCFLUSH: case TIOCSETC: case TIOCSLTC: case TIOCSPGRP: case TIOCLBIS: case TIOCLBIC: case TIOCLSET: case TIOCSTI: case TIOCSWINSZ: while (u.u_procp->p_pgrp != tp->t_pgrp && tp == u.u_ttyp && (u.u_procp->p_flag & SVFORK) == 0 && !(u.u_procp->p_sigignore & sigmask(SIGTTOU)) && !(u.u_procp->p_sigmask & sigmask(SIGTTOU))) { gsignal(u.u_procp->p_pgrp, SIGTTOU); sleep((caddr_t)&lbolt, TTOPRI); } break; } /* * Process the ioctl. */ switch (com) { /* get discipline number */ case TIOCGETD: *(int *)data = 0; break; /* set line discipline */ case TIOCSETD: { register int t = *(int *)data; if (t != 0) return (ENXIO); break; } /* prevent more opens on channel */ case TIOCEXCL: tp->t_state |= TS_XCLUDE; break; case TIOCNXCL: tp->t_state &= ~TS_XCLUDE; break; /* hang up line on last close */ case TIOCHPCL: tp->t_state |= TS_HUPCLS; break; case TIOCFLUSH: { register int flags = *(int *)data; if (flags == 0) flags = FREAD|FWRITE; else flags &= FREAD|FWRITE; ttyflush(tp, flags); break; } /* return number of characters immediately available */ case FIONREAD: *(off_t *)data = ttnread(tp); break; case TIOCOUTQ: *(int *)data = tp->t_outq.c_cc; break; case TIOCSTOP: s = spltty(); if ((tp->t_state & TS_TTSTOP) == 0) { tp->t_state |= TS_TTSTOP; (*cdevsw[major(tp->t_dev)].d_stop)(tp, 0); } splx(s); break; case TIOCSTART: s = spltty(); if ((tp->t_state & TS_TTSTOP) || (tp->t_flags & FLUSHO)) { tp->t_state &= ~TS_TTSTOP; tp->t_flags &= ~FLUSHO; ttstart(tp); } splx(s); break; /* * Simulate typing of a character at the terminal. */ case TIOCSTI: if (u.u_uid && (flag & FREAD) == 0) return (EPERM); if (u.u_uid && u.u_ttyp != tp) return (EACCES); ttyinput (*(char *)data, tp); break; case TIOCSETP: case TIOCSETN: { register struct sgttyb *sg = (struct sgttyb *)data; tp->t_erase = sg->sg_erase; tp->t_kill = sg->sg_kill; tp->t_ispeed = sg->sg_ispeed; tp->t_ospeed = sg->sg_ospeed; newflags = (tp->t_flags&0xffff0000) | (sg->sg_flags&0xffffL); s = spltty(); if (tp->t_flags & RAW || newflags & RAW || com == TIOCSETP) { ttywait(tp); ttyflush(tp, FREAD); } else if ((tp->t_flags & CBREAK) != (newflags & CBREAK)) { if (newflags & CBREAK) { struct clist tq; catq(&tp->t_rawq, &tp->t_canq); tq = tp->t_rawq; tp->t_rawq = tp->t_canq; tp->t_canq = tq; } else { tp->t_flags |= PENDIN; newflags |= PENDIN; ttwakeup (tp); } } tp->t_flags = newflags; if (tp->t_flags & RAW) { tp->t_state &= ~TS_TTSTOP; ttstart(tp); } splx(s); break; } /* send current parameters to user */ case TIOCGETP: { register struct sgttyb *sg = (struct sgttyb *)data; sg->sg_ispeed = tp->t_ispeed; sg->sg_ospeed = tp->t_ospeed; sg->sg_erase = tp->t_erase; sg->sg_kill = tp->t_kill; sg->sg_flags = tp->t_flags; break; } case FIONBIO: break; /* XXX remove */ case FIOASYNC: if (*(int *)data) tp->t_state |= TS_ASYNC; else tp->t_state &= ~TS_ASYNC; break; case TIOCGETC: bcopy((caddr_t)&tp->t_intrc, data, sizeof (struct tchars)); break; case TIOCSETC: bcopy(data, (caddr_t)&tp->t_intrc, sizeof (struct tchars)); break; /* set/get local special characters */ case TIOCSLTC: bcopy(data, (caddr_t)&tp->t_suspc, sizeof (struct ltchars)); break; case TIOCGLTC: bcopy((caddr_t)&tp->t_suspc, data, sizeof (struct ltchars)); break; /* * Modify local mode word. */ case TIOCLBIS: tp->t_flags |= (long)*(u_int *)data << 16; break; case TIOCLBIC: tp->t_flags &= ~((long)*(u_int *)data << 16); break; case TIOCLSET: tp->t_flags &= 0xffffL; tp->t_flags |= (long)*(u_int *)data << 16; break; case TIOCLGET: *(int *)data = tp->t_flags >> 16; break; /* * Allow SPGRP only if tty is open for reading. * Quick check: if we can find a process in the new pgrp, * this user must own that process. * SHOULD VERIFY THAT PGRP IS IN USE AND IS THIS USER'S. */ case TIOCSPGRP: { struct proc *p; short pgrp = *(int *)data; if (u.u_uid && (flag & FREAD) == 0) return (EPERM); p = pfind(pgrp); if (p && p->p_pgrp == pgrp && p->p_uid != u.u_uid && u.u_uid && !inferior(p)) return (EPERM); tp->t_pgrp = pgrp; break; } case TIOCGPGRP: *(int *)data = tp->t_pgrp; break; case TIOCSWINSZ: if (bcmp((caddr_t)&tp->t_winsize, data, sizeof (struct winsize))) { tp->t_winsize = *(struct winsize *)data; gsignal(tp->t_pgrp, SIGWINCH); } break; case TIOCGWINSZ: *(struct winsize *)data = tp->t_winsize; break; default: return (-1); } return (0); } /* * Check that input or output is possible on a terminal. */ int ttyselect (tp, rw) register struct tty *tp; int rw; { int nread; register int s = spltty(); switch (rw) { case FREAD: nread = ttnread(tp); if ((nread > 0) || ((tp->t_state & TS_CARR_ON) == 0)) goto win; if (tp->t_rsel && tp->t_rsel->p_wchan == (caddr_t)&selwait) tp->t_state |= TS_RCOLL; else tp->t_rsel = u.u_procp; break; case FWRITE: if (tp->t_outq.c_cc <= TTLOWAT(tp)) goto win; if (tp->t_wsel && tp->t_wsel->p_wchan == (caddr_t)&selwait) tp->t_state |= TS_WCOLL; else tp->t_wsel = u.u_procp; break; } splx(s); return (0); win: splx(s); return (1); } /* * Initial open of tty, or (re)entry to line discipline. * Establish a process group for distribution of * quits and interrupts from the tty. */ int ttyopen(dev, tp) dev_t dev; register struct tty *tp; { register struct proc *pp; pp = u.u_procp; tp->t_dev = dev; if (pp->p_pgrp == 0) { u.u_ttyp = tp; u.u_ttyd = dev; if (tp->t_pgrp == 0) tp->t_pgrp = pp->p_pid; pp->p_pgrp = tp->t_pgrp; } tp->t_state &= ~TS_WOPEN; if ((tp->t_state & TS_ISOPEN) == 0) { tp->t_state |= TS_ISOPEN; bzero((caddr_t)&tp->t_winsize, sizeof(tp->t_winsize)); } return (0); } /* * "close" a line discipline */ int ttylclose (tp, flag) register struct tty *tp; int flag; { /* * 4.4 has IO_NDELAY but I think that is a mistake because the upper level * 'close' routines all pass 'fp->f_flags' down. This was verified with a * printf here - the F* flags are received rather than the IO_* flags! */ if (flag & FNDELAY) ttyflush(tp, FREAD|FWRITE); else ttywflush(tp); return (0); } /* * Clean terminal on last close. */ void ttyclose(tp) register struct tty *tp; { ttyflush(tp, FREAD|FWRITE); tp->t_pgrp = 0; tp->t_state = 0; } /* * Handle modem control transition on a tty. * Flag indicates new state of carrier. * Returns 0 if the line should be turned off, otherwise 1. */ int ttymodem(tp, flag) register struct tty *tp; int flag; { if ((tp->t_state & TS_WOPEN) == 0 && (tp->t_flags & MDMBUF)) { /* * MDMBUF: do flow control according to carrier flag */ if (flag) { tp->t_state &= ~TS_TTSTOP; ttstart(tp); } else if ((tp->t_state & TS_TTSTOP) == 0) { tp->t_state |= TS_TTSTOP; (*cdevsw[major(tp->t_dev)].d_stop)(tp, 0); } } else if (flag == 0) { /* * Lost carrier. */ tp->t_state &= ~TS_CARR_ON; if (tp->t_state & TS_ISOPEN) { if ((tp->t_flags & NOHANG) == 0) { gsignal(tp->t_pgrp, SIGHUP); gsignal(tp->t_pgrp, SIGCONT); ttyflush(tp, FREAD|FWRITE); return (0); } } } else { /* * Carrier now on. */ tp->t_state |= TS_CARR_ON; wakeup ((caddr_t) &tp->t_rawq); } return (1); } /* * Default modem control routine (for other line disciplines). * Return argument flag, to turn off device on carrier drop. */ int nullmodem(tp, flag) register struct tty *tp; int flag; { if (flag) tp->t_state |= TS_CARR_ON; else tp->t_state &= ~TS_CARR_ON; return (flag); } /* * send string cp to tp */ static void ttyout (cp, tp) register char *cp; register struct tty *tp; { register int c; while ((c = *cp++)) (void) ttyoutput (c, tp); } /* * Crt back over cnt chars perhaps * erasing them. */ static void ttyrubo(tp, cnt) register struct tty *tp; register int cnt; { register char *rubostring = (tp->t_flags & CRTERA) ? "\b \b" : "\b"; while (--cnt >= 0) ttyout(rubostring, tp); } /* * Echo a typed character to the terminal */ static void ttyecho(c, tp) register int c; register struct tty *tp; { register int c7; if ((tp->t_state & TS_CNTTB) == 0) tp->t_flags &= ~FLUSHO; if ((tp->t_flags & ECHO) == 0) return; c &= 0377; if (tp->t_flags & RAW) { (void) ttyoutput(c, tp); return; } if (c == '\r' && tp->t_flags & CRMOD) c = '\n'; c7 = c & 0177; if (tp->t_flags & CTLECH) { if ((c7 <= 037 && c != '\t' && c != '\n') || c7 == 0177) { (void) ttyoutput('^', tp); if (c7 == 0177) c7 = '?'; else c7 += 'A' - 1; } } (void) ttyoutput(c7, tp); } /* * Reprint the rawq line. * We assume c_cc has already been checked. */ static void ttyretype(tp) register struct tty *tp; { register char *cp; int s; if (tp->t_rprntc != _POSIX_VDISABLE) ttyecho(tp->t_rprntc, tp); (void) ttyoutput('\n', tp); s = spltty(); for (cp = tp->t_canq.c_cf; cp; cp = nextc(&tp->t_canq, cp)) ttyecho(*cp, tp); for (cp = tp->t_rawq.c_cf; cp; cp = nextc(&tp->t_rawq, cp)) ttyecho(*cp, tp); tp->t_state &= ~TS_ERASE; splx(s); tp->t_rocount = tp->t_rawq.c_cc; tp->t_rocol = 0; } /* * Rubout one character from the rawq of tp * as cleanly as possible. */ static void ttyrub(c, tp) register int c; register struct tty *tp; { register char *cp; int savecol; int s; if ((tp->t_flags & ECHO) == 0) return; tp->t_flags &= ~FLUSHO; c &= 0377; if (tp->t_flags & CRTBS) { if (tp->t_rocount == 0) { /* * Screwed by ttwrite; retype */ ttyretype(tp); return; } /* * Out of the ENTIRE tty subsystem would believe this is the ONLY place * that the "9th" bit (quoted chars) is tested? */ if (c == ('\t' | 0200) || c == ('\n' | 0200)) ttyrubo (tp, 2); else switch (partab [c &= 0177] & 0177) { case ORDINARY: ttyrubo(tp, 1); break; case VTAB: case BACKSPACE: case CONTROL: case RETURN: if (tp->t_flags & CTLECH) ttyrubo(tp, 2); break; case TAB: if (tp->t_rocount < tp->t_rawq.c_cc) { ttyretype(tp); return; } s = spltty(); savecol = tp->t_col; tp->t_state |= TS_CNTTB; tp->t_flags |= FLUSHO; tp->t_col = tp->t_rocol; cp = tp->t_rawq.c_cf; for (; cp; cp = nextc (&tp->t_rawq, cp)) ttyecho(*cp, tp); tp->t_flags &= ~FLUSHO; tp->t_state &= ~TS_CNTTB; splx(s); /* * savecol will now be length of the tab */ savecol -= tp->t_col; tp->t_col += savecol; if (savecol > 8) savecol = 8; /* overflow screw */ while (--savecol >= 0) (void) ttyoutput('\b', tp); break; default: panic("ttyrub"); } } else if (tp->t_flags & PRTERA) { if ((tp->t_state & TS_ERASE) == 0) { (void) ttyoutput('\\', tp); tp->t_state |= TS_ERASE; } ttyecho(c, tp); } else ttyecho(tp->t_erase, tp); tp->t_rocount--; } /* * Is c a break char for tp? */ int ttbreakc (c, tp) register int c; register struct tty *tp; { return (c == '\n' || CCEQ (tp->t_eofc, c) || CCEQ (tp->t_brkc, c) || (c == '\r' && (tp->t_flags & CRMOD))); } /* * Place a character on raw TTY input queue, * putting in delimiters and waking up top * half as needed. Also echo if required. * The arguments are the character and the * appropriate tty structure. */ void ttyinput (c, tp) register int c; register struct tty *tp; { long t_flags = tp->t_flags; int i; /* * If input is pending take it first. */ if (t_flags & PENDIN) ttypend(tp); #ifdef UCB_METER tk_nin++; #endif c &= 0377; /* * In tandem mode, check high water mark. */ if (t_flags & (TANDEM | RTSCTS)) ttyblock(tp); if (t_flags & RAW) { /* * Raw mode, just put character * in input q w/o interpretation. */ if (tp->t_rawq.c_cc > TTYHOG) ttyflush(tp, FREAD | FWRITE); else { if (putc(c, &tp->t_rawq) == 0) ttwakeup (tp); ttyecho(c, tp); } goto endcase; } /* * Ignore any high bit added during * previous ttyinput processing. */ if ((tp->t_state & TS_TYPEN) == 0 && (t_flags & PASS8) == 0) c &= 0177; /* * Check for literal nexting very first. This is the _ONLY_ place * left which ORs in 0200. Handling literal nexting this way is * what keeps the tty subsystem from being 8 bit clean. The fix is * horrendous though and is put off for now. And to think that ALL * of this is made necessary by ttyrubout() - it's the only place that * actually _checks_ the 0200 bit and only for newline and tab chars * at that! * * If we had 9 bit bytes life would be a lot simpler ;) * * The basic idea is to flag the character as "special" and also * modify it so that the character does not match any of the special * editing or control characters. We could just as simply jump directly * to the test for 'cbreak' below. */ if (tp->t_state & TS_LNCH) { c |= 0200; tp->t_state &= ~TS_LNCH; } /* * Scan for special characters. This code * is really just a big case statement with * non-constant cases. The bottom of the * case statement is labeled ``endcase'', so goto * it after a case match, or similar. */ if (CCEQ(tp->t_lnextc, c)) { if (t_flags & ECHO) ttyout("^\b", tp); tp->t_state |= TS_LNCH; goto endcase; } if (CCEQ(tp->t_flushc, c)) { if (t_flags & FLUSHO) tp->t_flags &= ~FLUSHO; else { ttyflush(tp, FWRITE); ttyecho(c, tp); if (tp->t_rawq.c_cc + tp->t_canq.c_cc) ttyretype(tp); tp->t_flags |= FLUSHO; } goto startoutput; } if (CCEQ(tp->t_suspc, c)) { if ((t_flags & NOFLSH) == 0) ttyflush(tp, FREAD); ttyecho(c, tp); gsignal(tp->t_pgrp, SIGTSTP); goto endcase; } /* * Handle start/stop characters. */ if (CCEQ(tp->t_stopc, c)) { if ((tp->t_state & TS_TTSTOP) == 0) { tp->t_state |= TS_TTSTOP; (*cdevsw[major(tp->t_dev)].d_stop)(tp, 0); return; } if (CCEQ(tp->t_startc, c)) return; goto endcase; } if (CCEQ(tp->t_startc, c)) goto restartoutput; /* * Look for interrupt/quit chars. */ if (CCEQ(tp->t_intrc, c) || CCEQ(tp->t_quitc, c)) { if ((t_flags & NOFLSH) == 0) ttyflush(tp, FREAD|FWRITE); ttyecho(c, tp); gsignal(tp->t_pgrp, CCEQ(tp->t_intrc, c) ? SIGINT : SIGQUIT); goto endcase; } /* * Cbreak mode, don't process line editing * characters; check high water mark for wakeup. */ if (t_flags & CBREAK) { if (tp->t_rawq.c_cc > TTYHOG) { if (tp->t_outq.c_cc < TTHIWAT(tp)) (void) ttyoutput(CTRL('g'), tp); } else if (putc(c, &tp->t_rawq) == 0) { ttwakeup (tp); ttyecho (c, tp); } goto endcase; } /* * From here on down cooked mode character * processing takes place. */ if (CCEQ(tp->t_erase, c) || CCEQ(CTRL('h'), c)) { if (tp->t_rawq.c_cc) ttyrub(unputc(&tp->t_rawq), tp); goto endcase; } if (CCEQ(tp->t_kill, c)) { if (t_flags & CRTKIL && tp->t_rawq.c_cc == tp->t_rocount) { while (tp->t_rawq.c_cc) ttyrub(unputc(&tp->t_rawq), tp); } else { ttyecho(c, tp); ttyecho('\n', tp); while (getc(&tp->t_rawq) > 0) ; tp->t_rocount = 0; } tp->t_state &= ~TS_LOCAL; goto endcase; } /* * Check word erase/reprint line. */ if (CCEQ(tp->t_werasc, c)) { if (tp->t_rawq.c_cc == 0) goto endcase; do { c = unputc(&tp->t_rawq); if (c != ' ' && c != '\t') goto erasenb; ttyrub(c, tp); } while (tp->t_rawq.c_cc); goto endcase; erasenb: do { ttyrub(c, tp); if (tp->t_rawq.c_cc == 0) goto endcase; c = unputc(&tp->t_rawq); } while (c != ' ' && c != '\t'); (void) putc(c, &tp->t_rawq); goto endcase; } if (CCEQ(tp->t_rprntc, c)) { ttyretype(tp); goto endcase; } /* * Check for input buffer overflow */ if (tp->t_rawq.c_cc+tp->t_canq.c_cc >= TTYHOG) { (void) ttyoutput(CTRL('g'), tp); goto endcase; } /* * Put data char in q for user and * wakeup on seeing a line delimiter. */ if (putc(c, &tp->t_rawq) == 0) { if (ttbreakc (c, tp)) { tp->t_rocount = 0; catq(&tp->t_rawq, &tp->t_canq); ttwakeup (tp); } else if (tp->t_rocount++ == 0) tp->t_rocol = tp->t_col; if (tp->t_state & TS_ERASE) { tp->t_state &= ~TS_ERASE; (void) ttyoutput('/', tp); } i = tp->t_col; ttyecho(c, tp); if (CCEQ(tp->t_eofc, c) && t_flags & ECHO) { i = MIN(2, tp->t_col - i); while (i > 0) { (void) ttyoutput('\b', tp); i--; } } } endcase: /* * If DEC-style start/stop is enabled don't restart * output until seeing the start character. */ if (t_flags & DECCTQ && tp->t_state & TS_TTSTOP && tp->t_startc != tp->t_stopc) return; restartoutput: tp->t_state &= ~TS_TTSTOP; tp->t_flags &= ~FLUSHO; startoutput: ttstart(tp); } /* * Put character on TTY output queue, adding delays, * expanding tabs, and handling the CR/NL bit. * This is called both from the top half for output, * and from interrupt level for echoing. * The arguments are the character and the tty structure. * Returns < 0 if putc succeeds, otherwise returns char to resend */ int ttyoutput(c, tp) register int c; register struct tty *tp; { register int col; if (tp->t_flags & (RAW|LITOUT)) { if (tp->t_flags & FLUSHO) return (-1); if (putc(c, &tp->t_outq)) return(c); #ifdef UCB_METER tk_nout++; #endif return(-1); } c &= 0177; #ifdef whybother /* * Ignore EOT in normal mode to avoid * hanging up certain terminals. */ if (c == CEOT && (tp->t_flags & CBREAK) == 0) return(-1); #endif /* * Turn tabs to spaces as required */ if (c == '\t' && (tp->t_flags & XTABS)) { register int s; c = 8 - (tp->t_col&7); if ((tp->t_flags & FLUSHO) == 0) { s = spltty(); /* don't interrupt tabs */ c -= b_to_q(" ", c, &tp->t_outq); #ifdef UCB_METER tk_nout += c; #endif splx(s); } tp->t_col += c; return (c ? -1 : '\t'); } #ifdef UCB_METER tk_nout++; #endif /* * turn to if desired. */ if (c == '\n' && tp->t_flags & CRMOD) { if (putc('\r', &tp->t_outq)) return(c); #ifdef UCB_METER tk_nout++; #endif } if ((tp->t_flags & FLUSHO) == 0 && putc(c, &tp->t_outq)) return (c); col = tp->t_col; switch (partab[c] & 077) { case ORDINARY: col++; case CONTROL: break; case BACKSPACE: if (col) col--; break; case NEWLINE: case RETURN: col = 0; break; case TAB: col = (col | 07) + 1; break; } tp->t_col = col; return(-1); } /* * Called from device's read routine after it has * calculated the tty-structure given as argument. */ int ttread (tp, uio, flag) register struct tty *tp; struct uio *uio; int flag; { register struct clist *qp; register int c; long t_flags; int s, first, error = 0, carrier; loop: /* * Take any pending input first. */ s = spltty(); if (tp->t_flags & PENDIN) ttypend(tp); splx(s); /* * Hang process if it's in the background. */ if (tp == u.u_ttyp && u.u_procp->p_pgrp != tp->t_pgrp) { if ((u.u_procp->p_sigignore & sigmask(SIGTTIN)) || (u.u_procp->p_sigmask & sigmask(SIGTTIN)) || u.u_procp->p_flag & SVFORK) return (EIO); gsignal(u.u_procp->p_pgrp, SIGTTIN); sleep((caddr_t)&lbolt, TTIPRI); goto loop; } t_flags = tp->t_flags; /* * In raw mode take characters directly from the * raw queue w/o processing. Interlock against * device interrupts when interrogating rawq. */ if (t_flags & RAW) { s = spltty(); if (tp->t_rawq.c_cc <= 0) { carrier = ISSET(tp->t_state, TS_CARR_ON); if (!carrier && ISSET(tp->t_state, TS_ISOPEN)) { splx(s); return(0); /* EOF */ } if (flag & IO_NDELAY) { splx(s); return(EWOULDBLOCK); } sleep((caddr_t)&tp->t_rawq, TTIPRI); splx(s); goto loop; } splx(s); while (!error && tp->t_rawq.c_cc && uio->uio_resid) error = ureadc(getc(&tp->t_rawq), uio); goto checktandem; } /* * In cbreak mode use the rawq, otherwise * take characters from the canonicalized q. */ qp = t_flags & CBREAK ? &tp->t_rawq : &tp->t_canq; /* * No input, sleep on rawq awaiting hardware * receipt and notification. */ s = spltty(); if (qp->c_cc <= 0) { carrier = ISSET(tp->t_state, TS_CARR_ON); if (!carrier && ISSET(tp->t_state,TS_ISOPEN)) { splx(s); return(0); /* EOF */ } if (flag & IO_NDELAY) { splx(s); return(EWOULDBLOCK); } sleep((caddr_t)&tp->t_rawq, TTIPRI); splx(s); goto loop; } splx(s); /* * Input present, perform input mapping * and processing (we're not in raw mode). */ first = 1; while ((c = getc(qp)) >= 0) { if (t_flags & CRMOD && c == '\r') c = '\n'; /* * Check for delayed suspend character. */ if (CCEQ(tp->t_dsuspc, c)) { gsignal(tp->t_pgrp, SIGTSTP); if (first) { sleep((caddr_t)&lbolt, TTIPRI); goto loop; } break; } /* * Interpret EOF only in cooked mode. */ if (CCEQ(tp->t_eofc, c) && (t_flags & CBREAK) == 0) break; /* * Give user character. */ error = ureadc(t_flags & PASS8 ? c : c & 0177, uio); if (error) break; if (uio->uio_resid == 0) break; /* * In cooked mode check for a "break character" * marking the end of a "line of input". */ if ((t_flags & CBREAK) == 0 && ttbreakc (c, tp)) break; first = 0; } checktandem: /* * Look to unblock output now that (presumably) * the input queue has gone down. */ s = spltty(); if (ISSET(tp->t_state,TS_TBLOCK) && tp->t_rawq.c_cc < TTYUNBLOCK) ttyunblock(tp); splx(s); return(error); } /* * Check the output queue on tp for space for a kernel message * (from uprintf/tprintf). Allow some space over the normal * hiwater mark so we don't lose messages due to normal flow * control, but don't let the tty run amok. * Sleeps here are not interruptible, but we return prematurely * if new signals come in. */ int ttycheckoutq (tp, wait) register struct tty *tp; int wait; { int hiwat, s, oldsig; hiwat = TTHIWAT(tp); s = spltty(); oldsig = u.u_procp->p_sig; if (tp->t_outq.c_cc > hiwat + 200) while (tp->t_outq.c_cc > hiwat) { ttstart(tp); if (wait == 0 || u.u_procp->p_sig != oldsig) { splx(s); return(0); } timeout (wakeup, (caddr_t)&tp->t_outq, hz); tp->t_state |= TS_ASLEEP; sleep ((caddr_t) &tp->t_outq, PZERO - 1); } splx(s); return(1); } /* * Scan through str up to (but not including str[size]) stopping when a * character who's entry in table has mask bits set. Return number of * characters left in str. */ static int scanc (size, str) unsigned size; const char *str; { if (size == 0 || str == 0) return 0; do { if (partab [(u_char) *str++] & 077) return size; } while (--size > 0); return 0; } /* * Called from the device's write routine after it has * calculated the tty-structure given as argument. */ int ttwrite (tp, uio, flag) register struct tty *tp; register struct uio *uio; int flag; { char *cp; register int cc, ce; int i, hiwat, cnt, error, s; char obuf[OBUFSIZ]; hiwat = TTHIWAT(tp); cnt = uio->uio_resid; error = 0; cc = 0; cp = 0; loop: s = spltty(); if (! (tp->t_state & TS_CARR_ON)) { if (tp->t_state & TS_ISOPEN) { splx(s); return(EIO); } else if (flag & IO_NDELAY) { splx(s); error = EWOULDBLOCK; goto out; } else { /* Sleep awaiting carrier. */ sleep((caddr_t)&tp->t_rawq, TTIPRI); splx(s); goto loop; } } splx(s); /* * Hang the process if it's in the background. */ if (u.u_procp->p_pgrp != tp->t_pgrp && tp == u.u_ttyp && (tp->t_flags & TOSTOP) && (u.u_procp->p_flag & SVFORK)==0 && ! (u.u_procp->p_sigignore & sigmask(SIGTTOU)) && ! (u.u_procp->p_sigmask & sigmask(SIGTTOU))) { gsignal(u.u_procp->p_pgrp, SIGTTOU); sleep((caddr_t)&lbolt, TTIPRI); goto loop; } /* * Process the user's data in at most OBUFSIZ * chunks. Perform lower case simulation and * similar hacks. Keep track of high water * mark, sleep on overflow awaiting device aid * in acquiring new space. */ while (uio->uio_resid || cc > 0) { if (tp->t_flags & FLUSHO) { uio->uio_resid = 0; return(0); } if (tp->t_outq.c_cc > hiwat) goto ovhiwat; /* * Grab a hunk of data from the user, unless we have some * leftover from last time. */ if (cc == 0) { cc = MIN(uio->uio_resid, OBUFSIZ); cp = obuf; error = uiomove(cp, cc, uio); if (error) { cc = 0; break; } } /* * If nothing fancy need be done, grab those characters we * can handle without any of ttyoutput's processing and * just transfer them to the output q. For those chars * which require special processing (as indicated by the * bits in partab), call ttyoutput. After processing * a hunk of data, look for FLUSHO so ^O's will take effect * immediately. */ while (cc > 0) { if (tp->t_flags & (RAW|LITOUT)) ce = cc; else { ce = cc - scanc((unsigned)cc, (caddr_t)cp); /* * If ce is zero, then we're processing * a special character through ttyoutput. */ if (ce == 0) { tp->t_rocount = 0; if (ttyoutput(*cp, tp) >= 0) { overflow: /* out of c-lists */ s = spltty(); ttstart(tp); if (flag & IO_NDELAY) { splx(s); uio->uio_resid += cc; return (uio->uio_resid == cnt ? EWOULDBLOCK : 0); } tp->t_state |= TS_ASLEEP; sleep((caddr_t)&tp->t_outq, TTOPRI); splx(s); goto loop; } cp++, cc--; if (tp->t_flags & FLUSHO || tp->t_outq.c_cc > hiwat) goto ovhiwat; continue; } } /* * A bunch of normal characters have been found, * transfer them en masse to the output queue and * continue processing at the top of the loop. * If there are any further characters in this * <= OBUFSIZ chunk, the first should be a character * requiring special handling by ttyoutput. */ tp->t_rocount = 0; i = b_to_q(cp, ce, &tp->t_outq); ce -= i; tp->t_col += ce; cp += ce, cc -= ce; #ifdef UCB_METER tk_nout += ce; #endif if (i > 0) { /* out of c-lists */ goto overflow; } if (tp->t_flags & FLUSHO || tp->t_outq.c_cc > hiwat) break; } /* while (cc > 0) */ ttstart(tp); } /* while (uio->uio_resid || cc > 0) */ out: /* * If cc is nonzero, we leave the uio structure inconsistent, as the * offset and iov pointers have moved forward, but it doesn't matter * (the call will either return short or restart with a new uio). */ uio->uio_resid += cc; return (error); ovhiwat: s = spltty(); /* * This can only occur if FLUSHO is also set in t_flags, * or if ttstart/oproc is synchronous (or very fast). */ if (tp->t_outq.c_cc <= hiwat) { splx(s); goto loop; } ttstart(tp); if (flag & IO_NDELAY) { splx(s); uio->uio_resid += cc; return (uio->uio_resid == cnt ? EWOULDBLOCK : 0); } tp->t_state |= TS_ASLEEP; sleep((caddr_t)&tp->t_outq, TTOPRI); splx(s); goto loop; } void ttwakeup (tp) register struct tty *tp; { if (tp->t_rsel) { selwakeup (tp->t_rsel, tp->t_state & TS_RCOLL); tp->t_state &= ~TS_RCOLL; tp->t_rsel = 0; } if (tp->t_state & TS_ASYNC) gsignal (tp->t_pgrp, SIGIO); wakeup ((caddr_t) &tp->t_rawq); } ================================================ FILE: sys/kern/tty_pty.c ================================================ /* * Pseudo-teletype Driver * (Actually two drivers, requiring two entries in 'cdevsw') * * Copyright (c) 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include #ifdef PTY_ENABLED #include #include #include #include #include #include #include #include #include #include #include #include #include const struct devspec ptsdevs[] = { { 0, "ttyp0" }, { 1, "ttyp1" }, { 2, "ttyp2" }, { 3, "ttyp3" }, { 0, 0 } }; const struct devspec ptcdevs[] = { { 0, "ptyp0" }, { 1, "ptyp1" }, { 2, "ptyp2" }, { 3, "ptyp3" }, { 0, 0 } }; extern int TTYHOG; /* see tty.c */ #define BUFSIZ 100 /* Chunk size iomoved to/from user */ /* * pts == /dev/tty[pqrs]? * ptc == /dev/pty[pqrs]? */ struct tty pt_tty[PTY_NUNITS]; struct pt_ioctl { int pt_flags; struct proc *pt_selr, *pt_selw; u_char pt_send; u_char pt_ucntl; } pt_ioctl[PTY_NUNITS]; int npty = PTY_NUNITS; /* for pstat -t */ #define PF_RCOLL 0x01 #define PF_WCOLL 0x02 #define PF_PKT 0x08 /* packet mode */ #define PF_STOPPED 0x10 /* user told stopped */ #define PF_REMOTE 0x20 /* remote and flow controlled input */ #define PF_NOSTOP 0x40 #define PF_UCNTL 0x80 /* user control mode */ /*ARGSUSED*/ int ptsopen(dev_t dev, int flag, int mode) { register struct tty *tp; int error; #ifdef lint npty = npty; #endif if (minor(dev) >= PTY_NUNITS) return (ENXIO); tp = &pt_tty[minor(dev)]; if ((tp->t_state & TS_ISOPEN) == 0) { ttychars(tp); /* Set up default chars */ tp->t_ispeed = tp->t_ospeed = B115200; tp->t_flags = 0; /* No features (nor raw mode) */ } else if (tp->t_state&TS_XCLUDE && u.u_uid != 0) return (EBUSY); if (tp->t_oproc) /* Ctrlr still around. */ tp->t_state |= TS_CARR_ON; while ((tp->t_state & TS_CARR_ON) == 0) { tp->t_state |= TS_WOPEN; sleep((caddr_t)&tp->t_rawq, TTIPRI); } error = ttyopen(dev, tp); ptcwakeup (tp, FREAD | FWRITE); return (error); } int ptsclose(dev_t dev, int flag, int mode) { register struct tty *tp; tp = &pt_tty[minor(dev)]; ttyclose(tp); ptcwakeup(tp, FREAD|FWRITE); return 0; } int ptsread(dev_t dev, register struct uio *uio, int flag) { register struct tty *tp = &pt_tty[minor(dev)]; register struct pt_ioctl *pti = &pt_ioctl[minor(dev)]; int error = 0; again: if (pti->pt_flags & PF_REMOTE) { while (tp == u.u_ttyp && u.u_procp->p_pgrp != tp->t_pgrp) { if ((u.u_procp->p_sigignore & sigmask(SIGTTIN)) || (u.u_procp->p_sigmask & sigmask(SIGTTIN)) || u.u_procp->p_flag&SVFORK) return (EIO); gsignal(u.u_procp->p_pgrp, SIGTTIN); sleep((caddr_t)&lbolt, TTIPRI); } if (tp->t_canq.c_cc == 0) { if (flag & IO_NDELAY) return (EWOULDBLOCK); sleep((caddr_t)&tp->t_canq, TTIPRI); goto again; } while (tp->t_canq.c_cc > 1 && uio->uio_resid) if (ureadc(getc(&tp->t_canq), uio) < 0) { error = EFAULT; break; } if (tp->t_canq.c_cc == 1) (void) getc(&tp->t_canq); if (tp->t_canq.c_cc) return (error); } else if (tp->t_oproc) error = ttread(tp, uio, flag); ptcwakeup(tp, FWRITE); return (error); } /* * Write to pseudo-tty. * Wakeups of controlling tty will happen * indirectly, when tty driver calls ptsstart. */ int ptswrite(dev_t dev, register struct uio *uio, int flag) { register struct tty *tp; tp = &pt_tty[minor(dev)]; if (tp->t_oproc == 0) return (EIO); return ttwrite(tp, uio, flag); } /* * Start output on pseudo-tty. * Wake up process selecting or sleeping for input from controlling tty. */ void ptsstart(struct tty *tp) { register struct pt_ioctl *pti = &pt_ioctl[minor(tp->t_dev)]; if (tp->t_state & TS_TTSTOP) return; if (pti->pt_flags & PF_STOPPED) { pti->pt_flags &= ~PF_STOPPED; pti->pt_send = TIOCPKT_START; } ptcwakeup(tp, FREAD); } void ptcwakeup(struct tty *tp, int flag) { struct pt_ioctl *pti = &pt_ioctl[minor(tp->t_dev)]; if (flag & FREAD) { if (pti->pt_selr) { selwakeup(pti->pt_selr, (long)(pti->pt_flags & PF_RCOLL)); pti->pt_selr = 0; pti->pt_flags &= ~PF_RCOLL; } wakeup((caddr_t)&tp->t_outq.c_cf); } if (flag & FWRITE) { if (pti->pt_selw) { selwakeup(pti->pt_selw, (long)(pti->pt_flags & PF_WCOLL)); pti->pt_selw = 0; pti->pt_flags &= ~PF_WCOLL; } wakeup((caddr_t)&tp->t_rawq.c_cf); } } /*ARGSUSED*/ int ptcopen(dev_t dev, int flag, int mode) { register struct tty *tp; struct pt_ioctl *pti; if (minor(dev) >= PTY_NUNITS) return (ENXIO); tp = &pt_tty[minor(dev)]; if (tp->t_oproc) return (EIO); tp->t_oproc = ptsstart; ttymodem(tp, 1); pti = &pt_ioctl[minor(dev)]; pti->pt_flags = 0; pti->pt_send = 0; pti->pt_ucntl = 0; return (0); } int ptcclose(dev_t dev, int flag, int mode) { register struct tty *tp; tp = &pt_tty[minor(dev)]; ttymodem(tp, 0); tp->t_state &= ~TS_CARR_ON; tp->t_oproc = 0; /* mark closed */ return 0; } int ptcread(dev_t dev, register struct uio *uio, int flag) { register struct tty *tp = &pt_tty[minor(dev)]; struct pt_ioctl *pti = &pt_ioctl[minor(dev)]; char buf[BUFSIZ]; int error = 0, cc; /* * We want to block until the slave * is open, and there's something to read; * but if we lost the slave or we're NBIO, * then return the appropriate error instead. */ for (;;) { if (tp->t_state&TS_ISOPEN) { if (pti->pt_flags&PF_PKT && pti->pt_send) { error = ureadc((int)pti->pt_send, uio); if (error) return (error); pti->pt_send = 0; return (0); } if (pti->pt_flags&PF_UCNTL && pti->pt_ucntl) { error = ureadc((int)pti->pt_ucntl, uio); if (error) return (error); pti->pt_ucntl = 0; return (0); } if (tp->t_outq.c_cc && (tp->t_state&TS_TTSTOP) == 0) break; } if ((tp->t_state&TS_CARR_ON) == 0) return (0); /* EOF */ if (flag & IO_NDELAY) return (EWOULDBLOCK); sleep((caddr_t)&tp->t_outq.c_cf, TTIPRI); } if (pti->pt_flags & (PF_PKT|PF_UCNTL)) error = ureadc(0, uio); while (uio->uio_resid && error == 0) { cc = q_to_b(&tp->t_outq, buf, MIN(uio->uio_resid, BUFSIZ)); if (cc <= 0) break; error = uiomove(buf, cc, uio); } if (tp->t_outq.c_cc <= TTLOWAT(tp)) { if (tp->t_state&TS_ASLEEP) { tp->t_state &= ~TS_ASLEEP; wakeup((caddr_t)&tp->t_outq); } if (tp->t_wsel) { selwakeup(tp->t_wsel, tp->t_state & TS_WCOLL); tp->t_wsel = 0; tp->t_state &= ~TS_WCOLL; } } return (error); } void ptsstop(register struct tty *tp, int flush) { struct pt_ioctl *pti = &pt_ioctl[minor(tp->t_dev)]; int flag; /* note: FLUSHREAD and FLUSHWRITE already ok */ if (flush == 0) { flush = TIOCPKT_STOP; pti->pt_flags |= PF_STOPPED; } else pti->pt_flags &= ~PF_STOPPED; pti->pt_send |= flush; /* change of perspective */ flag = 0; if (flush & FREAD) flag |= FWRITE; if (flush & FWRITE) flag |= FREAD; ptcwakeup(tp, flag); } int ptcselect(dev_t dev, int rw) { register struct tty *tp = &pt_tty[minor(dev)]; struct pt_ioctl *pti = &pt_ioctl[minor(dev)]; struct proc *p; int s; if ((tp->t_state&TS_CARR_ON) == 0) return (1); switch (rw) { case FREAD: /* * Need to block timeouts (ttrstart). */ s = spltty(); if ((tp->t_state&TS_ISOPEN) && tp->t_outq.c_cc && (tp->t_state&TS_TTSTOP) == 0) { splx(s); return (1); } splx(s); /* FALLTHROUGH */ case 0: /* exceptional */ if ((tp->t_state&TS_ISOPEN) && ((pti->pt_flags&PF_PKT && pti->pt_send) || (pti->pt_flags&PF_UCNTL && pti->pt_ucntl))) return (1); if ((p = pti->pt_selr) && p->p_wchan == (caddr_t)&selwait) pti->pt_flags |= PF_RCOLL; else pti->pt_selr = u.u_procp; break; case FWRITE: if (tp->t_state&TS_ISOPEN) { if (pti->pt_flags & PF_REMOTE) { if (tp->t_canq.c_cc == 0) return (1); } else { if (tp->t_rawq.c_cc + tp->t_canq.c_cc < TTYHOG-2) return (1); if (tp->t_canq.c_cc == 0 && (tp->t_flags & (RAW|CBREAK)) == 0) return (1); } } if ((p = pti->pt_selw) && p->p_wchan == (caddr_t)&selwait) pti->pt_flags |= PF_WCOLL; else pti->pt_selw = u.u_procp; break; } return (0); } int ptcwrite(dev_t dev, register struct uio *uio, int flag) { register struct tty *tp = &pt_tty[minor(dev)]; register char *cp = NULL; register int cc = 0; char locbuf[BUFSIZ]; int cnt = 0; struct pt_ioctl *pti = &pt_ioctl[minor(dev)]; int error = 0; again: if ((tp->t_state&TS_ISOPEN) == 0) goto block; if (pti->pt_flags & PF_REMOTE) { if (tp->t_canq.c_cc) goto block; while (uio->uio_resid && tp->t_canq.c_cc < TTYHOG - 1) { if (cc == 0) { cc = MIN(uio->uio_resid, BUFSIZ); cc = MIN(cc, TTYHOG - 1 - tp->t_canq.c_cc); cp = locbuf; error = uiomove(cp, cc, uio); if (error) return (error); /* check again for safety */ if ((tp->t_state&TS_ISOPEN) == 0) return (EIO); } if (cc) (void) b_to_q(cp, cc, &tp->t_canq); cc = 0; } (void) putc(0, &tp->t_canq); ttwakeup(tp); wakeup((caddr_t)&tp->t_canq); return (0); } while (uio->uio_resid > 0) { if (cc == 0) { cc = MIN(uio->uio_resid, BUFSIZ); cp = locbuf; error = uiomove(cp, cc, uio); if (error) return (error); /* check again for safety */ if ((tp->t_state&TS_ISOPEN) == 0) return (EIO); } while (cc > 0) { if ((tp->t_rawq.c_cc + tp->t_canq.c_cc) >= TTYHOG - 2 && (tp->t_canq.c_cc > 0 || tp->t_flags & (RAW|CBREAK))) { wakeup((caddr_t)&tp->t_rawq); goto block; } ttyinput(*cp++, tp); cnt++; cc--; } cc = 0; } return (0); block: /* * Come here to wait for slave to open, for space * in outq, or space in rawq. */ if ((tp->t_state&TS_CARR_ON) == 0) return (EIO); if (flag & IO_NDELAY) { /* adjust for data copied in but not written */ uio->uio_resid += cc; if (cnt == 0) return (EWOULDBLOCK); return (0); } sleep((caddr_t)&tp->t_rawq.c_cf, TTOPRI); goto again; } int ptyioctl(dev_t dev, u_int cmd, caddr_t data, int flag) { register struct tty *tp = &pt_tty[minor(dev)]; register struct pt_ioctl *pti = &pt_ioctl[minor(dev)]; int stop, error; /* * IF CONTROLLER STTY THEN MUST FLUSH TO PREVENT A HANG. * ttywflush(tp) will hang if there are characters in the outq. */ if (cdevsw[major(dev)].d_open == ptcopen) switch (cmd) { case TIOCPKT: if (*(int *)data) { if (pti->pt_flags & PF_UCNTL) return (EINVAL); pti->pt_flags |= PF_PKT; } else pti->pt_flags &= ~PF_PKT; return (0); case TIOCUCNTL: if (*(int *)data) { if (pti->pt_flags & PF_PKT) return (EINVAL); pti->pt_flags |= PF_UCNTL; } else pti->pt_flags &= ~PF_UCNTL; return (0); case TIOCREMOTE: if (*(int *)data) pti->pt_flags |= PF_REMOTE; else pti->pt_flags &= ~PF_REMOTE; ttyflush(tp, FREAD|FWRITE); return (0); case TIOCSETP: case TIOCSETN: case TIOCSETD: while (getc(&tp->t_outq) >= 0) ; break; } error = ttioctl (tp, cmd, data, flag); if (error < 0) { if (pti->pt_flags & PF_UCNTL && (cmd & ~0xff) == UIOCCMD(0)) { if (cmd & 0xff) { pti->pt_ucntl = (u_char)cmd; ptcwakeup(tp, FREAD); } return (0); } error = ENOTTY; } stop = (tp->t_flags & RAW) == 0 && tp->t_stopc == CTRL('s') && tp->t_startc == CTRL('q'); if (pti->pt_flags & PF_NOSTOP) { if (stop) { pti->pt_send &= ~TIOCPKT_NOSTOP; pti->pt_send |= TIOCPKT_DOSTOP; pti->pt_flags &= ~PF_NOSTOP; ptcwakeup(tp, FREAD); } } else { if (!stop) { pti->pt_send &= ~TIOCPKT_DOSTOP; pti->pt_send |= TIOCPKT_NOSTOP; pti->pt_flags |= PF_NOSTOP; ptcwakeup(tp, FREAD); } } return (error); } void ptyattach() { printf("pty: %d units\n", PTY_NUNITS); } #endif ================================================ FILE: sys/kern/tty_subr.c ================================================ /* * Copyright (c) 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include #include #include #include #include char cwaiting; /* * Character list get/put */ int getc(p) register struct clist *p; { register struct cblock *bp; register int c, s; s = spltty(); if (p->c_cc <= 0) { c = -1; p->c_cc = 0; p->c_cf = p->c_cl = NULL; } else { c = *p->c_cf++ & 0377; if (--p->c_cc<=0) { bp = (struct cblock *)(p->c_cf-1); bp = (struct cblock *)((int)bp & ~CROUND); p->c_cf = NULL; p->c_cl = NULL; bp->c_next = cfreelist; cfreelist = bp; cfreecount += CBSIZE; if (cwaiting) { wakeup (&cwaiting); cwaiting = 0; } } else if (((int)p->c_cf & CROUND) == 0){ bp = (struct cblock *)(p->c_cf); bp--; p->c_cf = bp->c_next->c_info; bp->c_next = cfreelist; cfreelist = bp; cfreecount += CBSIZE; if (cwaiting) { wakeup (&cwaiting); cwaiting = 0; } } } splx(s); return (c); } /* * Copy clist to buffer. * Return number of bytes moved. */ int q_to_b (q, cp, cc) register struct clist *q; char *cp; int cc; { register struct cblock *bp; register int nc; int s; char *acp; if (cc <= 0) return (0); s = spltty(); if (q->c_cc <= 0) { q->c_cc = 0; q->c_cf = q->c_cl = NULL; splx(s); return (0); } acp = cp; while (cc) { nc = sizeof (struct cblock) - ((int)q->c_cf & CROUND); nc = MIN(nc, cc); nc = MIN(nc, q->c_cc); (void) bcopy(q->c_cf, cp, (unsigned)nc); q->c_cf += nc; q->c_cc -= nc; cc -= nc; cp += nc; if (q->c_cc <= 0) { bp = (struct cblock *)(q->c_cf - 1); bp = (struct cblock *)((int)bp & ~CROUND); q->c_cf = q->c_cl = NULL; bp->c_next = cfreelist; cfreelist = bp; cfreecount += CBSIZE; if (cwaiting) { wakeup (&cwaiting); cwaiting = 0; } break; } if (((int)q->c_cf & CROUND) == 0) { bp = (struct cblock *)(q->c_cf); bp--; q->c_cf = bp->c_next->c_info; bp->c_next = cfreelist; cfreelist = bp; cfreecount += CBSIZE; if (cwaiting) { wakeup (&cwaiting); cwaiting = 0; } } } splx(s); return (cp - acp); } /* * Return count of contiguous characters * in clist starting at q->c_cf. * Stop counting if flag&character is non-null. */ int ndqb (q, flag) register struct clist *q; int flag; { int cc; int s; s = spltty(); if (q->c_cc <= 0) { cc = -q->c_cc; goto out; } cc = ((int)q->c_cf + CBSIZE) & ~CROUND; cc -= (int)q->c_cf; if (q->c_cc < cc) cc = q->c_cc; if (flag) { register char *p, *end; p = q->c_cf; end = p; end += cc; while (p < end) { if (*p & flag) { cc = (int)p; cc -= (int)q->c_cf; break; } p++; } } out: splx(s); return (cc); } /* * Flush cc bytes from q. */ void ndflush (q, cc) register struct clist *q; register int cc; { register struct cblock *bp; char *end; int rem, s; s = spltty(); if (q->c_cc <= 0) goto out; while (cc>0 && q->c_cc) { bp = (struct cblock *)((int)q->c_cf & ~CROUND); if ((int)bp == (((int)q->c_cl-1) & ~CROUND)) { end = q->c_cl; } else { end = (char *)((int)bp + sizeof (struct cblock)); } rem = end - q->c_cf; if (cc >= rem) { cc -= rem; q->c_cc -= rem; q->c_cf = bp->c_next->c_info; bp->c_next = cfreelist; cfreelist = bp; cfreecount += CBSIZE; if (cwaiting) { wakeup (&cwaiting); cwaiting = 0; } } else { q->c_cc -= cc; q->c_cf += cc; if (q->c_cc <= 0) { bp->c_next = cfreelist; cfreelist = bp; cfreecount += CBSIZE; if (cwaiting) { wakeup (&cwaiting); cwaiting = 0; } } break; } } if (q->c_cc <= 0) { q->c_cf = q->c_cl = NULL; q->c_cc = 0; } out: splx(s); } /* * Put a symbol to a character list. */ int putc (c, p) int c; register struct clist *p; { register struct cblock *bp; register char *cp; register int s; s = spltty(); if ((cp = p->c_cl) == NULL || p->c_cc < 0 ) { if ((bp = cfreelist) == NULL) { splx(s); return (-1); } cfreelist = bp->c_next; cfreecount -= CBSIZE; bp->c_next = NULL; p->c_cf = cp = bp->c_info; } else if (((int)cp & CROUND) == 0) { bp = (struct cblock *)cp - 1; if ((bp->c_next = cfreelist) == NULL) { splx(s); return (-1); } bp = bp->c_next; cfreelist = bp->c_next; cfreecount -= CBSIZE; bp->c_next = NULL; cp = bp->c_info; } *cp++ = c; p->c_cc++; p->c_cl = cp; splx(s); return (0); } /* * Copy buffer to clist. * Return number of bytes not transfered. */ int b_to_q (cp, cc, q) register char *cp; struct clist *q; register int cc; { register char *cq; register struct cblock *bp; register int s, nc; int acc; if (cc <= 0) return (0); acc = cc; s = spltty(); if ((cq = q->c_cl) == NULL || q->c_cc < 0) { if ((bp = cfreelist) == NULL) goto out; cfreelist = bp->c_next; cfreecount -= CBSIZE; bp->c_next = NULL; q->c_cf = cq = bp->c_info; } while (cc) { if (((int)cq & CROUND) == 0) { bp = (struct cblock *)cq - 1; if ((bp->c_next = cfreelist) == NULL) goto out; bp = bp->c_next; cfreelist = bp->c_next; cfreecount -= CBSIZE; bp->c_next = NULL; cq = bp->c_info; } nc = MIN(cc, sizeof (struct cblock) - ((int)cq & CROUND)); (void) bcopy(cp, cq, (unsigned)nc); cp += nc; cq += nc; cc -= nc; } out: q->c_cl = cq; q->c_cc += acc - cc; splx(s); return (cc); } /* * Given a non-NULL pointter into the list (like c_cf which * always points to a real character if non-NULL) return the pointer * to the next character in the list or return NULL if no more chars. * * Callers must not allow getc's to happen between nextc's so that the * pointer becomes invalid. Note that interrupts are NOT masked. */ char * nextc (p, cp) register struct clist *p; register char *cp; { register char *rcp; if (p->c_cc && ++cp != p->c_cl) { if (((int)cp & CROUND) == 0) rcp = ((struct cblock *)cp)[-1].c_next->c_info; else rcp = cp; } else rcp = (char *)NULL; return (rcp); } /* * Remove the last character in the list and return it. */ int unputc (p) register struct clist *p; { register struct cblock *bp; register int c, s; struct cblock *obp; s = spltty(); if (p->c_cc <= 0) c = -1; else { c = *--p->c_cl; if (--p->c_cc <= 0) { bp = (struct cblock *)p->c_cl; bp = (struct cblock *)((int)bp & ~CROUND); p->c_cl = p->c_cf = NULL; bp->c_next = cfreelist; cfreelist = bp; cfreecount += CBSIZE; } else if (((int)p->c_cl & CROUND) == sizeof(bp->c_next)) { p->c_cl = (char *)((int)p->c_cl & ~CROUND); bp = (struct cblock *)p->c_cf; bp = (struct cblock *)((int)bp & ~CROUND); while (bp->c_next != (struct cblock *)p->c_cl) bp = bp->c_next; obp = bp; p->c_cl = (char *)(bp + 1); bp = bp->c_next; bp->c_next = cfreelist; cfreelist = bp; cfreecount += CBSIZE; obp->c_next = NULL; } } splx(s); return (c); } /* * Put the chars in the from que * on the end of the to que. */ void catq (from, to) register struct clist *from, *to; { char bbuf [CBSIZE*4]; register int c; int s; s = spltty(); if (to->c_cc == 0) { *to = *from; from->c_cc = 0; from->c_cf = NULL; from->c_cl = NULL; splx(s); return; } splx(s); while (from->c_cc > 0) { c = q_to_b(from, bbuf, sizeof bbuf); (void) b_to_q(bbuf, c, to); } } ================================================ FILE: sys/kern/tty_tty.c ================================================ /* * Copyright (c) 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * * @(#)tty_tty.c 1.2 (2.11BSD GTE) 11/29/94 */ /* * Indirect driver for controlling tty. * */ #include #include #include #include #include #include /*ARGSUSED*/ int syopen (dev, flag) dev_t dev; int flag; { if (u.u_ttyp == NULL) return (ENXIO); return((*cdevsw[major(u.u_ttyd)].d_open)(u.u_ttyd, flag, 0)); } /*ARGSUSED*/ int syread (dev, uio, flag) dev_t dev; struct uio *uio; int flag; { if (u.u_ttyp == NULL) return (ENXIO); return ((*cdevsw[major(u.u_ttyd)].d_read)(u.u_ttyd, uio, flag)); } /*ARGSUSED*/ int sywrite (dev, uio, flag) dev_t dev; struct uio *uio; int flag; { if (u.u_ttyp == NULL) return (ENXIO); return ((*cdevsw[major(u.u_ttyd)].d_write)(u.u_ttyd, uio, flag)); } /*ARGSUSED*/ int syioctl (dev, cmd, addr, flag) dev_t dev; u_int cmd; caddr_t addr; int flag; { if (cmd == TIOCNOTTY) { u.u_ttyp = 0; u.u_ttyd = 0; u.u_procp->p_pgrp = 0; return (0); } if (u.u_ttyp == NULL) return (ENXIO); return ((*cdevsw[major(u.u_ttyd)].d_ioctl)(u.u_ttyd, cmd, addr, flag)); } /*ARGSUSED*/ int syselect (dev, flag) dev_t dev; int flag; { if (u.u_ttyp == NULL) { u.u_error = ENXIO; return (0); } return ((*cdevsw[major(u.u_ttyd)].d_select)(u.u_ttyd, flag)); } ================================================ FILE: sys/kern/ufs_alloc.c ================================================ /* * Copyright (c) 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include #include #include #include #include #include #include #include #include #include typedef struct fblk *FBLKP; /* * Allocate a block in the file system. * * alloc will obtain the next available free disk block from the * free list of the specified device. The super block has up to * NICFREE remembered free blocks; the last of these is read to * obtain NICFREE more... */ struct buf * balloc(ip, flags) struct inode *ip; int flags; { register struct fs *fs; register struct buf *bp; int async; daddr_t bno; fs = ip->i_fs; async = fs->fs_flags & MNT_ASYNC; while (fs->fs_flock) sleep((caddr_t)&fs->fs_flock, PINOD); do { if (fs->fs_nfree <= 0) goto nospace; if (fs->fs_nfree > NICFREE) { fserr (fs, "bad free count"); goto nospace; } bno = fs->fs_free[--fs->fs_nfree]; if (bno == 0) goto nospace; } while (badblock(fs, bno)); if (fs->fs_nfree <= 0) { fs->fs_flock++; bp = bread(ip->i_dev, bno); if (((bp->b_flags&B_ERROR) == 0) && (bp->b_resid==0)) { register struct fblk *fbp; fbp = (FBLKP) bp->b_addr; *((FBLKP)&fs->fs_nfree) = *fbp; } brelse(bp); /* * Write the superblock back, synchronously if requested, * so that the free list pointer won't point at garbage. * We can still end up with dups in free if we then * use some of the blocks in this freeblock, then crash * without a sync. */ bp = getblk(ip->i_dev, SUPERB); fs->fs_fmod = 0; fs->fs_time = time.tv_sec; { register struct fs *fps; fps = (struct fs*) bp->b_addr; *fps = *fs; } if (!async) bwrite(bp); else bdwrite(bp); fs->fs_flock = 0; wakeup((caddr_t)&fs->fs_flock); if (fs->fs_nfree <=0) goto nospace; } bp = getblk(ip->i_dev, bno); bp->b_resid = 0; if (flags & B_CLRBUF) bzero (bp->b_addr, MAXBSIZE); fs->fs_fmod = 1; fs->fs_tfree--; return(bp); nospace: fs->fs_nfree = 0; fs->fs_tfree = 0; fserr (fs, "file system full"); /* * THIS IS A KLUDGE... * SHOULD RATHER SEND A SIGNAL AND SUSPEND THE PROCESS IN A * STATE FROM WHICH THE SYSTEM CALL WILL RESTART */ uprintf("\n%s: write failed, file system full\n", fs->fs_fsmnt); { register int i; for (i = 0; i < 5; i++) sleep((caddr_t)&lbolt, PRIBIO); } u.u_error = ENOSPC; return(NULL); } /* * Allocate an inode in the file system. * * Allocate an unused I node on the specified device. Used with file * creation. The algorithm keeps up to NICINOD spare I nodes in the * super block. When this runs out, a linear search through the I list * is instituted to pick up NICINOD more. */ struct inode * ialloc (pip) struct inode *pip; { register struct fs *fs; register struct buf *bp; register struct inode *ip; int i; struct dinode *dp; ino_t ino; daddr_t adr; ino_t inobas; int first; struct inode *ifind(); char *emsg = "no inodes free"; fs = pip->i_fs; while (fs->fs_ilock) sleep((caddr_t)&fs->fs_ilock, PINOD); loop: if (fs->fs_ninode > 0) { ino = fs->fs_inode[--fs->fs_ninode]; if (ino <= ROOTINO) goto loop; ip = iget(pip->i_dev, fs, ino); if (ip == NULL) return(NULL); if (ip->i_mode == 0) { bzero((caddr_t)ip->i_addr,sizeof(ip->i_addr)); ip->i_flags = 0; fs->fs_fmod = 1; fs->fs_tinode--; return(ip); } /* * Inode was allocated after all. * Look some more. */ iput(ip); goto loop; } fs->fs_ilock++; if (fs->fs_nbehind < 4 * NICINOD) { first = 1; ino = fs->fs_lasti; #ifdef DIAGNOSTIC if (itoo(ino)) panic("ialloc"); #endif adr = itod(ino); } else { fromtop: first = 0; ino = 1; adr = SUPERB+1; fs->fs_nbehind = 0; } inobas = 0; for (; adr < fs->fs_isize; adr++) { inobas = ino; bp = bread(pip->i_dev, adr); if ((bp->b_flags & B_ERROR) || bp->b_resid) { brelse(bp); ino += INOPB; continue; } dp = (struct dinode*) bp->b_addr; for (i = 0;i < INOPB;i++) { if (dp->di_mode != 0) goto cont; if (ifind(pip->i_dev, ino)) goto cont; fs->fs_inode[fs->fs_ninode++] = ino; if (fs->fs_ninode >= NICINOD) break; cont: ino++; dp++; } brelse(bp); if (fs->fs_ninode >= NICINOD) break; } if (fs->fs_ninode < NICINOD && first) goto fromtop; fs->fs_lasti = inobas; fs->fs_ilock = 0; wakeup((caddr_t)&fs->fs_ilock); if (fs->fs_ninode > 0) goto loop; fserr (fs, emsg); uprintf("\n%s: %s\n", fs->fs_fsmnt, emsg); u.u_error = ENOSPC; return(NULL); } /* * Free a block or fragment. * * Place the specified disk block back on the free list of the * specified device. */ void free (ip, bno) struct inode *ip; daddr_t bno; { register struct fs *fs; register struct buf *bp; struct fblk *fbp; fs = ip->i_fs; if (badblock (fs, bno)) { printf("bad block %D, ino %d\n", bno, ip->i_number); return; } while (fs->fs_flock) sleep((caddr_t)&fs->fs_flock, PINOD); if (fs->fs_nfree <= 0) { fs->fs_nfree = 1; fs->fs_free[0] = 0; } if (fs->fs_nfree >= NICFREE) { fs->fs_flock++; bp = getblk(ip->i_dev, bno); fbp = (FBLKP) bp->b_addr; *fbp = *((FBLKP)&fs->fs_nfree); fs->fs_nfree = 0; if (fs->fs_flags & MNT_ASYNC) bdwrite(bp); else bwrite(bp); fs->fs_flock = 0; wakeup((caddr_t)&fs->fs_flock); } fs->fs_free[fs->fs_nfree++] = bno; fs->fs_tfree++; fs->fs_fmod = 1; } /* * Free an inode. * * Free the specified I node on the specified device. The algorithm * stores up to NICINOD I nodes in the super block and throws away any more. */ void ifree (ip, ino) struct inode *ip; ino_t ino; { register struct fs *fs; fs = ip->i_fs; fs->fs_tinode++; if (fs->fs_ilock) return; if (fs->fs_ninode >= NICINOD) { if (fs->fs_lasti > ino) fs->fs_nbehind++; return; } fs->fs_inode[fs->fs_ninode++] = ino; fs->fs_fmod = 1; } /* * Fserr prints the name of a file system with an error diagnostic. * * The form of the error message is: * fs: error message */ void fserr (fp, cp) struct fs *fp; char *cp; { printf ("%s: %s\n", fp->fs_fsmnt, cp); } ================================================ FILE: sys/kern/ufs_bio.c ================================================ /* * Copyright (c) 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include #include #include #include #include #include #include #include #include /* * Read in (if necessary) the block and return a buffer pointer. */ struct buf * bread (dev, blkno) dev_t dev; daddr_t blkno; { register struct buf *bp; bp = getblk(dev, blkno); if (bp->b_flags&(B_DONE|B_DELWRI)) { return (bp); } bp->b_flags |= B_READ; bp->b_bcount = DEV_BSIZE; /* XXX? KB */ (*bdevsw[major(dev)].d_strategy)(bp); u.u_ru.ru_inblock++; /* pay for read */ biowait(bp); return(bp); } /* * Read in the block, like bread, but also start I/O on the * read-ahead block (which is not allocated to the caller) */ struct buf * breada(dev, blkno, rablkno) register dev_t dev; daddr_t blkno; daddr_t rablkno; { register struct buf *bp, *rabp; bp = NULL; /* * If the block isn't in core, then allocate * a buffer and initiate i/o (getblk checks * for a cache hit). */ if (! incore (dev, blkno)) { bp = getblk(dev, blkno); if ((bp->b_flags&(B_DONE|B_DELWRI)) == 0) { bp->b_flags |= B_READ; bp->b_bcount = DEV_BSIZE; /* XXX? KB */ (*bdevsw[major(dev)].d_strategy)(bp); u.u_ru.ru_inblock++; /* pay for read */ } } /* * If there's a read-ahead block, start i/o * on it also (as above). */ if (rablkno) { if (! incore (dev, rablkno)) { rabp = getblk(dev, rablkno); if (rabp->b_flags & (B_DONE|B_DELWRI)) { brelse(rabp); } else { rabp->b_flags |= B_READ|B_ASYNC; rabp->b_bcount = DEV_BSIZE; /* XXX? KB */ (*bdevsw[major(dev)].d_strategy)(rabp); u.u_ru.ru_inblock++; /* pay in advance */ } } } /* * If block was in core, let bread get it. * If block wasn't in core, then the read was started * above, and just wait for it. */ if (bp == NULL) return (bread(dev, blkno)); biowait(bp); return (bp); } /* * Write the buffer, waiting for completion. * Then release the buffer. */ void bwrite(bp) register struct buf *bp; { register int flag; flag = bp->b_flags; bp->b_flags &= ~(B_READ | B_DONE | B_ERROR | B_DELWRI); if ((flag&B_DELWRI) == 0) u.u_ru.ru_oublock++; /* noone paid yet */ bp->b_bcount = DEV_BSIZE; /* XXX? KB */ (*bdevsw[major(bp->b_dev)].d_strategy)(bp); /* * If the write was synchronous, then await i/o completion. * If the write was "delayed", then we put the buffer on * the q of blocks awaiting i/o completion status. */ if ((flag&B_ASYNC) == 0) { biowait(bp); brelse(bp); } else if (flag & B_DELWRI) bp->b_flags |= B_AGE; } /* * Release the buffer, marking it so that if it is grabbed * for another purpose it will be written out before being * given up (e.g. when writing a partial block where it is * assumed that another write for the same block will soon follow). * This can't be done for magtape, since writes must be done * in the same order as requested. */ void bdwrite (bp) register struct buf *bp; { if ((bp->b_flags&B_DELWRI) == 0) u.u_ru.ru_oublock++; /* noone paid yet */ if (bdevsw[major(bp->b_dev)].d_flags & B_TAPE) { bawrite(bp); } else { bp->b_flags |= B_DELWRI | B_DONE; brelse(bp); } } /* * Release the buffer, with no I/O implied. */ void brelse (bp) register struct buf *bp; { register struct buf *flist; register int s; /* * If someone's waiting for the buffer, or * is waiting for a buffer, wake 'em up. */ if (bp->b_flags&B_WANTED) wakeup((caddr_t)bp); if (bfreelist[0].b_flags&B_WANTED) { bfreelist[0].b_flags &= ~B_WANTED; wakeup((caddr_t)bfreelist); } if (bp->b_flags&B_ERROR) { if (bp->b_flags & B_LOCKED) bp->b_flags &= ~B_ERROR; /* try again later */ else bp->b_dev = NODEV; /* no assoc */ } /* * Stick the buffer back on a free list. */ s = splbio(); if (bp->b_flags & (B_ERROR|B_INVAL)) { /* block has no info ... put at front of most free list */ flist = &bfreelist[BQ_AGE]; binsheadfree(bp, flist); } else { if (bp->b_flags & B_LOCKED) flist = &bfreelist[BQ_LOCKED]; else if (bp->b_flags & B_AGE) flist = &bfreelist[BQ_AGE]; else flist = &bfreelist[BQ_LRU]; binstailfree(bp, flist); } bp->b_flags &= ~(B_WANTED|B_BUSY|B_ASYNC|B_AGE); splx(s); } /* * See if the block is associated with some buffer * (mainly to avoid getting hung up on a wait in breada) */ int incore (dev, blkno) register dev_t dev; daddr_t blkno; { register struct buf *bp; register struct buf *dp; dp = BUFHASH(dev, blkno); blkno = fsbtodb(blkno); for (bp = dp->b_forw; bp != dp; bp = bp->b_forw) if (bp->b_blkno == blkno && bp->b_dev == dev && (bp->b_flags & B_INVAL) == 0) return (1); return (0); } /* * Find a buffer which is available for use. * Select something from a free list. * Preference is to AGE list, then LRU list. */ struct buf * getnewbuf(void) { register struct buf *bp, *dp; int s; loop: s = splbio(); for (dp = &bfreelist[BQ_AGE]; dp > bfreelist; dp--) if (dp->av_forw != dp) break; if (dp == bfreelist) { /* no free blocks */ dp->b_flags |= B_WANTED; sleep((caddr_t)dp, PRIBIO+1); splx(s); goto loop; } splx(s); bp = dp->av_forw; notavail(bp); if (bp->b_flags & B_DELWRI) { bawrite(bp); goto loop; } if(bp->b_flags & (B_RAMREMAP|B_PHYS)) { #ifdef DIAGNOSTIC if ((bp < &buf[0]) || (bp >= &buf[NBUF])) panic("getnewbuf: RAMREMAP bp addr"); #endif bp->b_addr = bufdata + DEV_BSIZE * (bp - buf); } bp->b_flags = B_BUSY; return (bp); } /* * Assign a buffer for the given block. If the appropriate * block is already associated, return it; otherwise search * for the oldest non-busy buffer and reassign it. * * We use splx here because this routine may be called * on the interrupt stack during a dump, and we don't * want to lower the ipl back to 0. */ struct buf * getblk(dev, blkno) register dev_t dev; daddr_t blkno; { register struct buf *bp, *dp; daddr_t dblkno; int s; #ifdef DIAGNOSTIC if (major(dev) >= nblkdev) panic("blkdev"); #endif /* * Search the cache for the block. If we hit, but * the buffer is in use for i/o, then we wait until * the i/o has completed. */ dp = BUFHASH(dev, blkno); dblkno = fsbtodb(blkno); loop: for (bp = dp->b_forw; bp != dp; bp = bp->b_forw) { if (bp->b_blkno != dblkno || bp->b_dev != dev || bp->b_flags&B_INVAL) continue; s = splbio(); if (bp->b_flags&B_BUSY) { bp->b_flags |= B_WANTED; sleep((caddr_t)bp, PRIBIO+1); splx(s); goto loop; } splx(s); notavail(bp); return (bp); } bp = getnewbuf(); bfree(bp); bremhash(bp); binshash(bp, dp); bp->b_dev = dev; bp->b_blkno = dblkno; bp->b_error = 0; return (bp); } /* * get an empty block, * not assigned to any particular device */ struct buf * geteblk() { register struct buf *bp, *flist; bp = getnewbuf(); bp->b_flags |= B_INVAL; bfree(bp); bremhash(bp); flist = &bfreelist[BQ_AGE]; binshash(bp, flist); bp->b_dev = (dev_t)NODEV; bp->b_error = 0; return (bp); } /* * Wait for I/O completion on the buffer; return errors * to the user. */ void biowait(bp) register struct buf *bp; { register int s; s = splbio(); while ((bp->b_flags & B_DONE) == 0) sleep((caddr_t)bp, PRIBIO); splx(s); if (! u.u_error) /* XXX */ u.u_error = geterror(bp); } /* * Mark I/O complete on a buffer. * Wake up anyone waiting for it. */ void biodone(bp) register struct buf *bp; { if (bp->b_flags & B_DONE) panic("dup biodone"); bp->b_flags |= B_DONE; if (bp->b_flags & B_ASYNC) brelse(bp); else { bp->b_flags &= ~B_WANTED; wakeup((caddr_t)bp); } } /* * Insure that no part of a specified block is in an incore buffer. */ void blkflush (dev, blkno) register dev_t dev; daddr_t blkno; { register struct buf *ep; struct buf *dp; register int s; dp = BUFHASH(dev, blkno); blkno = fsbtodb(blkno); loop: for (ep = dp->b_forw; ep != dp; ep = ep->b_forw) { if (ep->b_blkno != blkno || ep->b_dev != dev || (ep->b_flags&B_INVAL)) continue; s = splbio(); if (ep->b_flags&B_BUSY) { ep->b_flags |= B_WANTED; sleep((caddr_t)ep, PRIBIO+1); splx(s); goto loop; } if (ep->b_flags & B_DELWRI) { splx(s); notavail(ep); bwrite(ep); goto loop; } splx(s); } } /* * Make sure all write-behind blocks on dev are flushed out. * (from umount and sync) */ void bflush(dev) register dev_t dev; { register struct buf *bp; register struct buf *flist; int s; loop: s = splbio(); for (flist = bfreelist; flist < &bfreelist[BQ_EMPTY]; flist++) { for (bp = flist->av_forw; bp != flist; bp = bp->av_forw) { if ((bp->b_flags & B_DELWRI) == 0) continue; if (dev == bp->b_dev) { bp->b_flags |= B_ASYNC; notavail(bp); bwrite(bp); splx(s); goto loop; } } } splx(s); } /* * Pick up the device's error number and pass it to the user; * if there is an error but the number is 0 set a generalized code. */ int geterror (bp) register struct buf *bp; { register int error = 0; if (bp->b_flags&B_ERROR) if ((error = bp->b_error)==0) return(EIO); return (error); } /* * Invalidate in core blocks belonging to closed or umounted filesystem * * This is not nicely done at all - the buffer ought to be removed from the * hash chains & have its dev/blkno fields clobbered, but unfortunately we * can't do that here, as it is quite possible that the block is still * being used for i/o. Eventually, all disc drivers should be forced to * have a close routine, which ought ensure that the queue is empty, then * properly flush the queues. Until that happy day, this suffices for * correctness. ... kre */ void binval(dev) register dev_t dev; { register struct buf *bp; register struct bufhd *hp; #define dp ((struct buf *)hp) for (hp = bufhash; hp < &bufhash[BUFHSZ]; hp++) for (bp = dp->b_forw; bp != dp; bp = bp->b_forw) if (bp->b_dev == dev) bp->b_flags |= B_INVAL; } ================================================ FILE: sys/kern/ufs_bmap.c ================================================ /* * Copyright (c) 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include #include #include #include #include #include #include #include #include #include /* * Bmap defines the structure of file system storage * by returning the physical block number on a device given the * inode and the logical block number in a file. * When convenient, it also leaves the physical * block number of the next block of the file in rablock * for use in read-ahead. */ daddr_t bmap(ip, bn, rwflg, flags) register struct inode *ip; daddr_t bn; int rwflg, flags; { register int i; register struct buf *bp; struct buf *nbp; int j, sh; daddr_t nb, *bap, ra; int async = ip->i_fs->fs_flags & MNT_ASYNC; if (bn < 0) { u.u_error = EFBIG; return((daddr_t)0); } ra = rablock = 0; /* * blocks 0..NADDR-4 are direct blocks */ if (bn < NADDR-3) { i = bn; nb = ip->i_addr[i]; if (nb == 0) { if (rwflg == B_READ || (bp = balloc(ip, flags)) == NULL) return((daddr_t)-1); nb = dbtofsb(bp->b_blkno); /* * directory blocks are usually the only thing written synchronously at this * point (so they never appear with garbage in them on the disk). This is * overridden if the filesystem was mounted 'async'. */ if (flags & B_SYNC) bwrite(bp); else bdwrite(bp); ip->i_addr[i] = nb; ip->i_flag |= IUPD|ICHG; } if (i < NADDR-4) rablock = ip->i_addr[i+1]; return(nb); } /* * addresses NADDR-3, NADDR-2, and NADDR-1 * have single, double, triple indirect blocks. * the first step is to determine * how many levels of indirection. */ sh = 0; nb = 1; bn -= NADDR-3; for (j = 3;j > 0;j--) { sh += NSHIFT; nb <<= NSHIFT; if (bn < nb) break; bn -= nb; } if (j == 0) { u.u_error = EFBIG; return((daddr_t)0); } /* * fetch the first indirect block */ nb = ip->i_addr[NADDR-j]; if (nb == 0) { if (rwflg == B_READ || (bp = balloc(ip, flags | B_CLRBUF)) == NULL) return((daddr_t) -1); nb = dbtofsb(bp->b_blkno); /* * Write synchronously if requested so that indirect blocks * never point at garbage. */ if (async) bdwrite(bp); else bwrite(bp); ip->i_addr[NADDR-j] = nb; ip->i_flag |= IUPD|ICHG; } /* * fetch through the indirect blocks */ for(;j <= 3;j++) { bp = bread(ip->i_dev, nb); if ((bp->b_flags & B_ERROR) || bp->b_resid) { brelse(bp); return((daddr_t)0); } bap = (daddr_t*) bp->b_addr; sh -= NSHIFT; i = (bn>>sh) & NMASK; nb = bap[i]; /* * calculate read-ahead */ if (i < NINDIR-1) ra = bap[i+1]; if (nb == 0) { if (rwflg == B_READ || (nbp = balloc(ip, flags | B_CLRBUF)) == NULL) { brelse(bp); return((daddr_t) -1); } nb = dbtofsb(nbp->b_blkno); /* * Write synchronously so indirect blocks never point at garbage and blocks * in directories never contain garbage. This check used to be based on the * type of inode, if it was a directory then 'sync' writes were done. See the * comments earlier about filesystems being mounted 'async'. */ if (!async && (j < 3 || (flags & B_SYNC))) bwrite(nbp); else bdwrite(nbp); bap = (daddr_t*) bp->b_addr; bap[i] = nb; bdwrite(bp); } else brelse(bp); } rablock = ra; return(nb); } ================================================ FILE: sys/kern/ufs_dsort.c ================================================ /* * Copyright (c) 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * * @(#)ufs_dsort.c 1.1 (2.10BSD Berkeley) 12/1/86 */ /* * generalized seek sort for disk */ #include #include #include #include void disksort (dp, bp) register struct buf *dp, *bp; { register struct buf *ap; struct buf *tp; ap = dp->b_actf; if (ap == NULL) { dp->b_actf = bp; dp->b_actl = bp; bp->av_forw = NULL; return; } tp = NULL; for (; ap != NULL; ap = ap->av_forw) { if ((bp->b_flags&B_READ) && (ap->b_flags&B_READ) == 0) { if (tp == NULL) tp = ap; break; } if ((bp->b_flags&B_READ) == 0 && (ap->b_flags&B_READ)) continue; if (ap->b_cylin <= bp->b_cylin) if (tp == NULL || ap->b_cylin >= tp->b_cylin) tp = ap; } if (tp == NULL) tp = dp->b_actl; bp->av_forw = tp->av_forw; tp->av_forw = bp; if (tp == dp->b_actl) dp->b_actl = bp; } #ifdef UCB_METER /* * Allocate iostat disk monitoring slots for a driver. If slots already * allocated (*dkn >= 0) or not enough slots left to satisfy request simply * ignore it. */ void dk_alloc (dkn, slots, name) int *dkn; /* pointer to number for iostat */ int slots; /* number of iostat slots requested */ char *name; /* name of device */ { int i; register char **np; register int *up; if (*dkn < 0 && dk_n + slots <= DK_NDRIVE) { /* * Allocate and initialize the slots */ *dkn = dk_n; np = &dk_name[dk_n]; up = &dk_unit[dk_n]; dk_n += slots; for (i = 0; i < slots; i++) { *np++ = name; *up++ = i; } } } #endif /* UCB_METER */ ================================================ FILE: sys/kern/ufs_fio.c ================================================ /* * Copyright (c) 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include #include #include #include #include #include #include #include /* * Check mode permission on inode pointer. * Mode is READ, WRITE or EXEC. * In the case of WRITE, the * read-only status of the file * system is checked. * Also in WRITE, prototype text * segments cannot be written. * The mode is shifted to select * the owner/group/other fields. * The super user is granted all * permissions. */ int access (ip, mode) register struct inode *ip; int mode; { register int m; register gid_t *gp; m = mode; if (m == IWRITE) { if (ip->i_flags & IMMUTABLE) { u.u_error = EPERM; return(1); } /* * Disallow write attempts on read-only * file systems; unless the file is a block * or character device resident on the * file system. */ if (ip->i_fs->fs_ronly != 0) { if ((ip->i_mode & IFMT) != IFCHR && (ip->i_mode & IFMT) != IFBLK) { u.u_error = EROFS; return (1); } } } /* * If you're the super-user, * you always get access. */ if (u.u_uid == 0) return (0); /* * Access check is based on only * one of owner, group, public. * If not owner, then check group. * If not a member of the group, then * check public access. */ if (u.u_uid != ip->i_uid) { m >>= 3; gp = u.u_groups; for (; gp < &u.u_groups[NGROUPS] && *gp != NOGROUP; gp++) if (ip->i_gid == *gp) goto found; m >>= 3; found: ; } if ((ip->i_mode&m) != 0) return (0); u.u_error = EACCES; return (1); } /* copied, for supervisory networking, to sys_net.c */ /* * Test if the current user is the * super user. */ int suser() { if (u.u_uid == 0) { return (1); } u.u_error = EPERM; return (0); } /* * Set the attributes on a file. This was placed here because ufs_syscalls * is too large already (it will probably be split into two files eventually). */ int ufs_setattr (ip, vap) register struct inode *ip; register struct vattr *vap; { int error; struct timeval atimeval, mtimeval; if (ip->i_fs->fs_ronly) /* can't change anything on a RO fs */ return(EROFS); if (vap->va_flags != VNOVAL) { if (u.u_uid != ip->i_uid && !suser()) return(u.u_error); if (u.u_uid == 0) { if ((ip->i_flags & (SF_IMMUTABLE|SF_APPEND)) && securelevel > 0) return(EPERM); ip->i_flags = vap->va_flags; } else { if (ip->i_flags & (SF_IMMUTABLE|SF_APPEND)) return(EPERM); ip->i_flags &= SF_SETTABLE; ip->i_flags |= (vap->va_flags & UF_SETTABLE); } ip->i_flag |= ICHG; if (vap->va_flags & (IMMUTABLE|APPEND)) return(0); } if (ip->i_flags & (IMMUTABLE|APPEND)) return(EPERM); /* * Go thru the fields (other than 'flags') and update iff not VNOVAL. */ if (vap->va_uid != (uid_t)VNOVAL || vap->va_gid != (gid_t)VNOVAL) { error = chown1 (ip, vap->va_uid, vap->va_gid); if (error) return(error); } if (vap->va_size != (off_t)VNOVAL) { if ((ip->i_mode & IFMT) == IFDIR) return(EISDIR); itrunc(ip, vap->va_size, 0); if (u.u_error) return(u.u_error); } if (vap->va_atime != (time_t)VNOVAL || vap->va_mtime != (time_t)VNOVAL) { if (u.u_uid != ip->i_uid && !suser() && ((vap->va_vaflags & VA_UTIMES_NULL) == 0 || access(ip, IWRITE))) return(u.u_error); if (vap->va_atime != (time_t)VNOVAL && ! (ip->i_fs->fs_flags & MNT_NOATIME)) ip->i_flag |= IACC; if (vap->va_mtime != (time_t)VNOVAL) ip->i_flag |= (IUPD|ICHG); atimeval.tv_sec = vap->va_atime; mtimeval.tv_sec = vap->va_mtime; iupdat(ip, &atimeval, &mtimeval, 1); } if (vap->va_mode != (mode_t)VNOVAL) return(chmod1(ip, vap->va_mode)); return(0); } /* * Check that device is mounted somewhere. * Return EBUSY if mounted, 0 otherwise. */ int ufs_mountedon (dev) dev_t dev; { register struct mount *mp; for (mp = mount; mp < &mount[NMOUNT]; mp++) { if (mp->m_inodp == NULL) continue; if (mp->m_dev == dev) return(EBUSY); } return(0); } ================================================ FILE: sys/kern/ufs_inode.c ================================================ /* * Copyright (c) 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include #include #include #include #include #include #include #include #include #include #define INOHSZ 16 /* must be power of two */ #define INOHASH(dev,ino) (((dev)+(ino))&(INOHSZ-1)) union ihead { /* inode LRU cache, stolen */ union ihead *ih_head[2]; struct inode *ih_chain[2]; } ihead[INOHSZ]; struct inode *ifreeh, **ifreet; /* * Initialize hash links for inodes * and build inode free list. */ void ihinit() { register int i; register struct inode *ip = inode; register union ihead *ih = ihead; for (i = INOHSZ; --i >= 0; ih++) { ih->ih_head[0] = ih; ih->ih_head[1] = ih; } ifreeh = ip; ifreet = &ip->i_freef; ip->i_freeb = &ifreeh; ip->i_forw = ip; ip->i_back = ip; for (i = NINODE; --i > 0; ) { ++ip; ip->i_forw = ip; ip->i_back = ip; *ifreet = ip; ip->i_freeb = ifreet; ifreet = &ip->i_freef; } ip->i_freef = NULL; } /* * Find an inode if it is incore. */ struct inode * ifind(dev, ino) register dev_t dev; register ino_t ino; { register struct inode *ip; union ihead *ih; ih = &ihead[INOHASH(dev, ino)]; for (ip = ih->ih_chain[0]; ip != (struct inode *)ih; ip = ip->i_forw) if (ino == ip->i_number && dev == ip->i_dev) return(ip); return((struct inode *)NULL); } /* * Look up an inode by device,inumber. * If it is in core (in the inode structure), * honor the locking protocol. * If it is not in core, read it in from the * specified device. * If the inode is mounted on, perform * the indicated indirection. * In all cases, a pointer to a locked * inode structure is returned. * * panic: no imt -- if the mounted file * system is not in the mount table. * "cannot happen" */ struct inode * iget(dev, fs, ino) dev_t dev; register struct fs *fs; ino_t ino; { register struct inode *ip; union ihead *ih; struct buf *bp; struct dinode *dp; loop: ih = &ihead[INOHASH(dev, ino)]; for (ip = ih->ih_chain[0]; ip != (struct inode *)ih; ip = ip->i_forw) if (ino == ip->i_number && dev == ip->i_dev) { /* * Following is essentially an inline expanded * copy of igrab(), expanded inline for speed, * and so that the test for a mounted on inode * can be deferred until after we are sure that * the inode isn't busy. */ if ((ip->i_flag&ILOCKED) != 0) { ip->i_flag |= IWANT; sleep((caddr_t)ip, PINOD); goto loop; } if ((ip->i_flag&IMOUNT) != 0) { register struct mount *mp; for (mp = &mount[0]; mp < &mount[NMOUNT]; mp++) if(mp->m_inodp == ip) { dev = mp->m_dev; fs = &mp->m_filsys; ino = ROOTINO; goto loop; } panic("no imt"); } if (ip->i_count == 0) { /* ino on free list */ register struct inode *iq; iq = ip->i_freef; if (iq) iq->i_freeb = ip->i_freeb; else ifreet = ip->i_freeb; *ip->i_freeb = iq; ip->i_freef = NULL; ip->i_freeb = NULL; } ip->i_count++; ip->i_flag |= ILOCKED; return(ip); } ip = ifreeh; if (ip == NULL) { log(LOG_ERR, "inode: table full\n"); u.u_error = ENFILE; return(NULL); } if (ip->i_count) panic("free inode isn't"); { register struct inode *iq; iq = ip->i_freef; if (iq) iq->i_freeb = &ifreeh; ifreeh = iq; } ip->i_freef = NULL; ip->i_freeb = NULL; /* * Now to take inode off the hash chain it was on * (initially, or after an iflush, it is on a "hash chain" * consisting entirely of itself, and pointed to by no-one, * but that doesn't matter), and put it on the chain for * its new (ino, dev) pair */ remque(ip); insque(ip, ih); ip->i_dev = dev; ip->i_fs = fs; ip->i_number = ino; cacheinval(ip); ip->i_flag = ILOCKED; ip->i_count++; ip->i_lastr = 0; bp = bread(dev, itod(ino)); /* * Check I/O errors */ if ((bp->b_flags&B_ERROR) != 0) { brelse(bp); /* * the inode doesn't contain anything useful, so it would * be misleading to leave it on its hash chain. * 'iput' will take care of putting it back on the free list. */ remque(ip); ip->i_forw = ip; ip->i_back = ip; /* * we also loose its inumber, just in case (as iput * doesn't do that any more) - but as it isn't on its * hash chain, I doubt if this is really necessary .. kre * (probably the two methods are interchangable) */ ip->i_number = 0; iput(ip); return(NULL); } dp = (struct dinode*) bp->b_addr; dp += itoo(ino); ip->i_ic1 = dp->di_ic1; ip->i_flags = dp->di_flags; ip->i_ic2 = dp->di_ic2; bcopy(dp->di_addr, ip->i_addr, NADDR * sizeof (daddr_t)); brelse(bp); return (ip); } /* * Convert a pointer to an inode into a reference to an inode. * * This is basically the internal piece of iget (after the * inode pointer is located) but without the test for mounted * filesystems. It is caller's responsibility to check that * the inode pointer is valid. */ void igrab (ip) register struct inode *ip; { while ((ip->i_flag&ILOCKED) != 0) { ip->i_flag |= IWANT; sleep((caddr_t)ip, PINOD); } if (ip->i_count == 0) { /* ino on free list */ register struct inode *iq; iq = ip->i_freef; if (iq) iq->i_freeb = ip->i_freeb; else ifreet = ip->i_freeb; *ip->i_freeb = iq; ip->i_freef = NULL; ip->i_freeb = NULL; } ip->i_count++; ip->i_flag |= ILOCKED; } /* * Decrement reference count of * an inode structure. * On the last reference, * write the inode out and if necessary, * truncate and deallocate the file. */ void iput (ip) register struct inode *ip; { #ifdef notnow /* * This code requires a lot of workarounds, you have to change * lots of places to gratuitously lock just so we can unlock it. * Not worth it. -- KB */ if ((ip->i_flag & ILOCKED) == 0) panic("iput"); #endif IUNLOCK(ip); irele(ip); } void irele (ip) register struct inode *ip; { if (ip->i_count == 1) { ip->i_flag |= ILOCKED; if (ip->i_nlink <= 0 && ip->i_fs->fs_ronly == 0) { itrunc (ip, (u_long) 0, 0); ip->i_mode = 0; ip->i_rdev = 0; ip->i_flag |= IUPD|ICHG; ifree(ip, ip->i_number); } IUPDAT(ip, &time, &time, 0); IUNLOCK(ip); ip->i_flag = 0; /* * Put the inode on the end of the free list. * Possibly in some cases it would be better to * put the inode at the head of the free list, * (eg: where i_mode == 0 || i_number == 0) * but I will think about that later .. kre * (i_number is rarely 0 - only after an i/o error in iget, * where i_mode == 0, the inode will probably be wanted * again soon for an ialloc, so possibly we should keep it) */ if (ifreeh) { *ifreet = ip; ip->i_freeb = ifreet; } else { ifreeh = ip; ip->i_freeb = &ifreeh; } ip->i_freef = NULL; ifreet = &ip->i_freef; } else if (!(ip->i_flag & ILOCKED)) ITIMES(ip, &time, &time); ip->i_count--; } /* * Check accessed and update flags on * an inode structure. * If any are on, update the inode * with the current time. * If waitfor set, then must insure * i/o order so wait for the write to complete. */ void iupdat (ip, ta, tm, waitfor) struct inode *ip; struct timeval *ta, *tm; int waitfor; { register struct buf *bp; register struct dinode *dp; register struct inode *tip = ip; if ((tip->i_flag & (IUPD|IACC|ICHG|IMOD)) == 0) return; if (tip->i_fs->fs_ronly) return; bp = bread(tip->i_dev, itod(tip->i_number)); if (bp->b_flags & B_ERROR) { brelse(bp); return; } if (tip->i_flag&IACC) tip->i_atime = ta->tv_sec; if (tip->i_flag&IUPD) tip->i_mtime = tm->tv_sec; if (tip->i_flag&ICHG) tip->i_ctime = time.tv_sec; tip->i_flag &= ~(IUPD|IACC|ICHG|IMOD); dp = (struct dinode*) bp->b_addr + itoo (tip->i_number); dp->di_ic1 = tip->i_ic1; dp->di_flags = tip->i_flags; dp->di_ic2 = tip->i_ic2; bcopy(ip->i_addr, dp->di_addr, NADDR * sizeof (daddr_t)); if (waitfor && ((ip->i_fs->fs_flags & MNT_ASYNC) == 0)) bwrite(bp); else bdwrite(bp); } #define SINGLE 0 /* index of single indirect block */ #define DOUBLE 1 /* index of double indirect block */ #define TRIPLE 2 /* index of triple indirect block */ static void trsingle (ip, bp, last, aflags) register struct inode *ip; struct buf *bp; daddr_t last; int aflags; { register const daddr_t *bstart, *bstop; const daddr_t *blarray = (const daddr_t*) bp->b_addr; bstart = &blarray[NINDIR - 1]; bstop = &blarray[last]; for (; bstart > bstop; --bstart) if (*bstart) free (ip, *bstart); } /* * Release blocks associated with the inode ip and * stored in the indirect block bn. Blocks are free'd * in LIFO order up to (but not including) lastbn. If * level is greater than SINGLE, the block is an indirect * block and recursive calls to indirtrunc must be used to * cleanse other indirect blocks. * * NB: triple indirect blocks are untested. */ void indirtrunc (ip, bn, lastbn, level, aflags) struct inode *ip; daddr_t bn, lastbn; int level; int aflags; { register struct buf *bp; daddr_t nb, last; long factor; /* * Calculate index in current block of last * block to be kept. -1 indicates the entire * block so we need not calculate the index. */ switch (level) { default: case SINGLE: factor = 1; break; case DOUBLE: factor = NINDIR; break; case TRIPLE: factor = NINDIR * NINDIR; break; } last = lastbn; if (lastbn > 0) last = last / factor; /* * Get buffer of block pointers, zero those * entries corresponding to blocks to be free'd, * and update on disk copy first. */ { register daddr_t *bap; register struct buf *cpy; bp = bread(ip->i_dev, bn); if (bp->b_flags&B_ERROR) { brelse(bp); return; } cpy = geteblk(); bcopy (bp->b_addr, cpy->b_addr, DEV_BSIZE); bap = (daddr_t*) bp->b_addr; bzero((caddr_t)&bap[last + 1], (u_int)(NINDIR - (last + 1)) * sizeof(daddr_t)); if (aflags & B_SYNC) bwrite(bp); else bawrite(bp); bp = cpy; } /* * Optimized for single indirect blocks, i.e. until a file is * greater than 4K + 256K you don't have to do a mapin/mapout * for every entry. The mapin/mapout is required since free() * may have to map an item in. Have to use another routine * since it requires 1K of kernel stack to get around the problem * and that doesn't work well with recursion. */ if (level == SINGLE) trsingle (ip, bp, last, aflags); else { register daddr_t *bstart, *bstop; bstart = (daddr_t*) bp->b_addr; bstop = &bstart[last]; bstart += NINDIR - 1; /* * Recursively free totally unused blocks. */ for (;bstart > bstop;--bstart) { nb = *bstart; if (nb) { indirtrunc(ip,nb,(daddr_t)-1, level-1, aflags); free(ip, nb); } } /* * Recursively free last partial block. */ if (lastbn >= 0) { nb = *bstop; last = lastbn % factor; if (nb != 0) indirtrunc(ip, nb, last, level - 1, aflags); } } brelse(bp); } /* * Truncate the inode ip to at most * length size. Free affected disk * blocks -- the blocks of the file * are removed in reverse order. * * NB: triple indirect blocks are untested. */ void itrunc (oip, length, ioflags) register struct inode *oip; u_long length; int ioflags; { daddr_t lastblock; register int i; register struct inode *ip; daddr_t bn, lastiblock[NIADDR]; struct buf *bp; int offset, level; struct inode tip; int aflags; aflags = B_CLRBUF; if (ioflags & IO_SYNC) aflags |= B_SYNC; /* * special hack for pipes, since size for them isn't the size of * the file, it's the amount currently waiting for transfer. It's * unclear that this will work, though, because pipes can (although * rarely do) get bigger than MAXPIPSIZ. Don't think it worked * in V7 either, I don't really understand what's going on. */ if (oip->i_flag & IPIPE) oip->i_size = MAXPIPSIZ; else if (oip->i_size == length) goto updret; /* * Lengthen the size of the file. We must ensure that the * last byte of the file is allocated. Since the smallest * value of osize is 0, length will be at least 1. */ if (oip->i_size < length) { bn = bmap(oip, lblkno(length - 1), B_WRITE, aflags); if (u.u_error || bn < 0) return; oip->i_size = length; goto doquotaupd; } /* * Calculate index into inode's block list of * last direct and indirect blocks (if any) * which we want to keep. Lastblock is -1 when * the file is truncated to 0. */ lastblock = lblkno(length + DEV_BSIZE - 1) - 1; lastiblock[SINGLE] = lastblock - NDADDR; lastiblock[DOUBLE] = lastiblock[SINGLE] - NINDIR; lastiblock[TRIPLE] = lastiblock[DOUBLE] - NINDIR * NINDIR; /* * Update the size of the file. If the file is not being * truncated to a block boundry, the contents of the * partial block following the end of the file must be * zero'ed in case it ever become accessable again because * of subsequent file growth. */ offset = blkoff(length); if (offset) { bn = bmap(oip, lblkno(length), B_WRITE, aflags); if (u.u_error || bn < 0) return; bp = bread(oip->i_dev, bn); if (bp->b_flags & B_ERROR) { u.u_error = EIO; brelse(bp); return; } bzero (bp->b_addr + offset, (u_int) (DEV_BSIZE - offset)); bdwrite(bp); } /* * Update file and block pointers * on disk before we start freeing blocks. * If we crash before free'ing blocks below, * the blocks will be returned to the free list. * lastiblock values are also normalized to -1 * for calls to indirtrunc below. */ tip = *oip; oip->i_size = length; for (level = TRIPLE; level >= SINGLE; level--) if (lastiblock[level] < 0) { oip->i_ib[level] = 0; lastiblock[level] = -1; } for (i = NDADDR - 1; i > lastblock; i--) oip->i_db[i] = 0; /* * Indirect blocks first. */ ip = &tip; for (level = TRIPLE; level >= SINGLE; level--) { bn = ip->i_ib[level]; if (bn != 0) { indirtrunc(ip, bn, lastiblock[level], level, aflags); if (lastiblock[level] < 0) { ip->i_ib[level] = 0; free(ip, bn); } } if (lastiblock[level] >= 0) goto done; } /* * All whole direct blocks. */ for (i = NDADDR - 1; i > lastblock; i--) { bn = ip->i_db[i]; if (bn == 0) continue; ip->i_db[i] = 0; free(ip, bn); } if (lastblock < 0) goto done; done: #ifdef DIAGNOSTIC /* BEGIN PARANOIA */ for (level = SINGLE; level <= TRIPLE; level++) if (ip->i_ib[level] != oip->i_ib[level]) panic("itrunc1"); for (i = 0; i < NDADDR; i++) if (ip->i_db[i] != oip->i_db[i]) panic("itrunc2"); /* END PARANOIA */ #endif doquotaupd: updret: oip->i_flag |= ICHG|IUPD; iupdat(oip, &time, &time, 1); } /* * Remove any inodes in the inode cache belonging to dev. * * There should not be any active ones, return error if any are found * (nb: this is a user error, not a system err) * * Also, count the references to dev by block devices - this really * has nothing to do with the object of the procedure, but as we have * to scan the inode table here anyway, we might as well get the * extra benefit. * * this is called from sumount() when dev is being unmounted */ int iflush (dev) dev_t dev; { register struct inode *ip; register int open = 0; for (ip = inode; ip < inode+NINODE; ip++) { if (ip->i_dev == dev) if (ip->i_count) return(-1); else { remque(ip); ip->i_forw = ip; ip->i_back = ip; /* * as i_count == 0, the inode was on the free * list already, just leave it there, it will * fall off the bottom eventually. We could * perhaps move it to the head of the free * list, but as umounts are done so * infrequently, we would gain very little, * while making the code bigger. */ } else if (ip->i_count && (ip->i_mode&IFMT)==IFBLK && ip->i_rdev == dev) open++; } return (open); } /* * Lock an inode. If its already locked, set the WANT bit and sleep. */ void ilock(ip) register struct inode *ip; { ILOCK(ip); } /* * Unlock an inode. If WANT bit is on, wakeup. */ void iunlock(ip) register struct inode *ip; { IUNLOCK(ip); } ================================================ FILE: sys/kern/ufs_mount.c ================================================ /* * Copyright (c) 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include #include #include #include #include #include #include #include #include #include #include #include #include /* * Common code for mount and umount. * Check that the user's argument is a reasonable * thing on which to mount, otherwise return error. */ static int getmdev (pdev, fname) caddr_t fname; dev_t *pdev; { register dev_t dev; register struct inode *ip; struct nameidata nd; register struct nameidata *ndp = &nd; if (!suser()) return (u.u_error); NDINIT (ndp, LOOKUP, FOLLOW, fname); ip = namei(ndp); if (ip == NULL) { if (u.u_error == ENOENT) return (ENODEV); /* needs translation */ return (u.u_error); } if ((ip->i_mode&IFMT) != IFBLK) { iput(ip); return (ENOTBLK); } dev = (dev_t)ip->i_rdev; iput(ip); if (major(dev) >= nblkdev) return (ENXIO); *pdev = dev; return (0); } void mount_updname (fs, on, from, lenon, lenfrom) struct fs *fs; char *on, *from; int lenon, lenfrom; { struct mount *mp; bzero (fs->fs_fsmnt, sizeof (fs->fs_fsmnt)); bcopy (on, fs->fs_fsmnt, sizeof (fs->fs_fsmnt) - 1); mp = (struct mount*) ((int) fs - offsetof (struct mount, m_filsys)); bzero (mp->m_mnton, sizeof (mp->m_mnton)); bzero (mp->m_mntfrom, sizeof (mp->m_mntfrom)); bcopy (on, mp->m_mnton, lenon); bcopy (from, mp->m_mntfrom, lenfrom); } void smount() { register struct a { char *fspec; char *freg; int flags; } *uap = (struct a *)u.u_arg; dev_t dev = 0; register struct inode *ip; register struct fs *fs; struct nameidata nd; struct nameidata *ndp = &nd; struct mount *mp; u_int lenon, lenfrom; int error = 0; char mnton[MNAMELEN], mntfrom[MNAMELEN]; u.u_error = getmdev (&dev, uap->fspec); if (u.u_error) return; NDINIT (ndp, LOOKUP, FOLLOW, uap->freg); if ((ip = namei(ndp)) == NULL) return; if ((ip->i_mode&IFMT) != IFDIR) { error = ENOTDIR; goto cmnout; } copystr (uap->freg, mnton, sizeof (mnton) - 1, &lenon); copystr (uap->fspec, mntfrom, sizeof (mntfrom) - 1, &lenfrom); if (uap->flags & MNT_UPDATE) { fs = ip->i_fs; mp = (struct mount *) ((int)fs - offsetof(struct mount, m_filsys)); if (ip->i_number != ROOTINO) { error = EINVAL; /* Not a mount point */ goto cmnout; } /* * Check that the device passed in is the same one that is in the mount * table entry for this mount point. */ if (dev != mp->m_dev) { error = EINVAL; /* not right mount point */ goto cmnout; } /* * This is where the RW to RO transformation would be done. It is, for now, * too much work to port pages of code to do (besides which most * programs get very upset at having access yanked out from under them). */ if (fs->fs_ronly == 0 && (uap->flags & MNT_RDONLY)) { error = EPERM; /* ! RW to RO updates */ goto cmnout; } /* * However, going from RO to RW is easy. Then merge in the new * flags (async, sync, nodev, etc) passed in from the program. */ if (fs->fs_ronly && ((uap->flags & MNT_RDONLY) == 0)) { fs->fs_ronly = 0; mp->m_flags &= ~MNT_RDONLY; } #define _MF (MNT_NOSUID | MNT_NODEV | MNT_NOEXEC | MNT_ASYNC | MNT_SYNCHRONOUS | MNT_NOATIME) mp->m_flags &= ~_MF; mp->m_flags |= (uap->flags & _MF); #undef _MF iput(ip); u.u_error = 0; goto updname; } else { /* * This is where a new mount (not an update of an existing mount point) is * done. * * The directory being mounted on can have no other references AND can not * currently be a mount point. Mount points have an inode number of (you * guessed it) ROOTINO which is 2. */ if (ip->i_count != 1 || (ip->i_number == ROOTINO)) { error = EBUSY; goto cmnout; } fs = mountfs (dev, uap->flags, ip); if (fs == 0) return; } /* * Lastly, both for new mounts and updates of existing mounts, update the * mounted-on and mounted-from fields. */ updname: mount_updname(fs, mnton, mntfrom, lenon, lenfrom); return; cmnout: iput(ip); u.u_error = error; } /* * Mount a filesystem on the given directory inode. * * this routine has races if running twice */ struct fs * mountfs (dev, flags, ip) dev_t dev; int flags; struct inode *ip; { register struct mount *mp = 0; struct buf *tp = 0; register struct fs *fs; register int error; int ronly = flags & MNT_RDONLY; int needclose = 0; error = (*bdevsw[major(dev)].d_open) (dev, ronly ? FREAD : (FREAD | FWRITE), S_IFBLK); if (error) goto out; needclose = 1; tp = bread (dev, SUPERB); if (tp->b_flags & B_ERROR) goto out; for (mp = &mount[0]; mp < &mount[NMOUNT]; mp++) if (mp->m_inodp != 0 && dev == mp->m_dev) { mp = 0; error = EBUSY; needclose = 0; goto out; } for (mp = &mount[0]; mp < &mount[NMOUNT]; mp++) if (mp->m_inodp == 0) goto found; mp = 0; error = EMFILE; /* needs translation */ goto out; found: mp->m_inodp = ip; /* reserve slot */ mp->m_dev = dev; fs = &mp->m_filsys; bcopy (tp->b_addr, (caddr_t)fs, sizeof(struct fs)); brelse (tp); tp = 0; if (fs->fs_magic1 != FSMAGIC1 || fs->fs_magic2 != FSMAGIC2) { error = EINVAL; goto out; } fs->fs_ronly = (ronly != 0); if (ronly == 0) fs->fs_fmod = 1; fs->fs_ilock = 0; fs->fs_flock = 0; fs->fs_nbehind = 0; fs->fs_lasti = 1; fs->fs_flags = flags; if (ip) { ip->i_flag |= IMOUNT; cacheinval(ip); IUNLOCK(ip); } return (fs); out: if (error == 0) error = EIO; if (ip) iput(ip); if (mp) mp->m_inodp = 0; if (tp) brelse(tp); if (needclose) { (*bdevsw[major(dev)].d_close)(dev, ronly? FREAD : FREAD|FWRITE, S_IFBLK); binval(dev); } u.u_error = error; return (0); } static int unmount1 (fname) caddr_t fname; { dev_t dev = 0; register struct mount *mp; register struct inode *ip; register int error; int aflag; error = getmdev(&dev, fname); if (error) return (error); for (mp = &mount[0]; mp < &mount[NMOUNT]; mp++) if (mp->m_inodp != NULL && dev == mp->m_dev) goto found; return (EINVAL); found: nchinval (dev); /* flush the name cache */ aflag = mp->m_flags & MNT_ASYNC; mp->m_flags &= ~MNT_ASYNC; /* Don't want async when unmounting */ ufs_sync(mp); if (iflush(dev) < 0) { mp->m_flags |= aflag; return (EBUSY); } ip = mp->m_inodp; ip->i_flag &= ~IMOUNT; irele(ip); mp->m_inodp = 0; mp->m_dev = 0; (*bdevsw[major(dev)].d_close)(dev, 0, S_IFBLK); binval(dev); return (0); } void umount() { struct a { char *fspec; } *uap = (struct a *)u.u_arg; u.u_error = unmount1 (uap->fspec); } ================================================ FILE: sys/kern/ufs_namei.c ================================================ /* * Copyright (c) 1982 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include #include #include #include #include #include #include #include #include #include int dirchk = 0; /* * Structures associated with name cacheing. */ #define NCHHASH 16 /* size of hash table */ #if ((NCHHASH)&((NCHHASH)-1)) != 0 #define NHASH(h, i, d) ((unsigned)((h) + (i) + 13 * (int)(d)) % (NCHHASH)) #else #define NHASH(h, i, d) ((unsigned)((h) + (i) + 13 * (int)(d)) & ((NCHHASH)-1)) #endif union nchash { union nchash *nch_head[2]; struct namecache *nch_chain[2]; } nchash[NCHHASH]; #define nch_forw nch_chain[0] #define nch_back nch_chain[1] struct namecache *nchhead, **nchtail; /* LRU chain pointers */ static void dirbad (ip, offset, how) struct inode *ip; off_t offset; char *how; { printf ("%s: bad dir I=%u off %ld: %s\n", ip->i_fs->fs_fsmnt, ip->i_number, offset, how); } /* * Return buffer with contents of block "offset" * from the beginning of directory "ip". If "res" * is non-zero, fill it in with a pointer to the * remaining space in the directory. */ static struct buf * blkatoff(ip, offset, res) struct inode *ip; off_t offset; char **res; { daddr_t lbn = lblkno(offset); register struct buf *bp; daddr_t bn; char *junk; bn = bmap(ip, lbn, B_READ, 0); if (u.u_error) return (0); if (bn == (daddr_t)-1) { dirbad(ip, offset, "hole in dir"); return (0); } bp = bread(ip->i_dev, bn); if (bp->b_flags & B_ERROR) { brelse(bp); return (0); } junk = (caddr_t) bp->b_addr; if (res) *res = junk + (u_int)blkoff(offset); return (bp); } /* * Do consistency checking on a directory entry: * record length must be multiple of 4 * entry must fit in rest of its DIRBLKSIZ block * record must be large enough to contain entry * name is not longer than MAXNAMLEN * name must be as long as advertised, and null terminated */ static int dirbadentry (ep, entryoffsetinblock) register struct direct *ep; int entryoffsetinblock; { register int i; if ((ep->d_reclen & 0x3) != 0 || ep->d_reclen > DIRBLKSIZ - (entryoffsetinblock & (DIRBLKSIZ - 1)) || ep->d_reclen < DIRSIZ(ep) || ep->d_namlen > MAXNAMLEN) return (1); for (i = 0; i < ep->d_namlen; i++) if (ep->d_name[i] == '\0') return (1); return (ep->d_name[i]); } /* * Convert a pathname into a pointer to a locked inode. * This is a very central and rather complicated routine. * If the file system is not maintained in a strict tree hierarchy, * this can result in a deadlock situation (see comments in code below). * * The flag argument is LOOKUP, CREATE, or DELETE depending on whether * the name is to be looked up, created, or deleted. When CREATE or * DELETE is specified, information usable in creating or deleteing a * directory entry is also calculated. If flag has LOCKPARENT or'ed * into it and the target of the pathname exists, namei returns both * the target and its parent directory locked. When creating and * LOCKPARENT is specified, the target may not be ".". When deleting * and LOCKPARENT is specified, the target may be ".", but the caller * must check to insure it does an irele and iput instead of two iputs. * * The FOLLOW flag is set when symbolic links are to be followed * when they occur at the end of the name translation process. * Symbolic links are always followed for all other pathname * components other than the last. * * Name caching works as follows: * * Names found by directory scans are retained in a cache * for future reference. It is managed LRU, so frequently * used names will hang around. Cache is indexed by hash value * obtained from (ino,dev,name) where ino & dev refer to the * directory containing name. * * For simplicity (and economy of storage), names longer than * a maximum length of NCHNAMLEN are not cached; they occur * infrequently in any case, and are almost never of interest. * * Upon reaching the last segment of a path, if the reference * is for DELETE, or NOCACHE is set (rewrite), and the * name is located in the cache, it will be dropped. * * Overall outline of namei: * * copy in name * get starting directory * dirloop: * check accessibility of directory * dirloop2: * copy next component of name to ndp->ni_dent * handle degenerate case where name is null string * look for name in cache, if found, then if at end of path * and deleting or creating, drop it, else to haveino * search for name in directory, to found or notfound * notfound: * if creating, return locked directory, leaving info on avail. slots * else return error * found: * if at end of path and deleting, return information to allow delete * if at end of path and rewriting (CREATE and LOCKPARENT), lock target * inode and return info to allow rewrite * if .. and on mounted filesys, look in mount table for parent * if not at end, add name to cache; if at end and neither creating * nor deleting, add name to cache * haveino: * if symbolic link, massage name in buffer and continue at dirloop * if more components of name, do next level at dirloop * return the answer as locked inode * * NOTE: (LOOKUP | LOCKPARENT) currently returns the parent inode, * but unlocked. */ struct inode * namei (ndp) register struct nameidata *ndp; { register char *cp; /* pointer into pathname argument */ /* these variables refer to things which must be freed or unlocked */ struct inode *dp = 0; /* the directory we are searching */ struct namecache *ncp = 0; /* cache slot for entry */ struct fs *fs; /* file system that directory is in */ struct buf *bp = 0; /* a buffer of directory entries */ struct direct *ep; /* the current directory entry */ int entryoffsetinblock = 0; /* offset of ep in bp's buffer */ /* these variables hold information about the search for a slot */ enum {NONE, COMPACT, FOUND} slotstatus; off_t slotoffset = -1; /* offset of area with free space */ int slotsize = 0; /* size of area at slotoffset */ int slotfreespace = 0; /* amount of space free in slot */ int slotneeded = 0; /* size of the entry we're seeking */ /* */ int numdirpasses; /* strategy for directory search */ off_t endsearch; /* offset to end directory search */ off_t prevoff = 0; /* ndp->ni_offset of previous entry */ int nlink = 0; /* number of symbolic links taken */ struct inode *pdp; /* saved dp during symlink work */ register int i; int error; int lockparent; int docache; /* == 0 do not cache last component */ int makeentry; /* != 0 if name to be added to cache */ unsigned hash; /* value of name hash for entry */ union nchash *nhp = 0; /* cache chain head for entry */ int isdotdot; /* != 0 if current name is ".." */ int flag; /* op ie, LOOKUP, CREATE, or DELETE */ off_t enduseful; /* pointer past last used dir slot */ char path[MAXPATHLEN]; /* current path */ lockparent = ndp->ni_nameiop & LOCKPARENT; docache = (ndp->ni_nameiop & NOCACHE) ^ NOCACHE; flag = ndp->ni_nameiop &~ (LOCKPARENT|NOCACHE|FOLLOW); if (flag == DELETE || lockparent) docache = 0; /* * Copy the name into the buffer. */ error = copystr (ndp->ni_dirp, path, MAXPATHLEN, (u_int*) 0); if (error) { u.u_error = error; goto retNULL; } /* * Get starting directory. */ cp = path; if (*cp == '/') { while (*cp == '/') cp++; if ((dp = u.u_rdir) == NULL) dp = rootdir; } else dp = u.u_cdir; fs = dp->i_fs; ILOCK(dp); dp->i_count++; ndp->ni_endoff = 0; /* * We come to dirloop to search a new directory. * The directory must be locked so that it can be * iput, and fs must be already set to dp->i_fs. */ dirloop: /* * Check accessibility of directory. */ if ((dp->i_mode&IFMT) != IFDIR) { u.u_error = ENOTDIR; goto bad; } if (access(dp, IEXEC)) goto bad; dirloop2: /* * Copy next component of name to ndp->ni_dent. */ hash = 0; for (i = 0; *cp != 0 && *cp != '/'; cp++) { if (i >= MAXNAMLEN) { u.u_error = ENAMETOOLONG; goto bad; } if (*cp & 0200) if ((*cp&0377) == ('/'|0200) || flag != DELETE) { u.u_error = EINVAL; goto bad; } ndp->ni_dent.d_name[i++] = *cp; hash += (unsigned char)*cp * i; } ndp->ni_dent.d_namlen = i; ndp->ni_dent.d_name[i] = '\0'; isdotdot = (i == 2 && ndp->ni_dent.d_name[0] == '.' && ndp->ni_dent.d_name[1] == '.'); makeentry = 1; if (*cp == '\0' && docache == 0) makeentry = 0; /* * Check for degenerate name (e.g. / or "") * which is a way of talking about a directory, * e.g. like "/." or ".". */ if (ndp->ni_dent.d_name[0] == '\0') { if (flag != LOOKUP || lockparent) { u.u_error = EISDIR; goto bad; } goto retDP; } /* * We now have a segment name to search for, and a directory to search. * * Before tediously performing a linear scan of the directory, * check the name cache to see if the directory/name pair * we are looking for is known already. We don't do this * if the segment name is long, simply so the cache can avoid * holding long names (which would either waste space, or * add greatly to the complexity). */ if (ndp->ni_dent.d_namlen > NCHNAMLEN) { nchstats.ncs_long++; makeentry = 0; } else { nhp = &nchash[NHASH(hash, dp->i_number, dp->i_dev)]; for (ncp = nhp->nch_forw; ncp != (struct namecache *)nhp; ncp = ncp->nc_forw) { if (ncp->nc_ino == dp->i_number && ncp->nc_dev == dp->i_dev && ncp->nc_nlen == ndp->ni_dent.d_namlen && !bcmp(ncp->nc_name, ndp->ni_dent.d_name, (unsigned)ncp->nc_nlen)) break; } if (ncp == (struct namecache *)nhp) { nchstats.ncs_miss++; ncp = NULL; } else { if (ncp->nc_id != ncp->nc_ip->i_id) nchstats.ncs_falsehits++; else if (!makeentry) nchstats.ncs_badhits++; else { /* * move this slot to end of LRU * chain, if not already there */ if (ncp->nc_nxt) { /* remove from LRU chain */ *ncp->nc_prev = ncp->nc_nxt; ncp->nc_nxt->nc_prev = ncp->nc_prev; /* and replace at end of it */ ncp->nc_nxt = NULL; ncp->nc_prev = nchtail; *nchtail = ncp; nchtail = &ncp->nc_nxt; } /* * Get the next inode in the path. * See comment above other `IUNLOCK' code for * an explaination of the locking protocol. */ pdp = dp; if (!isdotdot || dp != u.u_rdir) dp = ncp->nc_ip; if (dp == NULL) panic("namei: null cache ino"); if (pdp == dp) dp->i_count++; else if (isdotdot) { IUNLOCK(pdp); igrab(dp); } else { igrab(dp); IUNLOCK(pdp); } /* * Verify that the inode that we got * did not change while we were waiting * for it to be locked. */ if (ncp->nc_id != ncp->nc_ip->i_id) { iput(dp); ILOCK(pdp); dp = pdp; nchstats.ncs_falsehits++; } else { ndp->ni_dent.d_ino = dp->i_number; /* ni_dent.d_reclen is garbage ... */ nchstats.ncs_goodhits++; goto haveino; } } /* * Last component and we are renaming or deleting, * the cache entry is invalid, or otherwise don't * want cache entry to exist. */ /* remove from LRU chain */ *ncp->nc_prev = ncp->nc_nxt; if (ncp->nc_nxt) ncp->nc_nxt->nc_prev = ncp->nc_prev; else nchtail = ncp->nc_prev; remque(ncp); /* remove from hash chain */ /* insert at head of LRU list (first to grab) */ ncp->nc_nxt = nchhead; ncp->nc_prev = &nchhead; nchhead->nc_prev = &ncp->nc_nxt; nchhead = ncp; /* and make a dummy hash chain */ ncp->nc_forw = ncp; ncp->nc_back = ncp; ncp = NULL; } } /* * Suppress search for slots unless creating * file and at end of pathname, in which case * we watch for a place to put the new file in * case it doesn't already exist. */ slotstatus = FOUND; if (flag == CREATE && *cp == 0) { slotstatus = NONE; slotfreespace = 0; slotneeded = DIRSIZ(&ndp->ni_dent); } /* * If this is the same directory that this process * previously searched, pick up where we last left off. * We cache only lookups as these are the most common * and have the greatest payoff. Caching CREATE has little * benefit as it usually must search the entire directory * to determine that the entry does not exist. Caching the * location of the last DELETE has not reduced profiling time * and hence has been removed in the interest of simplicity. */ if (flag != LOOKUP || dp->i_number != u.u_ncache.nc_inumber || dp->i_dev != u.u_ncache.nc_dev) { ndp->ni_offset = 0; numdirpasses = 1; } else { if (u.u_ncache.nc_prevoffset > dp->i_size) u.u_ncache.nc_prevoffset = 0; ndp->ni_offset = u.u_ncache.nc_prevoffset; entryoffsetinblock = blkoff(ndp->ni_offset); if (entryoffsetinblock != 0) { bp = blkatoff(dp, ndp->ni_offset, (char **)0); if (bp == 0) goto bad; } numdirpasses = 2; nchstats.ncs_2passes++; } endsearch = roundup(dp->i_size, DIRBLKSIZ); enduseful = 0; searchloop: while (ndp->ni_offset < endsearch) { /* * If offset is on a block boundary, * read the next directory block. * Release previous if it exists. */ if (blkoff(ndp->ni_offset) == 0) { if (bp != NULL) { brelse(bp); } bp = blkatoff(dp, ndp->ni_offset, (char **)0); if (bp == 0) goto bad; entryoffsetinblock = 0; } /* * If still looking for a slot, and at a DIRBLKSIZE * boundary, have to start looking for free space again. */ if (slotstatus == NONE && (entryoffsetinblock&(DIRBLKSIZ-1)) == 0) { slotoffset = -1; slotfreespace = 0; } /* * Get pointer to next entry. * Full validation checks are slow, so we only check * enough to insure forward progress through the * directory. Complete checks can be run by patching * "dirchk" to be true. */ ep = (struct direct*) ((caddr_t) bp->b_addr + entryoffsetinblock); if (ep->d_reclen == 0 || (dirchk && dirbadentry (ep, entryoffsetinblock))) { dirbad(dp, ndp->ni_offset, "mangled entry"); i = DIRBLKSIZ - (entryoffsetinblock & (DIRBLKSIZ - 1)); ndp->ni_offset += i; entryoffsetinblock += i; continue; } /* * If an appropriate sized slot has not yet been found, * check to see if one is available. Also accumulate space * in the current block so that we can determine if * compaction is viable. */ if (slotstatus != FOUND) { int size = ep->d_reclen; if (ep->d_ino != 0) size -= DIRSIZ(ep); if (size > 0) { if (size >= slotneeded) { slotstatus = FOUND; slotoffset = ndp->ni_offset; slotsize = ep->d_reclen; } else if (slotstatus == NONE) { slotfreespace += size; if (slotoffset == -1) slotoffset = ndp->ni_offset; if (slotfreespace >= slotneeded) { slotstatus = COMPACT; slotsize = ndp->ni_offset + ep->d_reclen - slotoffset; } } } } /* * Check for a name match. */ if (ep->d_ino) { if (ep->d_namlen == ndp->ni_dent.d_namlen && !bcmp(ndp->ni_dent.d_name, ep->d_name, (unsigned)ep->d_namlen)) goto found; } prevoff = ndp->ni_offset; ndp->ni_offset += ep->d_reclen; entryoffsetinblock += ep->d_reclen; if (ep->d_ino) enduseful = ndp->ni_offset; } /* notfound: */ /* * If we started in the middle of the directory and failed * to find our target, we must check the beginning as well. */ if (numdirpasses == 2) { numdirpasses--; ndp->ni_offset = 0; endsearch = u.u_ncache.nc_prevoffset; goto searchloop; } /* * If creating, and at end of pathname and current * directory has not been removed, then can consider * allowing file to be created. */ if (flag == CREATE && *cp == 0 && dp->i_nlink != 0) { /* * Access for write is interpreted as allowing * creation of files in the directory. */ if (access(dp, IWRITE)) goto bad; /* * Return an indication of where the new directory * entry should be put. If we didn't find a slot, * then set ndp->ni_count to 0 indicating that the new * slot belongs at the end of the directory. If we found * a slot, then the new entry can be put in the range * [ndp->ni_offset .. ndp->ni_offset + ndp->ni_count) */ if (slotstatus == NONE) { ndp->ni_offset = roundup(dp->i_size, DIRBLKSIZ); ndp->ni_count = 0; enduseful = ndp->ni_offset; } else { ndp->ni_offset = slotoffset; ndp->ni_count = slotsize; if (enduseful < slotoffset + slotsize) enduseful = slotoffset + slotsize; } ndp->ni_endoff = roundup(enduseful, DIRBLKSIZ); dp->i_flag |= IUPD|ICHG; if (bp) { brelse(bp); } /* * We return with the directory locked, so that * the parameters we set up above will still be * valid if we actually decide to do a direnter(). * We return NULL to indicate that the entry doesn't * currently exist, leaving a pointer to the (locked) * directory inode in ndp->ni_pdir. */ ndp->ni_pdir = dp; goto retNULL; } u.u_error = ENOENT; goto bad; found: if (numdirpasses == 2) nchstats.ncs_pass2++; /* * Check that directory length properly reflects presence * of this entry. */ if (entryoffsetinblock + DIRSIZ(ep) > dp->i_size) { dirbad(dp, ndp->ni_offset, "i_size too small"); dp->i_size = entryoffsetinblock + DIRSIZ(ep); dp->i_flag |= IUPD|ICHG; } /* * Found component in pathname. * If the final component of path name, save information * in the cache as to where the entry was found. */ if (*cp == '\0' && flag == LOOKUP) { u.u_ncache.nc_prevoffset = ndp->ni_offset &~ (DIRBLKSIZ - 1); u.u_ncache.nc_inumber = dp->i_number; u.u_ncache.nc_dev = dp->i_dev; } /* * Save directory entry's inode number and reclen in ndp->ni_dent, * and release directory buffer. */ ndp->ni_dent.d_ino = ep->d_ino; ndp->ni_dent.d_reclen = ep->d_reclen; brelse(bp); bp = NULL; /* * If deleting, and at end of pathname, return * parameters which can be used to remove file. * If the lockparent flag isn't set, we return only * the directory (in ndp->ni_pdir), otherwise we go * on and lock the inode, being careful with ".". */ if (flag == DELETE && *cp == 0) { /* * Write access to directory required to delete files. */ if (access(dp, IWRITE)) goto bad; ndp->ni_pdir = dp; /* for dirremove() */ /* * Return pointer to current entry in ndp->ni_offset, * and distance past previous entry (if there * is a previous entry in this block) in ndp->ni_count. * Save directory inode pointer in ndp->ni_pdir for dirremove(). */ if ((ndp->ni_offset&(DIRBLKSIZ-1)) == 0) ndp->ni_count = 0; else ndp->ni_count = ndp->ni_offset - prevoff; if (lockparent) { if (dp->i_number == ndp->ni_dent.d_ino) dp->i_count++; else { dp = iget(dp->i_dev, fs, ndp->ni_dent.d_ino); if (dp == NULL) { iput(ndp->ni_pdir); goto bad; } /* * If directory is "sticky", then user must own * the directory, or the file in it, else he * may not delete it (unless he's root). This * implements append-only directories. */ if ((ndp->ni_pdir->i_mode & ISVTX) && u.u_uid != 0 && u.u_uid != ndp->ni_pdir->i_uid && dp->i_uid != u.u_uid) { iput(ndp->ni_pdir); u.u_error = EPERM; goto bad; } } } goto retDP; } /* * Special handling for ".." allowing chdir out of mounted * file system: indirect .. in root inode to reevaluate * in directory file system was mounted on. */ if (isdotdot) { if (dp == u.u_rdir) { ndp->ni_dent.d_ino = dp->i_number; makeentry = 0; } else if (ndp->ni_dent.d_ino == ROOTINO && dp->i_number == ROOTINO) { register struct mount *mp; register dev_t d; d = dp->i_dev; for (mp = &mount[1]; mp < &mount[NMOUNT]; mp++) if (mp->m_inodp && mp->m_dev == d) { iput(dp); dp = mp->m_inodp; ILOCK(dp); dp->i_count++; fs = dp->i_fs; cp -= 2; /* back over .. */ goto dirloop2; } } } /* * If rewriting (rename), return the inode and the * information required to rewrite the present directory * Must get inode of directory entry to verify it's a * regular file, or empty directory. */ if ((flag == CREATE && lockparent) && *cp == 0) { if (access(dp, IWRITE)) goto bad; ndp->ni_pdir = dp; /* for dirrewrite() */ /* * Careful about locking second inode. * This can only occur if the target is ".". */ if (dp->i_number == ndp->ni_dent.d_ino) { u.u_error = EISDIR; /* XXX */ goto bad; } dp = iget(dp->i_dev, fs, ndp->ni_dent.d_ino); if (dp == NULL) { iput(ndp->ni_pdir); goto bad; } goto retDP; } /* * Check for symbolic link, which may require us to massage the * name before we continue translation. We do not `iput' the * directory because we may need it again if the symbolic link * is relative to the current directory. Instead we save it * unlocked as "pdp". We must get the target inode before unlocking * the directory to insure that the inode will not be removed * before we get it. We prevent deadlock by always fetching * inodes from the root, moving down the directory tree. Thus * when following backward pointers ".." we must unlock the * parent directory before getting the requested directory. * There is a potential race condition here if both the current * and parent directories are removed before the `iget' for the * inode associated with ".." returns. We hope that this occurs * infrequently since we cannot avoid this race condition without * implementing a sophisticated deadlock detection algorithm. * Note also that this simple deadlock detection scheme will not * work if the file system has any hard links other than ".." * that point backwards in the directory structure. */ pdp = dp; if (isdotdot) { IUNLOCK(pdp); /* race to get the inode */ dp = iget(dp->i_dev, fs, ndp->ni_dent.d_ino); if (dp == NULL) goto bad2; } else if (dp->i_number == ndp->ni_dent.d_ino) { dp->i_count++; /* we want ourself, ie "." */ } else { dp = iget(dp->i_dev, fs, ndp->ni_dent.d_ino); IUNLOCK(pdp); if (dp == NULL) goto bad2; } /* * Insert name into cache if appropriate. */ if (makeentry) { if (ncp != NULL) panic("namei: duplicating cache"); /* * Free the cache slot at head of lru chain. */ ncp = nchhead; if (ncp) { /* remove from lru chain */ *ncp->nc_prev = ncp->nc_nxt; if (ncp->nc_nxt) ncp->nc_nxt->nc_prev = ncp->nc_prev; else nchtail = ncp->nc_prev; remque(ncp); /* remove from old hash chain */ /* grab the inode we just found */ ncp->nc_ip = dp; /* fill in cache info */ ncp->nc_ino = pdp->i_number; /* parents inum */ ncp->nc_dev = pdp->i_dev; /* & device */ ncp->nc_idev = dp->i_dev; /* our device */ ncp->nc_id = dp->i_id; /* identifier */ ncp->nc_nlen = ndp->ni_dent.d_namlen; bcopy(ndp->ni_dent.d_name, ncp->nc_name, (unsigned)ncp->nc_nlen); /* link at end of lru chain */ ncp->nc_nxt = NULL; ncp->nc_prev = nchtail; *nchtail = ncp; nchtail = &ncp->nc_nxt; /* and insert on hash chain */ insque(ncp, nhp); } } haveino: fs = dp->i_fs; /* * Check for symbolic link */ if ((dp->i_mode & IFMT) == IFLNK && ((ndp->ni_nameiop & FOLLOW) || *cp == '/')) { u_int pathlen = strlen(cp) + 1; if (dp->i_size + pathlen >= MAXPATHLEN - 1) { u.u_error = ENAMETOOLONG; goto bad2; } if (++nlink > MAXSYMLINKS) { u.u_error = ELOOP; goto bad2; } bp = bread(dp->i_dev, bmap(dp, (daddr_t)0, B_READ, 0)); if (bp->b_flags & B_ERROR) { brelse(bp); bp = NULL; goto bad2; } /* * Shift the rest of path further down the buffer, then * copy link path into the first part of the buffer. */ bcopy(cp, path + (u_int)dp->i_size, pathlen); bcopy(bp->b_addr, path, (u_int)dp->i_size); brelse(bp); bp = NULL; cp = path; iput(dp); if (*cp == '/') { irele(pdp); while (*cp == '/') cp++; if ((dp = u.u_rdir) == NULL) dp = rootdir; ILOCK(dp); dp->i_count++; } else { dp = pdp; ILOCK(dp); } fs = dp->i_fs; goto dirloop; } /* * Not a symbolic link. If more pathname, * continue at next component, else return. */ if (*cp == '/') { while (*cp == '/') cp++; irele(pdp); goto dirloop; } if (lockparent) ndp->ni_pdir = pdp; else irele(pdp); retDP: ndp->ni_ip = dp; return (dp); bad2: irele(pdp); bad: if (bp) { brelse(bp); } if (dp) iput(dp); retNULL: ndp->ni_ip = NULL; return (NULL); } /* * Write a directory entry after a call to namei, using the parameters * which it left in the u. area. The argument ip is the inode which * the new directory entry will refer to. The u. area field ndp->ni_pdir is * a pointer to the directory to be written, which was left locked by * namei. Remaining parameters (ndp->ni_offset, ndp->ni_count) indicate * how the space for the new entry is to be gotten. */ int direnter(ip, ndp) struct inode *ip; register struct nameidata *ndp; { register struct direct *ep, *nep; register struct inode *dp = ndp->ni_pdir; struct buf *bp; int loc, spacefree, error = 0; u_int dsize; int newentrysize; char *dirbuf; ndp->ni_dent.d_ino = ip->i_number; newentrysize = DIRSIZ(&ndp->ni_dent); if (ndp->ni_count == 0) { /* * If ndp->ni_count is 0, then namei could find no space in the * directory. In this case ndp->ni_offset will be on a directory * block boundary and we will write the new entry into a fresh * block. */ if (ndp->ni_offset&(DIRBLKSIZ-1)) panic("wdir: newblk"); ndp->ni_dent.d_reclen = DIRBLKSIZ; error = rdwri (UIO_WRITE, dp, (caddr_t)&ndp->ni_dent, newentrysize, ndp->ni_offset, IO_UNIT|IO_SYNC, (int *)0); dp->i_size = roundup(dp->i_size, DIRBLKSIZ); iput(dp); return (error); } /* * If ndp->ni_count is non-zero, then namei found space for the new * entry in the range ndp->ni_offset to ndp->ni_offset + ndp->ni_count. * in the directory. To use this space, we may have to compact * the entries located there, by copying them together towards * the beginning of the block, leaving the free space in * one usable chunk at the end. */ /* * Increase size of directory if entry eats into new space. * This should never push the size past a new multiple of * DIRBLKSIZE. * * N.B. - THIS IS AN ARTIFACT OF 4.2 AND SHOULD NEVER HAPPEN. */ if (ndp->ni_offset + ndp->ni_count > dp->i_size) dp->i_size = ndp->ni_offset + ndp->ni_count; /* * Get the block containing the space for the new directory * entry. Should return error by result instead of u.u_error. */ bp = blkatoff(dp, ndp->ni_offset, (char **)&dirbuf); if (bp == 0) { iput(dp); return (u.u_error); } /* * Find space for the new entry. In the simple case, the * entry at offset base will have the space. If it does * not, then namei arranged that compacting the region * ndp->ni_offset to ndp->ni_offset+ndp->ni_count would yield the space. */ ep = (struct direct *)dirbuf; dsize = DIRSIZ(ep); spacefree = ep->d_reclen - dsize; for (loc = ep->d_reclen; loc < ndp->ni_count; ) { nep = (struct direct *)(dirbuf + loc); if (ep->d_ino) { /* trim the existing slot */ ep->d_reclen = dsize; ep = (struct direct *)((char *)ep + dsize); } else { /* overwrite; nothing there; header is ours */ spacefree += dsize; } dsize = DIRSIZ(nep); spacefree += nep->d_reclen - dsize; loc += nep->d_reclen; bcopy((caddr_t)nep, (caddr_t)ep, dsize); } /* * Update the pointer fields in the previous entry (if any), * copy in the new entry, and write out the block. */ if (ep->d_ino == 0) { if (spacefree + dsize < newentrysize) panic("wdir: compact1"); ndp->ni_dent.d_reclen = spacefree + dsize; } else { if (spacefree < newentrysize) panic("wdir: compact2"); ndp->ni_dent.d_reclen = spacefree; ep->d_reclen = dsize; ep = (struct direct *)((char *)ep + dsize); } bcopy((caddr_t)&ndp->ni_dent, (caddr_t)ep, (u_int)newentrysize); bwrite(bp); dp->i_flag |= IUPD|ICHG; if (ndp->ni_endoff && ndp->ni_endoff < dp->i_size) itrunc(dp, (u_long)ndp->ni_endoff, 0); iput(dp); return (error); } /* * Remove a directory entry after a call to namei, using the * parameters which it left in the u. area. The u. entry * ni_offset contains the offset into the directory of the * entry to be eliminated. The ni_count field contains the * size of the previous record in the directory. If this * is 0, the first entry is being deleted, so we need only * zero the inode number to mark the entry as free. If the * entry isn't the first in the directory, we must reclaim * the space of the now empty record by adding the record size * to the size of the previous entry. */ int dirremove (ndp) register struct nameidata *ndp; { register struct inode *dp = ndp->ni_pdir; register struct buf *bp; struct direct *ep; if (ndp->ni_count == 0) { /* * First entry in block: set d_ino to zero. */ ndp->ni_dent.d_ino = 0; (void) rdwri (UIO_WRITE, dp, (caddr_t) &ndp->ni_dent, (int) DIRSIZ(&ndp->ni_dent), ndp->ni_offset, IO_UNIT | IO_SYNC, (int*) 0); } else { /* * Collapse new free space into previous entry. */ bp = blkatoff(dp, ndp->ni_offset - ndp->ni_count, (char **)&ep); if (bp == 0) return (0); ep->d_reclen += ndp->ni_dent.d_reclen; bwrite(bp); dp->i_flag |= IUPD|ICHG; } return (1); } /* * Rewrite an existing directory entry to point at the inode * supplied. The parameters describing the directory entry are * set up by a call to namei. */ void dirrewrite(dp, ip, ndp) register struct inode *dp; struct inode *ip; register struct nameidata *ndp; { ndp->ni_dent.d_ino = ip->i_number; u.u_error = rdwri (UIO_WRITE, dp, (caddr_t) &ndp->ni_dent, (int) DIRSIZ(&ndp->ni_dent), ndp->ni_offset, IO_UNIT | IO_SYNC, (int*) 0); iput(dp); } /* * Check if a directory is empty or not. * Inode supplied must be locked. * * Using a struct dirtemplate here is not precisely * what we want, but better than using a struct direct. * * NB: does not handle corrupted directories. */ int dirempty (ip, parentino) register struct inode *ip; ino_t parentino; { register off_t off; struct dirtemplate dbuf; register struct direct *dp = (struct direct *)&dbuf; int error, count; #define MINDIRSIZ (sizeof (struct dirtemplate) / 2) for (off = 0; off < ip->i_size; off += dp->d_reclen) { error = rdwri (UIO_READ, ip, (caddr_t) dp, MINDIRSIZ, off, IO_UNIT, &count); /* * Since we read MINDIRSIZ, residual must * be 0 unless we're at end of file. */ if (error || count != 0) return (0); /* avoid infinite loops */ if (dp->d_reclen == 0) return (0); /* skip empty entries */ if (dp->d_ino == 0) continue; /* accept only "." and ".." */ if (dp->d_namlen > 2) return (0); if (dp->d_name[0] != '.') return (0); /* * At this point d_namlen must be 1 or 2. * 1 implies ".", 2 implies ".." if second * char is also "." */ if (dp->d_namlen == 1) continue; if (dp->d_name[1] == '.' && dp->d_ino == parentino) continue; return (0); } return (1); } /* * Check if source directory is in the path of the target directory. * Target is supplied locked, source is unlocked. * The target is always iput() before returning. */ int checkpath (source, target) struct inode *source, *target; { struct dirtemplate dirbuf; register struct inode *ip; register int error = 0; ip = target; if (ip->i_number == source->i_number) { error = EEXIST; goto out; } if (ip->i_number == ROOTINO) goto out; for (;;) { if ((ip->i_mode&IFMT) != IFDIR) { error = ENOTDIR; break; } error = rdwri (UIO_READ, ip, (caddr_t) &dirbuf, sizeof(struct dirtemplate), (off_t) 0, IO_UNIT, (int*) 0); if (error != 0) break; if (dirbuf.dotdot_namlen != 2 || dirbuf.dotdot_name[0] != '.' || dirbuf.dotdot_name[1] != '.') { error = ENOTDIR; break; } if (dirbuf.dotdot_ino == source->i_number) { error = EINVAL; break; } if (dirbuf.dotdot_ino == ROOTINO) break; iput(ip); ip = iget(ip->i_dev, ip->i_fs, dirbuf.dotdot_ino); if (ip == NULL) { error = u.u_error; break; } } out: if (error == ENOTDIR) printf("checkpath: .. !dir\n"); if (ip != NULL) iput(ip); return (error); } /* * Name cache initialization, from main() when we are booting */ void nchinit() { register union nchash *nchp; register struct namecache *ncp; nchhead = 0; nchtail = &nchhead; for (ncp = namecache; ncp < &namecache[NNAMECACHE]; ncp++) { ncp->nc_forw = ncp; /* hash chain */ ncp->nc_back = ncp; ncp->nc_nxt = NULL; /* lru chain */ *nchtail = ncp; ncp->nc_prev = nchtail; nchtail = &ncp->nc_nxt; /* all else is zero already */ } for (nchp = nchash; nchp < &nchash[NCHHASH]; nchp++) { nchp->nch_head[0] = nchp; nchp->nch_head[1] = nchp; } } /* * Cache flush, called when filesys is umounted to * remove entries that would now be invalid * * The line "nxtcp = nchhead" near the end is to avoid potential problems * if the cache lru chain is modified while we are dumping the * inode. This makes the algorithm O(n^2), but do you think I care? */ void nchinval (dev) register dev_t dev; { register struct namecache *ncp, *nxtcp; for (ncp = nchhead; ncp; ncp = nxtcp) { nxtcp = ncp->nc_nxt; if (ncp->nc_ip == NULL || (ncp->nc_idev != dev && ncp->nc_dev != dev)) continue; /* free the resources we had */ ncp->nc_idev = NODEV; ncp->nc_dev = NODEV; ncp->nc_id = NULL; ncp->nc_ino = 0; ncp->nc_ip = NULL; remque(ncp); /* remove entry from its hash chain */ ncp->nc_forw = ncp; /* and make a dummy one */ ncp->nc_back = ncp; /* delete this entry from LRU chain */ *ncp->nc_prev = nxtcp; if (nxtcp) nxtcp->nc_prev = ncp->nc_prev; else nchtail = ncp->nc_prev; /* cause rescan of list, it may have altered */ nxtcp = nchhead; /* put the now-free entry at head of LRU */ ncp->nc_nxt = nxtcp; ncp->nc_prev = &nchhead; nxtcp->nc_prev = &ncp->nc_nxt; nchhead = ncp; } } /* * Name cache invalidation of all entries. */ void cinvalall() { register struct namecache *ncp, *encp = &namecache[NNAMECACHE]; for (ncp = namecache; ncp < encp; ncp++) ncp->nc_id = 0; } ================================================ FILE: sys/kern/ufs_subr.c ================================================ /* * Copyright (c) 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include #include #include #include #include #include #include #include #include int updlock; /* lock for sync */ /* * Go through the mount table looking for filesystems which have been modified. * For each "dirty" filesystem call 'ufs_sync' to flush changed inodes, data * blocks and the superblock to disc. */ void sync() { register struct mount *mp; register struct fs *fs; int async; if (updlock) return; updlock++; for (mp = &mount[0]; mp < &mount[NMOUNT]; mp++) { if (mp->m_inodp == NULL || mp->m_dev == NODEV) continue; fs = &mp->m_filsys; if (fs->fs_fmod == 0 || fs->fs_ilock || fs->fs_flock) continue; async = mp->m_flags & MNT_ASYNC; mp->m_flags &= ~MNT_ASYNC; ufs_sync(mp); mp->m_flags |= async; } updlock = 0; } /* * Flush all the blocks associated with an inode. * There are two strategies based on the size of the file; * large files are those with more than NBUF/2 blocks. * Large files * Walk through the buffer pool and push any dirty pages * associated with the device on which the file resides. * Small files * Look up each block in the file to see if it is in the * buffer pool writing any that are found to disk. * Note that we make a more stringent check of * writing out any block in the buffer pool that may * overlap the inode. This brings the inode up to * date with recent mods to the cooked device. */ void syncip(ip) struct inode *ip; { register struct buf *bp; register struct buf *lastbufp; long lbn, lastlbn; register int s; daddr_t blkno; lastlbn = howmany(ip->i_size, DEV_BSIZE); if (lastlbn < NBUF / 2) { for (lbn = 0; lbn < lastlbn; lbn++) { blkno = fsbtodb(bmap(ip, lbn, B_READ, 0)); blkflush(ip->i_dev, blkno); } } else { lastbufp = &buf[NBUF]; for (bp = buf; bp < lastbufp; bp++) { if (bp->b_dev != ip->i_dev || (bp->b_flags & B_DELWRI) == 0) continue; s = splbio(); if (bp->b_flags & B_BUSY) { bp->b_flags |= B_WANTED; sleep((caddr_t)bp, PRIBIO+1); splx(s); bp--; continue; } splx(s); notavail(bp); bwrite(bp); } } ip->i_flag |= ICHG; iupdat(ip, &time, &time, 1); } /* * Check that a specified block number is in range. */ int badblock (fp, bn) register struct fs *fp; daddr_t bn; { if (bn < fp->fs_isize || bn >= fp->fs_fsize) { printf("bad block %D, ",bn); fserr(fp, "bad block"); return (1); } return (0); } /* * Getfs maps a device number into a pointer to the incore super block. * * The algorithm is a linear search through the mount table. A * consistency check of the super block magic number is performed. * * panic: no fs -- the device is not mounted. * this "cannot happen" */ struct fs * getfs(dev) dev_t dev; { register struct mount *mp; register struct fs *fs; for (mp = &mount[0]; mp < &mount[NMOUNT]; mp++) { if (mp->m_inodp == NULL || mp->m_dev != dev) continue; fs = &mp->m_filsys; if (fs->fs_nfree > NICFREE || fs->fs_ninode > NICINOD) { fserr(fs, "bad count"); fs->fs_nfree = fs->fs_ninode = 0; } return(fs); } printf("no fs on dev (%u,%u)\n", major(dev), minor(dev)); return((struct fs *) NULL); } ================================================ FILE: sys/kern/ufs_syscalls.c ================================================ /* * Copyright (c) 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include #include #include #include #include #include #include #include #include #include /* * Common routine for chroot and chdir. */ static void chdirec(ipp) register struct inode **ipp; { register struct inode *ip; struct a { char *fname; } *uap = (struct a *)u.u_arg; struct nameidata nd; register struct nameidata *ndp = &nd; NDINIT (ndp, LOOKUP, FOLLOW, uap->fname); ip = namei(ndp); if (ip == NULL) return; if ((ip->i_mode&IFMT) != IFDIR) { u.u_error = ENOTDIR; goto bad; } if (access(ip, IEXEC)) goto bad; iunlock(ip); if (*ipp) irele(*ipp); *ipp = ip; return; bad: iput(ip); } /* * Change current working directory (``.''). */ void chdir() { chdirec (&u.u_cdir); } void fchdir() { register struct a { int fd; } *uap = (struct a *)u.u_arg; register struct inode *ip; ip = getinode (uap->fd); if (ip == NULL) return; ilock(ip); if ((ip->i_mode & IFMT) != IFDIR) { u.u_error = ENOTDIR; goto bad; } if (access (ip, IEXEC)) goto bad; iunlock(ip); ip->i_count++; irele(u.u_cdir); u.u_cdir = ip; return; bad: iunlock(ip); return; } /* * Change notion of root (``/'') directory. */ void chroot() { if (suser()) chdirec (&u.u_rdir); } /* * Check permissions, allocate an open file structure, * and call the device open routine if any. */ static int copen (mode, cmode, fname) int mode; int cmode; caddr_t fname; { register struct inode *ip; register struct file *fp; struct nameidata nd; register struct nameidata *ndp = &nd; int indx, type, flags, error; if (! fname) fname = ""; //printf ("copen (mode=%#o, cmode=%#o, fname=%#x '%s')\n", mode, cmode, fname, fname); fp = falloc(); if (fp == NULL) { //printf ("copen: falloc failed, errno=%d\n", u.u_error); return(u.u_error); /* XXX */ } flags = FFLAGS(mode); /* convert from open to kernel flags */ fp->f_flag = flags & FMASK; fp->f_type = DTYPE_INODE; cmode &= 077777 & ~ISVTX; indx = u.u_rval; u.u_dupfd = -indx - 1; NDINIT (ndp, LOOKUP, FOLLOW, fname); /* * ENODEV is returned by the 'fdopen()' routine - see the comments in that * routine for details about the hack being used. * * ENXIO only comes out of the 'portal fs' code (which 2.11BSD does not have). * It probably should have been removed during the port of the 'file descriptor * driver' since it's a "can not happen" event. * * u.u_dupfd is used because there the space in the proc structure is at a * premium in 2.11 while space in the u structure is relatively free. Also * there were more unused (pad) fields available in 'u' as compared to 'proc'. */ error = vn_open(ndp, flags, cmode); if (error) { //printf ("copen: vn_open failed, errno=%d\n", error); fp->f_count = 0; if ((error == ENODEV || error == ENXIO) && u.u_dupfd >= 0 && (error = dupfdopen(indx,u.u_dupfd,flags,error) == 0)) { u.u_rval = indx; return(0); } u.u_ofile[indx] = NULL; return(error); } ip = ndp->ni_ip; u.u_dupfd = 0; fp->f_data = (caddr_t)ip; if (flags & (O_EXLOCK | O_SHLOCK)) { if (flags & O_EXLOCK) type = LOCK_EX; else type = LOCK_SH; if (flags & FNONBLOCK) type |= LOCK_NB; error = ino_lock(fp, type); if (error) { //printf ("copen: ino_lock failed, errno=%d\n", error); closef(fp); u.u_ofile[indx] = NULL; } } //printf ("copen returned errno=%d\n", error); return(error); } /* * Open system call. */ void open() { register struct a { char *fname; int mode; int crtmode; } *uap = (struct a *) u.u_arg; u.u_error = copen (uap->mode, uap->crtmode, uap->fname); } /* * Mknod system call */ void mknod() { register struct inode *ip; register struct a { char *fname; int fmode; int dev; } *uap = (struct a *)u.u_arg; struct nameidata nd; register struct nameidata *ndp = &nd; if (! suser()) return; NDINIT (ndp, CREATE, NOFOLLOW, uap->fname); ip = namei(ndp); if (ip != NULL) { u.u_error = EEXIST; goto out; } if (u.u_error) return; ip = maknode (uap->fmode, ndp); if (ip == NULL) return; switch (ip->i_mode & IFMT) { case IFMT: /* used by badsect to flag bad sectors */ case IFCHR: case IFBLK: if (uap->dev) { /* * Want to be able to use this to make badblock * inodes, so don't truncate the dev number. */ ip->i_rdev = uap->dev; ip->i_dummy = 0; ip->i_flag |= IACC|IUPD|ICHG; } } out: iput(ip); } /* * link system call */ void link() { register struct inode *ip, *xp; register struct a { char *target; char *linkname; } *uap = (struct a *)u.u_arg; struct nameidata nd; register struct nameidata *ndp = &nd; NDINIT (ndp, LOOKUP, FOLLOW, uap->target); ip = namei(ndp); /* well, this routine is doomed anyhow */ if (ip == NULL) return; if ((ip->i_mode&IFMT) == IFDIR && !suser()) { iput(ip); return; } if (ip->i_flags & (IMMUTABLE|APPEND)) { u.u_error = EPERM; iput(ip); return; } ip->i_nlink++; ip->i_flag |= ICHG; iupdat(ip, &time, &time, 1); iunlock(ip); ndp->ni_nameiop = CREATE; ndp->ni_dirp = (caddr_t)uap->linkname; xp = namei(ndp); if (xp != NULL) { u.u_error = EEXIST; iput(xp); goto out; } if (u.u_error) goto out; if (ndp->ni_pdir->i_dev != ip->i_dev) { iput(ndp->ni_pdir); u.u_error = EXDEV; goto out; } u.u_error = direnter(ip, ndp); out: if (u.u_error) { ip->i_nlink--; ip->i_flag |= ICHG; } irele(ip); } /* * symlink -- make a symbolic link */ void symlink() { register struct a { char *target; char *linkname; } *uap = (struct a *)u.u_arg; register struct inode *ip; char *tp; int c, nc; struct nameidata nd; register struct nameidata *ndp = &nd; tp = uap->target; nc = 0; for (;;) { if (baduaddr (tp)) { u.u_error = EFAULT; return; } c = (u_char) *tp; if (c == 0) break; tp++; nc++; } NDINIT (ndp, CREATE, NOFOLLOW, uap->linkname); ip = namei(ndp); if (ip) { iput(ip); u.u_error = EEXIST; return; } if (u.u_error) return; ip = maknode (IFLNK | 0777, ndp); if (ip == NULL) return; u.u_error = rdwri (UIO_WRITE, ip, uap->target, nc, (off_t) 0, IO_UNIT, (int*) 0); /* handle u.u_error != 0 */ iput(ip); } /* * Unlink system call. * Hard to avoid races here, especially * in unlinking directories. */ void unlink() { register struct a { char *fname; } *uap = (struct a *)u.u_arg; register struct inode *ip, *dp; struct nameidata nd; register struct nameidata *ndp = &nd; NDINIT (ndp, DELETE, LOCKPARENT, uap->fname); ip = namei(ndp); if (ip == NULL) return; dp = ndp->ni_pdir; if ((ip->i_mode&IFMT) == IFDIR && !suser()) goto out; /* * Don't unlink a mounted file. */ if (ip->i_dev != dp->i_dev) { u.u_error = EBUSY; goto out; } if ((ip->i_flags & (IMMUTABLE|APPEND)) || (dp->i_flags & APPEND)) { u.u_error = EPERM; goto out; } if (dirremove(ndp)) { ip->i_nlink--; ip->i_flag |= ICHG; } out: if (dp == ip) irele(ip); else iput(ip); iput(dp); } /* * Access system call */ void saccess() { uid_t t_uid; gid_t t_gid; register struct inode *ip; register struct a { char *fname; int fmode; } *uap = (struct a *)u.u_arg; struct nameidata nd; register struct nameidata *ndp = &nd; t_uid = u.u_uid; t_gid = u.u_groups[0]; u.u_uid = u.u_ruid; u.u_groups[0] = u.u_rgid; NDINIT (ndp, LOOKUP, FOLLOW, uap->fname); ip = namei(ndp); if (ip != NULL) { if ((uap->fmode&R_OK) && access(ip, IREAD)) goto done; if ((uap->fmode&W_OK) && access(ip, IWRITE)) goto done; if ((uap->fmode&X_OK) && access(ip, IEXEC)) goto done; done: iput(ip); } u.u_uid = t_uid; u.u_groups[0] = t_gid; } static void stat1 (follow) int follow; { register struct inode *ip; register struct a { char *fname; struct stat *ub; } *uap = (struct a *)u.u_arg; struct stat sb; struct nameidata nd; register struct nameidata *ndp = &nd; NDINIT (ndp, LOOKUP, follow, uap->fname); ip = namei(ndp); if (ip == NULL) return; (void) ino_stat(ip, &sb); iput(ip); u.u_error = copyout((caddr_t)&sb, (caddr_t)uap->ub, sizeof (sb)); } /* * Stat system call. This version follows links. */ void stat() { stat1 (FOLLOW); } /* * Lstat system call. This version does not follow links. */ void lstat() { stat1 (NOFOLLOW); } /* * Return target name of a symbolic link */ void readlink() { register struct inode *ip; register struct a { char *name; char *buf; int count; } *uap = (struct a *)u.u_arg; struct nameidata nd; register struct nameidata *ndp = &nd; int resid; NDINIT (ndp, LOOKUP, NOFOLLOW, uap->name); ip = namei(ndp); if (ip == NULL) return; if ((ip->i_mode&IFMT) != IFLNK) { u.u_error = EINVAL; goto out; } u.u_error = rdwri (UIO_READ, ip, uap->buf, uap->count, (off_t) 0, IO_UNIT, &resid); out: iput(ip); u.u_rval = uap->count - resid; } static int chflags1 (ip, flags) register struct inode *ip; u_short flags; { struct vattr vattr; VATTR_NULL(&vattr); vattr.va_flags = flags; return(ufs_setattr(ip, &vattr)); } /* * change flags of a file given pathname. */ void chflags() { register struct inode *ip; register struct a { char *fname; u_int flags; } *uap = (struct a *)u.u_arg; struct nameidata nd; register struct nameidata *ndp = &nd; NDINIT (ndp, LOOKUP, FOLLOW, uap->fname); if ((ip = namei(ndp)) == NULL) return; u.u_error = chflags1 (ip, uap->flags); iput(ip); } /* * change flags of a file given file descriptor. */ void fchflags() { register struct a { int fd; u_int flags; } *uap = (struct a *)u.u_arg; register struct inode *ip; ip = getinode (uap->fd); if (ip == NULL) return; ilock(ip); u.u_error = chflags1 (ip, uap->flags); iunlock(ip); } /* * Change mode of a file given path name. */ void chmod() { register struct inode *ip; register struct a { char *fname; int fmode; } *uap = (struct a *)u.u_arg; struct vattr vattr; struct nameidata nd; register struct nameidata *ndp = &nd; NDINIT (ndp, LOOKUP, FOLLOW, uap->fname); ip = namei(ndp); if (!ip) return; VATTR_NULL(&vattr); vattr.va_mode = uap->fmode & 07777; u.u_error = ufs_setattr(ip, &vattr); iput(ip); } /* * Change mode of a file given a file descriptor. */ void fchmod() { register struct a { int fd; int fmode; } *uap = (struct a *)u.u_arg; register struct inode *ip; struct vattr vattr; if ((ip = getinode(uap->fd)) == NULL) return; ilock(ip); VATTR_NULL(&vattr); vattr.va_mode = uap->fmode & 07777; u.u_error = ufs_setattr(ip, &vattr); iunlock(ip); } /* * Change the mode on a file. This routine is called from ufs_setattr. * Inode must be locked before calling. */ int chmod1(ip, mode) register struct inode *ip; register int mode; { if (u.u_uid != ip->i_uid && !suser()) return(u.u_error); if (u.u_uid) { if ((ip->i_mode & IFMT) != IFDIR && (mode & ISVTX)) return(EFTYPE); if (!groupmember(ip->i_gid) && (mode & ISGID)) return(EPERM); } ip->i_mode &= ~07777; /* why? */ ip->i_mode |= mode&07777; ip->i_flag |= ICHG; return (0); } /* * Set ownership given a path name. */ void chown() { register struct inode *ip; register struct a { char *fname; int uid; int gid; } *uap = (struct a *)u.u_arg; struct nameidata nd; register struct nameidata *ndp = &nd; struct vattr vattr; NDINIT (ndp, LOOKUP, NOFOLLOW, uap->fname); ip = namei(ndp); if (ip == NULL) return; VATTR_NULL(&vattr); vattr.va_uid = uap->uid; vattr.va_gid = uap->gid; u.u_error = ufs_setattr(ip, &vattr); iput(ip); } /* * Set ownership given a file descriptor. */ void fchown() { register struct a { int fd; int uid; int gid; } *uap = (struct a *)u.u_arg; register struct inode *ip; struct vattr vattr; if ((ip = getinode(uap->fd)) == NULL) return; ilock(ip); VATTR_NULL(&vattr); vattr.va_uid = uap->uid; vattr.va_gid = uap->gid; u.u_error = ufs_setattr(ip, &vattr); iunlock(ip); } /* * Perform chown operation on inode ip. This routine called from ufs_setattr. * inode must be locked prior to call. */ int chown1 (ip, uid, gid) register struct inode *ip; register int uid, gid; { int ouid, ogid; if (uid == -1) uid = ip->i_uid; if (gid == -1) gid = ip->i_gid; /* * If we don't own the file, are trying to change the owner * of the file, or are not a member of the target group, * the caller must be superuser or the call fails. */ if ((u.u_uid != ip->i_uid || uid != ip->i_uid || !groupmember((gid_t)gid)) && !suser()) return (u.u_error); ouid = ip->i_uid; ogid = ip->i_gid; ip->i_uid = uid; ip->i_gid = gid; if (ouid != uid || ogid != gid) ip->i_flag |= ICHG; if (ouid != uid && u.u_uid != 0) ip->i_mode &= ~ISUID; if (ogid != gid && u.u_uid != 0) ip->i_mode &= ~ISGID; return (0); } /* * Truncate a file given its path name. */ void truncate() { register struct a { char *fname; off_t length; } *uap = (struct a *)u.u_arg; register struct inode *ip; struct nameidata nd; register struct nameidata *ndp = &nd; struct vattr vattr; NDINIT (ndp, LOOKUP, FOLLOW, uap->fname); ip = namei(ndp); if (ip == NULL) return; if (access(ip, IWRITE)) goto bad; VATTR_NULL(&vattr); vattr.va_size = uap->length; u.u_error = ufs_setattr(ip, &vattr); bad: iput(ip); } /* * Truncate a file given a file descriptor. */ void ftruncate() { register struct a { int fd; off_t length; } *uap = (struct a *)u.u_arg; register struct inode *ip; register struct file *fp; struct vattr vattr; if ((fp = getf(uap->fd)) == NULL) return; if (!(fp->f_flag&FWRITE) || (fp->f_type != DTYPE_INODE)) { u.u_error = EINVAL; return; } ip = (struct inode *)fp->f_data; ilock(ip); VATTR_NULL(&vattr); vattr.va_size = uap->length; u.u_error = ufs_setattr(ip, &vattr); iunlock(ip); } /* * Rename system call. * rename("foo", "bar"); * is essentially * unlink("bar"); * link("foo", "bar"); * unlink("foo"); * but ``atomically''. Can't do full commit without saving state in the * inode on disk which isn't feasible at this time. Best we can do is * always guarantee the target exists. * * Basic algorithm is: * * 1) Bump link count on source while we're linking it to the * target. This also insure the inode won't be deleted out * from underneath us while we work (it may be truncated by * a concurrent `trunc' or `open' for creation). * 2) Link source to destination. If destination already exists, * delete it first. * 3) Unlink source reference to inode if still around. If a * directory was moved and the parent of the destination * is different from the source, patch the ".." entry in the * directory. * * Source and destination must either both be directories, or both * not be directories. If target is a directory, it must be empty. */ void rename() { struct a { char *from; char *to; } *uap = (struct a *)u.u_arg; register struct inode *ip, *xp, *dp; struct dirtemplate dirbuf; int doingdirectory = 0, oldparent = 0, newparent = 0; struct nameidata nd; register struct nameidata *ndp = &nd; int error = 0; NDINIT (ndp, DELETE, LOCKPARENT, uap->from); ip = namei(ndp); if (ip == NULL) return; dp = ndp->ni_pdir; /* * 'from' file can not be renamed if it is immutable/appendonly or if its * parent directory is append only. */ if ((ip->i_flags & (IMMUTABLE|APPEND)) || (dp->i_flags & APPEND)) { iput(dp); if (dp == ip) irele(ip); else iput(ip); u.u_error = EPERM; return; } if ((ip->i_mode&IFMT) == IFDIR) { register struct direct *d; d = &ndp->ni_dent; /* * Avoid ".", "..", and aliases of "." for obvious reasons. */ if ((d->d_namlen == 1 && d->d_name[0] == '.') || (d->d_namlen == 2 && bcmp(d->d_name, "..", 2) == 0) || (dp == ip) || (ip->i_flag & IRENAME)) { iput(dp); if (dp == ip) irele(ip); else iput(ip); u.u_error = EINVAL; return; } ip->i_flag |= IRENAME; oldparent = dp->i_number; doingdirectory++; } iput(dp); /* * 1) Bump link count while we're moving stuff * around. If we crash somewhere before * completing our work, the link count * may be wrong, but correctable. */ ip->i_nlink++; ip->i_flag |= ICHG; iupdat(ip, &time, &time, 1); iunlock(ip); /* * When the target exists, both the directory * and target inodes are returned locked. */ ndp->ni_nameiop = CREATE | LOCKPARENT | NOCACHE; ndp->ni_dirp = (caddr_t)uap->to; xp = namei(ndp); if (u.u_error) { error = u.u_error; goto out; } dp = ndp->ni_pdir; /* * rename can not be done if 'to' file exists and is immutable/appendonly * or if the directory is append only (this is because an existing 'to' * has to be deleted first and that is illegal in an appendonly directory). */ if (xp && ((xp->i_flags & (IMMUTABLE|APPEND)) || (dp->i_flags & APPEND))) { error = EPERM; goto bad; } /* * If ".." must be changed (ie the directory gets a new * parent) then the source directory must not be in the * directory heirarchy above the target, as this would * orphan everything below the source directory. Also * the user must have write permission in the source so * as to be able to change "..". We must repeat the call * to namei, as the parent directory is unlocked by the * call to checkpath(). */ if (oldparent != dp->i_number) newparent = dp->i_number; if (doingdirectory && newparent) { if (access(ip, IWRITE)) goto bad; do { dp = ndp->ni_pdir; if (xp != NULL) iput(xp); u.u_error = checkpath(ip, dp); if (u.u_error) goto out; xp = namei(ndp); if (u.u_error) { error = u.u_error; goto out; } } while (dp != ndp->ni_pdir); } /* * 2) If target doesn't exist, link the target * to the source and unlink the source. * Otherwise, rewrite the target directory * entry to reference the source inode and * expunge the original entry's existence. */ if (xp == NULL) { if (dp->i_dev != ip->i_dev) { error = EXDEV; goto bad; } /* * Account for ".." in new directory. * When source and destination have the same * parent we don't fool with the link count. */ if (doingdirectory && newparent) { dp->i_nlink++; dp->i_flag |= ICHG; iupdat(dp, &time, &time, 1); } error = direnter(ip, ndp); if (error) goto out; } else { if (xp->i_dev != dp->i_dev || xp->i_dev != ip->i_dev) { error = EXDEV; goto bad; } /* * Short circuit rename(foo, foo). */ if (xp->i_number == ip->i_number) goto bad; /* * If the parent directory is "sticky", then the user must * own the parent directory, or the destination of the rename, * otherwise the destination may not be changed (except by * root). This implements append-only directories. */ if ((dp->i_mode & ISVTX) && u.u_uid != 0 && u.u_uid != dp->i_uid && xp->i_uid != u.u_uid) { error = EPERM; goto bad; } /* * Target must be empty if a directory * and have no links to it. * Also, insure source and target are * compatible (both directories, or both * not directories). */ if ((xp->i_mode&IFMT) == IFDIR) { if (!dirempty(xp, dp->i_number) || xp->i_nlink > 2) { error = ENOTEMPTY; goto bad; } if (!doingdirectory) { error = ENOTDIR; goto bad; } cacheinval(dp); } else if (doingdirectory) { error = EISDIR; goto bad; } dirrewrite(dp, ip, ndp); if (u.u_error) { error = u.u_error; goto bad1; } /* * Adjust the link count of the target to * reflect the dirrewrite above. If this is * a directory it is empty and there are * no links to it, so we can squash the inode and * any space associated with it. We disallowed * renaming over top of a directory with links to * it above, as the remaining link would point to * a directory without "." or ".." entries. */ xp->i_nlink--; if (doingdirectory) { if (--xp->i_nlink != 0) panic("rename: lnk dir"); itrunc(xp, (u_long)0, 0); /* IO_SYNC? */ } xp->i_flag |= ICHG; iput(xp); xp = NULL; } /* * 3) Unlink the source. */ NDINIT (ndp, DELETE, LOCKPARENT, uap->from); xp = namei(ndp); if (xp != NULL) dp = ndp->ni_pdir; else dp = NULL; /* * Insure that the directory entry still exists and has not * changed while the new name has been entered. If the source is * a file then the entry may have been unlinked or renamed. In * either case there is no further work to be done. If the source * is a directory then it cannot have been rmdir'ed; its link * count of three would cause a rmdir to fail with ENOTEMPTY. * The IRENAME flag insures that it cannot be moved by another * rename. */ if (xp != ip) { if (doingdirectory) panic("rename: lost dir entry"); } else { /* * If the source is a directory with a * new parent, the link count of the old * parent directory must be decremented * and ".." set to point to the new parent. */ if (doingdirectory && newparent) { dp->i_nlink--; dp->i_flag |= ICHG; error = rdwri (UIO_READ, xp, (caddr_t) &dirbuf, sizeof(struct dirtemplate), (off_t) 0, IO_UNIT, (int*) 0); if (error == 0) { if (dirbuf.dotdot_namlen != 2 || dirbuf.dotdot_name[0] != '.' || dirbuf.dotdot_name[1] != '.') { printf("rename: mangled dir\n"); } else { dirbuf.dotdot_ino = newparent; (void) rdwri (UIO_WRITE, xp, (caddr_t) &dirbuf, sizeof(struct dirtemplate), (off_t) 0, IO_UNIT | IO_SYNC, (int*) 0); cacheinval(dp); } } } if (dirremove(ndp)) { xp->i_nlink--; xp->i_flag |= ICHG; } xp->i_flag &= ~IRENAME; if (error == 0) /* XXX conservative */ error = u.u_error; } if (dp) iput(dp); if (xp) iput(xp); irele(ip); if (error) u.u_error = error; return; bad: iput(dp); bad1: if (xp) iput(xp); out: ip->i_nlink--; ip->i_flag |= ICHG; irele(ip); if (error) u.u_error = error; } /* * Make a new file. */ struct inode * maknode (mode, ndp) int mode; register struct nameidata *ndp; { register struct inode *ip; register struct inode *pdir = ndp->ni_pdir; ip = ialloc(pdir); if (ip == NULL) { iput(pdir); return (NULL); } ip->i_flag |= IACC|IUPD|ICHG; if ((mode & IFMT) == 0) mode |= IFREG; ip->i_mode = mode & ~u.u_cmask; ip->i_nlink = 1; ip->i_uid = u.u_uid; ip->i_gid = pdir->i_gid; if (ip->i_mode & ISGID && !groupmember(ip->i_gid)) ip->i_mode &= ~ISGID; /* * Make sure inode goes to disk before directory entry. */ iupdat(ip, &time, &time, 1); u.u_error = direnter(ip, ndp); if (u.u_error) { /* * Write error occurred trying to update directory * so must deallocate the inode. */ ip->i_nlink = 0; ip->i_flag |= ICHG; iput(ip); return (NULL); } ndp->ni_ip = ip; return (ip); } /* * A virgin directory (no blushing please). */ const struct dirtemplate mastertemplate = { 0, 12, 1, ".", 0, DIRBLKSIZ - 12, 2, "..", }; /* * Mkdir system call */ void mkdir() { register struct a { char *name; int dmode; } *uap = (struct a *)u.u_arg; register struct inode *ip, *dp; struct dirtemplate dirtemplate; struct nameidata nd; register struct nameidata *ndp = &nd; NDINIT (ndp, CREATE, NOFOLLOW, uap->name); ip = namei(ndp); if (u.u_error) return; if (ip != NULL) { iput(ip); u.u_error = EEXIST; return; } dp = ndp->ni_pdir; uap->dmode &= 0777; uap->dmode |= IFDIR; /* * Must simulate part of maknode here * in order to acquire the inode, but * not have it entered in the parent * directory. The entry is made later * after writing "." and ".." entries out. */ ip = ialloc(dp); if (ip == NULL) { iput(dp); return; } ip->i_flag |= IACC|IUPD|ICHG; ip->i_mode = uap->dmode & ~u.u_cmask; ip->i_nlink = 2; ip->i_uid = u.u_uid; ip->i_gid = dp->i_gid; iupdat(ip, &time, &time, 1); /* * Bump link count in parent directory * to reflect work done below. Should * be done before reference is created * so reparation is possible if we crash. */ dp->i_nlink++; dp->i_flag |= ICHG; iupdat(dp, &time, &time, 1); /* * Initialize directory with "." * and ".." from static template. */ dirtemplate = mastertemplate; dirtemplate.dot_ino = ip->i_number; dirtemplate.dotdot_ino = dp->i_number; u.u_error = rdwri (UIO_WRITE, ip, (caddr_t) &dirtemplate, sizeof (dirtemplate), (off_t) 0, IO_UNIT | IO_SYNC, (int*) 0); if (u.u_error) { dp->i_nlink--; dp->i_flag |= ICHG; goto bad; } ip->i_size = DIRBLKSIZ; /* * Directory all set up, now * install the entry for it in * the parent directory. */ u.u_error = direnter(ip, ndp); dp = NULL; if (u.u_error) { NDINIT (ndp, LOOKUP, NOCACHE, uap->name); dp = namei(ndp); if (dp) { dp->i_nlink--; dp->i_flag |= ICHG; } } bad: /* * No need to do an explicit itrunc here, * irele will do this for us because we set * the link count to 0. */ if (u.u_error) { ip->i_nlink = 0; ip->i_flag |= ICHG; } if (dp) iput(dp); iput(ip); } /* * Rmdir system call. */ void rmdir() { struct a { char *name; } *uap = (struct a *)u.u_arg; register struct inode *ip, *dp; struct nameidata nd; register struct nameidata *ndp = &nd; NDINIT (ndp, DELETE, LOCKPARENT, uap->name); ip = namei(ndp); if (ip == NULL) return; dp = ndp->ni_pdir; /* * No rmdir "." please. */ if (dp == ip) { irele(dp); iput(ip); u.u_error = EINVAL; return; } if ((ip->i_mode&IFMT) != IFDIR) { u.u_error = ENOTDIR; goto out; } /* * Don't remove a mounted on directory. */ if (ip->i_dev != dp->i_dev) { u.u_error = EBUSY; goto out; } /* * Verify the directory is empty (and valid). * (Rmdir ".." won't be valid since * ".." will contain a reference to * the current directory and thus be * non-empty.) */ if (ip->i_nlink != 2 || !dirempty(ip, dp->i_number)) { u.u_error = ENOTEMPTY; goto out; } if ((dp->i_flags & APPEND) || (ip->i_flags & (IMMUTABLE|APPEND))) { u.u_error = EPERM; goto out; } /* * Delete reference to directory before purging * inode. If we crash in between, the directory * will be reattached to lost+found, */ if (dirremove(ndp) == 0) goto out; dp->i_nlink--; dp->i_flag |= ICHG; cacheinval(dp); iput(dp); dp = NULL; /* * Truncate inode. The only stuff left * in the directory is "." and "..". The * "." reference is inconsequential since * we're quashing it. The ".." reference * has already been adjusted above. We've * removed the "." reference and the reference * in the parent directory, but there may be * other hard links so decrement by 2 and * worry about them later. */ ip->i_nlink -= 2; itrunc(ip, (u_long)0, 0); /* IO_SYNC? */ cacheinval(ip); out: if (dp) iput(dp); iput(ip); } /* * Get an inode pointer of a file descriptor. */ struct inode * getinode(fdes) int fdes; { register struct file *fp; if ((unsigned)fdes >= NOFILE || (fp = u.u_ofile[fdes]) == NULL) { u.u_error = EBADF; return ((struct inode *)0); } if (fp->f_type != DTYPE_INODE) { u.u_error = EINVAL; return ((struct inode *)0); } return((struct inode *)fp->f_data); } ================================================ FILE: sys/kern/ufs_syscalls2.c ================================================ /* * ufs_syscalls was getting too large. Various UFS related system calls were * relocated to this file. */ #include #include #include #include #include #include #include #include #include #include #include static int statfs1 (mp, sbp) struct mount *mp; struct statfs *sbp; { struct statfs sfs; register struct statfs *sfsp; struct fs *fs = &mp->m_filsys; sfsp = &sfs; sfsp->f_type = MOUNT_UFS; sfsp->f_bsize = MAXBSIZE; sfsp->f_iosize = MAXBSIZE; sfsp->f_blocks = fs->fs_fsize - fs->fs_isize; sfsp->f_bfree = fs->fs_tfree; sfsp->f_bavail = fs->fs_tfree; sfsp->f_files = (fs->fs_isize - 1) * INOPB; sfsp->f_ffree = fs->fs_tinode; bcopy (mp->m_mnton, sfsp->f_mntonname, MNAMELEN); bcopy (mp->m_mntfrom, sfsp->f_mntfromname, MNAMELEN); sfsp->f_flags = mp->m_flags & MNT_VISFLAGMASK; return copyout ((caddr_t) sfsp, (caddr_t) sbp, sizeof (struct statfs)); } void statfs() { register struct a { char *path; struct statfs *buf; } *uap = (struct a *)u.u_arg; register struct inode *ip; struct nameidata nd; register struct nameidata *ndp = &nd; struct mount *mp; NDINIT (ndp, LOOKUP, FOLLOW, uap->path); ip = namei(ndp); if (! ip) return; mp = (struct mount *)((int)ip->i_fs - offsetof(struct mount, m_filsys)); iput(ip); u.u_error = statfs1 (mp, uap->buf); } void fstatfs() { register struct a { int fd; struct statfs *buf; } *uap = (struct a *)u.u_arg; register struct inode *ip; struct mount *mp; ip = getinode(uap->fd); if (! ip) return; mp = (struct mount *)((int)ip->i_fs - offsetof(struct mount, m_filsys)); u.u_error = statfs1 (mp, uap->buf); } void getfsstat() { register struct a { struct statfs *buf; int bufsize; u_int flags; } *uap = (struct a *)u.u_arg; register struct mount *mp; caddr_t sfsp; int count, maxcount, error; maxcount = uap->bufsize / sizeof (struct statfs); sfsp = (caddr_t)uap->buf; count = 0; for (mp = mount; mp < &mount[NMOUNT]; mp++) { if (mp->m_inodp == NULL) continue; if (count < maxcount) { error = statfs1 (mp, sfsp); if (error) { u.u_error = error; return; } sfsp += sizeof (struct statfs); } count++; } if (sfsp && count > maxcount) u.u_rval = maxcount; else u.u_rval = count; } /* * This is somewhat inefficient in that the inode table is scanned for each * filesystem but it didn't seem worth a page or two of code on something * which only happens every 30 seconds. */ static void syncinodes(fs) struct fs *fs; { register struct inode *ip; /* * Write back each (modified) inode. */ for (ip = inode; ip < inode+NINODE; ip++) { /* * Attempt to reduce the overhead by short circuiting the scan if the * inode is not for the filesystem being processed. */ if (ip->i_fs != fs) continue; if ((ip->i_flag & ILOCKED) != 0 || ip->i_count == 0 || (ip->i_flag & (IMOD|IACC|IUPD|ICHG)) == 0) continue; ip->i_flag |= ILOCKED; ip->i_count++; iupdat(ip, &time, &time, 0); iput(ip); } } /* * 'ufs_sync' is the routine which syncs a single filesystem. This was * created to replace 'update' which 'unmount' called. It seemed silly to * sync _every_ filesystem when unmounting just one filesystem. */ int ufs_sync(mp) register struct mount *mp; { register struct fs *fs; struct buf *bp; int error = 0; fs = &mp->m_filsys; if (fs->fs_fmod && (mp->m_flags & MNT_RDONLY)) { printf("fs = %s\n", fs->fs_fsmnt); panic("sync: rofs"); } syncinodes(fs); /* sync the inodes for this filesystem */ bflush(mp->m_dev); /* flush dirty data blocks */ /* * And lastly the superblock, if the filesystem was modified. * Write back modified superblocks. Consistency check that the superblock * of each file system is still in the buffer cache. */ if (fs->fs_fmod) { bp = getblk(mp->m_dev, SUPERB); fs->fs_fmod = 0; fs->fs_time = time.tv_sec; bcopy(fs, bp->b_addr, sizeof (struct fs)); bwrite(bp); error = geterror(bp); } return(error); } /* * mode mask for creation of files */ void umask() { register struct a { int mask; } *uap = (struct a *)u.u_arg; u.u_rval = u.u_cmask; u.u_cmask = uap->mask & 07777; } /* * Seek system call */ void lseek() { register struct file *fp; register struct a { int fd; off_t off; int sbase; } *uap = (struct a *)u.u_arg; if ((fp = getf(uap->fd)) == NULL) return; if (fp->f_type != DTYPE_INODE) { u.u_error = ESPIPE; return; } switch (uap->sbase) { case L_INCR: fp->f_offset += uap->off; break; case L_XTND: fp->f_offset = uap->off + ((struct inode *)fp->f_data)->i_size; break; case L_SET: fp->f_offset = uap->off; break; default: u.u_error = EINVAL; return; } u.u_rval = fp->f_offset; } /* * Synch an open file. */ void fsync() { register struct a { int fd; } *uap = (struct a *)u.u_arg; register struct inode *ip; if ((ip = getinode(uap->fd)) == NULL) return; ilock(ip); syncip(ip); iunlock(ip); } void utimes() { register struct a { char *fname; struct timeval *tptr; } *uap = (struct a *)u.u_arg; register struct inode *ip; struct nameidata nd; register struct nameidata *ndp = &nd; struct timeval tv[2]; struct vattr vattr; VATTR_NULL(&vattr); if (uap->tptr == NULL) { tv[0].tv_sec = tv[1].tv_sec = time.tv_sec; vattr.va_vaflags |= VA_UTIMES_NULL; } else { u.u_error = copyin ((caddr_t)uap->tptr,(caddr_t)tv,sizeof(tv)); if (u.u_error) return; } NDINIT (ndp, LOOKUP, FOLLOW, uap->fname); if ((ip = namei(ndp)) == NULL) return; vattr.va_atime = tv[0].tv_sec; vattr.va_mtime = tv[1].tv_sec; u.u_error = ufs_setattr(ip, &vattr); iput(ip); } ================================================ FILE: sys/kern/vfs_vnops.c ================================================ /* * Copyright (c) 1982, 1986, 1989, 1993 * The Regents of the University of California. All rights reserved. * (c) UNIX System Laboratories, Inc. * All or some portions of this file are derived from material licensed * to the University of California by American Telephone and Telegraph * Co. or Unix System Laboratories, Inc. and are reproduced herein with * the permission of UNIX System Laboratories, Inc. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #include #include #include #include #include #include /* * 2.11BSD does not have "vnodes", having instead only old fashioned "inodes". * The routine names (i.e. vn_open) were retained since the functions them- * selves were ported over with minimal change. Retaining the 4.4 function * names also makes it easier to follow the logic flow when reading the 4.4 * sources. Also, changing the names from vn_* to in_* could have caused * confusion with the networking routines since 'in_' and 'ip_' are frequently * used in the networking code. * * The tab spacing has been altered to be (to me) more readable. */ /* * Common code for vnode open operations. * Check permissions, and call the VOP_OPEN (openi for 2.11) or VOP_CREATE * (maknode) routine. */ int vn_open (ndp, fmode, cmode) register struct nameidata *ndp; int fmode, cmode; { register struct inode *ip; register int error; if (fmode & O_CREAT) { if ((fmode & O_EXCL) == 0) ndp->ni_nameiop |= (CREATE|FOLLOW); else ndp->ni_nameiop = CREATE; ip = namei(ndp); if (ip == NULL) { if (u.u_error) { goto retuerr; } ip = maknode(cmode, ndp); if (ip == NULL) { goto retuerr; } fmode &= ~O_TRUNC; } else { if (fmode & O_EXCL) { error = EEXIST; goto bad; } fmode &= ~O_CREAT; } } else { ndp->ni_nameiop = LOOKUP | FOLLOW; ip = namei(ndp); if (ip == NULL) { goto retuerr; } } if ((ip->i_mode & IFMT) == IFSOCK) { error = EOPNOTSUPP; goto bad; } if ((ip->i_flags & APPEND) && (fmode&(FWRITE|O_APPEND)) == FWRITE) { error = EPERM; goto bad; } if ((fmode & O_CREAT) == 0) { if (fmode & FREAD) { if (access(ip, IREAD)) { error = u.u_error; /* XXX */ goto bad; } } if (fmode & (FWRITE | O_TRUNC)) { if ((ip->i_mode & IFMT) == IFDIR) { error = EISDIR; goto bad; } if (access(ip, IWRITE)) { error = u.u_error; goto bad; } } } if (fmode & O_TRUNC) itrunc(ip, (off_t)0, fmode & O_FSYNC ? IO_SYNC : 0); /* * 4.4 returns the vnode locked from vn_open which means that each caller * has to go and unlock it. * * 2.11 returns the inode unlocked (for now). */ iunlock(ip); /* because namei returns a locked inode */ if (setjmp(&u.u_qsave)) { error = EINTR; /* opens are not restarted after signals */ goto lbad; } error = openi (ip, fmode); if (error) { goto lbad; } return(0); /* * Gratuitous lock but it does (correctly) implement the earlier behaviour of * copen (it also avoids a panic in iput). */ lbad: ilock(ip); bad: /* * Do NOT do an 'ilock' here - this tag is to be used only when the inode is * locked (i.e. from namei). */ iput(ip); return(error); retuerr: return(u.u_error); /* XXX - Bletch */ } /* * Inode close call. Pipes and sockets do NOT enter here. This routine is * used by the kernel to close files it opened for itself. * The kernel does not create sockets or pipes on its own behalf. * * The difference between this routine and vn_closefile below is that vn_close * takes an "inode *" as a first argument and is passed the flags by the caller * while vn_closefile (called from the closef routine for DTYPE_INODE inodes) * takes a "file *" and extracts the flags from the file structure. */ int vn_close(ip, flags) register struct inode *ip; int flags; { register int error; error = closei(ip, flags); irele(ip); /* assumes inode is unlocked */ return(error); } /* * File table inode close routine. This is called from 'closef()' via the * "Fops" table (the 'inodeops' entry). * * NOTE: pipes are a special case of inode and have their own 'pipe_close' * entry in the 'pipeops' table. See sys_pipe.c for pipe_close(). * * In 4.4BSD this routine called vn_close() but since 2.11 does not do the * writecheck counting we can skip the overhead of nesting another level down * and call closei() and irele() ourself. */ int vn_closefile(fp) register struct file *fp; { register struct inode *ip = (struct inode *)fp->f_data; /* * Need to clear the inode pointer in the file structure so that the * inode is not seen during the scan for aliases of character or block * devices in closei(). */ fp->f_data = (caddr_t)0; /* XXX */ irele(ip); return (closei(ip, fp->f_flag)); } ================================================ FILE: sys/kern/vm_sched.c ================================================ /* * Copyright (c) 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include #include #include #include #include #include #include #define MINFINITY -32767 /* minus infinity */ int maxslp = MAXSLP; char runin; /* scheduling flag */ char runout; /* scheduling flag */ /* * The main loop of the scheduling (swapping) process. * The basic idea is: * see if anyone wants to be swapped in * swap out processes until there is room * swap him in * repeat * The runout flag is set whenever someone is swapped out. Sched sleeps on * it awaiting work. Sched sleeps on runin whenever it cannot find enough * core (by swapping out or otherwise) to fit the selected swapped process. * It is awakened when the core situation changes and in any case once per * second. */ void sched() { register struct proc *rp; struct proc *swapped_out = 0, *in_core = 0; register int out_time, rptime; for (;;) { /* Perform swap-out/swap-in action. */ spl0(); if (in_core) swapout (in_core, X_FREECORE, X_OLDSIZE, X_OLDSIZE); if (swapped_out) swapin (swapped_out); splhigh(); in_core = 0; swapped_out = 0; /* Find user to swap in; of users ready, * select one out longest. */ out_time = -20000; for (rp = allproc; rp; rp = rp->p_nxt) { if (rp->p_stat != SRUN || (rp->p_flag & SLOAD)) continue; rptime = rp->p_time - rp->p_nice * 8; /* * Always bring in parents ending a vfork, * to avoid deadlock */ if (rptime > out_time || (rp->p_flag & SVFPRNT)) { swapped_out = rp; out_time = rptime; if (rp->p_flag & SVFPRNT) break; } } /* If there is no one there, wait. */ if (! swapped_out) { ++runout; sleep ((caddr_t) &runout, PSWP); continue; } /* * Look around for somebody to swap out. * There may be only one non-system loaded process. */ for (rp = allproc; rp != NULL; rp = rp->p_nxt) { if (rp->p_stat != SZOMB && (rp->p_flag & (SSYS | SLOAD)) == SLOAD) { in_core = rp; break; } } if (! in_core) { /* In-core memory is empty. */ continue; } /* * Swap found user out if sleeping interruptibly, or if he has spent at * least 1 second in core and the swapped-out process has spent at * least 2 seconds out. Otherwise wait a bit and try again. */ if (! (in_core->p_flag & SLOCK) && (in_core->p_stat == SSTOP || (in_core->p_stat == SSLEEP && (in_core->p_flag & P_SINTR)) || ((in_core->p_stat == SRUN || in_core->p_stat == SSLEEP) && out_time >= 2 && in_core->p_time + in_core->p_nice >= 1))) { /* Swap out in-core process. */ in_core->p_flag &= ~SLOAD; if (in_core->p_stat == SRUN) remrq (in_core); } else { /* Nothing to swap in/out. */ in_core = 0; swapped_out = 0; ++runin; sleep ((caddr_t) &runin, PSWP); } } } /* * Count up various things once a second */ void vmmeter() { #ifdef UCB_METER register u_short *cp, *rp; register long *sp; ave(avefree, freemem, 5); ave(avefree30, freemem, 30); cp = &cnt.v_first; rp = &rate.v_first; sp = &sum.v_first; while (cp <= &cnt.v_last) { ave(*rp, *cp, 5); *sp += *cp; *cp = 0; rp++, cp++, sp++; } #endif if (time.tv_sec % 5 == 0) { vmtotal(); #ifdef UCB_METER rate.v_swpin = cnt.v_swpin; sum.v_swpin += cnt.v_swpin; cnt.v_swpin = 0; rate.v_swpout = cnt.v_swpout; sum.v_swpout += cnt.v_swpout; cnt.v_swpout = 0; #endif } } /* * Compute Tenex style load average. This code is adapted from similar code * by Bill Joy on the Vax system. The major change is that we avoid floating * point since not all pdp-11's have it. This makes the code quite hard to * read - it was derived with some algebra. * * "floating point" numbers here are stored in a 16 bit short, with 8 bits on * each side of the decimal point. Some partial products will have 16 bits to * the right. */ static void loadav (avg, n) register short *avg; register int n; { register int i; static const long cexp[3] = { 0353, /* 256 * exp(-1/12) */ 0373, /* 256 * exp(-1/60) */ 0376, /* 256 * exp(-1/180) */ }; for (i = 0; i < 3; i++) avg[i] = (cexp[i] * (avg[i]-(n<<8)) + (((long)n)<<16)) >> 8; } void vmtotal() { register struct proc *p; register int nrun = 0; #ifdef UCB_METER total.t_vmtxt = 0; total.t_avmtxt = 0; total.t_rmtxt = 0; total.t_armtxt = 0; total.t_vm = 0; total.t_avm = 0; total.t_rm = 0; total.t_arm = 0; total.t_rq = 0; total.t_dw = 0; total.t_sl = 0; total.t_sw = 0; #endif for (p = allproc; p != NULL; p = p->p_nxt) { if (p->p_flag & SSYS) continue; if (p->p_stat) { #ifdef UCB_METER if (p->p_stat != SZOMB) { total.t_vm += p->p_dsize + p->p_ssize + USIZE; if (p->p_flag & SLOAD) total.t_rm += p->p_dsize + p->p_ssize + USIZE; } #endif switch (p->p_stat) { case SSLEEP: case SSTOP: if (!(p->p_flag & P_SINTR) && p->p_stat == SSLEEP) nrun++; #ifdef UCB_METER if (p->p_flag & SLOAD) { if (!(p->p_flag & P_SINTR)) total.t_dw++; else if (p->p_slptime < maxslp) total.t_sl++; } else if (p->p_slptime < maxslp) total.t_sw++; if (p->p_slptime < maxslp) goto active; #endif break; case SRUN: case SIDL: nrun++; #ifdef UCB_METER if (p->p_flag & SLOAD) total.t_rq++; else total.t_sw++; active: total.t_avm += p->p_dsize + p->p_ssize + USIZE; if (p->p_flag & SLOAD) total.t_arm += p->p_dsize + p->p_ssize + USIZE; #endif break; } } } #ifdef UCB_METER total.t_vm += total.t_vmtxt; total.t_avm += total.t_avmtxt; total.t_rm += total.t_rmtxt; total.t_arm += total.t_armtxt; total.t_free = avefree; #endif loadav (avenrun, nrun); } ================================================ FILE: sys/kern/vm_swap.c ================================================ /* * Copyright (c) 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include #include #include #include #include #include #include /* * Swap a process in. * Allocate data and possible text separately. It would be better * to do largest first. Text, data, and stack are allocated in * that order, as that is likely to be in order of size. * U area goes into u0 buffer. */ void swapin (p) register struct proc *p; { size_t daddr = (size_t)__user_data_start; size_t saddr = (size_t)__user_data_end - p->p_ssize; size_t uaddr = (size_t) &u0; if (p->p_dsize) { swap (p->p_daddr, daddr, p->p_dsize, B_READ); mfree (swapmap, btod (p->p_dsize), p->p_daddr); } if (p->p_ssize) { swap (p->p_saddr, saddr, p->p_ssize, B_READ); mfree (swapmap, btod (p->p_ssize), p->p_saddr); } swap (p->p_addr, uaddr, USIZE, B_READ); mfree (swapmap, btod (USIZE), p->p_addr); p->p_daddr = daddr; p->p_saddr = saddr; p->p_addr = uaddr; if (p->p_stat == SRUN) setrq (p); p->p_flag |= SLOAD; p->p_time = 0; #ifdef UCB_METER cnt.v_swpin++; #endif } /* * Swap out process p. * odata and ostack are the old data size and the stack size * of the process, and are supplied during core expansion swaps. * The freecore flag causes its core to be freed -- it may be * off when called to create an image for a child process * in newproc. * * panic: out of swap space */ void swapout (p, freecore, odata, ostack) register struct proc *p; int freecore; register u_int odata, ostack; { size_t a[3]; if (odata == (u_int) X_OLDSIZE) odata = p->p_dsize; if (ostack == (u_int) X_OLDSIZE) ostack = p->p_ssize; if (malloc3 (swapmap, btod (p->p_dsize), btod (p->p_ssize), btod (USIZE), a) == NULL) panic ("out of swap space"); p->p_flag |= SLOCK; if (odata) { swap (a[0], p->p_daddr, odata, B_WRITE); } if (ostack) { swap (a[1], p->p_saddr, ostack, B_WRITE); } /* * Increment u_ru.ru_nswap for process being tossed out of core. * We can be called to swap out a process other than the current * process, so we have to map in the victim's u structure briefly. * Note, savekdsa6 *must* be a static, because we remove the stack * in the next instruction. The splclock is to prevent the clock * from coming in and doing accounting for the wrong process, plus * we don't want to come through here twice. Why are we doing * this, anyway? */ { int s; s = splclock(); u.u_ru.ru_nswap++; splx (s); } swap (a[2], p->p_addr, USIZE, B_WRITE); p->p_daddr = a[0]; p->p_saddr = a[1]; p->p_addr = a[2]; p->p_flag &= ~(SLOAD|SLOCK); p->p_time = 0; #ifdef UCB_METER cnt.v_swpout++; #endif if (runout) { runout = 0; wakeup ((caddr_t)&runout); } } ================================================ FILE: sys/kern/vm_swp.c ================================================ /* * Copyright (c) 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include #include #include #include #include #include #include #include /* * swap I/O */ void swap (blkno, coreaddr, count, rdflg) size_t blkno, coreaddr; register int count; int rdflg; { register struct buf *bp; int s; //printf ("swap (%u, %08x, %d, %s)\n", blkno, coreaddr, count, rdflg ? "R" : "W"); #ifdef UCB_METER if (rdflg) { cnt.v_kbin += (count + 1023) / 1024; } else { cnt.v_kbout += (count + 1023) / 1024; } #endif bp = geteblk(); /* allocate a buffer header */ while (count) { bp->b_flags = B_BUSY | B_PHYS | B_INVAL | rdflg; bp->b_dev = swapdev; bp->b_bcount = count; bp->b_blkno = blkno; bp->b_addr = (caddr_t) coreaddr; (*bdevsw[major(swapdev)].d_strategy) (bp); s = splbio(); while ((bp->b_flags & B_DONE) == 0) sleep ((caddr_t)bp, PSWP); splx (s); if ((bp->b_flags & B_ERROR) || bp->b_resid) panic ("hard err: swap"); count -= count; coreaddr += count; blkno += btod (count); } brelse(bp); } /* * Raw I/O. The arguments are * The strategy routine for the device * A buffer, which may be a special buffer header * owned exclusively by the device for this purpose or * NULL if one is to be allocated. * The device number * Read/write flag * Essentially all the work is computing physical addresses and * validating them. * * rewritten to use the iov/uio mechanism from 4.3bsd. the physbuf routine * was inlined. essentially the chkphys routine performs the same task * as the useracc routine on a 4.3 system. 3/90 sms * * If the buffer pointer is NULL then one is allocated "dynamically" from * the system cache. the 'invalid' flag is turned on so that the brelse() * done later doesn't place the buffer back in the cache. the 'phys' flag * is left on so that the address of the buffer is recalcuated in getnewbuf(). * The BYTE/WORD stuff began to be removed after testing proved that either * 1) the underlying hardware gives an error or 2) nothing bad happens. * besides, 4.3BSD doesn't do the byte/word check and noone could remember * why the byte/word check was added in the first place - likely historical * paranoia. chkphys() inlined. 5/91 sms * * Refined (and streamlined) the flow by using a 'for' construct * (a la 4.3Reno). Avoid allocating/freeing the buffer for each iovec * element (i must have been confused at the time). 6/91-sms * * Finished removing the BYTE/WORD code as part of implementing the common * raw read&write routines , systems had been running fine for several * months with it ifdef'd out. 9/91-sms */ int physio(strat, bp, dev, rw, uio) void (*strat) (struct buf*); register struct buf *bp; dev_t dev; int rw; register struct uio *uio; { int error = 0, s, c, allocbuf = 0; register struct iovec *iov; if (! bp) { allocbuf++; bp = geteblk(); } u.u_procp->p_flag |= SLOCK; for ( ; uio->uio_iovcnt; uio->uio_iov++, uio->uio_iovcnt--) { iov = uio->uio_iov; if (iov->iov_base >= iov->iov_base + iov->iov_len) { error = EFAULT; break; } /* * Check that transfer is either entirely in the * data or in the stack: that is, either * the end is in the data or the start is in the stack * (remember wraparound was already checked). */ if (baduaddr (iov->iov_base) || baduaddr (iov->iov_base + iov->iov_len - 1)) { error = EFAULT; break; } if (! allocbuf) { s = splbio(); while (bp->b_flags & B_BUSY) { bp->b_flags |= B_WANTED; sleep((caddr_t)bp, PRIBIO+1); } splx(s); } bp->b_error = 0; while (iov->iov_len) { bp->b_flags = B_BUSY | B_PHYS | B_INVAL | rw; bp->b_dev = dev; bp->b_addr = iov->iov_base; bp->b_blkno = (unsigned) uio->uio_offset >> DEV_BSHIFT; bp->b_bcount = iov->iov_len; c = bp->b_bcount; (*strat)(bp); s = splbio(); while ((bp->b_flags & B_DONE) == 0) sleep((caddr_t)bp, PRIBIO); if (bp->b_flags & B_WANTED) /* rare */ wakeup((caddr_t)bp); splx(s); c -= bp->b_resid; iov->iov_base += c; iov->iov_len -= c; uio->uio_resid -= c; uio->uio_offset += c; /* temp kludge for tape drives */ if (bp->b_resid || (bp->b_flags & B_ERROR)) break; } bp->b_flags &= ~(B_BUSY | B_WANTED); error = geterror(bp); /* temp kludge for tape drives */ if (bp->b_resid || error) break; } if (allocbuf) brelse(bp); u.u_procp->p_flag &= ~SLOCK; return(error); } int rawrw (dev, uio, flag) dev_t dev; register struct uio *uio; int flag; { return (physio(cdevsw[major(dev)].d_strategy, (struct buf *)NULL, dev, uio->uio_rw == UIO_READ ? B_READ : B_WRITE, uio)); } ================================================ FILE: sys/sys/buf.h ================================================ /* * Copyright (c) 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ /* * The header for buffers in the buffer pool and otherwise used * to describe a block i/o request is given here. * * Each buffer in the pool is usually doubly linked into 2 lists: * hashed into a chain by so it can be located in the cache, * and (usually) on (one of several) queues. These lists are circular and * doubly linked for easy removal. * * There are currently two queues for buffers: * one for buffers containing ``useful'' information (the cache) * one for buffers containing ``non-useful'' information * (and empty buffers, pushed onto the front) * These queues contain the buffers which are available for * reallocation, are kept in lru order. When not on one of these queues, * the buffers are ``checked out'' to drivers which use the available list * pointers to keep track of them in their i/o active queues. */ /* * Bufhd structures used at the head of the hashed buffer queues. * We only need three words for these, so this abbreviated * definition saves some space. */ struct bufhd { int b_flags; /* see defines below */ struct buf *b_forw, *b_back; /* fwd/bkwd pointer in chain */ }; struct buf { int b_flags; /* see defines below */ struct buf *b_forw, *b_back; /* hash chain (2 way street) */ struct buf *av_forw, *av_back; /* position on free list if not BUSY */ #define b_actf av_forw /* alternate names for driver queue */ #define b_actl av_back /* head - isn't history wonderful */ u_int b_bcount; /* transfer count */ #define b_active b_bcount /* driver queue head: drive active */ int b_error; /* returned after I/O */ dev_t b_dev; /* major+minor device name */ caddr_t b_addr; /* core address */ daddr_t b_blkno; /* block # on device */ u_int b_resid; /* words not transferred after error */ #define b_cylin b_resid /* disksort */ #define b_errcnt b_resid /* while i/o in progress: # retries */ }; /* * We never use BQ_LOCKED or BQ_EMPTY, but if you want the 4.X block I/O * code to drop in, you have to have BQ_AGE and BQ_LRU *after* the first * queue, and it only costs 6 bytes of data space. */ #define BQUEUES 3 /* number of free buffer queues */ #define BQ_LOCKED 0 /* super-blocks &c */ #define BQ_LRU 1 /* lru, useful buffers */ #define BQ_AGE 2 /* rubbish */ #define BQ_EMPTY 3 /* buffer headers with no memory */ /* Flags to low-level allocation routines. */ #define B_CLRBUF 0x01 /* Request allocated buffer be cleared. */ #define B_SYNC 0x02 /* Do all allocations synchronously. */ #define bawrite(bp) { (bp)->b_flags |= B_ASYNC; bwrite(bp); } #define bfree(bp) (bp)->b_bcount = 0 #ifdef KERNEL struct inode; #define BUFHSZ 16 /* must be power of 2 */ #define BUFHASH(dev,bn) ((struct buf*) &bufhash [((dev) + bn) & (BUFHSZ - 1)]) extern struct buf buf[]; /* the buffer pool itself */ extern char bufdata[]; /* core data */ extern struct bufhd bufhash[]; /* heads of hash lists */ extern struct buf bfreelist[]; /* heads of available lists */ /* * Assign a buffer for the given block. If the appropriate */ struct buf *getblk (dev_t dev, daddr_t blkno); /* * Allocate a block in the file system. */ struct buf *balloc (struct inode *ip, int flags); /* * Get an empty block. */ struct buf *geteblk (void); /* * Read in (if necessary) the block and return a buffer pointer. */ struct buf *bread (dev_t dev, daddr_t blkno); /* * Read in the block, like bread, but also start I/O on the * read-ahead block. */ struct buf *breada (dev_t dev, daddr_t blkno, daddr_t rablkno); /* * Write the buffer, waiting for completion. Then release the buffer. */ void bwrite (struct buf *bp); /* * Release the buffer, with delayed write. */ void bdwrite (struct buf *bp); /* * Mark I/O complete on a buffer. */ void biodone (struct buf *bp); /* * Release the buffer, with no I/O implied. */ void brelse (struct buf *bp); /* * Wait for I/O completion on the buffer. */ void biowait (struct buf *bp); /* * See if the block is associated with some buffer. */ int incore (dev_t dev, daddr_t blkno); /* * Make sure all write-behind blocks on dev are flushed out. */ void bflush (dev_t dev); /* * Insure that no part of a specified block is in an incore buffer. */ void blkflush (dev_t dev, daddr_t blkno); /* * Invalidate in core blocks belonging to closed or umounted filesystem. */ void binval (dev_t dev); /* * Pick up the device's error number and pass it to the user. */ int geterror (struct buf *bp); #endif /* KERNEL */ /* * These flags are kept in b_flags. */ #define B_WRITE 0x00000 /* non-read pseudo-flag */ #define B_READ 0x00001 /* read when I/O occurs */ #define B_DONE 0x00002 /* transaction finished */ #define B_ERROR 0x00004 /* transaction aborted */ #define B_BUSY 0x00008 /* not on av_forw/back list */ #define B_PHYS 0x00010 /* physical IO */ #define B_MAP 0x00020 /* alloc UNIBUS */ #define B_WANTED 0x00040 /* issue wakeup when BUSY goes off */ #define B_AGE 0x00080 /* delayed write for correct aging */ #define B_ASYNC 0x00100 /* don't wait for I/O completion */ #define B_DELWRI 0x00200 /* write at exit of avail list */ #define B_TAPE 0x00400 /* this is a magtape (no bdwrite) */ #define B_INVAL 0x00800 /* does not contain valid info */ #define B_BAD 0x01000 /* bad block revectoring in progress */ #define B_LOCKED 0x02000 /* locked in core (not reusable) */ #define B_UBAREMAP 0x04000 /* addr UNIBUS virtual, not physical */ #define B_RAMREMAP 0x08000 /* remapped into ramdisk */ /* * Insq/Remq for the buffer hash lists. */ #define bremhash(bp) { \ (bp)->b_back->b_forw = (bp)->b_forw; \ (bp)->b_forw->b_back = (bp)->b_back; \ } #define binshash(bp, dp) { \ (bp)->b_forw = (dp)->b_forw; \ (bp)->b_back = (dp); \ (dp)->b_forw->b_back = (bp); \ (dp)->b_forw = (bp); \ } /* * Insq/Remq for the buffer free lists. */ #define bremfree(bp) { \ (bp)->av_back->av_forw = (bp)->av_forw; \ (bp)->av_forw->av_back = (bp)->av_back; \ } #define binsheadfree(bp, dp) { \ (dp)->av_forw->av_back = (bp); \ (bp)->av_forw = (dp)->av_forw; \ (dp)->av_forw = (bp); \ (bp)->av_back = (dp); \ } #define binstailfree(bp, dp) { \ (dp)->av_back->av_forw = (bp); \ (bp)->av_back = (dp)->av_back; \ (dp)->av_back = (bp); \ (bp)->av_forw = (dp); \ } /* * Take a buffer off the free list it's on and * mark it as being use (B_BUSY) by a device. */ #define notavail(bp) { \ register int x = splbio(); \ bremfree(bp); \ (bp)->b_flags |= B_BUSY; \ splx(x); \ } ================================================ FILE: sys/sys/callout.h ================================================ /* * Copyright (c) 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ /* * The callout structure is for * a routine arranging * to be called by the clock interrupt * (clock.c) with a specified argument, * in a specified amount of time. * Used, for example, to time tab * delays on typewriters. * * The c_time field is stored in terms of ticks. Therefore, no callout * may be scheduled past around 8 minutes on a 60 HZ machine. This is * good as it avoids long operations on clock ticks. If you are ever * forced to use a long, you might as well start doing the real-time * timer as a timeout like 4.3BSD. */ struct callout { int c_time; /* incremental time */ caddr_t c_arg; /* argument to routine */ void (*c_func) (caddr_t); /* routine */ struct callout *c_next; }; #ifdef KERNEL extern struct callout *callfree, callout[], calltodo; #endif ================================================ FILE: sys/sys/clist.h ================================================ /* * Raw structures for the character list routines. * * Copyright (c) 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ struct cblock { struct cblock *c_next; char c_info [CBSIZE]; }; #ifdef KERNEL extern struct cblock cfree[]; struct cblock *cfreelist; int cfreecount; #endif ================================================ FILE: sys/sys/conf.h ================================================ #ifndef _CONF_H #define _CONF_H /* * Copyright (c) 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ struct uio; struct buf; struct tty; /* * Declaration of block device * switch. Each entry (row) is * the only link between the * main unix code and the driver. * The initialization of the * device switches is in the * file conf.c. */ struct bdevsw { int (*d_open) (dev_t, int, int); int (*d_close) (dev_t, int, int); void (*d_strategy) (struct buf*); daddr_t (*d_psize) (dev_t); /* query partition size */ int (*d_ioctl) (dev_t, u_int, caddr_t, int); int d_flags; /* tape flag */ }; #define MEM_MAJOR 1 /* * Character device switch. */ struct cdevsw { int (*d_open) (dev_t, int, int); int (*d_close) (dev_t, int, int); int (*d_read) (dev_t, struct uio*, int); int (*d_write) (dev_t, struct uio*, int); int (*d_ioctl) (dev_t, u_int, caddr_t, int); int (*d_stop) (struct tty*, int); struct tty *d_ttys; int (*d_select) (dev_t, int); void (*d_strategy) (struct buf*); char (*r_read) (dev_t); void (*r_write) (dev_t, char); }; #define UART_MAJOR 6 #define UARTUSB_MAJOR 7 #define GPANEL_MAJOR 16 #ifdef KERNEL #ifndef CONS_MINOR #define CONS_MINOR 0 #endif extern const struct bdevsw bdevsw[]; extern const struct cdevsw cdevsw[]; int rawrw (dev_t dev, struct uio *uio, int flag); #endif #endif ================================================ FILE: sys/sys/config.h ================================================ /* * Copyright (c) 1992, 1993 * The Regents of the University of California. All rights reserved. * Copyright (c) 2015 Serge Vakulenko * * This code is derived from software contributed to Berkeley by * Ralph Campbell. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ /* * This structure is used to encapsulate the routines for a device driver. * This allows an "object oriented" approach so a controller device driver * can support multiple attached devices or a device can be attached to * different types of controllers. */ struct driver { const char *d_name; /* driver name for vmstat and iostat */ int (*d_init)(); /* routine to probe & initialize device */ }; /* * This structure describes controllers directly connected to CPU * and is partially initialized in "ioconf.c" by the 'config' program. */ struct conf_ctlr { struct driver *ctlr_driver; /* controller driver routines */ int ctlr_unit; /* controller number */ char *ctlr_addr; /* address of controller */ int ctlr_pri; /* interrupt priority */ int ctlr_flags; /* flags */ int ctlr_alive; /* true if init routine succeeded */ }; /* * This structure describes devices connected to an interface * and is partially initialized in "ioconf.c" by the 'config' program. */ struct conf_device { struct driver *dev_driver; /* device driver routines */ struct driver *dev_cdriver; /* interface driver routines */ int dev_unit; /* device unit number */ int dev_ctlr; /* device interface number */ int dev_drive; /* device address number */ int dev_flags; /* flags */ /* assignment of signals to physical pins */ #define KCONF_MAXPINS 16 char dev_pins[KCONF_MAXPINS]; int dev_alive; /* true if init routine succeeded */ }; /* * This structure describes optional software services. */ struct conf_service { void (*svc_attach)(); /* routine to initialize service */ }; /* Define special unit types used by the config program */ #define QUES -1 /* -1 means '?' */ #define UNKNOWN -2 /* -2 means not set yet */ #ifdef KERNEL extern struct conf_ctlr conf_ctlr_init[]; extern struct conf_device conf_device_init[]; extern struct conf_service conf_service_init[]; #endif ================================================ FILE: sys/sys/dir.h ================================================ /* * Copyright (c) 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #ifndef _DIR_ #define _DIR_ #ifndef MAXNAMLEN #define MAXNAMLEN 63 #endif #define DIRBLKSIZ 1024 /* * inode numbers are ino_t rather than u_long now. before, when v7direct * was used for the kernel, inode numbers were u_short/ino_t anyways, and since * everything had to be recompiled when the fs structure was changed it seemed * like a good idea to change the "real direct structure". SMS */ struct direct { ino_t d_ino; /* inode number of entry */ u_short d_reclen; /* length of this record */ u_short d_namlen; /* length of string in d_name */ char d_name[MAXNAMLEN+1]; /* name must be no longer than this */ }; /* * A directory consists of some number of blocks of DIRBLKSIZ * bytes, where DIRBLKSIZ is chosen such that it can be transferred * to disk in a single atomic operation (e.g. 512 bytes on most machines). * * Each DIRBLKSIZ byte block contains some number of directory entry * structures, which are of variable length. Each directory entry has * a struct direct at the front of it, containing its inode number, * the length of the entry, and the length of the name contained in * the entry. These are followed by the name padded to a 4 byte boundary * with null bytes. All names are guaranteed null terminated. * The maximum length of a name in a directory is MAXNAMLEN. * * The macro DIRSIZ(dp) gives the amount of space required to represent * a directory entry. Free space in a directory is represented by * entries which have dp->d_reclen > DIRSIZ(dp). All DIRBLKSIZ bytes * in a directory block are claimed by the directory entries. This * usually results in the last entry in a directory having a large * dp->d_reclen. When entries are deleted from a directory, the * space is returned to the previous entry in the same directory * block by increasing its dp->d_reclen. If the first entry of * a directory block is free, then its dp->d_ino is set to 0. * Entries other than the first in a directory do not normally have * dp->d_ino set to 0. */ #undef DIRSIZ #define DIRSIZ(dp) \ ((((sizeof (struct direct) - (MAXNAMLEN+1)) + (dp)->d_namlen+1) + 3) &~ 3) /* * Definitions for library routines operating on directories. */ typedef struct _dirdesc { int dd_fd; long dd_loc; long dd_size; char dd_buf[DIRBLKSIZ]; struct direct dd_cur; } DIR; #ifndef NULL #define NULL 0 #endif #ifndef KERNEL extern DIR *opendir (const char *); extern struct direct *readdir (DIR *); extern long telldir (DIR *); extern void seekdir (DIR *, long); extern void closedir (DIR *); #define rewinddir(dirp) seekdir ((dirp), (long)0) #define dirfd(dirp) ((dirp)->dd_fd) #endif /* !KERNEL */ /* * Template for manipulating directories. * Should use struct direct's, but the name field * is MAXNAMLEN - 1, and this just won't do. */ #define dotdot_ino dtdt_ino #define dotdot_reclen dtdt_rec #define dotdot_name dtdt_name struct dirtemplate { ino_t dot_ino; u_short dot_reclen; u_short dot_namlen; char dot_name[4]; /* must be multiple of 4 */ ino_t dotdot_ino; u_short dotdot_reclen; u_short dotdot_namlen; char dotdot_name[4]; /* ditto */ }; #endif /* _DIR_ */ ================================================ FILE: sys/sys/disk.h ================================================ /* * Ioctl definitions for skeleton driver. * * Copyright (C) 2015 Serge Vakulenko * * Permission to use, copy, modify, and distribute this software * and its documentation for any purpose and without fee is hereby * granted, provided that the above copyright notice appear in all * copies and that both that the copyright notice and this * permission notice and warranty disclaimer appear in supporting * documentation, and that the name of the author not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * * The author disclaim all warranties with regard to this * software, including all implied warranties of merchantability * and fitness. In no event shall the author be liable for any * special, indirect or consequential damages or any damages * whatsoever resulting from loss of use, data or profits, whether * in an action of contract, negligence or other tortious action, * arising out of or in connection with the use or performance of * this software. */ #ifndef _SYS_DISK_H_ #define _SYS_DISK_H_ #include /* * IBM PC compatible partition table. */ #define MAXPARTITIONS 4 #define MBR_MAGIC 0xAA55 struct diskpart { /* the partition table */ u_char dp_status; /* active (bootable) flag */ #define DP_ACTIVE 0x80 u_char dp_start_chs[3]; /* ignored */ u_char dp_type; /* type of partition */ u_char dp_end_chs[3]; /* ignored */ u_int dp_offset; /* starting sector */ u_int dp_nsectors; /* number of sectors in partition */ }; /* * Partition types. */ #define PTYPE_UNUSED 0 /* unused */ #define PTYPE_BSDFFS 0xb7 /* 4.2BSD fast file system */ #define PTYPE_SWAP 0xb8 /* swap */ /* * Disk-specific ioctls. */ #define DIOCGETMEDIASIZE _IOR('d', 1, int) /* get size in kbytes */ #define DIOCREINIT _IO ('d', 2) /* re-initialize device */ #define DIOCGETPART _IOR('d', 3, struct diskpart) /* get partition */ #endif /* _SYS_DISK_H_ */ ================================================ FILE: sys/sys/dk.h ================================================ /* * Copyright (c) 1982, 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ /* * Instrumentation */ #define CPUSTATES 4 #define CP_USER 0 #define CP_NICE 1 #define CP_SYS 2 #define CP_IDLE 3 #define DK_NDRIVE 4 #if defined(KERNEL) && defined(UCB_METER) long cp_time[CPUSTATES]; /* number of ticks spent in each cpu state */ int dk_ndrive; /* number of drives being monitored */ int dk_busy; /* bit array of drive busy flags */ long dk_xfer[DK_NDRIVE]; /* number of transfers */ long dk_bytes[DK_NDRIVE]; /* number of bytes transfered */ char *dk_name[DK_NDRIVE]; /* names of monitored drives */ int dk_unit[DK_NDRIVE]; /* unit numbers of monitored drives */ int dk_n; /* number of dk numbers assigned so far */ long tk_nin; /* number of tty characters input */ long tk_nout; /* number of tty characters output */ #endif ================================================ FILE: sys/sys/dkbad.h ================================================ /* * Copyright (c) 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * * @(#)dkbad.h 1.1 (2.10BSD Berkeley) 12/1/86 */ /* * Definitions needed to perform bad sector * revectoring ala DEC STD 144. * * The bad sector information is located in the * first 5 even numbered sectors of the last * track of the disk pack. There are five * identical copies of the information, described * by the dkbad structure. * * Replacement sectors are allocated starting with * the first sector before the bad sector information * and working backwards towards the beginning of * the disk. A maximum of 126 bad sectors are supported. * The position of the bad sector in the bad sector table * determines which replacement sector it corresponds to. * * The bad sector information and replacement sectors * are conventionally only accessible through the * 'c' file system partition of the disk. If that * partition is used for a file system, the user is * responsible for making sure that it does not overlap * the bad sector information or any replacement sector.s */ /* * The 2.10BSD system defines MAXBAD as 32, not 126, although there * should be no problem with increasing that value. It's your basic * space tradeoff. Also, 2.10 drivers tend to have the bad sector * information available through the 'h' file system partition, although * there are exceptions to this rule. Note, this value is also present * in the bad144 program. */ #define MAXBAD 32 /* Maximum bad sectors supported */ struct dkbad { long bt_csn; /* cartridge serial number */ u_short bt_mbz; /* unused; should be 0 */ u_short bt_flag; /* -1 => alignment cartridge */ struct bt_bad { u_short bt_cyl; /* cylinder number of bad sector */ u_short bt_trksec; /* track and sector number */ } bt_bad[MAXBAD]; }; #define ECC 0 #define SSE 1 #define BSE 2 #define CONT 3 ================================================ FILE: sys/sys/errno.h ================================================ /* * Copyright (c) 1982, 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * * @(#)errno.h 7.1.3 (2.11BSD) 1999/9/6 */ #ifndef KERNEL extern int errno; /* global error number */ #endif #define EPERM 1 /* Not owner */ #define ENOENT 2 /* No such file or directory */ #define ESRCH 3 /* No such process */ #define EINTR 4 /* Interrupted system call */ #define EIO 5 /* I/O error */ #define ENXIO 6 /* No such device or address */ #define E2BIG 7 /* Arg list too long */ #define ENOEXEC 8 /* Exec format error */ #define EBADF 9 /* Bad file number */ #define ECHILD 10 /* No children */ #define EAGAIN 11 /* No more processes */ #define ENOMEM 12 /* Not enough core */ #define EACCES 13 /* Permission denied */ #define EFAULT 14 /* Bad address */ #define ENOTBLK 15 /* Block device required */ #define EBUSY 16 /* Mount device busy */ #define EEXIST 17 /* File exists */ #define EXDEV 18 /* Cross-device link */ #define ENODEV 19 /* No such device */ #define ENOTDIR 20 /* Not a directory*/ #define EISDIR 21 /* Is a directory */ #define EINVAL 22 /* Invalid argument */ #define ENFILE 23 /* File table overflow */ #define EMFILE 24 /* Too many open files */ #define ENOTTY 25 /* Not a typewriter */ #define ETXTBSY 26 /* Text file busy */ #define EFBIG 27 /* File too large */ #define ENOSPC 28 /* No space left on device */ #define ESPIPE 29 /* Illegal seek */ #define EROFS 30 /* Read-only file system */ #define EMLINK 31 /* Too many links */ #define EPIPE 32 /* Broken pipe */ /* math software */ #define EDOM 33 /* Argument too large */ #define ERANGE 34 /* Result too large */ /* non-blocking and interrupt i/o */ #define EWOULDBLOCK 35 /* Operation would block */ #define EDEADLK EWOULDBLOCK /* ditto */ #define EINPROGRESS 36 /* Operation now in progress */ #define EALREADY 37 /* Operation already in progress */ /* ipc/network software */ /* argument errors */ #define ENOTSOCK 38 /* Socket operation on non-socket */ #define EDESTADDRREQ 39 /* Destination address required */ #define EMSGSIZE 40 /* Message too long */ #define EPROTOTYPE 41 /* Protocol wrong type for socket */ #define ENOPROTOOPT 42 /* Protocol not available */ #define EPROTONOSUPPORT 43 /* Protocol not supported */ #define ESOCKTNOSUPPORT 44 /* Socket type not supported */ #define EOPNOTSUPP 45 /* Operation not supported on socket */ #define EPFNOSUPPORT 46 /* Protocol family not supported */ #define EAFNOSUPPORT 47 /* Address family not supported by protocol family */ #define EADDRINUSE 48 /* Address already in use */ #define EADDRNOTAVAIL 49 /* Can't assign requested address */ /* operational errors */ #define ENETDOWN 50 /* Network is down */ #define ENETUNREACH 51 /* Network is unreachable */ #define ENETRESET 52 /* Network dropped connection on reset */ #define ECONNABORTED 53 /* Software caused connection abort */ #define ECONNRESET 54 /* Connection reset by peer */ #define ENOBUFS 55 /* No buffer space available */ #define EISCONN 56 /* Socket is already connected */ #define ENOTCONN 57 /* Socket is not connected */ #define ESHUTDOWN 58 /* Can't send after socket shutdown */ #define ETOOMANYREFS 59 /* Too many references: can't splice */ #define ETIMEDOUT 60 /* Connection timed out */ #define ECONNREFUSED 61 /* Connection refused */ /* */ #define ELOOP 62 /* Too many levels of symbolic links */ #define ENAMETOOLONG 63 /* File name too long */ /* should be rearranged */ #define EHOSTDOWN 64 /* Host is down */ #define EHOSTUNREACH 65 /* No route to host */ #define ENOTEMPTY 66 /* Directory not empty */ /* quotas & mush */ #define EPROCLIM 67 /* Too many processes */ #define EUSERS 68 /* Too many users */ #define EDQUOT 69 /* Disc quota exceeded */ /* Network File System */ #define ESTALE 70 /* Stale NFS file handle */ #define EREMOTE 71 /* Too many levels of remote in path */ #define EBADRPC 72 /* RPC struct is bad */ #define ERPCMISMATCH 73 /* RPC version wrong */ #define EPROGUNAVAIL 74 /* RPC prog. not avail */ #define EPROGMISMATCH 75 /* Program version wrong */ #define EPROCUNAVAIL 76 /* Bad procedure for program */ #define ENOLCK 77 /* No locks available */ #define ENOSYS 78 /* Function not implemented */ #define EFTYPE 79 /* Inappropriate file type or format */ #define EAUTH 80 /* Authentication error */ #define ENEEDAUTH 81 /* Need authenticator */ #define ELAST 81 /* Must be equal largest errno */ #ifdef KERNEL /* pseudo-errors returned inside kernel to modify return back to user mode */ #define ERESTART -1 /* restart syscall */ #define EJUSTRETURN -2 /* don't modify regs, just return */ #endif ================================================ FILE: sys/sys/exec.h ================================================ /* * Copyright (c) 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #ifndef _SYS_EXEC_H_ #define _SYS_EXEC_H_ #ifdef KERNEL #define SHSIZE 64 #define SHPATHLEN 64 #define STRLEN 32 #include "exec_aout.h" #include "exec_elf.h" #define NO_ADDR ((caddr_t)(~0U)) /* Indicates addr. not yet filled in */ struct memsect { caddr_t vaddr; unsigned len; }; struct exec_params { char *userfname; /* The arguments to the exec() call */ char **userargp; char **userenvp; union { char sh[SHSIZE]; struct exec aout; struct elf_ehdr elf; } hdr; /* head of file to exec */ int hdr_len; /* number of bytes valid in image_header */ char **argp, **envp; u_short argc, envc; /* count of argument and environment strings */ u_short argbc, envbc; /* total number of chars in argc and envc string pool */ union { struct { char interpname[20]; /* real name of the script interpreter */ char interparg[SHPATHLEN]; /* interpreter arg */ char interpreted; /* flag - this executable is interpreted */ } sh; struct { struct buf *stbp; /* String table buffer pointer */ int stbpos; /* String table pos in buffer */ int stsize; /* String table size */ int stoffset; /* String table file pos */ char str[STRLEN]; } elf; struct { } aout; }; gid_t gid; uid_t uid; #define MAXALLOCBUF 6 struct { struct buf *bp; /* Memory allocator buffer */ u_short fill; /* Memory allocator "free" pointer */ } alloc[MAXALLOCBUF]; u_long ep_taddr, ep_tsize, ep_daddr, ep_dsize; struct inode *ip; /* executable file ip */ struct memsect text, data, bss, heap, stack; }; struct execsw { int (*es_check)(struct exec_params *epp); const char* es_name; }; extern const struct execsw execsw[]; extern int nexecs, exec_maxhdrsz; struct buf *exec_copy_args(char **argp, struct exec_params *epp, int isargv, int *argc, int *argbc); int exec_check(struct exec_params *epp); void exec_setupstack(unsigned entryaddr, struct exec_params *epp); void exec_alloc_freeall(struct exec_params *epp); void *exec_alloc(int size, int ru, struct exec_params *epp); int exec_estab(struct exec_params *epp); void exec_save_args(struct exec_params *epp); void exec_clear(struct exec_params *epp); #else /* KERNEL */ #include #endif #endif ================================================ FILE: sys/sys/exec_aout.h ================================================ #ifndef _SYS_EXEC_AOUT_H_ #define _SYS_EXEC_AOUT_H_ /* * Header prepended to each a.out file. */ struct exec { unsigned a_midmag; /* magic number */ unsigned a_text; /* size of text segment */ unsigned a_data; /* size of initialized data */ unsigned a_bss; /* size of uninitialized data */ unsigned a_reltext; /* size of text relocation info */ unsigned a_reldata; /* size of data relocation info */ unsigned a_syms; /* size of symbol table */ unsigned a_entry; /* entry point */ }; #define a_magic a_midmag & 0xffff /* a_magic (a_midmag & 0x0000ffff) */ #define RMAGIC 0406 /* relocatable object file */ #define OMAGIC 0407 /* old impure format */ #define NMAGIC 0410 /* read-only text */ /* * a_mid ((a_midmag & 0x03ff0000) >> 16) */ #define MID_ZERO 0 /* unknown - implementation dependent */ #define MID_SUN010 1 /* sun 68010/68020 binary */ #define MID_SUN020 2 /* sun 68020-only binary */ #define MID_PC386 100 /* 386 PC binary. (so quoth BFD) */ #define MID_HP200 200 /* hp200 (68010) BSD binary */ #define MID_I386 134 /* i386 BSD binary */ #define MID_M68K 135 /* m68k BSD binary with 8K page sizes */ #define MID_M68K4K 136 /* m68k BSD binary with 4K page sizes */ #define MID_NS32532 137 /* ns32532 */ #define MID_SPARC 138 /* sparc */ #define MID_PMAX 139 /* pmax */ #define MID_VAX1K 140 /* vax 1K page size binaries */ #define MID_ALPHA 141 /* Alpha BSD binary */ #define MID_MIPS 142 /* big-endian MIPS */ #define MID_ARM6 143 /* ARM6 */ #define MID_SH3 145 /* SH3 */ #define MID_POWERPC 149 /* big-endian PowerPC */ #define MID_VAX 150 /* vax */ #define MID_SPARC64 151 /* LP64 sparc */ #define MID_HP300 300 /* hp300 (68020+68881) BSD binary */ #define MID_HPUX 0x20C /* hp200/300 HP-UX binary */ #define MID_HPUX800 0x20B /* hp800 HP-UX binary */ /* * a_flags ((a_midmag & 0xfc000000 ) << 26) */ #define EX_PIC 0x10 #define EX_DYNAMIC 0x20 #define EX_DPMASK 0x30 /* * Interpretation of the (a_flags & EX_DPMASK) bits: * * 00 traditional executable or object file * 01 object file contains PIC code (set by `as -k') * 10 dynamic executable * 11 position independent executable image * (eg. a shared library) */ /* * The a.out structure's a_midmag field is a network-byteorder encoding * of this int * FFFFFFmmmmmmmmmmMMMMMMMMMMMMMMMM * Where `F' is 6 bits of flag like EX_DYNAMIC, * `m' is 10 bits of machine-id like MID_I386, and * `M' is 16 bits worth of magic number, ie. ZMAGIC. * The macros below will set/get the needed fields. */ #define N_GETMAGIC(ex) (((ex).a_midmag)&0x0000ffff) #define N_GETMID(ex) ((((ex).a_midmag)&0x03ff0000) >> 16) #define N_GETFLAG(ex) ((((ex).a_midmag)&0xfc000000 ) << 26) /* Valid magic number check. */ #define N_BADMAG(x) (N_GETMAGIC(x) != RMAGIC && \ N_GETMAGIC(x) != OMAGIC && \ N_GETMAGIC(x) != NMAGIC) /* Text segment offset. */ #define N_TXTOFF(x) sizeof(struct exec) /* Data segment offset. */ #define N_DATOFF(x) (N_TXTOFF(x) + (x).a_text) /* Text relocation table offset. */ #define N_TRELOFF(x) (N_DATOFF(x) + (x).a_data) /* Data relocation table offset. */ #define N_DRELOFF(x) (N_TRELOFF(x) + (x).a_reltext) /* Symbol table offset. */ #define N_SYMOFF(x) (N_GETMAGIC(x) == RMAGIC ? \ N_DRELOFF(x) + (x).a_reldata : \ N_DATOFF(x) + (x).a_data) #endif ================================================ FILE: sys/sys/exec_elf.h ================================================ /* $NetBSD: exec_elf.h,v 1.37.4.1 2000/07/26 23:57:06 mycroft Exp $ */ /*- * Copyright (c) 1994 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Christos Zoulas. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the NetBSD * Foundation, Inc. and its contributors. * 4. Neither the name of The NetBSD Foundation nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ #ifndef _SYS_EXEC_ELF_H_ #define _SYS_EXEC_ELF_H_ #ifndef _SYS_TYPES_H_ #include #endif /* * ELF Header */ #define ELF_NIDENT 16 struct elf_ehdr { unsigned char e_ident[ELF_NIDENT]; /* Id bytes */ unsigned short e_type; /* file type */ unsigned short e_machine; /* machine type */ unsigned int e_version; /* version number */ unsigned int e_entry; /* entry point */ unsigned int e_phoff; /* Program header table offset */ unsigned int e_shoff; /* Section header table offset */ unsigned int e_flags; /* Processor flags (currently unused, should be 0) */ unsigned short e_ehsize; /* sizeof elf_ehdr */ unsigned short e_phentsize; /* Program header entry size */ unsigned short e_phnum; /* Number of program headers */ unsigned short e_shentsize; /* Section header entry size */ unsigned short e_shnum; /* Number of section headers */ unsigned short e_shstrndx; /* String table index */ }; /* e_ident offsets */ #define EI_MAG0 0 /* first byte of magic number */ #define ELFMAG0 0x7f #define EI_MAG1 1 /* second byte of magic number */ #define ELFMAG1 'E' #define EI_MAG2 2 /* third byte of magic number */ #define ELFMAG2 'L' #define EI_MAG3 3 /* fourth byte of magic number */ #define ELFMAG3 'F' #define EI_CLASS 4 /* 5:th byte: File class */ #define ELFCLASSNONE 0 /* Invalid class */ #define ELFCLASS32 1 /* 32-bit objects */ #define ELFCLASS64 2 /* 64-bit objects */ #define ELFCLASSNUM 3 #define EI_DATA 5 /* 6:th byte: Data encoding */ #define ELFDATANONE 0 /* Unknown data format */ #define ELFDATA2LSB 1 /* two's complement, little-endian */ #define ELFDATA2MSB 2 /* two's complement, big-endian */ #define EI_VERSION 6 /* Version number of the ELF specification */ #define EV_NONE 0 /* Invalid version */ #define EV_CURRENT 1 /* Current version */ #define EV_NUM 2 #define EI_OSABI 7 /* Operating system/ABI identification */ #define ELFOSABI_SYSV 0 /* UNIX System V ABI */ #define ELFOSABI_HPUX 1 /* HP-UX operating system */ #define ELFOSABI_NETBSD /* NetBSD ABI */ #define ELFOSABI_LINUX /* Linux ABI */ #define ELFOSABI_SOLARIS /* Solaris ABI */ #define ELFOSABI_FREEBSD /* FreeBSD ABI */ #define ELFOSABI_ARM /* ARM architecture ABI */ #define ELFOSABI_STANDALONE 255 /* Stand-alone (embedded) application */ #define EI_ABIVERSION 8 /* ABI version */ #define EI_PAD 9 /* Start of padding bytes up to EI_NIDENT*/ #define ELFMAG "\177ELF" #define SELFMAG 4 /* e_type */ #define ET_NONE 0 /* Unknown file type */ #define ET_REL 1 /* A Relocatable file */ #define ET_EXEC 2 /* An Executable file */ #define ET_DYN 3 /* A Shared object file */ #define ET_CORE 4 /* A Core file */ #define ET_NUM 5 #define ET_LOOS 0xfe00 /* Operating system specific range */ #define ET_HIOS 0xfeff #define ET_LOPROC 0xff00 /* Processor-specific range */ #define ET_HIPROC 0xffff /* e_machine */ #define EM_NONE 0 /* No machine */ #define EM_M32 1 /* AT&T WE 32100 */ #define EM_SPARC 2 /* SPARC */ #define EM_386 3 /* Intel 80386 */ #define EM_68K 4 /* Motorola 68000 */ #define EM_88K 5 /* Motorola 88000 */ #define EM_486 6 /* Intel 80486 */ #define EM_860 7 /* Intel 80860 */ #define EM_MIPS 8 /* MIPS I Architecture */ #define EM_S370 9 /* Amdahl UTS on System/370 */ #define EM_MIPS_RS3_LE 10 /* MIPS RS3000 Little-endian */ #define EM_RS6000 11 /* IBM RS/6000 XXX reserved */ #define EM_PARISC 15 /* Hewlett-Packard PA-RISC */ #define EM_NCUBE 16 /* NCube XXX reserved */ #define EM_VPP500 17 /* Fujitsu VPP500 */ #define EM_SPARC32PLUS 18 /* Enhanced instruction set SPARC */ #define EM_960 19 /* Intel 80960 */ #define EM_PPC 20 /* PowerPC */ #define EM_V800 36 /* NEC V800 */ #define EM_FR20 37 /* Fujitsu FR20 */ #define EM_RH32 38 /* TRW RH-32 */ #define EM_RCE 39 /* Motorola RCE */ #define EM_ARM 40 /* Advanced RISC Machines ARM */ #define EM_ALPHA 41 /* DIGITAL Alpha */ #define EM_SH 42 /* Hitachi Super-H */ #define EM_SPARCV9 43 /* SPARC Version 9 */ #define EM_TRICORE 44 /* Siemens Tricore */ #define EM_ARC 45 /* Argonaut RISC Core */ #define EM_H8_300 46 /* Hitachi H8/300 */ #define EM_H8_300H 47 /* Hitachi H8/300H */ #define EM_H8S 48 /* Hitachi H8S */ #define EM_H8_500 49 /* Hitachi H8/500 */ #define EM_IA_64 50 /* Intel Merced Processor */ #define EM_MIPS_X 51 /* Stanford MIPS-X */ #define EM_COLDFIRE 52 /* Motorola Coldfire */ #define EM_68HC12 53 /* Motorola MC68HC12 */ #define EM_VAX 75 /* DIGITAL VAX */ #define EM_ALPHA_EXP 36902 /* used by NetBSD/alpha; obsolete */ #define EM_NUM 36903 /* * ELF Program Header */ struct elf_phdr { unsigned int p_type; /* entry type */ unsigned int p_offset; /* file offset */ unsigned int p_vaddr; /* virtual address */ unsigned int p_paddr; /* physical address (reserved, 0) */ unsigned int p_filesz; /* file size of segment (may be 0) */ unsigned int p_memsz; /* memory size of segment (may be 0) */ unsigned int p_flags; /* flags */ unsigned int p_align; /* memory & file alignment */ }; /* p_type */ #define PT_NULL 0 /* Program header table entry unused */ #define PT_LOAD 1 /* Loadable program segment */ #define PT_DYNAMIC 2 /* Dynamic linking information */ #define PT_INTERP 3 /* Program interpreter */ #define PT_NOTE 4 /* Auxiliary information */ #define PT_SHLIB 5 /* Reserved, unspecified semantics */ #define PT_PHDR 6 /* Entry for header table itself */ #define PT_NUM 7 #define PT_LOPROC 0x70000000 /* Start of processor-specific semantics */ #define PT_HIPROC 0x7fffffff /* end of processor-specific semantics */ #define PT_GNU_STACK /* GNU stack extension */ /* p_flags */ #define PF_R 0x4 /* Segment is readable */ #define PF_W 0x2 /* Segment is writable */ #define PF_X 0x1 /* Segment is executable */ /* A text segment commonly have PF_X|PF_R, a data segment PF_X|PF_W and PF_R */ #define PF_MASKOS 0x0ff00000 /* Opersting system specific values */ #define PF_MASKPROC 0xf0000000 /* Processor-specific values */ #define PT_MIPS_REGINFO 0x70000000 /* * Section Headers */ struct elf_shdr { unsigned int sh_name; /* section name (.shstrtab index) */ unsigned int sh_type; /* section type */ unsigned int sh_flags; /* section flags */ unsigned int sh_addr; /* virtual address */ unsigned int sh_offset; /* file offset */ unsigned int sh_size; /* section size */ unsigned int sh_link; /* link to another */ unsigned int sh_info; /* misc info */ unsigned int sh_addralign; /* memory alignment */ unsigned int sh_entsize; /* table entry size */ }; /* sh_type */ #define SHT_NULL 0 /* inactive */ #define SHT_PROGBITS 1 /* program defined contents */ #define SHT_SYMTAB 2 /* holds symbol table */ #define SHT_STRTAB 3 /* holds string table */ #define SHT_RELA 4 /* holds relocation info with explicit addends */ #define SHT_HASH 5 /* holds symbol hash table */ #define SHT_DYNAMIC 6 /* holds dynamic linking information */ #define SHT_NOTE 7 /* holds information marking */ #define SHT_NOBITS 8 /* holds a section that does not occupy space */ #define SHT_REL 9 /* holds relocation info without explicit addends */ #define SHT_SHLIB 10 /* reserved with unspecified semantics */ #define SHT_DYNSYM 11 /* holds a minimal set of dynamic linking symbols */ #define SHT_NUM 12 #define SHT_LOOS 0x60000000 /* Operating system specific range */ #define SHT_HIOS 0x6fffffff #define SHT_LOPROC 0x70000000 /* Processor-specific range */ #define SHT_HIPROC 0x7fffffff #define SHT_LOUSER 0x80000000 /* Application-specific range */ #define SHT_HIUSER 0xffffffff /* sh_flags */ #define SHF_WRITE 0x1 /* Section contains writable data */ #define SHF_ALLOC 0x2 /* Section occupies memory */ #define SHF_EXECINSTR 0x4 /* Section contains executable insns */ #define SHF_MASKOS 0x0f000000 /* Operating system specific values */ #define SHF_MASKPROC 0xf0000000 /* Processor-specific values */ /* * Symbol Table */ struct elf_sym { unsigned int st_name; /* Symbol name (.symtab index) */ unsigned int st_value; /* value of symbol */ unsigned int st_size; /* size of symbol */ unsigned char st_info; /* type / binding attrs */ unsigned char st_other; /* unused */ unsigned short st_shndx; /* section index of symbol */ }; /* Symbol Table index of the undefined symbol */ #define ELF_SYM_UNDEFINED 0 /* st_info: Symbol Bindings */ #define STB_LOCAL 0 /* local symbol */ #define STB_GLOBAL 1 /* global symbol */ #define STB_WEAK 2 /* weakly defined global symbol */ #define STB_NUM 3 #define STB_LOOS 10 /* Operating system specific range */ #define STB_HIOS 12 #define STB_LOPROC 13 /* Processor-specific range */ #define STB_HIPROC 15 /* st_info: Symbol Types */ #define STT_NOTYPE 0 /* Type not specified */ #define STT_OBJECT 1 /* Associated with a data object */ #define STT_FUNC 2 /* Associated with a function */ #define STT_SECTION 3 /* Associated with a section */ #define STT_FILE 4 /* Associated with a file name */ #define STT_NUM 5 #define STT_LOOS 10 /* Operating system specific range */ #define STT_HIOS 12 #define STT_LOPROC 13 /* Processor-specific range */ #define STT_HIPROC 15 /* st_info utility macros */ #define ELF_ST_BIND(info) ((unsigned int)(info) >> 4) #define ELF_ST_TYPE(info) ((unsigned int)(info) & 0xf) #define ELF_ST_INFO(bind,type) ((unsigned char)(((bind) << 4) | ((type) & 0xf))) /* * Special section indexes */ #define SHN_UNDEF 0 /* Undefined section */ #define SHN_LORESERVE 0xff00 /* Start of Reserved range */ #define SHN_ABS 0xfff1 /* Absolute symbols */ #define SHN_COMMON 0xfff2 /* Common symbols */ #define SHN_HIRESERVE 0xffff #define SHN_LOPROC 0xff00 /* Start of Processor-specific range */ #define SHN_HIPROC 0xff1f #define SHN_LOOS 0xff20 /* Operating system specific range */ #define SHN_HIOS 0xff3f #define SHN_MIPS_ACOMMON 0xff00 #define SHN_MIPS_TEXT 0xff01 #define SHN_MIPS_DATA 0xff02 #define SHN_MIPS_SCOMMON 0xff03 /* * Relocation Entries */ struct elf_rel { unsigned int r_offset; /* where to do it */ unsigned int r_info; /* index & type of relocation */ }; struct elf_rela { unsigned int r_offset; /* where to do it */ unsigned int r_info; /* index & type of relocation */ int r_addend; /* adjustment value */ }; /* r_info utility macros */ #define ELF_R_SYM(info) ((info) >> 8) #define ELF_R_TYPE(info) ((info) & 0xff) #define ELF_R_INFO(sym, type) (((sym) << 8) + (unsigned char)(type)) /* * Dynamic Section structure array */ struct elf_dyn { unsigned int d_tag; /* entry tag value */ union { unsigned int d_ptr; unsigned int d_val; } d_un; }; /* d_tag */ #define DT_NULL 0 /* Marks end of dynamic array */ #define DT_NEEDED 1 /* Name of needed library (DT_STRTAB offset) */ #define DT_PLTRELSZ 2 /* Size, in bytes, of relocations in PLT */ #define DT_PLTGOT 3 /* Address of PLT and/or GOT */ #define DT_HASH 4 /* Address of symbol hash table */ #define DT_STRTAB 5 /* Address of string table */ #define DT_SYMTAB 6 /* Address of symbol table */ #define DT_RELA 7 /* Address of Rela relocation table */ #define DT_RELASZ 8 /* Size, in bytes, of DT_RELA table */ #define DT_RELAENT 9 /* Size, in bytes, of one DT_RELA entry */ #define DT_STRSZ 10 /* Size, in bytes, of DT_STRTAB table */ #define DT_SYMENT 11 /* Size, in bytes, of one DT_SYMTAB entry */ #define DT_INIT 12 /* Address of initialization function */ #define DT_FINI 13 /* Address of termination function */ #define DT_SONAME 14 /* Shared object name (DT_STRTAB offset) */ #define DT_RPATH 15 /* Library search path (DT_STRTAB offset) */ #define DT_SYMBOLIC 16 /* Start symbol search within local object */ #define DT_REL 17 /* Address of Rel relocation table */ #define DT_RELSZ 18 /* Size, in bytes, of DT_REL table */ #define DT_RELENT 19 /* Size, in bytes, of one DT_REL entry */ #define DT_PLTREL 20 /* Type of PLT relocation entries */ #define DT_DEBUG 21 /* Used for debugging; unspecified */ #define DT_TEXTREL 22 /* Relocations might modify non-writable seg */ #define DT_JMPREL 23 /* Address of relocations associated with PLT */ #define DT_BIND_NOW 24 /* Process all relocations at load-time */ #define DT_INIT_ARRAY 25 /* Address of initialization function array */ #define DT_FINI_ARRAY 26 /* Size, in bytes, of DT_INIT_ARRAY array */ #define DT_INIT_ARRAYSZ 27 /* Address of termination function array */ #define DT_FINI_ARRAYSZ 28 /* Size, in bytes, of DT_FINI_ARRAY array*/ #define DT_NUM 29 #define DT_LOOS 0x60000000 /* Operating system specific range */ #define DT_HIOS 0x6fffffff #define DT_LOPROC 0x70000000 /* Processor-specific range */ #define DT_HIPROC 0x7fffffff /* * Auxiliary Vectors */ struct elf_auxinfo { unsigned int a_type; /* 32-bit id */ unsigned int a_v; /* 32-bit id */ }; /* a_type */ #define AT_NULL 0 /* Marks end of array */ #define AT_IGNORE 1 /* No meaning, a_un is undefined */ #define AT_EXECFD 2 /* Open file descriptor of object file */ #define AT_PHDR 3 /* &phdr[0] */ #define AT_PHENT 4 /* sizeof(phdr[0]) */ #define AT_PHNUM 5 /* # phdr entries */ #define AT_PAGESZ 6 /* PAGESIZE */ #define AT_BASE 7 /* Interpreter base addr */ #define AT_FLAGS 8 /* Processor flags */ #define AT_ENTRY 9 /* Entry address of executable */ #define AT_DCACHEBSIZE 10 /* Data cache block size */ #define AT_ICACHEBSIZE 11 /* Instruction cache block size */ #define AT_UCACHEBSIZE 12 /* Unified cache block size */ /* Vendor specific */ #define AT_MIPS_NOTELF 10 /* XXX a_val != 0 -> MIPS XCOFF executable */ #define AT_SUN_UID 2000 /* euid */ #define AT_SUN_RUID 2001 /* ruid */ #define AT_SUN_GID 2002 /* egid */ #define AT_SUN_RGID 2003 /* rgid */ /* Solaris kernel specific */ #define AT_SUN_LDELF 2004 /* dynamic linker's ELF header */ #define AT_SUN_LDSHDR 2005 /* dynamic linker's section header */ #define AT_SUN_LDNAME 2006 /* dynamic linker's name */ #define AT_SUN_LPGSIZE 2007 /* large pagesize */ /* Other information */ #define AT_SUN_PLATFORM 2008 /* sysinfo(SI_PLATFORM) */ #define AT_SUN_HWCAP 2009 /* process hardware capabilities */ #define AT_SUN_IFLUSH 2010 /* do we need to flush the instruction cache? */ #define AT_SUN_CPU 2011 /* cpu name */ /* ibcs2 emulation band aid */ #define AT_SUN_EMUL_ENTRY 2012 /* coff entry point */ #define AT_SUN_EMUL_EXECFD 2013 /* coff file descriptor */ /* Executable's fully resolved name */ #define AT_SUN_EXECNAME 2014 /* * Note Headers */ struct elf_nhdr { unsigned int n_namesz; unsigned int n_descsz; unsigned int n_type; }; #define ELF_NOTE_TYPE_OSVERSION 1 /* NetBSD-specific note type: Emulation name. desc is emul name string. */ #define ELF_NOTE_NETBSD_TYPE_EMULNAME 2 /* NetBSD-specific note name and description sizes */ #define ELF_NOTE_NETBSD_NAMESZ 7 #define ELF_NOTE_NETBSD_DESCSZ 4 /* NetBSD-specific note name */ #define ELF_NOTE_NETBSD_NAME "NetBSD\0\0" /* GNU-specific note name and description sizes */ #define ELF_NOTE_GNU_NAMESZ 4 #define ELF_NOTE_GNU_DESCSZ 4 /* GNU-specific note name */ #define ELF_NOTE_GNU_NAME "GNU\0" /* GNU-specific OS/version value stuff */ #define ELF_NOTE_GNU_OSMASK (unsigned int)0xff000000 #define ELF_NOTE_GNU_OSLINUX (unsigned int)0x01000000 #define ELF_NOTE_GNU_OSMACH (unsigned int)0x00000000 #include #ifdef _KERNEL #define ELF_AUX_ENTRIES 8 /* Size of aux array passed to loader */ struct elf_args { unsigned int arg_entry; /* program entry point */ unsigned int arg_interp; /* Interpreter load address */ unsigned int arg_phaddr; /* program header address */ unsigned int arg_phentsize; /* Size of program header */ unsigned int arg_phnum; /* Number of program headers */ }; #ifndef _LKM #include "opt_execfmt.h" #endif int exec_elf_makecmds __P((struct proc *, struct exec_package *)); int elf_read_from __P((struct proc *, struct vnode *, u_long, caddr_t, int)); void *elf_copyargs __P((struct exec_package *, struct ps_strings *, void *, void *)); /* common */ int exec_elf_setup_stack __P((struct proc *, struct exec_package *)); #endif /* _KERNEL */ #endif /* !_SYS_EXEC_ELF_H_ */ ================================================ FILE: sys/sys/fcntl.h ================================================ /*- * Copyright (c) 1983, 1990, 1993 * The Regents of the University of California. All rights reserved. * (c) UNIX System Laboratories, Inc. * All or some portions of this file are derived from material licensed * to the University of California by American Telephone and Telegraph * Co. or Unix System Laboratories, Inc. and are reproduced herein with * the permission of UNIX System Laboratories, Inc. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)fcntl.h 8.3.1 (2.11BSD GTE) 11/25/94 * * Copied from 4.4-Lite and modified for 2.11BSD. The modifications consisted * of removing: function prototypes (I don't like them, the compiler does not * support them, and it would mean dragging in cdefs.h to leave them in here), * #ifndef _POSIX_SOURCE lines (silly) and record locking related definitions * If anyone adds any of the above it will be easy enough to modify this file. * In the meantime why bog down (or blow up) cpp any further? */ #ifndef _FCNTL_H_ #define _FCNTL_H_ /* * This file includes the definitions for open and fcntl * described by POSIX for ; it also includes * related kernel definitions. */ #ifndef KERNEL #include #endif /* * File status flags: these are used by open(2), fcntl(2). * They are also used (indirectly) in the kernel file structure f_flags, * which is a superset of the open/fcntl flags. Open flags and f_flags * are inter-convertible using OFLAGS(fflags) and FFLAGS(oflags). * Open/fcntl flags begin with O_; kernel-internal flags begin with F. */ /* open-only flags */ #define O_RDONLY 0x0000 /* open for reading only */ #define O_WRONLY 0x0001 /* open for writing only */ #define O_RDWR 0x0002 /* open for reading and writing */ #define O_ACCMODE 0x0003 /* mask for above modes */ /* * Kernel encoding of open mode; separate read and write bits that are * independently testable: 1 greater than the above. * * XXX * FREAD and FWRITE are excluded from the #ifdef KERNEL so that TIOCFLUSH, * which was documented to use FREAD/FWRITE, continues to work. */ #define FREAD 0x0001 #define FWRITE 0x0002 #define O_NONBLOCK 0x0004 /* no delay */ #define O_APPEND 0x0008 /* set append mode */ #define O_SHLOCK 0x0010 /* open with shared file lock */ #define O_EXLOCK 0x0020 /* open with exclusive file lock */ #define O_ASYNC 0x0040 /* signal pgrp when data ready */ #define O_FSYNC 0x0080 /* synchronous writes */ #define O_CREAT 0x0200 /* create if nonexistant */ #define O_TRUNC 0x0400 /* truncate to zero length */ #define O_EXCL 0x0800 /* error if already exists */ #ifdef KERNEL #define FMARK 0x1000 /* mark during gc() */ #define FDEFER 0x2000 /* defer for next gc pass */ #endif /* defined by POSIX 1003.1; not 2.11BSD default, so bit is required */ /* Not currently implemented but it may be placed on the TODO list shortly */ #define O_NOCTTY 0x4000 /* don't assign controlling terminal */ #ifdef KERNEL /* convert from open() flags to/from fflags; convert O_RD/WR to FREAD/FWRITE */ #define FFLAGS(oflags) ((oflags) + 1) #define OFLAGS(fflags) ((fflags) - 1) /* bits to save after open */ #define FMASK (FREAD|FWRITE|FAPPEND|FASYNC|FFSYNC|FNONBLOCK) /* bits settable by fcntl(F_SETFL, ...) */ #define FCNTLFLAGS (FAPPEND|FASYNC|FFSYNC|FNONBLOCK) #endif /* * The O_* flags used to have only F* names, which were used in the kernel * and by fcntl. We retain the F* names for the kernel f_flags field * and for backward compatibility for fcntl. */ #define FAPPEND O_APPEND /* kernel/compat */ #define FASYNC O_ASYNC /* kernel/compat */ #define FFSYNC O_FSYNC /* kernel */ #define FEXLOCK O_EXLOCK /* kernel */ #define FSHLOCK O_SHLOCK /* kernel */ #define FNONBLOCK O_NONBLOCK /* kernel */ #define FNDELAY O_NONBLOCK /* compat */ #define O_NDELAY O_NONBLOCK /* compat */ /* * Constants used for fcntl(2) */ /* command values */ #define F_DUPFD 0 /* duplicate file descriptor */ #define F_GETFD 1 /* get file descriptor flags */ #define F_SETFD 2 /* set file descriptor flags */ #define F_GETFL 3 /* get file status flags */ #define F_SETFL 4 /* set file status flags */ #define F_GETOWN 5 /* get SIGIO/SIGURG proc/pgrp */ #define F_SETOWN 6 /* set SIGIO/SIGURG proc/pgrp */ /* file descriptor flags (F_GETFD, F_SETFD) */ #define FD_CLOEXEC 1 /* close-on-exec flag */ /* lock operations for flock(2) */ #define LOCK_SH 0x01 /* shared file lock */ #define LOCK_EX 0x02 /* exclusive file lock */ #define LOCK_NB 0x04 /* don't block when locking */ #define LOCK_UN 0x08 /* unlock file */ #endif /* !_FCNTL_H_ */ ================================================ FILE: sys/sys/file.h ================================================ /* * Copyright (c) 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #include #ifndef _SYS_FILE_H_ #define _SYS_FILE_H_ /* * Descriptor table entry. * One for each kernel object. */ struct file { int f_flag; /* see below */ int f_type; /* descriptor type */ u_int f_count; /* reference count */ int f_msgcount; /* references from message queue */ union { caddr_t f_Data; struct socket *f_Socket; } f_un; off_t f_offset; }; #ifdef KERNEL struct uio; struct fileops { int (*fo_rw) (struct file *fp, struct uio *uio); int (*fo_ioctl) (struct file *fp, u_int com, char *data); int (*fo_select) (struct file *fp, int flag); int (*fo_close) (struct file *fp); }; #define f_data f_un.f_Data #define f_socket f_un.f_Socket extern struct file file[]; extern const struct fileops *const Fops[]; extern const struct fileops inodeops; extern const struct fileops pipeops; /* * Convert a user supplied file descriptor into a pointer to a file structure. */ struct file *getf (int f); /* * Allocate a user file descriptor and a file structure. */ struct file *falloc (void); /* * Internal form of close. */ int closef (struct file *fp); /* * Set/clear file flags: nonblock and async. */ int fset (struct file *fp, int bit, int value); /* * Get/set process group id for a file. */ int fgetown (struct file *fp, int *valuep); int fsetown (struct file *fp, int value); /* * File table inode close routine. */ int vn_closefile (struct file *fp); /* * Place an advisory lock on an inode. */ int ino_lock (struct file *fp, int cmd); /* * Unlock a file. */ void ino_unlock (struct file *fp, int kind); int ino_ioctl (struct file *fp, u_int com, caddr_t data); #else /* KERNEL */ int flock(int fd, int operation); #endif /* KERNEL */ /* * Access call. */ #define F_OK 0 /* does file exist */ #define X_OK 1 /* is it executable by caller */ #define W_OK 2 /* writable by caller */ #define R_OK 4 /* readable by caller */ /* * Lseek call. */ #define L_SET 0 /* absolute offset */ #define L_INCR 1 /* relative to current offset */ #define L_XTND 2 /* relative to end of file */ #ifdef KERNEL #define GETF(fp, fd) { \ if ((unsigned)(fd) >= NOFILE || ((fp) = u.u_ofile[fd]) == NULL) { \ u.u_error = EBADF; \ return; \ } \ } #define DTYPE_INODE 1 /* file */ #define DTYPE_SOCKET 2 /* communications endpoint */ #define DTYPE_PIPE 3 /* I don't want to hear it, okay? */ #endif #endif /* _SYS_FILE_H_ */ ================================================ FILE: sys/sys/fs.h ================================================ /* * Copyright (c) 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #ifndef _SYS_FS_H_ #define _SYS_FS_H_ /* * The root inode is the root of the file system. * Inode 0 can't be used for normal purposes and * historically bad blocks were linked to inode 1, * thus the root inode is 2. (inode 1 is no longer used for * this purpose, however numerous dump tapes make this * assumption, so we are stuck with it) * The lost+found directory is given the next available * inode when it is created by ``mkfs''. */ #define SBSIZE DEV_BSIZE #define SUPERB ((daddr_t)0) /* block number of the super block */ #define ROOTINO ((ino_t)2) /* i number of all roots */ #define LOSTFOUNDINO (ROOTINO + 1) #define NICINOD 32 /* number of superblock inodes */ #define NICFREE 200 /* number of superblock free blocks */ /* * The path name on which the file system is mounted is maintained * in fs_fsmnt. MAXMNTLEN defines the amount of space allocated in * the super block for this name. */ #define MAXMNTLEN 28 /* * Super block for a file system. NOTE: The 'fs_flock' and 'fs_ilock' * fields MUST be on an even byte boundary because they are used as sleep() * channels and odd values specify a network sleep(). */ struct fs { u_int fs_magic1; /* magic word */ u_int fs_isize; /* first block after i-list */ u_int fs_fsize; /* size in blocks of entire volume */ u_int fs_swapsz; /* size in blocks of swap area */ int fs_nfree; /* number of addresses in fs_free */ daddr_t fs_free [NICFREE]; /* free block list */ int fs_ninode; /* number of inodes in fs_inode */ ino_t fs_inode [NICINOD]; /* free inode list */ int fs_flock; /* lock during free list manipulation */ int fs_fmod; /* super block modified flag */ int fs_ilock; /* lock during i-list manipulation */ int fs_ronly; /* mounted read-only flag */ time_t fs_time; /* last super block update */ u_int fs_tfree; /* total free blocks */ ino_t fs_tinode; /* total free inodes */ char fs_fsmnt [MAXMNTLEN]; /* ordinary file mounted on */ ino_t fs_lasti; /* start place for circular search */ ino_t fs_nbehind; /* est # free inodes before s_lasti */ u_int fs_flags; /* mount time flags */ u_int fs_magic2; /* magic word */ /* actually longer */ }; struct fblk { int df_nfree; /* number of addresses in df_free */ daddr_t df_free [NICFREE]; /* free block list */ }; #define FSMAGIC1 ('F' | 'S'<<8 | '<'<<16 | '<'<<24) #define FSMAGIC2 ('>' | '>'<<8 | 'F'<<16 | 'S'<<24) /* * Turn file system block numbers into disk block addresses. * This maps file system blocks to device size blocks. */ #define fsbtodb(b) ((daddr_t) (b)) #define dbtofsb(b) ((daddr_t) (b)) /* * Macros for handling inode numbers: * inode number to file system block offset. * inode number to file system block address. */ #define itoo(x) ((int)(((x) + INOPB - 1) % INOPB)) #define itod(x) ((daddr_t)((((u_int)(x) + INOPB - 1) / INOPB))) /* * The following macros optimize certain frequently calculated * quantities by using shifts and masks in place of divisions * modulos and multiplications. */ #define blkoff(loc) /* calculates (loc % fs->fs_bsize) */ \ ((loc) & DEV_BMASK) #define lblkno(loc) /* calculates (loc / fs->fs_bsize) */ \ ((unsigned) (loc) >> DEV_BSHIFT) /* * Determine the number of available blocks given a * percentage to hold in reserve */ #define freespace(fs, percentreserved) \ ((fs)->fs_tfree - ((fs)->fs_fsize - \ (fs)->fs_isize) * (percentreserved) / 100) /* * INOPB is the number of inodes in a secondary storage block. */ #define INOPB 16 /* MAXBSIZE / sizeof(dinode) */ /* * NINDIR is the number of indirects in a file system block. */ #define NINDIR (DEV_BSIZE / sizeof(daddr_t)) #define NSHIFT 8 /* log2(NINDIR) */ #define NMASK 0377L /* NINDIR - 1 */ /* * We continue to implement pipes within the file system because it would * be pretty tough for us to handle 10 4K blocked pipes on a 1M machine. * * 4K is the allowable buffering per write on a pipe. This is also roughly * the max size of the file created to implement the pipe. If this size is * bigger than 4096, pipes will be implemented with large files, which is * probably not good. */ #define MAXPIPSIZ (NDADDR * MAXBSIZE) #ifdef KERNEL struct inode; /* * Map a device number into a pointer to the incore super block. */ struct fs *getfs (dev_t dev); /* * Mount a filesystem on the given directory inode. */ struct fs *mountfs (dev_t dev, int flags, struct inode *ip); void mount_updname (struct fs *fs, char *on, char *from, int lenon, int lenfrom); /* * Sync a single filesystem. */ struct mount; int ufs_sync (struct mount *mp); /* * Check that a specified block number is in range. */ int badblock (struct fs *fp, daddr_t bn); /* * Print the name of a file system with an error diagnostic. */ void fserr (struct fs *fp, char *message); #endif /* KERNEL */ #endif /* _SYS_FS_H_ */ ================================================ FILE: sys/sys/glcd.h ================================================ #ifndef _GLCD_H #define _GLCD_H #include #include /* G13 */ #define TRIS_DI TRISG #define LAT_DI LATG #define PORT_DI PORTG #define PIN_DI 13 /* G12 */ #define TRIS_RW TRISG #define LAT_RW LATG #define PORT_RW PORTG #define PIN_RW 12 /* G14 */ #define TRIS_E TRISG #define LAT_E LATG #define PORT_E PORTG #define PIN_E 14 /* E1 */ #define TRIS_DB0 TRISE #define LAT_DB0 LATE #define PORT_DB0 PORTE #define PIN_DB0 1 /* E0 */ #define TRIS_DB1 TRISE #define LAT_DB1 LATE #define PORT_DB1 PORTE #define PIN_DB1 0 /* A7 */ #define TRIS_DB2 TRISA #define LAT_DB2 LATA #define PORT_DB2 PORTA #define PIN_DB2 7 /* A6 */ #define TRIS_DB3 TRISA #define LAT_DB3 LATA #define PORT_DB3 PORTA #define PIN_DB3 6 /* G0 */ #define TRIS_DB4 TRISG #define LAT_DB4 LATG #define PORT_DB4 PORTG #define PIN_DB4 0 /* G1 */ #define TRIS_DB5 TRISG #define LAT_DB5 LATG #define PORT_DB5 PORTG #define PIN_DB5 1 /* F1 */ #define TRIS_DB6 TRISF #define LAT_DB6 LATF #define PORT_DB6 PORTF #define PIN_DB6 1 /* F0 */ #define TRIS_DB7 TRISF #define LAT_DB7 LATF #define PORT_DB7 PORTF #define PIN_DB7 0 /* D7 */ #define TRIS_CS1 TRISD #define LAT_CS1 LATD #define PORT_CS1 PORTD #define PIN_CS1 7 /* D6 */ #define TRIS_CS2 TRISD #define LAT_CS2 LATD #define PORT_CS2 PORTD #define PIN_CS2 6 /* D5 */ #define TRIS_RES TRISD #define LAT_RES LATD #define PORT_RES PORTD #define PIN_RES 5 #define GLCD_CMD_OFF 0b00111110 #define GLCD_CMD_ON 0b00111111 #define GLCD_CMD_SET_Y 0b01000000 #define GLCD_CMD_SET_PAGE 0b10111000 #define GLCD_CMD_START 0b11000000 #define INPUT 1 #define OUTPUT 0 #define HIGH 1 #define LOW 0 #define DATA 1 #define INSTRUCTION 0 #define READ 1 #define WRITE 0 #define ENABLE 1 #define DISABLE 0 #define GLCD_STAT_BUSY 0b10000000 #define GLCD_STAT_ONOFF 0b00100000 #define GLCD_STAT_RESET 0b00010000 /* glcd interface */ struct glcd_command { u_char x1; u_char y1; u_char x2; u_char y2; u_char ink; }; #define GLCD_RESET _IOW('i', 1, struct glcd_command) #define GLCD_CLS _IOW('i', 2, struct glcd_command) #define GLCD_LOAD_PAGE _IOW('i', 3, struct glcd_command) #define GLCD_UPDATE _IOW('i', 4, struct glcd_command) #define GLCD_SET_PIXEL _IOW('i', 5, struct glcd_command) #define GLCD_CLEAR_PIXEL _IOW('i', 6, struct glcd_command) #define GLCD_LINE _IOW('i', 7, struct glcd_command) #define GLCD_BOX _IOW('i', 8, struct glcd_command) #define GLCD_FILLED_BOX _IOW('i', 9, struct glcd_command) #define GLCD_GOTO_XY _IOW('i', 10, struct glcd_command) #ifdef KERNEL #include "conf.h" extern int glcd_open(dev_t dev, int flag, int mode); extern int glcd_close(dev_t dev, int flag, int mode); extern int glcd_read(dev_t dev, struct uio *uio, int flag); extern int glcd_write(dev_t dev, struct uio *uio, int flag); extern int glcd_ioctl(dev_t dev, u_int cmd, caddr_t addr, int flag); #endif #endif ================================================ FILE: sys/sys/glob.h ================================================ #ifndef _GLOB_H #define _GLOB_H #ifdef KERNEL extern void rdglob(); extern void wrglob(); #else extern int rdglob(int); extern int wrglob(int,int); #endif #endif ================================================ FILE: sys/sys/gpanel.h ================================================ /* * Generic interface to a graphics panel device (TFT LCD, OLED and others). * * Copyright (C) 2015 Serge Vakulenko, * * Permission to use, copy, modify, and distribute this software * and its documentation for any purpose and without fee is hereby * granted, provided that the above copyright notice appear in all * copies and that both that the copyright notice and this * permission notice and warranty disclaimer appear in supporting * documentation, and that the name of the author not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * * The author disclaim all warranties with regard to this * software, including all implied warranties of merchantability * and fitness. In no event shall the author be liable for any * special, indirect or consequential damages or any damages * whatsoever resulting from loss of use, data or profits, whether * in an action of contract, negligence or other tortious action, * arising out of or in connection with the use or performance of * this software. */ #ifndef _GPANEL_H #define _GPANEL_H /* * Proportional/fixed font structure. */ struct gpanel_font_t { const char * name; /* font name */ int maxwidth; /* max width in pixels */ unsigned int height; /* height in pixels */ int ascent; /* ascent (baseline) height */ int firstchar; /* first character in bitmap */ int size; /* font size in characters */ const unsigned short *bits; /* 16-bit right-padded bitmap data */ const unsigned short *offset; /* offsets into bitmap data */ const unsigned char *width; /* character widths or 0 if fixed */ int defaultchar; /* default char (not glyph index) */ long bits_size; /* # words of bits */ }; struct gpanel_pixel_t { int color; /* pixel color */ int x, y; /* pixel position */ }; struct gpanel_clear_t { int color; /* pixel color */ int xsize, ysize; /* screen size */ }; struct gpanel_line_t { int color; /* line color */ int x0, y0; /* start point */ int x1, y1; /* end point */ }; struct gpanel_rect_t { int color; /* border or fill color */ int x0, y0; /* start point */ int x1, y1; /* end point */ }; struct gpanel_circle_t { int color; /* border color */ int x, y; /* center point */ int radius; /* circle radius */ }; struct gpanel_image_t { int x, y; /* start point */ int width, height; /* image size radius */ const unsigned short *image; /* array of pixels */ }; struct gpanel_char_t { const struct gpanel_font_t *font; /* font data */ int color; /* text color */ int background; /* background color or -1 for transparent */ int x, y; /* position */ int sym; /* unicode symbol index */ }; struct gpanel_text_t { const struct gpanel_font_t *font; /* font data */ int color; /* text color */ int background; /* background color or -1 for transparent */ int x, y; /* position */ const char *text; /* UTF-8 text */ }; #define GPANEL_CLEAR _IOW('g', 1, struct gpanel_clear_t) #define GPANEL_PIXEL _IOW('g', 2, struct gpanel_pixel_t) #define GPANEL_LINE _IOW('g', 3, struct gpanel_line_t) #define GPANEL_RECT _IOW('g', 4, struct gpanel_rect_t) #define GPANEL_FILL _IOW('g', 5, struct gpanel_rect_t) #define GPANEL_CIRCLE _IOW('g', 6, struct gpanel_circle_t) #define GPANEL_IMAGE _IOW('g', 7, struct gpanel_image_t) #define GPANEL_CHAR _IOW('g', 8, struct gpanel_char_t) #define GPANEL_TEXT _IOW('g', 9, struct gpanel_text_t) #ifndef KERNEL /* * User-level library. */ int gpanel_open(const char *devname); void gpanel_close(void); void gpanel_clear(int color, int *xsize, int *ysize); void gpanel_pixel(int color, int x, int y); void gpanel_line(int color, int x0, int y0, int x1, int y1); void gpanel_rect(int color, int x0, int y0, int x1, int y1); void gpanel_fill(int color, int x0, int y0, int x1, int y1); void gpanel_fill_triangle(int color, int x0, int y0, int x1, int y1, int x2, int y2); void gpanel_circle(int color, int x, int y, int radius); void gpanel_image(int x, int y, int width, int height, const unsigned short *data); void gpanel_char(const struct gpanel_font_t *font, int color, int background, int x, int y, int sym); void gpanel_text(const struct gpanel_font_t *font, int color, int background, int x, int y, const char *text); int gpanel_text_width(const struct gpanel_font_t *font, const char *text, int nchars); extern int _gpanel_fd; #else /* KERNEL */ /* * Kernel driver routines. */ struct uio; extern int gpanel_open(dev_t dev, int flag, int mode); extern int gpanel_close(dev_t dev, int flag, int mode); extern int gpanel_read(dev_t dev, struct uio *uio, int flag); extern int gpanel_write(dev_t dev, struct uio *uio, int flag); extern int gpanel_ioctl(dev_t dev, u_int cmd, caddr_t addr, int flag); extern int gpanel_read_byte(void); extern void gpanel_write_byte(int value); extern void gpanel_cs_active(void); extern void gpanel_cs_idle(void); extern void gpanel_rs_command(void); extern void gpanel_rs_data(void); extern void gpanel_wr_strobe(void); extern void gpanel_read_dir(void); extern void gpanel_write_dir(void); extern int gpanel_send_command(int value); extern int gpanel_send_data(int value); /* * Descriptor for access to the hardware-level driver. */ struct gpanel_hw { const char *name; void (*resize)(struct gpanel_hw *hw, int width, int height); void (*set_pixel)(int x, int y, int color); void (*fill_rectangle)(int x0, int y0, int x1, int y1, int color); void (*draw_image)(int x, int y, int width, int height, const unsigned short *data); void (*draw_glyph)(const struct gpanel_font_t *font, int color, int background, int x, int y, int width, const unsigned short *bits); }; extern int gpanel_width; extern int gpanel_height; extern void st7781_init_display(struct gpanel_hw *hw); extern void nt35702_init_display(struct gpanel_hw *hw); extern void ili9341_init_display(struct gpanel_hw *hw); extern void ili9481_init_display(struct gpanel_hw *hw); extern void s6d04h0_init_display(struct gpanel_hw *hw); #endif /* KERNEL */ #endif /* _GPANEL_H */ ================================================ FILE: sys/sys/gpio.h ================================================ /* * Copyright (c) 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * * @(#)gpio.h 1.4 (2.11BSD GTE) 1997/3/28 */ /* * Ioctl definitions */ #ifndef _GPIO_H #define _GPIO_H #include #include /* control general-purpose i/o pins */ #define GPIO_PORT(n) ((n) & 0xff) /* port number */ #define GPIO_PORTA GPIO_PORT(0) #define GPIO_PORTB GPIO_PORT(1) #define GPIO_PORTC GPIO_PORT(2) #define GPIO_PORTD GPIO_PORT(3) #define GPIO_PORTE GPIO_PORT(4) #define GPIO_PORTF GPIO_PORT(5) #define GPIO_PORTG GPIO_PORT(6) #define GPIO_COMMAND 0x1fff0000 /* command mask */ #define GPIO_CONFIN (IOC_VOID | 1 << 16 | 'g'<<8) /* configure as input */ #define GPIO_CONFOUT (IOC_VOID | 1 << 17 | 'g'<<8) /* configure as output */ #define GPIO_CONFOD (IOC_VOID | 1 << 18 | 'g'<<8) /* configure as open drain */ #define GPIO_DECONF (IOC_VOID | 1 << 19 | 'g'<<8) /* deconfigure */ #define GPIO_STORE (IOC_VOID | 1 << 20 | 'g'<<8) /* store all outputs */ #define GPIO_SET (IOC_VOID | 1 << 21 | 'g'<<8) /* set to 1 by mask */ #define GPIO_CLEAR (IOC_VOID | 1 << 22 | 'g'<<8) /* set to 0 by mask */ #define GPIO_INVERT (IOC_VOID | 1 << 23 | 'g'<<8) /* invert by mask */ #define GPIO_POLL (IOC_VOID | 1 << 24 | 'g'<<8) /* poll */ #define GPIO_LOL (IOC_IN | 1 << 25 | 'g'<<8) /* display lol picture */ #ifdef KERNEL #include "conf.h" int gpioopen (dev_t dev, int flag, int mode); int gpioclose (dev_t dev, int flag, int mode); int gpioread (dev_t dev, struct uio *uio, int flag); int gpiowrite (dev_t dev, struct uio *uio, int flag); int gpioioctl (dev_t dev, u_int cmd, caddr_t addr, int flag); #endif #endif ================================================ FILE: sys/sys/inode.h ================================================ /* * Copyright (c) 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ /* * The I node is the focus of all file activity in UNIX. * There is a unique inode allocated for each active file, * each current directory, each mounted-on file, text file, and the root. * An inode is 'named' by its dev/inumber pair. (iget/iget.c) * Data in icommon1 and icommon2 is read in from permanent inode on volume. */ /* * 28 of the di_addr address bytes are used; 7 addresses of 4 * bytes each: 4 direct (4Kb directly accessible) and 3 indirect. */ #define NDADDR 4 /* direct addresses in inode */ #define NIADDR 3 /* indirect addresses in inode */ #define NADDR (NDADDR + NIADDR) /* total addresses in inode */ struct icommon1 { u_short ic_mode; /* mode and type of file */ u_short ic_nlink; /* number of links to file */ uid_t ic_uid; /* owner's user id */ gid_t ic_gid; /* owner's group id */ off_t ic_size; /* number of bytes in file */ }; struct icommon2 { time_t ic_atime; /* time last accessed */ time_t ic_mtime; /* time last modified */ time_t ic_ctime; /* time created */ }; struct inode { struct inode *i_chain[2]; /* must be first */ u_int i_flag; u_int i_count; /* reference count */ dev_t i_dev; /* device where inode resides */ ino_t i_number; /* i number, 1-to-1 with device address */ u_int i_id; /* unique identifier */ struct fs *i_fs; /* file sys associated with this inode */ union { struct { u_short I_shlockc; /* count of shared locks */ u_short I_exlockc; /* count of exclusive locks */ } i_l; struct proc *I_rsel; /* pipe read select */ } i_un0; union { struct proc *I_wsel; /* pipe write select */ } i_un1; union { daddr_t I_addr[NADDR]; /* normal file/directory */ struct { daddr_t I_db[NDADDR]; /* normal file/directory */ daddr_t I_ib[NIADDR]; } i_f; struct { /* * the dummy field is here so that the de/compression * part of the iget/iput routines works for special * files. */ u_int I_dummy; dev_t I_rdev; /* dev type */ } i_d; } i_un2; union { daddr_t if_lastr; /* last read (read-ahead) */ struct { struct inode *if_freef; /* free list forward */ struct inode **if_freeb; /* free list back */ } i_fr; } i_un3; struct icommon1 i_ic1; u_int i_flags; /* user changeable flags */ struct icommon2 i_ic2; }; /* * Inode structure as it appears on * a disk block. */ struct dinode { struct icommon1 di_icom1; daddr_t di_addr[NADDR]; /* 7 block addresses 4 bytes each */ u_int di_reserved[1]; /* pad of 4 to make total size 64 */ u_int di_flags; struct icommon2 di_icom2; }; #define i_mode i_ic1.ic_mode #define i_nlink i_ic1.ic_nlink #define i_uid i_ic1.ic_uid #define i_gid i_ic1.ic_gid #define i_size i_ic1.ic_size #define i_shlockc i_un0.i_l.I_shlockc #define i_exlockc i_un0.i_l.I_exlockc #define i_rsel i_un0.I_rsel #define i_wsel i_un1.I_wsel #define i_db i_un2.i_f.I_db #define i_ib i_un2.i_f.I_ib #define i_atime i_ic2.ic_atime #define i_mtime i_ic2.ic_mtime #define i_ctime i_ic2.ic_ctime #define i_rdev i_un2.i_d.I_rdev #define i_addr i_un2.I_addr #define i_dummy i_un2.i_d.I_dummy #define i_lastr i_un3.if_lastr #define i_forw i_chain[0] #define i_back i_chain[1] #define i_freef i_un3.i_fr.if_freef #define i_freeb i_un3.i_fr.if_freeb #define di_ic1 di_icom1 #define di_ic2 di_icom2 #define di_mode di_ic1.ic_mode #define di_nlink di_ic1.ic_nlink #define di_uid di_ic1.ic_uid #define di_gid di_ic1.ic_gid #define di_size di_ic1.ic_size #define di_atime di_ic2.ic_atime #define di_mtime di_ic2.ic_mtime #define di_ctime di_ic2.ic_ctime #ifdef KERNEL struct stat; /* * Invalidate an inode. Used by the namei cache to detect stale * information. In order to save space and also reduce somewhat the * overhead - the i_id field is made into a u_short. If a pdp-11 can * invalidate 100 inodes per second, the cache will have to be invalidated * in about 11 minutes. Ha! * Assumes the cacheinvalall routine will map the namei cache. */ void cinvalall (void); #define cacheinval(ip) \ (ip)->i_id = ++nextinodeid; \ if (nextinodeid == 0) \ cinvalall(); u_int nextinodeid; /* unique id generator */ extern struct inode inode[]; /* the inode table itself */ struct inode *rootdir; /* pointer to inode of root directory */ /* * Initialize hash links for inodes and build inode free list. */ void ihinit (void); /* * Get an inode pointer of a file descriptor. */ struct inode *getinode (int fdes); /* * Allocate an inode in the file system. */ struct inode *ialloc (struct inode *pip); /* * Look up an inode by device, inumber. */ struct inode *iget (dev_t dev, struct fs *fs, ino_t ino); /* * Dereference an inode structure. On the last reference, * write the inode out and deallocate the file. */ void iput (struct inode *ip); /* * Make a new file. */ struct nameidata; struct inode *maknode (int mode, struct nameidata *ndp); /* * Open inode: initialize and validate special files. */ int openi (struct inode *ip, int mode); /* * Close inode: call the device driver for special (IBLK, ICHR) files. */ int closei (struct inode *ip, int flag); /* * Convert a pathname into a pointer to a locked inode. */ struct inode *namei (struct nameidata *ndp); enum uio_rw; int rdwri (enum uio_rw rw, struct inode *ip, caddr_t base, int len, off_t offset, int ioflg, int *aresid); struct uio; int rwip (struct inode *ip, struct uio *uio, int ioflag); /* * Check mode permission on inode pointer. */ int access (struct inode *ip, int mode); /* * Change the mode on a file. */ int chmod1 (struct inode *ip, int mode); /* * Change an owner of a file. */ int chown1 (struct inode *ip, int uid, int gid); /* * Lock/unlock an inode. */ void ilock (struct inode *ip); void iunlock (struct inode *ip); /* * Get inode statistics. */ int ino_stat (struct inode *ip, struct stat *sb); /* * Truncate the inode ip to at most length size. */ void itrunc (struct inode *oip, u_long length, int ioflags); /* * Update the inode with the current time. */ struct timeval; void iupdat (struct inode *ip, struct timeval *ta, struct timeval *tm, int waitfor); void irele (struct inode *ip); /* * Free an inode. */ void ifree (struct inode *ip, ino_t ino); /* * Free a block or fragment. */ void free (struct inode *ip, daddr_t bno); /* * Flush all the blocks associated with an inode. */ void syncip (struct inode *ip); /* * Remove any inodes in the inode cache belonging to dev. */ int iflush (dev_t dev); /* * Convert a pointer to an inode into a reference to an inode. */ void igrab (struct inode *ip); /* * Check if source directory is in the path of the target directory. */ int checkpath (struct inode *source, struct inode *target); /* * Check if a directory is empty or not. */ int dirempty (struct inode *ip, ino_t parentino); /* * Rewrite an existing directory entry to point at the inode supplied. */ void dirrewrite (struct inode *dp, struct inode *ip, struct nameidata *ndp); /* * Check that device is mounted somewhere. */ int ufs_mountedon (dev_t dev); /* * Set the attributes on a file. This was placed here because ufs_syscalls * is too large already (it will probably be split into two files eventually). */ struct vattr; int ufs_setattr (struct inode *ip, struct vattr *vap); /* * Cache flush, called when filesys is umounted. */ void nchinval (dev_t dev); #endif /* KERNEL */ /* i_flag */ #define ILOCKED 0x1 /* inode is locked */ #define IUPD 0x2 /* file has been modified */ #define IACC 0x4 /* inode access time to be updated */ #define IMOUNT 0x8 /* inode is mounted on */ #define IWANT 0x10 /* some process waiting on lock */ #define ITEXT 0x20 /* inode is pure text prototype */ #define ICHG 0x40 /* inode has been changed */ #define ISHLOCK 0x80 /* file has shared lock */ #define IEXLOCK 0x100 /* file has exclusive lock */ #define ILWAIT 0x200 /* someone waiting on file lock */ #define IMOD 0x400 /* inode has been modified */ #define IRENAME 0x800 /* inode is being renamed */ #define IPIPE 0x1000 /* inode is a pipe */ #define IRCOLL 0x2000 /* read select collision on pipe */ #define IWCOLL 0x4000 /* write select collision on pipe */ #define IXMOD 0x8000 /* inode is text, but impure (XXX) */ /* i_mode */ #define IFMT 0170000 /* type of file */ #define IFCHR 0020000 /* character special */ #define IFDIR 0040000 /* directory */ #define IFBLK 0060000 /* block special */ #define IFREG 0100000 /* regular */ #define IFLNK 0120000 /* symbolic link */ #define IFSOCK 0140000 /* socket */ #define ISUID 04000 /* set user id on execution */ #define ISGID 02000 /* set group id on execution */ #define ISVTX 01000 /* save swapped text even after use */ #define IREAD 0400 /* read, write, execute permissions */ #define IWRITE 0200 #define IEXEC 0100 #ifdef KERNEL /* * Flags for va_cflags. */ #define VA_UTIMES_NULL 0x01 /* utimes argument was NULL */ /* * Flags for ioflag. */ #define IO_UNIT 0x01 /* do I/O as atomic unit */ #define IO_APPEND 0x02 /* append write to end */ #define IO_SYNC 0x04 /* do I/O synchronously */ /*#define IO_NODELOCKED 0x08 not implemented */ #define IO_NDELAY 0x10 /* FNDELAY flag set in file table */ /* * This is a bit of a misnomer. 2.11BSD does not have 'vnodes' but it was * easier/simpler to keep the name 'vattr' than changing the name to something * like 'iattr'. * * This structure is a _subset_ of 4.4BSD's vnode attribute structure. ONLY * those attributes which can be *changed by the user* are present. Since we * do not have vnodes why initialize (and carry around) un-used members. */ struct vattr { mode_t va_mode; uid_t va_uid; gid_t va_gid; off_t va_size; time_t va_atime; time_t va_mtime; u_int va_flags; u_int va_vaflags; }; /* * Token indicating no attribute value yet assigned. */ #define VNOVAL (-1) /* * Initialize a inode attribute structure. */ #define VATTR_NULL(vp) { \ (vp)->va_mode = VNOVAL; \ (vp)->va_uid = VNOVAL; \ (vp)->va_gid = VNOVAL; \ (vp)->va_size = VNOVAL; \ (vp)->va_atime = VNOVAL; \ (vp)->va_mtime = VNOVAL; \ (vp)->va_flags = VNOVAL; \ (vp)->va_vaflags = VNOVAL; } /* * N.B: If the above structure changes be sure to modify the function * vattr_null in pdp/mch_xxx.s! */ #endif #define ILOCK(ip) { \ while ((ip)->i_flag & ILOCKED) { \ (ip)->i_flag |= IWANT; \ sleep((caddr_t)(ip), PINOD); \ } \ (ip)->i_flag |= ILOCKED; \ } #define IUNLOCK(ip) { \ (ip)->i_flag &= ~ILOCKED; \ if ((ip)->i_flag&IWANT) { \ (ip)->i_flag &= ~IWANT; \ wakeup((caddr_t)(ip)); \ } \ } #define IUPDAT(ip, t1, t2, waitfor) { \ if (ip->i_flag&(IUPD|IACC|ICHG|IMOD)) \ iupdat(ip, t1, t2, waitfor); \ } #define ITIMES(ip, t1, t2) { \ if ((ip)->i_flag&(IUPD|IACC|ICHG)) { \ (ip)->i_flag |= IMOD; \ if ((ip)->i_flag&IACC) \ (ip)->i_atime = (t1)->tv_sec; \ if ((ip)->i_flag&IUPD) \ (ip)->i_mtime = (t2)->tv_sec; \ if ((ip)->i_flag&ICHG) \ (ip)->i_ctime = time.tv_sec; \ (ip)->i_flag &= ~(IACC|IUPD|ICHG); \ } \ } ================================================ FILE: sys/sys/ioctl.h ================================================ /* * Copyright (c) 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * * @(#)ioctl.h 1.4 (2.11BSD GTE) 1997/3/28 */ /* * Ioctl definitions */ #ifndef _IOCTL_ #define _IOCTL_ #ifdef KERNEL #include "ttychars.h" #include "ttydev.h" #else #include #include int ioctl (int d, int request, ...); #endif struct tchars { char t_intrc; /* interrupt */ char t_quitc; /* quit */ char t_startc; /* start output */ char t_stopc; /* stop output */ char t_eofc; /* end-of-file */ char t_brkc; /* input delimiter (like nl) */ }; struct ltchars { char t_suspc; /* stop process signal */ char t_dsuspc; /* delayed stop process signal */ char t_rprntc; /* reprint line */ char t_flushc; /* flush output (toggles) */ char t_werasc; /* word erase */ char t_lnextc; /* literal next character */ }; /* * Structure for TIOCGETP and TIOCSETP ioctls. */ #ifndef _SGTTYB_ #define _SGTTYB_ struct sgttyb { char sg_ispeed; /* input speed */ char sg_ospeed; /* output speed */ char sg_erase; /* erase character */ char sg_kill; /* kill character */ short sg_flags; /* mode flags */ }; #endif /* * Window/terminal size structure. * This information is stored by the kernel * in order to provide a consistent interface, * but is not used by the kernel. * * Type must be "unsigned short" so that types.h not required. */ struct winsize { unsigned short ws_row; /* rows, in characters */ unsigned short ws_col; /* columns, in characters */ unsigned short ws_xpixel; /* horizontal size, pixels */ unsigned short ws_ypixel; /* vertical size, pixels */ }; /* * Pun for SUN. */ struct ttysize { unsigned short ts_lines; unsigned short ts_cols; unsigned short ts_xxx; unsigned short ts_yyy; }; #define TIOCGSIZE TIOCGWINSZ #define TIOCSSIZE TIOCSWINSZ #ifndef _IO /* * Ioctl's have the command encoded in the lower word, * and the size of any in or out parameters in the upper * word. The high 2 bits of the upper word are used * to encode the in/out status of the parameter; for now * we restrict parameters to at most 256 bytes (disklabels are 216 bytes). */ #define IOCPARM_MASK 0xff /* parameters must be < 256 bytes */ #define IOC_VOID 0x20000000 /* no parameters */ #define IOC_OUT 0x40000000 /* copy out parameters */ #define IOC_IN 0x80000000 /* copy in parameters */ #define IOC_INOUT (IOC_IN|IOC_OUT) #define _IO(x,y) (IOC_VOID | ((x)<<8)|y) #define _IOR(x,y,t) (IOC_OUT |((sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|y) #define _IOW(x,y,t) (IOC_IN |((sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|y) /* this should be _IORW, but stdio got there first */ #define _IOWR(x,y,t) (IOC_INOUT|((sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|y) #define _ION(x,y,n) (IOC_INOUT| (((n)&IOCPARM_MASK)<<16)|((x)<<8)|y) #endif /* * tty ioctl commands */ #define TIOCGETD _IOR('t', 0, int) /* get line discipline */ #define TIOCSETD _IOW('t', 1, int) /* set line discipline */ #define TIOCHPCL _IO ('t', 2) /* hang up on last close */ #define TIOCMODG _IOR('t', 3, int) /* get modem control state */ #define TIOCMODS _IOW('t', 4, int) /* set modem control state */ #define TIOCM_LE 0001 /* line enable */ #define TIOCM_DTR 0002 /* data terminal ready */ #define TIOCM_RTS 0004 /* request to send */ #define TIOCM_ST 0010 /* secondary transmit */ #define TIOCM_SR 0020 /* secondary receive */ #define TIOCM_CTS 0040 /* clear to send */ #define TIOCM_CAR 0100 /* carrier detect */ #define TIOCM_CD TIOCM_CAR #define TIOCM_RNG 0200 /* ring */ #define TIOCM_RI TIOCM_RNG #define TIOCM_DSR 0400 /* data set ready */ #define TIOCGETP _IOR('t', 8,struct sgttyb)/* get parameters -- gtty */ #define TIOCSETP _IOW('t', 9,struct sgttyb)/* set parameters -- stty */ #define TIOCSETN _IOW('t', 10,struct sgttyb)/* as above, but no flushtty */ #define TIOCEXCL _IO ('t', 13) /* set exclusive use of tty */ #define TIOCNXCL _IO ('t', 14) /* reset exclusive use of tty */ #define TIOCFLUSH _IOW('t', 16, int) /* flush buffers */ #define TIOCSETC _IOW('t', 17,struct tchars)/* set special characters */ #define TIOCGETC _IOR('t', 18,struct tchars)/* get special characters */ #define TANDEM 0x00000001 /* send stopc on out q full */ #define CBREAK 0x00000002 /* half-cooked mode */ /* 0x4 (old LCASE) */ #define ECHO 0x00000008 /* echo input */ #define CRMOD 0x00000010 /* map \r to \r\n on output */ #define RAW 0x00000020 /* no i/o processing */ #define ODDP 0x00000040 /* get/send odd parity */ #define EVENP 0x00000080 /* get/send even parity */ #define ANYP 0x000000c0 /* get any parity/send none */ /* 0x100 (old NLDELAY) */ /* 0x200 */ #define XTABS 0x00000400 /* expand tabs on output */ /* 0x0800 (part of old XTABS) */ /* 0x1000 (old CRDELAY) */ /* 0x2000 */ /* 0x4000 (old VTDELAY) */ /* 0x8000 (old BSDELAY) */ #define CRTBS 0x00010000 /* do backspacing for crt */ #define PRTERA 0x00020000 /* \ ... / erase */ #define CRTERA 0x00040000 /* " \b " to wipe out char */ /* 0x00080000 (old TILDE) */ #define MDMBUF 0x00100000 /* start/stop output on carrier intr */ #define LITOUT 0x00200000 /* literal output */ #define TOSTOP 0x00400000 /* SIGSTOP on background output */ #define FLUSHO 0x00800000 /* flush output to terminal */ #define NOHANG 0x01000000 /* no SIGHUP on carrier drop */ #define RTSCTS 0x02000000 /* use RTS/CTS flow control */ #define CRTKIL 0x04000000 /* kill line with " \b " */ #define PASS8 0x08000000 #define CTLECH 0x10000000 /* echo control chars as ^X */ #define PENDIN 0x20000000 /* tp->t_rawq needs reread */ #define DECCTQ 0x40000000 /* only ^Q starts after ^S */ #define NOFLSH 0x80000000 /* no output flush on signal */ /* locals, from 127 down */ #define TIOCLBIS _IOW('t', 127, int) /* bis local mode bits */ #define TIOCLBIC _IOW('t', 126, int) /* bic local mode bits */ #define TIOCLSET _IOW('t', 125, int) /* set entire local mode word */ #define TIOCLGET _IOR('t', 124, int) /* get local modes */ #define LCRTBS ((int)(CRTBS>>16)) #define LPRTERA ((int)(PRTERA>>16)) #define LCRTERA ((int)(CRTERA>>16)) #define LMDMBUF ((int)(MDMBUF>>16)) #define LLITOUT ((int)(LITOUT>>16)) #define LTOSTOP ((int)(TOSTOP>>16)) #define LFLUSHO ((int)(FLUSHO>>16)) #define LNOHANG ((int)(NOHANG>>16)) #define LRTSCTS ((int)(RTSCTS>>16)) #define LCRTKIL ((int)(CRTKIL>>16)) #define LPASS8 ((int)(PASS8>>16)) #define LCTLECH ((int)(CTLECH>>16)) #define LPENDIN ((int)(PENDIN>>16)) #define LDECCTQ ((int)(DECCTQ>>16)) #define LNOFLSH ((int)(NOFLSH>>16)) #define TIOCSBRK _IO ('t', 123) /* set break bit */ #define TIOCCBRK _IO ('t', 122) /* clear break bit */ #define TIOCSDTR _IO ('t', 121) /* set data terminal ready */ #define TIOCCDTR _IO ('t', 120) /* clear data terminal ready */ #define TIOCGPGRP _IOR('t', 119, int) /* get pgrp of tty */ #define TIOCSPGRP _IOW('t', 118, int) /* set pgrp of tty */ #define TIOCSLTC _IOW('t', 117,struct ltchars)/* set local special chars */ #define TIOCGLTC _IOR('t', 116,struct ltchars)/* get local special chars */ #define TIOCOUTQ _IOR('t', 115, int) /* output queue size */ #define TIOCSTI _IOW('t', 114, char)/* simulate terminal input */ #define TIOCNOTTY _IO ('t', 113) /* void tty association */ #define TIOCPKT _IOW('t', 112, int) /* pty: set/clear packet mode */ #define TIOCPKT_DATA 0x00 /* data packet */ #define TIOCPKT_FLUSHREAD 0x01 /* flush packet */ #define TIOCPKT_FLUSHWRITE 0x02 /* flush packet */ #define TIOCPKT_STOP 0x04 /* stop output */ #define TIOCPKT_START 0x08 /* start output */ #define TIOCPKT_NOSTOP 0x10 /* no more ^S, ^Q */ #define TIOCPKT_DOSTOP 0x20 /* now do ^S ^Q */ #define TIOCSTOP _IO ('t', 111) /* stop output, like ^S */ #define TIOCSTART _IO ('t', 110) /* start output, like ^Q */ #define TIOCMSET _IOW('t', 109, int) /* set all modem bits */ #define TIOCMBIS _IOW('t', 108, int) /* bis modem bits */ #define TIOCMBIC _IOW('t', 107, int) /* bic modem bits */ #define TIOCMGET _IOR('t', 106, int) /* get all modem bits */ #define TIOCREMOTE _IOW('t', 105, int) /* remote input editing */ #define TIOCGWINSZ _IOR('t', 104, struct winsize) /* get window size */ #define TIOCSWINSZ _IOW('t', 103, struct winsize) /* set window size */ #define TIOCUCNTL _IOW('t', 102, int) /* pty: set/clr usr cntl mode */ #define UIOCCMD(n) _IO ('u', n) /* usr cntl op "n" */ #define NTTYDISC 0 /* new tty discipline */ #define FIOCLEX _IO('f', 1) /* set exclusive use on fd */ #define FIONCLEX _IO('f', 2) /* remove exclusive use */ /* another local */ /* should use off_t for FIONREAD but that would require types.h */ #define FIONREAD _IOR('f', 97, long) /* get # bytes to read */ #define FIONBIO _IOW('f', 96, int) /* set/clear non-blocking i/o */ #define FIOASYNC _IOW('f', 95, int) /* set/clear async i/o */ #define FIOSETOWN _IOW('f', 94, int) /* set owner */ #define FIOGETOWN _IOR('f', 93, int) /* get owner */ /* socket i/o controls */ #define SIOCSHIWAT _IOW('s', 0, int) /* set high watermark */ #define SIOCGHIWAT _IOR('s', 1, int) /* get high watermark */ #define SIOCSLOWAT _IOW('s', 2, int) /* set low watermark */ #define SIOCGLOWAT _IOR('s', 3, int) /* get low watermark */ #define SIOCATMARK _IOR('s', 7, int) /* at oob mark? */ #define SIOCSPGRP _IOW('s', 8, int) /* set process group */ #define SIOCGPGRP _IOR('s', 9, int) /* get process group */ #define SIOCADDRT _IOW('r', 10, struct rtentry) /* add route */ #define SIOCDELRT _IOW('r', 11, struct rtentry) /* delete route */ #define SIOCSIFADDR _IOW ('i',12, struct ifreq) /* set ifnet address */ #define SIOCGIFADDR _IOWR('i',13, struct ifreq) /* get ifnet address */ #define SIOCSIFDSTADDR _IOW ('i',14, struct ifreq) /* set p-p address */ #define SIOCGIFDSTADDR _IOWR('i',15, struct ifreq) /* get p-p address */ #define SIOCSIFFLAGS _IOW ('i',16, struct ifreq) /* set ifnet flags */ #define SIOCGIFFLAGS _IOWR('i',17, struct ifreq) /* get ifnet flags */ #define SIOCGIFBRDADDR _IOWR('i',18, struct ifreq) /* get broadcast addr */ #define SIOCSIFBRDADDR _IOW ('i',19, struct ifreq) /* set broadcast addr */ #define SIOCGIFCONF _IOWR('i',20, struct ifconf) /* get ifnet list */ #define SIOCGIFNETMASK _IOWR('i',21, struct ifreq) /* get net addr mask */ #define SIOCSIFNETMASK _IOW ('i',22, struct ifreq) /* set net addr mask */ #define SIOCGIFMETRIC _IOWR('i',23, struct ifreq) /* get IF metric */ #define SIOCSIFMETRIC _IOW ('i',24, struct ifreq) /* set IF metric */ #define SIOCSARP _IOW ('i',30, struct arpreq) /* set arp entry */ #define SIOCGARP _IOWR('i',31, struct arpreq) /* get arp entry */ #define SIOCDARP _IOW ('i',32, struct arpreq) /* delete arp entry */ #endif ================================================ FILE: sys/sys/kernel.h ================================================ /* * Copyright (c) 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ /* * Global variables for the kernel */ /* 1.1 */ long hostid; char hostname[MAXHOSTNAMELEN]; int hostnamelen; /* 1.2 */ #include struct timeval boottime; struct timeval time; struct timezone tz; /* XXX */ int adjdelta; int hz; int usechz; /* # microseconds per hz */ int lbolt; /* awoken once a second */ short avenrun[3]; ================================================ FILE: sys/sys/map.h ================================================ /* * Resource Allocation Maps. * * Copyright (c) 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ /* * Associated routines manage allocation of an address space using * an array of segment descriptors. * * Malloc and mfree allocate and free the resource described * by the resource map. If the resource map becomes too fragmented * to be described in the available space, then some of the resource * is discarded. This may lead to critical shortages, * but is better than not checking (as the previous versions of * these routines did) or giving up and calling panic(). * * N.B.: The address 0 in the resource address space is not available * as it is used internally by the resource map routines. */ struct map { struct mapent *m_map; /* start of the map */ struct mapent *m_limit; /* address of last slot in map */ char *m_name; /* name of resource */ /* we use m_name when the map overflows, in warning messages */ }; struct mapent { size_t m_size; /* size of this segment of the map */ size_t m_addr; /* resource-space addr of start of segment */ }; #ifdef KERNEL extern struct map swapmap[]; /* space for swap allocation */ /* * Allocate units from the given map. */ size_t malloc (struct map *mp, size_t nbytes); /* * Free the previously allocated units at addr into the specified map. */ void mfree (struct map *mp, size_t nbytes, size_t addr); /* * Allocate resources for the three segments of a process. */ size_t malloc3 (struct map *mp, size_t d_size, size_t s_size, size_t u_size, size_t a[3]); #endif ================================================ FILE: sys/sys/mount.h ================================================ /* * Copyright (c) 1982, 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ /* * file system statistics */ #include #define MNAMELEN 90 /* length of buffer for returned name */ struct statfs { short f_type; /* type of filesystem (see below) */ u_short f_flags; /* copy of mount flags */ short f_bsize; /* fundamental file system block size */ short f_iosize; /* optimal transfer block size */ daddr_t f_blocks; /* total data blocks in file system */ daddr_t f_bfree; /* free blocks in fs */ daddr_t f_bavail; /* free blocks avail to non-superuser */ ino_t f_files; /* total file nodes in file system */ ino_t f_ffree; /* free file nodes in fs */ long f_fsid[2]; /* file system id */ long f_spare[5]; /* spare for later */ char f_mntonname[MNAMELEN]; /* directory on which mounted */ char f_mntfromname[MNAMELEN];/* mounted filesystem */ }; /* * File system types. Since only UFS is supported the others are not * specified at this time. */ #define MOUNT_NONE 0 #define MOUNT_UFS 1 /* Fast Filesystem */ #define MOUNT_MAXTYPE 1 #define INITMOUNTNAMES { \ "none", /* 0 MOUNT_NONE */ \ "ufs", /* 1 MOUNT_UFS */ \ 0, \ } /* * Mount structure. * One allocated on every mount. * Used to find the super block. */ struct mount { dev_t m_dev; /* device mounted */ struct fs m_filsys; /* superblock data */ #define m_flags m_filsys.fs_flags struct inode *m_inodp; /* pointer to mounted on inode */ struct inode *m_qinod; /* QUOTA: pointer to quota file */ char m_mntfrom [MNAMELEN]; /* /dev/xxxx mounted from */ char m_mnton [MNAMELEN]; /* directory mounted on - this is the * full(er) version of fs_fsmnt. */ }; /* * Mount flags. */ #define MNT_RDONLY 0x0001 /* read only filesystem */ #define MNT_SYNCHRONOUS 0x0002 /* file system written synchronously */ #define MNT_NOEXEC 0x0004 /* can't exec from filesystem */ #define MNT_NOSUID 0x0008 /* don't honor setuid bits on fs */ #define MNT_NODEV 0x0010 /* don't interpret special files */ #define MNT_QUOTA 0x0020 /* quotas are enabled on filesystem */ #define MNT_ASYNC 0x0040 /* file system written asynchronously */ #define MNT_NOATIME 0x0080 /* don't update access times */ /* * Mask of flags that are visible to statfs(). */ #define MNT_VISFLAGMASK 0x0fff /* * filesystem control flags. The high 4 bits are used for this. Since NFS * support will never be a problem we can avoid making the flags into a 'long. */ #define MNT_UPDATE 0x1000 /* not a real mount, just an update */ /* * Flags for various system call interfaces. * * These aren't used for anything in the system and are present only * for source code compatibility reasons. */ #define MNT_WAIT 1 #define MNT_NOWAIT 2 #ifdef KERNEL struct mount mount[NMOUNT]; #else int getfsstat (struct statfs *buf, int bufsize, unsigned flags); int getmntinfo (struct statfs **mntbufp, int flags); int statfs (const char *path, struct statfs *buf); int mount (const char *special, const char *name, int flags); int umount (const char *special); #endif ================================================ FILE: sys/sys/msgbuf.h ================================================ /* * Copyright (c) 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #define MSG_MAGIC 0x063061 #define MSG_BSIZE 2048 struct msgbuf { long msg_magic; int msg_bufx; int msg_bufr; char msg_bufc [MSG_BSIZE]; }; #define logMSG 0 /* /dev/klog */ #ifdef KERNEL /* * Check that log is open by a user program. */ int logisopen (int unit); #endif ================================================ FILE: sys/sys/mtio.h ================================================ /* * Copyright (c) 1982, 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * * @(#)mtio.h 7.1.2 (2.11BSD) 1998/3/7 */ /* * Structures and definitions for mag tape io control commands */ /* structure for MTIOCTOP - mag tape op command */ struct mtop { short mt_op; /* operations defined below */ daddr_t mt_count; /* how many of them */ }; /* operations */ #define MTWEOF 0 /* write an end-of-file record */ #define MTFSF 1 /* forward space file */ #define MTBSF 2 /* backward space file */ #define MTFSR 3 /* forward space record */ #define MTBSR 4 /* backward space record */ #define MTREW 5 /* rewind */ #define MTOFFL 6 /* rewind and put the drive offline */ #define MTNOP 7 /* no operation, sets status only */ #define MTCACHE 8 /* enable controller cache */ #define MTNOCACHE 9 /* disable controller cache */ #define MTFLUSH 10 /* flush cache */ /* structure for MTIOCGET - mag tape get status command */ struct mtget { short mt_type; /* type of magtape device */ /* the following two registers are grossly device dependent */ short mt_dsreg; /* ``drive status'' register */ short mt_erreg; /* ``error'' register */ /* end device-dependent registers */ short mt_resid; /* residual count */ /* the following two are not yet implemented */ daddr_t mt_fileno; /* file number of current position */ daddr_t mt_blkno; /* block number of current position */ /* end not yet implemented */ }; /* * Constants for mt_type byte. These are the same * for other controllers compatible with the types listed. */ #define MT_ISTS 0x01 /* TS-11 */ #define MT_ISHT 0x02 /* TM03 Massbus: TE16, TU45, TU77 */ #define MT_ISTM 0x03 /* TM11/TE10 Unibus */ #define MT_ISMT 0x04 /* TM78/TU78 Massbus */ #define MT_ISUT 0x05 /* SI TU-45 emulation on Unibus */ #define MT_ISCPC 0x06 /* SUN */ #define MT_ISAR 0x07 /* SUN */ #define MT_ISTMSCP 0x08 /* DEC TMSCP protocol (TU81, TK50) */ /* * At present only the TMSCP driver reports this information in the * high byte of the 'drive status' word. Other drives will (hopefully) * be updated in the future. */ #define MTF_BOM 0x01 /* At beginning of media */ #define MTF_EOM 0x02 /* At the end of media */ #define MTF_OFFLINE 0x04 /* Drive is offline */ #define MTF_WRTLCK 0x08 /* Drive is write protected */ #define MTF_WRITTEN 0x10 /* Tape has been written */ /* mag tape io control commands */ #define MTIOCTOP _IOW('m', 1, struct mtop) /* do a mag tape op */ #define MTIOCGET _IOR('m', 2, struct mtget) /* get tape status */ #define MTIOCIEOT _IO ('m', 3) /* ignore EOT error */ #define MTIOCEEOT _IO ('m', 4) /* enable EOT error */ ================================================ FILE: sys/sys/namei.h ================================================ /* * Copyright (c) 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #ifndef _NAMEI_ #define _NAMEI_ #ifdef KERNEL #include "uio.h" #else #include #endif /* * Encapsulation of namei parameters. * One of these is located in the u. area to * minimize space allocated on the kernel stack. */ struct nameidata { caddr_t ni_dirp; /* pathname pointer */ short ni_nameiop; /* see below */ short ni_error; /* error return if any */ off_t ni_endoff; /* end of useful stuff in directory */ struct inode *ni_pdir; /* inode of parent directory of dirp */ struct inode *ni_ip; /* inode of dirp */ off_t ni_offset; /* offset in directory */ u_short ni_count; /* offset of open slot (off_t?) */ struct direct ni_dent; /* current directory entry */ }; /* * namei operations and modifiers */ #define LOOKUP 0 /* perform name lookup only */ #define CREATE 1 /* setup for file creation */ #define DELETE 2 /* setup for file deletion */ #define LOCKPARENT 0x10 /* see the top of namei */ #define NOCACHE 0x20 /* name must not be left in cache */ #define FOLLOW 0x40 /* follow symbolic links */ #define NOFOLLOW 0x0 /* don't follow symbolic links (pseudo) */ #define NDINIT(ndp,op,flags,namep) {\ (ndp)->ni_nameiop = op | flags; \ (ndp)->ni_dirp = namep; } /* * This structure describes the elements in the cache of recent * names looked up by namei. */ struct namecache { struct namecache *nc_forw; /* hash chain, MUST BE FIRST */ struct namecache *nc_back; /* hash chain, MUST BE FIRST */ struct namecache *nc_nxt; /* LRU chain */ struct namecache **nc_prev; /* LRU chain */ struct inode *nc_ip; /* inode the name refers to */ ino_t nc_ino; /* ino of parent of name */ dev_t nc_dev; /* dev of parent of name */ dev_t nc_idev; /* dev of the name ref'd */ u_short nc_id; /* referenced inode's id */ char nc_nlen; /* length of name */ #define NCHNAMLEN 15 /* maximum name segment length we bother with */ char nc_name[NCHNAMLEN]; /* segment name */ }; #ifdef KERNEL extern struct namecache namecache []; struct nchstats nchstats; /* cache effectiveness statistics */ /* * Name cache initialization. */ void nchinit (void); /* * Common code for vnode open operations. */ int vn_open (struct nameidata *ndp, int fmode, int cmode); /* * Write a directory entry after a call to namei. */ int direnter (struct inode *ip, struct nameidata *ndp); /* * Remove a directory entry after a call to namei. */ int dirremove (struct nameidata *ndp); #endif /* KERNEL */ /* * Stats on usefulness of namei caches. */ struct nchstats { long ncs_goodhits; /* hits that we can reall use */ long ncs_badhits; /* hits we must drop */ long ncs_falsehits; /* hits with id mismatch */ long ncs_miss; /* misses */ long ncs_long; /* long names that ignore cache */ long ncs_pass2; /* names found with passes == 2 */ long ncs_2passes; /* number of times we attempt it */ }; #endif ================================================ FILE: sys/sys/param.h ================================================ /* * Copyright (c) 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #define BSD 211 /* 2.11 * 100, as cpp doesn't do floats */ #define DiscoBSD 202602 /* DiscoBSD version (year & month). */ #define DiscoBSD_2_6 1 /* DiscoBSD 2.6 */ #if !defined(offsetof) && defined(KERNEL) #define offsetof(type, member) ((size_t)(&((type *)0)->member)) #endif /* * Machine type dependent parameters. */ #include /* * Machine-independent constants */ #include #ifndef NMOUNT #define NMOUNT 2 /* number of mountable file systems */ #endif #define MAXUPRC 20 /* max processes per user */ #define NOFILE 30 /* max open files per process */ #define NCARGS 5120 /* # characters in exec arglist */ #define NGROUPS 16 /* max number groups */ #define NOGROUP 65535 /* marker for empty group set member */ /* * Priorities */ #define PSWP 0 #define PINOD 10 #define PRIBIO 20 #define PRIUBA 24 #define PZERO 25 #define PPIPE 26 #define PSOCK 26 #define PWAIT 30 #define PLOCK 35 #define PPAUSE 40 #define PUSER 50 #define NZERO 0 #define PRIMASK 0xff #define PCATCH 0x100 /* * Signals */ #include #define NBPW sizeof(int) /* number of bytes in an integer */ #ifndef NULL #define NULL 0 #endif #define CMASK 026 /* default mask for file creation */ #define NODEV (dev_t)(-1) /* CBLOCK is the size of a clist block, must be power of 2 */ #define CBLOCK 32 #define CBSIZE (CBLOCK - sizeof(struct cblock *)) /* data chars/clist */ #define CROUND (CBLOCK - 1) /* clist rounding */ #include /* * File system parameters and macros. * * The file system is made out of blocks of most MAXBSIZE units. */ #define MAXBSIZE 1024 /* * MAXPATHLEN defines the longest permissible path length * after expanding symbolic links. It is used to allocate * a temporary buffer from the buffer pool in which to do the * name expansion, hence should be a power of two, and must * be less than or equal to MAXBSIZE. * MAXSYMLINKS defines the maximum number of symbolic links * that may be expanded in a path name. It should be set high * enough to allow all legitimate uses, but halt infinite loops * reasonably quickly. */ #define MAXPATHLEN PATH_MAX #define MAXSYMLINKS 8 /* * Macros for fast min/max. */ #define MIN(a,b) (((a)<(b))?(a):(b)) #ifndef MAX #define MAX(a,b) (((a)>(b))?(a):(b)) #endif /* * Macros for counting and rounding. */ #ifndef howmany # define howmany(x,y) (((x)+((y)-1))/(y)) #endif #define roundup(x,y) ((((x)+((y)-1))/(y))*(y)) /* * Maximum size of hostname recognized and stored in the kernel. */ #define MAXHOSTNAMELEN 64 #if defined(KERNEL) && defined(INET) # include #endif /* * MAXMEM is the maximum core per process is allowed. First number is Kb. */ #ifndef MAXMEM #define MAXMEM (96*1024) #endif /* * Max length of a user login name. */ #define MAXLOGNAME 16 ================================================ FILE: sys/sys/picga.h ================================================ #ifndef _PICGA_H #define _PICGA_H #define SPI_IDLE 0x00 /* System control */ #define SPI_CLS 0x01 #define SPI_CLUT 0x02 #define SPI_ENCOPPER 0x03 #define SPI_DISCOPPER 0x04 #define SPI_COPPERFILL 0x05 #define SPI_SCROLL 0x06 #define SPI_COPY 0x07 /* Basic drawing */ #define SPI_PLOT 0x11 #define SPI_DRAW 0x12 #define SPI_COLOR 0x13 #define SPI_RECTANGLE 0x14 #define SPI_CIRCLE 0x15 /* Text commands */ #define SPI_LOCATE 0x80 #define SPI_FONT 0x81 #define SPI_PRINT 0x82 #define SPI_PRINTAT 0x83 #define SPI_PUTCH 0x84 #define SPI_PUTCHAR 0x85 #define SPI_FGCOLOR 0x86 #define SPI_BGCOLOR 0x87 #define FONT_SINCLAIR 0x00 #define FONT_TOPAZ 0x01 #define UP 0 #define DOWN 1 #define LEFT 2 #define RIGHT 3 struct coord2 { u_short x; u_short y; } __attribute__((packed)); struct coord4 { u_short x1; u_short y1; u_short x2; u_short y2; } __attribute__((packed)); struct coord6 { u_short x1; u_short y1; u_short x2; u_short y2; u_short x3; u_short y3; } __attribute__((packed)); struct intval { u_short value; } __attribute__((packed)); struct rectangle { u_short x1; u_short y1; u_short x2; u_short y2; u_int fill:1; u_char dither; } __attribute__((packed)); struct circle { u_short x; u_short y; u_short radius; u_int fill:1; } __attribute__((packed)); struct charval { u_char value; } __attribute__((packed)); #ifdef KERNEL #include "conf.h" extern void picga_command(u_char cmd, u_char len, void *data); extern int picga_open(dev_t dev, int flag, int mode); extern int picga_close(dev_t dev, int flag, int mode); extern int picga_read(dev_t dev, struct uio *uio, int flag); extern int picga_write(dev_t dev, struct uio *uio, int flag); extern int picga_ioctl(dev_t dev, u_int cmd, caddr_t addr, int flag); #endif #define PICGA_CLS _IO('g', 1) #endif ================================================ FILE: sys/sys/proc.h ================================================ /* * Copyright (c) 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #ifndef _SYS_PROC_H_ #define _SYS_PROC_H_ /* * One structure allocated per active * process. It contains all data needed * about the process while the * process may be swapped out. * Other per process data (user.h) * is swapped with the process. */ struct proc { struct proc *p_nxt; /* linked list of allocated proc slots */ struct proc **p_prev; /* also zombies, and free proc's */ struct proc *p_pptr; /* pointer to process structure of parent */ short p_flag; short p_uid; /* user id, used to direct tty signals */ short p_pid; /* unique process id */ short p_ppid; /* process id of parent */ long p_sig; /* signals pending to this process */ int p_stat; /* * Union to overwrite information no longer needed by ZOMBIED * process with exit information for the parent process. The * two structures have been carefully set up to use the same * amount of memory. Must be very careful that any values in * p_alive are not used for zombies (zombproc). */ union { struct { char P_pri; /* priority, negative is high */ char P_cpu; /* cpu usage for scheduling */ char P_time; /* resident time for scheduling */ char P_nice; /* nice for cpu usage */ char P_slptime; /* secs sleeping */ char P_ptracesig; /* used between parent & traced child */ struct proc *P_hash; /* hashed based on p_pid */ long P_sigmask; /* current signal mask */ long P_sigignore; /* signals being ignored */ long P_sigcatch; /* signals being caught by user */ short P_pgrp; /* name of process group leader */ struct proc *P_link; /* linked list of running processes */ size_t P_addr; /* address of u. area */ size_t P_daddr; /* address of data area */ size_t P_saddr; /* address of stack area */ size_t P_dsize; /* size of data area (clicks) */ size_t P_ssize; /* size of stack segment (clicks) */ caddr_t P_wchan; /* event process is awaiting */ struct k_itimerval P_realtimer; } p_alive; struct { int P_xstat; /* exit status for wait */ struct k_rusage P_ru; /* exit information */ } p_dead; } p_un; }; #define p_pri p_un.p_alive.P_pri #define p_cpu p_un.p_alive.P_cpu #define p_time p_un.p_alive.P_time #define p_nice p_un.p_alive.P_nice #define p_slptime p_un.p_alive.P_slptime #define p_hash p_un.p_alive.P_hash #define p_ptracesig p_un.p_alive.P_ptracesig #define p_sigmask p_un.p_alive.P_sigmask #define p_sigignore p_un.p_alive.P_sigignore #define p_sigcatch p_un.p_alive.P_sigcatch #define p_pgrp p_un.p_alive.P_pgrp #define p_link p_un.p_alive.P_link #define p_addr p_un.p_alive.P_addr #define p_daddr p_un.p_alive.P_daddr #define p_saddr p_un.p_alive.P_saddr #define p_dsize p_un.p_alive.P_dsize #define p_ssize p_un.p_alive.P_ssize #define p_wchan p_un.p_alive.P_wchan #define p_realtimer p_un.p_alive.P_realtimer #define p_clktim p_realtimer.it_value #define p_xstat p_un.p_dead.P_xstat #define p_ru p_un.p_dead.P_ru #define PIDHSZ 16 #define PIDHASH(pid) ((pid) & (PIDHSZ - 1)) /* arguments to swapout: */ #define X_OLDSIZE (-1) /* the old size is the same as current */ #define X_DONTFREE 0 /* save core image (for parent in newproc) */ #define X_FREECORE 1 /* free core space after swap */ #ifdef KERNEL struct proc *pidhash [PIDHSZ]; extern struct proc proc[]; /* the proc table itself */ struct proc *freeproc, *zombproc, *allproc, *qs; /* lists of procs in various states */ extern int nproc; /* * Init the process queues. */ void pqinit (void); /* * Find a process by pid. */ struct proc *pfind (int pid); /* * Set user priority. */ int setpri (struct proc *pp); /* * Send the specified signal to the specified process. */ void psignal (struct proc *p, int sig); /* * Send the specified signal to a process group. */ void gsignal (int pgrp, int sig); /* * Take the action for the specified signal. */ void postsig (int sig); /* * If the current process has received a signal, return the signal number. */ int issignal (struct proc *p); /* * Initialize signal state for process 0; * set to ignore signals that are ignored by default. */ void siginit (struct proc *p); /* * Remove a process from its wait queue */ void unsleep (struct proc *p); void selwakeup (struct proc *p, long coll); /* * Set the process running; * arrange for it to be swapped in if necessary. */ void setrun (struct proc *p); /* * Reschedule the CPU. */ void swtch (void); /* * Recompute process priorities, once a second. */ void schedcpu (caddr_t arg); /* * The main loop of the scheduling process. No return. */ void sched (void); /* * Create a new process -- the internal version of system call fork. */ int newproc (int isvfork); /* * Notify parent that vfork child is finished with parent's data. */ void endvfork (void); /* * Put the process into the run queue. */ void setrq (struct proc *p); /* * Remove runnable job from run queue. */ void remrq (struct proc *p); /* * Exit the process. */ void exit (int rv); /* * Swap I/O. */ void swap (size_t blkno, size_t coreaddr, int count, int rdflg); /* * Kill a process when ran out of swap space. */ void swkill (struct proc *p, char *name); /* * Give up the processor till a wakeup occurs on chan, at which time the * process enters the scheduling queue at priority pri. */ void sleep (caddr_t chan, int pri); /* * Give up the processor till a wakeup occurs on ident or a timeout expires. * Then the process enters the scheduling queue at given priority. */ int tsleep (caddr_t ident, int priority, u_int timo); /* * Arrange that given function is called in t/hz seconds. */ void timeout (void (*fun) (caddr_t), caddr_t arg, int t); /* * Remove a function timeout call from the callout structure. */ void untimeout (void (*fun) (caddr_t), caddr_t arg); /* * Handler for hardware clock interrupt. */ void hardclock (caddr_t pc, int ps); /* * Swap out a process. */ void swapout (struct proc *p, int freecore, u_int odata, u_int ostack); /* * Swap a process in. */ void swapin (struct proc *p); /* * Is p an inferior of the current process? */ int inferior (struct proc *p); /* * Test if the current user is the super user. */ int suser (void); /* * Load from user area (probably swapped out): real uid, * controlling terminal device, and controlling terminal pointer. */ struct tty; void fill_from_u (struct proc *p, uid_t *rup, struct tty **ttp, dev_t *tdp); /* * Grow the stack to include the SP. */ int grow (unsigned sp); /* * Kill current process with the specified signal in an uncatchable manner. */ void fatalsig (int signum); /* * Parent controlled tracing. */ int procxmt (void); void execsigs(register struct proc *p); void userret(int, time_t); #endif /* KERNEL */ /* stat codes */ #define SSLEEP 1 /* awaiting an event */ #define SWAIT 2 /* (abandoned state) */ #define SRUN 3 /* running */ #define SIDL 4 /* intermediate state in process creation */ #define SZOMB 5 /* intermediate state in process termination */ #define SSTOP 6 /* process being traced */ /* flag codes */ #define SLOAD 0x0001 /* in core */ #define SSYS 0x0002 /* swapper or pager process */ #define SLOCK 0x0004 /* process being swapped out */ #define SSWAP 0x0008 /* save area flag */ #define P_TRACED 0x0010 /* process is being traced */ #define P_WAITED 0x0020 /* another tracing flag */ /* 0x0040 unused */ #define P_SINTR 0x0080 /* sleeping interruptibly */ #define SVFORK 0x0100 /* process resulted from vfork() */ #define SVFPRNT 0x0200 /* parent in vfork, waiting for child */ #define SVFDONE 0x0400 /* parent has released child in vfork */ /* 0x0800 unused */ #define P_TIMEOUT 0x1000 /* tsleep timeout expired */ #define P_NOCLDSTOP 0x2000 /* no SIGCHLD signal to parent */ #define P_SELECT 0x4000 /* selecting; wakeup/waiting danger */ /* 0x8000 unused */ #define S_DATA 0 /* specified segment */ #define S_STACK 1 #endif /* !_SYS_PROC_H_ */ ================================================ FILE: sys/sys/ptrace.h ================================================ /* * Copyright (c) 1980, 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #ifndef _PTRACE_ #define _PTRACE_ #define PT_TRACE_ME 0 /* child declares it's being traced */ #define PT_READ_I 1 /* read word in child's I space */ #define PT_READ_D 2 /* read word in child's D space */ #define PT_READ_U 3 /* read word in child's user structure */ #define PT_WRITE_I 4 /* write word in child's I space */ #define PT_WRITE_D 5 /* write word in child's D space */ #define PT_WRITE_U 6 /* write word in child's user structure */ #define PT_CONTINUE 7 /* continue the child */ #define PT_KILL 8 /* kill the child process */ #define PT_STEP 9 /* single step the child */ /* * Tracing variables. * Used to pass trace command from * parent to child being traced. * This data base cannot be * shared and is locked * per user. */ struct ipc { int ip_lock; int ip_req; int *ip_addr; int ip_data; }; #ifdef KERNEL struct ipc ipc; #else int ptrace (int request, pid_t pid, void *addr, int data); #endif #endif ================================================ FILE: sys/sys/pty.h ================================================ #ifndef _PTY_H #define _PTY_H #define PF_RCOLL 0x01 #define PF_WCOLL 0x02 #define PF_PKT 0x08 /* packet mode */ #define PF_STOPPED 0x10 /* user told stopped */ #define PF_REMOTE 0x20 /* remote and flow controlled input */ #define PF_NOSTOP 0x40 #define PF_UCNTL 0x80 /* user control mode */ #ifdef KERNEL #include "uio.h" #include "tty.h" #include "conf.h" #ifndef PTY_NUNITS #define PTY_NUNITS 4 /* 4 units by default */ #endif extern struct tty pt_tty[]; extern int npty; extern int ptsopen(dev_t dev, int flag, int mode); extern int ptsclose(dev_t dev, int flag, int mode); extern int ptsread(dev_t dev, register struct uio *uio, int flag); extern int ptswrite(dev_t dev, register struct uio *uio, int flag); extern void ptsstart(struct tty *tp); extern void ptcwakeup(struct tty *tp, int flag); extern int ptcopen(dev_t dev, int flag, int mode); extern int ptcclose(dev_t dev, int flag, int mode); extern int ptcread(dev_t dev, register struct uio *uio, int flag); extern void ptsstop(register struct tty *tp, int flush); extern int ptcselect(dev_t dev, int rw); extern int ptcwrite(dev_t dev, register struct uio *uio, int flag); extern int ptyioctl(dev_t dev, u_int cmd, caddr_t data, int flag); #endif #endif ================================================ FILE: sys/sys/pwm.h ================================================ #ifndef _PWM_H #define _PWM_H #include struct pwm_state { int mode; int pwm_duty; }; #define PWM_MAX_DEV 5 #define PWM_MODE_PWM 0x0001 #define PWM_SET_MODE _IOW('i',1,int) #define PWM_DUTY _IOW('i',2,int) #ifdef KERNEL #include "conf.h" extern int pwm_open (dev_t dev, int flag, int mode); extern int pwm_close (dev_t dev, int flag, int mode); extern int pwm_read (dev_t dev, struct uio *uio, int flag); extern int pwm_write (dev_t dev, struct uio *uio, int flag); extern int pwm_ioctl (dev_t dev, u_int cmd, caddr_t addr, int flag); #endif #define OC2CON PIC32_R (0x03200) #define OC3CON PIC32_R (0x03400) #define OC5CON PIC32_R (0x03800) #define OC2RS PIC32_R (0x03220) #define OC3RS PIC32_R (0x03420) #define OC5RS PIC32_R (0x03820) #endif ================================================ FILE: sys/sys/reboot.h ================================================ /* * Copyright (c) 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * * @(#)reboot.h 1.2 (2.11BSD GTE) 1996/5/9 */ /* * Arguments to reboot system call. * These are passed to boot program in r4, * and on to init. */ #define RB_AUTOBOOT 0 /* flags for system auto-booting itself */ #define RB_ASKNAME 0x001 /* ask for file name to reboot from */ #define RB_SINGLE 0x002 /* reboot to single user only */ #define RB_NOSYNC 0x004 /* dont sync before reboot */ #define RB_HALT 0x008 /* don't reboot, just halt */ #define RB_INITNAME 0x010 /* name given for /etc/init */ #define RB_DFLTROOT 0x020 /* use compiled-in rootdev */ #define RB_DUMP 0x040 /* take a dump before rebooting */ #define RB_NOFSCK 0x080 /* don't perform fsck's on reboot */ #define RB_POWRFAIL 0x100 /* reboot caused by power failure */ #define RB_RDONLY 0x200 /* mount root fs read-only */ #define RB_AUTODEBUG 0x400 /* init runs autoconfig with "-d" (debug) */ #define RB_POWEROFF 0x800 /* signal PSU to switch off power */ #define RB_BOOTLOADER 0x1000 /* reboot into the bootloader */ #define RB_PANIC 0 /* reboot due to panic */ #define RB_BOOT 1 /* reboot due to boot() */ ================================================ FILE: sys/sys/resource.h ================================================ /* * Copyright (c) 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * * @(#)resource.h 1.3 (2.11BSD GTE) 1997/2/14 */ #ifndef _SYS_RESOURCE_H_ #define _SYS_RESOURCE_H_ #include /* * Process priority specifications to get/setpriority. */ #define PRIO_MIN (-20) #define PRIO_MAX 20 #define PRIO_PROCESS 0 #define PRIO_PGRP 1 #define PRIO_USER 2 /* * Resource utilization information. */ #define RUSAGE_SELF 0 #define RUSAGE_CHILDREN (-1) struct rusage { struct timeval ru_utime; /* user time used */ struct timeval ru_stime; /* system time used */ long ru_maxrss; #define ru_first ru_ixrss long ru_ixrss; /* integral shared memory size */ long ru_idrss; /* integral unshared data " */ long ru_isrss; /* integral unshared stack " */ long ru_minflt; /* page reclaims */ long ru_majflt; /* page faults */ long ru_nswap; /* swaps */ long ru_inblock; /* block input operations */ long ru_oublock; /* block output operations */ long ru_msgsnd; /* messages sent */ long ru_msgrcv; /* messages received */ long ru_nsignals; /* signals received */ long ru_nvcsw; /* voluntary context switches */ long ru_nivcsw; /* involuntary " */ #define ru_last ru_nivcsw }; struct k_rusage { /* KERNEL RUSAGE STRUCTURE */ #define k_ru_first ru_utime long ru_utime; /* user time used ('hz' ticks) */ long ru_stime; /* system time used ('hz' ticks) */ long ru_nswap; /* swaps */ long ru_inblock; /* block input operations */ long ru_oublock; /* block output operations */ long ru_msgsnd; /* messages sent */ long ru_msgrcv; /* messages received */ long ru_nsignals; /* signals received */ long ru_nvcsw; /* voluntary context switches */ long ru_nivcsw; /* involuntary " */ #define k_ru_last ru_nivcsw }; /* * Resource limits */ #define RLIMIT_CPU 0 /* cpu time in milliseconds */ #define RLIMIT_FSIZE 1 /* maximum file size */ #define RLIMIT_DATA 2 /* data size */ #define RLIMIT_STACK 3 /* stack size */ #define RLIMIT_CORE 4 /* core file size */ #define RLIMIT_RSS 5 /* resident set size */ #define RLIM_NLIMITS 6 /* number of resource limits */ #define RLIM_INFINITY 0x7fffffff struct rlimit { long rlim_cur; /* current (soft) limit */ long rlim_max; /* maximum value for rlim_cur */ }; /* Load average structure. */ struct loadavg { short ldavg[3]; int fscale; }; #ifdef KERNEL /* * Convert an internal kernel rusage structure into a `real' rusage structure. */ void rucvt (struct rusage *rup, struct k_rusage *krup); /* * Add resource usage data. */ void ruadd (struct k_rusage *ru, struct k_rusage *ru2); #else int getpriority (int which, int who); int getrlimit (int resource, struct rlimit *rlp); int getrusage (int who, struct rusage *usage); int setpriority (int which, int who, int prio); int setrlimit (int resource, struct rlimit *rlp); #endif #endif /* !_SYS_RESOURCE_H_ */ ================================================ FILE: sys/sys/select.h ================================================ /*- * Copyright (c) 1992, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)select.h 8.2.1 (2.11BSD) 2000/2/28 */ #ifndef _SYS_SELECT_H_ #define _SYS_SELECT_H_ #include /* * Select uses bit masks of file descriptors in longs. * These macros manipulate such bit fields (the filesystem macros use chars). * FD_SETSIZE may be defined by the user, but the default here * should be >= NOFILE (param.h). */ #ifndef FD_SETSIZE #define FD_SETSIZE 32 #endif typedef long fd_mask; #define NFDBITS (sizeof(fd_mask) * NBBY) /* bits per mask */ typedef struct fd_set { fd_mask fds_bits[1]; } fd_set; #define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1L << ((n) % NFDBITS))) #define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1L << ((n) % NFDBITS))) #define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1L << ((n) % NFDBITS))) #ifdef KERNEL #define FD_ZERO(p) bzero((char *)(p), sizeof(*(p))) #else #define FD_ZERO(p) memset((char *)(p), 0, sizeof(*(p))) #endif #ifndef KERNEL /* According to POSIX.1-2001 */ struct timeval; int select(int, fd_set *, fd_set *, fd_set *, struct timeval *); #endif /* !KERNEL */ #endif /* !_SYS_SELECT_H_ */ ================================================ FILE: sys/sys/signal.h ================================================ /* * Copyright (c) 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #ifndef NSIG #include #include /* sigcontext */ #define NSIG 32 #define SIGHUP 1 /* hangup */ #define SIGINT 2 /* interrupt */ #define SIGQUIT 3 /* quit */ #define SIGILL 4 /* illegal instruction (not reset when caught) */ #define SIGTRAP 5 /* trace trap (not reset when caught) */ #define SIGIOT 6 /* IOT instruction */ #define SIGABRT SIGIOT /* compatibility */ #define SIGEMT 7 /* EMT instruction */ #define SIGFPE 8 /* floating point exception */ #define SIGKILL 9 /* kill (cannot be caught or ignored) */ #define SIGBUS 10 /* bus error */ #define SIGSEGV 11 /* segmentation violation */ #define SIGSYS 12 /* bad argument to system call */ #define SIGPIPE 13 /* write on a pipe with no one to read it */ #define SIGALRM 14 /* alarm clock */ #define SIGTERM 15 /* software termination signal from kill */ #define SIGURG 16 /* urgent condition on IO channel */ #define SIGSTOP 17 /* sendable stop signal not from tty */ #define SIGTSTP 18 /* stop signal from tty */ #define SIGCONT 19 /* continue a stopped process */ #define SIGCHLD 20 /* to parent on child stop or exit */ #define SIGCLD SIGCHLD /* compatibility */ #define SIGTTIN 21 /* to readers pgrp upon background tty read */ #define SIGTTOU 22 /* like TTIN for output if (tp->t_local<OSTOP) */ #define SIGIO 23 /* input/output possible signal */ #define SIGXCPU 24 /* exceeded CPU time limit */ #define SIGXFSZ 25 /* exceeded file size limit */ #define SIGVTALRM 26 /* virtual time alarm */ #define SIGPROF 27 /* profiling time alarm */ #define SIGWINCH 28 /* window size changes */ #define SIGUSR1 30 /* user defined signal 1 */ #define SIGUSR2 31 /* user defined signal 2 */ typedef void (*sig_t) (int); /* type of signal function */ #define SIG_ERR (sig_t) -1 #define SIG_DFL (sig_t) 0 #define SIG_IGN (sig_t) 1 typedef unsigned long sigset_t; /* * Signal vector "template" used in sigaction call. */ struct sigaction { sig_t sa_handler; /* signal handler */ sigset_t sa_mask; /* signal mask to apply */ int sa_flags; /* see signal options below */ }; #define SA_ONSTACK 0x0001 /* take signal on signal stack */ #define SA_RESTART 0x0002 /* restart system on signal return */ #define SA_DISABLE 0x0004 /* disable taking signals on alternate stack */ #define SA_NOCLDSTOP 0x0008 /* do not generate SIGCHLD on child stop */ /* * Flags for sigprocmask: */ #define SIG_BLOCK 1 /* block specified signal set */ #define SIG_UNBLOCK 2 /* unblock specified signal set */ #define SIG_SETMASK 3 /* set specified signal set */ /* * Structure used in sigaltstack call. */ struct sigaltstack { char *ss_base; /* signal stack base */ int ss_size; /* signal stack length */ int ss_flags; /* SA_DISABLE and/or SA_ONSTACK */ }; #define MINSIGSTKSZ 128 /* minimum allowable stack */ #define SIGSTKSZ (MINSIGSTKSZ + 384) /* recommended stack size */ /* * 4.3 compatibility: * Signal vector "template" used in sigvec call. */ struct sigvec { sig_t sv_handler; /* signal handler */ long sv_mask; /* signal mask to apply */ int sv_flags; /* see signal options below */ }; #define SV_ONSTACK SA_ONSTACK /* take signal on signal stack */ #define SV_INTERRUPT SA_RESTART /* same bit, opposite sense */ #define sv_onstack sv_flags /* isn't compatibility wonderful! */ /* * 4.3 compatibility: * Structure used in sigstack call. */ struct sigstack { char *ss_sp; /* signal stack pointer */ int ss_onstack; /* current status */ }; /* * Macro for converting signal number to a mask suitable for * sigblock(). */ #define sigmask(m) (1L << ((m)-1)) #define sigaddset(set, signo) (*(set) |= 1L << ((signo) - 1), 0) #define sigdelset(set, signo) (*(set) &= ~(1L << ((signo) - 1)), 0) #define sigemptyset(set) (*(set) = (sigset_t)0, (int)0) #define sigfillset(set) (*(set) = ~(sigset_t)0, (int)0) #define sigismember(set, signo) ((*(set) & (1L << ((signo) - 1))) != 0) #ifdef KERNEL /* Table of signal properties. */ extern const char sigprop [NSIG + 1]; /* * Send an interrupt to process. */ void sendsig (sig_t p, int sig, long mask); #else /* KERNEL */ sig_t signal (int, sig_t); int sigaction (int signum, const struct sigaction *act, struct sigaction *oldact); int sigvec (int sig, struct sigvec *vec, struct sigvec *ovec); int kill (pid_t pid, int sig); int sigpause (int mask); int sigblock (int mask); int sigsetmask (int mask); int sigprocmask (int how, const sigset_t *set, sigset_t *oldset); int siginterrupt (int sig, int flag); int sigsuspend (const sigset_t *mask); #endif /* KERNEL */ #endif /* NSIG */ ================================================ FILE: sys/sys/signalvar.h ================================================ /* * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #ifndef _SYS_SIGNALVAR_H_ /* tmp for user.h */ #define _SYS_SIGNALVAR_H_ /* * Kernel signal definitions and data structures, * not exported to user programs. * * For 2BSD the parts that did not apply were cut out. */ /* signal flags */ #define SAS_OLDMASK 0x01 /* need to restore mask before pause */ #define SAS_ALTSTACK 0x02 /* have alternate signal stack */ /* additional signal action values, used only temporarily/internally */ #define SIG_CATCH (sig_t) 2 #define SIG_HOLD (sig_t) 3 /* * Determine signal that should be delivered to process p, the current * process, 0 if none. If there is a pending stop signal with default * action, the process stops in issignal(). * * This probably should be a routine (assembly) instead of a macro due * to the voluminous code generated by all of the 'long' operations. */ #define CURSIG(p) (((p)->p_sig == 0 || \ (((p)->p_flag & P_TRACED) == 0 && \ ((p)->p_sig & ~(p)->p_sigmask) == 0)) ? \ 0 : issignal(p)) /* * Signal properties and actions. * The array below categorizes the signals and their default actions * according to the following properties: */ #define SA_KILL 0x01 /* terminates process by default */ #define SA_CORE 0x02 /* ditto and coredumps */ #define SA_STOP 0x04 /* suspend process */ #define SA_TTYSTOP 0x08 /* ditto, from tty */ #define SA_IGNORE 0x10 /* ignore by default */ #define SA_CONT 0x20 /* continue if suspended */ #ifdef SIGPROP const char sigprop [NSIG + 1] = { 0, /* unused */ SA_KILL, /* SIGHUP */ SA_KILL, /* SIGINT */ SA_KILL | SA_CORE, /* SIGQUIT */ SA_KILL | SA_CORE, /* SIGILL */ SA_KILL | SA_CORE, /* SIGTRAP */ SA_KILL | SA_CORE, /* SIGABRT */ SA_KILL | SA_CORE, /* SIGEMT */ SA_KILL | SA_CORE, /* SIGFPE */ SA_KILL, /* SIGKILL */ SA_KILL | SA_CORE, /* SIGBUS */ SA_KILL | SA_CORE, /* SIGSEGV */ SA_KILL | SA_CORE, /* SIGSYS */ SA_KILL, /* SIGPIPE */ SA_KILL, /* SIGALRM */ SA_KILL, /* SIGTERM */ SA_IGNORE, /* SIGURG */ SA_STOP, /* SIGSTOP */ SA_STOP | SA_TTYSTOP, /* SIGTSTP */ SA_IGNORE | SA_CONT, /* SIGCONT */ SA_IGNORE, /* SIGCHLD */ SA_STOP | SA_TTYSTOP, /* SIGTTIN */ SA_STOP | SA_TTYSTOP, /* SIGTTOU */ SA_IGNORE, /* SIGIO */ SA_KILL, /* SIGXCPU */ SA_KILL, /* SIGXFSZ */ SA_KILL, /* SIGVTALRM */ SA_KILL, /* SIGPROF */ SA_IGNORE, /* SIGWINCH */ SA_IGNORE, /* SIGINFO */ SA_KILL, /* SIGUSR1 */ SA_KILL, /* SIGUSR2 */ }; #endif /* SIGPROP */ #ifdef KERNEL #define contsigmask (sigmask(SIGCONT)) #define stopsigmask (sigmask(SIGSTOP) | sigmask(SIGTSTP) | \ sigmask(SIGTTIN) | sigmask(SIGTTOU)) #define sigcantmask (sigmask(SIGKILL) | sigmask(SIGSTOP)) #endif #endif /* !_SYS_SIGNALVAR_H_ */ ================================================ FILE: sys/sys/skel.h ================================================ /* * Ioctl definitions for skeleton driver. * * Copyright (C) 2015 Serge Vakulenko * * Permission to use, copy, modify, and distribute this software * and its documentation for any purpose and without fee is hereby * granted, provided that the above copyright notice appear in all * copies and that both that the copyright notice and this * permission notice and warranty disclaimer appear in supporting * documentation, and that the name of the author not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * * The author disclaim all warranties with regard to this * software, including all implied warranties of merchantability * and fitness. In no event shall the author be liable for any * special, indirect or consequential damages or any damages * whatsoever resulting from loss of use, data or profits, whether * in an action of contract, negligence or other tortious action, * arising out of or in connection with the use or performance of * this software. */ #ifndef _SKEL_H #define _SKEL_H #include #define SKELCTL_SETMODE _IO ('?', 0) /* set driver mode mode */ #define SKELCTL_IO(n) _ION('?', 3, n) /* transfer n bytes */ #ifdef KERNEL #include "conf.h" int skeldev_open (dev_t dev, int flag, int mode); int skeldev_close (dev_t dev, int flag, int mode); int skeldev_read (dev_t dev, struct uio *uio, int flag); int skeldev_write (dev_t dev, struct uio *uio, int flag); int skeldev_ioctl (dev_t dev, u_int cmd, caddr_t addr, int flag); #endif #endif ================================================ FILE: sys/sys/spi.h ================================================ /* * Copyright (c) 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ /* * Ioctl definitions for SPI driver. */ #ifndef _SPI_H #define _SPI_H #include /* * User-level interface to the SPI port. */ #define SPICTL_SETMODE _IO ('p', 0) /* set SPI mode */ #define SPICTL_SETRATE _IO ('p', 1) /* set clock rate, kHz */ #define SPICTL_SETSELPIN _IO ('p', 2) /* set select pin */ #define SPICTL_IO8(n) _ION('p', 3, n) /* transfer n*8 bits */ #define SPICTL_IO16(n) _ION('p', 4, n) /* transfer n*16 bits */ #define SPICTL_IO32(n) _ION('p', 5, n) /* transfer n*32 bits */ #define SPICTL_IO8R(n) _ION('p', 6, n) /* transfer R n*8 bits */ #define SPICTL_IO16R(n) _ION('p', 7, n) /* transfer R n*16 bits */ #define SPICTL_IO32R(n) _ION('p', 8, n) /* transfer R n*32 bits */ #define SPICTL_IO8W(n) _ION('p', 9, n) /* transfer W n*8 bits */ #define SPICTL_IO16W(n) _ION('p', 10, n) /* transfer W n*16 bits */ #define SPICTL_IO32W(n) _ION('p', 11, n) /* transfer W n*32 bits */ #define SPICTL_IO32B(n) _ION('p', 12, n) /* transfer BE n*32 bits */ #define SPICTL_IO32RB(n) _ION('p', 13, n) /* transfer RBE n*32 bits */ #define SPICTL_IO32WB(n) _ION('p', 14, n) /* transfer WBE n*32 bits */ #ifdef KERNEL #include "conf.h" /* * Kernel-level interface to the SPI port. */ struct spiio { struct spireg *bus; unsigned int *cs_tris; unsigned int cs_pin; unsigned int baud; unsigned int mode; }; extern int spi_setup(struct spiio *io, int channel, int cs); extern void spi_set_cspin(struct spiio *io, unsigned int *tris, unsigned int pin); extern void spi_select(struct spiio *io); extern void spi_deselect(struct spiio *io); extern void spi_set(struct spiio *io, unsigned int set); extern void spi_clr(struct spiio *io, unsigned int set); extern unsigned int spi_status(struct spiio *io); extern unsigned char spi_transfer(struct spiio *io, unsigned char data); extern void spi_bulk_write_32_be(struct spiio *io, unsigned int len, char *data); extern void spi_bulk_write_32(struct spiio *io, unsigned int len, char *data); extern void spi_bulk_write_16(struct spiio *io, unsigned int len, char *data); extern void spi_bulk_write(struct spiio *io, unsigned int len, unsigned char *data); extern void spi_bulk_read_32_be(struct spiio *io, unsigned int len, char *data); extern void spi_bulk_read_32(struct spiio *io, unsigned int len, char *data); extern void spi_bulk_read_16(struct spiio *io, unsigned int len, char *data); extern void spi_bulk_read(struct spiio *io, unsigned int len, unsigned char *data); extern void spi_bulk_rw_32_be(struct spiio *io, unsigned int len, char *data); extern void spi_bulk_rw_32(struct spiio *io, unsigned int len, char *data); extern void spi_bulk_rw_16(struct spiio *io, unsigned int len, char *data); extern void spi_bulk_rw(struct spiio *io, unsigned int len, unsigned char *data); extern void spi_brg(struct spiio *io, unsigned int baud); extern char *spi_name(struct spiio *io); extern char spi_csname(struct spiio *io); extern int spi_cspin(struct spiio *io); extern unsigned int spi_get_brg(struct spiio *io); /* * Routines of the SPI device driver. */ int spidev_open (dev_t dev, int flag, int mode); int spidev_close (dev_t dev, int flag, int mode); int spidev_read (dev_t dev, struct uio *uio, int flag); int spidev_write (dev_t dev, struct uio *uio, int flag); int spidev_ioctl (dev_t dev, u_int cmd, caddr_t addr, int flag); #endif #endif ================================================ FILE: sys/sys/stat.h ================================================ /* * Copyright (c) 1982, 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #ifndef _STAT_H_ #define _STAT_H_ #include struct stat { dev_t st_dev; ino_t st_ino; u_int st_mode; int st_nlink; uid_t st_uid; gid_t st_gid; dev_t st_rdev; off_t st_size; time_t st_atime; time_t st_mtime; time_t st_ctime; long st_blksize; long st_blocks; u_int st_flags; }; #define S_IFMT 0170000 /* type of file */ #define S_IFDIR 0040000 /* directory */ #define S_IFCHR 0020000 /* character special */ #define S_IFBLK 0060000 /* block special */ #define S_IFREG 0100000 /* regular */ #define S_IFLNK 0120000 /* symbolic link */ #define S_IFSOCK 0140000 /* socket */ #define S_ISUID 0004000 /* set user id on execution */ #define S_ISGID 0002000 /* set group id on execution */ #define S_ISVTX 0001000 /* save swapped text even after use */ #define S_IREAD 0000400 /* read permission, owner */ #define S_IWRITE 0000200 /* write permission, owner */ #define S_IEXEC 0000100 /* execute/search permission, owner */ /* * Definitions of flags in mode that are 4.4 compatible. */ #define S_IFIFO 0010000 /* named pipe (fifo) - Not used by 2.11BSD */ #define S_IRWXU 0000700 /* RWX mask for owner */ #define S_IRUSR 0000400 /* R for owner */ #define S_IWUSR 0000200 /* W for owner */ #define S_IXUSR 0000100 /* X for owner */ #define S_IRWXG 0000070 /* RWX mask for group */ #define S_IRGRP 0000040 /* R for group */ #define S_IWGRP 0000020 /* W for group */ #define S_IXGRP 0000010 /* X for group */ #define S_IRWXO 0000007 /* RWX mask for other */ #define S_IROTH 0000004 /* R for other */ #define S_IWOTH 0000002 /* W for other */ #define S_IXOTH 0000001 /* X for other */ #define S_ISDIR(m) ((m & S_IFMT) == S_IFDIR) /* directory */ #define S_ISCHR(m) ((m & S_IFMT) == S_IFCHR) /* character special */ #define S_ISBLK(m) ((m & S_IFMT) == S_IFBLK) /* block special */ #define S_ISREG(m) ((m & S_IFMT) == S_IFREG) /* regular */ #define S_ISLNK(m) ((m & S_IFMT) == S_IFLNK) /* symbolic link */ #define S_ISSOCK(m) ((m & S_IFMT) == S_IFSOCK) /* socket */ /* * Definitions of flags stored in file flags word. Different from 4.4 because * 2.11BSD only could afford a u_short for the flags. It is not a great * inconvenience since there are still 5 bits in each byte available for * future use. * * Super-user and owner changeable flags. */ #define UF_SETTABLE 0x00ff /* mask of owner changeable flags */ #define UF_NODUMP 0x0001 /* do not dump file */ #define UF_IMMUTABLE 0x0002 /* file may not be changed */ #define UF_APPEND 0x0004 /* writes to file may only append */ /* * Super-user changeable flags. */ #define SF_SETTABLE 0xff00 /* mask of superuser changeable flags */ #define SF_ARCHIVED 0x0100 /* file is archived */ #define SF_IMMUTABLE 0x0200 /* file may not be changed */ #define SF_APPEND 0x0400 /* writes to file may only append */ #ifdef KERNEL /* * Shorthand abbreviations of above. */ #define APPEND (UF_APPEND | SF_APPEND) #define IMMUTABLE (UF_IMMUTABLE | SF_IMMUTABLE) #else int chmod (const char *path, mode_t mode); int fchmod (int fd, mode_t mode); int mknod (const char *path, mode_t mode, dev_t dev); int mkdir (const char *path, mode_t mode); int stat (const char *path, struct stat *sb); mode_t umask (mode_t cmask); #endif #endif /* !_STAT_H_ */ ================================================ FILE: sys/sys/stdint.h ================================================ #ifndef _STDINT_H #define _STDINT_H typedef signed char int8_t; typedef short int int16_t; typedef int int32_t; typedef long long int64_t; typedef unsigned char uint8_t; typedef unsigned short int uint16_t; typedef unsigned int uint32_t; typedef unsigned long long uint64_t; #define UINT32_C(x) (x##U) #define UINT64_C(x) (x##ULL) #endif /* _STDINT_H */ ================================================ FILE: sys/sys/swap.h ================================================ #ifndef _SWAP_H #define _SWAP_H #ifdef KERNEL #include "ioctl.h" #else #include #endif #define TFALLOC _IOWR('s', 1, off_t) #ifdef KERNEL extern int swopen(dev_t dev, int mode, int flag); extern int swclose(dev_t dev, int mode, int flag); extern void swstrategy(struct buf *bp); extern daddr_t swsize(dev_t dev); extern int swcread(dev_t dev, struct uio *uio, int flag); extern int swcwrite(dev_t dev, struct uio *uio, int flag); extern int swcioctl(dev_t dev, u_int cmd, caddr_t addr, int flag); extern int swcopen(dev_t dev, int mode, int flag); extern int swcclose(dev_t dev, int mode, int flag); #endif /* KERNEL */ #endif /* !_SWAP_H */ ================================================ FILE: sys/sys/sysctl.h ================================================ /* * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Mike Karels at Berkeley Software Design, Inc. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)sysctl.h 8.1.3 (2.11BSD) 1999/4/29 */ #ifndef _SYS_SYSCTL_H_ #define _SYS_SYSCTL_H_ /* * These are for the eproc, etext, einode, efile and map structures. */ #ifndef KERNEL #include #include #include #include #include #include #include #endif /* * Definitions for sysctl call. The sysctl call uses a hierarchical name * for objects that can be examined or modified. The name is expressed as * a sequence of integers. Like a file path name, the meaning of each * component depends on its place in the hierarchy. The top-level and kern * identifiers are defined here, and other identifiers are defined in the * respective subsystem header files. */ #define CTL_MAXNAME 12 /* largest number of components supported */ /* * Each subsystem defined by sysctl defines a list of variables * for that subsystem. Each name is either a node with further * levels defined below it, or it is a leaf of some particular * type given below. Each sysctl level defines a set of name/type * pairs to be used by sysctl(1) in manipulating the subsystem. */ struct ctlname { char *ctl_name; /* subsystem name */ int ctl_type; /* type of name */ }; #define CTLTYPE_NODE 1 /* name is a node */ #define CTLTYPE_INT 2 /* name describes a 16-bit integer */ #define CTLTYPE_STRING 3 /* name describes a string */ #define CTLTYPE_LONG 4 /* name describes a 32-bit number */ #define CTLTYPE_STRUCT 5 /* name describes a structure */ /* * Top-level identifiers */ #define CTL_UNSPEC 0 /* unused */ #define CTL_KERN 1 /* "high kernel": proc, limits */ #define CTL_VM 2 /* virtual memory */ #define CTL_FS 3 /* file system, mount type is next */ #define CTL_NET 4 /* network, see socket.h */ #define CTL_DEBUG 5 /* debugging parameters */ #define CTL_HW 6 /* generic cpu/io */ #define CTL_MACHDEP 7 /* machine dependent */ #define CTL_USER 8 /* user-level */ #define CTL_MAXID 9 /* number of valid top-level ids */ #ifndef KERNEL #define CTL_NAMES { \ { 0, 0 }, \ { "kern", CTLTYPE_NODE }, \ { "vm", CTLTYPE_NODE }, \ { "fs", CTLTYPE_NODE }, \ { "net", CTLTYPE_NODE }, \ { "debug", CTLTYPE_NODE }, \ { "hw", CTLTYPE_NODE }, \ { "machdep", CTLTYPE_NODE }, \ { "user", CTLTYPE_NODE }, \ } #endif /* * CTL_KERN identifiers */ #define KERN_OSTYPE 1 /* string: system version */ #define KERN_OSRELEASE 2 /* string: system release */ #define KERN_OSREV 3 /* int: system revision */ #define KERN_VERSION 4 /* string: compile time info */ #define KERN_MAXINODES 5 /* int: max inodes */ #define KERN_MAXPROC 6 /* int: max processes */ #define KERN_MAXFILES 7 /* int: max open files */ #define KERN_ARGMAX 8 /* int: max arguments to exec */ #define KERN_SECURELVL 9 /* int: system security level */ #define KERN_HOSTNAME 10 /* string: hostname */ #define KERN_HOSTID 11 /* int: host identifier */ #define KERN_CLOCKRATE 12 /* struct: struct clockinfo */ #define KERN_INODE 13 /* struct: inode structures */ #define KERN_PROC 14 /* struct: process entries */ #define KERN_FILE 15 /* struct: file entries */ #define KERN_PROF 16 /* node: kernel profiling info */ #define KERN_POSIX1 17 /* int: POSIX.1 version */ #define KERN_NGROUPS 18 /* int: # of supplemental group ids */ #define KERN_JOB_CONTROL 19 /* int: is job control available */ #define KERN_SAVED_IDS 20 /* int: saved set-user/group-ID */ #define KERN_BOOTTIME 21 /* struct: time kernel was booted */ #define KERN_MAXTEXTS 22 /* int: # of text entries */ #define KERN_TEXT 23 /* struct: text entries */ #define KERN_ACCTTHRESH 24 /* int: accounting daemon threshold */ #define KERN_OSVERSION 25 /* string: kernel build version */ #define KERN_MAXID 26 /* number of valid kern ids */ #ifndef KERNEL #define CTL_KERN_NAMES { \ { 0, 0 }, \ { "ostype", CTLTYPE_STRING }, \ { "osrelease", CTLTYPE_STRING }, \ { "osrevision", CTLTYPE_LONG }, \ { "version", CTLTYPE_STRING }, \ { "maxinodes", CTLTYPE_INT }, \ { "maxproc", CTLTYPE_INT }, \ { "maxfiles", CTLTYPE_INT }, \ { "argmax", CTLTYPE_INT }, \ { "securelevel", CTLTYPE_INT }, \ { "hostname", CTLTYPE_STRING }, \ { "hostid", CTLTYPE_LONG }, \ { "clockrate", CTLTYPE_STRUCT }, \ { "inode", CTLTYPE_STRUCT }, \ { "proc", CTLTYPE_STRUCT }, \ { "file", CTLTYPE_STRUCT }, \ { "profiling", CTLTYPE_NODE }, \ { "posix1version", CTLTYPE_INT }, \ { "ngroups", CTLTYPE_INT }, \ { "job_control", CTLTYPE_INT }, \ { "saved_ids", CTLTYPE_INT }, \ { "boottime", CTLTYPE_STRUCT }, \ { "maxtexts", CTLTYPE_INT }, \ { "text", CTLTYPE_STRUCT }, \ { "acctthresh", CTLTYPE_INT }, \ { "osversion", CTLTYPE_STRING }, \ } #endif /* * KERN_PROC subtypes */ #define KERN_PROC_ALL 0 /* everything */ #define KERN_PROC_PID 1 /* by process id */ #define KERN_PROC_PGRP 2 /* by process group id */ #define KERN_PROC_SESSION 3 /* by session of pid - NOT IN 2.11 */ #define KERN_PROC_TTY 4 /* by controlling tty */ #define KERN_PROC_UID 5 /* by effective uid */ #define KERN_PROC_RUID 6 /* by real uid */ /* * KERN_PROC subtype ops return arrays of augmented proc structures: */ struct kinfo_proc { struct proc kp_proc; /* proc structure */ struct eproc { struct proc *e_paddr; /* address of proc */ dev_t e_tdev; /* controlling tty dev */ pid_t e_tpgid; /* tty process group id */ uid_t e_ruid; /* real uid */ } kp_eproc; }; /* * KERN_INODE returns an array of augmented inode structures: */ struct kinfo_inode { struct inode *kp_inodep; /* address of inode */ struct inode kp_inode; /* inode structure */ }; /* * KERN_FILE returns an array of augmented file structures: */ struct kinfo_file { struct file *kp_filep; /* address of file */ struct file kp_file; /* file structure */ }; /* * CTL_HW identifiers */ #define HW_MACHINE 1 /* string: machine class */ #define HW_MODEL 2 /* string: specific machine model */ #define HW_NCPU 3 /* int: number of cpus */ #define HW_BYTEORDER 4 /* int: machine byte order */ #define HW_PHYSMEM 5 /* int: total memory */ #define HW_USERMEM 6 /* int: non-kernel memory */ #define HW_PAGESIZE 7 /* int: software page size */ #define HW_DISKNAMES 8 /* strings: disk drive names */ #define HW_DISKSTATS 9 /* struct: diskstats[] */ #define HW_MACHINE_ARCH 10 /* string: machine architecture */ #define HW_MAXID 11 /* number of valid hw ids */ #ifndef KERNEL #define CTL_HW_NAMES { \ { 0, 0 }, \ { "machine", CTLTYPE_STRING }, \ { "model", CTLTYPE_STRING }, \ { "ncpu", CTLTYPE_INT }, \ { "byteorder", CTLTYPE_INT }, \ { "physmem", CTLTYPE_LONG }, \ { "usermem", CTLTYPE_LONG }, \ { "pagesize", CTLTYPE_INT }, \ { "disknames", CTLTYPE_STRUCT }, \ { "diskstats", CTLTYPE_STRUCT }, \ { "machine_arch", CTLTYPE_STRING }, \ } #endif #ifndef KERNEL /* * CTL_USER definitions */ #define USER_CS_PATH 1 /* string: _CS_PATH */ #define USER_BC_BASE_MAX 2 /* int: BC_BASE_MAX */ #define USER_BC_DIM_MAX 3 /* int: BC_DIM_MAX */ #define USER_BC_SCALE_MAX 4 /* int: BC_SCALE_MAX */ #define USER_BC_STRING_MAX 5 /* int: BC_STRING_MAX */ #define USER_COLL_WEIGHTS_MAX 6 /* int: COLL_WEIGHTS_MAX */ #define USER_EXPR_NEST_MAX 7 /* int: EXPR_NEST_MAX */ #define USER_LINE_MAX 8 /* int: LINE_MAX */ #define USER_RE_DUP_MAX 9 /* int: RE_DUP_MAX */ #define USER_POSIX2_VERSION 10 /* int: POSIX2_VERSION */ #define USER_POSIX2_C_BIND 11 /* int: POSIX2_C_BIND */ #define USER_POSIX2_C_DEV 12 /* int: POSIX2_C_DEV */ #define USER_POSIX2_CHAR_TERM 13 /* int: POSIX2_CHAR_TERM */ #define USER_POSIX2_FORT_DEV 14 /* int: POSIX2_FORT_DEV */ #define USER_POSIX2_FORT_RUN 15 /* int: POSIX2_FORT_RUN */ #define USER_POSIX2_LOCALEDEF 16 /* int: POSIX2_LOCALEDEF */ #define USER_POSIX2_SW_DEV 17 /* int: POSIX2_SW_DEV */ #define USER_POSIX2_UPE 18 /* int: POSIX2_UPE */ #define USER_STREAM_MAX 19 /* int: POSIX2_STREAM_MAX */ #define USER_TZNAME_MAX 20 /* int: POSIX2_TZNAME_MAX */ #define USER_MAXID 21 /* number of valid user ids */ #define CTL_USER_NAMES { \ { 0, 0 }, \ { "cs_path", CTLTYPE_STRING }, \ { "bc_base_max", CTLTYPE_INT }, \ { "bc_dim_max", CTLTYPE_INT }, \ { "bc_scale_max", CTLTYPE_INT }, \ { "bc_string_max", CTLTYPE_INT }, \ { "coll_weights_max", CTLTYPE_INT }, \ { "expr_nest_max", CTLTYPE_INT }, \ { "line_max", CTLTYPE_INT }, \ { "re_dup_max", CTLTYPE_INT }, \ { "posix2_version", CTLTYPE_INT }, \ { "posix2_c_bind", CTLTYPE_INT }, \ { "posix2_c_dev", CTLTYPE_INT }, \ { "posix2_char_term", CTLTYPE_INT }, \ { "posix2_fort_dev", CTLTYPE_INT }, \ { "posix2_fort_run", CTLTYPE_INT }, \ { "posix2_localedef", CTLTYPE_INT }, \ { "posix2_sw_dev", CTLTYPE_INT }, \ { "posix2_upe", CTLTYPE_INT }, \ { "stream_max", CTLTYPE_INT }, \ { "tzname_max", CTLTYPE_INT }, \ } #endif /* * CTL_DEBUG definitions * * Second level identifier specifies which debug variable. * Third level identifier specifies which structure component. */ #define CTL_DEBUG_NAME 0 /* string: variable name */ #define CTL_DEBUG_VALUE 1 /* int: variable value */ #define CTL_DEBUG_MAXID 20 /* * Locking and stats */ struct sysctl_lock { int sl_lock; int sl_want; int sl_locked; }; #ifdef KERNEL #ifdef DEBUG /* * CTL_DEBUG variables. * * These are declared as separate variables so that they can be * individually initialized at the location of their associated * variable. The loader prevents multiple use by issuing errors * if a variable is initialized in more than one place. They are * aggregated into an array in debug_sysctl(), so that it can * conveniently locate them when queried. If more debugging * variables are added, they must also be declared here and also * entered into the array. */ struct ctldebug { char *debugname; /* name of debugging variable */ int *debugvar; /* pointer to debugging variable */ }; extern struct ctldebug debug0, debug1, debug2, debug3, debug4; extern struct ctldebug debug5, debug6, debug7, debug8, debug9; extern struct ctldebug debug10, debug11, debug12, debug13, debug14; extern struct ctldebug debug15, debug16, debug17, debug18, debug19; #endif /* DEBUG */ struct sysctl_lock memlock; /* * Internal sysctl function calling convention: * * (*sysctlfn)(name, namelen, oldval, oldlenp, newval, newlen); * * The name parameter points at the next component of the name to be * interpreted. The namelen parameter is the number of integers in * the name. */ typedef int (sysctlfn)(int *, u_int, void *, size_t *, void *, size_t); int sysctl_int(void *, size_t *, void *, size_t, int *); int sysctl_rdint(void *, size_t *, void *, int); int sysctl_long(void *, size_t *, void *, size_t, long *); int sysctl_rdlong(void *, size_t *, void *, long); int sysctl_string(void *, size_t *, void *, size_t, char *, int); int sysctl_rdstring(void *, size_t *, void *, const char *); int sysctl_struct(void *, size_t *, void *, size_t, void *, int); int sysctl_rdstruct(void *, size_t *, void *, void *, int); int sysctl_file(char *, size_t *); int sysctl_clockrate(char *, size_t *); int sysctl_inode(char *, size_t *); int sysctl_doproc(int *, u_int, char *, size_t *); void fill_eproc(struct proc *p, struct eproc *ep); void fill_from_u(struct proc *, uid_t *, struct tty **, dev_t *); #else /* !KERNEL */ int sysctl(int *, u_int, void *, size_t *, void *, size_t); int __sysctl(int *, u_int, void *, size_t *, void *, size_t); #endif /* KERNEL */ #endif /* !_SYS_SYSCTL_H_ */ ================================================ FILE: sys/sys/syslimits.h ================================================ /* $OpenBSD: syslimits.h,v 1.14 2020/04/02 18:00:00 deraadt Exp $ */ /* $NetBSD: syslimits.h,v 1.12 1995/10/05 05:26:19 thorpej Exp $ */ /* * Copyright (c) 1988, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)syslimits.h 8.1 (Berkeley) 6/2/93 */ #define PATH_MAX 256 /* max bytes in pathname */ ================================================ FILE: sys/sys/syslog.h ================================================ /* * Copyright (c) 1982, 1986, 1988, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)syslog.h 8.1.2 (2.11BSD) 1999/06/18 * $Id: syslog.h,v 1.4 1994/08/21 04:42:00 paul Exp $ */ #ifndef _SYS_SYSLOG_H_ #define _SYS_SYSLOG_H_ /* * priorities/facilities are encoded into a single 16-bit quantity, where the * bottom 3 bits are the priority (0-7) and the top 13 bits are the facility * (0-big number). Both the priorities and the facilities map roughly * one-to-one to strings in the syslogd(8) source code. This mapping is * included in this file. * * priorities (these are ordered) */ #define LOG_EMERG 0 /* system is unusable */ #define LOG_ALERT 1 /* action must be taken immediately */ #define LOG_CRIT 2 /* critical conditions */ #define LOG_ERR 3 /* error conditions */ #define LOG_WARNING 4 /* warning conditions */ #define LOG_NOTICE 5 /* normal but significant condition */ #define LOG_INFO 6 /* informational */ #define LOG_DEBUG 7 /* debug-level messages */ #define LOG_PRIMASK 0x07 /* mask to extract priority part (internal) */ /* extract priority */ #define LOG_PRI(p) ((p) & LOG_PRIMASK) #define LOG_MAKEPRI(fac, pri) (((fac) << 3) | (pri)) #ifdef SYSLOG_NAMES #define INTERNAL_NOPRI 0x10 /* the "no priority" priority */ /* mark "facility" */ #define INTERNAL_MARK LOG_MAKEPRI(LOG_NFACILITIES, 0) typedef struct _code { char *c_name; int c_val; } CODE; CODE prioritynames[] = { "alert", LOG_ALERT, "crit", LOG_CRIT, "debug", LOG_DEBUG, "emerg", LOG_EMERG, "err", LOG_ERR, "info", LOG_INFO, "none", INTERNAL_NOPRI, /* INTERNAL */ "notice", LOG_NOTICE, "warning", LOG_WARNING, NULL, -1, }; #endif /* facility codes */ #define LOG_KERN (0<<3) /* kernel messages */ #define LOG_USER (1<<3) /* random user-level messages */ #define LOG_MAIL (2<<3) /* mail system */ #define LOG_DAEMON (3<<3) /* system daemons */ #define LOG_AUTH (4<<3) /* security/authorization messages */ #define LOG_SYSLOG (5<<3) /* messages generated internally by syslogd */ #define LOG_LPR (6<<3) /* line printer subsystem */ #define LOG_NEWS (7<<3) /* network news subsystem */ #define LOG_UUCP (8<<3) /* UUCP subsystem */ #define LOG_CRON (9<<3) /* clock daemon */ #define LOG_AUTHPRIV (10<<3) /* security/authorization messages (private) */ #define LOG_FTP (11<<3) /* ftp daemon */ /* other codes through 15 reserved for system use */ #define LOG_LOCAL0 (16<<3) /* reserved for local use */ #define LOG_LOCAL1 (17<<3) /* reserved for local use */ #define LOG_LOCAL2 (18<<3) /* reserved for local use */ #define LOG_LOCAL3 (19<<3) /* reserved for local use */ #define LOG_LOCAL4 (20<<3) /* reserved for local use */ #define LOG_LOCAL5 (21<<3) /* reserved for local use */ #define LOG_LOCAL6 (22<<3) /* reserved for local use */ #define LOG_LOCAL7 (23<<3) /* reserved for local use */ #define LOG_NFACILITIES 24 /* current number of facilities */ #define LOG_FACMASK 0x03f8 /* mask to extract facility part */ /* facility of pri */ #define LOG_FAC(p) (((p) & LOG_FACMASK) >> 3) #ifdef SYSLOG_NAMES CODE facilitynames[] = { "auth", LOG_AUTH, "authpriv", LOG_AUTHPRIV, "cron", LOG_CRON, "daemon", LOG_DAEMON, "ftp", LOG_FTP, "kern", LOG_KERN, "lpr", LOG_LPR, "mail", LOG_MAIL, "mark", INTERNAL_MARK, /* INTERNAL */ "news", LOG_NEWS, "syslog", LOG_SYSLOG, "user", LOG_USER, "uucp", LOG_UUCP, "local0", LOG_LOCAL0, "local1", LOG_LOCAL1, "local2", LOG_LOCAL2, "local3", LOG_LOCAL3, "local4", LOG_LOCAL4, "local5", LOG_LOCAL5, "local6", LOG_LOCAL6, "local7", LOG_LOCAL7, NULL, -1, }; #endif #ifdef KERNEL #define LOG_PRINTF -1 /* pseudo-priority to indicate use of printf */ #else void syslog (int pri, const char *fmt, ...); void openlog (const char *ident, int logstat, int logfac); void closelog (void); #endif /* * arguments to setlogmask. */ #define LOG_MASK(pri) (1 << (pri)) /* mask for one priority */ #define LOG_UPTO(pri) ((1 << ((pri)+1)) - 1) /* all priorities through pri */ /* * Option flags for openlog. * * LOG_ODELAY no longer does anything. * LOG_NDELAY is the inverse of what it used to be. */ #define LOG_PID 0x01 /* log the pid with each message */ #define LOG_CONS 0x02 /* log on the console if errors in sending */ #define LOG_ODELAY 0x04 /* delay open until first syslog() (default) */ #define LOG_NDELAY 0x08 /* don't delay open */ #define LOG_NOWAIT 0x10 /* don't wait for console forks: DEPRECATED */ #define LOG_PERROR 0x20 /* log to stderr as well */ #endif ================================================ FILE: sys/sys/systm.h ================================================ /* * Copyright (c) 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ /* * The `securelevel' variable controls the security level of the system. * It can only be decreased by process 1 (/sbin/init). * * Security levels are as follows: * -1 permannently insecure mode - always run system in level 0 mode. * 0 insecure mode - immutable and append-only flags make be turned off. * All devices may be read or written subject to permission modes. * 1 secure mode - immutable and append-only flags may not be changed; * raw disks of mounted filesystems, /dev/mem, and /dev/kmem are * read-only. * 2 highly secure mode - same as (1) plus raw disks are always * read-only whether mounted or not. This level precludes tampering * with filesystems by unmounting them, but also inhibits running * newfs while the system is secured. * * In normal operation, the system runs in level 0 mode while single user * and in level 1 mode while multiuser. If level 2 mode is desired while * running multiuser, it can be set in the multiuser startup script * (/etc/rc.local) using sysctl(8). If it is desired to run the system * in level 0 mode while multiuser, initialize the variable securelevel * in /sys/kern/kern_sysctl.c to -1. Note that it is NOT initialized to * zero as that would allow the vmunix binary to be patched to -1. * Without initialization, securelevel loads in the BSS area which only * comes into existence when the kernel is loaded and hence cannot be * patched by a stalking hacker. */ #include "conf.h" extern int securelevel; /* system security level */ extern const char version[]; /* system version */ extern const char ostype[]; /* operating system name */ extern const char osversion[]; /* operating system version */ extern const char osrelease[]; /* operating system release */ /* * Nblkdev is the number of entries (rows) in the block switch. * Used in bounds checking on major device numbers. */ extern const int nblkdev; /* * Number of character switch entries. */ extern const int nchrdev; /* * Number of system call entries. */ extern const int nsysent; extern int mpid; /* generic for unique process id's */ extern char runin; /* scheduling flag */ extern char runout; /* scheduling flag */ extern int runrun; /* scheduling flag */ extern char curpri; /* more scheduling */ extern u_int swapstart, nswap; /* start and size of swap space */ extern int updlock; /* lock for sync */ extern daddr_t rablock; /* block to be read ahead */ extern dev_t rootdev; /* device of the root */ extern dev_t dumpdev; /* device to take dumps on */ extern long dumplo; /* offset into dumpdev */ extern dev_t swapdev; /* swapping device */ extern dev_t pipedev; /* pipe device */ extern const char icode[]; /* user init code */ extern const char icodeend[]; /* its end */ extern const char initflags[]; /* init flags string */ #ifdef PIC32MX7 /* XXX PIC32 */ #define __kernel_flash_start KERNEL_FLASH_START #define __kernel_flash_end KERNEL_FLASH_END #define __kernel_data_start KERNEL_DATA_START #define __kernel_data_end KERNEL_DATA_END #define __user_data_start USER_DATA_START #define __user_data_end USER_DATA_END #else /* Memory address symbols defined in kernel linker script. */ extern char __kernel_flash_start[]; extern char __kernel_flash_end[]; extern char __kernel_data_start[]; extern char __kernel_data_end[]; extern char __user_data_start[]; extern char __user_data_end[]; #endif /* XXX PIC32 */ struct inode; daddr_t bmap (struct inode *ip, daddr_t bn, int rwflg, int flags); extern void kmemdev(); /* * Structure of the system-entry table */ extern const struct sysent { int sy_narg; /* total number of arguments */ void (*sy_call) (void); /* handler */ } sysent[]; extern const char *syscallnames[]; extern int noproc; /* no one is running just now */ extern char *panicstr; extern int boothowto; /* reboot flags, from boot */ extern int selwait; extern size_t physmem; /* total amount of physical memory */ extern dev_t get_cdev_by_name(char *); extern char *cdevname(dev_t dev); void panic (char *msg); void printf (char *fmt, ...); void uprintf (char *fmt, ...); /* print to the current user's terminal */ struct tty; void tprintf (struct tty *tp, char *fmt, ...); /* print to the specified terminal */ int loginit (void); void log (int level, char *fmt, ...); int logwrt (char *buf, int len, int log); void logwakeup (int unit); void config (void); void cninit (void); void cnidentify (void); void cnputc (char c); int cngetc (void); int baduaddr (caddr_t addr); /* detect bad user address */ int badkaddr (caddr_t addr); /* detect bad kernel address */ int strncmp (const char *s1, const char *s2, size_t n); void bzero (void *s, size_t nbytes); void bcopy (const void *src, void *dest, size_t nbytes); int bcmp (const void *a, const void *b, size_t nbytes); int copystr (caddr_t src, caddr_t dest, u_int maxlen, u_int *copied); size_t strlen (const char *s); int ffs (u_long i); /* find the index of the lsb set bit */ void insque (void *element, void *pred); void remque (void *element); void startup (void); /* machine-dependent startup code */ int chrtoblk (dev_t dev); /* convert from character to block device number */ int isdisk (dev_t dev, int type); /* determine if a device is a disk */ int iskmemdev (dev_t dev); /* identify /dev/mem and /dev/kmem */ void boot (dev_t dev, int howto); /* * Copy data from kernel space fromaddr to user space address toaddr. * Fromaddr and toaddr must be word aligned. Returns zero on success, * EFAULT on failure. */ int copyout (const caddr_t from, caddr_t to, u_int nbytes); /* * Copy data from user space fromaddr to kernel space address toaddr. * Fromaddr and toaddr must be word aligned. Returns zero on success, * EFAULT on failure. */ int copyin (const caddr_t from, caddr_t to, u_int nbytes); /* * Check if gid is a member of the group set. */ int groupmember (gid_t gid); /* * Wake up all processes sleeping on chan. */ void wakeup (caddr_t chan); /* * Allocate iostat disk monitoring slots for a driver. */ void dk_alloc (int *dkn, int slots, char *name); /* * Initialize callouts. */ void coutinit (void); /* * Syscalls. */ void nosys (void); /* 1.1 processes and protection */ void getpid (void); void getppid (void), fork (void), rexit (void), execv (void), execve (void); void wait4 (void), getuid (void), getgid (void), getgroups (void), setgroups (void); void geteuid (void), getegid (void); void getpgrp (void), setpgrp (void); void setgid (void), setegid (void), setuid (void), seteuid (void); void ucall (void); /* 2BSD calls */ /* 1.2 memory management */ void brk (void); void ustore (void); /* 2BSD calls */ void ufetch (void); /* 2BSD calls */ /* 1.3 signals */ void sigstack (void), sigreturn (void); void sigaction (void), sigprocmask (void), sigpending (void), sigaltstack (void), sigsuspend (void); void sigwait (void), kill (void), killpg (void); /* 1.4 timing and statistics */ void gettimeofday (void), settimeofday (void); void getitimer (void), setitimer (void); void adjtime (void); /* 1.5 descriptors */ void getdtablesize (void), dup (void), dup2 (void), close (void); void pselect (void), select (void), fcntl (void), flock (void); /* 1.6 resource controls */ void getpriority (void), setpriority (void), getrusage (void), getrlimit (void), setrlimit (void); /* 1.7 system operation support */ void umount (void), smount (void); void sync (void), reboot (void), __sysctl (void); /* 2.1 generic operations */ void read (void), write (void), readv (void), writev (void), ioctl (void); /* 2.2 file system */ void chdir (void), fchdir (void), chroot (void); void mkdir (void), rmdir (void), chflags (void), fchflags (void); void open (void), mknod (void), unlink (void), stat (void), fstat (void), lstat (void); void chown (void), fchown (void), chmod (void), fchmod (void), utimes (void); void link (void), symlink (void), readlink (void), rename (void); void lseek (void), truncate (void), ftruncate (void), saccess (void), fsync (void); void statfs (void), fstatfs (void), getfsstat (void); /* 2.3 communications */ void socket (void), bind (void), listen (void), accept (void), connect (void); void socketpair (void), sendto (void), send (void), recvfrom (void), recv (void); void sendmsg (void), recvmsg (void), shutdown (void), setsockopt (void), getsockopt (void); void getsockname (void), getpeername (void), pipe (void); void umask (void); /* XXX */ /* 2.4 processes */ void ptrace (void); void profil (void); /* 'cuz sys calls are interruptible */ void vhangup (void); /* should just do in exit (void) */ void vfork (void); /* awaiting fork w/ copy on write */ /* * Drivers. */ struct buf; struct uio; void cninit(); int cnopen (dev_t dev, int flag, int mode); int cnclose (dev_t dev, int flag, int mode); int cnread (dev_t dev, struct uio *uio, int flag); int cnwrite (dev_t dev, struct uio *uio, int flag); int cnioctl (dev_t dev, u_int cmd, caddr_t addr, int flag); int cnselect (dev_t dev, int rw); #ifdef TS_ISOPEN extern struct tty cnttys[]; #endif int mmrw (dev_t dev, struct uio *uio, int flag); int seltrue (dev_t dev, int rw); void nostrategy (struct buf *bp); void nonet (void); int syopen (dev_t dev, int flag, int mode); int syread (dev_t dev, struct uio *uio, int flag); int sywrite (dev_t dev, struct uio *uio, int flag); int syioctl (dev_t dev, u_int cmd, caddr_t addr, int flag); int syselect (dev_t dev, int rw); int logopen (dev_t dev, int flag, int mode); int logclose (dev_t dev, int flag, int mode); int logread (dev_t dev, struct uio *uio, int flag); int logioctl (dev_t dev, u_int cmd, caddr_t addr, int flag); int logselect (dev_t dev, int rw); int fdopen (dev_t dev, int flag, int mode); int dupfdopen (int indx, int dfd, int mode, int error); ================================================ FILE: sys/sys/time.h ================================================ /* * Copyright (c) 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #ifndef _SYS_TIME_H_ #define _SYS_TIME_H_ #include /* * Structure returned by gettimeofday(2) system call, * and used in other calls. */ struct timeval { long tv_sec; /* seconds */ long tv_usec; /* and microseconds */ }; /* * Structure defined by POSIX.4 to be like a timeval but with nanoseconds * instead of microseconds. Silly on a PDP-11 but keeping the names the * same makes life simpler than changing the names. */ struct timespec { time_t tv_sec; /* seconds */ long tv_nsec; /* and nanoseconds */ }; struct timezone { int tz_minuteswest; /* minutes west of Greenwich */ int tz_dsttime; /* type of dst correction */ }; #define DST_NONE 0 /* not on dst */ #define DST_USA 1 /* USA style dst */ #define DST_AUST 2 /* Australian style dst */ #define DST_WET 3 /* Western European dst */ #define DST_MET 4 /* Middle European dst */ #define DST_EET 5 /* Eastern European dst */ #define DST_CAN 6 /* Canada */ /* * Operations on timevals. * * NB: timercmp does not work for >= or <=. */ #define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec) #define timercmp(tvp, uvp, cmp) \ ((tvp)->tv_sec cmp (uvp)->tv_sec || \ (tvp)->tv_sec == (uvp)->tv_sec && \ (tvp)->tv_usec cmp (uvp)->tv_usec) #define timerclear(tvp) (tvp)->tv_sec = (tvp)->tv_usec = 0 /* * Names of the interval timers, and structure * defining a timer setting. */ #define ITIMER_REAL 0 #define ITIMER_VIRTUAL 1 #define ITIMER_PROF 2 struct k_itimerval { long it_interval; /* timer interval */ long it_value; /* current value */ }; struct itimerval { struct timeval it_interval; /* timer interval */ struct timeval it_value; /* current value */ }; #ifdef KERNEL /* * Round up a proposed time value to a minimal resolution of the clock. */ int itimerfix (struct timeval *tv); /* * Add and subtract routines for timevals. */ void timevaladd (struct timeval *t1, struct timeval *t2); void timevalsub (struct timeval *t1, struct timeval *t2); /* * Compute number of hz until specified time. */ int hzto (struct timeval *tv); #else #include int gettimeofday (struct timeval *tv, struct timezone *tz); int settimeofday (const struct timeval *tv, const struct timezone *tz); int utimes (const char *filename, const struct timeval times[2]); int getitimer (int which, struct itimerval *curr_value); int setitimer (int which, const struct itimerval *new_value, struct itimerval *old_value); char *tztab (int zone, int dst); #endif /* * KERN_CLOCKRATE clock information structure */ struct clockinfo { int tick; /* micro-seconds per hz tick */ int hz; /* clock frequency */ int stathz; /* statistics clock frequency */ int profhz; /* profiling clock frequency */ }; extern unsigned int msec(); #endif /* !_SYS_TIME_H_ */ ================================================ FILE: sys/sys/times.h ================================================ /* * Copyright (c) 1982, 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * * @(#)times.h 7.1 (Berkeley) 6/4/86 */ /* * Structure returned by times() */ struct tms { time_t tms_utime; /* user time */ time_t tms_stime; /* system time */ time_t tms_cutime; /* user time, children */ time_t tms_cstime; /* system time, children */ }; ================================================ FILE: sys/sys/tty.h ================================================ #ifndef _TTY_H #define _TTY_H /* * Copyright (c) 1982, 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #ifdef KERNEL #include "types.h" #include "ttychars.h" #include "ttydev.h" #include "ioctl.h" #else #include #include #include #include #endif /* * A clist structure is the head of a linked list queue * of characters. The characters are stored in blocks * containing a link and CBSIZE (param.h) characters. * The routines in tty_subr.c manipulate these structures. */ struct clist { int c_cc; /* character count */ char *c_cf; /* pointer to first char */ char *c_cl; /* pointer to last char */ }; /* * Per-tty structure. * * Should be split in two, into device and tty drivers. * Glue could be masks of what to echo and circular buffer * (low, high, timeout). */ struct tty { union { struct { struct clist T_rawq; struct clist T_canq; } t_t; #define t_rawq t_nu.t_t.T_rawq /* raw characters or partial line */ #define t_canq t_nu.t_t.T_canq /* raw characters or partial line */ struct { struct buf *T_bufp; char *T_cp; int T_inbuf; int T_rec; } t_n; #define t_bufp t_nu.t_n.T_bufp /* buffer allocated to protocol */ #define t_cp t_nu.t_n.T_cp /* pointer into the ripped off buffer */ #define t_inbuf t_nu.t_n.T_inbuf /* number chars in the buffer */ #define t_rec t_nu.t_n.T_rec /* have a complete record */ } t_nu; struct clist t_outq; /* device */ void (*t_oproc) (struct tty*); struct proc *t_rsel; /* tty */ struct proc *t_wsel; caddr_t T_LINEP; /* ### */ caddr_t t_addr; /* ??? */ dev_t t_dev; /* device */ long t_flags; /* some of both */ long t_state; /* some of both */ int t_pgrp; /* tty */ int t_delct; /* tty */ int t_col; /* tty */ int t_ispeed, t_ospeed; /* device */ int t_rocount, t_rocol; /* tty */ struct ttychars t_chars; /* tty */ struct winsize t_winsize; /* window size */ /* be careful of tchars & co. */ #define t_erase t_chars.tc_erase #define t_kill t_chars.tc_kill #define t_intrc t_chars.tc_intrc #define t_quitc t_chars.tc_quitc #define t_startc t_chars.tc_startc #define t_stopc t_chars.tc_stopc #define t_eofc t_chars.tc_eofc #define t_brkc t_chars.tc_brkc #define t_suspc t_chars.tc_suspc #define t_dsuspc t_chars.tc_dsuspc #define t_rprntc t_chars.tc_rprntc #define t_flushc t_chars.tc_flushc #define t_werasc t_chars.tc_werasc #define t_lnextc t_chars.tc_lnextc }; #define TTIPRI 28 #define TTOPRI 29 /* limits */ #define NSPEEDS 29 #define TTMASK 15 #define OBUFSIZ 100 #ifdef KERNEL extern const int tthiwat[NSPEEDS], ttlowat[NSPEEDS]; extern int q_to_b(register struct clist *q, char *cp, int cc); #define TTHIWAT(tp) tthiwat[(tp)->t_ospeed&TTMASK] #define TTLOWAT(tp) ttlowat[(tp)->t_ospeed&TTMASK] extern int nldisp; /* number of line disciplines */ /* * Set t_chars to default values. */ void ttychars (struct tty *tp); /* * Clean terminal on last close. */ void ttyclose (struct tty *tp); /* * Wakeup processes waiting on output flow control. */ void ttyowake (struct tty *tp); /* * Get a symbol from a character list. */ int getc (struct clist *p); /* * Get the pointer to the next character in the list. */ char *nextc (struct clist *p, char *cp); /* * Put a symbol to a character list. */ int putc (int c, struct clist *p); /* * Remove the last character in the list and return it. */ int unputc (struct clist *p); /* * Put the chars in the from que on the end of the to que. */ void catq (struct clist *from, struct clist *to); /* * Copy buffer to clist. */ int b_to_q (char *cp, int nbytes, struct clist *q); /* * Common code for tty ioctls. */ int ttioctl (struct tty *tp, u_int com, caddr_t data, int flag); /* * Start output on the typewriter. */ void ttstart (struct tty *tp); void ttwakeup (struct tty *tp); /* * Place a character on raw TTY input queue, */ void ttyinput (int c, struct tty *tp); /* * Put character on TTY output queue. */ int ttyoutput (int c, struct tty *tp); /* * Initial open of tty, or (re)entry to line discipline. */ int ttyopen (dev_t dev, struct tty *tp); /* * Close a line discipline. */ int ttylclose (struct tty *tp, int flag); /* * Check the output queue for space. */ int ttycheckoutq (struct tty *tp, int wait); /* * Called from device's read routine after it has * calculated the tty-structure given as argument. */ struct uio; int ttread (struct tty *tp, struct uio *uio, int flag); int ttwrite (struct tty *tp, struct uio *uio, int flag); /* * Handle modem control transition on a tty. */ int ttymodem (struct tty *tp, int flag); /* * Check that input or output is possible on a terminal. */ int ttyselect (struct tty *tp, int rw); /* * Flush all TTY queues. */ void ttyflush (struct tty *tp, int rw); /* * Wait for output to drain, and flush input. */ void ttywflush (struct tty *tp); #endif /* KERNEL */ /* internal state bits */ #define TS_TIMEOUT 0x000001L /* delay timeout in progress */ #define TS_WOPEN 0x000002L /* waiting for open to complete */ #define TS_ISOPEN 0x000004L /* device is open */ #define TS_FLUSH 0x000008L /* outq has been flushed during DMA */ #define TS_CARR_ON 0x000010L /* software copy of carrier-present */ #define TS_BUSY 0x000020L /* output in progress */ #define TS_ASLEEP 0x000040L /* wakeup when output done */ #define TS_XCLUDE 0x000080L /* exclusive-use flag against open */ #define TS_TTSTOP 0x000100L /* output stopped by ctl-s */ #define TS_HUPCLS 0x000200L /* hang up upon last close */ #define TS_TBLOCK 0x000400L /* tandem queue blocked */ #define TS_RCOLL 0x000800L /* collision in read select */ #define TS_WCOLL 0x001000L /* collision in write select */ #define TS_ASYNC 0x004000L /* tty in async i/o mode */ /* state for intra-line fancy editing work */ #define TS_ERASE 0x040000L /* within a \.../ for PRTRUB */ #define TS_LNCH 0x080000L /* next character is literal */ #define TS_TYPEN 0x100000L /* retyping suspended input (PENDIN) */ #define TS_CNTTB 0x200000L /* counting tab width; leave FLUSHO alone */ #define TS_LOCAL (TS_ERASE|TS_LNCH|TS_TYPEN|TS_CNTTB) /* define partab character types */ #define ORDINARY 0 #define CONTROL 1 #define BACKSPACE 2 #define NEWLINE 3 #define TAB 4 #define VTAB 5 #define RETURN 6 #endif ================================================ FILE: sys/sys/ttychars.h ================================================ /* * Copyright (c) 1982, 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * * @(#)ttychars.h 7.2 (2.11BSD) 1997/4/15 */ /* * User visible structures and constants * related to terminal handling. */ #ifndef _TTYCHARS_ #define _TTYCHARS_ struct ttychars { char tc_erase; /* erase last character */ char tc_kill; /* erase entire line */ char tc_intrc; /* interrupt */ char tc_quitc; /* quit */ char tc_startc; /* start output */ char tc_stopc; /* stop output */ char tc_eofc; /* end-of-file */ char tc_brkc; /* input delimiter (like nl) */ char tc_suspc; /* stop process signal */ char tc_dsuspc; /* delayed stop process signal */ char tc_rprntc; /* reprint line */ char tc_flushc; /* flush output (toggles) */ char tc_werasc; /* word erase */ char tc_lnextc; /* literal next character */ }; #define CTRL(c) (c & 037) #define _POSIX_VDISABLE ((unsigned char)'\377') #define CCEQ(val,c) (c == val ? val != _POSIX_VDISABLE : 0) /* default special characters */ #define CERASE 0177 #define CKILL CTRL('u') #define CINTR CTRL('c') #define CQUIT CTRL('\\') #define CSTART CTRL('q') #define CSTOP CTRL('s') #define CEOF CTRL('d') #define CEOT CEOF #define CBRK _POSIX_VDISABLE #define CSUSP CTRL('z') #define CDSUSP CTRL('y') #define CRPRNT CTRL('r') #define CFLUSH CTRL('o') #define CWERASE CTRL('w') #define CLNEXT CTRL('v') #endif /* _TTYCHARS_ */ ================================================ FILE: sys/sys/ttydev.h ================================================ /* * Copyright (c) 1982, 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * * @(#)ttydev.h 7.1 (Berkeley) 6/4/86 */ /* * Terminal definitions related to underlying hardware. */ #ifndef _TTYDEV_ #define _TTYDEV_ /* * Speeds */ #define B0 0 #define B50 1 #define B75 2 #define B150 3 #define B200 4 #define B300 5 #define B600 6 #define B1200 7 #define B1800 8 #define B2400 9 #define B4800 10 #define B9600 11 #define B19200 12 #define B38400 13 #define B57600 14 #define B115200 15 #define B230400 16 #define B460800 17 #define B500000 18 #define B576000 19 #define B921600 20 #define B1000000 21 #define B1152000 22 #define B1500000 23 #define B2000000 24 #define B2500000 25 #define B3000000 26 #define B3500000 27 #define B4000000 28 #ifdef KERNEL /* * Modem control commands. */ #define DMSET 0 #define DMBIS 1 #define DMBIC 2 #define DMGET 3 #endif #endif ================================================ FILE: sys/sys/types.h ================================================ /* * Copyright (c) 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #ifndef _SYS_TYPES_H_ #define _SYS_TYPES_H_ #include /* * Basic system types and major/minor device constructing/busting macros. */ /* major part of a device */ #define major(x) ((int)(((int)(x)>>8)&0377)) /* minor part of a device */ #define minor(x) ((int)((x)&0377)) /* make a device number */ #define makedev(x,y) ((dev_t)(((x)<<8) | (y))) typedef unsigned char u_char; typedef unsigned short u_short; typedef unsigned int u_int; typedef unsigned long u_long; /* see this! unsigned longs at last! */ typedef unsigned short ushort; /* sys III compat */ #ifdef pdp11 typedef struct label_t { int val[7]; /* regs 2-7 and super SP */ } label_t; #endif typedef long daddr_t; typedef char * caddr_t; typedef u_int ino_t; #ifndef _SIZE_T #define _SIZE_T typedef u_int size_t; #endif #ifndef __ssize_t_defined #ifndef _SSIZE_T typedef int ssize_t; #define __ssize_t_defined #define _SSIZE_T #endif #endif #ifndef _TIME_T #define _TIME_T typedef long time_t; #endif typedef int dev_t; #ifndef _OFF_T #define _OFF_T typedef long off_t; #endif typedef u_int uid_t; typedef u_int gid_t; typedef int pid_t; typedef u_int mode_t; typedef int bool_t; /* boolean */ #define _PID_T #define _UID_T #define _GID_T #define _INO_T #define _DEV_T #define _TIME_T #define _MODE_T #define NBBY 8 /* number of bits in a byte */ #ifndef howmany #define howmany(x, y) (((x)+((y)-1))/(y)) #endif #include #ifdef KERNEL /* * Save the process' current register context. */ int setjmp (label_t *env); /* * Map in a user structure and jump to a saved context. */ void longjmp (size_t unew, label_t *env); #endif /* KERNEL */ #endif ================================================ FILE: sys/sys/uio.h ================================================ /* * Copyright (c) 1982, 1986, 1993, 1994 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * Copied from 4.4-Lite and modified for 2.11BSD. Modifications were removal * of prototypes, limits for dynamic allocation of iovec structs and changing * uio_resid to u_int from int. */ #ifndef _SYS_UIO_H_ #define _SYS_UIO_H_ #include "types.h" /* * XXX * iov_base should be a void *. */ struct iovec { char *iov_base; /* Base address. */ size_t iov_len; /* Length. */ }; enum uio_rw { UIO_READ, UIO_WRITE }; struct uio { struct iovec *uio_iov; int uio_iovcnt; off_t uio_offset; u_int uio_resid; enum uio_rw uio_rw; }; #ifdef KERNEL /* * Move data to/from user space. */ int uiomove (caddr_t cp, u_int n, struct uio *uio); /* * Give next character to user as result of read. */ int ureadc (int c, struct uio *uio); #else /* !KERNEL */ ssize_t readv (int fd, const struct iovec *iov, int iovcnt); ssize_t writev (int fd, const struct iovec *iov, int iovcnt); #endif /* KERNEL */ #endif /* !_SYS_UIO_H_ */ ================================================ FILE: sys/sys/user.h ================================================ /* * Copyright (c) 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #ifdef KERNEL #include "dir.h" #include "exec.h" #include "time.h" #include "resource.h" #else #include #include #include #include #endif /* * data that doesn't need to be referenced while the process is swapped. * For PIC32, the user block is USIZE bytes long; resides at virtual kernel loc * 0x80007400; contains the system stack (and possibly network stack) per * user; is cross referenced with the proc structure for the same process. */ #define MAXCOMLEN MAXNAMLEN /* <= MAXNAMLEN, >= sizeof(ac_comm) */ struct user { struct proc *u_procp; /* pointer to proc structure */ struct trapframe *u_frame; /* address of users saved frame */ char u_comm[MAXCOMLEN + 1]; /* command file name */ label_t u_qsave; /* for non-local gotos on interrupts */ label_t u_rsave; /* save info when exchanging stacks */ label_t u_ssave; /* label variable for swapping */ /* syscall parameters and results */ int u_arg[6]; /* arguments to current system call */ int u_rval; /* return value */ int u_error; /* return error code */ /* 1.1 - processes and protection */ uid_t u_uid; /* effective user id */ uid_t u_svuid; /* saved user id */ uid_t u_ruid; /* real user id */ gid_t u_svgid; /* saved group id */ gid_t u_rgid; /* real group id */ gid_t u_groups[NGROUPS]; /* groups, 0 terminated */ /* 1.2 - memory management */ size_t u_tsize; /* text size (clicks) */ size_t u_dsize; /* data size (clicks) */ size_t u_ssize; /* stack size (clicks) */ /* 1.3 - signal management */ sig_t u_signal[NSIG]; /* disposition of signals */ long u_sigmask[NSIG]; /* signals to be blocked */ long u_sigonstack; /* signals to take on sigstack */ long u_sigintr; /* signals that interrupt syscalls */ long u_oldmask; /* saved mask from before sigpause */ int u_code; /* ``code'' to trap */ int u_psflags; /* Process Signal flags */ struct sigaltstack u_sigstk; /* signal stack info */ u_int u_sigtramp; /* pointer to trampoline code in user space */ /* 1.4 - descriptor management */ struct file *u_ofile[NOFILE]; /* file structures for open files */ char u_pofile[NOFILE]; /* per-process flags of open files */ int u_lastfile; /* high-water mark of u_ofile */ #define UF_EXCLOSE 0x1 /* auto-close on exec */ #define UF_MAPPED 0x2 /* mapped from device */ struct inode *u_cdir; /* current directory */ struct inode *u_rdir; /* root directory of current process */ struct tty *u_ttyp; /* controlling tty pointer */ dev_t u_ttyd; /* controlling tty dev */ int u_cmask; /* mask for file creation */ /* 1.5 - timing and statistics */ struct k_rusage u_ru; /* stats for this proc */ struct k_rusage u_cru; /* sum of stats for reaped children */ struct k_itimerval u_timer[2]; /* profile/virtual timers */ long u_start; int u_dupfd; /* XXX - see kern_descrip.c/fdopen */ struct uprof { /* profile arguments */ unsigned *pr_base; /* buffer base */ unsigned pr_size; /* buffer size */ unsigned pr_off; /* pc offset */ unsigned pr_scale; /* pc scaling */ } u_prof; /* 1.6 - resource controls */ struct rlimit u_rlimit[RLIM_NLIMITS]; /* namei & co. */ struct nameicache { /* last successful directory search */ off_t nc_prevoffset; /* offset at which last entry found */ ino_t nc_inumber; /* inum of cached directory */ dev_t nc_dev; /* dev of cached directory */ } u_ncache; int u_stack[1]; /* kernel stack per user * extends from u + USIZE * backward not to reach here */ }; #include #ifdef KERNEL extern struct user u, u0; /* * Increment user profiling counters. */ void addupc (caddr_t pc, struct uprof *pbuf, int ticks); #endif ================================================ FILE: sys/sys/utsname.h ================================================ /*- * Copyright (c) 1994 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Chuck Karish of Mindcraft, Inc. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #ifndef _SYS_UTSNAME_H #define _SYS_UTSNAME_H #define SYS_NMLN 256 struct utsname { char sysname[SYS_NMLN]; /* Name of this OS. */ char nodename[SYS_NMLN]; /* Name of this network node. */ char release[SYS_NMLN]; /* Release level. */ char version[SYS_NMLN]; /* Version level. */ char machine[SYS_NMLN]; /* Hardware type. */ }; int uname(struct utsname *name); #endif /* !_SYS_UTSNAME_H */ ================================================ FILE: sys/sys/vm.h ================================================ /* * Copyright (c) 1982, 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #ifdef KERNEL #include "vmparam.h" #include "vmmac.h" #include "vmmeter.h" #include "vmsystm.h" #else #include #include #include #include #endif ================================================ FILE: sys/sys/vmmac.h ================================================ /* * Copyright (c) 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * * @(#)vmmac.h 1.1 (2.10 Berkeley) 12/1/86 */ /* Average new into old with aging factor time */ #define ave(smooth, cnt, time) \ smooth = ((time - 1) * (smooth) + (cnt)) / (time) ================================================ FILE: sys/sys/vmmeter.h ================================================ /* * Copyright (c) 1982, 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ /* * Virtual memory related instrumentation */ struct vmrate { #define v_first v_swtch u_short v_swtch; /* context switches */ u_short v_trap; /* calls to trap */ u_short v_syscall; /* calls to syscall() */ u_short v_intr; /* device interrupts */ u_short v_soft; /* software interrupts */ u_short v_fpsim; /* floating point simulator faults */ u_short v_kbin; /* kbytes swapped in */ u_short v_kbout; /* kbytes swapped out */ u_short v_swpin; /* swapins */ u_short v_swpout; /* swapouts */ #define v_last v_swpout }; struct vmsum { long v_swtch; /* context switches */ long v_trap; /* calls to trap */ long v_syscall; /* calls to syscall() */ long v_intr; /* device interrupts */ long v_soft; /* software interrupts */ long v_fpsim; /* floating point simulator faults */ long v_kbin; /* kbytes swapped in */ long v_kbout; /* kbytes swapped out */ long v_swpin; /* swapins */ long v_swpout; /* swapouts */ }; #if defined(KERNEL) && defined(UCB_METER) struct vmrate cnt, rate; struct vmsum sum; #endif /* systemwide totals computed every five seconds */ struct vmtotal { short t_rq; /* length of the run queue */ short t_dw; /* jobs in ``disk wait'' (neg priority) */ short t_sl; /* jobs sleeping in core */ short t_sw; /* swapped out runnable/short block jobs */ long t_vm; /* total virtual memory, clicks */ long t_avm; /* active virtual memory, clicks */ size_t t_rm; /* total real memory, clicks */ size_t t_arm; /* active real memory, clicks */ long t_vmtxt; /* virtual memory used by text, clicks */ long t_avmtxt; /* active virtual memory used by text, clicks */ size_t t_rmtxt; /* real memory used by text, clicks */ size_t t_armtxt; /* active real memory used by text, clicks */ size_t t_free; /* free memory, kb */ }; #ifdef KERNEL struct vmtotal total; /* * Count up various things once a second */ void vmmeter (void); void vmtotal (void); #endif ================================================ FILE: sys/sys/vmparam.h ================================================ /* * Copyright (c) 1982, 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ /* * CTL_VM identifiers */ #define VM_METER 1 /* struct vmmeter */ #define VM_LOADAVG 2 /* struct loadavg */ #define VM_SWAPMAP 3 /* struct mapent _swapmap[] */ #define VM_MAXID 5 /* number of valid vm ids */ #ifndef KERNEL #define CTL_VM_NAMES { \ { 0, 0 }, \ { "vmmeter", CTLTYPE_STRUCT }, \ { "loadavg", CTLTYPE_STRUCT }, \ { "swapmap", CTLTYPE_STRUCT }, \ } #endif ================================================ FILE: sys/sys/vmsystm.h ================================================ /* * Miscellaneous virtual memory subsystem variables and structures. * * Copyright (c) 1982, 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * * @(#)vmsystm.h 7.2.1 (2.11BSD GTE) 1/15/95 */ /* * Fork/vfork accounting. */ struct forkstat { long cntfork; long cntvfork; long sizfork; long sizvfork; }; #if defined(KERNEL) && defined(UCB_METER) size_t freemem; /* remaining clicks of free memory */ u_short avefree; /* moving average of remaining free clicks */ u_short avefree30; /* 30 sec (avefree is 5 sec) moving average */ /* * writable copies of tunables */ int maxslp; /* max sleep time before very swappable */ struct forkstat forkstat; #endif ================================================ FILE: sys/sys/wait.h ================================================ /* * Copyright (c) 1982, 1986 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * * @(#)wait.h 7.2.1 (2.11BSD GTE) 1995/06/23 */ /* * This file holds definitions relevent to the wait system call. * Some of the options here are available only through the ``wait3'' * entry point; the old entry point with one argument has more fixed * semantics, never returning status of unstopped children, hanging until * a process terminates if any are outstanding, and never returns * detailed information about process resource utilization (). */ /* * Structure of the information in the first word returned by both * wait and wait3. If w_stopval==WSTOPPED, then the second structure * describes the information returned, else the first. See WUNTRACED below. */ union wait { int w_status; /* used in syscall */ /* * Terminated process status. */ struct { unsigned w_Termsig :7; /* termination signal */ unsigned w_Coredump :1; /* core dump indicator */ unsigned w_Retcode :8; /* exit code if w_termsig==0 */ } w_T; /* * Stopped process status. Returned * only for traced children unless requested * with the WUNTRACED option bit. */ struct { unsigned w_Stopval :8; /* == W_STOPPED if stopped */ unsigned w_Stopsig :8; /* signal that stopped us */ } w_S; }; #define w_termsig w_T.w_Termsig #define w_coredump w_T.w_Coredump #define w_retcode w_T.w_Retcode #define w_stopval w_S.w_Stopval #define w_stopsig w_S.w_Stopsig #define WSTOPPED 0177 /* value of s.stopval if process is stopped */ /* * Option bits for the second argument of wait3. WNOHANG causes the * wait to not hang if there are no stopped or terminated processes, rather * returning an error indication in this case (pid==0). WUNTRACED * indicates that the caller should receive status about untraced children * which stop due to signals. If children are stopped and a wait without * this option is done, it is as though they were still running... nothing * about them is returned. */ #define WNOHANG 1 /* dont hang in wait */ #define WUNTRACED 2 /* tell about stopped, untraced children */ #define WIFSTOPPED(x) (((union wait*)&(x))->w_stopval == WSTOPPED) #define WIFSIGNALED(x) (((union wait*)&(x))->w_stopval != WSTOPPED &&\ (((union wait*)&(x))->w_termsig != 0)) #define WIFEXITED(x) (((union wait*)&(x))->w_stopval != WSTOPPED &&\ (((union wait*)&(x))->w_termsig == 0)) #define WEXITSTATUS(x) (((union wait*)&(x))->w_retcode) #define WTERMSIG(x) (((union wait*)&(x))->w_termsig) #define WCOREDUMP(x) (((union wait*)&(x))->w_coredump) #define WSTOPSIG(x) (((union wait*)&(x))->w_stopsig) #define W_STOPCODE(sig) ((sig << 8) | WSTOPPED) #define W_EXITCODE(ret,sig) ((ret << 8) | (sig)) #define WAIT_ANY (-1) #define WAIT_MYPGRP 0 #ifndef KERNEL #include #include int wait (int *istat); int wait3 (int *istat, int options, struct rusage *rup); int waitpid (int pid, int *istat, int options); int wait4 (int pid, int *istat, int options, struct rusage *rup); #endif ================================================ FILE: tools/Makefile ================================================ SUBDIR!=if [ x"${MACHINE}" = x"pic32" ] ; then \ echo "binstall aoututils elf2aout fsutil config icache mkrd virtualmips" ; \ else \ echo "binstall aoututils elf2aout fsutil config" ; \ fi all install depend: ${SUBDIR} -for i in ${SUBDIR}; do ${MAKE} -C $$i ${MFLAGS} $@; done clean: rm -f *~ bin/* for i in ${SUBDIR}; do ${MAKE} -C $$i ${MFLAGS} clean; done ================================================ FILE: tools/Makefile.inc ================================================ # Common defines and tools to support cross-hosting platforms. _HOST_OSNAME!= uname -s TOOLDIR?= ${TOPSRC}/tools TOOLBINDIR?= ${TOOLDIR}/bin HOST_CC?= cc CC= ${HOST_CC} # libbsd-dev package on Linux in overlay mode. _LIBBSD_CFLAGS!=if [ x"${_HOST_OSNAME}" = x"Linux" ] ; then \ pkg-config libbsd-overlay --cflags ; \ else \ echo "" ; \ fi _LIBBSD_LIBS!= if [ x"${_HOST_OSNAME}" = x"Linux" ] ; then \ pkg-config libbsd-overlay --libs ; \ else \ echo "" ; \ fi INSTALL= ${TOOLBINDIR}/binstall -U YACC!= if [ x"${_HOST_OSNAME}" = x"Linux" ] ; then \ echo "byacc" ; \ else \ echo "yacc" ; \ fi YFLAGS= -d #MANROFF= nroff -man -h -Tascii MANROFF= mandoc -Tascii ================================================ FILE: tools/aoututils/Makefile ================================================ # # aoututils - utilities for building and maintaining a.out executables # # Must be kept in sync with utilities in usr.bin # SUBDIR= aout ar as ld nm ranlib size strip all install clean: for i in ${SUBDIR}; do ${MAKE} -C $$i ${MFLAGS} $@; done ================================================ FILE: tools/aoututils/Makefile.inc ================================================ TOPSRC!=cd ../../..; pwd -include ${TOPSRC}/tools/Makefile.inc CFLAGS= -Os -Wall -std=gnu89 -fno-builtin -DCROSS \ -I. -I../include \ -idirafter ${TOPSRC}/include \ -idirafter ../ar # libbsd-dev package on Linux in overlay mode. CFLAGS+=${_LIBBSD_CFLAGS} LIBS+= ${_LIBBSD_LIBS} all: ${PROG} ${PROG}: ${OBJS} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ ${OBJS} ${LIBS} install: all ${INSTALL} ${PROG} ${TOOLBINDIR}/${PROG} clean: rm -f *.o ${PROG} *~ .PHONY: all install clean ================================================ FILE: tools/aoututils/include/a.out.h ================================================ /*- * Copyright (c) 1991 The Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #ifndef _AOUT_H_ #define _AOUT_H_ #include #define _AOUT_INCLUDE_ #include /* Relocations */ struct reloc { unsigned flags; #define RSMASK 0x70 /* bitmask for segments */ #define RABS 0 #define RTEXT 0x20 #define RDATA 0x30 #define RBSS 0x40 #define RSTRNG 0x60 /* for assembler */ #define REXT 0x70 /* externals and bitmask */ #define RGPREL 0x08 /* gp relative */ #define RFMASK 0x07 /* bitmask for format */ #define RBYTE16 0x00 /* low part of byte address: bits 15:0 */ #define RBYTE32 0x01 /* 32-bit byte address */ #define RHIGH16 0x02 /* upper part of byte address: bits 31:16 */ #define RHIGH16S 0x03 /* upper part of address with signed offset */ #define RWORD16 0x04 /* word address: bits 17:2 */ #define RWORD26 0x05 /* word address: bits 27:2 */ unsigned index; /* 24-bit index in symbol table, * for REXT */ unsigned offset; /* 16-bit offset, * for RIGH16 and RIGH16S */ }; #endif /* !_AOUT_H_ */ ================================================ FILE: tools/aoututils/include/ar.h ================================================ /*- * Copyright (c) 1991 The Regents of the University of California. * All rights reserved. * * This code is derived from software contributed to Berkeley by * Hugh Smith at The University of Guelph. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #ifndef _AR_H_ #define _AR_H_ #define ARMAG "!\n" /* ar "magic number" */ #define SARMAG 8 /* strlen(ARMAG); */ #define AR_EFMT1 "#1/" /* extended format #1 */ struct ar_hdr { char ar_name[16]; /* name */ char ar_date[12]; /* modification time */ char ar_uid[6]; /* user id */ char ar_gid[6]; /* group id */ char ar_mode[8]; /* octal file permissions */ char ar_size[10]; /* size in bytes */ #define ARFMAG "`\n" char ar_fmag[2]; /* consistency check */ }; #define ARHDRSZ 60 #endif /* !_AR_H_ */ ================================================ FILE: tools/aoututils/include/nlist.h ================================================ /*- * Copyright (c) 1991 The Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #ifndef _NLIST_H_ #define _NLIST_H_ #include /* * Symbol table entry format. */ struct nlist { char *n_name; /* In memory address of symbol name, * or string table offset (file) */ u_short n_len; /* Length of name in bytes */ u_short n_type; /* Type of symbol - see below */ u_int n_value; /* Symbol value */ }; /* * Simple values for n_type. */ #define N_UNDF 0x00 /* undefined */ #define N_ABS 0x01 /* absolute */ #define N_TEXT 0x02 /* text segment */ #define N_DATA 0x03 /* data segment */ #define N_BSS 0x04 /* bss segment */ #define N_STRNG 0x05 /* string segment (for assembler) */ #define N_COMM 0x06 /* .comm segment (for assembler) */ #define N_FN 0x1f /* file name */ #define N_TYPE 0x1f /* mask for all the type bits */ #define N_EXT 0x20 /* external (global) bit, OR'ed in */ #define N_WEAK 0x40 /* weak reference bit, OR'ed in */ #define N_LOC 0x80 /* local, for assembler */ /* * Get symbols from a file. */ int nlist (char *name, struct nlist *list); /* * Get kernel symbols. */ int knlist (struct nlist *list); #endif /* !_NLIST_H_ */ ================================================ FILE: tools/aoututils/include/ranlib.h ================================================ /*- * Copyright (c) 1990 The Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #ifndef _RANLIB_H_ #define _RANLIB_H_ #define RANLIBMAG "__.SYMDEF" /* archive file name */ #define RANLIBSKEW 3 /* creation time offset */ struct ranlib { int ran_len; /* 1 byte - name length in bytes */ unsigned ran_off; /* 4 bytes - file offset */ char *ran_name; /* in memory symbol name */ }; #endif /* !_RANLIB_H_ */ ================================================ FILE: tools/binstall/.gitignore ================================================ xinstall ================================================ FILE: tools/binstall/Makefile ================================================ TOPSRC!=cd ../..; pwd -include ../Makefile.inc PROG= xinstall OBJS= xinstall.o # Use uninstalled copy of the install program. INSTALL=./xinstall # libbsd-dev package on Linux in overlay mode. CFLAGS+=${_LIBBSD_CFLAGS} LIBS+= ${_LIBBSD_LIBS} all: ${PROG} ${PROG}: ${OBJS} ${CC} ${LDFLAGS} -o $@ ${OBJS} ${LIBS} install: all ${INSTALL} ${PROG} ${TOOLBINDIR}/binstall clean: rm -f *~ *.o ${PROG} .PHONY: all install clean ================================================ FILE: tools/binstall/install.1 ================================================ .\" $OpenBSD: install.1,v 1.31 2019/02/08 12:53:44 schwarze Exp $ .\" $NetBSD: install.1,v 1.4 1994/11/14 04:57:17 jtc Exp $ .\" .\" Copyright (c) 1987, 1990, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)install.1 8.1 (Berkeley) 6/6/93 .\" .Dd $Mdocdate: February 10 2024 $ .Dt INSTALL 1 .Os .Sh NAME .Nm install .Nd install binaries .Sh SYNOPSIS .Nm install .Op Fl bCcDdFpSsU .Op Fl B Ar suffix .Op Fl f Ar flags .Op Fl g Ar group .Op Fl m Ar mode .Op Fl o Ar owner .Ar source ... target ... .Sh DESCRIPTION The .Ar source file(s) are copied to the .Ar target file or directory. If the .Ar target file already exists, it is either renamed to .Ar file.old if the .Fl b option is given or overwritten if permissions allow. An alternate backup suffix may be specified via the .Fl B option's argument. If the .Fl d option is given, .Ar target directories are created, and no files are copied. .Pp The options are as follows: .Bl -tag -width "-B suffix" .It Fl B Ar suffix Use .Ar suffix as the backup suffix if .Fl b is given. .It Fl b Backup any existing files before overwriting them by renaming them to .Ar file.old . See .Fl B for specifying a different backup suffix. .It Fl C Copy the file. If the target file already exists and the files are the same, then don't change the modification time of the target. .It Fl c Copy the file. This is actually the default. The .Fl c option is only included for backwards compatibility. .It Fl D Create all leading components of the target before installing into it. .It Fl d Create directories. Missing parent directories are created as required. This option cannot be used with the .Fl B , b , C , c , .Fl f , p , or .Fl s options. .It Fl F Flush the file's contents to disk. When copying a file, use the .Xr fsync 2 function to synchronize the installed file's contents with the on-disk version. .It Fl f Ar flags Specify the target's file .Ar flags . (See .Xr chflags 1 for a list of possible flags and their meanings.) .It Fl g Ar group Specify a .Ar group . A numeric GID is allowed. .It Fl m Ar mode Specify an alternate .Ar mode . The default mode is set to rwxr-xr-x (0755). The specified mode may be either an octal or symbolic value; see .Xr chmod 1 for a description of possible mode values. .It Fl o Ar owner Specify an .Ar owner . A numeric UID is allowed. .It Fl p Preserve the modification time. Copy the file, as if the .Fl C (compare and copy) option is specified, except if the target file doesn't already exist or is different, then preserve the modification time of the file. .It Fl S Safe copy. This option has no effect and is supported only for compatibility. When installing a file, a temporary file is created and written first in the destination directory, then atomically renamed. This avoids both race conditions and the destruction of existing files in case of write failures. .It Fl s .Nm exec's the command .Pa /usr/bin/strip to strip binaries so that install can be portable over a large number of systems and binary types. If the environment variable .Ev STRIP is set, it is used instead. .It Fl U Unprivileged mode. Do not attempt to modify the default .Ar owner , .Ar group , and file .Ar flags of the target. .El .Pp By default, .Nm preserves all file flags, with the exception of the .Dq nodump flag. .Pp The .Nm utility attempts to prevent moving a file onto itself. .Pp Installing .Pa /dev/null creates an empty file. .Sh ENVIRONMENT .Bl -tag -width "STRIP" .It Ev STRIP For an alternate .Xr strip 1 program to run. Default is .Pa /usr/bin/strip . .El .Sh FILES .Bl -tag -width INS@XXXXXXXXXX -compact .It Pa INS@XXXXXXXXXX Temporary files created in the target directory by .Xr mkstemp 3 . .El .Sh EXIT STATUS .Ex -std install .Sh SEE ALSO .Xr chflags 1 , .Xr chgrp 1 , .Xr chmod 1 , .Xr cp 1 , .Xr mv 1 , .Xr strip 1 , .Xr chown 8 .Sh HISTORY The .Nm utility appeared in .Bx 4.2 . .Sh CAVEATS The .Fl C , .Fl D , .Fl F , .Fl p , .Fl S , and .Fl U flags are non-standard and should not be relied upon for portability. .Pp Temporary files may be left in the target directory if .Nm exits abnormally. ================================================ FILE: tools/binstall/pathnames.h ================================================ /* $OpenBSD: pathnames.h,v 1.3 2003/06/03 02:56:24 millert Exp $ */ /* $NetBSD: pathnames.h,v 1.3 1994/11/14 04:57:18 jtc Exp $ */ /* * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)pathnames.h 8.1 (Berkeley) 6/6/93 * $NetBSD: pathnames.h,v 1.3 1994/11/14 04:57:18 jtc Exp $ */ #define _PATH_STRIP "/usr/bin/strip" ================================================ FILE: tools/binstall/xinstall.c ================================================ /* $OpenBSD: xinstall.c,v 1.77 2022/12/04 23:50:50 cheloha Exp $ */ /* $NetBSD: xinstall.c,v 1.9 1995/12/20 10:25:17 jonathan Exp $ */ /* * Copyright (c) 1987, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "pathnames.h" #define HAVE_CHFLAGS 1 #define HAVE_ISSETUGID 1 #ifdef __linux__ #undef HAVE_CHFLAGS #undef HAVE_ISSETUGID #endif #ifndef UID_MAX #define UID_MAX UINT_MAX #endif #ifndef GID_MAX #define GID_MAX UINT_MAX #endif #define _MAXBSIZE (64 * 1024) #define MINIMUM(a, b) (((a) < (b)) ? (a) : (b)) #define DIRECTORY 0x01 /* Tell install it's a directory. */ #define SETFLAGS 0x02 /* Tell install to set flags. */ #define USEFSYNC 0x04 /* Tell install to use fsync(2). */ #define BACKUP_SUFFIX ".old" int dobackup, docompare, dodest, dodir, dopreserve, dostrip, dounpriv; int mode = S_IRWXU|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH; char pathbuf[PATH_MAX], tempfile[PATH_MAX]; char *suffix = BACKUP_SUFFIX; uid_t uid = (uid_t)-1; gid_t gid = (gid_t)-1; void copy(int, char *, int, char *, off_t, int); int compare(int, const char *, off_t, int, const char *, off_t); void install(char *, char *, u_long, u_int); void install_dir(char *, int); void strip(char *); void usage(void); int create_tempfile(char *, char *, size_t); int file_write(int, char *, size_t, int *, int *, int); void file_flush(int, int); int main(int argc, char *argv[]) { struct stat from_sb, to_sb; void *set; #ifdef __FreeBSD__ u_long fset = 0; #else u_int32_t fset = 0; #endif u_int iflags; int ch, no_target; char *flags, *to_name, *group = NULL, *owner = NULL; const char *errstr; iflags = 0; while ((ch = getopt(argc, argv, "B:bCcDdFf:g:m:o:pSsU")) != -1) switch(ch) { case 'C': docompare = 1; break; case 'B': suffix = optarg; /* fall through; -B implies -b */ case 'b': dobackup = 1; break; case 'c': /* For backwards compatibility. */ break; case 'F': iflags |= USEFSYNC; break; case 'f': flags = optarg; #if HAVE_CHFLAGS if (strtofflags(&flags, &fset, NULL)) errx(1, "%s: invalid flag", flags); iflags |= SETFLAGS; #endif break; case 'g': group = optarg; break; case 'm': if (!(set = setmode(optarg))) errx(1, "%s: invalid file mode", optarg); mode = getmode(set, 0); free(set); break; case 'o': owner = optarg; break; case 'p': docompare = dopreserve = 1; break; case 'S': /* For backwards compatibility. */ break; case 's': dostrip = 1; break; case 'D': dodest = 1; break; case 'd': dodir = 1; break; case 'U': dounpriv = 1; break; default: usage(); } argc -= optind; argv += optind; /* some options make no sense when creating directories */ if ((docompare || dostrip) && dodir) usage(); /* must have at least two arguments, except when creating directories */ if (argc == 0 || (argc == 1 && !dodir)) usage(); /* get group and owner id's */ if (group != NULL && !dounpriv && gid_from_group(group, &gid) == -1) { gid = strtonum(group, 0, GID_MAX, &errstr); if (errstr != NULL) errx(1, "unknown group %s", group); } if (owner != NULL && !dounpriv && uid_from_user(owner, &uid) == -1) { uid = strtonum(owner, 0, UID_MAX, &errstr); if (errstr != NULL) errx(1, "unknown user %s", owner); } if (dodir) { for (; *argv != NULL; ++argv) install_dir(*argv, mode); exit(0); /* NOTREACHED */ } if (dodest) { char *dest = dirname(argv[argc - 1]); if (dest == NULL) errx(1, "cannot determine dirname"); /* * When -D is passed, do not chmod the directory with the mode set for * the target file. If more restrictive permissions are required then * '-d -m' ought to be used instead. */ install_dir(dest, 0755); } no_target = stat(to_name = argv[argc - 1], &to_sb); if (!no_target && S_ISDIR(to_sb.st_mode)) { for (; *argv != to_name; ++argv) install(*argv, to_name, fset, iflags | DIRECTORY); exit(0); /* NOTREACHED */ } /* can't do file1 file2 directory/file */ if (argc != 2) errx(1, "Target: %s", argv[argc-1]); if (!no_target) { if (stat(*argv, &from_sb)) err(1, "%s", *argv); if (!S_ISREG(to_sb.st_mode)) errx(1, "%s: not a regular file", to_name); if (to_sb.st_dev == from_sb.st_dev && to_sb.st_ino == from_sb.st_ino) errx(1, "%s and %s are the same file", *argv, to_name); } install(*argv, to_name, fset, iflags); exit(0); /* NOTREACHED */ } /* * install -- * build a path name and install the file */ void install(char *from_name, char *to_name, u_long fset, u_int flags) { struct stat from_sb, to_sb; struct timespec ts[2]; int devnull, from_fd, to_fd, serrno, tmpmode, files_match = 0; char *p; char *target_name = tempfile; (void)memset((void *)&from_sb, 0, sizeof(from_sb)); (void)memset((void *)&to_sb, 0, sizeof(to_sb)); /* If try to install NULL file to a directory, fails. */ if (flags & DIRECTORY || strcmp(from_name, _PATH_DEVNULL)) { if (stat(from_name, &from_sb)) err(1, "%s", from_name); if (!S_ISREG(from_sb.st_mode)) errx(1, "%s: not a regular file", from_name); /* Build the target path. */ if (flags & DIRECTORY) { (void)snprintf(pathbuf, sizeof(pathbuf), "%s/%s", to_name, (p = strrchr(from_name, '/')) ? ++p : from_name); to_name = pathbuf; } devnull = 0; } else { devnull = 1; } if (stat(to_name, &to_sb) == 0) { /* Only compare against regular files. */ if (docompare && !S_ISREG(to_sb.st_mode)) { docompare = 0; warnx("%s: not a regular file", to_name); } } else if (docompare) { /* File does not exist so silently ignore compare flag. */ docompare = 0; } if (!devnull) { if ((from_fd = open(from_name, O_RDONLY)) == -1) err(1, "%s", from_name); } to_fd = create_tempfile(to_name, tempfile, sizeof(tempfile)); if (to_fd < 0) err(1, "%s", tempfile); if (!devnull) copy(from_fd, from_name, to_fd, tempfile, from_sb.st_size, ((off_t)from_sb.st_blocks * S_BLKSIZE < from_sb.st_size)); if (dostrip) { strip(tempfile); /* * Re-open our fd on the target, in case we used a strip * that does not work in-place -- like gnu binutils strip. */ close(to_fd); if ((to_fd = open(tempfile, O_RDONLY)) == -1) err(1, "stripping %s", to_name); } /* * Compare the (possibly stripped) temp file to the target. */ if (docompare) { int temp_fd = to_fd; struct stat temp_sb; /* Re-open to_fd using the real target name. */ if ((to_fd = open(to_name, O_RDONLY)) == -1) err(1, "%s", to_name); if (fstat(temp_fd, &temp_sb)) { serrno = errno; (void)unlink(tempfile); errc(1, serrno, "%s", tempfile); } if (compare(temp_fd, tempfile, temp_sb.st_size, to_fd, to_name, to_sb.st_size) == 0) { /* * If target has more than one link we need to * replace it in order to snap the extra links. * Need to preserve target file times, though. */ if (to_sb.st_nlink != 1) { ts[0] = to_sb.st_atim; ts[1] = to_sb.st_mtim; futimens(temp_fd, ts); } else { files_match = 1; (void)unlink(tempfile); target_name = to_name; (void)close(temp_fd); } } if (!files_match) { (void)close(to_fd); to_fd = temp_fd; } } /* * Preserve the timestamp of the source file if necessary. */ if (dopreserve && !dounpriv && !files_match) { ts[0] = from_sb.st_atim; ts[1] = from_sb.st_mtim; futimens(to_fd, ts); } /* * Set owner, group, mode for target; do the chown first, * chown may lose the setuid bits. */ if (!dounpriv && (gid != (gid_t)-1 || uid != (uid_t)-1) && fchown(to_fd, uid, gid)) { serrno = errno; if (target_name == tempfile) (void)unlink(target_name); errx(1, "%s: chown/chgrp: %s", target_name, strerror(serrno)); } /* If unprivileged, still do a chmod of the lower 0777 bits. */ tmpmode = mode; if (dounpriv) tmpmode &= S_IRWXU|S_IRWXG|S_IRWXO; if (fchmod(to_fd, tmpmode)) { serrno = errno; if (target_name == tempfile) (void)unlink(target_name); errx(1, "%s: chmod: %s", target_name, strerror(serrno)); } #if HAVE_CHFLAGS /* * If provided a set of flags, set them, otherwise, preserve the * flags, except for the dump flag. */ if (!dounpriv && fchflags(to_fd, flags & SETFLAGS ? fset : from_sb.st_flags & ~UF_NODUMP)) { if (errno != EOPNOTSUPP || (from_sb.st_flags & ~UF_NODUMP) != 0) warnx("%s: chflags: %s", target_name, strerror(errno)); } #endif if (flags & USEFSYNC) fsync(to_fd); (void)close(to_fd); if (!devnull) (void)close(from_fd); /* * Move the new file into place if the files are different * or were not compared. */ if (!files_match) { #if HAVE_CHFLAGS #define NOCHANGEBITS (UF_IMMUTABLE | UF_APPEND | SF_IMMUTABLE | SF_APPEND) /* Try to turn off the immutable bits. */ if (to_sb.st_flags & (NOCHANGEBITS)) (void)chflags(to_name, to_sb.st_flags & ~(NOCHANGEBITS)); #endif if (dobackup) { char backup[PATH_MAX]; (void)snprintf(backup, PATH_MAX, "%s%s", to_name, suffix); /* It is ok for the target file not to exist. */ if (rename(to_name, backup) == -1 && errno != ENOENT) { serrno = errno; unlink(tempfile); errx(1, "rename: %s to %s: %s", to_name, backup, strerror(serrno)); } } if (rename(tempfile, to_name) == -1 ) { serrno = errno; unlink(tempfile); errx(1, "rename: %s to %s: %s", tempfile, to_name, strerror(serrno)); } } } /* * copy -- * copy from one file to another */ void copy(int from_fd, char *from_name, int to_fd, char *to_name, off_t size, int sparse) { ssize_t nr, nw; int serrno; char *p, buf[_MAXBSIZE]; if (size == 0) return; /* Rewind file descriptors. */ if (lseek(from_fd, (off_t)0, SEEK_SET) == (off_t)-1) err(1, "lseek: %s", from_name); if (lseek(to_fd, (off_t)0, SEEK_SET) == (off_t)-1) err(1, "lseek: %s", to_name); /* * Mmap and write if less than 8M (the limit is so we don't totally * trash memory on big files. This is really a minor hack, but it * wins some CPU back. Sparse files need special treatment. */ if (!sparse && size <= 8 * 1048576) { size_t siz; if ((p = mmap(NULL, (size_t)size, PROT_READ, MAP_PRIVATE, from_fd, (off_t)0)) == MAP_FAILED) { serrno = errno; (void)unlink(to_name); errc(1, serrno, "%s", from_name); } madvise(p, size, MADV_SEQUENTIAL); siz = (size_t)size; if ((nw = write(to_fd, p, siz)) != siz) { serrno = errno; (void)unlink(to_name); errx(1, "%s: %s", to_name, strerror(nw > 0 ? EIO : serrno)); } (void) munmap(p, (size_t)size); } else { int sz, rem, isem = 1; struct stat sb; /* * Pass the blocksize of the file being written to the write * routine. if the size is zero, use the default S_BLKSIZE. */ if (fstat(to_fd, &sb) != 0 || sb.st_blksize == 0) sz = S_BLKSIZE; else sz = sb.st_blksize; rem = sz; while ((nr = read(from_fd, buf, sizeof(buf))) > 0) { if (sparse) nw = file_write(to_fd, buf, nr, &rem, &isem, sz); else nw = write(to_fd, buf, nr); if (nw != nr) { serrno = errno; (void)unlink(to_name); errx(1, "%s: %s", to_name, strerror(nw > 0 ? EIO : serrno)); } } if (sparse) file_flush(to_fd, isem); if (nr != 0) { serrno = errno; (void)unlink(to_name); errc(1, serrno, "%s", from_name); } } } /* * compare -- * compare two files; non-zero means files differ */ int compare(int from_fd, const char *from_name, off_t from_len, int to_fd, const char *to_name, off_t to_len) { caddr_t p1, p2; size_t length; off_t from_off, to_off, remainder; int dfound; if (from_len == 0 && from_len == to_len) return (0); if (from_len != to_len) return (1); /* * Compare the two files being careful not to mmap * more than 8M at a time. */ from_off = to_off = (off_t)0; remainder = from_len; do { length = MINIMUM(remainder, 8 * 1048576); remainder -= length; if ((p1 = mmap(NULL, length, PROT_READ, MAP_PRIVATE, from_fd, from_off)) == MAP_FAILED) err(1, "%s", from_name); if ((p2 = mmap(NULL, length, PROT_READ, MAP_PRIVATE, to_fd, to_off)) == MAP_FAILED) err(1, "%s", to_name); if (length) { madvise(p1, length, MADV_SEQUENTIAL); madvise(p2, length, MADV_SEQUENTIAL); } dfound = memcmp(p1, p2, length); (void) munmap(p1, length); (void) munmap(p2, length); from_off += length; to_off += length; } while (!dfound && remainder > 0); return(dfound); } /* * strip -- * use strip(1) to strip the target file */ void strip(char *to_name) { int serrno, status; char * volatile path_strip; pid_t pid; #if HAVE_ISSETUGID if (issetugid() || (path_strip = getenv("STRIP")) == NULL) #endif path_strip = _PATH_STRIP; switch ((pid = vfork())) { case -1: serrno = errno; (void)unlink(to_name); errc(1, serrno, "forks"); case 0: execl(path_strip, "strip", "--", to_name, (char *)NULL); warn("%s", path_strip); _exit(1); default: while (waitpid(pid, &status, 0) == -1) { if (errno != EINTR) break; } if (!WIFEXITED(status)) (void)unlink(to_name); } } /* * install_dir -- * build directory hierarchy */ void install_dir(char *path, int mode) { char *p; struct stat sb; int ch; for (p = path;; ++p) if (!*p || (p != path && *p == '/')) { ch = *p; *p = '\0'; if (mkdir(path, 0777)) { int mkdir_errno = errno; if (stat(path, &sb)) { /* Not there; use mkdir()s errno */ errc(1, mkdir_errno, "%s", path); /* NOTREACHED */ } if (!S_ISDIR(sb.st_mode)) { /* Is there, but isn't a directory */ errc(1, ENOTDIR, "%s", path); /* NOTREACHED */ } } if (!(*p = ch)) break; } if (!dounpriv && (((gid != (gid_t)-1 || uid != (uid_t)-1) && chown(path, uid, gid)) || chmod(path, mode))) { warn("%s", path); } } /* * usage -- * print a usage message and die */ void usage(void) { (void)fprintf(stderr, "usage: install [-bCcDdFpSsU] [-B suffix] "); (void)fprintf(stderr, "[-f flags] [-g group] [-m mode]\n"); (void)fprintf(stderr, "\t [-o owner] source ... target ...\n"); exit(1); /* NOTREACHED */ } /* * create_tempfile -- * create a temporary file based on path and open it */ int create_tempfile(char *path, char *temp, size_t tsize) { char *p; strlcpy(temp, path, tsize); if ((p = strrchr(temp, '/')) != NULL) p++; else p = temp; *p = '\0'; strlcat(p, "INS@XXXXXXXXXX", tsize); return(mkstemp(temp)); } /* * file_write() * Write/copy a file (during copy or archive extract). This routine knows * how to copy files with lseek holes in it. (Which are read as file * blocks containing all 0's but do not have any file blocks associated * with the data). Typical examples of these are files created by dbm * variants (.pag files). While the file size of these files are huge, the * actual storage is quite small (the files are sparse). The problem is * the holes read as all zeros so are probably stored on the archive that * way (there is no way to determine if the file block is really a hole, * we only know that a file block of all zero's can be a hole). * At this writing, no major archive format knows how to archive files * with holes. However, on extraction (or during copy, -rw) we have to * deal with these files. Without detecting the holes, the files can * consume a lot of file space if just written to disk. This replacement * for write when passed the basic allocation size of a file system block, * uses lseek whenever it detects the input data is all 0 within that * file block. In more detail, the strategy is as follows: * While the input is all zero keep doing an lseek. Keep track of when we * pass over file block boundaries. Only write when we hit a non zero * input. once we have written a file block, we continue to write it to * the end (we stop looking at the input). When we reach the start of the * next file block, start checking for zero blocks again. Working on file * block boundaries significantly reduces the overhead when copying files * that are NOT very sparse. This overhead (when compared to a write) is * almost below the measurement resolution on many systems. Without it, * files with holes cannot be safely copied. It does has a side effect as * it can put holes into files that did not have them before, but that is * not a problem since the file contents are unchanged (in fact it saves * file space). (Except on paging files for diskless clients. But since we * cannot determine one of those file from here, we ignore them). If this * ever ends up on a system where CTG files are supported and the holes * are not desired, just do a conditional test in those routines that * call file_write() and have it call write() instead. BEFORE CLOSING THE * FILE, make sure to call file_flush() when the last write finishes with * an empty block. A lot of file systems will not create an lseek hole at * the end. In this case we drop a single 0 at the end to force the * trailing 0's in the file. * ---Parameters--- * rem: how many bytes left in this file system block * isempt: have we written to the file block yet (is it empty) * sz: basic file block allocation size * cnt: number of bytes on this write * str: buffer to write * Return: * number of bytes written, -1 on write (or lseek) error. */ int file_write(int fd, char *str, size_t cnt, int *rem, int *isempt, int sz) { char *pt; char *end; size_t wcnt; char *st = str; /* * while we have data to process */ while (cnt) { if (!*rem) { /* * We are now at the start of file system block again * (or what we think one is...). start looking for * empty blocks again */ *isempt = 1; *rem = sz; } /* * only examine up to the end of the current file block or * remaining characters to write, whatever is smaller */ wcnt = MINIMUM(cnt, *rem); cnt -= wcnt; *rem -= wcnt; if (*isempt) { /* * have not written to this block yet, so we keep * looking for zero's */ pt = st; end = st + wcnt; /* * look for a zero filled buffer */ while ((pt < end) && (*pt == '\0')) ++pt; if (pt == end) { /* * skip, buf is empty so far */ if (lseek(fd, (off_t)wcnt, SEEK_CUR) == -1) { warn("lseek"); return(-1); } st = pt; continue; } /* * drat, the buf is not zero filled */ *isempt = 0; } /* * have non-zero data in this file system block, have to write */ if (write(fd, st, wcnt) != wcnt) { warn("write"); return(-1); } st += wcnt; } return(st - str); } /* * file_flush() * when the last file block in a file is zero, many file systems will not * let us create a hole at the end. To get the last block with zeros, we * write the last BYTE with a zero (back up one byte and write a zero). */ void file_flush(int fd, int isempt) { static char blnk[] = "\0"; /* * silly test, but make sure we are only called when the last block is * filled with all zeros. */ if (!isempt) return; /* * move back one byte and write a zero */ if (lseek(fd, (off_t)-1, SEEK_CUR) == -1) { warn("Failed seek on file"); return; } if (write(fd, blnk, 1) == -1) warn("Failed write to file"); return; } ================================================ FILE: tools/icache/.gitignore ================================================ ice2aout ================================================ FILE: tools/icache/Makefile ================================================ TOPSRC!=cd ../..; pwd -include ../Makefile.inc CFLAGS = -O -Wall OBJS = ice2aout.o PROG = ice2aout # For Mac OS X #LIBS = -largp all: $(PROG) install: all ${INSTALL} ${PROG} ${TOOLBINDIR}/${PROG} clean: rm -f *~ *.o ${PROG} $(PROG): $(OBJS) $(CC) $(LDFLAGS) -o $@ $(OBJS) $(LIBS) ================================================ FILE: tools/icache/ice2aout.c ================================================ /* Copyright (c) 2013, Alexey Frunze All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. The views and conclusions contained in the software and documentation are those of the authors and should not be interpreted as representing official policies, either expressed or implied, of the FreeBSD Project. */ /*****************************************************************************/ /* */ /* MIPS ELF to RetroBSD a.out convertor with support for MIPS icache */ /* */ /*****************************************************************************/ #include #include #include #include #include #include typedef unsigned char uchar, uint8; typedef signed char schar, int8; typedef unsigned short ushort, uint16; typedef short int16; #if UINT_MAX >= 0xFFFFFFFF typedef unsigned uint32; typedef int int32; #else typedef unsigned long uint32; typedef long int32; #endif typedef unsigned uint; typedef unsigned long ulong; typedef long long longlong; typedef unsigned long long ulonglong; #if ULONG_MAX >= 0xFFFFFFFFFFFFFFFFULL typedef unsigned long uint64; typedef long int64; #else typedef unsigned long long uint64; typedef long long int64; #endif #define C_ASSERT(expr) extern char CAssertExtern[(expr)?1:-1] C_ASSERT(CHAR_BIT == 8); C_ASSERT(sizeof(uint16) == 2); C_ASSERT(sizeof(uint32) == 4); C_ASSERT(sizeof(uint64) == 8); C_ASSERT(sizeof(size_t) >= 4); #pragma pack(push,1) typedef struct { uint8 e_ident[16]; uint16 e_type; uint16 e_machine; uint32 e_version; uint32 e_entry; uint32 e_phoff; uint32 e_shoff; uint32 e_flags; uint16 e_ehsize; uint16 e_phentsize; uint16 e_phnum; uint16 e_shentsize; uint16 e_shnum; uint16 e_shstrndx; } Elf32Hdr; typedef struct { uint32 sh_name; uint32 sh_type; uint32 sh_flags; uint32 sh_addr; uint32 sh_offset; uint32 sh_size; uint32 sh_link; uint32 sh_info; uint32 sh_addralign; uint32 sh_entsize; } Elf32SectHdr; typedef struct { uint32 a_magic; /* magic number */ #define OMAGIC 0407 /* old impure format */ uint32 a_text; /* size of text segment */ uint32 a_data; /* size of initialized data */ uint32 a_bss; /* size of uninitialized data */ uint32 a_reltext; /* size of text relocation info */ uint32 a_reldata; /* size of data relocation info */ uint32 a_syms; /* size of symbol table */ uint32 a_entry; /* entry point */ } AoutHdr; #pragma pack(pop) C_ASSERT(sizeof(Elf32Hdr) == 52); C_ASSERT(sizeof(Elf32SectHdr) == 40); C_ASSERT(sizeof(AoutHdr) == 32); typedef struct { const char* Name; uint32 FileOffs; uint32 Addr; uint32 Size; uint32 Flags; uint32 Flags2; } tSection; tSection* Sections = NULL; uint SectionCnt = 0; char* SectNames = NULL; uint32 EntryPointAddr = 0; FILE* ElfFile = NULL; FILE* AoutFile = NULL; const char* AoutName = NULL; void error(char* format, ...) { va_list vl; va_start(vl, format); if (ElfFile) fclose(ElfFile); if (AoutFile) fclose(AoutFile); if (AoutName != NULL) remove(AoutName); puts(""); vprintf(format, vl); va_end(vl); exit(-1); } int SectAddrCompare(const void* pa, const void* pb) { const tSection *p1 = pa, *p2 = pb; if (p1->Addr < p2->Addr) return -1; else if (p1->Addr > p2->Addr) return +1; return 0; } void WriteZeroes(FILE* f, uint32 size) { static const char zeroes[1024]; while (size) { uint32 sz; if (size > sizeof zeroes) sz = sizeof zeroes; else sz = size; if (fwrite(zeroes, 1, sz, f) != sz) error("Can't write file\n"); size -= sz; } } void CopyFileData(FILE* fto, FILE* ffrom, uint32 size) { char buf[1024]; while (size) { uint32 sz; if (size > sizeof buf) sz = sizeof buf; else sz = size; if (fread(buf, 1, sz, ffrom) != sz) error("Can't read file\n"); if (fwrite(buf, 1, sz, fto) != sz) error("Can't write file\n"); size -= sz; } } int main(int argc, char** argv) { Elf32Hdr elfHdr; Elf32SectHdr sectHdr; uint idx; int unsupported = 0; int verbose = 0; AoutHdr aoutHdr; uint32 addr; uint32 endAddr = 0, codeEndAddr, bssStartAddr; if (argc > 1 && !strcmp(argv[1], "-v")) { verbose = 1; argc--; argv++; } if (argc != 3 || !(ElfFile = fopen(argv[1], "rb")) || !(AoutFile = fopen(AoutName = argv[2], "wb"))) error("Usage:\n ice2aout [-v] \n"); if (fread(&elfHdr, 1, sizeof elfHdr, ElfFile) != sizeof elfHdr) error("Can't read file\n"); if (memcmp(elfHdr.e_ident, "\x7F""ELF", 4)) error("Not an ELF file\n"); if (elfHdr.e_ident[6] != 1) error("Not a v1 ELF file\n"); if (elfHdr.e_ehsize != sizeof elfHdr) error("Unexpected ELF header size\n"); if (elfHdr.e_shentsize != sizeof sectHdr) error("Unexpected ELF section size\n"); if (elfHdr.e_ident[4] != 1) error("Not a 32-bit file\n"); if (elfHdr.e_ident[5] != 1) error("Not a little-endian file\n"); if (elfHdr.e_type != 2) error("Not an executable file\n"); if (elfHdr.e_machine != 8) error("Not a MIPS executable\n"); if (fseek(ElfFile, elfHdr.e_shoff + elfHdr.e_shstrndx * sizeof sectHdr, SEEK_SET)) error("Can't read file\n"); if (fread(§Hdr, 1, sizeof sectHdr, ElfFile) != sizeof sectHdr) error("Can't read file\n"); if ((SectNames = malloc(sectHdr.sh_size)) == NULL) error("Out of memory\n"); if (fseek(ElfFile, sectHdr.sh_offset, SEEK_SET)) error("Can't read file\n"); if (fread(SectNames, 1, sectHdr.sh_size, ElfFile) != sectHdr.sh_size) error("Can't read file\n"); if ((Sections = calloc(1, (elfHdr.e_shnum + 1) * sizeof(tSection))) == NULL) error("Out of memory\n"); for (idx = 0; idx < elfHdr.e_shnum; idx++) { const char* name = ""; if (fseek(ElfFile, elfHdr.e_shoff + idx * sizeof sectHdr, SEEK_SET)) error("Can't read file\n"); if (fread(§Hdr, 1, sizeof sectHdr, ElfFile) != sizeof sectHdr) error("Can't read file\n"); if (sectHdr.sh_type == 0) memset(§Hdr, 0, sizeof sectHdr); if (sectHdr.sh_name) name = SectNames + sectHdr.sh_name; unsupported |= (!strcmp(name, ".dynsym") || !strcmp(name, ".dynstr") || !strcmp(name, ".dynamic") || !strcmp(name, ".hash") || !strcmp(name, ".got") || !strcmp(name, ".plt") || sectHdr.sh_type == 5 || // SHT_HASH sectHdr.sh_type == 6 || // SHT_DYNAMIC sectHdr.sh_type == 11); // SHT_DYNSYM // Keep only allocatable sections of non-zero size if ((sectHdr.sh_flags & 2) && sectHdr.sh_size) // SHF_ALLOC and size > 0 { Sections[SectionCnt].FileOffs = 0; Sections[SectionCnt].Name = name; Sections[SectionCnt].Addr = sectHdr.sh_addr; Sections[SectionCnt].Size = sectHdr.sh_size; Sections[SectionCnt].Flags = (sectHdr.sh_flags & 1) | ((sectHdr.sh_flags & 4) >> 1); // bit0=Writable,bit1=eXecutable if (sectHdr.sh_type == 1) // SHT_PROGBITS { Sections[SectionCnt].FileOffs = sectHdr.sh_offset; } SectionCnt++; } } EntryPointAddr = elfHdr.e_entry; // Sort sections by address as we'll need them in order // and without gaps inbetween qsort(Sections, SectionCnt, sizeof Sections[0], &SectAddrCompare); if (verbose) { printf(" # XAW VirtAddr FileOffs Size Name\n"); for (idx = 0; idx < SectionCnt; idx++) { tSection* p = &Sections[idx]; printf("%2u %c%c%c 0x%08lX 0x%08lX %10lu %s\n", idx, "-X"[(p->Flags / 2) & 1], "-A"[1], "-W"[(p->Flags / 1) & 1], (ulong)p->Addr, (ulong)p->FileOffs, (ulong)p->Size, p->Name); } printf("Entry: 0x%08lX\n", (ulong)EntryPointAddr); puts(""); } if (unsupported) error("Dynamically linked or unsupported type of executable\n"); // Write an empty a.out header at first, it will be updated later memset(&aoutHdr, 0, sizeof aoutHdr); if (fwrite(&aoutHdr, 1, sizeof aoutHdr, AoutFile) != sizeof aoutHdr) error("Can't write file\n"); #define USER_DATA_START 0x7F008000 #define MAXMEM (96*1024) #define USER_DATA_END (USER_DATA_START + MAXMEM) if (verbose) printf("Phase 1: Processing sections in the range 0x%08lX ... 0x%08lX ...\n", (ulong)USER_DATA_START, (ulong)USER_DATA_END - 1); addr = USER_DATA_START; // Copy non-cached sections for (idx = 0; idx < SectionCnt; idx++) { tSection* p = &Sections[idx]; if (p->Addr + p->Size >= p->Addr && p->Addr >= USER_DATA_START && p->Addr + p->Size <= USER_DATA_END) { if (verbose) printf("Copying %s ...\n", p->Name); if (idx && (Sections[idx - 1].Flags2 & 1)) { if (p->Addr < Sections[idx - 1].Addr + Sections[idx - 1].Size) error("Sections must not intersect in memory\n"); if ((p->Flags & 2) && !(Sections[idx - 1].Flags & 2)) // executable after non-executable error("Code sections must precede data sections in memory\n"); } if ((p->Flags & 2) && !p->FileOffs) // executable and initialized to all zeroes error("Code sections must not be initialized to all zeroes\n"); // If this section has code/data in it, if it's not initialized to all zeroes... if (p->FileOffs) { // Fill inter-section gaps (and .bss-like sections that aren't at the end) // with zeroes. This lets me order sections more flexibly and yet make // sure they all are properly initialized. if (addr < p->Addr) { WriteZeroes(AoutFile, p->Addr - addr); addr = p->Addr; } // Copy section if (fseek(ElfFile, p->FileOffs, SEEK_SET)) error("Can't read file\n"); CopyFileData(AoutFile, ElfFile, p->Size); addr += p->Size; } p->Flags2 |= 1; // section has been processed endAddr = p->Addr + p->Size; } else { if (verbose) printf("Skipping %s ...\n", p->Name); } } if (endAddr == 0) error("There are no copiable sections in this range\n"); if (verbose) printf("Phase 2: Processing sections outside the range 0x%08lX ... 0x%08lX ...\n", (ulong)USER_DATA_START, (ulong)USER_DATA_END - 1); // Append cached section(s) for (idx = 0; idx < SectionCnt; idx++) { tSection* p = &Sections[idx]; if (p->Addr + p->Size >= p->Addr && (p->Addr >= USER_DATA_END || p->Addr + p->Size <= USER_DATA_START)) { if (verbose) printf("Copying %s ...\n", p->Name); // Copy section if (p->FileOffs) { if (fseek(ElfFile, p->FileOffs, SEEK_SET)) error("Can't read file\n"); CopyFileData(AoutFile, ElfFile, p->Size); } p->Flags2 |= 1; // section has been processed } } // Make sure no section has been left unprocessed for (idx = 0; idx < SectionCnt; idx++) { tSection* p = &Sections[idx]; if (!(p->Flags2 & 1)) error("Not all sections have been processed, e.g. %s hasn't\n", p->Name); } // Update a.out header aoutHdr.a_magic = OMAGIC; aoutHdr.a_entry = EntryPointAddr; codeEndAddr = endAddr; for (idx = SectionCnt - 1; idx != (uint)-1; idx--) { tSection* p = &Sections[idx]; if (p->Addr + p->Size >= p->Addr && p->Addr >= USER_DATA_START && p->Addr + p->Size <= USER_DATA_END) { // While not executable, keep going, executable sections are first if (!(p->Flags & 2)) codeEndAddr = p->Addr; else break; } } bssStartAddr = endAddr; for (idx = SectionCnt - 1; idx != (uint)-1; idx--) { tSection* p = &Sections[idx]; if (p->Addr + p->Size >= p->Addr && p->Addr >= USER_DATA_START && p->Addr + p->Size <= USER_DATA_END) { // While initialized to all zeroes, keep going if (!p->FileOffs) bssStartAddr = p->Addr; else break; } } aoutHdr.a_text = codeEndAddr - USER_DATA_START; aoutHdr.a_data = bssStartAddr - codeEndAddr; aoutHdr.a_bss = endAddr - bssStartAddr; if (fseek(AoutFile, 0, SEEK_SET)) error("Can't write file\n"); if (fwrite(&aoutHdr, 1, sizeof aoutHdr, AoutFile) != sizeof aoutHdr) error("Can't write file\n"); if (fclose(AoutFile)) error("Can't write file\n"); fclose(ElfFile); if (verbose) { printf("a.out header:\n" " text size: %lu\n" " data size: %lu\n" " bss size: %lu\n", (ulong)aoutHdr.a_text, (ulong)aoutHdr.a_data, (ulong)aoutHdr.a_bss); printf("Done\n"); } return 0; } ================================================ FILE: tools/icache/license.txt ================================================ Copyright (c) 2013, Alexey Frunze All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. The views and conclusions contained in the software and documentation are those of the authors and should not be interpreted as representing official policies, either expressed or implied, of the FreeBSD Project. ================================================ FILE: tools/icache/readme.txt ================================================ icache is a MIPS emulator + software instruction cache. With it one may be able to run large programs on MIPS32 processors that would otherwise not fit into small on-chip RAMs of ~128KB. Supported platform: RetroBSD. http://www.retrobsd.org/ See the Wiki for more up-to-date details: http://github.com/alexfru/icacheMips/wiki ================================================ FILE: tools/libufs/Makefile ================================================ TOPSRC!=cd ../..; pwd -include ../Makefile.inc LOBJS=fs.o util.o fops.o set.o CFLAGS=-Wall -ggdb3 PROGS=umkfs umkdir uls uchmod uchown uchgrp ulogin ucd ucat POBJS=umkfs.o umkdir.o uls.o uchmod.o uchown.o uchgrp.o ulogin.o ucd.o ucat.o LDFLAGS=-L. -lufs -ggdb3 ARFLAGS=-cr LIB=libufs.a all: $(LIB) $(PROGS) $(LIB): $(LOBJS) $(AR) $(ARFLAGS) $(LIB) $(LOBJS) $(PROGS): $(POBJS) $(LIB) $(CC) -o $@ $@.o $(LDFLAGS) clean: rm -f $(LIB) $(LOBJS) $(PROGS) $(POBJS) ================================================ FILE: tools/libufs/fops.c ================================================ #include #include #include #include #include #include #include #include "libufs.h" // Split a path into an array of char pointers, each // one containing an element of the path, char **splitpath(char *path, int *ndir) { char *p,*q; int dn = 0; char **dirs; *ndir = 0; p = path; while (*p == '/') p++; while (*(p+strlen(p)-1) == '/') { *(p+strlen(p)-1) = '\0'; } // First count the number of entries we have q = p; for ( ; *p; p++) { if (*p == '/') { (*ndir)++; } } if(*q) (*ndir)++; p = q; // Then allocate enough space for them dirs = malloc(*ndir * sizeof(char *)); // Now do the actual splitting. for ( ; *p; p++) { if ((*p) == '/') { *p = 0; dirs[dn] = q; p++; dn++; q = p; } } if (*q) { dirs[dn] = q; dn++; } if (dn != *ndir) { printf("Something odd happened to the path\n"); } return dirs; } unsigned int getfileinode(struct filesystem *f, struct inode *in, char *fn) { unsigned int ino = 0; char *buf; char *d; struct direct *de; buf = fsreadblock(f, in->i_db[0]); if (!buf) { printf("Bad read\n"); return 0; } d = buf; de = (struct direct *)d; while ((de < (struct direct *)(buf+DEV_BSIZE)) && (de->d_ino != 0)) { if (!strcmp(de->d_name, fn)) { ino = de->d_ino; break; } d += de->d_reclen; de = (struct direct *)d; } free(buf); return ino; } struct inode *inodebypath(struct filesystem *f, char *path) { char **dirs = NULL; int ndir = 0; int i; struct inode *in = f->root; char *p = strdup(path); int ino __attribute__((unused)); dirs = splitpath(p, &ndir); if (ndir == 0) { free(dirs); free(p); return f->root; } for (i = 0; i < ndir; i++) { ino = getfileinode(f, in, dirs[i]); if (ino != 0) { if (in != f->root) { free(in); } in = fsreadinode(f, ino); } else { free(p); free(dirs); if (in != f->root) { free(in); } return 0; } } free(p); free(dirs); return in; } struct inode *inodebypartpath(struct filesystem *f, char *path, int *depth) { char **dirs = NULL; int ndir = 0; int i; struct inode *in = f->root; char *p = strdup(path); int ino __attribute__((unused)); if(depth) *depth = 0; dirs = splitpath(p, &ndir); for (i = 0; i < ndir; i++) { ino = getfileinode(f, in, dirs[i]); if (ino != 0) { if (in != f->root) { free(in); } in = fsreadinode(f, ino); if(depth) (*depth)++; } else { printf("Not found\n"); free(p); free(dirs); return in; } } free(p); free(dirs); return in; } void listdir(struct filesystem *f, ino_t ino) { struct inode *in; struct inode *ip; char *buf; int i; char c; char *d; struct direct *dp; struct tm *tmp; char tbuf[22]; in = fsreadinode(f, ino); for (i = 0; i < NADDR; i++) { if (in->i_db[i] > 0) { buf = fsreadblock(f, in->i_db[i]); d = buf; while ((d - buf) < DEV_BSIZE) { dp = (struct direct *)d; ip = fsreadinode(f, dp->d_ino); switch (ip->i_mode & IFMT) { case IFBLK: printf("b"); break; case IFCHR: printf("c"); break; case IFDIR: printf("d"); break; case IFLNK: printf("l"); break; default: printf("-"); break; } c = '-'; if (ip->i_mode & 0400) c = 'r'; printf("%c", c); c = '-'; if (ip->i_mode & 0200) c = 'w'; printf("%c", c); c = '-'; if (ip->i_mode & 0100) c = 'x'; if (ip->i_mode & 04000) c = 's'; printf("%c", c); c = '-'; if (ip->i_mode & 0040) c = 'r'; printf("%c", c); c = '-'; if (ip->i_mode & 0020) c = 'w'; printf("%c", c); c = '-'; if (ip->i_mode & 0010) c = 'x'; if (ip->i_mode & 02000) c = 's'; printf("%c", c); c = '-'; if (ip->i_mode & 0004) c = 'r'; printf("%c", c); c = '-'; if (ip->i_mode & 0002) c = 'w'; printf("%c", c); c = '-'; if (ip->i_mode & 0001) c = 'x'; if (ip->i_mode & 01000) c = 't'; printf("%c", c); printf(" %5u", ip->i_number); printf(" %8lu", ip->i_size); tmp = localtime(&ip->i_mtime); strftime(tbuf, 20, "%Y-%m-%d %H:%M", tmp); printf(" %s", tbuf); printf(" %s", dp->d_name); #if 0 printf("\n "); for (i=0; ii_addr[i]); } #endif printf("\n"); d += dp->d_reclen; free(ip); } free(buf); } } free(in); } struct inode *adddirectory(struct filesystem *f, struct inode *in, char *name) { char *buf; char *d; struct direct *dp; int bno; struct inode *ip; ino_t ino = fsinodealloc(f); int rem; int i = 0; if (!(in->i_mode & IFDIR)) { errno = ENOTDIR; return NULL; } if (ino == 0) { printf("Could not allocate inode\n"); errno = ENOSPC; return NULL; } // Create the new directory bno = fsblockalloc(f); if (bno == 0) { errno = ENOSPC; return NULL; } rem = DEV_BSIZE; buf = malloc(DEV_BSIZE); d = buf; dp = (struct direct *)d; dp->d_ino = ino; dp->d_namlen = 1; dp->d_name[0] = '.'; dp->d_name[1] = '\0'; dp->d_reclen = DIRSIZ(dp); rem -= dp->d_reclen; d += dp->d_reclen; dp = (struct direct *)d; dp->d_ino = in->i_number; dp->d_namlen = 2; dp->d_name[0] = '.'; dp->d_name[1] = '.'; dp->d_name[2] = '\0'; dp->d_reclen = rem; fswriteblock(f, bno, buf); free(buf); ip = malloc(sizeof(struct inode)); for (i = 0; i < NADDR; i++) ip->i_db[i] = 0; ip->i_number = ino; ip->i_db[0] = bno; ip->i_mode = IFDIR | 0755; ip->i_uid = 0; ip->i_gid = 0; ip->i_nlink = 2; ip->i_size = DEV_BSIZE; ip->i_atime = time(NULL); ip->i_ctime = time(NULL); ip->i_mtime = time(NULL); fswriteinode(f, ip); // insert the new directory into the parent buf = fsreadblock(f, in->i_db[0]); if (!buf) { printf("Bad read\n"); errno = EIO; return NULL; } d = buf; rem = DEV_BSIZE; while ((d - buf) < DEV_BSIZE) { dp = (struct direct *)d; printf("inode %d (%d %d)\n", (int)dp->d_ino, (int)dp->d_reclen, sizeof(struct direct)); if (dp->d_reclen != DIRSIZ(dp)) { if (dp->d_ino != 0) { dp->d_reclen = DIRSIZ(dp); rem -= dp->d_reclen; d += dp->d_reclen; dp = (struct direct *)d; } dp->d_ino = ino; dp->d_namlen = strlen(name); bcopy(name, dp->d_name, strlen(name)); dp->d_reclen = rem; if (!fswriteblock(f, in->i_db[0], buf)) { errno = EIO; free(ip); free(buf); return NULL; } in->i_nlink++; fswriteinode(f, in); free(buf); return ip; } i++; rem -= dp->d_reclen; d += dp->d_reclen; } free(ip); free(buf); errno = ENOSPC; return NULL; } int umkdir(struct filesystem *f, char *path) { struct inode *in; struct inode *ip; int sd; int i; char *p = strdup(path); int ndir; char **dirs = splitpath(p, &ndir); in = inodebypartpath(f, path, &sd); if (sd == ndir) { if (in != f->root) { free(in); } free(p); free(dirs); errno = EEXIST; return 0; } for (i = sd; i < ndir; i++) { ip = adddirectory(f, in, dirs[i]); if (in != f->root) { free(in); } if (!ip) { free(p); free(dirs); return 0; } in = ip; } if (in != f->root) { free(in); } free(p); free(dirs); return 1; } int uls(struct filesystem *f, char *path) { struct inode *in; in = inodebypath(f, path); if (!in) { errno = ENOENT; return 0; } listdir(f, in->i_number); if (in != f->root) free(in); return 1; } int uchmod(struct filesystem *f, char *path, int mode) { struct inode *in; char *p = strdup(path); int ndir; char **dirs = splitpath(p, &ndir); free(p); free(dirs); in = inodebypath(f, path); if (!in) { errno = ENOENT; return 0; } in->i_mode &= ~07777; in->i_mode |= (mode & 07777); fswriteinode(f, in); free(in); return 1; } int uchown(struct filesystem *f, char *path, int uid) { struct inode *in; char *p = strdup(path); int ndir; char **dirs = splitpath(p, &ndir); free(p); free(dirs); in = inodebypath(f, path); if (!in) { errno = ENOENT; return 0; } in->i_uid = uid; fswriteinode(f, in); free(in); return 1; } int uchgrp(struct filesystem *f, char *path, int gid) { struct inode *in; char *p = strdup(path); int ndir; char **dirs = splitpath(p, &ndir); free(p); free(dirs); in = inodebypath(f, path); if (!in) { errno = ENOENT; return 0; } in->i_mode = gid; fswriteinode(f, in); free(in); return 1; } int uftruncate(UFILE *file) { return 1; } struct inode *fscreatefile(struct filesystem *f, char *path) { return NULL; } UFILE *ufopen(struct filesystem *f, char *path, char *mode) { UFILE *file = malloc(sizeof(UFILE)); file->f = f; file->in = inodebypath(f, path); file->readoffset = 0; file->writeoffset = 0; file->perm = 0; if (!strcmp(mode, "r")) { if (!file->in) { return 0; } file->readoffset = 0; file->writeoffset = 0; file->perm = O_RDONLY; } if (!strcmp(mode, "r+")) { if (!file->in) { return 0; } file->readoffset = 0; file->writeoffset = 0; file->perm = O_RDWR; } if (!strcmp(mode, "w")) { if (!file->in) { return 0; } uftruncate(file); file->readoffset = 0; file->writeoffset = 0; file->perm = O_WRONLY; } if (!strcmp(mode, "w+")) { if (!file->in) { file->in = fscreatefile(f, path); } else { uftruncate(file); } file->readoffset = 0; file->writeoffset = 0; file->perm = O_RDWR; } if (!strcmp(mode, "a")) { if (!file->in) { file->in = fscreatefile(f, path); } file->readoffset = file->in->i_size; file->writeoffset = file->in->i_size; file->perm = O_WRONLY; } if (!strcmp(mode, "a+")) { if (!file->in) { file->in = fscreatefile(f, path); } file->readoffset = 0; file->writeoffset = file->in->i_size; file->perm = O_RDWR; } return file; } void ufclose(UFILE *f) { if (f->in) { free(f->in); } free(f); } int ufgetc(UFILE *f) { unsigned char *buf; int bno; int offset; unsigned int addr; int c; int *ib; if (f->readoffset >= f->in->i_size) { return EOF; } bno = f->readoffset / DEV_BSIZE; offset = f->readoffset - (bno * DEV_BSIZE); if (bno < NADDR-3) { addr = f->in->i_db[bno]; } else { bno -= NADDR-3; // First level indirect if (bno < DEV_BSIZE / 4) { buf = fsreadblock(f->f, f->in->i_db[NADDR-3]); ib = (daddr_t *)buf; addr = ib[bno]; free(buf); } else { bno -= (DEV_BSIZE / 4); // Double indirect if (bno < ((DEV_BSIZE / 4) * (DEV_BSIZE / 4))) { buf = fsreadblock(f->f, f->in->i_db[NADDR-2]); ib = (daddr_t *)buf; addr = ib[bno / (DEV_BSIZE / 4)]; free(buf); buf = fsreadblock(f->f, addr); ib = (daddr_t *)buf; addr = ib[bno - ((bno / (DEV_BSIZE / 4)) * (DEV_BSIZE / 4))]; free(buf); } else { // It gets horrible now - triple indirect. } } } buf = fsreadblock(f->f, addr); if (!buf) { return -EIO; } f->readoffset++; c = buf[offset]; free(buf); return c; } ================================================ FILE: tools/libufs/fs.c ================================================ #include #include #include #include #include #include #include #include "libufs.h" void inodemap(void *buf) { int i; struct inode *in; for (i = 0; i < INOPB; i++) { in = (struct inode *)(buf + (i * sizeof(struct inode))); printf("%lu\n", (unsigned long)in->i_number); } } // Convert an array of direct structures into a filesysem block // representing a directory structure containing those direct // structures as the content int32_t makedir(struct direct *protodir, int entries, void *buf) { char *cp; int i, spcleft; spcleft = DIRBLKSIZ; for (cp = buf, i = 0; i < entries - 1; i++) { protodir[i].d_reclen = DIRSIZ(&protodir[i]); bcopy(&protodir[i], cp, protodir[i].d_reclen); cp += protodir[i].d_reclen; spcleft -= protodir[i].d_reclen; } protodir[i].d_reclen = spcleft; bcopy(&protodir[i], cp, DIRSIZ(&protodir[i])); for (i=0; ifs); } u_int32_t fsinodealloc(struct filesystem *f) { u_int32_t ino; // are there any known free inodes? struct inode *in; u_int32_t ninode = 0; badino: if (f->fs->fs_ninode > 0) { ino = f->fs->fs_inode[--f->fs->fs_ninode]; // An inode number below ROOTINO is not valid. if (ino <= ROOTINO) { goto badino; } in = malloc(sizeof(struct inode)); bzero(in, sizeof(struct inode)); in->i_number = ino; fswriteinode(f, in); free(in); f->fs->fs_tinode--; fssync(f); return ino; } // We couldn't get an inode, so we need to scrape the filesystem // for more. printf("Not able to get an inode - scraping\n"); // First, let's find a good inode for ourselves... for (ino = ROOTINO+1; itod(ino) < f->fs->fs_isize; ino++) { in = fsreadinode(f, ino); if (in->i_mode == 0) { bzero(in, sizeof(struct inode)); in->i_number = ino; fswriteinode(f, in); ninode = ino; f->fs->fs_tinode--; fssync(f); free(in); break; } free(in); } printf("Got inode %lu\n", (unsigned long)ninode); // Did it work? if (ninode == 0) { printf("Error: out of inodes\n"); return 0; } // Now to find a free one. for (ino = ninode+1; itod(ino) < f->fs->fs_isize; ino++) { in = fsreadinode(f, ino); if (in->i_mode == 0) { f->fs->fs_inode[f->fs->fs_ninode++] = ino; if (f->fs->fs_ninode == NICINOD) break; } } fssync(f); return ninode; } int64_t fsblockalloc(struct filesystem *f) { int64_t bno; if (f->fs->fs_tfree == 0) { printf("disk full\n"); return 0; } if (f->fs->fs_nfree == 0) { printf("no free space and no scraping yet\n"); return 0; } f->fs->fs_tfree--; bno = f->fs->fs_free[--f->fs->fs_nfree]; fssync(f); return (bno); } void *fsreadblock(struct filesystem *f, int64_t bno) { int n; int64_t offset; char *buf = malloc(DEV_BSIZE); if (!buf) { printf("Unable to allocate buffer!!!!!\n"); return NULL; } offset = (int64_t) bno*DEV_BSIZE; if (lseek(f->fd, offset, 0) != offset) { printf("lseek read error: %lu\n", (unsigned long)bno); free(buf); return NULL; } n = read(f->fd, buf, DEV_BSIZE); if (n != DEV_BSIZE) { printf("read error: %ld\n", (long)bno); free(buf); return NULL; } return buf; } int fswriteblock(struct filesystem *f, int64_t bno, void *buf) { int n; int64_t offset; offset = (int64_t) bno*DEV_BSIZE; if (lseek(f->fd, offset, 0) != offset) { printf ("lseek failed on block number %lu, offset=%lu\n", (unsigned long)bno, (unsigned long)offset); return 0; } n = write(f->fd, buf, DEV_BSIZE); if (n != DEV_BSIZE) { printf("write error: %ld\n", (long)bno); return 0; } return 1; } struct inode *fsreadinode(struct filesystem *f, int64_t ino) { char *buf; struct inode *i; int64_t off; struct dinode *dp; int n; buf = fsreadblock(f, itod(ino)); if (!buf) { printf("Failed reading inode block\n"); return NULL; } i = malloc(sizeof(struct inode)); off = itoo(ino); dp = (struct dinode *)(buf + (sizeof(struct dinode) * off)); i->i_number = ino; i->i_ic1 = dp->di_icom1; i->i_flags = dp->di_flags; i->i_ic2 = dp->di_icom2; for (n = 0; n < NADDR; n++) i->i_addr[n] = dp->di_addr[n]; free(buf); return i; } int fswriteinode(struct filesystem *f, struct inode *ip) { char *buf; struct dinode *dp; int64_t d; int n; d = itod(ip->i_number); if (d >= f->fs->fs_isize) { printf("ilist too small\n"); return 0; } buf = fsreadblock(f, d); if (!buf) { return 0; } dp = (struct dinode *)(buf + (itoo(ip->i_number) * sizeof(struct dinode))); dp->di_icom1 = ip->i_ic1; dp->di_flags = ip->i_flags; dp->di_icom2 = ip->i_ic2; for (n = 0; n < NADDR; n++) dp->di_addr[n] = ip->i_addr[n]; if (!fswriteblock(f, d, buf)) { free(buf); return 0; } free(buf); return 1; } void fsfreeblock(struct filesystem *f, int64_t bno) { if (bno != 0) f->fs->fs_tfree++; if (f->fs->fs_nfree < NICFREE) { f->fs->fs_free[f->fs->fs_nfree++] = bno; } fssync(f); } struct filesystem *fsopen(char *filename) { struct filesystem *f; f = malloc(sizeof(struct filesystem)); f->fd = open(filename, O_RDWR); if (!f->fd) { free(f); return NULL; } f->fs = (struct fs *)fsreadblock(f, SUPERB); if (!f->fs) { printf("%s: Bad superblock\n", filename); free(f); return NULL; } f->root = fsreadinode(f, ROOTINO); if (!f->root) { printf("%s: Bad root directory\n", filename); free(f->fs); free(f); return NULL; } return f; } void fsclose(struct filesystem *f) { if (!f) return; if (f->fd) { if (f->fs) { fswriteblock(f, SUPERB, f->fs); } close(f->fd); } if (f->root) free(f->root); if (f->fs) free(f->fs); free(f); } void bfree(struct filesystem *f, int64_t bno) { register int i; struct fblk *fb = malloc(DEV_BSIZE); if (bno != 0) f->fs->fs_tfree++; if (f->fs->fs_nfree >= NICFREE) { fb->df_nfree = f->fs->fs_nfree; for (i=0; idf_free[i] = f->fs->fs_free[i]; fswriteblock(f, bno, fb); printf("Writing free list to %d\n", (int)bno); f->fs->fs_nfree = 0; } f->fs->fs_free[f->fs->fs_nfree++] = bno; } void bflist(struct filesystem *f) { struct inode in; int64_t d; bzero(&in, sizeof (in)); in.i_number = 1; /* inode 1 is a historical hack */ in.i_mode = IFREG; fswriteinode(f, &in); bfree(f, (int64_t)0); d = f->fs->fs_fsize; while (--d >= f->fs->fs_isize + f->fs->fs_swapsz) { bfree(f, d); } printf("Resultant free list size %d\n", f->fs->fs_nfree); } struct filesystem *fsnew(char *filename, unsigned int blocks, unsigned int bpi) { struct filesystem *f; unsigned int i; char *buffer; f = malloc(sizeof(DEV_BSIZE)); f->fd = open(filename, O_RDWR | O_TRUNC | O_CREAT, 0644); if (!f->fd) { free(f); return NULL; } buffer = malloc(DEV_BSIZE); bzero(buffer, DEV_BSIZE); for (i=0; ifs = malloc(DEV_BSIZE); f->fs->fs_fsize = blocks; fsformat(f, bpi); return f; } int fsformat(struct filesystem *f, int bpi) { unsigned int nino; char *buffer = malloc(DEV_BSIZE); unsigned int i; nino = (f->fs->fs_fsize * DEV_BSIZE / bpi) / INOPB; if (nino <= 0) { nino = 1; } f->fs->fs_isize = nino+1; f->fs->fs_swapsz = 0; f->fs->fs_time = time(NULL); f->fs->fs_magic1 = FSMAGIC1; f->fs->fs_magic2 = FSMAGIC2; f->fs->fs_tfree = 0; f->fs->fs_tinode = 0; f->fs->fs_ninode = 0; f->fs->fs_nfree = 0; bzero(buffer, DEV_BSIZE); for (i = SUPERB+1; i != f->fs->fs_isize; i++) { if (!fswriteblock(f, i, buffer)) { close(f->fd); free(f->fs); free(buffer); return 0; } f->fs->fs_tinode += INOPB; } bflist(f); fsinit(f); free(buffer); return 1; } void fsinit(struct filesystem *f) { int i; struct inode node; char *buf = malloc(DEV_BSIZE); time_t utime; struct direct lost_found_dir[] = { { LOSTFOUNDINO, sizeof(struct direct), 1, "." }, { ROOTINO, sizeof(struct direct), 2, ".." }, { 0, DIRBLKSIZ, 0, "" }, }; struct direct root_dir[] = { { ROOTINO, sizeof(struct direct), 1, "." }, { ROOTINO, sizeof(struct direct), 2, ".." }, { LOSTFOUNDINO, sizeof(struct direct), 10, "lost+found" }, { 0, DIRBLKSIZ, 0, "" }, }; utime = time(NULL); node.i_atime = utime; node.i_mtime = utime; node.i_ctime = utime; makedir(lost_found_dir, 2, buf); for (i = DIRBLKSIZ; i < DEV_BSIZE; i += DIRBLKSIZ) bcopy(&lost_found_dir[2], &buf[i], DIRSIZ(&lost_found_dir[2])); node.i_number = LOSTFOUNDINO; node.i_mode = IFDIR | 0755; node.i_nlink = 2; node.i_size = DEV_BSIZE; node.i_db[0] = fsblockalloc(f); fswriteblock(f, node.i_db[0], buf); fswriteinode(f, &node); node.i_number = ROOTINO; node.i_mode = IFDIR | 0755; node.i_nlink = 3; node.i_size = makedir(root_dir, 3, buf); node.i_db[0] = fsblockalloc(f); fswriteblock(f, node.i_db[0], buf); fswriteinode(f, &node); free(buf); } ================================================ FILE: tools/libufs/libufs.h ================================================ #ifndef _LIBUFS_H #define _LIBUFS_H #include #define dev_t int #define ino_t u_int #define time_t long #define DEV_BSIZE 1024 // Block size #define BPI (16 * DEV_BSIZE) // Bytes per inode #define ROOTINO ((u_int)2) // i number of all roots #define LOSTFOUNDINO (ROOTINO + 1) // i number of lost+found #define NICINOD 32 // number of superblock inodes #define NICFREE 200 // number of superblock free blocks #define MAXMNTLEN 28 #define NSHIFT 8 #define NMASK 0377L #define MAXNAMLEN 63 #define MAXSYMLINKS 8 #define DEV_BMASK (DEV_BSIZE-1) #define B_CLRBUF 0x01 #define DEV_BSHIFT 10 #define DIRBLKSIZ 1024 #define NINDIR (DEV_BSIZE / sizeof(long)) #define INOPB 16 #define MAXPATHLEN 256 #define FSMAGIC1 ('F' | 'S'<<8 | '<'<<16 | '<'<<24) #define FSMAGIC2 ('>' | '>'<<8 | 'F'<<16 | 'S'<<24) #define SUPERB ((long)0) /* block number of the super block */ #define PINOD 10 #define dbtofsb(b) ((long) (b)) #define itod(x) ((long)((((u_int)(x) + INOPB - 1) / INOPB))) #define itoo(x) ((int)(((x) + INOPB - 1) % INOPB)) #define DIRSIZ(dp) \ ((((sizeof (struct direct) - (MAXNAMLEN+1)) + (dp)->d_namlen+1) + 3) &~ 3) #define blkoff(loc) /* calculates (loc % fs->fs_bsize) */ \ ((loc) & DEV_BMASK) #define lblkno(loc) /* calculates (loc / fs->fs_bsize) */ \ ((unsigned) (loc) >> DEV_BSHIFT) #define NDINIT(ndp,op,flags,namep) {\ (ndp)->ni_nameiop = op | flags; \ (ndp)->ni_dirp = namep; } #define roundup(x,y) ((((x)+((y)-1))/(y))*(y)) #define LOOKUP 0 /* perform name lookup only */ #define CREATE 1 /* setup for file creation */ #define DELETE 2 /* setup for file deletion */ #define LOCKPARENT 0x10 /* see the top of namei */ #define NOCACHE 0x20 /* name must not be left in cache */ #define FOLLOW 0x40 /* follow symbolic links */ #define NOFOLLOW 0x0 /* don't follow symbolic links (pseudo) */ #define B_READ 0x00001 /* read when I/O occurs */ #define B_ERROR 0x00004 /* transaction aborted */ struct fs { u_int fs_magic1; /* magic word */ u_int fs_isize; /* first block after i-list */ u_int fs_fsize; /* size in blocks of entire volume */ u_int fs_swapsz; /* size in blocks of swap area */ int fs_nfree; /* number of addresses in fs_free */ daddr_t fs_free [NICFREE]; /* free block list */ int fs_ninode; /* number of inodes in fs_inode */ ino_t fs_inode [NICINOD]; /* free inode list */ int fs_flock; /* lock during free list manipulation */ int fs_fmod; /* super block modified flag */ int fs_ilock; /* lock during i-list manipulation */ int fs_ronly; /* mounted read-only flag */ time_t fs_time; /* last super block update */ u_int fs_tfree; /* total free blocks */ ino_t fs_tinode; /* total free inodes */ char fs_fsmnt [MAXMNTLEN]; /* ordinary file mounted on */ ino_t fs_lasti; /* start place for circular search */ ino_t fs_nbehind; /* est # free inodes before s_lasti */ u_int fs_flags; /* mount time flags */ u_int fs_magic2; /* magic word */ /* actually longer */ }; struct fblk { int df_nfree; /* number of addresses in df_free */ daddr_t df_free [NICFREE]; /* free block list */ }; struct direct { ino_t d_ino; /* inode number of entry */ u_short d_reclen; /* length of this record */ u_short d_namlen; /* length of string in d_name */ char d_name[MAXNAMLEN+1]; /* name must be no longer than this */ }; #define NDADDR 4 /* direct addresses in inode */ #define NIADDR 3 /* indirect addresses in inode */ #define NADDR (NDADDR + NIADDR) /* total addresses in inode */ struct icommon1 { u_short ic_mode; /* mode and type of file */ u_short ic_nlink; /* number of links to file */ uid_t ic_uid; /* owner's user id */ gid_t ic_gid; /* owner's group id */ off_t ic_size; /* number of bytes in file */ }; struct icommon2 { time_t ic_atime; /* time last accessed */ time_t ic_mtime; /* time last modified */ time_t ic_ctime; /* time created */ }; struct inode { struct inode *i_chain[2]; /* must be first */ u_int i_flag; u_int i_count; /* reference count */ dev_t i_dev; /* device where inode resides */ ino_t i_number; /* i number, 1-to-1 with device address */ u_int i_id; /* unique identifier */ struct fs *i_fs; /* file sys associated with this inode */ union { struct { u_short I_shlockc; /* count of shared locks */ u_short I_exlockc; /* count of exclusive locks */ } i_l; struct proc *I_rsel; /* pipe read select */ } i_un0; union { struct proc *I_wsel; /* pipe write select */ } i_un1; union { daddr_t I_addr[NADDR]; /* normal file/directory */ struct { daddr_t I_db[NDADDR]; /* normal file/directory */ daddr_t I_ib[NIADDR]; } i_f; struct { /* * the dummy field is here so that the de/compression * part of the iget/iput routines works for special * files. */ u_int I_dummy; dev_t I_rdev; /* dev type */ } i_d; } i_un2; union { daddr_t if_lastr; /* last read (read-ahead) */ struct { struct inode *if_freef; /* free list forward */ struct inode **if_freeb; /* free list back */ } i_fr; } i_un3; struct icommon1 i_ic1; u_int i_flags; /* user changeable flags */ struct icommon2 i_ic2; }; struct dinode { struct icommon1 di_icom1; daddr_t di_addr[NADDR]; /* 7 block addresses 4 bytes each */ u_int di_reserved[1]; /* pad of 4 to make total size 64 */ u_int di_flags; struct icommon2 di_icom2; }; struct nameidata { caddr_t ni_dirp; /* pathname pointer */ short ni_nameiop; /* see below */ short ni_error; /* error return if any */ off_t ni_endoff; /* end of useful stuff in directory */ struct inode *ni_pdir; /* inode of parent directory of dirp */ struct inode *ni_ip; /* inode of dirp */ off_t ni_offset; /* offset in directory */ u_short ni_count; /* offset of open slot (off_t?) */ struct direct ni_dent; /* current directory entry */ }; #define i_mode i_ic1.ic_mode #define i_nlink i_ic1.ic_nlink #define i_uid i_ic1.ic_uid #define i_gid i_ic1.ic_gid #define i_size i_ic1.ic_size #define i_shlockc i_un0.i_l.I_shlockc #define i_exlockc i_un0.i_l.I_exlockc #define i_rsel i_un0.I_rsel #define i_wsel i_un1.I_wsel #define i_db i_un2.i_f.I_db #define i_ib i_un2.i_f.I_ib #define i_atime i_ic2.ic_atime #define i_mtime i_ic2.ic_mtime #define i_ctime i_ic2.ic_ctime #define i_rdev i_un2.i_d.I_rdev #define i_addr i_un2.I_addr #define i_dummy i_un2.i_d.I_dummy #define i_lastr i_un3.if_lastr #define i_forw i_chain[0] #define i_back i_chain[1] #define i_freef i_un3.i_fr.if_freef #define i_freeb i_un3.i_fr.if_freeb #define di_ic1 di_icom1 #define di_ic2 di_icom2 #define di_mode di_ic1.ic_mode #define di_nlink di_ic1.ic_nlink #define di_uid di_ic1.ic_uid #define di_gid di_ic1.ic_gid #define di_size di_ic1.ic_size #define di_atime di_ic2.ic_atime #define di_mtime di_ic2.ic_mtime #define di_ctime di_ic2.ic_ctime /* i_flag */ #define ILOCKED 0x1 /* inode is locked */ #define IUPD 0x2 /* file has been modified */ #define IACC 0x4 /* inode access time to be updated */ #define IMOUNT 0x8 /* inode is mounted on */ #define IWANT 0x10 /* some process waiting on lock */ #define ITEXT 0x20 /* inode is pure text prototype */ #define ICHG 0x40 /* inode has been changed */ #define ISHLOCK 0x80 /* file has shared lock */ #define IEXLOCK 0x100 /* file has exclusive lock */ #define ILWAIT 0x200 /* someone waiting on file lock */ #define IMOD 0x400 /* inode has been modified */ #define IRENAME 0x800 /* inode is being renamed */ #define IPIPE 0x1000 /* inode is a pipe */ #define IRCOLL 0x2000 /* read select collision on pipe */ #define IWCOLL 0x4000 /* write select collision on pipe */ #define IXMOD 0x8000 /* inode is text, but impure (XXX) */ /* i_mode */ #define IFMT 0170000 /* type of file */ #define IFCHR 0020000 /* character special */ #define IFDIR 0040000 /* directory */ #define IFBLK 0060000 /* block special */ #define IFREG 0100000 /* regular */ #define IFLNK 0120000 /* symbolic link */ #define IFSOCK 0140000 /* socket */ #define ISUID 04000 /* set user id on execution */ #define ISGID 02000 /* set group id on execution */ #define ISVTX 01000 /* save swapped text even after use */ #define IREAD 0400 /* read, write, execute permissions */ #define IWRITE 0200 #define IEXEC 0100 #define IUPDAT(ip, t1, t2, waitfor) { \ if (ip->i_flag&(IUPD|IACC|ICHG|IMOD)) \ iupdat(ip, t1, t2, waitfor); \ } #define ITIMES(ip, t1, t2) { \ if ((ip)->i_flag&(IUPD|IACC|ICHG)) { \ (ip)->i_flag |= IMOD; \ if ((ip)->i_flag&IACC) \ (ip)->i_atime = (t1)->tv_sec; \ if ((ip)->i_flag&IUPD) \ (ip)->i_mtime = (t2)->tv_sec; \ if ((ip)->i_flag&ICHG) \ (ip)->i_ctime = time.tv_sec; \ (ip)->i_flag &= ~(IACC|IUPD|ICHG); \ } \ } struct bufhd { int32_t b_flags; /* see defines below */ struct buf *b_forw, *b_back; /* fwd/bkwd pointer in chain */ }; struct buf { int32_t b_flags; /* see defines below */ struct buf *b_forw, *b_back; /* hash chain (2 way street) */ struct buf *av_forw, *av_back; /* position on free list if not BUSY */ #define b_actf av_forw /* alternate names for driver queue */ #define b_actl av_back /* head - isn't history wonderful */ u_int32_t b_bcount; /* transfer count */ #define b_active b_bcount /* driver queue head: drive active */ int32_t b_error; /* returned after I/O */ dev_t b_dev; /* major+minor device name */ caddr_t b_addr; /* core address */ long b_blkno; /* block # on device */ u_int32_t b_resid; /* words not transferred after error */ #define b_cylin b_resid /* disksort */ #define b_errcnt b_resid /* while i/o in progress: # retries */ }; #define dotdot_ino dtdt_ino #define dotdot_reclen dtdt_rec #define dotdot_name dtdt_name struct dirtemplate { u_int dot_ino; u_short dot_reclen; u_short dot_namlen; char dot_name[4]; /* must be multiple of 4 */ u_int dotdot_ino; u_short dotdot_reclen; u_short dotdot_namlen; char dotdot_name[4]; /* ditto */ }; struct filesystem { int32_t fd; struct fs *fs; struct inode *root; }; extern int32_t makedir(struct direct *protodir, int32_t entries, void *buf); extern void *fsreadblock(struct filesystem *f, int64_t bno); extern int32_t fsformat(struct filesystem *f, int32_t bpi); extern void fsinit(struct filesystem *f); extern struct filesystem *fsopen(char *filename); extern void fsclose(struct filesystem *f); extern struct filesystem *fsnew(char *filename, u_int32_t blocks, u_int32_t bpi); extern int32_t fsformat(struct filesystem *f, int32_t bpi); extern struct inode *fsreadinode(struct filesystem *f, int64_t ino); extern int32_t fswriteblock(struct filesystem *f, int64_t bno, void *buf); extern int32_t fswriteinode(struct filesystem *f, struct inode *ip); extern u_int32_t fsinodealloc(struct filesystem *f); extern int64_t fsblockalloc(struct filesystem *f); extern int32_t umkdir(struct filesystem *f, char *path); extern int uls(struct filesystem *f, char *path); extern int uchmod(struct filesystem *f, char *path, int mode); extern int uchown(struct filesystem *f, char *path, int uid); extern int uchgrp(struct filesystem *f, char *path, int gid); extern struct inode *inodebypath(struct filesystem *f, char *path); typedef struct { struct filesystem *f; struct inode *in; off_t readoffset; off_t writeoffset; int perm; } UFILE; extern char *getsetting(char *setting); extern void storesetting(char *setting, char *value); extern char **splitpath(char *path, int *ndir); extern void compresspath(char *path); extern UFILE *ufopen(struct filesystem *f, char *path, char *mode); extern void ufclose(UFILE *f); extern int ufgetc(UFILE *f); #endif ================================================ FILE: tools/libufs/set.c ================================================ #include #include #include #include #include "libufs.h" char *getsetting(char *setting) { FILE *f; char *s = NULL; char *home; char temp[1024]; char sub[1024]; char fmt[1024]; home = getenv("HOME"); sprintf(temp, "%s/.libufs", home); f = fopen(temp, "r"); if (!f) { return s; } sprintf(fmt, "%s=%%s", setting); while (fgets(temp, 1024, f)) { bzero(sub, 800); if (sscanf(temp, fmt, sub)) { s = strdup(sub); } } fclose(f); return s; } void storesetting(char *setting, char *value) { FILE *f1; FILE *f2; char *home; char temp1[1024]; char temp2[1024]; if (!setting) { return; } home = getenv("HOME"); sprintf(temp1, "%s/.libufs.bak", home); sprintf(temp2, "%s/.libufs", home); rename(temp2, temp1); f1 = fopen(temp1, "r"); if (!f1) { return; } f2 = fopen(temp2, "w"); if (!f2) { fclose(f2); return; } sprintf(temp2, "%s=", setting); while (fgets(temp1, 1024, f1)) { if (strncmp(temp1, temp2, strlen(temp2)) != 0) { if (strlen(temp1) > 2) { fprintf(f2, "%s", temp1); } } } if (value) { fprintf(f2, "%s=%s\n", setting, value); } fclose(f1); fclose(f2); } ================================================ FILE: tools/libufs/ucat.c ================================================ #include #include #include "libufs.h" int main(int argc, char *argv[]) { struct filesystem *f; char path[1024]; char *image = getsetting("imagefile"); UFILE *file; int c; if (!image) { printf("Have you run ulogin?\n"); return 10; } char *cwd = getsetting("cwd"); if (argc == 2) { if (argv[1][0] == '/') { sprintf(path, "%s", argv[1]); } else { sprintf(path, "%s/%s", cwd, argv[1]); } } else { sprintf(path, "%s", cwd); } free(cwd); f = fsopen(image); if (!f) { printf("Unable to open %s\n", image); fsclose(f); free(image); return(10); } file = ufopen(f, path, "r"); if (!file) { printf("%s: not found\n", path); fsclose(f); free(image); return(10); } while ((c = ufgetc(file)) != EOF) { printf("%c", c); } ufclose(file); fsclose(f); free(image); return 0; } ================================================ FILE: tools/libufs/ucd.c ================================================ #include #include #include #include "libufs.h" int main(int argc, char *argv[]) { struct filesystem *f; char *temp = malloc(1024); char *image; image = getsetting("imagefile"); if (!image) { printf("Have you run ulogin?\n"); return 10; } if (argc != 2) { printf("Usage: %s \n", argv[0]); free(image); return 10; } f = fsopen(image); if (!f) { if(image) free(image); return 10; } if (argv[1][0] == '/') { if (!inodebypath(f, argv[1])) { printf("%s not found\n", argv[1]); } else { storesetting("cwd", argv[1]); } fsclose(f); free(image); return 0; } else { char *cwd = getsetting("cwd"); if (!cwd) { sprintf(temp, "/%s", argv[1]); } else { sprintf(temp, "%s/%s", cwd, argv[1]); compresspath(temp); free(cwd); } if (!inodebypath(f, temp)) { printf("%s not found\n", temp); } else { storesetting("cwd", temp); } free(image); fsclose(f); return 0; } return 0; } ================================================ FILE: tools/libufs/uchgrp.c ================================================ #include #include #include "libufs.h" int main(int argc, char *argv[]) { struct filesystem *f; int i; int mode; char temp[1024]; char *cwd; char *fsname = getsetting("imagefile");; if (!fsname) { printf("Have you run ulogin?\n"); return 10; } if (argc < 3) { printf("Usage: %s ...\n", argv[0]); return 10; } sscanf(argv[1], "%o", &mode); f = fsopen(fsname); if (!f) { printf("Unable to open %s\n", fsname); return 10; } cwd = getsetting("cwd"); for (i = 2; i < argc; i++) { if (argv[i][0] == '/') { uchgrp(f, argv[i], mode); } else { if (!cwd) { sprintf(temp, "/%s", argv[i]); } else { sprintf(temp, "%s/%s", cwd, argv[i]); } compresspath(temp); uchgrp(f, temp, mode); } } fsclose(f); if (cwd) free(cwd); free(fsname); return 0; } ================================================ FILE: tools/libufs/uchmod.c ================================================ #include #include #include "libufs.h" int main(int argc, char *argv[]) { struct filesystem *f; int i; int mode; char temp[1024]; char *cwd; char *fsname = getsetting("imagefile");; if (!fsname) { printf("Have you run ulogin?\n"); return 10; } if (argc < 3) { printf("Usage: %s ...\n", argv[0]); return 10; } sscanf(argv[1], "%o", &mode); f = fsopen(fsname); if (!f) { printf("Unable to open %s\n", fsname); return 10; } cwd = getsetting("cwd"); for (i = 2; i < argc; i++) { if (argv[i][0] == '/') { uchmod(f, argv[i], mode); } else { if (!cwd) { sprintf(temp, "/%s", argv[i]); } else { sprintf(temp, "%s/%s", cwd, argv[i]); } compresspath(temp); uchmod(f, temp, mode); } } fsclose(f); if (cwd) free(cwd); free(fsname); return 0; } ================================================ FILE: tools/libufs/uchown.c ================================================ #include #include #include "libufs.h" int main(int argc, char *argv[]) { struct filesystem *f; int i; int mode; char temp[1024]; char *cwd; char *fsname = getsetting("imagefile");; if (!fsname) { printf("Have you run ulogin?\n"); return 10; } if (argc < 3) { printf("Usage: %s ...\n", argv[0]); return 10; } sscanf(argv[1], "%o", &mode); f = fsopen(fsname); if (!f) { printf("Unable to open %s\n", fsname); return 10; } cwd = getsetting("cwd"); for (i = 2; i < argc; i++) { if (argv[i][0] == '/') { uchown(f, argv[i], mode); } else { if (!cwd) { sprintf(temp, "/%s", argv[i]); } else { sprintf(temp, "%s/%s", cwd, argv[i]); } compresspath(temp); uchown(f, temp, mode); } } fsclose(f); if (cwd) free(cwd); free(fsname); return 0; } ================================================ FILE: tools/libufs/ulogin.c ================================================ #include #include #include #include "libufs.h" int main(int argc, char *argv[]) { char *filename; struct filesystem *f; char fullpath[1024]; char cwd[800]; if (argc != 2) { printf("Usage: %s \n", argv[0]); return 10; } filename = argv[1]; f = fsopen(filename); if (!f) { printf("Unable to open %s\n", filename); return 10; } if (filename[0] == '/') { storesetting("imagefile", filename); } else { getcwd(cwd,800); sprintf(fullpath, "%s/%s", cwd, filename); storesetting("imagefile", fullpath); } storesetting("cwd","/"); return 0; } ================================================ FILE: tools/libufs/uls.c ================================================ #include #include #include "libufs.h" int main(int argc, char *argv[]) { struct filesystem *f; char path[1024]; char *image = getsetting("imagefile"); if (!image) { printf("Have you run ulogin?\n"); return 10; } char *cwd = getsetting("cwd"); if (argc == 2) { if (argv[1][0] == '/') { sprintf(path, "%s", argv[1]); } else { sprintf(path, "%s/%s", cwd, argv[1]); } } else { sprintf(path, "%s", cwd); } free(cwd); f = fsopen(image); if (!f) { printf("Unable to open %s\n", image); } else { if (!uls(f, path)) { printf("%s not found\n", path); } } fsclose(f); free(image); return 0; } ================================================ FILE: tools/libufs/umkdir.c ================================================ #include #include #include "libufs.h" int main(int argc, char *argv[]) { struct filesystem *f; int i; char *image = getsetting("imagefile"); char temp[1024]; char *cwd; if (argc < 2) { printf("Usage: %s ...\n", argv[0]); return 10; } f = fsopen(image); if (!f) { return 10; } cwd = getsetting("cwd"); for (i = 1; i < argc; i++) { if (argv[i][0] == '/') { umkdir(f, argv[i]); } else { if (!cwd) { sprintf(temp, "/%s", argv[i]); } else { sprintf(temp, "%s/%s", cwd, argv[i]); } compresspath(temp); umkdir(f, temp); } } if (cwd) free(cwd); free(image); fsclose(f); return 0; } ================================================ FILE: tools/libufs/umkfs.c ================================================ #include #include #include #include #include "libufs.h" int main(int argc, char *argv[]) { struct stat sb; int opt; int blocks = 0; int bpi = BPI; struct filesystem *f; while ((opt = getopt(argc, argv, "i:b:")) != -1) { switch (opt) { case 'i': bpi = atoi(optarg); break; case 'b': blocks = atoi(optarg); break; } } if (argc <= optind) { printf("Usage: %s [-i bpi] [-b blocks] file\n", argv[0]); printf(" Format an file image with a UFS filesystem\n"); return 10; } if (stat(argv[optind], &sb) != -1) { f = fsopen(argv[optind]); if (!f) { printf("Error opening image file\n"); return 10; } f->fs->fs_fsize = sb.st_size / DEV_BSIZE; fsformat(f, bpi); } else { f = fsnew(argv[optind], blocks, bpi); } fsclose(f); return 0; } ================================================ FILE: tools/libufs/util.c ================================================ #include #include #include #include #include "libufs.h" void compresspath(char *path) { char *work; char *p, *q; char **dirs; int ndir; int i,j; // First, remove any double slashes for (p = path; *(p+1); p++) { while ((*p == '/') && (*(p+1) == '/')) { for (q = p+1; *q; q++) { *q = *(q+1); } } } // Now we need to split it all up and remove any single dots, and // cd up any double dots. work = strdup(path); dirs = splitpath(work, &ndir); for (i = 0; i < ndir; i++) { if (!strcmp(dirs[i], ".")) { for (j = i; j < ndir-1; j++) { dirs[j] = dirs[j+1]; } ndir--; } if (!strcmp(dirs[i], "..")) { for (j = i-1; j < ndir-1; j++) { dirs[j] = dirs[j+1]; } ndir--; for (j = i-1; j < ndir-1; j++) { dirs[j] = dirs[j+1]; } ndir--; } } sprintf(path, "%s", ""); for (i=0; i=0.75 USE_GMAKE = Yes # Fails to link main.o and libopenocd.a properly resulting in undefined reference in the gdb_server.o USE_LIBTOOL = gnu .include ================================================ FILE: tools/openbsd/ports/devel/openocd/distinfo ================================================ SHA256 (openocd-0.11.0.tar.bz2) = Q6POc0r/HTcGrYd5Op86U3HLDjV/D/0KFRZWsGs9Hn0= SIZE (openocd-0.11.0.tar.bz2) = 5699972 ================================================ FILE: tools/openbsd/ports/devel/openocd/patches/patch-src_jtag_drivers_cmsis_dap_usb_hid_c ================================================ Index: src/jtag/drivers/cmsis_dap_usb_hid.c --- src/jtag/drivers/cmsis_dap_usb_hid.c.orig +++ src/jtag/drivers/cmsis_dap_usb_hid.c @@ -56,7 +56,7 @@ static int cmsis_dap_hid_open(struct cmsis_dap *dap, u target_vid = 0; target_pid = 0; - if (hid_init() != 0) { + if (hidapi_hid_init() != 0) { LOG_ERROR("unable to open HIDAPI"); return ERROR_FAIL; } ================================================ FILE: tools/openbsd/ports/devel/openocd/patches/patch-src_jtag_drivers_nulink_usb_c ================================================ Index: src/jtag/drivers/nulink_usb.c --- src/jtag/drivers/nulink_usb.c.orig +++ src/jtag/drivers/nulink_usb.c @@ -1043,7 +1043,7 @@ static int nulink_usb_open(struct hl_interface_param_s return ERROR_FAIL; } - if (hid_init() != 0) { + if (hidapi_hid_init() != 0) { LOG_ERROR("unable to open HIDAPI"); return ERROR_FAIL; } ================================================ FILE: tools/openbsd/ports/devel/openocd/pkg/DESCR ================================================ OpenOCD is a Free and Open On-Chip Debugging, In-System Programming and Boundary-Scan Testing. ================================================ FILE: tools/openbsd/ports/devel/openocd/pkg/PLIST ================================================ @bin bin/openocd @info info/openocd.info @man man/man1/openocd.1 share/openocd/ share/openocd/OpenULINK/ share/openocd/OpenULINK/ulink_firmware.hex share/openocd/contrib/ share/openocd/contrib/60-openocd.rules share/openocd/contrib/libdcc/ share/openocd/contrib/libdcc/README share/openocd/contrib/libdcc/dcc_stdio.c share/openocd/contrib/libdcc/dcc_stdio.h share/openocd/contrib/libdcc/example.c share/openocd/scripts/ share/openocd/scripts/bitsbytes.tcl share/openocd/scripts/board/ share/openocd/scripts/board/8devices-lima.cfg share/openocd/scripts/board/actux3.cfg share/openocd/scripts/board/adapteva_parallella1.cfg share/openocd/scripts/board/adsp-sc584-ezbrd.cfg share/openocd/scripts/board/alphascale_asm9260_ek.cfg share/openocd/scripts/board/altera_sockit.cfg share/openocd/scripts/board/am3517evm.cfg share/openocd/scripts/board/arm_evaluator7t.cfg share/openocd/scripts/board/arm_musca_a.cfg share/openocd/scripts/board/arty_s7.cfg share/openocd/scripts/board/asus-rt-n16.cfg share/openocd/scripts/board/asus-rt-n66u.cfg share/openocd/scripts/board/at91cap7a-stk-sdram.cfg share/openocd/scripts/board/at91eb40a.cfg share/openocd/scripts/board/at91rm9200-dk.cfg share/openocd/scripts/board/at91rm9200-ek.cfg share/openocd/scripts/board/at91sam9261-ek.cfg share/openocd/scripts/board/at91sam9263-ek.cfg share/openocd/scripts/board/at91sam9g20-ek.cfg share/openocd/scripts/board/atmel_at91sam7s-ek.cfg share/openocd/scripts/board/atmel_at91sam9260-ek.cfg share/openocd/scripts/board/atmel_at91sam9rl-ek.cfg share/openocd/scripts/board/atmel_sam3n_ek.cfg share/openocd/scripts/board/atmel_sam3s_ek.cfg share/openocd/scripts/board/atmel_sam3u_ek.cfg share/openocd/scripts/board/atmel_sam3x_ek.cfg share/openocd/scripts/board/atmel_sam4e_ek.cfg share/openocd/scripts/board/atmel_sam4l8_xplained_pro.cfg share/openocd/scripts/board/atmel_sam4s_ek.cfg share/openocd/scripts/board/atmel_sam4s_xplained_pro.cfg share/openocd/scripts/board/atmel_samc20_xplained_pro.cfg share/openocd/scripts/board/atmel_samc21_xplained_pro.cfg share/openocd/scripts/board/atmel_samd10_xplained_mini.cfg share/openocd/scripts/board/atmel_samd11_xplained_pro.cfg share/openocd/scripts/board/atmel_samd20_xplained_pro.cfg share/openocd/scripts/board/atmel_samd21_xplained_pro.cfg share/openocd/scripts/board/atmel_same70_xplained.cfg share/openocd/scripts/board/atmel_samg53_xplained_pro.cfg share/openocd/scripts/board/atmel_samg55_xplained_pro.cfg share/openocd/scripts/board/atmel_saml21_xplained_pro.cfg share/openocd/scripts/board/atmel_samr21_xplained_pro.cfg share/openocd/scripts/board/atmel_samv71_xplained_ultra.cfg share/openocd/scripts/board/avnet_ultrazed-eg.cfg share/openocd/scripts/board/balloon3-cpu.cfg share/openocd/scripts/board/bcm28155_ap.cfg share/openocd/scripts/board/bluefield.cfg share/openocd/scripts/board/bt-homehubv1.cfg share/openocd/scripts/board/colibri.cfg share/openocd/scripts/board/crossbow_tech_imote2.cfg share/openocd/scripts/board/csb337.cfg share/openocd/scripts/board/csb732.cfg share/openocd/scripts/board/da850evm.cfg share/openocd/scripts/board/digi_connectcore_wi-9c.cfg share/openocd/scripts/board/digilent_analog_discovery.cfg share/openocd/scripts/board/digilent_atlys.cfg share/openocd/scripts/board/digilent_zedboard.cfg share/openocd/scripts/board/diolan_lpc4350-db1.cfg share/openocd/scripts/board/diolan_lpc4357-db1.cfg share/openocd/scripts/board/dk-tm4c129.cfg share/openocd/scripts/board/dm355evm.cfg share/openocd/scripts/board/dm365evm.cfg share/openocd/scripts/board/dm6446evm.cfg share/openocd/scripts/board/dp_busblaster_v3.cfg share/openocd/scripts/board/dp_busblaster_v4.cfg share/openocd/scripts/board/dptechnics_dpt-board-v1.cfg share/openocd/scripts/board/efikamx.cfg share/openocd/scripts/board/efm32.cfg share/openocd/scripts/board/eir.cfg share/openocd/scripts/board/ek-lm3s1968.cfg share/openocd/scripts/board/ek-lm3s3748.cfg share/openocd/scripts/board/ek-lm3s6965.cfg share/openocd/scripts/board/ek-lm3s811-revb.cfg share/openocd/scripts/board/ek-lm3s811.cfg share/openocd/scripts/board/ek-lm3s8962.cfg share/openocd/scripts/board/ek-lm3s9b9x.cfg share/openocd/scripts/board/ek-lm3s9d92.cfg share/openocd/scripts/board/ek-lm4f120xl.cfg share/openocd/scripts/board/ek-lm4f232.cfg share/openocd/scripts/board/ek-tm4c123gxl.cfg share/openocd/scripts/board/ek-tm4c1294xl.cfg share/openocd/scripts/board/embedded-artists_lpc2478-32.cfg share/openocd/scripts/board/emcraft_imx8m-som-bsb.cfg share/openocd/scripts/board/emcraft_twr-vf6-som-bsb.cfg share/openocd/scripts/board/emcraft_vf6-som.cfg share/openocd/scripts/board/ethernut3.cfg share/openocd/scripts/board/frdm-kl25z.cfg share/openocd/scripts/board/frdm-kl46z.cfg share/openocd/scripts/board/fsl_imx6q_sabresd.cfg share/openocd/scripts/board/glyn_tonga2.cfg share/openocd/scripts/board/gti/ share/openocd/scripts/board/gti/espressobin.cfg share/openocd/scripts/board/gumstix-aerocore.cfg share/openocd/scripts/board/hammer.cfg share/openocd/scripts/board/hilscher_nxdb500sys.cfg share/openocd/scripts/board/hilscher_nxeb500hmi.cfg share/openocd/scripts/board/hilscher_nxhx10.cfg share/openocd/scripts/board/hilscher_nxhx50.cfg share/openocd/scripts/board/hilscher_nxhx500.cfg share/openocd/scripts/board/hilscher_nxsb100.cfg share/openocd/scripts/board/hitex_lpc1768stick.cfg share/openocd/scripts/board/hitex_lpc2929.cfg share/openocd/scripts/board/hitex_stm32-performancestick.cfg share/openocd/scripts/board/hitex_str9-comstick.cfg share/openocd/scripts/board/iar_lpc1768.cfg share/openocd/scripts/board/iar_str912_sk.cfg share/openocd/scripts/board/icnova_imx53_sodimm.cfg share/openocd/scripts/board/icnova_sam9g45_sodimm.cfg share/openocd/scripts/board/imx27ads.cfg share/openocd/scripts/board/imx27lnst.cfg share/openocd/scripts/board/imx28evk.cfg share/openocd/scripts/board/imx31pdk.cfg share/openocd/scripts/board/imx35pdk.cfg share/openocd/scripts/board/imx53-m53evk.cfg share/openocd/scripts/board/imx53loco.cfg share/openocd/scripts/board/imx8mp-evk.cfg share/openocd/scripts/board/insignal_arndale.cfg share/openocd/scripts/board/kasli.cfg share/openocd/scripts/board/kc100.cfg share/openocd/scripts/board/kc705.cfg share/openocd/scripts/board/kcu105.cfg share/openocd/scripts/board/keil_mcb1700.cfg share/openocd/scripts/board/keil_mcb2140.cfg share/openocd/scripts/board/kindle2.cfg share/openocd/scripts/board/kwikstik.cfg share/openocd/scripts/board/la_fonera-fon2200.cfg share/openocd/scripts/board/lemaker_hikey.cfg share/openocd/scripts/board/linksys-wag200g.cfg share/openocd/scripts/board/linksys-wrt54gl.cfg share/openocd/scripts/board/linksys_nslu2.cfg share/openocd/scripts/board/lisa-l.cfg share/openocd/scripts/board/logicpd_imx27.cfg share/openocd/scripts/board/lpc1850_spifi_generic.cfg share/openocd/scripts/board/lpc4350_spifi_generic.cfg share/openocd/scripts/board/lubbock.cfg share/openocd/scripts/board/marsohod.cfg share/openocd/scripts/board/marsohod2.cfg share/openocd/scripts/board/marsohod3.cfg share/openocd/scripts/board/mbed-lpc11u24.cfg share/openocd/scripts/board/mbed-lpc1768.cfg share/openocd/scripts/board/mcb1700.cfg share/openocd/scripts/board/microchip_explorer16.cfg share/openocd/scripts/board/microchip_same54_xplained_pro.cfg share/openocd/scripts/board/microchip_saml11_xplained_pro.cfg share/openocd/scripts/board/mini2440.cfg share/openocd/scripts/board/mini6410.cfg share/openocd/scripts/board/minispartan6.cfg share/openocd/scripts/board/nds32_corvettef1.cfg share/openocd/scripts/board/nds32_xc5.cfg share/openocd/scripts/board/nds32_xc7.cfg share/openocd/scripts/board/netgear-dg834v3.cfg share/openocd/scripts/board/netgear-wg102.cfg share/openocd/scripts/board/nordic_nrf51822_mkit.cfg share/openocd/scripts/board/nordic_nrf51_dk.cfg share/openocd/scripts/board/nordic_nrf52_dk.cfg share/openocd/scripts/board/nordic_nrf52_ftx232.cfg share/openocd/scripts/board/novena-internal-fpga.cfg share/openocd/scripts/board/numato_mimas_a7.cfg share/openocd/scripts/board/numato_opsis.cfg share/openocd/scripts/board/nxp_frdm-ls1012a.cfg share/openocd/scripts/board/nxp_imx7sabre.cfg share/openocd/scripts/board/nxp_lpc-link2.cfg share/openocd/scripts/board/nxp_mcimx8m-evk.cfg share/openocd/scripts/board/olimex_LPC2378STK.cfg share/openocd/scripts/board/olimex_lpc_h2148.cfg share/openocd/scripts/board/olimex_sam7_ex256.cfg share/openocd/scripts/board/olimex_sam7_la2.cfg share/openocd/scripts/board/olimex_sam9_l9260.cfg share/openocd/scripts/board/olimex_stm32_h103.cfg share/openocd/scripts/board/olimex_stm32_h107.cfg share/openocd/scripts/board/olimex_stm32_p107.cfg share/openocd/scripts/board/omap2420_h4.cfg share/openocd/scripts/board/openrd.cfg share/openocd/scripts/board/or1k_generic.cfg share/openocd/scripts/board/osk5912.cfg share/openocd/scripts/board/phone_se_j100i.cfg share/openocd/scripts/board/phytec_lpc3250.cfg share/openocd/scripts/board/pic-p32mx.cfg share/openocd/scripts/board/pipistrello.cfg share/openocd/scripts/board/propox_mmnet1001.cfg share/openocd/scripts/board/pxa255_sst.cfg share/openocd/scripts/board/quark_d2000_refboard.cfg share/openocd/scripts/board/quark_x10xx_board.cfg share/openocd/scripts/board/quicklogic_quickfeather.cfg share/openocd/scripts/board/redbee.cfg share/openocd/scripts/board/reflexces_achilles_i-dev_kit_arria10.cfg share/openocd/scripts/board/renesas_dk-s7g2.cfg share/openocd/scripts/board/renesas_gr_peach.cfg share/openocd/scripts/board/renesas_porter.cfg share/openocd/scripts/board/renesas_salvator-xs.cfg share/openocd/scripts/board/renesas_silk.cfg share/openocd/scripts/board/renesas_stout.cfg share/openocd/scripts/board/rigado_bmd300_ek.cfg share/openocd/scripts/board/rsc-w910.cfg share/openocd/scripts/board/sayma_amc.cfg share/openocd/scripts/board/sheevaplug.cfg share/openocd/scripts/board/sifive-e31arty.cfg share/openocd/scripts/board/sifive-e51arty.cfg share/openocd/scripts/board/sifive-hifive1-revb.cfg share/openocd/scripts/board/sifive-hifive1.cfg share/openocd/scripts/board/smdk6410.cfg share/openocd/scripts/board/snps_em_sk.cfg share/openocd/scripts/board/snps_em_sk_v1.cfg share/openocd/scripts/board/snps_em_sk_v2.1.cfg share/openocd/scripts/board/snps_em_sk_v2.2.cfg share/openocd/scripts/board/snps_hsdk.cfg share/openocd/scripts/board/spansion_sk-fm4-176l-s6e2cc.cfg share/openocd/scripts/board/spansion_sk-fm4-u120-9b560.cfg share/openocd/scripts/board/spear300evb.cfg share/openocd/scripts/board/spear300evb_mod.cfg share/openocd/scripts/board/spear310evb20.cfg share/openocd/scripts/board/spear310evb20_mod.cfg share/openocd/scripts/board/spear320cpu.cfg share/openocd/scripts/board/spear320cpu_mod.cfg share/openocd/scripts/board/st_b-l475e-iot01a.cfg share/openocd/scripts/board/st_nucleo_8l152r8.cfg share/openocd/scripts/board/st_nucleo_f0.cfg share/openocd/scripts/board/st_nucleo_f103rb.cfg share/openocd/scripts/board/st_nucleo_f3.cfg share/openocd/scripts/board/st_nucleo_f4.cfg share/openocd/scripts/board/st_nucleo_f7.cfg share/openocd/scripts/board/st_nucleo_h743zi.cfg share/openocd/scripts/board/st_nucleo_h745zi.cfg share/openocd/scripts/board/st_nucleo_l073rz.cfg share/openocd/scripts/board/st_nucleo_l1.cfg share/openocd/scripts/board/st_nucleo_l4.cfg share/openocd/scripts/board/st_nucleo_l5.cfg share/openocd/scripts/board/st_nucleo_wb55.cfg share/openocd/scripts/board/steval-idb007v1.cfg share/openocd/scripts/board/steval-idb008v1.cfg share/openocd/scripts/board/steval-idb011v1.cfg share/openocd/scripts/board/steval_pcc010.cfg share/openocd/scripts/board/stm320518_eval.cfg share/openocd/scripts/board/stm320518_eval_stlink.cfg share/openocd/scripts/board/stm32100b_eval.cfg share/openocd/scripts/board/stm3210b_eval.cfg share/openocd/scripts/board/stm3210c_eval.cfg share/openocd/scripts/board/stm3210e_eval.cfg share/openocd/scripts/board/stm3220g_eval.cfg share/openocd/scripts/board/stm3220g_eval_stlink.cfg share/openocd/scripts/board/stm3241g_eval.cfg share/openocd/scripts/board/stm3241g_eval_stlink.cfg share/openocd/scripts/board/stm32429i_eval.cfg share/openocd/scripts/board/stm32429i_eval_stlink.cfg share/openocd/scripts/board/stm32439i_eval.cfg share/openocd/scripts/board/stm32439i_eval_stlink.cfg share/openocd/scripts/board/stm327x6g_eval.cfg share/openocd/scripts/board/stm32f0discovery.cfg share/openocd/scripts/board/stm32f103c8_blue_pill.cfg share/openocd/scripts/board/stm32f334discovery.cfg share/openocd/scripts/board/stm32f3discovery.cfg share/openocd/scripts/board/stm32f412g-disco.cfg share/openocd/scripts/board/stm32f413h-disco.cfg share/openocd/scripts/board/stm32f429disc1.cfg share/openocd/scripts/board/stm32f429discovery.cfg share/openocd/scripts/board/stm32f469discovery.cfg share/openocd/scripts/board/stm32f469i-disco.cfg share/openocd/scripts/board/stm32f4discovery.cfg share/openocd/scripts/board/stm32f723e-disco.cfg share/openocd/scripts/board/stm32f746g-disco.cfg share/openocd/scripts/board/stm32f769i-disco.cfg share/openocd/scripts/board/stm32f7discovery.cfg share/openocd/scripts/board/stm32h735g-disco.cfg share/openocd/scripts/board/stm32h745i-disco.cfg share/openocd/scripts/board/stm32h747i-disco.cfg share/openocd/scripts/board/stm32h750b-disco.cfg share/openocd/scripts/board/stm32h7b3i-disco.cfg share/openocd/scripts/board/stm32h7x3i_eval.cfg share/openocd/scripts/board/stm32h7x_dual_qspi.cfg share/openocd/scripts/board/stm32l0discovery.cfg share/openocd/scripts/board/stm32l476g-disco.cfg share/openocd/scripts/board/stm32l496g-disco.cfg share/openocd/scripts/board/stm32l4discovery.cfg share/openocd/scripts/board/stm32l4p5g-disco.cfg share/openocd/scripts/board/stm32l4r9i-disco.cfg share/openocd/scripts/board/stm32ldiscovery.cfg share/openocd/scripts/board/stm32mp15x_dk2.cfg share/openocd/scripts/board/stm32vldiscovery.cfg share/openocd/scripts/board/str910-eval.cfg share/openocd/scripts/board/telo.cfg share/openocd/scripts/board/ti_am335xevm.cfg share/openocd/scripts/board/ti_am437x_idk.cfg share/openocd/scripts/board/ti_am43xx_evm.cfg share/openocd/scripts/board/ti_beagleboard.cfg share/openocd/scripts/board/ti_beagleboard_xm.cfg share/openocd/scripts/board/ti_beaglebone-base.cfg share/openocd/scripts/board/ti_beaglebone.cfg share/openocd/scripts/board/ti_beaglebone_black.cfg share/openocd/scripts/board/ti_blaze.cfg share/openocd/scripts/board/ti_cc13x0_launchpad.cfg share/openocd/scripts/board/ti_cc13x2_launchpad.cfg share/openocd/scripts/board/ti_cc26x0_launchpad.cfg share/openocd/scripts/board/ti_cc26x2_launchpad.cfg share/openocd/scripts/board/ti_cc3200_launchxl.cfg share/openocd/scripts/board/ti_cc3220sf_launchpad.cfg share/openocd/scripts/board/ti_cc32xx_launchpad.cfg share/openocd/scripts/board/ti_dk-tm4c129.cfg share/openocd/scripts/board/ti_ek-tm4c123gxl.cfg share/openocd/scripts/board/ti_ek-tm4c1294xl.cfg share/openocd/scripts/board/ti_msp432_launchpad.cfg share/openocd/scripts/board/ti_pandaboard.cfg share/openocd/scripts/board/ti_pandaboard_es.cfg share/openocd/scripts/board/ti_tmdx570ls20susb.cfg share/openocd/scripts/board/ti_tmdx570ls31usb.cfg share/openocd/scripts/board/tocoding_poplar.cfg share/openocd/scripts/board/topas910.cfg share/openocd/scripts/board/topasa900.cfg share/openocd/scripts/board/tp-link_tl-mr3020.cfg share/openocd/scripts/board/tp-link_wdr4300.cfg share/openocd/scripts/board/twr-k60f120m.cfg share/openocd/scripts/board/twr-k60n512.cfg share/openocd/scripts/board/twr-vf65gs10.cfg share/openocd/scripts/board/twr-vf65gs10_cmsisdap.cfg share/openocd/scripts/board/tx25_stk5.cfg share/openocd/scripts/board/tx27_stk5.cfg share/openocd/scripts/board/unknown_at91sam9260.cfg share/openocd/scripts/board/uptech_2410.cfg share/openocd/scripts/board/verdex.cfg share/openocd/scripts/board/voipac.cfg share/openocd/scripts/board/voltcraft_dso-3062c.cfg share/openocd/scripts/board/x300t.cfg share/openocd/scripts/board/xmc-2go.cfg share/openocd/scripts/board/xmc1100-boot-kit.cfg share/openocd/scripts/board/xmc4200-application-kit-actuator.cfg share/openocd/scripts/board/xmc4300-relax.cfg share/openocd/scripts/board/xmc4500-application-kit-general.cfg share/openocd/scripts/board/xmc4500-application-kit-sdram.cfg share/openocd/scripts/board/xmc4500-relax.cfg share/openocd/scripts/board/xmc4700-relax.cfg share/openocd/scripts/board/xmc4800-relax.cfg share/openocd/scripts/board/xmos_xk-xac-xa8_arm.cfg share/openocd/scripts/board/zy1000.cfg share/openocd/scripts/chip/ share/openocd/scripts/chip/atmel/ share/openocd/scripts/chip/atmel/at91/ share/openocd/scripts/chip/atmel/at91/aic.tcl share/openocd/scripts/chip/atmel/at91/at91_pio.cfg share/openocd/scripts/chip/atmel/at91/at91_pmc.cfg share/openocd/scripts/chip/atmel/at91/at91_rstc.cfg share/openocd/scripts/chip/atmel/at91/at91_wdt.cfg share/openocd/scripts/chip/atmel/at91/at91sam7x128.tcl share/openocd/scripts/chip/atmel/at91/at91sam7x256.tcl share/openocd/scripts/chip/atmel/at91/at91sam9261.cfg share/openocd/scripts/chip/atmel/at91/at91sam9261_matrix.cfg share/openocd/scripts/chip/atmel/at91/at91sam9263.cfg share/openocd/scripts/chip/atmel/at91/at91sam9263_matrix.cfg share/openocd/scripts/chip/atmel/at91/at91sam9_init.cfg share/openocd/scripts/chip/atmel/at91/at91sam9_sdramc.cfg share/openocd/scripts/chip/atmel/at91/at91sam9_smc.cfg share/openocd/scripts/chip/atmel/at91/hardware.cfg share/openocd/scripts/chip/atmel/at91/pmc.tcl share/openocd/scripts/chip/atmel/at91/rtt.tcl share/openocd/scripts/chip/atmel/at91/sam9_smc.cfg share/openocd/scripts/chip/atmel/at91/usarts.tcl share/openocd/scripts/chip/st/ share/openocd/scripts/chip/st/spear/ share/openocd/scripts/chip/st/spear/quirk_no_srst.tcl share/openocd/scripts/chip/st/spear/spear3xx.tcl share/openocd/scripts/chip/st/spear/spear3xx_ddr.tcl share/openocd/scripts/chip/st/stm32/ share/openocd/scripts/chip/st/stm32/stm32.tcl share/openocd/scripts/chip/st/stm32/stm32_rcc.tcl share/openocd/scripts/chip/st/stm32/stm32_regs.tcl share/openocd/scripts/chip/ti/ share/openocd/scripts/chip/ti/lm3s/ share/openocd/scripts/chip/ti/lm3s/lm3s.tcl share/openocd/scripts/chip/ti/lm3s/lm3s_regs.tcl share/openocd/scripts/cpld/ share/openocd/scripts/cpld/altera-5m570z-cpld.cfg share/openocd/scripts/cpld/altera-epm240.cfg share/openocd/scripts/cpld/jtagspi.cfg share/openocd/scripts/cpld/lattice-lc4032ze.cfg share/openocd/scripts/cpld/xilinx-xc6s.cfg share/openocd/scripts/cpld/xilinx-xc7.cfg share/openocd/scripts/cpld/xilinx-xcf-p.cfg share/openocd/scripts/cpld/xilinx-xcf-s.cfg share/openocd/scripts/cpld/xilinx-xcr3256.cfg share/openocd/scripts/cpld/xilinx-xcu.cfg share/openocd/scripts/cpu/ share/openocd/scripts/cpu/arc/ share/openocd/scripts/cpu/arc/common.tcl share/openocd/scripts/cpu/arc/em.tcl share/openocd/scripts/cpu/arc/hs.tcl share/openocd/scripts/cpu/arc/v2.tcl share/openocd/scripts/cpu/arm/ share/openocd/scripts/cpu/arm/arm7tdmi.tcl share/openocd/scripts/cpu/arm/arm920.tcl share/openocd/scripts/cpu/arm/arm946.tcl share/openocd/scripts/cpu/arm/arm966.tcl share/openocd/scripts/cpu/arm/cortex_m3.tcl share/openocd/scripts/fpga/ share/openocd/scripts/fpga/altera-10m50.cfg share/openocd/scripts/fpga/altera-ep3c10.cfg share/openocd/scripts/fpga/xilinx-dna.cfg share/openocd/scripts/fpga/xilinx-xadc.cfg share/openocd/scripts/interface/ share/openocd/scripts/interface/altera-usb-blaster.cfg share/openocd/scripts/interface/altera-usb-blaster2.cfg share/openocd/scripts/interface/arm-jtag-ew.cfg share/openocd/scripts/interface/at91rm9200.cfg share/openocd/scripts/interface/buspirate.cfg share/openocd/scripts/interface/calao-usb-a9260.cfg share/openocd/scripts/interface/chameleon.cfg share/openocd/scripts/interface/cmsis-dap.cfg share/openocd/scripts/interface/dln-2-gpiod.cfg share/openocd/scripts/interface/dummy.cfg share/openocd/scripts/interface/estick.cfg share/openocd/scripts/interface/flashlink.cfg share/openocd/scripts/interface/ft232r.cfg share/openocd/scripts/interface/ftdi/ share/openocd/scripts/interface/ftdi/100ask-openjtag.cfg share/openocd/scripts/interface/ftdi/axm0432.cfg share/openocd/scripts/interface/ftdi/c232hm.cfg share/openocd/scripts/interface/ftdi/calao-usb-a9260-c01.cfg share/openocd/scripts/interface/ftdi/calao-usb-a9260-c02.cfg share/openocd/scripts/interface/ftdi/cortino.cfg share/openocd/scripts/interface/ftdi/digilent-hs1.cfg share/openocd/scripts/interface/ftdi/digilent-hs2.cfg share/openocd/scripts/interface/ftdi/digilent_jtag_hs3.cfg share/openocd/scripts/interface/ftdi/digilent_jtag_smt2.cfg share/openocd/scripts/interface/ftdi/digilent_jtag_smt2_nc.cfg share/openocd/scripts/interface/ftdi/dlp-usb1232h.cfg share/openocd/scripts/interface/ftdi/dp_busblaster.cfg share/openocd/scripts/interface/ftdi/dp_busblaster_kt-link.cfg share/openocd/scripts/interface/ftdi/flossjtag-noeeprom.cfg share/openocd/scripts/interface/ftdi/flossjtag.cfg share/openocd/scripts/interface/ftdi/flyswatter.cfg share/openocd/scripts/interface/ftdi/flyswatter2.cfg share/openocd/scripts/interface/ftdi/ft232h-module-swd.cfg share/openocd/scripts/interface/ftdi/gw16042.cfg share/openocd/scripts/interface/ftdi/hie-jtag.cfg share/openocd/scripts/interface/ftdi/hilscher_nxhx10_etm.cfg share/openocd/scripts/interface/ftdi/hilscher_nxhx500_etm.cfg share/openocd/scripts/interface/ftdi/hilscher_nxhx500_re.cfg share/openocd/scripts/interface/ftdi/hilscher_nxhx50_etm.cfg share/openocd/scripts/interface/ftdi/hilscher_nxhx50_re.cfg share/openocd/scripts/interface/ftdi/hitex_lpc1768stick.cfg share/openocd/scripts/interface/ftdi/hitex_str9-comstick.cfg share/openocd/scripts/interface/ftdi/icebear.cfg share/openocd/scripts/interface/ftdi/imx8mp-evk.cfg share/openocd/scripts/interface/ftdi/incircuit-icprog.cfg share/openocd/scripts/interface/ftdi/iotlab-usb.cfg share/openocd/scripts/interface/ftdi/isodebug.cfg share/openocd/scripts/interface/ftdi/jtag-lock-pick_tiny_2.cfg share/openocd/scripts/interface/ftdi/jtagkey.cfg share/openocd/scripts/interface/ftdi/jtagkey2.cfg share/openocd/scripts/interface/ftdi/jtagkey2p.cfg share/openocd/scripts/interface/ftdi/kt-link.cfg share/openocd/scripts/interface/ftdi/lisa-l.cfg share/openocd/scripts/interface/ftdi/luminary-icdi.cfg share/openocd/scripts/interface/ftdi/luminary-lm3s811.cfg share/openocd/scripts/interface/ftdi/luminary.cfg share/openocd/scripts/interface/ftdi/m53evk.cfg share/openocd/scripts/interface/ftdi/mbftdi.cfg share/openocd/scripts/interface/ftdi/minimodule-swd.cfg share/openocd/scripts/interface/ftdi/minimodule.cfg share/openocd/scripts/interface/ftdi/minispartan6.cfg share/openocd/scripts/interface/ftdi/neodb.cfg share/openocd/scripts/interface/ftdi/ngxtech.cfg share/openocd/scripts/interface/ftdi/olimex-arm-jtag-swd.cfg share/openocd/scripts/interface/ftdi/olimex-arm-usb-ocd-h.cfg share/openocd/scripts/interface/ftdi/olimex-arm-usb-ocd.cfg share/openocd/scripts/interface/ftdi/olimex-arm-usb-tiny-h.cfg share/openocd/scripts/interface/ftdi/olimex-jtag-tiny.cfg share/openocd/scripts/interface/ftdi/oocdlink.cfg share/openocd/scripts/interface/ftdi/opendous_ftdi.cfg share/openocd/scripts/interface/ftdi/openocd-usb-hs.cfg share/openocd/scripts/interface/ftdi/openocd-usb.cfg share/openocd/scripts/interface/ftdi/openrd.cfg share/openocd/scripts/interface/ftdi/pipistrello.cfg share/openocd/scripts/interface/ftdi/redbee-econotag.cfg share/openocd/scripts/interface/ftdi/redbee-usb.cfg share/openocd/scripts/interface/ftdi/rowley-cc-arm-swd.cfg share/openocd/scripts/interface/ftdi/sheevaplug.cfg share/openocd/scripts/interface/ftdi/signalyzer-lite.cfg share/openocd/scripts/interface/ftdi/signalyzer.cfg share/openocd/scripts/interface/ftdi/snps_sdp.cfg share/openocd/scripts/interface/ftdi/steppenprobe.cfg share/openocd/scripts/interface/ftdi/stm32-stick.cfg share/openocd/scripts/interface/ftdi/swd-resistor-hack.cfg share/openocd/scripts/interface/ftdi/ti-icdi.cfg share/openocd/scripts/interface/ftdi/tumpa-lite.cfg share/openocd/scripts/interface/ftdi/tumpa.cfg share/openocd/scripts/interface/ftdi/turtelizer2-revB.cfg share/openocd/scripts/interface/ftdi/turtelizer2-revC.cfg share/openocd/scripts/interface/ftdi/um232h.cfg share/openocd/scripts/interface/ftdi/vpaclink.cfg share/openocd/scripts/interface/ftdi/xds100v2.cfg share/openocd/scripts/interface/ftdi/xds100v3.cfg share/openocd/scripts/interface/imx-native.cfg share/openocd/scripts/interface/jlink.cfg share/openocd/scripts/interface/jtag_dpi.cfg share/openocd/scripts/interface/jtag_vpi.cfg share/openocd/scripts/interface/kitprog.cfg share/openocd/scripts/interface/nds32-aice.cfg share/openocd/scripts/interface/nulink.cfg share/openocd/scripts/interface/opendous.cfg share/openocd/scripts/interface/openjtag.cfg share/openocd/scripts/interface/osbdm.cfg share/openocd/scripts/interface/parport.cfg share/openocd/scripts/interface/parport_dlc5.cfg share/openocd/scripts/interface/raspberrypi-native.cfg share/openocd/scripts/interface/raspberrypi2-native.cfg share/openocd/scripts/interface/rlink.cfg share/openocd/scripts/interface/rshim.cfg share/openocd/scripts/interface/stlink-dap.cfg share/openocd/scripts/interface/stlink-v1.cfg share/openocd/scripts/interface/stlink-v2-1.cfg share/openocd/scripts/interface/stlink-v2.cfg share/openocd/scripts/interface/stlink.cfg share/openocd/scripts/interface/sysfsgpio-raspberrypi.cfg share/openocd/scripts/interface/ti-icdi.cfg share/openocd/scripts/interface/ulink.cfg share/openocd/scripts/interface/usb-jtag.cfg share/openocd/scripts/interface/usbprog.cfg share/openocd/scripts/interface/vsllink.cfg share/openocd/scripts/interface/xds110.cfg share/openocd/scripts/mem_helper.tcl share/openocd/scripts/memory.tcl share/openocd/scripts/mmr_helpers.tcl share/openocd/scripts/target/ share/openocd/scripts/target/1986ве1т.cfg share/openocd/scripts/target/adsp-sc58x.cfg share/openocd/scripts/target/aduc702x.cfg share/openocd/scripts/target/aducm360.cfg share/openocd/scripts/target/allwinner_v3s.cfg share/openocd/scripts/target/alphascale_asm9260t.cfg share/openocd/scripts/target/altera_fpgasoc.cfg share/openocd/scripts/target/altera_fpgasoc_arria10.cfg share/openocd/scripts/target/am335x.cfg share/openocd/scripts/target/am437x.cfg share/openocd/scripts/target/amdm37x.cfg share/openocd/scripts/target/ar71xx.cfg share/openocd/scripts/target/arm_corelink_sse200.cfg share/openocd/scripts/target/armada370.cfg share/openocd/scripts/target/at32ap7000.cfg share/openocd/scripts/target/at91r40008.cfg share/openocd/scripts/target/at91rm9200.cfg share/openocd/scripts/target/at91sam3XXX.cfg share/openocd/scripts/target/at91sam3ax_4x.cfg share/openocd/scripts/target/at91sam3ax_8x.cfg share/openocd/scripts/target/at91sam3ax_xx.cfg share/openocd/scripts/target/at91sam3nXX.cfg share/openocd/scripts/target/at91sam3sXX.cfg share/openocd/scripts/target/at91sam3u1c.cfg share/openocd/scripts/target/at91sam3u1e.cfg share/openocd/scripts/target/at91sam3u2c.cfg share/openocd/scripts/target/at91sam3u2e.cfg share/openocd/scripts/target/at91sam3u4c.cfg share/openocd/scripts/target/at91sam3u4e.cfg share/openocd/scripts/target/at91sam3uxx.cfg share/openocd/scripts/target/at91sam4XXX.cfg share/openocd/scripts/target/at91sam4c32x.cfg share/openocd/scripts/target/at91sam4cXXX.cfg share/openocd/scripts/target/at91sam4lXX.cfg share/openocd/scripts/target/at91sam4sXX.cfg share/openocd/scripts/target/at91sam4sd32x.cfg share/openocd/scripts/target/at91sam7a2.cfg share/openocd/scripts/target/at91sam7se512.cfg share/openocd/scripts/target/at91sam7sx.cfg share/openocd/scripts/target/at91sam7x256.cfg share/openocd/scripts/target/at91sam7x512.cfg share/openocd/scripts/target/at91sam9.cfg share/openocd/scripts/target/at91sam9260.cfg share/openocd/scripts/target/at91sam9260_ext_RAM_ext_flash.cfg share/openocd/scripts/target/at91sam9261.cfg share/openocd/scripts/target/at91sam9263.cfg share/openocd/scripts/target/at91sam9g10.cfg share/openocd/scripts/target/at91sam9g20.cfg share/openocd/scripts/target/at91sam9g45.cfg share/openocd/scripts/target/at91sam9rl.cfg share/openocd/scripts/target/at91samdXX.cfg share/openocd/scripts/target/at91samg5x.cfg share/openocd/scripts/target/atheros_ar2313.cfg share/openocd/scripts/target/atheros_ar2315.cfg share/openocd/scripts/target/atheros_ar9331.cfg share/openocd/scripts/target/atheros_ar9344.cfg share/openocd/scripts/target/atmega128.cfg share/openocd/scripts/target/atmega128rfa1.cfg share/openocd/scripts/target/atsame5x.cfg share/openocd/scripts/target/atsaml1x.cfg share/openocd/scripts/target/atsamv.cfg share/openocd/scripts/target/avr32.cfg share/openocd/scripts/target/bcm281xx.cfg share/openocd/scripts/target/bcm4706.cfg share/openocd/scripts/target/bcm4718.cfg share/openocd/scripts/target/bcm47xx.cfg share/openocd/scripts/target/bcm5352e.cfg share/openocd/scripts/target/bcm6348.cfg share/openocd/scripts/target/bluefield.cfg share/openocd/scripts/target/bluenrg-x.cfg share/openocd/scripts/target/c100.cfg share/openocd/scripts/target/c100config.tcl share/openocd/scripts/target/c100helper.tcl share/openocd/scripts/target/c100regs.tcl share/openocd/scripts/target/cc2538.cfg share/openocd/scripts/target/cs351x.cfg share/openocd/scripts/target/davinci.cfg share/openocd/scripts/target/dragonite.cfg share/openocd/scripts/target/dsp56321.cfg share/openocd/scripts/target/dsp568013.cfg share/openocd/scripts/target/dsp568037.cfg share/openocd/scripts/target/efm32.cfg share/openocd/scripts/target/em357.cfg share/openocd/scripts/target/em358.cfg share/openocd/scripts/target/eos_s3.cfg share/openocd/scripts/target/epc9301.cfg share/openocd/scripts/target/esi32xx.cfg share/openocd/scripts/target/exynos5250.cfg share/openocd/scripts/target/faux.cfg share/openocd/scripts/target/feroceon.cfg share/openocd/scripts/target/fm3.cfg share/openocd/scripts/target/fm4.cfg share/openocd/scripts/target/fm4_mb9bf.cfg share/openocd/scripts/target/fm4_s6e2cc.cfg share/openocd/scripts/target/gd32vf103.cfg share/openocd/scripts/target/gp326xxxa.cfg share/openocd/scripts/target/hi3798.cfg share/openocd/scripts/target/hi6220.cfg share/openocd/scripts/target/hilscher_netx10.cfg share/openocd/scripts/target/hilscher_netx50.cfg share/openocd/scripts/target/hilscher_netx500.cfg share/openocd/scripts/target/icepick.cfg share/openocd/scripts/target/imx.cfg share/openocd/scripts/target/imx21.cfg share/openocd/scripts/target/imx25.cfg share/openocd/scripts/target/imx27.cfg share/openocd/scripts/target/imx28.cfg share/openocd/scripts/target/imx31.cfg share/openocd/scripts/target/imx35.cfg share/openocd/scripts/target/imx51.cfg share/openocd/scripts/target/imx53.cfg share/openocd/scripts/target/imx6.cfg share/openocd/scripts/target/imx6sx.cfg share/openocd/scripts/target/imx6ul.cfg share/openocd/scripts/target/imx7.cfg share/openocd/scripts/target/imx7ulp.cfg share/openocd/scripts/target/imx8m.cfg share/openocd/scripts/target/infineon/ share/openocd/scripts/target/infineon/tle987x.cfg share/openocd/scripts/target/is5114.cfg share/openocd/scripts/target/ixp42x.cfg share/openocd/scripts/target/k1921vk01t.cfg share/openocd/scripts/target/k40.cfg share/openocd/scripts/target/k60.cfg share/openocd/scripts/target/ke0x.cfg share/openocd/scripts/target/ke1xf.cfg share/openocd/scripts/target/ke1xz.cfg share/openocd/scripts/target/kl25.cfg share/openocd/scripts/target/kl46.cfg share/openocd/scripts/target/klx.cfg share/openocd/scripts/target/ks869x.cfg share/openocd/scripts/target/kx.cfg share/openocd/scripts/target/lpc11xx.cfg share/openocd/scripts/target/lpc12xx.cfg share/openocd/scripts/target/lpc13xx.cfg share/openocd/scripts/target/lpc17xx.cfg share/openocd/scripts/target/lpc1850.cfg share/openocd/scripts/target/lpc1xxx.cfg share/openocd/scripts/target/lpc2103.cfg share/openocd/scripts/target/lpc2124.cfg share/openocd/scripts/target/lpc2129.cfg share/openocd/scripts/target/lpc2148.cfg share/openocd/scripts/target/lpc2294.cfg share/openocd/scripts/target/lpc2378.cfg share/openocd/scripts/target/lpc2460.cfg share/openocd/scripts/target/lpc2478.cfg share/openocd/scripts/target/lpc2900.cfg share/openocd/scripts/target/lpc2xxx.cfg share/openocd/scripts/target/lpc3131.cfg share/openocd/scripts/target/lpc3250.cfg share/openocd/scripts/target/lpc40xx.cfg share/openocd/scripts/target/lpc4350.cfg share/openocd/scripts/target/lpc4357.cfg share/openocd/scripts/target/lpc4370.cfg share/openocd/scripts/target/lpc84x.cfg share/openocd/scripts/target/lpc8nxx.cfg share/openocd/scripts/target/lpc8xx.cfg share/openocd/scripts/target/ls1012a.cfg share/openocd/scripts/target/marvell/ share/openocd/scripts/target/marvell/88f3710.cfg share/openocd/scripts/target/marvell/88f3720.cfg share/openocd/scripts/target/marvell/88f37x0.cfg share/openocd/scripts/target/max32620.cfg share/openocd/scripts/target/max32625.cfg share/openocd/scripts/target/max3263x.cfg share/openocd/scripts/target/mc13224v.cfg share/openocd/scripts/target/mdr32f9q2i.cfg share/openocd/scripts/target/nds32v2.cfg share/openocd/scripts/target/nds32v3.cfg share/openocd/scripts/target/nds32v3m.cfg share/openocd/scripts/target/nds32v5.cfg share/openocd/scripts/target/nhs31xx.cfg share/openocd/scripts/target/nrf51.cfg share/openocd/scripts/target/nrf52.cfg share/openocd/scripts/target/nuc910.cfg share/openocd/scripts/target/numicro.cfg share/openocd/scripts/target/omap2420.cfg share/openocd/scripts/target/omap3530.cfg share/openocd/scripts/target/omap4430.cfg share/openocd/scripts/target/omap4460.cfg share/openocd/scripts/target/omap5912.cfg share/openocd/scripts/target/omapl138.cfg share/openocd/scripts/target/or1k.cfg share/openocd/scripts/target/pic32mx.cfg share/openocd/scripts/target/psoc4.cfg share/openocd/scripts/target/psoc5lp.cfg share/openocd/scripts/target/psoc6.cfg share/openocd/scripts/target/pxa255.cfg share/openocd/scripts/target/pxa270.cfg share/openocd/scripts/target/pxa3xx.cfg share/openocd/scripts/target/qualcomm_qca4531.cfg share/openocd/scripts/target/quark_d20xx.cfg share/openocd/scripts/target/quark_x10xx.cfg share/openocd/scripts/target/readme.txt share/openocd/scripts/target/renesas_r7s72100.cfg share/openocd/scripts/target/renesas_rcar_gen2.cfg share/openocd/scripts/target/renesas_rcar_gen3.cfg share/openocd/scripts/target/renesas_rcar_reset_common.cfg share/openocd/scripts/target/renesas_s7g2.cfg share/openocd/scripts/target/rk3308.cfg share/openocd/scripts/target/samsung_s3c2410.cfg share/openocd/scripts/target/samsung_s3c2440.cfg share/openocd/scripts/target/samsung_s3c2450.cfg share/openocd/scripts/target/samsung_s3c4510.cfg share/openocd/scripts/target/samsung_s3c6410.cfg share/openocd/scripts/target/sharp_lh79532.cfg share/openocd/scripts/target/sim3x.cfg share/openocd/scripts/target/smp8634.cfg share/openocd/scripts/target/snps_em_sk_fpga.cfg share/openocd/scripts/target/snps_hsdk.cfg share/openocd/scripts/target/spear3xx.cfg share/openocd/scripts/target/stellaris.cfg share/openocd/scripts/target/stm32f0x.cfg share/openocd/scripts/target/stm32f1x.cfg share/openocd/scripts/target/stm32f2x.cfg share/openocd/scripts/target/stm32f3x.cfg share/openocd/scripts/target/stm32f4x.cfg share/openocd/scripts/target/stm32f7x.cfg share/openocd/scripts/target/stm32g0x.cfg share/openocd/scripts/target/stm32g4x.cfg share/openocd/scripts/target/stm32h7x.cfg share/openocd/scripts/target/stm32h7x_dual_bank.cfg share/openocd/scripts/target/stm32l0.cfg share/openocd/scripts/target/stm32l0_dual_bank.cfg share/openocd/scripts/target/stm32l1.cfg share/openocd/scripts/target/stm32l1x_dual_bank.cfg share/openocd/scripts/target/stm32l4x.cfg share/openocd/scripts/target/stm32l5x.cfg share/openocd/scripts/target/stm32mp15x.cfg share/openocd/scripts/target/stm32w108xx.cfg share/openocd/scripts/target/stm32wbx.cfg share/openocd/scripts/target/stm32wlx.cfg share/openocd/scripts/target/stm32xl.cfg share/openocd/scripts/target/stm8l.cfg share/openocd/scripts/target/stm8l152.cfg share/openocd/scripts/target/stm8s.cfg share/openocd/scripts/target/stm8s003.cfg share/openocd/scripts/target/stm8s103.cfg share/openocd/scripts/target/stm8s105.cfg share/openocd/scripts/target/str710.cfg share/openocd/scripts/target/str730.cfg share/openocd/scripts/target/str750.cfg share/openocd/scripts/target/str912.cfg share/openocd/scripts/target/swj-dp.tcl share/openocd/scripts/target/swm050.cfg share/openocd/scripts/target/test_reset_syntax_error.cfg share/openocd/scripts/target/test_syntax_error.cfg share/openocd/scripts/target/ti-ar7.cfg share/openocd/scripts/target/ti-cjtag.cfg share/openocd/scripts/target/ti_calypso.cfg share/openocd/scripts/target/ti_cc13x0.cfg share/openocd/scripts/target/ti_cc13x2.cfg share/openocd/scripts/target/ti_cc26x0.cfg share/openocd/scripts/target/ti_cc26x2.cfg share/openocd/scripts/target/ti_cc3220sf.cfg share/openocd/scripts/target/ti_cc32xx.cfg share/openocd/scripts/target/ti_dm355.cfg share/openocd/scripts/target/ti_dm365.cfg share/openocd/scripts/target/ti_dm6446.cfg share/openocd/scripts/target/ti_msp432.cfg share/openocd/scripts/target/ti_rm4x.cfg share/openocd/scripts/target/ti_tms570.cfg share/openocd/scripts/target/ti_tms570ls20xxx.cfg share/openocd/scripts/target/ti_tms570ls3137.cfg share/openocd/scripts/target/tmpa900.cfg share/openocd/scripts/target/tmpa910.cfg share/openocd/scripts/target/tnetc4401.cfg share/openocd/scripts/target/u8500.cfg share/openocd/scripts/target/vybrid_vf6xx.cfg share/openocd/scripts/target/xilinx_zynqmp.cfg share/openocd/scripts/target/xmc1xxx.cfg share/openocd/scripts/target/xmc4xxx.cfg share/openocd/scripts/target/xmos_xs1-xau8a-10_arm.cfg share/openocd/scripts/target/zynq_7000.cfg share/openocd/scripts/target/к1879xб1я.cfg share/openocd/scripts/test/ share/openocd/scripts/test/selftest.cfg share/openocd/scripts/test/syntax1.cfg share/openocd/scripts/tools/ share/openocd/scripts/tools/firmware-recovery.tcl share/openocd/scripts/tools/memtest.tcl ================================================ FILE: tools/openbsd/ports/mystuff/devel/arm-none-eabi/Makefile ================================================ SUBDIR = SUBDIR += binutils SUBDIR += binutils,aarch64 SUBDIR += gcc SUBDIR += gcc,aarch64 SUBDIR += gdb SUBDIR += newlib .include ================================================ FILE: tools/openbsd/ports/mystuff/devel/arm-none-eabi/Makefile.inc ================================================ CONFIG?= arm-none-eabi PKGNAME?= ${CONFIG}-${DISTNAME} FULLPKGNAME?= ${PKGNAME} CATEGORIES+= devel # GPLv3 # For newlib: multiple copyrights, but basically BSD. # See: ${PREFIX}/share/doc/newlib PERMIT_PACKAGE= Yes CONFIGURE_STYLE=gnu CONFIGURE_ARGS+=--target=${CONFIG} \ --disable-shared \ --disable-nls \ --disable-werror EXTRACT_SUFX?= .tar.xz ================================================ FILE: tools/openbsd/ports/mystuff/devel/arm-none-eabi/binutils/Makefile ================================================ COMMENT= binutils for ${CONFIG} cross-development VERSION= 2.40 DISTNAME= binutils-${VERSION} FLAVORS= aarch64 arm FLAVOR?= arm .if "${FLAVOR}" == "aarch64" CONFIG= aarch64-none-elf .elif "${FLAVOR}" == "arm" CONFIG= arm-none-eabi .else ERRORS+= "either aarch64 or arm FLAVOR should be set" .endif HOMEPAGE= https://www.gnu.org/software/binutils/ WANTLIB= c z SITES= ${SITE_GNU:=binutils/} DIST_SUBDIR= binutils USE_GMAKE= Yes USE_LIBTOOL= No CONFIGURE_ARGS+=--enable-commonbfdlib=no \ --enable-interwork \ --enable-multilib \ --without-zstd SUBST_VARS += CONFIG .include ================================================ FILE: tools/openbsd/ports/mystuff/devel/arm-none-eabi/binutils/distinfo ================================================ SHA256 (binutils/binutils-2.40.tar.xz) = D4pMJy1/F/Np3tEKSsoouOMEgo6VUm2kgrDMxN/J2OE= SIZE (binutils/binutils-2.40.tar.xz) = 25241484 ================================================ FILE: tools/openbsd/ports/mystuff/devel/arm-none-eabi/binutils/patches/patch-bfd_Makefile_in ================================================ Index: bfd/Makefile.in --- bfd/Makefile.in.orig +++ bfd/Makefile.in @@ -266,7 +266,7 @@ am__v_texidevnull_ = $(am__v_texidevnull_@AM_DEFAULT_V am__v_texidevnull_0 = > /dev/null am__v_texidevnull_1 = am__dirstamp = $(am__leading_dot)dirstamp -INFO_DEPS = doc/bfd.info +INFO_DEPS = am__TEXINFO_TEX_DIR = $(srcdir) DVIS = doc/bfd.dvi PDFS = doc/bfd.pdf ================================================ FILE: tools/openbsd/ports/mystuff/devel/arm-none-eabi/binutils/patches/patch-binutils_Makefile_in ================================================ Index: binutils/Makefile.in --- binutils/Makefile.in.orig +++ binutils/Makefile.in @@ -404,7 +404,7 @@ AM_V_texidevnull = $(am__v_texidevnull_@AM_V@) am__v_texidevnull_ = $(am__v_texidevnull_@AM_DEFAULT_V@) am__v_texidevnull_0 = > /dev/null am__v_texidevnull_1 = -INFO_DEPS = doc/binutils.info +INFO_DEPS = am__TEXINFO_TEX_DIR = $(srcdir) DVIS = doc/binutils.dvi PDFS = doc/binutils.pdf ================================================ FILE: tools/openbsd/ports/mystuff/devel/arm-none-eabi/binutils/patches/patch-gas_Makefile_in ================================================ Index: gas/Makefile.in --- gas/Makefile.in.orig +++ gas/Makefile.in @@ -270,7 +270,7 @@ AM_V_texidevnull = $(am__v_texidevnull_@AM_V@) am__v_texidevnull_ = $(am__v_texidevnull_@AM_DEFAULT_V@) am__v_texidevnull_0 = > /dev/null am__v_texidevnull_1 = -INFO_DEPS = doc/as.info +INFO_DEPS = TEXINFO_TEX = $(top_srcdir)/../texinfo.tex am__TEXINFO_TEX_DIR = $(top_srcdir)/.. DVIS = doc/as.dvi ================================================ FILE: tools/openbsd/ports/mystuff/devel/arm-none-eabi/binutils/patches/patch-gprof_Makefile_in ================================================ Index: gprof/Makefile.in --- gprof/Makefile.in.orig +++ gprof/Makefile.in @@ -217,7 +217,7 @@ AM_V_texidevnull = $(am__v_texidevnull_@AM_V@) am__v_texidevnull_ = $(am__v_texidevnull_@AM_DEFAULT_V@) am__v_texidevnull_0 = > /dev/null am__v_texidevnull_1 = -INFO_DEPS = gprof.info +INFO_DEPS = am__TEXINFO_TEX_DIR = $(srcdir)/../texinfo DVIS = gprof.dvi PDFS = gprof.pdf ================================================ FILE: tools/openbsd/ports/mystuff/devel/arm-none-eabi/binutils/patches/patch-ld_Makefile_in ================================================ Index: ld/Makefile.in --- ld/Makefile.in.orig +++ ld/Makefile.in @@ -301,7 +301,7 @@ AM_V_texidevnull = $(am__v_texidevnull_@AM_V@) am__v_texidevnull_ = $(am__v_texidevnull_@AM_DEFAULT_V@) am__v_texidevnull_0 = > /dev/null am__v_texidevnull_1 = -INFO_DEPS = ld.info +INFO_DEPS = am__TEXINFO_TEX_DIR = $(srcdir)/../texinfo DVIS = ld.dvi PDFS = ld.pdf @@ -1042,7 +1042,7 @@ libldtestplug4_la_SOURCES = testplug4.c libldtestplug4_la_CFLAGS = -g -O2 libldtestplug4_la_LDFLAGS = -no-undefined -rpath /nowhere bfdplugindir = $(libdir)/bfd-plugins -bfdplugin_LTLIBRARIES = libdep.la +bfdplugin_LTLIBRARIES = libdep_la_SOURCES = libdep_plugin.c libdep_la_LDFLAGS = -no-undefined -rpath /nowhere -module -avoid-version libdep_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ ================================================ FILE: tools/openbsd/ports/mystuff/devel/arm-none-eabi/binutils/patches/patch-libctf_Makefile_in ================================================ Index: libctf/Makefile.in --- libctf/Makefile.in.orig +++ libctf/Makefile.in @@ -306,7 +306,7 @@ am__v_texidevnull_ = $(am__v_texidevnull_@AM_DEFAULT_V am__v_texidevnull_0 = > /dev/null am__v_texidevnull_1 = am__dirstamp = $(am__leading_dot)dirstamp -INFO_DEPS = doc/ctf-spec.info +INFO_DEPS = am__TEXINFO_TEX_DIR = $(srcdir) DVIS = doc/ctf-spec.dvi PDFS = doc/ctf-spec.pdf ================================================ FILE: tools/openbsd/ports/mystuff/devel/arm-none-eabi/binutils/patches/patch-libiberty_Makefile_in ================================================ Index: libiberty/Makefile.in --- libiberty/Makefile.in.orig +++ libiberty/Makefile.in @@ -376,7 +376,7 @@ libiberty.html : $(srcdir)/libiberty.texi $(TEXISRC) @MAINT@ echo stamp > stamp-functions INSTALL_DEST = @INSTALL_DEST@ -install: install_to_$(INSTALL_DEST) install-subdir +install: install-strip: install .PHONY: install install-strip ================================================ FILE: tools/openbsd/ports/mystuff/devel/arm-none-eabi/binutils/patches/patch-libsframe_Makefile_in ================================================ Index: libsframe/Makefile.in --- libsframe/Makefile.in.orig +++ libsframe/Makefile.in @@ -276,7 +276,7 @@ AM_V_texidevnull = $(am__v_texidevnull_@AM_V@) am__v_texidevnull_ = $(am__v_texidevnull_@AM_DEFAULT_V@) am__v_texidevnull_0 = > /dev/null am__v_texidevnull_1 = -INFO_DEPS = doc/sframe-spec.info +INFO_DEPS = am__TEXINFO_TEX_DIR = $(srcdir) DVIS = doc/sframe-spec.dvi PDFS = doc/sframe-spec.pdf ================================================ FILE: tools/openbsd/ports/mystuff/devel/arm-none-eabi/binutils/pkg/DESCR ================================================ GNU Binutils collection, configured for the ${CONFIG} target. * ld - the GNU linker. * as - the GNU assembler. But they also include: * addr2line - Converts addresses into filenames and line numbers. * ar - A utility for creating, modifying and extracting from archives. * c++filt - Filter to demangle encoded C++ symbols. * gprof - Displays profiling information. * nlmconv - Converts object code into an NLM. * nm - Lists symbols from object files. * objcopy - Copys and translates object files. * objdump - Displays information from object files. * ranlib - Generates an index to the contents of an archive. * readelf - Displays information from any ELF format object file. * size - Lists the section sizes of an object or archive file. * strings - Lists printable strings from files. * strip - Discards symbols. * windres - A compiler for Windows resource files. Most of these programs use BFD, the Binary File Descriptor library, to do low-level manipulation. Many of them also use the opcodes library to assemble and disassemble machine instructions. ================================================ FILE: tools/openbsd/ports/mystuff/devel/arm-none-eabi/binutils/pkg/PFRAG.aarch64 ================================================ ${CONFIG}/lib/ ${CONFIG}/lib/ldscripts/ ${CONFIG}/lib/ldscripts/aarch64elf.x ${CONFIG}/lib/ldscripts/aarch64elf.xbn ${CONFIG}/lib/ldscripts/aarch64elf.xc ${CONFIG}/lib/ldscripts/aarch64elf.xce ${CONFIG}/lib/ldscripts/aarch64elf.xd ${CONFIG}/lib/ldscripts/aarch64elf.xdc ${CONFIG}/lib/ldscripts/aarch64elf.xdce ${CONFIG}/lib/ldscripts/aarch64elf.xde ${CONFIG}/lib/ldscripts/aarch64elf.xdw ${CONFIG}/lib/ldscripts/aarch64elf.xdwe ${CONFIG}/lib/ldscripts/aarch64elf.xe ${CONFIG}/lib/ldscripts/aarch64elf.xn ${CONFIG}/lib/ldscripts/aarch64elf.xr ${CONFIG}/lib/ldscripts/aarch64elf.xs ${CONFIG}/lib/ldscripts/aarch64elf.xsc ${CONFIG}/lib/ldscripts/aarch64elf.xsce ${CONFIG}/lib/ldscripts/aarch64elf.xse ${CONFIG}/lib/ldscripts/aarch64elf.xsw ${CONFIG}/lib/ldscripts/aarch64elf.xswe ${CONFIG}/lib/ldscripts/aarch64elf.xu ${CONFIG}/lib/ldscripts/aarch64elf.xw ${CONFIG}/lib/ldscripts/aarch64elf.xwe ${CONFIG}/lib/ldscripts/aarch64elf32.x ${CONFIG}/lib/ldscripts/aarch64elf32.xbn ${CONFIG}/lib/ldscripts/aarch64elf32.xc ${CONFIG}/lib/ldscripts/aarch64elf32.xce ${CONFIG}/lib/ldscripts/aarch64elf32.xd ${CONFIG}/lib/ldscripts/aarch64elf32.xdc ${CONFIG}/lib/ldscripts/aarch64elf32.xdce ${CONFIG}/lib/ldscripts/aarch64elf32.xde ${CONFIG}/lib/ldscripts/aarch64elf32.xdw ${CONFIG}/lib/ldscripts/aarch64elf32.xdwe ${CONFIG}/lib/ldscripts/aarch64elf32.xe ${CONFIG}/lib/ldscripts/aarch64elf32.xn ${CONFIG}/lib/ldscripts/aarch64elf32.xr ${CONFIG}/lib/ldscripts/aarch64elf32.xs ${CONFIG}/lib/ldscripts/aarch64elf32.xsc ${CONFIG}/lib/ldscripts/aarch64elf32.xsce ${CONFIG}/lib/ldscripts/aarch64elf32.xse ${CONFIG}/lib/ldscripts/aarch64elf32.xsw ${CONFIG}/lib/ldscripts/aarch64elf32.xswe ${CONFIG}/lib/ldscripts/aarch64elf32.xu ${CONFIG}/lib/ldscripts/aarch64elf32.xw ${CONFIG}/lib/ldscripts/aarch64elf32.xwe ${CONFIG}/lib/ldscripts/aarch64elf32b.x ${CONFIG}/lib/ldscripts/aarch64elf32b.xbn ${CONFIG}/lib/ldscripts/aarch64elf32b.xc ${CONFIG}/lib/ldscripts/aarch64elf32b.xce ${CONFIG}/lib/ldscripts/aarch64elf32b.xd ${CONFIG}/lib/ldscripts/aarch64elf32b.xdc ${CONFIG}/lib/ldscripts/aarch64elf32b.xdce ${CONFIG}/lib/ldscripts/aarch64elf32b.xde ${CONFIG}/lib/ldscripts/aarch64elf32b.xdw ${CONFIG}/lib/ldscripts/aarch64elf32b.xdwe ${CONFIG}/lib/ldscripts/aarch64elf32b.xe ${CONFIG}/lib/ldscripts/aarch64elf32b.xn ${CONFIG}/lib/ldscripts/aarch64elf32b.xr ${CONFIG}/lib/ldscripts/aarch64elf32b.xs ${CONFIG}/lib/ldscripts/aarch64elf32b.xsc ${CONFIG}/lib/ldscripts/aarch64elf32b.xsce ${CONFIG}/lib/ldscripts/aarch64elf32b.xse ${CONFIG}/lib/ldscripts/aarch64elf32b.xsw ${CONFIG}/lib/ldscripts/aarch64elf32b.xswe ${CONFIG}/lib/ldscripts/aarch64elf32b.xu ${CONFIG}/lib/ldscripts/aarch64elf32b.xw ${CONFIG}/lib/ldscripts/aarch64elf32b.xwe ${CONFIG}/lib/ldscripts/aarch64elfb.x ${CONFIG}/lib/ldscripts/aarch64elfb.xbn ${CONFIG}/lib/ldscripts/aarch64elfb.xc ${CONFIG}/lib/ldscripts/aarch64elfb.xce ${CONFIG}/lib/ldscripts/aarch64elfb.xd ${CONFIG}/lib/ldscripts/aarch64elfb.xdc ${CONFIG}/lib/ldscripts/aarch64elfb.xdce ${CONFIG}/lib/ldscripts/aarch64elfb.xde ${CONFIG}/lib/ldscripts/aarch64elfb.xdw ${CONFIG}/lib/ldscripts/aarch64elfb.xdwe ${CONFIG}/lib/ldscripts/aarch64elfb.xe ${CONFIG}/lib/ldscripts/aarch64elfb.xn ${CONFIG}/lib/ldscripts/aarch64elfb.xr ${CONFIG}/lib/ldscripts/aarch64elfb.xs ${CONFIG}/lib/ldscripts/aarch64elfb.xsc ${CONFIG}/lib/ldscripts/aarch64elfb.xsce ${CONFIG}/lib/ldscripts/aarch64elfb.xse ${CONFIG}/lib/ldscripts/aarch64elfb.xsw ${CONFIG}/lib/ldscripts/aarch64elfb.xswe ${CONFIG}/lib/ldscripts/aarch64elfb.xu ${CONFIG}/lib/ldscripts/aarch64elfb.xw ${CONFIG}/lib/ldscripts/aarch64elfb.xwe ${CONFIG}/lib/ldscripts/armelf.x ${CONFIG}/lib/ldscripts/armelf.xbn ${CONFIG}/lib/ldscripts/armelf.xc ${CONFIG}/lib/ldscripts/armelf.xce ${CONFIG}/lib/ldscripts/armelf.xd ${CONFIG}/lib/ldscripts/armelf.xdc ${CONFIG}/lib/ldscripts/armelf.xdce ${CONFIG}/lib/ldscripts/armelf.xde ${CONFIG}/lib/ldscripts/armelf.xdw ${CONFIG}/lib/ldscripts/armelf.xdwe ${CONFIG}/lib/ldscripts/armelf.xe ${CONFIG}/lib/ldscripts/armelf.xn ${CONFIG}/lib/ldscripts/armelf.xr ${CONFIG}/lib/ldscripts/armelf.xs ${CONFIG}/lib/ldscripts/armelf.xsc ${CONFIG}/lib/ldscripts/armelf.xsce ${CONFIG}/lib/ldscripts/armelf.xse ${CONFIG}/lib/ldscripts/armelf.xsw ${CONFIG}/lib/ldscripts/armelf.xswe ${CONFIG}/lib/ldscripts/armelf.xu ${CONFIG}/lib/ldscripts/armelf.xw ${CONFIG}/lib/ldscripts/armelf.xwe ${CONFIG}/lib/ldscripts/armelfb.x ${CONFIG}/lib/ldscripts/armelfb.xbn ${CONFIG}/lib/ldscripts/armelfb.xc ${CONFIG}/lib/ldscripts/armelfb.xce ${CONFIG}/lib/ldscripts/armelfb.xd ${CONFIG}/lib/ldscripts/armelfb.xdc ${CONFIG}/lib/ldscripts/armelfb.xdce ${CONFIG}/lib/ldscripts/armelfb.xde ${CONFIG}/lib/ldscripts/armelfb.xdw ${CONFIG}/lib/ldscripts/armelfb.xdwe ${CONFIG}/lib/ldscripts/armelfb.xe ${CONFIG}/lib/ldscripts/armelfb.xn ${CONFIG}/lib/ldscripts/armelfb.xr ${CONFIG}/lib/ldscripts/armelfb.xs ${CONFIG}/lib/ldscripts/armelfb.xsc ${CONFIG}/lib/ldscripts/armelfb.xsce ${CONFIG}/lib/ldscripts/armelfb.xse ${CONFIG}/lib/ldscripts/armelfb.xsw ${CONFIG}/lib/ldscripts/armelfb.xswe ${CONFIG}/lib/ldscripts/armelfb.xu ${CONFIG}/lib/ldscripts/armelfb.xw ${CONFIG}/lib/ldscripts/armelfb.xwe ================================================ FILE: tools/openbsd/ports/mystuff/devel/arm-none-eabi/binutils/pkg/PFRAG.arm ================================================ @pkgpath devel/arm-none-eabi/binutils, ${CONFIG}/lib/ ${CONFIG}/lib/ldscripts/ ${CONFIG}/lib/ldscripts/armelf.x ${CONFIG}/lib/ldscripts/armelf.xbn ${CONFIG}/lib/ldscripts/armelf.xc ${CONFIG}/lib/ldscripts/armelf.xce ${CONFIG}/lib/ldscripts/armelf.xd ${CONFIG}/lib/ldscripts/armelf.xdc ${CONFIG}/lib/ldscripts/armelf.xdce ${CONFIG}/lib/ldscripts/armelf.xde ${CONFIG}/lib/ldscripts/armelf.xdw ${CONFIG}/lib/ldscripts/armelf.xdwe ${CONFIG}/lib/ldscripts/armelf.xe ${CONFIG}/lib/ldscripts/armelf.xn ${CONFIG}/lib/ldscripts/armelf.xr ${CONFIG}/lib/ldscripts/armelf.xs ${CONFIG}/lib/ldscripts/armelf.xsc ${CONFIG}/lib/ldscripts/armelf.xsce ${CONFIG}/lib/ldscripts/armelf.xse ${CONFIG}/lib/ldscripts/armelf.xsw ${CONFIG}/lib/ldscripts/armelf.xswe ${CONFIG}/lib/ldscripts/armelf.xu ${CONFIG}/lib/ldscripts/armelf.xw ${CONFIG}/lib/ldscripts/armelf.xwe ================================================ FILE: tools/openbsd/ports/mystuff/devel/arm-none-eabi/binutils/pkg/PLIST ================================================ %%aarch64%% %%arm%% ${CONFIG}/ ${CONFIG}/bin/ @bin ${CONFIG}/bin/ar @bin ${CONFIG}/bin/as @bin ${CONFIG}/bin/ld @bin ${CONFIG}/bin/ld.bfd @bin ${CONFIG}/bin/nm @bin ${CONFIG}/bin/objcopy @bin ${CONFIG}/bin/objdump @bin ${CONFIG}/bin/ranlib @bin ${CONFIG}/bin/readelf @bin ${CONFIG}/bin/strip @bin bin/${CONFIG}-addr2line @bin bin/${CONFIG}-ar @bin bin/${CONFIG}-as @bin bin/${CONFIG}-c++filt @bin bin/${CONFIG}-elfedit @bin bin/${CONFIG}-gprof @bin bin/${CONFIG}-ld @bin bin/${CONFIG}-ld.bfd @bin bin/${CONFIG}-nm @bin bin/${CONFIG}-objcopy @bin bin/${CONFIG}-objdump @bin bin/${CONFIG}-ranlib @bin bin/${CONFIG}-readelf @bin bin/${CONFIG}-size @bin bin/${CONFIG}-strings @bin bin/${CONFIG}-strip @man man/man1/${CONFIG}-addr2line.1 @man man/man1/${CONFIG}-ar.1 @man man/man1/${CONFIG}-as.1 @man man/man1/${CONFIG}-c++filt.1 @man man/man1/${CONFIG}-dlltool.1 @man man/man1/${CONFIG}-elfedit.1 @man man/man1/${CONFIG}-gprof.1 @man man/man1/${CONFIG}-ld.1 @man man/man1/${CONFIG}-nm.1 @man man/man1/${CONFIG}-objcopy.1 @man man/man1/${CONFIG}-objdump.1 @man man/man1/${CONFIG}-ranlib.1 @man man/man1/${CONFIG}-readelf.1 @man man/man1/${CONFIG}-size.1 @man man/man1/${CONFIG}-strings.1 @man man/man1/${CONFIG}-strip.1 @man man/man1/${CONFIG}-windmc.1 @man man/man1/${CONFIG}-windres.1 ================================================ FILE: tools/openbsd/ports/mystuff/devel/arm-none-eabi/gcc/Makefile ================================================ BROKEN-powerpc64 = fails to apply patches/vecstep-* BROKEN-arm = spins CPU more than 12h building gcc-12.2.0/libgcc/libgcc2.c COMMENT= gcc for ${CONFIG} cross-development VERSION= 12.2.0 DISTNAME= gcc-${VERSION} PKGNAME= ${CONFIG}-gcc-${VERSION} REVISION= 2 USE_NOEXECONLY= Yes FLAVORS= aarch64 arm FLAVOR?= arm .if "${FLAVOR}" == "aarch64" CONFIG= aarch64-none-elf MULTILIB= default .elif "${FLAVOR}" == "arm" CONFIG= arm-none-eabi MULTILIB= rmprofile .else ERRORS+= "either aarch64 or arm FLAVOR should be set" .endif SUBST_VARS+= VERSION CONFIG WANTLIB= c m ${COMPILER_LIBCXX} gmp mpfr mpc pthread DIST_SUBDIR= gcc COMPILER = base-clang ports-gcc base-gcc SITES= ${SITE_GCC:=releases/gcc-$(VERSION)/} .if ${MACHINE_ARCH} == "powerpc64" PATCH_LIST = patch-* vecstep-* .endif BUILD_DEPENDS+= devel/bison \ ${RUN_DEPENDS} LIB_DEPENDS= devel/mpfr devel/libmpc .if ${FLAVOR:Maarch64} BUILD_DEPENDS+= devel/arm-none-eabi/binutils,aarch64 RUN_DEPENDS= devel/arm-none-eabi/binutils,aarch64 .elif ${FLAVOR:Marm} BUILD_DEPENDS+= devel/arm-none-eabi/binutils,arm RUN_DEPENDS= devel/arm-none-eabi/binutils,arm .else ERRORS+= "either aarch64 or arm FLAVOR should be set" .endif LANGS= c,c++ CONFIGURE_ARGS+=--enable-languages=${LANGS} \ --enable-multilib \ --with-multilib-list=${MULTILIB}\ --enable-interwork \ --with-gmp=${LOCALBASE} \ --with-newlib \ --disable-libcc1 \ --enable-cpp \ --without-isl \ --without-zstd CONFIGURE_ENV= CPPFLAGS="${CPPFLAGS} -I${LOCALBASE}/include" \ LDFLAGS="-L${LOCALBASE}/lib" # Avoid build failure when lang/gcc/8 is installed whose ansidecl.h misses these CPPFLAGS += -DATTRIBUTE_NONSTRING= -DATTRIBUTE_RESULT_SIZE_1= CPPFLAGS += -DATTRIBUTE_RESULT_SIZE_2= -DATTRIBUTE_RESULT_SIZE_1_2= CPPFLAGS += -DATTRIBUTE_WARN_UNUSED_RESULT= SEPARATE_BUILD= Yes USE_GMAKE= Yes YACC= bison post-install: chown -R ${SHAREOWN}:${SHAREGRP} \ ${PREFIX}/lib/gcc/${CONFIG}/${VERSION}/ .include ================================================ FILE: tools/openbsd/ports/mystuff/devel/arm-none-eabi/gcc/distinfo ================================================ SHA256 (gcc/gcc-12.2.0.tar.xz) = 5UnPnPNZSgDie2WJ1DItcOByDN0hPzm+tBgeBpJiMP8= SIZE (gcc/gcc-12.2.0.tar.xz) = 84645292 ================================================ FILE: tools/openbsd/ports/mystuff/devel/arm-none-eabi/gcc/patches/patch-Makefile_in ================================================ Index: Makefile.in --- Makefile.in.orig +++ Makefile.in @@ -1116,29 +1116,8 @@ configure-host: \ maybe-configure-libctf .PHONY: configure-target configure-target: \ - maybe-configure-target-libstdc++-v3 \ - maybe-configure-target-libsanitizer \ - maybe-configure-target-libvtv \ - maybe-configure-target-liboffloadmic \ - maybe-configure-target-libssp \ maybe-configure-target-newlib \ - maybe-configure-target-libgcc \ - maybe-configure-target-libbacktrace \ - maybe-configure-target-libquadmath \ - maybe-configure-target-libgfortran \ - maybe-configure-target-libobjc \ - maybe-configure-target-libgo \ - maybe-configure-target-libphobos \ - maybe-configure-target-libtermcap \ - maybe-configure-target-winsup \ - maybe-configure-target-libgloss \ - maybe-configure-target-libffi \ - maybe-configure-target-zlib \ - maybe-configure-target-rda \ - maybe-configure-target-libada \ - maybe-configure-target-libgomp \ - maybe-configure-target-libitm \ - maybe-configure-target-libatomic + maybe-configure-target-libgcc # The target built for a native non-bootstrap build. .PHONY: all @@ -1296,47 +1275,10 @@ all-host: maybe-all-libctf .PHONY: all-target -@if target-libstdc++-v3-no-bootstrap -all-target: maybe-all-target-libstdc++-v3 -@endif target-libstdc++-v3-no-bootstrap -@if target-libsanitizer-no-bootstrap -all-target: maybe-all-target-libsanitizer -@endif target-libsanitizer-no-bootstrap -@if target-libvtv-no-bootstrap -all-target: maybe-all-target-libvtv -@endif target-libvtv-no-bootstrap -all-target: maybe-all-target-liboffloadmic -all-target: maybe-all-target-libssp all-target: maybe-all-target-newlib @if target-libgcc-no-bootstrap all-target: maybe-all-target-libgcc @endif target-libgcc-no-bootstrap -@if target-libbacktrace-no-bootstrap -all-target: maybe-all-target-libbacktrace -@endif target-libbacktrace-no-bootstrap -all-target: maybe-all-target-libquadmath -all-target: maybe-all-target-libgfortran -all-target: maybe-all-target-libobjc -all-target: maybe-all-target-libgo -@if target-libphobos-no-bootstrap -all-target: maybe-all-target-libphobos -@endif target-libphobos-no-bootstrap -all-target: maybe-all-target-libtermcap -all-target: maybe-all-target-winsup -all-target: maybe-all-target-libgloss -all-target: maybe-all-target-libffi -@if target-zlib-no-bootstrap -all-target: maybe-all-target-zlib -@endif target-zlib-no-bootstrap -all-target: maybe-all-target-rda -all-target: maybe-all-target-libada -@if target-libgomp-no-bootstrap -all-target: maybe-all-target-libgomp -@endif target-libgomp-no-bootstrap -all-target: maybe-all-target-libitm -@if target-libatomic-no-bootstrap -all-target: maybe-all-target-libatomic -@endif target-libatomic-no-bootstrap # Do a target for all the subdirectories. A ``make do-X'' will do a # ``make X'' in all subdirectories (because, in general, there is a @@ -1409,29 +1351,8 @@ info-host: maybe-info-libctf .PHONY: info-target -info-target: maybe-info-target-libstdc++-v3 -info-target: maybe-info-target-libsanitizer -info-target: maybe-info-target-libvtv -info-target: maybe-info-target-liboffloadmic -info-target: maybe-info-target-libssp info-target: maybe-info-target-newlib info-target: maybe-info-target-libgcc -info-target: maybe-info-target-libbacktrace -info-target: maybe-info-target-libquadmath -info-target: maybe-info-target-libgfortran -info-target: maybe-info-target-libobjc -info-target: maybe-info-target-libgo -info-target: maybe-info-target-libphobos -info-target: maybe-info-target-libtermcap -info-target: maybe-info-target-winsup -info-target: maybe-info-target-libgloss -info-target: maybe-info-target-libffi -info-target: maybe-info-target-zlib -info-target: maybe-info-target-rda -info-target: maybe-info-target-libada -info-target: maybe-info-target-libgomp -info-target: maybe-info-target-libitm -info-target: maybe-info-target-libatomic .PHONY: do-dvi do-dvi: @@ -1499,29 +1420,8 @@ dvi-host: maybe-dvi-libctf .PHONY: dvi-target -dvi-target: maybe-dvi-target-libstdc++-v3 -dvi-target: maybe-dvi-target-libsanitizer -dvi-target: maybe-dvi-target-libvtv -dvi-target: maybe-dvi-target-liboffloadmic -dvi-target: maybe-dvi-target-libssp dvi-target: maybe-dvi-target-newlib dvi-target: maybe-dvi-target-libgcc -dvi-target: maybe-dvi-target-libbacktrace -dvi-target: maybe-dvi-target-libquadmath -dvi-target: maybe-dvi-target-libgfortran -dvi-target: maybe-dvi-target-libobjc -dvi-target: maybe-dvi-target-libgo -dvi-target: maybe-dvi-target-libphobos -dvi-target: maybe-dvi-target-libtermcap -dvi-target: maybe-dvi-target-winsup -dvi-target: maybe-dvi-target-libgloss -dvi-target: maybe-dvi-target-libffi -dvi-target: maybe-dvi-target-zlib -dvi-target: maybe-dvi-target-rda -dvi-target: maybe-dvi-target-libada -dvi-target: maybe-dvi-target-libgomp -dvi-target: maybe-dvi-target-libitm -dvi-target: maybe-dvi-target-libatomic .PHONY: do-pdf do-pdf: @@ -1589,29 +1489,8 @@ pdf-host: maybe-pdf-libctf .PHONY: pdf-target -pdf-target: maybe-pdf-target-libstdc++-v3 -pdf-target: maybe-pdf-target-libsanitizer -pdf-target: maybe-pdf-target-libvtv -pdf-target: maybe-pdf-target-liboffloadmic -pdf-target: maybe-pdf-target-libssp pdf-target: maybe-pdf-target-newlib pdf-target: maybe-pdf-target-libgcc -pdf-target: maybe-pdf-target-libbacktrace -pdf-target: maybe-pdf-target-libquadmath -pdf-target: maybe-pdf-target-libgfortran -pdf-target: maybe-pdf-target-libobjc -pdf-target: maybe-pdf-target-libgo -pdf-target: maybe-pdf-target-libphobos -pdf-target: maybe-pdf-target-libtermcap -pdf-target: maybe-pdf-target-winsup -pdf-target: maybe-pdf-target-libgloss -pdf-target: maybe-pdf-target-libffi -pdf-target: maybe-pdf-target-zlib -pdf-target: maybe-pdf-target-rda -pdf-target: maybe-pdf-target-libada -pdf-target: maybe-pdf-target-libgomp -pdf-target: maybe-pdf-target-libitm -pdf-target: maybe-pdf-target-libatomic .PHONY: do-html do-html: @@ -1679,29 +1558,8 @@ html-host: maybe-html-libctf .PHONY: html-target -html-target: maybe-html-target-libstdc++-v3 -html-target: maybe-html-target-libsanitizer -html-target: maybe-html-target-libvtv -html-target: maybe-html-target-liboffloadmic -html-target: maybe-html-target-libssp html-target: maybe-html-target-newlib html-target: maybe-html-target-libgcc -html-target: maybe-html-target-libbacktrace -html-target: maybe-html-target-libquadmath -html-target: maybe-html-target-libgfortran -html-target: maybe-html-target-libobjc -html-target: maybe-html-target-libgo -html-target: maybe-html-target-libphobos -html-target: maybe-html-target-libtermcap -html-target: maybe-html-target-winsup -html-target: maybe-html-target-libgloss -html-target: maybe-html-target-libffi -html-target: maybe-html-target-zlib -html-target: maybe-html-target-rda -html-target: maybe-html-target-libada -html-target: maybe-html-target-libgomp -html-target: maybe-html-target-libitm -html-target: maybe-html-target-libatomic .PHONY: do-TAGS do-TAGS: @@ -1769,29 +1627,8 @@ TAGS-host: maybe-TAGS-libctf .PHONY: TAGS-target -TAGS-target: maybe-TAGS-target-libstdc++-v3 -TAGS-target: maybe-TAGS-target-libsanitizer -TAGS-target: maybe-TAGS-target-libvtv -TAGS-target: maybe-TAGS-target-liboffloadmic -TAGS-target: maybe-TAGS-target-libssp TAGS-target: maybe-TAGS-target-newlib TAGS-target: maybe-TAGS-target-libgcc -TAGS-target: maybe-TAGS-target-libbacktrace -TAGS-target: maybe-TAGS-target-libquadmath -TAGS-target: maybe-TAGS-target-libgfortran -TAGS-target: maybe-TAGS-target-libobjc -TAGS-target: maybe-TAGS-target-libgo -TAGS-target: maybe-TAGS-target-libphobos -TAGS-target: maybe-TAGS-target-libtermcap -TAGS-target: maybe-TAGS-target-winsup -TAGS-target: maybe-TAGS-target-libgloss -TAGS-target: maybe-TAGS-target-libffi -TAGS-target: maybe-TAGS-target-zlib -TAGS-target: maybe-TAGS-target-rda -TAGS-target: maybe-TAGS-target-libada -TAGS-target: maybe-TAGS-target-libgomp -TAGS-target: maybe-TAGS-target-libitm -TAGS-target: maybe-TAGS-target-libatomic .PHONY: do-install-info do-install-info: @@ -1859,29 +1696,8 @@ install-info-host: maybe-install-info-libctf .PHONY: install-info-target -install-info-target: maybe-install-info-target-libstdc++-v3 -install-info-target: maybe-install-info-target-libsanitizer -install-info-target: maybe-install-info-target-libvtv -install-info-target: maybe-install-info-target-liboffloadmic -install-info-target: maybe-install-info-target-libssp install-info-target: maybe-install-info-target-newlib install-info-target: maybe-install-info-target-libgcc -install-info-target: maybe-install-info-target-libbacktrace -install-info-target: maybe-install-info-target-libquadmath -install-info-target: maybe-install-info-target-libgfortran -install-info-target: maybe-install-info-target-libobjc -install-info-target: maybe-install-info-target-libgo -install-info-target: maybe-install-info-target-libphobos -install-info-target: maybe-install-info-target-libtermcap -install-info-target: maybe-install-info-target-winsup -install-info-target: maybe-install-info-target-libgloss -install-info-target: maybe-install-info-target-libffi -install-info-target: maybe-install-info-target-zlib -install-info-target: maybe-install-info-target-rda -install-info-target: maybe-install-info-target-libada -install-info-target: maybe-install-info-target-libgomp -install-info-target: maybe-install-info-target-libitm -install-info-target: maybe-install-info-target-libatomic .PHONY: do-install-dvi do-install-dvi: @@ -2039,29 +1855,8 @@ install-pdf-host: maybe-install-pdf-libctf .PHONY: install-pdf-target -install-pdf-target: maybe-install-pdf-target-libstdc++-v3 -install-pdf-target: maybe-install-pdf-target-libsanitizer -install-pdf-target: maybe-install-pdf-target-libvtv -install-pdf-target: maybe-install-pdf-target-liboffloadmic -install-pdf-target: maybe-install-pdf-target-libssp install-pdf-target: maybe-install-pdf-target-newlib install-pdf-target: maybe-install-pdf-target-libgcc -install-pdf-target: maybe-install-pdf-target-libbacktrace -install-pdf-target: maybe-install-pdf-target-libquadmath -install-pdf-target: maybe-install-pdf-target-libgfortran -install-pdf-target: maybe-install-pdf-target-libobjc -install-pdf-target: maybe-install-pdf-target-libgo -install-pdf-target: maybe-install-pdf-target-libphobos -install-pdf-target: maybe-install-pdf-target-libtermcap -install-pdf-target: maybe-install-pdf-target-winsup -install-pdf-target: maybe-install-pdf-target-libgloss -install-pdf-target: maybe-install-pdf-target-libffi -install-pdf-target: maybe-install-pdf-target-zlib -install-pdf-target: maybe-install-pdf-target-rda -install-pdf-target: maybe-install-pdf-target-libada -install-pdf-target: maybe-install-pdf-target-libgomp -install-pdf-target: maybe-install-pdf-target-libitm -install-pdf-target: maybe-install-pdf-target-libatomic .PHONY: do-install-html do-install-html: @@ -2129,29 +1924,8 @@ install-html-host: maybe-install-html-libctf .PHONY: install-html-target -install-html-target: maybe-install-html-target-libstdc++-v3 -install-html-target: maybe-install-html-target-libsanitizer -install-html-target: maybe-install-html-target-libvtv -install-html-target: maybe-install-html-target-liboffloadmic -install-html-target: maybe-install-html-target-libssp install-html-target: maybe-install-html-target-newlib install-html-target: maybe-install-html-target-libgcc -install-html-target: maybe-install-html-target-libbacktrace -install-html-target: maybe-install-html-target-libquadmath -install-html-target: maybe-install-html-target-libgfortran -install-html-target: maybe-install-html-target-libobjc -install-html-target: maybe-install-html-target-libgo -install-html-target: maybe-install-html-target-libphobos -install-html-target: maybe-install-html-target-libtermcap -install-html-target: maybe-install-html-target-winsup -install-html-target: maybe-install-html-target-libgloss -install-html-target: maybe-install-html-target-libffi -install-html-target: maybe-install-html-target-zlib -install-html-target: maybe-install-html-target-rda -install-html-target: maybe-install-html-target-libada -install-html-target: maybe-install-html-target-libgomp -install-html-target: maybe-install-html-target-libitm -install-html-target: maybe-install-html-target-libatomic .PHONY: do-installcheck do-installcheck: @@ -2219,29 +1993,8 @@ installcheck-host: maybe-installcheck-libctf .PHONY: installcheck-target -installcheck-target: maybe-installcheck-target-libstdc++-v3 -installcheck-target: maybe-installcheck-target-libsanitizer -installcheck-target: maybe-installcheck-target-libvtv -installcheck-target: maybe-installcheck-target-liboffloadmic -installcheck-target: maybe-installcheck-target-libssp installcheck-target: maybe-installcheck-target-newlib installcheck-target: maybe-installcheck-target-libgcc -installcheck-target: maybe-installcheck-target-libbacktrace -installcheck-target: maybe-installcheck-target-libquadmath -installcheck-target: maybe-installcheck-target-libgfortran -installcheck-target: maybe-installcheck-target-libobjc -installcheck-target: maybe-installcheck-target-libgo -installcheck-target: maybe-installcheck-target-libphobos -installcheck-target: maybe-installcheck-target-libtermcap -installcheck-target: maybe-installcheck-target-winsup -installcheck-target: maybe-installcheck-target-libgloss -installcheck-target: maybe-installcheck-target-libffi -installcheck-target: maybe-installcheck-target-zlib -installcheck-target: maybe-installcheck-target-rda -installcheck-target: maybe-installcheck-target-libada -installcheck-target: maybe-installcheck-target-libgomp -installcheck-target: maybe-installcheck-target-libitm -installcheck-target: maybe-installcheck-target-libatomic .PHONY: do-mostlyclean do-mostlyclean: @@ -2309,29 +2062,8 @@ mostlyclean-host: maybe-mostlyclean-libctf .PHONY: mostlyclean-target -mostlyclean-target: maybe-mostlyclean-target-libstdc++-v3 -mostlyclean-target: maybe-mostlyclean-target-libsanitizer -mostlyclean-target: maybe-mostlyclean-target-libvtv -mostlyclean-target: maybe-mostlyclean-target-liboffloadmic -mostlyclean-target: maybe-mostlyclean-target-libssp mostlyclean-target: maybe-mostlyclean-target-newlib mostlyclean-target: maybe-mostlyclean-target-libgcc -mostlyclean-target: maybe-mostlyclean-target-libbacktrace -mostlyclean-target: maybe-mostlyclean-target-libquadmath -mostlyclean-target: maybe-mostlyclean-target-libgfortran -mostlyclean-target: maybe-mostlyclean-target-libobjc -mostlyclean-target: maybe-mostlyclean-target-libgo -mostlyclean-target: maybe-mostlyclean-target-libphobos -mostlyclean-target: maybe-mostlyclean-target-libtermcap -mostlyclean-target: maybe-mostlyclean-target-winsup -mostlyclean-target: maybe-mostlyclean-target-libgloss -mostlyclean-target: maybe-mostlyclean-target-libffi -mostlyclean-target: maybe-mostlyclean-target-zlib -mostlyclean-target: maybe-mostlyclean-target-rda -mostlyclean-target: maybe-mostlyclean-target-libada -mostlyclean-target: maybe-mostlyclean-target-libgomp -mostlyclean-target: maybe-mostlyclean-target-libitm -mostlyclean-target: maybe-mostlyclean-target-libatomic .PHONY: do-clean do-clean: @@ -2399,29 +2131,8 @@ clean-host: maybe-clean-libctf .PHONY: clean-target -clean-target: maybe-clean-target-libstdc++-v3 -clean-target: maybe-clean-target-libsanitizer -clean-target: maybe-clean-target-libvtv -clean-target: maybe-clean-target-liboffloadmic -clean-target: maybe-clean-target-libssp clean-target: maybe-clean-target-newlib clean-target: maybe-clean-target-libgcc -clean-target: maybe-clean-target-libbacktrace -clean-target: maybe-clean-target-libquadmath -clean-target: maybe-clean-target-libgfortran -clean-target: maybe-clean-target-libobjc -clean-target: maybe-clean-target-libgo -clean-target: maybe-clean-target-libphobos -clean-target: maybe-clean-target-libtermcap -clean-target: maybe-clean-target-winsup -clean-target: maybe-clean-target-libgloss -clean-target: maybe-clean-target-libffi -clean-target: maybe-clean-target-zlib -clean-target: maybe-clean-target-rda -clean-target: maybe-clean-target-libada -clean-target: maybe-clean-target-libgomp -clean-target: maybe-clean-target-libitm -clean-target: maybe-clean-target-libatomic .PHONY: do-distclean do-distclean: @@ -2489,29 +2200,8 @@ distclean-host: maybe-distclean-libctf .PHONY: distclean-target -distclean-target: maybe-distclean-target-libstdc++-v3 -distclean-target: maybe-distclean-target-libsanitizer -distclean-target: maybe-distclean-target-libvtv -distclean-target: maybe-distclean-target-liboffloadmic -distclean-target: maybe-distclean-target-libssp distclean-target: maybe-distclean-target-newlib distclean-target: maybe-distclean-target-libgcc -distclean-target: maybe-distclean-target-libbacktrace -distclean-target: maybe-distclean-target-libquadmath -distclean-target: maybe-distclean-target-libgfortran -distclean-target: maybe-distclean-target-libobjc -distclean-target: maybe-distclean-target-libgo -distclean-target: maybe-distclean-target-libphobos -distclean-target: maybe-distclean-target-libtermcap -distclean-target: maybe-distclean-target-winsup -distclean-target: maybe-distclean-target-libgloss -distclean-target: maybe-distclean-target-libffi -distclean-target: maybe-distclean-target-zlib -distclean-target: maybe-distclean-target-rda -distclean-target: maybe-distclean-target-libada -distclean-target: maybe-distclean-target-libgomp -distclean-target: maybe-distclean-target-libitm -distclean-target: maybe-distclean-target-libatomic .PHONY: do-maintainer-clean do-maintainer-clean: @@ -2579,29 +2269,8 @@ maintainer-clean-host: maybe-maintainer-clean-libctf .PHONY: maintainer-clean-target -maintainer-clean-target: maybe-maintainer-clean-target-libstdc++-v3 -maintainer-clean-target: maybe-maintainer-clean-target-libsanitizer -maintainer-clean-target: maybe-maintainer-clean-target-libvtv -maintainer-clean-target: maybe-maintainer-clean-target-liboffloadmic -maintainer-clean-target: maybe-maintainer-clean-target-libssp maintainer-clean-target: maybe-maintainer-clean-target-newlib maintainer-clean-target: maybe-maintainer-clean-target-libgcc -maintainer-clean-target: maybe-maintainer-clean-target-libbacktrace -maintainer-clean-target: maybe-maintainer-clean-target-libquadmath -maintainer-clean-target: maybe-maintainer-clean-target-libgfortran -maintainer-clean-target: maybe-maintainer-clean-target-libobjc -maintainer-clean-target: maybe-maintainer-clean-target-libgo -maintainer-clean-target: maybe-maintainer-clean-target-libphobos -maintainer-clean-target: maybe-maintainer-clean-target-libtermcap -maintainer-clean-target: maybe-maintainer-clean-target-winsup -maintainer-clean-target: maybe-maintainer-clean-target-libgloss -maintainer-clean-target: maybe-maintainer-clean-target-libffi -maintainer-clean-target: maybe-maintainer-clean-target-zlib -maintainer-clean-target: maybe-maintainer-clean-target-rda -maintainer-clean-target: maybe-maintainer-clean-target-libada -maintainer-clean-target: maybe-maintainer-clean-target-libgomp -maintainer-clean-target: maybe-maintainer-clean-target-libitm -maintainer-clean-target: maybe-maintainer-clean-target-libatomic # Here are the targets which correspond to the do-X targets. @@ -2727,29 +2396,8 @@ check-host: \ .PHONY: check-target check-target: \ - maybe-check-target-libstdc++-v3 \ - maybe-check-target-libsanitizer \ - maybe-check-target-libvtv \ - maybe-check-target-liboffloadmic \ - maybe-check-target-libssp \ maybe-check-target-newlib \ - maybe-check-target-libgcc \ - maybe-check-target-libbacktrace \ - maybe-check-target-libquadmath \ - maybe-check-target-libgfortran \ - maybe-check-target-libobjc \ - maybe-check-target-libgo \ - maybe-check-target-libphobos \ - maybe-check-target-libtermcap \ - maybe-check-target-winsup \ - maybe-check-target-libgloss \ - maybe-check-target-libffi \ - maybe-check-target-zlib \ - maybe-check-target-rda \ - maybe-check-target-libada \ - maybe-check-target-libgomp \ - maybe-check-target-libitm \ - maybe-check-target-libatomic + maybe-check-target-libgcc do-check: @: $(MAKE); $(unstage) @@ -2919,29 +2567,8 @@ install-host: \ .PHONY: install-target install-target: \ - maybe-install-target-libstdc++-v3 \ - maybe-install-target-libsanitizer \ - maybe-install-target-libvtv \ - maybe-install-target-liboffloadmic \ - maybe-install-target-libssp \ maybe-install-target-newlib \ - maybe-install-target-libgcc \ - maybe-install-target-libbacktrace \ - maybe-install-target-libquadmath \ - maybe-install-target-libgfortran \ - maybe-install-target-libobjc \ - maybe-install-target-libgo \ - maybe-install-target-libphobos \ - maybe-install-target-libtermcap \ - maybe-install-target-winsup \ - maybe-install-target-libgloss \ - maybe-install-target-libffi \ - maybe-install-target-zlib \ - maybe-install-target-rda \ - maybe-install-target-libada \ - maybe-install-target-libgomp \ - maybe-install-target-libitm \ - maybe-install-target-libatomic + maybe-install-target-libgcc uninstall: @echo "the uninstall target is not supported in this tree" @@ -3029,30 +2656,8 @@ install-strip-host: \ .PHONY: install-strip-target install-strip-target: \ - maybe-install-strip-target-libstdc++-v3 \ - maybe-install-strip-target-libsanitizer \ - maybe-install-strip-target-libvtv \ - maybe-install-strip-target-liboffloadmic \ - maybe-install-strip-target-libssp \ maybe-install-strip-target-newlib \ - maybe-install-strip-target-libgcc \ - maybe-install-strip-target-libbacktrace \ - maybe-install-strip-target-libquadmath \ - maybe-install-strip-target-libgfortran \ - maybe-install-strip-target-libobjc \ - maybe-install-strip-target-libgo \ - maybe-install-strip-target-libphobos \ - maybe-install-strip-target-libtermcap \ - maybe-install-strip-target-winsup \ - maybe-install-strip-target-libgloss \ - maybe-install-strip-target-libffi \ - maybe-install-strip-target-zlib \ - maybe-install-strip-target-rda \ - maybe-install-strip-target-libada \ - maybe-install-strip-target-libgomp \ - maybe-install-strip-target-libitm \ - maybe-install-strip-target-libatomic - + maybe-install-strip-target-libgcc ### other supporting targets ================================================ FILE: tools/openbsd/ports/mystuff/devel/arm-none-eabi/gcc/patches/patch-gcc_Makefile_in ================================================ Index: gcc/Makefile.in --- gcc/Makefile.in.orig +++ gcc/Makefile.in @@ -3784,13 +3784,7 @@ install-driver: installdirs xgcc$(exeext) # Install the info files. # $(INSTALL_DATA) might be a relative pathname, so we can't cd into srcdir # to do the install. -install-info:: doc installdirs \ - $(DESTDIR)$(infodir)/cpp.info \ - $(DESTDIR)$(infodir)/gcc.info \ - $(DESTDIR)$(infodir)/cppinternals.info \ - $(DESTDIR)$(infodir)/gccinstall.info \ - $(DESTDIR)$(infodir)/gccint.info \ - lang.install-info +install-info:: $(DESTDIR)$(infodir)/%.info: doc/%.info installdirs rm -f $@ @@ -3857,10 +3851,7 @@ install-man: lang.install-man \ $(DESTDIR)$(man1dir)/$(GCOV_INSTALL_NAME)$(man1ext) \ $(DESTDIR)$(man1dir)/$(GCOV_TOOL_INSTALL_NAME)$(man1ext) \ $(DESTDIR)$(man1dir)/$(GCOV_DUMP_INSTALL_NAME)$(man1ext) \ - $(if $(filter yes,@enable_lto@),$(DESTDIR)$(man1dir)/$(LTO_DUMP_INSTALL_NAME)$(man1ext)) \ - $(DESTDIR)$(man7dir)/fsf-funding$(man7ext) \ - $(DESTDIR)$(man7dir)/gfdl$(man7ext) \ - $(DESTDIR)$(man7dir)/gpl$(man7ext) + $(if $(filter yes,@enable_lto@),$(DESTDIR)$(man1dir)/$(LTO_DUMP_INSTALL_NAME)$(man1ext)) $(DESTDIR)$(man7dir)/%$(man7ext): doc/%.7 installdirs -rm -f $@ ================================================ FILE: tools/openbsd/ports/mystuff/devel/arm-none-eabi/gcc/patches/patch-gcc_common_opt ================================================ Index: gcc/common.opt --- gcc/common.opt.orig +++ gcc/common.opt @@ -2017,7 +2017,7 @@ Common Var(flag_ivopts) Init(1) Optimization Optimize induction variables on trees. fjump-tables -Common Var(flag_jump_tables) Init(1) Optimization +Common Var(flag_jump_tables) Init(0) Optimization Use jump tables for sufficiently large switch statements. fbit-tests ================================================ FILE: tools/openbsd/ports/mystuff/devel/arm-none-eabi/gcc/patches/patch-gcc_config_arm_elf_h ================================================ Index: gcc/config/arm/elf.h --- gcc/config/arm/elf.h.orig +++ gcc/config/arm/elf.h @@ -50,7 +50,7 @@ #ifndef SUBTARGET_ASM_FLOAT_SPEC #define SUBTARGET_ASM_FLOAT_SPEC "\ -%{mapcs-float:-mfloat}" +%{mapcs-float:-mfloat} %{!mhard-float:-mfpu=softfpa} %{mhard-float:-mfpu=fpa}" #endif #undef SUBSUBTARGET_EXTRA_SPECS ================================================ FILE: tools/openbsd/ports/mystuff/devel/arm-none-eabi/gcc/patches/patch-gcc_config_host ================================================ Index: gcc/config.host --- gcc/config.host.orig +++ gcc/config.host @@ -99,8 +99,7 @@ case ${host} in esac case ${host} in - aarch64*-*-freebsd* | aarch64*-*-linux* | aarch64*-*-fuchsia* |\ - aarch64*-*-darwin*) + aarch64*-*-*) case ${target} in aarch64*-*-*) host_extra_gcc_objs="driver-aarch64.o" @@ -108,7 +107,7 @@ case ${host} in ;; esac ;; - arm*-*-freebsd* | arm*-*-netbsd* | arm*-*-linux* | arm*-*-fuchsia*) + arm*-*-*) case ${target} in arm*-*-*) host_extra_gcc_objs="driver-arm.o" ================================================ FILE: tools/openbsd/ports/mystuff/devel/arm-none-eabi/gcc/patches/patch-gcc_configure ================================================ Index: gcc/configure --- gcc/configure.orig +++ gcc/configure @@ -32456,14 +32456,14 @@ if test "$gcc_cv_c_no_fpie" = "yes"; then fi -# Check if -no-pie works. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for -no-pie option" >&5 -$as_echo_n "checking for -no-pie option... " >&6; } +# Check if -nopie works. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for -nopie option" >&5 +$as_echo_n "checking for -nopie option... " >&6; } if ${gcc_cv_no_pie+:} false; then : $as_echo_n "(cached) " >&6 else saved_LDFLAGS="$LDFLAGS" - LDFLAGS="$LDFLAGS -no-pie" + LDFLAGS="$LDFLAGS -nopie" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) {return 0;} @@ -32480,7 +32480,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_no_pie" >&5 $as_echo "$gcc_cv_no_pie" >&6; } if test "$gcc_cv_no_pie" = "yes"; then - NO_PIE_FLAG="-no-pie" + NO_PIE_FLAG="-nopie" fi ================================================ FILE: tools/openbsd/ports/mystuff/devel/arm-none-eabi/gcc/patches/patch-libcc1_connection_cc ================================================ Index: libcc1/connection.cc --- libcc1/connection.cc.orig +++ libcc1/connection.cc @@ -20,6 +20,7 @@ along with GCC; see the file COPYING3. If not see #include #include #include +#include #include #include #include ================================================ FILE: tools/openbsd/ports/mystuff/devel/arm-none-eabi/gcc/patches/patch-libgcc_Makefile_in ================================================ Index: libgcc/Makefile.in --- libgcc/Makefile.in.orig +++ libgcc/Makefile.in @@ -1093,7 +1093,7 @@ libgcc-extra-parts: $(EXTRA_PARTS) parts="$(EXTRA_PARTS)"; \ for file in $$parts; do \ rm -f $(gcc_objdir)$(MULTISUBDIR)/$$file; \ - $(INSTALL_DATA) $$file $(gcc_objdir)$(MULTISUBDIR)/; \ + install -c $$file $(gcc_objdir)$(MULTISUBDIR)/; \ case $$file in \ *.a) \ $(RANLIB) $(gcc_objdir)$(MULTISUBDIR)/$$file ;; \ @@ -1123,7 +1123,7 @@ install-unwind_h-forbuild: unwind.h # internal headers are copied by gcc's install. install-unwind_h: $(mkinstalldirs) $(DESTDIR)$(libsubdir)/include - $(INSTALL_DATA) unwind.h $(DESTDIR)$(libsubdir)/include + install -c unwind.h $(DESTDIR)$(libsubdir)/include all: install-unwind_h-forbuild @@ -1149,7 +1149,7 @@ install-libunwind: # NOTE: Maybe this should go into $(inst_libdir), but this # is where the old mklibgcc.in put it. - $(INSTALL_DATA) libunwind.a $(DESTDIR)$(inst_slibdir)/ + install -c libunwind.a $(DESTDIR)$(inst_slibdir)/ chmod 644 $(DESTDIR)$(inst_slibdir)/libunwind.a $(RANLIB) $(DESTDIR)$(inst_slibdir)/libunwind.a @@ -1160,7 +1160,7 @@ install-libunwind: install-shared: $(mkinstalldirs) $(DESTDIR)$(inst_libdir) - $(INSTALL_DATA) libgcc_eh.a $(DESTDIR)$(inst_libdir)/ + install -c libgcc_eh.a $(DESTDIR)$(inst_libdir)/ chmod 644 $(DESTDIR)$(inst_libdir)/libgcc_eh.a $(RANLIB) $(DESTDIR)$(inst_libdir)/libgcc_eh.a @@ -1171,19 +1171,17 @@ install-shared: install-leaf: $(install-shared) $(install-libunwind) $(mkinstalldirs) $(DESTDIR)$(inst_libdir) - $(INSTALL_DATA) libgcc.a $(DESTDIR)$(inst_libdir)/ - chmod 644 $(DESTDIR)$(inst_libdir)/libgcc.a + install -c libgcc.a $(DESTDIR)$(inst_libdir) $(RANLIB) $(DESTDIR)$(inst_libdir)/libgcc.a ifeq ($(enable_gcov),yes) - $(INSTALL_DATA) libgcov.a $(DESTDIR)$(inst_libdir)/ - chmod 644 $(DESTDIR)$(inst_libdir)/libgcov.a + install -c libgcov.a $(DESTDIR)$(inst_libdir) $(RANLIB) $(DESTDIR)$(inst_libdir)/libgcov.a endif parts="$(INSTALL_PARTS)"; \ for file in $$parts; do \ rm -f $(DESTDIR)$(inst_libdir)/$$file; \ - $(INSTALL_DATA) $$file $(DESTDIR)$(inst_libdir)/; \ + install -c $$file $(DESTDIR)$(inst_libdir)/; \ case $$file in \ *.a) \ $(RANLIB) $(gcc_objdir)$(MULTISUBDIR)/$$file ;; \ ================================================ FILE: tools/openbsd/ports/mystuff/devel/arm-none-eabi/gcc/patches/patch-libiberty_Makefile_in ================================================ Index: libiberty/Makefile.in --- libiberty/Makefile.in.orig +++ libiberty/Makefile.in @@ -376,7 +376,7 @@ libiberty.html : $(srcdir)/libiberty.texi $(TEXISRC) @MAINT@ echo stamp > stamp-functions INSTALL_DEST = @INSTALL_DEST@ -install: install_to_$(INSTALL_DEST) install-subdir +install: install-strip: install .PHONY: install install-strip ================================================ FILE: tools/openbsd/ports/mystuff/devel/arm-none-eabi/gcc/patches/vecstep-gcc_tree-vect-loop_c ================================================ clang on powerpc64 defines vec_step already which collides with the symbol in gcc, see https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=239266#c23 renaming suggested at https://gcc.gnu.org/legacy-ml/gcc/2019-07/msg00131.html Index: gcc/tree-vect-loop.c --- gcc/tree-vect-loop.c.orig +++ gcc/tree-vect-loop.c @@ -55,6 +55,8 @@ along with GCC; see the file COPYING3. If not see #include "vec-perm-indices.h" #include "tree-eh.h" +#define vec_step vec_step_ + /* Loop Vectorization Pass. This pass tries to vectorize loops. ================================================ FILE: tools/openbsd/ports/mystuff/devel/arm-none-eabi/gcc/pkg/DESCR ================================================ GNU cross compiler suite, configured for the ${CONFIG} target. ================================================ FILE: tools/openbsd/ports/mystuff/devel/arm-none-eabi/gcc/pkg/PFRAG.aarch64 ================================================ @conflict aarch64-none-elf-gcc-linaro-* @pkgpath devel/arm-none-eabi/gcc-linaro,aarch64 lib/gcc/ lib/gcc/${CONFIG}/ lib/gcc/${CONFIG}/${VERSION}/ lib/gcc/${CONFIG}/${VERSION}/crtbegin.o lib/gcc/${CONFIG}/${VERSION}/crtend.o lib/gcc/${CONFIG}/${VERSION}/crtfastmath.o lib/gcc/${CONFIG}/${VERSION}/crti.o lib/gcc/${CONFIG}/${VERSION}/crtn.o lib/gcc/${CONFIG}/${VERSION}/ilp32/ lib/gcc/${CONFIG}/${VERSION}/ilp32/crtbegin.o lib/gcc/${CONFIG}/${VERSION}/ilp32/crtend.o lib/gcc/${CONFIG}/${VERSION}/ilp32/crtfastmath.o lib/gcc/${CONFIG}/${VERSION}/ilp32/crti.o lib/gcc/${CONFIG}/${VERSION}/ilp32/crtn.o @static-lib lib/gcc/${CONFIG}/${VERSION}/ilp32/libgcc.a @static-lib lib/gcc/${CONFIG}/${VERSION}/ilp32/libgcov.a lib/gcc/${CONFIG}/${VERSION}/include/ lib/gcc/${CONFIG}/${VERSION}/include-fixed/ lib/gcc/${CONFIG}/${VERSION}/include-fixed/README lib/gcc/${CONFIG}/${VERSION}/include-fixed/limits.h lib/gcc/${CONFIG}/${VERSION}/include-fixed/syslimits.h lib/gcc/${CONFIG}/${VERSION}/include/arm_acle.h lib/gcc/${CONFIG}/${VERSION}/include/arm_bf16.h lib/gcc/${CONFIG}/${VERSION}/include/arm_fp16.h lib/gcc/${CONFIG}/${VERSION}/include/arm_neon.h lib/gcc/${CONFIG}/${VERSION}/include/arm_sve.h lib/gcc/${CONFIG}/${VERSION}/include/float.h lib/gcc/${CONFIG}/${VERSION}/include/gcov.h lib/gcc/${CONFIG}/${VERSION}/include/iso646.h lib/gcc/${CONFIG}/${VERSION}/include/stdalign.h lib/gcc/${CONFIG}/${VERSION}/include/stdarg.h lib/gcc/${CONFIG}/${VERSION}/include/stdatomic.h lib/gcc/${CONFIG}/${VERSION}/include/stdbool.h lib/gcc/${CONFIG}/${VERSION}/include/stddef.h lib/gcc/${CONFIG}/${VERSION}/include/stdfix.h lib/gcc/${CONFIG}/${VERSION}/include/stdint-gcc.h lib/gcc/${CONFIG}/${VERSION}/include/stdint.h lib/gcc/${CONFIG}/${VERSION}/include/stdnoreturn.h lib/gcc/${CONFIG}/${VERSION}/include/tgmath.h lib/gcc/${CONFIG}/${VERSION}/include/unwind.h lib/gcc/${CONFIG}/${VERSION}/include/varargs.h lib/gcc/${CONFIG}/${VERSION}/install-tools/ lib/gcc/${CONFIG}/${VERSION}/install-tools/fixinc_list lib/gcc/${CONFIG}/${VERSION}/install-tools/gsyslimits.h lib/gcc/${CONFIG}/${VERSION}/install-tools/include/ lib/gcc/${CONFIG}/${VERSION}/install-tools/include/README lib/gcc/${CONFIG}/${VERSION}/install-tools/include/limits.h lib/gcc/${CONFIG}/${VERSION}/install-tools/macro_list lib/gcc/${CONFIG}/${VERSION}/install-tools/mkheaders.conf @static-lib lib/gcc/${CONFIG}/${VERSION}/libgcc.a @static-lib lib/gcc/${CONFIG}/${VERSION}/libgcov.a lib/gcc/${CONFIG}/${VERSION}/plugin/ lib/gcc/${CONFIG}/${VERSION}/plugin/gtype.state lib/gcc/${CONFIG}/${VERSION}/plugin/include/ lib/gcc/${CONFIG}/${VERSION}/plugin/include/ada/ lib/gcc/${CONFIG}/${VERSION}/plugin/include/ada/gcc-interface/ lib/gcc/${CONFIG}/${VERSION}/plugin/include/ada/gcc-interface/ada-tree.def lib/gcc/${CONFIG}/${VERSION}/plugin/include/addresses.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/alias.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/align.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/all-tree.def lib/gcc/${CONFIG}/${VERSION}/plugin/include/alloc-pool.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/ansidecl.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/array-traits.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/asan.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/attr-fnspec.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/attribs.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/auto-host.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/auto-profile.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/b-header-vars lib/gcc/${CONFIG}/${VERSION}/plugin/include/backend.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/basic-block.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/bb-reorder.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/bitmap.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/builtin-attrs.def lib/gcc/${CONFIG}/${VERSION}/plugin/include/builtin-types.def lib/gcc/${CONFIG}/${VERSION}/plugin/include/builtins.def lib/gcc/${CONFIG}/${VERSION}/plugin/include/builtins.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/bversion.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/c-family/ lib/gcc/${CONFIG}/${VERSION}/plugin/include/c-family/c-common.def lib/gcc/${CONFIG}/${VERSION}/plugin/include/c-family/c-common.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/c-family/c-objc.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/c-family/c-pragma.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/c-family/c-pretty-print.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/c-tree.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/calls.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/ccmp.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/cfg-flags.def lib/gcc/${CONFIG}/${VERSION}/plugin/include/cfg.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/cfganal.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/cfgbuild.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/cfgcleanup.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/cfgexpand.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/cfghooks.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/cfgloop.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/cfgloopmanip.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/cfgrtl.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/cgraph.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/cif-code.def lib/gcc/${CONFIG}/${VERSION}/plugin/include/collect-utils.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/collect2-aix.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/collect2.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/color-macros.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/conditions.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/config/ lib/gcc/${CONFIG}/${VERSION}/plugin/include/config.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/config/aarch64/ lib/gcc/${CONFIG}/${VERSION}/plugin/include/config/aarch64/aarch64-arches.def lib/gcc/${CONFIG}/${VERSION}/plugin/include/config/aarch64/aarch64-cores.def lib/gcc/${CONFIG}/${VERSION}/plugin/include/config/aarch64/aarch64-elf-raw.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/config/aarch64/aarch64-elf.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/config/aarch64/aarch64-errata.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/config/aarch64/aarch64-fusion-pairs.def lib/gcc/${CONFIG}/${VERSION}/plugin/include/config/aarch64/aarch64-opts.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/config/aarch64/aarch64-protos.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/config/aarch64/aarch64-tuning-flags.def lib/gcc/${CONFIG}/${VERSION}/plugin/include/config/aarch64/aarch64.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/config/aarch64/biarchlp64.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/config/arm/ lib/gcc/${CONFIG}/${VERSION}/plugin/include/config/arm/aarch-common-protos.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/config/dbxelf.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/config/elfos.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/config/initfini-array.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/config/newlib-stdint.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/configargs.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/context.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/convert.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/coretypes.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/coroutine-builtins.def lib/gcc/${CONFIG}/${VERSION}/plugin/include/coverage.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/cp/ lib/gcc/${CONFIG}/${VERSION}/plugin/include/cp/cp-tree.def lib/gcc/${CONFIG}/${VERSION}/plugin/include/cp/cp-tree.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/cp/cxx-pretty-print.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/cp/name-lookup.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/cp/operators.def lib/gcc/${CONFIG}/${VERSION}/plugin/include/cp/type-utils.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/cppbuiltin.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/cppdefault.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/cpplib.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/cselib.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/ctfc.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/d/ lib/gcc/${CONFIG}/${VERSION}/plugin/include/d/d-tree.def lib/gcc/${CONFIG}/${VERSION}/plugin/include/data-streamer.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/dbgcnt.def lib/gcc/${CONFIG}/${VERSION}/plugin/include/dbgcnt.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/dbxout.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/dce.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/ddg.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/debug.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/defaults.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/df.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/dfp.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/diagnostic-color.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/diagnostic-core.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/diagnostic-event-id.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/diagnostic-metadata.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/diagnostic-path.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/diagnostic-spec.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/diagnostic-url.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/diagnostic.def lib/gcc/${CONFIG}/${VERSION}/plugin/include/diagnostic.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/digraph.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/dojump.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/dominance.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/domwalk.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/double-int.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/dump-context.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/dumpfile.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/dwarf2asm.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/dwarf2ctf.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/dwarf2out.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/edit-context.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/emit-rtl.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/errors.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/escaped_string.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/et-forest.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/except.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/explow.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/expmed.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/expr.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/fibonacci_heap.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/file-find.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/file-prefix-map.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/filenames.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/fixed-value.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/flag-types.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/flags.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/fold-const-call.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/fold-const.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/function-abi.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/function.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/gcc-plugin.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/gcc-rich-location.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/gcc-symtab.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/gcc.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/gcov-counter.def lib/gcc/${CONFIG}/${VERSION}/plugin/include/gcov-io.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/gcse-common.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/gcse.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/generic-match.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/gengtype.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/genrtl.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/gensupport.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/ggc-internal.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/ggc.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/gimple-array-bounds.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/gimple-builder.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/gimple-expr.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/gimple-fold.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/gimple-iterator.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/gimple-low.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/gimple-match.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/gimple-predicate-analysis.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/gimple-predict.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/gimple-pretty-print.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/gimple-range-cache.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/gimple-range-edge.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/gimple-range-fold.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/gimple-range-gori.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/gimple-range-path.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/gimple-range-trace.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/gimple-range.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/gimple-ssa-evrp-analyze.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/gimple-ssa-warn-access.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/gimple-ssa-warn-restrict.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/gimple-ssa.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/gimple-streamer.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/gimple-walk.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/gimple.def lib/gcc/${CONFIG}/${VERSION}/plugin/include/gimple.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/gimplify-me.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/gimplify.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/glimits.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/gomp-constants.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/graph.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/graphds.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/graphite.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/graphviz.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/gsstruct.def lib/gcc/${CONFIG}/${VERSION}/plugin/include/gstab.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/gsyms.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/gsyslimits.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/gtm-builtins.def lib/gcc/${CONFIG}/${VERSION}/plugin/include/gtype-desc.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/hard-reg-set.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/hash-map-traits.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/hash-map.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/hash-set.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/hash-table.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/hash-traits.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/hashtab.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/highlev-plugin-common.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/hooks.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/hosthooks-def.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/hosthooks.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/hw-doloop.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/hwint.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/ifcvt.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/inchash.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/incpath.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/input.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/insn-addr.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/insn-attr-common.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/insn-attr.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/insn-codes.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/insn-config.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/insn-constants.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/insn-flags.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/insn-modes-inline.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/insn-modes.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/insn-notes.def lib/gcc/${CONFIG}/${VERSION}/plugin/include/int-vector-builder.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/internal-fn.def lib/gcc/${CONFIG}/${VERSION}/plugin/include/internal-fn.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/intl.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/ipa-fnsummary.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/ipa-icf-gimple.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/ipa-icf.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/ipa-inline.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/ipa-modref-tree.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/ipa-modref.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/ipa-param-manipulation.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/ipa-predicate.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/ipa-prop.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/ipa-ref.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/ipa-reference.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/ipa-utils.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/ira-int.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/ira.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/is-a.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/iterator-utils.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/json.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/langhooks-def.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/langhooks.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/lcm.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/libfuncs.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/libiberty.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/limitx.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/limity.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/line-map.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/loop-unroll.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/lower-subreg.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/lra-int.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/lra.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/lto-compress.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/lto-section-names.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/lto-streamer.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/machmode.def lib/gcc/${CONFIG}/${VERSION}/plugin/include/machmode.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/md5.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/mem-stats-traits.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/mem-stats.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/memmodel.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/memory-block.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/mode-classes.def lib/gcc/${CONFIG}/${VERSION}/plugin/include/mux-utils.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/objc/ lib/gcc/${CONFIG}/${VERSION}/plugin/include/objc/objc-tree.def lib/gcc/${CONFIG}/${VERSION}/plugin/include/obstack-utils.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/obstack.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/omp-builtins.def lib/gcc/${CONFIG}/${VERSION}/plugin/include/omp-expand.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/omp-general.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/omp-low.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/omp-offload.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/omp-simd-clone.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/opt-problem.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/opt-suggestions.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/optabs-libfuncs.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/optabs-query.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/optabs-tree.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/optabs.def lib/gcc/${CONFIG}/${VERSION}/plugin/include/optabs.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/optinfo-emit-json.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/optinfo.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/options.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/opts-diagnostic.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/opts.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/ordered-hash-map.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/output.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/pass-instances.def lib/gcc/${CONFIG}/${VERSION}/plugin/include/pass_manager.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/passes.def lib/gcc/${CONFIG}/${VERSION}/plugin/include/plugin-api.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/plugin-version.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/plugin.def lib/gcc/${CONFIG}/${VERSION}/plugin/include/plugin.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/pointer-query.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/poly-int-types.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/poly-int.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/predict.def lib/gcc/${CONFIG}/${VERSION}/plugin/include/predict.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/prefix.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/pretty-print.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/print-rtl.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/print-tree.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/profile-count.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/profile.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/range-op.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/range.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/read-md.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/read-rtl-function.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/real.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/realmpfr.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/recog.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/reg-notes.def lib/gcc/${CONFIG}/${VERSION}/plugin/include/regcprop.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/regrename.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/regs.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/regset.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/reload.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/resource.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/rtl-error.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/rtl-iter.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/rtl-ssa.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/rtl.def lib/gcc/${CONFIG}/${VERSION}/plugin/include/rtl.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/rtlanal.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/rtlhash.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/rtlhooks-def.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/rtx-vector-builder.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/run-rtl-passes.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/safe-ctype.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/sanitizer.def lib/gcc/${CONFIG}/${VERSION}/plugin/include/sbitmap.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/sched-int.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/sel-sched-dump.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/sel-sched-ir.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/sel-sched.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/selftest-diagnostic.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/selftest-rtl.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/selftest.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/sese.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/shortest-paths.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/shrink-wrap.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/signop.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/sparseset.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/spellcheck-tree.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/spellcheck.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/splay-tree-utils.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/splay-tree.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/sreal.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/ssa-iterators.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/ssa.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/stab.def lib/gcc/${CONFIG}/${VERSION}/plugin/include/statistics.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/stmt.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/stor-layout.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/streamer-hooks.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/stringpool.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/substring-locations.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/symbol-summary.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/symtab-clones.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/symtab-thunks.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/symtab.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/sync-builtins.def lib/gcc/${CONFIG}/${VERSION}/plugin/include/system.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/target-def.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/target-globals.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/target-hooks-macros.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/target-insns.def lib/gcc/${CONFIG}/${VERSION}/plugin/include/target.def lib/gcc/${CONFIG}/${VERSION}/plugin/include/target.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/targhooks.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/timevar.def lib/gcc/${CONFIG}/${VERSION}/plugin/include/timevar.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tm-preds.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tm.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tm_p.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/toplev.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tracer.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/trans-mem.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-affine.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-cfg.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-cfgcleanup.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-check.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-chrec.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-core.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-data-ref.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-dfa.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-diagnostic.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-dump.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-eh.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-hash-traits.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-hasher.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-if-conv.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-inline.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-into-ssa.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-iterator.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-nested.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-object-size.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-outof-ssa.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-parloops.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-pass.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-phinodes.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-pretty-print.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-scalar-evolution.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-sra.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-ssa-address.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-ssa-alias-compare.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-ssa-alias.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-ssa-ccp.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-ssa-coalesce.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-ssa-dce.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-ssa-dom.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-ssa-dse.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-ssa-live.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-ssa-loop-ivopts.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-ssa-loop-manip.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-ssa-loop-niter.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-ssa-loop.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-ssa-math-opts.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-ssa-operands.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-ssa-propagate.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-ssa-reassoc.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-ssa-sccvn.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-ssa-scopedtables.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-ssa-strlen.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-ssa-ter.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-ssa-threadedge.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-ssa-threadupdate.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-ssa.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-ssanames.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-stdarg.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-streamer.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-switch-conversion.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-vector-builder.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-vectorizer.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-vrp.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree.def lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/treestruct.def lib/gcc/${CONFIG}/${VERSION}/plugin/include/tristate.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tsan.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tsystem.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/typeclass.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/typed-splay-tree.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/ubsan.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/valtrack.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/value-pointer-equiv.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/value-prof.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/value-query.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/value-range-equiv.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/value-range.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/value-relation.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/varasm.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/vec-perm-indices.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/vec.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/vector-builder.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/version.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/vmsdbg.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/vr-values.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/vtable-verify.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/wide-int-bitmask.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/wide-int-print.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/wide-int.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/xcoff.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/xcoffout.h ================================================ FILE: tools/openbsd/ports/mystuff/devel/arm-none-eabi/gcc/pkg/PFRAG.arm ================================================ @conflict arm-none-eabi-gcc-linaro-* @pkgpath devel/arm-none-eabi/gcc-linaro, @pkgpath devel/arm-none-eabi/gcc-linaro,arm lib/gcc/ lib/gcc/${CONFIG}/ lib/gcc/${CONFIG}/${VERSION}/ lib/gcc/${CONFIG}/${VERSION}/arm/ lib/gcc/${CONFIG}/${VERSION}/arm/v5te/ lib/gcc/${CONFIG}/${VERSION}/arm/v5te/hard/ lib/gcc/${CONFIG}/${VERSION}/arm/v5te/hard/crtbegin.o lib/gcc/${CONFIG}/${VERSION}/arm/v5te/hard/crtend.o lib/gcc/${CONFIG}/${VERSION}/arm/v5te/hard/crtfastmath.o lib/gcc/${CONFIG}/${VERSION}/arm/v5te/hard/crti.o lib/gcc/${CONFIG}/${VERSION}/arm/v5te/hard/crtn.o @static-lib lib/gcc/${CONFIG}/${VERSION}/arm/v5te/hard/libgcc.a @static-lib lib/gcc/${CONFIG}/${VERSION}/arm/v5te/hard/libgcov.a lib/gcc/${CONFIG}/${VERSION}/arm/v5te/softfp/ lib/gcc/${CONFIG}/${VERSION}/arm/v5te/softfp/crtbegin.o lib/gcc/${CONFIG}/${VERSION}/arm/v5te/softfp/crtend.o lib/gcc/${CONFIG}/${VERSION}/arm/v5te/softfp/crtfastmath.o lib/gcc/${CONFIG}/${VERSION}/arm/v5te/softfp/crti.o lib/gcc/${CONFIG}/${VERSION}/arm/v5te/softfp/crtn.o @static-lib lib/gcc/${CONFIG}/${VERSION}/arm/v5te/softfp/libgcc.a @static-lib lib/gcc/${CONFIG}/${VERSION}/arm/v5te/softfp/libgcov.a lib/gcc/${CONFIG}/${VERSION}/crtbegin.o lib/gcc/${CONFIG}/${VERSION}/crtend.o lib/gcc/${CONFIG}/${VERSION}/crtfastmath.o lib/gcc/${CONFIG}/${VERSION}/crti.o lib/gcc/${CONFIG}/${VERSION}/crtn.o lib/gcc/${CONFIG}/${VERSION}/include/ lib/gcc/${CONFIG}/${VERSION}/include-fixed/ lib/gcc/${CONFIG}/${VERSION}/include-fixed/README lib/gcc/${CONFIG}/${VERSION}/include-fixed/limits.h lib/gcc/${CONFIG}/${VERSION}/include-fixed/syslimits.h lib/gcc/${CONFIG}/${VERSION}/include/arm_acle.h lib/gcc/${CONFIG}/${VERSION}/include/arm_bf16.h lib/gcc/${CONFIG}/${VERSION}/include/arm_cde.h lib/gcc/${CONFIG}/${VERSION}/include/arm_cmse.h lib/gcc/${CONFIG}/${VERSION}/include/arm_fp16.h lib/gcc/${CONFIG}/${VERSION}/include/arm_mve.h lib/gcc/${CONFIG}/${VERSION}/include/arm_mve_types.h lib/gcc/${CONFIG}/${VERSION}/include/arm_neon.h lib/gcc/${CONFIG}/${VERSION}/include/float.h lib/gcc/${CONFIG}/${VERSION}/include/gcov.h lib/gcc/${CONFIG}/${VERSION}/include/iso646.h lib/gcc/${CONFIG}/${VERSION}/include/mmintrin.h lib/gcc/${CONFIG}/${VERSION}/include/stdalign.h lib/gcc/${CONFIG}/${VERSION}/include/stdarg.h lib/gcc/${CONFIG}/${VERSION}/include/stdatomic.h lib/gcc/${CONFIG}/${VERSION}/include/stdbool.h lib/gcc/${CONFIG}/${VERSION}/include/stddef.h lib/gcc/${CONFIG}/${VERSION}/include/stdfix.h lib/gcc/${CONFIG}/${VERSION}/include/stdint-gcc.h lib/gcc/${CONFIG}/${VERSION}/include/stdint.h lib/gcc/${CONFIG}/${VERSION}/include/stdnoreturn.h lib/gcc/${CONFIG}/${VERSION}/include/tgmath.h lib/gcc/${CONFIG}/${VERSION}/include/unwind-arm-common.h lib/gcc/${CONFIG}/${VERSION}/include/unwind.h lib/gcc/${CONFIG}/${VERSION}/include/varargs.h lib/gcc/${CONFIG}/${VERSION}/install-tools/ lib/gcc/${CONFIG}/${VERSION}/install-tools/fixinc_list lib/gcc/${CONFIG}/${VERSION}/install-tools/gsyslimits.h lib/gcc/${CONFIG}/${VERSION}/install-tools/include/ lib/gcc/${CONFIG}/${VERSION}/install-tools/include/README lib/gcc/${CONFIG}/${VERSION}/install-tools/include/limits.h lib/gcc/${CONFIG}/${VERSION}/install-tools/macro_list lib/gcc/${CONFIG}/${VERSION}/install-tools/mkheaders.conf @static-lib lib/gcc/${CONFIG}/${VERSION}/libgcc.a @static-lib lib/gcc/${CONFIG}/${VERSION}/libgcov.a lib/gcc/${CONFIG}/${VERSION}/plugin/ lib/gcc/${CONFIG}/${VERSION}/plugin/gtype.state lib/gcc/${CONFIG}/${VERSION}/plugin/include/ lib/gcc/${CONFIG}/${VERSION}/plugin/include/ada/ lib/gcc/${CONFIG}/${VERSION}/plugin/include/ada/gcc-interface/ lib/gcc/${CONFIG}/${VERSION}/plugin/include/ada/gcc-interface/ada-tree.def lib/gcc/${CONFIG}/${VERSION}/plugin/include/addresses.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/alias.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/align.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/all-tree.def lib/gcc/${CONFIG}/${VERSION}/plugin/include/alloc-pool.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/ansidecl.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/arm-cpu.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/arm-isa.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/array-traits.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/asan.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/attr-fnspec.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/attribs.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/auto-host.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/auto-profile.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/b-header-vars lib/gcc/${CONFIG}/${VERSION}/plugin/include/backend.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/basic-block.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/bb-reorder.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/bitmap.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/builtin-attrs.def lib/gcc/${CONFIG}/${VERSION}/plugin/include/builtin-types.def lib/gcc/${CONFIG}/${VERSION}/plugin/include/builtins.def lib/gcc/${CONFIG}/${VERSION}/plugin/include/builtins.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/bversion.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/c-family/ lib/gcc/${CONFIG}/${VERSION}/plugin/include/c-family/c-common.def lib/gcc/${CONFIG}/${VERSION}/plugin/include/c-family/c-common.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/c-family/c-objc.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/c-family/c-pragma.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/c-family/c-pretty-print.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/c-tree.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/calls.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/ccmp.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/cfg-flags.def lib/gcc/${CONFIG}/${VERSION}/plugin/include/cfg.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/cfganal.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/cfgbuild.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/cfgcleanup.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/cfgexpand.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/cfghooks.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/cfgloop.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/cfgloopmanip.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/cfgrtl.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/cgraph.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/cif-code.def lib/gcc/${CONFIG}/${VERSION}/plugin/include/collect-utils.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/collect2-aix.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/collect2.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/color-macros.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/conditions.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/config/ lib/gcc/${CONFIG}/${VERSION}/plugin/include/config.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/config/arm/ lib/gcc/${CONFIG}/${VERSION}/plugin/include/config/arm/aarch-common-protos.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/config/arm/aout.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/config/arm/arm-flags.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/config/arm/arm-opts.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/config/arm/arm-protos.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/config/arm/arm.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/config/arm/bpabi.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/config/arm/elf.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/config/arm/unknown-elf.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/config/dbxelf.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/config/elfos.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/config/initfini-array.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/config/newlib-stdint.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/config/vxworks-dummy.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/configargs.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/context.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/convert.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/coretypes.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/coroutine-builtins.def lib/gcc/${CONFIG}/${VERSION}/plugin/include/coverage.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/cp/ lib/gcc/${CONFIG}/${VERSION}/plugin/include/cp/cp-tree.def lib/gcc/${CONFIG}/${VERSION}/plugin/include/cp/cp-tree.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/cp/cxx-pretty-print.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/cp/name-lookup.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/cp/operators.def lib/gcc/${CONFIG}/${VERSION}/plugin/include/cp/type-utils.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/cppbuiltin.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/cppdefault.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/cpplib.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/cselib.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/ctfc.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/d/ lib/gcc/${CONFIG}/${VERSION}/plugin/include/d/d-tree.def lib/gcc/${CONFIG}/${VERSION}/plugin/include/data-streamer.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/dbgcnt.def lib/gcc/${CONFIG}/${VERSION}/plugin/include/dbgcnt.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/dbxout.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/dce.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/ddg.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/debug.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/defaults.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/df.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/dfp.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/diagnostic-color.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/diagnostic-core.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/diagnostic-event-id.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/diagnostic-metadata.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/diagnostic-path.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/diagnostic-spec.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/diagnostic-url.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/diagnostic.def lib/gcc/${CONFIG}/${VERSION}/plugin/include/diagnostic.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/digraph.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/dojump.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/dominance.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/domwalk.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/double-int.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/dump-context.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/dumpfile.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/dwarf2asm.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/dwarf2ctf.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/dwarf2out.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/edit-context.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/emit-rtl.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/errors.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/escaped_string.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/et-forest.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/except.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/explow.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/expmed.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/expr.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/fibonacci_heap.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/file-find.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/file-prefix-map.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/filenames.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/fixed-value.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/flag-types.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/flags.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/fold-const-call.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/fold-const.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/function-abi.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/function.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/gcc-plugin.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/gcc-rich-location.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/gcc-symtab.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/gcc.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/gcov-counter.def lib/gcc/${CONFIG}/${VERSION}/plugin/include/gcov-io.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/gcse-common.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/gcse.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/generic-match.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/gengtype.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/genrtl.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/gensupport.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/ggc-internal.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/ggc.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/gimple-array-bounds.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/gimple-builder.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/gimple-expr.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/gimple-fold.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/gimple-iterator.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/gimple-low.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/gimple-match.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/gimple-predicate-analysis.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/gimple-predict.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/gimple-pretty-print.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/gimple-range-cache.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/gimple-range-edge.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/gimple-range-fold.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/gimple-range-gori.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/gimple-range-path.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/gimple-range-trace.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/gimple-range.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/gimple-ssa-evrp-analyze.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/gimple-ssa-warn-access.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/gimple-ssa-warn-restrict.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/gimple-ssa.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/gimple-streamer.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/gimple-walk.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/gimple.def lib/gcc/${CONFIG}/${VERSION}/plugin/include/gimple.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/gimplify-me.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/gimplify.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/glimits.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/gomp-constants.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/graph.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/graphds.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/graphite.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/graphviz.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/gsstruct.def lib/gcc/${CONFIG}/${VERSION}/plugin/include/gstab.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/gsyms.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/gsyslimits.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/gtm-builtins.def lib/gcc/${CONFIG}/${VERSION}/plugin/include/gtype-desc.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/hard-reg-set.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/hash-map-traits.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/hash-map.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/hash-set.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/hash-table.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/hash-traits.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/hashtab.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/highlev-plugin-common.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/hooks.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/hosthooks-def.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/hosthooks.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/hw-doloop.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/hwint.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/ifcvt.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/inchash.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/incpath.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/input.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/insn-addr.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/insn-attr-common.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/insn-attr.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/insn-codes.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/insn-config.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/insn-constants.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/insn-flags.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/insn-modes-inline.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/insn-modes.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/insn-notes.def lib/gcc/${CONFIG}/${VERSION}/plugin/include/int-vector-builder.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/internal-fn.def lib/gcc/${CONFIG}/${VERSION}/plugin/include/internal-fn.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/intl.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/ipa-fnsummary.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/ipa-icf-gimple.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/ipa-icf.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/ipa-inline.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/ipa-modref-tree.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/ipa-modref.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/ipa-param-manipulation.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/ipa-predicate.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/ipa-prop.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/ipa-ref.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/ipa-reference.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/ipa-utils.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/ira-int.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/ira.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/is-a.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/iterator-utils.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/json.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/langhooks-def.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/langhooks.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/lcm.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/libfuncs.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/libiberty.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/limitx.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/limity.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/line-map.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/loop-unroll.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/lower-subreg.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/lra-int.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/lra.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/lto-compress.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/lto-section-names.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/lto-streamer.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/machmode.def lib/gcc/${CONFIG}/${VERSION}/plugin/include/machmode.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/md5.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/mem-stats-traits.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/mem-stats.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/memmodel.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/memory-block.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/mode-classes.def lib/gcc/${CONFIG}/${VERSION}/plugin/include/mux-utils.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/objc/ lib/gcc/${CONFIG}/${VERSION}/plugin/include/objc/objc-tree.def lib/gcc/${CONFIG}/${VERSION}/plugin/include/obstack-utils.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/obstack.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/omp-builtins.def lib/gcc/${CONFIG}/${VERSION}/plugin/include/omp-expand.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/omp-general.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/omp-low.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/omp-offload.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/omp-simd-clone.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/opt-problem.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/opt-suggestions.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/optabs-libfuncs.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/optabs-query.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/optabs-tree.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/optabs.def lib/gcc/${CONFIG}/${VERSION}/plugin/include/optabs.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/optinfo-emit-json.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/optinfo.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/options.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/opts-diagnostic.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/opts.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/ordered-hash-map.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/output.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/pass-instances.def lib/gcc/${CONFIG}/${VERSION}/plugin/include/pass_manager.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/passes.def lib/gcc/${CONFIG}/${VERSION}/plugin/include/plugin-api.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/plugin-version.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/plugin.def lib/gcc/${CONFIG}/${VERSION}/plugin/include/plugin.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/pointer-query.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/poly-int-types.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/poly-int.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/predict.def lib/gcc/${CONFIG}/${VERSION}/plugin/include/predict.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/prefix.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/pretty-print.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/print-rtl.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/print-tree.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/profile-count.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/profile.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/range-op.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/range.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/read-md.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/read-rtl-function.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/real.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/realmpfr.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/recog.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/reg-notes.def lib/gcc/${CONFIG}/${VERSION}/plugin/include/regcprop.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/regrename.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/regs.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/regset.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/reload.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/resource.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/rtl-error.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/rtl-iter.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/rtl-ssa.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/rtl.def lib/gcc/${CONFIG}/${VERSION}/plugin/include/rtl.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/rtlanal.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/rtlhash.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/rtlhooks-def.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/rtx-vector-builder.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/run-rtl-passes.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/safe-ctype.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/sanitizer.def lib/gcc/${CONFIG}/${VERSION}/plugin/include/sbitmap.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/sched-int.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/sel-sched-dump.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/sel-sched-ir.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/sel-sched.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/selftest-diagnostic.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/selftest-rtl.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/selftest.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/sese.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/shortest-paths.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/shrink-wrap.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/signop.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/sparseset.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/spellcheck-tree.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/spellcheck.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/splay-tree-utils.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/splay-tree.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/sreal.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/ssa-iterators.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/ssa.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/stab.def lib/gcc/${CONFIG}/${VERSION}/plugin/include/statistics.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/stmt.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/stor-layout.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/streamer-hooks.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/stringpool.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/substring-locations.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/symbol-summary.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/symtab-clones.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/symtab-thunks.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/symtab.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/sync-builtins.def lib/gcc/${CONFIG}/${VERSION}/plugin/include/system.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/target-def.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/target-globals.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/target-hooks-macros.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/target-insns.def lib/gcc/${CONFIG}/${VERSION}/plugin/include/target.def lib/gcc/${CONFIG}/${VERSION}/plugin/include/target.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/targhooks.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/timevar.def lib/gcc/${CONFIG}/${VERSION}/plugin/include/timevar.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tm-preds.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tm.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tm_p.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/toplev.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tracer.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/trans-mem.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-affine.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-cfg.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-cfgcleanup.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-check.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-chrec.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-core.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-data-ref.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-dfa.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-diagnostic.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-dump.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-eh.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-hash-traits.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-hasher.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-if-conv.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-inline.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-into-ssa.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-iterator.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-nested.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-object-size.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-outof-ssa.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-parloops.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-pass.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-phinodes.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-pretty-print.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-scalar-evolution.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-sra.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-ssa-address.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-ssa-alias-compare.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-ssa-alias.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-ssa-ccp.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-ssa-coalesce.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-ssa-dce.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-ssa-dom.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-ssa-dse.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-ssa-live.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-ssa-loop-ivopts.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-ssa-loop-manip.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-ssa-loop-niter.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-ssa-loop.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-ssa-math-opts.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-ssa-operands.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-ssa-propagate.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-ssa-reassoc.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-ssa-sccvn.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-ssa-scopedtables.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-ssa-strlen.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-ssa-ter.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-ssa-threadedge.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-ssa-threadupdate.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-ssa.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-ssanames.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-stdarg.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-streamer.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-switch-conversion.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-vector-builder.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-vectorizer.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree-vrp.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree.def lib/gcc/${CONFIG}/${VERSION}/plugin/include/tree.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/treestruct.def lib/gcc/${CONFIG}/${VERSION}/plugin/include/tristate.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tsan.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/tsystem.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/typeclass.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/typed-splay-tree.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/ubsan.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/valtrack.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/value-pointer-equiv.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/value-prof.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/value-query.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/value-range-equiv.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/value-range.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/value-relation.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/varasm.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/vec-perm-indices.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/vec.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/vector-builder.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/version.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/vmsdbg.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/vr-values.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/vtable-verify.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/wide-int-bitmask.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/wide-int-print.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/wide-int.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/xcoff.h lib/gcc/${CONFIG}/${VERSION}/plugin/include/xcoffout.h lib/gcc/${CONFIG}/${VERSION}/thumb/ lib/gcc/${CONFIG}/${VERSION}/thumb/nofp/ lib/gcc/${CONFIG}/${VERSION}/thumb/nofp/crtbegin.o lib/gcc/${CONFIG}/${VERSION}/thumb/nofp/crtend.o lib/gcc/${CONFIG}/${VERSION}/thumb/nofp/crtfastmath.o lib/gcc/${CONFIG}/${VERSION}/thumb/nofp/crti.o lib/gcc/${CONFIG}/${VERSION}/thumb/nofp/crtn.o @static-lib lib/gcc/${CONFIG}/${VERSION}/thumb/nofp/libgcc.a @static-lib lib/gcc/${CONFIG}/${VERSION}/thumb/nofp/libgcov.a lib/gcc/${CONFIG}/${VERSION}/thumb/v6-m/ lib/gcc/${CONFIG}/${VERSION}/thumb/v6-m/nofp/ lib/gcc/${CONFIG}/${VERSION}/thumb/v6-m/nofp/crtbegin.o lib/gcc/${CONFIG}/${VERSION}/thumb/v6-m/nofp/crtend.o lib/gcc/${CONFIG}/${VERSION}/thumb/v6-m/nofp/crtfastmath.o lib/gcc/${CONFIG}/${VERSION}/thumb/v6-m/nofp/crti.o lib/gcc/${CONFIG}/${VERSION}/thumb/v6-m/nofp/crtn.o @static-lib lib/gcc/${CONFIG}/${VERSION}/thumb/v6-m/nofp/libgcc.a @static-lib lib/gcc/${CONFIG}/${VERSION}/thumb/v6-m/nofp/libgcov.a lib/gcc/${CONFIG}/${VERSION}/thumb/v7/ lib/gcc/${CONFIG}/${VERSION}/thumb/v7+fp/ lib/gcc/${CONFIG}/${VERSION}/thumb/v7+fp/hard/ lib/gcc/${CONFIG}/${VERSION}/thumb/v7+fp/hard/crtbegin.o lib/gcc/${CONFIG}/${VERSION}/thumb/v7+fp/hard/crtend.o lib/gcc/${CONFIG}/${VERSION}/thumb/v7+fp/hard/crtfastmath.o lib/gcc/${CONFIG}/${VERSION}/thumb/v7+fp/hard/crti.o lib/gcc/${CONFIG}/${VERSION}/thumb/v7+fp/hard/crtn.o @static-lib lib/gcc/${CONFIG}/${VERSION}/thumb/v7+fp/hard/libgcc.a @static-lib lib/gcc/${CONFIG}/${VERSION}/thumb/v7+fp/hard/libgcov.a lib/gcc/${CONFIG}/${VERSION}/thumb/v7+fp/softfp/ lib/gcc/${CONFIG}/${VERSION}/thumb/v7+fp/softfp/crtbegin.o lib/gcc/${CONFIG}/${VERSION}/thumb/v7+fp/softfp/crtend.o lib/gcc/${CONFIG}/${VERSION}/thumb/v7+fp/softfp/crtfastmath.o lib/gcc/${CONFIG}/${VERSION}/thumb/v7+fp/softfp/crti.o lib/gcc/${CONFIG}/${VERSION}/thumb/v7+fp/softfp/crtn.o @static-lib lib/gcc/${CONFIG}/${VERSION}/thumb/v7+fp/softfp/libgcc.a @static-lib lib/gcc/${CONFIG}/${VERSION}/thumb/v7+fp/softfp/libgcov.a lib/gcc/${CONFIG}/${VERSION}/thumb/v7-m/ lib/gcc/${CONFIG}/${VERSION}/thumb/v7-m/nofp/ lib/gcc/${CONFIG}/${VERSION}/thumb/v7-m/nofp/crtbegin.o lib/gcc/${CONFIG}/${VERSION}/thumb/v7-m/nofp/crtend.o lib/gcc/${CONFIG}/${VERSION}/thumb/v7-m/nofp/crtfastmath.o lib/gcc/${CONFIG}/${VERSION}/thumb/v7-m/nofp/crti.o lib/gcc/${CONFIG}/${VERSION}/thumb/v7-m/nofp/crtn.o @static-lib lib/gcc/${CONFIG}/${VERSION}/thumb/v7-m/nofp/libgcc.a @static-lib lib/gcc/${CONFIG}/${VERSION}/thumb/v7-m/nofp/libgcov.a lib/gcc/${CONFIG}/${VERSION}/thumb/v7-r+fp.sp/ lib/gcc/${CONFIG}/${VERSION}/thumb/v7-r+fp.sp/hard/ lib/gcc/${CONFIG}/${VERSION}/thumb/v7-r+fp.sp/hard/crtbegin.o lib/gcc/${CONFIG}/${VERSION}/thumb/v7-r+fp.sp/hard/crtend.o lib/gcc/${CONFIG}/${VERSION}/thumb/v7-r+fp.sp/hard/crtfastmath.o lib/gcc/${CONFIG}/${VERSION}/thumb/v7-r+fp.sp/hard/crti.o lib/gcc/${CONFIG}/${VERSION}/thumb/v7-r+fp.sp/hard/crtn.o @static-lib lib/gcc/${CONFIG}/${VERSION}/thumb/v7-r+fp.sp/hard/libgcc.a @static-lib lib/gcc/${CONFIG}/${VERSION}/thumb/v7-r+fp.sp/hard/libgcov.a lib/gcc/${CONFIG}/${VERSION}/thumb/v7-r+fp.sp/softfp/ lib/gcc/${CONFIG}/${VERSION}/thumb/v7-r+fp.sp/softfp/crtbegin.o lib/gcc/${CONFIG}/${VERSION}/thumb/v7-r+fp.sp/softfp/crtend.o lib/gcc/${CONFIG}/${VERSION}/thumb/v7-r+fp.sp/softfp/crtfastmath.o lib/gcc/${CONFIG}/${VERSION}/thumb/v7-r+fp.sp/softfp/crti.o lib/gcc/${CONFIG}/${VERSION}/thumb/v7-r+fp.sp/softfp/crtn.o @static-lib lib/gcc/${CONFIG}/${VERSION}/thumb/v7-r+fp.sp/softfp/libgcc.a @static-lib lib/gcc/${CONFIG}/${VERSION}/thumb/v7-r+fp.sp/softfp/libgcov.a lib/gcc/${CONFIG}/${VERSION}/thumb/v7/nofp/ lib/gcc/${CONFIG}/${VERSION}/thumb/v7/nofp/crtbegin.o lib/gcc/${CONFIG}/${VERSION}/thumb/v7/nofp/crtend.o lib/gcc/${CONFIG}/${VERSION}/thumb/v7/nofp/crtfastmath.o lib/gcc/${CONFIG}/${VERSION}/thumb/v7/nofp/crti.o lib/gcc/${CONFIG}/${VERSION}/thumb/v7/nofp/crtn.o @static-lib lib/gcc/${CONFIG}/${VERSION}/thumb/v7/nofp/libgcc.a @static-lib lib/gcc/${CONFIG}/${VERSION}/thumb/v7/nofp/libgcov.a lib/gcc/${CONFIG}/${VERSION}/thumb/v7e-m/ lib/gcc/${CONFIG}/${VERSION}/thumb/v7e-m+dp/ lib/gcc/${CONFIG}/${VERSION}/thumb/v7e-m+dp/hard/ lib/gcc/${CONFIG}/${VERSION}/thumb/v7e-m+dp/hard/crtbegin.o lib/gcc/${CONFIG}/${VERSION}/thumb/v7e-m+dp/hard/crtend.o lib/gcc/${CONFIG}/${VERSION}/thumb/v7e-m+dp/hard/crtfastmath.o lib/gcc/${CONFIG}/${VERSION}/thumb/v7e-m+dp/hard/crti.o lib/gcc/${CONFIG}/${VERSION}/thumb/v7e-m+dp/hard/crtn.o @static-lib lib/gcc/${CONFIG}/${VERSION}/thumb/v7e-m+dp/hard/libgcc.a @static-lib lib/gcc/${CONFIG}/${VERSION}/thumb/v7e-m+dp/hard/libgcov.a lib/gcc/${CONFIG}/${VERSION}/thumb/v7e-m+dp/softfp/ lib/gcc/${CONFIG}/${VERSION}/thumb/v7e-m+dp/softfp/crtbegin.o lib/gcc/${CONFIG}/${VERSION}/thumb/v7e-m+dp/softfp/crtend.o lib/gcc/${CONFIG}/${VERSION}/thumb/v7e-m+dp/softfp/crtfastmath.o lib/gcc/${CONFIG}/${VERSION}/thumb/v7e-m+dp/softfp/crti.o lib/gcc/${CONFIG}/${VERSION}/thumb/v7e-m+dp/softfp/crtn.o @static-lib lib/gcc/${CONFIG}/${VERSION}/thumb/v7e-m+dp/softfp/libgcc.a @static-lib lib/gcc/${CONFIG}/${VERSION}/thumb/v7e-m+dp/softfp/libgcov.a lib/gcc/${CONFIG}/${VERSION}/thumb/v7e-m+fp/ lib/gcc/${CONFIG}/${VERSION}/thumb/v7e-m+fp/hard/ lib/gcc/${CONFIG}/${VERSION}/thumb/v7e-m+fp/hard/crtbegin.o lib/gcc/${CONFIG}/${VERSION}/thumb/v7e-m+fp/hard/crtend.o lib/gcc/${CONFIG}/${VERSION}/thumb/v7e-m+fp/hard/crtfastmath.o lib/gcc/${CONFIG}/${VERSION}/thumb/v7e-m+fp/hard/crti.o lib/gcc/${CONFIG}/${VERSION}/thumb/v7e-m+fp/hard/crtn.o @static-lib lib/gcc/${CONFIG}/${VERSION}/thumb/v7e-m+fp/hard/libgcc.a @static-lib lib/gcc/${CONFIG}/${VERSION}/thumb/v7e-m+fp/hard/libgcov.a lib/gcc/${CONFIG}/${VERSION}/thumb/v7e-m+fp/softfp/ lib/gcc/${CONFIG}/${VERSION}/thumb/v7e-m+fp/softfp/crtbegin.o lib/gcc/${CONFIG}/${VERSION}/thumb/v7e-m+fp/softfp/crtend.o lib/gcc/${CONFIG}/${VERSION}/thumb/v7e-m+fp/softfp/crtfastmath.o lib/gcc/${CONFIG}/${VERSION}/thumb/v7e-m+fp/softfp/crti.o lib/gcc/${CONFIG}/${VERSION}/thumb/v7e-m+fp/softfp/crtn.o @static-lib lib/gcc/${CONFIG}/${VERSION}/thumb/v7e-m+fp/softfp/libgcc.a @static-lib lib/gcc/${CONFIG}/${VERSION}/thumb/v7e-m+fp/softfp/libgcov.a lib/gcc/${CONFIG}/${VERSION}/thumb/v7e-m/nofp/ lib/gcc/${CONFIG}/${VERSION}/thumb/v7e-m/nofp/crtbegin.o lib/gcc/${CONFIG}/${VERSION}/thumb/v7e-m/nofp/crtend.o lib/gcc/${CONFIG}/${VERSION}/thumb/v7e-m/nofp/crtfastmath.o lib/gcc/${CONFIG}/${VERSION}/thumb/v7e-m/nofp/crti.o lib/gcc/${CONFIG}/${VERSION}/thumb/v7e-m/nofp/crtn.o @static-lib lib/gcc/${CONFIG}/${VERSION}/thumb/v7e-m/nofp/libgcc.a @static-lib lib/gcc/${CONFIG}/${VERSION}/thumb/v7e-m/nofp/libgcov.a lib/gcc/${CONFIG}/${VERSION}/thumb/v8-m.base/ lib/gcc/${CONFIG}/${VERSION}/thumb/v8-m.base/nofp/ lib/gcc/${CONFIG}/${VERSION}/thumb/v8-m.base/nofp/crtbegin.o lib/gcc/${CONFIG}/${VERSION}/thumb/v8-m.base/nofp/crtend.o lib/gcc/${CONFIG}/${VERSION}/thumb/v8-m.base/nofp/crtfastmath.o lib/gcc/${CONFIG}/${VERSION}/thumb/v8-m.base/nofp/crti.o lib/gcc/${CONFIG}/${VERSION}/thumb/v8-m.base/nofp/crtn.o @static-lib lib/gcc/${CONFIG}/${VERSION}/thumb/v8-m.base/nofp/libgcc.a @static-lib lib/gcc/${CONFIG}/${VERSION}/thumb/v8-m.base/nofp/libgcov.a lib/gcc/${CONFIG}/${VERSION}/thumb/v8-m.main/ lib/gcc/${CONFIG}/${VERSION}/thumb/v8-m.main+dp/ lib/gcc/${CONFIG}/${VERSION}/thumb/v8-m.main+dp/hard/ lib/gcc/${CONFIG}/${VERSION}/thumb/v8-m.main+dp/hard/crtbegin.o lib/gcc/${CONFIG}/${VERSION}/thumb/v8-m.main+dp/hard/crtend.o lib/gcc/${CONFIG}/${VERSION}/thumb/v8-m.main+dp/hard/crtfastmath.o lib/gcc/${CONFIG}/${VERSION}/thumb/v8-m.main+dp/hard/crti.o lib/gcc/${CONFIG}/${VERSION}/thumb/v8-m.main+dp/hard/crtn.o @static-lib lib/gcc/${CONFIG}/${VERSION}/thumb/v8-m.main+dp/hard/libgcc.a @static-lib lib/gcc/${CONFIG}/${VERSION}/thumb/v8-m.main+dp/hard/libgcov.a lib/gcc/${CONFIG}/${VERSION}/thumb/v8-m.main+dp/softfp/ lib/gcc/${CONFIG}/${VERSION}/thumb/v8-m.main+dp/softfp/crtbegin.o lib/gcc/${CONFIG}/${VERSION}/thumb/v8-m.main+dp/softfp/crtend.o lib/gcc/${CONFIG}/${VERSION}/thumb/v8-m.main+dp/softfp/crtfastmath.o lib/gcc/${CONFIG}/${VERSION}/thumb/v8-m.main+dp/softfp/crti.o lib/gcc/${CONFIG}/${VERSION}/thumb/v8-m.main+dp/softfp/crtn.o @static-lib lib/gcc/${CONFIG}/${VERSION}/thumb/v8-m.main+dp/softfp/libgcc.a @static-lib lib/gcc/${CONFIG}/${VERSION}/thumb/v8-m.main+dp/softfp/libgcov.a lib/gcc/${CONFIG}/${VERSION}/thumb/v8-m.main+fp/ lib/gcc/${CONFIG}/${VERSION}/thumb/v8-m.main+fp/hard/ lib/gcc/${CONFIG}/${VERSION}/thumb/v8-m.main+fp/hard/crtbegin.o lib/gcc/${CONFIG}/${VERSION}/thumb/v8-m.main+fp/hard/crtend.o lib/gcc/${CONFIG}/${VERSION}/thumb/v8-m.main+fp/hard/crtfastmath.o lib/gcc/${CONFIG}/${VERSION}/thumb/v8-m.main+fp/hard/crti.o lib/gcc/${CONFIG}/${VERSION}/thumb/v8-m.main+fp/hard/crtn.o @static-lib lib/gcc/${CONFIG}/${VERSION}/thumb/v8-m.main+fp/hard/libgcc.a @static-lib lib/gcc/${CONFIG}/${VERSION}/thumb/v8-m.main+fp/hard/libgcov.a lib/gcc/${CONFIG}/${VERSION}/thumb/v8-m.main+fp/softfp/ lib/gcc/${CONFIG}/${VERSION}/thumb/v8-m.main+fp/softfp/crtbegin.o lib/gcc/${CONFIG}/${VERSION}/thumb/v8-m.main+fp/softfp/crtend.o lib/gcc/${CONFIG}/${VERSION}/thumb/v8-m.main+fp/softfp/crtfastmath.o lib/gcc/${CONFIG}/${VERSION}/thumb/v8-m.main+fp/softfp/crti.o lib/gcc/${CONFIG}/${VERSION}/thumb/v8-m.main+fp/softfp/crtn.o @static-lib lib/gcc/${CONFIG}/${VERSION}/thumb/v8-m.main+fp/softfp/libgcc.a @static-lib lib/gcc/${CONFIG}/${VERSION}/thumb/v8-m.main+fp/softfp/libgcov.a lib/gcc/${CONFIG}/${VERSION}/thumb/v8-m.main/nofp/ lib/gcc/${CONFIG}/${VERSION}/thumb/v8-m.main/nofp/crtbegin.o lib/gcc/${CONFIG}/${VERSION}/thumb/v8-m.main/nofp/crtend.o lib/gcc/${CONFIG}/${VERSION}/thumb/v8-m.main/nofp/crtfastmath.o lib/gcc/${CONFIG}/${VERSION}/thumb/v8-m.main/nofp/crti.o lib/gcc/${CONFIG}/${VERSION}/thumb/v8-m.main/nofp/crtn.o @static-lib lib/gcc/${CONFIG}/${VERSION}/thumb/v8-m.main/nofp/libgcc.a @static-lib lib/gcc/${CONFIG}/${VERSION}/thumb/v8-m.main/nofp/libgcov.a lib/gcc/${CONFIG}/${VERSION}/thumb/v8.1-m.main+mve/ lib/gcc/${CONFIG}/${VERSION}/thumb/v8.1-m.main+mve/hard/ lib/gcc/${CONFIG}/${VERSION}/thumb/v8.1-m.main+mve/hard/crtbegin.o lib/gcc/${CONFIG}/${VERSION}/thumb/v8.1-m.main+mve/hard/crtend.o lib/gcc/${CONFIG}/${VERSION}/thumb/v8.1-m.main+mve/hard/crtfastmath.o lib/gcc/${CONFIG}/${VERSION}/thumb/v8.1-m.main+mve/hard/crti.o lib/gcc/${CONFIG}/${VERSION}/thumb/v8.1-m.main+mve/hard/crtn.o @static-lib lib/gcc/${CONFIG}/${VERSION}/thumb/v8.1-m.main+mve/hard/libgcc.a @static-lib lib/gcc/${CONFIG}/${VERSION}/thumb/v8.1-m.main+mve/hard/libgcov.a ================================================ FILE: tools/openbsd/ports/mystuff/devel/arm-none-eabi/gcc/pkg/PLIST ================================================ %%aarch64%% %%arm%% @bin bin/${CONFIG}-c++ @bin bin/${CONFIG}-cpp @bin bin/${CONFIG}-g++ @bin bin/${CONFIG}-gcc @bin bin/${CONFIG}-gcc-${VERSION} @bin bin/${CONFIG}-gcc-ar @bin bin/${CONFIG}-gcc-nm @bin bin/${CONFIG}-gcc-ranlib @bin bin/${CONFIG}-gcov @bin bin/${CONFIG}-gcov-dump @bin bin/${CONFIG}-gcov-tool @bin bin/${CONFIG}-lto-dump libexec/gcc/ libexec/gcc/${CONFIG}/ libexec/gcc/${CONFIG}/${VERSION}/ @bin libexec/gcc/${CONFIG}/${VERSION}/cc1 @bin libexec/gcc/${CONFIG}/${VERSION}/cc1plus @bin libexec/gcc/${CONFIG}/${VERSION}/collect2 @bin libexec/gcc/${CONFIG}/${VERSION}/g++-mapper-server libexec/gcc/${CONFIG}/${VERSION}/install-tools/ libexec/gcc/${CONFIG}/${VERSION}/install-tools/fixinc.sh @bin libexec/gcc/${CONFIG}/${VERSION}/install-tools/fixincl libexec/gcc/${CONFIG}/${VERSION}/install-tools/mkheaders libexec/gcc/${CONFIG}/${VERSION}/install-tools/mkinstalldirs libexec/gcc/${CONFIG}/${VERSION}/liblto_plugin.la @so libexec/gcc/${CONFIG}/${VERSION}/liblto_plugin.so @bin libexec/gcc/${CONFIG}/${VERSION}/lto-wrapper @bin libexec/gcc/${CONFIG}/${VERSION}/lto1 libexec/gcc/${CONFIG}/${VERSION}/plugin/ @bin libexec/gcc/${CONFIG}/${VERSION}/plugin/gengtype @man man/man1/${CONFIG}-cpp.1 @man man/man1/${CONFIG}-g++.1 @man man/man1/${CONFIG}-gcc.1 @man man/man1/${CONFIG}-gcov-dump.1 @man man/man1/${CONFIG}-gcov-tool.1 @man man/man1/${CONFIG}-gcov.1 @comment @man man/man7/fsf-funding.7 @comment @man man/man7/gfdl.7 @comment @man man/man7/gpl.7 @man man/man1/${CONFIG}-lto-dump.1 ================================================ FILE: tools/openbsd/ports/mystuff/devel/arm-none-eabi/gdb/Makefile ================================================ COMMENT= gdb for arm-none-eabi cross-development DISTNAME= gdb-12.1 HOMEPAGE= https://www.gnu.org/software/gdb/ WANTLIB+= ${COMPILER_LIBCXX} WANTLIB+= c curses expat m pthread SITES= ${SITE_GNU:=gdb/} DIST_SUBDIR= gdb USE_GMAKE= Yes MODGNU_CONFIG_GUESS_DIRS= ${WRKSRC} ${WRKSRC}/gdb # C++11 COMPILER= base-clang ports-gcc SEPARATE_BUILD= Yes CONFIGURE_ARGS+= \ --disable-install-libbfd \ --disable-sim \ --enable-interwork \ --enable-multilib \ --enable-thumb \ --with-system-zlib \ --without-guile \ --without-isl \ --without-lzma \ --without-mpc \ --without-mpfr \ --without-python MAKE_FLAGS= V=1 LDFLAGS="-L${LOCALBASE}/lib ${LDFLAGS}" # Avoid using malloc replacement for no good reason MAKE_ENV= gl_cv_malloc_ptrdiff=yes MODULES+= lang/python TEST_DEPENDS= devel/dejagnu .include ================================================ FILE: tools/openbsd/ports/mystuff/devel/arm-none-eabi/gdb/distinfo ================================================ SHA256 (gdb/gdb-12.1.tar.xz) = DheTv48rVNU/Rt6oTM/URvSPgbKXsoxPf8AXuBjWn+0= SIZE (gdb/gdb-12.1.tar.xz) = 22470332 ================================================ FILE: tools/openbsd/ports/mystuff/devel/arm-none-eabi/gdb/patches/patch-gdb_data-directory_Makefile_in ================================================ Index: gdb/data-directory/Makefile.in --- gdb/data-directory/Makefile.in.orig +++ gdb/data-directory/Makefile.in @@ -199,7 +199,7 @@ stamp-syscalls: Makefile $(SYSCALLS_FILES) for file in $$files ; do \ f=$(SYSCALLS_SRCDIR)/$$file ; \ if test -f $$f ; then \ - $(INSTALL_DATA) $$f ./$(SYSCALLS_DIR) ; \ + cp $$f ./$(SYSCALLS_DIR) ; \ fi ; \ done touch $@ @@ -241,8 +241,8 @@ stamp-python: Makefile $(PYTHON_FILES) if test "x$$files" != x ; then \ for file in $$files ; do \ dir=`echo "$$file" | sed 's,/[^/]*$$,,'` ; \ - $(INSTALL_DIR) ./$(PYTHON_DIR)/$$dir ; \ - $(INSTALL_DATA) $(PYTHON_SRCDIR)/$$file ./$(PYTHON_DIR)/$$dir ; \ + mkdir -p ./$(PYTHON_DIR)/$$dir ; \ + cp $(PYTHON_SRCDIR)/$$file ./$(PYTHON_DIR)/$$dir ; \ done ; \ fi touch $@ @@ -335,7 +335,7 @@ stamp-system-gdbinit: Makefile $(SYSTEM_GDBINIT_FILES) for file in $$files ; do \ f=$(SYSTEM_GDBINIT_SRCDIR)/$$file ; \ if test -f $$f ; then \ - $(INSTALL_DATA) $$f ./$(SYSTEM_GDBINIT_DIR) ; \ + cp $$f ./$(SYSTEM_GDBINIT_DIR) ; \ fi ; \ done touch $@ ================================================ FILE: tools/openbsd/ports/mystuff/devel/arm-none-eabi/gdb/patches/patch-gdb_i386-obsd-nat_c ================================================ Bogus variable name. Index: gdb/i386-obsd-nat.c --- gdb/i386-obsd-nat.c.orig +++ gdb/i386-obsd-nat.c @@ -94,7 +94,7 @@ void _initialize_i386obsd_nat (); void _initialize_i386obsd_nat () { - add_inf_child_target (&i386_obsd_nat_target); + add_inf_child_target (&the_i386_obsd_nat_target); /* Support debugging kernel virtual memory images. */ bsd_kvm_add_target (i386obsd_supply_pcb); ================================================ FILE: tools/openbsd/ports/mystuff/devel/arm-none-eabi/gdb/patches/patch-gdbsupport_enum-flags_h ================================================ Index: gdbsupport/enum-flags.h --- gdbsupport/enum-flags.h.orig +++ gdbsupport/enum-flags.h @@ -91,9 +91,12 @@ template<> struct integer_for_size<8, 1> { typedef int template struct enum_underlying_type { + DIAGNOSTIC_PUSH + DIAGNOSTIC_IGNORE_ENUM_CONSTEXPR_CONVERSION typedef typename integer_for_size(T (-1) < T (0))>::type type; + DIAGNOSTIC_POP }; namespace enum_flags_detail ================================================ FILE: tools/openbsd/ports/mystuff/devel/arm-none-eabi/gdb/patches/patch-include_diagnostics_h ================================================ From 12e3f3bc6ec74eb50e04675f5bcf962482d3ff25 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Thu, 23 Feb 2023 12:35:40 -0500 Subject: [PATCH] gdbsupport: ignore -Wenum-constexpr-conversion in enum-flags.h Index: include/diagnostics.h --- include/diagnostics.h.orig +++ include/diagnostics.h @@ -66,6 +66,11 @@ # define DIAGNOSTIC_ERROR_SWITCH \ DIAGNOSTIC_ERROR ("-Wswitch") +# if __has_warning ("-Wenum-constexpr-conversion") +# define DIAGNOSTIC_IGNORE_ENUM_CONSTEXPR_CONVERSION \ + DIAGNOSTIC_IGNORE ("-Wenum-constexpr-conversion") +# endif + #elif defined (__GNUC__) /* GCC */ # if __GNUC__ >= 7 @@ -110,6 +115,10 @@ #ifndef DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL # define DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL +#endif + +#ifndef DIAGNOSTIC_IGNORE_ENUM_CONSTEXPR_CONVERSION +# define DIAGNOSTIC_IGNORE_ENUM_CONSTEXPR_CONVERSION #endif #ifndef DIAGNOSTIC_ERROR_SWITCH ================================================ FILE: tools/openbsd/ports/mystuff/devel/arm-none-eabi/gdb/patches/patch-include_filenames_h ================================================ Our libiberty does not have filename_cmp(), but since it would simply call strcmp(), use a macro when building gdb and most of all libbfd. Fixes linking against libbfd with our system libiberty. Index: include/filenames.h --- include/filenames.h.orig +++ include/filenames.h @@ -81,11 +81,10 @@ extern "C" { (IS_DIR_SEPARATOR_1 (dos_based, (f)[0]) \ || HAS_DRIVE_SPEC_1 (dos_based, f)) -extern int filename_cmp (const char *s1, const char *s2); -#define FILENAME_CMP(s1, s2) filename_cmp(s1, s2) +#define FILENAME_CMP(s1, s2) strcmp(s1, s2) +#define filename_cmp(s1, s2) strcmp(s1, s2) -extern int filename_ncmp (const char *s1, const char *s2, - size_t n); +#define filename_ncmp(s1, s2, n) strncmp(s1, s2, n) extern hashval_t filename_hash (const void *s); ================================================ FILE: tools/openbsd/ports/mystuff/devel/arm-none-eabi/gdb/patches/patch-libiberty_Makefile_in ================================================ Index: libiberty/Makefile.in --- libiberty/Makefile.in.orig +++ libiberty/Makefile.in @@ -376,7 +376,7 @@ libiberty.html : $(srcdir)/libiberty.texi $(TEXISRC) @MAINT@ echo stamp > stamp-functions INSTALL_DEST = @INSTALL_DEST@ -install: install_to_$(INSTALL_DEST) install-subdir +install: install-strip: install .PHONY: install install-strip ================================================ FILE: tools/openbsd/ports/mystuff/devel/arm-none-eabi/gdb/patches/patch-libiberty_filename_cmp_c ================================================ Our libiberty does not have filename_cmp(), but since it would simply call strcmp(), use a macro when building gdb and most of all libbfd. Fixes linking against libbfd with our system libiberty. --- libiberty/filename_cmp.c.orig Thu Feb 19 12:58:08 2015 +++ libiberty/filename_cmp.c Fri Feb 20 22:12:26 2015 @@ -52,6 +52,7 @@ and backward slashes are equal. */ +#if 0 int filename_cmp (const char *s1, const char *s2) { @@ -146,6 +147,7 @@ filename_ncmp (const char *s1, const char *s2, size_t return 0; #endif } +#endif /* ================================================ FILE: tools/openbsd/ports/mystuff/devel/arm-none-eabi/gdb/pkg/DESCR ================================================ This is the GNU debugger, configured for the arm-none-eabi target. For more information, type "help" from within GDB, or consult the GDB manual (available as on-line info or a printed manual). ================================================ FILE: tools/openbsd/ports/mystuff/devel/arm-none-eabi/gdb/pkg/PLIST ================================================ @bin bin/arm-none-eabi-gdb bin/arm-none-eabi-gdb-add-index @comment lib/charset.alias @comment include/gdb/ @comment include/gdb/jit-reader.h @comment @info info/annotate.info @comment @info info/bfd.info @comment @info info/ctf-spec.info @comment @info info/gdb.info @comment @info info/stabs.info @man man/man1/arm-none-eabi-gdb-add-index.1 @man man/man1/arm-none-eabi-gdb.1 @man man/man1/arm-none-eabi-gdbserver.1 @man man/man5/arm-none-eabi-gdbinit.5 @comment share/gdb/syscalls/ @comment share/gdb/syscalls/aarch64-linux.xml @comment share/gdb/syscalls/amd64-linux.xml @comment share/gdb/syscalls/arm-linux.xml @comment share/gdb/syscalls/freebsd.xml @comment share/gdb/syscalls/gdb-syscalls.dtd @comment share/gdb/syscalls/i386-linux.xml @comment share/gdb/syscalls/mips-n32-linux.xml @comment share/gdb/syscalls/mips-n64-linux.xml @comment share/gdb/syscalls/mips-o32-linux.xml @comment share/gdb/syscalls/netbsd.xml @comment share/gdb/syscalls/ppc-linux.xml @comment share/gdb/syscalls/ppc64-linux.xml @comment share/gdb/syscalls/s390-linux.xml @comment share/gdb/syscalls/s390x-linux.xml @comment share/gdb/syscalls/sparc-linux.xml @comment share/gdb/syscalls/sparc64-linux.xml @comment share/gdb/system-gdbinit/ @comment share/gdb/system-gdbinit/elinos.py @comment share/gdb/system-gdbinit/wrs-linux.py ================================================ FILE: tools/openbsd/ports/mystuff/devel/arm-none-eabi/newlib/Makefile ================================================ COMMENT= newlib for arm-none-eabi cross-development DISTNAME= newlib-2.2.0-1 VERSION= 2.2.0.1 PKGNAME= ${CONFIG}-newlib-${VERSION} REVISION= 3 MAKE_ENV+= ${CONFIGURE_ENV} HOMEPAGE= http://sourceware.org/newlib/ SITES= ftp://sourceware.org/pub/newlib/ #SITES= ftp://sources.redhat.com/pub/newlib/ EXTRACT_SUFX= .tar.gz BUILD_DEPENDS= devel/arm-none-eabi/binutils,arm \ ${RUN_DEPENDS} RUN_DEPENDS= devel/arm-none-eabi/gcc,arm # cope with user settings in /etc/mk.conf MAKE_FLAGS= CFLAGS="-I${LOCALBASE}/include" USE_GMAKE= Yes CONFIGURE_ARGS+=--enable-interwork \ --enable-multilib post-install: ${INSTALL_DATA_DIR} ${PREFIX}/share/doc/arm-none-eabi/newlib ${INSTALL_DATA} ${WRKDIST}/COPYING.NEWLIB \ ${PREFIX}/share/doc/arm-none-eabi/newlib .include ================================================ FILE: tools/openbsd/ports/mystuff/devel/arm-none-eabi/newlib/distinfo ================================================ SHA256 (newlib-2.2.0-1.tar.gz) = wdU/0XZdlVrFE6puL1dkVe51BwctQAMUSVyKiibryOw= SIZE (newlib-2.2.0-1.tar.gz) = 16597844 ================================================ FILE: tools/openbsd/ports/mystuff/devel/arm-none-eabi/newlib/patches/patch-etc_Makefile_in ================================================ --- etc/Makefile.in.orig Fri Jul 31 00:44:48 2009 +++ etc/Makefile.in Thu Oct 14 14:17:07 2010 @@ -58,7 +58,7 @@ TEXIDIR = $(srcdir)/../texinfo #### Host, target, and site specific Makefile fragments come in here. ### -INFOFILES = standards.info configure.info +INFOFILES = DVIFILES = standards.dvi configure.dvi PDFFILES = standards.pdf configure.pdf HTMLFILES = standards.html configure.html ================================================ FILE: tools/openbsd/ports/mystuff/devel/arm-none-eabi/newlib/patches/patch-libgloss_arm_Makefile_in ================================================ Make macro checks ARMv8-M baseline proof. Add newlib/libc/machine/arm to the include path if newlib is present. Index: libgloss/arm/Makefile.in --- libgloss/arm/Makefile.in.orig +++ libgloss/arm/Makefile.in @@ -94,6 +94,8 @@ IQ80310_INSTALL = install-iq80310 # Host specific makefile fragment comes in here. @host_makefile_frag@ +INCLUDES += `if [ -d ${objroot}/newlib ]; then echo -I$(srcroot)/newlib/libc/machine/arm; fi` + # # build a test program for each target board. Just trying to get # it to link is a good test, so we ignore all the errors for now. ================================================ FILE: tools/openbsd/ports/mystuff/devel/arm-none-eabi/newlib/patches/patch-libgloss_arm_arm_h ================================================ Include acle-compat.h. (THUMB_V7_V6M): Rename to ... (PREFER_THUMB): This. Use ACLE macros __ARM_ARCH_ISA_ARM instead of __ARM_ARCH_6M__ to decide whether to define it. (THUMB1_ONLY): Define for Thumb-1 only targets. (THUMB_V7M_V6M): Rename to ... (THUMB_VXM): This. Defined based on __ARM_ARCH_ISA_ARM, excluding ARMv7. Index: libgloss/arm/arm.h --- libgloss/arm/arm.h.orig +++ libgloss/arm/arm.h @@ -29,25 +29,27 @@ #ifndef _LIBGLOSS_ARM_H #define _LIBGLOSS_ARM_H -/* __thumb2__ stands for thumb on armva7(A/R/M/EM) architectures, - __ARM_ARCH_6M__ stands for armv6-M(thumb only) architecture, - __ARM_ARCH_7M__ stands for armv7-M(thumb only) architecture. - __ARM_ARCH_7EM__ stands for armv7e-M(thumb only) architecture. - There are some macro combinations used many times in libgloss/arm, - like (__thumb2__ || (__thumb__ && __ARM_ARCH_6M__)), so factor - it out and use THUMB_V7_V6M instead, which stands for thumb on - v6-m/v7 arch as the combination does. */ -#if defined(__thumb2__) || (defined(__thumb__) && defined(__ARM_ARCH_6M__)) -# define THUMB_V7_V6M +#include "acle-compat.h" + +/* Checking for targets supporting only Thumb instructions (eg. ARMv6-M) or + supporting Thumb-2 instructions, whether ARM instructions are available or + not, is done many times in libgloss/arm. So factor it out and use + PREFER_THUMB instead. */ +#if __thumb2__ || (__thumb__ && !__ARM_ARCH_ISA_ARM) +# define PREFER_THUMB #endif -/* The (__ARM_ARCH_7EM__ || __ARM_ARCH_7M__ || __ARM_ARCH_6M__) combination - stands for cortex-M profile architectures, which don't support ARM state. - Factor it out and use THUMB_V7M_V6M instead. */ -#if defined(__ARM_ARCH_7M__) \ - || defined(__ARM_ARCH_7EM__) \ - || defined(__ARM_ARCH_6M__) -# define THUMB_V7M_V6M +/* Processor only capable of executing Thumb-1 instructions. */ +#if __ARM_ARCH_ISA_THUMB == 1 && !__ARM_ARCH_ISA_ARM +# define THUMB1_ONLY +#endif + +/* M profile architectures. This is a different set of architectures than + those not having ARM ISA because it does not contain ARMv7. This macro is + necessary to test which architectures use bkpt as semihosting interface from + architectures using svc. */ +#if !__ARM_ARCH_ISA_ARM && !__ARM_ARCH_7__ +# define THUMB_VXM #endif /* Defined if this target supports the BLX Rm instruction. */ ================================================ FILE: tools/openbsd/ports/mystuff/devel/arm-none-eabi/newlib/patches/patch-libgloss_arm_crt0_S ================================================ Make macro checks ARMv8-M baseline proof. Index: libgloss/arm/crt0.S --- libgloss/arm/crt0.S.orig +++ libgloss/arm/crt0.S @@ -44,7 +44,7 @@ /* .text is used instead of .section .text so it works with arm-aout too. */ .text .syntax unified -#ifdef THUMB_V7_V6M +#ifdef PREFER_THUMB .thumb .macro FUNC_START name .global \name @@ -98,7 +98,7 @@ /* stack limit is at end of data */ /* allow slop for stack overflow handling and small frames */ -#ifdef __ARM_ARCH_6M__ +#ifdef THUMB1_ONLY ldr r0, .LC2 adds r0, #128 adds r0, #128 @@ -112,7 +112,7 @@ /* Issue Angel SWI to read stack info */ movs r0, #AngelSWI_Reason_HeapInfo adr r1, .LC0 /* point at ptr to 4 words to receive data */ -#ifdef THUMB_V7M_V6M +#ifdef THUMB_VXM bkpt AngelSWI #elif defined(__thumb2__) /* We are in thumb mode for startup on armv7 architectures. */ @@ -149,7 +149,7 @@ cmp r2, #0 beq .LC27 /* allow slop for stack overflow handling and small frames */ -#ifdef __ARM_ARCH_6M__ +#ifdef THUMB1_ONLY adds r2, #128 adds r2, #128 mov sl, r2 @@ -175,7 +175,7 @@ #ifdef __thumb2__ it eq #endif -#ifdef __ARM_ARCH_6M__ +#ifdef THUMB1_ONLY bne .LC28 ldr r3, .LC0 .LC28: @@ -187,7 +187,7 @@ have somehow missed it below (in which case it gets the same value as FIQ - not ideal, but better than nothing.) */ mov sp, r3 -#ifdef THUMB_V7_V6M +#ifdef PREFER_THUMB /* XXX Fill in stack assignments for interrupt modes. */ #else mrs r2, CPSR @@ -230,7 +230,7 @@ this default 64k is enough for the program being executed. However, it ensures that this simple crt0 world will not immediately cause an overflow event: */ -#ifdef __ARM_ARCH_6M__ +#ifdef THUMB1_ONLY movs r2, #64 lsls r2, r2, #10 subs r2, r3, r2 @@ -250,7 +250,7 @@ subs a3, a3, a1 /* Third arg: length of block */ -#if defined(__thumb__) && !defined(THUMB_V7_V6M) +#if __thumb__ && !defined(PREFER_THUMB) /* Enter Thumb mode.... */ add a4, pc, #1 /* Get the address of the Thumb block */ bx a4 /* Go there and start Thumb decoding */ @@ -421,7 +421,7 @@ __change_mode: bl FUNCTION (exit) /* Should not return. */ -#if defined(__thumb__) && !defined(THUMB_V7_V6M) +#if __thumb__ && !defined(PREFER_THUMB) /* Come out of Thumb mode. This code should be redundant. */ mov a4, pc ================================================ FILE: tools/openbsd/ports/mystuff/devel/arm-none-eabi/newlib/patches/patch-libgloss_arm_linux-crt0_c ================================================ Make macro checks ARMv8-M baseline proof. Index: libgloss/arm/linux-crt0.c --- libgloss/arm/linux-crt0.c.orig +++ libgloss/arm/linux-crt0.c @@ -12,7 +12,7 @@ static int _main(int argc, char *argv[]) __attribute__((noreturn)); -#if defined(__thumb__) && !defined(THUMB_V7_V6M) +#if __thumb__ && !defined(PREFER_THUMB) asm("\n" ".code 32\n" ".global _start\n" ================================================ FILE: tools/openbsd/ports/mystuff/devel/arm-none-eabi/newlib/patches/patch-libgloss_arm_redboot-crt0_S ================================================ Make macro checks ARMv8-M baseline proof. Index: libgloss/arm/redboot-crt0.S --- libgloss/arm/redboot-crt0.S.orig +++ libgloss/arm/redboot-crt0.S @@ -14,7 +14,7 @@ .text .syntax unified /* Setup the assembly entry point. */ -#ifdef THUMB_V7_V6M +#ifdef PREFER_THUMB .macro FUNC_START name .global \name .thumb_func @@ -31,13 +31,13 @@ FUNC_START SYM_NAME(_start) /* Unnecessary to set fp for v6-m/v7-m, which don't support ARM state. */ -#ifndef THUMB_V7M_V6M +#if __ARM_ARCH_ISA_ARM mov fp, #0 /* Null frame pointer. */ #endif movs r7, #0 /* Null frame pointer for Thumb. */ /* Enable interrupts for gdb debugging. */ -#ifdef THUMB_V7_V6M +#ifdef PREFER_THUMB cpsie if #else mrs r0, cpsr @@ -66,7 +66,7 @@ /* Nothing to left to clear. */ #endif -#if defined(__thumb__) && !defined(THUMB_V7_V6M) +#if __thumb__ && !defined(PREFER_THUMB) /* Enter Thumb mode. */ add a4, pc, #1 /* Get the address of the Thumb block. */ bx a4 /* Go there and start Thumb decoding. */ ================================================ FILE: tools/openbsd/ports/mystuff/devel/arm-none-eabi/newlib/patches/patch-libgloss_arm_swi_h ================================================ Make macro checks ARMv8-M baseline proof. Index: libgloss/arm/swi.h --- libgloss/arm/swi.h.orig +++ libgloss/arm/swi.h @@ -36,7 +36,7 @@ #define AngelSWI AngelSWI_ARM #endif /* For thumb only architectures use the BKPT instruction instead of SWI. */ -#ifdef THUMB_V7M_V6M +#ifdef THUMB_VXM #define AngelSWIInsn "bkpt" #define AngelSWIAsm bkpt #else ================================================ FILE: tools/openbsd/ports/mystuff/devel/arm-none-eabi/newlib/patches/patch-libgloss_arm_trap_S ================================================ Include code in trap.S for APCS only. Index: libgloss/arm/trap.S --- libgloss/arm/trap.S.orig +++ libgloss/arm/trap.S @@ -1,6 +1,6 @@ #include "arm.h" /* Run-time exception support */ -#ifndef THUMB_V7_V6M +#ifndef __ARM_EABI__ #include "swi.h" /* .text is used instead of .section .text so it works with arm-aout too. */ ================================================ FILE: tools/openbsd/ports/mystuff/devel/arm-none-eabi/newlib/patches/patch-newlib_doc_makedoc_c ================================================ Index: newlib/doc/makedoc.c --- newlib/doc/makedoc.c.orig +++ newlib/doc/makedoc.c @@ -1314,11 +1314,11 @@ DEFUN(compile, (string), /* Got a number, embedd the magic push number function */ add_to_definition(ptr, push_number); - add_to_definition(ptr, atol(word)); + add_to_definition(ptr, (stinst_type)atol(word)); break; default: add_to_definition(ptr, call); - add_to_definition(ptr, lookup_word(word)); + add_to_definition(ptr, (stinst_type)lookup_word(word)); } string = nextword(string, &word); ================================================ FILE: tools/openbsd/ports/mystuff/devel/arm-none-eabi/newlib/patches/patch-newlib_libc_machine_arm_setjmp_S ================================================ Make macro checks ARMv8-M baseline proof. Use ACLE macros __ARM_ARCH_ISA_THUMB and __ARM_ARCH_ISA_ARM to check for Thumb-2 only targets rather than __ARM_ARCH and __ARM_ARCH_PROFILE. Likewise for Thumb-1 only target and include acle-compat.h. Index: newlib/libc/machine/arm/setjmp.S --- newlib/libc/machine/arm/setjmp.S.orig +++ newlib/libc/machine/arm/setjmp.S @@ -2,6 +2,8 @@ Nick Clifton, Cygnus Solutions, 13 June 1997. */ +#include "acle-compat.h" + /* ANSI concatenation macros. */ #define CONCAT(a, b) CONCAT2(a, b) #define CONCAT2(a, b) a##b @@ -55,8 +57,8 @@ For Thumb-2 do everything in Thumb mode. */ -#if defined(__ARM_ARCH_6M__) -/* ARMv6-M has to be implemented in Thumb mode. */ +#if __ARM_ARCH_ISA_THUMB == 1 && !__ARM_ARCH_ISA_ARM +/* ARMv6-M-like has to be implemented in Thumb mode. */ .thumb .thumb_func ================================================ FILE: tools/openbsd/ports/mystuff/devel/arm-none-eabi/newlib/patches/patch-newlib_libc_machine_arm_strcmp_S ================================================ Make macro checks ARMv8-M baseline proof. Likewise for Thumb-1 and Thumb-2 only target and include acle-compat.h. Index: newlib/libc/machine/arm/strcmp.S --- newlib/libc/machine/arm/strcmp.S.orig +++ newlib/libc/machine/arm/strcmp.S @@ -29,6 +29,7 @@ /* Wrapper for the various implementations of strcmp. */ #include "arm_asm.h" +#include "acle-compat.h" #ifdef __ARM_BIG_ENDIAN #define S2LO lsl @@ -61,7 +62,7 @@ .endm #if defined (__OPTIMIZE_SIZE__) || defined (PREFER_SIZE_OVER_SPEED) \ - || (__ARM_ARCH == 6 && __ARM_ARCH_PROFILE == 'M') + || (__ARM_ARCH_ISA_THUMB == 1 && !__ARM_ARCH_ISA_ARM) # if defined (__thumb__) && !defined (__thumb2__) /* Thumb1 only variant. If size is preferred, use strcmp-armv4t.S. @@ -78,7 +79,7 @@ # include "strcmp-arm-tiny.S" # endif -#elif __ARM_ARCH >= 7 +#elif __ARM_ARCH_ISA_THUMB == 2 # ifdef __ARM_FEATURE_SIMD32 # include "strcmp-armv7.S" ================================================ FILE: tools/openbsd/ports/mystuff/devel/arm-none-eabi/newlib/patches/patch-newlib_libc_sys_arm_Makefile_am ================================================ Fix build with newlib supplied syscalls enabled. acle-compat.h is libc/machine/arm. Index: newlib/libc/sys/arm/Makefile.am --- newlib/libc/sys/arm/Makefile.am.orig +++ newlib/libc/sys/arm/Makefile.am @@ -2,7 +2,7 @@ AUTOMAKE_OPTIONS = cygnus -INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS) +INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS) -I$(newlib_basedir)/libc/machine/arm AM_CCASFLAGS = $(INCLUDES) ================================================ FILE: tools/openbsd/ports/mystuff/devel/arm-none-eabi/newlib/patches/patch-newlib_libc_sys_arm_Makefile_in ================================================ Fix build with newlib supplied syscalls enabled. acle-compat.h is libc/machine/arm. Index: newlib/libc/sys/arm/Makefile.in --- newlib/libc/sys/arm/Makefile.in.orig +++ newlib/libc/sys/arm/Makefile.in @@ -193,7 +193,7 @@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AUTOMAKE_OPTIONS = cygnus -INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS) +INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS) -I$(newlib_basedir)/libc/machine/arm AM_CCASFLAGS = $(INCLUDES) noinst_LIBRARIES = lib.a @MAY_SUPPLY_SYSCALLS_FALSE@extra_objs = ================================================ FILE: tools/openbsd/ports/mystuff/devel/arm-none-eabi/newlib/patches/patch-newlib_libc_sys_arm_arm_h ================================================ Include acle-compat.h. (THUMB_V7_V6M): Rename to ... (PREFER_THUMB): This. Use ACLE macros __ARM_ARCH_ISA_ARM instead of __ARM_ARCH_6M__ to decide whether to define it. (THUMB1_ONLY): Define for Thumb-1 only targets. (THUMB_V7M_V6M): Rename to ... (THUMB_VXM): This. Defined based on __ARM_ARCH_ISA_ARM, excluding ARMv7. Index: newlib/libc/sys/arm/arm.h --- newlib/libc/sys/arm/arm.h.orig +++ newlib/libc/sys/arm/arm.h @@ -29,25 +29,27 @@ #ifndef _LIBGLOSS_ARM_H #define _LIBGLOSS_ARM_H -/* __thumb2__ stands for thumb on armva7(A/R/M/EM) architectures, - __ARM_ARCH_6M__ stands for armv6-M(thumb only) architecture, - __ARM_ARCH_7M__ stands for armv7-M(thumb only) architecture. - __ARM_ARCH_7EM__ stands for armv7e-M(thumb only) architecture. - There are some macro combinations used many times in libgloss/arm, - like (__thumb2__ || (__thumb__ && __ARM_ARCH_6M__)), so factor - it out and use THUMB_V7_V6M instead, which stands for thumb on - v6-m/v7 arch as the combination does. */ -#if defined(__thumb2__) || (defined(__thumb__) && defined(__ARM_ARCH_6M__)) -# define THUMB_V7_V6M +#include "acle-compat.h" + +/* Checking for targets supporting only Thumb instructions (eg. ARMv6-M) or + supporting Thumb-2 instructions, whether ARM instructions are available or + not, is done many times in libgloss/arm. So factor it out and use + PREFER_THUMB instead. */ +#if __thumb2__ || (__thumb__ && !__ARM_ARCH_ISA_ARM) +# define PREFER_THUMB #endif -/* The (__ARM_ARCH_7EM__ || __ARM_ARCH_7M__ || __ARM_ARCH_6M__) combination - stands for cortex-M profile architectures, which don't support ARM state. - Factor it out and use THUMB_V7M_V6M instead. */ -#if defined(__ARM_ARCH_7M__) \ - || defined(__ARM_ARCH_7EM__) \ - || defined(__ARM_ARCH_6M__) -# define THUMB_V7M_V6M +/* Processor only capable of executing Thumb-1 instructions. */ +#if __ARM_ARCH_ISA_THUMB == 1 && !__ARM_ARCH_ISA_ARM +# define THUMB1_ONLY +#endif + +/* M profile architectures. This is a different set of architectures than + those not having ARM ISA because it does not contain ARMv7. This macro is + necessary to test which architectures use bkpt as semihosting interface from + architectures using svc. */ +#if !__ARM_ARCH_ISA_ARM && !__ARM_ARCH_7__ +# define THUMB_VXM #endif /* Defined if this target supports the BLX Rm instruction. */ ================================================ FILE: tools/openbsd/ports/mystuff/devel/arm-none-eabi/newlib/patches/patch-newlib_libc_sys_arm_crt0_S ================================================ Make macro checks ARMv8-M baseline proof. Index: newlib/libc/sys/arm/crt0.S --- newlib/libc/sys/arm/crt0.S.orig +++ newlib/libc/sys/arm/crt0.S @@ -44,7 +44,7 @@ /* .text is used instead of .section .text so it works with arm-aout too. */ .text .syntax unified -#ifdef THUMB_V7_V6M +#ifdef PREFER_THUMB .thumb .macro FUNC_START name .global \name @@ -85,7 +85,7 @@ /* Stack limit is at end of data. */ /* Allow slop for stack overflow handling and small frames. */ -#ifdef __ARM_ARCH_6M__ +#ifdef THUMB1_ONLY ldr r0, .LC2 adds r0, #128 adds r0, #128 @@ -99,7 +99,7 @@ /* Issue Angel SWI to read stack info. */ movs r0, #AngelSWI_Reason_HeapInfo adr r1, .LC0 /* Point at ptr to 4 words to receive data. */ -#ifdef THUMB_V7M_V6M +#ifdef THUMB_VXM bkpt AngelSWI #elif defined(__thumb2__) /* We are in thumb mode for startup on armv7 architectures. */ @@ -137,7 +137,7 @@ beq .LC27 /* Allow slop for stack overflow handling and small frames. */ -#ifdef __ARM_ARCH_6M__ +#ifdef THUMB1_ONLY adds r2, #128 adds r2, #128 mov sl, r2 @@ -164,7 +164,7 @@ #ifdef __thumb2__ it eq #endif -#ifdef __ARM_ARCH_6M__ +#ifdef THUMB1_ONLY bne .LC28 ldr r3, .LC0 .LC28: @@ -176,7 +176,7 @@ have somehow missed it below (in which case it gets the same value as FIQ - not ideal, but better than nothing). */ mov sp, r3 -#ifdef THUMB_V7_V6M +#ifdef PREFER_THUMB /* XXX Fill in stack assignments for interrupt modes. */ #else mrs r2, CPSR @@ -219,7 +219,7 @@ this default 64k is enough for the program being executed. However, it ensures that this simple crt0 world will not immediately cause an overflow event: */ -#ifdef __ARM_ARCH_6M__ +#ifdef THUMB1_ONLY movs r2, #64 lsls r2, r2, #10 subs r2, r3, r2 @@ -239,7 +239,7 @@ subs a3, a3, a1 /* Third arg: length of block. */ -#if defined(__thumb__) && !defined(THUMB_V7_V6M) +#if __thumb__ && !defined(PREFER_THUMB) /* Enter Thumb mode... */ add a4, pc, #1 /* Get the address of the Thumb block. */ bx a4 /* Go there and start Thumb decoding. */ @@ -278,7 +278,7 @@ __change_mode: #else movs r0, #AngelSWI_Reason_GetCmdLine adr r1, .LC30 /* Space for command line. */ -#ifdef THUMB_V7M_V6M +#ifdef THUMB_VXM bkpt AngelSWI #else AngelSWIAsm AngelSWI @@ -404,7 +404,7 @@ __change_mode: bl FUNCTION (exit) /* Should not return. */ -#if defined(__thumb__) && !defined(THUMB_V7_V6M) +#if __thumb__ && !defined(PREFER_THUMB) /* Come out of Thumb mode. This code should be redundant. */ mov a4, pc bx a4 ================================================ FILE: tools/openbsd/ports/mystuff/devel/arm-none-eabi/newlib/patches/patch-newlib_libc_sys_arm_swi_h ================================================ Make macro checks ARMv8-M baseline proof. Index: newlib/libc/sys/arm/swi.h --- newlib/libc/sys/arm/swi.h.orig +++ newlib/libc/sys/arm/swi.h @@ -36,7 +36,7 @@ #define AngelSWI AngelSWI_ARM #endif /* For thumb only architectures use the BKPT instruction instead of SWI. */ -#ifdef THUMB_V7M_V6M +#ifdef THUMB_VXM #define AngelSWIInsn "bkpt" #define AngelSWIAsm bkpt #else ================================================ FILE: tools/openbsd/ports/mystuff/devel/arm-none-eabi/newlib/patches/patch-newlib_libc_sys_arm_trap_S ================================================ Include code in trap.S for APCS only. Index: newlib/libc/sys/arm/trap.S --- newlib/libc/sys/arm/trap.S.orig +++ newlib/libc/sys/arm/trap.S @@ -1,5 +1,5 @@ /* Run-time exception support */ -#if !defined(__thumb2__) +#ifndef __ARM_EABI__ #include "swi.h" /* .text is used instead of .section .text so it works with arm-aout too. */ ================================================ FILE: tools/openbsd/ports/mystuff/devel/arm-none-eabi/newlib/patches/patch-newlib_libm_machine_arm_s_ceil_c ================================================ Check for 64bit FP instructions availability in libm before using them. Index: newlib/libm/machine/arm/s_ceil.c --- newlib/libm/machine/arm/s_ceil.c.orig +++ newlib/libm/machine/arm/s_ceil.c @@ -24,7 +24,7 @@ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#if __ARM_ARCH >= 8 && !defined (__SOFTFP__) +#if __ARM_ARCH >= 8 && (__ARM_FP & 0x8) && !defined (__SOFTFP__) #include double ================================================ FILE: tools/openbsd/ports/mystuff/devel/arm-none-eabi/newlib/patches/patch-newlib_libm_machine_arm_s_floor_c ================================================ Check for 64bit FP instructions availability in libm before using them. Index: newlib/libm/machine/arm/s_floor.c --- newlib/libm/machine/arm/s_floor.c.orig +++ newlib/libm/machine/arm/s_floor.c @@ -24,7 +24,7 @@ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#if __ARM_ARCH >= 8 && !defined (__SOFTFP__) +#if __ARM_ARCH >= 8 && (__ARM_FP & 0x8) && !defined (__SOFTFP__) #include double ================================================ FILE: tools/openbsd/ports/mystuff/devel/arm-none-eabi/newlib/patches/patch-newlib_libm_machine_arm_s_nearbyint_c ================================================ Check for 64bit FP instructions availability in libm before using them. Index: newlib/libm/machine/arm/s_nearbyint.c --- newlib/libm/machine/arm/s_nearbyint.c.orig +++ newlib/libm/machine/arm/s_nearbyint.c @@ -24,7 +24,7 @@ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#if __ARM_ARCH >= 8 && !defined (__SOFTFP__) +#if __ARM_ARCH >= 8 && (__ARM_FP & 0x8) && !defined (__SOFTFP__) #include double ================================================ FILE: tools/openbsd/ports/mystuff/devel/arm-none-eabi/newlib/patches/patch-newlib_libm_machine_arm_s_rint_c ================================================ Check for 64bit FP instructions availability in libm before using them. Index: newlib/libm/machine/arm/s_rint.c --- newlib/libm/machine/arm/s_rint.c.orig +++ newlib/libm/machine/arm/s_rint.c @@ -24,7 +24,7 @@ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#if __ARM_ARCH >= 8 && !defined (__SOFTFP__) +#if __ARM_ARCH >= 8 && (__ARM_FP & 0x8) && !defined (__SOFTFP__) #include double ================================================ FILE: tools/openbsd/ports/mystuff/devel/arm-none-eabi/newlib/patches/patch-newlib_libm_machine_arm_s_round_c ================================================ Check for 64bit FP instructions availability in libm before using them. Index: newlib/libm/machine/arm/s_round.c --- newlib/libm/machine/arm/s_round.c.orig +++ newlib/libm/machine/arm/s_round.c @@ -24,7 +24,7 @@ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#if __ARM_ARCH >= 8 && !defined (__SOFTFP__) +#if __ARM_ARCH >= 8 && (__ARM_FP & 0x8) && !defined (__SOFTFP__) #include double ================================================ FILE: tools/openbsd/ports/mystuff/devel/arm-none-eabi/newlib/patches/patch-newlib_libm_machine_arm_s_trunc_c ================================================ Check for 64bit FP instructions availability in libm before using them. Index: newlib/libm/machine/arm/s_trunc.c --- newlib/libm/machine/arm/s_trunc.c.orig +++ newlib/libm/machine/arm/s_trunc.c @@ -24,7 +24,7 @@ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#if __ARM_ARCH >= 8 && !defined (__SOFTFP__) +#if __ARM_ARCH >= 8 && (__ARM_FP & 0x8) && !defined (__SOFTFP__) #include double ================================================ FILE: tools/openbsd/ports/mystuff/devel/arm-none-eabi/newlib/pkg/DESCR ================================================ Newlib is a C library intended for use on embedded systems. It is a conglomeration of several library parts, all under free software licenses that make them easily usable on embedded products. This port has been created to support development on embedded ARM systems but in theory, additional targets should be possible. ================================================ FILE: tools/openbsd/ports/mystuff/devel/arm-none-eabi/newlib/pkg/PLIST ================================================ arm-none-eabi/include/ arm-none-eabi/include/_ansi.h arm-none-eabi/include/_syslist.h arm-none-eabi/include/alloca.h arm-none-eabi/include/ar.h arm-none-eabi/include/argz.h arm-none-eabi/include/assert.h arm-none-eabi/include/bits/ arm-none-eabi/include/complex.h arm-none-eabi/include/ctype.h arm-none-eabi/include/dirent.h arm-none-eabi/include/envlock.h arm-none-eabi/include/envz.h arm-none-eabi/include/errno.h arm-none-eabi/include/fastmath.h arm-none-eabi/include/fcntl.h arm-none-eabi/include/fnmatch.h arm-none-eabi/include/getopt.h arm-none-eabi/include/glob.h arm-none-eabi/include/grp.h arm-none-eabi/include/iconv.h arm-none-eabi/include/ieeefp.h arm-none-eabi/include/inttypes.h arm-none-eabi/include/langinfo.h arm-none-eabi/include/libgen.h arm-none-eabi/include/limits.h arm-none-eabi/include/locale.h arm-none-eabi/include/machine/ arm-none-eabi/include/machine/_default_types.h arm-none-eabi/include/machine/_types.h arm-none-eabi/include/machine/ansi.h arm-none-eabi/include/machine/endian.h arm-none-eabi/include/machine/fastmath.h arm-none-eabi/include/machine/ieeefp.h arm-none-eabi/include/machine/malloc.h arm-none-eabi/include/machine/param.h arm-none-eabi/include/machine/setjmp-dj.h arm-none-eabi/include/machine/setjmp.h arm-none-eabi/include/machine/stdlib.h arm-none-eabi/include/machine/termios.h arm-none-eabi/include/machine/time.h arm-none-eabi/include/machine/types.h arm-none-eabi/include/malloc.h arm-none-eabi/include/math.h arm-none-eabi/include/newlib.h arm-none-eabi/include/paths.h arm-none-eabi/include/pthread.h arm-none-eabi/include/pwd.h arm-none-eabi/include/reent.h arm-none-eabi/include/regdef.h arm-none-eabi/include/regex.h arm-none-eabi/include/rpc/ arm-none-eabi/include/sched.h arm-none-eabi/include/search.h arm-none-eabi/include/setjmp.h arm-none-eabi/include/signal.h arm-none-eabi/include/spawn.h arm-none-eabi/include/stdatomic.h arm-none-eabi/include/stdint.h arm-none-eabi/include/stdio.h arm-none-eabi/include/stdio_ext.h arm-none-eabi/include/stdlib.h arm-none-eabi/include/string.h arm-none-eabi/include/strings.h arm-none-eabi/include/sys/ arm-none-eabi/include/sys/_default_fcntl.h arm-none-eabi/include/sys/_intsup.h arm-none-eabi/include/sys/_types.h arm-none-eabi/include/sys/cdefs.h arm-none-eabi/include/sys/config.h arm-none-eabi/include/sys/custom_file.h arm-none-eabi/include/sys/dir.h arm-none-eabi/include/sys/dirent.h arm-none-eabi/include/sys/errno.h arm-none-eabi/include/sys/fcntl.h arm-none-eabi/include/sys/features.h arm-none-eabi/include/sys/file.h arm-none-eabi/include/sys/iconvnls.h arm-none-eabi/include/sys/lock.h arm-none-eabi/include/sys/param.h arm-none-eabi/include/sys/queue.h arm-none-eabi/include/sys/reent.h arm-none-eabi/include/sys/resource.h arm-none-eabi/include/sys/sched.h arm-none-eabi/include/sys/signal.h arm-none-eabi/include/sys/stat.h arm-none-eabi/include/sys/stdio.h arm-none-eabi/include/sys/string.h arm-none-eabi/include/sys/syslimits.h arm-none-eabi/include/sys/time.h arm-none-eabi/include/sys/timeb.h arm-none-eabi/include/sys/times.h arm-none-eabi/include/sys/types.h arm-none-eabi/include/sys/unistd.h arm-none-eabi/include/sys/utime.h arm-none-eabi/include/sys/wait.h arm-none-eabi/include/tar.h arm-none-eabi/include/termios.h arm-none-eabi/include/tgmath.h arm-none-eabi/include/time.h arm-none-eabi/include/unctrl.h arm-none-eabi/include/unistd.h arm-none-eabi/include/utime.h arm-none-eabi/include/utmp.h arm-none-eabi/include/wchar.h arm-none-eabi/include/wctype.h arm-none-eabi/include/wordexp.h arm-none-eabi/lib/aprofile-validation.specs arm-none-eabi/lib/aprofile-ve.specs arm-none-eabi/lib/arm/ arm-none-eabi/lib/arm/v5te/ arm-none-eabi/lib/arm/v5te/hard/ arm-none-eabi/lib/arm/v5te/hard/aprofile-validation.specs arm-none-eabi/lib/arm/v5te/hard/aprofile-ve.specs arm-none-eabi/lib/arm/v5te/hard/cpu-init/ arm-none-eabi/lib/arm/v5te/hard/cpu-init/rdimon-aem.o arm-none-eabi/lib/arm/v5te/hard/crt0.o arm-none-eabi/lib/arm/v5te/hard/iq80310.specs @static-lib arm-none-eabi/lib/arm/v5te/hard/libc.a @static-lib arm-none-eabi/lib/arm/v5te/hard/libg.a @static-lib arm-none-eabi/lib/arm/v5te/hard/libgloss-linux.a @static-lib arm-none-eabi/lib/arm/v5te/hard/libm.a @static-lib arm-none-eabi/lib/arm/v5te/hard/libnosys.a @static-lib arm-none-eabi/lib/arm/v5te/hard/librdimon.a @static-lib arm-none-eabi/lib/arm/v5te/hard/librdpmon.a arm-none-eabi/lib/arm/v5te/hard/linux-crt0.o arm-none-eabi/lib/arm/v5te/hard/linux.specs arm-none-eabi/lib/arm/v5te/hard/nano.specs arm-none-eabi/lib/arm/v5te/hard/nosys.specs arm-none-eabi/lib/arm/v5te/hard/pid.specs arm-none-eabi/lib/arm/v5te/hard/rdimon-crt0.o arm-none-eabi/lib/arm/v5te/hard/rdimon.specs arm-none-eabi/lib/arm/v5te/hard/rdpmon-crt0.o arm-none-eabi/lib/arm/v5te/hard/rdpmon.specs arm-none-eabi/lib/arm/v5te/hard/redboot-crt0.o arm-none-eabi/lib/arm/v5te/hard/redboot-syscalls.o arm-none-eabi/lib/arm/v5te/hard/redboot.ld arm-none-eabi/lib/arm/v5te/hard/redboot.specs arm-none-eabi/lib/arm/v5te/softfp/ arm-none-eabi/lib/arm/v5te/softfp/aprofile-validation.specs arm-none-eabi/lib/arm/v5te/softfp/aprofile-ve.specs arm-none-eabi/lib/arm/v5te/softfp/cpu-init/ arm-none-eabi/lib/arm/v5te/softfp/cpu-init/rdimon-aem.o arm-none-eabi/lib/arm/v5te/softfp/crt0.o arm-none-eabi/lib/arm/v5te/softfp/iq80310.specs @static-lib arm-none-eabi/lib/arm/v5te/softfp/libc.a @static-lib arm-none-eabi/lib/arm/v5te/softfp/libg.a @static-lib arm-none-eabi/lib/arm/v5te/softfp/libgloss-linux.a @static-lib arm-none-eabi/lib/arm/v5te/softfp/libm.a @static-lib arm-none-eabi/lib/arm/v5te/softfp/libnosys.a @static-lib arm-none-eabi/lib/arm/v5te/softfp/librdimon.a @static-lib arm-none-eabi/lib/arm/v5te/softfp/librdpmon.a arm-none-eabi/lib/arm/v5te/softfp/linux-crt0.o arm-none-eabi/lib/arm/v5te/softfp/linux.specs arm-none-eabi/lib/arm/v5te/softfp/nano.specs arm-none-eabi/lib/arm/v5te/softfp/nosys.specs arm-none-eabi/lib/arm/v5te/softfp/pid.specs arm-none-eabi/lib/arm/v5te/softfp/rdimon-crt0.o arm-none-eabi/lib/arm/v5te/softfp/rdimon.specs arm-none-eabi/lib/arm/v5te/softfp/rdpmon-crt0.o arm-none-eabi/lib/arm/v5te/softfp/rdpmon.specs arm-none-eabi/lib/arm/v5te/softfp/redboot-crt0.o arm-none-eabi/lib/arm/v5te/softfp/redboot-syscalls.o arm-none-eabi/lib/arm/v5te/softfp/redboot.ld arm-none-eabi/lib/arm/v5te/softfp/redboot.specs arm-none-eabi/lib/cpu-init/ arm-none-eabi/lib/cpu-init/rdimon-aem.o arm-none-eabi/lib/crt0.o arm-none-eabi/lib/iq80310.specs @static-lib arm-none-eabi/lib/libc.a @static-lib arm-none-eabi/lib/libg.a @static-lib arm-none-eabi/lib/libgloss-linux.a @static-lib arm-none-eabi/lib/libm.a @static-lib arm-none-eabi/lib/libnosys.a @static-lib arm-none-eabi/lib/librdimon.a @static-lib arm-none-eabi/lib/librdpmon.a arm-none-eabi/lib/linux-crt0.o arm-none-eabi/lib/linux.specs arm-none-eabi/lib/nano.specs arm-none-eabi/lib/nosys.specs arm-none-eabi/lib/pid.specs arm-none-eabi/lib/rdimon-crt0.o arm-none-eabi/lib/rdimon.specs arm-none-eabi/lib/rdpmon-crt0.o arm-none-eabi/lib/rdpmon.specs arm-none-eabi/lib/redboot-crt0.o arm-none-eabi/lib/redboot-syscalls.o arm-none-eabi/lib/redboot.ld arm-none-eabi/lib/redboot.specs arm-none-eabi/lib/thumb/ arm-none-eabi/lib/thumb/nofp/ arm-none-eabi/lib/thumb/nofp/aprofile-validation.specs arm-none-eabi/lib/thumb/nofp/aprofile-ve.specs arm-none-eabi/lib/thumb/nofp/cpu-init/ arm-none-eabi/lib/thumb/nofp/cpu-init/rdimon-aem.o arm-none-eabi/lib/thumb/nofp/crt0.o arm-none-eabi/lib/thumb/nofp/iq80310.specs @static-lib arm-none-eabi/lib/thumb/nofp/libc.a @static-lib arm-none-eabi/lib/thumb/nofp/libg.a @static-lib arm-none-eabi/lib/thumb/nofp/libgloss-linux.a @static-lib arm-none-eabi/lib/thumb/nofp/libm.a @static-lib arm-none-eabi/lib/thumb/nofp/libnosys.a @static-lib arm-none-eabi/lib/thumb/nofp/librdimon.a @static-lib arm-none-eabi/lib/thumb/nofp/librdpmon.a arm-none-eabi/lib/thumb/nofp/linux-crt0.o arm-none-eabi/lib/thumb/nofp/linux.specs arm-none-eabi/lib/thumb/nofp/nano.specs arm-none-eabi/lib/thumb/nofp/nosys.specs arm-none-eabi/lib/thumb/nofp/pid.specs arm-none-eabi/lib/thumb/nofp/rdimon-crt0.o arm-none-eabi/lib/thumb/nofp/rdimon.specs arm-none-eabi/lib/thumb/nofp/rdpmon-crt0.o arm-none-eabi/lib/thumb/nofp/rdpmon.specs arm-none-eabi/lib/thumb/nofp/redboot-crt0.o arm-none-eabi/lib/thumb/nofp/redboot-syscalls.o arm-none-eabi/lib/thumb/nofp/redboot.ld arm-none-eabi/lib/thumb/nofp/redboot.specs arm-none-eabi/lib/thumb/v6-m/ arm-none-eabi/lib/thumb/v6-m/nofp/ arm-none-eabi/lib/thumb/v6-m/nofp/aprofile-validation.specs arm-none-eabi/lib/thumb/v6-m/nofp/aprofile-ve.specs arm-none-eabi/lib/thumb/v6-m/nofp/cpu-init/ arm-none-eabi/lib/thumb/v6-m/nofp/cpu-init/rdimon-aem.o arm-none-eabi/lib/thumb/v6-m/nofp/crt0.o arm-none-eabi/lib/thumb/v6-m/nofp/iq80310.specs @static-lib arm-none-eabi/lib/thumb/v6-m/nofp/libc.a @static-lib arm-none-eabi/lib/thumb/v6-m/nofp/libg.a @static-lib arm-none-eabi/lib/thumb/v6-m/nofp/libgloss-linux.a @static-lib arm-none-eabi/lib/thumb/v6-m/nofp/libm.a @static-lib arm-none-eabi/lib/thumb/v6-m/nofp/libnosys.a @static-lib arm-none-eabi/lib/thumb/v6-m/nofp/librdimon.a @static-lib arm-none-eabi/lib/thumb/v6-m/nofp/librdpmon.a arm-none-eabi/lib/thumb/v6-m/nofp/linux-crt0.o arm-none-eabi/lib/thumb/v6-m/nofp/linux.specs arm-none-eabi/lib/thumb/v6-m/nofp/nano.specs arm-none-eabi/lib/thumb/v6-m/nofp/nosys.specs arm-none-eabi/lib/thumb/v6-m/nofp/pid.specs arm-none-eabi/lib/thumb/v6-m/nofp/rdimon-crt0.o arm-none-eabi/lib/thumb/v6-m/nofp/rdimon.specs arm-none-eabi/lib/thumb/v6-m/nofp/rdpmon-crt0.o arm-none-eabi/lib/thumb/v6-m/nofp/rdpmon.specs arm-none-eabi/lib/thumb/v6-m/nofp/redboot-crt0.o arm-none-eabi/lib/thumb/v6-m/nofp/redboot-syscalls.o arm-none-eabi/lib/thumb/v6-m/nofp/redboot.ld arm-none-eabi/lib/thumb/v6-m/nofp/redboot.specs arm-none-eabi/lib/thumb/v7/ arm-none-eabi/lib/thumb/v7+fp/ arm-none-eabi/lib/thumb/v7+fp/hard/ arm-none-eabi/lib/thumb/v7+fp/hard/aprofile-validation.specs arm-none-eabi/lib/thumb/v7+fp/hard/aprofile-ve.specs arm-none-eabi/lib/thumb/v7+fp/hard/cpu-init/ arm-none-eabi/lib/thumb/v7+fp/hard/cpu-init/rdimon-aem.o arm-none-eabi/lib/thumb/v7+fp/hard/crt0.o arm-none-eabi/lib/thumb/v7+fp/hard/iq80310.specs @static-lib arm-none-eabi/lib/thumb/v7+fp/hard/libc.a @static-lib arm-none-eabi/lib/thumb/v7+fp/hard/libg.a @static-lib arm-none-eabi/lib/thumb/v7+fp/hard/libgloss-linux.a @static-lib arm-none-eabi/lib/thumb/v7+fp/hard/libm.a @static-lib arm-none-eabi/lib/thumb/v7+fp/hard/libnosys.a @static-lib arm-none-eabi/lib/thumb/v7+fp/hard/librdimon.a @static-lib arm-none-eabi/lib/thumb/v7+fp/hard/librdpmon.a arm-none-eabi/lib/thumb/v7+fp/hard/linux-crt0.o arm-none-eabi/lib/thumb/v7+fp/hard/linux.specs arm-none-eabi/lib/thumb/v7+fp/hard/nano.specs arm-none-eabi/lib/thumb/v7+fp/hard/nosys.specs arm-none-eabi/lib/thumb/v7+fp/hard/pid.specs arm-none-eabi/lib/thumb/v7+fp/hard/rdimon-crt0.o arm-none-eabi/lib/thumb/v7+fp/hard/rdimon.specs arm-none-eabi/lib/thumb/v7+fp/hard/rdpmon-crt0.o arm-none-eabi/lib/thumb/v7+fp/hard/rdpmon.specs arm-none-eabi/lib/thumb/v7+fp/hard/redboot-crt0.o arm-none-eabi/lib/thumb/v7+fp/hard/redboot-syscalls.o arm-none-eabi/lib/thumb/v7+fp/hard/redboot.ld arm-none-eabi/lib/thumb/v7+fp/hard/redboot.specs arm-none-eabi/lib/thumb/v7+fp/softfp/ arm-none-eabi/lib/thumb/v7+fp/softfp/aprofile-validation.specs arm-none-eabi/lib/thumb/v7+fp/softfp/aprofile-ve.specs arm-none-eabi/lib/thumb/v7+fp/softfp/cpu-init/ arm-none-eabi/lib/thumb/v7+fp/softfp/cpu-init/rdimon-aem.o arm-none-eabi/lib/thumb/v7+fp/softfp/crt0.o arm-none-eabi/lib/thumb/v7+fp/softfp/iq80310.specs @static-lib arm-none-eabi/lib/thumb/v7+fp/softfp/libc.a @static-lib arm-none-eabi/lib/thumb/v7+fp/softfp/libg.a @static-lib arm-none-eabi/lib/thumb/v7+fp/softfp/libgloss-linux.a @static-lib arm-none-eabi/lib/thumb/v7+fp/softfp/libm.a @static-lib arm-none-eabi/lib/thumb/v7+fp/softfp/libnosys.a @static-lib arm-none-eabi/lib/thumb/v7+fp/softfp/librdimon.a @static-lib arm-none-eabi/lib/thumb/v7+fp/softfp/librdpmon.a arm-none-eabi/lib/thumb/v7+fp/softfp/linux-crt0.o arm-none-eabi/lib/thumb/v7+fp/softfp/linux.specs arm-none-eabi/lib/thumb/v7+fp/softfp/nano.specs arm-none-eabi/lib/thumb/v7+fp/softfp/nosys.specs arm-none-eabi/lib/thumb/v7+fp/softfp/pid.specs arm-none-eabi/lib/thumb/v7+fp/softfp/rdimon-crt0.o arm-none-eabi/lib/thumb/v7+fp/softfp/rdimon.specs arm-none-eabi/lib/thumb/v7+fp/softfp/rdpmon-crt0.o arm-none-eabi/lib/thumb/v7+fp/softfp/rdpmon.specs arm-none-eabi/lib/thumb/v7+fp/softfp/redboot-crt0.o arm-none-eabi/lib/thumb/v7+fp/softfp/redboot-syscalls.o arm-none-eabi/lib/thumb/v7+fp/softfp/redboot.ld arm-none-eabi/lib/thumb/v7+fp/softfp/redboot.specs arm-none-eabi/lib/thumb/v7-m/ arm-none-eabi/lib/thumb/v7-m/nofp/ arm-none-eabi/lib/thumb/v7-m/nofp/aprofile-validation.specs arm-none-eabi/lib/thumb/v7-m/nofp/aprofile-ve.specs arm-none-eabi/lib/thumb/v7-m/nofp/cpu-init/ arm-none-eabi/lib/thumb/v7-m/nofp/cpu-init/rdimon-aem.o arm-none-eabi/lib/thumb/v7-m/nofp/crt0.o arm-none-eabi/lib/thumb/v7-m/nofp/iq80310.specs @static-lib arm-none-eabi/lib/thumb/v7-m/nofp/libc.a @static-lib arm-none-eabi/lib/thumb/v7-m/nofp/libg.a @static-lib arm-none-eabi/lib/thumb/v7-m/nofp/libgloss-linux.a @static-lib arm-none-eabi/lib/thumb/v7-m/nofp/libm.a @static-lib arm-none-eabi/lib/thumb/v7-m/nofp/libnosys.a @static-lib arm-none-eabi/lib/thumb/v7-m/nofp/librdimon.a @static-lib arm-none-eabi/lib/thumb/v7-m/nofp/librdpmon.a arm-none-eabi/lib/thumb/v7-m/nofp/linux-crt0.o arm-none-eabi/lib/thumb/v7-m/nofp/linux.specs arm-none-eabi/lib/thumb/v7-m/nofp/nano.specs arm-none-eabi/lib/thumb/v7-m/nofp/nosys.specs arm-none-eabi/lib/thumb/v7-m/nofp/pid.specs arm-none-eabi/lib/thumb/v7-m/nofp/rdimon-crt0.o arm-none-eabi/lib/thumb/v7-m/nofp/rdimon.specs arm-none-eabi/lib/thumb/v7-m/nofp/rdpmon-crt0.o arm-none-eabi/lib/thumb/v7-m/nofp/rdpmon.specs arm-none-eabi/lib/thumb/v7-m/nofp/redboot-crt0.o arm-none-eabi/lib/thumb/v7-m/nofp/redboot-syscalls.o arm-none-eabi/lib/thumb/v7-m/nofp/redboot.ld arm-none-eabi/lib/thumb/v7-m/nofp/redboot.specs arm-none-eabi/lib/thumb/v7-r+fp.sp/ arm-none-eabi/lib/thumb/v7-r+fp.sp/hard/ arm-none-eabi/lib/thumb/v7-r+fp.sp/hard/aprofile-validation.specs arm-none-eabi/lib/thumb/v7-r+fp.sp/hard/aprofile-ve.specs arm-none-eabi/lib/thumb/v7-r+fp.sp/hard/cpu-init/ arm-none-eabi/lib/thumb/v7-r+fp.sp/hard/cpu-init/rdimon-aem.o arm-none-eabi/lib/thumb/v7-r+fp.sp/hard/crt0.o arm-none-eabi/lib/thumb/v7-r+fp.sp/hard/iq80310.specs @static-lib arm-none-eabi/lib/thumb/v7-r+fp.sp/hard/libc.a @static-lib arm-none-eabi/lib/thumb/v7-r+fp.sp/hard/libg.a @static-lib arm-none-eabi/lib/thumb/v7-r+fp.sp/hard/libgloss-linux.a @static-lib arm-none-eabi/lib/thumb/v7-r+fp.sp/hard/libm.a @static-lib arm-none-eabi/lib/thumb/v7-r+fp.sp/hard/libnosys.a @static-lib arm-none-eabi/lib/thumb/v7-r+fp.sp/hard/librdimon.a @static-lib arm-none-eabi/lib/thumb/v7-r+fp.sp/hard/librdpmon.a arm-none-eabi/lib/thumb/v7-r+fp.sp/hard/linux-crt0.o arm-none-eabi/lib/thumb/v7-r+fp.sp/hard/linux.specs arm-none-eabi/lib/thumb/v7-r+fp.sp/hard/nano.specs arm-none-eabi/lib/thumb/v7-r+fp.sp/hard/nosys.specs arm-none-eabi/lib/thumb/v7-r+fp.sp/hard/pid.specs arm-none-eabi/lib/thumb/v7-r+fp.sp/hard/rdimon-crt0.o arm-none-eabi/lib/thumb/v7-r+fp.sp/hard/rdimon.specs arm-none-eabi/lib/thumb/v7-r+fp.sp/hard/rdpmon-crt0.o arm-none-eabi/lib/thumb/v7-r+fp.sp/hard/rdpmon.specs arm-none-eabi/lib/thumb/v7-r+fp.sp/hard/redboot-crt0.o arm-none-eabi/lib/thumb/v7-r+fp.sp/hard/redboot-syscalls.o arm-none-eabi/lib/thumb/v7-r+fp.sp/hard/redboot.ld arm-none-eabi/lib/thumb/v7-r+fp.sp/hard/redboot.specs arm-none-eabi/lib/thumb/v7-r+fp.sp/softfp/ arm-none-eabi/lib/thumb/v7-r+fp.sp/softfp/aprofile-validation.specs arm-none-eabi/lib/thumb/v7-r+fp.sp/softfp/aprofile-ve.specs arm-none-eabi/lib/thumb/v7-r+fp.sp/softfp/cpu-init/ arm-none-eabi/lib/thumb/v7-r+fp.sp/softfp/cpu-init/rdimon-aem.o arm-none-eabi/lib/thumb/v7-r+fp.sp/softfp/crt0.o arm-none-eabi/lib/thumb/v7-r+fp.sp/softfp/iq80310.specs @static-lib arm-none-eabi/lib/thumb/v7-r+fp.sp/softfp/libc.a @static-lib arm-none-eabi/lib/thumb/v7-r+fp.sp/softfp/libg.a @static-lib arm-none-eabi/lib/thumb/v7-r+fp.sp/softfp/libgloss-linux.a @static-lib arm-none-eabi/lib/thumb/v7-r+fp.sp/softfp/libm.a @static-lib arm-none-eabi/lib/thumb/v7-r+fp.sp/softfp/libnosys.a @static-lib arm-none-eabi/lib/thumb/v7-r+fp.sp/softfp/librdimon.a @static-lib arm-none-eabi/lib/thumb/v7-r+fp.sp/softfp/librdpmon.a arm-none-eabi/lib/thumb/v7-r+fp.sp/softfp/linux-crt0.o arm-none-eabi/lib/thumb/v7-r+fp.sp/softfp/linux.specs arm-none-eabi/lib/thumb/v7-r+fp.sp/softfp/nano.specs arm-none-eabi/lib/thumb/v7-r+fp.sp/softfp/nosys.specs arm-none-eabi/lib/thumb/v7-r+fp.sp/softfp/pid.specs arm-none-eabi/lib/thumb/v7-r+fp.sp/softfp/rdimon-crt0.o arm-none-eabi/lib/thumb/v7-r+fp.sp/softfp/rdimon.specs arm-none-eabi/lib/thumb/v7-r+fp.sp/softfp/rdpmon-crt0.o arm-none-eabi/lib/thumb/v7-r+fp.sp/softfp/rdpmon.specs arm-none-eabi/lib/thumb/v7-r+fp.sp/softfp/redboot-crt0.o arm-none-eabi/lib/thumb/v7-r+fp.sp/softfp/redboot-syscalls.o arm-none-eabi/lib/thumb/v7-r+fp.sp/softfp/redboot.ld arm-none-eabi/lib/thumb/v7-r+fp.sp/softfp/redboot.specs arm-none-eabi/lib/thumb/v7/nofp/ arm-none-eabi/lib/thumb/v7/nofp/aprofile-validation.specs arm-none-eabi/lib/thumb/v7/nofp/aprofile-ve.specs arm-none-eabi/lib/thumb/v7/nofp/cpu-init/ arm-none-eabi/lib/thumb/v7/nofp/cpu-init/rdimon-aem.o arm-none-eabi/lib/thumb/v7/nofp/crt0.o arm-none-eabi/lib/thumb/v7/nofp/iq80310.specs @static-lib arm-none-eabi/lib/thumb/v7/nofp/libc.a @static-lib arm-none-eabi/lib/thumb/v7/nofp/libg.a @static-lib arm-none-eabi/lib/thumb/v7/nofp/libgloss-linux.a @static-lib arm-none-eabi/lib/thumb/v7/nofp/libm.a @static-lib arm-none-eabi/lib/thumb/v7/nofp/libnosys.a @static-lib arm-none-eabi/lib/thumb/v7/nofp/librdimon.a @static-lib arm-none-eabi/lib/thumb/v7/nofp/librdpmon.a arm-none-eabi/lib/thumb/v7/nofp/linux-crt0.o arm-none-eabi/lib/thumb/v7/nofp/linux.specs arm-none-eabi/lib/thumb/v7/nofp/nano.specs arm-none-eabi/lib/thumb/v7/nofp/nosys.specs arm-none-eabi/lib/thumb/v7/nofp/pid.specs arm-none-eabi/lib/thumb/v7/nofp/rdimon-crt0.o arm-none-eabi/lib/thumb/v7/nofp/rdimon.specs arm-none-eabi/lib/thumb/v7/nofp/rdpmon-crt0.o arm-none-eabi/lib/thumb/v7/nofp/rdpmon.specs arm-none-eabi/lib/thumb/v7/nofp/redboot-crt0.o arm-none-eabi/lib/thumb/v7/nofp/redboot-syscalls.o arm-none-eabi/lib/thumb/v7/nofp/redboot.ld arm-none-eabi/lib/thumb/v7/nofp/redboot.specs arm-none-eabi/lib/thumb/v7e-m/ arm-none-eabi/lib/thumb/v7e-m+dp/ arm-none-eabi/lib/thumb/v7e-m+dp/hard/ arm-none-eabi/lib/thumb/v7e-m+dp/hard/aprofile-validation.specs arm-none-eabi/lib/thumb/v7e-m+dp/hard/aprofile-ve.specs arm-none-eabi/lib/thumb/v7e-m+dp/hard/cpu-init/ arm-none-eabi/lib/thumb/v7e-m+dp/hard/cpu-init/rdimon-aem.o arm-none-eabi/lib/thumb/v7e-m+dp/hard/crt0.o arm-none-eabi/lib/thumb/v7e-m+dp/hard/iq80310.specs @static-lib arm-none-eabi/lib/thumb/v7e-m+dp/hard/libc.a @static-lib arm-none-eabi/lib/thumb/v7e-m+dp/hard/libg.a @static-lib arm-none-eabi/lib/thumb/v7e-m+dp/hard/libgloss-linux.a @static-lib arm-none-eabi/lib/thumb/v7e-m+dp/hard/libm.a @static-lib arm-none-eabi/lib/thumb/v7e-m+dp/hard/libnosys.a @static-lib arm-none-eabi/lib/thumb/v7e-m+dp/hard/librdimon.a @static-lib arm-none-eabi/lib/thumb/v7e-m+dp/hard/librdpmon.a arm-none-eabi/lib/thumb/v7e-m+dp/hard/linux-crt0.o arm-none-eabi/lib/thumb/v7e-m+dp/hard/linux.specs arm-none-eabi/lib/thumb/v7e-m+dp/hard/nano.specs arm-none-eabi/lib/thumb/v7e-m+dp/hard/nosys.specs arm-none-eabi/lib/thumb/v7e-m+dp/hard/pid.specs arm-none-eabi/lib/thumb/v7e-m+dp/hard/rdimon-crt0.o arm-none-eabi/lib/thumb/v7e-m+dp/hard/rdimon.specs arm-none-eabi/lib/thumb/v7e-m+dp/hard/rdpmon-crt0.o arm-none-eabi/lib/thumb/v7e-m+dp/hard/rdpmon.specs arm-none-eabi/lib/thumb/v7e-m+dp/hard/redboot-crt0.o arm-none-eabi/lib/thumb/v7e-m+dp/hard/redboot-syscalls.o arm-none-eabi/lib/thumb/v7e-m+dp/hard/redboot.ld arm-none-eabi/lib/thumb/v7e-m+dp/hard/redboot.specs arm-none-eabi/lib/thumb/v7e-m+dp/softfp/ arm-none-eabi/lib/thumb/v7e-m+dp/softfp/aprofile-validation.specs arm-none-eabi/lib/thumb/v7e-m+dp/softfp/aprofile-ve.specs arm-none-eabi/lib/thumb/v7e-m+dp/softfp/cpu-init/ arm-none-eabi/lib/thumb/v7e-m+dp/softfp/cpu-init/rdimon-aem.o arm-none-eabi/lib/thumb/v7e-m+dp/softfp/crt0.o arm-none-eabi/lib/thumb/v7e-m+dp/softfp/iq80310.specs @static-lib arm-none-eabi/lib/thumb/v7e-m+dp/softfp/libc.a @static-lib arm-none-eabi/lib/thumb/v7e-m+dp/softfp/libg.a @static-lib arm-none-eabi/lib/thumb/v7e-m+dp/softfp/libgloss-linux.a @static-lib arm-none-eabi/lib/thumb/v7e-m+dp/softfp/libm.a @static-lib arm-none-eabi/lib/thumb/v7e-m+dp/softfp/libnosys.a @static-lib arm-none-eabi/lib/thumb/v7e-m+dp/softfp/librdimon.a @static-lib arm-none-eabi/lib/thumb/v7e-m+dp/softfp/librdpmon.a arm-none-eabi/lib/thumb/v7e-m+dp/softfp/linux-crt0.o arm-none-eabi/lib/thumb/v7e-m+dp/softfp/linux.specs arm-none-eabi/lib/thumb/v7e-m+dp/softfp/nano.specs arm-none-eabi/lib/thumb/v7e-m+dp/softfp/nosys.specs arm-none-eabi/lib/thumb/v7e-m+dp/softfp/pid.specs arm-none-eabi/lib/thumb/v7e-m+dp/softfp/rdimon-crt0.o arm-none-eabi/lib/thumb/v7e-m+dp/softfp/rdimon.specs arm-none-eabi/lib/thumb/v7e-m+dp/softfp/rdpmon-crt0.o arm-none-eabi/lib/thumb/v7e-m+dp/softfp/rdpmon.specs arm-none-eabi/lib/thumb/v7e-m+dp/softfp/redboot-crt0.o arm-none-eabi/lib/thumb/v7e-m+dp/softfp/redboot-syscalls.o arm-none-eabi/lib/thumb/v7e-m+dp/softfp/redboot.ld arm-none-eabi/lib/thumb/v7e-m+dp/softfp/redboot.specs arm-none-eabi/lib/thumb/v7e-m+fp/ arm-none-eabi/lib/thumb/v7e-m+fp/hard/ arm-none-eabi/lib/thumb/v7e-m+fp/hard/aprofile-validation.specs arm-none-eabi/lib/thumb/v7e-m+fp/hard/aprofile-ve.specs arm-none-eabi/lib/thumb/v7e-m+fp/hard/cpu-init/ arm-none-eabi/lib/thumb/v7e-m+fp/hard/cpu-init/rdimon-aem.o arm-none-eabi/lib/thumb/v7e-m+fp/hard/crt0.o arm-none-eabi/lib/thumb/v7e-m+fp/hard/iq80310.specs @static-lib arm-none-eabi/lib/thumb/v7e-m+fp/hard/libc.a @static-lib arm-none-eabi/lib/thumb/v7e-m+fp/hard/libg.a @static-lib arm-none-eabi/lib/thumb/v7e-m+fp/hard/libgloss-linux.a @static-lib arm-none-eabi/lib/thumb/v7e-m+fp/hard/libm.a @static-lib arm-none-eabi/lib/thumb/v7e-m+fp/hard/libnosys.a @static-lib arm-none-eabi/lib/thumb/v7e-m+fp/hard/librdimon.a @static-lib arm-none-eabi/lib/thumb/v7e-m+fp/hard/librdpmon.a arm-none-eabi/lib/thumb/v7e-m+fp/hard/linux-crt0.o arm-none-eabi/lib/thumb/v7e-m+fp/hard/linux.specs arm-none-eabi/lib/thumb/v7e-m+fp/hard/nano.specs arm-none-eabi/lib/thumb/v7e-m+fp/hard/nosys.specs arm-none-eabi/lib/thumb/v7e-m+fp/hard/pid.specs arm-none-eabi/lib/thumb/v7e-m+fp/hard/rdimon-crt0.o arm-none-eabi/lib/thumb/v7e-m+fp/hard/rdimon.specs arm-none-eabi/lib/thumb/v7e-m+fp/hard/rdpmon-crt0.o arm-none-eabi/lib/thumb/v7e-m+fp/hard/rdpmon.specs arm-none-eabi/lib/thumb/v7e-m+fp/hard/redboot-crt0.o arm-none-eabi/lib/thumb/v7e-m+fp/hard/redboot-syscalls.o arm-none-eabi/lib/thumb/v7e-m+fp/hard/redboot.ld arm-none-eabi/lib/thumb/v7e-m+fp/hard/redboot.specs arm-none-eabi/lib/thumb/v7e-m+fp/softfp/ arm-none-eabi/lib/thumb/v7e-m+fp/softfp/aprofile-validation.specs arm-none-eabi/lib/thumb/v7e-m+fp/softfp/aprofile-ve.specs arm-none-eabi/lib/thumb/v7e-m+fp/softfp/cpu-init/ arm-none-eabi/lib/thumb/v7e-m+fp/softfp/cpu-init/rdimon-aem.o arm-none-eabi/lib/thumb/v7e-m+fp/softfp/crt0.o arm-none-eabi/lib/thumb/v7e-m+fp/softfp/iq80310.specs @static-lib arm-none-eabi/lib/thumb/v7e-m+fp/softfp/libc.a @static-lib arm-none-eabi/lib/thumb/v7e-m+fp/softfp/libg.a @static-lib arm-none-eabi/lib/thumb/v7e-m+fp/softfp/libgloss-linux.a @static-lib arm-none-eabi/lib/thumb/v7e-m+fp/softfp/libm.a @static-lib arm-none-eabi/lib/thumb/v7e-m+fp/softfp/libnosys.a @static-lib arm-none-eabi/lib/thumb/v7e-m+fp/softfp/librdimon.a @static-lib arm-none-eabi/lib/thumb/v7e-m+fp/softfp/librdpmon.a arm-none-eabi/lib/thumb/v7e-m+fp/softfp/linux-crt0.o arm-none-eabi/lib/thumb/v7e-m+fp/softfp/linux.specs arm-none-eabi/lib/thumb/v7e-m+fp/softfp/nano.specs arm-none-eabi/lib/thumb/v7e-m+fp/softfp/nosys.specs arm-none-eabi/lib/thumb/v7e-m+fp/softfp/pid.specs arm-none-eabi/lib/thumb/v7e-m+fp/softfp/rdimon-crt0.o arm-none-eabi/lib/thumb/v7e-m+fp/softfp/rdimon.specs arm-none-eabi/lib/thumb/v7e-m+fp/softfp/rdpmon-crt0.o arm-none-eabi/lib/thumb/v7e-m+fp/softfp/rdpmon.specs arm-none-eabi/lib/thumb/v7e-m+fp/softfp/redboot-crt0.o arm-none-eabi/lib/thumb/v7e-m+fp/softfp/redboot-syscalls.o arm-none-eabi/lib/thumb/v7e-m+fp/softfp/redboot.ld arm-none-eabi/lib/thumb/v7e-m+fp/softfp/redboot.specs arm-none-eabi/lib/thumb/v7e-m/nofp/ arm-none-eabi/lib/thumb/v7e-m/nofp/aprofile-validation.specs arm-none-eabi/lib/thumb/v7e-m/nofp/aprofile-ve.specs arm-none-eabi/lib/thumb/v7e-m/nofp/cpu-init/ arm-none-eabi/lib/thumb/v7e-m/nofp/cpu-init/rdimon-aem.o arm-none-eabi/lib/thumb/v7e-m/nofp/crt0.o arm-none-eabi/lib/thumb/v7e-m/nofp/iq80310.specs @static-lib arm-none-eabi/lib/thumb/v7e-m/nofp/libc.a @static-lib arm-none-eabi/lib/thumb/v7e-m/nofp/libg.a @static-lib arm-none-eabi/lib/thumb/v7e-m/nofp/libgloss-linux.a @static-lib arm-none-eabi/lib/thumb/v7e-m/nofp/libm.a @static-lib arm-none-eabi/lib/thumb/v7e-m/nofp/libnosys.a @static-lib arm-none-eabi/lib/thumb/v7e-m/nofp/librdimon.a @static-lib arm-none-eabi/lib/thumb/v7e-m/nofp/librdpmon.a arm-none-eabi/lib/thumb/v7e-m/nofp/linux-crt0.o arm-none-eabi/lib/thumb/v7e-m/nofp/linux.specs arm-none-eabi/lib/thumb/v7e-m/nofp/nano.specs arm-none-eabi/lib/thumb/v7e-m/nofp/nosys.specs arm-none-eabi/lib/thumb/v7e-m/nofp/pid.specs arm-none-eabi/lib/thumb/v7e-m/nofp/rdimon-crt0.o arm-none-eabi/lib/thumb/v7e-m/nofp/rdimon.specs arm-none-eabi/lib/thumb/v7e-m/nofp/rdpmon-crt0.o arm-none-eabi/lib/thumb/v7e-m/nofp/rdpmon.specs arm-none-eabi/lib/thumb/v7e-m/nofp/redboot-crt0.o arm-none-eabi/lib/thumb/v7e-m/nofp/redboot-syscalls.o arm-none-eabi/lib/thumb/v7e-m/nofp/redboot.ld arm-none-eabi/lib/thumb/v7e-m/nofp/redboot.specs arm-none-eabi/lib/thumb/v8-m.base/ arm-none-eabi/lib/thumb/v8-m.base/nofp/ arm-none-eabi/lib/thumb/v8-m.base/nofp/aprofile-validation.specs arm-none-eabi/lib/thumb/v8-m.base/nofp/aprofile-ve.specs arm-none-eabi/lib/thumb/v8-m.base/nofp/cpu-init/ arm-none-eabi/lib/thumb/v8-m.base/nofp/cpu-init/rdimon-aem.o arm-none-eabi/lib/thumb/v8-m.base/nofp/crt0.o arm-none-eabi/lib/thumb/v8-m.base/nofp/iq80310.specs @static-lib arm-none-eabi/lib/thumb/v8-m.base/nofp/libc.a @static-lib arm-none-eabi/lib/thumb/v8-m.base/nofp/libg.a @static-lib arm-none-eabi/lib/thumb/v8-m.base/nofp/libgloss-linux.a @static-lib arm-none-eabi/lib/thumb/v8-m.base/nofp/libm.a @static-lib arm-none-eabi/lib/thumb/v8-m.base/nofp/libnosys.a @static-lib arm-none-eabi/lib/thumb/v8-m.base/nofp/librdimon.a @static-lib arm-none-eabi/lib/thumb/v8-m.base/nofp/librdpmon.a arm-none-eabi/lib/thumb/v8-m.base/nofp/linux-crt0.o arm-none-eabi/lib/thumb/v8-m.base/nofp/linux.specs arm-none-eabi/lib/thumb/v8-m.base/nofp/nano.specs arm-none-eabi/lib/thumb/v8-m.base/nofp/nosys.specs arm-none-eabi/lib/thumb/v8-m.base/nofp/pid.specs arm-none-eabi/lib/thumb/v8-m.base/nofp/rdimon-crt0.o arm-none-eabi/lib/thumb/v8-m.base/nofp/rdimon.specs arm-none-eabi/lib/thumb/v8-m.base/nofp/rdpmon-crt0.o arm-none-eabi/lib/thumb/v8-m.base/nofp/rdpmon.specs arm-none-eabi/lib/thumb/v8-m.base/nofp/redboot-crt0.o arm-none-eabi/lib/thumb/v8-m.base/nofp/redboot-syscalls.o arm-none-eabi/lib/thumb/v8-m.base/nofp/redboot.ld arm-none-eabi/lib/thumb/v8-m.base/nofp/redboot.specs arm-none-eabi/lib/thumb/v8-m.main/ arm-none-eabi/lib/thumb/v8-m.main+dp/ arm-none-eabi/lib/thumb/v8-m.main+dp/hard/ arm-none-eabi/lib/thumb/v8-m.main+dp/hard/aprofile-validation.specs arm-none-eabi/lib/thumb/v8-m.main+dp/hard/aprofile-ve.specs arm-none-eabi/lib/thumb/v8-m.main+dp/hard/cpu-init/ arm-none-eabi/lib/thumb/v8-m.main+dp/hard/cpu-init/rdimon-aem.o arm-none-eabi/lib/thumb/v8-m.main+dp/hard/crt0.o arm-none-eabi/lib/thumb/v8-m.main+dp/hard/iq80310.specs @static-lib arm-none-eabi/lib/thumb/v8-m.main+dp/hard/libc.a @static-lib arm-none-eabi/lib/thumb/v8-m.main+dp/hard/libg.a @static-lib arm-none-eabi/lib/thumb/v8-m.main+dp/hard/libgloss-linux.a @static-lib arm-none-eabi/lib/thumb/v8-m.main+dp/hard/libm.a @static-lib arm-none-eabi/lib/thumb/v8-m.main+dp/hard/libnosys.a @static-lib arm-none-eabi/lib/thumb/v8-m.main+dp/hard/librdimon.a @static-lib arm-none-eabi/lib/thumb/v8-m.main+dp/hard/librdpmon.a arm-none-eabi/lib/thumb/v8-m.main+dp/hard/linux-crt0.o arm-none-eabi/lib/thumb/v8-m.main+dp/hard/linux.specs arm-none-eabi/lib/thumb/v8-m.main+dp/hard/nano.specs arm-none-eabi/lib/thumb/v8-m.main+dp/hard/nosys.specs arm-none-eabi/lib/thumb/v8-m.main+dp/hard/pid.specs arm-none-eabi/lib/thumb/v8-m.main+dp/hard/rdimon-crt0.o arm-none-eabi/lib/thumb/v8-m.main+dp/hard/rdimon.specs arm-none-eabi/lib/thumb/v8-m.main+dp/hard/rdpmon-crt0.o arm-none-eabi/lib/thumb/v8-m.main+dp/hard/rdpmon.specs arm-none-eabi/lib/thumb/v8-m.main+dp/hard/redboot-crt0.o arm-none-eabi/lib/thumb/v8-m.main+dp/hard/redboot-syscalls.o arm-none-eabi/lib/thumb/v8-m.main+dp/hard/redboot.ld arm-none-eabi/lib/thumb/v8-m.main+dp/hard/redboot.specs arm-none-eabi/lib/thumb/v8-m.main+dp/softfp/ arm-none-eabi/lib/thumb/v8-m.main+dp/softfp/aprofile-validation.specs arm-none-eabi/lib/thumb/v8-m.main+dp/softfp/aprofile-ve.specs arm-none-eabi/lib/thumb/v8-m.main+dp/softfp/cpu-init/ arm-none-eabi/lib/thumb/v8-m.main+dp/softfp/cpu-init/rdimon-aem.o arm-none-eabi/lib/thumb/v8-m.main+dp/softfp/crt0.o arm-none-eabi/lib/thumb/v8-m.main+dp/softfp/iq80310.specs @static-lib arm-none-eabi/lib/thumb/v8-m.main+dp/softfp/libc.a @static-lib arm-none-eabi/lib/thumb/v8-m.main+dp/softfp/libg.a @static-lib arm-none-eabi/lib/thumb/v8-m.main+dp/softfp/libgloss-linux.a @static-lib arm-none-eabi/lib/thumb/v8-m.main+dp/softfp/libm.a @static-lib arm-none-eabi/lib/thumb/v8-m.main+dp/softfp/libnosys.a @static-lib arm-none-eabi/lib/thumb/v8-m.main+dp/softfp/librdimon.a @static-lib arm-none-eabi/lib/thumb/v8-m.main+dp/softfp/librdpmon.a arm-none-eabi/lib/thumb/v8-m.main+dp/softfp/linux-crt0.o arm-none-eabi/lib/thumb/v8-m.main+dp/softfp/linux.specs arm-none-eabi/lib/thumb/v8-m.main+dp/softfp/nano.specs arm-none-eabi/lib/thumb/v8-m.main+dp/softfp/nosys.specs arm-none-eabi/lib/thumb/v8-m.main+dp/softfp/pid.specs arm-none-eabi/lib/thumb/v8-m.main+dp/softfp/rdimon-crt0.o arm-none-eabi/lib/thumb/v8-m.main+dp/softfp/rdimon.specs arm-none-eabi/lib/thumb/v8-m.main+dp/softfp/rdpmon-crt0.o arm-none-eabi/lib/thumb/v8-m.main+dp/softfp/rdpmon.specs arm-none-eabi/lib/thumb/v8-m.main+dp/softfp/redboot-crt0.o arm-none-eabi/lib/thumb/v8-m.main+dp/softfp/redboot-syscalls.o arm-none-eabi/lib/thumb/v8-m.main+dp/softfp/redboot.ld arm-none-eabi/lib/thumb/v8-m.main+dp/softfp/redboot.specs arm-none-eabi/lib/thumb/v8-m.main+fp/ arm-none-eabi/lib/thumb/v8-m.main+fp/hard/ arm-none-eabi/lib/thumb/v8-m.main+fp/hard/aprofile-validation.specs arm-none-eabi/lib/thumb/v8-m.main+fp/hard/aprofile-ve.specs arm-none-eabi/lib/thumb/v8-m.main+fp/hard/cpu-init/ arm-none-eabi/lib/thumb/v8-m.main+fp/hard/cpu-init/rdimon-aem.o arm-none-eabi/lib/thumb/v8-m.main+fp/hard/crt0.o arm-none-eabi/lib/thumb/v8-m.main+fp/hard/iq80310.specs @static-lib arm-none-eabi/lib/thumb/v8-m.main+fp/hard/libc.a @static-lib arm-none-eabi/lib/thumb/v8-m.main+fp/hard/libg.a @static-lib arm-none-eabi/lib/thumb/v8-m.main+fp/hard/libgloss-linux.a @static-lib arm-none-eabi/lib/thumb/v8-m.main+fp/hard/libm.a @static-lib arm-none-eabi/lib/thumb/v8-m.main+fp/hard/libnosys.a @static-lib arm-none-eabi/lib/thumb/v8-m.main+fp/hard/librdimon.a @static-lib arm-none-eabi/lib/thumb/v8-m.main+fp/hard/librdpmon.a arm-none-eabi/lib/thumb/v8-m.main+fp/hard/linux-crt0.o arm-none-eabi/lib/thumb/v8-m.main+fp/hard/linux.specs arm-none-eabi/lib/thumb/v8-m.main+fp/hard/nano.specs arm-none-eabi/lib/thumb/v8-m.main+fp/hard/nosys.specs arm-none-eabi/lib/thumb/v8-m.main+fp/hard/pid.specs arm-none-eabi/lib/thumb/v8-m.main+fp/hard/rdimon-crt0.o arm-none-eabi/lib/thumb/v8-m.main+fp/hard/rdimon.specs arm-none-eabi/lib/thumb/v8-m.main+fp/hard/rdpmon-crt0.o arm-none-eabi/lib/thumb/v8-m.main+fp/hard/rdpmon.specs arm-none-eabi/lib/thumb/v8-m.main+fp/hard/redboot-crt0.o arm-none-eabi/lib/thumb/v8-m.main+fp/hard/redboot-syscalls.o arm-none-eabi/lib/thumb/v8-m.main+fp/hard/redboot.ld arm-none-eabi/lib/thumb/v8-m.main+fp/hard/redboot.specs arm-none-eabi/lib/thumb/v8-m.main+fp/softfp/ arm-none-eabi/lib/thumb/v8-m.main+fp/softfp/aprofile-validation.specs arm-none-eabi/lib/thumb/v8-m.main+fp/softfp/aprofile-ve.specs arm-none-eabi/lib/thumb/v8-m.main+fp/softfp/cpu-init/ arm-none-eabi/lib/thumb/v8-m.main+fp/softfp/cpu-init/rdimon-aem.o arm-none-eabi/lib/thumb/v8-m.main+fp/softfp/crt0.o arm-none-eabi/lib/thumb/v8-m.main+fp/softfp/iq80310.specs @static-lib arm-none-eabi/lib/thumb/v8-m.main+fp/softfp/libc.a @static-lib arm-none-eabi/lib/thumb/v8-m.main+fp/softfp/libg.a @static-lib arm-none-eabi/lib/thumb/v8-m.main+fp/softfp/libgloss-linux.a @static-lib arm-none-eabi/lib/thumb/v8-m.main+fp/softfp/libm.a @static-lib arm-none-eabi/lib/thumb/v8-m.main+fp/softfp/libnosys.a @static-lib arm-none-eabi/lib/thumb/v8-m.main+fp/softfp/librdimon.a @static-lib arm-none-eabi/lib/thumb/v8-m.main+fp/softfp/librdpmon.a arm-none-eabi/lib/thumb/v8-m.main+fp/softfp/linux-crt0.o arm-none-eabi/lib/thumb/v8-m.main+fp/softfp/linux.specs arm-none-eabi/lib/thumb/v8-m.main+fp/softfp/nano.specs arm-none-eabi/lib/thumb/v8-m.main+fp/softfp/nosys.specs arm-none-eabi/lib/thumb/v8-m.main+fp/softfp/pid.specs arm-none-eabi/lib/thumb/v8-m.main+fp/softfp/rdimon-crt0.o arm-none-eabi/lib/thumb/v8-m.main+fp/softfp/rdimon.specs arm-none-eabi/lib/thumb/v8-m.main+fp/softfp/rdpmon-crt0.o arm-none-eabi/lib/thumb/v8-m.main+fp/softfp/rdpmon.specs arm-none-eabi/lib/thumb/v8-m.main+fp/softfp/redboot-crt0.o arm-none-eabi/lib/thumb/v8-m.main+fp/softfp/redboot-syscalls.o arm-none-eabi/lib/thumb/v8-m.main+fp/softfp/redboot.ld arm-none-eabi/lib/thumb/v8-m.main+fp/softfp/redboot.specs arm-none-eabi/lib/thumb/v8-m.main/nofp/ arm-none-eabi/lib/thumb/v8-m.main/nofp/aprofile-validation.specs arm-none-eabi/lib/thumb/v8-m.main/nofp/aprofile-ve.specs arm-none-eabi/lib/thumb/v8-m.main/nofp/cpu-init/ arm-none-eabi/lib/thumb/v8-m.main/nofp/cpu-init/rdimon-aem.o arm-none-eabi/lib/thumb/v8-m.main/nofp/crt0.o arm-none-eabi/lib/thumb/v8-m.main/nofp/iq80310.specs @static-lib arm-none-eabi/lib/thumb/v8-m.main/nofp/libc.a @static-lib arm-none-eabi/lib/thumb/v8-m.main/nofp/libg.a @static-lib arm-none-eabi/lib/thumb/v8-m.main/nofp/libgloss-linux.a @static-lib arm-none-eabi/lib/thumb/v8-m.main/nofp/libm.a @static-lib arm-none-eabi/lib/thumb/v8-m.main/nofp/libnosys.a @static-lib arm-none-eabi/lib/thumb/v8-m.main/nofp/librdimon.a @static-lib arm-none-eabi/lib/thumb/v8-m.main/nofp/librdpmon.a arm-none-eabi/lib/thumb/v8-m.main/nofp/linux-crt0.o arm-none-eabi/lib/thumb/v8-m.main/nofp/linux.specs arm-none-eabi/lib/thumb/v8-m.main/nofp/nano.specs arm-none-eabi/lib/thumb/v8-m.main/nofp/nosys.specs arm-none-eabi/lib/thumb/v8-m.main/nofp/pid.specs arm-none-eabi/lib/thumb/v8-m.main/nofp/rdimon-crt0.o arm-none-eabi/lib/thumb/v8-m.main/nofp/rdimon.specs arm-none-eabi/lib/thumb/v8-m.main/nofp/rdpmon-crt0.o arm-none-eabi/lib/thumb/v8-m.main/nofp/rdpmon.specs arm-none-eabi/lib/thumb/v8-m.main/nofp/redboot-crt0.o arm-none-eabi/lib/thumb/v8-m.main/nofp/redboot-syscalls.o arm-none-eabi/lib/thumb/v8-m.main/nofp/redboot.ld arm-none-eabi/lib/thumb/v8-m.main/nofp/redboot.specs arm-none-eabi/lib/thumb/v8.1-m.main+mve/ arm-none-eabi/lib/thumb/v8.1-m.main+mve/hard/ arm-none-eabi/lib/thumb/v8.1-m.main+mve/hard/aprofile-validation.specs arm-none-eabi/lib/thumb/v8.1-m.main+mve/hard/aprofile-ve.specs arm-none-eabi/lib/thumb/v8.1-m.main+mve/hard/cpu-init/ arm-none-eabi/lib/thumb/v8.1-m.main+mve/hard/cpu-init/rdimon-aem.o arm-none-eabi/lib/thumb/v8.1-m.main+mve/hard/crt0.o arm-none-eabi/lib/thumb/v8.1-m.main+mve/hard/iq80310.specs @static-lib arm-none-eabi/lib/thumb/v8.1-m.main+mve/hard/libc.a @static-lib arm-none-eabi/lib/thumb/v8.1-m.main+mve/hard/libg.a @static-lib arm-none-eabi/lib/thumb/v8.1-m.main+mve/hard/libgloss-linux.a @static-lib arm-none-eabi/lib/thumb/v8.1-m.main+mve/hard/libm.a @static-lib arm-none-eabi/lib/thumb/v8.1-m.main+mve/hard/libnosys.a @static-lib arm-none-eabi/lib/thumb/v8.1-m.main+mve/hard/librdimon.a @static-lib arm-none-eabi/lib/thumb/v8.1-m.main+mve/hard/librdpmon.a arm-none-eabi/lib/thumb/v8.1-m.main+mve/hard/linux-crt0.o arm-none-eabi/lib/thumb/v8.1-m.main+mve/hard/linux.specs arm-none-eabi/lib/thumb/v8.1-m.main+mve/hard/nano.specs arm-none-eabi/lib/thumb/v8.1-m.main+mve/hard/nosys.specs arm-none-eabi/lib/thumb/v8.1-m.main+mve/hard/pid.specs arm-none-eabi/lib/thumb/v8.1-m.main+mve/hard/rdimon-crt0.o arm-none-eabi/lib/thumb/v8.1-m.main+mve/hard/rdimon.specs arm-none-eabi/lib/thumb/v8.1-m.main+mve/hard/rdpmon-crt0.o arm-none-eabi/lib/thumb/v8.1-m.main+mve/hard/rdpmon.specs arm-none-eabi/lib/thumb/v8.1-m.main+mve/hard/redboot-crt0.o arm-none-eabi/lib/thumb/v8.1-m.main+mve/hard/redboot-syscalls.o arm-none-eabi/lib/thumb/v8.1-m.main+mve/hard/redboot.ld arm-none-eabi/lib/thumb/v8.1-m.main+mve/hard/redboot.specs share/doc/arm-none-eabi/ share/doc/arm-none-eabi/newlib/ share/doc/arm-none-eabi/newlib/COPYING.NEWLIB ================================================ FILE: tools/openbsd/ports/mystuff/devel/mips-elf/Makefile ================================================ SUBDIR = SUBDIR += binutils SUBDIR += gcc .include ================================================ FILE: tools/openbsd/ports/mystuff/devel/mips-elf/Makefile.inc ================================================ CONFIG= mips-elf PKGNAME?= ${CONFIG}-${DISTNAME} FULLPKGNAME?= ${PKGNAME} CATEGORIES+= devel # GPLv3 # For newlib: multiple copyrights, but basically BSD. # See: ${PREFIX}/share/doc/newlib PERMIT_PACKAGE= Yes # XXX at least gmkdir gets picked up if present BUILD_DEPENDS += sysutils/coreutils CONFIGURE_STYLE=gnu CONFIGURE_ARGS+=--target=${CONFIG} \ --disable-shared \ --disable-nls \ --disable-werror EXTRACT_SUFX?= .tar.xz ================================================ FILE: tools/openbsd/ports/mystuff/devel/mips-elf/binutils/Makefile ================================================ COMMENT= binutils for ${CONFIG} cross-development VERSION= 2.40 DISTNAME= binutils-${VERSION} HOMEPAGE= https://www.gnu.org/software/binutils/ WANTLIB= c SITES= ${SITE_GNU:=binutils/} DIST_SUBDIR= binutils USE_GMAKE= Yes USE_LIBTOOL= No CONFIGURE_ARGS+=--enable-commonbfdlib=no \ --enable-interwork \ --enable-multilib \ --without-zstd SUBST_VARS+= CONFIG .include ================================================ FILE: tools/openbsd/ports/mystuff/devel/mips-elf/binutils/distinfo ================================================ SHA256 (binutils/binutils-2.40.tar.xz) = D4pMJy1/F/Np3tEKSsoouOMEgo6VUm2kgrDMxN/J2OE= SIZE (binutils/binutils-2.40.tar.xz) = 25241484 ================================================ FILE: tools/openbsd/ports/mystuff/devel/mips-elf/binutils/patches/patch-bfd_Makefile_in ================================================ Index: bfd/Makefile.in --- bfd/Makefile.in.orig +++ bfd/Makefile.in @@ -266,7 +266,7 @@ am__v_texidevnull_ = $(am__v_texidevnull_@AM_DEFAULT_V am__v_texidevnull_0 = > /dev/null am__v_texidevnull_1 = am__dirstamp = $(am__leading_dot)dirstamp -INFO_DEPS = doc/bfd.info +INFO_DEPS = am__TEXINFO_TEX_DIR = $(srcdir) DVIS = doc/bfd.dvi PDFS = doc/bfd.pdf ================================================ FILE: tools/openbsd/ports/mystuff/devel/mips-elf/binutils/patches/patch-binutils_Makefile_in ================================================ Index: binutils/Makefile.in --- binutils/Makefile.in.orig +++ binutils/Makefile.in @@ -404,7 +404,7 @@ AM_V_texidevnull = $(am__v_texidevnull_@AM_V@) am__v_texidevnull_ = $(am__v_texidevnull_@AM_DEFAULT_V@) am__v_texidevnull_0 = > /dev/null am__v_texidevnull_1 = -INFO_DEPS = doc/binutils.info +INFO_DEPS = am__TEXINFO_TEX_DIR = $(srcdir) DVIS = doc/binutils.dvi PDFS = doc/binutils.pdf ================================================ FILE: tools/openbsd/ports/mystuff/devel/mips-elf/binutils/patches/patch-gas_Makefile_in ================================================ Index: gas/Makefile.in --- gas/Makefile.in.orig +++ gas/Makefile.in @@ -270,7 +270,7 @@ AM_V_texidevnull = $(am__v_texidevnull_@AM_V@) am__v_texidevnull_ = $(am__v_texidevnull_@AM_DEFAULT_V@) am__v_texidevnull_0 = > /dev/null am__v_texidevnull_1 = -INFO_DEPS = doc/as.info +INFO_DEPS = TEXINFO_TEX = $(top_srcdir)/../texinfo.tex am__TEXINFO_TEX_DIR = $(top_srcdir)/.. DVIS = doc/as.dvi ================================================ FILE: tools/openbsd/ports/mystuff/devel/mips-elf/binutils/patches/patch-gprof_Makefile_in ================================================ Index: gprof/Makefile.in --- gprof/Makefile.in.orig +++ gprof/Makefile.in @@ -217,7 +217,7 @@ AM_V_texidevnull = $(am__v_texidevnull_@AM_V@) am__v_texidevnull_ = $(am__v_texidevnull_@AM_DEFAULT_V@) am__v_texidevnull_0 = > /dev/null am__v_texidevnull_1 = -INFO_DEPS = gprof.info +INFO_DEPS = am__TEXINFO_TEX_DIR = $(srcdir)/../texinfo DVIS = gprof.dvi PDFS = gprof.pdf ================================================ FILE: tools/openbsd/ports/mystuff/devel/mips-elf/binutils/patches/patch-ld_Makefile_in ================================================ Index: ld/Makefile.in --- ld/Makefile.in.orig +++ ld/Makefile.in @@ -301,7 +301,7 @@ AM_V_texidevnull = $(am__v_texidevnull_@AM_V@) am__v_texidevnull_ = $(am__v_texidevnull_@AM_DEFAULT_V@) am__v_texidevnull_0 = > /dev/null am__v_texidevnull_1 = -INFO_DEPS = ld.info +INFO_DEPS = am__TEXINFO_TEX_DIR = $(srcdir)/../texinfo DVIS = ld.dvi PDFS = ld.pdf @@ -1042,7 +1042,7 @@ libldtestplug4_la_SOURCES = testplug4.c libldtestplug4_la_CFLAGS = -g -O2 libldtestplug4_la_LDFLAGS = -no-undefined -rpath /nowhere bfdplugindir = $(libdir)/bfd-plugins -bfdplugin_LTLIBRARIES = libdep.la +bfdplugin_LTLIBRARIES = libdep_la_SOURCES = libdep_plugin.c libdep_la_LDFLAGS = -no-undefined -rpath /nowhere -module -avoid-version libdep_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ ================================================ FILE: tools/openbsd/ports/mystuff/devel/mips-elf/binutils/patches/patch-libctf_Makefile_in ================================================ Index: libctf/Makefile.in --- libctf/Makefile.in.orig +++ libctf/Makefile.in @@ -306,7 +306,7 @@ am__v_texidevnull_ = $(am__v_texidevnull_@AM_DEFAULT_V am__v_texidevnull_0 = > /dev/null am__v_texidevnull_1 = am__dirstamp = $(am__leading_dot)dirstamp -INFO_DEPS = doc/ctf-spec.info +INFO_DEPS = am__TEXINFO_TEX_DIR = $(srcdir) DVIS = doc/ctf-spec.dvi PDFS = doc/ctf-spec.pdf ================================================ FILE: tools/openbsd/ports/mystuff/devel/mips-elf/binutils/patches/patch-libiberty_Makefile_in ================================================ Index: libiberty/Makefile.in --- libiberty/Makefile.in.orig +++ libiberty/Makefile.in @@ -376,7 +376,7 @@ libiberty.html : $(srcdir)/libiberty.texi $(TEXISRC) @MAINT@ echo stamp > stamp-functions INSTALL_DEST = @INSTALL_DEST@ -install: install_to_$(INSTALL_DEST) install-subdir +install: install-strip: install .PHONY: install install-strip ================================================ FILE: tools/openbsd/ports/mystuff/devel/mips-elf/binutils/patches/patch-libsframe_Makefile_in ================================================ Index: libsframe/Makefile.in --- libsframe/Makefile.in.orig +++ libsframe/Makefile.in @@ -276,7 +276,7 @@ AM_V_texidevnull = $(am__v_texidevnull_@AM_V@) am__v_texidevnull_ = $(am__v_texidevnull_@AM_DEFAULT_V@) am__v_texidevnull_0 = > /dev/null am__v_texidevnull_1 = -INFO_DEPS = doc/sframe-spec.info +INFO_DEPS = am__TEXINFO_TEX_DIR = $(srcdir) DVIS = doc/sframe-spec.dvi PDFS = doc/sframe-spec.pdf ================================================ FILE: tools/openbsd/ports/mystuff/devel/mips-elf/binutils/pkg/DESCR ================================================ GNU Binutils collection, configured for the ${CONFIG} target. * ld - the GNU linker. * as - the GNU assembler. But they also include: * addr2line - Converts addresses into filenames and line numbers. * ar - A utility for creating, modifying and extracting from archives. * c++filt - Filter to demangle encoded C++ symbols. * gprof - Displays profiling information. * nlmconv - Converts object code into an NLM. * nm - Lists symbols from object files. * objcopy - Copys and translates object files. * objdump - Displays information from object files. * ranlib - Generates an index to the contents of an archive. * readelf - Displays information from any ELF format object file. * size - Lists the section sizes of an object or archive file. * strings - Lists printable strings from files. * strip - Discards symbols. * windres - A compiler for Windows resource files. Most of these programs use BFD, the Binary File Descriptor library, to do low-level manipulation. Many of them also use the opcodes library to assemble and disassemble machine instructions. ================================================ FILE: tools/openbsd/ports/mystuff/devel/mips-elf/binutils/pkg/PLIST ================================================ @comment @info info/bfd.info @comment @info info/binutils.info @comment @info info/gprof.info @comment @info info/ld.info @bin bin/${CONFIG}-addr2line @bin bin/${CONFIG}-ar @bin bin/${CONFIG}-as @bin bin/${CONFIG}-c++filt @bin bin/${CONFIG}-elfedit @bin bin/${CONFIG}-ld @bin bin/${CONFIG}-ld.bfd @bin bin/${CONFIG}-nm @bin bin/${CONFIG}-objcopy @bin bin/${CONFIG}-objdump @bin bin/${CONFIG}-ranlib @bin bin/${CONFIG}-readelf @bin bin/${CONFIG}-size @bin bin/${CONFIG}-strings @bin bin/${CONFIG}-strip @man man/man1/${CONFIG}-addr2line.1 @man man/man1/${CONFIG}-ar.1 @man man/man1/${CONFIG}-as.1 @man man/man1/${CONFIG}-c++filt.1 @man man/man1/${CONFIG}-dlltool.1 @man man/man1/${CONFIG}-elfedit.1 @man man/man1/${CONFIG}-ld.1 @man man/man1/${CONFIG}-nm.1 @man man/man1/${CONFIG}-objcopy.1 @man man/man1/${CONFIG}-objdump.1 @man man/man1/${CONFIG}-ranlib.1 @man man/man1/${CONFIG}-readelf.1 @man man/man1/${CONFIG}-size.1 @man man/man1/${CONFIG}-strings.1 @man man/man1/${CONFIG}-strip.1 @man man/man1/${CONFIG}-windmc.1 @man man/man1/${CONFIG}-windres.1 ${CONFIG}/ ${CONFIG}/bin/ @bin ${CONFIG}/bin/ar @bin ${CONFIG}/bin/as @bin ${CONFIG}/bin/ld @bin ${CONFIG}/bin/ld.bfd @bin ${CONFIG}/bin/nm @bin ${CONFIG}/bin/objcopy @bin ${CONFIG}/bin/objdump @bin ${CONFIG}/bin/ranlib @bin ${CONFIG}/bin/readelf @bin ${CONFIG}/bin/strip ${CONFIG}/lib/ ${CONFIG}/lib/ldscripts/ ${CONFIG}/lib/ldscripts/elf32ebmip.x ${CONFIG}/lib/ldscripts/elf32ebmip.xbn ${CONFIG}/lib/ldscripts/elf32ebmip.xc ${CONFIG}/lib/ldscripts/elf32ebmip.xce ${CONFIG}/lib/ldscripts/elf32ebmip.xd ${CONFIG}/lib/ldscripts/elf32ebmip.xdc ${CONFIG}/lib/ldscripts/elf32ebmip.xdce ${CONFIG}/lib/ldscripts/elf32ebmip.xde ${CONFIG}/lib/ldscripts/elf32ebmip.xdw ${CONFIG}/lib/ldscripts/elf32ebmip.xdwe ${CONFIG}/lib/ldscripts/elf32ebmip.xe ${CONFIG}/lib/ldscripts/elf32ebmip.xn ${CONFIG}/lib/ldscripts/elf32ebmip.xr ${CONFIG}/lib/ldscripts/elf32ebmip.xs ${CONFIG}/lib/ldscripts/elf32ebmip.xsc ${CONFIG}/lib/ldscripts/elf32ebmip.xsce ${CONFIG}/lib/ldscripts/elf32ebmip.xse ${CONFIG}/lib/ldscripts/elf32ebmip.xsw ${CONFIG}/lib/ldscripts/elf32ebmip.xswe ${CONFIG}/lib/ldscripts/elf32ebmip.xu ${CONFIG}/lib/ldscripts/elf32ebmip.xw ${CONFIG}/lib/ldscripts/elf32ebmip.xwe ================================================ FILE: tools/openbsd/ports/mystuff/devel/mips-elf/gcc/Makefile ================================================ COMMENT= gcc for ${CONFIG} cross-development VERSION= 12.2.0 DISTNAME= gcc-${VERSION} PKGNAME= ${CONFIG}-gcc-${VERSION} SHARED_LIBS+= lto_plugin 0.0 # 0.0 SUBST_VARS+= VERSION WANTLIB= ${COMPILER_LIBCXX} c gmp m mpc mpfr pthread DIST_SUBDIR= gcc COMPILER= base-clang ports-gcc base-gcc MAKE_GXX= No MAKE_FORTRAN= No MAKE_OBJC= No MAKE_JAVA= No MAKE_ADA= No SITES= ${SITE_GCC:=releases/gcc-${VERSION}/} BUILD_DEPENDS+= ${RUN_DEPENDS} \ devel/bison LIB_DEPENDS= devel/mpfr \ devel/libmpc RUN_DEPENDS= devel/${CONFIG}/binutils #LANGS= c,c++ LANGS= c CFLAGS= -O2 -g CONFIGURE_ARGS+=--enable-languages=${LANGS} \ --with-arch-32=mips32r2 \ --with-gmp="${LOCALBASE}" \ --with-mpc="${LOCALBASE}" \ --with-mpfr="${LOCALBASE}" \ --without-isl \ --without-zstd \ --disable-libssp \ --with-newlib \ --disable-libstdc___v3 \ --disable-libcc1 \ --disable-nls \ --disable-shared \ --disable-decimal-float \ --disable-threads \ --disable-libmudflap \ --disable-libgomp \ --disable-libquadmath \ --enable-multilib \ --enable-cpp \ --enable-lto CONFIGURE_ENV= CPPFLAGS="${CPPFLAGS} -I${LOCALBASE}/include" \ LDFLAGS="-L${LOCALBASE}/lib" # Avoid build failure when lang/gcc/8 is installed whose ansidecl.h misses these CPPFLAGS+= -DATTRIBUTE_NONSTRING= -DATTRIBUTE_RESULT_SIZE_1= CPPFLAGS+= -DATTRIBUTE_RESULT_SIZE_2= -DATTRIBUTE_RESULT_SIZE_1_2= CPPFLAGS+= -DATTRIBUTE_WARN_UNUSED_RESULT= SEPARATE_BUILD= Yes USE_GMAKE= Yes YACC= bison post-install: chown -R ${SHAREOWN}:${SHAREGRP} \ ${PREFIX}/lib/gcc/${CONFIG}/${VERSION}/ .include ================================================ FILE: tools/openbsd/ports/mystuff/devel/mips-elf/gcc/distinfo ================================================ SHA256 (gcc/gcc-12.2.0.tar.xz) = 5UnPnPNZSgDie2WJ1DItcOByDN0hPzm+tBgeBpJiMP8= SIZE (gcc/gcc-12.2.0.tar.xz) = 84645292 ================================================ FILE: tools/openbsd/ports/mystuff/devel/mips-elf/gcc/patches/patch-Makefile_in ================================================ Index: Makefile.in --- Makefile.in.orig +++ Makefile.in @@ -1116,29 +1116,8 @@ configure-host: \ maybe-configure-libctf .PHONY: configure-target configure-target: \ - maybe-configure-target-libstdc++-v3 \ - maybe-configure-target-libsanitizer \ - maybe-configure-target-libvtv \ - maybe-configure-target-liboffloadmic \ - maybe-configure-target-libssp \ maybe-configure-target-newlib \ - maybe-configure-target-libgcc \ - maybe-configure-target-libbacktrace \ - maybe-configure-target-libquadmath \ - maybe-configure-target-libgfortran \ - maybe-configure-target-libobjc \ - maybe-configure-target-libgo \ - maybe-configure-target-libphobos \ - maybe-configure-target-libtermcap \ - maybe-configure-target-winsup \ - maybe-configure-target-libgloss \ - maybe-configure-target-libffi \ - maybe-configure-target-zlib \ - maybe-configure-target-rda \ - maybe-configure-target-libada \ - maybe-configure-target-libgomp \ - maybe-configure-target-libitm \ - maybe-configure-target-libatomic + maybe-configure-target-libgcc # The target built for a native non-bootstrap build. .PHONY: all @@ -1296,47 +1275,10 @@ all-host: maybe-all-libctf .PHONY: all-target -@if target-libstdc++-v3-no-bootstrap -all-target: maybe-all-target-libstdc++-v3 -@endif target-libstdc++-v3-no-bootstrap -@if target-libsanitizer-no-bootstrap -all-target: maybe-all-target-libsanitizer -@endif target-libsanitizer-no-bootstrap -@if target-libvtv-no-bootstrap -all-target: maybe-all-target-libvtv -@endif target-libvtv-no-bootstrap -all-target: maybe-all-target-liboffloadmic -all-target: maybe-all-target-libssp all-target: maybe-all-target-newlib @if target-libgcc-no-bootstrap all-target: maybe-all-target-libgcc @endif target-libgcc-no-bootstrap -@if target-libbacktrace-no-bootstrap -all-target: maybe-all-target-libbacktrace -@endif target-libbacktrace-no-bootstrap -all-target: maybe-all-target-libquadmath -all-target: maybe-all-target-libgfortran -all-target: maybe-all-target-libobjc -all-target: maybe-all-target-libgo -@if target-libphobos-no-bootstrap -all-target: maybe-all-target-libphobos -@endif target-libphobos-no-bootstrap -all-target: maybe-all-target-libtermcap -all-target: maybe-all-target-winsup -all-target: maybe-all-target-libgloss -all-target: maybe-all-target-libffi -@if target-zlib-no-bootstrap -all-target: maybe-all-target-zlib -@endif target-zlib-no-bootstrap -all-target: maybe-all-target-rda -all-target: maybe-all-target-libada -@if target-libgomp-no-bootstrap -all-target: maybe-all-target-libgomp -@endif target-libgomp-no-bootstrap -all-target: maybe-all-target-libitm -@if target-libatomic-no-bootstrap -all-target: maybe-all-target-libatomic -@endif target-libatomic-no-bootstrap # Do a target for all the subdirectories. A ``make do-X'' will do a # ``make X'' in all subdirectories (because, in general, there is a @@ -1409,29 +1351,8 @@ info-host: maybe-info-libctf .PHONY: info-target -info-target: maybe-info-target-libstdc++-v3 -info-target: maybe-info-target-libsanitizer -info-target: maybe-info-target-libvtv -info-target: maybe-info-target-liboffloadmic -info-target: maybe-info-target-libssp info-target: maybe-info-target-newlib info-target: maybe-info-target-libgcc -info-target: maybe-info-target-libbacktrace -info-target: maybe-info-target-libquadmath -info-target: maybe-info-target-libgfortran -info-target: maybe-info-target-libobjc -info-target: maybe-info-target-libgo -info-target: maybe-info-target-libphobos -info-target: maybe-info-target-libtermcap -info-target: maybe-info-target-winsup -info-target: maybe-info-target-libgloss -info-target: maybe-info-target-libffi -info-target: maybe-info-target-zlib -info-target: maybe-info-target-rda -info-target: maybe-info-target-libada -info-target: maybe-info-target-libgomp -info-target: maybe-info-target-libitm -info-target: maybe-info-target-libatomic .PHONY: do-dvi do-dvi: @@ -1499,29 +1420,8 @@ dvi-host: maybe-dvi-libctf .PHONY: dvi-target -dvi-target: maybe-dvi-target-libstdc++-v3 -dvi-target: maybe-dvi-target-libsanitizer -dvi-target: maybe-dvi-target-libvtv -dvi-target: maybe-dvi-target-liboffloadmic -dvi-target: maybe-dvi-target-libssp dvi-target: maybe-dvi-target-newlib dvi-target: maybe-dvi-target-libgcc -dvi-target: maybe-dvi-target-libbacktrace -dvi-target: maybe-dvi-target-libquadmath -dvi-target: maybe-dvi-target-libgfortran -dvi-target: maybe-dvi-target-libobjc -dvi-target: maybe-dvi-target-libgo -dvi-target: maybe-dvi-target-libphobos -dvi-target: maybe-dvi-target-libtermcap -dvi-target: maybe-dvi-target-winsup -dvi-target: maybe-dvi-target-libgloss -dvi-target: maybe-dvi-target-libffi -dvi-target: maybe-dvi-target-zlib -dvi-target: maybe-dvi-target-rda -dvi-target: maybe-dvi-target-libada -dvi-target: maybe-dvi-target-libgomp -dvi-target: maybe-dvi-target-libitm -dvi-target: maybe-dvi-target-libatomic .PHONY: do-pdf do-pdf: @@ -1589,29 +1489,8 @@ pdf-host: maybe-pdf-libctf .PHONY: pdf-target -pdf-target: maybe-pdf-target-libstdc++-v3 -pdf-target: maybe-pdf-target-libsanitizer -pdf-target: maybe-pdf-target-libvtv -pdf-target: maybe-pdf-target-liboffloadmic -pdf-target: maybe-pdf-target-libssp pdf-target: maybe-pdf-target-newlib pdf-target: maybe-pdf-target-libgcc -pdf-target: maybe-pdf-target-libbacktrace -pdf-target: maybe-pdf-target-libquadmath -pdf-target: maybe-pdf-target-libgfortran -pdf-target: maybe-pdf-target-libobjc -pdf-target: maybe-pdf-target-libgo -pdf-target: maybe-pdf-target-libphobos -pdf-target: maybe-pdf-target-libtermcap -pdf-target: maybe-pdf-target-winsup -pdf-target: maybe-pdf-target-libgloss -pdf-target: maybe-pdf-target-libffi -pdf-target: maybe-pdf-target-zlib -pdf-target: maybe-pdf-target-rda -pdf-target: maybe-pdf-target-libada -pdf-target: maybe-pdf-target-libgomp -pdf-target: maybe-pdf-target-libitm -pdf-target: maybe-pdf-target-libatomic .PHONY: do-html do-html: @@ -1679,29 +1558,8 @@ html-host: maybe-html-libctf .PHONY: html-target -html-target: maybe-html-target-libstdc++-v3 -html-target: maybe-html-target-libsanitizer -html-target: maybe-html-target-libvtv -html-target: maybe-html-target-liboffloadmic -html-target: maybe-html-target-libssp html-target: maybe-html-target-newlib html-target: maybe-html-target-libgcc -html-target: maybe-html-target-libbacktrace -html-target: maybe-html-target-libquadmath -html-target: maybe-html-target-libgfortran -html-target: maybe-html-target-libobjc -html-target: maybe-html-target-libgo -html-target: maybe-html-target-libphobos -html-target: maybe-html-target-libtermcap -html-target: maybe-html-target-winsup -html-target: maybe-html-target-libgloss -html-target: maybe-html-target-libffi -html-target: maybe-html-target-zlib -html-target: maybe-html-target-rda -html-target: maybe-html-target-libada -html-target: maybe-html-target-libgomp -html-target: maybe-html-target-libitm -html-target: maybe-html-target-libatomic .PHONY: do-TAGS do-TAGS: @@ -1769,29 +1627,8 @@ TAGS-host: maybe-TAGS-libctf .PHONY: TAGS-target -TAGS-target: maybe-TAGS-target-libstdc++-v3 -TAGS-target: maybe-TAGS-target-libsanitizer -TAGS-target: maybe-TAGS-target-libvtv -TAGS-target: maybe-TAGS-target-liboffloadmic -TAGS-target: maybe-TAGS-target-libssp TAGS-target: maybe-TAGS-target-newlib TAGS-target: maybe-TAGS-target-libgcc -TAGS-target: maybe-TAGS-target-libbacktrace -TAGS-target: maybe-TAGS-target-libquadmath -TAGS-target: maybe-TAGS-target-libgfortran -TAGS-target: maybe-TAGS-target-libobjc -TAGS-target: maybe-TAGS-target-libgo -TAGS-target: maybe-TAGS-target-libphobos -TAGS-target: maybe-TAGS-target-libtermcap -TAGS-target: maybe-TAGS-target-winsup -TAGS-target: maybe-TAGS-target-libgloss -TAGS-target: maybe-TAGS-target-libffi -TAGS-target: maybe-TAGS-target-zlib -TAGS-target: maybe-TAGS-target-rda -TAGS-target: maybe-TAGS-target-libada -TAGS-target: maybe-TAGS-target-libgomp -TAGS-target: maybe-TAGS-target-libitm -TAGS-target: maybe-TAGS-target-libatomic .PHONY: do-install-info do-install-info: @@ -1859,29 +1696,8 @@ install-info-host: maybe-install-info-libctf .PHONY: install-info-target -install-info-target: maybe-install-info-target-libstdc++-v3 -install-info-target: maybe-install-info-target-libsanitizer -install-info-target: maybe-install-info-target-libvtv -install-info-target: maybe-install-info-target-liboffloadmic -install-info-target: maybe-install-info-target-libssp install-info-target: maybe-install-info-target-newlib install-info-target: maybe-install-info-target-libgcc -install-info-target: maybe-install-info-target-libbacktrace -install-info-target: maybe-install-info-target-libquadmath -install-info-target: maybe-install-info-target-libgfortran -install-info-target: maybe-install-info-target-libobjc -install-info-target: maybe-install-info-target-libgo -install-info-target: maybe-install-info-target-libphobos -install-info-target: maybe-install-info-target-libtermcap -install-info-target: maybe-install-info-target-winsup -install-info-target: maybe-install-info-target-libgloss -install-info-target: maybe-install-info-target-libffi -install-info-target: maybe-install-info-target-zlib -install-info-target: maybe-install-info-target-rda -install-info-target: maybe-install-info-target-libada -install-info-target: maybe-install-info-target-libgomp -install-info-target: maybe-install-info-target-libitm -install-info-target: maybe-install-info-target-libatomic .PHONY: do-install-dvi do-install-dvi: @@ -2039,29 +1855,8 @@ install-pdf-host: maybe-install-pdf-libctf .PHONY: install-pdf-target -install-pdf-target: maybe-install-pdf-target-libstdc++-v3 -install-pdf-target: maybe-install-pdf-target-libsanitizer -install-pdf-target: maybe-install-pdf-target-libvtv -install-pdf-target: maybe-install-pdf-target-liboffloadmic -install-pdf-target: maybe-install-pdf-target-libssp install-pdf-target: maybe-install-pdf-target-newlib install-pdf-target: maybe-install-pdf-target-libgcc -install-pdf-target: maybe-install-pdf-target-libbacktrace -install-pdf-target: maybe-install-pdf-target-libquadmath -install-pdf-target: maybe-install-pdf-target-libgfortran -install-pdf-target: maybe-install-pdf-target-libobjc -install-pdf-target: maybe-install-pdf-target-libgo -install-pdf-target: maybe-install-pdf-target-libphobos -install-pdf-target: maybe-install-pdf-target-libtermcap -install-pdf-target: maybe-install-pdf-target-winsup -install-pdf-target: maybe-install-pdf-target-libgloss -install-pdf-target: maybe-install-pdf-target-libffi -install-pdf-target: maybe-install-pdf-target-zlib -install-pdf-target: maybe-install-pdf-target-rda -install-pdf-target: maybe-install-pdf-target-libada -install-pdf-target: maybe-install-pdf-target-libgomp -install-pdf-target: maybe-install-pdf-target-libitm -install-pdf-target: maybe-install-pdf-target-libatomic .PHONY: do-install-html do-install-html: @@ -2129,29 +1924,8 @@ install-html-host: maybe-install-html-libctf .PHONY: install-html-target -install-html-target: maybe-install-html-target-libstdc++-v3 -install-html-target: maybe-install-html-target-libsanitizer -install-html-target: maybe-install-html-target-libvtv -install-html-target: maybe-install-html-target-liboffloadmic -install-html-target: maybe-install-html-target-libssp install-html-target: maybe-install-html-target-newlib install-html-target: maybe-install-html-target-libgcc -install-html-target: maybe-install-html-target-libbacktrace -install-html-target: maybe-install-html-target-libquadmath -install-html-target: maybe-install-html-target-libgfortran -install-html-target: maybe-install-html-target-libobjc -install-html-target: maybe-install-html-target-libgo -install-html-target: maybe-install-html-target-libphobos -install-html-target: maybe-install-html-target-libtermcap -install-html-target: maybe-install-html-target-winsup -install-html-target: maybe-install-html-target-libgloss -install-html-target: maybe-install-html-target-libffi -install-html-target: maybe-install-html-target-zlib -install-html-target: maybe-install-html-target-rda -install-html-target: maybe-install-html-target-libada -install-html-target: maybe-install-html-target-libgomp -install-html-target: maybe-install-html-target-libitm -install-html-target: maybe-install-html-target-libatomic .PHONY: do-installcheck do-installcheck: @@ -2219,29 +1993,8 @@ installcheck-host: maybe-installcheck-libctf .PHONY: installcheck-target -installcheck-target: maybe-installcheck-target-libstdc++-v3 -installcheck-target: maybe-installcheck-target-libsanitizer -installcheck-target: maybe-installcheck-target-libvtv -installcheck-target: maybe-installcheck-target-liboffloadmic -installcheck-target: maybe-installcheck-target-libssp installcheck-target: maybe-installcheck-target-newlib installcheck-target: maybe-installcheck-target-libgcc -installcheck-target: maybe-installcheck-target-libbacktrace -installcheck-target: maybe-installcheck-target-libquadmath -installcheck-target: maybe-installcheck-target-libgfortran -installcheck-target: maybe-installcheck-target-libobjc -installcheck-target: maybe-installcheck-target-libgo -installcheck-target: maybe-installcheck-target-libphobos -installcheck-target: maybe-installcheck-target-libtermcap -installcheck-target: maybe-installcheck-target-winsup -installcheck-target: maybe-installcheck-target-libgloss -installcheck-target: maybe-installcheck-target-libffi -installcheck-target: maybe-installcheck-target-zlib -installcheck-target: maybe-installcheck-target-rda -installcheck-target: maybe-installcheck-target-libada -installcheck-target: maybe-installcheck-target-libgomp -installcheck-target: maybe-installcheck-target-libitm -installcheck-target: maybe-installcheck-target-libatomic .PHONY: do-mostlyclean do-mostlyclean: @@ -2309,29 +2062,8 @@ mostlyclean-host: maybe-mostlyclean-libctf .PHONY: mostlyclean-target -mostlyclean-target: maybe-mostlyclean-target-libstdc++-v3 -mostlyclean-target: maybe-mostlyclean-target-libsanitizer -mostlyclean-target: maybe-mostlyclean-target-libvtv -mostlyclean-target: maybe-mostlyclean-target-liboffloadmic -mostlyclean-target: maybe-mostlyclean-target-libssp mostlyclean-target: maybe-mostlyclean-target-newlib mostlyclean-target: maybe-mostlyclean-target-libgcc -mostlyclean-target: maybe-mostlyclean-target-libbacktrace -mostlyclean-target: maybe-mostlyclean-target-libquadmath -mostlyclean-target: maybe-mostlyclean-target-libgfortran -mostlyclean-target: maybe-mostlyclean-target-libobjc -mostlyclean-target: maybe-mostlyclean-target-libgo -mostlyclean-target: maybe-mostlyclean-target-libphobos -mostlyclean-target: maybe-mostlyclean-target-libtermcap -mostlyclean-target: maybe-mostlyclean-target-winsup -mostlyclean-target: maybe-mostlyclean-target-libgloss -mostlyclean-target: maybe-mostlyclean-target-libffi -mostlyclean-target: maybe-mostlyclean-target-zlib -mostlyclean-target: maybe-mostlyclean-target-rda -mostlyclean-target: maybe-mostlyclean-target-libada -mostlyclean-target: maybe-mostlyclean-target-libgomp -mostlyclean-target: maybe-mostlyclean-target-libitm -mostlyclean-target: maybe-mostlyclean-target-libatomic .PHONY: do-clean do-clean: @@ -2399,29 +2131,8 @@ clean-host: maybe-clean-libctf .PHONY: clean-target -clean-target: maybe-clean-target-libstdc++-v3 -clean-target: maybe-clean-target-libsanitizer -clean-target: maybe-clean-target-libvtv -clean-target: maybe-clean-target-liboffloadmic -clean-target: maybe-clean-target-libssp clean-target: maybe-clean-target-newlib clean-target: maybe-clean-target-libgcc -clean-target: maybe-clean-target-libbacktrace -clean-target: maybe-clean-target-libquadmath -clean-target: maybe-clean-target-libgfortran -clean-target: maybe-clean-target-libobjc -clean-target: maybe-clean-target-libgo -clean-target: maybe-clean-target-libphobos -clean-target: maybe-clean-target-libtermcap -clean-target: maybe-clean-target-winsup -clean-target: maybe-clean-target-libgloss -clean-target: maybe-clean-target-libffi -clean-target: maybe-clean-target-zlib -clean-target: maybe-clean-target-rda -clean-target: maybe-clean-target-libada -clean-target: maybe-clean-target-libgomp -clean-target: maybe-clean-target-libitm -clean-target: maybe-clean-target-libatomic .PHONY: do-distclean do-distclean: @@ -2489,29 +2200,8 @@ distclean-host: maybe-distclean-libctf .PHONY: distclean-target -distclean-target: maybe-distclean-target-libstdc++-v3 -distclean-target: maybe-distclean-target-libsanitizer -distclean-target: maybe-distclean-target-libvtv -distclean-target: maybe-distclean-target-liboffloadmic -distclean-target: maybe-distclean-target-libssp distclean-target: maybe-distclean-target-newlib distclean-target: maybe-distclean-target-libgcc -distclean-target: maybe-distclean-target-libbacktrace -distclean-target: maybe-distclean-target-libquadmath -distclean-target: maybe-distclean-target-libgfortran -distclean-target: maybe-distclean-target-libobjc -distclean-target: maybe-distclean-target-libgo -distclean-target: maybe-distclean-target-libphobos -distclean-target: maybe-distclean-target-libtermcap -distclean-target: maybe-distclean-target-winsup -distclean-target: maybe-distclean-target-libgloss -distclean-target: maybe-distclean-target-libffi -distclean-target: maybe-distclean-target-zlib -distclean-target: maybe-distclean-target-rda -distclean-target: maybe-distclean-target-libada -distclean-target: maybe-distclean-target-libgomp -distclean-target: maybe-distclean-target-libitm -distclean-target: maybe-distclean-target-libatomic .PHONY: do-maintainer-clean do-maintainer-clean: @@ -2579,29 +2269,8 @@ maintainer-clean-host: maybe-maintainer-clean-libctf .PHONY: maintainer-clean-target -maintainer-clean-target: maybe-maintainer-clean-target-libstdc++-v3 -maintainer-clean-target: maybe-maintainer-clean-target-libsanitizer -maintainer-clean-target: maybe-maintainer-clean-target-libvtv -maintainer-clean-target: maybe-maintainer-clean-target-liboffloadmic -maintainer-clean-target: maybe-maintainer-clean-target-libssp maintainer-clean-target: maybe-maintainer-clean-target-newlib maintainer-clean-target: maybe-maintainer-clean-target-libgcc -maintainer-clean-target: maybe-maintainer-clean-target-libbacktrace -maintainer-clean-target: maybe-maintainer-clean-target-libquadmath -maintainer-clean-target: maybe-maintainer-clean-target-libgfortran -maintainer-clean-target: maybe-maintainer-clean-target-libobjc -maintainer-clean-target: maybe-maintainer-clean-target-libgo -maintainer-clean-target: maybe-maintainer-clean-target-libphobos -maintainer-clean-target: maybe-maintainer-clean-target-libtermcap -maintainer-clean-target: maybe-maintainer-clean-target-winsup -maintainer-clean-target: maybe-maintainer-clean-target-libgloss -maintainer-clean-target: maybe-maintainer-clean-target-libffi -maintainer-clean-target: maybe-maintainer-clean-target-zlib -maintainer-clean-target: maybe-maintainer-clean-target-rda -maintainer-clean-target: maybe-maintainer-clean-target-libada -maintainer-clean-target: maybe-maintainer-clean-target-libgomp -maintainer-clean-target: maybe-maintainer-clean-target-libitm -maintainer-clean-target: maybe-maintainer-clean-target-libatomic # Here are the targets which correspond to the do-X targets. @@ -2727,29 +2396,8 @@ check-host: \ .PHONY: check-target check-target: \ - maybe-check-target-libstdc++-v3 \ - maybe-check-target-libsanitizer \ - maybe-check-target-libvtv \ - maybe-check-target-liboffloadmic \ - maybe-check-target-libssp \ maybe-check-target-newlib \ - maybe-check-target-libgcc \ - maybe-check-target-libbacktrace \ - maybe-check-target-libquadmath \ - maybe-check-target-libgfortran \ - maybe-check-target-libobjc \ - maybe-check-target-libgo \ - maybe-check-target-libphobos \ - maybe-check-target-libtermcap \ - maybe-check-target-winsup \ - maybe-check-target-libgloss \ - maybe-check-target-libffi \ - maybe-check-target-zlib \ - maybe-check-target-rda \ - maybe-check-target-libada \ - maybe-check-target-libgomp \ - maybe-check-target-libitm \ - maybe-check-target-libatomic + maybe-check-target-libgcc do-check: @: $(MAKE); $(unstage) @@ -2919,29 +2567,8 @@ install-host: \ .PHONY: install-target install-target: \ - maybe-install-target-libstdc++-v3 \ - maybe-install-target-libsanitizer \ - maybe-install-target-libvtv \ - maybe-install-target-liboffloadmic \ - maybe-install-target-libssp \ maybe-install-target-newlib \ - maybe-install-target-libgcc \ - maybe-install-target-libbacktrace \ - maybe-install-target-libquadmath \ - maybe-install-target-libgfortran \ - maybe-install-target-libobjc \ - maybe-install-target-libgo \ - maybe-install-target-libphobos \ - maybe-install-target-libtermcap \ - maybe-install-target-winsup \ - maybe-install-target-libgloss \ - maybe-install-target-libffi \ - maybe-install-target-zlib \ - maybe-install-target-rda \ - maybe-install-target-libada \ - maybe-install-target-libgomp \ - maybe-install-target-libitm \ - maybe-install-target-libatomic + maybe-install-target-libgcc uninstall: @echo "the uninstall target is not supported in this tree" @@ -3029,30 +2656,8 @@ install-strip-host: \ .PHONY: install-strip-target install-strip-target: \ - maybe-install-strip-target-libstdc++-v3 \ - maybe-install-strip-target-libsanitizer \ - maybe-install-strip-target-libvtv \ - maybe-install-strip-target-liboffloadmic \ - maybe-install-strip-target-libssp \ maybe-install-strip-target-newlib \ - maybe-install-strip-target-libgcc \ - maybe-install-strip-target-libbacktrace \ - maybe-install-strip-target-libquadmath \ - maybe-install-strip-target-libgfortran \ - maybe-install-strip-target-libobjc \ - maybe-install-strip-target-libgo \ - maybe-install-strip-target-libphobos \ - maybe-install-strip-target-libtermcap \ - maybe-install-strip-target-winsup \ - maybe-install-strip-target-libgloss \ - maybe-install-strip-target-libffi \ - maybe-install-strip-target-zlib \ - maybe-install-strip-target-rda \ - maybe-install-strip-target-libada \ - maybe-install-strip-target-libgomp \ - maybe-install-strip-target-libitm \ - maybe-install-strip-target-libatomic - + maybe-install-strip-target-libgcc ### other supporting targets ================================================ FILE: tools/openbsd/ports/mystuff/devel/mips-elf/gcc/patches/patch-gcc_Makefile_in ================================================ Index: gcc/Makefile.in --- gcc/Makefile.in.orig +++ gcc/Makefile.in @@ -3784,13 +3784,7 @@ install-driver: installdirs xgcc$(exeext) # Install the info files. # $(INSTALL_DATA) might be a relative pathname, so we can't cd into srcdir # to do the install. -install-info:: doc installdirs \ - $(DESTDIR)$(infodir)/cpp.info \ - $(DESTDIR)$(infodir)/gcc.info \ - $(DESTDIR)$(infodir)/cppinternals.info \ - $(DESTDIR)$(infodir)/gccinstall.info \ - $(DESTDIR)$(infodir)/gccint.info \ - lang.install-info +install-info:: $(DESTDIR)$(infodir)/%.info: doc/%.info installdirs rm -f $@ @@ -3857,10 +3851,7 @@ install-man: lang.install-man \ $(DESTDIR)$(man1dir)/$(GCOV_INSTALL_NAME)$(man1ext) \ $(DESTDIR)$(man1dir)/$(GCOV_TOOL_INSTALL_NAME)$(man1ext) \ $(DESTDIR)$(man1dir)/$(GCOV_DUMP_INSTALL_NAME)$(man1ext) \ - $(if $(filter yes,@enable_lto@),$(DESTDIR)$(man1dir)/$(LTO_DUMP_INSTALL_NAME)$(man1ext)) \ - $(DESTDIR)$(man7dir)/fsf-funding$(man7ext) \ - $(DESTDIR)$(man7dir)/gfdl$(man7ext) \ - $(DESTDIR)$(man7dir)/gpl$(man7ext) + $(if $(filter yes,@enable_lto@),$(DESTDIR)$(man1dir)/$(LTO_DUMP_INSTALL_NAME)$(man1ext)) $(DESTDIR)$(man7dir)/%$(man7ext): doc/%.7 installdirs -rm -f $@ ================================================ FILE: tools/openbsd/ports/mystuff/devel/mips-elf/gcc/patches/patch-gcc_common_opt ================================================ Index: gcc/common.opt --- gcc/common.opt.orig +++ gcc/common.opt @@ -2017,7 +2017,7 @@ Common Var(flag_ivopts) Init(1) Optimization Optimize induction variables on trees. fjump-tables -Common Var(flag_jump_tables) Init(1) Optimization +Common Var(flag_jump_tables) Init(0) Optimization Use jump tables for sufficiently large switch statements. fbit-tests ================================================ FILE: tools/openbsd/ports/mystuff/devel/mips-elf/gcc/patches/patch-gcc_config_host ================================================ Index: gcc/config.host --- gcc/config.host.orig +++ gcc/config.host @@ -99,8 +99,7 @@ case ${host} in esac case ${host} in - aarch64*-*-freebsd* | aarch64*-*-linux* | aarch64*-*-fuchsia* |\ - aarch64*-*-darwin*) + aarch64*-*-*) case ${target} in aarch64*-*-*) host_extra_gcc_objs="driver-aarch64.o" @@ -108,7 +107,7 @@ case ${host} in ;; esac ;; - arm*-*-freebsd* | arm*-*-netbsd* | arm*-*-linux* | arm*-*-fuchsia*) + arm*-*-*) case ${target} in arm*-*-*) host_extra_gcc_objs="driver-arm.o" ================================================ FILE: tools/openbsd/ports/mystuff/devel/mips-elf/gcc/patches/patch-gcc_configure ================================================ Index: gcc/configure --- gcc/configure.orig +++ gcc/configure @@ -32456,14 +32456,14 @@ if test "$gcc_cv_c_no_fpie" = "yes"; then fi -# Check if -no-pie works. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for -no-pie option" >&5 -$as_echo_n "checking for -no-pie option... " >&6; } +# Check if -nopie works. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for -nopie option" >&5 +$as_echo_n "checking for -nopie option... " >&6; } if ${gcc_cv_no_pie+:} false; then : $as_echo_n "(cached) " >&6 else saved_LDFLAGS="$LDFLAGS" - LDFLAGS="$LDFLAGS -no-pie" + LDFLAGS="$LDFLAGS -nopie" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) {return 0;} @@ -32480,7 +32480,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_no_pie" >&5 $as_echo "$gcc_cv_no_pie" >&6; } if test "$gcc_cv_no_pie" = "yes"; then - NO_PIE_FLAG="-no-pie" + NO_PIE_FLAG="-nopie" fi ================================================ FILE: tools/openbsd/ports/mystuff/devel/mips-elf/gcc/patches/patch-libcc1_connection_cc ================================================ Index: libcc1/connection.cc --- libcc1/connection.cc.orig +++ libcc1/connection.cc @@ -20,6 +20,7 @@ along with GCC; see the file COPYING3. If not see #include #include #include +#include #include #include #include ================================================ FILE: tools/openbsd/ports/mystuff/devel/mips-elf/gcc/patches/patch-libgcc_Makefile_in ================================================ Index: libgcc/Makefile.in --- libgcc/Makefile.in.orig +++ libgcc/Makefile.in @@ -1093,7 +1093,7 @@ libgcc-extra-parts: $(EXTRA_PARTS) parts="$(EXTRA_PARTS)"; \ for file in $$parts; do \ rm -f $(gcc_objdir)$(MULTISUBDIR)/$$file; \ - $(INSTALL_DATA) $$file $(gcc_objdir)$(MULTISUBDIR)/; \ + install -c $$file $(gcc_objdir)$(MULTISUBDIR)/; \ case $$file in \ *.a) \ $(RANLIB) $(gcc_objdir)$(MULTISUBDIR)/$$file ;; \ @@ -1123,7 +1123,7 @@ install-unwind_h-forbuild: unwind.h # internal headers are copied by gcc's install. install-unwind_h: $(mkinstalldirs) $(DESTDIR)$(libsubdir)/include - $(INSTALL_DATA) unwind.h $(DESTDIR)$(libsubdir)/include + install -c unwind.h $(DESTDIR)$(libsubdir)/include all: install-unwind_h-forbuild @@ -1149,7 +1149,7 @@ install-libunwind: # NOTE: Maybe this should go into $(inst_libdir), but this # is where the old mklibgcc.in put it. - $(INSTALL_DATA) libunwind.a $(DESTDIR)$(inst_slibdir)/ + install -c libunwind.a $(DESTDIR)$(inst_slibdir)/ chmod 644 $(DESTDIR)$(inst_slibdir)/libunwind.a $(RANLIB) $(DESTDIR)$(inst_slibdir)/libunwind.a @@ -1160,7 +1160,7 @@ install-libunwind: install-shared: $(mkinstalldirs) $(DESTDIR)$(inst_libdir) - $(INSTALL_DATA) libgcc_eh.a $(DESTDIR)$(inst_libdir)/ + install -c libgcc_eh.a $(DESTDIR)$(inst_libdir)/ chmod 644 $(DESTDIR)$(inst_libdir)/libgcc_eh.a $(RANLIB) $(DESTDIR)$(inst_libdir)/libgcc_eh.a @@ -1171,19 +1171,17 @@ install-shared: install-leaf: $(install-shared) $(install-libunwind) $(mkinstalldirs) $(DESTDIR)$(inst_libdir) - $(INSTALL_DATA) libgcc.a $(DESTDIR)$(inst_libdir)/ - chmod 644 $(DESTDIR)$(inst_libdir)/libgcc.a + install -c libgcc.a $(DESTDIR)$(inst_libdir) $(RANLIB) $(DESTDIR)$(inst_libdir)/libgcc.a ifeq ($(enable_gcov),yes) - $(INSTALL_DATA) libgcov.a $(DESTDIR)$(inst_libdir)/ - chmod 644 $(DESTDIR)$(inst_libdir)/libgcov.a + install -c libgcov.a $(DESTDIR)$(inst_libdir) $(RANLIB) $(DESTDIR)$(inst_libdir)/libgcov.a endif parts="$(INSTALL_PARTS)"; \ for file in $$parts; do \ rm -f $(DESTDIR)$(inst_libdir)/$$file; \ - $(INSTALL_DATA) $$file $(DESTDIR)$(inst_libdir)/; \ + install -c $$file $(DESTDIR)$(inst_libdir)/; \ case $$file in \ *.a) \ $(RANLIB) $(gcc_objdir)$(MULTISUBDIR)/$$file ;; \ ================================================ FILE: tools/openbsd/ports/mystuff/devel/mips-elf/gcc/patches/patch-libgcc_config_host ================================================ Index: libgcc/config.host --- libgcc/config.host.orig +++ libgcc/config.host @@ -166,11 +166,11 @@ mips*-*-*) # All MIPS targets provide a full set of FP routines. cpu_type=mips tmake_file="mips/t-mips" - if test "${libgcc_cv_mips_hard_float}" = yes; then - tmake_file="${tmake_file} t-hardfp-sfdf t-hardfp" - else +# XXX if test "${libgcc_cv_mips_hard_float}" = yes; then +# XXX tmake_file="${tmake_file} t-hardfp-sfdf t-hardfp" +# XXX else tmake_file="${tmake_file} t-softfp-sfdf" - fi +# XXX fi if test "${ac_cv_sizeof_long_double}" = 16; then tmake_file="${tmake_file} mips/t-softfp-tf" fi ================================================ FILE: tools/openbsd/ports/mystuff/devel/mips-elf/gcc/patches/patch-libiberty_Makefile_in ================================================ Index: libiberty/Makefile.in --- libiberty/Makefile.in.orig +++ libiberty/Makefile.in @@ -376,7 +376,7 @@ libiberty.html : $(srcdir)/libiberty.texi $(TEXISRC) @MAINT@ echo stamp > stamp-functions INSTALL_DEST = @INSTALL_DEST@ -install: install_to_$(INSTALL_DEST) install-subdir +install: install-strip: install .PHONY: install install-strip ================================================ FILE: tools/openbsd/ports/mystuff/devel/mips-elf/gcc/pkg/DESCR ================================================ GNU cross compiler suite, configured for the mips-elf target. ================================================ FILE: tools/openbsd/ports/mystuff/devel/mips-elf/gcc/pkg/PLIST ================================================ @bin bin/mips-elf-cpp @bin bin/mips-elf-gcc @bin bin/mips-elf-gcc-${VERSION} @bin bin/mips-elf-gcc-ar @bin bin/mips-elf-gcc-nm @bin bin/mips-elf-gcc-ranlib @bin bin/mips-elf-gcov @comment @info info/cpp.info @comment @info info/cppinternals.info @comment @info info/gcc.info @comment @info info/gccinstall.info @comment @info info/gccint.info @comment @info info/libquadmath.info @bin bin/mips-elf-gcov-dump @bin bin/mips-elf-gcov-tool @bin bin/mips-elf-lto-dump lib/gcc/ lib/gcc/mips-elf/ lib/gcc/mips-elf/${VERSION}/ lib/gcc/mips-elf/${VERSION}/crtbegin.o lib/gcc/mips-elf/${VERSION}/crtend.o lib/gcc/mips-elf/${VERSION}/crti.o lib/gcc/mips-elf/${VERSION}/crtn.o lib/gcc/mips-elf/${VERSION}/el/ lib/gcc/mips-elf/${VERSION}/el/crtbegin.o lib/gcc/mips-elf/${VERSION}/el/crtend.o lib/gcc/mips-elf/${VERSION}/el/crti.o lib/gcc/mips-elf/${VERSION}/el/crtn.o @static-lib lib/gcc/mips-elf/${VERSION}/el/libgcc.a @static-lib lib/gcc/mips-elf/${VERSION}/el/libgcov.a lib/gcc/mips-elf/${VERSION}/include/ lib/gcc/mips-elf/${VERSION}/include-fixed/ lib/gcc/mips-elf/${VERSION}/include-fixed/README lib/gcc/mips-elf/${VERSION}/include-fixed/limits.h lib/gcc/mips-elf/${VERSION}/include-fixed/syslimits.h lib/gcc/mips-elf/${VERSION}/include/float.h lib/gcc/mips-elf/${VERSION}/include/gcov.h lib/gcc/mips-elf/${VERSION}/include/iso646.h lib/gcc/mips-elf/${VERSION}/include/loongson-mmiintrin.h lib/gcc/mips-elf/${VERSION}/include/loongson.h lib/gcc/mips-elf/${VERSION}/include/msa.h lib/gcc/mips-elf/${VERSION}/include/stdalign.h lib/gcc/mips-elf/${VERSION}/include/stdarg.h lib/gcc/mips-elf/${VERSION}/include/stdatomic.h lib/gcc/mips-elf/${VERSION}/include/stdbool.h lib/gcc/mips-elf/${VERSION}/include/stddef.h lib/gcc/mips-elf/${VERSION}/include/stdfix.h lib/gcc/mips-elf/${VERSION}/include/stdint-gcc.h lib/gcc/mips-elf/${VERSION}/include/stdint.h lib/gcc/mips-elf/${VERSION}/include/stdnoreturn.h lib/gcc/mips-elf/${VERSION}/include/tgmath.h lib/gcc/mips-elf/${VERSION}/include/unwind.h lib/gcc/mips-elf/${VERSION}/include/varargs.h lib/gcc/mips-elf/${VERSION}/install-tools/ lib/gcc/mips-elf/${VERSION}/install-tools/fixinc_list lib/gcc/mips-elf/${VERSION}/install-tools/gsyslimits.h lib/gcc/mips-elf/${VERSION}/install-tools/include/ lib/gcc/mips-elf/${VERSION}/install-tools/include/README lib/gcc/mips-elf/${VERSION}/install-tools/include/limits.h lib/gcc/mips-elf/${VERSION}/install-tools/macro_list lib/gcc/mips-elf/${VERSION}/install-tools/mkheaders.conf @static-lib lib/gcc/mips-elf/${VERSION}/libgcc.a @static-lib lib/gcc/mips-elf/${VERSION}/libgcov.a lib/gcc/mips-elf/${VERSION}/plugin/ lib/gcc/mips-elf/${VERSION}/plugin/gtype.state lib/gcc/mips-elf/${VERSION}/plugin/include/ lib/gcc/mips-elf/${VERSION}/plugin/include/ada/ lib/gcc/mips-elf/${VERSION}/plugin/include/ada/gcc-interface/ lib/gcc/mips-elf/${VERSION}/plugin/include/ada/gcc-interface/ada-tree.def lib/gcc/mips-elf/${VERSION}/plugin/include/addresses.h lib/gcc/mips-elf/${VERSION}/plugin/include/alias.h lib/gcc/mips-elf/${VERSION}/plugin/include/align.h lib/gcc/mips-elf/${VERSION}/plugin/include/all-tree.def lib/gcc/mips-elf/${VERSION}/plugin/include/alloc-pool.h lib/gcc/mips-elf/${VERSION}/plugin/include/ansidecl.h lib/gcc/mips-elf/${VERSION}/plugin/include/array-traits.h lib/gcc/mips-elf/${VERSION}/plugin/include/asan.h lib/gcc/mips-elf/${VERSION}/plugin/include/attr-fnspec.h lib/gcc/mips-elf/${VERSION}/plugin/include/attribs.h lib/gcc/mips-elf/${VERSION}/plugin/include/auto-host.h lib/gcc/mips-elf/${VERSION}/plugin/include/auto-profile.h lib/gcc/mips-elf/${VERSION}/plugin/include/b-header-vars lib/gcc/mips-elf/${VERSION}/plugin/include/backend.h lib/gcc/mips-elf/${VERSION}/plugin/include/basic-block.h lib/gcc/mips-elf/${VERSION}/plugin/include/bb-reorder.h lib/gcc/mips-elf/${VERSION}/plugin/include/bitmap.h lib/gcc/mips-elf/${VERSION}/plugin/include/builtin-attrs.def lib/gcc/mips-elf/${VERSION}/plugin/include/builtin-types.def lib/gcc/mips-elf/${VERSION}/plugin/include/builtins.def lib/gcc/mips-elf/${VERSION}/plugin/include/builtins.h lib/gcc/mips-elf/${VERSION}/plugin/include/bversion.h lib/gcc/mips-elf/${VERSION}/plugin/include/c-family/ lib/gcc/mips-elf/${VERSION}/plugin/include/c-family/c-common.def lib/gcc/mips-elf/${VERSION}/plugin/include/c-family/c-common.h lib/gcc/mips-elf/${VERSION}/plugin/include/c-family/c-objc.h lib/gcc/mips-elf/${VERSION}/plugin/include/c-family/c-pragma.h lib/gcc/mips-elf/${VERSION}/plugin/include/c-family/c-pretty-print.h lib/gcc/mips-elf/${VERSION}/plugin/include/c-tree.h lib/gcc/mips-elf/${VERSION}/plugin/include/calls.h lib/gcc/mips-elf/${VERSION}/plugin/include/ccmp.h lib/gcc/mips-elf/${VERSION}/plugin/include/cfg-flags.def lib/gcc/mips-elf/${VERSION}/plugin/include/cfg.h lib/gcc/mips-elf/${VERSION}/plugin/include/cfganal.h lib/gcc/mips-elf/${VERSION}/plugin/include/cfgbuild.h lib/gcc/mips-elf/${VERSION}/plugin/include/cfgcleanup.h lib/gcc/mips-elf/${VERSION}/plugin/include/cfgexpand.h lib/gcc/mips-elf/${VERSION}/plugin/include/cfghooks.h lib/gcc/mips-elf/${VERSION}/plugin/include/cfgloop.h lib/gcc/mips-elf/${VERSION}/plugin/include/cfgloopmanip.h lib/gcc/mips-elf/${VERSION}/plugin/include/cfgrtl.h lib/gcc/mips-elf/${VERSION}/plugin/include/cgraph.h lib/gcc/mips-elf/${VERSION}/plugin/include/cif-code.def lib/gcc/mips-elf/${VERSION}/plugin/include/collect-utils.h lib/gcc/mips-elf/${VERSION}/plugin/include/collect2-aix.h lib/gcc/mips-elf/${VERSION}/plugin/include/collect2.h lib/gcc/mips-elf/${VERSION}/plugin/include/color-macros.h lib/gcc/mips-elf/${VERSION}/plugin/include/conditions.h lib/gcc/mips-elf/${VERSION}/plugin/include/config/ lib/gcc/mips-elf/${VERSION}/plugin/include/config.h lib/gcc/mips-elf/${VERSION}/plugin/include/config/elfos.h lib/gcc/mips-elf/${VERSION}/plugin/include/config/initfini-array.h lib/gcc/mips-elf/${VERSION}/plugin/include/config/mips/ lib/gcc/mips-elf/${VERSION}/plugin/include/config/mips/elf.h lib/gcc/mips-elf/${VERSION}/plugin/include/config/mips/mips-opts.h lib/gcc/mips-elf/${VERSION}/plugin/include/config/mips/mips-protos.h lib/gcc/mips-elf/${VERSION}/plugin/include/config/mips/mips.h lib/gcc/mips-elf/${VERSION}/plugin/include/config/newlib-stdint.h lib/gcc/mips-elf/${VERSION}/plugin/include/config/vxworks-dummy.h lib/gcc/mips-elf/${VERSION}/plugin/include/configargs.h lib/gcc/mips-elf/${VERSION}/plugin/include/context.h lib/gcc/mips-elf/${VERSION}/plugin/include/convert.h lib/gcc/mips-elf/${VERSION}/plugin/include/coretypes.h lib/gcc/mips-elf/${VERSION}/plugin/include/coroutine-builtins.def lib/gcc/mips-elf/${VERSION}/plugin/include/coverage.h lib/gcc/mips-elf/${VERSION}/plugin/include/cp/ lib/gcc/mips-elf/${VERSION}/plugin/include/cp/cp-tree.def lib/gcc/mips-elf/${VERSION}/plugin/include/cppbuiltin.h lib/gcc/mips-elf/${VERSION}/plugin/include/cppdefault.h lib/gcc/mips-elf/${VERSION}/plugin/include/cpplib.h lib/gcc/mips-elf/${VERSION}/plugin/include/cselib.h lib/gcc/mips-elf/${VERSION}/plugin/include/ctfc.h lib/gcc/mips-elf/${VERSION}/plugin/include/d/ lib/gcc/mips-elf/${VERSION}/plugin/include/d/d-tree.def lib/gcc/mips-elf/${VERSION}/plugin/include/data-streamer.h lib/gcc/mips-elf/${VERSION}/plugin/include/dbgcnt.def lib/gcc/mips-elf/${VERSION}/plugin/include/dbgcnt.h lib/gcc/mips-elf/${VERSION}/plugin/include/dbxout.h lib/gcc/mips-elf/${VERSION}/plugin/include/dce.h lib/gcc/mips-elf/${VERSION}/plugin/include/ddg.h lib/gcc/mips-elf/${VERSION}/plugin/include/debug.h lib/gcc/mips-elf/${VERSION}/plugin/include/defaults.h lib/gcc/mips-elf/${VERSION}/plugin/include/df.h lib/gcc/mips-elf/${VERSION}/plugin/include/dfp.h lib/gcc/mips-elf/${VERSION}/plugin/include/diagnostic-color.h lib/gcc/mips-elf/${VERSION}/plugin/include/diagnostic-core.h lib/gcc/mips-elf/${VERSION}/plugin/include/diagnostic-event-id.h lib/gcc/mips-elf/${VERSION}/plugin/include/diagnostic-metadata.h lib/gcc/mips-elf/${VERSION}/plugin/include/diagnostic-path.h lib/gcc/mips-elf/${VERSION}/plugin/include/diagnostic-spec.h lib/gcc/mips-elf/${VERSION}/plugin/include/diagnostic-url.h lib/gcc/mips-elf/${VERSION}/plugin/include/diagnostic.def lib/gcc/mips-elf/${VERSION}/plugin/include/diagnostic.h lib/gcc/mips-elf/${VERSION}/plugin/include/digraph.h lib/gcc/mips-elf/${VERSION}/plugin/include/dojump.h lib/gcc/mips-elf/${VERSION}/plugin/include/dominance.h lib/gcc/mips-elf/${VERSION}/plugin/include/domwalk.h lib/gcc/mips-elf/${VERSION}/plugin/include/double-int.h lib/gcc/mips-elf/${VERSION}/plugin/include/dump-context.h lib/gcc/mips-elf/${VERSION}/plugin/include/dumpfile.h lib/gcc/mips-elf/${VERSION}/plugin/include/dwarf2asm.h lib/gcc/mips-elf/${VERSION}/plugin/include/dwarf2ctf.h lib/gcc/mips-elf/${VERSION}/plugin/include/dwarf2out.h lib/gcc/mips-elf/${VERSION}/plugin/include/edit-context.h lib/gcc/mips-elf/${VERSION}/plugin/include/emit-rtl.h lib/gcc/mips-elf/${VERSION}/plugin/include/errors.h lib/gcc/mips-elf/${VERSION}/plugin/include/escaped_string.h lib/gcc/mips-elf/${VERSION}/plugin/include/et-forest.h lib/gcc/mips-elf/${VERSION}/plugin/include/except.h lib/gcc/mips-elf/${VERSION}/plugin/include/explow.h lib/gcc/mips-elf/${VERSION}/plugin/include/expmed.h lib/gcc/mips-elf/${VERSION}/plugin/include/expr.h lib/gcc/mips-elf/${VERSION}/plugin/include/fibonacci_heap.h lib/gcc/mips-elf/${VERSION}/plugin/include/file-find.h lib/gcc/mips-elf/${VERSION}/plugin/include/file-prefix-map.h lib/gcc/mips-elf/${VERSION}/plugin/include/filenames.h lib/gcc/mips-elf/${VERSION}/plugin/include/fixed-value.h lib/gcc/mips-elf/${VERSION}/plugin/include/flag-types.h lib/gcc/mips-elf/${VERSION}/plugin/include/flags.h lib/gcc/mips-elf/${VERSION}/plugin/include/fold-const-call.h lib/gcc/mips-elf/${VERSION}/plugin/include/fold-const.h lib/gcc/mips-elf/${VERSION}/plugin/include/function-abi.h lib/gcc/mips-elf/${VERSION}/plugin/include/function.h lib/gcc/mips-elf/${VERSION}/plugin/include/gcc-plugin.h lib/gcc/mips-elf/${VERSION}/plugin/include/gcc-rich-location.h lib/gcc/mips-elf/${VERSION}/plugin/include/gcc-symtab.h lib/gcc/mips-elf/${VERSION}/plugin/include/gcc.h lib/gcc/mips-elf/${VERSION}/plugin/include/gcov-counter.def lib/gcc/mips-elf/${VERSION}/plugin/include/gcov-io.h lib/gcc/mips-elf/${VERSION}/plugin/include/gcse-common.h lib/gcc/mips-elf/${VERSION}/plugin/include/gcse.h lib/gcc/mips-elf/${VERSION}/plugin/include/generic-match.h lib/gcc/mips-elf/${VERSION}/plugin/include/gengtype.h lib/gcc/mips-elf/${VERSION}/plugin/include/genrtl.h lib/gcc/mips-elf/${VERSION}/plugin/include/gensupport.h lib/gcc/mips-elf/${VERSION}/plugin/include/ggc-internal.h lib/gcc/mips-elf/${VERSION}/plugin/include/ggc.h lib/gcc/mips-elf/${VERSION}/plugin/include/gimple-array-bounds.h lib/gcc/mips-elf/${VERSION}/plugin/include/gimple-builder.h lib/gcc/mips-elf/${VERSION}/plugin/include/gimple-expr.h lib/gcc/mips-elf/${VERSION}/plugin/include/gimple-fold.h lib/gcc/mips-elf/${VERSION}/plugin/include/gimple-iterator.h lib/gcc/mips-elf/${VERSION}/plugin/include/gimple-low.h lib/gcc/mips-elf/${VERSION}/plugin/include/gimple-match.h lib/gcc/mips-elf/${VERSION}/plugin/include/gimple-predicate-analysis.h lib/gcc/mips-elf/${VERSION}/plugin/include/gimple-predict.h lib/gcc/mips-elf/${VERSION}/plugin/include/gimple-pretty-print.h lib/gcc/mips-elf/${VERSION}/plugin/include/gimple-range-cache.h lib/gcc/mips-elf/${VERSION}/plugin/include/gimple-range-edge.h lib/gcc/mips-elf/${VERSION}/plugin/include/gimple-range-fold.h lib/gcc/mips-elf/${VERSION}/plugin/include/gimple-range-gori.h lib/gcc/mips-elf/${VERSION}/plugin/include/gimple-range-path.h lib/gcc/mips-elf/${VERSION}/plugin/include/gimple-range-trace.h lib/gcc/mips-elf/${VERSION}/plugin/include/gimple-range.h lib/gcc/mips-elf/${VERSION}/plugin/include/gimple-ssa-evrp-analyze.h lib/gcc/mips-elf/${VERSION}/plugin/include/gimple-ssa-warn-access.h lib/gcc/mips-elf/${VERSION}/plugin/include/gimple-ssa-warn-restrict.h lib/gcc/mips-elf/${VERSION}/plugin/include/gimple-ssa.h lib/gcc/mips-elf/${VERSION}/plugin/include/gimple-streamer.h lib/gcc/mips-elf/${VERSION}/plugin/include/gimple-walk.h lib/gcc/mips-elf/${VERSION}/plugin/include/gimple.def lib/gcc/mips-elf/${VERSION}/plugin/include/gimple.h lib/gcc/mips-elf/${VERSION}/plugin/include/gimplify-me.h lib/gcc/mips-elf/${VERSION}/plugin/include/gimplify.h lib/gcc/mips-elf/${VERSION}/plugin/include/glimits.h lib/gcc/mips-elf/${VERSION}/plugin/include/gomp-constants.h lib/gcc/mips-elf/${VERSION}/plugin/include/graph.h lib/gcc/mips-elf/${VERSION}/plugin/include/graphds.h lib/gcc/mips-elf/${VERSION}/plugin/include/graphite.h lib/gcc/mips-elf/${VERSION}/plugin/include/graphviz.h lib/gcc/mips-elf/${VERSION}/plugin/include/gsstruct.def lib/gcc/mips-elf/${VERSION}/plugin/include/gstab.h lib/gcc/mips-elf/${VERSION}/plugin/include/gsyms.h lib/gcc/mips-elf/${VERSION}/plugin/include/gsyslimits.h lib/gcc/mips-elf/${VERSION}/plugin/include/gtm-builtins.def lib/gcc/mips-elf/${VERSION}/plugin/include/gtype-desc.h lib/gcc/mips-elf/${VERSION}/plugin/include/hard-reg-set.h lib/gcc/mips-elf/${VERSION}/plugin/include/hash-map-traits.h lib/gcc/mips-elf/${VERSION}/plugin/include/hash-map.h lib/gcc/mips-elf/${VERSION}/plugin/include/hash-set.h lib/gcc/mips-elf/${VERSION}/plugin/include/hash-table.h lib/gcc/mips-elf/${VERSION}/plugin/include/hash-traits.h lib/gcc/mips-elf/${VERSION}/plugin/include/hashtab.h lib/gcc/mips-elf/${VERSION}/plugin/include/highlev-plugin-common.h lib/gcc/mips-elf/${VERSION}/plugin/include/hooks.h lib/gcc/mips-elf/${VERSION}/plugin/include/hosthooks-def.h lib/gcc/mips-elf/${VERSION}/plugin/include/hosthooks.h lib/gcc/mips-elf/${VERSION}/plugin/include/hw-doloop.h lib/gcc/mips-elf/${VERSION}/plugin/include/hwint.h lib/gcc/mips-elf/${VERSION}/plugin/include/ifcvt.h lib/gcc/mips-elf/${VERSION}/plugin/include/inchash.h lib/gcc/mips-elf/${VERSION}/plugin/include/incpath.h lib/gcc/mips-elf/${VERSION}/plugin/include/input.h lib/gcc/mips-elf/${VERSION}/plugin/include/insn-addr.h lib/gcc/mips-elf/${VERSION}/plugin/include/insn-attr-common.h lib/gcc/mips-elf/${VERSION}/plugin/include/insn-attr.h lib/gcc/mips-elf/${VERSION}/plugin/include/insn-codes.h lib/gcc/mips-elf/${VERSION}/plugin/include/insn-config.h lib/gcc/mips-elf/${VERSION}/plugin/include/insn-constants.h lib/gcc/mips-elf/${VERSION}/plugin/include/insn-flags.h lib/gcc/mips-elf/${VERSION}/plugin/include/insn-modes-inline.h lib/gcc/mips-elf/${VERSION}/plugin/include/insn-modes.h lib/gcc/mips-elf/${VERSION}/plugin/include/insn-notes.def lib/gcc/mips-elf/${VERSION}/plugin/include/int-vector-builder.h lib/gcc/mips-elf/${VERSION}/plugin/include/internal-fn.def lib/gcc/mips-elf/${VERSION}/plugin/include/internal-fn.h lib/gcc/mips-elf/${VERSION}/plugin/include/intl.h lib/gcc/mips-elf/${VERSION}/plugin/include/ipa-fnsummary.h lib/gcc/mips-elf/${VERSION}/plugin/include/ipa-icf-gimple.h lib/gcc/mips-elf/${VERSION}/plugin/include/ipa-icf.h lib/gcc/mips-elf/${VERSION}/plugin/include/ipa-inline.h lib/gcc/mips-elf/${VERSION}/plugin/include/ipa-modref-tree.h lib/gcc/mips-elf/${VERSION}/plugin/include/ipa-modref.h lib/gcc/mips-elf/${VERSION}/plugin/include/ipa-param-manipulation.h lib/gcc/mips-elf/${VERSION}/plugin/include/ipa-predicate.h lib/gcc/mips-elf/${VERSION}/plugin/include/ipa-prop.h lib/gcc/mips-elf/${VERSION}/plugin/include/ipa-ref.h lib/gcc/mips-elf/${VERSION}/plugin/include/ipa-reference.h lib/gcc/mips-elf/${VERSION}/plugin/include/ipa-utils.h lib/gcc/mips-elf/${VERSION}/plugin/include/ira-int.h lib/gcc/mips-elf/${VERSION}/plugin/include/ira.h lib/gcc/mips-elf/${VERSION}/plugin/include/is-a.h lib/gcc/mips-elf/${VERSION}/plugin/include/iterator-utils.h lib/gcc/mips-elf/${VERSION}/plugin/include/json.h lib/gcc/mips-elf/${VERSION}/plugin/include/langhooks-def.h lib/gcc/mips-elf/${VERSION}/plugin/include/langhooks.h lib/gcc/mips-elf/${VERSION}/plugin/include/lcm.h lib/gcc/mips-elf/${VERSION}/plugin/include/libfuncs.h lib/gcc/mips-elf/${VERSION}/plugin/include/libiberty.h lib/gcc/mips-elf/${VERSION}/plugin/include/limitx.h lib/gcc/mips-elf/${VERSION}/plugin/include/limity.h lib/gcc/mips-elf/${VERSION}/plugin/include/line-map.h lib/gcc/mips-elf/${VERSION}/plugin/include/loop-unroll.h lib/gcc/mips-elf/${VERSION}/plugin/include/lower-subreg.h lib/gcc/mips-elf/${VERSION}/plugin/include/lra-int.h lib/gcc/mips-elf/${VERSION}/plugin/include/lra.h lib/gcc/mips-elf/${VERSION}/plugin/include/lto-compress.h lib/gcc/mips-elf/${VERSION}/plugin/include/lto-section-names.h lib/gcc/mips-elf/${VERSION}/plugin/include/lto-streamer.h lib/gcc/mips-elf/${VERSION}/plugin/include/machmode.def lib/gcc/mips-elf/${VERSION}/plugin/include/machmode.h lib/gcc/mips-elf/${VERSION}/plugin/include/md5.h lib/gcc/mips-elf/${VERSION}/plugin/include/mem-stats-traits.h lib/gcc/mips-elf/${VERSION}/plugin/include/mem-stats.h lib/gcc/mips-elf/${VERSION}/plugin/include/memmodel.h lib/gcc/mips-elf/${VERSION}/plugin/include/memory-block.h lib/gcc/mips-elf/${VERSION}/plugin/include/mode-classes.def lib/gcc/mips-elf/${VERSION}/plugin/include/mux-utils.h lib/gcc/mips-elf/${VERSION}/plugin/include/objc/ lib/gcc/mips-elf/${VERSION}/plugin/include/objc/objc-tree.def lib/gcc/mips-elf/${VERSION}/plugin/include/obstack-utils.h lib/gcc/mips-elf/${VERSION}/plugin/include/obstack.h lib/gcc/mips-elf/${VERSION}/plugin/include/omp-builtins.def lib/gcc/mips-elf/${VERSION}/plugin/include/omp-expand.h lib/gcc/mips-elf/${VERSION}/plugin/include/omp-general.h lib/gcc/mips-elf/${VERSION}/plugin/include/omp-low.h lib/gcc/mips-elf/${VERSION}/plugin/include/omp-offload.h lib/gcc/mips-elf/${VERSION}/plugin/include/omp-simd-clone.h lib/gcc/mips-elf/${VERSION}/plugin/include/opt-problem.h lib/gcc/mips-elf/${VERSION}/plugin/include/opt-suggestions.h lib/gcc/mips-elf/${VERSION}/plugin/include/optabs-libfuncs.h lib/gcc/mips-elf/${VERSION}/plugin/include/optabs-query.h lib/gcc/mips-elf/${VERSION}/plugin/include/optabs-tree.h lib/gcc/mips-elf/${VERSION}/plugin/include/optabs.def lib/gcc/mips-elf/${VERSION}/plugin/include/optabs.h lib/gcc/mips-elf/${VERSION}/plugin/include/optinfo-emit-json.h lib/gcc/mips-elf/${VERSION}/plugin/include/optinfo.h lib/gcc/mips-elf/${VERSION}/plugin/include/options.h lib/gcc/mips-elf/${VERSION}/plugin/include/opts-diagnostic.h lib/gcc/mips-elf/${VERSION}/plugin/include/opts.h lib/gcc/mips-elf/${VERSION}/plugin/include/ordered-hash-map.h lib/gcc/mips-elf/${VERSION}/plugin/include/output.h lib/gcc/mips-elf/${VERSION}/plugin/include/pass-instances.def lib/gcc/mips-elf/${VERSION}/plugin/include/pass_manager.h lib/gcc/mips-elf/${VERSION}/plugin/include/passes.def lib/gcc/mips-elf/${VERSION}/plugin/include/plugin-api.h lib/gcc/mips-elf/${VERSION}/plugin/include/plugin-version.h lib/gcc/mips-elf/${VERSION}/plugin/include/plugin.def lib/gcc/mips-elf/${VERSION}/plugin/include/plugin.h lib/gcc/mips-elf/${VERSION}/plugin/include/pointer-query.h lib/gcc/mips-elf/${VERSION}/plugin/include/poly-int-types.h lib/gcc/mips-elf/${VERSION}/plugin/include/poly-int.h lib/gcc/mips-elf/${VERSION}/plugin/include/predict.def lib/gcc/mips-elf/${VERSION}/plugin/include/predict.h lib/gcc/mips-elf/${VERSION}/plugin/include/prefix.h lib/gcc/mips-elf/${VERSION}/plugin/include/pretty-print.h lib/gcc/mips-elf/${VERSION}/plugin/include/print-rtl.h lib/gcc/mips-elf/${VERSION}/plugin/include/print-tree.h lib/gcc/mips-elf/${VERSION}/plugin/include/profile-count.h lib/gcc/mips-elf/${VERSION}/plugin/include/profile.h lib/gcc/mips-elf/${VERSION}/plugin/include/range-op.h lib/gcc/mips-elf/${VERSION}/plugin/include/range.h lib/gcc/mips-elf/${VERSION}/plugin/include/read-md.h lib/gcc/mips-elf/${VERSION}/plugin/include/read-rtl-function.h lib/gcc/mips-elf/${VERSION}/plugin/include/real.h lib/gcc/mips-elf/${VERSION}/plugin/include/realmpfr.h lib/gcc/mips-elf/${VERSION}/plugin/include/recog.h lib/gcc/mips-elf/${VERSION}/plugin/include/reg-notes.def lib/gcc/mips-elf/${VERSION}/plugin/include/regcprop.h lib/gcc/mips-elf/${VERSION}/plugin/include/regrename.h lib/gcc/mips-elf/${VERSION}/plugin/include/regs.h lib/gcc/mips-elf/${VERSION}/plugin/include/regset.h lib/gcc/mips-elf/${VERSION}/plugin/include/reload.h lib/gcc/mips-elf/${VERSION}/plugin/include/resource.h lib/gcc/mips-elf/${VERSION}/plugin/include/rtl-error.h lib/gcc/mips-elf/${VERSION}/plugin/include/rtl-iter.h lib/gcc/mips-elf/${VERSION}/plugin/include/rtl-ssa.h lib/gcc/mips-elf/${VERSION}/plugin/include/rtl.def lib/gcc/mips-elf/${VERSION}/plugin/include/rtl.h lib/gcc/mips-elf/${VERSION}/plugin/include/rtlanal.h lib/gcc/mips-elf/${VERSION}/plugin/include/rtlhash.h lib/gcc/mips-elf/${VERSION}/plugin/include/rtlhooks-def.h lib/gcc/mips-elf/${VERSION}/plugin/include/rtx-vector-builder.h lib/gcc/mips-elf/${VERSION}/plugin/include/run-rtl-passes.h lib/gcc/mips-elf/${VERSION}/plugin/include/safe-ctype.h lib/gcc/mips-elf/${VERSION}/plugin/include/sanitizer.def lib/gcc/mips-elf/${VERSION}/plugin/include/sbitmap.h lib/gcc/mips-elf/${VERSION}/plugin/include/sched-int.h lib/gcc/mips-elf/${VERSION}/plugin/include/sel-sched-dump.h lib/gcc/mips-elf/${VERSION}/plugin/include/sel-sched-ir.h lib/gcc/mips-elf/${VERSION}/plugin/include/sel-sched.h lib/gcc/mips-elf/${VERSION}/plugin/include/selftest-diagnostic.h lib/gcc/mips-elf/${VERSION}/plugin/include/selftest-rtl.h lib/gcc/mips-elf/${VERSION}/plugin/include/selftest.h lib/gcc/mips-elf/${VERSION}/plugin/include/sese.h lib/gcc/mips-elf/${VERSION}/plugin/include/shortest-paths.h lib/gcc/mips-elf/${VERSION}/plugin/include/shrink-wrap.h lib/gcc/mips-elf/${VERSION}/plugin/include/signop.h lib/gcc/mips-elf/${VERSION}/plugin/include/sparseset.h lib/gcc/mips-elf/${VERSION}/plugin/include/spellcheck-tree.h lib/gcc/mips-elf/${VERSION}/plugin/include/spellcheck.h lib/gcc/mips-elf/${VERSION}/plugin/include/splay-tree-utils.h lib/gcc/mips-elf/${VERSION}/plugin/include/splay-tree.h lib/gcc/mips-elf/${VERSION}/plugin/include/sreal.h lib/gcc/mips-elf/${VERSION}/plugin/include/ssa-iterators.h lib/gcc/mips-elf/${VERSION}/plugin/include/ssa.h lib/gcc/mips-elf/${VERSION}/plugin/include/stab.def lib/gcc/mips-elf/${VERSION}/plugin/include/statistics.h lib/gcc/mips-elf/${VERSION}/plugin/include/stmt.h lib/gcc/mips-elf/${VERSION}/plugin/include/stor-layout.h lib/gcc/mips-elf/${VERSION}/plugin/include/streamer-hooks.h lib/gcc/mips-elf/${VERSION}/plugin/include/stringpool.h lib/gcc/mips-elf/${VERSION}/plugin/include/substring-locations.h lib/gcc/mips-elf/${VERSION}/plugin/include/symbol-summary.h lib/gcc/mips-elf/${VERSION}/plugin/include/symtab-clones.h lib/gcc/mips-elf/${VERSION}/plugin/include/symtab-thunks.h lib/gcc/mips-elf/${VERSION}/plugin/include/symtab.h lib/gcc/mips-elf/${VERSION}/plugin/include/sync-builtins.def lib/gcc/mips-elf/${VERSION}/plugin/include/system.h lib/gcc/mips-elf/${VERSION}/plugin/include/target-def.h lib/gcc/mips-elf/${VERSION}/plugin/include/target-globals.h lib/gcc/mips-elf/${VERSION}/plugin/include/target-hooks-macros.h lib/gcc/mips-elf/${VERSION}/plugin/include/target-insns.def lib/gcc/mips-elf/${VERSION}/plugin/include/target.def lib/gcc/mips-elf/${VERSION}/plugin/include/target.h lib/gcc/mips-elf/${VERSION}/plugin/include/targhooks.h lib/gcc/mips-elf/${VERSION}/plugin/include/timevar.def lib/gcc/mips-elf/${VERSION}/plugin/include/timevar.h lib/gcc/mips-elf/${VERSION}/plugin/include/tm-preds.h lib/gcc/mips-elf/${VERSION}/plugin/include/tm.h lib/gcc/mips-elf/${VERSION}/plugin/include/tm_p.h lib/gcc/mips-elf/${VERSION}/plugin/include/toplev.h lib/gcc/mips-elf/${VERSION}/plugin/include/tracer.h lib/gcc/mips-elf/${VERSION}/plugin/include/trans-mem.h lib/gcc/mips-elf/${VERSION}/plugin/include/tree-affine.h lib/gcc/mips-elf/${VERSION}/plugin/include/tree-cfg.h lib/gcc/mips-elf/${VERSION}/plugin/include/tree-cfgcleanup.h lib/gcc/mips-elf/${VERSION}/plugin/include/tree-check.h lib/gcc/mips-elf/${VERSION}/plugin/include/tree-chrec.h lib/gcc/mips-elf/${VERSION}/plugin/include/tree-core.h lib/gcc/mips-elf/${VERSION}/plugin/include/tree-data-ref.h lib/gcc/mips-elf/${VERSION}/plugin/include/tree-dfa.h lib/gcc/mips-elf/${VERSION}/plugin/include/tree-diagnostic.h lib/gcc/mips-elf/${VERSION}/plugin/include/tree-dump.h lib/gcc/mips-elf/${VERSION}/plugin/include/tree-eh.h lib/gcc/mips-elf/${VERSION}/plugin/include/tree-hash-traits.h lib/gcc/mips-elf/${VERSION}/plugin/include/tree-hasher.h lib/gcc/mips-elf/${VERSION}/plugin/include/tree-if-conv.h lib/gcc/mips-elf/${VERSION}/plugin/include/tree-inline.h lib/gcc/mips-elf/${VERSION}/plugin/include/tree-into-ssa.h lib/gcc/mips-elf/${VERSION}/plugin/include/tree-iterator.h lib/gcc/mips-elf/${VERSION}/plugin/include/tree-nested.h lib/gcc/mips-elf/${VERSION}/plugin/include/tree-object-size.h lib/gcc/mips-elf/${VERSION}/plugin/include/tree-outof-ssa.h lib/gcc/mips-elf/${VERSION}/plugin/include/tree-parloops.h lib/gcc/mips-elf/${VERSION}/plugin/include/tree-pass.h lib/gcc/mips-elf/${VERSION}/plugin/include/tree-phinodes.h lib/gcc/mips-elf/${VERSION}/plugin/include/tree-pretty-print.h lib/gcc/mips-elf/${VERSION}/plugin/include/tree-scalar-evolution.h lib/gcc/mips-elf/${VERSION}/plugin/include/tree-sra.h lib/gcc/mips-elf/${VERSION}/plugin/include/tree-ssa-address.h lib/gcc/mips-elf/${VERSION}/plugin/include/tree-ssa-alias-compare.h lib/gcc/mips-elf/${VERSION}/plugin/include/tree-ssa-alias.h lib/gcc/mips-elf/${VERSION}/plugin/include/tree-ssa-ccp.h lib/gcc/mips-elf/${VERSION}/plugin/include/tree-ssa-coalesce.h lib/gcc/mips-elf/${VERSION}/plugin/include/tree-ssa-dce.h lib/gcc/mips-elf/${VERSION}/plugin/include/tree-ssa-dom.h lib/gcc/mips-elf/${VERSION}/plugin/include/tree-ssa-dse.h lib/gcc/mips-elf/${VERSION}/plugin/include/tree-ssa-live.h lib/gcc/mips-elf/${VERSION}/plugin/include/tree-ssa-loop-ivopts.h lib/gcc/mips-elf/${VERSION}/plugin/include/tree-ssa-loop-manip.h lib/gcc/mips-elf/${VERSION}/plugin/include/tree-ssa-loop-niter.h lib/gcc/mips-elf/${VERSION}/plugin/include/tree-ssa-loop.h lib/gcc/mips-elf/${VERSION}/plugin/include/tree-ssa-math-opts.h lib/gcc/mips-elf/${VERSION}/plugin/include/tree-ssa-operands.h lib/gcc/mips-elf/${VERSION}/plugin/include/tree-ssa-propagate.h lib/gcc/mips-elf/${VERSION}/plugin/include/tree-ssa-reassoc.h lib/gcc/mips-elf/${VERSION}/plugin/include/tree-ssa-sccvn.h lib/gcc/mips-elf/${VERSION}/plugin/include/tree-ssa-scopedtables.h lib/gcc/mips-elf/${VERSION}/plugin/include/tree-ssa-strlen.h lib/gcc/mips-elf/${VERSION}/plugin/include/tree-ssa-ter.h lib/gcc/mips-elf/${VERSION}/plugin/include/tree-ssa-threadedge.h lib/gcc/mips-elf/${VERSION}/plugin/include/tree-ssa-threadupdate.h lib/gcc/mips-elf/${VERSION}/plugin/include/tree-ssa.h lib/gcc/mips-elf/${VERSION}/plugin/include/tree-ssanames.h lib/gcc/mips-elf/${VERSION}/plugin/include/tree-stdarg.h lib/gcc/mips-elf/${VERSION}/plugin/include/tree-streamer.h lib/gcc/mips-elf/${VERSION}/plugin/include/tree-switch-conversion.h lib/gcc/mips-elf/${VERSION}/plugin/include/tree-vector-builder.h lib/gcc/mips-elf/${VERSION}/plugin/include/tree-vectorizer.h lib/gcc/mips-elf/${VERSION}/plugin/include/tree-vrp.h lib/gcc/mips-elf/${VERSION}/plugin/include/tree.def lib/gcc/mips-elf/${VERSION}/plugin/include/tree.h lib/gcc/mips-elf/${VERSION}/plugin/include/treestruct.def lib/gcc/mips-elf/${VERSION}/plugin/include/tristate.h lib/gcc/mips-elf/${VERSION}/plugin/include/tsan.h lib/gcc/mips-elf/${VERSION}/plugin/include/tsystem.h lib/gcc/mips-elf/${VERSION}/plugin/include/typeclass.h lib/gcc/mips-elf/${VERSION}/plugin/include/typed-splay-tree.h lib/gcc/mips-elf/${VERSION}/plugin/include/ubsan.h lib/gcc/mips-elf/${VERSION}/plugin/include/valtrack.h lib/gcc/mips-elf/${VERSION}/plugin/include/value-pointer-equiv.h lib/gcc/mips-elf/${VERSION}/plugin/include/value-prof.h lib/gcc/mips-elf/${VERSION}/plugin/include/value-query.h lib/gcc/mips-elf/${VERSION}/plugin/include/value-range-equiv.h lib/gcc/mips-elf/${VERSION}/plugin/include/value-range.h lib/gcc/mips-elf/${VERSION}/plugin/include/value-relation.h lib/gcc/mips-elf/${VERSION}/plugin/include/varasm.h lib/gcc/mips-elf/${VERSION}/plugin/include/vec-perm-indices.h lib/gcc/mips-elf/${VERSION}/plugin/include/vec.h lib/gcc/mips-elf/${VERSION}/plugin/include/vector-builder.h lib/gcc/mips-elf/${VERSION}/plugin/include/version.h lib/gcc/mips-elf/${VERSION}/plugin/include/vmsdbg.h lib/gcc/mips-elf/${VERSION}/plugin/include/vr-values.h lib/gcc/mips-elf/${VERSION}/plugin/include/vtable-verify.h lib/gcc/mips-elf/${VERSION}/plugin/include/wide-int-bitmask.h lib/gcc/mips-elf/${VERSION}/plugin/include/wide-int-print.h lib/gcc/mips-elf/${VERSION}/plugin/include/wide-int.h lib/gcc/mips-elf/${VERSION}/plugin/include/xcoff.h lib/gcc/mips-elf/${VERSION}/plugin/include/xcoffout.h lib/gcc/mips-elf/${VERSION}/soft-float/ lib/gcc/mips-elf/${VERSION}/soft-float/crtbegin.o lib/gcc/mips-elf/${VERSION}/soft-float/crtend.o lib/gcc/mips-elf/${VERSION}/soft-float/crti.o lib/gcc/mips-elf/${VERSION}/soft-float/crtn.o lib/gcc/mips-elf/${VERSION}/soft-float/eb/ lib/gcc/mips-elf/${VERSION}/soft-float/eb/crtbegin.o lib/gcc/mips-elf/${VERSION}/soft-float/eb/crtend.o lib/gcc/mips-elf/${VERSION}/soft-float/eb/crti.o lib/gcc/mips-elf/${VERSION}/soft-float/eb/crtn.o @static-lib lib/gcc/mips-elf/${VERSION}/soft-float/eb/libgcc.a @static-lib lib/gcc/mips-elf/${VERSION}/soft-float/eb/libgcov.a lib/gcc/mips-elf/${VERSION}/soft-float/el/ lib/gcc/mips-elf/${VERSION}/soft-float/el/crtbegin.o lib/gcc/mips-elf/${VERSION}/soft-float/el/crtend.o lib/gcc/mips-elf/${VERSION}/soft-float/el/crti.o lib/gcc/mips-elf/${VERSION}/soft-float/el/crtn.o @static-lib lib/gcc/mips-elf/${VERSION}/soft-float/el/libgcc.a @static-lib lib/gcc/mips-elf/${VERSION}/soft-float/el/libgcov.a @static-lib lib/gcc/mips-elf/${VERSION}/soft-float/libgcc.a @static-lib lib/gcc/mips-elf/${VERSION}/soft-float/libgcov.a libexec/gcc/ libexec/gcc/mips-elf/ libexec/gcc/mips-elf/${VERSION}/ @bin libexec/gcc/mips-elf/${VERSION}/cc1 @bin libexec/gcc/mips-elf/${VERSION}/collect2 @bin libexec/gcc/mips-elf/${VERSION}/g++-mapper-server libexec/gcc/mips-elf/${VERSION}/install-tools/ libexec/gcc/mips-elf/${VERSION}/install-tools/fixinc.sh @bin libexec/gcc/mips-elf/${VERSION}/install-tools/fixincl libexec/gcc/mips-elf/${VERSION}/install-tools/mkheaders libexec/gcc/mips-elf/${VERSION}/install-tools/mkinstalldirs libexec/gcc/mips-elf/${VERSION}/liblto_plugin.la @so libexec/gcc/mips-elf/${VERSION}/liblto_plugin.so @bin libexec/gcc/mips-elf/${VERSION}/lto-wrapper @bin libexec/gcc/mips-elf/${VERSION}/lto1 libexec/gcc/mips-elf/${VERSION}/plugin/ @bin libexec/gcc/mips-elf/${VERSION}/plugin/gengtype @man man/man1/mips-elf-cpp.1 @man man/man1/mips-elf-gcc.1 @man man/man1/mips-elf-gcov-dump.1 @man man/man1/mips-elf-gcov-tool.1 @man man/man1/mips-elf-gcov.1 @comment @man man/man7/fsf-funding.7 @comment @man man/man7/gfdl.7 @comment @man man/man7/gpl.7 @man man/man1/mips-elf-lto-dump.1 ================================================ FILE: tools/openbsd/ports/mystuff/devel/stlink/Makefile ================================================ COMMENT= toolset for ST Microelectronics ST-Link V1/V2/V2-1/V3 V= 1.8.0 DISTNAME= stlink-${V} SHARED_LIBS+= stlink 0.0 # 0.0 CATEGORIES= devel HOMEPAGE= https://github.com/stlink-org/stlink # BSD PERMIT_PACKAGE= Yes WANTLIB= c usb-1.0 GH_ACCOUNT= stlink-org GH_PROJECT= stlink GH_TAGNAME= v${V} LIB_DEPENDS= devel/libusb1 MODULES= devel/cmake .include ================================================ FILE: tools/openbsd/ports/mystuff/devel/stlink/distinfo ================================================ SHA256 (stlink-1.8.0.tar.gz) = z/dgtcISwsxID3BbnKfzgo1rnCZ5UMalRwAs0KH19qw= SIZE (stlink-1.8.0.tar.gz) = 257240 ================================================ FILE: tools/openbsd/ports/mystuff/devel/stlink/patches/patch-CMakeLists_txt ================================================ Index: CMakeLists.txt --- CMakeLists.txt.orig +++ CMakeLists.txt @@ -392,7 +392,6 @@ install(FILES ${CHIP_FILES} DESTINATION ${CMAKE_CHIPS_ option(STLINK_GENERATE_MANPAGES "Generate manpages with pandoc" OFF) add_subdirectory(doc/man) # contains subordinate CMakeLists to generate manpages -add_subdirectory(src/stlink-gui) # contains subordinate CMakeLists to build GUI add_subdirectory(tests) # contains subordinate CMakeLists to build test executables add_subdirectory(cmake/packaging) # contains subordinate CMakeLists to build packages ================================================ FILE: tools/openbsd/ports/mystuff/devel/stlink/patches/patch-cmake_modules_c_flags_cmake ================================================ Index: cmake/modules/c_flags.cmake --- cmake/modules/c_flags.cmake.orig +++ cmake/modules/c_flags.cmake @@ -28,7 +28,6 @@ add_cflag_if_supported("-Wformat") add_cflag_if_supported("-Wformat-security") add_cflag_if_supported("-Wmaybe-uninitialized") add_cflag_if_supported("-Wmissing-variable-declarations") -add_cflag_if_supported("-Wshorten-64-to-32") add_cflag_if_supported("-Wimplicit-function-declaration") ## ================================================ FILE: tools/openbsd/ports/mystuff/devel/stlink/patches/patch-doc_man_CMakeLists_txt ================================================ Index: doc/man/CMakeLists.txt --- doc/man/CMakeLists.txt.orig +++ doc/man/CMakeLists.txt @@ -30,7 +30,7 @@ foreach (manpage ${MANPAGES}) endif() if (f AND NOT WIN32) - install(FILES ${f} DESTINATION ${CMAKE_INSTALL_DATADIR}/man/man1) + install(FILES ${f} DESTINATION ${CMAKE_INSTALL_MANDIR}/man1) unset(f) endif() endforeach () ================================================ FILE: tools/openbsd/ports/mystuff/devel/stlink/pkg/DESCR ================================================ Programming toolset for ST Microelectronics ST-Link V1/V2/V2-1/V3 Example command to load firmware into target: $ st-flash --reset write file.bin 0x08000000 ================================================ FILE: tools/openbsd/ports/mystuff/devel/stlink/pkg/PLIST ================================================ @bin bin/st-flash @bin bin/st-info @bin bin/st-trace @bin bin/st-util include/stlink/ include/stlink/backend.h include/stlink/calculate.h include/stlink/chipid.h include/stlink/commands.h include/stlink/common_flash.h include/stlink/flash_loader.h include/stlink/helper.h include/stlink/lib_md5.h include/stlink/libusb_settings.h include/stlink/logging.h include/stlink/map_file.h include/stlink/md5.h include/stlink/option_bytes.h include/stlink/read_write.h include/stlink/register.h include/stlink/sg.h include/stlink/spdlog_wrapper.h include/stlink/stlink.h include/stlink/stm32.h include/stlink/stm32flash.h include/stlink/usb.h include/stlink/version.h @static-lib lib/libstlink.a @lib lib/libstlink.so.${LIBstlink_VERSION} @man man/man1/st-flash.1 @man man/man1/st-info.1 @man man/man1/st-util.1 share/stlink/ share/stlink/chips/ share/stlink/chips/C011xx.chip share/stlink/chips/C031xx.chip share/stlink/chips/F03x.chip share/stlink/chips/F04x.chip share/stlink/chips/F05x.chip share/stlink/chips/F07x.chip share/stlink/chips/F09x.chip share/stlink/chips/F1xx_CL.chip share/stlink/chips/F1xx_HD.chip share/stlink/chips/F1xx_LD.chip share/stlink/chips/F1xx_MD.chip share/stlink/chips/F1xx_VL_HD.chip share/stlink/chips/F1xx_VL_MD_LD.chip share/stlink/chips/F1xx_XLD.chip share/stlink/chips/F2xx.chip share/stlink/chips/F301_F302_F318.chip share/stlink/chips/F302_F303_F358.chip share/stlink/chips/F302_F303_F398_HD.chip share/stlink/chips/F303_F328_F334.chip share/stlink/chips/F37x.chip share/stlink/chips/F401xB_xC.chip share/stlink/chips/F401xD_xE.chip share/stlink/chips/F410.chip share/stlink/chips/F411xC_xE.chip share/stlink/chips/F412.chip share/stlink/chips/F413_F423.chip share/stlink/chips/F42x_F43x.chip share/stlink/chips/F446.chip share/stlink/chips/F46x_F47x.chip share/stlink/chips/F4x5_F4x7.chip share/stlink/chips/F72x_F73x.chip share/stlink/chips/F74x_F75x.chip share/stlink/chips/F76x_F77x.chip share/stlink/chips/G03x_G04x.chip share/stlink/chips/G05x_G06x.chip share/stlink/chips/G07x_G08x.chip share/stlink/chips/G0Bx_G0Cx.chip share/stlink/chips/G43x_G44x.chip share/stlink/chips/G47x_G48x.chip share/stlink/chips/G49x_G4Ax.chip share/stlink/chips/H5xx.chip share/stlink/chips/H72x_H73x.chip share/stlink/chips/H74x_H75x.chip share/stlink/chips/H7Ax_H7Bx.chip share/stlink/chips/L0xxx_Cat_1.chip share/stlink/chips/L0xxx_Cat_2.chip share/stlink/chips/L0xxx_Cat_3.chip share/stlink/chips/L0xxx_Cat_5.chip share/stlink/chips/L1xx_Cat_1.chip share/stlink/chips/L1xx_Cat_2.chip share/stlink/chips/L1xx_Cat_3.chip share/stlink/chips/L1xx_Cat_4.chip share/stlink/chips/L1xx_Cat_5.chip share/stlink/chips/L41x_L42x.chip share/stlink/chips/L43x_L44x.chip share/stlink/chips/L45x_L46x.chip share/stlink/chips/L47x_L48x.chip share/stlink/chips/L496x_L4A6x.chip share/stlink/chips/L4Px_L4Qx.chip share/stlink/chips/L4Rx.chip share/stlink/chips/L5x5xx.chip share/stlink/chips/U535_U545.chip share/stlink/chips/U55Fx_U5Gx.chip share/stlink/chips/U575_U585.chip share/stlink/chips/U59x_U5Ax.chip share/stlink/chips/WBx0_WBx5.chip share/stlink/chips/WLEx.chip share/stlink/chips/unknown_device.chip ================================================ FILE: tools/openbsd/ports/mystuff/emulators/qemu-arm/Makefile ================================================ ONLY_FOR_ARCHS= amd64 i386 powerpc sparc64 USE_WXNEEDED= Yes COMMENT= multi system emulator, Arm Cortex-M version DISTNAME= qemu-arm-2.8.0.6.20190517 REVISION= 0 CATEGORIES= emulators HOMEPAGE= https://github.com/ilg-archived/qemu # GPLv2, LGPLv2 and BSD PERMIT_PACKAGE= Yes GH_ACCOUNT= ilg-archived GH_PROJECT= qemu GH_TAGNAME= v2.8.0-6-20190517 WANTLIB= SDL2 SDL2_image X11 c drm epoxy fdt \ gbm glib-2.0 gthread-2.0 intl iscsi m \ atk-1.0 cairo cairo-gobject gdk-3 \ gdk_pixbuf-2.0 gio-2.0 gobject-2.0 gtk-3 \ harfbuzz pango-1.0 pangocairo-1.0 vte-2.91 \ pixman-1 util z ${COMPILER_LIBCXX} # Using TLS emulation layer COMPILER= base-clang ports-gcc MODULES= lang/python MODPY_VERSION= ${MODPY_DEFAULT_VERSION_2} BUILD_DEPENDS= devel/gettext,-tools \ textproc/py-sphinx${MODPY_FLAVOR} \ textproc/texi2html LIB_DEPENDS= devel/dtc \ devel/glib2 \ devel/libiscsi \ devel/pango \ devel/sdl2 \ devel/sdl2-image \ devel/vte3 \ graphics/cairo MODPY_RUNDEP= No MAKE_ENV= V=1 FAKE_FLAGS= qemu_confdir=${PREFIX}/share/examples/qemu EXTRA_CFLAGS= -I${LOCALBASE}/include -I${X11BASE}/include EXTRA_LDFLAGS= -L${LOCALBASE}/lib -L${X11BASE}/lib # fix build with ancient ncurses. ncurses needs to be updated to 5.9 or newer. EXTRA_CFLAGS+= -D_XOPEN_SOURCE_EXTENDED # until the system headers are fixed properly. EXTRA_CFLAGS+= -Wno-redundant-decls SEPARATE_BUILD= Yes USE_GMAKE= Yes CONFIGURE_STYLE=simple CONFIGURE_ARGS= --prefix=${PREFIX} \ --sysconfdir=${SYSCONFDIR} \ --mandir=${PREFIX}/man \ --python=${MODPY_BIN} \ --cc="${CC}" \ --cxx="${CXX}" \ --host-cc="${CC}" \ --extra-cflags="${EXTRA_CFLAGS}" \ --extra-ldflags="${EXTRA_LDFLAGS}" \ --target-list="gnuarmeclipse-softmmu" \ --with-sdlabi="2.0" \ --disable-bsd-user \ --disable-werror \ --disable-bluez \ --disable-gcrypt \ --disable-gnutls \ --disable-libnfs \ --disable-libssh2 \ --disable-linux-aio \ --disable-lzo \ --disable-nettle \ --disable-seccomp \ --disable-smartcard \ --disable-snappy \ --disable-spice \ --disable-usb-redir \ --disable-vnc-sasl FLAVORS= debug FLAVOR?= .if ${FLAVOR:Mdebug} CFLAGS+= -O0 CONFIGURE_ARGS+=--enable-debug INSTALL_STRIP= .else CONFIGURE_ARGS+=--disable-debug-info .endif TEST_TARGET= check # Install the json scripts and board graphics. post-install: ${INSTALL_DATA_DIR} ${PREFIX}/share/qemu/devices ${INSTALL_DATA} ${WRKSRC}/gnu-mcu-eclipse/devices/*.json \ ${PREFIX}/share/qemu/devices ${INSTALL_DATA} ${WRKSRC}/gnu-mcu-eclipse/devices/README.md \ ${PREFIX}/share/qemu/devices ${INSTALL_DATA_DIR} ${PREFIX}/share/qemu/graphics ${INSTALL_DATA} ${WRKSRC}/gnu-mcu-eclipse/graphics/*.jpg \ ${PREFIX}/share/qemu/graphics .include ================================================ FILE: tools/openbsd/ports/mystuff/emulators/qemu-arm/distinfo ================================================ SHA256 (qemu-arm-2.8.0.6.20190517.tar.gz) = DXr9KwFXGUp3IjXwA3lSda67LyDqEfvzt+H7MeDMAfw= SIZE (qemu-arm-2.8.0.6.20190517.tar.gz) = 17989504 ================================================ FILE: tools/openbsd/ports/mystuff/emulators/qemu-arm/patches/patch-include_ui_egl-helpers_h ================================================ From fbd57c754f32804a63295f70f271d1ef128ee590 Mon Sep 17 00:00:00 2001 From: Alexander Kanavin Date: Wed, 16 Jan 2019 12:37:51 +0100 Subject: [PATCH] egl-helpers.h: do not depend on X11 Window type, use EGLNativeWindowType MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It was assumed that mesa provides the necessary X11 includes, but it is not always the case, as it can be configured without x11 support. Signed-off-by: Alexander Kanavin Reviewed-by: Philippe Mathieu-Daudé Message-id: 20190116113751.17177-1-alex.kanavin@gmail.com [ kraxel: codestyle fix (long line) ] Signed-off-by: Gerd Hoffmann Index: include/ui/egl-helpers.h --- include/ui/egl-helpers.h.orig +++ include/ui/egl-helpers.h @@ -20,7 +20,7 @@ int egl_get_fd_for_texture(uint32_t tex_id, EGLint *st #endif -EGLSurface qemu_egl_init_surface_x11(EGLContext ectx, Window win); +EGLSurface qemu_egl_init_surface_x11(EGLContext ectx, EGLNativeWindowType win); int qemu_egl_init_dpy(EGLNativeDisplayType dpy, bool gles, bool debug); EGLContext qemu_egl_init_ctx(void); ================================================ FILE: tools/openbsd/ports/mystuff/emulators/qemu-arm/patches/patch-ui_egl-helpers_c ================================================ From fbd57c754f32804a63295f70f271d1ef128ee590 Mon Sep 17 00:00:00 2001 From: Alexander Kanavin Date: Wed, 16 Jan 2019 12:37:51 +0100 Subject: [PATCH] egl-helpers.h: do not depend on X11 Window type, use EGLNativeWindowType MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It was assumed that mesa provides the necessary X11 includes, but it is not always the case, as it can be configured without x11 support. Signed-off-by: Alexander Kanavin Reviewed-by: Philippe Mathieu-Daudé Message-id: 20190116113751.17177-1-alex.kanavin@gmail.com [ kraxel: codestyle fix (long line) ] Signed-off-by: Gerd Hoffmann Index: ui/egl-helpers.c --- ui/egl-helpers.c.orig +++ ui/egl-helpers.c @@ -146,7 +146,7 @@ int egl_get_fd_for_texture(uint32_t tex_id, EGLint *st /* ---------------------------------------------------------------------- */ -EGLSurface qemu_egl_init_surface_x11(EGLContext ectx, Window win) +EGLSurface qemu_egl_init_surface_x11(EGLContext ectx, EGLNativeWindowType win) { EGLSurface esurface; EGLBoolean b; @@ -155,7 +155,7 @@ EGLSurface qemu_egl_init_surface_x11(EGLContext ectx, (unsigned long) win); esurface = eglCreateWindowSurface(qemu_egl_display, qemu_egl_config, - (EGLNativeWindowType)win, NULL); + win, NULL); if (esurface == EGL_NO_SURFACE) { error_report("egl: eglCreateWindowSurface failed"); return NULL; ================================================ FILE: tools/openbsd/ports/mystuff/emulators/qemu-arm/patches/patch-ui_gtk-egl_c ================================================ From fbd57c754f32804a63295f70f271d1ef128ee590 Mon Sep 17 00:00:00 2001 From: Alexander Kanavin Date: Wed, 16 Jan 2019 12:37:51 +0100 Subject: [PATCH] egl-helpers.h: do not depend on X11 Window type, use EGLNativeWindowType MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It was assumed that mesa provides the necessary X11 includes, but it is not always the case, as it can be configured without x11 support. Signed-off-by: Alexander Kanavin Reviewed-by: Philippe Mathieu-Daudé Message-id: 20190116113751.17177-1-alex.kanavin@gmail.com [ kraxel: codestyle fix (long line) ] Signed-off-by: Gerd Hoffmann Index: ui/gtk-egl.c --- ui/gtk-egl.c.orig +++ ui/gtk-egl.c @@ -64,7 +64,8 @@ void gd_egl_init(VirtualConsole *vc) } vc->gfx.ectx = qemu_egl_init_ctx(); - vc->gfx.esurface = qemu_egl_init_surface_x11(vc->gfx.ectx, x11_window); + vc->gfx.esurface = qemu_egl_init_surface_x11 + (vc->gfx.ectx, (EGLNativeWindowType)x11_window); assert(vc->gfx.esurface); } ================================================ FILE: tools/openbsd/ports/mystuff/emulators/qemu-arm/pkg/DESCR ================================================ QEMU is an open source machine emulator. It can run OSes and programs made for one machine (e.g. an ARM board) on a different machine (e.g. your own PC). By using dynamic translation, it achieves very good performance. ================================================ FILE: tools/openbsd/ports/mystuff/emulators/qemu-arm/pkg/PLIST ================================================ @conflict kqemu-* @conflict qemu-* @pkgpath emulators/kqemu @pkgpath emulators/qemu,kqemu @pkgpath emulators/qemu-old[,no_x11] @bin bin/qemu-system-gnuarmeclipse @man man/man1/qemu.1 share/doc/qemu/ share/doc/qemu/qemu-doc.html share/doc/qemu/qmp-commands.txt share/qemu/ share/qemu/devices/ share/qemu/devices/README.md share/qemu/devices/STM32F0x1-qemu.json share/qemu/devices/STM32F0x2-qemu.json share/qemu/devices/STM32F103xx-qemu.json share/qemu/devices/STM32F107xx-qemu.json share/qemu/devices/STM32F40x-qemu.json share/qemu/devices/STM32F411xx-qemu.json share/qemu/devices/STM32F429x-qemu.json share/qemu/graphics/ share/qemu/graphics/Maple.jpg share/qemu/graphics/NUCLEO-F072RB.jpg share/qemu/graphics/NUCLEO-F103RB.jpg share/qemu/graphics/NUCLEO-F411RE.jpg share/qemu/graphics/NetduinoGo.jpg share/qemu/graphics/NetduinoPlus2.jpg share/qemu/graphics/OLIMEXINO-STM32.jpg share/qemu/graphics/STM32-E407.jpg share/qemu/graphics/STM32-H103.jpg share/qemu/graphics/STM32-P103.jpg share/qemu/graphics/STM32-P107.jpg share/qemu/graphics/STM32F0-Discovery.jpg share/qemu/graphics/STM32F4-Discovery.jpg share/qemu/graphics/STM32F429I-Discovery.jpg share/qemu/keymaps/ share/qemu/keymaps/ar share/qemu/keymaps/bepo share/qemu/keymaps/common share/qemu/keymaps/cz share/qemu/keymaps/da share/qemu/keymaps/de share/qemu/keymaps/de-ch share/qemu/keymaps/en-gb share/qemu/keymaps/en-us share/qemu/keymaps/es share/qemu/keymaps/et share/qemu/keymaps/fi share/qemu/keymaps/fo share/qemu/keymaps/fr share/qemu/keymaps/fr-be share/qemu/keymaps/fr-ca share/qemu/keymaps/fr-ch share/qemu/keymaps/hr share/qemu/keymaps/hu share/qemu/keymaps/is share/qemu/keymaps/it share/qemu/keymaps/ja share/qemu/keymaps/lt share/qemu/keymaps/lv share/qemu/keymaps/mk share/qemu/keymaps/modifiers share/qemu/keymaps/nl share/qemu/keymaps/nl-be share/qemu/keymaps/no share/qemu/keymaps/pl share/qemu/keymaps/pt share/qemu/keymaps/pt-br share/qemu/keymaps/ru share/qemu/keymaps/sl share/qemu/keymaps/sv share/qemu/keymaps/th share/qemu/keymaps/tr share/qemu/trace-events-all ================================================ FILE: tools/virtualmips/.gitignore ================================================ .deps pic32 m4k *~ ================================================ FILE: tools/virtualmips/LICENSE ================================================ The following points clarify the virtualmips license: virtualmips as a whole is released under the GNU General Public License ================================================ FILE: tools/virtualmips/Makefile ================================================ TOPSRC!=cd ../..; pwd -include ../Makefile.inc # # Build VirtualMIPS simulator. # # Select target board: # chipKIT Max32 CFLAGS = -DSIM_PIC32 -DPIC32MX7 -DMAX32 # Maximite #CFLAGS = -DSIM_PIC32 -DPIC32MX7 -DMAXIMITE # Microchip Explorer 16 #CFLAGS = -DSIM_PIC32 -DPIC32MX7 -DEXPLORER16 # UBW32 with UART console #CFLAGS = -DSIM_PIC32 -DPIC32MX7 -DUBW32 #CFLAGS += -Wall -MT $@ -MD -MP -MF .deps/$*.dep -I/opt/local/include -I/opt/local/include/libelf CFLAGS += -Wall -MT $@ -MD -MP -MF .deps/$*.dep -I/usr/local/include -I/usr/local/include/elftoolchain LIBS = -lpthread -lelf LIBS += -L/usr/local/lib/elftoolchain # libbsd-dev package on Linux in overlay mode. CFLAGS+= ${_LIBBSD_CFLAGS} LIBS+= ${_LIBBSD_LIBS} ADDLIBS!=if [ x"${_HOST_OSNAME}" = x"OpenBSD" ] ; then \ echo "-L/usr/local/lib -lintl" ; \ elif [ x"${_HOST_OSNAME}" = x"Darwin" ] ; then \ echo "-L/opt/local/lib -lintl" ; \ elif [ x"${_HOST_OSNAME}" = x"Linux" ] ; then \ echo "-lrt" ; \ else \ echo "" ; \ fi LIBS += ${ADDLIBS} # Optimization. CFLAGS += -O #CFLAGS += -O3 -fomit-frame-pointer # Microchip PIC32MX PROG = pic32 OBJS = pic32.o pic32_dev_flash.o pic32_dev_uart.o pic32_dev_intcon.o \ pic32_dev_spi.o pic32_dev_gpio.o dev_sdcard.o dev_swap.o \ pic32_dev_bmxcon.o pic32_dev_dmacon.o pic32_dev_syscon.o \ pic32_dev_prefetch.o pic32_dev_adc.o pic32_dev_devcfg.o \ pic32_dev_rtcc.o pic32_dev_timer.o # Generic M4K core #PROG = m4k #OBJS = m4k.o # Ingenic JZ4740. #CFLAGS += -DSIM_PAVO -D_USE_FDD_ #PROG = pavo #OBJS = pavo.o jz4740.o jz4740_dev_cpm.o jz4740_dev_dma.o \ # jz4740_dev_emc.o jz4740_dev_gpio.o jz4740_dev_int.o \ # jz4740_dev_rtc.o jz4740_dev_ts.o \ # jz4740_dev_uart.o jz4740_dev_wdt_tcu.o # Implement LCD. #CFLAGS += -DSIM_LCD #LIBS += -lSDL #OBJS += jz4740_dev_lcd.o vp_sdl.o # Use JIT compiler. #CFLAGS += -D_USE_JIT_ #OBJS += mips_jit.o x86_trans.o # Common files. OBJS += dev_cs8900.o dev_nand_flash_1g.o dev_ram.o \ dev_vtty.o device.o vm.o cpu.o mips.o mips_cp0.o \ mips_exec.o mips_fdd.o crc.o mips_hostalarm.o \ mempool.o sbox.o utils.o vp_clock.o vp_timer.o net_io.o \ mips_memory.o debug.o gdb_interface.o main.o \ mips-dis.o config.o all: .deps $(PROG) $(PROG): $(OBJS) $(CC) $(LDFLAGS) -o $@ $(OBJS) $(LIBS) .deps: @mkdir .deps install: all clean: rm -rf *.o *~ *_log.txt .deps pavo m4k pic32 pic32-log.txt *.core -include .deps/*.dep ================================================ FILE: tools/virtualmips/README ================================================ Please visit http://code.google.com/p/virtualmips/ to get the information of how to use VirtualMIPS. ================================================ FILE: tools/virtualmips/SConstruct ================================================ #Build script of virtualmips. #Scons is really an excellent tool to build software! import os,platform,SCons,glob,re,sys ######################### # Global Environment # ######################### baseEnv=Environment() if ARGUMENTS.get('debug',0): baseEnv.Append(CCFLAGS = "-g") helpString = """ Usage: scons [target] [compile options] Targets: pavo: Build VirtualMIPS for pavo emulation mknandflash: Build mknandflash tool Compile Options: jit: Set to 0 to compile VirtualMIPS *without* JIT support(pavo only). Default 1. lcd: Set to 0 to compile VirtualMIPS *without* LCD support(pavo only). Default 1. mhz: Set to 1 to test emulator's speed. Default 0. debug: Set to 1 to compile with -g. Default 0. o: Set optimization level.Default 3. cc: Set compiler.Default "gcc". You can set cc=gcc-3.4 to use gcc 3.4. """ ######################### # Project Environment # ######################### baseEnv.Append(INCDIR = [os.path.join(os.path.abspath('.'),'../emulator')]) baseEnv.Append(INCDIR = [os.path.join(os.path.abspath('.'),'../emulator','device')]) baseEnv.Append(INCDIR = [os.path.join(os.path.abspath('.'),'../emulator','system')]) baseEnv.Append(INCDIR = [os.path.join(os.path.abspath('.'),'../emulator','mips')]) baseEnv.Append(INCDIR = [os.path.join(os.path.abspath('.'),'../emulator','utils')]) baseEnv.Append(INCDIR = [os.path.join(os.path.abspath('.'),'../emulator','utils','net')]) baseEnv.Append(INCDIR = [os.path.join(os.path.abspath('.'),'../emulator','memory')]) baseEnv.Append(INCDIR = [os.path.join(os.path.abspath('.'),'../emulator','gdb')]) baseEnv.Append(CPPPATH = baseEnv['INCDIR']) baseEnv.Append(LIBS = ['confuse','pthread','rt','elf'] ) baseEnv.Append(LIBPATH = ['/usr/lib', '/usr/local/lib'] ) baseEnv.Append(CCFLAGS= "-Wall -fomit-frame-pointer" ) mhz = ARGUMENTS.get('mhz', 0) if int(mhz): #test emulator's MHZ baseEnv.Append(CCFLAGS = "-DDEBUG_MHZ") o = ARGUMENTS.get('o', 3) if int(o)==3: baseEnv.Append(CCFLAGS= "-O3" ) baseEnv.Append(LINKFLAGS = "-O3" ) elif int(o)==2: baseEnv.Append(CCFLAGS= "-O2" ) baseEnv.Append(LINKFLAGS = "-O2" ) elif int(o)==1: baseEnv.Append(CCFLAGS= "-O1" ) baseEnv.Append(LINKFLAGS = "-O1" ) cc1 = ARGUMENTS.get('cc', "gcc") if (cc1): baseEnv.Replace(CC = cc1) Help(helpString) def listFiles(dirs,srcexts): allFiles = [] for dir in (dirs): path= os.path.join(os.path.abspath(dir),srcexts) newFiles = glob.glob(path) for newFile in newFiles: allFiles.append(newFile) return allFiles if 'pavo' in COMMAND_LINE_TARGETS: pavo = baseEnv.Clone() pavo.Append(CPPPATH = [os.path.join(os.path.abspath('.'),'../emulator','system','jz','soc')]) pavo.Append(CPPPATH = [os.path.join(os.path.abspath('.'),'../emulator','system','jz','pavo')]) pavo.Append(CPPPATH = [os.path.join(os.path.abspath('.'),'../emulator','utils','sdl')]) pavo.Append(CCFLAGS = "-DSIM_PAVO") lcd = ARGUMENTS.get('lcd', 1) if int(lcd): #check libsdl conf = Configure(pavo) if not conf.CheckLib('SDL'): print 'Did not find libSDL, exiting!' Exit(1) if not conf.CheckCHeader('SDL/SDL.h'): print 'SDL/SDL.h must be installed!' Exit(1) pavo = conf.Finish() pavo.Append(CCFLAGS = "-DSIM_LCD") pavo.Append(LINKFLAGS = "-lSDL") pavo.Program('pavo',listFiles(pavo['CPPPATH'],'*.c')) if 'mknandflash' in COMMAND_LINE_TARGETS: mknandflash=Environment() mknandflash.Program('mknandflash','../tool/mknandflash.c',LIBS = ['confuse'] ) ================================================ FILE: tools/virtualmips/adm5120/adm5120.c ================================================ /* * Copyright (C) yajin 2008 * * This file is part of the virtualmips distribution. * See LICENSE file for terms of the license. * */ #define _GNU_SOURCE #include #include #include #include #include "utils.h" #include "adm5120.h" #include "mips.h" #include "vm.h" #include "cpu.h" #include "mips_exec.h" #include "debug.h" #include "vp_lock.h" int dev_sw_init (vm_instance_t * vm, char *name, m_pa_t paddr, m_uint32_t len); int dev_rom_init (vm_instance_t * vm, char *name); int dev_nor_flash_4m_init (vm_instance_t * vm, char *name); int dev_mpmc_init (vm_instance_t * vm, char *name, m_pa_t paddr, m_uint32_t len); int dev_intctrl_init (vm_instance_t * vm, char *name, m_pa_t paddr, m_uint32_t len); int dev_uart_init (vm_instance_t * vm, char *name, m_pa_t paddr, m_uint32_t len, vtty_t * vtty, int uart_index); int dev_pci_init (vm_instance_t * vm, char *name, m_pa_t paddr, m_uint32_t len); /* Initialize default parameters for a adm5120 */ static void adm5120_init_defaults (adm5120_t * adm5120) { vm_instance_t *vm = adm5120->vm; if (vm->configure_filename == NULL) vm->configure_filename = strdup (ADM5120_DEFAULT_CONFIG_FILE); vm->ram_size = ADM5120_DEFAULT_RAM_SIZE; vm->boot_method = ADM5120_DEFAULT_BOOT_METHOD; vm->kernel_filename = strdup (ADM5120_DEFAULT_KERNEL_FILENAME); } /* Initialize the adm5120 Platform (MIPS) */ static int adm5120_init_platform (adm5120_t * adm5120) { struct vm_instance *vm = adm5120->vm; cpu_mips_t *cpu0; void *(*cpu_run_fn) (void *); vm_init_vtty (vm); /* Create a CPU group */ vm->cpu_group = cpu_group_create ("System CPU"); /* Initialize the virtual MIPS processor */ if (!(cpu0 = cpu_create (vm, CPU_TYPE_MIPS32, 0))) { vm_error (vm, "unable to create CPU0!\n"); return (-1); } /* Add this CPU to the system CPU group */ cpu_group_add (vm->cpu_group, cpu0); vm->boot_cpu = cpu0; cpu_run_fn = (void *) mips_exec_run_cpu; /* create the CPU thread execution */ if (pthread_create (&cpu0->cpu_thread, NULL, cpu_run_fn, cpu0) != 0) { fprintf (stderr, "cpu_create: unable to create thread for CPU%u\n", 0); free (cpu0); return (-1); } cpu0->addr_bus_mask = ADM5120_ADDR_BUS_MASK; /* Initialize RAM */ vm_ram_init (vm, 0x00000000ULL); /* Initialize ROM */ /*if (vm->rom_size!=0) * { * if (dev_rom_init(vm, "ROM")==-1) * return (-1); * } */ /* Initialize FLASH */ if ((vm->flash_size != 0) && (vm->flash_type == FLASH_TYPE_NOR_FLASH)) if (dev_nor_flash_4m_init (vm, "NORFLASH4M") == -1) return (-1); if (dev_sw_init (vm, "SW", ADM5120_SWCTRL_BASE, SW_INDEX_MAX * 4) == -1) return (-1); if (dev_mpmc_init (vm, "MPMC", ADM5120_MPMC_BASE, MPMC_INDEX_MAX * 4) == -1) return (-1); if (dev_intctrl_init (vm, "INT CTRL", ADM5120_INTC_BASE, INTCTRL_INDEX_MAX * 4) == -1) return (-1); if (dev_uart_init (vm, "UART 0", ADM5120_UART0_BASE, 0x24, vm->vtty_con1, 0) == -1) return (-1); if (dev_uart_init (vm, "UART 1", ADM5120_UART1_BASE, 0x24, vm->vtty_con2, 0) == -1) return (-1); if (dev_pci_init (vm, "PCI", ADM5120_PCI_BASE, PCI_INDEX_MAX * 4) == -1) return (-1); return (0); } extern m_uint32_t sw_table[SW_INDEX_MAX]; /*set adm5120 reg default value. Only needed if boot from linux elf image. Linux will query sw_table[0x7] to get sdram size. */ static void adm5120_reg_default_value (adm5120_t * adm5120) { if (adm5120->vm->ram_size == 128) sw_table[0x7] = 0x50405; // 128M else if (adm5120->vm->ram_size == 64) sw_table[0x7] = 0x50404; // 64m else if (adm5120->vm->ram_size == 32) sw_table[0x7] = 0x50423; //16M *2 else if (adm5120->vm->ram_size == 16) sw_table[0x7] = 0x50403; //16M else if (adm5120->vm->ram_size == 8) sw_table[0x7] = 0x50402; // 8M else if (adm5120->vm->ram_size == 4) sw_table[0x7] = 0x50401; // 4M else ASSERT (0, "Invalid ram_size.\n Valid value:4,8,16,32,64,128\n"); } static int adm5120_boot (adm5120_t * adm5120) { vm_instance_t *vm = adm5120->vm; cpu_mips_t *cpu; m_va_t kernel_entry_point; if (!vm->boot_cpu) return (-1); vm_suspend (vm); /* Check that CPU activity is really suspended */ if (cpu_group_sync_state (vm->cpu_group) == -1) { vm_error (vm, "unable to sync with system CPUs.\n"); return (-1); } /* Reset the boot CPU */ cpu = (vm->boot_cpu); mips_reset (cpu); /*set configure register */ cpu->cp0.config_usable = 0x3; /*only configure sel 0 and 1 is valid */ cpu->cp0.config_reg[0] = ADM5120_CONFIG0; cpu->cp0.config_reg[1] = ADM5120_CONFIG1; /*set PC and PRID */ cpu->cp0.reg[MIPS_CP0_PRID] = ADM5120_PRID; cpu->cp0.tlb_entries = ADM5120_DEFAULT_TLB_ENTRYNO; cpu->pc = ADM5120_ROM_PC; /*If we boot from elf kernel image, load the image and set pc to elf entry */ if (vm->boot_method == BOOT_ELF) { if (mips_load_elf_image (cpu, vm->kernel_filename, &kernel_entry_point) == -1) return (-1); adm5120_reg_default_value (adm5120); cpu->pc = kernel_entry_point; } /* Launch the simulation */ printf ("\nADM5120 '%s': starting simulation (CPU0 PC=0x%" LL "x), " "JIT %sabled.\n", vm->name, cpu->pc, vm->jit_use ? "en" : "dis"); vm->status = VM_STATUS_RUNNING; cpu_start (vm->boot_cpu); return (0); } extern m_uint32_t intctrl_table[INTCTRL_INDEX_MAX]; /* Mapping adm irq to mips irq. So why we need a mapping of interrupts? IN ADM5120,there are 10 interrupts 0 Timer 1 Uart 0 2 Uart 1 3 USB Host 4 External I/O 0 5 External I/O 1 6 PCI 0 7 PCI 1 8 PCI 2 9 Switch ADM5120 will triger INTERRUPT 2 and 3 to MIPS. INT_M(0X14) register control the interrupt releation of ADM5120 and iqr/firq. */ int adm_irq2mips_irq (vm_instance_t * vm, u_int irq) { m_uint32_t int_bit_mask = 0; int_bit_mask = 1 << irq; if ((intctrl_table[IRQ_MODE_REG / 4] & int_bit_mask) == int_bit_mask) { return ADM5120_MIPSINT_FIQ; } else return ADM5120_MIPSINT_IRQ; } int whether_irq_enable (vm_instance_t * vm, u_int irq) { m_uint32_t int_bit_mask = 0; int_bit_mask = 1 << irq; if ((intctrl_table[IRQ_ENABLE_REG / 4] & int_bit_mask) == int_bit_mask) { return TRUE; } else return FALSE; } void adm5120_clear_irq (vm_instance_t * vm, u_int irq) { assert (irq <= INT_LVL_MAX); int mips_irq_no; m_uint32_t int_bit_mask = 0; int_bit_mask = 1 << irq; /*clear raw status */ intctrl_table[IRQ_RAW_STATUS_REG / 4] &= ~int_bit_mask; mips_irq_no = adm_irq2mips_irq (vm, irq); if (ADM5120_MIPSINT_FIQ == mips_irq_no) { intctrl_table[FIQ_STATUS_REG / 4] &= ~int_bit_mask; } else { intctrl_table[IRQ_STATUS_REG / 4] &= ~int_bit_mask; } irq = mips_irq_no; mips_clear_irq (vm->boot_cpu, irq); } /*We must map adm irq to mips irq before setting irq*/ void adm5120_set_irq (vm_instance_t * vm, u_int irq) { assert (irq <= INT_LVL_MAX); int mips_irq_no; m_uint32_t int_bit_mask = 0; int_bit_mask = 1 << irq; /*set raw status */ intctrl_table[IRQ_RAW_STATUS_REG / 4] |= int_bit_mask; /*check whether irq is enabled */ if (whether_irq_enable (vm, irq) == FALSE) return; mips_irq_no = adm_irq2mips_irq (vm, irq); if (ADM5120_MIPSINT_FIQ == mips_irq_no) { intctrl_table[FIQ_STATUS_REG / 4] |= int_bit_mask; } else { intctrl_table[IRQ_STATUS_REG / 4] |= int_bit_mask; } irq = mips_irq_no; mips_set_irq (vm->boot_cpu, irq); mips_update_irq_flag (vm->boot_cpu); } COMMON_CONFIG_INFO_ARRAY static void printf_configure (adm5120_t * adm5120) { vm_instance_t *vm = adm5120->vm; PRINT_COMMON_CONFIG_OPTION; } static void adm5120_parse_configure (adm5120_t * adm5120) { vm_instance_t *vm = adm5120->vm; cfg_opt_t opts[] = { COMMON_CONFIG_OPTION CFG_END () }; cfg_t *cfg; cfg = cfg_init (opts, 0); cfg_parse (cfg, vm->configure_filename); cfg_free (cfg); VALID_COMMON_CONFIG_OPTION; if (vm->boot_method == BOOT_BINARY) { ASSERT (vm->boot_from == 1, "boot_from must be 1(NOR Flash)\n ADM5120 only can boot from NOR Flash.\n"); } /*Print the configure information */ printf_configure (adm5120); } /* Create a router instance */ vm_instance_t *create_instance (char *configure_filename) { adm5120_t *adm5120; char *name; if (!(adm5120 = malloc (sizeof (*adm5120)))) { fprintf (stderr, "ADM5120': Unable to create new instance!\n"); return NULL; } memset (adm5120, 0, sizeof (*adm5120)); name = strdup ("adm5120"); if (!(adm5120->vm = vm_create (name, VM_TYPE_ADM5120))) { fprintf (stderr, "ADM5120 : unable to create VM instance!\n"); goto err_vm; } free (name); if (configure_filename != NULL) adm5120->vm->configure_filename = strdup (configure_filename); adm5120_init_defaults (adm5120); adm5120_parse_configure (adm5120); /*init gdb debug */ vm_debug_init (adm5120->vm); adm5120->vm->hw_data = adm5120; return (adm5120->vm); err_vm: free (adm5120); return NULL; } int init_instance (vm_instance_t * vm) { adm5120_t *adm5120 = VM_ADM5120 (vm); if (adm5120_init_platform (adm5120) == -1) { vm_error (vm, "unable to initialize the platform hardware.\n"); return (-1); } /* IRQ routing */ vm->set_irq = adm5120_set_irq; vm->clear_irq = adm5120_clear_irq; return (adm5120_boot (adm5120)); } ================================================ FILE: tools/virtualmips/adm5120/adm5120.conf ================================================ #configure file for adm5120 # RAM size in kbytes. If not set, default value is 16384. ram_size = 16384 #There are two methods for virtualmips to boot the image. #Binary. It means virtualmips direct boots the image from ROM or flash. The entry pc is 0x1fc00000. The image contains bootloader and kernel/rootfs. #ELF. It means virtualmips reads an elf image(setten by kernel_file_name) into sdram and then boots from elf entry point. The elf image contains kernel and rootfs. #Default boot method is ELF. #1:Binary 2:elf boot_method = 2 #boot_from MUST be set if boot_method=1. #1:NOR_FLASH 2 NAND FLASH boot_from = 1 #If boot_method is elf, that means boot the elf image.kernel_file_name gives the elf image path. #kernel_file_name MUST be set if boot_method=2. kernel_file_name = "vmlinux-adm5120" #1 NOR 2 NAND flash_type = 1 #Flash size. 4 and 0 is valid for NOR type flash. 0 means no flash emulation. 4 means 4M bytes flash(device id=22F9h) emulation. flash_size = 4 #Flash file path. If this file does not exist, virtualmips will create it. flash_file_name = "run.bin" #flash physical address. for nor flash only flash_phy_address = 0x1fc00000 #set to 1 to enable gdb debug gdb_debug = 0 #the port for remote gdb connection gdb_port = 5555 ================================================ FILE: tools/virtualmips/adm5120/adm5120.h ================================================ /* * Copyright (C) yajin 2008 * * This file is part of the virtualmips distribution. * See LICENSE file for terms of the license. * */ #ifndef __ADM5120_H__ #define __ADM5120_H__ #include "types.h" /*virtual address and physical address*/ typedef m_uint32_t m_va_t; typedef m_uint32_t m_pa_t; typedef m_uint32_t m_reg_t; typedef m_int32_t m_ireg_t; typedef m_uint32_t m_cp0_reg_t; #define DATA_WIDTH 32 /*64 */ #define LL /*ADM5120 use soft fpu*/ #define SOFT_FPU 1 /*Guest endian*/ #define GUEST_BYTE_ORDER ARCH_LITTLE_ENDIAN #ifndef GUEST_BYTE_ORDER #error Please define guest architecture in utils.h! #endif /* Host to VM conversion functions */ #if HOST_BYTE_ORDER == GUEST_BYTE_ORDER #define htovm16(x) (x) #define htovm32(x) (x) #define htovm64(x) (x) #define vmtoh16(x) (x) #define vmtoh32(x) (x) #define vmtoh64(x) (x) #elif HOST_BYTE_ORDER==ARCH_LITTLE_ENDIAN //host:little guest:big #define htovm16(x) (htons(x)) #define htovm32(x) (htonl(x)) #define htovm64(x) (swap64(x)) #define vmtoh16(x) (ntohs(x)) #define vmtoh32(x) (ntohl(x)) #define vmtoh64(x) (swap64(x)) #else //host:big guest:little #define htovm16(x) (ntohs(x)) #define htovm32(x) (ntohl(x)) #define htovm64(x) (swap64(x)) #define vmtoh16(x) (htons(x)) #define vmtoh32(x) (htonl(x)) #define vmtoh64(x) (swap64(x)) #endif #define ADM5120_DEFAULT_CONFIG_FILE "adm5120.conf" #define ADM5120_DEFAULT_RAM_SIZE 16 #define ADM5120_DEFAULT_BOOT_METHOD BOOT_ELF #define ADM5120_DEFAULT_KERNEL_FILENAME "vmlinux" #define ADM5120_ADDR_BUS_MASK 0xffffffff /*32bit phy address */ #define ADM5120_CONFIG0 0x80000082 #define ADM5120_CONFIG1 0x3E613080 /*CACHE (128SET*32 BYTES*2 WAY)= 8K */ //#define ADM5120_CONFIG7 0x0 //#define SOC_CONFIG0 ADM5120_CONFIG0 //#define SOC_CONFIG1 ADM5120_CONFIG1 //#define SOC_CONFIG7 ADM5120_CONFIG7 #define ADM5120_ROM_PC 0xbfc00000UL #define ADM5120_PRID 0x0001800b #define ADM5120_DEFAULT_TLB_ENTRYNO 16 struct adm5120_system { /* Associated VM instance */ vm_instance_t *vm; }; typedef struct adm5120_system adm5120_t; #define VM_ADM5120(vm) ((adm5120_t *)vm->hw_data) vm_instance_t *create_instance (char *conf); int init_instance (vm_instance_t * vm); //void virtual_timer(cpu_mips_t *cpu); /*---------ADM5120 SOC releated--------------------*/ /*========================= Physical Memory Map ============================*/ #define ADM5120_SDRAM_BASE 0 #define ADM5120_SMEM1_BASE 0x10000000 #define ADM5120_EXTIO0_BASE 0x10C00000 #define ADM5120_EXTIO1_BASE 0x10E00000 #define ADM5120_MPMC_BASE 0x11000000 #define ADM5120_USBHOST_BASE 0x11200000 #define ADM5120_PCIMEM_BASE 0x11400000 #define ADM5120_PCIIO_BASE 0x11500000 #define ADM5120_PCICFG_BASE 0x115FFFF0 #define ADM5120_MIPS_BASE 0x11A00000 #define ADM5120_SWCTRL_BASE 0x12000000 #define ADM5120_INTC_BASE 0x12200000 #define ADM5120_SYSC_BASE 0x12400000 #define ADM5120_UART0_BASE 0x12600000 #define ADM5120_UART1_BASE 0x12800000 #define ADM5120_SMEM0_BASE 0x1FC00000 /*========================= Switch Control Register ========================*/ /* Control Register */ #define CODE_REG 0x0000 #define SftRest_REG 0x0004 #define Boot_done_REG 0x0008 #define SWReset_REG 0x000C #define Global_St_REG 0x0010 #define PHY_st_REG 0x0014 #define Port_st_REG 0x0018 #define Mem_control_REG 0x001C #define SW_conf_REG 0x0020 #define CPUp_conf_REG 0x0024 #define Port_conf0_REG 0x0028 #define Port_conf1_REG 0x002C #define Port_conf2_REG 0x0030 #define VLAN_G1_REG 0x0040 #define VLAN_G2_REG 0x0044 #define Send_trig_REG 0x0048 #define Srch_cmd_REG 0x004C #define ADDR_st0_REG 0x0050 #define ADDR_st1_REG 0x0054 #define MAC_wt0_REG 0x0058 #define MAC_wt1_REG 0x005C #define BW_cntl0_REG 0x0060 #define BW_cntl1_REG 0x0064 #define PHY_cntl0_REG 0x0068 #define PHY_cntl1_REG 0x006C #define FC_th_REG 0x0070 #define Adj_port_th_REG 0x0074 #define Port_th_REG 0x0078 #define PHY_cntl2_REG 0x007C #define PHY_cntl3_REG 0x0080 #define Pri_cntl_REG 0x0084 #define VLAN_pri_REG 0x0088 #define TOS_en_REG 0x008C #define TOS_map0_REG 0x0090 #define TOS_map1_REG 0x0094 #define Custom_pri1_REG 0x0098 #define Custom_pri2_REG 0x009C #define PHY_cntl4_REG 0x00A0 #define Empty_cnt_REG 0x00A4 #define Port_cnt_sel_REG 0x00A8 #define Port_cnt_REG 0x00AC #define SW_Int_st_REG 0x00B0 #define SW_Int_mask_REG 0x00B4 // GPIO config #define GPIO_conf0_REG 0x00B8 #define GPIO_conf2_REG 0x00BC // Watch dog #define Watchdog0_REG 0x00C0 #define Watchdog1_REG 0x00C4 #define Swap_in_REG 0x00C8 #define Swap_out_REG 0x00CC // Tx/Rx Descriptors #define Send_HBaddr_REG 0x00D0 #define Send_LBaddr_REG 0x00D4 #define Recv_HBaddr_REG 0x00D8 #define Recv_LBaddr_REG 0x00DC #define Send_HWaddr_REG 0x00E0 #define Send_LWaddr_REG 0x00E4 #define Recv_HWaddr_REG 0x00E8 #define Recv_LWaddr_REG 0x00EC // Timer Control #define Timer_int_REG 0x00F0 #define Timer_REG 0x00F4 // LED control #define Port0_LED_REG 0x0100 #define Port1_LED_REG 0x0104 #define Port2_LED_REG 0x0108 #define Port3_LED_REG 0x010c #define Port4_LED_REG 0x0110 #define SW_INDEX_MAX 0x45 //0x0114/4 /* Timer_int_REG */ #define SW_TIMER_INT_DISABLE 0x10000 #define SW_TIMER_INT 0x1 /* Timer_REG */ #define SW_TIMER_EN 0x10000 #define SW_TIMER_MASK 0xffff #define SW_TIMER_10MS_TICKS 0x3D09 #define SW_TIMER_1MS_TICKS 0x61A #define SW_TIMER_100US_TICKS 0x9D /*==================== MultiPort Memory Controller (MPMC) ==================*/ /* registers offset */ #define MPMC_CONTROL_REG 0x0000 #define MPMC_STATUS_REG 0x0004 #define MPMC_CONFIG_REG 0x0008 #define MPMC_DM_CONTROL_REG 0x0020 #define MPMC_DM_REFRESH_REG 0x0024 #define MPMC_DM_TRP_REG 0x0030 #define MPMC_DM_TRAS_REG 0x0034 #define MPMC_DM_TSREX_REG 0x0038 #define MPMC_DM_TAPR_REG 0x003C #define MPMC_DM_TDAL_REG 0x0040 #define MPMC_DM_TWR_REG 0x0044 #define MPMC_DM_TRC_REG 0x0048 #define MPMC_DM_TRFC_REG 0x004C #define MPMC_DM_TXSR_REG 0x0050 #define MPMC_DM_TRRD_REG 0x0054 #define MPMC_DM_TMRD_REG 0x0058 #define MPMC_SM_EXTWAIT_REG 0x0080 #define MPMC_DM_CONFIG0_REG 0x0100 #define MPMC_DM_RASCAS0_REG 0x0104 #define MPMC_DM_CONFIG1_REG 0x0120 #define MPMC_DM_RASCAS1_REG 0x0124 #define MPMC_SM_CONFIG0_REG 0x0200 #define MPMC_SM_WAITWEN0_REG 0x0204 #define MPMC_SM_WAITOEN0_REG 0x0208 #define MPMC_SM_WAITRD0_REG 0x020C #define MPMC_SM_WAITPAGE0_REG 0x0210 #define MPMC_SM_WAITWR0_REG 0x0214 #define MPMC_SM_WAITTURN0_REG 0x0218 #define MPMC_SM_CONFIG1_REG 0x0220 #define MPMC_SM_WAITWEN1_REG 0x0224 #define MPMC_SM_WAITOEN1_REG 0x0228 #define MPMC_SM_WAITRD1_REG 0x022C #define MPMC_SM_WAITPAGE1_REG 0x0230 #define MPMC_SM_WAITWR1_REG 0x0234 #define MPMC_SM_WAITTURN1_REG 0x0238 #define MPMC_SM_CONFIG2_REG 0x0240 #define MPMC_SM_WAITWEN2_REG 0x0244 #define MPMC_SM_WAITOEN2_REG 0x0248 #define MPMC_SM_WAITRD2_REG 0x024C #define MPMC_SM_WAITPAGE2_REG 0x0250 #define MPMC_SM_WAITWR2_REG 0x0254 #define MPMC_SM_WAITTURN2_REG 0x0258 #define MPMC_SM_CONFIG3_REG 0x0260 #define MPMC_SM_WAITWEN3_REG 0x0264 #define MPMC_SM_WAITOEN3_REG 0x0268 #define MPMC_SM_WAITRD3_REG 0x026C #define MPMC_SM_WAITPAGE3_REG 0x0270 #define MPMC_SM_WAITWR3_REG 0x0274 #define MPMC_SM_WAITTURN3_REG 0x0278 #define MPMC_INDEX_MAX 0x9f //0x027C/4 /*=========================== UART Control Register ========================*/ #define UART_DR_REG 0x00 #define UART_RSR_REG 0x04 #define UART_ECR_REG 0x04 #define UART_LCR_H_REG 0x08 #define UART_LCR_M_REG 0x0c #define UART_LCR_L_REG 0x10 #define UART_CR_REG 0x14 #define UART_FR_REG 0x18 #define UART_IIR_REG 0x1c #define UART_ICR_REG 0x1C #define UART_ILPR_REG 0x20 /* rsr/ecr reg */ #define UART_OVERRUN_ERR 0x08 #define UART_BREAK_ERR 0x04 #define UART_PARITY_ERR 0x02 #define UART_FRAMING_ERR 0x01 #define UART_RX_STATUS_MASK 0x0f #define UART_RX_ERROR ( UART_BREAK_ERR \ | UART_PARITY_ERR \ | UART_FRAMING_ERR) /* lcr_h reg */ #define UART_SEND_BREAK 0x01 #define UART_PARITY_EN 0x02 #define UART_EVEN_PARITY 0x04 #define UART_TWO_STOP_BITS 0x08 #define UART_ENABLE_FIFO 0x10 #define UART_WLEN_5BITS 0x00 #define UART_WLEN_6BITS 0x20 #define UART_WLEN_7BITS 0x40 #define UART_WLEN_8BITS 0x60 #define UART_WLEN_MASK 0x60 /* cr reg */ #define UART_PORT_EN 0x01 #define UART_SIREN 0x02 #define UART_SIRLP 0x04 #define UART_MODEM_STATUS_INT_EN 0x08 #define UART_RX_INT_EN 0x10 #define UART_TX_INT_EN 0x20 #define UART_RX_TIMEOUT_INT_EN 0x40 #define UART_LOOPBACK_EN 0x80 /* fr reg */ #define UART_CTS 0x01 #define UART_DSR 0x02 #define UART_DCD 0x04 #define UART_BUSY 0x08 #define UART_RX_FIFO_EMPTY 0x10 #define UART_TX_FIFO_FULL 0x20 #define UART_RX_FIFO_FULL 0x40 #define UART_TX_FIFO_EMPTY 0x80 /* iir/icr reg */ #define UART_MODEM_STATUS_INT 0x01 #define UART_RX_INT 0x02 #define UART_TX_INT 0x04 #define UART_RX_TIMEOUT_INT 0x08 #define UART_INT_MASK 0x0f #define ADM5120_UARTCLK_FREQ 62500000 /* uart_baudrate */ #define UART_230400bps_DIVISOR UART_BAUDDIV(230400) // #define UART_115200bps_DIVISOR UART_BAUDDIV(115200) #define UART_115200bps_DIVISOR 33 // #define UART_76800bps_DIVISOR UART_BAUDDIV(76800) #define UART_76800bps_DIVISOR 50 // #define UART_57600bps_DIVISOR UART_BAUDDIV(57600) #define UART_57600bps_DIVISOR 67 //#define UART_38400bps_DIVISOR UART_BAUDDIV(38400) #define UART_38400bps_DIVISOR 102 //#define UART_19200bps_DIVISOR UART_BAUDDIV(19200) #define UART_19200bps_DIVISOR 202 //#define UART_14400bps_DIVISOR UART_BAUDDIV(14400) #define UART_14400bps_DIVISOR 270 //#define UART_9600bps_DIVISOR UART_BAUDDIV(9600) #define UART_9600bps_DIVISOR 406 //#define UART_2400bps_DIVISOR UART_BAUDDIV(2400) #define UART_2400bps_DIVISOR 1627 //#define UART_1200bps_DIVISOR UART_BAUDDIV(1200) #define UART_INDEX_MAX 0x9 //0x024/4 /* pci space pci memory 0x1140 0000- 0x114f ffff pci io 0x1150 0000 - 0x 115f ffef pci configuration address port 0x115ffff0 pci configuration data port 0x115ffff8 */ #define ADM5120_PCI_BASE 0x11400000 #define PCI_INDEX_MAX 0X80000 //0X200000/4 /*========================== Interrupt Controller ==========================*/ /* registers offset */ #define IRQ_STATUS_REG 0x00 /* Read */ #define IRQ_RAW_STATUS_REG 0x04 /* Read */ #define IRQ_ENABLE_REG 0x08 /* Read/Write */ #define IRQ_DISABLE_REG 0x0C /* Write */ #define IRQ_SOFT_REG 0x10 /* Write */ #define IRQ_MODE_REG 0x14 /* Read/Write */ #define FIQ_STATUS_REG 0x18 /* Read */ /* test registers */ #define IRQ_TESTSRC_REG 0x1c /* Read/Write */ #define IRQ_SRCSEL_REG 0x20 /* Read/Write */ #define IRQ_LEVEL_REG 0x24 /* Read/Write */ #define INTCTRL_INDEX_MAX 0xa //0x028/4 /* interrupt levels */ #define INT_LVL_TIMER 0 /* Timer */ #define INT_LVL_UART0 1 /* Uart 0 */ #define INT_LVL_UART1 2 /* Uart 1 */ #define INT_LVL_USBHOST 3 /* USB Host */ #define INT_LVL_EXTIO_0 4 /* External I/O 0 */ #define INT_LVL_EXTIO_1 5 /* External I/O 1 */ #define INT_LVL_PCI_0 6 /* PCI 0 */ #define INT_LVL_PCI_1 7 /* PCI 1 */ #define INT_LVL_PCI_2 8 /* PCI 2 */ #define INT_LVL_SWITCH 9 /* Switch */ #define INT_LVL_MAX INT_LVL_SWITCH /* interrupts */ #define IRQ_TIMER (0x1 << INT_LVL_TIMER) #define IRQ_UART0 (0x1 << INT_LVL_UART0) #define IRQ_UART1 (0x1 << INT_LVL_UART1) #define IRQ_USBHOST (0x1 << INT_LVL_USBHOST) #define IRQ_EXTIO_0 (0x1 << INT_LVL_EXTIO_0) #define IRQ_EXTIO_1 (0x1 << INT_LVL_EXTIO_1) #define IRQ_PCI_INT0 (0x1 << INT_LVL_PCI_0) #define IRQ_PCI_INT1 (0x1 << INT_LVL_PCI_1) #define IRQ_PCI_INT2 (0x1 << INT_LVL_PCI_2) #define IRQ_SWITCH (0x1 << INT_LVL_SWITCH) #define IRQ_MASK 0x3ff #define ADM5120_MIPSINT_SOFT0 0 #define ADM5120_MIPSINT_SOFT1 1 #define ADM5120_MIPSINT_IRQ 2 #define ADM5120_MIPSINT_FIQ 3 #define ADM5120_MIPSINT_REV0 4 #define ADM5120_MIPSINT_REV1 5 #define ADM5120_MIPSINT_REV2 6 #define ADM5120_MIPSINT_TIMER 7 #endif ================================================ FILE: tools/virtualmips/adm5120/adm5120_dev_intctrl.c ================================================ /* * Copyright (C) yajin 2008 * * This file is part of the virtualmips distribution. * See LICENSE file for terms of the license. * */ #define _GNU_SOURCE #include #include #include #include #include #include #include "device.h" #include "mips_memory.h" #include "adm5120.h" #include "cpu.h" m_uint32_t intctrl_table[INTCTRL_INDEX_MAX]; struct intctrl_data { struct vdevice *dev; m_uint8_t *intctrl_ptr; m_uint32_t intctrl_size; }; void *dev_intctrl_access (cpu_mips_t * cpu, struct vdevice *dev, m_uint32_t offset, u_int op_size, u_int op_type, m_reg_t * data, m_uint8_t * has_set_value) { struct intctrl_data *d = dev->priv_data; if (offset >= d->intctrl_size) { *data = 0; return NULL; } switch (offset) { case IRQ_DISABLE_REG: if (MTS_WRITE == op_type) { intctrl_table[IRQ_ENABLE_REG / 4] = *data & 0x3ff; *has_set_value = TRUE; return NULL; } break; } return ((void *) (d->intctrl_ptr + offset)); } void dev_intctrl_init_defaultvalue () { } int dev_intctrl_init (vm_instance_t * vm, char *name, m_pa_t paddr, m_uint32_t len) { struct intctrl_data *d; /* allocate the private data structure */ if (!(d = malloc (sizeof (*d)))) { fprintf (stderr, "INTCTRL: unable to create device.\n"); return (-1); } memset (d, 0, sizeof (*d)); if (!(d->dev = dev_create (name))) goto err_dev_create; d->dev->priv_data = d; d->dev->phys_addr = paddr; d->dev->phys_len = len; d->intctrl_ptr = (m_uint8_t *) (m_iptr_t) (&intctrl_table[0]); d->intctrl_size = len; d->dev->handler = dev_intctrl_access; d->dev->flags = VDEVICE_FLAG_NO_MTS_MMAP; vm_bind_device (vm, d->dev); dev_intctrl_init_defaultvalue (); return (0); err_dev_create: free (d); return (-1); } ================================================ FILE: tools/virtualmips/adm5120/adm5120_dev_mpmc.c ================================================ /* * Copyright (C) yajin 2008 * * This file is part of the virtualmips distribution. * See LICENSE file for terms of the license. * */ #define _GNU_SOURCE #include #include #include #include #include #include #include "device.h" #include "memory.h" #include "adm5120.h" #include "cpu.h" m_uint32_t mpmc_table[MPMC_INDEX_MAX]; struct mpmc_data { struct vdevice *dev; m_uint8_t *mpmc_ptr; m_uint32_t mpmc_size; }; void *dev_mpmc_access (cpu_mips_t * cpu, struct vdevice *dev, m_uint32_t offset, u_int op_size, u_int op_type, m_reg_t * data, m_uint8_t * has_set_value) { struct mpmc_data *d = dev->priv_data; if (offset >= d->mpmc_size) { *data = 0; return NULL; } return ((void *) (d->mpmc_ptr + offset)); } void dev_mpmc_init_defaultvalue () { } int dev_mpmc_init (vm_instance_t * vm, char *name, m_pa_t paddr, m_uint32_t len) { struct mpmc_data *d; /* allocate the private data structure */ if (!(d = malloc (sizeof (*d)))) { fprintf (stderr, "MPMC: unable to create device.\n"); return (-1); } memset (d, 0, sizeof (*d)); if (!(d->dev = dev_create (name))) goto err_dev_create; d->dev->priv_data = d; d->dev->phys_addr = paddr; d->dev->phys_len = len; d->mpmc_ptr = (m_uint8_t *) (m_iptr_t) (&mpmc_table[0]); d->mpmc_size = len; d->dev->handler = dev_mpmc_access; d->dev->flags = VDEVICE_FLAG_NO_MTS_MMAP; vm_bind_device (vm, d->dev); dev_mpmc_init_defaultvalue (); return (0); err_dev_create: free (d); return (-1); } ================================================ FILE: tools/virtualmips/adm5120/adm5120_dev_pci.c ================================================ /* * Copyright (C) yajin 2008 * * This file is part of the virtualmips distribution. * See LICENSE file for terms of the license. * */ #define _GNU_SOURCE #include #include #include #include #include #include #include "device.h" #include "memory.h" #include "adm5120.h" #include "cpu.h" m_uint32_t pci_table[PCI_INDEX_MAX]; struct pci_data { struct vdevice *dev; m_uint8_t *pci_ptr; m_uint32_t pci_size; }; void *dev_pci_access (cpu_mips_t * cpu, struct vdevice *dev, m_uint32_t offset, u_int op_size, u_int op_type, m_reg_t * data, m_uint8_t * has_set_value) { struct pci_data *d = dev->priv_data; if (offset >= d->pci_size) { *data = 0; return NULL; } return ((void *) (d->pci_ptr + offset)); } void dev_pci_init_defaultvalue () { } int dev_pci_init (vm_instance_t * vm, char *name, m_pa_t paddr, m_uint32_t len) { struct pci_data *d; /* allocate the private data structure */ if (!(d = malloc (sizeof (*d)))) { fprintf (stderr, "PCI: unable to create device.\n"); return (-1); } memset (d, 0, sizeof (*d)); if (!(d->dev = dev_create (name))) goto err_dev_create; d->dev->priv_data = d; d->dev->phys_addr = paddr; d->dev->phys_len = len; d->pci_ptr = (m_uint8_t *) (m_iptr_t) (&pci_table[0]); d->pci_size = len; d->dev->handler = dev_pci_access; d->dev->flags = VDEVICE_FLAG_NO_MTS_MMAP; vm_bind_device (vm, d->dev); dev_pci_init_defaultvalue (); return (0); err_dev_create: free (d); return (-1); } ================================================ FILE: tools/virtualmips/adm5120/adm5120_dev_sw.c ================================================ /* * Copyright (C) yajin 2008 * * This file is part of the virtualmips distribution. * See LICENSE file for terms of the license. * */ #define _GNU_SOURCE #include #include #include #include #include #include #include "device.h" #include "mips_memory.h" #include "adm5120.h" #include "cpu.h" m_uint32_t sw_table[SW_INDEX_MAX]; struct sw_data { struct vdevice *dev; m_uint8_t *sw_ptr; m_uint32_t sw_size; }; extern int timeout; extern m_uint32_t time_reload; void *dev_sw_access (cpu_mips_t * cpu, struct vdevice *dev, m_uint32_t offset, u_int op_size, u_int op_type, m_reg_t * data, m_uint8_t * has_set_value) { struct sw_data *d = dev->priv_data; if (offset >= d->sw_size) { *data = 0; return NULL; } switch (offset) { case Timer_int_REG: if (op_type == MTS_WRITE) { if (*data & SW_TIMER_INT) { timeout = 0; } } else if (op_type == MTS_READ) { *data = sw_table[Timer_int_REG / 4] & (~SW_TIMER_INT); *data |= timeout; *has_set_value = TRUE; return NULL; } else assert (0); break; case Timer_REG: if (op_type == MTS_WRITE) { time_reload = *data & SW_TIMER_MASK; } break; } return ((void *) (d->sw_ptr + offset)); } void dev_sw_init_defaultvalue () { sw_table[CODE_REG / 4] = 0x34085120; sw_table[Timer_int_REG / 4] = 0x10000; sw_table[Timer_REG / 4] = 0xffff; } int dev_sw_init (vm_instance_t * vm, char *name, m_pa_t paddr, m_uint32_t len) { struct sw_data *d; /* allocate the private data structure */ if (!(d = malloc (sizeof (*d)))) { fprintf (stderr, "SW: unable to create device.\n"); return (-1); } memset (d, 0, sizeof (*d)); if (!(d->dev = dev_create (name))) goto err_dev_create; d->dev->priv_data = d; d->dev->phys_addr = paddr; d->dev->phys_len = len; d->sw_ptr = (m_uint8_t *) (m_iptr_t) (&sw_table[0]); d->sw_size = len; d->dev->handler = dev_sw_access; d->dev->flags = VDEVICE_FLAG_NO_MTS_MMAP; vm_bind_device (vm, d->dev); dev_sw_init_defaultvalue (); return (0); err_dev_create: free (d); return (-1); } ================================================ FILE: tools/virtualmips/adm5120/adm5120_dev_uart.c ================================================ /* * Copyright (C) yajin 2008 * * This file is part of the virtualmips distribution. * See LICENSE file for terms of the license. * */ #define _GNU_SOURCE #include #include #include #include #include #include #include "device.h" #include "mips_memory.h" #include "adm5120.h" #include "cpu.h" m_uint32_t uart_table[2][UART_INDEX_MAX]; struct uart_data { struct vdevice *dev; m_uint8_t *uart_ptr; m_uint32_t uart_size; vtty_t *vtty[2]; }; #define ADM5120_UART_IRQ0 1 #define ADM5120_UART_IRQ1 2 void uart_set_interrupt (cpu_mips_t * cpu, int channel) { if (channel == 0) cpu->vm->set_irq (cpu->vm, INT_LVL_UART0); else if (channel == 1) cpu->vm->set_irq (cpu->vm, INT_LVL_UART1); return; assert (0); } void uart_clear_interrupt (cpu_mips_t * cpu, int channel) { if (channel == 0) cpu->vm->clear_irq (cpu->vm, INT_LVL_UART0); else if (channel == 1) cpu->vm->clear_irq (cpu->vm, INT_LVL_UART1); return; assert (0); } /* Console port input */ static void tty_con0_input (vtty_t * vtty) { uart_table[0][UART_FR_REG / 4] &= ~UART_RX_FIFO_EMPTY; if (vtty_is_full (vtty)) uart_table[0][UART_FR_REG / 4] |= UART_RX_FIFO_FULL; if ((uart_table[0][UART_CR_REG / 4] & UART_RX_INT_EN) && (uart_table[0][UART_CR_REG / 4] & UART_PORT_EN)) { uart_table[0][UART_ICR_REG / 4] |= UART_RX_INT; uart_set_interrupt (vtty->vm->boot_cpu, 0); } } /* Console port input */ static void tty_con1_input (vtty_t * vtty) { uart_table[1][UART_FR_REG / 4] &= ~UART_RX_FIFO_EMPTY; if (vtty_is_full (vtty)) uart_table[1][UART_FR_REG / 4] |= UART_RX_FIFO_FULL; if ((uart_table[1][UART_CR_REG / 4] & UART_RX_INT_EN) && (uart_table[1][UART_CR_REG / 4] & UART_PORT_EN)) { uart_set_interrupt (vtty->vm->boot_cpu, 1); uart_table[1][UART_ICR_REG / 4] |= UART_RX_INT; } } void *dev_uart_access (cpu_mips_t * cpu, struct vdevice *dev, m_uint32_t offset, u_int op_size, u_int op_type, m_reg_t * data, m_uint8_t * has_set_value, m_uint8_t channel) { struct uart_data *d = dev->priv_data; if (offset >= d->uart_size) { *data = 0; return NULL; } switch (offset) { case (UART_DR_REG): if (!(uart_table[channel][UART_CR_REG / 4] & UART_PORT_EN)) { //uart port is disabled. if (op_type == MTS_READ) { *data = vmtoh32 (0xffffffff); } *has_set_value = TRUE; return NULL; } if (op_type == MTS_READ) { if (vtty_is_char_avail (d->vtty[channel])) { *data = vtty_get_char (d->vtty[channel]); uart_table[channel][UART_RSR_REG / 4] = 0; } else *data = vmtoh32 (0xffffffff); if (vtty_is_char_avail (d->vtty[channel])) { uart_table[channel][UART_FR_REG / 4] &= ~UART_RX_FIFO_EMPTY; uart_table[channel][UART_FR_REG / 4] |= UART_RX_FIFO_FULL; if ((uart_table[channel][UART_CR_REG / 4] & UART_RX_INT_EN) && (uart_table[channel][UART_CR_REG / 4] & UART_PORT_EN)) { uart_table[channel][UART_ICR_REG / 4] |= UART_RX_INT; uart_set_interrupt (cpu, channel); } } else { uart_table[channel][UART_FR_REG / 4] |= UART_RX_FIFO_EMPTY; uart_table[channel][UART_FR_REG / 4] &= ~UART_RX_FIFO_FULL; if ((uart_table[channel][UART_CR_REG / 4] & UART_RX_INT_EN) && (uart_table[channel][UART_CR_REG / 4] & UART_PORT_EN)) { uart_table[channel][UART_ICR_REG / 4] &= ~UART_RX_INT; uart_clear_interrupt (cpu, channel); } } *has_set_value = TRUE; } else if (op_type == MTS_WRITE) { vtty_put_char (d->vtty[channel], (char) *data); *has_set_value = TRUE; } else { assert (0); } return NULL; break; case UART_RSR_REG: if (op_type == MTS_WRITE) { uart_table[channel][UART_RSR_REG / 4] = 0; *has_set_value = TRUE; } break; case UART_CR_REG: if (op_type == MTS_WRITE) { //enable UART if ((*data) & UART_PORT_EN) { if (*data & UART_TX_INT_EN) { //START TX uart_table[channel][UART_ICR_REG / 4] |= UART_TX_INT; uart_set_interrupt (cpu, channel); } else { //TX interrupt dissabled uart_table[channel][UART_ICR_REG / 4] &= ~UART_TX_INT; uart_clear_interrupt (cpu, channel); } if (*data & UART_RX_INT_EN) { if (vtty_is_char_avail (d->vtty[channel])) { //set RX interrupt uart_table[channel][UART_ICR_REG / 4] |= UART_RX_INT; uart_set_interrupt (cpu, channel); } } else { //disable RX interrupt uart_table[channel][UART_ICR_REG / 4] &= ~UART_RX_INT; uart_clear_interrupt (cpu, channel); } } else { //disable UART //clear rx and tx interrupt uart_table[channel][UART_ICR_REG / 4] &= ~UART_TX_INT; uart_clear_interrupt (cpu, channel); uart_table[channel][UART_ICR_REG / 4] &= ~UART_RX_INT; uart_clear_interrupt (cpu, channel); } } break; } return ((void *) (d->uart_ptr + offset)); } void dev_uart_init_defaultvalue (int uart_index) { uart_table[uart_index][UART_FR_REG / 4] = 0x90; uart_table[uart_index][UART_RSR_REG / 4] = 0; } void *dev_uart_access0 (cpu_mips_t * cpu, struct vdevice *dev, m_uint32_t offset, u_int op_size, u_int op_type, m_reg_t * data, m_uint8_t * has_set_value) { return dev_uart_access (cpu, dev, offset, op_size, op_type, data, has_set_value, 0); } void *dev_uart_access1 (cpu_mips_t * cpu, struct vdevice *dev, m_uint32_t offset, u_int op_size, u_int op_type, m_reg_t * data, m_uint8_t * has_set_value) { return dev_uart_access (cpu, dev, offset, op_size, op_type, data, has_set_value, 1); } int dev_uart_init (vm_instance_t * vm, char *name, m_pa_t paddr, m_uint32_t len, vtty_t * vtty, int uart_index) { struct uart_data *d; /* allocate the private data structure */ if (!(d = malloc (sizeof (*d)))) { fprintf (stderr, "UART: unable to create device.\n"); return (-1); } memset (d, 0, sizeof (*d)); if (!(d->dev = dev_create (name))) goto err_dev_create; d->dev->priv_data = d; d->dev->phys_addr = paddr; d->dev->phys_len = len; d->dev->flags = VDEVICE_FLAG_NO_MTS_MMAP; (*d).vtty[uart_index] = vtty; d->uart_size = len; if (uart_index == 0) { d->dev->handler = dev_uart_access0; (*d).vtty[uart_index]->read_notifier = tty_con0_input; } else { d->dev->handler = dev_uart_access1; (*d).vtty[uart_index]->read_notifier = tty_con1_input; } d->uart_ptr = (m_uint8_t *) (m_iptr_t) (&uart_table[uart_index]); vm_bind_device (vm, d->dev); dev_uart_init_defaultvalue (uart_index); return (0); err_dev_create: free (d); return (-1); } ================================================ FILE: tools/virtualmips/adm5120/adm5120_host_alarm.c ================================================ /* * Copyright (C) yajin 2008 * * This file is part of the virtualmips distribution. * See LICENSE file for terms of the license. * */ #define _GNU_SOURCE #include #include #include #include #include #include #include "device.h" #include "adm5120.h" #include "mips.h" #define ADM_FREQ 175000000 /*175MHZ */ int instructions = 0; extern m_uint32_t sw_table[SW_INDEX_MAX]; #define MAX_INSTRUCTIONS 1 int timeout = 0; m_uint32_t time_reload; extern m_uint32_t uart_table[2][UART_INDEX_MAX]; extern cpu_mips_t *current_cpu; void uart_set_interrupt (cpu_mips_t * cpu, int channel); /*ADM5120 use host_alarm_handler to process all the things, This method is deprecated. JZ4740 uses a timer method, which is more flexible. See jz4740_host_alam.c */ void host_alarm_handler (int host_signum) { m_uint32_t tim; if (unlikely (current_cpu->state != CPU_STATE_RUNNING)) return; if ((uart_table[0][UART_CR_REG / 4] & UART_RX_INT_EN) && (uart_table[0][UART_CR_REG / 4] & UART_PORT_EN)) { if (vtty_is_char_avail (current_cpu->vm->vtty_con1)) { uart_set_interrupt (current_cpu, 0); uart_table[0][UART_ICR_REG / 4] |= UART_RX_INT; return; } } if (uart_table[0][UART_CR_REG / 4] & UART_PORT_EN) { if (uart_table[0][UART_CR_REG / 4] & UART_TX_INT_EN) { uart_table[0][UART_ICR_REG / 4] |= UART_TX_INT; uart_set_interrupt (current_cpu, 0); return; } } /*check count and compare */ /*Why 2*1000? CPU is 175MHZ, we assume CPI(cycle per instruction)=2 * see arch/mips/adm5120/setup.c for more information * 49 void __init mips_time_init(void) */ current_cpu->cp0.reg[MIPS_CP0_COUNT] += ADM_FREQ / (2 * 1000); if (current_cpu->cp0.reg[MIPS_CP0_COMPARE] != 0) { if (current_cpu->cp0.reg[MIPS_CP0_COUNT] >= current_cpu->cp0.reg[MIPS_CP0_COMPARE]) { mips_set_irq (current_cpu, MIPS_TIMER_INTERRUPT); mips_update_irq_flag (current_cpu); } } /*Linux kernel does not use this timer. It use mips count */ if (sw_table[Timer_REG / 4] & SW_TIMER_EN) { tim = sw_table[Timer_REG / 4] & SW_TIMER_MASK; if (tim == 0) { tim = time_reload; timeout = 1; } else tim -= 0x2000; /*1ms=2000*640ns.but 2000 is too slow. I set it to 0x2000 */ if ((m_int32_t) tim < 0x2000) tim = 0; sw_table[Timer_REG / 4] &= ~SW_TIMER_MASK; sw_table[Timer_REG / 4] += tim; } } ================================================ FILE: tools/virtualmips/bsd_syscalls.h ================================================ /* * System call switch table. */ static const struct { int narg; const char *name; } bsd_syscalls[] = { { 0, "#0" }, /* 0 = out-of-range */ { 1, "exit", }, /* 1 = exit */ { 0, "fork", }, /* 2 = fork */ { 3, "read", }, /* 3 = read */ { 3, "write", }, /* 4 = write */ { 3, "open", }, /* 5 = open */ { 1, "close", }, /* 6 = close */ { 4, "wait4", }, /* 7 = wait4 */ { 0, "#8", }, /* 8 = (old creat) */ { 2, "link", }, /* 9 = link */ { 1, "unlink", }, /* 10 = unlink */ { 2, "execv", }, /* 11 = execv */ { 1, "chdir", }, /* 12 = chdir */ { 1, "fchdir", }, /* 13 = fchdir */ { 3, "mknod", }, /* 14 = mknod */ { 2, "chmod", }, /* 15 = chmod */ { 3, "chown", }, /* 16 = chown; now 3 args */ { 2, "chflags", }, /* 17 = chflags */ { 2, "fchflags", }, /* 18 = fchflags */ { 4, "lseek", }, /* 19 = lseek */ { 0, "getpid", }, /* 20 = getpid */ { 3, "mount", }, /* 21 = mount */ { 1, "umount", }, /* 22 = umount */ { 6, "__sysctl", }, /* 23 = __sysctl */ { 0, "getuid", }, /* 24 = getuid */ { 0, "geteuid", }, /* 25 = geteuid */ { 4, "ptrace", }, /* 26 = ptrace */ { 0, "getppid", }, /* 27 = getppid */ { 2, "statfs", }, /* 28 = statfs */ { 2, "fstatfs", }, /* 29 = fstatfs */ { 3, "getfsstat", }, /* 30 = getfsstat */ { 4, "sigaction", }, /* 31 = sigaction */ { 3, "sigprocmask", }, /* 32 = sigprocmask */ { 2, "access", }, /* 33 = access */ { 1, "sigpending", }, /* 34 = sigpending */ { 2, "sigaltstack", }, /* 35 = sigaltstack */ { 0, "sync", }, /* 36 = sync */ { 2, "kill", }, /* 37 = kill */ { 2, "stat", }, /* 38 = stat */ { 2, "getlogin", }, /* 39 = getlogin */ { 2, "lstat", }, /* 40 = lstat */ { 1, "dup", }, /* 41 = dup */ { 0, "pipe", }, /* 42 = pipe */ { 1, "setlogin", }, /* 43 = setlogin */ { 4, "profil", }, /* 44 = profil */ { 1, "setuid", }, /* 45 = setuid */ { 1, "seteuid", }, /* 46 = seteuid */ { 0, "getgid", }, /* 47 = getgid */ { 0, "getegid", }, /* 48 = getegid */ { 1, "setgid", }, /* 49 = setgid */ { 1, "setegid", }, /* 50 = setegid */ { 0, "#51", }, /* 51 = unused */ { 3, "phys", }, /* 52 = (2.9) set phys addr */ { 1, "lock", }, /* 53 = (2.9) lock in core */ { 4, "ioctl", }, /* 54 = ioctl */ { 1, "reboot", }, /* 55 = reboot */ { 2, "sigwait", }, /* 56 = sigwait */ { 2, "symlink", }, /* 57 = symlink */ { 3, "readlink", }, /* 58 = readlink */ { 3, "execve", }, /* 59 = execve */ { 1, "umask", }, /* 60 = umask */ { 1, "chroot", }, /* 61 = chroot */ { 2, "fstat", }, /* 62 = fstat */ { 0, "#63", }, /* 63 = reserved */ { 0, "#64", }, /* 64 = (old getpagesize) */ { 6, "pselect", }, /* 65 = pselect */ { 0, "vfork", }, /* 66 = vfork */ { 0, "#67", }, /* 67 = unused */ { 0, "#68", }, /* 68 = unused */ { 1, "brk", }, /* 69 = brk */ { 0, "#70", }, /* 70 = unused */ { 0, "#71", }, /* 71 = unused */ { 0, "#72", }, /* 72 = unused */ { 0, "#73", }, /* 73 = unused */ { 0, "#74", }, /* 74 = unused */ { 0, "#75", }, /* 75 = unused */ { 0, "vhangup", }, /* 76 = vhangup */ { 0, "#77", }, /* 77 = unused */ { 0, "#78", }, /* 78 = unused */ { 2, "getgroups", }, /* 79 = getgroups */ { 2, "setgroups", }, /* 80 = setgroups */ { 1, "getpgrp", }, /* 81 = getpgrp */ { 2, "setpgrp", }, /* 82 = setpgrp */ { 3, "setitimer", }, /* 83 = setitimer */ { 0, "old wait", }, /* 84 = (old wait,wait3) */ { 0, "#85", }, /* 85 = unused */ { 2, "getitimer", }, /* 86 = getitimer */ { 0, "#87", }, /* 87 = (old gethostname) */ { 0, "#88", }, /* 88 = (old sethostname) */ { 0, "getdtablesize",}, /* 89 = getdtablesize */ { 2, "dup2", }, /* 90 = dup2 */ { 0, "#91", }, /* 91 = unused */ { 3, "fcntl", }, /* 92 = fcntl */ { 5, "select", }, /* 93 = select */ { 0, "#94", }, /* 94 = unused */ { 1, "fsync", }, /* 95 = fsync */ { 3, "setpriority", }, /* 96 = setpriority */ { 3, "socket", }, /* 97 = socket */ { 3, "connect", }, /* 98 = connect */ { 3, "accept", }, /* 99 = accept */ { 2, "getpriority", }, /* 100 = getpriority */ { 4, "send", }, /* 101 = send */ { 4, "recv", }, /* 102 = recv */ { 1, "sigreturn", }, /* 103 = sigreturn */ { 3, "bind", }, /* 104 = bind */ { 5, "setsockopt", }, /* 105 = setsockopt */ { 2, "listen", }, /* 106 = listen */ { 1, "sigsuspend", }, /* 107 = sigsuspend */ { 0, "#108", }, /* 108 = (old sigvec) */ { 0, "#109", }, /* 109 = (old sigblock) */ { 0, "#110", }, /* 110 = (old sigsetmask) */ { 0, "#111", }, /* 111 = (old sigpause) */ { 2, "sigstack", }, /* 112 = sigstack COMPAT-43 */ { 3, "recvmsg", }, /* 113 = recvmsg */ { 3, "sendmsg", }, /* 114 = sendmsg */ { 0, "#115", }, /* 115 = unused */ { 2, "gettimeofday", }, /* 116 = gettimeofday */ { 2, "getrusage", }, /* 117 = getrusage */ { 5, "getsockopt", }, /* 118 = getsockopt */ { 0, "#119", }, /* 119 = unused */ { 3, "readv", }, /* 120 = readv */ { 3, "writev", }, /* 121 = writev */ { 2, "settimeofday", }, /* 122 = settimeofday */ { 3, "fchown", }, /* 123 = fchown */ { 2, "fchmod", }, /* 124 = fchmod */ { 6, "recvfrom", }, /* 125 = recvfrom */ { 0, "#126", }, /* 126 = (old setreuid) */ { 0, "#127", }, /* 127 = (old setregid) */ { 2, "rename", }, /* 128 = rename */ { 3, "truncate", }, /* 129 = truncate */ { 3, "ftruncate", }, /* 130 = ftruncate */ { 2, "flock", }, /* 131 = flock */ { 0, "#132", }, /* 132 = nosys */ { 6, "sendto", }, /* 133 = sendto */ { 2, "shutdown", }, /* 134 = shutdown */ { 4, "socketpair", }, /* 135 = socketpair */ { 2, "mkdir", }, /* 136 = mkdir */ { 1, "rmdir", }, /* 137 = rmdir */ { 2, "utimes", }, /* 138 = utimes */ { 0, "#139", }, /* 139 = unused */ { 2, "adjtime", }, /* 140 = adjtime */ { 3, "getpeername", }, /* 141 = getpeername */ { 0, "#142", }, /* 142 = (old gethostid) */ { 0, "#143", }, /* 143 = (old sethostid) */ { 2, "getrlimit", }, /* 144 = getrlimit */ { 2, "setrlimit", }, /* 145 = setrlimit */ { 2, "killpg", }, /* 146 = killpg */ { 0, "#147", }, /* 147 = nosys */ { 2, "setquota", }, /* 148 = quota */ { 4, "quota", }, /* 149 = qquota */ { 3, "getsockname", }, /* 150 = getsockname */ { 0, "#151", }, /* 151 = unused */ { 0, "nostk", }, /* 152 = nostk */ { 1, "fetchi", }, /* 153 = fetchi */ { 4, "ucall", }, /* 154 = ucall */ { 0, "fperr", }, /* 155 = fperr */ }; ================================================ FILE: tools/virtualmips/config.c ================================================ /* * Parsing INI-style configuration files. The routines are taken and * modified from SMB source code (http://samba.anu.edu.au/cifs). * * Copyright (C) 2009-2012 Serge Vakulenko * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #include #include #include #include "config.h" static const char *confname; static char *bufr; static int bsize; static char *cursec; /* * Scan to the end of a comment. */ static int eat_comment (FILE *fp) { int c; c = getc (fp); while (c > 0 && c != '\n') c = getc (fp); return c; } /* * Skip whitespaces to end of line. */ static int eat_whitespace (FILE *fp) { int c; c = getc (fp); while (isspace(c) && c != '\n') c = getc (fp); return c; } /* * Search for continuation backshash, starting from line end, * When found, return it's index. * When no continuation, return -1. */ static int find_continuation (char *line, int pos) { pos--; while (pos >= 0 && isspace (line [pos])) pos--; if (pos >= 0 && line[pos] == '\\') return pos; /* No continuation. */ return -1; } /* * Scan a parameter name (or name and value pair) and pass the value (or * values) to function pfunc(). */ static void parse_parameter (FILE *fp, void (*pfunc) (void*, char*, char*, char*), void *arg, int c) { int i = 0; /* position withing bufr */ int end = 0; /* bufr[end] is current end-of-string */ int vstart = 0; /* starting position of the parameter */ /* Loop until we found the start of the value */ while (vstart == 0) { /* Ensure there's space for next char */ if (i > (bsize-2)) { bsize += 1024; bufr = realloc (bufr, bsize); if (! bufr) { fprintf (stderr, "%s: malloc failed\n", confname); exit (-1); } } switch (c) { case '=': if (end == 0) { fprintf (stderr, "%s: invalid parameter name\n", confname); exit (-1); } bufr[end++] = '\0'; i = end; vstart = end; bufr[i] = '\0'; break; case ';': /* comment line */ case '#': c = eat_comment (fp); case '\n': i = find_continuation (bufr, i); if (i < 0) { /* End of line, but no assignment symbol. */ bufr[end]='\0'; fprintf (stderr, "%s: bad line, ignored: `%s'\n", confname, bufr); return; } end = ((i > 0) && (bufr[i-1] == ' ')) ? (i-1) : (i); c = getc (fp); break; case '\0': case EOF: bufr[i] = '\0'; fprintf (stderr, "%s: unexpected end-of-file at %s: func\n", confname, bufr); exit (-1); default: if (isspace (c)) { bufr[end] = ' '; i = end + 1; c = eat_whitespace (fp); } else { bufr[i++] = c; end = i; c = getc (fp); } break; } } /* Now parse the value */ c = eat_whitespace (fp); while (c > 0) { if (i > (bsize-2)) { bsize += 1024; bufr = realloc (bufr, bsize); if (! bufr) { fprintf (stderr, "%s: malloc failed\n", confname); exit (-1); } } switch(c) { case '\r': c = getc (fp); break; case ';': /* comment line */ case '#': c = eat_comment (fp); case '\n': i = find_continuation (bufr, i); if (i < 0) c = 0; else { for (end=i; (end >= 0) && isspace (bufr[end]); end--) ; c = getc (fp); } break; default: bufr[i++] = c; if (! isspace (c)) end = i; c = getc (fp); break; } } bufr[end] = '\0'; pfunc (arg, cursec, bufr, &bufr [vstart]); } /* * Scan a section name and remember it in `cursec'. */ static void parse_section (FILE *fp) { int c, i, end; /* We've already got the '['. Scan past initial white space. */ c = eat_whitespace (fp); i = 0; end = 0; while (c > 0) { if (i > (bsize-2)) { bsize += 1024; bufr = realloc (bufr, bsize); if (! bufr) { fprintf (stderr, "%s: malloc failed\n", confname); exit (-1); } } switch (c) { case ']': /* found the closing bracked */ bufr[end] = '\0'; if (end == 0) { fprintf (stderr, "%s: empty section name\n", confname); exit (-1); } /* Register a section. */ if (cursec) free (cursec); cursec = strdup (bufr); eat_comment (fp); return; case '\n': i = find_continuation (bufr, i); if (i < 0) { bufr [end] = 0; fprintf (stderr, "%s: invalid line: '%s'\n", confname, bufr); exit (-1); } end = ((i > 0) && (bufr[i-1] == ' ')) ? (i-1) : (i); c = getc (fp); break; default: if (isspace (c)) { bufr[end] = ' '; i = end + 1; c = eat_whitespace (fp); } else { bufr[i++] = c; end = i; c = getc (fp); } break; } } } /* * Process the named parameter file */ void conf_parse (const char *filename, void (*pfunc) (void*, char*, char*, char*), void *arg) { FILE *fp; int c; confname = filename; fp = fopen (filename, "r"); if (! fp) { fprintf (stderr, "%s: unable to open config file\n", filename); exit (-1); } bsize = 1024; bufr = (char*) malloc (bsize); if (! bufr) { fprintf (stderr, "%s: malloc failed\n", confname); fclose (fp); exit (-1); } /* Parse file. */ c = eat_whitespace (fp); while (c > 0) { switch (c) { case '\n': /* blank line */ c = eat_whitespace (fp); break; case ';': /* comment line */ case '#': c = eat_comment (fp); break; case '[': /* section header */ parse_section (fp); c = eat_whitespace (fp); break; case '\\': /* bogus backslash */ c = eat_whitespace (fp); break; default: /* parameter line */ parse_parameter (fp, pfunc, arg, c); c = eat_whitespace (fp); break; } } fclose (fp); if (cursec) { free (cursec); cursec = 0; } free (bufr); bufr = 0; bsize = 0; } ================================================ FILE: tools/virtualmips/config.h ================================================ /* * Parsing INI-style configuration files. The routines are taken and * modified from SMB source code (http://samba.anu.edu.au/cifs). * * Copyright (C) 2009-2012 Serge Vakulenko * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ void conf_parse (const char *filename, void (*pfunc) (void*, char*, char*, char*), void *arg); ================================================ FILE: tools/virtualmips/cpu.c ================================================ /* * Copyright (C) yajin 2008 * * This file is part of the virtualmips distribution. * See LICENSE file for terms of the license. */ #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include "cpu.h" #include "mips_memory.h" #include "device.h" #include "mips.h" #include "mips_cp0.h" #include "mips_exec.h" #include "vm.h" #define LOG_ENABLE 0 /* * Log a message for a CPU */ void cpu_log (cpu_mips_t * cpu, char *module, char *format, ...) { #if LOG_ENABLE char buffer[256]; va_list ap; va_start (ap, format); snprintf (buffer, sizeof (buffer), "CPU%u: %s", cpu->id, module); vm_flog (cpu->vm, buffer, format, ap); va_end (ap); #endif } /* * Start a CPU */ void cpu_start (cpu_mips_t * cpu) { if (cpu) { cpu->state = CPU_STATE_RUNNING; } } /* * Stop a CPU */ void cpu_stop (cpu_mips_t * cpu) { if (cpu) { cpu_log (cpu, "CPU_STATE", "Halting CPU (old state=%u)...\n", cpu->state); cpu->state = CPU_STATE_HALTED; } } void cpu_restart (cpu_mips_t * cpu) { if (cpu) { cpu_log (cpu, "CPU_STATE", "Restartting CPU (old state=%u)...\n", cpu->state); cpu->state = CPU_STATE_RESTARTING; } } /* * Create a new CPU */ cpu_mips_t *cpu_create (vm_instance_t * vm, u_int type, u_int id) { cpu_mips_t *cpu; cpu = malloc (sizeof (*cpu)); if (!cpu) return NULL; memset (cpu, 0, sizeof (*cpu)); cpu->vm = vm; cpu->id = id; cpu->type = type; cpu->state = CPU_STATE_SUSPENDED; cpu->vm = vm; mips_init (cpu); return cpu; } /* * Delete a CPU */ void cpu_delete (cpu_mips_t * cpu) { if (cpu) { /* Stop activity of this CPU */ cpu_stop (cpu); pthread_join (cpu->cpu_thread, NULL); mips_delete (cpu); free (cpu); } } /* * Find a CPU in a group given its ID */ cpu_mips_t *cpu_group_find_id (cpu_group_t * group, u_int id) { cpu_mips_t *cpu; if (!group) return NULL; for (cpu = group->cpu_list; cpu; cpu = cpu->next) if (cpu->id == id) return cpu; return NULL; } /* * Find the highest CPU ID in a CPU group */ int cpu_group_find_highest_id (cpu_group_t * group, u_int * highest_id) { cpu_mips_t *cpu; u_int max_id = 0; if (!group || group->cpu_list) return (-1); for (cpu = group->cpu_list; cpu; cpu = cpu->next) if (cpu->id >= max_id) max_id = cpu->id; *highest_id = max_id; return (0); } /* * Add a CPU in a CPU group */ int cpu_group_add (cpu_group_t * group, cpu_mips_t * cpu) { if (!group) return (-1); /* check that we don't already have a CPU with this id */ if (cpu_group_find_id (group, cpu->id) != NULL) { fprintf (stderr, "cpu_group_add: CPU%u already present in group.\n", cpu->id); return (-1); } cpu->next = group->cpu_list; group->cpu_list = cpu; return (0); } /* * Create a new CPU group */ cpu_group_t *cpu_group_create (char *name) { cpu_group_t *group; if (!(group = malloc (sizeof (*group)))) return NULL; group->name = name; group->cpu_list = NULL; return group; } /* * Delete a CPU group */ void cpu_group_delete (cpu_group_t * group) { cpu_mips_t *cpu, *next; if (group != NULL) { for (cpu = group->cpu_list; cpu; cpu = next) { next = cpu->next; cpu_delete (cpu); } free (group); } } /* * Rebuild the MTS subsystem for a CPU group */ int cpu_group_rebuild_mts (cpu_group_t * group) { cpu_mips_t *cpu; for (cpu = group->cpu_list; cpu; cpu = cpu->next) cpu->mts_rebuild (cpu); return (0); } /* * Start all CPUs of a CPU group */ void cpu_group_start_all_cpu (cpu_group_t * group) { cpu_mips_t *cpu; for (cpu = group->cpu_list; cpu; cpu = cpu->next) cpu_start (cpu); } /* * Stop all CPUs of a CPU group */ void cpu_group_stop_all_cpu (cpu_group_t * group) { cpu_mips_t *cpu; for (cpu = group->cpu_list; cpu; cpu = cpu->next) cpu_stop (cpu); } /* * Set a state of all CPUs of a CPU group */ void cpu_group_set_state (cpu_group_t * group, u_int state) { cpu_mips_t *cpu; for (cpu = group->cpu_list; cpu; cpu = cpu->next) cpu->state = state; } /* * Returns TRUE if all CPUs in a CPU group are inactive */ static int cpu_group_check_activity (cpu_group_t * group) { cpu_mips_t *cpu; for (cpu = group->cpu_list; cpu; cpu = cpu->next) { if (!cpu->cpu_thread_running) continue; if (cpu->state == CPU_STATE_RUNNING) return (FALSE); } return (TRUE); } /* * Synchronize on CPUs (all CPUs must be inactive) */ int cpu_group_sync_state (cpu_group_t * group) { m_tmcnt_t t1, t2; /* Check that CPU activity is really suspended */ t1 = m_gettime (); while (!cpu_group_check_activity (group)) { t2 = m_gettime (); if (t2 > (t1 + 10000)) return (-1); usleep (50000); } return (0); } /* * Save state of all CPUs */ int cpu_group_save_state (cpu_group_t * group) { cpu_mips_t *cpu; for (cpu = group->cpu_list; cpu; cpu = cpu->next) cpu->prev_state = cpu->state; return (TRUE); } /* * Restore state of all CPUs */ int cpu_group_restore_state (cpu_group_t * group) { cpu_mips_t *cpu; for (cpu = group->cpu_list; cpu; cpu = cpu->next) cpu->state = cpu->prev_state; return (TRUE); } ================================================ FILE: tools/virtualmips/cpu.h ================================================ /* * Copyright (C) yajin 2008 * * This file is part of the virtualmips distribution. * See LICENSE file for terms of the license. * */ #ifndef __CPU_H__ #define __CPU_H__ #include #include "utils.h" #include "mips.h" #include "system.h" /* Possible CPU types */ enum { CPU_TYPE_MIPS64 = 1, CPU_TYPE_MIPS32, }; /* Virtual CPU states */ enum { CPU_STATE_RUNNING = 0, /*cpu is running */ CPU_STATE_HALTED, CPU_STATE_SUSPENDED, /*CPU is SUSPENDED */ CPU_STATE_RESTARTING, /*cpu is restarting */ CPU_STATE_PAUSING, /*cpu is pausing for timer */ }; /* CPU group definition */ typedef struct cpu_group cpu_group_t; struct cpu_group { char *name; cpu_mips_t *cpu_list; void *priv_data; }; void cpu_log (cpu_mips_t * cpu, char *module, char *format, ...); void cpu_start (cpu_mips_t * cpu); void cpu_stop (cpu_mips_t * cpu); void cpu_restart (cpu_mips_t * cpu); cpu_mips_t *cpu_create (vm_instance_t * vm, u_int type, u_int id); void cpu_delete (cpu_mips_t * cpu); cpu_mips_t *cpu_group_find_id (cpu_group_t * group, u_int id); int cpu_group_find_highest_id (cpu_group_t * group, u_int * highest_id); int cpu_group_add (cpu_group_t * group, cpu_mips_t * cpu); cpu_group_t *cpu_group_create (char *name); void cpu_group_delete (cpu_group_t * group); int cpu_group_rebuild_mts (cpu_group_t * group); void cpu_group_start_all_cpu (cpu_group_t * group); void cpu_group_stop_all_cpu (cpu_group_t * group); void cpu_group_set_state (cpu_group_t * group, u_int state); int cpu_group_sync_state (cpu_group_t * group); int cpu_group_save_state (cpu_group_t * group); int cpu_group_restore_state (cpu_group_t * group); #endif ================================================ FILE: tools/virtualmips/crc.c ================================================ /* * Cisco router simulation platform. * Copyright (c) 2006 Christophe Fillot (cf@utc.fr) * * CRC functions. */ #include #include #include #include #include #include #include #include #include #include #include "utils.h" #include "crc.h" #define CRC12_POLY 0x0f01 #define CRC16_POLY 0xa001 #define CRC32_POLY 0xedb88320L /* CRC tables */ m_uint16_t crc12_array[256], crc16_array[256]; m_uint32_t crc32_array[256]; /* Initialize CRC-12 algorithm */ static void crc12_init (void) { m_uint16_t crc, c; int i, j; for (i = 0; i < 256; i++) { crc = 0; c = (m_uint16_t) i; for (j = 0; j < 8; j++) { if ((crc ^ c) & 0x0001) crc = (crc >> 1) ^ CRC12_POLY; else crc = crc >> 1; c = c >> 1; } crc12_array[i] = crc; } } /* Initialize CRC-16 algorithm */ static void crc16_init (void) { m_uint16_t crc, c; int i, j; for (i = 0; i < 256; i++) { crc = 0; c = (m_uint16_t) i; for (j = 0; j < 8; j++) { if ((crc ^ c) & 0x0001) crc = (crc >> 1) ^ CRC16_POLY; else crc = crc >> 1; c = c >> 1; } crc16_array[i] = crc; } } /* Initialize CRC-32 algorithm */ static void crc32_init (void) { unsigned long c; int n, k; for (n = 0; n < 256; n++) { c = (unsigned long) n; for (k = 0; k < 8; k++) { if (c & 1) c = CRC32_POLY ^ (c >> 1); else c = c >> 1; } crc32_array[n] = c; } } /* Initialize CRC algorithms */ void crc_init (void) { crc12_init (); crc16_init (); crc32_init (); } ================================================ FILE: tools/virtualmips/crc.h ================================================ /* * Cisco router simulation platform. * Copyright (c) 2006 Christophe Fillot (cf@utc.fr) * * CRC functions. */ #ifndef __CRC_H__ #define __CRC_H__ #include #include "utils.h" extern m_uint16_t crc12_array[], crc16_array[]; extern m_uint32_t crc32_array[]; /* Compute a CRC-12 hash on a 32-bit integer */ static forced_inline m_uint32_t crc12_hash_u32 (m_uint32_t val) { register m_uint32_t crc = 0; register int i; for (i = 0; i < 4; i++) { crc = (crc >> 8) ^ crc12_array[(crc ^ val) & 0xff]; val >>= 8; } return (crc); } /* Compute a CRC-16 hash on a 32-bit integer */ static forced_inline m_uint32_t crc16_hash_u32 (m_uint32_t val) { register m_uint32_t crc = 0; register int i; for (i = 0; i < 4; i++) { crc = (crc >> 8) ^ crc16_array[(crc ^ val) & 0xff]; val >>= 8; } return (crc); } /* Compute a CRC-32 on the specified block */ static forced_inline m_uint32_t crc32_compute (m_uint32_t crc_accum, m_uint8_t * ptr, int len) { unsigned long c = crc_accum; int n; for (n = 0; n < len; n++) { c = crc32_array[(c ^ ptr[n]) & 0xff] ^ (c >> 8); } return (~c); } /* Initialize CRC algorithms */ void crc_init (void); #endif ================================================ FILE: tools/virtualmips/debug.c ================================================ /* * Copyright (C) yajin 2008 * * This file is part of the virtualmips distribution. * See LICENSE file for terms of the license. * */ /* A simple interface for GDB. Based on SimOS. */ #define _GNU_SOURCE #include #include #include #include "vm.h" #include "mips.h" #include "utils.h" #include "debug.h" int forced_inline mips_debug (vm_instance_t * vm, int is_break) { Simdebug_result res; res = Simdebug_run (vm, is_break ? SIGTRAP : SIGUSR2); switch (res) { case SD_CONTINUE: vm->mipsy_break_nexti = MIPS_NOBREAK; vm->mipsy_debug_mode = 1; break; case SD_NEXTI_ANYCPU: vm->mipsy_break_nexti = MIPS_BREAKANYCPU; vm->mipsy_debug_mode = 1; break; default: vm->mipsy_break_nexti = res; vm->mipsy_debug_mode = 1; break; } return 0; } void vm_debug_init (vm_instance_t * vm) { struct sockaddr_in sockaddr; int tmp; if (vm->gdb_debug != 1) return; vm->mipsy_debug_mode = 1; vm->mipsy_break_nexti = -1; vm->gdb_interact_sock = -1; vm->gdb_debug_from_poll = 0; vm->gdb_listen_sock = socket (PF_INET, SOCK_STREAM, 0); if (vm->gdb_listen_sock < 0) { fprintf (stderr, "Can't open debug socket. Run without gdb debug\n"); vm->gdb_debug = 0; return; } /* Allow rapid reuse of this port. */ tmp = 1; if (setsockopt (vm->gdb_listen_sock, SOL_SOCKET, SO_REUSEADDR, (char *) &tmp, sizeof (tmp)) < 0) { printf ("simdebug setsockopt SO_REUSEADDR"); /* Not fatal */ } bzero ((char *) &sockaddr, sizeof (struct sockaddr_in)); sockaddr.sin_family = PF_INET; sockaddr.sin_port = htons (vm->gdb_port); sockaddr.sin_addr.s_addr = INADDR_ANY; while (bind (vm->gdb_listen_sock, (struct sockaddr *) &sockaddr, sizeof (sockaddr)) || listen (vm->gdb_listen_sock, 1)) { vm->gdb_port++; sockaddr.sin_port = htons (vm->gdb_port); } vm->breakpoint_head = 0; vm->breakpoint_tail = 0; } ================================================ FILE: tools/virtualmips/debug.h ================================================ /* * Copyright (C) yajin 2008 * * This file is part of the virtualmips distribution. * See LICENSE file for terms of the license. * */ #ifndef __DEBUG_H__ #define __DEBUG_H__ #include "vm.h" #define MIPS_NOBREAK (-2) #define MIPS_BREAKANYCPU (-1) void vm_debug_init (vm_instance_t * vm); int mips_debug (vm_instance_t * vm, int is_break); #endif ================================================ FILE: tools/virtualmips/dev_cs8900.c ================================================ /* * Copyright (C) yajin 2008 * * This file is part of the virtualmips distribution. * See LICENSE file for terms of the license. * */ /* * cs8900 net card emulation. * (jz4740 driver). * Only works in linux 2.6.24/2.6.22/2.4.20 * uboot can not use it. * * Please use TCP instead of UDP when using NFS. * Throughput is about 50k-100k bytes per second when downloading a file from host using http. * Maybe improved when JIT is implemented in the future. * */ #include #include #include #include #include #include #include #include #include "crc.h" #include "utils.h" #include "cpu.h" #include "vm.h" #include "mips_memory.h" #include "device.h" #include "net.h" #include "net_io.h" #include "dev_cs8900.h" /*#define QUEUE_SIZE 128 #define PACKET_LEN 1600 m_uint8_t recv_buffer[QUEUE_SIZE][PACKET_LEN]; m_uint8_t packet_len[QUEUE_SIZE]; m_uint8_t read_index=0; m_uint8_t write_index=0; */ /*00:62:9c:61:cf:16*/ static uint8_t cs8900a_default_mac[6] = { 0x00, 0x62, 0x9c, 0x61, 0xcf, 0x16 }; #define CS8900_DEFAULT_RX_TIMEOUT 40 #define CS8900_MIN_RX_TIMEOUT 20 #define CS8900_MAX_RX_TIMEOUT 100 #define CS8900_RX_TIMEOUT_STEP 5 static m_uint32_t cs8900a_rx_timeout = CS8900_DEFAULT_RX_TIMEOUT; /* Maximum packet size */ #define CS8900_MAX_PKT_SIZE 1518 #define CS8900_MIN_PKT_SIZE 8 #define CS8900_RUN_PKT_SIZE 64 #define CS8900A_PRODUCT_ID 0x630e /*little endian */ #define PP_RT_DATA0 0x00 #define PP_RT_DATA1 0x02 #define PP_TX_CMD 0X04 #define PP_TX_LEN 0X06 #define PP_IO_ISQ 0X08 #define PP_ADDRESS 0x0a /* PacketPage Pointer Port (Section 4.10.10) */ #define PP_DATA0 0x0c /* PacketPage Data Port (Section 4.10.10) */ #define PP_DATA1 0X0e #define PP_ProductID 0x0000 /* Section 4.3.1 Product Identification Code */ #define PP_ISAIOB 0x0020 /* IO base address */ #define PP_IntNum 0x0022 /* Section 3.2.3 Interrupt Number */ #define PP_ISASOF 0x0026 /* ISA DMA offset */ #define PP_DmaFrameCnt 0x0028 /* ISA DMA Frame count */ #define PP_DmaByteCnt 0x002A /* ISA DMA Byte count */ #define PP_MemBase 0x002c /* Section 4.9.2 Memory Base Address Register */ #define PP_EEPROMCommand 0x0040 /* Section 4.3.11 EEPROM Command */ #define PP_EEPROMData 0x0042 /* Section 4.3.12 EEPROM Data */ #define PP_RxCFG 0x0102 /* Section 4.4.6 Receiver Configuration */ #define PP_RxCTL 0x0104 /* Section 4.4.8 Receiver Control */ #define PP_TxCFG 0x0106 /* Section 4.4.9 Transmit Configuration */ #define PP_BufCFG 0x010a /* Section 4.4.12 Buffer Configuration */ #define PP_LineCTL 0x0112 /* Section 4.4.16 Line Control */ #define PP_SelfCTL 0x0114 /* Section 4.4.18 Self Control */ #define PP_BusCTL 0x0116 /* Section 4.4.20 Bus Control */ #define PP_TestCTL 0x0118 /* Section 4.4.22 Test Control */ #define PP_AutoNegCTL 0x011C /* Auto Negotiation Ctrl */ #define PP_ISQ 0x0120 /* Section 4.4.5 Interrupt Status Queue */ #define PP_RxEvent 0x0124 /* Rx Event Register */ #define PP_TxEvent 0x0128 /* Section 4.4.10 Transmitter Event */ #define PP_BufEvent 0x012c /* Section 4.4.13 Buffer Event */ #define PP_RxMISS 0x0130 /* Section 4.4.14 Receiver Miss Counter */ #define PP_TxCOL 0x0132 /* Section 4.4.15 Transmit Collision Counter */ #define PP_LineST 0x0134 /* Line State Register */ #define PP_SelfST 0x0136 /* Section 4.4.19 Self Status */ #define PP_BusST 0x0138 /* Section 4.4.21 Bus Status */ #define PP_TDR 0x013C /* Time Domain Reflectometry */ #define PP_AutoNegST 0x013E /* Auto Neg Status */ #define PP_TxCMD 0x0144 /* Section 4.4.11 Transmit Command */ #define PP_TxLength 0x0146 /* Section 4.5.2 Transmit Length */ #define PP_LAF 0x0150 /* Hash Table */ #define PP_IA 0x0158 /* Section 4.6.2 Individual Address (IEEE Address) */ #define PP_RxStatus 0x0400 /* Section 4.7.1 Receive Status */ #define PP_RxLength 0x0402 /* Section 4.7.1 Receive Length (in bytes) */ #define PP_RxFrame 0x0404 /* Section 4.7.2 Receive Frame Location */ #define PP_TxFrame 0x0a00 /* Section 4.7.2 Transmit Frame Location */ /* PP_RxCFG */ #define Skip_1 0x0040 #define StreamE 0x0080 #define RxOKiE 0x0100 #define RxDMAonly 0x0200 #define AutoRxDMAE 0x0400 #define BufferCRC 0x0800 #define CRCerroriE 0x1000 #define RuntiE 0x2000 #define ExtradataiE 0x4000 /* PP_TxCFG */ #define Loss_of_CRSiE 0x0040 #define SQErroriE 0x0080 #define TxOKiE 0x0100 #define Out_of_windowiE 0x0200 #define JabberiE 0x0400 #define AnycolliE 0x0800 #define T16colliE 0x8000 /* PP_BufCFG */ #define SWint_X 0x0040 #define RxDMAiE 0x0080 #define Rdy4TxiE 0x0100 #define TxUnderruniE 0x0200 #define RxMissiE 0x0400 #define Rx128iE 0x0800 #define TxColOvfiE 0x1000 #define MissOvfloiE 0x2000 #define RxDestiE 0x8000 /* PP_RxCTL */ #define IAHashA 0x0040 #define PromiscuousA 0x0080 #define RxOKA 0x0100 #define MulticastA 0x0200 #define IndividualA 0x0400 #define BroadcastA 0x0800 #define CRCerrorA 0x1000 #define RuntA 0x2000 #define ExtradataA 0x4000 /* PP_SelfCTL */ #define RESET 0x0040 #define SWSuspend 0x0100 #define HWSleepE 0x0200 #define HWStandbyE 0x0400 #define HC0E 0x1000 #define HC1E 0x2000 #define HCB0 0x4000 #define HCB1 0x8000 /* PP_LineCTL */ #define SerRxON 0x0040 #define SerTxON 0x0080 #define AUIonly 0x0100 #define AutoAUI_10BT 0x0200 #define ModBackoffE 0x0800 #define PolarityDis 0x1000 #define L2_partDefDis 0x2000 #define LoRxSquelch 0x4000 /* PP_TxEvent */ #define Loss_of_CRS 0x0040 #define SQEerror 0x0080 #define TxOK 0x0100 #define Out_of_window 0x0200 #define Jabber 0x0400 #define T16coll 0x8000 #define RxEvent 0x0004 #define TxEvent 0x0008 #define BufEvent 0x000c #define RxMISS 0x0010 #define TxCOL 0x0012 /* PP_BufEvent */ #define SWint 0x0040 #define RxDMAFrame 0x0080 #define Rdy4Tx 0x0100 #define TxUnderrun 0x0200 #define RxMiss 0x0400 #define Rx128 0x0800 #define RxDest 0x8000 /* PP_TxCMD */ #define After5 0 #define After381 1 #define After1021 2 #define AfterAll 3 #define TxStart(x) ((x) << 6) #define Force 0x0100 #define Onecoll 0x0200 #define InhibitCRC 0x1000 #define TxPadDis 0x2000 /* PP_BusST */ #define TxBidErr 0x0080 #define Rdy4TxNOW 0x0100 extern cpu_mips_t *current_cpu; static void dev_cs8900_gen_interrupt (struct cs8900_data *d) { vm_instance_t *vm; vm = d->vm; /*must check RQ bit in 0x116 */ m_uint8_t *ram_base; ram_base = (m_uint8_t *) (&(d->internal_ram[0])); if ((*(m_uint16_t *) (ram_base + PP_BusCTL)) & (0x8000)) { /*generate IRQ */ vm->set_irq (vm, d->irq_no); } } static void dev_cs8900_init_defaultvalue (struct cs8900_data *d) { m_uint8_t *ram_base; ram_base = (m_uint8_t *) (&(d->internal_ram[0])); *(m_uint32_t *) (ram_base + PP_ProductID) = CS8900A_PRODUCT_ID; *(m_uint16_t *) (ram_base + PP_ISAIOB) = 0x300; *(m_uint16_t *) (ram_base + PP_IntNum) = 0x4; *(m_uint16_t *) (ram_base + PP_IntNum) = 0x4; *(m_uint16_t *) (ram_base + PP_RxCFG) = 0x3; *(m_uint16_t *) (ram_base + PP_RxEvent) = 0x4; *(m_uint16_t *) (ram_base + PP_RxCTL) = 0x5; *(m_uint16_t *) (ram_base + PP_TxCFG) = 0x7; *(m_uint16_t *) (ram_base + PP_TxEvent) = 0x8; *(m_uint16_t *) (ram_base + 0x108) = 0x9; *(m_uint16_t *) (ram_base + PP_BufCFG) = 0xb; *(m_uint16_t *) (ram_base + PP_BufEvent) = 0xc; *(m_uint16_t *) (ram_base + PP_RxMISS) = 0x10; *(m_uint16_t *) (ram_base + PP_TxCOL) = 0x12; *(m_uint16_t *) (ram_base + PP_LineCTL) = 0x13; *(m_uint16_t *) (ram_base + PP_LineST) = 0x14; *(m_uint16_t *) (ram_base + PP_SelfCTL) = 0x15; *(m_uint16_t *) (ram_base + PP_SelfST) = 0x16; *(m_uint16_t *) (ram_base + PP_BusCTL) = 0x17; *(m_uint16_t *) (ram_base + PP_BusST) = 0x18; *(m_uint16_t *) (ram_base + PP_TestCTL) = 0x19; *(m_uint16_t *) (ram_base + PP_TDR) = 0x1c; *(m_uint16_t *) (ram_base + PP_TxCMD) = 0x9; *(ram_base + PP_IA) = cs8900a_default_mac[0]; *(ram_base + PP_IA + 1) = cs8900a_default_mac[1]; *(ram_base + PP_IA + 2) = cs8900a_default_mac[2]; *(ram_base + PP_IA + 3) = cs8900a_default_mac[3]; *(ram_base + PP_IA + 4) = cs8900a_default_mac[4]; *(ram_base + PP_IA + 5) = cs8900a_default_mac[5]; } static void dev_cs8900_reset (cpu_mips_t * cpu, struct vdevice *dev) { struct cs8900_data *d = dev->priv_data; memset (d->internal_ram, 0, sizeof (d->internal_ram)); dev_cs8900_init_defaultvalue (d); } /* Check if a packet must be delivered to the emulated chip based on length*/ static inline int cs8900_handle_len (struct cs8900_data *d, m_uint8_t * pkt, ssize_t pkt_len) { /*we do not check CRC !!!! */ if (pkt_len < CS8900_MIN_PKT_SIZE) return FALSE; ASSERT ((pkt_len >= CS8900_RUN_PKT_SIZE) && (pkt_len <= CS8900_MAX_PKT_SIZE), "not valid pktlen 0x%x\n", (unsigned) pkt_len); /*64internal_ram[0])); if ((*(m_uint16_t *) (ram_base + PP_RxCTL)) & PromiscuousA) { goto rx_dest_int; } if (eth_addr_is_bcast (&hdr->daddr)) { if ((*(m_uint16_t *) (ram_base + PP_RxCTL)) & BroadcastA) { *(m_uint16_t *) (ram_base + PP_RxEvent) |= BroadcastA; *(m_uint16_t *) (ram_base + PP_RxStatus) |= BroadcastA; goto rx_dest_int; } else return FALSE; } if (eth_addr_is_mcast (&hdr->daddr)) { if ((*(m_uint16_t *) (ram_base + PP_RxCTL)) & MulticastA) { *(m_uint16_t *) (ram_base + PP_RxEvent) |= MulticastA; *(m_uint16_t *) (ram_base + PP_RxStatus) |= MulticastA; goto rx_dest_int; } else return FALSE; } if ((*(m_uint16_t *) (ram_base + PP_RxCTL)) & IndividualA) { /* Accept frames directly for us, discard others */ if (!memcmp ((ram_base + PP_IA), &hdr->daddr, N_ETH_ALEN)) { *(m_uint16_t *) (ram_base + PP_RxEvent) |= IndividualA; *(m_uint16_t *) (ram_base + PP_RxStatus) |= IndividualA; goto rx_dest_int; } else return FALSE; } rx_dest_int: return (TRUE); } static int dev_cs8900_receive_pkt (struct cs8900_data *d, u_char * pkt, ssize_t pkt_len) { m_uint8_t *ram_base; ram_base = (m_uint8_t *) (&(d->internal_ram[0])); /* Truncate the packet if it is too big */ pkt_len = m_min (pkt_len, CS8900_MAX_PKT_SIZE); /*set RX len */ *(m_uint16_t *) (ram_base + PP_RxLength) = pkt_len; /*Rx status has been set */ /*just copy frame to internal ram */ memcpy (ram_base + PP_RxFrame, pkt, pkt_len); /*generate interrupt */ *(m_uint16_t *) (ram_base + PP_RxEvent) |= RxOKA; *(m_uint16_t *) (ram_base + PP_RxStatus) |= RxOKA; if ((*(m_uint16_t *) (ram_base + PP_RxCFG)) & RxOKiE) { //*(m_uint16_t*)(ram_base+PP_ISQ) &= ~0x3f; *(m_uint16_t *) (ram_base + PP_ISQ) |= RxEvent; dev_cs8900_gen_interrupt (d); } return TRUE; } static int dev_cs8900_rx (netio_desc_t * nio, u_char * pkt, ssize_t pkt_len, struct cs8900_data *d) { m_uint8_t *ram_base; m_uint16_t real_len; int i; m_uint32_t ifcs; ram_base = (m_uint8_t *) (&(d->internal_ram[0])); if (!((*(m_uint16_t *) (ram_base + PP_LineCTL)) & SerRxON)) return FALSE; real_len = pkt_len; /*FIXME: yajin * jzdriver discard <64 bytes packet. But arp packet has 40 bytes. Pad it to 64 bytes to meet jz driver's requirement */ if (unlikely (pkt_len < 64)) { /*pad to 60 bytes */ for (i = pkt_len; i < 60; i++) { *(pkt + i) = 0x0; } /*add crc */ ifcs = crc32_compute (0xFFFFFFFF, pkt, 60); *(pkt + 60) = ifcs & 0xff; *(pkt + 61) = (ifcs >> 8) & 0xff; *(pkt + 62) = (ifcs >> 16) & 0xff; *(pkt + 63) = ifcs >> 24; real_len = 64; } /*check MAC address */ if (!(cs8900_handle_mac_addr (d, pkt))) return FALSE; /*check frame len */ if (!(cs8900_handle_len (d, pkt, real_len))) return FALSE; return (dev_cs8900_receive_pkt (d, pkt, real_len)); } static int dev_cs8900_tx (struct cs8900_data *d) { m_uint8_t *ram_base; ram_base = (m_uint8_t *) (&(d->internal_ram[0])); m_uint16_t send_len; int i; m_uint32_t ifcs; send_len = *(m_uint16_t *) (ram_base + PP_TxLength); /*check if tx is enabled */ if ((*(m_uint16_t *) (ram_base + PP_LineCTL)) & SerTxON) { /*pad if len<60 */ if (send_len <= (CS8900_RUN_PKT_SIZE - 4)) { if (!((*(m_uint16_t *) (ram_base + PP_TxCMD)) & TxPadDis)) { /*pad to 60 bytes */ for (i = send_len; i < 60; i++) { *(ram_base + PP_TxFrame + i) = 0x0; } send_len = 60; if (!((*(m_uint16_t *) (ram_base + PP_TxCMD)) & InhibitCRC)) { /*append crc */ ifcs = crc32_compute (0xFFFFFFFF, ram_base + PP_TxFrame, send_len); *(ram_base + PP_TxFrame + send_len) = ifcs & 0xff; *(ram_base + PP_TxFrame + send_len + 1) = (ifcs >> 8) & 0xff; *(ram_base + PP_TxFrame + send_len + 2) = (ifcs >> 16) & 0xff; *(ram_base + PP_TxFrame + send_len + 3) = ifcs >> 24; send_len += 4; } } } *(m_uint16_t *) (ram_base + PP_TxLength) = send_len; netio_send (d->nio, ram_base + PP_TxFrame, send_len); *(m_uint16_t *) (ram_base + PP_TxEvent) = TxOK | 0x8; /*is = not |. all other bits must be cleared */ if ((*(m_uint16_t *) (ram_base + PP_TxCFG)) & TxOKiE) { /*if TXOKIE, generate an interrupt */ /*set ISQ (regno=TX Event) */ //*(m_uint16_t*)(ram_base+PP_ISQ) &= ~0x3f; *(m_uint16_t *) (ram_base + PP_ISQ) |= TxEvent; dev_cs8900_gen_interrupt (d); } } return TRUE; } /* how to determinte the timeout value??? */ void dev_cs8900_active_timer (struct cs8900_data *d) { vp_mod_timer (d->cs8900_timer, vp_get_clock (rt_clock) + cs8900a_rx_timeout); } void dev_cs8900_unactive_timer (struct cs8900_data *d) { vp_del_timer (d->cs8900_timer); } void dev_cs8900_cb (void *opaque) { struct cs8900_data *d = opaque; int fd; ssize_t pkt_len; static m_uint8_t status = 0; ASSERT (d->nio != NULL, "set nio first\n"); if ((fd = netio_get_fd (d->nio)) == -1) { ASSERT (0, "can not get nio fd. init cs8900 nio first.\n"); } pkt_len = netio_recv (d->nio, d->nio->rx_pkt, sizeof (d->nio->rx_pkt)); if (pkt_len > 0) { /*rx packet */ dev_cs8900_rx (d->nio, d->nio->rx_pkt, pkt_len, d); /*Why we need to adjust CS8900_MAX_RX_TIMEOUT? yajin * If CS8900_MAX_RX_TIMEOUT is small, that means rx packets quickly. Tx can not get enough time to tell cpu * that tx ok. * If CS8900_MAX_RX_TIMEOUT is big, that means rx packets slow. This will decrease network throughtput and * some applications will complain about rx timeout. * So I adjut the CS8900_MAX_RX_TIMEOUT dynamicly when receiving a packet . * * Please use TCP protocol instead of UDP when mounting directory using nfs. * */ if (cs8900a_rx_timeout >= CS8900_MAX_RX_TIMEOUT) status = 1; else if (cs8900a_rx_timeout <= CS8900_MIN_RX_TIMEOUT) status = 2; if (status == 0) cs8900a_rx_timeout -= CS8900_RX_TIMEOUT_STEP; if (status == 1) cs8900a_rx_timeout -= CS8900_RX_TIMEOUT_STEP; else if (status == 2) cs8900a_rx_timeout += CS8900_RX_TIMEOUT_STEP; } cs8900a_rx_timeout = CS8900_DEFAULT_RX_TIMEOUT; dev_cs8900_active_timer (d); } static void *dev_cs8900_access (cpu_mips_t * cpu, struct vdevice *dev, m_uint32_t offset, u_int op_size, u_int op_type, m_uint32_t * data, m_uint8_t * has_set_value) { struct cs8900_data *d = dev->priv_data; void *ret; m_uint8_t *ram_base; m_uint16_t io_address; m_uint16_t isq; ram_base = (m_uint8_t *) (&(d->internal_ram[0])); if (offset >= d->cs8900_size) { *data = 0; return NULL; } #if VALIDE_CS8900_OPERATION if (op_type == MTS_WRITE) { ASSERT (offset != PP_IO_ISQ, "Write to read only register in CS8900. offset %x\n", offset); } else if (op_type == MTS_READ) { ASSERT (offset != PP_TX_CMD, "Read write only register in CS8900. offset %x\n", offset); ASSERT (offset != PP_TX_LEN, "Read write only register in CS8900. offset %x\n", offset); } #endif switch (offset) { case PP_RT_DATA0: case PP_RT_DATA0 + 1: case PP_RT_DATA1: case PP_RT_DATA1 + 1: if (op_type == MTS_READ) { ASSERT (d->rx_read_index < (*(m_uint16_t *) (ram_base + PP_RxLength)), "read out of data rx_read_index %x data len %x \n", d->rx_read_index, (*(m_uint16_t *) (ram_base + PP_RxLength))); ret = (void *) (ram_base + PP_RxFrame + d->rx_read_index); d->rx_read_index += op_size; /****if read all data,set d->rx_read_index=0*/ if (d->rx_read_index >= *(m_uint16_t *) (ram_base + PP_RxLength)) d->rx_read_index = 0; return ret; } else if (op_type == MTS_WRITE) { ret = (void *) (ram_base + PP_TxFrame + d->tx_send_index); if (op_size == MTS_BYTE) *(m_uint8_t *) ret = *data; if (op_size == MTS_HALF_WORD) *(m_uint16_t *) ret = *data; else *(m_uint32_t *) ret = *data; *has_set_value = TRUE; d->tx_send_index += op_size; /*if write all data into tx buffer, set d->tx_send_index=0 */ if (d->tx_send_index >= *(m_uint16_t *) (ram_base + PP_TxLength)) { d->tx_send_index = 0; /*start tx a frame */ dev_cs8900_tx (d); } return NULL; } break; case PP_TX_CMD: ret = (void *) (ram_base + PP_TxCMD); return ret; case PP_TX_LEN: ret = (void *) (ram_base + PP_TxLength); return ret; case PP_IO_ISQ: ASSERT (0, "not support PP_IO_ISQ \n"); case PP_ADDRESS: return (void *) (ram_base + PP_ADDRESS); case PP_DATA0: case PP_DATA1: if (offset == PP_DATA0) ASSERT (op_size == MTS_HALF_WORD, "op_size must be 2. op_size %x\n", op_size); else if (offset == PP_DATA1) ASSERT (0, "cs8900 only support 16 bit IO operation"); io_address = *(m_uint16_t *) (ram_base + PP_ADDRESS); switch (io_address) { case PP_ProductID: ASSERT (op_type == MTS_READ, "write to read only register %x\n", *(m_uint16_t *) (ram_base + PP_ADDRESS)); *data = CS8900A_PRODUCT_ID; *has_set_value = TRUE; return NULL; case PP_ProductID + 2: /*16 bit */ *data = 0; *has_set_value = TRUE; return NULL; case PP_ISAIOB: case PP_IntNum: return (void *) (ram_base + io_address); case PP_ISASOF: case PP_DmaFrameCnt: case PP_DmaByteCnt: case PP_MemBase: case PP_EEPROMCommand: case PP_EEPROMData: ASSERT (0, "Not support yet offset %x \n", io_address); break; case PP_RxCFG: if (op_type == MTS_WRITE) { if (*data & Skip_1) { memset (ram_base + PP_RxFrame, 0x0, PP_TxFrame - 1 - PP_RxFrame); } *(m_uint16_t *) (ram_base + PP_RxCFG) = *data | 0x3; *has_set_value = TRUE; return NULL; } else /*read */ return (void *) (ram_base + io_address); case PP_RxCTL: if (op_type == MTS_WRITE) { *(m_uint16_t *) (ram_base + PP_RxCTL) = *data | 0x5; *has_set_value = TRUE; if (*data & IAHashA) ASSERT (0, "Hash dest address is not support yet \n"); return NULL; } else return (void *) (ram_base + io_address); case PP_TxCFG: if (op_type == MTS_WRITE) { *(m_uint16_t *) (ram_base + PP_TxCFG) = *data | 0x7; *has_set_value = TRUE; return NULL; } else return (void *) (ram_base + io_address); case 0x108: /*read 0x108 actually read 0x144 TXcmd */ ASSERT (op_type == MTS_READ, "CS8900 write to read only register. IO address 0x108 \n"); return (void *) (ram_base + 0x144); case PP_BufCFG: if (op_type == MTS_WRITE) { if (*data & SWint_X) { *(m_uint16_t *) (ram_base + PP_BufEvent) |= SWint; //*(m_uint16_t*)(ram_base+PP_ISQ) &= ~0x3f; *(m_uint16_t *) (ram_base + PP_ISQ) |= BufEvent; dev_cs8900_gen_interrupt (d); } if (*data & Rdy4TxiE) { /*if host set rdy4tx, we are always ready for tx */ *(m_uint16_t *) (ram_base + PP_BufEvent) |= Rdy4Tx; //*(m_uint16_t*)(ram_base+PP_ISQ) &= ~0x3f; *(m_uint16_t *) (ram_base + PP_ISQ) |= BufEvent; dev_cs8900_gen_interrupt (d); } *(m_uint16_t *) (ram_base + PP_BufCFG) = *data | 0xb; *has_set_value = TRUE; return NULL; } else return (void *) (ram_base + io_address); case PP_LineCTL: if (op_type == MTS_WRITE) { *(m_uint16_t *) (ram_base + PP_LineCTL) = *data | 0x13; if ((*data & SerRxON) || (*data & SerTxON)) dev_cs8900_active_timer (d); *has_set_value = TRUE; return NULL; } else return (void *) (ram_base + io_address); case PP_SelfCTL: if (op_type == MTS_WRITE) { if (*data & RESET) { dev_cs8900_reset (cpu, dev); } *(m_uint16_t *) (ram_base + PP_SelfCTL) = *data | 0x15; *has_set_value = TRUE; return NULL; } else return (void *) (ram_base + io_address); case PP_BusCTL: if (op_type == MTS_WRITE) { *(m_uint16_t *) (ram_base + PP_BusCTL) = *data | 0x17; *has_set_value = TRUE; return NULL; } else return (void *) (ram_base + io_address); case PP_TestCTL: if (op_type == MTS_WRITE) { *(m_uint16_t *) (ram_base + PP_TestCTL) = *data | 0x19; *has_set_value = TRUE; return NULL; } else return (void *) (ram_base + io_address); case PP_ISQ: isq = *(m_uint16_t *) (ram_base + PP_ISQ); if (op_type == MTS_WRITE) { *(m_uint16_t *) (ram_base + PP_ISQ) = 0; *has_set_value = TRUE; return NULL; } /*Readonly? But sometimes, kernel will write to this register. */ //ASSERT(op_type == MTS_READ, "wirte to read only register io_address %x.", io_address); /*SHOULD be read */ if (isq & TxEvent) { *(m_uint16_t *) (ram_base + PP_ISQ) &= ~TxEvent; *(m_uint16_t *) data = *(m_uint16_t *) (ram_base + PP_TxEvent); *(m_uint16_t *) (ram_base + PP_TxEvent) = 0X8; //return (void*)(ram_base+PP_TxEvent); } else if (isq & RxEvent) { *(m_uint16_t *) (ram_base + PP_ISQ) &= ~RxEvent; *(m_uint16_t *) data = *(m_uint16_t *) (ram_base + PP_RxEvent); *(m_uint16_t *) (ram_base + PP_RxEvent) = 0X4; //return (void*)(ram_base+PP_RxEvent); } else if (isq & BufEvent) { *(m_uint16_t *) (ram_base + PP_ISQ) &= ~BufEvent; *(m_uint16_t *) data = *(m_uint16_t *) (ram_base + PP_BufEvent); *(m_uint16_t *) (ram_base + PP_BufEvent) = 0Xc; //return (void*)(ram_base+PP_BufEvent); } else if (isq & RxMISS) { *(m_uint16_t *) (ram_base + PP_ISQ) &= ~RxMISS; *(m_uint16_t *) data = *(m_uint16_t *) (ram_base + PP_RxMISS); *(m_uint16_t *) (ram_base + PP_RxMISS) = 0x10; //return (void*)(ram_base+PP_RxMISS); } else if (isq & TxCOL) { *(m_uint16_t *) (ram_base + PP_ISQ) &= ~TxCOL; *(m_uint16_t *) data = *(m_uint16_t *) (ram_base + PP_TxCOL); *(m_uint16_t *) (ram_base + PP_TxCOL) = 0x12; //return (void*)(ram_base+PP_TxCOL); } else { return (void *) (ram_base + PP_ISQ); } *has_set_value = TRUE; return NULL; break; case PP_RxEvent: /*read rx event will clear it */ ASSERT (op_type == MTS_READ, "CS8900 write to read only register. IO address %x \n", io_address); *(m_uint16_t *) data = *(m_uint16_t *) (ram_base + PP_RxEvent); *has_set_value = TRUE; *(m_uint16_t *) (ram_base + PP_RxEvent) = 0X4; return NULL; case PP_TxEvent: /*read tx event will clear it */ ASSERT (op_type == MTS_READ, "CS8900 write to read only register. IO address %x \n", io_address); *(m_uint16_t *) data = *(m_uint16_t *) (ram_base + PP_TxEvent); *has_set_value = TRUE; *(m_uint16_t *) (ram_base + PP_TxEvent) = 0X8; return NULL; case PP_BufEvent: /*read BufEvent event will clear it */ ASSERT (op_type == MTS_READ, "CS8900 write to read only register. IO address %x \n", io_address); *(m_uint16_t *) data = *(m_uint16_t *) (ram_base + PP_BufEvent); *has_set_value = TRUE; *(m_uint16_t *) (ram_base + PP_BufEvent) = 0Xc; return NULL; case PP_RxMISS: case PP_TxCOL: case PP_LineST: case PP_SelfST: case PP_TDR: ASSERT (op_type == MTS_READ, "CS8900 write to read only register. IO address %x \n", io_address); return (void *) (ram_base + io_address); case PP_BusST: *(m_uint16_t *) (ram_base + PP_BusST) |= Rdy4TxNOW; //else //{ // *(m_uint16_t*)(ram_base+PP_BusST) &= ~Rdy4TxNOW; //} return (void *) (ram_base + io_address); case PP_TxCMD: ASSERT (op_type == MTS_WRITE, "CS8900 read write only register. IO address %x \n", PP_TxCMD); *(m_uint16_t *) (ram_base + PP_TxCMD) = *data | 0x9; *has_set_value = TRUE; return NULL; case PP_TxLength: ASSERT (op_type == MTS_WRITE, "CS8900 read write only register. IO address %x \n", PP_TxLength); *(m_uint16_t *) (ram_base + PP_TxLength) = *data; *has_set_value = TRUE; if (*(m_uint16_t *) (ram_base + PP_TxLength) > 1518) { *(m_uint16_t *) (ram_base + PP_BusST) |= TxBidErr; } else if (*(m_uint16_t *) (ram_base + PP_TxLength) > 1514) { if (!((*(m_uint16_t *) (ram_base + PP_TxCMD)) & InhibitCRC)) *(m_uint16_t *) (ram_base + PP_BusST) |= TxBidErr; else *(m_uint16_t *) (ram_base + PP_BusST) &= ~TxBidErr; } else *(m_uint16_t *) (ram_base + PP_BusST) &= ~TxBidErr; return NULL; case PP_LAF: case PP_LAF + 1: case PP_LAF + 2: case PP_LAF + 3: case PP_LAF + 4: case PP_LAF + 5: case PP_LAF + 6: case PP_LAF + 7: case PP_IA: case PP_IA + 1: case PP_IA + 2: case PP_IA + 3: case PP_IA + 4: case PP_IA + 5: case PP_RxStatus: case PP_RxLength: return (void *) (ram_base + io_address); default: ASSERT (0, "error io address %x\n", io_address); } } return NULL; } struct cs8900_data *dev_cs8900_init (vm_instance_t * vm, char *name, m_pa_t phys_addr, m_uint32_t phys_len, int irq) { struct cs8900_data *d; /* Allocate the private data structure for DEC21140 */ if (!(d = malloc (sizeof (*d)))) { fprintf (stderr, "%s (cs8900_data): out of memory\n", name); return NULL; } memset (d, 0, sizeof (*d)); /* Create the device itself */ if (!(d->dev = dev_create (name))) { fprintf (stderr, "%s (DEC21140): unable to create device.\n", name); goto err_dev; } d->irq_no = irq; d->vm = vm; d->dev->priv_data = d; d->dev->phys_addr = phys_addr; d->dev->phys_len = phys_len; d->cs8900_size = phys_len; d->dev->handler = dev_cs8900_access; d->dev->reset_handler = dev_cs8900_reset; d->dev->flags = VDEVICE_FLAG_NO_MTS_MMAP; d->cs8900_timer = vp_new_timer (rt_clock, dev_cs8900_cb, d); vm_bind_device (vm, d->dev); return (d); err_dev: free (d); return NULL; } int dev_cs8900_set_nio (struct cs8900_data *d, netio_desc_t * nio) { /* check that a NIO is not already bound */ if (d->nio != NULL) return (-1); d->nio = nio; return (0); } ================================================ FILE: tools/virtualmips/dev_cs8900.h ================================================ /* * Copyright (C) yajin 2008 * * This file is part of the virtualmips distribution. * See LICENSE file for terms of the license. * */ #ifndef __DEV_CS8900_H__ #define __DEV_CS8900_H__ #include "utils.h" #include "cpu.h" #include "vm.h" #include "mips_memory.h" #include "device.h" #include "net.h" #include "net_io.h" #include "vp_timer.h" #define CS8900_INTERNAL_RAM_SIZE 0x1000 /*4K */ /* CS8900 Data */ struct cs8900_data { char *name; m_uint32_t cs8900_size; /* Device information */ struct vdevice *dev; /* Virtual machine */ vm_instance_t *vm; /* NetIO descriptor */ netio_desc_t *nio; /*one nio can have multi listener */ /*internal RAM 4K bytes */ m_uint32_t internal_ram[CS8900_INTERNAL_RAM_SIZE / 4]; m_uint32_t irq_no; m_uint16_t rx_read_index; m_uint16_t tx_send_index; vp_timer_t *cs8900_timer; // m_uint8_t want_tx; // m_uint8_t want_rx; }; int dev_cs8900_set_nio (struct cs8900_data *d, netio_desc_t * nio); struct cs8900_data *dev_cs8900_init (vm_instance_t * vm, char *name, m_pa_t phys_addr, m_uint32_t phys_len, int irq); #endif ================================================ FILE: tools/virtualmips/dev_nand_flash_1g.c ================================================ /* * Copyright (C) yajin 2008 * * This file is part of the virtualmips distribution. * See LICENSE file for terms of the license. * */ /* 1G bytes nand flash emulation. Samsung K9F8G08 1GB 1G bytes nand flash are stored in file nandflash8g.0-nandflash8g.8191 (8192 blocks). The flash file only be created when writing to block (copy on write). Please use tool/mknandflash to create init nand file of u-boot image. */ /* supported operation: READ Read for copy back Read ID Reset Page program Copy-back Block erase Random data input Random data output */ #include #include #include #include #include #include #include #include #include #include #include #include "device.h" #include "mips_memory.h" #include "dev_nand_flash_1g.h" m_uint8_t id_info[5] = { 0xec, 0xd3, 0x51, 0x95, 0x58 }; #define NAND_STATUS_READY 0x40 #define NAND_STATUS_WP 0x80 /*status ready & not write protected*/ /*I am always ready. haha. Better than real nand flash :)*/ m_uint8_t nand_status = NAND_STATUS_READY | NAND_STATUS_WP; #ifdef CPU_LOG #undef CPU_LOG #endif //#define DEBUG_FLASH_ACCESS #ifdef DEBUG_FLASH_ACCESS #define CPU_LOG(arg1) cpu_log arg1 #else #define CPU_LOG(arg1) #endif /*Create nand flash file. 1 block 1 file.*/ static unsigned char *create_nand_flash_file (m_uint32_t block_no) { char file_path[512]; char page[NAND_FLASH_1G_PAGE_SIZE]; int i, n; int fd; unsigned char *ret; /*create nand flash file when writing */ snprintf (file_path, sizeof (file_path), "%s/%s.%d", NAND_FLASH_1G_FILE_DIR, NAND_FLASH_1G_FILE_PREFIX, block_no); fd = open (file_path, O_RDWR | O_CREAT, S_IREAD | S_IWRITE | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH); assert (fd >= 0); for (i = 0; i < NAND_FLASH_1G_PAGES_PER_BLOCK; i++) { memset (page, 0xff, NAND_FLASH_1G_PAGE_SIZE); n = write (fd, page, NAND_FLASH_1G_PAGE_SIZE); assert (n == NAND_FLASH_1G_PAGE_SIZE); } ret = memzone_map_file (fd, NAND_FLASH_1G_BLOCK_SIZE); assert (ret != NULL); return ret; } /*get the page pointer given row addr and block start address*/ unsigned char *get_nand_flash_page_ptr (m_uint32_t row_addr, unsigned char *block_start) { m_uint32_t block_no = row_addr >> NAND_FLASH_1G_BLOCK_PAGE_OFFSET; m_uint32_t page_no = row_addr & NAND_FLASH_1G_BLOCK_PAGE_MASK; assert (block_no < NAND_FLASH_1G_TOTAL_BLOCKS); assert (block_start != NULL); return (block_start + page_no * NAND_FLASH_1G_PAGE_SIZE); } static void nand_flash_erase_block (unsigned char *block_start) { memset (block_start, 0xff, NAND_FLASH_1G_BLOCK_SIZE); } /*write data to nand file (1 page)*/ static void write_nand_flash_page_file (m_uint32_t row_addr, unsigned char *block_start, unsigned char *write_data) { unsigned char *page_ptr; int i; page_ptr = get_nand_flash_page_ptr (row_addr, block_start); /*we only copy different data into page */ for (i = 0; i < NAND_FLASH_1G_PAGE_SIZE; i++) { if (*(write_data + i) == 0XFF) continue; if ((*(page_ptr + i)) != (*(write_data + i))) { *(page_ptr + i) = *(write_data + i); } } } char *state_string[8] = { "STATE_INIT", "STATE_READ_START", "STATE_RANDOM_READ_START", "STATE_WRITE_START", "STATE_RANDOM_WRITE_START", "STATE_READ_PAGE_FOR_COPY_WRITE", "STATE_COPY_START", "STATE_ERASE_START", }; void *dev_nand_flash_1g_access (cpu_mips_t * cpu, struct vdevice *dev, m_uint32_t offset, u_int op_size, u_int op_type, m_uint32_t * data, m_uint8_t * has_set_value) { nand_flash_1g_data_t *d = dev->priv_data; m_uint32_t block_no; void *ret; /*COMMAND PORT */ if (offset == NAND_COMMPORT_OFFSET) { /*clear addr offset */ d->addr_offset = 0; switch (d->state) { case STATE_INIT: if (((*data) & 0xff) == 0x00) d->state = STATE_READ_START; else if (((*data) & 0xff) == 0x80) { memset (d->write_buffer, 0xff, NAND_FLASH_1G_PAGE_SIZE); d->state = STATE_WRITE_START; } else if (((*data) & 0xff) == 0x05) { assert (d->has_issue_30h == 1); d->state = STATE_RANDOM_READ_START; d->has_issue_30h = 0; } else if (((*data) & 0xff) == 0xFF) { /*reset */ d->state = STATE_INIT; } else if (((*data) & 0xff) == 0x90) { /*read ID */ d->data_port_ipr = id_info; d->state = STATE_INIT; d->read_offset = 0; } else if (((*data) & 0xff) == 0x60) { /*ERASE */ d->state = STATE_ERASE_START; /*erase only need row address. adjust addr_offset */ d->addr_offset = 2; } else if (((*data) & 0xff) == 0x70) { /*READ STATUS */ d->state = STATE_INIT; d->read_offset = 0; d->data_port_ipr = &nand_status; } else ASSERT (0, "*data %x\n", *data); break; case STATE_ERASE_START: if (((*data) & 0xff) == 0xd0) { //erase blcok block_no = (d->row_addr) >> NAND_FLASH_1G_BLOCK_PAGE_OFFSET; if (d->flash_map[block_no] == NULL) d->flash_map[block_no] = create_nand_flash_file (block_no); nand_flash_erase_block (d->flash_map[block_no]); d->state = STATE_INIT; } else assert (0); break; case STATE_READ_START: if (((*data) & 0xff) == 0x30) { d->has_issue_30h = 1; d->state = STATE_INIT; block_no = (d->row_addr) >> NAND_FLASH_1G_BLOCK_PAGE_OFFSET; if (d->flash_map[block_no] == NULL) { CPU_LOG ((cpu, "", "block_no %x is null. redirect to fake page.", block_no)); d->data_port_ipr = get_nand_flash_page_ptr (d->row_addr, d->fake_block); } else d->data_port_ipr = get_nand_flash_page_ptr (d->row_addr, d->flash_map[block_no]); d->read_offset = d->col_addr; CPU_LOG ((cpu, "", "d->read_offset %x d->col_addr %x.", d->read_offset, d->col_addr)); } else if (((*data) & 0xff) == 0x35) { d->state = STATE_READ_PAGE_FOR_COPY_WRITE; block_no = (d->row_addr) >> NAND_FLASH_1G_BLOCK_PAGE_OFFSET; memset (d->write_buffer, 0xff, NAND_FLASH_1G_PAGE_SIZE); } else if (((*data) & 0xff) == 0xFF) { /*reset */ d->state = STATE_INIT; } else assert (0); break; case STATE_RANDOM_READ_START: if (((*data) & 0xff) == 0xe0) { d->state = STATE_INIT; block_no = (d->row_addr) >> NAND_FLASH_1G_BLOCK_PAGE_OFFSET; if (d->flash_map[block_no] == NULL) { CPU_LOG ((cpu, "", "block_no %x is null. redirect to fake page.", block_no)); d->data_port_ipr = get_nand_flash_page_ptr (d->row_addr, d->fake_block); } else d->data_port_ipr = get_nand_flash_page_ptr (d->row_addr, d->flash_map[block_no]); d->read_offset = d->col_addr; } else if (((*data) & 0xff) == 0x05) { d->state = STATE_RANDOM_READ_START; } else assert (0); break; case STATE_WRITE_START: if (((*data) & 0xff) == 0x10) { d->state = STATE_INIT; block_no = (d->row_addr) >> NAND_FLASH_1G_BLOCK_PAGE_OFFSET; if (d->flash_map[block_no] == NULL) d->flash_map[block_no] = create_nand_flash_file (block_no); write_nand_flash_page_file (d->row_addr, d->flash_map[block_no], d->write_buffer); d->write_offset = 0; } else if (((*data) & 0xff) == 0x85) { d->write_offset = 0; d->state = STATE_RANDOM_WRITE_START; } else assert (0); break; case STATE_RANDOM_WRITE_START: if (((*data) & 0xff) == 0x10) { d->state = STATE_INIT; block_no = (d->row_addr) >> NAND_FLASH_1G_BLOCK_PAGE_OFFSET; if (d->flash_map[block_no] == NULL) d->flash_map[block_no] = create_nand_flash_file (block_no); write_nand_flash_page_file (d->row_addr, d->flash_map[block_no], d->write_buffer); d->write_offset = 0; } else if (((*data) & 0xff) == 0x85) { d->write_offset = 0; d->state = STATE_RANDOM_WRITE_START; } else assert (0); break; case STATE_READ_PAGE_FOR_COPY_WRITE: if (((*data) & 0xff) == 0x85) { d->write_offset = 0; d->state = STATE_COPY_START; } else assert (0); break; case STATE_COPY_START: if (((*data) & 0xff) == 0x10) { d->state = STATE_INIT; block_no = (d->row_addr) >> NAND_FLASH_1G_BLOCK_PAGE_OFFSET; if (d->flash_map[block_no] == NULL) d->flash_map[block_no] = create_nand_flash_file (block_no); write_nand_flash_page_file (d->row_addr, d->flash_map[block_no], d->write_buffer); d->write_offset = 0; } else if (((*data) & 0xff) == 0x85) { d->write_offset = 0; d->state = STATE_RANDOM_WRITE_START; } else assert (0); break; default: assert (0); } CPU_LOG ((cpu, "", " state %s\n", state_string[d->state])); } else if (offset == NAND_DATAPORT_OFFSET) { *has_set_value = FALSE; if (op_type == MTS_READ) { /*data port */ CPU_LOG ((cpu, "", "pc %x data %x d->read_offset %x d->data_port_ipr %x \n", cpu->pc, *(d->data_port_ipr + d->read_offset), d->read_offset, d->data_port_ipr)); ret = (void *) (d->data_port_ipr + d->read_offset); d->read_offset++; return ret; } else if (op_type == MTS_WRITE) { ret = (void *) (d->write_buffer + d->col_addr + d->write_offset); d->write_offset++; return ret; } assert (0); } else if (offset == NAND_ADDRPORT_OFFSET) { CPU_LOG ((cpu, "", "ADDRESS pc %x d->addr_offset %x *data %x \n", cpu->pc, d->addr_offset, *data)); /*ADDRESS PORT */ assert (op_type == MTS_WRITE); *has_set_value = TRUE; switch (d->addr_offset) { case 0x0: d->col_addr = (*data) & 0xff; break; case 0x01: d->col_addr += ((*data) & 0xff) << 8; break; case 0x2: d->row_addr = (*data) & 0xff; break; case 0x03: d->row_addr += ((*data) & 0xff) << 8; break; case 0x04: d->row_addr += ((*data) & 0xff) << 16; break; default: assert (0); } CPU_LOG ((cpu, "", "col_addr %x row_addr %x\n", d->col_addr, d->row_addr)); d->addr_offset++; } *has_set_value = TRUE; return NULL; } static int load_nand_flash_file (nand_flash_1g_data_t * d) { int i, j = 0; struct dirent *ent = NULL; DIR *p_dir; char file_path[512]; char *file_name; char block_number[16]; int fd; //nand_flash_1g_data_t *d=*nand_flash; memset (d->flash_map, 0x0, NAND_FLASH_1G_TOTAL_BLOCKS * sizeof (d->flash_map[0])); p_dir = opendir (NAND_FLASH_1G_FILE_DIR); if (NULL == p_dir) { fprintf (stderr, "NAND FLASH: Can not open nand flash file directory \"%s\".\n", NAND_FLASH_1G_FILE_DIR); goto err_flash_map_create; } while (NULL != (ent = readdir (p_dir))) { //we only take care file if (ent->d_type == DT_DIR) continue; snprintf (file_path, sizeof (file_path), "%s/%s", NAND_FLASH_1G_FILE_DIR, ent->d_name); if (get_file_size (file_path) != NAND_FLASH_1G_BLOCK_SIZE) continue; file_name = strdup (ent->d_name); for (i = strlen (file_name) - 1; i >= 0; i--) { if (file_name[i] == '.') break; } if (i == -1) { //not a valid flash file continue; } file_name[i] = '\0'; if (strcmp (file_name, NAND_FLASH_1G_FILE_PREFIX) != 0) { continue; } free (file_name); file_name = strdup (ent->d_name); //get the block number strncpy (block_number, file_name + i + 1, strlen (file_name) - i - 1); block_number[strlen (file_name) - i - 1] = '\0'; i = atoi (block_number); fd = open (file_path, O_RDWR); if (fd < 0) goto err_open_flash_file; d->flash_map[i] = memzone_map_file (fd, NAND_FLASH_1G_BLOCK_SIZE); if (d->flash_map[i] == NULL) goto err_map_flash_file; close (fd); free (file_name); j++; } closedir (p_dir); printf ("\nloaded %d nand flash file from directory \"%s\". \n", j, NAND_FLASH_1G_FILE_DIR); return (0); err_map_flash_file: close (fd); err_open_flash_file: free (file_name); err_flash_map_create: return (-1); } void dev_nand_flash_1g_reset (cpu_mips_t * cpu, struct vdevice *dev) { nand_flash_1g_data_t *d = dev->priv_data; memset (d->fake_block, 0xff, NAND_FLASH_1G_BLOCK_SIZE); d->state = STATE_INIT; memset (d->write_buffer, 0xff, NAND_FLASH_1G_PAGE_SIZE); } int dev_nand_flash_1g_init (vm_instance_t * vm, char *name, m_pa_t phys_addr, m_uint32_t phys_len, nand_flash_1g_data_t ** nand_flash) { nand_flash_1g_data_t *d; /* allocate the private data structure */ if (!(d = malloc (sizeof (*d)))) { fprintf (stderr, "NAND FLASH: unable to create device.\n"); return (-1); } memset (d, 0, sizeof (*d)); /*load all flash data to d->flash_map */ if (load_nand_flash_file (d) == -1) return (-1); /*set fake_page * We only create nand flash file when writing to a blcok. * When reading from a block which has not been written, give it the fake_page. */ memset (d->fake_block, 0xff, NAND_FLASH_1G_BLOCK_SIZE); d->state = STATE_INIT; memset (d->write_buffer, 0xff, NAND_FLASH_1G_PAGE_SIZE); if (!(d->dev = dev_create (name))) goto err_dev_create; d->dev->priv_data = d; d->dev->handler = dev_nand_flash_1g_access; d->dev->reset_handler = dev_nand_flash_1g_reset; /*NAND COMMPORT AND DATA PORT ADDRESS */ d->dev->phys_addr = phys_addr; d->dev->phys_len = phys_len; d->dev->flags = VDEVICE_FLAG_NO_MTS_MMAP; /* Map this device to the VM */ vm_bind_device (vm, d->dev); *nand_flash = d; return (0); err_dev_create: free (d); return (-1); } ================================================ FILE: tools/virtualmips/dev_nand_flash_1g.h ================================================ /* * Copyright (C) yajin 2008 * * This file is part of the virtualmips distribution. * See LICENSE file for terms of the license. * */ #ifndef __DEV_NAND_FLASH_1G_H__ #define __DEV_NAND_FLASH_1G_H__ #include "utils.h" #define NAND_FLASH_1G_BLOCK_PAGE_OFFSET 0x6 /*64 page in a blcok */ #define NAND_FLASH_1G_BLOCK_PAGE_MASK 0x3f #define NAND_FLASH_1G_TOTAL_SIZE 0x42000000 /*1G data BYTES +32M bytes SPARE BYTES */ #define NAND_FLASH_1G_TOTAL_PLANE 4 #define NAND_FLASH_1G_TOTAL_PAGES 0x80000 #define NAND_FLASH_1G_TOTAL_BLOCKS 0x2000 #define NAND_FLASH_1G_PAGES_PER_BLOCK 0x40 #define NAND_FLASH_1G_PAGE_SIZE 0x840 /*2k bytes date size+64 bytes spare size */ #define NAND_FLASH_1G_SPARE_SIZE 0x40 /*64 bytes */ #define NAND_FLASH_1G_BLOCK_SIZE 0x21000 /*132k bytes */ #define NAND_FLASH_1G_PAGE_DATA_SIZE 0x800 /*2k bytes */ #define NAND_FLASH_1G_BLOCK_DATA_SIZE 0x20000 /*128k bytes */ #define NAND_FLASH_1G_BLOCK_OFFSET(x) (NAND_FLASH_1G_BLOCK_SIZE*x) #define NAND_FLASH_1G_PAGE_OFFSET(x) (NAND_FLASH_1G_PAGE_SIZE*x) #define NAND_FLASH_1G_FILE_PREFIX "nandflash1GB" #define NAND_FLASH_1G_FILE_DIR "nandflash1GB" /*NAND_FLASH_STATE*/ #define STATE_INIT 0x0 #define STATE_READ_START 0x1 #define STATE_RANDOM_READ_START 0x2 #define STATE_WRITE_START 0x3 #define STATE_RANDOM_WRITE_START 0x4 #define STATE_READ_PAGE_FOR_COPY_WRITE 0x5 #define STATE_COPY_START 0x6 #define STATE_ERASE_START 0x7 #define NAND_DATAPORT_OFFSET 0x00000000 #define NAND_ADDRPORT_OFFSET 0x00010000 #define NAND_COMMPORT_OFFSET 0x00008000 /* nand flash private data */ struct nand_flash_1g_data { struct vdevice *dev; int state; unsigned char *flash_map[NAND_FLASH_1G_TOTAL_BLOCKS]; unsigned char fake_block[NAND_FLASH_1G_BLOCK_SIZE]; m_uint32_t row_addr; m_uint32_t col_addr; unsigned char write_buffer[NAND_FLASH_1G_PAGE_SIZE]; //for copy back m_uint32_t read_offset; m_uint32_t write_offset; m_uint32_t addr_offset; m_uint8_t has_issue_30h; /*for nand flash read */ unsigned char *data_port_ipr; }; typedef struct nand_flash_1g_data nand_flash_1g_data_t; unsigned char *get_nand_flash_page_ptr (m_uint32_t row_addr, unsigned char *block_start); int dev_nand_flash_1g_init (vm_instance_t * vm, char *name, m_pa_t phys_addr, m_uint32_t phys_len, nand_flash_1g_data_t ** nand_flash); #endif ================================================ FILE: tools/virtualmips/dev_nor_flash_4m.c ================================================ /* * Copyright (C) yajin 2008 * * This file is part of the virtualmips distribution. * See LICENSE file for terms of the license. */ /* 4M *byte* FLASH device simulation (device id=22F9h). Most important part of flash simulation is CFI interface. See flash datasheet for details. */ #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include "device.h" #include "mips_memory.h" #define ROM_INIT_STATE 0 /* flash private data */ struct flash_data { struct vdevice *dev; m_uint8_t *flash_ptr; m_uint32_t flash_size; m_uint8_t *flash_file_name; m_uint32_t state; int flash_fd; }; typedef struct flash_data flash_data_t; #define BPTR(d,offset) (((char *)d->flash_ptr) + offset) m_uint16_t vendorID = 0x01; // target is little end 0x0001 m_uint16_t deviceID = 0x22f9; // target is little end 0x22F9 m_uint16_t earse_ready = 0x80; // target is little end 0X0080 m_uint32_t last_offset = 0; m_uint32_t dump_data; m_uint32_t cfi_data[] = { 0x51, 0x52, 0x59, 0x2, 0x0, 0x40, 0x0, 0x0, 0x0, 0x0, 0x0, 0x27, 0x36, 0x0, 0x0, 0x4, 0x0, 0xa, 0x0, 0x5, 0x0, 0x4, 0x0, 0x16, 0x2, 0x0, 0x0, 0x0, 0x2, 0x7, 0x0, 0x20, 0x0, 0x3e, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x50, 0x52, 0x49, 0x31, 0x31, 0x0, 0x2, 0x4, 0x1, 0x4, 0x0, 0x0, 0x0, 0xb5, 0xc5, 0x2, //02 BOTTOM }; static void secotor_info (m_uint32_t offset, m_uint32_t * sector_start, m_uint32_t * sector_size) { if (offset <= 0x00FFF) { *sector_start = offset & 0xFFFFFE00; *sector_size = 0x2000; return; } *sector_start = offset & (0xffff0000); *sector_size = 0x10000; } void *dev_flash_access (cpu_mips_t * cpu, struct vdevice *dev, m_uint32_t offset, u_int op_size, u_int op_type, m_uint32_t * data, m_uint8_t * has_set_value) { flash_data_t *d = dev->priv_data; m_uint32_t r_offset, sector_size, sector_start; m_uint32_t last_sector_start, last_sector_size; if (offset >= d->flash_size) { *data = 0; return NULL; } if (op_type == MTS_READ) { switch (d->state) { case 0: return (BPTR (d, offset)); case 99: /*cfi query */ if ((offset >= 0x20) && (offset <= 0x9e)) { *data = (cfi_data[(offset - 0x20) / 2]); //always littleend *has_set_value = TRUE; } else { d->state = 0; return (BPTR (d, offset)); } break; case 0x6: d->state = 0; if (offset == 0X0) return &vendorID; if (offset == 0X2) return &deviceID; break; case 10: //last cycle is chip erase or sector erase secotor_info (offset, §or_start, §or_size); secotor_info (last_offset, &last_sector_start, &last_sector_size); d->state = 0; if (last_sector_start == sector_start) return &earse_ready; else return (BPTR (d, offset)); break; default: cpu_log (cpu, dev->name, "read: unhandled state %d\n", d->state); } return NULL; } if (op_type == MTS_WRITE) { r_offset = offset; if ((op_size == MTS_HALF_WORD) && (offset == 0X554)) offset = 0X555; switch (d->state) { case ROM_INIT_STATE: switch (offset) { case 0xAAA: if (((*data) & 0xff) == 0xAA) d->state = 1; break; case 0XAA: if (((*data) & 0xff) == 0x98) { d->state = 99; //CFI QUERY } break; default: switch ((*data) & 0xff) { case 0xB0: /* Erase/Program Suspend */ d->state = 0; break; case 0x30: /* Erase/Program Resume */ d->state = 0; break; case 0xF0: case 0xFF: /*Read/Reset */ d->state = 0; break; default: return ((void *) (d->flash_ptr + r_offset)); } } break; case 99: if (((*data & 0xff) == 0xff) || ((*data & 0xff) == 0xf0)) d->state = 0; else return ((void *) (d->flash_ptr + r_offset)); break; case 1: if ((offset != 0x555) && ((*data & 0xff) != 0x55)) d->state = 0; else d->state = 2; break; case 2: d->state = 0; if (offset == 0xAAA) { switch ((*data) & 0xff) { case 0x80: d->state = 3; break; case 0xA0: /* Byte/Word program */ d->state = 4; break; case 0x90: /* Product ID Entry / Status of Block B protection */ d->state = 6; break; } } break; case 3: if ((offset != 0xAAA) && (*data != 0xAA)) d->state = 0; else d->state = 8; break; case 8: if ((offset != 0x555) && (*data != 0x55)) d->state = 0; else d->state = 9; break; case 9: d->state = 10; last_offset = r_offset; switch ((*data) & 0xff) { case 0x10: /* Chip Erase */ memset (BPTR (d, 0), 0, d->dev->phys_len); break; case 0x30: /* Sector Erase */ secotor_info (r_offset, §or_start, §or_size); break; } break; /* Byte/Word Program */ case 4: d->state = 0; return ((void *) (d->flash_ptr + r_offset)); break; default: cpu_log (cpu, dev->name, "write: unhandled state %d\n", d->state); } return &dump_data; } assert (0); } static int dev_flash_load (char *flash_file_name, m_uint32_t flash_len, unsigned char **flash_data_hp, u_int create) { int fd; struct stat sb; unsigned char *temp; fd = open (flash_file_name, O_RDWR); if ((fd < 0) && (create == 1)) { fprintf (stderr, "Can not open flash file. name %s\n", flash_file_name); fprintf (stderr, "creating flash file. name %s\n", flash_file_name); fd = open (flash_file_name, O_RDWR | O_CREAT, S_IREAD | S_IWRITE | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH); if (fd < 0) { fprintf (stderr, "Can not create flash file. name %s\n", flash_file_name); return (-1); } temp = malloc (flash_len); assert (temp != NULL); memset (temp, 0xff, flash_len); lseek (fd, 0, SEEK_SET); write (fd, (void *) temp, flash_len); free (temp); fprintf (stderr, "create flash file success. name %s\n", flash_file_name); lseek (fd, 0, SEEK_SET); } else if (fd < 0) { fprintf (stderr, "%s does not exist and not allowed to create.\n", flash_file_name); return (-1); } assert (fd >= 0); fstat (fd, &sb); if (flash_len < sb.st_size) { fprintf (stderr, "Too large flash file. flash len:%d M, flash file name %s," "flash file legth: %d bytes.\n", flash_len, flash_file_name, (int) sb.st_size); return (-1); } *flash_data_hp = mmap (NULL, sb.st_size, PROT_WRITE | PROT_READ, MAP_SHARED, fd, 0); if (*flash_data_hp == MAP_FAILED) { fprintf (stderr, "errno %d\n", errno); fprintf (stderr, "failed\n"); return (-1); } return 0; } /* Initialize a NOR Flash zone */ int dev_nor_flash_4m_init (vm_instance_t * vm, char *name) { flash_data_t *d; unsigned char *flash_data_hp; /*load rom data */ if (dev_flash_load (vm->flash_filename, vm->flash_size * 1048576, &flash_data_hp, 1) < 0) return (-1); /* allocate the private data structure */ if (!(d = malloc (sizeof (*d)))) { fprintf (stderr, "FLASH: unable to create device.\n"); return (-1); } memset (d, 0, sizeof (*d)); d->flash_ptr = flash_data_hp; d->flash_size = vm->flash_size * 1048576; d->state = ROM_INIT_STATE; if (!(d->dev = dev_create (name))) goto err_dev_create; d->dev->priv_data = d; d->dev->phys_addr = vm->flash_address; d->dev->phys_len = vm->flash_size * 1048576; d->dev->handler = dev_flash_access; d->dev->flags = VDEVICE_FLAG_NO_MTS_MMAP; /* Map this device to the VM */ vm_bind_device (vm, d->dev); return (0); err_dev_create: free (d); return (-1); } ================================================ FILE: tools/virtualmips/dev_ram.c ================================================ /* * Copyright (C) yajin 2008 * * This file is part of the virtualmips distribution. * See LICENSE file for terms of the license. * */ #define _GNU_SOURCE #include #include #include #include #include #include #include "vm.h" #include "mips_memory.h" #include "device.h" /* RAM private data */ struct ram_data { struct vdevice *dev; }; void dev_ram_reset (cpu_mips_t * cpu, struct vdevice *dev) { assert (dev->host_addr != 0); /*reset ram */ //memset ((unsigned char *) dev->host_addr, 0x0, dev->phys_len); } /* Initialize a RAM zone */ int dev_ram_init (vm_instance_t * vm, char *name, m_pa_t paddr, m_uint32_t len) { struct ram_data *d; /* allocate the private data structure */ if (!(d = malloc (sizeof (*d)))) { fprintf (stderr, "RAM: unable to create device.\n"); return (-1); } memset (d, 0, sizeof (*d)); if (!(d->dev = dev_create_ram (vm, name, paddr, len))) { fprintf (stderr, "RAM: unable to create device.\n"); goto err_dev_create; } d->dev->priv_data = d; d->dev->reset_handler = dev_ram_reset; return (0); err_dev_create: free (d); return (-1); } ================================================ FILE: tools/virtualmips/dev_sdcard.c ================================================ /* * SD/MMC card emulation. * * Copyright (C) 2011 Serge Vakulenko * * This file is part of the virtualmips distribution. * See LICENSE file for terms of the license. * */ #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include "vm.h" #include "mips_memory.h" #include "device.h" #include "dev_sdcard.h" //#define TRACE printf #ifndef TRACE #define TRACE(...) /*empty*/ #endif /* * Definitions for MMC/SDC commands. */ #define CMD_GO_IDLE (0x40+0) /* CMD0 */ #define CMD_SEND_OP_SDC (0x40+41) /* ACMD41 (SDC) */ #define CMD_SET_BLEN (0x40+16) #define CMD_SEND_IF_COND (0x40+8) #define CMD_SEND_CSD (0x40+9) #define CMD_STOP (0x40+12) #define CMD_READ_SINGLE (0x40+17) #define CMD_READ_MULTIPLE (0x40+18) #define CMD_SET_WBECNT (0x40+23) /* ACMD23 */ #define CMD_WRITE_SINGLE (0x40+24) #define CMD_WRITE_MULTIPLE (0x40+25) #define CMD_APP (0x40+55) /* CMD55 */ #define DATA_START_BLOCK 0xFE /* start data for single block */ #define STOP_TRAN_TOKEN 0xFD /* stop token for write multiple */ #define WRITE_MULTIPLE_TOKEN 0xFC /* start data for write multiple */ static void sdcard_read_data (int fd, unsigned offset, unsigned char *buf, unsigned blen) { /* Fill uninitialized blocks by FF: simulate real flash media. */ memset (buf, 0xFF, blen); if (lseek (fd, offset, 0) != offset) { printf ("sdcard: seek failed, offset %#x\n", offset); return; } if (read (fd, buf, blen) < 0) { printf ("sdcard: read failed, offset %#x\n", offset); return; } } static void sdcard_write_data (int fd, unsigned offset, unsigned char *buf, unsigned blen) { if (lseek (fd, offset, 0) != offset) { printf ("sdcard: seek failed, offset %#x\n", offset); return; } if (write (fd, buf, blen) != blen) { printf ("sdcard: write failed, offset %#x\n", offset); return; } } static void sdcard_reset (sdcard_t *d) { d->select = 0; d->blen = 512; d->count = 0; } /* * Reset sdcard. */ void dev_sdcard_reset (cpu_mips_t *cpu) { pic32_t *pic32 = (pic32_t*) cpu->vm->hw_data; sdcard_reset (&pic32->sdcard[0]); sdcard_reset (&pic32->sdcard[1]); } /* * Initialize SD card. */ int dev_sdcard_init (sdcard_t *d, char *name, unsigned mbytes, char *filename) { memset (d, 0, sizeof (*d)); d->name = name; if (mbytes == 0 || ! filename) { /* No SD card installed. */ return (0); } d->kbytes = mbytes * 1024; d->fd = open (filename, O_RDWR); if (d->fd < 0) { /* Fatal: no image available. */ perror (filename); return (-1); } return (0); } void dev_sdcard_select (cpu_mips_t *cpu, int unit, int on) { pic32_t *pic32 = (pic32_t*) cpu->vm->hw_data; sdcard_t *d = &pic32->sdcard[unit]; if (on) { //TRACE ("sdcard%d: (((\n", unit); d->select = 1; d->count = 0; } else { //TRACE ("sdcard%d: )))\n", unit); d->select = 0; } } /* * Data i/o: send byte to device. * Return received byte. */ unsigned dev_sdcard_io (cpu_mips_t *cpu, unsigned data) { pic32_t *pic32 = (pic32_t*) cpu->vm->hw_data; sdcard_t *d = pic32->sdcard[0].select ? &pic32->sdcard[0] : pic32->sdcard[1].select ? &pic32->sdcard[1] : 0; unsigned reply; if (! d || ! d->fd) { //TRACE ("sdcard: unselected i/o\n"); return 0xFF; } data = (unsigned char) data; reply = 0xFF; if (d->count == 0) { d->buf[0] = data; if (data != 0xFF) d->count++; } else { switch (d->buf[0]) { case CMD_GO_IDLE: /* CMD0: reset */ if (d->count >= 7) break; d->buf [d->count++] = data; if (d->count == 7) reply = 0x01; break; case CMD_APP: /* CMD55: application prefix */ if (d->count >= 7) break; d->buf [d->count++] = data; if (d->count == 7) { reply = 0; d->count = 0; } break; case CMD_SEND_OP_SDC: /* ACMD41: initialization */ if (d->count >= 7) break; d->buf [d->count++] = data; if (d->count == 7) reply = 0; break; case CMD_SET_BLEN: /* Set block length */ if (d->count >= 7) break; d->buf [d->count++] = data; if (d->count == 7) { d->blen = d->buf[1] << 24 | d->buf[2] << 16 | d->buf[3] << 8 | d->buf[4]; TRACE ("sdcard%d: set block length %u bytes\n", d->unit, d->blen); reply = (d->blen > 0 && d->blen <= 1024) ? 0 : 4; } break; case CMD_SET_WBECNT: /* Set write block erase count */ if (d->count >= 7) break; d->buf [d->count++] = data; if (d->count == 7) { d->wbecnt = d->buf[1] << 24 | d->buf[2] << 16 | d->buf[3] << 8 | d->buf[4]; TRACE ("sdcard%d: set write block erase count %u\n", d->unit, d->wbecnt); reply = 0; d->count = 0; } break; case CMD_SEND_CSD: /* Get card data */ if (d->count >= 7) break; d->buf [d->count++] = data; if (d->count == 7) { /* Send reply */ TRACE ("sdcard%d: send media size %u sectors\n", d->unit, d->kbytes * 2); reply = 0; d->limit = 16 + 3; d->count = 1; d->buf[0] = 0; d->buf[1] = DATA_START_BLOCK; d->buf[2+0] = 1 << 6; /* SDC ver 2.00 */ d->buf[2+1] = 0; d->buf[2+2] = 0; d->buf[2+3] = 0; d->buf[2+4] = 0; d->buf[2+5] = 0; d->buf[2+6] = 0; d->buf[2+7] = 0; d->buf[2+8] = (d->kbytes / 512 - 1) >> 8; d->buf[2+9] = d->kbytes / 512 - 1; d->buf[2+10] = 0; d->buf[2+11] = 0; d->buf[2+12] = 0; d->buf[2+13] = 0; d->buf[2+14] = 0; d->buf[2+15] = 0; d->buf[d->limit - 1] = 0xFF; d->buf[d->limit] = 0xFF; } break; case CMD_READ_SINGLE: /* Read block */ if (d->count >= 7) break; d->buf [d->count++] = data; if (d->count == 7) { /* Send reply */ reply = 0; d->offset = d->buf[1] << 24 | d->buf[2] << 16 | d->buf[3] << 8 | d->buf[4]; TRACE ("sdcard%d: read offset %#x, length %u kbytes\n", d->unit, d->offset, d->blen); d->limit = d->blen + 3; d->count = 1; d->buf[0] = 0; d->buf[1] = DATA_START_BLOCK; sdcard_read_data (d->fd, d->offset, &d->buf[2], d->blen); d->buf[d->limit - 1] = 0xFF; d->buf[d->limit] = 0xFF; } break; case CMD_READ_MULTIPLE: /* Read multiple blocks */ if (d->count >= 7) break; d->buf [d->count++] = data; if (d->count == 7) { /* Send reply */ reply = 0; d->read_multiple = 1; d->offset = d->buf[1] << 24 | d->buf[2] << 16 | d->buf[3] << 8 | d->buf[4]; TRACE ("sdcard%d: read offset %#x, length %u kbytes\n", d->unit, d->offset, d->blen); d->limit = d->blen + 3; d->count = 1; d->buf[0] = 0; d->buf[1] = DATA_START_BLOCK; sdcard_read_data (d->fd, d->offset, &d->buf[2], d->blen); d->buf[d->limit - 1] = 0xFF; d->buf[d->limit] = 0xFF; } break; case CMD_WRITE_SINGLE: /* Write block */ if (d->count >= sizeof (d->buf)) break; d->buf [d->count++] = data; if (d->count == 7) { /* Accept command */ reply = 0; d->offset = d->buf[1] << 24 | d->buf[2] << 16 | d->buf[3] << 8 | d->buf[4]; TRACE ("sdcard%d: write offset %#x\n", d->unit, d->offset); } else if (d->count == 7 + d->blen + 2 + 2) { if (d->buf[7] == DATA_START_BLOCK) { /* Accept data */ reply = 0x05; d->offset = d->buf[1] << 24 | d->buf[2] << 16 | d->buf[3] << 8 | d->buf[4]; sdcard_write_data (d->fd, d->offset, &d->buf[8], d->blen); TRACE ("sdcard%d: write data, length %u kbytes\n", d->unit, d->blen); } else { /* Reject data */ reply = 4; TRACE ("sdcard%d: reject write data, tag=%02x\n", d->unit, d->buf[7]); } } break; case CMD_WRITE_MULTIPLE: /* Write multiple blocks */ if (d->count >= 7) break; d->buf [d->count++] = data; if (d->count == 7) { /* Accept command */ reply = 0; d->offset = d->buf[1] << 24 | d->buf[2] << 16 | d->buf[3] << 8 | d->buf[4]; TRACE ("sdcard%d: write multiple offset %#x\n", d->unit, d->offset); d->count = 0; } break; case WRITE_MULTIPLE_TOKEN: /* Data for write-miltiple */ if (d->count >= sizeof (d->buf)) break; d->buf [d->count++] = data; if (d->count == 2 + d->blen + 2) { /* Accept data */ reply = 0x05; sdcard_write_data (d->fd, d->offset, &d->buf[1], d->blen); TRACE ("sdcard%d: write sector %u, length %u kbytes\n", d->unit, d->offset / 512, d->blen); d->offset += 512; d->count = 0; } break; case CMD_STOP: /* Stop read-multiple sequence */ if (d->count > 1) break; d->read_multiple = 0; reply = 0; break; case CMD_SEND_IF_COND: /* Stop read-multiple sequence */ if (d->count > 1) break; d->read_multiple = 0; reply = 4; /* Unknown command */ break; case 0: /* Reply */ if (d->count <= d->limit) { reply = d->buf [d->count++]; break; } if (d->read_multiple) { /* Next read-multiple block. */ d->offset += d->blen; d->count = 1; sdcard_read_data (d->fd, d->offset, &d->buf[2], d->blen); reply = 0; } break; default: /* Ignore */ break; } } //TRACE ("sdcard%d: send %02x, reply %02x\n", d->unit, data, reply); return reply; } ================================================ FILE: tools/virtualmips/dev_sdcard.h ================================================ /* * SecureDigital flash card. * * Copyright (C) 2011 Serge Vakulenko * * This file is part of the virtualmips distribution. * See LICENSE file for terms of the license. */ #ifndef __DEV_SD__ #define __DEV_SD__ /* SD card private data */ struct sdcard { char *name; /* Device name */ unsigned kbytes; /* Disk size */ int unit; /* Index (sd0 or sd1) */ int fd; /* Image file */ int select; /* Selected */ int read_multiple; /* Read-multiple mode */ unsigned blen; /* Block length */ unsigned wbecnt; /* Write block erase count */ unsigned offset; /* Read/write offset */ unsigned count; /* Byte count */ unsigned limit; /* Reply length */ unsigned char buf [1024 + 16]; }; typedef struct sdcard sdcard_t; int dev_sdcard_init (sdcard_t *d, char *devname, unsigned mbytes, char *filename); void dev_sdcard_reset (cpu_mips_t *cpu); void dev_sdcard_select (cpu_mips_t *cpu, int unit, int on); unsigned dev_sdcard_io (cpu_mips_t *cpu, unsigned data); #endif ================================================ FILE: tools/virtualmips/dev_swap.c ================================================ /* * RAM-based disk for swap. * * Copyright (C) 2011 Igor Mokos * Copyright (C) 2011 Serge Vakulenko * * This file is part of the virtualmips distribution. * See LICENSE file for terms of the license. * */ #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include "vm.h" #include "mips_memory.h" #include "device.h" #include "dev_swap.h" //#define TRACE printf #ifndef TRACE #define TRACE(...) /*empty*/ #endif /* * Reset swap. */ void dev_swap_reset (cpu_mips_t *cpu) { pic32_t *pic32 = (pic32_t*) cpu->vm->hw_data; pic32->swap.rd = 0; pic32->swap.wr = 0; pic32->swap.ldaddr = 0; pic32->swap.offset = 0; } /* * Initialize SD card. */ int dev_swap_init (swap_t *d, char *name) { memset (d, 0, sizeof (*d)); d->name = name; return (0); } void dev_swap_rd (cpu_mips_t *cpu, int on) { pic32_t *pic32 = (pic32_t*) cpu->vm->hw_data; swap_t *d = &pic32->swap; if (on && ! d->rd) { d->rd = 1; d->offset %= SWAP_BYTES; d->data = d->buf [d->offset]; TRACE ("swap: RD on, %06X -> %02X\n", d->offset, d->data); } else if (! on && d->rd) { d->rd = 0; d->offset++; TRACE ("swap: RD off, offset = %06X\n", d->offset); } } void dev_swap_wr (cpu_mips_t *cpu, int on) { pic32_t *pic32 = (pic32_t*) cpu->vm->hw_data; swap_t *d = &pic32->swap; if (on && ! d->wr) { d->wr = 1; d->offset %= SWAP_BYTES; d->buf [d->offset] = d->data; TRACE ("swap: WR on, %06X := %02X\n", d->offset, d->data); } else if (! on && d->wr) { d->wr = 0; d->offset++; TRACE ("swap: WR off, offset = %06X\n", d->offset); } } void dev_swap_ldaddr (cpu_mips_t *cpu, int on) { pic32_t *pic32 = (pic32_t*) cpu->vm->hw_data; swap_t *d = &pic32->swap; if (on && ! d->ldaddr) { d->ldaddr = 1; d->offset >>= 4; d->offset |= d->data << 20; TRACE ("swap: LDADDR on, offset = %06X\n", d->offset); } else if (! on && d->ldaddr) { TRACE ("swap: LDADDR off\n"); d->ldaddr = 0; } } /* * Data i/o: send byte to device. * Return received byte. */ unsigned dev_swap_io (cpu_mips_t *cpu, unsigned char newval, unsigned char rmask) { pic32_t *pic32 = (pic32_t*) cpu->vm->hw_data; swap_t *d = &pic32->swap; if (rmask == 0) { /* Write mode. */ //TRACE ("swap: send %02x\n", newval); d->data = newval; } else { //TRACE ("swap: receive %02x\n", d->data); } /* Read mode. */ return d->data; } ================================================ FILE: tools/virtualmips/dev_swap.h ================================================ /* * RAM-based disk for swap. * * Copyright (C) 2011 Igor Mokos * Copyright (C) 2011 Serge Vakulenko * * This file is part of the virtualmips distribution. * See LICENSE file for terms of the license. */ #ifndef __DEV_SWAP__ #define __DEV_SWAP__ #define SWAP_BYTES (2*1024*1024) /* Disk size */ /* Swap device private data */ struct swap { char *name; /* Device name */ int rd; /* RD signal */ int wr; /* WR signal */ int ldaddr; /* LDADDR signal */ unsigned char data; /* Latched byte */ unsigned offset; /* Read/write offset */ unsigned char buf [SWAP_BYTES]; /* Stored data */ }; typedef struct swap swap_t; int dev_swap_init (swap_t *d, char *devname); void dev_swap_reset (cpu_mips_t *cpu); void dev_swap_rd (cpu_mips_t *cpu, int on); void dev_swap_wr (cpu_mips_t *cpu, int on); void dev_swap_ldaddr (cpu_mips_t *cpu, int on); unsigned dev_swap_io (cpu_mips_t *cpu, unsigned char data, unsigned char mask); #endif ================================================ FILE: tools/virtualmips/dev_vtty.c ================================================ /* * Cisco router simulation platform. * Copyright (c) 2005,2006 Christophe Fillot (cf@utc.fr) * * Virtual console TTY. * * "Interactive" part idea by Mtve. * TCP console added by Mtve. * Serial console by Peter Ross (suxen_drol@hotmail.com) */ /* By default, Cygwin supports only 64 FDs with select()! */ /* * Copyright (C) yajin 2008 * * This file is part of the virtualmips distribution. * See LICENSE file for terms of the license. * */ #ifdef __CYGWIN__ #define FD_SETSIZE 1024 #endif #include #include #include #include #include #include #include #include #include #include #include #include "utils.h" #include "mips.h" #include "vm.h" #include "mips_exec.h" #include "device.h" #include "mips_memory.h" #include "dev_vtty.h" /* VTTY list */ static pthread_mutex_t vtty_list_mutex = PTHREAD_MUTEX_INITIALIZER; static vtty_t *vtty_list = NULL; static pthread_t vtty_thread; #define VTTY_LIST_LOCK() pthread_mutex_lock(&vtty_list_mutex); #define VTTY_LIST_UNLOCK() pthread_mutex_unlock(&vtty_list_mutex); static struct termios tios, tios_orig; /* Send Telnet command: WILL TELOPT_ECHO */ static void vtty_telnet_will_echo (vtty_t * vtty) { u_char cmd[] = { IAC, WILL, TELOPT_ECHO }; if (write (vtty->fd, cmd, sizeof (cmd)) < 0) perror ("vtty_telnet_will_echo"); } /* Send Telnet command: Suppress Go-Ahead */ static void vtty_telnet_will_suppress_go_ahead (vtty_t * vtty) { u_char cmd[] = { IAC, WILL, TELOPT_SGA }; if (write (vtty->fd, cmd, sizeof (cmd)) < 0) perror ("vtty_telnet_will_suppress_go_ahead"); } /* Send Telnet command: Don't use linemode */ static void vtty_telnet_dont_linemode (vtty_t * vtty) { u_char cmd[] = { IAC, DONT, TELOPT_LINEMODE }; if (write (vtty->fd, cmd, sizeof (cmd)) < 0) perror ("vtty_telnet_dont_linemode"); } /* Send Telnet command: does the client support terminal type message? */ static void vtty_telnet_do_ttype (vtty_t * vtty) { u_char cmd[] = { IAC, DO, TELOPT_TTYPE }; if (write (vtty->fd, cmd, sizeof (cmd)) < 0) perror ("vtty_telnet_do_ttype"); } /* Restore TTY original settings */ static void vtty_term_reset (void) { tcsetattr (STDIN_FILENO, TCSANOW, &tios_orig); } /* Initialize real TTY */ static void vtty_term_init (void) { tcgetattr (STDIN_FILENO, &tios); memcpy (&tios_orig, &tios, sizeof (struct termios)); atexit (vtty_term_reset); tios.c_cc[VTIME] = 0; tios.c_cc[VMIN] = 1; /* Disable Ctrl-C, Ctrl-S, Ctrl-Q and Ctrl-Z */ tios.c_cc[VINTR] = 0; tios.c_cc[VSTART] = 0; tios.c_cc[VSTOP] = 0; tios.c_cc[VSUSP] = 0; tios.c_lflag &= ~(ICANON | ECHO); tios.c_iflag &= ~ICRNL; tcsetattr (STDIN_FILENO, TCSANOW, &tios); tcflush (STDIN_FILENO, TCIFLUSH); } /* Wait for a TCP connection */ static int vtty_tcp_conn_wait (vtty_t * vtty) { struct sockaddr_in serv; int one = 1; vtty->state = VTTY_STATE_TCP_INVALID; if ((vtty->accept_fd = socket (PF_INET, SOCK_STREAM, 0)) < 0) { perror ("vtty_tcp_waitcon: socket"); return (-1); } if (setsockopt (vtty->accept_fd, SOL_SOCKET, SO_REUSEADDR, &one, sizeof (one)) < 0) { perror ("vtty_tcp_waitcon: setsockopt(SO_REUSEADDR)"); goto error; } memset (&serv, 0, sizeof (serv)); serv.sin_family = AF_INET; serv.sin_addr.s_addr = htonl (INADDR_ANY); serv.sin_port = htons (vtty->tcp_port); if (bind (vtty->accept_fd, (struct sockaddr *) &serv, sizeof (serv)) < 0) { perror ("vtty_tcp_waitcon: bind"); goto error; } if (listen (vtty->accept_fd, 1) < 0) { perror ("vtty_tcp_waitcon: listen"); goto error; } vm_log (vtty->vm, "VTTY", "%s: waiting connection on tcp port %d (FD %d)\n", vtty->name, vtty->tcp_port, vtty->accept_fd); vtty->select_fd = &vtty->accept_fd; vtty->state = VTTY_STATE_TCP_WAITING; return (0); error: close (vtty->accept_fd); vtty->accept_fd = -1; vtty->select_fd = NULL; return (-1); } /* Accept a TCP connection */ static int vtty_tcp_conn_accept (vtty_t * vtty) { if ((vtty->fd = accept (vtty->accept_fd, NULL, NULL)) < 0) { fprintf (stderr, "vtty_tcp_conn_accept: accept on port %d failed %s\n", vtty->tcp_port, strerror (errno)); return (-1); } vm_log (vtty->vm, "VTTY", "%s is now connected (accept_fd=%d,conn_fd=%d)\n", vtty->name, vtty->accept_fd, vtty->fd); /* Adapt Telnet settings */ if (vtty->terminal_support) { vtty_telnet_do_ttype (vtty); vtty_telnet_will_echo (vtty); vtty_telnet_will_suppress_go_ahead (vtty); vtty_telnet_dont_linemode (vtty); vtty->input_state = VTTY_INPUT_TELNET; } if (!(vtty->fstream = fdopen (vtty->fd, "wb"))) { close (vtty->fd); vtty->fd = -1; return (-1); } fprintf (vtty->fstream, "Connected to Dynamips VM \"%s\" ( type %s) - %s\r\n\r\n", vtty->vm->name, vm_get_type (vtty->vm), vtty->name); vtty->select_fd = &vtty->fd; vtty->state = VTTY_STATE_TCP_RUNNING; return (0); } /* * Parse serial interface descriptor string, return 0 if success * string takes the form "device:baudrate:databits:parity:stopbits:hwflow" * device is mandatory, other options are optional (default=9600,8,N,1,0). */ int vtty_parse_serial_option (vtty_serial_option_t * option, char *optarg) { char *array[6]; int count; if ((count = m_strtok (optarg, ':', array, 6)) < 1) { fprintf (stderr, "vtty_parse_serial_option: invalid string\n"); return (-1); } if (!(option->device = strdup (array[0]))) { fprintf (stderr, "vtty_parse_serial_option: unable to copy string\n"); return (-1); } option->baudrate = (count > 1) ? atoi (array[1]) : 9600; option->databits = (count > 2) ? atoi (array[2]) : 8; if (count > 3) { switch (*array[3]) { case 'o': case 'O': option->parity = 1; /* odd */ case 'e': case 'E': option->parity = 2; /* even */ default: option->parity = 0; /* none */ } } else { option->parity = 0; } option->stopbits = (count > 4) ? atoi (array[4]) : 1; option->hwflow = (count > 5) ? atoi (array[5]) : 0; return (0); } #if defined(__CYGWIN__) || defined(SUNOS) void cfmakeraw (struct termios *termios_p) { termios_p->c_iflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR | IGNCR | ICRNL | IXON); termios_p->c_oflag &= ~OPOST; termios_p->c_lflag &= ~(ECHO | ECHONL | ICANON | ISIG | IEXTEN); termios_p->c_cflag &= ~(CSIZE | PARENB); termios_p->c_cflag |= CS8; } #endif /* * Setup serial port, return 0 if success. */ static int vtty_serial_setup (vtty_t * vtty, const vtty_serial_option_t * option) { struct termios tio; int tio_baudrate; if (tcgetattr (vtty->fd, &tio) != 0) { fprintf (stderr, "error: tcgetattr failed\n"); return (-1); } cfmakeraw (&tio); tio.c_cflag = 0 | CLOCAL // ignore modem control lines ; tio.c_cflag &= ~CREAD; tio.c_cflag |= CREAD; switch (option->baudrate) { case 50: tio_baudrate = B50; break; case 75: tio_baudrate = B75; break; case 110: tio_baudrate = B110; break; case 134: tio_baudrate = B134; break; case 150: tio_baudrate = B150; break; case 200: tio_baudrate = B200; break; case 300: tio_baudrate = B300; break; case 600: tio_baudrate = B600; break; case 1200: tio_baudrate = B1200; break; case 1800: tio_baudrate = B1800; break; case 2400: tio_baudrate = B2400; break; case 4800: tio_baudrate = B4800; break; case 9600: tio_baudrate = B9600; break; case 19200: tio_baudrate = B19200; break; case 38400: tio_baudrate = B38400; break; case 57600: tio_baudrate = B57600; break; #if defined(B76800) case 76800: tio_baudrate = B76800; break; #endif case 115200: tio_baudrate = B115200; break; #if defined(B230400) case 230400: tio_baudrate = B230400; break; #endif default: fprintf (stderr, "error: unsupported baudrate\n"); return (-1); } cfsetospeed (&tio, tio_baudrate); cfsetispeed (&tio, tio_baudrate); tio.c_cflag &= ~CSIZE; /* clear size flag */ switch (option->databits) { case 5: tio.c_cflag |= CS5; break; case 6: tio.c_cflag |= CS6; break; case 7: tio.c_cflag |= CS7; break; case 8: tio.c_cflag |= CS8; break; default: fprintf (stderr, "error: unsupported databits\n"); return (-1); } tio.c_iflag &= ~INPCK; /* clear parity flag */ tio.c_cflag &= ~(PARENB | PARODD); switch (option->parity) { case 0: break; case 2: tio.c_iflag |= INPCK; tio.c_cflag |= PARENB; break; /* even */ case 1: tio.c_iflag |= INPCK; tio.c_cflag |= PARENB | PARODD; break; /* odd */ default: fprintf (stderr, "error: unsupported parity\n"); return (-1); } tio.c_cflag &= ~CSTOPB; /* clear stop flag */ switch (option->stopbits) { case 1: break; case 2: tio.c_cflag |= CSTOPB; break; default: fprintf (stderr, "error: unsupported stopbits\n"); return (-1); } #if defined(CRTSCTS) tio.c_cflag &= ~CRTSCTS; #endif #if defined(CNEW_RTSCTS) tio.c_cflag &= ~CNEW_RTSCTS; #endif if (option->hwflow) { #if defined(CRTSCTS) tio.c_cflag |= CRTSCTS; #else tio.c_cflag |= CNEW_RTSCTS; #endif } tio.c_cc[VTIME] = 0; tio.c_cc[VMIN] = 1; /* block read() until one character is available */ #if 0 /* not neccessary unless O_NONBLOCK used */ if (fcntl (vtty->fd, F_SETFL, 0) != 0) { /* enable blocking mode */ fprintf (stderr, "error: fnctl F_SETFL failed\n"); return (-1); } #endif if (tcflush (vtty->fd, TCIOFLUSH) != 0) { fprintf (stderr, "error: tcflush failed\n"); return (-1); } if (tcsetattr (vtty->fd, TCSANOW, &tio) != 0) { fprintf (stderr, "error: tcsetattr failed\n"); return (-1); } return (0); } /* Create a virtual tty */ vtty_t *vtty_create (vm_instance_t * vm, char *name, int type, int tcp_port, const vtty_serial_option_t * option) { vtty_t *vtty; if (!(vtty = malloc (sizeof (*vtty)))) { fprintf (stderr, "VTTY: unable to create new virtual tty.\n"); return NULL; } memset (vtty, 0, sizeof (*vtty)); vtty->name = name; vtty->type = type; vtty->vm = vm; vtty->fd = -1; vtty->fstream = NULL; vtty->accept_fd = -1; pthread_mutex_init (&vtty->lock, NULL); vtty->terminal_support = 0; // was 1 (vak) vtty->input_state = VTTY_INPUT_TEXT; switch (vtty->type) { case VTTY_TYPE_NONE: vtty->select_fd = NULL; break; case VTTY_TYPE_TERM: vtty_term_init (); vtty->fd = STDIN_FILENO; vtty->select_fd = &vtty->fd; vtty->fstream = stdout; break; case VTTY_TYPE_TCP: vtty->tcp_port = tcp_port; vtty_tcp_conn_wait (vtty); break; case VTTY_TYPE_SERIAL: vtty->fd = open (option->device, O_RDWR); if (vtty->fd < 0) { fprintf (stderr, "VTTY: open failed\n"); free (vtty); return NULL; } if (vtty_serial_setup (vtty, option)) { fprintf (stderr, "VTTY: setup failed\n"); close (vtty->fd); free (vtty); return NULL; } vtty->select_fd = &vtty->fd; vtty->terminal_support = 0; break; default: fprintf (stderr, "tty_create: bad vtty type %d\n", vtty->type); return NULL; } /* Add this new VTTY to the list */ VTTY_LIST_LOCK (); vtty->next = vtty_list; vtty->pprev = &vtty_list; if (vtty_list != NULL) vtty_list->pprev = &vtty->next; vtty_list = vtty; VTTY_LIST_UNLOCK (); return vtty; } /* Delete a virtual tty */ void vtty_delete (vtty_t * vtty) { if (vtty != NULL) { if (vtty->pprev != NULL) { VTTY_LIST_LOCK (); if (vtty->next) vtty->next->pprev = vtty->pprev; *(vtty->pprev) = vtty->next; VTTY_LIST_UNLOCK (); } if ((vtty->fstream) && (vtty->fstream != stdout)) fclose (vtty->fstream); /* We don't close FD 0 since it is stdin */ if (vtty->fd > 0) { vm_log (vtty->vm, "VTTY", "%s: closing FD %d\n", vtty->name, vtty->fd); close (vtty->fd); } if (vtty->accept_fd != -1) { vm_log (vtty->vm, "VTTY", "%s: closing accept FD %d\n", vtty->name, vtty->accept_fd); close (vtty->accept_fd); } free (vtty); } } /* Store a character in the FIFO buffer */ static int vtty_store (vtty_t * vtty, u_char c) { u_int nwptr; VTTY_LOCK (vtty); nwptr = vtty->write_ptr + 1; if (nwptr == VTTY_BUFFER_SIZE) nwptr = 0; if (nwptr == vtty->read_ptr) { VTTY_UNLOCK (vtty); return (-1); } vtty->buffer[vtty->write_ptr] = c; vtty->write_ptr = nwptr; VTTY_UNLOCK (vtty); return (0); } /* Store a string in the FIFO buffer */ int vtty_store_str (vtty_t * vtty, char *str) { if (!vtty) return (0); while (*str != 0) { if (vtty_store (vtty, *str) == -1) return (-1); str++; } vtty->input_pending = TRUE; return (0); } /* Store CTRL+C in buffer */ int vtty_store_ctrlc (vtty_t * vtty) { if (vtty) vtty_store (vtty, 0x03); return (0); } /* * Read a character from the terminal. */ static int vtty_term_read (vtty_t * vtty) { u_char c; if (read (vtty->fd, &c, 1) == 1) return (c); perror ("read from vtty failed"); return (-1); } /* * Read a character from the TCP connection. */ static int vtty_tcp_read (vtty_t * vtty) { u_char c; switch (vtty->state) { case VTTY_STATE_TCP_RUNNING: if (read (vtty->fd, &c, 1) == 1) return (c); /* Problem with the connection: Re-enter wait mode */ shutdown (vtty->fd, 2); fclose (vtty->fstream); close (vtty->fd); vtty->fstream = NULL; vtty->fd = -1; vtty->select_fd = &vtty->accept_fd; vtty->state = VTTY_STATE_TCP_WAITING; return (-1); case VTTY_STATE_TCP_WAITING: /* A new connection has arrived */ vtty_tcp_conn_accept (vtty); return (-1); } /* Shouldn't happen... */ return (-1); } /* * Read a character from the USB connection. */ static int vtty_usb_read (vtty_t * vtty) { // stub perror("VTTY not yet implemented on USB\n"); return (-1); } /* * Read a character from the virtual TTY. * * If the VTTY is a TCP connection, restart it in case of error. */ static int vtty_read (vtty_t * vtty) { switch (vtty->type) { case VTTY_TYPE_TERM: case VTTY_TYPE_SERIAL: return (vtty_term_read (vtty)); case VTTY_TYPE_TCP: return (vtty_tcp_read (vtty)); case VTTY_TYPE_USB: return (vtty_usb_read (vtty)); default: fprintf (stderr, "vtty_read: bad vtty type %d\n", vtty->type); return (-1); } /* NOTREACHED */ return (-1); } #if 0 /* Remote control for MIPS64 processors */ static int remote_control_mips (vtty_t * vtty, char c, cpu_mips_t * cpu) { switch (c) { /* Show information about JIT compiled pages */ case 'b': // printf("\nCPU0: %u JIT compiled pages [Exec Area Pages: %lu/%lu]\n", // cpu->compiled_pages, // (u_long)cpu->exec_page_alloc, // (u_long)cpu->exec_page_count); break; /* Non-JIT mode statistics */ case 'j': // mips_dump_stats(cpu); break; default: return (FALSE); } return (TRUE); } #endif /* Read a character (until one is available) and store it in buffer */ static void vtty_read_and_store (vtty_t * vtty) { int c; /* wait until we get a character input */ c = vtty_read (vtty); /* if read error, do nothing */ if (c < 0) return; if (!vtty->terminal_support) { vtty_store (vtty, c); return; } switch (vtty->input_state) { case VTTY_INPUT_TEXT: switch (c) { case 0x1b: vtty->input_state = VTTY_INPUT_VT1; return; /* Ctrl + ']' (0x1d, 29), or Alt-Gr + '*' (0xb3, 179) */ case 0x1d: case 0xb3: vtty->input_state = VTTY_INPUT_REMOTE; return; case IAC: vtty->input_state = VTTY_INPUT_TELNET; return; case 0: /* NULL - Must be ignored - generated by Linux telnet */ case 10: /* LF (Line Feed) - Must be ignored on Windows platform */ return; default: /* Store a standard character */ vtty_store (vtty, c); return; } case VTTY_INPUT_VT1: switch (c) { case 0x5b: vtty->input_state = VTTY_INPUT_VT2; return; default: vtty_store (vtty, 0x1b); vtty_store (vtty, c); } vtty->input_state = VTTY_INPUT_TEXT; return; case VTTY_INPUT_VT2: switch (c) { case 0x41: /* Up Arrow */ vtty_store (vtty, 16); break; case 0x42: /* Down Arrow */ vtty_store (vtty, 14); break; case 0x43: /* Right Arrow */ vtty_store (vtty, 6); break; case 0x44: /* Left Arrow */ vtty_store (vtty, 2); break; default: vtty_store (vtty, 0x5b); vtty_store (vtty, 0x1b); vtty_store (vtty, c); break; } vtty->input_state = VTTY_INPUT_TEXT; return; case VTTY_INPUT_REMOTE: //remote_control(vtty, c); vtty->input_state = VTTY_INPUT_TEXT; return; case VTTY_INPUT_TELNET: vtty->telnet_cmd = c; switch (c) { case WILL: case WONT: case DO: case DONT: vtty->input_state = VTTY_INPUT_TELNET_IYOU; return; case SB: vtty->telnet_cmd = c; vtty->input_state = VTTY_INPUT_TELNET_SB1; return; case SE: break; case IAC: vtty_store (vtty, IAC); break; } vtty->input_state = VTTY_INPUT_TEXT; return; case VTTY_INPUT_TELNET_IYOU: vtty->telnet_opt = c; /* if telnet client can support ttype, ask it to send ttype string */ if ((vtty->telnet_cmd == WILL) && (vtty->telnet_opt == TELOPT_TTYPE)) { vtty_put_char (vtty, IAC); vtty_put_char (vtty, SB); vtty_put_char (vtty, TELOPT_TTYPE); vtty_put_char (vtty, TELQUAL_SEND); vtty_put_char (vtty, IAC); vtty_put_char (vtty, SE); } vtty->input_state = VTTY_INPUT_TEXT; return; case VTTY_INPUT_TELNET_SB1: vtty->telnet_opt = c; vtty->input_state = VTTY_INPUT_TELNET_SB2; return; case VTTY_INPUT_TELNET_SB2: vtty->telnet_qual = c; if ((vtty->telnet_opt == TELOPT_TTYPE) && (vtty->telnet_qual == TELQUAL_IS)) vtty->input_state = VTTY_INPUT_TELNET_SB_TTYPE; else vtty->input_state = VTTY_INPUT_TELNET_NEXT; return; case VTTY_INPUT_TELNET_SB_TTYPE: /* parse ttype string: first char is sufficient */ /* if client is xterm or vt, set the title bar */ if ((c == 'x') || (c == 'X') || (c == 'v') || (c == 'V')) { // fprintf(vtty->fstream, "\033]0;Dynamips(%i): %s, %s\07", // vtty->vm->instance_id, vtty->vm->name, vtty->name); } vtty->input_state = VTTY_INPUT_TELNET_NEXT; return; case VTTY_INPUT_TELNET_NEXT: /* ignore all chars until next IAC */ if (c == IAC) vtty->input_state = VTTY_INPUT_TELNET; return; } } int vtty_bytes (vtty_t * vtty) { if (vtty->read_ptr < vtty->write_ptr) return vtty->write_ptr - vtty->read_ptr; else if (vtty->read_ptr == vtty->write_ptr) { return VTTY_BUFFER_SIZE; } else return VTTY_BUFFER_SIZE - (vtty->read_ptr - vtty->write_ptr); } int vtty_is_full (vtty_t * vtty) { return (vtty->read_ptr == vtty->write_ptr); } /* Read a character from the buffer (-1 if the buffer is empty) */ int vtty_get_char (vtty_t * vtty) { u_char c; VTTY_LOCK (vtty); if (vtty->read_ptr == vtty->write_ptr) { VTTY_UNLOCK (vtty); return (-1); } c = vtty->buffer[vtty->read_ptr++]; if (vtty->read_ptr == VTTY_BUFFER_SIZE) vtty->read_ptr = 0; VTTY_UNLOCK (vtty); return (c); } /* Returns TRUE if a character is available in buffer */ int vtty_is_char_avail (vtty_t * vtty) { int res; VTTY_LOCK (vtty); res = (vtty->read_ptr != vtty->write_ptr); VTTY_UNLOCK (vtty); return (res); } /* Put char to vtty */ // XXX void vtty_put_char (vtty_t * vtty, char ch) void vtty_put_char (vtty_t * vtty, int ch) { switch (vtty->type) { case VTTY_TYPE_NONE: break; case VTTY_TYPE_TERM: //printf("put char %c\n",ch); fwrite (&ch, 1, 1, vtty->fstream); break; case VTTY_TYPE_TCP: if ((vtty->state == VTTY_STATE_TCP_RUNNING) && (fwrite (&ch, 1, 1, vtty->fstream) != 1)) { vm_log (vtty->vm, "VTTY", "%s: put char %d failed (%s)\n", vtty->name, (int) ch, strerror (errno)); } break; case VTTY_TYPE_SERIAL: if (write (vtty->fd, &ch, 1) != 1) { vm_log (vtty->vm, "VTTY", "%s: put char 0x%x failed (%s)\n", vtty->name, (int) ch, strerror (errno)); } break; default: fprintf (stderr, "vtty_put_char: bad vtty type %d\n", vtty->type); exit (1); } } /* Put a buffer to vtty */ void vtty_put_buffer (vtty_t * vtty, char *buf, size_t len) { size_t i; for (i = 0; i < len; i++) vtty_put_char (vtty, buf[i]); } /* Flush VTTY output */ void vtty_flush (vtty_t * vtty) { switch (vtty->type) { case VTTY_TYPE_TERM: case VTTY_TYPE_TCP: if (vtty->fstream) fflush (vtty->fstream); break; case VTTY_TYPE_SERIAL: fsync (vtty->fd); break; } } /* VTTY thread */ static void *vtty_thread_main (void *arg) { vtty_t *vtty; struct timeval tv; int fd, fd_max, res; fd_set rfds; for (;;) { VTTY_LIST_LOCK (); /* Build the FD set */ FD_ZERO (&rfds); fd_max = -1; for (vtty = vtty_list; vtty; vtty = vtty->next) { if (!vtty->select_fd) continue; if ((fd = *vtty->select_fd) < 0) continue; if (fd > fd_max) fd_max = fd; FD_SET (fd, &rfds); } VTTY_LIST_UNLOCK (); /* Wait for incoming data */ tv.tv_sec = 0; tv.tv_usec = 50 * 1000; /* 50 ms */ res = select (fd_max + 1, &rfds, NULL, NULL, &tv); if (res == -1) { if (errno != EINTR) { perror ("vtty_thread: select"); for (vtty = vtty_list; vtty; vtty = vtty->next) { fprintf (stderr, " %-15s: %s, FD %d\n", vtty->vm->name, vtty->name, vtty->fd); } } continue; } /* Examine active FDs and call user handlers */ VTTY_LIST_LOCK (); for (vtty = vtty_list; vtty; vtty = vtty->next) { if (!vtty->select_fd) continue; if ((fd = *vtty->select_fd) < 0) continue; if (FD_ISSET (fd, &rfds)) { vtty_read_and_store (vtty); vtty->input_pending = TRUE; } if (vtty->input_pending) { if (vtty->read_notifier != NULL) vtty->read_notifier (vtty); vtty->input_pending = FALSE; } /* Flush any pending output */ if (!vtty->managed_flush) vtty_flush (vtty); } VTTY_LIST_UNLOCK (); } return NULL; } /* Initialize the VTTY thread */ int vtty_init (void) { if (pthread_create (&vtty_thread, NULL, vtty_thread_main, NULL)) { perror ("vtty: pthread_create"); return (-1); } return (0); } ================================================ FILE: tools/virtualmips/dev_vtty.h ================================================ /* * Cisco router simulation platform. * Copyright (c) 2005,2006 Christophe Fillot (cf@utc.fr) * * Virtual console TTY. */ /* * Copyright (C) yajin 2008 * * This file is part of the virtualmips distribution. * See LICENSE file for terms of the license. * */ #ifndef __DEV_VTTY_H__ #define __DEV_VTTY_H__ #include #include #include "vm.h" #include /* 4 Kb should be enough for a keyboard buffer */ #define VTTY_BUFFER_SIZE 4096 /* VTTY connection types */ enum { VTTY_TYPE_NONE = 0, VTTY_TYPE_TERM, VTTY_TYPE_TCP, VTTY_TYPE_SERIAL, VTTY_TYPE_USB, }; /* VTTY connection states (for TCP) */ enum { VTTY_STATE_TCP_INVALID, /* connection is not working */ VTTY_STATE_TCP_WAITING, /* waiting for incoming connection */ VTTY_STATE_TCP_RUNNING, /* character reading/writing ok */ }; /* VTTY input states */ enum { VTTY_INPUT_TEXT, VTTY_INPUT_VT1, VTTY_INPUT_VT2, VTTY_INPUT_REMOTE, VTTY_INPUT_TELNET, VTTY_INPUT_TELNET_IYOU, VTTY_INPUT_TELNET_SB1, VTTY_INPUT_TELNET_SB2, VTTY_INPUT_TELNET_SB_TTYPE, VTTY_INPUT_TELNET_NEXT }; /* Commmand line support utility */ typedef struct vtty_serial_option vtty_serial_option_t; struct vtty_serial_option { char *device; int baudrate, databits, parity, stopbits, hwflow; }; int vtty_parse_serial_option (vtty_serial_option_t * params, char *optarg); /* Virtual TTY structure */ typedef struct virtual_tty vtty_t; struct virtual_tty { vm_instance_t *vm; char *name; int type, state; int tcp_port; int terminal_support; int input_state; int input_pending; int telnet_cmd, telnet_opt, telnet_qual; int fd, accept_fd, *select_fd; int managed_flush; FILE *fstream; u_char buffer[VTTY_BUFFER_SIZE]; u_int read_ptr, write_ptr; pthread_mutex_t lock; vtty_t *next, **pprev; void *priv_data; /* Read notification */ void (*read_notifier) (vtty_t *); }; #define VTTY_LOCK(tty) pthread_mutex_lock(&(tty)->lock); #define VTTY_UNLOCK(tty) pthread_mutex_unlock(&(tty)->lock); /* create a virtual tty */ vtty_t *vtty_create (vm_instance_t * vm, char *name, int type, int tcp_port, const vtty_serial_option_t * option); /* delete a virtual tty */ void vtty_delete (vtty_t * vtty); /* Store a string in the FIFO buffer */ int vtty_store_str (vtty_t * vtty, char *str); /* read a character from the buffer (-1 if the buffer is empty) */ int vtty_get_char (vtty_t * vtty); /* print a character to vtty */ // XXX void vtty_put_char (vtty_t * vtty, char ch); void vtty_put_char (vtty_t * vtty, int ch); /* Put a buffer to vtty */ void vtty_put_buffer (vtty_t * vtty, char *buf, size_t len); /* Flush VTTY output */ void vtty_flush (vtty_t * vtty); /* returns TRUE if a character is available in buffer */ int vtty_is_char_avail (vtty_t * vtty); /* write CTRL+C to buffer */ int vtty_store_ctrlc (vtty_t *); /* Initialize the VTTY thread */ int vtty_init (void); int vtty_is_full (vtty_t * vtty); int vtty_bytes (vtty_t * vtty); #endif ================================================ FILE: tools/virtualmips/device.c ================================================ /* * Cisco router simulation platform. * Copyright (c) 2005,2006 Christophe Fillot (cf@utc.fr) */ /* * Copyright (C) yajin 2008 * * This file is part of the virtualmips distribution. * See LICENSE file for terms of the license. * */ #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include "cpu.h" #include "vm.h" #include "mips_memory.h" #include "device.h" #define DEBUG_DEV_ACCESS 0 /* Get device by ID */ struct vdevice *dev_get_by_id (vm_instance_t * vm, u_int dev_id) { if (!vm || (dev_id >= VM_DEVICE_MAX)) return NULL; return (vm->dev_array[dev_id]); } /* Get device by name */ struct vdevice *dev_get_by_name (vm_instance_t * vm, char *name) { struct vdevice *dev; if (!vm) return NULL; for (dev = vm->dev_list; dev; dev = dev->next) if (!strcmp (dev->name, name)) return dev; return NULL; } /* Device lookup by physical address */ //struct vdevice *dev_lookup(vm_instance_t *vm,m_pa_t phys_addr,int cached) struct vdevice *dev_lookup (vm_instance_t * vm, m_pa_t phys_addr) { struct vdevice *dev; if (!vm) return NULL; for (dev = vm->dev_list; dev; dev = dev->next) { // if (cached && !(dev->flags & VDEVICE_FLAG_CACHING)) // continue; if ((phys_addr >= dev->phys_addr) && ((phys_addr - dev->phys_addr) < dev->phys_len)) return dev; } return NULL; } /* Find the next device after the specified address */ //struct vdevice *dev_lookup_next(vm_instance_t *vm,m_pa_t phys_addr, // struct vdevice *dev_start,int cached) struct vdevice *dev_lookup_next (vm_instance_t * vm, m_pa_t phys_addr, struct vdevice *dev_start) { struct vdevice *dev; if (!vm) return NULL; dev = (dev_start != NULL) ? dev_start : vm->dev_list; for (; dev; dev = dev->next) { //if (cached && !(dev->flags & VDEVICE_FLAG_CACHING)) // continue; if (dev->phys_addr > phys_addr) return dev; } return NULL; } /* Initialize a device */ void dev_init (struct vdevice *dev) { memset (dev, 0, sizeof (*dev)); dev->fd = -1; } /* reset all devices */ void dev_reset_all (vm_instance_t * vm) { struct vdevice *dev; for (dev = vm->dev_list; dev; dev = dev->next) { ASSERT (dev->reset_handler != NULL, "reset_handler is NULL. name %s\n", dev->name); dev->reset_handler (vm->boot_cpu, dev); } } /* Allocate a device */ struct vdevice *dev_create (char *name) { struct vdevice *dev; if (!(dev = malloc (sizeof (*dev)))) { fprintf (stderr, "dev_create: insufficient memory to " "create device '%s'.\n", name); return NULL; } dev_init (dev); dev->name = name; return dev; } /* Remove a device */ void dev_remove (vm_instance_t * vm, struct vdevice *dev) { if (dev == NULL) return; vm_unbind_device (vm, dev); vm_log (vm, "DEVICE", "Removal of device %s, fd=%d, host_addr=0x%" LL "x, flags=%d\n", dev->name, dev->fd, (m_uint64_t) dev->host_addr, dev->flags); if (dev->flags & VDEVICE_FLAG_REMAP) { dev_init (dev); return; } if (dev->fd != -1) { /* Unmap memory mapped file */ if (dev->host_addr) { vm_log (vm, "MMAP", "unmapping of device '%s', " "fd=%d, host_addr=0x%" LL "x, len=0x%x\n", dev->name, dev->fd, (m_uint64_t) dev->host_addr, dev->phys_len); munmap ((void *) dev->host_addr, dev->phys_len); } close (dev->fd); } else { /* Use of malloc'ed host memory: free it */ if (dev->host_addr) free ((void *) dev->host_addr); } /* reinitialize the device to a clean state */ dev_init (dev); } /* Show properties of a device */ void dev_show (struct vdevice *dev) { if (!dev) return; printf (" %-18s: 0x%12.12" LL "x (0x%8.8x)\n", dev->name, dev->phys_addr, dev->phys_len); } /* Show the device list */ void dev_show_list (vm_instance_t * vm) { struct vdevice *dev; printf ("\nVM \"%s\" () Device list:\n", vm->name); for (dev = vm->dev_list; dev; dev = dev->next) dev_show (dev); printf ("\n"); } /* Remap a device at specified physical address */ struct vdevice *dev_remap (char *name, struct vdevice *orig, m_pa_t paddr, m_uint32_t len) { struct vdevice *dev; if (!(dev = dev_create (name))) return NULL; dev->phys_addr = paddr; dev->phys_len = len; dev->flags = orig->flags | VDEVICE_FLAG_REMAP; dev->fd = orig->fd; dev->host_addr = orig->host_addr; dev->handler = orig->handler; //dev->sparse_map = orig->sparse_map; return dev; } /* Create a RAM device */ struct vdevice *dev_create_ram (vm_instance_t * vm, char *name, m_pa_t paddr, m_uint32_t len) { struct vdevice *dev; if (!(dev = dev_create (name))) return NULL; dev->phys_addr = paddr; dev->phys_len = len; //dev->flags = VDEVICE_FLAG_CACHING; dev->host_addr = (m_iptr_t) m_memalign (4096, dev->phys_len); memset ((void*) dev->host_addr, 0, dev->phys_len); if (!dev->host_addr) { free (dev); return NULL; } vm_bind_device (vm, dev); return dev; } ================================================ FILE: tools/virtualmips/device.h ================================================ /* * Cisco router simulation platform. * Copyright (c) 2005,2006 Christophe Fillot (cf@utc.fr) */ /* * Copyright (C) yajin 2008 * * This file is part of the virtualmips distribution. * See LICENSE file for terms of the license. * */ #ifndef __DEVICE_H__ #define __DEVICE_H__ #include #include "utils.h" #include "mips.h" #include "vm.h" #include "cpu.h" /* Device Flags */ #define VDEVICE_FLAG_NO_MTS_MMAP 0x01 /* Prevent MMAPed access by MTS */ #define VDEVICE_FLAG_CACHING 0x02 /* Device does support caching */ #define VDEVICE_FLAG_REMAP 0x04 /* Physical address remapping */ //#define VDEVICE_FLAG_COW 0x08 /* Copy on write device */ #define VDEVICE_PTE_DIRTY 0x01 /*device handler */ typedef void *(*dev_handler_t) (cpu_mips_t * cpu, vdevice_t * dev, m_uint32_t offset, u_int op_size, u_int op_type, m_reg_t * data, m_uint8_t * has_set_value); typedef void (*dev_reset_handler_t) (cpu_mips_t * cpu, vdevice_t * dev); /* Virtual Device */ struct vdevice { char *name; u_int id; m_pa_t phys_addr; m_uint32_t phys_len; m_iptr_t host_addr; void *priv_data; int flags; int fd; dev_handler_t handler; dev_reset_handler_t reset_handler; struct vdevice *next, **pprev; }; /* device access function */ static forced_inline void *dev_access_fast (cpu_mips_t * cpu, u_int dev_id, m_uint32_t offset, u_int op_size, u_int op_type, m_reg_t * data, m_uint8_t * has_set_value) { struct vdevice *dev = cpu->vm->dev_array[dev_id]; if (unlikely (!dev)) { cpu_log (cpu, "dev_access_fast", "null handler (dev_id=%u,offset=0x%x)\n", dev_id, offset); return NULL; } return (dev->handler (cpu, dev, offset, op_size, op_type, data, has_set_value)); } struct vdevice *dev_lookup (vm_instance_t * vm, m_pa_t phys_addr); void dev_init (struct vdevice *dev); int dev_ram_init (vm_instance_t * vm, char *name, m_pa_t paddr, m_uint32_t len); struct vdevice *dev_create (char *name); struct vdevice *dev_create_ram (vm_instance_t * vm, char *name, m_pa_t paddr, m_uint32_t len); void dev_reset_all (vm_instance_t * vm); #endif ================================================ FILE: tools/virtualmips/gdb_interface.c ================================================ /* * Copyright (C) 1996-1998 by the Board of Trustees * of Leland Stanford Junior University. * * This file is part of the SimOS distribution. * See LICENSE file for terms of the license. * */ /* * Copyright (C) yajin 2008 * * This file is part of the virtualmips distribution. * See LICENSE file for terms of the license. * */ /*GDB interface for virtualmips based on simos*/ #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include "vm.h" #include "mips.h" #include "gdb_interface.h" #include "utils.h" #include "debug.h" #define GDB_NUM_REGS 72 //general cpu register and cp0 reegister #define VCONT "vCont" #define QSYMBOL "qSymbol" #define QC "qC" #define QOFFSETS "qOffsets" int delete_breakpoint (vm_instance_t * vm, m_uint32_t addr, int len) { virtual_breakpoint_t *tmp, *prev = 0; tmp = vm->breakpoint_head; // addr = SIGN_EXTEND(32,addr); while (tmp) { if (tmp->addr == addr) { /*find it */ if (prev) prev->next = tmp->next; if (vm->breakpoint_head == tmp) vm->breakpoint_head = tmp->next; if (vm->breakpoint_tail == tmp) vm->breakpoint_tail = prev; if (tmp->save) free (tmp->save); free (tmp); goto exit; } prev = tmp; tmp = tmp->next; } exit: return SUCCESS; } virtual_breakpoint_t *alloc_breakpoint (vm_instance_t * vm, m_uint32_t addr, char *save, int len) { virtual_breakpoint_t *tmp; tmp = malloc (sizeof (virtual_breakpoint_t)); if (!tmp) return NULL; memset (tmp, 0, sizeof (*tmp)); tmp->addr = (addr); if (save) { tmp->save = malloc (strlen (save) + 1); strlcpy (tmp->save, save, sizeof(tmp->save)); } //tmp->cpuno = cpuno; tmp->len = len; tmp->next = 0; return tmp; } int insert_breakpoint (vm_instance_t * vm, virtual_breakpoint_t * new) { virtual_breakpoint_t *tmp; if (vm->breakpoint_head == 0) { vm->breakpoint_tail = vm->breakpoint_head = new; } else { tmp = vm->breakpoint_head; while (tmp) { if (tmp->addr == new->addr) { /*the same one */ if (new->save) free (new->save); free (new); goto exit; } tmp = tmp->next; } vm->breakpoint_tail->next = new; vm->breakpoint_tail = new; } exit: return SUCCESS; } static int fromhex (int a) { if (a >= '0' && a <= '9') return a - '0'; else if (a >= 'a' && a <= 'f') return a - 'a' + 10; else { fprintf (stderr, "Request contains invalid hex digit : %s %d\n", __FILE__, __LINE__); return 0; } } /* Convert number NIB to a hex digit. */ static int tohex (int nib) { if (nib < 10) return '0' + nib; else return 'a' + nib - 10; } #if 0 static int bin2hex (const char *bin, char *hex, int count) { int i; /* May use a length, or a nul-terminated string as input. */ if (count == 0) count = strlen (bin); for (i = 0; i < count; i++) { *hex++ = tohex ((*bin >> 4) & 0xf); *hex++ = tohex (*bin++ & 0xf); } *hex = 0; return i; } #endif static void convert_int_to_ascii (char *from, char *to, int n) { int nib; char ch; while (n--) { ch = *from++; nib = ((ch & 0xf0) >> 4) & 0x0f; *to++ = tohex (nib); nib = ch & 0x0f; *to++ = tohex (nib); } *to++ = 0; } /***************************************************************** * readchar * Returns next char from remote GDB. -1 if error. *****************************************************************/ static int readchar (int fd) { static char buf[BUFSIZ]; static int bufcnt = 0; static char *bufp; if (bufcnt-- > 0) return *bufp++ & 0x7f; bufcnt = read (fd, buf, BUFSIZ); if (bufcnt <= 0) { printf ("Simdebug readchar"); return -1; } bufp = buf; bufcnt--; return *bufp++ & 0x7f; } /***************************************************************** * getpkt * * Read a packet from the remote machine, with error checking, * and store it in BUF. Returns length of packet, or negative if error. *****************************************************************/ static int getpkt (int fd, char *buf) { char *bp; unsigned char csum, c1, c2; int c; bp = buf; while (1) { csum = 0; while (1) { c = readchar (fd); if (c == '$') break; if (c < 0) goto errout; } bp = buf; while (1) { c = readchar (fd); if (c < 0) goto errout; if (c == '#') break; *bp++ = c; csum += c; } *bp = 0; c = readchar (fd); if (c < 0) goto errout; c1 = fromhex (c); c = readchar (fd); if (c < 0) goto errout; c2 = fromhex (c); if (csum == (c1 << 4) + c2) break; if (write (fd, "-", 1) < 0) return -1; } if (write (fd, "+", 1) < 0) return -1; return bp - buf; errout: return -1; } static void write_ok (char *buf) { buf[0] = 'O'; buf[1] = 'K'; buf[2] = '\0'; } static void write_enn (char *buf) { buf[0] = 'E'; #if 0 buf[1] = 'N'; buf[2] = 'N'; #endif buf[1] = '0'; buf[2] = '1'; buf[3] = '\0'; } /* Send a packet to the remote machine, with error checking. The data of the packet is in BUF. Returns >= 0 on success, -1 otherwise. */ static int putpkt (int fd, char *buf) { //printf("putpkt\n"); int i; unsigned char csum = 0; char buf2[2000]; char buf3[1]; int cnt = strlen (buf); char *p; /* Copy the packet into buffer BUF2, encapsulating it * and giving it a checksum. */ p = buf2; *p++ = '$'; for (i = 0; i < cnt; i++) { csum += buf[i]; *p++ = buf[i]; } *p++ = '#'; *p++ = tohex ((csum >> 4) & 0xf); *p++ = tohex (csum & 0xf); /* Send it over and over until we get a positive ack. */ do { int cc; if (write (fd, buf2, p - buf2) != p - buf2) { printf ("putpkt(write)\n"); goto errout; } cc = read (fd, buf3, 1); if (cc <= 0) { printf ("putpkt(read)\n"); goto errout; } } while (buf3[0] != '+'); return 1; /* Success! */ errout: return -1; } static void attach_gdb (vm_instance_t * vm) { struct sockaddr_in sockaddr1; unsigned int tmp; int gdb_fd; if (!vm->gdb_debug_from_poll) printf ("Waiting for gdb on port %d.\n", vm->gdb_port); tmp = sizeof (sockaddr1); gdb_fd = accept (vm->gdb_listen_sock, (struct sockaddr *) &sockaddr1, &tmp); vm->gdb_interact_sock = gdb_fd; if (gdb_fd == -1) { printf ("Debugger accept failed\n"); return; } if (!vm->gdb_debug_from_poll) printf ("GDB attached. Enjoy yourself!\n"); /* Tell TCP not to delay small packets. This greatly speeds up * interactive response. */ tmp = 1; setsockopt (gdb_fd, SOL_SOCKET, SO_KEEPALIVE, (char *) &tmp, sizeof (tmp)); tmp = 1; setsockopt (gdb_fd, IPPROTO_TCP, TCP_NODELAY, (char *) &tmp, sizeof (tmp)); // int save_fcntl_flags; #if defined(F_SETFL) && defined (FASYNC) save_fcntl_flags = fcntl (gdb_fd, F_GETFL, 0); fcntl (gdb_fd, F_SETFL, save_fcntl_flags | FASYNC); #if defined (F_SETOWN) fcntl (gdb_fd, F_SETOWN, getpid ()); #endif #endif signal (SIGIO, SIG_IGN); // return gdb_fd; } #define MAX_XFER (8*1024) #define WORD_SZ 4 #define BYTE_SZ 1 int debug_read_memory (cpu_mips_t * cpu, m_uint32_t vaddr, unsigned int len, char *buf) { //void *haddr=NULL; //m_uint32_t exc; //m_uint32_t data; //m_uint8_t has_set_value=FALSE; char readout_buf[MAX_XFER]; if (len > MAX_XFER) { fprintf (stderr, "read_memory: too many bytes requested"); } assert (len <= MAX_XFER); int reallen = len; char *cur = readout_buf; int i = 0; //We read one byte once to avoid align problem for (i = 0; i < (reallen / BYTE_SZ); i++) { cpu->mips_mts_gdb_lb (cpu, vaddr, cur); cur += BYTE_SZ; vaddr += BYTE_SZ; } convert_int_to_ascii (readout_buf, buf, len); return SUCCESS; } int forced_inline cpu_hit_breakpoint (vm_instance_t * vm, m_uint32_t vaddr) { virtual_breakpoint_t *tmp = vm->breakpoint_head; static char cmd_buf[BUFSIZ + 1]; while (tmp) { if (tmp->addr == vaddr) { snprintf (cmd_buf, sizeof(cmd_buf), "S%02x", SIGTRAP); if (putpkt (vm->gdb_interact_sock, cmd_buf) < 0) { /* the connection was terminated prematurely. Reset */ close (vm->gdb_interact_sock); vm->gdb_interact_sock = -1; vm->mipsy_debug_mode = 0; //we do not debug anymore printf ("Remote debugger connection lost, continuing...\n"); return FAILURE; } return SUCCESS; } tmp = tmp->next; } return FAILURE; } /* Convert hex digit A to a number. */ Simdebug_result Simdebug_run (vm_instance_t * vm, int sig) { static char cmd_buf[BUFSIZ + 1]; char *b; int i = 0; Simdebug_result ret = SD_CONTINUE; if (vm->gdb_interact_sock <= 0) { attach_gdb (vm); if (vm->gdb_interact_sock < 0) { return SD_CONTINUE; /* could not get debugger */ } vm->gdb_debug_from_poll = 0; /* whether or not we entered from poll doesn't * matter this time, but we'd better reset it * before next time this function runs */ } else { /* reestablish an old connection. We might get here either * for internal reasons (hitting a breakpoint) or for external * reasons (gdb sent us a ^C). If external, we need to swallow * the break packet. Then in either case, let GDB know why * we stopped. */ if (vm->gdb_debug_from_poll) { vm->gdb_debug_from_poll = 0; int cc; char c; cc = read (vm->gdb_interact_sock, &c, 1); if (cc != 1 || c != '\003') { fprintf (stderr, "input_interrupt, cc = %d c = %d\n", cc, c); goto errout; } sig = SIGINT; /* Inform the remote debugger we have entered debugging mode. */ // snprintf (cmd_buf, sizeof(cmd_buf), "S%02x%02x", sig, debug_cpuno); snprintf (cmd_buf, sizeof(cmd_buf), "S%02x", sig); if (putpkt (vm->gdb_interact_sock, cmd_buf) < 0) goto errout; } } while (1) { char ch; i = 0; int pkg_len = 0; if ((pkg_len = getpkt (vm->gdb_interact_sock, cmd_buf)) <= 0) goto errout; ch = cmd_buf[i++]; SIM_DEBUG (('g', "gdb command %c \n", ch)); //printf("---\n gdb command %s\n",cmd_buf); switch (ch) { case 'c': ret = SD_CONTINUE; goto out; case 'g': //read register { m_uint32_t r = 0; b = cmd_buf; for (i = 0; i < GDB_NUM_REGS; i++) { //FIXME: find the mapping from register index to register of cpu and cpu0 of gdb if (vm->boot_cpu->reg_get (vm->boot_cpu, i, &r) == FAILURE) r = 0; /* * flip the bytes around */ r = htovm32 (r); //gdb likes the data of target machine format convert_int_to_ascii ((char *) &r, b, 4); b += 8; } *b = 0; break; } case 'H': write_ok (cmd_buf); break; case 'm': { m_uint32_t memaddr; unsigned int len; if (sscanf (cmd_buf + 1, "%x,%x", &memaddr, &len) != 2) { write_enn (cmd_buf); } else { if (debug_read_memory (vm->boot_cpu, memaddr, len, cmd_buf) != SUCCESS) write_enn (cmd_buf); } break; } case 'p': { m_uint32_t r, index = 0; b = cmd_buf; if (sscanf (cmd_buf + 1, "%x", &index) != 1) write_enn (cmd_buf); else { // index=vmtoh32(index); if (vm->boot_cpu->reg_get (vm->boot_cpu, index, &r) == FAILURE) r = 0; /* * flip the bytes around */ r = htovm32 (r); //gdb likes the data of target machine format convert_int_to_ascii ((char *) &r, b, 4); //*(r+4)=0; //*(r+5)=0; //*(r+6)=0; //*(r+7)=0; } } break; case 'v': { char *cmd_tmp; cmd_tmp = cmd_buf; if (strncmp (cmd_buf, VCONT, strlen (VCONT)) != 0) write_enn (cmd_buf); else { cmd_tmp += strlen (VCONT); if (';' == cmd_tmp[0]) { cmd_tmp++; if ('c' == cmd_tmp[0]) { ret = SD_CONTINUE; goto out; } else if ('s' == cmd_tmp[0]) { /*single step */ int cpuno; cpuno = 0; ret = cpuno; goto out; } else write_enn (cmd_buf); } else if ('?' == (cmd_tmp)[0]) { /*query */ strlcpy (cmd_buf, VCONT ";c", sizeof(cmd_buf)); } else write_enn (cmd_buf); } } break; case 'q': { if (strncmp (cmd_buf, QSYMBOL, strlen (QSYMBOL)) == 0) write_ok (cmd_buf); else if (strncmp (cmd_buf, QC, strlen (QC)) == 0) { strlcpy (cmd_buf, "QC0", sizeof(cmd_buf)); } else if (strncmp (cmd_buf, QOFFSETS, strlen (QOFFSETS)) == 0) { strlcpy (cmd_buf, "Text=0;Data=0;Bss=0", sizeof(cmd_buf)); } else { write_enn (cmd_buf); } } break; case 's': case 'S': ret = SD_NEXTI_ANYCPU; goto out; case 'z': { m_uint32_t addr; int len; if ('0' == (cmd_buf + 1)[0]) { //memory breakpoint if (sscanf (cmd_buf + 3, "%x,%x", &addr, &len) != 2) { write_enn (cmd_buf); } else { if (delete_breakpoint (vm, addr, len) != SUCCESS) write_enn (cmd_buf); else { write_ok (cmd_buf); } } } else write_enn (cmd_buf); } break; case 'Z': { m_uint32_t addr; int len; if ('0' == (cmd_buf + 1)[0]) { //memory breakpoint if (sscanf (cmd_buf + 3, "%x,%x", &addr, &len) != 2) { write_enn (cmd_buf); } else { virtual_breakpoint_t *tmp = alloc_breakpoint (vm, addr, 0, len); insert_breakpoint (vm, tmp); write_ok (cmd_buf); } } else write_enn (cmd_buf); } break; case '?': snprintf (cmd_buf, sizeof(cmd_buf), "S%02x", sig); break; default: write_enn (cmd_buf); break; } //printf("send %s\n",cmd_buf); if (putpkt (vm->gdb_interact_sock, cmd_buf) < 0) goto errout; } out: return ret; errout: /* the connection was terminated prematurely. Reset */ close (vm->gdb_interact_sock); vm->gdb_interact_sock = -1; printf ("Remote debugger connection lost, continuing...\n"); return SD_CONTINUE; } void bad_memory_access_gdb (vm_instance_t * vm) { static char cmd_buf[BUFSIZ + 1]; vm->mipsy_break_nexti = MIPS_BREAKANYCPU; snprintf (cmd_buf, sizeof(cmd_buf), "S%02x", SIGTRAP); if (putpkt (vm->gdb_interact_sock, cmd_buf) < 0) { /* the connection was terminated prematurely. Reset */ close (vm->gdb_interact_sock); vm->gdb_interact_sock = -1; vm->mipsy_debug_mode = 0; //we do not debug anymore printf ("Remote debugger connection lost, continuing...\n"); } } ================================================ FILE: tools/virtualmips/gdb_interface.h ================================================ /* * Copyright (C) yajin 2008 * * This file is part of the virtualmips distribution. * See LICENSE file for terms of the license. * */ #ifndef __GDB_INTERFACE_H__ #define __GDB_INTERFACE_H__ #include "utils.h" #include "mips.h" typedef enum Simdebug_result { SD_CONTINUE = -2, SD_NEXTI_ANYCPU = -1 } Simdebug_result; typedef struct virtualBreakpoint { m_uint32_t addr; char *save; //int cpuno; int len; /*break point instruction len */ struct virtualBreakpoint *next; } virtual_breakpoint_t; int cpu_hit_breakpoint (vm_instance_t * vm, m_uint32_t vaddr); Simdebug_result Simdebug_run (vm_instance_t * vm, int sig); void bad_memory_access_gdb (vm_instance_t * vm); #endif ================================================ FILE: tools/virtualmips/jz4740/jz4740.c ================================================ /* * Copyright (C) yajin 2008 * * This file is part of the virtualmips distribution. * See LICENSE file for terms of the license. * */ #include #include #include #include #include "utils.h" #include "mips.h" #include "vm.h" #include "cpu.h" #include "mips_exec.h" #include "debug.h" #include "jz4740.h" #include "pavo.h" #include "device.h" int jz4740_boot_from_nandflash (vm_instance_t * vm) { struct vdevice *dev; unsigned char *page_addr; int i; pavo_t *pavo; if (vm->type == VM_TYPE_PAVO) { pavo = VM_PAVO (vm); } else ASSERT (0, "Error vm type\n"); /*get ram device */ dev = dev_lookup (vm, 0x0); assert (dev != NULL); assert (dev->host_addr != 0); /*copy 8K nand flash data to 8K RAM */ for (i = 0; i < (0x2000 / NAND_FLASH_1G_PAGE_DATA_SIZE); i++) { page_addr = get_nand_flash_page_ptr (i, pavo->nand_flash->flash_map[0]); memcpy ((unsigned char *) dev->host_addr + NAND_FLASH_1G_PAGE_DATA_SIZE * i, page_addr, NAND_FLASH_1G_PAGE_DATA_SIZE); } return (0); } int jz4740_reset (vm_instance_t * vm) { cpu_mips_t *cpu; m_va_t kernel_entry_point; vm_suspend (vm); /* Check that CPU activity is really suspended */ if (cpu_group_sync_state (vm->cpu_group) == -1) { vm_error (vm, "unable to sync with system CPUs.\n"); return (-1); } /* Reset the boot CPU */ cpu = (vm->boot_cpu); mips_reset (cpu); /*set configure register */ cpu->cp0.config_usable = 0x83; /* configure sel 0 1 7 is valid */ cpu->cp0.config_reg[0] = JZ4740_CONFIG0; cpu->cp0.config_reg[1] = JZ4740_CONFIG1; cpu->cp0.config_reg[7] = JZ4740_CONFIG7; /*set PC and PRID */ cpu->cp0.reg[MIPS_CP0_PRID] = JZ4740_PRID; cpu->cp0.tlb_entries = JZ4740_DEFAULT_TLB_ENTRYNO; cpu->pc = JZ4740_ROM_PC; /*reset all devices */ dev_reset_all (vm); #ifdef _USE_JIT_ /*if jit is used. flush all jit buffer */ if (vm->jit_use) mips_jit_flush (cpu, 0); #endif /*If we boot from elf kernel image, load the image and set pc to elf entry */ if (vm->boot_method == BOOT_ELF) { if (mips_load_elf_image (cpu, vm->kernel_filename, &kernel_entry_point) == -1) return (-1); cpu->pc = kernel_entry_point; } else if (vm->boot_method == BOOT_BINARY) { if (jz4740_boot_from_nandflash (vm) == -1) return (-1); } /* Launch the simulation */ printf ("VM '%s': starting simulation (CPU0 PC=0x%" LL "x), JIT %sabled.\n", vm->name, cpu->pc, vm->jit_use ? "en" : "dis"); vm->status = VM_STATUS_RUNNING; cpu_start (vm->boot_cpu); return (0); } ================================================ FILE: tools/virtualmips/jz4740/jz4740.h ================================================ /* * Copyright (C) yajin 2008 * * This file is part of the virtualmips distribution. * See LICENSE file for terms of the license. * */ /*JZ4740 Header file */ #ifndef __JZ4740_H__ #define __JZ4740_H__ #include "types.h" /*virtual address and physical address*/ typedef m_uint32_t m_va_t; typedef m_uint32_t m_pa_t; typedef m_uint32_t m_reg_t; typedef m_int32_t m_ireg_t; typedef m_uint32_t m_cp0_reg_t; #define DATA_WIDTH 32 /*64 */ #define LL /*JZ4740 use soft fpu*/ #define SOFT_FPU 1 /*Guest endian*/ #define GUEST_BYTE_ORDER ARCH_LITTLE_ENDIAN #ifndef GUEST_BYTE_ORDER #error Please define guest architecture in utils.h! #endif /* Host to VM conversion functions */ #if HOST_BYTE_ORDER == GUEST_BYTE_ORDER #define htovm16(x) (x) #define htovm32(x) (x) #define htovm64(x) (x) #define vmtoh16(x) (x) #define vmtoh32(x) (x) #define vmtoh64(x) (x) #elif HOST_BYTE_ORDER==ARCH_LITTLE_ENDIAN //host:little guest:big #define htovm16(x) (htons(x)) #define htovm32(x) (htonl(x)) #define htovm64(x) (swap64(x)) #define vmtoh16(x) (ntohs(x)) #define vmtoh32(x) (ntohl(x)) #define vmtoh64(x) (swap64(x)) #else //host:big guest:little #define htovm16(x) (ntohs(x)) #define htovm32(x) (ntohl(x)) #define htovm64(x) (swap64(x)) #define vmtoh16(x) (htons(x)) #define vmtoh32(x) (htonl(x)) #define vmtoh64(x) (swap64(x)) #endif #define JZ4740_CONFIG0 0x80000082 #define JZ4740_CONFIG1 0x3E613080 /*CACHE (128SET*32 BYTES*2 WAY)= 8K */ #define JZ4740_CONFIG7 0x0 #define JZ4740_ROM_PC 0x80000004 #define JZ4740_PRID 0x0ad0024f /*jz4740 prid */ #define JZ4740_DEFAULT_TLB_ENTRYNO 32 /*32 pairs */ /*------------------------REG DEFINE---------------------------------*/ #define NAND_DATAPORT 0x18000000 #define NAND_ADDRPORT 0x18010000 #define NAND_COMMPORT 0x18008000 /*FOR CS8900*/ #define CS8900_IO_BASE 0x8000000 #define CS8900_SIZE 0x10 #define CS8900_DEFAULT_IRQ 107 #define CS8900_GPIO_GROUP 1 /* GPIO is in 4 groups. 32 per group*/ /* 48-79 0 80-111 1 112-143 2 144-175 3 so irq 107 is in gpio group 1 */ /*---------------------GPIO----------------------------------*/ #define JZ4740_GPIO_BASE 0x10010000 #define JZ4740_GPIO_SIZE 0x388 //n = 0,1,2,3 #define GPIO_PXPIN(n) ( (0x00 + (n)*0x100)) /* PIN Level Register */ #define GPIO_PXDAT(n) ((0x10 + (n)*0x100)) /* Port Data Register */ #define GPIO_PXDATS(n) ( (0x14 + (n)*0x100)) /* Port Data Set Register */ #define GPIO_PXDATC(n) ( (0x18 + (n)*0x100)) /* Port Data Clear Register */ #define GPIO_PXIM(n) ( (0x20 + (n)*0x100)) /* Interrupt Mask Register */ #define GPIO_PXIMS(n) ( (0x24 + (n)*0x100)) /* Interrupt Mask Set Reg */ #define GPIO_PXIMC(n) ( (0x28 + (n)*0x100)) /* Interrupt Mask Clear Reg */ #define GPIO_PXPE(n) ((0x30 + (n)*0x100)) /* Pull Enable Register */ #define GPIO_PXPES(n) ( (0x34 + (n)*0x100)) /* Pull Enable Set Reg. */ #define GPIO_PXPEC(n) ( (0x38 + (n)*0x100)) /* Pull Enable Clear Reg. */ #define GPIO_PXFUN(n) ( (0x40 + (n)*0x100)) /* Function Register */ #define GPIO_PXFUNS(n) ( (0x44 + (n)*0x100)) /* Function Set Register */ #define GPIO_PXFUNC(n) ( (0x48 + (n)*0x100)) /* Function Clear Register */ #define GPIO_PXSEL(n) ( (0x50 + (n)*0x100)) /* Select Register */ #define GPIO_PXSELS(n) ( (0x54 + (n)*0x100)) /* Select Set Register */ #define GPIO_PXSELC(n) ( (0x58 + (n)*0x100)) /* Select Clear Register */ #define GPIO_PXDIR(n) ( (0x60 + (n)*0x100)) /* Direction Register */ #define GPIO_PXDIRS(n) ( (0x64 + (n)*0x100)) /* Direction Set Register */ #define GPIO_PXDIRC(n) ( (0x68 + (n)*0x100)) /* Direction Clear Register */ #define GPIO_PXTRG(n) ( (0x70 + (n)*0x100)) /* Trigger Register */ #define GPIO_PXTRGS(n) ( (0x74 + (n)*0x100)) /* Trigger Set Register */ #define GPIO_PXTRGC(n) ( (0x78 + (n)*0x100)) /* Trigger Set Register */ #define GPIO_PXFLG(n) ( (0x80 + (n)*0x100)) /* Port Flag Register */ /* According to datasheet, it is 0x14. I think it shoud be 0x84*/ #define GPIO_PXFLGC(n) ( (0x84 + (n)*0x100)) /* Port Flag clear Register */ #define JZ4740_GPIO_INDEX_MAX 0xe2 /*0x388/4 */ /*---------------------UART----------------------------------*/ #define JZ4740_UART_SIZE 0x302c #define JZ4740_UART0_BASE 0x10030000 #define JZ4740_UART0_SIZE 0x2c #define JZ4740_UART1_BASE 0x10031000 #define JZ4740_UART1_SIZE 0x2c #define JZ4740_UART2_BASE 0x10032000 #define JZ4740_UART2_SIZE 0x2c #define JZ4740_UART3_BASE 0x10033000 #define JZ4740_UART3_SIZE 0x2c #define JZ4740_UART_BASE JZ4740_UART0_BASE #define UART_RBR (0x00) #define UART_THR (0x00) #define UART_DLLR (0x00) #define UART_DLHR (0x04) #define UART_IER (0x04) #define UART_IIR (0x08) #define UART_FCR (0x08) #define UART_LCR (0x0C) #define UART_MCR (0x10) #define UART_LSR (0x14) #define UART_MSR (0x18) #define UART_SPR (0x1C) #define UART_ISR (0x20) #define UART_UMR (0x24) #define UART_UACR (0x28) #define JZ4740_UART_INDEX_MAX 0xb //0x02c/4 #define JZ4740_UART_NUMBER 2 //we emulates two uarts #define UART_IER_RDRIE 0x01 #define UART_IER_TDRIE 0x02 #define UART_IER_RLSIE 0x04 #define UART_IER_MSIE 0x08 #define UART_IER_RTOIE 0x10 #define UART_FCR_FME 0x1 #define UART_FCR_RFRT 0x2 #define UART_FCR_TFRT 0x4 #define UART_FCR_DME 0x8 #define UART_FCR_UME 0x10 #define UART_FCR_RDTR 0xC0 #define UART_FCR_RDTR_SHIFT 0x6 #define UART_LSR_DRY 0x1 #define UART_LSR_OVER 0x2 #define UART_LSR_PARER 0x4 #define UART_LSR_FMER 0x8 #define UART_LSR_BI 0x10 #define UART_LSR_TDRQ 0x20 #define UART_LSR_TEMP 0x40 #define UART_LSR_FIFOE 0x80 /*-------------------PLL----------------------*/ #define JZ4740_CPM_BASE 0x10000000 #define JZ4740_CPM_SIZE 0X70 #define CPM_CPCCR (0x00) #define CPM_CPPCR (0x10) #define CPM_I2SCDR (0x60) #define CPM_LPCDR (0x64) #define CPM_MSCCDR (0x68) #define CPM_UHCCDR (0x6C) #define CPM_LCR (0x04) #define CPM_CLKGR (0x20) #define CPM_SCR (0x24) #define CPM_HCR (0x30) #define CPM_HWFCR (0x34) #define CPM_HRCR (0x38) #define CPM_HWCR (0x3c) #define CPM_HWSR (0x40) #define CPM_HSPR (0x44) #define JZ4740_CPM_INDEX_MAX 0X1c /*0X70/4 */ /*-------------------EMC----------------------*/ #define JZ4740_EMC_BASE 0x13010000 #define JZ4740_EMC_SIZE 0xa400 /*FROM A000-A3FF is mode register */ #define EMC_BCR ( 0x0) /* BCR */ #define EMC_SMCR0 ( 0x10) /* Static Memory Control Register 0 */ #define EMC_SMCR1 ( 0x14) /* Static Memory Control Register 1 */ #define EMC_SMCR2 ( 0x18) /* Static Memory Control Register 2 */ #define EMC_SMCR3 ( 0x1c) /* Static Memory Control Register 3 */ #define EMC_SMCR4 ( 0x20) /* Static Memory Control Register 4 */ #define EMC_SACR0 ( 0x30) /* Static Memory Bank 0 Addr Config Reg */ #define EMC_SACR1 ( 0x34) /* Static Memory Bank 1 Addr Config Reg */ #define EMC_SACR2 ( 0x38) /* Static Memory Bank 2 Addr Config Reg */ #define EMC_SACR3 ( 0x3c) /* Static Memory Bank 3 Addr Config Reg */ #define EMC_SACR4 ( 0x40) /* Static Memory Bank 4 Addr Config Reg */ #define EMC_NFCSR ( 0x050) /* NAND Flash Control/Status Register */ #define EMC_NFECR ( 0x100) /* NAND Flash ECC Control Register */ #define EMC_NFECC ( 0x104) /* NAND Flash ECC Data Register */ #define EMC_NFPAR0 ( 0x108) /* NAND Flash RS Parity 0 Register */ #define EMC_NFPAR1 ( 0x10c) /* NAND Flash RS Parity 1 Register */ #define EMC_NFPAR2 ( 0x110) /* NAND Flash RS Parity 2 Register */ #define EMC_NFINTS ( 0x114) /* NAND Flash Interrupt Status Register */ #define EMC_NFINTE ( 0x118) /* NAND Flash Interrupt Enable Register */ #define EMC_NFERR0 ( 0x11c) /* NAND Flash RS Error Report 0 Register */ #define EMC_NFERR1 ( 0x120) /* NAND Flash RS Error Report 1 Register */ #define EMC_NFERR2 ( 0x124) /* NAND Flash RS Error Report 2 Register */ #define EMC_NFERR3 ( 0x128) /* NAND Flash RS Error Report 3 Register */ #define EMC_DMCR ( 0x80) /* DRAM Control Register */ #define EMC_RTCSR ( 0x84) /* Refresh Time Control/Status Register */ #define EMC_RTCNT ( 0x88) /* Refresh Timer Counter */ #define EMC_RTCOR ( 0x8c) /* Refresh Time Constant Register */ #define EMC_DMAR0 ( 0x90) /* SDRAM Bank 0 Addr Config Register */ #define EMC_SDMR0 ( 0xa000) /* Mode Register of SDRAM bank 0 */ /*has other register*/ #define JZ4740_EMC_INDEX_MAX 0x4b /*0x12c/4 */ /*-----------------------RTC-------------------------------------*/ #define JZ4740_RTC_BASE 0x10003000 #define JZ4740_RTC_SIZE 0x38 #define RTC_RCR ( 0x00) /* RTC Control Register */ #define RTC_RSR ( 0x04) /* RTC Second Register */ #define RTC_RSAR ( 0x08) /* RTC Second Alarm Register */ #define RTC_RGR ( 0x0c) /* RTC Regulator Register */ #define RTC_HCR ( 0x20) /* Hibernate Control Register */ #define RTC_HWFCR ( 0x24) /* Hibernate Wakeup Filter Counter Reg */ #define RTC_HRCR ( 0x28) /* Hibernate Reset Counter Register */ #define RTC_HWCR ( 0x2c) /* Hibernate Wakeup Control Register */ #define RTC_HWRSR ( 0x30) /* Hibernate Wakeup Status Register */ #define RTC_HSPR ( 0x34) /* Hibernate Scratch Pattern Register */ #define RTC_RCR_WRDY_BIT 7 #define RTC_RCR_WRDY (1 << 7) /* Write Ready Flag */ #define RTC_RCR_1HZ_BIT 6 #define RTC_RCR_1HZ (1 << RTC_RCR_1HZ_BIT) /* 1Hz Flag */ #define RTC_RCR_1HZIE (1 << 5) /* 1Hz Interrupt Enable */ #define RTC_RCR_AF_BIT 4 #define RTC_RCR_AF (1 << RTC_RCR_AF_BIT) /* Alarm Flag */ #define RTC_RCR_AIE (1 << 3) /* Alarm Interrupt Enable */ #define RTC_RCR_AE (1 << 2) /* Alarm Enable */ #define RTC_RCR_RTCE (1 << 0) /* RTC Enable */ /* RTC Regulator Register */ #define RTC_RGR_LOCK (1 << 31) /* Lock Bit */ #define RTC_RGR_ADJC_BIT 16 #define RTC_RGR_ADJC_MASK (0x3ff << RTC_RGR_ADJC_BIT) #define RTC_RGR_NC1HZ_BIT 0 #define RTC_RGR_NC1HZ_MASK (0xffff << RTC_RGR_NC1HZ_BIT) /* Hibernate Control Register */ #define RTC_HCR_PD (1 << 0) /* Power Down */ /* Hibernate Wakeup Filter Counter Register */ #define RTC_HWFCR_BIT 5 #define RTC_HWFCR_MASK (0x7ff << RTC_HWFCR_BIT) /* Hibernate Reset Counter Register */ #define RTC_HRCR_BIT 5 #define RTC_HRCR_MASK (0x7f << RTC_HRCR_BIT) /* Hibernate Wakeup Control Register */ #define RTC_HWCR_EALM (1 << 0) /* RTC alarm wakeup enable */ /* Hibernate Wakeup Status Register */ #define RTC_HWRSR_HR (1 << 5) /* Hibernate reset */ #define RTC_HWRSR_PPR (1 << 4) /* PPR reset */ #define RTC_HWRSR_PIN (1 << 1) /* Wakeup pin status bit */ #define RTC_HWRSR_ALM (1 << 0) /* RTC alarm status bit */ #define JZ4740_RTC_INDEX_MAX 0xe /*0x38/4 */ /*----------------------WDT&TCU--------------------------------*/ #define JZ4740_WDT_TCU_BASE 0x10002000 #define JZ4740_WDT_TCU_SIZE 0xa0 #define WDT_TDR ( 0x00) #define WDT_TCER ( 0x04) #define WDT_TCNT ( 0x08) #define WDT_TCSR ( 0x0C) #define TCU_CLOCK_EXT 0x4 #define TCU_CLOCK_RTC 0x2 #define TCU_CLOCK_PCK 0x0 #define TCU_CLOCK_SOUCE_MASK 0x7 #define TCU_CLOCK_PRESCALE_MASK 0x38 #define TCU_CLOCK_PRESCALE_OFFSET 0x3 #define WDT_CLOCK_EXT 0x4 #define WDT_CLOCK_RTC 0x2 #define WDT_CLOCK_PCK 0x0 #define WDT_CLOCK_SOUCE_MASK 0x7 #define WDT_CLOCK_PRESCALE_MASK 0x38 #define WDT_CLOCK_PRESCALE_OFFSET 0x3 #define EXT_CLOCK 12000000 /*12M */ #define RTC_CLOCK 32768 /************************************************************************* * TCU (Timer Counter Unit) *************************************************************************/ #define TCU_TSR ( 0x1C) /* Timer Stop Register */ #define TCU_TSSR ( 0x2C) /* Timer Stop Set Register */ #define TCU_TSCR ( 0x3C) /* Timer Stop Clear Register */ #define TCU_TER ( 0x10) /* Timer Counter Enable Register */ #define TCU_TESR ( 0x14) /* Timer Counter Enable Set Register */ #define TCU_TECR ( 0x18) /* Timer Counter Enable Clear Register */ #define TCU_TFR ( 0x20) /* Timer Flag Register */ #define TCU_TFSR ( 0x24) /* Timer Flag Set Register */ #define TCU_TFCR ( 0x28) /* Timer Flag Clear Register */ #define TCU_TMR ( 0x30) /* Timer Mask Register */ #define TCU_TMSR ( 0x34) /* Timer Mask Set Register */ #define TCU_TMCR ( 0x38) /* Timer Mask Clear Register */ #define TCU_TDFR0 ( 0x40) /* Timer Data Full Register */ #define TCU_TDHR0 ( 0x44) /* Timer Data Half Register */ #define TCU_TCNT0 ( 0x48) /* Timer Counter Register */ #define TCU_TCSR0 ( 0x4C) /* Timer Control Register */ #define TCU_TDFR1 ( 0x50) #define TCU_TDHR1 ( 0x54) #define TCU_TCNT1 ( 0x58) #define TCU_TCSR1 ( 0x5C) #define TCU_TDFR2 (0x60) #define TCU_TDHR2 ( 0x64) #define TCU_TCNT2 ( 0x68) #define TCU_TCSR2 ( 0x6C) #define TCU_TDFR3 ( 0x70) #define TCU_TDHR3 ( 0x74) #define TCU_TCNT3 ( 0x78) #define TCU_TCSR3 ( 0x7C) #define TCU_TDFR4 ( 0x80) #define TCU_TDHR4 ( 0x84) #define TCU_TCNT4 ( 0x88) #define TCU_TCSR4 ( 0x8C) #define TCU_TDFR5 ( 0x90) #define TCU_TDHR5 ( 0x94) #define TCU_TCNT5 ( 0x98) #define TCU_TCSR5 ( 0x9C) #define TCU_TDFR(n) (TCU_TDFR0+n*0x10) #define TCU_TDHR(n) (TCU_TDHR0+n*0x10) #define TCU_TCNT(n) (TCU_TCNT0+n*0x10) #define TCU_TCSR(n) (TCU_TCSR0+n*0x10) #define WDT_TIMER_STOP 0x10000 #define JZ4740_WDT_INDEX_MAX 0x28 /*0xa0/4 */ /*-------------------LCD---------------------*/ #define JZ4740_LCD_BASE 0x13050000 #define JZ4740_LCD_SIZE 0x60 #define LCD_CFG ( 0x00) /* LCD Configure Register */ #define LCD_VSYNC ( 0x04) /* Vertical Synchronize Register */ #define LCD_HSYNC ( 0x08) /* Horizontal Synchronize Register */ #define LCD_VAT ( 0x0c) /* Virtual Area Setting Register */ #define LCD_DAH ( 0x10) /* Display Area Horizontal Start/End Point */ #define LCD_DAV ( 0x14) /* Display Area Vertical Start/End Point */ #define LCD_PS ( 0x18) /* PS Signal Setting */ #define LCD_CLS ( 0x1c) /* CLS Signal Setting */ #define LCD_SPL ( 0x20) /* SPL Signal Setting */ #define LCD_REV ( 0x24) /* REV Signal Setting */ #define LCD_CTRL ( 0x30) /* LCD Control Register */ #define LCD_STATE ( 0x34) /* LCD Status Register */ #define LCD_IID ( 0x38) /* Interrupt ID Register */ #define LCD_DA0 ( 0x40) /* Descriptor Address Register 0 */ #define LCD_SA0 ( 0x44) /* Source Address Register 0 */ #define LCD_FID0 ( 0x48) /* Frame ID Register 0 */ #define LCD_CMD0 ( 0x4c) /* DMA Command Register 0 */ #define LCD_DA1 ( 0x50) /* Descriptor Address Register 1 */ #define LCD_SA1 ( 0x54) /* Source Address Register 1 */ #define LCD_FID1 ( 0x58) /* Frame ID Register 1 */ #define LCD_CMD1 ( 0x5c) /* DMA Command Register 1 */ #define LCD_CTRL_BST_BIT 28 /* Burst Length Selection */ #define LCD_CTRL_BST_MASK (0x03 << LCD_CTRL_BST_BIT) #define LCD_CTRL_BST_4 (0 << LCD_CTRL_BST_BIT) /* 4-word */ #define LCD_CTRL_BST_8 (1 << LCD_CTRL_BST_BIT) /* 8-word */ #define LCD_CTRL_BST_16 (2 << LCD_CTRL_BST_BIT) /* 16-word */ #define LCD_CTRL_RGB565 (0 << 27) /* RGB565 mode */ #define LCD_CTRL_RGB555 (1 << 27) /* RGB555 mode */ #define LCD_CTRL_OFUP (1 << 26) /* Output FIFO underrun protection enable */ #define LCD_CTRL_FRC_BIT 24 /* STN FRC Algorithm Selection */ #define LCD_CTRL_FRC_MASK (0x03 << LCD_CTRL_FRC_BIT) #define LCD_CTRL_FRC_16 (0 << LCD_CTRL_FRC_BIT) /* 16 grayscale */ #define LCD_CTRL_FRC_4 (1 << LCD_CTRL_FRC_BIT) /* 4 grayscale */ #define LCD_CTRL_FRC_2 (2 << LCD_CTRL_FRC_BIT) /* 2 grayscale */ #define LCD_CTRL_PDD_BIT 16 /* Load Palette Delay Counter */ #define LCD_CTRL_PDD_MASK (0xff << LCD_CTRL_PDD_BIT) #define LCD_CTRL_EOFM (1 << 13) /* EOF interrupt mask */ #define LCD_CTRL_SOFM (1 << 12) /* SOF interrupt mask */ #define LCD_CTRL_OFUM (1 << 11) /* Output FIFO underrun interrupt mask */ #define LCD_CTRL_IFUM0 (1 << 10) /* Input FIFO 0 underrun interrupt mask */ #define LCD_CTRL_IFUM1 (1 << 9) /* Input FIFO 1 underrun interrupt mask */ #define LCD_CTRL_LDDM (1 << 8) /* LCD disable done interrupt mask */ #define LCD_CTRL_QDM (1 << 7) /* LCD quick disable done interrupt mask */ #define LCD_CTRL_BEDN (1 << 6) /* Endian selection */ #define LCD_CTRL_PEDN (1 << 5) /* Endian in byte:0-msb first, 1-lsb first */ #define LCD_CTRL_DIS (1 << 4) /* Disable indicate bit */ #define LCD_CTRL_ENA (1 << 3) /* LCD enable bit */ #define LCD_CTRL_BPP_BIT 0 /* Bits Per Pixel */ #define LCD_CTRL_BPP_MASK (0x07 << LCD_CTRL_BPP_BIT) #define LCD_CTRL_BPP_1 (0 << LCD_CTRL_BPP_BIT) /* 1 bpp */ #define LCD_CTRL_BPP_2 (1 << LCD_CTRL_BPP_BIT) /* 2 bpp */ #define LCD_CTRL_BPP_4 (2 << LCD_CTRL_BPP_BIT) /* 4 bpp */ #define LCD_CTRL_BPP_8 (3 << LCD_CTRL_BPP_BIT) /* 8 bpp */ #define LCD_CTRL_BPP_16 (4 << LCD_CTRL_BPP_BIT) /* 15/16 bpp */ #define LCD_CTRL_BPP_18_24 (5 << LCD_CTRL_BPP_BIT) /* 18/24/32 bpp */ /* Display Area Horizontal Start/End Point Register */ #define LCD_DAH_HDS_BIT 16 /* Horizontal display area start in dot clock */ #define LCD_DAH_HDS_MASK (0xffff << LCD_DAH_HDS_BIT) #define LCD_DAH_HDE_BIT 0 /* Horizontal display area end in dot clock */ #define LCD_DAH_HDE_MASK (0xffff << LCD_DAH_HDE_BIT) /* Display Area Vertical Start/End Point Register */ #define LCD_DAV_VDS_BIT 16 /* Vertical display area start in line clock */ #define LCD_DAV_VDS_MASK (0xffff << LCD_DAV_VDS_BIT) #define LCD_DAV_VDE_BIT 0 /* Vertical display area end in line clock */ #define LCD_DAV_VDE_MASK (0xffff << LCD_DAV_VDE_BIT) #define LCD_STATE_QD (1 << 7) /* Quick Disable Done */ #define LCD_STATE_EOF (1 << 5) /* EOF Flag */ #define LCD_STATE_SOF (1 << 4) /* SOF Flag */ #define LCD_STATE_OFU (1 << 3) /* Output FIFO Underrun */ #define LCD_STATE_IFU0 (1 << 2) /* Input FIFO 0 Underrun */ #define LCD_STATE_IFU1 (1 << 1) /* Input FIFO 1 Underrun */ #define LCD_STATE_LDD (1 << 0) /* LCD Disabled */ #define LCD_CMD_SOFINT (1 << 31) #define LCD_CMD_EOFINT (1 << 30) #define LCD_CMD_PAL (1 << 28) #define LCD_CMD_LEN_BIT 0 #define LCD_CMD_LEN_MASK (0xffffff << LCD_CMD_LEN_BIT) #define JZ4740_LCD_INDEX_MAX 0x18 /*0x60/4 */ /*---------------------touch screen------------------*/ #define JZ4740_TS_BASE 0x10070000 #define JZ4740_TS_SIZE 0x28 #define SADC_ENA ( 0x00) /* ADC Enable Register */ #define SADC_CFG ( 0x04) /* ADC Configure Register */ #define SADC_CTRL ( 0x08) /* ADC Control Register */ #define SADC_STATE ( 0x0C) /* ADC Status Register */ #define SADC_SAMETIME ( 0x10) /* ADC Same Point Time Register */ #define SADC_WAITTIME ( 0x14) /* ADC Wait Time Register */ #define SADC_TSDAT ( 0x18) /* ADC Touch Screen Data Register */ #define SADC_BATDAT ( 0x1C) /* ADC PBAT Data Register */ #define SADC_SADDAT ( 0x20) /* ADC SADCIN Data Register */ /* ADC Enable Register */ #define SADC_ENA_ADEN (1 << 7) /* Touch Screen Enable */ #define SADC_ENA_TSEN (1 << 2) /* Touch Screen Enable */ #define SADC_ENA_PBATEN (1 << 1) /* PBAT Enable */ #define SADC_ENA_SADCINEN (1 << 0) /* SADCIN Enable */ /* ADC Configure Register */ #define SADC_CFG_EXIN (1 << 30) #define SADC_CFG_CLKOUT_NUM_BIT 16 #define SADC_CFG_CLKOUT_NUM_MASK (0x7 << SADC_CFG_CLKOUT_NUM_BIT) #define SADC_CFG_TS_DMA (1 << 15) /* Touch Screen DMA Enable */ #define SADC_CFG_XYZ_BIT 13 /* XYZ selection */ #define SADC_CFG_XYZ_MASK (0x3 << SADC_CFG_XYZ_BIT) #define SADC_CFG_XY (0 << SADC_CFG_XYZ_BIT) #define SADC_CFG_XYZ (1 << SADC_CFG_XYZ_BIT) #define SADC_CFG_XYZ1Z2 (2 << SADC_CFG_XYZ_BIT) #define SADC_CFG_SNUM_BIT 10 /* Sample Number */ #define SADC_CFG_SNUM_MASK (0x7 << SADC_CFG_SNUM_BIT) #define SADC_CFG_SNUM_1 (0x0 << SADC_CFG_SNUM_BIT) #define SADC_CFG_SNUM_2 (0x1 << SADC_CFG_SNUM_BIT) #define SADC_CFG_SNUM_3 (0x2 << SADC_CFG_SNUM_BIT) #define SADC_CFG_SNUM_4 (0x3 << SADC_CFG_SNUM_BIT) #define SADC_CFG_SNUM_5 (0x4 << SADC_CFG_SNUM_BIT) #define SADC_CFG_SNUM_6 (0x5 << SADC_CFG_SNUM_BIT) #define SADC_CFG_SNUM_8 (0x6 << SADC_CFG_SNUM_BIT) #define SADC_CFG_SNUM_9 (0x7 << SADC_CFG_SNUM_BIT) #define SADC_CFG_CLKDIV_BIT 5 /* AD Converter frequency clock divider */ #define SADC_CFG_CLKDIV_MASK (0x1f << SADC_CFG_CLKDIV_BIT) #define SADC_CFG_PBAT_HIGH (0 << 4) /* PBAT >= 2.5V */ #define SADC_CFG_PBAT_LOW (1 << 4) /* PBAT < 2.5V */ #define SADC_CFG_CMD_BIT 0 /* ADC Command */ #define SADC_CFG_CMD_MASK (0xf << SADC_CFG_CMD_BIT) #define SADC_CFG_CMD_X_SE (0x0 << SADC_CFG_CMD_BIT) /* X Single-End */ #define SADC_CFG_CMD_Y_SE (0x1 << SADC_CFG_CMD_BIT) /* Y Single-End */ #define SADC_CFG_CMD_X_DIFF (0x2 << SADC_CFG_CMD_BIT) /* X Differential */ #define SADC_CFG_CMD_Y_DIFF (0x3 << SADC_CFG_CMD_BIT) /* Y Differential */ #define SADC_CFG_CMD_Z1_DIFF (0x4 << SADC_CFG_CMD_BIT) /* Z1 Differential */ #define SADC_CFG_CMD_Z2_DIFF (0x5 << SADC_CFG_CMD_BIT) /* Z2 Differential */ #define SADC_CFG_CMD_Z3_DIFF (0x6 << SADC_CFG_CMD_BIT) /* Z3 Differential */ #define SADC_CFG_CMD_Z4_DIFF (0x7 << SADC_CFG_CMD_BIT) /* Z4 Differential */ #define SADC_CFG_CMD_TP_SE (0x8 << SADC_CFG_CMD_BIT) /* Touch Pressure */ #define SADC_CFG_CMD_PBATH_SE (0x9 << SADC_CFG_CMD_BIT) /* PBAT >= 2.5V */ #define SADC_CFG_CMD_PBATL_SE (0xa << SADC_CFG_CMD_BIT) /* PBAT < 2.5V */ #define SADC_CFG_CMD_SADCIN_SE (0xb << SADC_CFG_CMD_BIT) /* Measure SADCIN */ #define SADC_CFG_CMD_INT_PEN (0xc << SADC_CFG_CMD_BIT) /* INT_PEN Enable */ /* ADC Control Register */ #define SADC_CTRL_PENDM (1 << 4) /* Pen Down Interrupt Mask */ #define SADC_CTRL_PENUM (1 << 3) /* Pen Up Interrupt Mask */ #define SADC_CTRL_TSRDYM (1 << 2) /* Touch Screen Data Ready Interrupt Mask */ #define SADC_CTRL_PBATRDYM (1 << 1) /* PBAT Data Ready Interrupt Mask */ #define SADC_CTRL_SRDYM (1 << 0) /* SADCIN Data Ready Interrupt Mask */ /* ADC Status Register */ #define SADC_STATE_TSBUSY (1 << 7) /* TS A/D is working */ #define SADC_STATE_PBATBUSY (1 << 6) /* PBAT A/D is working */ #define SADC_STATE_SBUSY (1 << 5) /* SADCIN A/D is working */ #define SADC_STATE_PEND (1 << 4) /* Pen Down Interrupt Flag */ #define SADC_STATE_PENU (1 << 3) /* Pen Up Interrupt Flag */ #define SADC_STATE_TSRDY (1 << 2) /* Touch Screen Data Ready Interrupt Flag */ #define SADC_STATE_PBATRDY (1 << 1) /* PBAT Data Ready Interrupt Flag */ #define SADC_STATE_SRDY (1 << 0) /* SADCIN Data Ready Interrupt Flag */ /* ADC Touch Screen Data Register */ #define SADC_TSDAT_DATA0_BIT 0 #define SADC_TSDAT_DATA0_MASK (0xfff << SADC_TSDAT_DATA0_BIT) #define SADC_TSDAT_TYPE0 (1 << 15) #define SADC_TSDAT_DATA1_BIT 16 #define SADC_TSDAT_DATA1_MASK (0xfff << SADC_TSDAT_DATA1_BIT) #define SADC_TSDAT_TYPE1 (1 << 31) #define JZ4740_TS_INDEX_MAX 0xA /*0x28/4 */ /*--------------DMA--------------------*/ #define JZ4740_DMA_BASE 0x13020000 #define JZ4740_DMA_SIZE 0x310 #define MAX_DMA_NUM 6 /* max 6 channels */ #define DMAC_DSAR(n) ( (0x00 + (n) * 0x20)) /* DMA source address */ #define DMAC_DTAR(n) ( (0x04 + (n) * 0x20)) /* DMA target address */ #define DMAC_DTCR(n) ( (0x08 + (n) * 0x20)) /* DMA transfer count */ #define DMAC_DRSR(n) ( (0x0c + (n) * 0x20)) /* DMA request source */ #define DMAC_DCCSR(n) ( (0x10 + (n) * 0x20)) /* DMA control/status */ #define DMAC_DCMD(n) ( (0x14 + (n) * 0x20)) /* DMA command */ #define DMAC_DDA(n) ( (0x18 + (n) * 0x20)) /* DMA descriptor address */ #define DMAC_DMACR ( 0x0300) /* DMA control register */ #define DMAC_DMAIPR ( 0x0304) /* DMA interrupt pending */ #define DMAC_DMADBR ( 0x0308) /* DMA doorbell */ #define DMAC_DMADBSR ( 0x030C) /* DMA doorbell set */ // channel 0 #define DMAC_DSAR0 DMAC_DSAR(0) #define DMAC_DTAR0 DMAC_DTAR(0) #define DMAC_DTCR0 DMAC_DTCR(0) #define DMAC_DRSR0 DMAC_DRSR(0) #define DMAC_DCCSR0 DMAC_DCCSR(0) #define DMAC_DCMD0 DMAC_DCMD(0) #define DMAC_DDA0 DMAC_DDA(0) // channel 1 #define DMAC_DSAR1 DMAC_DSAR(1) #define DMAC_DTAR1 DMAC_DTAR(1) #define DMAC_DTCR1 DMAC_DTCR(1) #define DMAC_DRSR1 DMAC_DRSR(1) #define DMAC_DCCSR1 DMAC_DCCSR(1) #define DMAC_DCMD1 DMAC_DCMD(1) #define DMAC_DDA1 DMAC_DDA(1) // channel 2 #define DMAC_DSAR2 DMAC_DSAR(2) #define DMAC_DTAR2 DMAC_DTAR(2) #define DMAC_DTCR2 DMAC_DTCR(2) #define DMAC_DRSR2 DMAC_DRSR(2) #define DMAC_DCCSR2 DMAC_DCCSR(2) #define DMAC_DCMD2 DMAC_DCMD(2) #define DMAC_DDA2 DMAC_DDA(2) // channel 3 #define DMAC_DSAR3 DMAC_DSAR(3) #define DMAC_DTAR3 DMAC_DTAR(3) #define DMAC_DTCR3 DMAC_DTCR(3) #define DMAC_DRSR3 DMAC_DRSR(3) #define DMAC_DCCSR3 DMAC_DCCSR(3) #define DMAC_DCMD3 DMAC_DCMD(3) #define DMAC_DDA3 DMAC_DDA(3) // channel 4 #define DMAC_DSAR4 DMAC_DSAR(4) #define DMAC_DTAR4 DMAC_DTAR(4) #define DMAC_DTCR4 DMAC_DTCR(4) #define DMAC_DRSR4 DMAC_DRSR(4) #define DMAC_DCCSR4 DMAC_DCCSR(4) #define DMAC_DCMD4 DMAC_DCMD(4) #define DMAC_DDA4 DMAC_DDA(4) // channel 5 #define DMAC_DSAR5 DMAC_DSAR(5) #define DMAC_DTAR5 DMAC_DTAR(5) #define DMAC_DTCR5 DMAC_DTCR(5) #define DMAC_DRSR5 DMAC_DRSR(5) #define DMAC_DCCSR5 DMAC_DCCSR(5) #define DMAC_DCMD5 DMAC_DCMD(5) #define DMAC_DDA5 DMAC_DDA(5) #define JZ4740_DMA_INDEX_MAX 0xC4 /*0x310/4 */ // DMA request source register #define DMAC_DRSR_RS_BIT 0 #define DMAC_DRSR_RS_MASK (0x1f << DMAC_DRSR_RS_BIT) #define DMAC_DRSR_RS_AUTO (8 << DMAC_DRSR_RS_BIT) #define DMAC_DRSR_RS_UART0OUT (20 << DMAC_DRSR_RS_BIT) #define DMAC_DRSR_RS_UART0IN (21 << DMAC_DRSR_RS_BIT) #define DMAC_DRSR_RS_SSIOUT (22 << DMAC_DRSR_RS_BIT) #define DMAC_DRSR_RS_SSIIN (23 << DMAC_DRSR_RS_BIT) #define DMAC_DRSR_RS_AICOUT (24 << DMAC_DRSR_RS_BIT) #define DMAC_DRSR_RS_AICIN (25 << DMAC_DRSR_RS_BIT) #define DMAC_DRSR_RS_MSCOUT (26 << DMAC_DRSR_RS_BIT) #define DMAC_DRSR_RS_MSCIN (27 << DMAC_DRSR_RS_BIT) #define DMAC_DRSR_RS_TCU (28 << DMAC_DRSR_RS_BIT) #define DMAC_DRSR_RS_SADC (29 << DMAC_DRSR_RS_BIT) #define DMAC_DRSR_RS_SLCD (30 << DMAC_DRSR_RS_BIT) // DMA channel control/status register #define DMAC_DCCSR_NDES (1 << 31) /* descriptor (0) or not (1) ? */ #define DMAC_DCCSR_CDOA_BIT 16 /* copy of DMA offset address */ #define DMAC_DCCSR_CDOA_MASK (0xff << DMAC_DCCSR_CDOA_BIT) #define DMAC_DCCSR_INV (1 << 6) /* descriptor invalid */ #define DMAC_DCCSR_AR (1 << 4) /* address error */ #define DMAC_DCCSR_TT (1 << 3) /* transfer terminated */ #define DMAC_DCCSR_HLT (1 << 2) /* DMA halted */ #define DMAC_DCCSR_CT (1 << 1) /* count terminated */ #define DMAC_DCCSR_EN (1 << 0) /* channel enable bit */ // DMA channel command register #define DMAC_DCMD_SAI (1 << 23) /* source address increment */ #define DMAC_DCMD_DAI (1 << 22) /* dest address increment */ #define DMAC_DCMD_RDIL_BIT 16 /* request detection interval length */ #define DMAC_DCMD_RDIL_MASK (0x0f << DMAC_DCMD_RDIL_BIT) #define DMAC_DCMD_RDIL_IGN (0 << DMAC_DCMD_RDIL_BIT) #define DMAC_DCMD_RDIL_2 (1 << DMAC_DCMD_RDIL_BIT) #define DMAC_DCMD_RDIL_4 (2 << DMAC_DCMD_RDIL_BIT) #define DMAC_DCMD_RDIL_8 (3 << DMAC_DCMD_RDIL_BIT) #define DMAC_DCMD_RDIL_12 (4 << DMAC_DCMD_RDIL_BIT) #define DMAC_DCMD_RDIL_16 (5 << DMAC_DCMD_RDIL_BIT) #define DMAC_DCMD_RDIL_20 (6 << DMAC_DCMD_RDIL_BIT) #define DMAC_DCMD_RDIL_24 (7 << DMAC_DCMD_RDIL_BIT) #define DMAC_DCMD_RDIL_28 (8 << DMAC_DCMD_RDIL_BIT) #define DMAC_DCMD_RDIL_32 (9 << DMAC_DCMD_RDIL_BIT) #define DMAC_DCMD_RDIL_48 (10 << DMAC_DCMD_RDIL_BIT) #define DMAC_DCMD_RDIL_60 (11 << DMAC_DCMD_RDIL_BIT) #define DMAC_DCMD_RDIL_64 (12 << DMAC_DCMD_RDIL_BIT) #define DMAC_DCMD_RDIL_124 (13 << DMAC_DCMD_RDIL_BIT) #define DMAC_DCMD_RDIL_128 (14 << DMAC_DCMD_RDIL_BIT) #define DMAC_DCMD_RDIL_200 (15 << DMAC_DCMD_RDIL_BIT) #define DMAC_DCMD_SWDH_BIT 14 /* source port width */ #define DMAC_DCMD_SWDH_MASK (0x03 << DMAC_DCMD_SWDH_BIT) #define DMAC_DCMD_SWDH_32 (0 << DMAC_DCMD_SWDH_BIT) #define DMAC_DCMD_SWDH_8 (1 << DMAC_DCMD_SWDH_BIT) #define DMAC_DCMD_SWDH_16 (2 << DMAC_DCMD_SWDH_BIT) #define DMAC_DCMD_DWDH_BIT 12 /* dest port width */ #define DMAC_DCMD_DWDH_MASK (0x03 << DMAC_DCMD_DWDH_BIT) #define DMAC_DCMD_DWDH_32 (0 << DMAC_DCMD_DWDH_BIT) #define DMAC_DCMD_DWDH_8 (1 << DMAC_DCMD_DWDH_BIT) #define DMAC_DCMD_DWDH_16 (2 << DMAC_DCMD_DWDH_BIT) #define DMAC_DCMD_DS_BIT 8 /* transfer data size of a data unit */ #define DMAC_DCMD_DS_MASK (0x07 << DMAC_DCMD_DS_BIT) #define DMAC_DCMD_DS_32BIT (0 << DMAC_DCMD_DS_BIT) #define DMAC_DCMD_DS_8BIT (1 << DMAC_DCMD_DS_BIT) #define DMAC_DCMD_DS_16BIT (2 << DMAC_DCMD_DS_BIT) #define DMAC_DCMD_DS_16BYTE (3 << DMAC_DCMD_DS_BIT) #define DMAC_DCMD_DS_32BYTE (4 << DMAC_DCMD_DS_BIT) #define DMAC_DCMD_TM (1 << 7) /* transfer mode: 0-single 1-block */ #define DMAC_DCMD_DES_V (1 << 4) /* descriptor valid flag */ #define DMAC_DCMD_DES_VM (1 << 3) /* descriptor valid mask: 1:support V-bit */ #define DMAC_DCMD_DES_VIE (1 << 2) /* DMA valid error interrupt enable */ #define DMAC_DCMD_TIE (1 << 1) /* DMA transfer interrupt enable */ #define DMAC_DCMD_LINK (1 << 0) /* descriptor link enable */ // DMA descriptor address register #define DMAC_DDA_BASE_BIT 12 /* descriptor base address */ #define DMAC_DDA_BASE_MASK (0x0fffff << DMAC_DDA_BASE_BIT) #define DMAC_DDA_OFFSET_BIT 4 /* descriptor offset address */ #define DMAC_DDA_OFFSET_MASK (0x0ff << DMAC_DDA_OFFSET_BIT) // DMA control register #define DMAC_DMACR_PR_BIT 8 /* channel priority mode */ #define DMAC_DMACR_PR_MASK (0x03 << DMAC_DMACR_PR_BIT) #define DMAC_DMACR_PR_012345 (0 << DMAC_DMACR_PR_BIT) #define DMAC_DMACR_PR_023145 (1 << DMAC_DMACR_PR_BIT) #define DMAC_DMACR_PR_201345 (2 << DMAC_DMACR_PR_BIT) #define DMAC_DMACR_PR_RR (3 << DMAC_DMACR_PR_BIT) /* round robin */ #define DMAC_DMACR_HLT (1 << 3) /* DMA halt flag */ #define DMAC_DMACR_AR (1 << 2) /* address error flag */ #define DMAC_DMACR_DMAE (1 << 0) /* DMA enable bit */ /*------------INT CONTROLLER------------------------*/ #define JZ4740_INT_BASE 0x10001000 #define JZ4740_INT_SIZE 0x1C #define INTC_ISR ( 0x00) #define INTC_IMR ( 0x04) #define INTC_IMSR ( 0x08) #define INTC_IMCR ( 0x0c) #define INTC_IPR ( 0x10) // 1st-level interrupts #define IRQ_I2C 1 #define IRQ_UHC 3 #define IRQ_UART0 9 #define IRQ_SADC 12 #define IRQ_MSC 14 #define IRQ_RTC 15 #define IRQ_SSI 16 #define IRQ_CIM 17 #define IRQ_AIC 18 #define IRQ_ETH 19 #define IRQ_DMAC 20 #define IRQ_TCU2 21 #define IRQ_TCU1 22 #define IRQ_TCU0 23 #define IRQ_UDC 24 #define IRQ_GPIO3 25 #define IRQ_GPIO2 26 #define IRQ_GPIO1 27 #define IRQ_GPIO0 28 #define IRQ_IPU 29 #define IRQ_LCD 30 // 2nd-level interrupts #define IRQ_DMA_0 32 /* 32 to 37 for DMAC channel 0 to 5 */ #define IRQ_GPIO_0 48 /* 48 to 175 for GPIO pin 0 to 127 */ #define JZ4740_INT_INDEX_MAX 0x7 /*0x1C/4 */ #define JZ4740_INT_TO_MIPS 0x2 /*jz4740 intc will issue int 2 to mips cpu */ int jz4740_boot_from_nandflash (vm_instance_t * vm); int jz4740_reset (vm_instance_t * vm); #endif ================================================ FILE: tools/virtualmips/jz4740/jz4740_dev_cpm.c ================================================ /* * Copyright (C) yajin 2008 * * This file is part of the virtualmips distribution. * See LICENSE file for terms of the license. * */ /*Just a dummy cpm for JZ4740 I need document!!! */ #define _GNU_SOURCE #include #include #include #include #include #include #include "device.h" #include "mips_memory.h" #include "cpu.h" #include "jz4740.h" m_uint32_t jz4740_cpm_table[JZ4740_CPM_INDEX_MAX]; struct jz4740_cpm_data { struct vdevice *dev; m_uint8_t *jz4740_cpm_ptr; m_uint32_t jz4740_cpm_size; }; void *dev_jz4740_cpm_access (cpu_mips_t * cpu, struct vdevice *dev, m_uint32_t offset, u_int op_size, u_int op_type, m_reg_t * data, m_uint8_t * has_set_value) { struct jz4740_cpm_data *d = dev->priv_data; if (offset >= d->jz4740_cpm_size) { *data = 0; return NULL; } return ((void *) (d->jz4740_cpm_ptr + offset)); } void dev_jz4740_cpm_init_defaultvalue () { memset (jz4740_cpm_table, 0x0, sizeof (jz4740_cpm_table)); } void dev_jz4740_cpm_reset (cpu_mips_t * cpu, struct vdevice *dev) { dev_jz4740_cpm_init_defaultvalue (); } int dev_jz4740_cpm_init (vm_instance_t * vm, char *name, m_pa_t paddr, m_uint32_t len) { struct jz4740_cpm_data *d; /* allocate the private data structure */ if (!(d = malloc (sizeof (*d)))) { fprintf (stderr, "jz4740_cpm: unable to create device.\n"); return (-1); } memset (d, 0, sizeof (*d)); if (!(d->dev = dev_create (name))) goto err_dev_create; d->dev->priv_data = d; d->dev->phys_addr = paddr; d->dev->phys_len = len; d->jz4740_cpm_ptr = (m_uint8_t *) (&jz4740_cpm_table[0]); d->jz4740_cpm_size = len; d->dev->handler = dev_jz4740_cpm_access; d->dev->reset_handler = dev_jz4740_cpm_reset; d->dev->flags = VDEVICE_FLAG_NO_MTS_MMAP; vm_bind_device (vm, d->dev); //dev_jz4740_cpm_init_defaultvalue(); return (0); err_dev_create: free (d); return (-1); } ================================================ FILE: tools/virtualmips/jz4740/jz4740_dev_dma.c ================================================ /* * Copyright (C) yajin 2008 * * This file is part of the virtualmips distribution. * See LICENSE file for terms of the license. * */ /*DMA Controller Only support AUTO Request. TODO: */ #define _GNU_SOURCE #include #include #include #include #include #include #include "device.h" #include "mips_memory.h" #include "cpu.h" #include "jz4740.h" m_uint32_t jz4740_dma_table[JZ4740_DMA_INDEX_MAX]; struct jz4740_dma_data { struct vdevice *dev; m_uint8_t *jz4740_dma_ptr; m_uint32_t jz4740_dma_size; }; typedef struct { m_uint32_t dcmd; /* DCMD value for the current transfer */ m_uint32_t dsadr; /* DSAR value for the current transfer */ m_uint32_t dtadr; /* DTAR value for the current transfer */ m_uint32_t ddadr; /* Points to the next descriptor + transfer count */ } jz_dma_desc; static int get_dma_unit_size (int channel, m_uint32_t cmd_value) { //switch (jz4740_dma_table[DMAC_DCMD(channel)/4]&DMAC_DCMD_DS_MASK) switch (cmd_value & DMAC_DCMD_DS_MASK) { case DMAC_DCMD_DS_32BIT: return 4; case DMAC_DCMD_DS_16BIT: return 2; case DMAC_DCMD_DS_8BIT: return 1; case DMAC_DCMD_DS_16BYTE: return 16; case DMAC_DCMD_DS_32BYTE: return 32; default: assert (0); } } void dma_non_descriptor_trans (cpu_mips_t * cpu, struct jz4740_dma_data *d, int channel) { physmem_dma_transfer (cpu->vm, jz4740_dma_table[DMAC_DSAR (channel) / 4], jz4740_dma_table[DMAC_DTAR (channel) / 4], get_dma_unit_size (channel, jz4740_dma_table[DMAC_DCMD (channel) / 4]) * jz4740_dma_table[DMAC_DTCR (channel) / 4]); /*we have finished dma */ jz4740_dma_table[DMAC_DTCR (channel) / 4] = 0; /*set DIR QP */ jz4740_dma_table[DMAC_DMAIPR / 4] |= 1 << channel; /*some cleanup work */ /*clean AR TT GLOBAL AR */ jz4740_dma_table[DMAC_DCCSR (channel) / 4] |= ~DMAC_DCCSR_AR; jz4740_dma_table[DMAC_DCCSR (channel) / 4] |= ~DMAC_DCCSR_TT; jz4740_dma_table[DMAC_DMACR / 4] |= ~DMAC_DMACR_AR; if (jz4740_dma_table[DMAC_DCMD (channel) / 4] & DMAC_DCMD_TIE) { cpu->vm->set_irq (cpu->vm, IRQ_DMAC); } } void dma_descriptor_trans (cpu_mips_t * cpu, struct jz4740_dma_data *d, int channel) { jz_dma_desc *desc; m_pa_t desc_phy; m_uint32_t dummy_data; /*fetch the first descritpor */ desc_phy = jz4740_dma_table[DMAC_DDA (channel) / 4]; ASSERT ((desc_phy & 0xf) == 0, "DDA%d should be 16 bytes aligned\n", channel); desc = physmem_get_hptr (cpu->vm, desc_phy, 4, MTS_READ, &dummy_data); ASSERT (desc != NULL, "error descriptor phyaddress %x\n", desc_phy); while (1) { if (((desc->dcmd) & DMAC_DCMD_DES_VM) && (!((desc->dcmd) & DMAC_DCMD_DES_V))) { /*STOP DMA SET DCSN.INV=1 */ jz4740_dma_table[DMAC_DCCSR (channel) / 4] |= DMAC_DCCSR_INV; return; } physmem_dma_transfer (cpu->vm, desc->dsadr, desc->dtadr, (desc->ddadr & 0xffffff) * get_dma_unit_size (channel, desc->dcmd)); if ((desc->dcmd) & DMAC_DCMD_DES_VM) { /*clear v */ desc->dcmd |= ~DMAC_DCMD_DES_V; } if ((desc->dcmd) & DMAC_DCMD_LINK) { /*set DCSN.CT=1 */ jz4740_dma_table[DMAC_DCCSR (channel) / 4] |= DMAC_DCCSR_CT; } else { /*set DCSN.TT=1 */ jz4740_dma_table[DMAC_DCCSR (channel) / 4] |= DMAC_DCCSR_TT; } if (desc->dcmd & DMAC_DCMD_TIE) { cpu->vm->set_irq (cpu->vm, IRQ_DMAC); } if ((desc->dcmd) & DMAC_DCMD_LINK) { /*fetch next descriptor */ desc_phy = jz4740_dma_table[DMAC_DDA (channel) / 4] & 0xfffff000; desc_phy += (desc->dtadr & 0xff000000) >> 24; desc = physmem_get_hptr (cpu->vm, desc_phy, 4, MTS_READ, &dummy_data); ASSERT (desc != NULL, "error descriptor phyaddress %x\n", desc_phy); } else break; } } void enable_dma_channel (cpu_mips_t * cpu, struct jz4740_dma_data *d, int channel) { if (jz4740_dma_table[DMAC_DMACR / 4] & DMAC_DMACR_DMAE) { if ((jz4740_dma_table[DMAC_DCCSR (channel) / 4] & DMAC_DCCSR_NDES)) { /*NON DESCRIPTOR */ dma_non_descriptor_trans (cpu, d, channel); } } } void enable_global_dma (cpu_mips_t * cpu, struct jz4740_dma_data *d) { int channel; for (channel = 0; channel < MAX_DMA_NUM; channel++) { if ((jz4740_dma_table[DMAC_DCCSR (channel) / 4] & DMAC_DCCSR_NDES)) { if ((jz4740_dma_table[DMAC_DCCSR (channel) / 4] & DMAC_DCCSR_NDES)) dma_non_descriptor_trans (cpu, d, channel); /*NON DESCRIPTOR */ } } } void enable_dma_dbn (cpu_mips_t * cpu, struct jz4740_dma_data *d, int channel) { /*DESCRIPTOR trans */ if ((jz4740_dma_table[DMAC_DMACR / 4] & DMAC_DMACR_DMAE) && (jz4740_dma_table[DMAC_DCCSR (channel) / 4] & DMAC_DCCSR_NDES)) { dma_descriptor_trans (cpu, d, channel); } } void *dev_jz4740_dma_access (cpu_mips_t * cpu, struct vdevice *dev, m_uint32_t offset, u_int op_size, u_int op_type, m_reg_t * data, m_uint8_t * has_set_value) { struct jz4740_dma_data *d = dev->priv_data; int channel; if (offset >= d->jz4740_dma_size) { *data = 0; return NULL; } if (op_type == MTS_WRITE) { switch (offset) { case DMAC_DRSR0: case DMAC_DRSR1: case DMAC_DRSR2: case DMAC_DRSR3: case DMAC_DRSR4: case DMAC_DRSR5: /*only support AUTO request */ ASSERT (((*data) & DMAC_DRSR_RS_MASK) == DMAC_DRSR_RS_AUTO, "only support AUTO request\n"); return ((void *) (d->jz4740_dma_ptr + offset)); case DMAC_DCCSR0: case DMAC_DCCSR1: case DMAC_DCCSR2: case DMAC_DCCSR3: case DMAC_DCCSR4: case DMAC_DCCSR5: channel = (offset - 0x10) / 0x20; jz4740_dma_table[DMAC_DCCSR (channel) / 4] = *data; *has_set_value = TRUE; if ((*data) & DMAC_DCCSR_EN) { enable_dma_channel (cpu, d, channel); } return NULL; case DMAC_DMACR: /*DMA Control register */ jz4740_dma_table[DMAC_DMACR / 4] = *data; *has_set_value = TRUE; if ((*data) & DMAC_DMACR_DMAE) { enable_global_dma (cpu, d); } return NULL; case DMAC_DMADBR: case DMAC_DMADBSR: jz4740_dma_table[DMAC_DMADBR / 4] = *data; *has_set_value = TRUE; for (channel = 0; channel < 6; channel++) { if ((*data) & (1 << channel)) { enable_dma_dbn (cpu, d, channel); break; } } return NULL; default: return ((void *) (d->jz4740_dma_ptr + offset)); } } else if (op_type == MTS_READ) return ((void *) (d->jz4740_dma_ptr + offset)); else assert (0); return NULL; } void dev_jz4740_dma_init_defaultvalue () { memset (jz4740_dma_table, 0x0, sizeof (jz4740_dma_table)); } void dev_jz4740_dma_reset (cpu_mips_t * cpu, struct vdevice *dev) { dev_jz4740_dma_init_defaultvalue (); } int dev_jz4740_dma_init (vm_instance_t * vm, char *name, m_pa_t paddr, m_uint32_t len) { struct jz4740_dma_data *d; /* allocate the private data structure */ if (!(d = malloc (sizeof (*d)))) { fprintf (stderr, "jz4740_dma: unable to create device.\n"); return (-1); } memset (d, 0, sizeof (*d)); if (!(d->dev = dev_create (name))) goto err_dev_create; d->dev->priv_data = d; d->dev->phys_addr = paddr; d->dev->phys_len = len; d->jz4740_dma_ptr = (m_uint8_t *) (&jz4740_dma_table[0]); d->jz4740_dma_size = len; d->dev->handler = dev_jz4740_dma_access; d->dev->reset_handler = dev_jz4740_dma_reset; d->dev->flags = VDEVICE_FLAG_NO_MTS_MMAP; vm_bind_device (vm, d->dev); return (0); err_dev_create: free (d); return (-1); } ================================================ FILE: tools/virtualmips/jz4740/jz4740_dev_emc.c ================================================ /* * Copyright (C) yajin 2008 * * This file is part of the virtualmips distribution. * See LICENSE file for terms of the license. * */ /*EMC. */ #define _GNU_SOURCE #include #include #include #include #include #include #include "device.h" #include "mips_memory.h" #include "cpu.h" #include "jz4740.h" m_uint32_t jz4740_emc_table[JZ4740_EMC_INDEX_MAX]; m_uint32_t emc_sdram0[256]; /*configure register for sdram0*/ /*In order to save space, set emc sdram0 seperately.*/ struct jz4740_emc_data { struct vdevice *dev; m_uint8_t *jz4740_emc_ptr; m_uint32_t jz4740_emc_size; }; void *dev_jz4740_emc_access (cpu_mips_t * cpu, struct vdevice *dev, m_uint32_t offset, u_int op_size, u_int op_type, m_reg_t * data, m_uint8_t * has_set_value) { struct jz4740_emc_data *d = dev->priv_data; /*TODO: SDRAM MODE. Now just set dummy value. */ /*EMC SDRAM0 is in seperate space */ if ((offset >= EMC_SDMR0) && (offset <= (EMC_SDMR0 + 0x3ff))) { return (void *) (((m_uint8_t *) & emc_sdram0[0]) + offset - EMC_SDMR0); } if ((offset >= d->jz4740_emc_size)) { *data = 0; return NULL; } /*FIXME: * currently we do not support nand flash rc check. just set * EMC_NFINTS_DECF(bit 3) and EMC_NFINTS_ENCF(bit 2). to tell uboot and decoding and Encoding finished * set EMC_NFINTS_ERR(bit 0)=0 : no error */ if (offset == EMC_NFINTS) { jz4740_emc_table[EMC_NFINTS / 4] |= 0xc; } return ((void *) (d->jz4740_emc_ptr + offset)); } void dev_jz4740_emc_init_defaultvalue () { memset (jz4740_emc_table, 0x0, sizeof (jz4740_emc_table)); #ifdef SIM_PAVO /*EMC BCR(31:30):Boot sel * 11:2k page nand flash */ jz4740_emc_table[EMC_BCR / 4] |= 0xc0000000; #endif } void dev_jz4740_emc_reset (cpu_mips_t * cpu, struct vdevice *dev) { dev_jz4740_emc_init_defaultvalue (); } int dev_jz4740_emc_init (vm_instance_t * vm, char *name, m_pa_t paddr, m_uint32_t len) { struct jz4740_emc_data *d; /* allocate the private data structure */ if (!(d = malloc (sizeof (*d)))) { fprintf (stderr, "jz4740_emc: unable to create device.\n"); return (-1); } memset (d, 0, sizeof (*d)); if (!(d->dev = dev_create (name))) goto err_dev_create; d->dev->priv_data = d; d->dev->phys_addr = paddr; d->dev->phys_len = len; d->jz4740_emc_ptr = (m_uint8_t *) (&jz4740_emc_table[0]); d->jz4740_emc_size = len; d->dev->handler = dev_jz4740_emc_access; d->dev->reset_handler = dev_jz4740_emc_reset; d->dev->flags = VDEVICE_FLAG_NO_MTS_MMAP; vm_bind_device (vm, d->dev); //dev_jz4740_emc_init_defaultvalue(); return (0); err_dev_create: free (d); return (-1); } ================================================ FILE: tools/virtualmips/jz4740/jz4740_dev_gpio.c ================================================ /* * Copyright (C) yajin 2008 * * This file is part of the virtualmips distribution. * See LICENSE file for terms of the license. * */ #define _GNU_SOURCE #include #include #include #include #include #include #include "device.h" #include "mips_memory.h" #include "cpu.h" #include "jz4740.h" /*set to 0 to improve performance. set to 1 to debug gpio*/ #define VALIDE_GPIO_OPERATION 0 m_uint32_t jz4740_gpio_table[JZ4740_GPIO_INDEX_MAX]; struct jz4740_gpio_data { struct vdevice *dev; m_uint8_t *jz4740_gpio_ptr; m_uint32_t jz4740_gpio_size; }; /* GPIO is in 4 groups. 32 per group*/ /* 48-79 0 80-111 1 112-143 2 144-175 3 #define IRQ_GPIO3 25 #define IRQ_GPIO2 26 #define IRQ_GPIO1 27 #define IRQ_GPIO0 28 #define IRQ_GPIO_0 48 48 to 175 for GPIO pin 0 to 127 */ void dev_jz4740_gpio_setirq (int irq) { int group_no; int pin_no; ASSERT ((irq >= IRQ_GPIO_0) && (irq < IRQ_GPIO_0 + 128), "wrong gpio irq 0x%x\n", irq); group_no = (irq - IRQ_GPIO_0) / 32; pin_no = (irq - IRQ_GPIO_0) % 32; jz4740_gpio_table[GPIO_PXFLG (group_no) / 4] |= 1 << pin_no; } void dev_jz4740_gpio_clearirq (int irq) { int group_no; int pin_no; ASSERT ((irq >= IRQ_GPIO_0) && (irq < IRQ_GPIO_0 + 128), "wrong gpio irq 0x%x\n", irq); group_no = (irq - IRQ_GPIO_0) / 32; pin_no = (irq - IRQ_GPIO_0) % 32; jz4740_gpio_table[GPIO_PXFLG (group_no) / 4] &= ~(1 << pin_no); } void *dev_jz4740_gpio_access (cpu_mips_t * cpu, struct vdevice *dev, m_uint32_t offset, u_int op_size, u_int op_type, m_reg_t * data, m_uint8_t * has_set_value) { struct jz4740_gpio_data *d = dev->priv_data; m_uint8_t group; m_uint32_t mask, mask_data, temp; if (offset >= d->jz4740_gpio_size) { *data = 0; return NULL; } #if VALIDE_GPIO_OPERATION if (op_type == MTS_WRITE) { ASSERT (offset != GPIO_PXPIN (0), "Write to read only register in GPIO. offset %x\n", offset); ASSERT (offset != GPIO_PXPIN (1), "Write to read only register in GPIO. offset %x\n", offset); ASSERT (offset != GPIO_PXPIN (2), "Write to read only register in GPIO. offset %x\n", offset); ASSERT (offset != GPIO_PXPIN (3), "Write to read only register in GPIO. offset %x\n", offset); ASSERT (offset != GPIO_PXDAT (0), "Write to read only register in GPIO. offset %x\n", offset); ASSERT (offset != GPIO_PXDAT (1), "Write to read only register in GPIO. offset %x\n", offset); ASSERT (offset != GPIO_PXDAT (2), "Write to read only register in GPIO. offset %x\n", offset); ASSERT (offset != GPIO_PXDAT (3), "Write to read only register in GPIO. offset %x\n", offset); ASSERT (offset != GPIO_PXIM (0), "Write to read only register in GPIO. offset %x\n", offset); ASSERT (offset != GPIO_PXIM (1), "Write to read only register in GPIO. offset %x\n", offset); ASSERT (offset != GPIO_PXIM (2), "Write to read only register in GPIO. offset %x\n", offset); ASSERT (offset != GPIO_PXIM (3), "Write to read only register in GPIO. offset %x\n", offset); ASSERT (offset != GPIO_PXPE (0), "Write to read only register in GPIO. offset %x\n", offset); ASSERT (offset != GPIO_PXPE (1), "Write to read only register in GPIO. offset %x\n", offset); ASSERT (offset != GPIO_PXPE (2), "Write to read only register in GPIO. offset %x\n", offset); ASSERT (offset != GPIO_PXPE (3), "Write to read only register in GPIO. offset %x\n", offset); ASSERT (offset != GPIO_PXFUN (0), "Write to read only register in GPIO. offset %x\n", offset); ASSERT (offset != GPIO_PXFUN (1), "Write to read only register in GPIO. offset %x\n", offset); ASSERT (offset != GPIO_PXFUN (2), "Write to read only register in GPIO. offset %x\n", offset); ASSERT (offset != GPIO_PXFUN (3), "Write to read only register in GPIO. offset %x\n", offset); ASSERT (offset != GPIO_PXSEL (0), "Write to read only register in GPIO. offset %x\n", offset); ASSERT (offset != GPIO_PXSEL (1), "Write to read only register in GPIO. offset %x\n", offset); ASSERT (offset != GPIO_PXSEL (2), "Write to read only register in GPIO. offset %x\n", offset); ASSERT (offset != GPIO_PXSEL (3), "Write to read only register in GPIO. offset %x\n", offset); ASSERT (offset != GPIO_PXDIR (0), "Write to read only register in GPIO. offset %x\n", offset); ASSERT (offset != GPIO_PXDIR (1), "Write to read only register in GPIO. offset %x\n", offset); ASSERT (offset != GPIO_PXDIR (2), "Write to read only register in GPIO. offset %x\n", offset); ASSERT (offset != GPIO_PXDIR (3), "Write to read only register in GPIO. offset %x\n", offset); ASSERT (offset != GPIO_PXTRG (0), "Write to read only register in GPIO. offset %x\n", offset); ASSERT (offset != GPIO_PXTRG (1), "Write to read only register in GPIO. offset %x\n", offset); ASSERT (offset != GPIO_PXTRG (2), "Write to read only register in GPIO. offset %x\n", offset); ASSERT (offset != GPIO_PXTRG (3), "Write to read only register in GPIO. offset %x\n", offset); ASSERT (offset != GPIO_PXFLG (0), "Write to read only register in GPIO. offset %x\n", offset); ASSERT (offset != GPIO_PXFLG (1), "Write to read only register in GPIO. offset %x\n", offset); ASSERT (offset != GPIO_PXFLG (2), "Write to read only register in GPIO. offset %x\n", offset); ASSERT (offset != GPIO_PXFLG (3), "Write to read only register in GPIO. offset %x\n", offset); } if (op_type == MTS_READ) { ASSERT (offset != GPIO_PXDATS (0), "Read write only register in GPIO. offset %x\n", offset); ASSERT (offset != GPIO_PXDATS (0), "Read write only register in GPIO. offset %x\n", offset); ASSERT (offset != GPIO_PXDATS (0), "Read write only register in GPIO. offset %x\n", offset); ASSERT (offset != GPIO_PXDATS (0), "Read write only register in GPIO. offset %x\n", offset); ASSERT (offset != GPIO_PXDATC (0), "Read write only register in GPIO. offset %x\n", offset); ASSERT (offset != GPIO_PXDATC (0), "Read write only register in GPIO. offset %x\n", offset); ASSERT (offset != GPIO_PXDATC (0), "Read write only register in GPIO. offset %x\n", offset); ASSERT (offset != GPIO_PXDATC (0), "Read write only register in GPIO. offset %x\n", offset); ASSERT (offset != GPIO_PXIMS (0), "Read write only register in GPIO. offset %x\n", offset); ASSERT (offset != GPIO_PXIMS (0), "Read write only register in GPIO. offset %x\n", offset); ASSERT (offset != GPIO_PXIMS (0), "Read write only register in GPIO. offset %x\n", offset); ASSERT (offset != GPIO_PXIMS (0), "Read write only register in GPIO. offset %x\n", offset); ASSERT (offset != GPIO_PXIMC (0), "Read write only register in GPIO. offset %x\n", offset); ASSERT (offset != GPIO_PXIMC (0), "Read write only register in GPIO. offset %x\n", offset); ASSERT (offset != GPIO_PXIMC (0), "Read write only register in GPIO. offset %x\n", offset); ASSERT (offset != GPIO_PXIMC (0), "Read write only register in GPIO. offset %x\n", offset); ASSERT (offset != GPIO_PXPES (0), "Read write only register in GPIO. offset %x\n", offset); ASSERT (offset != GPIO_PXPES (0), "Read write only register in GPIO. offset %x\n", offset); ASSERT (offset != GPIO_PXPES (0), "Read write only register in GPIO. offset %x\n", offset); ASSERT (offset != GPIO_PXPES (0), "Read write only register in GPIO. offset %x\n", offset); ASSERT (offset != GPIO_PXPEC (0), "Read write only register in GPIO. offset %x\n", offset); ASSERT (offset != GPIO_PXPEC (0), "Read write only register in GPIO. offset %x\n", offset); ASSERT (offset != GPIO_PXPEC (0), "Read write only register in GPIO. offset %x\n", offset); ASSERT (offset != GPIO_PXPEC (0), "Read write only register in GPIO. offset %x\n", offset); ASSERT (offset != GPIO_PXFUNS (0), "Read write only register in GPIO. offset %x\n", offset); ASSERT (offset != GPIO_PXFUNS (0), "Read write only register in GPIO. offset %x\n", offset); ASSERT (offset != GPIO_PXFUNS (0), "Read write only register in GPIO. offset %x\n", offset); ASSERT (offset != GPIO_PXFUNS (0), "Read write only register in GPIO. offset %x\n", offset); ASSERT (offset != GPIO_PXFUNC (0), "Read write only register in GPIO. offset %x\n", offset); ASSERT (offset != GPIO_PXFUNC (0), "Read write only register in GPIO. offset %x\n", offset); ASSERT (offset != GPIO_PXFUNC (0), "Read write only register in GPIO. offset %x\n", offset); ASSERT (offset != GPIO_PXFUNC (0), "Read write only register in GPIO. offset %x\n", offset); ASSERT (offset != GPIO_PXDIRS (0), "Read write only register in GPIO. offset %x\n", offset); ASSERT (offset != GPIO_PXDIRS (0), "Read write only register in GPIO. offset %x\n", offset); ASSERT (offset != GPIO_PXDIRS (0), "Read write only register in GPIO. offset %x\n", offset); ASSERT (offset != GPIO_PXDIRS (0), "Read write only register in GPIO. offset %x\n", offset); ASSERT (offset != GPIO_PXDIRC (0), "Read write only register in GPIO. offset %x\n", offset); ASSERT (offset != GPIO_PXDIRC (0), "Read write only register in GPIO. offset %x\n", offset); ASSERT (offset != GPIO_PXDIRC (0), "Read write only register in GPIO. offset %x\n", offset); ASSERT (offset != GPIO_PXDIRC (0), "Read write only register in GPIO. offset %x\n", offset); ASSERT (offset != GPIO_PXTRGS (0), "Read write only register in GPIO. offset %x\n", offset); ASSERT (offset != GPIO_PXTRGS (0), "Read write only register in GPIO. offset %x\n", offset); ASSERT (offset != GPIO_PXTRGS (0), "Read write only register in GPIO. offset %x\n", offset); ASSERT (offset != GPIO_PXTRGS (0), "Read write only register in GPIO. offset %x\n", offset); ASSERT (offset != GPIO_PXTRGC (0), "Read write only register in GPIO. offset %x\n", offset); ASSERT (offset != GPIO_PXTRGC (0), "Read write only register in GPIO. offset %x\n", offset); ASSERT (offset != GPIO_PXTRGC (0), "Read write only register in GPIO. offset %x\n", offset); ASSERT (offset != GPIO_PXTRGC (0), "Read write only register in GPIO. offset %x\n", offset); ASSERT (offset != GPIO_PXFLGC (0), "Read write only register in GPIO. offset %x\n", offset); ASSERT (offset != GPIO_PXFLGC (0), "Read write only register in GPIO. offset %x\n", offset); ASSERT (offset != GPIO_PXFLGC (0), "Read write only register in GPIO. offset %x\n", offset); ASSERT (offset != GPIO_PXFLGC (0), "Read write only register in GPIO. offset %x\n", offset); } #endif if (op_type == MTS_READ) { #ifdef SIM_PAVO /*PAVO GPIO(C) PIN 30 -> NAND FLASH R/B. */ if (offset == GPIO_PXPIN (2)) { /*FOR NAND FLASH.PIN 30 ----|_____|------ */ temp = jz4740_gpio_table[GPIO_PXPIN (2) / 4]; temp &= 0x40000000; if (temp) temp &= ~0x40000000; else temp |= 0x40000000; jz4740_gpio_table[GPIO_PXPIN (2) / 4] = temp; } #endif return ((void *) (d->jz4740_gpio_ptr + offset)); } else if (op_type == MTS_WRITE) { switch (op_size) { case 1: mask = 0xff; break; case 2: mask = 0xffff; break; case 4: mask = 0xffffffff; break; default: assert (0); } switch (offset) { case GPIO_PXDATS (0): case GPIO_PXDATS (1): case GPIO_PXDATS (2): case GPIO_PXDATS (3): group = offset / 0x100; mask_data = (*data) & mask; jz4740_gpio_table[GPIO_PXDAT (group) / 4] |= mask_data; break; case GPIO_PXDATC (0): case GPIO_PXDATC (1): case GPIO_PXDATC (2): case GPIO_PXDATC (3): group = offset / 0x100; mask_data = (*data) & mask; mask_data = ~(mask_data); jz4740_gpio_table[GPIO_PXDAT (group) / 4] &= mask_data; break; case GPIO_PXIMS (0): case GPIO_PXIMS (1): case GPIO_PXIMS (2): case GPIO_PXIMS (3): group = offset / 0x100; mask_data = (*data) & mask; jz4740_gpio_table[GPIO_PXIM (group) / 4] |= mask_data; break; case GPIO_PXIMC (0): case GPIO_PXIMC (1): case GPIO_PXIMC (2): case GPIO_PXIMC (3): group = offset / 0x100; mask_data = (*data) & mask; mask_data = ~(mask_data); jz4740_gpio_table[GPIO_PXIM (group) / 4] &= mask_data; break; case GPIO_PXPES (0): case GPIO_PXPES (1): case GPIO_PXPES (2): case GPIO_PXPES (3): group = offset / 0x100; mask_data = (*data) & mask; jz4740_gpio_table[GPIO_PXPE (group) / 4] |= mask_data; break; case GPIO_PXPEC (0): case GPIO_PXPEC (1): case GPIO_PXPEC (2): case GPIO_PXPEC (3): group = offset / 0x100; mask_data = (*data) & mask; mask_data = ~(mask_data); jz4740_gpio_table[GPIO_PXPE (group) / 4] &= mask_data; break; case GPIO_PXFUNS (0): case GPIO_PXFUNS (1): case GPIO_PXFUNS (2): case GPIO_PXFUNS (3): group = offset / 0x100; mask_data = (*data) & mask; jz4740_gpio_table[GPIO_PXFUN (group) / 4] |= mask_data; break; case GPIO_PXFUNC (0): case GPIO_PXFUNC (1): case GPIO_PXFUNC (2): case GPIO_PXFUNC (3): group = offset / 0x100; mask_data = (*data) & mask; mask_data = ~(mask_data); jz4740_gpio_table[GPIO_PXFUN (group) / 4] &= mask_data; break; case GPIO_PXSELS (0): case GPIO_PXSELS (1): case GPIO_PXSELS (2): case GPIO_PXSELS (3): group = offset / 0x100; mask_data = (*data) & mask; jz4740_gpio_table[GPIO_PXSEL (group) / 4] |= mask_data; break; case GPIO_PXSELC (0): case GPIO_PXSELC (1): case GPIO_PXSELC (2): case GPIO_PXSELC (3): group = offset / 0x100; mask_data = (*data) & mask; mask_data = ~(mask_data); jz4740_gpio_table[GPIO_PXSEL (group) / 4] &= mask_data; break; case GPIO_PXDIRS (0): case GPIO_PXDIRS (1): case GPIO_PXDIRS (2): case GPIO_PXDIRS (3): group = offset / 0x100; mask_data = (*data) & mask; jz4740_gpio_table[GPIO_PXDIR (group) / 4] |= mask_data; break; case GPIO_PXDIRC (0): case GPIO_PXDIRC (1): case GPIO_PXDIRC (2): case GPIO_PXDIRC (3): group = offset / 0x100; mask_data = (*data) & mask; mask_data = ~(mask_data); jz4740_gpio_table[GPIO_PXDIR (group) / 4] &= mask_data; break; case GPIO_PXTRGS (0): case GPIO_PXTRGS (1): case GPIO_PXTRGS (2): case GPIO_PXTRGS (3): group = offset / 0x100; mask_data = (*data) & mask; jz4740_gpio_table[GPIO_PXTRG (group) / 4] |= mask_data; break; case GPIO_PXTRGC (0): case GPIO_PXTRGC (1): case GPIO_PXTRGC (2): case GPIO_PXTRGC (3): group = offset / 0x100; mask_data = (*data) & mask; mask_data = ~(mask_data); jz4740_gpio_table[GPIO_PXTRG (group) / 4] &= mask_data; break; case GPIO_PXFLGC (0): case GPIO_PXFLGC (1): case GPIO_PXFLGC (2): case GPIO_PXFLGC (3): group = offset / 0x100; mask_data = (*data) & mask; mask_data = ~(mask_data); jz4740_gpio_table[GPIO_PXFLG (group) / 4] &= mask_data; break; default: cpu_log (cpu, "", "invalid offset in GPIO. offset %x\n", offset); return NULL; } *has_set_value = TRUE; return NULL; } return NULL; } void dev_jz4740_gpio_init_defaultvalue () { memset (jz4740_gpio_table, 0x0, sizeof (jz4740_gpio_table)); jz4740_gpio_table[GPIO_PXIM (0) / 4] = 0xffffffff; jz4740_gpio_table[GPIO_PXIM (1) / 4] = 0xffffffff; jz4740_gpio_table[GPIO_PXIM (2) / 4] = 0xffffffff; jz4740_gpio_table[GPIO_PXIM (3) / 4] = 0xffffffff; //jz4740_gpio_table[GPIO_PXPIN(2)/4]=0x40000000; } void dev_jz4740_gpio_reset (cpu_mips_t * cpu, struct vdevice *dev) { dev_jz4740_gpio_init_defaultvalue (); } int dev_jz4740_gpio_init (vm_instance_t * vm, char *name, m_pa_t paddr, m_uint32_t len) { struct jz4740_gpio_data *d; /* allocate the private data structure */ if (!(d = malloc (sizeof (*d)))) { fprintf (stderr, "jz4740_gpio: unable to create device.\n"); return (-1); } memset (d, 0, sizeof (*d)); if (!(d->dev = dev_create (name))) goto err_dev_create; d->dev->priv_data = d; d->dev->phys_addr = paddr; d->dev->phys_len = len; d->jz4740_gpio_ptr = (m_uint8_t *) (&jz4740_gpio_table[0]); d->jz4740_gpio_size = len; d->dev->handler = dev_jz4740_gpio_access; d->dev->reset_handler = dev_jz4740_gpio_reset; d->dev->flags = VDEVICE_FLAG_NO_MTS_MMAP; vm_bind_device (vm, d->dev); //dev_jz4740_gpio_init_defaultvalue(); return (0); err_dev_create: free (d); return (-1); } ================================================ FILE: tools/virtualmips/jz4740/jz4740_dev_int.c ================================================ /* * Copyright (C) yajin 2008 * * This file is part of the virtualmips distribution. * See LICENSE file for terms of the license. * */ /*jz4740 Interrupt controller*/ #define _GNU_SOURCE #include #include #include #include #include #include #include "device.h" #include "mips_memory.h" #include "cpu.h" #include "jz4740.h" #define VALIDE_INT_OPERATION 0 extern cpu_mips_t *current_cpu; m_uint32_t jz4740_int_table[JZ4740_INT_INDEX_MAX]; struct jz4740_int_data { struct vdevice *dev; m_uint8_t *jz4740_int_ptr; m_uint32_t jz4740_int_size; }; void *dev_jz4740_int_access (cpu_mips_t * cpu, struct vdevice *dev, m_uint32_t offset, u_int op_size, u_int op_type, m_reg_t * data, m_uint8_t * has_set_value) { struct jz4740_int_data *d = dev->priv_data; m_uint32_t mask_data, mask; if (offset >= d->jz4740_int_size) { *data = 0; return NULL; } #if VALIDE_INT_OPERATION if (op_type == MTS_WRITE) { ASSERT (offset != INTC_ISR, "Write to read only register in INT. offset %x\n", offset); ASSERT (offset != INTC_IPR, "Write to read only register in INT. offset %x\n", offset); } else if (op_type == MTS_READ) { ASSERT (offset != INTC_IMSR, "Read write only register in INT. offset %x\n", offset); ASSERT (offset != INTC_IMCR, "Read write only register in INT. offset %x\n", offset); } #endif switch (op_size) { case 1: mask = 0xff; break; case 2: mask = 0xffff; break; case 4: mask = 0xffffffff; break; default: assert (0); } switch (offset) { case INTC_IMSR: /*set */ assert (op_type == MTS_WRITE); mask_data = (*data) & mask; jz4740_int_table[INTC_IMR / 4] |= mask_data; *has_set_value = TRUE; break; case INTC_IMCR: /*clear */ assert (op_type == MTS_WRITE); mask_data = (*data) & mask; mask_data = ~(mask_data); jz4740_int_table[INTC_IMR / 4] &= mask_data; *has_set_value = TRUE; break; case INTC_IPR: /*clear */ *data = jz4740_int_table[INTC_IPR / 4]; jz4740_int_table[INTC_IPR / 4] = 0; *has_set_value = TRUE; return NULL; default: return ((void *) (d->jz4740_int_ptr + offset)); } return NULL; } void dev_jz4740_int_init_defaultvalue () { memset (jz4740_int_table, 0x0, sizeof (jz4740_int_table)); jz4740_int_table[INTC_IMR / 4] = 0xffffffff; } void dev_jz4740_int_reset (cpu_mips_t * cpu, struct vdevice *dev) { dev_jz4740_int_init_defaultvalue (); } int dev_jz4740_int_init (vm_instance_t * vm, char *name, m_pa_t paddr, m_uint32_t len) { struct jz4740_int_data *d; /* allocate the private data structure */ if (!(d = malloc (sizeof (*d)))) { fprintf (stderr, "jz4740_dma: unable to create device.\n"); return (-1); } memset (d, 0, sizeof (*d)); if (!(d->dev = dev_create (name))) goto err_dev_create; d->dev->priv_data = d; d->dev->phys_addr = paddr; d->dev->phys_len = len; d->jz4740_int_ptr = (m_uint8_t *) (&jz4740_int_table[0]); d->jz4740_int_size = len; d->dev->handler = dev_jz4740_int_access; d->dev->reset_handler = dev_jz4740_int_reset; d->dev->flags = VDEVICE_FLAG_NO_MTS_MMAP; vm_bind_device (vm, d->dev); return (0); err_dev_create: free (d); return (-1); } ================================================ FILE: tools/virtualmips/jz4740/jz4740_dev_lcd.c ================================================ /* * Copyright (C) yajin 2008 * * This file is part of the virtualmips distribution. * See LICENSE file for terms of the license. * */ #ifdef SIM_LCD #define _GNU_SOURCE #include #include #include #include #include #include #include "device.h" #include "mips_memory.h" #include "cpu.h" #include "jz4740.h" #include "vp_sdl.h" #include "vp_timer.h" #include "utils.h" int dev_jz4740_ts_init (vm_instance_t * vm, char *name, m_pa_t paddr, m_uint32_t len, struct DisplayState *ds); #define LCD_TIMEOUT 500 //MS #define LCD_WIDTH 480 #define LCD_HEIGHT 272 #define LCD_BPP 32 /*32 bit per pixel */ extern cpu_mips_t *current_cpu; m_uint32_t jz4740_lcd_table[JZ4740_LCD_INDEX_MAX]; struct jz_fb_dma_descriptor { m_uint32_t fdadr; /* Frame descriptor address register */ m_uint32_t fsadr; /* Frame source address register */ m_uint32_t fidr; /* Frame ID register */ m_uint32_t ldcmd; /* Command register */ }; struct jz4740_lcd_data { struct vdevice *dev; m_uint8_t *jz4740_lcd_ptr; m_uint32_t jz4740_lcd_size; vp_timer_t *lcd_timer; struct DisplayState *ds; m_uint16_t vde, vds, hds, hde; }; void dev_jz4740_lcd_init_defaultvalue () { memset (jz4740_lcd_table, 0x0, sizeof (jz4740_lcd_table)); } void dev_jz4740_active_lcd (struct jz4740_lcd_data *d) { vp_mod_timer (d->lcd_timer, vp_get_clock (rt_clock) + LCD_TIMEOUT); } void dev_jz4740_unactive_lcd (struct jz4740_lcd_data *d) { vp_del_timer (d->lcd_timer); } void dev_jz4740_lcd_reset (cpu_mips_t * cpu, struct vdevice *dev) { struct jz4740_lcd_data *d = dev->priv_data; dev_jz4740_lcd_init_defaultvalue (); dev_jz4740_unactive_lcd (d); } void *dev_jz4740_lcd_access (cpu_mips_t * cpu, struct vdevice *dev, m_uint32_t offset, u_int op_size, u_int op_type, m_reg_t * data, m_uint8_t * has_set_value) { struct jz4740_lcd_data *d = dev->priv_data; if ((offset >= d->jz4740_lcd_size)) { *data = 0; return NULL; } switch (offset) { case LCD_CTRL: if (op_type == MTS_WRITE) { if (*data & LCD_CTRL_ENA) { dev_jz4740_active_lcd (d); } else { dev_jz4740_unactive_lcd (d); jz4740_lcd_table[LCD_STATE / 4] |= LCD_STATE_QD; /*INTERRUPT*/ if ((jz4740_lcd_table[LCD_CTRL / 4] & LCD_CTRL_QDM) == 0x0) { current_cpu->vm->set_irq (current_cpu->vm, IRQ_LCD); } } if (*data & LCD_CTRL_DIS) { dev_jz4740_unactive_lcd (d); jz4740_lcd_table[LCD_STATE / 4] |= LCD_STATE_LDD; /*INTERRUPT*/ if ((jz4740_lcd_table[LCD_CTRL / 4] & LCD_CTRL_LDDM) == 0x0) { current_cpu->vm->set_irq (current_cpu->vm, IRQ_LCD); } } if ((*data & LCD_CTRL_BPP_MASK) == LCD_CTRL_BPP_16) { d->ds->depth = 16; dpy_resize (d->ds, d->ds->width, d->ds->height); } else if ((*data & LCD_CTRL_BPP_MASK) == LCD_CTRL_BPP_18_24) { d->ds->depth = 32; dpy_resize (d->ds, d->ds->width, d->ds->height); } else { ASSERT (0, "errror bpp \n"); } } break; case LCD_DAH: if (op_type == MTS_WRITE) { d->hde = (*data & LCD_DAH_HDE_MASK) >> LCD_DAH_HDE_BIT; d->hds = (*data & LCD_DAH_HDS_MASK) >> LCD_DAH_HDS_BIT; ASSERT (d->hde > d->hds, "hde < hds hde %x hds %x \n", d->hde, d->hds); d->ds->width = d->hde - d->hds; ASSERT (d->ds->width > 0, "d->ds->width<=0 %x \n", d->ds->width); ASSERT (d->ds->height > 0, "d->ds->height<=0 %x \n", d->ds->height); dpy_resize (d->ds, d->ds->width, d->ds->height); } break; case LCD_DAV: if (op_type == MTS_WRITE) { d->vde = (*data & LCD_DAV_VDE_MASK) >> LCD_DAV_VDE_BIT; d->vds = (*data & LCD_DAV_VDS_MASK) >> LCD_DAV_VDS_BIT; ASSERT (d->vde > d->vds, "vde < vds vde %x vds %x \n", d->vde, d->vds); d->ds->height = d->vde - d->vds; ASSERT (d->ds->width > 0, "d->ds->width<=0 %x \n", d->ds->width); ASSERT (d->ds->height > 0, "d->ds->height<=0 %x \n", d->ds->height); dpy_resize (d->ds, d->ds->width, d->ds->height); } break; } return ((void *) (d->jz4740_lcd_ptr + offset)); } void dev_jz4740_lcd_cb (void *opaque) { struct jz4740_lcd_data *d = opaque; struct jz_fb_dma_descriptor *lcda0_desc = NULL; m_uint8_t *src_data; m_uint32_t dummy; lcda0_desc = (struct jz_fb_dma_descriptor *) physmem_get_hptr (current_cpu->vm, jz4740_lcd_table[LCD_DA0 / 4], 0, MTS_READ, &dummy); src_data = physmem_get_hptr (current_cpu->vm, lcda0_desc->fsadr, 0, MTS_READ, &dummy); ASSERT (src_data != NULL, "dev_jz4740_lcd_cb can not get framebuffer src data\n"); jz4740_lcd_table[LCD_SA0 / 4] = lcda0_desc->fsadr; jz4740_lcd_table[LCD_FID0 / 4] = lcda0_desc->fidr; jz4740_lcd_table[LCD_CMD0 / 4] = lcda0_desc->ldcmd; ASSERT ((((jz4740_lcd_table[LCD_CTRL / 4] & LCD_CTRL_BPP_MASK) == LCD_CTRL_BPP_16) || ((jz4740_lcd_table[LCD_CTRL / 4] & LCD_CTRL_BPP_MASK) == LCD_CTRL_BPP_18_24)), "Only 15/16/18/24 bpp supproted\n"); memcpy (d->ds->data, src_data, d->ds->height * d->ds->width * d->ds->depth / 8); dpy_update (d->ds, 0, 0, 0, 0); jz4740_lcd_table[LCD_STATE / 4] |= LCD_STATE_EOF; if ((jz4740_lcd_table[LCD_CMD0 / 4] & LCD_CMD_EOFINT) && ((jz4740_lcd_table[LCD_CTRL / 4] & LCD_CTRL_EOFM) == 0x0)) { current_cpu->vm->set_irq (current_cpu->vm, IRQ_LCD); } dev_jz4740_active_lcd (d); } int dev_jz4740_lcd_init (vm_instance_t * vm, char *name, m_pa_t paddr, m_uint32_t len) { struct jz4740_lcd_data *d; /* allocate the private data structure */ if (!(d = malloc (sizeof (*d)))) { fprintf (stderr, "jz4740_lcd: unable to create device.\n"); return (-1); } memset (d, 0, sizeof (*d)); if (!(d->dev = dev_create (name))) goto err_dev_create; d->dev->priv_data = d; d->dev->phys_addr = paddr; d->dev->phys_len = len; d->jz4740_lcd_ptr = (m_uint8_t *) (&jz4740_lcd_table[0]); d->jz4740_lcd_size = len; d->dev->handler = dev_jz4740_lcd_access; d->dev->reset_handler = dev_jz4740_lcd_reset; d->dev->flags = VDEVICE_FLAG_NO_MTS_MMAP; d->lcd_timer = vp_new_timer (rt_clock, dev_jz4740_lcd_cb, d); d->ds = malloc (sizeof (*d->ds)); if (d->ds == NULL) goto err_dev_create; d->ds->width = LCD_WIDTH; d->ds->height = LCD_HEIGHT; d->ds->depth = 32; sdl_display_init (d->ds, 0); vm_bind_device (vm, d->dev); /*Init jz4740 internal TS */ if (dev_jz4740_ts_init (vm, "JZ4740 TS", JZ4740_TS_BASE, JZ4740_TS_SIZE, d->ds) == -1) goto err_dev_create; return (0); err_dev_create: free (d); return (-1); } #endif ================================================ FILE: tools/virtualmips/jz4740/jz4740_dev_rtc.c ================================================ /* * Copyright (C) yajin 2008 * * This file is part of the virtualmips distribution. * See LICENSE file for terms of the license. * */ /*RTC. */ #define _GNU_SOURCE #include #include #include #include #include #include #include "device.h" #include "mips_memory.h" #include "cpu.h" #include "jz4740.h" #include "vp_timer.h" #define RTC_TIMEOUT 1000 //1000MS=1S extern cpu_mips_t *current_cpu; m_uint32_t jz4740_rtc_table[JZ4740_RTC_INDEX_MAX]; struct jz4740_rtc_data { struct vdevice *dev; m_uint8_t *jz4740_rtc_ptr; m_uint32_t jz4740_rtc_size; vp_timer_t *rtc_timer; }; static const unsigned int sum_monthday[13] = { 0, 31, 31 + 28, 31 + 28 + 31, 31 + 28 + 31 + 30, 31 + 28 + 31 + 30 + 31, 31 + 28 + 31 + 30 + 31 + 30, 31 + 28 + 31 + 30 + 31 + 30 + 31, 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31, 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30, 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31, 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30, 365 }; static const unsigned int yearday[5] = { 0, 366, 366 + 365, 366 + 365 * 2, 366 + 365 * 3 }; static const unsigned int sweekday = 6; unsigned int forced_inline jz_mktime (int year, int mon, int day, int hour, int min, int sec) { unsigned int seccounter; if (year < 2000) year = 2000; year -= 2000; seccounter = (year / 4) * (365 * 3 + 366); seccounter += yearday[year % 4]; if (year % 4) seccounter += sum_monthday[mon - 1]; else if (mon >= 3) seccounter += sum_monthday[mon - 1] + 1; /* Feb is 29 days. */ else seccounter += sum_monthday[mon - 1]; seccounter += day - 1; seccounter *= 24; seccounter += hour; seccounter *= 60; seccounter += min; seccounter *= 60; seccounter += sec; return seccounter; } /*Set RTC Time. From Year 2000.*/ void dev_jz4740_rtc_init_defaultvalue () { time_t timep; struct tm *p; memset (jz4740_rtc_table, 0x0, sizeof (jz4740_rtc_table)); /*Set RTC value to current time */ time (&timep); p = localtime (&timep); jz4740_rtc_table[RTC_RSR / 4] = jz_mktime ((1900 + p->tm_year), (1 + p->tm_mon), p->tm_mday, p->tm_hour, p->tm_min, p->tm_sec); } void dev_jz4740_rtc_reset (cpu_mips_t * cpu, struct vdevice *dev) { dev_jz4740_rtc_init_defaultvalue (); } void dev_jz4740_active_rtc (struct jz4740_rtc_data *d) { vp_mod_timer (d->rtc_timer, vp_get_clock (rt_clock) + RTC_TIMEOUT); } void dev_jz4740_unactive_rtc (struct jz4740_rtc_data *d) { vp_del_timer (d->rtc_timer); } void *dev_jz4740_rtc_access (cpu_mips_t * cpu, struct vdevice *dev, m_uint32_t offset, u_int op_size, u_int op_type, m_reg_t * data, m_uint8_t * has_set_value) { struct jz4740_rtc_data *d = dev->priv_data; if (offset >= d->jz4740_rtc_size) { *data = 0; return NULL; } switch (offset) { case RTC_RCR: if (op_type == MTS_READ) { /*RTC_RCR (RTC_RCR_WRDY )=1 bit 7 */ jz4740_rtc_table[RTC_RCR / 4] |= RTC_RCR_WRDY; } else if (op_type == MTS_WRITE) { if (*data & RTC_RCR_RTCE) { dev_jz4740_active_rtc (d); } else { dev_jz4740_unactive_rtc (d); } } break; } return ((void *) (d->jz4740_rtc_ptr + offset)); } void dev_jz4740_rtc_cb (void *opaque) { struct jz4740_rtc_data *d = opaque; time_t timep; struct tm *p; if (jz4740_rtc_table[RTC_RCR / 4] & RTC_RCR_RTCE) { //rtc enable jz4740_rtc_table[RTC_RCR / 4] |= RTC_RCR_1HZ; if (jz4740_rtc_table[RTC_RCR / 4] & RTC_RCR_1HZIE) { current_cpu->vm->set_irq (current_cpu->vm, IRQ_RTC); } time (&timep); p = localtime (&timep); /*always get the current time from host */ jz4740_rtc_table[RTC_RSR / 4] = jz_mktime ((1900 + p->tm_year), (1 + p->tm_mon), p->tm_mday, p->tm_hour, p->tm_min, p->tm_sec); if (jz4740_rtc_table[RTC_RSR / 4] == jz4740_rtc_table[RTC_RSAR / 4]) { if (jz4740_rtc_table[RTC_RCR / 4] & RTC_RCR_AE) { jz4740_rtc_table[RTC_RCR / 4] |= RTC_RCR_AF; if (jz4740_rtc_table[RTC_RCR / 4] & RTC_RCR_AIE) { current_cpu->vm->set_irq (current_cpu->vm, IRQ_RTC); } } } } dev_jz4740_active_rtc (d); } int dev_jz4740_rtc_init (vm_instance_t * vm, char *name, m_pa_t paddr, m_uint32_t len) { struct jz4740_rtc_data *d; /* allocate the private data structure */ if (!(d = malloc (sizeof (*d)))) { fprintf (stderr, "jz4740_rtc: unable to create device.\n"); return (-1); } memset (d, 0, sizeof (*d)); if (!(d->dev = dev_create (name))) goto err_dev_create; d->dev->priv_data = d; d->dev->phys_addr = paddr; d->dev->phys_len = len; d->jz4740_rtc_ptr = (m_uint8_t *) (&jz4740_rtc_table[0]); d->jz4740_rtc_size = len; d->dev->handler = dev_jz4740_rtc_access; d->dev->reset_handler = dev_jz4740_rtc_reset; d->dev->flags = VDEVICE_FLAG_NO_MTS_MMAP; d->rtc_timer = vp_new_timer (rt_clock, dev_jz4740_rtc_cb, d); vm_bind_device (vm, d->dev); dev_jz4740_rtc_init_defaultvalue (); return (0); err_dev_create: free (d); return (-1); } ================================================ FILE: tools/virtualmips/jz4740/jz4740_dev_ts.c ================================================ /* * Copyright (C) yajin 2008 * * This file is part of the virtualmips distribution. * See LICENSE file for terms of the license. * */ #ifdef SIM_LCD #define _GNU_SOURCE #include #include #include #include #include #include #include "device.h" #include "mips_memory.h" #include "cpu.h" #include "jz4740.h" #include "vp_sdl.h" #include "vp_timer.h" #include "utils.h" extern cpu_mips_t *current_cpu; #define TSMAXX 4096 #define TSMAXY 4096 #define TSMINX 0 #define TSMINY 0 #define TS_TIMEOUT 15 //MS m_uint32_t jz4740_ts_table[JZ4740_TS_INDEX_MAX]; #define MOUSE_DOWN 1 #define MOUSE_UP 2 #define MOUSE_MOVE 3 struct jz4740_ts_data { struct vdevice *dev; m_uint8_t *jz4740_ts_ptr; m_uint32_t jz4740_ts_size; vp_timer_t *ts_timer; m_uint8_t xyz; /*xyz of cfg */ m_uint8_t snum; /*snum of cfg */ m_uint8_t read_index; m_uint32_t x, y; /*mouse status */ m_uint8_t mouse_status; struct DisplayState *ds; }; void dev_jz4740_active_ts (struct jz4740_ts_data *d) { vp_mod_timer (d->ts_timer, vp_get_clock (rt_clock) + TS_TIMEOUT); } void dev_jz4740_unactive_ts (struct jz4740_ts_data *d) { vp_del_timer (d->ts_timer); } void dev_jz4740_ts_cb (void *opaque) { struct jz4740_ts_data *d = opaque; SDL_Event *ts_ev; if ((jz4740_ts_table[SADC_ENA / 4] & SADC_ENA_TSEN)) { if ((jz4740_ts_table[SADC_CTRL / 4] & SADC_CTRL_PENDM) == 0) { ts_ev = sdl_getmouse_down (); /*Pen down interrupt */ if (ts_ev != NULL) { d->x = ((ts_ev->button.x) * (TSMAXX - TSMINX) / d->ds->width) + TSMINX; d->y = ((ts_ev->button.y) * (TSMAXY - TSMINY) / d->ds->height) + TSMINY; if (d->x > TSMAXX) d->x = TSMAXX; if (d->y > TSMAXY) d->y = TSMAXY; /*Interrupt */ current_cpu->vm->set_irq (current_cpu->vm, IRQ_SADC); jz4740_ts_table[SADC_STATE / 4] |= (SADC_STATE_PEND | SADC_STATE_TSRDY); } } if ((jz4740_ts_table[SADC_CTRL / 4] & SADC_CTRL_PENUM) == 0) { /*Pen UP interrupt */ if (d->read_index == 0) { /* * TODO: Mouse up checking. * We do not check whether mouse up. JUST assume when clicked, it is always mouseup. * Can not use hand writing in qtopia. */ /*Interrupt */ current_cpu->vm->set_irq (current_cpu->vm, IRQ_SADC); jz4740_ts_table[SADC_STATE / 4] |= (SADC_STATE_PENU | SADC_STATE_TSRDY); } } } dev_jz4740_active_ts (d); } void dev_jz4740_ts_init_defaultvalue () { memset (jz4740_ts_table, 0x0, sizeof (jz4740_ts_table)); } void dev_jz4740_ts_reset (cpu_mips_t * cpu, struct vdevice *dev) { dev_jz4740_ts_init_defaultvalue (); } void *dev_jz4740_ts_access (cpu_mips_t * cpu, struct vdevice *dev, m_uint32_t offset, u_int op_size, u_int op_type, m_reg_t * data, m_uint8_t * has_set_value) { struct jz4740_ts_data *d = dev->priv_data; if ((offset >= d->jz4740_ts_size)) { *data = 0; return NULL; } switch (offset) { case SADC_ENA: if (op_type == MTS_WRITE) { ASSERT ((*data & SADC_ENA_TSEN), "Only touche screen model is support in SADC \n"); if (*data & SADC_ENA_TSEN) dev_jz4740_active_ts (d); else dev_jz4740_unactive_ts (d); } break; case SADC_CFG: if (op_type == MTS_WRITE) { ASSERT ((*data & SADC_CFG_TS_DMA) == 0x0, "Only touche screen model is support in SADC \n"); ASSERT ((*data & SADC_CFG_XYZ_MASK) != (3 << SADC_CFG_XYZ_BIT), "XYZ =3 is not support \n"); ASSERT ((*data & SADC_CFG_XYZ_MASK) != (2 << SADC_CFG_XYZ_BIT), "XYZ =2 is not support \n"); d->xyz = (*data & SADC_CFG_XYZ_MASK) >> SADC_CFG_XYZ_BIT; d->snum = ((*data & SADC_CFG_SNUM_MASK) >> SADC_CFG_SNUM_BIT) + 1; /*need read twice */ if (d->xyz == 0x1) d->snum *= 2; d->read_index = 0; } break; case SADC_STATE: if (op_type == MTS_WRITE) { jz4740_ts_table[SADC_STATE / 4] = ~(*data); *has_set_value = TRUE; return NULL; } else { *data = jz4740_ts_table[SADC_STATE / 4] & 0x1f; *data |= SADC_CTRL_TSRDYM; *has_set_value = TRUE; return NULL; } break; case SADC_TSDAT: if (op_type == MTS_READ) { if ((d->read_index % 2) == 0) { *data = ((d->x) & 0x7fff) | ((d->y & 0x7ffff) << 16); } else { *data = ((500) & 0x7fff); } *has_set_value = TRUE; d->read_index++; if (d->read_index == d->snum) d->read_index = 0; return NULL; } break; } return ((void *) (d->jz4740_ts_ptr + offset)); } int dev_jz4740_ts_init (vm_instance_t * vm, char *name, m_pa_t paddr, m_uint32_t len, struct DisplayState *ds) { struct jz4740_ts_data *d; /* allocate the private data structure */ if (!(d = malloc (sizeof (*d)))) { fprintf (stderr, "jz4740_lcd: unable to create device.\n"); return (-1); } memset (d, 0, sizeof (*d)); if (!(d->dev = dev_create (name))) goto err_dev_create; d->dev->priv_data = d; d->dev->phys_addr = paddr; d->dev->phys_len = len; d->jz4740_ts_ptr = (m_uint8_t *) (&jz4740_ts_table[0]); d->jz4740_ts_size = len; d->dev->handler = dev_jz4740_ts_access; d->dev->reset_handler = dev_jz4740_ts_reset; d->dev->flags = VDEVICE_FLAG_NO_MTS_MMAP; d->ts_timer = vp_new_timer (rt_clock, dev_jz4740_ts_cb, d); d->ds = ds; vm_bind_device (vm, d->dev); return (0); err_dev_create: free (d); return (-1); } #endif ================================================ FILE: tools/virtualmips/jz4740/jz4740_dev_uart.c ================================================ /* * Copyright (C) yajin 2008 * * This file is part of the virtualmips distribution. * See LICENSE file for terms of the license. * */ /*JZ4740 UART Emulation. * * JZ4740 UART is compatible with 16c550 . * * Linux use uart interrupt to receive and send data. * * For simulator, it is a bad idea for os to use interrupt to send data . * Because simulator is always READY for sending, so interrupt is slow than polling. * * * receive: * 1.set IER * 2. Wating interrupt (read IIR and LSR) * 3. if IIR says an interrupt and LSR says that data ready. read RBR. * * send: * 1. set IER to enable transmit request interrupt * 2. if UART can send data, generate an interrupt and set IIR LSR * 3. linux receives the interrupt ,read IIR and LSR * 4. send data. * */ #define _GNU_SOURCE #include #include #include #include #include #include #include "device.h" #include "mips_memory.h" #include "jz4740.h" #include "cpu.h" #include "vp_timer.h" /* Interrupt Identification Register */ #define IIR_NPENDING 0x01 /* 0: irq pending, 1: no irq pending */ #define IIR_TXRDY 0x02 #define IIR_RXRDY 0x04 struct jz4740_uart_data { struct vdevice *dev; u_int irq, duart_irq_seq; u_int output; vtty_t *vtty; vm_instance_t *vm; m_uint32_t ier; /*0x04 */ m_uint32_t iir; /*0x08 */ m_uint32_t fcr; /*0x08 */ m_uint32_t lcr; /*0x0c */ m_uint32_t mcr; /*0x10 */ m_uint32_t lsr; /*0x14 */ m_uint32_t msr; /*0x18 */ m_uint32_t spr; /*0x1c */ m_uint32_t isr; /*0x20 */ m_uint32_t umr; /*0x24 */ m_uint32_t uacr; /*0x28 */ m_uint32_t jz4740_uart_size; vp_timer_t *uart_timer; }; static void jz4740_tty_con_input (vtty_t * vtty) { struct jz4740_uart_data *d = vtty->priv_data; if (d->ier & UART_IER_RDRIE) { d->vm->set_irq (d->vm, d->irq); } d->lsr |= UART_LSR_DRY; } void *dev_jz4740_uart_access (cpu_mips_t * cpu, struct vdevice *dev, m_uint32_t offset, u_int op_size, u_int op_type, m_reg_t * data, m_uint8_t * has_set_value) { struct jz4740_uart_data *d = dev->priv_data; u_char odata; if (offset >= d->jz4740_uart_size) { *data = 0; return NULL; } switch (offset) { case UART_RBR: /*0x0 RBR THR */ if (op_type == MTS_READ) { *data = vtty_get_char (d->vtty); if (vtty_is_char_avail (d->vtty)) d->lsr |= UART_LSR_DRY; else d->lsr &= ~UART_LSR_DRY; } else { vtty_put_char (d->vtty, (char) (*data)); if ((d->ier & UART_IER_TDRIE) && (d->output == 0) && (d->fcr & 0x10)) { /*yajin. * * In order to put the next data more quickly, just set irq not waiting for host_alarm_handler to set irq. * Sorry uart, too much work for you. * * Sometimes, linux kernel prints "serial8250: too much work for irq9" if we print large data on screen. * Please patch the kernel. comment "printk(KERN_ERR "serial8250: too much work for " * "irq%d\n", irq);" * qemu has some question. * http://lkml.org/lkml/2008/1/12/135 * http://kerneltrap.org/mailarchive/linux-kernel/2008/2/7/769924 * * If jit is used in future, we may not need to set irq here because simulation is quick enough. Then we have * no "too much work for irq9" problem. * * */ d->output = TRUE; d->vm->set_irq (d->vm, d->irq); } } *has_set_value = TRUE; break; case UART_IER: /*0x4 */ if (op_type == MTS_READ) { *data = d->ier; } else { d->ier = *data & 0xFF; } *has_set_value = TRUE; break; case UART_IIR: /*0x08 */ d->vm->clear_irq (d->vm, d->irq); if (op_type == MTS_READ) { odata = IIR_NPENDING; if (vtty_is_char_avail (d->vtty)) { odata = IIR_RXRDY; } else { if (d->output) { odata = IIR_TXRDY; d->output = 0; } } *data = odata; } else { d->fcr = *data; if (d->fcr & 0x20) d->lsr &= ~UART_LSR_DRY; } *has_set_value = TRUE; break; case UART_LSR: /*0x14 */ if (op_type == MTS_READ) { d->lsr |= UART_LSR_TDRQ | UART_LSR_TEMP; if (vtty_is_char_avail (d->vtty)) d->lsr |= UART_LSR_DRY; return &(d->lsr); } else ASSERT (0, "WRITE TO LSR\n"); *has_set_value = TRUE; break; case UART_LCR: return &(d->lcr); case UART_MCR: return &(d->mcr); case UART_MSR: return &(d->msr); case UART_SPR: return &(d->spr); case UART_ISR: return &(d->isr); case UART_UMR: return &(d->umr); case UART_UACR: return &(d->uacr); default: ASSERT (0, "invalid uart offset %x\n", offset); } return NULL; } void dev_jz4740_uart_reset (cpu_mips_t * cpu, struct vdevice *dev) { struct jz4740_uart_data *d = dev->priv_data; d->fcr = 0x0; d->lcr = 0x0; d->mcr = 0x0; d->lsr |= UART_LSR_TDRQ | UART_LSR_TEMP; d->msr = 0x0; d->spr = 0x0; d->isr = 0x0; d->umr = 0x0; d->uacr = 0x0; } extern cpu_mips_t *current_cpu; #define UART_TIME_OUT 25 void dev_jz4740_uart_cb (void *opaque) { struct jz4740_uart_data *d = (struct jz4740_uart_data *) opaque; d->output = 0; if (vtty_is_char_avail (d->vtty)) { d->lsr |= UART_LSR_DRY; if (d->ier & UART_IER_RDRIE) { d->vm->set_irq (d->vm, d->irq); vp_mod_timer (d->uart_timer, vp_get_clock (rt_clock) + UART_TIME_OUT); return; } } if ((d->ier & UART_IER_TDRIE) && (d->output == 0) && (d->fcr & 0x10)) { d->output = TRUE; d->vm->set_irq (d->vm, d->irq); vp_mod_timer (d->uart_timer, vp_get_clock (rt_clock) + UART_TIME_OUT); return; } // d->uart_timer->set_time=vp_get_clock(rt_clock); vp_mod_timer (d->uart_timer, vp_get_clock (rt_clock) + UART_TIME_OUT); } int dev_jz4740_uart_init (vm_instance_t * vm, char *name, m_pa_t paddr, m_uint32_t len, u_int irq, vtty_t * vtty) { struct jz4740_uart_data *d; /* allocate the private data structure */ if (!(d = malloc (sizeof (*d)))) { fprintf (stderr, "JZ4740 UART: unable to create device.\n"); return (-1); } memset (d, 0, sizeof (*d)); if (!(d->dev = dev_create (name))) goto err_dev_create; d->dev->priv_data = d; d->dev->phys_addr = paddr; d->dev->phys_len = len; d->dev->flags = VDEVICE_FLAG_NO_MTS_MMAP; d->vm = vm; (*d).vtty = vtty; d->irq = irq; vtty->priv_data = d; d->jz4740_uart_size = len; d->dev->handler = dev_jz4740_uart_access; d->dev->reset_handler = dev_jz4740_uart_reset; (*d).vtty->read_notifier = jz4740_tty_con_input; d->uart_timer = vp_new_timer (rt_clock, dev_jz4740_uart_cb, d); //d->uart_timer->set_time=vp_get_clock(rt_clock); vp_mod_timer (d->uart_timer, vp_get_clock (rt_clock) + UART_TIME_OUT); vm_bind_device (vm, d->dev); return (0); err_dev_create: free (d); return (-1); } ================================================ FILE: tools/virtualmips/jz4740/jz4740_dev_wdt_tcu.c ================================================ /* * Copyright (C) yajin 2008 * * This file is part of the virtualmips distribution. * See LICENSE file for terms of the license. * */ /* Watch dog and timer of JZ4740. * TODO: * 2. timer1-5 */ #define _GNU_SOURCE #include #include #include #include #include #include #include "device.h" #include "mips_memory.h" #include "cpu.h" #include "jz4740.h" #include "vp_timer.h" #include "vp_clock.h" #define VALIDE_WDT_TCU_OPERATION 0 extern cpu_mips_t *current_cpu; m_uint32_t jz4740_wdt_tcu_table[JZ4740_WDT_INDEX_MAX]; /*4:EXT 2:RTC 1:PCK*/ //m_uint8_t jz4740_tcu_clock_source[JZ4740_WDT_INDEX_MAX]; //m_uint32_t jz4740_tcu_clock_prescale[JZ4740_WDT_INDEX_MAX]; /*clocksource/prescale*/ m_uint64_t jz4740_tcu_clock[JZ4740_WDT_INDEX_MAX]; m_uint64_t jz4740_wdt_clock; struct jz4740_wdt_tcu_data { struct vdevice *dev; m_uint8_t *jz4740_wdt_tcu_ptr; m_uint32_t jz4740_wdt_tcu_size; vp_timer_t *tcu_timer[JZ4740_WDT_INDEX_MAX]; vp_timer_t *wdt_timer; }; /*fire timer0 every 10ms*/ void dev_jz4740_tcu_active_timer0 (struct jz4740_wdt_tcu_data *d) { d->tcu_timer[0]->set_time = vp_get_clock (rt_clock); vp_mod_timer (d->tcu_timer[0], vp_get_clock (rt_clock) + 10); } void dev_jz4740_tcu_unactive_timer0 (struct jz4740_wdt_tcu_data *d) { vp_del_timer (d->tcu_timer[0]); } void dev_jz4740_active_wdt (struct jz4740_wdt_tcu_data *d) { d->wdt_timer->set_time = vp_get_clock (rt_clock); vp_mod_timer (d->wdt_timer, vp_get_clock (rt_clock) + 10); } void dev_jz4740_unactive_wdt (struct jz4740_wdt_tcu_data *d) { vp_del_timer (d->wdt_timer); } void *dev_jz4740_wdt_tcu_access (cpu_mips_t * cpu, struct vdevice *dev, m_uint32_t offset, u_int op_size, u_int op_type, m_reg_t * data, m_uint8_t * has_set_value) { struct jz4740_wdt_tcu_data *d = dev->priv_data; m_uint32_t mask_data, mask; int clock_index; //m_uint64_t clock; if (offset >= d->jz4740_wdt_tcu_size) { *data = 0; return NULL; } #if VALIDE_WDT_TCU_OPERATION if (op_type == MTS_WRITE) { ASSERT (offset != TCU_TSR, "Write to read only register in TCU. offset %x\n", offset); ASSERT (offset != TCU_TER, "Write to read only register in TCU. offset %x\n", offset); ASSERT (offset != TCU_TFR, "Write to read only register in TCU. offset %x\n", offset); ASSERT (offset != TCU_TMR, "Write to read only register in TCU. offset %x\n", offset); } else if (op_type == MTS_READ) { ASSERT (offset != TCU_TSSR, "Read write only register in TCU. offset %x\n", offset); ASSERT (offset != TCU_TSCR, "Read write only register in TCU. offset %x\n", offset); ASSERT (offset != TCU_TESR, "Read write only register in TCU. offset %x\n", offset); ASSERT (offset != TCU_TECR, "Read write only register in TCU. offset %x\n", offset); ASSERT (offset != TCU_TFSR, "Read write only register in TCU. offset %x\n", offset); ASSERT (offset != TCU_TFCR, "Read write only register in TCU. offset %x\n", offset); ASSERT (offset != TCU_TMSR, "Read write only register in TCU. offset %x\n", offset); ASSERT (offset != TCU_TMCR, "Read write only register in TCU. offset %x\n", offset); } else assert (0); #endif switch (op_size) { case 1: mask = 0xff; break; case 2: mask = 0xffff; break; case 4: mask = 0xffffffff; break; default: assert (0); } switch (offset) { case TCU_TSSR: /*set */ assert (op_type == MTS_WRITE); mask_data = (*data) & mask; jz4740_wdt_tcu_table[TCU_TSR / 4] |= mask_data; *has_set_value = TRUE; if (jz4740_wdt_tcu_table[TCU_TSR / 4] & 0x01) dev_jz4740_tcu_unactive_timer0 (d); if (jz4740_wdt_tcu_table[TCU_TSR / 4] & WDT_TIMER_STOP) dev_jz4740_unactive_wdt (d); break; case TCU_TSCR: /*clear */ assert (op_type == MTS_WRITE); mask_data = (*data) & mask; mask_data = ~(mask_data); jz4740_wdt_tcu_table[TCU_TSR / 4] &= mask_data; *has_set_value = TRUE; if ((!jz4740_wdt_tcu_table[TCU_TSR / 4] & 0x01) && (jz4740_wdt_tcu_table[TCU_TER / 4] & 0x01)) dev_jz4740_tcu_active_timer0 (d); if (unlikely (jz4740_wdt_tcu_table[WDT_TCER / 4] & 0x01) && (!(jz4740_wdt_tcu_table[TCU_TSR / 4] & WDT_TIMER_STOP))) dev_jz4740_active_wdt (d); break; case TCU_TESR: /*set */ assert (op_type == MTS_WRITE); mask_data = (*data) & mask; jz4740_wdt_tcu_table[TCU_TER / 4] |= mask_data; *has_set_value = TRUE; if ((!jz4740_wdt_tcu_table[TCU_TSR / 4] & 0x01) && (jz4740_wdt_tcu_table[TCU_TER / 4] & 0x01)) dev_jz4740_tcu_active_timer0 (d); break; case TCU_TECR: /*clear */ assert (op_type == MTS_WRITE); mask_data = (*data) & mask; mask_data = ~(mask_data); jz4740_wdt_tcu_table[TCU_TER / 4] &= mask_data; *has_set_value = TRUE; if (!(jz4740_wdt_tcu_table[TCU_TER / 4] & 0x01)) dev_jz4740_tcu_unactive_timer0 (d); break; case TCU_TFSR: /*set */ assert (op_type == MTS_WRITE); mask_data = (*data) & mask; jz4740_wdt_tcu_table[TCU_TFR / 4] |= mask_data; *has_set_value = TRUE; break; case TCU_TFCR: /*clear */ assert (op_type == MTS_WRITE); mask_data = (*data) & mask; mask_data = ~(mask_data); jz4740_wdt_tcu_table[TCU_TFR / 4] &= mask_data; *has_set_value = TRUE; break; case TCU_TMSR: /*set */ assert (op_type == MTS_WRITE); mask_data = (*data) & mask; jz4740_wdt_tcu_table[TCU_TMR / 4] |= mask_data; *has_set_value = TRUE; break; case TCU_TMCR: /*clear */ assert (op_type == MTS_WRITE); mask_data = (*data) & mask; mask_data = ~(mask_data); jz4740_wdt_tcu_table[TCU_TMR / 4] &= mask_data; *has_set_value = TRUE; break; case TCU_TCSR0: case TCU_TCSR1: case TCU_TCSR2: case TCU_TCSR3: case TCU_TCSR4: case TCU_TCSR5: if (op_type == MTS_WRITE) { clock_index = (offset - TCU_TCSR0) / 0x10; if (((*data) & TCU_CLOCK_SOUCE_MASK) == TCU_CLOCK_EXT) { jz4740_tcu_clock[clock_index] = EXT_CLOCK; } else if (((*data) & TCU_CLOCK_SOUCE_MASK) == TCU_CLOCK_RTC) { jz4740_tcu_clock[clock_index] = RTC_CLOCK; } else ASSERT (0, "RTC and EXT clock is supported \n"); if ((((*data) & TCU_CLOCK_PRESCALE_MASK) >> TCU_CLOCK_PRESCALE_OFFSET) == 0x1) jz4740_tcu_clock[clock_index] = jz4740_tcu_clock[clock_index] / 4; else if ((((*data) & TCU_CLOCK_PRESCALE_MASK) >> TCU_CLOCK_PRESCALE_OFFSET) == 0x2) jz4740_tcu_clock[clock_index] = jz4740_tcu_clock[clock_index] / 16; else if ((((*data) & TCU_CLOCK_PRESCALE_MASK) >> TCU_CLOCK_PRESCALE_OFFSET) == 0x3) jz4740_tcu_clock[clock_index] = jz4740_tcu_clock[clock_index] / 64; else if ((((*data) & TCU_CLOCK_PRESCALE_MASK) >> TCU_CLOCK_PRESCALE_OFFSET) == 0x4) jz4740_tcu_clock[clock_index] = jz4740_tcu_clock[clock_index] / 256; else if ((((*data) & TCU_CLOCK_PRESCALE_MASK) >> TCU_CLOCK_PRESCALE_OFFSET) == 0x5) jz4740_tcu_clock[clock_index] = jz4740_tcu_clock[clock_index] / 1024; else if ((((*data) & TCU_CLOCK_PRESCALE_MASK) >> TCU_CLOCK_PRESCALE_OFFSET) != 0x0) ASSERT (0, "INVALID PRESCALE\n"); } return ((void *) (d->jz4740_wdt_tcu_ptr + offset)); case WDT_TCSR: if (op_type == MTS_WRITE) { if (((*data) & WDT_CLOCK_SOUCE_MASK) == WDT_CLOCK_EXT) { jz4740_wdt_clock = EXT_CLOCK; } else if (((*data) & WDT_CLOCK_SOUCE_MASK) == WDT_CLOCK_RTC) jz4740_wdt_clock = RTC_CLOCK; else ASSERT (0, "RTC and EXT clock is supported \n"); if ((((*data) & WDT_CLOCK_PRESCALE_MASK) >> WDT_CLOCK_PRESCALE_OFFSET) == 0x1) jz4740_wdt_clock = jz4740_wdt_clock / 4; else if ((((*data) & WDT_CLOCK_PRESCALE_MASK) >> WDT_CLOCK_PRESCALE_OFFSET) == 0x2) jz4740_wdt_clock = jz4740_wdt_clock / 16; else if ((((*data) & WDT_CLOCK_PRESCALE_MASK) >> WDT_CLOCK_PRESCALE_OFFSET) == 0x3) jz4740_wdt_clock = jz4740_wdt_clock / 64; else if ((((*data) & WDT_CLOCK_PRESCALE_MASK) >> WDT_CLOCK_PRESCALE_OFFSET) == 0x4) jz4740_wdt_clock = jz4740_wdt_clock / 256; else if ((((*data) & WDT_CLOCK_PRESCALE_MASK) >> WDT_CLOCK_PRESCALE_OFFSET) == 0x5) jz4740_wdt_clock = jz4740_wdt_clock / 1024; else if ((((*data) & WDT_CLOCK_PRESCALE_MASK) >> WDT_CLOCK_PRESCALE_OFFSET) != 0x0) ASSERT (0, "INVALID PRESCALE %x \n", *data); } return ((void *) (d->jz4740_wdt_tcu_ptr + offset)); case WDT_TCER: if (op_type == MTS_WRITE) { jz4740_wdt_tcu_table[WDT_TCER / 4] = (*data) & 0x1; *has_set_value = TRUE; if (unlikely (jz4740_wdt_tcu_table[WDT_TCER / 4] & 0x01) && (!(jz4740_wdt_tcu_table[TCU_TSR / 4] & WDT_TIMER_STOP))) dev_jz4740_active_wdt (d); else dev_jz4740_unactive_wdt (d); } else return ((void *) (d->jz4740_wdt_tcu_ptr + offset)); default: return ((void *) (d->jz4740_wdt_tcu_ptr + offset)); } return NULL; } void dev_jz4740_wdt_tcu_init_defaultvalue () { memset (jz4740_wdt_tcu_table, 0x0, sizeof (jz4740_wdt_tcu_table)); jz4740_wdt_tcu_table[TCU_TDFR0 / 4] = 0X7FF8; jz4740_wdt_tcu_table[TCU_TDHR0 / 4] = 0X7FF7; jz4740_wdt_tcu_table[TCU_TCNT0 / 4] = 0X7FF7; jz4740_wdt_tcu_table[TCU_TDFR1 / 4] = 0X7FF8; jz4740_wdt_tcu_table[TCU_TDHR1 / 4] = 0X7FF7; jz4740_wdt_tcu_table[TCU_TCNT1 / 4] = 0X7FF7; jz4740_wdt_tcu_table[TCU_TDFR2 / 4] = 0X7FF8; jz4740_wdt_tcu_table[TCU_TDHR2 / 4] = 0X7FF7; jz4740_wdt_tcu_table[TCU_TCNT2 / 4] = 0X7FF7; jz4740_wdt_tcu_table[TCU_TDFR3 / 4] = 0X7FF8; jz4740_wdt_tcu_table[TCU_TDHR3 / 4] = 0X7FF7; jz4740_wdt_tcu_table[TCU_TCNT3 / 4] = 0X7FF7; jz4740_wdt_tcu_table[TCU_TDFR4 / 4] = 0X7FF8; jz4740_wdt_tcu_table[TCU_TDHR4 / 4] = 0X7FF7; jz4740_wdt_tcu_table[TCU_TCNT4 / 4] = 0X7FF7; jz4740_wdt_tcu_table[TCU_TDFR5 / 4] = 0X7FF8; jz4740_wdt_tcu_table[TCU_TDHR5 / 4] = 0X7FF7; jz4740_wdt_tcu_table[TCU_TCNT5 / 4] = 0X7FF7; } void dev_jz4740_wdt_tcu_reset (cpu_mips_t * cpu, struct vdevice *dev) { dev_jz4740_wdt_tcu_init_defaultvalue (); } int gasdf; int reset_request = 0; /*10ms*/ void dev_jz4740_wdt_cb (void *opaque) { m_int64_t current; m_uint32_t past_time; struct jz4740_wdt_tcu_data *d = (struct jz4740_wdt_tcu_data *) opaque; if (unlikely (jz4740_wdt_tcu_table[WDT_TCER / 4] & 0x01) && (!(jz4740_wdt_tcu_table[TCU_TSR / 4] & WDT_TIMER_STOP))) { current = vp_get_clock (rt_clock); past_time = current - d->tcu_timer[0]->set_time; { jz4740_wdt_tcu_table[WDT_TCNT / 4] += (jz4740_wdt_clock) / 100; if (jz4740_wdt_tcu_table[WDT_TCNT / 4] >= jz4740_wdt_tcu_table[WDT_TDR / 4]) { /*RESET soc */ cpu_restart (current_cpu); jz4740_reset (current_cpu->vm); } } } dev_jz4740_active_wdt (d); } /*10ms Linux uses 100HZ timer, so we fire tcu every 10 ms. 1ms -> jz4740_wdt_tcu_table[TCU_TCNT0/4]+= jz4740_tcu_clock[0])/1000; */ void dev_jz4740_tcu_cb (void *opaque) { struct jz4740_wdt_tcu_data *d = (struct jz4740_wdt_tcu_data *) opaque; m_int64_t current; m_uint32_t past_time; current = vp_get_clock (rt_clock); past_time = current - d->tcu_timer[0]->set_time; jz4740_wdt_tcu_table[TCU_TCNT0 / 4] += (past_time * jz4740_tcu_clock[0]) / 1000; jz4740_wdt_tcu_table[TCU_TCNT0 / 4] &= 0xffff; if (jz4740_wdt_tcu_table[TCU_TCNT0 / 4] >= jz4740_wdt_tcu_table[TCU_TDHR0 / 4]) { /*set TFR */ jz4740_wdt_tcu_table[TCU_TFR / 4] |= 1 << 16; if (!(jz4740_wdt_tcu_table[TCU_TMR / 4] & (1 << 16))) current_cpu->vm->set_irq (current_cpu->vm, IRQ_TCU0); } if (jz4740_wdt_tcu_table[TCU_TCNT0 / 4] >= jz4740_wdt_tcu_table[TCU_TDFR0 / 4]) { jz4740_wdt_tcu_table[TCU_TFR / 4] |= 1; if (!(jz4740_wdt_tcu_table[TCU_TMR / 4] & (0x1))) { current_cpu->vm->set_irq (current_cpu->vm, IRQ_TCU0); } jz4740_wdt_tcu_table[TCU_TCNT0 / 4] = 0; } dev_jz4740_tcu_active_timer0 (d); } int dev_jz4740_wdt_tcu_init (vm_instance_t * vm, char *name, m_pa_t paddr, m_uint32_t len) { struct jz4740_wdt_tcu_data *d; /* allocate the private data structure */ if (!(d = malloc (sizeof (*d)))) { fprintf (stderr, "jz4740_wdt_tcu: unable to create device.\n"); return (-1); } memset (d, 0, sizeof (*d)); if (!(d->dev = dev_create (name))) goto err_dev_create; d->dev->priv_data = d; d->dev->phys_addr = paddr; d->dev->phys_len = len; d->jz4740_wdt_tcu_ptr = (m_uint8_t *) (&jz4740_wdt_tcu_table[0]); d->jz4740_wdt_tcu_size = len; d->dev->handler = dev_jz4740_wdt_tcu_access; d->dev->reset_handler = dev_jz4740_wdt_tcu_reset; d->dev->flags = VDEVICE_FLAG_NO_MTS_MMAP; /*only emulate timer0 */ d->tcu_timer[0] = vp_new_timer (rt_clock, dev_jz4740_tcu_cb, d); d->wdt_timer = vp_new_timer (rt_clock, dev_jz4740_wdt_cb, d); vm_bind_device (vm, d->dev); return (0); err_dev_create: free (d); return (-1); } #if 0 /*-------------Virtual Timer and WDT Timer----------------------*/ m_uint32_t past_instructions = 0; //m_uint32_t past_instructions[6]; /*TODO:need to adjust*/ #define COUNT_PER_INSTRUCTION 0x80 //0X180 /*JUST TIMER 0*/ void forced_inline virtual_jz4740_timer (cpu_mips_t * cpu) { if (unlikely (jz4740_wdt_tcu_table[TCU_TSR / 4] & 0x01)) { return; } if (likely (jz4740_wdt_tcu_table[TCU_TER / 4] & 0x01)) { //allow counter past_instructions++; if (past_instructions == COUNT_PER_INSTRUCTION) { jz4740_wdt_tcu_table[TCU_TCNT0 / 4] += 1; if (jz4740_wdt_tcu_table[TCU_TCNT0 / 4] == jz4740_wdt_tcu_table[TCU_TDHR0 / 4]) { /*set TFR */ jz4740_wdt_tcu_table[TCU_TFR / 4] |= 1 << 16; if (!(jz4740_wdt_tcu_table[TCU_TMR / 4] & (1 << 16))) cpu->vm->set_irq (cpu->vm, IRQ_TCU0); } if (jz4740_wdt_tcu_table[TCU_TCNT0 / 4] == jz4740_wdt_tcu_table[TCU_TDFR0 / 4]) { jz4740_wdt_tcu_table[TCU_TFR / 4] |= 1; if (!(jz4740_wdt_tcu_table[TCU_TMR / 4] & (0x1))) { cpu->vm->set_irq (cpu->vm, IRQ_TCU0); } jz4740_wdt_tcu_table[TCU_TCNT0 / 4] = 0; } past_instructions = 0; } } } m_uint32_t wdt_past_instructions = 0; void forced_inline virtual_jz4740_wdt (cpu_mips_t * cpu) { if (likely (jz4740_wdt_tcu_table[TCU_TSR / 4] & WDT_TIMER_STOP)) { return; } if (unlikely (jz4740_wdt_tcu_table[WDT_TCER / 4] & 0x01)) { wdt_past_instructions++; if (wdt_past_instructions >= COUNT_PER_INSTRUCTION) { jz4740_wdt_tcu_table[WDT_TCNT / 4] += 1; wdt_past_instructions = 0; if (jz4740_wdt_tcu_table[WDT_TCNT / 4] & 0xffff0000) jz4740_wdt_tcu_table[WDT_TCNT / 4] = 0; if (jz4740_wdt_tcu_table[WDT_TCNT / 4] >= jz4740_wdt_tcu_table[WDT_TDR / 4]) { /*RESET soc */ cpu_stop (cpu); cpu->cpu_thread_running = FALSE; jz4740_reset (cpu->vm); } } } } void forced_inline virtual_timer (cpu_mips_t * cpu) { virtual_jz4740_timer (cpu); virtual_jz4740_wdt (cpu); } #endif ================================================ FILE: tools/virtualmips/m4k.c ================================================ /* * Simulation of generic M4K core. * * Copyright (C) 2015 Serge Vakulenko * * This file is part of the virtualmips distribution. * See LICENSE file for terms of the license. */ #define _GNU_SOURCE #include #include #include #include "vp_lock.h" #include "utils.h" #include "mips.h" #include "vm.h" #include "cpu.h" #include "mips_exec.h" #include "debug.h" #include "m4k.h" #include "device.h" #include "mips_jit.h" #define BOOT_RAM_KBYTES 64 /* Size of boot RAM area */ /* * Store a word to the physical memory. */ int store_word (vm_instance_t *vm, m_pa_t paddr, unsigned data) { struct vdevice *dev = dev_lookup (vm, paddr); char *ptr; if (! dev) return -1; /* Only for RAM */ ptr = (char *) dev->host_addr + (paddr - dev->phys_addr); *(m_uint32_t*) ptr = data; return 0; } /* * Load MIPS hex file into memory. */ static void load_hex_file (struct vm_instance *vm, const char *filename) { FILE *fp; char buf [64], *p, *ep; unsigned address, end_address, data, big_endian = 0; fp = fopen (filename, "r"); if (! fp) { fprintf (stderr, "%s: Cannot open\n", filename); exit (-1); } while (fgets (buf, sizeof(buf), fp) != 0) { /* Check header for endian */ if (buf[0] == '#') { if (strncmp (buf, "# Endian Big", 12) == 0) { big_endian = 1; } continue; } address = strtoul (buf, &ep, 16); if (ep == buf || *ep == 0) { continue; } if (*ep == '-') { p = ep+1; end_address = strtoul (p, &ep, 16); if (ep == p || *ep != ' ') { continue; } } else end_address = address; p = ep; data = strtoul (p, &ep, 16); if (ep == p) { continue; } /* Byte swap. */ if (big_endian) { data = (data & 0x000000ff) << 24 | (data & 0x0000ff00) << 8 | (data & 0x00ff0000) >> 8 | (data & 0xff000000) >> 24 ; } do { if (store_word (vm, address << 2, data) < 0) { fprintf (stderr, "%s: No memory at physical address %08x\n", filename, address << 2); exit (-1); } //printf (" %08x <= %08x\n", address << 2, data); } while (address++ < end_address); } fclose (fp); } /* * Initialize the M4K platform. */ static int m4k_init_platform (m4k_t *m4k) { struct vm_instance *vm = m4k->vm; cpu_mips_t *cpu0; void *(*cpu_run_fn) (void *); //vm_init_vtty (vm); /* Create a CPU group */ vm->cpu_group = cpu_group_create ("System CPU"); /* Initialize the virtual MIPS processor */ cpu0 = cpu_create (vm, CPU_TYPE_MIPS32, 0); if (! cpu0) { vm_error (vm, "unable to create CPU0!\n"); return (-1); } /* Add this CPU to the system CPU group */ cpu_group_add (vm->cpu_group, cpu0); vm->boot_cpu = cpu0; /* create the CPU thread execution */ cpu_run_fn = (void *) mips_exec_run_cpu; if (pthread_create (&cpu0->cpu_thread, NULL, cpu_run_fn, cpu0) != 0) { fprintf (stderr, "cpu_create: unable to create thread for CPU%u\n", 0); free (cpu0); return (-1); } /* 32-bit address */ cpu0->addr_bus_mask = 0xffffffff; /* Initialize main RAM */ vm_ram_init (vm, 0x00000000ULL); /* Initialize boot RAM area */ dev_ram_init (vm, "boot", 0x1fc00000, BOOT_RAM_KBYTES*1024); load_hex_file (vm, m4k->boot_file_name); return (0); } /* * Find pending interrupt with the biggest priority. * Setup INTSTAT and cause registers. * Update irq_pending flag for CPU. */ void m4k_update_irq_flag (m4k_t *m4k) { cpu_mips_t *cpu = m4k->vm->boot_cpu; /* Assume no interrupts pending. */ cpu->irq_cause = 0; cpu->irq_pending = 0; //TODO cpu->irq_cause = 0; /*printf ("-- vector = %d, level = %d\n", vector, level);*/ mips_update_irq_flag (cpu); } void m4k_clear_irq (vm_instance_t *vm, u_int irq) { m4k_t *m4k = (m4k_t*) vm->hw_data; /* Clear interrupt flag status */ //TODO m4k_update_irq_flag (m4k); } void m4k_set_irq (vm_instance_t *vm, u_int irq) { m4k_t *m4k = (m4k_t*) vm->hw_data; /* Set interrupt flag status */ //TODO m4k_update_irq_flag (m4k); } /* * Activate core timer interrupt */ void set_timer_irq (cpu_mips_t *cpu) { //TODO } /* * Clear core timer interrupt */ void clear_timer_irq (cpu_mips_t *cpu) { //TODO } /* * Increment timers. */ void host_alarm (cpu_mips_t *cpu, int nclocks) { //m4k_t *m4k = (m4k_t*) cpu->vm->hw_data; //TODO } /* * Create an instance of virtual machine. */ vm_instance_t *create_instance (char *filename) { vm_instance_t *vm; m4k_t *m4k; const char *name = "m4k"; m4k = malloc (sizeof (*m4k)); if (! m4k) { fprintf (stderr, "M4K: unable to create new instance!\n"); return NULL; } memset (m4k, 0, sizeof (*m4k)); vm = vm_create (name, VM_TYPE_PIC32); if (! vm) { fprintf (stderr, "M4K: unable to create VM instance!\n"); free (m4k); return NULL; } vm->hw_data = m4k; m4k->vm = vm; /* Initialize default parameters for m4k */ vm->ram_size = 4*1024; /* kilobytes */ vm->debug_level = 3; /* trace all instructions */ m4k->boot_file_name = filename ? filename : "test.hex"; m4k->start_address = 0xbfc00000; const char *output_file_name = "m4k.trace"; printf ("Redirect output to %s\n", output_file_name); if (freopen(output_file_name, "w", stdout) != stdout) { fprintf (stderr, "M4K: Unable to redirect output!\n"); exit(-1); } /* Print the configure information */ printf("ram_size: %dk bytes \n", vm->ram_size); printf("start_address: 0x%x\n", m4k->start_address); /* init gdb debug */ vm_debug_init (m4k->vm); return m4k->vm; } int init_instance (vm_instance_t * vm) { m4k_t *m4k = (m4k_t *) vm->hw_data; cpu_mips_t *cpu; if (m4k_init_platform (m4k) == -1) { vm_error (vm, "unable to initialize the platform hardware.\n"); return (-1); } if (! vm->boot_cpu) { vm_error (vm, "unable to boot cpu.\n"); return (-1); } /* IRQ routing */ vm->set_irq = m4k_set_irq; vm->clear_irq = m4k_clear_irq; vm_suspend (vm); /* Check that CPU activity is really suspended */ if (cpu_group_sync_state (vm->cpu_group) == -1) { vm_error (vm, "unable to sync with system CPUs.\n"); return (-1); } /* Reset the boot CPU */ cpu = vm->boot_cpu; mips_reset (cpu); /* Set config0-config3 registers. */ cpu->cp0.config_usable = 0x0f; cpu->cp0.config_reg[0] = 0xa4000582; cpu->cp0.config_reg[1] = 0x80000006; cpu->cp0.config_reg[2] = 0x80000000; cpu->cp0.config_reg[3] = 0x00000020; /* set PC and PRID */ cpu->pc = m4k->start_address; cpu->cp0.tlb_entries = 0; cpu->cp0.reg[MIPS_CP0_PRID] = 0x00018700; cpu->cp0.reg[MIPS_CP0_DEBUG] = 0x00010000; /* Enable magic opcodes. */ cpu->magic_opcodes = 1; /* reset all devices */ dev_reset_all (vm); #ifdef _USE_JIT_ /* if jit is used. flush all jit buffer */ if (vm->jit_use) mips_jit_flush (cpu, 0); #endif /* Launch the simulation */ printf ("--- Start simulation: PC=0x%" LL "x, JIT %sabled\n", cpu->pc, vm->jit_use ? "en" : "dis"); vm->status = VM_STATUS_RUNNING; cpu_start (vm->boot_cpu); return (0); } ================================================ FILE: tools/virtualmips/m4k.h ================================================ /* * Copyright (C) 2015 Serge Vakulenko * * This file is part of the virtualmips distribution. * See LICENSE file for terms of the license. */ #ifndef __M4K_H__ #define __M4K_H__ #include "types.h" #define DATA_WIDTH 32 /* MIPS32 architecture */ #define LL /* empty - printf format for machine word */ /* * Data types */ typedef m_uint32_t m_va_t; typedef m_uint32_t m_pa_t; typedef m_uint32_t m_reg_t; typedef m_int32_t m_ireg_t; typedef m_uint32_t m_cp0_reg_t; /*Guest endian*/ #define GUEST_BYTE_ORDER ARCH_LITTLE_ENDIAN /* Host to VM conversion functions */ #if HOST_BYTE_ORDER == GUEST_BYTE_ORDER #define htovm16(x) (x) #define htovm32(x) (x) #define htovm64(x) (x) #define vmtoh16(x) (x) #define vmtoh32(x) (x) #define vmtoh64(x) (x) #else //host:big guest:little #define htovm16(x) (ntohs(x)) #define htovm32(x) (ntohl(x)) #define htovm64(x) (swap64(x)) #define vmtoh16(x) (htons(x)) #define vmtoh32(x) (htonl(x)) #define vmtoh64(x) (swap64(x)) #endif struct m4k_system { /* Associated VM instance */ vm_instance_t *vm; unsigned start_address; /* jump here on reset */ char *boot_file_name; /* image of boot flash */ }; typedef struct m4k_system m4k_t; struct virtual_tty; vm_instance_t *create_instance (char *conf); int init_instance (vm_instance_t *vm); int m4k_reset (vm_instance_t *vm); void m4k_update_irq_flag (m4k_t *m4k); void m4k_set_irq (vm_instance_t *vm, unsigned irq); void m4k_clear_irq (vm_instance_t *vm, unsigned irq); void dumpregs (cpu_mips_t *cpu); #endif ================================================ FILE: tools/virtualmips/main.c ================================================ /* * Copyright (C) yajin 2008 * * This file is part of the virtualmips distribution. * See LICENSE file for terms of the license. */ #define _GNU_SOURCE #include #include #include #include #include #include "utils.h" #include "mips.h" #include "device.h" #include "vm.h" #include "mips_exec.h" #include "vp_timer.h" #include "crc.h" #include "net_io.h" #define VERSION "0.06-retrobsd" void signal_gen_handler (int sig) { switch (sig) { case SIGHUP: /* For future use */ break; case SIGQUIT: printf ("\n--- Stop simulation\n"); /*do not worry, exit will release all resource */ exit (EXIT_SUCCESS); break; case SIGINT: /* In theory, this shouldn't happen thanks to VTTY settings */ break; default: fprintf (stderr, "Unhandled signal %d\n", sig); } } /* Setups signals */ static void setup_signals (void) { struct sigaction act; memset (&act, 0, sizeof (act)); act.sa_handler = signal_gen_handler; act.sa_flags = SA_RESTART; sigaction (SIGHUP, &act, NULL); sigaction (SIGQUIT, &act, NULL); sigaction (SIGINT, &act, NULL); } int main (int argc, char *argv[]) { vm_instance_t *vm; char *configure_filename = NULL; printf ("\nVirtualMIPS (version %s)\n", VERSION); printf ("Copyright (c) 2008 yajin, 2011-2015 vak.\n"); printf ("Build date: %s %s\n\n", __DATE__, __TIME__); /* Initialize CRC functions */ crc_init (); /* Initialize VTTY code */ vtty_init (); /* Create the default instance */ if (argc > 1) configure_filename = argv[1]; vm = create_instance (configure_filename); if (!vm) return EXIT_FAILURE; /* Set seed for random value. */ srand ((int) time (0)); setup_signals (); init_timers (); if (init_instance (vm) < 0) { fprintf (stderr, "Unable to initialize instance.\n"); return EXIT_FAILURE; } /* We get here, because the cpu is not running now. */ vm_monitor (vm); printf ("VM shut down\n"); return (0); } ================================================ FILE: tools/virtualmips/mempool.c ================================================ /* * Copyright (c) 1999-2006 Christophe Fillot. * E-mail: cf@utc.fr * * mempool.c: Simple Memory Pools. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "utils.h" #include "mempool.h" /* * Internal function used to allocate a memory block, and do basic operations * on it. It does not manipulate pools, so no mutex is needed. */ static inline memblock_t *memblock_alloc (size_t size, int zeroed) { memblock_t *block; size_t total_size; total_size = size + sizeof (memblock_t); if (!(block = malloc (total_size))) return NULL; if (zeroed) memset (block, 0, total_size); block->tag = MEMBLOCK_TAG; block->block_size = size; block->prev = block->next = NULL; return block; } /* Insert block in linked list */ static inline void memblock_insert (mempool_t * pool, memblock_t * block) { MEMPOOL_LOCK (pool); pool->nr_blocks++; pool->total_size += block->block_size; block->prev = NULL; block->next = pool->block_list; if (block->next) block->next->prev = block; pool->block_list = block; MEMPOOL_UNLOCK (pool); } /* Remove block from linked list */ static inline void memblock_delete (mempool_t * pool, memblock_t * block) { MEMPOOL_LOCK (pool); pool->nr_blocks--; pool->total_size -= block->block_size; if (!block->prev) pool->block_list = block->next; else block->prev->next = block->next; if (block->next) block->next->prev = block->prev; block->next = block->prev = NULL; MEMPOOL_UNLOCK (pool); } /* Allocate a new block in specified pool (internal function) */ static inline void *mp_alloc_inline (mempool_t * pool, size_t size, int zeroed) { memblock_t *block; if (!(block = memblock_alloc (size, zeroed))) return NULL; block->pool = pool; memblock_insert (pool, block); return (block->data); } /* Allocate a new block in specified pool */ void *mp_alloc (mempool_t * pool, size_t size) { return (mp_alloc_inline (pool, size, TRUE)); } /* Allocate a new block which will not be zeroed */ void *mp_alloc_n0 (mempool_t * pool, size_t size) { return (mp_alloc_inline (pool, size, FALSE)); } /* Reallocate a block */ void *mp_realloc (void *addr, size_t new_size) { memblock_t *ptr, *block = (memblock_t *) addr - 1; mempool_t *pool; size_t total_size; assert (block->tag == MEMBLOCK_TAG); pool = block->pool; /* remove this block from list */ memblock_delete (pool, block); /* reallocate block with specified size */ total_size = new_size + sizeof (memblock_t); if (!(ptr = realloc (block, total_size))) { memblock_insert (pool, block); return NULL; } ptr->block_size = new_size; memblock_insert (pool, ptr); return ptr->data; } /* Allocate a new memory block and copy data into it */ void *mp_dup (mempool_t * pool, void *data, size_t size) { void *p; if ((p = mp_alloc_n0 (pool, size))) memcpy (p, data, size); return p; } /* Duplicate specified string and insert it in a memory pool */ char *mp_strdup (mempool_t * pool, char *str) { char *new_str; if ((new_str = mp_alloc (pool, strlen (str) + 1)) == NULL) return NULL; strlcpy (new_str, str, sizeof(new_str)); return new_str; } /* Free block at specified address */ int mp_free (void *addr) { memblock_t *block = (memblock_t *) addr - 1; mempool_t *pool; if (addr != NULL) { assert (block->tag == MEMBLOCK_TAG); pool = block->pool; memblock_delete (pool, block); memset (block, 0, sizeof (memblock_t)); free (block); } return (0); } /* Free block at specified address and clean pointer */ int mp_free_ptr (void *addr) { void *p; assert (addr != NULL); p = *(void **) addr; *(void **) addr = NULL; mp_free (p); return (0); } /* Free all blocks of specified pool */ void mp_free_all_blocks (mempool_t * pool) { memblock_t *block, *next; MEMPOOL_LOCK (pool); for (block = pool->block_list; block; block = next) { next = block->next; free (block); } pool->block_list = NULL; pool->nr_blocks = 0; pool->total_size = 0; MEMPOOL_UNLOCK (pool); } /* Free specified memory pool */ void mp_free_pool (mempool_t * pool) { mp_free_all_blocks (pool); if (!(pool->flags & MEMPOOL_FIXED)) free (pool); } /* Create a new pool in a fixed memory area */ mempool_t *mp_create_fixed_pool (mempool_t * mp, char *name) { memset (mp, 0, sizeof (*mp)); if (pthread_mutex_init (&mp->lock, NULL) != 0) return NULL; mp->name = name; mp->block_list = NULL; mp->flags = MEMPOOL_FIXED; return mp; } /* Create a new pool */ mempool_t *mp_create_pool (char *name) { mempool_t *mp = malloc (sizeof (*mp)); if (!mp || !mp_create_fixed_pool (mp, name)) { free (mp); return NULL; } mp->flags = 0; /* clear "FIXED" flag */ return mp; } ================================================ FILE: tools/virtualmips/mempool.h ================================================ /* * Copyright (c) 1999-2006 Christophe Fillot. * E-mail: cf@utc.fr * * mempool.h: Simple Memory Pools. */ #ifndef __MEMPOOL_H__ #define __MEMPOOL_H__ 1 #include #include #include #include "utils.h" /* Memory Pool "Fixed" Flag */ #define MEMPOOL_FIXED 1 /* Dummy value used to check if a memory block is invalid */ #define MEMBLOCK_TAG 0xdeadbeef typedef struct memblock memblock_t; typedef struct mempool mempool_t; /* Memory block */ struct memblock { int tag; /* MEMBLOCK_TAG if block is valid */ size_t block_size; /* Block size (without header) */ memblock_t *next, *prev; /* Double linked list pointers */ mempool_t *pool; /* Pool which contains this block */ m_uint64_t data[0]; /* Memory block itself */ }; /* Memory Pool */ struct mempool { memblock_t *block_list; /* Double-linked block list */ pthread_mutex_t lock; /* Mutex for managing pool */ char *name; /* Name of this pool */ int flags; /* Flags */ int nr_blocks; /* Number of blocks in this pool */ size_t total_size; /* Total bytes allocated */ size_t max_size; /* Maximum memory */ }; /* Lock and unlock access to a memory pool */ #define MEMPOOL_LOCK(mp) pthread_mutex_lock(&(mp)->lock) #define MEMPOOL_UNLOCK(mp) pthread_mutex_unlock(&(mp)->lock) /* Callback function for use with mp_foreach */ typedef void (*mp_foreach_cbk) (memblock_t * block, void *user_arg); /* Execute an action for each block in specified pool */ static inline void mp_foreach (mempool_t * pool, mp_foreach_cbk cbk, void *arg) { memblock_t *mb; for (mb = pool->block_list; mb; mb = mb->next) cbk (mb, arg); } /* Allocate a new block in specified pool */ void *mp_alloc (mempool_t * pool, size_t size); /* Allocate a new block which will not be zeroed */ void *mp_alloc_n0 (mempool_t * pool, size_t size); /* Reallocate a block */ void *mp_realloc (void *addr, size_t new_size); /* Allocate a new memory block and copy data into it */ void *mp_dup (mempool_t * pool, void *data, size_t size); /* Duplicate specified string and insert it in a memory pool */ char *mp_strdup (mempool_t * pool, char *str); /* Free block at specified address */ int mp_free (void *addr); /* Free block at specified address and clean pointer */ int mp_free_ptr (void *addr); /* Free all blocks of specified pool */ void mp_free_all_blocks (mempool_t * pool); /* Free specified memory pool */ void mp_free_pool (mempool_t * pool); /* Create a new pool in a fixed memory area */ mempool_t *mp_create_fixed_pool (mempool_t * mp, char *name); /* Create a new pool */ mempool_t *mp_create_pool (char *name); #endif ================================================ FILE: tools/virtualmips/mips-dis.c ================================================ /* * Print mips instructions. * * Copyright 1989, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, * 2000, 2001, 2002, 2003, 2005, 2006, 2007, 2008, 2009 * Free Software Foundation, Inc. * Contributed by Nobuyuki Hikichi (hikichi@sra.co.jp). * Rewritten for VirtualMIPS by Serge Vakulenko. * * This file is part of the virtualmips distribution. * See LICENSE file for terms of the license. */ #include #include #include #include "mips-opcode.h" #include "mips-opc.c" #include "mips16-opc.c" /* FIXME: These are needed to figure out if the code is mips16 or not. The low bit of the address is often a good indicator. No symbol table is available when this code runs out in an embedded system as when it is used for disassembler support in a monitor. */ /* Mips instructions are at maximum this many bytes long. */ #define INSNLEN 4 struct mips_cp0sel_name { unsigned int cp0reg; unsigned int sel; const char *const name; }; /* The mips16 registers. */ static const unsigned int mips16_to_32_reg_map[] = { 16, 17, 2, 3, 4, 5, 6, 7 }; #define mips16_reg_names(rn) mips_gpr_names[mips16_to_32_reg_map[rn]] static const char *const mips_gpr_names[32] = { "zero", "at", "v0", "v1", "a0", "a1", "a2", "a3", "t0", "t1", "t2", "t3", "t4", "t5", "t6", "t7", "s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7", "t8", "t9", "k0", "k1", "gp", "sp", "s8", "ra" }; static const char *const mips_fpr_names[32] = { "$f0", "$f1", "$f2", "$f3", "$f4", "$f5", "$f6", "$f7", "$f8", "$f9", "$f10", "$f11", "$f12", "$f13", "$f14", "$f15", "$f16", "$f17", "$f18", "$f19", "$f20", "$f21", "$f22", "$f23", "$f24", "$f25", "$f26", "$f27", "$f28", "$f29", "$f30", "$f31" }; static const char *const mips_cp0_names[32] = { "c0_index", "c0_random", "c0_entrylo0", "c0_entrylo1", "c0_context", "c0_pagemask", "c0_wired", "c0_hwrena", "c0_badvaddr", "c0_count", "c0_entryhi", "c0_compare", "c0_status", "c0_cause", "c0_epc", "c0_prid", "c0_config", "c0_lladdr", "c0_watchlo", "c0_watchhi", "c0_xcontext", "$21", "$22", "c0_debug", "c0_depc", "c0_perfcnt", "c0_errctl", "c0_cacheerr", "c0_taglo", "c0_taghi", "c0_errorepc", "c0_desave", }; static const struct mips_cp0sel_name mips_cp0sel_names[] = { {4, 1, "c0_contextconfig"}, {0, 1, "c0_mvpcontrol"}, {0, 2, "c0_mvpconf0"}, {0, 3, "c0_mvpconf1"}, {1, 1, "c0_vpecontrol"}, {1, 2, "c0_vpeconf0"}, {1, 3, "c0_vpeconf1"}, {1, 4, "c0_yqmask"}, {1, 5, "c0_vpeschedule"}, {1, 6, "c0_vpeschefback"}, {2, 1, "c0_tcstatus"}, {2, 2, "c0_tcbind"}, {2, 3, "c0_tcrestart"}, {2, 4, "c0_tchalt"}, {2, 5, "c0_tccontext"}, {2, 6, "c0_tcschedule"}, {2, 7, "c0_tcschefback"}, {5, 1, "c0_pagegrain"}, {6, 1, "c0_srsconf0"}, {6, 2, "c0_srsconf1"}, {6, 3, "c0_srsconf2"}, {6, 4, "c0_srsconf3"}, {6, 5, "c0_srsconf4"}, {12, 1, "c0_intctl"}, {12, 2, "c0_srsctl"}, {12, 3, "c0_srsmap"}, {15, 1, "c0_ebase"}, {16, 1, "c0_config1"}, {16, 2, "c0_config2"}, {16, 3, "c0_config3"}, {18, 1, "c0_watchlo,1"}, {18, 2, "c0_watchlo,2"}, {18, 3, "c0_watchlo,3"}, {18, 4, "c0_watchlo,4"}, {18, 5, "c0_watchlo,5"}, {18, 6, "c0_watchlo,6"}, {18, 7, "c0_watchlo,7"}, {19, 1, "c0_watchhi,1"}, {19, 2, "c0_watchhi,2"}, {19, 3, "c0_watchhi,3"}, {19, 4, "c0_watchhi,4"}, {19, 5, "c0_watchhi,5"}, {19, 6, "c0_watchhi,6"}, {19, 7, "c0_watchhi,7"}, {23, 1, "c0_tracecontrol"}, {23, 2, "c0_tracecontrol2"}, {23, 3, "c0_usertracedata"}, {23, 4, "c0_tracebpc"}, {25, 1, "c0_perfcnt,1"}, {25, 2, "c0_perfcnt,2"}, {25, 3, "c0_perfcnt,3"}, {25, 4, "c0_perfcnt,4"}, {25, 5, "c0_perfcnt,5"}, {25, 6, "c0_perfcnt,6"}, {25, 7, "c0_perfcnt,7"}, {27, 1, "c0_cacheerr,1"}, {27, 2, "c0_cacheerr,2"}, {27, 3, "c0_cacheerr,3"}, {28, 1, "c0_datalo"}, {28, 2, "c0_taglo1"}, {28, 3, "c0_datalo1"}, {28, 4, "c0_taglo2"}, {28, 5, "c0_datalo2"}, {28, 6, "c0_taglo3"}, {28, 7, "c0_datalo3"}, {29, 1, "c0_datahi"}, {29, 2, "c0_taghi1"}, {29, 3, "c0_datahi1"}, {29, 4, "c0_taghi2"}, {29, 5, "c0_datahi2"}, {29, 6, "c0_taghi3"}, {29, 7, "c0_datahi3"}, }; static const int mips_cp0sel_names_len = sizeof (mips_cp0sel_names) / sizeof (*mips_cp0sel_names); static const char *const mips_hwr_names[32] = { "$0", "$1", "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$16", "$17", "$18", "$19", "$20", "$21", "$22", "$23", "$24", "$25", "$26", "$27", "$28", "$29", "$30", "$31" }; /* * If set disassemble as most general inst. */ static int no_aliases = 0; static unsigned target; static void print_address (unsigned address, FILE *stream) { if (address < 16) fprintf (stream, "%d", address); else fprintf (stream, "0x%x", address); } static const struct mips_cp0sel_name * lookup_mips_cp0sel_name (const struct mips_cp0sel_name *names, unsigned int len, unsigned int cp0reg, unsigned int sel) { unsigned int i; for (i = 0; i < len; i++) if (names[i].cp0reg == cp0reg && names[i].sel == sel) return &names[i]; return NULL; } /* * CP0 register including 'sel' code for mftc0, to be * printed textually if known. If not known, print both * CP0 register name and sel numerically since CP0 register * with sel 0 may have a name unrelated to register being * printed. */ const char *cp0reg_name (unsigned cp0reg, unsigned sel) { const struct mips_cp0sel_name *n; static char name [32]; if (sel == 0) return mips_cp0_names[cp0reg]; n = lookup_mips_cp0sel_name (mips_cp0sel_names, mips_cp0sel_names_len, cp0reg, sel); if (n != NULL) return n->name; snprintf (name, sizeof(name), "CP0_R[%d,%d]", cp0reg, sel); return name; } /* Print insn arguments for 32/64-bit code. */ static void print_insn_args (const char *d, register unsigned long int l, unsigned pc, FILE *stream, const struct mips_opcode *opp) { int op, delta; unsigned int lsb, msb, msbd; lsb = 0; for (; *d != '\0'; d++) { switch (*d) { case ',': case '(': case ')': case '[': case ']': fprintf (stream, "%c", *d); break; case '+': /* Extension character; switch for second char. */ d++; switch (*d) { case '\0': /* xgettext:c-format */ fprintf (stream, "# internal error, incomplete extension sequence (+)"); return; case 'A': lsb = (l >> OP_SH_SHAMT) & OP_MASK_SHAMT; fprintf (stream, "0x%x", lsb); break; case 'B': msb = (l >> OP_SH_INSMSB) & OP_MASK_INSMSB; fprintf (stream, "0x%x", msb - lsb + 1); break; case '1': fprintf (stream, "0x%lx", (l >> OP_SH_UDI1) & OP_MASK_UDI1); break; case '2': fprintf (stream, "0x%lx", (l >> OP_SH_UDI2) & OP_MASK_UDI2); break; case '3': fprintf (stream, "0x%lx", (l >> OP_SH_UDI3) & OP_MASK_UDI3); break; case '4': fprintf (stream, "0x%lx", (l >> OP_SH_UDI4) & OP_MASK_UDI4); break; case 'C': case 'H': msbd = (l >> OP_SH_EXTMSBD) & OP_MASK_EXTMSBD; fprintf (stream, "0x%x", msbd + 1); break; case 'D': { const struct mips_cp0sel_name *n; unsigned int cp0reg, sel; cp0reg = (l >> OP_SH_RD) & OP_MASK_RD; sel = (l >> OP_SH_SEL) & OP_MASK_SEL; /* CP0 register including 'sel' code for mtcN (et al.), to be * printed textually if known. If not known, print both * CP0 register name and sel numerically since CP0 register * with sel 0 may have a name unrelated to register being * printed. */ n = lookup_mips_cp0sel_name (mips_cp0sel_names, mips_cp0sel_names_len, cp0reg, sel); if (n != NULL) fprintf (stream, "%s", n->name); else fprintf (stream, "$%d,%d", cp0reg, sel); break; } case 'E': lsb = ((l >> OP_SH_SHAMT) & OP_MASK_SHAMT) + 32; fprintf (stream, "0x%x", lsb); break; case 'F': msb = ((l >> OP_SH_INSMSB) & OP_MASK_INSMSB) + 32; fprintf (stream, "0x%x", msb - lsb + 1); break; case 'G': msbd = ((l >> OP_SH_EXTMSBD) & OP_MASK_EXTMSBD) + 32; fprintf (stream, "0x%x", msbd + 1); break; case 't': /* Coprocessor 0 reg name */ fprintf (stream, "%s", mips_cp0_names[(l >> OP_SH_RT) & OP_MASK_RT]); break; case 'T': /* Coprocessor 0 reg name */ { const struct mips_cp0sel_name *n; unsigned int cp0reg, sel; cp0reg = (l >> OP_SH_RT) & OP_MASK_RT; sel = (l >> OP_SH_SEL) & OP_MASK_SEL; /* CP0 register including 'sel' code for mftc0, to be * printed textually if known. If not known, print both * CP0 register name and sel numerically since CP0 register * with sel 0 may have a name unrelated to register being * printed. */ n = lookup_mips_cp0sel_name (mips_cp0sel_names, mips_cp0sel_names_len, cp0reg, sel); if (n != NULL) fprintf (stream, "%s", n->name); else fprintf (stream, "$%d,%d", cp0reg, sel); break; } case 'x': /* bbit bit index */ fprintf (stream, "0x%lx", (l >> OP_SH_BBITIND) & OP_MASK_BBITIND); break; case 'p': /* cins, cins32, exts and exts32 position */ fprintf (stream, "0x%lx", (l >> OP_SH_CINSPOS) & OP_MASK_CINSPOS); break; case 's': /* cins and exts length-minus-one */ fprintf (stream, "0x%lx", (l >> OP_SH_CINSLM1) & OP_MASK_CINSLM1); break; case 'S': /* cins32 and exts32 length-minus-one field */ fprintf (stream, "0x%lx", (l >> OP_SH_CINSLM1) & OP_MASK_CINSLM1); break; case 'Q': /* seqi/snei immediate field */ op = (l >> OP_SH_SEQI) & OP_MASK_SEQI; /* Sign-extend it. */ op = (op ^ 512) - 512; fprintf (stream, "%d", op); break; default: /* xgettext:c-format */ fprintf (stream, "# internal error, undefined extension sequence (+%c)", *d); return; } break; case '2': fprintf (stream, "0x%lx", (l >> OP_SH_BP) & OP_MASK_BP); break; case '3': fprintf (stream, "0x%lx", (l >> OP_SH_SA3) & OP_MASK_SA3); break; case '4': fprintf (stream, "0x%lx", (l >> OP_SH_SA4) & OP_MASK_SA4); break; case '5': fprintf (stream, "0x%lx", (l >> OP_SH_IMM8) & OP_MASK_IMM8); break; case '6': fprintf (stream, "0x%lx", (l >> OP_SH_RS) & OP_MASK_RS); break; case '7': fprintf (stream, "$ac%ld", (l >> OP_SH_DSPACC) & OP_MASK_DSPACC); break; case '8': fprintf (stream, "0x%lx", (l >> OP_SH_WRDSP) & OP_MASK_WRDSP); break; case '9': fprintf (stream, "$ac%ld", (l >> OP_SH_DSPACC_S) & OP_MASK_DSPACC_S); break; case '0': /* dsp 6-bit signed immediate in bit 20 */ delta = ((l >> OP_SH_DSPSFT) & OP_MASK_DSPSFT); if (delta & 0x20) /* test sign bit */ delta |= ~OP_MASK_DSPSFT; fprintf (stream, "%d", delta); break; case ':': /* dsp 7-bit signed immediate in bit 19 */ delta = ((l >> OP_SH_DSPSFT_7) & OP_MASK_DSPSFT_7); if (delta & 0x40) /* test sign bit */ delta |= ~OP_MASK_DSPSFT_7; fprintf (stream, "%d", delta); break; case '\'': fprintf (stream, "0x%lx", (l >> OP_SH_RDDSP) & OP_MASK_RDDSP); break; case '@': /* dsp 10-bit signed immediate in bit 16 */ delta = ((l >> OP_SH_IMM10) & OP_MASK_IMM10); if (delta & 0x200) /* test sign bit */ delta |= ~OP_MASK_IMM10; fprintf (stream, "%d", delta); break; case '!': fprintf (stream, "%ld", (l >> OP_SH_MT_U) & OP_MASK_MT_U); break; case '$': fprintf (stream, "%ld", (l >> OP_SH_MT_H) & OP_MASK_MT_H); break; case '*': fprintf (stream, "$ac%ld", (l >> OP_SH_MTACC_T) & OP_MASK_MTACC_T); break; case '&': fprintf (stream, "$ac%ld", (l >> OP_SH_MTACC_D) & OP_MASK_MTACC_D); break; case 'g': /* Coprocessor register for CTTC1, MTTC2, MTHC2, CTTC2. */ fprintf (stream, "$%ld", (l >> OP_SH_RD) & OP_MASK_RD); break; case 's': case 'b': case 'r': case 'v': fprintf (stream, "%s", mips_gpr_names[(l >> OP_SH_RS) & OP_MASK_RS]); break; case 't': case 'w': fprintf (stream, "%s", mips_gpr_names[(l >> OP_SH_RT) & OP_MASK_RT]); break; case 'i': case 'u': fprintf (stream, "0x%lx", (l >> OP_SH_IMMEDIATE) & OP_MASK_IMMEDIATE); break; case 'j': /* Same as i, but sign-extended. */ case 'o': delta = (l >> OP_SH_DELTA) & OP_MASK_DELTA; if (delta & 0x8000) delta |= ~0xffff; fprintf (stream, "%d", delta); break; case 'h': fprintf (stream, "0x%x", (unsigned int) ((l >> OP_SH_PREFX) & OP_MASK_PREFX)); break; case 'k': fprintf (stream, "0x%x", (unsigned int) ((l >> OP_SH_CACHE) & OP_MASK_CACHE)); break; case 'a': target = (((pc + 4) & ~(unsigned) 0x0fffffff) | (((l >> OP_SH_TARGET) & OP_MASK_TARGET) << 2)); /* For gdb disassembler, force odd address on jalx. */ if (strcmp (opp->name, "jalx") == 0) target |= 1; print_address (target, stream); break; case 'p': /* Sign extend the displacement. */ delta = (l >> OP_SH_DELTA) & OP_MASK_DELTA; if (delta & 0x8000) delta |= ~0xffff; target = (delta << 2) + pc + INSNLEN; print_address (target, stream); break; case 'd': fprintf (stream, "%s", mips_gpr_names[(l >> OP_SH_RD) & OP_MASK_RD]); break; case 'U': { /* First check for both rd and rt being equal. */ unsigned int reg = (l >> OP_SH_RD) & OP_MASK_RD; if (reg == ((l >> OP_SH_RT) & OP_MASK_RT)) fprintf (stream, "%s", mips_gpr_names[reg]); else { /* If one is zero use the other. */ if (reg == 0) fprintf (stream, "%s", mips_gpr_names[(l >> OP_SH_RT) & OP_MASK_RT]); else if (((l >> OP_SH_RT) & OP_MASK_RT) == 0) fprintf (stream, "%s", mips_gpr_names[reg]); else /* Bogus, result depends on processor. */ fprintf (stream, "%s or %s", mips_gpr_names[reg], mips_gpr_names[(l >> OP_SH_RT) & OP_MASK_RT]); } } break; case 'z': fprintf (stream, "%s", mips_gpr_names[0]); break; case '<': case '1': fprintf (stream, "0x%lx", (l >> OP_SH_SHAMT) & OP_MASK_SHAMT); break; case 'c': fprintf (stream, "0x%lx", (l >> OP_SH_CODE) & OP_MASK_CODE); break; case 'q': fprintf (stream, "0x%lx", (l >> OP_SH_CODE2) & OP_MASK_CODE2); break; case 'C': fprintf (stream, "0x%lx", (l >> OP_SH_COPZ) & OP_MASK_COPZ); break; case 'B': fprintf (stream, "0x%lx", (l >> OP_SH_CODE20) & OP_MASK_CODE20); break; case 'J': fprintf (stream, "0x%lx", (l >> OP_SH_CODE19) & OP_MASK_CODE19); break; case 'S': case 'V': fprintf (stream, "%s", mips_fpr_names[(l >> OP_SH_FS) & OP_MASK_FS]); break; case 'T': case 'W': fprintf (stream, "%s", mips_fpr_names[(l >> OP_SH_FT) & OP_MASK_FT]); break; case 'D': fprintf (stream, "%s", mips_fpr_names[(l >> OP_SH_FD) & OP_MASK_FD]); break; case 'R': fprintf (stream, "%s", mips_fpr_names[(l >> OP_SH_FR) & OP_MASK_FR]); break; case 'E': /* Coprocessor register for lwcN instructions, et al. * * Note that there is no load/store cp0 instructions, and * that FPU (cp1) instructions disassemble this field using * 'T' format. Therefore, until we gain understanding of * cp2 register names, we can simply print the register * numbers. */ fprintf (stream, "$%ld", (l >> OP_SH_RT) & OP_MASK_RT); break; case 'G': /* Coprocessor register for mtcN instructions, et al. Note * that FPU (cp1) instructions disassemble this field using * 'S' format. Therefore, we only need to worry about cp0, * cp2, and cp3. */ op = (l >> OP_SH_OP) & OP_MASK_OP; if (op == OP_OP_COP0) fprintf (stream, "%s", mips_cp0_names[(l >> OP_SH_RD) & OP_MASK_RD]); else fprintf (stream, "$%ld", (l >> OP_SH_RD) & OP_MASK_RD); break; case 'K': fprintf (stream, "%s", mips_hwr_names[(l >> OP_SH_RD) & OP_MASK_RD]); break; case 'N': fprintf (stream, ((opp->pinfo & (FP_D | FP_S)) != 0 ? "$fcc%ld" : "$cc%ld"), (l >> OP_SH_BCC) & OP_MASK_BCC); break; case 'M': fprintf (stream, "$fcc%ld", (l >> OP_SH_CCC) & OP_MASK_CCC); break; case 'P': fprintf (stream, "%ld", (l >> OP_SH_PERFREG) & OP_MASK_PERFREG); break; case 'e': fprintf (stream, "%ld", (l >> OP_SH_VECBYTE) & OP_MASK_VECBYTE); break; case '%': fprintf (stream, "%ld", (l >> OP_SH_VECALIGN) & OP_MASK_VECALIGN); break; case 'H': fprintf (stream, "%ld", (l >> OP_SH_SEL) & OP_MASK_SEL); break; case 'O': fprintf (stream, "%ld", (l >> OP_SH_ALN) & OP_MASK_ALN); break; case 'Q': { unsigned int vsel = (l >> OP_SH_VSEL) & OP_MASK_VSEL; if ((vsel & 0x10) == 0) { int fmt; vsel &= 0x0f; for (fmt = 0; fmt < 3; fmt++, vsel >>= 1) if ((vsel & 1) == 0) break; fprintf (stream, "$v%ld[%d]", (l >> OP_SH_FT) & OP_MASK_FT, vsel >> 1); } else if ((vsel & 0x08) == 0) { fprintf (stream, "$v%ld", (l >> OP_SH_FT) & OP_MASK_FT); } else { fprintf (stream, "0x%lx", (l >> OP_SH_FT) & OP_MASK_FT); } } break; case 'X': fprintf (stream, "$v%ld", (l >> OP_SH_FD) & OP_MASK_FD); break; case 'Y': fprintf (stream, "$v%ld", (l >> OP_SH_FS) & OP_MASK_FS); break; case 'Z': fprintf (stream, "$v%ld", (l >> OP_SH_FT) & OP_MASK_FT); break; default: /* xgettext:c-format */ fprintf (stream, "# internal error, undefined modifier (%c)\n", *d); return; } } } /* * Print the mips instruction at address MEMADDR. */ static void print_insn_mips (unsigned memaddr, unsigned long int word, FILE *stream) { const struct mips_opcode *op; static int init = 0; static const struct mips_opcode *mips_hash[OP_MASK_OP + 1]; /* Build a hash table to shorten the search time. */ if (! init) { unsigned int i; for (i = 0; i <= OP_MASK_OP; i++) { for (op = mips_opcodes; op < &mips_opcodes[mips_num_opcodes]; op++) { if (op->pinfo == INSN_MACRO || (no_aliases && (op->pinfo2 & INSN2_ALIAS))) continue; if (i == ((op->match >> OP_SH_OP) & OP_MASK_OP)) { mips_hash[i] = op; break; } } } init = 1; } target = 0; op = mips_hash[(word >> OP_SH_OP) & OP_MASK_OP]; if (op != NULL) { for (; op < &mips_opcodes[mips_num_opcodes]; op++) { if (op->pinfo != INSN_MACRO && !(no_aliases && (op->pinfo2 & INSN2_ALIAS)) && (word & op->mask) == op->match) { const char *d; fprintf (stream, "%s", op->name); d = op->args; if (d != NULL && *d != '\0') { fprintf (stream, "\t"); print_insn_args (d, word, memaddr, stream, op); } return; } } } /* Handle undefined instructions. */ fprintf (stream, "0x%lx", word); } /* * Disassemble an operand for a mips16 instruction. */ static void print_mips16_insn_arg (char type, const struct mips_opcode *op, int l, int use_extend, int extend, unsigned memaddr, FILE *stream) { switch (type) { case ',': case '(': case ')': fprintf (stream, "%c", type); break; case 'y': case 'w': fprintf (stream, "%s", mips16_reg_names (((l >> MIPS16OP_SH_RY) & MIPS16OP_MASK_RY))); break; case 'x': case 'v': fprintf (stream, "%s", mips16_reg_names (((l >> MIPS16OP_SH_RX) & MIPS16OP_MASK_RX))); break; case 'z': fprintf (stream, "%s", mips16_reg_names (((l >> MIPS16OP_SH_RZ) & MIPS16OP_MASK_RZ))); break; case 'Z': fprintf (stream, "%s", mips16_reg_names (((l >> MIPS16OP_SH_MOVE32Z) & MIPS16OP_MASK_MOVE32Z))); break; case '0': fprintf (stream, "%s", mips_gpr_names[0]); break; case 'S': fprintf (stream, "%s", mips_gpr_names[29]); break; case 'P': fprintf (stream, "$pc"); break; case 'R': fprintf (stream, "%s", mips_gpr_names[31]); break; case 'X': fprintf (stream, "%s", mips_gpr_names[((l >> MIPS16OP_SH_REGR32) & MIPS16OP_MASK_REGR32)]); break; case 'Y': fprintf (stream, "%s", mips_gpr_names[MIPS16OP_EXTRACT_REG32R (l)]); break; case '<': case '>': case '[': case ']': case '4': case '5': case 'H': case 'W': case 'D': case 'j': case '6': case '8': case 'V': case 'C': case 'U': case 'k': case 'K': case 'p': case 'q': case 'A': case 'B': case 'E': { int immed, nbits, shift, signedp, extbits, pcrel, extu, branch; shift = 0; signedp = 0; extbits = 16; pcrel = 0; extu = 0; branch = 0; switch (type) { case '<': nbits = 3; immed = (l >> MIPS16OP_SH_RZ) & MIPS16OP_MASK_RZ; extbits = 5; extu = 1; break; case '>': nbits = 3; immed = (l >> MIPS16OP_SH_RX) & MIPS16OP_MASK_RX; extbits = 5; extu = 1; break; case '[': nbits = 3; immed = (l >> MIPS16OP_SH_RZ) & MIPS16OP_MASK_RZ; extbits = 6; extu = 1; break; case ']': nbits = 3; immed = (l >> MIPS16OP_SH_RX) & MIPS16OP_MASK_RX; extbits = 6; extu = 1; break; case '4': nbits = 4; immed = (l >> MIPS16OP_SH_IMM4) & MIPS16OP_MASK_IMM4; signedp = 1; extbits = 15; break; case '5': nbits = 5; immed = (l >> MIPS16OP_SH_IMM5) & MIPS16OP_MASK_IMM5; break; case 'H': nbits = 5; shift = 1; immed = (l >> MIPS16OP_SH_IMM5) & MIPS16OP_MASK_IMM5; break; case 'W': nbits = 5; shift = 2; immed = (l >> MIPS16OP_SH_IMM5) & MIPS16OP_MASK_IMM5; break; case 'D': nbits = 5; shift = 3; immed = (l >> MIPS16OP_SH_IMM5) & MIPS16OP_MASK_IMM5; break; case 'j': nbits = 5; immed = (l >> MIPS16OP_SH_IMM5) & MIPS16OP_MASK_IMM5; signedp = 1; break; case '6': nbits = 6; immed = (l >> MIPS16OP_SH_IMM6) & MIPS16OP_MASK_IMM6; break; case '8': nbits = 8; immed = (l >> MIPS16OP_SH_IMM8) & MIPS16OP_MASK_IMM8; break; case 'V': nbits = 8; shift = 2; immed = (l >> MIPS16OP_SH_IMM8) & MIPS16OP_MASK_IMM8; /* FIXME: This might be lw, or it might be addiu to $sp or * $pc. We assume it's load. */ break; case 'C': nbits = 8; shift = 3; immed = (l >> MIPS16OP_SH_IMM8) & MIPS16OP_MASK_IMM8; break; case 'U': nbits = 8; immed = (l >> MIPS16OP_SH_IMM8) & MIPS16OP_MASK_IMM8; extu = 1; break; case 'k': nbits = 8; immed = (l >> MIPS16OP_SH_IMM8) & MIPS16OP_MASK_IMM8; signedp = 1; break; case 'K': nbits = 8; shift = 3; immed = (l >> MIPS16OP_SH_IMM8) & MIPS16OP_MASK_IMM8; signedp = 1; break; case 'p': nbits = 8; immed = (l >> MIPS16OP_SH_IMM8) & MIPS16OP_MASK_IMM8; signedp = 1; pcrel = 1; branch = 1; break; case 'q': nbits = 11; immed = (l >> MIPS16OP_SH_IMM11) & MIPS16OP_MASK_IMM11; signedp = 1; pcrel = 1; branch = 1; break; case 'A': nbits = 8; shift = 2; immed = (l >> MIPS16OP_SH_IMM8) & MIPS16OP_MASK_IMM8; pcrel = 1; /* FIXME: This can be lw or la. We assume it is lw. */ break; case 'B': nbits = 5; shift = 3; immed = (l >> MIPS16OP_SH_IMM5) & MIPS16OP_MASK_IMM5; pcrel = 1; break; case 'E': nbits = 5; shift = 2; immed = (l >> MIPS16OP_SH_IMM5) & MIPS16OP_MASK_IMM5; pcrel = 1; break; default: fprintf (stream, "# internal disassembler error, unrecognised mips16 type (%c)", type); abort (); } if (!use_extend) { if (signedp && immed >= (1 << (nbits - 1))) immed -= 1 << nbits; immed <<= shift; if ((type == '<' || type == '>' || type == '[' || type == ']') && immed == 0) immed = 8; } else { if (extbits == 16) immed |= ((extend & 0x1f) << 11) | (extend & 0x7e0); else if (extbits == 15) immed |= ((extend & 0xf) << 11) | (extend & 0x7f0); else immed = ((extend >> 6) & 0x1f) | (extend & 0x20); immed &= (1 << extbits) - 1; if (!extu && immed >= (1 << (extbits - 1))) immed -= 1 << extbits; } if (!pcrel) fprintf (stream, "%d", immed); else { unsigned baseaddr; if (branch) { immed *= 2; baseaddr = memaddr + 2; } else if (use_extend) { baseaddr = memaddr - 2; } else { baseaddr = memaddr; } target = (baseaddr & ~((1 << shift) - 1)) + immed; if (pcrel && branch) /* For gdb disassembler, maintain odd address. */ target |= 1; print_address (target, stream); } } break; case 'a': { int jalx = l & 0x400; if (!use_extend) extend = 0; l = ((l & 0x1f) << 23) | ((l & 0x3e0) << 13) | (extend << 2); if (! jalx) /* For gdb disassembler, maintain odd address. */ l |= 1; } target = ((memaddr + 4) & ~(unsigned) 0x0fffffff) | l; print_address (target, stream); break; case 'l': case 'L': { int need_comma, amask, smask; need_comma = 0; l = (l >> MIPS16OP_SH_IMM6) & MIPS16OP_MASK_IMM6; amask = (l >> 3) & 7; if (amask > 0 && amask < 5) { fprintf (stream, "%s", mips_gpr_names[4]); if (amask > 1) fprintf (stream, "-%s", mips_gpr_names[amask + 3]); need_comma = 1; } smask = (l >> 1) & 3; if (smask == 3) { fprintf (stream, "%s??", need_comma ? "," : ""); need_comma = 1; } else if (smask > 0) { fprintf (stream, "%s%s", need_comma ? "," : "", mips_gpr_names[16]); if (smask > 1) fprintf (stream, "-%s", mips_gpr_names[smask + 15]); need_comma = 1; } if (l & 1) { fprintf (stream, "%s%s", need_comma ? "," : "", mips_gpr_names[31]); need_comma = 1; } if (amask == 5 || amask == 6) { fprintf (stream, "%s$f0", need_comma ? "," : ""); if (amask == 6) fprintf (stream, "-$f1"); } } break; case 'm': case 'M': /* MIPS16e save/restore. */ { int need_comma = 0; int amask, args, statics; int nsreg, smask; int framesz; int i, j; l = l & 0x7f; if (use_extend) l |= extend << 16; amask = (l >> 16) & 0xf; if (amask == MIPS16_ALL_ARGS) { args = 4; statics = 0; } else if (amask == MIPS16_ALL_STATICS) { args = 0; statics = 4; } else { args = amask >> 2; statics = amask & 3; } if (args > 0) { fprintf (stream, "%s", mips_gpr_names[4]); if (args > 1) fprintf (stream, "-%s", mips_gpr_names[4 + args - 1]); need_comma = 1; } framesz = (((l >> 16) & 0xf0) | (l & 0x0f)) * 8; if (framesz == 0 && !use_extend) framesz = 128; fprintf (stream, "%s%d", need_comma ? "," : "", framesz); if (l & 0x40) /* $ra */ fprintf (stream, ",%s", mips_gpr_names[31]); nsreg = (l >> 24) & 0x7; smask = 0; if (l & 0x20) /* $s0 */ smask |= 1 << 0; if (l & 0x10) /* $s1 */ smask |= 1 << 1; if (nsreg > 0) /* $s2-$s8 */ smask |= ((1 << nsreg) - 1) << 2; /* Find first set static reg bit. */ for (i = 0; i < 9; i++) { if (smask & (1 << i)) { fprintf (stream, ",%s", mips_gpr_names[i == 8 ? 30 : (16 + i)]); /* Skip over string of set bits. */ for (j = i; smask & (2 << j); j++) continue; if (j > i) fprintf (stream, "-%s", mips_gpr_names[j == 8 ? 30 : (16 + j)]); i = j + 1; } } /* Statics $ax - $a3. */ if (statics == 1) fprintf (stream, ",%s", mips_gpr_names[7]); else if (statics > 0) fprintf (stream, ",%s-%s", mips_gpr_names[7 - statics + 1], mips_gpr_names[7]); } break; default: /* xgettext:c-format */ fprintf (stream, "# internal disassembler error, unrecognised modifier (%c)\n", type); abort (); } } /* * Disassemble mips16 instructions. */ static void print_insn_mips16 (unsigned memaddr, unsigned int opcode, int nbytes, FILE *stream) { int insn, use_extend, extend; const struct mips_opcode *op, *opend; insn = opcode; if (nbytes == 2) { use_extend = 0; extend = 0; insn = opcode; } else { if ((opcode & 0xf8000000) == 0xf0000000) { /* Handle the extend opcode specially. */ use_extend = 1; insn = opcode & 0xffff; extend = (opcode >> 16) & 0x7ff; } else { /* jal, jalx */ use_extend = 0; insn = opcode >> 16; extend = opcode & 0xffff; } } /* FIXME: Should probably use a hash table on the major opcode here. */ opend = mips16_opcodes + mips16_num_opcodes; for (op = mips16_opcodes; op < opend; op++) { if (op->pinfo != INSN_MACRO && (insn & op->mask) == op->match) { const char *s; fprintf (stream, "%s", op->name); if (op->args[0] != '\0') fprintf (stream, "\t"); for (s = op->args; *s != '\0'; s++) { if (*s == ',' && s[1] == 'w' && (((insn >> MIPS16OP_SH_RX) & MIPS16OP_MASK_RX) == ((insn >> MIPS16OP_SH_RY) & MIPS16OP_MASK_RY))) { /* Skip the register and the comma. */ ++s; continue; } if (*s == ',' && s[1] == 'v' && (((insn >> MIPS16OP_SH_RZ) & MIPS16OP_MASK_RZ) == ((insn >> MIPS16OP_SH_RX) & MIPS16OP_MASK_RX))) { /* Skip the register and the comma. */ ++s; continue; } print_mips16_insn_arg (*s, op, insn, use_extend, extend, memaddr, stream); } return; } } fprintf (stream, "0x"); if (use_extend) fprintf (stream, "%04x", extend | 0xf000); fprintf (stream, "%04x", insn); } /* * Disassemble and print the instruction mnemonics. * Opcode size can be 4 or 2 bytes. * Parameter `isa' defines an instruction set architecture: * 0 - mips32 encoding * 1 - mips16e encoding * 2 - micromips encoding (someday) */ void print_mips (unsigned memaddr, unsigned int opcode, int nbytes, int isa, FILE *stream) { switch (isa) { default: case 0: print_insn_mips (memaddr, opcode, stream); break; case 1: print_insn_mips16 (memaddr, opcode, nbytes, stream); break; case 2: /* TODO: micromips encoding */ break; } } ================================================ FILE: tools/virtualmips/mips-opc.c ================================================ /* * MIPS opcode list. * * Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002 * 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. * Contributed by Ralph Campbell and OSF * Commented and modified by Ian Lance Taylor, Cygnus Support * Extended for MIPS32 support by Anders Norlander, and by SiByte, Inc. * MIPS-3D, MDMX, and MIPS32 Release 2 support added by Broadcom * Corporation (SiByte). * Adapted for VirtualMIPS by Serge Vakulenko. * * This file is part of the virtualmips distribution. * See LICENSE file for terms of the license. */ /* Short hand so the lines aren't too long. */ #define LDD INSN_LOAD_MEMORY_DELAY #define LCD INSN_LOAD_COPROC_DELAY #define UBD INSN_UNCOND_BRANCH_DELAY #define CBD INSN_COND_BRANCH_DELAY #define COD INSN_COPROC_MOVE_DELAY #define CLD INSN_COPROC_MEMORY_DELAY #define CBL INSN_COND_BRANCH_LIKELY #define TRAP INSN_TRAP #define SM INSN_STORE_MEMORY #define WR_d INSN_WRITE_GPR_D #define WR_t INSN_WRITE_GPR_T #define WR_31 INSN_WRITE_GPR_31 #define WR_D INSN_WRITE_FPR_D #define WR_T INSN_WRITE_FPR_T #define WR_S INSN_WRITE_FPR_S #define RD_s INSN_READ_GPR_S #define RD_b INSN_READ_GPR_S #define RD_t INSN_READ_GPR_T #define RD_S INSN_READ_FPR_S #define RD_T INSN_READ_FPR_T #define RD_R INSN_READ_FPR_R #define WR_CC INSN_WRITE_COND_CODE #define RD_CC INSN_READ_COND_CODE #define RD_C0 INSN_COP #define RD_C1 INSN_COP #define RD_C2 INSN_COP #define RD_C3 INSN_COP #define WR_C0 INSN_COP #define WR_C1 INSN_COP #define WR_C2 INSN_COP #define WR_C3 INSN_COP #define CP INSN_COP #define WR_HI INSN_WRITE_HI #define RD_HI INSN_READ_HI #define MOD_HI WR_HI|RD_HI #define WR_LO INSN_WRITE_LO #define RD_LO INSN_READ_LO #define MOD_LO WR_LO|RD_LO #define WR_HILO WR_HI|WR_LO #define RD_HILO RD_HI|RD_LO #define MOD_HILO WR_HILO|RD_HILO #define IS_M INSN_MULT #define WR_MACC INSN2_WRITE_MDMX_ACC #define RD_MACC INSN2_READ_MDMX_ACC /* MIPS DSP ASE support. NOTE: 1. MIPS DSP ASE includes 4 accumulators ($ac0 - $ac3). $ac0 is the pair of original HI and LO. $ac1, $ac2 and $ac3 are new registers, and have the same structure as $ac0 (HI + LO). For DSP instructions that write or read accumulators (that may be $ac0), we add WR_a (WR_HILO) or RD_a (RD_HILO) attributes, such that HILO dependencies are maintained conservatively. 2. For some mul. instructions that use integer registers as destinations but destroy HI+LO as side-effect, we add WR_HILO to their attributes. 3. MIPS DSP ASE includes a new DSP control register, which has 6 fields (ccond, outflag, EFI, c, scount, pos). Many DSP instructions read or write certain fields of the DSP control register. For simplicity, we decide not to track dependencies of these fields. However, "bposge32" is a branch instruction that depends on the "pos" field. In order to make sure that GAS does not reorder DSP instructions that writes the "pos" field and "bposge32", we add DSP_VOLA (INSN_TRAP) attribute to those instructions that write the "pos" field. */ #define WR_a WR_HILO /* Write dsp accumulators (reuse WR_HILO) */ #define RD_a RD_HILO /* Read dsp accumulators (reuse RD_HILO) */ #define MOD_a WR_a|RD_a #define DSP_VOLA INSN_TRAP /* The order of overloaded instructions matters. Label arguments and register arguments look the same. Instructions that can have either for arguments must apear in the correct order in this table for the assembler to pick the right one. In other words, entries with immediate operands must apear after the same instruction with registers. Because of the lookup algorithm used, entries with the same opcode name must be contiguous. Many instructions are short hand for other instructions (i.e., The jal instruction is short for jalr ). */ static const struct mips_opcode mips_opcodes[] = { /* These instructions appear first so that the disassembler will find them first. The assemblers uses a hash table based on the instruction name anyhow. */ /* name, args, match, mask, pinfo, pinfo2 */ {"pref", "k,o(b)", 0xcc000000, 0xfc000000, RD_b, }, {"prefx", "h,t(b)", 0x4c00000f, 0xfc0007ff, RD_b|RD_t|FP_S, }, {"nop", "", 0x00000000, 0xffffffff, 0, INSN2_ALIAS, }, /* sll */ {"ssnop", "", 0x00000040, 0xffffffff, 0, INSN2_ALIAS, }, /* sll */ {"ehb", "", 0x000000c0, 0xffffffff, 0, INSN2_ALIAS, }, /* sll */ {"li", "t,j", 0x24000000, 0xffe00000, WR_t, INSN2_ALIAS, }, /* addiu */ {"li", "t,i", 0x34000000, 0xffe00000, WR_t, INSN2_ALIAS, }, /* ori */ {"li", "t,I", 0, (int) M_LI, INSN_MACRO, }, {"move", "d,s", 0, (int) M_MOVE, INSN_MACRO, }, {"move", "d,s", 0x0000002d, 0xfc1f07ff, WR_d|RD_s, INSN2_ALIAS, },/* daddu */ {"move", "d,s", 0x00000021, 0xfc1f07ff, WR_d|RD_s, INSN2_ALIAS, },/* addu */ {"move", "d,s", 0x00000025, 0xfc1f07ff, WR_d|RD_s, INSN2_ALIAS, },/* or */ {"b", "p", 0x10000000, 0xffff0000, UBD, INSN2_ALIAS, },/* beq 0,0 */ {"b", "p", 0x04010000, 0xffff0000, UBD, INSN2_ALIAS, },/* bgez 0 */ {"bal", "p", 0x04110000, 0xffff0000, UBD|WR_31, INSN2_ALIAS, },/* bgezal 0*/ {"abs", "d,v", 0, (int) M_ABS, INSN_MACRO, }, {"abs.s", "D,V", 0x46000005, 0xffff003f, WR_D|RD_S|FP_S, }, {"abs.d", "D,V", 0x46200005, 0xffff003f, WR_D|RD_S|FP_D, }, {"abs.ps", "D,V", 0x46c00005, 0xffff003f, WR_D|RD_S|FP_D, }, {"abs.ps", "D,V", 0x45600005, 0xffff003f, WR_D|RD_S|FP_D, }, {"add", "d,v,t", 0x00000020, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"add", "t,r,I", 0, (int) M_ADD_I, INSN_MACRO, }, {"add", "D,S,T", 0x45c00000, 0xffe0003f, RD_S|RD_T|WR_D|FP_S, }, {"add", "D,S,T", 0x4b40000c, 0xffe0003f, RD_S|RD_T|WR_D|FP_S, }, {"add.s", "D,V,T", 0x46000000, 0xffe0003f, WR_D|RD_S|RD_T|FP_S, }, {"add.d", "D,V,T", 0x46200000, 0xffe0003f, WR_D|RD_S|RD_T|FP_D, }, {"add.ob", "X,Y,Q", 0x7800000b, 0xfc20003f, WR_D|RD_S|RD_T|FP_D, }, {"add.ob", "D,S,T", 0x4ac0000b, 0xffe0003f, WR_D|RD_S|RD_T, }, {"add.ob", "D,S,T[e]", 0x4800000b, 0xfe20003f, WR_D|RD_S|RD_T, }, {"add.ob", "D,S,k", 0x4bc0000b, 0xffe0003f, WR_D|RD_S|RD_T, }, {"add.ps", "D,V,T", 0x46c00000, 0xffe0003f, WR_D|RD_S|RD_T|FP_D, }, {"add.ps", "D,V,T", 0x45600000, 0xffe0003f, WR_D|RD_S|RD_T|FP_D, }, {"add.qh", "X,Y,Q", 0x7820000b, 0xfc20003f, WR_D|RD_S|RD_T|FP_D, }, {"adda.ob", "Y,Q", 0x78000037, 0xfc2007ff, RD_S|RD_T|FP_D, WR_MACC, }, {"adda.qh", "Y,Q", 0x78200037, 0xfc2007ff, RD_S|RD_T|FP_D, WR_MACC, }, {"addi", "t,r,j", 0x20000000, 0xfc000000, WR_t|RD_s, }, {"addiu", "t,r,j", 0x24000000, 0xfc000000, WR_t|RD_s, }, {"addl.ob", "Y,Q", 0x78000437, 0xfc2007ff, RD_S|RD_T|FP_D, WR_MACC, }, {"addl.qh", "Y,Q", 0x78200437, 0xfc2007ff, RD_S|RD_T|FP_D, WR_MACC, }, {"addr.ps", "D,S,T", 0x46c00018, 0xffe0003f, WR_D|RD_S|RD_T|FP_D, }, {"addu", "d,v,t", 0x00000021, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"addu", "t,r,I", 0, (int) M_ADDU_I, INSN_MACRO, }, {"addu", "D,S,T", 0x45800000, 0xffe0003f, RD_S|RD_T|WR_D|FP_S, }, {"addu", "D,S,T", 0x4b00000c, 0xffe0003f, RD_S|RD_T|WR_D|FP_S, }, {"alni.ob", "X,Y,Z,O", 0x78000018, 0xff00003f, WR_D|RD_S|RD_T|FP_D, }, {"alni.ob", "D,S,T,%", 0x48000018, 0xff00003f, WR_D|RD_S|RD_T, }, {"alni.qh", "X,Y,Z,O", 0x7800001a, 0xff00003f, WR_D|RD_S|RD_T|FP_D, }, {"alnv.ps", "D,V,T,s", 0x4c00001e, 0xfc00003f, WR_D|RD_S|RD_T|FP_D, }, {"alnv.ob", "X,Y,Z,s", 0x78000019, 0xfc00003f, WR_D|RD_S|RD_T|RD_s|FP_D, }, {"alnv.qh", "X,Y,Z,s", 0x7800001b, 0xfc00003f, WR_D|RD_S|RD_T|RD_s|FP_D, }, {"and", "d,v,t", 0x00000024, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"and", "t,r,I", 0, (int) M_AND_I, INSN_MACRO, }, {"and", "D,S,T", 0x47c00002, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"and", "D,S,T", 0x4bc00002, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"and.ob", "X,Y,Q", 0x7800000c, 0xfc20003f, WR_D|RD_S|RD_T|FP_D, }, {"and.ob", "D,S,T", 0x4ac0000c, 0xffe0003f, WR_D|RD_S|RD_T, }, {"and.ob", "D,S,T[e]", 0x4800000c, 0xfe20003f, WR_D|RD_S|RD_T, }, {"and.ob", "D,S,k", 0x4bc0000c, 0xffe0003f, WR_D|RD_S|RD_T, }, {"and.qh", "X,Y,Q", 0x7820000c, 0xfc20003f, WR_D|RD_S|RD_T|FP_D, }, {"andi", "t,r,i", 0x30000000, 0xfc000000, WR_t|RD_s, }, {"baddu", "d,v,t", 0x70000028, 0xfc0007ff, WR_d|RD_s|RD_t, }, /* b is at the top of the table. */ /* bal is at the top of the table. */ {"bbit032", "s,+x,p", 0xd8000000, 0xfc000000, RD_s|CBD, }, {"bbit0", "s,+X,p", 0xd8000000, 0xfc000000, RD_s|CBD, }, /* bbit032 */ {"bbit0", "s,+x,p", 0xc8000000, 0xfc000000, RD_s|CBD, }, {"bbit132", "s,+x,p", 0xf8000000, 0xfc000000, RD_s|CBD, }, {"bbit1", "s,+X,p", 0xf8000000, 0xfc000000, RD_s|CBD, }, /* bbit132 */ {"bbit1", "s,+x,p", 0xe8000000, 0xfc000000, RD_s|CBD, }, /* bc0[tf]l? are at the bottom of the table. */ {"bc1any2f", "N,p", 0x45200000, 0xffe30000, CBD|RD_CC|FP_S, }, {"bc1any2t", "N,p", 0x45210000, 0xffe30000, CBD|RD_CC|FP_S, }, {"bc1any4f", "N,p", 0x45400000, 0xffe30000, CBD|RD_CC|FP_S, }, {"bc1any4t", "N,p", 0x45410000, 0xffe30000, CBD|RD_CC|FP_S, }, {"bc1f", "p", 0x45000000, 0xffff0000, CBD|RD_CC|FP_S, }, {"bc1f", "N,p", 0x45000000, 0xffe30000, CBD|RD_CC|FP_S, }, {"bc1fl", "p", 0x45020000, 0xffff0000, CBL|RD_CC|FP_S, }, {"bc1fl", "N,p", 0x45020000, 0xffe30000, CBL|RD_CC|FP_S, }, {"bc1t", "p", 0x45010000, 0xffff0000, CBD|RD_CC|FP_S, }, {"bc1t", "N,p", 0x45010000, 0xffe30000, CBD|RD_CC|FP_S, }, {"bc1tl", "p", 0x45030000, 0xffff0000, CBL|RD_CC|FP_S, }, {"bc1tl", "N,p", 0x45030000, 0xffe30000, CBL|RD_CC|FP_S, }, /* bc2* are at the bottom of the table. */ /* bc3* are at the bottom of the table. */ {"beqz", "s,p", 0x10000000, 0xfc1f0000, CBD|RD_s, }, {"beqzl", "s,p", 0x50000000, 0xfc1f0000, CBL|RD_s, }, {"beq", "s,t,p", 0x10000000, 0xfc000000, CBD|RD_s|RD_t, }, {"beq", "s,I,p", 0, (int) M_BEQ_I, INSN_MACRO, }, {"beql", "s,t,p", 0x50000000, 0xfc000000, CBL|RD_s|RD_t, }, {"beql", "s,I,p", 0, (int) M_BEQL_I, INSN_MACRO, }, {"bge", "s,t,p", 0, (int) M_BGE, INSN_MACRO, }, {"bge", "s,I,p", 0, (int) M_BGE_I, INSN_MACRO, }, {"bgel", "s,t,p", 0, (int) M_BGEL, INSN_MACRO, }, {"bgel", "s,I,p", 0, (int) M_BGEL_I, INSN_MACRO, }, {"bgeu", "s,t,p", 0, (int) M_BGEU, INSN_MACRO, }, {"bgeu", "s,I,p", 0, (int) M_BGEU_I, INSN_MACRO, }, {"bgeul", "s,t,p", 0, (int) M_BGEUL, INSN_MACRO, }, {"bgeul", "s,I,p", 0, (int) M_BGEUL_I, INSN_MACRO, }, {"bgez", "s,p", 0x04010000, 0xfc1f0000, CBD|RD_s, }, {"bgezl", "s,p", 0x04030000, 0xfc1f0000, CBL|RD_s, }, {"bgezal", "s,p", 0x04110000, 0xfc1f0000, CBD|RD_s|WR_31, }, {"bgezall", "s,p", 0x04130000, 0xfc1f0000, CBL|RD_s|WR_31, }, {"bgt", "s,t,p", 0, (int) M_BGT, INSN_MACRO, }, {"bgt", "s,I,p", 0, (int) M_BGT_I, INSN_MACRO, }, {"bgtl", "s,t,p", 0, (int) M_BGTL, INSN_MACRO, }, {"bgtl", "s,I,p", 0, (int) M_BGTL_I, INSN_MACRO, }, {"bgtu", "s,t,p", 0, (int) M_BGTU, INSN_MACRO, }, {"bgtu", "s,I,p", 0, (int) M_BGTU_I, INSN_MACRO, }, {"bgtul", "s,t,p", 0, (int) M_BGTUL, INSN_MACRO, }, {"bgtul", "s,I,p", 0, (int) M_BGTUL_I, INSN_MACRO, }, {"bgtz", "s,p", 0x1c000000, 0xfc1f0000, CBD|RD_s, }, {"bgtzl", "s,p", 0x5c000000, 0xfc1f0000, CBL|RD_s, }, {"ble", "s,t,p", 0, (int) M_BLE, INSN_MACRO, }, {"ble", "s,I,p", 0, (int) M_BLE_I, INSN_MACRO, }, {"blel", "s,t,p", 0, (int) M_BLEL, INSN_MACRO, }, {"blel", "s,I,p", 0, (int) M_BLEL_I, INSN_MACRO, }, {"bleu", "s,t,p", 0, (int) M_BLEU, INSN_MACRO, }, {"bleu", "s,I,p", 0, (int) M_BLEU_I, INSN_MACRO, }, {"bleul", "s,t,p", 0, (int) M_BLEUL, INSN_MACRO, }, {"bleul", "s,I,p", 0, (int) M_BLEUL_I, INSN_MACRO, }, {"blez", "s,p", 0x18000000, 0xfc1f0000, CBD|RD_s, }, {"blezl", "s,p", 0x58000000, 0xfc1f0000, CBL|RD_s, }, {"blt", "s,t,p", 0, (int) M_BLT, INSN_MACRO, }, {"blt", "s,I,p", 0, (int) M_BLT_I, INSN_MACRO, }, {"bltl", "s,t,p", 0, (int) M_BLTL, INSN_MACRO, }, {"bltl", "s,I,p", 0, (int) M_BLTL_I, INSN_MACRO, }, {"bltu", "s,t,p", 0, (int) M_BLTU, INSN_MACRO, }, {"bltu", "s,I,p", 0, (int) M_BLTU_I, INSN_MACRO, }, {"bltul", "s,t,p", 0, (int) M_BLTUL, INSN_MACRO, }, {"bltul", "s,I,p", 0, (int) M_BLTUL_I, INSN_MACRO, }, {"bltz", "s,p", 0x04000000, 0xfc1f0000, CBD|RD_s, }, {"bltzl", "s,p", 0x04020000, 0xfc1f0000, CBL|RD_s, }, {"bltzal", "s,p", 0x04100000, 0xfc1f0000, CBD|RD_s|WR_31, }, {"bltzall", "s,p", 0x04120000, 0xfc1f0000, CBL|RD_s|WR_31, }, {"bnez", "s,p", 0x14000000, 0xfc1f0000, CBD|RD_s, }, {"bnezl", "s,p", 0x54000000, 0xfc1f0000, CBL|RD_s, }, {"bne", "s,t,p", 0x14000000, 0xfc000000, CBD|RD_s|RD_t, }, {"bne", "s,I,p", 0, (int) M_BNE_I, INSN_MACRO, }, {"bnel", "s,t,p", 0x54000000, 0xfc000000, CBL|RD_s|RD_t, }, {"bnel", "s,I,p", 0, (int) M_BNEL_I, INSN_MACRO, }, {"break", "", 0x0000000d, 0xffffffff, TRAP, }, {"break", "c", 0x0000000d, 0xfc00ffff, TRAP, }, {"break", "c,q", 0x0000000d, 0xfc00003f, TRAP, }, {"c.f.d", "S,T", 0x46200030, 0xffe007ff, RD_S|RD_T|WR_CC|FP_D, }, {"c.f.d", "M,S,T", 0x46200030, 0xffe000ff, RD_S|RD_T|WR_CC|FP_D, }, {"c.f.s", "S,T", 0x46000030, 0xffe007ff, RD_S|RD_T|WR_CC|FP_S, }, {"c.f.s", "M,S,T", 0x46000030, 0xffe000ff, RD_S|RD_T|WR_CC|FP_S, }, {"c.f.ps", "S,T", 0x46c00030, 0xffe007ff, RD_S|RD_T|WR_CC|FP_D, }, {"c.f.ps", "S,T", 0x45600030, 0xffe007ff, RD_S|RD_T|WR_CC|FP_D, }, {"c.f.ps", "M,S,T", 0x46c00030, 0xffe000ff, RD_S|RD_T|WR_CC|FP_D, }, {"c.un.d", "S,T", 0x46200031, 0xffe007ff, RD_S|RD_T|WR_CC|FP_D, }, {"c.un.d", "M,S,T", 0x46200031, 0xffe000ff, RD_S|RD_T|WR_CC|FP_D, }, {"c.un.s", "S,T", 0x46000031, 0xffe007ff, RD_S|RD_T|WR_CC|FP_S, }, {"c.un.s", "M,S,T", 0x46000031, 0xffe000ff, RD_S|RD_T|WR_CC|FP_S, }, {"c.un.ps", "S,T", 0x46c00031, 0xffe007ff, RD_S|RD_T|WR_CC|FP_D, }, {"c.un.ps", "S,T", 0x45600031, 0xffe007ff, RD_S|RD_T|WR_CC|FP_D, }, {"c.un.ps", "M,S,T", 0x46c00031, 0xffe000ff, RD_S|RD_T|WR_CC|FP_D, }, {"c.eq.d", "S,T", 0x46200032, 0xffe007ff, RD_S|RD_T|WR_CC|FP_D, }, {"c.eq.d", "M,S,T", 0x46200032, 0xffe000ff, RD_S|RD_T|WR_CC|FP_D, }, {"c.eq.s", "S,T", 0x46000032, 0xffe007ff, RD_S|RD_T|WR_CC|FP_S, }, {"c.eq.s", "M,S,T", 0x46000032, 0xffe000ff, RD_S|RD_T|WR_CC|FP_S, }, {"c.eq.ob", "Y,Q", 0x78000001, 0xfc2007ff, WR_CC|RD_S|RD_T|FP_D, }, {"c.eq.ob", "S,T", 0x4ac00001, 0xffe007ff, WR_CC|RD_S|RD_T, }, {"c.eq.ob", "S,T[e]", 0x48000001, 0xfe2007ff, WR_CC|RD_S|RD_T, }, {"c.eq.ob", "S,k", 0x4bc00001, 0xffe007ff, WR_CC|RD_S|RD_T, }, {"c.eq.ps", "S,T", 0x46c00032, 0xffe007ff, RD_S|RD_T|WR_CC|FP_D, }, {"c.eq.ps", "S,T", 0x45600032, 0xffe007ff, RD_S|RD_T|WR_CC|FP_D, }, {"c.eq.ps", "M,S,T", 0x46c00032, 0xffe000ff, RD_S|RD_T|WR_CC|FP_D, }, {"c.eq.qh", "Y,Q", 0x78200001, 0xfc2007ff, WR_CC|RD_S|RD_T|FP_D, }, {"c.ueq.d", "S,T", 0x46200033, 0xffe007ff, RD_S|RD_T|WR_CC|FP_D, }, {"c.ueq.d", "M,S,T", 0x46200033, 0xffe000ff, RD_S|RD_T|WR_CC|FP_D, }, {"c.ueq.s", "S,T", 0x46000033, 0xffe007ff, RD_S|RD_T|WR_CC|FP_S, }, {"c.ueq.s", "M,S,T", 0x46000033, 0xffe000ff, RD_S|RD_T|WR_CC|FP_S, }, {"c.ueq.ps","S,T", 0x46c00033, 0xffe007ff, RD_S|RD_T|WR_CC|FP_D, }, {"c.ueq.ps","S,T", 0x45600033, 0xffe007ff, RD_S|RD_T|WR_CC|FP_D, }, {"c.ueq.ps","M,S,T", 0x46c00033, 0xffe000ff, RD_S|RD_T|WR_CC|FP_D, }, {"c.olt.d", "S,T", 0x46200034, 0xffe007ff, RD_S|RD_T|WR_CC|FP_D, }, {"c.olt.d", "M,S,T", 0x46200034, 0xffe000ff, RD_S|RD_T|WR_CC|FP_D, }, {"c.olt.s", "S,T", 0x46000034, 0xffe007ff, RD_S|RD_T|WR_CC|FP_S, }, {"c.olt.s", "M,S,T", 0x46000034, 0xffe000ff, RD_S|RD_T|WR_CC|FP_S, }, {"c.olt.ps","S,T", 0x46c00034, 0xffe007ff, RD_S|RD_T|WR_CC|FP_D, }, {"c.olt.ps","S,T", 0x45600034, 0xffe007ff, RD_S|RD_T|WR_CC|FP_D, }, {"c.olt.ps","M,S,T", 0x46c00034, 0xffe000ff, RD_S|RD_T|WR_CC|FP_D, }, {"c.ult.d", "S,T", 0x46200035, 0xffe007ff, RD_S|RD_T|WR_CC|FP_D, }, {"c.ult.d", "M,S,T", 0x46200035, 0xffe000ff, RD_S|RD_T|WR_CC|FP_D, }, {"c.ult.s", "S,T", 0x46000035, 0xffe007ff, RD_S|RD_T|WR_CC|FP_S, }, {"c.ult.s", "M,S,T", 0x46000035, 0xffe000ff, RD_S|RD_T|WR_CC|FP_S, }, {"c.ult.ps","S,T", 0x46c00035, 0xffe007ff, RD_S|RD_T|WR_CC|FP_D, }, {"c.ult.ps","S,T", 0x45600035, 0xffe007ff, RD_S|RD_T|WR_CC|FP_D, }, {"c.ult.ps","M,S,T", 0x46c00035, 0xffe000ff, RD_S|RD_T|WR_CC|FP_D, }, {"c.ole.d", "S,T", 0x46200036, 0xffe007ff, RD_S|RD_T|WR_CC|FP_D, }, {"c.ole.d", "M,S,T", 0x46200036, 0xffe000ff, RD_S|RD_T|WR_CC|FP_D, }, {"c.ole.s", "S,T", 0x46000036, 0xffe007ff, RD_S|RD_T|WR_CC|FP_S, }, {"c.ole.s", "M,S,T", 0x46000036, 0xffe000ff, RD_S|RD_T|WR_CC|FP_S, }, {"c.ole.ps","S,T", 0x46c00036, 0xffe007ff, RD_S|RD_T|WR_CC|FP_D, }, {"c.ole.ps","S,T", 0x45600036, 0xffe007ff, RD_S|RD_T|WR_CC|FP_D, }, {"c.ole.ps","M,S,T", 0x46c00036, 0xffe000ff, RD_S|RD_T|WR_CC|FP_D, }, {"c.ule.d", "S,T", 0x46200037, 0xffe007ff, RD_S|RD_T|WR_CC|FP_D, }, {"c.ule.d", "M,S,T", 0x46200037, 0xffe000ff, RD_S|RD_T|WR_CC|FP_D, }, {"c.ule.s", "S,T", 0x46000037, 0xffe007ff, RD_S|RD_T|WR_CC|FP_S, }, {"c.ule.s", "M,S,T", 0x46000037, 0xffe000ff, RD_S|RD_T|WR_CC|FP_S, }, {"c.ule.ps","S,T", 0x46c00037, 0xffe007ff, RD_S|RD_T|WR_CC|FP_D, }, {"c.ule.ps","S,T", 0x45600037, 0xffe007ff, RD_S|RD_T|WR_CC|FP_D, }, {"c.ule.ps","M,S,T", 0x46c00037, 0xffe000ff, RD_S|RD_T|WR_CC|FP_D, }, {"c.sf.d", "S,T", 0x46200038, 0xffe007ff, RD_S|RD_T|WR_CC|FP_D, }, {"c.sf.d", "M,S,T", 0x46200038, 0xffe000ff, RD_S|RD_T|WR_CC|FP_D, }, {"c.sf.s", "S,T", 0x46000038, 0xffe007ff, RD_S|RD_T|WR_CC|FP_S, }, {"c.sf.s", "M,S,T", 0x46000038, 0xffe000ff, RD_S|RD_T|WR_CC|FP_S, }, {"c.sf.ps", "S,T", 0x46c00038, 0xffe007ff, RD_S|RD_T|WR_CC|FP_D, }, {"c.sf.ps", "S,T", 0x45600038, 0xffe007ff, RD_S|RD_T|WR_CC|FP_D, }, {"c.sf.ps", "M,S,T", 0x46c00038, 0xffe000ff, RD_S|RD_T|WR_CC|FP_D, }, {"c.ngle.d","S,T", 0x46200039, 0xffe007ff, RD_S|RD_T|WR_CC|FP_D, }, {"c.ngle.d","M,S,T", 0x46200039, 0xffe000ff, RD_S|RD_T|WR_CC|FP_D, }, {"c.ngle.s","S,T", 0x46000039, 0xffe007ff, RD_S|RD_T|WR_CC|FP_S, }, {"c.ngle.s","M,S,T", 0x46000039, 0xffe000ff, RD_S|RD_T|WR_CC|FP_S, }, {"c.ngle.ps","S,T", 0x46c00039, 0xffe007ff, RD_S|RD_T|WR_CC|FP_D, }, {"c.ngle.ps","S,T", 0x45600039, 0xffe007ff, RD_S|RD_T|WR_CC|FP_D, }, {"c.ngle.ps","M,S,T", 0x46c00039, 0xffe000ff, RD_S|RD_T|WR_CC|FP_D, }, {"c.seq.d", "S,T", 0x4620003a, 0xffe007ff, RD_S|RD_T|WR_CC|FP_D, }, {"c.seq.d", "M,S,T", 0x4620003a, 0xffe000ff, RD_S|RD_T|WR_CC|FP_D, }, {"c.seq.s", "S,T", 0x4600003a, 0xffe007ff, RD_S|RD_T|WR_CC|FP_S, }, {"c.seq.s", "M,S,T", 0x4600003a, 0xffe000ff, RD_S|RD_T|WR_CC|FP_S, }, {"c.seq.ps","S,T", 0x46c0003a, 0xffe007ff, RD_S|RD_T|WR_CC|FP_D, }, {"c.seq.ps","S,T", 0x4560003a, 0xffe007ff, RD_S|RD_T|WR_CC|FP_D, }, {"c.seq.ps","M,S,T", 0x46c0003a, 0xffe000ff, RD_S|RD_T|WR_CC|FP_D, }, {"c.ngl.d", "S,T", 0x4620003b, 0xffe007ff, RD_S|RD_T|WR_CC|FP_D, }, {"c.ngl.d", "M,S,T", 0x4620003b, 0xffe000ff, RD_S|RD_T|WR_CC|FP_D, }, {"c.ngl.s", "S,T", 0x4600003b, 0xffe007ff, RD_S|RD_T|WR_CC|FP_S, }, {"c.ngl.s", "M,S,T", 0x4600003b, 0xffe000ff, RD_S|RD_T|WR_CC|FP_S, }, {"c.ngl.ps","S,T", 0x46c0003b, 0xffe007ff, RD_S|RD_T|WR_CC|FP_D, }, {"c.ngl.ps","S,T", 0x4560003b, 0xffe007ff, RD_S|RD_T|WR_CC|FP_D, }, {"c.ngl.ps","M,S,T", 0x46c0003b, 0xffe000ff, RD_S|RD_T|WR_CC|FP_D, }, {"c.lt.d", "S,T", 0x4620003c, 0xffe007ff, RD_S|RD_T|WR_CC|FP_D, }, {"c.lt.d", "M,S,T", 0x4620003c, 0xffe000ff, RD_S|RD_T|WR_CC|FP_D, }, {"c.lt.s", "S,T", 0x4600003c, 0xffe007ff, RD_S|RD_T|WR_CC|FP_S, }, {"c.lt.s", "M,S,T", 0x4600003c, 0xffe000ff, RD_S|RD_T|WR_CC|FP_S, }, {"c.lt.ob", "Y,Q", 0x78000004, 0xfc2007ff, WR_CC|RD_S|RD_T|FP_D, }, {"c.lt.ob", "S,T", 0x4ac00004, 0xffe007ff, WR_CC|RD_S|RD_T, }, {"c.lt.ob", "S,T[e]", 0x48000004, 0xfe2007ff, WR_CC|RD_S|RD_T, }, {"c.lt.ob", "S,k", 0x4bc00004, 0xffe007ff, WR_CC|RD_S|RD_T, }, {"c.lt.ps", "S,T", 0x46c0003c, 0xffe007ff, RD_S|RD_T|WR_CC|FP_D, }, {"c.lt.ps", "S,T", 0x4560003c, 0xffe007ff, RD_S|RD_T|WR_CC|FP_D, }, {"c.lt.ps", "M,S,T", 0x46c0003c, 0xffe000ff, RD_S|RD_T|WR_CC|FP_D, }, {"c.lt.qh", "Y,Q", 0x78200004, 0xfc2007ff, WR_CC|RD_S|RD_T|FP_D, }, {"c.nge.d", "S,T", 0x4620003d, 0xffe007ff, RD_S|RD_T|WR_CC|FP_D, }, {"c.nge.d", "M,S,T", 0x4620003d, 0xffe000ff, RD_S|RD_T|WR_CC|FP_D, }, {"c.nge.s", "S,T", 0x4600003d, 0xffe007ff, RD_S|RD_T|WR_CC|FP_S, }, {"c.nge.s", "M,S,T", 0x4600003d, 0xffe000ff, RD_S|RD_T|WR_CC|FP_S, }, {"c.nge.ps","S,T", 0x46c0003d, 0xffe007ff, RD_S|RD_T|WR_CC|FP_D, }, {"c.nge.ps","S,T", 0x4560003d, 0xffe007ff, RD_S|RD_T|WR_CC|FP_D, }, {"c.nge.ps","M,S,T", 0x46c0003d, 0xffe000ff, RD_S|RD_T|WR_CC|FP_D, }, {"c.le.d", "S,T", 0x4620003e, 0xffe007ff, RD_S|RD_T|WR_CC|FP_D, }, {"c.le.d", "M,S,T", 0x4620003e, 0xffe000ff, RD_S|RD_T|WR_CC|FP_D, }, {"c.le.s", "S,T", 0x4600003e, 0xffe007ff, RD_S|RD_T|WR_CC|FP_S, }, {"c.le.s", "M,S,T", 0x4600003e, 0xffe000ff, RD_S|RD_T|WR_CC|FP_S, }, {"c.le.ob", "Y,Q", 0x78000005, 0xfc2007ff, WR_CC|RD_S|RD_T|FP_D, }, {"c.le.ob", "S,T", 0x4ac00005, 0xffe007ff, WR_CC|RD_S|RD_T, }, {"c.le.ob", "S,T[e]", 0x48000005, 0xfe2007ff, WR_CC|RD_S|RD_T, }, {"c.le.ob", "S,k", 0x4bc00005, 0xffe007ff, WR_CC|RD_S|RD_T, }, {"c.le.ps", "S,T", 0x46c0003e, 0xffe007ff, RD_S|RD_T|WR_CC|FP_D, }, {"c.le.ps", "S,T", 0x4560003e, 0xffe007ff, RD_S|RD_T|WR_CC|FP_D, }, {"c.le.ps", "M,S,T", 0x46c0003e, 0xffe000ff, RD_S|RD_T|WR_CC|FP_D, }, {"c.le.qh", "Y,Q", 0x78200005, 0xfc2007ff, WR_CC|RD_S|RD_T|FP_D, }, {"c.ngt.d", "S,T", 0x4620003f, 0xffe007ff, RD_S|RD_T|WR_CC|FP_D, }, {"c.ngt.d", "M,S,T", 0x4620003f, 0xffe000ff, RD_S|RD_T|WR_CC|FP_D, }, {"c.ngt.s", "S,T", 0x4600003f, 0xffe007ff, RD_S|RD_T|WR_CC|FP_S, }, {"c.ngt.s", "M,S,T", 0x4600003f, 0xffe000ff, RD_S|RD_T|WR_CC|FP_S, }, {"c.ngt.ps","S,T", 0x46c0003f, 0xffe007ff, RD_S|RD_T|WR_CC|FP_D, }, {"c.ngt.ps","S,T", 0x4560003f, 0xffe007ff, RD_S|RD_T|WR_CC|FP_D, }, {"c.ngt.ps","M,S,T", 0x46c0003f, 0xffe000ff, RD_S|RD_T|WR_CC|FP_D, }, {"cabs.eq.d", "M,S,T", 0x46200072, 0xffe000ff, RD_S|RD_T|WR_CC|FP_D, }, {"cabs.eq.ps", "M,S,T", 0x46c00072, 0xffe000ff, RD_S|RD_T|WR_CC|FP_D, }, {"cabs.eq.s", "M,S,T", 0x46000072, 0xffe000ff, RD_S|RD_T|WR_CC|FP_S, }, {"cabs.f.d", "M,S,T", 0x46200070, 0xffe000ff, RD_S|RD_T|WR_CC|FP_D, }, {"cabs.f.ps", "M,S,T", 0x46c00070, 0xffe000ff, RD_S|RD_T|WR_CC|FP_D, }, {"cabs.f.s", "M,S,T", 0x46000070, 0xffe000ff, RD_S|RD_T|WR_CC|FP_S, }, {"cabs.le.d", "M,S,T", 0x4620007e, 0xffe000ff, RD_S|RD_T|WR_CC|FP_D, }, {"cabs.le.ps", "M,S,T", 0x46c0007e, 0xffe000ff, RD_S|RD_T|WR_CC|FP_D, }, {"cabs.le.s", "M,S,T", 0x4600007e, 0xffe000ff, RD_S|RD_T|WR_CC|FP_S, }, {"cabs.lt.d", "M,S,T", 0x4620007c, 0xffe000ff, RD_S|RD_T|WR_CC|FP_D, }, {"cabs.lt.ps", "M,S,T", 0x46c0007c, 0xffe000ff, RD_S|RD_T|WR_CC|FP_D, }, {"cabs.lt.s", "M,S,T", 0x4600007c, 0xffe000ff, RD_S|RD_T|WR_CC|FP_S, }, {"cabs.nge.d", "M,S,T", 0x4620007d, 0xffe000ff, RD_S|RD_T|WR_CC|FP_D, }, {"cabs.nge.ps","M,S,T", 0x46c0007d, 0xffe000ff, RD_S|RD_T|WR_CC|FP_D, }, {"cabs.nge.s", "M,S,T", 0x4600007d, 0xffe000ff, RD_S|RD_T|WR_CC|FP_S, }, {"cabs.ngl.d", "M,S,T", 0x4620007b, 0xffe000ff, RD_S|RD_T|WR_CC|FP_D, }, {"cabs.ngl.ps","M,S,T", 0x46c0007b, 0xffe000ff, RD_S|RD_T|WR_CC|FP_D, }, {"cabs.ngl.s", "M,S,T", 0x4600007b, 0xffe000ff, RD_S|RD_T|WR_CC|FP_S, }, {"cabs.ngle.d","M,S,T", 0x46200079, 0xffe000ff, RD_S|RD_T|WR_CC|FP_D, }, {"cabs.ngle.ps","M,S,T",0x46c00079, 0xffe000ff, RD_S|RD_T|WR_CC|FP_D, }, {"cabs.ngle.s","M,S,T", 0x46000079, 0xffe000ff, RD_S|RD_T|WR_CC|FP_S, }, {"cabs.ngt.d", "M,S,T", 0x4620007f, 0xffe000ff, RD_S|RD_T|WR_CC|FP_D, }, {"cabs.ngt.ps","M,S,T", 0x46c0007f, 0xffe000ff, RD_S|RD_T|WR_CC|FP_D, }, {"cabs.ngt.s", "M,S,T", 0x4600007f, 0xffe000ff, RD_S|RD_T|WR_CC|FP_S, }, {"cabs.ole.d", "M,S,T", 0x46200076, 0xffe000ff, RD_S|RD_T|WR_CC|FP_D, }, {"cabs.ole.ps","M,S,T", 0x46c00076, 0xffe000ff, RD_S|RD_T|WR_CC|FP_D, }, {"cabs.ole.s", "M,S,T", 0x46000076, 0xffe000ff, RD_S|RD_T|WR_CC|FP_S, }, {"cabs.olt.d", "M,S,T", 0x46200074, 0xffe000ff, RD_S|RD_T|WR_CC|FP_D, }, {"cabs.olt.ps","M,S,T", 0x46c00074, 0xffe000ff, RD_S|RD_T|WR_CC|FP_D, }, {"cabs.olt.s", "M,S,T", 0x46000074, 0xffe000ff, RD_S|RD_T|WR_CC|FP_S, }, {"cabs.seq.d", "M,S,T", 0x4620007a, 0xffe000ff, RD_S|RD_T|WR_CC|FP_D, }, {"cabs.seq.ps","M,S,T", 0x46c0007a, 0xffe000ff, RD_S|RD_T|WR_CC|FP_D, }, {"cabs.seq.s", "M,S,T", 0x4600007a, 0xffe000ff, RD_S|RD_T|WR_CC|FP_S, }, {"cabs.sf.d", "M,S,T", 0x46200078, 0xffe000ff, RD_S|RD_T|WR_CC|FP_D, }, {"cabs.sf.ps", "M,S,T", 0x46c00078, 0xffe000ff, RD_S|RD_T|WR_CC|FP_D, }, {"cabs.sf.s", "M,S,T", 0x46000078, 0xffe000ff, RD_S|RD_T|WR_CC|FP_S, }, {"cabs.ueq.d", "M,S,T", 0x46200073, 0xffe000ff, RD_S|RD_T|WR_CC|FP_D, }, {"cabs.ueq.ps","M,S,T", 0x46c00073, 0xffe000ff, RD_S|RD_T|WR_CC|FP_D, }, {"cabs.ueq.s", "M,S,T", 0x46000073, 0xffe000ff, RD_S|RD_T|WR_CC|FP_S, }, {"cabs.ule.d", "M,S,T", 0x46200077, 0xffe000ff, RD_S|RD_T|WR_CC|FP_D, }, {"cabs.ule.ps","M,S,T", 0x46c00077, 0xffe000ff, RD_S|RD_T|WR_CC|FP_D, }, {"cabs.ule.s", "M,S,T", 0x46000077, 0xffe000ff, RD_S|RD_T|WR_CC|FP_S, }, {"cabs.ult.d", "M,S,T", 0x46200075, 0xffe000ff, RD_S|RD_T|WR_CC|FP_D, }, {"cabs.ult.ps","M,S,T", 0x46c00075, 0xffe000ff, RD_S|RD_T|WR_CC|FP_D, }, {"cabs.ult.s", "M,S,T", 0x46000075, 0xffe000ff, RD_S|RD_T|WR_CC|FP_S, }, {"cabs.un.d", "M,S,T", 0x46200071, 0xffe000ff, RD_S|RD_T|WR_CC|FP_D, }, {"cabs.un.ps", "M,S,T", 0x46c00071, 0xffe000ff, RD_S|RD_T|WR_CC|FP_D, }, {"cabs.un.s", "M,S,T", 0x46000071, 0xffe000ff, RD_S|RD_T|WR_CC|FP_S, }, /* CW4010 instructions which are aliases for the cache instruction. */ {"flushi", "", 0xbc010000, 0xffffffff, 0, }, {"flushd", "", 0xbc020000, 0xffffffff, 0, }, {"flushid", "", 0xbc030000, 0xffffffff, 0, }, {"wb", "o(b)", 0xbc040000, 0xfc1f0000, SM|RD_b, }, {"cache", "k,o(b)", 0xbc000000, 0xfc000000, RD_b, }, {"cache", "k,A(b)", 0, (int) M_CACHE_AB, INSN_MACRO, }, {"ceil.l.d", "D,S", 0x4620000a, 0xffff003f, WR_D|RD_S|FP_D, }, {"ceil.l.s", "D,S", 0x4600000a, 0xffff003f, WR_D|RD_S|FP_S|FP_D, }, {"ceil.w.d", "D,S", 0x4620000e, 0xffff003f, WR_D|RD_S|FP_S|FP_D, }, {"ceil.w.s", "D,S", 0x4600000e, 0xffff003f, WR_D|RD_S|FP_S, }, {"cfc0", "t,G", 0x40400000, 0xffe007ff, LCD|WR_t|RD_C0, }, {"cfc1", "t,G", 0x44400000, 0xffe007ff, LCD|WR_t|RD_C1|FP_S, }, {"cfc1", "t,S", 0x44400000, 0xffe007ff, LCD|WR_t|RD_C1|FP_S, }, /* cfc2 is at the bottom of the table. */ /* cfc3 is at the bottom of the table. */ {"cftc1", "d,E", 0x41000023, 0xffe007ff, TRAP|LCD|WR_d|RD_C1|FP_S, }, {"cftc1", "d,T", 0x41000023, 0xffe007ff, TRAP|LCD|WR_d|RD_C1|FP_S, }, {"cftc2", "d,E", 0x41000025, 0xffe007ff, TRAP|LCD|WR_d|RD_C2, }, {"cins32", "t,r,+p,+S",0x70000033, 0xfc00003f, WR_t|RD_s, }, {"cins", "t,r,+P,+S",0x70000033, 0xfc00003f, WR_t|RD_s, }, /* cins32 */ {"cins", "t,r,+p,+s",0x70000032, 0xfc00003f, WR_t|RD_s, }, {"clo", "U,s", 0x70000021, 0xfc0007ff, WR_d|WR_t|RD_s, }, {"clz", "U,s", 0x70000020, 0xfc0007ff, WR_d|WR_t|RD_s, }, {"ctc0", "t,G", 0x40c00000, 0xffe007ff, COD|RD_t|WR_CC, }, {"ctc1", "t,G", 0x44c00000, 0xffe007ff, COD|RD_t|WR_CC|FP_S, }, {"ctc1", "t,S", 0x44c00000, 0xffe007ff, COD|RD_t|WR_CC|FP_S, }, /* ctc2 is at the bottom of the table. */ /* ctc3 is at the bottom of the table. */ {"cttc1", "t,g", 0x41800023, 0xffe007ff, TRAP|COD|RD_t|WR_CC|FP_S, }, {"cttc1", "t,S", 0x41800023, 0xffe007ff, TRAP|COD|RD_t|WR_CC|FP_S, }, {"cttc2", "t,g", 0x41800025, 0xffe007ff, TRAP|COD|RD_t|WR_CC, }, {"cvt.d.l", "D,S", 0x46a00021, 0xffff003f, WR_D|RD_S|FP_D, }, {"cvt.d.s", "D,S", 0x46000021, 0xffff003f, WR_D|RD_S|FP_S|FP_D, }, {"cvt.d.w", "D,S", 0x46800021, 0xffff003f, WR_D|RD_S|FP_S|FP_D, }, {"cvt.l.d", "D,S", 0x46200025, 0xffff003f, WR_D|RD_S|FP_D, }, {"cvt.l.s", "D,S", 0x46000025, 0xffff003f, WR_D|RD_S|FP_S|FP_D, }, {"cvt.s.l", "D,S", 0x46a00020, 0xffff003f, WR_D|RD_S|FP_S|FP_D, }, {"cvt.s.d", "D,S", 0x46200020, 0xffff003f, WR_D|RD_S|FP_S|FP_D, }, {"cvt.s.w", "D,S", 0x46800020, 0xffff003f, WR_D|RD_S|FP_S, }, {"cvt.s.pl","D,S", 0x46c00028, 0xffff003f, WR_D|RD_S|FP_S|FP_D, }, {"cvt.s.pu","D,S", 0x46c00020, 0xffff003f, WR_D|RD_S|FP_S|FP_D, }, {"cvt.w.d", "D,S", 0x46200024, 0xffff003f, WR_D|RD_S|FP_S|FP_D, }, {"cvt.w.s", "D,S", 0x46000024, 0xffff003f, WR_D|RD_S|FP_S, }, {"cvt.ps.pw", "D,S", 0x46800026, 0xffff003f, WR_D|RD_S|FP_S|FP_D, }, {"cvt.ps.s","D,V,T", 0x46000026, 0xffe0003f, WR_D|RD_S|RD_T|FP_S|FP_D, }, {"cvt.pw.ps", "D,S", 0x46c00024, 0xffff003f, WR_D|RD_S|FP_S|FP_D, }, {"dabs", "d,v", 0, (int) M_DABS, INSN_MACRO, }, {"dadd", "d,v,t", 0x0000002c, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"dadd", "t,r,I", 0, (int) M_DADD_I, INSN_MACRO, }, {"dadd", "D,S,T", 0x45e00000, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"dadd", "D,S,T", 0x4b60000c, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"daddi", "t,r,j", 0x60000000, 0xfc000000, WR_t|RD_s, }, {"daddiu", "t,r,j", 0x64000000, 0xfc000000, WR_t|RD_s, }, {"daddu", "d,v,t", 0x0000002d, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"daddu", "t,r,I", 0, (int) M_DADDU_I, INSN_MACRO, }, {"daddwc", "d,s,t", 0x70000038, 0xfc0007ff, WR_d|RD_s|RD_t|WR_C0|RD_C0, }, {"sdbbp", "", 0x7000003f, 0xffffffff, 0, }, {"dclo", "U,s", 0x70000025, 0xfc0007ff, RD_s|WR_d|WR_t, }, {"dclz", "U,s", 0x70000024, 0xfc0007ff, RD_s|WR_d|WR_t, }, /* dctr and dctw are used on the r5000. */ {"dctr", "o(b)", 0xbc050000, 0xfc1f0000, RD_b, }, {"dctw", "o(b)", 0xbc090000, 0xfc1f0000, RD_b, }, {"deret", "", 0x4200001f, 0xffffffff, 0, }, {"dext", "t,r,I,+I", 0, (int) M_DEXT, INSN_MACRO, }, {"dext", "t,r,+A,+C", 0x7c000003, 0xfc00003f, WR_t|RD_s, }, {"dextm", "t,r,+A,+G", 0x7c000001, 0xfc00003f, WR_t|RD_s, }, {"dextu", "t,r,+E,+H", 0x7c000002, 0xfc00003f, WR_t|RD_s, }, /* For ddiv, see the comments about div. */ {"ddiv", "z,s,t", 0x0000001e, 0xfc00ffff, RD_s|RD_t|WR_HILO, }, {"ddiv", "d,v,t", 0, (int) M_DDIV_3, INSN_MACRO, }, {"ddiv", "d,v,I", 0, (int) M_DDIV_3I, INSN_MACRO, }, /* For ddivu, see the comments about div. */ {"ddivu", "z,s,t", 0x0000001f, 0xfc00ffff, RD_s|RD_t|WR_HILO, }, {"ddivu", "d,v,t", 0, (int) M_DDIVU_3, INSN_MACRO, }, {"ddivu", "d,v,I", 0, (int) M_DDIVU_3I, INSN_MACRO, }, {"di", "", 0x41606000, 0xffffffff, WR_t|WR_C0, }, {"di", "t", 0x41606000, 0xffe0ffff, WR_t|WR_C0, }, {"dins", "t,r,I,+I", 0, (int) M_DINS, INSN_MACRO, }, {"dins", "t,r,+A,+B", 0x7c000007, 0xfc00003f, WR_t|RD_s, }, {"dinsm", "t,r,+A,+F", 0x7c000005, 0xfc00003f, WR_t|RD_s, }, {"dinsu", "t,r,+E,+F", 0x7c000006, 0xfc00003f, WR_t|RD_s, }, /* The MIPS assembler treats the div opcode with two operands as though the first operand appeared twice (the first operand is both a source and a destination). To get the div machine instruction, you must use an explicit destination of $0. */ {"div", "z,s,t", 0x0000001a, 0xfc00ffff, RD_s|RD_t|WR_HILO, }, {"div", "z,t", 0x0000001a, 0xffe0ffff, RD_s|RD_t|WR_HILO, }, {"div", "d,v,t", 0, (int) M_DIV_3, INSN_MACRO, }, {"div", "d,v,I", 0, (int) M_DIV_3I, INSN_MACRO, }, {"div.d", "D,V,T", 0x46200003, 0xffe0003f, WR_D|RD_S|RD_T|FP_D, }, {"div.s", "D,V,T", 0x46000003, 0xffe0003f, WR_D|RD_S|RD_T|FP_S, }, {"div.ps", "D,V,T", 0x46c00003, 0xffe0003f, WR_D|RD_S|RD_T|FP_D, }, /* For divu, see the comments about div. */ {"divu", "z,s,t", 0x0000001b, 0xfc00ffff, RD_s|RD_t|WR_HILO, }, {"divu", "z,t", 0x0000001b, 0xffe0ffff, RD_s|RD_t|WR_HILO, }, {"divu", "d,v,t", 0, (int) M_DIVU_3, INSN_MACRO, }, {"divu", "d,v,I", 0, (int) M_DIVU_3I, INSN_MACRO, }, {"dla", "t,A(b)", 0, (int) M_DLA_AB, INSN_MACRO, }, {"dlca", "t,A(b)", 0, (int) M_DLCA_AB, INSN_MACRO, }, {"dli", "t,j", 0x24000000, 0xffe00000, WR_t, }, /* addiu */ {"dli", "t,i", 0x34000000, 0xffe00000, WR_t, }, /* ori */ {"dli", "t,I", 0, (int) M_DLI, INSN_MACRO, }, {"dmacc", "d,s,t", 0x00000029, 0xfc0007ff, RD_s|RD_t|WR_LO|WR_d, }, {"dmacchi", "d,s,t", 0x00000229, 0xfc0007ff, RD_s|RD_t|WR_LO|WR_d, }, {"dmacchis", "d,s,t", 0x00000629, 0xfc0007ff, RD_s|RD_t|WR_LO|WR_d, }, {"dmacchiu", "d,s,t", 0x00000269, 0xfc0007ff, RD_s|RD_t|WR_LO|WR_d, }, {"dmacchius", "d,s,t", 0x00000669, 0xfc0007ff, RD_s|RD_t|WR_LO|WR_d, }, {"dmaccs", "d,s,t", 0x00000429, 0xfc0007ff, RD_s|RD_t|WR_LO|WR_d, }, {"dmaccu", "d,s,t", 0x00000069, 0xfc0007ff, RD_s|RD_t|WR_LO|WR_d, }, {"dmaccus", "d,s,t", 0x00000469, 0xfc0007ff, RD_s|RD_t|WR_LO|WR_d, }, {"dmadd16", "s,t", 0x00000029, 0xfc00ffff, RD_s|RD_t|MOD_LO, }, {"dmfc0", "t,G", 0x40200000, 0xffe007ff, LCD|WR_t|RD_C0, }, {"dmfc0", "t,+D", 0x40200000, 0xffe007f8, LCD|WR_t|RD_C0, }, {"dmfc0", "t,G,H", 0x40200000, 0xffe007f8, LCD|WR_t|RD_C0, }, {"dmt", "", 0x41600bc1, 0xffffffff, TRAP, }, {"dmt", "t", 0x41600bc1, 0xffe0ffff, TRAP|WR_t, }, {"dmtc0", "t,G", 0x40a00000, 0xffe007ff, COD|RD_t|WR_C0|WR_CC, }, {"dmtc0", "t,+D", 0x40a00000, 0xffe007f8, COD|RD_t|WR_C0|WR_CC, }, {"dmtc0", "t,G,H", 0x40a00000, 0xffe007f8, COD|RD_t|WR_C0|WR_CC, }, {"dmfc1", "t,S", 0x44200000, 0xffe007ff, LCD|WR_t|RD_S|FP_D, }, {"dmfc1", "t,G", 0x44200000, 0xffe007ff, LCD|WR_t|RD_S|FP_D, }, {"dmtc1", "t,S", 0x44a00000, 0xffe007ff, COD|RD_t|WR_S|FP_D, }, {"dmtc1", "t,G", 0x44a00000, 0xffe007ff, COD|RD_t|WR_S|FP_D, }, /* dmfc2 is at the bottom of the table. */ /* dmtc2 is at the bottom of the table. */ /* dmfc3 is at the bottom of the table. */ /* dmtc3 is at the bottom of the table. */ {"dmul", "d,v,t", 0x70000003, 0xfc0007ff, WR_d|RD_s|RD_t|WR_HILO, }, {"dmul", "d,v,t", 0, (int) M_DMUL, INSN_MACRO, }, {"dmul", "d,v,I", 0, (int) M_DMUL_I, INSN_MACRO, }, {"dmulo", "d,v,t", 0, (int) M_DMULO, INSN_MACRO, }, {"dmulo", "d,v,I", 0, (int) M_DMULO_I, INSN_MACRO, }, {"dmulou", "d,v,t", 0, (int) M_DMULOU, INSN_MACRO, }, {"dmulou", "d,v,I", 0, (int) M_DMULOU_I, INSN_MACRO, }, {"dmult", "s,t", 0x0000001c, 0xfc00ffff, RD_s|RD_t|WR_HILO, }, {"dmultu", "s,t", 0x0000001d, 0xfc00ffff, RD_s|RD_t|WR_HILO, }, {"dneg", "d,w", 0x0000002e, 0xffe007ff, WR_d|RD_t, }, /* dsub 0 */ {"dnegu", "d,w", 0x0000002f, 0xffe007ff, WR_d|RD_t, }, /* dsubu 0*/ {"dpop", "d,v", 0x7000002d, 0xfc1f07ff, WR_d|RD_s, }, {"drem", "z,s,t", 0x0000001e, 0xfc00ffff, RD_s|RD_t|WR_HILO, }, {"drem", "d,v,t", 0, (int) M_DREM_3, INSN_MACRO, }, {"drem", "d,v,I", 0, (int) M_DREM_3I, INSN_MACRO, }, {"dremu", "z,s,t", 0x0000001f, 0xfc00ffff, RD_s|RD_t|WR_HILO, }, {"dremu", "d,v,t", 0, (int) M_DREMU_3, INSN_MACRO, }, {"dremu", "d,v,I", 0, (int) M_DREMU_3I, INSN_MACRO, }, {"dret", "", 0x7000003e, 0xffffffff, 0, }, {"drol", "d,v,t", 0, (int) M_DROL, INSN_MACRO, }, {"drol", "d,v,I", 0, (int) M_DROL_I, INSN_MACRO, }, {"dror", "d,v,t", 0, (int) M_DROR, INSN_MACRO, }, {"dror", "d,v,I", 0, (int) M_DROR_I, INSN_MACRO, }, {"dror", "d,w,<", 0x0020003a, 0xffe0003f, WR_d|RD_t, }, {"drorv", "d,t,s", 0x00000056, 0xfc0007ff, RD_t|RD_s|WR_d, }, {"dror32", "d,w,<", 0x0020003e, 0xffe0003f, WR_d|RD_t, }, {"drotl", "d,v,t", 0, (int) M_DROL, INSN_MACRO, }, {"drotl", "d,v,I", 0, (int) M_DROL_I, INSN_MACRO, }, {"dror", "d,v,t", 0, (int) M_DROR, INSN_MACRO, }, {"dror", "d,v,I", 0, (int) M_DROR_I, INSN_MACRO, }, {"drorv", "d,t,s", 0x00000056, 0xfc0007ff, RD_t|RD_s|WR_d, }, {"dror32", "d,w,<", 0x0020003e, 0xffe0003f, WR_d|RD_t, }, {"dsbh", "d,w", 0x7c0000a4, 0xffe007ff, WR_d|RD_t, }, {"dshd", "d,w", 0x7c000164, 0xffe007ff, WR_d|RD_t, }, {"dsllv", "d,t,s", 0x00000014, 0xfc0007ff, WR_d|RD_t|RD_s, }, {"dsll32", "d,w,<", 0x0000003c, 0xffe0003f, WR_d|RD_t, }, {"dsll", "d,w,s", 0x00000014, 0xfc0007ff, WR_d|RD_t|RD_s, }, /* dsllv */ {"dsll", "d,w,>", 0x0000003c, 0xffe0003f, WR_d|RD_t, }, /* dsll32 */ {"dsll", "d,w,<", 0x00000038, 0xffe0003f, WR_d|RD_t, }, {"dsll", "D,S,T", 0x45a00002, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"dsll", "D,S,T", 0x4b20000e, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"dsrav", "d,t,s", 0x00000017, 0xfc0007ff, WR_d|RD_t|RD_s, }, {"dsra32", "d,w,<", 0x0000003f, 0xffe0003f, WR_d|RD_t, }, {"dsra", "d,w,s", 0x00000017, 0xfc0007ff, WR_d|RD_t|RD_s, }, /* dsrav */ {"dsra", "d,w,>", 0x0000003f, 0xffe0003f, WR_d|RD_t, }, /* dsra32 */ {"dsra", "d,w,<", 0x0000003b, 0xffe0003f, WR_d|RD_t, }, {"dsra", "D,S,T", 0x45e00003, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"dsra", "D,S,T", 0x4b60000f, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"dsrlv", "d,t,s", 0x00000016, 0xfc0007ff, WR_d|RD_t|RD_s, }, {"dsrl32", "d,w,<", 0x0000003e, 0xffe0003f, WR_d|RD_t, }, {"dsrl", "d,w,s", 0x00000016, 0xfc0007ff, WR_d|RD_t|RD_s, }, /* dsrlv */ {"dsrl", "d,w,>", 0x0000003e, 0xffe0003f, WR_d|RD_t, }, /* dsrl32 */ {"dsrl", "d,w,<", 0x0000003a, 0xffe0003f, WR_d|RD_t, }, {"dsrl", "D,S,T", 0x45a00003, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"dsrl", "D,S,T", 0x4b20000f, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"dsub", "d,v,t", 0x0000002e, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"dsub", "d,v,I", 0, (int) M_DSUB_I, INSN_MACRO, }, {"dsub", "D,S,T", 0x45e00001, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"dsub", "D,S,T", 0x4b60000d, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"dsubu", "d,v,t", 0x0000002f, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"dsubu", "d,v,I", 0, (int) M_DSUBU_I, INSN_MACRO, }, {"dvpe", "", 0x41600001, 0xffffffff, TRAP, }, {"dvpe", "t", 0x41600001, 0xffe0ffff, TRAP|WR_t, }, {"ei", "", 0x41606020, 0xffffffff, WR_t|WR_C0, }, {"ei", "t", 0x41606020, 0xffe0ffff, WR_t|WR_C0, }, {"emt", "", 0x41600be1, 0xffffffff, TRAP, }, {"emt", "t", 0x41600be1, 0xffe0ffff, TRAP|WR_t, }, {"eret", "", 0x42000018, 0xffffffff, 0, }, {"evpe", "", 0x41600021, 0xffffffff, TRAP, }, {"evpe", "t", 0x41600021, 0xffe0ffff, TRAP|WR_t, }, {"ext", "t,r,+A,+C", 0x7c000000, 0xfc00003f, WR_t|RD_s, }, {"exts32", "t,r,+p,+S",0x7000003b, 0xfc00003f, WR_t|RD_s, }, {"exts", "t,r,+P,+S",0x7000003b, 0xfc00003f, WR_t|RD_s, }, /* exts32 */ {"exts", "t,r,+p,+s",0x7000003a, 0xfc00003f, WR_t|RD_s, }, {"floor.l.d", "D,S", 0x4620000b, 0xffff003f, WR_D|RD_S|FP_D, }, {"floor.l.s", "D,S", 0x4600000b, 0xffff003f, WR_D|RD_S|FP_S|FP_D, }, {"floor.w.d", "D,S", 0x4620000f, 0xffff003f, WR_D|RD_S|FP_S|FP_D, }, {"floor.w.s", "D,S", 0x4600000f, 0xffff003f, WR_D|RD_S|FP_S, }, {"hibernate","", 0x42000023, 0xffffffff, 0, }, {"ins", "t,r,+A,+B", 0x7c000004, 0xfc00003f, WR_t|RD_s, }, {"jr", "s", 0x00000008, 0xfc1fffff, UBD|RD_s, }, /* jr.hb is officially MIPS{32,64}R2, but it works on R1 as jr with the same hazard barrier effect. */ {"jr.hb", "s", 0x00000408, 0xfc1fffff, UBD|RD_s, }, {"j", "s", 0x00000008, 0xfc1fffff, UBD|RD_s, }, /* jr */ /* SVR4 PIC code requires special handling for j, so it must be a macro. */ {"j", "a", 0, (int) M_J_A, INSN_MACRO, }, /* This form of j is used by the disassembler and internally by the assembler, but will never match user input (because the line above will match first). */ {"j", "a", 0x08000000, 0xfc000000, UBD, }, {"jalr", "s", 0x0000f809, 0xfc1fffff, UBD|RD_s|WR_d, }, {"jalr", "d,s", 0x00000009, 0xfc1f07ff, UBD|RD_s|WR_d, }, /* jalr.hb is officially MIPS{32,64}R2, but it works on R1 as jalr with the same hazard barrier effect. */ {"jalr.hb", "s", 0x0000fc09, 0xfc1fffff, UBD|RD_s|WR_d, }, {"jalr.hb", "d,s", 0x00000409, 0xfc1f07ff, UBD|RD_s|WR_d, }, /* SVR4 PIC code requires special handling for jal, so it must be a macro. */ {"jal", "d,s", 0, (int) M_JAL_2, INSN_MACRO, }, {"jal", "s", 0, (int) M_JAL_1, INSN_MACRO, }, {"jal", "a", 0, (int) M_JAL_A, INSN_MACRO, }, /* This form of jal is used by the disassembler and internally by the assembler, but will never match user input (because the line above will match first). */ {"jal", "a", 0x0c000000, 0xfc000000, UBD|WR_31, }, {"jalx", "a", 0x74000000, 0xfc000000, UBD|WR_31, }, {"la", "t,A(b)", 0, (int) M_LA_AB, INSN_MACRO, }, {"lb", "t,o(b)", 0x80000000, 0xfc000000, LDD|RD_b|WR_t, }, {"lb", "t,A(b)", 0, (int) M_LB_AB, INSN_MACRO, }, {"lbu", "t,o(b)", 0x90000000, 0xfc000000, LDD|RD_b|WR_t, }, {"lbu", "t,A(b)", 0, (int) M_LBU_AB, INSN_MACRO, }, {"lca", "t,A(b)", 0, (int) M_LCA_AB, INSN_MACRO, }, /* The macro has to be first to handle o32 correctly. */ {"ld", "t,o(b)", 0, (int) M_LD_OB, INSN_MACRO, }, {"ld", "t,o(b)", 0xdc000000, 0xfc000000, WR_t|RD_b, }, {"ld", "t,A(b)", 0, (int) M_LD_AB, INSN_MACRO, }, {"ldaddw", "t,b", 0x70000010, 0xfc00ffff, SM|RD_t|WR_t|RD_b, }, {"ldaddwu", "t,b", 0x70000011, 0xfc00ffff, SM|RD_t|WR_t|RD_b, }, {"ldaddd", "t,b", 0x70000012, 0xfc00ffff, SM|RD_t|WR_t|RD_b, }, {"ldc1", "T,o(b)", 0xd4000000, 0xfc000000, CLD|RD_b|WR_T|FP_D, }, {"ldc1", "E,o(b)", 0xd4000000, 0xfc000000, CLD|RD_b|WR_T|FP_D, }, {"ldc1", "T,A(b)", 0, (int) M_LDC1_AB, INSN_MACRO, INSN2_M_FP_D, }, {"ldc1", "E,A(b)", 0, (int) M_LDC1_AB, INSN_MACRO, INSN2_M_FP_D, }, {"l.d", "T,o(b)", 0xd4000000, 0xfc000000, CLD|RD_b|WR_T|FP_D, }, /* ldc1 */ {"l.d", "T,o(b)", 0, (int) M_L_DOB, INSN_MACRO, INSN2_M_FP_D, }, {"l.d", "T,A(b)", 0, (int) M_L_DAB, INSN_MACRO, INSN2_M_FP_D, }, {"ldc2", "E,o(b)", 0xd8000000, 0xfc000000, CLD|RD_b|WR_CC, }, {"ldc2", "E,A(b)", 0, (int) M_LDC2_AB, INSN_MACRO, }, {"ldc3", "E,o(b)", 0xdc000000, 0xfc000000, CLD|RD_b|WR_CC, }, {"ldc3", "E,A(b)", 0, (int) M_LDC3_AB, INSN_MACRO, }, {"ldl", "t,o(b)", 0x68000000, 0xfc000000, LDD|WR_t|RD_b, }, {"ldl", "t,A(b)", 0, (int) M_LDL_AB, INSN_MACRO, }, {"ldr", "t,o(b)", 0x6c000000, 0xfc000000, LDD|WR_t|RD_b, }, {"ldr", "t,A(b)", 0, (int) M_LDR_AB, INSN_MACRO, }, {"ldxc1", "D,t(b)", 0x4c000001, 0xfc00f83f, LDD|WR_D|RD_t|RD_b|FP_D, }, {"lh", "t,o(b)", 0x84000000, 0xfc000000, LDD|RD_b|WR_t, }, {"lh", "t,A(b)", 0, (int) M_LH_AB, INSN_MACRO, }, {"lhu", "t,o(b)", 0x94000000, 0xfc000000, LDD|RD_b|WR_t, }, {"lhu", "t,A(b)", 0, (int) M_LHU_AB, INSN_MACRO, }, /* li is at the start of the table. */ {"li.d", "t,F", 0, (int) M_LI_D, INSN_MACRO, INSN2_M_FP_D, }, {"li.d", "T,L", 0, (int) M_LI_DD, INSN_MACRO, INSN2_M_FP_D, }, {"li.s", "t,f", 0, (int) M_LI_S, INSN_MACRO, INSN2_M_FP_S, }, {"li.s", "T,l", 0, (int) M_LI_SS, INSN_MACRO, INSN2_M_FP_S, }, {"ll", "t,o(b)", 0xc0000000, 0xfc000000, LDD|RD_b|WR_t, }, {"ll", "t,A(b)", 0, (int) M_LL_AB, INSN_MACRO, }, {"lld", "t,o(b)", 0xd0000000, 0xfc000000, LDD|RD_b|WR_t, }, {"lld", "t,A(b)", 0, (int) M_LLD_AB, INSN_MACRO, }, {"lui", "t,u", 0x3c000000, 0xffe00000, WR_t, }, {"luxc1", "D,t(b)", 0x4c000005, 0xfc00f83f, LDD|WR_D|RD_t|RD_b|FP_D, }, {"lw", "t,o(b)", 0x8c000000, 0xfc000000, LDD|RD_b|WR_t, }, {"lw", "t,A(b)", 0, (int) M_LW_AB, INSN_MACRO, }, {"lwc0", "E,o(b)", 0xc0000000, 0xfc000000, CLD|RD_b|WR_CC, }, {"lwc0", "E,A(b)", 0, (int) M_LWC0_AB, INSN_MACRO, }, {"lwc1", "T,o(b)", 0xc4000000, 0xfc000000, CLD|RD_b|WR_T|FP_S, }, {"lwc1", "E,o(b)", 0xc4000000, 0xfc000000, CLD|RD_b|WR_T|FP_S, }, {"lwc1", "T,A(b)", 0, (int) M_LWC1_AB, INSN_MACRO, INSN2_M_FP_S, }, {"lwc1", "E,A(b)", 0, (int) M_LWC1_AB, INSN_MACRO, INSN2_M_FP_S, }, {"l.s", "T,o(b)", 0xc4000000, 0xfc000000, CLD|RD_b|WR_T|FP_S, }, /* lwc1 */ {"l.s", "T,A(b)", 0, (int) M_LWC1_AB, INSN_MACRO, INSN2_M_FP_S, }, {"lwc2", "E,o(b)", 0xc8000000, 0xfc000000, CLD|RD_b|WR_CC, }, {"lwc2", "E,A(b)", 0, (int) M_LWC2_AB, INSN_MACRO, }, {"lwc3", "E,o(b)", 0xcc000000, 0xfc000000, CLD|RD_b|WR_CC, }, {"lwc3", "E,A(b)", 0, (int) M_LWC3_AB, INSN_MACRO, }, {"lwl", "t,o(b)", 0x88000000, 0xfc000000, LDD|RD_b|WR_t, }, {"lwl", "t,A(b)", 0, (int) M_LWL_AB, INSN_MACRO, }, {"lcache", "t,o(b)", 0x88000000, 0xfc000000, LDD|RD_b|WR_t, }, /* same */ {"lcache", "t,A(b)", 0, (int) M_LWL_AB, INSN_MACRO, }, /* as lwl */ {"lwr", "t,o(b)", 0x98000000, 0xfc000000, LDD|RD_b|WR_t, }, {"lwr", "t,A(b)", 0, (int) M_LWR_AB, INSN_MACRO, }, {"flush", "t,o(b)", 0x98000000, 0xfc000000, LDD|RD_b|WR_t, }, /* same */ {"flush", "t,A(b)", 0, (int) M_LWR_AB, INSN_MACRO, }, /* as lwr */ {"fork", "d,s,t", 0x7c000008, 0xfc0007ff, TRAP|WR_d|RD_s|RD_t, }, {"lwu", "t,o(b)", 0x9c000000, 0xfc000000, LDD|RD_b|WR_t, }, {"lwu", "t,A(b)", 0, (int) M_LWU_AB, INSN_MACRO, }, {"lwxc1", "D,t(b)", 0x4c000000, 0xfc00f83f, LDD|WR_D|RD_t|RD_b|FP_S, }, {"lwxs", "d,t(b)", 0x70000088, 0xfc0007ff, LDD|RD_b|RD_t|WR_d, }, {"macc", "d,s,t", 0x00000028, 0xfc0007ff, RD_s|RD_t|WR_HILO|WR_d, }, {"macc", "d,s,t", 0x00000158, 0xfc0007ff, RD_s|RD_t|WR_HILO|WR_d, }, {"maccs", "d,s,t", 0x00000428, 0xfc0007ff, RD_s|RD_t|WR_HILO|WR_d, }, {"macchi", "d,s,t", 0x00000228, 0xfc0007ff, RD_s|RD_t|WR_HILO|WR_d, }, {"macchi", "d,s,t", 0x00000358, 0xfc0007ff, RD_s|RD_t|WR_HILO|WR_d, }, {"macchis", "d,s,t", 0x00000628, 0xfc0007ff, RD_s|RD_t|WR_HILO|WR_d, }, {"macchiu", "d,s,t", 0x00000268, 0xfc0007ff, RD_s|RD_t|WR_HILO|WR_d, }, {"macchiu", "d,s,t", 0x00000359, 0xfc0007ff, RD_s|RD_t|WR_HILO|WR_d, }, {"macchius","d,s,t", 0x00000668, 0xfc0007ff, RD_s|RD_t|WR_HILO|WR_d, }, {"maccu", "d,s,t", 0x00000068, 0xfc0007ff, RD_s|RD_t|WR_HILO|WR_d, }, {"maccu", "d,s,t", 0x00000159, 0xfc0007ff, RD_s|RD_t|WR_HILO|WR_d, }, {"maccus", "d,s,t", 0x00000468, 0xfc0007ff, RD_s|RD_t|WR_HILO|WR_d, }, {"mad", "s,t", 0x70000000, 0xfc00ffff, RD_s|RD_t|MOD_HILO, }, {"madu", "s,t", 0x70000001, 0xfc00ffff, RD_s|RD_t|MOD_HILO, }, {"madd.d", "D,R,S,T", 0x4c000021, 0xfc00003f, RD_R|RD_S|RD_T|WR_D|FP_D, }, {"madd.d", "D,S,T", 0x46200018, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"madd.d", "D,S,T", 0x72200018, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"madd.s", "D,R,S,T", 0x4c000020, 0xfc00003f, RD_R|RD_S|RD_T|WR_D|FP_S, }, {"madd.s", "D,S,T", 0x46000018, 0xffe0003f, RD_S|RD_T|WR_D|FP_S, }, {"madd.s", "D,S,T", 0x72000018, 0xffe0003f, RD_S|RD_T|WR_D|FP_S, }, {"madd.ps", "D,R,S,T", 0x4c000026, 0xfc00003f, RD_R|RD_S|RD_T|WR_D|FP_D, }, {"madd.ps", "D,S,T", 0x45600018, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"madd.ps", "D,S,T", 0x71600018, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"madd", "s,t", 0x0000001c, 0xfc00ffff, RD_s|RD_t|WR_HILO, }, {"madd", "s,t", 0x70000000, 0xfc00ffff, RD_s|RD_t|MOD_HILO, }, {"madd", "s,t", 0x70000000, 0xfc00ffff, RD_s|RD_t|WR_HILO|IS_M, }, {"madd", "7,s,t", 0x70000000, 0xfc00e7ff, MOD_a|RD_s|RD_t, }, {"madd", "d,s,t", 0x70000000, 0xfc0007ff, RD_s|RD_t|WR_HILO|WR_d|IS_M, }, {"maddp", "s,t", 0x70000441, 0xfc00ffff, RD_s|RD_t|MOD_HILO, }, {"maddu", "s,t", 0x0000001d, 0xfc00ffff, RD_s|RD_t|WR_HILO, }, {"maddu", "s,t", 0x70000001, 0xfc00ffff, RD_s|RD_t|MOD_HILO, }, {"maddu", "s,t", 0x70000001, 0xfc00ffff, RD_s|RD_t|WR_HILO|IS_M, }, {"maddu", "7,s,t", 0x70000001, 0xfc00e7ff, MOD_a|RD_s|RD_t, }, {"maddu", "d,s,t", 0x70000001, 0xfc0007ff, RD_s|RD_t|WR_HILO|WR_d|IS_M, }, {"madd16", "s,t", 0x00000028, 0xfc00ffff, RD_s|RD_t|MOD_HILO, }, {"max.ob", "X,Y,Q", 0x78000007, 0xfc20003f, WR_D|RD_S|RD_T|FP_D, }, {"max.ob", "D,S,T", 0x4ac00007, 0xffe0003f, WR_D|RD_S|RD_T, }, {"max.ob", "D,S,T[e]", 0x48000007, 0xfe20003f, WR_D|RD_S|RD_T, }, {"max.ob", "D,S,k", 0x4bc00007, 0xffe0003f, WR_D|RD_S|RD_T, }, {"max.qh", "X,Y,Q", 0x78200007, 0xfc20003f, WR_D|RD_S|RD_T|FP_D, }, {"mfpc", "t,P", 0x4000c801, 0xffe0ffc1, LCD|WR_t|RD_C0, }, {"mfps", "t,P", 0x4000c800, 0xffe0ffc1, LCD|WR_t|RD_C0, }, {"mftacx", "d", 0x41020021, 0xffff07ff, TRAP|WR_d|RD_a, }, {"mftacx", "d,*", 0x41020021, 0xfff307ff, TRAP|WR_d|RD_a, }, {"mftc0", "d,+t", 0x41000000, 0xffe007ff, TRAP|LCD|WR_d|RD_C0, }, {"mftc0", "d,+T", 0x41000000, 0xffe007f8, TRAP|LCD|WR_d|RD_C0, }, {"mftc0", "d,E,H", 0x41000000, 0xffe007f8, TRAP|LCD|WR_d|RD_C0, }, {"mftc1", "d,T", 0x41000022, 0xffe007ff, TRAP|LCD|WR_d|RD_T|FP_S, }, {"mftc1", "d,E", 0x41000022, 0xffe007ff, TRAP|LCD|WR_d|RD_T|FP_S, }, {"mftc2", "d,E", 0x41000024, 0xffe007ff, TRAP|LCD|WR_d|RD_C2, }, {"mftdsp", "d", 0x41100021, 0xffff07ff, TRAP|WR_d, }, {"mftgpr", "d,t", 0x41000020, 0xffe007ff, TRAP|WR_d|RD_t, }, {"mfthc1", "d,T", 0x41000032, 0xffe007ff, TRAP|LCD|WR_d|RD_T|FP_D, }, {"mfthc1", "d,E", 0x41000032, 0xffe007ff, TRAP|LCD|WR_d|RD_T|FP_D, }, {"mfthc2", "d,E", 0x41000034, 0xffe007ff, TRAP|LCD|WR_d|RD_C2, }, {"mfthi", "d", 0x41010021, 0xffff07ff, TRAP|WR_d|RD_a, }, {"mfthi", "d,*", 0x41010021, 0xfff307ff, TRAP|WR_d|RD_a, }, {"mftlo", "d", 0x41000021, 0xffff07ff, TRAP|WR_d|RD_a, }, {"mftlo", "d,*", 0x41000021, 0xfff307ff, TRAP|WR_d|RD_a, }, {"mftr", "d,t,!,H,$", 0x41000000, 0xffe007c8, TRAP|WR_d, }, {"mfc0", "t,G", 0x40000000, 0xffe007ff, LCD|WR_t|RD_C0, }, {"mfc0", "t,+D", 0x40000000, 0xffe007f8, LCD|WR_t|RD_C0, }, {"mfc0", "t,G,H", 0x40000000, 0xffe007f8, LCD|WR_t|RD_C0, }, {"mfc1", "t,S", 0x44000000, 0xffe007ff, LCD|WR_t|RD_S|FP_S, }, {"mfc1", "t,G", 0x44000000, 0xffe007ff, LCD|WR_t|RD_S|FP_S, }, {"mfhc1", "t,S", 0x44600000, 0xffe007ff, LCD|WR_t|RD_S|FP_D, }, {"mfhc1", "t,G", 0x44600000, 0xffe007ff, LCD|WR_t|RD_S|FP_D, }, /* mfc2 is at the bottom of the table. */ /* mfhc2 is at the bottom of the table. */ /* mfc3 is at the bottom of the table. */ {"mfdr", "t,G", 0x7000003d, 0xffe007ff, LCD|WR_t|RD_C0, }, {"mfhi", "d", 0x00000010, 0xffff07ff, WR_d|RD_HI, }, {"mfhi", "d,9", 0x00000010, 0xff9f07ff, WR_d|RD_HI, }, {"mflo", "d", 0x00000012, 0xffff07ff, WR_d|RD_LO, }, {"mflo", "d,9", 0x00000012, 0xff9f07ff, WR_d|RD_LO, }, {"mflhxu", "d", 0x00000052, 0xffff07ff, WR_d|MOD_HILO, }, {"mfcr", "t,s", 0x70000018, 0xfc00ffff, WR_t, }, {"min.ob", "X,Y,Q", 0x78000006, 0xfc20003f, WR_D|RD_S|RD_T|FP_D, }, {"min.ob", "D,S,T", 0x4ac00006, 0xffe0003f, WR_D|RD_S|RD_T, }, {"min.ob", "D,S,T[e]", 0x48000006, 0xfe20003f, WR_D|RD_S|RD_T, }, {"min.ob", "D,S,k", 0x4bc00006, 0xffe0003f, WR_D|RD_S|RD_T, }, {"min.qh", "X,Y,Q", 0x78200006, 0xfc20003f, WR_D|RD_S|RD_T|FP_D, }, {"mov.d", "D,S", 0x46200006, 0xffff003f, WR_D|RD_S|FP_D, }, {"mov.s", "D,S", 0x46000006, 0xffff003f, WR_D|RD_S|FP_S, }, {"mov.ps", "D,S", 0x46c00006, 0xffff003f, WR_D|RD_S|FP_D, }, {"mov.ps", "D,S", 0x45600006, 0xffff003f, WR_D|RD_S|FP_D, }, {"movf", "d,s,N", 0x00000001, 0xfc0307ff, WR_d|RD_s|RD_CC|FP_S|FP_D, }, {"movf.d", "D,S,N", 0x46200011, 0xffe3003f, WR_D|RD_S|RD_CC|FP_D, }, {"movf.l", "D,S,N", 0x46a00011, 0xffe3003f, WR_D|RD_S|RD_CC|FP_D, }, {"movf.l", "X,Y,N", 0x46a00011, 0xffe3003f, WR_D|RD_S|RD_CC|FP_D, }, {"movf.s", "D,S,N", 0x46000011, 0xffe3003f, WR_D|RD_S|RD_CC|FP_S, }, {"movf.ps", "D,S,N", 0x46c00011, 0xffe3003f, WR_D|RD_S|RD_CC|FP_D, }, {"movn", "d,v,t", 0x0000000b, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"movnz", "d,v,t", 0x0000000b, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"ffc", "d,v", 0x0000000b, 0xfc1f07ff, WR_d|RD_s, }, {"movn.d", "D,S,t", 0x46200013, 0xffe0003f, WR_D|RD_S|RD_t|FP_D, }, {"movn.l", "D,S,t", 0x46a00013, 0xffe0003f, WR_D|RD_S|RD_t|FP_D, }, {"movn.l", "X,Y,t", 0x46a00013, 0xffe0003f, WR_D|RD_S|RD_t|FP_D, }, {"movn.s", "D,S,t", 0x46000013, 0xffe0003f, WR_D|RD_S|RD_t|FP_S, }, {"movn.ps", "D,S,t", 0x46c00013, 0xffe0003f, WR_D|RD_S|RD_t|FP_D, }, {"movt", "d,s,N", 0x00010001, 0xfc0307ff, WR_d|RD_s|RD_CC|FP_S|FP_D, }, {"movt.d", "D,S,N", 0x46210011, 0xffe3003f, WR_D|RD_S|RD_CC|FP_D, }, {"movt.l", "D,S,N", 0x46a10011, 0xffe3003f, WR_D|RD_S|RD_CC|FP_D, }, {"movt.l", "X,Y,N", 0x46a10011, 0xffe3003f, WR_D|RD_S|RD_CC|FP_D, }, {"movt.s", "D,S,N", 0x46010011, 0xffe3003f, WR_D|RD_S|RD_CC|FP_S, }, {"movt.ps", "D,S,N", 0x46c10011, 0xffe3003f, WR_D|RD_S|RD_CC|FP_D, }, {"movz", "d,v,t", 0x0000000a, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"ffs", "d,v", 0x0000000a, 0xfc1f07ff, WR_d|RD_s, }, {"movz.d", "D,S,t", 0x46200012, 0xffe0003f, WR_D|RD_S|RD_t|FP_D, }, {"movz.l", "D,S,t", 0x46a00012, 0xffe0003f, WR_D|RD_S|RD_t|FP_D, }, {"movz.l", "X,Y,t", 0x46a00012, 0xffe0003f, WR_D|RD_S|RD_t|FP_D, }, {"movz.s", "D,S,t", 0x46000012, 0xffe0003f, WR_D|RD_S|RD_t|FP_S, }, {"movz.ps", "D,S,t", 0x46c00012, 0xffe0003f, WR_D|RD_S|RD_t|FP_D, }, {"msac", "d,s,t", 0x000001d8, 0xfc0007ff, RD_s|RD_t|WR_HILO|WR_d, }, {"msacu", "d,s,t", 0x000001d9, 0xfc0007ff, RD_s|RD_t|WR_HILO|WR_d, }, {"msachi", "d,s,t", 0x000003d8, 0xfc0007ff, RD_s|RD_t|WR_HILO|WR_d, }, {"msachiu", "d,s,t", 0x000003d9, 0xfc0007ff, RD_s|RD_t|WR_HILO|WR_d, }, /* move is at the top of the table. */ {"msgn.qh", "X,Y,Q", 0x78200000, 0xfc20003f, WR_D|RD_S|RD_T|FP_D, }, {"msgsnd", "t", 0, (int) M_MSGSND, INSN_MACRO, }, {"msgld", "", 0, (int) M_MSGLD, INSN_MACRO, }, {"msgld", "t", 0, (int) M_MSGLD_T, INSN_MACRO, }, {"msgwait", "", 0, (int) M_MSGWAIT, INSN_MACRO, }, {"msgwait", "t", 0, (int) M_MSGWAIT_T,INSN_MACRO, }, {"msub.d", "D,R,S,T", 0x4c000029, 0xfc00003f, RD_R|RD_S|RD_T|WR_D|FP_D, }, {"msub.d", "D,S,T", 0x46200019, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"msub.d", "D,S,T", 0x72200019, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"msub.s", "D,R,S,T", 0x4c000028, 0xfc00003f, RD_R|RD_S|RD_T|WR_D|FP_S, }, {"msub.s", "D,S,T", 0x46000019, 0xffe0003f, RD_S|RD_T|WR_D|FP_S, }, {"msub.s", "D,S,T", 0x72000019, 0xffe0003f, RD_S|RD_T|WR_D|FP_S, }, {"msub.ps", "D,R,S,T", 0x4c00002e, 0xfc00003f, RD_R|RD_S|RD_T|WR_D|FP_D, }, {"msub.ps", "D,S,T", 0x45600019, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"msub.ps", "D,S,T", 0x71600019, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"msub", "s,t", 0x0000001e, 0xfc00ffff, RD_s|RD_t|WR_HILO, }, {"msub", "s,t", 0x70000004, 0xfc00ffff, RD_s|RD_t|MOD_HILO, }, {"msub", "7,s,t", 0x70000004, 0xfc00e7ff, MOD_a|RD_s|RD_t, }, {"msubu", "s,t", 0x0000001f, 0xfc00ffff, RD_s|RD_t|WR_HILO, }, {"msubu", "s,t", 0x70000005, 0xfc00ffff, RD_s|RD_t|MOD_HILO, }, {"msubu", "7,s,t", 0x70000005, 0xfc00e7ff, MOD_a|RD_s|RD_t, }, {"mtpc", "t,P", 0x4080c801, 0xffe0ffc1, COD|RD_t|WR_C0, }, {"mtps", "t,P", 0x4080c800, 0xffe0ffc1, COD|RD_t|WR_C0, }, {"mtc0", "t,G", 0x40800000, 0xffe007ff, COD|RD_t|WR_C0|WR_CC, }, {"mtc0", "t,+D", 0x40800000, 0xffe007f8, COD|RD_t|WR_C0|WR_CC, }, {"mtc0", "t,G,H", 0x40800000, 0xffe007f8, COD|RD_t|WR_C0|WR_CC, }, {"mtc1", "t,S", 0x44800000, 0xffe007ff, COD|RD_t|WR_S|FP_S, }, {"mtc1", "t,G", 0x44800000, 0xffe007ff, COD|RD_t|WR_S|FP_S, }, {"mthc1", "t,S", 0x44e00000, 0xffe007ff, COD|RD_t|WR_S|FP_D, }, {"mthc1", "t,G", 0x44e00000, 0xffe007ff, COD|RD_t|WR_S|FP_D, }, /* mtc2 is at the bottom of the table. */ /* mthc2 is at the bottom of the table. */ /* mtc3 is at the bottom of the table. */ {"mtdr", "t,G", 0x7080003d, 0xffe007ff, COD|RD_t|WR_C0, }, {"mthi", "s", 0x00000011, 0xfc1fffff, RD_s|WR_HI, }, {"mthi", "s,7", 0x00000011, 0xfc1fe7ff, RD_s|WR_HI, }, {"mtlo", "s", 0x00000013, 0xfc1fffff, RD_s|WR_LO, }, {"mtlo", "s,7", 0x00000013, 0xfc1fe7ff, RD_s|WR_LO, }, {"mtlhx", "s", 0x00000053, 0xfc1fffff, RD_s|MOD_HILO, }, {"mtcr", "t,s", 0x70000019, 0xfc00ffff, RD_t, }, {"mtm0", "s", 0x70000008, 0xfc1fffff, RD_s, }, {"mtm1", "s", 0x7000000c, 0xfc1fffff, RD_s, }, {"mtm2", "s", 0x7000000d, 0xfc1fffff, RD_s, }, {"mtp0", "s", 0x70000009, 0xfc1fffff, RD_s, }, {"mtp1", "s", 0x7000000a, 0xfc1fffff, RD_s, }, {"mtp2", "s", 0x7000000b, 0xfc1fffff, RD_s, }, {"mttc0", "t,G", 0x41800000, 0xffe007ff, TRAP|COD|RD_t|WR_C0|WR_CC, }, {"mttc0", "t,+D", 0x41800000, 0xffe007f8, TRAP|COD|RD_t|WR_C0|WR_CC, }, {"mttc0", "t,G,H", 0x41800000, 0xffe007f8, TRAP|COD|RD_t|WR_C0|WR_CC, }, {"mttc1", "t,S", 0x41800022, 0xffe007ff, TRAP|COD|RD_t|WR_S|FP_S, }, {"mttc1", "t,G", 0x41800022, 0xffe007ff, TRAP|COD|RD_t|WR_S|FP_S, }, {"mttc2", "t,g", 0x41800024, 0xffe007ff, TRAP|COD|RD_t|WR_C2|WR_CC, }, {"mttacx", "t", 0x41801021, 0xffe0ffff, TRAP|WR_a|RD_t, }, {"mttacx", "t,&", 0x41801021, 0xffe09fff, TRAP|WR_a|RD_t, }, {"mttdsp", "t", 0x41808021, 0xffe0ffff, TRAP|RD_t, }, {"mttgpr", "t,d", 0x41800020, 0xffe007ff, TRAP|WR_d|RD_t, }, {"mtthc1", "t,S", 0x41800032, 0xffe007ff, TRAP|COD|RD_t|WR_S|FP_D, }, {"mtthc1", "t,G", 0x41800032, 0xffe007ff, TRAP|COD|RD_t|WR_S|FP_D, }, {"mtthc2", "t,g", 0x41800034, 0xffe007ff, TRAP|COD|RD_t|WR_C2|WR_CC, }, {"mtthi", "t", 0x41800821, 0xffe0ffff, TRAP|WR_a|RD_t, }, {"mtthi", "t,&", 0x41800821, 0xffe09fff, TRAP|WR_a|RD_t, }, {"mttlo", "t", 0x41800021, 0xffe0ffff, TRAP|WR_a|RD_t, }, {"mttlo", "t,&", 0x41800021, 0xffe09fff, TRAP|WR_a|RD_t, }, {"mttr", "t,d,!,H,$", 0x41800000, 0xffe007c8, TRAP|RD_t, }, {"mul.d", "D,V,T", 0x46200002, 0xffe0003f, WR_D|RD_S|RD_T|FP_D, }, {"mul.s", "D,V,T", 0x46000002, 0xffe0003f, WR_D|RD_S|RD_T|FP_S, }, {"mul.ob", "X,Y,Q", 0x78000030, 0xfc20003f, WR_D|RD_S|RD_T|FP_D, }, {"mul.ob", "D,S,T", 0x4ac00030, 0xffe0003f, WR_D|RD_S|RD_T, }, {"mul.ob", "D,S,T[e]", 0x48000030, 0xfe20003f, WR_D|RD_S|RD_T, }, {"mul.ob", "D,S,k", 0x4bc00030, 0xffe0003f, WR_D|RD_S|RD_T, }, {"mul.ps", "D,V,T", 0x46c00002, 0xffe0003f, WR_D|RD_S|RD_T|FP_D, }, {"mul.ps", "D,V,T", 0x45600002, 0xffe0003f, WR_D|RD_S|RD_T|FP_D, }, {"mul.qh", "X,Y,Q", 0x78200030, 0xfc20003f, WR_D|RD_S|RD_T|FP_D, }, {"mul", "d,v,t", 0x70000002, 0xfc0007ff, WR_d|RD_s|RD_t|WR_HILO, }, {"mul", "d,s,t", 0x00000058, 0xfc0007ff, RD_s|RD_t|WR_HILO|WR_d, }, {"mul", "d,v,t", 0, (int) M_MUL, INSN_MACRO, }, {"mul", "d,v,I", 0, (int) M_MUL_I, INSN_MACRO, }, {"mula.ob", "Y,Q", 0x78000033, 0xfc2007ff, RD_S|RD_T|FP_D, WR_MACC, }, {"mula.ob", "S,T", 0x4ac00033, 0xffe007ff, WR_CC|RD_S|RD_T, }, {"mula.ob", "S,T[e]", 0x48000033, 0xfe2007ff, WR_CC|RD_S|RD_T, }, {"mula.ob", "S,k", 0x4bc00033, 0xffe007ff, WR_CC|RD_S|RD_T, }, {"mula.qh", "Y,Q", 0x78200033, 0xfc2007ff, RD_S|RD_T|FP_D, WR_MACC, }, {"mulhi", "d,s,t", 0x00000258, 0xfc0007ff, RD_s|RD_t|WR_HILO|WR_d, }, {"mulhiu", "d,s,t", 0x00000259, 0xfc0007ff, RD_s|RD_t|WR_HILO|WR_d, }, {"mull.ob", "Y,Q", 0x78000433, 0xfc2007ff, RD_S|RD_T|FP_D, WR_MACC, }, {"mull.ob", "S,T", 0x4ac00433, 0xffe007ff, WR_CC|RD_S|RD_T, }, {"mull.ob", "S,T[e]", 0x48000433, 0xfe2007ff, WR_CC|RD_S|RD_T, }, {"mull.ob", "S,k", 0x4bc00433, 0xffe007ff, WR_CC|RD_S|RD_T, }, {"mull.qh", "Y,Q", 0x78200433, 0xfc2007ff, RD_S|RD_T|FP_D, WR_MACC, }, {"mulo", "d,v,t", 0, (int) M_MULO, INSN_MACRO, }, {"mulo", "d,v,I", 0, (int) M_MULO_I, INSN_MACRO, }, {"mulou", "d,v,t", 0, (int) M_MULOU, INSN_MACRO, }, {"mulou", "d,v,I", 0, (int) M_MULOU_I, INSN_MACRO, }, {"mulr.ps", "D,S,T", 0x46c0001a, 0xffe0003f, WR_D|RD_S|RD_T|FP_D, }, {"muls", "d,s,t", 0x000000d8, 0xfc0007ff, RD_s|RD_t|WR_HILO|WR_d, }, {"mulsu", "d,s,t", 0x000000d9, 0xfc0007ff, RD_s|RD_t|WR_HILO|WR_d, }, {"mulshi", "d,s,t", 0x000002d8, 0xfc0007ff, RD_s|RD_t|WR_HILO|WR_d, }, {"mulshiu", "d,s,t", 0x000002d9, 0xfc0007ff, RD_s|RD_t|WR_HILO|WR_d, }, {"muls.ob", "Y,Q", 0x78000032, 0xfc2007ff, RD_S|RD_T|FP_D, WR_MACC, }, {"muls.ob", "S,T", 0x4ac00032, 0xffe007ff, WR_CC|RD_S|RD_T, }, {"muls.ob", "S,T[e]", 0x48000032, 0xfe2007ff, WR_CC|RD_S|RD_T, }, {"muls.ob", "S,k", 0x4bc00032, 0xffe007ff, WR_CC|RD_S|RD_T, }, {"muls.qh", "Y,Q", 0x78200032, 0xfc2007ff, RD_S|RD_T|FP_D, WR_MACC, }, {"mulsl.ob", "Y,Q", 0x78000432, 0xfc2007ff, RD_S|RD_T|FP_D, WR_MACC, }, {"mulsl.ob", "S,T", 0x4ac00432, 0xffe007ff, WR_CC|RD_S|RD_T, }, {"mulsl.ob", "S,T[e]", 0x48000432, 0xfe2007ff, WR_CC|RD_S|RD_T, }, {"mulsl.ob", "S,k", 0x4bc00432, 0xffe007ff, WR_CC|RD_S|RD_T, }, {"mulsl.qh", "Y,Q", 0x78200432, 0xfc2007ff, RD_S|RD_T|FP_D, WR_MACC, }, {"mult", "s,t", 0x00000018, 0xfc00ffff, RD_s|RD_t|WR_HILO|IS_M, }, {"mult", "7,s,t", 0x00000018, 0xfc00e7ff, WR_a|RD_s|RD_t, }, {"mult", "d,s,t", 0x00000018, 0xfc0007ff, RD_s|RD_t|WR_HILO|WR_d|IS_M, }, {"multp", "s,t", 0x00000459, 0xfc00ffff, RD_s|RD_t|MOD_HILO, }, {"multu", "s,t", 0x00000019, 0xfc00ffff, RD_s|RD_t|WR_HILO|IS_M, }, {"multu", "7,s,t", 0x00000019, 0xfc00e7ff, WR_a|RD_s|RD_t, }, {"multu", "d,s,t", 0x00000019, 0xfc0007ff, RD_s|RD_t|WR_HILO|WR_d|IS_M, }, {"mulu", "d,s,t", 0x00000059, 0xfc0007ff, RD_s|RD_t|WR_HILO|WR_d, }, {"neg", "d,w", 0x00000022, 0xffe007ff, WR_d|RD_t, }, /* sub 0 */ {"negu", "d,w", 0x00000023, 0xffe007ff, WR_d|RD_t, }, /* subu 0 */ {"neg.d", "D,V", 0x46200007, 0xffff003f, WR_D|RD_S|FP_D, }, {"neg.s", "D,V", 0x46000007, 0xffff003f, WR_D|RD_S|FP_S, }, {"neg.ps", "D,V", 0x46c00007, 0xffff003f, WR_D|RD_S|FP_D, }, {"neg.ps", "D,V", 0x45600007, 0xffff003f, WR_D|RD_S|FP_D, }, {"nmadd.d", "D,R,S,T", 0x4c000031, 0xfc00003f, RD_R|RD_S|RD_T|WR_D|FP_D, }, {"nmadd.d", "D,S,T", 0x4620001a, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"nmadd.d", "D,S,T", 0x7220001a, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"nmadd.s", "D,R,S,T", 0x4c000030, 0xfc00003f, RD_R|RD_S|RD_T|WR_D|FP_S, }, {"nmadd.s", "D,S,T", 0x4600001a, 0xffe0003f, RD_S|RD_T|WR_D|FP_S, }, {"nmadd.s", "D,S,T", 0x7200001a, 0xffe0003f, RD_S|RD_T|WR_D|FP_S, }, {"nmadd.ps","D,R,S,T", 0x4c000036, 0xfc00003f, RD_R|RD_S|RD_T|WR_D|FP_D, }, {"nmadd.ps","D,S,T", 0x4560001a, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"nmadd.ps","D,S,T", 0x7160001a, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"nmsub.d", "D,R,S,T", 0x4c000039, 0xfc00003f, RD_R|RD_S|RD_T|WR_D|FP_D, }, {"nmsub.d", "D,S,T", 0x4620001b, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"nmsub.d", "D,S,T", 0x7220001b, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"nmsub.s", "D,R,S,T", 0x4c000038, 0xfc00003f, RD_R|RD_S|RD_T|WR_D|FP_S, }, {"nmsub.s", "D,S,T", 0x4600001b, 0xffe0003f, RD_S|RD_T|WR_D|FP_S, }, {"nmsub.s", "D,S,T", 0x7200001b, 0xffe0003f, RD_S|RD_T|WR_D|FP_S, }, {"nmsub.ps","D,R,S,T", 0x4c00003e, 0xfc00003f, RD_R|RD_S|RD_T|WR_D|FP_D, }, {"nmsub.ps","D,S,T", 0x4560001b, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"nmsub.ps","D,S,T", 0x7160001b, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, /* nop is at the start of the table. */ {"nor", "d,v,t", 0x00000027, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"nor", "t,r,I", 0, (int) M_NOR_I, INSN_MACRO, }, {"nor", "D,S,T", 0x47a00002, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"nor", "D,S,T", 0x4ba00002, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"nor.ob", "X,Y,Q", 0x7800000f, 0xfc20003f, WR_D|RD_S|RD_T|FP_D, }, {"nor.ob", "D,S,T", 0x4ac0000f, 0xffe0003f, WR_D|RD_S|RD_T, }, {"nor.ob", "D,S,T[e]", 0x4800000f, 0xfe20003f, WR_D|RD_S|RD_T, }, {"nor.ob", "D,S,k", 0x4bc0000f, 0xffe0003f, WR_D|RD_S|RD_T, }, {"nor.qh", "X,Y,Q", 0x7820000f, 0xfc20003f, WR_D|RD_S|RD_T|FP_D, }, {"not", "d,v", 0x00000027, 0xfc1f07ff, WR_d|RD_s|RD_t, },/*nor d,s,0*/ {"or", "d,v,t", 0x00000025, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"or", "t,r,I", 0, (int) M_OR_I, INSN_MACRO, }, {"or", "D,S,T", 0x45a00000, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"or", "D,S,T", 0x4b20000c, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"or.ob", "X,Y,Q", 0x7800000e, 0xfc20003f, WR_D|RD_S|RD_T|FP_D, }, {"or.ob", "D,S,T", 0x4ac0000e, 0xffe0003f, WR_D|RD_S|RD_T, }, {"or.ob", "D,S,T[e]", 0x4800000e, 0xfe20003f, WR_D|RD_S|RD_T, }, {"or.ob", "D,S,k", 0x4bc0000e, 0xffe0003f, WR_D|RD_S|RD_T, }, {"or.qh", "X,Y,Q", 0x7820000e, 0xfc20003f, WR_D|RD_S|RD_T|FP_D, }, {"ori", "t,r,i", 0x34000000, 0xfc000000, WR_t|RD_s, }, {"pabsdiff.ob", "X,Y,Q",0x78000009, 0xfc20003f, WR_D|RD_S|RD_T|FP_D, }, {"pabsdiffc.ob", "Y,Q", 0x78000035, 0xfc2007ff, RD_S|RD_T|FP_D, WR_MACC, }, {"pavg.ob", "X,Y,Q", 0x78000008, 0xfc20003f, WR_D|RD_S|RD_T|FP_D, }, {"pickf.ob", "X,Y,Q", 0x78000002, 0xfc20003f, WR_D|RD_S|RD_T|FP_D, }, {"pickf.ob", "D,S,T", 0x4ac00002, 0xffe0003f, WR_D|RD_S|RD_T, }, {"pickf.ob", "D,S,T[e]",0x48000002, 0xfe20003f, WR_D|RD_S|RD_T, }, {"pickf.ob", "D,S,k", 0x4bc00002, 0xffe0003f, WR_D|RD_S|RD_T, }, {"pickf.qh", "X,Y,Q", 0x78200002, 0xfc20003f, WR_D|RD_S|RD_T|FP_D, }, {"pickt.ob", "X,Y,Q", 0x78000003, 0xfc20003f, WR_D|RD_S|RD_T|FP_D, }, {"pickt.ob", "D,S,T", 0x4ac00003, 0xffe0003f, WR_D|RD_S|RD_T, }, {"pickt.ob", "D,S,T[e]",0x48000003, 0xfe20003f, WR_D|RD_S|RD_T, }, {"pickt.ob", "D,S,k", 0x4bc00003, 0xffe0003f, WR_D|RD_S|RD_T, }, {"pickt.qh", "X,Y,Q", 0x78200003, 0xfc20003f, WR_D|RD_S|RD_T|FP_D, }, {"pll.ps", "D,V,T", 0x46c0002c, 0xffe0003f, WR_D|RD_S|RD_T|FP_D, }, {"plu.ps", "D,V,T", 0x46c0002d, 0xffe0003f, WR_D|RD_S|RD_T|FP_D, }, {"pop", "d,v", 0x7000002c, 0xfc1f07ff, WR_d|RD_s, }, /* pref and prefx are at the start of the table. */ {"pul.ps", "D,V,T", 0x46c0002e, 0xffe0003f, WR_D|RD_S|RD_T|FP_D, }, {"puu.ps", "D,V,T", 0x46c0002f, 0xffe0003f, WR_D|RD_S|RD_T|FP_D, }, {"pperm", "s,t", 0x70000481, 0xfc00ffff, MOD_HILO|RD_s|RD_t, }, {"rach.ob", "X", 0x7a00003f, 0xfffff83f, WR_D|FP_D, RD_MACC, }, {"rach.ob", "D", 0x4a00003f, 0xfffff83f, WR_D, }, {"rach.qh", "X", 0x7a20003f, 0xfffff83f, WR_D|FP_D, RD_MACC, }, {"racl.ob", "X", 0x7800003f, 0xfffff83f, WR_D|FP_D, RD_MACC, }, {"racl.ob", "D", 0x4800003f, 0xfffff83f, WR_D, }, {"racl.qh", "X", 0x7820003f, 0xfffff83f, WR_D|FP_D, RD_MACC, }, {"racm.ob", "X", 0x7900003f, 0xfffff83f, WR_D|FP_D, RD_MACC, }, {"racm.ob", "D", 0x4900003f, 0xfffff83f, WR_D, }, {"racm.qh", "X", 0x7920003f, 0xfffff83f, WR_D|FP_D, RD_MACC, }, {"recip.d", "D,S", 0x46200015, 0xffff003f, WR_D|RD_S|FP_D, }, {"recip.ps","D,S", 0x46c00015, 0xffff003f, WR_D|RD_S|FP_D, }, {"recip.s", "D,S", 0x46000015, 0xffff003f, WR_D|RD_S|FP_S, }, {"recip1.d", "D,S", 0x4620001d, 0xffff003f, WR_D|RD_S|FP_D, }, {"recip1.ps", "D,S", 0x46c0001d, 0xffff003f, WR_D|RD_S|FP_S, }, {"recip1.s", "D,S", 0x4600001d, 0xffff003f, WR_D|RD_S|FP_S, }, {"recip2.d", "D,S,T", 0x4620001c, 0xffe0003f, WR_D|RD_S|RD_T|FP_D, }, {"recip2.ps", "D,S,T", 0x46c0001c, 0xffe0003f, WR_D|RD_S|RD_T|FP_S, }, {"recip2.s", "D,S,T", 0x4600001c, 0xffe0003f, WR_D|RD_S|RD_T|FP_S, }, {"rem", "z,s,t", 0x0000001a, 0xfc00ffff, RD_s|RD_t|WR_HILO, }, {"rem", "d,v,t", 0, (int) M_REM_3, INSN_MACRO, }, {"rem", "d,v,I", 0, (int) M_REM_3I, INSN_MACRO, }, {"remu", "z,s,t", 0x0000001b, 0xfc00ffff, RD_s|RD_t|WR_HILO, }, {"remu", "d,v,t", 0, (int) M_REMU_3, INSN_MACRO, }, {"remu", "d,v,I", 0, (int) M_REMU_3I, INSN_MACRO, }, {"rdhwr", "t,K", 0x7c00003b, 0xffe007ff, WR_t, }, {"rdpgpr", "d,w", 0x41400000, 0xffe007ff, WR_d, }, {"rfe", "", 0x42000010, 0xffffffff, 0, }, {"rnas.qh", "X,Q", 0x78200025, 0xfc20f83f, WR_D|RD_T|FP_D, RD_MACC, }, {"rnau.ob", "X,Q", 0x78000021, 0xfc20f83f, WR_D|RD_T|FP_D, RD_MACC, }, {"rnau.qh", "X,Q", 0x78200021, 0xfc20f83f, WR_D|RD_T|FP_D, RD_MACC, }, {"rnes.qh", "X,Q", 0x78200026, 0xfc20f83f, WR_D|RD_T|FP_D, RD_MACC, }, {"rneu.ob", "X,Q", 0x78000022, 0xfc20f83f, WR_D|RD_T|FP_D, RD_MACC, }, {"rneu.qh", "X,Q", 0x78200022, 0xfc20f83f, WR_D|RD_T|FP_D, RD_MACC, }, {"rol", "d,v,t", 0, (int) M_ROL, INSN_MACRO, }, {"rol", "d,v,I", 0, (int) M_ROL_I, INSN_MACRO, }, {"ror", "d,v,t", 0, (int) M_ROR, INSN_MACRO, }, {"ror", "d,v,I", 0, (int) M_ROR_I, INSN_MACRO, }, {"ror", "d,w,<", 0x00200002, 0xffe0003f, WR_d|RD_t, }, {"rorv", "d,t,s", 0x00000046, 0xfc0007ff, RD_t|RD_s|WR_d, }, {"rotl", "d,v,t", 0, (int) M_ROL, INSN_MACRO, }, {"rotl", "d,v,I", 0, (int) M_ROL_I, INSN_MACRO, }, {"ror", "d,v,t", 0, (int) M_ROR, INSN_MACRO, }, {"ror", "d,v,I", 0, (int) M_ROR_I, INSN_MACRO, }, {"rorv", "d,t,s", 0x00000046, 0xfc0007ff, RD_t|RD_s|WR_d, }, {"round.l.d", "D,S", 0x46200008, 0xffff003f, WR_D|RD_S|FP_D, }, {"round.l.s", "D,S", 0x46000008, 0xffff003f, WR_D|RD_S|FP_S|FP_D, }, {"round.w.d", "D,S", 0x4620000c, 0xffff003f, WR_D|RD_S|FP_S|FP_D, }, {"round.w.s", "D,S", 0x4600000c, 0xffff003f, WR_D|RD_S|FP_S, }, {"rsqrt.d", "D,S", 0x46200016, 0xffff003f, WR_D|RD_S|FP_D, }, {"rsqrt.ps","D,S", 0x46c00016, 0xffff003f, WR_D|RD_S|FP_D, }, {"rsqrt.s", "D,S", 0x46000016, 0xffff003f, WR_D|RD_S|FP_S, }, {"rsqrt1.d", "D,S", 0x4620001e, 0xffff003f, WR_D|RD_S|FP_D, }, {"rsqrt1.ps", "D,S", 0x46c0001e, 0xffff003f, WR_D|RD_S|FP_S, }, {"rsqrt1.s", "D,S", 0x4600001e, 0xffff003f, WR_D|RD_S|FP_S, }, {"rsqrt2.d", "D,S,T", 0x4620001f, 0xffe0003f, WR_D|RD_S|RD_T|FP_D, }, {"rsqrt2.ps", "D,S,T", 0x46c0001f, 0xffe0003f, WR_D|RD_S|RD_T|FP_S, }, {"rsqrt2.s", "D,S,T", 0x4600001f, 0xffe0003f, WR_D|RD_S|RD_T|FP_S, }, {"rzs.qh", "X,Q", 0x78200024, 0xfc20f83f, WR_D|RD_T|FP_D, RD_MACC, }, {"rzu.ob", "X,Q", 0x78000020, 0xfc20f83f, WR_D|RD_T|FP_D, RD_MACC, }, {"rzu.ob", "D,k", 0x4bc00020, 0xffe0f83f, WR_D|RD_S|RD_T, }, {"rzu.qh", "X,Q", 0x78200020, 0xfc20f83f, WR_D|RD_T|FP_D, RD_MACC, }, {"sb", "t,o(b)", 0xa0000000, 0xfc000000, SM|RD_t|RD_b, }, {"sb", "t,A(b)", 0, (int) M_SB_AB, INSN_MACRO, }, {"sc", "t,o(b)", 0xe0000000, 0xfc000000, SM|RD_t|WR_t|RD_b, }, {"sc", "t,A(b)", 0, (int) M_SC_AB, INSN_MACRO, }, {"scd", "t,o(b)", 0xf0000000, 0xfc000000, SM|RD_t|WR_t|RD_b, }, {"scd", "t,A(b)", 0, (int) M_SCD_AB, INSN_MACRO, }, /* The macro has to be first to handle o32 correctly. */ {"sd", "t,o(b)", 0, (int) M_SD_OB, INSN_MACRO, }, {"sd", "t,o(b)", 0xfc000000, 0xfc000000, SM|RD_t|RD_b, }, {"sd", "t,A(b)", 0, (int) M_SD_AB, INSN_MACRO, }, {"sdbbp", "", 0x0000000e, 0xffffffff, TRAP, }, {"sdbbp", "c", 0x0000000e, 0xfc00ffff, TRAP, }, {"sdbbp", "c,q", 0x0000000e, 0xfc00003f, TRAP, }, {"sdbbp", "", 0x7000003f, 0xffffffff, TRAP, }, {"sdbbp", "B", 0x7000003f, 0xfc00003f, TRAP, }, {"sdc1", "T,o(b)", 0xf4000000, 0xfc000000, SM|RD_T|RD_b|FP_D, }, {"sdc1", "E,o(b)", 0xf4000000, 0xfc000000, SM|RD_T|RD_b|FP_D, }, {"sdc1", "T,A(b)", 0, (int) M_SDC1_AB, INSN_MACRO, INSN2_M_FP_D, }, {"sdc1", "E,A(b)", 0, (int) M_SDC1_AB, INSN_MACRO, INSN2_M_FP_D, }, {"sdc2", "E,o(b)", 0xf8000000, 0xfc000000, SM|RD_C2|RD_b, }, {"sdc2", "E,A(b)", 0, (int) M_SDC2_AB, INSN_MACRO, }, {"sdc3", "E,o(b)", 0xfc000000, 0xfc000000, SM|RD_C3|RD_b, }, {"sdc3", "E,A(b)", 0, (int) M_SDC3_AB, INSN_MACRO, }, {"s.d", "T,o(b)", 0xf4000000, 0xfc000000, SM|RD_T|RD_b|FP_D, }, {"s.d", "T,o(b)", 0, (int) M_S_DOB, INSN_MACRO, INSN2_M_FP_D, }, {"s.d", "T,A(b)", 0, (int) M_S_DAB, INSN_MACRO, INSN2_M_FP_D, }, {"sdl", "t,o(b)", 0xb0000000, 0xfc000000, SM|RD_t|RD_b, }, {"sdl", "t,A(b)", 0, (int) M_SDL_AB, INSN_MACRO, }, {"sdr", "t,o(b)", 0xb4000000, 0xfc000000, SM|RD_t|RD_b, }, {"sdr", "t,A(b)", 0, (int) M_SDR_AB, INSN_MACRO, }, {"sdxc1", "S,t(b)", 0x4c000009, 0xfc0007ff, SM|RD_S|RD_t|RD_b|FP_D, }, {"seb", "d,w", 0x7c000420, 0xffe007ff, WR_d|RD_t, }, {"seh", "d,w", 0x7c000620, 0xffe007ff, WR_d|RD_t, }, {"selsl", "d,v,t", 0x00000005, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"selsr", "d,v,t", 0x00000001, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"seq", "d,v,t", 0x7000002a, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"seq", "d,v,t", 0, (int) M_SEQ, INSN_MACRO, }, {"seq", "d,v,I", 0, (int) M_SEQ_I, INSN_MACRO, }, {"seq", "S,T", 0x46a00032, 0xffe007ff, RD_S|RD_T|WR_CC|FP_D, }, {"seq", "S,T", 0x4ba0000c, 0xffe007ff, RD_S|RD_T|WR_CC|FP_D, }, {"seqi", "t,r,+Q", 0x7000002e, 0xfc00003f, WR_t|RD_s, }, {"sge", "d,v,t", 0, (int) M_SGE, INSN_MACRO, }, {"sge", "d,v,I", 0, (int) M_SGE_I, INSN_MACRO, }, {"sgeu", "d,v,t", 0, (int) M_SGEU, INSN_MACRO, }, {"sgeu", "d,v,I", 0, (int) M_SGEU_I, INSN_MACRO, }, {"sgt", "d,v,t", 0, (int) M_SGT, INSN_MACRO, }, {"sgt", "d,v,I", 0, (int) M_SGT_I, INSN_MACRO, }, {"sgtu", "d,v,t", 0, (int) M_SGTU, INSN_MACRO, }, {"sgtu", "d,v,I", 0, (int) M_SGTU_I, INSN_MACRO, }, {"sh", "t,o(b)", 0xa4000000, 0xfc000000, SM|RD_t|RD_b, }, {"sh", "t,A(b)", 0, (int) M_SH_AB, INSN_MACRO, }, {"shfl.bfla.qh", "X,Y,Z", 0x7a20001f, 0xffe0003f, WR_D|RD_S|RD_T|FP_D, }, {"shfl.mixh.ob", "X,Y,Z", 0x7980001f, 0xffe0003f, WR_D|RD_S|RD_T|FP_D, }, {"shfl.mixh.ob", "D,S,T", 0x4980001f, 0xffe0003f, WR_D|RD_S|RD_T, }, {"shfl.mixh.qh", "X,Y,Z", 0x7820001f, 0xffe0003f, WR_D|RD_S|RD_T|FP_D, }, {"shfl.mixl.ob", "X,Y,Z", 0x79c0001f, 0xffe0003f, WR_D|RD_S|RD_T|FP_D, }, {"shfl.mixl.ob", "D,S,T", 0x49c0001f, 0xffe0003f, WR_D|RD_S|RD_T, }, {"shfl.mixl.qh", "X,Y,Z", 0x78a0001f, 0xffe0003f, WR_D|RD_S|RD_T|FP_D, }, {"shfl.pach.ob", "X,Y,Z", 0x7900001f, 0xffe0003f, WR_D|RD_S|RD_T|FP_D, }, {"shfl.pach.ob", "D,S,T", 0x4900001f, 0xffe0003f, WR_D|RD_S|RD_T, }, {"shfl.pach.qh", "X,Y,Z", 0x7920001f, 0xffe0003f, WR_D|RD_S|RD_T|FP_D, }, {"shfl.pacl.ob", "D,S,T", 0x4940001f, 0xffe0003f, WR_D|RD_S|RD_T, }, {"shfl.repa.qh", "X,Y,Z", 0x7b20001f, 0xffe0003f, WR_D|RD_S|RD_T|FP_D, }, {"shfl.repb.qh", "X,Y,Z", 0x7ba0001f, 0xffe0003f, WR_D|RD_S|RD_T|FP_D, }, {"shfl.upsl.ob", "X,Y,Z", 0x78c0001f, 0xffe0003f, WR_D|RD_S|RD_T|FP_D, }, {"sle", "d,v,t", 0, (int) M_SLE, INSN_MACRO, }, {"sle", "d,v,I", 0, (int) M_SLE_I, INSN_MACRO, }, {"sle", "S,T", 0x46a0003e, 0xffe007ff, RD_S|RD_T|WR_CC|FP_D, }, {"sle", "S,T", 0x4ba0000e, 0xffe007ff, RD_S|RD_T|WR_CC|FP_D, }, {"sleu", "d,v,t", 0, (int) M_SLEU, INSN_MACRO, }, {"sleu", "d,v,I", 0, (int) M_SLEU_I, INSN_MACRO, }, {"sleu", "S,T", 0x4680003e, 0xffe007ff, RD_S|RD_T|WR_CC|FP_D, }, {"sleu", "S,T", 0x4b80000e, 0xffe007ff, RD_S|RD_T|WR_CC|FP_D, }, {"sllv", "d,t,s", 0x00000004, 0xfc0007ff, WR_d|RD_t|RD_s, }, {"sll", "d,w,s", 0x00000004, 0xfc0007ff, WR_d|RD_t|RD_s, }, /* sllv */ {"sll", "d,w,<", 0x00000000, 0xffe0003f, WR_d|RD_t, }, {"sll", "D,S,T", 0x45800002, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"sll", "D,S,T", 0x4b00000e, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"sll.ob", "X,Y,Q", 0x78000010, 0xfc20003f, WR_D|RD_S|RD_T|FP_D, }, {"sll.ob", "D,S,T[e]", 0x48000010, 0xfe20003f, WR_D|RD_S|RD_T, }, {"sll.ob", "D,S,k", 0x4bc00010, 0xffe0003f, WR_D|RD_S|RD_T, }, {"sll.qh", "X,Y,Q", 0x78200010, 0xfc20003f, WR_D|RD_S|RD_T|FP_D, }, {"slt", "d,v,t", 0x0000002a, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"slt", "d,v,I", 0, (int) M_SLT_I, INSN_MACRO, }, {"slt", "S,T", 0x46a0003c, 0xffe007ff, RD_S|RD_T|WR_CC|FP_D, }, {"slt", "S,T", 0x4ba0000d, 0xffe007ff, RD_S|RD_T|WR_CC|FP_D, }, {"slti", "t,r,j", 0x28000000, 0xfc000000, WR_t|RD_s, }, {"sltiu", "t,r,j", 0x2c000000, 0xfc000000, WR_t|RD_s, }, {"sltu", "d,v,t", 0x0000002b, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"sltu", "d,v,I", 0, (int) M_SLTU_I, INSN_MACRO, }, {"sltu", "S,T", 0x4680003c, 0xffe007ff, RD_S|RD_T|WR_CC|FP_D, }, {"sltu", "S,T", 0x4b80000d, 0xffe007ff, RD_S|RD_T|WR_CC|FP_D, }, {"sne", "d,v,t", 0x7000002b, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"sne", "d,v,t", 0, (int) M_SNE, INSN_MACRO, }, {"sne", "d,v,I", 0, (int) M_SNE_I, INSN_MACRO, }, {"snei", "t,r,+Q", 0x7000002f, 0xfc00003f, WR_t|RD_s, }, {"sqrt.d", "D,S", 0x46200004, 0xffff003f, WR_D|RD_S|FP_D, }, {"sqrt.s", "D,S", 0x46000004, 0xffff003f, WR_D|RD_S|FP_S, }, {"sqrt.ps", "D,S", 0x46c00004, 0xffff003f, WR_D|RD_S|FP_D, }, {"srav", "d,t,s", 0x00000007, 0xfc0007ff, WR_d|RD_t|RD_s, }, {"sra", "d,w,s", 0x00000007, 0xfc0007ff, WR_d|RD_t|RD_s, }, /* srav */ {"sra", "d,w,<", 0x00000003, 0xffe0003f, WR_d|RD_t, }, {"sra", "D,S,T", 0x45c00003, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"sra", "D,S,T", 0x4b40000f, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"sra.qh", "X,Y,Q", 0x78200013, 0xfc20003f, WR_D|RD_S|RD_T|FP_D, }, {"srlv", "d,t,s", 0x00000006, 0xfc0007ff, WR_d|RD_t|RD_s, }, {"srl", "d,w,s", 0x00000006, 0xfc0007ff, WR_d|RD_t|RD_s, }, /* srlv */ {"srl", "d,w,<", 0x00000002, 0xffe0003f, WR_d|RD_t, }, {"srl", "D,S,T", 0x45800003, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"srl", "D,S,T", 0x4b00000f, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"srl.ob", "X,Y,Q", 0x78000012, 0xfc20003f, WR_D|RD_S|RD_T|FP_D, }, {"srl.ob", "D,S,T[e]", 0x48000012, 0xfe20003f, WR_D|RD_S|RD_T, }, {"srl.ob", "D,S,k", 0x4bc00012, 0xffe0003f, WR_D|RD_S|RD_T, }, {"srl.qh", "X,Y,Q", 0x78200012, 0xfc20003f, WR_D|RD_S|RD_T|FP_D, }, /* ssnop is at the start of the table. */ {"standby", "", 0x42000021, 0xffffffff, 0, }, {"sub", "d,v,t", 0x00000022, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"sub", "d,v,I", 0, (int) M_SUB_I, INSN_MACRO, }, {"sub", "D,S,T", 0x45c00001, 0xffe0003f, RD_S|RD_T|WR_D|FP_S, }, {"sub", "D,S,T", 0x4b40000d, 0xffe0003f, RD_S|RD_T|WR_D|FP_S, }, {"sub.d", "D,V,T", 0x46200001, 0xffe0003f, WR_D|RD_S|RD_T|FP_D, }, {"sub.s", "D,V,T", 0x46000001, 0xffe0003f, WR_D|RD_S|RD_T|FP_S, }, {"sub.ob", "X,Y,Q", 0x7800000a, 0xfc20003f, WR_D|RD_S|RD_T|FP_D, }, {"sub.ob", "D,S,T", 0x4ac0000a, 0xffe0003f, WR_D|RD_S|RD_T, }, {"sub.ob", "D,S,T[e]", 0x4800000a, 0xfe20003f, WR_D|RD_S|RD_T, }, {"sub.ob", "D,S,k", 0x4bc0000a, 0xffe0003f, WR_D|RD_S|RD_T, }, {"sub.ps", "D,V,T", 0x46c00001, 0xffe0003f, WR_D|RD_S|RD_T|FP_D, }, {"sub.ps", "D,V,T", 0x45600001, 0xffe0003f, WR_D|RD_S|RD_T|FP_D, }, {"sub.qh", "X,Y,Q", 0x7820000a, 0xfc20003f, WR_D|RD_S|RD_T|FP_D, }, {"suba.ob", "Y,Q", 0x78000036, 0xfc2007ff, RD_S|RD_T|FP_D, WR_MACC, }, {"suba.qh", "Y,Q", 0x78200036, 0xfc2007ff, RD_S|RD_T|FP_D, WR_MACC, }, {"subl.ob", "Y,Q", 0x78000436, 0xfc2007ff, RD_S|RD_T|FP_D, WR_MACC, }, {"subl.qh", "Y,Q", 0x78200436, 0xfc2007ff, RD_S|RD_T|FP_D, WR_MACC, }, {"subu", "d,v,t", 0x00000023, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"subu", "d,v,I", 0, (int) M_SUBU_I, INSN_MACRO, }, {"subu", "D,S,T", 0x45800001, 0xffe0003f, RD_S|RD_T|WR_D|FP_S, }, {"subu", "D,S,T", 0x4b00000d, 0xffe0003f, RD_S|RD_T|WR_D|FP_S, }, {"suspend", "", 0x42000022, 0xffffffff, 0, }, {"suxc1", "S,t(b)", 0x4c00000d, 0xfc0007ff, SM|RD_S|RD_t|RD_b|FP_D, }, {"sw", "t,o(b)", 0xac000000, 0xfc000000, SM|RD_t|RD_b, }, {"sw", "t,A(b)", 0, (int) M_SW_AB, INSN_MACRO, }, {"swapw", "t,b", 0x70000014, 0xfc00ffff, SM|RD_t|WR_t|RD_b, }, {"swapwu", "t,b", 0x70000015, 0xfc00ffff, SM|RD_t|WR_t|RD_b, }, {"swapd", "t,b", 0x70000016, 0xfc00ffff, SM|RD_t|WR_t|RD_b, }, {"swc0", "E,o(b)", 0xe0000000, 0xfc000000, SM|RD_C0|RD_b, }, {"swc0", "E,A(b)", 0, (int) M_SWC0_AB, INSN_MACRO, }, {"swc1", "T,o(b)", 0xe4000000, 0xfc000000, SM|RD_T|RD_b|FP_S, }, {"swc1", "E,o(b)", 0xe4000000, 0xfc000000, SM|RD_T|RD_b|FP_S, }, {"swc1", "T,A(b)", 0, (int) M_SWC1_AB, INSN_MACRO, INSN2_M_FP_S, }, {"swc1", "E,A(b)", 0, (int) M_SWC1_AB, INSN_MACRO, INSN2_M_FP_S, }, {"s.s", "T,o(b)", 0xe4000000, 0xfc000000, SM|RD_T|RD_b|FP_S, }, /* swc1 */ {"s.s", "T,A(b)", 0, (int) M_SWC1_AB, INSN_MACRO, INSN2_M_FP_S, }, {"swc2", "E,o(b)", 0xe8000000, 0xfc000000, SM|RD_C2|RD_b, }, {"swc2", "E,A(b)", 0, (int) M_SWC2_AB, INSN_MACRO, }, {"swc3", "E,o(b)", 0xec000000, 0xfc000000, SM|RD_C3|RD_b, }, {"swc3", "E,A(b)", 0, (int) M_SWC3_AB, INSN_MACRO, }, {"swl", "t,o(b)", 0xa8000000, 0xfc000000, SM|RD_t|RD_b, }, {"swl", "t,A(b)", 0, (int) M_SWL_AB, INSN_MACRO, }, {"scache", "t,o(b)", 0xa8000000, 0xfc000000, RD_t|RD_b, }, /* same */ {"scache", "t,A(b)", 0, (int) M_SWL_AB, INSN_MACRO, }, /* as swl */ {"swr", "t,o(b)", 0xb8000000, 0xfc000000, SM|RD_t|RD_b, }, {"swr", "t,A(b)", 0, (int) M_SWR_AB, INSN_MACRO, }, {"invalidate", "t,o(b)",0xb8000000, 0xfc000000, RD_t|RD_b, }, /* same */ {"invalidate", "t,A(b)",0, (int) M_SWR_AB, INSN_MACRO, }, /* as swr */ {"swxc1", "S,t(b)", 0x4c000008, 0xfc0007ff, SM|RD_S|RD_t|RD_b|FP_S, }, {"synciobdma", "", 0x0000008f, 0xffffffff, INSN_SYNC, }, {"syncs", "", 0x0000018f, 0xffffffff, INSN_SYNC, }, {"syncw", "", 0x0000010f, 0xffffffff, INSN_SYNC, }, {"syncws", "", 0x0000014f, 0xffffffff, INSN_SYNC, }, {"sync_acquire", "", 0x0000044f, 0xffffffff, INSN_SYNC, }, {"sync_mb", "", 0x0000040f, 0xffffffff, INSN_SYNC, }, {"sync_release", "", 0x0000048f, 0xffffffff, INSN_SYNC, }, {"sync_rmb", "", 0x000004cf, 0xffffffff, INSN_SYNC, }, {"sync_wmb", "", 0x0000010f, 0xffffffff, INSN_SYNC, }, {"sync", "", 0x0000000f, 0xffffffff, INSN_SYNC, }, {"sync", "1", 0x0000000f, 0xfffff83f, INSN_SYNC, }, {"sync.p", "", 0x0000040f, 0xffffffff, INSN_SYNC, }, {"sync.l", "", 0x0000000f, 0xffffffff, INSN_SYNC, }, {"synci", "o(b)", 0x041f0000, 0xfc1f0000, SM|RD_b, }, {"syscall", "", 0x0000000c, 0xffffffff, TRAP, }, {"syscall", "B", 0x0000000c, 0xfc00003f, TRAP, }, {"teqi", "s,j", 0x040c0000, 0xfc1f0000, RD_s|TRAP, }, {"teq", "s,t", 0x00000034, 0xfc00ffff, RD_s|RD_t|TRAP, }, {"teq", "s,t,q", 0x00000034, 0xfc00003f, RD_s|RD_t|TRAP, }, {"teq", "s,j", 0x040c0000, 0xfc1f0000, RD_s|TRAP, }, /* teqi */ {"teq", "s,I", 0, (int) M_TEQ_I, INSN_MACRO, }, {"tgei", "s,j", 0x04080000, 0xfc1f0000, RD_s|TRAP, }, {"tge", "s,t", 0x00000030, 0xfc00ffff, RD_s|RD_t|TRAP, }, {"tge", "s,t,q", 0x00000030, 0xfc00003f, RD_s|RD_t|TRAP, }, {"tge", "s,j", 0x04080000, 0xfc1f0000, RD_s|TRAP, }, /* tgei */ {"tge", "s,I", 0, (int) M_TGE_I, INSN_MACRO, }, {"tgeiu", "s,j", 0x04090000, 0xfc1f0000, RD_s|TRAP, }, {"tgeu", "s,t", 0x00000031, 0xfc00ffff, RD_s|RD_t|TRAP, }, {"tgeu", "s,t,q", 0x00000031, 0xfc00003f, RD_s|RD_t|TRAP, }, {"tgeu", "s,j", 0x04090000, 0xfc1f0000, RD_s|TRAP, }, /* tgeiu */ {"tgeu", "s,I", 0, (int) M_TGEU_I, INSN_MACRO, }, {"tlbp", "", 0x42000008, 0xffffffff, INSN_TLB, }, {"tlbr", "", 0x42000001, 0xffffffff, INSN_TLB, }, {"tlbwi", "", 0x42000002, 0xffffffff, INSN_TLB, }, {"tlbwr", "", 0x42000006, 0xffffffff, INSN_TLB, }, {"tlti", "s,j", 0x040a0000, 0xfc1f0000, RD_s|TRAP, }, {"tlt", "s,t", 0x00000032, 0xfc00ffff, RD_s|RD_t|TRAP, }, {"tlt", "s,t,q", 0x00000032, 0xfc00003f, RD_s|RD_t|TRAP, }, {"tlt", "s,j", 0x040a0000, 0xfc1f0000, RD_s|TRAP, }, /* tlti */ {"tlt", "s,I", 0, (int) M_TLT_I, INSN_MACRO, }, {"tltiu", "s,j", 0x040b0000, 0xfc1f0000, RD_s|TRAP, }, {"tltu", "s,t", 0x00000033, 0xfc00ffff, RD_s|RD_t|TRAP, }, {"tltu", "s,t,q", 0x00000033, 0xfc00003f, RD_s|RD_t|TRAP, }, {"tltu", "s,j", 0x040b0000, 0xfc1f0000, RD_s|TRAP, }, /* tltiu */ {"tltu", "s,I", 0, (int) M_TLTU_I, INSN_MACRO, }, {"tnei", "s,j", 0x040e0000, 0xfc1f0000, RD_s|TRAP, }, {"tne", "s,t", 0x00000036, 0xfc00ffff, RD_s|RD_t|TRAP, }, {"tne", "s,t,q", 0x00000036, 0xfc00003f, RD_s|RD_t|TRAP, }, {"tne", "s,j", 0x040e0000, 0xfc1f0000, RD_s|TRAP, }, /* tnei */ {"tne", "s,I", 0, (int) M_TNE_I, INSN_MACRO, }, {"trunc.l.d", "D,S", 0x46200009, 0xffff003f, WR_D|RD_S|FP_D, }, {"trunc.l.s", "D,S", 0x46000009, 0xffff003f, WR_D|RD_S|FP_S|FP_D, }, {"trunc.w.d", "D,S", 0x4620000d, 0xffff003f, WR_D|RD_S|FP_S|FP_D, }, {"trunc.w.d", "D,S,x", 0x4620000d, 0xffff003f, WR_D|RD_S|FP_S|FP_D, }, {"trunc.w.d", "D,S,t", 0, (int) M_TRUNCWD, INSN_MACRO, INSN2_M_FP_S|INSN2_M_FP_D, }, {"trunc.w.s", "D,S", 0x4600000d, 0xffff003f, WR_D|RD_S|FP_S, }, {"trunc.w.s", "D,S,x", 0x4600000d, 0xffff003f, WR_D|RD_S|FP_S, }, {"trunc.w.s", "D,S,t", 0, (int) M_TRUNCWS, INSN_MACRO, INSN2_M_FP_S, }, {"uld", "t,o(b)", 0, (int) M_ULD, INSN_MACRO, }, {"uld", "t,A(b)", 0, (int) M_ULD_A, INSN_MACRO, }, {"ulh", "t,o(b)", 0, (int) M_ULH, INSN_MACRO, }, {"ulh", "t,A(b)", 0, (int) M_ULH_A, INSN_MACRO, }, {"ulhu", "t,o(b)", 0, (int) M_ULHU, INSN_MACRO, }, {"ulhu", "t,A(b)", 0, (int) M_ULHU_A, INSN_MACRO, }, {"ulw", "t,o(b)", 0, (int) M_ULW, INSN_MACRO, }, {"ulw", "t,A(b)", 0, (int) M_ULW_A, INSN_MACRO, }, {"usd", "t,o(b)", 0, (int) M_USD, INSN_MACRO, }, {"usd", "t,A(b)", 0, (int) M_USD_A, INSN_MACRO, }, {"ush", "t,o(b)", 0, (int) M_USH, INSN_MACRO, }, {"ush", "t,A(b)", 0, (int) M_USH_A, INSN_MACRO, }, {"usw", "t,o(b)", 0, (int) M_USW, INSN_MACRO, }, {"usw", "t,A(b)", 0, (int) M_USW_A, INSN_MACRO, }, {"v3mulu", "d,v,t", 0x70000011, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"vmm0", "d,v,t", 0x70000010, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"vmulu", "d,v,t", 0x7000000f, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"wach.ob", "Y", 0x7a00003e, 0xffff07ff, RD_S|FP_D, WR_MACC, }, {"wach.ob", "S", 0x4a00003e, 0xffff07ff, RD_S, }, {"wach.qh", "Y", 0x7a20003e, 0xffff07ff, RD_S|FP_D, WR_MACC, }, {"wacl.ob", "Y,Z", 0x7800003e, 0xffe007ff, RD_S|RD_T|FP_D, WR_MACC, }, {"wacl.ob", "S,T", 0x4800003e, 0xffe007ff, RD_S|RD_T, }, {"wacl.qh", "Y,Z", 0x7820003e, 0xffe007ff, RD_S|RD_T|FP_D, WR_MACC, }, {"wait", "", 0x42000020, 0xffffffff, TRAP, }, {"wait", "J", 0x42000020, 0xfe00003f, TRAP, }, {"waiti", "", 0x42000020, 0xffffffff, TRAP, }, {"wrpgpr", "d,w", 0x41c00000, 0xffe007ff, RD_t, }, {"wsbh", "d,w", 0x7c0000a0, 0xffe007ff, WR_d|RD_t, }, {"xor", "d,v,t", 0x00000026, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"xor", "t,r,I", 0, (int) M_XOR_I, INSN_MACRO, }, {"xor", "D,S,T", 0x47800002, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"xor", "D,S,T", 0x4b800002, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"xor.ob", "X,Y,Q", 0x7800000d, 0xfc20003f, WR_D|RD_S|RD_T|FP_D, }, {"xor.ob", "D,S,T", 0x4ac0000d, 0xffe0003f, WR_D|RD_S|RD_T, }, {"xor.ob", "D,S,T[e]", 0x4800000d, 0xfe20003f, WR_D|RD_S|RD_T, }, {"xor.ob", "D,S,k", 0x4bc0000d, 0xffe0003f, WR_D|RD_S|RD_T, }, {"xor.qh", "X,Y,Q", 0x7820000d, 0xfc20003f, WR_D|RD_S|RD_T|FP_D, }, {"xori", "t,r,i", 0x38000000, 0xfc000000, WR_t|RD_s, }, {"yield", "s", 0x7c000009, 0xfc1fffff, TRAP|RD_s, }, {"yield", "d,s", 0x7c000009, 0xfc1f07ff, TRAP|WR_d|RD_s, }, /* User Defined Instruction. */ {"udi0", "s,t,d,+1",0x70000010, 0xfc00003f, WR_d|RD_s|RD_t, }, {"udi0", "s,t,+2", 0x70000010, 0xfc00003f, WR_d|RD_s|RD_t, }, {"udi0", "s,+3", 0x70000010, 0xfc00003f, WR_d|RD_s|RD_t, }, {"udi0", "+4", 0x70000010, 0xfc00003f, WR_d|RD_s|RD_t, }, {"udi1", "s,t,d,+1",0x70000011, 0xfc00003f, WR_d|RD_s|RD_t, }, {"udi1", "s,t,+2", 0x70000011, 0xfc00003f, WR_d|RD_s|RD_t, }, {"udi1", "s,+3", 0x70000011, 0xfc00003f, WR_d|RD_s|RD_t, }, {"udi1", "+4", 0x70000011, 0xfc00003f, WR_d|RD_s|RD_t, }, {"udi2", "s,t,d,+1",0x70000012, 0xfc00003f, WR_d|RD_s|RD_t, }, {"udi2", "s,t,+2", 0x70000012, 0xfc00003f, WR_d|RD_s|RD_t, }, {"udi2", "s,+3", 0x70000012, 0xfc00003f, WR_d|RD_s|RD_t, }, {"udi2", "+4", 0x70000012, 0xfc00003f, WR_d|RD_s|RD_t, }, {"udi3", "s,t,d,+1",0x70000013, 0xfc00003f, WR_d|RD_s|RD_t, }, {"udi3", "s,t,+2", 0x70000013, 0xfc00003f, WR_d|RD_s|RD_t, }, {"udi3", "s,+3", 0x70000013, 0xfc00003f, WR_d|RD_s|RD_t, }, {"udi3", "+4", 0x70000013, 0xfc00003f, WR_d|RD_s|RD_t, }, {"udi4", "s,t,d,+1",0x70000014, 0xfc00003f, WR_d|RD_s|RD_t, }, {"udi4", "s,t,+2", 0x70000014, 0xfc00003f, WR_d|RD_s|RD_t, }, {"udi4", "s,+3", 0x70000014, 0xfc00003f, WR_d|RD_s|RD_t, }, {"udi4", "+4", 0x70000014, 0xfc00003f, WR_d|RD_s|RD_t, }, {"udi5", "s,t,d,+1",0x70000015, 0xfc00003f, WR_d|RD_s|RD_t, }, {"udi5", "s,t,+2", 0x70000015, 0xfc00003f, WR_d|RD_s|RD_t, }, {"udi5", "s,+3", 0x70000015, 0xfc00003f, WR_d|RD_s|RD_t, }, {"udi5", "+4", 0x70000015, 0xfc00003f, WR_d|RD_s|RD_t, }, {"udi6", "s,t,d,+1",0x70000016, 0xfc00003f, WR_d|RD_s|RD_t, }, {"udi6", "s,t,+2", 0x70000016, 0xfc00003f, WR_d|RD_s|RD_t, }, {"udi6", "s,+3", 0x70000016, 0xfc00003f, WR_d|RD_s|RD_t, }, {"udi6", "+4", 0x70000016, 0xfc00003f, WR_d|RD_s|RD_t, }, {"udi7", "s,t,d,+1",0x70000017, 0xfc00003f, WR_d|RD_s|RD_t, }, {"udi7", "s,t,+2", 0x70000017, 0xfc00003f, WR_d|RD_s|RD_t, }, {"udi7", "s,+3", 0x70000017, 0xfc00003f, WR_d|RD_s|RD_t, }, {"udi7", "+4", 0x70000017, 0xfc00003f, WR_d|RD_s|RD_t, }, {"udi8", "s,t,d,+1",0x70000018, 0xfc00003f, WR_d|RD_s|RD_t, }, {"udi8", "s,t,+2", 0x70000018, 0xfc00003f, WR_d|RD_s|RD_t, }, {"udi8", "s,+3", 0x70000018, 0xfc00003f, WR_d|RD_s|RD_t, }, {"udi8", "+4", 0x70000018, 0xfc00003f, WR_d|RD_s|RD_t, }, {"udi9", "s,t,d,+1",0x70000019, 0xfc00003f, WR_d|RD_s|RD_t, }, {"udi9", "s,t,+2", 0x70000019, 0xfc00003f, WR_d|RD_s|RD_t, }, {"udi9", "s,+3", 0x70000019, 0xfc00003f, WR_d|RD_s|RD_t, }, {"udi9", "+4", 0x70000019, 0xfc00003f, WR_d|RD_s|RD_t, }, {"udi10", "s,t,d,+1",0x7000001a, 0xfc00003f, WR_d|RD_s|RD_t, }, {"udi10", "s,t,+2", 0x7000001a, 0xfc00003f, WR_d|RD_s|RD_t, }, {"udi10", "s,+3", 0x7000001a, 0xfc00003f, WR_d|RD_s|RD_t, }, {"udi10", "+4", 0x7000001a, 0xfc00003f, WR_d|RD_s|RD_t, }, {"udi11", "s,t,d,+1",0x7000001b, 0xfc00003f, WR_d|RD_s|RD_t, }, {"udi11", "s,t,+2", 0x7000001b, 0xfc00003f, WR_d|RD_s|RD_t, }, {"udi11", "s,+3", 0x7000001b, 0xfc00003f, WR_d|RD_s|RD_t, }, {"udi11", "+4", 0x7000001b, 0xfc00003f, WR_d|RD_s|RD_t, }, {"udi12", "s,t,d,+1",0x7000001c, 0xfc00003f, WR_d|RD_s|RD_t, }, {"udi12", "s,t,+2", 0x7000001c, 0xfc00003f, WR_d|RD_s|RD_t, }, {"udi12", "s,+3", 0x7000001c, 0xfc00003f, WR_d|RD_s|RD_t, }, {"udi12", "+4", 0x7000001c, 0xfc00003f, WR_d|RD_s|RD_t, }, {"udi13", "s,t,d,+1",0x7000001d, 0xfc00003f, WR_d|RD_s|RD_t, }, {"udi13", "s,t,+2", 0x7000001d, 0xfc00003f, WR_d|RD_s|RD_t, }, {"udi13", "s,+3", 0x7000001d, 0xfc00003f, WR_d|RD_s|RD_t, }, {"udi13", "+4", 0x7000001d, 0xfc00003f, WR_d|RD_s|RD_t, }, {"udi14", "s,t,d,+1",0x7000001e, 0xfc00003f, WR_d|RD_s|RD_t, }, {"udi14", "s,t,+2", 0x7000001e, 0xfc00003f, WR_d|RD_s|RD_t, }, {"udi14", "s,+3", 0x7000001e, 0xfc00003f, WR_d|RD_s|RD_t, }, {"udi14", "+4", 0x7000001e, 0xfc00003f, WR_d|RD_s|RD_t, }, {"udi15", "s,t,d,+1",0x7000001f, 0xfc00003f, WR_d|RD_s|RD_t, }, {"udi15", "s,t,+2", 0x7000001f, 0xfc00003f, WR_d|RD_s|RD_t, }, {"udi15", "s,+3", 0x7000001f, 0xfc00003f, WR_d|RD_s|RD_t, }, {"udi15", "+4", 0x7000001f, 0xfc00003f, WR_d|RD_s|RD_t, }, /* Coprocessor 2 move/branch operations overlap with VR5400 .ob format instructions so they are here for the latters to take precedence. */ {"bc2f", "p", 0x49000000, 0xffff0000, CBD|RD_CC, }, {"bc2f", "N,p", 0x49000000, 0xffe30000, CBD|RD_CC, }, {"bc2fl", "p", 0x49020000, 0xffff0000, CBL|RD_CC, }, {"bc2fl", "N,p", 0x49020000, 0xffe30000, CBL|RD_CC, }, {"bc2t", "p", 0x49010000, 0xffff0000, CBD|RD_CC, }, {"bc2t", "N,p", 0x49010000, 0xffe30000, CBD|RD_CC, }, {"bc2tl", "p", 0x49030000, 0xffff0000, CBL|RD_CC, }, {"bc2tl", "N,p", 0x49030000, 0xffe30000, CBL|RD_CC, }, {"cfc2", "t,G", 0x48400000, 0xffe007ff, LCD|WR_t|RD_C2, }, {"ctc2", "t,G", 0x48c00000, 0xffe007ff, COD|RD_t|WR_CC, }, {"dmfc2", "t,i", 0x48200000, 0xffe00000, LCD|WR_t|RD_C2, }, {"dmfc2", "t,G", 0x48200000, 0xffe007ff, LCD|WR_t|RD_C2, }, {"dmfc2", "t,G,H", 0x48200000, 0xffe007f8, LCD|WR_t|RD_C2, }, {"dmtc2", "t,i", 0x48a00000, 0xffe00000, COD|RD_t|WR_C2|WR_CC, }, {"dmtc2", "t,G", 0x48a00000, 0xffe007ff, COD|RD_t|WR_C2|WR_CC, }, {"dmtc2", "t,G,H", 0x48a00000, 0xffe007f8, COD|RD_t|WR_C2|WR_CC, }, {"mfc2", "t,G", 0x48000000, 0xffe007ff, LCD|WR_t|RD_C2, }, {"mfc2", "t,G,H", 0x48000000, 0xffe007f8, LCD|WR_t|RD_C2, }, {"mfhc2", "t,G", 0x48600000, 0xffe007ff, LCD|WR_t|RD_C2, }, {"mfhc2", "t,G,H", 0x48600000, 0xffe007f8, LCD|WR_t|RD_C2, }, {"mfhc2", "t,i", 0x48600000, 0xffe00000, LCD|WR_t|RD_C2, }, {"mtc2", "t,G", 0x48800000, 0xffe007ff, COD|RD_t|WR_C2|WR_CC, }, {"mtc2", "t,G,H", 0x48800000, 0xffe007f8, COD|RD_t|WR_C2|WR_CC, }, {"mthc2", "t,G", 0x48e00000, 0xffe007ff, COD|RD_t|WR_C2|WR_CC, }, {"mthc2", "t,G,H", 0x48e00000, 0xffe007f8, COD|RD_t|WR_C2|WR_CC, }, {"mthc2", "t,i", 0x48e00000, 0xffe00000, COD|RD_t|WR_C2|WR_CC, }, /* Coprocessor 3 move/branch operations overlap with MIPS IV COP1X instructions, so they are here for the latters to take precedence. */ {"bc3f", "p", 0x4d000000, 0xffff0000, CBD|RD_CC, }, {"bc3fl", "p", 0x4d020000, 0xffff0000, CBL|RD_CC, }, {"bc3t", "p", 0x4d010000, 0xffff0000, CBD|RD_CC, }, {"bc3tl", "p", 0x4d030000, 0xffff0000, CBL|RD_CC, }, {"cfc3", "t,G", 0x4c400000, 0xffe007ff, LCD|WR_t|RD_C3, }, {"ctc3", "t,G", 0x4cc00000, 0xffe007ff, COD|RD_t|WR_CC, }, {"dmfc3", "t,G", 0x4c200000, 0xffe007ff, LCD|WR_t|RD_C3, }, {"dmtc3", "t,G", 0x4ca00000, 0xffe007ff, COD|RD_t|WR_C3|WR_CC, }, {"mfc3", "t,G", 0x4c000000, 0xffe007ff, LCD|WR_t|RD_C3, }, {"mfc3", "t,G,H", 0x4c000000, 0xffe007f8, LCD|WR_t|RD_C3, }, {"mtc3", "t,G", 0x4c800000, 0xffe007ff, COD|RD_t|WR_C3|WR_CC, }, {"mtc3", "t,G,H", 0x4c800000, 0xffe007f8, COD|RD_t|WR_C3|WR_CC, }, /* Conflicts with the 4650's "mul" instruction. Nobody's using the 4010 any more, so move this insn out of the way. If the object format gave us more info, we could do this right. */ {"addciu", "t,r,j", 0x70000000, 0xfc000000, WR_t|RD_s, }, /* MIPS DSP ASE */ {"absq_s.ph", "d,t", 0x7c000252, 0xffe007ff, WR_d|RD_t, }, {"absq_s.pw", "d,t", 0x7c000456, 0xffe007ff, WR_d|RD_t, }, {"absq_s.qh", "d,t", 0x7c000256, 0xffe007ff, WR_d|RD_t, }, {"absq_s.w", "d,t", 0x7c000452, 0xffe007ff, WR_d|RD_t, }, {"addq.ph", "d,s,t", 0x7c000290, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"addq.pw", "d,s,t", 0x7c000494, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"addq.qh", "d,s,t", 0x7c000294, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"addq_s.ph", "d,s,t", 0x7c000390, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"addq_s.pw", "d,s,t", 0x7c000594, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"addq_s.qh", "d,s,t", 0x7c000394, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"addq_s.w", "d,s,t", 0x7c000590, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"addsc", "d,s,t", 0x7c000410, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"addu.ob", "d,s,t", 0x7c000014, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"addu.qb", "d,s,t", 0x7c000010, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"addu_s.ob", "d,s,t", 0x7c000114, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"addu_s.qb", "d,s,t", 0x7c000110, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"addwc", "d,s,t", 0x7c000450, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"bitrev", "d,t", 0x7c0006d2, 0xffe007ff, WR_d|RD_t, }, {"bposge32", "p", 0x041c0000, 0xffff0000, CBD, }, {"bposge64", "p", 0x041d0000, 0xffff0000, CBD, }, {"cmp.eq.ph", "s,t", 0x7c000211, 0xfc00ffff, RD_s|RD_t, }, {"cmp.eq.pw", "s,t", 0x7c000415, 0xfc00ffff, RD_s|RD_t, }, {"cmp.eq.qh", "s,t", 0x7c000215, 0xfc00ffff, RD_s|RD_t, }, {"cmpgu.eq.ob", "d,s,t", 0x7c000115, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"cmpgu.eq.qb", "d,s,t", 0x7c000111, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"cmpgu.le.ob", "d,s,t", 0x7c000195, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"cmpgu.le.qb", "d,s,t", 0x7c000191, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"cmpgu.lt.ob", "d,s,t", 0x7c000155, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"cmpgu.lt.qb", "d,s,t", 0x7c000151, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"cmp.le.ph", "s,t", 0x7c000291, 0xfc00ffff, RD_s|RD_t, }, {"cmp.le.pw", "s,t", 0x7c000495, 0xfc00ffff, RD_s|RD_t, }, {"cmp.le.qh", "s,t", 0x7c000295, 0xfc00ffff, RD_s|RD_t, }, {"cmp.lt.ph", "s,t", 0x7c000251, 0xfc00ffff, RD_s|RD_t, }, {"cmp.lt.pw", "s,t", 0x7c000455, 0xfc00ffff, RD_s|RD_t, }, {"cmp.lt.qh", "s,t", 0x7c000255, 0xfc00ffff, RD_s|RD_t, }, {"cmpu.eq.ob", "s,t", 0x7c000015, 0xfc00ffff, RD_s|RD_t, }, {"cmpu.eq.qb", "s,t", 0x7c000011, 0xfc00ffff, RD_s|RD_t, }, {"cmpu.le.ob", "s,t", 0x7c000095, 0xfc00ffff, RD_s|RD_t, }, {"cmpu.le.qb", "s,t", 0x7c000091, 0xfc00ffff, RD_s|RD_t, }, {"cmpu.lt.ob", "s,t", 0x7c000055, 0xfc00ffff, RD_s|RD_t, }, {"cmpu.lt.qb", "s,t", 0x7c000051, 0xfc00ffff, RD_s|RD_t, }, {"dextpdp", "t,7,6", 0x7c0002bc, 0xfc00e7ff, WR_t|RD_a|DSP_VOLA, }, {"dextpdpv", "t,7,s", 0x7c0002fc, 0xfc00e7ff, WR_t|RD_a|RD_s|DSP_VOLA, }, {"dextp", "t,7,6", 0x7c0000bc, 0xfc00e7ff, WR_t|RD_a, }, {"dextpv", "t,7,s", 0x7c0000fc, 0xfc00e7ff, WR_t|RD_a|RD_s, }, {"dextr.l", "t,7,6", 0x7c00043c, 0xfc00e7ff, WR_t|RD_a, }, {"dextr_r.l", "t,7,6", 0x7c00053c, 0xfc00e7ff, WR_t|RD_a, }, {"dextr_rs.l", "t,7,6", 0x7c0005bc, 0xfc00e7ff, WR_t|RD_a, }, {"dextr_rs.w", "t,7,6", 0x7c0001bc, 0xfc00e7ff, WR_t|RD_a, }, {"dextr_r.w", "t,7,6", 0x7c00013c, 0xfc00e7ff, WR_t|RD_a, }, {"dextr_s.h", "t,7,6", 0x7c0003bc, 0xfc00e7ff, WR_t|RD_a, }, {"dextrv.l", "t,7,s", 0x7c00047c, 0xfc00e7ff, WR_t|RD_a|RD_s, }, {"dextrv_r.l", "t,7,s", 0x7c00057c, 0xfc00e7ff, WR_t|RD_a|RD_s, }, {"dextrv_rs.l", "t,7,s", 0x7c0005fc, 0xfc00e7ff, WR_t|RD_a|RD_s, }, {"dextrv_rs.w", "t,7,s", 0x7c0001fc, 0xfc00e7ff, WR_t|RD_a|RD_s, }, {"dextrv_r.w", "t,7,s", 0x7c00017c, 0xfc00e7ff, WR_t|RD_a|RD_s, }, {"dextrv_s.h", "t,7,s", 0x7c0003fc, 0xfc00e7ff, WR_t|RD_a|RD_s, }, {"dextrv.w", "t,7,s", 0x7c00007c, 0xfc00e7ff, WR_t|RD_a|RD_s, }, {"dextr.w", "t,7,6", 0x7c00003c, 0xfc00e7ff, WR_t|RD_a, }, {"dinsv", "t,s", 0x7c00000d, 0xfc00ffff, WR_t|RD_s, }, {"dmadd", "7,s,t", 0x7c000674, 0xfc00e7ff, MOD_a|RD_s|RD_t, }, {"dmaddu", "7,s,t", 0x7c000774, 0xfc00e7ff, MOD_a|RD_s|RD_t, }, {"dmsub", "7,s,t", 0x7c0006f4, 0xfc00e7ff, MOD_a|RD_s|RD_t, }, {"dmsubu", "7,s,t", 0x7c0007f4, 0xfc00e7ff, MOD_a|RD_s|RD_t, }, {"dmthlip", "s,7", 0x7c0007fc, 0xfc1fe7ff, RD_s|MOD_a|DSP_VOLA, }, {"dpaq_sa.l.pw", "7,s,t", 0x7c000334, 0xfc00e7ff, MOD_a|RD_s|RD_t, }, {"dpaq_sa.l.w", "7,s,t", 0x7c000330, 0xfc00e7ff, MOD_a|RD_s|RD_t, }, {"dpaq_s.w.ph", "7,s,t", 0x7c000130, 0xfc00e7ff, MOD_a|RD_s|RD_t, }, {"dpaq_s.w.qh", "7,s,t", 0x7c000134, 0xfc00e7ff, MOD_a|RD_s|RD_t, }, {"dpau.h.obl", "7,s,t", 0x7c0000f4, 0xfc00e7ff, MOD_a|RD_s|RD_t, }, {"dpau.h.obr", "7,s,t", 0x7c0001f4, 0xfc00e7ff, MOD_a|RD_s|RD_t, }, {"dpau.h.qbl", "7,s,t", 0x7c0000f0, 0xfc00e7ff, MOD_a|RD_s|RD_t, }, {"dpau.h.qbr", "7,s,t", 0x7c0001f0, 0xfc00e7ff, MOD_a|RD_s|RD_t, }, {"dpsq_sa.l.pw", "7,s,t", 0x7c000374, 0xfc00e7ff, MOD_a|RD_s|RD_t, }, {"dpsq_sa.l.w", "7,s,t", 0x7c000370, 0xfc00e7ff, MOD_a|RD_s|RD_t, }, {"dpsq_s.w.ph", "7,s,t", 0x7c000170, 0xfc00e7ff, MOD_a|RD_s|RD_t, }, {"dpsq_s.w.qh", "7,s,t", 0x7c000174, 0xfc00e7ff, MOD_a|RD_s|RD_t, }, {"dpsu.h.obl", "7,s,t", 0x7c0002f4, 0xfc00e7ff, MOD_a|RD_s|RD_t, }, {"dpsu.h.obr", "7,s,t", 0x7c0003f4, 0xfc00e7ff, MOD_a|RD_s|RD_t, }, {"dpsu.h.qbl", "7,s,t", 0x7c0002f0, 0xfc00e7ff, MOD_a|RD_s|RD_t, }, {"dpsu.h.qbr", "7,s,t", 0x7c0003f0, 0xfc00e7ff, MOD_a|RD_s|RD_t, }, {"dshilo", "7,:", 0x7c0006bc, 0xfc07e7ff, MOD_a, }, {"dshilov", "7,s", 0x7c0006fc, 0xfc1fe7ff, MOD_a|RD_s, }, {"extpdp", "t,7,6", 0x7c0002b8, 0xfc00e7ff, WR_t|RD_a|DSP_VOLA, }, {"extpdpv", "t,7,s", 0x7c0002f8, 0xfc00e7ff, WR_t|RD_a|RD_s|DSP_VOLA, }, {"extp", "t,7,6", 0x7c0000b8, 0xfc00e7ff, WR_t|RD_a, }, {"extpv", "t,7,s", 0x7c0000f8, 0xfc00e7ff, WR_t|RD_a|RD_s, }, {"extr_rs.w", "t,7,6", 0x7c0001b8, 0xfc00e7ff, WR_t|RD_a, }, {"extr_r.w", "t,7,6", 0x7c000138, 0xfc00e7ff, WR_t|RD_a, }, {"extr_s.h", "t,7,6", 0x7c0003b8, 0xfc00e7ff, WR_t|RD_a, }, {"extrv_rs.w", "t,7,s", 0x7c0001f8, 0xfc00e7ff, WR_t|RD_a|RD_s, }, {"extrv_r.w", "t,7,s", 0x7c000178, 0xfc00e7ff, WR_t|RD_a|RD_s, }, {"extrv_s.h", "t,7,s", 0x7c0003f8, 0xfc00e7ff, WR_t|RD_a|RD_s, }, {"extrv.w", "t,7,s", 0x7c000078, 0xfc00e7ff, WR_t|RD_a|RD_s, }, {"extr.w", "t,7,6", 0x7c000038, 0xfc00e7ff, WR_t|RD_a, }, {"insv", "t,s", 0x7c00000c, 0xfc00ffff, WR_t|RD_s, }, {"lbux", "d,t(b)", 0x7c00018a, 0xfc0007ff, LDD|WR_d|RD_t|RD_b, }, {"ldx", "d,t(b)", 0x7c00020a, 0xfc0007ff, LDD|WR_d|RD_t|RD_b, }, {"lhx", "d,t(b)", 0x7c00010a, 0xfc0007ff, LDD|WR_d|RD_t|RD_b, }, {"lwx", "d,t(b)", 0x7c00000a, 0xfc0007ff, LDD|WR_d|RD_t|RD_b, }, {"maq_sa.w.phl", "7,s,t", 0x7c000430, 0xfc00e7ff, MOD_a|RD_s|RD_t, }, {"maq_sa.w.phr", "7,s,t", 0x7c0004b0, 0xfc00e7ff, MOD_a|RD_s|RD_t, }, {"maq_sa.w.qhll", "7,s,t", 0x7c000434, 0xfc00e7ff, MOD_a|RD_s|RD_t, }, {"maq_sa.w.qhlr", "7,s,t", 0x7c000474, 0xfc00e7ff, MOD_a|RD_s|RD_t, }, {"maq_sa.w.qhrl", "7,s,t", 0x7c0004b4, 0xfc00e7ff, MOD_a|RD_s|RD_t, }, {"maq_sa.w.qhrr", "7,s,t", 0x7c0004f4, 0xfc00e7ff, MOD_a|RD_s|RD_t, }, {"maq_s.l.pwl", "7,s,t", 0x7c000734, 0xfc00e7ff, MOD_a|RD_s|RD_t, }, {"maq_s.l.pwr", "7,s,t", 0x7c0007b4, 0xfc00e7ff, MOD_a|RD_s|RD_t, }, {"maq_s.w.phl", "7,s,t", 0x7c000530, 0xfc00e7ff, MOD_a|RD_s|RD_t, }, {"maq_s.w.phr", "7,s,t", 0x7c0005b0, 0xfc00e7ff, MOD_a|RD_s|RD_t, }, {"maq_s.w.qhll", "7,s,t", 0x7c000534, 0xfc00e7ff, MOD_a|RD_s|RD_t, }, {"maq_s.w.qhlr", "7,s,t", 0x7c000574, 0xfc00e7ff, MOD_a|RD_s|RD_t, }, {"maq_s.w.qhrl", "7,s,t", 0x7c0005b4, 0xfc00e7ff, MOD_a|RD_s|RD_t, }, {"maq_s.w.qhrr", "7,s,t", 0x7c0005f4, 0xfc00e7ff, MOD_a|RD_s|RD_t, }, {"modsub", "d,s,t", 0x7c000490, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"mthlip", "s,7", 0x7c0007f8, 0xfc1fe7ff, RD_s|MOD_a|DSP_VOLA, }, {"muleq_s.pw.qhl", "d,s,t", 0x7c000714, 0xfc0007ff, WR_d|RD_s|RD_t|WR_HILO, }, {"muleq_s.pw.qhr", "d,s,t", 0x7c000754, 0xfc0007ff, WR_d|RD_s|RD_t|WR_HILO, }, {"muleq_s.w.phl", "d,s,t", 0x7c000710, 0xfc0007ff, WR_d|RD_s|RD_t|WR_HILO, }, {"muleq_s.w.phr", "d,s,t", 0x7c000750, 0xfc0007ff, WR_d|RD_s|RD_t|WR_HILO, }, {"muleu_s.ph.qbl", "d,s,t", 0x7c000190, 0xfc0007ff, WR_d|RD_s|RD_t|WR_HILO, }, {"muleu_s.ph.qbr", "d,s,t", 0x7c0001d0, 0xfc0007ff, WR_d|RD_s|RD_t|WR_HILO, }, {"muleu_s.qh.obl", "d,s,t", 0x7c000194, 0xfc0007ff, WR_d|RD_s|RD_t|WR_HILO, }, {"muleu_s.qh.obr", "d,s,t", 0x7c0001d4, 0xfc0007ff, WR_d|RD_s|RD_t|WR_HILO, }, {"mulq_rs.ph", "d,s,t", 0x7c0007d0, 0xfc0007ff, WR_d|RD_s|RD_t|WR_HILO, }, {"mulq_rs.qh", "d,s,t", 0x7c0007d4, 0xfc0007ff, WR_d|RD_s|RD_t|WR_HILO, }, {"mulsaq_s.l.pw", "7,s,t", 0x7c0003b4, 0xfc00e7ff, MOD_a|RD_s|RD_t, }, {"mulsaq_s.w.ph", "7,s,t", 0x7c0001b0, 0xfc00e7ff, MOD_a|RD_s|RD_t, }, {"mulsaq_s.w.qh", "7,s,t", 0x7c0001b4, 0xfc00e7ff, MOD_a|RD_s|RD_t, }, {"packrl.ph", "d,s,t", 0x7c000391, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"packrl.pw", "d,s,t", 0x7c000395, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"pick.ob", "d,s,t", 0x7c0000d5, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"pick.ph", "d,s,t", 0x7c0002d1, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"pick.pw", "d,s,t", 0x7c0004d5, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"pick.qb", "d,s,t", 0x7c0000d1, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"pick.qh", "d,s,t", 0x7c0002d5, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"preceq.pw.qhla", "d,t", 0x7c000396, 0xffe007ff, WR_d|RD_t, }, {"preceq.pw.qhl", "d,t", 0x7c000316, 0xffe007ff, WR_d|RD_t, }, {"preceq.pw.qhra", "d,t", 0x7c0003d6, 0xffe007ff, WR_d|RD_t, }, {"preceq.pw.qhr", "d,t", 0x7c000356, 0xffe007ff, WR_d|RD_t, }, {"preceq.s.l.pwl", "d,t", 0x7c000516, 0xffe007ff, WR_d|RD_t, }, {"preceq.s.l.pwr", "d,t", 0x7c000556, 0xffe007ff, WR_d|RD_t, }, {"precequ.ph.qbla", "d,t", 0x7c000192, 0xffe007ff, WR_d|RD_t, }, {"precequ.ph.qbl", "d,t", 0x7c000112, 0xffe007ff, WR_d|RD_t, }, {"precequ.ph.qbra", "d,t", 0x7c0001d2, 0xffe007ff, WR_d|RD_t, }, {"precequ.ph.qbr", "d,t", 0x7c000152, 0xffe007ff, WR_d|RD_t, }, {"precequ.pw.qhla", "d,t", 0x7c000196, 0xffe007ff, WR_d|RD_t, }, {"precequ.pw.qhl", "d,t", 0x7c000116, 0xffe007ff, WR_d|RD_t, }, {"precequ.pw.qhra", "d,t", 0x7c0001d6, 0xffe007ff, WR_d|RD_t, }, {"precequ.pw.qhr", "d,t", 0x7c000156, 0xffe007ff, WR_d|RD_t, }, {"preceq.w.phl", "d,t", 0x7c000312, 0xffe007ff, WR_d|RD_t, }, {"preceq.w.phr", "d,t", 0x7c000352, 0xffe007ff, WR_d|RD_t, }, {"preceu.ph.qbla", "d,t", 0x7c000792, 0xffe007ff, WR_d|RD_t, }, {"preceu.ph.qbl", "d,t", 0x7c000712, 0xffe007ff, WR_d|RD_t, }, {"preceu.ph.qbra", "d,t", 0x7c0007d2, 0xffe007ff, WR_d|RD_t, }, {"preceu.ph.qbr", "d,t", 0x7c000752, 0xffe007ff, WR_d|RD_t, }, {"preceu.qh.obla", "d,t", 0x7c000796, 0xffe007ff, WR_d|RD_t, }, {"preceu.qh.obl", "d,t", 0x7c000716, 0xffe007ff, WR_d|RD_t, }, {"preceu.qh.obra", "d,t", 0x7c0007d6, 0xffe007ff, WR_d|RD_t, }, {"preceu.qh.obr", "d,t", 0x7c000756, 0xffe007ff, WR_d|RD_t, }, {"precrq.ob.qh", "d,s,t", 0x7c000315, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"precrq.ph.w", "d,s,t", 0x7c000511, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"precrq.pw.l", "d,s,t", 0x7c000715, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"precrq.qb.ph", "d,s,t", 0x7c000311, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"precrq.qh.pw", "d,s,t", 0x7c000515, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"precrq_rs.ph.w", "d,s,t", 0x7c000551, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"precrq_rs.qh.pw", "d,s,t", 0x7c000555, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"precrqu_s.ob.qh", "d,s,t", 0x7c0003d5, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"precrqu_s.qb.ph", "d,s,t", 0x7c0003d1, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"raddu.l.ob", "d,s", 0x7c000514, 0xfc1f07ff, WR_d|RD_s, }, {"raddu.w.qb", "d,s", 0x7c000510, 0xfc1f07ff, WR_d|RD_s, }, {"rddsp", "d", 0x7fff04b8, 0xffff07ff, WR_d, }, {"rddsp", "d,'", 0x7c0004b8, 0xffc007ff, WR_d, }, {"repl.ob", "d,5", 0x7c000096, 0xff0007ff, WR_d, }, {"repl.ph", "d,@", 0x7c000292, 0xfc0007ff, WR_d, }, {"repl.pw", "d,@", 0x7c000496, 0xfc0007ff, WR_d, }, {"repl.qb", "d,5", 0x7c000092, 0xff0007ff, WR_d, }, {"repl.qh", "d,@", 0x7c000296, 0xfc0007ff, WR_d, }, {"replv.ob", "d,t", 0x7c0000d6, 0xffe007ff, WR_d|RD_t, }, {"replv.ph", "d,t", 0x7c0002d2, 0xffe007ff, WR_d|RD_t, }, {"replv.pw", "d,t", 0x7c0004d6, 0xffe007ff, WR_d|RD_t, }, {"replv.qb", "d,t", 0x7c0000d2, 0xffe007ff, WR_d|RD_t, }, {"replv.qh", "d,t", 0x7c0002d6, 0xffe007ff, WR_d|RD_t, }, {"shilo", "7,0", 0x7c0006b8, 0xfc0fe7ff, MOD_a, }, {"shilov", "7,s", 0x7c0006f8, 0xfc1fe7ff, MOD_a|RD_s, }, {"shll.ob", "d,t,3", 0x7c000017, 0xff0007ff, WR_d|RD_t, }, {"shll.ph", "d,t,4", 0x7c000213, 0xfe0007ff, WR_d|RD_t, }, {"shll.pw", "d,t,6", 0x7c000417, 0xfc0007ff, WR_d|RD_t, }, {"shll.qb", "d,t,3", 0x7c000013, 0xff0007ff, WR_d|RD_t, }, {"shll.qh", "d,t,4", 0x7c000217, 0xfe0007ff, WR_d|RD_t, }, {"shll_s.ph", "d,t,4", 0x7c000313, 0xfe0007ff, WR_d|RD_t, }, {"shll_s.pw", "d,t,6", 0x7c000517, 0xfc0007ff, WR_d|RD_t, }, {"shll_s.qh", "d,t,4", 0x7c000317, 0xfe0007ff, WR_d|RD_t, }, {"shll_s.w", "d,t,6", 0x7c000513, 0xfc0007ff, WR_d|RD_t, }, {"shllv.ob", "d,t,s", 0x7c000097, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"shllv.ph", "d,t,s", 0x7c000293, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"shllv.pw", "d,t,s", 0x7c000497, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"shllv.qb", "d,t,s", 0x7c000093, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"shllv.qh", "d,t,s", 0x7c000297, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"shllv_s.ph", "d,t,s", 0x7c000393, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"shllv_s.pw", "d,t,s", 0x7c000597, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"shllv_s.qh", "d,t,s", 0x7c000397, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"shllv_s.w", "d,t,s", 0x7c000593, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"shra.ph", "d,t,4", 0x7c000253, 0xfe0007ff, WR_d|RD_t, }, {"shra.pw", "d,t,6", 0x7c000457, 0xfc0007ff, WR_d|RD_t, }, {"shra.qh", "d,t,4", 0x7c000257, 0xfe0007ff, WR_d|RD_t, }, {"shra_r.ph", "d,t,4", 0x7c000353, 0xfe0007ff, WR_d|RD_t, }, {"shra_r.pw", "d,t,6", 0x7c000557, 0xfc0007ff, WR_d|RD_t, }, {"shra_r.qh", "d,t,4", 0x7c000357, 0xfe0007ff, WR_d|RD_t, }, {"shra_r.w", "d,t,6", 0x7c000553, 0xfc0007ff, WR_d|RD_t, }, {"shrav.ph", "d,t,s", 0x7c0002d3, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"shrav.pw", "d,t,s", 0x7c0004d7, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"shrav.qh", "d,t,s", 0x7c0002d7, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"shrav_r.ph", "d,t,s", 0x7c0003d3, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"shrav_r.pw", "d,t,s", 0x7c0005d7, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"shrav_r.qh", "d,t,s", 0x7c0003d7, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"shrav_r.w", "d,t,s", 0x7c0005d3, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"shrl.ob", "d,t,3", 0x7c000057, 0xff0007ff, WR_d|RD_t, }, {"shrl.qb", "d,t,3", 0x7c000053, 0xff0007ff, WR_d|RD_t, }, {"shrlv.ob", "d,t,s", 0x7c0000d7, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"shrlv.qb", "d,t,s", 0x7c0000d3, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"subq.ph", "d,s,t", 0x7c0002d0, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"subq.pw", "d,s,t", 0x7c0004d4, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"subq.qh", "d,s,t", 0x7c0002d4, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"subq_s.ph", "d,s,t", 0x7c0003d0, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"subq_s.pw", "d,s,t", 0x7c0005d4, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"subq_s.qh", "d,s,t", 0x7c0003d4, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"subq_s.w", "d,s,t", 0x7c0005d0, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"subu.ob", "d,s,t", 0x7c000054, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"subu.qb", "d,s,t", 0x7c000050, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"subu_s.ob", "d,s,t", 0x7c000154, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"subu_s.qb", "d,s,t", 0x7c000150, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"wrdsp", "s", 0x7c1ffcf8, 0xfc1fffff, RD_s|DSP_VOLA, }, {"wrdsp", "s,8", 0x7c0004f8, 0xfc1e07ff, RD_s|DSP_VOLA, }, /* MIPS DSP ASE Rev2 */ {"absq_s.qb", "d,t", 0x7c000052, 0xffe007ff, WR_d|RD_t, }, {"addu.ph", "d,s,t", 0x7c000210, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"addu_s.ph", "d,s,t", 0x7c000310, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"adduh.qb", "d,s,t", 0x7c000018, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"adduh_r.qb", "d,s,t", 0x7c000098, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"append", "t,s,h", 0x7c000031, 0xfc0007ff, WR_t|RD_t|RD_s, }, {"balign", "t,s,I", 0, (int) M_BALIGN, INSN_MACRO, }, {"balign", "t,s,2", 0x7c000431, 0xfc00e7ff, WR_t|RD_t|RD_s, }, {"cmpgdu.eq.qb", "d,s,t", 0x7c000611, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"cmpgdu.lt.qb", "d,s,t", 0x7c000651, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"cmpgdu.le.qb", "d,s,t", 0x7c000691, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"dpa.w.ph", "7,s,t", 0x7c000030, 0xfc00e7ff, MOD_a|RD_s|RD_t, }, {"dps.w.ph", "7,s,t", 0x7c000070, 0xfc00e7ff, MOD_a|RD_s|RD_t, }, {"mul.ph", "d,s,t", 0x7c000318, 0xfc0007ff, WR_d|RD_s|RD_t|WR_HILO, }, {"mul_s.ph", "d,s,t", 0x7c000398, 0xfc0007ff, WR_d|RD_s|RD_t|WR_HILO, }, {"mulq_rs.w", "d,s,t", 0x7c0005d8, 0xfc0007ff, WR_d|RD_s|RD_t|WR_HILO, }, {"mulq_s.ph", "d,s,t", 0x7c000790, 0xfc0007ff, WR_d|RD_s|RD_t|WR_HILO, }, {"mulq_s.w", "d,s,t", 0x7c000598, 0xfc0007ff, WR_d|RD_s|RD_t|WR_HILO, }, {"mulsa.w.ph", "7,s,t", 0x7c0000b0, 0xfc00e7ff, MOD_a|RD_s|RD_t, }, {"precr.qb.ph", "d,s,t", 0x7c000351, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"precr_sra.ph.w", "t,s,h", 0x7c000791, 0xfc0007ff, WR_t|RD_t|RD_s, }, {"precr_sra_r.ph.w", "t,s,h", 0x7c0007d1, 0xfc0007ff, WR_t|RD_t|RD_s, }, {"prepend", "t,s,h", 0x7c000071, 0xfc0007ff, WR_t|RD_t|RD_s, }, {"shra.qb", "d,t,3", 0x7c000113, 0xff0007ff, WR_d|RD_t, }, {"shra_r.qb", "d,t,3", 0x7c000153, 0xff0007ff, WR_d|RD_t, }, {"shrav.qb", "d,t,s", 0x7c000193, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"shrav_r.qb", "d,t,s", 0x7c0001d3, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"shrl.ph", "d,t,4", 0x7c000653, 0xfe0007ff, WR_d|RD_t, }, {"shrlv.ph", "d,t,s", 0x7c0006d3, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"subu.ph", "d,s,t", 0x7c000250, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"subu_s.ph", "d,s,t", 0x7c000350, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"subuh.qb", "d,s,t", 0x7c000058, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"subuh_r.qb", "d,s,t", 0x7c0000d8, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"addqh.ph", "d,s,t", 0x7c000218, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"addqh_r.ph", "d,s,t", 0x7c000298, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"addqh.w", "d,s,t", 0x7c000418, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"addqh_r.w", "d,s,t", 0x7c000498, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"subqh.ph", "d,s,t", 0x7c000258, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"subqh_r.ph", "d,s,t", 0x7c0002d8, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"subqh.w", "d,s,t", 0x7c000458, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"subqh_r.w", "d,s,t", 0x7c0004d8, 0xfc0007ff, WR_d|RD_s|RD_t, }, {"dpax.w.ph", "7,s,t", 0x7c000230, 0xfc00e7ff, MOD_a|RD_s|RD_t, }, {"dpsx.w.ph", "7,s,t", 0x7c000270, 0xfc00e7ff, MOD_a|RD_s|RD_t, }, {"dpaqx_s.w.ph", "7,s,t", 0x7c000630, 0xfc00e7ff, MOD_a|RD_s|RD_t, }, {"dpaqx_sa.w.ph", "7,s,t", 0x7c0006b0, 0xfc00e7ff, MOD_a|RD_s|RD_t, }, {"dpsqx_s.w.ph", "7,s,t", 0x7c000670, 0xfc00e7ff, MOD_a|RD_s|RD_t, }, {"dpsqx_sa.w.ph", "7,s,t", 0x7c0006f0, 0xfc00e7ff, MOD_a|RD_s|RD_t, }, /* Move bc0* after mftr and mttr to avoid opcode collision. */ {"bc0f", "p", 0x41000000, 0xffff0000, CBD|RD_CC, }, {"bc0fl", "p", 0x41020000, 0xffff0000, CBL|RD_CC, }, {"bc0t", "p", 0x41010000, 0xffff0000, CBD|RD_CC, }, {"bc0tl", "p", 0x41030000, 0xffff0000, CBL|RD_CC, }, /* ST Microelectronics Loongson-2E and -2F. */ {"mult.g", "d,s,t", 0x7c000018, 0xfc0007ff, RD_s|RD_t|WR_d, }, {"mult.g", "d,s,t", 0x70000010, 0xfc0007ff, RD_s|RD_t|WR_d, }, {"multu.g", "d,s,t", 0x7c000019, 0xfc0007ff, RD_s|RD_t|WR_d, }, {"multu.g", "d,s,t", 0x70000012, 0xfc0007ff, RD_s|RD_t|WR_d, }, {"dmult.g", "d,s,t", 0x7c00001c, 0xfc0007ff, RD_s|RD_t|WR_d, }, {"dmult.g", "d,s,t", 0x70000011, 0xfc0007ff, RD_s|RD_t|WR_d, }, {"dmultu.g", "d,s,t", 0x7c00001d, 0xfc0007ff, RD_s|RD_t|WR_d, }, {"dmultu.g", "d,s,t", 0x70000013, 0xfc0007ff, RD_s|RD_t|WR_d, }, {"div.g", "d,s,t", 0x7c00001a, 0xfc0007ff, RD_s|RD_t|WR_d, }, {"div.g", "d,s,t", 0x70000014, 0xfc0007ff, RD_s|RD_t|WR_d, }, {"divu.g", "d,s,t", 0x7c00001b, 0xfc0007ff, RD_s|RD_t|WR_d, }, {"divu.g", "d,s,t", 0x70000016, 0xfc0007ff, RD_s|RD_t|WR_d, }, {"ddiv.g", "d,s,t", 0x7c00001e, 0xfc0007ff, RD_s|RD_t|WR_d, }, {"ddiv.g", "d,s,t", 0x70000015, 0xfc0007ff, RD_s|RD_t|WR_d, }, {"ddivu.g", "d,s,t", 0x7c00001f, 0xfc0007ff, RD_s|RD_t|WR_d, }, {"ddivu.g", "d,s,t", 0x70000017, 0xfc0007ff, RD_s|RD_t|WR_d, }, {"mod.g", "d,s,t", 0x7c000022, 0xfc0007ff, RD_s|RD_t|WR_d, }, {"mod.g", "d,s,t", 0x7000001c, 0xfc0007ff, RD_s|RD_t|WR_d, }, {"modu.g", "d,s,t", 0x7c000023, 0xfc0007ff, RD_s|RD_t|WR_d, }, {"modu.g", "d,s,t", 0x7000001e, 0xfc0007ff, RD_s|RD_t|WR_d, }, {"dmod.g", "d,s,t", 0x7c000026, 0xfc0007ff, RD_s|RD_t|WR_d, }, {"dmod.g", "d,s,t", 0x7000001d, 0xfc0007ff, RD_s|RD_t|WR_d, }, {"dmodu.g", "d,s,t", 0x7c000027, 0xfc0007ff, RD_s|RD_t|WR_d, }, {"dmodu.g", "d,s,t", 0x7000001f, 0xfc0007ff, RD_s|RD_t|WR_d, }, {"packsshb", "D,S,T", 0x47400002, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"packsshb", "D,S,T", 0x4b400002, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"packsswh", "D,S,T", 0x47200002, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"packsswh", "D,S,T", 0x4b200002, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"packushb", "D,S,T", 0x47600002, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"packushb", "D,S,T", 0x4b600002, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"paddb", "D,S,T", 0x47c00000, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"paddb", "D,S,T", 0x4bc00000, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"paddh", "D,S,T", 0x47400000, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"paddh", "D,S,T", 0x4b400000, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"paddw", "D,S,T", 0x47600000, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"paddw", "D,S,T", 0x4b600000, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"paddd", "D,S,T", 0x47e00000, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"paddd", "D,S,T", 0x4be00000, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"paddsb", "D,S,T", 0x47800000, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"paddsb", "D,S,T", 0x4b800000, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"paddsh", "D,S,T", 0x47000000, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"paddsh", "D,S,T", 0x4b000000, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"paddusb", "D,S,T", 0x47a00000, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"paddusb", "D,S,T", 0x4ba00000, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"paddush", "D,S,T", 0x47200000, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"paddush", "D,S,T", 0x4b200000, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"pandn", "D,S,T", 0x47e00002, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"pandn", "D,S,T", 0x4be00002, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"pavgb", "D,S,T", 0x46600000, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"pavgb", "D,S,T", 0x4b200008, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"pavgh", "D,S,T", 0x46400000, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"pavgh", "D,S,T", 0x4b000008, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"pcmpeqb", "D,S,T", 0x46c00001, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"pcmpeqb", "D,S,T", 0x4b800009, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"pcmpeqh", "D,S,T", 0x46800001, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"pcmpeqh", "D,S,T", 0x4b400009, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"pcmpeqw", "D,S,T", 0x46400001, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"pcmpeqw", "D,S,T", 0x4b000009, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"pcmpgtb", "D,S,T", 0x46e00001, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"pcmpgtb", "D,S,T", 0x4ba00009, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"pcmpgth", "D,S,T", 0x46a00001, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"pcmpgth", "D,S,T", 0x4b600009, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"pcmpgtw", "D,S,T", 0x46600001, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"pcmpgtw", "D,S,T", 0x4b200009, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"pextrh", "D,S,T", 0x45c00002, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"pextrh", "D,S,T", 0x4b40000e, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"pinsrh_0", "D,S,T", 0x47800003, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"pinsrh_0", "D,S,T", 0x4b800003, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"pinsrh_1", "D,S,T", 0x47a00003, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"pinsrh_1", "D,S,T", 0x4ba00003, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"pinsrh_2", "D,S,T", 0x47c00003, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"pinsrh_2", "D,S,T", 0x4bc00003, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"pinsrh_3", "D,S,T", 0x47e00003, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"pinsrh_3", "D,S,T", 0x4be00003, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"pmaddhw", "D,S,T", 0x45e00002, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"pmaddhw", "D,S,T", 0x4b60000e, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"pmaxsh", "D,S,T", 0x46800000, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"pmaxsh", "D,S,T", 0x4b400008, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"pmaxub", "D,S,T", 0x46c00000, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"pmaxub", "D,S,T", 0x4b800008, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"pminsh", "D,S,T", 0x46a00000, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"pminsh", "D,S,T", 0x4b600008, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"pminub", "D,S,T", 0x46e00000, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"pminub", "D,S,T", 0x4ba00008, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"pmovmskb", "D,S", 0x46a00005, 0xffff003f, RD_S|WR_D|FP_D, }, {"pmovmskb", "D,S", 0x4ba0000f, 0xffff003f, RD_S|WR_D|FP_D, }, {"pmulhuh", "D,S,T", 0x46e00002, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"pmulhuh", "D,S,T", 0x4ba0000a, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"pmulhh", "D,S,T", 0x46a00002, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"pmulhh", "D,S,T", 0x4b60000a, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"pmullh", "D,S,T", 0x46800002, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"pmullh", "D,S,T", 0x4b40000a, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"pmuluw", "D,S,T", 0x46c00002, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"pmuluw", "D,S,T", 0x4b80000a, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"pasubub", "D,S,T", 0x45a00001, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"pasubub", "D,S,T", 0x4b20000d, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"biadd", "D,S", 0x46800005, 0xffff003f, RD_S|WR_D|FP_D, }, {"biadd", "D,S", 0x4b80000f, 0xffff003f, RD_S|WR_D|FP_D, }, {"pshufh", "D,S,T", 0x47000002, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"pshufh", "D,S,T", 0x4b000002, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"psllh", "D,S,T", 0x46600002, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"psllh", "D,S,T", 0x4b20000a, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"psllw", "D,S,T", 0x46400002, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"psllw", "D,S,T", 0x4b00000a, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"psrah", "D,S,T", 0x46a00003, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"psrah", "D,S,T", 0x4b60000b, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"psraw", "D,S,T", 0x46800003, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"psraw", "D,S,T", 0x4b40000b, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"psrlh", "D,S,T", 0x46600003, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"psrlh", "D,S,T", 0x4b20000b, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"psrlw", "D,S,T", 0x46400003, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"psrlw", "D,S,T", 0x4b00000b, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"psubb", "D,S,T", 0x47c00001, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"psubb", "D,S,T", 0x4bc00001, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"psubh", "D,S,T", 0x47400001, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"psubh", "D,S,T", 0x4b400001, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"psubw", "D,S,T", 0x47600001, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"psubw", "D,S,T", 0x4b600001, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"psubd", "D,S,T", 0x47e00001, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"psubd", "D,S,T", 0x4be00001, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"psubsb", "D,S,T", 0x47800001, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"psubsb", "D,S,T", 0x4b800001, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"psubsh", "D,S,T", 0x47000001, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"psubsh", "D,S,T", 0x4b000001, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"psubusb", "D,S,T", 0x47a00001, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"psubusb", "D,S,T", 0x4ba00001, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"psubush", "D,S,T", 0x47200001, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"psubush", "D,S,T", 0x4b200001, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"punpckhbh", "D,S,T", 0x47600003, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"punpckhbh", "D,S,T", 0x4b600003, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"punpckhhw", "D,S,T", 0x47200003, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"punpckhhw", "D,S,T", 0x4b200003, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"punpckhwd", "D,S,T", 0x46e00003, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"punpckhwd", "D,S,T", 0x4ba0000b, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"punpcklbh", "D,S,T", 0x47400003, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"punpcklbh", "D,S,T", 0x4b400003, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"punpcklhw", "D,S,T", 0x47000003, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"punpcklhw", "D,S,T", 0x4b000003, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"punpcklwd", "D,S,T", 0x46c00003, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"punpcklwd", "D,S,T", 0x4b80000b, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, }, {"sequ", "S,T", 0x46800032, 0xffe007ff, RD_S|RD_T|WR_CC|FP_D, }, {"sequ", "S,T", 0x4b80000c, 0xffe007ff, RD_S|RD_T|WR_CC|FP_D, }, /* No hazard protection on coprocessor instructions--they shouldn't change the state of the processor and if they do it's up to the user to put in nops as necessary. These are at the end so that the disassembler recognizes more specific versions first. */ {"c0", "C", 0x42000000, 0xfe000000, CP, }, {"c1", "C", 0x46000000, 0xfe000000, FP_S, }, {"c2", "C", 0x4a000000, 0xfe000000, CP, }, {"c3", "C", 0x4e000000, 0xfe000000, CP, }, {"cop0", "C", 0, (int) M_COP0, INSN_MACRO, }, {"cop1", "C", 0, (int) M_COP1, INSN_MACRO, INSN2_M_FP_S, }, {"cop2", "C", 0, (int) M_COP2, INSN_MACRO, }, {"cop3", "C", 0, (int) M_COP3, INSN_MACRO, } }; static const int mips_num_opcodes = sizeof (mips_opcodes) / sizeof (mips_opcodes[0]); #undef LDD #undef LCD #undef UBD #undef CBD #undef COD #undef CLD #undef CBL #undef TRAP #undef SM #undef WR_d #undef WR_t #undef WR_31 #undef WR_D #undef WR_T #undef WR_S #undef RD_s #undef RD_b #undef RD_t #undef RD_S #undef RD_T #undef RD_R #undef WR_CC #undef RD_CC #undef RD_C0 #undef RD_C1 #undef RD_C2 #undef RD_C3 #undef WR_C0 #undef WR_C1 #undef WR_C2 #undef WR_C3 #undef CP #undef WR_HI #undef RD_HI #undef MOD_HI #undef WR_LO #undef RD_LO #undef MOD_LO #undef WR_HILO #undef RD_HILO #undef MOD_HILO #undef IS_M #undef WR_MACC #undef RD_MACC #undef WR_a #undef RD_a #undef MOD_a #undef DSP_VOLA ================================================ FILE: tools/virtualmips/mips-opcode.h ================================================ /* * Mips opcode list. * * Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, * 2003, 2004, 2005, 2008, 2009, 2010 * Free Software Foundation, Inc. * Contributed by Ralph Campbell and OSF * Commented and modified by Ian Lance Taylor, Cygnus Support * Adapted for VirtualMIPS by Serge Vakulenko. * * This file is part of the virtualmips distribution. * See LICENSE file for terms of the license. */ #ifndef _MIPS_H_ #define _MIPS_H_ /* These are bit masks and shift counts to use to access the various fields of an instruction. To retrieve the X field of an instruction, use the expression (i >> OP_SH_X) & OP_MASK_X To set the same field (to j), use i = (i &~ (OP_MASK_X << OP_SH_X)) | (j << OP_SH_X) Make sure you use fields that are appropriate for the instruction, of course. The 'i' format uses OP, RS, RT and IMMEDIATE. The 'j' format uses OP and TARGET. The 'r' format uses OP, RS, RT, RD, SHAMT and FUNCT. The 'b' format uses OP, RS, RT and DELTA. The floating point 'i' format uses OP, RS, RT and IMMEDIATE. The floating point 'r' format uses OP, FMT, FT, FS, FD and FUNCT. A breakpoint instruction uses OP, CODE and SPEC (10 bits of the breakpoint instruction are not defined; Kane says the breakpoint code field in BREAK is 20 bits; yet MIPS assemblers and debuggers only use ten bits). An optional two-operand form of break/sdbbp allows the lower ten bits to be set too, and MIPS32 and later architectures allow 20 bits to be set with a signal operand (using CODE20). The syscall instruction uses CODE20. The general coprocessor instructions use COPZ. */ #define OP_MASK_OP 0x3f #define OP_SH_OP 26 #define OP_MASK_RS 0x1f #define OP_SH_RS 21 #define OP_MASK_FR 0x1f #define OP_SH_FR 21 #define OP_MASK_FMT 0x1f #define OP_SH_FMT 21 #define OP_MASK_BCC 0x7 #define OP_SH_BCC 18 #define OP_MASK_CODE 0x3ff #define OP_SH_CODE 16 #define OP_MASK_CODE2 0x3ff #define OP_SH_CODE2 6 #define OP_MASK_RT 0x1f #define OP_SH_RT 16 #define OP_MASK_FT 0x1f #define OP_SH_FT 16 #define OP_MASK_CACHE 0x1f #define OP_SH_CACHE 16 #define OP_MASK_RD 0x1f #define OP_SH_RD 11 #define OP_MASK_FS 0x1f #define OP_SH_FS 11 #define OP_MASK_PREFX 0x1f #define OP_SH_PREFX 11 #define OP_MASK_CCC 0x7 #define OP_SH_CCC 8 #define OP_MASK_CODE20 0xfffff /* 20 bit syscall/breakpoint code. */ #define OP_SH_CODE20 6 #define OP_MASK_SHAMT 0x1f #define OP_SH_SHAMT 6 #define OP_MASK_FD 0x1f #define OP_SH_FD 6 #define OP_MASK_TARGET 0x3ffffff #define OP_SH_TARGET 0 #define OP_MASK_COPZ 0x1ffffff #define OP_SH_COPZ 0 #define OP_MASK_IMMEDIATE 0xffff #define OP_SH_IMMEDIATE 0 #define OP_MASK_DELTA 0xffff #define OP_SH_DELTA 0 #define OP_MASK_FUNCT 0x3f #define OP_SH_FUNCT 0 #define OP_MASK_SPEC 0x3f #define OP_SH_SPEC 0 #define OP_SH_LOCC 8 /* FP condition code. */ #define OP_SH_HICC 18 /* FP condition code. */ #define OP_MASK_CC 0x7 #define OP_SH_COP1NORM 25 /* Normal COP1 encoding. */ #define OP_MASK_COP1NORM 0x1 /* a single bit. */ #define OP_SH_COP1SPEC 21 /* COP1 encodings. */ #define OP_MASK_COP1SPEC 0xf #define OP_MASK_COP1SCLR 0x4 #define OP_MASK_COP1CMP 0x3 #define OP_SH_COP1CMP 4 #define OP_SH_FORMAT 21 /* FP short format field. */ #define OP_MASK_FORMAT 0x7 #define OP_SH_TRUE 16 #define OP_MASK_TRUE 0x1 #define OP_SH_GE 17 #define OP_MASK_GE 0x01 #define OP_SH_UNSIGNED 16 #define OP_MASK_UNSIGNED 0x1 #define OP_SH_HINT 16 #define OP_MASK_HINT 0x1f #define OP_SH_MMI 0 /* Multimedia (parallel) op. */ #define OP_MASK_MMI 0x3f #define OP_SH_MMISUB 6 #define OP_MASK_MMISUB 0x1f #define OP_MASK_PERFREG 0x1f /* Performance monitoring. */ #define OP_SH_PERFREG 1 #define OP_SH_SEL 0 /* Coprocessor select field. */ #define OP_MASK_SEL 0x7 /* The sel field of mfcZ and mtcZ. */ #define OP_SH_CODE19 6 /* 19 bit wait code. */ #define OP_MASK_CODE19 0x7ffff #define OP_SH_ALN 21 #define OP_MASK_ALN 0x7 #define OP_SH_VSEL 21 #define OP_MASK_VSEL 0x1f #define OP_MASK_VECBYTE 0x7 /* Selector field is really 4 bits, but 0x8-0xf don't select bytes. */ #define OP_SH_VECBYTE 22 #define OP_MASK_VECALIGN 0x7 /* Vector byte-align (alni.ob) op. */ #define OP_SH_VECALIGN 21 #define OP_MASK_INSMSB 0x1f /* "ins" MSB. */ #define OP_SH_INSMSB 11 #define OP_MASK_EXTMSBD 0x1f /* "ext" MSBD. */ #define OP_SH_EXTMSBD 11 /* MIPS DSP ASE */ #define OP_SH_DSPACC 11 #define OP_MASK_DSPACC 0x3 #define OP_SH_DSPACC_S 21 #define OP_MASK_DSPACC_S 0x3 #define OP_SH_DSPSFT 20 #define OP_MASK_DSPSFT 0x3f #define OP_SH_DSPSFT_7 19 #define OP_MASK_DSPSFT_7 0x7f #define OP_SH_SA3 21 #define OP_MASK_SA3 0x7 #define OP_SH_SA4 21 #define OP_MASK_SA4 0xf #define OP_SH_IMM8 16 #define OP_MASK_IMM8 0xff #define OP_SH_IMM10 16 #define OP_MASK_IMM10 0x3ff #define OP_SH_WRDSP 11 #define OP_MASK_WRDSP 0x3f #define OP_SH_RDDSP 16 #define OP_MASK_RDDSP 0x3f #define OP_SH_BP 11 #define OP_MASK_BP 0x3 /* MIPS MT ASE */ #define OP_SH_MT_U 5 #define OP_MASK_MT_U 0x1 #define OP_SH_MT_H 4 #define OP_MASK_MT_H 0x1 #define OP_SH_MTACC_T 18 #define OP_MASK_MTACC_T 0x3 #define OP_SH_MTACC_D 13 #define OP_MASK_MTACC_D 0x3 #define OP_OP_COP0 0x10 #define OP_OP_COP1 0x11 #define OP_OP_COP2 0x12 #define OP_OP_COP3 0x13 #define OP_OP_LWC1 0x31 #define OP_OP_LWC2 0x32 #define OP_OP_LWC3 0x33 /* a.k.a. pref */ #define OP_OP_LDC1 0x35 #define OP_OP_LDC2 0x36 #define OP_OP_LDC3 0x37 /* a.k.a. ld */ #define OP_OP_SWC1 0x39 #define OP_OP_SWC2 0x3a #define OP_OP_SWC3 0x3b #define OP_OP_SDC1 0x3d #define OP_OP_SDC2 0x3e #define OP_OP_SDC3 0x3f /* a.k.a. sd */ /* Values in the 'VSEL' field. */ #define MDMX_FMTSEL_IMM_QH 0x1d #define MDMX_FMTSEL_IMM_OB 0x1e #define MDMX_FMTSEL_VEC_QH 0x15 #define MDMX_FMTSEL_VEC_OB 0x16 /* UDI */ #define OP_SH_UDI1 6 #define OP_MASK_UDI1 0x1f #define OP_SH_UDI2 6 #define OP_MASK_UDI2 0x3ff #define OP_SH_UDI3 6 #define OP_MASK_UDI3 0x7fff #define OP_SH_UDI4 6 #define OP_MASK_UDI4 0xfffff /* Octeon */ #define OP_SH_BBITIND 16 #define OP_MASK_BBITIND 0x1f #define OP_SH_CINSPOS 6 #define OP_MASK_CINSPOS 0x1f #define OP_SH_CINSLM1 11 #define OP_MASK_CINSLM1 0x1f #define OP_SH_SEQI 6 #define OP_MASK_SEQI 0x3ff /* This structure holds information for a particular instruction. */ struct mips_opcode { /* The name of the instruction. */ const char *name; /* A string describing the arguments for this instruction. */ const char *args; /* The basic opcode for the instruction. When assembling, this opcode is modified by the arguments to produce the actual opcode that is used. If pinfo is INSN_MACRO, then this is 0. */ unsigned long match; /* If pinfo is not INSN_MACRO, then this is a bit mask for the relevant portions of the opcode when disassembling. If the actual opcode anded with the match field equals the opcode field, then we have found the correct instruction. If pinfo is INSN_MACRO, then this field is the macro identifier. */ unsigned long mask; /* For a macro, this is INSN_MACRO. Otherwise, it is a collection of bits describing the instruction, notably any relevant hazard information. */ unsigned long pinfo; /* A collection of additional bits describing the instruction. */ unsigned long pinfo2; }; /* These are the characters which may appear in the args field of an instruction. They appear in the order in which the fields appear when the instruction is used. Commas and parentheses in the args string are ignored when assembling, and written into the output when disassembling. Each of these characters corresponds to a mask field defined above. "1" 5 bit sync type (OP_*_SHAMT) "<" 5 bit shift amount (OP_*_SHAMT) ">" shift amount between 32 and 63, stored after subtracting 32 (OP_*_SHAMT) "a" 26 bit target address (OP_*_TARGET) "b" 5 bit base register (OP_*_RS) "c" 10 bit breakpoint code (OP_*_CODE) "d" 5 bit destination register specifier (OP_*_RD) "h" 5 bit prefx hint (OP_*_PREFX) "i" 16 bit unsigned immediate (OP_*_IMMEDIATE) "j" 16 bit signed immediate (OP_*_DELTA) "k" 5 bit cache opcode in target register position (OP_*_CACHE) Also used for immediate operands in vr5400 vector insns. "o" 16 bit signed offset (OP_*_DELTA) "p" 16 bit PC relative branch target address (OP_*_DELTA) "q" 10 bit extra breakpoint code (OP_*_CODE2) "r" 5 bit same register used as both source and target (OP_*_RS) "s" 5 bit source register specifier (OP_*_RS) "t" 5 bit target register (OP_*_RT) "u" 16 bit upper 16 bits of address (OP_*_IMMEDIATE) "v" 5 bit same register used as both source and destination (OP_*_RS) "w" 5 bit same register used as both target and destination (OP_*_RT) "U" 5 bit same destination register in both OP_*_RD and OP_*_RT (used by clo and clz) "C" 25 bit coprocessor function code (OP_*_COPZ) "B" 20 bit syscall/breakpoint function code (OP_*_CODE20) "J" 19 bit wait function code (OP_*_CODE19) "x" accept and ignore register name "z" must be zero register "K" 5 bit Hardware Register (rdhwr instruction) (OP_*_RD) "+A" 5 bit ins/ext/dins/dext/dinsm/dextm position, which becomes LSB (OP_*_SHAMT). Enforces: 0 <= pos < 32. "+B" 5 bit ins/dins size, which becomes MSB (OP_*_INSMSB). Requires that "+A" or "+E" occur first to set position. Enforces: 0 < (pos+size) <= 32. "+C" 5 bit ext/dext size, which becomes MSBD (OP_*_EXTMSBD). Requires that "+A" or "+E" occur first to set position. Enforces: 0 < (pos+size) <= 32. (Also used by "dext" w/ different limits, but limits for that are checked by the M_DEXT macro.) "+E" 5 bit dinsu/dextu position, which becomes LSB-32 (OP_*_SHAMT). Enforces: 32 <= pos < 64. "+F" 5 bit "dinsm/dinsu" size, which becomes MSB-32 (OP_*_INSMSB). Requires that "+A" or "+E" occur first to set position. Enforces: 32 < (pos+size) <= 64. "+G" 5 bit "dextm" size, which becomes MSBD-32 (OP_*_EXTMSBD). Requires that "+A" or "+E" occur first to set position. Enforces: 32 < (pos+size) <= 64. "+H" 5 bit "dextu" size, which becomes MSBD (OP_*_EXTMSBD). Requires that "+A" or "+E" occur first to set position. Enforces: 32 < (pos+size) <= 64. Floating point instructions: "D" 5 bit destination register (OP_*_FD) "M" 3 bit compare condition code (OP_*_CCC) (only used for mips4 and up) "N" 3 bit branch condition code (OP_*_BCC) (only used for mips4 and up) "S" 5 bit fs source 1 register (OP_*_FS) "T" 5 bit ft source 2 register (OP_*_FT) "R" 5 bit fr source 3 register (OP_*_FR) "V" 5 bit same register used as floating source and destination (OP_*_FS) "W" 5 bit same register used as floating target and destination (OP_*_FT) Coprocessor instructions: "E" 5 bit target register (OP_*_RT) "G" 5 bit destination register (OP_*_RD) "H" 3 bit sel field for (d)mtc* and (d)mfc* (OP_*_SEL) "P" 5 bit performance-monitor register (OP_*_PERFREG) "e" 5 bit vector register byte specifier (OP_*_VECBYTE) "%" 3 bit immediate vr5400 vector alignment operand (OP_*_VECALIGN) see also "k" above "+D" Combined destination register ("G") and sel ("H") for CP0 ops, for pretty-printing in disassembly only. Macro instructions: "A" General 32 bit expression "I" 32 bit immediate (value placed in imm_expr). "+I" 32 bit immediate (value placed in imm2_expr). "F" 64 bit floating point constant in .rdata "L" 64 bit floating point constant in .lit8 "f" 32 bit floating point constant "l" 32 bit floating point constant in .lit4 MDMX instruction operands (note that while these use the FP register fields, they accept both $fN and $vN names for the registers): "O" MDMX alignment offset (OP_*_ALN) "Q" MDMX vector/scalar/immediate source (OP_*_VSEL and OP_*_FT) "X" MDMX destination register (OP_*_FD) "Y" MDMX source register (OP_*_FS) "Z" MDMX source register (OP_*_FT) DSP ASE usage: "2" 2 bit unsigned immediate for byte align (OP_*_BP) "3" 3 bit unsigned immediate (OP_*_SA3) "4" 4 bit unsigned immediate (OP_*_SA4) "5" 8 bit unsigned immediate (OP_*_IMM8) "6" 5 bit unsigned immediate (OP_*_RS) "7" 2 bit dsp accumulator register (OP_*_DSPACC) "8" 6 bit unsigned immediate (OP_*_WRDSP) "9" 2 bit dsp accumulator register (OP_*_DSPACC_S) "0" 6 bit signed immediate (OP_*_DSPSFT) ":" 7 bit signed immediate (OP_*_DSPSFT_7) "'" 6 bit unsigned immediate (OP_*_RDDSP) "@" 10 bit signed immediate (OP_*_IMM10) MT ASE usage: "!" 1 bit usermode flag (OP_*_MT_U) "$" 1 bit load high flag (OP_*_MT_H) "*" 2 bit dsp/smartmips accumulator register (OP_*_MTACC_T) "&" 2 bit dsp/smartmips accumulator register (OP_*_MTACC_D) "g" 5 bit coprocessor 1 and 2 destination register (OP_*_RD) "+t" 5 bit coprocessor 0 destination register (OP_*_RT) "+T" 5 bit coprocessor 0 destination register (OP_*_RT) - disassembly only UDI immediates: "+1" UDI immediate bits 6-10 "+2" UDI immediate bits 6-15 "+3" UDI immediate bits 6-20 "+4" UDI immediate bits 6-25 Octeon: "+x" Bit index field of bbit. Enforces: 0 <= index < 32. "+X" Bit index field of bbit aliasing bbit32. Matches if 32 <= index < 64, otherwise skips to next candidate. "+p" Position field of cins/cins32/exts/exts32. Enforces 0 <= pos < 32. "+P" Position field of cins/exts aliasing cins32/exts32. Matches if 32 <= pos < 64, otherwise skips to next candidate. "+Q" Immediate field of seqi/snei. Enforces -512 <= imm < 512. "+s" Length-minus-one field of cins/exts. Enforces: 0 <= lenm1 < 32. "+S" Length-minus-one field of cins32/exts32 or cins/exts aliasing cint32/exts32. Enforces non-negative value and that pos + lenm1 < 32 or pos + lenm1 < 64 depending whether previous position field is "+p" or "+P". Other: "()" parens surrounding optional value "," separates operands "[]" brackets around index for vector-op scalar operand specifier (vr5400) "+" Start of extension sequence. Characters used so far, for quick reference when adding more: "1234567890" "%[]<>(),+:'@!$*&" "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "abcdefghijklopqrstuvwxz" Extension character sequences used so far ("+" followed by the following), for quick reference when adding more: "1234" "ABCDEFGHIPQSTX" "pstx" */ /* These are the bits which may be set in the pinfo field of an instructions, if it is not equal to INSN_MACRO. */ /* Modifies the general purpose register in OP_*_RD. */ #define INSN_WRITE_GPR_D 0x00000001 /* Modifies the general purpose register in OP_*_RT. */ #define INSN_WRITE_GPR_T 0x00000002 /* Modifies general purpose register 31. */ #define INSN_WRITE_GPR_31 0x00000004 /* Modifies the floating point register in OP_*_FD. */ #define INSN_WRITE_FPR_D 0x00000008 /* Modifies the floating point register in OP_*_FS. */ #define INSN_WRITE_FPR_S 0x00000010 /* Modifies the floating point register in OP_*_FT. */ #define INSN_WRITE_FPR_T 0x00000020 /* Reads the general purpose register in OP_*_RS. */ #define INSN_READ_GPR_S 0x00000040 /* Reads the general purpose register in OP_*_RT. */ #define INSN_READ_GPR_T 0x00000080 /* Reads the floating point register in OP_*_FS. */ #define INSN_READ_FPR_S 0x00000100 /* Reads the floating point register in OP_*_FT. */ #define INSN_READ_FPR_T 0x00000200 /* Reads the floating point register in OP_*_FR. */ #define INSN_READ_FPR_R 0x00000400 /* Modifies coprocessor condition code. */ #define INSN_WRITE_COND_CODE 0x00000800 /* Reads coprocessor condition code. */ #define INSN_READ_COND_CODE 0x00001000 /* TLB operation. */ #define INSN_TLB 0x00002000 /* Reads coprocessor register other than floating point register. */ #define INSN_COP 0x00004000 /* Instruction loads value from memory, requiring delay. */ #define INSN_LOAD_MEMORY_DELAY 0x00008000 /* Instruction loads value from coprocessor, requiring delay. */ #define INSN_LOAD_COPROC_DELAY 0x00010000 /* Instruction has unconditional branch delay slot. */ #define INSN_UNCOND_BRANCH_DELAY 0x00020000 /* Instruction has conditional branch delay slot. */ #define INSN_COND_BRANCH_DELAY 0x00040000 /* Conditional branch likely: if branch not taken, insn nullified. */ #define INSN_COND_BRANCH_LIKELY 0x00080000 /* Moves to coprocessor register, requiring delay. */ #define INSN_COPROC_MOVE_DELAY 0x00100000 /* Loads coprocessor register from memory, requiring delay. */ #define INSN_COPROC_MEMORY_DELAY 0x00200000 /* Reads the HI register. */ #define INSN_READ_HI 0x00400000 /* Reads the LO register. */ #define INSN_READ_LO 0x00800000 /* Modifies the HI register. */ #define INSN_WRITE_HI 0x01000000 /* Modifies the LO register. */ #define INSN_WRITE_LO 0x02000000 /* Takes a trap (easier to keep out of delay slot). */ #define INSN_TRAP 0x04000000 /* Instruction stores value into memory. */ #define INSN_STORE_MEMORY 0x08000000 /* Instruction uses single precision floating point. */ #define FP_S 0x10000000 /* Instruction uses double precision floating point. */ #define FP_D 0x20000000 /* Instruction is part of the tx39's integer multiply family. */ #define INSN_MULT 0x40000000 /* Instruction synchronize shared memory. */ #define INSN_SYNC 0x80000000 /* Instruction is actually a macro. It should be ignored by the disassembler, and requires special treatment by the assembler. */ #define INSN_MACRO 0xffffffff /* These are the bits which may be set in the pinfo2 field of an instruction. */ /* Instruction is a simple alias (I.E. "move" for daddu/addu/or) */ #define INSN2_ALIAS 0x00000001 /* Instruction reads MDMX accumulator. */ #define INSN2_READ_MDMX_ACC 0x00000002 /* Instruction writes MDMX accumulator. */ #define INSN2_WRITE_MDMX_ACC 0x00000004 /* Macro uses single-precision floating-point instructions. This should only be set for macros. For instructions, FP_S in pinfo carries the same information. */ #define INSN2_M_FP_S 0x00000008 /* Macro uses double-precision floating-point instructions. This should only be set for macros. For instructions, FP_D in pinfo carries the same information. */ #define INSN2_M_FP_D 0x00000010 /* Masks used for Chip specific instructions. */ #define INSN_CHIP_MASK 0xc3ff0820 /* Cavium Networks Octeon instructions. */ #define INSN_OCTEON 0x00000800 /* Masks used for MIPS-defined ASEs. */ #define INSN_ASE_MASK 0x3c00f000 /* DSP ASE */ #define INSN_DSP 0x00001000 #define INSN_DSP64 0x00002000 /* 0x00004000 is unused. */ /* MIPS-3D ASE */ #define INSN_MIPS3D 0x00008000 /* MIPS R4650 instruction. */ #define INSN_4650 0x00010000 /* LSI R4010 instruction. */ #define INSN_4010 0x00020000 /* NEC VR4100 instruction. */ #define INSN_4100 0x00040000 /* Toshiba R3900 instruction. */ #define INSN_3900 0x00080000 /* MIPS R10000 instruction. */ #define INSN_10000 0x00100000 /* Broadcom SB-1 instruction. */ #define INSN_SB1 0x00200000 /* NEC VR4111/VR4181 instruction. */ #define INSN_4111 0x00400000 /* NEC VR4120 instruction. */ #define INSN_4120 0x00800000 /* NEC VR5400 instruction. */ #define INSN_5400 0x01000000 /* NEC VR5500 instruction. */ #define INSN_5500 0x02000000 /* MDMX ASE */ #define INSN_MDMX 0x04000000 /* MT ASE */ #define INSN_MT 0x08000000 /* SmartMIPS ASE */ #define INSN_SMARTMIPS 0x10000000 /* DSP R2 ASE */ #define INSN_DSPR2 0x20000000 /* ST Microelectronics Loongson 2E. */ #define INSN_LOONGSON_2E 0x40000000 /* ST Microelectronics Loongson 2F. */ #define INSN_LOONGSON_2F 0x80000000 /* RMI Xlr instruction */ #define INSN_XLR 0x00000020 /* MIPS ISA defines, use instead of hardcoding ISA level. */ #define ISA_UNKNOWN 0 /* Gas internal use. */ #define ISA_MIPS1 INSN_ISA1 #define ISA_MIPS2 INSN_ISA2 #define ISA_MIPS3 INSN_ISA3 #define ISA_MIPS4 INSN_ISA4 #define ISA_MIPS5 INSN_ISA5 #define ISA_MIPS32 INSN_ISA32 #define ISA_MIPS64 INSN_ISA64 #define ISA_MIPS32R2 INSN_ISA32R2 #define ISA_MIPS64R2 INSN_ISA64R2 /* CPU defines, use instead of hardcoding processor number. Keep this in sync with bfd/archures.c in order for machine selection to work. */ #define CPU_UNKNOWN 0 /* Gas internal use. */ #define CPU_R3000 3000 #define CPU_R3900 3900 #define CPU_R4000 4000 #define CPU_R4010 4010 #define CPU_VR4100 4100 #define CPU_R4111 4111 #define CPU_VR4120 4120 #define CPU_R4300 4300 #define CPU_R4400 4400 #define CPU_R4600 4600 #define CPU_R4650 4650 #define CPU_R5000 5000 #define CPU_VR5400 5400 #define CPU_VR5500 5500 #define CPU_R6000 6000 #define CPU_RM7000 7000 #define CPU_R8000 8000 #define CPU_RM9000 9000 #define CPU_R10000 10000 #define CPU_R12000 12000 #define CPU_R14000 14000 #define CPU_R16000 16000 #define CPU_MIPS16 16 #define CPU_MIPS32 32 #define CPU_MIPS32R2 33 #define CPU_MIPS5 5 #define CPU_MIPS64 64 #define CPU_MIPS64R2 65 #define CPU_SB1 12310201 /* octal 'SB', 01. */ #define CPU_LOONGSON_2E 3001 #define CPU_LOONGSON_2F 3002 #define CPU_OCTEON 6501 #define CPU_XLR 887682 /* decimal 'XLR' */ /* This is a list of macro expanded instructions. _I appended means immediate _A appended means address _AB appended means address with base register _D appended means 64 bit floating point constant _S appended means 32 bit floating point constant. */ enum { M_ABS, M_ADD_I, M_ADDU_I, M_AND_I, M_BALIGN, M_BEQ, M_BEQ_I, M_BEQL_I, M_BGE, M_BGEL, M_BGE_I, M_BGEL_I, M_BGEU, M_BGEUL, M_BGEU_I, M_BGEUL_I, M_BGT, M_BGTL, M_BGT_I, M_BGTL_I, M_BGTU, M_BGTUL, M_BGTU_I, M_BGTUL_I, M_BLE, M_BLEL, M_BLE_I, M_BLEL_I, M_BLEU, M_BLEUL, M_BLEU_I, M_BLEUL_I, M_BLT, M_BLTL, M_BLT_I, M_BLTL_I, M_BLTU, M_BLTUL, M_BLTU_I, M_BLTUL_I, M_BNE, M_BNE_I, M_BNEL_I, M_CACHE_AB, M_DABS, M_DADD_I, M_DADDU_I, M_DDIV_3, M_DDIV_3I, M_DDIVU_3, M_DDIVU_3I, M_DEXT, M_DINS, M_DIV_3, M_DIV_3I, M_DIVU_3, M_DIVU_3I, M_DLA_AB, M_DLCA_AB, M_DLI, M_DMUL, M_DMUL_I, M_DMULO, M_DMULO_I, M_DMULOU, M_DMULOU_I, M_DREM_3, M_DREM_3I, M_DREMU_3, M_DREMU_3I, M_DSUB_I, M_DSUBU_I, M_DSUBU_I_2, M_J_A, M_JAL_1, M_JAL_2, M_JAL_A, M_L_DOB, M_L_DAB, M_LA_AB, M_LB_A, M_LB_AB, M_LBU_A, M_LBU_AB, M_LCA_AB, M_LD_A, M_LD_OB, M_LD_AB, M_LDC1_AB, M_LDC2_AB, M_LDC3_AB, M_LDL_AB, M_LDR_AB, M_LH_A, M_LH_AB, M_LHU_A, M_LHU_AB, M_LI, M_LI_D, M_LI_DD, M_LI_S, M_LI_SS, M_LL_AB, M_LLD_AB, M_LS_A, M_LW_A, M_LW_AB, M_LWC0_A, M_LWC0_AB, M_LWC1_A, M_LWC1_AB, M_LWC2_A, M_LWC2_AB, M_LWC3_A, M_LWC3_AB, M_LWL_A, M_LWL_AB, M_LWR_A, M_LWR_AB, M_LWU_AB, M_MSGSND, M_MSGLD, M_MSGLD_T, M_MSGWAIT, M_MSGWAIT_T, M_MOVE, M_MUL, M_MUL_I, M_MULO, M_MULO_I, M_MULOU, M_MULOU_I, M_NOR_I, M_OR_I, M_REM_3, M_REM_3I, M_REMU_3, M_REMU_3I, M_DROL, M_ROL, M_DROL_I, M_ROL_I, M_DROR, M_ROR, M_DROR_I, M_ROR_I, M_S_DA, M_S_DOB, M_S_DAB, M_S_S, M_SC_AB, M_SCD_AB, M_SD_A, M_SD_OB, M_SD_AB, M_SDC1_AB, M_SDC2_AB, M_SDC3_AB, M_SDL_AB, M_SDR_AB, M_SEQ, M_SEQ_I, M_SGE, M_SGE_I, M_SGEU, M_SGEU_I, M_SGT, M_SGT_I, M_SGTU, M_SGTU_I, M_SLE, M_SLE_I, M_SLEU, M_SLEU_I, M_SLT_I, M_SLTU_I, M_SNE, M_SNE_I, M_SB_A, M_SB_AB, M_SH_A, M_SH_AB, M_SW_A, M_SW_AB, M_SWC0_A, M_SWC0_AB, M_SWC1_A, M_SWC1_AB, M_SWC2_A, M_SWC2_AB, M_SWC3_A, M_SWC3_AB, M_SWL_A, M_SWL_AB, M_SWR_A, M_SWR_AB, M_SUB_I, M_SUBU_I, M_SUBU_I_2, M_TEQ_I, M_TGE_I, M_TGEU_I, M_TLT_I, M_TLTU_I, M_TNE_I, M_TRUNCWD, M_TRUNCWS, M_ULD, M_ULD_A, M_ULH, M_ULH_A, M_ULHU, M_ULHU_A, M_ULW, M_ULW_A, M_USH, M_USH_A, M_USW, M_USW_A, M_USD, M_USD_A, M_XOR_I, M_COP0, M_COP1, M_COP2, M_COP3, M_NUM_MACROS }; /* The order of overloaded instructions matters. Label arguments and register arguments look the same. Instructions that can have either for arguments must apear in the correct order in this table for the assembler to pick the right one. In other words, entries with immediate operands must apear after the same instruction with registers. Many instructions are short hand for other instructions (i.e., The jal instruction is short for jalr ). */ /* The rest of this file adds definitions for the mips16 TinyRISC processor. */ /* These are the bitmasks and shift counts used for the different fields in the instruction formats. Other than OP, no masks are provided for the fixed portions of an instruction, since they are not needed. The I format uses IMM11. The RI format uses RX and IMM8. The RR format uses RX, and RY. The RRI format uses RX, RY, and IMM5. The RRR format uses RX, RY, and RZ. The RRI_A format uses RX, RY, and IMM4. The SHIFT format uses RX, RY, and SHAMT. The I8 format uses IMM8. The I8_MOVR32 format uses RY and REGR32. The IR_MOV32R format uses REG32R and MOV32Z. The I64 format uses IMM8. The RI64 format uses RY and IMM5. */ #define MIPS16OP_MASK_OP 0x1f #define MIPS16OP_SH_OP 11 #define MIPS16OP_MASK_IMM11 0x7ff #define MIPS16OP_SH_IMM11 0 #define MIPS16OP_MASK_RX 0x7 #define MIPS16OP_SH_RX 8 #define MIPS16OP_MASK_IMM8 0xff #define MIPS16OP_SH_IMM8 0 #define MIPS16OP_MASK_RY 0x7 #define MIPS16OP_SH_RY 5 #define MIPS16OP_MASK_IMM5 0x1f #define MIPS16OP_SH_IMM5 0 #define MIPS16OP_MASK_RZ 0x7 #define MIPS16OP_SH_RZ 2 #define MIPS16OP_MASK_IMM4 0xf #define MIPS16OP_SH_IMM4 0 #define MIPS16OP_MASK_REGR32 0x1f #define MIPS16OP_SH_REGR32 0 #define MIPS16OP_MASK_REG32R 0x1f #define MIPS16OP_SH_REG32R 3 #define MIPS16OP_EXTRACT_REG32R(i) ((((i) >> 5) & 7) | ((i) & 0x18)) #define MIPS16OP_MASK_MOVE32Z 0x7 #define MIPS16OP_SH_MOVE32Z 0 #define MIPS16OP_MASK_IMM6 0x3f #define MIPS16OP_SH_IMM6 5 /* These are the characters which may appears in the args field of a MIPS16 instruction. They appear in the order in which the fields appear when the instruction is used. Commas and parentheses in the args string are ignored when assembling, and written into the output when disassembling. "y" 3 bit register (MIPS16OP_*_RY) "x" 3 bit register (MIPS16OP_*_RX) "z" 3 bit register (MIPS16OP_*_RZ) "Z" 3 bit register (MIPS16OP_*_MOVE32Z) "v" 3 bit same register as source and destination (MIPS16OP_*_RX) "w" 3 bit same register as source and destination (MIPS16OP_*_RY) "0" zero register ($0) "S" stack pointer ($sp or $29) "P" program counter "R" return address register ($ra or $31) "X" 5 bit MIPS register (MIPS16OP_*_REGR32) "Y" 5 bit MIPS register (MIPS16OP_*_REG32R) "6" 6 bit unsigned break code (MIPS16OP_*_IMM6) "a" 26 bit jump address "e" 11 bit extension value "l" register list for entry instruction "L" register list for exit instruction The remaining codes may be extended. Except as otherwise noted, the full extended operand is a 16 bit signed value. "<" 3 bit unsigned shift count * 0 (MIPS16OP_*_RZ) (full 5 bit unsigned) ">" 3 bit unsigned shift count * 0 (MIPS16OP_*_RX) (full 5 bit unsigned) "[" 3 bit unsigned shift count * 0 (MIPS16OP_*_RZ) (full 6 bit unsigned) "]" 3 bit unsigned shift count * 0 (MIPS16OP_*_RX) (full 6 bit unsigned) "4" 4 bit signed immediate * 0 (MIPS16OP_*_IMM4) (full 15 bit signed) "5" 5 bit unsigned immediate * 0 (MIPS16OP_*_IMM5) "H" 5 bit unsigned immediate * 2 (MIPS16OP_*_IMM5) "W" 5 bit unsigned immediate * 4 (MIPS16OP_*_IMM5) "D" 5 bit unsigned immediate * 8 (MIPS16OP_*_IMM5) "j" 5 bit signed immediate * 0 (MIPS16OP_*_IMM5) "8" 8 bit unsigned immediate * 0 (MIPS16OP_*_IMM8) "V" 8 bit unsigned immediate * 4 (MIPS16OP_*_IMM8) "C" 8 bit unsigned immediate * 8 (MIPS16OP_*_IMM8) "U" 8 bit unsigned immediate * 0 (MIPS16OP_*_IMM8) (full 16 bit unsigned) "k" 8 bit signed immediate * 0 (MIPS16OP_*_IMM8) "K" 8 bit signed immediate * 8 (MIPS16OP_*_IMM8) "p" 8 bit conditional branch address (MIPS16OP_*_IMM8) "q" 11 bit branch address (MIPS16OP_*_IMM11) "A" 8 bit PC relative address * 4 (MIPS16OP_*_IMM8) "B" 5 bit PC relative address * 8 (MIPS16OP_*_IMM5) "E" 5 bit PC relative address * 4 (MIPS16OP_*_IMM5) "m" 7 bit register list for save instruction (18 bit extended) "M" 7 bit register list for restore instruction (18 bit extended) */ /* Save/restore encoding for the args field when all 4 registers are either saved as arguments or saved/restored as statics. */ #define MIPS16_ALL_ARGS 0xe #define MIPS16_ALL_STATICS 0xb /* For the mips16, we use the same opcode table format and a few of the same flags. However, most of the flags are different. */ /* Modifies the register in MIPS16OP_*_RX. */ #define MIPS16_INSN_WRITE_X 0x00000001 /* Modifies the register in MIPS16OP_*_RY. */ #define MIPS16_INSN_WRITE_Y 0x00000002 /* Modifies the register in MIPS16OP_*_RZ. */ #define MIPS16_INSN_WRITE_Z 0x00000004 /* Modifies the T ($24) register. */ #define MIPS16_INSN_WRITE_T 0x00000008 /* Modifies the SP ($29) register. */ #define MIPS16_INSN_WRITE_SP 0x00000010 /* Modifies the RA ($31) register. */ #define MIPS16_INSN_WRITE_31 0x00000020 /* Modifies the general purpose register in MIPS16OP_*_REG32R. */ #define MIPS16_INSN_WRITE_GPR_Y 0x00000040 /* Reads the register in MIPS16OP_*_RX. */ #define MIPS16_INSN_READ_X 0x00000080 /* Reads the register in MIPS16OP_*_RY. */ #define MIPS16_INSN_READ_Y 0x00000100 /* Reads the register in MIPS16OP_*_MOVE32Z. */ #define MIPS16_INSN_READ_Z 0x00000200 /* Reads the T ($24) register. */ #define MIPS16_INSN_READ_T 0x00000400 /* Reads the SP ($29) register. */ #define MIPS16_INSN_READ_SP 0x00000800 /* Reads the RA ($31) register. */ #define MIPS16_INSN_READ_31 0x00001000 /* Reads the program counter. */ #define MIPS16_INSN_READ_PC 0x00002000 /* Reads the general purpose register in MIPS16OP_*_REGR32. */ #define MIPS16_INSN_READ_GPR_X 0x00004000 /* Is an unconditional branch insn. */ #define MIPS16_INSN_UNCOND_BRANCH 0x00008000 /* Is a conditional branch insn. */ #define MIPS16_INSN_COND_BRANCH 0x00010000 /* The following flags have the same value for the mips16 opcode table: INSN_UNCOND_BRANCH_DELAY INSN_COND_BRANCH_DELAY INSN_COND_BRANCH_LIKELY (never used) INSN_READ_HI INSN_READ_LO INSN_WRITE_HI INSN_WRITE_LO INSN_TRAP INSN_ISA3 */ /* A NOP insn impemented as "or at,at,zero". Used to implement -mfix-loongson2f. */ #define LOONGSON2F_NOP_INSN 0x00200825 #endif /* _MIPS_H_ */ ================================================ FILE: tools/virtualmips/mips.c ================================================ /* * Cisco router simulation platform. * Copyright (c) 2005,2006 Christophe Fillot (cf@utc.fr) * */ /* * Copyright (C) yajin 2008 * * This file is part of the virtualmips distribution. * See LICENSE file for terms of the license. * */ #define _GNU_SOURCE #include #include #include #include #include #include #include "mips_memory.h" #include "mips_exec.h" #include "mips.h" #include "vm.h" #include "utils.h" #include "system.h" #include "mips_cp0.h" #include "mips_jit.h" #define GDB_SR 32 #define GDB_LO 33 #define GDB_HI 34 #define GDB_BAD 35 #define GDB_CAUSE 36 #define GDB_PC 37 /* MIPS general purpose registers names */ char *mips_gpr_reg_names[MIPS64_GPR_NR] = { "zr", "at", "v0", "v1", "a0", "a1", "a2", "a3", "t0", "t1", "t2", "t3", "t4", "t5", "t6", "t7", "s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7", "t8", "t9", "k0", "k1", "gp", "sp", "fp", "ra", }; /* Cacheability and Coherency Attribute */ static int cca_cache_status[8] = { 1, 1, 0, 1, 0, 1, 0, 0, }; /* Exception vectors. */ #define VECTOR_TLB_REFILL 0x000 #define VECTOR_GENERIC 0x180 #define VECTOR_INTERRUPT 0x200 /* Get register index given its name */ int mips_get_reg_index (char *name) { int i; for (i = 0; i < MIPS64_GPR_NR; i++) if (!strcmp (mips_gpr_reg_names[i], name)) return (i); return (-1); } /* Get cacheability info */ int mips_cca_cached (m_uint8_t val) { return (cca_cache_status[val & 0x03]); } /* Set a register */ void mips_reg_set (cpu_mips_t * cpu, u_int reg, m_reg_t val) { if (reg == 0 || reg >= MIPS64_GPR_NR) return; cpu->gpr[reg] = val; if (cpu->vm->debug_level > 2 || (cpu->vm->debug_level > 1 && (cpu->cp0.reg[MIPS_CP0_STATUS] & MIPS_CP0_STATUS_UM) && ! (cpu->cp0.reg[MIPS_CP0_STATUS] & MIPS_CP0_STATUS_EXL))) { /* Print GPR values in user mode. */ printf (" $%d := %08x \n", reg, val); } } /*get register value giving index. For GDB*/ int mips_reg_get (cpu_mips_t * cpu, u_int reg, m_reg_t * val) { if (reg < MIPS64_GPR_NR) { *val = cpu->gpr[reg]; return SUCCESS; } else { switch (reg) { case GDB_SR: *val = cpu->cp0.reg[MIPS_CP0_STATUS]; break; case GDB_LO: *val = cpu->lo; break; case GDB_HI: *val = cpu->hi; break; case GDB_BAD: *val = cpu->cp0.reg[MIPS_CP0_BADVADDR]; break; case GDB_CAUSE: *val = cpu->cp0.reg[MIPS_CP0_CAUSE]; break; case GDB_PC: *val = cpu->pc; break; default: return FAILURE; } } return SUCCESS; } /* Delete a MIPS64 processor */ void mips_delete (cpu_mips_t * cpu) { if (cpu) { mips_mem_shutdown (cpu); } } /* Reset a MIPS64 CPU */ int mips_reset (cpu_mips_t * cpu) { cpu->cp0.reg[MIPS_CP0_STATUS] = MIPS_CP0_STATUS_BEV; cpu->cp0.reg[MIPS_CP0_CAUSE] = 0; cpu->cp0.ebase_reg = 0x80000000; /* Clear the complete TLB */ memset (&cpu->cp0.tlb, 0, MIPS64_TLB_MAX_ENTRIES * sizeof (tlb_entry_t)); /* Restart the MTS subsystem */ mips_set_addr_mode (cpu, 32 /*64 */ ); /* zzz */ cpu->mts_rebuild (cpu); /* Flush JIT structures */ //mips_jit_flush(cpu,0); return (0); } /* Initialize a MIPS64 processor */ int mips_init (cpu_mips_t * cpu) { /* Set the CPU methods */ cpu->reg_get = (void *) mips_reg_get; cpu->reg_set = (void *) mips_reg_set; /* Set the startup parameters */ mips_reset (cpu); return (0); } /* Load an ELF image into the simulated memory. Using libelf*/ int mips_load_elf_image (cpu_mips_t * cpu, char *filename, m_va_t * entry_point) { m_va_t vaddr; m_uint32_t remain; void *haddr; Elf32_Ehdr *ehdr; Elf32_Shdr *shdr; Elf_Scn *scn; Elf *img_elf; size_t len, clen; int i, fd; FILE *bfd; if (! filename) return (-1); #ifdef __CYGWIN__ fd = open (filename, O_RDONLY | O_BINARY); #else fd = open (filename, O_RDONLY); #endif printf ("Loading ELF file '%s'...\n", filename); if (fd == -1) { perror ("load_elf_image: open"); return (-1); } if (elf_version (EV_CURRENT) == EV_NONE) { fprintf (stderr, "load_elf_image: library out of date\n"); return (-1); } if (!(img_elf = elf_begin (fd, ELF_C_READ, NULL))) { fprintf (stderr, "load_elf_image: elf_begin: %s\n", elf_errmsg (elf_errno ())); return (-1); } if (!(ehdr = elf32_getehdr (img_elf))) { fprintf (stderr, "load_elf_image: invalid ELF file\n"); return (-1); } bfd = fdopen (fd, "rb"); if (!bfd) { perror ("load_elf_image: fdopen"); return (-1); } // if (!skip_load) { for (i = 0; i < ehdr->e_shnum; i++) { scn = elf_getscn (img_elf, i); shdr = elf32_getshdr (scn); len = shdr->sh_size; if (!(shdr->sh_flags & SHF_ALLOC) || !len) continue; fseek (bfd, shdr->sh_offset, SEEK_SET); vaddr = sign_extend (shdr->sh_addr, 32); if (cpu->vm->debug_level > 0) { printf (" * Adding section at virtual address 0x%8.8" LL "x " "(len=0x%8.8lx)\n", vaddr & 0xFFFFFFFF, (u_long) len); } while (len > 0) { haddr = cpu->mem_op_lookup (cpu, vaddr); if (!haddr) { fprintf (stderr, "load_elf_image: invalid load address 0x%" LL "x\n", vaddr); return (-1); } if (len > MIPS_MIN_PAGE_SIZE) clen = MIPS_MIN_PAGE_SIZE; else clen = len; remain = MIPS_MIN_PAGE_SIZE; remain -= (vaddr - (vaddr & MIPS_MIN_PAGE_SIZE)); clen = m_min (clen, remain); if (fread ((u_char *) haddr, clen, 1, bfd) < 1) break; vaddr += clen; len -= clen; } } printf ("ELF entry point: 0x%x\n", ehdr->e_entry); if (entry_point) *entry_point = ehdr->e_entry; elf_end (img_elf); fclose (bfd); return (0); } /* Update the IRQ flag (inline) */ static forced_inline fastcall int mips_update_irq_flag_fast (cpu_mips_t * cpu) { mips_cp0_t *cp0 = &cpu->cp0; m_uint32_t cause; cpu->irq_pending = FALSE; cause = cp0->reg[MIPS_CP0_CAUSE] & ~MIPS_CP0_CAUSE_IMASK; cp0->reg[MIPS_CP0_CAUSE] = cause | cpu->irq_cause; /*printf ("(%08x-%08x) ", cpu->pc, cp0->reg[MIPS_CP0_STATUS]); fflush (stdout);*/ if ((cp0->reg[MIPS_CP0_STATUS] & (MIPS_CP0_STATUS_IE | MIPS_CP0_STATUS_EXL | MIPS_CP0_STATUS_ERL)) == MIPS_CP0_STATUS_IE) { #ifdef SIM_PIC32 m_uint32_t current_ipl = cp0->reg[MIPS_CP0_STATUS] >> 10 & 63; m_uint32_t requested_ipl = cp0->reg[MIPS_CP0_CAUSE] >> 10 & 63; /*printf ("(%d-%d) ", requested_ipl, current_ipl); fflush (stdout);*/ if (unlikely (requested_ipl > current_ipl)) { cpu->irq_pending = TRUE; return (TRUE); } #else m_uint32_t imask = cp0->reg[MIPS_CP0_STATUS] & MIPS_CP0_STATUS_IMASK; if (unlikely (cp0->reg[MIPS_CP0_CAUSE] & imask)) { cpu->irq_pending = TRUE; return (TRUE); } #endif } return (FALSE); } /* Update the IRQ flag */ int fastcall mips_update_irq_flag (cpu_mips_t * cpu) { return mips_update_irq_flag_fast (cpu); } #if SIM_PIC32 static void print_arg (int val) { if (val & 0xff000000) printf ("%08x", val); else printf ("%u", val); } static void print_args (int narg, int arg0, int arg1, int arg2, int arg3, int arg4, int arg5) { print_arg (arg0); if (narg > 1) { printf (", "); print_arg (arg1); } if (narg > 2) { printf (", "); print_arg (arg2); } if (narg > 3) { printf (", "); print_arg (arg3); } if (narg > 4) { printf (", "); print_arg (arg4); } if (narg > 5) { printf (", "); print_arg (arg5); } } /* * Print trace information for exception. * For syscalls, display name and arguments. */ static void print_exception (cpu_mips_t * cpu, u_int exc_code) { const char *code = 0; #include "bsd_syscalls.h" if (exc_code == MIPS_CP0_CAUSE_SYSCALL) { mips_insn_t code; if (mips_fetch_instruction (cpu, cpu->pc, &code) != 0) { printf ("--- syscall at %08x: cannot fetch instruction opcode\n", cpu->pc); return; } /* bottom 8 bits are index */ code = (code >> 6) & 0377; if (code == 97) cpu->vm->debug_level = 2; if (code == 1) cpu->vm->debug_level = 1; cpu->trace_syscall = code; if (code >= sizeof (bsd_syscalls) / sizeof (bsd_syscalls[0])) { printf ("--- syscall: #%d at %08x\n", (int)code, cpu->pc); return; } printf ("--- syscall: %s (", bsd_syscalls[code].name); if (bsd_syscalls[code].narg > 0) { m_reg_t arg4 = 0, arg5 = 0; void *haddr; u_int exc; m_uint8_t has_set_value; if (bsd_syscalls[code].narg >= 4) { has_set_value = FALSE; haddr = mips_mts32_access (cpu, cpu->gpr[MIPS_GPR_SP] + 16, MIPS_MEMOP_LW, 4, MTS_READ, &arg4, &exc, &has_set_value, 0); if (exc || (! haddr && ! has_set_value)) arg4 = 0; else if (! has_set_value) arg4 = vmtoh32 (*(m_uint32_t *) haddr); } if (bsd_syscalls[code].narg >= 5) { has_set_value = FALSE; haddr = mips_mts32_access (cpu, cpu->gpr[MIPS_GPR_SP] + 20, MIPS_MEMOP_LW, 4, MTS_READ, &arg5, &exc, &has_set_value, 0); if (exc || (! haddr && ! has_set_value)) arg5 = 0; else if (! has_set_value) arg5 = vmtoh32 (*(m_uint32_t *) haddr); } print_args (bsd_syscalls[code].narg, cpu->gpr[MIPS_GPR_A0], cpu->gpr[MIPS_GPR_A1], cpu->gpr[MIPS_GPR_A2], cpu->gpr[MIPS_GPR_A3], arg4, arg5); } printf (") at %08x\n", cpu->pc); return; } printf ("--- %08x: exception ", cpu->pc); switch (exc_code) { case MIPS_CP0_CAUSE_INTERRUPT: code = "Interrupt"; break; case MIPS_CP0_CAUSE_ADDR_LOAD: code = "Address Load"; break; case MIPS_CP0_CAUSE_ADDR_SAVE: code = "Address Save"; break; case MIPS_CP0_CAUSE_BUS_INSTR: code = "Bus fetch"; break; case MIPS_CP0_CAUSE_BUS_DATA: code = "Bus load/store"; break; case MIPS_CP0_CAUSE_SYSCALL: code = "Syscall"; break; case MIPS_CP0_CAUSE_BP: code = "Breakpoint"; break; case MIPS_CP0_CAUSE_ILLOP: code = "Reserved Instruction"; break; case MIPS_CP0_CAUSE_CP_UNUSABLE:code = "Coprocessor Unusable"; break; case MIPS_CP0_CAUSE_OVFLW: code = "Arithmetic Overflow"; break; case MIPS_CP0_CAUSE_TRAP: code = "Trap"; break; } if (code) printf ("'%s'\n", code); else printf ("%d\n", exc_code); printf (" c0_status = %08x\n", cpu->cp0.reg[MIPS_CP0_STATUS]); printf (" c0_cause = %08x\n", cpu->cp0.reg[MIPS_CP0_CAUSE]); printf (" c0_epc = %08x\n", cpu->cp0.reg[MIPS_CP0_EPC]); switch (exc_code) { case MIPS_CP0_CAUSE_TLB_MOD: case MIPS_CP0_CAUSE_TLB_LOAD: case MIPS_CP0_CAUSE_TLB_SAVE: case MIPS_CP0_CAUSE_ADDR_LOAD: case MIPS_CP0_CAUSE_ADDR_SAVE: printf (" c0_badvaddr = %08x\n", cpu->cp0.reg[MIPS_CP0_BADVADDR]); break; } } #endif /* Generate an exception */ void mips_trigger_exception (cpu_mips_t * cpu, u_int exc_code, int bd_slot) { mips_cp0_t *cp0 = &cpu->cp0; m_uint64_t new_pc; m_uint32_t old_status = cp0->reg[MIPS_CP0_STATUS]; m_reg_t cause; /* keep IM, set exception code and bd slot */ cause = cp0->reg[MIPS_CP0_CAUSE]; /* If EXL is set, neither EPC nor Cause.BD are modified. */ if (! (old_status & MIPS_CP0_STATUS_EXL)) { cp0->reg[MIPS_CP0_EPC] = cpu->pc | cpu->is_mips16e; /* Update Cause.BD */ if (bd_slot) cause |= MIPS_CP0_CAUSE_BD_SLOT; else cause &= ~MIPS_CP0_CAUSE_BD_SLOT; } cpu->is_mips16e = 0; cause &= ~MIPS_CP0_CAUSE_EXC_MASK; //clear exec-code cause |= (exc_code << 2); cp0->reg[MIPS_CP0_CAUSE] = cause; if (exc_code == MIPS_CP0_CAUSE_INTERRUPT) cpu->irq_cause = 0; /* Set EXL bit in status register */ /*TODO: RESET SOFT RESET AND NMI EXCEPTION */ cp0->reg[MIPS_CP0_STATUS] |= MIPS_CP0_STATUS_EXL; /* clear ERL bit in status register */ /*TODO: RESET SOFT RESET AND NMI EXCEPTION */ cp0->reg[MIPS_CP0_STATUS] &= ~MIPS_CP0_STATUS_ERL; /* Compute the vector address. */ if (cp0->reg[MIPS_CP0_STATUS] & MIPS_CP0_STATUS_BEV) { /* Boot exception vector. */ new_pc = 0xffffffffbfc00200ULL + VECTOR_GENERIC; } else { /* Use EBase register value. */ new_pc = cp0->ebase_reg + VECTOR_GENERIC; } if (! (old_status & MIPS_CP0_STATUS_EXL)) { if (exc_code == MIPS_CP0_CAUSE_TLB_LOAD || exc_code == MIPS_CP0_CAUSE_TLB_SAVE) { /* TBL refill: use offset 0. */ new_pc += VECTOR_TLB_REFILL - VECTOR_GENERIC; } else if (exc_code == MIPS_CP0_CAUSE_INTERRUPT && (cp0->reg[MIPS_CP0_CAUSE] & MIPS_CP0_CAUSE_IV)) { /* Interrupt: use offset 0x200. */ new_pc += VECTOR_INTERRUPT - VECTOR_GENERIC; } } if (cpu->vm->debug_level > 2 || (exc_code != MIPS_CP0_CAUSE_INTERRUPT && (exc_code != MIPS_CP0_CAUSE_SYSCALL || cpu->vm->debug_level > 0))) { print_exception (cpu, exc_code); } cpu->pc = (m_va_t) new_pc; /* Clear the pending IRQ flag */ cpu->irq_pending = 0; } /* * Generate a Debug exception */ void mips_trigger_debug_exception (cpu_mips_t *cpu, u_int dexc_type) { mips_cp0_t *cp0 = &cpu->cp0; int old_dm = cpu->cp0.reg[MIPS_CP0_DEBUG] & MIPS_CP0_DEBUG_DM; /* Update exception type bits. */ cpu->cp0.reg[MIPS_CP0_DEBUG] &= ~(MIPS_CP0_DEBUG_DSS | MIPS_CP0_DEBUG_DBP | MIPS_CP0_DEBUG_DDBL | MIPS_CP0_DEBUG_DDBS | MIPS_CP0_DEBUG_DIB | MIPS_CP0_DEBUG_DINT | MIPS_CP0_DEBUG_DDBLIMPR | MIPS_CP0_DEBUG_DDBSIMPR | MIPS_CP0_DEBUG_DEXCCODE); cpu->cp0.reg[MIPS_CP0_DEBUG] |= dexc_type; /* Update delay slot flag. */ if (cpu->is_in_bdslot) cpu->cp0.reg[MIPS_CP0_DEBUG] |= MIPS_CP0_DEBUG_DBD; else cpu->cp0.reg[MIPS_CP0_DEBUG] &= ~MIPS_CP0_DEBUG_DBD; /* Set Debug mode. */ cpu->cp0.reg[MIPS_CP0_DEBUG] |= MIPS_CP0_DEBUG_DM; cpu->cp0.reg[MIPS_CP0_DEBUG] |= MIPS_CP0_DEBUG_IEXI; /* Set DEPC. */ cp0->reg[MIPS_CP0_DEPC] = cpu->pc | cpu->is_mips16e; if (cpu->vm->debug_level > 2) { char *type = 0; printf ("--- 0x%08x: ", cpu->pc); if (old_dm) type = " Debug exception in Debug mode"; else switch (dexc_type) { case MIPS_CP0_DEBUG_DSS: type = "Debug Single Step exception"; break; case MIPS_CP0_DEBUG_DBP: type = "Debug Breakpoint exception"; break; case MIPS_CP0_DEBUG_DDBL: type = "Debug Data Break Load exception"; break; case MIPS_CP0_DEBUG_DDBS: type = "Debug Data Break Store exception"; break; case MIPS_CP0_DEBUG_DIB: type = "Debug Instruction Break exception"; break; case MIPS_CP0_DEBUG_DINT: type = "Debug Interrupt exception"; break; case MIPS_CP0_DEBUG_DDBLIMPR: type = "Debug Data Break Load Impresize exception"; break; case MIPS_CP0_DEBUG_DDBSIMPR: type = "Debug Data Break Store Impresize exception"; break; } if (type) printf ("%s\n", type); else printf ("Debug exception %#x\n", dexc_type); printf (" c0_debug := %08x\n", cpu->cp0.reg[MIPS_CP0_DEBUG]); printf (" c0_depc := %08x\n", cpu->cp0.reg[MIPS_CP0_DEPC]); } /* Jump to Debug exception vector. */ cpu->pc = (m_va_t) 0xffffffffbfc00480ULL; cpu->is_mips16e = 0; /* Clear the pending IRQ flag */ cpu->irq_pending = 0; } /* Execute fpu instruction */ void fastcall mips_exec_soft_fpu (cpu_mips_t * cpu) { mips_cp0_t *cp0 = &cpu->cp0; cp0->reg[MIPS_CP0_CAUSE] |= 0x10000000; //CE=1 mips_trigger_exception (cpu, MIPS_CP0_CAUSE_CP_UNUSABLE, cpu->is_in_bdslot); } /* Execute ERET instruction */ void fastcall mips_exec_eret (cpu_mips_t * cpu) { mips_cp0_t *cp0 = &cpu->cp0; if (cp0->reg[MIPS_CP0_STATUS] & MIPS_CP0_STATUS_ERL) { cp0->reg[MIPS_CP0_STATUS] &= ~MIPS_CP0_STATUS_ERL; cpu->pc = cp0->reg[MIPS_CP0_ERR_EPC]; } else { cp0->reg[MIPS_CP0_STATUS] &= ~MIPS_CP0_STATUS_EXL; cpu->pc = cp0->reg[MIPS_CP0_EPC]; } if (cpu->vm->debug_level > 2) { printf (" c0_status := %08x\n", cpu->cp0.reg[MIPS_CP0_STATUS]); } /* We have to clear the LLbit */ cpu->ll_bit = 0; cpu->is_mips16e = cpu->pc & 1; cpu->pc &= ~1; } /* Execute DERET instruction */ void fastcall mips_exec_deret (cpu_mips_t *cpu) { mips_cp0_t *cp0 = &cpu->cp0; /* Clear Debug mode. */ cpu->cp0.reg[MIPS_CP0_DEBUG] &= ~MIPS_CP0_DEBUG_DM; cpu->cp0.reg[MIPS_CP0_DEBUG] &= ~MIPS_CP0_DEBUG_IEXI; /* Restore PC. */ cpu->pc = cp0->reg[MIPS_CP0_DEPC]; cpu->is_mips16e = cpu->pc & 1; cpu->pc &= ~1; if (cpu->vm->debug_level > 2) { printf (" c0_debug := %08x\n", cpu->cp0.reg[MIPS_CP0_DEBUG]); } } /* Execute BREAK instruction */ void fastcall mips_exec_break (cpu_mips_t * cpu, u_int code) { mips_trigger_exception (cpu, MIPS_CP0_CAUSE_BP, cpu->is_in_bdslot); } /* Trigger a Trap Exception */ void fastcall mips_trigger_trap_exception (cpu_mips_t * cpu) { //printf ("MIPS64: TRAP exception, CPU=%p\n", cpu); mips_trigger_exception (cpu, MIPS_CP0_CAUSE_TRAP, cpu->is_in_bdslot); } /* Execute SYSCALL instruction */ void fastcall mips_exec_syscall (cpu_mips_t * cpu) { #if DEBUG_SYSCALL printf ("MIPS: SYSCALL at PC=0x%" LL "x (RA=0x%" LL "x)\n" " a0=0x%" LL "x, a1=0x%" LL "x, a2=0x%" LL "x, a3=0x%" LL "x\n", cpu->pc, cpu->gpr[MIPS_GPR_RA], cpu->gpr[MIPS_GPR_A0], cpu->gpr[MIPS_GPR_A1], cpu->gpr[MIPS_GPR_A2], cpu->gpr[MIPS_GPR_A3]); #endif if (cpu->is_in_bdslot == 0) mips_trigger_exception (cpu, MIPS_CP0_CAUSE_SYSCALL, 0); else mips_trigger_exception (cpu, MIPS_CP0_CAUSE_SYSCALL, 1); } /* Trigger IRQs */ void forced_inline fastcall mips_trigger_irq (cpu_mips_t * cpu) { if (mips_update_irq_flag (cpu)) mips_trigger_exception (cpu, MIPS_CP0_CAUSE_INTERRUPT, 0); } /* Set an IRQ */ void mips_set_irq (cpu_mips_t * cpu, m_uint8_t irq) { m_uint32_t m; m = (1 << (irq + MIPS_CP0_CAUSE_ISHIFT)) & MIPS_CP0_CAUSE_IMASK; //atomic_or(&cpu->irq_cause,m); cpu->irq_cause |= m; } /* Clear an IRQ */ void mips_clear_irq (cpu_mips_t * cpu, m_uint8_t irq) { m_uint32_t m; m = (1 << (irq + MIPS_CP0_CAUSE_ISHIFT)) & MIPS_CP0_CAUSE_IMASK; cpu->irq_cause &= ~m; //atomic_and(&cpu->irq_cause,~m); if (! cpu->irq_cause) cpu->irq_pending = 0; } ================================================ FILE: tools/virtualmips/mips.h ================================================ /* * Cisco router simulation platform. * Copyright (c) 2005,2006 Christophe Fillot (cf@utc.fr) * */ /* * Copyright (C) yajin 2008 * * This file is part of the virtualmips distribution. * See LICENSE file for terms of the license. * */ #ifndef __MIPS_H__ #define __MIPS_H__ #include #include "system.h" #include "utils.h" /* * MIPS General Purpose Registers */ #define MIPS_GPR_ZERO 0 /* zero */ #define MIPS_GPR_AT 1 /* at */ #define MIPS_GPR_V0 2 /* v0 */ #define MIPS_GPR_V1 3 /* v1 */ #define MIPS_GPR_A0 4 /* a0 */ #define MIPS_GPR_A1 5 /* a1 */ #define MIPS_GPR_A2 6 /* a2 */ #define MIPS_GPR_A3 7 /* a3 */ #define MIPS_GPR_T0 8 /* t0 */ #define MIPS_GPR_T1 9 /* t1 */ #define MIPS_GPR_T2 10 /* t2 */ #define MIPS_GPR_T3 11 /* t3 */ #define MIPS_GPR_T4 12 /* t4 */ #define MIPS_GPR_T5 13 /* t5 */ #define MIPS_GPR_T6 14 /* t6 */ #define MIPS_GPR_T7 15 /* t7 */ #define MIPS_GPR_S0 16 /* s0 */ #define MIPS_GPR_S1 17 /* s1 */ #define MIPS_GPR_S2 18 /* s2 */ #define MIPS_GPR_S3 19 /* s3 */ #define MIPS_GPR_S4 20 /* s4 */ #define MIPS_GPR_S5 21 /* s5 */ #define MIPS_GPR_S6 22 /* s6 */ #define MIPS_GPR_S7 23 /* s7 */ #define MIPS_GPR_T8 24 /* t8 */ #define MIPS_GPR_T9 25 /* t9 */ #define MIPS_GPR_K0 26 /* k0 */ #define MIPS_GPR_K1 27 /* k1 */ #define MIPS_GPR_GP 28 /* gp */ #define MIPS_GPR_SP 29 /* sp */ #define MIPS_GPR_FP 30 /* fp */ #define MIPS_GPR_RA 31 /* ra */ /* * Coprocessor 0 (System Coprocessor) Register definitions */ #define MIPS_CP0_INDEX 0 /* TLB Index */ #define MIPS_CP0_RANDOM 1 /* TLB Random */ #define MIPS_CP0_TLB_LO_0 2 /* TLB Entry Lo0 */ #define MIPS_CP0_TLB_LO_1 3 /* TLB Entry Lo1 */ #define MIPS_CP0_CONTEXT 4 /* Kernel PTE pointer */ #define MIPS_CP0_PAGEMASK 5 /* TLB Page Mask */ #define MIPS_CP0_WIRED 6 /* TLB Wired */ #define MIPS_CP0_INFO 7 /* Info (RM7000) */ #define MIPS_CP0_BADVADDR 8 /* Bad Virtual Address */ #define MIPS_CP0_COUNT 9 /* Count */ #define MIPS_CP0_TLB_HI 10 /* TLB Entry Hi */ #define MIPS_CP0_COMPARE 11 /* Timer Compare */ #define MIPS_CP0_STATUS 12 /* Status */ #define MIPS_CP0_CAUSE 13 /* Cause */ #define MIPS_CP0_EPC 14 /* Exception PC */ #define MIPS_CP0_PRID 15 /* Proc Rev ID */ #define MIPS_CP0_CONFIG 16 /* Configuration */ #define MIPS_CP0_LLADDR 17 /* Load/Link address */ #define MIPS_CP0_WATCHLO 18 /* Low Watch address */ #define MIPS_CP0_WATCHHI 19 /* High Watch address */ #define MIPS_CP0_XCONTEXT 20 /* Extended context */ #define MIPS_CP0_DEBUG 23 /* Debug */ #define MIPS_CP0_DEPC 24 /* DEPC */ #define MIPS_CP0_ECC 26 /* ECC and parity */ #define MIPS_CP0_CACHERR 27 /* Cache Err/Status */ #define MIPS_CP0_TAGLO 28 /* Cache Tag Lo */ #define MIPS_CP0_TAGHI 29 /* Cache Tag Hi */ #define MIPS_CP0_ERR_EPC 30 /* Error exception PC */ /* * CP0 Status Register */ #define MIPS_CP0_STATUS_CU0 0x10000000 #define MIPS_CP0_STATUS_CU1 0x20000000 #define MIPS_CP0_STATUS_CU2 0x40000000 #define MIPS_CP0_STATUS_BEV 0x00400000 #define MIPS_CP0_STATUS_TS 0x00200000 #define MIPS_CP0_STATUS_SR 0x00100000 #define MIPS_CP0_STATUS_CH 0x00040000 #define MIPS_CP0_STATUS_CE 0x00020000 #define MIPS_CP0_STATUS_DE 0x00010000 #define MIPS_CP0_STATUS_RP 0x08000000 #define MIPS_CP0_STATUS_FR 0x04000000 #define MIPS_CP0_STATUS_RE 0x02000000 #define MIPS_CP0_STATUS_KX 0x00000080 #define MIPS_CP0_STATUS_SX 0x00000040 #define MIPS_CP0_STATUS_UX 0x00000020 #define MIPS_CP0_STATUS_KSU 0x00000018 #define MIPS_CP0_STATUS_ERL 0x00000004 #define MIPS_CP0_STATUS_EXL 0x00000002 #define MIPS_CP0_STATUS_IE 0x00000001 #define MIPS_CP0_STATUS_IMASK7 0x00008000 #define MIPS_CP0_STATUS_IMASK6 0x00004000 #define MIPS_CP0_STATUS_IMASK5 0x00002000 #define MIPS_CP0_STATUS_IMASK4 0x00001000 #define MIPS_CP0_STATUS_IMASK3 0x00000800 #define MIPS_CP0_STATUS_IMASK2 0x00000400 #define MIPS_CP0_STATUS_IMASK1 0x00000200 #define MIPS_CP0_STATUS_IMASK0 0x00000100 #define MIPS_CP0_STATUS_DS_MASK 0x00770000 #define MIPS_CP0_STATUS_CU_MASK 0xF0000000 #define MIPS_CP0_STATUS_IMASK 0x0000FF00 /* Addressing mode: Kernel, Supervisor and User */ #define MIPS_CP0_STATUS_KSU_SHIFT 0x03 #define MIPS_CP0_STATUS_KSU_MASK 0x03 #define MIPS_CP0_STATUS_KM 0x00 #define MIPS_CP0_STATUS_SM 0x01 #define MIPS_CP0_STATUS_UM 0x10 /* * CP0 Cause register */ #define MIPS_CP0_CAUSE_BD_SLOT 0x80000000 #define MIPS_CP0_CAUSE_MASK 0x0000007C #define MIPS_CP0_CAUSE_CEMASK 0x30000000 #define MIPS_CP0_CAUSE_CESHIFT 28 #ifdef SIM_PIC32 #define MIPS_CP0_CAUSE_IMASK 0x0000FC00 /* mips r2 */ #else #define MIPS_CP0_CAUSE_IMASK 0x0000FF00 /* mips r1 */ #endif #define MIPS_CP0_CAUSE_IV 0x00800000 #define MIPS_CP0_CAUSE_SHIFT 2 #define MIPS_CP0_CAUSE_CESHIFT 28 #define MIPS_CP0_CAUSE_ISHIFT 8 #define MIPS_CP0_CAUSE_EXC_MASK 0x0000007C #define MIPS_CP0_CAUSE_INTERRUPT 0 #define MIPS_CP0_CAUSE_TLB_MOD 1 #define MIPS_CP0_CAUSE_TLB_LOAD 2 #define MIPS_CP0_CAUSE_TLB_SAVE 3 #define MIPS_CP0_CAUSE_ADDR_LOAD 4 /* ADEL */ #define MIPS_CP0_CAUSE_ADDR_SAVE 5 /* ADES */ #define MIPS_CP0_CAUSE_BUS_INSTR 6 #define MIPS_CP0_CAUSE_BUS_DATA 7 #define MIPS_CP0_CAUSE_SYSCALL 8 #define MIPS_CP0_CAUSE_BP 9 #define MIPS_CP0_CAUSE_ILLOP 10 #define MIPS_CP0_CAUSE_CP_UNUSABLE 11 #define MIPS_CP0_CAUSE_OVFLW 12 #define MIPS_CP0_CAUSE_TRAP 13 #define MIPS_CP0_CAUSE_FPE 15 #define MIPS_CP0_CAUSE_WATCH 23 #define MIPS_CP0_CAUSE_IBIT7 0x00008000 #define MIPS_CP0_CAUSE_IBIT6 0x00004000 #define MIPS_CP0_CAUSE_IBIT5 0x00002000 #define MIPS_CP0_CAUSE_IBIT4 0x00001000 #define MIPS_CP0_CAUSE_IBIT3 0x00000800 #define MIPS_CP0_CAUSE_IBIT2 0x00000400 #define MIPS_CP0_CAUSE_IBIT1 0x00000200 #define MIPS_CP0_CAUSE_IBIT0 0x00000100 /* cp0 context */ #define MIPS_CP0_CONTEXT_PTEBASE_MASK 0xff800000 #define MIPS_CP0_CONTEXT_BADVPN2_MASK 0x0007ffff0 /* * CP0 Debug register */ #define MIPS_CP0_DEBUG_DBD 0x80000000 /* Debug exception on delay slot */ #define MIPS_CP0_DEBUG_DM 0x40000000 /* Debug mode */ #define MIPS_CP0_DEBUG_IEXI 0x00100000 /* Imprecise Error eXception Inhibit */ #define MIPS_CP0_DEBUG_DDBSIMPR 0x00080000 /* Debug Data Break Store Impresize exception */ #define MIPS_CP0_DEBUG_DDBLIMPR 0x00040000 /* Debug Data Break Load Impresize exception */ #define MIPS_CP0_DEBUG_DEXCCODE 0x00003c00 /* Debug exception code */ #define MIPS_CP0_DEBUG_DEXCCODE_SHIFT 10 #define MIPS_CP0_DEBUG_DINT 0x00000020 /* Debug Interrupt exception */ #define MIPS_CP0_DEBUG_DIB 0x00000010 /* Debug Instruction Break exception */ #define MIPS_CP0_DEBUG_DDBS 0x00000008 /* Debug Data Break Store exception */ #define MIPS_CP0_DEBUG_DDBL 0x00000004 /* Debug Data Break Load exception */ #define MIPS_CP0_DEBUG_DBP 0x00000002 /* Debug Breakpoint exception */ #define MIPS_CP0_DEBUG_DSS 0x00000001 /* Debug Single Step exception */ #define MIPS_CP0_DEBUG_WMASK 0x10700180 /* Writable bits */ /* TLB masks and shifts */ #define MIPS_TLB_PAGE_MASK 0x01ffe000 #define MIPS_TLB_PAGE_SHIFT 13 //#define MIPS_TLB_VPN2_MASK 0xffffe000 #define MIPS_TLB_VPN2_MASK_32 0xffffe000 #define MIPS_TLB_VPN2_MASK_64 0xc00000ffffffe000ULL #define MIPS_TLB_PFN_MASK 0x3fffffc0 #define MIPS_TLB_ASID_MASK 0x000000ff /* "asid" in EntryHi */ #define MIPS_TLB_G_MASK 0x00001000 /* "Global" in EntryHi */ #define MIPS_TLB_V_MASK 0x2 /* "Valid" in EntryLo */ #define MIPS_TLB_D_MASK 0x4 /* "Dirty" in EntryLo */ #define MIPS_TLB_C_MASK 0x38 /* Page Coherency Attribute */ #define MIPS_TLB_C_SHIFT 3 #define MIPS_TLB_V_SHIT 1 #define MIPS_TLB_D_SHIT 2 #define MIPS_CP0_LO_G_MASK 0x00000001 /* "Global" in Lo0/1 reg */ #define MIPS_CP0_HI_SAFE_MASK 0xffffe0ff /* Safety mask for Hi reg */ #define MIPS_CP0_LO_SAFE_MASK 0x7fffffff /* Safety mask for Lo reg */ /* MIPS "jr ra" instruction */ #define MIPS_INSN_JR_RA 0x03e00008 #ifdef SIM_PIC32 #define MIPS_MIN_PAGE_SHIFT 8 #define MIPS_MIN_PAGE_SIZE (1 << MIPS_MIN_PAGE_SHIFT) #define MIPS_MIN_PAGE_IMASK (MIPS_MIN_PAGE_SIZE - 1) #define MIPS_MIN_PAGE_MASK 0xffffffffffffff00ULL #else /* Minimum page size: 4 Kb */ #define MIPS_MIN_PAGE_SHIFT 12 #define MIPS_MIN_PAGE_SIZE (1 << MIPS_MIN_PAGE_SHIFT) #define MIPS_MIN_PAGE_IMASK (MIPS_MIN_PAGE_SIZE - 1) #define MIPS_MIN_PAGE_MASK 0xfffffffffffff000ULL #endif /* Addressing mode: Kernel, Supervisor and User */ #define MIPS_MODE_KERNEL 00 /* Segments in 32-bit User mode */ #define MIPS_USEG_BASE 0x00000000 #define MIPS_USEG_SIZE 0x80000000 /* Segments in 32-bit Supervisor mode */ #define MIPS_SUSEG_BASE 0x00000000 #define MIPS_SUSEG_SIZE 0x80000000 #define MIPS_SSEG_BASE 0xc0000000 #define MIPS_SSEG_SIZE 0x20000000 /* Segments in 32-bit Kernel mode */ #define MIPS_KUSEG_BASE 0x00000000 #define MIPS_KUSEG_SIZE 0x80000000 #define MIPS_KSEG0_BASE 0x80000000 #define MIPS_KSEG0_SIZE 0x20000000 #define MIPS_KSEG1_BASE 0xa0000000 #define MIPS_KSEG1_SIZE 0x20000000 #define MIPS_KSSEG_BASE 0xc0000000 #define MIPS_KSSEG_SIZE 0x20000000 #define MIPS_KSEG3_BASE 0xe0000000 #define MIPS_KSEG3_SIZE 0x20000000 /* xkphys mask (36-bit physical address) */ #define MIPS64_XKPHYS_ZONE_MASK 0xF800000000000000ULL #define MIPS64_XKPHYS_PHYS_SIZE (1ULL << 36) #define MIPS64_XKPHYS_PHYS_MASK (MIPS64_XKPHYS_PHYS_SIZE - 1) #define MIPS64_XKPHYS_CCA_SHIFT 59 /* Number of GPR (general purpose registers) */ #define MIPS64_GPR_NR 32 /* Number of registers in CP0 */ #define MIPS64_CP0_REG_NR 32 /*8 configure register in cp0. sel:0-7*/ #define MIPS64_CP0_CONFIG_REG_NR 8 /* Number of registers in CP1 */ #define MIPS64_CP1_REG_NR 32 /* Number of TLB entries */ #define MIPS64_TLB_STD_ENTRIES 48 #define MIPS64_TLB_MAX_ENTRIES 64 #define MIPS64_TLB_IDX_MASK 0x3f /* 6 bits */ /* Enable the 64 TLB entries for R7000 CPU */ #define MIPS64_R7000_TLB64_ENABLE 0x20000000 /* Number of instructions per page */ #define MIPS_INSN_PER_PAGE (MIPS_MIN_PAGE_SIZE/sizeof(mips_insn_t)) /* MIPS CPU Identifiers */ #define MIPS_PRID_R4600 0x00002012 #define MIPS_PRID_R4700 0x00002112 #define MIPS_PRID_R5000 0x00002312 #define MIPS_PRID_R7000 0x00002721 #define MIPS_PRID_R527x 0x00002812 #define MIPS_PRID_BCM1250 0x00040102 enum { MIPS_KUSEG = 0, MIPS_KSEG0, MIPS_KSEG1, MIPS_KSEG2, }; /* Memory operations */ enum { MIPS_MEMOP_LOOKUP = 0, MIPS_MEMOP_LB, MIPS_MEMOP_LBU, MIPS_MEMOP_LH, MIPS_MEMOP_LHU, MIPS_MEMOP_LW, MIPS_MEMOP_LWU, MIPS_MEMOP_LD, MIPS_MEMOP_SB, MIPS_MEMOP_SH, MIPS_MEMOP_SW, MIPS_MEMOP_SD, MIPS_MEMOP_LWL, MIPS_MEMOP_LWR, MIPS_MEMOP_LDL, MIPS_MEMOP_LDR, MIPS_MEMOP_SWL, MIPS_MEMOP_SWR, MIPS_MEMOP_SDL, MIPS_MEMOP_SDR, MIPS_MEMOP_LL, MIPS_MEMOP_SC, MIPS_MEMOP_LDC1, MIPS_MEMOP_SDC1, MIPS_MEMOP_CACHE, MIPS_MEMOP_MAX, }; /* Maximum number of breakpoints */ #define MIPS64_MAX_BREAKPOINTS 8 #define CPU_INTERRUPT_EXIT 0x01 /* wants exit from main loop */ #define CPU_INTERRUPT_HARD 0x02 /* hardware interrupt pending */ #define CPU_INTERRUPT_EXITTB 0x04 /* exit the current TB (use for x86 a20 case) */ #define CPU_INTERRUPT_TIMER 0x08 /* internal timer exception pending */ #define CPU_INTERRUPT_FIQ 0x10 /* Fast interrupt pending. */ #define CPU_INTERRUPT_HALT 0x20 /* CPU halt wanted */ #define CPU_INTERRUPT_SMI 0x40 /* (x86 only) SMI interrupt pending */ /* MIPS CPU type */ //typedef struct cpu_mips cpu_mips_t; /* Memory operation function prototype */ typedef u_int fastcall (*mips_memop_fn) (cpu_mips_t * cpu, m_va_t vaddr, u_int reg); /* TLB entry definition */ typedef struct { m_va_t mask; m_va_t hi; m_va_t lo0; m_va_t lo1; } tlb_entry_t; /* System Coprocessor (CP0) definition */ typedef struct { m_cp0_reg_t reg[MIPS64_CP0_REG_NR]; /*because configure has sel 0-7, seperate it to reg */ m_cp0_reg_t config_reg[MIPS64_CP0_CONFIG_REG_NR]; m_cp0_reg_t intctl_reg; m_cp0_reg_t ebase_reg; m_uint8_t config_usable; /*if configure register sel N is useable, set the bit in config_usable to 1 */ tlb_entry_t tlb[MIPS64_TLB_MAX_ENTRIES]; /* Number of TLB entries */ u_int tlb_entries; } mips_cp0_t; /* mips CPU definition */ struct cpu_mips { /* CPU identifier for MP systems */ u_int id; u_int type; m_va_t pc, ret_pc; m_va_t jit_pc; m_reg_t gpr[MIPS64_GPR_NR]; m_reg_t lo, hi; /* VM instance */ vm_instance_t *vm; /* Next CPU in group */ cpu_mips_t *next; /* System coprocessor (CP0) */ mips_cp0_t cp0; /* CPU states */ volatile m_uint32_t state, prev_state; /* Thread running this CPU */ pthread_t cpu_thread; int cpu_thread_running; /*pause request. INTERRUPT will pause cpu */ m_uint32_t pause_request; /* Methods */ int (*reg_get) (cpu_mips_t * cpu, u_int reg, m_reg_t * val); void (*reg_set) (cpu_mips_t * cpu, u_int reg_index, m_reg_t val); void (*mts_rebuild) (cpu_mips_t * cpu); u_int (*mips_mts_gdb_lb) (cpu_mips_t * cpu, m_va_t vaddr, void *cur); /* MTS32/MTS64 caches */ union { mts32_entry_t *mts32_cache; mts64_entry_t *mts64_cache; } mts_u; /* General Purpose Registers, Pointer Counter, LO/HI, IRQ */ m_uint32_t irq_pending, irq_cause, ll_bit; /* Virtual address to physical page translation */ int (*translate) (cpu_mips_t * cpu, m_va_t vaddr, m_uint32_t * phys_page); /* Memory access functions */ mips_memop_fn mem_op_fn[MIPS_MEMOP_MAX]; /* Memory lookup function (to load ELF image,...) */ void *fastcall (*mem_op_lookup) (cpu_mips_t * cpu, m_va_t vaddr); /* Address bus mask for physical addresses */ m_va_t addr_bus_mask; /* MTS map/unmap/rebuild operations */ void (*mts_map) (cpu_mips_t * cpu, m_va_t vaddr, m_pa_t paddr, m_uint32_t len, int cache_access, int tlb_index); void (*mts_unmap) (cpu_mips_t * cpu, m_va_t vaddr, m_uint32_t len, m_uint32_t val, int tlb_index); void (*mts_shutdown) (cpu_mips_t * cpu); /* MTS cache statistics */ m_uint64_t mts_misses, mts_lookups; /* Address mode (32 or 64 bits) */ u_int addr_mode; int is_in_bdslot; int insn_len; /* length of last fetched instruction in bytes */ int is_mips16e; /* 1 if ISA Mode is MIPS16e, 0 if MIPS32 */ int trace_syscall; int magic_opcodes; /* Current exec page (non-JIT) info */ m_va_t njm_exec_page; mips_insn_t *njm_exec_ptr; #ifdef _USE_JIT_ /* JIT flush method */ u_int jit_flush_method; /* Number of compiled pages */ u_int compiled_pages; /* Code page translation cache */ mips_jit_tcb_t **exec_blk_map; void *exec_page_area; size_t exec_page_area_size; /*M bytes */ size_t exec_page_count, exec_page_alloc; insn_exec_page_t *exec_page_free_list; insn_exec_page_t *exec_page_array; /* Current and free lists of translated code blocks */ mips_jit_tcb_t *tcb_list, *tcb_last, *tcb_free_list; /* Direct block jump.Optimization */ u_int exec_blk_direct_jump; #endif }; /* Register names */ extern char *mips_gpr_reg_names[]; #define MAJOR_OP(_inst) (((uint)_inst >> 26) & 0x3f ) int mips_load_elf_image (cpu_mips_t * cpu, char *filename, m_va_t * entry_point); int mips_get_reg_index (char *name); int mips_cca_cached (m_uint8_t val); void mips_dump_regs (cpu_mips_t * cpu); void mips_delete (cpu_mips_t * cpu); int mips_reset (cpu_mips_t * cpu); int mips_init (cpu_mips_t * cpu); int mips_load_elf_image (cpu_mips_t * cpu, char *filename, m_va_t * entry_point); void mips_delete (cpu_mips_t * cpu); int fastcall mips_update_irq_flag (cpu_mips_t * cpu); void mips_trigger_exception (cpu_mips_t * cpu, u_int exc_code, int bd_slot); void mips_trigger_debug_exception (cpu_mips_t * cpu, u_int dexc_type); void fastcall mips_exec_soft_fpu (cpu_mips_t * cpu); void fastcall mips_exec_eret (cpu_mips_t * cpu); void fastcall mips_exec_deret (cpu_mips_t * cpu); void fastcall mips_exec_break (cpu_mips_t * cpu, u_int code); void fastcall mips_trigger_trap_exception (cpu_mips_t * cpu); void fastcall mips_exec_syscall (cpu_mips_t * cpu); void fastcall mips_trigger_irq (cpu_mips_t * cpu); void mips_set_irq (cpu_mips_t * cpu, m_uint8_t irq); void mips_clear_irq (cpu_mips_t * cpu, m_uint8_t irq); /* Control timer interrupt */ void set_timer_irq (cpu_mips_t *cpu); void clear_timer_irq (cpu_mips_t *cpu); /* * Disassemble and print the instruction mnemonics. * Opcode size can be 4 or 2 bytes. * Parameter `isa' defines an instruction set architecture: * 0 - mips32 encoding * 1 - mips16e encoding * 2 - micromips encoding (someday) */ void print_mips (unsigned memaddr, unsigned int opcode, int nbytes, int isa, FILE *stream); const char *cp0reg_name (unsigned cp0reg, unsigned sel); int mips_fetch_instruction (cpu_mips_t * cpu, m_va_t pc, mips_insn_t * insn); void *mips_mts32_access (cpu_mips_t * cpu, m_va_t vaddr, u_int op_code, u_int op_size, u_int op_type, m_reg_t * data, u_int * exc, m_uint8_t * has_set_value, u_int is_fromgdb); #endif ================================================ FILE: tools/virtualmips/mips16-opc.c ================================================ /* * This is the opcodes table for the mips16 processor. The format of * this table is intentionally identical to the one in mips-opc.c. * However, the special letters that appear in the argument string are * different, and the table uses some different flags. * * Copyright 1996, 1997, 1998, 2000, 2005, 2006, 2007 * Free Software Foundation, Inc. * Contributed by Ian Lance Taylor, Cygnus Support * Adapted for VirtualMIPS by Serge Vakulenko. * * This file is part of the virtualmips distribution. * See LICENSE file for terms of the license. */ /* Use some short hand macros to keep down the length of the lines in the opcodes table. */ #define UBD INSN_UNCOND_BRANCH_DELAY #define UBR MIPS16_INSN_UNCOND_BRANCH #define CBR MIPS16_INSN_COND_BRANCH #define WR_x MIPS16_INSN_WRITE_X #define WR_y MIPS16_INSN_WRITE_Y #define WR_z MIPS16_INSN_WRITE_Z #define WR_T MIPS16_INSN_WRITE_T #define WR_SP MIPS16_INSN_WRITE_SP #define WR_31 MIPS16_INSN_WRITE_31 #define WR_Y MIPS16_INSN_WRITE_GPR_Y #define RD_x MIPS16_INSN_READ_X #define RD_y MIPS16_INSN_READ_Y #define RD_Z MIPS16_INSN_READ_Z #define RD_T MIPS16_INSN_READ_T #define RD_SP MIPS16_INSN_READ_SP #define RD_31 MIPS16_INSN_READ_31 #define RD_PC MIPS16_INSN_READ_PC #define RD_X MIPS16_INSN_READ_GPR_X #define WR_HI INSN_WRITE_HI #define WR_LO INSN_WRITE_LO #define RD_HI INSN_READ_HI #define RD_LO INSN_READ_LO #define TRAP INSN_TRAP static const struct mips_opcode mips16_opcodes[] = { /* name, args, match, mask, pinfo */ {"nop", "", 0x6500, 0xffff, RD_Z, }, /* move $0,$Z */ {"la", "x,A", 0x0800, 0xf800, WR_x|RD_PC, }, {"abs", "x,w", 0, (int) M_ABS, INSN_MACRO, }, {"addiu", "y,x,4", 0x4000, 0xf810, WR_y|RD_x, }, {"addiu", "x,k", 0x4800, 0xf800, WR_x|RD_x, }, {"addiu", "S,K", 0x6300, 0xff00, WR_SP|RD_SP, }, {"addiu", "S,S,K", 0x6300, 0xff00, WR_SP|RD_SP, }, {"addiu", "x,P,V", 0x0800, 0xf800, WR_x|RD_PC, }, {"addiu", "x,S,V", 0x0000, 0xf800, WR_x|RD_SP, }, {"addu", "z,v,y", 0xe001, 0xf803, WR_z|RD_x|RD_y, }, {"addu", "y,x,4", 0x4000, 0xf810, WR_y|RD_x, }, {"addu", "x,k", 0x4800, 0xf800, WR_x|RD_x, }, {"addu", "S,K", 0x6300, 0xff00, WR_SP|RD_SP, }, {"addu", "S,S,K", 0x6300, 0xff00, WR_SP|RD_SP, }, {"addu", "x,P,V", 0x0800, 0xf800, WR_x|RD_PC, }, {"addu", "x,S,V", 0x0000, 0xf800, WR_x|RD_SP, }, {"and", "x,y", 0xe80c, 0xf81f, WR_x|RD_x|RD_y, }, {"b", "q", 0x1000, 0xf800, UBR, }, {"beq", "x,y,p", 0, (int) M_BEQ, INSN_MACRO, }, {"beq", "x,U,p", 0, (int) M_BEQ_I, INSN_MACRO, }, {"beqz", "x,p", 0x2000, 0xf800, CBR|RD_x, }, {"bge", "x,y,p", 0, (int) M_BGE, INSN_MACRO, }, {"bge", "x,8,p", 0, (int) M_BGE_I, INSN_MACRO, }, {"bgeu", "x,y,p", 0, (int) M_BGEU, INSN_MACRO, }, {"bgeu", "x,8,p", 0, (int) M_BGEU_I, INSN_MACRO, }, {"bgt", "x,y,p", 0, (int) M_BGT, INSN_MACRO, }, {"bgt", "x,8,p", 0, (int) M_BGT_I, INSN_MACRO, }, {"bgtu", "x,y,p", 0, (int) M_BGTU, INSN_MACRO, }, {"bgtu", "x,8,p", 0, (int) M_BGTU_I, INSN_MACRO, }, {"ble", "x,y,p", 0, (int) M_BLE, INSN_MACRO, }, {"ble", "x,8,p", 0, (int) M_BLE_I, INSN_MACRO, }, {"bleu", "x,y,p", 0, (int) M_BLEU, INSN_MACRO, }, {"bleu", "x,8,p", 0, (int) M_BLEU_I, INSN_MACRO, }, {"blt", "x,y,p", 0, (int) M_BLT, INSN_MACRO, }, {"blt", "x,8,p", 0, (int) M_BLT_I, INSN_MACRO, }, {"bltu", "x,y,p", 0, (int) M_BLTU, INSN_MACRO, }, {"bltu", "x,8,p", 0, (int) M_BLTU_I, INSN_MACRO, }, {"bne", "x,y,p", 0, (int) M_BNE, INSN_MACRO, }, {"bne", "x,U,p", 0, (int) M_BNE_I, INSN_MACRO, }, {"bnez", "x,p", 0x2800, 0xf800, CBR|RD_x, }, {"break", "6", 0xe805, 0xf81f, TRAP, }, {"bteqz", "p", 0x6000, 0xff00, CBR|RD_T, }, {"btnez", "p", 0x6100, 0xff00, CBR|RD_T, }, {"cmpi", "x,U", 0x7000, 0xf800, WR_T|RD_x, }, {"cmp", "x,y", 0xe80a, 0xf81f, WR_T|RD_x|RD_y, }, {"cmp", "x,U", 0x7000, 0xf800, WR_T|RD_x, }, {"dla", "y,E", 0xfe00, 0xff00, WR_y|RD_PC, }, {"daddiu", "y,x,4", 0x4010, 0xf810, WR_y|RD_x, }, {"daddiu", "y,j", 0xfd00, 0xff00, WR_y|RD_y, }, {"daddiu", "S,K", 0xfb00, 0xff00, WR_SP|RD_SP, }, {"daddiu", "S,S,K", 0xfb00, 0xff00, WR_SP|RD_SP, }, {"daddiu", "y,P,W", 0xfe00, 0xff00, WR_y|RD_PC, }, {"daddiu", "y,S,W", 0xff00, 0xff00, WR_y|RD_SP, }, {"daddu", "z,v,y", 0xe000, 0xf803, WR_z|RD_x|RD_y, }, {"daddu", "y,x,4", 0x4010, 0xf810, WR_y|RD_x, }, {"daddu", "y,j", 0xfd00, 0xff00, WR_y|RD_y, }, {"daddu", "S,K", 0xfb00, 0xff00, WR_SP|RD_SP, }, {"daddu", "S,S,K", 0xfb00, 0xff00, WR_SP|RD_SP, }, {"daddu", "y,P,W", 0xfe00, 0xff00, WR_y|RD_PC, }, {"daddu", "y,S,W", 0xff00, 0xff00, WR_y|RD_SP, }, {"ddiv", "0,x,y", 0xe81e, 0xf81f, RD_x|RD_y|WR_HI|WR_LO, }, {"ddiv", "z,v,y", 0, (int) M_DDIV_3, INSN_MACRO, }, {"ddivu", "0,x,y", 0xe81f, 0xf81f, RD_x|RD_y|WR_HI|WR_LO, }, {"ddivu", "z,v,y", 0, (int) M_DDIVU_3, INSN_MACRO, }, {"div", "0,x,y", 0xe81a, 0xf81f, RD_x|RD_y|WR_HI|WR_LO, }, {"div", "z,v,y", 0, (int) M_DIV_3, INSN_MACRO, }, {"divu", "0,x,y", 0xe81b, 0xf81f, RD_x|RD_y|WR_HI|WR_LO, }, {"divu", "z,v,y", 0, (int) M_DIVU_3, INSN_MACRO, }, {"dmul", "z,v,y", 0, (int) M_DMUL, INSN_MACRO, }, {"dmult", "x,y", 0xe81c, 0xf81f, RD_x|RD_y|WR_HI|WR_LO, }, {"dmultu", "x,y", 0xe81d, 0xf81f, RD_x|RD_y|WR_HI|WR_LO, }, {"drem", "0,x,y", 0xe81e, 0xf81f, RD_x|RD_y|WR_HI|WR_LO, }, {"drem", "z,v,y", 0, (int) M_DREM_3, INSN_MACRO, }, {"dremu", "0,x,y", 0xe81f, 0xf81f, RD_x|RD_y|WR_HI|WR_LO, }, {"dremu", "z,v,y", 0, (int) M_DREMU_3, INSN_MACRO, }, {"dsllv", "y,x", 0xe814, 0xf81f, WR_y|RD_y|RD_x, }, {"dsll", "x,w,[", 0x3001, 0xf803, WR_x|RD_y, }, {"dsll", "y,x", 0xe814, 0xf81f, WR_y|RD_y|RD_x, }, {"dsrav", "y,x", 0xe817, 0xf81f, WR_y|RD_y|RD_x, }, {"dsra", "y,]", 0xe813, 0xf81f, WR_y|RD_y, }, {"dsra", "y,x", 0xe817, 0xf81f, WR_y|RD_y|RD_x, }, {"dsrlv", "y,x", 0xe816, 0xf81f, WR_y|RD_y|RD_x, }, {"dsrl", "y,]", 0xe808, 0xf81f, WR_y|RD_y, }, {"dsrl", "y,x", 0xe816, 0xf81f, WR_y|RD_y|RD_x, }, {"dsubu", "z,v,y", 0xe002, 0xf803, WR_z|RD_x|RD_y, }, {"dsubu", "y,x,4", 0, (int) M_DSUBU_I, INSN_MACRO, }, {"dsubu", "y,j", 0, (int) M_DSUBU_I_2, INSN_MACRO, }, {"exit", "L", 0xed09, 0xff1f, TRAP, }, {"exit", "L", 0xee09, 0xff1f, TRAP, }, {"exit", "L", 0xef09, 0xff1f, TRAP, }, {"entry", "l", 0xe809, 0xf81f, TRAP, }, {"jalr", "x", 0xe840, 0xf8ff, UBD|WR_31|RD_x, }, {"jalr", "R,x", 0xe840, 0xf8ff, UBD|WR_31|RD_x, }, {"jal", "x", 0xe840, 0xf8ff, UBD|WR_31|RD_x, }, {"jal", "R,x", 0xe840, 0xf8ff, UBD|WR_31|RD_x, }, {"jal", "a", 0x1800, 0xfc00, UBD|WR_31, }, {"jalx", "a", 0x1c00, 0xfc00, UBD|WR_31, }, {"jr", "x", 0xe800, 0xf8ff, UBD|RD_x, }, {"jr", "R", 0xe820, 0xffff, UBD|RD_31, }, {"j", "x", 0xe800, 0xf8ff, UBD|RD_x, }, {"j", "R", 0xe820, 0xffff, UBD|RD_31, }, {"lb", "y,5(x)", 0x8000, 0xf800, WR_y|RD_x, }, {"lbu", "y,5(x)", 0xa000, 0xf800, WR_y|RD_x, }, {"ld", "y,D(x)", 0x3800, 0xf800, WR_y|RD_x, }, {"ld", "y,B", 0xfc00, 0xff00, WR_y|RD_PC, }, {"ld", "y,D(P)", 0xfc00, 0xff00, WR_y|RD_PC, }, {"ld", "y,D(S)", 0xf800, 0xff00, WR_y|RD_SP, }, {"lh", "y,H(x)", 0x8800, 0xf800, WR_y|RD_x, }, {"lhu", "y,H(x)", 0xa800, 0xf800, WR_y|RD_x, }, {"li", "x,U", 0x6800, 0xf800, WR_x, }, {"lw", "y,W(x)", 0x9800, 0xf800, WR_y|RD_x, }, {"lw", "x,A", 0xb000, 0xf800, WR_x|RD_PC, }, {"lw", "x,V(P)", 0xb000, 0xf800, WR_x|RD_PC, }, {"lw", "x,V(S)", 0x9000, 0xf800, WR_x|RD_SP, }, {"lwu", "y,W(x)", 0xb800, 0xf800, WR_y|RD_x, }, {"mfhi", "x", 0xe810, 0xf8ff, WR_x|RD_HI, }, {"mflo", "x", 0xe812, 0xf8ff, WR_x|RD_LO, }, {"move", "y,X", 0x6700, 0xff00, WR_y|RD_X, }, {"move", "Y,Z", 0x6500, 0xff00, WR_Y|RD_Z, }, {"mul", "z,v,y", 0, (int) M_MUL, INSN_MACRO, }, {"mult", "x,y", 0xe818, 0xf81f, RD_x|RD_y|WR_HI|WR_LO, }, {"multu", "x,y", 0xe819, 0xf81f, RD_x|RD_y|WR_HI|WR_LO, }, {"neg", "x,w", 0xe80b, 0xf81f, WR_x|RD_y, }, {"not", "x,w", 0xe80f, 0xf81f, WR_x|RD_y, }, {"or", "x,y", 0xe80d, 0xf81f, WR_x|RD_x|RD_y, }, {"rem", "0,x,y", 0xe81a, 0xf81f, RD_x|RD_y|WR_HI|WR_LO, }, {"rem", "z,v,y", 0, (int) M_REM_3, INSN_MACRO, }, {"remu", "0,x,y", 0xe81b, 0xf81f, RD_x|RD_y|WR_HI|WR_LO, }, {"remu", "z,v,y", 0, (int) M_REMU_3, INSN_MACRO, }, {"sb", "y,5(x)", 0xc000, 0xf800, RD_y|RD_x, }, {"sd", "y,D(x)", 0x7800, 0xf800, RD_y|RD_x, }, {"sd", "y,D(S)", 0xf900, 0xff00, RD_y|RD_PC, }, {"sd", "R,C(S)", 0xfa00, 0xff00, RD_31|RD_PC, }, {"sh", "y,H(x)", 0xc800, 0xf800, RD_y|RD_x, }, {"sllv", "y,x", 0xe804, 0xf81f, WR_y|RD_y|RD_x, }, {"sll", "x,w,<", 0x3000, 0xf803, WR_x|RD_y, }, {"sll", "y,x", 0xe804, 0xf81f, WR_y|RD_y|RD_x, }, {"slti", "x,8", 0x5000, 0xf800, WR_T|RD_x, }, {"slt", "x,y", 0xe802, 0xf81f, WR_T|RD_x|RD_y, }, {"slt", "x,8", 0x5000, 0xf800, WR_T|RD_x, }, {"sltiu", "x,8", 0x5800, 0xf800, WR_T|RD_x, }, {"sltu", "x,y", 0xe803, 0xf81f, WR_T|RD_x|RD_y, }, {"sltu", "x,8", 0x5800, 0xf800, WR_T|RD_x, }, {"srav", "y,x", 0xe807, 0xf81f, WR_y|RD_y|RD_x, }, {"sra", "x,w,<", 0x3003, 0xf803, WR_x|RD_y, }, {"sra", "y,x", 0xe807, 0xf81f, WR_y|RD_y|RD_x, }, {"srlv", "y,x", 0xe806, 0xf81f, WR_y|RD_y|RD_x, }, {"srl", "x,w,<", 0x3002, 0xf803, WR_x|RD_y, }, {"srl", "y,x", 0xe806, 0xf81f, WR_y|RD_y|RD_x, }, {"subu", "z,v,y", 0xe003, 0xf803, WR_z|RD_x|RD_y, }, {"subu", "y,x,4", 0, (int) M_SUBU_I, INSN_MACRO, }, {"subu", "x,k", 0, (int) M_SUBU_I_2, INSN_MACRO, }, {"sw", "y,W(x)", 0xd800, 0xf800, RD_y|RD_x, }, {"sw", "x,V(S)", 0xd000, 0xf800, RD_x|RD_SP, }, {"sw", "R,V(S)", 0x6200, 0xff00, RD_31|RD_SP, }, {"xor", "x,y", 0xe80e, 0xf81f, WR_x|RD_x|RD_y, }, /* MIPS16e additions */ {"jalrc", "x", 0xe8c0, 0xf8ff, UBR|WR_31|RD_x|TRAP, }, {"jalrc", "R,x", 0xe8c0, 0xf8ff, UBR|WR_31|RD_x|TRAP, }, {"jrc", "x", 0xe880, 0xf8ff, UBR|RD_x|TRAP, }, {"jrc", "R", 0xe8a0, 0xffff, UBR|RD_31|TRAP, }, {"restore", "M", 0x6400, 0xff80, WR_31|RD_SP|WR_SP|TRAP, }, {"save", "m", 0x6480, 0xff80, RD_31|RD_SP|WR_SP|TRAP, }, {"sdbbp", "6", 0xe801, 0xf81f, TRAP, }, {"seb", "x", 0xe891, 0xf8ff, WR_x|RD_x, }, {"seh", "x", 0xe8b1, 0xf8ff, WR_x|RD_x, }, {"sew", "x", 0xe8d1, 0xf8ff, WR_x|RD_x, }, {"zeb", "x", 0xe811, 0xf8ff, WR_x|RD_x, }, {"zeh", "x", 0xe831, 0xf8ff, WR_x|RD_x, }, {"zew", "x", 0xe851, 0xf8ff, WR_x|RD_x, }, }; static const int mips16_num_opcodes = ((sizeof mips16_opcodes) / (sizeof (mips16_opcodes[0]))); #undef UBD #undef UBR #undef CBR #undef WR_x #undef WR_y #undef WR_z #undef WR_T #undef WR_SP #undef WR_31 #undef WR_Y #undef RD_x #undef RD_y #undef RD_Z #undef RD_T #undef RD_SP #undef RD_31 #undef RD_PC #undef RD_X #undef WR_HI #undef WR_LO #undef RD_HI #undef RD_LO #undef TRAP ================================================ FILE: tools/virtualmips/mips_codetable.c ================================================ /* * Code dispatch table. * * Copyright (C) yajin 2008 * * This file is part of the virtualmips distribution. * See LICENSE file for terms of the license. */ /* * Take the 'reserved instruction' exception. */ static int unknown_op (cpu_mips_t * cpu, mips_insn_t insn) { #if 0 printf ("--- Unknown instruction:\n"); printf ("%08x: %08x ", cpu->pc, insn); print_mips (cpu->pc, insn, cpu->insn_len, cpu->is_mips16e, stdout); printf ("\n"); #endif mips_trigger_exception (cpu, MIPS_CP0_CAUSE_ILLOP, cpu->is_in_bdslot); return 1; } /* * Take the 'coprocessor unusable' exception. */ static int cop_unusable(cpu_mips_t * cpu, int cop_index) { if (cpu->cp0.reg[MIPS_CP0_DEBUG] & MIPS_CP0_DEBUG_DM) { /* Coprocessor unusable in Debug mode. */ mips_trigger_debug_exception (cpu, 0); cpu->cp0.reg[MIPS_CP0_DEBUG] |= MIPS_CP0_CAUSE_CP_UNUSABLE << MIPS_CP0_DEBUG_DEXCCODE_SHIFT; } else { /* Set Cause.CE field. */ cpu->cp0.reg[MIPS_CP0_CAUSE] &= ~MIPS_CP0_CAUSE_CEMASK; cpu->cp0.reg[MIPS_CP0_CAUSE] |= cop_index << MIPS_CP0_CAUSE_CESHIFT; mips_trigger_exception (cpu, MIPS_CP0_CAUSE_CP_UNUSABLE, cpu->is_in_bdslot); } return 1; } static int add_op (cpu_mips_t *cpu, mips_insn_t insn) { int rs = bits (insn, 21, 25); int rt = bits (insn, 16, 20); int rd = bits (insn, 11, 15); m_ireg_t a = cpu->gpr[rs]; m_ireg_t b = cpu->gpr[rt]; m_ireg_t res = a + b; if ((a > 0 && b > 0 && res < 0) || (a < 0 && b < 0 && res >= 0)) { /* Take overflow exception. */ mips_trigger_exception (cpu, MIPS_CP0_CAUSE_OVFLW, cpu->is_in_bdslot); return 1; } cpu->reg_set (cpu, rd, sign_extend (res, 32)); return (0); } static int addi_op (cpu_mips_t * cpu, mips_insn_t insn) { int rs = bits (insn, 21, 25); int rt = bits (insn, 16, 20); int imm = bits (insn, 0, 15); m_ireg_t a = cpu->gpr[rs]; m_ireg_t b = sign_extend (imm, 16); m_ireg_t res = a + b; if ((a > 0 && b > 0 && res < 0) || (a < 0 && b < 0 && res >= 0)) { /* Take overflow exception. */ mips_trigger_exception (cpu, MIPS_CP0_CAUSE_OVFLW, cpu->is_in_bdslot); return 1; } cpu->reg_set (cpu, rt, sign_extend (res, 32)); return (0); } static int addiu_op (cpu_mips_t * cpu, mips_insn_t insn) { int rs = bits (insn, 21, 25); int rt = bits (insn, 16, 20); int imm = bits (insn, 0, 15); m_uint32_t res, val = sign_extend (imm, 16); res = (m_uint32_t) cpu->gpr[rs] + val; cpu->reg_set (cpu, rt, sign_extend (res, 32)); return (0); } static int addu_op (cpu_mips_t * cpu, mips_insn_t insn) { int rs = bits (insn, 21, 25); int rt = bits (insn, 16, 20); int rd = bits (insn, 11, 15); m_uint32_t res; res = (m_uint32_t) cpu->gpr[rs] + (m_uint32_t) cpu->gpr[rt]; cpu->reg_set (cpu, rd, sign_extend (res, 32)); return (0); } static int and_op (cpu_mips_t * cpu, mips_insn_t insn) { int rs = bits (insn, 21, 25); int rt = bits (insn, 16, 20); int rd = bits (insn, 11, 15); cpu->reg_set (cpu, rd, cpu->gpr[rs] & cpu->gpr[rt]); return (0); } static int andi_op (cpu_mips_t * cpu, mips_insn_t insn) { int rs = bits (insn, 21, 25); int rt = bits (insn, 16, 20); int imm = bits (insn, 0, 15); cpu->reg_set (cpu, rt, cpu->gpr[rs] & imm); return (0); } static int bcond_op (cpu_mips_t * cpu, mips_insn_t insn) { uint16_t special_func = bits (insn, 16, 20); return mips_bcond_opcodes[special_func].func (cpu, insn); } static int beq_op (cpu_mips_t * cpu, mips_insn_t insn) { int rs = bits (insn, 21, 25); int rt = bits (insn, 16, 20); int offset = bits (insn, 0, 15); m_va_t new_pc; int res; /* compute the new pc */ new_pc = (cpu->pc + 4) + sign_extend (offset << 2, 18); /* take the branch if gpr[rs] == gpr[rt] */ res = (cpu->gpr[rs] == cpu->gpr[rt]); /* exec the instruction in the delay slot */ int ins_res = mips_exec_bdslot (cpu); if (likely (!ins_res)) { if (res) cpu->pc = new_pc; else cpu->pc += 8; } return (1); } static int beql_op (cpu_mips_t * cpu, mips_insn_t insn) { int rs = bits (insn, 21, 25); int rt = bits (insn, 16, 20); int offset = bits (insn, 0, 15); m_va_t new_pc; int res; /* compute the new pc */ new_pc = (cpu->pc + 4) + sign_extend (offset << 2, 18); /* take the branch if gpr[rs] == gpr[rt] */ res = (cpu->gpr[rs] == cpu->gpr[rt]); /* take the branch if the test result is true */ if (res) { int ins_res = mips_exec_bdslot (cpu); if (likely (!ins_res)) cpu->pc = new_pc; } else cpu->pc += 8; return (1); } static int bgez_op (cpu_mips_t * cpu, mips_insn_t insn) { int rs = bits (insn, 21, 25); int offset = bits (insn, 0, 15); m_va_t new_pc; int res; /* compute the new pc */ new_pc = (cpu->pc + 4) + sign_extend (offset << 2, 18); /* take the branch if gpr[rs] >= 0 */ res = ((m_ireg_t) cpu->gpr[rs] >= 0); /* exec the instruction in the delay slot */ /* exec the instruction in the delay slot */ int ins_res = mips_exec_bdslot (cpu); if (likely (!ins_res)) { /* take the branch if the test result is true */ if (res) cpu->pc = new_pc; else cpu->pc += 8; } return (1); } static int bgezal_op (cpu_mips_t * cpu, mips_insn_t insn) { int rs = bits (insn, 21, 25); int offset = bits (insn, 0, 15); m_va_t new_pc; int res; /* compute the new pc */ new_pc = (cpu->pc + 4) + sign_extend (offset << 2, 18); /* set the return address (instruction after the delay slot) */ cpu->reg_set (cpu, MIPS_GPR_RA, cpu->pc + 8); /* take the branch if gpr[rs] >= 0 */ res = ((m_ireg_t) cpu->gpr[rs] >= 0); /* exec the instruction in the delay slot */ int ins_res = mips_exec_bdslot (cpu); if (likely (!ins_res)) { /* take the branch if the test result is true */ if (res) cpu->pc = new_pc; else cpu->pc += 8; } return (1); } static int bgezall_op (cpu_mips_t * cpu, mips_insn_t insn) { int rs = bits (insn, 21, 25); int offset = bits (insn, 0, 15); m_va_t new_pc; int res; /* compute the new pc */ new_pc = (cpu->pc + 4) + sign_extend (offset << 2, 18); /* set the return address (instruction after the delay slot) */ cpu->reg_set (cpu, MIPS_GPR_RA, cpu->pc + 8); /* take the branch if gpr[rs] >= 0 */ res = ((m_ireg_t) cpu->gpr[rs] >= 0); /* take the branch if the test result is true */ if (res) { mips_exec_bdslot (cpu); cpu->pc = new_pc; } else cpu->pc += 8; return (1); } static int bgezl_op (cpu_mips_t * cpu, mips_insn_t insn) { int rs = bits (insn, 21, 25); int offset = bits (insn, 0, 15); m_va_t new_pc; int res; /* compute the new pc */ new_pc = (cpu->pc + 4) + sign_extend (offset << 2, 18); /* take the branch if gpr[rs] >= 0 */ res = ((m_ireg_t) cpu->gpr[rs] >= 0); /* take the branch if the test result is true */ if (res) { mips_exec_bdslot (cpu); cpu->pc = new_pc; } else cpu->pc += 8; return (1); } static int bgtz_op (cpu_mips_t * cpu, mips_insn_t insn) { int rs = bits (insn, 21, 25); int offset = bits (insn, 0, 15); m_va_t new_pc; int res; /* compute the new pc */ new_pc = (cpu->pc + 4) + sign_extend (offset << 2, 18); /* take the branch if gpr[rs] > 0 */ res = ((m_ireg_t) cpu->gpr[rs] > 0); /* exec the instruction in the delay slot */ int ins_res = mips_exec_bdslot (cpu); if (likely (!ins_res)) { /* take the branch if the test result is true */ if (res) cpu->pc = new_pc; else cpu->pc += 8; } return (1); } static int bgtzl_op (cpu_mips_t * cpu, mips_insn_t insn) { int rs = bits (insn, 21, 25); int offset = bits (insn, 0, 15); m_va_t new_pc; int res; /* compute the new pc */ new_pc = (cpu->pc + 4) + sign_extend (offset << 2, 18); /* take the branch if gpr[rs] > 0 */ res = ((m_ireg_t) cpu->gpr[rs] > 0); /* take the branch if the test result is true */ if (res) { mips_exec_bdslot (cpu); cpu->pc = new_pc; } else cpu->pc += 8; return (1); } static int blez_op (cpu_mips_t * cpu, mips_insn_t insn) { int rs = bits (insn, 21, 25); int offset = bits (insn, 0, 15); m_va_t new_pc; int res; /* compute the new pc */ new_pc = (cpu->pc + 4) + sign_extend (offset << 2, 18); /* take the branch if gpr[rs] <= 0 */ res = ((m_ireg_t) cpu->gpr[rs] <= 0); /* exec the instruction in the delay slot */ int ins_res = mips_exec_bdslot (cpu); if (likely (!ins_res)) { /* take the branch if the test result is true */ if (res) cpu->pc = new_pc; else cpu->pc += 8; } return (1); } static int blezl_op (cpu_mips_t * cpu, mips_insn_t insn) { int rs = bits (insn, 21, 25); int offset = bits (insn, 0, 15); m_va_t new_pc; int res; /* compute the new pc */ new_pc = (cpu->pc + 4) + sign_extend (offset << 2, 18); /* take the branch if gpr[rs] <= 0 */ res = ((m_ireg_t) cpu->gpr[rs] <= 0); /* take the branch if the test result is true */ if (res) { mips_exec_bdslot (cpu); cpu->pc = new_pc; } else cpu->pc += 8; return (1); } static int bltz_op (cpu_mips_t * cpu, mips_insn_t insn) { int rs = bits (insn, 21, 25); int offset = bits (insn, 0, 15); m_va_t new_pc; int res; /* compute the new pc */ new_pc = (cpu->pc + 4) + sign_extend (offset << 2, 18); /* take the branch if gpr[rs] < 0 */ res = ((m_ireg_t) cpu->gpr[rs] < 0); /* exec the instruction in the delay slot */ int ins_res = mips_exec_bdslot (cpu); if (likely (!ins_res)) { /* take the branch if the test result is true */ if (res) cpu->pc = new_pc; else cpu->pc += 8; } return (1); } static int bltzal_op (cpu_mips_t * cpu, mips_insn_t insn) { int rs = bits (insn, 21, 25); int offset = bits (insn, 0, 15); m_va_t new_pc; int res; /* compute the new pc */ new_pc = (cpu->pc + 4) + sign_extend (offset << 2, 18); /* set the return address (instruction after the delay slot) */ cpu->reg_set (cpu, MIPS_GPR_RA, cpu->pc + 8); /* take the branch if gpr[rs] < 0 */ res = ((m_ireg_t) cpu->gpr[rs] < 0); /* exec the instruction in the delay slot */ int ins_res = mips_exec_bdslot (cpu); if (likely (!ins_res)) { /* take the branch if the test result is true */ if (res) cpu->pc = new_pc; else cpu->pc += 8; } return (1); } static int bltzall_op (cpu_mips_t * cpu, mips_insn_t insn) { int rs = bits (insn, 21, 25); int offset = bits (insn, 0, 15); m_va_t new_pc; int res; /* compute the new pc */ new_pc = (cpu->pc + 4) + sign_extend (offset << 2, 18); /* set the return address (instruction after the delay slot) */ cpu->reg_set (cpu, MIPS_GPR_RA, cpu->pc + 8); /* take the branch if gpr[rs] < 0 */ res = ((m_ireg_t) cpu->gpr[rs] < 0); /* take the branch if the test result is true */ if (res) { mips_exec_bdslot (cpu); cpu->pc = new_pc; } else cpu->pc += 8; return (1); } static int bltzl_op (cpu_mips_t * cpu, mips_insn_t insn) { int rs = bits (insn, 21, 25); int offset = bits (insn, 0, 15); m_va_t new_pc; int res; /* compute the new pc */ new_pc = (cpu->pc + 4) + sign_extend (offset << 2, 18); /* take the branch if gpr[rs] < 0 */ res = ((m_ireg_t) cpu->gpr[rs] < 0); /* take the branch if the test result is true */ if (res) { mips_exec_bdslot (cpu); cpu->pc = new_pc; } else cpu->pc += 8; return (1); } static int bne_op (cpu_mips_t * cpu, mips_insn_t insn) { int rs = bits (insn, 21, 25); int rt = bits (insn, 16, 20); int offset = bits (insn, 0, 15); m_va_t new_pc; int res; /* compute the new pc */ new_pc = (cpu->pc + 4) + sign_extend (offset << 2, 18); /* take the branch if gpr[rs] != gpr[rt] */ res = (cpu->gpr[rs] != cpu->gpr[rt]); /* exec the instruction in the delay slot */ int ins_res = mips_exec_bdslot (cpu); if (likely (!ins_res)) { /* take the branch if the test result is true */ if (res) cpu->pc = new_pc; else cpu->pc += 8; } return (1); } static int bnel_op (cpu_mips_t * cpu, mips_insn_t insn) { int rs = bits (insn, 21, 25); int rt = bits (insn, 16, 20); int offset = bits (insn, 0, 15); m_va_t new_pc; int res; /* compute the new pc */ new_pc = (cpu->pc + 4) + sign_extend (offset << 2, 18); /* take the branch if gpr[rs] != gpr[rt] */ res = (cpu->gpr[rs] != cpu->gpr[rt]); /* take the branch if the test result is true */ if (res) { mips_exec_bdslot (cpu); cpu->pc = new_pc; } else cpu->pc += 8; return (1); } static int break_op (cpu_mips_t * cpu, mips_insn_t insn) { u_int code = bits (insn, 6, 25); mips_exec_break (cpu, code); return (1); } static int cache_op (cpu_mips_t * cpu, mips_insn_t insn) { int base = bits (insn, 21, 25); int op = bits (insn, 16, 20); int offset = bits (insn, 0, 15); return (mips_exec_memop2 (cpu, MIPS_MEMOP_CACHE, base, offset, op, FALSE)); } static int cfc0_op (cpu_mips_t * cpu, mips_insn_t insn) { return unknown_op (cpu, insn); } static int clz_op (cpu_mips_t * cpu, mips_insn_t insn) { int rs = bits (insn, 21, 25); int rd = bits (insn, 11, 15); int i; m_uint32_t val; val = 32; for (i = 31; i >= 0; i--) { if (cpu->gpr[rs] & (1 << i)) { val = 31 - i; break; } } cpu->reg_set (cpu, rd, val); return (0); } static int clo_op (cpu_mips_t * cpu, mips_insn_t insn) { int rs = bits (insn, 21, 25); int rd = bits (insn, 11, 15); int i; m_uint32_t val; val = 32; for (i = 31; i >= 0; i--) { if (! (cpu->gpr[rs] & (1 << i))) { val = 31 - i; break; } } cpu->reg_set (cpu, rd, val); return (0); } static int cop0_op (cpu_mips_t * cpu, mips_insn_t insn) { uint16_t special_func = bits (insn, 21, 25); //printf ("cop0 instruction. func %x\n", special_func); return mips_cop0_opcodes[special_func].func (cpu, insn); } static int cop1_op (cpu_mips_t * cpu, mips_insn_t insn) { #if SOFT_FPU mips_exec_soft_fpu (cpu); return (1); #else if (! (cpu->cp0.reg [MIPS_CP0_STATUS] & MIPS_CP0_STATUS_CU1)) { return cop_unusable (cpu, 1); } return unknown_op (cpu, insn); #endif } static int cop2_op (cpu_mips_t * cpu, mips_insn_t insn) { if (! (cpu->cp0.reg [MIPS_CP0_STATUS] & MIPS_CP0_STATUS_CU2)) { return cop_unusable (cpu, 2); } return unknown_op (cpu, insn); } static int div_op (cpu_mips_t * cpu, mips_insn_t insn) { int rs = bits (insn, 21, 25); int rt = bits (insn, 16, 20); if (cpu->gpr[rt] == 0) return (0); if (cpu->gpr[rs] == 0x80000000 && cpu->gpr[rt] == 0xFFFFFFFF) { cpu->lo = 0x80000000; cpu->hi = 0; return (0); } cpu->lo = (m_int32_t) cpu->gpr[rs] / (m_int32_t) cpu->gpr[rt]; cpu->hi = (m_int32_t) cpu->gpr[rs] % (m_int32_t) cpu->gpr[rt]; cpu->lo = sign_extend (cpu->lo, 32); cpu->hi = sign_extend (cpu->hi, 32); return (0); } static int divu_op (cpu_mips_t * cpu, mips_insn_t insn) { int rs = bits (insn, 21, 25); int rt = bits (insn, 16, 20); if (cpu->gpr[rt] == 0) return (0); cpu->lo = (m_uint32_t) cpu->gpr[rs] / (m_uint32_t) cpu->gpr[rt]; cpu->hi = (m_uint32_t) cpu->gpr[rs] % (m_uint32_t) cpu->gpr[rt]; cpu->lo = sign_extend (cpu->lo, 32); cpu->hi = sign_extend (cpu->hi, 32); return (0); } static int eret_op (cpu_mips_t * cpu, mips_insn_t insn) { #if 1 if (cpu->trace_syscall && (cpu->cp0.reg[MIPS_CP0_STATUS] & MIPS_CP0_STATUS_UM)) { if (cpu->gpr[2] == 0xffffffff) printf (" syscall failed, errno %u\n", cpu->gpr[8]); else { if (cpu->gpr[2] & ~0xffff) printf (" syscall returned %08x\n", cpu->gpr[2]); else printf (" syscall returned %u\n", cpu->gpr[2]); } cpu->trace_syscall = 0; } #endif mips_exec_eret (cpu); return (1); } static int deret_op (cpu_mips_t * cpu, mips_insn_t insn) { mips_exec_deret (cpu); return (1); } static int j_op (cpu_mips_t * cpu, mips_insn_t insn) { u_int instr_index = bits (insn, 0, 25); m_va_t new_pc; /* compute the new pc */ new_pc = cpu->pc & ~((1 << 28) - 1); new_pc |= instr_index << 2; /* exec the instruction in the delay slot */ int ins_res = mips_exec_bdslot (cpu); if (likely (!ins_res)) cpu->pc = new_pc; return (1); } static int jal_op (cpu_mips_t * cpu, mips_insn_t insn) { u_int instr_index = bits (insn, 0, 25); m_va_t new_pc; /* compute the new pc */ new_pc = (cpu->pc + 4) & ~((1 << 28) - 1); new_pc |= instr_index << 2; /* set the return address (instruction after the delay slot) */ cpu->reg_set (cpu, MIPS_GPR_RA, cpu->pc + 8); int ins_res = mips_exec_bdslot (cpu); if (likely (!ins_res)) cpu->pc = new_pc; return (1); } static int jalx_op (cpu_mips_t * cpu, mips_insn_t insn) { u_int instr_index = bits (insn, 0, 25); m_va_t new_pc; /* compute the new pc */ new_pc = (cpu->pc + 4) & ~((1 << 28) - 1); new_pc |= instr_index << 2; /* set the return address (instruction after the delay slot) */ cpu->reg_set (cpu, MIPS_GPR_RA, cpu->pc + 8); int ins_res = mips_exec_bdslot (cpu); if (likely (!ins_res)) { cpu->is_mips16e = 1; cpu->pc = new_pc; } return (1); } static int jalr_op (cpu_mips_t * cpu, mips_insn_t insn) { int rs = bits (insn, 21, 25); int rd = bits (insn, 11, 15); m_va_t new_pc; /* set the return pc (instruction after the delay slot) in GPR[rd] */ cpu->reg_set (cpu, rd, cpu->pc + 8); /* get the new pc */ new_pc = cpu->gpr[rs]; int ins_res = mips_exec_bdslot (cpu); if (likely (!ins_res)) { cpu->is_mips16e = new_pc & 1; cpu->pc = new_pc & 0xFFFFFFFE; } return (1); } static int jr_op (cpu_mips_t * cpu, mips_insn_t insn) { int rs = bits (insn, 21, 25); m_va_t new_pc; /* get the new pc */ new_pc = cpu->gpr[rs]; int ins_res = mips_exec_bdslot (cpu); if (likely (!ins_res)) { cpu->is_mips16e = new_pc & 1; cpu->pc = new_pc & 0xFFFFFFFE; } return (1); } static int lb_op (cpu_mips_t * cpu, mips_insn_t insn) { int base = bits (insn, 21, 25); int rt = bits (insn, 16, 20); int offset = bits (insn, 0, 15); return (mips_exec_memop2 (cpu, MIPS_MEMOP_LB, base, offset, rt, TRUE)); } static int lbu_op (cpu_mips_t * cpu, mips_insn_t insn) { int base = bits (insn, 21, 25); int rt = bits (insn, 16, 20); int offset = bits (insn, 0, 15); return (mips_exec_memop2 (cpu, MIPS_MEMOP_LBU, base, offset, rt, TRUE)); } static int lh_op (cpu_mips_t * cpu, mips_insn_t insn) { int base = bits (insn, 21, 25); int rt = bits (insn, 16, 20); int offset = bits (insn, 0, 15); return (mips_exec_memop2 (cpu, MIPS_MEMOP_LH, base, offset, rt, TRUE)); } static int lhu_op (cpu_mips_t * cpu, mips_insn_t insn) { int base = bits (insn, 21, 25); int rt = bits (insn, 16, 20); int offset = bits (insn, 0, 15); return (mips_exec_memop2 (cpu, MIPS_MEMOP_LHU, base, offset, rt, TRUE)); } static int ll_op (cpu_mips_t * cpu, mips_insn_t insn) { int base = bits (insn, 21, 25); int rt = bits (insn, 16, 20); int offset = bits (insn, 0, 15); return (mips_exec_memop2 (cpu, MIPS_MEMOP_LL, base, offset, rt, TRUE)); } static int lui_op (cpu_mips_t * cpu, mips_insn_t insn) { int rt = bits (insn, 16, 20); int imm = bits (insn, 0, 15); cpu->reg_set (cpu, rt, sign_extend (imm, 16) << 16); return (0); } static int lw_op (cpu_mips_t * cpu, mips_insn_t insn) { int base = bits (insn, 21, 25); int rt = bits (insn, 16, 20); int offset = bits (insn, 0, 15); return (mips_exec_memop2 (cpu, MIPS_MEMOP_LW, base, offset, rt, TRUE)); } static int lwl_op (cpu_mips_t * cpu, mips_insn_t insn) { int base = bits (insn, 21, 25); int rt = bits (insn, 16, 20); int offset = bits (insn, 0, 15); return (mips_exec_memop2 (cpu, MIPS_MEMOP_LWL, base, offset, rt, TRUE)); } static int lwr_op (cpu_mips_t * cpu, mips_insn_t insn) { int base = bits (insn, 21, 25); int rt = bits (insn, 16, 20); int offset = bits (insn, 0, 15); return (mips_exec_memop2 (cpu, MIPS_MEMOP_LWR, base, offset, rt, TRUE)); } static int spec3_op (cpu_mips_t * cpu, mips_insn_t insn) { int index = bits (insn, 0, 5); return mips_spec3_opcodes[index].func (cpu, insn); } static int bshfl_op (cpu_mips_t * cpu, mips_insn_t insn) { int rt = bits (insn, 16, 20); int rd = bits (insn, 11, 15); int sa = bits (insn, 6, 10); //printf ("seh rt=%d, rd=%d, sa=%x\n", rt, rd, sa); switch (sa) { case 0x02: /* wsbh - word swap bytes within halfwords */ cpu->reg_set (cpu, rd, bits (cpu->gpr[rt], 16, 23) << 24 | bits (cpu->gpr[rt], 24, 31) << 16 | bits (cpu->gpr[rt], 0, 7) << 8 | bits (cpu->gpr[rt], 8, 15)); return (0); case 0x10: /* seb - sign extend byte */ cpu->reg_set (cpu, rd, sign_extend (cpu->gpr[rt], 8)); return (0); case 0x18: /* seh - sign extend halfword */ cpu->reg_set (cpu, rd, sign_extend (cpu->gpr[rt], 16)); return (0); } return unknown_op (cpu, insn); } static int ext_op (cpu_mips_t * cpu, mips_insn_t insn) { int rs = bits (insn, 21, 25); int rt = bits (insn, 16, 20); int msbd = bits (insn, 11, 15); int lsb = bits (insn, 6, 10); /* Extract bit field */ cpu->reg_set (cpu, rt, (cpu->gpr[rs] >> lsb) & (~0U >> (31 - msbd))); return (0); } static int ins_op (cpu_mips_t * cpu, mips_insn_t insn) { int rs = bits (insn, 21, 25); int rt = bits (insn, 16, 20); int msb = bits (insn, 11, 15); int lsb = bits (insn, 6, 10); /* Insert bit field */ int mask = ~0U >> (31-msb+lsb) << lsb; cpu->gpr[rt] &= ~mask; cpu->gpr[rt] |= (cpu->gpr[rs] << lsb) & mask; return (0); } static int spec2_op (cpu_mips_t * cpu, mips_insn_t insn) { int index = bits (insn, 0, 5); return mips_spec2_opcodes[index].func (cpu, insn); } static int madd_op (cpu_mips_t * cpu, mips_insn_t insn) { int rs = bits (insn, 21, 25); int rt = bits (insn, 16, 20); m_int64_t val, temp; val = (m_int32_t) (m_int32_t) cpu->gpr[rs]; val *= (m_int32_t) (m_int32_t) cpu->gpr[rt]; temp = cpu->hi; temp = temp << 32; temp += cpu->lo; val += temp; cpu->lo = sign_extend (val, 32); cpu->hi = sign_extend (val >> 32, 32); return (0); } static int maddu_op (cpu_mips_t * cpu, mips_insn_t insn) { int rs = bits (insn, 21, 25); int rt = bits (insn, 16, 20); m_int64_t val, temp; val = (m_uint32_t) (m_uint32_t) cpu->gpr[rs]; val *= (m_uint32_t) (m_uint32_t) cpu->gpr[rt]; temp = cpu->hi; temp = temp << 32; temp += cpu->lo; val += temp; cpu->lo = sign_extend (val, 32); cpu->hi = sign_extend (val >> 32, 32); return (0); } static int mfc0_op (cpu_mips_t * cpu, mips_insn_t insn) { int rt = bits (insn, 16, 20); int rd = bits (insn, 11, 15); int sel = bits (insn, 0, 2); //mfc rt,rd mips_cp0_exec_mfc0 (cpu, rt, rd, sel); return (0); } static int mfhi_op (cpu_mips_t * cpu, mips_insn_t insn) { int rd = bits (insn, 11, 15); if (rd) cpu->reg_set (cpu, rd, cpu->hi); return (0); } static int mflo_op (cpu_mips_t * cpu, mips_insn_t insn) { int rd = bits (insn, 11, 15); if (rd) cpu->reg_set (cpu, rd, cpu->lo); return (0); } static int movc_op (cpu_mips_t * cpu, mips_insn_t insn) { if (! (cpu->cp0.reg [MIPS_CP0_STATUS] & MIPS_CP0_STATUS_CU1)) { return cop_unusable (cpu, 1); } return unknown_op (cpu, insn); } static int movz_op (cpu_mips_t * cpu, mips_insn_t insn) { int rs = bits (insn, 21, 25); int rd = bits (insn, 11, 15); int rt = bits (insn, 16, 20); if ((cpu->gpr[rt]) == 0) cpu->reg_set (cpu, rd, sign_extend (cpu->gpr[rs], 32)); return (0); } static int movn_op (cpu_mips_t * cpu, mips_insn_t insn) { int rs = bits (insn, 21, 25); int rd = bits (insn, 11, 15); int rt = bits (insn, 16, 20); // printf("pc %x rs %x rd %x rt %x\n",cpu->pc,rs,rd,rt); if ((cpu->gpr[rt]) != 0) cpu->reg_set (cpu, rd, sign_extend (cpu->gpr[rs], 32)); return (0); } static int msub_op (cpu_mips_t * cpu, mips_insn_t insn) { int rs = bits (insn, 21, 25); int rt = bits (insn, 16, 20); m_int64_t val, temp; val = (m_int32_t) (m_int32_t) cpu->gpr[rs]; val *= (m_int32_t) (m_int32_t) cpu->gpr[rt]; temp = cpu->hi; temp = temp << 32; temp += cpu->lo; temp -= val; //val += temp; cpu->lo = sign_extend (temp, 32); cpu->hi = sign_extend (temp >> 32, 32); return (0); } static int msubu_op (cpu_mips_t * cpu, mips_insn_t insn) { int rs = bits (insn, 21, 25); int rt = bits (insn, 16, 20); m_int64_t val, temp; val = (m_uint32_t) (m_uint32_t) cpu->gpr[rs]; val *= (m_uint32_t) (m_uint32_t) cpu->gpr[rt]; temp = cpu->hi; temp = temp << 32; temp += cpu->lo; temp -= val; //val += temp; cpu->lo = sign_extend (temp, 32); cpu->hi = sign_extend (temp >> 32, 32); return (0); } static int mtc0_op (cpu_mips_t * cpu, mips_insn_t insn) { int rt = bits (insn, 16, 20); int rd = bits (insn, 11, 15); int sel = bits (insn, 0, 2); //printf("cpu->pc %x insn %x\n",cpu->pc,insn); mips_cp0_exec_mtc0 (cpu, rt, rd, sel); return (0); } static int mthi_op (cpu_mips_t * cpu, mips_insn_t insn) { int rs = bits (insn, 21, 25); cpu->hi = cpu->gpr[rs]; return (0); } static int mtlo_op (cpu_mips_t * cpu, mips_insn_t insn) { int rs = bits (insn, 21, 25); cpu->lo = cpu->gpr[rs]; return (0); } static int mul_op (cpu_mips_t * cpu, mips_insn_t insn) { int rs = bits (insn, 21, 25); int rt = bits (insn, 16, 20); int rd = bits (insn, 11, 15); m_int32_t val; /* note: after this instruction, HI/LO regs are undefined */ val = (m_int32_t) cpu->gpr[rs] * (m_int32_t) cpu->gpr[rt]; cpu->reg_set (cpu, rd, sign_extend (val, 32)); return (0); } static int mult_op (cpu_mips_t * cpu, mips_insn_t insn) { int rs = bits (insn, 21, 25); int rt = bits (insn, 16, 20); m_int64_t val; val = (m_int64_t) (m_int32_t) cpu->gpr[rs]; val *= (m_int64_t) (m_int32_t) cpu->gpr[rt]; cpu->lo = sign_extend (val, 32); cpu->hi = sign_extend (val >> 32, 32); return (0); } static int multu_op (cpu_mips_t * cpu, mips_insn_t insn) { int rs = bits (insn, 21, 25); int rt = bits (insn, 16, 20); m_int64_t val; //must be 64 bit. not m_reg_t !!! val = (m_reg_t) (m_uint32_t) cpu->gpr[rs]; val *= (m_reg_t) (m_uint32_t) cpu->gpr[rt]; cpu->lo = sign_extend (val, 32); cpu->hi = sign_extend (val >> 32, 32); return (0); } static int nor_op (cpu_mips_t * cpu, mips_insn_t insn) { int rs = bits (insn, 21, 25); int rt = bits (insn, 16, 20); int rd = bits (insn, 11, 15); cpu->reg_set (cpu, rd, ~(cpu->gpr[rs] | cpu->gpr[rt])); return (0); } static int or_op (cpu_mips_t * cpu, mips_insn_t insn) { int rs = bits (insn, 21, 25); int rt = bits (insn, 16, 20); int rd = bits (insn, 11, 15); cpu->reg_set (cpu, rd, cpu->gpr[rs] | cpu->gpr[rt]); return (0); } static int ori_op (cpu_mips_t * cpu, mips_insn_t insn) { int rs = bits (insn, 21, 25); int rt = bits (insn, 16, 20); int imm = bits (insn, 0, 15); cpu->reg_set (cpu, rt, cpu->gpr[rs] | imm); return (0); } static int pref_op (cpu_mips_t * cpu, mips_insn_t insn) { return (0); } static int sb_op (cpu_mips_t * cpu, mips_insn_t insn) { int base = bits (insn, 21, 25); int rt = bits (insn, 16, 20); int offset = bits (insn, 0, 15); return (mips_exec_memop2 (cpu, MIPS_MEMOP_SB, base, offset, rt, FALSE)); } static int sc_op (cpu_mips_t * cpu, mips_insn_t insn) { int base = bits (insn, 21, 25); int rt = bits (insn, 16, 20); int offset = bits (insn, 0, 15); return (mips_exec_memop2 (cpu, MIPS_MEMOP_SC, base, offset, rt, TRUE)); } static int sh_op (cpu_mips_t * cpu, mips_insn_t insn) { int base = bits (insn, 21, 25); int rt = bits (insn, 16, 20); int offset = bits (insn, 0, 15); return (mips_exec_memop2 (cpu, MIPS_MEMOP_SH, base, offset, rt, FALSE)); } static int sll_op (cpu_mips_t * cpu, mips_insn_t insn) { int rt = bits (insn, 16, 20); int rd = bits (insn, 11, 15); int sa = bits (insn, 6, 10); m_uint32_t res; res = (m_uint32_t) cpu->gpr[rt] << sa; cpu->reg_set (cpu, rd, sign_extend (res, 32)); return (0); } static int sllv_op (cpu_mips_t * cpu, mips_insn_t insn) { int rs = bits (insn, 21, 25); int rt = bits (insn, 16, 20); int rd = bits (insn, 11, 15); m_uint32_t res; res = (m_uint32_t) cpu->gpr[rt] << (cpu->gpr[rs] & 0x1f); cpu->reg_set (cpu, rd, sign_extend (res, 32)); return (0); } static int slt_op (cpu_mips_t * cpu, mips_insn_t insn) { int rs = bits (insn, 21, 25); int rt = bits (insn, 16, 20); int rd = bits (insn, 11, 15); if ((m_ireg_t) cpu->gpr[rs] < (m_ireg_t) cpu->gpr[rt]) cpu->reg_set (cpu, rd, 1); else cpu->reg_set (cpu, rd, 0); return (0); } static int slti_op (cpu_mips_t * cpu, mips_insn_t insn) { int rs = bits (insn, 21, 25); int rt = bits (insn, 16, 20); int imm = bits (insn, 0, 15); m_ireg_t val = sign_extend (imm, 16); if ((m_ireg_t) cpu->gpr[rs] < val) cpu->reg_set (cpu, rt, 1); else cpu->reg_set (cpu, rt, 0); return (0); } static int sltiu_op (cpu_mips_t * cpu, mips_insn_t insn) { int rs = bits (insn, 21, 25); int rt = bits (insn, 16, 20); int imm = bits (insn, 0, 15); m_reg_t val = sign_extend (imm, 16); if (rs == 0 && rt == 0 && cpu->magic_opcodes) { if (imm == 0xabc1) { printf ("%08x: Test FAIL\n", cpu->pc); printf ("\n--- Stop simulation\n"); fprintf (stderr, "Test FAIL\n"); exit (EXIT_SUCCESS); } if (imm == 0xabc2) { printf ("%08x: Test PASS\n", cpu->pc); printf ("\n--- Stop simulation\n"); fprintf (stderr, "Test PASS\n"); exit (EXIT_SUCCESS); } } if (cpu->gpr[rs] < val) cpu->reg_set (cpu, rt, 1); else cpu->reg_set (cpu, rt, 0); return (0); } static int sltu_op (cpu_mips_t * cpu, mips_insn_t insn) { int rs = bits (insn, 21, 25); int rt = bits (insn, 16, 20); int rd = bits (insn, 11, 15); if (cpu->gpr[rs] < cpu->gpr[rt]) cpu->reg_set (cpu, rd, 1); else cpu->reg_set (cpu, rd, 0); return (0); } static int spec_op (cpu_mips_t * cpu, mips_insn_t insn) { uint16_t special_func = bits (insn, 0, 5); return mips_spec_opcodes[special_func].func (cpu, insn); } static int sra_op (cpu_mips_t * cpu, mips_insn_t insn) { int rt = bits (insn, 16, 20); int rd = bits (insn, 11, 15); int sa = bits (insn, 6, 10); m_int32_t res; res = (m_int32_t) cpu->gpr[rt] >> sa; cpu->reg_set (cpu, rd, sign_extend (res, 32)); return (0); } static int srav_op (cpu_mips_t * cpu, mips_insn_t insn) { int rs = bits (insn, 21, 25); int rt = bits (insn, 16, 20); int rd = bits (insn, 11, 15); m_int32_t res; res = (m_int32_t) cpu->gpr[rt] >> (cpu->gpr[rs] & 0x1f); cpu->reg_set (cpu, rd, sign_extend (res, 32)); return (0); } static int srl_op (cpu_mips_t * cpu, mips_insn_t insn) { int rt = bits (insn, 16, 20); int rd = bits (insn, 11, 15); int sa = bits (insn, 6, 10); m_uint32_t res; /* srl */ res = (m_uint32_t) cpu->gpr[rt] >> sa; if ((insn >> 21) & 1) { /* rotr */ res |= (m_uint32_t) cpu->gpr[rt] << (32 - sa); } cpu->reg_set (cpu, rd, sign_extend (res, 32)); return (0); } static int srlv_op (cpu_mips_t * cpu, mips_insn_t insn) { int rs = bits (insn, 21, 25); int rt = bits (insn, 16, 20); int rd = bits (insn, 11, 15); m_uint32_t res, sa; /* srlv */ sa = cpu->gpr[rs] & 0x1f; res = (m_uint32_t) cpu->gpr[rt] >> sa; if ((insn >> 6) & 1) { /* rotrv */ res |= (m_uint32_t) cpu->gpr[rt] << (32 - sa); } cpu->reg_set (cpu, rd, sign_extend (res, 32)); return (0); } static int sub_op (cpu_mips_t * cpu, mips_insn_t insn) { int rs = bits (insn, 21, 25); int rt = bits (insn, 16, 20); int rd = bits (insn, 11, 15); m_ireg_t a = cpu->gpr[rs]; m_ireg_t b = cpu->gpr[rt]; m_ireg_t res = a - b; if ((a > 0 && b < 0 && res < 0) || (a < 0 && b > 0 && res >= 0)) { /* Take overflow exception. */ mips_trigger_exception (cpu, MIPS_CP0_CAUSE_OVFLW, cpu->is_in_bdslot); return 1; } cpu->reg_set (cpu, rd, sign_extend (res, 32)); return (0); } static int subu_op (cpu_mips_t * cpu, mips_insn_t insn) { int rs = bits (insn, 21, 25); int rt = bits (insn, 16, 20); int rd = bits (insn, 11, 15); m_uint32_t res; res = (m_uint32_t) cpu->gpr[rs] - (m_uint32_t) cpu->gpr[rt]; cpu->reg_set (cpu, rd, sign_extend (res, 32)); return (0); } static int sw_op (cpu_mips_t * cpu, mips_insn_t insn) { int base = bits (insn, 21, 25); int rt = bits (insn, 16, 20); int offset = bits (insn, 0, 15); return (mips_exec_memop2 (cpu, MIPS_MEMOP_SW, base, offset, rt, FALSE)); } static int swl_op (cpu_mips_t * cpu, mips_insn_t insn) { int base = bits (insn, 21, 25); int rt = bits (insn, 16, 20); int offset = bits (insn, 0, 15); return (mips_exec_memop2 (cpu, MIPS_MEMOP_SWL, base, offset, rt, FALSE)); } static int swr_op (cpu_mips_t * cpu, mips_insn_t insn) { int base = bits (insn, 21, 25); int rt = bits (insn, 16, 20); int offset = bits (insn, 0, 15); return (mips_exec_memop2 (cpu, MIPS_MEMOP_SWR, base, offset, rt, FALSE)); } static int sync_op (cpu_mips_t * cpu, mips_insn_t insn) { return (0); } static int syscall_op (cpu_mips_t * cpu, mips_insn_t insn) { mips_exec_syscall (cpu); return (1); } static int teq_op (cpu_mips_t * cpu, mips_insn_t insn) { int rs = bits (insn, 21, 25); int rt = bits (insn, 16, 20); if (unlikely (cpu->gpr[rs] == cpu->gpr[rt])) { mips_trigger_trap_exception (cpu); return (1); } return (0); } static int teqi_op (cpu_mips_t * cpu, mips_insn_t insn) { int rs = bits (insn, 21, 25); int imm = bits (insn, 0, 15); m_reg_t val = sign_extend (imm, 16); if (unlikely (cpu->gpr[rs] == val)) { mips_trigger_trap_exception (cpu); return (1); } return (0); } /* * DI and EI instructions */ static int mfmc0_op (cpu_mips_t * cpu, mips_insn_t insn) { int rt = bits (insn, 16, 20); int rd = bits (insn, 11, 15); int func = bits (insn, 0, 10); if (rd == 12) { switch (func) { case 0x020: /* ei - enable interrupts */ cpu->reg_set (cpu, rt, cpu->cp0.reg [MIPS_CP0_STATUS]); cpu->cp0.reg [MIPS_CP0_STATUS] |= MIPS_CP0_STATUS_IE; return 0; case 0x000: /* di - disable interrupts */ cpu->reg_set (cpu, rt, cpu->cp0.reg [MIPS_CP0_STATUS]); cpu->cp0.reg [MIPS_CP0_STATUS] &= ~MIPS_CP0_STATUS_IE; return 0; } } return unknown_op (cpu, insn); } static int tlb_op (cpu_mips_t * cpu, mips_insn_t insn) { uint16_t func = bits (insn, 0, 5); return mips_tlb_opcodes[func].func (cpu, insn); } static int tlbp_op (cpu_mips_t * cpu, mips_insn_t insn) { mips_cp0_exec_tlbp (cpu); return (0); } static int tlbr_op (cpu_mips_t * cpu, mips_insn_t insn) { mips_cp0_exec_tlbr (cpu); return (0); } static int tlbwi_op (cpu_mips_t * cpu, mips_insn_t insn) { mips_cp0_exec_tlbwi (cpu); return (0); } static int tlbwr_op (cpu_mips_t * cpu, mips_insn_t insn) { mips_cp0_exec_tlbwr (cpu); return (0); } static int tge_op (cpu_mips_t * cpu, mips_insn_t insn) { int rs = bits (insn, 21, 25); int rt = bits (insn, 16, 20); if ((m_ireg_t) cpu->gpr[rs] >= (m_ireg_t) cpu->gpr[rt]) { mips_trigger_trap_exception (cpu); return (1); } return (0); } static int tgei_op (cpu_mips_t * cpu, mips_insn_t insn) { int rs = bits (insn, 21, 25); m_ireg_t val = sign_extend (bits (insn, 0, 15), 16); if (unlikely ((m_ireg_t) cpu->gpr[rs] >= val)) { mips_trigger_trap_exception (cpu); return (1); } return (0); } static int tgeiu_op (cpu_mips_t * cpu, mips_insn_t insn) { int rs = bits (insn, 21, 25); m_reg_t val = sign_extend (bits (insn, 0, 15), 16); if (unlikely ((m_reg_t) cpu->gpr[rs] >= val)) { mips_trigger_trap_exception (cpu); return (1); } return (0); } static int tgeu_op (cpu_mips_t * cpu, mips_insn_t insn) { int rs = bits (insn, 21, 25); int rt = bits (insn, 16, 20); if ((m_reg_t) cpu->gpr[rs] >= (m_reg_t) cpu->gpr[rt]) { mips_trigger_trap_exception (cpu); return (1); } return (0); } static int tlt_op (cpu_mips_t * cpu, mips_insn_t insn) { int rs = bits (insn, 21, 25); int rt = bits (insn, 16, 20); if ((m_ireg_t) cpu->gpr[rs] < (m_ireg_t) cpu->gpr[rt]) { mips_trigger_trap_exception (cpu); return (1); } return (0); } static int tlti_op (cpu_mips_t * cpu, mips_insn_t insn) { int rs = bits (insn, 21, 25); m_ireg_t val = sign_extend (bits (insn, 0, 15), 16); if (unlikely ((m_ireg_t) cpu->gpr[rs] < val)) { mips_trigger_trap_exception (cpu); return (1); } return (0); } static int tltiu_op (cpu_mips_t * cpu, mips_insn_t insn) { int rs = bits (insn, 21, 25); m_reg_t val = sign_extend (bits (insn, 0, 15), 16); if (unlikely ((m_reg_t) cpu->gpr[rs] < val)) { mips_trigger_trap_exception (cpu); return (1); } return (0); } static int tltu_op (cpu_mips_t * cpu, mips_insn_t insn) { int rs = bits (insn, 21, 25); int rt = bits (insn, 16, 20); if ((m_reg_t) cpu->gpr[rs] < (m_reg_t) cpu->gpr[rt]) { mips_trigger_trap_exception (cpu); return (1); } return (0); } static int tne_op (cpu_mips_t * cpu, mips_insn_t insn) { int rs = bits (insn, 21, 25); int rt = bits (insn, 16, 20); if ((m_ireg_t) cpu->gpr[rs] != (m_ireg_t) cpu->gpr[rt]) { mips_trigger_trap_exception (cpu); return (1); } return (0); } static int tnei_op (cpu_mips_t * cpu, mips_insn_t insn) { int rs = bits (insn, 21, 25); m_reg_t val = sign_extend (bits (insn, 0, 15), 16); if (unlikely (cpu->gpr[rs] != val)) { mips_trigger_trap_exception (cpu); return (1); } return (0); } static int wait_op (cpu_mips_t * cpu, mips_insn_t insn) { if (! (cpu->cp0.reg [MIPS_CP0_STATUS] & MIPS_CP0_STATUS_IE)) { /* Wait instruction with interrupts disabled - stop the simulator. */ printf ("%08x: wait instruction with interrupts disabled - stop the simulator.\n", cpu->pc); kill (0, SIGQUIT); } usleep (1000); return (0); } static int xor_op (cpu_mips_t * cpu, mips_insn_t insn) { int rs = bits (insn, 21, 25); int rt = bits (insn, 16, 20); int rd = bits (insn, 11, 15); cpu->reg_set (cpu, rd, cpu->gpr[rs] ^ cpu->gpr[rt]); return (0); } static int rdpgpr_op (cpu_mips_t * cpu, mips_insn_t insn) { int rt = bits (insn, 16, 20); int rd = bits (insn, 11, 15); printf ("%08x: unsupported RDPGPR $%u,$%u instruction.\n", cpu->pc, rd, rt); return (0); } static int wrpgpr_op (cpu_mips_t * cpu, mips_insn_t insn) { int rt = bits (insn, 16, 20); int rd = bits (insn, 11, 15); printf ("%08x: unsupported WRPGPR $%u,$%u instruction.\n", cpu->pc, rd, rt); return (0); } static int xori_op (cpu_mips_t * cpu, mips_insn_t insn) { int rs = bits (insn, 21, 25); int rt = bits (insn, 16, 20); int imm = bits (insn, 0, 15); cpu->reg_set (cpu, rt, cpu->gpr[rs] ^ imm); return (0); } static int sdbbp_op (cpu_mips_t * cpu, mips_insn_t insn) { /* Clear status of previos Debug exception. */ cpu->cp0.reg[MIPS_CP0_DEBUG] &= ~MIPS_CP0_DEBUG_DEXCCODE; if (cpu->cp0.reg[MIPS_CP0_DEBUG] & MIPS_CP0_DEBUG_DM) { /* Already in Debug mode: take nested debug exception. */ mips_trigger_debug_exception (cpu, 0); /* Set nested exception type. */ cpu->cp0.reg[MIPS_CP0_DEBUG] |= MIPS_CP0_CAUSE_BP << MIPS_CP0_DEBUG_DEXCCODE_SHIFT; } else { /* Take a Breakpoint exception. */ mips_trigger_debug_exception (cpu, MIPS_CP0_DEBUG_DBP); } return 1; } static int undef_op (cpu_mips_t * cpu, mips_insn_t insn) { return unknown_op (cpu, insn); } static int undef_bcond (cpu_mips_t * cpu, mips_insn_t insn) { return unknown_op (cpu, insn); } static int undef_cop0 (cpu_mips_t * cpu, mips_insn_t insn) { return unknown_op (cpu, insn); } static int undef_spec2 (cpu_mips_t * cpu, mips_insn_t insn) { return unknown_op (cpu, insn); } static int undef_spec3 (cpu_mips_t * cpu, mips_insn_t insn) { return unknown_op (cpu, insn); } static int undef_spec (cpu_mips_t * cpu, mips_insn_t insn) { return unknown_op (cpu, insn); } static int undef_tlb (cpu_mips_t * cpu, mips_insn_t insn) { return unknown_op (cpu, insn); } /* * Main instruction table, indexed by bits 31:26 of opcode. */ static const struct mips_op_desc mips_opcodes[] = { {"spec", spec_op, 0x00}, /* indexed by FUNC field */ {"bcond", bcond_op, 0x01}, /* indexed by RT field */ {"j", j_op, 0x02}, {"jal", jal_op, 0x03}, {"beq", beq_op, 0x04}, {"bne", bne_op, 0x05}, {"blez", blez_op, 0x06}, {"bgtz", bgtz_op, 0x07}, {"addi", addi_op, 0x08}, {"addiu", addiu_op, 0x09}, {"slti", slti_op, 0x0A}, {"sltiu", sltiu_op, 0x0B}, {"andi", andi_op, 0x0C}, {"ori", ori_op, 0x0D}, {"xori", xori_op, 0x0E}, {"lui", lui_op, 0x0F}, {"cop0", cop0_op, 0x10}, /* indexed by RS field */ {"cop1", cop1_op, 0x11}, {"cop2", cop2_op, 0x12}, {"cop1x", cop1_op, 0x13}, {"beql", beql_op, 0x14}, {"bnel", bnel_op, 0x15}, {"blezl", blezl_op, 0x16}, {"bgtzl", bgtzl_op, 0x17}, {"daddi", unknown_op, 0x18}, {"daddiu", unknown_op, 0x19}, {"ldl", unknown_op, 0x1A}, {"ldr", unknown_op, 0x1B}, {"spec2", spec2_op, 0x1C}, /* indexed by FUNC field */ {"jalx", jalx_op, 0x1D}, {"undef", undef_op, 0x1E}, {"spec3", spec3_op, 0x1F}, /* indexed by FUNC field */ {"lb", lb_op, 0x20}, {"lh", lh_op, 0x21}, {"lwl", lwl_op, 0x22}, {"lw", lw_op, 0x23}, {"lbu", lbu_op, 0x24}, {"lhu", lhu_op, 0x25}, {"lwr", lwr_op, 0x26}, {"lwu", unknown_op, 0x27}, {"sb", sb_op, 0x28}, {"sh", sh_op, 0x29}, {"swl", swl_op, 0x2A}, {"sw", sw_op, 0x2B}, {"sdl", unknown_op, 0x2C}, {"sdr", unknown_op, 0x2D}, {"swr", swr_op, 0x2E}, {"cache", cache_op, 0x2F}, {"ll", ll_op, 0x30}, {"lwc1", cop1_op, 0x31}, {"lwc2", cop2_op, 0x32}, {"pref", pref_op, 0x33}, {"lld", unknown_op, 0x34}, {"ldc1", cop1_op, 0x35}, {"ldc2", cop2_op, 0x36}, {"ld", unknown_op, 0x37}, {"sc", sc_op, 0x38}, {"swc1", cop1_op, 0x39}, {"swc2", cop2_op, 0x3A}, {"undef", undef_op, 0x3B}, {"scd", unknown_op, 0x3C}, {"sdc1", cop1_op, 0x3D}, {"sdc2", cop2_op, 0x3E}, {"sd", unknown_op, 0x3F}, }; /* * SPEC opcode: indexed by FUNC field. */ static const struct mips_op_desc mips_spec_opcodes[] = { {"sll", sll_op, 0x00}, {"movc", movc_op, 0x01}, {"srl", srl_op, 0x02}, {"sra", sra_op, 0x03}, {"sllv", sllv_op, 0x04}, {"?spec", undef_spec, 0x05}, {"srlv", srlv_op, 0x06}, {"srav", srav_op, 0x07}, {"jr", jr_op, 0x08}, {"jalr", jalr_op, 0x09}, {"movz", movz_op, 0x0A}, {"movn", movn_op, 0x0B}, {"syscall", syscall_op, 0x0C}, {"break", break_op, 0x0D}, {"spim", undef_spec, 0x0E}, {"sync", sync_op, 0x0F}, {"mfhi", mfhi_op, 0x10}, {"mthi", mthi_op, 0x11}, {"mflo", mflo_op, 0x12}, {"mtlo", mtlo_op, 0x13}, {"dsllv", unknown_op, 0x14}, {"?spec", undef_spec, 0x15}, {"dsrlv", unknown_op, 0x16}, {"dsrav", unknown_op, 0x17}, {"mult", mult_op, 0x18}, {"multu", multu_op, 0x19}, {"div", div_op, 0x1A}, {"divu", divu_op, 0x1B}, {"dmult", unknown_op, 0x1C}, {"dmultu", unknown_op, 0x1D}, {"ddiv", unknown_op, 0x1E}, {"ddivu", unknown_op, 0x1F}, {"add", add_op, 0x20}, {"addu", addu_op, 0x21}, {"sub", sub_op, 0x22}, {"subu", subu_op, 0x23}, {"and", and_op, 0x24}, {"or", or_op, 0x25}, {"xor", xor_op, 0x26}, {"nor", nor_op, 0x27}, {"?spec", undef_spec, 0x28}, {"?spec", undef_spec, 0x29}, {"slt", slt_op, 0x2A}, {"sltu", sltu_op, 0x2B}, {"dadd", unknown_op, 0x2C}, {"daddu", unknown_op, 0x2D}, {"dsub", unknown_op, 0x2E}, {"dsubu", unknown_op, 0x2F}, {"tge", tge_op, 0x30}, {"tgeu", tgeu_op, 0x31}, {"tlt", tlt_op, 0x32}, {"tltu", tltu_op, 0x33}, {"teq", teq_op, 0x34}, {"?spec", undef_spec, 0x35}, {"tne", tne_op, 0x36}, {"?spec", undef_spec, 0x37}, {"dsll", unknown_op, 0x38}, {"?spec", undef_spec, 0x39}, {"dsrl", unknown_op, 0x3A}, {"dsra", unknown_op, 0x3B}, {"dsll32", unknown_op, 0x3C}, {"?spec", undef_spec, 0x3D}, {"dsrl32", unknown_op, 0x3E}, {"dsra32", unknown_op, 0x3F} }; /* * BCOND opcode: indexed by RT field. */ static const struct mips_op_desc mips_bcond_opcodes[] = { {"bltz", bltz_op, 0x00}, {"bgez", bgez_op, 0x01}, {"bltzl", bltzl_op, 0x02}, {"bgezl", bgezl_op, 0x03}, {"spimi", undef_bcond,0x04}, {"?bcond", undef_bcond,0x05}, {"?bcond", undef_bcond,0x06}, {"?bcond", undef_bcond,0x07}, {"tgei", tgei_op, 0x08}, {"tgeiu", tgeiu_op, 0x09}, {"tlti", tlti_op, 0x0A}, {"tltiu", tltiu_op, 0x0B}, {"teqi", teqi_op, 0x0C}, {"?bcond", undef_bcond,0x0D}, {"tnei", tnei_op, 0x0E}, {"?bcond", undef_bcond,0x0F}, {"bltzal", bltzal_op, 0x10}, {"bgezal", bgezal_op, 0x11}, {"bltzall", bltzall_op, 0x12}, {"bgezall", bgezall_op, 0x13}, {"?bcond", undef_bcond,0x14}, {"?bcond", undef_bcond,0x15}, {"?bcond", undef_bcond,0x16}, {"?bcond", undef_bcond,0x17}, {"?bcond", undef_bcond,0x18}, {"?bcond", undef_bcond,0x19}, {"?bcond", undef_bcond,0x1A}, {"?bcond", undef_bcond,0x1B}, {"?bcond", undef_bcond,0x1C}, {"?bcond", undef_bcond,0x1D}, {"?bcond", undef_bcond,0x1E}, {"?bcond", undef_bcond,0x1F} }; /* * COP0 opcode: indexed by RS field. */ static const struct mips_op_desc mips_cop0_opcodes[] = { {"mfc0", mfc0_op, 0x0}, {"dmfc0", unknown_op, 0x1}, {"cfc0", cfc0_op, 0x2}, {"?cop0", undef_cop0, 0x3}, {"mtc0", mtc0_op, 0x4}, {"dmtc0", unknown_op, 0x5}, {"?cop0", undef_cop0, 0x6}, {"?cop0", undef_cop0, 0x7}, {"?cop0", undef_cop0, 0x8}, {"?cop0", undef_cop0, 0x9}, {"?cop0", rdpgpr_op, 0xa}, {"?cop0", mfmc0_op, 0xb}, {"?cop0", undef_cop0, 0xc}, {"?cop0", undef_cop0, 0xd}, {"wrpgpr", wrpgpr_op, 0xe}, {"?cop0", undef_cop0, 0xf}, {"tlb", tlb_op, 0x10}, /* indexed by FUNC field */ {"?cop0", undef_cop0, 0x11}, {"?cop0", undef_cop0, 0x12}, {"?cop0", undef_cop0, 0x13}, {"?cop0", undef_cop0, 0x14}, {"?cop0", undef_cop0, 0x15}, {"?cop0", undef_cop0, 0x16}, {"?cop0", undef_cop0, 0x17}, {"?cop0", undef_cop0, 0x18}, {"?cop0", undef_cop0, 0x19}, {"?cop0", undef_cop0, 0x1a}, {"?cop0", undef_cop0, 0x1b}, {"?cop0", undef_cop0, 0x1c}, {"?cop0", undef_cop0, 0x1d}, {"?cop0", undef_cop0, 0x1e}, {"?cop0", undef_cop0, 0x1f}, }; /* * SPEC2 opcode: indexed by FUNC field. */ static const struct mips_op_desc mips_spec2_opcodes[] = { {"madd", madd_op, 0x0}, {"maddu", maddu_op, 0x1}, {"mul", mul_op, 0x2}, {"?spec2", undef_spec2,0x3}, {"msub", msub_op, 0x4}, {"msubu", msubu_op, 0x5}, {"?spec2", undef_spec2,0x6}, {"?spec2", undef_spec2,0x7}, {"?spec2", undef_spec2,0x8}, {"?spec2", undef_spec2,0x9}, {"?spec2", undef_spec2,0xa}, {"?spec2", undef_spec2,0xb}, {"?spec2", undef_spec2,0xc}, {"?spec2", undef_spec2,0xd}, {"?spec2", undef_spec2,0xe}, {"?spec2", undef_spec2,0xf}, {"?spec2", undef_spec2,0x10}, {"?spec2", undef_spec2,0x11}, {"?spec2", undef_spec2,0x12}, {"?spec2", undef_spec2,0x13}, {"?spec2", undef_spec2,0x14}, {"?spec2", undef_spec2,0x15}, {"?spec2", undef_spec2,0x16}, {"?spec2", undef_spec2,0x17}, {"?spec2", undef_spec2,0x18}, {"?spec2", undef_spec2,0x19}, {"?spec2", undef_spec2,0x1a}, {"?spec2", undef_spec2,0x1b}, {"?spec2", undef_spec2,0x1c}, {"?spec2", undef_spec2,0x1d}, {"?spec2", undef_spec2,0x1e}, {"?spec2", undef_spec2,0x1f}, {"clz", clz_op, 0x20}, {"clo", clo_op, 0x21}, {"?spec2", undef_spec2,0x22}, {"?spec2", undef_spec2,0x23}, {"?spec2", undef_spec2,0x24}, {"?spec2", undef_spec2,0x25}, {"?spec2", undef_spec2,0x26}, {"?spec2", undef_spec2,0x27}, {"?spec2", undef_spec2,0x28}, {"?spec2", undef_spec2,0x29}, {"?spec2", undef_spec2,0x2a}, {"?spec2", undef_spec2,0x2b}, {"?spec2", undef_spec2,0x2c}, {"?spec2", undef_spec2,0x2d}, {"?spec2", undef_spec2,0x2e}, {"?spec2", undef_spec2,0x2f}, {"?spec2", undef_spec2,0x30}, {"?spec2", undef_spec2,0x31}, {"?spec2", undef_spec2,0x32}, {"?spec2", undef_spec2,0x33}, {"?spec2", undef_spec2,0x34}, {"?spec2", undef_spec2,0x35}, {"?spec2", undef_spec2,0x36}, {"?spec2", undef_spec2,0x37}, {"?spec2", undef_spec2,0x38}, {"?spec2", undef_spec2,0x39}, {"?spec2", undef_spec2,0x3a}, {"?spec2", undef_spec2,0x3b}, {"?spec2", undef_spec2,0x3c}, {"?spec2", undef_spec2,0x3d}, {"?spec2", undef_spec2,0x3e}, {"sdbbp", sdbbp_op, 0x3f}, }; /* * SPEC3 opcode: indexed by FUNC field. */ static const struct mips_op_desc mips_spec3_opcodes[] = { {"ext", ext_op, 0x0}, {"?spec3", undef_spec3,0x1}, {"?spec3", undef_spec3,0x2}, {"?spec3", undef_spec3,0x3}, {"ins", ins_op, 0x4}, {"?spec3", undef_spec3,0x5}, {"?spec3", undef_spec3,0x6}, {"?spec3", undef_spec3,0x7}, {"?spec3", undef_spec3,0x8}, {"?spec3", undef_spec3,0x9}, {"?spec3", undef_spec3,0xa}, {"?spec3", undef_spec3,0xb}, {"?spec3", undef_spec3,0xc}, {"?spec3", undef_spec3,0xd}, {"?spec3", undef_spec3,0xe}, {"?spec3", undef_spec3,0xf}, {"?spec3", undef_spec3,0x10}, {"?spec3", undef_spec3,0x11}, {"?spec3", undef_spec3,0x12}, {"?spec3", undef_spec3,0x13}, {"?spec3", undef_spec3,0x14}, {"?spec3", undef_spec3,0x15}, {"?spec3", undef_spec3,0x16}, {"?spec3", undef_spec3,0x17}, {"?spec3", undef_spec3,0x18}, {"?spec3", undef_spec3,0x19}, {"?spec3", undef_spec3,0x1a}, {"?spec3", undef_spec3,0x1b}, {"?spec3", undef_spec3,0x1c}, {"?spec3", undef_spec3,0x1d}, {"?spec3", undef_spec3,0x1e}, {"?spec3", undef_spec3,0x1f}, {"bshfl", bshfl_op, 0x20}, {"?spec3", undef_spec3,0x21}, {"?spec3", undef_spec3,0x22}, {"?spec3", undef_spec3,0x23}, {"?spec3", undef_spec3,0x24}, {"?spec3", undef_spec3,0x25}, {"?spec3", undef_spec3,0x26}, {"?spec3", undef_spec3,0x27}, {"?spec3", undef_spec3,0x28}, {"?spec3", undef_spec3,0x29}, {"?spec3", undef_spec3,0x2a}, {"?spec3", undef_spec3,0x2b}, {"?spec3", undef_spec3,0x2c}, {"?spec3", undef_spec3,0x2d}, {"?spec3", undef_spec3,0x2e}, {"?spec3", undef_spec3,0x2f}, {"?spec3", undef_spec3,0x30}, {"?spec3", undef_spec3,0x31}, {"?spec3", undef_spec3,0x32}, {"?spec3", undef_spec3,0x33}, {"?spec3", undef_spec3,0x34}, {"?spec3", undef_spec3,0x35}, {"?spec3", undef_spec3,0x36}, {"?spec3", undef_spec3,0x37}, {"?spec3", undef_spec3,0x38}, {"?spec3", undef_spec3,0x39}, {"?spec3", undef_spec3,0x3a}, {"?spec3", undef_spec3,0x3b}, {"?spec3", undef_spec3,0x3c}, {"?spec3", undef_spec3,0x3d}, {"?spec3", undef_spec3,0x3e}, {"?spec3", undef_spec3,0x3f}, }; /* * TLB opcode: indexed by FUNC field. */ static const struct mips_op_desc mips_tlb_opcodes[] = { {"?tlb", undef_tlb, 0x0}, {"tlbr", tlbr_op, 0x1}, {"tlbwi", tlbwi_op, 0x2}, {"?tlb", undef_tlb, 0x3}, {"?tlb", undef_tlb, 0x4}, {"?tlb", undef_tlb, 0x5}, {"tlbwi", tlbwr_op, 0x6}, {"?tlb", undef_tlb, 0x7}, {"tlbp", tlbp_op, 0x8}, {"?tlb", undef_tlb, 0x9}, {"?tlb", undef_tlb, 0xa}, {"?tlb", undef_tlb, 0xb}, {"?tlb", undef_tlb, 0xc}, {"?tlb", undef_tlb, 0xd}, {"?tlb", undef_tlb, 0xe}, {"?tlb", undef_tlb, 0xf}, {"?tlb", undef_tlb, 0x10}, {"?tlb", undef_tlb, 0x11}, {"?tlb", undef_tlb, 0x12}, {"?tlb", undef_tlb, 0x13}, {"?tlb", undef_tlb, 0x14}, {"?tlb", undef_tlb, 0x15}, {"?tlb", undef_tlb, 0x16}, {"?tlb", undef_tlb, 0x17}, {"eret", eret_op, 0x18}, {"?tlb", undef_tlb, 0x19}, {"?tlb", undef_tlb, 0x1a}, {"?tlb", undef_tlb, 0x1b}, {"?tlb", undef_tlb, 0x1c}, {"?tlb", undef_tlb, 0x1d}, {"?tlb", undef_tlb, 0x1e}, {"deret", deret_op, 0x1f}, {"wait", wait_op, 0x20}, {"?tlb", undef_tlb, 0x21}, {"?tlb", undef_tlb, 0x22}, {"?tlb", undef_tlb, 0x23}, {"?tlb", undef_tlb, 0x24}, {"?tlb", undef_tlb, 0x25}, {"?tlb", undef_tlb, 0x26}, {"?tlb", undef_tlb, 0x27}, {"?tlb", undef_tlb, 0x28}, {"?tlb", undef_tlb, 0x29}, {"?tlb", undef_tlb, 0x2a}, {"?tlb", undef_tlb, 0x2b}, {"?tlb", undef_tlb, 0x2c}, {"?tlb", undef_tlb, 0x2d}, {"?tlb", undef_tlb, 0x2e}, {"?tlb", undef_tlb, 0x2f}, {"?tlb", undef_tlb, 0x30}, {"?tlb", undef_tlb, 0x31}, {"?tlb", undef_tlb, 0x32}, {"?tlb", undef_tlb, 0x33}, {"?tlb", undef_tlb, 0x34}, {"?tlb", undef_tlb, 0x35}, {"?tlb", undef_tlb, 0x36}, {"?tlb", undef_tlb, 0x37}, {"?tlb", undef_tlb, 0x38}, {"?tlb", undef_tlb, 0x39}, {"?tlb", undef_tlb, 0x3a}, {"?tlb", undef_tlb, 0x3b}, {"?tlb", undef_tlb, 0x3c}, {"?tlb", undef_tlb, 0x3d}, {"?tlb", undef_tlb, 0x3e}, {"?tlb", undef_tlb, 0x3f}, }; static int mips_exec_mips16e(cpu_mips_t* cpu, mips_insn_t instr) { mips_insn_t extend = instr >> 16; const m_va_t pc = cpu->pc; m_va_t nextPc = pc + cpu->insn_len; int res = 0; instr &= 0xFFFF; #define xlat(r) ((r) | (((r) - 2) & 16)) #define op (instr >> 11) #define imm2 (instr & 0x3) // RRR/SHIFT-funct #define imm3 (instr & 0x7) // MOV32R rz #define imm4 (instr & 0xF) // SVRS framesize #define simm4 (imm4 - ((instr & 0x8) << 1)) #define imm5 (instr & 0x1F) // MOVR32 r32 #define imm8 ((uint8_t)instr) #define simm8 ((int8_t)instr) #define imm11 (instr & 0x7FF) #define simm11 (imm11 - ((instr & 0x400) << 1)) #define imm15 (((extend & 0xF) << 11) | (extend & 0x7F0) | imm4) // EXT-RRI-A addiu #define simm15 (imm15 - ((extend & 0x8) << 12)) #define imm16 (((extend & 0x1F) << 11) | (extend & 0x7E0) | imm5) #define simm16 ((int16_t)imm16) #define imm26 (((extend & 0x1F) << 21) | ((extend & 0x3E0) << 11) | (uint16_t)instr) // jal(x) #define rx ((instr >> 8) & 0x7) // funct/SVRS #define ry ((instr >> 5) & 0x7) // RR-funct #define rz ((instr >> 2) & 0x7) // sa #define r32s ((instr & 0x18) | ((instr >> 5) & 0x7)) // MOV32R split/swapped r32 #define sa5 ((extend >> 6) & 0x1F) // EXT-SHIFT #define fmsz8 ((extend & 0xF0) | imm4) // EXT-SVRS #define aregs (extend & 0xF) // EXT-SVRS #define xsregs ((extend >> 8) & 0x7) // EXT-SVRS #define code6 ((instr >> 5) & 0x3F) // break, sdbbp if ((extend >> 11) == 3) { // jal(x) adr26<<2 (32-bit instruction; delay slot) cpu->reg_set(cpu, MIPS_GPR_RA, nextPc + 3); // 2 for non-extended instruction in delay slot + 1 for ISA Mode if (mips_exec_bdslot(cpu) == 0) { nextPc = (nextPc & 0xF0000000) | (imm26 << 2); cpu->pc = nextPc; cpu->is_mips16e = (extend & 0x400) == 0; // jalx switches to MIPS32 } res = 1; } else if (!extend) { switch (op) { case 0: // addiu[sp] rx, sp, imm8<<2 cpu->reg_set(cpu, xlat(rx), cpu->gpr[MIPS_GPR_SP] + (imm8 << 2)); break; case 1: // addiu[pc] rx, pc, imm8<<2 cpu->reg_set(cpu, xlat(rx), (pc + (imm8 << 2)) & 0xFFFFFFFC); break; case 2: // b ofs11<<1 (no delay slot) nextPc += simm11 << 1; cpu->pc = nextPc; res = 1; break; case 4: // beqz rx, ofs8<<1 (no delay slot) if (cpu->gpr[xlat(rx)] == 0) nextPc += simm8 << 1; cpu->pc = nextPc; res = 1; break; case 5: // bnez rx, ofs8<<1 (no delay slot) if (cpu->gpr[xlat(rx)] != 0) nextPc += simm8 << 1; cpu->pc = nextPc; res = 1; break; case 6: // SHIFT switch (imm2) { case 0: // sll rx, ry, imm3 cpu->reg_set(cpu, xlat(rx), cpu->gpr[xlat(ry)] << (rz | ((rz - 1) & 8))); break; case 2: // srl rx, ry, imm3 cpu->reg_set(cpu, xlat(rx), cpu->gpr[xlat(ry)] >> (rz | ((rz - 1) & 8))); break; case 3: // sra rx, ry, imm3 cpu->reg_set(cpu, xlat(rx), (int32_t)cpu->gpr[xlat(ry)] >> (rz | ((rz - 1) & 8))); break; default: goto lInvalidInstruction; } break; case 8: // RRI-A addiu ry, rx, simm4 if (unlikely(instr & 0x10)) goto lInvalidInstruction; cpu->reg_set(cpu, xlat(ry), cpu->gpr[xlat(rx)] + simm4); break; case 9: // addiu[8] rx, simm8 cpu->reg_set(cpu, xlat(rx), cpu->gpr[xlat(rx)] + simm8); break; case 10: // slti rx, imm8 cpu->reg_set(cpu, MIPS_GPR_T8, (int32_t)cpu->gpr[xlat(rx)] < (int32_t)imm8); break; case 11: // sltiu rx, imm8 cpu->reg_set(cpu, MIPS_GPR_T8, cpu->gpr[xlat(rx)] < imm8); break; case 12: // I8 switch (rx) { case 0: // bteqz ofs8<<1 (no delay slot) if (cpu->gpr[MIPS_GPR_T8] == 0) nextPc += simm8 << 1; cpu->pc = nextPc; res = 1; break; case 1: // btnez ofs8<<1 (no delay slot) if (cpu->gpr[MIPS_GPR_T8] != 0) nextPc += simm8 << 1; cpu->pc = nextPc; res = 1; break; case 2: // sw[rasp] ra, ofs8<<2(sp) res = mips_exec_memop2(cpu, MIPS_MEMOP_SW, MIPS_GPR_SP, imm8 << 2, MIPS_GPR_RA, FALSE); break; case 3: // ADJSP AKA addiu sp, simm8<<3 cpu->reg_set(cpu, MIPS_GPR_SP, cpu->gpr[MIPS_GPR_SP] + (simm8 << 3)); break; case 4: // SVRS if (instr & 0x80) { // save uint32_t temp = cpu->gpr[MIPS_GPR_SP], temp2 = temp - (imm4 ? imm4 * 8 : 128); if (instr & 0x40) // ra res = mips_exec_memop(cpu, MIPS_MEMOP_SW, temp -= 4, MIPS_GPR_RA, FALSE); if ((instr & 0x10) && !res) // s1 res = mips_exec_memop(cpu, MIPS_MEMOP_SW, temp -= 4, MIPS_GPR_S1, FALSE); if ((instr & 0x20) && !res) // s0 res = mips_exec_memop(cpu, MIPS_MEMOP_SW, temp -= 4, MIPS_GPR_S0, FALSE); if (!res) cpu->reg_set(cpu, MIPS_GPR_SP, temp2); } else { // restore uint32_t temp = cpu->gpr[MIPS_GPR_SP] + (imm4 ? imm4 * 8 : 128), temp2 = temp; if (instr & 0x40) // ra res = mips_exec_memop(cpu, MIPS_MEMOP_LW, temp -= 4, MIPS_GPR_RA, TRUE); if ((instr & 0x10) && !res) // s1 res = mips_exec_memop(cpu, MIPS_MEMOP_LW, temp -= 4, MIPS_GPR_S1, TRUE); if ((instr & 0x20) && !res) // s0 res = mips_exec_memop(cpu, MIPS_MEMOP_LW, temp -= 4, MIPS_GPR_S0, TRUE); if (!res) cpu->reg_set(cpu, MIPS_GPR_SP, temp2); } break; case 5: // move r32, rz (nop = move $0, $16) cpu->reg_set(cpu, r32s, cpu->gpr[xlat(imm3)]); cpu->gpr[0] = 0; break; case 7: // move ry, r32 cpu->reg_set(cpu, xlat(ry), cpu->gpr[imm5]); break; default: goto lInvalidInstruction; } break; case 13: // li rx, imm8 cpu->reg_set(cpu, xlat(rx), imm8); break; case 14: // cmpi rx, imm8 cpu->reg_set(cpu, MIPS_GPR_T8, cpu->gpr[xlat(rx)] ^ imm8); break; case 16: // lb ry, ofs5(rx) res = mips_exec_memop2(cpu, MIPS_MEMOP_LB, xlat(rx), imm5, xlat(ry), TRUE); break; case 17: // lh ry, ofs5<<1(rx) res = mips_exec_memop2(cpu, MIPS_MEMOP_LH, xlat(rx), imm5 << 1, xlat(ry), TRUE); break; case 18: // lw[sp] rx, ofs8<<2(sp) res = mips_exec_memop2(cpu, MIPS_MEMOP_LW, MIPS_GPR_SP, imm8 << 2, xlat(rx), TRUE); break; case 19: // lw ry, ofs5<<2(rx) res = mips_exec_memop2(cpu, MIPS_MEMOP_LW, xlat(rx), imm5 << 2, xlat(ry), TRUE); break; case 20: // lbu ry, ofs5(rx) res = mips_exec_memop2(cpu, MIPS_MEMOP_LBU, xlat(rx), imm5, xlat(ry), TRUE); break; case 21: // lhu ry, ofs5<<1(rx) res = mips_exec_memop2(cpu, MIPS_MEMOP_LHU, xlat(rx), imm5 << 1, xlat(ry), TRUE); break; case 22: // lw[pc] rx, ofs8<<2(pc) res = mips_exec_memop(cpu, MIPS_MEMOP_LW, (pc + (imm8 << 2)) & 0xFFFFFFFC, xlat(rx), TRUE); break; case 24: // sb ry, ofs5(rx) res = mips_exec_memop2(cpu, MIPS_MEMOP_SB, xlat(rx), imm5, xlat(ry), FALSE); break; case 25: // sh ry, ofs5<<1(rx) res = mips_exec_memop2(cpu, MIPS_MEMOP_SH, xlat(rx), imm5 << 1, xlat(ry), FALSE); break; case 26: // sw[sp] rx, ofs8<<2(sp) res = mips_exec_memop2(cpu, MIPS_MEMOP_SW, MIPS_GPR_SP, imm8 << 2, xlat(rx), FALSE); break; case 27: // sw ry, ofs5<<2(rx) res = mips_exec_memop2(cpu, MIPS_MEMOP_SW, xlat(rx), imm5 << 2, xlat(ry), FALSE); break; case 28: // RRR switch (imm2) { case 1: // addu rz, rx, ry cpu->reg_set(cpu, xlat(rz), cpu->gpr[xlat(rx)] + cpu->gpr[xlat(ry)]); break; case 3: // subu rz, rx, ry cpu->reg_set(cpu, xlat(rz), cpu->gpr[xlat(rx)] - cpu->gpr[xlat(ry)]); break; default: goto lInvalidInstruction; } break; case 29: // RR switch (imm5) { case 0: // J(AL)R(C) switch (ry) { case 0: // jr rx (delay slot) nextPc = cpu->gpr[xlat(rx)]; if (mips_exec_bdslot(cpu) == 0) { cpu->pc = nextPc & 0xFFFFFFFE; cpu->is_mips16e = nextPc & 1; // may switch to MIPS32 } res = 1; break; case 1: // jr ra (delay slot) if (unlikely(rx)) goto lInvalidInstruction; nextPc = cpu->gpr[MIPS_GPR_RA]; if (mips_exec_bdslot(cpu) == 0) { cpu->pc = nextPc & 0xFFFFFFFE; cpu->is_mips16e = nextPc & 1; // may switch to MIPS32 } res = 1; break; case 2: // jalr (delay slot) cpu->reg_set(cpu, MIPS_GPR_RA, nextPc + 3); // 2 for non-extended instruction in delay slot + 1 for ISA Mode nextPc = cpu->gpr[xlat(rx)]; if (mips_exec_bdslot(cpu) == 0) { cpu->pc = nextPc & 0xFFFFFFFE; cpu->is_mips16e = nextPc & 1; // may switch to MIPS32 } res = 1; break; case 4: // jrc rx (no delay slot) nextPc = cpu->gpr[xlat(rx)]; cpu->pc = nextPc & 0xFFFFFFFE; cpu->is_mips16e = nextPc & 1; // may switch to MIPS32 res = 1; break; case 5: // jrc ra (no delay slot) if (unlikely(rx)) goto lInvalidInstruction; nextPc = cpu->gpr[MIPS_GPR_RA]; cpu->pc = nextPc & 0xFFFFFFFE; cpu->is_mips16e = nextPc & 1; // may switch to MIPS32 res = 1; break; case 6: // jalrc (no delay slot) cpu->reg_set(cpu, MIPS_GPR_RA, nextPc + 1); // 1 for ISA Mode nextPc = cpu->gpr[xlat(rx)]; cpu->pc = nextPc & 0xFFFFFFFE; cpu->is_mips16e = nextPc & 1; // may switch to MIPS32 res = 1; break; default: goto lInvalidInstruction; } break; case 1: // sdbbp imm6 res = sdbbp_op(cpu, instr); break; case 2: // slt rx, ry cpu->reg_set(cpu, MIPS_GPR_T8, (int32_t)cpu->gpr[xlat(rx)] < (int32_t)cpu->gpr[xlat(ry)]); break; case 3: // sltu rx, ry cpu->reg_set(cpu, MIPS_GPR_T8, cpu->gpr[xlat(rx)] < cpu->gpr[xlat(ry)]); break; case 4: // sllv ry, rx cpu->reg_set(cpu, xlat(ry), cpu->gpr[xlat(ry)] << (cpu->gpr[xlat(rx)] & 31)); break; case 5: // break imm6 mips_exec_break(cpu, code6); res = 1; break; case 6: // srlv ry, rx cpu->reg_set(cpu, xlat(ry), cpu->gpr[xlat(ry)] >> (cpu->gpr[xlat(rx)] & 31)); break; case 7: // srav ry, rx cpu->reg_set(cpu, xlat(ry), (int32_t)cpu->gpr[xlat(ry)] >> (cpu->gpr[xlat(rx)] & 31)); break; case 10: // cmp rx, ry cpu->reg_set(cpu, MIPS_GPR_T8, cpu->gpr[xlat(rx)] ^ cpu->gpr[xlat(ry)]); break; case 11: // neg rx, ry cpu->reg_set(cpu, xlat(rx), -cpu->gpr[xlat(ry)]); break; case 12: // and rx, ry cpu->reg_set(cpu, xlat(rx), cpu->gpr[xlat(rx)] & cpu->gpr[xlat(ry)]); break; case 13: // or rx, ry cpu->reg_set(cpu, xlat(rx), cpu->gpr[xlat(rx)] | cpu->gpr[xlat(ry)]); break; case 14: // xor rx, ry cpu->reg_set(cpu, xlat(rx), cpu->gpr[xlat(rx)] ^ cpu->gpr[xlat(ry)]); break; case 15: // not rx, ry cpu->reg_set(cpu, xlat(rx), ~cpu->gpr[xlat(ry)]); break; case 16: // mfhi rx if (unlikely(ry)) goto lInvalidInstruction; cpu->reg_set(cpu, xlat(rx), cpu->hi); break; case 17: // CNVT switch (ry) { case 0: // zeb rx cpu->reg_set(cpu, xlat(rx), cpu->gpr[xlat(rx)] & 0xFF); break; case 1: // zeh rx cpu->reg_set(cpu, xlat(rx), cpu->gpr[xlat(rx)] & 0xFFFF); break; case 4: // seb rx cpu->reg_set(cpu, xlat(rx), (int8_t)cpu->gpr[xlat(rx)]); break; case 5: // seh rx cpu->reg_set(cpu, xlat(rx), (int16_t)cpu->gpr[xlat(rx)]); break; default: goto lInvalidInstruction; } break; case 18: // mflo rx if (unlikely(ry)) goto lInvalidInstruction; cpu->reg_set(cpu, xlat(rx), cpu->lo); break; case 24: { // mult rx, ry int64_t p = (int64_t)(int32_t)cpu->gpr[xlat(rx)] * (int32_t)cpu->gpr[xlat(ry)]; cpu->lo = (uint32_t)p; cpu->hi = (uint32_t)(p >> 32); } break; case 25: { // multu rx, ry uint64_t p = (uint64_t)cpu->gpr[xlat(rx)] * cpu->gpr[xlat(ry)]; cpu->lo = (uint32_t)p; cpu->hi = (uint32_t)(p >> 32); } break; case 26: // div rx, ry if (!(cpu->gpr[xlat(ry)] == 0 || (cpu->gpr[xlat(rx)] == 0x80000000 && cpu->gpr[xlat(ry)] == 0xFFFFFFFF))) { cpu->lo = (int32_t)cpu->gpr[xlat(rx)] / (int32_t)cpu->gpr[xlat(ry)]; cpu->hi = (int32_t)cpu->gpr[xlat(rx)] % (int32_t)cpu->gpr[xlat(ry)]; } break; case 27: // divu rx, ry if (cpu->gpr[xlat(ry)]) { cpu->lo = cpu->gpr[xlat(rx)] / cpu->gpr[xlat(ry)]; cpu->hi = cpu->gpr[xlat(rx)] % cpu->gpr[xlat(ry)]; } break; default: goto lInvalidInstruction; } break; default: goto lInvalidInstruction; } // ^^^ NON-EXTENDED ^^^ } else { // vvv EXTENDED vvv if (unlikely(cpu->is_in_bdslot)) goto lInvalidInstruction; switch (op) { case 0: // addiu[sp] rx, sp, simm16 if (unlikely(ry)) goto lInvalidInstruction; cpu->reg_set(cpu, xlat(rx), cpu->gpr[MIPS_GPR_SP] + simm16); break; case 1: // addiu[pc] rx, pc, simm16 if (unlikely(ry)) goto lInvalidInstruction; cpu->reg_set(cpu, xlat(rx), (pc & 0xFFFFFFFC) + simm16); break; case 2: // b ofs16<<1 (no delay slot) if (unlikely(instr & 0x7E0)) goto lInvalidInstruction; nextPc += simm16 << 1; cpu->pc = nextPc; res = 1; break; case 4: // beqz rx, ofs16<<1 (no delay slot) if (unlikely(ry)) goto lInvalidInstruction; if (cpu->gpr[xlat(rx)] == 0) nextPc += simm16 << 1; cpu->pc = nextPc; res = 1; break; case 5: // bnez rx, ofs16<<1 (no delay slot) if (unlikely(ry)) goto lInvalidInstruction; if (cpu->gpr[xlat(rx)] != 0) nextPc += simm16 << 1; cpu->pc = nextPc; res = 1; break; case 6: // SHIFT switch (imm2) { case 0: // sll rx, ry, imm5 if (unlikely((extend & 0x3F) | rz)) goto lInvalidInstruction; cpu->reg_set(cpu, xlat(rx), cpu->gpr[xlat(ry)] << sa5); break; case 2: // srl rx, ry, imm5 if (unlikely((extend & 0x3F) | rz)) goto lInvalidInstruction; cpu->reg_set(cpu, xlat(rx), cpu->gpr[xlat(ry)] >> sa5); break; case 3: // sra rx, ry, imm5 if (unlikely((extend & 0x3F) | rz)) goto lInvalidInstruction; cpu->reg_set(cpu, xlat(rx), (int32_t)cpu->gpr[xlat(ry)] >> sa5); break; default: goto lInvalidInstruction; } break; case 8: // RRI-A addiu ry, rx, simm15 if (unlikely(instr & 0x10)) goto lInvalidInstruction; cpu->reg_set(cpu, xlat(ry), cpu->gpr[xlat(rx)] + simm15); break; case 9: // addiu rx, simm16 if (unlikely(ry)) goto lInvalidInstruction; cpu->reg_set(cpu, xlat(rx), cpu->gpr[xlat(rx)] + simm16); break; case 10: // slti rx, simm16 if (unlikely(ry)) goto lInvalidInstruction; cpu->reg_set(cpu, MIPS_GPR_T8, (int32_t)cpu->gpr[xlat(rx)] < simm16); break; case 11: // sltiu rx, simm16 if (unlikely(ry)) goto lInvalidInstruction; cpu->reg_set(cpu, MIPS_GPR_T8, cpu->gpr[xlat(rx)] < (uint32_t)simm16); break; case 12: // I8 switch (rx) { case 0: // bteqz ofs16<<1 (no delay slot) if (unlikely(ry)) goto lInvalidInstruction; if (cpu->gpr[MIPS_GPR_T8] == 0) nextPc += simm16 << 1; cpu->pc = nextPc; res = 1; break; case 1: // btnez ofs16<<1 (no delay slot) if (unlikely(ry)) goto lInvalidInstruction; if (cpu->gpr[MIPS_GPR_T8] != 0) nextPc += simm16 << 1; cpu->pc = nextPc; res = 1; break; case 2: // sw[rasp] ra, ofs16(sp) if (unlikely(ry)) goto lInvalidInstruction; res = mips_exec_memop2(cpu, MIPS_MEMOP_SW, MIPS_GPR_SP, simm16, MIPS_GPR_RA, FALSE); break; case 3: // ADJSP AKA addiu sp, simm16 if (unlikely(ry)) goto lInvalidInstruction; cpu->reg_set(cpu, MIPS_GPR_SP, cpu->gpr[MIPS_GPR_SP] + simm16); break; case 4: { // SVRS uint32_t astatic = 0; uint32_t i; switch (aregs) { case 1: case 5: case 9: case 13: astatic = 1; break; case 2: case 6: case 10: astatic = 2; break; case 3: case 7: astatic = 3; break; case 11: astatic = 4; break; case 15: goto lInvalidInstruction; // TBD!!! or address error??? } if (instr & 0x80) { // save uint32_t temp = cpu->gpr[MIPS_GPR_SP], temp2 = temp - fmsz8 * 8; uint32_t args = 0; switch (aregs) { case 4: case 5: case 6: case 7: args = 1; break; case 8: case 9: case 10: args = 2; break; case 12: case 13: args = 3; break; case 14: args = 4; break; case 15: goto lInvalidInstruction; // TBD!!! or address error??? } for (i = 0; i < args && !res; i++) res = mips_exec_memop(cpu, MIPS_MEMOP_SW, temp + i * 4, 4 + i, FALSE); if ((instr & 0x40) && !res) // ra res = mips_exec_memop(cpu, MIPS_MEMOP_SW, temp -= 4, MIPS_GPR_RA, FALSE); for (i = xsregs; i && !res; i--) res = mips_exec_memop(cpu, MIPS_MEMOP_SW, temp -= 4, (i == 7) ? 30 : 17 + i, FALSE); if ((instr & 0x10) && !res) // s1 res = mips_exec_memop(cpu, MIPS_MEMOP_SW, temp -= 4, MIPS_GPR_S1, FALSE); if ((instr & 0x20) && !res) // s0 res = mips_exec_memop(cpu, MIPS_MEMOP_SW, temp -= 4, MIPS_GPR_S0, FALSE); for (i = 0; i < astatic && !res; i++) res = mips_exec_memop(cpu, MIPS_MEMOP_SW, temp -= 4, 7 - i, FALSE); if (!res) cpu->reg_set(cpu, MIPS_GPR_SP, temp2); } else { // restore uint32_t temp2 = cpu->gpr[MIPS_GPR_SP] + fmsz8 * 8, temp = temp2; if (instr & 0x40) // ra res = mips_exec_memop(cpu, MIPS_MEMOP_LW, temp -= 4, MIPS_GPR_RA, TRUE); for (i = xsregs; i && !res; i--) res = mips_exec_memop(cpu, MIPS_MEMOP_LW, temp -= 4, (i == 7) ? 30 : 17 + i, TRUE); if ((instr & 0x10) && !res) // s1 res = mips_exec_memop(cpu, MIPS_MEMOP_LW, temp -= 4, MIPS_GPR_S1, TRUE); if ((instr & 0x20) && !res) // s0 res = mips_exec_memop(cpu, MIPS_MEMOP_LW, temp -= 4, MIPS_GPR_S0, TRUE); for (i = 0; i < astatic && !res; i++) res = mips_exec_memop(cpu, MIPS_MEMOP_LW, temp -= 4, 7 - i, TRUE); if (!res) cpu->reg_set(cpu, MIPS_GPR_SP, temp2); } } break; default: goto lInvalidInstruction; } break; case 13: // li rx, imm16 if (unlikely(ry)) goto lInvalidInstruction; cpu->reg_set(cpu, xlat(rx), imm16); break; case 14: // cmpi rx, imm16 if (unlikely(ry)) goto lInvalidInstruction; cpu->reg_set(cpu, MIPS_GPR_T8, cpu->gpr[xlat(rx)] ^ imm16); break; case 16: // lb ry, ofs16(rx) res = mips_exec_memop2(cpu, MIPS_MEMOP_LB, xlat(rx), simm16, xlat(ry), TRUE); break; case 17: // lh ry, ofs16(rx) res = mips_exec_memop2(cpu, MIPS_MEMOP_LH, xlat(rx), simm16, xlat(ry), TRUE); break; case 18: // lw[sp] rx, ofs16(sp) if (unlikely(ry)) goto lInvalidInstruction; res = mips_exec_memop2(cpu, MIPS_MEMOP_LW, MIPS_GPR_SP, simm16, xlat(rx), TRUE); break; case 19: // lw ry, ofs16(rx) res = mips_exec_memop2(cpu, MIPS_MEMOP_LW, xlat(rx), simm16, xlat(ry), TRUE); break; case 20: // lbu ry, ofs16(rx) res = mips_exec_memop2(cpu, MIPS_MEMOP_LBU, xlat(rx), simm16, xlat(ry), TRUE); break; case 21: // lhu ry, ofs16(rx) res = mips_exec_memop2(cpu, MIPS_MEMOP_LHU, xlat(rx), simm16, xlat(ry), TRUE); break; case 22: // lw[pc] rx, ofs16(pc) if (unlikely(ry)) goto lInvalidInstruction; res = mips_exec_memop(cpu, MIPS_MEMOP_LW, (pc & 0xFFFFFFFC) + simm16, xlat(rx), TRUE); break; case 24: // sb ry, ofs16(rx) res = mips_exec_memop2(cpu, MIPS_MEMOP_SB, xlat(rx), simm16, xlat(ry), FALSE); break; case 25: // sh ry, ofs16(rx) res = mips_exec_memop2(cpu, MIPS_MEMOP_SH, xlat(rx), simm16, xlat(ry), FALSE); break; case 26: // sw[sp] rx, ofs16(sp) if (unlikely(ry)) goto lInvalidInstruction; res = mips_exec_memop2(cpu, MIPS_MEMOP_SW, MIPS_GPR_SP, simm16, xlat(rx), FALSE); break; case 27: // sw ry, ofs16(rx) res = mips_exec_memop2(cpu, MIPS_MEMOP_SW, xlat(rx), simm16, xlat(ry), FALSE); break; default: goto lInvalidInstruction; } } return res; lInvalidInstruction: unknown_op(cpu, (extend << 16) | instr); return 1; #undef xlat #undef op #undef imm2 #undef imm3 #undef imm4 #undef simm4 #undef imm5 #undef imm8 #undef simm8 #undef imm11 #undef simm11 #undef imm15 #undef simm15 #undef imm16 #undef simm16 #undef imm26 #undef rx #undef ry #undef rz #undef r32s #undef sa5 #undef fmsz8 #undef aregs #undef xsregs #undef code6 } ================================================ FILE: tools/virtualmips/mips_cp0.c ================================================ /* * Cisco router simulation platform. * Copyright (c) 2005,2006 Christophe Fillot (cf@utc.fr) * * MIPS Coprocessor 0 (System Coprocessor) implementation. * We don't use the JIT here, since there is no high performance needed. */ /* * Copyright (C) yajin 2008 * * This file is part of the virtualmips distribution. * See LICENSE file for terms of the license. * */ #define _GNU_SOURCE #include #include #include "mips.h" #include "mips_memory.h" #include "mips_cp0.h" #include "cpu.h" #include "vm.h" /* MIPS cp0 registers names */ char *mips_cp0_reg_names[MIPS64_CP0_REG_NR] = { "index", "random", "entry_lo", "cp0_r3", "context", "cp0_r5", "wired", "cp0_r7", "badvaddr", "cp0_r9", "entry_hi", "cp0_r11", "status", "cause", "epc", "prid", "dreg", "depc", "cp0_r18", "cp0_r19", "cctl", "cp0_r21", "cp0_r22", "cp0_r23", "cp0_r24", "cp0_r25", "cp0_r26", "cp0_r27", "cp0_r28", "cp0_r29", "cp0_r30", "desave", }; /* Get value of random register */ static inline u_int mips_cp0_get_random_reg (cpu_mips_t * cpu) { int random_value; random_value = (int) ((double) (cpu->cp0.tlb_entries) * arc4random () / (RAND_MAX + 1.0)); return random_value; } /* Get a cp0 register (fast version) */ static inline m_cp0_reg_t mips_cp0_get_reg_fast (cpu_mips_t * cpu, u_int cp0_reg, u_int sel) { mips_cp0_t *cp0 = &cpu->cp0; switch (cp0_reg) { case MIPS_CP0_RANDOM: return (mips_cp0_get_random_reg (cpu)); case MIPS_CP0_CONFIG: if (! ((1 << sel) & cp0->config_usable)) { unimpl: fprintf (stderr, "Read from unimplemented CP0 register %s\n", cp0reg_name (cp0_reg, sel)); return 0; } return cp0->config_reg[sel]; case MIPS_CP0_STATUS: switch (sel) { case 0: /* Status */ return cp0->reg[cp0_reg]; case 1: /* IntCtl */ return cp0->intctl_reg; case 2: /* SRSCtl */ return 0; } goto unimpl; case MIPS_CP0_PRID: switch (sel) { case 0: /* PRId */ return cp0->reg[cp0_reg]; case 1: /* EBase */ return cp0->ebase_reg; } goto unimpl; default: if (sel != 0) goto unimpl; return cp0->reg[cp0_reg]; } } /* Get a cp0 register */ m_cp0_reg_t mips_cp0_get_reg (cpu_mips_t * cpu, u_int cp0_reg) { return (mips_cp0_get_reg_fast (cpu, cp0_reg, 0)); } void fastcall mips_cp0_exec_mfc0_fastcall (cpu_mips_t * cpu, mips_insn_t insn) { int rt = bits (insn, 16, 20); int rd = bits (insn, 11, 15); int sel = bits (insn, 0, 2); cpu->reg_set (cpu, rt, sign_extend (mips_cp0_get_reg_fast (cpu, rd, sel), 32)); } /* MFC0 */ void mips_cp0_exec_mfc0 (cpu_mips_t * cpu, u_int gp_reg, u_int cp0_reg, u_int sel) { cpu->reg_set (cpu, gp_reg, sign_extend (mips_cp0_get_reg_fast (cpu, cp0_reg, sel), 32)); } void fastcall mips_cp0_exec_mtc0_fastcall (cpu_mips_t * cpu, mips_insn_t insn) { int rt = bits (insn, 16, 20); int rd = bits (insn, 11, 15); int sel = bits (insn, 0, 2); mips_cp0_set_reg (cpu, rd, sel, cpu->gpr[rt] & 0xffffffff); } void mips_cp0_exec_mtc0 (cpu_mips_t * cpu, u_int gp_reg, u_int cp0_reg, u_int sel) { mips_cp0_set_reg (cpu, cp0_reg, sel, cpu->gpr[gp_reg] & 0xffffffff); } /* Set a cp0 register */ void mips_cp0_set_reg (cpu_mips_t * cpu, u_int cp0_reg, u_int sel, m_uint32_t val) { mips_cp0_t *cp0 = &cpu->cp0; if (cpu->vm->debug_level > 2) { extern const char *cp0reg_name (unsigned cp0reg, unsigned sel); printf (" %s := %08x\n", cp0reg_name (cp0_reg, sel), val); fflush (stdout); } switch (cp0_reg) { case MIPS_CP0_STATUS: switch (sel) { case 0: /* Status */ cp0->reg[cp0_reg] = val; break; case 1: /* IntCtl */ cp0->intctl_reg = val; break; case 2: /* SRSCtl */ /* Read-only */ break; default: goto unimpl; } break; case MIPS_CP0_PRID: switch (sel) { case 0: /* PRId */ /* read only register */ break; case 1: /* EBase */ cp0->ebase_reg = (val & 0x3ffff000) | 0x80000000; break; default: goto unimpl; } break; case MIPS_CP0_RANDOM: case MIPS_CP0_WIRED: /* read only registers */ if (sel != 0) goto unimpl; break; case MIPS_CP0_COMPARE: // Write to compare will clear timer interrupt if (sel != 0) goto unimpl; clear_timer_irq (cpu); cp0->reg[cp0_reg] = val; break; case MIPS_CP0_CONFIG: if (! ((1 << sel) & cp0->config_usable)) goto unimpl; switch (sel) { case 0: /* Config */ /* only bits 0:2 are writable */ val &= 3; cp0->config_reg[sel] &= 0xfffffffc; cp0->config_reg[sel] |= val; break; default: /* Config1-Config7 registers are read-only. */ break; } break; case MIPS_CP0_DEBUG: /* Only some bits of Debug register are writable. */ if (sel != 0) goto unimpl; cp0->reg[cp0_reg] &= ~MIPS_CP0_DEBUG_WMASK; cp0->reg[cp0_reg] |= val & MIPS_CP0_DEBUG_WMASK; break; default: if (sel != 0) { unimpl: fprintf (stderr, "Write to unimplemented register %s\n", cp0reg_name (cp0_reg, sel)); break; } cp0->reg[cp0_reg] = val; } } /* Get the VPN2 mask */ m_cp0_reg_t mips_cp0_get_vpn2_mask (cpu_mips_t * cpu) { if (cpu->addr_mode == 64) return ((m_cp0_reg_t) MIPS_TLB_VPN2_MASK_64); else return ((m_cp0_reg_t) MIPS_TLB_VPN2_MASK_32); } /* TLBP: Probe a TLB entry */ void fastcall mips_cp0_exec_tlbp (cpu_mips_t * cpu) { mips_cp0_t *cp0 = &cpu->cp0; m_uint32_t vpn2, hi_reg, vpn2_mask, page_mask, hi_addr; tlb_entry_t *entry; u_int asid; int i; vpn2_mask = mips_cp0_get_vpn2_mask (cpu); hi_reg = cp0->reg[MIPS_CP0_TLB_HI]; asid = hi_reg & MIPS_TLB_ASID_MASK; vpn2 = hi_reg & vpn2_mask; cp0->reg[MIPS_CP0_INDEX] = 0x80000000; for (i = 0; i < cp0->tlb_entries; i++) { entry = &cp0->tlb[i]; page_mask = ~(entry->mask + 0x1FFF); hi_addr = entry->hi & mips_cp0_get_vpn2_mask (cpu); if (((vpn2 & page_mask) == (hi_addr & page_mask)) && (((entry->hi & MIPS_TLB_G_MASK)) || ((entry->hi & MIPS_TLB_ASID_MASK) == asid))) { cp0->reg[MIPS_CP0_INDEX] = i; cp0->reg[MIPS_CP0_INDEX] &= ~0x80000000ULL; return; #if DEBUG_TLB_ACTIVITY cpu_log (cpu, "", "CPU: CP0_TLBP returned %x\n", i); #endif } } } /* Get the page size corresponding to a page mask */ static inline m_uint32_t get_page_size (m_uint32_t page_mask) { return ((page_mask + 0x2000) >> 1); } void mips_cp0_unmap_tlb_to_mts (cpu_mips_t * cpu, int index) { m_va_t v0_addr, v1_addr; m_uint32_t page_size; tlb_entry_t *entry; entry = &cpu->cp0.tlb[index]; page_size = get_page_size (entry->mask); v0_addr = entry->hi & mips_cp0_get_vpn2_mask (cpu); v1_addr = v0_addr + page_size; if (entry->lo0 & MIPS_TLB_V_MASK) cpu->mts_unmap (cpu, v0_addr, page_size, MTS_ACC_T, index); if (entry->lo1 & MIPS_TLB_V_MASK) cpu->mts_unmap (cpu, v1_addr, page_size, MTS_ACC_T, index); } /* TLBW: Write a TLB entry */ static forced_inline void mips_cp0_exec_tlbw (cpu_mips_t * cpu, u_int index) { mips_cp0_t *cp0 = &cpu->cp0; tlb_entry_t *entry; if (index < cp0->tlb_entries) { entry = &cp0->tlb[index]; /* Unmap the old entry if it was valid */ mips_cp0_unmap_tlb_to_mts (cpu, index); entry->mask = cp0->reg[MIPS_CP0_PAGEMASK]; entry->hi = cp0->reg[MIPS_CP0_TLB_HI]; entry->lo0 = cp0->reg[MIPS_CP0_TLB_LO_0]; entry->lo1 = cp0->reg[MIPS_CP0_TLB_LO_1]; /* if G bit is set in lo0 and lo1, set it in hi */ if ((entry->lo0 & entry->lo1) & MIPS_CP0_LO_G_MASK) entry->hi |= MIPS_TLB_G_MASK; /* Clear G bit in TLB lo0 and lo1 */ entry->lo0 &= ~MIPS_CP0_LO_G_MASK; entry->lo1 &= ~MIPS_CP0_LO_G_MASK; } } /* TLBWI: Write Indexed TLB entry */ void fastcall mips_cp0_exec_tlbwi (cpu_mips_t * cpu) { m_uint32_t index; /*FIX ME: May be a bug in tlblhandler of 2.6.11. by yajin. IN kernel, TLBL exception handler run a tlbp and then tlbw without checking tlbp is successful. assume 2aaa8a9c lw t0,(s0) 1.First we need to load instruction in 2aaa8a9c. A tlbl exception occurs. tlbp failed and tlbw write tlb entry into entry x. 2. And then exceute the instruction. load a data from a memory. A tlbl exception occurs. tlbp failed and tlbw write tlb entry into entry x. and return to pc=2aaa8a9c and do the process 1. This will cause a infinate loop. In fact, we need to check whether is successfully. If success, tlbw. otherwise tlbwr. So I first check whether last tlbp failed(check highest bit of index register). If tlbp failed, write tlbwr instead tlbw. It works well. */ if (cpu->cp0.reg[MIPS_CP0_INDEX] & 0x80000000) { mips_cp0_exec_tlbwr (cpu); } else { index = cpu->cp0.reg[MIPS_CP0_INDEX]; mips_cp0_exec_tlbw (cpu, index); } } /* TLBWR: Write Random TLB entry */ void fastcall mips_cp0_exec_tlbwr (cpu_mips_t * cpu) { mips_cp0_exec_tlbw (cpu, mips_cp0_get_random_reg (cpu)); } /* TLBR: Read Indexed TLB entry */ void fastcall mips_cp0_exec_tlbr (cpu_mips_t * cpu) { mips_cp0_t *cp0 = &cpu->cp0; tlb_entry_t *entry; u_int index; index = cp0->reg[MIPS_CP0_INDEX]; #if DEBUG_TLB_ACTIVITY cpu_log (cpu, "TLB", "CP0_TLBR: Read entry %u.\n", index); #endif if (index < cp0->tlb_entries) { entry = &cp0->tlb[index]; cp0->reg[MIPS_CP0_PAGEMASK] = entry->mask; cp0->reg[MIPS_CP0_TLB_HI] = entry->hi; cp0->reg[MIPS_CP0_TLB_LO_0] = entry->lo0; cp0->reg[MIPS_CP0_TLB_LO_1] = entry->lo1; if (entry->hi & MIPS_TLB_G_MASK) { cp0->reg[MIPS_CP0_TLB_LO_0] |= MIPS_CP0_LO_G_MASK; cp0->reg[MIPS_CP0_TLB_LO_1] |= MIPS_CP0_LO_G_MASK; cp0->reg[MIPS_CP0_TLB_HI] &= ~MIPS_TLB_G_MASK; } } } #ifndef SIM_PIC32 int mips_cp0_tlb_lookup (cpu_mips_t *cpu, m_va_t vaddr, mts_map_t *res) { mips_cp0_t *cp0 = &cpu->cp0; m_va_t vpn_addr, hi_addr, page_mask, page_size; tlb_entry_t *entry; u_int asid; int i; vpn_addr = vaddr & mips_cp0_get_vpn2_mask (cpu); asid = cp0->reg[MIPS_CP0_TLB_HI] & MIPS_TLB_ASID_MASK; for (i = 0; i < cp0->tlb_entries; i++) { entry = &cp0->tlb[i]; page_mask = ~(entry->mask + 0x1FFF); hi_addr = entry->hi & mips_cp0_get_vpn2_mask (cpu); if (((vpn_addr & page_mask) == (hi_addr & page_mask)) && ((entry->hi & MIPS_TLB_G_MASK) || ((entry->hi & MIPS_TLB_ASID_MASK) == asid))) { page_size = get_page_size (entry->mask); if ((vaddr & page_size) == 0) { res->tlb_index = i; res->vaddr = vaddr & MIPS_MIN_PAGE_MASK; res->paddr = (entry->lo0 & MIPS_TLB_PFN_MASK) << 6; res->paddr += ((res->vaddr) & (page_size - 1)); //res->paddr += ( (vaddr )& (page_size-1)); res->paddr &= cpu->addr_bus_mask; res->dirty = (entry->lo0 & MIPS_TLB_D_MASK) >> MIPS_TLB_D_SHIT; res->valid = (entry->lo0 & MIPS_TLB_V_MASK) >> MIPS_TLB_V_SHIT; res->asid = asid; res->g_bit = entry->hi & MIPS_TLB_G_MASK; return (TRUE); } else { res->tlb_index = i; res->vaddr = vaddr & MIPS_MIN_PAGE_MASK; res->paddr = (entry->lo1 & MIPS_TLB_PFN_MASK) << 6; res->paddr += ((res->vaddr) & (page_size - 1)); //res->paddr += ( (vaddr )& (page_size-1)); res->paddr &= cpu->addr_bus_mask; res->dirty = (entry->lo1 & MIPS_TLB_D_MASK) >> MIPS_TLB_D_SHIT; res->valid = (entry->lo1 & MIPS_TLB_V_MASK) >> MIPS_TLB_V_SHIT; res->asid = asid; res->g_bit = entry->hi & MIPS_TLB_G_MASK; return (TRUE); } } } return FALSE; } #endif #if 0 /* Write page size in buffer */ static char *get_page_size_str (char *buffer, size_t len, m_uint32_t page_mask) { m_uint32_t page_size; page_size = get_page_size (page_mask); /* Mb ? */ if (page_size >= (1024 * 1024)) snprintf (buffer, len, "%uMB", page_size >> 20); else snprintf (buffer, len, "%uKB", page_size >> 10); return buffer; } /* Dump the specified TLB entry */ void mips_tlb_dump_entry (cpu_mips_t * cpu, u_int index) { tlb_entry_t *entry; char buffer[256]; entry = &cpu->cp0.tlb[index]; /* virtual Address */ printf (" %2d: vaddr=0x%8.8" LL "x ", index, entry->hi & mips_cp0_get_vpn2_mask (cpu)); /* global or ASID */ if ((entry->lo0 & MIPS_TLB_G_MASK) && ((entry->lo1 & MIPS_TLB_G_MASK))) printf ("(global) "); else printf ("(asid 0x%2.2" LL "x) ", entry->hi & MIPS_TLB_ASID_MASK); /* 1st page: Lo0 */ printf ("p0="); if (entry->lo0 & MIPS_TLB_V_MASK) printf ("0x%9.9" LL "x", (entry->lo0 & MIPS_TLB_PFN_MASK) << 6); else printf ("(invalid) "); printf (" %c ", (entry->lo0 & MIPS_TLB_D_MASK) ? 'D' : ' '); /* 2nd page: Lo1 */ printf ("p1="); if (entry->lo1 & MIPS_TLB_V_MASK) printf ("0x%9.9" LL "x", (entry->lo1 & MIPS_TLB_PFN_MASK) << 6); else printf ("(invalid) "); printf (" %c ", (entry->lo1 & MIPS_TLB_D_MASK) ? 'D' : ' '); /* page size */ printf (" (%s)\n", get_page_size_str (buffer, sizeof (buffer), entry->mask)); } /* Human-Readable dump of the TLB */ void mips_tlb_dump (cpu_mips_t * cpu) { cpu_mips_t *mcpu = (cpu); u_int i; printf ("TLB dump:\n"); for (i = 0; i < mcpu->cp0.tlb_entries; i++) mips_tlb_dump_entry (mcpu, i); printf ("\n"); } /* Raw dump of the TLB */ void mips_tlb_raw_dump (cpu_mips_t * cpu) { cpu_mips_t *mcpu = (cpu); tlb_entry_t *entry; u_int i; printf ("TLB dump:\n"); for (i = 0; i < mcpu->cp0.tlb_entries; i++) { entry = &mcpu->cp0.tlb[i]; printf (" %2d: mask=0x%16.16" LL "x hi=0x%16.16" LL "x " "lo0=0x%16.16" LL "x lo1=0x%16.16" LL "x\n", i, entry->mask, entry->hi, entry->lo0, entry->lo1); } printf ("\n"); } #endif ================================================ FILE: tools/virtualmips/mips_cp0.h ================================================ /* * Cisco router simulation platform. * Copyright (c) 2005,2006 Christophe Fillot (cf@utc.fr) */ /* * Copyright (C) yajin 2008 * * This file is part of the virtualmips distribution. * See LICENSE file for terms of the license. * */ #ifndef __CP0_H__ #define __CP0_H__ #include "utils.h" #include "system.h" /* CP0 register names */ extern char *mips_cp0_reg_names[]; m_cp0_reg_t mips_cp0_get_reg (cpu_mips_t * cpu, u_int cp0_reg); void fastcall mips_cp0_exec_mfc0_fastcall (cpu_mips_t * cpu, mips_insn_t insn); void mips_cp0_exec_mfc0 (cpu_mips_t * cpu, u_int gp_reg, u_int cp0_reg, u_int sel); void mips_cp0_exec_mtc0 (cpu_mips_t * cpu, u_int gp_reg, u_int cp0_reg, u_int sel); void fastcall mips_cp0_exec_mtc0_fastcall (cpu_mips_t * cpu, mips_insn_t insn); void mips_cp0_set_reg (cpu_mips_t * cpu, u_int cp0_reg, u_int sel, m_uint32_t val); m_cp0_reg_t mips_cp0_get_vpn2_mask (cpu_mips_t * cpu); void fastcall mips_cp0_exec_tlbp (cpu_mips_t * cpu); void fastcall mips_cp0_exec_tlbwi (cpu_mips_t * cpu); void fastcall mips_cp0_exec_tlbwr (cpu_mips_t * cpu); void fastcall mips_cp0_exec_tlbr (cpu_mips_t * cpu); int mips_cp0_tlb_lookup (cpu_mips_t * cpu, m_va_t vaddr, mts_map_t * res); void mips_tlb_dump (cpu_mips_t * cpu); void mips_tlb_raw_dump (cpu_mips_t * cpu); #endif ================================================ FILE: tools/virtualmips/mips_exec.c ================================================ /* * Copyright (C) yajin 2008 * * This file is part of the virtualmips distribution. * See LICENSE file for terms of the license. */ #include "cpu.h" #include "vm.h" #include "mips_exec.h" #include "mips_fdd.h" #include "vp_timer.h" cpu_mips_t *current_cpu; /*select different main loop*/ void *mips_exec_run_cpu (cpu_mips_t * cpu) { #ifdef _USE_JIT_ if (cpu->vm->jit_use) { mips_jit_init (cpu); return mips_jit_run_cpu (cpu); } else #endif return mips_cpu_fdd (cpu); } ================================================ FILE: tools/virtualmips/mips_exec.h ================================================ /* * Cisco router simulation platform. * Copyright (c) 2005,2006 Christophe Fillot (cf@utc.fr) */ /* * Copyright (C) yajin 2008 * * This file is part of the virtualmips distribution. * See LICENSE file for terms of the license. * */ #ifndef __MIPS64_EXEC_H__ #define __MIPS64_EXEC_H__ #include "utils.h" #include "system.h" #include "mips_jit.h" struct mips_op_desc { char *opname; int (*func) (cpu_mips_t *, mips_insn_t); m_uint16_t num; }; struct mips_jit_desc { char *opname; int (*emit_func) (cpu_mips_t *, mips_jit_tcb_t *, mips_insn_t); m_uint16_t num; int delay_slot; /*can this instruction in delay slot. 1:can. 0: can not */ }; /* Run MIPS code in step-by-step mode */ void *mips_exec_run_cpu (cpu_mips_t * cpu); #endif ================================================ FILE: tools/virtualmips/mips_fdd.c ================================================ /* * This is the basic fetch-decode-dispatch(fdd) routine. * Emulation speed is slow but easy to debug. * * Copyright (C) yajin 2008 * * This file is part of the virtualmips distribution. * See LICENSE file for terms of the license. */ #include #include #include #include #include #include #include #include #include #include #include #include "cpu.h" #include "vm.h" #include "mips_exec.h" #include "mips_memory.h" #include "mips.h" #include "mips_cp0.h" #include "debug.h" #include "vp_timer.h" #include "mips_hostalarm.h" //#ifdef _USE_FDD_ static const struct mips_op_desc mips_opcodes[]; static const struct mips_op_desc mips_spec_opcodes[]; static const struct mips_op_desc mips_bcond_opcodes[]; static const struct mips_op_desc mips_cop0_opcodes[]; static const struct mips_op_desc mips_spec2_opcodes[]; static const struct mips_op_desc mips_spec3_opcodes[]; static const struct mips_op_desc mips_tlb_opcodes[]; static int mips_exec_mips16e (cpu_mips_t * cpu, mips_insn_t instruction); extern cpu_mips_t *current_cpu; /*for emulation performance check*/ #ifdef DEBUG_MHZ #define C_1000MHZ 1000000000 struct timeval pstart, pend; float timeuse, performance; m_uint64_t instructions_executed = 0; #endif static void forced_inline mips_main_loop_wait (cpu_mips_t * cpu, int timeout) { vp_run_timers (&active_timers[VP_TIMER_REALTIME], vp_get_clock (rt_clock)); } static int forced_inline mips_exec_memop (cpu_mips_t * cpu, int memop, m_va_t vaddr, u_int dst_reg, int keep_ll_bit) { mips_memop_fn fn; if (!keep_ll_bit) cpu->ll_bit = 0; fn = cpu->mem_op_fn[memop]; return (fn (cpu, vaddr, dst_reg)); } /* Execute a memory operation (2) */ static int forced_inline mips_exec_memop2 (cpu_mips_t * cpu, int memop, u_int base_reg, int offset, u_int dst_reg, int keep_ll_bit) { m_va_t vaddr = cpu->gpr[base_reg] + sign_extend (offset, 16); return mips_exec_memop (cpu, memop, vaddr, dst_reg, keep_ll_bit); } extern void mips_access_special (cpu_mips_t * cpu, m_va_t vaddr, m_uint32_t mask, u_int op_code, u_int op_type, u_int op_size, m_reg_t * data, u_int * exc); /* Fetch an instruction */ static int mips_fetch_instruction_inner (cpu_mips_t * cpu, m_va_t pc, mips_insn_t * insn, u_int size) { m_va_t exec_page; m_uint32_t offset; if (unlikely (pc & (size - 1))) { u_int exc = 0; mips_access_special(cpu, pc, MTS_ACC_AE, MIPS_MEMOP_LOOKUP, MTS_READ, size, NULL, &exc); return (1); } exec_page = pc & ~(m_va_t) MIPS_MIN_PAGE_IMASK; if (unlikely (exec_page != cpu->njm_exec_page)) { cpu->njm_exec_ptr = cpu->mem_op_lookup (cpu, exec_page); } if (cpu->njm_exec_ptr == NULL) { //exception when fetching instruction return (1); } cpu->njm_exec_page = exec_page; offset = (pc & MIPS_MIN_PAGE_IMASK) >> 2; *insn = vmtoh32 (cpu->njm_exec_ptr[offset]); if (unlikely (size == 2)) { if (pc & 2) { *insn >>= 16; } else { *insn &= 0xFFFF; } } // printf ("(%08x) %08x\n", pc, *insn); return (0); } int mips_fetch_instruction (cpu_mips_t * cpu, m_va_t pc, mips_insn_t * insn) { int res; if (unlikely(cpu->is_mips16e)) { res = mips_fetch_instruction_inner(cpu, pc, insn, 2); if (unlikely(res)) { return res; } if (unlikely((*insn >> 11) == 0x1E || (*insn >> 11) == 3)) { /* 4-byte extended instruction or jal(x): 2 more bytes needed */ mips_insn_t i; res = mips_fetch_instruction_inner(cpu, pc + 2, &i, 2); if (unlikely(res)) { return res; } *insn = (*insn << 16) | i; cpu->insn_len = 4; } else { /* 2-byte instruction */ cpu->insn_len = 2; } } else { res = mips_fetch_instruction_inner(cpu, pc, insn, 4); cpu->insn_len = 4; } return res; } /* Execute a single instruction */ static forced_inline int mips_exec_single_instruction (cpu_mips_t * cpu, mips_insn_t instruction) { #ifdef DEBUG_MHZ if (unlikely (instructions_executed == 0)) { gettimeofday (&pstart, NULL); } instructions_executed++; if (unlikely (instructions_executed == C_1000MHZ)) { gettimeofday (&pend, NULL); timeuse = 1000000 * (pend.tv_sec - pstart.tv_sec) + pend.tv_usec - pstart.tv_usec; timeuse /= 1000000; performance = 1000 / timeuse; printf ("Used Time:%f seconds. %f MHZ\n", timeuse, performance); exit (1); } #endif if (unlikely(cpu->is_mips16e)) { return mips_exec_mips16e (cpu, instruction); } else { register uint op; op = MAJOR_OP (instruction); return mips_opcodes[op].func (cpu, instruction); } } /* Single-step execution */ void fastcall mips_exec_single_step (cpu_mips_t * cpu, mips_insn_t instruction) { int res; int insn_len = cpu->insn_len; res = mips_exec_single_instruction (cpu, instruction); /* Normal flow ? */ if (likely (!res)) cpu->pc += insn_len; } void dumpregs (cpu_mips_t *cpu) { printf (" t0 = %8x s0 = %8x t8 = %8x lo = %8x\n", cpu->gpr[8], cpu->gpr[16], cpu->gpr[24], cpu->lo); printf ("at = %8x t1 = %8x s1 = %8x t9 = %8x hi = %8x\n", cpu->gpr[1], cpu->gpr[9], cpu->gpr[17], cpu->gpr[25], cpu->hi); printf ("v0 = %8x t2 = %8x s2 = %8x status = %8x\n", cpu->gpr[2], cpu->gpr[10], cpu->gpr[18], cpu->cp0.reg[MIPS_CP0_STATUS]); printf ("v1 = %8x t3 = %8x s3 = %8x\n", cpu->gpr[3], cpu->gpr[11], cpu->gpr[19]); printf ("a0 = %8x t4 = %8x s4 = %8x gp = %8x pc = %8x\n", cpu->gpr[4], cpu->gpr[12], cpu->gpr[20], cpu->gpr[28], cpu->pc); printf ("a1 = %8x t5 = %8x s5 = %8x sp = %8x\n", cpu->gpr[5], cpu->gpr[13], cpu->gpr[21], cpu->gpr[29]); printf ("a2 = %8x t6 = %8x s6 = %8x fp = %8x\n", cpu->gpr[6], cpu->gpr[14], cpu->gpr[22], cpu->gpr[30]); printf ("a3 = %8x t7 = %8x s7 = %8x ra = %8x\n", cpu->gpr[7], cpu->gpr[15], cpu->gpr[23], cpu->gpr[31]); } /* * MIPS64 fetch->decode->dispatch main loop */ void *mips_cpu_fdd (cpu_mips_t * cpu) { mips_insn_t insn = 0; int res; cpu->cpu_thread_running = TRUE; current_cpu = cpu; mips_init_host_alarm (); start_cpu: for (;;) { int insn_len; if (unlikely (cpu->state != CPU_STATE_RUNNING)) break; if (unlikely ((cpu->pause_request) & CPU_INTERRUPT_EXIT)) { cpu->state = CPU_STATE_PAUSING; break; } /* Reset "zero register" (for safety) */ cpu->gpr[0] = 0; /* Check IRQ */ if (unlikely (cpu->irq_pending)) { mips_trigger_irq (cpu); continue; } /* Fetch the instruction */ res = mips_fetch_instruction (cpu, cpu->pc, &insn); insn_len = cpu->insn_len; if (cpu->vm->trace_address == cpu->pc) { /* Trace address. */ printf ("*** %08x: %08x ", cpu->pc, insn); print_mips (cpu->pc, insn, cpu->insn_len, cpu->is_mips16e, stdout); printf ("\n"); dumpregs (cpu); } if (unlikely (res == 1)) { /*exception when fetching instruction */ printf ("%08x: exception when fetching instruction\n", cpu->pc); if (cpu->pc == 0) exit(-1); continue; } if (unlikely ((cpu->vm->mipsy_debug_mode) && ((cpu_hit_breakpoint (cpu->vm, cpu->pc) == SUCCESS) || (cpu->vm->gdb_interact_sock == -1) || (cpu->vm->mipsy_break_nexti == MIPS_BREAKANYCPU)))) { if (mips_debug (cpu->vm, 1)) { continue; } } if (cpu->vm->debug_level > 2 || (cpu->vm->debug_level > 1 && (cpu->cp0.reg[MIPS_CP0_STATUS] & MIPS_CP0_STATUS_UM) && ! (cpu->cp0.reg[MIPS_CP0_STATUS] & MIPS_CP0_STATUS_EXL))) { /* Print instructions in user mode. */ printf ("%08x: ", cpu->pc); if (insn_len == 2) printf (" %04x ", insn); else printf ("%08x ", insn); print_mips (cpu->pc, insn, insn_len, cpu->is_mips16e, stdout); printf ("\n"); fflush (stdout); #if 0 m_uint32_t dummy; unsigned char *p = physmem_get_hptr (cpu->vm, 0x00010000, 0, MTS_READ, &dummy); if (p) { unsigned nbytes; for (nbytes=0x40; nbytes>0; p+=16, nbytes-=16) { printf ("%08x: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n", (unsigned) p, p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7], p[8], p[9], p[10], p[11], p[12], p[13], p[14], p[15]); } } #endif } res = mips_exec_single_instruction (cpu, insn); /* Normal flow ? */ if (likely (!res)) cpu->pc += insn_len; } while (cpu->cpu_thread_running) { switch (cpu->state) { case CPU_STATE_RUNNING: cpu->state = CPU_STATE_RUNNING; goto start_cpu; case CPU_STATE_HALTED: cpu->cpu_thread_running = FALSE; break; case CPU_STATE_RESTARTING: cpu->state = CPU_STATE_RESTARTING; /*Just waiting for cpu restart. */ break; case CPU_STATE_PAUSING: /*main loop must wait for me. heihei :) */ mips_main_loop_wait (cpu, 0); cpu->state = CPU_STATE_RUNNING; cpu->pause_request &= ~CPU_INTERRUPT_EXIT; /*start cpu again */ goto start_cpu; } } return NULL; } /* Execute the instruction in delay slot */ static forced_inline int mips_exec_bdslot (cpu_mips_t * cpu) { mips_insn_t insn; int res = 0; int insn_len = cpu->insn_len; cpu->is_in_bdslot = 1; /* Fetch the instruction in delay slot */ res = mips_fetch_instruction (cpu, cpu->pc + insn_len, &insn); if (res == 1) { /*exception when fetching instruction */ cpu->is_in_bdslot = 0; return (1); } cpu->is_in_bdslot = 1; if (cpu->vm->debug_level > 2 || (cpu->vm->debug_level > 1 && (cpu->cp0.reg[MIPS_CP0_STATUS] & MIPS_CP0_STATUS_UM) && ! (cpu->cp0.reg[MIPS_CP0_STATUS] & MIPS_CP0_STATUS_EXL))) { /* Print instructions in user mode. */ printf ("%08x: %08x ", cpu->pc + insn_len, insn); print_mips (cpu->pc, insn, insn_len, cpu->is_mips16e, stdout); printf ("\n"); fflush (stdout); } /* Execute the instruction */ res = mips_exec_single_instruction (cpu, insn); cpu->is_in_bdslot = 0; return res; } #include "mips_codetable.c" //#endif ================================================ FILE: tools/virtualmips/mips_fdd.h ================================================ /* * Copyright (C) yajin 2008 * * This file is part of the virtualmips distribution. * See LICENSE file for terms of the license. * */ #ifndef __MIPS64_FDD_H__ #define __MIPS64_FDD_H__ #include "utils.h" #include "system.h" void *mips_cpu_fdd (cpu_mips_t * cpu); #endif ================================================ FILE: tools/virtualmips/mips_hostalarm.c ================================================ #include #include #include #include #include #include #include #include #include #include #include #include #ifdef __linux__ #include #endif #include "cpu.h" #include "vm.h" #include "mips_exec.h" #include "mips_memory.h" #include "mips.h" #include "mips_cp0.h" #include "debug.h" #include "vp_timer.h" #include "mips_hostalarm.h" /*code from qemu*/ #define TFR(expr) do { if ((expr) != -1) break; } while (errno == EINTR) static struct qemu_alarm_timer *alarm_timer; extern cpu_mips_t *current_cpu; #define RTC_FREQ 1024 #define ALARM_FLAG_DYNTICKS 0x1 #define ALARM_FLAG_EXPIRED 0x2 /* TODO: MIN_TIMER_REARM_US should be optimized */ #define MIN_TIMER_REARM_US 250 struct hpet_info { unsigned long hi_ireqfreq; /* Hz */ unsigned long hi_flags; /* information */ unsigned short hi_hpet; unsigned short hi_timer; }; #define HPET_INFO_PERIODIC 0x0001 /* timer is periodic */ #define HPET_IE_ON _IO('h', 0x01) /* interrupt on */ #define HPET_IE_OFF _IO('h', 0x02) /* interrupt off */ #define HPET_INFO _IOR('h', 0x03, struct hpet_info) #define HPET_EPI _IO('h', 0x04) /* enable periodic */ #define HPET_DPI _IO('h', 0x05) /* disable periodic */ #define HPET_IRQFREQ _IOW('h', 0x6, unsigned long) /* IRQFREQ usec */ /* * Host alarm, fired once 1 ms. * It will find whether a timer has been expired. * If so, run timers. */ void host_alarm_handler (int host_signum) { if (unlikely (current_cpu->state != CPU_STATE_RUNNING)) return; if (vp_timer_expired (active_timers[VP_TIMER_REALTIME], vp_get_clock (rt_clock))) { /* Tell cpu we need to pause because timer out */ current_cpu->pause_request |= CPU_INTERRUPT_EXIT; } /* Check count and compare */ #define KHZ 80000 current_cpu->cp0.reg[MIPS_CP0_COUNT] += KHZ / 2; if (current_cpu->cp0.reg[MIPS_CP0_COMPARE] != 0) { if (current_cpu->cp0.reg[MIPS_CP0_COUNT] >= current_cpu->cp0.reg[MIPS_CP0_COMPARE]) { set_timer_irq (current_cpu); } } /*printf ("-- count = %u, compare = %u\n", current_cpu->cp0.reg[MIPS_CP0_COUNT], current_cpu->cp0.reg[MIPS_CP0_COMPARE]);*/ host_alarm (current_cpu, KHZ); } #ifdef __linux__ static void enable_sigio_timer (int fd) { struct sigaction act; /* timer signal */ sigfillset (&act.sa_mask); act.sa_flags = 0; act.sa_handler = host_alarm_handler; sigaction (SIGIO, &act, NULL); fcntl (fd, F_SETFL, O_ASYNC); fcntl (fd, F_SETOWN, getpid ()); } static int hpet_start_timer (struct qemu_alarm_timer *t) { struct hpet_info info; int r, fd; fd = open ("/dev/hpet", O_RDONLY); if (fd < 0) return -1; /* Set frequency */ r = ioctl (fd, HPET_IRQFREQ, RTC_FREQ); if (r < 0) { fprintf (stderr, "Could not configure '/dev/hpet' to have a 1024Hz timer. This is not a fatal\n" "error, but for better emulation accuracy type:\n" "'echo 1024 > /proc/sys/dev/hpet/max-user-freq' as root.\n"); goto fail; } /* Check capabilities */ r = ioctl (fd, HPET_INFO, &info); if (r < 0) goto fail; /* Enable periodic mode */ r = ioctl (fd, HPET_EPI, 0); if (info.hi_flags && (r < 0)) goto fail; /* Enable interrupt */ r = ioctl (fd, HPET_IE_ON, 0); if (r < 0) goto fail; enable_sigio_timer (fd); t->priv = (void *) (long) fd; return 0; fail: close (fd); return -1; } static void hpet_stop_timer (struct qemu_alarm_timer *t) { int fd = (long) t->priv; close (fd); } static int rtc_start_timer (struct qemu_alarm_timer *t) { int rtc_fd; TFR (rtc_fd = open ("/dev/rtc", O_RDONLY)); if (rtc_fd < 0) return -1; if (ioctl (rtc_fd, RTC_IRQP_SET, RTC_FREQ) < 0) { fprintf (stderr, "Could not configure '/dev/rtc' to have a 1024 Hz timer. This is not a fatal\n" "error, but for better emulation accuracy either use a 2.6 host Linux kernel or\n" "type 'echo 1024 > /proc/sys/dev/rtc/max-user-freq' as root.\n"); goto fail; } if (ioctl (rtc_fd, RTC_PIE_ON, 0) < 0) { fail: close (rtc_fd); return -1; } enable_sigio_timer (rtc_fd); t->priv = (void *) (long) rtc_fd; return 0; } static void rtc_stop_timer (struct qemu_alarm_timer *t) { int rtc_fd = (long) t->priv; close (rtc_fd); } #endif /* __linux__ */ static int unix_start_timer (struct qemu_alarm_timer *t) { struct sigaction act; struct itimerval itv; int err; /* timer signal */ sigfillset (&act.sa_mask); act.sa_flags = 0; act.sa_handler = host_alarm_handler; sigaction (SIGALRM, &act, NULL); itv.it_interval.tv_sec = 0; /* for i386 kernel 2.6 to get 1 ms */ itv.it_interval.tv_usec = 999; itv.it_value.tv_sec = 0; itv.it_value.tv_usec = 10 * 1000; err = setitimer (ITIMER_REAL, &itv, NULL); if (err) return -1; return 0; } static void unix_stop_timer (struct qemu_alarm_timer *t) { struct itimerval itv; memset (&itv, 0, sizeof (itv)); setitimer (ITIMER_REAL, &itv, NULL); } static struct qemu_alarm_timer alarm_timers[] = { #ifdef __linux__ /* HPET - if available - is preferred */ {"hpet", 0, hpet_start_timer, hpet_stop_timer, NULL, NULL}, /* ...otherwise try RTC */ {"rtc", 0, rtc_start_timer, rtc_stop_timer, NULL, NULL}, #endif {"unix", 0, unix_start_timer, unix_stop_timer, NULL, NULL}, {NULL,} }; /*host alarm*/ void mips_init_host_alarm (void) { struct qemu_alarm_timer *t; int i, err = -1; for (i = 0; alarm_timers[i].name; i++) { t = &alarm_timers[i]; err = t->start (t); if (! err) break; } /*#define DEBUG_HOST_ALARM*/ #ifdef DEBUG_HOST_ALARM printf ("--- Using %s timer\n", alarm_timers[i].name); #endif if (err) { fprintf (stderr, "Unable to find any suitable alarm timer.\n"); fprintf (stderr, "Terminating\n"); exit (1); } alarm_timer = t; } ================================================ FILE: tools/virtualmips/mips_hostalarm.h ================================================ #ifndef __MIPS64_HOSTALARM_H__ #define __MIPS64_HOSTALARM_H__ struct qemu_alarm_timer { char const *name; unsigned int flags; int (*start) (struct qemu_alarm_timer * t); void (*stop) (struct qemu_alarm_timer * t); void (*rearm) (struct qemu_alarm_timer * t); void *priv; }; void mips_init_host_alarm (void); void host_alarm (cpu_mips_t *cpu, int nclocks); #endif ================================================ FILE: tools/virtualmips/mips_jit.c ================================================ /* * Copyright (C) yajin 2008 * * This file is part of the virtualmips distribution. * See LICENSE file for terms of the license. * */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include "cpu.h" #include "vm.h" #include "mips_exec.h" #include "mips_memory.h" #include "mips.h" #include "mips_cp0.h" #include "debug.h" #include "vp_timer.h" #include "mips_hostalarm.h" #include "x86_trans.h" #ifdef _USE_JIT_ extern struct mips_jit_desc mips_jit[]; extern cpu_mips_t *current_cpu; jmp_buf run_jmp; static void forced_inline mips_main_loop_wait (cpu_mips_t * cpu, int timeout) { vp_run_timers (&active_timers[VP_TIMER_REALTIME], vp_get_clock (rt_clock)); } /* Initialize the JIT structure */ int mips_jit_init (cpu_mips_t * cpu) { insn_exec_page_t *cp; u_char *cp_addr; u_int area_size; size_t len; int i; /* Physical mapping for executable pages */ len = MIPS_JIT_PC_HASH_SIZE * sizeof (void *); cpu->exec_blk_map = m_memalign (4096, len); memset (cpu->exec_blk_map, 0, len); /* Get area size */ area_size = MIPS_EXEC_AREA_SIZE; /* Create executable page area */ cpu->exec_page_area_size = area_size * 1048576; cpu->exec_page_area = mmap (NULL, cpu->exec_page_area_size, PROT_EXEC | PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANON, -1, (off_t) 0); if (!cpu->exec_page_area) { fprintf (stderr, "mips_jit_init: unable to create exec area (size %lu)\n", (u_long) cpu->exec_page_area_size); return (-1); } /* Carve the executable page area */ cpu->exec_page_count = cpu->exec_page_area_size / MIPS_JIT_BUFSIZE; cpu->exec_page_array = calloc (cpu->exec_page_count, sizeof (insn_exec_page_t)); if (!cpu->exec_page_array) { fprintf (stderr, "mips_jit_init: unable to create exec page array\n"); return (-1); } for (i = 0, cp_addr = cpu->exec_page_area; i < cpu->exec_page_count; i++) { cp = &cpu->exec_page_array[i]; cp->ptr = cp_addr; cp_addr += MIPS_JIT_BUFSIZE; cp->next = cpu->exec_page_free_list; cpu->exec_page_free_list = cp; } printf ("CPU%u: carved JIT exec zone of %lu Mb into %lu pages of %u Kb.\n", cpu->id, (u_long) (cpu->exec_page_area_size / 1048576), (u_long) cpu->exec_page_count, MIPS_JIT_BUFSIZE / 1024); return (0); } /* Flush the JIT */ int mips_jit_flush (cpu_mips_t * cpu, m_uint32_t threshold) { mips_jit_tcb_t *p, *next; m_uint32_t pc_hash; u_int count = 0; m_uint32_t flush_threadhold = 0; if (threshold == 0) flush_threadhold = (m_uint32_t) (0xffffffff); for (p = cpu->tcb_list; p; p = next) { next = p->next; if ((m_uint32_t) p->acc_count <= flush_threadhold) { pc_hash = mips_jit_get_pc_hash (cpu, p->start_pc); cpu->exec_blk_map[pc_hash] = NULL; mips_jit_tcb_free (cpu, p, TRUE); count++; } } cpu->compiled_pages -= count; return (count); } /* Shutdown the JIT */ void mips_jit_shutdown (cpu_mips_t * cpu) { mips_jit_tcb_t *p, *next; /* Flush the JIT */ mips_jit_flush (cpu, 0); /* Free the instruction blocks */ for (p = cpu->tcb_free_list; p; p = next) { next = p->next; free (p); } /* Unmap the executable page area */ if (cpu->exec_page_area) munmap (cpu->exec_page_area, cpu->exec_page_area_size); /* Free the exec page array */ free (cpu->exec_page_array); /* Free physical mapping for executable pages */ free (cpu->exec_blk_map); } /* Allocate an exec page */ static forced_inline insn_exec_page_t *exec_page_alloc (cpu_mips_t * cpu) { insn_exec_page_t *p; u_int count; /* If the free list is empty, flush JIT */ if (unlikely (!cpu->exec_page_free_list)) { if (cpu->jit_flush_method) { mips_jit_flush (cpu, 0); } else { count = mips_jit_flush (cpu, 100); if (!cpu->exec_page_free_list) mips_jit_flush (cpu, 0); } /* Use both methods alternatively */ cpu->jit_flush_method = 1 - cpu->jit_flush_method; } if (unlikely (!(p = cpu->exec_page_free_list))) { return NULL; } cpu->exec_page_free_list = p->next; cpu->exec_page_alloc++; return p; } /* Free an exec page and returns it to the pool */ static forced_inline void exec_page_free (cpu_mips_t * cpu, insn_exec_page_t * p) { if (p) { p->next = cpu->exec_page_free_list; cpu->exec_page_free_list = p; cpu->exec_page_alloc--; } } /* Fetch a MIPS instruction */ static forced_inline mips_insn_t insn_fetch (mips_jit_tcb_t * b) { return (vmtoh32 (b->mips_code[b->mips_trans_pos])); } #ifdef DEBUG_JIT void fastcall jit_debug (cpu_mips_t * cpu, mips_jit_tcb_t * block) { /*Put the debug code here. */ } #endif /*What is the meaning of delay_slot? Search the whole project and you will find delay_slot can be 0/1/2. 0: we are translating the instruction not in delay slot. 1: we are translating the instruction in delay and update mips_trans_pos. 2: we are translating the instruction in delay and NOT update mips_trans_pos. */ /* Fetch a MIPS instruction and emit corresponding translated code */ int mips_jit_fetch_and_emit (cpu_mips_t * cpu, mips_jit_tcb_t * block, int delay_slot) { mips_insn_t code; register uint op; code = insn_fetch (block); op = MAJOR_OP (code); /* Branch-delay slot is in another page: slow exec */ if ((block->mips_trans_pos == (MIPS_INSN_PER_PAGE - 1)) && (insn_is_jmp (code))) { block->jit_insn_ptr[block->mips_trans_pos] = block->jit_ptr; mips_set_pc (block, block->start_pc + (block->mips_trans_pos << 2)); mips_emit_single_step (block, code); mips_jit_tcb_push_epilog (block); block->mips_trans_pos++; return (0); } if (!delay_slot) block->jit_insn_ptr[block->mips_trans_pos] = block->jit_ptr; if (delay_slot == 0) block->mips_trans_pos++; #ifdef DEBUG_JIT m_uint32_t jit_pc; if (delay_slot == 0) jit_pc = block->start_pc + ((block->mips_trans_pos - 1) << 2); else jit_pc = block->start_pc + ((block->mips_trans_pos) << 2); x86_mov_membase_imm (block->jit_ptr, X86_EDI, OFFSET (cpu_mips_t, jit_pc), jit_pc, 4); x86_mov_reg_reg (block->jit_ptr, X86_EAX, X86_EDI, 4); x86_mov_reg_imm (block->jit_ptr, X86_EDX, block); mips_emit_basic_c_call (block, jit_debug); #endif if (delay_slot && insn_is_jmp (code)) { /*why a jump instruction in a delay slot??? yajin * * --------- * |CODE | * |-------| * | DATA | * --------- * * When data and code is in one page and we translate a page once. * Emulator does not know where is data and where is code. So it just translate the whole * page. * data : 504f4e4d (jmp) * data : 54535251 (jmp TOO) * So 54535251 is in delay slot of 504f4e4d. * We just add mips_trans_pos and return. * TODO: a better method is to stop tranlating the page. * */ if (delay_slot == 1) block->mips_trans_pos++; return (0); } if (!delay_slot) { /* Check for IRQs and cpu pausing before jumps */ if (insn_is_jmp (code)) { mips_check_cpu_pausing (block); mips_check_pending_irq (block); } } /*set is_in_bdslot*/ if ((delay_slot == 1) || (delay_slot == 2)) x86_mov_membase_imm (block->jit_ptr, X86_EDI, OFFSET (cpu_mips_t, is_in_bdslot), 0x1, 4); mips_jit[op].emit_func (cpu, block, code); /*clear is_in_bdslot*/ if ((delay_slot == 1) || (delay_slot == 2)) x86_mov_membase_imm (block->jit_ptr, X86_EDI, OFFSET (cpu_mips_t, is_in_bdslot), 0x0, 4); if (delay_slot == 1) block->mips_trans_pos++; return (0); } /* Add end of JIT block */ static forced_inline void mips_jit_tcb_add_end (mips_jit_tcb_t * b) { mips_set_pc (b, b->start_pc + (b->mips_trans_pos << 2)); mips_jit_tcb_push_epilog (b); } /* Record a patch to apply in a compiled block */ int mips_jit_tcb_record_patch (mips_jit_tcb_t * block, u_char * jit_ptr, m_va_t vaddr) { struct mips_jit_patch_table *ipt = block->patch_table; struct mips_insn_patch *patch; /* pc must be 32-bit aligned */ if (vaddr & 0x03) { fprintf (stderr, "Block 0x%8.8" LL "x: trying to record an invalid PC " "(0x%8.8" LL "x) - mips_trans_pos=%d.\n", block->start_pc, vaddr, block->mips_trans_pos); return (-1); } if (!ipt || (ipt->cur_patch >= MIPS64_INSN_PATCH_TABLE_SIZE)) { /* full table or no table, create a new one */ ipt = malloc (sizeof (*ipt)); if (!ipt) { fprintf (stderr, "Block 0x%8.8" LL "x: unable to create patch table.\n", block->start_pc); return (-1); } memset (ipt, 0, sizeof (*ipt)); ipt->next = block->patch_table; block->patch_table = ipt; } #if DEBUG_BLOCK_PATCH printf ("Block 0x%8.8llx: recording patch [JIT:%p->mips:0x%8.8llx], " "MTP=%d\n", block->start_pc, jit_ptr, vaddr, block->mips_trans_pos); #endif patch = &ipt->patches[ipt->cur_patch]; patch->jit_insn = jit_ptr; patch->mips_pc = vaddr; ipt->cur_patch++; return (0); } /* Apply all patches */ static int mips_jit_tcb_apply_patches (cpu_mips_t * cpu, mips_jit_tcb_t * block) { struct mips_jit_patch_table *ipt; struct mips_insn_patch *patch; u_char *jit_dst; int i; for (ipt = block->patch_table; ipt; ipt = ipt->next) for (i = 0; i < ipt->cur_patch; i++) { patch = &ipt->patches[i]; jit_dst = mips_jit_tcb_get_host_ptr (block, patch->mips_pc); if (jit_dst) { #if DEBUG_BLOCK_PATCH printf ("Block 0x%8.8llx: applying patch " "[JIT:%p->mips:0x%8.8llx=JIT:%p]\n", block->start_pc, patch->jit_insn, patch->mips_pc, jit_dst); #endif mips_jit_tcb_set_patch (patch->jit_insn, jit_dst); } } return (0); } /* Free the patch table */ static void mips_jit_tcb_free_patches (mips_jit_tcb_t * block) { struct mips_jit_patch_table *p, *next; for (p = block->patch_table; p; p = next) { next = p->next; free (p); } block->patch_table = NULL; } /* Adjust the JIT buffer if its size is not sufficient */ static int mips_jit_tcb_adjust_buffer (cpu_mips_t * cpu, mips_jit_tcb_t * block) { insn_exec_page_t *new_buffer; if ((block->jit_ptr - block->jit_buffer->ptr) <= (MIPS_JIT_BUFSIZE - 512)) return (0); #if DEBUG_BLOCK_CHUNK printf ("Block 0x%" LL "x: adjusting JIT buffer...\n", block->start_pc); #endif if (block->jit_chunk_pos >= MIPS_JIT_MAX_CHUNKS) { fprintf (stderr, "Block 0x%" LL "x: too many JIT chunks.\n", block->start_pc); return (-1); } if (!(new_buffer = exec_page_alloc (cpu))) return (-1); /* record the new exec page */ block->jit_chunks[block->jit_chunk_pos++] = block->jit_buffer; block->jit_buffer = new_buffer; /* jump to the new exec page (link) */ mips_jit_tcb_set_jump (block->jit_ptr, new_buffer->ptr); block->jit_ptr = new_buffer->ptr; return (0); } /* Allocate an instruction block */ static inline mips_jit_tcb_t *mips_jit_tcb_alloc (cpu_mips_t * cpu) { mips_jit_tcb_t *p; if (cpu->tcb_free_list) { p = cpu->tcb_free_list; cpu->tcb_free_list = p->next; } else { if (!(p = malloc (sizeof (*p)))) { return NULL; } } memset (p, 0, sizeof (*p)); return p; } /* Free an instruction block */ void mips_jit_tcb_free (cpu_mips_t * cpu, mips_jit_tcb_t * block, int list_removal) { int i; if (block) { if (list_removal) { /* Remove the block from the linked list */ if (block->next) block->next->prev = block->prev; else cpu->tcb_last = block->prev; if (block->prev) block->prev->next = block->next; else cpu->tcb_list = block->next; } /* Free the patch tables */ mips_jit_tcb_free_patches (block); /* Free code pages */ for (i = 0; i < MIPS_JIT_MAX_CHUNKS; i++) exec_page_free (cpu, block->jit_chunks[i]); /* Free the current JIT buffer */ exec_page_free (cpu, block->jit_buffer); /* Free the MIPS-to-native code mapping */ free (block->jit_insn_ptr); /* Make the block return to the free list */ block->next = cpu->tcb_free_list; cpu->tcb_free_list = block; } } #ifdef DEBUG_JIT /*get the tcb count*/ static void mips_jit_count_tcb (cpu_mips_t * cpu) { unsigned int i = 0; insn_exec_page_t *p1; p1 = cpu->exec_page_free_list; while (p1 != NULL) { p1 = p1->next; i++; } printf ("FREE PAGES %x \n", i); i = 0; mips_jit_tcb_t *tcb1; tcb1 = cpu->tcb_list; while (tcb1 != NULL) { tcb1 = tcb1->next; i++; } printf ("tcb list %x \n", i); i = 0; tcb1 = cpu->tcb_free_list; while (tcb1 != NULL) { tcb1 = tcb1->next; i++; } printf ("tcb free list %x \n", i); } #endif /* Create an instruction block */ static mips_jit_tcb_t *mips_jit_tcb_create (cpu_mips_t * cpu, m_va_t vaddr) { mips_jit_tcb_t *block = NULL; m_uint32_t asid; if (!(block = mips_jit_tcb_alloc (cpu))) goto err_block_alloc; block->start_pc = vaddr; int zone = (vaddr >> 29) & 0x7; if ((zone == 0x4) || (zone == 0x5)) { } else { mips_cp0_t *cp0 = &cpu->cp0; asid = cp0->reg[MIPS_CP0_TLB_HI] & MIPS_TLB_ASID_MASK; block->asid = asid; } /* Allocate the first JIT buffer */ if (!(block->jit_buffer = exec_page_alloc (cpu))) goto err_jit_alloc; block->jit_ptr = block->jit_buffer->ptr; block->mips_code = cpu->mem_op_lookup (cpu, block->start_pc); if (!block->mips_code) { /*TLB Exception */ int zone = (block->start_pc >> 29) & 0x7; switch (zone) { case 0x0: case 0x1: case 0x2: case 0x3: case 0x6: case 0x7: /*Return the tcb to tcb free list */ cpu->exec_blk_map[mips_jit_get_pc_hash (cpu, block->start_pc)] = NULL; mips_jit_tcb_free (cpu, block, FALSE); longjmp (run_jmp, 1); break; default: fprintf (stderr, "No memory map for code execution at 0x%" LL "x\n", block->start_pc); goto err_lookup; } } return block; err_lookup: err_jit_alloc: mips_jit_tcb_free (cpu, block, FALSE); err_block_alloc: fprintf (stderr, "%% Unable to create instruction block for vaddr=0x%" LL "x\n", vaddr); return NULL; } /* Compile a MIPS instruction page */ static inline mips_jit_tcb_t * mips_jit_tcb_compile (cpu_mips_t * cpu, m_va_t vaddr) { mips_jit_tcb_t *block; m_uint64_t page_addr; size_t len; page_addr = vaddr & ~(m_uint64_t) MIPS_MIN_PAGE_IMASK; if (unlikely (!(block = mips_jit_tcb_create (cpu, page_addr)))) { fprintf (stderr, "insn_page_compile: unable to create JIT block.\n"); return NULL; } /* Allocate the array used to convert MIPS code ptr to native code ptr */ len = MIPS_MIN_PAGE_SIZE / sizeof (mips_insn_t); if (!(block->jit_insn_ptr = calloc (len, sizeof (u_char *)))) { fprintf (stderr, "insn_page_compile: unable to create JIT mappings.\n"); goto error; } /* Emit native code for each instruction */ block->mips_trans_pos = 0; while (block->mips_trans_pos < MIPS_INSN_PER_PAGE) { if (unlikely ((mips_jit_fetch_and_emit (cpu, block, 0) == -1))) { fprintf (stderr, "insn_page_compile: unable to fetch instruction.\n"); goto error; } #if DEBUG_BLOCK_COMPILE printf ("Page 0x%8.8" LL "x: emitted tag 0x%8.8x/0x%8.8x\n", block->start_pc, tag->mask, tag->value); #endif mips_jit_tcb_adjust_buffer (cpu, block); } mips_jit_tcb_add_end (block); mips_jit_tcb_apply_patches (cpu, block); mips_jit_tcb_free_patches (block); /* Add the block to the linked list */ block->next = cpu->tcb_list; block->prev = NULL; if (cpu->tcb_list) cpu->tcb_list->prev = block; else cpu->tcb_last = block; cpu->tcb_list = block; cpu->compiled_pages++; return block; error: mips_jit_tcb_free (cpu, block, FALSE); return NULL; } /* Run a compiled MIPS instruction block */ static forced_inline void mips_jit_tcb_run (cpu_mips_t * cpu, mips_jit_tcb_t * block) { if (unlikely (cpu->pc & 0x03)) { fprintf (stderr, "mips_jit_tcb_run: Invalid PC 0x%" LL "x.\n", cpu->pc); cpu_stop (cpu); return; } /* Execute JIT compiled code */ mips_jit_tcb_exec (cpu, block); } void *mips_jit_run_cpu (cpu_mips_t * cpu) { m_uint32_t pc_hash; mips_jit_tcb_t *block; cpu->cpu_thread_running = TRUE; current_cpu = cpu; mips_init_host_alarm (); setjmp (run_jmp); start_cpu: for (;;) { if (unlikely (cpu->state != CPU_STATE_RUNNING)) break; if (unlikely ((cpu->pause_request) & CPU_INTERRUPT_EXIT)) { cpu->state = CPU_STATE_PAUSING; break; } /* Reset "zero register" (for safety) */ cpu->gpr[0] = 0; /* Check IRQ */ if (unlikely (cpu->irq_pending)) { mips_trigger_irq (cpu); //continue; } pc_hash = mips_jit_get_pc_hash (cpu, cpu->pc); block = cpu->exec_blk_map[pc_hash]; /* No block found, compile the page */ if (unlikely (!block) || unlikely (!mips_jit_tcb_match (cpu, block, cpu->pc))) { if (block != NULL) { mips_jit_tcb_free (cpu, block, TRUE); cpu->exec_blk_map[pc_hash] = NULL; } block = mips_jit_tcb_compile (cpu, cpu->pc); if (unlikely (!block)) { fprintf (stderr, "VM '%s': unable to compile block for CPU%u PC=0x%" LL "x\n", cpu->vm->name, cpu->id, cpu->pc); cpu_stop (cpu); break; } block->acc_count++; cpu->exec_blk_map[pc_hash] = block; } mips_jit_tcb_run (cpu, block); } while (cpu->cpu_thread_running) { switch (cpu->state) { case CPU_STATE_RUNNING: cpu->state = CPU_STATE_RUNNING; goto start_cpu; case CPU_STATE_HALTED: cpu->cpu_thread_running = FALSE; break; case CPU_STATE_RESTARTING: cpu->state = CPU_STATE_RESTARTING; /*Just waiting for cpu restart. */ break; case CPU_STATE_PAUSING: /*main loop must wait for me. heihei :) */ mips_main_loop_wait (cpu, 0); cpu->state = CPU_STATE_RUNNING; cpu->pause_request &= ~CPU_INTERRUPT_EXIT; /*start cpu again */ goto start_cpu; } } return NULL; } #endif ================================================ FILE: tools/virtualmips/mips_jit.h ================================================ /* * Copyright (C) yajin 2008 * * This file is part of the virtualmips distribution. * See LICENSE file for terms of the license. * */ /* JIT Support. In order to improve the simulation speed, JIT is always used in simulators. Unlike the JIT of high language, virtualmips does not have basic block. It translates one page(4K) code one time and then run it. Problems: 1. code fetch exception 2. delay slot 3. interrupt emulation 4. Self-modify code 5. debug JIT How to debug JIT is the most tricky problem. I do not have better method, but just logging and comparing with interpreter. Thanks to the file diff tools. If you know how to debug JIT, please tell me. Most of the code is stripped from Dynamips. Thanks Christophe Fillot. Many optimation chances exist. 1. add asid as a hash key of translated block so that translated block is not fushed too often. 2. A better way to find translated block. red-block tree?? 3. peephole optimation??? 4. Use profile tools such as vtune to find the hot path and then optimize it. */ #ifndef __MIPS64_JIT_H__ #define __MIPS64_JIT_H__ #include "system.h" #include "utils.h" #include "sbox.h" #include "mips.h" #include "mips_memory.h" #ifndef _USE_JIT_ #define JIT_SUPPORT 0 #endif #ifdef _USE_JIT_ #define JIT_SUPPORT 1 /* Size of executable page area (in Mb) */ #ifndef __CYGWIN__ #define MIPS_EXEC_AREA_SIZE 64 #else #define MIPS_EXEC_AREA_SIZE 16 #endif /* Buffer size for JIT code generation */ #define MIPS_JIT_BUFSIZE 32768 /* Maximum number of X86 chunks */ #define MIPS_JIT_MAX_CHUNKS 32 /* Size of hash for PC lookup */ #define MIPS_JIT_PC_HASH_BITS 16 #define MIPS_JIT_PC_HASH_MASK ((1 << MIPS_JIT_PC_HASH_BITS) - 1) #define MIPS_JIT_PC_HASH_SIZE (1 << MIPS_JIT_PC_HASH_BITS) /* Instruction jump patch */ struct mips_insn_patch { u_char *jit_insn; m_uint64_t mips_pc; }; /* Instruction patch table */ #define MIPS64_INSN_PATCH_TABLE_SIZE 32 struct mips_jit_patch_table { struct mips_insn_patch patches[MIPS64_INSN_PATCH_TABLE_SIZE]; u_int cur_patch; struct mips_jit_patch_table *next; }; /* Host executable page */ struct insn_exec_page { u_char *ptr; insn_exec_page_t *next; }; /* MIPS64 translated code block */ struct mips_jit_tcb { /*start pc in tcb */ m_va_t start_pc; m_uint32_t asid; m_uint32_t acc_count; /*guest pc to host pc mapping table */ u_char **jit_insn_ptr; /*guest code of this tcb */ mips_insn_t *mips_code; u_int mips_trans_pos; u_int jit_chunk_pos; /*used in translating */ u_char *jit_ptr; insn_exec_page_t *jit_buffer; insn_exec_page_t *jit_chunks[MIPS_JIT_MAX_CHUNKS]; struct mips_jit_patch_table *patch_table; mips_jit_tcb_t *prev, *next; }; int mips_jit_init (cpu_mips_t * cpu); int mips_jit_flush (cpu_mips_t * cpu, m_uint32_t threshold); void mips_jit_shutdown (cpu_mips_t * cpu); int mips_jit_fetch_and_emit (cpu_mips_t * cpu, mips_jit_tcb_t * block, int delay_slot); int mips_jit_tcb_record_patch (mips_jit_tcb_t * block, u_char * jit_ptr, m_va_t vaddr); void mips_jit_tcb_free (cpu_mips_t * cpu, mips_jit_tcb_t * block, int list_removal); void *mips_jit_run_cpu (cpu_mips_t * cpu); /*-----------inline functions-----------------------------*/ /* Get the JIT instruction pointer in a translated block */ static forced_inline u_char * mips_jit_tcb_get_host_ptr (mips_jit_tcb_t * b, m_va_t vaddr) { m_uint32_t offset; offset = ((m_uint32_t) vaddr & MIPS_MIN_PAGE_IMASK) >> 2; return (b->jit_insn_ptr[offset]); } /* Check if the specified address belongs to the specified block */ static forced_inline int mips_jit_tcb_local_addr (mips_jit_tcb_t * block, m_va_t vaddr, u_char ** jit_addr) { if ((vaddr & MIPS_MIN_PAGE_MASK) == block->start_pc) { *jit_addr = mips_jit_tcb_get_host_ptr (block, vaddr); return (1); } return (0); } extern int test33; /* Check if PC register matches the compiled block virtual address */ static forced_inline int mips_jit_tcb_match (cpu_mips_t * cpu, mips_jit_tcb_t * block, m_va_t vaddr) { m_va_t vpage; // vpage = cpu->pc & ~(m_va_t)MIPS_MIN_PAGE_IMASK; vpage = vaddr & ~(m_va_t) MIPS_MIN_PAGE_IMASK; if (block->start_pc != vpage) return 0; /*block->start_pc == vpage */ if (!vaddr_mapped (vaddr)) return 1; /*block->start_pc == vpage and mapped.check asid */ int asid = cpu->cp0.reg[MIPS_CP0_TLB_HI] & MIPS_TLB_ASID_MASK; return (block->asid == asid); } /* Compute the hash index for the specified PC value */ /*TODO: Add asid as a hash key. Currently same pc of different asid will get the same hash value. */ static forced_inline m_uint32_t mips_jit_get_pc_hash (cpu_mips_t * cpu, m_va_t pc) { m_uint32_t page_hash; page_hash = sbox_u32 (pc >> MIPS_MIN_PAGE_SHIFT); return ((page_hash ^ (page_hash >> 12)) & MIPS_JIT_PC_HASH_MASK); } /*if the code write to code region, flush the translated page*/ static forced_inline void jit_handle_self_write (cpu_mips_t * cpu, m_va_t vaddr) { m_uint32_t pc_hash; mips_jit_tcb_t *block; pc_hash = mips_jit_get_pc_hash (cpu, vaddr); block = cpu->exec_blk_map[pc_hash]; if (block != NULL) { if (unlikely (mips_jit_tcb_match (cpu, block, vaddr))) { mips_jit_tcb_free (cpu, block, TRUE); cpu->exec_blk_map[pc_hash] = NULL; } } } /*whether instruction is a jump instruction*/ static forced_inline int insn_is_jmp (unsigned int insn) { /*can insn be in delay slot */ int op = MAJOR_OP (insn); uint16_t special_func; switch (op) { case 0x0: { special_func = bits (insn, 0, 5); switch (special_func) { case 0x8: case 0x9: return 1; default: return 0; } } case 0x1: { special_func = bits (insn, 16, 20); switch (special_func) { case 0x0: case 0x1: case 0x2: case 0x3: case 0x4: case 0x10: case 0x11: case 0x12: case 0x13: return 1; default: return 0; } } case 0x2: case 0x3: case 0x4: case 0x5: case 0x6: case 0x7: case 0x14: case 0x15: case 0x16: case 0x17: return 1; default: return 0; } } /* Check if an instruction is in a delay slot or not */ static forced_inline int mips_jit_is_delay_slot (mips_jit_tcb_t * b, m_va_t pc) { m_uint32_t offset, insn; offset = (pc - b->start_pc) >> 2; if (!offset) return (FALSE); ASSERT (b->mips_code != NULL, "b->mips_code can not be NULL\n"); /* Fetch the previous instruction to determine if it is a jump */ insn = vmtoh32 (b->mips_code[offset - 1]); return insn_is_jmp (insn); } #endif #endif ================================================ FILE: tools/virtualmips/mips_memory.c ================================================ /* * Cisco router simulation platform. * Copyright (c) 2005,2006 Christophe Fillot (cf@utc.fr) * Copyright (C) yajin 2008 * * This file is part of the virtualmips distribution. * See LICENSE file for terms of the license. */ #include #include #include #include #include #include #include #include #include #include "cpu.h" #include "vm.h" #include "mips_memory.h" #include "device.h" #include "utils.h" #include "mips_cp0.h" #include "gdb_interface.h" #include "mips_jit.h" void bad_memory_access (cpu_mips_t * cpu, m_va_t vaddr) { mips_insn_t insn; printf ("*** %08x: bad memory reference\n", vaddr); if (mips_fetch_instruction (cpu, cpu->pc, &insn) == 0) { printf ("*** %08x: %08x ", cpu->pc, insn); print_mips (cpu->pc, insn, cpu->insn_len, cpu->is_mips16e, stdout); printf ("\n"); } if (mips_fetch_instruction (cpu, cpu->pc + 4, &insn) == 0) { printf ("*** %08x: %08x ", cpu->pc + 4, insn); print_mips (cpu->pc, insn, cpu->insn_len, cpu->is_mips16e, stdout); printf ("\n"); } dumpregs (cpu); if (cpu->vm->mipsy_debug_mode) bad_memory_access_gdb (cpu->vm); else assert (0); } /* * MTS access with special access mask */ void mips_access_special (cpu_mips_t * cpu, m_va_t vaddr, m_uint32_t mask, u_int op_code, u_int op_type, u_int op_size, m_reg_t * data, u_int * exc) { m_reg_t vpn; m_uint8_t exc_code; switch (mask) { case MTS_ACC_U: if (op_type == MTS_READ) *data = 0; break; case MTS_ACC_T: case MTS_ACC_M: case MTS_ACC_AE: //if (op_code != MIPS_MEMOP_LOOKUP) //lookup also raise exception { cpu->cp0.reg[MIPS_CP0_BADVADDR] = vaddr; //clear vpn of entry hi cpu->cp0.reg[MIPS_CP0_TLB_HI] &= ~(mips_cp0_get_vpn2_mask (cpu)); //set VPN of entryhi vpn = vaddr & mips_cp0_get_vpn2_mask (cpu); cpu->cp0.reg[MIPS_CP0_TLB_HI] |= vpn; //set context register cpu->cp0.reg[MIPS_CP0_CONTEXT] &= ~MIPS_CP0_CONTEXT_BADVPN2_MASK; vaddr = (vaddr >> 13) << 4; vaddr = vaddr & MIPS_CP0_CONTEXT_BADVPN2_MASK; cpu->cp0.reg[MIPS_CP0_CONTEXT] |= vaddr; #ifdef SIM_PIC32 if (op_type == MTS_READ) exc_code = MIPS_CP0_CAUSE_ADDR_LOAD; else exc_code = MIPS_CP0_CAUSE_ADDR_SAVE; #else if (mask == MTS_ACC_M) exc_code = MIPS_CP0_CAUSE_TLB_MOD; else if (mask == MTS_ACC_T) { if (op_type == MTS_READ) exc_code = MIPS_CP0_CAUSE_TLB_LOAD; else exc_code = MIPS_CP0_CAUSE_TLB_SAVE; } else if (mask == MTS_ACC_AE) { if (op_type == MTS_READ) exc_code = MIPS_CP0_CAUSE_ADDR_LOAD; else exc_code = MIPS_CP0_CAUSE_ADDR_SAVE; } else assert (0); #endif mips_trigger_exception (cpu, exc_code, cpu->is_in_bdslot); } *exc = 1; break; } } /* === MTS for 32-bit address space ======================================= */ #ifdef MTS_ADDR_SIZE #undef MTS_ADDR_SIZE #endif #define MTS_ADDR_SIZE 32 static int mips_mts32_translate (cpu_mips_t * cpu, m_va_t vaddr, m_uint32_t * phys_page); /* * Initialize the MTS subsystem for the specified CPU */ int mips_mts32_init (cpu_mips_t * cpu) { size_t len; /* Initialize the cache entries to 0 (empty) */ len = MTS32_HASH_SIZE * sizeof (mts32_entry_t); cpu->mts_u.mts32_cache = malloc (len); if (! cpu->mts_u.mts32_cache) return (-1); memset (cpu->mts_u.mts32_cache, 0xFF, len); cpu->mts_lookups = 0; cpu->mts_misses = 0; return (0); } /* Free memory used by MTS */ void mips_mts32_shutdown (cpu_mips_t * cpu) { /* Free the cache itself */ free (cpu->mts_u.mts32_cache); cpu->mts_u.mts32_cache = NULL; } /* Show MTS detailed information (debugging only!) */ void mips_mts32_show_stats (cpu_mips_t * cpu) { #if DEBUG_MTS_MAP_VIRT mts32_entry_t *entry; u_int i, count; #endif printf ("\nCPU%u: MTS%d statistics:\n", cpu->id, MTS_ADDR_SIZE); #if DEBUG_MTS_MAP_VIRT /* Valid hash entries */ for (count = 0, i = 0; i < MTS32_HASH_SIZE; i++) { entry = &(cpu->mts_u.mts32_cache[i]); if (!(entry->gvpa & MTS_INV_ENTRY_MASK)) { printf (" %4u: vaddr=0x%8.8llx, paddr=0x%8.8llx, hpa=%p\n", i, (m_uint64_t) entry->gvpa, (m_uint64_t) entry->gppa, (void *) entry->hpa); count++; } } printf (" %u/%u valid hash entries.\n", count, MTS32_HASH_SIZE); #endif printf (" Total lookups: %llu, misses: %llu, efficiency: %g%%\n", (unsigned long long)cpu->mts_lookups, (unsigned long long)cpu->mts_misses, 100 - ((double) (cpu->mts_misses * 100) / (double) cpu->mts_lookups)); } /* Invalidate the complete MTS cache */ void mips_mts32_invalidate_cache (cpu_mips_t * cpu) { size_t len; len = MTS32_HASH_SIZE * sizeof (mts32_entry_t); memset (cpu->mts_u.mts32_cache, 0xFF, len); } /* Invalidate partially the MTS cache, given a TLB entry index */ void mips_mts32_invalidate_tlb_entry (cpu_mips_t * cpu, m_va_t vaddr) { mts32_entry_t *entry; m_uint32_t hash_bucket; hash_bucket = MTS32_HASH (vaddr); entry = &cpu->mts_u.mts32_cache[hash_bucket]; memset (entry, 0xFF, sizeof (mts32_entry_t)); } /* * MTS mapping. * * It is NOT inlined since it triggers a GCC bug on my config (x86, GCC 3.3.5) */ static no_inline mts32_entry_t *mips_mts32_map (cpu_mips_t * cpu, u_int op_type, mts_map_t * map, mts32_entry_t * entry, mts32_entry_t * alt_entry, u_int is_fromgdb) { struct vdevice *dev; m_uint32_t offset; dev = dev_lookup (cpu->vm, map->paddr); if (! dev) { if (! is_fromgdb) { printf ("no device!\n"); printf ("cpu->pc %x vaddr %x paddr %x \n", cpu->pc, map->vaddr, map->paddr); exit (-1); } return NULL; } if (! dev->host_addr || (dev->flags & VDEVICE_FLAG_NO_MTS_MMAP)) { offset = map->paddr - dev->phys_addr; alt_entry->gvpa = map->vaddr; alt_entry->gppa = map->paddr; alt_entry->hpa = (dev->id << MTS_DEVID_SHIFT) + offset; alt_entry->flags = MTS_FLAG_DEV; alt_entry->mapped = map->mapped; return alt_entry; } ASSERT (dev->host_addr != 0, "dev->host_addr can not be null\n"); entry->gvpa = map->vaddr; entry->gppa = map->paddr; entry->hpa = dev->host_addr + (map->paddr - dev->phys_addr); entry->flags = 0; entry->asid = map->asid; entry->g_bit = map->g_bit; entry->dirty_bit = map->dirty; entry->mapped = map->mapped; return entry; } /* MTS lookup */ static fastcall void *mips_mts32_lookup (cpu_mips_t * cpu, m_va_t vaddr) { m_reg_t data; u_int exc; m_uint8_t has_set_value = FALSE; return (mips_mts32_access (cpu, vaddr, MIPS_MEMOP_LOOKUP, 4, MTS_READ, &data, &exc, &has_set_value, 0)); } /* === MIPS Memory Operations ============================================= */ u_int mips_mts32_gdb_lb (cpu_mips_t * cpu, m_va_t vaddr, void *cur) { // m_reg_t data; void *haddr; u_int exc; m_uint8_t has_set_value = FALSE; haddr = mips_mts32_access (cpu, vaddr, MIPS_MEMOP_LB, 1, MTS_READ, (m_reg_t *) cur, &exc, &has_set_value, 1); if ((exc) || (haddr == NULL)) *(m_uint8_t *) cur = 0x0; else *(m_uint8_t *) cur = (*(m_uint8_t *) haddr); return (0); } /* LB: Load Byte */ u_int fastcall mips_mts32_lb (cpu_mips_t * cpu, m_va_t vaddr, u_int reg) { m_reg_t data; void *haddr; u_int exc; m_uint8_t has_set_value = FALSE; haddr = mips_mts32_access (cpu, vaddr, MIPS_MEMOP_LB, 1, MTS_READ, &data, &exc, &has_set_value, 0); if (exc) return exc; if ((haddr == NULL) && (has_set_value == FALSE)) { bad_memory_access (cpu, vaddr); } if (likely (has_set_value == FALSE)) data = *(m_uint8_t *) haddr; if (likely (!exc)) cpu->reg_set (cpu, reg, sign_extend (data, 8)); return (exc); } /* LBU: Load Byte Unsigned */ u_int fastcall mips_mts32_lbu (cpu_mips_t * cpu, m_va_t vaddr, u_int reg) { m_reg_t data; void *haddr; u_int exc; m_uint8_t has_set_value = FALSE; haddr = mips_mts32_access (cpu, vaddr, MIPS_MEMOP_LBU, 1, MTS_READ, &data, &exc, &has_set_value, 0); if (exc) return exc; if ((haddr == NULL) && (has_set_value == FALSE)) { bad_memory_access (cpu, vaddr); } if (likely (has_set_value == FALSE)) data = *(m_uint8_t *) haddr; if (likely (!exc)) cpu->reg_set (cpu, reg, data & 0xff); return (exc); } /* LH: Load Half-Word */ u_int fastcall mips_mts32_lh (cpu_mips_t * cpu, m_va_t vaddr, u_int reg) { m_reg_t data; void *haddr; u_int exc; m_uint8_t has_set_value = FALSE; haddr = mips_mts32_access (cpu, vaddr, MIPS_MEMOP_LH, 2, MTS_READ, &data, &exc, &has_set_value, 0); if (exc) return exc; if ((haddr == NULL) && (has_set_value == FALSE)) { bad_memory_access (cpu, vaddr); } if (likely (has_set_value == FALSE)) data = vmtoh16 (*(m_uint16_t *) haddr); if (likely (!exc)) cpu->reg_set (cpu, reg, sign_extend (data, 16)); return (exc); } /* LHU: Load Half-Word Unsigned */ u_int fastcall mips_mts32_lhu (cpu_mips_t * cpu, m_va_t vaddr, u_int reg) { m_reg_t data; void *haddr; u_int exc; m_uint8_t has_set_value = FALSE; haddr = mips_mts32_access (cpu, vaddr, MIPS_MEMOP_LHU, 2, MTS_READ, &data, &exc, &has_set_value, 0); if (exc) return exc; if ((haddr == NULL) && (has_set_value == FALSE)) { bad_memory_access (cpu, vaddr); } if (likely (has_set_value == FALSE)) data = vmtoh16 (*(m_uint16_t *) haddr); if (likely (!exc)) cpu->reg_set (cpu, reg, data & 0xffff); return (exc); } /* LW: Load Word */ u_int fastcall mips_mts32_lw (cpu_mips_t * cpu, m_va_t vaddr, u_int reg) { m_reg_t data; void *haddr; u_int exc; m_uint8_t has_set_value = FALSE; haddr = mips_mts32_access (cpu, vaddr, MIPS_MEMOP_LW, 4, MTS_READ, &data, &exc, &has_set_value, 0); if (exc) return exc; if ((haddr == NULL) && (has_set_value == FALSE)) { bad_memory_access (cpu, vaddr); } if (likely (has_set_value == FALSE)) { data = vmtoh32 (*(m_uint32_t *) haddr); } if (likely (!exc)) { if (cpu->vm->debug_level > 2 || (cpu->vm->debug_level > 1 && (cpu->cp0.reg[MIPS_CP0_STATUS] & MIPS_CP0_STATUS_UM) && ! (cpu->cp0.reg[MIPS_CP0_STATUS] & MIPS_CP0_STATUS_EXL) && vaddr >= 0x7f008000 && vaddr < 0x7f020000)) { /* Print memory accesses in user mode. */ printf (" read %08x -> %08x \n", vaddr, data); } cpu->reg_set (cpu, reg, sign_extend (data, 32)); } return (exc); } /* LWU: Load Word Unsigned */ u_int fastcall mips_mts32_lwu (cpu_mips_t * cpu, m_va_t vaddr, u_int reg) { m_reg_t data; void *haddr; u_int exc; m_uint8_t has_set_value = FALSE; haddr = mips_mts32_access (cpu, vaddr, MIPS_MEMOP_LWU, 4, MTS_READ, &data, &exc, &has_set_value, 0); if (exc) return exc; if ((haddr == NULL) && (has_set_value == FALSE)) { bad_memory_access (cpu, vaddr); } if (likely (has_set_value == FALSE)) data = vmtoh32 (*(m_uint32_t *) haddr); if (likely (!exc)) cpu->reg_set (cpu, reg, data & 0xffffffff); return (exc); } /* LD: Load Double-Word */ u_int fastcall mips_mts32_ld (cpu_mips_t * cpu, m_va_t vaddr, u_int reg) { m_reg_t data; void *haddr; u_int exc; m_uint8_t has_set_value = FALSE; haddr = mips_mts32_access (cpu, vaddr, MIPS_MEMOP_LD, 8, MTS_READ, &data, &exc, &has_set_value, 0); if (exc) return exc; if ((haddr == NULL) && (has_set_value == FALSE)) { bad_memory_access (cpu, vaddr); } if (likely (has_set_value == FALSE)) data = vmtoh64 (*(m_uint64_t *) haddr); if (likely (!exc)) cpu->reg_set (cpu, reg, data); return (exc); } /* SB: Store Byte */ u_int fastcall mips_mts32_sb (cpu_mips_t * cpu, m_va_t vaddr, u_int reg) { m_reg_t data; void *haddr = NULL; u_int exc; m_uint8_t has_set_value = FALSE; data = cpu->gpr[reg] & 0xff; haddr = mips_mts32_access (cpu, vaddr, MIPS_MEMOP_SB, 1, MTS_WRITE, &data, &exc, &has_set_value, 0); if (exc) return exc; if ((haddr == NULL) && (has_set_value == FALSE)) { bad_memory_access (cpu, vaddr); } if (likely (has_set_value == FALSE)) { #ifdef _USE_JIT_ if (cpu->vm->jit_use) jit_handle_self_write (cpu, vaddr); #endif *(m_uint8_t *) haddr = data; } return (exc); } /* SH: Store Half-Word */ u_int fastcall mips_mts32_sh (cpu_mips_t * cpu, m_va_t vaddr, u_int reg) { m_reg_t data; void *haddr; u_int exc; m_uint8_t has_set_value = FALSE; data = cpu->gpr[reg] & 0xffff; haddr = mips_mts32_access (cpu, vaddr, MIPS_MEMOP_SH, 2, MTS_WRITE, &data, &exc, &has_set_value, 0); if (exc) return exc; if ((haddr == NULL) && (has_set_value == FALSE)) { bad_memory_access (cpu, vaddr); } if (likely (has_set_value == FALSE)) { #ifdef _USE_JIT_ if (cpu->vm->jit_use) jit_handle_self_write (cpu, vaddr); #endif *(m_uint16_t *) haddr = htovm16 (data); } return (exc); } /* SW: Store Word */ u_int fastcall mips_mts32_sw (cpu_mips_t * cpu, m_va_t vaddr, u_int reg) { m_reg_t data; void *haddr; u_int exc; m_uint8_t has_set_value = FALSE; data = cpu->gpr[reg] & 0xffffffff; haddr = mips_mts32_access (cpu, vaddr, MIPS_MEMOP_SW, 4, MTS_WRITE, &data, &exc, &has_set_value, 0); if (exc) return exc; if ((haddr == NULL) && (has_set_value == FALSE)) { bad_memory_access (cpu, vaddr); } if (likely (has_set_value == FALSE)) { #ifdef _USE_JIT_ if (cpu->vm->jit_use) jit_handle_self_write (cpu, vaddr); #endif *(m_uint32_t *) haddr = htovm32 (data); if (cpu->vm->debug_level > 2 || (cpu->vm->debug_level > 1 && (cpu->cp0.reg[MIPS_CP0_STATUS] & MIPS_CP0_STATUS_UM) && ! (cpu->cp0.reg[MIPS_CP0_STATUS] & MIPS_CP0_STATUS_EXL) && vaddr >= 0x7f008000 && vaddr < 0x7f020000)) { /* Print memory accesses in user mode. */ printf (" write %08x := %08x \n", vaddr, data); } } return (exc); } /* SD: Store Double-Word */ u_int fastcall mips_mts32_sd (cpu_mips_t * cpu, m_va_t vaddr, u_int reg) { m_reg_t data; void *haddr; u_int exc; m_uint8_t has_set_value = FALSE; data = cpu->gpr[reg]; haddr = mips_mts32_access (cpu, vaddr, MIPS_MEMOP_SD, 8, MTS_WRITE, &data, &exc, &has_set_value, 0); if (exc) return exc; if ((haddr == NULL) && (has_set_value == FALSE)) { bad_memory_access (cpu, vaddr); } if (likely (has_set_value == FALSE)) *(m_uint64_t *) haddr = htovm64 (data); return (exc); } /* LDC1: Load Double-Word To Coprocessor 1 */ u_int fastcall mips_mts32_ldc1 (cpu_mips_t * cpu, m_va_t vaddr, u_int reg) { printf ("mips_mts32_ldc1 pc %x\n", cpu->pc); exit (-1); return 0; } u_int fastcall mips_mts32_lwl (cpu_mips_t * cpu, m_va_t vaddr, u_int reg) { void *haddr = NULL; u_int exc; m_uint32_t data, naddr, shift = 0, mask1 = 0, mask2 = 0; m_uint8_t has_set_value = FALSE; naddr = vaddr & ~(0x03); haddr = mips_mts32_access (cpu, naddr, MIPS_MEMOP_LWL, 4, MTS_READ, &data, &exc, &has_set_value, 0); if (exc) return exc; if ((haddr == NULL) && (has_set_value == FALSE)) { bad_memory_access (cpu, vaddr); } if (has_set_value == FALSE) { data = vmtoh32 (*(m_reg_t *) haddr); switch (vaddr & 0x3) { #if GUEST_BYTE_ORDER==ARCH_LITTLE_ENDIAN case 0x0: #elif GUEST_BYTE_ORDER==ARCH_BIG_ENDIAN case 0x3: #endif mask1 = 0xff; mask2 = 0xff000000; shift = 24; break; #if GUEST_BYTE_ORDER==ARCH_LITTLE_ENDIAN case 0x1: #elif GUEST_BYTE_ORDER==ARCH_BIG_ENDIAN case 0x2: #endif mask1 = 0xffff; mask2 = 0xffff0000; shift = 16; break; #if GUEST_BYTE_ORDER==ARCH_LITTLE_ENDIAN case 0x2: #elif GUEST_BYTE_ORDER==ARCH_BIG_ENDIAN case 0x1: #endif mask1 = 0xffffff; mask2 = 0xffffff00; shift = 8; break; #if GUEST_BYTE_ORDER==ARCH_LITTLE_ENDIAN case 0x3: #elif GUEST_BYTE_ORDER==ARCH_BIG_ENDIAN case 0x0: #endif mask1 = 0xffffffff; mask2 = 0xffffffff; shift = 0; break; } data = (data & mask1) << shift; data &= mask2; cpu->gpr[reg] &= ~mask2; cpu->gpr[reg] |= data; cpu->reg_set (cpu, reg, sign_extend (cpu->gpr[reg], 32)); } return 0; } u_int fastcall mips_mts32_lwr (cpu_mips_t * cpu, m_va_t vaddr, u_int reg) { void *haddr = NULL; u_int exc; m_uint32_t data, naddr, shift = 0, mask1 = 0, mask2 = 0; m_uint8_t has_set_value = FALSE; naddr = vaddr & ~(0x03); haddr = mips_mts32_access (cpu, naddr, MIPS_MEMOP_LWR, 4, MTS_READ, &data, &exc, &has_set_value, 0); if (exc) return exc; if ((haddr == NULL) && (has_set_value == FALSE)) { bad_memory_access (cpu, vaddr); } if (has_set_value == FALSE) { data = vmtoh32 (*(m_reg_t *) haddr); switch (vaddr & 0x3) { #if GUEST_BYTE_ORDER==ARCH_LITTLE_ENDIAN case 0x3: #elif GUEST_BYTE_ORDER==ARCH_BIG_ENDIAN case 0x0: #endif mask1 = 0xff; mask2 = 0xff000000; shift = 24; break; #if GUEST_BYTE_ORDER==ARCH_LITTLE_ENDIAN case 0x2: #elif GUEST_BYTE_ORDER==ARCH_BIG_ENDIAN case 0x1: #endif mask1 = 0xffff; mask2 = 0xffff0000; shift = 16; break; #if GUEST_BYTE_ORDER==ARCH_LITTLE_ENDIAN case 0x1: #elif GUEST_BYTE_ORDER==ARCH_BIG_ENDIAN case 0x2: #endif mask1 = 0xffffff; mask2 = 0xffffff00; shift = 8; break; #if GUEST_BYTE_ORDER==ARCH_LITTLE_ENDIAN case 0x0: #elif GUEST_BYTE_ORDER==ARCH_BIG_ENDIAN case 0x3: #endif mask1 = 0xffffffff; mask2 = 0xffffffff; shift = 0; break; } data = (data & mask2) >> shift; data &= mask1; cpu->gpr[reg] &= ~mask1; cpu->gpr[reg] |= data; cpu->reg_set (cpu, reg, sign_extend (cpu->gpr[reg], 32)); } return 0; } /* LDL: Load Double-Word Left */ u_int fastcall mips_mts32_ldl (cpu_mips_t * cpu, m_va_t vaddr, u_int reg) { m_reg_t r_mask, naddr; m_reg_t data; u_int m_shift; void *haddr; u_int exc; m_uint8_t has_set_value = FALSE; naddr = vaddr & ~(0x07); haddr = mips_mts32_access (cpu, naddr, MIPS_MEMOP_LDL, 8, MTS_READ, &data, &exc, &has_set_value, 0); if (exc) return exc; if ((haddr == NULL) && (has_set_value == FALSE)) { bad_memory_access (cpu, vaddr); } if (likely (haddr != NULL)) data = (m_reg_t) (vmtoh64 (*(m_uint64_t *) haddr)); if (likely (!exc)) { m_shift = (vaddr & 0x07) << 3; r_mask = (1ULL << m_shift) - 1; data <<= m_shift; cpu->gpr[reg] &= r_mask; cpu->gpr[reg] |= data; } return (exc); } /* LDR: Load Double-Word Right */ u_int fastcall mips_mts32_ldr (cpu_mips_t * cpu, m_va_t vaddr, u_int reg) { m_reg_t r_mask, naddr; m_reg_t data; u_int m_shift; void *haddr; u_int exc; m_uint8_t has_set_value = FALSE; naddr = vaddr & ~(0x07); haddr = mips_mts32_access (cpu, naddr, MIPS_MEMOP_LDR, 8, MTS_READ, &data, &exc, &has_set_value, 0); if (exc) return exc; if ((haddr == NULL) && (has_set_value == FALSE)) { bad_memory_access (cpu, vaddr); } if (likely (haddr != NULL)) data = (m_reg_t) (vmtoh64 (*(m_uint64_t *) haddr)); if (likely (!exc)) { m_shift = ((vaddr & 0x07) + 1) << 3; r_mask = (1ULL << m_shift) - 1; data >>= (64 - m_shift); cpu->gpr[reg] &= ~r_mask; cpu->gpr[reg] |= data; } return (exc); } u_int fastcall mips_mts32_swl (cpu_mips_t * cpu, m_va_t vaddr, u_int reg) { void *haddr = NULL; u_int exc; m_uint32_t data, naddr, temp, mask1 = 0, mask2 = 0, shift = 0; m_uint8_t has_set_value = FALSE; naddr = vaddr & ~(0x03ULL); data = cpu->gpr[reg] & 0xffffffff; haddr = mips_mts32_access (cpu, naddr, MIPS_MEMOP_SWL, 4, MTS_WRITE, &data, &exc, &has_set_value, 0); if (exc) return exc; if ((haddr == NULL) && (has_set_value == FALSE)) { bad_memory_access (cpu, vaddr); } if (has_set_value == FALSE) { switch (vaddr & 0x3) { #if GUEST_BYTE_ORDER==ARCH_LITTLE_ENDIAN case 0x0: #elif GUEST_BYTE_ORDER==ARCH_BIG_ENDIAN case 0x3: #endif mask1 = 0xff; mask2 = 0xff000000; shift = 24; break; #if GUEST_BYTE_ORDER==ARCH_LITTLE_ENDIAN case 0x1: #elif GUEST_BYTE_ORDER==ARCH_BIG_ENDIAN case 0x2: #endif mask1 = 0xffff; mask2 = 0xffff0000; shift = 16; break; #if GUEST_BYTE_ORDER==ARCH_LITTLE_ENDIAN case 0x2: #elif GUEST_BYTE_ORDER==ARCH_BIG_ENDIAN case 0x1: #endif mask1 = 0xffffff; mask2 = 0xffffff00; shift = 8; break; #if GUEST_BYTE_ORDER==ARCH_LITTLE_ENDIAN case 0x3: #elif GUEST_BYTE_ORDER==ARCH_BIG_ENDIAN case 0x0: #endif mask1 = 0xffffffff; mask2 = 0xffffffff; shift = 0; break; } data = (data & mask2) >> shift; data &= mask1; temp = vmtoh32 (*(m_uint32_t *) haddr); temp &= ~mask1; temp = temp | data; *(m_uint32_t *) haddr = htovm32 (temp); } return 0; } u_int fastcall mips_mts32_swr (cpu_mips_t * cpu, m_va_t vaddr, u_int reg) { void *haddr = NULL; u_int exc; m_uint32_t data, naddr, temp, mask1 = 0, mask2 = 0, shift = 0; m_uint8_t has_set_value = FALSE; naddr = vaddr & ~(0x03ULL); data = cpu->gpr[reg] & 0xffffffff; haddr = mips_mts32_access (cpu, naddr, MIPS_MEMOP_SWR, 4, MTS_WRITE, &data, &exc, &has_set_value, 0); if (exc) return exc; if ((haddr == NULL) && (has_set_value == FALSE)) { bad_memory_access (cpu, vaddr); } if (has_set_value == FALSE) { switch (vaddr & 0x3) { #if GUEST_BYTE_ORDER==ARCH_LITTLE_ENDIAN case 0x3: #elif GUEST_BYTE_ORDER==ARCH_BIG_ENDIAN case 0x0: #endif mask1 = 0xff; mask2 = 0xff000000; shift = 24; break; #if GUEST_BYTE_ORDER==ARCH_LITTLE_ENDIAN case 0x2: #elif GUEST_BYTE_ORDER==ARCH_BIG_ENDIAN case 0x1: #endif mask1 = 0xffff; mask2 = 0xffff0000; shift = 16; break; #if GUEST_BYTE_ORDER==ARCH_LITTLE_ENDIAN case 0x1: #elif GUEST_BYTE_ORDER==ARCH_BIG_ENDIAN case 0x2: #endif mask1 = 0xffffff; mask2 = 0xffffff00; shift = 8; break; #if GUEST_BYTE_ORDER==ARCH_LITTLE_ENDIAN case 0x0: #elif GUEST_BYTE_ORDER==ARCH_BIG_ENDIAN case 0x3: #endif mask1 = 0xffffffff; mask2 = 0xffffffff; shift = 0; break; } data = (data & mask1) << shift; data &= mask2; temp = vmtoh32 (*(m_uint32_t *) haddr); temp &= ~mask2; temp = temp | data; *(m_uint32_t *) haddr = htovm32 (temp); } return 0; } /* SDL: Store Double-Word Left */ u_int fastcall mips_mts32_sdl (cpu_mips_t * cpu, m_va_t vaddr, u_int reg) { m_reg_t d_mask, naddr; m_reg_t data; u_int r_shift; void *haddr; u_int exc; m_uint8_t has_set_value = FALSE; naddr = vaddr & ~(0x07); haddr = mips_mts32_access (cpu, naddr, MIPS_MEMOP_SDL, 8, MTS_READ, &data, &exc, &has_set_value, 0); if (exc) return exc; if ((haddr == NULL) && (has_set_value == FALSE)) { bad_memory_access (cpu, vaddr); } if (unlikely (exc)) return (exc); if (likely (haddr != NULL)) data = (m_reg_t) (vmtoh64 (*(m_uint64_t *) haddr)); r_shift = (vaddr & 0x07) << 3; d_mask = 0xffffffffffffffffULL >> r_shift; data &= ~d_mask; data |= cpu->gpr[reg] >> r_shift; haddr = mips_mts32_access (cpu, naddr, MIPS_MEMOP_SDL, 8, MTS_WRITE, &data, &exc, &has_set_value, 0); if ((haddr == NULL) && (has_set_value == FALSE)) { bad_memory_access (cpu, vaddr); } if (likely (haddr != NULL)) *(m_reg_t *) (m_uint64_t *) haddr = (m_reg_t) (htovm64 (data)); return (exc); } /* SDR: Store Double-Word Right */ u_int fastcall mips_mts32_sdr (cpu_mips_t * cpu, m_va_t vaddr, u_int reg) { m_reg_t d_mask, naddr; m_reg_t data; u_int r_shift; void *haddr; u_int exc; m_uint8_t has_set_value = FALSE; naddr = vaddr & ~(0x07); haddr = mips_mts32_access (cpu, naddr, MIPS_MEMOP_SDR, 8, MTS_READ, &data, &exc, &has_set_value, 0); if (exc) return exc; if ((haddr == NULL) && (has_set_value == FALSE)) { bad_memory_access (cpu, vaddr); } if (unlikely (exc)) return (exc); if (likely (haddr != NULL)) data = vmtoh64 (*(m_uint64_t *) haddr); r_shift = ((vaddr & 0x07) + 1) << 3; d_mask = 0xffffffffffffffffULL >> r_shift; data &= d_mask; data |= cpu->gpr[reg] << (64 - r_shift); haddr = mips_mts32_access (cpu, naddr, MIPS_MEMOP_SDR, 8, MTS_WRITE, &data, &exc, &has_set_value, 0); if ((haddr == NULL) && (has_set_value == FALSE)) { bad_memory_access (cpu, vaddr); } if (likely (haddr != NULL)) *(m_reg_t *) (m_uint64_t *) haddr = (m_reg_t) (htovm64 (data)); return (exc); } /* LL: Load Linked */ u_int fastcall mips_mts32_ll (cpu_mips_t * cpu, m_va_t vaddr, u_int reg) { m_reg_t data; void *haddr; u_int exc; m_uint8_t has_set_value = FALSE; haddr = mips_mts32_access (cpu, vaddr, MIPS_MEMOP_LL, 4, MTS_READ, &data, &exc, &has_set_value, 0); if (exc) return exc; if ((haddr == NULL) && (has_set_value == FALSE)) { bad_memory_access (cpu, vaddr); } if (likely (haddr != NULL)) data = vmtoh32 (*(m_uint32_t *) haddr); if (likely (!exc)) { cpu->reg_set (cpu, reg, sign_extend (data, 32)); cpu->ll_bit = 1; } return (exc); } /* SC: Store Conditional */ u_int fastcall mips_mts32_sc (cpu_mips_t * cpu, m_va_t vaddr, u_int reg) { m_reg_t data; void *haddr; u_int exc = 0; m_uint8_t has_set_value = FALSE; data = cpu->gpr[reg] & 0xffffffff; haddr = mips_mts32_access (cpu, vaddr, MIPS_MEMOP_SC, 4, MTS_WRITE, &data, &exc, &has_set_value, 0); if (exc) return exc; if (cpu->ll_bit) { if ((haddr == NULL) && (has_set_value == FALSE)) { bad_memory_access (cpu, vaddr); } if (likely (haddr != NULL)) *(m_uint32_t *) haddr = htovm32 (data); } if (likely (!exc)) cpu->reg_set (cpu, reg, cpu->ll_bit); return (exc); } /* SDC1: Store Double-Word from Coprocessor 1 */ u_int fastcall mips_mts32_sdc1 (cpu_mips_t * cpu, m_va_t vaddr, u_int reg) { /* m_uint64_t data; * void *haddr; * u_int exc; * m_uint8_t has_set_value=FALSE; * * * data = cpu->fpu.reg[reg]; * haddr = mips_mts32_access(cpu,vaddr,MIPS_MEMOP_SDC1,8,MTS_WRITE, * &data,&exc,&has_set_value); * if ((haddr==NULL)&&(has_set_value==FALSE)) * { * bad_memory_access(cpu,vaddr); * } * if (likely(haddr != NULL)) *(m_uint64_t *)haddr = htovm64(data); * return(exc); */ printf ("mips_mts32_sdc1 pc %x\n", cpu->pc); exit (-1); return 0; } /* CACHE: Cache operation */ u_int fastcall mips_mts32_cache (cpu_mips_t * cpu, m_va_t vaddr, u_int op) { return (0); } /* === MTS Cache Management ============================================= */ /* MTS map/unmap/rebuild "API" functions */ void mips_mts32_api_map (cpu_mips_t * cpu, m_va_t vaddr, m_pa_t paddr, m_uint32_t len, int cache_access, int tlb_index) { /* nothing to do, the cache will be filled on-the-fly */ } void mips_mts32_api_unmap (cpu_mips_t * cpu, m_va_t vaddr, m_uint32_t len, m_uint32_t val, int tlb_index) { /* Invalidate the TLB entry or the full cache if no index is specified */ if (tlb_index != -1) mips_mts32_invalidate_tlb_entry (cpu, vaddr); else mips_mts32_invalidate_cache (cpu); } void mips_mts32_api_rebuild (cpu_mips_t * cpu) { mips_mts32_invalidate_cache ((cpu)); } /* ======================================================================== */ /* Initialize memory access vectors */ void mips_mts32_init_memop_vectors (cpu_mips_t * cpu) { /* XXX TODO: * - LD/SD forbidden in Supervisor/User modes with 32-bit addresses. */ cpu->addr_mode = 32; /* API vectors */ cpu->mts_map = mips_mts32_api_map; cpu->mts_unmap = mips_mts32_api_unmap; /* Memory lookup operation */ cpu->mem_op_lookup = mips_mts32_lookup; /* Translation operation */ cpu->translate = mips_mts32_translate; /* Shutdown operation */ cpu->mts_shutdown = mips_mts32_shutdown; /* Rebuild MTS data structures */ cpu->mts_rebuild = mips_mts32_api_rebuild; /* Show statistics */ //cpu->mts_show_stats = mips_mts32_show_stats; cpu->mips_mts_gdb_lb = mips_mts32_gdb_lb; /* Load Operations */ cpu->mem_op_fn[MIPS_MEMOP_LB] = mips_mts32_lb; cpu->mem_op_fn[MIPS_MEMOP_LBU] = mips_mts32_lbu; cpu->mem_op_fn[MIPS_MEMOP_LH] = mips_mts32_lh; cpu->mem_op_fn[MIPS_MEMOP_LHU] = mips_mts32_lhu; cpu->mem_op_fn[MIPS_MEMOP_LW] = mips_mts32_lw; cpu->mem_op_fn[MIPS_MEMOP_LWU] = mips_mts32_lwu; cpu->mem_op_fn[MIPS_MEMOP_LD] = mips_mts32_ld; cpu->mem_op_fn[MIPS_MEMOP_LDL] = mips_mts32_ldl; cpu->mem_op_fn[MIPS_MEMOP_LDR] = mips_mts32_ldr; /* Store Operations */ cpu->mem_op_fn[MIPS_MEMOP_SB] = mips_mts32_sb; cpu->mem_op_fn[MIPS_MEMOP_SH] = mips_mts32_sh; cpu->mem_op_fn[MIPS_MEMOP_SW] = mips_mts32_sw; cpu->mem_op_fn[MIPS_MEMOP_SD] = mips_mts32_sd; /* Load Left/Right operations */ cpu->mem_op_fn[MIPS_MEMOP_LWL] = mips_mts32_lwl; cpu->mem_op_fn[MIPS_MEMOP_LWR] = mips_mts32_lwr; cpu->mem_op_fn[MIPS_MEMOP_LDL] = mips_mts32_ldl; cpu->mem_op_fn[MIPS_MEMOP_LDR] = mips_mts32_ldr; /* Store Left/Right operations */ cpu->mem_op_fn[MIPS_MEMOP_SWL] = mips_mts32_swl; cpu->mem_op_fn[MIPS_MEMOP_SWR] = mips_mts32_swr; cpu->mem_op_fn[MIPS_MEMOP_SDL] = mips_mts32_sdl; cpu->mem_op_fn[MIPS_MEMOP_SDR] = mips_mts32_sdr; /* LL/SC - Load Linked / Store Conditional */ cpu->mem_op_fn[MIPS_MEMOP_LL] = mips_mts32_ll; cpu->mem_op_fn[MIPS_MEMOP_SC] = mips_mts32_sc; /* Coprocessor 1 memory access functions */ cpu->mem_op_fn[MIPS_MEMOP_LDC1] = mips_mts32_ldc1; cpu->mem_op_fn[MIPS_MEMOP_SDC1] = mips_mts32_sdc1; /* Cache Operation */ cpu->mem_op_fn[MIPS_MEMOP_CACHE] = mips_mts32_cache; } /* === Specific operations for MTS32 ====================================== */ /* * MTS32 slow lookup */ static mts32_entry_t *mips_mts32_slow_lookup (cpu_mips_t * cpu, m_uint64_t vaddr, u_int op_code, u_int op_size, u_int op_type, m_reg_t * data, u_int * exc, mts32_entry_t * alt_entry, u_int is_fromgdb) { m_uint32_t hash_bucket, zone; mts32_entry_t *entry; mts_map_t map; map.tlb_index = -1; hash_bucket = MTS32_HASH (vaddr); entry = &cpu->mts_u.mts32_cache[hash_bucket]; zone = (vaddr >> 29) & 0x7; #if DEBUG_MTS_STATS cpu->mts_misses++; #endif switch (zone) { case 0x00: case 0x01: case 0x02: case 0x03: /* kuseg */ #ifdef SIM_PIC32 if (vaddr == 0) goto err_undef; map.vaddr = vaddr & MIPS_MIN_PAGE_MASK; map.paddr = map.vaddr & 0x1ffff; map.mapped = FALSE; #else /* trigger TLB exception if no matching entry found */ if (! mips_cp0_tlb_lookup (cpu, vaddr, &map)) goto err_tlb; if ((map.valid & 0x1) != 0x1) goto err_tlb; if ((MTS_WRITE == op_type) && ((map.dirty & 0x1) != 0x1)) goto err_mod; map.mapped = TRUE; #endif entry = mips_mts32_map (cpu, op_type, &map, entry, alt_entry, is_fromgdb); if (! entry) goto err_undef; return (entry); case 0x04: /* kseg0 */ map.vaddr = vaddr & MIPS_MIN_PAGE_MASK; map.paddr = map.vaddr - (m_pa_t) 0xFFFFFFFF80000000ULL; map.mapped = FALSE; entry = mips_mts32_map (cpu, op_type, &map, entry, alt_entry, is_fromgdb); if (! entry) goto err_undef; return (entry); case 0x05: /* kseg1 */ map.vaddr = vaddr & MIPS_MIN_PAGE_MASK; map.paddr = map.vaddr - (m_pa_t) 0xFFFFFFFFA0000000ULL; map.mapped = FALSE; entry = mips_mts32_map (cpu, op_type, &map, entry, alt_entry, is_fromgdb); if (! entry) goto err_undef; return (entry); case 0x06: /* ksseg */ case 0x07: /* kseg3 */ #ifdef SIM_PIC32 map.vaddr = vaddr & MIPS_MIN_PAGE_MASK; map.paddr = map.vaddr & 0x1ffff; map.mapped = FALSE; #else //ASSERT(0,"not implemented upper 1G memory space \n"); /* trigger TLB exception if no matching entry found */ if (! mips_cp0_tlb_lookup (cpu, vaddr, &map)) goto err_tlb; if ((map.valid & 0x1) != 0x1) goto err_tlb; if ((MTS_WRITE == op_type) && ((map.dirty & 0x1) != 0x1)) goto err_mod; map.mapped = TRUE; #endif entry = mips_mts32_map (cpu, op_type, &map, entry, alt_entry, is_fromgdb); if (! entry) goto err_undef; return (entry); } #ifndef SIM_PIC32 err_mod: if (is_fromgdb) return NULL; mips_access_special (cpu, vaddr, MTS_ACC_M, op_code, op_type, op_size, data, exc); return NULL; err_tlb: if (is_fromgdb) return NULL; mips_access_special (cpu, vaddr, MTS_ACC_T, op_code, op_type, op_size, data, exc); return NULL; #endif err_undef: if (is_fromgdb) return NULL; mips_access_special (cpu, vaddr, MTS_ACC_U, op_code, op_type, op_size, data, exc); return NULL; } static forced_inline int mips_mts32_check_tlbcache (cpu_mips_t * cpu, m_va_t vaddr, u_int op_type, mts32_entry_t * entry) { m_uint32_t asid; mips_cp0_t *cp0 = &cpu->cp0; asid = cp0->reg[MIPS_CP0_TLB_HI] & MIPS_TLB_ASID_MASK; if (((m_uint32_t) vaddr & MIPS_MIN_PAGE_MASK) != entry->gvpa) return 0; if (entry->mapped == TRUE) { if ((op_type == MTS_WRITE) && (!entry->dirty_bit)) return 0; if ((!entry->g_bit) && (asid != entry->asid)) return 0; } return 1; } /* MTS32 access */ void *mips_mts32_access (cpu_mips_t * cpu, m_va_t vaddr, u_int op_code, u_int op_size, u_int op_type, m_reg_t * data, u_int * exc, m_uint8_t * has_set_value, u_int is_fromgdb) { mts32_entry_t *entry, alt_entry; m_uint32_t hash_bucket; m_iptr_t haddr; u_int dev_id; /* A job need to be done first: check whether access is aligned!!! MIPS FPU Emulator use a unaligned lw access to cause exception and then handle it. 72 73 * The strategy is to push the instruction onto the user stack 74 * and put a trap after it which we can catch and jump to 75 * the required address any alternative apart from full 76 * instruction simulation!!. 77 * 78 * Algorithmics used a system call instruction, and 79 * borrowed that vector. MIPS/Linux version is a bit 80 * more heavyweight in the interests of portability and 81 * multiprocessor support. For Linux we generate a 82 * an unaligned access and force an address error exception. 83 * 84 * For embedded systems (stand-alone) we prefer to use a 85 * non-existing CP1 instruction. This prevents us from emulating 86 * branches, but gives us a cleaner interface to the exception 87 * handler (single entry point). 88 I did not check it before version 0.04 and hwclock/qtopia always segment fault. Very hard to debug this problem!!!! yajin */ //if (vaddr == 0x7f010020) //printf ("%08x: %s address %08x\n", cpu->pc, //(op_type == MTS_WRITE) ? "write" : "read", (unsigned) vaddr); if (MTS_HALF_WORD == op_size) { if (unlikely ((vaddr & 0x00000001UL) != 0x0)) { err_addr: if (is_fromgdb) return NULL; mips_access_special (cpu, vaddr, MTS_ACC_AE, op_code, op_type, op_size, data, exc); return NULL; } } else if (MTS_WORD == op_size) { if ((op_code != MIPS_MEMOP_LWL) && (op_code != MIPS_MEMOP_LWR) && (op_code != MIPS_MEMOP_SWL) && (op_code != MIPS_MEMOP_SWR)) { if (unlikely ((vaddr & 0x00000003UL) != 0x0)) goto err_addr; } } *exc = 0; hash_bucket = MTS32_HASH (vaddr); entry = &cpu->mts_u.mts32_cache [hash_bucket]; if (unlikely (mips_mts32_check_tlbcache (cpu, vaddr, op_type, entry) == 0)) { entry = mips_mts32_slow_lookup (cpu, vaddr, op_code, op_size, op_type, data, exc, &alt_entry, is_fromgdb); if (! entry) return NULL; if (entry->flags & MTS_FLAG_DEV) { dev_id = (entry->hpa & MTS_DEVID_MASK) >> MTS_DEVID_SHIFT; haddr = entry->hpa & MTS_DEVOFF_MASK; haddr += vaddr - entry->gvpa; void *addr = dev_access_fast (cpu, dev_id, haddr, op_size, op_type, data, has_set_value); /*printf ("%08x: mts32_access fast returned %p\n", cpu->pc, addr);*/ return addr; } } /* Raw memory access */ haddr = entry->hpa + (vaddr & MIPS_MIN_PAGE_IMASK); return ((void *) haddr); } /* MTS32 virtual address to physical address translation */ static int mips_mts32_translate (cpu_mips_t * cpu, m_va_t vaddr, m_pa_t * phys_page) { mts32_entry_t *entry, alt_entry; m_uint32_t hash_bucket; m_reg_t data = 0; u_int exc = 0; hash_bucket = MTS32_HASH (vaddr); entry = &cpu->mts_u.mts32_cache[hash_bucket]; if (unlikely (mips_mts32_check_tlbcache (cpu, vaddr, MTS_READ, entry) == 0)) { entry = mips_mts32_slow_lookup (cpu, vaddr, MIPS_MEMOP_LOOKUP, 4, MTS_READ, &data, &exc, &alt_entry, 0); if (! entry) return (-1); ASSERT (! (entry->flags & MTS_FLAG_DEV), "error when translating virtual address to phyaddrss \n"); } *phys_page = entry->gppa >> MIPS_MIN_PAGE_SHIFT; return (0); } /* ======================================================================== */ /* Shutdown MTS subsystem */ void mips_mem_shutdown (cpu_mips_t * cpu) { if (cpu->mts_shutdown != NULL) cpu->mts_shutdown (cpu); } /* Set the address mode */ int mips_set_addr_mode (cpu_mips_t * cpu, u_int addr_mode) { if (cpu->addr_mode != addr_mode) { mips_mem_shutdown (cpu); switch (addr_mode) { case 32: mips_mts32_init (cpu); mips_mts32_init_memop_vectors (cpu); break; /*case 64: * TODO: 64 bit memory operation * mips_mts64_init(cpu); * mips_mts64_init_memop_vectors(cpu); * break; */ default: fprintf (stderr, "mts_set_addr_mode: internal error (addr_mode=%u)\n", addr_mode); exit (EXIT_FAILURE); } } return (0); } /*------------------DMA------------------------*/ /* Get host pointer for the physical ram address */ void *physmem_get_hptr (vm_instance_t * vm, m_pa_t paddr, u_int op_size, u_int op_type, m_uint32_t * data) { struct vdevice *dev; m_uint32_t offset; m_uint8_t has_set_value; if (!(dev = dev_lookup (vm, paddr))) return NULL; /*Only for RAM */ if ((dev->host_addr != 0) && !(dev->flags & VDEVICE_FLAG_NO_MTS_MMAP)) return ((void *) dev->host_addr + (paddr - dev->phys_addr)); if (op_size == 0) return NULL; ASSERT (0, "physmem_get_hptr error\n"); offset = paddr - dev->phys_addr; return (dev->handler (vm->boot_cpu, dev, offset, op_size, op_type, data, &has_set_value)); } /* DMA transfer operation */ void physmem_dma_transfer (vm_instance_t * vm, m_pa_t src, m_pa_t dst, size_t len) { m_uint32_t dummy; u_char *sptr, *dptr; size_t clen, sl, dl; while (len > 0) { sptr = physmem_get_hptr (vm, src, 0, MTS_READ, &dummy); dptr = physmem_get_hptr (vm, dst, 0, MTS_WRITE, &dummy); if (!sptr || !dptr) { vm_log (vm, "DMA", "unable to transfer from 0x%" LL "x to 0x%" LL "x\n", src, dst); ASSERT (0, "physmem_dma_transfer src %x dst %x\n", src, dst); return; } sl = VM_PAGE_SIZE - (src & VM_PAGE_IMASK); dl = VM_PAGE_SIZE - (dst & VM_PAGE_IMASK); clen = m_min (sl, dl); clen = m_min (clen, len); memcpy (dptr, sptr, clen); src += clen; dst += clen; len -= clen; } } ================================================ FILE: tools/virtualmips/mips_memory.h ================================================ /* * Cisco router simulation platform. * Copyright (c) 2006 Christophe Fillot (cf@utc.fr) */ /* * Copyright (C) yajin 2008 * * This file is part of the virtualmips distribution. * See LICENSE file for terms of the license. * */ #ifndef __MIPS64_MEM_H__ #define __MIPS64_MEM_H__ #include #include "utils.h" #include "system.h" /* MTS operation */ #define MTS_READ 0 #define MTS_WRITE 1 #define MTS_BYTE 1 #define MTS_HALF_WORD 2 #define MTS_WORD 4 /* 0.5GB value */ #define MTS_SIZE_512M 0x20000000 /* MTS flag bits: D (device), ACC (memory access), C (chain) */ #define MTS_FLAG_BITS 4 #define MTS_FLAG_MASK 0x0000000fUL /* Masks for MTS entries */ #define MTS_CHAIN_MASK 0x00000001 #define MTS_ACC_MASK 0x00000006 #define MTS_DEV_MASK 0x00000008 #define MTS_ADDR_MASK (~MTS_FLAG_MASK) /* Device ID mask and shift, device offset mask */ #define MTS_DEVID_MASK 0xfc000000 #define MTS_DEVID_SHIFT 26 #define MTS_DEVOFF_MASK 0x03fffff0 /* Memory access flags */ #define MTS_ACC_OK 0x00000000 /* Access OK */ #define MTS_ACC_AE 0x00000002 /* Address Error */ #define MTS_ACC_T 0x00000004 /* TLB Exception */ #define MTS_ACC_U 0x00000006 /* Unexistent */ #define MTS_ACC_M 0x00000008 /* TLB MODE */ /* Hash table size for MTS64 (default: [shift:16,bits:12]) */ #define MTS64_HASH_SHIFT 12 #define MTS64_HASH_BITS 14 #define MTS64_HASH_SIZE (1 << MTS64_HASH_BITS) #define MTS64_HASH_MASK (MTS64_HASH_SIZE - 1) /* MTS64 hash on virtual addresses */ #define MTS64_HASH(vaddr) (((vaddr) >> MTS64_HASH_SHIFT) & MTS64_HASH_MASK) /* Hash table size for MTS32 (default: [shift:15,bits:15]) */ #define MTS32_HASH_SHIFT 12 #define MTS32_HASH_BITS 14 #define MTS32_HASH_SIZE (1 << MTS32_HASH_BITS) #define MTS32_HASH_MASK (MTS32_HASH_SIZE - 1) /* MTS32 hash on virtual addresses */ #define MTS32_HASH(vaddr) (((vaddr) >> MTS32_HASH_SHIFT) & MTS32_HASH_MASK) /* Number of entries per chunk */ #define MTS64_CHUNK_SIZE 256 #define MTS32_CHUNK_SIZE 256 /* MTS64: chunk definition */ struct mts64_chunk { mts64_entry_t entry[MTS64_CHUNK_SIZE]; struct mts64_chunk *next; u_int count; }; /* MTS32: chunk definition */ struct mts32_chunk { mts32_entry_t entry[MTS32_CHUNK_SIZE]; struct mts32_chunk *next; u_int count; }; /*check whether vaddr need map*/ static int forced_inline vaddr_mapped (m_va_t vaddr) { int zone = (vaddr >> 29) & 0x7; if ((zone == 0x4) || (zone == 0x5)) { return 0; } else { return 1; } } /* Shutdown the MTS subsystem */ void mips_mem_shutdown (cpu_mips_t * cpu); /* Set the address mode */ int mips_set_addr_mode (cpu_mips_t * cpu, u_int addr_mode); void physmem_dma_transfer (vm_instance_t * vm, m_pa_t src, m_pa_t dst, size_t len); void *physmem_get_hptr (vm_instance_t * vm, m_pa_t paddr, u_int op_size, u_int op_type, m_uint32_t * data); #endif ================================================ FILE: tools/virtualmips/net.h ================================================ #ifndef __NET_H__ #define __NET_H__ #include "utils.h" /* Ethernet Constants */ #define N_ETH_ALEN 6 #define N_ETH_HLEN sizeof(n_eth_hdr_t) /* Ethernet Address */ typedef struct { m_uint8_t eth_addr_byte[N_ETH_ALEN]; } __attribute__ ((__packed__)) n_eth_addr_t; /* Ethernet Header */ typedef struct { n_eth_addr_t daddr; /* destination eth addr */ n_eth_addr_t saddr; /* source ether addr */ m_uint16_t type; /* packet type ID field */ } __attribute__ ((__packed__)) n_eth_hdr_t; /* Check for a broadcast/multicast ethernet address */ static inline int eth_addr_is_bcast (n_eth_addr_t * addr) { return ((addr->eth_addr_byte[0] == 0xff) && (addr->eth_addr_byte[1] == 0xff) && (addr->eth_addr_byte[2] == 0xff) && (addr->eth_addr_byte[3] == 0xff) && (addr->eth_addr_byte[4] == 0xff) && (addr->eth_addr_byte[5] == 0xff)); } static inline int eth_addr_is_mcast (n_eth_addr_t * addr) { return ((!eth_addr_is_bcast (addr)) && (addr->eth_addr_byte[0] & 1)); } #endif ================================================ FILE: tools/virtualmips/net_io.c ================================================ /* * Cisco router simulation platform. * Copyright (c) 2005,2006 Christophe Fillot (cf@utc.fr) * * Network Input/Output Abstraction Layer. */ /* By default, Cygwin supports only 64 FDs with select()! */ #ifdef __CYGWIN__ #define FD_SETSIZE 1024 #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifdef __linux__ #include #include #endif #include "net.h" #include "net_io.h" /* Free a NetIO descriptor */ static int netio_free (void *data, void *arg); #if 0 /* NIO RX listener */ static pthread_mutex_t netio_rxl_mutex = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t netio_rxq_mutex = PTHREAD_MUTEX_INITIALIZER; static struct netio_rx_listener *netio_rxl_list = NULL; static struct netio_rx_listener *netio_rxl_add_list = NULL; static netio_desc_t *netio_rxl_remove_list = NULL; static pthread_t netio_rxl_thread; static pthread_cond_t netio_rxl_cond; #define NETIO_RXL_LOCK() pthread_mutex_lock(&netio_rxl_mutex); #define NETIO_RXL_UNLOCK() pthread_mutex_unlock(&netio_rxl_mutex); #define NETIO_RXQ_LOCK() pthread_mutex_lock(&netio_rxq_mutex); #define NETIO_RXQ_UNLOCK() pthread_mutex_unlock(&netio_rxq_mutex); #endif /* NetIO type */ typedef struct { char *name; char *desc; } netio_type_t; /* NETIO types (must follow the enum definition) */ static netio_type_t netio_types[NETIO_TYPE_MAX] = { {"unix", "UNIX local sockets"}, {"vde", "Virtual Distributed Ethernet / UML switch"}, {"tap", "Linux/FreeBSD TAP device"}, {"udp", "UDP sockets"}, {"tcp_cli", "TCP client"}, {"tcp_ser", "TCP server"}, #ifdef LINUX_ETH {"linux_eth", "Linux Ethernet device"}, #endif #ifdef GEN_ETH {"gen_eth", "Generic Ethernet device (PCAP)"}, #endif {"fifo", "FIFO (intra-hypervisor)"}, {"null", "Null device"}, }; /* Get NETIO type given a description */ int netio_get_type (char *type) { int i; for (i = 0; i < NETIO_TYPE_MAX; i++) if (!strcmp (type, netio_types[i].name)) return (i); return (-1); } /* Show the NETIO types */ void netio_show_types (void) { int i; printf ("Available NETIO types:\n"); for (i = 0; i < NETIO_TYPE_MAX; i++) printf (" * %-10s : %s\n", netio_types[i].name, netio_types[i].desc); printf ("\n"); } /* Create a new NetIO descriptor */ static netio_desc_t *netio_create (char *name) { netio_desc_t *nio; if (!(nio = malloc (sizeof (*nio)))) return NULL; /* setup as a NULL descriptor */ memset (nio, 0, sizeof (*nio)); nio->type = NETIO_TYPE_NULL; /* save name for registry */ if (!(nio->name = strdup (name))) { free (nio); return NULL; } return nio; } /* Send a packet through a NetIO descriptor */ ssize_t netio_send (netio_desc_t * nio, void *pkt, size_t len) { if (!nio) return (-1); if (nio->debug) { printf ("NIO %s: sending a packet of %lu bytes:\n", nio->name, (u_long) len); mem_dump (stdout, pkt, len); } return (nio->send (nio->dptr, pkt, len)); } /* Receive a packet through a NetIO descriptor */ ssize_t netio_recv (netio_desc_t * nio, void *pkt, size_t max_len) { ssize_t len; if (!nio) return (-1); /* Receive the packet */ if ((len = nio->recv (nio->dptr, pkt, max_len)) <= 0) return (-1); if (nio->debug) { printf ("NIO %s: receiving a packet of %ld bytes:\n", nio->name, (long) len); mem_dump (stdout, pkt, len); } return (len); } /* Get a NetIO FD */ int netio_get_fd (netio_desc_t * nio) { int fd = -1; switch (nio->type) { //case NETIO_TYPE_UNIX: // fd = nio->u.nud.fd; // break; //case NETIO_TYPE_VDE: // fd = nio->u.nvd.data_fd; // break; case NETIO_TYPE_TAP: fd = nio->u.ntd.fd; break; //case NETIO_TYPE_TCP_CLI: //case NETIO_TYPE_TCP_SER: //case NETIO_TYPE_UDP: // fd = nio->u.nid.fd; // break; //#ifdef LINUX_ETH // case NETIO_TYPE_LINUX_ETH: // fd = nio->u.nled.fd; // break; //#endif } return (fd); } #if 0 /* * ========================================================================= * UNIX sockets * ========================================================================= */ /* Create an UNIX socket */ static int netio_unix_create_socket (netio_unix_desc_t * nud) { struct sockaddr_un local_sock; if ((nud->fd = socket (AF_UNIX, SOCK_DGRAM, 0)) == -1) { perror ("netio_unix: socket"); return (-1); } memset (&local_sock, 0, sizeof (local_sock)); local_sock.sun_family = AF_UNIX; strlcpy (local_sock.sun_path, nud->local_filename, sizeof(local_sock.sun_path)); if (bind (nud->fd, (struct sockaddr *) &local_sock, sizeof (local_sock)) == -1) { perror ("netio_unix: bind"); return (-1); } return (nud->fd); } /* Free a NetIO unix descriptor */ static void netio_unix_free (netio_unix_desc_t * nud) { if (nud->fd != -1) close (nud->fd); if (nud->local_filename) { unlink (nud->local_filename); free (nud->local_filename); } } /* Allocate a new NetIO UNIX descriptor */ static int netio_unix_create (netio_unix_desc_t * nud, char *local, char *remote) { memset (nud, 0, sizeof (*nud)); nud->fd = -1; /* check lengths */ if ((strlen (local) >= sizeof (nud->remote_sock.sun_path)) || (strlen (remote) >= sizeof (nud->remote_sock.sun_path))) goto nomem_error; if (!(nud->local_filename = strdup (local))) goto nomem_error; if (netio_unix_create_socket (nud) == -1) return (-1); /* prepare the remote info */ nud->remote_sock.sun_family = AF_UNIX; strlcpy (nud->remote_sock.sun_path, remote, sizeof(nud->remote_sock.sun_path)); return (0); nomem_error: fprintf (stderr, "netio_unix_create: " "invalid file size or insufficient memory\n"); return (-1); } /* Write a packet to an UNIX socket */ static ssize_t netio_unix_send (netio_unix_desc_t * nud, void *pkt, size_t pkt_len) { return (sendto (nud->fd, pkt, pkt_len, 0, (struct sockaddr *) &nud->remote_sock, sizeof (&nud->remote_sock))); } /* Receive a packet from an UNIX socket */ static ssize_t netio_unix_recv (netio_unix_desc_t * nud, void *pkt, size_t max_len) { return (recvfrom (nud->fd, pkt, max_len, 0, NULL, NULL)); } /* Save the NIO configuration */ static void netio_unix_save_cfg (netio_desc_t * nio, FILE * fd) { netio_unix_desc_t *nud = nio->dptr; fprintf (fd, "nio create_unix %s %s %s\n", nio->name, nud->local_filename, nud->remote_sock.sun_path); } /* Create a new NetIO descriptor with UNIX method */ netio_desc_t *netio_desc_create_unix (char *nio_name, char *local, char *remote) { netio_desc_t *nio; if (!(nio = netio_create (nio_name))) return NULL; if (netio_unix_create (&nio->u.nud, local, remote) == -1) { netio_free (nio, NULL); return NULL; } nio->type = NETIO_TYPE_UNIX; nio->send = (void *) netio_unix_send; nio->recv = (void *) netio_unix_recv; nio->save_cfg = netio_unix_save_cfg; nio->dptr = &nio->u.nud; if (netio_record (nio) == -1) { netio_free (nio, NULL); return NULL; } return nio; } /* * ========================================================================= * VDE (Virtual Distributed Ethernet) interface * ========================================================================= */ /* Free a NetIO VDE descriptor */ static void netio_vde_free (netio_vde_desc_t * nvd) { if (nvd->data_fd != -1) close (nvd->data_fd); if (nvd->ctrl_fd != -1) close (nvd->ctrl_fd); if (nvd->local_filename) { unlink (nvd->local_filename); free (nvd->local_filename); } } /* Create a new NetIO VDE descriptor */ static int netio_vde_create (netio_vde_desc_t * nvd, char *control, char *local) { struct sockaddr_un ctrl_sock, tst; struct vde_request_v3 req; ssize_t len; int res; memset (nvd, 0, sizeof (*nvd)); nvd->ctrl_fd = nvd->data_fd = -1; if ((strlen (control) >= sizeof (ctrl_sock.sun_path)) || (strlen (local) >= sizeof (nvd->remote_sock.sun_path))) { fprintf (stderr, "netio_vde_create: bad filenames specified\n"); return (-1); } /* Copy the local filename */ if (!(nvd->local_filename = strdup (local))) { fprintf (stderr, "netio_vde_create: insufficient memory\n"); return (-1); } /* Connect to the VDE switch controller */ nvd->ctrl_fd = socket (AF_UNIX, SOCK_STREAM, 0); if (nvd->ctrl_fd < 0) { perror ("netio_vde_create: socket(control)"); return (-1); } memset (&ctrl_sock, 0, sizeof (ctrl_sock)); ctrl_sock.sun_family = AF_UNIX; strlcpy (ctrl_sock.sun_path, control, sizeof(ctrl_sock.sun_path)); res = connect (nvd->ctrl_fd, (struct sockaddr *) &ctrl_sock, sizeof (ctrl_sock)); if (res < 0) { perror ("netio_vde_create: connect(control)"); return (-1); } tst.sun_family = AF_UNIX; strlcpy (tst.sun_path, local, sizeof(tst.sun_path)); /* Create the data connection */ nvd->data_fd = socket (AF_UNIX, SOCK_DGRAM, 0); if (nvd->data_fd < 0) { perror ("netio_vde_create: socket(data)"); return (-1); } if (bind (nvd->data_fd, (struct sockaddr *) &tst, sizeof (tst)) < 0) { perror ("netio_vde_create: bind(data)"); return (-1); } /* Now, process to registration */ memset (&req, 0, sizeof (req)); req.sock.sun_family = AF_UNIX; strlcpy (req.sock.sun_path, local, sizeof(req.sock.sun_path)); req.magic = VDE_SWITCH_MAGIC; req.version = VDE_SWITCH_VERSION; req.type = VDE_REQ_NEW_CONTROL; len = write (nvd->ctrl_fd, &req, sizeof (req)); if (len != sizeof (req)) { perror ("netio_vde_create: write(req)"); return (-1); } /* Read the remote socket descriptor */ len = read (nvd->ctrl_fd, &nvd->remote_sock, sizeof (nvd->remote_sock)); if (len != sizeof (nvd->remote_sock)) { perror ("netio_vde_create: read(req)"); return (-1); } return (0); } /* Write a packet to a VDE data socket */ static ssize_t netio_vde_send (netio_vde_desc_t * nvd, void *pkt, size_t pkt_len) { return (sendto (nvd->data_fd, pkt, pkt_len, 0, (struct sockaddr *) &nvd->remote_sock, sizeof (nvd->remote_sock))); } /* Receive a packet from a VDE socket */ static ssize_t netio_vde_recv (netio_vde_desc_t * nvd, void *pkt, size_t max_len) { return (recvfrom (nvd->data_fd, pkt, max_len, 0, NULL, NULL)); } /* Save the NIO configuration */ static void netio_vde_save_cfg (netio_desc_t * nio, FILE * fd) { netio_vde_desc_t *nvd = nio->dptr; fprintf (fd, "nio create_vde %s %s %s\n", nio->name, nvd->remote_sock.sun_path, nvd->local_filename); } /* Create a new NetIO descriptor with VDE method */ netio_desc_t *netio_desc_create_vde (char *nio_name, char *control, char *local) { netio_vde_desc_t *nvd; netio_desc_t *nio; if (!(nio = netio_create (nio_name))) return NULL; nvd = &nio->u.nvd; if (netio_vde_create (nvd, control, local) == -1) { netio_free (nio, NULL); return NULL; } nio->type = NETIO_TYPE_VDE; nio->send = (void *) netio_vde_send; nio->recv = (void *) netio_vde_recv; nio->save_cfg = netio_vde_save_cfg; nio->dptr = &nio->u.nvd; if (netio_record (nio) == -1) { netio_free (nio, NULL); return NULL; } return nio; } #endif /* * ========================================================================= * TAP devices * ========================================================================= */ /* Free a NetIO TAP descriptor */ static void netio_tap_free (netio_tap_desc_t * ntd) { if (ntd->fd != -1) close (ntd->fd); } /* Open a TAP device */ static int netio_tap_open (char *tap_devname) { #ifdef __linux__ struct ifreq ifr; int fd, err; if ((fd = open ("/dev/net/tun", O_RDWR)) < 0) return (-1); memset (&ifr, 0, sizeof (ifr)); /* Flags: IFF_TUN - TUN device (no Ethernet headers) * IFF_TAP - TAP device * * IFF_NO_PI - Do not provide packet information */ ifr.ifr_flags = IFF_TAP | IFF_NO_PI; if (*tap_devname) strncpy (ifr.ifr_name, tap_devname, IFNAMSIZ); if ((err = ioctl (fd, TUNSETIFF, (void *) &ifr)) < 0) { close (fd); return err; } strlcpy (tap_devname, ifr.ifr_name, NETIO_DEV_MAXLEN); return (fd); #else int i, fd = -1; if (*tap_devname) { fd = open (tap_devname, O_RDWR); } else { for (i = 0; i < 16; i++) { snprintf (tap_devname, NETIO_DEV_MAXLEN, "/dev/tap%d", i); if ((fd = open (tap_devname, O_RDWR)) >= 0) break; } } return (fd); #endif } /* Allocate a new NetIO TAP descriptor */ static int netio_tap_create (netio_tap_desc_t * ntd, char *tap_name) { if (strlen (tap_name) >= NETIO_DEV_MAXLEN) { fprintf (stderr, "netio_tap_create: bad TAP device string specified.\n"); return (-1); } memset (ntd, 0, sizeof (*ntd)); strlcpy (ntd->filename, tap_name, NETIO_DEV_MAXLEN); ntd->fd = netio_tap_open (ntd->filename); if (ntd->fd == -1) { fprintf (stderr, "netio_tap_create: unable to open TAP device %s (%s)\n", tap_name, strerror (errno)); return (-1); } /*SET NO BLOCKING */ if (fcntl (ntd->fd, F_SETFL, O_NONBLOCK) == -1) printf ("Set file descriptor to non-blocking mode failed\n"); return (0); } /* Write a packet to a TAP device */ static ssize_t netio_tap_send (netio_tap_desc_t * ntd, void *pkt, size_t pkt_len) { return (write (ntd->fd, pkt, pkt_len)); } /* Receive a packet through a TAP device */ static ssize_t netio_tap_recv (netio_tap_desc_t * ntd, void *pkt, size_t max_len) { return (read (ntd->fd, pkt, max_len)); } /* Create a new NetIO descriptor with TAP method */ netio_desc_t *netio_desc_create_tap (char *nio_name, char *tap_name) { netio_tap_desc_t *ntd; netio_desc_t *nio; if (!(nio = netio_create (nio_name))) return NULL; ntd = &nio->u.ntd; if (netio_tap_create (ntd, tap_name) == -1) { netio_free (nio, NULL); return NULL; } nio->type = NETIO_TYPE_TAP; nio->send = (void *) netio_tap_send; nio->recv = (void *) netio_tap_recv; nio->dptr = &nio->u.ntd; return nio; } #if 0 /* * ========================================================================= * TCP sockets * ========================================================================= */ /* Free a NetIO TCP descriptor */ static void netio_tcp_free (netio_inet_desc_t * nid) { if (nid->fd != -1) close (nid->fd); } /* * very simple protocol to send packets over tcp * 32 bits in network format - size of packet, then packet itself and so on. */ static ssize_t netio_tcp_send (netio_inet_desc_t * nid, void *pkt, size_t pkt_len) { u_long l = htonl (pkt_len); if (write (nid->fd, &l, sizeof (l)) == -1) return (-1); return (write (nid->fd, pkt, pkt_len)); } static ssize_t netio_tcp_recv (netio_inet_desc_t * nid, void *pkt, size_t max_len) { u_long l; if (read (nid->fd, &l, sizeof (l)) != sizeof (l)) return (-1); if (ntohl (l) > max_len) return (-1); return (read (nid->fd, pkt, ntohl (l))); } static int netio_tcp_cli_create (netio_inet_desc_t * nid, char *host, char *port) { struct sockaddr_in serv; struct servent *sp; struct hostent *hp; if ((nid->fd = socket (PF_INET, SOCK_STREAM, 0)) < 0) { perror ("netio_tcp_cli_create: socket"); return (-1); } memset (&serv, 0, sizeof (serv)); serv.sin_family = AF_INET; if (atoi (port) == 0) { if (!(sp = getservbyname (port, "tcp"))) { fprintf (stderr, "netio_tcp_cli_create: port %s is neither " "number not service %s\n", port, strerror (errno)); close (nid->fd); return (-1); } serv.sin_port = sp->s_port; } else serv.sin_port = htons (atoi (port)); if (inet_addr (host) == INADDR_NONE) { if (!(hp = gethostbyname (host))) { fprintf (stderr, "netio_tcp_cli_create: no host %s\n", host); close (nid->fd); return (-1); } serv.sin_addr.s_addr = *hp->h_addr; } else serv.sin_addr.s_addr = inet_addr (host); if (connect (nid->fd, (struct sockaddr *) &serv, sizeof (serv)) < 0) { fprintf (stderr, "netio_tcp_cli_create: connect to %s:%s failed %s\n", host, port, strerror (errno)); close (nid->fd); return (-1); } return (0); } /* Create a new NetIO descriptor with TCP_CLI method */ netio_desc_t *netio_desc_create_tcp_cli (char *nio_name, char *host, char *port) { netio_desc_t *nio; if (!(nio = netio_create (nio_name))) return NULL; if (netio_tcp_cli_create (&nio->u.nid, host, port) < 0) { netio_free (nio, NULL); return NULL; } nio->type = NETIO_TYPE_TCP_CLI; nio->send = (void *) netio_tcp_send; nio->recv = (void *) netio_tcp_recv; nio->dptr = &nio->u.nid; if (netio_record (nio) == -1) { netio_free (nio, NULL); return NULL; } return nio; } static int netio_tcp_ser_create (netio_inet_desc_t * nid, char *port) { struct sockaddr_in serv; struct servent *sp; int sock_fd; if ((sock_fd = socket (PF_INET, SOCK_STREAM, 0)) < 0) { perror ("netio_tcp_cli_create: socket\n"); return (-1); } memset (&serv, 0, sizeof (serv)); serv.sin_family = AF_INET; serv.sin_addr.s_addr = htonl (INADDR_ANY); if (atoi (port) == 0) { if (!(sp = getservbyname (port, "tcp"))) { fprintf (stderr, "netio_tcp_ser_create: port %s is neither " "number not service %s\n", port, strerror (errno)); close (sock_fd); return (-1); } serv.sin_port = sp->s_port; } else serv.sin_port = htons (atoi (port)); if (bind (sock_fd, (struct sockaddr *) &serv, sizeof (serv)) < 0) { fprintf (stderr, "netio_tcp_ser_create: bind %s failed %s\n", port, strerror (errno)); close (sock_fd); return (-1); } if (listen (sock_fd, 1) < 0) { fprintf (stderr, "netio_tcp_ser_create: listen %s failed %s\n", port, strerror (errno)); close (sock_fd); return (-1); } fprintf (stderr, "Waiting connection on port %s...\n", port); if ((nid->fd = accept (sock_fd, NULL, NULL)) < 0) { fprintf (stderr, "netio_tcp_ser_create: accept %s failed %s\n", port, strerror (errno)); close (sock_fd); return (-1); } fprintf (stderr, "Connected\n"); close (sock_fd); return (0); } /* Create a new NetIO descriptor with TCP_SER method */ netio_desc_t *netio_desc_create_tcp_ser (char *nio_name, char *port) { netio_desc_t *nio; if (!(nio = netio_create (nio_name))) return NULL; if (netio_tcp_ser_create (&nio->u.nid, port) == -1) { netio_free (nio, NULL); return NULL; } nio->type = NETIO_TYPE_TCP_SER; nio->send = (void *) netio_tcp_send; nio->recv = (void *) netio_tcp_recv; nio->dptr = &nio->u.nid; if (netio_record (nio) == -1) { netio_free (nio, NULL); return NULL; } return nio; } /* * ========================================================================= * UDP sockets * ========================================================================= */ /* Free a NetIO UDP descriptor */ static void netio_udp_free (netio_inet_desc_t * nid) { if (nid->remote_host) { free (nid->remote_host); nid->remote_host = NULL; } if (nid->fd != -1) close (nid->fd); } /* Write a packet to an UDP socket */ static ssize_t netio_udp_send (netio_inet_desc_t * nid, void *pkt, size_t pkt_len) { return (send (nid->fd, pkt, pkt_len, 0)); } /* Receive a packet from an UDP socket */ static ssize_t netio_udp_recv (netio_inet_desc_t * nid, void *pkt, size_t max_len) { return (recvfrom (nid->fd, pkt, max_len, 0, NULL, NULL)); } /* Save the NIO configuration */ static void netio_udp_save_cfg (netio_desc_t * nio, FILE * fd) { netio_inet_desc_t *nid = nio->dptr; fprintf (fd, "nio create_udp %s %d %s %d\n", nio->name, nid->local_port, nid->remote_host, nid->remote_port); } /* Create a new NetIO descriptor with UDP method */ netio_desc_t *netio_desc_create_udp (char *nio_name, int local_port, char *remote_host, int remote_port) { netio_inet_desc_t *nid; netio_desc_t *nio; if (!(nio = netio_create (nio_name))) return NULL; nid = &nio->u.nid; nid->local_port = local_port; nid->remote_port = remote_port; if (!(nid->remote_host = strdup (remote_host))) { fprintf (stderr, "netio_desc_create_udp: insufficient memory\n"); goto error; } if ((nid->fd = udp_connect (local_port, remote_host, remote_port)) < 0) { fprintf (stderr, "netio_desc_create_udp: unable to connect to %s:%d\n", remote_host, remote_port); goto error; } nio->type = NETIO_TYPE_UDP; nio->send = (void *) netio_udp_send; nio->recv = (void *) netio_udp_recv; nio->save_cfg = netio_udp_save_cfg; nio->dptr = &nio->u.nid; if (netio_record (nio) == -1) goto error; return nio; error: netio_free (nio, NULL); return NULL; } /* * ========================================================================= * Linux RAW Ethernet driver * ========================================================================= */ #ifdef LINUX_ETH /* Free a NetIO raw ethernet descriptor */ static void netio_lnxeth_free (netio_lnxeth_desc_t * nled) { if (nled->fd != -1) close (nled->fd); } /* Write a packet to a raw Ethernet socket */ static ssize_t netio_lnxeth_send (netio_lnxeth_desc_t * nled, void *pkt, size_t pkt_len) { return (lnx_eth_send (nled->fd, nled->dev_id, pkt, pkt_len)); } /* Receive a packet from an raw Ethernet socket */ static ssize_t netio_lnxeth_recv (netio_lnxeth_desc_t * nled, void *pkt, size_t max_len) { return (lnx_eth_recv (nled->fd, pkt, max_len)); } /* Save the NIO configuration */ static void netio_lnxeth_save_cfg (netio_desc_t * nio, FILE * fd) { netio_lnxeth_desc_t *nled = nio->dptr; fprintf (fd, "nio create_linux_eth %s %s\n", nio->name, nled->dev_name); } /* Create a new NetIO descriptor with raw Ethernet method */ netio_desc_t *netio_desc_create_lnxeth (char *nio_name, char *dev_name) { netio_lnxeth_desc_t *nled; netio_desc_t *nio; if (!(nio = netio_create (nio_name))) return NULL; nled = &nio->u.nled; if (strlen (dev_name) >= NETIO_DEV_MAXLEN) { fprintf (stderr, "netio_desc_create_lnxeth: bad Ethernet device string " "specified.\n"); netio_free (nio, NULL); return NULL; } strlcpy (nled->dev_name, dev_name, NETIO_DEV_MAXLEN); nled->fd = lnx_eth_init_socket (dev_name); nled->dev_id = lnx_eth_get_dev_index (dev_name); if (nled->fd < 0) { netio_free (nio, NULL); return NULL; } nio->type = NETIO_TYPE_LINUX_ETH; nio->send = (void *) netio_lnxeth_send; nio->recv = (void *) netio_lnxeth_recv; nio->save_cfg = netio_lnxeth_save_cfg; nio->dptr = &nio->u.nled; if (netio_record (nio) == -1) { netio_free (nio, NULL); return NULL; } return nio; } #endif /* LINUX_ETH */ /* * ========================================================================= * Generic RAW Ethernet driver * ========================================================================= */ #ifdef GEN_ETH /* Free a NetIO raw ethernet descriptor */ static void netio_geneth_free (netio_geneth_desc_t * nged) { gen_eth_close (nged->pcap_dev); } /* Write a packet to an Ethernet device */ static ssize_t netio_geneth_send (netio_geneth_desc_t * nged, void *pkt, size_t pkt_len) { return (gen_eth_send (nged->pcap_dev, pkt, pkt_len)); } /* Receive a packet from an Ethernet device */ static ssize_t netio_geneth_recv (netio_geneth_desc_t * nged, void *pkt, size_t max_len) { return (gen_eth_recv (nged->pcap_dev, pkt, max_len)); } /* Save the NIO configuration */ static void netio_geneth_save_cfg (netio_desc_t * nio, FILE * fd) { netio_geneth_desc_t *nged = nio->dptr; fprintf (fd, "nio create_gen_eth %s %s\n", nio->name, nged->dev_name); } /* Create a new NetIO descriptor with generic raw Ethernet method */ netio_desc_t *netio_desc_create_geneth (char *nio_name, char *dev_name) { netio_geneth_desc_t *nged; netio_desc_t *nio; if (!(nio = netio_create (nio_name))) return NULL; nged = &nio->u.nged; if (strlen (dev_name) >= NETIO_DEV_MAXLEN) { fprintf (stderr, "netio_desc_create_geneth: bad Ethernet device string " "specified.\n"); netio_free (nio, NULL); return NULL; } strlcpy (nged->dev_name, dev_name, NETIO_DEV_MAXLEN); if (!(nged->pcap_dev = gen_eth_init (dev_name))) { netio_free (nio, NULL); return NULL; } nio->type = NETIO_TYPE_GEN_ETH; nio->send = (void *) netio_geneth_send; nio->recv = (void *) netio_geneth_recv; nio->save_cfg = netio_geneth_save_cfg; nio->dptr = &nio->u.nged; if (netio_record (nio) == -1) { netio_free (nio, NULL); return NULL; } return nio; } #endif /* GEN_ETH */ /* * ========================================================================= * FIFO Driver (intra-hypervisor communications) * ========================================================================= */ /* Extract the first packet of the FIFO */ static netio_fifo_pkt_t *netio_fifo_extract_pkt (netio_fifo_desc_t * nfd) { netio_fifo_pkt_t *p; if (!(p = nfd->head)) return NULL; nfd->pkt_count--; nfd->head = p->next; if (!nfd->head) nfd->last = NULL; return p; } /* Insert a packet into the FIFO (in tail) */ static void netio_fifo_insert_pkt (netio_fifo_desc_t * nfd, netio_fifo_pkt_t * p) { pthread_mutex_lock (&nfd->lock); nfd->pkt_count++; p->next = NULL; if (nfd->last) { nfd->last->next = p; } else { nfd->head = p; } nfd->last = p; pthread_mutex_unlock (&nfd->lock); } /* Free the packet list */ static void netio_fifo_free_pkt_list (netio_fifo_desc_t * nfd) { netio_fifo_pkt_t *p, *next; for (p = nfd->head; p; p = next) { next = p->next; free (p); } nfd->head = nfd->last = NULL; nfd->pkt_count = 0; } /* Establish a cross-connect between two FIFO NetIO */ int netio_fifo_crossconnect (netio_desc_t * a, netio_desc_t * b) { netio_fifo_desc_t *pa, *pb; if ((a->type != NETIO_TYPE_FIFO) || (b->type != NETIO_TYPE_FIFO)) return (-1); pa = &a->u.nfd; pb = &b->u.nfd; /* A => B */ pthread_mutex_lock (&pa->endpoint_lock); pthread_mutex_lock (&pa->lock); pa->endpoint = pb; netio_fifo_free_pkt_list (pa); pthread_mutex_unlock (&pa->lock); pthread_mutex_unlock (&pa->endpoint_lock); /* B => A */ pthread_mutex_lock (&pb->endpoint_lock); pthread_mutex_lock (&pb->lock); pb->endpoint = pa; netio_fifo_free_pkt_list (pb); pthread_mutex_unlock (&pb->lock); pthread_mutex_unlock (&pb->endpoint_lock); return (0); } /* Unbind an endpoint */ static void netio_fifo_unbind_endpoint (netio_fifo_desc_t * nfd) { pthread_mutex_lock (&nfd->endpoint_lock); nfd->endpoint = NULL; pthread_mutex_unlock (&nfd->endpoint_lock); } /* Free a NetIO FIFO descriptor */ static void netio_fifo_free (netio_fifo_desc_t * nfd) { if (nfd->endpoint) netio_fifo_unbind_endpoint (nfd->endpoint); netio_fifo_free_pkt_list (nfd); pthread_mutex_destroy (&nfd->lock); pthread_cond_destroy (&nfd->cond); } /* Send a packet (to the endpoint FIFO) */ static ssize_t netio_fifo_send (netio_fifo_desc_t * nfd, void *pkt, size_t pkt_len) { netio_fifo_pkt_t *p; size_t len; pthread_mutex_lock (&nfd->endpoint_lock); /* The cross-connect must have been established before */ if (!nfd->endpoint) goto error; /* Allocate a a new packet and insert it into the endpoint FIFO */ len = sizeof (netio_fifo_pkt_t) + pkt_len; if (!(p = malloc (len))) goto error; memcpy (p->pkt, pkt, pkt_len); p->pkt_len = pkt_len; netio_fifo_insert_pkt (nfd->endpoint, p); pthread_cond_signal (&nfd->endpoint->cond); pthread_mutex_unlock (&nfd->endpoint_lock); return (pkt_len); error: pthread_mutex_unlock (&nfd->endpoint_lock); return (-1); } /* Read a packet from the local FIFO queue */ static ssize_t netio_fifo_recv (netio_fifo_desc_t * nfd, void *pkt, size_t max_len) { struct timespec ts; m_tmcnt_t expire; netio_fifo_pkt_t *p; size_t len = -1; /* Wait for the endpoint to signal a new arriving packet */ expire = m_gettime_usec () + 50000; ts.tv_sec = expire / 1000000; ts.tv_nsec = (expire % 1000000) * 1000; pthread_mutex_lock (&nfd->lock); pthread_cond_timedwait (&nfd->cond, &nfd->lock, &ts); /* Extract a packet from the list */ p = netio_fifo_extract_pkt (nfd); pthread_mutex_unlock (&nfd->lock); if (p) { len = m_min (p->pkt_len, max_len); memcpy (pkt, p->pkt, len); free (p); } return (len); } /* Create a new NetIO descriptor with FIFO method */ netio_desc_t *netio_desc_create_fifo (char *nio_name) { netio_fifo_desc_t *nfd; netio_desc_t *nio; if (!(nio = netio_create (nio_name))) return NULL; nfd = &nio->u.nfd; pthread_mutex_init (&nfd->lock, NULL); pthread_mutex_init (&nfd->endpoint_lock, NULL); pthread_cond_init (&nfd->cond, NULL); nio->type = NETIO_TYPE_FIFO; nio->send = (void *) netio_fifo_send; nio->recv = (void *) netio_fifo_recv; nio->dptr = nfd; if (netio_record (nio) == -1) { netio_free (nio, NULL); return NULL; } return nio; } /* * ========================================================================= * NULL Driver (does nothing, used for debugging) * ========================================================================= */ static ssize_t netio_null_send (void *null_ptr, void *pkt, size_t pkt_len) { return (pkt_len); } static ssize_t netio_null_recv (void *null_ptr, void *pkt, size_t max_len) { usleep (200000); return (-1); } static void netio_null_save_cfg (netio_desc_t * nio, FILE * fd) { fprintf (fd, "nio create_null %s\n", nio->name); } /* Create a new NetIO descriptor with NULL method */ netio_desc_t *netio_desc_create_null (char *nio_name) { netio_desc_t *nio; if (!(nio = netio_create (nio_name))) return NULL; nio->type = NETIO_TYPE_NULL; nio->send = (void *) netio_null_send; nio->recv = (void *) netio_null_recv; nio->save_cfg = netio_null_save_cfg; nio->dptr = NULL; if (netio_record (nio) == -1) { netio_free (nio, NULL); return NULL; } return nio; } #endif /* Free a NetIO descriptor */ static int netio_free (void *data, void *arg) { netio_desc_t *nio = data; if (nio) { switch (nio->type) { case NETIO_TYPE_TAP: netio_tap_free (&nio->u.ntd); break; case NETIO_TYPE_NULL: break; default: fprintf (stderr, "NETIO: unknown descriptor type %u\n", nio->type); } free (nio->name); free (nio); } return (TRUE); } #if 0 /* * ========================================================================= * RX Listeners * ========================================================================= */ /* Find a RX listener */ static inline struct netio_rx_listener *netio_rxl_find (netio_desc_t * nio) { struct netio_rx_listener *rxl; for (rxl = netio_rxl_list; rxl; rxl = rxl->next) if (rxl->nio == nio) return rxl; return NULL; } /* Remove a NIO from the listener list */ static int netio_rxl_remove_internal (netio_desc_t * nio) { struct netio_rx_listener *rxl; int res = -1; if ((rxl = netio_rxl_find (nio))) { /* we suppress this NIO only when the ref count hits 0 */ rxl->ref_count--; if (!rxl->ref_count) { /* remove this listener from the double linked list */ if (rxl->next) rxl->next->prev = rxl->prev; if (rxl->prev) rxl->prev->next = rxl->next; else netio_rxl_list = rxl->next; /* if this is non-FD NIO, wait for thread to terminate */ if (netio_get_fd (rxl->nio) == -1) { rxl->running = FALSE; pthread_join (rxl->spec_thread, NULL); } free (rxl); } res = 0; } return (res); } /* Add a RXL listener to the listener list */ static void netio_rxl_add_internal (struct netio_rx_listener *rxl) { struct netio_rx_listener *tmp; if ((tmp = netio_rxl_find (rxl->nio))) { tmp->ref_count++; free (rxl); } else { rxl->prev = NULL; rxl->next = netio_rxl_list; if (rxl->next) rxl->next->prev = rxl; netio_rxl_list = rxl; } } /* RX Listener dedicated thread (for non-FD NIO) */ static void *netio_rxl_spec_thread (void *arg) { struct netio_rx_listener *rxl = arg; netio_desc_t *nio = rxl->nio; ssize_t pkt_len; while (rxl->running) { pkt_len = netio_recv (nio, nio->rx_pkt, sizeof (nio->rx_pkt)); if (pkt_len > 0) { rxl->rx_handler (nio, nio->rx_pkt, pkt_len, rxl->arg1, rxl->arg2); } } return NULL; } /* RX Listener General Thread */ void *netio_rxl_gen_thread (void *arg) { struct netio_rx_listener *rxl; ssize_t pkt_len; netio_desc_t *nio; struct timeval tv; int fd, fd_max, res; fd_set rfds; for (;;) { NETIO_RXL_LOCK (); NETIO_RXQ_LOCK (); /* Add the new waiting NIO to the active list */ while (netio_rxl_add_list != NULL) { rxl = netio_rxl_add_list; netio_rxl_add_list = netio_rxl_add_list->next; netio_rxl_add_internal (rxl); } /* Delete the NIO present in the remove list */ while (netio_rxl_remove_list != NULL) { nio = netio_rxl_remove_list; netio_rxl_remove_list = netio_rxl_remove_list->rxl_next; netio_rxl_remove_internal (nio); } pthread_cond_broadcast (&netio_rxl_cond); NETIO_RXQ_UNLOCK (); /* Build the FD set */ FD_ZERO (&rfds); fd_max = -1; for (rxl = netio_rxl_list; rxl; rxl = rxl->next) { if ((fd = netio_get_fd (rxl->nio)) == -1) continue; if (fd > fd_max) fd_max = fd; FD_SET (fd, &rfds); } NETIO_RXL_UNLOCK (); /* Wait for incoming packets */ tv.tv_sec = 0; tv.tv_usec = 2 * 1000; /* 2 ms */ res = select (fd_max + 1, &rfds, NULL, NULL, &tv); if (res == -1) { if (errno != EINTR) perror ("netio_rxl_thread: select"); continue; } /* Examine active FDs and call user handlers */ NETIO_RXL_LOCK (); for (rxl = netio_rxl_list; rxl; rxl = rxl->next) { nio = rxl->nio; if ((fd = netio_get_fd (nio)) == -1) continue; if (FD_ISSET (fd, &rfds)) { { pkt_len = netio_recv (nio, nio->rx_pkt, sizeof (nio->rx_pkt)); if (pkt_len > 0) { rxl->rx_handler (nio, nio->rx_pkt, pkt_len, rxl->arg1, rxl->arg2); } } } } } NETIO_RXL_UNLOCK (); } return NULL; } /* Add a RX listener in the listener list */ int netio_rxl_add (netio_desc_t * nio, netio_rx_handler_t rx_handler, void *arg1, void *arg2) { struct netio_rx_listener *rxl; NETIO_RXQ_LOCK (); if (!(rxl = malloc (sizeof (*rxl)))) { NETIO_RXQ_UNLOCK (); fprintf (stderr, "netio_rxl_add: unable to create structure.\n"); return (-1); } memset (rxl, 0, sizeof (*rxl)); rxl->nio = nio; rxl->ref_count = 1; rxl->rx_handler = rx_handler; rxl->arg1 = arg1; rxl->arg2 = arg2; rxl->running = TRUE; if ((netio_get_fd (rxl->nio) == -1) && pthread_create (&rxl->spec_thread, NULL, netio_rxl_spec_thread, rxl)) { NETIO_RXQ_UNLOCK (); fprintf (stderr, "netio_rxl_add: unable to create specific thread.\n"); free (rxl); return (-1); } rxl->next = netio_rxl_add_list; netio_rxl_add_list = rxl; pthread_cond_wait (&netio_rxl_cond, &netio_rxq_mutex); NETIO_RXQ_UNLOCK (); return (0); } /* Remove a NIO from the listener list */ int netio_rxl_remove (netio_desc_t * nio) { NETIO_RXQ_LOCK (); nio->rxl_next = netio_rxl_remove_list; netio_rxl_remove_list = nio; pthread_cond_wait (&netio_rxl_cond, &netio_rxq_mutex); NETIO_RXQ_UNLOCK (); return (0); } /* Initialize the RXL thread */ int netio_rxl_init (void) { pthread_cond_init (&netio_rxl_cond, NULL); if (pthread_create (&netio_rxl_thread, NULL, netio_rxl_gen_thread, NULL)) { perror ("netio_rxl_init: pthread_create"); return (-1); } return (0); } #endif ================================================ FILE: tools/virtualmips/net_io.h ================================================ /* * Cisco router simulation platform. * Copyright (c) 2005,2006 Christophe Fillot (cf@utc.fr) * * Network I/O Layer. */ #ifndef __NET_IO_H__ #define __NET_IO_H__ #include #include #include #include #include "utils.h" /* Maximum packet size */ #define NETIO_MAX_PKT_SIZE 32768 /* Maximum device length */ #define NETIO_DEV_MAXLEN 64 enum { NETIO_TYPE_UNIX = 0, NETIO_TYPE_VDE, NETIO_TYPE_TAP, NETIO_TYPE_UDP, NETIO_TYPE_TCP_CLI, NETIO_TYPE_TCP_SER, #ifdef LINUX_ETH NETIO_TYPE_LINUX_ETH, #endif #ifdef GEN_ETH NETIO_TYPE_GEN_ETH, #endif NETIO_TYPE_FIFO, NETIO_TYPE_NULL, NETIO_TYPE_MAX, }; enum { NETIO_FILTER_ACTION_DROP = 0, NETIO_FILTER_ACTION_PASS, NETIO_FILTER_ACTION_ALTER, NETIO_FILTER_ACTION_DUPLICATE, }; typedef struct netio_desc netio_desc_t; /* VDE switch definitions */ enum vde_request_type { VDE_REQ_NEW_CONTROL }; #define VDE_SWITCH_MAGIC 0xfeedface #define VDE_SWITCH_VERSION 3 struct vde_request_v3 { m_uint32_t magic; m_uint32_t version; enum vde_request_type type; struct sockaddr_un sock; }; /* netio unix descriptor */ typedef struct netio_unix_desc netio_unix_desc_t; struct netio_unix_desc { char *local_filename; struct sockaddr_un remote_sock; int fd; }; /* netio vde descriptor */ typedef struct netio_vde_desc netio_vde_desc_t; struct netio_vde_desc { char *local_filename; struct sockaddr_un remote_sock; int ctrl_fd, data_fd; }; /* netio tap descriptor */ typedef struct netio_tap_desc netio_tap_desc_t; struct netio_tap_desc { char filename[NETIO_DEV_MAXLEN]; int fd; }; /* netio udp/tcp descriptor */ typedef struct netio_inet_desc netio_inet_desc_t; struct netio_inet_desc { int local_port, remote_port; char *remote_host; int fd; }; #ifdef LINUX_ETH /* netio linux raw ethernet descriptor */ typedef struct netio_lnxeth_desc netio_lnxeth_desc_t; struct netio_lnxeth_desc { char dev_name[NETIO_DEV_MAXLEN]; int dev_id, fd; }; #endif #ifdef GEN_ETH /* netio generic raw ethernet descriptor */ typedef struct netio_geneth_desc netio_geneth_desc_t; struct netio_geneth_desc { char dev_name[NETIO_DEV_MAXLEN]; pcap_t *pcap_dev; }; #endif /* FIFO packet */ typedef struct netio_fifo_pkt netio_fifo_pkt_t; struct netio_fifo_pkt { netio_fifo_pkt_t *next; size_t pkt_len; char pkt[0]; }; /* Netio FIFO */ typedef struct netio_fifo_desc netio_fifo_desc_t; struct netio_fifo_desc { pthread_cond_t cond; pthread_mutex_t lock, endpoint_lock; netio_fifo_desc_t *endpoint; netio_fifo_pkt_t *head, *last; u_int pkt_count; }; /* Packet filter */ typedef struct netio_pktfilter netio_pktfilter_t; struct netio_pktfilter { char *name; int (*setup) (netio_desc_t * nio, void **opt, int argc, char *argv[]); void (*free) (netio_desc_t * nio, void **opt); int (*pkt_handler) (netio_desc_t * nio, void *pkt, size_t len, void *opt); netio_pktfilter_t *next; }; /* Generic netio descriptor */ struct netio_desc { u_int type; void *dptr; char *name; int debug; /*can nio recv packet now? */ //u_int can_recv; /* Frame Relay specific information */ //m_uint8_t fr_lmi_seq; //void *fr_conn_list; /* Ethernet specific information */ //u_int vlan_port_type; //m_uint16_t vlan_id; //void *vlan_input_vector; union { //netio_unix_desc_t nud; //netio_vde_desc_t nvd; netio_tap_desc_t ntd; //netio_inet_desc_t nid; #ifdef LINUX_ETH //netio_lnxeth_desc_t nled; #endif #ifdef GEN_ETH //netio_geneth_desc_t nged; #endif //netio_fifo_desc_t nfd; } u; /* Send and receive prototypes */ ssize_t (*send) (void *desc, void *pkt, size_t len); ssize_t (*recv) (void *desc, void *pkt, size_t len); /* Configuration saving */ //void (*save_cfg)(netio_desc_t *nio,FILE *fd); /* Packet filters */ //netio_pktfilter_t *rx_filter,*tx_filter,*both_filter; //void *rx_filter_data,*tx_filter_data,*both_filter_data; /* Next pointer (for RX listener) */ netio_desc_t *rxl_next; /* Packet data */ u_char rx_pkt[NETIO_MAX_PKT_SIZE]; }; /* RX listener */ typedef int (*netio_rx_handler_t) (netio_desc_t * nio, u_char * pkt, ssize_t pkt_len, void *arg1, void *arg2); struct netio_rx_listener { netio_desc_t *nio; u_int ref_count; volatile int running; netio_rx_handler_t rx_handler; void *arg1, *arg2; pthread_t spec_thread; struct netio_rx_listener *prev, *next; }; /* Get NETIO type given a description */ int netio_get_type (char *type); /* Show the NETIO types */ void netio_show_types (void); /* Create a new NetIO descriptor */ netio_desc_t *netio_desc_create_unix (char *nio_name, char *local, char *remote); /* Create a new NetIO descriptor with VDE method */ netio_desc_t *netio_desc_create_vde (char *nio_name, char *control, char *local); /* Create a new NetIO descriptor with TAP method */ netio_desc_t *netio_desc_create_tap (char *nio_name, char *tap_name); /* Create a new NetIO descriptor with TCP_CLI method */ netio_desc_t *netio_desc_create_tcp_cli (char *nio_name, char *addr, char *port); /* Create a new NetIO descriptor with TCP_SER method */ netio_desc_t *netio_desc_create_tcp_ser (char *nio_name, char *port); /* Create a new NetIO descriptor with UDP method */ netio_desc_t *netio_desc_create_udp (char *nio_name, int local_port, char *remote_host, int remote_port); #ifdef LINUX_ETH /* Create a new NetIO descriptor with raw Ethernet method */ netio_desc_t *netio_desc_create_lnxeth (char *nio_name, char *dev_name); #endif #ifdef GEN_ETH /* Create a new NetIO descriptor with generic raw Ethernet method */ netio_desc_t *netio_desc_create_geneth (char *nio_name, char *dev_name); #endif /* Establish a cross-connect between two FIFO NetIO */ int netio_fifo_crossconnect (netio_desc_t * a, netio_desc_t * b); /* Create a new NetIO descriptor with FIFO method */ netio_desc_t *netio_desc_create_fifo (char *nio_name); /* Create a new NetIO descriptor with NULL method */ netio_desc_t *netio_desc_create_null (char *nio_name); /* Acquire a reference to NIO from registry (increment reference count) */ netio_desc_t *netio_acquire (char *name); /* Release an NIO (decrement reference count) */ int netio_release (char *name); /* Delete a NetIO descriptor */ int netio_delete (char *name); /* Delete all NetIO descriptors */ int netio_delete_all (void); /* Save the configuration of a NetIO descriptor */ void netio_save_config (netio_desc_t * nio, FILE * fd); /* Save configurations of all NetIO descriptors */ void netio_save_config_all (FILE * fd); /* Send a packet through a NetIO descriptor */ ssize_t netio_send (netio_desc_t * nio, void *pkt, size_t len); /* Receive a packet through a NetIO descriptor */ ssize_t netio_recv (netio_desc_t * nio, void *pkt, size_t max_len); /* Get a NetIO FD */ int netio_get_fd (netio_desc_t * nio); /* Enable a RX listener */ int netio_rxl_enable (netio_desc_t * nio); /* Add an RX listener in the listener list */ int netio_rxl_add (netio_desc_t * nio, netio_rx_handler_t rx_handler, void *arg1, void *arg2); /* Remove a NIO from the listener list */ int netio_rxl_remove (netio_desc_t * nio); /* Initialize the RXL thread */ int netio_rxl_init (void); #endif ================================================ FILE: tools/virtualmips/pavo.c ================================================ /* * Copyright (C) yajin 2008 * * This file is part of the virtualmips distribution. * See LICENSE file for terms of the license. */ #define _GNU_SOURCE #include #include #include #include #include "vp_lock.h" #include "utils.h" #include "mips.h" #include "vm.h" #include "cpu.h" #include "mips_exec.h" #include "debug.h" #include "pavo.h" #include "device.h" #include "dev_cs8900.h" #include "mips_jit.h" #define MIPS_TIMER_INTERRUPT 7 extern m_uint32_t jz4740_int_table[JZ4740_INT_INDEX_MAX]; int dev_jz4740_gpio_init (vm_instance_t * vm, char *name, m_pa_t paddr, m_uint32_t len); int dev_jz4740_uart_init (vm_instance_t * vm, char *name, m_pa_t paddr, m_uint32_t len, u_int irq, vtty_t * vtty); int dev_jz4740_cpm_init (vm_instance_t * vm, char *name, m_pa_t paddr, m_uint32_t len); int dev_jz4740_emc_init (vm_instance_t * vm, char *name, m_pa_t paddr, m_uint32_t len); int dev_jz4740_rtc_init (vm_instance_t * vm, char *name, m_pa_t paddr, m_uint32_t len); int dev_jz4740_wdt_tcu_init (vm_instance_t * vm, char *name, m_pa_t paddr, m_uint32_t len); int dev_jz4740_int_init (vm_instance_t * vm, char *name, m_pa_t paddr, m_uint32_t len); int dev_jz4740_dma_init (vm_instance_t * vm, char *name, m_pa_t paddr, m_uint32_t len); int dev_jz4740_lcd_init (vm_instance_t * vm, char *name, m_pa_t paddr, m_uint32_t len); void dev_jz4740_gpio_setirq (int irq); void dev_jz4740_gpio_clearirq (int irq); /* Initialize default parameters for pavo */ static void pavo_init_defaults (pavo_t * pavo) { vm_instance_t *vm = pavo->vm; if (vm->configure_filename == NULL) vm->configure_filename = strdup (PAVO_DEFAULT_CONFIG_FILE); vm->ram_size = PAVO_DEFAULT_RAM_SIZE; vm->boot_method = PAVO_DEFAULT_BOOT_METHOD; vm->kernel_filename = strdup (PAVO_DEFAULT_KERNEL_FILENAME); } int pavo_init_cs8900 (pavo_t * pavo, char *name, m_pa_t paddr, m_uint32_t len, int irq_no) { struct vm_instance *vm = pavo->vm; int nio_type = -1; netio_desc_t *nio; int count; char *tokens[10]; struct cs8900_data *d; if ((count = m_strsplit (pavo->cs8900_iotype, ':', tokens, 10)) < 2) { vm_error (vm, "unable to parse NIO description '%s'.\n", pavo->cs8900_iotype); return (-1); } nio_type = netio_get_type (tokens[0]); switch (nio_type) { case NETIO_TYPE_TAP: nio = netio_desc_create_tap (name, tokens[1]); break; //case NETIO_TYPE_LINUX_ETH: // nio=netio_desc_create_lnxeth(name,tokens[1]); // break; default: return (-1); } if (!nio) { vm_error (vm, "unable to create NETIO descriptor %s\n", tokens[0]); return (-1); } d = dev_cs8900_init (vm, name, paddr, len, irq_no); if (!d) { vm_error (vm, "unable to int cs8900\n"); return (-1); } if (dev_cs8900_set_nio (d, nio) == -1) { vm_error (vm, "unable to set cs8900 nio \n"); return (-1); } return 0; } /* Initialize the PAVO Platform (MIPS) */ static int pavo_init_platform (pavo_t * pavo) { struct vm_instance *vm = pavo->vm; cpu_mips_t *cpu0; void *(*cpu_run_fn) (void *); vm_init_vtty (vm); /* Create a CPU group */ vm->cpu_group = cpu_group_create ("System CPU"); /* Initialize the virtual MIPS processor */ if (!(cpu0 = cpu_create (vm, CPU_TYPE_MIPS32, 0))) { vm_error (vm, "unable to create CPU0!\n"); return (-1); } /* Add this CPU to the system CPU group */ cpu_group_add (vm->cpu_group, cpu0); vm->boot_cpu = cpu0; cpu_run_fn = (void *) mips_exec_run_cpu; /* create the CPU thread execution */ if (pthread_create (&cpu0->cpu_thread, NULL, cpu_run_fn, cpu0) != 0) { fprintf (stderr, "cpu_create: unable to create thread for CPU%u\n", 0); free (cpu0); return (-1); } cpu0->addr_bus_mask = PAVO_ADDR_BUS_MASK; /* Initialize RAM */ vm_ram_init (vm, 0x00000000ULL); /*create 1GB nand flash */ if ((vm->flash_size == 0x400) && (vm->flash_type = FLASH_TYPE_NAND_FLASH)) if (dev_nand_flash_1g_init (vm, "NAND FLASH 1G", NAND_DATAPORT, 0x10004, &(pavo->nand_flash)) == -1) return (-1); if (dev_jz4740_gpio_init (vm, "JZ4740 GPIO", JZ4740_GPIO_BASE, JZ4740_GPIO_SIZE) == -1) return (-1); if (dev_jz4740_uart_init (vm, "JZ4740 UART0", JZ4740_UART0_BASE, JZ4740_UART0_SIZE, 9, vm->vtty_con1) == -1) return (-1); if (dev_jz4740_uart_init (vm, "JZ4740 UART1", JZ4740_UART1_BASE, JZ4740_UART1_SIZE, 8, vm->vtty_con2) == -1) return (-1); if (dev_jz4740_cpm_init (vm, "JZ4740 CPM", JZ4740_CPM_BASE, JZ4740_CPM_SIZE) == -1) return (-1); if (dev_jz4740_emc_init (vm, "JZ4740 EMC", JZ4740_EMC_BASE, JZ4740_EMC_SIZE) == -1) return (-1); if (dev_jz4740_rtc_init (vm, "JZ4740 RTC", JZ4740_RTC_BASE, JZ4740_RTC_SIZE) == -1) return (-1); if (dev_jz4740_wdt_tcu_init (vm, "JZ4740 WDT/TCU", JZ4740_WDT_TCU_BASE, JZ4740_WDT_TCU_SIZE) == -1) return (-1); if (dev_jz4740_int_init (vm, "JZ4740 INT", JZ4740_INT_BASE, JZ4740_INT_SIZE) == -1) return (-1); if (dev_jz4740_dma_init (vm, "JZ4740 DMA", JZ4740_DMA_BASE, JZ4740_DMA_SIZE) == -1) return (-1); if (pavo->cs8900_enable == 1) { if (pavo_init_cs8900 (pavo, "CS8900A", CS8900_IO_BASE, CS8900_SIZE, CS8900_DEFAULT_IRQ) == -1) return (-1); } /*LCD*/ #ifdef SIM_LCD if (dev_jz4740_lcd_init (vm, "JZ4740 LCD", JZ4740_LCD_BASE, JZ4740_LCD_SIZE) == -1) return (-1); #endif return (0); } static int pavo_boot (pavo_t * pavo) { vm_instance_t *vm = pavo->vm; if (!vm->boot_cpu) return (-1); return jz4740_reset (vm); } void pavo_clear_irq (vm_instance_t * vm, u_int irq) { m_uint32_t irq_mask; irq_mask = 1 << irq; /*clear ISR and IPR */ jz4740_int_table[INTC_ISR / 4] &= ~irq_mask; jz4740_int_table[INTC_IPR / 4] &= ~irq_mask; } /*map irq to soc irq*/ int forced_inline plat_soc_irq (u_int irq) { if ((irq >= 48) && (irq <= 175)) { dev_jz4740_gpio_setirq (irq); /*GPIO IRQ */ if ((irq >= 48) && (irq <= 79)) irq = IRQ_GPIO0; else if ((irq >= 80) && (irq <= 111)) irq = IRQ_GPIO1; else if ((irq >= 112) && (irq <= 143)) irq = IRQ_GPIO2; else if ((irq >= 144) && (irq <= 175)) irq = IRQ_GPIO3; } return irq; } void pavo_set_irq (vm_instance_t * vm, u_int irq) { m_uint32_t irq_mask; irq = plat_soc_irq (irq); irq_mask = 1 << irq; jz4740_int_table[INTC_ISR / 4] |= irq_mask; /*first check ICMR. masked interrupt is **invisible** to cpu */ if (unlikely (jz4740_int_table[INTC_IMR / 4] & irq_mask)) { /*the irq is masked. clear IPR */ jz4740_int_table[INTC_IPR / 4] &= ~irq_mask; } else { /*the irq is not masked */ /*set IPR */ /* * we set IPR, not *or* . yajin * * JZ Kernel 'plat_irq_dispatch' determine which is the highest priority interrupt * and handle. * It uses a function ffs to find first set irq from least bit to highest bit. * 260 irq = ffs(intc_ipr) - 1; * * That means when tcu0 irq and gpio1 irq occurs at the same time ,INTC_IPR=0x8800000 * and irq handler will handle tcu0 irq(bit 23) not gpio1 irq(bit 27). * * In pavo gpio1->cs8900 int * * TCU0 irq occurs every 10 ms and gpio1 occurs about 10ms (cs8900 has received a packet * or has txed a packet), jz kernel always handle tcu0 irq. gpio1 irq is hungry. So I just set * jz4740_int_table[INTC_IPR/4]= irq_mask not or(|) irq_mask. TCU0 irq may be lost. However, * gpio1 irq is not so ofen so it is not a big problem. * * In emulator, irq is not a good method for hardware to tell kernel something has happened. * Emulator likes polling more than interrupt :) . * */ jz4740_int_table[INTC_IPR / 4] = irq_mask; mips_set_irq (vm->boot_cpu, JZ4740_INT_TO_MIPS); mips_update_irq_flag (vm->boot_cpu); } } COMMON_CONFIG_INFO_ARRAY; static void printf_configure (pavo_t * pavo) { vm_instance_t *vm = pavo->vm; PRINT_COMMON_CONFIG_OPTION; /*print other configure information here */ if (pavo->cs8900_enable == 1) { printf ("CS8900 net card enabled\n"); printf ("CS8900 iotype %s \n", pavo->cs8900_iotype); } else printf ("CS8900 net card disenabled\n"); } static void pavo_parse_configure (pavo_t * pavo) { vm_instance_t *vm = pavo->vm; cfg_opt_t opts[] = { COMMON_CONFIG_OPTION /*add other configure information here */ CFG_SIMPLE_INT ("cs8900_enable", &(pavo->cs8900_enable)), CFG_SIMPLE_STR ("cs8900_iotype", &(pavo->cs8900_iotype)), CFG_SIMPLE_INT ("jit_use", &(vm->jit_use)), CFG_END () }; cfg_t *cfg; cfg = cfg_init (opts, 0); cfg_parse (cfg, vm->configure_filename); cfg_free (cfg); VALID_COMMON_CONFIG_OPTION; /*add other configure information validation here */ if (vm->boot_method == BOOT_BINARY) { ASSERT (vm->boot_from == 2, "boot_from must be 2(NAND Flash)\n pavo only can boot from NAND Flash.\n"); } if (vm->flash_size != 0) { ASSERT (vm->flash_size == 4, "flash_size should be 4.\n We only support 4MB NOR flash emulation\n"); } if (pavo->cs8900_enable == 1) { ASSERT (pavo->cs8900_iotype != NULL, "You must set cs8900_enable \n"); } if (vm->jit_use == 1) { ASSERT (JIT_SUPPORT == 1, "You must compile with JIT Support to use jit. \n"); } /*Print the configure information */ printf_configure (pavo); } /* Clear timer interrupt */ void clear_timer_irq (cpu_mips_t *cpu) { mips_clear_irq (cpu, MIPS_TIMER_INTERRUPT); mips_update_irq_flag (cpu); } /* Create a router instance */ vm_instance_t *create_instance (char *configure_filename) { pavo_t *pavo; char *name; if (!(pavo = malloc (sizeof (*pavo)))) { fprintf (stderr, "ADM5120': Unable to create new instance!\n"); return NULL; } memset (pavo, 0, sizeof (*pavo)); name = strdup ("pavo"); if (!(pavo->vm = vm_create (name, VM_TYPE_PAVO))) { fprintf (stderr, "PAVO : unable to create VM instance!\n"); goto err_vm; } free (name); if (configure_filename != NULL) pavo->vm->configure_filename = strdup (configure_filename); pavo_init_defaults (pavo); pavo_parse_configure (pavo); /*init gdb debug */ vm_debug_init (pavo->vm); pavo->vm->hw_data = pavo; return (pavo->vm); err_vm: free (name); free (pavo); return NULL; } int init_instance (vm_instance_t * vm) { pavo_t *pavo = VM_PAVO (vm); if (pavo_init_platform (pavo) == -1) { vm_error (vm, "unable to initialize the platform hardware.\n"); return (-1); } /* IRQ routing */ vm->set_irq = pavo_set_irq; vm->clear_irq = pavo_clear_irq; return (pavo_boot (pavo)); } ================================================ FILE: tools/virtualmips/pavo.conf ================================================ #configure file for pavo # RAM size in kbytes. If not set, default value is 65536. ram_size = 65536 #1:Binary 2:elf boot_method = 1 #1:NOR FLASH 2 NAND FLASH boot_from = 2 kernel_file_name = "vmlinux-pavo" #1 NOR 2 NAND flash_type = 2 flash_size = 0x400 /*Mbytes*/ #flash_file_name = "flash.bin" only need for nor flash #flash_phy_address = 0x1fc00000 only need for nor flash gdb_debug = 0 gdb_port = 5555 cs8900_enable = 1 cs8900_iotype = "tap:tap0" #JIT. MUST compile with JIT support if you set jit_use=1 #JIT is only supported on X86_32 host. AMD64 is not supported. #jit_use = 1 ================================================ FILE: tools/virtualmips/pavo.h ================================================ /* * Copyright (C) yajin 2008 * * This file is part of the virtualmips distribution. * See LICENSE file for terms of the license. * */ #ifndef __PAVO_H__ #define __PAVO_H__ #include "jz4740.h" #include "dev_nand_flash_1g.h" #ifdef SIM_LCD #include "vp_sdl.h" #endif #define PAVO_DEFAULT_CONFIG_FILE "pavo.conf" #define PAVO_DEFAULT_RAM_SIZE 16 #define PAVO_DEFAULT_BOOT_METHOD BOOT_BINARY #define PAVO_DEFAULT_KERNEL_FILENAME "vmlinux" #define PAVO_ADDR_BUS_MASK 0xffffffff /*32bit phy address */ struct pavo_system { /* Associated VM instance */ vm_instance_t *vm; nand_flash_1g_data_t *nand_flash; m_uint32_t cs8900_enable; char *cs8900_iotype; /*For LCD */ //#ifdef SIM_LCD //struct DisplayState *ds; //#endif }; typedef struct pavo_system pavo_t; #define VM_PAVO(vm) ((pavo_t *)vm->hw_data) vm_instance_t *create_instance (char *conf); int init_instance (vm_instance_t * vm); //void virtual_timer(cpu_mips_t *cpu); int pavo_reset (vm_instance_t * vm); #endif ================================================ FILE: tools/virtualmips/pic32.c ================================================ /* * PIC32 emulation. * * Copyright (C) 2011 Serge Vakulenko * * This file is part of the virtualmips distribution. * See LICENSE file for terms of the license. */ #define _GNU_SOURCE #include #include #include #include "vp_lock.h" #include "utils.h" #include "mips.h" #include "vm.h" #include "cpu.h" #include "mips_exec.h" #include "debug.h" #include "pic32.h" #include "device.h" #include "mips_jit.h" /* * Translate IRQ number to interrupt vector. */ static const int irq_to_vector[] = { PIC32_VECT_CT, /* 0 - Core Timer Interrupt */ PIC32_VECT_CS0, /* 1 - Core Software Interrupt 0 */ PIC32_VECT_CS1, /* 2 - Core Software Interrupt 1 */ PIC32_VECT_INT0, /* 3 - External Interrupt 0 */ PIC32_VECT_T1, /* 4 - Timer1 */ PIC32_VECT_IC1, /* 5 - Input Capture 1 */ PIC32_VECT_OC1, /* 6 - Output Compare 1 */ PIC32_VECT_INT1, /* 7 - External Interrupt 1 */ PIC32_VECT_T2, /* 8 - Timer2 */ PIC32_VECT_IC2, /* 9 - Input Capture 2 */ PIC32_VECT_OC2, /* 10 - Output Compare 2 */ PIC32_VECT_INT2, /* 11 - External Interrupt 2 */ PIC32_VECT_T3, /* 12 - Timer3 */ PIC32_VECT_IC3, /* 13 - Input Capture 3 */ PIC32_VECT_OC3, /* 14 - Output Compare 3 */ PIC32_VECT_INT3, /* 15 - External Interrupt 3 */ PIC32_VECT_T4, /* 16 - Timer4 */ PIC32_VECT_IC4, /* 17 - Input Capture 4 */ PIC32_VECT_OC4, /* 18 - Output Compare 4 */ PIC32_VECT_INT4, /* 19 - External Interrupt 4 */ PIC32_VECT_T5, /* 20 - Timer5 */ PIC32_VECT_IC5, /* 21 - Input Capture 5 */ PIC32_VECT_OC5, /* 22 - Output Compare 5 */ PIC32_VECT_SPI1, /* 23 - SPI1 Fault */ PIC32_VECT_SPI1, /* 24 - SPI1 Transfer Done */ PIC32_VECT_SPI1, /* 25 - SPI1 Receive Done */ PIC32_VECT_U1 | /* 26 - UART1 Error */ PIC32_VECT_SPI3 | /* 26 - SPI3 Fault */ PIC32_VECT_I2C3, /* 26 - I2C3 Bus Collision Event */ PIC32_VECT_U1 | /* 27 - UART1 Receiver */ PIC32_VECT_SPI3 | /* 27 - SPI3 Transfer Done */ PIC32_VECT_I2C3, /* 27 - I2C3 Slave Event */ PIC32_VECT_U1 | /* 28 - UART1 Transmitter */ PIC32_VECT_SPI3 | /* 28 - SPI3 Receive Done */ PIC32_VECT_I2C3, /* 28 - I2C3 Master Event */ PIC32_VECT_I2C1, /* 29 - I2C1 Bus Collision Event */ PIC32_VECT_I2C1, /* 30 - I2C1 Slave Event */ PIC32_VECT_I2C1, /* 31 - I2C1 Master Event */ PIC32_VECT_CN, /* 32 - Input Change Interrupt */ PIC32_VECT_AD1, /* 33 - ADC1 Convert Done */ PIC32_VECT_PMP, /* 34 - Parallel Master Port */ PIC32_VECT_CMP1, /* 35 - Comparator Interrupt */ PIC32_VECT_CMP2, /* 36 - Comparator Interrupt */ PIC32_VECT_U3 | /* 37 - UART3 Error */ PIC32_VECT_SPI2 | /* 37 - SPI2 Fault */ PIC32_VECT_I2C4, /* 37 - I2C4 Bus Collision Event */ PIC32_VECT_U3 | /* 38 - UART3 Receiver */ PIC32_VECT_SPI2 | /* 38 - SPI2 Transfer Done */ PIC32_VECT_I2C4, /* 38 - I2C4 Slave Event */ PIC32_VECT_U3 | /* 39 - UART3 Transmitter */ PIC32_VECT_SPI2 | /* 39 - SPI2 Receive Done */ PIC32_VECT_I2C4, /* 39 - I2C4 Master Event */ PIC32_VECT_U2 | /* 40 - UART2 Error */ PIC32_VECT_SPI4 | /* 40 - SPI4 Fault */ PIC32_VECT_I2C5, /* 40 - I2C5 Bus Collision Event */ PIC32_VECT_U2 | /* 41 - UART2 Receiver */ PIC32_VECT_SPI4 | /* 41 - SPI4 Transfer Done */ PIC32_VECT_I2C5, /* 41 - I2C5 Slave Event */ PIC32_VECT_U2 | /* 42 - UART2 Transmitter */ PIC32_VECT_SPI4 | /* 42 - SPI4 Receive Done */ PIC32_VECT_I2C5, /* 42 - I2C5 Master Event */ PIC32_VECT_I2C2, /* 43 - I2C2 Bus Collision Event */ PIC32_VECT_I2C2, /* 44 - I2C2 Slave Event */ PIC32_VECT_I2C2, /* 45 - I2C2 Master Event */ PIC32_VECT_FSCM, /* 46 - Fail-Safe Clock Monitor */ PIC32_VECT_RTCC, /* 47 - Real-Time Clock and Calendar */ PIC32_VECT_DMA0, /* 48 - DMA Channel 0 */ PIC32_VECT_DMA1, /* 49 - DMA Channel 1 */ PIC32_VECT_DMA2, /* 50 - DMA Channel 2 */ PIC32_VECT_DMA3, /* 51 - DMA Channel 3 */ PIC32_VECT_DMA4, /* 52 - DMA Channel 4 */ PIC32_VECT_DMA5, /* 53 - DMA Channel 5 */ PIC32_VECT_DMA6, /* 54 - DMA Channel 6 */ PIC32_VECT_DMA7, /* 55 - DMA Channel 7 */ PIC32_VECT_FCE, /* 56 - Flash Control Event */ PIC32_VECT_USB, /* 57 - USB */ PIC32_VECT_CAN1, /* 58 - Control Area Network 1 */ PIC32_VECT_CAN2, /* 59 - Control Area Network 2 */ PIC32_VECT_ETH, /* 60 - Ethernet Interrupt */ PIC32_VECT_IC1, /* 61 - Input Capture 1 Error */ PIC32_VECT_IC2, /* 62 - Input Capture 2 Error */ PIC32_VECT_IC3, /* 63 - Input Capture 3 Error */ PIC32_VECT_IC4, /* 64 - Input Capture 4 Error */ PIC32_VECT_IC5, /* 65 - Input Capture 5 Error */ PIC32_VECT_PMP, /* 66 - Parallel Master Port Error */ PIC32_VECT_U4, /* 67 - UART4 Error */ PIC32_VECT_U4, /* 68 - UART4 Receiver */ PIC32_VECT_U4, /* 69 - UART4 Transmitter */ PIC32_VECT_U6, /* 70 - UART6 Error */ PIC32_VECT_U6, /* 71 - UART6 Receiver */ PIC32_VECT_U6, /* 72 - UART6 Transmitter */ PIC32_VECT_U5, /* 73 - UART5 Error */ PIC32_VECT_U5, /* 74 - UART5 Receiver */ PIC32_VECT_U5, /* 75 - UART5 Transmitter */ }; /* Initialize the PIC32 Platform (MIPS) */ static int pic32_init_platform (pic32_t *pic32) { struct vm_instance *vm = pic32->vm; cpu_mips_t *cpu0; void *(*cpu_run_fn) (void *); vm_init_vtty (vm); /* Create a CPU group */ vm->cpu_group = cpu_group_create ("System CPU"); /* Initialize the virtual MIPS processor */ cpu0 = cpu_create (vm, CPU_TYPE_MIPS32, 0); if (! cpu0) { vm_error (vm, "unable to create CPU0!\n"); return (-1); } /* Add this CPU to the system CPU group */ cpu_group_add (vm->cpu_group, cpu0); vm->boot_cpu = cpu0; /* create the CPU thread execution */ cpu_run_fn = (void *) mips_exec_run_cpu; if (pthread_create (&cpu0->cpu_thread, NULL, cpu_run_fn, cpu0) != 0) { fprintf (stderr, "cpu_create: unable to create thread for CPU%u\n", 0); free (cpu0); return (-1); } /* 32-bit address */ cpu0->addr_bus_mask = 0xffffffff; /* Initialize RAM */ vm_ram_init (vm, 0x00000000ULL); /* Initialize two flash areas */ if (vm->flash_size != 0) if (dev_pic32_flash_init (vm, "Program flash", vm->flash_size, vm->flash_address, vm->flash_filename) == -1) return (-1); if (pic32->boot_flash_size != 0) if (dev_pic32_flash_init (vm, "Boot flash", pic32->boot_flash_size, pic32->boot_flash_address, pic32->boot_file_name) == -1) return (-1); /* Initialize peripherals */ if (dev_pic32_uart_init (vm, "UART1", PIC32_U1MODE, PIC32_IRQ_U1E, vm->vtty_con[0]) == -1) return (-1); if (dev_pic32_uart_init (vm, "UART2", PIC32_U2MODE, PIC32_IRQ_U2E, vm->vtty_con[1]) == -1) return (-1); #if NVTTY >= 3 if (dev_pic32_uart_init (vm, "UART3", PIC32_U3MODE, PIC32_IRQ_U3E, vm->vtty_con[2]) == -1) return (-1); #endif #if NVTTY >= 4 if (dev_pic32_uart_init (vm, "UART4", PIC32_U4MODE, PIC32_IRQ_U4E, vm->vtty_con[3]) == -1) return (-1); #endif #if NVTTY >= 5 if (dev_pic32_uart_init (vm, "UART5", PIC32_U5MODE, PIC32_IRQ_U5E, vm->vtty_con[4]) == -1) return (-1); #endif #if NVTTY >= 6 if (dev_pic32_uart_init (vm, "UART6", PIC32_U6MODE, PIC32_IRQ_U6E, vm->vtty_con[5]) == -1) return (-1); #endif if (dev_pic32_intcon_init (vm, "INTCON", PIC32_INTCON) == -1) return (-1); if (dev_pic32_dmacon_init (vm, "DMACON", PIC32_DMACON) == -1) return (-1); if (dev_pic32_syscon_init (vm, "SYSCON", PIC32_OSCCON) == -1) return (-1); if (dev_pic32_adc_init (vm, "ADC", PIC32_AD1CON1) == -1) return (-1); if (dev_pic32_prefetch_init (vm, "Prefetch", PIC32_CHECON) == -1) return (-1); if (dev_pic32_bmxcon_init (vm, "BMX", PIC32_BMXCON) == -1) return (-1); if (dev_pic32_rtcc_init (vm, "RTCC", PIC32_RTCCON) == -1) return (-1); if (dev_pic32_gpio_init (vm, "GPIO", PIC32_TRISA) == -1) return (-1); if (dev_pic32_spi_init (vm, "SPI1", PIC32_SPI1CON, PIC32_IRQ_SPI1E) == -1) return (-1); if (dev_pic32_spi_init (vm, "SPI2", PIC32_SPI2CON, PIC32_IRQ_SPI2E) == -1) return (-1); if (dev_pic32_spi_init (vm, "SPI3", PIC32_SPI3CON, PIC32_IRQ_SPI3E) == -1) return (-1); if (dev_pic32_spi_init (vm, "SPI4", PIC32_SPI4CON, PIC32_IRQ_SPI4E) == -1) return (-1); pic32->timer1 = dev_pic32_timer_init (vm, "Timer1", PIC32_T1CON, PIC32_IRQ_T1); pic32->timer2 = dev_pic32_timer_init (vm, "Timer2", PIC32_T2CON, PIC32_IRQ_T2); pic32->timer3 = dev_pic32_timer_init (vm, "Timer3", PIC32_T3CON, PIC32_IRQ_T3); pic32->timer4 = dev_pic32_timer_init (vm, "Timer4", PIC32_T4CON, PIC32_IRQ_T4); pic32->timer5 = dev_pic32_timer_init (vm, "Timer5", PIC32_T5CON, PIC32_IRQ_T5); if (! pic32->timer1 || ! pic32->timer2 || ! pic32->timer3 || ! pic32->timer4 || ! pic32->timer5) return (-1); if (dev_sdcard_init (&pic32->sdcard[0], "SD0", pic32->sdcard0_size, pic32->sdcard0_file_name) < 0) return (-1); if (dev_sdcard_init (&pic32->sdcard[1], "SD1", pic32->sdcard1_size, pic32->sdcard1_file_name) < 0) return (-1); if (dev_swap_init (&pic32->swap, "Swap") < 0) return (-1); /* Initialize DEVCFG area */ if (dev_pic32_devcfg_init (vm, "DEVCFG", 0x1fc02f00) < 0) return (-1); pic32->sdcard[1].unit = 1; return (0); } /* * Find pending interrupt with the biggest priority. * Setup INTSTAT and cause registers. * Update irq_pending flag for CPU. */ void pic32_update_irq_flag (pic32_t *pic32) { cpu_mips_t *cpu = pic32->vm->boot_cpu; int vector, level, irq, n, v; /* Assume no interrupts pending. */ cpu->irq_cause = 0; cpu->irq_pending = 0; pic32->intstat = 0; if ((pic32->ifs[0] & pic32->iec[0]) || (pic32->ifs[1] & pic32->iec[1]) || (pic32->ifs[2] & pic32->iec[2])) { /* Find the most prioritive pending interrupt, * it's vector and level. */ vector = 0; level = 0; for (irq=0; irq> 5; if ((pic32->ifs[n] & pic32->iec[n]) >> (irq & 31) & 1) { /* Interrupt is pending. */ v = irq_to_vector [irq]; if (v < 0) continue; if (pic32->ivprio[v] > level) { vector = v; level = pic32->ivprio[v]; } } } pic32->intstat = vector | (level << 8); cpu->irq_cause = level << 10; /*printf ("-- vector = %d, level = %d\n", vector, level);*/ } /*else printf ("-- no irq pending\n");*/ mips_update_irq_flag (cpu); } void pic32_clear_irq (vm_instance_t *vm, u_int irq) { pic32_t *pic32 = (pic32_t*) vm->hw_data; /* Clear interrupt flag status */ pic32->ifs [irq >> 5] &= ~(1 << (irq & 31)); pic32_update_irq_flag (pic32); } void pic32_set_irq (vm_instance_t *vm, u_int irq) { pic32_t *pic32 = (pic32_t*) vm->hw_data; /* Set interrupt flag status */ pic32->ifs [irq >> 5] |= 1 << (irq & 31); pic32_update_irq_flag (pic32); } /* * Activate core timer interrupt */ void set_timer_irq (cpu_mips_t *cpu) { pic32_set_irq (cpu->vm, PIC32_VECT_CT); } /* * Clear core timer interrupt */ void clear_timer_irq (cpu_mips_t *cpu) { pic32_clear_irq (cpu->vm, PIC32_VECT_CT); } /* * Increment timers. */ void host_alarm (cpu_mips_t *cpu, int nclocks) { pic32_t *pic32 = (pic32_t*) cpu->vm->hw_data; dev_pic32_timer_tick (cpu, pic32->timer1, nclocks); dev_pic32_timer_tick (cpu, pic32->timer2, nclocks); dev_pic32_timer_tick (cpu, pic32->timer3, nclocks); dev_pic32_timer_tick (cpu, pic32->timer4, nclocks); dev_pic32_timer_tick (cpu, pic32->timer5, nclocks); } /* * Configuration information. */ static char *boot_method_string[2] = {"Binary", "ELF"}; static char *boot_from_string[2] = {"NOR FLASH", "NAND FLASH"}; static char *flash_type_string[2] = {"NOR FLASH", "NAND FLASH"}; static char *start_address = 0; static char *trace_address = 0; static char *uart_type[NVTTY] = {0}; static char *uart_port[NVTTY] = {0}; static void configure_parameter (void *arg, char *section, char *param, char *value) { pic32_t *pic32 = arg; vm_instance_t *vm = pic32->vm; if (strcmp (param, "ram_size") == 0) vm->ram_size = strtoul (value, 0, 0); else if (strcmp (param, "gdb_debug") == 0) vm->gdb_debug = strtoul (value, 0, 0); else if (strcmp (param, "gdb_port") == 0) vm->gdb_port = strtoul (value, 0, 0); else if (strcmp (param, "flash_size") == 0) vm->flash_size = strtoul (value, 0, 0); else if (strcmp (param, "flash_type") == 0) vm->flash_type = strtoul (value, 0, 0); else if (strcmp (param, "flash_file_name") == 0) vm->flash_filename = strdup (value); else if (strcmp (param, "flash_phy_address") == 0) vm->flash_address = strtoul (value, 0, 0); else if (strcmp (param, "boot_method") == 0) vm->boot_method = strtoul (value, 0, 0); else if (strcmp (param, "boot_from") == 0) vm->boot_from = strtoul (value, 0, 0); else if (strcmp (param, "kernel_file_name") == 0) vm->kernel_filename = strdup (value); else if (strcmp (param, "jit_use") == 0) vm->jit_use = strtoul (value, 0, 0); else if (strcmp (param, "debug_level") == 0) vm->debug_level = strtoul (value, 0, 0); else if (strcmp (param, "boot_flash_size") == 0) pic32->boot_flash_size = strtoul (value, 0, 0); else if (strcmp (param, "boot_flash_address")== 0) pic32->boot_flash_address = strtoul (value, 0, 0); else if (strcmp (param, "boot_file_name") == 0) pic32->boot_file_name = strdup (value); else if (strcmp (param, "start_address") == 0) start_address = strdup (value); else if (strcmp (param, "trace_address") == 0) trace_address = strdup (value); else if (strcmp (param, "sdcard_port") == 0) pic32->sdcard_port = strtoul (value, 0, 0); else if (strcmp (param, "sdcard0_size") == 0) pic32->sdcard0_size = strtoul (value, 0, 0); else if (strcmp (param, "sdcard1_size") == 0) pic32->sdcard1_size = strtoul (value, 0, 0); else if (strcmp (param, "sdcard0_file_name") == 0) pic32->sdcard0_file_name = strdup (value); else if (strcmp (param, "sdcard1_file_name") == 0) pic32->sdcard1_file_name = strdup (value); else if (strcmp (param, "uart1_type") == 0) uart_type[0] = strdup (value); else if (strcmp (param, "uart2_type") == 0) uart_type[1] = strdup (value); else if (strcmp (param, "uart3_type") == 0) uart_type[2] = strdup (value); else if (strcmp (param, "uart4_type") == 0) uart_type[3] = strdup (value); else if (strcmp (param, "uart5_type") == 0) uart_type[4] = strdup (value); else if (strcmp (param, "uart6_type") == 0) uart_type[5] = strdup (value); else if (strcmp (param, "uart1_port") == 0) uart_port[0] = strdup (value); else if (strcmp (param, "uart2_port") == 0) uart_port[1] = strdup (value); else if (strcmp (param, "uart3_port") == 0) uart_port[2] = strdup (value); else if (strcmp (param, "uart4_port") == 0) uart_port[3] = strdup (value); else if (strcmp (param, "uart5_port") == 0) uart_port[4] = strdup (value); else if (strcmp (param, "uart6_port") == 0) uart_port[5] = strdup (value); else { fprintf (stderr, "%s: unknown parameter `%s'\n", vm->configure_filename, param); exit (-1); } //printf ("Configure: %s = '%s'\n", param, value); } static void pic32_parse_configure (pic32_t *pic32) { vm_instance_t *vm = pic32->vm; int i; conf_parse (vm->configure_filename, configure_parameter, pic32); if (start_address) pic32->start_address = strtoul (start_address, 0, 0); if (trace_address) vm->trace_address = strtoul (trace_address, 0, 0); for (i=0; ivtty_type[i] = VTTY_TYPE_TERM; else if (strcmp (uart_type[i], "tcp") == 0) vm->vtty_type[i] = VTTY_TYPE_TCP; else if (strcmp (uart_type[i], "none") == 0) vm->vtty_type[i] = VTTY_TYPE_NONE; else { printf ("Unknown option: uart%d_type = %s\n", i+1, uart_type[i]); continue; } if (uart_port[i]) { vm->vtty_tcp_port[i] = strtoul (uart_port[i], 0, 0); } else if (vm->vtty_type[i] == VTTY_TYPE_TCP) { vm->vtty_tcp_port[i] = 2300 + i; } } ASSERT(vm->ram_size != 0, "ram_size can not be 0\n"); if (vm->flash_type == FLASH_TYPE_NOR_FLASH) { if (vm->flash_size != 0) { /*ASSERT(vm->flash_filename!=NULL, "flash_file_name can not be NULL\n");*/ /* flash_filename can be null. virtualmips will create it. */ ASSERT(vm->flash_address != 0, "flash_address can not be 0\n"); } } else if (vm->flash_type == FLASH_TYPE_NAND_FLASH) { ASSERT(vm->flash_size == 0x400, "flash_size should be 0x400.\n We only support 1G byte NAND flash emulation\n"); assert(1); } else ASSERT(0, "error flash_type. valid value: 1:NOR FLASH 2:NAND FLASH\n"); ASSERT(vm->boot_method != 0, "boot_method can not be 0\n 1:binary 2:elf \n"); if (vm->boot_method == BOOT_BINARY) { /* boot from binary image */ ASSERT(vm->boot_from != 0, "boot_from can not be 0\n 1:NOR FLASH 2:NAND FLASH\n"); if (vm->boot_from==BOOT_FROM_NOR_FLASH) { ASSERT(vm->flash_type == FLASH_TYPE_NOR_FLASH, "flash_type must be 1(NOR FLASH)\n"); ASSERT(vm->flash_size != 0, "flash_size can not be 0\n"); ASSERT(vm->flash_filename != NULL, "flash_filename can not be NULL\n"); ASSERT(vm->flash_address != 0, "flash_address can not be 0\n"); } else if (vm->boot_from == BOOT_FROM_NAND_FLASH) { ASSERT(vm->flash_type == FLASH_TYPE_NAND_FLASH, "flash_type must be 2(NAND FLASH)\n"); ASSERT(vm->flash_size != 0, "flash_size can not be 0\n"); /*ASSERT(vm->flash_filename!=NULL,"flash_filename can not be NULL\n");*/ } else ASSERT(0, "error boot_from. valid value: 1:NOR FLASH 2:NAND FLASH\n"); } else if (vm->boot_method == BOOT_ELF) { ASSERT(vm->kernel_filename!=0,"kernel_file_name can not be NULL\n "); } else ASSERT(0, "error boot_method. valid value: 1:binary 2:elf \n"); /* Add other configure information validation here */ if (vm->jit_use) { ASSERT (JIT_SUPPORT == 1, "You must compile with JIT Support to use jit.\n"); } /* Print the configure information */ printf("Using configure file: %s\n", vm->configure_filename); printf("ram_size: %dk bytes \n", vm->ram_size); printf("boot_method: %s \n", boot_method_string[vm->boot_method-1]); if (vm->flash_size != 0) { printf("flash_type: %s \n",flash_type_string[vm->flash_type-1]); printf("flash_size: %dk bytes \n",vm->flash_size); if (vm->flash_type == FLASH_TYPE_NOR_FLASH) { printf("flash_file_name: %s \n",vm->flash_filename); printf("flash_phy_address: 0x%x \n",vm->flash_address); } } if (vm->boot_method == BOOT_BINARY) { printf("boot_from: %s \n",boot_from_string[vm->boot_from-1]); } if (vm->boot_method == BOOT_ELF) { printf("kernel_file_name: %s \n",vm->kernel_filename); } if (vm->gdb_debug != 0) { printf("GDB debug enable\n"); printf("GDB port: %d \n",vm->gdb_port); } /* print other configure information here */ if (pic32->boot_flash_size > 0) { printf ("boot_flash_size: %dk bytes\n", pic32->boot_flash_size); printf ("boot_flash_address: 0x%x\n", pic32->boot_flash_address); printf ("boot_file_name: %s\n", pic32->boot_file_name); } if (pic32->sdcard_port) { printf ("sdcard_port: SPI%d\n", pic32->sdcard_port); } if (pic32->sdcard0_size > 0) { printf ("sdcard0_size: %dM bytes\n", pic32->sdcard0_size); printf ("sdcard0_file_name: %s\n", pic32->sdcard0_file_name); } if (pic32->sdcard1_size > 0) { printf ("sdcard1_size: %dM bytes\n", pic32->sdcard1_size); printf ("sdcard1_file_name: %s\n", pic32->sdcard1_file_name); } printf ("start_address: 0x%x\n", pic32->start_address); if (vm->trace_address != 0) printf ("trace_address: 0x%x\n", vm->trace_address); for (i=0; ivtty_type[i] != VTTY_TYPE_NONE) printf ("uart%d_type = %s\n", i+1, vm->vtty_type[i] == VTTY_TYPE_TERM ? "console" : vm->vtty_type[i] == VTTY_TYPE_TCP ? "tcp" : "???"); if (vm->vtty_tcp_port[i]) printf ("uart%d_type = %u\n", i+1, vm->vtty_tcp_port[i]); } } /* * Create an instance of virtual machine. */ vm_instance_t *create_instance (char *configure_filename) { vm_instance_t *vm; pic32_t *pic32; const char *name = "pic32"; int i; pic32 = malloc (sizeof (*pic32)); if (! pic32) { fprintf (stderr, "PIC32: unable to create new instance!\n"); return NULL; } memset (pic32, 0, sizeof (*pic32)); vm = vm_create (name, VM_TYPE_PIC32); if (! vm) { fprintf (stderr, "PIC32: unable to create VM instance!\n"); free (pic32); return NULL; } vm->hw_data = pic32; pic32->vm = vm; vm->vtty_type[0] = VTTY_TYPE_TERM; for (i=1; ivtty_type[i] = VTTY_TYPE_NONE; /* Initialize default parameters for pic32 */ if (configure_filename == NULL) #ifdef UBW32 configure_filename = "pic32_ubw32.conf"; #elif defined EXPLORER16 configure_filename = "pic32_explorer16.conf"; #elif defined MAXIMITE configure_filename = "pic32_maximite.conf"; #elif defined MAX32 configure_filename = "pic32_max32.conf"; #endif vm->configure_filename = strdup (configure_filename); vm->ram_size = 128; /* kilobytes */ vm->boot_method = BOOT_BINARY; vm->boot_from = BOOT_FROM_NOR_FLASH; vm->flash_type = FLASH_TYPE_NOR_FLASH; pic32_parse_configure (pic32); /* init gdb debug */ vm_debug_init (pic32->vm); return pic32->vm; } int init_instance (vm_instance_t * vm) { pic32_t *pic32 = (pic32_t *) vm->hw_data; cpu_mips_t *cpu; if (pic32_init_platform (pic32) == -1) { vm_error (vm, "unable to initialize the platform hardware.\n"); return (-1); } if (! vm->boot_cpu) { vm_error (vm, "unable to boot cpu.\n"); return (-1); } /* IRQ routing */ vm->set_irq = pic32_set_irq; vm->clear_irq = pic32_clear_irq; vm_suspend (vm); /* Check that CPU activity is really suspended */ if (cpu_group_sync_state (vm->cpu_group) == -1) { vm_error (vm, "unable to sync with system CPUs.\n"); return (-1); } /* Reset the boot CPU */ cpu = vm->boot_cpu; mips_reset (cpu); /* Set config0-config3 registers. */ cpu->cp0.config_usable = 0x0f; cpu->cp0.config_reg[0] = 0xa4010582; cpu->cp0.config_reg[1] = 0x80000004; cpu->cp0.config_reg[2] = 0x80000000; cpu->cp0.config_reg[3] = 0x00000060; /* set PC and PRID */ cpu->cp0.reg[MIPS_CP0_PRID] = 0x00ff8700; /* TODO */ cpu->cp0.tlb_entries = 0; cpu->pc = pic32->start_address; /* reset all devices */ dev_reset_all (vm); dev_sdcard_reset (cpu); #ifdef _USE_JIT_ /* if jit is used. flush all jit buffer */ if (vm->jit_use) mips_jit_flush (cpu, 0); #endif /* Launch the simulation */ printf ("--- Start simulation: PC=0x%" LL "x, JIT %sabled\n", cpu->pc, vm->jit_use ? "en" : "dis"); vm->status = VM_STATUS_RUNNING; cpu_start (vm->boot_cpu); return (0); } ================================================ FILE: tools/virtualmips/pic32.h ================================================ /* * Copyright (C) 2011 Serge Vakulenko * * This file is part of the virtualmips distribution. * See LICENSE file for terms of the license. */ #ifndef __PIC32_H__ #define __PIC32_H__ #include "types.h" #include "pic32mx.h" #include "dev_sdcard.h" #include "dev_swap.h" #define DATA_WIDTH 32 /* MIPS32 architecture */ #define LL /* empty - printf format for machine word */ /* * Data types */ typedef m_uint32_t m_va_t; typedef m_uint32_t m_pa_t; typedef m_uint32_t m_reg_t; typedef m_int32_t m_ireg_t; typedef m_uint32_t m_cp0_reg_t; /*Guest endian*/ #define GUEST_BYTE_ORDER ARCH_LITTLE_ENDIAN /* Host to VM conversion functions */ #if HOST_BYTE_ORDER == GUEST_BYTE_ORDER #define htovm16(x) (x) #define htovm32(x) (x) #define htovm64(x) (x) #define vmtoh16(x) (x) #define vmtoh32(x) (x) #define vmtoh64(x) (x) #else //host:big guest:little #define htovm16(x) (ntohs(x)) #define htovm32(x) (ntohl(x)) #define htovm64(x) (swap64(x)) #define vmtoh16(x) (htons(x)) #define vmtoh32(x) (htonl(x)) #define vmtoh64(x) (swap64(x)) #endif struct pic32_system { /* Associated VM instance */ vm_instance_t *vm; unsigned start_address; /* jump here on reset */ unsigned boot_flash_size; /* size of boot flash in kbytes */ unsigned boot_flash_address; /* physical address of boot flash */ char *boot_file_name; /* image of boot flash */ unsigned sdcard_port; /* SPI port number */ unsigned sdcard0_size; /* size of SD card 0 in Mbytes */ unsigned sdcard1_size; /* size of SD card 1 in Mbytes */ char *sdcard0_file_name; /* image of SD card 0 */ char *sdcard1_file_name; /* image of SD card 1 */ sdcard_t sdcard [2]; /* max number of sdcards */ swap_t swap; /* swap device */ struct vdevice *intdev; /* interrupt controller */ unsigned intcon; /* interrupt control */ unsigned intstat; /* interrupt status */ unsigned iptmr; /* temporal proximity */ unsigned ifs[3]; /* interrupt flag status */ unsigned iec[3]; /* interrupt enable control */ unsigned ipc[12]; /* interrupt priority control */ unsigned ivprio[64]; /* priority of interrupt vectors */ struct vdevice *timer1; /* timer 1 */ struct vdevice *timer2; /* timer 2 */ struct vdevice *timer3; /* timer 3 */ struct vdevice *timer4; /* timer 4 */ struct vdevice *timer5; /* timer 5 */ struct vdevice *bmxdev; /* memory controller */ unsigned bmxcon; /* memory control */ unsigned bmx_ram_kpba; /* RAM kernel program base address */ unsigned bmx_ram_udba; /* RAM user data base address */ unsigned bmx_ram_upba; /* RAM user program base address */ unsigned bmx_flash_upba; /* Flash user program base address */ struct vdevice *rtcdev; /* RTCC controller */ unsigned rtccon; /* RTC control */ struct vdevice *dmadev; /* DMA controller */ unsigned dmacon; /* DMA control */ unsigned dmastat; /* DMA status */ unsigned dmaaddr; /* DMA address */ struct vdevice *sysdev; /* System controller */ unsigned osccon; unsigned osctun; unsigned ddpcon; /* Debug data port control */ unsigned devid; /* Device identifier */ unsigned syskey; unsigned rcon; unsigned rswrst; unsigned ad1con1; /* Analog to digital converter */ unsigned ad1con2; unsigned ad1con3; unsigned ad1chs; unsigned ad1cssl; unsigned ad1pcfg; struct vdevice *cfgdev; /* Device configuration */ unsigned devcfg3; unsigned devcfg2; unsigned devcfg1; unsigned devcfg0; struct vdevice *prefetch; /* Prefetch cache controller */ unsigned checon; }; typedef struct pic32_system pic32_t; struct virtual_tty; vm_instance_t *create_instance (char *conf); int init_instance (vm_instance_t *vm); int pic32_reset (vm_instance_t *vm); void pic32_update_irq_flag (pic32_t *pic32); void pic32_set_irq (vm_instance_t *vm, unsigned irq); void pic32_clear_irq (vm_instance_t *vm, unsigned irq); int dev_pic32_flash_init (vm_instance_t *vm, char *name, unsigned flash_kbytes, unsigned flash_address, char *filename); int dev_pic32_uart_init (vm_instance_t *vm, char *name, unsigned paddr, unsigned irq, struct virtual_tty *vtty); int dev_pic32_intcon_init (vm_instance_t *vm, char *name, unsigned paddr); int dev_pic32_dmacon_init (vm_instance_t *vm, char *name, unsigned paddr); int dev_pic32_syscon_init (vm_instance_t *vm, char *name, unsigned paddr); int dev_pic32_adc_init (vm_instance_t *vm, char *name, unsigned paddr); int dev_pic32_prefetch_init (vm_instance_t *vm, char *name, unsigned paddr); int dev_pic32_bmxcon_init (vm_instance_t *vm, char *name, unsigned paddr); int dev_pic32_rtcc_init (vm_instance_t *vm, char *name, unsigned paddr); int dev_pic32_spi_init (vm_instance_t *vm, char *name, unsigned paddr, unsigned irq); struct vdevice *dev_pic32_timer_init (vm_instance_t *vm, char *name, unsigned paddr, unsigned irq); int dev_pic32_gpio_init (vm_instance_t *vm, char *name, unsigned paddr); int dev_pic32_devcfg_init (vm_instance_t *vm, char *name, unsigned paddr); void dev_pic32_timer_tick (cpu_mips_t *cpu, struct vdevice *dev, unsigned nclocks); void dumpregs (cpu_mips_t *cpu); #endif ================================================ FILE: tools/virtualmips/pic32_dev_adc.c ================================================ /* * System controller for PIC32. * * Copyright (C) 2011 Serge Vakulenko * * This file is part of the virtualmips distribution. * See LICENSE file for terms of the license. */ #define _GNU_SOURCE #include #include #include #include #include #include #include "device.h" #include "mips_memory.h" #include "cpu.h" #include "pic32.h" #define ADC_REG_SIZE 0x170 extern cpu_mips_t *current_cpu; /* * Perform an assign/clear/set/invert operation. */ static inline unsigned write_op (int a, int b, int op) { switch (op & 0xc) { case 0x0: /* Assign */ a = b; break; case 0x4: /* Clear */ a &= ~b; break; case 0x8: /* Set */ a |= b; break; case 0xc: /* Invert */ a ^= b; break; } return a; } void *dev_pic32_adc_access (cpu_mips_t *cpu, struct vdevice *dev, m_uint32_t offset, u_int op_size, u_int op_type, m_reg_t *data, m_uint8_t *has_set_value) { pic32_t *pic32 = dev->priv_data; if (offset >= ADC_REG_SIZE) { *data = 0; return NULL; } if (op_type == MTS_READ) *data = 0; switch (offset & 0xff0) { case PIC32_AD1CON1 & 0xff0: /* Control register 1 */ if (op_type == MTS_READ) { *data = pic32->ad1con1; } else { pic32->ad1con1 = write_op (pic32->ad1con1, *data, offset); } break; case PIC32_AD1CON2 & 0xff0: /* Control register 2 */ if (op_type == MTS_READ) { *data = pic32->ad1con2; } else { pic32->ad1con2 = write_op (pic32->ad1con2, *data, offset); } break; case PIC32_AD1CON3 & 0xff0: /* Control register 3 */ if (op_type == MTS_READ) { *data = pic32->ad1con3; } else { pic32->ad1con3 = write_op (pic32->ad1con3, *data, offset); } break; case PIC32_AD1CHS & 0xff0: /* Channel select */ if (op_type == MTS_READ) { *data = pic32->ad1chs; } else { pic32->ad1chs = write_op (pic32->ad1chs, *data, offset); } break; case PIC32_AD1CSSL & 0xff0: /* Input scan selection */ if (op_type == MTS_READ) { *data = pic32->ad1cssl; } else { pic32->ad1cssl = write_op (pic32->ad1cssl, *data, offset); } break; case PIC32_AD1PCFG & 0xff0: /* Port configuration */ if (op_type == MTS_READ) { *data = pic32->ad1pcfg; } else { pic32->ad1pcfg = write_op (pic32->ad1pcfg, *data, offset); } break; case PIC32_ADC1BUF0 & 0xff0: case PIC32_ADC1BUF1 & 0xff0: case PIC32_ADC1BUF2 & 0xff0: case PIC32_ADC1BUF3 & 0xff0: case PIC32_ADC1BUF4 & 0xff0: case PIC32_ADC1BUF5 & 0xff0: case PIC32_ADC1BUF6 & 0xff0: case PIC32_ADC1BUF7 & 0xff0: case PIC32_ADC1BUF8 & 0xff0: case PIC32_ADC1BUF9 & 0xff0: case PIC32_ADC1BUFA & 0xff0: case PIC32_ADC1BUFB & 0xff0: case PIC32_ADC1BUFC & 0xff0: case PIC32_ADC1BUFD & 0xff0: case PIC32_ADC1BUFE & 0xff0: case PIC32_ADC1BUFF & 0xff0: if (op_type == MTS_READ) { /* Result words */ *data = 0; // TODO } break; default: ASSERT (0, "unknown adc offset %x\n", offset); } *has_set_value = TRUE; return NULL; } void dev_pic32_adc_reset (cpu_mips_t *cpu, struct vdevice *dev) { pic32_t *pic32 = dev->priv_data; pic32->ad1con1 = 0; pic32->ad1con2 = 0; pic32->ad1con3 = 0; pic32->ad1chs = 0; pic32->ad1cssl = 0; pic32->ad1pcfg = 0; } int dev_pic32_adc_init (vm_instance_t *vm, char *name, unsigned paddr) { pic32_t *pic32 = (pic32_t *) vm->hw_data; pic32->sysdev = dev_create (name); if (! pic32->sysdev) return (-1); pic32->sysdev->priv_data = pic32; pic32->sysdev->phys_addr = paddr; pic32->sysdev->phys_len = ADC_REG_SIZE; pic32->sysdev->handler = dev_pic32_adc_access; pic32->sysdev->reset_handler = dev_pic32_adc_reset; pic32->sysdev->flags = VDEVICE_FLAG_NO_MTS_MMAP; vm_bind_device (vm, pic32->sysdev); return (0); } ================================================ FILE: tools/virtualmips/pic32_dev_bmxcon.c ================================================ /* * Interrupt controller for PIC32. * * Copyright (C) 2011 Serge Vakulenko * * This file is part of the virtualmips distribution. * See LICENSE file for terms of the license. */ #define _GNU_SOURCE #include #include #include #include #include #include #include "device.h" #include "mips_memory.h" #include "cpu.h" #include "pic32.h" #define BMXCON_REG_SIZE 0x80 extern cpu_mips_t *current_cpu; /* * Perform an assign/clear/set/invert operation. */ static inline unsigned write_op (int a, int b, int op) { switch (op & 0xc) { case 0x0: /* Assign */ a = b; break; case 0x4: /* Clear */ a &= ~b; break; case 0x8: /* Set */ a |= b; break; case 0xc: /* Invert */ a ^= b; break; } return a; } void *dev_pic32_bmxcon_access (cpu_mips_t *cpu, struct vdevice *dev, m_uint32_t offset, u_int op_size, u_int op_type, m_reg_t *data, m_uint8_t *has_set_value) { pic32_t *pic32 = dev->priv_data; if (offset >= BMXCON_REG_SIZE) { *data = 0; return NULL; } if (op_type == MTS_READ) *data = 0; switch (offset & 0x1f0) { case PIC32_BMXCON & 0x1f0: /* Interrupt Control */ if (op_type == MTS_READ) { *data = pic32->bmxcon; if (cpu->vm->debug_level > 2) printf (" read BMXCON -> %08x\n", *data); } else { pic32->bmxcon = write_op (pic32->bmxcon, *data, offset); if (cpu->vm->debug_level > 2) printf (" BMXCON := %08x\n", pic32->bmxcon); } break; case PIC32_BMXDKPBA & 0x1f0: /* Data RAM kernel program base address */ if (op_type == MTS_READ) { *data = pic32->bmx_ram_kpba; } else { pic32->bmx_ram_kpba = write_op (pic32->bmx_ram_kpba, *data, offset); } break; case PIC32_BMXDUDBA & 0x1f0: /* Data RAM user data base address */ if (op_type == MTS_READ) { *data = pic32->bmx_ram_udba; } else { pic32->bmx_ram_udba = write_op (pic32->bmx_ram_udba, *data, offset); } break; case PIC32_BMXDUPBA & 0x1f0: /* Data RAM user program base address */ if (op_type == MTS_READ) { *data = pic32->bmx_ram_upba; } else { pic32->bmx_ram_upba = write_op (pic32->bmx_ram_upba, *data, offset); } break; case PIC32_BMXPUPBA & 0x1f0: /* Program Flash user program base address */ if (op_type == MTS_READ) { *data = pic32->bmx_flash_upba; } else { pic32->bmx_flash_upba = write_op (pic32->bmx_flash_upba, *data, offset); } break; case PIC32_BMXDRMSZ & 0x1f0: /* Data RAM memory size */ if (op_type == MTS_READ) { *data = cpu->vm->ram_size * 1024; } break; case PIC32_BMXPFMSZ & 0x1f0: /* Program Flash memory size */ if (op_type == MTS_READ) { *data = cpu->vm->flash_size * 1024; } break; case PIC32_BMXBOOTSZ & 0x1f0: /* Boot Flash size */ if (op_type == MTS_READ) { *data = pic32->boot_flash_size * 1024; } break; default: ASSERT (0, "unknown bmxcon offset %x\n", offset); } *has_set_value = TRUE; return NULL; } void dev_pic32_bmxcon_reset (cpu_mips_t *cpu, struct vdevice *dev) { pic32_t *pic32 = dev->priv_data; pic32->bmxcon = 0x001f0041; pic32->bmx_ram_kpba = 0; pic32->bmx_ram_udba = 0; pic32->bmx_ram_upba = 0; pic32->bmx_flash_upba = 0; } int dev_pic32_bmxcon_init (vm_instance_t *vm, char *name, unsigned paddr) { pic32_t *pic32 = (pic32_t *) vm->hw_data; pic32->bmxdev = dev_create (name); if (! pic32->bmxdev) return (-1); pic32->bmxdev->priv_data = pic32; pic32->bmxdev->phys_addr = paddr; pic32->bmxdev->phys_len = BMXCON_REG_SIZE; pic32->bmxdev->handler = dev_pic32_bmxcon_access; pic32->bmxdev->reset_handler = dev_pic32_bmxcon_reset; pic32->bmxdev->flags = VDEVICE_FLAG_NO_MTS_MMAP; vm_bind_device (vm, pic32->bmxdev); return (0); } ================================================ FILE: tools/virtualmips/pic32_dev_devcfg.c ================================================ /* * Device configuration registers for PIC32. * * Copyright (C) 2012 Serge Vakulenko * * This file is part of the virtualmips distribution. * See LICENSE file for terms of the license. */ #define _GNU_SOURCE #include #include #include #include #include #include #include "device.h" #include "mips_memory.h" #include "cpu.h" #include "pic32.h" #define DEVCFG_REG_SIZE 0x100 void *dev_pic32_devcfg_access (cpu_mips_t *cpu, struct vdevice *dev, m_uint32_t offset, u_int op_size, u_int op_type, m_reg_t *data, m_uint8_t *has_set_value) { pic32_t *pic32 = dev->priv_data; if (offset >= DEVCFG_REG_SIZE) { *data = 0; return NULL; } if (op_type == MTS_READ) *data = 0; switch (offset & 0xfc) { case 0xf0: /* DEVCFG3 */ if (op_type == MTS_READ) { *data = pic32->devcfg3; if (cpu->vm->debug_level > 2) printf (" read DEVCFG3 -> %08x\n", *data); } break; case 0xf4: /* DEVCFG2 */ if (op_type == MTS_READ) { *data = pic32->devcfg2; if (cpu->vm->debug_level > 2) printf (" read DEVCFG3 -> %08x\n", *data); } break; case 0xf8: /* DEVCFG1 */ if (op_type == MTS_READ) { *data = pic32->devcfg1; if (cpu->vm->debug_level > 2) printf (" read DEVCFG3 -> %08x\n", *data); } break; case 0xfc: /* DEVCFG0 */ if (op_type == MTS_READ) { *data = pic32->devcfg0; if (cpu->vm->debug_level > 2) printf (" read DEVCFG3 -> %08x\n", *data); } break; // TODO: other registers. default: ASSERT (0, "unknown devcfg offset %x\n", offset); } *has_set_value = TRUE; return NULL; } void dev_pic32_devcfg_reset (cpu_mips_t *cpu, struct vdevice *dev) { pic32_t *pic32 = dev->priv_data; pic32->devcfg3 = 0xffff0722; // From Max32 bootloader pic32->devcfg2 = 0xd979f8f9; pic32->devcfg1 = 0x5bfd6aff; pic32->devcfg0 = 0xffffff7f; } int dev_pic32_devcfg_init (vm_instance_t *vm, char *name, unsigned paddr) { pic32_t *pic32 = (pic32_t *) vm->hw_data; pic32->cfgdev = dev_create (name); if (! pic32->cfgdev) return (-1); pic32->cfgdev->priv_data = pic32; pic32->cfgdev->phys_addr = paddr; pic32->cfgdev->phys_len = DEVCFG_REG_SIZE; pic32->cfgdev->handler = dev_pic32_devcfg_access; pic32->cfgdev->reset_handler = dev_pic32_devcfg_reset; pic32->cfgdev->flags = VDEVICE_FLAG_NO_MTS_MMAP; vm_bind_device (vm, pic32->cfgdev); return (0); } ================================================ FILE: tools/virtualmips/pic32_dev_dmacon.c ================================================ /* * DMA controller for PIC32. * * Copyright (C) 2011 Serge Vakulenko * * This file is part of the virtualmips distribution. * See LICENSE file for terms of the license. */ #define _GNU_SOURCE #include #include #include #include #include #include #include "device.h" #include "mips_memory.h" #include "cpu.h" #include "pic32.h" #define DMACON_REG_SIZE 0x660 extern cpu_mips_t *current_cpu; /* * Perform an assign/clear/set/invert operation. */ static inline unsigned write_op (int a, int b, int op) { switch (op & 0xc) { case 0x0: /* Assign */ a = b; break; case 0x4: /* Clear */ a &= ~b; break; case 0x8: /* Set */ a |= b; break; case 0xc: /* Invert */ a ^= b; break; } return a; } void *dev_pic32_dmacon_access (cpu_mips_t *cpu, struct vdevice *dev, m_uint32_t offset, u_int op_size, u_int op_type, m_reg_t *data, m_uint8_t *has_set_value) { pic32_t *pic32 = dev->priv_data; if (offset >= DMACON_REG_SIZE) { *data = 0; return NULL; } if (op_type == MTS_READ) *data = 0; switch (offset & 0x1f0) { case PIC32_DMACON & 0x1f0: /* DMA Control */ if (op_type == MTS_READ) { *data = pic32->dmacon; if (cpu->vm->debug_level > 2) printf (" read DMACON -> %08x\n", *data); } else { pic32->dmacon = write_op (pic32->dmacon, *data, offset); if (cpu->vm->debug_level > 2) printf (" DMACON := %08x\n", pic32->dmacon); } break; case PIC32_DMASTAT: /* DMA Status */ if (op_type == MTS_READ) { *data = pic32->dmastat; if (cpu->vm->debug_level > 2) printf (" read DMASTAT -> %08x\n", *data); } break; case PIC32_DMAADDR: /* DMA address */ if (op_type == MTS_READ) { *data = pic32->dmaaddr; if (cpu->vm->debug_level > 2) printf (" read DMAADDR -> %08x\n", *data); } else { pic32->dmaaddr = *data; if (cpu->vm->debug_level > 2) printf (" DMAADDR := %08x\n", *data); } break; // TODO: other registers. default: ASSERT (0, "unknown dmacon offset %x\n", offset); } *has_set_value = TRUE; return NULL; } void dev_pic32_dmacon_reset (cpu_mips_t *cpu, struct vdevice *dev) { pic32_t *pic32 = dev->priv_data; pic32->dmacon = 0; pic32->dmastat = 0; pic32->dmaaddr = 0; } int dev_pic32_dmacon_init (vm_instance_t *vm, char *name, unsigned paddr) { pic32_t *pic32 = (pic32_t *) vm->hw_data; pic32->dmadev = dev_create (name); if (! pic32->dmadev) return (-1); pic32->dmadev->priv_data = pic32; pic32->dmadev->phys_addr = paddr; pic32->dmadev->phys_len = DMACON_REG_SIZE; pic32->dmadev->handler = dev_pic32_dmacon_access; pic32->dmadev->reset_handler = dev_pic32_dmacon_reset; pic32->dmadev->flags = VDEVICE_FLAG_NO_MTS_MMAP; vm_bind_device (vm, pic32->dmadev); return (0); } ================================================ FILE: tools/virtualmips/pic32_dev_flash.c ================================================ /* * Internal Flash memory of PIC32 microcontroller. * Copyright (C) 2011 Serge Vakulenko * * This file is part of the virtualmips distribution. * See LICENSE file for terms of the license. */ #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include "device.h" #include "mips_memory.h" #include "pic32.h" /* flash private data */ typedef struct flash_data { struct vdevice *dev; m_uint8_t *flash_ptr; m_uint32_t flash_size; m_uint8_t *flash_file_name; } flash_data_t; void *dev_flash_access (cpu_mips_t * cpu, struct vdevice *dev, m_uint32_t offset, u_int op_size, u_int op_type, m_uint32_t * data, m_uint8_t * has_set_value) { flash_data_t *d = dev->priv_data; if (offset >= d->flash_size) { printf ("-- flash: access %08x -- out of memory\n", dev->phys_addr + offset); *data = 0xff; *has_set_value = TRUE; return NULL; } if (op_type == MTS_READ) { #if 0 printf ("-- flash: read %08x -> %08x\n", dev->phys_addr + offset, *(unsigned *) (d->flash_ptr + offset)); #endif return d->flash_ptr + offset; } if (op_type == MTS_WRITE) { printf ("-- flash: write %08x ***\n", dev->phys_addr + offset); return NULL; } assert (0); } static int dev_flash_load (char *flash_file_name, unsigned flash_len, unsigned char **flash_data_hp) { int fd; struct stat sb; fd = open (flash_file_name, O_RDONLY); if (fd < 0) { fprintf (stderr, "%s does not exist.\n", flash_file_name); return (-1); } fstat (fd, &sb); if (flash_len < sb.st_size) { fprintf (stderr, "Too large flash file.\nFlash len: %d kbytes, file name %s, " "file legth: %d bytes.\n", flash_len / 1024, flash_file_name, (int) sb.st_size); return (-1); } if (sb.st_size <= 0) { fprintf (stderr, "%s: empty flash file.\n", flash_file_name); return (-1); } *flash_data_hp = mmap (NULL, sb.st_size, PROT_READ, MAP_SHARED, fd, 0); if (*flash_data_hp == MAP_FAILED) { fprintf (stderr, "%s: ", flash_file_name); perror ("mmap"); return (-1); } return 0; } static void dev_flash_reset (cpu_mips_t * cpu, struct vdevice *dev) { //flash_data_t *d = dev->priv_data; //d->state = 0; } /* * Initialize a NOR Flash zone */ int dev_pic32_flash_init (vm_instance_t * vm, char *name, unsigned flash_kbytes, unsigned flash_address, char *filename) { flash_data_t *d; unsigned char *flash_data_hp; /* load rom data */ if (dev_flash_load (filename, flash_kbytes * 1024, &flash_data_hp) < 0) return (-1); /* allocate the private data structure */ d = malloc (sizeof (*d)); if (!d) { fprintf (stderr, "FLASH: unable to create device.\n"); return (-1); } memset (d, 0, sizeof (*d)); d->flash_ptr = flash_data_hp; d->flash_size = flash_kbytes * 1024; d->dev = dev_create (name); if (!d->dev) { free (d); return (-1); } d->dev->priv_data = d; d->dev->phys_addr = flash_address; d->dev->phys_len = flash_kbytes * 1024; d->dev->handler = dev_flash_access; d->dev->reset_handler = dev_flash_reset; d->dev->flags = VDEVICE_FLAG_NO_MTS_MMAP; /* Map this device to the VM */ vm_bind_device (vm, d->dev); return (0); } ================================================ FILE: tools/virtualmips/pic32_dev_gpio.c ================================================ /* * GPIO emulation for PIC32. * * Copyright (C) 2011 Serge Vakulenko * * This file is part of the virtualmips distribution. * See LICENSE file for terms of the license. */ #define _GNU_SOURCE #include #include #include #include #include #include #include "device.h" #include "mips_memory.h" #include "pic32.h" #include "cpu.h" #include "vp_timer.h" #define GPIO_REG_SIZE 0x1F0 #ifdef UBW32 #define MASKA_CS0 (1 << 9) // A9: sd0 on SPI1 #define MASKA_CS1 (1 << 10) // A10: sd1 on SPI1 #define MASKC_LDADDR (1 << 1) // C1: swap LDADDR #define MASKE_WR (1 << 9) // E8: swap WR #define MASKE_RD (1 << 8) // E8: swap RD #define MASKE_DATA (0xff << 0) // E0-E7: swap DATA #define SHIFTE_DATA 0 #elif defined MAXIMITE #define MASKE_CS0 (1 << 0) // E0: sd0 on SPI4 #define MASKE_CS1 // reserved #define MASKD_PS2C (1 << 6) // PS2 keyboard #define MASKD_PS2D (1 << 7) #elif defined MAX32 #define MASKC_CS0 (1 << 14) // C14: sd0 on SPI2 #define MASKD_CS1 (1 << 1) // D1: sd1 on SPI2 #elif defined EXPLORER16 #define MASKB_CS0 (1 << 1) // B1: sd0 on SPI1 #define MASKB_CS1 (1 << 2) // B2: sd1 on SPI1 #endif struct pic32_gpio_data { struct vdevice *dev; vtty_t *vtty; vm_instance_t *vm; pic32_t *pic32; unsigned tris_a; /* 0x00 - port A mask of inputs */ unsigned port_a; /* 0x10 - port A pins */ unsigned lat_a; /* 0x20 - port A latched outputs */ unsigned odc_a; /* 0x30 - port A open drain configuration */ unsigned tris_b; /* 0x40 - port B mask of inputs */ unsigned port_b; /* 0x50 - port B pins */ unsigned lat_b; /* 0x60 - port B latched outputs */ unsigned odc_b; /* 0x70 - port B open drain configuration */ unsigned tris_c; /* 0x80 - port C mask of inputs */ unsigned port_c; /* 0x90 - port C pins */ unsigned lat_c; /* 0xA0 - port C latched outputs */ unsigned odc_c; /* 0xB0 - port C open drain configuration */ unsigned tris_d; /* 0xC0 - port D mask of inputs */ unsigned port_d; /* 0xD0 - port D pins */ unsigned lat_d; /* 0xE0 - port D latched outputs */ unsigned odc_d; /* 0xF0 - port D open drain configuration */ unsigned tris_e; /* 0x00 - port E mask of inputs */ unsigned port_e; /* 0x10 - port E pins */ unsigned lat_e; /* 0x20 - port E latched outputs */ unsigned odc_e; /* 0x30 - port E open drain configuration */ unsigned tris_f; /* 0x40 - port F mask of inputs */ unsigned port_f; /* 0x50 - port F pins */ unsigned lat_f; /* 0x60 - port F latched outputs */ unsigned odc_f; /* 0x70 - port F open drain configuration */ unsigned tris_g; /* 0x80 - port G mask of inputs */ unsigned port_g; /* 0x90 - port G pins */ unsigned lat_g; /* 0xA0 - port G latched outputs */ unsigned odc_g; /* 0xB0 - port G open drain configuration */ unsigned cncon; /* 0xC0 - interrupt-on-change control */ unsigned cnen; /* 0xD0 - input change interrupt enable */ unsigned cnpue; /* 0xE0 - input pin pull-up enable */ }; extern cpu_mips_t *current_cpu; /* * Perform an assign/clear/set/invert operation. */ static inline unsigned write_op (int a, int b, int op) { switch (op & 0xc) { case 0x0: /* Assign */ a = b; break; case 0x4: /* Clear */ a &= ~b; break; case 0x8: /* Set */ a |= b; break; case 0xc: /* Invert */ a ^= b; break; } return a; } void *dev_pic32_gpio_access (cpu_mips_t *cpu, struct vdevice *dev, m_uint32_t offset, u_int op_size, u_int op_type, m_reg_t * data, m_uint8_t * has_set_value) { struct pic32_gpio_data *d = dev->priv_data; if (offset >= GPIO_REG_SIZE) { printf ("gpio: overhit\n"); *data = 0; return NULL; } //printf ("gpio: %s offset %#x\n", (op_type == MTS_READ) ? "read" : "write", offset); if (op_type == MTS_READ) *data = 0; switch (offset & 0x1f0) { /* * Port A */ case PIC32_TRISA & 0x1f0: /* Port A: mask of inputs */ if (op_type == MTS_READ) { *data = d->tris_a; } else { d->tris_a = write_op (d->tris_a, *data, offset); } break; case PIC32_PORTA & 0x1f0: /* Port A: read inputs, write outputs */ if (op_type == MTS_READ) { *data = d->port_a; } else { goto lat_a; } break; case PIC32_LATA & 0x1f0: /* Port A: read/write outputs */ if (op_type == MTS_READ) { *data = d->lat_a; } else { lat_a: d->lat_a = write_op (d->lat_a, *data, offset); #ifdef UBW32 /* Control SD card 0 */ if (d->lat_a & MASKA_CS0) dev_sdcard_select (cpu, 0, 0); else dev_sdcard_select (cpu, 0, 1); /* Control SD card 1 */ if (d->lat_a & MASKA_CS1) dev_sdcard_select (cpu, 1, 0); else dev_sdcard_select (cpu, 1, 1); #endif } break; case PIC32_ODCA & 0x1f0: /* Port A: open drain configuration */ if (op_type == MTS_READ) { *data = d->odc_a; } else { d->odc_a = write_op (d->odc_a, *data, offset); } break; /* * Port B */ case PIC32_TRISB & 0x1f0: /* Port B: mask of inputs */ if (op_type == MTS_READ) { *data = d->tris_b; } else { d->tris_b = write_op (d->tris_b, *data, offset); } break; case PIC32_PORTB & 0x1f0: /* Port B: read inputs, write outputs */ if (op_type == MTS_READ) { *data = d->port_b; } else { goto lat_b; } break; case PIC32_LATB & 0x1f0: /* Port B: read/write outputs */ if (op_type == MTS_READ) { *data = d->lat_b; } else { lat_b: d->lat_b = write_op (d->lat_b, *data, offset); #ifdef EXPLORER16 /* Control SD card 0 */ if (d->lat_b & MASKB_CS0) dev_sdcard_select (cpu, 0, 0); else dev_sdcard_select (cpu, 0, 1); /* Control SD card 1 */ if (d->lat_b & MASKB_CS1) dev_sdcard_select (cpu, 1, 0); else dev_sdcard_select (cpu, 1, 1); #endif } break; case PIC32_ODCB & 0x1f0: /* Port B: open drain configuration */ if (op_type == MTS_READ) { *data = d->odc_b; } else { d->odc_b = write_op (d->odc_b, *data, offset); } break; /* * Port C */ case PIC32_TRISC & 0x1f0: /* Port C: mask of inputs */ if (op_type == MTS_READ) { *data = d->tris_c; } else { d->tris_c = write_op (d->tris_c, *data, offset); } break; case PIC32_PORTC & 0x1f0: /* Port C: read inputs, write outputs */ if (op_type == MTS_READ) { *data = d->port_c; } else { goto lat_c; } break; case PIC32_LATC & 0x1f0: /* Port C: read/write outputs */ if (op_type == MTS_READ) { *data = d->lat_c; } else { lat_c: d->lat_c = write_op (d->lat_c, *data, offset); #ifdef UBW32 if (d->lat_c & MASKC_LDADDR) /* Swap disk: LDADDR */ dev_swap_ldaddr (cpu, 0); else dev_swap_ldaddr (cpu, 1); #endif #ifdef MAX32 /* Control SD card 0 */ if (d->lat_c & MASKC_CS0) dev_sdcard_select (cpu, 0, 0); else dev_sdcard_select (cpu, 0, 1); #endif } break; case PIC32_ODCC & 0x1f0: /* Port C: open drain configuration */ if (op_type == MTS_READ) { *data = d->odc_c; } else { d->odc_c = write_op (d->odc_c, *data, offset); } break; /* * Port D */ case PIC32_TRISD & 0x1f0: /* Port D: mask of inputs */ if (op_type == MTS_READ) { *data = d->tris_d; } else { d->tris_d = write_op (d->tris_d, *data, offset); } break; case PIC32_PORTD & 0x1f0: /* Port D: read inputs, write outputs */ #ifndef MAXIMITE if (op_type == MTS_READ) { *data = d->port_d; } else { goto lat_d; } #else if (op_type == MTS_READ) { #if 0 /* Poll PS2 keyboard */ if (dev_keyboard_clock (cpu)) d->port_d &= ~MASKD_PS2C; else d->port_d |= MASKD_PS2C; if (dev_keyboard_data (cpu)) d->port_d &= ~MASKD_PS2D; else d->port_d |= MASKD_PS2D; #endif *data = d->port_d; } else { goto lat_d; } #endif break; case PIC32_LATD & 0x1f0: /* Port D: read/write outputs */ if (op_type == MTS_READ) { *data = d->lat_d; } else { lat_d: d->lat_d = write_op (d->lat_d, *data, offset); #ifdef MAX32 /* Control SD card 1 */ if (d->lat_d & MASKD_CS1) dev_sdcard_select (cpu, 1, 0); else dev_sdcard_select (cpu, 1, 1); #endif } break; case PIC32_ODCD & 0x1f0: /* Port D: open drain configuration */ if (op_type == MTS_READ) { *data = d->odc_d; } else { d->odc_d = write_op (d->odc_d, *data, offset); } break; /* * Port E */ case PIC32_TRISE & 0x1f0: /* Port E: mask of inputs */ if (op_type == MTS_READ) { *data = d->tris_e; } else { d->tris_e = write_op (d->tris_e, *data, offset); } break; case PIC32_PORTE & 0x1f0: /* Port E: read inputs, write outputs */ if (op_type == MTS_READ) { #ifdef UBW32 /* Swap disk: DATA */ d->port_e &= ~MASKE_DATA; d->port_e |= dev_swap_io (cpu, 0, 0xff); #endif *data = d->port_e; } else { goto lat_e; } break; case PIC32_LATE & 0x1f0: /* Port E: read/write outputs */ if (op_type == MTS_READ) { *data = d->lat_e; } else { lat_e: d->lat_e = write_op (d->lat_e, *data, offset); #ifdef MAXIMITE /* Control SD card 0 */ if (d->lat_e & MASKE_CS0) dev_sdcard_select (cpu, 0, 0); else dev_sdcard_select (cpu, 0, 1); #if 0 /* Control SD card 1 */ if (d->lat_e & MASKE_CS1) dev_sdcard_select (cpu, 1, 0); else dev_sdcard_select (cpu, 1, 1); #endif #endif #ifdef UBW32 if (d->lat_e & MASKE_RD) /* Swap disk: RD */ dev_swap_rd (cpu, 0); else dev_swap_rd (cpu, 1); if (d->lat_e & MASKE_WR) /* Swap disk: WR */ dev_swap_wr (cpu, 0); else dev_swap_wr (cpu, 1); /* Swap disk: DATA */ dev_swap_io (cpu, d->lat_e >> SHIFTE_DATA, d->tris_e >> SHIFTE_DATA); #endif } break; case PIC32_ODCE & 0x1f0: /* Port E: open drain configuration */ if (op_type == MTS_READ) { *data = d->odc_e; } else { d->odc_e = write_op (d->odc_e, *data, offset); } break; /* * Port F */ case PIC32_TRISF & 0x1f0: /* Port F: mask of inputs */ if (op_type == MTS_READ) { *data = d->tris_f; } else { d->tris_f = write_op (d->tris_f, *data, offset); } break; case PIC32_PORTF & 0x1f0: /* Port F: read inputs, write outputs */ if (op_type == MTS_READ) { *data = d->port_f; } else { goto lat_f; } break; case PIC32_LATF & 0x1f0: /* Port F: read/write outputs */ if (op_type == MTS_READ) { *data = d->lat_f; } else { lat_f: d->lat_f = write_op (d->lat_f, *data, offset); } break; case PIC32_ODCF & 0x1f0: /* Port F: open drain configuration */ if (op_type == MTS_READ) { *data = d->odc_f; } else { d->odc_f = write_op (d->odc_f, *data, offset); } break; /* * Port G */ case PIC32_TRISG & 0x1f0: /* Port G: mask of inputs */ if (op_type == MTS_READ) { *data = d->tris_g; } else { d->tris_g = write_op (d->tris_g, *data, offset); } break; case PIC32_PORTG & 0x1f0: /* Port G: read inputs, write outputs */ if (op_type == MTS_READ) { *data = d->port_g; } else { goto lat_g; } break; case PIC32_LATG & 0x1f0: /* Port G: read/write outputs */ if (op_type == MTS_READ) { *data = d->lat_g; } else { lat_g: d->lat_g = write_op (d->lat_g, *data, offset); } break; case PIC32_ODCG & 0x1f0: /* Port G: open drain configuration */ if (op_type == MTS_READ) { *data = d->odc_g; } else { d->odc_g = write_op (d->odc_g, *data, offset); } break; /* * Change notifier */ case PIC32_CNCON & 0x1f0: /* Interrupt-on-change control */ if (op_type == MTS_READ) { *data = d->cncon; } else { d->cncon = write_op (d->cncon, *data, offset); } break; case PIC32_CNEN & 0x1f0: /* Input change interrupt enable */ if (op_type == MTS_READ) { *data = d->cnen; } else { d->cnen = write_op (d->cnen, *data, offset); } break; case PIC32_CNPUE & 0x1f0: /* Input pin pull-up enable */ if (op_type == MTS_READ) { *data = d->cnpue; } else { d->cnpue = write_op (d->cnpue, *data, offset); } break; /* TODO */ //printf ("%s: read data.\n", dev->name); /* TODO */ //printf ("%s: write %02x.\n", dev->name, d->buf); default: ASSERT (0, "%s: unknown offset 0x%x\n", dev->name, offset); } *has_set_value = TRUE; return NULL; } void dev_pic32_gpio_reset (cpu_mips_t * cpu, struct vdevice *dev) { struct pic32_gpio_data *d = dev->priv_data; /* All pins are inputs. */ d->tris_a = d->tris_b = d->tris_c = d->tris_d = d->tris_e = d->tris_f = d->tris_g = 0xFFFF; /* All inputs are high. */ d->port_a = d->port_b = d->port_c = d->port_d = d->port_e = d->port_f = d->port_g = 0xFFFF; /* All outputs are high. */ d->lat_a = d->lat_b = d->lat_c = d->lat_d = d->lat_e = d->lat_f = d->lat_g = 0xFFFF; /* All open drains are disabled. */ d->odc_a = d->odc_b = d->odc_c = d->odc_d = d->odc_e = d->odc_f = d->odc_g = 0; /* No interrupts, no pullups. */ d->cncon = 0; d->cnen = 0; d->cnpue = 0; } int dev_pic32_gpio_init (vm_instance_t *vm, char *name, unsigned paddr) { struct pic32_gpio_data *d; pic32_t *pic32 = (pic32_t *) vm->hw_data; /* allocate the private data structure */ d = malloc (sizeof (*d)); if (!d) { fprintf (stderr, "PIC32 GPIO: unable to create device.\n"); return (-1); } memset (d, 0, sizeof (*d)); d->dev = dev_create (name); if (!d->dev) { free (d); return (-1); } d->dev->priv_data = d; d->dev->phys_addr = paddr; d->dev->phys_len = GPIO_REG_SIZE; d->dev->flags = VDEVICE_FLAG_NO_MTS_MMAP; d->vm = vm; d->pic32 = pic32; d->dev->handler = dev_pic32_gpio_access; d->dev->reset_handler = dev_pic32_gpio_reset; vm_bind_device (vm, d->dev); return (0); } ================================================ FILE: tools/virtualmips/pic32_dev_intcon.c ================================================ /* * Interrupt controller for PIC32. * * Copyright (C) 2011 Serge Vakulenko * * This file is part of the virtualmips distribution. * See LICENSE file for terms of the license. */ #define _GNU_SOURCE #include #include #include #include #include #include #include "device.h" #include "mips_memory.h" #include "cpu.h" #include "pic32.h" #define INTCON_REG_SIZE 0x190 extern cpu_mips_t *current_cpu; /* * Perform an assign/clear/set/invert operation. */ static inline unsigned write_op (int a, int b, int op) { switch (op & 0xc) { case 0x0: /* Assign */ a = b; break; case 0x4: /* Clear */ a &= ~b; break; case 0x8: /* Set */ a |= b; break; case 0xc: /* Invert */ a ^= b; break; } return a; } void *dev_pic32_intcon_access (cpu_mips_t *cpu, struct vdevice *dev, m_uint32_t offset, u_int op_size, u_int op_type, m_reg_t *data, m_uint8_t *has_set_value) { pic32_t *pic32 = dev->priv_data; unsigned n, v; if (offset >= INTCON_REG_SIZE) { *data = 0; return NULL; } if (op_type == MTS_READ) *data = 0; switch (offset & 0x1f0) { case PIC32_INTCON & 0x1f0: /* Interrupt Control */ if (op_type == MTS_READ) { *data = pic32->intcon; } else { pic32->intcon = write_op (pic32->intcon, *data, offset); } break; case PIC32_INTSTAT & 0x1f0: /* Interrupt Status */ if (op_type == MTS_READ) { *data = pic32->intstat; } break; case PIC32_IPTMR & 0x1f0: /* Temporal Proximity Timer */ if (op_type == MTS_READ) { *data = pic32->iptmr; } else { pic32->iptmr = write_op (pic32->iptmr, *data, offset); } break; case PIC32_IFS(0) & 0x1f0: /* IFS(0..2) - Interrupt Flag Status */ case PIC32_IFS(1) & 0x1f0: case PIC32_IFS(2) & 0x1f0: n = (offset - (PIC32_IFS(0) & 0x1f0)) >> 4; if (op_type == MTS_READ) { *data = pic32->ifs[n]; } else { pic32->ifs[n] = write_op (pic32->ifs[n], *data, offset); pic32_update_irq_flag (pic32); } break; case PIC32_IEC(0) & 0x1f0: /* IEC(0..2) - Interrupt Enable Control */ case PIC32_IEC(1) & 0x1f0: case PIC32_IEC(2) & 0x1f0: n = (offset - (PIC32_IEC(0) & 0x1f0)) >> 4; if (op_type == MTS_READ) { *data = pic32->iec[n]; } else { pic32->iec[n] = write_op (pic32->iec[n], *data, offset); pic32_update_irq_flag (pic32); } break; case PIC32_IPC(0) & 0x1f0: /* IPC(0..11) - Interrupt Priority Control */ case PIC32_IPC(1) & 0x1f0: case PIC32_IPC(2) & 0x1f0: case PIC32_IPC(3) & 0x1f0: case PIC32_IPC(4) & 0x1f0: case PIC32_IPC(5) & 0x1f0: case PIC32_IPC(6) & 0x1f0: case PIC32_IPC(7) & 0x1f0: case PIC32_IPC(8) & 0x1f0: case PIC32_IPC(9) & 0x1f0: case PIC32_IPC(10) & 0x1f0: case PIC32_IPC(11) & 0x1f0: case PIC32_IPC(12) & 0x1f0: n = (offset - (PIC32_IPC(0) & 0x1f0)) >> 4; if (op_type == MTS_READ) { *data = pic32->ipc[n]; } else { pic32->ipc[n] = write_op (pic32->ipc[n], *data, offset); v = n << 2; pic32->ivprio[v] = pic32->ipc[n] >> 2 & 63; pic32->ivprio[v+1] = pic32->ipc[n] >> 10 & 63; pic32->ivprio[v+2] = pic32->ipc[n] >> 18 & 63; pic32->ivprio[v+3] = pic32->ipc[n] >> 26 & 63; pic32_update_irq_flag (pic32); } break; default: ASSERT (0, "unknown intcon offset %x\n", offset); } *has_set_value = TRUE; return NULL; } void dev_pic32_intcon_reset (cpu_mips_t *cpu, struct vdevice *dev) { pic32_t *pic32 = dev->priv_data; pic32->intcon = 0; pic32->intstat = 0; pic32->iptmr = 0; memset (pic32->ifs, 0, sizeof (pic32->ifs)); memset (pic32->iec, 0, sizeof (pic32->iec)); memset (pic32->ipc, 0, sizeof (pic32->ipc)); memset (pic32->ivprio, 0, sizeof (pic32->ivprio)); cpu->irq_cause = 0; cpu->irq_pending = 0; } int dev_pic32_intcon_init (vm_instance_t *vm, char *name, unsigned paddr) { pic32_t *pic32 = (pic32_t *) vm->hw_data; pic32->intdev = dev_create (name); if (! pic32->intdev) return (-1); pic32->intdev->priv_data = pic32; pic32->intdev->phys_addr = paddr; pic32->intdev->phys_len = INTCON_REG_SIZE; pic32->intdev->handler = dev_pic32_intcon_access; pic32->intdev->reset_handler = dev_pic32_intcon_reset; pic32->intdev->flags = VDEVICE_FLAG_NO_MTS_MMAP; vm_bind_device (vm, pic32->intdev); return (0); } ================================================ FILE: tools/virtualmips/pic32_dev_prefetch.c ================================================ /* * Prefetch controller for PIC32. * * Copyright (C) 2011 Serge Vakulenko * * This file is part of the virtualmips distribution. * See LICENSE file for terms of the license. */ #define _GNU_SOURCE #include #include #include #include #include #include #include "device.h" #include "mips_memory.h" #include "cpu.h" #include "pic32.h" #define PREFETCH_REG_SIZE 0xd0 extern cpu_mips_t *current_cpu; /* * Perform an assign/clear/set/invert operation. */ static inline unsigned write_op (int a, int b, int op) { switch (op & 0xc) { case 0x0: /* Assign */ a = b; break; case 0x4: /* Clear */ a &= ~b; break; case 0x8: /* Set */ a |= b; break; case 0xc: /* Invert */ a ^= b; break; } return a; } void *dev_pic32_prefetch_access (cpu_mips_t *cpu, struct vdevice *dev, m_uint32_t offset, u_int op_size, u_int op_type, m_reg_t *data, m_uint8_t *has_set_value) { pic32_t *pic32 = dev->priv_data; if (offset >= PREFETCH_REG_SIZE) { *data = 0; return NULL; } if (op_type == MTS_READ) *data = 0; switch (offset & 0x1f0) { case PIC32_CHECON & 0xf0: /* Prefetch Control */ if (op_type == MTS_READ) { *data = pic32->checon; if (cpu->vm->debug_level > 2) printf (" read CHECON -> %08x\n", *data); } else { pic32->checon = write_op (pic32->checon, *data, offset); if (cpu->vm->debug_level > 2) printf (" CHECON := %08x\n", pic32->checon); } break; // TODO: other registers. default: ASSERT (0, "unknown prefetch offset %x\n", offset); } *has_set_value = TRUE; return NULL; } void dev_pic32_prefetch_reset (cpu_mips_t *cpu, struct vdevice *dev) { pic32_t *pic32 = dev->priv_data; pic32->checon = 0x00000007; } int dev_pic32_prefetch_init (vm_instance_t *vm, char *name, unsigned paddr) { pic32_t *pic32 = (pic32_t *) vm->hw_data; pic32->prefetch = dev_create (name); if (! pic32->prefetch) return (-1); pic32->prefetch->priv_data = pic32; pic32->prefetch->phys_addr = paddr; pic32->prefetch->phys_len = PREFETCH_REG_SIZE; pic32->prefetch->handler = dev_pic32_prefetch_access; pic32->prefetch->reset_handler = dev_pic32_prefetch_reset; pic32->prefetch->flags = VDEVICE_FLAG_NO_MTS_MMAP; vm_bind_device (vm, pic32->prefetch); return (0); } ================================================ FILE: tools/virtualmips/pic32_dev_rtcc.c ================================================ /* * Interrupt controller for PIC32. * * Copyright (C) 2011 Serge Vakulenko * * This file is part of the virtualmips distribution. * See LICENSE file for terms of the license. */ #define _GNU_SOURCE #include #include #include #include #include #include #include "device.h" #include "mips_memory.h" #include "cpu.h" #include "pic32.h" #define RTCC_REG_SIZE 0x80 extern cpu_mips_t *current_cpu; /* * Perform an assign/clear/set/invert operation. */ static inline unsigned write_op (int a, int b, int op) { switch (op & 0xc) { case 0x0: /* Assign */ a = b; break; case 0x4: /* Clear */ a &= ~b; break; case 0x8: /* Set */ a |= b; break; case 0xc: /* Invert */ a ^= b; break; } return a; } void *dev_pic32_rtcc_access (cpu_mips_t *cpu, struct vdevice *dev, m_uint32_t offset, u_int op_size, u_int op_type, m_reg_t *data, m_uint8_t *has_set_value) { pic32_t *pic32 = dev->priv_data; if (offset >= RTCC_REG_SIZE) { *data = 0; return NULL; } if (op_type == MTS_READ) *data = 0; switch (offset & 0x1f0) { case PIC32_RTCCON & 0x1f0: /* RTC Control */ if (op_type == MTS_READ) { *data = pic32->rtccon; if (cpu->vm->debug_level > 2) printf (" read RTCCON -> %08x\n", *data); } else { pic32->rtccon = write_op (pic32->rtccon, *data, offset); if (cpu->vm->debug_level > 2) printf (" RTCCON := %08x\n", pic32->rtccon); } break; case PIC32_RTCALRM & 0x1f0: /* RTC alarm control */ if (op_type == MTS_READ) { *data = 0; } else { //pic32->rtcalrm = write_op (pic32->rtcalrm, *data, offset); } break; case PIC32_RTCTIME & 0x1f0: /* RTC time value */ if (op_type == MTS_READ) { *data = 0; } else { //pic32->rtctime = write_op (pic32->rtctime, *data, offset); } break; case PIC32_RTCDATE & 0x1f0: /* RTC date value */ if (op_type == MTS_READ) { *data = 0; } else { //pic32->rtcdate = write_op (pic32->rtcdate, *data, offset); } break; case PIC32_ALRMTIME & 0x1f0: /* Alarm time value */ if (op_type == MTS_READ) { *data = 0; } else { //pic32->alrmtime = write_op (pic32->alrmtime, *data, offset); } break; case PIC32_ALRMDATE & 0x1f0: /* Alarm date value */ if (op_type == MTS_READ) { *data = 0; } else { //pic32->alrmdate = write_op (pic32->alrmdate, *data, offset); } break; default: ASSERT (0, "unknown rtcc offset %x\n", offset); } *has_set_value = TRUE; return NULL; } void dev_pic32_rtcc_reset (cpu_mips_t *cpu, struct vdevice *dev) { pic32_t *pic32 = dev->priv_data; pic32->rtccon = 0; } int dev_pic32_rtcc_init (vm_instance_t *vm, char *name, unsigned paddr) { pic32_t *pic32 = (pic32_t *) vm->hw_data; pic32->rtcdev = dev_create (name); if (! pic32->rtcdev) return (-1); pic32->rtcdev->priv_data = pic32; pic32->rtcdev->phys_addr = paddr; pic32->rtcdev->phys_len = RTCC_REG_SIZE; pic32->rtcdev->handler = dev_pic32_rtcc_access; pic32->rtcdev->reset_handler = dev_pic32_rtcc_reset; pic32->rtcdev->flags = VDEVICE_FLAG_NO_MTS_MMAP; vm_bind_device (vm, pic32->rtcdev); return (0); } ================================================ FILE: tools/virtualmips/pic32_dev_spi.c ================================================ /* * SPI emulation for PIC32. * Two SD/MMC disks attached to SPI1. * * Copyright (C) 2011 Serge Vakulenko * * This file is part of the virtualmips distribution. * See LICENSE file for terms of the license. */ #define _GNU_SOURCE #include #include #include #include #include #include #include "device.h" #include "mips_memory.h" #include "pic32.h" #include "cpu.h" #include "vp_timer.h" #include "dev_sdcard.h" #define SPI_REG_SIZE 0x40 struct pic32_spi_data { struct vdevice *dev; vm_instance_t *vm; pic32_t *pic32; u_int irq; /* base irq number */ #define IRQ_FAULT 0 /* error interrupt */ #define IRQ_TX 1 /* transmitter interrupt */ #define IRQ_RX 2 /* receiver interrupt */ unsigned con; /* 0x00 - Control */ unsigned stat; /* 0x10 - Status */ unsigned buf [4]; /* 0x20 - Transmit and receive buffer */ unsigned brg; /* 0x40 - Baud rate generator */ unsigned rfifo; /* read fifo counter */ unsigned wfifo; /* write fifo counter */ }; extern cpu_mips_t *current_cpu; /* * Perform an assign/clear/set/invert operation. */ static inline unsigned write_op (int a, int b, int op) { switch (op & 0xc) { case 0x0: /* Assign */ a = b; break; case 0x4: /* Clear */ a &= ~b; break; case 0x8: /* Set */ a |= b; break; case 0xc: /* Invert */ a ^= b; break; } return a; } void *dev_pic32_spi_access (cpu_mips_t * cpu, struct vdevice *dev, m_uint32_t offset, u_int op_size, u_int op_type, m_reg_t * data, m_uint8_t * has_set_value) { struct pic32_spi_data *d = dev->priv_data; unsigned newval; if (offset >= SPI_REG_SIZE) { *data = 0; return NULL; } if (op_type == MTS_READ) *data = 0; switch (offset & 0x1f0) { case PIC32_SPI1CON & 0x1f0: /* SPIx Control */ if (op_type == MTS_READ) { *data = d->con; } else { d->con = write_op (d->con, *data, offset); if (! (d->con & PIC32_SPICON_ON)) { d->vm->clear_irq (d->vm, d->irq + IRQ_FAULT); d->vm->clear_irq (d->vm, d->irq + IRQ_RX); d->vm->clear_irq (d->vm, d->irq + IRQ_TX); d->stat = PIC32_SPISTAT_SPITBE; } else if (! (d->con & PIC32_SPICON_ENHBUF)) { d->rfifo = 0; d->wfifo = 0; } } break; case PIC32_SPI1STAT & 0x1f0: /* SPIx Status */ if (op_type == MTS_READ) { *data = d->stat; } else { /* Only ROV bit is writable. */ newval = write_op (d->stat, *data, offset); d->stat = (d->stat & ~PIC32_SPISTAT_SPIROV) | (newval & PIC32_SPISTAT_SPIROV); } break; case PIC32_SPI1BUF & 0x1ff: /* SPIx SPIx Buffer */ if (op_type == MTS_READ) { *data = d->buf [d->rfifo]; if (d->con & PIC32_SPICON_ENHBUF) { d->rfifo++; d->rfifo &= 3; } if (d->stat & PIC32_SPISTAT_SPIRBF) { d->stat &= ~PIC32_SPISTAT_SPIRBF; //d->vm->clear_irq (d->vm, d->irq + IRQ_RX); } } else { unsigned sdcard_port = d->pic32->sdcard_port; /* Perform SD card i/o on configured SPI port. */ if ((dev->phys_addr == PIC32_SPI1CON && sdcard_port == 1) || (dev->phys_addr == PIC32_SPI2CON && sdcard_port == 2) || (dev->phys_addr == PIC32_SPI3CON && sdcard_port == 3) || (dev->phys_addr == PIC32_SPI4CON && sdcard_port == 4)) { unsigned val = *data; if (d->con & PIC32_SPICON_MODE32) { /* 32-bit data width */ d->buf [d->wfifo] = (unsigned char) dev_sdcard_io (cpu, val >> 24) << 24; d->buf [d->wfifo] |= (unsigned char) dev_sdcard_io (cpu, val >> 16) << 16; d->buf [d->wfifo] |= (unsigned char) dev_sdcard_io (cpu, val >> 8) << 8; d->buf [d->wfifo] |= (unsigned char) dev_sdcard_io (cpu, val); } else if (d->con & PIC32_SPICON_MODE16) { /* 16-bit data width */ d->buf [d->wfifo] = (unsigned char) dev_sdcard_io (cpu, val >> 8) << 8; d->buf [d->wfifo] |= (unsigned char) dev_sdcard_io (cpu, val); } else { /* 8-bit data width */ d->buf [d->wfifo] = (unsigned char) dev_sdcard_io (cpu, val); } } else { /* No device */ d->buf [d->wfifo] = ~0; } if (d->stat & PIC32_SPISTAT_SPIRBF) { d->stat |= PIC32_SPISTAT_SPIROV; //d->vm->set_irq (d->vm, d->irq + IRQ_FAULT); } else if (d->con & PIC32_SPICON_ENHBUF) { d->wfifo++; d->wfifo &= 3; if (d->wfifo == d->rfifo) { d->stat |= PIC32_SPISTAT_SPIRBF; //d->vm->set_irq (d->vm, d->irq + IRQ_RX); } } else { d->stat |= PIC32_SPISTAT_SPIRBF; //d->vm->set_irq (d->vm, d->irq + IRQ_RX); } } break; case PIC32_SPI1BRG & 0x1f0: /* SPIx Baud rate */ if (op_type == MTS_READ) { *data = d->brg; } else { d->brg = write_op (d->brg, *data, offset); } break; default: ASSERT (0, "unknown spi offset %x\n", offset); } *has_set_value = TRUE; return NULL; } void dev_pic32_spi_reset (cpu_mips_t *cpu, struct vdevice *dev) { struct pic32_spi_data *d = dev->priv_data; d->con = 0; d->stat = PIC32_SPISTAT_SPITBE; /* Transmit buffer is empty */ d->wfifo = 0; d->rfifo = 0; d->brg = 0; } int dev_pic32_spi_init (vm_instance_t *vm, char *name, unsigned paddr, unsigned irq) { struct pic32_spi_data *d; pic32_t *pic32 = (pic32_t *) vm->hw_data; /* allocate the private data structure */ d = malloc (sizeof (*d)); if (!d) { fprintf (stderr, "PIC32 SPI: unable to create device.\n"); return (-1); } memset (d, 0, sizeof (*d)); d->dev = dev_create (name); if (! d->dev) { free (d); return (-1); } d->dev->priv_data = d; d->dev->phys_addr = paddr; d->dev->phys_len = SPI_REG_SIZE; d->dev->flags = VDEVICE_FLAG_NO_MTS_MMAP; d->vm = vm; d->irq = irq; d->pic32 = pic32; d->dev->handler = dev_pic32_spi_access; d->dev->reset_handler = dev_pic32_spi_reset; vm_bind_device (vm, d->dev); return (0); } ================================================ FILE: tools/virtualmips/pic32_dev_syscon.c ================================================ /* * System controller for PIC32. * * Copyright (C) 2011 Serge Vakulenko * * This file is part of the virtualmips distribution. * See LICENSE file for terms of the license. */ #define _GNU_SOURCE #include #include #include #include #include #include #include "device.h" #include "mips_memory.h" #include "cpu.h" #include "pic32.h" #define SYSCON_REG_SIZE 0x1000 extern cpu_mips_t *current_cpu; static int syskey_unlock; static void soft_reset (cpu_mips_t *cpu) { pic32_t *pic32 = (pic32_t*) cpu->vm->hw_data; mips_reset (cpu); cpu->pc = pic32->start_address; /* reset all devices */ dev_reset_all (cpu->vm); dev_sdcard_reset (cpu); } void *dev_pic32_syscon_access (cpu_mips_t *cpu, struct vdevice *dev, m_uint32_t offset, u_int op_size, u_int op_type, m_reg_t *data, m_uint8_t *has_set_value) { pic32_t *pic32 = dev->priv_data; if (offset >= SYSCON_REG_SIZE) { *data = 0; return NULL; } if (op_type == MTS_READ) *data = 0; switch (offset & 0xff0) { case PIC32_OSCCON & 0xff0: if (op_type == MTS_READ) { *data = pic32->osccon; if (cpu->vm->debug_level > 2) printf (" read OSCCON -> %08x\n", *data); } else { pic32->osccon = *data; if (cpu->vm->debug_level > 2) printf (" OSCCON := %08x\n", *data); } break; case PIC32_OSCTUN & 0xff0: if (op_type == MTS_READ) { *data = pic32->osctun; if (cpu->vm->debug_level > 2) printf (" read OSCTUN -> %08x\n", *data); } else { pic32->osctun = *data; if (cpu->vm->debug_level > 2) printf (" OSCTUN := %08x\n", *data); } break; case PIC32_DDPCON & 0xff0: /* Debug Data Port Control */ if (op_type == MTS_READ) { *data = pic32->ddpcon; if (cpu->vm->debug_level > 2) printf (" read DDPCON -> %08x\n", *data); } else { pic32->ddpcon = *data; if (cpu->vm->debug_level > 2) printf (" DDPCON := %08x\n", *data); } break; case PIC32_DEVID & 0xff0: /* Device identifier */ /* read-only register */ if (op_type == MTS_READ) { *data = pic32->devid; if (cpu->vm->debug_level > 2) printf (" read DEVID -> %08x\n", *data); } break; case PIC32_SYSKEY & 0xff0: if (op_type == MTS_READ) { *data = pic32->syskey; if (cpu->vm->debug_level > 2) printf (" read SYSKEY -> %08x\n", *data); } else { pic32->syskey = *data; if (cpu->vm->debug_level > 2) printf (" SYSKEY := %08x\n", *data); /* Unlock state machine. */ switch (syskey_unlock) { case 0: if (pic32->syskey == 0xaa996655) syskey_unlock = 1; else syskey_unlock = 0; break; case 1: if (pic32->syskey == 0x556699aa) syskey_unlock = 2; else syskey_unlock = 0; break; default: syskey_unlock = 0; break; } } break; case PIC32_RCON & 0xff0: if (op_type == MTS_READ) { *data = pic32->rcon; if (cpu->vm->debug_level > 2) printf (" read RCON -> %08x\n", *data); } else { pic32->rcon = *data; if (cpu->vm->debug_level > 2) printf (" RCON := %08x\n", *data); } break; case PIC32_RSWRST & 0xff0: if (op_type == MTS_READ) { *data = pic32->rswrst; if (cpu->vm->debug_level > 2) printf (" read RSWRST -> %08x\n", *data); } else { pic32->rswrst = *data; if (cpu->vm->debug_level > 2) printf (" RSWRST := %08x\n", *data); if (syskey_unlock == 2 && (pic32->rswrst & 1)) soft_reset (cpu); } break; default: ASSERT (0, "unknown syscon offset %x\n", offset); } *has_set_value = TRUE; return NULL; } void dev_pic32_syscon_reset (cpu_mips_t *cpu, struct vdevice *dev) { pic32_t *pic32 = dev->priv_data; pic32->osccon = 0x01453320; /* from ubw32 board */ pic32->osctun = 0; pic32->ddpcon = 0; pic32->devid = 0x04307053; /* 795F512L */ pic32->syskey = 0; pic32->rcon = 0; pic32->rswrst = 0; syskey_unlock = 0; } int dev_pic32_syscon_init (vm_instance_t *vm, char *name, unsigned paddr) { pic32_t *pic32 = (pic32_t *) vm->hw_data; pic32->sysdev = dev_create (name); if (! pic32->sysdev) return (-1); pic32->sysdev->priv_data = pic32; pic32->sysdev->phys_addr = paddr; pic32->sysdev->phys_len = SYSCON_REG_SIZE; pic32->sysdev->handler = dev_pic32_syscon_access; pic32->sysdev->reset_handler = dev_pic32_syscon_reset; pic32->sysdev->flags = VDEVICE_FLAG_NO_MTS_MMAP; vm_bind_device (vm, pic32->sysdev); return (0); } ================================================ FILE: tools/virtualmips/pic32_dev_timer.c ================================================ /* * Timer emulation for PIC32. * * Copyright (C) 2012 Serge Vakulenko * * This file is part of the virtualmips distribution. * See LICENSE file for terms of the license. */ #define _GNU_SOURCE #include #include #include #include #include #include #include "device.h" #include "mips_memory.h" #include "pic32.h" #include "cpu.h" #include "vp_timer.h" #include "dev_sdcard.h" #define TIMER_REG_SIZE 0x30 struct pic32_timer_data { struct vdevice *dev; vm_instance_t *vm; pic32_t *pic32; unsigned irq; /* irq number */ unsigned con; /* 0x00 - Control */ unsigned count; /* 0x10 - Count */ unsigned period; /* 0x20 - Period */ unsigned scale; /* prescale value */ }; extern cpu_mips_t *current_cpu; static const int timer_scale[8] = { 1, 2, 4, 8, 16, 32, 64, 256, }; /* * Perform an assign/clear/set/invert operation. */ static inline unsigned write_op (int a, int b, int op) { switch (op & 0xc) { case 0x0: /* Assign */ a = b; break; case 0x4: /* Clear */ a &= ~b; break; case 0x8: /* Set */ a |= b; break; case 0xc: /* Invert */ a ^= b; break; } return a; } void *dev_pic32_timer_access (cpu_mips_t * cpu, struct vdevice *dev, m_uint32_t offset, u_int op_size, u_int op_type, m_reg_t * data, m_uint8_t * has_set_value) { struct pic32_timer_data *d = dev->priv_data; unsigned newval; if (offset >= TIMER_REG_SIZE) { *data = 0; return NULL; } if (op_type == MTS_READ) *data = 0; switch (offset & 0x1f0) { case PIC32_T1CON & 0x1f0: /* Timer control */ if (op_type == MTS_READ) { *data = d->con; fprintf (stderr, "%s read TCON -> %04x\n", dev->name, d->con); } else { d->con = write_op (d->con, *data, offset); d->scale = timer_scale [(d->con >> 4) & 7]; fprintf (stderr, "%s write TCON %04x\n", dev->name, d->con); if (! (d->con & PIC32_TCON_ON)) { d->vm->clear_irq (d->vm, d->irq); d->count = 0; } } break; case PIC32_TMR1 & 0x1f0: /* Timer count */ if (op_type == MTS_READ) { *data = d->count / d->scale; fprintf (stderr, "%s read TMR -> %04x\n", dev->name, d->count / d->scale); } else { newval = write_op (d->count / d->scale, *data, offset); fprintf (stderr, "%s write TMR %04x\n", dev->name, newval); d->count = newval * d->scale; } break; case PIC32_PR1 & 0x1ff: /* Timer period */ if (op_type == MTS_READ) { *data = d->period; fprintf (stderr, "%s read PR -> %04x\n", dev->name, d->period); //d->vm->clear_irq (d->vm, d->irq); } else { newval = write_op (d->period, *data, offset); fprintf (stderr, "%s write PR %04x\n", dev->name, newval); d->period = newval; //d->vm->set_irq (d->vm, d->irq); } break; default: ASSERT (0, "unknown timer offset %x\n", offset); } *has_set_value = TRUE; return NULL; } /* * Increment timer counter. * Fire periodic interrupt. */ void dev_pic32_timer_tick (cpu_mips_t *cpu, struct vdevice *dev, unsigned nclocks) { struct pic32_timer_data *d = dev->priv_data; /* Check that timer is enabled. */ if (! (d->con & PIC32_TCON_ON) || d->period == 0) return; /* Update counter and check overflow. */ d->count += nclocks; if (d->count < d->period * d->scale) return; /* Counter matched. */ d->count %= d->period * d->scale; pic32_set_irq (cpu->vm, d->irq); fprintf (stderr, "%s irq %u\n", dev->name, d->irq); } void dev_pic32_timer_reset (cpu_mips_t *cpu, struct vdevice *dev) { struct pic32_timer_data *d = dev->priv_data; d->con = 0; d->count = 0; d->period = 0; d->scale = 1; pic32_clear_irq (cpu->vm, d->irq); } struct vdevice *dev_pic32_timer_init (vm_instance_t *vm, char *name, unsigned paddr, unsigned irq) { struct pic32_timer_data *d; pic32_t *pic32 = (pic32_t *) vm->hw_data; /* allocate the private data structure */ d = malloc (sizeof (*d)); if (!d) { fprintf (stderr, "PIC32 timer: unable to create device.\n"); return 0; } memset (d, 0, sizeof (*d)); d->dev = dev_create (name); if (! d->dev) { free (d); return 0; } d->dev->priv_data = d; d->dev->phys_addr = paddr; d->dev->phys_len = TIMER_REG_SIZE; d->dev->flags = VDEVICE_FLAG_NO_MTS_MMAP; d->vm = vm; d->irq = irq; d->pic32 = pic32; d->dev->handler = dev_pic32_timer_access; d->dev->reset_handler = dev_pic32_timer_reset; vm_bind_device (vm, d->dev); return d->dev; } ================================================ FILE: tools/virtualmips/pic32_dev_uart.c ================================================ /* * UART emulation for PIC32. * * Copyright (C) 2011 Serge Vakulenko * * This file is part of the virtualmips distribution. * See LICENSE file for terms of the license. */ #define _GNU_SOURCE #include #include #include #include #include #include #include "device.h" #include "mips_memory.h" #include "pic32.h" #include "cpu.h" #include "vp_timer.h" #define UART_REG_SIZE 0x50 #define UART_TIME_OUT 1 struct pic32_uart_data { struct vdevice *dev; vtty_t *vtty; vm_instance_t *vm; vp_timer_t *uart_timer; u_int output; u_int irq; /* base irq number */ #define IRQ_ERR 0 /* error interrupt */ #define IRQ_RX 1 /* receiver interrupt */ #define IRQ_TX 2 /* transmitter interrupt */ m_uint32_t mode; /* 0x00 - mode */ m_uint32_t sta; /* 0x10 - status and control */ m_uint32_t txreg; /* 0x20 - transmit */ m_uint32_t rxreg; /* 0x30 - receive */ m_uint32_t brg; /* 0x40 - baud rate */ }; extern cpu_mips_t *current_cpu; static void pic32_tty_con_input (vtty_t * vtty) { struct pic32_uart_data *d = vtty->priv_data; if (d->mode & PIC32_UMODE_ON) { /* UART enabled. */ if (d->sta & PIC32_USTA_URXEN) { /* Receiver enabled - activate interrupt. */ d->vm->set_irq (d->vm, d->irq + IRQ_RX); /* Receive data available */ d->sta |= PIC32_USTA_URXDA; } } } void *dev_pic32_uart_access (cpu_mips_t * cpu, struct vdevice *dev, m_uint32_t offset, u_int op_size, u_int op_type, m_reg_t * data, m_uint8_t * has_set_value) { struct pic32_uart_data *d = dev->priv_data; unsigned newval; if (offset >= UART_REG_SIZE) { *data = 0; return NULL; } if (op_type == MTS_READ) { /* * Reading UART registers. */ switch (offset) { case PIC32_U1RXREG & 0xff: /* Receive data */ *data = vtty_get_char (d->vtty); if (vtty_is_char_avail (d->vtty)) { d->sta |= PIC32_USTA_URXDA; } else { d->sta &= ~PIC32_USTA_URXDA; d->vm->clear_irq (d->vm, d->irq + IRQ_RX); } break; case PIC32_U1BRG & 0xff: /* Baud rate */ *data = d->brg; break; case PIC32_U1MODE & 0xff: /* Mode */ *data = d->mode; break; case PIC32_U1STA & 0xff: /* Status and control */ d->sta |= PIC32_USTA_RIDLE | /* Receiver is idle */ PIC32_USTA_TRMT; /* Transmit shift register is empty */ if (vtty_is_char_avail (d->vtty)) d->sta |= PIC32_USTA_URXDA; *data = d->sta; #if 0 printf ("<%x>", d->sta); fflush (stdout); #endif break; case PIC32_U1TXREG & 0xff: /* Transmit */ case PIC32_U1MODECLR & 0xff: case PIC32_U1MODESET & 0xff: case PIC32_U1MODEINV & 0xff: case PIC32_U1STACLR & 0xff: case PIC32_U1STASET & 0xff: case PIC32_U1STAINV & 0xff: case PIC32_U1BRGCLR & 0xff: case PIC32_U1BRGSET & 0xff: case PIC32_U1BRGINV & 0xff: *data = 0; break; default: ASSERT (0, "reading unknown uart offset %x\n", offset); } *has_set_value = TRUE; #if 0 printf ("--- uart: read %02x -> %08x\n", offset, *data); fflush (stdout); #endif } else { /* * Writing UART registers. */ #if 0 printf ("--- uart: write %02x := %08x\n", offset, *data); fflush (stdout); #endif switch (offset) { case PIC32_U1TXREG & 0xff: /* Transmit */ /* Don't skip ^M. */ vtty_put_char (d->vtty, (char) (*data)); if ((d->mode & PIC32_UMODE_ON) && (d->sta & PIC32_USTA_UTXEN) && (d->output == 0)) { /* * yajin. * * In order to put the next data more quickly, * just set irq not waiting for * host_alarm_handler to set irq. Sorry uart, * too much work for you. * * Sometimes, linux kernel prints "serial8250: * too much work for irq9" if we print large * data on screen. Please patch the kernel. * comment "printk(KERN_ERR "serial8250: too * much work for " "irq%d\n", irq);" qemu has * some question. * http://lkml.org/lkml/2008/1/12/135 * http://kerneltrap.org/mailarchive/linux-ker * nel/2008/2/7/769924 * * If jit is used in future, we may not need to * set irq here because simulation is quick * enough. Then we have no "too much work for * irq9" problem. */ d->output = TRUE; d->vm->set_irq (d->vm, d->irq + IRQ_TX); } break; case PIC32_U1MODE & 0xff: /* Mode */ newval = *data; write_mode: d->mode = newval; if (!(d->mode & PIC32_UMODE_ON)) { d->vm->clear_irq (d->vm, d->irq + IRQ_RX); d->vm->clear_irq (d->vm, d->irq + IRQ_TX); d->sta &= ~PIC32_USTA_URXDA; d->sta &= ~(PIC32_USTA_URXDA | PIC32_USTA_FERR | PIC32_USTA_PERR | PIC32_USTA_UTXBF); d->sta |= PIC32_USTA_RIDLE | PIC32_USTA_TRMT; } break; case PIC32_U1MODECLR & 0xff: newval = d->mode & ~*data; goto write_mode; case PIC32_U1MODESET & 0xff: newval = d->mode | *data; goto write_mode; case PIC32_U1MODEINV & 0xff: newval = d->mode ^ *data; goto write_mode; case PIC32_U1STA & 0xff: /* Status and control */ newval = *data; write_sta: d->sta &= PIC32_USTA_URXDA | PIC32_USTA_FERR | PIC32_USTA_PERR | PIC32_USTA_RIDLE | PIC32_USTA_TRMT | PIC32_USTA_UTXBF; d->sta |= newval & ~(PIC32_USTA_URXDA | PIC32_USTA_FERR | PIC32_USTA_PERR | PIC32_USTA_RIDLE | PIC32_USTA_TRMT | PIC32_USTA_UTXBF); if (!(d->sta & PIC32_USTA_URXEN)) { d->vm->clear_irq (d->vm, d->irq + IRQ_RX); d->sta &= ~(PIC32_USTA_URXDA | PIC32_USTA_FERR | PIC32_USTA_PERR); } if (!(d->sta & PIC32_USTA_UTXEN)) { d->vm->clear_irq (d->vm, d->irq + IRQ_TX); d->sta &= ~PIC32_USTA_UTXBF; d->sta |= PIC32_USTA_TRMT; } break; case PIC32_U1STACLR & 0xff: newval = d->sta & ~*data; goto write_sta; case PIC32_U1STASET & 0xff: newval = d->sta | *data; goto write_sta; case PIC32_U1STAINV & 0xff: newval = d->sta ^ *data; goto write_sta; case PIC32_U1BRG & 0xff: /* Baud rate */ newval = *data; write_brg: d->brg = newval; break; case PIC32_U1BRGCLR & 0xff: newval = d->brg & ~*data; goto write_brg; case PIC32_U1BRGSET & 0xff: newval = d->brg | *data; goto write_brg; case PIC32_U1BRGINV & 0xff: newval = d->brg ^ *data; goto write_brg; case PIC32_U1RXREG & 0xff: /* Receive */ /* Ignore */ break; default: ASSERT (0, "writing unknown uart offset %x\n", offset); } *has_set_value = TRUE; } return NULL; } void dev_pic32_uart_reset (cpu_mips_t * cpu, struct vdevice *dev) { struct pic32_uart_data *d = dev->priv_data; d->mode = 0; d->sta = PIC32_USTA_RIDLE | /* Receiver is idle */ PIC32_USTA_TRMT; /* Transmit shift register is empty */ d->txreg = 0; d->rxreg = 0; d->brg = 0; } void dev_pic32_uart_cb (void *opaque) { struct pic32_uart_data *d = (struct pic32_uart_data *) opaque; d->output = 0; if (d->mode & PIC32_UMODE_ON) { /* UART enabled. */ if ((d->sta & PIC32_USTA_URXEN) && vtty_is_char_avail (d->vtty)) { /* Receive data available */ d->sta |= PIC32_USTA_URXDA; /* Activate receive interrupt. */ d->vm->set_irq (d->vm, d->irq + IRQ_RX); vp_mod_timer (d->uart_timer, vp_get_clock (rt_clock) + UART_TIME_OUT); return; } if ((d->sta & PIC32_USTA_UTXEN) && (d->output == 0)) { /* Activate transmit interrupt. */ d->output = TRUE; d->vm->set_irq (d->vm, d->irq + IRQ_TX); vp_mod_timer (d->uart_timer, vp_get_clock (rt_clock) + UART_TIME_OUT); return; } } vp_mod_timer (d->uart_timer, vp_get_clock (rt_clock) + UART_TIME_OUT); } int dev_pic32_uart_init (vm_instance_t *vm, char *name, unsigned paddr, unsigned irq, vtty_t *vtty) { struct pic32_uart_data *d; /* allocate the private data structure */ d = malloc (sizeof (*d)); if (!d) { fprintf (stderr, "PIC32 UART: unable to create device.\n"); return (-1); } memset (d, 0, sizeof (*d)); d->dev = dev_create (name); if (!d->dev) { free (d); return (-1); } d->dev->priv_data = d; d->dev->phys_addr = paddr; d->dev->phys_len = UART_REG_SIZE; d->dev->flags = VDEVICE_FLAG_NO_MTS_MMAP; d->vm = vm; (*d).vtty = vtty; d->irq = irq; vtty->priv_data = d; d->dev->handler = dev_pic32_uart_access; d->dev->reset_handler = dev_pic32_uart_reset; (*d).vtty->read_notifier = pic32_tty_con_input; d->uart_timer = vp_new_timer (rt_clock, dev_pic32_uart_cb, d); vp_mod_timer (d->uart_timer, vp_get_clock (rt_clock) + UART_TIME_OUT); vm_bind_device (vm, d->dev); return (0); } ================================================ FILE: tools/virtualmips/pic32_explorer16.conf ================================================ # # Configure file for Explorer16 board # gdb_debug = 0 gdb_port = 5555 # # Data memory # ram_size = 128 # kbytes # # Program flash # flash_size = 492 # kbytes flash_phy_address = 0x1d000000 flash_file_name = ../../sys/arch/pic32/compile/EXPLORER16/unix.bin # # Boot flash # boot_flash_size = 12 # kbytes boot_flash_address = 0x1fc00000 boot_file_name = ../../sys/arch/pic32/compile/EXPLORER16/boot.bin start_address = 0x9fc00000 # user program # # SD/MMC cards # sdcard_port = 1 # SPI1 sdcard0_size = 512 # Mbytes sdcard0_file_name = ../../distrib/pic32/sdcard.img # # UARTs 1..6 # uart1_type = none uart2_type = console # # Debug level: # 0 - quiet # 1 - trace system calls and exceptions # 2 - trace inctructions in user mode # 3 - trace all inctructions # debug_level = 0 #trace_address = 0x9d00720c ================================================ FILE: tools/virtualmips/pic32_max32.conf ================================================ # # Configure file for MAX32 # gdb_debug = 0 gdb_port = 5555 # # Data memory # ram_size = 128 # kbytes # # Program flash # flash_size = 492 # kbytes flash_phy_address = 0x1d000000 flash_file_name = ../../sys/arch/pic32/compile/MAX32/unix.bin start_address = 0x9d001000 # user program # # SD/MMC cards # sdcard_port = 2 # SPI2 sdcard0_size = 512 # Mbytes sdcard0_file_name = ../../distrib/pic32/sdcard.img # # UARTs 1..6 # uart1_type = console # # Debug level: # 0 - quiet # 1 - trace system calls and exceptions # 2 - trace inctructions in user mode # 3 - trace all inctructions # debug_level = 0 #trace_address = 0x9d00720c ================================================ FILE: tools/virtualmips/pic32_maximite.conf ================================================ # # Configure file for Maximite # gdb_debug = 0 gdb_port = 5555 # # Data memory # ram_size = 128 # kbytes # # Program flash # flash_size = 492 # kbytes flash_phy_address = 0x1d005000 flash_file_name = ../../sys/arch/pic32/compile/MAXIMITE/unix.bin start_address = 0x9d006000 # user program # # SD/MMC cards # sdcard_port = 4 # SPI4 sdcard0_size = 512 # Mbytes sdcard0_file_name = ../../distrib/pic32/sdcard.img # # UARTs 1..6 # uart1_type = none uart4_type = console # # Debug level: # 0 - quiet # 1 - trace system calls and exceptions # 2 - trace inctructions in user mode # 3 - trace all inctructions # debug_level = 0 #trace_address = 0x9d00720c ================================================ FILE: tools/virtualmips/pic32_ubw32.conf ================================================ # # Configure file for UBW32 # gdb_debug = 0 gdb_port = 5555 # # Data memory # ram_size = 128 # kbytes # # Program flash # flash_size = 492 # kbytes flash_phy_address = 0x1d005000 flash_file_name = ../../sys/arch/pic32/compile/UBW32/unix.bin start_address = 0x9d006000 # user program # # SD/MMC cards # sdcard_port = 1 # SPI1 sdcard0_size = 512 # Mbytes sdcard0_file_name = ../../distrib/pic32/sdcard.img #sdcard1_size = 2 # Mbytes #sdcard1_file_name = ../../home.img # # UARTs 1..6 # uart1_type = console #uart1_type = tcp #uart1_port = 2302 #uart2_type = tcp #uart2_port = 2302 #uart3_type = tcp #uart3_port = 2303 #uart4_type = tcp #uart4_port = 2304 #uart5_type = tcp #uart5_port = 2305 #uart6_type = tcp #uart6_port = 2306 # # Debug level: # 0 - quiet # 1 - trace system calls and exceptions # 2 - trace inctructions in user mode # 3 - trace all inctructions # debug_level = 0 #trace_address = 0x9d00720c ================================================ FILE: tools/virtualmips/pic32mx.h ================================================ /* * Hardware register defines for Microchip PIC32MX microcontrollers. * * Copyright (C) 2010 Serge Vakulenko, * * Permission to use, copy, modify, and distribute this software * and its documentation for any purpose and without fee is hereby * granted, provided that the above copyright notice appear in all * copies and that both that the copyright notice and this * permission notice and warranty disclaimer appear in supporting * documentation, and that the name of the author not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * * The author disclaim all warranties with regard to this * software, including all implied warranties of merchantability * and fitness. In no event shall the author be liable for any * special, indirect or consequential damages or any damages * whatsoever resulting from loss of use, data or profits, whether * in an action of contract, negligence or other tortious action, * arising out of or in connection with the use or performance of * this software. */ #ifndef _IO_PIC32MX_H #define _IO_PIC32MX_H /*-------------------------------------- * Peripheral registers. */ #define PIC32_R(a) (0x1F800000 + (a)) /*-------------------------------------- * Interrupt controller registers. */ #define PIC32_INTCON PIC32_R (0x81000) /* Interrupt Control */ #define PIC32_INTCONCLR PIC32_R (0x81004) #define PIC32_INTCONSET PIC32_R (0x81008) #define PIC32_INTCONINV PIC32_R (0x8100C) #define PIC32_INTSTAT PIC32_R (0x81010) /* Interrupt Status */ #define PIC32_IPTMR PIC32_R (0x81020) /* Temporal Proximity Timer */ #define PIC32_IPTMRCLR PIC32_R (0x81024) #define PIC32_IPTMRSET PIC32_R (0x81028) #define PIC32_IPTMRINV PIC32_R (0x8102C) #define PIC32_IFS(n) PIC32_R (0x81030+((n)<<4)) /* IFS(0..2) - Interrupt Flag Status */ #define PIC32_IFSCLR(n) PIC32_R (0x81034+((n)<<4)) #define PIC32_IFSSET(n) PIC32_R (0x81038+((n)<<4)) #define PIC32_IFSINV(n) PIC32_R (0x8103C+((n)<<4)) #define PIC32_IEC(n) PIC32_R (0x81060+((n)<<4)) /* IEC(0..2) - Interrupt Enable Control */ #define PIC32_IECCLR(n) PIC32_R (0x81064+((n)<<4)) #define PIC32_IECSET(n) PIC32_R (0x81068+((n)<<4)) #define PIC32_IECINV(n) PIC32_R (0x8106C+((n)<<4)) #define PIC32_IPC(n) PIC32_R (0x81090+((n)<<4)) /* IPC(0..12) - Interrupt Priority Control */ #define PIC32_IPCCLR(n) PIC32_R (0x81094+((n)<<4)) #define PIC32_IPCSET(n) PIC32_R (0x81098+((n)<<4)) #define PIC32_IPCINV(n) PIC32_R (0x8109C+((n)<<4)) /* * Interrupt Control register. */ #define PIC32_INTCON_INT0EP 0x0001 /* External interrupt 0 polarity rising edge */ #define PIC32_INTCON_INT1EP 0x0002 /* External interrupt 1 polarity rising edge */ #define PIC32_INTCON_INT2EP 0x0004 /* External interrupt 2 polarity rising edge */ #define PIC32_INTCON_INT3EP 0x0008 /* External interrupt 3 polarity rising edge */ #define PIC32_INTCON_INT4EP 0x0010 /* External interrupt 4 polarity rising edge */ #define PIC32_INTCON_TPC(x) ((x)<<8) /* Temporal proximity group priority */ #define PIC32_INTCON_MVEC 0x1000 /* Multi-vectored mode */ #define PIC32_INTCON_FRZ 0x4000 /* Freeze in debug mode */ #define PIC32_INTCON_SS0 0x8000 /* Single vector has a shadow register set */ /* * Interrupt Status register. */ #define PIC32_INTSTAT_VEC(s) ((s) & 0xFF) /* Interrupt vector */ #define PIC32_INTSTAT_SRIPL(s) ((s) >> 8 & 7) /* Requested priority level */ /* * Interrupt Prority Control register. */ #define PIC32_IPC_IS0(x) (x) /* Interrupt 0 subpriority */ #define PIC32_IPC_IP0(x) ((x)<<2) /* Interrupt 0 priority */ #define PIC32_IPC_IS1(x) ((x)<<8) /* Interrupt 1 subpriority */ #define PIC32_IPC_IP1(x) ((x)<<10) /* Interrupt 1 priority */ #define PIC32_IPC_IS2(x) ((x)<<16) /* Interrupt 2 subpriority */ #define PIC32_IPC_IP2(x) ((x)<<18) /* Interrupt 2 priority */ #define PIC32_IPC_IS3(x) ((x)<<24) /* Interrupt 3 subpriority */ #define PIC32_IPC_IP3(x) ((x)<<26) /* Interrupt 3 priority */ /* * IRQ numbers for PIC32MX3xx/4xx/5xx/6xx/7xx. */ #define PIC32_IRQ_CT 0 /* Core Timer Interrupt */ #define PIC32_IRQ_CS0 1 /* Core Software Interrupt 0 */ #define PIC32_IRQ_CS1 2 /* Core Software Interrupt 1 */ #define PIC32_IRQ_INT0 3 /* External Interrupt 0 */ #define PIC32_IRQ_T1 4 /* Timer1 */ #define PIC32_IRQ_IC1 5 /* Input Capture 1 */ #define PIC32_IRQ_OC1 6 /* Output Compare 1 */ #define PIC32_IRQ_INT1 7 /* External Interrupt 1 */ #define PIC32_IRQ_T2 8 /* Timer2 */ #define PIC32_IRQ_IC2 9 /* Input Capture 2 */ #define PIC32_IRQ_OC2 10 /* Output Compare 2 */ #define PIC32_IRQ_INT2 11 /* External Interrupt 2 */ #define PIC32_IRQ_T3 12 /* Timer3 */ #define PIC32_IRQ_IC3 13 /* Input Capture 3 */ #define PIC32_IRQ_OC3 14 /* Output Compare 3 */ #define PIC32_IRQ_INT3 15 /* External Interrupt 3 */ #define PIC32_IRQ_T4 16 /* Timer4 */ #define PIC32_IRQ_IC4 17 /* Input Capture 4 */ #define PIC32_IRQ_OC4 18 /* Output Compare 4 */ #define PIC32_IRQ_INT4 19 /* External Interrupt 4 */ #define PIC32_IRQ_T5 20 /* Timer5 */ #define PIC32_IRQ_IC5 21 /* Input Capture 5 */ #define PIC32_IRQ_OC5 22 /* Output Compare 5 */ #define PIC32_IRQ_SPI1E 23 /* SPI1 Fault */ #define PIC32_IRQ_SPI1TX 24 /* SPI1 Transfer Done */ #define PIC32_IRQ_SPI1RX 25 /* SPI1 Receive Done */ #define PIC32_IRQ_SPI3E 26 /* SPI3 Fault */ #define PIC32_IRQ_SPI3TX 27 /* SPI3 Transfer Done */ #define PIC32_IRQ_SPI3RX 28 /* SPI3 Receive Done */ #define PIC32_IRQ_U1E 26 /* UART1 Error */ #define PIC32_IRQ_U1RX 27 /* UART1 Receiver */ #define PIC32_IRQ_U1TX 28 /* UART1 Transmitter */ #define PIC32_IRQ_I2C3B 26 /* I2C3 Bus Collision Event */ #define PIC32_IRQ_I2C3S 27 /* I2C3 Slave Event */ #define PIC32_IRQ_I2C3M 28 /* I2C3 Master Event */ #define PIC32_IRQ_I2C1B 29 /* I2C1 Bus Collision Event */ #define PIC32_IRQ_I2C1S 30 /* I2C1 Slave Event */ #define PIC32_IRQ_I2C1M 31 /* I2C1 Master Event */ #define PIC32_IRQ_CN 32 /* Input Change Interrupt */ #define PIC32_IRQ_AD1 33 /* ADC1 Convert Done */ #define PIC32_IRQ_PMP 34 /* Parallel Master Port */ #define PIC32_IRQ_CMP1 35 /* Comparator Interrupt */ #define PIC32_IRQ_CMP2 36 /* Comparator Interrupt */ #define PIC32_IRQ_SPI2E 37 /* SPI2 Fault */ #define PIC32_IRQ_SPI2TX 38 /* SPI2 Transfer Done */ #define PIC32_IRQ_SPI2RX 39 /* SPI2 Receive Done */ #define PIC32_IRQ_U3E 37 /* UART3 Error */ #define PIC32_IRQ_U3RX 38 /* UART3 Receiver */ #define PIC32_IRQ_U3TX 39 /* UART3 Transmitter */ #define PIC32_IRQ_I2C4B 37 /* I2C4 Bus Collision Event */ #define PIC32_IRQ_I2C4S 38 /* I2C4 Slave Event */ #define PIC32_IRQ_I2C4M 39 /* I2C4 Master Event */ #define PIC32_IRQ_SPI4E 40 /* SPI4 Fault */ #define PIC32_IRQ_SPI4TX 41 /* SPI4 Transfer Done */ #define PIC32_IRQ_SPI4RX 42 /* SPI4 Receive Done */ #define PIC32_IRQ_U2E 40 /* UART2 Error */ #define PIC32_IRQ_U2RX 41 /* UART2 Receiver */ #define PIC32_IRQ_U2TX 42 /* UART2 Transmitter */ #define PIC32_IRQ_I2C5B 40 /* I2C5 Bus Collision Event */ #define PIC32_IRQ_I2C5S 41 /* I2C5 Slave Event */ #define PIC32_IRQ_I2C5M 42 /* I2C5 Master Event */ #define PIC32_IRQ_I2C2B 43 /* I2C2 Bus Collision Event */ #define PIC32_IRQ_I2C2S 44 /* I2C2 Slave Event */ #define PIC32_IRQ_I2C2M 45 /* I2C2 Master Event */ #define PIC32_IRQ_FSCM 46 /* Fail-Safe Clock Monitor */ #define PIC32_IRQ_RTCC 47 /* Real-Time Clock and Calendar */ #define PIC32_IRQ_DMA0 48 /* DMA Channel 0 */ #define PIC32_IRQ_DMA1 49 /* DMA Channel 1 */ #define PIC32_IRQ_DMA2 50 /* DMA Channel 2 */ #define PIC32_IRQ_DMA3 51 /* DMA Channel 3 */ #define PIC32_IRQ_DMA4 52 /* DMA Channel 4 */ #define PIC32_IRQ_DMA5 53 /* DMA Channel 5 */ #define PIC32_IRQ_DMA6 54 /* DMA Channel 6 */ #define PIC32_IRQ_DMA7 55 /* DMA Channel 7 */ #define PIC32_IRQ_FCE 56 /* Flash Control Event */ #define PIC32_IRQ_USB 57 /* USB */ #define PIC32_IRQ_CAN1 58 /* Control Area Network 1 */ #define PIC32_IRQ_CAN2 59 /* Control Area Network 2 */ #define PIC32_IRQ_ETH 60 /* Ethernet Interrupt */ #define PIC32_IRQ_IC1E 61 /* Input Capture 1 Error */ #define PIC32_IRQ_IC2E 62 /* Input Capture 2 Error */ #define PIC32_IRQ_IC3E 63 /* Input Capture 3 Error */ #define PIC32_IRQ_IC4E 64 /* Input Capture 4 Error */ #define PIC32_IRQ_IC5E 65 /* Input Capture 5 Error */ #define PIC32_IRQ_PMPE 66 /* Parallel Master Port Error */ #define PIC32_IRQ_U4E 67 /* UART4 Error */ #define PIC32_IRQ_U4RX 68 /* UART4 Receiver */ #define PIC32_IRQ_U4TX 69 /* UART4 Transmitter */ #define PIC32_IRQ_U6E 70 /* UART6 Error */ #define PIC32_IRQ_U6RX 71 /* UART6 Receiver */ #define PIC32_IRQ_U6TX 72 /* UART6 Transmitter */ #define PIC32_IRQ_U5E 73 /* UART5 Error */ #define PIC32_IRQ_U5RX 74 /* UART5 Receiver */ #define PIC32_IRQ_U5TX 75 /* UART5 Transmitter */ /* * Interrupt vector numbers for PIC32MX3xx/4xx/5xx/6xx/7xx. */ #define PIC32_VECT_CT 0 /* Core Timer Interrupt */ #define PIC32_VECT_CS0 1 /* Core Software Interrupt 0 */ #define PIC32_VECT_CS1 2 /* Core Software Interrupt 1 */ #define PIC32_VECT_INT0 3 /* External Interrupt 0 */ #define PIC32_VECT_T1 4 /* Timer1 */ #define PIC32_VECT_IC1 5 /* Input Capture 1 */ #define PIC32_VECT_OC1 6 /* Output Compare 1 */ #define PIC32_VECT_INT1 7 /* External Interrupt 1 */ #define PIC32_VECT_T2 8 /* Timer2 */ #define PIC32_VECT_IC2 9 /* Input Capture 2 */ #define PIC32_VECT_OC2 10 /* Output Compare 2 */ #define PIC32_VECT_INT2 11 /* External Interrupt 2 */ #define PIC32_VECT_T3 12 /* Timer3 */ #define PIC32_VECT_IC3 13 /* Input Capture 3 */ #define PIC32_VECT_OC3 14 /* Output Compare 3 */ #define PIC32_VECT_INT3 15 /* External Interrupt 3 */ #define PIC32_VECT_T4 16 /* Timer4 */ #define PIC32_VECT_IC4 17 /* Input Capture 4 */ #define PIC32_VECT_OC4 18 /* Output Compare 4 */ #define PIC32_VECT_INT4 19 /* External Interrupt 4 */ #define PIC32_VECT_T5 20 /* Timer5 */ #define PIC32_VECT_IC5 21 /* Input Capture 5 */ #define PIC32_VECT_OC5 22 /* Output Compare 5 */ #define PIC32_VECT_SPI1 23 /* SPI1 */ #define PIC32_VECT_SPI3 24 /* SPI3 */ #define PIC32_VECT_U1 24 /* UART1 */ #define PIC32_VECT_I2C3 24 /* I2C3 */ #define PIC32_VECT_I2C1 25 /* I2C1 */ #define PIC32_VECT_CN 26 /* Input Change Interrupt */ #define PIC32_VECT_AD1 27 /* ADC1 Convert Done */ #define PIC32_VECT_PMP 28 /* Parallel Master Port */ #define PIC32_VECT_CMP1 29 /* Comparator Interrupt */ #define PIC32_VECT_CMP2 30 /* Comparator Interrupt */ #define PIC32_VECT_SPI2 31 /* SPI2 */ #define PIC32_VECT_U3 31 /* UART3 */ #define PIC32_VECT_I2C4 31 /* I2C4 */ #define PIC32_VECT_SPI4 32 /* SPI4 */ #define PIC32_VECT_U2 32 /* UART2 */ #define PIC32_VECT_I2C5 32 /* I2C5 */ #define PIC32_VECT_I2C2 33 /* I2C2 */ #define PIC32_VECT_FSCM 34 /* Fail-Safe Clock Monitor */ #define PIC32_VECT_RTCC 35 /* Real-Time Clock and Calendar */ #define PIC32_VECT_DMA0 36 /* DMA Channel 0 */ #define PIC32_VECT_DMA1 37 /* DMA Channel 1 */ #define PIC32_VECT_DMA2 38 /* DMA Channel 2 */ #define PIC32_VECT_DMA3 39 /* DMA Channel 3 */ #define PIC32_VECT_DMA4 40 /* DMA Channel 4 */ #define PIC32_VECT_DMA5 41 /* DMA Channel 5 */ #define PIC32_VECT_DMA6 42 /* DMA Channel 6 */ #define PIC32_VECT_DMA7 43 /* DMA Channel 7 */ #define PIC32_VECT_FCE 44 /* Flash Control Event */ #define PIC32_VECT_USB 45 /* USB */ #define PIC32_VECT_CAN1 46 /* Control Area Network 1 */ #define PIC32_VECT_CAN2 47 /* Control Area Network 2 */ #define PIC32_VECT_ETH 48 /* Ethernet Interrupt */ #define PIC32_VECT_U4 49 /* UART4 */ #define PIC32_VECT_U6 50 /* UART6 */ #define PIC32_VECT_U5 51 /* UART5 */ /*-------------------------------------- * DMA controller registers. */ #define PIC32_DMACON PIC32_R (0x83000) /* DMA Control */ #define PIC32_DMACONCLR PIC32_R (0x83004) #define PIC32_DMACONSET PIC32_R (0x83008) #define PIC32_DMACONINV PIC32_R (0x8300C) #define PIC32_DMASTAT PIC32_R (0x83010) /* DMA Status */ #define PIC32_DMAADDR PIC32_R (0x83020) /* DMA Address */ // TODO: other DMA registers. /*-------------------------------------- * System controller registers. */ #define PIC32_OSCCON PIC32_R (0xf000) #define PIC32_OSCTUN PIC32_R (0xf010) #define PIC32_DDPCON PIC32_R (0xf200) /* Debug Data Port Control */ #define PIC32_DEVID PIC32_R (0xf220) #define PIC32_SYSKEY PIC32_R (0xf230) #define PIC32_RCON PIC32_R (0xf600) #define PIC32_RSWRST PIC32_R (0xf610) /*-------------------------------------- * Prefetch cache controller registers. */ #define PIC32_CHECON PIC32_R (0x84000) /* Prefetch cache control */ // TODO: other prefetech registers /*-------------------------------------- * Bus matrix control registers. */ #define PIC32_BMXCON PIC32_R (0x82000) /* Memory configuration */ #define PIC32_BMXDKPBA PIC32_R (0x82010) /* Data RAM kernel program base address */ #define PIC32_BMXDUDBA PIC32_R (0x82020) /* Data RAM user data base address */ #define PIC32_BMXDUPBA PIC32_R (0x82030) /* Data RAM user program base address */ #define PIC32_BMXDRMSZ PIC32_R (0x82040) /* Data RAM size */ #define PIC32_BMXPUPBA PIC32_R (0x82050) /* Program Flash user program base address */ #define PIC32_BMXPFMSZ PIC32_R (0x82060) /* Program Flash size */ #define PIC32_BMXBOOTSZ PIC32_R (0x82070) /* Boot Flash size */ /*-------------------------------------- * Real time clock and calendar. */ #define PIC32_RTCCON PIC32_R (0x0200) /* RTC control */ #define PIC32_RTCALRM PIC32_R (0x0210) /* RTC alarm control */ #define PIC32_RTCTIME PIC32_R (0x0220) /* RTC time value */ #define PIC32_RTCDATE PIC32_R (0x0230) /* RTC date value */ #define PIC32_ALRMTIME PIC32_R (0x0240) /* Alarm time value */ #define PIC32_ALRMDATE PIC32_R (0x0250) /* Alarm date value */ /*-------------------------------------- * Timer registers. */ #define PIC32_T1CON PIC32_R (0x0600) /* Timer 1 control */ #define PIC32_TMR1 PIC32_R (0x0610) /* Timer 1 count */ #define PIC32_PR1 PIC32_R (0x0620) /* Timer 1 period */ #define PIC32_T2CON PIC32_R (0x0800) /* Timer 2 control */ #define PIC32_TMR2 PIC32_R (0x0810) /* Timer 2 count */ #define PIC32_PR2 PIC32_R (0x0820) /* Timer 2 period */ #define PIC32_T3CON PIC32_R (0x0A00) /* Timer 3 control */ #define PIC32_TMR3 PIC32_R (0x0A10) /* Timer 3 count */ #define PIC32_PR3 PIC32_R (0x0A20) /* Timer 3 period */ #define PIC32_T4CON PIC32_R (0x0C00) /* Timer 4 control */ #define PIC32_TMR4 PIC32_R (0x0C10) /* Timer 4 count */ #define PIC32_PR4 PIC32_R (0x0C20) /* Timer 4 period */ #define PIC32_T5CON PIC32_R (0x0E00) /* Timer 5 control */ #define PIC32_TMR5 PIC32_R (0x0E10) /* Timer 5 count */ #define PIC32_PR5 PIC32_R (0x0E20) /* Timer 5 period */ /* * Timer Control register. */ #define PIC32_TCON_ON 0x8000 /* Timer is enabled */ #define PIC32_TCON_FRZ 0x4000 /* Freeze when CPU is in Debug mode */ #define PIC32_TCON_SIDL 0x2000 /* Stop in Idle mode */ #define PIC32_TCON_TWDIS 0x1000 /* (Timer A) Asynchronous Timer Write Disable */ #define PIC32_TCON_TWIP 0x0800 /* (Timer A) Asynchronous Timer Write in Progress */ #define PIC32_TCON_TGATE 0x0080 /* Enable gated time accumulation (only when TCS=0) */ #define PIC32_TCON_TCKPS_MASK 0x0070 /* Timer Input Clock Prescale Select */ #define PIC32_TCON_TCKPS_256 0x0070 /* 1:256 */ #define PIC32_TCON_TCKPS_64 0x0060 /* 1:64 */ #define PIC32_TCON_TCKPS_32 0x0050 /* 1:32 */ #define PIC32_TCON_TCKPS_16 0x0040 /* 1:16 */ #define PIC32_TCON_TCKPS_8 0x0030 /* 1:8 */ #define PIC32_TCON_TCKPS_4 0x0020 /* 1:4 */ #define PIC32_TCON_TCKPS_2 0x0010 /* 1:2 */ #define PIC32_TCON_TCKPS_1 0x0000 /* 1:1 */ #define PIC32_TCON_T32 0x0008 /* (Timer B) TMRx and TMRy form a 32-bit timer */ #define PIC32_TCON_TSYNC 0x0004 /* (Timer A) External clock input is synchronized */ #define PIC32_TCON_TCS 0x0002 /* External clock from TxCKI pin */ /*-------------------------------------- * UART registers. */ #define PIC32_U1MODE PIC32_R (0x6000) /* Mode */ #define PIC32_U1MODECLR PIC32_R (0x6004) #define PIC32_U1MODESET PIC32_R (0x6008) #define PIC32_U1MODEINV PIC32_R (0x600C) #define PIC32_U1STA PIC32_R (0x6010) /* Status and control */ #define PIC32_U1STACLR PIC32_R (0x6014) #define PIC32_U1STASET PIC32_R (0x6018) #define PIC32_U1STAINV PIC32_R (0x601C) #define PIC32_U1TXREG PIC32_R (0x6020) /* Transmit */ #define PIC32_U1RXREG PIC32_R (0x6030) /* Receive */ #define PIC32_U1BRG PIC32_R (0x6040) /* Baud rate */ #define PIC32_U1BRGCLR PIC32_R (0x6044) #define PIC32_U1BRGSET PIC32_R (0x6048) #define PIC32_U1BRGINV PIC32_R (0x604C) #ifdef PIC32MX4 #define PIC32_U2MODE PIC32_R (0x6200) /* Mode */ #define PIC32_U2MODECLR PIC32_R (0x6204) #define PIC32_U2MODESET PIC32_R (0x6208) #define PIC32_U2MODEINV PIC32_R (0x620C) #define PIC32_U2STA PIC32_R (0x6210) /* Status and control */ #define PIC32_U2STACLR PIC32_R (0x6214) #define PIC32_U2STASET PIC32_R (0x6218) #define PIC32_U2STAINV PIC32_R (0x621C) #define PIC32_U2TXREG PIC32_R (0x6220) /* Transmit */ #define PIC32_U2RXREG PIC32_R (0x6230) /* Receive */ #define PIC32_U2BRG PIC32_R (0x6240) /* Baud rate */ #define PIC32_U2BRGCLR PIC32_R (0x6244) #define PIC32_U2BRGSET PIC32_R (0x6248) #define PIC32_U2BRGINV PIC32_R (0x624C) #endif #ifdef PIC32MX7 #define PIC32_U4MODE PIC32_R (0x6200) /* Mode */ #define PIC32_U4MODECLR PIC32_R (0x6204) #define PIC32_U4MODESET PIC32_R (0x6208) #define PIC32_U4MODEINV PIC32_R (0x620C) #define PIC32_U4STA PIC32_R (0x6210) /* Status and control */ #define PIC32_U4STACLR PIC32_R (0x6214) #define PIC32_U4STASET PIC32_R (0x6218) #define PIC32_U4STAINV PIC32_R (0x621C) #define PIC32_U4TXREG PIC32_R (0x6220) /* Transmit */ #define PIC32_U4RXREG PIC32_R (0x6230) /* Receive */ #define PIC32_U4BRG PIC32_R (0x6240) /* Baud rate */ #define PIC32_U4BRGCLR PIC32_R (0x6244) #define PIC32_U4BRGSET PIC32_R (0x6248) #define PIC32_U4BRGINV PIC32_R (0x624C) #define PIC32_U3MODE PIC32_R (0x6400) /* Mode */ #define PIC32_U3MODECLR PIC32_R (0x6404) #define PIC32_U3MODESET PIC32_R (0x6408) #define PIC32_U3MODEINV PIC32_R (0x640C) #define PIC32_U3STA PIC32_R (0x6410) /* Status and control */ #define PIC32_U3STACLR PIC32_R (0x6414) #define PIC32_U3STASET PIC32_R (0x6418) #define PIC32_U3STAINV PIC32_R (0x641C) #define PIC32_U3TXREG PIC32_R (0x6420) /* Transmit */ #define PIC32_U3RXREG PIC32_R (0x6430) /* Receive */ #define PIC32_U3BRG PIC32_R (0x6440) /* Baud rate */ #define PIC32_U3BRGCLR PIC32_R (0x6444) #define PIC32_U3BRGSET PIC32_R (0x6448) #define PIC32_U3BRGINV PIC32_R (0x644C) #define PIC32_U6MODE PIC32_R (0x6600) /* Mode */ #define PIC32_U6MODECLR PIC32_R (0x6604) #define PIC32_U6MODESET PIC32_R (0x6608) #define PIC32_U6MODEINV PIC32_R (0x660C) #define PIC32_U6STA PIC32_R (0x6610) /* Status and control */ #define PIC32_U6STACLR PIC32_R (0x6614) #define PIC32_U6STASET PIC32_R (0x6618) #define PIC32_U6STAINV PIC32_R (0x661C) #define PIC32_U6TXREG PIC32_R (0x6620) /* Transmit */ #define PIC32_U6RXREG PIC32_R (0x6630) /* Receive */ #define PIC32_U6BRG PIC32_R (0x6640) /* Baud rate */ #define PIC32_U6BRGCLR PIC32_R (0x6644) #define PIC32_U6BRGSET PIC32_R (0x6648) #define PIC32_U6BRGINV PIC32_R (0x664C) #define PIC32_U2MODE PIC32_R (0x6800) /* Mode */ #define PIC32_U2MODECLR PIC32_R (0x6804) #define PIC32_U2MODESET PIC32_R (0x6808) #define PIC32_U2MODEINV PIC32_R (0x680C) #define PIC32_U2STA PIC32_R (0x6810) /* Status and control */ #define PIC32_U2STACLR PIC32_R (0x6814) #define PIC32_U2STASET PIC32_R (0x6818) #define PIC32_U2STAINV PIC32_R (0x681C) #define PIC32_U2TXREG PIC32_R (0x6820) /* Transmit */ #define PIC32_U2RXREG PIC32_R (0x6830) /* Receive */ #define PIC32_U2BRG PIC32_R (0x6840) /* Baud rate */ #define PIC32_U2BRGCLR PIC32_R (0x6844) #define PIC32_U2BRGSET PIC32_R (0x6848) #define PIC32_U2BRGINV PIC32_R (0x684C) #define PIC32_U5MODE PIC32_R (0x6A00) /* Mode */ #define PIC32_U5MODECLR PIC32_R (0x6A04) #define PIC32_U5MODESET PIC32_R (0x6A08) #define PIC32_U5MODEINV PIC32_R (0x6A0C) #define PIC32_U5STA PIC32_R (0x6A10) /* Status and control */ #define PIC32_U5STACLR PIC32_R (0x6A14) #define PIC32_U5STASET PIC32_R (0x6A18) #define PIC32_U5STAINV PIC32_R (0x6A1C) #define PIC32_U5TXREG PIC32_R (0x6A20) /* Transmit */ #define PIC32_U5RXREG PIC32_R (0x6A30) /* Receive */ #define PIC32_U5BRG PIC32_R (0x6A40) /* Baud rate */ #define PIC32_U5BRGCLR PIC32_R (0x6A44) #define PIC32_U5BRGSET PIC32_R (0x6A48) #define PIC32_U5BRGINV PIC32_R (0x6A4C) #endif /* * UART Mode register. */ #define PIC32_UMODE_STSEL 0x0001 /* 2 Stop bits */ #define PIC32_UMODE_PDSEL 0x0006 /* Bitmask: */ #define PIC32_UMODE_PDSEL_8NPAR 0x0000 /* 8-bit data, no parity */ #define PIC32_UMODE_PDSEL_8EVEN 0x0002 /* 8-bit data, even parity */ #define PIC32_UMODE_PDSEL_8ODD 0x0004 /* 8-bit data, odd parity */ #define PIC32_UMODE_PDSEL_9NPAR 0x0006 /* 9-bit data, no parity */ #define PIC32_UMODE_BRGH 0x0008 /* High Baud Rate Enable */ #define PIC32_UMODE_RXINV 0x0010 /* Receive Polarity Inversion */ #define PIC32_UMODE_ABAUD 0x0020 /* Auto-Baud Enable */ #define PIC32_UMODE_LPBACK 0x0040 /* UARTx Loopback Mode */ #define PIC32_UMODE_WAKE 0x0080 /* Wake-up on start bit during Sleep Mode */ #define PIC32_UMODE_UEN 0x0300 /* Bitmask: */ #define PIC32_UMODE_UEN_RTS 0x0100 /* Using UxRTS pin */ #define PIC32_UMODE_UEN_RTSCTS 0x0200 /* Using UxCTS and UxRTS pins */ #define PIC32_UMODE_UEN_BCLK 0x0300 /* Using UxBCLK pin */ #define PIC32_UMODE_RTSMD 0x0800 /* UxRTS Pin Simplex mode */ #define PIC32_UMODE_IREN 0x1000 /* IrDA Encoder and Decoder Enable bit */ #define PIC32_UMODE_SIDL 0x2000 /* Stop in Idle Mode */ #define PIC32_UMODE_FRZ 0x4000 /* Freeze in Debug Exception Mode */ #define PIC32_UMODE_ON 0x8000 /* UART Enable */ /* * UART Control and status register. */ #define PIC32_USTA_URXDA 0x00000001 /* Receive Data Available (read-only) */ #define PIC32_USTA_OERR 0x00000002 /* Receive Buffer Overrun */ #define PIC32_USTA_FERR 0x00000004 /* Framing error detected (read-only) */ #define PIC32_USTA_PERR 0x00000008 /* Parity error detected (read-only) */ #define PIC32_USTA_RIDLE 0x00000010 /* Receiver is idle (read-only) */ #define PIC32_USTA_ADDEN 0x00000020 /* Address Detect mode */ #define PIC32_USTA_URXISEL 0x000000C0 /* Bitmask: receive interrupt is set when... */ #define PIC32_USTA_URXISEL_NEMP 0x00000000 /* ...receive buffer is not empty */ #define PIC32_USTA_URXISEL_HALF 0x00000040 /* ...receive buffer becomes 1/2 full */ #define PIC32_USTA_URXISEL_3_4 0x00000080 /* ...receive buffer becomes 3/4 full */ #define PIC32_USTA_TRMT 0x00000100 /* Transmit shift register is empty (read-only) */ #define PIC32_USTA_UTXBF 0x00000200 /* Transmit buffer is full (read-only) */ #define PIC32_USTA_UTXEN 0x00000400 /* Transmit Enable */ #define PIC32_USTA_UTXBRK 0x00000800 /* Transmit Break */ #define PIC32_USTA_URXEN 0x00001000 /* Receiver Enable */ #define PIC32_USTA_UTXINV 0x00002000 /* Transmit Polarity Inversion */ #define PIC32_USTA_UTXISEL 0x0000C000 /* Bitmask: TX interrupt is generated when... */ #define PIC32_USTA_UTXISEL_1 0x00000000 /* ...the transmit buffer contains at least one empty space */ #define PIC32_USTA_UTXISEL_ALL 0x00004000 /* ...all characters have been transmitted */ #define PIC32_USTA_UTXISEL_EMP 0x00008000 /* ...the transmit buffer becomes empty */ #define PIC32_USTA_ADDR 0x00FF0000 /* Automatic Address Mask */ #define PIC32_USTA_ADM_EN 0x01000000 /* Automatic Address Detect */ /* * Compute the 16-bit baud rate divisor, given * the oscillator frequency and baud rate. * Round to the nearest integer. */ #define PIC32_BRG_BAUD(fr,bd) ((((fr)/8 + (bd)) / (bd) / 2) - 1) /*-------------------------------------- * SPI registers. */ #ifdef PIC32MX4 #define PIC32_SPI1CON PIC32_R (0x5800) /* Control */ #define PIC32_SPI1CONCLR PIC32_R (0x5804) #define PIC32_SPI1CONSET PIC32_R (0x5808) #define PIC32_SPI1CONINV PIC32_R (0x580C) #define PIC32_SPI1STAT PIC32_R (0x5810) /* Status */ #define PIC32_SPI1STATCLR PIC32_R (0x5814) #define PIC32_SPI1STATSET PIC32_R (0x5818) #define PIC32_SPI1STATINV PIC32_R (0x581C) #define PIC32_SPI1BUF PIC32_R (0x5820) /* Transmit and receive buffer */ #define PIC32_SPI1BRG PIC32_R (0x5830) /* Baud rate generator */ #define PIC32_SPI1BRGCLR PIC32_R (0x5834) #define PIC32_SPI1BRGSET PIC32_R (0x5838) #define PIC32_SPI1BRGINV PIC32_R (0x583C) #endif #ifdef PIC32MX7 #define PIC32_SPI3CON PIC32_R (0x5800) /* Control */ #define PIC32_SPI3CONCLR PIC32_R (0x5804) #define PIC32_SPI3CONSET PIC32_R (0x5808) #define PIC32_SPI3CONINV PIC32_R (0x580C) #define PIC32_SPI3STAT PIC32_R (0x5810) /* Status */ #define PIC32_SPI3STATCLR PIC32_R (0x5814) #define PIC32_SPI3STATSET PIC32_R (0x5818) #define PIC32_SPI3STATINV PIC32_R (0x581C) #define PIC32_SPI3BUF PIC32_R (0x5820) /* Transmit and receive buffer */ #define PIC32_SPI3BRG PIC32_R (0x5830) /* Baud rate generator */ #define PIC32_SPI3BRGCLR PIC32_R (0x5834) #define PIC32_SPI3BRGSET PIC32_R (0x5838) #define PIC32_SPI3BRGINV PIC32_R (0x583C) #define PIC32_SPI4CON PIC32_R (0x5C00) /* Control */ #define PIC32_SPI4CONCLR PIC32_R (0x5C04) #define PIC32_SPI4CONSET PIC32_R (0x5C08) #define PIC32_SPI4CONINV PIC32_R (0x5C0C) #define PIC32_SPI4STAT PIC32_R (0x5C10) /* Status */ #define PIC32_SPI4STATCLR PIC32_R (0x5C14) #define PIC32_SPI4STATSET PIC32_R (0x5C18) #define PIC32_SPI4STATINV PIC32_R (0x5C1C) #define PIC32_SPI4BUF PIC32_R (0x5C20) /* Transmit and receive buffer */ #define PIC32_SPI4BRG PIC32_R (0x5C30) /* Baud rate generator */ #define PIC32_SPI4BRGCLR PIC32_R (0x5C34) #define PIC32_SPI4BRGSET PIC32_R (0x5C38) #define PIC32_SPI4BRGINV PIC32_R (0x5C3C) #define PIC32_SPI1CON PIC32_R (0x5E00) /* Control */ #define PIC32_SPI1CONCLR PIC32_R (0x5E04) #define PIC32_SPI1CONSET PIC32_R (0x5E08) #define PIC32_SPI1CONINV PIC32_R (0x5E0C) #define PIC32_SPI1STAT PIC32_R (0x5E10) /* Status */ #define PIC32_SPI1STATCLR PIC32_R (0x5E14) #define PIC32_SPI1STATSET PIC32_R (0x5E18) #define PIC32_SPI1STATINV PIC32_R (0x5E1C) #define PIC32_SPI1BUF PIC32_R (0x5E20) /* Transmit and receive buffer */ #define PIC32_SPI1BRG PIC32_R (0x5E30) /* Baud rate generator */ #define PIC32_SPI1BRGCLR PIC32_R (0x5E34) #define PIC32_SPI1BRGSET PIC32_R (0x5E38) #define PIC32_SPI1BRGINV PIC32_R (0x5E3C) #endif #define PIC32_SPI2CON PIC32_R (0x5A00) /* Control */ #define PIC32_SPI2CONCLR PIC32_R (0x5A04) #define PIC32_SPI2CONSET PIC32_R (0x5A08) #define PIC32_SPI2CONINV PIC32_R (0x5A0C) #define PIC32_SPI2STAT PIC32_R (0x5A10) /* Status */ #define PIC32_SPI2STATCLR PIC32_R (0x5A14) #define PIC32_SPI2STATSET PIC32_R (0x5A18) #define PIC32_SPI2STATINV PIC32_R (0x5A1C) #define PIC32_SPI2BUF PIC32_R (0x5A20) /* Transmit and receive buffer */ #define PIC32_SPI2BRG PIC32_R (0x5A30) /* Baud rate generator */ #define PIC32_SPI2BRGCLR PIC32_R (0x5A34) #define PIC32_SPI2BRGSET PIC32_R (0x5A38) #define PIC32_SPI2BRGINV PIC32_R (0x5A3C) /* * SPI Control register. */ #define PIC32_SPICON_MSTEN 0x00000020 /* Master mode */ #define PIC32_SPICON_CKP 0x00000040 /* Idle clock is high level */ #define PIC32_SPICON_SSEN 0x00000080 /* Slave mode: SSx pin enable */ #define PIC32_SPICON_CKE 0x00000100 /* Output data changes on * transition from active clock * state to Idle clock state */ #define PIC32_SPICON_SMP 0x00000200 /* Master mode: input data sampled * at end of data output time. */ #define PIC32_SPICON_MODE16 0x00000400 /* 16-bit data width */ #define PIC32_SPICON_MODE32 0x00000800 /* 32-bit data width */ #define PIC32_SPICON_DISSDO 0x00001000 /* SDOx pin is not used */ #define PIC32_SPICON_SIDL 0x00002000 /* Stop in Idle mode */ #define PIC32_SPICON_FRZ 0x00004000 /* Freeze in Debug mode */ #define PIC32_SPICON_ON 0x00008000 /* SPI Peripheral is enabled */ #define PIC32_SPICON_ENHBUF 0x00010000 /* Enhanced buffer enable */ #define PIC32_SPICON_SPIFE 0x00020000 /* Frame synchronization pulse * coincides with the first bit clock */ #define PIC32_SPICON_FRMPOL 0x20000000 /* Frame pulse is active-high */ #define PIC32_SPICON_FRMSYNC 0x40000000 /* Frame sync pulse input (Slave mode) */ #define PIC32_SPICON_FRMEN 0x80000000 /* Framed SPI support */ /* * SPI Status register. */ #define PIC32_SPISTAT_SPIRBF 0x00000001 /* Receive buffer is full */ #define PIC32_SPISTAT_SPITBE 0x00000008 /* Transmit buffer is empty */ #define PIC32_SPISTAT_SPIROV 0x00000040 /* Receive overflow flag */ #define PIC32_SPISTAT_SPIBUSY 0x00000800 /* SPI is busy */ /*-------------------------------------- * Port A-G registers. */ #define PIC32_TRISA PIC32_R (0x86000) /* Port A: mask of inputs */ #define PIC32_TRISACLR PIC32_R (0x86004) #define PIC32_TRISASET PIC32_R (0x86008) #define PIC32_TRISAINV PIC32_R (0x8600C) #define PIC32_PORTA PIC32_R (0x86010) /* Port A: read inputs, write outputs */ #define PIC32_PORTACLR PIC32_R (0x86014) #define PIC32_PORTASET PIC32_R (0x86018) #define PIC32_PORTAINV PIC32_R (0x8601C) #define PIC32_LATA PIC32_R (0x86020) /* Port A: read/write outputs */ #define PIC32_LATACLR PIC32_R (0x86024) #define PIC32_LATASET PIC32_R (0x86028) #define PIC32_LATAINV PIC32_R (0x8602C) #define PIC32_ODCA PIC32_R (0x86030) /* Port A: open drain configuration */ #define PIC32_ODCACLR PIC32_R (0x86034) #define PIC32_ODCASET PIC32_R (0x86038) #define PIC32_ODCAINV PIC32_R (0x8603C) #define PIC32_TRISB PIC32_R (0x86040) /* Port B: mask of inputs */ #define PIC32_TRISBCLR PIC32_R (0x86044) #define PIC32_TRISBSET PIC32_R (0x86048) #define PIC32_TRISBINV PIC32_R (0x8604C) #define PIC32_PORTB PIC32_R (0x86050) /* Port B: read inputs, write outputs */ #define PIC32_PORTBCLR PIC32_R (0x86054) #define PIC32_PORTBSET PIC32_R (0x86058) #define PIC32_PORTBINV PIC32_R (0x8605C) #define PIC32_LATB PIC32_R (0x86060) /* Port B: read/write outputs */ #define PIC32_LATBCLR PIC32_R (0x86064) #define PIC32_LATBSET PIC32_R (0x86068) #define PIC32_LATBINV PIC32_R (0x8606C) #define PIC32_ODCB PIC32_R (0x86070) /* Port B: open drain configuration */ #define PIC32_ODCBCLR PIC32_R (0x86074) #define PIC32_ODCBSET PIC32_R (0x86078) #define PIC32_ODCBINV PIC32_R (0x8607C) #define PIC32_TRISC PIC32_R (0x86080) /* Port C: mask of inputs */ #define PIC32_TRISCCLR PIC32_R (0x86084) #define PIC32_TRISCSET PIC32_R (0x86088) #define PIC32_TRISCINV PIC32_R (0x8608C) #define PIC32_PORTC PIC32_R (0x86090) /* Port C: read inputs, write outputs */ #define PIC32_PORTCCLR PIC32_R (0x86094) #define PIC32_PORTCSET PIC32_R (0x86098) #define PIC32_PORTCINV PIC32_R (0x8609C) #define PIC32_LATC PIC32_R (0x860A0) /* Port C: read/write outputs */ #define PIC32_LATCCLR PIC32_R (0x860A4) #define PIC32_LATCSET PIC32_R (0x860A8) #define PIC32_LATCINV PIC32_R (0x860AC) #define PIC32_ODCC PIC32_R (0x860B0) /* Port C: open drain configuration */ #define PIC32_ODCCCLR PIC32_R (0x860B4) #define PIC32_ODCCSET PIC32_R (0x860B8) #define PIC32_ODCCINV PIC32_R (0x860BC) #define PIC32_TRISD PIC32_R (0x860C0) /* Port D: mask of inputs */ #define PIC32_TRISDCLR PIC32_R (0x860C4) #define PIC32_TRISDSET PIC32_R (0x860C8) #define PIC32_TRISDINV PIC32_R (0x860CC) #define PIC32_PORTD PIC32_R (0x860D0) /* Port D: read inputs, write outputs */ #define PIC32_PORTDCLR PIC32_R (0x860D4) #define PIC32_PORTDSET PIC32_R (0x860D8) #define PIC32_PORTDINV PIC32_R (0x860DC) #define PIC32_LATD PIC32_R (0x860E0) /* Port D: read/write outputs */ #define PIC32_LATDCLR PIC32_R (0x860E4) #define PIC32_LATDSET PIC32_R (0x860E8) #define PIC32_LATDINV PIC32_R (0x860EC) #define PIC32_ODCD PIC32_R (0x860F0) /* Port D: open drain configuration */ #define PIC32_ODCDCLR PIC32_R (0x860F4) #define PIC32_ODCDSET PIC32_R (0x860F8) #define PIC32_ODCDINV PIC32_R (0x860FC) #define PIC32_TRISE PIC32_R (0x86100) /* Port E: mask of inputs */ #define PIC32_TRISECLR PIC32_R (0x86104) #define PIC32_TRISESET PIC32_R (0x86108) #define PIC32_TRISEINV PIC32_R (0x8610C) #define PIC32_PORTE PIC32_R (0x86110) /* Port E: read inputs, write outputs */ #define PIC32_PORTECLR PIC32_R (0x86114) #define PIC32_PORTESET PIC32_R (0x86118) #define PIC32_PORTEINV PIC32_R (0x8611C) #define PIC32_LATE PIC32_R (0x86120) /* Port E: read/write outputs */ #define PIC32_LATECLR PIC32_R (0x86124) #define PIC32_LATESET PIC32_R (0x86128) #define PIC32_LATEINV PIC32_R (0x8612C) #define PIC32_ODCE PIC32_R (0x86130) /* Port E: open drain configuration */ #define PIC32_ODCECLR PIC32_R (0x86134) #define PIC32_ODCESET PIC32_R (0x86138) #define PIC32_ODCEINV PIC32_R (0x8613C) #define PIC32_TRISF PIC32_R (0x86140) /* Port F: mask of inputs */ #define PIC32_TRISFCLR PIC32_R (0x86144) #define PIC32_TRISFSET PIC32_R (0x86148) #define PIC32_TRISFINV PIC32_R (0x8614C) #define PIC32_PORTF PIC32_R (0x86150) /* Port F: read inputs, write outputs */ #define PIC32_PORTFCLR PIC32_R (0x86154) #define PIC32_PORTFSET PIC32_R (0x86158) #define PIC32_PORTFINV PIC32_R (0x8615C) #define PIC32_LATF PIC32_R (0x86160) /* Port F: read/write outputs */ #define PIC32_LATFCLR PIC32_R (0x86164) #define PIC32_LATFSET PIC32_R (0x86168) #define PIC32_LATFINV PIC32_R (0x8616C) #define PIC32_ODCF PIC32_R (0x86170) /* Port F: open drain configuration */ #define PIC32_ODCFCLR PIC32_R (0x86174) #define PIC32_ODCFSET PIC32_R (0x86178) #define PIC32_ODCFINV PIC32_R (0x8617C) #define PIC32_TRISG PIC32_R (0x86180) /* Port G: mask of inputs */ #define PIC32_TRISGCLR PIC32_R (0x86184) #define PIC32_TRISGSET PIC32_R (0x86188) #define PIC32_TRISGINV PIC32_R (0x8618C) #define PIC32_PORTG PIC32_R (0x86190) /* Port G: read inputs, write outputs */ #define PIC32_PORTGCLR PIC32_R (0x86194) #define PIC32_PORTGSET PIC32_R (0x86198) #define PIC32_PORTGINV PIC32_R (0x8619C) #define PIC32_LATG PIC32_R (0x861A0) /* Port G: read/write outputs */ #define PIC32_LATGCLR PIC32_R (0x861A4) #define PIC32_LATGSET PIC32_R (0x861A8) #define PIC32_LATGINV PIC32_R (0x861AC) #define PIC32_ODCG PIC32_R (0x861B0) /* Port G: open drain configuration */ #define PIC32_ODCGCLR PIC32_R (0x861B4) #define PIC32_ODCGSET PIC32_R (0x861B8) #define PIC32_ODCGINV PIC32_R (0x861BC) #define PIC32_CNCON PIC32_R (0x861C0) /* Interrupt-on-change control */ #define PIC32_CNCONCLR PIC32_R (0x861C4) #define PIC32_CNCONSET PIC32_R (0x861C8) #define PIC32_CNCONINV PIC32_R (0x861CC) #define PIC32_CNEN PIC32_R (0x861D0) /* Input change interrupt enable */ #define PIC32_CNENCLR PIC32_R (0x861D4) #define PIC32_CNENSET PIC32_R (0x861D8) #define PIC32_CNENINV PIC32_R (0x861DC) #define PIC32_CNPUE PIC32_R (0x861E0) /* Input pin pull-up enable */ #define PIC32_CNPUECLR PIC32_R (0x861E4) #define PIC32_CNPUESET PIC32_R (0x861E8) #define PIC32_CNPUEINV PIC32_R (0x861EC) /*-------------------------------------- * A/D Converter registers. */ #define PIC32_AD1CON1 PIC32_R (0x9000) /* Control register 1 */ #define PIC32_AD1CON1CLR PIC32_R (0x9004) #define PIC32_AD1CON1SET PIC32_R (0x9008) #define PIC32_AD1CON1INV PIC32_R (0x900C) #define PIC32_AD1CON2 PIC32_R (0x9010) /* Control register 2 */ #define PIC32_AD1CON2CLR PIC32_R (0x9014) #define PIC32_AD1CON2SET PIC32_R (0x9018) #define PIC32_AD1CON2INV PIC32_R (0x901C) #define PIC32_AD1CON3 PIC32_R (0x9020) /* Control register 3 */ #define PIC32_AD1CON3CLR PIC32_R (0x9024) #define PIC32_AD1CON3SET PIC32_R (0x9028) #define PIC32_AD1CON3INV PIC32_R (0x902C) #define PIC32_AD1CHS PIC32_R (0x9040) /* Channel select */ #define PIC32_AD1CHSCLR PIC32_R (0x9044) #define PIC32_AD1CHSSET PIC32_R (0x9048) #define PIC32_AD1CHSINV PIC32_R (0x904C) #define PIC32_AD1CSSL PIC32_R (0x9050) /* Input scan selection */ #define PIC32_AD1CSSLCLR PIC32_R (0x9054) #define PIC32_AD1CSSLSET PIC32_R (0x9058) #define PIC32_AD1CSSLINV PIC32_R (0x905C) #define PIC32_AD1PCFG PIC32_R (0x9060) /* Port configuration */ #define PIC32_AD1PCFGCLR PIC32_R (0x9064) #define PIC32_AD1PCFGSET PIC32_R (0x9068) #define PIC32_AD1PCFGINV PIC32_R (0x906C) #define PIC32_ADC1BUF0 PIC32_R (0x9070) /* Result words */ #define PIC32_ADC1BUF1 PIC32_R (0x9080) #define PIC32_ADC1BUF2 PIC32_R (0x9090) #define PIC32_ADC1BUF3 PIC32_R (0x90A0) #define PIC32_ADC1BUF4 PIC32_R (0x90B0) #define PIC32_ADC1BUF5 PIC32_R (0x90C0) #define PIC32_ADC1BUF6 PIC32_R (0x90D0) #define PIC32_ADC1BUF7 PIC32_R (0x90E0) #define PIC32_ADC1BUF8 PIC32_R (0x90F0) #define PIC32_ADC1BUF9 PIC32_R (0x9100) #define PIC32_ADC1BUFA PIC32_R (0x9110) #define PIC32_ADC1BUFB PIC32_R (0x9120) #define PIC32_ADC1BUFC PIC32_R (0x9130) #define PIC32_ADC1BUFD PIC32_R (0x9140) #define PIC32_ADC1BUFE PIC32_R (0x9150) #define PIC32_ADC1BUFF PIC32_R (0x9160) /*-------------------------------------- * Parallel master port registers. */ #define PIC32_PMCON PIC32_R (0x7000) /* Control */ #define PIC32_PMCONCLR PIC32_R (0x7004) #define PIC32_PMCONSET PIC32_R (0x7008) #define PIC32_PMCONINV PIC32_R (0x700C) #define PIC32_PMMODE PIC32_R (0x7010) /* Mode */ #define PIC32_PMMODECLR PIC32_R (0x7014) #define PIC32_PMMODESET PIC32_R (0x7018) #define PIC32_PMMODEINV PIC32_R (0x701C) #define PIC32_PMADDR PIC32_R (0x7020) /* Address */ #define PIC32_PMADDRCLR PIC32_R (0x7024) #define PIC32_PMADDRSET PIC32_R (0x7028) #define PIC32_PMADDRINV PIC32_R (0x702C) #define PIC32_PMDOUT PIC32_R (0x7030) /* Data output */ #define PIC32_PMDOUTCLR PIC32_R (0x7034) #define PIC32_PMDOUTSET PIC32_R (0x7038) #define PIC32_PMDOUTINV PIC32_R (0x703C) #define PIC32_PMDIN PIC32_R (0x7040) /* Data input */ #define PIC32_PMDINCLR PIC32_R (0x7044) #define PIC32_PMDINSET PIC32_R (0x7048) #define PIC32_PMDININV PIC32_R (0x704C) #define PIC32_PMAEN PIC32_R (0x7050) /* Pin enable */ #define PIC32_PMAENCLR PIC32_R (0x7054) #define PIC32_PMAENSET PIC32_R (0x7058) #define PIC32_PMAENINV PIC32_R (0x705C) #define PIC32_PMSTAT PIC32_R (0x7060) /* Status (slave only) */ #define PIC32_PMSTATCLR PIC32_R (0x7064) #define PIC32_PMSTATSET PIC32_R (0x7068) #define PIC32_PMSTATINV PIC32_R (0x706C) /* * PMP Control register. */ #define PIC32_PMCON_RDSP 0x0001 /* Read strobe polarity active-high */ #define PIC32_PMCON_WRSP 0x0002 /* Write strobe polarity active-high */ #define PIC32_PMCON_CS1P 0x0008 /* Chip select 0 polarity active-high */ #define PIC32_PMCON_CS2P 0x0010 /* Chip select 1 polarity active-high */ #define PIC32_PMCON_ALP 0x0020 /* Address latch polarity active-high */ #define PIC32_PMCON_CSF 0x00C0 /* Chip select function bitmask: */ #define PIC32_PMCON_CSF_NONE 0x0000 /* PMCS2 and PMCS1 as A[15:14] */ #define PIC32_PMCON_CSF_CS2 0x0040 /* PMCS2 as chip select */ #define PIC32_PMCON_CSF_CS21 0x0080 /* PMCS2 and PMCS1 as chip select */ #define PIC32_PMCON_PTRDEN 0x0100 /* Read/write strobe port enable */ #define PIC32_PMCON_PTWREN 0x0200 /* Write enable strobe port enable */ #define PIC32_PMCON_PMPTTL 0x0400 /* TTL input buffer select */ #define PIC32_PMCON_ADRMUX 0x1800 /* Address/data mux selection bitmask: */ #define PIC32_PMCON_ADRMUX_NONE 0x0000 /* Address and data separate */ #define PIC32_PMCON_ADRMUX_AD 0x0800 /* Lower address on PMD[7:0], high on PMA[15:8] */ #define PIC32_PMCON_ADRMUX_D8 0x1000 /* All address on PMD[7:0] */ #define PIC32_PMCON_ADRMUX_D16 0x1800 /* All address on PMD[15:0] */ #define PIC32_PMCON_SIDL 0x2000 /* Stop in idle */ #define PIC32_PMCON_FRZ 0x4000 /* Freeze in debug exception */ #define PIC32_PMCON_ON 0x8000 /* Parallel master port enable */ /* * PMP Mode register. */ #define PIC32_PMMODE_WAITE(x) ((x)<<0) /* Wait states: data hold after RW strobe */ #define PIC32_PMMODE_WAITM(x) ((x)<<2) /* Wait states: data RW strobe */ #define PIC32_PMMODE_WAITB(x) ((x)<<6) /* Wait states: data setup to RW strobe */ #define PIC32_PMMODE_MODE 0x0300 /* Mode select bitmask: */ #define PIC32_PMMODE_MODE_SLAVE 0x0000 /* Legacy slave */ #define PIC32_PMMODE_MODE_SLENH 0x0100 /* Enhanced slave */ #define PIC32_PMMODE_MODE_MAST2 0x0200 /* Master mode 2 */ #define PIC32_PMMODE_MODE_MAST1 0x0300 /* Master mode 1 */ #define PIC32_PMMODE_MODE16 0x0400 /* 16-bit mode */ #define PIC32_PMMODE_INCM 0x1800 /* Address increment mode bitmask: */ #define PIC32_PMMODE_INCM_NONE 0x0000 /* No increment/decrement */ #define PIC32_PMMODE_INCM_INC 0x0800 /* Increment address */ #define PIC32_PMMODE_INCM_DEC 0x1000 /* Decrement address */ #define PIC32_PMMODE_INCM_SLAVE 0x1800 /* Slave auto-increment */ #define PIC32_PMMODE_IRQM 0x6000 /* Interrupt request bitmask: */ #define PIC32_PMMODE_IRQM_DIS 0x0000 /* No interrupt generated */ #define PIC32_PMMODE_IRQM_END 0x2000 /* Interrupt at end of read/write cycle */ #define PIC32_PMMODE_IRQM_A3 0x4000 /* Interrupt on address 3 */ #define PIC32_PMMODE_BUSY 0x8000 /* Port is busy */ /* * PMP Address register. */ #define PIC32_PMADDR_PADDR 0x3FFF /* Destination address */ #define PIC32_PMADDR_CS1 0x4000 /* Chip select 1 is active */ #define PIC32_PMADDR_CS2 0x8000 /* Chip select 2 is active */ /* * PMP status register (slave only). */ #define PIC32_PMSTAT_OB0E 0x0001 /* Output buffer 0 empty */ #define PIC32_PMSTAT_OB1E 0x0002 /* Output buffer 1 empty */ #define PIC32_PMSTAT_OB2E 0x0004 /* Output buffer 2 empty */ #define PIC32_PMSTAT_OB3E 0x0008 /* Output buffer 3 empty */ #define PIC32_PMSTAT_OBUF 0x0040 /* Output buffer underflow */ #define PIC32_PMSTAT_OBE 0x0080 /* Output buffer empty */ #define PIC32_PMSTAT_IB0F 0x0100 /* Input buffer 0 full */ #define PIC32_PMSTAT_IB1F 0x0200 /* Input buffer 1 full */ #define PIC32_PMSTAT_IB2F 0x0400 /* Input buffer 2 full */ #define PIC32_PMSTAT_IB3F 0x0800 /* Input buffer 3 full */ #define PIC32_PMSTAT_IBOV 0x4000 /* Input buffer overflow */ #define PIC32_PMSTAT_IBF 0x8000 /* Input buffer full */ #endif /* _IO_PIC32MX_H */ ================================================ FILE: tools/virtualmips/sbox.c ================================================ /* * Cisco router simulation platform. * Copyright (c) 2007 Christophe Fillot (cf@utc.fr) * * S-Box: http://bretm.home.comcast.net/hash/10.html */ #include #include #include #include #include #include #include #include #include #include #include "utils.h" #include "sbox.h" m_uint32_t sbox_array[] = { 0xF53E1837, 0x5F14C86B, 0x9EE3964C, 0xFA796D53, 0x32223FC3, 0x4D82BC98, 0xA0C7FA62, 0x63E2C982, 0x24994A5B, 0x1ECE7BEE, 0x292B38EF, 0xD5CD4E56, 0x514F4303, 0x7BE12B83, 0x7192F195, 0x82DC7300, 0x084380B4, 0x480B55D3, 0x5F430471, 0x13F75991, 0x3F9CF22C, 0x2FE0907A, 0xFD8E1E69, 0x7B1D5DE8, 0xD575A85C, 0xAD01C50A, 0x7EE00737, 0x3CE981E8, 0x0E447EFA, 0x23089DD6, 0xB59F149F, 0x13600EC7, 0xE802C8E6, 0x670921E4, 0x7207EFF0, 0xE74761B0, 0x69035234, 0xBFA40F19, 0xF63651A0, 0x29E64C26, 0x1F98CCA7, 0xD957007E, 0xE71DDC75, 0x3E729595, 0x7580B7CC, 0xD7FAF60B, 0x92484323, 0xA44113EB, 0xE4CBDE08, 0x346827C9, 0x3CF32AFA, 0x0B29BCF1, 0x6E29F7DF, 0xB01E71CB, 0x3BFBC0D1, 0x62EDC5B8, 0xB7DE789A, 0xA4748EC9, 0xE17A4C4F, 0x67E5BD03, 0xF3B33D1A, 0x97D8D3E9, 0x09121BC0, 0x347B2D2C, 0x79A1913C, 0x504172DE, 0x7F1F8483, 0x13AC3CF6, 0x7A2094DB, 0xC778FA12, 0xADF7469F, 0x21786B7B, 0x71A445D0, 0xA8896C1B, 0x656F62FB, 0x83A059B3, 0x972DFE6E, 0x4122000C, 0x97D9DA19, 0x17D5947B, 0xB1AFFD0C, 0x6EF83B97, 0xAF7F780B, 0x4613138A, 0x7C3E73A6, 0xCF15E03D, 0x41576322, 0x672DF292, 0xB658588D, 0x33EBEFA9, 0x938CBF06, 0x06B67381, 0x07F192C6, 0x2BDA5855, 0x348EE0E8, 0x19DBB6E3, 0x3222184B, 0xB69D5DBA, 0x7E760B88, 0xAF4D8154, 0x007A51AD, 0x35112500, 0xC9CD2D7D, 0x4F4FB761, 0x694772E3, 0x694C8351, 0x4A7E3AF5, 0x67D65CE1, 0x9287DE92, 0x2518DB3C, 0x8CB4EC06, 0xD154D38F, 0xE19A26BB, 0x295EE439, 0xC50A1104, 0x2153C6A7, 0x82366656, 0x0713BC2F, 0x6462215A, 0x21D9BFCE, 0xBA8EACE6, 0xAE2DF4C1, 0x2A8D5E80, 0x3F7E52D1, 0x29359399, 0xFEA1D19C, 0x18879313, 0x455AFA81, 0xFADFE838, 0x62609838, 0xD1028839, 0x0736E92F, 0x3BCA22A3, 0x1485B08A, 0x2DA7900B, 0x852C156D, 0xE8F24803, 0x00078472, 0x13F0D332, 0x2ACFD0CF, 0x5F747F5C, 0x87BB1E2F, 0xA7EFCB63, 0x23F432F0, 0xE6CE7C5C, 0x1F954EF6, 0xB609C91B, 0x3B4571BF, 0xEED17DC0, 0xE556CDA0, 0xA7846A8D, 0xFF105F94, 0x52B7CCDE, 0x0E33E801, 0x664455EA, 0xF2C70414, 0x73E7B486, 0x8F830661, 0x8B59E826, 0xBB8AEDCA, 0xF3D70AB9, 0xD739F2B9, 0x4A04C34A, 0x88D0F089, 0xE02191A2, 0xD89D9C78, 0x192C2749, 0xFC43A78F, 0x0AAC88CB, 0x9438D42D, 0x9E280F7A, 0x36063802, 0x38E8D018, 0x1C42A9CB, 0x92AAFF6C, 0xA24820C5, 0x007F077F, 0xCE5BC543, 0x69668D58, 0x10D6FF74, 0xBE00F621, 0x21300BBE, 0x2E9E8F46, 0x5ACEA629, 0xFA1F86C7, 0x52F206B8, 0x3EDF1A75, 0x6DA8D843, 0xCF719928, 0x73E3891F, 0xB4B95DD6, 0xB2A42D27, 0xEDA20BBF, 0x1A58DBDF, 0xA449AD03, 0x6DDEF22B, 0x900531E6, 0x3D3BFF35, 0x5B24ABA2, 0x472B3E4C, 0x387F2D75, 0x4D8DBA36, 0x71CB5641, 0xE3473F3F, 0xF6CD4B7F, 0xBF7D1428, 0x344B64D0, 0xC5CDFCB6, 0xFE2E0182, 0x2C37A673, 0xDE4EB7A3, 0x63FDC933, 0x01DC4063, 0x611F3571, 0xD167BFAF, 0x4496596F, 0x3DEE0689, 0xD8704910, 0x7052A114, 0x068C9EC5, 0x75D0E766, 0x4D54CC20, 0xB44ECDE2, 0x4ABC653E, 0x2C550A21, 0x1A52C0DB, 0xCFED03D0, 0x119BAFE2, 0x876A6133, 0xBC232088, 0x435BA1B2, 0xAE99BBFA, 0xBB4F08E4, 0xA62B5F49, 0x1DA4B695, 0x336B84DE, 0xDC813D31, 0x00C134FB, 0x397A98E6, 0x151F0E64, 0xD9EB3E69, 0xD3C7DF60, 0xD2F2C336, 0x2DDD067B, 0xBD122835, 0xB0B3BD3A, 0xB0D54E46, 0x8641F1E4, 0xA0B38F96, 0x51D39199, 0x37A6AD75, 0xDF84EE41, 0x3C034CBA, 0xACDA62FC, 0x11923B8B, 0x45EF170A, }; ================================================ FILE: tools/virtualmips/sbox.h ================================================ /* * Cisco router simulation platform. * Copyright (c) 2007 Christophe Fillot (cf@utc.fr) * * S-box functions. */ #ifndef __SBOX_H__ #define __SBOX_H__ #include #include "utils.h" extern m_uint32_t sbox_array[]; static inline m_uint32_t sbox_compute (m_uint8_t * data, int len) { m_uint32_t hash = 0; while (len > 0) { hash ^= sbox_array[*data]; hash *= 3; data++; } return (hash); } static forced_inline m_uint32_t sbox_u32 (m_uint32_t val) { m_uint32_t hash = 0; hash ^= sbox_array[(m_uint8_t) val]; hash *= 3; val >>= 8; hash ^= sbox_array[(m_uint8_t) val]; hash *= 3; val >>= 8; hash ^= sbox_array[(m_uint8_t) val]; hash *= 3; val >>= 8; hash ^= sbox_array[(m_uint8_t) val]; return (hash); } #endif ================================================ FILE: tools/virtualmips/system.h ================================================ /* * Copyright (C) yajin 2008 * * This file is part of the virtualmips distribution. * See LICENSE file for terms of the license. * */ #ifndef __SYSTEM_H__ #define __SYSTEM_H__ #ifdef SIM_ADM5120 #include "adm5120.h" #endif #ifdef SIM_PAVO #include "pavo.h" #endif #ifdef SIM_PIC32 #include "pic32.h" #endif #endif ================================================ FILE: tools/virtualmips/types.h ================================================ /* * Copyright (C) yajin 2008 * * This file is part of the virtualmips distribution. * See LICENSE file for terms of the license. * */ #ifndef __TYPES_H__ #define __TYPES_H__ #include /*types from qemu*/ typedef unsigned char uint8_t; typedef unsigned short uint16_t; typedef unsigned int uint32_t; #if defined(__linux__) || defined(__APPLE__) typedef u_int64_t uint64_t; #endif #ifndef __sun__ typedef signed char int8_t; #endif typedef signed short int16_t; typedef signed int int32_t; /*used in dynamips. so just typedef again*/ /* Common types */ typedef uint8_t m_uint8_t; typedef int8_t m_int8_t; typedef uint16_t m_uint16_t; typedef int16_t m_int16_t; typedef uint32_t m_uint32_t; typedef int32_t m_int32_t; typedef uint64_t m_uint64_t; typedef int64_t m_int64_t; typedef unsigned long m_iptr_t; typedef m_uint64_t m_tmcnt_t; #if defined (__x86_64__) || defined(__ia64) /*function label address*/ typedef m_uint64_t m_hiptr_t; #else typedef m_uint32_t m_hiptr_t; #endif typedef void (*pvoid) (void); /* MIPS instruction */ typedef m_uint32_t mips_insn_t; /* True/False definitions */ #ifndef FALSE #define FALSE 0 #endif #ifndef TRUE #define TRUE 1 #endif //for gdb interface /* Used for functions which can fail */ enum result_t { SUCCESS, FAILURE, STALL, BUSERROR, SCFAILURE }; /* Forward declarations */ typedef struct cpu_mips cpu_mips_t; typedef struct vm_instance vm_instance_t; typedef struct vdevice vdevice_t; typedef struct mips_jit_tcb mips_jit_tcb_t; typedef struct insn_exec_page insn_exec_page_t; #endif ================================================ FILE: tools/virtualmips/utils.c ================================================ /* * Cisco router simulation platform. * Copyright (c) 2005,2006 Christophe Fillot. All rights reserved. * * Utility functions. */ /* * Copyright (C) yajin 2008 * * This file is part of the virtualmips distribution. * See LICENSE file for terms of the license. * */ #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifdef __CYGWIN__ #include #endif #include "utils.h" extern FILE *log_file; unsigned int get_file_size (const char *file_path) { struct stat statbuf; if (stat (file_path, &statbuf) == -1) { printf ("Get stat on %s Error:%s\n", file_path, strerror (errno)); return (0); } if (S_ISDIR (statbuf.st_mode)) return (0); if (S_ISREG (statbuf.st_mode)) return (statbuf.st_size); return 0; } /* Dynamic sprintf */ char *dyn_sprintf (const char *fmt, ...) { int n, size = 512; va_list ap; char *p, *p2; if ((p = malloc (size)) == NULL) { perror ("dyn_sprintf: malloc"); return NULL; } for (;;) { /* Try to print in the allocated space */ va_start (ap, fmt); n = vsnprintf (p, size, fmt, ap); va_end (ap); /* If that worked, return the string */ if ((n > -1) && (n < size)) return p; /* Else try again with more space. */ if (n > -1) size = n + 1; else size *= 2; free (p); if ((p2 = malloc (size)) == NULL) { perror ("dyn_sprintf: realloc"); return NULL; } p = p2; } free (p2); } /* Split a string */ int m_strsplit (char *str, char delim, char **array, int max_count) { int i, pos = 0; size_t len; char *ptr; for (i = 0; i < max_count; i++) array[i] = NULL; do { if (pos == max_count) goto error; ptr = strchr (str, delim); if (!ptr) ptr = str + strlen (str); len = ptr - str; if (!(array[pos] = malloc (len + 1))) goto error; memcpy (array[pos], str, len); array[pos][len] = 0; str = ptr + 1; pos++; } while (*ptr); return (pos); error: for (i = 0; i < max_count; i++) free (array[i]); return (-1); } /* Tokenize a string */ int m_strtok (char *str, char delim, char **array, int max_count) { int i, pos = 0; size_t len; char *ptr; for (i = 0; i < max_count; i++) array[i] = NULL; do { if (pos == max_count) goto error; ptr = strchr (str, delim); if (!ptr) ptr = str + strlen (str); len = ptr - str; if (!(array[pos] = malloc (len + 1))) goto error; memcpy (array[pos], str, len); array[pos][len] = 0; while (*ptr == delim) ptr++; str = ptr; pos++; } while (*ptr); return (pos); error: for (i = 0; i < max_count; i++) free (array[i]); return (-1); } /* Quote a string */ char *m_strquote (char *buffer, size_t buf_len, char *str) { char *p; if (!(p = strpbrk (str, " \t\"'"))) return str; snprintf (buffer, buf_len, "\"%s\"", str); return buffer; } /* Ugly function that dumps a structure in hexa and ascii. */ void mem_dump (FILE * f_output, u_char * pkt, u_int len) { u_int x, i = 0, tmp; while (i < len) { if ((len - i) > 16) x = 16; else x = len - i; fprintf (f_output, "%4.4x: ", i); for (tmp = 0; tmp < x; tmp++) fprintf (f_output, "%2.2x ", pkt[i + tmp]); for (tmp = x; tmp < 16; tmp++) fprintf (f_output, " "); for (tmp = 0; tmp < x; tmp++) { char c = pkt[i + tmp]; if (((c >= 'A') && (c <= 'Z')) || ((c >= 'a') && (c <= 'z')) || ((c >= '0') && (c <= '9'))) fprintf (f_output, "%c", c); else fputs (".", f_output); } i += x; fprintf (f_output, "\n"); } fprintf (f_output, "\n"); } /* Logging function */ void m_flog (FILE * fd, char *module, char *fmt, va_list ap) { struct timeval now; static char buf[256]; time_t ct; gettimeofday (&now, 0); ct = now.tv_sec; strftime (buf, sizeof (buf), "%b %d %H:%M:%S", localtime (&ct)); if (fd) { fprintf (fd, "%s.%03ld %s: ", buf, (long) now.tv_usec / 1000, module); vfprintf (fd, fmt, ap); fflush (fd); } } #if 0 /* Logging function */ void m_log (char *module, char *fmt, ...) { va_list ap; va_start (ap, fmt); m_flog (log_file, module, fmt, ap); va_end (ap); } #endif /* Returns a line from specified file (remove trailing '\n') */ char *m_fgets (char *buffer, int size, FILE * fd) { int len; buffer[0] = '\0'; if (fgets (buffer, size, fd) == NULL) return NULL; len = strlen (buffer); if (len == 0) return NULL; /* remove trailing '\n' */ if (buffer[len - 1] == '\n') buffer[len - 1] = '\0'; return buffer; } /* Read a file and returns it in a buffer */ ssize_t m_read_file (char *filename, char **buffer) { char tmp[256], *ptr, *nptr; size_t len, tot_len; FILE *fd; *buffer = ptr = NULL; tot_len = 0; /* Open file for reading */ if ((fd = fopen (filename, "r")) == NULL) return (-1); while ((len = fread (tmp, 1, sizeof (tmp), fd)) > 0) { /* Reallocate memory */ nptr = realloc (ptr, tot_len + len + 1); if (nptr == NULL) { if (ptr) free (ptr); fclose (fd); return (-1); } ptr = nptr; /* Ok, memory could be allocated */ memcpy (&ptr[tot_len], tmp, len); tot_len += len; } fclose (fd); *buffer = ptr; return (tot_len); } /* Allocate aligned memory */ void *m_memalign (size_t boundary, size_t size) { void *p; #if defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) if (posix_memalign ((void *) &p, boundary, size)) #else #if defined(__CYGWIN__) || defined(SUNOS) if (!(p = memalign (boundary, size))) #else if (!(p = malloc (size))) #endif #endif return NULL; assert (((m_iptr_t) p & (boundary - 1)) == 0); return p; } /* Block specified signal for calling thread */ int m_signal_block (int sig) { sigset_t sig_mask; sigemptyset (&sig_mask); sigaddset (&sig_mask, sig); return (pthread_sigmask (SIG_BLOCK, &sig_mask, NULL)); } /* Unblock specified signal for calling thread */ int m_signal_unblock (int sig) { sigset_t sig_mask; sigemptyset (&sig_mask); sigaddset (&sig_mask, sig); return (pthread_sigmask (SIG_UNBLOCK, &sig_mask, NULL)); } /* Set non-blocking mode on a file descriptor */ int m_fd_set_non_block (int fd) { int flags; if ((flags = fcntl (fd, F_GETFL, 0)) < 1) return (-1); return (fcntl (fd, F_SETFL, flags | O_NONBLOCK)); } /* Map a memory zone from a file */ u_char *memzone_map_file (int fd, size_t len) { return (mmap (NULL, len, PROT_READ | PROT_WRITE, MAP_SHARED, fd, (off_t) 0)); } /* Map a memory zone from a file, with copy-on-write (COW) */ u_char *memzone_map_cow_file (int fd, size_t len) { return (mmap (NULL, len, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, (off_t) 0)); } /* Create a file to serve as a memory zone */ int memzone_create_file (char *filename, size_t len, u_char ** ptr) { int fd; if ((fd = open (filename, O_CREAT | O_RDWR, S_IRWXU)) == -1) { perror ("memzone_create_file: open"); return (-1); } if (ftruncate (fd, len) == -1) { perror ("memzone_create_file: ftruncate"); close (fd); return (-1); } *ptr = memzone_map_file (fd, len); if (!*ptr) { close (fd); fd = -1; } return (fd); } /* Open a file to serve as a COW memory zone */ int memzone_open_cow_file (char *filename, size_t len, u_char ** ptr) { int fd; if ((fd = open (filename, O_RDWR, S_IRWXU)) == -1) { perror ("memzone_open_file: open"); return (-1); } *ptr = memzone_map_cow_file (fd, len); if (!*ptr) { close (fd); fd = -1; } return (fd); } /* Open a file and map it in memory */ int memzone_open_file (char *filename, u_char ** ptr, off_t * fsize) { struct stat fprop; int fd; if ((fd = open (filename, O_RDWR, S_IRWXU)) == -1) return (-1); if (fstat (fd, &fprop) == -1) goto err_fstat; *fsize = fprop.st_size; if (!(*ptr = memzone_map_file (fd, *fsize))) goto err_mmap; return (fd); err_mmap: err_fstat: close (fd); return (-1); } /* Compute NVRAM checksum */ m_uint16_t nvram_cksum (m_uint16_t * ptr, size_t count) { m_uint32_t sum = 0; while (count > 1) { sum = sum + ntohs (*ptr); ptr++; count -= sizeof (m_uint16_t); } if (count > 0) sum = sum + ((ntohs (*ptr) & 0xFF) << 8); while (sum >> 16) sum = (sum & 0xffff) + (sum >> 16); return (~sum); } /* Byte-swap a memory block */ void mem_bswap32 (void *ptr, size_t len) { m_uint32_t *p = ptr; size_t count = len >> 2; int i; for (i = 0; i < count; i++, p++) *p = swap32 (*p); } /* Reverse a byte */ m_uint8_t m_reverse_u8 (m_uint8_t val) { m_uint8_t res = 0; int i; for (i = 0; i < 8; i++) if (val & (1 << i)) res |= 1 << (7 - i); return (res); } void SubstituteLLx (char *out, const char *text, int maxlen) { int i; for (i = 0; i < maxlen && text[i]; i++) { out[i] = text[i]; } out[i] = text[i]; } /***************************************************************** * Debug * Print a debug message, if flag is enabled. Like printf, * only with an extra argument on the front. * to output debug infomation , you should excute "simos -d [flag]" ****************************************************************/ void Debug (char flag, char *format, ...) { // if (DebugIsEnabled(flag)) { char llformat[1024]; va_list ap; va_start (ap, format); SubstituteLLx (llformat, format, 1024); /* Make this go to stderr also... */ vfprintf (stderr, llformat, ap); //vCPUPrint(llformat, ap); fprintf (stderr, "\r"); fflush (stderr); va_end (ap); //} } ================================================ FILE: tools/virtualmips/utils.h ================================================ /* * Copyright (C) yajin 2008 * * This file is part of the virtualmips distribution. * See LICENSE file for terms of the license. * */ #ifndef __UTILS_H__ #define __UTILS_H__ #include #include #include #include #include #include #include #include #include "config.h" #include "types.h" #include "system.h" /* Endianness */ #define ARCH_BIG_ENDIAN 0x4321 #define ARCH_LITTLE_ENDIAN 0x1234 #if defined(PPC) || defined(__powerpc__) || defined(__ppc__) #define HOST_BYTE_ORDER ARCH_BIG_ENDIAN #elif defined(__sparc) || defined(__sparc__) #define HOST_BYTE_ORDER ARCH_BIG_ENDIAN #elif defined(__alpha) || defined(__alpha__) #define HOST_BYTE_ORDER ARCH_LITTLE_ENDIAN #elif defined(__i386) || defined(__i386__) || defined(i386) #define HOST_BYTE_ORDER ARCH_LITTLE_ENDIAN #elif defined(__x86_64__) #define HOST_BYTE_ORDER ARCH_LITTLE_ENDIAN #endif #ifndef HOST_BYTE_ORDER #error Please define your architecture in utils.h! #endif #if __GNUC__ > 2 #define forced_inline inline __attribute__((always_inline)) #define no_inline __attribute__ ((noinline)) /* http://kerneltrap.org/node/4705 */ #define likely(x) __builtin_expect((x),1) #define unlikely(x) __builtin_expect((x),0) #else #define forced_inline inline #define no_inline #define likely(x) (x) #define unlikely(x) (x) #endif #define fastcall __attribute__((regparm(3))) #define asmlinkage __attribute__((regparm(0))) #define ASSERT(a,format,args...) do{ if ((format!=NULL)&&(!(a))) fprintf(stderr,format, ##args); assert((a));} while(0) /* BOOT METHOD */ enum { BOOT_BINARY = 1, BOOT_ELF = 2, }; /* BOOT FROM */ enum { BOOT_FROM_NOR_FLASH = 1, BOOT_FROM_NAND_FLASH = 2, }; /* FLASH TYPE */ enum { FLASH_TYPE_NOR_FLASH = 1, FLASH_TYPE_NAND_FLASH = 2, }; /* Size of a field in a structure */ #define SIZEOF(st,field) (sizeof(((st *)NULL)->field)) /* Compute offset of a field in a structure */ #define OFFSET(st,f) ((long)&((st *)(NULL))->f) /* Max and min macro */ #define m_max(a,b) (((a) > (b)) ? (a) : (b)) #define m_min(a,b) (((a) < (b)) ? (a) : (b)) /* MTS mapping info */ typedef struct { m_va_t vaddr; m_pa_t paddr; m_uint64_t len; // m_uint32_t cached; m_uint32_t tlb_index; m_uint8_t mapped; m_uint8_t dirty; m_uint8_t valid; m_uint32_t asid; m_uint8_t g_bit; } mts_map_t; /* Invalid VTLB entry */ #define MTS_INV_ENTRY_MASK 0x00000001 /* MTS entry flags */ #define MTS_FLAG_DEV 0x000000001 /* Virtual device used */ #define MTS_FLAG_COW 0x000000002 /* Copy-On-Write */ #define MTS_FLAG_EXEC 0x000000004 /* Exec page */ /* Virtual TLB entry (32-bit MMU) */ struct mts32_entry { m_uint32_t gvpa; /* Guest Virtual Page Address */ m_uint32_t gppa; /* Guest Physical Page Address */ m_iptr_t hpa; /* Host Page Address */ m_uint32_t asid; m_uint8_t g_bit; m_uint8_t dirty_bit; m_uint8_t mapped; m_uint32_t flags; /* Flags */ } __attribute__ ((aligned (16))); typedef struct mts32_entry mts32_entry_t; /* Virtual TLB entry (64-bit MMU) */ struct mts64_entry { m_va_t gvpa; /* Guest Virtual Page Address */ m_pa_t gppa; /* Guest Physical Page Address */ m_iptr_t hpa; /* Host Page Address */ m_uint32_t flags; /* Flags */ } __attribute__ ((aligned (16))); typedef struct mts64_entry mts64_entry_t; /* Host register allocation */ #define HREG_FLAG_ALLOC_LOCKED 1 #define HREG_FLAG_ALLOC_FORCED 2 struct hreg_map { int hreg, vreg; int flags; struct hreg_map *prev, *next; }; /* Global logfile */ extern FILE *log_file; /* Check status of a bit */ static inline int check_bit (u_int old, u_int new, u_int bit) { int mask = 1 << bit; if ((old & mask) && !(new & mask)) return (1); /* bit unset */ if (!(old & mask) && (new & mask)) return (2); /* bit set */ /* no change */ return (0); } /* Sign-extension */ #if DATA_WIDTH==64 static forced_inline m_int64_t sign_extend (m_int64_t x, int len) #elif DATA_WIDTH==32 static forced_inline m_int32_t sign_extend (m_int32_t x, int len) #else #error Undefined DATA_WIDTH #endif { len = DATA_WIDTH - len; return (x << len) >> len; } /* Sign-extension (32-bit) */ static forced_inline m_int32_t sign_extend_32 (m_int32_t x, int len) { len = 32 - len; return (x << len) >> len; } /* Extract bits from a 32-bit values */ static inline int bits (m_uint32_t val, int start, int end) { return ((val >> start) & ((1 << (end - start + 1)) - 1)); } /* Normalize a size */ static inline u_int normalize_size (u_int val, u_int nb, int shift) { return (((val + nb - 1) & ~(nb - 1)) >> shift); } /* Use builtin swapxx() on OS other than Linux and FreeBSD. */ #if defined(__linux__) || defined(__FreeBSD__) /* Convert a 16-bit number between little and big endian */ static forced_inline m_uint16_t swap16 (m_uint16_t value) { return ((value >> 8) | ((value & 0xFF) << 8)); } /* Convert a 32-bit number between little and big endian */ static forced_inline m_uint32_t swap32 (m_uint32_t value) { m_uint32_t result; result = value >> 24; result |= ((value >> 16) & 0xff) << 8; result |= ((value >> 8) & 0xff) << 16; result |= (value & 0xff) << 24; return (result); } /* Convert a 64-bit number between little and big endian */ static forced_inline m_uint64_t swap64 (m_uint64_t value) { m_uint64_t result; result = (m_uint64_t) swap32 (value & 0xffffffff) << 32; result |= swap32 (value >> 32); return (result); } #endif /* __linux__ || __FreeBSD__ */ /* Get current time in number of msec since epoch */ static inline m_tmcnt_t m_gettime (void) { struct timeval tvp; gettimeofday (&tvp, NULL); return (((m_tmcnt_t) tvp.tv_sec * 1000) + ((m_tmcnt_t) tvp.tv_usec / 1000)); } /* Get current time in number of usec since epoch */ static inline m_tmcnt_t m_gettime_usec (void) { struct timeval tvp; gettimeofday (&tvp, NULL); return (((m_tmcnt_t) tvp.tv_sec * 1000000) + (m_tmcnt_t) tvp.tv_usec); } #ifdef __CYGWIN__ #define GET_TIMEZONE _timezone #else #define GET_TIMEZONE timezone #endif /* Get current time in number of ms (localtime) */ static inline m_tmcnt_t m_gettime_adj (void) { struct timeval tvp; struct tm tmx; time_t gmt_adjust; time_t ct; gettimeofday (&tvp, NULL); ct = tvp.tv_sec; localtime_r (&ct, &tmx); #if defined(__CYGWIN__) || defined(SUNOS) gmt_adjust = -(tmx.tm_isdst ? GET_TIMEZONE - 3600 : GET_TIMEZONE); #else gmt_adjust = tmx.tm_gmtoff; #endif tvp.tv_sec += gmt_adjust; return (((m_tmcnt_t) tvp.tv_sec * 1000) + ((m_tmcnt_t) tvp.tv_usec / 1000)); } //#if 0 #define DEBUGGING_DISABLED //#endif #ifndef DEBUGGING_DISABLED #define SIM_DEBUG(arg1) Debug arg1 #else #define SIM_DEBUG(arg1) #endif /*return a file size*/ unsigned int get_file_size (const char *filename); /* Dynamic sprintf */ char *dyn_sprintf (const char *fmt, ...); /* Split a string */ int m_strsplit (char *str, char delim, char **array, int max_count); /* Tokenize a string */ int m_strtok (char *str, char delim, char **array, int max_count); /* Quote a string */ char *m_strquote (char *buffer, size_t buf_len, char *str); /* Ugly function that dumps a structure in hexa and ascii. */ void mem_dump (FILE * f_output, u_char * pkt, u_int len); /* Logging function */ void m_flog (FILE * fd, char *module, char *fmt, va_list ap); /* Logging function */ //void m_log(char *module,char *fmt,...); /* Returns a line from specified file (remove trailing '\n') */ char *m_fgets (char *buffer, int size, FILE * fd); /* Read a file and returns it in a buffer */ ssize_t m_read_file (char *filename, char **buffer); /* Allocate aligned memory */ void *m_memalign (size_t boundary, size_t size); /* Block specified signal for calling thread */ int m_signal_block (int sig); /* Unblock specified signal for calling thread */ int m_signal_unblock (int sig); /* Set non-blocking mode on a file descriptor */ int m_fd_set_non_block (int fd); /* Map a memory zone from a file */ u_char *memzone_map_file (int fd, size_t len); /* Map a memory zone from a file, with copy-on-write (COW) */ u_char *memzone_map_cow_file (int fd, size_t len); /* Create a file to serve as a memory zone */ int memzone_create_file (char *filename, size_t len, u_char ** ptr); /* Open a file to serve as a COW memory zone */ int memzone_open_cow_file (char *filename, size_t len, u_char ** ptr); /* Open a file and map it in memory */ int memzone_open_file (char *filename, u_char ** ptr, off_t * fsize); /* Compute NVRAM checksum */ m_uint16_t nvram_cksum (m_uint16_t * ptr, size_t count); /* Byte-swap a memory block */ void mem_bswap32 (void *ptr, size_t len); /* Reverse a byte */ m_uint8_t m_reverse_u8 (m_uint8_t val); void Debug (char flag, char *format, ...); #endif ================================================ FILE: tools/virtualmips/vm.c ================================================ /* * Cisco router simulation platform. * Copyright (c) 2005,2006 Christophe Fillot (cf@utc.fr) * * Virtual machine abstraction. */ /* * Copyright (C) yajin 2008 * * This file is part of the virtualmips distribution. * See LICENSE file for terms of the license. * */ #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include "device.h" #include "cpu.h" #include "vm.h" #include "dev_vtty.h" #include "debug.h" /* Get VM type */ char *vm_get_type (vm_instance_t * vm) { char *machine; switch (vm->type) { case VM_TYPE_SWARM: machine = "swarm"; break; case VM_TYPE_ADM5120: machine = "ADM5120"; break; case VM_TYPE_PAVO: machine = "PAVO"; break; case VM_TYPE_PIC32: machine = "PIC32"; break; default: machine = "unknown"; break; } return machine; } /* Get platform type */ char *vm_get_platform_type (vm_instance_t * vm) { char *machine; switch (vm->type) { case VM_TYPE_SWARM: machine = "swarm"; break; case VM_TYPE_ADM5120: machine = "ADM5120"; break; case VM_TYPE_PIC32: machine = "PIC32"; break; default: machine = "VM"; break; } return machine; } /* Generate a filename for use by the instance */ static char *vm_build_filename (vm_instance_t * vm, char *name) { char *filename; filename = dyn_sprintf ("%s-%s", vm->name, name); assert (filename != NULL); return filename; } /* Log a message */ void vm_flog (vm_instance_t * vm, char *module, char *format, va_list ap) { if (vm->log_fd) m_flog (vm->log_fd, module, format, ap); } /* Log a message */ void vm_log (vm_instance_t * vm, char *module, char *format, ...) { va_list ap; if (vm->log_fd) { va_start (ap, format); vm_flog (vm, module, format, ap); va_end (ap); } } /* Close the log file */ int vm_close_log (vm_instance_t * vm) { if (vm->log_fd) fclose (vm->log_fd); free (vm->log_file); vm->log_file = NULL; vm->log_fd = NULL; return (0); } /* Create the log file */ int vm_create_log (vm_instance_t * vm) { if (vm->log_file_enabled) { vm_close_log (vm); vm->log_file = vm_build_filename (vm, "log.txt"); if (! vm->log_file) return (-1); vm->log_fd = fopen (vm->log_file, "w"); if (! vm->log_fd) { fprintf (stderr, "VM %s: unable to create log file '%s'\n", vm->name, vm->log_file); free (vm->log_file); vm->log_file = NULL; return (-1); } } return (0); } /* Error message */ void vm_error (vm_instance_t * vm, char *format, ...) { char buffer[2048]; va_list ap; va_start (ap, format); vsnprintf (buffer, sizeof (buffer), format, ap); va_end (ap); fprintf (stderr, "%s '%s': %s", vm_get_platform_type (vm), vm->name, buffer); } /* Create a new VM instance */ vm_instance_t *vm_create (const char *name, int machine_type) { vm_instance_t *vm; int i; vm = malloc (sizeof (*vm)); if (!vm) { fprintf (stderr, "VM %s: unable to create new instance!\n", name); return NULL; } memset (vm, 0, sizeof (*vm)); vm->type = machine_type; vm->status = VM_STATUS_HALTED; vm->jit_use = 0; vm->vtty_type[0] = VTTY_TYPE_TERM; for (i=1; ivtty_type[i] = VTTY_TYPE_NONE; //vm->timer_irq_check_itv = VM_TIMER_IRQ_CHECK_ITV; //vm->log_file_enabled = TRUE; vm->name = strdup (name); if (!name) { fprintf (stderr, "VM %s: unable to store instance name!\n", name); goto err_name; } /* create log file */ if (vm_create_log (vm) == -1) { free (vm->name); err_name: free (vm); return NULL; } return vm; } /* * Shutdown hardware resources used by a VM. * The CPU must have been stopped. */ static int vm_hardware_shutdown (vm_instance_t * vm) { //int i; if ((vm->status == VM_STATUS_HALTED) || !vm->cpu_group) { vm_log (vm, "VM", "trying to shutdown an inactive VM.\n"); return (-1); } vm_log (vm, "VM", "shutdown procedure engaged.\n"); /* Mark the VM as halted */ vm->status = VM_STATUS_HALTED; /* Disable NVRAM operations */ // vm->nvram_extract_config = NULL; // vm->nvram_push_config = NULL; /* Free the object list */ // vm_object_free_list(vm); /* Free resources used by PCI busses */ // vm_log(vm,"VM","removing PCI busses.\n"); // pci_io_data_remove(vm,vm->pci_io_space); // pci_bus_remove(vm->pci_bus[0]); // pci_bus_remove(vm->pci_bus[1]); // vm->pci_bus[0] = vm->pci_bus[1] = NULL; /* Free the PCI bus pool */ /* for(i=0;ipci_bus_pool[i] != NULL) { * pci_bus_remove(vm->pci_bus_pool[i]); * vm->pci_bus_pool[i] = NULL; * } * } */ /* Remove the IRQ routing vectors */ vm->set_irq = NULL; vm->clear_irq = NULL; /* Delete the VTTY for Console and AUX ports */ vm_log (vm, "VM", "deleting VTTY.\n"); vm_delete_vtty (vm); /* Delete system CPU group */ vm_log (vm, "VM", "deleting system CPUs.\n"); cpu_group_delete (vm->cpu_group); vm->cpu_group = NULL; vm->boot_cpu = NULL; vm_log (vm, "VM", "shutdown procedure completed.\n"); return (0); } /* Free resources used by a VM */ void vm_free (vm_instance_t * vm) { if (vm != NULL) { /* Free hardware resources */ vm_hardware_shutdown (vm); /* Close log file */ vm_close_log (vm); /* Remove the lock file */ // vm_release_lock(vm,TRUE); /* Free all chunks */ // vm_chunk_free_all(vm); /* Free various elements */ // free(vm->ghost_ram_filename); // free(vm->sym_filename); //free(vm->ios_image); // free(vm->ios_config); //free(vm->rom_filename); free (vm->name); free (vm); } } /* * Initialize RAM */ int vm_ram_init (vm_instance_t * vm, m_pa_t paddr) { m_uint32_t len; len = vm->ram_size * 1024; #ifdef SIM_PAVO /* Why plus 0x2000 (8k) for PAVO?? It seems that jz4740 has an extra 8k boot memory. I am not sure. But uboot use the extra memory space beyond 64M memory space. So I just add 0x2000 to ram. */ len += 0x2000; #endif return (dev_ram_init (vm, "ram", paddr, len)); } /* Initialize VTTY */ int vm_init_vtty (vm_instance_t * vm) { int i; /* Create Console and AUX ports */ vm->vtty_con[0] = vtty_create (vm, "Console port", vm->vtty_type[0], vm->vtty_tcp_port[0], &vm->vtty_serial_option[0]); for (i=1; ivtty_con[i] = vtty_create (vm, "UART port", vm->vtty_type[i], vm->vtty_tcp_port[i], &vm->vtty_serial_option[i]); return (0); } /* Delete VTTY */ void vm_delete_vtty (vm_instance_t * vm) { int i; for (i=0; ivtty_con[i]); vm->vtty_con[i] = NULL; } } /* Bind a device to a virtual machine */ int vm_bind_device (vm_instance_t * vm, struct vdevice *dev) { struct vdevice **cur; u_int i; /* * Add this device to the device array. The index in the device array * is used by the MTS subsystem. */ for (i = 0; i < VM_DEVICE_MAX; i++) if (!vm->dev_array[i]) break; if (i == VM_DEVICE_MAX) { fprintf (stderr, "VM: vm_bind_device: device table full.\n"); return (-1); } vm->dev_array[i] = dev; dev->id = i; /* * Add it to the linked-list (devices are ordered by physical addresses). */ for (cur = &vm->dev_list; *cur; cur = &(*cur)->next) if ((*cur)->phys_addr > dev->phys_addr) break; dev->next = *cur; if (*cur) (*cur)->pprev = &dev->next; dev->pprev = cur; *cur = dev; return (0); } /* Unbind a device from a virtual machine */ int vm_unbind_device (vm_instance_t * vm, struct vdevice *dev) { u_int i; if (!dev || !dev->pprev) return (-1); /* Remove the device from the linked list */ if (dev->next) dev->next->pprev = dev->pprev; *(dev->pprev) = dev->next; /* Remove the device from the device array */ for (i = 0; i < VM_DEVICE_MAX; i++) if (vm->dev_array[i] == dev) { vm->dev_array[i] = NULL; break; } /* Clear device list info */ dev->next = NULL; dev->pprev = NULL; return (0); } /* Map a device at the specified physical address */ int vm_map_device (vm_instance_t * vm, struct vdevice *dev, m_pa_t base_addr) { #if 0 /* Suspend VM activity */ vm_suspend (vm); if (cpu_group_sync_state (vm->cpu_group) == -1) { fprintf (stderr, "VM%u: unable to sync with system CPUs.\n", vm->instance_id); return (-1); } #endif /* Unbind the device if it was already active */ vm_unbind_device (vm, dev); /* Map the device at the new base address and rebuild MTS */ dev->phys_addr = base_addr; vm_bind_device (vm, dev); cpu_group_rebuild_mts (vm->cpu_group); #if 0 vm_resume (vm); #endif return (0); } /* Suspend a VM instance */ int vm_suspend (vm_instance_t * vm) { if (vm->status == VM_STATUS_RUNNING) { cpu_group_save_state (vm->cpu_group); cpu_group_set_state (vm->cpu_group, CPU_STATE_SUSPENDED); vm->status = VM_STATUS_SUSPENDED; } return (0); } /* Resume a VM instance */ int vm_resume (vm_instance_t * vm) { if (vm->status == VM_STATUS_SUSPENDED) { cpu_group_restore_state (vm->cpu_group); vm->status = VM_STATUS_RUNNING; } return (0); } /* Stop an instance */ int vm_stop (vm_instance_t * vm) { cpu_group_stop_all_cpu (vm->cpu_group); vm->status = VM_STATUS_SHUTDOWN; return (0); } /* Monitor an instance periodically */ void vm_monitor (vm_instance_t * vm) { while (vm->status != VM_STATUS_SHUTDOWN) usleep (1000); } ================================================ FILE: tools/virtualmips/vm.h ================================================ /* * Cisco router simulation platform. * Copyright (c) 2005,2006 Christophe Fillot (cf@utc.fr) * * Virtual machine abstraction. */ /* * Copyright (C) yajin 2008 * * This file is part of the virtualmips distribution. * See LICENSE file for terms of the license. * */ #ifndef __VM_H__ #define __VM_H__ #include #include "cpu.h" #include "dev_vtty.h" #include "system.h" #include "gdb_interface.h" #define VM_PAGE_SHIFT 12 #define VM_PAGE_SIZE (1 << VM_PAGE_SHIFT) #define VM_PAGE_IMASK (VM_PAGE_SIZE - 1) #define VM_PAGE_MASK (~(VM_PAGE_IMASK)) /* Maximum number of devices per VM */ #define VM_DEVICE_MAX (1 << 6) /* VM types */ enum { VM_TYPE_SWARM = 0, VM_TYPE_ADM5120, VM_TYPE_PIC32, VM_TYPE_PAVO, }; /* VM instance status */ enum { VM_STATUS_HALTED = 0, /* VM is halted and no HW resources are used */ VM_STATUS_SHUTDOWN, /* Shutdown procedure engaged */ VM_STATUS_RUNNING, /* VM is running */ VM_STATUS_SUSPENDED, /* VM is suspended */ }; /* VM instance */ struct vm_instance { char *name; int type; int status; /* Instance status */ char *log_file; /* Log filename */ int log_file_enabled; /* Logging enabled */ u_int ram_size; /* RAM size in Mb */ //u_int rom_size; /* ROM size in Mb */ //char *rom_filename; /* ROM filename */ //m_pa_t rom_address; /* ROM phy address */ u_int flash_size; /* FLASH size in Mb */ char *flash_filename; /* FLASH filename */ m_pa_t flash_address; /* FLASH phy address */ u_int flash_type; /* NAND Flash OR NOR FLASH */ u_int boot_method; /* binary or elf */ char *kernel_filename; u_int boot_from; char *configure_filename; FILE *lock_fd, *log_fd; /* Lock/Log file descriptors */ int debug_level; /* Debugging Level */ u_int trace_address; /* Trace this address */ int jit_use; /* CPUs use JIT */ /* Basic hardware: system CPU */ cpu_group_t *cpu_group; cpu_mips_t *boot_cpu; /* Memory mapped devices */ struct vdevice *dev_list; struct vdevice *dev_array[VM_DEVICE_MAX]; /* IRQ routing */ void (*set_irq) (vm_instance_t * vm, u_int irq); void (*clear_irq) (vm_instance_t * vm, u_int irq); /* Console VTTY type and parameters */ #define NVTTY 6 int vtty_type [NVTTY]; int vtty_tcp_port[NVTTY]; vtty_serial_option_t vtty_serial_option[NVTTY]; /* Virtual TTY for Console and AUX ports */ vtty_t *vtty_con [NVTTY]; /* Specific hardware data */ void *hw_data; /* gdb interface */ m_uint32_t gdb_debug, gdb_port; int gdb_interact_sock; //connect socket int gdb_listen_sock; //listen socket int gdb_debug_from_poll; virtual_breakpoint_t *breakpoint_head, *breakpoint_tail; int mipsy_debug_mode; int mipsy_break_nexti; }; char *vm_get_type (vm_instance_t * vm); char *vm_get_platform_type (vm_instance_t * vm); void vm_flog (vm_instance_t * vm, char *module, char *format, va_list ap); void vm_log (vm_instance_t * vm, char *module, char *format, ...); int vm_close_log (vm_instance_t * vm); int vm_create_log (vm_instance_t * vm); void vm_error (vm_instance_t * vm, char *format, ...); vm_instance_t *vm_create (const char *name, int machine_type); void vm_free (vm_instance_t * vm); int vm_ram_init (vm_instance_t * vm, m_pa_t paddr); int vm_init_vtty (vm_instance_t * vm); void vm_delete_vtty (vm_instance_t * vm); int vm_bind_device (vm_instance_t * vm, struct vdevice *dev); int vm_unbind_device (vm_instance_t * vm, struct vdevice *dev); int vm_map_device (vm_instance_t * vm, struct vdevice *dev, m_pa_t base_addr); int vm_suspend (vm_instance_t * vm); int vm_resume (vm_instance_t * vm); int vm_stop (vm_instance_t * vm); void vm_monitor (vm_instance_t * vm); #endif ================================================ FILE: tools/virtualmips/vp_clock.c ================================================ /* * Copyright (C) yajin 2008 * * This file is part of the virtualmips distribution. * See LICENSE file for terms of the license. * */ #include #include #include "utils.h" #include "vp_clock.h" static int use_rt_clock; vp_clock_t *rt_clock; vp_clock_t *vm_clock; void init_get_clock (void) { use_rt_clock = 0; #if defined(__linux__) { struct timespec ts; if (clock_gettime (CLOCK_MONOTONIC, &ts) == 0) { use_rt_clock = 1; } } #endif } /*ns*/ static m_int64_t get_clock (void) { #if defined(__linux__) if (use_rt_clock) { struct timespec ts; clock_gettime (CLOCK_MONOTONIC, &ts); return ts.tv_sec * 1000000000LL + ts.tv_nsec; } else #endif { /* XXX: using gettimeofday leads to problems if the date * changes, so it should be avoided. */ struct timeval tv; gettimeofday (&tv, NULL); return tv.tv_sec * 1000000000LL + (tv.tv_usec * 1000); } } /*ms*/ m_int64_t vp_get_clock (vp_clock_t * clock) { switch (clock->type) { case VP_TIMER_REALTIME: return get_clock () / 1000000; default: case VP_TIMER_VIRTUAL: ASSERT (0, "not support yet\n"); } return 0; } vp_clock_t *vp_new_clock (int type) { vp_clock_t *clock; clock = malloc (sizeof (vp_clock_t)); memset (clock, 0x0, sizeof (*clock)); if (!clock) return NULL; clock->type = type; return clock; } ================================================ FILE: tools/virtualmips/vp_clock.h ================================================ /* * Copyright (C) yajin 2008 * * This file is part of the virtualmips distribution. * See LICENSE file for terms of the license. * */ #ifndef __VP_CLOCK_H__ #define __VP_CLOCK_H__ #include "utils.h" /*clock utils from qemu*/ #define VP_TIMER_REALTIME 0 #define VP_TIMER_VIRTUAL 1 struct vp_clock { int type; /* XXX: add frequency */ }; typedef struct vp_clock vp_clock_t; extern vp_clock_t *rt_clock; extern vp_clock_t *vm_clock; void init_get_clock (void); vp_clock_t *vp_new_clock (int type); m_int64_t vp_get_clock (vp_clock_t * clock); #endif ================================================ FILE: tools/virtualmips/vp_lock.h ================================================ /* * Copyright (C) yajin 2008 * * This file is part of the virtualmips distribution. * See LICENSE file for terms of the license. * */ #ifndef __VP_LOCK_H__ #define __VP_LOCK_H__ /*testandset from QEMU*/ #ifdef __i386__ static inline int testandset (int *p) { long int readval = 0; __asm__ __volatile__ ("lock; cmpxchgl %2, %0":"+m" (*p), "+a" (readval):"r" (1):"cc"); return readval; } #endif #ifdef __x86_64__ static inline int testandset (int *p) { long int readval = 0; __asm__ __volatile__ ("lock; cmpxchgl %2, %0":"+m" (*p), "+a" (readval):"r" (1):"cc"); return readval; } #endif #ifdef __ia64 #include static inline int testandset (int *p) { return __sync_lock_test_and_set (p, 1); } #endif #endif ================================================ FILE: tools/virtualmips/vp_sdl.c ================================================ /* * Copyright (C) yajin 2008 * * This file is part of the virtualmips distribution. * See LICENSE file for terms of the license. * */ #ifdef SIM_LCD #include "vp_sdl.h" #include SDL_Surface *screen; SDL_Event ev; static void sdl_update (DisplayState * ds, int x, int y, int w, int h) { SDL_UpdateRect (screen, x, y, w, h); } static void sdl_resize (DisplayState * ds, int w, int h) { int flags; // printf("resizing to %d %d\n", w, h); flags = SDL_HWSURFACE | SDL_ASYNCBLIT | SDL_HWACCEL; again: screen = SDL_SetVideoMode (w, h, ds->depth, flags); if (!screen) { fprintf (stderr, "Could not open SDL display\n"); exit (1); } if (!screen->pixels && (flags & SDL_HWSURFACE) && (flags & SDL_FULLSCREEN)) { flags &= ~SDL_HWSURFACE; goto again; } if (!screen->pixels) { fprintf (stderr, "Could not open SDL display\n"); exit (1); } ds->data = screen->pixels; ds->linesize = screen->pitch; //ds->depth = screen->format->BitsPerPixel; if (ds->depth == 32 && screen->format->Rshift == 0) { ds->bgr = 1; } else { ds->bgr = 0; } } SDL_Event *sdl_getmouse_down () { if (SDL_PollEvent (&ev)) { if (ev.type == SDL_MOUSEBUTTONDOWN) { return &ev; } } return NULL; } SDL_Event *sdl_getmouse_up () { if (SDL_PollEvent (&ev)) { if (ev.type == SDL_MOUSEBUTTONUP) { return &ev; } } return NULL; } static void sdl_refresh (DisplayState * ds) { } static void sdl_update_caption (void) { char buf[1024]; strlcpy (buf, "VirtualMIPS", sizeof(buf)); SDL_WM_SetCaption (buf, ""); } /* loading VirtualMIPS logo. A bit ugly logo. Sorry CNN, I have not learned how to ps pictures. Please forgive me. */ static void sdl_display_logo (void) { SDL_Surface *image; SDL_Rect dest; image = SDL_LoadBMP ("logo.bmp"); if (image == NULL) { fprintf (stderr, "can not load logo logo.bmp: %s\n", SDL_GetError ()); return; } dest.x = 0; dest.y = 0; dest.w = image->w; dest.h = image->h; SDL_BlitSurface (image, NULL, screen, &dest); SDL_UpdateRects (screen, 1, &dest); } static void sdl_cleanup (void) { printf ("SDL Clean \n"); SDL_Quit (); } void sdl_display_init (DisplayState * ds, int full_screen) { int flags; flags = SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE; if (SDL_Init (flags)) { fprintf (stderr, "Could not initialize SDL - exiting\n"); exit (1); } #ifndef _WIN32 signal (SIGINT, SIG_DFL); signal (SIGQUIT, SIG_DFL); #endif ds->dpy_update = sdl_update; ds->dpy_resize = sdl_resize; ds->dpy_refresh = sdl_refresh; sdl_resize (ds, ds->width, ds->height); sdl_update_caption (); sdl_display_logo (); SDL_EnableUNICODE (1); atexit (sdl_cleanup); } #endif ================================================ FILE: tools/virtualmips/vp_sdl.h ================================================ /* * Copyright (C) yajin 2008 * * This file is part of the virtualmips distribution. * See LICENSE file for terms of the license. * */ #ifndef __VSDL_H__ #define __VSDL_H__ #ifdef SIM_LCD /*defined in Makefile */ #include "utils.h" #include "SDL/SDL.h" struct DisplayState { uint8_t *data; int linesize; int depth; int bgr; /* BGR color order instead of RGB. Only valid for depth == 32 */ int width; int height; void *opaque; void (*dpy_update) (struct DisplayState * s, int x, int y, int w, int h); void (*dpy_resize) (struct DisplayState * s, int w, int h); void (*dpy_refresh) (struct DisplayState * s); void (*dpy_copy) (struct DisplayState * s, int src_x, int src_y, int dst_x, int dst_y, int w, int h); }; typedef struct DisplayState DisplayState; static inline void dpy_update (DisplayState * s, int x, int y, int w, int h) { s->dpy_update (s, x, y, w, h); } static inline void dpy_resize (DisplayState * s, int w, int h) { s->dpy_resize (s, w, h); } /* static inline void draw_pixel(SDL_Surface *screen, Uint8 R, Uint8 G, Uint8 B,Uint32 x,Uint32 y) { Uint32 color = SDL_MapRGB(screen->format, R, G, B); switch (screen->format->BytesPerPixel) { case 1: { Uint8 *bufp; bufp = (Uint8 *)screen->pixels + y*screen->pitch + x; *bufp = color; } break; case 2: { Uint16 *bufp; bufp = (Uint16 *)screen->pixels + y*screen->pitch/2 + x; *bufp = color; } break; case 3: { Uint8 *bufp; bufp = (Uint8 *)screen->pixels + y*screen->pitch + x; *(bufp+screen->format->Rshift/8) = R; *(bufp+screen->format->Gshift/8) = G; *(bufp+screen->format->Bshift/8) = B; } break; case 4: { Uint32 *bufp; bufp = (Uint32 *)screen->pixels + y*screen->pitch/4 + x; *bufp = color; } break; } } */ void sdl_display_init (DisplayState * ds, int full_screen); SDL_Event *sdl_getmouse_down (); SDL_Event *sdl_getmouse_up (); #endif #endif ================================================ FILE: tools/virtualmips/vp_timer.c ================================================ /* * Copyright (C) yajin 2008 * * This file is part of the virtualmips distribution. * See LICENSE file for terms of the license. * */ /* Timer routine. Emulator has many timers. Every 1ms, emulator will check whether there is timer request and pause the cpu when processing timer event. Codes are from qemu. yajin */ #include #include #include "vp_timer.h" #include "vp_clock.h" vp_timer_t *active_timers[2]; m_int64_t ticks_per_sec; vp_timer_t *vp_new_timer (vp_clock_t * clock, vp_timer_cb * cb, void *opaque) { vp_timer_t *ts; ts = malloc (sizeof (vp_timer_t)); memset (ts, 0x0, sizeof (*ts)); if (ts == NULL) return NULL; ts->clock = clock; ts->cb = cb; ts->opaque = opaque; return ts; } void vp_free_timer (vp_timer_t * ts) { ASSERT (ts != NULL, "ts==NULL. NULL can not be freed\n"); free (ts); } /* stop a timer, but do not dealloc it */ void vp_del_timer (vp_timer_t * ts) { vp_timer_t **pt, *t; /* NOTE: this code must be signal safe because * qemu_timer_expired() can be called from a signal. */ pt = &active_timers[ts->clock->type]; for (;;) { t = *pt; if (!t) break; if (t == ts) { *pt = t->next; break; } pt = &t->next; } } /* modify the current timer so that it will be fired when current_time >= expire_time. The corresponding callback will be called. */ void vp_mod_timer (vp_timer_t * ts, m_int64_t expire_time) { vp_timer_t **pt, *t; vp_del_timer (ts); /* add the timer in the sorted list */ /* NOTE: this code must be signal safe because * qemu_timer_expired() can be called from a signal. */ pt = &active_timers[ts->clock->type]; for (;;) { t = *pt; if (!t) break; if (t->expire_time > expire_time) break; pt = &t->next; } ts->expire_time = expire_time; ts->next = *pt; *pt = ts; } int vp_timer_pending (vp_timer_t * ts) { vp_timer_t *t; for (t = active_timers[ts->clock->type]; t != NULL; t = t->next) { if (t == ts) return 1; } return 0; } inline int vp_timer_expired (vp_timer_t * timer_head, m_int64_t current_time) { if (!timer_head) return 0; return (timer_head->expire_time <= current_time); } void vp_run_timers (vp_timer_t ** ptimer_head, m_int64_t current_time) { vp_timer_t *ts; for (;;) { ts = *ptimer_head; if (!ts || ts->expire_time > current_time) break; /* remove timer from the list before calling the callback */ *ptimer_head = ts->next; ts->next = NULL; /* run the callback (the timer list can be modified) */ ts->cb (ts->opaque); } } void init_timers (void) { init_get_clock (); ticks_per_sec = VP_TIMER_BASE; rt_clock = vp_new_clock (VP_TIMER_REALTIME); vm_clock = vp_new_clock (VP_TIMER_VIRTUAL); } ================================================ FILE: tools/virtualmips/vp_timer.h ================================================ /* * Copyright (C) yajin 2008 * * This file is part of the virtualmips distribution. * See LICENSE file for terms of the license. * */ #ifndef __VP_TIMER_H__ #define __VP_TIMER_H__ #include "vp_clock.h" #include "utils.h" #define VP_TIMER_BASE 1000000000LL typedef void vp_timer_cb (void *opaque); struct vp_timer { vp_clock_t *clock; m_int64_t expire_time; m_int64_t set_time; vp_timer_cb *cb; void *opaque; struct vp_timer *next; }; typedef struct vp_timer vp_timer_t; extern vp_timer_t *active_timers[2]; vp_timer_t *vp_new_timer (vp_clock_t * clock, vp_timer_cb * cb, void *opaque); void vp_free_timer (vp_timer_t * ts); void vp_mod_timer (vp_timer_t * ts, m_int64_t expire_time); void vp_del_timer (vp_timer_t * ts); int vp_timer_pending (vp_timer_t * ts); int vp_timer_expired (vp_timer_t * timer_head, m_int64_t current_time); void vp_run_timers (vp_timer_t ** ptimer_head, m_int64_t current_time); void init_timers (void); #endif ================================================ FILE: tools/virtualmips/x86-codegen.h ================================================ /* * x86-codegen.h: Macros for generating x86 code * * Authors: * Paolo Molaro (lupus@ximian.com) * Intel Corporation (ORP Project) * Sergey Chaban (serge@wildwestsoftware.com) * Dietmar Maurer (dietmar@ximian.com) * Patrik Torstensson * * Copyright (C) 2000 Intel Corporation. All rights reserved. * Copyright (C) 2001, 2002 Ximian, Inc. */ #ifndef X86_H #define X86_H #include /* // x86 register numbers */ typedef enum { X86_EAX = 0, X86_ECX = 1, X86_EDX = 2, X86_EBX = 3, X86_ESP = 4, X86_EBP = 5, X86_ESI = 6, X86_EDI = 7, X86_NREG } X86_Reg_No; /* // opcodes for alu instructions */ typedef enum { X86_ADD = 0, X86_OR = 1, X86_ADC = 2, X86_SBB = 3, X86_AND = 4, X86_SUB = 5, X86_XOR = 6, X86_CMP = 7, X86_NALU } X86_ALU_Opcode; /* // opcodes for shift instructions */ typedef enum { X86_SHLD, X86_SHLR, X86_ROL = 0, X86_ROR = 1, X86_RCL = 2, X86_RCR = 3, X86_SHL = 4, X86_SHR = 5, X86_SAR = 7, X86_NSHIFT = 8 } X86_Shift_Opcode; /* // opcodes for floating-point instructions */ typedef enum { X86_FADD = 0, X86_FMUL = 1, X86_FCOM = 2, X86_FCOMP = 3, X86_FSUB = 4, X86_FSUBR = 5, X86_FDIV = 6, X86_FDIVR = 7, X86_NFP = 8 } X86_FP_Opcode; /* // integer conditions codes */ typedef enum { X86_CC_EQ = 0, X86_CC_E = 0, X86_CC_Z = 0, X86_CC_NE = 1, X86_CC_NZ = 1, X86_CC_LT = 2, X86_CC_B = 2, X86_CC_C = 2, X86_CC_NAE = 2, X86_CC_LE = 3, X86_CC_BE = 3, X86_CC_NA = 3, X86_CC_GT = 4, X86_CC_A = 4, X86_CC_NBE = 4, X86_CC_GE = 5, X86_CC_AE = 5, X86_CC_NB = 5, X86_CC_NC = 5, X86_CC_LZ = 6, X86_CC_S = 6, X86_CC_GEZ = 7, X86_CC_NS = 7, X86_CC_P = 8, X86_CC_PE = 8, X86_CC_NP = 9, X86_CC_PO = 9, X86_CC_O = 10, X86_CC_NO = 11, X86_NCC } X86_CC; /* FP status */ enum { X86_FP_C0 = 0x100, X86_FP_C1 = 0x200, X86_FP_C2 = 0x400, X86_FP_C3 = 0x4000, X86_FP_CC_MASK = 0x4500 }; /* FP control word */ enum { X86_FPCW_INVOPEX_MASK = 0x1, X86_FPCW_DENOPEX_MASK = 0x2, X86_FPCW_ZERODIV_MASK = 0x4, X86_FPCW_OVFEX_MASK = 0x8, X86_FPCW_UNDFEX_MASK = 0x10, X86_FPCW_PRECEX_MASK = 0x20, X86_FPCW_PRECC_MASK = 0x300, X86_FPCW_ROUNDC_MASK = 0xc00, /* values for precision control */ X86_FPCW_PREC_SINGLE = 0, X86_FPCW_PREC_DOUBLE = 0x200, X86_FPCW_PREC_EXTENDED = 0x300, /* values for rounding control */ X86_FPCW_ROUND_NEAREST = 0, X86_FPCW_ROUND_DOWN = 0x400, X86_FPCW_ROUND_UP = 0x800, X86_FPCW_ROUND_TOZERO = 0xc00 }; /* // prefix code */ typedef enum { X86_LOCK_PREFIX = 0xF0, X86_REPNZ_PREFIX = 0xF2, X86_REPZ_PREFIX = 0xF3, X86_REP_PREFIX = 0xF3, X86_CS_PREFIX = 0x2E, X86_SS_PREFIX = 0x36, X86_DS_PREFIX = 0x3E, X86_ES_PREFIX = 0x26, X86_FS_PREFIX = 0x64, X86_GS_PREFIX = 0x65, X86_UNLIKELY_PREFIX = 0x2E, X86_LIKELY_PREFIX = 0x3E, X86_OPERAND_PREFIX = 0x66, X86_ADDRESS_PREFIX = 0x67 } X86_Prefix; static const unsigned char x86_cc_unsigned_map[X86_NCC] = { 0x74, /* eq */ 0x75, /* ne */ 0x72, /* lt */ 0x76, /* le */ 0x77, /* gt */ 0x73, /* ge */ 0x78, /* lz */ 0x79, /* gez */ 0x7a, /* p */ 0x7b, /* np */ 0x70, /* o */ 0x71, /* no */ }; static const unsigned char x86_cc_signed_map[X86_NCC] = { 0x74, /* eq */ 0x75, /* ne */ 0x7c, /* lt */ 0x7e, /* le */ 0x7f, /* gt */ 0x7d, /* ge */ 0x78, /* lz */ 0x79, /* gez */ 0x7a, /* p */ 0x7b, /* np */ 0x70, /* o */ 0x71, /* no */ }; typedef union { int val; unsigned char b[4]; } x86_imm_buf; #define X86_NOBASEREG (-1) /* // bitvector mask for callee-saved registers */ #define X86_ESI_MASK (1<> 6) #define x86_modrm_reg(modrm) (((modrm) >> 3) & 0x7) #define x86_modrm_rm(modrm) ((modrm) & 0x7) #define x86_address_byte(inst,m,o,r) do { *(inst)++ = ((((m)&0x03)<<6)|(((o)&0x07)<<3)|(((r)&0x07))); } while (0) #define x86_imm_emit32(inst,imm) \ do { \ x86_imm_buf imb; imb.val = (int) (imm); \ *(inst)++ = imb.b [0]; \ *(inst)++ = imb.b [1]; \ *(inst)++ = imb.b [2]; \ *(inst)++ = imb.b [3]; \ } while (0) #define x86_imm_emit16(inst,imm) do { *(short*)(inst) = (imm); (inst) += 2; } while (0) #define x86_imm_emit8(inst,imm) do { *(inst) = (unsigned char)((imm) & 0xff); ++(inst); } while (0) #define x86_is_imm8(imm) (((int)(imm) >= -128 && (int)(imm) <= 127)) #define x86_is_imm16(imm) (((int)(imm) >= -(1<<16) && (int)(imm) <= ((1<<16)-1))) #define x86_reg_emit(inst,r,regno) do { x86_address_byte ((inst), 3, (r), (regno)); } while (0) #define x86_reg8_emit(inst,r,regno,is_rh,is_rnoh) do {x86_address_byte ((inst), 3, (is_rh)?((r)|4):(r), (is_rnoh)?((regno)|4):(regno));} while (0) #define x86_regp_emit(inst,r,regno) do { x86_address_byte ((inst), 0, (r), (regno)); } while (0) #define x86_mem_emit(inst,r,disp) do { x86_address_byte ((inst), 0, (r), 5); x86_imm_emit32((inst), (disp)); } while (0) #define x86_membase_emit(inst,r,basereg,disp) do {\ if ((basereg) == X86_ESP) { \ if ((disp) == 0) { \ x86_address_byte ((inst), 0, (r), X86_ESP); \ x86_address_byte ((inst), 0, X86_ESP, X86_ESP); \ } else if (x86_is_imm8((disp))) { \ x86_address_byte ((inst), 1, (r), X86_ESP); \ x86_address_byte ((inst), 0, X86_ESP, X86_ESP); \ x86_imm_emit8 ((inst), (disp)); \ } else { \ x86_address_byte ((inst), 2, (r), X86_ESP); \ x86_address_byte ((inst), 0, X86_ESP, X86_ESP); \ x86_imm_emit32 ((inst), (disp)); \ } \ break; \ } \ if ((disp) == 0 && (basereg) != X86_EBP) { \ x86_address_byte ((inst), 0, (r), (basereg)); \ break; \ } \ if (x86_is_imm8((disp))) { \ x86_address_byte ((inst), 1, (r), (basereg)); \ x86_imm_emit8 ((inst), (disp)); \ } else { \ x86_address_byte ((inst), 2, (r), (basereg)); \ x86_imm_emit32 ((inst), (disp)); \ } \ } while (0) #define x86_memindex_emit(inst,r,basereg,disp,indexreg,shift) \ do { \ if ((basereg) == X86_NOBASEREG) { \ x86_address_byte ((inst), 0, (r), 4); \ x86_address_byte ((inst), (shift), (indexreg), 5); \ x86_imm_emit32 ((inst), (disp)); \ } else if ((disp) == 0 && (basereg) != X86_EBP) { \ x86_address_byte ((inst), 0, (r), 4); \ x86_address_byte ((inst), (shift), (indexreg), (basereg)); \ } else if (x86_is_imm8((disp))) { \ x86_address_byte ((inst), 1, (r), 4); \ x86_address_byte ((inst), (shift), (indexreg), (basereg)); \ x86_imm_emit8 ((inst), (disp)); \ } else { \ x86_address_byte ((inst), 2, (r), 4); \ x86_address_byte ((inst), (shift), (indexreg), 5); \ x86_imm_emit32 ((inst), (disp)); \ } \ } while (0) /* * target is the position in the code where to jump to: * target = code; * .. output loop code... * x86_mov_reg_imm (code, X86_EAX, 0); * loop = code; * x86_loop (code, -1); * ... finish method * * patch displacement * x86_patch (loop, target); * * ins should point at the start of the instruction that encodes a target. * the instruction is inspected for validity and the correct displacement * is inserted. */ #define x86_patch(ins,target) \ do { \ unsigned char* pos = (ins) + 1; \ int disp, size = 0; \ switch (*(unsigned char*)(ins)) { \ case 0xe8: case 0xe9: ++size; break; /* call, jump32 */ \ case 0x0f: if (!(*pos >= 0x70 && *pos <= 0x8f)) assert (0); \ ++size; ++pos; break; /* prefix for 32-bit disp */ \ case 0xe0: case 0xe1: case 0xe2: /* loop */ \ case 0xeb: /* jump8 */ \ /* conditional jump opcodes */ \ case 0x70: case 0x71: case 0x72: case 0x73: \ case 0x74: case 0x75: case 0x76: case 0x77: \ case 0x78: case 0x79: case 0x7a: case 0x7b: \ case 0x7c: case 0x7d: case 0x7e: case 0x7f: \ break; \ default: assert (0); \ } \ disp = (target) - pos; \ if (size) x86_imm_emit32 (pos, disp - 4); \ else if (x86_is_imm8 (disp - 1)) x86_imm_emit8 (pos, disp - 1); \ else assert (0); \ } while (0) #define x86_breakpoint(inst) \ do { \ *(inst)++ = 0xcc; \ } while (0) #define x86_clc(inst) do { *(inst)++ =(unsigned char)0xf8; } while (0) #define x86_cld(inst) do { *(inst)++ =(unsigned char)0xfc; } while (0) #define x86_stosb(inst) do { *(inst)++ =(unsigned char)0xaa; } while (0) #define x86_stosl(inst) do { *(inst)++ =(unsigned char)0xab; } while (0) #define x86_stosd(inst) x86_stosl((inst)) #define x86_movsb(inst) do { *(inst)++ =(unsigned char)0xa4; } while (0) #define x86_movsl(inst) do { *(inst)++ =(unsigned char)0xa5; } while (0) #define x86_movsd(inst) x86_movsl((inst)) #define x86_prefix(inst,p) do { *(inst)++ =(unsigned char) (p); } while (0) #define x86_bswap(inst,reg) \ do { \ *(inst)++ = 0x0f; \ *(inst)++ = (unsigned char)0xc8 + (reg); \ } while (0) #define x86_rdtsc(inst) \ do { \ *(inst)++ = 0x0f; \ *(inst)++ = 0x31; \ } while (0) #define x86_cmpxchg_reg_reg(inst,dreg,reg) \ do { \ *(inst)++ = (unsigned char)0x0f; \ *(inst)++ = (unsigned char)0xb1; \ x86_reg_emit ((inst), (reg), (dreg)); \ } while (0) #define x86_cmpxchg_mem_reg(inst,mem,reg) \ do { \ *(inst)++ = (unsigned char)0x0f; \ *(inst)++ = (unsigned char)0xb1; \ x86_mem_emit ((inst), (reg), (mem)); \ } while (0) #define x86_cmpxchg_membase_reg(inst,basereg,disp,reg) \ do { \ *(inst)++ = (unsigned char)0x0f; \ *(inst)++ = (unsigned char)0xb1; \ x86_membase_emit ((inst), (reg), (basereg), (disp)); \ } while (0) #define x86_xchg_reg_reg(inst,dreg,reg,size) \ do { \ if ((size) == 1) \ *(inst)++ = (unsigned char)0x86; \ else \ *(inst)++ = (unsigned char)0x87; \ x86_reg_emit ((inst), (reg), (dreg)); \ } while (0) #define x86_xchg_mem_reg(inst,mem,reg,size) \ do { \ if ((size) == 1) \ *(inst)++ = (unsigned char)0x86; \ else \ *(inst)++ = (unsigned char)0x87; \ x86_mem_emit ((inst), (reg), (mem)); \ } while (0) #define x86_xchg_membase_reg(inst,basereg,disp,reg,size) \ do { \ if ((size) == 1) \ *(inst)++ = (unsigned char)0x86; \ else \ *(inst)++ = (unsigned char)0x87; \ x86_membase_emit ((inst), (reg), (basereg), (disp)); \ } while (0) #define x86_xadd_reg_reg(inst,dreg,reg,size) \ do { \ *(inst)++ = (unsigned char)0x0F; \ if ((size) == 1) \ *(inst)++ = (unsigned char)0xC0; \ else \ *(inst)++ = (unsigned char)0xC1; \ x86_reg_emit ((inst), (reg), (dreg)); \ } while (0) #define x86_xadd_mem_reg(inst,mem,reg,size) \ do { \ *(inst)++ = (unsigned char)0x0F; \ if ((size) == 1) \ *(inst)++ = (unsigned char)0xC0; \ else \ *(inst)++ = (unsigned char)0xC1; \ x86_mem_emit ((inst), (reg), (mem)); \ } while (0) #define x86_xadd_membase_reg(inst,basereg,disp,reg,size) \ do { \ *(inst)++ = (unsigned char)0x0F; \ if ((size) == 1) \ *(inst)++ = (unsigned char)0xC0; \ else \ *(inst)++ = (unsigned char)0xC1; \ x86_membase_emit ((inst), (reg), (basereg), (disp)); \ } while (0) #define x86_inc_mem(inst,mem) \ do { \ *(inst)++ = (unsigned char)0xff; \ x86_mem_emit ((inst), 0, (mem)); \ } while (0) #define x86_inc_membase(inst,basereg,disp) \ do { \ *(inst)++ = (unsigned char)0xff; \ x86_membase_emit ((inst), 0, (basereg), (disp)); \ } while (0) #define x86_inc_reg(inst,reg) do { *(inst)++ = (unsigned char)0x40 + (reg); } while (0) #define x86_dec_mem(inst,mem) \ do { \ *(inst)++ = (unsigned char)0xff; \ x86_mem_emit ((inst), 1, (mem)); \ } while (0) #define x86_dec_membase(inst,basereg,disp) \ do { \ *(inst)++ = (unsigned char)0xff; \ x86_membase_emit ((inst), 1, (basereg), (disp)); \ } while (0) #define x86_dec_reg(inst,reg) do { *(inst)++ = (unsigned char)0x48 + (reg); } while (0) #define x86_not_mem(inst,mem) \ do { \ *(inst)++ = (unsigned char)0xf7; \ x86_mem_emit ((inst), 2, (mem)); \ } while (0) #define x86_not_membase(inst,basereg,disp) \ do { \ *(inst)++ = (unsigned char)0xf7; \ x86_membase_emit ((inst), 2, (basereg), (disp)); \ } while (0) #define x86_not_reg(inst,reg) \ do { \ *(inst)++ = (unsigned char)0xf7; \ x86_reg_emit ((inst), 2, (reg)); \ } while (0) #define x86_neg_mem(inst,mem) \ do { \ *(inst)++ = (unsigned char)0xf7; \ x86_mem_emit ((inst), 3, (mem)); \ } while (0) #define x86_neg_membase(inst,basereg,disp) \ do { \ *(inst)++ = (unsigned char)0xf7; \ x86_membase_emit ((inst), 3, (basereg), (disp)); \ } while (0) #define x86_neg_reg(inst,reg) \ do { \ *(inst)++ = (unsigned char)0xf7; \ x86_reg_emit ((inst), 3, (reg)); \ } while (0) #define x86_nop(inst) do { *(inst)++ = (unsigned char)0x90; } while (0) #define x86_alu_reg_imm(inst,opc,reg,imm) \ do { \ if ((reg) == X86_EAX) { \ *(inst)++ = (((unsigned char)(opc)) << 3) + 5; \ x86_imm_emit32 ((inst), (imm)); \ break; \ } \ if (x86_is_imm8((imm))) { \ *(inst)++ = (unsigned char)0x83; \ x86_reg_emit ((inst), (opc), (reg)); \ x86_imm_emit8 ((inst), (imm)); \ } else { \ *(inst)++ = (unsigned char)0x81; \ x86_reg_emit ((inst), (opc), (reg)); \ x86_imm_emit32 ((inst), (imm)); \ } \ } while (0) #define x86_alu_mem_imm(inst,opc,mem,imm) \ do { \ if (x86_is_imm8((imm))) { \ *(inst)++ = (unsigned char)0x83; \ x86_mem_emit ((inst), (opc), (mem)); \ x86_imm_emit8 ((inst), (imm)); \ } else { \ *(inst)++ = (unsigned char)0x81; \ x86_mem_emit ((inst), (opc), (mem)); \ x86_imm_emit32 ((inst), (imm)); \ } \ } while (0) #define x86_alu_membase_imm(inst,opc,basereg,disp,imm) \ do { \ if (x86_is_imm8((imm))) { \ *(inst)++ = (unsigned char)0x83; \ x86_membase_emit ((inst), (opc), (basereg), (disp)); \ x86_imm_emit8 ((inst), (imm)); \ } else { \ *(inst)++ = (unsigned char)0x81; \ x86_membase_emit ((inst), (opc), (basereg), (disp)); \ x86_imm_emit32 ((inst), (imm)); \ } \ } while (0) #define x86_alu_membase8_imm(inst,opc,basereg,disp,imm) \ do { \ *(inst)++ = (unsigned char)0x80; \ x86_membase_emit ((inst), (opc), (basereg), (disp)); \ x86_imm_emit8 ((inst), (imm)); \ } while (0) #define x86_alu_mem_reg(inst,opc,mem,reg) \ do { \ *(inst)++ = (((unsigned char)(opc)) << 3) + 1; \ x86_mem_emit ((inst), (reg), (mem)); \ } while (0) #define x86_alu_membase_reg(inst,opc,basereg,disp,reg) \ do { \ *(inst)++ = (((unsigned char)(opc)) << 3) + 1; \ x86_membase_emit ((inst), (reg), (basereg), (disp)); \ } while (0) #define x86_alu_reg_reg(inst,opc,dreg,reg) \ do { \ *(inst)++ = (((unsigned char)(opc)) << 3) + 3; \ x86_reg_emit ((inst), (dreg), (reg)); \ } while (0) /** * @x86_alu_reg8_reg8: * Supports ALU operations between two 8-bit registers. * dreg := dreg opc reg * X86_Reg_No enum is used to specify the registers. * Additionally is_*_h flags are used to specify what part * of a given 32-bit register is used - high (TRUE) or low (FALSE). * For example: dreg = X86_EAX, is_dreg_h = TRUE -> use AH */ #define x86_alu_reg8_reg8(inst,opc,dreg,reg,is_dreg_h,is_reg_h) \ do { \ *(inst)++ = (((unsigned char)(opc)) << 3) + 2; \ x86_reg8_emit ((inst), (dreg), (reg), (is_dreg_h), (is_reg_h)); \ } while (0) #define x86_alu_reg_mem(inst,opc,reg,mem) \ do { \ *(inst)++ = (((unsigned char)(opc)) << 3) + 3; \ x86_mem_emit ((inst), (reg), (mem)); \ } while (0) #define x86_alu_reg_membase(inst,opc,reg,basereg,disp) \ do { \ *(inst)++ = (((unsigned char)(opc)) << 3) + 3; \ x86_membase_emit ((inst), (reg), (basereg), (disp)); \ } while (0) #define x86_test_reg_imm(inst,reg,imm) \ do { \ if ((reg) == X86_EAX) { \ *(inst)++ = (unsigned char)0xa9; \ } else { \ *(inst)++ = (unsigned char)0xf7; \ x86_reg_emit ((inst), 0, (reg)); \ } \ x86_imm_emit32 ((inst), (imm)); \ } while (0) #define x86_test_mem_imm(inst,mem,imm) \ do { \ *(inst)++ = (unsigned char)0xf7; \ x86_mem_emit ((inst), 0, (mem)); \ x86_imm_emit32 ((inst), (imm)); \ } while (0) #define x86_test_membase_imm(inst,basereg,disp,imm) \ do { \ *(inst)++ = (unsigned char)0xf7; \ x86_membase_emit ((inst), 0, (basereg), (disp)); \ x86_imm_emit32 ((inst), (imm)); \ } while (0) #define x86_test_reg_reg(inst,dreg,reg) \ do { \ *(inst)++ = (unsigned char)0x85; \ x86_reg_emit ((inst), (reg), (dreg)); \ } while (0) #define x86_test_mem_reg(inst,mem,reg) \ do { \ *(inst)++ = (unsigned char)0x85; \ x86_mem_emit ((inst), (reg), (mem)); \ } while (0) #define x86_test_membase_reg(inst,basereg,disp,reg) \ do { \ *(inst)++ = (unsigned char)0x85; \ x86_membase_emit ((inst), (reg), (basereg), (disp)); \ } while (0) #define x86_shift_reg_imm(inst,opc,reg,imm) \ do { \ if ((imm) == 1) { \ *(inst)++ = (unsigned char)0xd1; \ x86_reg_emit ((inst), (opc), (reg)); \ } else { \ *(inst)++ = (unsigned char)0xc1; \ x86_reg_emit ((inst), (opc), (reg)); \ x86_imm_emit8 ((inst), (imm)); \ } \ } while (0) #define x86_shift_mem_imm(inst,opc,mem,imm) \ do { \ if ((imm) == 1) { \ *(inst)++ = (unsigned char)0xd1; \ x86_mem_emit ((inst), (opc), (mem)); \ } else { \ *(inst)++ = (unsigned char)0xc1; \ x86_mem_emit ((inst), (opc), (mem)); \ x86_imm_emit8 ((inst), (imm)); \ } \ } while (0) #define x86_shift_membase_imm(inst,opc,basereg,disp,imm) \ do { \ if ((imm) == 1) { \ *(inst)++ = (unsigned char)0xd1; \ x86_membase_emit ((inst), (opc), (basereg), (disp)); \ } else { \ *(inst)++ = (unsigned char)0xc1; \ x86_membase_emit ((inst), (opc), (basereg), (disp)); \ x86_imm_emit8 ((inst), (imm)); \ } \ } while (0) #define x86_shift_reg(inst,opc,reg) \ do { \ *(inst)++ = (unsigned char)0xd3; \ x86_reg_emit ((inst), (opc), (reg)); \ } while (0) #define x86_shift_mem(inst,opc,mem) \ do { \ *(inst)++ = (unsigned char)0xd3; \ x86_mem_emit ((inst), (opc), (mem)); \ } while (0) #define x86_shift_membase(inst,opc,basereg,disp) \ do { \ *(inst)++ = (unsigned char)0xd3; \ x86_membase_emit ((inst), (opc), (basereg), (disp)); \ } while (0) /* * Multi op shift missing. */ #define x86_shrd_reg(inst,dreg,reg) \ do { \ *(inst)++ = (unsigned char)0x0f; \ *(inst)++ = (unsigned char)0xad; \ x86_reg_emit ((inst), (reg), (dreg)); \ } while (0) #define x86_shrd_reg_imm(inst,dreg,reg,shamt) \ do { \ *(inst)++ = (unsigned char)0x0f; \ *(inst)++ = (unsigned char)0xac; \ x86_reg_emit ((inst), (reg), (dreg)); \ x86_imm_emit8 ((inst), (shamt)); \ } while (0) #define x86_shld_reg(inst,dreg,reg) \ do { \ *(inst)++ = (unsigned char)0x0f; \ *(inst)++ = (unsigned char)0xa5; \ x86_reg_emit ((inst), (reg), (dreg)); \ } while (0) #define x86_shld_reg_imm(inst,dreg,reg,shamt) \ do { \ *(inst)++ = (unsigned char)0x0f; \ *(inst)++ = (unsigned char)0xa4; \ x86_reg_emit ((inst), (reg), (dreg)); \ x86_imm_emit8 ((inst), (shamt)); \ } while (0) /* * EDX:EAX = EAX * rm */ #define x86_mul_reg(inst,reg,is_signed) \ do { \ *(inst)++ = (unsigned char)0xf7; \ x86_reg_emit ((inst), 4 + ((is_signed) ? 1 : 0), (reg)); \ } while (0) #define x86_mul_mem(inst,mem,is_signed) \ do { \ *(inst)++ = (unsigned char)0xf7; \ x86_mem_emit ((inst), 4 + ((is_signed) ? 1 : 0), (mem)); \ } while (0) #define x86_mul_membase(inst,basereg,disp,is_signed) \ do { \ *(inst)++ = (unsigned char)0xf7; \ x86_membase_emit ((inst), 4 + ((is_signed) ? 1 : 0), (basereg), (disp)); \ } while (0) /* * r *= rm */ #define x86_imul_reg_reg(inst,dreg,reg) \ do { \ *(inst)++ = (unsigned char)0x0f; \ *(inst)++ = (unsigned char)0xaf; \ x86_reg_emit ((inst), (dreg), (reg)); \ } while (0) #define x86_imul_reg_mem(inst,reg,mem) \ do { \ *(inst)++ = (unsigned char)0x0f; \ *(inst)++ = (unsigned char)0xaf; \ x86_mem_emit ((inst), (reg), (mem)); \ } while (0) #define x86_imul_reg_membase(inst,reg,basereg,disp) \ do { \ *(inst)++ = (unsigned char)0x0f; \ *(inst)++ = (unsigned char)0xaf; \ x86_membase_emit ((inst), (reg), (basereg), (disp)); \ } while (0) /* * dreg = rm * imm */ #define x86_imul_reg_reg_imm(inst,dreg,reg,imm) \ do { \ if (x86_is_imm8 ((imm))) { \ *(inst)++ = (unsigned char)0x6b; \ x86_reg_emit ((inst), (dreg), (reg)); \ x86_imm_emit8 ((inst), (imm)); \ } else { \ *(inst)++ = (unsigned char)0x69; \ x86_reg_emit ((inst), (dreg), (reg)); \ x86_imm_emit32 ((inst), (imm)); \ } \ } while (0) #define x86_imul_reg_mem_imm(inst,reg,mem,imm) \ do { \ if (x86_is_imm8 ((imm))) { \ *(inst)++ = (unsigned char)0x6b; \ x86_mem_emit ((inst), (reg), (mem)); \ x86_imm_emit8 ((inst), (imm)); \ } else { \ *(inst)++ = (unsigned char)0x69; \ x86_reg_emit ((inst), (reg), (mem)); \ x86_imm_emit32 ((inst), (imm)); \ } \ } while (0) #define x86_imul_reg_membase_imm(inst,reg,basereg,disp,imm) \ do { \ if (x86_is_imm8 ((imm))) { \ *(inst)++ = (unsigned char)0x6b; \ x86_membase_emit ((inst), (reg), (basereg), (disp)); \ x86_imm_emit8 ((inst), (imm)); \ } else { \ *(inst)++ = (unsigned char)0x69; \ x86_membase_emit ((inst), (reg), (basereg), (disp)); \ x86_imm_emit32 ((inst), (imm)); \ } \ } while (0) /* * divide EDX:EAX by rm; * eax = quotient, edx = remainder */ #define x86_div_reg(inst,reg,is_signed) \ do { \ *(inst)++ = (unsigned char)0xf7; \ x86_reg_emit ((inst), 6 + ((is_signed) ? 1 : 0), (reg)); \ } while (0) #define x86_div_mem(inst,mem,is_signed) \ do { \ *(inst)++ = (unsigned char)0xf7; \ x86_mem_emit ((inst), 6 + ((is_signed) ? 1 : 0), (mem)); \ } while (0) #define x86_div_membase(inst,basereg,disp,is_signed) \ do { \ *(inst)++ = (unsigned char)0xf7; \ x86_membase_emit ((inst), 6 + ((is_signed) ? 1 : 0), (basereg), (disp)); \ } while (0) #define x86_mov_mem_reg(inst,mem,reg,size) \ do { \ switch ((size)) { \ case 1: *(inst)++ = (unsigned char)0x88; break; \ case 2: *(inst)++ = (unsigned char)0x66; /* fall through */ \ case 4: *(inst)++ = (unsigned char)0x89; break; \ default: assert (0); \ } \ x86_mem_emit ((inst), (reg), (mem)); \ } while (0) #define x86_mov_regp_reg(inst,regp,reg,size) \ do { \ switch ((size)) { \ case 1: *(inst)++ = (unsigned char)0x88; break; \ case 2: *(inst)++ = (unsigned char)0x66; /* fall through */ \ case 4: *(inst)++ = (unsigned char)0x89; break; \ default: assert (0); \ } \ x86_regp_emit ((inst), (reg), (regp)); \ } while (0) #define x86_mov_membase_reg(inst,basereg,disp,reg,size) \ do { \ switch ((size)) { \ case 1: *(inst)++ = (unsigned char)0x88; break; \ case 2: *(inst)++ = (unsigned char)0x66; /* fall through */ \ case 4: *(inst)++ = (unsigned char)0x89; break; \ default: assert (0); \ } \ x86_membase_emit ((inst), (reg), (basereg), (disp)); \ } while (0) #define x86_mov_memindex_reg(inst,basereg,disp,indexreg,shift,reg,size) \ do { \ switch ((size)) { \ case 1: *(inst)++ = (unsigned char)0x88; break; \ case 2: *(inst)++ = (unsigned char)0x66; /* fall through */ \ case 4: *(inst)++ = (unsigned char)0x89; break; \ default: assert (0); \ } \ x86_memindex_emit ((inst), (reg), (basereg), (disp), (indexreg), (shift)); \ } while (0) #define x86_mov_reg_reg(inst,dreg,reg,size) \ do { \ switch ((size)) { \ case 1: *(inst)++ = (unsigned char)0x8a; break; \ case 2: *(inst)++ = (unsigned char)0x66; /* fall through */ \ case 4: *(inst)++ = (unsigned char)0x8b; break; \ default: assert (0); \ } \ x86_reg_emit ((inst), (dreg), (reg)); \ } while (0) #define x86_mov_reg_mem(inst,reg,mem,size) \ do { \ switch ((size)) { \ case 1: *(inst)++ = (unsigned char)0x8a; break; \ case 2: *(inst)++ = (unsigned char)0x66; /* fall through */ \ case 4: *(inst)++ = (unsigned char)0x8b; break; \ default: assert (0); \ } \ x86_mem_emit ((inst), (reg), (mem)); \ } while (0) #define x86_mov_reg_membase(inst,reg,basereg,disp,size) \ do { \ switch ((size)) { \ case 1: *(inst)++ = (unsigned char)0x8a; break; \ case 2: *(inst)++ = (unsigned char)0x66; /* fall through */ \ case 4: *(inst)++ = (unsigned char)0x8b; break; \ default: assert (0); \ } \ x86_membase_emit ((inst), (reg), (basereg), (disp)); \ } while (0) #define x86_mov_reg_memindex(inst,reg,basereg,disp,indexreg,shift,size) \ do { \ switch ((size)) { \ case 1: *(inst)++ = (unsigned char)0x8a; break; \ case 2: *(inst)++ = (unsigned char)0x66; /* fall through */ \ case 4: *(inst)++ = (unsigned char)0x8b; break; \ default: assert (0); \ } \ x86_memindex_emit ((inst), (reg), (basereg), (disp), (indexreg), (shift)); \ } while (0) /* * Note: x86_clear_reg () chacnges the condition code! */ #define x86_clear_reg(inst,reg) x86_alu_reg_reg((inst), X86_XOR, (reg), (reg)) #define x86_mov_reg_imm(inst,reg,imm) \ do { \ *(inst)++ = (unsigned char)0xb8 + (reg); \ x86_imm_emit32 ((inst), (imm)); \ } while (0) #define x86_mov_mem_imm(inst,mem,imm,size) \ do { \ if ((size) == 1) { \ *(inst)++ = (unsigned char)0xc6; \ x86_mem_emit ((inst), 0, (mem)); \ x86_imm_emit8 ((inst), (imm)); \ } else if ((size) == 2) { \ *(inst)++ = (unsigned char)0x66; \ *(inst)++ = (unsigned char)0xc7; \ x86_mem_emit ((inst), 0, (mem)); \ x86_imm_emit16 ((inst), (imm)); \ } else { \ *(inst)++ = (unsigned char)0xc7; \ x86_mem_emit ((inst), 0, (mem)); \ x86_imm_emit32 ((inst), (imm)); \ } \ } while (0) #define x86_mov_membase_imm(inst,basereg,disp,imm,size) \ do { \ if ((size) == 1) { \ *(inst)++ = (unsigned char)0xc6; \ x86_membase_emit ((inst), 0, (basereg), (disp)); \ x86_imm_emit8 ((inst), (imm)); \ } else if ((size) == 2) { \ *(inst)++ = (unsigned char)0x66; \ *(inst)++ = (unsigned char)0xc7; \ x86_membase_emit ((inst), 0, (basereg), (disp)); \ x86_imm_emit16 ((inst), (imm)); \ } else { \ *(inst)++ = (unsigned char)0xc7; \ x86_membase_emit ((inst), 0, (basereg), (disp)); \ x86_imm_emit32 ((inst), (imm)); \ } \ } while (0) #define x86_mov_memindex_imm(inst,basereg,disp,indexreg,shift,imm,size) \ do { \ if ((size) == 1) { \ *(inst)++ = (unsigned char)0xc6; \ x86_memindex_emit ((inst), 0, (basereg), (disp), (indexreg), (shift)); \ x86_imm_emit8 ((inst), (imm)); \ } else if ((size) == 2) { \ *(inst)++ = (unsigned char)0x66; \ *(inst)++ = (unsigned char)0xc7; \ x86_memindex_emit ((inst), 0, (basereg), (disp), (indexreg), (shift)); \ x86_imm_emit16 ((inst), (imm)); \ } else { \ *(inst)++ = (unsigned char)0xc7; \ x86_memindex_emit ((inst), 0, (basereg), (disp), (indexreg), (shift)); \ x86_imm_emit32 ((inst), (imm)); \ } \ } while (0) #define x86_lea_mem(inst,reg,mem) \ do { \ *(inst)++ = (unsigned char)0x8d; \ x86_mem_emit ((inst), (reg), (mem)); \ } while (0) #define x86_lea_membase(inst,reg,basereg,disp) \ do { \ *(inst)++ = (unsigned char)0x8d; \ x86_membase_emit ((inst), (reg), (basereg), (disp)); \ } while (0) #define x86_lea_memindex(inst,reg,basereg,disp,indexreg,shift) \ do { \ *(inst)++ = (unsigned char)0x8d; \ x86_memindex_emit ((inst), (reg), (basereg), (disp), (indexreg), (shift)); \ } while (0) #define x86_widen_reg(inst,dreg,reg,is_signed,is_half) \ do { \ unsigned char op = 0xb6; \ assert (is_half || X86_IS_BYTE_REG (reg)); \ *(inst)++ = (unsigned char)0x0f; \ if ((is_signed)) op += 0x08; \ if ((is_half)) op += 0x01; \ *(inst)++ = op; \ x86_reg_emit ((inst), (dreg), (reg)); \ } while (0) #define x86_widen_mem(inst,dreg,mem,is_signed,is_half) \ do { \ unsigned char op = 0xb6; \ *(inst)++ = (unsigned char)0x0f; \ if ((is_signed)) op += 0x08; \ if ((is_half)) op += 0x01; \ *(inst)++ = op; \ x86_mem_emit ((inst), (dreg), (mem)); \ } while (0) #define x86_widen_membase(inst,dreg,basereg,disp,is_signed,is_half) \ do { \ unsigned char op = 0xb6; \ *(inst)++ = (unsigned char)0x0f; \ if ((is_signed)) op += 0x08; \ if ((is_half)) op += 0x01; \ *(inst)++ = op; \ x86_membase_emit ((inst), (dreg), (basereg), (disp)); \ } while (0) #define x86_widen_memindex(inst,dreg,basereg,disp,indexreg,shift,is_signed,is_half) \ do { \ unsigned char op = 0xb6; \ *(inst)++ = (unsigned char)0x0f; \ if ((is_signed)) op += 0x08; \ if ((is_half)) op += 0x01; \ *(inst)++ = op; \ x86_memindex_emit ((inst), (dreg), (basereg), (disp), (indexreg), (shift)); \ } while (0) #define x86_lahf(inst) do { *(inst)++ = (unsigned char)0x9f; } while (0) #define x86_sahf(inst) do { *(inst)++ = (unsigned char)0x9e; } while (0) #define x86_xchg_ah_al(inst) \ do { \ *(inst)++ = (unsigned char)0x86; \ *(inst)++ = (unsigned char)0xe0; \ } while (0) #define x86_cdq(inst) do { *(inst)++ = (unsigned char)0x99; } while (0) #define x86_wait(inst) do { *(inst)++ = (unsigned char)0x9b; } while (0) #define x86_fp_op_mem(inst,opc,mem,is_double) \ do { \ *(inst)++ = (is_double) ? (unsigned char)0xdc : (unsigned char)0xd8; \ x86_mem_emit ((inst), (opc), (mem)); \ } while (0) #define x86_fp_op_membase(inst,opc,basereg,disp,is_double) \ do { \ *(inst)++ = (is_double) ? (unsigned char)0xdc : (unsigned char)0xd8; \ x86_membase_emit ((inst), (opc), (basereg), (disp)); \ } while (0) #define x86_fp_op(inst,opc,index) \ do { \ *(inst)++ = (unsigned char)0xd8; \ *(inst)++ = (unsigned char)0xc0+((opc)<<3)+((index)&0x07); \ } while (0) #define x86_fp_op_reg(inst,opc,index,pop_stack) \ do { \ static const unsigned char map[] = { 0, 1, 2, 3, 5, 4, 7, 6, 8}; \ *(inst)++ = (pop_stack) ? (unsigned char)0xde : (unsigned char)0xdc; \ *(inst)++ = (unsigned char)0xc0+(map[(opc)]<<3)+((index)&0x07); \ } while (0) /** * @x86_fp_int_op_membase * Supports FPU operations between ST(0) and integer operand in memory. * Operation encoded using X86_FP_Opcode enum. * Operand is addressed by [basereg + disp]. * is_int specifies whether operand is int32 (TRUE) or int16 (FALSE). */ #define x86_fp_int_op_membase(inst,opc,basereg,disp,is_int) \ do { \ *(inst)++ = (is_int) ? (unsigned char)0xda : (unsigned char)0xde; \ x86_membase_emit ((inst), opc, (basereg), (disp)); \ } while (0) #define x86_fstp(inst,index) \ do { \ *(inst)++ = (unsigned char)0xdd; \ *(inst)++ = (unsigned char)0xd8+(index); \ } while (0) #define x86_fcompp(inst) \ do { \ *(inst)++ = (unsigned char)0xde; \ *(inst)++ = (unsigned char)0xd9; \ } while (0) #define x86_fucompp(inst) \ do { \ *(inst)++ = (unsigned char)0xda; \ *(inst)++ = (unsigned char)0xe9; \ } while (0) #define x86_fnstsw(inst) \ do { \ *(inst)++ = (unsigned char)0xdf; \ *(inst)++ = (unsigned char)0xe0; \ } while (0) #define x86_fnstcw(inst,mem) \ do { \ *(inst)++ = (unsigned char)0xd9; \ x86_mem_emit ((inst), 7, (mem)); \ } while (0) #define x86_fnstcw_membase(inst,basereg,disp) \ do { \ *(inst)++ = (unsigned char)0xd9; \ x86_membase_emit ((inst), 7, (basereg), (disp)); \ } while (0) #define x86_fldcw(inst,mem) \ do { \ *(inst)++ = (unsigned char)0xd9; \ x86_mem_emit ((inst), 5, (mem)); \ } while (0) #define x86_fldcw_membase(inst,basereg,disp) \ do { \ *(inst)++ = (unsigned char)0xd9; \ x86_membase_emit ((inst), 5, (basereg), (disp)); \ } while (0) #define x86_fchs(inst) \ do { \ *(inst)++ = (unsigned char)0xd9; \ *(inst)++ = (unsigned char)0xe0; \ } while (0) #define x86_frem(inst) \ do { \ *(inst)++ = (unsigned char)0xd9; \ *(inst)++ = (unsigned char)0xf8; \ } while (0) #define x86_fxch(inst,index) \ do { \ *(inst)++ = (unsigned char)0xd9; \ *(inst)++ = (unsigned char)0xc8 + ((index) & 0x07); \ } while (0) #define x86_fcomi(inst,index) \ do { \ *(inst)++ = (unsigned char)0xdb; \ *(inst)++ = (unsigned char)0xf0 + ((index) & 0x07); \ } while (0) #define x86_fcomip(inst,index) \ do { \ *(inst)++ = (unsigned char)0xdf; \ *(inst)++ = (unsigned char)0xf0 + ((index) & 0x07); \ } while (0) #define x86_fucomi(inst,index) \ do { \ *(inst)++ = (unsigned char)0xdb; \ *(inst)++ = (unsigned char)0xe8 + ((index) & 0x07); \ } while (0) #define x86_fucomip(inst,index) \ do { \ *(inst)++ = (unsigned char)0xdf; \ *(inst)++ = (unsigned char)0xe8 + ((index) & 0x07); \ } while (0) #define x86_fld(inst,mem,is_double) \ do { \ *(inst)++ = (is_double) ? (unsigned char)0xdd : (unsigned char)0xd9; \ x86_mem_emit ((inst), 0, (mem)); \ } while (0) #define x86_fld_membase(inst,basereg,disp,is_double) \ do { \ *(inst)++ = (is_double) ? (unsigned char)0xdd : (unsigned char)0xd9; \ x86_membase_emit ((inst), 0, (basereg), (disp)); \ } while (0) #define x86_fld80_mem(inst,mem) \ do { \ *(inst)++ = (unsigned char)0xdb; \ x86_mem_emit ((inst), 5, (mem)); \ } while (0) #define x86_fld80_membase(inst,basereg,disp) \ do { \ *(inst)++ = (unsigned char)0xdb; \ x86_membase_emit ((inst), 5, (basereg), (disp)); \ } while (0) #define x86_fild(inst,mem,is_long) \ do { \ if ((is_long)) { \ *(inst)++ = (unsigned char)0xdf; \ x86_mem_emit ((inst), 5, (mem)); \ } else { \ *(inst)++ = (unsigned char)0xdb; \ x86_mem_emit ((inst), 0, (mem)); \ } \ } while (0) #define x86_fild_membase(inst,basereg,disp,is_long) \ do { \ if ((is_long)) { \ *(inst)++ = (unsigned char)0xdf; \ x86_membase_emit ((inst), 5, (basereg), (disp)); \ } else { \ *(inst)++ = (unsigned char)0xdb; \ x86_membase_emit ((inst), 0, (basereg), (disp)); \ } \ } while (0) #define x86_fld_reg(inst,index) \ do { \ *(inst)++ = (unsigned char)0xd9; \ *(inst)++ = (unsigned char)0xc0 + ((index) & 0x07); \ } while (0) #define x86_fldz(inst) \ do { \ *(inst)++ = (unsigned char)0xd9; \ *(inst)++ = (unsigned char)0xee; \ } while (0) #define x86_fld1(inst) \ do { \ *(inst)++ = (unsigned char)0xd9; \ *(inst)++ = (unsigned char)0xe8; \ } while (0) #define x86_fldpi(inst) \ do { \ *(inst)++ = (unsigned char)0xd9; \ *(inst)++ = (unsigned char)0xeb; \ } while (0) #define x86_fst(inst,mem,is_double,pop_stack) \ do { \ *(inst)++ = (is_double) ? (unsigned char)0xdd: (unsigned char)0xd9; \ x86_mem_emit ((inst), 2 + ((pop_stack) ? 1 : 0), (mem)); \ } while (0) #define x86_fst_membase(inst,basereg,disp,is_double,pop_stack) \ do { \ *(inst)++ = (is_double) ? (unsigned char)0xdd: (unsigned char)0xd9; \ x86_membase_emit ((inst), 2 + ((pop_stack) ? 1 : 0), (basereg), (disp)); \ } while (0) #define x86_fst80_mem(inst,mem) \ do { \ *(inst)++ = (unsigned char)0xdb; \ x86_mem_emit ((inst), 7, (mem)); \ } while (0) #define x86_fst80_membase(inst,basereg,disp) \ do { \ *(inst)++ = (unsigned char)0xdb; \ x86_membase_emit ((inst), 7, (basereg), (disp)); \ } while (0) #define x86_fist_pop(inst,mem,is_long) \ do { \ if ((is_long)) { \ *(inst)++ = (unsigned char)0xdf; \ x86_mem_emit ((inst), 7, (mem)); \ } else { \ *(inst)++ = (unsigned char)0xdb; \ x86_mem_emit ((inst), 3, (mem)); \ } \ } while (0) #define x86_fist_pop_membase(inst,basereg,disp,is_long) \ do { \ if ((is_long)) { \ *(inst)++ = (unsigned char)0xdf; \ x86_membase_emit ((inst), 7, (basereg), (disp)); \ } else { \ *(inst)++ = (unsigned char)0xdb; \ x86_membase_emit ((inst), 3, (basereg), (disp)); \ } \ } while (0) #define x86_fstsw(inst) \ do { \ *(inst)++ = (unsigned char)0x9b; \ *(inst)++ = (unsigned char)0xdf; \ *(inst)++ = (unsigned char)0xe0; \ } while (0) /** * @x86_fist_membase * Converts content of ST(0) to integer and stores it at memory location * addressed by [basereg + disp]. * is_int specifies whether destination is int32 (TRUE) or int16 (FALSE). */ #define x86_fist_membase(inst,basereg,disp,is_int) \ do { \ if ((is_int)) { \ *(inst)++ = (unsigned char)0xdb; \ x86_membase_emit ((inst), 2, (basereg), (disp)); \ } else { \ *(inst)++ = (unsigned char)0xdf; \ x86_membase_emit ((inst), 2, (basereg), (disp)); \ } \ } while (0) #define x86_push_reg(inst,reg) \ do { \ *(inst)++ = (unsigned char)0x50 + (reg); \ } while (0) #define x86_push_regp(inst,reg) \ do { \ *(inst)++ = (unsigned char)0xff; \ x86_regp_emit ((inst), 6, (reg)); \ } while (0) #define x86_push_mem(inst,mem) \ do { \ *(inst)++ = (unsigned char)0xff; \ x86_mem_emit ((inst), 6, (mem)); \ } while (0) #define x86_push_membase(inst,basereg,disp) \ do { \ *(inst)++ = (unsigned char)0xff; \ x86_membase_emit ((inst), 6, (basereg), (disp)); \ } while (0) #define x86_push_memindex(inst,basereg,disp,indexreg,shift) \ do { \ *(inst)++ = (unsigned char)0xff; \ x86_memindex_emit ((inst), 6, (basereg), (disp), (indexreg), (shift)); \ } while (0) #define x86_push_imm_template(inst) x86_push_imm (inst, 0xf0f0f0f0) #define x86_push_imm(inst,imm) \ do { \ int _imm = (int) (imm); \ if (x86_is_imm8 (_imm)) { \ *(inst)++ = (unsigned char)0x6A; \ x86_imm_emit8 ((inst), (_imm)); \ } else { \ *(inst)++ = (unsigned char)0x68; \ x86_imm_emit32 ((inst), (_imm)); \ } \ } while (0) #define x86_pop_reg(inst,reg) \ do { \ *(inst)++ = (unsigned char)0x58 + (reg); \ } while (0) #define x86_pop_mem(inst,mem) \ do { \ *(inst)++ = (unsigned char)0x87; \ x86_mem_emit ((inst), 0, (mem)); \ } while (0) #define x86_pop_membase(inst,basereg,disp) \ do { \ *(inst)++ = (unsigned char)0x87; \ x86_membase_emit ((inst), 0, (basereg), (disp)); \ } while (0) #define x86_pushad(inst) do { *(inst)++ = (unsigned char)0x60; } while (0) #define x86_pushfd(inst) do { *(inst)++ = (unsigned char)0x9c; } while (0) #define x86_popad(inst) do { *(inst)++ = (unsigned char)0x61; } while (0) #define x86_popfd(inst) do { *(inst)++ = (unsigned char)0x9d; } while (0) #define x86_loop(inst,imm) \ do { \ *(inst)++ = (unsigned char)0xe2; \ x86_imm_emit8 ((inst), (imm)); \ } while (0) #define x86_loope(inst,imm) \ do { \ *(inst)++ = (unsigned char)0xe1; \ x86_imm_emit8 ((inst), (imm)); \ } while (0) #define x86_loopne(inst,imm) \ do { \ *(inst)++ = (unsigned char)0xe0; \ x86_imm_emit8 ((inst), (imm)); \ } while (0) #define x86_jump32(inst,imm) \ do { \ *(inst)++ = (unsigned char)0xe9; \ x86_imm_emit32 ((inst), (imm)); \ } while (0) #define x86_jump8(inst,imm) \ do { \ *(inst)++ = (unsigned char)0xeb; \ x86_imm_emit8 ((inst), (imm)); \ } while (0) #define x86_jump_reg(inst,reg) \ do { \ *(inst)++ = (unsigned char)0xff; \ x86_reg_emit ((inst), 4, (reg)); \ } while (0) #define x86_jump_mem(inst,mem) \ do { \ *(inst)++ = (unsigned char)0xff; \ x86_mem_emit ((inst), 4, (mem)); \ } while (0) #define x86_jump_membase(inst,basereg,disp) \ do { \ *(inst)++ = (unsigned char)0xff; \ x86_membase_emit ((inst), 4, (basereg), (disp)); \ } while (0) /* * target is a pointer in our buffer. */ #define x86_jump_code(inst,target) \ do { \ int t = (unsigned char*)(target) - (inst) - 2; \ if (x86_is_imm8(t)) { \ x86_jump8 ((inst), t); \ } else { \ t -= 3; \ x86_jump32 ((inst), t); \ } \ } while (0) #define x86_jump_disp(inst,disp) \ do { \ int t = (disp) - 2; \ if (x86_is_imm8(t)) { \ x86_jump8 ((inst), t); \ } else { \ t -= 3; \ x86_jump32 ((inst), t); \ } \ } while (0) #define x86_branch8(inst,cond,imm,is_signed) \ do { \ if ((is_signed)) \ *(inst)++ = x86_cc_signed_map [(cond)]; \ else \ *(inst)++ = x86_cc_unsigned_map [(cond)]; \ x86_imm_emit8 ((inst), (imm)); \ } while (0) #define x86_branch32(inst,cond,imm,is_signed) \ do { \ *(inst)++ = (unsigned char)0x0f; \ if ((is_signed)) \ *(inst)++ = x86_cc_signed_map [(cond)] + 0x10; \ else \ *(inst)++ = x86_cc_unsigned_map [(cond)] + 0x10; \ x86_imm_emit32 ((inst), (imm)); \ } while (0) #define x86_branch(inst,cond,target,is_signed) \ do { \ int offset = (target) - (inst) - 2; \ if (x86_is_imm8 ((offset))) \ x86_branch8 ((inst), (cond), offset, (is_signed)); \ else { \ offset -= 4; \ x86_branch32 ((inst), (cond), offset, (is_signed)); \ } \ } while (0) #define x86_branch_disp(inst,cond,disp,is_signed) \ do { \ int offset = (disp) - 2; \ if (x86_is_imm8 ((offset))) \ x86_branch8 ((inst), (cond), offset, (is_signed)); \ else { \ offset -= 4; \ x86_branch32 ((inst), (cond), offset, (is_signed)); \ } \ } while (0) #define x86_set_reg(inst,cond,reg,is_signed) \ do { \ assert (X86_IS_BYTE_REG (reg)); \ *(inst)++ = (unsigned char)0x0f; \ if ((is_signed)) \ *(inst)++ = x86_cc_signed_map [(cond)] + 0x20; \ else \ *(inst)++ = x86_cc_unsigned_map [(cond)] + 0x20; \ x86_reg_emit ((inst), 0, (reg)); \ } while (0) #define x86_set_mem(inst,cond,mem,is_signed) \ do { \ *(inst)++ = (unsigned char)0x0f; \ if ((is_signed)) \ *(inst)++ = x86_cc_signed_map [(cond)] + 0x20; \ else \ *(inst)++ = x86_cc_unsigned_map [(cond)] + 0x20; \ x86_mem_emit ((inst), 0, (mem)); \ } while (0) #define x86_set_membase(inst,cond,basereg,disp,is_signed) \ do { \ *(inst)++ = (unsigned char)0x0f; \ if ((is_signed)) \ *(inst)++ = x86_cc_signed_map [(cond)] + 0x20; \ else \ *(inst)++ = x86_cc_unsigned_map [(cond)] + 0x20; \ x86_membase_emit ((inst), 0, (basereg), (disp)); \ } while (0) #define x86_call_imm(inst,disp) \ do { \ *(inst)++ = (unsigned char)0xe8; \ x86_imm_emit32 ((inst), (int)(disp)); \ } while (0) #define x86_call_reg(inst,reg) \ do { \ *(inst)++ = (unsigned char)0xff; \ x86_reg_emit ((inst), 2, (reg)); \ } while (0) #define x86_call_mem(inst,mem) \ do { \ *(inst)++ = (unsigned char)0xff; \ x86_mem_emit ((inst), 2, (mem)); \ } while (0) #define x86_call_membase(inst,basereg,disp) \ do { \ *(inst)++ = (unsigned char)0xff; \ x86_membase_emit ((inst), 2, (basereg), (disp)); \ } while (0) #define x86_call_code(inst,target) \ do { \ int _x86_offset = (unsigned char*)(target) - (inst); \ _x86_offset -= 5; \ x86_call_imm ((inst), _x86_offset); \ } while (0) #define x86_ret(inst) do { *(inst)++ = (unsigned char)0xc3; } while (0) #define x86_ret_imm(inst,imm) \ do { \ if ((imm) == 0) { \ x86_ret ((inst)); \ } else { \ *(inst)++ = (unsigned char)0xc2; \ x86_imm_emit16 ((inst), (imm)); \ } \ } while (0) #define x86_cmov_reg(inst,cond,is_signed,dreg,reg) \ do { \ *(inst)++ = (unsigned char) 0x0f; \ if ((is_signed)) \ *(inst)++ = x86_cc_signed_map [(cond)] - 0x30; \ else \ *(inst)++ = x86_cc_unsigned_map [(cond)] - 0x30; \ x86_reg_emit ((inst), (dreg), (reg)); \ } while (0) #define x86_cmov_mem(inst,cond,is_signed,reg,mem) \ do { \ *(inst)++ = (unsigned char) 0x0f; \ if ((is_signed)) \ *(inst)++ = x86_cc_signed_map [(cond)] - 0x30; \ else \ *(inst)++ = x86_cc_unsigned_map [(cond)] - 0x30; \ x86_mem_emit ((inst), (reg), (mem)); \ } while (0) #define x86_cmov_membase(inst,cond,is_signed,reg,basereg,disp) \ do { \ *(inst)++ = (unsigned char) 0x0f; \ if ((is_signed)) \ *(inst)++ = x86_cc_signed_map [(cond)] - 0x30; \ else \ *(inst)++ = x86_cc_unsigned_map [(cond)] - 0x30; \ x86_membase_emit ((inst), (reg), (basereg), (disp)); \ } while (0) #define x86_enter(inst,framesize) \ do { \ *(inst)++ = (unsigned char)0xc8; \ x86_imm_emit16 ((inst), (framesize)); \ *(inst)++ = 0; \ } while (0) #define x86_leave(inst) do { *(inst)++ = (unsigned char)0xc9; } while (0) #define x86_sahf(inst) do { *(inst)++ = (unsigned char)0x9e; } while (0) #define x86_fsin(inst) do { *(inst)++ = (unsigned char)0xd9; *(inst)++ = (unsigned char)0xfe; } while (0) #define x86_fcos(inst) do { *(inst)++ = (unsigned char)0xd9; *(inst)++ = (unsigned char)0xff; } while (0) #define x86_fabs(inst) do { *(inst)++ = (unsigned char)0xd9; *(inst)++ = (unsigned char)0xe1; } while (0) #define x86_ftst(inst) do { *(inst)++ = (unsigned char)0xd9; *(inst)++ = (unsigned char)0xe4; } while (0) #define x86_fxam(inst) do { *(inst)++ = (unsigned char)0xd9; *(inst)++ = (unsigned char)0xe5; } while (0) #define x86_fpatan(inst) do { *(inst)++ = (unsigned char)0xd9; *(inst)++ = (unsigned char)0xf3; } while (0) #define x86_fprem(inst) do { *(inst)++ = (unsigned char)0xd9; *(inst)++ = (unsigned char)0xf8; } while (0) #define x86_fprem1(inst) do { *(inst)++ = (unsigned char)0xd9; *(inst)++ = (unsigned char)0xf5; } while (0) #define x86_frndint(inst) do { *(inst)++ = (unsigned char)0xd9; *(inst)++ = (unsigned char)0xfc; } while (0) #define x86_fsqrt(inst) do { *(inst)++ = (unsigned char)0xd9; *(inst)++ = (unsigned char)0xfa; } while (0) #define x86_fptan(inst) do { *(inst)++ = (unsigned char)0xd9; *(inst)++ = (unsigned char)0xf2; } while (0) #define x86_padding(inst,size) \ do { \ switch ((size)) { \ case 1: x86_nop ((inst)); break; \ case 2: *(inst)++ = 0x8b; \ *(inst)++ = 0xc0; break; \ case 3: *(inst)++ = 0x8d; *(inst)++ = 0x6d; \ *(inst)++ = 0x00; break; \ case 4: *(inst)++ = 0x8d; *(inst)++ = 0x64; \ *(inst)++ = 0x24; *(inst)++ = 0x00; \ break; \ case 5: *(inst)++ = 0x8d; *(inst)++ = 0x64; \ *(inst)++ = 0x24; *(inst)++ = 0x00; \ x86_nop ((inst)); break; \ case 6: *(inst)++ = 0x8d; *(inst)++ = 0xad; \ *(inst)++ = 0x00; *(inst)++ = 0x00; \ *(inst)++ = 0x00; *(inst)++ = 0x00; \ break; \ case 7: *(inst)++ = 0x8d; *(inst)++ = 0xa4; \ *(inst)++ = 0x24; *(inst)++ = 0x00; \ *(inst)++ = 0x00; *(inst)++ = 0x00; \ *(inst)++ = 0x00; break; \ default: assert (0); \ } \ } while (0) #define x86_prolog(inst,frame_size,reg_mask) \ do { \ unsigned i, m = 1; \ x86_enter ((inst), (frame_size)); \ for (i = 0; i < X86_NREG; ++i, m <<= 1) { \ if ((reg_mask) & m) \ x86_push_reg ((inst), i); \ } \ } while (0) #define x86_epilog(inst,reg_mask) \ do { \ unsigned i, m = 1 << X86_EDI; \ for (i = X86_EDI; m != 0; i--, m=m>>1) { \ if ((reg_mask) & m) \ x86_pop_reg ((inst), i); \ } \ x86_leave ((inst)); \ x86_ret ((inst)); \ } while (0) #endif // X86_H ================================================ FILE: tools/virtualmips/x86_trans.c ================================================ /* * Copyright (C) yajin 2008 * * This file is part of the virtualmips distribution. * See LICENSE file for terms of the license. * */ #include #include #include #include #include #include #include #include #include #include #include "cpu.h" #include "vm.h" #include "mips_exec.h" #include "mips_memory.h" #include "mips.h" #include "mips_cp0.h" #include "debug.h" #include "vp_timer.h" #include "x86_trans.h" #ifdef _USE_JIT_ struct mips_jit_desc mips_jit[]; static struct mips_jit_desc mips_spec_jit[]; static struct mips_jit_desc mips_bcond_jit[]; static struct mips_jit_desc mips_cop0_jit[]; static struct mips_jit_desc mips_mad_jit[]; static struct mips_jit_desc mips_tlb_jit[]; void fastcall mips_exec_single_step (cpu_mips_t * cpu, mips_insn_t instruction); #define REG_OFFSET(reg) (OFFSET(cpu_mips_t,gpr[(reg)])) #define CP0_REG_OFFSET(c0reg) (OFFSET(cpu_mips_t,cp0.reg[(c0reg)])) #define MEMOP_OFFSET(op) (OFFSET(cpu_mips_t,mem_op_fn[(op)])) /* Set the Pointer Counter (PC) register */ void mips_set_pc (mips_jit_tcb_t * b, m_va_t new_pc) { x86_mov_membase_imm (b->jit_ptr, X86_EDI, OFFSET (cpu_mips_t, pc), new_pc & 0xFFFFFFFF, 4); } /* Set the Return Address (RA) register */ void mips_set_ra (mips_jit_tcb_t * b, m_va_t ret_pc) { x86_mov_membase_imm (b->jit_ptr, X86_EDI, REG_OFFSET (MIPS_GPR_RA), ret_pc & 0xFFFFFFFF, 4); } /* * Try to branch directly to the specified JIT block without returning to * main loop. */ static void mips_try_direct_far_jump (cpu_mips_t * cpu, mips_jit_tcb_t * b, m_va_t new_pc) { m_va_t new_page; m_uint32_t pc_hash, pc_offset; u_char *test1, *test2, *test3, *test4, *test5, *test6; new_page = new_pc & MIPS_MIN_PAGE_MASK; pc_offset = (new_pc & MIPS_MIN_PAGE_IMASK) >> 2; pc_hash = mips_jit_get_pc_hash (cpu, new_pc); /* Get JIT block info in %edx */ x86_mov_reg_membase (b->jit_ptr, X86_EBX, X86_EDI, OFFSET (cpu_mips_t, exec_blk_map), 4); x86_mov_reg_membase (b->jit_ptr, X86_EDX, X86_EBX, pc_hash * sizeof (void *), 4); /* no JIT block found ? */ x86_test_reg_reg (b->jit_ptr, X86_EDX, X86_EDX); test1 = b->jit_ptr; x86_branch8 (b->jit_ptr, X86_CC_Z, 0, 1); /* Check block PC */ x86_mov_reg_imm (b->jit_ptr, X86_EAX, (m_uint32_t) new_page); x86_alu_reg_membase (b->jit_ptr, X86_CMP, X86_EAX, X86_EDX, OFFSET (mips_jit_tcb_t, start_pc)); test2 = b->jit_ptr; x86_branch8 (b->jit_ptr, X86_CC_NE, 0, 1); /*whether newpc is mapped */ x86_shift_reg_imm (b->jit_ptr, X86_SHR, X86_EAX, 29); x86_alu_reg_imm (b->jit_ptr, X86_AND, X86_EAX, 0x7); x86_alu_reg_imm (b->jit_ptr, X86_CMP, X86_EAX, 0x4); test4 = b->jit_ptr; x86_branch8 (b->jit_ptr, X86_CC_E, 0, 1); x86_alu_reg_imm (b->jit_ptr, X86_CMP, X86_EAX, 0x5); test5 = b->jit_ptr; x86_branch8 (b->jit_ptr, X86_CC_E, 0, 1); /*check ASID */ x86_lea_membase (b->jit_ptr, X86_ESI, X86_EDI, OFFSET (cpu_mips_t, cp0)); //x86_mov_reg_membase(b->jit_ptr,X86_ESI, // X86_EDI,OFFSET(cpu_mips_t,cp0),4); x86_mov_reg_membase (b->jit_ptr, X86_EBX, X86_ESI, OFFSET (mips_cp0_t, reg[MIPS_CP0_TLB_HI]), 4); x86_alu_reg_imm (b->jit_ptr, X86_AND, X86_EBX, MIPS_TLB_ASID_MASK); x86_alu_reg_membase (b->jit_ptr, X86_CMP, X86_EBX, X86_EDX, OFFSET (mips_jit_tcb_t, asid)); test6 = b->jit_ptr; x86_branch8 (b->jit_ptr, X86_CC_NE, 0, 1); x86_patch (test4, b->jit_ptr); x86_patch (test5, b->jit_ptr); /* Jump to the code */ x86_mov_reg_membase (b->jit_ptr, X86_ESI, X86_EDX, OFFSET (mips_jit_tcb_t, jit_insn_ptr), 4); x86_mov_reg_membase (b->jit_ptr, X86_EBX, X86_ESI, pc_offset * sizeof (void *), 4); x86_test_reg_reg (b->jit_ptr, X86_EBX, X86_EBX); test3 = b->jit_ptr; x86_branch8 (b->jit_ptr, X86_CC_Z, 0, 1); x86_jump_reg (b->jit_ptr, X86_EBX); /* Returns to caller... */ x86_patch (test1, b->jit_ptr); x86_patch (test2, b->jit_ptr); x86_patch (test3, b->jit_ptr); x86_patch (test6, b->jit_ptr); mips_set_pc (b, new_pc); mips_jit_tcb_push_epilog (b); } /* Set Jump */ static void mips_set_jump (cpu_mips_t * cpu, mips_jit_tcb_t * b, m_va_t new_pc, int local_jump) { int return_to_caller = FALSE; u_char *jump_ptr; if (!local_jump) return_to_caller = TRUE; if (!return_to_caller && mips_jit_tcb_local_addr (b, new_pc, &jump_ptr)) { if (jump_ptr) { x86_jump_code (b->jit_ptr, jump_ptr); } else { /* Never jump directly to code in a delay slot. */ /*Hi yajin, why a delay slot can have entry point or why have to jmp * to delay slot? * The following is the code from celinux 2.4. * * 802a19d4: 1500004a bnez t0,802a1b00 * * 802a19d8 : * 802a19d8: 00064142 srl t0,a2,0x5 * * if call function both_aligned(0x802a19d8), it is in delay slot of 0x802a19d4 but it is * the entry of function both_aligned. * Just set pc to 0x802a19d8 and return main loop. */ if (mips_jit_is_delay_slot (b, new_pc)) { mips_set_pc (b, new_pc); mips_jit_tcb_push_epilog (b); return; } mips_jit_tcb_record_patch (b, b->jit_ptr, new_pc); x86_jump32 (b->jit_ptr, 0); } } else { mips_try_direct_far_jump (cpu, b, new_pc); #if 0 if (cpu->exec_blk_direct_jump) { /* Block lookup optimization */ mips_try_direct_far_jump (cpu, b, new_pc); } else { mips_set_pc (b, new_pc); mips_jit_tcb_push_epilog (b); } #endif } } /* Basic C call */ void mips_emit_basic_c_call (mips_jit_tcb_t * b, void *f) { x86_mov_reg_imm (b->jit_ptr, X86_EBX, f); x86_call_reg (b->jit_ptr, X86_EBX); } /* Emit a simple call to a C function without any parameter */ static void mips_emit_c_call (mips_jit_tcb_t * b, void *f) { mips_set_pc (b, b->start_pc + ((b->mips_trans_pos - 1) << 2)); mips_emit_basic_c_call (b, f); } /* Single-step operation */ void mips_emit_single_step (mips_jit_tcb_t * b, mips_insn_t insn) { x86_mov_reg_reg (b->jit_ptr, X86_EAX, X86_EDI, 4); x86_mov_reg_imm (b->jit_ptr, X86_EDX, insn); mips_emit_basic_c_call (b, mips_exec_single_step); } /* Memory operation */ /*we use EAX EDX ECX to transfer parameter. yajin. Makesure memory operation DONOT have more than 3 parameters*/ static void mips_emit_memop (mips_jit_tcb_t * b, int op, int base, int offset, int target, int keep_ll_bit) { m_va_t val = sign_extend (offset, 16); m_uint8_t *test1; /* Save PC for exception handling */ mips_set_pc (b, b->start_pc + ((b->mips_trans_pos - 1) << 2)); if (!keep_ll_bit) { x86_clear_reg (b->jit_ptr, X86_EAX); x86_mov_membase_reg (b->jit_ptr, X86_EDI, OFFSET (cpu_mips_t, ll_bit), X86_EAX, 4); } x86_mov_reg_imm (b->jit_ptr, X86_EDX, val); /* EDX = GPR[base] + sign-extended offset */ x86_alu_reg_membase (b->jit_ptr, X86_ADD, X86_EDX, X86_EDI, REG_OFFSET (base)); /* ECX = target register */ x86_mov_reg_imm (b->jit_ptr, X86_ECX, target); /* EAX = CPU instance pointer */ x86_mov_reg_reg (b->jit_ptr, X86_EAX, X86_EDI, 4); x86_mov_reg_membase (b->jit_ptr, X86_EBX, X86_EDI, MEMOP_OFFSET (op), 4); x86_call_reg (b->jit_ptr, X86_EBX); /*check the return value */ x86_alu_reg_imm (b->jit_ptr, X86_CMP, X86_EAX, 0); /*IF return value==0.NO exception. */ test1 = b->jit_ptr; x86_branch8 (b->jit_ptr, X86_CC_E, 0, 1); mips_jit_tcb_push_epilog (b); x86_patch (test1, b->jit_ptr); } /* Unknown opcode handler */ static asmlinkage void mips_unknown_opcode (cpu_mips_t * cpu, m_uint32_t opcode) { printf ("MIPS64: unhandled opcode 0x%8.8x at 0x%" LL "x (ra=0x%" LL "x)\n", opcode, cpu->pc, cpu->gpr[MIPS_GPR_RA]); //mips_dump_regs(cpu); } /* Emit unhandled instruction code */ static int mips_emit_unknown (cpu_mips_t * cpu, mips_jit_tcb_t * b, mips_insn_t opcode) { x86_mov_reg_imm (b->jit_ptr, X86_EAX, opcode); x86_alu_reg_imm (b->jit_ptr, X86_SUB, X86_ESP, 4); x86_push_reg (b->jit_ptr, X86_EAX); x86_push_reg (b->jit_ptr, X86_EDI); mips_emit_c_call (b, mips_unknown_opcode); x86_alu_reg_imm (b->jit_ptr, X86_ADD, X86_ESP, 12); return (0); } /* Invalid delay slot handler */ static fastcall void mips_invalid_delay_slot (cpu_mips_t * cpu) { printf ("MIPS64: invalid instruction in delay slot at 0x%" LL "x (ra=0x%" LL "x)\n", cpu->pc, cpu->gpr[MIPS_GPR_RA]); //mips_dump_regs(cpu); /* Halt the virtual CPU */ cpu->pc = 0; } /* Emit unhandled instruction code */ int mips_emit_invalid_delay_slot (mips_jit_tcb_t * b) { x86_mov_reg_reg (b->jit_ptr, X86_EAX, X86_EDI, 4); mips_emit_c_call (b, mips_invalid_delay_slot); x86_alu_reg_imm (b->jit_ptr, X86_ADD, X86_ESP, 12); mips_jit_tcb_push_epilog (b); return (0); } void mips_check_cpu_pausing (mips_jit_tcb_t * b) { u_char *test1; /* Check pause_request */ x86_mov_reg_membase (b->jit_ptr, X86_EAX, X86_EDI, OFFSET (cpu_mips_t, pause_request), 4); x86_alu_reg_imm (b->jit_ptr, X86_AND, X86_EAX, CPU_INTERRUPT_EXIT); x86_alu_reg_imm (b->jit_ptr, X86_CMP, X86_EAX, CPU_INTERRUPT_EXIT); test1 = b->jit_ptr; x86_branch32 (b->jit_ptr, X86_CC_NE, 0, 1); /*if (cpu->pause_request)&CPU_INTERRUPT_EXIT==CPU_INTERRUPT_EXIT, * set cpu->state and return to main loop */ mips_set_pc (b, b->start_pc + ((b->mips_trans_pos - 1) << 2)); x86_mov_membase_imm (b->jit_ptr, X86_EDI, OFFSET (cpu_mips_t, state), CPU_STATE_PAUSING, 4); mips_jit_tcb_push_epilog (b); /*else do noting */ x86_patch (test1, b->jit_ptr); } /* Check if there are pending IRQ */ void mips_check_pending_irq (mips_jit_tcb_t * b) { u_char *test1; /* Check the pending IRQ flag */ x86_mov_reg_membase (b->jit_ptr, X86_EAX, X86_EDI, OFFSET (cpu_mips_t, irq_pending), 4); x86_test_reg_reg (b->jit_ptr, X86_EAX, X86_EAX); test1 = b->jit_ptr; x86_branch32 (b->jit_ptr, X86_CC_Z, 0, 1); /* Save PC */ mips_set_pc (b, b->start_pc + ((b->mips_trans_pos - 1) << 2)); /* Trigger the IRQ */ x86_mov_reg_reg (b->jit_ptr, X86_EAX, X86_EDI, 4); mips_emit_basic_c_call (b, mips_trigger_irq); mips_jit_tcb_push_epilog (b); x86_patch (test1, b->jit_ptr); } /* ADD */ static int mips_emit_add (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { int rs = bits (insn, 21, 25); int rt = bits (insn, 16, 20); int rd = bits (insn, 11, 15); //printf("rs %d rt %d rd %d \n",rs,rt,rd); /* TODO: Exception handling */ x86_mov_reg_membase (b->jit_ptr, X86_EAX, X86_EDI, REG_OFFSET (rs), 4); x86_alu_reg_membase (b->jit_ptr, X86_ADD, X86_EAX, X86_EDI, REG_OFFSET (rt)); x86_mov_membase_reg (b->jit_ptr, X86_EDI, REG_OFFSET (rd), X86_EAX, 4); return (0); } /* ADDI */ static int mips_emit_addi (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { int rs = bits (insn, 21, 25); int rt = bits (insn, 16, 20); int imm = bits (insn, 0, 15); m_uint32_t val = sign_extend (imm, 16); // printf("rs %d rt %d val %d \n",rs,rt,val); /* TODO: Exception handling */ x86_mov_reg_imm (b->jit_ptr, X86_EAX, val); x86_alu_reg_membase (b->jit_ptr, X86_ADD, X86_EAX, X86_EDI, REG_OFFSET (rs)); x86_mov_membase_reg (b->jit_ptr, X86_EDI, REG_OFFSET (rt), X86_EAX, 4); return (0); } /* ADDI */ static int mips_emit_addiu (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { int rs = bits (insn, 21, 25); int rt = bits (insn, 16, 20); int imm = bits (insn, 0, 15); m_uint32_t val = sign_extend (imm, 16); // printf("rs %d rt %d val %d \n",rs,rt,val); /* TODO: Exception handling */ x86_mov_reg_imm (b->jit_ptr, X86_EAX, val); x86_alu_reg_membase (b->jit_ptr, X86_ADD, X86_EAX, X86_EDI, REG_OFFSET (rs)); x86_mov_membase_reg (b->jit_ptr, X86_EDI, REG_OFFSET (rt), X86_EAX, 4); return (0); } /* ADDu */ static int mips_emit_addu (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { int rs = bits (insn, 21, 25); int rt = bits (insn, 16, 20); int rd = bits (insn, 11, 15); // printf("rs %d rt %d rd %d \n",rs,rt,rd); x86_mov_reg_membase (b->jit_ptr, X86_EAX, X86_EDI, REG_OFFSET (rs), 4); x86_alu_reg_membase (b->jit_ptr, X86_ADD, X86_EAX, X86_EDI, REG_OFFSET (rt)); x86_mov_membase_reg (b->jit_ptr, X86_EDI, REG_OFFSET (rd), X86_EAX, 4); return (0); } /* AND */ static int mips_emit_and (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { int rs = bits (insn, 21, 25); int rt = bits (insn, 16, 20); int rd = bits (insn, 11, 15); x86_mov_reg_membase (b->jit_ptr, X86_EAX, X86_EDI, REG_OFFSET (rs), 4); x86_alu_reg_membase (b->jit_ptr, X86_AND, X86_EAX, X86_EDI, REG_OFFSET (rt)); x86_mov_membase_reg (b->jit_ptr, X86_EDI, REG_OFFSET (rd), X86_EAX, 4); return (0); } /* ANDI */ static int mips_emit_andi (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { int rs = bits (insn, 21, 25); int rt = bits (insn, 16, 20); int imm = bits (insn, 0, 15); x86_mov_reg_imm (b->jit_ptr, X86_EAX, imm); x86_alu_reg_membase (b->jit_ptr, X86_AND, X86_EAX, X86_EDI, REG_OFFSET (rs)); x86_mov_membase_reg (b->jit_ptr, X86_EDI, REG_OFFSET (rt), X86_EAX, 4); return (0); } static int mips_emit_bcond (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { uint16_t special_func = bits (insn, 16, 20); return mips_bcond_jit[special_func].emit_func (cpu, b, insn); } /* Hi yajin, why we need call mips_jit_fetch_and_emit twice? Why do we translate beq like this: mips_jit_fetch_and_emit(cpu,b,1); x86_mov_reg_membase(b->jit_ptr,X86_EAX,X86_EDI,REG_OFFSET(rs),4); x86_alu_reg_membase(b->jit_ptr,X86_CMP,X86_EAX,X86_EDI,REG_OFFSET(rt)); test1 = b->jit_ptr; x86_branch32(b->jit_ptr, X86_CC_NE, 0, 1); mips_set_jump(cpu,b,new_pc,1); x86_patch(test1,b->jit_ptr); That is fetching the delay slot code first and then jumping to new pc according to the comparing result of register rs and register rt. This seems right but it is wrong and not easy to catch this bug!!! The instruction in delay slot may change the content of register rs and rt and the comparing result can not be trusted anymore. We MUST compare register rs and rt and then run the code in delay slot. */ /* BEQ (Branch On Equal) */ static int mips_emit_beq (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { int rs = bits (insn, 21, 25); int rt = bits (insn, 16, 20); int offset = bits (insn, 0, 15); u_char *test1; m_va_t new_pc; /* compute the new pc */ new_pc = b->start_pc + (b->mips_trans_pos << 2); new_pc += sign_extend (offset << 2, 18); /* * compare gpr[rs] and gpr[rt]. * compare the low 32 bits first (higher probability). */ x86_mov_reg_membase (b->jit_ptr, X86_EAX, X86_EDI, REG_OFFSET (rs), 4); x86_alu_reg_membase (b->jit_ptr, X86_CMP, X86_EAX, X86_EDI, REG_OFFSET (rt)); test1 = b->jit_ptr; x86_branch32 (b->jit_ptr, X86_CC_NE, 0, 1); /* insert the instruction in the delay slot */ mips_jit_fetch_and_emit (cpu, b, 2); /* set the new pc in cpu structure */ mips_set_jump (cpu, b, new_pc, 1); x86_patch (test1, b->jit_ptr); /* if the branch is not taken, we have to execute the delay slot too */ mips_jit_fetch_and_emit (cpu, b, 1); return (0); } /* BEQL (Branch On Equal Likely) */ static int mips_emit_beql (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { int rs = bits (insn, 21, 25); int rt = bits (insn, 16, 20); int offset = bits (insn, 0, 15); u_char *test1; m_va_t new_pc; /* compute the new pc */ new_pc = b->start_pc + (b->mips_trans_pos << 2); new_pc += sign_extend (offset << 2, 18); /* * compare gpr[rs] and gpr[rt]. * compare the low 32 bits first (higher probability). */ x86_mov_reg_membase (b->jit_ptr, X86_EAX, X86_EDI, REG_OFFSET (rs), 4); x86_alu_reg_membase (b->jit_ptr, X86_CMP, X86_EAX, X86_EDI, REG_OFFSET (rt)); test1 = b->jit_ptr; x86_branch32 (b->jit_ptr, X86_CC_NE, 0, 1); /* insert the instruction in the delay slot */ mips_jit_fetch_and_emit (cpu, b, 1); /* set the new pc in cpu structure */ mips_set_jump (cpu, b, new_pc, 1); x86_patch (test1, b->jit_ptr); return (0); } /* BGEZ (Branch On Greater or Equal Than Zero) */ static int mips_emit_bgez (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { int rs = bits (insn, 21, 25); int offset = bits (insn, 0, 15); u_char *test1; m_va_t new_pc; /* compute the new pc */ new_pc = b->start_pc + (b->mips_trans_pos << 2); new_pc += sign_extend (offset << 2, 18); /* If sign bit is set, don't take the branch */ x86_mov_reg_membase (b->jit_ptr, X86_EAX, X86_EDI, REG_OFFSET (rs), 4); x86_test_reg_reg (b->jit_ptr, X86_EAX, X86_EAX); test1 = b->jit_ptr; x86_branch32 (b->jit_ptr, X86_CC_S, 0, 1); /* insert the instruction in the delay slot */ mips_jit_fetch_and_emit (cpu, b, 2); /* set the new pc in cpu structure */ mips_set_jump (cpu, b, new_pc, 1); x86_patch (test1, b->jit_ptr); /* if the branch is not taken, we have to execute the delay slot too */ mips_jit_fetch_and_emit (cpu, b, 1); return (0); } /* BGEZAL (Branch On Greater or Equal Than Zero And Link) */ static int mips_emit_bgezal (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { int rs = bits (insn, 21, 25); int offset = bits (insn, 0, 15); u_char *test1; m_va_t new_pc; /* compute the new pc */ new_pc = b->start_pc + (b->mips_trans_pos << 2); new_pc += sign_extend (offset << 2, 18); /* set the return address (instruction after the delay slot) */ mips_set_ra (b, b->start_pc + ((b->mips_trans_pos + 1) << 2)); /* If sign bit is set, don't take the branch */ x86_mov_reg_membase (b->jit_ptr, X86_EAX, X86_EDI, REG_OFFSET (rs), 4); x86_test_reg_reg (b->jit_ptr, X86_EAX, X86_EAX); test1 = b->jit_ptr; x86_branch32 (b->jit_ptr, X86_CC_S, 0, 1); /* insert the instruction in the delay slot */ mips_jit_fetch_and_emit (cpu, b, 2); /* set the new pc in cpu structure */ mips_set_jump (cpu, b, new_pc, 1); x86_patch (test1, b->jit_ptr); /* if the branch is not taken, we have to execute the delay slot too */ mips_jit_fetch_and_emit (cpu, b, 1); return (0); } /* BGEZALL (Branch On Greater or Equal Than Zero and Link Likely) */ static int mips_emit_bgezall (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { int rs = bits (insn, 21, 25); int offset = bits (insn, 0, 15); u_char *test1; m_va_t new_pc; /* compute the new pc */ new_pc = b->start_pc + (b->mips_trans_pos << 2); new_pc += sign_extend (offset << 2, 18); /* set the return address (instruction after the delay slot) */ mips_set_ra (b, b->start_pc + ((b->mips_trans_pos + 1) << 2)); /* if sign bit is set, don't take the branch */ x86_mov_reg_membase (b->jit_ptr, X86_EAX, X86_EDI, REG_OFFSET (rs), 4); x86_test_reg_reg (b->jit_ptr, X86_EAX, X86_EAX); test1 = b->jit_ptr; x86_branch32 (b->jit_ptr, X86_CC_S, 0, 1); /* insert the instruction in the delay slot */ mips_jit_fetch_and_emit (cpu, b, 1); /* set the new pc in cpu structure */ mips_set_jump (cpu, b, new_pc, 1); x86_patch (test1, b->jit_ptr); return (0); } /* BGEZL (Branch On Greater or Equal Than Zero Likely) */ static int mips_emit_bgezl (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { int rs = bits (insn, 21, 25); int offset = bits (insn, 0, 15); u_char *test1; m_va_t new_pc; /* compute the new pc */ new_pc = b->start_pc + (b->mips_trans_pos << 2); new_pc += sign_extend (offset << 2, 18); /* if sign bit is set, don't take the branch */ x86_mov_reg_membase (b->jit_ptr, X86_EAX, X86_EDI, REG_OFFSET (rs), 4); x86_test_reg_reg (b->jit_ptr, X86_EAX, X86_EAX); test1 = b->jit_ptr; x86_branch32 (b->jit_ptr, X86_CC_S, 0, 1); /* insert the instruction in the delay slot */ mips_jit_fetch_and_emit (cpu, b, 1); /* set the new pc in cpu structure */ mips_set_jump (cpu, b, new_pc, 1); x86_patch (test1, b->jit_ptr); return (0); } /* BGTZ (Branch On Greater Than Zero) */ static int mips_emit_bgtz (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { int rs = bits (insn, 21, 25); int offset = bits (insn, 0, 15); u_char *test1, *test2; m_va_t new_pc; /* compute the new pc */ new_pc = b->start_pc + (b->mips_trans_pos << 2); new_pc += sign_extend (offset << 2, 18); x86_mov_reg_membase (b->jit_ptr, X86_EAX, X86_EDI, REG_OFFSET (rs), 4); x86_test_reg_reg (b->jit_ptr, X86_EAX, X86_EAX); /*goto end if <0 */ test1 = b->jit_ptr; x86_branch32 (b->jit_ptr, X86_CC_S, 0, 1); /*goto end if =0 */ test2 = b->jit_ptr; x86_branch32 (b->jit_ptr, X86_CC_Z, 0, 1); /* here, we take the branch */ //x86_patch(test2,b->jit_ptr); /* insert the instruction in the delay slot */ mips_jit_fetch_and_emit (cpu, b, 2); /* set the new pc in cpu structure */ mips_set_jump (cpu, b, new_pc, 1); x86_patch (test1, b->jit_ptr); x86_patch (test2, b->jit_ptr); /* if the branch is not taken, we have to execute the delay slot too */ mips_jit_fetch_and_emit (cpu, b, 1); return (0); } /* BGTZL (Branch On Greater Than Zero Likely) */ static int mips_emit_bgtzl (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { int rs = bits (insn, 21, 25); int offset = bits (insn, 0, 15); u_char *test1, *test2; m_va_t new_pc; /* compute the new pc */ new_pc = b->start_pc + (b->mips_trans_pos << 2); new_pc += sign_extend (offset << 2, 18); x86_mov_reg_membase (b->jit_ptr, X86_EAX, X86_EDI, REG_OFFSET (rs), 4); x86_test_reg_reg (b->jit_ptr, X86_EAX, X86_EAX); /*goto end if <0 */ test1 = b->jit_ptr; x86_branch32 (b->jit_ptr, X86_CC_S, 0, 1); /*goto end if =0 */ test2 = b->jit_ptr; x86_branch32 (b->jit_ptr, X86_CC_Z, 0, 1); /* here, we take the branch */ // x86_patch(test2,b->jit_ptr); /* insert the instruction in the delay slot */ mips_jit_fetch_and_emit (cpu, b, 1); /* set the new pc in cpu structure */ mips_set_jump (cpu, b, new_pc, 1); x86_patch (test1, b->jit_ptr); x86_patch (test2, b->jit_ptr); return (0); } /* BLEZ (Branch On Less or Equal Than Zero) */ static int mips_emit_blez (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { int rs = bits (insn, 21, 25); int offset = bits (insn, 0, 15); u_char *test1, *test2; m_va_t new_pc; /* compute the new pc */ new_pc = b->start_pc + (b->mips_trans_pos << 2); new_pc += sign_extend (offset << 2, 18); x86_mov_reg_membase (b->jit_ptr, X86_EAX, X86_EDI, REG_OFFSET (rs), 4); x86_test_reg_reg (b->jit_ptr, X86_EAX, X86_EAX); /*if <0, take the branch */ test1 = b->jit_ptr; x86_branch32 (b->jit_ptr, X86_CC_S, 0, 1); /*else if !=0, do not take the branch */ test2 = b->jit_ptr; x86_branch32 (b->jit_ptr, X86_CC_NZ, 0, 1); /* here, we take the branch */ x86_patch (test1, b->jit_ptr); /* insert the instruction in the delay slot */ mips_jit_fetch_and_emit (cpu, b, 2); /* set the new pc in cpu structure */ mips_set_jump (cpu, b, new_pc, 1); x86_patch (test2, b->jit_ptr); /* if the branch is not taken, we have to execute the delay slot too */ mips_jit_fetch_and_emit (cpu, b, 1); return (0); } /* BLEZL (Branch On Less or Equal Than Zero Likely) */ static int mips_emit_blezl (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { int rs = bits (insn, 21, 25); int offset = bits (insn, 0, 15); u_char *test1, *test2; m_va_t new_pc; /* compute the new pc */ new_pc = b->start_pc + (b->mips_trans_pos << 2); new_pc += sign_extend (offset << 2, 18); x86_mov_reg_membase (b->jit_ptr, X86_EAX, X86_EDI, REG_OFFSET (rs), 4); x86_test_reg_reg (b->jit_ptr, X86_EAX, X86_EAX); /*if <0, take the branch */ test1 = b->jit_ptr; x86_branch32 (b->jit_ptr, X86_CC_S, 0, 1); /*else if !=0, do not take the branch */ test2 = b->jit_ptr; x86_branch32 (b->jit_ptr, X86_CC_NZ, 0, 1); /* here, we take the branch */ x86_patch (test1, b->jit_ptr); /* insert the instruction in the delay slot */ mips_jit_fetch_and_emit (cpu, b, 1); /* set the new pc in cpu structure */ mips_set_jump (cpu, b, new_pc, 1); x86_patch (test2, b->jit_ptr); return (0); } /* BLTZ (Branch On Less Than Zero) */ static int mips_emit_bltz (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { int rs = bits (insn, 21, 25); int offset = bits (insn, 0, 15); u_char *test1; m_va_t new_pc; /* compute the new pc */ new_pc = b->start_pc + (b->mips_trans_pos << 2); new_pc += sign_extend (offset << 2, 18); /* * test the sign bit of gpr[rs], if set, take the branch. */ x86_mov_reg_membase (b->jit_ptr, X86_EAX, X86_EDI, REG_OFFSET (rs), 4); x86_test_reg_reg (b->jit_ptr, X86_EAX, X86_EAX); test1 = b->jit_ptr; x86_branch32 (b->jit_ptr, X86_CC_NS, 0, 1); /* insert the instruction in the delay slot */ mips_jit_fetch_and_emit (cpu, b, 2); /* set the new pc in cpu structure */ mips_set_jump (cpu, b, new_pc, 1); x86_patch (test1, b->jit_ptr); /* if the branch is not taken, we have to execute the delay slot too */ mips_jit_fetch_and_emit (cpu, b, 1); return (0); } /* BLTZAL (Branch On Less Than Zero And Link) */ static int mips_emit_bltzal (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { int rs = bits (insn, 21, 25); int offset = bits (insn, 0, 15); u_char *test1; m_va_t new_pc; /* compute the new pc */ new_pc = b->start_pc + (b->mips_trans_pos << 2); new_pc += sign_extend (offset << 2, 18); /* set the return address (instruction after the delay slot) */ mips_set_ra (b, b->start_pc + ((b->mips_trans_pos + 1) << 2)); /* * test the sign bit of gpr[rs], if set, take the branch. */ x86_mov_reg_membase (b->jit_ptr, X86_EAX, X86_EDI, REG_OFFSET (rs), 4); x86_test_reg_reg (b->jit_ptr, X86_EAX, X86_EAX); test1 = b->jit_ptr; x86_branch32 (b->jit_ptr, X86_CC_NS, 0, 1); /* insert the instruction in the delay slot */ mips_jit_fetch_and_emit (cpu, b, 2); /* set the new pc in cpu structure */ mips_set_jump (cpu, b, new_pc, 1); x86_patch (test1, b->jit_ptr); /* if the branch is not taken, we have to execute the delay slot too */ mips_jit_fetch_and_emit (cpu, b, 1); return (0); } /* BLTZALL (Branch On Less Than Zero And Link Likely) */ static int mips_emit_bltzall (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { int rs = bits (insn, 21, 25); int offset = bits (insn, 0, 15); u_char *test1; m_va_t new_pc; /* compute the new pc */ new_pc = b->start_pc + (b->mips_trans_pos << 2); new_pc += sign_extend (offset << 2, 18); /* set the return address (instruction after the delay slot) */ mips_set_ra (b, b->start_pc + ((b->mips_trans_pos + 1) << 2)); /* * test the sign bit of gpr[rs], if set, take the branch. */ x86_mov_reg_membase (b->jit_ptr, X86_EAX, X86_EDI, REG_OFFSET (rs), 4); x86_test_reg_reg (b->jit_ptr, X86_EAX, X86_EAX); test1 = b->jit_ptr; x86_branch32 (b->jit_ptr, X86_CC_NS, 0, 1); /* insert the instruction in the delay slot */ mips_jit_fetch_and_emit (cpu, b, 1); /* set the new pc in cpu structure */ mips_set_jump (cpu, b, new_pc, 1); x86_patch (test1, b->jit_ptr); return (0); } /* BLTZL (Branch On Less Than Zero Likely) */ static int mips_emit_bltzl (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { int rs = bits (insn, 21, 25); int offset = bits (insn, 0, 15); u_char *test1; m_va_t new_pc; /* compute the new pc */ new_pc = b->start_pc + (b->mips_trans_pos << 2); new_pc += sign_extend (offset << 2, 18); /* * test the sign bit of gpr[rs], if set, take the branch. */ x86_mov_reg_membase (b->jit_ptr, X86_EAX, X86_EDI, REG_OFFSET (rs), 4); x86_test_reg_reg (b->jit_ptr, X86_EAX, X86_EAX); test1 = b->jit_ptr; x86_branch32 (b->jit_ptr, X86_CC_NS, 0, 1); /* insert the instruction in the delay slot */ mips_jit_fetch_and_emit (cpu, b, 1); /* set the new pc in cpu structure */ mips_set_jump (cpu, b, new_pc, 1); x86_patch (test1, b->jit_ptr); return (0); } /* BNE (Branch On Not Equal) */ static int mips_emit_bne (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { int rs = bits (insn, 21, 25); int rt = bits (insn, 16, 20); int offset = bits (insn, 0, 15); u_char *test2; m_va_t new_pc; /* compute the new pc */ new_pc = b->start_pc + (b->mips_trans_pos << 2); new_pc += sign_extend (offset << 2, 18); /* * compare gpr[rs] and gpr[rt]. * compare the low 32 bits first (higher probability). */ x86_mov_reg_membase (b->jit_ptr, X86_EAX, X86_EDI, REG_OFFSET (rs), 4); x86_alu_reg_membase (b->jit_ptr, X86_CMP, X86_EAX, X86_EDI, REG_OFFSET (rt)); test2 = b->jit_ptr; x86_branch32 (b->jit_ptr, X86_CC_E, 0, 1); /* insert the instruction in the delay slot */ mips_jit_fetch_and_emit (cpu, b, 2); /* set the new pc in cpu structure */ mips_set_jump (cpu, b, new_pc, 1); x86_patch (test2, b->jit_ptr); /* if the branch is not taken, we have to execute the delay slot too */ mips_jit_fetch_and_emit (cpu, b, 1); return (0); } /* BNEL (Branch On Not Equal Likely) */ static int mips_emit_bnel (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { int rs = bits (insn, 21, 25); int rt = bits (insn, 16, 20); int offset = bits (insn, 0, 15); u_char *test2; m_va_t new_pc; /* compute the new pc */ new_pc = b->start_pc + (b->mips_trans_pos << 2); new_pc += sign_extend (offset << 2, 18); /* * compare gpr[rs] and gpr[rt]. * compare the low 32 bits first (higher probability). */ x86_mov_reg_membase (b->jit_ptr, X86_EAX, X86_EDI, REG_OFFSET (rs), 4); x86_alu_reg_membase (b->jit_ptr, X86_CMP, X86_EAX, X86_EDI, REG_OFFSET (rt)); test2 = b->jit_ptr; x86_branch32 (b->jit_ptr, X86_CC_E, 0, 1); /* insert the instruction in the delay slot */ mips_jit_fetch_and_emit (cpu, b, 1); /* set the new pc in cpu structure */ mips_set_jump (cpu, b, new_pc, 1); x86_patch (test2, b->jit_ptr); return (0); } /* BREAK */ static int mips_emit_break (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { u_int code = bits (insn, 6, 25); //x86_alu_reg_imm(b->jit_ptr,X86_SUB,X86_ESP,12); x86_mov_reg_imm (b->jit_ptr, X86_EDX, code); x86_mov_reg_reg (b->jit_ptr, X86_EAX, X86_EDI, 4); mips_emit_basic_c_call (b, mips_exec_break); x86_alu_reg_imm (b->jit_ptr, X86_ADD, X86_ESP, 12); mips_jit_tcb_push_epilog (b); return (0); } /* CACHE */ static int mips_emit_cache (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { int base = bits (insn, 21, 25); int op = bits (insn, 16, 20); int offset = bits (insn, 0, 15); mips_emit_memop (b, MIPS_MEMOP_CACHE, base, offset, op, FALSE); return (0); } static int mips_emit_cfc0 (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { mips_emit_unknown (cpu, b, insn); return (0); } static int fastcall clz_emu (cpu_mips_t * cpu, mips_insn_t insn) { int rs = bits (insn, 21, 25); int rd = bits (insn, 11, 15); int i; m_uint32_t val; val = 32; for (i = 31; i >= 0; i--) { if (cpu->gpr[rs] & (1 << i)) { val = 31 - i; break; } } cpu->gpr[rd] = val; return (0); } static int mips_emit_clz (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { //x86_alu_reg_imm(b->jit_ptr,X86_SUB,X86_ESP,12); x86_mov_reg_imm (b->jit_ptr, X86_EDX, insn); x86_mov_reg_reg (b->jit_ptr, X86_EAX, X86_EDI, 4); mips_emit_basic_c_call (b, clz_emu); return (0); } static int mips_emit_cop0 (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { uint16_t special_func = bits (insn, 21, 25); return mips_cop0_jit[special_func].emit_func (cpu, b, insn); } static int mips_emit_cop1 (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { #if SOFT_FPU /* Save PC for exception handling */ mips_set_pc (b, b->start_pc + ((b->mips_trans_pos - 1) << 2)); x86_mov_reg_reg (b->jit_ptr, X86_EAX, X86_EDI, 4); mips_emit_basic_c_call (b, mips_exec_soft_fpu); mips_jit_tcb_push_epilog (b); return (0); #else mips_emit_unknown (cpu, b, insn); return (0); #endif } static int mips_emit_cop1x (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { #if SOFT_FPU /* Save PC for exception handling */ mips_set_pc (b, b->start_pc + ((b->mips_trans_pos - 1) << 2)); x86_mov_reg_reg (b->jit_ptr, X86_EAX, X86_EDI, 4); mips_emit_basic_c_call (b, mips_exec_soft_fpu); mips_jit_tcb_push_epilog (b); return (0); #else mips_emit_unknown (cpu, b, insn); return (0); #endif } static int mips_emit_cop2 (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { mips_emit_unknown (cpu, b, insn); return (0); } static int mips_emit_dadd (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { mips_emit_unknown (cpu, b, insn); return (0); } static int mips_emit_daddi (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { mips_emit_unknown (cpu, b, insn); return (0); } static int mips_emit_daddiu (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { mips_emit_unknown (cpu, b, insn); return (0); } static int mips_emit_daddu (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { mips_emit_unknown (cpu, b, insn); return (0); } static int mips_emit_ddiv (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { mips_emit_unknown (cpu, b, insn); return (0); } static int mips_emit_ddivu (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { mips_emit_unknown (cpu, b, insn); return (0); } static int mips_emit_div (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { int rs = bits (insn, 21, 25); int rt = bits (insn, 16, 20); /* eax = gpr[rs] */ x86_mov_reg_membase (b->jit_ptr, X86_EAX, X86_EDI, REG_OFFSET (rs), 4); x86_cdq (b->jit_ptr); /* ebx = gpr[rt] */ x86_mov_reg_membase (b->jit_ptr, X86_EBX, X86_EDI, REG_OFFSET (rt), 4); /* eax = quotient (LO), edx = remainder (HI) */ x86_div_reg (b->jit_ptr, X86_EBX, 1); /* store LO */ x86_mov_membase_reg (b->jit_ptr, X86_EDI, OFFSET (cpu_mips_t, lo), X86_EAX, 4); /* store HI */ x86_mov_membase_reg (b->jit_ptr, X86_EDI, OFFSET (cpu_mips_t, hi), X86_EDX, 4); return (0); } static int mips_emit_divu (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { int rs = bits (insn, 21, 25); int rt = bits (insn, 16, 20); /* eax = gpr[rs] */ x86_clear_reg (b->jit_ptr, X86_EDX); x86_mov_reg_membase (b->jit_ptr, X86_EAX, X86_EDI, REG_OFFSET (rs), 4); /* ebx = gpr[rt] */ x86_mov_reg_membase (b->jit_ptr, X86_EBX, X86_EDI, REG_OFFSET (rt), 4); /* eax = quotient (LO), edx = remainder (HI) */ x86_div_reg (b->jit_ptr, X86_EBX, 0); /* store LO */ x86_mov_membase_reg (b->jit_ptr, X86_EDI, OFFSET (cpu_mips_t, lo), X86_EAX, 4); /* store HI */ x86_mov_membase_reg (b->jit_ptr, X86_EDI, OFFSET (cpu_mips_t, hi), X86_EDX, 4); return (0); } static int mips_emit_dmfc0 (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { mips_emit_unknown (cpu, b, insn); return (0); } static int mips_emit_dmtc0 (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { mips_emit_unknown (cpu, b, insn); return (0); } static int mips_emit_dmult (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { mips_emit_unknown (cpu, b, insn); return (0); } static int mips_emit_dmultu (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { mips_emit_unknown (cpu, b, insn); return (0); } static int mips_emit_dsll (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { mips_emit_unknown (cpu, b, insn); return (0); } static int mips_emit_dsllv (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { mips_emit_unknown (cpu, b, insn); return (0); } static int mips_emit_dsrlv (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { mips_emit_unknown (cpu, b, insn); return (0); } static int mips_emit_dsrav (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { mips_emit_unknown (cpu, b, insn); return (0); } static int mips_emit_dsub (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { mips_emit_unknown (cpu, b, insn); return (0); } static int mips_emit_dsubu (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { mips_emit_unknown (cpu, b, insn); return (0); } static int mips_emit_dsrl (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { mips_emit_unknown (cpu, b, insn); return (0); } static int mips_emit_dsra (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { mips_emit_unknown (cpu, b, insn); return (0); } static int mips_emit_dsll32 (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { mips_emit_unknown (cpu, b, insn); return (0); } static int mips_emit_dsrl32 (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { mips_emit_unknown (cpu, b, insn); return (0); } static int mips_emit_dsra32 (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { mips_emit_unknown (cpu, b, insn); return (0); } static int mips_emit_eret (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { mips_set_pc (b, b->start_pc + ((b->mips_trans_pos - 1) << 2)); x86_mov_reg_reg (b->jit_ptr, X86_EAX, X86_EDI, 4); mips_emit_basic_c_call (b, mips_exec_eret); mips_jit_tcb_push_epilog (b); return (0); } /* J (Jump) */ static int mips_emit_j (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { u_int instr_index = bits (insn, 0, 25); m_va_t new_pc; /* compute the new pc */ new_pc = b->start_pc + (b->mips_trans_pos << 2); new_pc &= ~((1 << 28) - 1); new_pc |= instr_index << 2; /* insert the instruction in the delay slot */ mips_jit_fetch_and_emit (cpu, b, 1); /* set the new pc in cpu structure */ mips_set_jump (cpu, b, new_pc, 1); return (0); } static int mips_emit_jal (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { u_int instr_index = bits (insn, 0, 25); m_va_t new_pc, ret_pc; /* compute the new pc */ new_pc = b->start_pc + (b->mips_trans_pos << 2); new_pc &= ~((1 << 28) - 1); new_pc |= instr_index << 2; /* set the return address (instruction after the delay slot) */ ret_pc = b->start_pc + ((b->mips_trans_pos + 1) << 2); mips_set_ra (b, ret_pc); /* insert the instruction in the delay slot */ mips_jit_fetch_and_emit (cpu, b, 1); /* set the new pc in cpu structure */ mips_set_jump (cpu, b, new_pc, 0); return (0); } static int mips_emit_jalr (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { int rs = bits (insn, 21, 25); int rd = bits (insn, 11, 15); m_va_t ret_pc; /* set the return pc (instruction after the delay slot) in GPR[rd] */ ret_pc = b->start_pc + ((b->mips_trans_pos + 1) << 2); x86_mov_membase_imm (b->jit_ptr, X86_EDI, REG_OFFSET (rd), ret_pc, 4); /* get the new pc */ x86_mov_reg_membase (b->jit_ptr, X86_ECX, X86_EDI, REG_OFFSET (rs), 4); x86_mov_membase_reg (b->jit_ptr, X86_EDI, OFFSET (cpu_mips_t, ret_pc), X86_ECX, 4); /* insert the instruction in the delay slot */ mips_jit_fetch_and_emit (cpu, b, 1); /* set the new pc */ x86_mov_reg_membase (b->jit_ptr, X86_ECX, X86_EDI, OFFSET (cpu_mips_t, ret_pc), 4); x86_mov_membase_reg (b->jit_ptr, X86_EDI, OFFSET (cpu_mips_t, pc), X86_ECX, 4); /* returns to the caller which will determine the next path */ mips_jit_tcb_push_epilog (b); return (0); } static int mips_emit_jr (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { int rs = bits (insn, 21, 25); /* get the new pc */ x86_mov_reg_membase (b->jit_ptr, X86_ECX, X86_EDI, REG_OFFSET (rs), 4); x86_mov_membase_reg (b->jit_ptr, X86_EDI, OFFSET (cpu_mips_t, ret_pc), X86_ECX, 4); /* insert the instruction in the delay slot */ mips_jit_fetch_and_emit (cpu, b, 1); /* set the new pc */ x86_mov_reg_membase (b->jit_ptr, X86_ECX, X86_EDI, OFFSET (cpu_mips_t, ret_pc), 4); x86_mov_membase_reg (b->jit_ptr, X86_EDI, OFFSET (cpu_mips_t, pc), X86_ECX, 4); /* returns to the caller which will determine the next path */ mips_jit_tcb_push_epilog (b); return (0); } static int mips_emit_lb (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { int base = bits (insn, 21, 25); int rt = bits (insn, 16, 20); int offset = bits (insn, 0, 15); mips_emit_memop (b, MIPS_MEMOP_LB, base, offset, rt, TRUE); return (0); } static int mips_emit_lbu (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { int base = bits (insn, 21, 25); int rt = bits (insn, 16, 20); int offset = bits (insn, 0, 15); mips_emit_memop (b, MIPS_MEMOP_LBU, base, offset, rt, TRUE); return (0); } static int mips_emit_ld (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { mips_emit_unknown (cpu, b, insn); return (0); } static int mips_emit_ldc1 (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { mips_emit_unknown (cpu, b, insn); return (0); } static int mips_emit_ldc2 (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { mips_emit_unknown (cpu, b, insn); return (0); } static int mips_emit_ldl (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { mips_emit_unknown (cpu, b, insn); return (0); } static int mips_emit_ldr (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { mips_emit_unknown (cpu, b, insn); return (0); } static int mips_emit_lh (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { int base = bits (insn, 21, 25); int rt = bits (insn, 16, 20); int offset = bits (insn, 0, 15); mips_emit_memop (b, MIPS_MEMOP_LH, base, offset, rt, TRUE); return (0); } static int mips_emit_lhu (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { int base = bits (insn, 21, 25); int rt = bits (insn, 16, 20); int offset = bits (insn, 0, 15); mips_emit_memop (b, MIPS_MEMOP_LHU, base, offset, rt, TRUE); return (0); } static int mips_emit_ll (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { int base = bits (insn, 21, 25); int rt = bits (insn, 16, 20); int offset = bits (insn, 0, 15); mips_emit_memop (b, MIPS_MEMOP_LL, base, offset, rt, TRUE); return (0); } static int mips_emit_lld (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { mips_emit_unknown (cpu, b, insn); return (0); } static int mips_emit_lui (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { int rt = bits (insn, 16, 20); int imm = bits (insn, 0, 15); m_reg_t val = sign_extend (imm, 16) << 16; x86_mov_membase_imm (b->jit_ptr, X86_EDI, REG_OFFSET (rt), val, 4); return (0); } static int mips_emit_lw (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { int base = bits (insn, 21, 25); int rt = bits (insn, 16, 20); int offset = bits (insn, 0, 15); mips_emit_memop (b, MIPS_MEMOP_LW, base, offset, rt, TRUE); return (0); } static int mips_emit_lwc1 (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { #if SOFT_FPU /* Save PC for exception handling */ mips_set_pc (b, b->start_pc + ((b->mips_trans_pos - 1) << 2)); x86_mov_reg_reg (b->jit_ptr, X86_EAX, X86_EDI, 4); mips_emit_basic_c_call (b, mips_exec_soft_fpu); mips_jit_tcb_push_epilog (b); return (0); #else mips_emit_unknown (cpu, b, insn); return (0); #endif } static int mips_emit_lwc2 (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { mips_emit_unknown (cpu, b, insn); return (0); } static int mips_emit_lwl (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { int base = bits (insn, 21, 25); int rt = bits (insn, 16, 20); int offset = bits (insn, 0, 15); mips_emit_memop (b, MIPS_MEMOP_LWL, base, offset, rt, TRUE); return (0); } static int mips_emit_lwr (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { int base = bits (insn, 21, 25); int rt = bits (insn, 16, 20); int offset = bits (insn, 0, 15); mips_emit_memop (b, MIPS_MEMOP_LWR, base, offset, rt, TRUE); return (0); } static int mips_emit_lwu (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { int base = bits (insn, 21, 25); int rt = bits (insn, 16, 20); int offset = bits (insn, 0, 15); mips_emit_memop (b, MIPS_MEMOP_LWU, base, offset, rt, TRUE); return (0); } static int mips_emit_mad (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { int index = bits (insn, 0, 5); return mips_mad_jit[index].emit_func (cpu, b, insn); } static int fastcall madd_emu (cpu_mips_t * cpu, mips_insn_t insn) { int rs = bits (insn, 21, 25); int rt = bits (insn, 16, 20); m_int64_t val, temp; val = (m_int32_t) (m_int32_t) cpu->gpr[rs]; val *= (m_int32_t) (m_int32_t) cpu->gpr[rt]; temp = cpu->hi; temp = temp << 32; temp += cpu->lo; val += temp; cpu->lo = sign_extend (val, 32); cpu->hi = sign_extend (val >> 32, 32); return (0); } static int mips_emit_madd (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { //x86_alu_reg_imm(b->jit_ptr,X86_SUB,X86_ESP,12); x86_mov_reg_imm (b->jit_ptr, X86_EDX, insn); x86_mov_reg_reg (b->jit_ptr, X86_EAX, X86_EDI, 4); mips_emit_basic_c_call (b, madd_emu); return (0); } static int fastcall maddu_emu (cpu_mips_t * cpu, mips_insn_t insn) { int rs = bits (insn, 21, 25); int rt = bits (insn, 16, 20); m_int64_t val, temp; val = (m_uint32_t) (m_uint32_t) cpu->gpr[rs]; val *= (m_uint32_t) (m_uint32_t) cpu->gpr[rt]; temp = cpu->hi; temp = temp << 32; temp += cpu->lo; val += temp; cpu->lo = sign_extend (val, 32); cpu->hi = sign_extend (val >> 32, 32); return (0); } static int mips_emit_maddu (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { //x86_alu_reg_imm(b->jit_ptr,X86_SUB,X86_ESP,12); x86_mov_reg_imm (b->jit_ptr, X86_EDX, insn); x86_mov_reg_reg (b->jit_ptr, X86_EAX, X86_EDI, 4); mips_emit_basic_c_call (b, maddu_emu); return (0); } static int mips_emit_mfc0 (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { x86_mov_reg_imm (b->jit_ptr, X86_EDX, insn); x86_mov_reg_reg (b->jit_ptr, X86_EAX, X86_EDI, 4); mips_emit_basic_c_call (b, mips_cp0_exec_mfc0_fastcall); return (0); } static int mips_emit_mfhi (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { int rd = bits (insn, 11, 15); x86_mov_reg_membase (b->jit_ptr, X86_EAX, X86_EDI, OFFSET (cpu_mips_t, hi), 4); x86_mov_membase_reg (b->jit_ptr, X86_EDI, REG_OFFSET (rd), X86_EAX, 4); return (0); } static int mips_emit_mflo (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { int rd = bits (insn, 11, 15); x86_mov_reg_membase (b->jit_ptr, X86_EAX, X86_EDI, OFFSET (cpu_mips_t, lo), 4); x86_mov_membase_reg (b->jit_ptr, X86_EDI, REG_OFFSET (rd), X86_EAX, 4); return (0); } static int mips_emit_movc (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { mips_emit_unknown (cpu, b, insn); return (0); } static int mips_emit_movz (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { int rs = bits (insn, 21, 25); int rd = bits (insn, 11, 15); int rt = bits (insn, 16, 20); u_char *test1; x86_mov_reg_membase (b->jit_ptr, X86_EAX, X86_EDI, REG_OFFSET (rt), 4); x86_test_reg_reg (b->jit_ptr, X86_EAX, X86_EAX); /*goto end if !=0 */ test1 = b->jit_ptr; x86_branch32 (b->jit_ptr, X86_CC_NZ, 0, 1); x86_mov_reg_membase (b->jit_ptr, X86_EAX, X86_EDI, REG_OFFSET (rs), 4); x86_mov_membase_reg (b->jit_ptr, X86_EDI, REG_OFFSET (rd), X86_EAX, 4); x86_patch (test1, b->jit_ptr); return (0); } static int mips_emit_movn (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { int rs = bits (insn, 21, 25); int rd = bits (insn, 11, 15); int rt = bits (insn, 16, 20); u_char *test1; x86_mov_reg_membase (b->jit_ptr, X86_EAX, X86_EDI, REG_OFFSET (rt), 4); x86_test_reg_reg (b->jit_ptr, X86_EAX, X86_EAX); /*goto end if ==0 */ test1 = b->jit_ptr; x86_branch32 (b->jit_ptr, X86_CC_Z, 0, 1); x86_mov_reg_membase (b->jit_ptr, X86_EAX, X86_EDI, REG_OFFSET (rs), 4); x86_mov_membase_reg (b->jit_ptr, X86_EDI, REG_OFFSET (rd), X86_EAX, 4); x86_patch (test1, b->jit_ptr); return (0); } static int fastcall msub_emu (cpu_mips_t * cpu, mips_insn_t insn) { int rs = bits (insn, 21, 25); int rt = bits (insn, 16, 20); m_int64_t val, temp; val = (m_int32_t) (m_int32_t) cpu->gpr[rs]; val *= (m_int32_t) (m_int32_t) cpu->gpr[rt]; temp = cpu->hi; temp = temp << 32; temp += cpu->lo; temp -= val; //val += temp; cpu->lo = sign_extend (temp, 32); cpu->hi = sign_extend (temp >> 32, 32); return (0); } static int mips_emit_msub (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { //x86_alu_reg_imm(b->jit_ptr,X86_SUB,X86_ESP,12); x86_mov_reg_imm (b->jit_ptr, X86_EDX, insn); x86_mov_reg_reg (b->jit_ptr, X86_EAX, X86_EDI, 4); mips_emit_basic_c_call (b, msub_emu); return (0); } static int fastcall msubu_emu (cpu_mips_t * cpu, mips_insn_t insn) { int rs = bits (insn, 21, 25); int rt = bits (insn, 16, 20); m_int64_t val, temp; val = (m_uint32_t) (m_uint32_t) cpu->gpr[rs]; val *= (m_uint32_t) (m_uint32_t) cpu->gpr[rt]; temp = cpu->hi; temp = temp << 32; temp += cpu->lo; temp -= val; cpu->lo = sign_extend (temp, 32); cpu->hi = sign_extend (temp >> 32, 32); return (0); } static int mips_emit_msubu (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { //x86_alu_reg_imm(b->jit_ptr,X86_SUB,X86_ESP,12); x86_mov_reg_imm (b->jit_ptr, X86_EDX, insn); x86_mov_reg_reg (b->jit_ptr, X86_EAX, X86_EDI, 4); mips_emit_basic_c_call (b, msubu_emu); return (0); } static int mips_emit_mtc0 (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { x86_mov_reg_imm (b->jit_ptr, X86_EDX, insn); x86_mov_reg_reg (b->jit_ptr, X86_EAX, X86_EDI, 4); mips_emit_basic_c_call (b, mips_cp0_exec_mtc0_fastcall); return (0); } static fastcall int mthi_emu (cpu_mips_t * cpu, mips_insn_t insn) { int rs = bits (insn, 21, 25); cpu->hi = cpu->gpr[rs]; return (0); } static fastcall int mtlo_emu (cpu_mips_t * cpu, mips_insn_t insn) { int rs = bits (insn, 21, 25); cpu->lo = cpu->gpr[rs]; return (0); } static int mips_emit_mthi (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { //x86_alu_reg_imm(b->jit_ptr,X86_SUB,X86_ESP,12); x86_mov_reg_imm (b->jit_ptr, X86_EDX, insn); x86_mov_reg_reg (b->jit_ptr, X86_EAX, X86_EDI, 4); mips_emit_basic_c_call (b, mthi_emu); return (0); } static int mips_emit_mtlo (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { //x86_alu_reg_imm(b->jit_ptr,X86_SUB,X86_ESP,12); x86_mov_reg_imm (b->jit_ptr, X86_EDX, insn); x86_mov_reg_reg (b->jit_ptr, X86_EAX, X86_EDI, 4); mips_emit_basic_c_call (b, mtlo_emu); return (0); } /* MUL */ static int mips_emit_mul (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { int rs = bits (insn, 21, 25); int rt = bits (insn, 16, 20); int rd = bits (insn, 11, 15); x86_mov_reg_membase (b->jit_ptr, X86_EAX, X86_EDI, REG_OFFSET (rs), 4); x86_mov_reg_membase (b->jit_ptr, X86_EBX, X86_EDI, REG_OFFSET (rt), 4); x86_mul_reg (b->jit_ptr, X86_EBX, 1); /* store result in gpr[rd] */ x86_mov_membase_reg (b->jit_ptr, X86_EDI, REG_OFFSET (rd), X86_EAX, 4); return (0); } static int mips_emit_mult (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { int rs = bits (insn, 21, 25); int rt = bits (insn, 16, 20); x86_mov_reg_membase (b->jit_ptr, X86_EAX, X86_EDI, REG_OFFSET (rs), 4); x86_mov_reg_membase (b->jit_ptr, X86_EBX, X86_EDI, REG_OFFSET (rt), 4); x86_mul_reg (b->jit_ptr, X86_EBX, 1); /* store LO */ x86_mov_membase_reg (b->jit_ptr, X86_EDI, OFFSET (cpu_mips_t, lo), X86_EAX, 4); /* store HI */ x86_mov_membase_reg (b->jit_ptr, X86_EDI, OFFSET (cpu_mips_t, hi), X86_EDX, 4); return (0); } static int mips_emit_multu (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { int rs = bits (insn, 21, 25); int rt = bits (insn, 16, 20); x86_mov_reg_membase (b->jit_ptr, X86_EAX, X86_EDI, REG_OFFSET (rs), 4); x86_mov_reg_membase (b->jit_ptr, X86_EBX, X86_EDI, REG_OFFSET (rt), 4); x86_mul_reg (b->jit_ptr, X86_EBX, 0); /* store LO */ x86_mov_membase_reg (b->jit_ptr, X86_EDI, OFFSET (cpu_mips_t, lo), X86_EAX, 4); /* store HI */ x86_mov_membase_reg (b->jit_ptr, X86_EDI, OFFSET (cpu_mips_t, hi), X86_EDX, 4); return (0); } static int mips_emit_nor (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { int rs = bits (insn, 21, 25); int rt = bits (insn, 16, 20); int rd = bits (insn, 11, 15); x86_mov_reg_membase (b->jit_ptr, X86_EAX, X86_EDI, REG_OFFSET (rs), 4); x86_alu_reg_membase (b->jit_ptr, X86_OR, X86_EAX, X86_EDI, REG_OFFSET (rt)); x86_not_reg (b->jit_ptr, X86_EAX); x86_mov_membase_reg (b->jit_ptr, X86_EDI, REG_OFFSET (rd), X86_EAX, 4); return (0); } static int mips_emit_or (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { int rs = bits (insn, 21, 25); int rt = bits (insn, 16, 20); int rd = bits (insn, 11, 15); x86_mov_reg_membase (b->jit_ptr, X86_EAX, X86_EDI, REG_OFFSET (rs), 4); x86_alu_reg_membase (b->jit_ptr, X86_OR, X86_EAX, X86_EDI, REG_OFFSET (rt)); x86_mov_membase_reg (b->jit_ptr, X86_EDI, REG_OFFSET (rd), X86_EAX, 4); return (0); } static int mips_emit_ori (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { int rs = bits (insn, 21, 25); int rt = bits (insn, 16, 20); int imm = bits (insn, 0, 15); x86_mov_reg_imm (b->jit_ptr, X86_EAX, imm & 0xffff); x86_alu_reg_membase (b->jit_ptr, X86_OR, X86_EAX, X86_EDI, REG_OFFSET (rs)); x86_mov_membase_reg (b->jit_ptr, X86_EDI, REG_OFFSET (rt), X86_EAX, 4); return (0); } static int mips_emit_pref (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { return (0); } static int mips_emit_sb (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { int base = bits (insn, 21, 25); int rt = bits (insn, 16, 20); int offset = bits (insn, 0, 15); mips_emit_memop (b, MIPS_MEMOP_SB, base, offset, rt, TRUE); return (0); } static int mips_emit_sc (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { int base = bits (insn, 21, 25); int rt = bits (insn, 16, 20); int offset = bits (insn, 0, 15); mips_emit_memop (b, MIPS_MEMOP_SC, base, offset, rt, TRUE); return (0); } static int mips_emit_scd (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { mips_emit_unknown (cpu, b, insn); return (0); } static int mips_emit_sd (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { mips_emit_unknown (cpu, b, insn); return (0); } static int mips_emit_sdc1 (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { #if SOFT_FPU /* Save PC for exception handling */ mips_set_pc (b, b->start_pc + ((b->mips_trans_pos - 1) << 2)); x86_mov_reg_reg (b->jit_ptr, X86_EAX, X86_EDI, 4); mips_emit_basic_c_call (b, mips_exec_soft_fpu); mips_jit_tcb_push_epilog (b); return (0); #else mips_emit_unknown (cpu, b, insn); return (0); #endif } static int mips_emit_sdc2 (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { mips_emit_unknown (cpu, b, insn); return (0); } static int mips_emit_sdl (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { mips_emit_unknown (cpu, b, insn); return (0); } static int mips_emit_sdr (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { mips_emit_unknown (cpu, b, insn); return (0); } static int mips_emit_sh (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { int base = bits (insn, 21, 25); int rt = bits (insn, 16, 20); int offset = bits (insn, 0, 15); mips_emit_memop (b, MIPS_MEMOP_SH, base, offset, rt, TRUE); return (0); } static int mips_emit_sll (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { int rt = bits (insn, 16, 20); int rd = bits (insn, 11, 15); int sa = bits (insn, 6, 10); x86_mov_reg_membase (b->jit_ptr, X86_EAX, X86_EDI, REG_OFFSET (rt), 4); x86_shift_reg_imm (b->jit_ptr, X86_SHL, X86_EAX, sa); x86_mov_membase_reg (b->jit_ptr, X86_EDI, REG_OFFSET (rd), X86_EAX, 4); return (0); } static int mips_emit_sllv (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { int rs = bits (insn, 21, 25); int rt = bits (insn, 16, 20); int rd = bits (insn, 11, 15); x86_mov_reg_membase (b->jit_ptr, X86_ECX, X86_EDI, REG_OFFSET (rs), 4); x86_alu_reg_imm (b->jit_ptr, X86_AND, X86_ECX, 0x1f); x86_mov_reg_membase (b->jit_ptr, X86_EAX, X86_EDI, REG_OFFSET (rt), 4); x86_shift_reg (b->jit_ptr, X86_SHL, X86_EAX); x86_mov_membase_reg (b->jit_ptr, X86_EDI, REG_OFFSET (rd), X86_EAX, 4); return (0); } static int mips_emit_slt (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { int rs = bits (insn, 21, 25); int rt = bits (insn, 16, 20); int rd = bits (insn, 11, 15); u_char *test1; /* eax = gpr[rt] */ x86_mov_reg_membase (b->jit_ptr, X86_EAX, X86_EDI, REG_OFFSET (rt), 4); /* ecx = gpr[rs] */ x86_mov_reg_membase (b->jit_ptr, X86_ECX, X86_EDI, REG_OFFSET (rs), 4); /* we set rd to 1 when gpr[rs] < gpr[rt] */ x86_clear_reg (b->jit_ptr, X86_ESI); x86_mov_membase_reg (b->jit_ptr, X86_EDI, REG_OFFSET (rd), X86_ESI, 4); x86_alu_reg_reg (b->jit_ptr, X86_CMP, X86_ECX, X86_EAX); /* rs >= rt => end */ test1 = b->jit_ptr; x86_branch8 (b->jit_ptr, X86_CC_GE, 0, 1); x86_inc_membase (b->jit_ptr, X86_EDI, REG_OFFSET (rd)); /* end */ x86_patch (test1, b->jit_ptr); return (0); } static int mips_emit_slti (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { int rs = bits (insn, 21, 25); int rt = bits (insn, 16, 20); int imm = bits (insn, 0, 15); m_ireg_t val = sign_extend (imm, 16); u_char *test1; /* eax =val */ x86_mov_reg_imm (b->jit_ptr, X86_EAX, val); /* ecx = gpr[rs] */ x86_mov_reg_membase (b->jit_ptr, X86_ECX, X86_EDI, REG_OFFSET (rs), 4); /* we set rt to 1 when gpr[rs] < val */ x86_clear_reg (b->jit_ptr, X86_ESI); x86_mov_membase_reg (b->jit_ptr, X86_EDI, REG_OFFSET (rt), X86_ESI, 4); x86_alu_reg_reg (b->jit_ptr, X86_CMP, X86_ECX, X86_EAX); /* rs >= val => end */ test1 = b->jit_ptr; x86_branch8 (b->jit_ptr, X86_CC_GE, 0, 1); x86_inc_membase (b->jit_ptr, X86_EDI, REG_OFFSET (rt)); /* end */ x86_patch (test1, b->jit_ptr); return (0); } static int mips_emit_sltiu (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { int rs = bits (insn, 21, 25); int rt = bits (insn, 16, 20); int imm = bits (insn, 0, 15); m_reg_t val = sign_extend (imm, 16); u_char *test1; /* eax =val */ x86_mov_reg_imm (b->jit_ptr, X86_EAX, val); /* ecx = gpr[rs] */ x86_mov_reg_membase (b->jit_ptr, X86_ECX, X86_EDI, REG_OFFSET (rs), 4); /* we set rt to 1 when gpr[rs] < val */ x86_clear_reg (b->jit_ptr, X86_ESI); x86_mov_membase_reg (b->jit_ptr, X86_EDI, REG_OFFSET (rt), X86_ESI, 4); x86_alu_reg_reg (b->jit_ptr, X86_CMP, X86_ECX, X86_EAX); /* rs() >= val => end */ test1 = b->jit_ptr; x86_branch8 (b->jit_ptr, X86_CC_GE, 0, 0); x86_inc_membase (b->jit_ptr, X86_EDI, REG_OFFSET (rt)); /* end */ x86_patch (test1, b->jit_ptr); return (0); } static int mips_emit_sltu (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { int rs = bits (insn, 21, 25); int rt = bits (insn, 16, 20); int rd = bits (insn, 11, 15); u_char *test1; /* eax = gpr[rt] */ x86_mov_reg_membase (b->jit_ptr, X86_EAX, X86_EDI, REG_OFFSET (rt), 4); /* ecx = gpr[rs] */ x86_mov_reg_membase (b->jit_ptr, X86_ECX, X86_EDI, REG_OFFSET (rs), 4); /* we set rd to 1 when gpr[rs] < gpr[rt] */ x86_clear_reg (b->jit_ptr, X86_ESI); x86_mov_membase_reg (b->jit_ptr, X86_EDI, REG_OFFSET (rd), X86_ESI, 4); x86_alu_reg_reg (b->jit_ptr, X86_CMP, X86_ECX, X86_EAX); /* rs() >= rt(high) => end */ test1 = b->jit_ptr; x86_branch8 (b->jit_ptr, X86_CC_GE, 0, 0); x86_inc_membase (b->jit_ptr, X86_EDI, REG_OFFSET (rd)); /* end */ x86_patch (test1, b->jit_ptr); return (0); } static int mips_emit_spec (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { uint16_t special_func = bits (insn, 0, 5); return mips_spec_jit[special_func].emit_func (cpu, b, insn); } static int mips_emit_sra (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { int rt = bits (insn, 16, 20); int rd = bits (insn, 11, 15); int sa = bits (insn, 6, 10); x86_mov_reg_membase (b->jit_ptr, X86_EAX, X86_EDI, REG_OFFSET (rt), 4); x86_shift_reg_imm (b->jit_ptr, X86_SAR, X86_EAX, sa); x86_mov_membase_reg (b->jit_ptr, X86_EDI, REG_OFFSET (rd), X86_EAX, 4); return (0); } static int mips_emit_srav (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { int rs = bits (insn, 21, 25); int rt = bits (insn, 16, 20); int rd = bits (insn, 11, 15); x86_mov_reg_membase (b->jit_ptr, X86_ECX, X86_EDI, REG_OFFSET (rs), 4); x86_alu_reg_imm (b->jit_ptr, X86_AND, X86_ECX, 0x1f); x86_mov_reg_membase (b->jit_ptr, X86_EAX, X86_EDI, REG_OFFSET (rt), 4); x86_shift_reg (b->jit_ptr, X86_SAR, X86_EAX); x86_mov_membase_reg (b->jit_ptr, X86_EDI, REG_OFFSET (rd), X86_EAX, 4); return (0); } static int mips_emit_srl (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { int rt = bits (insn, 16, 20); int rd = bits (insn, 11, 15); int sa = bits (insn, 6, 10); x86_mov_reg_membase (b->jit_ptr, X86_EAX, X86_EDI, REG_OFFSET (rt), 4); x86_shift_reg_imm (b->jit_ptr, X86_SHR, X86_EAX, sa); x86_mov_membase_reg (b->jit_ptr, X86_EDI, REG_OFFSET (rd), X86_EAX, 4); return (0); } static int mips_emit_srlv (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { int rs = bits (insn, 21, 25); int rt = bits (insn, 16, 20); int rd = bits (insn, 11, 15); x86_mov_reg_membase (b->jit_ptr, X86_ECX, X86_EDI, REG_OFFSET (rs), 4); x86_alu_reg_imm (b->jit_ptr, X86_AND, X86_ECX, 0x1f); x86_mov_reg_membase (b->jit_ptr, X86_EAX, X86_EDI, REG_OFFSET (rt), 4); x86_shift_reg (b->jit_ptr, X86_SHR, X86_EAX); x86_mov_membase_reg (b->jit_ptr, X86_EDI, REG_OFFSET (rd), X86_EAX, 4); return (0); } static int mips_emit_sub (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { int rs = bits (insn, 21, 25); int rt = bits (insn, 16, 20); int rd = bits (insn, 11, 15); /* TODO: Exception handling */ x86_mov_reg_membase (b->jit_ptr, X86_EAX, X86_EDI, REG_OFFSET (rs), 4); x86_alu_reg_membase (b->jit_ptr, X86_SUB, X86_EAX, X86_EDI, REG_OFFSET (rt)); x86_mov_membase_reg (b->jit_ptr, X86_EDI, REG_OFFSET (rd), X86_EAX, 4); return (0); } static int mips_emit_subu (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { int rs = bits (insn, 21, 25); int rt = bits (insn, 16, 20); int rd = bits (insn, 11, 15); x86_mov_reg_membase (b->jit_ptr, X86_EAX, X86_EDI, REG_OFFSET (rs), 4); x86_alu_reg_membase (b->jit_ptr, X86_SUB, X86_EAX, X86_EDI, REG_OFFSET (rt)); x86_mov_membase_reg (b->jit_ptr, X86_EDI, REG_OFFSET (rd), X86_EAX, 4); return (0); } static int mips_emit_sw (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { int base = bits (insn, 21, 25); int rt = bits (insn, 16, 20); int offset = bits (insn, 0, 15); mips_emit_memop (b, MIPS_MEMOP_SW, base, offset, rt, TRUE); return (0); } static int mips_emit_swc1 (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { #if SOFT_FPU /* Save PC for exception handling */ mips_set_pc (b, b->start_pc + ((b->mips_trans_pos - 1) << 2)); x86_mov_reg_reg (b->jit_ptr, X86_EAX, X86_EDI, 4); mips_emit_basic_c_call (b, mips_exec_soft_fpu); mips_jit_tcb_push_epilog (b); return (0); #else mips_emit_unknown (cpu, b, insn); return (0); #endif } static int mips_emit_swc2 (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { mips_emit_unknown (cpu, b, insn); return (0); } static int mips_emit_swl (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { int base = bits (insn, 21, 25); int rt = bits (insn, 16, 20); int offset = bits (insn, 0, 15); mips_emit_memop (b, MIPS_MEMOP_SWL, base, offset, rt, TRUE); return (0); } static int mips_emit_swr (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { int base = bits (insn, 21, 25); int rt = bits (insn, 16, 20); int offset = bits (insn, 0, 15); mips_emit_memop (b, MIPS_MEMOP_SWR, base, offset, rt, TRUE); return (0); } static int mips_emit_sync (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { return (0); } static int mips_emit_syscall (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { mips_set_pc (b, b->start_pc + ((b->mips_trans_pos - 1) << 2)); x86_mov_reg_reg (b->jit_ptr, X86_EAX, X86_EDI, 4); mips_emit_basic_c_call (b, mips_exec_syscall); mips_jit_tcb_push_epilog (b); return (0); } static int mips_emit_teq (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { int rs = bits (insn, 21, 25); int rt = bits (insn, 16, 20); u_char *test1; /* Compare low part */ x86_mov_reg_membase (b->jit_ptr, X86_ECX, X86_EDI, REG_OFFSET (rs), 4); x86_alu_reg_membase (b->jit_ptr, X86_CMP, X86_ECX, X86_EDI, REG_OFFSET (rt)); test1 = b->jit_ptr; x86_branch32 (b->jit_ptr, X86_CC_NE, 0, 1); /* Generate trap exception */ x86_alu_reg_imm (b->jit_ptr, X86_SUB, X86_ESP, 12); x86_mov_reg_reg (b->jit_ptr, X86_EAX, X86_EDI, 4); mips_emit_c_call (b, mips_trigger_trap_exception); x86_alu_reg_imm (b->jit_ptr, X86_ADD, X86_ESP, 12); mips_jit_tcb_push_epilog (b); /* end */ x86_patch (test1, b->jit_ptr); return (0); } static int mips_emit_teqi (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { int rs = bits (insn, 21, 25); int imm = bits (insn, 0, 15); m_reg_t val = sign_extend (imm, 16); u_char *test1; /* edx:eax = val */ x86_mov_reg_imm (b->jit_ptr, X86_EAX, val); /* Compare low part */ x86_mov_reg_membase (b->jit_ptr, X86_ECX, X86_EDI, REG_OFFSET (rs), 4); x86_alu_reg_reg (b->jit_ptr, X86_CMP, X86_ECX, X86_EAX); test1 = b->jit_ptr; x86_branch32 (b->jit_ptr, X86_CC_NE, 0, 1); /* Generate trap exception */ x86_alu_reg_imm (b->jit_ptr, X86_SUB, X86_ESP, 12); x86_mov_reg_reg (b->jit_ptr, X86_EAX, X86_EDI, 4); mips_emit_c_call (b, mips_trigger_trap_exception); x86_alu_reg_imm (b->jit_ptr, X86_ADD, X86_ESP, 12); mips_jit_tcb_push_epilog (b); /* end */ x86_patch (test1, b->jit_ptr); return (0); } static int mips_emit_tlb (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { uint16_t func = bits (insn, 0, 5); return mips_tlb_jit[func].emit_func (cpu, b, insn); } static int mips_emit_tlbp (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { mips_set_pc (b, b->start_pc + ((b->mips_trans_pos - 1) << 2)); x86_mov_reg_reg (b->jit_ptr, X86_EAX, X86_EDI, 4); mips_emit_basic_c_call (b, mips_cp0_exec_tlbp); return (0); } static int mips_emit_tlbr (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { mips_set_pc (b, b->start_pc + ((b->mips_trans_pos - 1) << 2)); x86_mov_reg_reg (b->jit_ptr, X86_EAX, X86_EDI, 4); mips_emit_basic_c_call (b, mips_cp0_exec_tlbr); return (0); } static int mips_emit_tlbwi (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { mips_set_pc (b, b->start_pc + ((b->mips_trans_pos - 1) << 2)); x86_mov_reg_reg (b->jit_ptr, X86_EAX, X86_EDI, 4); mips_emit_basic_c_call (b, mips_cp0_exec_tlbwi); return (0); } static int mips_emit_tlbwr (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { mips_set_pc (b, b->start_pc + ((b->mips_trans_pos - 1) << 2)); x86_mov_reg_reg (b->jit_ptr, X86_EAX, X86_EDI, 4); mips_emit_basic_c_call (b, mips_cp0_exec_tlbwr); return (0); } static int mips_emit_tge (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { mips_emit_unknown (cpu, b, insn); return (0); } static int mips_emit_tgei (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { mips_emit_unknown (cpu, b, insn); return (0); } static int mips_emit_tgeu (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { mips_emit_unknown (cpu, b, insn); return (0); } static int mips_emit_tgeiu (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { mips_emit_unknown (cpu, b, insn); return (0); } static int mips_emit_tlt (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { mips_emit_unknown (cpu, b, insn); return (0); } static int mips_emit_tlti (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { mips_emit_unknown (cpu, b, insn); return (0); } static int mips_emit_tltiu (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { mips_emit_unknown (cpu, b, insn); return (0); } static int mips_emit_tltu (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { mips_emit_unknown (cpu, b, insn); return (0); } static int fastcall tne_emu (cpu_mips_t * cpu, mips_insn_t insn) { int rs = bits (insn, 21, 25); int rt = bits (insn, 16, 20); if ((m_ireg_t) cpu->gpr[rs] != (m_ireg_t) cpu->gpr[rt]) { /*take a trap */ mips_trigger_trap_exception (cpu); return (1); } else return (0); } static int mips_emit_tne (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { x86_mov_reg_imm (b->jit_ptr, X86_EDX, insn); x86_mov_reg_reg (b->jit_ptr, X86_EAX, X86_EDI, 4); mips_emit_basic_c_call (b, tne_emu); return (0); } static int mips_emit_tnei (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { mips_emit_unknown (cpu, b, insn); return (0); } static int mips_emit_wait (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { return (0); } static int mips_emit_xor (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { int rs = bits (insn, 21, 25); int rt = bits (insn, 16, 20); int rd = bits (insn, 11, 15); x86_mov_reg_membase (b->jit_ptr, X86_EAX, X86_EDI, REG_OFFSET (rs), 4); x86_alu_reg_membase (b->jit_ptr, X86_XOR, X86_EAX, X86_EDI, REG_OFFSET (rt)); x86_mov_membase_reg (b->jit_ptr, X86_EDI, REG_OFFSET (rd), X86_EAX, 4); return (0); } static int mips_emit_xori (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { int rs = bits (insn, 21, 25); int rt = bits (insn, 16, 20); int imm = bits (insn, 0, 15); x86_mov_reg_imm (b->jit_ptr, X86_EAX, imm); x86_alu_reg_membase (b->jit_ptr, X86_XOR, X86_EAX, X86_EDI, REG_OFFSET (rs)); x86_mov_membase_reg (b->jit_ptr, X86_EDI, REG_OFFSET (rt), X86_EAX, 4); return (0); } static int mips_emit_undef (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { mips_emit_unknown (cpu, b, insn); return (0); } static int mips_emit_unknownBcond (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { mips_emit_unknown (cpu, b, insn); return (0); } static int mips_emit_unknowncop0 (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { mips_emit_unknown (cpu, b, insn); return (0); } static int mips_emit_unknownmad (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { mips_emit_unknown (cpu, b, insn); return (0); } static int mips_emit_unknownSpec (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { mips_emit_unknown (cpu, b, insn); return (0); } static int mips_emit_unknowntlb (cpu_mips_t * cpu, mips_jit_tcb_t * b, unsigned int insn) { mips_emit_unknown (cpu, b, insn); return (0); } /*instruction table*/ struct mips_jit_desc mips_jit[] = { {"spec", mips_emit_spec, 0x00, 0x99}, {"bcond", mips_emit_bcond, 0x01, 0x99}, {"j", mips_emit_j, 0x02, 0x0}, {"jal", mips_emit_jal, 0x03, 0x0}, {"beq", mips_emit_beq, 0x04, 0x0}, {"bne", mips_emit_bne, 0x05, 0x0}, {"blez", mips_emit_blez, 0x06, 0x0}, {"bgtz", mips_emit_bgtz, 0x07, 0x0}, {"addi", mips_emit_addi, 0x08, 0x1}, {"addiu", mips_emit_addiu, 0x09, 0x1}, {"slti", mips_emit_slti, 0x0A, 0x1}, {"sltiu", mips_emit_sltiu, 0x0B, 0x1}, {"andi", mips_emit_andi, 0x0C, 0x1}, {"ori", mips_emit_ori, 0x0D, 0x1}, {"xori", mips_emit_xori, 0x0E, 0x1}, {"lui", mips_emit_lui, 0x0F, 0x1}, {"cop0", mips_emit_cop0, 0x10, 0x99}, {"cop1", mips_emit_cop1, 0x11, 0x1}, {"cop2", mips_emit_cop2, 0x12, 0x1}, {"cop1x", mips_emit_cop1x, 0x13, 0x1}, {"beql", mips_emit_beql, 0x14, 0x0}, {"bnel", mips_emit_bnel, 0x15, 0x0}, {"blezl", mips_emit_blezl, 0x16, 0x0}, {"bgtzl", mips_emit_bgtzl, 0x17, 0x0}, {"daddi", mips_emit_daddi, 0x18, 0x1}, {"daddiu", mips_emit_daddiu, 0x19, 0x1}, {"ldl", mips_emit_ldl, 0x1A, 0x1}, {"ldr", mips_emit_ldr, 0x1B, 0x1}, {"undef", mips_emit_mad, 0x1C, 0x99}, {"undef", mips_emit_undef, 0x1D, 0x1}, {"undef", mips_emit_undef, 0x1E, 0x1}, {"undef", mips_emit_undef, 0x1F, 0x1}, {"lb", mips_emit_lb, 0x20, 0x1}, {"lh", mips_emit_lh, 0x21, 0x1}, {"lwl", mips_emit_lwl, 0x22, 0x1}, {"lw", mips_emit_lw, 0x23, 0x1}, {"lbu", mips_emit_lbu, 0x24, 0x1}, {"lhu", mips_emit_lhu, 0x25, 0x1}, {"lwr", mips_emit_lwr, 0x26, 0x1}, {"lwu", mips_emit_lwu, 0x27, 0x1}, {"sb", mips_emit_sb, 0x28, 0x1}, {"sh", mips_emit_sh, 0x29, 0x1}, {"swl", mips_emit_swl, 0x2A, 0x1}, {"sw", mips_emit_sw, 0x2B, 0x1}, {"sdl", mips_emit_sdl, 0x2C, 0x1}, {"sdr", mips_emit_sdr, 0x2D, 0x1}, {"swr", mips_emit_swr, 0x2E, 0x1}, {"cache", mips_emit_cache, 0x2F, 0x1}, {"ll", mips_emit_ll, 0x30, 0x1}, {"lwc1", mips_emit_lwc1, 0x31, 0x1}, {"lwc2", mips_emit_lwc2, 0x32, 0x1}, {"pref", mips_emit_pref, 0x33, 0x1}, {"lld", mips_emit_lld, 0x34, 0x1}, {"ldc1", mips_emit_ldc1, 0x35, 0x1}, {"ldc2", mips_emit_ldc2, 0x36, 0x1}, {"ld", mips_emit_ld, 0x37, 0x1}, {"sc", mips_emit_sc, 0x38, 0x1}, {"swc1", mips_emit_swc1, 0x39, 0x1}, {"swc2", mips_emit_swc2, 0x3A, 0x1}, {"undef", mips_emit_undef, 0x3B, 0x1}, {"scd", mips_emit_scd, 0x3C, 0x1}, {"sdc1", mips_emit_sdc1, 0x3D, 0x1}, {"sdc2", mips_emit_sdc2, 0x3E, 0x1}, {"sd", mips_emit_sd, 0x3F, 0x1}, }; /* Based on the func field of spec opcode */ static struct mips_jit_desc mips_spec_jit[] = { {"sll", mips_emit_sll, 0x00, 0x1}, {"movc", mips_emit_movc, 0x01, 0x1}, {"srl", mips_emit_srl, 0x02, 0x1}, {"sra", mips_emit_sra, 0x03, 0x1}, {"sllv", mips_emit_sllv, 0x04, 0x1}, {"unknownSpec", mips_emit_unknownSpec, 0x05, 0x1}, {"srlv", mips_emit_srlv, 0x06, 0x1}, {"srav", mips_emit_srav, 0x07, 0x1}, {"jr", mips_emit_jr, 0x08, 0x0}, {"jalr", mips_emit_jalr, 0x09, 0x0}, {"movz", mips_emit_movz, 0x0A, 0x1}, {"movn", mips_emit_movn, 0x0B, 0x1}, {"syscall", mips_emit_syscall, 0x0C, 0x1}, {"break", mips_emit_break, 0x0D, 0x1}, {"spim", mips_emit_unknownSpec, 0x0E, 0x1}, {"sync", mips_emit_sync, 0x0F, 0x1}, {"mfhi", mips_emit_mfhi, 0x10, 0x1}, {"mthi", mips_emit_mthi, 0x11, 0x1}, {"mflo", mips_emit_mflo, 0x12, 0x1}, {"mtlo", mips_emit_mtlo, 0x13, 0x1}, {"dsllv", mips_emit_dsllv, 0x14, 0x1}, {"unknownSpec", mips_emit_unknownSpec, 0x15, 0x1}, {"dsrlv", mips_emit_dsrlv, 0x16, 0x1}, {"dsrav", mips_emit_dsrav, 0x17, 0x1}, {"mult", mips_emit_mult, 0x18, 0x1}, {"multu", mips_emit_multu, 0x19, 0x1}, {"div", mips_emit_div, 0x1A, 0x1}, {"divu", mips_emit_divu, 0x1B, 0x1}, {"dmult", mips_emit_dmult, 0x1C, 0x1}, {"dmultu", mips_emit_dmultu, 0x1D, 0x1}, {"ddiv", mips_emit_ddiv, 0x1E, 0x1}, {"ddivu", mips_emit_ddivu, 0x1F, 0x1}, {"add", mips_emit_add, 0x20, 0x1}, {"addu", mips_emit_addu, 0x21, 0x1}, {"sub", mips_emit_sub, 0x22, 0x1}, {"subu", mips_emit_subu, 0x23, 0x1}, {"and", mips_emit_and, 0x24, 0x1}, {"or", mips_emit_or, 0x25, 0x1}, {"xor", mips_emit_xor, 0x26, 0x1}, {"nor", mips_emit_nor, 0x27, 0x1}, {"unknownSpec", mips_emit_unknownSpec, 0x28, 0x1}, {"unknownSpec", mips_emit_unknownSpec, 0x29, 0x1}, {"slt", mips_emit_slt, 0x2A, 0x1}, {"sltu", mips_emit_sltu, 0x2B, 0x1}, {"dadd", mips_emit_dadd, 0x2C, 0x1}, {"daddu", mips_emit_daddu, 0x2D, 0x1}, {"dsub", mips_emit_dsub, 0x2E, 0x1}, {"dsubu", mips_emit_dsubu, 0x2F, 0x1}, {"tge", mips_emit_tge, 0x30, 0x1}, {"tgeu", mips_emit_tgeu, 0x31, 0x1}, {"tlt", mips_emit_tlt, 0x32, 0x1}, {"tltu", mips_emit_tltu, 0x33, 0x1}, {"teq", mips_emit_teq, 0x34, 0x1}, {"unknownSpec", mips_emit_unknownSpec, 0x35, 0x1}, {"tne", mips_emit_tne, 0x36, 0x1}, {"unknownSpec", mips_emit_unknownSpec, 0x37, 0x1}, {"dsll", mips_emit_dsll, 0x38, 0x1}, {"unknownSpec", mips_emit_unknownSpec, 0x39, 0x1}, {"dsrl", mips_emit_dsrl, 0x3A, 0x1}, {"dsra", mips_emit_dsra, 0x3B, 0x1}, {"dsll32", mips_emit_dsll32, 0x3C, 0x1}, {"unknownSpec", mips_emit_unknownSpec, 0x3D, 0x1}, {"dsrl32", mips_emit_dsrl32, 0x3E, 0x1}, {"dsra32", mips_emit_dsra32, 0x3F, 0x1} }; /* Based on the rt field of bcond opcodes */ static struct mips_jit_desc mips_bcond_jit[] = { {"bltz", mips_emit_bltz, 0x00, 0x0}, {"bgez", mips_emit_bgez, 0x01, 0x0}, {"bltzl", mips_emit_bltzl, 0x02, 0x0}, {"bgezl", mips_emit_bgezl, 0x03, 0x0}, {"spimi", mips_emit_unknownBcond, 0x04, 0x0}, {"unknownBcond", mips_emit_unknownBcond, 0x05, 0x1}, {"unknownBcond", mips_emit_unknownBcond, 0x06, 0x1}, {"unknownBcond", mips_emit_unknownBcond, 0x07, 0x1}, {"tgei", mips_emit_tgei, 0x08, 0x1}, {"tgeiu", mips_emit_tgeiu, 0x09, 0x1}, {"tlti", mips_emit_tlti, 0x0A, 0x1}, {"tltiu", mips_emit_tltiu, 0x0B, 0x1}, {"teqi", mips_emit_teqi, 0x0C, 0x1}, {"unknownBcond", mips_emit_unknownBcond, 0x0D, 0x1}, {"tnei", mips_emit_tnei, 0x0E, 0x1}, {"unknownBcond", mips_emit_unknownBcond, 0x0F, 0x1}, {"bltzal", mips_emit_bltzal, 0x10, 0x0}, {"bgezal", mips_emit_bgezal, 0x11, 0x0}, {"bltzall", mips_emit_bltzall, 0x12, 0x0}, {"bgezall", mips_emit_bgezall, 0x13, 0x0}, {"unknownBcond", mips_emit_unknownBcond, 0x14, 0x1}, {"unknownBcond", mips_emit_unknownBcond, 0x15, 0x1}, {"unknownBcond", mips_emit_unknownBcond, 0x16, 0x1}, {"unknownBcond", mips_emit_unknownBcond, 0x17, 0x1}, {"unknownBcond", mips_emit_unknownBcond, 0x18, 0x1}, {"unknownBcond", mips_emit_unknownBcond, 0x19, 0x1}, {"unknownBcond", mips_emit_unknownBcond, 0x1A, 0x1}, {"unknownBcond", mips_emit_unknownBcond, 0x1B, 0x1}, {"unknownBcond", mips_emit_unknownBcond, 0x1C, 0x1}, {"unknownBcond", mips_emit_unknownBcond, 0x1D, 0x1}, {"unknownBcond", mips_emit_unknownBcond, 0x1E, 0x1}, {"unknownBcond", mips_emit_unknownBcond, 0x1F, 0x1} }; static struct mips_jit_desc mips_cop0_jit[] = { {"mfc0", mips_emit_mfc0, 0x0, 0x1}, {"dmfc0", mips_emit_dmfc0, 0x1, 0x1}, {"cfc0", mips_emit_cfc0, 0x2, 0x1}, {"unknowncop0", mips_emit_unknowncop0, 0x3, 0x1}, {"mtc0", mips_emit_mtc0, 0x4, 0x1}, {"dmtc0", mips_emit_dmtc0, 0x5, 0x1}, {"unknowncop0", mips_emit_unknowncop0, 0x6, 0x1}, {"unknowncop0", mips_emit_unknowncop0, 0x7, 0x1}, {"unknowncop0", mips_emit_unknowncop0, 0x8, 0x1}, {"unknowncop0", mips_emit_unknowncop0, 0x9, 0x1}, {"unknowncop0", mips_emit_unknowncop0, 0xa, 0x1}, {"unknowncop0", mips_emit_unknowncop0, 0xb, 0x1}, {"unknowncop0", mips_emit_unknowncop0, 0xc, 0x1}, {"unknowncop0", mips_emit_unknowncop0, 0xd, 0x1}, {"unknowncop0", mips_emit_unknowncop0, 0xe, 0x1}, {"unknowncop0", mips_emit_unknowncop0, 0xf, 0x1}, {"tlb", mips_emit_tlb, 0x10, 0x1}, {"unknowncop0", mips_emit_unknowncop0, 0x11, 0x1}, {"unknowncop0", mips_emit_unknowncop0, 0x12, 0x1}, {"unknowncop0", mips_emit_unknowncop0, 0x13, 0x1}, {"unknowncop0", mips_emit_unknowncop0, 0x14, 0x1}, {"unknowncop0", mips_emit_unknowncop0, 0x15, 0x1}, {"unknowncop0", mips_emit_unknowncop0, 0x16, 0x1}, {"unknowncop0", mips_emit_unknowncop0, 0x17, 0x1}, {"unknowncop0", mips_emit_unknowncop0, 0x18, 0x1}, {"unknowncop0", mips_emit_unknowncop0, 0x19, 0x1}, {"unknowncop0", mips_emit_unknowncop0, 0x1a, 0x1}, {"unknowncop0", mips_emit_unknowncop0, 0x1b, 0x1}, {"unknowncop0", mips_emit_unknowncop0, 0x1c, 0x1}, {"unknowncop0", mips_emit_unknowncop0, 0x1d, 0x1}, {"unknowncop0", mips_emit_unknowncop0, 0x1e, 0x1}, {"unknowncop0", mips_emit_unknowncop0, 0x1f, 0x1}, }; static struct mips_jit_desc mips_mad_jit[] = { {"mad", mips_emit_madd, 0x0, 0x1}, {"maddu", mips_emit_maddu, 0x1, 0x1}, {"mul", mips_emit_mul, 0x2, 0x1}, {"unknownmad_op", mips_emit_unknownmad, 0x3, 0x1}, {"msub", mips_emit_msub, 0x4, 0x1}, {"msubu", mips_emit_msubu, 0x5, 0x1}, {"unknownmad_op", mips_emit_unknownmad, 0x6, 0x1}, {"unknownmad_op", mips_emit_unknownmad, 0x7, 0x1}, {"unknownmad_op", mips_emit_unknownmad, 0x8, 0x1}, {"unknownmad_op", mips_emit_unknownmad, 0x9, 0x1}, {"unknownmad_op", mips_emit_unknownmad, 0xa, 0x1}, {"unknownmad_op", mips_emit_unknownmad, 0xb, 0x1}, {"unknownmad_op", mips_emit_unknownmad, 0xc, 0x1}, {"unknownmad_op", mips_emit_unknownmad, 0xd, 0x1}, {"unknownmad_op", mips_emit_unknownmad, 0xe, 0x1}, {"unknownmad_op", mips_emit_unknownmad, 0xf, 0x1}, {"unknownmad_op", mips_emit_unknownmad, 0x10, 0x1}, {"unknownmad_op", mips_emit_unknownmad, 0x11, 0x1}, {"unknownmad_op", mips_emit_unknownmad, 0x12, 0x1}, {"unknownmad_op", mips_emit_unknownmad, 0x13, 0x1}, {"unknownmad_op", mips_emit_unknownmad, 0x14, 0x1}, {"unknownmad_op", mips_emit_unknownmad, 0x15, 0x1}, {"unknownmad_op", mips_emit_unknownmad, 0x16, 0x1}, {"unknownmad_op", mips_emit_unknownmad, 0x17, 0x1}, {"unknownmad_op", mips_emit_unknownmad, 0x18, 0x1}, {"unknownmad_op", mips_emit_unknownmad, 0x19, 0x1}, {"unknownmad_op", mips_emit_unknownmad, 0x1a, 0x1}, {"unknownmad_op", mips_emit_unknownmad, 0x1b, 0x1}, {"unknownmad_op", mips_emit_unknownmad, 0x1c, 0x1}, {"unknownmad_op", mips_emit_unknownmad, 0x1d, 0x1}, {"unknownmad_op", mips_emit_unknownmad, 0x1e, 0x1}, {"unknownmad_op", mips_emit_unknownmad, 0x1f, 0x1}, {"clz", mips_emit_clz, 0x20, 0x1}, {"unknownmad_op", mips_emit_unknownmad, 0x21, 0x1}, {"unknownmad_op", mips_emit_unknownmad, 0x22, 0x1}, {"unknownmad_op", mips_emit_unknownmad, 0x23, 0x1}, {"unknownmad_op", mips_emit_unknownmad, 0x24, 0x1}, {"unknownmad_op", mips_emit_unknownmad, 0x25, 0x1}, {"unknownmad_op", mips_emit_unknownmad, 0x26, 0x1}, {"unknownmad_op", mips_emit_unknownmad, 0x27, 0x1}, {"unknownmad_op", mips_emit_unknownmad, 0x28, 0x1}, {"unknownmad_op", mips_emit_unknownmad, 0x29, 0x1}, {"unknownmad_op", mips_emit_unknownmad, 0x2a, 0x1}, {"unknownmad_op", mips_emit_unknownmad, 0x2b, 0x1}, {"unknownmad_op", mips_emit_unknownmad, 0x2c, 0x1}, {"unknownmad_op", mips_emit_unknownmad, 0x2d, 0x1}, {"unknownmad_op", mips_emit_unknownmad, 0x2e, 0x1}, {"unknownmad_op", mips_emit_unknownmad, 0x2f, 0x1}, {"unknownmad_op", mips_emit_unknownmad, 0x30, 0x1}, {"unknownmad_op", mips_emit_unknownmad, 0x31, 0x1}, {"unknownmad_op", mips_emit_unknownmad, 0x32, 0x1}, {"unknownmad_op", mips_emit_unknownmad, 0x33, 0x1}, {"unknownmad_op", mips_emit_unknownmad, 0x34, 0x1}, {"unknownmad_op", mips_emit_unknownmad, 0x35, 0x1}, {"unknownmad_op", mips_emit_unknownmad, 0x36, 0x1}, {"unknownmad_op", mips_emit_unknownmad, 0x37, 0x1}, {"unknownmad_op", mips_emit_unknownmad, 0x38, 0x1}, {"unknownmad_op", mips_emit_unknownmad, 0x39, 0x1}, {"unknownmad_op", mips_emit_unknownmad, 0x3a, 0x1}, {"unknownmad_op", mips_emit_unknownmad, 0x3b, 0x1}, {"unknownmad_op", mips_emit_unknownmad, 0x3c, 0x1}, {"unknownmad_op", mips_emit_unknownmad, 0x3d, 0x1}, {"unknownmad_op", mips_emit_unknownmad, 0x3e, 0x1}, {"unknownmad_op", mips_emit_unknownmad, 0x3f, 0x1}, }; static struct mips_jit_desc mips_tlb_jit[] = { {"unknowntlb_op", mips_emit_unknowntlb, 0x0, 0x1}, {"tlbr", mips_emit_tlbr, 0x1, 0x1}, {"tlbwi", mips_emit_tlbwi, 0x2, 0x1}, {"unknowntlb_op", mips_emit_unknowntlb, 0x3, 0x1}, {"unknowntlb_op", mips_emit_unknowntlb, 0x4, 0x1}, {"unknowntlb_op", mips_emit_unknowntlb, 0x5, 0x1}, {"tlbwi", mips_emit_tlbwr, 0x6, 0x1}, {"unknowntlb_op", mips_emit_unknowntlb, 0x7, 0x1}, {"tlbp", mips_emit_tlbp, 0x8, 0x1}, {"unknowntlb_op", mips_emit_unknowntlb, 0x9, 0x1}, {"unknowntlb_op", mips_emit_unknowntlb, 0xa, 0x1}, {"unknowntlb_op", mips_emit_unknowntlb, 0xb, 0x1}, {"unknowntlb_op", mips_emit_unknowntlb, 0xc, 0x1}, {"unknowntlb_op", mips_emit_unknowntlb, 0xd, 0x1}, {"unknowntlb_op", mips_emit_unknowntlb, 0xe, 0x1}, {"unknowntlb_op", mips_emit_unknowntlb, 0xf, 0x1}, {"unknowntlb_op", mips_emit_unknowntlb, 0x10, 0x1}, {"unknowntlb_op", mips_emit_unknowntlb, 0x11, 0x1}, {"unknowntlb_op", mips_emit_unknowntlb, 0x12, 0x1}, {"unknowntlb_op", mips_emit_unknowntlb, 0x13, 0x1}, {"unknowntlb_op", mips_emit_unknowntlb, 0x14, 0x1}, {"unknowntlb_op", mips_emit_unknowntlb, 0x15, 0x1}, {"unknowntlb_op", mips_emit_unknowntlb, 0x16, 0x1}, {"unknowntlb_op", mips_emit_unknowntlb, 0x17, 0x1}, {"eret", mips_emit_eret, 0x18, 0x1}, {"unknowntlb_op", mips_emit_unknowntlb, 0x19, 0x1}, {"unknowntlb_op", mips_emit_unknowntlb, 0x1a, 0x1}, {"unknowntlb_op", mips_emit_unknowntlb, 0x1b, 0x1}, {"unknowntlb_op", mips_emit_unknowntlb, 0x1c, 0x1}, {"unknowntlb_op", mips_emit_unknowntlb, 0x1d, 0x1}, {"unknowntlb_op", mips_emit_unknowntlb, 0x1e, 0x1}, {"unknowntlb_op", mips_emit_unknowntlb, 0x1f, 0x1}, {"wait", mips_emit_wait, 0x20, 0x1}, {"unknowntlb_op", mips_emit_unknowntlb, 0x21, 0x1}, {"unknowntlb_op", mips_emit_unknowntlb, 0x22, 0x1}, {"unknowntlb_op", mips_emit_unknowntlb, 0x23, 0x1}, {"unknowntlb_op", mips_emit_unknowntlb, 0x24, 0x1}, {"unknowntlb_op", mips_emit_unknowntlb, 0x25, 0x1}, {"unknowntlb_op", mips_emit_unknowntlb, 0x26, 0x1}, {"unknowntlb_op", mips_emit_unknowntlb, 0x27, 0x1}, {"unknowntlb_op", mips_emit_unknowntlb, 0x28, 0x1}, {"unknowntlb_op", mips_emit_unknowntlb, 0x29, 0x1}, {"unknowntlb_op", mips_emit_unknowntlb, 0x2a, 0x1}, {"unknowntlb_op", mips_emit_unknowntlb, 0x2b, 0x1}, {"unknowntlb_op", mips_emit_unknowntlb, 0x2c, 0x1}, {"unknowntlb_op", mips_emit_unknowntlb, 0x2d, 0x1}, {"unknowntlb_op", mips_emit_unknowntlb, 0x2e, 0x1}, {"unknowntlb_op", mips_emit_unknowntlb, 0x2f, 0x1}, {"unknowntlb_op", mips_emit_unknowntlb, 0x30, 0x1}, {"unknowntlb_op", mips_emit_unknowntlb, 0x31, 0x1}, {"unknowntlb_op", mips_emit_unknowntlb, 0x32, 0x1}, {"unknowntlb_op", mips_emit_unknowntlb, 0x33, 0x1}, {"unknowntlb_op", mips_emit_unknowntlb, 0x34, 0x1}, {"unknowntlb_op", mips_emit_unknowntlb, 0x35, 0x1}, {"unknowntlb_op", mips_emit_unknowntlb, 0x36, 0x1}, {"unknowntlb_op", mips_emit_unknowntlb, 0x37, 0x1}, {"unknowntlb_op", mips_emit_unknowntlb, 0x38, 0x1}, {"unknowntlb_op", mips_emit_unknowntlb, 0x39, 0x1}, {"unknowntlb_op", mips_emit_unknowntlb, 0x3a, 0x1}, {"unknowntlb_op", mips_emit_unknowntlb, 0x3b, 0x1}, {"unknowntlb_op", mips_emit_unknowntlb, 0x3c, 0x1}, {"unknowntlb_op", mips_emit_unknowntlb, 0x3d, 0x1}, {"unknowntlb_op", mips_emit_unknowntlb, 0x3e, 0x1}, {"unknowntlb_op", mips_emit_unknowntlb, 0x3f, 0x1}, }; #endif ================================================ FILE: tools/virtualmips/x86_trans.h ================================================ /* * Cisco router simulation platform. * Copyright (c) 2005,2006 Christophe Fillot (cf@utc.fr) */ /* * Copyright (C) yajin 2008 * * This file is part of the virtualmips distribution. * See LICENSE file for terms of the license. * */ #ifndef __MIPS64_X86_TRANS_H__ #define __MIPS64_X86_TRANS_H__ #include "system.h" #include "x86-codegen.h" #ifdef _USE_JIT_ /* Manipulate bitmasks atomically */ static forced_inline void x86_atomic_or (m_uint32_t * v, m_uint32_t m) { __asm__ __volatile__ ("lock; orl %1,%0":"=m" (*v):"ir" (m), "m" (*v)); } static forced_inline void x86_atomic_and (m_uint32_t * v, m_uint32_t m) { __asm__ __volatile__ ("lock; andl %1,%0":"=m" (*v):"ir" (m), "m" (*v)); } /* Wrappers to x86-codegen functions */ #define mips_jit_tcb_set_patch x86_patch #define mips_jit_tcb_set_jump x86_jump_code /* Push epilog for an x86 instruction block */ static forced_inline void mips_jit_tcb_push_epilog (mips_jit_tcb_t * block) { x86_ret (block->jit_ptr); } /* Translated block function pointer */ typedef void (*insn_tblock_fptr) (void); void fastcall mips_exec_single_step (cpu_mips_t * cpu, mips_insn_t instruction); /* Execute JIT code */ static forced_inline void mips_jit_tcb_exec (cpu_mips_t * cpu, mips_jit_tcb_t * block) { insn_tblock_fptr jit_code; m_uint32_t offset; offset = (cpu->pc & MIPS_MIN_PAGE_IMASK) >> 2; jit_code = (insn_tblock_fptr) block->jit_insn_ptr[offset]; if (unlikely (!jit_code)) { mips_exec_single_step (cpu, vmtoh32 (block->mips_code[offset])); return; } asm volatile ("movl %0,%%edi"::"r" (cpu): "esi", "edi", "ecx", "edx"); jit_code (); } void mips_set_pc (mips_jit_tcb_t * b, m_va_t new_pc); void mips_emit_single_step (mips_jit_tcb_t * b, mips_insn_t insn); void mips_check_cpu_pausing (mips_jit_tcb_t * b); void mips_check_pending_irq (mips_jit_tcb_t * b); #endif #endif ================================================ FILE: usr.sbin/Makefile ================================================ # # Public domain - 1996/10/24 - sms # # @(#)Makefile 1.2 (2.11BSD) 1997/6/27 # TOPSRC!=cd ..; pwd include ${TOPSRC}/share/mk/sys.mk SUBDIR= chroot cron disktool iostat mkpasswd pstat talloc \ update vipw # TODO: devupdate all: ${SUBDIR} ${SUBDIR}: FRC cd $@; ${MAKE} ${MFLAGS} all FRC: install: FRC -for i in ${SUBDIR}; do \ (cd $$i; ${MAKE} ${MFLAGS} DESTDIR=${DESTDIR} install); done clean: /bin/rm -f a.out core *.s *.o *.dis *.elf *~ errs for i in ${SUBDIR}; do (cd $$i; ${MAKE} ${MFLAGS} clean); done